[cut: only the first 33554432 bytes of this file were read]
<?xml version="1.0" encoding="utf-8"?>
<posts>
  <row Id="1" PostTypeId="1" AcceptedAnswerId="5" CreationDate="2015-02-03T16:40:26.487" Score="45" ViewCount="11414" Body="&lt;p&gt;I'd like to see line numbers, starting with &lt;code&gt;1&lt;/code&gt; at the top, on the left side of Vim. Ideally it would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 | foo = Foo.new&#xA;2 | bar = Bar.new&#xA;3 | baz = foo.baz(bar)&#xA;...&#xA;10| test = AwesomeSauce.test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do this in Vim?&lt;/p&gt;&#xA;" OwnerDisplayName="user2" LastEditorDisplayName="user2" LastEditDate="2015-02-03T17:51:07.583" LastActivityDate="2018-12-12T18:05:13.460" Title="How can I add line numbers to Vim?" Tags="|line-numbers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2" PostTypeId="2" ParentId="1" CreationDate="2015-02-03T16:43:11.760" Score="23" Body="&lt;p&gt;You can use the command:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set number  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to turn on line numbering.  To turn it off again you can use:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nonumber   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want vim to always default to showing line numbers you can add the command to your &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nu&lt;/code&gt; and &lt;code&gt;nonu&lt;/code&gt; can be used as aliases for &lt;code&gt;number&lt;/code&gt; and &lt;code&gt;nonumber&lt;/code&gt; respectively.&lt;/p&gt;&#xA;" OwnerUserId="5" LastEditorUserId="1109" LastEditDate="2018-12-12T18:05:13.460" LastActivityDate="2018-12-12T18:05:13.460" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3" PostTypeId="1" AcceptedAnswerId="8" CreationDate="2015-02-03T16:54:26.737" Score="110" ViewCount="89852" Body="&lt;p&gt;A lot of vim commands can take a number referring to the number of lines that the command will act on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to show the line numbers relative to the current line? Something like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3: some text here&#xA;2: more text&#xA;1: This is the line above where the cursor is&#xA;0: The cursor is on this line&#xA;1: This is the line after the cursor&#xA;2: More text here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11" LastEditorUserId="28" LastEditDate="2015-02-03T16:55:58.233" LastActivityDate="2017-11-20T16:51:43.517" Title="How can I show relative line numbers?" Tags="|line-numbers|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4" PostTypeId="1" AcceptedAnswerId="43" CreationDate="2015-02-03T16:54:37.670" Score="45" ViewCount="17172" Body="&lt;p&gt;I'd like to have different indentations based on the type of file I am working on. For example, working on a &lt;code&gt;.c&lt;/code&gt; file I'd like my indentation be 4 spaces. In &lt;code&gt;.html&lt;/code&gt; files I'd like to (have to) work with tabs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I achieve that?&lt;/p&gt;&#xA;" OwnerUserId="12" LastEditorUserId="21062" LastEditDate="2019-08-06T22:20:56.890" LastActivityDate="2019-08-06T22:20:56.890" Title="How can I change the default indentation based on filetype?" Tags="|indentation|filetype|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5" PostTypeId="2" ParentId="1" CreationDate="2015-02-03T16:54:58.480" Score="57" Body="&lt;p&gt;You have two options:&#xA;&lt;code&gt;set number&lt;/code&gt; for regular line numbers&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And also&#xA;&lt;code&gt;set relativenumber&lt;/code&gt; which will show relative line numbers. i.e. current line is always 0. This is useful for moving up/down N number of lines using &lt;code&gt;5j&lt;/code&gt; for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is cool is that you can combine them. I have the following in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number                     &quot; Show current line number&#xA;set relativenumber             &quot; Show relative line numbers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will make it use relative numbers for all lines except the current line, which will show you the actual number.&lt;/p&gt;&#xA;" OwnerUserId="19" LastEditorUserId="135" LastEditDate="2015-02-03T21:05:27.990" LastActivityDate="2015-02-03T21:05:27.990" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6" PostTypeId="1" CreationDate="2015-02-03T16:55:25.927" Score="57" ViewCount="22224" Body="&lt;p&gt;The last news item on &lt;a href=&quot;http://www.vim.org/&quot;&gt;vim.org&lt;/a&gt; talks about using the 'undofile' to save your history and undo changes even after a reboot:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A feature I enjoy using myself is not known to many users, as I found out last weekend. Besides undo with as many levels as you like, Vim also offers storing the undo information in a file. So you can exit Vim, reboot your computer and still undo changes you made. See the help for 'undofile'. &lt;em&gt;(Bram Moolenaar)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How can I enable and use this feature?&lt;/p&gt;&#xA;" OwnerDisplayName="user2" LastEditorUserId="24" LastEditDate="2015-02-05T08:44:10.167" LastActivityDate="2020-11-25T17:31:04.880" Title="How can I use the undofile?" Tags="|persistent-state|undo-redo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7" PostTypeId="2" ParentId="3" CreationDate="2015-02-03T16:56:53.240" Score="5" Body="&lt;pre&gt;&lt;code&gt;function! NumberToggle()&#xA;  if(&amp;amp;relativenumber == 1)&#xA;    set norelativenumber&#xA;  else&#xA;    set relativenumber&#xA;  endif&#xA;endfunc&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;nt :call NumberToggle()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27" LastActivityDate="2015-02-03T16:56:53.240" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8" PostTypeId="2" ParentId="3" CreationDate="2015-02-03T16:58:00.347" Score="133" Body="&lt;p&gt;I just replied to a similar question here: &lt;a href=&quot;https://vi.stackexchange.com/questions/1/how-can-i-add-line-numbers-to-vim&quot;&gt;How can I add line numbers to Vim?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beginning with version 7.3, you can use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set relativenumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I actually use both &lt;code&gt;relativenumber&lt;/code&gt; and &lt;code&gt;number&lt;/code&gt; in my vimrc which will use relative numbers for all lines except the current line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number                     &quot; Show current line number&#xA;set relativenumber             &quot; Show relative line numbers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2015-02-03T21:58:31.907" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9" PostTypeId="1" AcceptedAnswerId="23" CreationDate="2015-02-03T16:58:07.553" Score="23" ViewCount="1446" Body="&lt;p&gt;Vimscript looks somewhat similar to Python code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can Vim be integrated with high-level language interpreters, such as Python?&lt;/p&gt;&#xA;" OwnerUserId="28" LastEditorUserId="343" LastEditDate="2016-02-10T10:55:41.193" LastActivityDate="2016-02-10T10:55:41.193" Title="Can I script Vim using Python?" Tags="|vimscript-python|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10" PostTypeId="2" ParentId="4" CreationDate="2015-02-03T16:59:52.260" Score="12" Body="&lt;p&gt;&lt;code&gt;augroup&lt;/code&gt; allows you to group related autocommands into named groups. (See &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/14.html&quot;&gt;here&lt;/a&gt; to learn about Autocommand Groups.) We use &lt;code&gt;augroup&lt;/code&gt;s to add autocommands to &lt;code&gt;~/.vimrc&lt;/code&gt; in a way that won't add a duplicate every time we source it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc&#xA;  autocmd!&#xA;augroup END&#xA;&#xA;autocmd vimrc FileType html setlocal shiftwidth=4 tabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27" LastEditorUserId="27" LastEditDate="2015-02-03T17:06:20.293" LastActivityDate="2015-02-03T17:06:20.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11" PostTypeId="2" ParentId="4" CreationDate="2015-02-03T17:00:05.557" Score="14" Body="&lt;p&gt;You can do this with autocommands in your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I have a function &lt;code&gt;html_like_mode&lt;/code&gt; that sets up various things for editing HTML files. In my &lt;code&gt;.vimrc&lt;/code&gt;, I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.html call s:html_like_mode()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That keys off of the file extension. You can also key off of the filetype, if you have that enabled:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType perl setlocal equalprg=perltidy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, you can have it do any command there. So you could easily do a &lt;code&gt;setlocal shiftwidth 4&lt;/code&gt; for your *.c files. &lt;/p&gt;&#xA;" OwnerUserId="31" LastActivityDate="2015-02-03T17:00:05.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12" PostTypeId="1" AcceptedAnswerId="14" CreationDate="2015-02-03T17:00:19.820" Score="39" ViewCount="7462" Body="&lt;p&gt;Starting from a blank slate, how can I obtain a document that contains&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;2&#xA;3&#xA;4&#xA;5&#xA;6&#xA;7&#xA;8&#xA;9&#xA;10&#xA;…&#xA;100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To be clear, I don't want these numbers displayed in the margin; I want them inserted into the document itself.&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2016-12-07T20:47:09.990" Title="How can I generate a list of sequential numbers, one per line?" Tags="|line-numbers|text-generation|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13" PostTypeId="1" AcceptedAnswerId="2561" CreationDate="2015-02-03T17:01:08.817" Score="14" ViewCount="1184" Body="&lt;p&gt;Actually, I hit this problem when I used ssh from my android phone to log in into a linux server, and I tried to use vim to edit some files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It was a little bit... displeasing, although I could do everything which I could do from a normal desktop/keyboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Extension:&lt;/em&gt; There was a question, why it was displeasing if I could do anything I wanted. For example, typing &lt;code&gt;5j45|&lt;/code&gt; on an emulated keyboard on a touchscreen has a &lt;em&gt;much&lt;/em&gt; lower information rate (between your brain and your device) as touching the intended character position on a touchscreen.&lt;/p&gt;&#xA;" OwnerUserId="28" LastEditorUserId="28" LastEditDate="2015-02-11T09:12:42.553" LastActivityDate="2021-09-23T14:27:44.810" Title="Does any solution exist to use vim from touch screen?" Tags="|input-devices|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14" PostTypeId="2" ParentId="12" CreationDate="2015-02-03T17:02:14.507" Score="56" Body="&lt;p&gt;Use &lt;code&gt;:put&lt;/code&gt; and &lt;code&gt;range()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put =range(1,100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To avoid the blank line at the top (&lt;a href=&quot;https://vi.stackexchange.com/questions/12/how-can-i-generate-a-list-of-sequential-numbers-one-per-line#comment15_14&quot;&gt;kudos to romainl&lt;/a&gt;), use &lt;code&gt;:0put&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:0put =range(1,100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user2" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-03T17:41:33.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15" PostTypeId="2" ParentId="4" CreationDate="2015-02-03T17:03:20.783" Score="8" Body="&lt;p&gt;Used &lt;strong&gt;autocmd&lt;/strong&gt; and &lt;strong&gt;FileType&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType html setlocal shiftwidth=4 tabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="37" LastActivityDate="2015-02-03T17:03:20.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16" PostTypeId="1" AcceptedAnswerId="47" CreationDate="2015-02-03T17:03:23.567" Score="9" ViewCount="179" Body="&lt;p&gt;It is normally on the left side, and it enables a fast switching between files in a complex directory hierarchy.&lt;/p&gt;&#xA;" OwnerUserId="28" LastEditorUserId="33" LastEditDate="2015-02-03T17:47:06.440" LastActivityDate="2015-02-03T21:07:24.633" Title="Can I use some file-tree selector which exists on graphical IDEs?" Tags="|filesystem|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17" PostTypeId="1" CreationDate="2015-02-03T17:05:28.760" Score="15" ViewCount="3498" Body="&lt;p&gt;This is a problem I had recently. I have a file with several hundred lines of text. How can I search for a string between two specific line numbers? For e.g. I want to search between line numbers 100 and 325.&lt;/p&gt;&#xA;" OwnerUserId="5" LastActivityDate="2019-10-03T12:00:35.497" Title="How can I search for a string between certain line numbers?" Tags="|line-numbers|search|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18" PostTypeId="2" ParentId="12" CreationDate="2015-02-03T17:05:31.460" Score="20" Body="&lt;p&gt;In addition to Undo's pure-vim &lt;code&gt;:put =range(1,100)&lt;/code&gt; (which actually leaves you with a blank line up top), you can, depending on your OS, use one of its commands. E.g., on a Unix/Linux box:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%!seq 1 100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above works by piping the entire (empty) buffer to &lt;code&gt;seq&lt;/code&gt;, which ignores its input and just outputs the numbers 1 to 100. Vim then replaces the entire buffer with &lt;code&gt;seq&lt;/code&gt;'s output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's useful when you're already familiar with some command-line way to get what you want.&lt;/p&gt;&#xA;" OwnerUserId="31" LastActivityDate="2015-02-03T17:05:31.460" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19" PostTypeId="1" AcceptedAnswerId="33" CreationDate="2015-02-03T17:05:49.273" Score="31" ViewCount="1544" Body="&lt;p&gt;When using &lt;kbd&gt;ci&quot;&lt;/kbd&gt; the cursor does not have to reside in the double quoted area. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|String somestring = &quot;some text&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming the pipe is the cursor position, &lt;kbd&gt;ci&quot;&lt;/kbd&gt; will make it jump to the quoted area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, when using &lt;kbd&gt;ci(&lt;/kbd&gt;, the cursor must be inside the parentheses to work and will not move the cursor inside them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the reason for this difference in behavior?&#xA;I assume there is a way to map the keys so that this behavior is present. Are there any drawbacks to doing this?&lt;/p&gt;&#xA;" OwnerUserId="18" LastEditorUserId="1292" LastEditDate="2018-08-17T20:19:40.253" LastActivityDate="2020-10-05T02:33:40.007" Title="Why can ci&quot; be outside of quoted area and ci( only works inside parentheses?" Tags="|cursor-motions|cursor-movement|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20" PostTypeId="2" ParentId="16" CreationDate="2015-02-03T17:05:49.540" Score="4" Body="&lt;p&gt;If &lt;strong&gt;nerdtree&lt;/strong&gt; set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:NERDTreeWinPos = &quot;right&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="37" LastActivityDate="2015-02-03T17:05:49.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23" PostTypeId="2" ParentId="9" CreationDate="2015-02-03T17:15:05.140" Score="20" Body="&lt;p&gt;Yes, vim can be built with several different language interpreters available. This is something you (or your distro) picked when compiling vim from source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Available at least are Python (as you requested), Perl, Ruby, and Tcl. The vim documentation has details for each; the python one is in &lt;a href=&quot;http://vimhelp.appspot.com/if_pyth.txt.html&quot;&gt;&lt;code&gt;:help if_pyth.txt&lt;/code&gt;&lt;/a&gt;. That document has plenty of examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, here are the ones for other languages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Perl: &lt;a href=&quot;http://vimhelp.appspot.com/if_perl.txt.html&quot;&gt;&lt;code&gt;:help if_perl.txt&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Ruby: &lt;a href=&quot;http://vimhelp.appspot.com/if_ruby.txt.html&quot;&gt;&lt;code&gt;:help if_ruby.txt&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Tcl: &lt;a href=&quot;http://vimhelp.appspot.com/if_tcl.txt.html&quot;&gt;&lt;code&gt;:help if_tcl.txt&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Lua: &lt;a href=&quot;http://vimhelp.appspot.com/if_lua.txt.html&quot;&gt;&lt;code&gt;:help if_lua.txt&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;MzScheme: &lt;a href=&quot;http://vimhelp.appspot.com/if_mzsch.txt.html&quot;&gt;&lt;code&gt;:help if_mzscheme.txt&lt;/code&gt;&lt;/a&gt; (It's called Racket now, but in Vim it's still called MzScheme for historical reasons).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="31" LastEditorUserId="51" LastEditDate="2015-08-08T18:56:44.530" LastActivityDate="2015-08-08T18:56:44.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24" PostTypeId="1" AcceptedAnswerId="26" CreationDate="2015-02-03T17:15:37.783" Score="60" ViewCount="11162" Body="&lt;p&gt;When I do a change in my &lt;code&gt;.vimrc&lt;/code&gt;, I usually exit Vim and open it again. Is there an easier way to reload the new &lt;code&gt;.vimrc&lt;/code&gt; changes?&lt;/p&gt;&#xA;" OwnerUserId="53" LastActivityDate="2016-09-02T14:26:07.110" Title="How do I reload my vimrc without leaving Vim?" Tags="|vimrc|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25" PostTypeId="1" CreationDate="2015-02-03T17:17:19.700" Score="10" ViewCount="523" Body="&lt;p&gt;When I write a script in gedit, the commands, comments, variables etc... are given different colors. How do I setup vim to do the same?&lt;/p&gt;&#xA;" OwnerUserId="17" LastEditorUserId="5" LastEditDate="2015-02-03T17:25:31.333" LastActivityDate="2015-02-03T17:25:31.333" Title="How can I add syntax highlighting to vim as I can do in gedit?" Tags="|syntax-highlighting|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26" PostTypeId="2" ParentId="24" CreationDate="2015-02-03T17:18:16.467" Score="58" Body="&lt;p&gt;Run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:source $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;inside Vim to reload the &lt;code&gt;vimrc&lt;/code&gt; file. Or, a shorter version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:so $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as mentioned in a comment by &lt;a href=&quot;https://vi.stackexchange.com/users/467/kenorb&quot;&gt;kenorb&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also find it useful to map either of these forms to a key. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;r :source $MYVIMRC&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-21T04:34:01.737" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="27" PostTypeId="2" ParentId="17" CreationDate="2015-02-03T17:19:20.177" Score="7" Body="&lt;pre&gt;&lt;code&gt;:100,235g/foo/#&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then press &lt;code&gt;:147&amp;lt;CR&amp;gt;&lt;/code&gt; to jump to the desired line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;:ilist&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:100,235il foo&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help range&lt;/code&gt;, &lt;code&gt;:help :global&lt;/code&gt; and &lt;code&gt;:help :ilist&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-02-03T17:37:25.613" LastActivityDate="2015-02-03T17:37:25.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28" PostTypeId="2" ParentId="9" CreationDate="2015-02-03T17:21:22.127" Score="6" Body="&lt;p&gt;Yes, you can create routines with high level languages such as python, ruby, perl, among other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To see what languages your vim supports:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="37" LastEditorUserId="67" LastEditDate="2015-02-03T17:47:16.883" LastActivityDate="2015-02-03T17:47:16.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="29" PostTypeId="2" ParentId="25" CreationDate="2015-02-03T17:22:50.620" Score="8" Body="&lt;p&gt;Try &lt;code&gt;:syntax on&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To have syntax highlighting enabled by default, add the following line to your &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the file doesn't exist, create it.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-02-03T17:22:50.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="30" PostTypeId="2" ParentId="25" CreationDate="2015-02-03T17:23:12.400" Score="10" Body="&lt;p&gt;vim has an extensive support for syntax highlighting and typical distributions contain a number of highlighting rules. For enabling this you have to switch the syntax module on using &lt;code&gt;:syntax on&lt;/code&gt; in your vim session or globally your &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html&quot;&gt;vim help on syntax&lt;/a&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="59" LastActivityDate="2015-02-03T17:23:12.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="31" PostTypeId="1" AcceptedAnswerId="38" CreationDate="2015-02-03T17:23:17.467" Score="17" ViewCount="1847" Body="&lt;p&gt;I usually need to move/copy code snippets between my source files. After I paste a block of text, I usually need to apply some operation to that block such as reindenting them with &lt;code&gt;=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to easily visually select the block of text I just pasted without doing it manually?&lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="24" LastEditDate="2015-02-19T10:09:01.483" LastActivityDate="2015-02-19T10:09:01.483" Title="How do I visually select the block of text I just pasted in Vim?" Tags="|cut-copy-paste|visual-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="32" PostTypeId="2" ParentId="19" CreationDate="2015-02-03T17:24:29.370" Score="10" Body="&lt;p&gt;The quote family of text objects (&lt;code&gt;i'&lt;/code&gt;, &lt;code&gt;i&quot;&lt;/code&gt;, &lt;code&gt;a'&lt;/code&gt;, and &lt;code&gt;a&quot;&lt;/code&gt;) are different than the rest of the text objects in that they only look at the current line.  Due to this, the choice was made not to require the cursor to be within the quotes.  Instead, Vim will search forward within the line to find a quoted string when the cursor isn't already inside one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a &lt;a href=&quot;http://article.gmane.org/gmane.editors.vim.devel/43570&quot;&gt;discussion&lt;/a&gt; around some patches which would allow this forward searching behavior to be implemented for block based text objects as well.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-02-03T17:24:29.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="33" PostTypeId="2" ParentId="19" CreationDate="2015-02-03T17:25:15.577" Score="28" Body="&lt;p&gt;The main difference here is that parenthetical statements (targeted by &lt;code&gt;ci(&lt;/code&gt;) can be nested, while quoted strings (targeted by &lt;code&gt;ci&quot;&lt;/code&gt;) cannot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your cursor is outside of some parenthetical statement, it could still be inside of some other one. For example (&lt;code&gt;*&lt;/code&gt; marks the cursor position):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$foo = array(&#xA;    'x' =&amp;gt; ar*ray(1, 2, 3),&#xA;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The line the cursor is on contains &lt;code&gt;(1, 2, 3)&lt;/code&gt;, but the cursor is also inside the larger &lt;code&gt;array(...)&lt;/code&gt; block. In this case, the larger one is the appropriate target for &lt;code&gt;ci(&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your cursor is outside of some quoted string, since they can't be nested, there's no perfectly sensible thing to do. So, Vim takes advantage and finds the first quoted string on the line.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-02-03T17:25:15.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="34" PostTypeId="1" CreationDate="2015-02-03T17:28:04.373" Score="197" ViewCount="97858" Body="&lt;p&gt;I've been hearing about &lt;a href=&quot;http://neovim.org/&quot;&gt;Neovim&lt;/a&gt;; how does it differ from Vim? All the points on the homepage are just architectural changes 'under the hood'. As a user, what's the difference for me?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2022-09-21T12:34:48.153" LastActivityDate="2022-09-21T12:34:48.153" Title="What is Neovim, and how is it different from Vim?" Tags="|neovim|" AnswerCount="6" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="35" PostTypeId="2" ParentId="31" CreationDate="2015-02-03T17:28:42.477" Score="17" Body="&lt;p&gt;This mapping allows you to reselect the text you just pasted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gV `[v`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But you should have used &lt;code&gt;[p&lt;/code&gt; and &lt;code&gt;]p&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help [p&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-02-03T17:28:42.477" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="36" PostTypeId="1" AcceptedAnswerId="46" CreationDate="2015-02-03T17:28:50.227" Score="10" ViewCount="607" Body="&lt;p&gt;Folding is useful to hide away parts of the document. A visual representation of the folding structure as a tree would be useful for understanding the document structure at a glance.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2015-02-03T17:47:52.287" Title="Is there a way to display folded parts as a tree?" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="37" PostTypeId="2" ParentId="31" CreationDate="2015-02-03T17:29:09.693" Score="3" Body="&lt;p&gt;Vim includes the following helpful mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which select the first and last character of previously changed text, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following series of keys (in normal mode) will select the last pasted text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`[v`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For faster access, you could set up a mapping, &lt;a href=&quot;http://vim.wikia.com/wiki/Selecting_your_pasted_text&quot; rel=&quot;nofollow&quot;&gt;for example&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gp `[v`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="58" LastActivityDate="2015-02-03T17:29:09.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="38" PostTypeId="2" ParentId="31" CreationDate="2015-02-03T17:30:38.580" Score="25" Body="&lt;p&gt;The &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt; marks delimit the first and last line of the previously changed or yanked text.  The &lt;code&gt;`[&lt;/code&gt; and &lt;code&gt;`]&lt;/code&gt; counterparts delimit the respective lines &amp;amp; columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using that, you could visually select the last changed block of lines with &lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt; and then apply the &lt;code&gt;=&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, since a paste leaves your cursor at the first line of the content that was pasted, you could also just specify a motion over which the &lt;code&gt;=&lt;/code&gt; command should be applied, in this case to the &lt;code&gt;']&lt;/code&gt; mark.  This would be &lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-02-03T17:30:38.580" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="39" PostTypeId="1" AcceptedAnswerId="190" CreationDate="2015-02-03T17:30:57.097" Score="73" ViewCount="114577" Body="&lt;p&gt;Many IDEs automatically complete function names, variables, method names, etc. as the user types. The best ones complete the names based both on the language's built-in library as well as what has already been defined in other files of the same program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, as I'm typing the following Python program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hungy = True&#xA;&#xA;def eatFood(food):&#xA;    pass&#xA;&#xA;if hungry:&#xA;    eatF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the line &lt;code&gt;eatF&lt;/code&gt; would automatically show &lt;code&gt;eatFood()&lt;/code&gt; as an available auto-complete option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does Vim have this capability? If so, how can I enable it?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="88" LastEditDate="2015-02-04T01:35:55.463" LastActivityDate="2022-09-13T15:47:01.673" Title="Is it possible to have vim auto-complete function names, variables, etc. when using it to program?" Tags="|autocompletion|ide|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="40" PostTypeId="1" AcceptedAnswerId="48" CreationDate="2015-02-03T17:31:50.490" Score="51" ViewCount="31220" Body="&lt;p&gt;Is there a way to center the line I'm editing in the screen? This is sometimes needed to see a bit more context above and below the current line.&lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="48490" LastEditDate="2023-09-01T02:43:44.460" LastActivityDate="2023-09-01T02:43:44.460" Title="How do I center the current line in the screen?" Tags="|cursor-movement|scrolling|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="41" PostTypeId="2" ParentId="24" CreationDate="2015-02-03T17:32:00.757" Score="22" Body="&lt;p&gt;If you just want to reload the file once in a while&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:source $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as Paul wrote is correct. If you end up changing your vimrc often, you could add something like this to your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost .vimrc,_vimrc source $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will reload the file when you write it (from within that vim session)&lt;/p&gt;&#xA;" OwnerUserId="59" LastEditorUserId="51" LastEditDate="2015-02-20T22:35:43.030" LastActivityDate="2015-02-20T22:35:43.030" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="42" PostTypeId="1" AcceptedAnswerId="416" CreationDate="2015-02-03T17:33:26.077" Score="16" ViewCount="604" Body="&lt;p&gt;I have a number of JavaScript files where the strings are snippets of HTML to be inserted into the webpage. Vim performs syntax highlighting on the JavaScript, and highlights the quoted strings as such. It seems to go beyond highlighting, in fact: within a quote, vim does not match the &lt;code&gt;&amp;lt;&lt;/code&gt; that begins a tag with the &lt;code&gt;&amp;gt;&lt;/code&gt; that ends it when using &lt;kbd&gt;%&lt;/kbd&gt;; it seems to assume things like brackets don't exist in string literals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to indicate to vim that string literals should be treated as code in a separate language?&lt;/p&gt;&#xA;" OwnerUserId="29" LastEditorUserId="29" LastEditDate="2015-02-03T19:54:26.397" LastActivityDate="2017-12-05T01:20:01.560" Title="Treat string literals as a different language" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="43" PostTypeId="2" ParentId="4" CreationDate="2015-02-03T17:33:54.150" Score="33" Body="&lt;p&gt;The best method is to put those settings in &lt;code&gt;~/.vim/after/ftplugin/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For HTML (assuming you want 4 characters-wide tabs):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/after/ftplugin/html.vim&#xA;&#xA;setlocal shiftwidth=4&#xA;setlocal softtabstop=4&#xA;setlocal noexpandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using an ftplugin is prefered to using autocommands because Vim already does filetype checks by itself and already tries to source the adequate ftplugin so there's no reason to force even more checks and reimplement the wheel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-- edit --&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you have &lt;code&gt;filetype plugin on&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt; — which you should — Vim will try to detect the filetype of the files you edit and, once the correct filetype is found and set for the buffer, try to source the corresponding ftplugin in these standard locations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$VIMRUNTIME/ftplugin/html.vim&#xA;~/.vim/ftplugin/html.vim&#xA;~/.vim/ftplugin/after/html.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All of that happens &lt;em&gt;automatically&lt;/em&gt; so, if your filetype is recognized by Vim, there is absolutely no reason to add any filetype detection logic: just add your settings to the right ftplugin and you are good.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-02-03T20:47:51.393" LastActivityDate="2015-02-03T20:47:51.393" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="44" PostTypeId="2" ParentId="40" CreationDate="2015-02-03T17:35:26.433" Score="14" Body="&lt;p&gt;Type &lt;code&gt;zz&lt;/code&gt; to center the current line in the screen:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/vj73x.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user2" LastActivityDate="2015-02-03T17:35:26.433" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="46" PostTypeId="2" ParentId="36" CreationDate="2015-02-03T17:35:57.367" Score="11" Body="&lt;p&gt;You can use &lt;code&gt;:set foldcolumn=&amp;lt;number&amp;gt;&lt;/code&gt; to display a &lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;-wide column that tries to visualize fold levels. It would look something like this, by default (with a marker fold method, using &lt;code&gt;{{{&lt;/code&gt; and &lt;code&gt;}}}&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-    {{{ Top Level Fold&#xA;|-   {{{ Nested Fold&#xA;||-  {{{ Deepest Fold&#xA;|||  }}}&#xA;||   }}}&#xA;|-   {{{ Another Nested Fold&#xA;||   }}}&#xA;|    }}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this consumes quite a lot of horizontal real-estate. Another method would be to write a custom &lt;code&gt;foldtext()&lt;/code&gt; implementation which reads the fold level with &lt;code&gt;foldlevel()&lt;/code&gt; and formats accordingly. This will waste less horizontal space, but won't really be as helpful for visually understanding the tree since you can't see the folds underneath a collapsed fold. For example, your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldtext=CustomFoldText()&#xA;function! CustomFoldText()&#xA;  let line = getline(v:foldstart) . &quot;...&quot;&#xA;  return repeat(&quot;--| &quot;, v:foldlevel) . line&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are plugins that provide on-demand visualizations of the fold hierarchy, such as &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=732&quot;&gt;folddigest.vim&lt;/a&gt;, as well. They work, essentially, by parsing the fold level of every line, building up an appropriate data structure, and dumping a visualization of the data structure to a new buffer. You could probably adapt the technique to your own needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also want to look at plugins that provide &quot;indent guides,&quot; such as &lt;a href=&quot;https://github.com/nathanaelkane/vim-indent-guides&quot;&gt;this one&lt;/a&gt;. I've never personally used them, and I hear they cause some people performance issues since they generally involve generating lots of custom match highlights via &lt;code&gt;matchadd()&lt;/code&gt;, but your mileage may vary.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorDisplayName="user72" LastEditDate="2015-02-03T17:47:52.287" LastActivityDate="2015-02-03T17:47:52.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="47" PostTypeId="2" ParentId="16" CreationDate="2015-02-03T17:36:26.180" Score="8" Body="&lt;p&gt;Vim comes with a built-in file explorer called netrw. If you have a reasonaby recent Vim, the following command will give you the kind of feature you are missing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Lexplore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help netrw&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-02-03T17:36:26.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="48" PostTypeId="2" ParentId="40" CreationDate="2015-02-03T17:36:59.543" Score="75" Body="&lt;p&gt;The &lt;code&gt;z.&lt;/code&gt; and &lt;code&gt;zz&lt;/code&gt; commands will recenter the line the cursor is on.  &lt;code&gt;z.&lt;/code&gt; also moves the cursor to the first non-whitespace character in the line, while &lt;code&gt;zz&lt;/code&gt; keeps the cursor where it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are similar commands for the top (&lt;code&gt;z&amp;lt;CR&amp;gt;&lt;/code&gt;/&lt;code&gt;zt&lt;/code&gt;) and bottom (&lt;code&gt;z-&lt;/code&gt;/&lt;code&gt;zb&lt;/code&gt;) of the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The versions of these commands that end in a letter keep the cursor column, while the ones ending in punctuation move the cursor.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-02-03T17:36:59.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="49" PostTypeId="2" ParentId="40" CreationDate="2015-02-03T17:37:19.330" Score="6" Body="&lt;p&gt;Yes, in normal mode you can use &lt;code&gt;zz&lt;/code&gt; to do so. But as the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/scroll.html#zz&quot; rel=&quot;noreferrer&quot;&gt;docs&lt;/a&gt; forewarn, be careful with capslock as &lt;code&gt;ZZ&lt;/code&gt; will write the buffer to file and quit.&lt;/p&gt;&#xA;" OwnerUserId="44" LastActivityDate="2015-02-03T17:37:19.330" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="50" PostTypeId="2" ParentId="40" CreationDate="2015-02-03T17:37:38.970" Score="4" Body="&lt;p&gt;In normal mode, &lt;code&gt;zz&lt;/code&gt; will move the line currently under the cursor to the center of the screen.&lt;/p&gt;&#xA;" OwnerUserId="78" LastEditorUserId="88" LastEditDate="2015-02-04T01:29:58.057" LastActivityDate="2015-02-04T01:29:58.057" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="51" PostTypeId="2" ParentId="34" CreationDate="2015-02-03T17:37:58.987" Score="129" Body="&lt;p&gt;Just like the neovim homepage describes, neovim's objective is to pave the way for a better &amp;amp; more openly community driven open source project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The architectural changes not only will bring more stability &amp;amp; improve performance to vim but make the code a lot more maintainable and bring the entry barrier slightly down for anyone who is interested to contribute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the key changes also includes the core feature of access to executing jobs / tasks asynchronously in vim, which has been one of the most requested feature of vim since a long time. This can help improve performance of vim even further especially because vim will not have to block while a background job is doing something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a vim user, not much might change besides the fact that neovim should grow as a software much faster (fix issues, add features) as compared to stock vim and that it will have much better performance in the long run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit (10 June, 2020)&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I think I missed mentioning one key aspect that differentiates VIM&#xA;  from NeoVIM as an open source software.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The underlying problem (whether or not this is a problem is subjective)&#xA;  with VIM has been that Bram Moolenar, the core contributor is the Gate&#xA;  Keeper and to some extent the bottleneck that prevents changes / fixes&#xA;  / new ideas from other developers making into VIM at a fast pace.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;NeoVIM has a strong focus on community contribution and hence is more&#xA;  open in that regards. Also helps that there are several core&#xA;  contributors, not just one.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;One interesting side-effect of having NeoVIM is that since it directly competes with VIM, it has resulted in Bram be more open to bringing radical innovations to VIM, which in the absense of NeoVIM he would not have. Things like background jobs, popup windows (floating windows) / text properties, inline terminal, etc are examples of ideas that have been added to VIM because they were saught out features that were added to NeoVIM, even though there has been demand for many of these features since long.&lt;/p&gt;&#xA;" OwnerUserId="74" LastEditorUserId="74" LastEditDate="2020-06-10T18:14:35.433" LastActivityDate="2020-06-10T18:14:35.433" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="52" PostTypeId="1" AcceptedAnswerId="59" CreationDate="2015-02-03T17:38:13.723" Score="55" ViewCount="13272" Body="&lt;p&gt;I work on a range of JavaScript projects. In most of these projects, the indentation of JavaScript files is 2 spaces, so I've set my default indentation width to that. However it becomes 1 or 4 in some other projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to ask Vim to change the indentation style based on the style already used in the current file?&lt;/p&gt;&#xA;" OwnerUserId="53" LastActivityDate="2023-02-22T09:55:18.137" Title="How do I make Vim adapt to the current indenting style of the file I'm editing?" Tags="|indentation|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="53" PostTypeId="2" ParentId="6" CreationDate="2015-02-03T17:39:54.577" Score="67" Body="&lt;p&gt;The simplest version is: create &lt;code&gt;~/.vim/undo-dir/&lt;/code&gt; directory and add the following to the &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set undodir=~/.vim/undo-dir&#xA;set undofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, it's not flawless, and it's better to read on. From my own &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Let's save undo info!&#xA;if !isdirectory($HOME.&amp;quot;/.vim&amp;quot;)&#xA;    call mkdir($HOME.&amp;quot;/.vim&amp;quot;, &amp;quot;&amp;quot;, 0770)&#xA;endif&#xA;if !isdirectory($HOME.&amp;quot;/.vim/undo-dir&amp;quot;)&#xA;    call mkdir($HOME.&amp;quot;/.vim/undo-dir&amp;quot;, &amp;quot;&amp;quot;, 0700)&#xA;endif&#xA;set undodir=~/.vim/undo-dir&#xA;set undofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I prefer not to clutter random directories with undo files. So I set the &lt;code&gt;undodir&lt;/code&gt; option, which puts all of them in one undo directory. That leaves one problem—I'm lazy, and don't feel like creating that directory on all my machines (I use a version control system to sync my &lt;code&gt;.vimrc&lt;/code&gt; across a bunch of machines). Thankfully, it's easy enough to have Vim check for and create the directories if they don't exist.&lt;/p&gt;&#xA;&lt;p&gt;Note also the &lt;code&gt;0700&lt;/code&gt; mode on the undo directory (that's full permissions for the owner, no permissions for anyone else). Which files I've edited, when, etc. should stay private. And since this is a directory only I can access, I don't have to worry about someone else putting a symlink in there, or their own undo file, or whatever as you'd have to worry about using a system temporary directory.&lt;/p&gt;&#xA;&lt;p&gt;Finally, not being a system temporary directory, it's not subject to the system tempfile cleanup policy. Often, that's fairly short—a week or so. But to keep it from growing forever, I put the following in my &lt;code&gt;crontab&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# m h  dom mon dow   command&#xA; 43 00 *   *   3     find /home/anthony/.vim/undo-dir -type f -mtime +90 -delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So after 90 days of not being modified, they're deleted. (Honestly, they're not really that big, and you could easily leave them forever with how cheap disk is. But consider also your own privacy if your machine is ever compromised.)&lt;/p&gt;&#xA;" OwnerUserId="31" LastEditorUserId="10604" LastEditDate="2020-11-25T17:31:04.880" LastActivityDate="2020-11-25T17:31:04.880" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="54" PostTypeId="2" ParentId="39" CreationDate="2015-02-03T17:41:48.150" Score="23" Body="&lt;p&gt;Vim has support for completion natively. You can read about the various different completions that Vim supports at &lt;code&gt;:h ins-completion&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, for all purposes I have found, ins-completions are enough for my liking, however there are some completion plugins that add more value beyond what ins-completions offers. &lt;a href=&quot;https://github.com/Shougo/neocomplete.vim&quot; rel=&quot;noreferrer&quot;&gt;NeoComplete&lt;/a&gt;, &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;noreferrer&quot;&gt;YCM (YouCompleteMe)&lt;/a&gt; are a few for the same. They are more advanced in the sense that they try to combine different types of completions more accurately, and they also have advanced caching mechanisms, so they tend to be faster. YCM even goes to the extent to work with external compilers / utilities to provide better IntelliSense.&lt;/p&gt;&#xA;" OwnerUserId="74" LastEditorUserId="927" LastEditDate="2017-07-15T02:56:50.410" LastActivityDate="2017-07-15T02:56:50.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="55" PostTypeId="2" ParentId="39" CreationDate="2015-02-03T17:42:01.103" Score="9" Body="&lt;p&gt;Yes, auto completion scripts for vim exist. The &quot;best&quot; choice is depending on your programming language. As your example code is Python I suggest to take a look at &lt;a href=&quot;https://github.com/davidhalter/jedi&quot;&gt;Jedi&lt;/a&gt;. Build on top of that &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot;&gt;You complete me&lt;/a&gt; exists, which also has support for other languages, but is sometimes seen as too big. For other languages you can browse through the long set on &lt;a href=&quot;http://www.vim.org/scripts/script_search_results.php?keywords=completion&amp;amp;script_type=&amp;amp;order_by=rating&amp;amp;direction=descending&amp;amp;search=search&quot;&gt;vim scripts&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="59" LastActivityDate="2015-02-03T17:42:01.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="56" PostTypeId="1" AcceptedAnswerId="69" CreationDate="2015-02-03T17:42:18.780" Score="14" ViewCount="3209" Body="&lt;p&gt;By default, &lt;code&gt;vim&lt;/code&gt; leaves swap files in my project directory, and on crashes it leaves backup files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I prevent this? Or do I need to update all my projects' &lt;code&gt;.VCSignore&lt;/code&gt; file?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-03T18:08:17.863" LastActivityDate="2022-11-02T19:02:27.637" Title="How can I prevent Vim from leaving too many files (like swap, backup, undo)?" Tags="|crash-recovery|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="57" PostTypeId="2" ParentId="56" CreationDate="2015-02-03T17:42:18.780" Score="1" Body="&lt;p&gt;This is what I do in my vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fun! MkdirIfNeeded(dir, flags, permissions)&#xA;    if !isdirectory(a:dir)&#xA;        call mkdir(a:dir, a:flags, a:permissions)&#xA;    endif&#xA;endfun&#xA;&#xA;&amp;quot; Set (&amp;amp; create if needed) a temp directory to keep backup &amp;amp; swap files&#xA;if has('win32')&#xA;    let whoami = substitute(system(&amp;quot;whoami /LOGONID&amp;quot;), '\n', '', '')&#xA;    let tmpdir = 'C:/tmp/vim_' . whoami&#xA;else&#xA;    let whoami = substitute(system(&amp;quot;whoami&amp;quot;), '\n', '', '')&#xA;    let tmpdir = '/var/tmp/vim_' . whoami&#xA;endif&#xA;call MkdirIfNeeded(tmpdir, 'p', 0700)&#xA;&#xA;let &amp;amp;backupdir = tmpdir&#xA;let &amp;amp;dir = tmpdir&#xA;let &amp;amp;undodir = tmpdir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It will create &lt;code&gt;/var/tmp/vim_&amp;lt;username&amp;gt;&lt;/code&gt;, and use this to store all vim-related files, keeping your project directory clean.&lt;/p&gt;&#xA;&lt;p&gt;Using &lt;code&gt;whoami&lt;/code&gt; makes sure you can use the vimrc globally (ie. for the user &amp;amp; root) while still using separate directories; if you don't need this, you could replace it with a hard coded directory for faster startup. You could also use &lt;code&gt;~/.vim/&lt;/code&gt; directory, but I like using &lt;code&gt;/var/tmp&lt;/code&gt; because it's usually a separate filesystem.&lt;/p&gt;&#xA;&lt;p&gt;I use &lt;code&gt;/var/tmp&lt;/code&gt; because &lt;code&gt;/tmp&lt;/code&gt; is often cleared on reboot. You probably don't want this directory world-writable, since people could then place files there to do potentially harmful things when you open a file.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="21410" LastEditDate="2022-11-02T19:02:27.637" LastActivityDate="2022-11-02T19:02:27.637" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="58" PostTypeId="2" ParentId="52" CreationDate="2015-02-03T17:42:52.410" Score="18" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/ciaranm/detectindent&quot; rel=&quot;nofollow noreferrer&quot;&gt;ciaranm/detectindent&lt;/a&gt; might be what you're looking for. It's unmaintained (last updated in 2015, there was also a fork that was last updated in 2016: &lt;a href=&quot;https://github.com/roryokane/detectindent&quot; rel=&quot;nofollow noreferrer&quot;&gt;roryokane/detectindent&lt;/a&gt;) and I haven't used it, but looks like it does what you want:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A Vim plugin, for automatically detecting indent settings. This plugin adds a :DetectIndent command, which tries to intelligently set the 'shiftwidth', 'expandtab' and 'tabstop' options based upon the existing settings in use in the active file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerDisplayName="user2" LastEditorDisplayName="user26313" LastEditDate="2023-02-22T09:55:18.137" LastActivityDate="2023-02-22T09:55:18.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="59" PostTypeId="2" ParentId="52" CreationDate="2015-02-03T17:44:17.883" Score="48" Body="&lt;p&gt;Install this plugin: &lt;a href=&quot;https://github.com/tpope/vim-sleuth&quot; rel=&quot;nofollow noreferrer&quot;&gt;tpope/vim-sleuth&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="74" LastEditorDisplayName="user26313" LastEditDate="2023-02-21T20:54:38.640" LastActivityDate="2023-02-21T20:54:38.640" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="60" PostTypeId="2" ParentId="39" CreationDate="2015-02-03T17:46:19.047" Score="38" Body="&lt;p&gt;Such functionality - i.e., searching the current file (and all open files) for auto-completion, should be enabled by default with &lt;code&gt;Ctrl+P&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/5040g.png&quot; alt=&quot;screenshot of autocompletion in use&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can go to the &lt;strong&gt;n&lt;/strong&gt;ext suggestion with &lt;code&gt;Ctrl+N&lt;/code&gt;, the &lt;strong&gt;p&lt;/strong&gt;revious suggestion with &lt;code&gt;Ctrl+P&lt;/code&gt; and select it by typing any letter (which will be appended right after the suggestion).&lt;/p&gt;&#xA;" OwnerUserId="82" LastEditorUserId="82" LastEditDate="2015-02-03T18:47:14.643" LastActivityDate="2015-02-03T18:47:14.643" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="61" PostTypeId="1" AcceptedAnswerId="66" CreationDate="2015-02-03T17:48:40.290" Score="6" ViewCount="214" Body="&lt;p&gt;I have a lot of &lt;code&gt;*.sage&lt;/code&gt; that follow the Python syntax. However, VIm does not recognize this. Can I make VIm set &lt;code&gt;++filetype&lt;/code&gt; based solely on the file extension?&lt;/p&gt;&#xA;" OwnerUserId="82" LastActivityDate="2015-02-03T17:58:42.593" Title="Setting up ++ft according to the file extension" Tags="|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="62" PostTypeId="2" ParentId="16" CreationDate="2015-02-03T17:49:53.817" Score="4" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot;&gt;NerdTree&lt;/a&gt; is commonly used for this, but you may want to take a look at &lt;a href=&quot;http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/&quot;&gt;Oil and vinegar - split windows and the project drawer &lt;/a&gt;, which makes an argument against using it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you choose to go this way, &lt;a href=&quot;https://github.com/tpope/vim-vinegar&quot;&gt;tpope/vim-vinegar&lt;/a&gt; is an extension that enhances the build in directory browser.&lt;/p&gt;&#xA;" OwnerUserId="81" LastEditorUserId="81" LastEditDate="2015-02-03T17:56:15.307" LastActivityDate="2015-02-03T17:56:15.307" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="63" PostTypeId="1" CreationDate="2015-02-03T17:50:44.983" Score="26" ViewCount="1150" Body="&lt;p&gt;As a complete beginner with no vi experience, how can I learn to use Vim using just Vim itself?  Is there a built-in tutorial, and how can I access it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume I have a laptop with Linux and Vim installed, and no Internet connection.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-03T19:07:41.063" LastActivityDate="2020-09-12T16:39:21.473" Title="How can a complete beginner learn Vim using just Vim itself?" Tags="|help-system|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="64" PostTypeId="1" AcceptedAnswerId="73" CreationDate="2015-02-03T17:51:30.750" Score="129" ViewCount="192715" Body="&lt;p&gt;When working with multiple files, it would be very handy if we can see more than one file in the screen at once. Is there any way in Vim to split the window (horizontally or vertically) so each split can show a different file?&lt;/p&gt;&#xA;" OwnerUserId="53" LastActivityDate="2015-02-16T10:52:45.930" Title="Is it possible to split Vim window to view multiple files at once?" Tags="|split|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="65" PostTypeId="2" ParentId="61" CreationDate="2015-02-03T17:51:33.303" Score="4" Body="&lt;p&gt;Yes, you can, using the &lt;code&gt;au(tocmd)&lt;/code&gt; event handler for events &lt;code&gt;BufNewFile&lt;/code&gt; and &lt;code&gt;BufRead&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.sage set filetype=python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="82" LastActivityDate="2015-02-03T17:51:33.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="66" PostTypeId="2" ParentId="61" CreationDate="2015-02-03T17:54:01.690" Score="4" Body="&lt;p&gt;You can add an &lt;code&gt;ftdetect&lt;/code&gt; plugin for vim. Read &lt;code&gt;:h ftdetect&lt;/code&gt; for detailed information. To quote from the docs for the lazy :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If a file type that you want to use is not detected yet, there are four ways&#xA;  to add it.  In any way, it's better not to modify the $VIMRUNTIME/filetype.vim&#xA;  file.  It will be overwritten when installing a new version of Vim.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A. If you want to overrule all default file type checks.&#xA;    This works by writing one file for each filetype.  The disadvantage is that&#xA;    means there can be many files.  The advantage is that you can simply drop&#xA;    this file in the right directory to make it work.&lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;&lt;p&gt;Create your user runtime directory.  You would normally use the first&#xA;   item of the 'runtimepath' option.  Then create the directory &quot;ftdetect&quot;&#xA;   inside it.  Example for Unix: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!mkdir ~/.vim&#xA;:!mkdir ~/.vim/ftdetect&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Create a file that contains an autocommand to detect the file type.&#xA;   Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.mine      set filetype=mine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Note that there is no &quot;augroup&quot; command, this has already been done&#xA;   when sourcing your file.  You could also use the pattern &quot;*&quot; and then&#xA;   check the contents of the file to recognize it.&#xA;   Write this file as &quot;mine.vim&quot; in the &quot;ftdetect&quot; directory in your user&#xA;   runtime directory.  For example, for Unix:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w ~/.vim/ftdetect/mine.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;To use the new filetype detection you must restart Vim.&#xA;  The files in the &quot;ftdetect&quot; directory are used after all the default&#xA;  checks, thus they can overrule a previously detected file type.  But you&#xA;  can also use &lt;code&gt;:setfiletype&lt;/code&gt; to keep a previously detected filetype.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="74" LastEditorUserId="82" LastEditDate="2015-02-03T17:58:42.593" LastActivityDate="2015-02-03T17:58:42.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="67" PostTypeId="2" ParentId="63" CreationDate="2015-02-03T17:54:29.353" Score="6" Body="&lt;p&gt;You can learn the basics by running &lt;code&gt;vimtutor&lt;/code&gt; at the command line. This ships with vim and provides a basic interactive tutorial on it's use.&lt;/p&gt;&#xA;" OwnerUserId="14" LastActivityDate="2015-02-03T17:54:29.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="68" PostTypeId="1" CreationDate="2015-02-03T17:55:11.177" Score="22" ViewCount="6994" Body="&lt;p&gt;I've turned on spellcheck with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set spell spelllang=en_us&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can now correct the spelling of a word by typing &lt;code&gt;1z=&lt;/code&gt; (that is, choose the &lt;code&gt;1&lt;/code&gt;st spelling correction (&lt;code&gt;z=&lt;/code&gt;)).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make this automatically run on the previous word whenever I type a space, without any delays? It also tries to &quot;fix&quot; words that are &lt;em&gt;already spelled correctly&lt;/em&gt; (which is why I can't do something like &lt;code&gt;inoremap &amp;lt;space&amp;gt; &amp;lt;esc&amp;gt;mmb1z=`ma&amp;lt;space&amp;gt;&lt;/code&gt;), so I only want to correct every word I type &lt;strong&gt;if it's misspelled&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to autocorrect misspelled words in Vim?&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="51" LastEditDate="2015-02-04T15:41:24.330" LastActivityDate="2019-10-25T10:27:24.717" Title="Autocorrect spelling mistakes" Tags="|spell-checking|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="69" PostTypeId="2" ParentId="56" CreationDate="2015-02-03T17:56:02.550" Score="16" Body="&lt;h3&gt;Backup files&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;By default, Vim doesn't leave backup files behind.  They are merely transient files that exist while Vim is saving the buffer to disk.  As described in &lt;code&gt;:help backup-table&lt;/code&gt; this behavior can be controlled by the &lt;code&gt;'backup'&lt;/code&gt; and &lt;code&gt;'writebackup'&lt;/code&gt; options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'backup' 'writebackup'  action  ~&#xA;   off       off    no backup made&#xA;   off       on     backup current file, deleted afterwards (default)&#xA;   on        off    delete old backup, backup current file&#xA;   on        on     delete old backup, backup current file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Swap files&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;As for swap files, it can be useful to collect them in a dedicated directory.  This can be done with the &lt;code&gt;'directory'&lt;/code&gt; option.  For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set directory^=$HOME/.vim/tmp//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will add &lt;code&gt;$HOME/.vim/tmp&lt;/code&gt; to the head of the list of directories that Vim will try to use when creating a swap file.  The trailing &lt;code&gt;//&lt;/code&gt; makes Vim encode the entire path name to the file so there aren't collisions with similarly named files from different directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;:&#xA;This effectively disables the ability for Vim to notice if multiple users are trying to edit the same file since the swap files are stored in different locations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The snippet below (adapted from &lt;a href=&quot;https://github.com/tpope/tpope/blob/338a4e89494bfe4928d3a0221c3ea1a7f09937cb/.vimrc#L328-L329&quot;&gt;tpope's vimrc&lt;/a&gt;) will also disable the swap file for a buffer when it isn't modified, that way if Vim/your computer crashes when you have a bunch of files open, the swap files left behind will only be for modified files.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorHold,BufWritePost,BufReadPost,BufLeave *&#xA;  \ if isdirectory(expand(&quot;&amp;lt;amatch&amp;gt;:h&quot;)) | let &amp;amp;swapfile = &amp;amp;modified | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;: Since the swap file only exists when the buffer is modified, this has a similar effect as setting &lt;code&gt;'directory'&lt;/code&gt;.  If the buffer is unmodified, then another Vim can start editing it without notice.  If the second Vim saves before the first one makes more changes, then they won't be noticed until the user tries to save or something triggers Vim to check if the file is modified.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2015-02-04T03:26:05.757" LastActivityDate="2015-02-04T03:26:05.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="70" PostTypeId="2" ParentId="64" CreationDate="2015-02-03T17:57:35.373" Score="36" Body="&lt;p&gt;Yes, there are the &lt;code&gt;:split&lt;/code&gt; (split into two windows, top half and bottom half) and &lt;code&gt;:vsplit&lt;/code&gt; (left and right) commands. You can then use &lt;kbd&gt;Ctrl-W &lt;em&gt;direction&lt;/em&gt;&lt;/kbd&gt; to switch windows (where &lt;em&gt;direction&lt;/em&gt; is one of the normal hjkl cursor movement keys, or the arrow keys).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then &lt;code&gt;:edit&lt;/code&gt; (etc.) a different file in each window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full documentation is at &lt;code&gt;:help windows.txt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="31" LastEditorUserId="31" LastEditDate="2015-02-03T18:03:28.023" LastActivityDate="2015-02-03T18:03:28.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="71" PostTypeId="2" ParentId="64" CreationDate="2015-02-03T17:57:49.107" Score="15" Body="&lt;p&gt;You can use &lt;code&gt;:split&lt;/code&gt; or &lt;code&gt;:vsplit&lt;/code&gt; for horizontal and vertical splits respectively. Provide the path to the file you want to open to open a specific file. Or just type the command to open a copy if the current file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then move between splits using &lt;code&gt;C-w + hjkl&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18" LastEditorUserId="13" LastEditDate="2015-02-15T19:03:47.833" LastActivityDate="2015-02-15T19:03:47.833" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="72" PostTypeId="2" ParentId="63" CreationDate="2015-02-03T17:57:59.920" Score="28" Body="&lt;p&gt;&lt;code&gt;vimtutor&lt;/code&gt; is a program that comes with vanilla vim installations. It's a 30-minute-ish tutorial program that explains the basics of vim. On *nix systems, you generally only need to execute &lt;code&gt;vimtutor&lt;/code&gt; on the command-line. Unix also has &lt;code&gt;gvimtutor&lt;/code&gt; available, if you'd prefer a GUI version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Windows, &lt;code&gt;vimtutor.bat&lt;/code&gt; is located in &lt;code&gt;$VIMRUNTIME&lt;/code&gt; (generally something like &lt;code&gt;C:\Program Files (x86)\Vim\vim74&lt;/code&gt; or similar). &lt;code&gt;vimtutor.bat&lt;/code&gt; will default to GUI vim on Windows; pass &lt;code&gt;-console&lt;/code&gt; if you want to force it to use console vim. On Windows 8, at least, you can also just search for 'vim tutor' (without the quotes, of course) from the Start Menu to open the tutor.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorUserId="514" LastEditDate="2015-10-10T22:38:55.910" LastActivityDate="2015-10-10T22:38:55.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="73" PostTypeId="2" ParentId="64" CreationDate="2015-02-03T17:58:22.147" Score="112" Body="&lt;p&gt;Yes, vim has the ability to split both horizontally using &lt;code&gt;:split&lt;/code&gt; and vertically using &lt;code&gt;:vsplit&lt;/code&gt; which both work just like &lt;code&gt;:edit&lt;/code&gt; for opening a file, except they open it in a horizontal / vertical split respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, I would recommend to also read &lt;code&gt;:h window-move-cursor&lt;/code&gt; for moving around different splits with ease.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-03T17:58:22.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="74" PostTypeId="1" AcceptedAnswerId="79" CreationDate="2015-02-03T17:59:25.830" Score="45" ViewCount="20176" Body="&lt;p&gt;Some word processors and text editors auto-save the files we're editing from time to time, which is very convenient for surviving from nasty crashes, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make Vim auto-save our files after a specific interval? &lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="24" LastEditDate="2015-02-03T18:03:11.010" LastActivityDate="2022-09-19T16:11:08.860" Title="Is it possible to make Vim auto-save files?" Tags="|save|crash-recovery|" AnswerCount="10" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="75" PostTypeId="2" ParentId="56" CreationDate="2015-02-03T18:00:18.833" Score="5" Body="&lt;p&gt;I use my &lt;code&gt;.vimrc&lt;/code&gt; on multiple machines, including shared servers. I don't necessarily want people being able to see the files that I'm working on and I like keeping my home directory relatively clean. So this is my solution which will work on Linux and Mac OS X just fine.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Sets central temp file location, to prevent local default behavior.&#xA;if isdirectory($HOME . '/.vim/.tmp') == 0&#xA;  :silent !mkdir -m 700 -p ~/.vim/.tmp &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&#xA;endif&#xA;&#xA;set backupdir=~/.vim/.tmp &quot;,~/.local/tmp/vim,/var/tmp,/tmp,&#xA;set directory=~/.vim/.tmp &quot;,~/.local/tmp/vim,/var/tmp,/tmp,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this will create a &lt;code&gt;.tmp&lt;/code&gt; directory under &lt;code&gt;~/.vim&lt;/code&gt; if it doesn't already exist. This would be the new home of your swap files. For undo files, I also have the following in my &lt;code&gt;.vimrc&lt;/code&gt; (which is pretty similar):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;+undofile&quot;)&#xA;  &quot; undofile -- This allows you to use undos after exiting and &#xA;  &quot;             restarting. NOTE: only present in 7.3+&#xA;  &quot;             :help undo-persistence&#xA;  if isdirectory( $HOME . '/.vim/.undo' ) == 0&#xA;    :silent !mkdir -m 700 -p ~/.vim/.undo &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&#xA;  endif&#xA;  set undodir=~/.vim/.undo&#xA;  set undofile&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="44" LastActivityDate="2015-02-03T18:00:18.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="76" PostTypeId="1" AcceptedAnswerId="86" CreationDate="2015-02-03T18:02:54.560" Score="47" ViewCount="23424" Body="&lt;p&gt;I know it's possible to open a new file in a split, with &lt;code&gt;:split&lt;/code&gt; or &lt;code&gt;:vsplit&lt;/code&gt;, but is it possible to open a new split with an existing buffer, potentially leveraging autocomplete?&lt;/p&gt;&#xA;" OwnerUserId="14" LastActivityDate="2019-10-25T14:05:17.833" Title="Can I open a new vim split from an existing buffer?" Tags="|split|buffers|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="77" PostTypeId="1" AcceptedAnswerId="288" CreationDate="2015-02-03T18:03:24.890" Score="40" ViewCount="4288" Body="&lt;p&gt;At my work we use a standard &lt;code&gt;ts&lt;/code&gt; of 2; my personal preference is 4, which is what I use for my hobby projects, and this other project we inherited has the convention of &lt;code&gt;ts=8&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also some other settings I want to set on a project basis (for example folding). Basing these settings on the filetype or auto-detecting them based on what the file uses are &lt;em&gt;not&lt;/em&gt; good options, since I want to respect each project's conventions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I make Vim use a settings file that applies to a project (everything in a directory tree) without adding a modeline to all the files?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-23T17:04:00.103" LastActivityDate="2017-10-10T20:33:15.813" Title="Applying settings to a directory tree only" Tags="|vimrc|filesystem|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="79" PostTypeId="2" ParentId="74" CreationDate="2015-02-03T18:07:43.503" Score="41" Body="&lt;p&gt;There isn't a builtin option, although &lt;code&gt;:help 'autosave'&lt;/code&gt; (in todo.txt) refers to a description of what such an option could do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possible way to implement this is to use the &lt;code&gt;CursorHold&lt;/code&gt; autocommand event.  This event is triggered when the user hasn't pressed a key for &lt;code&gt;'updatetime'&lt;/code&gt; milliseconds.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorHold * update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:update&lt;/code&gt; command only saves the buffer if it is modified.  If you also wanted this to happen while insert mode is active, &lt;code&gt;CursorHoldI&lt;/code&gt; could be added to the event list.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorHold,CursorHoldI * update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another alternative is the &lt;code&gt;'autowrite'&lt;/code&gt; option, which will save the buffer before executing an external command (useful for saving before running &lt;code&gt;:make&lt;/code&gt;) or switching to a different buffer.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2017-12-18T12:25:26.423" LastActivityDate="2017-12-18T12:25:26.423" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="80" PostTypeId="1" AcceptedAnswerId="81" CreationDate="2015-02-03T18:08:06.667" Score="50" ViewCount="14896" Body="&lt;p&gt;I know that &lt;code&gt;gg&lt;/code&gt; and &lt;code&gt;G&lt;/code&gt; can move the cursor to the top and bottom of the file. But is there a way to jump to the top or bottom of the visible window?&lt;/p&gt;&#xA;" OwnerUserId="53" LastActivityDate="2023-07-13T12:47:56.457" Title="How can I move the cursor to the top or bottom of the screen?" Tags="|cursor-movement|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="81" PostTypeId="2" ParentId="80" CreationDate="2015-02-03T18:09:58.903" Score="66" Body="&lt;p&gt;Type &lt;kbd&gt;H&lt;/kbd&gt; (capital H, H for &amp;quot;high&amp;quot;) to move to the top of the screen.&lt;/p&gt;&#xA;&lt;p&gt;Type &lt;kbd&gt;M&lt;/kbd&gt; (capital M, M for &amp;quot;middle&amp;quot;) to move to the middle of the screen.&lt;/p&gt;&#xA;&lt;p&gt;Type &lt;kbd&gt;L&lt;/kbd&gt; (capital L, L for &amp;quot;low&amp;quot;) to move to the bottom of the screen.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="32861" LastEditDate="2023-07-13T12:47:56.457" LastActivityDate="2023-07-13T12:47:56.457" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="82" PostTypeId="1" AcceptedAnswerId="389" CreationDate="2015-02-03T18:10:07.387" Score="48" ViewCount="79578" Body="&lt;p&gt;Some editors (such as Visual Studio on windows) do C++ autocompletion which understand C++. For example, given:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;vector&amp;gt;&#xA;&#xA;int main(void) {&#xA;  std::vector&amp;lt;int&amp;gt; v;&#xA;  v.i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In Visual Studio the auto-completion knows the only method on &lt;code&gt;std::vector&amp;lt;int&amp;gt;&lt;/code&gt; that starts with an &lt;code&gt;i&lt;/code&gt; is &lt;code&gt;insert&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to get this kind of autocompletion in vim?&lt;/p&gt;&#xA;" OwnerUserId="92" LastEditorUserId="23502" LastEditDate="2022-10-27T19:18:59.323" LastActivityDate="2022-10-27T19:18:59.323" Title="How to get intelligent C++ auto-completion?" Tags="|ide|autocompletion|filetype-c++|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="83" PostTypeId="2" ParentId="63" CreationDate="2015-02-03T18:15:56.973" Score="9" Body="&lt;p&gt;Like others have mentioned &lt;code&gt;vimtutor&lt;/code&gt; is a good place to start, there are several other resources available to you for improving on your knowledge &amp;amp; understanding of the vim philosophy, which needless to say is not only brilliant but surprisingly &amp;amp; pleasantly intuitive.&lt;/p&gt;&#xA;&lt;p&gt;However I would still like to use an example to draw a parallel to how one should approach learning vim.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;As we are born, we are pretty much immobile, we need to be carried to wherever we need to go, slowly our legs &amp;amp; arms develop muscles and gradually with practice we learn both how to use them &amp;amp; control them precisely to make use of them to start crawling so we can explore our surroundings ourselves. As we grow further and develop more muscles, strength &amp;amp; coordination we start to walk and with some more of the same we eventually are able to run. Now you might think this would be the end of it but it isn't, after we're fairly comfortable walking / running to wherever we desire, we feel the need to go farther and farther and realise the need for more tools (different vehicles) to go farther and faster.&lt;/p&gt;&#xA;&lt;p&gt;Learning vim IMO should be similar to that, in that you should learn the basics first and then gradually and incrementally keep learning more advanced patterns, ideas, plugins to keep improving your workflow. With practice everything you learn would get embedded in your muscle memory and become second nature and that would the time for you to learn further more tricks and repeat this cycle. Since VIM is still under development and adding new features (there's also NeoVIM), this process can go on forever.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;After a certain point, when VIM's philosophy has embedded deep in your muscle memory you will stop spending time thinking about &lt;code&gt;how&lt;/code&gt; to do what you want and be completely focused on &lt;code&gt;what&lt;/code&gt; you really want to do. When that happens you will be feel frustrated at how painfully slow and awful it is to edit text in other applications / editors that do not have some decent support for emulating vim.&lt;/p&gt;&#xA;" OwnerUserId="74" LastEditorUserId="74" LastEditDate="2020-09-12T16:39:21.473" LastActivityDate="2020-09-12T16:39:21.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="84" PostTypeId="1" AcceptedAnswerId="96" CreationDate="2015-02-03T18:16:03.930" Score="513" ViewCount="685478" Body="&lt;p&gt;Is there a way to copy a block of text to the system clipboard, so I can paste it in another program?&lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="24" LastEditDate="2015-02-03T23:55:49.503" LastActivityDate="2024-03-05T04:20:21.890" Title="How can I copy text to the system clipboard from Vim?" Tags="|cut-copy-paste|os-clipboard|" AnswerCount="15" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="85" PostTypeId="1" CreationDate="2015-02-03T18:16:27.527" Score="6" ViewCount="866" Body="&lt;p&gt;Let's say I've been working with vim for some time; I've dabbled with my &lt;code&gt;~/.vimrc&lt;/code&gt; and copied-and-pasted some snippets in I find on the way, with minimal changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm beginning to get a hazy understanding of this weird language called vimscript. What is an effective way for me to develop a greater understanding of it?&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="24" LastEditDate="2015-02-04T10:12:52.917" LastActivityDate="2015-02-04T10:12:52.917" Title="What is an effective way to learn vimscript?" Tags="|vimscript|" AnswerCount="1" CommentCount="6" ClosedDate="2015-02-03T19:01:25.343" ContentLicense="CC BY-SA 3.0" />
  <row Id="86" PostTypeId="2" ParentId="76" CreationDate="2015-02-03T18:17:37.503" Score="62" Body="&lt;p&gt;The &lt;code&gt;sbuffer&lt;/code&gt; command will let you create a split with an existing buffer name or number. &lt;code&gt;:sb#&lt;/code&gt; will open a split with buffer number &lt;code&gt;#&lt;/code&gt; (as displayed in the &lt;code&gt;:buffers&lt;/code&gt; list). &lt;code&gt;:sb foo&lt;/code&gt; will open a split with the buffer named &lt;code&gt;foo&lt;/code&gt;. Tab-complete will cycle the available buffer names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:vertical sb...&lt;/code&gt; if you want a vertical split instead of the default, horizontal, one. &lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-02-03T18:17:37.503" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="87" PostTypeId="2" ParentId="85" CreationDate="2015-02-03T18:17:40.363" Score="4" Body="&lt;p&gt;I have found &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; to be invaluable in improving my understanding of vimscript. It covers both the theory (as a programming language) as well as improving my understanding of vim as an editor. Recommended.&lt;/p&gt;&#xA;" OwnerUserId="91" LastActivityDate="2015-02-03T18:17:40.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="88" PostTypeId="1" AcceptedAnswerId="90" CreationDate="2015-02-03T18:18:01.323" Score="31" ViewCount="7595" Body="&lt;p&gt;For some text formats, line breaks matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I often use Vim to write MediaWiki documents, where you can't just put a linebreak anywhere (unlike Markdown). So I'm forced to write lines with a lot of characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can lead to long (200+ chars) or even &lt;em&gt;very&lt;/em&gt; long (1000+ chars) lines. I find this very awkward to use in Vim. One example is if I want to edit something in the middle of the 1000 character-line, I need to move my cursor 500 times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be made a bit faster with &lt;code&gt;w&lt;/code&gt; or &lt;code&gt;/&lt;/code&gt;, but it's still awkward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there better ways to deal with this? Better movement keys? Some sort of &quot;fake wrapping&quot; (text behaves as if &lt;code&gt;tw=80&lt;/code&gt;, but no &lt;code&gt;\n&lt;/code&gt; in the file), or something else?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorDisplayName="user579" LastEditDate="2018-09-12T08:40:01.233" LastActivityDate="2021-12-06T01:28:31.217" Title="How do I deal with very long lines in text (500+ characters)?" Tags="|cursor-movement|large-documents|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="89" PostTypeId="2" ParentId="84" CreationDate="2015-02-03T18:22:33.733" Score="52" Body="&lt;p&gt;From &lt;a href=&quot;http://vim.wikia.com/wiki/Accessing_the_system_clipboard&quot; rel=&quot;noreferrer&quot;&gt;http://vim.wikia.com/wiki/Accessing_the_system_clipboard&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard=unnamedplus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This changes the default Vim register to the &lt;code&gt;+&lt;/code&gt; register, which is linked to the system clipboard. From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#clipboard-unnamedplus&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h clipboard-unnamedplus&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                        clipboard-unnamedplus&#xA;unnamedplus     A variant of the &quot;unnamed&quot; flag which uses the&#xA;                clipboard register '+' (quoteplus) instead of&#xA;                register '*' for all yank, delete, change and put&#xA;                operations which would normally go to the unnamed&#xA;                register.  When &quot;unnamed&quot; is also included to the&#xA;                option, yank operations (but not delete, change or&#xA;                put) will additionally copy the text into register&#xA;                '*'.&#xA;                Only available with the +X11 feature.&#xA;                Availability can be checked with: &#xA;                        if has('unnamedplus')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="93" LastEditorUserId="343" LastEditDate="2017-02-03T17:16:19.750" LastActivityDate="2017-02-03T17:16:19.750" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="90" PostTypeId="2" ParentId="88" CreationDate="2015-02-03T18:22:33.990" Score="32" Body="&lt;p&gt;You can use &lt;code&gt;g&lt;/code&gt; series of commands to move to the boundaries of the visible screen area.  For example, &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt; moves to the right edge of the screen (which is not necessarily the end of the line).  &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; moves the cursor down one line &lt;em&gt;as it appears on your screen&lt;/em&gt; (which is not necessarily one logical line down).&lt;/p&gt;&#xA;&lt;p&gt;Perhaps you could rebind the arrow keys:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Up&amp;gt; gk&#xA;nnoremap &amp;lt;Down&amp;gt; gj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or some people also directly rebind &lt;kbd&gt;k&lt;/kbd&gt; and &lt;kbd&gt;j&lt;/kbd&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap k gk&#xA;nnoremap j gj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For insert mode, you could use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-k&amp;gt; &amp;lt;C-o&amp;gt;gk&#xA;inoremap &amp;lt;C-j&amp;gt; &amp;lt;C-o&amp;gt;gj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Up&amp;gt; &amp;lt;C-o&amp;gt;gk&#xA;inoremap &amp;lt;Down&amp;gt; &amp;lt;C-o&amp;gt;gj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;In addition, if you use &lt;code&gt;:set wrap&lt;/code&gt;, Vim will wrap the lines, so you can see all of the line. You can also use &lt;code&gt;set showbreak=+&lt;/code&gt; to show a &lt;code&gt;+&lt;/code&gt; to indicate that Vim is doing wrapping.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;To jump to specific column positions, you can use the &lt;kbd&gt;|&lt;/kbd&gt; command. For example, &lt;kbd&gt;200|&lt;/kbd&gt; will go to column position 200.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="51" LastEditDate="2021-12-06T01:28:31.217" LastActivityDate="2021-12-06T01:28:31.217" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="91" PostTypeId="2" ParentId="88" CreationDate="2015-02-03T18:23:53.163" Score="3" Body="&lt;p&gt;Vim has support for soft wrapping, just &lt;code&gt;set wrap&lt;/code&gt; to enable it and it will wrap long lines going beyond the visible screen. You can use &lt;code&gt;gj&lt;/code&gt; &amp;amp; &lt;code&gt;gk&lt;/code&gt; to move up/down respectively over such wrapped lines.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-03T18:23:53.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="92" PostTypeId="2" ParentId="84" CreationDate="2015-02-03T18:26:42.867" Score="28" Body="&lt;p&gt;On builds that support it, the register named &lt;code&gt;*&lt;/code&gt; is the system clipboard.  To copy text from Vim to the system clipboard, you can select the text using visual mode, then press &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;*&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt; to copy it to the system clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conversely, use &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;*&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; to paste text from the system clipboard into Vim.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="64" LastEditDate="2015-05-26T09:47:48.570" LastActivityDate="2015-05-26T09:47:48.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="93" PostTypeId="1" AcceptedAnswerId="100" CreationDate="2015-02-03T18:31:11.553" Score="126" ViewCount="95615" Body="&lt;p&gt;Is it possible to count how many times a word or a pattern appears in a file? This is sometimes useful to find out how many times a function has been called, etc.&lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="343" LastEditDate="2017-12-06T11:11:23.787" LastActivityDate="2021-01-06T20:17:40.633" Title="Is there a way to count the number of occurrences of a word in a file?" Tags="|search|counting|" AnswerCount="7" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="94" PostTypeId="5" CreationDate="2015-02-03T18:31:31.687" Score="0" Body="&lt;p&gt;This tag is for questions about how to use Vim's built-in help system, accessible using the &lt;code&gt;:help&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-04T14:05:37.743" LastActivityDate="2015-02-04T14:05:37.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="95" PostTypeId="4" CreationDate="2015-02-03T18:31:31.687" Score="0" Body="Questions about the built-in help system" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-03T18:57:45.967" LastActivityDate="2015-02-03T18:57:45.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="96" PostTypeId="2" ParentId="84" CreationDate="2015-02-03T18:34:03.263" Score="574" Body="&lt;p&gt;For &lt;strong&gt;X11&lt;/strong&gt;-based systems (ie. &lt;strong&gt;Linux&lt;/strong&gt; and most other &lt;strong&gt;UNIX&lt;/strong&gt;-like systems)&#xA;there are two clipboards which are independent of each other:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;PRIMARY - This is copy-on-select, and can be pasted with the middle mouse&#xA;button.&lt;/li&gt;&#xA;&lt;li&gt;CLIPBOARD - This is copied with (usually) &lt;code&gt;^C&lt;/code&gt;, and pasted with &lt;code&gt;^V&lt;/code&gt; (It's&#xA;like MS Windows).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;OS X&lt;/strong&gt; and &lt;strong&gt;Windows&lt;/strong&gt; systems only have one clipboard.&lt;/p&gt;&#xA;&lt;p&gt;For X11 systems there are also number of tools that synchronize these clipboards&#xA;for you; so if they appear to be the same, you may have one of them running.&lt;/p&gt;&#xA;&lt;p&gt;Vim has two special registers corresponding to these clipboards:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;*&lt;/code&gt; uses PRIMARY; mnemonic: &lt;strong&gt;S&lt;/strong&gt;tar is &lt;strong&gt;S&lt;/strong&gt;elect (for copy-on-&lt;strong&gt;s&lt;/strong&gt;elect)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;+&lt;/code&gt; uses CLIPBOARD; mnemonic: CTRL &lt;strong&gt;PLUS&lt;/strong&gt; C (for the common keybind)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;On Windows &amp;amp; OS X there is no difference between &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt;, since these systems&#xA;only have a single clipboard, and both registers refer to the same thing (it&#xA;doesn't matter which one you use).&lt;/p&gt;&#xA;&lt;p&gt;You can use these registers as any register. For example, using the PRIMARY&#xA;clipboard &lt;code&gt;*&lt;/code&gt; with the &lt;code&gt;y&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt; commands:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;quot;*yy&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;quot;*p&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You could maybe use this as more convenient keybinds:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Leader&amp;gt;y &amp;quot;*y&#xA;noremap &amp;lt;Leader&amp;gt;p &amp;quot;*p&#xA;noremap &amp;lt;Leader&amp;gt;Y &amp;quot;+y&#xA;noremap &amp;lt;Leader&amp;gt;P &amp;quot;+p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you want to &amp;quot;automatically&amp;quot; interface with the system's clipboard instead of&#xA;referring to it manually all the time, you can set the &lt;code&gt;clipboard&lt;/code&gt; variable:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Set it to &lt;code&gt;unnamed&lt;/code&gt; to use &lt;code&gt;*&lt;/code&gt; (PRIMARY, on select)&lt;/li&gt;&#xA;&lt;li&gt;Set it to &lt;code&gt;unnamedplus&lt;/code&gt; to use &lt;code&gt;+&lt;/code&gt; (CLIPBOARD, &lt;code&gt;^C&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now, just using &lt;code&gt;yy&lt;/code&gt; will go to the system's clipboard, instead of Vim's unnamed&#xA;register, and &lt;code&gt;p&lt;/code&gt; will paste the system's clipboard.&lt;/p&gt;&#xA;&lt;p&gt;You can also assign to these registers just like any register with &lt;code&gt;let&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:let @+=42&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:let @*=42&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The &lt;code&gt;clipboard&lt;/code&gt; setting has some more options (such as exclude filters); but&#xA;these are the basics. See &lt;code&gt;:help 'clipboard'&lt;/code&gt; for the full story ;-)&lt;/p&gt;&#xA;&lt;h1&gt;gVim&lt;/h1&gt;&#xA;&lt;p&gt;If you use gVim, you can get copy-on-select behaviour when using&#xA;&lt;code&gt;:set guioptions+=a&lt;/code&gt;.&lt;br /&gt;&#xA;This is enabled by default on X11 systems (copies to PRIMARY), but &lt;em&gt;not&lt;/em&gt; on MS&#xA;Windows &amp;amp; OSX (as selecting any text would override your clipboard).&lt;/p&gt;&#xA;&lt;h1&gt;No &lt;code&gt;+clipboard&lt;/code&gt;?&lt;/h1&gt;&#xA;&lt;p&gt;Vim requires the &lt;code&gt;+clipboard&lt;/code&gt; feature flag for any of this to work; you can&#xA;check if your Vim has this by using &lt;code&gt;:echo has('clipboard')&lt;/code&gt; from within Vim (if the&#xA;output is &lt;code&gt;0&lt;/code&gt;, it's &lt;em&gt;not&lt;/em&gt; present, if it's &lt;code&gt;1&lt;/code&gt;, it is), or checking the output of&#xA;&lt;code&gt;vim --version&lt;/code&gt; for &lt;code&gt;+clipboard&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Most Linux distributions ship with a &amp;quot;minimal&amp;quot; Vim build by default, which&#xA;doesn't have &lt;code&gt;+clipboard&lt;/code&gt;, but you can usually install it:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Debian &amp;amp; Ubuntu: Install &lt;code&gt;vim-gtk3&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Fedora: install &lt;code&gt;vim-X11&lt;/code&gt;, and run &lt;code&gt;vimx&lt;/code&gt; instead of &lt;code&gt;vim&lt;/code&gt; (&lt;a href=&quot;https://vi.stackexchange.com/q/2063/51&quot;&gt;more info&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Arch Linux: install &lt;code&gt;gvim&lt;/code&gt; (this will enable &lt;code&gt;+clipboard&lt;/code&gt; for normal &lt;code&gt;vim&lt;/code&gt; as well).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You could also use &lt;code&gt;xclip&lt;/code&gt;, &lt;code&gt;xcopy&lt;/code&gt;, or &lt;code&gt;xsel&lt;/code&gt; to copy text to the clipboard;&#xA;see the following questions for solutions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/332/define-custom-commands-for-the-and-registers&quot;&gt;Define custom commands for the * and + registers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/8354/51&quot;&gt;How can I copy over an ssh session without +clipboard?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;SSH&lt;/h1&gt;&#xA;&lt;p&gt;You can also use a clipboard on remote machines if you enable X11 forwarding&#xA;over SSH. This is especially useful with the above tip since you can then use&#xA;&lt;code&gt;xclip&lt;/code&gt; to access your desktop's clipboard. The Vim on the machine you're&#xA;ssh-ing to will still need the &lt;code&gt;+clipboard&lt;/code&gt; feature.&lt;/p&gt;&#xA;&lt;p&gt;This requires the &lt;code&gt;ForwardX11Trusted&lt;/code&gt; setting, and should &lt;strong&gt;only be&#xA;done with trusted servers&lt;/strong&gt;, as this gives the server almost complete control&#xA;over your X11 session:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ ssh -XY myhost&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To make these settings persistent (so you don't need to add &lt;code&gt;-XY&lt;/code&gt; every time),&#xA;you could  do something like this in your &lt;code&gt;~/.ssh/config&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Do **NOT** set this globally; it gives the server complete control over&#xA;# your X11 session.&#xA;Host myhost&#xA;    ForwardX11 yes&#xA;    ForwardX11Trusted yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Neovim&lt;/h1&gt;&#xA;&lt;p&gt;Neovim revamped the clipboard support. The built-in interface was removed and&#xA;replaced with a system that call an external utility such as &lt;code&gt;xclip&lt;/code&gt;, &lt;code&gt;xsel&lt;/code&gt;, or&#xA;&lt;code&gt;pbcopy&lt;/code&gt;/&lt;code&gt;pbpaste&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It should automatically pick up these utilities and use them. On OS X &lt;code&gt;pbcopy&lt;/code&gt;&#xA;and &lt;code&gt;pbpaste&lt;/code&gt; should be available by default, on Linux you probably want to&#xA;install &lt;code&gt;xclip&lt;/code&gt;, as that's the most widely available (there are actually &lt;em&gt;two&lt;/em&gt;&#xA;versions of &lt;code&gt;xsel&lt;/code&gt; with &lt;em&gt;incompatible flags&lt;/em&gt;. This is really stupid).&lt;/p&gt;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://neovim.io/doc/user/provider.html#clipboard&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help clipboard&lt;/code&gt;&lt;/a&gt; in Neovim.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="16457" LastEditDate="2020-10-14T15:18:36.260" LastActivityDate="2020-10-14T15:18:36.260" CommentCount="19" ContentLicense="CC BY-SA 4.0" />
  <row Id="97" PostTypeId="2" ParentId="93" CreationDate="2015-02-03T18:34:49.177" Score="3" Body="&lt;p&gt;&lt;code&gt;:%s/pattern//g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will see the number of substitutions in the status bar.  That is how many times the &lt;code&gt;pattern&lt;/code&gt; appears.  Then just press &lt;code&gt;u&lt;/code&gt; to undo the substitutions.&lt;/p&gt;&#xA;" OwnerUserId="93" LastEditorUserId="11046" LastEditDate="2018-10-31T10:16:57.383" LastActivityDate="2018-10-31T10:16:57.383" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="98" PostTypeId="2" ParentId="93" CreationDate="2015-02-03T18:37:59.430" Score="19" Body="&lt;p&gt;&lt;code&gt;:%s/pattern//n&lt;/code&gt; The &lt;code&gt;n&lt;/code&gt; flag in the end tells &lt;code&gt;:s&lt;/code&gt; command to report the number of matches and not actually substitute. Read &lt;code&gt;:h :s_flags&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-03T18:37:59.430" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="99" PostTypeId="2" ParentId="93" CreationDate="2015-02-03T18:41:16.913" Score="10" Body="&lt;p&gt;First use &lt;code&gt;/&lt;/code&gt; to search for a regex, then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s///gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the same as Dhurva's answer, except that it a.) Is easier to use (since you can preview the results of what your regex matches first) and b.) Matches globally with the &lt;code&gt;g&lt;/code&gt; flag to count &lt;strong&gt;all&lt;/strong&gt; occurrences.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-03T18:41:16.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="100" PostTypeId="2" ParentId="93" CreationDate="2015-02-03T18:42:19.227" Score="178" Body="&lt;p&gt;Quincy's answer is fine, but there's an exact way to do this which doesn't require editing the buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/pattern//ng&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will print a message like &lt;code&gt;3 matches on 2 lines&lt;/code&gt;, and no changes will be made to your buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;n&lt;/code&gt; flag makes the &lt;code&gt;:substitute&lt;/code&gt; command print the number of matches instead of performing an actual substitution; the &lt;code&gt;g&lt;/code&gt; flag enables reporting of multiple matches per line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another thing that might be useful to your use case is to print all lines that match a pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/pattern/print&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which can be shortened to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/pattern&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is one of the simplest uses of the &lt;code&gt;:global&lt;/code&gt; command (which is mind-bogglingly powerful). It will simply print out all of the lines that match &lt;code&gt;pattern&lt;/code&gt;, and then (if there is more than one line) you press &lt;code&gt;Enter&lt;/code&gt; or type another command to make it go away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bit of trivia: This command is the origin of the name &lt;code&gt;grep&lt;/code&gt;, as it would commonly be described as &lt;code&gt;g/re/p&lt;/code&gt;, where &lt;code&gt;re&lt;/code&gt; stands for &quot;regular expression&quot;.&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="12003" LastEditDate="2018-07-27T18:30:42.750" LastActivityDate="2018-07-27T18:30:42.750" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="101" PostTypeId="1" AcceptedAnswerId="109" CreationDate="2015-02-03T18:45:02.220" Score="7" ViewCount="282" Body="&lt;p&gt;Vim has an &quot;abbreviation&quot; feature built-in that can automatically expand certain abbreviations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:iab SE Stack Exchange&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hhWer.gif&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, sometimes I might want to type &quot;SE&quot; &lt;em&gt;without&lt;/em&gt; it expanding to &quot;Stack Exchange.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to undo a single abbreviation and insert only the original, unabbreviated text? If not, can I add something to my &lt;code&gt;.vimrc&lt;/code&gt; to enable a key shortcut or other method of doing so?&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-03T18:55:35.190" Title="Undo a single iab abbreviation expansion" Tags="|abbreviations|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="102" PostTypeId="1" AcceptedAnswerId="103" CreationDate="2015-02-03T18:48:06.547" Score="18" ViewCount="2835" Body="&lt;p&gt;I have turned on line wrapping with &lt;code&gt;set wrap linebreak nolist&lt;/code&gt; in my .vimrc. However, this has the annoying behavior that lines not &lt;em&gt;completely&lt;/em&gt; visible on the screen are hidden outright and replaced with @ signs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/zrsie.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make these lines show up even though they are partially hidden?&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-03-01T04:45:00.147" Title="Show partially hidden wrapped lines" Tags="|wrapping|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="103" PostTypeId="2" ParentId="102" CreationDate="2015-02-03T18:48:06.547" Score="21" Body="&lt;p&gt;You can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set display+=lastline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27display%27&quot;&gt;&lt;code&gt;:help 'display'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lastline        When included, as much as possible of the last line&#xA;                in a window will be displayed.  When not included, a&#xA;                last line that doesn't fit is replaced with &quot;@&quot; lines.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastEditorUserId="51" LastEditDate="2015-03-01T04:45:00.147" LastActivityDate="2015-03-01T04:45:00.147" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="104" PostTypeId="1" AcceptedAnswerId="105" CreationDate="2015-02-03T18:50:16.037" Score="260" ViewCount="190417" Body="&lt;p&gt;When I'm editing a file in Vim, is there a command to see the path of the current file? Sometimes this is very handy if there are multiple files with the same name in a project.&lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="24" LastEditDate="2015-02-04T14:03:47.873" LastActivityDate="2024-03-15T10:14:49.623" Title="How can I see the full path of the current file?" Tags="|statusline|" AnswerCount="13" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="105" PostTypeId="2" ParentId="104" CreationDate="2015-02-03T18:50:16.037" Score="313" Body="&lt;p&gt;You can press &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#CTRL-G&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;{count}Ctrl-G&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{count}CTRL-G       Like CTRL-G, but prints the current file name with&#xA;                    full path.  If the count is higher than 1 the current&#xA;                    buffer number is also given.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;1&lt;/kbd&gt; followed by &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;G&lt;/kbd&gt; shows the full path of the current file. If &lt;code&gt;{count}&lt;/code&gt; is higher than 1, the buffer name will also be shown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Pressing only &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;G&lt;/kbd&gt; shows the path relative to Vim's current working directory, as pointed out by Jasper in the comments.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the following command in your &lt;code&gt;.vimrc&lt;/code&gt; to add the full path to the status line, so it is always visible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%F&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="53" LastEditorUserId="205" LastEditDate="2019-03-25T06:46:32.803" LastActivityDate="2019-03-25T06:46:32.803" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="106" PostTypeId="1" AcceptedAnswerId="111" CreationDate="2015-02-03T18:51:18.497" Score="9" ViewCount="3306" Body="&lt;p&gt;If I edit a file with vim that I have &lt;em&gt;previously&lt;/em&gt; edited, I'd like vim to jump to the position I was in when I last closed the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I accomplish this?&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorUserId="24" LastEditDate="2015-02-03T19:16:48.427" LastActivityDate="2017-02-18T19:48:31.267" Title="How can I restore the cursor position when opening a file?" Tags="|cursor-movement|sessions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="107" PostTypeId="1" CreationDate="2015-02-03T18:51:22.157" Score="10" ViewCount="341" Body="&lt;p&gt;I often want to copy a line and replace another line with the pasted copy. Is there a better way than &lt;code&gt;Y&lt;/code&gt; on source line, go to the line that has to be replaced and &lt;code&gt;Pjdd&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="79" LastEditorUserId="21062" LastEditDate="2019-08-06T22:19:54.020" LastActivityDate="2019-08-06T22:19:54.020" Title="Overwrite current line with register?" Tags="|cut-copy-paste|register|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="108" PostTypeId="2" ParentId="107" CreationDate="2015-02-03T18:53:16.197" Score="5" Body="&lt;p&gt;You can go to the source line, yank it with &lt;code&gt;yy&lt;/code&gt; or &lt;code&gt;Y&lt;/code&gt;, go back to the target line, and press &lt;code&gt;Vp&lt;/code&gt; (select the line with a visual selection, and replace the visual selection with the previously yanked line).&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="88" LastEditDate="2015-02-03T19:00:16.237" LastActivityDate="2015-02-03T19:00:16.237" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="109" PostTypeId="2" ParentId="101" CreationDate="2015-02-03T18:55:35.190" Score="7" Body="&lt;p&gt;When you typing SE hit &lt;code&gt;CTRL-v&lt;/code&gt; and then &lt;code&gt;spacebar&lt;/code&gt; to insert space character.&#xA;See &lt;code&gt;:h i_CTRL-v&lt;/code&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="50" LastActivityDate="2015-02-03T18:55:35.190" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="111" PostTypeId="2" ParentId="106" CreationDate="2015-02-03T19:00:53.360" Score="3" Body="&lt;p&gt;What I use (adapted from &lt;code&gt;:help restore-cursor&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Go to the last cursor location when a file is opened, unless this is a&#xA;&quot; git commit (in which case it's annoying)&#xA;au BufReadPost *&#xA;    \ if line(&quot;'\&quot;&quot;) &amp;gt; 0 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) &amp;amp;&amp;amp; &amp;amp;filetype != &quot;gitcommit&quot; |&#xA;        \ execute(&quot;normal `\&quot;&quot;) |&#xA;    \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;BufReadPost&lt;/code&gt; gets run when starting to edit a bufffer. The &lt;code&gt;&quot;&lt;/code&gt; mark is the cursor position when last exited the file (as remembered by viminfo). We first check if this is set higher than 0, and lower than the number of lines in the file, before jumping to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We &lt;em&gt;don't&lt;/em&gt; do this if the filetype is gitcommit, since I find this annoying (I always want it to start at the first line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to keep &lt;code&gt;viminfo&lt;/code&gt; file for all of this, which is enabled by default.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-03T19:07:18.607" LastActivityDate="2015-02-03T19:07:18.607" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="112" PostTypeId="1" CreationDate="2015-02-03T19:04:40.897" Score="-3" ViewCount="157" Body="&lt;p&gt;When first starting out using vim, I was nervous that I'd get lost in some foreign mode that could potentially wreak havoc. I felt like there was never really any &quot;safety net&quot; preventing me from a major blunder, possibly leading to a catastrophe with either my system or the file I was working on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've built up my own personal confidence, but surely there might be other beginners who feel the same way I did when starting out. Are there safeguards that can be put in place for someone learning the ropes? Any type of sandboxing, restrictions, or safety features would be ideal.&lt;/p&gt;&#xA;" OwnerUserId="114" LastEditorUserId="24" LastEditDate="2015-02-05T08:45:35.057" LastActivityDate="2015-02-05T08:45:35.057" Title="Are there any precautionary measures I can take for a beginner?" Tags="|undo-redo|" AnswerCount="1" CommentCount="4" ClosedDate="2015-02-03T19:22:47.627" ContentLicense="CC BY-SA 3.0" />
  <row Id="113" PostTypeId="2" ParentId="112" CreationDate="2015-02-03T19:08:56.153" Score="4" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Become comfortable with vimtutor. Doesn't matter if you mess the file up, because it's a temporary version.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Learn to undo something with normal mode and &lt;code&gt;u&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It's kinda difficult to have a catastrophe with your system, by accident from Vim. If you find yourself accidentally typing &lt;code&gt;:! rm / -rf&lt;/code&gt; then you've got bigger problems than Vim. Don't do that at all. &lt;strong&gt;Anywhere&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Remember that if you run &lt;code&gt;:q&lt;/code&gt; without saving, it won't write the file. So if you open something up and it gets ruined, don't do a &lt;code&gt;:w&lt;/code&gt; an &lt;code&gt;:x&lt;/code&gt; or a &lt;code&gt;:wq&lt;/code&gt;. Quit straight out and try again.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="124" LastEditorUserId="124" LastEditDate="2015-02-03T20:45:27.157" LastActivityDate="2015-02-03T20:45:27.157" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="114" PostTypeId="5" CreationDate="2015-02-03T19:09:53.730" Score="0" Body="&lt;p&gt;This tag is for questions about how to use Vim's built-in help system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From Vim, help is available through the &lt;code&gt;:help&lt;/code&gt; (or &lt;code&gt;:h&lt;/code&gt; for short) command. You can add a subject to search for it: &lt;code&gt;:help subject&lt;/code&gt;. Almost any subject will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an overview of the help system, see &lt;a href=&quot;http://vimhelp.appspot.com/helphelp.txt.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help help&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="51" LastEditDate="2015-02-06T09:58:25.133" LastActivityDate="2015-02-06T09:58:25.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="115" PostTypeId="4" CreationDate="2015-02-03T19:09:53.730" Score="0" Body="Questions about Vim's built-in help system, which is accessible through the&#xD;&#xA;:help command" OwnerUserId="24" LastEditorUserId="51" LastEditDate="2015-02-16T22:33:26.820" LastActivityDate="2015-02-16T22:33:26.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="116" PostTypeId="1" AcceptedAnswerId="117" CreationDate="2015-02-03T19:23:04.940" Score="28" ViewCount="5488" Body="&lt;p&gt;I accidentally pressed &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;, and now the status line says &lt;code&gt;recording&lt;/code&gt;.  What does that mean?  How do I get out of this &quot;recording&quot; mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;Esc&lt;/kbd&gt; doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="88" LastEditDate="2015-02-04T15:22:02.810" LastActivityDate="2015-02-13T13:25:15.803" Title="After pressing qq, the status line says &quot;recording&quot;. How do I get out of this mode?" Tags="|macro|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="117" PostTypeId="2" ParentId="116" CreationDate="2015-02-03T19:23:49.097" Score="38" Body="&lt;p&gt;&lt;code&gt;q&lt;/code&gt; is the command to begin the recording of a macro. By pressing &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; you have told Vim to record a macro and store it in the register &lt;code&gt;q&lt;/code&gt;. To stop Vim to record the macro, and thus to make the message &lt;code&gt;recording&lt;/code&gt; disappear, you have to stop the recording by pressing &lt;kbd&gt;q&lt;/kbd&gt; again. See &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#recording&quot;&gt;&lt;code&gt;:help recording&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2015-02-13T13:25:15.803" LastActivityDate="2015-02-13T13:25:15.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="118" PostTypeId="1" AcceptedAnswerId="172" CreationDate="2015-02-03T19:26:04.430" Score="16" ViewCount="1384" Body="&lt;p&gt;There are the &quot;normal&quot; straight quotes:&lt;br&gt;&#xA;' &quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you have the angled &quot;smart quotes&quot;:&lt;br&gt;&#xA;‘ ’ “ ”&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's spellcheck works with &quot;straight&quot; quotes, but not angeled quotes, so this is considered &quot;wrong&quot;:&lt;br&gt;&#xA;It’s ... Monty Python’s&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though it's not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screenshot, in case your font doesn't show the difference:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/AYqye.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I fix this? I would prefer to get it working for both variants (it's and it’s).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="23502" LastEditDate="2022-10-27T19:16:02.057" LastActivityDate="2022-10-27T19:16:02.057" Title="How can I use Vim's spellcheck with ‘smart quotes’?" Tags="|spell-checking|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="119" PostTypeId="1" AcceptedAnswerId="121" CreationDate="2015-02-03T19:28:41.753" Score="21" ViewCount="7557" Body="&lt;p&gt;Let's say I have a function, named &lt;code&gt;StripWhitespace&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can run it on a single file by opening the file and running &lt;code&gt;:StripWhitespace&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I automatically run that function against a folder of files, and save the results as I go along?&lt;/p&gt;&#xA;" OwnerUserId="131" LastEditorUserId="24" LastEditDate="2015-02-03T20:13:50.860" LastActivityDate="2015-03-04T07:52:13.803" Title="How can I run a function or macro across a folder of files?" Tags="|macro|multiple-files|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="120" PostTypeId="1" AcceptedAnswerId="156" CreationDate="2015-02-03T19:32:00.867" Score="35" ViewCount="3533" Body="&lt;p&gt;In a very long file with (accurately-) indented code, it may be helpful to move directly to a line of text above or below the cursor which delimits the indenting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(One way of doing this could be via the indent foldmethod, by folding the current indent level, which collapses the lines delimiting the indent level to be only a &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt; away from the cursor. However, I have found instances where indent folding hasn't been able to work on the indent I'm interested in.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example, with the cursor marked by the underscore &lt;code&gt;_&lt;/code&gt; (at the second character column between the definitions of &lt;code&gt;class Bazz&lt;/code&gt; and &lt;code&gt;class Qux&lt;/code&gt;), but imagine that the number of paragraphs or lines within the &lt;code&gt;module&lt;/code&gt;s is unknown or variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;module Foo&#xA;  # lots of code...&#xA;end&#xA;&#xA;module Bar&#xA;  class Baz&#xA;    # ...&#xA;  end&#xA;&#xA;  class Bazz&#xA;    # lots of code...&#xA;  end&#xA; _&#xA;  class Qux&#xA;    # ...&#xA;  end&#xA;&#xA;  class Quux&#xA;    # lots of code...&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...how could I quickly navigate to the &lt;code&gt;o&lt;/code&gt; of &lt;code&gt;module Bar&lt;/code&gt; above the cursor, or the &lt;code&gt;n&lt;/code&gt; of the &lt;code&gt;end&lt;/code&gt; below the cursor at the very last line? Note that the vertical column contains whitespaces, but also no characters at the second column in between the &lt;code&gt;class&lt;/code&gt; definitions.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="205" LastEditDate="2016-04-20T09:30:18.723" LastActivityDate="2019-01-04T13:48:26.850" Title="How do I move vertically until reaching a non-whitespace character?" Tags="|indentation|cursor-movement|" AnswerCount="8" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="121" PostTypeId="2" ParentId="119" CreationDate="2015-02-03T19:33:18.443" Score="14" Body="&lt;p&gt;You can use the &lt;code&gt;-c&lt;/code&gt; argument to run a command on startup, from &lt;code&gt;vim(1)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   -c {command}&#xA;               {command} will be executed after the first  file  has  been&#xA;               read.   {command}  is interpreted as an Ex command.  If the&#xA;               {command} contains spaces it must  be  enclosed  in  double&#xA;               quotes  (this depends on the shell that is used).  Example:&#xA;               Vim &quot;+set si&quot; main.c&#xA;               Note: You can use up to 10 &quot;+&quot; or &quot;-c&quot; commands.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c ':call StripWhitespace()' file1 file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To quit afterwards, add &lt;code&gt;| :wqa&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c ':call StripWhitespace() | :wqa' file1 file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-03T19:33:18.443" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="122" PostTypeId="1" AcceptedAnswerId="125" CreationDate="2015-02-03T19:35:13.177" Score="34" ViewCount="3182" Body="&lt;p&gt;Frequently, in configuration files I might copy and paste a block of lines, then I want to make small changes to that block. After pasting, I use &lt;code&gt;x&lt;/code&gt; to delete characters that I want to remove, then move on to paste the next block. Except &lt;code&gt;x&lt;/code&gt; puts the deleted characters on the clipboard, so I have to recopy the block of lines again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this without going into insert mode?&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="153" LastEditDate="2015-02-11T22:34:25.167" LastActivityDate="2017-03-28T18:29:17.327" Title="Performing certain operations without clearing register" Tags="|cut-copy-paste|register|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="123" PostTypeId="2" ParentId="12" CreationDate="2015-02-03T19:39:28.193" Score="18" Body="&lt;p&gt;For the record, and definitely not the shortest way (see @Undo's awesome solution),&#xA;but sequence of keystrokes will do it too:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;Y&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;9&lt;/kbd&gt;&lt;kbd&gt;8&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me break that down for you:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;i1&amp;lt;Esc&amp;gt;&lt;/code&gt; -- insert the number 1, then get back out to command mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qa&lt;/code&gt; -- start recording a macro in register &quot;a&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Y&lt;/code&gt; -- copy the current line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; -- paste the current line (cursor will also move to the pasted line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Ctrl&amp;gt;a&lt;/code&gt; -- increment the next number on the line, making it 2&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; -- stop recording the macro (was register &quot;a&quot;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;98@a&lt;/code&gt; -- replay the macro in register &quot;a&quot; 98 times&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="135" LastEditorUserId="1841" LastEditDate="2015-07-30T13:25:45.213" LastActivityDate="2015-07-30T13:25:45.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="124" PostTypeId="1" AcceptedAnswerId="525" CreationDate="2015-02-03T19:41:58.970" Score="11" ViewCount="451" Body="&lt;p&gt;I usually have multiple instances of vim running on the same machine. When I make a change to my vimrc I can just &lt;code&gt;:source ~/.vimrc&lt;/code&gt; (with an easy mapping or an autocmd). But in order to have all running instances reflect the change I have to run that in each of them separately. Can I use the &lt;code&gt;clientserver&lt;/code&gt; feature to tell all instances to reload my vimrc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also be interested in solutions that don't use &lt;code&gt;clientserver&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="126" LastEditorUserId="126" LastEditDate="2015-02-03T21:11:58.577" LastActivityDate="2015-02-06T15:15:47.730" Title="Is it possible to use vim's clientserver functionality to keep settings synchronized?" Tags="|vimrc|clientserver|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="125" PostTypeId="2" ParentId="122" CreationDate="2015-02-03T19:42:03.020" Score="38" Body="&lt;p&gt;Your options are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use the black hole register &lt;code&gt;_&lt;/code&gt;.  For example, to delete a line you would type &lt;code&gt;&quot;_dd&lt;/code&gt;.  This deletes without affecting the clipboard.&lt;/li&gt;&#xA;&lt;li&gt;Explicitly name a register for the original yank.  For example, to yank a line into a named register you would type &lt;code&gt;&quot;ayy&lt;/code&gt; then to paste you would type &lt;code&gt;&quot;ap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use the yank registers to retrieve the original yank instead.  You can yank, then delete as necessary, then when you go to paste type &lt;code&gt;&quot;0p&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use a plugin such as &lt;a href=&quot;https://github.com/svermeulen/vim-easyclip&quot;&gt;vim-easyclip&lt;/a&gt; to provide a cut operator that is distinct from the delete operator (full disclosure: I wrote that)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Run &lt;code&gt;:help registers&lt;/code&gt; for more detail on the first 3&lt;/p&gt;&#xA;" OwnerUserId="132" LastEditorUserId="132" LastEditDate="2015-02-03T20:48:52.053" LastActivityDate="2015-02-03T20:48:52.053" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="126" PostTypeId="1" AcceptedAnswerId="132" CreationDate="2015-02-03T19:42:52.910" Score="22" ViewCount="1631" Body="&lt;p&gt;In C and C-like languages, I can use &lt;code&gt;%&lt;/code&gt; to jump to the corresponding curly brace that the cursor is on. This is a well-known &quot;trick&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in Ruby for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def fun&#xA;    [1, 2].each do |n|&#xA;    end&#xA;end &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't work, since ruby doesn't use the characters in &lt;code&gt;matchpairs&lt;/code&gt; (set to &lt;code&gt;(:),{:},[:],&amp;lt;:&amp;gt;&lt;/code&gt; by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried setting that, but it doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set matchpairs=def:end&#xA;E474: Invalid argument: matchpairs=def:end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I get this to work with languages such as Ruby as well? Note this is &lt;em&gt;not&lt;/em&gt; a Ruby-specific question, other examples might be shell scripts (&lt;code&gt;if&lt;/code&gt;/&lt;code&gt;fi&lt;/code&gt;) or Lua (&lt;code&gt;function&lt;/code&gt;/&lt;code&gt;end&lt;/code&gt;), and many many more.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-10-20T13:57:53.160" Title="Using % in languages without curly braces" Tags="|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="127" PostTypeId="2" ParentId="122" CreationDate="2015-02-03T19:43:19.973" Score="12" Body="&lt;p&gt;&lt;code&gt;x&lt;/code&gt; doesn't put things on the clipboard, it puts them into a &lt;em&gt;register&lt;/em&gt;. If you don't tell it which register to put it into, it puts it into the unnamed register, which of course overwrites the previous contents. So, instead, tell it which register to use: &lt;kbd&gt;&lt;code&gt;&quot; REGISTER x&lt;/code&gt;&lt;/kbd&gt;, where REGISTER is any single letter. You then use the same quote-register prefix to &lt;kbd&gt;p&lt;/kbd&gt; to paste from that register. (Note: lowercase replaces their content; uppercase appends).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also two special registers &lt;code&gt;&quot;0&lt;/code&gt; and &lt;code&gt;&quot;1&lt;/code&gt;. &lt;code&gt;&quot;0&lt;/code&gt; is the most recently yanked (&lt;kbd&gt;y&lt;/kbd&gt;) text, which will remain even if you delete some text with another command (like &lt;kbd&gt;x&lt;/kbd&gt;). &lt;code&gt;&quot;1&lt;/code&gt; is the most-recently deleted text, as long as that text isn't small (one line). Small deleted text goes in &lt;code&gt;&quot;-&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, as Steve Vermeulen points out, you can tell vim not to save deleted text by specifying the black hole register &lt;code&gt;&quot;_&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant help command is &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#registers&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help registers&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="31" LastEditorUserId="205" LastEditDate="2015-02-12T05:28:36.083" LastActivityDate="2015-02-12T05:28:36.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="128" PostTypeId="2" ParentId="104" CreationDate="2015-02-03T19:46:22.897" Score="37" Body="&lt;p&gt;You can use &lt;code&gt;:!ls %:p&lt;/code&gt; to get the full path to the current file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the ex context, &lt;code&gt;%&lt;/code&gt; will either mean the contents of the file or the filename. When shelling out, it represents the file path relative to the current directory. The command '&lt;code&gt;%:p&lt;/code&gt;' will add the full path filename modifier to &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few other interesting filename modifiers such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:~&lt;/code&gt;: Get the file path relative to the home directory (this one didn't work for me for some reason)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:.&lt;/code&gt;: Get the file path relative to the current directory (&lt;code&gt;%&lt;/code&gt; default)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:r&lt;/code&gt;: File name root. The name of the file without the extension.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:e&lt;/code&gt;: File's extension.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h&lt;/code&gt;: Split on &lt;code&gt;/&lt;/code&gt; and return the left half (i.e. if I'm editing a file in a path of &lt;code&gt;/tmp/test.txt&lt;/code&gt; and run &lt;code&gt;%:p:h&lt;/code&gt; will return &lt;code&gt;/tmp&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:t&lt;/code&gt;: Split on &lt;code&gt;/&lt;/code&gt; and return the right half (i.e. if I'm editing a file in a path of &lt;code&gt;/tmp/test.txt&lt;/code&gt; and run &lt;code&gt;%:p:t&lt;/code&gt; will return &lt;code&gt;text.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="133" LastEditorUserId="133" LastEditDate="2015-02-05T12:42:43.193" LastActivityDate="2015-02-05T12:42:43.193" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="129" PostTypeId="1" AcceptedAnswerId="142" CreationDate="2015-02-03T19:47:54.417" Score="13" ViewCount="1504" Body="&lt;p&gt;Too often do I make the mistake of typing with the wrong window focused (and have done so a few times with a USB authenticator). In programs with lots of hotkeys enabled (Gmail, VLC, Vim), this often has the unintended consequence of making unwanted modifications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can sometimes trace my steps and remember what I have typed to repair any changes or revert any settings that I tweaked if I catch myself early. Unfortunately, that is not always the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim, I could have something as innocuous and apparent as altering a line of text which is easily undone. Or, I could have unknowingly modified something not so easily identified. &lt;strong&gt;If I accidentally type a sequence of unwanted commands in Vim, how can I check for and undo any edits or changes to settings?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="114" LastEditorUserId="24" LastEditDate="2015-02-05T08:44:35.610" LastActivityDate="2015-08-11T06:55:45.113" Title="How can I safely undo changes that I may or may not have made?" Tags="|undo-redo|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="130" PostTypeId="1" AcceptedAnswerId="161" CreationDate="2015-02-03T19:48:24.160" Score="41" ViewCount="8884" Body="&lt;p&gt;How do I comment out multiple in visual mode selected lines? How do I make it language specific?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if the first 4 lines are selected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo(a,b):&#xA;    for each in (a,b):&#xA;        print each&#xA;    return a+b&#xA;print &quot;2&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The operation of a command/macro should result in this (in python):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#def foo(a,b):&#xA;#    for each in (a,b):&#xA;#        print each&#xA;#    return a+b&#xA;print &quot;2&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="129" LastEditorUserId="205" LastEditDate="2017-02-27T09:40:25.897" LastActivityDate="2023-05-11T20:25:54.170" Title="How to comment out a set of lines which are selected in visual mode?" Tags="|visual-mode|comments|" AnswerCount="12" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="132" PostTypeId="2" ParentId="126" CreationDate="2015-02-03T19:51:50.833" Score="20" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=39&quot;&gt;matchit&lt;/a&gt; plugin. This is included in modern vim distributions, so all you have to do to use it is add the following to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime macros/matchit.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also get it packaged as a plugin if you prefer. It recognizes many keywords by default (including &lt;code&gt;def&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt;) and can be extended to recognize more.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2015-02-03T19:51:50.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="133" PostTypeId="2" ParentId="122" CreationDate="2015-02-03T19:55:35.200" Score="3" Body="&lt;p&gt;The &lt;code&gt;:let&lt;/code&gt; command will let you redefine a named register. In vim's command line, pressing &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;R&lt;/kbd&gt; &lt;em&gt;twice&lt;/em&gt;&lt;sup&gt;1&lt;/sup&gt; and then the register name will paste the register's contents into the command. Then you can then modify what it's pasted, and save the register with your modifications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In normal mode, on a line containing the text &quot;Foo Bar&quot;, typing &lt;code&gt;&quot;fyy&lt;/code&gt; yanks the whole line (&lt;code&gt;yy&lt;/code&gt;) into the &lt;code&gt;f&lt;/code&gt; register (&lt;code&gt;&quot;f&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;:let @f='&lt;/code&gt;, and &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt;, &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt; again, then &lt;kbd&gt;f&lt;/kbd&gt;, and you should see it paste in &quot;Foo Bar&quot;, so your command line now reads &lt;code&gt;:let @f='Foo Bar&lt;/code&gt;, with the cursor at the very end.&lt;/li&gt;&#xA;&lt;li&gt;Now you can use the arrows and delete keys to edit what you've just pasted in, such as &lt;code&gt;:let @f='foo bar baz&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Finish off the quoting: &lt;code&gt;:let @f='foo bar baz'&lt;/code&gt; and hit &lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now you've redefined the contents of the &lt;code&gt;f&lt;/code&gt; register to be &quot;foo bar baz&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This also works for macros! &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Alet&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help let&lt;/code&gt;&lt;/a&gt; for more information.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt; lets you insert a register when you're already in insert mode, as if you're typing the characters. Using this sequence &lt;em&gt;twice&lt;/em&gt; is important because &quot;the text is inserted literally, not as if typed. This differs when the register contains characters like &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt;.&quot; —&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-R_CTRL-R&quot; rel=&quot;nofollow&quot;&gt;the insert.txt vimdoc, &lt;code&gt;:help i_CTRL-R_CTRL-R&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2015-02-12T08:28:21.127" LastActivityDate="2015-02-12T08:28:21.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="134" PostTypeId="2" ParentId="63" CreationDate="2015-02-03T19:58:20.080" Score="20" Body="&lt;p&gt;You can learn Vim by reading &lt;code&gt;:help&lt;/code&gt; from top to bottom. When you enter &lt;code&gt;:help&lt;/code&gt;, it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*help.txt*      For Vim version 7.3.  Last change: 2010 Jul 20&#xA;&#xA;                        VIM - main help file&#xA;                                                                         k&#xA;      Move around:  Use the cursor keys, or &quot;h&quot; to go left,            h   l&#xA;                    &quot;j&quot; to go down, &quot;k&quot; to go up, &quot;l&quot; to go right.       j&#xA;Close this window:  Use &quot;:q&amp;lt;Enter&amp;gt;&quot;.&#xA;   Get out of Vim:  Use &quot;:qa!&amp;lt;Enter&amp;gt;&quot; (careful, all changes are lost!).&#xA;&#xA;Jump to a subject:  Position the cursor on a tag (e.g. |bars|) and hit CTRL-].&#xA;   With the mouse:  &quot;:set mouse=a&quot; to enable the mouse (in xterm or GUI).&#xA;                    Double-click the left mouse button on a tag, e.g. |bars|.&#xA;        Jump back:  Type CTRL-T or CTRL-O (repeat to go further back).&#xA;&#xA;Get specific help:  It is possible to go directly to whatever you want help&#xA;                    on, by giving an argument to the |:help| command.&#xA;                    It is possible to further specify the context:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, it starts from the essentials, such as moving around, jumping to subjects and back, and so on. If you scroll down a little bit, this list of documents becomes visible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;------------------------------------------------------------------------------&#xA;                                                *doc-file-list* *Q_ct*&#xA;BASIC:&#xA;|quickref|      Overview of the most common commands you will use&#xA;|tutor|         30 minutes training course for beginners&#xA;|copying|       About copyrights&#xA;|iccf|          Helping poor children in Uganda&#xA;|sponsor|       Sponsor Vim development, become a registered Vim user&#xA;|www|           Vim on the World Wide Web&#xA;|bugs|          Where to send bug reports&#xA;&#xA;USER MANUAL: These files explain how to accomplish an editing task.&#xA;&#xA;|usr_toc.txt|   Table Of Contents&#xA;&#xA;Getting Started&#xA;|usr_01.txt|  About the manuals&#xA;|usr_02.txt|  The first steps in Vim&#xA;|usr_03.txt|  Moving around&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the navigation tips that were given at the top (and &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt; to follow a link) you can start visiting the sections, for example starting from &lt;code&gt;tutor&lt;/code&gt;.&#xA;(This is actually how I learned Vim in the first place.)&lt;/p&gt;&#xA;" OwnerUserId="135" LastEditorUserId="24" LastEditDate="2015-02-03T20:05:04.163" LastActivityDate="2015-02-03T20:05:04.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="135" PostTypeId="1" CreationDate="2015-02-03T20:05:17.607" Score="1" ViewCount="271" Body="&lt;p&gt;If I have vim in a windowed terminal, sometimes I paste (using the terminal's paste functionality, e.g. middle click) from another window that isn't vim. Most of the time, when I do this, I wanted to be in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously, this mistake can basically do anything that vim can do; most of the time there will be an early insert-mode character that will prevent most forms of document damage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the best way to recover from this mistake?&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="24" LastEditDate="2015-02-05T08:45:16.603" LastActivityDate="2015-02-05T08:45:16.603" Title="What can happen if I accidentally paste into command mode? What should I do if I do this?" Tags="|cut-copy-paste|undo-redo|" AnswerCount="1" CommentCount="1" ClosedDate="2015-02-03T22:44:40.350" ContentLicense="CC BY-SA 3.0" />
  <row Id="136" PostTypeId="2" ParentId="84" CreationDate="2015-02-03T20:07:10.283" Score="22" Body="&lt;p&gt;The other answers cover how to copy text from your buffer into the system clipboard.&#xA;Another common operation is to copy text from another &lt;em&gt;register&lt;/em&gt; to the clipboard.&#xA;For example, if you've already yanked some text into &lt;code&gt;&quot;&lt;/code&gt; (the default register), you might want to load that register into the clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do this with &lt;code&gt;:let&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;let @+=@&quot;&lt;/code&gt; &amp;mdash; copies the default register into the clipboard&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;let @*=@&quot;&lt;/code&gt; &amp;mdash; copies the default register into the X11 primary selection (&quot;mouse clipboard&quot;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;let @+=@a&lt;/code&gt; &amp;mdash; copy from register &lt;code&gt;a&lt;/code&gt; to the clipboard&lt;/li&gt;&#xA;&lt;li&gt;etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that this works for registers in general: &lt;code&gt;let @a=@b&lt;/code&gt; copies register &lt;code&gt;b&lt;/code&gt; to register &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="142" LastActivityDate="2015-02-03T20:07:10.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="137" PostTypeId="1" AcceptedAnswerId="138" CreationDate="2015-02-03T20:08:43.133" Score="13" ViewCount="11299" Body="&lt;p&gt;How do I edit &lt;code&gt;crontab&lt;/code&gt; files in FreeBSD?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ crontab -e&#xA;# ... I do my thing in vim &amp;amp; :wq&#xA;&#xA;&quot;crontab.9ZcXiFaawt&quot; 6L, 203C written&#xA;crontab: temp file must be edited in place&#xA;Exit 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;EDITOR=nvi&lt;/code&gt; works fine... Linux also seems to work fine...&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="23502" LastEditDate="2022-10-27T19:12:58.920" LastActivityDate="2022-10-27T19:12:58.920" Title="How do I edit crontab files with Vim (I get the error: 'temp file must be edited in place')?" Tags="|save|unix|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="138" PostTypeId="2" ParentId="137" CreationDate="2015-02-03T20:08:43.133" Score="19" Body="&lt;p&gt;The problem is how Vim writes files. By default, it makes a copy of the file and overwrite the original one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can observe this with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Show the file's inode&#xA;$ ls -i a&#xA;3156153 a&#xA;&#xA;# Open file in Vim, :wq&#xA;&#xA;# inode changed!&#xA;$ ls -i a&#xA;3155322 a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;crontab&lt;/code&gt; gets confused by this (see &lt;code&gt;:help crontab&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to use &lt;code&gt;:set backupcopy&lt;/code&gt; to &lt;code&gt;yes&lt;/code&gt; to make Vim overwrite the original file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;yes&quot;   make a copy of the file and overwrite the original one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can do this automatically for crontab files with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType crontab setlocal bkc=yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-03T20:08:43.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="139" PostTypeId="2" ParentId="135" CreationDate="2015-02-03T20:12:05.883" Score="7" Body="&lt;p&gt;Assuming that no &lt;code&gt;:w&lt;/code&gt; or &lt;code&gt;:write&lt;/code&gt; command was issued, all of the changes should still be in the buffer only, not written to disk.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An &lt;code&gt;:earlier 30s&lt;/code&gt; command should restore your buffer to the state it was in 30 seconds ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if you want to discard all changes, there's always &lt;code&gt;:quit!&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2015-02-03T20:12:05.883" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="140" PostTypeId="2" ParentId="130" CreationDate="2015-02-03T20:14:27.513" Score="10" Body="&lt;p&gt;Doing it automatically would require you to add something like the following to your &lt;code&gt;vimrc&lt;/code&gt; file (&lt;a href=&quot;http://vim.wikia.com/wiki/Comment/UnComment_visually_selected_text&quot;&gt;source&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType haskell,vhdl,ada let b:comment_leader = '-- '&#xA;au FileType vim let b:comment_leader = '&quot; '&#xA;au FileType c,cpp,java let b:comment_leader = '// '&#xA;au FileType sh,make let b:comment_leader = '# '&#xA;au FileType tex let b:comment_leader = '% '&#xA;noremap &amp;lt;silent&amp;gt; ,c :&amp;lt;C-B&amp;gt;sil &amp;lt;C-E&amp;gt;s/^/&amp;lt;C-R&amp;gt;=escape(b:comment_leader,'\/')&amp;lt;CR&amp;gt;/&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; ,u :&amp;lt;C-B&amp;gt;sil &amp;lt;C-E&amp;gt;s/^\V&amp;lt;C-R&amp;gt;=escape(b:comment_leader,'\/')&amp;lt;CR&amp;gt;//e&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt; to comment a region and &lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;u&lt;/kbd&gt; to uncomment a region. This manually sets the comment symbols for different languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second option is to use a plugin like &lt;a href=&quot;https://github.com/tomtom/tcomment_vim&quot;&gt;tcomment&lt;/a&gt;, &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot;&gt;vim-commentary&lt;/a&gt; or &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1528&quot;&gt;comments.vim&lt;/a&gt;. I use tcomment myself. Please, read the instructions on usage and installation at their pages, as I beleive that's beyond the topic of the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suggest you use a plugin (one of the linked above or another) as that is much easier than maintaining a piece of code in your &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I removed the manual way as the question was changed and also the correct way was answered by 200_success.&lt;/p&gt;&#xA;" OwnerUserId="20" LastEditorUserId="20" LastEditDate="2015-02-03T20:25:31.463" LastActivityDate="2015-02-03T20:25:31.463" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="141" PostTypeId="2" ParentId="130" CreationDate="2015-02-03T20:14:48.397" Score="26" Body="&lt;p&gt;Using Visual Block mode (&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;), select the beginning of the lines.  Then hit &lt;kbd&gt;I&lt;/kbd&gt;&lt;kbd&gt;#&lt;/kbd&gt; (that's a capital letter &lt;code&gt;I&lt;/code&gt;) to insert the hash character on each of those lines. Then press &lt;kbd&gt;Esc&lt;/kbd&gt; to return from Insert Mode to Normal Mode.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-05T22:10:28.163" LastActivityDate="2015-02-05T22:10:28.163" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="142" PostTypeId="2" ParentId="129" CreationDate="2015-02-03T20:17:33.793" Score="16" Body="&lt;p&gt;Invoke&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:undolist&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to see when you made the last set of changes.&#xA;If it says that there were a few changes made, e.g., &quot;3 seconds ago,&quot; and you know that you only &lt;em&gt;intentionally&lt;/em&gt; changed it, say, a minute ago, then execute&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:earlier 10s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to revert to the desired state.&#xA;Otherwise, if there are no recent changes, you don't have to do anything.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Further reference:&lt;/strong&gt; &lt;code&gt;:help undo-tree&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="142" LastActivityDate="2015-02-03T20:17:33.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="143" PostTypeId="1" AcceptedAnswerId="152" CreationDate="2015-02-03T20:19:53.617" Score="9" ViewCount="421" Body="&lt;p&gt;There is many times in my day to day work life that I need to operate on a specific function, things like highlighting or searching for a variable, but I have never managed to limit the scope of the edits/search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way in vim to selectively say, find all references to &lt;code&gt;$color&lt;/code&gt; inside these sets of braces, or this fold etc. If possible, it would be ideal this is relatively generic, so that it could be applied to Editing/Replacing text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$color = &quot;#fff&quot;;&#xA;function PickColor () {&#xA;  $color = &quot;#bbb&quot;;&#xA;  $newColors = [&quot;#000&quot;, &quot;#fbf&quot;, $color];&#xA;  foreach ($newColors as $c) {&#xA;    if ($c == &quot;#fff&quot;) {&#xA;       break;&#xA;    }&#xA;  }&#xA;}&#xA;$differentColor = $color;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code is a relatively bad example, however, if I needed to replace all instances of $color how would one do this in the context of the function PickColor. As another example, using &lt;code&gt;#&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; You can go to the next instance of that text object, how would you limit the scope for the search to just this function (basically wrapping the search) opposed to the entire file which could span thousands of lines and losing your place, or incorrectly replacing something in another function that you shouldn't have?&lt;/p&gt;&#xA;" OwnerUserId="137" LastEditorUserId="24" LastEditDate="2015-02-03T20:45:33.553" LastActivityDate="2015-02-06T22:38:25.773" Title="Restricting operations to a section of code" Tags="|search|cursor-motions|ide|substitute|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="144" PostTypeId="2" ParentId="124" CreationDate="2015-02-03T20:20:36.633" Score="-1" Body="&lt;p&gt;I don't know about clientserver, but since you said you were interested in other solutions I would recommend looking into this writeup about dotfiles from Github.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://dotfiles.github.io&quot; rel=&quot;nofollow&quot;&gt;https://dotfiles.github.io&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You obviously don't have to use Github, but the concepts are sound and seem to be widely used.&lt;/p&gt;&#xA;" OwnerUserId="41" LastActivityDate="2015-02-03T20:20:36.633" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="145" PostTypeId="2" ParentId="120" CreationDate="2015-02-03T20:20:56.407" Score="2" Body="&lt;p&gt;It's not exactly what you asked for because it's not vertical movement,&#xA;but something that's similar, fast, and might be good enough for you is moving backward 2 paragraphs: &lt;kbd&gt;{&lt;/kbd&gt;&lt;kbd&gt;{&lt;/kbd&gt;. This will take you to the line right before &lt;code&gt;module Bar&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="135" LastActivityDate="2015-02-03T20:20:56.407" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="146" PostTypeId="2" ParentId="130" CreationDate="2015-02-03T20:23:20.947" Score="20" Body="&lt;p&gt;If you just need a quick solution for whatever language you're currently in, and you already have the text selected in visual mode, then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm 0i#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does the job.&#xA;(For each line, in normal mode, go to the first column and insert &lt;code&gt;#&lt;/code&gt;. Using &lt;code&gt;:norm I#&lt;/code&gt; will insert it before the first non-whitespace character, which may not be what you want.)&#xA;Using &lt;code&gt;:norm i#&lt;/code&gt; will also work, because &lt;code&gt;:norm&lt;/code&gt; starts at the beginning of the line, but it's less explicit and less clear if you don't know that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if you intend to do this frequently, you'll want to set up a mapping or look for a plugin.&lt;/p&gt;&#xA;" OwnerUserId="142" LastEditorUserId="142" LastEditDate="2015-02-19T15:17:48.543" LastActivityDate="2015-02-19T15:17:48.543" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="147" PostTypeId="2" ParentId="129" CreationDate="2015-02-03T20:23:34.877" Score="4" Body="&lt;p&gt;To rephrase the question, you are looking for a way to see or otherwise get notified about the changes you have made to a file, and then use an undo feature. There maybe other way or even plugins which supports this. But I'll explain what I've been using for the same purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You combine existing vim feature to get this done. For example, you could define a function such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Function: View changes after the last save&#xA;function! s:DiffSinceSave()&#xA;  let filetype=&amp;amp;ft&#xA;  diffthis&#xA;  vnew | r # | normal! 1Gdd&#xA;  diffthis&#xA;  exe &quot;setlocal bt=nofile bh=wipe nobl noswf ro ft=&quot; . filetype&#xA;  exe &quot;normal! ]c&quot;&#xA;endfunction&#xA;com! DiffSaved call s:DiffSinceSave()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then call it later and even map a shortcut key.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Map key to function: View changes after the last save&#xA;nnoremap &amp;lt;leader&amp;gt;? :DiffSaved&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will open a split window based diff view which will show you changes made since the last save. After you have identified the changes made, then you can quit that view and use other vim features such as undo and undo tree, etc. or even plugins to revert back to previous states.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize that this is not ideal because you have to have a certain kind of workflow for this to be useful. But this works fairly well. And on the plus side, we aren't changing how vim works or relying on anything outside. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope you find this useful. I adapted this solution a while ago from snippets found on the Internet including vim Wikia. So that's where any credit is due.&lt;/p&gt;&#xA;" OwnerUserId="138" LastActivityDate="2015-02-03T20:23:34.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="148" PostTypeId="2" ParentId="143" CreationDate="2015-02-03T20:24:51.200" Score="3" Body="&lt;p&gt;You select the block you are interested in in visual line mode (shift + v) and then you type &lt;code&gt;:&lt;/code&gt; and your command which will now apply to the block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you wanted to replace in the selection, you can run &lt;code&gt;:s/string/replacement_string&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="150" LastActivityDate="2015-02-03T20:24:51.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="149" PostTypeId="1" AcceptedAnswerId="162" CreationDate="2015-02-03T20:29:25.623" Score="67" ViewCount="52803" Body="&lt;p&gt;I have server log files that are several gigabytes in size (on Ubuntu). When I attempt to open them, the terminal locks up for a minute or so while the file is loaded into Vim. Is there a way to reduce this time, for example by setting Vim to load the file on demand, or by some other method?&lt;/p&gt;&#xA;" OwnerUserId="77" LastEditorUserId="24" LastEditDate="2015-02-03T20:31:30.080" LastActivityDate="2022-10-30T20:04:08.147" Title="How can I open very large files with good performance?" Tags="|large-documents|" AnswerCount="5" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="150" PostTypeId="2" ParentId="149" CreationDate="2015-02-03T20:30:42.350" Score="4" Body="&lt;p&gt;I have heard that turning off syntax highlighting can help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18" LastEditorDisplayName="user2" LastEditDate="2015-02-03T20:43:52.997" LastActivityDate="2015-02-03T20:43:52.997" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="151" PostTypeId="1" AcceptedAnswerId="153" CreationDate="2015-02-03T20:30:52.303" Score="9" ViewCount="305" Body="&lt;p&gt;I'm editing Prolog files as part of an exploratory project, and some of the files I'm working with have the extension &lt;code&gt;.pl&lt;/code&gt;, which is shared by Perl files. Whenever I do work on a Prolog file named &lt;code&gt;[somefile].pl&lt;/code&gt;, Vim gives me syntax highlighting and error detection for Perl, rather than Prolog. I could totally disable syntax highlighting for Perl or force &lt;code&gt;.pl&lt;/code&gt; to be recognized as Prolog, but I'd like to know if there's a less dictatorial way of fixing the issue. Is there a way I can set the syntax highlighting programmatically, or use some sort of a key combination to tell Vim that I'm editing a Prolog file rather than a Perl file?&lt;/p&gt;&#xA;" OwnerUserId="151" LastEditorUserId="24" LastEditDate="2015-02-04T12:34:35.907" LastActivityDate="2015-02-04T16:56:29.633" Title="How can I get correct autocompletion for ambiguous file extensions?" Tags="|ide|syntax-highlighting|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="152" PostTypeId="2" ParentId="143" CreationDate="2015-02-03T20:31:53.157" Score="14" Body="&lt;p&gt;Here are a few ways to do it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1  | $color = &quot;#fff&quot;;&#xA;2  | function PickColor () {&#xA;3  |     $color = &quot;#bbb&quot;;&#xA;4  |     $newColors = [&quot;#000&quot;, &quot;#fbf&quot;, $color];&#xA;5  |     foreach ($newColors as $c) {&#xA;6  |         if ($c == &quot;#fff&quot;) {&#xA;7  |             break;&#xA;8  |         }&#xA;9  |     }&#xA;10 | }&#xA;11 | $differentColor = $color;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've modified your example to include line numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now you can replace instances of &lt;code&gt;$color&lt;/code&gt;, with say &lt;code&gt;$newColor&lt;/code&gt;, in the following ways.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Line Number Ranges&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:1,11s/\$color/$newColor/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This makes the substitution operate on lines 1-11 inclusive.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Relative Line Ranges&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Place your cursor on line 1, then...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:.,11s/\$color/$newColor/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This says the range starts with the current line and ends on line 11.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Visual Selection Ranges&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Go to line 1 and press &lt;code&gt;Shift+V&lt;/code&gt; then &lt;code&gt;G&lt;/code&gt;.  This visually selects line 1.  Then...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;:s/\$color/$newColor/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This limits the substitution to the range covered by your selection.  Vim will automatically insert the &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; range for you when you press &lt;code&gt;:&lt;/code&gt; with an active selection.&lt;/p&gt;&#xA;" OwnerUserId="93" LastActivityDate="2015-02-03T20:31:53.157" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="153" PostTypeId="2" ParentId="151" CreationDate="2015-02-03T20:36:13.377" Score="7" Body="&lt;p&gt;I can only answer the second part of your question.&#xA;You can tell Vim that you're editing a Prolog file with this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set syntax=prolog&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you never work in Perl, then it wouldn't seem &quot;dictatorial&quot; to add custom configuration in your &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.pl setfiletype prolog syntax=prolog&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="135" LastEditorUserId="135" LastEditDate="2015-02-03T20:42:42.273" LastActivityDate="2015-02-03T20:42:42.273" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="154" PostTypeId="2" ParentId="130" CreationDate="2015-02-03T20:36:21.547" Score="5" Body="&lt;p&gt;I use &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;noreferrer&quot;&gt;scrooloose/nerdcommenter&lt;/a&gt; for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this plugin you can visual select your lines and hit &lt;kbd&gt;leader&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt; to toggle comments. Depending on the file type it will use different symbols for commenting.&lt;/p&gt;&#xA;" OwnerUserId="153" LastActivityDate="2015-02-03T20:36:21.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="155" PostTypeId="2" ParentId="151" CreationDate="2015-02-03T20:36:39.293" Score="5" Body="&lt;p&gt;You could add the following to the top or the bottom of the file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%vim: ft=prolog&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will tell Vim to treat the file as a Prolog file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_21.html#21.6&quot; rel=&quot;nofollow&quot;&gt;“Modelines” in the user manual&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#modeline&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help modeline&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="93" LastEditorUserId="8" LastEditDate="2015-02-04T16:56:29.633" LastActivityDate="2015-02-04T16:56:29.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="156" PostTypeId="2" ParentId="120" CreationDate="2015-02-03T20:40:42.683" Score="10" Body="&lt;p&gt;How about this function?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function FloatUp()&#xA;    while line(&quot;.&quot;) &amp;gt; 1&#xA;                \ &amp;amp;&amp;amp; (strlen(getline(&quot;.&quot;)) &amp;lt; col(&quot;.&quot;)&#xA;                \ || getline(&quot;.&quot;)[col(&quot;.&quot;) - 1] =~ '\s')&#xA;        norm k&#xA;    endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could &lt;code&gt;nnoremap gU :call FloatUp()&amp;lt;CR&amp;gt;&lt;/code&gt; (&lt;code&gt;gU&lt;/code&gt; for &quot;go up&quot;), and then invoke with &lt;code&gt;gU&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The code repeatedly moves up the cursor (with &lt;code&gt;norm k&lt;/code&gt;) as long as the &lt;code&gt;while&lt;/code&gt; condition holds.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;while&lt;/code&gt; condition holds if this is not the first line (&lt;code&gt;line(&quot;.&quot;) &amp;gt; 1&lt;/code&gt;) and either&#xA;&lt;ul&gt;&#xA;&lt;li&gt;this line is too short (probably empty); or&lt;/li&gt;&#xA;&lt;li&gt;the current line (&lt;code&gt;getline(&quot;.&quot;)&lt;/code&gt;)'s character at the current column (&lt;code&gt;[col(&quot;.&quot;) - 1]&lt;/code&gt;) is whitespace (&lt;code&gt;=~ '\s'&lt;/code&gt;; i.e., matches the whitespace pattern).&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="142" LastEditorUserId="142" LastEditDate="2015-02-03T20:48:38.363" LastActivityDate="2015-02-03T20:48:38.363" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="157" PostTypeId="2" ParentId="120" CreationDate="2015-02-03T20:44:38.657" Score="3" Body="&lt;p&gt;I use a modified version of the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3037&quot; rel=&quot;nofollow&quot;&gt;vim-indent-object&lt;/a&gt; plugin to provide this behavior.  My modifications can be seen &lt;a href=&quot;https://github.com/svermeulen/vim-indent-object/blob/working/plugin/indentobject.vim&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This allows me to map &lt;code&gt;[i&lt;/code&gt; to go to beginning of current indent level and &lt;code&gt;]i&lt;/code&gt; to go the end.&lt;/p&gt;&#xA;" OwnerUserId="132" LastActivityDate="2015-02-03T20:44:38.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="159" PostTypeId="5" CreationDate="2015-02-03T20:49:25.377" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-03T20:49:25.377" LastActivityDate="2015-02-03T20:49:25.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="160" PostTypeId="4" CreationDate="2015-02-03T20:49:25.377" Score="0" Body="Questions about the use of Vim as an integrated development environment for programming" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-03T21:36:27.347" LastActivityDate="2015-02-03T21:36:27.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="161" PostTypeId="2" ParentId="130" CreationDate="2015-02-03T20:55:03.410" Score="39" Body="&lt;p&gt;If you want language specific commenting you will need a plugin like &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;noreferrer&quot;&gt;nerdcommenter&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, although it doesn't answer your actual question, you can use builtin vim actions and your knowledge of each language's comment characters...&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Option #1: V-blocks&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:1&lt;/code&gt; &lt;kbd&gt;Enter&lt;/kbd&gt;  (Go to line 1)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-V (V-Block mode)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;jjj&lt;/code&gt; (Down 3 more lines)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;-I (Enter insert mode before the block)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;#&lt;/code&gt; (Insert a '#')&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; (Back to normal mode)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Option #2: Substitution&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,4s/^/#/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Breakdown:&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:&lt;/code&gt; Ex command follows&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1,4&lt;/code&gt; on lines from 1 through 4&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s&lt;/code&gt; substitute&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt; separator for pieces of the substitution command.&lt;br&gt;&#xA;(You can also use a different character, e.g. &lt;code&gt;:&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; beginning of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt; separator&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;#&lt;/code&gt; the comment character for python&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt; final separator&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Option #3: Repeat application of a macro (&lt;a href=&quot;https://stackoverflow.com/questions/355907/how-do-i-repeat-an-edit-on-multiple-lines-in-vim&quot;&gt;source&lt;/a&gt;)&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:1&lt;/code&gt; &lt;kbd&gt;Enter&lt;/kbd&gt; (Go to line 1)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qa&lt;/code&gt; (Start recording on register &lt;code&gt;a&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;KBD&gt;Shift&lt;/KBD&gt;-I (Enter insert mode at the beginning of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;#&lt;/code&gt; (Add a '#' at the beginning of the line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; (Back to normal mode)&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;q&lt;/code&gt; (Stop recording)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:2,4 normal @a&lt;/code&gt; (re-run the macro recorded to register &lt;code&gt;a&lt;/code&gt; on lines between 2 and 4)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OR&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you can select the lines in visual mode and hit &lt;code&gt;:&lt;/code&gt; to automatically&#xA;populate the Ex line with &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt; (a range from the beginning to the end of the&#xA;visual selection) then type &lt;code&gt;normal @a&lt;/code&gt; and hit &lt;KBD&gt;Enter&lt;/KBD&gt; (&lt;a href=&quot;https://stackoverflow.com/questions/3337926/vim-macro-on-every-line-of-visual-selection&quot;&gt;source&lt;/a&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now, whenever you want to comment some lines just re-run the macro recorded&#xA;to register &lt;code&gt;a&lt;/code&gt; on those lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:9,22 normal @a (comment out lines 9-22)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="141" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-09-04T16:34:18.787" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="162" PostTypeId="2" ParentId="149" CreationDate="2015-02-03T20:57:28.410" Score="75" Body="&lt;p&gt;First, try loading vim with no plugins or vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE gargantuan.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this is substantially faster, then you probably have syntax highlighting, folding, plugins, or something else going on that's taking up most of the time.&#xA;Try turning stuff off in your vimrc (and disabling your plugins) until you find the culprit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also make sure to &lt;code&gt;set ft= syn=&lt;/code&gt; and &lt;code&gt;syntax off&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this doesn't help, it's probably the case that you have very long &lt;em&gt;lines&lt;/em&gt; that are causing the problem.&#xA;Try &lt;code&gt;set nowrap&lt;/code&gt; to turn line wrapping off.&lt;/p&gt;&#xA;" OwnerUserId="142" LastActivityDate="2015-02-03T20:57:28.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="163" PostTypeId="1" AcceptedAnswerId="166" CreationDate="2015-02-03T20:58:03.903" Score="14" ViewCount="1208" Body="&lt;p&gt;There are times when I want to test changes to a file before I overwrite the original.&#xA;Is there any way I can save a file being edited to a new file?&lt;/p&gt;&#xA;" OwnerUserId="25" LastEditorUserId="24" LastEditDate="2015-02-03T22:36:36.597" LastActivityDate="2015-02-03T22:36:36.597" Title="How do you save the file that you're working on as a new file?" Tags="|save|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="164" PostTypeId="2" ParentId="163" CreationDate="2015-02-03T20:59:40.730" Score="0" Body="&lt;p&gt;Yes, there is a way.&#xA;&lt;code&gt;:w new_file_name&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="162" LastActivityDate="2015-02-03T20:59:40.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="165" PostTypeId="2" ParentId="163" CreationDate="2015-02-03T21:00:02.860" Score="0" Body="&lt;p&gt;Simply specify a newfilepath at the &lt;code&gt;:w&lt;/code&gt; command - &lt;code&gt;:w newfile.foo&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="161" LastActivityDate="2015-02-03T21:00:02.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="166" PostTypeId="2" ParentId="163" CreationDate="2015-02-03T21:01:59.670" Score="23" Body="&lt;p&gt;You can give a parameter to the &lt;code&gt;:w&lt;/code&gt; or &lt;code&gt;:write&lt;/code&gt; command to save to a different file.&#xA;For example to save the current buffer to &lt;code&gt;/tmp/data.txt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w /tmp/data.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, keep in mind that this does not switch your buffer to that other file.&#xA;So if you keep editing and do just &lt;code&gt;:w&lt;/code&gt;, that will save to the current file, not to the other one. To switch to the other file, use the &lt;code&gt;:edit&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e /tmp/data.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To do this one step, save to another file and switch to it, use the &lt;code&gt;:saveas&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sav /tmp/data.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="135" LastActivityDate="2015-02-03T21:01:59.670" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="167" PostTypeId="2" ParentId="163" CreationDate="2015-02-03T21:02:40.437" Score="6" Body="&lt;p&gt;Vim has a &quot;backup mode&quot; that can be enabled by &lt;code&gt;:set backup&lt;/code&gt; or &lt;code&gt;:set patchmode&lt;/code&gt;.  In that mode, Vim automatically keeps a backup copy of files that you write.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you issue &lt;code&gt;:set patchmode=.orig&lt;/code&gt;, and you edit an existing file &lt;code&gt;somefile.txt&lt;/code&gt;, then when you issue &lt;code&gt;:w&lt;/code&gt; normally, Vim will keep a copy of the old file as &lt;code&gt;somefile.txt.orig&lt;/code&gt; and save the new contents as &lt;code&gt;somefile.txt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2015-02-03T21:02:40.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="168" PostTypeId="1" AcceptedAnswerId="171" CreationDate="2015-02-03T21:05:35.887" Score="15" ViewCount="614" Body="&lt;p&gt;Is it possible to retrieve changes branch that I &amp;quot;abandoned&amp;quot;?&lt;/p&gt;&#xA;&lt;p&gt;For example, I am undoing several operations using &lt;code&gt;u&lt;/code&gt;, then I am making a change in insert mode. But then I realize I don't want to have this change, I would rather go back to where I was at the beginning (before undoing).&lt;/p&gt;&#xA;&lt;p&gt;Are these changes lost forever?&lt;/p&gt;&#xA;" OwnerUserId="162" LastEditorUserId="23502" LastEditDate="2022-10-27T19:10:55.833" LastActivityDate="2022-10-27T19:10:55.833" Title="How do you use changes tree in vim?" Tags="|undo-redo|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="169" PostTypeId="2" ParentId="149" CreationDate="2015-02-03T21:06:13.583" Score="27" Body="&lt;p&gt;Vim is the wrong tool for the job: you should use a pager like &lt;code&gt;more&lt;/code&gt; or &lt;code&gt;less&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you insist on using an editor, try &lt;a href=&quot;http://vim.wikia.com/wiki/Faster_loading_of_large_files&quot;&gt;this example adapted from the Vim wiki&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup LargeFile&#xA;        let g:large_file = 10485760 &quot; 10MB&#xA;&#xA;        &quot; Set options:&#xA;        &quot;   eventignore+=FileType (no syntax highlighting etc&#xA;        &quot;   assumes FileType always on)&#xA;        &quot;   noswapfile (save copy of file)&#xA;        &quot;   bufhidden=unload (save memory when other file is viewed)&#xA;        &quot;   buftype=nowritefile (is read-only)&#xA;        &quot;   undolevels=-1 (no undo possible)&#xA;        au BufReadPre *&#xA;                \ let f=expand(&quot;&amp;lt;afile&amp;gt;&quot;) |&#xA;                \ if getfsize(f) &amp;gt; g:large_file |&#xA;                        \ set eventignore+=FileType |&#xA;                        \ setlocal noswapfile bufhidden=unload buftype=nowrite undolevels=-1 |&#xA;                \ else |&#xA;                        \ set eventignore-=FileType |&#xA;                \ endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="51" LastEditDate="2015-02-04T14:07:49.307" LastActivityDate="2015-02-04T14:07:49.307" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="170" PostTypeId="2" ParentId="16" CreationDate="2015-02-03T21:07:24.633" Score="2" Body="&lt;p&gt;When I was transitioning to vim away from other editors, I wanted both a project drawer on the left and good tab functionality. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I started to use &lt;a href=&quot;https://github.com/jistr/vim-nerdtree-tabs&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDTreeTabs&lt;/a&gt;, which is NERDTree, except optimized for use with multiple tabs. In particular, there is only one NERDTree now, and if you change tabs, the NERDTree is still there. So it really feels like a project drawer like you might find in other editors. Here's an example use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9iza7.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can customize the width of the NERDTree if you want. You might also set it to automatically close after use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works reasonably well with splits, but as in &lt;a href=&quot;https://vi.stackexchange.com/a/62/130&quot;&gt;Chad's answer&lt;/a&gt;, there are difficulties with NERDTree and splits.&lt;/p&gt;&#xA;" OwnerUserId="130" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-03T21:07:24.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="171" PostTypeId="2" ParentId="168" CreationDate="2015-02-03T21:08:24.637" Score="14" Body="&lt;p&gt;For navigating the undo tree your best bet is to use the &lt;a href=&quot;http://sjl.bitbucket.org/gundo.vim/&quot;&gt;Gundo&lt;/a&gt; plugin.  This creates a new split window with special bindings to jump to different branches within the undo tree as well as a preview pane that shows you exactly what changed between each node in the tree.&lt;/p&gt;&#xA;" OwnerUserId="132" LastEditorUserId="132" LastEditDate="2015-02-03T21:15:25.137" LastActivityDate="2015-02-03T21:15:25.137" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="172" PostTypeId="2" ParentId="118" CreationDate="2015-02-03T21:11:42.837" Score="8" Body="&lt;pre&gt;&lt;code&gt;$ grep &quot;'&quot; /usr/share/dict/words | wc -l&#xA;26226&#xA;$ grep -i python /usr/share/dict/words&#xA;Python&#xA;Python's&#xA;python&#xA;python's&#xA;pythons&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that all these words with apostrophes are actually in your dictionary file.&#xA;So if you're okay with modifying your vim spelling dictionary, then do so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ grep &quot;'&quot; /usr/share/dict/words | sed &quot;s/'/’/g&quot; &amp;gt;&amp;gt; ~/.vim/spell/en.utf-8.add&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;grep&lt;/code&gt; to find all words in your system dictionary that contain an apostrophe (&lt;code&gt;'&lt;/code&gt;);&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sed&lt;/code&gt; to change the straight quotes to smart quotes (that's &lt;code&gt;s/'/’/g&lt;/code&gt;, where the first quote is straight and the second is smart); and&lt;/li&gt;&#xA;&lt;li&gt;append it to your language dictionary (replace with whatever your language is).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You will need to recompile this to a &lt;code&gt;.spl&lt;/code&gt; file, which you can do from Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:mkspell! ~/.vim/spell/en.utf-8.add&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to use the actual spell files that Vim uses as a starting place (instead of your system dictionary), you can use the &lt;code&gt;:spelldump&lt;/code&gt; command.&#xA;The output will include &lt;em&gt;all&lt;/em&gt; the words Vim uses for the current &lt;code&gt;spelllang&lt;/code&gt;, &lt;em&gt;including&lt;/em&gt; those already added from the &lt;code&gt;.add&lt;/code&gt; file.&#xA;Save the result of &lt;code&gt;:spelldump&lt;/code&gt; to a file and remove the first two lines (header info), then use the same commands as above.&#xA;You may also want to pipe it through &lt;code&gt;uniq&lt;/code&gt; as well, to remove duplicate entries.&#xA;(No need to &lt;code&gt;sort&lt;/code&gt;; the output of &lt;code&gt;:spelldump&lt;/code&gt; is already sorted.)&lt;/p&gt;&#xA;" OwnerUserId="142" LastEditorUserId="142" LastEditDate="2015-02-05T19:52:09.950" LastActivityDate="2015-02-05T19:52:09.950" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="173" PostTypeId="2" ParentId="77" CreationDate="2015-02-03T21:18:51.393" Score="5" Body="&lt;p&gt;There is the &lt;a href=&quot;http://editorconfig.org&quot; rel=&quot;noreferrer&quot;&gt;Editor Config&lt;/a&gt; project which allows you to define project level configurations like tabstop settings along with new line styles and other things. There are many plugging for all sorts of editors including &lt;a href=&quot;https://github.com/editorconfig/editorconfig-vim#readme&quot; rel=&quot;noreferrer&quot;&gt;vim&lt;/a&gt;. It also allows you to define settings for different file types.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# EditorConfig is awesome: http://EditorConfig.org&#xA;&#xA;# top-most EditorConfig file&#xA;root = true&#xA;&#xA;# Unix-style newlines with a newline ending every file&#xA;[*]&#xA;end_of_line = lf&#xA;insert_final_newline = true&#xA;&#xA;# Matches multiple files with brace expansion notation&#xA;# Set default charset&#xA;[*.{js,py}]&#xA;charset = utf-8&#xA;&#xA;# 4 space indentation&#xA;[*.py]&#xA;indent_style = space&#xA;indent_size = 4&#xA;&#xA;# Tab indentation (no size specified)&#xA;[*.js]&#xA;indent_style = tab&#xA;&#xA;# Indentation override for all JS under lib directory&#xA;[lib/**.js]&#xA;indent_style = space&#xA;indent_size = 2&#xA;&#xA;# Matches the exact files either package.json or .travis.yml&#xA;[{package.json,.travis.yml}]&#xA;indent_style = space&#xA;indent_size = 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="171" LastActivityDate="2015-02-03T21:18:51.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="174" PostTypeId="1" AcceptedAnswerId="176" CreationDate="2015-02-03T21:21:03.833" Score="10" ViewCount="672" Body="&lt;p&gt;Is there a way to 'pipe' text from a register to an another register or set of registers? For example, move &lt;code&gt;&quot;q&lt;/code&gt; to registers &lt;code&gt;&quot;1&lt;/code&gt; through &lt;code&gt;&quot;5&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often wish to create slightly different versions of the same macro, so it is useful to be able to copy a 'template' macro to several registers and then modify each of them in place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give a practical example, here is the problem that prompted this question for me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to turn the following line from a hardware description language into many repeated blocks,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RAM64(in=in, load=load0, address=address[0..5], out=out1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RAM64(in=in, load=load1, address=address[0..5], out=out2);&#xA;RAM64(in=in, load=load2, address=address[0..5], out=out3);&#xA;RAM64(in=in, load=load3, address=address[0..5], out=out4);&#xA;RAM64(in=in, load=load4, address=address[0..5], out=out5);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a macro which performs this, using the  increment function, &lt;code&gt;yypW^At)^A&lt;/code&gt; which I stored in register &lt;code&gt;&quot;a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes, I need the pattern of incrementing to be slightly different, such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RAM512(in=in, load=load1, address=address[0..8], out=out2);&#xA;RAM512(in=in, load=load2, address=address[0..8], out=out4);&#xA;RAM512(in=in, load=load3, address=address[0..8], out=out6);&#xA;RAM512(in=in, load=load4, address=address[0..8], out=out8);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the macro in register &lt;code&gt;&quot;b&lt;/code&gt; would be &lt;code&gt;yypW^At)^A^A&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want a register to do this, but for each increment from 1-5. The register &lt;code&gt;&quot;a&lt;/code&gt; could (somehow) be copied to registers b through e. Then I would paste each register into the buffer, make the required modification (add more  terms, change the character that follows the &lt;code&gt;t&lt;/code&gt; motion etc) and yank the modified expression back into the register. Ideally this last step could even be included in the command(s) to copy the registers&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This saves me from repeating all of the characters in the macro that do NOT require changing. For my example it may be trivial, but I can foresee times when it might be very helpful to do what I am asking.&lt;/p&gt;&#xA;" OwnerUserId="161" LastEditorUserId="161" LastEditDate="2015-02-03T22:57:20.473" LastActivityDate="2015-02-04T13:17:17.020" Title="How can text be moved from one register to an arbitrary number of registers?" Tags="|cut-copy-paste|register|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="175" PostTypeId="2" ParentId="174" CreationDate="2015-02-03T21:28:22.837" Score="6" Body="&lt;h1&gt;Using &lt;code&gt;getreg&lt;/code&gt; and &lt;code&gt;setreg&lt;/code&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;To copy from &lt;code&gt;q&lt;/code&gt; to registers &lt;code&gt;1&lt;/code&gt;&amp;ndash;&lt;code&gt;5&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let src=getreg('q', 1)&#xA;for i in range(1, 5)&#xA;    call setreg(i, src)&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To copy to a more general list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let src=getreg('q', 1)&#xA;for i in ['a', 'c', 'e']&#xA;    call setreg(i, src)&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Using &lt;code&gt;execute&lt;/code&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;To copy from &lt;code&gt;q&lt;/code&gt; to registers &lt;code&gt;1&lt;/code&gt;&amp;ndash;&lt;code&gt;5&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(1, 5)&#xA;   execute 'let @' . i . '=@a'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To copy to a more general list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in ['a', 'c', 'e']&#xA;    execute 'let @' . i . '=@a'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation.&lt;/strong&gt;&#xA;The command &lt;code&gt;let&lt;/code&gt; can be used as &lt;code&gt;let @x=@y&lt;/code&gt;, which copies register &lt;code&gt;y&lt;/code&gt; to register &lt;code&gt;x&lt;/code&gt;.&#xA;Essentially, we're just constructing these commands in a loop (changing the value of &lt;code&gt;x&lt;/code&gt; in the above form) and &lt;code&gt;execute&lt;/code&gt;ing them.&lt;/p&gt;&#xA;" OwnerUserId="142" LastEditorUserId="15" LastEditDate="2015-02-03T21:52:55.823" LastActivityDate="2015-02-03T21:52:55.823" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="176" PostTypeId="2" ParentId="174" CreationDate="2015-02-03T21:29:26.997" Score="7" Body="&lt;p&gt;Macros are just text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open a new empty buffer and put your macro there. You can duplicate the lines, change one thing here and something else elsewhere then yank a line and use it right away with &lt;code&gt;@&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No need to pollute your registers, especially the number registers which serve an entirely different purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-- edit --&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your question is easier to understand now that you added some explanation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it turns out, you only need to change your initial recording to achieve your goal, without playing with registers as if they were variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i = 1                     &quot; define variable i&#xA;qa                             &quot; start recording in register a&#xA;yy                             &quot; yank the line&#xA;p                              &quot; paste it&#xA;W                              &quot; move to next WORD&#xA;&amp;lt;C-v&amp;gt;&amp;lt;C-a&amp;gt;                     &quot; increment number&#xA;t)                             &quot; jump to the other number to increment&#xA;:norm &amp;lt;C-r&amp;gt;=i&amp;lt;CR&amp;gt;&amp;lt;C-v&amp;gt;&amp;lt;C-a&amp;gt;    &quot; increment the number by i&#xA;q                              &quot; stop recording&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To create 5 copies of the current line with the last number incremented by 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i = 2|norm 5@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or 12 copies, with the last number incremented by 23:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i = 23|norm 12@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-02-04T13:17:17.020" LastActivityDate="2015-02-04T13:17:17.020" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="177" PostTypeId="1" AcceptedAnswerId="179" CreationDate="2015-02-03T21:29:33.360" Score="104" ViewCount="86395" Body="&lt;p&gt;When I edit files, Vim tends to create files named &lt;code&gt;.&lt;i&gt;filename&lt;/i&gt;.swp&lt;/code&gt;, which I find annoying.  From &lt;code&gt;vim -h&lt;/code&gt;, I see that the &lt;code&gt;-n&lt;/code&gt; option suppresses the creation of swap files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a vimrc directive that I can use to disable swap files by default?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the purpose of swap files, and what functionality would I be missing out on by suppressing them?&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2022-03-17T17:47:43.247" Title="What is the purpose of swap files?" Tags="|vimrc|crash-recovery|swap-file|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="179" PostTypeId="2" ParentId="177" CreationDate="2015-02-03T21:37:25.897" Score="126" Body="&lt;h3&gt;Reasons for swap files&lt;/h3&gt;&#xA;&lt;p&gt;Swap files store changes you've made to the buffer.  If Vim or your computer crashes, they allow you to recover those changes.&lt;/p&gt;&#xA;&lt;p&gt;Swap files also provide a way to avoid multiple instances of Vim from editing the same file.  This can be useful on multi-user systems or just to know if you have another Vim already editing a file.&lt;/p&gt;&#xA;&lt;h3&gt;Disabling swap files&lt;/h3&gt;&#xA;&lt;p&gt;If you want to disable creating swap files entirely (which I wouldn't recommend), you can add &lt;code&gt;set noswapfile&lt;/code&gt; to your &lt;code&gt;.vimrc&lt;/code&gt;.  This sets the global value of the option.  You can then override that for specific buffers by using &lt;code&gt;:setlocal swapfile&lt;/code&gt; while running Vim.&lt;/p&gt;&#xA;&lt;h3&gt;Organizing swap files&lt;/h3&gt;&#xA;&lt;p&gt;If your issue is more about the extra files spread around your filesystem, then you could aggregate all the swap files in one place.  For example, create a &lt;code&gt;~/.vim/tmp&lt;/code&gt; directory and then add&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set directory^=$HOME/.vim/tmp//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to your &lt;code&gt;.vimrc&lt;/code&gt;.  The &lt;code&gt;'directory'&lt;/code&gt; option contains a list of directories which Vim will use to try and store the swap file.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;^=&lt;/code&gt; syntax for &lt;code&gt;:set&lt;/code&gt; prepends the directory name to the head of the list, so Vim will check that directory first.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;//&lt;/code&gt; at the end of the directory name tells Vim to use the absolute path to the file to create the swap file so there aren't collisions between files of the same name from different directories.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Note that this will prevent Vim from noticing when there are multiple users trying to edit the same file.  Since the swap file isn't in the same directory as the original file, the other user's Vim won't know about the swap file and won't warn them that it's already being edited.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="35229" LastEditDate="2021-06-25T03:39:46.550" LastActivityDate="2021-06-25T03:39:46.550" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="180" PostTypeId="2" ParentId="174" CreationDate="2015-02-03T21:40:16.023" Score="1" Body="&lt;p&gt;To directly answer the question, if you want to quickly and easily copy the contents of one register to another, you can put the following in your .vimrc.  You can then execute &lt;code&gt;&amp;lt;leader&amp;gt;rcab&lt;/code&gt; to copy the contents of register &lt;code&gt;a&lt;/code&gt; to register &lt;code&gt;b&lt;/code&gt;.  As an example I chose &lt;code&gt;&amp;lt;leader&amp;gt;rc&lt;/code&gt; to stand for 'register copy'&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:CopyRegister()&#xA;    let sourceReg = nr2char(getchar())&#xA;&#xA;    if sourceReg !~# '\v^[a-z0-9]'&#xA;        echo &quot;Invalid register given: &quot; . sourceReg&#xA;        return&#xA;    endif&#xA;&#xA;    let destinationReg = nr2char(getchar())&#xA;&#xA;    if destinationReg !~# '\v^[a-z0-9]'&#xA;        echo &quot;Invalid register given: &quot; . destinationReg&#xA;        return&#xA;    endif&#xA;&#xA;    call setreg(destinationReg, getreg(sourceReg, 1))&#xA;    echo &quot;Replaced register '&quot;. destinationReg .&quot;' with contents of register '&quot;. sourceReg .&quot;'&quot;&#xA;endfunction&#xA;&#xA;&quot; rc = register copy&#xA;nnoremap &amp;lt;leader&amp;gt;rc :call &amp;lt;sid&amp;gt;CopyRegister()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="132" LastEditorUserId="132" LastEditDate="2015-02-03T21:48:28.827" LastActivityDate="2015-02-03T21:48:28.827" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="181" PostTypeId="1" AcceptedAnswerId="214" CreationDate="2015-02-03T21:40:16.413" Score="2" ViewCount="357" Body="&lt;p&gt;I've used &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1984&quot; rel=&quot;nofollow&quot;&gt;fuzzyfinder&lt;/a&gt; to change between buffers for a long time (since 2008-2009). I've upgraded MacVim no less than 10 times since I've started using fuzzy finder. I've had this in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;t :FufBuffer&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;D-t&amp;gt; :FufBuffer&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A few months back I upgraded to 7.4 (73). And now Command-T just opens a tab. I want to de-activate this behavior and have Command-T just make FufBuffer show up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="155" LastEditorUserId="24" LastEditDate="2015-02-03T22:33:49.303" LastActivityDate="2015-02-03T23:47:06.113" Title="keyboard shortcuts and MacVim 7.4" Tags="|macvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="182" PostTypeId="1" AcceptedAnswerId="191" CreationDate="2015-02-03T21:47:03.600" Score="12" ViewCount="3092" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/carlhuda/janus&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/carlhuda/janus&lt;/a&gt; vim distribution and clearly not satisfied with load time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the best way to profile and speed-up vim load time?&#xA;Also would be interesting to compare load time with &lt;a href=&quot;http://vim.spf13.com/&quot; rel=&quot;noreferrer&quot;&gt;http://vim.spf13.com/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="179" LastEditorUserId="24" LastEditDate="2015-02-09T02:39:50.280" LastActivityDate="2015-02-09T02:39:50.280" Title="Cut vim load time" Tags="|performance|startup|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="183" PostTypeId="1" CreationDate="2015-02-03T21:51:58.027" Score="4" ViewCount="121" Body="&lt;p&gt;I tried to create a custom syntax file to read &lt;a href=&quot;http://www.fixtradingcommunity.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;FIX messages&lt;/a&gt;. Note: &lt;a href=&quot;https://superuser.com/questions/763121/cygwin-vim-doesnt-load-files-in-runtimepath&quot;&gt;I am certain my custom files are being loaded by Vim.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The file format is sequences of &lt;code&gt;NUMBER=VALUE&lt;/code&gt; pairs separated by the unprintable &lt;code&gt;0x1&lt;/code&gt; character. I wanted a few of the pairs (the ones with important data) to turn colors when I open the file in Vim. I don't care about which colors they turn, as long as they are all different and are easily distinguishable from each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, I want the tags associated with the following numbers to be highlighted: 44, 52, 54, 60, 9717.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my syntax file (&lt;code&gt;~/.vim/syntax.vim&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if version &amp;gt;= 600&#xA;    if exists(&quot;b:current_syntax&quot;)&#xA;         finish&#xA;    endif&#xA;else&#xA;    syntax clear&#xA;endif&#xA;&#xA;syn case ignore&#xA;&#xA;&quot;syn match fixPrice &quot;\|44[=][^|]\+\|&quot;&#xA;&quot;syn match fixSendingTime &quot;\|52[=][^|]\+\|&quot;&#xA;&quot;syn match fixTransactTime &quot;\|60[=][^|]\+\|&quot;&#xA;&quot;syn match fixCorrelation &quot;\|9717[=][^|]\+\|&quot;&#xA;&quot;syn match fixSide &quot;\|54[=][^|]\+\|&quot;&#xA;syn match fixPrice &quot;44&quot;&#xA;syn match fixSendingTime &quot;|52&quot;&#xA;syn match fixTransactTime &quot;\|60&quot;&#xA;syn match fixCorrelation &quot;\|9717&quot;&#xA;syn match fixSide &quot;\|54&quot;&#xA;&#xA;&quot; Define the default highlighting&#xA;if version &amp;gt;= 508 || !exists(&quot;did_fix_syntax_inits&quot;)&#xA;        if version &amp;lt; 508&#xA;                let did_fix_syntax_inits = 1&#xA;                command -nargs=+ HiLink hi link &amp;lt;args&amp;gt;&#xA;        else&#xA;                command -nargs=+ HiLink hi def link &amp;lt;args&amp;gt;&#xA;        endif&#xA;&#xA;        HiLink fixPrice Label&#xA;        HiLink fixSendingTime Number&#xA;        HiLink fixTransactTime Include&#xA;        HiLink fixCorrelation String&#xA;        HiLink fixSide Identifier&#xA;&#xA;        delcommand HiLink&#xA;endif&#xA;&#xA;let b:current_syntax = &quot;fix&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sample line of data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;8=FIXT.1.1^A9=380^A35=X^A49=CME^A56=0^A34=13362975^A52=20130626135401572^A1128=9^A268=3^A279=0^A269=2^A48=42025^A22=8^A270=-224^A271=1^A273=135401000^A274=2^A451=32^A1020=23^A83=523628^A5799=1^A5797=1^A279=0^A269=2^A48=17311^A22=8^A270=12356^A271=1^A273=135401000^A277=1^A451=-395^A1020=201377^A83=5671131^A5797=1^A279=0^A269=2^A48=122816^A22=8^A270=12580^A271=1^A273=135401000^A274=2^A277=1^A451=-427^A1020=31^A83=1396693^A5797=2^A75=20130626^A10=001^A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the &lt;code&gt;^A&lt;/code&gt; characters are the &lt;code&gt;0x1&lt;/code&gt; unprintable characters, you can fix this file with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\^A/&amp;lt;01&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;&amp;lt;01&amp;gt;&lt;/code&gt; is entered with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; followed by &lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;1&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2015-02-08T20:51:31.867" Title="Custom syntax file for FIX data doesn't work" Tags="|syntax-highlighting|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="184" PostTypeId="1" AcceptedAnswerId="252" CreationDate="2015-02-03T21:52:34.083" Score="103" ViewCount="158668" Body="&lt;p&gt;When you search for a word in a file with something like &lt;code&gt;/console.log&lt;/code&gt;, all of the instances of &lt;code&gt;console.log&lt;/code&gt; are highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you're no longer interested in these, the highlighting can be distracting. My current strategy for removing the highlighting is to do something like &lt;code&gt;/asntehua&lt;/code&gt;. Is there a proper way to remove this word highlighting?&lt;/p&gt;&#xA;" OwnerUserId="69" LastActivityDate="2022-10-03T16:32:30.763" Title="How can I clear word highlighting in the current document (e.g. such as after searching for a word)?" Tags="|search|highlight|" AnswerCount="10" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="185" PostTypeId="2" ParentId="184" CreationDate="2015-02-03T21:54:16.523" Score="55" Body="&lt;p&gt;Simply type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noh&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Where &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; symbolizes a carriage return, i.e. Enter.)  The full non-abbreviated version of this command is &lt;code&gt;:nohlsearch&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For convenience, you can have a mapping such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;&amp;lt;space&amp;gt; :noh&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your &lt;code&gt;.vimrc&lt;/code&gt;. Since my leader is Space, this allows me to clear highlighting simply by tapping space twice. (By default, &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; is set to &lt;code&gt;\&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another popular option is to bind it to &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;L&lt;/kbd&gt;, since this is more or less the default for 'redrawn terminal screen', which is &lt;em&gt;very roughly what you're&lt;/em&gt; doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-L&amp;gt; :nohlsearch&amp;lt;CR&amp;gt;&amp;lt;C-L&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has the side-effect of &lt;em&gt;also&lt;/em&gt; redrawing the terminal screen, which might be slow if your terminal connection is slow (which is very rare these days).&lt;br&gt;&#xA;NOTE: If you're using &lt;a href=&quot;http://github.com/tpope/vim-sensible&quot; rel=&quot;noreferrer&quot;&gt;tpope/vim-sensible&lt;/a&gt; then it already offers the &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; mapping listed above.&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="13519" LastEditDate="2017-07-21T09:42:48.650" LastActivityDate="2017-07-21T09:42:48.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="188" PostTypeId="2" ParentId="88" CreationDate="2015-02-03T21:58:11.737" Score="2" Body="&lt;p&gt;As others have said, you can use &lt;kbd&gt;g&lt;/kbd&gt; + something to move around.&#xA;However, when you have extremely long lines, pressing &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; multiple times to move downward is not ergonomic. I have the following in my &lt;code&gt;.vimrc&lt;/code&gt; to make that much easier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;D-j&amp;gt; gj&#xA;vmap &amp;lt;D-k&amp;gt; gk&#xA;vmap &amp;lt;D-4&amp;gt; g$&#xA;vmap &amp;lt;D-6&amp;gt; g^&#xA;vmap &amp;lt;D-0&amp;gt; g^&#xA;nmap &amp;lt;D-j&amp;gt; gj&#xA;nmap &amp;lt;D-k&amp;gt; gk&#xA;nmap &amp;lt;D-4&amp;gt; g$&#xA;nmap &amp;lt;D-6&amp;gt; g^&#xA;nmap &amp;lt;D-0&amp;gt; g^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On a Mac, this allows me to use j, k, $, 0 and ^ on display lines by holding down the command key. On other systems, instead of &lt;code&gt;D&lt;/code&gt; you could try &lt;code&gt;M&lt;/code&gt; or &lt;code&gt;A&lt;/code&gt; for Alt, or &lt;code&gt;C&lt;/code&gt; for Control.&lt;/p&gt;&#xA;" OwnerUserId="135" LastEditorUserId="135" LastEditDate="2015-02-03T22:49:42.023" LastActivityDate="2015-02-03T22:49:42.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="189" PostTypeId="2" ParentId="182" CreationDate="2015-02-03T22:00:21.003" Score="5" Body="&lt;p&gt;You can debug startup time by using the built in Vim profiler (&lt;a href=&quot;http://vimcasts.org/episodes/profiling-vimscript-performance/&quot; rel=&quot;noreferrer&quot;&gt;tutorial&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your version of vim is compiled with &lt;code&gt;:profile&lt;/code&gt; you can run:&#xA;&lt;code&gt;vim --cmd 'profile start vimrc.profile' --cmd 'profile! file ~/.vimrc'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, your stuck debugging it manually by adding and removing plugins and seeing where the long startup times are coming from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally don't recommend using a Vim distribution. If you don't know what every line in your &lt;code&gt;.vimrc&lt;/code&gt; is doing, then it becomes difficult to track down problems, or find where two plugins happen to conflict. For my personal configuration, I've spent a few months adding and removing plugins, finding which ones work for me and which ones don't. Vim is highly customizable, so take advantage of the fact that it can be configured to work perfectly with your workflow.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2015-02-03T22:00:21.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="190" PostTypeId="2" ParentId="39" CreationDate="2015-02-03T22:01:42.113" Score="51" Body="&lt;p&gt;There are many different flavors of autocomplete in vim. One way might be to use &lt;a href=&quot;https://github.com/ervandew/supertab&quot; rel=&quot;noreferrer&quot;&gt;SuperTab&lt;/a&gt;. This provides a way to use tab-completion at more or less any time. This would enable you to hit &lt;kbd&gt;Tab&lt;/kbd&gt; after you've partially typed the word to get a completion list. For instance, typing &lt;code&gt;eatF&lt;/code&gt; followed by &lt;kbd&gt;Tab&lt;/kbd&gt; to expand to &lt;code&gt;eatFood.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Please Note&lt;/strong&gt;: these pictures all link to example gifs in action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kKbAz.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dVuOT.png&quot; alt=&quot;supertab completions&quot; title=&quot;Click to see a gif&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has excellent other options. You should read &lt;code&gt;:h ins-completion&lt;/code&gt; to see the variety of built-in completion options. Using vim's &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;X&lt;/kbd&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;O&lt;/kbd&gt;, combined with a python-aware plugin like &lt;a href=&quot;https://github.com/davidhalter/jedi&quot; rel=&quot;noreferrer&quot;&gt;jedi&lt;/a&gt; can give a completion flavor. Jedi can be configured to give documentation on omni-completion (this is what &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;X&lt;/kbd&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;O&lt;/kbd&gt; does). Then documentation for the completion candidates would appear in a split window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KlAjl.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/etSIu.png&quot; alt=&quot;ctrlxctrlo completion&quot; title=&quot;Click to see a gif&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using similar plugins but different options leads to all sorts of behaviours. It's possible, for instance, to not need to prompt for autocompletion (if that's what you're after). Instead, after you type some number of letters (say, 2 or 3) of a word, a plugin can try to intelligently offer possible completions in a menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9QnR9.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gtNK0.png&quot; alt=&quot;enter image description here&quot; title=&quot;Click to see a gif&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the short answer is a &lt;strong&gt;yes!&lt;/strong&gt; But the configuration process can be a bit complicated. I think of it as a step in the long stairway of mastering vim.&lt;/p&gt;&#xA;" OwnerUserId="130" LastEditorUserId="130" LastEditDate="2015-02-05T07:05:44.930" LastActivityDate="2015-02-05T07:05:44.930" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="191" PostTypeId="2" ParentId="182" CreationDate="2015-02-03T22:04:53.597" Score="18" Body="&lt;p&gt;If you just want to see what's consuming start up time, then you can use the &lt;code&gt;--startuptime&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --startuptime timing.out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The file will look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;times in msec&#xA; clock   self+sourced   self:  sourced script&#xA; clock   elapsed:              other lines&#xA;&#xA;000.000  000.000: --- VIM STARTING ---&#xA;000.000  000.000: Allocated generic buffers&#xA;000.000  000.000: locale set&#xA;000.000  000.000: GUI prepared&#xA;000.000  000.000: clipboard setup&#xA;000.000  000.000: window checked&#xA;000.000  000.000: inits 1&#xA;000.000  000.000: parsing arguments&#xA;000.000  000.000: expanding arguments&#xA;000.000  000.000: shell init&#xA;000.000  000.000: Termcap init&#xA;000.000  000.000: inits 2&#xA;000.000  000.000: init highlight&#xA;000.000  000.000  000.000: sourcing /usr/share/vim/vim74/debian.vim&#xA;000.000  000.000  000.000: sourcing $VIM/vimrc&#xA;000.000  000.000  000.000: sourcing /home/mccoyj1/.vim/autoload/pathogen.vim&#xA;008.004  004.002  004.002: sourcing /home/mccoyj1/.vim/bundle/janah/colors/janah.vim&#xA;040.022  032.018  032.018: sourcing /usr/share/vim/vim74/filetype.vim&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-02-03T22:04:53.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="192" PostTypeId="1" AcceptedAnswerId="197" CreationDate="2015-02-03T22:05:27.597" Score="3" ViewCount="222" Body="&lt;p&gt;When I'm shelling out some external command using &lt;code&gt;!&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r !pbpaste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!./path/to_my_script&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What environment will be used and how to manually configure it?&#xA;I'm a big fan of ZSH. Can I have some dedicated RC files that similar to my &lt;code&gt;~/.zshrc&lt;/code&gt; and &lt;code&gt;~/.zprofile&lt;/code&gt; and explicitly set zsh as default interpreter?&lt;/p&gt;&#xA;" OwnerUserId="179" LastEditorUserId="24" LastEditDate="2015-02-06T20:03:29.800" LastActivityDate="2015-02-06T20:03:29.800" Title="ex mode choice of shell for external commands" Tags="|external-command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="193" PostTypeId="1" AcceptedAnswerId="198" CreationDate="2015-02-03T22:09:28.013" Score="5" ViewCount="114" Body="&lt;p&gt;Consider a directory structure like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;topdir/&#xA;  file1&#xA;  file2&#xA;  foo/&#xA;    bar1&#xA;    bar2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Say I want to open some file in &lt;code&gt;foo/&lt;/code&gt; in a new tab.&#xA;I would first write &lt;code&gt;:tabe topdir/&lt;/code&gt;, and then keep hitting &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; until &lt;code&gt;:tabe topdir/foo/&lt;/code&gt; is displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I want to tab-complete the files in &lt;code&gt;foo/&lt;/code&gt;.&#xA;But if I just hit &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; again, I'll wrap around to &lt;code&gt;file1&lt;/code&gt; instead of going down into the &lt;code&gt;foo/&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can get around this by typing and deleting a space, but this seems kind of ugly.&#xA;Is there a way to directly say, &quot;yes, this is the partial completion that I want—now tab-complete again as if I had entered this command manually up to this point&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(For reference, my &lt;code&gt;wildmode&lt;/code&gt; is &lt;code&gt;full&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="142" LastEditorUserId="142" LastEditDate="2015-02-03T22:40:16.617" LastActivityDate="2015-02-03T22:55:48.940" Title="How can I go into a directory in filename completion?" Tags="|autocompletion|command-line|filesystem|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="195" PostTypeId="2" ParentId="168" CreationDate="2015-02-03T22:18:08.653" Score="15" Body="&lt;p&gt;For simple cases like this, you can simply press &lt;code&gt;g-&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, what this does is traverse the change list chronologically (treating a &lt;code&gt;u&lt;/code&gt; as an actual change), rather than linearly (like with &lt;code&gt;u&lt;/code&gt;/&lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you've inserted a few lines, and you press &lt;code&gt;g-&lt;/code&gt;, this happens:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/SOVns.gif&quot; alt=&quot;demonstration&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-03T22:18:08.653" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="196" PostTypeId="1" AcceptedAnswerId="199" CreationDate="2015-02-03T22:19:30.310" Score="64" ViewCount="24049" Body="&lt;p&gt;I am trying to use a regex for replacing text in a file (replace a full url with just protocol/domain/):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(https\?:\/\/.*?\/\).*/\1/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately &lt;code&gt;.*?&lt;/code&gt; does not match the string, even trying to escape the &lt;code&gt;?&lt;/code&gt; quantifier? How should non-greedy quantifier be escaped in vim?&lt;/p&gt;&#xA;" OwnerUserId="188" LastEditorUserId="24" LastEditDate="2015-02-08T17:51:39.367" LastActivityDate="2019-05-21T02:06:07.867" Title="How to make regex matchers non-greedy?" Tags="|regular-expression|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="197" PostTypeId="2" ParentId="192" CreationDate="2015-02-03T22:25:40.143" Score="4" Body="&lt;p&gt;TL;DR Vim runs the shell you would expect but in non-interactive mode.  See your shell's documentation for non-interactive mode affects initialization, i.e. which init files are read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim uses whatever shell is specified in your environment (either through the &lt;code&gt;$SHELL&lt;/code&gt; environment variable or, if that isn't available, your user's entry in &lt;code&gt;/etc/passwd&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, Vim is going to run the shell in non-interactive mode since, well, you're using the shell non-interactively.  Shell initialization is different for non-interactive mode vs. interactive mode.  One common thing people notice is that they likely won't have aliases available.  This is intentional (from the shell's perspective) because scripts shouldn't need aliases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, it's possible to have Vim run your shell in interactive mode by setting the &lt;code&gt;'shellcmdflag'&lt;/code&gt; flag appropriately.  That isn't necessarily a good idea, though.  Forcing the shell into interactive mode may cause other unintended side effects.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-02-03T22:25:40.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="198" PostTypeId="2" ParentId="193" CreationDate="2015-02-03T22:26:55.503" Score="8" Body="&lt;p&gt;Simply press the right arrow key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QSzhf.gif&quot; alt=&quot;demonstration&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-03T22:26:55.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="199" PostTypeId="2" ParentId="196" CreationDate="2015-02-03T22:29:09.140" Score="93" Body="&lt;p&gt;Vim's regex has special syntax for non-greedy versions of operators (it's kind of annoying, but you just have to memorize them): &lt;a href=&quot;http://vimregex.com/#Non-Greedy&quot;&gt;http://vimregex.com/#Non-Greedy&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The non-greedy version of &lt;code&gt;*&lt;/code&gt; is &lt;code&gt;\{-}&lt;/code&gt;. So, simply replace &lt;code&gt;.*&lt;/code&gt; with &lt;code&gt;.\{-}&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(https\?:\/\/.\{-}\/\).*/\1/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-03T22:29:09.140" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="200" PostTypeId="2" ParentId="74" CreationDate="2015-02-03T22:41:36.997" Score="12" Body="&lt;p&gt;Vim does have an auto-save feature, but it saves it to the &quot;recovery&quot; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you edit a document, e.g. &lt;code&gt;MyFile.txt&lt;/code&gt; vim will create the revovery file &lt;code&gt;.MyFile.txt.swp&lt;/code&gt;. If your system were to crash, or your session were to die, then you can reconnect, and recover from essentially where you left off, by typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -r MyFile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will open the file for editing, and recover the last changes you made to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then save the recovered version the normal way &lt;code&gt;:w&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, when you exit vim, it will leave the &lt;code&gt;.MyFile.txt.swp&lt;/code&gt; around, and you need to remove it manually:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rm .MyFile.txt.swp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/recover.html#recovery&quot;&gt;&quot;Recovery&quot; Man page&lt;/a&gt;&#xA;Also &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_11.html&quot;&gt;Chapter 11&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2015-02-03T22:41:36.997" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="201" PostTypeId="1" AcceptedAnswerId="206" CreationDate="2015-02-03T22:46:54.970" Score="28" ViewCount="8151" Body="&lt;p&gt;I like to use vimdiff as a git diff/merge tool. The problem is when I resize the host terminal window to a new size: of the two split panes, the leftmost remain of the same width, while the rightmost is extended to full window size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command to make the split panes equal width after the windows has been resized? Or a setting that makes the panes always be of same size? I looked into &lt;code&gt;:set equalalways&lt;/code&gt; but it does not seem to do what I am asking.&lt;/p&gt;&#xA;" OwnerUserId="188" LastEditorUserId="188" LastEditDate="2015-02-03T22:52:11.437" LastActivityDate="2016-08-09T22:36:07.767" Title="Make panes resize when host window is resized" Tags="|split|vimdiff|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="202" PostTypeId="1" AcceptedAnswerId="209" CreationDate="2015-02-03T22:49:45.820" Score="24" ViewCount="14361" Body="&lt;p&gt;I'm using Vim in a terminal, so scrolling with the scroll wheel uses the &lt;code&gt;\e[A&lt;/code&gt; and &lt;code&gt;\e[B&lt;/code&gt; syntax (where &lt;code&gt;\e&lt;/code&gt; symbolizes &lt;code&gt;\x1b&lt;/code&gt;, or escape).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, Vim interprets this by moving the cursor up or down a line. The desired behavior is that the &lt;em&gt;screen&lt;/em&gt; is moved up or down, like &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt; do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I tell Vim to move the screen when I used my scroll wheel, while keeping the cursor on the same line? This should work in all common modes (insert, normal, visual select).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've already tried, for example, &lt;code&gt;:nnoremap &amp;lt;esc&amp;gt;[A &amp;lt;C-e&amp;gt;&lt;/code&gt; (replacing &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; with a literal escape character inserted with &lt;kbd&gt;Ctrl+V&lt;/kbd&gt; &lt;kbd&gt;Esc&lt;/kbd&gt;), but this proved to be futile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim 7.4.52 on Ubuntu 14.04 with GNOME.&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="24" LastEditDate="2015-02-03T23:55:55.117" LastActivityDate="2020-11-07T22:58:04.360" Title="Scroll the screen, not the cursor, when using scrollwheel" Tags="|mouse|scrolling|x11|terminal|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="203" PostTypeId="2" ParentId="193" CreationDate="2015-02-03T22:55:48.940" Score="8" Body="&lt;p&gt;I prefer to type / because extra/////slashes///are//ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the arrow keys are poison. :)&lt;/p&gt;&#xA;" OwnerUserId="195" LastActivityDate="2015-02-03T22:55:48.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="204" PostTypeId="2" ParentId="201" CreationDate="2015-02-03T22:57:34.233" Score="17" Body="&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt; will resize the split panes to become equal. But I don't know how to make them equal automatically, triggered when the window is resized.&lt;/p&gt;&#xA;" OwnerUserId="135" LastActivityDate="2015-02-03T22:57:34.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="205" PostTypeId="2" ParentId="88" CreationDate="2015-02-03T23:00:13.317" Score="4" Body="&lt;p&gt;When I'm dealing with very long lines, the biggest pain point has to do with differing line lengths. That is, moving up or down near the ends of the lines scrolls the window very far left or right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be avoided by setting &lt;code&gt;virtualedit=all&lt;/code&gt;, which allows you to move the cursor into the space long after the line endings.&lt;/p&gt;&#xA;" OwnerUserId="195" LastActivityDate="2015-02-03T23:00:13.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="206" PostTypeId="2" ParentId="201" CreationDate="2015-02-03T23:00:34.080" Score="35" Body="&lt;p&gt;To go along with @janos's answer, you can set an &lt;code&gt;autocmd&lt;/code&gt; to automatically press those keys when the window is resized (put this in your &lt;code&gt;.vimrc&lt;/code&gt; without the leading colon if you want it to apply every time you open Vim):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd VimResized * wincmd =&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#VimResized&quot; rel=&quot;noreferrer&quot;&gt;Here are the docs for the &lt;code&gt;VimResized&lt;/code&gt; autocmd&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="2920" LastEditDate="2016-08-09T22:36:07.767" LastActivityDate="2016-08-09T22:36:07.767" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="207" PostTypeId="2" ParentId="202" CreationDate="2015-02-03T23:02:54.617" Score="0" Body="&lt;p&gt;The behavior that you want is what happens on my vim.  I can't find a setting that turns it on/off.  Maybe check the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/scroll.html#scroll-mouse-wheel&quot; rel=&quot;nofollow&quot;&gt;:help scrolling&lt;/a&gt;?  &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;scrolloff&amp;#39;&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;scrolloff&lt;/code&gt;&lt;/a&gt; might be involved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also consider using &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#mark-motions&quot; rel=&quot;nofollow&quot;&gt;marks&lt;/a&gt; as a workaround.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; (set mark 'a')&lt;/li&gt;&#xA;&lt;li&gt;scroll the screen as you'd like&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;`&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; (send cursor to mark 'a')&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="141" LastActivityDate="2015-02-03T23:02:54.617" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="208" PostTypeId="2" ParentId="129" CreationDate="2015-02-03T23:05:43.827" Score="4" Body="&lt;p&gt;It seems to me the simple answer to this is to press &lt;code&gt;u&lt;/code&gt; until you undo a change you wanted to keep, then press &lt;code&gt;Ctrl-R&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="195" LastActivityDate="2015-02-03T23:05:43.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="209" PostTypeId="2" ParentId="202" CreationDate="2015-02-03T23:09:34.983" Score="21" Body="&lt;p&gt;As @Doorknob said in his comment, &lt;code&gt;:set mouse=a&lt;/code&gt; fixes the problem.&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2015-02-03T23:09:34.983" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="211" PostTypeId="1" AcceptedAnswerId="212" CreationDate="2015-02-03T23:27:37.637" Score="9" ViewCount="3279" Body="&lt;p&gt;In writing some Vimscript to try to answer &lt;a href=&quot;https://vi.stackexchange.com/a/145/182&quot;&gt;this question&lt;/a&gt;, I was exploring ways to &quot;search for a line with pattern P in position X&quot; (P is a search pattern, X is a number).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to do this would be to search for (e.g.) &lt;code&gt;^.....[a-z]&lt;/code&gt;, where &lt;code&gt;[a-z]&lt;/code&gt; is the pattern, and &lt;code&gt;5&lt;/code&gt; is the position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how would I use Vimscript to make &lt;code&gt;.....&lt;/code&gt;, from &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;5&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="182" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-09T00:44:50.893" Title="How do I search for a line that contains a pattern at column n" Tags="|vimscript|search|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="212" PostTypeId="2" ParentId="211" CreationDate="2015-02-03T23:31:43.840" Score="10" Body="&lt;p&gt;Simply use regex syntax for &quot;repeat &lt;code&gt;n&lt;/code&gt; times&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^.\{5}[a-z]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This searches for 5 &lt;code&gt;.&lt;/code&gt;s and then an &lt;code&gt;[a-z]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just want to repeat a character &lt;code&gt;c&lt;/code&gt; &lt;code&gt;n&lt;/code&gt; times, simply do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let dots = repeat('.', 5)&#xA;&quot; dots is now '.....'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastEditorUserId="88" LastEditDate="2015-02-03T23:52:11.837" LastActivityDate="2015-02-03T23:52:11.837" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="213" PostTypeId="2" ParentId="120" CreationDate="2015-02-03T23:32:58.547" Score="18" Body="&lt;p&gt;I like using search for these things, because Vim's regexs have an insane amount of things you can search for, like specific virtual column numbers, in this case:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap cd /\%&amp;lt;C-R&amp;gt;=virtcol(&quot;.&quot;)&amp;lt;CR&amp;gt;v\S&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap cu ?\%&amp;lt;C-R&amp;gt;=virtcol(&quot;.&quot;)&amp;lt;CR&amp;gt;v\S&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;cd&lt;/code&gt; to go down and &lt;code&gt;cu&lt;/code&gt; to go up. I'm thinking &quot;column up&quot; and &quot;column down&quot; here. I'm almost 100% confident that these are no-ops by default. Or pick your own mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should work whether you are using tabs or spaces or both.&lt;/p&gt;&#xA;" OwnerUserId="195" LastActivityDate="2015-02-03T23:32:58.547" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="214" PostTypeId="2" ParentId="181" CreationDate="2015-02-03T23:47:06.113" Score="4" Body="&lt;p&gt;See &lt;code&gt;:help cmd-key&lt;/code&gt; and &lt;code&gt;:help macmenu&lt;/code&gt;.  As you noticed &lt;kbd&gt;⌘-T&lt;/kbd&gt; is now mapped to &quot;New Tab&quot; in the menu.  You need to free up &lt;kbd&gt;⌘-T&lt;/kbd&gt; before you can remap it to something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like the following should be added to your &lt;strong&gt;.gvimrc&lt;/strong&gt; (.vimrc will not work):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Free Up Cmd-t&#xA;macmenu File.New\ Tab key=&amp;lt;nop&amp;gt;&#xA;&#xA;&quot; Remap it to fuzzyFinder&#xA;nmap &amp;lt;D-t&amp;gt; :FufBuffer&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="109" LastActivityDate="2015-02-03T23:47:06.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="215" PostTypeId="1" AcceptedAnswerId="218" CreationDate="2015-02-04T00:09:19.027" Score="20" ViewCount="459" Body="&lt;p&gt;Occasionally when I try to quit Vim, I get something that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QLOnE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how I accidentally invoke this, but my current method for escaping it is to hit random keys and eventually it goes away. Two questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How am I invoking it (I use &lt;code&gt;:q&lt;/code&gt; to exit vim) accidentally, and&lt;/li&gt;&#xA;&lt;li&gt;How can I exit it quickly and get back to what I'm working on?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerDisplayName="user2" LastActivityDate="2015-02-04T00:14:10.030" Title="What is the '[Command Line]' that sometimes comes up when I try to quit, and how can I quickly exit it?" Tags="|command-line|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="216" PostTypeId="2" ParentId="215" CreationDate="2015-02-04T00:13:25.270" Score="2" Body="&lt;p&gt;That view shows your recently used commands, you reversed the characters and pressed &lt;code&gt;q:&lt;/code&gt; instead. You can use the default &lt;code&gt;&amp;lt;C-w&amp;gt; q&lt;/code&gt; to close it.&lt;/p&gt;&#xA;" OwnerUserId="206" LastActivityDate="2015-02-04T00:13:25.270" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="217" PostTypeId="2" ParentId="215" CreationDate="2015-02-04T00:14:06.993" Score="7" Body="&lt;p&gt;&lt;code&gt;:help Command-line&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *Cmdline-mode* *Command-line-mode*&#xA;Command-line mode       *Cmdline* *Command-line* *mode-cmdline* *:*&#xA;&#xA;Command-line mode is used to enter Ex commands (&quot;:&quot;), search patterns&#xA;(&quot;/&quot; and &quot;?&quot;), and filter commands (&quot;!&quot;).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One of the ways to enter Command Line mode is &lt;code&gt;q:&lt;/code&gt;, which you're probably accidentally typing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is simply a new window. You can close it via &lt;code&gt;&amp;lt;C-w&amp;gt; q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a related note, I suggest using &lt;code&gt;ZZ&lt;/code&gt; to save and quit instead. It's easier to type and less prone to mistakes like these.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-04T00:14:06.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="218" PostTypeId="2" ParentId="215" CreationDate="2015-02-04T00:14:10.030" Score="21" Body="&lt;p&gt;You have invoked it by pressing &lt;code&gt;q:&lt;/code&gt; which opens a new window and allows you to write an Ex command. That is why it's called the &lt;code&gt;Command Line&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read up on it by typing &lt;code&gt;:help q:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it is a window you can simply exit it as any other window, notably &lt;code&gt;:q&lt;/code&gt; written correctly.&lt;/p&gt;&#xA;" OwnerUserId="73" LastActivityDate="2015-02-04T00:14:10.030" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="219" PostTypeId="2" ParentId="143" CreationDate="2015-02-04T00:16:20.193" Score="6" Body="&lt;p&gt;If you're comfortable taking the plugin route, there's &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn&quot;&gt;NrrwRgn&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You visually select a block, then run the &lt;code&gt;:NR&lt;/code&gt; command, which opens a new buffer (in a split) with the selected text. You can make modifications to this buffer, and when you save to it, it gets saved back to the original file as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion, this plugin solves the problem very well, letting you focus on the operations you want to do without re-thinking how to apply them to a specific range.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-02-04T00:16:20.193" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="220" PostTypeId="1" CreationDate="2015-02-04T00:16:51.487" Score="1" ViewCount="58" Body="&lt;p&gt;Let's say we wanted to produce the following text in a very &quot;vim&quot; way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Row 1 {&#xA;  33.33%;&#xA;}&#xA;Row 2 {&#xA;  66.66%;&#xA;}&#xA;Row 3 {&#xA;  100%;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This isn't too complicated, but I think of it as a standin for something far more annoying, like having 12 rows (which might happen in CSS, for instance). I'm not interested in writing a whole plugin, because I think that is excessive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something I don't know too much about yet is using expressions () or making throw-away mappings. I bet these would lead to really clever, really nice ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be that the &quot;right&quot; way is to be clever with a macro involving &lt;code&gt;:put =1.0/3&lt;/code&gt; or something (this performs the division). But I'm not sure how to properly increment the numerator in this sort of expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be the &quot;right&quot; way to open a scratch buffer, write a quick throwaway function, and call it. But really, this is a very large hammer for a very small nail. There is some length of list where this would become more efficient than simply typing it, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There might be &lt;code&gt;:ex&lt;/code&gt; magic or a really convenient commandline tool that I should pipe into vim, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are so many options, and I'm not sure which are reasonable, and which are in the vim way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;To make this clear, I am not looking for the &lt;strong&gt;shortest&lt;/strong&gt; way as in true code-golf, but instead a way that is extensible and comparable to making other formatted lists of numbers&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="130" LastEditorUserId="51" LastEditDate="2015-02-04T17:04:40.220" LastActivityDate="2015-02-04T19:20:29.953" Title="Created a formatted list of percentages efficiently" Tags="|macro|text-generation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="221" PostTypeId="1" AcceptedAnswerId="227" CreationDate="2015-02-04T00:18:44.077" Score="20" ViewCount="3367" Body="&lt;p&gt;Vim, by default, opens all .md files as &quot;modula2&quot; code. I have never heard of modula2, nor do I plan to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I tell vim to always treat &lt;code&gt;foo.md&lt;/code&gt; as Markdown (as if I had typed &lt;code&gt;:set ft=markdown&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-04T01:14:41.967" Title="Open .md files as Markdown" Tags="|filetype|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="222" PostTypeId="2" ParentId="221" CreationDate="2015-02-04T00:18:44.077" Score="13" Body="&lt;p&gt;I currently have this line as an ugly hack in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead *.md set ft=markdown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm still wondering if there's a better way, though.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-04T00:18:44.077" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="223" PostTypeId="5" CreationDate="2015-02-04T00:29:43.907" Score="0" Body="&lt;p&gt;The easiest way to start editing in diff mode is with the &quot;vimdiff&quot; command.&#xA;This starts Vim as usual, and additionally sets up for viewing the differences&#xA;between the arguments.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff file1 file2 [file3 [file4]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is equivalent to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -d file1 file2 [file3 [file4]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/diff.html#diff&quot; rel=&quot;nofollow&quot;&gt;vimdoc&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="188" LastEditorUserId="188" LastEditDate="2015-02-04T14:07:20.890" LastActivityDate="2015-02-04T14:07:20.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="224" PostTypeId="4" CreationDate="2015-02-04T00:29:43.907" Score="0" Body="The diff feature of vim lets show differences between two,&#xD;&#xA;three or four versions of the same file" OwnerUserId="188" LastEditorUserId="188" LastEditDate="2015-02-04T14:07:36.863" LastActivityDate="2015-02-04T14:07:36.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="225" PostTypeId="2" ParentId="220" CreationDate="2015-02-04T00:35:14.207" Score="1" Body="&lt;p&gt;This is really long and ugly, but here goes...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Generating a list of initial numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i1&amp;lt;esc&amp;gt;qqyyp&amp;lt;C-a&amp;gt;q@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;2&#xA;3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need more, add &lt;code&gt;n@@&lt;/code&gt; to the end of this, where &lt;code&gt;n&lt;/code&gt; is the amount of numbers more than three you need (i.e. if you want 20%, 40%, ..., 100%, then just append a &lt;code&gt;2@@&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Convert these to percentages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V?1&amp;lt;cr&amp;gt;:s:.*:\=100.0*submatch(0)/3&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;33.333333&#xA;66.666667&#xA;100.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used &lt;code&gt;:&lt;/code&gt; as the separator for &lt;code&gt;s&lt;/code&gt; to avoid having to escape the &lt;code&gt;/&lt;/code&gt; in the replacement section (which for some reason doesn't work), but you could use any other character as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, this question taught me about &lt;code&gt;\=&lt;/code&gt;! Found it via Google. &lt;code&gt;submatch(0)&lt;/code&gt; is simply the entire matched text.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add the rest of the formatting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gv:s/^/Row {\r  /&amp;lt;cr&amp;gt;gvj:s/\([0-9]\)$/\1%\r}&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Row {&#xA;  33.333333%&#xA;}&#xA;Row {&#xA;  66.666667%&#xA;}&#xA;Row {&#xA;  100.0%&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sorry, this doesn't add the row numbers. I have to go now, further explanation will be added later.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The full thing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i1&amp;lt;esc&amp;gt;qqyyp&amp;lt;C-a&amp;gt;q@qV?1&amp;lt;cr&amp;gt;:s:.*:\=100.0*submatch(0)/3&amp;lt;cr&amp;gt;gv:s/^/Row {\r  /&amp;lt;cr&amp;gt;gvj:s/\([0-9]\)$/\1%\r}&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastEditorUserId="88" LastEditDate="2015-02-04T01:33:25.277" LastActivityDate="2015-02-04T01:33:25.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="226" PostTypeId="2" ParentId="104" CreationDate="2015-02-04T00:36:01.337" Score="14" Body="&lt;p&gt;One can see the current working directory with &lt;code&gt;:pwd&lt;/code&gt;. Of course, this is only the directory, and not the filename. To get the working directory and filename, we can use the special register &lt;code&gt;%&lt;/code&gt;, which contains information about the current file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;:echo @%&lt;/code&gt;, you'll get the directory and filename of the current file.&lt;br&gt;&#xA;If you use &lt;code&gt;:echo expand('%:p')&lt;/code&gt;, you'll get the full path and filename of the current file. This is very similar to CharlesL's &lt;a href=&quot;https://vi.stackexchange.com/a/128/130&quot;&gt;answer&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I remember this one, though, because if you use vim's help &lt;code&gt;:h expand&lt;/code&gt;, then it mentions that &lt;code&gt;%&lt;/code&gt; and &lt;code&gt;%:p&lt;/code&gt; and their relatives. &lt;/p&gt;&#xA;" OwnerUserId="130" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-04T00:36:01.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="227" PostTypeId="2" ParentId="221" CreationDate="2015-02-04T00:37:03.063" Score="11" Body="&lt;p&gt;In the file &lt;code&gt;filetype.vim&lt;/code&gt; that is shipped with your distribution you will find a line that looks probably similar to this (on my machine it lives at &lt;code&gt;/usr/share/vim/vim74&lt;/code&gt;) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.md,*.m2,*.mi setf modula2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, this tells vim to set the filetype as modula2 if your file has such an ending.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To override this behaviour you can put a line like this in your own &lt;code&gt;.vimrc&lt;/code&gt; (Taken from the Archlinux filetype.vim) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md  set ft=markdown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I previously had &lt;code&gt;setf&lt;/code&gt; as the function to be called, but it seems to be a reserved function for the &lt;code&gt;filetype.vim&lt;/code&gt; file.&lt;/p&gt;&#xA;" OwnerUserId="73" LastEditorUserId="73" LastEditDate="2015-02-04T01:14:41.967" LastActivityDate="2015-02-04T01:14:41.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="228" PostTypeId="2" ParentId="168" CreationDate="2015-02-04T00:50:29.563" Score="2" Body="&lt;p&gt;No, you cannot go back and forward in the tree. The best way is to use a plugin to this job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another plugin is the &lt;a href=&quot;https://github.com/mbbill/undotree&quot; rel=&quot;nofollow&quot;&gt;Undotree&lt;/a&gt;. It's like &lt;a href=&quot;https://github.com/sjl/gundo.vim&quot; rel=&quot;nofollow&quot;&gt;Gundo&lt;/a&gt;, but with some differences:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pure vimscript implementation and no 3rd-party libraries(like&#xA;python) is needed, don't worry about performance, it's not such a&#xA;big deal for vim to handle this. The only dependency is the 'diff'&#xA;tool which always shipped with vim and even without 'diff' you still&#xA;can use most of the features of this script.&lt;/li&gt;&#xA;&lt;li&gt;Realtime updated undo tree. Once you make changes, the undo tree&#xA;will be updated simultaneously.&lt;/li&gt;&#xA;&lt;li&gt;Several useful marks, like current changeset, next redo changeset,&#xA;saved changeset, etc.&lt;/li&gt;&#xA;&lt;li&gt;Toggle between relative timestamp and absolute timestamp.&lt;/li&gt;&#xA;&lt;li&gt;Realtime updated undo window.&lt;/li&gt;&#xA;&lt;li&gt;Ability to clear undo history.&lt;/li&gt;&#xA;&lt;li&gt;More customizable.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="177" LastEditorUserId="88" LastEditDate="2015-02-04T01:29:12.743" LastActivityDate="2015-02-04T01:29:12.743" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="229" PostTypeId="2" ParentId="220" CreationDate="2015-02-04T01:17:49.087" Score="2" Body="&lt;p&gt;I don't think there's going to be a non-horrible way to do this in Vim without a plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I absolutely had to do it within Vim, without just typing it out, I would call out to awk:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:r!awk 'BEGIN { for(i=1; i&amp;lt;4; i++) { print &quot;Row &quot; i &quot; {&quot;; print &quot;\t&quot; 100/3*i &quot;\%;&quot;; print &quot;}&quot;; } }'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="195" LastEditorUserId="195" LastEditDate="2015-02-04T19:20:29.953" LastActivityDate="2015-02-04T19:20:29.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="230" PostTypeId="1" AcceptedAnswerId="232" CreationDate="2015-02-04T01:39:58.083" Score="15" ViewCount="8763" Body="&lt;p&gt;I type with a non-QWERTY keyboard layout. Many of the keys Vim uses are now on the home row, but some key bindings just don't work, the most obvious one being the &lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt; keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How and where can I change these key bindings to work better with my keyboard layout?&lt;/p&gt;&#xA;" OwnerUserId="211" LastEditorUserId="88" LastEditDate="2015-02-04T01:49:17.227" LastActivityDate="2021-04-29T03:41:48.077" Title="How can I modify Vim to work with a different keyboard layout?" Tags="|vimrc|keyboard-layout|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="231" PostTypeId="2" ParentId="230" CreationDate="2015-02-04T01:45:09.367" Score="2" Body="&lt;p&gt;You can remap keys in vim. &lt;code&gt;nnoremap [ h&lt;/code&gt; remaps &lt;code&gt;[&lt;/code&gt; to &lt;code&gt;h&lt;/code&gt;, so you can use &lt;code&gt;[&lt;/code&gt; in place of &lt;code&gt;h&lt;/code&gt;, you could remap &lt;code&gt;h&lt;/code&gt; to what &lt;code&gt;[&lt;/code&gt; originally did for it to be complete. You'd have to do this for all keys though and there are different modes to consider, so I guess it would be a bit of a pain.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-04T01:45:09.367" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="232" PostTypeId="2" ParentId="230" CreationDate="2015-02-04T01:49:09.503" Score="11" Body="&lt;pre&gt;&lt;code&gt;:help langmap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can remap keys in command mode but leave them intact for typing. This means you can use the intent of  &lt;kbd&gt;hjkl&lt;/kbd&gt; - adjacent homerow keys for scrolling - by pressing the positional equivalents on your keyboard. Suppose your layout is Dvorak, then those same keys are &lt;kbd&gt;dhtn&lt;/kbd&gt;. We need to map all four, even &lt;kbd&gt;h&lt;/kbd&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set langmap=dh,hj,tk,nl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can now navigate using &lt;kbd&gt;dhtn&lt;/kbd&gt;. This won't affect &lt;code&gt;:commands like this&lt;/code&gt; and won't change insert mode (i.e. pressing &lt;kbd&gt;t&lt;/kbd&gt; will give you a 't').&lt;/p&gt;&#xA;&lt;p&gt;You'll need to map other keys too for normal mode - for instance, the delete action would normally be &lt;kbd&gt;d&lt;/kbd&gt; but that's now a navigation key. &lt;kbd&gt;j&lt;/kbd&gt;, &lt;kbd&gt;k&lt;/kbd&gt; or &lt;kbd&gt;l&lt;/kbd&gt; might work since they're no longer navigation keys.&lt;/p&gt;&#xA;" OwnerUserId="212" LastEditorUserId="212" LastEditDate="2021-04-29T03:41:48.077" LastActivityDate="2021-04-29T03:41:48.077" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="233" PostTypeId="1" AcceptedAnswerId="234" CreationDate="2015-02-04T02:27:31.523" Score="25" ViewCount="32965" Body="&lt;p&gt;I work on projects with varying levels of indentation. In many of these projects, because of how the files are typically structured, most lines are indented at least two levels (such as methods in Java files).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would mean that creating a new line when on a line line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void something () {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would bring my cursor to the next line, automatically indented in, like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void something () {&#xA;    [cursor]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While I can hit the tab key a few times on a new line to get it to line up, is there a better way of doing this (possible automatically)?&lt;/p&gt;&#xA;" OwnerUserId="89" LastEditorUserId="24" LastEditDate="2015-02-04T03:01:11.680" LastActivityDate="2017-11-27T14:40:25.700" Title="How can I automatically indent on new lines?" Tags="|indentation|ide|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="234" PostTypeId="2" ParentId="233" CreationDate="2015-02-04T02:27:31.523" Score="22" Body="&lt;p&gt;This can be done using a combination of the &lt;code&gt;autoindent&lt;/code&gt; option and the &lt;code&gt;filetype&lt;/code&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;autoindent&lt;/code&gt; option will copy your current indentation when creating a new line. So if your current indentation level is 4 when you start the new line, the cursor will be moved to the same indentation level on the next line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;~/.vimrc&lt;/code&gt; file, you would put&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;code&gt;filetype&lt;/code&gt; plugin as well to automatically determine the next indentation level based on the file type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can enable this on the fly with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, in your &lt;code&gt;~/.vimrc&lt;/code&gt; file you would put&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will automatically determine the indentation based on the file type.&lt;/p&gt;&#xA;" OwnerUserId="89" LastActivityDate="2015-02-04T02:27:31.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="235" PostTypeId="2" ParentId="233" CreationDate="2015-02-04T03:00:27.817" Score="8" Body="&lt;p&gt;Use &lt;code&gt;:set cindent&lt;/code&gt; (&lt;code&gt;:set cin&lt;/code&gt; for short) or &lt;code&gt;:set smartindent&lt;/code&gt; (&lt;code&gt;:set si&lt;/code&gt; for short).  If your line ends in an opening brace, and you hit &lt;kbd&gt;Enter&lt;/kbd&gt;, the following line will automatically be indented one additional level.  (This is better than &lt;code&gt;:set autoindent&lt;/code&gt;, which merely indents the next line at the &lt;em&gt;same&lt;/em&gt; level.)  &lt;code&gt;cindent&lt;/code&gt; is better tailored to C-like languages, while &lt;code&gt;smartindent&lt;/code&gt; is more versatile for use with other programming languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The amount and type of indentation is controlled by &lt;code&gt;:set shiftwidth=…&lt;/code&gt;, &lt;code&gt;:set tabstop=…&lt;/code&gt;, and &lt;code&gt;:set expandtab&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-04T07:12:49.437" LastActivityDate="2015-02-04T07:12:49.437" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="236" PostTypeId="1" AcceptedAnswerId="242" CreationDate="2015-02-04T03:30:51.720" Score="46" ViewCount="18098" Body="&lt;p&gt;I like the smart-indent feature of Vim, it allows me to create well-indented code blocks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I regularly copy/paste code in to buffers, but that code is often poorly formatted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be ideal is to &quot;re-process&quot; the code through the smart-indent system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is such a thing possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, how would you 'fix' the following code (an extract from a larger block - I don't want to fix each line manually...) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    else &#xA;                {&#xA;                        m[c] = 5;&#xA;                Finished = true;&#xA;std::cout&amp;lt;&amp;lt;&quot;(ID,R,E)&quot;&amp;lt;&amp;lt;&quot;--&amp;gt;&quot;&amp;lt;&amp;lt;&quot;(&quot;&amp;lt;&amp;lt;g[c]&amp;lt;&amp;lt;&quot;,&quot;&amp;lt;&amp;lt;r[c]&amp;lt;&amp;lt;&quot;,&quot;&amp;lt;&amp;lt;E1 &amp;lt;&amp;lt;&quot;)&quot;&amp;lt;&amp;lt; std::endl;&#xA;std::cout &amp;lt;&amp;lt; &quot;\n&quot;&amp;lt;&amp;lt;&quot;finish--&amp;gt;&quot; &amp;lt;&amp;lt; r[c] &amp;lt;&amp;lt; &quot;\t&quot; &amp;lt;&amp;lt;&quot;E1--&amp;gt;&quot;&amp;lt;&amp;lt; E1 &amp;lt;&amp;lt;&quot;\n&quot; ;&#xA;                }&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="86" LastEditorUserId="24" LastEditDate="2015-02-04T10:54:16.207" LastActivityDate="2017-06-24T23:16:19.330" Title="Re-indenting badly indented code" Tags="|indentation|ide|" AnswerCount="7" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="237" PostTypeId="2" ParentId="236" CreationDate="2015-02-04T03:44:15.443" Score="5" Body="&lt;p&gt;To reindent a file already in the buffer, use &lt;code&gt;gg=G&lt;/code&gt;: See &lt;a href=&quot;http://vim.wikia.com/wiki/Fix_indentation&quot; rel=&quot;nofollow&quot;&gt;Fix Indentation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reindenting a portion of a file, various bounds can be applied to the &lt;code&gt;=&lt;/code&gt; filter (for example, &lt;code&gt;==&lt;/code&gt; fixes just the current line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To keep the indentation unchanged when pasting text you can &lt;code&gt;:set paste&lt;/code&gt; before you paste text into the buffer, this will prevent vim from auto-indenting text that you've just pasted. After pasting stuff, you can go back using &lt;code&gt;set :nopaste&lt;/code&gt; when you're done. See vimdoc &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27paste%27&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find yourself pasting stuff frequently, it'd be a good idea to use &lt;a href=&quot;http://vim.wikia.com/wiki/Toggle_auto-indenting_for_code_paste&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; tip on the VimWiki and setup a key for &quot;paste-mode&quot; toggle by adding these lines to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; :set invpaste paste?&amp;lt;CR&amp;gt;&#xA;set pastetoggle=&amp;lt;F2&amp;gt;&#xA;set showmode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then hit &lt;code&gt;&amp;lt;F2&amp;gt;&lt;/code&gt; to toggle paste-mode. vim will show the words &quot;PASTE&quot; in the status line when paste mode is active.&lt;/p&gt;&#xA;" OwnerUserId="224" LastEditorUserId="86" LastEditDate="2015-02-04T14:04:16.407" LastActivityDate="2015-02-04T14:04:16.407" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="238" PostTypeId="1" AcceptedAnswerId="247" CreationDate="2015-02-04T03:44:25.987" Score="16" ViewCount="3707" Body="&lt;p&gt;This only seems to happens when using vim inside of tmux. I'm also using iTerm 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I create a new tmux pane or resize a tmux pane, it immediately looks like the this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/yQTD0.png&quot; alt=&quot;messed up background in vim&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then the only way to fix it is to scroll around in vim, and it goes back to this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qHQLp.png&quot; alt=&quot;good background in vim&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be causing this?&lt;/p&gt;&#xA;" OwnerUserId="226" LastEditorUserId="226" LastEditDate="2015-02-06T00:06:23.603" LastActivityDate="2019-06-29T19:49:21.800" Title="Tmux is changing part of the background in vim" Tags="|terminal|tmux|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="239" PostTypeId="1" AcceptedAnswerId="243" CreationDate="2015-02-04T03:52:25.290" Score="18" ViewCount="1140" Body="&lt;p&gt;I rarely, if ever, just open &lt;code&gt;vim&lt;/code&gt; without filenames. Often enough, I want to test something out, usually a quick throwaway script, and I usually name them &lt;code&gt;test.sh&lt;/code&gt; (or some variant thereof, like &lt;code&gt;test.py&lt;/code&gt;). Can I make &lt;code&gt;vim&lt;/code&gt; assume a &lt;code&gt;test.sh&lt;/code&gt; filename if I ran &lt;code&gt;vim&lt;/code&gt; without any filenames? I'd usually use aliases (like &lt;code&gt;vims&lt;/code&gt; for &lt;code&gt;vim test.sh&lt;/code&gt; and &lt;code&gt;vimp&lt;/code&gt; for &lt;code&gt;vim test.py&lt;/code&gt;, or go the whole &lt;code&gt;:w test.sh&lt;/code&gt;), but I wonder if there's a way from within &lt;code&gt;vim&lt;/code&gt;. It would be even better if I can restrict this to certain directories, like &lt;code&gt;/tmp&lt;/code&gt;, or &lt;code&gt;~/dev&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="51" LastEditDate="2015-04-30T15:40:42.133" LastActivityDate="2015-12-04T06:00:07.823" Title="How do I make Vim use a default filename when not given any filenames?" Tags="|vimrc|startup|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="240" PostTypeId="2" ParentId="236" CreationDate="2015-02-04T03:56:47.593" Score="20" Body="&lt;p&gt;The &lt;code&gt;=&lt;/code&gt; command can be used to reindent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like most normal mode commands it can be applied to a motion, so you can reindent the just pasted code with &lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;.  This reindents from the current cursor position to the &lt;code&gt;']&lt;/code&gt; mark, which is the last line of the paste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;=&lt;/code&gt; can also be used from visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another useful command is &lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;, which pastes at the same indent level as the current line.  This can help paste properly indented text, although at a different indent depth, in accordance with the surrounding text.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-02-04T03:56:47.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="241" PostTypeId="1" AcceptedAnswerId="537" CreationDate="2015-02-04T04:05:43.253" Score="39" ViewCount="7634" Body="&lt;p&gt;Consider a case with multiple splits in a window. vim allows quickly &amp;quot;maximizing&amp;quot; the current split to take up the whole window via &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; &lt;code&gt;o&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way get vim to &amp;quot;remember&amp;quot; the splits that existed before and revert to this state after executing &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; &lt;code&gt;o&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: To clarify, I'm looking for a way to do this without the use of any third-party plugins.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help CTRL-W_o&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="224" LastEditorUserId="14340" LastEditDate="2020-10-11T11:56:46.470" LastActivityDate="2022-11-27T22:44:52.573" Title="How to undo/revert making current window the only window (&quot;:only&quot; / &quot;&lt;C-W&gt; o&quot;)?" Tags="|vim-windows|split|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="242" PostTypeId="2" ParentId="236" CreationDate="2015-02-04T04:07:59.843" Score="54" Body="&lt;p&gt;I do this one of two ways.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Indent adjusted paste&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First, if the code in the buffer is formatted, but at a different level of indentation, I use &lt;code&gt;]p&lt;/code&gt; instead of &lt;code&gt;p&lt;/code&gt;, which pastes the code as is, but with the indentation shifted such that the first line pasted is the same depth as the line I'm on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.G. source copied to buffer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (1) {&#xA;    dostuff();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;E.G. result of pasting it with &lt;code&gt;]p&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int myfunc() {&#xA;    int i = 5; /* Cursor on this line before paste */&#xA;    while (1) {&#xA;        dostuff();&#xA;    }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim puts the while at the same indentation level as &lt;code&gt;int i&lt;/code&gt;. This is quick, but only works if the copied code is properly indented within itself.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Reformat after paste&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;=&lt;/code&gt; operator in vim reformats the code based on the configured formatting rules. For short snippets of pasting, I'll go into visual mode with &lt;code&gt;v&lt;/code&gt;, select the lines I just pasted and then press &lt;code&gt;=&lt;/code&gt; to reformat them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For larger pastes, I take advantage of the fact that the cursor goes to the first pasted line, and that vim says something like &quot;84 more lines&quot;. I can then enter &lt;code&gt;84==&lt;/code&gt; to reflow those 84 lines (of course, substitute 84 with the number of lines you actually paste).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help ]p&lt;/code&gt; for adjusted indent paste&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help =&lt;/code&gt; covers &lt;code&gt;={motion}&lt;/code&gt;, &lt;code&gt;[count]==&lt;/code&gt; and &lt;code&gt;{Visual}=&lt;/code&gt; for filtering through custom or builtin indent rules&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="51" LastEditDate="2017-06-24T23:16:19.330" LastActivityDate="2017-06-24T23:16:19.330" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="243" PostTypeId="2" ParentId="239" CreationDate="2015-02-04T04:30:58.030" Score="11" Body="&lt;p&gt;Try putting this at the end of your .vimrc (modify as appropriate)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if @% == &quot;&quot; &amp;amp;&amp;amp; getcwd() == &quot;/tmp&quot;&#xA;    :silent edit test.sh&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This checks if the current filename is empty (&lt;code&gt;@%&lt;/code&gt; references the current filename), and checks if vim's current directory is &lt;code&gt;/tmp&lt;/code&gt;. You could add other directories as well like so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(getcwd() == &quot;/tmp&quot; || getcwd() == &quot;~/dev&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It then silently edits test.sh. If that file already exists, it'll load it. Otherwise, you'll start a new buffer with that name and the file will be created if you write it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did silent to suppress the following message during startup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;test.sh&quot; [New File]&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-02-04T04:30:58.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="244" PostTypeId="2" ParentId="236" CreationDate="2015-02-04T05:09:14.870" Score="8" Body="&lt;p&gt;Using &lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; &lt;em&gt;(mnemonic is 'format a paragraph')&lt;/em&gt; will have vim attempt to autoformat the current paragraph. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to pay careful attention to what you're potentially reformatting, you might find it saner and quicker to use &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; to visually select the current paragraph (giving you a visual indication of what is being reformatted), followed by &lt;kbd&gt;=&lt;/kbd&gt;. I find this useful in files where I know that vim will reformat incorrectly, and I don't want to mistakenly incorrectly format other lines.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2015-02-04T05:09:14.870" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="245" PostTypeId="1" AcceptedAnswerId="248" CreationDate="2015-02-04T05:14:45.553" Score="7" ViewCount="2285" Body="&lt;p&gt;Using gF I can jump to a file with the format foobar.py:27:6 to open foobar.py on line 27. My question is how I can make this jump in vimscript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, this won't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal gF &quot; . foobar.py:27:6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;because gF doesn't take an argument - it uses the word under the cursor - but hopefully this gives an impression of what I'm trying to do.&lt;/p&gt;&#xA;" OwnerUserId="234" LastActivityDate="2019-10-27T14:11:23.173" Title="Jumping to a file in vimscript" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="246" PostTypeId="2" ParentId="238" CreationDate="2015-02-04T05:20:27.137" Score="1" Body="&lt;p&gt;I believe this is related to &lt;code&gt;ttyfast&lt;/code&gt; so the screen is not fully redrawn. Try setting it to on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'ttyfast' 'tf'      boolean (default off, on when 'term' is xterm, hpterm,&#xA;                    sun-cmd, screen, rxvt, dtterm or&#xA;                    iris-ansi; also on when running Vim in&#xA;                    a DOS console)&#xA;            global&#xA;            {not in Vi}&#xA;    Indicates a fast terminal connection.  More characters will be sent to&#xA;    the screen for redrawing, instead of using insert/delete line&#xA;    commands.  Improves smoothness of redrawing when there are multiple&#xA;    windows and the terminal does not support a scrolling region.&#xA;    Also enables the extra writing of characters at the end of each screen&#xA;    line for lines that wrap.  This helps when using copy/paste with the&#xA;    mouse in an xterm and other terminals.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="237" LastActivityDate="2015-02-04T05:20:27.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="247" PostTypeId="2" ParentId="238" CreationDate="2015-02-04T05:22:36.757" Score="20" Body="&lt;p&gt;You might try to add the following to your .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;term =~ '256color'&#xA;  &quot; disable Background Color Erase (BCE)&#xA;  set t_ut=&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;t_ut&lt;/code&gt; option (default = y) describes how vim handles what it wants as background colors compared to attempting to use the current background color. This snippet clears that option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, then you might try to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ttyfast&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is an option that handles how vim redraws screens.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2015-02-04T05:22:36.757" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="248" PostTypeId="2" ParentId="245" CreationDate="2015-02-04T05:28:27.517" Score="8" Body="&lt;p&gt;If you don't care about the column, and as an example you have the linenumber and filename in variables, you could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;edit +&quot; . linenumber . &quot; &quot; . filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, as from your example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;edit +27 foobar.py&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To expand the colon separation and then edit would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let fileLine=&quot;foobar.py:27&quot;&#xA;let filename=split(fileLine,&quot;:&quot;)[0]&#xA;let linenumber=split(fileLine,&quot;:&quot;)[1]&#xA;execute &quot;edit +&quot; . linenumber . &quot; &quot; . filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm hard coding the value of fileLine there, but you could obtain it however you like. I'm ignoring the column for simplicity and because you only mentioned jumping to the line in your question.&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-02-04T05:28:27.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="249" PostTypeId="2" ParentId="239" CreationDate="2015-02-04T05:43:12.863" Score="5" Body="&lt;p&gt;A modification of John's answer may be useful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if @% == &quot;&quot; &amp;amp;&amp;amp; getcwd() == &quot;/tmp&quot;&#xA;    :silent edit `=glob(&quot;test\.*&quot;, 1, 1)[0]`&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That opens the first file which begins with &lt;code&gt;test.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of just the first file, if you wanted to open other matching files as well, do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if @% == &quot;&quot; &amp;amp;&amp;amp; getcwd() == &quot;/tmp&quot;&#xA;    for i in glob(&quot;test\.*&quot;, 1, 1)&#xA;        :silent edit `=i`&#xA;    endfor&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="233" LastEditorUserId="4939" LastEditDate="2015-12-04T06:00:07.823" LastActivityDate="2015-12-04T06:00:07.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="251" PostTypeId="2" ParentId="143" CreationDate="2015-02-04T06:06:18.167" Score="0" Body="&lt;p&gt;Use the braces text object '}'and select inside the braces with 'i}'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;on the line with the opening curly brace of the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$&amp;lt;C-V&amp;gt;i}:s/\$color/$newColor/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;first go to the end of the line (which will be on or inside the opening brace) then  to go into visual select, then select using the braces text object. 'i}' is inside braces 'a}' is around braces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For languages that lack braces, &lt;a href=&quot;http://blog.carbonfive.com/2011/10/17/vim-text-objects-the-definitive-guide/&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;Vim Text Object: The Definitive Guide&lt;/em&gt;&lt;/a&gt; suggests some plugins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For languages like Python and CoffeeScript, &lt;a href=&quot;https://github.com/michaeljsmith/vim-indent-object&quot; rel=&quot;nofollow&quot;&gt;Indent Object&lt;/a&gt; provides text objects based on indentation level: &lt;code&gt;ai&lt;/code&gt; includes the current indentation level and the line above; &lt;code&gt;ii&lt;/code&gt; includes the current indentation level excluding the line above.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/nelstrom/vim-textobj-rubyblock&quot; rel=&quot;nofollow&quot;&gt;Ruby Block&lt;/a&gt; adds support for text objects &lt;code&gt;ar&lt;/code&gt; and &lt;code&gt;ir&lt;/code&gt;, based on the presence of the &lt;code&gt;end&lt;/code&gt; keyword.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="233" LastEditorUserId="24" LastEditDate="2015-02-06T22:38:25.773" LastActivityDate="2015-02-06T22:38:25.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="252" PostTypeId="2" ParentId="184" CreationDate="2015-02-04T06:17:07.593" Score="77" Body="&lt;p&gt;As an alternative to &lt;code&gt;:noh&lt;/code&gt;, I like to do &lt;code&gt;:let @/=&quot;&quot;&lt;/code&gt; mapped to a keyboard shortcut.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference is that &lt;code&gt;:noh&lt;/code&gt; leaves the search term in the search register, so &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; in normal mode resume the search by jumping to the next/previous match and re-highlighting.&#xA;Using &lt;code&gt;:let @/=&quot;&quot;&lt;/code&gt;, on the other hand, causes the message &lt;code&gt;E25: No previous regular expression&lt;/code&gt; and &lt;em&gt;leaves your cursor where it was&lt;/em&gt;, which is especially convenient if you don't yet know about &lt;code&gt;ctrl&lt;/code&gt;-&lt;code&gt;o&lt;/code&gt; yet and accidentally hit &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can also be used the other way. To cause vim to highlight some text without jumping to it, you can &lt;code&gt;:let @/=&quot;some text&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In these expressions, @ lets you refer to a register, and @/ is the register holding the last search pattern.&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-02-04T06:17:07.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="255" PostTypeId="2" ParentId="241" CreationDate="2015-02-04T07:15:24.717" Score="3" Body="&lt;p&gt;I use the ZoomWin plugin (&lt;a href=&quot;https://github.com/itspriddle/ZoomWin&quot; rel=&quot;nofollow&quot;&gt;https://github.com/itspriddle/ZoomWin&lt;/a&gt;) for exactly this scenario. Pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;W&lt;/kbd&gt;-&lt;kbd&gt;O&lt;/kbd&gt; a second time restores your window layout.&lt;/p&gt;&#xA;" OwnerUserId="248" LastActivityDate="2015-02-04T07:15:24.717" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="256" PostTypeId="2" ParentId="192" CreationDate="2015-02-04T07:20:49.513" Score="3" Body="&lt;p&gt;You can add this line to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shell=/usr/local/bin/zsh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(or whatever the path is to your zsh install)&lt;/p&gt;&#xA;" OwnerUserId="248" LastActivityDate="2015-02-04T07:20:49.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="257" PostTypeId="1" AcceptedAnswerId="260" CreationDate="2015-02-04T07:34:15.737" Score="26" ViewCount="9144" Body="&lt;p&gt;I use Vi as my preferred (and, in fact, only) text editor on Linux Systems. I know how to change modes from normal to insert, and vice-versa.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to have Vi automatically load into Insert Mode rather than Normal Mode?&lt;/p&gt;&#xA;&lt;p&gt;I want this because I can only access my Linux over SSH, and my computer that I can use for SSH access is &lt;em&gt;so&lt;/em&gt; slow, it takes &lt;em&gt;ages&lt;/em&gt; to load command mode. (Also my Openwrt system is quite slow).&lt;/p&gt;&#xA;" OwnerDisplayName="user254" LastEditorUserId="10604" LastEditDate="2020-08-11T20:35:27.997" LastActivityDate="2023-02-01T11:30:48.367" Title="Automatically load Vi into insert mode" Tags="|insert-mode|invocation|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="258" PostTypeId="1" AcceptedAnswerId="270" CreationDate="2015-02-04T07:41:28.630" Score="8" ViewCount="1214" Body="&lt;p&gt;I'm aiming to make scripts I write in a certain directory (or of a certain extension) automatically executable on creation. I can do this whenever a file is written to, using &lt;a href=&quot;https://askubuntu.com/a/546239/158442&quot;&gt;the following &lt;code&gt;autocmd&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.py silent execute &quot;! chmod +x %&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I don't like is that this runs every time the file is written. If I had decided to reset the permissions of a particular script, I wouldn't want it to be set again, for example. And if the command is expensive, or is not idempotent, it would be undesirable to run it again and again. While this particular example uses &lt;code&gt;chmod&lt;/code&gt;, please consider a more general case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an event for when a buffer is created for a new file (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocmd-events&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;BufNewFile&lt;/code&gt;&lt;/a&gt;), but is there some way to do this when such a buffer is written the first time?&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.647" LastActivityDate="2019-07-05T10:28:14.373" Title="How do I run a command on creation of a new file?" Tags="|save|autocmd|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="259" PostTypeId="2" ParentId="257" CreationDate="2015-02-04T07:45:00.713" Score="16" Body="&lt;pre&gt;&lt;code&gt;$ vim -y &amp;lt;file&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;-y        Easy mode.  Implied for |evim| and |eview|.  Starts with        'insertmode' set and behaves like a click-and-type editor.      This&#xA;  sources the script $VIMRUNTIME/evim.vim.  Mappings are        set up to&#xA;  work like most click-and-type editors, see        |evim-keys|.  The GUI is&#xA;  started when available.       {not in Vi}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/starting.html&quot;&gt;source&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="153" LastActivityDate="2015-02-04T07:45:00.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="260" PostTypeId="2" ParentId="257" CreationDate="2015-02-04T07:45:19.973" Score="37" Body="&lt;p&gt;You can use the &lt;code&gt;+startinsert&lt;/code&gt; option (or &lt;code&gt;+star&lt;/code&gt; for short) to start Vim with insert mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +star myfile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want this to happen by default when starting Vim, you can make an alias (in your &lt;code&gt;.bashrc&lt;/code&gt; or &lt;code&gt;.zshrc&lt;/code&gt; for example) as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vim=&quot;vim +startinsert&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, that works only when starting Vim. If you want Vim to be in Insert mode even when you open a file from within Vim, add the following to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile * startinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="53" LastActivityDate="2015-02-04T07:45:19.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="261" PostTypeId="2" ParentId="257" CreationDate="2015-02-04T07:46:39.613" Score="5" Body="&lt;p&gt;Although I think starting in insert mode is not the vim way, you can do this very easily. You should start vim with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c startinsert 'file'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The -c flag passes in a command into vim. The &lt;code&gt;:startinsert&lt;/code&gt; command changes to insert mode. As you can imagine, you could start vim with any number of commands if you so desired.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2015-02-04T07:46:39.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="262" PostTypeId="5" CreationDate="2015-02-04T07:58:39.077" Score="0" Body="&lt;p&gt;One of Vim's most powerful features is its ability to run arbitrary commands on certain events for matching files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Key Terms:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;event&lt;/code&gt;: The set of events on which &lt;code&gt;vim&lt;/code&gt; triggers &lt;code&gt;autocmd&lt;/code&gt; execution. These include staring to writ a file (&lt;code&gt;BufWrite&lt;/code&gt;), before exiting vim (&lt;code&gt;VimLeavePre&lt;/code&gt;), etc.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;pattern&lt;/code&gt;: A pattern to match file names for which an &lt;code&gt;autocmd&lt;/code&gt; will be executed. Patterns can include wildcards, environment variables and special terms for buffer-local action.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;command&lt;/code&gt;: The command to be executed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Standard information:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html&quot; rel=&quot;nofollow&quot;&gt;Vimdoc&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-02-04T14:05:23.137" LastActivityDate="2015-02-04T14:05:23.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="263" PostTypeId="4" CreationDate="2015-02-04T07:58:39.077" Score="0" Body="`autocmd`s are commands executed automatically on certain events. Questions on creating or modifying `autocmd` definitions are appropriate for this tag." OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-02-04T14:04:22.797" LastActivityDate="2015-02-04T14:04:22.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="264" PostTypeId="2" ParentId="77" CreationDate="2015-02-04T08:11:19.647" Score="15" Body="&lt;p&gt;I use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=441&quot;&gt;localvimrc&lt;/a&gt; for this purpose. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put a &lt;code&gt;.lvimrc&lt;/code&gt; with your project settings inside your project and these settings will override settings in &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, you will be asked if you want to source this file, eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;localvimrc: source /home/martin/code/.lvimrc? ([y]es/[n]o/[a]ll/[q]uit) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is to prevent sourcing random (untrusted) vimrc files. If you find this annoying, you can setup a whitelist of &lt;code&gt;.lvimrc&lt;/code&gt; files with &lt;code&gt;g:localvimrc_whitelist&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:localvimrc_whitelist = '/home/martin/code/.lvimrc'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can just disable asking for confirmation completely with &lt;code&gt;set g:localvimrc_ask = 0&lt;/code&gt;. This is not recommended, though.&lt;/p&gt;&#xA;" OwnerUserId="153" LastEditorUserId="51" LastEditDate="2015-02-25T16:35:12.493" LastActivityDate="2015-02-25T16:35:12.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="265" PostTypeId="1" AcceptedAnswerId="815" CreationDate="2015-02-04T08:12:05.683" Score="5" ViewCount="189" Body="&lt;p&gt;The &lt;a href=&quot;http://vim-latex.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;Vim LaTeX-suite&lt;/a&gt; includes a number of predefined LaTeX environments, including the obsolete¹ &lt;code&gt;eqnarray&lt;/code&gt; and &lt;code&gt;eqnarray*&lt;/code&gt; environments. I want to get rid of every last shadow of these environments in the LaTeX-suite. How do I do that (and replace them by other environments)?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;¹ e.g. see &lt;a href=&quot;http://www.tug.org/pracjourn/2006-4/madsen/madsen.pdf&quot; rel=&quot;nofollow&quot;&gt;Avoid eqnarray!&lt;/a&gt; (PDF)&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="211" LastEditorUserId="51" LastEditDate="2015-04-30T11:41:02.540" LastActivityDate="2015-04-30T11:41:02.540" Title="Remove eqnarray from Vim LaTeX" Tags="|filetype-tex|plugin-vim-latex|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="266" PostTypeId="5" CreationDate="2015-02-04T08:13:21.417" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;https://github.com/vim-latex/vim-latex&quot; rel=&quot;nofollow&quot;&gt;the project home page&lt;/a&gt; for more details on the features of the plugin.&lt;/p&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="1841" LastEditDate="2016-05-01T09:42:31.947" LastActivityDate="2016-05-01T09:42:31.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="267" PostTypeId="4" CreationDate="2015-02-04T08:13:21.417" Score="0" Body="Questions about the plugin vim-latex which provides enhanced LaTeX support for Vim." OwnerUserId="-1" LastEditorUserId="1841" LastEditDate="2016-05-01T09:42:31.947" LastActivityDate="2016-05-01T09:42:31.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="268" PostTypeId="1" CreationDate="2015-02-04T08:17:59.857" Score="7" ViewCount="1342" Body="&lt;p&gt;One of the first things you learn in vimtutor is to follow links in the vim help files with &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;]&lt;/kbd&gt;. I'm interested in creating my own tags/linking system in arbitrary files. For the sake of this question, let's say I'm creating a sort of TODO list in markdown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose that we have the following minifile:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TODO&#xA;=====&#xA;  1. Learn Vimscript the Hard Way    |hardway|&#xA;&#xA;(some other things, maybe)&#xA;&#xA;&#xA;Complete Learn Vimscript the Hard Way&#xA;-------------------------------------  :hardway&#xA;&#xA;(Some sort of details, etc.)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the goal would be to put the cursor on the first &lt;code&gt;|hardway|&lt;/code&gt;, hit something akin to &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;]&lt;/kbd&gt;, and be transported to the &lt;code&gt;:hardway&lt;/code&gt; tag located elsewhere. Ideally, this could even occur if &lt;code&gt;:hardway&lt;/code&gt; was in a different file (but maybe the same directory).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently use a low-tech alternative. Instead of &lt;code&gt;|hardway|&lt;/code&gt;, I would have something like &lt;code&gt;|hardway.md|&lt;/code&gt;, so that I can &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; on the &quot;tag&quot; and ge taken to the &lt;code&gt;hardway.md&lt;/code&gt; file. While this is manageable, I feel like it should be possible (maybe even not hard) to create and maintain my own tag system on arbitrary filetypes.&lt;/p&gt;&#xA;" OwnerUserId="130" LastEditorUserId="51" LastEditDate="2015-02-04T17:13:37.970" LastActivityDate="2015-02-04T20:11:00.910" Title="Creating tags between markdown files similar to :h" Tags="|filesystem|tags|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="269" PostTypeId="1" AcceptedAnswerId="273" CreationDate="2015-02-04T08:19:44.930" Score="7" ViewCount="324" Body="&lt;p&gt;When I'm editing English text, I need to work with full sentences instead of lines of text in the file. Using the default Vim commands for this kind of text manipulation is very awkward, because I may have to join and split lines redundantly in order to copy a given sentence in the file. As an example, I might want to move sentence two before sentence one in the text below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is sentence&#xA;one. This is sentence&#xA;two. This is sentence&#xA;three.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are there any settings or plugins that will allow me to do this more easily?&lt;/p&gt;&#xA;" OwnerUserId="261" LastActivityDate="2015-02-04T08:40:31.220" Title="Working with English sentences" Tags="|cut-copy-paste|cursor-motions|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="270" PostTypeId="2" ParentId="258" CreationDate="2015-02-04T08:25:49.260" Score="8" Body="&lt;p&gt;This would set the file to be executable after writing to the file if it's not already executable&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.py&#xA;    \  if getfperm(expand('%')) !~# 'x'&#xA;    \|   silent execute &quot;! chmod +x %&quot;&#xA;    \| endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think this should be the better approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make only a new file executable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre *.py&#xA;    \  if !filereadable(expand('%'))&#xA;    \|   let b:is_new = 1&#xA;    \| endif&#xA;autocmd BufWritePost *.py&#xA;    \  if get(b:, 'is_new', 0)&#xA;    \|   silent execute '!chmod +x %'&#xA;    \|   let b:is_new = 0&#xA;    \| endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="74" LastEditorUserId="51" LastEditDate="2019-07-05T10:28:14.373" LastActivityDate="2019-07-05T10:28:14.373" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="271" PostTypeId="5" CreationDate="2015-02-04T08:28:27.433" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Vim_script&quot; rel=&quot;nofollow noreferrer&quot;&gt;VimScript&lt;/a&gt; (also called VimL) is a scripting language embedded into Vim. It can be used to create plugins and customize Vim to suit your needs.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Documentation&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Online Vim Docs &lt;a href=&quot;https://vimhelp.org/usr_41.txt.html#usr_41.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;VimScript language&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Tutorials&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.ibm.com/developerworks/library/l-vim-script-1/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;IBM's Vimscript Tutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the hardway&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://andrewscala.com/vimscript/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Five Minute Vimscript&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="53" LastEditorUserId="14302" LastEditDate="2019-05-06T07:14:21.430" LastActivityDate="2019-05-06T07:14:21.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="272" PostTypeId="4" CreationDate="2015-02-04T08:28:27.433" Score="0" Body="A scripting language embedded into Vim. It can be used to customize Vim to suit your needs and to create plugins. Also called VimL." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-03-14T00:23:30.103" LastActivityDate="2016-03-14T00:23:30.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="273" PostTypeId="2" ParentId="269" CreationDate="2015-02-04T08:33:20.053" Score="9" Body="&lt;p&gt;You already seem to be aware of the 'ap' text-object that represents a paragraph, similar to that there exist 2 text-objects to deal with sentences, 'is' &amp;amp; 'as' for inner sentence &amp;amp; a (or around) sentence. You should use these along with sentence motions '(', ')' for moving them around if need be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg.) For moving sentence two before sentence one. I would use the following key combinations in vim : &lt;code&gt;)das(P&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;)&lt;/code&gt;: helps you move to the beginning of the second sentence.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;das&lt;/code&gt;: deletes the sentence.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(&lt;/code&gt;: Moves back to the beginning of the first sentence (previous sentence to be precise)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt;: Pastes the previously deleted sentence before the current one.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="74" LastEditorUserId="74" LastEditDate="2015-02-04T08:38:39.923" LastActivityDate="2015-02-04T08:38:39.923" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="274" PostTypeId="2" ParentId="269" CreationDate="2015-02-04T08:40:31.220" Score="0" Body="&lt;p&gt;Here's one possibility. Let's say we have textwidth=40 in mind, and we want to play with Lorem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consetetur&#xA;sadipscing elitr, sed diam nonumy eirmod&#xA;tempor invidunt ut labore et dolore&#xA;magna aliquyam erat, sed diam voluptua.&#xA;At vero eos et accusam et justo duo&#xA;dolores et ea rebum. Stet clita kasd&#xA;gubergren, no sea takimata sanctus est&#xA;Lorem ipsum dolor sit amet.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's say we want to move the &lt;code&gt;At vero...&lt;/code&gt; sentence after the &lt;code&gt;Stet clita...&lt;/code&gt; sentence. We might navigate to the &lt;code&gt;At vero...&lt;/code&gt; sentence, use &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;a&#xA;&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt; to delete the sentence. Navigate after the &lt;code&gt;Stet...&lt;/code&gt; sentence, &lt;kbd&gt;p&lt;/kbd&gt; the &lt;code&gt;At vero&lt;/code&gt; sentence after it (perhaps inserting a space if necessary).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This yields&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consetetur&#xA;sadipscing elitr, sed diam nonumy eirmod&#xA;tempor invidunt ut labore et dolore&#xA;magna aliquyam erat, sed diam voluptua.&#xA;Stet clita kasd&#xA;gubergren, no sea takimata sanctus est&#xA;Lorem ipsum dolor sit amet. At vero eos et accusam et justo duo&#xA;dolores et ea rebum. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but we can &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; to reformat the paragraph to the textwidth, yielding&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consetetur&#xA;sadipscing elitr, sed diam nonumy eirmod&#xA;tempor invidunt ut labore et dolore&#xA;magna aliquyam erat, sed diam voluptua.&#xA;Stet clita kasd gubergren, no sea&#xA;takimata sanctus est Lorem ipsum dolor&#xA;sit amet. At vero eos et accusam et&#xA;justo duo dolores et ea rebum. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, vim's &lt;code&gt;gq&lt;/code&gt; is sufficiently capable of doing this with repeated application of &lt;code&gt;gq&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To a certain extent, vim will automatically attempt to format things on the fly if you &lt;code&gt;:set fo=aw2tq&lt;/code&gt;. This is explained in &lt;code&gt;:h formatoptions&lt;/code&gt; and more relevantly &lt;code&gt;:h fo-table&lt;/code&gt;. But in my (limited) experience, it does a mediocre job with the above Lorem ipsum test. But it does very well in handling typing on the fly.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2015-02-04T08:40:31.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="275" PostTypeId="2" ParentId="268" CreationDate="2015-02-04T08:43:14.667" Score="1" Body="&lt;p&gt;VIM's &lt;code&gt;:find&lt;/code&gt; and &lt;code&gt;gf&lt;/code&gt; are quite awesome, I use them all the time, they rely on the vim setting &lt;code&gt;path&lt;/code&gt; and look for files in there. VIM also provides additional setting &lt;code&gt;suffixesadd&lt;/code&gt; which is a list of suffixes find will try to add to the file names and look them up. eg.) &lt;code&gt;set suffixesadd+='.md'&lt;/code&gt; to work with markdown files.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-04T08:43:14.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="276" PostTypeId="1" AcceptedAnswerId="277" CreationDate="2015-02-04T08:57:40.323" Score="26" ViewCount="17167" Body="&lt;p&gt;In some occasions, Vim respond is very slow. Is there a procedure to easily identify what causes the problem?&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2015-02-04T09:08:11.223" Title="How to find what slows down Vim?" Tags="|performance|" AnswerCount="1" CommentCount="6" ClosedDate="2015-02-04T12:08:56.850" ContentLicense="CC BY-SA 3.0" />
  <row Id="277" PostTypeId="2" ParentId="276" CreationDate="2015-02-04T09:08:11.223" Score="46" Body="&lt;p&gt;Vim has a built-in profile set of commands. See &lt;code&gt;:h profile&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would open up vim, and then run the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:profile start profile.log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets up the file &lt;code&gt;profile.log&lt;/code&gt; to be the log file. If it already exists, it will be overwritten. We now need to tell vim what to profile&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:profile func *&#xA;:profile file *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This says to profile all functions and all script files. Overkill, perhaps. Now, you should do things that make vim act slowly. They are being profiled in the background. Once you have concluded, end the profiling.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:profile pause&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And quit vim. Now, read the &lt;code&gt;profile.log&lt;/code&gt; file and see what's slow. Note that this is for slow running inside of vim. If vim is slow to start up (a different problem), you should start vim with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --startuptime log.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and read the times, see what's taking so long.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2015-02-04T09:08:11.223" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="278" PostTypeId="1" AcceptedAnswerId="279" CreationDate="2015-02-04T09:19:00.747" Score="21" ViewCount="665" Body="&lt;p&gt;I was about to answer a question but realized that my answer depends on a key binding provided by a plugin I have installed. Even worse, I don't know which plugin provides it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way I know to solve this problem would be to &quot;binary search&quot; my installed plugins by disabling half and enabling the other half. I use Vundle to manage my plugins so each iteration would only require me to comment out part of a plugin list but that's still a clumsy procedure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to determine which plugin is responsible for a given key binding? Is there a way to determine if a given key binding is instead provided by my &lt;code&gt;vimrc&lt;/code&gt; file directly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize Vim doesn't have a builtin notion of plugins, so maybe the question is more precisely phrased as &quot;How can I determine which file containing vimscript is responsible for a given key binding?&quot;.&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2015-02-04T09:24:50.583" Title="Figure out which plugin is responsible for a key binding" Tags="|key-bindings|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="279" PostTypeId="2" ParentId="278" CreationDate="2015-02-04T09:24:50.583" Score="25" Body="&lt;p&gt;You can use the following: &lt;code&gt;:verbose map &amp;lt;c-p&amp;gt;&lt;/code&gt; replacing &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt; with the key bind you're looking for. Prints something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Last set from ~/.vim/bundle/ctrlp.vim/plugin/ctrlp.vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="248" LastActivityDate="2015-02-04T09:24:50.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="280" PostTypeId="2" ParentId="258" CreationDate="2015-02-04T09:27:36.927" Score="2" Body="&lt;p&gt;I use a different solution for this, with a script I called &lt;code&gt;xvim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;&#xA;vim -p &quot;$@&quot;&#xA;for f in &quot;$@&quot;; do&#xA;    [ -f &quot;$f&quot; ] &amp;amp;&amp;amp; chmod a+x &quot;$f&quot;&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I put this in my &lt;code&gt;~/bin&lt;/code&gt; (make sure this is in your &lt;code&gt;PATH&lt;/code&gt;), and also linked  &lt;code&gt;xvi&lt;/code&gt; to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage of this, is that I explicitly control which files are executable, rather than just assuming that all &lt;code&gt;.*.py&lt;/code&gt; files should be executable (files in modules usually aren't). You also don't need to set it up for all filetypes (&lt;code&gt;*.rb&lt;/code&gt;, &lt;code&gt;*.sh&lt;/code&gt;, etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want &lt;code&gt;xvim&lt;/code&gt; to overwrite existing permissions, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;&#xA;for f in &quot;$@&quot;; do&#xA;    [ -f &quot;$f&quot; ] &amp;amp;&amp;amp; continue&#xA;    touch &quot;$f&quot;&#xA;    chmod a+x &quot;$f&quot;&#xA;done&#xA;vim -p &quot;$@&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this will create the files immediately when you run &lt;code&gt;xvim file&lt;/code&gt; (this is different from &lt;code&gt;vim&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-04T10:07:22.707" LastActivityDate="2015-02-04T10:07:22.707" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="281" PostTypeId="1" AcceptedAnswerId="282" CreationDate="2015-02-04T09:29:24.503" Score="106" ViewCount="63294" Body="&lt;p&gt;How can I figure out which key is set as my &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;, and how do I remap it?&lt;/p&gt;&#xA;" OwnerUserId="176" LastEditorUserId="51" LastEditDate="2015-02-20T22:56:40.267" LastActivityDate="2015-02-20T22:56:40.267" Title="How can I find out what &lt;Leader&gt; is set to? And is it possible to remap &lt;Leader&gt;?" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="282" PostTypeId="2" ParentId="281" CreationDate="2015-02-04T09:34:46.283" Score="106" Body="&lt;p&gt;By default your &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; is &lt;code&gt;\&lt;/code&gt;, backslash. You can check it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo mapleader&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this gives you an &lt;code&gt;E121: Undefined variable: mapleader&lt;/code&gt;, it means it's set to the default of &lt;code&gt;\&lt;/code&gt;. If it gives you something else, then it's that :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can easily remap it. I mapped it to the space-bar:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let mapleader = &quot;\&amp;lt;Space&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the value of &lt;code&gt;mapleader&lt;/code&gt; is used at the moment the mapping is defined. So this example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;,&quot;&#xA;nnoremap &amp;lt;Leader&amp;gt;a :echo &quot;Hey there ,&quot;&amp;lt;CR&amp;gt;&#xA;&#xA;let mapleader = &quot;\&amp;lt;Space&amp;gt;&quot;&#xA;nnoremap &amp;lt;Leader&amp;gt;a :echo &quot;Hey there space&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will produce &lt;em&gt;two&lt;/em&gt; mappings: &lt;code&gt;,a&lt;/code&gt; and &lt;code&gt;&amp;lt;Space&amp;gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that the &lt;em&gt;current&lt;/em&gt; value of &lt;code&gt;mapleader&lt;/code&gt; is not necessarily the value that was used to define your mappings!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, there's the &lt;code&gt;maplocalleader&lt;/code&gt;, which is the same as &lt;code&gt;mapleader&lt;/code&gt;, except that it's used by &lt;code&gt;&amp;lt;LocalLeader&amp;gt;&lt;/code&gt; and that it's local to the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information about &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; can be found in Vim's help with &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#mapleader&quot;&gt;&lt;code&gt;:help mapleader&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="153" LastEditorUserId="51" LastEditDate="2015-02-20T22:48:35.553" LastActivityDate="2015-02-20T22:48:35.553" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="284" PostTypeId="2" ParentId="281" CreationDate="2015-02-04T09:35:20.377" Score="11" Body="&lt;p&gt;You can display the current leader key like this &lt;code&gt;:let mapleader&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="248" LastActivityDate="2015-02-04T09:35:20.377" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="285" PostTypeId="1" CreationDate="2015-02-04T09:58:09.960" Score="17" ViewCount="4343" Body="&lt;p&gt;For a long time now I've been using &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;noreferrer&quot;&gt;Vundle&lt;/a&gt; to manage my vim plugins. As best I can make out this basically just organizes plugins in an isolated directory structure and keeps track of updating them against source URLs where normally the plugin would be manually arranged side by side in the plugins directory.&lt;/p&gt;&#xA;&lt;p&gt;I've run across several references to using the same plugins under multiple plugin managers. &lt;a href=&quot;https://github.com/Shougo/neobundle.vim&quot; rel=&quot;noreferrer&quot;&gt;NeoBundle&lt;/a&gt; for example seems to use the same plugins. However there seem to be a number of other plugin managers out there. Are all of these compatible in the sense that they all use the same source files or do the plugins have to be specially prepared in order to be compatible with each manager? Asked another way, Which other plugin managers are interchangeable enough that they would handle my current Vundle plugins and/or what plugin formats can I assume are Vundle manageable even if they advertise under a different manager?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;" OwnerUserId="267" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-09-29T20:20:32.607" Title="What makes a plugin Vundle compatible and are other plugin managers interchangeable?" Tags="|plugin-system|plugin-managers|plugin-vundle|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="286" PostTypeId="1" AcceptedAnswerId="290" CreationDate="2015-02-04T10:06:14.327" Score="8" ViewCount="4685" Body="&lt;p&gt;When I open another file in a Vim session all editing history for the other files disappears. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to configure Vim that it would automatically save and restore file editing history when hopping through files?&lt;/p&gt;&#xA;" OwnerUserId="147" LastEditorUserId="15" LastEditDate="2018-07-12T13:56:38.623" LastActivityDate="2018-07-13T19:43:39.713" Title="How to cache file editing history in Vim, that it would not disappear after switching the file?" Tags="|undo-redo|persistent-state|command-history|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="287" PostTypeId="1" AcceptedAnswerId="289" CreationDate="2015-02-04T10:07:32.493" Score="77" ViewCount="28103" Body="&lt;p&gt;I have several tasks I am working on in one repository. I would like to create &quot;workspaces&quot; for working on them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One &quot;workspace&quot; or &quot;buffer layout&quot; would have all files I need to work on open in the layout I want (using &lt;code&gt;^w+v&lt;/code&gt;, &lt;code&gt;^w+s&lt;/code&gt; to split window).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, when I start working on another task I would like to save my current layout, move to another one, but I would like to be able to get back to previous layouts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="162" LastEditorUserId="24" LastEditDate="2015-02-19T10:33:02.523" LastActivityDate="2020-03-27T20:17:29.957" Title="How to save window, split, and buffer layout?" Tags="|buffers|persistent-state|vim-windows|sessions|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="288" PostTypeId="2" ParentId="77" CreationDate="2015-02-04T10:14:26.390" Score="26" Body="&lt;p&gt;There are a few lightweight ways to do this.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Check for a file of given name and source it&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if filereadable(&quot;.vimscript_file&quot;)&#xA;    so .vimscript_file&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The file is hidden in the example but that's optional.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Local &lt;code&gt;.vimrc&lt;/code&gt; files&lt;/strong&gt; (not the same as the plugin)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set exrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is similar to 1. but the file will be called &quot;.vimrc&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A common suggestion to accompany this is to use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set secure&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which prevents a &lt;code&gt;.vimrc&lt;/code&gt; file from doing potentially dangerous things like running&#xA;shell commands. The idea is that you wouldn't want to have vim read a &lt;code&gt;.vimrc&lt;/code&gt; file written by someone else that does something nasty.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Autocommands that check the current path&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *path-possibly-using-globbing setlocal setting=value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the option I use. I don't change much between different projects so YMMV but if you just want to do one or two things based on path and keep it in your &lt;code&gt;.vimrc&lt;/code&gt; this is nice and simple.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="268" LastEditorUserId="51" LastEditDate="2015-02-25T09:42:51.587" LastActivityDate="2015-02-25T09:42:51.587" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="289" PostTypeId="2" ParentId="287" CreationDate="2015-02-04T10:16:09.410" Score="72" Body="&lt;p&gt;You can use vim's &lt;code&gt;:mksession&lt;/code&gt; and write each &quot;workspace&quot; to a different file, then reopen a session using &lt;code&gt;vim -S session_file&lt;/code&gt;, however, if you're open to using a plugin then I find the &lt;a href=&quot;https://github.com/mhinz/vim-startify&quot; rel=&quot;noreferrer&quot;&gt;vim-startify&lt;/a&gt; plugin is exactly what I need for this sort of scenario.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does a great job of managing sessions, in vim and mccvim, and it gives you a list of recent files as well when you open vim. It will auto-change to the right working directory for you too. It also lets you &lt;em&gt;pin&lt;/em&gt; files to the startify opening screen as well, which is nice for easy access to things like your &lt;code&gt;.vimrc&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="248" LastEditorUserId="14609" LastEditDate="2020-03-27T20:17:29.957" LastActivityDate="2020-03-27T20:17:29.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="290" PostTypeId="2" ParentId="286" CreationDate="2015-02-04T10:18:38.607" Score="11" Body="&lt;p&gt;What I do is add the following to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set undofile&#xA;set undodir=~/.vim/undo/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way all your undo/change tree information is saved across vim sessions, and next time you open your file you can still undo/redo old edits.&lt;/p&gt;&#xA;" OwnerUserId="248" LastActivityDate="2015-02-04T10:18:38.607" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="291" PostTypeId="2" ParentId="285" CreationDate="2015-02-04T10:25:40.367" Score="3" Body="&lt;p&gt;I probably don't know all plugin managers, but most (including vundle), if not all, build on the plugin system that tpope invented with pathogen. This plugin system basically recreates the folder structure you have in ~/.vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it short. They should be interchangeable.&lt;/p&gt;&#xA;" OwnerUserId="127" LastActivityDate="2015-02-04T10:25:40.367" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="292" PostTypeId="2" ParentId="287" CreationDate="2015-02-04T11:30:51.633" Score="32" Body="&lt;p&gt;You can use tpope's &lt;a href=&quot;https://github.com/tpope/vim-obsession&quot; rel=&quot;noreferrer&quot;&gt;vim-obsession&lt;/a&gt; plugin to easily manage sessions. It is like a wrapper to Vim's in-built &lt;code&gt;mksession&lt;/code&gt;, but provides a set of other niceties as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can save the current session (or buffer layout) by giving the command &lt;code&gt;:Obsession&lt;/code&gt;. If you don't supply an argument, it writes a session file called &lt;code&gt;Session.vim&lt;/code&gt; by default. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To reload a session, either use &lt;code&gt;vim -S &amp;lt;session-name&amp;gt;&lt;/code&gt; or &lt;code&gt;:source &amp;lt;session-name&amp;gt;&lt;/code&gt; if you're inside Vim already. By default, &lt;code&gt;vim -S&lt;/code&gt; with no arguments will read &lt;code&gt;Session.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The nice thing is, you don't have to remember to save the session each time you exit Vim. It is automatically managed by the plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another very important feature of vim-obession is that it does not save options and maps. &lt;code&gt;mksession&lt;/code&gt; captures the current options and maps, which you don't want to happen if you just want to save the buffer layout. Also it interferes when a plugin is updated, etc.&lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="10604" LastEditDate="2020-02-12T02:35:50.600" LastActivityDate="2020-02-12T02:35:50.600" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="293" PostTypeId="2" ParentId="236" CreationDate="2015-02-04T12:10:45.680" Score="1" Body="&lt;p&gt;I recently installed vim-pasta (&lt;a href=&quot;https://github.com/sickill/vim-pasta&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sickill/vim-pasta&lt;/a&gt;), and that seems to improve the indentation of code when I paste. The README also has some good discussion about various code pasting strategies.&lt;/p&gt;&#xA;" OwnerUserId="283" LastActivityDate="2015-02-04T12:10:45.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="294" PostTypeId="1" AcceptedAnswerId="295" CreationDate="2015-02-04T12:45:30.403" Score="0" ViewCount="123" Body="&lt;p&gt;When I use &lt;code&gt;:cd&lt;/code&gt; command in gvim it allows to complete the directories with a simple &lt;code&gt;Tab&lt;/code&gt; press. However with &lt;code&gt;:o&lt;/code&gt; command I only get &lt;code&gt;^I&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I migrate the same bahavior from &lt;code&gt;:cd&lt;/code&gt; to &lt;code&gt;:o&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="245" LastEditorUserId="51" LastEditDate="2015-02-04T15:37:42.287" LastActivityDate="2015-02-04T17:05:48.283" Title="Tab behaviour between :o and :cd" Tags="|autocompletion|tabbed-user-interface|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="295" PostTypeId="2" ParentId="294" CreationDate="2015-02-04T12:54:37.757" Score="5" Body="&lt;p&gt;The &lt;code&gt;:o&lt;/code&gt; command does something completely different, where tabs wouldn't really make sense:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This command is in Vi, but Vim only simulates it:&#xA;&#xA;                                                    *:o* *:op* *:open*&#xA;:[range]o[pen]              Works like |:visual|: end Ex mode.&#xA;                            {Vi: start editing in open mode}&#xA;&#xA;:[range]o[pen] /pattern/    As above, additionally move the cursor to the&#xA;                            column where &quot;pattern&quot; matches in the cursor&#xA;                            line.&#xA;&#xA;Vim does not support open mode, since it's not really useful.  For those&#xA;situations where &quot;:open&quot; would start open mode Vim will leave Ex mode, which&#xA;allows executing the same commands, but updates the whole screen instead of&#xA;only one line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, try pressing &lt;kbd&gt;Q&lt;/kbd&gt; (that is, &lt;kbd&gt;Shift+q&lt;/kbd&gt;). Then type &lt;code&gt;o&lt;/code&gt; in the prompt. You should be back in normal mode. Now insert &quot;This is some text&quot; onto your current line, press &lt;kbd&gt;Q&lt;/kbd&gt; again, and type &lt;code&gt;o /x/&lt;/code&gt;. You should be back in normal mode, with your cursor on the &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:o&lt;/code&gt; with a filename appears to work the same way as &lt;code&gt;:e&lt;/code&gt;. However, I wouldn't rely on this, since it appears to be undocumented.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-04T12:54:37.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="296" PostTypeId="2" ParentId="211" CreationDate="2015-02-04T13:24:32.503" Score="5" Body="&lt;p&gt;Vim also has this nice feature &lt;code&gt;/\%5c[a-z]&lt;/code&gt; which matches &lt;code&gt;[a-z]&lt;/code&gt; only in column 5. You can read about it in more detail in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5c%25c&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h \%c&lt;/code&gt;&lt;/a&gt;. There is also &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5c%25v&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;\%v&lt;/code&gt;&lt;/a&gt; which is to be used for virtual column which is relevant in case of a lot of wrapped lines and it will match the virtual column even for the wrapped lines.&lt;/p&gt;&#xA;" OwnerUserId="74" LastEditorUserId="8" LastEditDate="2015-02-09T00:44:50.893" LastActivityDate="2015-02-09T00:44:50.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="297" PostTypeId="2" ParentId="287" CreationDate="2015-02-04T13:28:04.867" Score="16" Body="&lt;p&gt;As a side note, I'd like to point out that I built yet another plugin &lt;a href=&quot;https://github.com/dhruvasagar/vim-prosession&quot;&gt;dhruvasagar/vim-prosession&lt;/a&gt; as an extension to &lt;a href=&quot;https://github.com/tpope/vim-obsession&quot;&gt;tpope/vim-obsession&lt;/a&gt; that enhances it even further to create &amp;amp; manage vim sessions by default in a centralised repository as per configuration on a per directory basis and loads them automatically when you launch vim without any arguments on the directory. It also allows you to switch between different sessions for convenience.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-04T13:28:04.867" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="298" PostTypeId="1" AcceptedAnswerId="411" CreationDate="2015-02-04T13:41:35.853" Score="19" ViewCount="3070" Body="&lt;p&gt;I often have to edit various XML files with vim, which vary wildly in size - from configuration files containing a few hunded lines to production data files with sizes up to 2GB. Having syntax highlighting enabled is of course a very bad idea when dealing with huge files, thus I want to disable it if the file is bigger than a threshold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could not get this to work using &lt;code&gt;autocommand&lt;/code&gt; directly to disable syntax highlighting, as apparently the command is executed &lt;em&gt;before&lt;/em&gt; syntax is enabled when starting vim from the shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; this autocmd has no effect except for the echo:&#xA;autocmd Filetype xml if getfsize(@%) &amp;gt; 1000000 | echom '!' | syntax off | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found a workaround in that I can disable syntax highlighting globally, then turn it on again for all other filetypes than xml, and turn it on for filetype xml if the file is not bigger than the threshold:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax off&#xA;autocmd Filetype * syntax off&#xA;autocmd Filetype * if &amp;amp;ft != 'xml' | syntax enable | endif&#xA;autocmd Filetype xml if getfsize(@%) &amp;lt; 1000000 | syntax enable | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to work, but feels wrong and will become unmanageable once I want to do this for more filetypes and conditions. Furthermore, it influences all buffers. What is the proper way to disable syntax highlighting in one buffer under specific conditions?&lt;/p&gt;&#xA;" OwnerUserId="117" LastActivityDate="2015-02-05T09:00:15.537" Title="Disable syntax highlighting depending on file size and type" Tags="|syntax-highlighting|autocmd|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="299" PostTypeId="2" ParentId="298" CreationDate="2015-02-04T13:45:37.317" Score="0" Body="&lt;p&gt;This &lt;code&gt;autocmd BufReadPre * if getfsize(expand(&quot;%&quot;)) &amp;gt; 10000000 | syntax off | endif&lt;/code&gt; is what you need.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-04T13:45:37.317" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="300" PostTypeId="1" AcceptedAnswerId="301" CreationDate="2015-02-04T13:47:02.420" Score="146" ViewCount="186437" Body="&lt;p&gt;The primary reason I like vim over emacs is that my hand movement distance away from the home row is very low (even as a programmer). However, the one main time that I do this is leaving insert mode, by pressing Escape.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently learned that I can use Ctrl+C to leave insert mode as well. However, this isn't really an improvement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I exit insert mode without having my hands leave the home row, and without massively impacting what I have the ability to type? Note: I use a mostly vanilla vim with a dvorak keyboard layout, though I'd love to hear solutions for a qwerty layout as well.&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="24" LastEditDate="2015-02-05T07:47:51.780" LastActivityDate="2022-10-29T02:54:54.367" Title="Other ways to exit Insert mode besides Escape" Tags="|key-bindings|insert-mode|keyboard-layout|escape|" AnswerCount="17" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="301" PostTypeId="2" ParentId="300" CreationDate="2015-02-04T13:57:18.527" Score="98" Body="&lt;p&gt;A common binding you'll see is &lt;strong&gt;jj&lt;/strong&gt;, because it works well for QWERTY layouts if you use home row positioning.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap jj &amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In that case, to type a literal &lt;code&gt;jj&lt;/code&gt; - you should wait for 1 sec (by default) between typing the second character. (see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27timeout%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'timeout'&lt;/code&gt;&lt;/a&gt; for details) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;code&gt;c-o&lt;/code&gt; which will take you out of insert, letting you do &lt;strong&gt;one&lt;/strong&gt; normal command, and then put you right back into insert.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Avoid_the_escape_key&quot; rel=&quot;noreferrer&quot;&gt;http://vim.wikia.com/wiki/Avoid_the_escape_key&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="287" LastEditorUserId="287" LastEditDate="2017-05-02T16:43:25.183" LastActivityDate="2017-05-02T16:43:25.183" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="303" PostTypeId="2" ParentId="300" CreationDate="2015-02-04T14:18:54.327" Score="23" Body="&lt;p&gt;&lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; are two native alternatives to &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help i_&amp;lt;esc&amp;gt;&lt;/code&gt; and &lt;code&gt;:help i_ctrl-c&lt;/code&gt; which explains the difference between &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-02-04T15:30:17.483" LastActivityDate="2015-02-04T15:30:17.483" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="304" PostTypeId="2" ParentId="285" CreationDate="2015-02-04T14:36:38.857" Score="12" Body="&lt;p&gt;For a plugin to be Pathogen/Vundle/NeoBundle/Plug/VAM-compatible, it needs to follow the standard structure expected by Vim in your &lt;code&gt;~/.vim/&lt;/code&gt; directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;STANDARD STRUCTURE           PLUGIN STRUCTURE&#xA;&#xA;~/.vim/autoload/...          ~/.vim/bundle/pluginname/autoload/...&#xA;      /doc/...                                       /doc/...&#xA;      /ftplugin/...                                  /ftplugin/...&#xA;      /indent/...                                    /indent/...&#xA;      /plugin/...                                    /plugin/...&#xA;      /syntax/...                                    /syntax/...&#xA;      /...                                           /...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you can recognize that structure (the structure, not that exact list of subdirs) in the plugin's repository or zip file, the plugin is Pathogen/Vundle/NeoBundle/Plug/VAM-compatible.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-02-04T15:45:18.983" LastActivityDate="2015-02-04T15:45:18.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="305" PostTypeId="1" AcceptedAnswerId="306" CreationDate="2015-02-04T14:42:58.840" Score="71" ViewCount="108124" Body="&lt;p&gt;Is it possible to rename the file I'm editing from within Vim? Currently what I do is exit Vim, rename the file and open from Vim again.&lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="24" LastEditDate="2015-02-04T16:57:17.803" LastActivityDate="2020-11-18T16:10:51.800" Title="How can I rename the file I'm editing?" Tags="|save|file-operations|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="306" PostTypeId="2" ParentId="305" CreationDate="2015-02-04T14:50:37.437" Score="70" Body="&lt;p&gt;You could save the file under a different name using &lt;code&gt;:w newname&lt;/code&gt;. But this operation won't remove the old file and the 'old' file stays in your buffer, so any changes will be applied to your 'old' file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:saveas&lt;/code&gt; saves your new file and opens it in a new buffer. But it doesn't delete the old file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;a href=&quot;https://github.com/tpope/vim-eunuch&quot; rel=&quot;noreferrer&quot;&gt;tpope/vim-eunuch&lt;/a&gt; to &lt;code&gt;:Move&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:Move: Rename a buffer and the file on disk simultaneously.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="153" LastEditorUserId="26140" LastEditDate="2020-01-15T01:52:05.997" LastActivityDate="2020-01-15T01:52:05.997" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="307" PostTypeId="2" ParentId="305" CreationDate="2015-02-04T14:52:35.180" Score="12" Body="&lt;p&gt;I've been using the &lt;a href=&quot;https://github.com/vim-scripts/Rename2&quot; rel=&quot;noreferrer&quot;&gt;Rename2 plugin&lt;/a&gt; for this for years. It renames both the current buffer, and the file on disk:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Rename {newname}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: I found this a &lt;code&gt;.vimrc&lt;/code&gt; file on &lt;a href=&quot;https://github.com/garybernhardt/dotfiles/blob/master/.vimrc&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RenameFile()&#xA;    let old_name = expand('%')&#xA;    let new_name = input('New file name: ', expand('%'), 'file')&#xA;    if new_name != '' &amp;amp;&amp;amp; new_name != old_name&#xA;        exec ':saveas ' . new_name&#xA;        exec ':silent !rm ' . old_name&#xA;        redraw!&#xA;    endif&#xA;endfunction&#xA;map &amp;lt;leader&amp;gt;n :call RenameFile()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="248" LastEditorUserId="248" LastEditDate="2015-02-06T18:49:58.663" LastActivityDate="2015-02-06T18:49:58.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="308" PostTypeId="1" CreationDate="2015-02-04T14:54:32.307" Score="9" ViewCount="1281" Body="&lt;p&gt;I'm trying to create a script for performing fuzzy search inside a buffer. The main idea is to take some input, and insert &lt;code&gt;.\{-}&lt;/code&gt; between every pair of characters, e.g. &lt;code&gt;foo&lt;/code&gt; becomes &lt;code&gt;f.\{-}o.\{-}o&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works fairly well, but comes up with a lot of non-ideal matches. I think a fuzzy search should yield the shortest matches first. Consider the following example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void put()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doing a fuzzy search for &lt;code&gt;put&lt;/code&gt; (so, &lt;code&gt;p.\{-}u.\{-}t&lt;/code&gt;) will match the entire string &lt;code&gt;public void put&lt;/code&gt;, but the shorter &lt;code&gt;put&lt;/code&gt; within that match would be more useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The non-greedy operator is good at finding matches that &lt;em&gt;end&lt;/em&gt; earlier, but I need something that can, at the same time, prefer matches that &lt;em&gt;start&lt;/em&gt; later. Conceptually, it should be non-greedy in both directions. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="24" LastEditDate="2015-02-08T17:51:05.247" LastActivityDate="2015-03-27T00:57:12.800" Title="Regex that prefers shorter matches within a match? (This is more involved than non-greedy)" Tags="|vimscript|regular-expression|" AnswerCount="1" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="309" PostTypeId="2" ParentId="300" CreationDate="2015-02-04T15:03:34.530" Score="42" Body="&lt;p&gt;The mappings that I use are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap jk &amp;lt;esc&amp;gt;&#xA;inoremap kj &amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, you can simply hit &lt;kbd&gt;j&lt;/kbd&gt; and &lt;kbd&gt;k&lt;/kbd&gt; at the same time, without having to worry about which one you press first.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-04T15:03:34.530" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="310" PostTypeId="1" AcceptedAnswerId="2197" CreationDate="2015-02-04T15:03:47.650" Score="15" ViewCount="2638" Body="&lt;p&gt;When I open &lt;code&gt;vim&lt;/code&gt; with multiple files (&lt;code&gt;vim f1 f2 ...&lt;/code&gt;), how can I make it open them in tabs directly, without using &lt;code&gt;-p&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking to separate out shell behaviour from vim behaviour, removing &lt;code&gt;vim&lt;/code&gt;-based aliases, etc. That's why I'd prefer not to use aliases, etc. (hence, no &lt;code&gt;-p&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty sure this one has been asked on a few SE sites (such as on &lt;a href=&quot;https://stackoverflow.com/questions/17545610/vim-making-tabbed-behaviour-default&quot;&gt;SO&lt;/a&gt;). However, I'm in no position to judge what would be the best way to do this, so I'm also hoping for a note on why a suggested method is good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the particular SO post linked:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;the accepted answer does &lt;code&gt;tabpagemax=9999&lt;/code&gt;. Call it personal bias, but I see a limit being set to a large number and I think there's something wrong (the way I'd feel if I saw &lt;code&gt;chmod 777&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au VimEnter * set tabpagemax=9999|sil tab ball|set tabpagemax&amp;amp;vim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;the other answer leads to an extra empty tab being opened, while being far more concise.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd VimEnter * argdo tabedit&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm hoping for an answer which doesn't have an extra tab opened and doesn't set a limit to a large value (or explain why that's not a bad thing).&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2021-08-30T20:40:16.147" Title="How do I make opening new tabs the default?" Tags="|tabbed-user-interface|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="312" PostTypeId="2" ParentId="68" CreationDate="2015-02-04T15:24:32.467" Score="11" Body="&lt;p&gt;I would recommend against automatically fixing every word that is marked wrong, for two reasons.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First, you'll get a lot of false positives on things you meant to type, especially in more technical writing.&#xA;You certainly can (and perhaps should) add these two your dictionary so that they're recognized and suggested.&#xA;However, if you don't notice that they're autocorrected, they could slip through to a final version of a document&amp;mdash;or worse, if you're writing code or a configuration file (e.g., changing &lt;code&gt;xmin&lt;/code&gt; to &lt;code&gt;min&lt;/code&gt; would make the graph look totally wrong).&#xA;Comments can also become weird (e.g., I had &quot;Label and nullary instruction&quot; changed to &quot;Label and nullify instruction,&quot; which changes the meaning (a) from a noun phrase to an imperative, and (b) to meaning something completely different.)&lt;/li&gt;&#xA;&lt;li&gt;Second, the autocorrect is pretty poor on short words.&#xA;In my experience, it tends to complete to the closest word, which, with, e.g., three-letter words, can be totally different from what you mean.&#xA;If you mean to type &lt;em&gt;of&lt;/em&gt; but accidentally type &lt;em&gt;fo&lt;/em&gt;, it will be corrected to &lt;em&gt;few&lt;/em&gt;&amp;mdash;not what you wanted!&#xA;Again, these can be hard to catch in cursory revisions.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With that in mind, I think your &lt;em&gt;real&lt;/em&gt; goal is to be able to quickly recognize and fix typographical errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the following mappings to accomplish this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Go back to last misspelled word and pick first suggestion.&#xA;inoremap &amp;lt;C-L&amp;gt; &amp;lt;C-G&amp;gt;u&amp;lt;Esc&amp;gt;[s1z=`]a&amp;lt;C-G&amp;gt;u&#xA;&#xA;&quot; Select last misspelled word (typing will edit).&#xA;nnoremap &amp;lt;C-K&amp;gt; &amp;lt;Esc&amp;gt;[sve&amp;lt;C-G&amp;gt;&#xA;inoremap &amp;lt;C-K&amp;gt; &amp;lt;Esc&amp;gt;[sve&amp;lt;C-G&amp;gt;&#xA;snoremap &amp;lt;C-K&amp;gt; &amp;lt;Esc&amp;gt;b[sviw&amp;lt;C-G&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I'm typing body text, any misspelled words will be underlined, per my highlighting settings.&#xA;If I see that the word is relatively long and it's a simple typo, then I can figure that &lt;code&gt;spell&lt;/code&gt; will probably fix it correctly, so I hit &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; and just keep typing.&#xA;If it's a shorter word or I anticipate that it will get it wrong, I can press &lt;code&gt;&amp;lt;C-K&amp;gt;&lt;/code&gt; and adjust it myself.&#xA;Finally, if &lt;code&gt;spell&lt;/code&gt; unexpectedly corrects to the wrong thing, I've set an undo marker with &lt;code&gt;&amp;lt;C-G&amp;gt;u&lt;/code&gt;, so I can just &lt;code&gt;&amp;lt;Esc&amp;gt;ucW&lt;/code&gt; to change it manually&#xA;This makes for a very quick workflow most of the time.&lt;/p&gt;&#xA;" OwnerUserId="142" LastActivityDate="2015-02-04T15:24:32.467" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="313" PostTypeId="5" CreationDate="2015-02-04T15:45:33.530" Score="0" Body="&lt;p&gt;Inline spell-checking is available in Vim since version 7. It can be turned on with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set spell spelllang=en_us&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;en_us&lt;/code&gt; is the name of the dictionary to use as reference. While it is running, it will highlight words using four different colors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SpellBad    word not recognized                 |hl-SpellBad|&#xA;SpellCap    word not capitalised                |hl-SpellCap|&#xA;SpellRare   rare word                           |hl-SpellRare|&#xA;SpellLocal  wrong spelling for selected region  |hl-SpellLocal|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After moving the cursor on a misspelled word, &lt;code&gt;z=&lt;/code&gt; can be used to get a list of replacement candidates. If the word is highlighted as misspelled, but you still think it is correct, you can add it to the dictionary instead, using &lt;code&gt;zg&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To turn the feature off, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nospell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Full documentation: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/spell.html&quot; rel=&quot;nofollow&quot;&gt;spell vimdoc&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="188" LastEditorUserId="188" LastEditDate="2015-02-23T13:16:02.730" LastActivityDate="2015-02-23T13:16:02.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="314" PostTypeId="4" CreationDate="2015-02-04T15:45:33.530" Score="0" Body="A feature that identifies and highlights misspelled words, and lets you choose among possible correct replacements." OwnerUserId="188" LastEditorUserId="51" LastEditDate="2015-02-24T13:04:17.727" LastActivityDate="2015-02-24T13:04:17.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="315" PostTypeId="5" CreationDate="2015-02-04T15:46:39.673" Score="0" Body="&lt;p&gt;The vimrc file lives in &lt;code&gt;$HOME/.vimrc&lt;/code&gt; or &lt;code&gt;$HOME/.vim/vimrc&lt;/code&gt; on UNIX systems, and  in &lt;code&gt;$HOME/_vimrc&lt;/code&gt; or &lt;code&gt;$HOME/_vimfiles/vimrc&lt;/code&gt; on MS Windows systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;https://github.com/neovim/neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neovim&lt;/a&gt;&lt;/em&gt; uses another configuration file located in &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt;&#xA;or &lt;code&gt;~\AppData\Local\nvim\init.vim&lt;/code&gt;if you're using Windows 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see the currently used vimrc file with the &lt;code&gt;$MYVIMRC&lt;/code&gt; variable, i.e. &lt;code&gt;:echo $MYVIMRC&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many pre-made vimrc files on the internet. Popular ones are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-sensible&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sensible&lt;/a&gt;: &lt;em&gt;Think of sensible.vim as one step above 'nocompatible' mode: a universal set of defaults that (hopefully) everyone can agree on.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/spf13/spf13-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;spf13-vim&lt;/a&gt;: &lt;em&gt;It is a good starting point for anyone intending to use VIM for development&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/carlhuda/janus&quot; rel=&quot;nofollow noreferrer&quot;&gt;Janus&lt;/a&gt;: &lt;em&gt;designed to provide minimal working environment using the most popular plug-ins and the most common mappings&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="12003" LastEditDate="2017-08-23T03:59:01.700" LastActivityDate="2017-08-23T03:59:01.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="316" PostTypeId="4" CreationDate="2015-02-04T15:46:39.673" Score="0" Body="Vim reads initialization commands from a file called vimrc on startup. This can be used to set settings, define functions, execute autocommands, and more." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-06T09:58:34.230" LastActivityDate="2015-02-06T09:58:34.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="317" PostTypeId="1" AcceptedAnswerId="318" CreationDate="2015-02-04T15:48:06.083" Score="29" ViewCount="6404" Body="&lt;p&gt;Some applications have the notion of a &lt;em&gt;&quot;session&quot;&lt;/em&gt;, where you can run a command to load a file in an existing instance of an application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, when I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ firefox http://vi.stackexchange.com&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Firefox re-uses an existing Firefox process, rather than creating a new one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible with Vim?&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="205" LastEditDate="2016-10-09T03:37:04.770" LastActivityDate="2021-01-20T18:26:54.427" Title="Can I open a file in an existing Vim instance from an external command?" Tags="|sessions|clientserver|invocation|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="318" PostTypeId="2" ParentId="317" CreationDate="2015-02-04T15:50:35.950" Score="30" Body="&lt;p&gt;You need vim compiled with &lt;code&gt;+clientserver&lt;/code&gt;, and then you can use the command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim --servername SERVER&lt;/code&gt; to start a vim instance, and &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim --servername SERVER --remote FILE&lt;/code&gt; to open the file in the named vim instance.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;macOS only&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;MacVim runs a server by default - you can use &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;mvim --remote-tab-silent&lt;/code&gt; to open a file in a new tab in your existing MacVim instance, or      &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;mvim --remote-silent&lt;/code&gt; to open the file in a new buffer in the same tab.&lt;/p&gt;&#xA;" OwnerUserId="248" LastEditorUserId="18875" LastEditDate="2020-03-25T17:11:53.997" LastActivityDate="2020-03-25T17:11:53.997" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="319" PostTypeId="1" CreationDate="2015-02-04T15:56:50.990" Score="34" ViewCount="10097" Body="&lt;p&gt;Something I've found useful in other editors is the ability to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;take the selected text&lt;/li&gt;&#xA;&lt;li&gt;run an external command and pass the selection to its &lt;code&gt;stdin&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;take the external commands &lt;code&gt;stdout&lt;/code&gt; and replace the current selection with it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;This way you can write useful text tools which operate on the selection using any language that can do basic io.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can this be done with vim using the selection?&#xA;... a single character, word, paragraph... etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Directly in the command line, or via a key binding?)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Note&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Commands such as &lt;code&gt;!sort&lt;/code&gt; work on the line-level, the reason I'm asking this question is because I would like to operate on the selection. (i.e., the text that would be removed if &lt;code&gt;x&lt;/code&gt; was pressed).&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="301" LastEditDate="2017-01-26T19:13:01.443" LastActivityDate="2020-07-12T17:41:32.787" Title="How to use an external command in Vim to modify selected words and lines?" Tags="|external-command|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="320" PostTypeId="1" AcceptedAnswerId="325" CreationDate="2015-02-04T16:05:33.613" Score="2" ViewCount="1241" Body="&lt;p&gt;What are some of the ways to construct autocommand groups in the .vimrc? What is the benefit of grouping autocommands? Can you provide some materials on proper use of autocommand groups? Any help here is greatly appreciated. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="231" LastActivityDate="2015-02-04T16:42:58.920" Title="Autocommand groups syntax and usage" Tags="|vimscript|autocmd|" AnswerCount="1" CommentCount="0" ClosedDate="2015-02-04T16:57:50.997" ContentLicense="CC BY-SA 3.0" />
  <row Id="321" PostTypeId="2" ParentId="319" CreationDate="2015-02-04T16:05:48.567" Score="29" Body="&lt;p&gt;I find that often the easiest way is to use visual mode with &lt;kbd&gt;v&lt;/kbd&gt; (or capital &lt;kbd&gt;V&lt;/kbd&gt; to select whole lines), and select the text you want to pipe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!cat&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't do anything useful, as such. A useful command I use often is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!python -m json.tool&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to format JSON.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also just type (without visual mode):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:&amp;lt;range&amp;gt;!command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, for the entire file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!python -m json.tool&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or for the current line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.!python -m json.tool&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-22T18:07:03.150" LastActivityDate="2015-02-22T18:07:03.150" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="323" PostTypeId="2" ParentId="305" CreationDate="2015-02-04T16:14:42.447" Score="5" Body="&lt;p&gt;The best way is to use &lt;code&gt;:Move&lt;/code&gt;, as OrangTux said. For completeness, you can also perform terminal commands in vi editors using a bang (&lt;code&gt;!&lt;/code&gt;) in command mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!mv {current_file} {new_name}&#xA;:e {new_name}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this method doesn't remove the old buffer from your buffer list.&lt;/p&gt;&#xA;" OwnerUserId="306" LastEditorUserId="15" LastEditDate="2015-02-04T17:04:29.793" LastActivityDate="2015-02-04T17:04:29.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="324" PostTypeId="1" CreationDate="2015-02-04T16:39:27.480" Score="5" ViewCount="1911" Body="&lt;p&gt;Many answers make reference to a &quot;paste buffer&quot; or a &quot;search buffer&quot;. Can someone provide a quick primer on what types of buffer there are? Are they interchangeable? Or is it something different?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="51" LastEditDate="2015-02-04T16:47:53.553" LastActivityDate="2015-02-04T16:54:55.973" Title="What types of buffers are there?" Tags="|buffers|" AnswerCount="2" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="325" PostTypeId="2" ParentId="320" CreationDate="2015-02-04T16:42:58.920" Score="1" Body="&lt;p&gt;One of the most common uses of autocommands is to allow you to execute commands only on specific filetypes, or to customize a keymapping to execute differently in different filetypes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I could do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetype_ruby&#xA;    autocmd!&#xA;    autocmd FileType ruby nnoremap &amp;lt;buffer&amp;gt; &amp;lt;localleader&amp;gt;t :!rake test&#xA;augroup END&#xA;&#xA;augroup filetype_erlang&#xA;    autocmd!&#xA;    autocmd FileType erlang nnoremap &amp;lt;buffer&amp;gt; &amp;lt;localleader&amp;gt;t :!rebar eunit&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this example does is it maps the &lt;code&gt;&amp;lt;localleader&amp;gt;t&lt;/code&gt; hotkey to running tests through the appropriate build tool - using rake in a ruby project, and rebar in an erlang project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is especially useful for developers making plugins specific to a certain programming language, like vim-ruby or any of &lt;a href=&quot;https://github.com/tpope&quot; rel=&quot;nofollow&quot;&gt;tpope's&lt;/a&gt; ruby plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other events you can use besides FileType - there's:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;BufWrite (when a buffer is written)&lt;/li&gt;&#xA;&lt;li&gt;FileAppendCmd ( when a file is appended to)&lt;/li&gt;&#xA;&lt;li&gt;FileAppendPost&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and many others. Basically, if you want vim to execute specific commands when these events are fired, augroups are the way to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some good references for reading and learning:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/14.html&quot; rel=&quot;nofollow&quot;&gt;Learn VimScript the hard way&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html&quot; rel=&quot;nofollow&quot;&gt;Vim Documentation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;:h autocmd-groups&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="306" LastActivityDate="2015-02-04T16:42:58.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="326" PostTypeId="2" ParentId="324" CreationDate="2015-02-04T16:44:53.297" Score="6" Body="&lt;p&gt;From the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#windows-intro&quot; rel=&quot;noreferrer&quot;&gt;vim help&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Summary:&#xA;   A buffer is the in-memory text of a file.&#xA;   A window is a viewport on a buffer.&#xA;   A tab page is a collection of windows.&#xA;&#xA;A window is a viewport onto a buffer.  You can use multiple windows on one&#xA;buffer, or several windows on different buffers.&#xA;&#xA;A buffer is a file loaded into memory for editing.  The original file remains&#xA;unchanged until you write the buffer to the file.&#xA;&#xA;A buffer can be in one of three states:&#xA;&#xA;                            *active-buffer*&#xA;active:   The buffer is displayed in a window.  If there is a file for this&#xA;      buffer, it has been read into the buffer.  The buffer may have been&#xA;      modified since then and thus be different from the file.&#xA;                            *hidden-buffer*&#xA;hidden:   The buffer is not displayed.  If there is a file for this buffer, it&#xA;      has been read into the buffer.  Otherwise it's the same as an active&#xA;      buffer, you just can't see it.&#xA;                            *inactive-buffer*&#xA;inactive: The buffer is not displayed and does not contain anything.  Options&#xA;      for the buffer are remembered if the file was once loaded.  It can&#xA;      contain marks from the |viminfo| file.  But the buffer doesn't&#xA;      contain text.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can access this with the command &lt;code&gt;:h window&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get a list of your current buffers with &lt;code&gt;:buffers&lt;/code&gt; or &lt;code&gt;:ls&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can search through all your current buffers with the command &lt;code&gt;:bufdo&lt;/code&gt; which executes a command in all open buffers like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo %s/pattern/replace/ge | update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="226" LastEditorUserId="226" LastEditDate="2015-02-04T16:51:57.493" LastActivityDate="2015-02-04T16:51:57.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="327" PostTypeId="2" ParentId="324" CreationDate="2015-02-04T16:54:55.973" Score="7" Body="&lt;p&gt;Those posts are incorrectly using the term &lt;code&gt;buffer&lt;/code&gt; when they mean &lt;code&gt;register&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As aharris88's answer shows, a buffer typically represents a file that is currently being edited.  There are buffers that don't represent a file, but the common case is the representation of a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#registers&quot; rel=&quot;noreferrer&quot;&gt;Registers&lt;/a&gt;, on the other hand, hold pieces of data for later use.  An example that most people use on a frequent basis is the unnamed register (&lt;code&gt;&quot;&lt;/code&gt;).  This is the register that, by default, stores the last yank or delete and is the register used, by default, when pasting.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-02-04T16:54:55.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="328" PostTypeId="1" AcceptedAnswerId="348" CreationDate="2015-02-04T17:03:27.667" Score="19" ViewCount="1034" Body="&lt;p&gt;I want to have a quick way of setting the Vim &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;paste&amp;#39;&quot;&gt;&lt;code&gt;'paste'&lt;/code&gt;&lt;/a&gt; option, inserting some text, and reverting to the previous value of &lt;code&gt;'paste'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A typical use case insert the OS clipboard content literally, regardless of any insert mode rewriting that may be active, such as automatic indentation, and without changing the state of Vim. Another use case would be to allow an OS macro feature to inject keystrokes into Vim and have them interpreted as literal text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This obviously generalizes to other options — the general idea is to set some options but only for the duration of one trip through insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I want to bind a key sequence (say &lt;code&gt;_i&lt;/code&gt;) to a macro that does this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set paste&#xA;i…&amp;lt;Esc&amp;gt;&#xA;:set nopaste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where by &lt;code&gt;i…&amp;lt;Esc&amp;gt;&lt;/code&gt; I mean switch to insert mode (as with the &lt;code&gt;i&lt;/code&gt; command) and resume the macro upon return to command mode, except that I want to end up with the &lt;code&gt;'paste'&lt;/code&gt; still active if it was active beforehand. How can I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&#xA;Note: The content of the OS clipboard is mapped to the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/gui.html#clipboard&quot;&gt;&lt;code&gt;&quot;*&lt;/code&gt; register&lt;/a&gt;. When that works, the &lt;code&gt;'paste'&lt;/code&gt; option isn't very useful. The motivating scenario for this question is for those times when the conditions for &lt;code&gt;&quot;*&lt;/code&gt; register support are not met — Vim isn't compiled with the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/various.html#+xterm_clipboard&quot;&gt;&lt;code&gt;+xterm_clipboard&lt;/code&gt;&lt;/a&gt; feature, or it's running in a terminal such as Screen or over SSH which isolates it from the ambient X server.&#xA;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2015-02-05T00:03:59.653" LastActivityDate="2019-07-18T07:07:14.810" Title="Set the paste option, but for one insertion only" Tags="|vimscript|insert-mode|options|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="329" PostTypeId="2" ParentId="294" CreationDate="2015-02-04T17:05:48.283" Score="1" Body="&lt;p&gt;Vim only includes the &lt;code&gt;:o[pen]&lt;/code&gt; command for legacy reasons.  The command you're looking for is &lt;code&gt;:e[dit]&lt;/code&gt;, which has all the completion behavior you would expect.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-02-04T17:05:48.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="330" PostTypeId="1" AcceptedAnswerId="333" CreationDate="2015-02-04T17:13:33.533" Score="0" ViewCount="2228" Body="&lt;p&gt;In various editors one can mark a block of code and with a shortcut, comment it right away. Is there a possible way to do it in Vim without an extra plugin? If not, which plugin or script would you suggest?&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="51" LastEditDate="2015-02-04T21:02:09.843" LastActivityDate="2015-02-04T21:02:09.843" Title="How can I comment code with a command in Vim" Tags="|ide|" AnswerCount="2" CommentCount="0" ClosedDate="2015-02-04T19:56:39.647" ContentLicense="CC BY-SA 3.0" />
  <row Id="331" PostTypeId="2" ParentId="328" CreationDate="2015-02-04T17:19:27.767" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;except that I want to end up with the &lt;code&gt;'paste'&lt;/code&gt; still active if it was active beforehand.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'paste'&lt;/code&gt; should be active for as short a time as possible.  It disables a lot of functionality (including maps), because its sole purpose is to avoid misinterpreting text that is being pasted.  As such, I think the quoted requirement shouldn't really be necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, it's actually quite easy to paste without needing to set &lt;code&gt;'paste'&lt;/code&gt;.  If you're running gvim or have &lt;code&gt;+xterm_clipboard&lt;/code&gt; in console vim, then you can simply use &lt;code&gt;&quot;+p&lt;/code&gt; to paste from the OS clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem of automatic indentation while paste only really happens in two scenarios.  Inserting the contents of a register while in insert mode (&lt;code&gt;&amp;lt;C-r&amp;gt;+&lt;/code&gt;) or middle-click pasting with the mouse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of inserting the contents of a register while in insert mode, pasting from the register in normal mode will avoid the reformatting issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to middle-click paste with the mouse, then use the &lt;code&gt;'mouse'&lt;/code&gt; option to let Vim, instead of the terminal, handle the middle-click.  Vim will then insert the contents literally instead of interpreting the incoming text as being typed.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-02-04T17:19:27.767" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="332" PostTypeId="1" CreationDate="2015-02-04T17:24:04.857" Score="10" ViewCount="6002" Body="&lt;p&gt;If I'm using a build of Vim with the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/various.html#+xterm_clipboard&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;xterm_clipboard&lt;/code&gt;&lt;/a&gt; feature then the system &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/gui.html#clipboard&quot; rel=&quot;noreferrer&quot;&gt;clipboard&lt;/a&gt; content is available through the &lt;code&gt;+&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the build I'm using doesn't have this feature, can I make the &lt;code&gt;&quot;+&lt;/code&gt; register call my custom programs to retrieve and set the system clipboard (&lt;a href=&quot;http://www.vergenet.net/~conrad/software/xsel/&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;xsel -bo&lt;/code&gt;&lt;/a&gt; and &lt;code&gt;xsel -bi&lt;/code&gt;, or likewise with &lt;a href=&quot;http://sourceforge.net/projects/xclip/&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;xclip&lt;/code&gt;&lt;/a&gt;)? Likewise with &lt;code&gt;&quot;*&lt;/code&gt; to call &lt;code&gt;xsel -po&lt;/code&gt; and &lt;code&gt;xsel -pi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point is to be able to type something like &lt;code&gt;&quot;+p&lt;/code&gt; without having to worry whether the feature is available. Typing &lt;code&gt;:r !xsel -b&amp;lt;Enter&amp;gt;&lt;/code&gt; is not what I'm looking for: I want the same keystrokes to work, and I want the paste variants to follow what's available for “true” registers (&lt;code&gt;P&lt;/code&gt;, &lt;code&gt;gp&lt;/code&gt;, …).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus: can I define custom commands for other register names?&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="24" LastEditDate="2015-02-04T19:18:26.923" LastActivityDate="2015-02-04T19:18:26.923" Title="Define custom commands for the * and + registers" Tags="|register|os-clipboard|x11|external-command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="333" PostTypeId="2" ParentId="330" CreationDate="2015-02-04T17:42:43.037" Score="2" Body="&lt;p&gt;The best way that I found is using &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow&quot;&gt;tpope's vim-commentary plugin&lt;/a&gt;. You're able to use the &lt;code&gt;ctrl+v I#&lt;/code&gt; mentioned in the question linked to in the comment to the OP, but this will automatically work with different comment types with different languages.&lt;/p&gt;&#xA;" OwnerUserId="306" LastActivityDate="2015-02-04T17:42:43.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="334" PostTypeId="2" ParentId="330" CreationDate="2015-02-04T17:45:17.637" Score="0" Body="&lt;p&gt;From my answer &lt;a href=&quot;https://vi.stackexchange.com/a/154/153&quot;&gt;over here&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I use &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;scrooloose/nerdcommenter&lt;/a&gt; for this.&lt;/p&gt;&#xA;&lt;p&gt;With this plugin you can visual select your lines and hit&#xA;&lt;kbd&gt;leader&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt; to toggle comments. Depending on the&#xA;file type it will use different symbols for commenting.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="153" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-02-04T17:45:17.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="335" PostTypeId="2" ParentId="332" CreationDate="2015-02-04T17:52:22.110" Score="8" Body="&lt;p&gt;A few &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping should be able to do the job here.  The basic structure would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ClipboardOrXclip(command, register)&#xA;    if a:register !~ '[+*]' || has('xterm_clipboard') || has('gui_running')&#xA;        &quot; Just return the original command if the clipboard is accessible&#xA;        &quot; or it's not a register that should be handled by xsel&#xA;        return a:command&#xA;    endif&#xA;    if a:register == '+'&#xA;        return &quot;&amp;lt;Esc&amp;gt;:r !xsel -bo&amp;lt;CR&amp;gt;&quot;&#xA;    else&#xA;        return &quot;&amp;lt;Esc&amp;gt;:r !xsel -po&amp;lt;CR&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; p ClipboardOrXclip('p', v:register)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function would need to be expanded to handle all the variations of &lt;code&gt;p&lt;/code&gt;, &lt;code&gt;P&lt;/code&gt;, &lt;code&gt;gp&lt;/code&gt;, etc. but this should be a good start.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2015-02-04T18:45:18.047" LastActivityDate="2015-02-04T18:45:18.047" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="336" PostTypeId="5" CreationDate="2015-02-04T18:15:22.500" Score="0" Body="&lt;p&gt;Plugins can be used to extend and customize Vim's functionality to a considerable extent. The following posts provide an introduction to the plugin system:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vi.stackexchange.com/questions/619/what-is-a-vim-plugin&quot;&gt;What is a Vim plugin?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vi.stackexchange.com/questions/613/how-to-install-a-plugin-in-vim-vi&quot;&gt;How do I install a plugin in vim/vi?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vi.stackexchange.com/questions/285/what-makes-a-plugin-vundle-compatible-and-are-other-plugin-managers-interchangea&quot;&gt;What makes a plugin Vundle compatible and are other plugin managers interchangeable?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-package-managers&quot;&gt;What is the difference between the vim package managers?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;/questions/tagged/plugin-system&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;plugin-system&amp;#39;&quot; rel=&quot;tag&quot;&gt;plugin-system&lt;/a&gt; tag should be used for questions about the plugin system in general, and NOT for specific plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Common terms:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vimball - a packaged form of a plugin.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/&quot; rel=&quot;nofollow&quot;&gt;Vim Scripts&lt;/a&gt; - a repository for many Vim plugins.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="51" LastEditDate="2015-04-30T11:54:06.250" LastActivityDate="2015-04-30T11:54:06.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="337" PostTypeId="4" CreationDate="2015-02-04T18:15:22.500" Score="0" Body="For questions about Vim's plugin system. NOT for questions about a specific plugin (use the appropriate plugin-* tag) or questions that may require a plugin." OwnerUserId="51" LastEditorUserId="25" LastEditDate="2021-06-23T23:37:38.280" LastActivityDate="2021-06-23T23:37:38.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="338" PostTypeId="1" CreationDate="2015-02-04T18:19:47.710" Score="8" ViewCount="3305" Body="&lt;p&gt;I've heard rumours about Vim having some hidden &quot;easter eggs&quot; and jokes. Is this true? What are they?&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-05T20:59:54.230" Title="Does Vim have any hidden &quot;easter eggs&quot; or jokes? If so, which?" Tags="|help-system|undocumented-behaviour|" AnswerCount="7" CommentCount="0" ClosedDate="2015-02-05T21:57:10.953" ContentLicense="CC BY-SA 3.0" />
  <row Id="340" PostTypeId="1" CreationDate="2015-02-04T18:35:28.823" Score="13" ViewCount="3799" Body="&lt;p&gt;I just noticed that my trackpad scroll works in Vim, inertia and all. I'd like to change this to work horizontally - so I can scroll up and down to make the cursor move left-and-right instead of holding down the right arrow key for huge amounts of time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I map my scrolling to left/right movement?&lt;/p&gt;&#xA;" OwnerDisplayName="user2" LastEditorUserId="51" LastEditDate="2015-02-04T18:37:20.953" LastActivityDate="2017-09-20T20:22:18.003" Title="How can I use my trackpad for horizontal scrolling?" Tags="|scrolling|mouse|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="341" PostTypeId="1" AcceptedAnswerId="346" CreationDate="2015-02-04T18:42:20.247" Score="24" ViewCount="6510" Body="&lt;p&gt;On some unixes sometime I found a command named &lt;code&gt;nvi&lt;/code&gt;. It was a vi-like editor, without much of its functionality. Maybe it was a fork of the old &lt;code&gt;vi&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, which &lt;code&gt;vi&lt;/code&gt; versions are a fork of the others, and which are independent developments? Do they have a &quot;family tree&quot;, similar to the unixes?&lt;/p&gt;&#xA;" OwnerUserId="28" LastEditorUserId="205" LastEditDate="2016-03-30T20:52:24.643" LastActivityDate="2022-07-01T14:31:36.433" Title="What is the relation between vi, nvi and vim?" Tags="|history-of|original-vi|nvi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="342" PostTypeId="1" CreationDate="2015-02-04T18:47:59.287" Score="10" ViewCount="720" Body="&lt;p&gt;Is it possible to edit a file under different settings at the same time? More precisely, I'd like to have multiple buffers in the same instance of Vim which have the same content (changing one buffer affects the other buffer's content immediately), but different cursor positions, different marks, different syntax highlighting, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Common use cases include editing different parts of the same file independently (without e.g. entering visual mode in one instance break the current visual mode selection in the other instance), and editing mixed-format files (e.g. HTML and Javascript) without having to switch settings. (An alternate approach for the second use case would be to change settings automatically based on the cursor position but that's out of scope for this question.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An editor whose mention admittedly could shock calls this “indirect buffers”.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2015-02-04T19:00:20.290" LastActivityDate="2015-02-04T19:35:59.527" Title="Multiple buffers, same file, different settings" Tags="|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="343" PostTypeId="1" AcceptedAnswerId="345" CreationDate="2015-02-04T18:56:02.653" Score="116" ViewCount="140356" Body="&lt;p&gt;Is there a way to edit binary files in some kind of hexadecimal mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example if I have some binary data shown by &lt;code&gt;xxd&lt;/code&gt; or &lt;code&gt;hexdump -C&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ hexdump -C a.bin | head -n 5&#xA;00000000  cf fa ed fe 07 00 00 01  03 00 00 80 02 00 00 00  |................|&#xA;00000010  12 00 00 00 40 05 00 00  85 00 20 00 00 00 00 00  |....@..... .....|&#xA;00000020  19 00 00 00 48 00 00 00  5f 5f 50 41 47 45 5a 45  |....H...__PAGEZE|&#xA;00000030  52 4f 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |RO..............|&#xA;00000040  00 00 00 00 01 00 00 00  00 00 00 00 00 00 00 00  |................|&#xA;&#xA;$ xxd a.bin | head -n 5&#xA;0000000: cffa edfe 0700 0001 0300 0080 0200 0000  ................&#xA;0000010: 1200 0000 4005 0000 8500 2000 0000 0000  ....@..... .....&#xA;0000020: 1900 0000 4800 0000 5f5f 5041 4745 5a45  ....H...__PAGEZE&#xA;0000030: 524f 0000 0000 0000 0000 0000 0000 0000  RO..............&#xA;0000040: 0000 0000 0100 0000 0000 0000 0000 0000  ................&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I want to change the value at a specific position,&#xA;this kind of view will help finding the right place,&#xA;for example when the position to change is near some known string.&lt;/p&gt;&#xA;" OwnerUserId="135" LastEditorUserId="48490" LastEditDate="2023-09-01T06:26:44.593" LastActivityDate="2023-11-06T16:11:15.153" Title="How to edit binary files with Vim?" Tags="|vimscript|filetype|binary-file|xxd|" AnswerCount="8" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="344" PostTypeId="2" ParentId="343" CreationDate="2015-02-04T18:56:17.717" Score="32" Body="&lt;p&gt;To view the content of a binary file in a hex view,&#xA;open the file, switch on binary mode, and filter the buffer through the &lt;code&gt;xxd&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set binary&#xA;:%!xxd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can make changes in the left area (edit the hex numbers),&#xA;and when ready, filter through &lt;code&gt;xxd -r&lt;/code&gt;, and finally save the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!xxd -r&#xA;:w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the filtering step after opening and before closing sounds tedious,&#xA;and you often do this with files with &lt;code&gt;.bin&lt;/code&gt; extension,&#xA;you can add this to your vimrc to make the process automatic:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; for hex editing&#xA;augroup Binary&#xA;  au!&#xA;  au BufReadPre  *.bin let &amp;amp;bin=1&#xA;  au BufReadPost *.bin if &amp;amp;bin | %!xxd&#xA;  au BufReadPost *.bin set ft=xxd | endif&#xA;  au BufWritePre *.bin if &amp;amp;bin | %!xxd -r&#xA;  au BufWritePre *.bin endif&#xA;  au BufWritePost *.bin if &amp;amp;bin | %!xxd&#xA;  au BufWritePost *.bin set nomod | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="135" LastEditorUserId="135" LastEditDate="2015-02-04T21:37:40.290" LastActivityDate="2015-02-04T21:37:40.290" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="345" PostTypeId="2" ParentId="343" CreationDate="2015-02-04T18:58:07.273" Score="124" Body="&lt;p&gt;The simplest way is to use the &lt;code&gt;binary&lt;/code&gt; option. From &lt;code&gt;:help binary&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This option should be set before editing a binary file.  You can also&#xA;use the -b Vim argument.  When this option is switched on a few&#xA;options will be changed (also when it already was on):&#xA;        'textwidth'  will be set to 0&#xA;        'wrapmargin' will be set to 0&#xA;        'modeline'   will be off&#xA;        'expandtab'  will be off&#xA;Also, 'fileformat' and 'fileformats' options will not be used, the&#xA;file is read and written like 'fileformat' was &quot;unix&quot; (a single &amp;lt;NL&amp;gt;&#xA;separates lines).&#xA;The 'fileencoding' and 'fileencodings' options will not be used, the&#xA;file is read without conversion.&#xA;&#xA;[..]&#xA;&#xA;When writing a file the &amp;lt;EOL&amp;gt; for the last line is only written if&#xA;there was one in the original file (normally Vim appends an &amp;lt;EOL&amp;gt; to&#xA;the last line if there is none; this would make the file longer).  See&#xA;the 'endofline' option.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't do this, and your environment is using a multibyte encoding (e.g.&#xA;UTF-8, as most people use), Vim tries to encode the text as such, usually&#xA;leading to file corruption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can verify this by opening a file, and just using &lt;code&gt;:w&lt;/code&gt;. It is now&#xA;changed.&lt;br&gt;&#xA;If you set &lt;code&gt;LANG&lt;/code&gt; and &lt;code&gt;LC_ALL&lt;/code&gt; to &lt;code&gt;C&lt;/code&gt; (ASCII), Vim doesn't convert anything and&#xA;the files stay the same (it still adds a newline, though) since Vim won't need&#xA;to do any multibyte encoding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally also prefer to &lt;em&gt;disable&lt;/em&gt; &lt;code&gt;set wrap&lt;/code&gt; for binary, although others&#xA;might prefer to &lt;em&gt;enable&lt;/em&gt; it. YMMV.&#xA;Another useful thing to do is &lt;code&gt;:set display=uhex&lt;/code&gt;. From &lt;code&gt;:help 'display'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uhex            Show unprintable characters hexadecimal as &amp;lt;xx&amp;gt;&#xA;                instead of using ^C and ~C.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And as a last tip, you can show the hex value of the character under the cursor&#xA;in the ruler with &lt;code&gt;%B&lt;/code&gt; (&lt;code&gt;:set rulerformat=0x%B&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;More advanced: &lt;code&gt;xxd&lt;/code&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;code&gt;xxd(1)&lt;/code&gt; tool to convert a file to more readable format, and&#xA;(this is the important bit), parse the edited &quot;readable format&quot; and write it&#xA;back as binary data. &lt;code&gt;xxd&lt;/code&gt; is part of &lt;code&gt;vim&lt;/code&gt;, so if you have &lt;code&gt;vim&lt;/code&gt; installed you&#xA;should also have &lt;code&gt;xxd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ xxd /bin/ls | vi -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you've already opened the file, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!xxd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now make your changes, you need to do that on the left-hand side of the display&#xA;(the hex numbers), changes to the right-hand side (printable representation) are&#xA;ignored on write.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To save it, use &lt;code&gt;xxd -r&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!xxd -r &amp;gt; new-ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will save the file to &lt;code&gt;new-ls&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or to load the binary in the current buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!xxd -r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;xxd(1)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   -r | -revert&#xA;          reverse operation: convert (or patch) hexdump into  binary.   If&#xA;          not  writing  to stdout, xxd writes into its output file without&#xA;          truncating it. Use the combination -r -p to read plain hexadeci‐&#xA;          mal dumps without line number information and without a particu‐&#xA;          lar column layout. Additional  Whitespace  and  line-breaks  are&#xA;          allowed anywhere.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then just use &lt;code&gt;:w&lt;/code&gt; to write it. (&lt;strong&gt;beware&lt;/strong&gt;: you want to set the &lt;code&gt;binary&lt;/code&gt;&#xA;option before you write to the file, for the same reasons outline above).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Complementary keybinds to make this a bit easier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Hex read&#xA;nmap &amp;lt;Leader&amp;gt;hr :%!xxd&amp;lt;CR&amp;gt; :set filetype=xxd&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Hex write&#xA;nmap &amp;lt;Leader&amp;gt;hw :%!xxd -r&amp;lt;CR&amp;gt; :set binary&amp;lt;CR&amp;gt; :set filetype=&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is also available from the menu if you're using gVim, under 'Tools ➙&#xA;Convert to HEX' and 'Tools ➙ Convert back'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vim.wikia.com/wiki/VimTip1518&quot; rel=&quot;noreferrer&quot;&gt;vim tips wiki&lt;/a&gt; has a page with more&#xA;information and some helper scripts. Personally, I think you're probably better&#xA;off using a real hex editor if you're editing binary files that often. Vim &lt;em&gt;can&lt;/em&gt;&#xA;sort of do the job, but it's obviously not designed for it, and if you ever&#xA;write without &lt;code&gt;:set binary&lt;/code&gt; Vim might destroy your binary files!&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-01-10T01:56:49.500" LastActivityDate="2019-01-10T01:56:49.500" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="346" PostTypeId="2" ParentId="341" CreationDate="2015-02-04T19:13:58.740" Score="29" Body="&lt;p&gt;From &lt;code&gt;nvi(1)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HISTORY&#xA;    The ex editor first appeared in 1BSD.  The nex/nvi replacements for the&#xA;    ex/vi editor first appeared in 4.4BSD.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some background, from memory, so I hope got the details correct:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the beginning, UNIX was free. Everyone could request a copy from Ken, and he&#xA;would send you a tape with the source (allegedly with the text &quot;love, Ken&quot; on&#xA;them). The terms &quot;free software&quot; or &quot;open source&quot; didn't exist yet, but for all&#xA;intents and purposes it was &quot;open source&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason for this was because UNIX was developed at Bell labs. Bell labs&#xA;is part of AT&amp;amp;T which, at the time, had an effective monopoly on telephony. As&#xA;part of an agreement with the U.S. government, it was agreed that AT&amp;amp;T was &lt;em&gt;not&lt;/em&gt;&#xA;allowed to enter other fields of businesses (such as computers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Somewhere along the way this changed, and UNIX became proprietary software. As a&#xA;result, BSD (which stems from UNIX) &lt;em&gt;also&lt;/em&gt; became proprietary software. &lt;code&gt;vi&lt;/code&gt; was&#xA;written as part of BSD, so it also became proprietary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is why in the late '80s to early '90s some &quot;vi clones&quot; appeared, such as &lt;code&gt;stevie&lt;/code&gt; (later the basis for &lt;code&gt;vim&lt;/code&gt;) and &lt;code&gt;nvi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the early '90s, people wanted a free BSD system, so &lt;code&gt;nvi&lt;/code&gt; was created for&#xA;4.4BSD-lite (lite meaning, not encumbered by AT&amp;amp;T code), so &lt;code&gt;nvi&lt;/code&gt; was created as&#xA;a &quot;bug-for-bug compatible&quot; replacement for the encumbered &lt;code&gt;vi&lt;/code&gt;. It has all of the &lt;code&gt;vi&lt;/code&gt; features, but not the more advanced features you might find in &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FreeBSD &amp;amp; NetBSD both descend from 4.4BSD-Lite (and OpenBSD &amp;amp; DragonflyBSD&#xA;descend from NetBSD and FreeBSD, respectively), which is why they ship with&#xA;&lt;code&gt;nvi&lt;/code&gt; installed by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unlike Linux, BSD systems have a single &quot;base&quot; system of which &lt;code&gt;nvi&lt;/code&gt; is part&#xA;of, so there are &lt;em&gt;really&lt;/em&gt; 4+ versions of &lt;code&gt;nvi&lt;/code&gt;. But in reality the changes are&#xA;small to non-existent, the BSD projects exchange code, so most bugfixes and&#xA;enhancements are shared (but perhaps not all?). I believe FreeBSD added multibyte support a few years ago, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;vim&lt;/code&gt; story is more boring: Bram was running on Amiga, wanted to run &lt;code&gt;vi&lt;/code&gt;, but couldn't find a &lt;code&gt;vi&lt;/code&gt; for Amiga. So he took the &lt;code&gt;stevie&lt;/code&gt; code, ported it to Amiga, and continued to improved it further. This is why you can still find many Amiga-related notes in the docs even today.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the meanwhile, UNIX is &quot;free&quot; once more, and you can run&#xA;&lt;a href=&quot;http://ex-vi.cvs.sourceforge.net/&quot;&gt;original &lt;code&gt;vi&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-03-30T21:12:27.067" LastActivityDate="2016-03-30T21:12:27.067" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="347" PostTypeId="2" ParentId="342" CreationDate="2015-02-04T19:35:59.527" Score="3" Body="&lt;p&gt;Using multiple windows to view the same buffer allows you to view, edit, select, ... on different parts of a buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Syntax highlighting is a more complicated matter, depending on what exactly you want.  Vim already supports highlighting different parts of a buffer with different syntax.  For example, if you have an html filetype buffer, then &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tags will be highlighted as CSS, &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags will be highlighted as javascript, etc.  This is done by using the &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-include&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:syn include&lt;/code&gt;&lt;/a&gt; command and then defining the relevant syntax regions that the syntax should be applied to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative is to use the &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Aownsyntax&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:ownsyntax&lt;/code&gt;&lt;/a&gt; command to specify the syntax highlighting that is used for a specific window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Marks are the sticky point.  The lowercase marks are specific to a buffer and the uppercase marks are global, but there aren't any window-specific marks.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-02-04T19:35:59.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="348" PostTypeId="2" ParentId="328" CreationDate="2015-02-04T19:36:02.277" Score="15" Body="&lt;p&gt;Give this a try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Paste_Func()&#xA;    let s:inPaste = &amp;amp;paste&#xA;    if !s:inPaste&#xA;        set paste&#xA;    endif&#xA;&#xA;    echom s:inPaste&#xA;    augroup paste_callback&#xA;        autocmd!&#xA;        autocmd InsertLeave &amp;lt;buffer&amp;gt; call Paste_End()&#xA;    augroup END&#xA;&#xA;    startinsert&#xA;endfunction&#xA;&#xA;function! Paste_End()&#xA;    augroup paste_callback&#xA;        autocmd!&#xA;    augroup END&#xA;    augroup! paste_callback&#xA;&#xA;    if !s:inPaste&#xA;        set nopaste&#xA;    endif&#xA;endfunction&#xA;&#xA;map _i :call Paste_Func()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It stores your current paste status in the inPaste variable and sets paste if it isn't already set. Then it sets up an autocmd for when you leave insert mode, and then puts you in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you leave insert mode it runs the autocmd, which first removes the autocmd (so it doesn't get run when you leave insert mode any other way), and finally sets nopaste if you were not in paste mode originally. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you are using vim in a terminal, you may want to take a look at &lt;a href=&quot;https://github.com/ConradIrwin/vim-bracketed-paste&quot;&gt;vim-bracketed-paste&lt;/a&gt;, which uses the &lt;a href=&quot;http://cirw.in/blog/bracketed-paste&quot;&gt;bracketed paste mode&lt;/a&gt; feature provided by several terminal emulators to detect if you are pasting and set the mode automatically. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: fixed the script&lt;/p&gt;&#xA;" OwnerUserId="81" LastEditorUserId="81" LastEditDate="2015-02-04T22:51:56.087" LastActivityDate="2015-02-04T22:51:56.087" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="349" PostTypeId="2" ParentId="300" CreationDate="2015-02-04T19:48:22.153" Score="66" Body="&lt;p&gt;Beside the built-in alternatives &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; key cited by others, another popular solution is to remap &lt;code&gt;&amp;lt;CapsLock&amp;gt;&lt;/code&gt; as an additional Escape. &#xA;This both on a Qwerty and Dvorak keyboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way you can press Esc very easily with the left little finger, without removing hands from the HomeRow (incidentally, Escape was just above CapsLock in the &lt;a href=&quot;http://xahlee.info/kbd/ADM-3A_terminal.html&quot; rel=&quot;noreferrer&quot;&gt;ADM-3A Terminal&lt;/a&gt; used by &lt;a href=&quot;https://www.theregister.co.uk/Print/2003/09/11/bill_joys_greatest_gift/&quot; rel=&quot;noreferrer&quot;&gt;Bill Joy while writing vi&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remapping can be done:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;on Windows using &lt;a href=&quot;http://www.autohotkey.com/&quot; rel=&quot;noreferrer&quot;&gt;AutoHotKey&lt;/a&gt; utility;&lt;/li&gt;&#xA;&lt;li&gt;on Mac using the &lt;a href=&quot;https://pqrs.org/osx/karabiner/&quot; rel=&quot;noreferrer&quot;&gt;KeyRemap4MacBook&lt;/a&gt; utility and others;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;on Linux, varies according to the Desktop Environment.    For example on Linux Mint/Cinnamon is just a matter of selecting the&#xA;proper option in Menu-&gt;Keyboard-&gt;Keyboard Layouts-&gt;Caps Lock behavior. Alternatively, but less easily, it can be remapped at Xorg level using the xmodmap program and having it run the following &lt;code&gt;.Xmodmap&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;clear Lock&#xA;keycode 0x42 = Escape&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The system can be setup to automatically run it at every login by placing strategically the following shell script lines (supposing &lt;code&gt;.Xmodmap&lt;/code&gt; is on your home dir &lt;code&gt;~&lt;/code&gt;) in the chain of login auto-sourced files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [ -s ~/.Xmodmap ]; then&#xA;  xmodmap ~/.Xmodmap&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is tricky however, because actually sourced files vary according to the (desktop) environment used. As example, I have xmodmap called as an entry in the Cinnamon &quot;Startup Applications&quot; (which allows me to do more than the standard GUI key remapping customization).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some people go even further and program the CapsLock key to behave:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;as a &lt;code&gt;Ctrl&lt;/code&gt; key by pressing and holding it,  &lt;/li&gt;&#xA;&lt;li&gt;as an &lt;code&gt;Esc&lt;/code&gt; key by pressing and quickly releasing it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This can be done on Windows and Mac by properly setting/programming the corresponding remap utility (specifically for AutoHotkey hints can be found &lt;a href=&quot;https://superuser.com/questions/381296/mapping-caps-lock-to-escape-and-control-on-windows-7&quot;&gt;here&lt;/a&gt; and for KeyRemap4MacBook check &lt;a href=&quot;http://stevelosh.com/blog/2012/10/a-modern-space-cadet/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;). On Linux using the program &lt;a href=&quot;https://github.com/alols/xcape&quot; rel=&quot;noreferrer&quot;&gt;xcape&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="311" LastEditorUserId="25719" LastEditDate="2019-11-19T08:09:25.557" LastActivityDate="2019-11-19T08:09:25.557" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="350" PostTypeId="2" ParentId="340" CreationDate="2015-02-04T19:49:32.470" Score="3" Body="&lt;p&gt;According to &lt;code&gt;:help scroll-mouse-wheel&lt;/code&gt; the answer is no if you are using the Win32 GUI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, using X11 GUI or console vim with mouse support, the wheel sends key presses that you can remap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you could get the behaviour you describe by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap &amp;lt;ScrollWheelUp&amp;gt; h&#xA;:nmap &amp;lt;ScrollWheelDown&amp;gt; l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I'm using &lt;code&gt;nmap&lt;/code&gt; for mapping in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get similar behaviour in other modes, you can map to the direction instead of the normal key. E.g. for insert mode movement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap &amp;lt;ScrollWheelUp&amp;gt; &amp;lt;Left&amp;gt;&#xA;:imap &amp;lt;ScrollWheelDown&amp;gt; &amp;lt;Right&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make these default, stick them at the bottom of your vimrc.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-02-04T20:00:19.040" LastActivityDate="2015-02-04T20:00:19.040" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="351" PostTypeId="1" AcceptedAnswerId="399" CreationDate="2015-02-04T20:08:41.177" Score="10" ViewCount="646" Body="&lt;p&gt;For example, if I have some JavaScript code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var widget = library()&#xA;  .chainCall1()&#xA;  .chainCall2()&#xA;  .chainCall3();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I use the &lt;code&gt;=&lt;/code&gt; command to auto indent it, it comes out looking this this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var widget = library()&#xA;.chainCall1()&#xA;.chainCall2()&#xA;.chainCall3();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which isn't what I want. I want it to indent the chain calls like it originally was. How can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="226" LastActivityDate="2015-02-05T06:09:28.730" Title="Incorrectly indents JavaScript chain calls" Tags="|indentation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="352" PostTypeId="2" ParentId="268" CreationDate="2015-02-04T20:11:00.910" Score="4" Body="&lt;p&gt;I've implemented something like this using &lt;a href=&quot;http://ctags.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;Exuberant Ctags&lt;/a&gt; and a &lt;code&gt;.ctags&lt;/code&gt; file&#xA;in the directory (should also work with &lt;code&gt;.ctags&lt;/code&gt; in the home directory).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read up on using Ctags with arbitrary regex, but the gist of it is that you'll&#xA;be able to use that same &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;code&gt;]&lt;/code&gt; to go to these tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The contents of my &lt;code&gt;.ctags&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--langdef=markdown&#xA;--langmap=markdown:.md&#xA;--regex-markdown=/^#+\s*([^#]*)\s*#+$/\1/h,heading,headings/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then run ctags.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctags -R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you should get a file called &lt;code&gt;tags&lt;/code&gt; which has mappings for all markdown headers&#xA;in the &lt;code&gt;### HEADER ###&lt;/code&gt; format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/tagsrch.html#tagsrch.txt&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help tags&lt;/code&gt;&lt;/a&gt; for more information about navigating tags (e.g. when there are&#xA;multiple hits for a tag).&lt;/p&gt;&#xA;" OwnerUserId="141" LastActivityDate="2015-02-04T20:11:00.910" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="353" PostTypeId="2" ParentId="305" CreationDate="2015-02-04T20:34:28.247" Score="17" Body="&lt;p&gt;You could drop to &lt;em&gt;Netrw&lt;/em&gt; and rename the file there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the file you're editing is in the current directory, then do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Navigate to the file, press &lt;kbd&gt;R&lt;/kbd&gt;, and change the name.&#xA;Press &lt;kbd&gt;Enter&lt;/kbd&gt; to edit the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a caveat though: the original buffer remains in the list of buffers.&#xA;If you switch to it, it's empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the file you're editing is in a different directory, you can change to the file's directory with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cd %:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't want to change the directory for the entire Vim session but only for the current buffer, then you can do instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:lcd %:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="135" LastActivityDate="2015-02-04T20:34:28.247" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="354" PostTypeId="5" CreationDate="2015-02-04T21:12:00.847" Score="0" Body="&lt;p&gt;nvi is a free and &quot;bug-compatible&quot; clone of Bill Joy's original &lt;code&gt;vi&lt;/code&gt; with some enhancements like multiple undo levels. It first appeared in 4.4BSD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is the default &lt;code&gt;vi&lt;/code&gt; for all modern BSD systems.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-07T12:44:28.570" LastActivityDate="2015-08-07T12:44:28.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="355" PostTypeId="4" CreationDate="2015-02-04T21:12:00.847" Score="0" Body="A free and &quot;bug-compatible&quot; clone of Bill Joy's original `vi`. It first appeared in 4.4BSD." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-07T12:44:28.570" LastActivityDate="2015-08-07T12:44:28.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="356" PostTypeId="1" AcceptedAnswerId="357" CreationDate="2015-02-04T21:31:17.257" Score="84" ViewCount="80145" Body="&lt;p&gt;When coding in different languages, I tend to need to restrict my lines to a specific length (usually 79 or 80 characters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen this done in other editors through the use of a ruler (solid line displayed at the column) or by changing the color of the text to indicate that it has gone over.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I have Vim indicate to me when I am approaching or going over 79 characters in a single line?&lt;/p&gt;&#xA;" OwnerUserId="89" LastEditorUserId="2388" LastEditDate="2016-07-11T13:30:53.987" LastActivityDate="2022-11-09T09:02:42.033" Title="How can I set up a ruler at a specific column?" Tags="|alignment|colorcolumn|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="357" PostTypeId="2" ParentId="356" CreationDate="2015-02-04T21:31:17.257" Score="112" Body="&lt;p&gt;You can display a ruler at a specific line using the &lt;code&gt;:set colorcolumn&lt;/code&gt; (&lt;code&gt;:set cc&lt;/code&gt; for short) option which is only available in Vim 7.3 or later.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set colorcolumn=80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will set the background color of that column to red, giving you a visual ruler to work from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0rVzL.png&quot; alt=&quot;Picture of default colorcolumn set to 80&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use a different color other than red (which really stands out), you can change the color by setting the &lt;code&gt;highlight&lt;/code&gt; for &lt;code&gt;ColorColumn&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight ColorColumn ctermbg=0 guibg=lightgrey&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9vyQT.png&quot; alt=&quot;Customized color for the column&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can set the color for terminal versions of Vim using the &lt;code&gt;cterm&lt;/code&gt; argument and GUI versions of Vim using the &lt;code&gt;guibg&lt;/code&gt; argument. The &lt;code&gt;0&lt;/code&gt; is the value of the ASCII escape code for black, which is grey when brightened (which it is, by default). The value &lt;code&gt;lightgrey&lt;/code&gt; is used for GUI versions of Vim, like gVim, to change the background color to a light grey.&lt;/p&gt;&#xA;" OwnerUserId="89" LastActivityDate="2015-02-04T21:31:17.257" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="358" PostTypeId="1" AcceptedAnswerId="360" CreationDate="2015-02-04T21:36:50.943" Score="65" ViewCount="26277" Body="&lt;p&gt;I know I can browse Vim help with &lt;code&gt;:help&lt;/code&gt;, but this opens a split. Sometimes, I just like to study documentation. How can I read the Vim documentation in a &amp;quot;full screen&amp;quot; mode?&lt;/p&gt;&#xA;" OwnerUserId="189" LastEditorUserId="48490" LastEditDate="2024-01-14T17:28:22.250" LastActivityDate="2024-01-21T03:12:32.197" Title="How to &quot;full screen&quot; browse Vim help?" Tags="|help-system|vim-windows|" AnswerCount="17" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="359" PostTypeId="2" ParentId="358" CreationDate="2015-02-04T21:42:29.487" Score="7" Body="&lt;p&gt;You can make the help window full width and height by eliminating all other split windows, using &lt;kbd&gt;Control-w&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt; while inside the help window. This command makes the current window the &lt;em&gt;only&lt;/em&gt; window, removing all other windows.&lt;/p&gt;&#xA;" OwnerUserId="135" LastEditorUserId="135" LastEditDate="2015-02-04T22:47:41.110" LastActivityDate="2015-02-04T22:47:41.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="360" PostTypeId="2" ParentId="358" CreationDate="2015-02-04T21:43:31.550" Score="73" Body="&lt;p&gt;Just expand the help window to be the only visible window: &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;-&lt;kbd&gt;o&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you're done you can switch back to your other buffers.&lt;/p&gt;&#xA;" OwnerUserId="248" LastActivityDate="2015-02-04T21:43:31.550" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="361" PostTypeId="1" AcceptedAnswerId="395" CreationDate="2015-02-04T21:43:52.413" Score="16" ViewCount="1217" Body="&lt;p&gt;Vim keeps a history of ex commands (accessible via &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;↑&lt;/kbd&gt; and &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;), and that history persists after quitting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run multiple instances of Vim (same user, same home directory), how does Vim arbitrate between the command histories?  It seems that the last process to exit wins.  Is there a way to keep the command histories of all instances?&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2015-02-05T12:12:10.550" Title="How is command history resolved between multiple instances of Vim?" Tags="|command-line|command-history|persistent-state|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="362" PostTypeId="2" ParentId="358" CreationDate="2015-02-04T21:48:45.540" Score="36" Body="&lt;p&gt;Alternatively, you could open the help window in a new tab: &lt;code&gt;:tab help foo&lt;/code&gt;, and then use &lt;code&gt;:q&lt;/code&gt; to close it.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-04T21:48:45.540" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="363" PostTypeId="1" AcceptedAnswerId="392" CreationDate="2015-02-04T22:35:57.630" Score="43" ViewCount="21700" Body="&lt;p&gt;Here is (part of) a table I use in some documentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+---------------+------------------------+---------------------------------------+&#xA;| TASK NAME     | WHEN                   | DESCRIPTION                           |&#xA;+---------------+------------------------+---------------------------------------+&#xA;| db:seed       | On every update        | Data required for the application to  |&#xA;|               |                        | run; you should always be able to     |&#xA;|               |                        | safely execute this multiple times    |&#xA;|               |                        | for an update.                        |&#xA;| db:truncate   | Manually (dangerous!)  | TRUNCATE all tables but postal_codes  |&#xA;| postal_codes  | Once                   | Load the postal_codes table           |&#xA;+---------------+------------------------+---------------------------------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is this is very awkward to edit; if I change one thing, I need to&#xA;(manually) re-align everything, which is a PITA&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there easier ways to manage this? I don't care about the exact above layout&#xA;as such, but would like to keep the wrapping of the 3rd column...&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-07T00:46:25.447" LastActivityDate="2022-07-05T20:48:20.513" Title="How can I easily create and maintain tables?" Tags="|wrapping|word-processing|alignment|ascii-art|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="364" PostTypeId="1" AcceptedAnswerId="368" CreationDate="2015-02-04T22:48:27.177" Score="19" ViewCount="7396" Body="&lt;p&gt;I know using &lt;code&gt;:set cryptmethod=zip&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; secure, but how secure is using &lt;code&gt;:set cryptmethod=blowfish&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;p&gt;On &lt;a href=&quot;http://en.wikipedia.org/wiki/Blowfish_(cipher)&quot; rel=&quot;nofollow noreferrer&quot;&gt;wikipedia&lt;/a&gt; I read that the blowfish cipher, as such, should be secure, but this says nothing about the security of Vim's &lt;em&gt;implementation&lt;/em&gt; of it.&lt;/p&gt;&#xA;&lt;p&gt;And what about swapfiles, backupfiles, undofiles, and other possible ways to bypass the blowfish encryption? How secure is Vim there?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="23502" LastEditDate="2022-10-28T07:21:50.140" LastActivityDate="2022-10-28T09:49:48.393" Title="How secure is encrypting files with blowfish?" Tags="|security|encryption|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="365" PostTypeId="1" AcceptedAnswerId="2210" CreationDate="2015-02-04T22:53:37.467" Score="21" ViewCount="2892" Body="&lt;p&gt;I am looking for a possible solution for applying two different background colors inside a single vim buffer depending on context &lt;a href=&quot;https://raw.github.com/SublimeText-Markdown/MarkdownEditing/master/screenshots/light.png&quot;&gt;like in this sublime text example&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One use case of that is to color code snippets inside markup files differently so they stand out more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I have never seen an example with a setup like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this at all possible in vim?&lt;/p&gt;&#xA;" OwnerUserId="307" LastEditorUserId="51" LastEditDate="2015-02-05T00:45:08.467" LastActivityDate="2016-12-23T15:12:22.670" Title="Is it possible to use two different color backgrounds in a single vim buffer?" Tags="|colorscheme|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="366" PostTypeId="1" AcceptedAnswerId="367" CreationDate="2015-02-04T23:03:20.800" Score="6" ViewCount="245" Body="&lt;p&gt;If I encrypt a file with &lt;code&gt;:set cryptmethod=blowfish&lt;/code&gt; or &lt;code&gt;:set cryptmethod=blowfish2&lt;/code&gt;, and open the file in Vim, it asks for my password on startup. I type in the &lt;em&gt;correct&lt;/em&gt; password and continue happily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I enter the &lt;em&gt;wrong&lt;/em&gt; password, Vim will show me something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;1f&amp;gt;íW&amp;gt;&amp;lt;00&amp;gt;©?&amp;lt;11&amp;gt;­·Á&amp;lt;91&amp;gt;´!&amp;lt;98&amp;gt;!&amp;lt;0c&amp;gt;C ¦&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because Vim used the wrong key (and thus gets the wrong decryption).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This behaviour is not just annoying, but also dangerous (if you accidentally save it like this, you've lost your file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim is the only program I've ever used that does this. All other programs simply ask the password again. Can I make Vim do this? &lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-04T23:49:03.923" Title="How do I detect I've entered a wrong password when using cryptmethod (and make Vim ask for it again)?" Tags="|security|encryption|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="367" PostTypeId="2" ParentId="366" CreationDate="2015-02-04T23:13:06.687" Score="4" Body="&lt;p&gt;The best I've managed to do is use a wrapper script, I've named this &lt;code&gt;svim&lt;/code&gt; and&#xA;put it in &lt;code&gt;~/bin&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;&#xA;[ -z &quot;$1&quot; ] &amp;amp;&amp;amp; (echo &quot;We need a file&quot;; exit 1)&#xA;[ -f &quot;$1&quot; ] || (echo &quot;File needs to exist&quot;; exit 1)&#xA;[ &quot;$(head -c8 &quot;$1&quot;)&quot; = &quot;VimCrypt&quot; ] || (echo &quot;File needs to be encrypted&quot;; exit 1)&#xA;&#xA;while :; do&#xA;    vim -c &quot;source ~/.vim/password.vim&quot; &quot;$1&quot;&#xA;&#xA;    [ $? -eq 0 ] &amp;amp;&amp;amp; break&#xA;&#xA;    clear&#xA;    echo &quot;That seems to be the wrong password; press enter to try again, or ^C to abort&quot;&#xA;&#xA;    # Make sure we don't echo anything to the screen, in the case the user&#xA;    # enters the password here (as I did a few times...)&#xA;    # TODO: We really want to solve this better by allowing password input here&#xA;    stty -echo&#xA;    read x&#xA;    stty echo&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/.vim/password.vim&lt;/code&gt; looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; If there are less than 3 + (bytes / 100) newlines, we assume the password&#xA;&quot; is incorrect, and we're displaying a bunch of gibberish. Quit, and try&#xA;&quot; again&#xA;if getline(1) != '' &amp;amp;&amp;amp; line(&quot;$&quot;) &amp;lt; 3 + (line2byte(line(&quot;$&quot;)) / 100)&#xA;    &quot; User pressed ^C&#xA;    if strpart(getline(&quot;.&quot;), 0, 12) == &quot;VimCrypt~02!&quot;&#xA;        quit!&#xA;    else&#xA;        cquit!&#xA;    endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This isn't perfect. It won't work for small files, for example, and perhaps some other scenarios as well. But it's the best I could think of ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. I asked Bram about this, and his reply was &quot;just type the correct password&quot;, and that it's a 'feature'... So I don't expect a fix in Vim.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-04T23:13:06.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="368" PostTypeId="2" ParentId="364" CreationDate="2015-02-04T23:22:27.920" Score="21" Body="&lt;p&gt;It is &lt;em&gt;not&lt;/em&gt; secure. David Leadbeater posted POC code to brute-force upto 64 bytes in an article titled, somewhat ironically, &lt;a href=&quot;https://dgl.cx/2014/10/vim-blowfish&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Vim blowfish encryption... or why you shouldn't roll your own crypto&lt;/em&gt;&lt;/a&gt;. The Vim documentation &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#encryption&quot; rel=&quot;nofollow noreferrer&quot;&gt;now recommends&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;- The implementation of 'cryptmethod' &amp;quot;blowfish&amp;quot; has a flaw.  It is possible&#xA;  to crack the first 64 bytes of a file and in some circumstances more of the&#xA;  file. Use of it is not recommended, but it's still the strongest method&#xA;  supported by Vim 7.3 and 7.4.  The &amp;quot;zip&amp;quot; method is even weaker.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And, earlier on:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;The text in the swap file and the undo file is also encrypted.  E843&#xA;However, this is done block-by-block and may reduce the time needed to crack a&#xA;password.  You can disable the swap file, but then a crash will cause you to&#xA;lose your work.  The undo file can be disabled without much disadvantage. &#xA;        :set noundofile&#xA;        :noswapfile edit secrets&#xA;&#xA;Note: The text in memory is not encrypted.  A system administrator may be able&#xA;to see your text while you are editing it.  When filtering text with&#xA;&amp;quot;:!filter&amp;quot; or using &amp;quot;:w !command&amp;quot; the text is also not encrypted, this may&#xA;reveal it to others.  The 'viminfo' file is not encrypted.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Summary:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you care about security, &lt;code&gt;blowfish&lt;/code&gt; should not be used. Use &lt;code&gt;blowfish2&lt;/code&gt; or &lt;code&gt;xchacha20&lt;/code&gt; instead. xchacha20 requires that Vim was built with +sodium, but is the most secure option as it uses the well-known libsodium.&lt;/li&gt;&#xA;&lt;li&gt;While &lt;code&gt;swap&lt;/code&gt; and &lt;code&gt;undo&lt;/code&gt; files are encrypted, &lt;code&gt;viminfo&lt;/code&gt; isn't.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Unsolicited advice:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you do care about security, &lt;em&gt;do not roll your own encryption&lt;/em&gt;. And that means the &lt;code&gt;blowfish2&lt;/code&gt; implementation as well. Use something else, like GPG. The &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3645&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;gnupg.vim&lt;/code&gt;&lt;/a&gt; plugin may be useful. It seems &lt;a href=&quot;https://github.com/jamessan/vim-gnupg&quot; rel=&quot;nofollow noreferrer&quot;&gt;to be maintained&lt;/a&gt;. It disables &lt;code&gt;viminfo&lt;/code&gt; and the swap file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="51" LastEditDate="2022-10-28T09:49:48.393" LastActivityDate="2022-10-28T09:49:48.393" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="371" PostTypeId="2" ParentId="366" CreationDate="2015-02-04T23:49:03.923" Score="1" Body="&lt;p&gt;Is this closer to what you want? It doesn't improve on the testing for key correctness, but it does remove the need for the wrapper script.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup check_enc&#xA;    autocmd!&#xA;    autocmd BufRead * call Check_Enc()&#xA;augroup END&#xA;&#xA;function! Check_Enc()&#xA;    if &amp;amp;l:cm != &quot;&quot;&#xA;        if getline(1) != '' &amp;amp;&amp;amp; line(&quot;$&quot;) &amp;lt; 3 + (line2byte(line(&quot;$&quot;)) / 100)&#xA;            set key=&#xA;            edit&#xA;            call Check_Enc()&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When a buffer is read it checks if a cryptmethod is set, and if so is uses your check to see if it assumes the key is incorrect. If so, it sets the key to blank and re-edits the file causing it to prompt you for the password again.&lt;/p&gt;&#xA;" OwnerUserId="81" LastActivityDate="2015-02-04T23:49:03.923" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="372" PostTypeId="2" ParentId="340" CreationDate="2015-02-04T23:51:06.460" Score="1" Body="&lt;p&gt;If you use MacVim on OS X, this will work with a trackpad:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=n &quot; enable mouse in normal mode&#xA;set nowrap  &quot; disable line wrapping (so there's something to scroll to)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="212" LastActivityDate="2015-02-04T23:51:06.460" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="373" PostTypeId="1" AcceptedAnswerId="374" CreationDate="2015-02-05T00:32:27.000" Score="29" ViewCount="14565" Body="&lt;p&gt;Sometimes I use &lt;code&gt;:s&lt;/code&gt; with a complicated regexp which may or may not be correct, or I'm not sure if I want to replace &lt;em&gt;all&lt;/em&gt; matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can tell Vim to confirm every match it finds before it actually replaces the text?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="10604" LastEditDate="2020-04-05T19:10:01.493" LastActivityDate="2020-04-19T18:05:28.027" Title="Can I do an interactive :substitute (search &amp; replace)?" Tags="|substitute|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="374" PostTypeId="2" ParentId="373" CreationDate="2015-02-05T00:32:27.000" Score="35" Body="&lt;p&gt;Yes! Use the &lt;code&gt;c&lt;/code&gt; flag for &lt;code&gt;:substitute&lt;/code&gt;. From &lt;code&gt;:help substitute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[c]     Confirm each substitution.  Vim highlights the matching string (with&#xA;        hl-IncSearch).  You can type:                           :s_c&#xA;            'y'     to substitute this match&#xA;            'l'     to substitute this match and then quit (&quot;last&quot;)&#xA;            'n'     to skip this match&#xA;            &amp;lt;Esc&amp;gt;   to quit substituting&#xA;            'a'     to substitute this and all remaining matches {not in Vi}&#xA;            'q'     to quit substituting {not in Vi}&#xA;            CTRL-E  to scroll the screen up {not in Vi, not available when&#xA;                        compiled without the +insert_expand feature}&#xA;            CTRL-Y  to scroll the screen down {not in Vi, not available when&#xA;                        compiled without the +insert_expand feature}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example usage is simple as pie:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/old/new/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is very useful, but didn't know about this until 2 weeks ago :-) And it's even available in ol' vi :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus tip: You may also want to use &lt;code&gt;:set nowrapscan&lt;/code&gt;; this prevents Vim from wrapping to top when it hits the bottom. I've found this to be &lt;em&gt;especially useful&lt;/em&gt; when using the &lt;code&gt;c&lt;/code&gt; flag.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-04-19T18:05:28.027" LastActivityDate="2020-04-19T18:05:28.027" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="375" PostTypeId="2" ParentId="356" CreationDate="2015-02-05T00:32:41.470" Score="28" Body="&lt;p&gt;As an addendum to Kevin's answer, you can have multiple colorcolumns. When I code, I sometimes have a &quot;soft&quot; limit at 80 columns and a &quot;hard&quot; limit at 120 columns. So I want a line at 80, and then every column after 120 to be colored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do this with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;colorcolumn=&quot;80,&quot;.join(range(120,999),&quot;,&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, this can be easily modified to other preferences.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2015-02-05T00:32:41.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="376" PostTypeId="1" CreationDate="2015-02-05T00:32:42.547" Score="17" ViewCount="4881" Body="&lt;p&gt;After almost every time I type something in caps, I forget to turn off capslock when returning to normal mode. I then try to move the cursor and end up joining a bunch of lines and a lot of other things I don't expect to be happening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to configure vim to turn off capslock when I press escape to enter Normal mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there are solutions that are OS-specific, I am interested in those applicable to Linux.&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="24" LastEditDate="2015-02-09T01:48:24.520" LastActivityDate="2018-10-01T07:52:43.307" Title="Can vim automatically turn off Capslock when returning to normal mode?" Tags="|normal-mode|" AnswerCount="7" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="377" PostTypeId="5" CreationDate="2015-02-05T00:32:57.400" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-05T00:32:57.400" LastActivityDate="2015-02-05T00:32:57.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="378" PostTypeId="4" CreationDate="2015-02-05T00:32:57.400" Score="0" Body="Questions on ex- or colon-commands. For questions about command-line options used to launch the editor, use the [invocation] tag." OwnerUserId="24" LastEditorUserId="33" LastEditDate="2015-02-05T00:53:43.370" LastActivityDate="2015-02-05T00:53:43.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="379" PostTypeId="5" CreationDate="2015-02-05T00:33:17.657" Score="0" Body="&lt;p&gt;Options are settings that influence the behavior of the editor and that can be set at runtime. Options can have string, numeric or boolean values. In Vim, some options can have different values in different buffers or windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This tag is about ex/vi edit options. For command line options when starting vi, see &lt;a href=&quot;/questions/tagged/invocation&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'invocation'&quot; rel=&quot;tag&quot;&gt;invocation&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Basic usage&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Change the value of an option: &lt;code&gt;:set &lt;em&gt;optionname&lt;/em&gt;=&lt;em&gt;value&lt;/em&gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Set a boolean option to true: &lt;code&gt;:set &lt;em&gt;optionname&lt;/em&gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Set a boolean option to false: &lt;code&gt;:set &lt;em&gt;nooptionname&lt;/em&gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;See the current value of an option: &lt;code&gt;:set &lt;em&gt;optionname&lt;/em&gt;?&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;References&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/009695399/utilities/ex.html#tag_04_45_13_60&quot; rel=&quot;nofollow&quot;&gt;POSIX&lt;/a&gt; ex options&lt;/li&gt;&#xA;&lt;li&gt;Vim: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickref.html#option-list&quot; rel=&quot;nofollow&quot;&gt;quick list of all options&lt;/a&gt;, &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#option-summary&quot; rel=&quot;nofollow&quot;&gt;detailed manual of all options&lt;/a&gt;, &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#set-option&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;set&lt;/code&gt; command&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2015-02-05T00:53:50.660" LastActivityDate="2015-02-05T00:53:50.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="380" PostTypeId="4" CreationDate="2015-02-05T00:33:17.657" Score="0" Body="For questions about runtime settings that modify the behavior of the editor. When applicable, tag the version of the editor." OwnerUserId="8" LastEditorUserId="25" LastEditDate="2021-12-09T02:46:13.957" LastActivityDate="2021-12-09T02:46:13.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="381" PostTypeId="2" ParentId="363" CreationDate="2015-02-05T00:35:21.057" Score="7" Body="&lt;p&gt;If you can use &lt;code&gt;sed&lt;/code&gt; and &lt;code&gt;column&lt;/code&gt;, a command-line solution that comes close would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!sed 's/[- ]*\([+|]\)/'$'\x01''\1/g' | column -ts $'\x01' | sed '/^[-+ ]*$/s/ /-/g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could combine this with visual selection and &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; or with line numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Uses &lt;a href=&quot;http://manpages.ubuntu.com/sed.1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;sed&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://manpages.ubuntu.com/column.1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;column&lt;/code&gt;&lt;/a&gt;. Vim is incidental.&#xA;The &lt;code&gt;sed&lt;/code&gt; commands can probably be changed to vim &lt;code&gt;:substitute&lt;/code&gt; commands, but &lt;code&gt;column&lt;/code&gt; is crucial.&lt;/li&gt;&#xA;&lt;li&gt;The row separators (&lt;code&gt;---...-&lt;/code&gt;) get padded, but I have suspicions on its reliability.&lt;/li&gt;&#xA;&lt;li&gt;I don't know how portable &lt;code&gt;$'\x01'&lt;/code&gt; is.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Sources:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/18714/command-like-column-t-that-instead-keeps-separators-in-output&quot;&gt;Command like &lt;code&gt;column -t&lt;/code&gt; that instead keeps separators in output&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/2575545/vim-pipe-selected-text-to-shell-cmd-and-receive-output-on-vim-info-command-line&quot;&gt;Vim: Pipe selected text to shell cmd and receive output on vim info/command line&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-02-05T00:46:12.880" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="382" PostTypeId="2" ParentId="376" CreationDate="2015-02-05T00:43:03.890" Score="8" Body="&lt;p&gt;Responses to &lt;a href=&quot;https://stackoverflow.com/q/10530185/2209946&quot;&gt;this question&lt;/a&gt; indicate that it's not likely - Vim doesn't have access to the OS to make that call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can try changing your behaviour so that Caps Lock isn't required. It's a popular key to map to &lt;kbd&gt;Ctrl&lt;/kbd&gt;, &lt;kbd&gt;Esc&lt;/kbd&gt; or &lt;kbd&gt;Meta&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has the &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;U&lt;/kbd&gt; operator to uppercase a selection or motion, so perhaps you could type normally and use that afterwards. Also relevant: &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;u&lt;/kbd&gt; to lowercase and &lt;kbd&gt;~&lt;/kbd&gt; to toggle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also ways to autocomplete, which may reduce your need to type &lt;code&gt;VERY_LONG_MACRO_NAMES&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="212" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-02-05T00:43:03.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="383" PostTypeId="5" CreationDate="2015-02-05T01:20:14.617" Score="0" Body="&lt;p&gt;For a general overview on how to interface with the systems's clipboard, see: &lt;a href=&quot;http://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim/96&quot;&gt;How can I copy text to the system clipboard from Vim?&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-06T09:58:15.027" LastActivityDate="2015-02-06T09:58:15.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="384" PostTypeId="4" CreationDate="2015-02-05T01:20:14.617" Score="0" Body="Questions about interfacing with the system's clipboard." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-09T14:35:16.110" LastActivityDate="2015-02-09T14:35:16.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="385" PostTypeId="1" AcceptedAnswerId="386" CreationDate="2015-02-05T01:34:13.423" Score="10" ViewCount="321" Body="&lt;p&gt;Pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;w&lt;/kbd&gt; in Insert mode will delete the previous word. It is equivalent to &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;Backspace&lt;/kbd&gt; in Windows, and &lt;kbd&gt;Opt&lt;/kbd&gt;-&lt;kbd&gt;Delete&lt;/kbd&gt; in OS X, and really speeds up typing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has the separate concepts of &lt;code&gt;word&lt;/code&gt; and &lt;code&gt;WORD&lt;/code&gt; (see &lt;code&gt;:help word&lt;/code&gt;). This is invaluable for text navigation: it is the difference between &lt;kbd&gt;w&lt;/kbd&gt; and &lt;kbd&gt;W&lt;/kbd&gt;, &lt;kbd&gt;b&lt;/kbd&gt; and &lt;kbd&gt;B&lt;/kbd&gt;, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;w&lt;/kbd&gt; operates on &lt;code&gt;word&lt;/code&gt;. Is there a similar instruction for &lt;code&gt;WORD&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="212" LastEditorUserId="24" LastEditDate="2015-02-05T02:30:36.737" LastActivityDate="2015-02-05T02:30:36.737" Title="Is there a &lt;C-w&gt; for WORDs?" Tags="|key-bindings|insert-mode|word-processing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="386" PostTypeId="2" ParentId="385" CreationDate="2015-02-05T01:54:07.413" Score="7" Body="&lt;p&gt;I don't believe there is one built in, but you can map one yourself in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-b&amp;gt; &amp;lt;esc&amp;gt;vBda&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="81" LastActivityDate="2015-02-05T01:54:07.413" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="387" PostTypeId="2" ParentId="373" CreationDate="2015-02-05T02:18:22.237" Score="23" Body="&lt;p&gt;In addition to what Carpetsmoker said:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;amp;incsearch&lt;/code&gt; (&lt;code&gt;set incsearch&lt;/code&gt;) setting in Vim is really useful. You can use it together with a useful and little known trick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trick is to try out your complex regex by just using the &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt; command. Vim will use the &lt;code&gt;&amp;amp;incsearch&lt;/code&gt; setting to show matches interactively. Once you're happy with the regex, you can use &lt;code&gt;:%s//replacement&lt;/code&gt; to have vim use the previous search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice how the part in &lt;code&gt;//&lt;/code&gt; is blank (that's where you put the text to search). If you leave it blank, you are telling Vim to use the previous search regex. With this, you can type out a complex regex with &lt;code&gt;/&lt;/code&gt; and have all the benefits of &lt;code&gt;set incsearch&lt;/code&gt;, and then use the &lt;code&gt;%s//replacement&lt;/code&gt; command to actually execute the search and replace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want something similar to incsearch for &lt;code&gt;:s&lt;/code&gt; commands, check out &lt;a href=&quot;https://github.com/osyo-manga/vim-over&quot;&gt;vim-over&lt;/a&gt;, but I just prefer using the native Vim way.&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="246" LastEditDate="2015-02-05T02:23:58.183" LastActivityDate="2015-02-05T02:23:58.183" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="388" PostTypeId="1" AcceptedAnswerId="397" CreationDate="2015-02-05T02:30:20.987" Score="315" ViewCount="179681" Body="&lt;p&gt;I have been looking at the different package managers for Vim, and the one I decided to use is &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;noreferrer&quot;&gt;vim-plug&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, I have seen others like &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;noreferrer&quot;&gt;pathogen&lt;/a&gt; and &lt;a href=&quot;https://github.com/gmarik/Vundle.vim&quot; rel=&quot;noreferrer&quot;&gt;vundle&lt;/a&gt;, and I honestly don't know what the difference is.&lt;/p&gt;&#xA;&lt;p&gt;Can someone give me a brief overview of the differences, so I can decide which works best for me?&lt;/p&gt;&#xA;" OwnerUserId="326" LastEditorUserId="23502" LastEditDate="2022-10-28T07:19:04.090" LastActivityDate="2022-10-28T07:19:04.090" Title="What are the differences between the Vim plugin managers?" Tags="|plugin-managers|" AnswerCount="10" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="389" PostTypeId="2" ParentId="82" CreationDate="2015-02-05T02:36:41.957" Score="39" Body="&lt;p&gt;I really like &lt;a href=&quot;https://github.com/Rip-Rip/clang_complete&quot;&gt;clang_complete&lt;/a&gt; for this. It does require clang, and you need to tell it where libclang resides in your system. After that, it works wonderfully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;People might suggest YouCompleteMe, but to be honest, that plugin is hugely bloated for what it says it does, and it requires way too many steps to install. I also had it segfault Vim on multiple occasions. I couldn't be happier with clang_complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I get when I type &lt;code&gt;v.&lt;/code&gt;: &lt;img src=&quot;https://i.stack.imgur.com/OYcjy.png&quot; alt=&quot;clang-complete&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="246" LastActivityDate="2015-02-05T02:36:41.957" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="390" PostTypeId="2" ParentId="388" CreationDate="2015-02-05T03:07:37.610" Score="77" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot;&gt;Pathogen&lt;/a&gt; is simple. Essentially it just does:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;autoload plugins from a folder&lt;/li&gt;&#xA;&lt;li&gt;generate help tags for these plugins&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Pros:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;minimalist&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Cons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;everything else done manually (installing, updating, removing, etc.)&lt;/li&gt;&#xA;&lt;li&gt;no lazy loading&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To install it download &lt;a href=&quot;https://github.com/tpope/vim-pathogen/blob/master/autoload/pathogen.vim&quot;&gt;&lt;code&gt;pathogen.vim&lt;/code&gt;&lt;/a&gt; to &lt;code&gt;~/.vim/autoload&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ~/.vim/autoload ~/.vim/bundle &amp;amp;&amp;amp; \&#xA;curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And add to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call pathogen#infect()&#xA;call pathogen#helptags() &quot;If you like to get crazy :)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't like to get crazy, only call &lt;code&gt;:Helptags&lt;/code&gt; when you need to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plugins are then added to &lt;code&gt;~/vim/bundle&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="1292" LastEditDate="2015-08-17T12:14:26.903" LastActivityDate="2015-08-17T12:14:26.903" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="391" PostTypeId="2" ParentId="388" CreationDate="2015-02-05T03:12:23.847" Score="54" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/gmarik/Vundle.vim&quot;&gt;Vundle&lt;/a&gt; is more complex. It is a package manager à la &lt;a href=&quot;http://en.wikipedia.org/wiki/Advanced_Packaging_Tool&quot;&gt;&lt;code&gt;apt&lt;/code&gt;&lt;/a&gt; or &lt;code&gt;yum&lt;/code&gt; for plugins. It can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;search a plugin index&lt;/li&gt;&#xA;&lt;li&gt;update plugins&lt;/li&gt;&#xA;&lt;li&gt;generate helptags automatically&lt;/li&gt;&#xA;&lt;li&gt;keep, but not use, plugins in the autoload folder&lt;/li&gt;&#xA;&lt;li&gt;clean out such unused plugins&lt;/li&gt;&#xA;&lt;li&gt;Works on Linux, OSX, and MS Windows&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To install:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then add to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'gmarik/Vundle.vim'&#xA;&#xA;&quot; more Plugin commands&#xA;&quot; ...&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To install a plugin, use the &lt;code&gt;Plugin&lt;/code&gt; command in &lt;code&gt;.vimrc&lt;/code&gt; (more examples on the Github README):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; plugin on Github&#xA;Plugin 'tpope/vim-fugitive'&#xA;&quot; plugin from http://vim-scripts.org/vim/scripts.html&#xA;Plugin 'L9'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then call &lt;code&gt;:PluginInstall&lt;/code&gt; from &lt;code&gt;.vim&lt;/code&gt; (or &lt;code&gt;vim +PluginInstall +qall&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-06-23T05:36:58.540" LastActivityDate="2016-06-23T05:36:58.540" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="392" PostTypeId="2" ParentId="363" CreationDate="2015-02-05T03:33:07.980" Score="56" Body="&lt;p&gt;I am the author of the plugin&#xA;&lt;a href=&quot;https://github.com/dhruvasagar/vim-table-mode&quot; rel=&quot;noreferrer&quot;&gt;vim-table-mode&lt;/a&gt;.&#xA;I've spent quite a lot of time building &amp;amp; improving this, especially with&#xA;community feedback and it caters exactly to this use case.&lt;/p&gt;&#xA;&lt;p&gt;A short quickstart: You enter 'table mode' with the &lt;code&gt;:TableModeEnable&lt;/code&gt; command,&#xA;you can then simply type:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;||&#xA;| MOVIE | QUOTE|&#xA;||&#xA;| Blade Runner | Like tears in the rain |&#xA;| Monty Python's quest for the holy grail | Are you suggesting that coconuts migrate? |&#xA;||&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And vim-table-mode will automatically take care of the alignment for you&#xA;on-the-fly, so that it will look as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|-----------------------------------------+-------------------------------------------|&#xA;| MOVIE                                   | QUOTE                                     |&#xA;|-----------------------------------------+-------------------------------------------|&#xA;| Blade Runner                            | Like tears in the rain                    |&#xA;| Monty Python's quest for the holy grail | Are you suggesting that coconuts migrate? |&#xA;|-----------------------------------------+-------------------------------------------|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When editing the table later, vim-table-mode will also take care of the&#xA;alignment for you.&lt;/p&gt;&#xA;&lt;p&gt;Use the &lt;code&gt;Tableize&lt;/code&gt; command to convert existing text to tables, e.g.,&lt;br /&gt;&#xA;&lt;code&gt;%Tableize/,&lt;/code&gt; will convert any tables to text in the entire file, using &lt;code&gt;,&lt;/code&gt; as the delimiter.&lt;/p&gt;&#xA;&lt;p&gt;You can leave 'table mode' with &lt;code&gt;:TableModeDisable&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Its core is about easily creating tables which will be auto formatted as you&#xA;type. It offers a lot of mappings to move around and manipulate tables as well&#xA;(a particularly useful one is &lt;code&gt;&amp;lt;Leader&amp;gt;tdc&lt;/code&gt; to remove an entire column).  All&#xA;you have to do is enable table mode and these will kick in and you can just type&#xA;away without worrying about formatting.&lt;/p&gt;&#xA;&lt;p&gt;It has many more features than displayed here, such as the ability to right&#xA;align columns with a little hint on the header. It also has a neat spreadsheet&#xA;formula engine that allows one to define formulas &amp;amp; perform computations like a&#xA;regular spreadsheet would.&lt;/p&gt;&#xA;&lt;p&gt;It's built to be extremely flexible &amp;amp; configurable so you can change several&#xA;aspects of the tables &amp;amp; borders that are created.&lt;/p&gt;&#xA;&lt;p&gt;I have also created a few screencasts trying to showcase its powers.&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=9lVQ0VJY3ps&quot; rel=&quot;noreferrer&quot;&gt;This screencast is the most recent one&lt;/a&gt;, but please note that there have been many improvements since.&lt;/p&gt;&#xA;" OwnerUserId="74" LastEditorUserId="14340" LastEditDate="2020-09-25T06:04:22.550" LastActivityDate="2020-09-25T06:04:22.550" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="393" PostTypeId="1" AcceptedAnswerId="401" CreationDate="2015-02-05T03:56:17.647" Score="6" ViewCount="2288" Body="&lt;p&gt;The vimwiki plugin offers a great feature of converting whole Wiki to HTML: &lt;code&gt;:VimwikiAll2HTML&lt;/code&gt;. But it bothers me that there are no back links to the main page, and the only way to navigate back to the main page is using the browser's &quot;back&quot; button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to modify the template vimwiki uses to produce HTML? Preferably without touching the plugin internals (I use pathogen and I want it to be portable between Vim installations).&lt;/p&gt;&#xA;" OwnerUserId="189" LastActivityDate="2015-02-08T05:56:55.453" Title="Altering HTML templates in vimwiki" Tags="|plugin-vimwiki|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="394" PostTypeId="2" ParentId="376" CreationDate="2015-02-05T03:58:09.037" Score="4" Body="&lt;p&gt;I have remapped my capslock to be ctrl and I rarely use capslock anymore. However, for vim if I ever need, you have &lt;a href=&quot;https://github.com/tpope/vim-capslock&quot;&gt;tpope/vim-capslock&lt;/a&gt; as a software temporary capslock for you. If you use this it should be fairly easy to setup an autocmd for the event &lt;code&gt;InsertLeave&lt;/code&gt; and disable capslock.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-05T03:58:09.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="395" PostTypeId="2" ParentId="361" CreationDate="2015-02-05T04:08:03.357" Score="11" Body="&lt;p&gt;The answer to your title question is what you observed. From the vim user manual &lt;a href=&quot;https://vimhelp.appspot.com/usr_21.txt.html#21.3&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 21.3&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When you run Vim multiple times, the last one exiting will store its&#xA;  information.  This may cause information that previously exiting Vims&#xA;  stored to be lost.  Each item can be remembered only once.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, the filename of the viminfo file (where the command history is stored, among other things like global marks and register contents, if so configured) is changeable! This means that you can setup different 'histories' for different projects or instances of vim. Assuming you don't run more than one vim instance per project, managing the viminfo filename via vimrc (or other project settings plugin) is a great way to handle this.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Setup alternative viminfo files&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For project level management, we want to configure vim to save your viminfo to a different file. This can be done within a running vim prior to quitting, or by your vimrc, for example you might have lines in your vimrc that detect a particular directory as belonging to a project.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set viminfo+=nPath/to/custom/viminfofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An example of having vimrc automatically set this based on directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if getcwd() == &quot;/projects/projA&quot;&#xA;     set viminfo+=n~/.viminfo-projA&#xA; endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result of the above is that the project-specific history will be loaded at startup and saved on exit, if vim is launched in the /projects/projA directory.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Load an alternate viminfo during startup&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is good for the case where you want to save your history to the side and load it later, without managing it at a project level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, to save the history, you add to the viminfo option as above prior to exiting. Then to load the history, launch vim with the -i option&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -i Path/to/custom/viminfofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't want to exit vim to save the viminfo file, you can use &lt;code&gt;:wv&lt;/code&gt; (&lt;code&gt;:wviminfo&lt;/code&gt;). This saves the viminfo file without exiting vim according to the n setting above. And, you can also do &lt;code&gt;:wv SomeOtherFile&lt;/code&gt; to save to a location that isn't the same as the setting in the viminfo option. This may be more convenient than setting up the filename to use at exit, but doesn't stop vim from using the default file once it does exit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in first vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:wv ~/customInfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in second terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -i ~/customInfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, if a second vim is already running and you want to load the viminfo:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:rv ~/customInfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;:wv&lt;/code&gt; and &lt;code&gt;:rv&lt;/code&gt; don't change the name of the file vim will save on exit nor the name of the file read during startup.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Additional information&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Description of &lt;code&gt;set viminfo+=nSomePath&lt;/code&gt;: We use the set command to adjust the option named &lt;code&gt;viminfo&lt;/code&gt;. The &lt;code&gt;+=&lt;/code&gt; indicates we want to append to the option, not change everything. We append the &lt;code&gt;n&lt;/code&gt; option which specifies the filename for viminfo. Immediately after &lt;code&gt;n&lt;/code&gt; we have &lt;code&gt;SomePath&lt;/code&gt; which will be the filename used for saving viminfo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation for &lt;code&gt;wv&lt;/code&gt; (&lt;code&gt;:help wv&lt;/code&gt;) indicates that this command will first read the viminfo file, then merge between old and new information. So far I have no information about how the merging works in this case, but I'd guess it keeps marks for unknown files and registers that aren't set in the current session.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="24" LastEditDate="2015-02-05T12:12:10.550" LastActivityDate="2015-02-05T12:12:10.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="396" PostTypeId="2" ParentId="376" CreationDate="2015-02-05T04:08:41.150" Score="2" Body="&lt;p&gt;Another option is to remap your &lt;kbd&gt;CapsLock&lt;/kbd&gt; to &lt;kbd&gt;Esc&lt;/kbd&gt;. This is a mapping I've been using for a couple of years now: &lt;kbd&gt;CapsLock&lt;/kbd&gt; is on a home row, so it's really easy to use if you touch type. It also promotes proper Vim usage, since getting out of insert mode is much easier (key is closer than &lt;kbd&gt;Esc&lt;/kbd&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's easy to remap: Linux supports this natively, there are small apps for Mac OS X and Windows to accomplish that. And some expensive keyboards even come with a feature that allows remapping keys.&lt;/p&gt;&#xA;" OwnerUserId="189" LastActivityDate="2015-02-05T04:08:41.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="397" PostTypeId="2" ParentId="388" CreationDate="2015-02-05T04:19:37.987" Score="211" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;noreferrer&quot;&gt;vim-plug&lt;/a&gt; is a nice alternative to Vundle, it does things a bit different from a technical point of view which should make it faster (&lt;a href=&quot;http://junegunn.kr/2013/09/writing-my-own-vim-plugin-manager/&quot; rel=&quot;noreferrer&quot;&gt;see this&lt;/a&gt;). It has most (or all?) of the features of Vundle.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Parallel update procedure for Vim with any of &lt;code&gt;+ruby&lt;/code&gt;, &lt;code&gt;+python&lt;/code&gt;, or Neovim. Falls back to sequential mode using Vimscript if none is available.&lt;/li&gt;&#xA;&lt;li&gt;Lazy loading, for faster startup (&lt;a href=&quot;http://junegunn.kr/2014/07/vim-plugins-and-startup-time/&quot; rel=&quot;noreferrer&quot;&gt;see this&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Install plugins.&lt;/li&gt;&#xA;&lt;li&gt;Update plugins.&lt;/li&gt;&#xA;&lt;li&gt;Review / rollback updates.&lt;/li&gt;&#xA;&lt;li&gt;Supports OSX, Linux &amp;amp; UNIX systems, and MS Windows.&lt;/li&gt;&#xA;&lt;li&gt;Post-update hooks e.g. automatically recompile YCM&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To start using it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;curl -fLo ~/.vim/autoload/plug.vim --create-dirs \&#xA;    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin()&#xA;Plug 'tpope/vim-sensible'&#xA;&#xA;&quot; On-demand loading&#xA;Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then give the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PlugInstall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to install the listed plugins.&lt;/p&gt;&#xA;" OwnerUserId="331" LastEditorUserId="24" LastEditDate="2019-06-21T21:32:57.347" LastActivityDate="2019-06-21T21:32:57.347" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="398" PostTypeId="1" AcceptedAnswerId="3471" CreationDate="2015-02-05T04:48:20.150" Score="15" ViewCount="1324" Body="&lt;p&gt;So a while ago I had decided to learn more about how vim's syntax files work, by creating my own.  My goal was to create a simple syntax file that would split the file into 3 parts based on delimiters, and include pre-existing syntax files for two of those three parts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is an example file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Some text, unstyled&#xA;&#xA;==================== Log&#xA;(Output of git log)&#xA;&#xA;==================== Diff&#xA;(Output of diff)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The goal was to apply &lt;code&gt;git.vim&lt;/code&gt; to just the log, and &lt;code&gt;diff.vim&lt;/code&gt; to just the diff, excluding the two headers.&lt;sup&gt;1&lt;/sup&gt;  This is what my syntax file ended up looking like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;b:current_syntax&quot;)&#xA;    finish&#xA;endif&#xA;&#xA;syntax include @gitlog $VIMRUNTIME/syntax/git.vim&#xA;syntax region GitLog&#xA;    \ start=/^===* Log/&#xA;    \ end=/^===* Diff/&#xA;    \ contains=@gitlog&#xA;&#xA;syntax include @gitdiff $VIMRUNTIME/syntax/diff.vim&#xA;syntax region Diff&#xA;    \ start=/^===* Diff/&#xA;    \ end=/\n\n/&#xA;    \ contains=@gitdiff&#xA;&#xA;let b:current_syntax = &quot;logdiff&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note how &lt;code&gt;end&lt;/code&gt; on the first region is the same as &lt;code&gt;start&lt;/code&gt; on the second region.  This doesn't work; the second region is apparently not detected and syntax highlighting is not applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can make it work by loosening the regex to &lt;code&gt;end=/^===/&lt;/code&gt; and &lt;code&gt;start=/=== Diff/&lt;/code&gt;, so that the regions don't touch, but don't particularly like that - it's less obvious that one is supposed to start where the other ends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to allow two region definitions to touch the same characters (and/or make the matching edges exclusive instead of inclusive) or am I stuck with the looser regex?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&lt;sup&gt;1&lt;/sup&gt;(Yes, I know &lt;code&gt;git.vim&lt;/code&gt; includes &lt;code&gt;diff.vim&lt;/code&gt;, but this was a learning exercise)&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="238" LastEditorUserId="238" LastEditDate="2015-02-05T04:56:18.463" LastActivityDate="2017-03-01T10:38:01.713" Title="Can vim syntax regions be made to touch/overlap?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="399" PostTypeId="2" ParentId="351" CreationDate="2015-02-05T06:09:28.730" Score="3" Body="&lt;p&gt;I had the same problem - for the most part the JavaScript formatting done by vim is not bad, but in examples like the one you give it fails miserably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been using the &lt;a href=&quot;https://github.com/maksimr/vim-jsbeautify&quot; rel=&quot;nofollow&quot;&gt;vim-jsbeautify&lt;/a&gt; plugin to fix things where the vim indentation fails, and also to clean up ugly code other people have written. It works really well, you can run it on the whole file or just a region, and it's customisable using an &lt;a href=&quot;http://editorconfig.org/&quot; rel=&quot;nofollow&quot;&gt;EditorConfig&lt;/a&gt; file.&lt;/p&gt;&#xA;" OwnerUserId="248" LastActivityDate="2015-02-05T06:09:28.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="400" PostTypeId="1" CreationDate="2015-02-05T06:38:23.003" Score="6" ViewCount="829" Body="&lt;p&gt;I love vim, I love python, and I dislike vimscript. So I would like to know how to write plugins (or throwaway scripts) for vim in python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, the first reference should be &lt;code&gt;:h python&lt;/code&gt;, but I find it very hard to follow. A different reference might be to read the source for full-fledged vim plugins written (largely) in python, like &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow&quot;&gt;Ultisnips&lt;/a&gt;. But surely there are stepping stones in the middle?&lt;/p&gt;&#xA;" OwnerUserId="130" LastEditorUserId="51" LastEditDate="2015-04-30T11:42:37.797" LastActivityDate="2015-04-30T11:42:37.797" Title="Resources for scripting vim with python" Tags="|vimscript|plugin-system|vimscript-python|" AnswerCount="0" CommentCount="3" ClosedDate="2015-02-05T14:57:00.517" ContentLicense="CC BY-SA 3.0" />
  <row Id="401" PostTypeId="2" ParentId="393" CreationDate="2015-02-05T07:12:34.863" Score="6" Body="&lt;p&gt;Found a solution in vimwiki documentation. Here's a modification to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vimwiki_list = [{&#xA;  \ 'path': '$HOME/Dropbox/vimwiki',&#xA;  \ 'template_path': '$HOME/Dropbox/vimwiki/templates',&#xA;  \ 'template_default': 'default',&#xA;  \ 'template_ext': '.html'}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I had to create &lt;code&gt;$HOME/Dropbox/vimwiki/templates/default.html&lt;/code&gt;, and I took original HTML file content from &lt;code&gt;vimwiki/autoload/vimwiki/default.tpl&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously &lt;code&gt;$HOME/Dropbox/vimwiki&lt;/code&gt; is to be replace with whatever directory your wiki is in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Wrote an article with more detail: &lt;a href=&quot;http://www.rosipov.com/blog/custom-templates-in-vimwiki/&quot; rel=&quot;noreferrer&quot;&gt;http://www.rosipov.com/blog/custom-templates-in-vimwiki/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="189" LastEditorUserId="189" LastEditDate="2015-02-08T05:56:55.453" LastActivityDate="2015-02-08T05:56:55.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="402" PostTypeId="1" CreationDate="2015-02-05T07:26:45.897" Score="13" ViewCount="1196" Body="&lt;p&gt;Various plain-text markup languages: &#xA;&lt;em&gt;reStructuredText, Markdown, asciidoc (others too)&lt;/em&gt;,&#xA;use an underline to denote titles.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Chapter 1 Title&#xA;===============&#xA;&#xA;Section 1.1 Title&#xA;-----------------&#xA;&#xA;Subsection 1.1.1 Title&#xA;~~~~~~~~~~~~~~~~~~~~~~&#xA;&#xA;Section 1.2 Title&#xA;-----------------&#xA;&#xA;Chapter 2 Title&#xA;===============&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a convenient way add these in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;add a character with a length matching the line above.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2015-02-06T03:24:19.903" Title="How to underline titles? (reStructuredText, Markdown, asciidoc style)" Tags="|markup|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="403" PostTypeId="1" CreationDate="2015-02-05T07:28:01.217" Score="3" ViewCount="4462" Body="&lt;p&gt;Because of Vim's modes, there is not a lot of holding down the &lt;kbd&gt;Ctrl&lt;/kbd&gt; key while pressing another key. However ,in insert (or replace) mode, &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;R&lt;/kbd&gt; will let you paste a register, and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; lets you insert any character literally. &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; deletes a word, and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;H&lt;/kbd&gt; backspaces a letter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the term for these key sequences?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there more of them?&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="205" LastEditDate="2016-05-16T21:55:57.707" LastActivityDate="2020-03-20T21:26:09.773" Title="What are the Control-key combinations/chords?" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="404" PostTypeId="2" ParentId="403" CreationDate="2015-02-05T07:28:01.217" Score="7" Body="&lt;p&gt;The &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;insert.txt Vimdoc&lt;/a&gt; calls these &quot;special keys&quot;, and the docs can be brought up with &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#ins-special-keys&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ins-special-keys&lt;/code&gt;&lt;/a&gt;. Some fun examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;adjust the indentation of the line you're currently typing with &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;T&lt;/kbd&gt; and &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;D&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;K&lt;/kbd&gt; lets you insert &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/digraph.html#digraphs&quot; rel=&quot;nofollow noreferrer&quot;&gt;digraphs&lt;/a&gt; (e.g. &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;K&lt;/kbd&gt; &lt;kbd&gt;O&lt;/kbd&gt; &lt;kbd&gt;K&lt;/kbd&gt; inserts a &quot;✓&quot;)&lt;/li&gt;&#xA;&lt;li&gt;when you're ready to get out of insert mode, save your left wrist some movement by using &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; instead of &lt;kbd&gt;Escape&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are also some &quot;special special keys&quot;, docs are at &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#ins-special-special&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ins-special-special&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2020-03-20T21:26:09.773" LastActivityDate="2020-03-20T21:26:09.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="405" PostTypeId="2" ParentId="402" CreationDate="2015-02-05T07:42:08.280" Score="22" Body="&lt;p&gt;A naïve approach (no plugins or scripting) would be &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;Y&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Y&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; duplicates the current line and puts the cursor on the lower line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;V&lt;/kbd&gt; selects the second line in Visual Line mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt; replaces all characters on the line with the &lt;code&gt;=&lt;/code&gt; character.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can, of course, &lt;code&gt;:noremap&lt;/code&gt; that keystroke sequence to your taste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Add Heading: Control-H&#xA;nnoremap &amp;lt;C-h&amp;gt; YpVr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...leaving off the last character so you can type in whichever you want for the title.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="301" LastEditDate="2015-02-06T03:24:19.903" LastActivityDate="2015-02-06T03:24:19.903" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="406" PostTypeId="1" CreationDate="2015-02-05T07:44:29.330" Score="3" ViewCount="828" Body="&lt;p&gt;I'm trying to retrain my fingers to refrain from using &lt;kbd&gt;Escape&lt;/kbd&gt; so often.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I disable &lt;kbd&gt;Escape&lt;/kbd&gt; when I'm in insert mode, leaving just &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; and &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; as the only ways to return to normal mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried &lt;code&gt;:inoremap &amp;lt;Esc&amp;gt; &amp;lt;nop&amp;gt;&lt;/code&gt; but that seems to half-break both &lt;kbd&gt;Escape&lt;/kbd&gt; and &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2015-02-05T18:22:56.643" LastActivityDate="2015-02-26T03:47:28.043" Title="Can Escape be disabled in insert mode?" Tags="|key-bindings|insert-mode|escape|habit-breaking|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="407" PostTypeId="2" ParentId="406" CreationDate="2015-02-05T07:51:01.657" Score="-1" Body="&lt;p&gt;I think you missed the backslash. Disable &lt;kbd&gt;Esc&lt;/kbd&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap \&amp;lt;Esc&amp;gt; Nop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From comment of &lt;a href=&quot;https://vi.stackexchange.com/users/20/tokoyami&quot;&gt;user&lt;/a&gt; under &lt;a href=&quot;https://vi.stackexchange.com/a/282/153&quot;&gt;this&lt;/a&gt; answer:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The backslash is required because otherwise vim will recognize &amp;lt; Space&gt; as a  normal string and not the code for the space key. See :help expr-string for examples. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="153" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2015-02-05T07:56:27.017" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="408" PostTypeId="2" ParentId="406" CreationDate="2015-02-05T07:53:56.323" Score="7" Body="&lt;p&gt;I don't think that's possible, the problem is that &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; is the same as &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; as in the key codes that vim receives when you type it is exactly the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can reproduce this and validate it in insert mode by hitting &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; first and then &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; respectively and you'll see it sends the same key code to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence VIM cannot distinguish between the two (at least within a terminal), I am not too sure if things are different for gui versions.&lt;/p&gt;&#xA;" OwnerUserId="74" LastEditorUserId="74" LastEditDate="2015-02-05T07:59:11.083" LastActivityDate="2015-02-05T07:59:11.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="409" PostTypeId="2" ParentId="406" CreationDate="2015-02-05T07:54:28.140" Score="5" Body="&lt;p&gt;In insert mode, you can type &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;v&lt;/kbd&gt; &lt;kbd&gt;Esc&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;v&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt;. You will see the literal interpretation of those key sequences according to vim. (See &lt;code&gt;:h i_CTRL_V&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most importantly, you'll notice that they are the same (at least for me in both vim in xterm and gvim). So you cannot disable one and not the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, I'd say it's a bad idea to remap &lt;kbd&gt;Esc&lt;/kbd&gt;, as you'll have unintended consequences.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2015-02-05T07:54:28.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="410" PostTypeId="1" CreationDate="2015-02-05T08:26:46.883" Score="41" ViewCount="5295" Body="&lt;p&gt;I've sometimes tried invoking Vim using &lt;code&gt;xargs&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -name '*.java' | xargs vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… which kind of works:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;As Vim launches, I see the following warning flash briefly:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;Vim: Warning: Input is not from a terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;Editing works — &lt;code&gt;:files&lt;/code&gt; correctly enumerates all of the &lt;code&gt;.java&lt;/code&gt; files as expected.&lt;/li&gt;&#xA;&lt;li&gt;I can save and quit.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;However, after exiting Vim, my terminal is borked:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Whatever I type at the shell prompt is not echoed.&lt;/li&gt;&#xA;&lt;li&gt;Carriage returns don't appear at all, and line feeds only sometimes appear.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This goes on until I issue a &lt;a href=&quot;http://man.cx/tset(1)&quot;&gt;&lt;code&gt;reset(1)&lt;/code&gt;&lt;/a&gt; command to reinitialize the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a Vim bug, or is there a more satisfactory explanation for why it interacts with the terminal like that?  I've seen it happen on Vim up to version 7.3 (the version doesn't seem to matter) on Linux and various Unices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware of one workaround, namely &lt;code&gt;vim $(find . -name '*.java')&lt;/code&gt;.  Other workarounds would be welcome, though that's not my main question.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-05T15:35:39.133" LastActivityDate="2019-10-11T02:14:16.040" Title="Terminal borked after invoking Vim with xargs" Tags="|terminal|invocation|unix|quit|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="411" PostTypeId="2" ParentId="298" CreationDate="2015-02-05T09:00:15.537" Score="17" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/298/disable-syntax-highlighting-depending-on-file-size-and-type#comment291_299&quot;&gt;This comment&lt;/a&gt; by &lt;a href=&quot;https://vi.stackexchange.com/users/31/derobert&quot;&gt;derobert&lt;/a&gt; led me to the solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype xml if getfsize(@%) &amp;gt; 1000000 | setlocal syntax=OFF | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to reliably disable syntax highlighting in one buffer only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;autocmd BufReadPre&lt;/code&gt; was a bit of a red herring. &lt;code&gt;syntax off&lt;/code&gt;  works in the &lt;code&gt;BufReadPre&lt;/code&gt; context but not in the &lt;code&gt;Filetype&lt;/code&gt; context (and of course disables syntax globally); while &lt;code&gt;setlocal syntax=OFF&lt;/code&gt; does &lt;em&gt;not&lt;/em&gt; work in the &lt;code&gt;BufReadPre&lt;/code&gt; context but works in the &lt;code&gt;Filetype&lt;/code&gt; context.&lt;/p&gt;&#xA;" OwnerUserId="117" LastActivityDate="2015-02-05T09:00:15.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="412" PostTypeId="2" ParentId="410" CreationDate="2015-02-05T09:08:33.800" Score="13" Body="&lt;h3&gt;Workaround suggestion: use a buffer as a filesystem navigator&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;vim -&lt;/code&gt; command to read a list of paths from stdin. Vim's &lt;a href=&quot;https://vimhelp.appspot.com/starting.txt.html#--&quot;&gt;&lt;code&gt;:help --&lt;/code&gt;&lt;/a&gt; explains this:&lt;sup&gt;1&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Start editing a new buffer, which is filled with text that is read&#xA;  from stdin.  The commands that would normally be read from stdin will&#xA;  now be read from stderr.  Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -name &quot;*.c&quot; -print | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can then use &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; or &lt;kbd&gt;Ctrl-w&lt;/kbd&gt;&lt;kbd&gt;Ctrl-f&lt;/kbd&gt; to navigate to the file in the same buffer or in a new split window respectively.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Workaround suggestion: argument list&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Another great way is to use the Vim's argument list. The &lt;code&gt;:argadd **/*.java&lt;/code&gt; command will populate Vim's argument list with all the java files found inside the current directory recursively. You can then use the &lt;code&gt;:next&lt;/code&gt; and &lt;code&gt;:prev&lt;/code&gt; to move between the files.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; &lt;sub&gt;The first &lt;code&gt;-&lt;/code&gt; tells Vim you want to search the help for a command line option, the second is actually the command line flag you're searching for. Read &lt;a href=&quot;https://vimhelp.appspot.com/help.txt.html#help-context&quot;&gt;&lt;code&gt;:help help-context&lt;/code&gt;&lt;/a&gt; for more tricks like this.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="24" LastEditDate="2015-02-05T23:55:01.927" LastActivityDate="2015-02-05T23:55:01.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="413" PostTypeId="2" ParentId="406" CreationDate="2015-02-05T09:11:20.433" Score="6" Body="&lt;p&gt;If you use Linux (though not an exact answer), I recommend that you map &lt;kbd&gt;Caps Lock&lt;/kbd&gt; to &lt;kbd&gt;Ctrl&lt;/kbd&gt; and then use &lt;a href=&quot;https://github.com/alols/xcape&quot;&gt;xcape&lt;/a&gt; to adjust &lt;kbd&gt;Caps Lock&lt;/kbd&gt; behavior as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;when pressed by itself, &lt;kbd&gt;Caps Lock&lt;/kbd&gt; behaves like &lt;kbd&gt;Esc&lt;/kbd&gt;;&lt;/li&gt;&#xA;&lt;li&gt;when combined with another key, &lt;kbd&gt;Caps Lock&lt;/kbd&gt; behaves like &lt;kbd&gt;Ctrl&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So you can press both &lt;kbd&gt;Esc&lt;/kbd&gt; and a &lt;kbd&gt;Ctrl&lt;/kbd&gt; combination more easily than any other solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To remap the keys, try this command in Linux:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setxkbmap -option '' -option 'ctrl:nocaps'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It resets already existing options first and then set &lt;kbd&gt;Caps Lock&lt;/kbd&gt; as an additional &lt;kbd&gt;Ctrl&lt;/kbd&gt;. I know, weird name. If you don't want to reset options first, omit &lt;code&gt;-option ''&lt;/code&gt;. It may be useful if you have other options set in another place. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other options related to &lt;kbd&gt;Esc&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ grep escape /usr/share/X11/xkb/rules/base.lst&#xA;800:  caps:swapescape      Swap ESC and Caps Lock&#xA;801:  caps:escape          Make Caps Lock an additional ESC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://manpages.ubuntu.com/xcape.1&quot;&gt;&lt;code&gt;xcape&lt;/code&gt;&lt;/a&gt; allows you to use a modifier key as another key when pressed and released on its own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my &lt;code&gt;.xinitrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;... snip ...&#xA;setxkbmap -option '' -option 'ctrl:nocaps'&#xA;pkill xcape&#xA;xcape&#xA;exec xmonad&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="336" LastEditorUserId="205" LastEditDate="2015-02-26T03:47:28.043" LastActivityDate="2015-02-26T03:47:28.043" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="414" PostTypeId="1" CreationDate="2015-02-05T09:43:53.883" Score="13" ViewCount="455" Body="&lt;p&gt;Vim is so infinitely configurable.  However, devising a vimrc is a daunting task for novices and intermediate users.  Basically, you're expected to develop one from a blank slate by reading the documentation and picking up serendipitous tips from other users.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an intuitive configuration menu to help beginners generate and revise a vimrc?  Maybe a web-based tool, or something analogous to an options dialog in a word processor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/5eQ0c.png&quot; alt=&quot;LibreOffice preferences screenshot (CC-BY-SA 3.0 from th.libreoffice.org/get-help/installation/mac/)&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2016-09-29T23:25:33.657" Title="UI to personalize a vimrc without writing one from scratch" Tags="|vimrc|options|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="415" PostTypeId="1" AcceptedAnswerId="421" CreationDate="2015-02-05T11:56:50.290" Score="16" ViewCount="4561" Body="&lt;p&gt;For some reason or another I often divide the code into subsections separated by headers like these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;################################################################################&#xA;#################################### LOAD ######################################&#xA;################################################################################&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These are 3 80-column wide lines of &lt;code&gt;#&lt;/code&gt; with a title centered in the middle.&#xA;So far I haven't find a quick way to generate these in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I usually do is something along the lines of &lt;code&gt;80i#&lt;/code&gt; and then &lt;code&gt;yypp&lt;/code&gt; to give me 3 lines, but then I need to navigate to the middle and add text. I usually do this with replace, but replace does not center the header inside &lt;code&gt;#&lt;/code&gt;…&lt;code&gt;#&lt;/code&gt; So I delete the excess of &lt;code&gt;#&lt;/code&gt;'s manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to center the text in the middle row? And what would be a faster way to achieve this result?&lt;/p&gt;&#xA;" OwnerUserId="307" LastEditorUserId="24" LastEditDate="2015-02-06T00:11:12.360" LastActivityDate="2017-04-23T17:34:39.210" Title="Adding 80-column wide comment header block with centered text" Tags="|alignment|comments|ascii-art|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="416" PostTypeId="2" ParentId="42" CreationDate="2015-02-05T12:06:27.177" Score="8" Body="&lt;p&gt;You will need to use &lt;code&gt;contains&lt;/code&gt; keyword in a syntax file (see &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#:syn-contains&quot; rel=&quot;nofollow noreferrer&quot;&gt;:help contains&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example of usage, see how the pythonDocTest syntax region &lt;a href=&quot;https://github.com/hdima/python-syntax/blob/master/syntax/python.vim#L347&quot; rel=&quot;nofollow noreferrer&quot;&gt;is defined&lt;/a&gt; and &lt;a href=&quot;https://github.com/hdima/python-syntax/blob/master/syntax/python.vim#L271&quot; rel=&quot;nofollow noreferrer&quot;&gt;used&lt;/a&gt; within a Python syntax file.&lt;/p&gt;&#xA;" OwnerUserId="182" LastEditorUserId="182" LastEditDate="2017-12-05T01:20:01.560" LastActivityDate="2017-12-05T01:20:01.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="417" PostTypeId="2" ParentId="415" CreationDate="2015-02-05T12:28:33.897" Score="5" Body="&lt;p&gt;First, you need to &lt;code&gt;:set expandtab&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;80&lt;/code&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;#&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; to create the top line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Y&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; to duplicate it&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;O&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;code&gt;LOAD&lt;/code&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:center 80&lt;/code&gt; (The &lt;code&gt;80&lt;/code&gt; may be omitted, depending on your &lt;code&gt;textwidth&lt;/code&gt; setting.)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;#&lt;/kbd&gt; to fill the left side (using visual select and replace)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; to fill the right side (by duplicating some characters from the bottom line)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="24" LastEditorUserId="88" LastEditDate="2015-02-05T12:46:22.803" LastActivityDate="2015-02-05T12:46:22.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="418" PostTypeId="2" ParentId="415" CreationDate="2015-02-05T12:32:16.167" Score="3" Body="&lt;p&gt;I would use a vimscript function for that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Header(width, word)&#xA;    let a:inserted_word = ' ' . a:word . ' '&#xA;    let a:word_width = strlen(a:inserted_word)&#xA;    let a:length_before = (a:width - a:word_width) / 2&#xA;    let a:hashes_before = repeat('#', a:length_before)&#xA;    let a:hashes_after = repeat('#', a:width - (a:word_width + a:length_before))&#xA;    let a:hash_line = repeat('#', a:width)&#xA;    let a:word_line = a:hashes_before . a:inserted_word . a:hashes_after&#xA;&#xA;    :put =a:hash_line&#xA;    :put =a:word_line&#xA;    :put =a:hash_line&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it could be called like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;: call Header(80, 'Hello')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="182" LastEditorUserId="182" LastEditDate="2015-02-05T15:47:13.723" LastActivityDate="2015-02-05T15:47:13.723" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="420" PostTypeId="2" ParentId="415" CreationDate="2015-02-05T12:51:39.553" Score="2" Body="&lt;p&gt;Or you could use visual blocks:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Make sure you already have at least three blank lines at the top, then &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;80&lt;/kbd&gt;&lt;kbd&gt;L&lt;/kbd&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;R&lt;/kbd&gt;&lt;kbd&gt;#&lt;/kbd&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move to the middle of the block (you're going to have to eyeball this)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; and select the area of the block you want to remove&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;R&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Go to beginning of empty space, hit &lt;kbd&gt;R&lt;/kbd&gt; and type your header.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Granted, it's not the most perfect way to create a header, as you have to eyeball it, but it's an interesting case for the Visual Block selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Result&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#################################################################################&#xA;##########################    this is a header      #############################&#xA;#################################################################################&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="133" LastActivityDate="2015-02-05T12:51:39.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="421" PostTypeId="2" ParentId="415" CreationDate="2015-02-05T12:52:03.253" Score="26" Body="&lt;p&gt;Here's a slightly more efficient / easier method. Type it with the cursor at the beginning of the line of text (i.e. &lt;code&gt;LOAD&lt;/code&gt;) that you want to center.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:center 80&amp;lt;cr&amp;gt;&lt;/code&gt;: center the text with Vim's built in function&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;hhv0r#&lt;/code&gt;: add the &lt;code&gt;#&lt;/code&gt;s on the left&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;40A#&amp;lt;esc&amp;gt;&lt;/code&gt;: add plenty of &lt;code&gt;#&lt;/code&gt;s on the right&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d80|&lt;/code&gt;: delete excess &lt;code&gt;#&lt;/code&gt;s on the right&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;YppVr#kk.&lt;/code&gt;: add top and bottom &lt;code&gt;#&lt;/code&gt;s&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, the full command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:center 80&amp;lt;cr&amp;gt;hhv0r#A&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;40A#&amp;lt;esc&amp;gt;d80&amp;lt;bar&amp;gt;YppVr#kk.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could put something like this in your .vimrc in order to add a convenient mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-b&amp;gt; :center 80&amp;lt;cr&amp;gt;hhv0r#A&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;40A#&amp;lt;esc&amp;gt;d80&amp;lt;bar&amp;gt;YppVr#kk.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Mini-screencast demonstration:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/SYuBs.gif&quot; alt=&quot;demonstration&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="88" LastEditDate="2015-02-05T14:49:38.817" LastActivityDate="2015-02-05T14:49:38.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="422" PostTypeId="1" AcceptedAnswerId="423" CreationDate="2015-02-05T13:39:09.987" Score="209" ViewCount="263561" Body="&lt;p&gt;When I work on files in python, I sometimes mistake tabs for spaces and vice versa. Is there a way I can get Vim to display a character for a tab instead of a tab?&lt;/p&gt;&#xA;" OwnerUserId="25" LastEditorUserId="10604" LastEditDate="2023-06-04T19:14:07.853" LastActivityDate="2023-06-04T19:14:07.853" Title="How can I display tabs as characters?" Tags="|whitespace|tab-characters|" AnswerCount="9" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="423" PostTypeId="2" ParentId="422" CreationDate="2015-02-05T13:46:20.687" Score="221" Body="&lt;p&gt;Yes, use listchars:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list&#xA;set listchars=tab:&amp;gt;-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you put these two lines in your .vimrc, tabs will be shown as &lt;code&gt;&amp;gt;&lt;/code&gt; for the start position and &lt;code&gt;-&lt;/code&gt; through the rest of the tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Sidenote: listchars can also show trailing spaces with &lt;code&gt;trail:x&lt;/code&gt; (replace &lt;code&gt;x&lt;/code&gt; with the character you want to use for a trailing space), which can be useful as well.)&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-05T13:46:20.687" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="425" PostTypeId="2" ParentId="422" CreationDate="2015-02-05T13:49:20.350" Score="7" Body="&lt;p&gt;Easiest method is to do &lt;code&gt;:set list&lt;/code&gt;, which will show tabs as &lt;code&gt;^I&lt;/code&gt; and end of line as &lt;code&gt;$&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like to use a mapping that calls&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set invlist &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to toggle between regular display and list display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap &amp;lt;leader&amp;gt;l :set invlist&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows me to quickly check if there are tab vs space problems and then go back to a regular display.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-02-05T15:08:50.300" LastActivityDate="2015-02-05T15:08:50.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="426" PostTypeId="2" ParentId="414" CreationDate="2015-02-05T14:09:23.250" Score="4" Body="&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: this answer is obviously wrong as other answers link to the tools.&#xA;However, this reply might have same value as to the alternate (maybe even better) approach to the root problem thread author has.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I don't think such a tool exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But to answer the &quot;root&quot; of your question - you definitely don't have to start writing your &lt;code&gt;.vimrc&lt;/code&gt; from scratch. Common practice among beginning users is to look into &lt;code&gt;.vimrc&lt;/code&gt; files of expert vim users. Here are some examples you could learn a lot from:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tpope/tpope/blob/master/.vimrc&quot; rel=&quot;nofollow&quot;&gt;Tim Pope's vimrc&lt;/a&gt; - creator of many ingenious vim plugins&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/nelstrom/dotfiles/blob/master/vimrc&quot; rel=&quot;nofollow&quot;&gt;Drew Neil's vimrc&lt;/a&gt; - author of vimcasts.org&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/garybernhardt/dotfiles/blob/master/.vimrc&quot; rel=&quot;nofollow&quot;&gt;Gary Bernhard's vimrc&lt;/a&gt; - creator of destroyallsoftware.com and a well known vim user&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://bitbucket.org/sjl/dotfiles/src/603bb1ae9da27c6e08ab115df1cb5d8f6a1442c3/vim/vimrc?at=default&quot; rel=&quot;nofollow&quot;&gt;Steve Losh's vimrc&lt;/a&gt; - the author of popular VimL book and a couple popular plugins&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Lastly, there's Tim Pope's plugin &lt;a href=&quot;https://github.com/tpope/vim-sensible&quot; rel=&quot;nofollow&quot;&gt;vim-sensible&lt;/a&gt; that provides some fundamentals and I'd recommend installing it.&lt;/p&gt;&#xA;" OwnerDisplayName="user345" LastEditorDisplayName="user345" LastEditDate="2015-05-28T17:22:12.063" LastActivityDate="2015-05-28T17:22:12.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="427" PostTypeId="2" ParentId="414" CreationDate="2015-02-05T14:12:37.083" Score="13" Body="&lt;p&gt;One website for generating &lt;code&gt;.vimrc&lt;/code&gt;s is &lt;a href=&quot;http://vimconfig.com/&quot; rel=&quot;nofollow&quot;&gt;http://vimconfig.com/&lt;/a&gt; .  It's fairly basic — just enough to get started on  (line numbers, search highlighting, etc.).&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="24" LastEditDate="2016-09-29T23:25:33.657" LastActivityDate="2016-09-29T23:25:33.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="428" PostTypeId="2" ParentId="414" CreationDate="2015-02-05T14:16:08.527" Score="14" Body="&lt;p&gt;You can use the built-in &lt;code&gt;:options&lt;/code&gt; and &lt;code&gt;:mkvimrc&lt;/code&gt; (see &lt;code&gt;:help :options&lt;/code&gt; and &lt;code&gt;:help :mkvimrc&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But… creating your own &lt;code&gt;~/.vimrc&lt;/code&gt; is a daunting task &lt;em&gt;only&lt;/em&gt; if you want the perfect &lt;code&gt;vimrc&lt;/code&gt; &quot;right now&quot;. If you are not patient enough, there are dozens of alternative editors with less options and GUI dialogs. Vim is not an editor you can pick up in an afternoon: expect work and reading.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-02-05T14:16:08.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="429" PostTypeId="2" ParentId="365" CreationDate="2015-02-05T14:29:01.293" Score="14" Body="&lt;p&gt;It's certainly possible to use a different background colour for syntax-highlighted elements. Just define the &lt;code&gt;guibg&lt;/code&gt; and &lt;code&gt;ctermbg&lt;/code&gt; colours in your &lt;code&gt;hilight&lt;/code&gt; command. The former sets the background colour for GUI Vim, and the latter for terminal Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this has the important limitation that it can only set the background colours for characters that actually exist in the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result of this is that the background colour cannot extend past the end of the text on a line to the edge of the window, so the colouring of the code &lt;em&gt;blocks&lt;/em&gt; shown in your example is not possible:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Oq3ZY.png&quot; alt=&quot;An example of the background colouring possible in Vim&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also change the background colour of entire lines using the Sign feature. (See &lt;code&gt;linehl&lt;/code&gt; in &lt;code&gt;:help sign.txt&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gusFo.png&quot; alt=&quot;An example of colouring the background with signs&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, note that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Doing so requires writing code to place signs on each line that needs to be coloured and keep these updated as the file's contents change,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;By default, when placing a sign, the sign column will be displayed at the left of the window. It is possible to change the colouring of the sign column with the &lt;code&gt;SignColumn&lt;/code&gt; highlight group, and in more recent versions of Vim it can be removed entirely. (See &lt;code&gt;:help 'signcolumn'&lt;/code&gt;.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For example, to adapt &lt;a href=&quot;https://vi.stackexchange.com/a/2210/343&quot;&gt;Carpetsmoker's solution&lt;/a&gt; to use the (more robust) sign mechanism, you could do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Define a highlight group and a sign that uses it&#xA;highlight default markdownCodeBlock ctermbg=230 guibg=lightyellow&#xA;sign define codeblock linehl=markdownCodeBlock&#xA;&#xA;&quot; Use signs to highlight code blocks&#xA;function! MarkdownBlocks()&#xA;    function! s:applySign(idx, val)&#xA;        if a:val[0] == &quot;\t&quot; || a:val[:3] == &quot;    &quot;&#xA;            let l = a:idx + 1&#xA;            execute &quot;sign place &quot; . l . &quot; line=&quot; . l . &quot; name=codeblock file=&quot; . expand(&quot;%:p&quot;)&#xA;        endif&#xA;    endfunction&#xA;&#xA;    &quot; Remove old signs&#xA;    execute &quot;sign unplace * file=&quot; . expand(&quot;%:p&quot;)&#xA;&#xA;    &quot; Get all lines in a list&#xA;    let l:lines = getline(1, line('$'))&#xA;    &quot; Add new signs&#xA;    call map(l:lines, function('s:applySign'))&#xA;endfunction&#xA;&#xA;&quot; Set signs on loading the file, leaving insert mode, and after writing it&#xA;au FileType markdown call MarkdownBlocks()&#xA;au InsertLeave *.markdown call MarkdownBlocks()&#xA;au BufWritePost *.markdown call MarkdownBlocks()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This simplifies the code somewhat, and has fewer caveats than Carpetsmoker's version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;@ChristianBrabandt&lt;/a&gt;'s &lt;a href=&quot;https://github.com/chrisbra/DynamicSigns&quot; rel=&quot;nofollow noreferrer&quot;&gt;DynamicSigns&lt;/a&gt; plugin makes using the Sign feature for this purpose easier: he describes how use it to do so in &lt;a href=&quot;https://vi.stackexchange.com/a/3759/343&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-12-23T15:12:22.670" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="430" PostTypeId="2" ParentId="422" CreationDate="2015-02-05T14:31:34.320" Score="79" Body="&lt;p&gt;The basic answer is &lt;code&gt;:set list&lt;/code&gt;, which causes tabs to display as &lt;code&gt;^I&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I recommend going beyond that.  Just &lt;code&gt;:set list&lt;/code&gt; is problematic in that it fails to preserve visual alignment on screen.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%.o: %.cpp&#xA;^Ig++ -c $&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't look good, especially when you expect the &lt;code&gt;g&lt;/code&gt; of &lt;code&gt;g++&lt;/code&gt; to appear under the first &lt;code&gt;p&lt;/code&gt; of &lt;code&gt;cpp&lt;/code&gt; (assuming &lt;code&gt;tabstop=8&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, I suggest that in your &lt;code&gt;.vimrc&lt;/code&gt; you put something like &lt;code&gt;:set listchars=tab:␉·&lt;/code&gt;  (To be clear, that's Unicode character &lt;a href=&quot;https://codepoints.net/U+2409&quot;&gt;U+2409 SYMBOL FOR HORIZONTAL TABULATION&lt;/a&gt; followed by &lt;a href=&quot;https://codepoints.net/U+00B7&quot;&gt;U+00B7 MIDDLE DOT&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As explained in &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27listchars%27&quot;&gt;&lt;code&gt;:help listchars&lt;/code&gt;&lt;/a&gt;, a two-character setting for &lt;code&gt;tab:xy&lt;/code&gt; causes visual alignment to be preserved:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;tab:xy        Two characters to be used to show a tab.  The first&#xA;              char is used once.  The second char is repeated to&#xA;              fill the space that the tab normally occupies.&#xA;              &quot;tab:&amp;gt;-&quot; will show a tab that takes four spaces as&#xA;              &quot;&amp;gt;---&quot;.  When omitted, a tab is show as ^I.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The example above would appear on screen as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%.o: %.cpp&#xA;␉·······g++ -c $&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Personally, I go all-out with my &lt;code&gt;listchars&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set listchars=eol:⏎,tab:␉·,trail:␠,nbsp:⎵&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For &lt;code&gt;eol&lt;/code&gt;, I use &lt;a href=&quot;https://codepoints.net/U+23CE&quot;&gt;U+23CE RETURN SYMBOL&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;For &lt;code&gt;trail&lt;/code&gt;, I use &lt;a href=&quot;https://codepoints.net/U+2420&quot;&gt;U+2420 SYMBOL FOR SPACE&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;For &lt;code&gt;nbsp&lt;/code&gt;, I use &lt;a href=&quot;https://codepoints.net/U+23B5&quot;&gt;U+23B5 BOTTOM SQUARE BRACKET&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These characters are distinctive enough that they rarely appear literally in document text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To type these special characters into your &lt;code&gt;vimrc&lt;/code&gt;, type &lt;kbd&gt;Ctrl-v&lt;/kbd&gt;&lt;kbd&gt;u&lt;/kbd&gt;&lt;code&gt;23CE&lt;/code&gt; while in Insert Mode, as explained in &lt;a href=&quot;https://vimhelp.appspot.com/mbyte.txt.html#utf-8-typing&quot;&gt;&lt;code&gt;:help utf-8-typing&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-05T14:44:01.947" LastActivityDate="2015-02-05T14:44:01.947" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="431" PostTypeId="1" AcceptedAnswerId="433" CreationDate="2015-02-05T15:17:12.390" Score="58" ViewCount="7242" Body="&lt;p&gt;Sometimes I have selected a visual selection with, for example, &lt;code&gt;Vjjjjj&lt;/code&gt;, only to realize later that I should have started the selection one line higher. However, pressing &lt;code&gt;k&lt;/code&gt; simply decreases the lower range of the selection rather than moving the entire selection up one line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a &lt;em&gt;visual&lt;/em&gt;ization (ha, ha), where the bolded lines are the ones I have selected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;Do not select this line&#xA;Do not select this line&#xA;Select this line!        &#xA;&lt;b&gt;Select this line!&lt;/b&gt;        &amp;lt;-- I pressed &lt;kbd&gt;V&lt;/kbd&gt; here...&#xA;&lt;b&gt;Select this line!&lt;/b&gt;&#xA;&lt;b&gt;Select this line!&lt;/b&gt;&#xA;&lt;b&gt;Select this line!&lt;/b&gt;&#xA;&lt;b&gt;Select this line!&lt;/b&gt;        &amp;lt;-- ... and moved to here. But I should have started my&#xA;Do not select this line      selection one line higher!&#xA;Do not select this line&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I extend a visual selection by moving its starting point in the other direction? If this is not possible, is there any way to add a mapping in my .vimrc that enables me to do so?&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="24" LastEditDate="2015-02-19T10:08:23.930" LastActivityDate="2015-02-19T10:08:23.930" Title="Expand a visual selection in the other direction" Tags="|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="432" PostTypeId="1" AcceptedAnswerId="435" CreationDate="2015-02-05T15:24:16.437" Score="25" ViewCount="8893" Body="&lt;p&gt;If I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ less file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And press &lt;code&gt;q&lt;/code&gt; to exit &lt;code&gt;less&lt;/code&gt;, I stil see the same text as I had on the screen when &lt;code&gt;less&lt;/code&gt; was still running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;:q&lt;/code&gt;, my terminal is blanked...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screenshots of my terminal after quiting &lt;code&gt;less&lt;/code&gt; and &lt;code&gt;vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/RXIAc.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/tniz2.png&quot; alt=&quot;enter image description here&quot;&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I somehow prevent this? This is &lt;em&gt;only&lt;/em&gt; on my Linux system. My FreeBSD system actually works as expected (using the same software/settings all around, &lt;code&gt;TERM&lt;/code&gt; is &lt;code&gt;xterm-color&lt;/code&gt; for both, &lt;code&gt;vim -u NONE&lt;/code&gt; doesn't make a difference).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of what I would like to have:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mxeMe.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="24" LastEditDate="2015-02-05T15:35:00.487" LastActivityDate="2015-02-06T13:15:21.030" Title="Prevent Vim from clearing the terminal after exit" Tags="|terminal|linux|quit|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="433" PostTypeId="2" ParentId="431" CreationDate="2015-02-05T15:24:46.593" Score="88" Body="&lt;p&gt;You can use the &lt;code&gt;o&lt;/code&gt; command, from &lt;code&gt;:help v_o&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Go to Other end of highlighted text: The current         cursor&#xA;  position becomes the start of the highlighted     text and the cursor&#xA;  is moved to the other end of the     highlighted text.  The&#xA;  highlighted area remains the      same.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So when you have finished selecting the lines you want press &lt;kbd&gt;o&lt;/kbd&gt;, the cursor will move to the beginning of the selection and you can select the line before by pressing &lt;kbd&gt;k&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13" LastActivityDate="2015-02-05T15:24:46.593" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="434" PostTypeId="1" AcceptedAnswerId="437" CreationDate="2015-02-05T15:32:52.710" Score="1" ViewCount="189" Body="&lt;p&gt;When I write an answer on this site, I often want to link to a part of Vim's &lt;code&gt;:help&lt;/code&gt; pages; &lt;a href=&quot;http://vimhelp.appspot.com/&quot; rel=&quot;nofollow&quot;&gt;http://vimhelp.appspot.com/&lt;/a&gt; has an online version of that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'm too lazy to manually lookup the page online, and add links for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to do is somehow make Vim generate an valid URL to part of the helpfile I'm currently viewing. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo WebHelp()&#xA;[`:help split`](http://vimhelp.appspot.com/windows.txt.html#%3Asplit)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The links on vimhelp.appspot seem to correspond to the same file&#xA; &amp;amp; tags as Vim uses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can get the current file with &lt;code&gt;:echo expand('%')&lt;/code&gt; (&lt;code&gt;windows.txt&lt;/code&gt; in the above example), and I know how too url-encode string, but I'm not sure how to get the nearest tag the cursor is at? (&lt;code&gt;:split&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-05T16:33:20.090" Title="Get name of nearest tag to the cursor" Tags="|tags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="435" PostTypeId="2" ParentId="432" CreationDate="2015-02-05T15:38:02.933" Score="30" Body="&lt;p&gt;By default VIM, when terminating, sends the string configured with the option &lt;code&gt;t_te&lt;/code&gt; to the hosting terminal to tell it to clear the screen. To avoid it just &lt;code&gt;:set t_te=&lt;/code&gt; to send nothing to the terminal and avoid screen clearing. See &lt;code&gt;:help term&lt;/code&gt; form more information about terminal capabilities.&lt;/p&gt;&#xA;" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2015-02-05T16:00:11.673" LastActivityDate="2015-02-05T16:00:11.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="436" PostTypeId="2" ParentId="432" CreationDate="2015-02-05T16:10:56.440" Score="3" Body="&lt;p&gt;As you are using an xterm you could use its main and alternate screen buffers for screen swapping, as in &lt;a href=&quot;https://github.com/jalanb/dotjab/blob/master/vim/vimrc#L263&quot; rel=&quot;nofollow&quot;&gt;this section from my .vimrc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;term == &quot;linux&quot;&#xA;    set t_ti=^[[?1049h&#xA;    set t_te=^[[?1049l&#xA;endif                                                       &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;^[&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; literal text, it is the escape character, use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; followed by &lt;kbd&gt;Esc&lt;/kbd&gt; to insert it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These vim commands add the relevant commands which can be missing from the linux terminfo entry. More info at&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help xterm-screens&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="182" LastEditorUserId="51" LastEditDate="2015-02-06T13:15:21.030" LastActivityDate="2015-02-06T13:15:21.030" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="437" PostTypeId="2" ParentId="434" CreationDate="2015-02-05T16:33:20.090" Score="2" Body="&lt;p&gt;Tags in help files are enclosed within &lt;code&gt;*&lt;/code&gt; characters. So to find the closest one above the current position I would search with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ?\*[^*]\+\*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As there can be a number of such tags after the main/header tag, I would prefer to find one at end of line, and to then position the cursor after the first &lt;code&gt;*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?\*\zs[^*]\+\*$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then yank as far as the next &lt;code&gt;*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y/\*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This leaves the most recent &quot;header tag&quot; copied to the buffer, whence it can be pasted into (what I assume is) your &lt;code&gt;WebHelp()&lt;/code&gt; function&lt;/p&gt;&#xA;" OwnerUserId="182" LastActivityDate="2015-02-05T16:33:20.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="438" PostTypeId="1" AcceptedAnswerId="441" CreationDate="2015-02-05T17:33:14.477" Score="12" ViewCount="175" Body="&lt;p&gt;Occasionally, when I'm searching the help system for a particular topic, it will be shadowed by a different topic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I do &lt;code&gt;:h display&lt;/code&gt; I get help for something involving &quot;GUI Resources&quot;, when I wanted help for the &quot;display&quot; setting (as in &lt;code&gt;set display=lastline&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I find these &quot;shadowed&quot; topics, or list the most relevant matching topics?&lt;/p&gt;&#xA;" OwnerUserId="126" LastEditorUserId="51" LastEditDate="2015-02-05T18:06:29.027" LastActivityDate="2022-07-27T10:00:09.437" Title="Shadowed terms in help" Tags="|help-system|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="439" PostTypeId="1" AcceptedAnswerId="440" CreationDate="2015-02-05T17:33:40.370" Score="118" ViewCount="31027" Body="&lt;p&gt;The standard &lt;kbd&gt;J&lt;/kbd&gt; command for joining lines replaces the newline character(s) with a space. It's useful when editing 'literature' but can be troublesome if I, say, edit a hex dump by hand if I forget to remove the superfluous space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a quick &amp;amp; easy method to join two lines without producing a space between them?&lt;/p&gt;&#xA;" OwnerUserId="351" LastEditorUserId="24" LastEditDate="2015-02-06T00:39:18.160" LastActivityDate="2020-04-11T11:33:13.440" Title="How to join lines without producing a space?" Tags="|whitespace|line-breaks|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="440" PostTypeId="2" ParentId="439" CreationDate="2015-02-05T17:56:01.997" Score="144" Body="&lt;p&gt;The &lt;code&gt;gJ&lt;/code&gt; mapping does this; from &lt;code&gt;:help gJ&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Join [count] lines, with a minimum of two lines. Don't insert or remove any spaces. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could rebind it to &lt;code&gt;J&lt;/code&gt;, if you want to save a keystroke:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap J gJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this doesn't &lt;em&gt;remove&lt;/em&gt; any spaces, so if either the current line ends with a space or next line starts with one or more spaces they will be left as is; so this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hello&#xA;    world&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hello    world&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We could use &lt;code&gt;Jx&lt;/code&gt; in this case, then it will be &lt;code&gt;Helloworld&lt;/code&gt;, but that won't work in all cases; from the help:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Join the highlighted lines, with a minimum of two lines.  Remove the indent and insert up to two&#xA;  spaces&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;These commands, except &quot;gJ&quot;, insert one space in place of the  unless&#xA;  there is trailing white space or the next line starts with a ')'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So in some cases more than one space or no space is inserted. As far as I can&#xA;see, there is no easy way to change this behaviour; I created a function to&#xA;modify &lt;code&gt;gJ&lt;/code&gt; to always join without spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Like gJ, but always remove spaces&#xA;fun! s:join_spaceless()&#xA;    execute 'normal! gJ'&#xA;&#xA;    &quot; Remove character under the cursor if it's whitespace.&#xA;    if matchstr(getline('.'), '\%' . col('.') . 'c.') =~ '\s'&#xA;        execute 'normal! dw'&#xA;    endif&#xA;endfun&#xA;&#xA;&quot; Map it to a key&#xA;nnoremap &amp;lt;Leader&amp;gt;J :call &amp;lt;SID&amp;gt;join_spaceless()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want, you can add &lt;code&gt;let save = winsaveview()&lt;/code&gt; at the start of the function, and &lt;code&gt;call winrestview(save)&lt;/code&gt; at the end to prevent the cursor from moving (but the current behaviour is the same as &lt;code&gt;gJ&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;code&gt;:help J&lt;/code&gt;, &lt;code&gt;:help 'joinspaces'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-04-11T11:33:13.440" LastActivityDate="2020-04-11T11:33:13.440" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="441" PostTypeId="2" ParentId="438" CreationDate="2015-02-05T18:00:14.193" Score="16" Body="&lt;p&gt;Setting names are always surrounded by quotes, so use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'display'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to get the page you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You get some useful completions when pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;D&lt;/kbd&gt;, ie:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help display&amp;lt;^D&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will give you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-display  :display  'display'  :syn-display  strdisplaywidth()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As completions :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus tip:&lt;br&gt;&#xA;If you use &lt;code&gt;:set wildmenu&lt;/code&gt;, this will also work with &lt;kbd&gt;Tab&lt;/kbd&gt;, and you will have some additional completion features.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-05T19:06:25.957" LastActivityDate="2015-02-05T19:06:25.957" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="442" PostTypeId="1" AcceptedAnswerId="443" CreationDate="2015-02-05T18:37:56.843" Score="4" ViewCount="288" Body="&lt;p&gt;I copy several lines of text and open a brand new file.&lt;/p&gt;&#xA;&lt;p&gt;If I paste with &lt;code&gt;p&lt;/code&gt;, I get an empty line above the pasted text.&lt;/p&gt;&#xA;&lt;p&gt;If I paste with &lt;code&gt;P&lt;/code&gt;, I get an empty line below the pasted text.&lt;/p&gt;&#xA;&lt;p&gt;How can I paste and remove/replace/delete the current line?&lt;/p&gt;&#xA;" OwnerUserId="226" LastEditorUserId="23502" LastEditDate="2022-10-28T07:16:13.677" LastActivityDate="2022-10-28T07:16:13.677" Title="How to paste and remove current line?" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="443" PostTypeId="2" ParentId="442" CreationDate="2015-02-05T18:41:43.283" Score="9" Body="&lt;p&gt;Select the current line in visual mode before pasting: &lt;code&gt;Vp&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user2" LastActivityDate="2015-02-05T18:41:43.283" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="444" PostTypeId="1" AcceptedAnswerId="445" CreationDate="2015-02-05T19:15:29.393" Score="330" ViewCount="256418" Body="&lt;p&gt;Quite often I am working with files that are version controlled, so it is possible for changes to be made to them outside of Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is a quick way to reload the file without having to close and reopen Vim? And is there a way to do this automatically?&lt;/p&gt;&#xA;" OwnerUserId="89" LastEditorUserId="24" LastEditDate="2015-02-06T00:13:33.943" LastActivityDate="2024-02-21T17:20:55.183" Title="How do I reload the current file?" Tags="|file-operations|load|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="445" PostTypeId="2" ParentId="444" CreationDate="2015-02-05T19:18:05.133" Score="431" Body="&lt;p&gt;The command you want is &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#edit-a-file&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:e&lt;/code&gt;&lt;/a&gt; (short for &lt;code&gt;:edit&lt;/code&gt;). If you use &lt;code&gt;:edit!&lt;/code&gt; it will discard local changes and reload.&lt;/p&gt;&#xA;&lt;p&gt;You can also have vim do this automatically with &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27autoread%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;set autoread&lt;/code&gt;&lt;/a&gt; in your vimrc.&lt;/p&gt;&#xA;" OwnerUserId="126" LastEditorUserId="1065" LastEditDate="2024-02-21T17:20:55.183" LastActivityDate="2024-02-21T17:20:55.183" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="446" PostTypeId="2" ParentId="338" CreationDate="2015-02-05T19:19:05.877" Score="3" Body="&lt;p&gt;You can't do the dishes with Vim. From &lt;a href=&quot;http://vimhelp.appspot.com/howto.txt.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help howdoi&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|You can't! (yet)|  do dishes using Vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-02-05T19:25:11.960" LastActivityDate="2015-02-05T19:25:11.960" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="447" PostTypeId="2" ParentId="338" CreationDate="2015-02-05T19:23:01.563" Score="3" Body="&lt;pre&gt;&lt;code&gt;:help!&#xA;E478: Don't panic!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not in big friendly letters on the cover though&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-05T19:23:01.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="448" PostTypeId="2" ParentId="338" CreationDate="2015-02-05T19:24:06.633" Score="2" Body="&lt;pre&gt;&lt;code&gt;:help 42&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;What is the meaning of life, the universe and everything?  42&#xA;Douglas Adams, the only person who knew what this question really was about&#xA;is now dead, unfortunately.  So now you might wonder what the meaning of&#xA;death is...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-05T19:24:06.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="449" PostTypeId="2" ParentId="338" CreationDate="2015-02-05T19:25:26.490" Score="4" Body="&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/The_Treachery_of_Images&quot; rel=&quot;nofollow&quot;&gt;Vim is surreallist&lt;/a&gt;. From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#bar&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help bar&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|           To screen column [count] in the current line.&#xA;            |exclusive| motion.  Ceci n'est pas une pipe.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-02-05T19:25:26.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="450" PostTypeId="2" ParentId="338" CreationDate="2015-02-05T19:25:42.590" Score="3" Body="&lt;pre&gt;&lt;code&gt;:Ni!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Do you demand a shrubbery?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-05T19:25:42.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="451" PostTypeId="2" ParentId="338" CreationDate="2015-02-05T19:26:48.813" Score="1" Body="&lt;pre&gt;&lt;code&gt;:help UserGettingBored&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        UserGettingBored&#xA;UserGettingBored                When the user presses the same key 42 times.&#xA;                                Just kidding! :-)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Older versions of Vim (7.2?) actually seem to have had a different description for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help UserGettingBored&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *UserGettingBored*&#xA;UserGettingBored        When the user hits CTRL-C.  Just kidding! :-)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-05T20:59:54.230" LastActivityDate="2015-02-05T20:59:54.230" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="452" PostTypeId="2" ParentId="338" CreationDate="2015-02-05T19:27:26.747" Score="3" Body="&lt;p&gt;Vim understands that nuns can live in monasteries too. &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#map-modes&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help map-modes&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nunmap can also be used outside of a monastery.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-02-05T19:27:26.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="453" PostTypeId="2" ParentId="265" CreationDate="2015-02-05T19:33:29.130" Score="0" Body="&lt;p&gt;If you just want to remove all the eqnarray's in the source, first run an &lt;code&gt;ack&lt;/code&gt; or a recursive &lt;code&gt;grep&lt;/code&gt; or &lt;code&gt;sed&lt;/code&gt; in your own personal fork of &lt;a href=&quot;https://github.com/vim-latex/vim-latex&quot; rel=&quot;nofollow&quot;&gt;the github repo&lt;/a&gt; to find all occurrences of the word, so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd $vim_latex_dir&#xA;$ ack 'eqnarray'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll observe that 5 document files have it, as well as the ftplugin files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ftplugin/latex-suite/envmacros.vim&#xA;ftplugin/latex-suite/outline.py&#xA;ftplugin/latex-suite/texrc&#xA;ftplugin/latex-suite/wizardfuncs.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is where the surgery happens--you'll need to go to the line numbers of the occurrences in each file and examine the extent of the cancer--what I mean by this is that in some files you can simply remove the entire line of the match, whereas in other places you may need to remove/alter an entire function or very precisely alter a part of a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regardless, if you proceed to do as described above and manage to remove all the eqnarrays, you'll have your own version of vim-latex that no longer recognizes eqnarray. &lt;/p&gt;&#xA;" OwnerUserId="44" LastActivityDate="2015-02-05T19:33:29.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="454" PostTypeId="1" AcceptedAnswerId="2285" CreationDate="2015-02-05T19:46:36.720" Score="211" ViewCount="203018" Body="&lt;p&gt;It's pretty common when programming or opening text files to encounter files with trailing whitespace at the end of a line. vim has a way to show this by setting the &lt;code&gt;trail&lt;/code&gt; option in the &lt;code&gt;listchars&lt;/code&gt; option and then turning &lt;code&gt;list&lt;/code&gt; on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, what's the easiest way to eliminate that trailing whitespace globally across the whole of a file (ideally without a plugin)?&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="24" LastEditDate="2015-02-06T18:42:00.640" LastActivityDate="2023-08-06T12:06:59.243" Title="What's the simplest way to strip trailing whitespace from all lines in a file?" Tags="|whitespace|line-breaks|" AnswerCount="6" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="455" PostTypeId="2" ParentId="130" CreationDate="2015-02-05T19:49:54.907" Score="5" Body="&lt;p&gt;I find the &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-commentary plugin&lt;/a&gt; is by far and away the easiest way to do this. Select a range of lines, then just hit &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;. It will use an appropriate commenting character for the filetype you have open. It's even possible without any visual selection to uncomment adjacent commented lines with  &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;u&lt;/kbd&gt; or &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="1841" LastEditDate="2017-01-15T17:37:35.367" LastActivityDate="2017-01-15T17:37:35.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="456" PostTypeId="2" ParentId="454" CreationDate="2015-02-05T19:52:31.113" Score="305" Body="&lt;p&gt;The &amp;quot;simplest&amp;quot; way is to just use &lt;code&gt;:substitute&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\s\+$//e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s&lt;/code&gt; to run &lt;code&gt;:substitute&lt;/code&gt; over the range &lt;code&gt;%&lt;/code&gt;, which is the entire buffer.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s&lt;/code&gt; to match all whitespace characters.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\+&lt;/code&gt; to match 1 or more of them.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt; to anchor at the end of the line.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;e&lt;/code&gt; flag to not give an error if there is no match (i.e. the file is already without trailing whitespace).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;However, this is probably not the &amp;quot;best&amp;quot; way as it causes two side-effects:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;it moves the cursor to the last match;&lt;/li&gt;&#xA;&lt;li&gt;it adds the command to the history and search history;&lt;/li&gt;&#xA;&lt;li&gt;it resets the last search term.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;You can fix this with a small function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fun! TrimWhitespace()&#xA;    let l:save = winsaveview()&#xA;    keeppatterns %s/\s\+$//e&#xA;    call winrestview(l:save)&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And then use it like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:call TrimWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The &lt;code&gt;winsaveview()&lt;/code&gt; will save the current &amp;quot;view&amp;quot;, which includes the cursor position, folds, jumps, etc. The &lt;code&gt;winrestview()&lt;/code&gt; at the end will restore this from the saved variable.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;:keeppatterns&lt;/code&gt; prevents the &lt;code&gt;\s\+$&lt;/code&gt; pattern from being added to the search history.&lt;/li&gt;&#xA;&lt;li&gt;The last-used search term is automatically restored after leaving a function, so we don't have to do anything else for this.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Since this is somewhat annoying to type &lt;code&gt;:call&lt;/code&gt; all the time, you can define a command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;command! TrimWhitespace call TrimWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Which can be be used without the &lt;code&gt;:call&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:TrimWhitespace&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And you can of course bind it to a key:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:noremap &amp;lt;Leader&amp;gt;w :call TrimWhitespace()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Some people like to automatically do this before they write a file to disk, like so:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * call TrimWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I don't like it, as some formats require trailing whitespace (such as  &lt;a href=&quot;https://daringfireball.net/projects/markdown/syntax#p&quot; rel=&quot;noreferrer&quot;&gt;Markdown&lt;/a&gt;), and on some other occasions you even want trailing whitespace in your code (such as formatting an email, and using the &lt;code&gt;--&amp;lt;Space&amp;gt;&lt;/code&gt; marker to indicate the start of a signature).&lt;/p&gt;&#xA;&lt;p&gt;You can skip binary files with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * if !&amp;amp;binary | call TrimWhitespace() | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or other filestypes:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * if !&amp;amp;binary &amp;amp;&amp;amp; &amp;amp;ft !=# 'mail' &#xA;                   \|   call TrimWhitespace()&#xA;                   \| endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Shameless plug mode: a while ago I &lt;a href=&quot;http://code.arp242.net/sanitize_files&quot; rel=&quot;noreferrer&quot;&gt;wrote a little Python script&lt;/a&gt; to clean up whitespace for an entire project at once.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2023-08-06T12:06:59.243" LastActivityDate="2023-08-06T12:06:59.243" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="457" PostTypeId="1" AcceptedAnswerId="461" CreationDate="2015-02-05T19:58:21.087" Score="194" ViewCount="82734" Body="&lt;p&gt;Vim has an Ex mode that can be entered by entering &lt;kbd&gt;Q&lt;/kbd&gt;, and a command line mode that can be entered with &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;. A common complaint amongst new vim users is that they enter these modes accidentally when trying to quit vim. As such, I disable these keys in my &lt;code&gt;~/.vimrc&lt;/code&gt; to stop myself hitting them accidentally (particularly &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map q: &amp;lt;Nop&amp;gt;&#xA;nnoremap Q &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although I've read the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/intro.html#Ex&quot; rel=&quot;noreferrer&quot;&gt;vim documentation on Ex&lt;/a&gt;, am a moderately experienced Vim user, and understand the basic idea behind it, I still struggle to find any use for it in my daily vim use. In general it seems less useful than just entering a standard vim command-line command prefixed with &lt;kbd&gt;:&lt;/kbd&gt;, as changes are not echoed straight away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does Ex have any practical everyday use in modern Vim? Is there anything that's easier to do in Ex mode than with standard commands? What is the difference between command line mode and ex mode?&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="91" LastEditDate="2018-09-13T12:37:59.840" LastActivityDate="2022-03-29T07:41:19.590" Title="Does Ex mode have any practical use?" Tags="|ex-mode|" AnswerCount="9" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="458" PostTypeId="1" AcceptedAnswerId="462" CreationDate="2015-02-05T20:03:16.333" Score="59" ViewCount="21154" Body="&lt;p&gt;When working on a feature branch in &lt;code&gt;git&lt;/code&gt;, I frequently need to stash my changes to commit a bug fix to the main branch. When I'm done working on the changes, I &lt;code&gt;git stash pop&lt;/code&gt;, which updates the timestamps on the files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though the files are identical, the next time I try to save, I get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;WARNING: The file has been changed since reading it!!!&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Do you really want to write to it (y/n)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't want to automatically reload the file every time it changes on disk, only when I &lt;code&gt;git stash pop&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, I manually reload each buffer individually (&lt;code&gt;:e&lt;/code&gt;). Is there any way I can do this in one command?&lt;/p&gt;&#xA;" OwnerUserId="323" LastEditorUserId="24" LastEditDate="2015-02-06T00:42:51.670" LastActivityDate="2023-01-17T21:09:26.990" Title="How can I reload all buffers at once?" Tags="|buffers|load|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="459" PostTypeId="1" CreationDate="2015-02-05T20:10:53.173" Score="3" ViewCount="121" Body="&lt;p&gt;When I need to reopen &lt;code&gt;vim&lt;/code&gt; for some reason (vim updated, reboot, etc), I need to manually open a bunch of buffers when I start up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way I can save the current set of buffers open in some kind of list and open them all as a group the next time I start vim?&lt;/p&gt;&#xA;" OwnerUserId="323" LastActivityDate="2015-02-05T20:16:35.983" Title="Can I open a group of buffers at once?" Tags="|buffers|" AnswerCount="1" CommentCount="1" ClosedDate="2015-02-05T21:42:25.797" ContentLicense="CC BY-SA 3.0" />
  <row Id="460" PostTypeId="2" ParentId="459" CreationDate="2015-02-05T20:16:35.983" Score="2" Body="&lt;p&gt;You can save your current session to a file with &lt;code&gt;:mksession filename&lt;/code&gt; and then restore it by running vim with &lt;code&gt;vim -S filename&lt;/code&gt;.  You can find the full documentation with &lt;code&gt;:help views-sessions&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="355" LastActivityDate="2015-02-05T20:16:35.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="461" PostTypeId="2" ParentId="457" CreationDate="2015-02-05T20:30:31.910" Score="142" Body="&lt;p&gt;&lt;code&gt;Q&lt;/code&gt; is, as you found, ex mode.  It's not entirely useful to use interactively, but it exists because Vim can be used to emulate the old &lt;code&gt;ex&lt;/code&gt; binary.  In fact, many systems provide the &lt;code&gt;ex&lt;/code&gt; command by simply symlinking it to &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;q:&lt;/code&gt;, or &lt;code&gt;:&amp;lt;C-f&amp;gt;&lt;/code&gt;, instead provides a way to browse your command-line history and edit it like a normal buffer.  This makes it easy to find a previous command you ran, edit it with normal Vim commands, and then run the modified command.  The &lt;code&gt;q/&lt;/code&gt; and &lt;code&gt;q?&lt;/code&gt; commands exist to provide the same functionality for the search history.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-02-05T20:30:31.910" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="462" PostTypeId="2" ParentId="458" CreationDate="2015-02-05T20:32:13.190" Score="74" Body="&lt;p&gt;See &lt;code&gt;:help bufdo&lt;/code&gt; for what you want to do.  It will execute a command in each buffer in the buffer list.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may also want to look at &lt;code&gt;:help noconfirm&lt;/code&gt; to disable the confirmation dialog before issueing the &lt;code&gt;bufdo&lt;/code&gt; command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set noconfirm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and reenabling it after the &lt;code&gt;bufdo&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set confirm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="109" LastEditorUserId="109" LastEditDate="2015-02-05T20:41:08.920" LastActivityDate="2015-02-05T20:41:08.920" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="463" PostTypeId="2" ParentId="457" CreationDate="2015-02-05T20:37:56.640" Score="19" Body="&lt;p&gt;The command-line window is useful for writing out long complicated commands.  Since the command history opens as a window, you can use any vim navigation or editing command/mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you want to edit a long substitution command that you ran once, but had made a mistake:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%165,177s:here is a whole bunch of text I wnat to replace:here is the replacement:c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to change the search string, you cannot use vim motions like &lt;code&gt;b&lt;/code&gt; in the Ex line to navigate (although I believe that there are key mappings for this navigation).  Instead, most people would hit the left-arrow key a bunch of times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better way: hit &lt;code&gt;q:&lt;/code&gt; to go into the command-line window, &lt;code&gt;k&lt;/code&gt; to move up to the last command, and navigate with normal motions to the part of the command you want to change.  Want to change an entire word, no problem: &lt;code&gt;ciw&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="141" LastEditorUserId="880" LastEditDate="2015-02-27T23:08:50.210" LastActivityDate="2015-02-27T23:08:50.210" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="464" PostTypeId="1" AcceptedAnswerId="466" CreationDate="2015-02-05T20:44:04.660" Score="40" ViewCount="8669" Body="&lt;p&gt;After I've been working on a project for a while, I start to see large gaps between consecutive buffer numbers. This is because the buffers in between them were wiped out for various reasons. Unfortunately, this can make it awkward to jump to a particular buffer, or select a range of buffers, after typing &lt;code&gt;:ls&lt;/code&gt;. Is there some way to renumber all of the open buffers, starting from one, without opening all of the files again?&lt;/p&gt;&#xA;" OwnerUserId="261" LastActivityDate="2022-02-15T21:04:18.393" Title="Renumbering buffer list" Tags="|buffers|multiple-files|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="465" PostTypeId="2" ParentId="464" CreationDate="2015-02-05T20:52:29.230" Score="8" Body="&lt;p&gt;According to the documentation, the buffer numbers never change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Each buffer has a unique number.  That number will not change,&#xA;    so you can always go to a specific buffer with &quot;:buffer N&quot; or&#xA;    &quot;N CTRL-^&quot;, where N is the buffer number.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only way I can think to renumber the buffers is to restart vim.&lt;/p&gt;&#xA;" OwnerUserId="226" LastActivityDate="2015-02-05T20:52:29.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="466" PostTypeId="2" ParentId="464" CreationDate="2015-02-05T20:55:03.900" Score="29" Body="&lt;p&gt;No (not without deleting buffers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim does not support manually buffer number assignment or re-ordering of buffers once you open them. It's philosophy is that each buffer gets an identifier that is fixed for the lifetime of that buffer (in the help for &lt;code&gt;:ls&lt;/code&gt;, it notes that &quot;each buffer has a unique number.  That number will not change...&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use the argument list, though. Put all open buffers into the argument list, delete all outstanding buffers, then open everything in the argument list. The following commands will accomplish that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:argdel *&lt;/code&gt; (delete the existing argument list)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:bufdo argadd %&lt;/code&gt; (for each buffer, add the buffer's path to the list)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:1,1000bd&lt;/code&gt; (delete buffers 1 to 1000; probably there's a better way to do this)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:argdo e&lt;/code&gt; (for each argument, edit that argument)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This will leave you with an extra empty buffer that vim opens when you delete all the previous buffers, but it's a reasonably approximation of the functionality you want. You can just &lt;code&gt;:bd&lt;/code&gt; that extra buffer.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorDisplayName="user72" LastEditDate="2015-02-05T21:07:01.577" LastActivityDate="2015-02-05T21:07:01.577" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="467" PostTypeId="1" AcceptedAnswerId="468" CreationDate="2015-02-05T21:03:31.197" Score="24" ViewCount="11259" Body="&lt;p&gt;I quite often use the &lt;code&gt;:registers&lt;/code&gt; command to show the contents of all the registers (I forget what I put where, exactly what the role of &lt;code&gt;&quot;*&lt;/code&gt;, &lt;code&gt;&quot;.&lt;/code&gt;, &lt;code&gt;&quot;%&lt;/code&gt;, etc. are).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Especially because I set the &lt;code&gt;&quot;&lt;/code&gt; option in the &lt;code&gt;viminfo&lt;/code&gt; option, and hence my registers are persisted between my vim sessions (which in general I want, in the short term), over time the &lt;code&gt;:registers&lt;/code&gt; list gets longer and longer, and hence more and more cumbersome and filled with really old stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, the only way I've found to fix this is to manually edit some of the 'old' register contents out of &lt;code&gt;~/.viminfo&lt;/code&gt;, which I need to do with &lt;code&gt;vim -u NONE&lt;/code&gt; and is hence a bit cumbersome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a cleaner way to wipe all registers, or wipe a specific register, so it no longer appears in the &lt;code&gt;:registers&lt;/code&gt; list?&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="24" LastEditDate="2015-02-05T21:14:41.043" LastActivityDate="2020-07-18T22:28:01.847" Title="How can I clear a register/multiple registers completely?" Tags="|register|persistent-state|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="468" PostTypeId="2" ParentId="467" CreationDate="2015-02-05T21:27:00.680" Score="19" Body="&lt;p&gt;In short, there is not a cleaner way to wipe registers so completely that they disappear from &lt;code&gt;:reg&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than murk around with &lt;code&gt;~/.viminfo&lt;/code&gt;, I tend to &quot;softclear&quot; registers when I'm really and truly done with them by setting them to be blank. To clear the &lt;code&gt;a&lt;/code&gt; register, for instance, I type &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; to set the &lt;code&gt;a&lt;/code&gt; register to an empty string. Equivalently, &lt;code&gt;:let @a=''&lt;/code&gt; does the same. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, looking at the output of &lt;code&gt;:reg&lt;/code&gt; is still helpful because it is very easy to discern between empty registers and contained registers. On the other hand, I find that essentially all of my named registers lie on the top row (macros) or the main row (useful paste things), and even then I've only used about 15 named registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There was a &lt;a href=&quot;http://vim.1045645.n5.nabble.com/how-to-clear-registers-td1143529.html&quot;&gt;thread&lt;/a&gt; on the vim mailing list a few years back that also concluded that there was no easier way to wipe registers.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2015-02-05T21:27:00.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="469" PostTypeId="1" AcceptedAnswerId="472" CreationDate="2015-02-05T21:33:07.183" Score="4" ViewCount="86" Body="&lt;p&gt;It seems like any time I edit a file with gvim it creates a litany of files I don't want or seem to need. I understand the &lt;code&gt;&amp;lt;filename&amp;gt;.~&lt;/code&gt; files are backups of the file before I started editing and &lt;code&gt;.&amp;lt;filename&amp;gt;.swp&lt;/code&gt; are swap files holding bits of data only while vim is open, but what is the purpose of &lt;code&gt;&amp;lt;filename&amp;gt;.project.vim&lt;/code&gt;? Can I safely delete them? Can I make gvim stop creating them in the first place?&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="24" LastEditDate="2015-02-09T15:45:51.507" LastActivityDate="2015-02-09T15:45:51.507" Title="How do I get rid of &lt;filename&gt;.project.vim files?" Tags="|vimrc|sessions|persistent-state|gvim|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="470" PostTypeId="2" ParentId="458" CreationDate="2015-02-05T22:01:28.923" Score="22" Body="&lt;p&gt;You can do this with the &lt;code&gt;:checktime&lt;/code&gt; command. From the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#:checktime&quot;&gt;docs&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:checkt[ime]        Check if any buffers were changed outside of Vim.&#xA;                    This checks and warns you if you would end up with two&#xA;                    versions of a file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command will ask you what to do for each buffer the file of which has a changed timestamp. To disable this for files that haven't changed you can do &lt;code&gt;:set autoread&lt;/code&gt; to force vim to just reload them. vim &lt;strong&gt;will&lt;/strong&gt; ask you if the contents between the buffer and the file on disk have changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can setup a map like the following for ease of use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :checktime&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20" LastActivityDate="2015-02-05T22:01:28.923" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="471" PostTypeId="1" AcceptedAnswerId="473" CreationDate="2015-02-05T22:02:25.823" Score="44" ViewCount="25644" Body="&lt;p&gt;There seems to be two ways to store preferences specific to gvim:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Keep an &lt;code&gt;.vimrc&lt;/code&gt; file for vim and a &lt;code&gt;.gvimrc&lt;/code&gt; file for gvim specific additions.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Keep all settings in &lt;code&gt;.vimrc&lt;/code&gt; and wrap gvim specific settings in a feature detection conditional:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('gui_running')&#xA;    &quot; gvim specific settings here&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Given the existence of the latter option, why would I ever need a &lt;code&gt;.gvimrc&lt;/code&gt; file?&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorDisplayName="user72" LastEditDate="2015-02-05T22:19:07.197" LastActivityDate="2020-07-28T08:31:16.877" Title="Why do I need both a vimrc and a gvimrc?" Tags="|vimrc|gvim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="472" PostTypeId="2" ParentId="469" CreationDate="2015-02-05T22:03:10.250" Score="6" Body="&lt;p&gt;From &lt;code&gt;doc/automatic-tex-plugin.txt&lt;/code&gt; in the &lt;a href=&quot;http://atp-vim.sourceforge.net/&quot;&gt;Automatic LaTeX Plugin&lt;/a&gt; source:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                *b:atp_ProjectScript*&#xA;                                                *g:atp_ProjectScript*&#xA;Setting one of the variables |b:atp_ProjectScript| or&#xA;|g:atp_ProjectScript| to 0 the feature will be turned off.  Local&#xA;variable, i.e. b: has precedence over the global one g:.  So you can&#xA;turned off the feature for only specific files. The global variable&#xA;will turn it off for all files.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So simply adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:atp_ProjectScript = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your &lt;code&gt;.vimrc&lt;/code&gt; should solve the problem.&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="88" LastEditDate="2015-02-05T22:08:29.777" LastActivityDate="2015-02-05T22:08:29.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="473" PostTypeId="2" ParentId="471" CreationDate="2015-02-05T22:12:36.447" Score="34" Body="&lt;p&gt;When the GUI starts, some settings are reset and then &lt;code&gt;.gvimrc&lt;/code&gt; is processed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consequently, if you want a non-default value for any of those settings, you'll need to set it in a &lt;code&gt;.gvimrc&lt;/code&gt;; testing for GUI mode in &lt;code&gt;.vimrc&lt;/code&gt; won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One such setting is &lt;code&gt;t_vb&lt;/code&gt;, the terminal code used for the visual bell; in fact, all terminal optionals are reset to defaults for GUI mode (see &lt;code&gt;:help terminal-options&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally a bunch of GUI setup and menu customization is carried out; if you want to tweak any of that, you'll want that in a &lt;code&gt;.gvimrc&lt;/code&gt; or it may not have any impact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading over &lt;code&gt;:help gvimrc&lt;/code&gt; provides a good overview of things that may change on you between the sourcing of your &lt;code&gt;.vimrc&lt;/code&gt; and &lt;code&gt;.gvimrc&lt;/code&gt; that you may want to consider re-adjusting in the latter.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-02-05T22:12:36.447" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="474" PostTypeId="1" AcceptedAnswerId="585" CreationDate="2015-02-05T23:03:41.687" Score="6" ViewCount="429" Body="&lt;p&gt;I am attempting to learn more about scripting Vim and writing plugins with python, but I'm having trouble getting started. Although I've read &lt;code&gt;:h python&lt;/code&gt; (first step, read the manual), I had trouble parsing it.&lt;/p&gt;&#xA;&lt;p&gt;So I thought it would be a good idea to try to understand a very simple python plugin. In &lt;a href=&quot;https://vi.stackexchange.com/q/415/130&quot;&gt;this question&lt;/a&gt;, a user wants to make a box like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;################################################################################&#xA;#################################### LOAD ######################################&#xA;################################################################################&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;around words that they type.&lt;/p&gt;&#xA;&lt;p&gt;How can we do this in vim through python?&lt;/p&gt;&#xA;&lt;p&gt;Specifically, I would like to write a function &lt;code&gt;MyPythonFunction()&lt;/code&gt; and be able to have the line&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;some words&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;with my cursor on that line, perform &lt;code&gt;:call MyPythonFunction()&lt;/code&gt;, and have this function (written as much as possible in python) create the block of hashes with the line of text centered in the middle row.&lt;/p&gt;&#xA;" OwnerUserId="130" LastEditorUserId="23502" LastEditDate="2022-10-28T07:12:46.633" LastActivityDate="2022-10-28T07:12:46.633" Title="Making a box in vim via python" Tags="|vimscript|ascii-art|vimscript-python|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="475" PostTypeId="1" AcceptedAnswerId="476" CreationDate="2015-02-05T23:41:21.113" Score="27" ViewCount="5079" Body="&lt;p&gt;Sometimes it happens that I open a file and make some modifications as my own&#xA;user, without noticing or &quot;forgetting&quot; to noticing the &lt;code&gt;[read-only]&lt;/code&gt; warning in&#xA;the status line (ie. some random &lt;code&gt;/etc&lt;/code&gt; config file like &lt;code&gt;/etc/resolv.conf&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:w!&lt;/code&gt; obviously fails in this case because my user has no write permission&#xA;anyway.  So I have to &lt;code&gt;:w /home/filename&lt;/code&gt;, exit and &lt;code&gt;sudo mv ...&lt;/code&gt;, very&#xA;uncomfortable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way so that I escalate temporarily to root to be able to save the&#xA;file currently opened? (given I am in &lt;code&gt;sudoers&lt;/code&gt; or/and I can &lt;code&gt;su&lt;/code&gt; directly)?&lt;/p&gt;&#xA;" OwnerUserId="188" LastEditorUserId="51" LastEditDate="2015-02-05T23:59:36.450" LastActivityDate="2015-02-24T08:21:58.220" Title="How to save a file for which I have no write permissions?" Tags="|save|command-line|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="476" PostTypeId="2" ParentId="475" CreationDate="2015-02-05T23:48:30.773" Score="24" Body="&lt;p&gt;The trick is to use an external call to &lt;code&gt;sudo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !sudo tee %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How this works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:w !&amp;lt;command&amp;gt;&lt;/code&gt; executes &lt;code&gt;&amp;lt;command&amp;gt;&lt;/code&gt; with the contents of the buffer as stdin.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;tee&lt;/code&gt; duplicates stdin to a file &amp;amp; stdout; &lt;code&gt;%&lt;/code&gt; expands to the current filename..&lt;/li&gt;&#xA;&lt;li&gt;You prefix this with &lt;code&gt;sudo&lt;/code&gt; for root permissions.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You're not &lt;em&gt;really&lt;/em&gt; saving the file with Vim, rather, you're calling an external program to overwrite the contents of the file you're editing. This is why you will get a warning from Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;W12: Warning: File &quot;xxx&quot; has changed and the buffer was changed in Vim as well&#xA;See &quot;:help W12&quot; for more info.&#xA;[O]K, (L)oad File: &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could turn this into a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! SuperWrite()&#xA;        write !sudo tee %&#xA;        &quot; Or with :silent (but that doesn't seem to work for everyone)&#xA;        &quot;silent write !sudo tee %&#xA;        edit!&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And keybind:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;w! :call SuperWrite()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;su&lt;/code&gt;, only the root user can use &lt;code&gt;-c&lt;/code&gt; to immediately execute a command. I don't think you can use &lt;code&gt;su&lt;/code&gt; to do this, but perhaps there is a trick I am unaware of...&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-24T08:21:58.220" LastActivityDate="2015-02-24T08:21:58.220" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="477" PostTypeId="1" AcceptedAnswerId="542" CreationDate="2015-02-05T23:59:22.770" Score="8" ViewCount="205" Body="&lt;p&gt;Referring to clean-up tasks like (but not limited to) the ones detailed in these questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/236/re-indenting-badly-indented-code&quot;&gt;Re-indenting badly indented code&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/454/whats-the-simplest-way-to-strip-trailing-whitespace-from-all-lines-in-a-file&quot;&gt;What&amp;#39;s the simplest way to strip trailing whitespace from all lines in a file?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;is there a way to apply those commands only the lines of the files which were actually modified? This is for keeping the diff output focused on the actual change after editing source code (a potential code-reviewer would not be confused by the changes involved in cleaning the whole file), while not introducing new formatting problems.&lt;/p&gt;&#xA;" OwnerUserId="188" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-08T09:27:07.117" Title="Running cleanup commands only for edited lines possible?" Tags="|indentation|command-line|whitespace|" AnswerCount="1" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="478" PostTypeId="1" CreationDate="2015-02-06T00:01:24.153" Score="14" ViewCount="6603" Body="&lt;p&gt;Is there a way to make Vim fold functions based on the syntax of a function declaration? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example having vim turn a function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foobar(foo,bar):&#xA;  if foo &amp;gt; bar:&#xA;    print &quot;foo&quot;&#xA;  elif foo &amp;lt; bar:&#xA;    print &quot;bar&quot;&#xA;  elif foo == bar:&#xA;    print &quot;foobar&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+----- 7 lines: def foobar(foo,bar): -------------------------------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there some set of commands or a function I can put into my .vimrc file use to accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="25" LastEditorUserId="51" LastEditDate="2015-04-30T15:40:18.810" LastActivityDate="2022-05-05T20:47:10.767" Title="How do you fold functions automatically?" Tags="|folding|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="479" PostTypeId="2" ParentId="475" CreationDate="2015-02-06T00:01:26.253" Score="12" Body="&lt;p&gt;I use the following mapping in my .vimrc, which I find useful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap w!! w !sudo tee %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's easy to remember, because &lt;code&gt;w&lt;/code&gt; is &quot;write,&quot; &lt;code&gt;w!&lt;/code&gt; is &quot;force write,&quot; and &lt;code&gt;w!!&lt;/code&gt; is &quot;super-duper-force write.&quot; :P&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-06T00:01:26.253" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="480" PostTypeId="2" ParentId="478" CreationDate="2015-02-06T00:04:41.130" Score="8" Body="&lt;p&gt;Sure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use &lt;code&gt;zc&lt;/code&gt; to close a fold, &lt;code&gt;zo&lt;/code&gt; to open one, or &lt;code&gt;za&lt;/code&gt; to toggle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, Vim doesn't include folding information for Python by default, which you appear to be using. You could use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2462&quot;&gt;one of many external resources&lt;/a&gt;, however.&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="88" LastEditDate="2015-02-06T00:09:45.777" LastActivityDate="2015-02-06T00:09:45.777" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="481" PostTypeId="2" ParentId="478" CreationDate="2015-02-06T00:06:51.537" Score="13" Body="&lt;p&gt;Given that your example is in Python, which relies on correct indentation of code blocks it is enough to base folding on that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set foldmethod=indent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information on the varieties of folding available see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27foldmethod%27&quot;&gt;:help foldmethod&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="182" LastEditorUserId="182" LastEditDate="2015-02-06T14:49:34.150" LastActivityDate="2015-02-06T14:49:34.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="482" PostTypeId="1" AcceptedAnswerId="483" CreationDate="2015-02-06T00:12:23.697" Score="6" ViewCount="622" Body="&lt;p&gt;I've turned on spellcheck with &lt;code&gt;:set spell spelllang=en_us&lt;/code&gt;. Now there's a bunch of words highlighted in red, and I just want to correct them all to their closest matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I correct all misspelled words in the entire file?&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-06T00:12:23.697" Title="Correct all spelling mistakes in the document" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="483" PostTypeId="2" ParentId="482" CreationDate="2015-02-06T00:12:23.697" Score="11" Body="&lt;p&gt;Here's something I didn't know until a little while ago: Macros can be recursive! That is, you can call a macro from within the same macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, here's the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ggqq]s1z=@qq@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg  Move to the beginning of the file&#xA;qq  Start recording the &quot;q&quot; macro&#xA;]s  Find the next misspelled word&#xA;1z= Correct its spelling&#xA;@q  Call the &quot;q&quot; macro (we're still recording!)&#xA;q   Finish recording&#xA;@q  Call the macro for the first time&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since there's a &lt;code&gt;@q&lt;/code&gt; at the end of the macro, it repeatedly calls itself until it reaches EOF. Therefore, it'll correct all the misspelled words in the entire document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure the &lt;code&gt;q&lt;/code&gt; macro is empty before running this, though (if not, you can clear it with &lt;code&gt;qqq&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-06T00:12:23.697" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="484" PostTypeId="1" CreationDate="2015-02-06T00:56:23.767" Score="12" ViewCount="2325" Body="&lt;h1&gt;Intro&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;When programming in C and C++ you usually split your function prototypes and actual functions into a &lt;code&gt;.h&lt;/code&gt;/&lt;code&gt;.hpp&lt;/code&gt; and &lt;code&gt;.c&lt;/code&gt;/&lt;code&gt;.cpp&lt;/code&gt; file. Sadly it's very tedious to transfer the function prototypes from one file to another, and requires opening both files at the same time (or a good memory), as well as a lot of unnecessary typing, especially when changes to the arguments or member names are made.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Example&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;foo.hpp&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int someFunction(int someArgument);&#xA;&#xA;class someClass&#xA;{&#xA;     public:&#xA;     someClass();&#xA;     ~someClass();&#xA;&#xA;     int anotherFunction(int anotherArgument);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;foo.cpp&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;foo.hpp&quot;&#xA;&#xA;int someFunction(int someArgument)&#xA;{&#xA;    // Code goes here&#xA;}&#xA;&#xA;someClass::someClass()&#xA;{&#xA;    // Code goes here&#xA;}&#xA;&#xA;someClass::~someClass()&#xA;{&#xA;    // Code goes here   &#xA;}&#xA;&#xA;int someClass::anotherFunction(int anotherArgument)&#xA;{&#xA;    // Code goes here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Is there a way to automatically create and update the functions in &lt;code&gt;foo.cpp&lt;/code&gt; using the definitions and prototypes in &lt;code&gt;foo.hpp&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="359" LastEditorUserId="51" LastEditDate="2015-02-06T21:39:36.597" LastActivityDate="2015-02-19T14:54:53.557" Title="Automatically creating functions out of function prototypes from header files" Tags="|ide|filetype-c++|filetype-c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="485" PostTypeId="1" CreationDate="2015-02-06T00:59:21.367" Score="53" ViewCount="23569" Body="&lt;p&gt;Many CLI programs output nicely-highlighted text. While most of them check if the output is going to a file, some include the terminal escape codes. I like the output with the escape codes, but viewing these files in Vim is painful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can Vim interpret these escape codes into the expected colors? If not, can Vim be set to ignore these escape codes?&lt;/p&gt;&#xA;" OwnerUserId="323" LastEditorUserId="51" LastEditDate="2015-02-11T18:23:58.660" LastActivityDate="2023-10-23T07:17:46.440" Title="Can Vim interpret terminal color escape codes?" Tags="|syntax-highlighting|terminal|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="486" PostTypeId="2" ParentId="485" CreationDate="2015-02-06T01:10:42.457" Score="48" Body="&lt;p&gt;There are various plugins which allow you to view ANSI colours through escape codes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=302&quot; rel=&quot;noreferrer&quot;&gt;AnsiEsc.vim&lt;/a&gt; – &lt;code&gt;:AnsiEsc&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/chrisbra/Colorizer&quot; rel=&quot;noreferrer&quot;&gt;Colorizer&lt;/a&gt; – &lt;code&gt;:ColorToggle&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to &lt;em&gt;remove&lt;/em&gt; all escape codes, you could use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;lt;1b&amp;gt;\[[0-9;]*m//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;&amp;lt;1b&amp;gt;&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; literal text, it is the escape character, use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; followed by &lt;kbd&gt;Esc&lt;/kbd&gt; to insert it (it may also show up as &lt;code&gt;^[&lt;/code&gt;, depending on your &lt;code&gt;display&lt;/code&gt; setting).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can remove them with &lt;code&gt;sed&lt;/code&gt;; for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sed 's|\x1b\[[;0-9]*m||g' somefile | vi -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2018-10-24T11:28:46.633" LastActivityDate="2018-10-24T11:28:46.633" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="487" PostTypeId="1" AcceptedAnswerId="488" CreationDate="2015-02-06T01:27:53.850" Score="8" ViewCount="8283" Body="&lt;p&gt;I am writing some documentation (a user guide),&#xA;in markdown in Vim.&lt;/p&gt;&#xA;&lt;p&gt;I now realise what I thought should be one page, really should be 2.&#xA;But I've already written a lot of of both halves.&lt;/p&gt;&#xA;&lt;p&gt;How can I split the file at the cursor (or some other marker), into two separate files?&lt;/p&gt;&#xA;&lt;h3&gt;For Example:&lt;/h3&gt;&#xA;&lt;p&gt;Wholefile.md:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;But I must explain to you how all this mistaken idea of denouncing of a pleasure and &#xA;praising pain was born and I will give you a complete account of the system, and expound &#xA;the actual teachings of the great explorer of the truth, the master-builder of human &#xA;happiness.     &#xA;No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but &#xA;because those who do not know how to pursue pleasure rationally encounter consequences &#xA;that are extremely painful. Nor again is there anyone who loves or pursues or desires &#xA;to obtain pain of itself, because it is pain, but occasionally circumstances occur in &#xA;which toil and pain can procure him some great pleasure.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Part1.md:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;But I must explain to you how all this mistaken idea of denouncing of a pleasure and &#xA;praising pain was born and I will give you a complete account of the system, and expound &#xA;the actual teachings of the great explorer of the truth, the master-builder of human &#xA;happiness. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Part2.md:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but &#xA;because those who do not know how to pursue pleasure rationally encounter consequences &#xA;that are extremely painful. Nor again is there anyone who loves or pursues or desires &#xA;to obtain pain of itself, because it is pain, but occasionally circumstances occur in &#xA;which toil and pain can procure him some great pleasure.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="360" LastEditorUserId="21410" LastEditDate="2022-11-02T19:02:37.240" LastActivityDate="2022-11-02T19:02:37.240" Title="How do I break a file into two?" Tags="|multiple-files|file-operations|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="488" PostTypeId="2" ParentId="487" CreationDate="2015-02-06T01:45:38.060" Score="15" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Move the cursor to the last line of Part 1.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Type &lt;code&gt;Vgg&lt;/code&gt; to select the first part, and &lt;code&gt;:w Part1.md&amp;lt;cr&amp;gt;&lt;/code&gt; to save that section to the first file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;code&gt;`&amp;gt;j&lt;/code&gt;, which will move the cursor to the first line of Part 2.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Type &lt;code&gt;VG&lt;/code&gt; to select the second part, and &lt;code&gt;:w Part2.md&amp;lt;cr&amp;gt;&lt;/code&gt; to save that section to the second file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-06T01:45:38.060" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="489" PostTypeId="2" ParentId="484" CreationDate="2015-02-06T03:24:45.543" Score="3" Body="&lt;p&gt;Whew, this one was fun!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/.*\n^{/yank A&amp;lt;cr&amp;gt;:bn&amp;lt;cr&amp;gt;pkdd:%s/$/;/&amp;lt;cr&amp;gt;:g/::/d B&amp;lt;cr&amp;gt;A&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;class &amp;lt;cr&amp;gt;{&amp;lt;cr&amp;gt;};&amp;lt;esc&amp;gt;&quot;BP:%s/[^ ]\+:://&amp;lt;cr&amp;gt;j%jyt(kk$p=ipjA&amp;lt;cr&amp;gt;public:&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can go ahead and map that to a single keystroke in your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-b&amp;gt; :g/.*\n^{/yank A&amp;lt;cr&amp;gt;:bn&amp;lt;cr&amp;gt;pkdd:%s/$/;/&amp;lt;cr&amp;gt;:g/::/d B&amp;lt;cr&amp;gt;A&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;class &amp;lt;cr&amp;gt;{&amp;lt;cr&amp;gt;};&amp;lt;esc&amp;gt;&quot;BP:%s/[^ ]\+:://&amp;lt;cr&amp;gt;j%jyt(kk$p=ipjA&amp;lt;cr&amp;gt;public:&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this assumes that the constructor is the first class method to appear. (I could fix that, but I'd rather keep it simple. Please do mention in a comment if you need that fixed.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also assumes that your header file buffer is empty and located directly after your source file buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step-by-step explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/.*\n^{/yank A&amp;lt;cr&amp;gt;            Yank all the function definitions (power of g!)&#xA;:bn&amp;lt;cr&amp;gt;                         Move to the header file buffer&#xA;pkdd                            Put in the function definitions&#xA;:%s/$/;/&amp;lt;cr&amp;gt;                    Add semicolons&#xA;:g/::/d B&amp;lt;cr&amp;gt;                   Grab the class methods and put them in register B&#xA;A&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;class &amp;lt;cr&amp;gt;{&amp;lt;cr&amp;gt;};&amp;lt;esc&amp;gt; Self-explanatory, add class skeleton&#xA;&quot;BP                             Put the class methods in the class&#xA;:%s/[^ ]\+:://&amp;lt;cr&amp;gt;              Remove someClass::&#xA;j%jyt(kk$p                      Add the actual class name&#xA;=ip                             Fix indentation&#xA;jA&amp;lt;cr&amp;gt;public:&amp;lt;esc&amp;gt;              Add the `public:' modifier&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-06T03:24:45.543" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="490" PostTypeId="1" AcceptedAnswerId="493" CreationDate="2015-02-06T04:13:02.647" Score="22" ViewCount="765" Body="&lt;p&gt;I have seen that a lot of Vim Plug-ins don't seem to have &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pi_vimball.html&quot; rel=&quot;noreferrer&quot;&gt;Vimballs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vimballs were/are basically a tarball for a plugin that vim knows how to install.&#xA;They were/are thus slightly more convenient that using &lt;code&gt;tar -xvf&lt;/code&gt; &#xA;because you didn't/don't  have to have to worry that the tarball had the directory structure nested in different ways&#xA;ie if it started at .vim, or within the .vim directory structure, or if there was a parent folder in the tarball with the same name as the plugin etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been seeing less and less of them and none in plugins that I've seen on Github.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there an active attempt to deprecate them?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If so why?&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Is this because we now have Vundle, Pathogen, etc?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="360" LastEditorUserId="360" LastEditDate="2017-07-27T05:13:58.317" LastActivityDate="2017-07-27T05:13:58.317" Title="Why aren't Vimballs commonly used?" Tags="|plugin-system|plugin-managers|vimball|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="491" PostTypeId="1" AcceptedAnswerId="492" CreationDate="2015-02-06T04:14:51.513" Score="13" ViewCount="6751" Body="&lt;p&gt;I was given a plugin for Vim.&#xA;It came in something called a &lt;code&gt;.vimball&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What am I meant to do with this exactly?&lt;/li&gt;&#xA;&lt;li&gt;Where do I put it?&lt;/li&gt;&#xA;&lt;li&gt;Do I need to be root to install it?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="360" LastActivityDate="2018-11-24T08:46:21.220" Title="How do I install a .vimball Plugin?" Tags="|plugin-system|vimball|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="492" PostTypeId="2" ParentId="491" CreationDate="2015-02-06T04:23:44.067" Score="15" Body="&lt;p&gt;Simply open the vimball file in Vim and then execute &lt;code&gt;:source %&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will move the files to their appropriate folders in your &lt;code&gt;~/.vim&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't need to be root as it just copies files to your &lt;code&gt;~/.vim&lt;/code&gt; directory. You can delete it after you have sourced the vimball file&lt;/p&gt;&#xA;" OwnerUserId="246" LastActivityDate="2015-02-06T04:23:44.067" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="493" PostTypeId="2" ParentId="490" CreationDate="2015-02-06T04:58:58.123" Score="27" Body="&lt;p&gt;The primary reason is precisely your second point, since there has been an active movement on a community level to use source control for managing plugins with the aid of plugin managers like pathogen, vundle, neobundle etc, it's become more of an easier approach to upgrading the plugins. You can also more easily control which release you would like to lock your plugin on. Also another important aspect of using this approach is that you get to isolate each plugin and keep them in their separate folders which makes dealing with them a lot more easy whether you want to upgrade them individually or remove them altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vimball approach makes doing this very hard, and hence has been seeing less adoption in the past. I don't think there was ever an explicit attempt to deprecate it, it's just more of a trend towards other better ways of managing plugins.&lt;/p&gt;&#xA;" OwnerUserId="74" LastEditorUserId="74" LastEditDate="2015-02-06T05:12:13.190" LastActivityDate="2015-02-06T05:12:13.190" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="494" PostTypeId="2" ParentId="487" CreationDate="2015-02-06T05:08:33.183" Score="1" Body="&lt;p&gt;I wrote this script sometime ago for a similar use case.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! functions#Extract(bang,cmd,fname) range abort&#xA;  let extn = expand('%:e')&#xA;  if empty(extn)&#xA;    let l:fname = a:fname&#xA;  else&#xA;    let l:fname = a:fname . '.' . extn&#xA;  endif&#xA;  let [first, last] = [a:firstline, a:lastline]&#xA;  let range = first.&quot;,&quot;.last&#xA;  let spaces = matchstr(getline(first),&quot;^ *&quot;)&#xA;  let buf = @@&#xA;  silent exe range.&quot;yank&quot;&#xA;  let partial = @@&#xA;  let @@ = buf&#xA;  let old_ai = &amp;amp;ai&#xA;  try&#xA;    let &amp;amp;ai = 0&#xA;    silent exe &quot;norm! :&quot;.range.&quot;change\&amp;lt;CR&amp;gt;&quot;.spaces.a:fname.&quot;\&amp;lt;CR&amp;gt;.\&amp;lt;CR&amp;gt;&quot;&#xA;  finally&#xA;    let &amp;amp;ai = old_ai&#xA;  endtry&#xA;  execute a:cmd . ' ' . expand('%:p:h') . '/' . l:fname&#xA;  let @@ = partial&#xA;  silent put&#xA;  0delete&#xA;  let @@ = buf&#xA;  if !empty(spaces)&#xA;    silent! exe '%substitute/^' . spaces . '//'&#xA;  endif&#xA;endfunction&#xA;&#xA;command! -bar -nargs=1 -range SExtract :&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call functions#Extract(&amp;lt;bang&amp;gt;0,&quot;split&quot;,&amp;lt;q-args&amp;gt;)&#xA;command! -bar -nargs=1 -range VExtract :&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call functions#Extract(&amp;lt;bang&amp;gt;0,&quot;vsplit&quot;,&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What it essentially does is pretty much what you described. You can select a region of the current document in visual mode and invoke either &lt;code&gt;SExtract&lt;/code&gt; or &lt;code&gt;VExtract&lt;/code&gt; with a 'name' to open a new file with that name and the extension of the current file in either a &lt;code&gt;split&lt;/code&gt; or &lt;code&gt;vsplit&lt;/code&gt;. Then you can just save the other one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This leaves the name of the new file in place of the content you extracted in the previous file. Which you could just remove I suppose or tweak this script accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: I made this long ago, and it was inspired by the code of &lt;code&gt;Rextract&lt;/code&gt; that tpope provided in vim-rails plugin. I am sure it can be improved in several ways.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-06T05:08:33.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="495" PostTypeId="1" AcceptedAnswerId="496" CreationDate="2015-02-06T06:28:27.167" Score="135" ViewCount="165776" Body="&lt;p&gt;Is it possible to convert tabs to spaces, while maintaining text alignment?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply replacing only works usefully when there are no leading characters.&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="301" LastEditDate="2015-02-16T00:04:00.190" LastActivityDate="2023-01-20T10:18:54.537" Title="How to replace tabs with spaces?" Tags="|indentation|tab-characters|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="496" PostTypeId="2" ParentId="495" CreationDate="2015-02-06T06:45:36.210" Score="145" Body="&lt;p&gt;You can use the &lt;code&gt;:retab&lt;/code&gt; command. From &#xA;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Aretab&quot;&gt;&lt;code&gt;:help :retab&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Replace all sequences of white-space containing a &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; with new strings of&#xA;  white-space using the new tabstop value given.  If you do not specify a new&#xA;  tabstop size or it is zero, Vim uses the current value of &lt;code&gt;'tabstop'&lt;/code&gt;.&#xA;  [...]&#xA;  With &lt;code&gt;'expandtab'&lt;/code&gt; on, Vim replaces all tabs with the appropriate number of&#xA;  spaces.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that the command accepts a range, so you can make a visual selection and&#xA;then just &lt;code&gt;:retab&lt;/code&gt; the selected lines.&lt;/p&gt;&#xA;" OwnerUserId="259" LastEditorUserId="51" LastEditDate="2015-02-07T02:14:52.723" LastActivityDate="2015-02-07T02:14:52.723" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="497" PostTypeId="5" CreationDate="2015-02-06T07:57:44.220" Score="0" Body="&lt;p&gt;Bill Joy's original screen-orientated text editor, called Vi. The name Vi was derived from the shortest unambiguous abbreviation for the ex command &lt;code&gt;visual&lt;/code&gt;, which switches the ex line editor to visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Vi&quot; rel=&quot;nofollow&quot;&gt;Source&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user254" LastEditorUserId="51" LastEditDate="2015-02-06T19:12:31.417" LastActivityDate="2015-02-06T19:12:31.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="498" PostTypeId="4" CreationDate="2015-02-06T07:57:44.220" Score="0" Body="Bill Joy's original Vi text-editor." OwnerDisplayName="user254" LastEditorDisplayName="user254" LastEditDate="2015-02-06T12:41:42.827" LastActivityDate="2015-02-06T12:41:42.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="499" PostTypeId="1" CreationDate="2015-02-06T08:37:00.183" Score="20" ViewCount="4312" Body="&lt;p&gt;I use &lt;code&gt;vimdiff&lt;/code&gt; to inspect differences between files, and some times it misses out a bit. for example, if I have the following two files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//a.c&#xA;printf(&quot;Hello\n&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//b.c&#xA;int i = printf(&quot;hello\n&quot;) + 3;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;showing them in &lt;code&gt;vimdiff&lt;/code&gt; gives:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ni5YK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I will want to see is that in b.c the &lt;code&gt;h&lt;/code&gt; is not capitalized. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to tell vimdiff to compare (in that line) just part of it (I mean, ignore the &lt;code&gt;int i =&lt;/code&gt; and the &lt;code&gt;+ 3&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="342" LastEditorUserId="24" LastEditDate="2015-02-06T09:03:12.920" LastActivityDate="2018-06-03T15:39:18.093" Title="More detailed comparison within a line" Tags="|vimdiff|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="500" PostTypeId="2" ParentId="499" CreationDate="2015-02-06T08:56:23.973" Score="21" Body="&lt;p&gt;I don't think this can be done by Vim itself. From &lt;a href=&quot;http://vimhelp.appspot.com/diff.txt.html#view-diffs&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h view-diffs&lt;/code&gt;&lt;/a&gt; (emphasis mine):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;hl-DiffText   DiffText        Changed text inside a Changed line.  &lt;strong&gt;Vim&#xA;                                finds the first character that is different,&#xA;                                and the last character that is different&#xA;                                (searching from the end of the line).&lt;/strong&gt;  The&#xA;                                text in between is highlighted.  &lt;strong&gt;This means&#xA;                                that parts in the middle that are still the&#xA;                                same are highlighted anyway.&lt;/strong&gt;  Only &quot;iwhite&quot; of&#xA;                                'diffopt' is used here.&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/499/more-detailed-comparison-within-a-line#comment571_499&quot;&gt;Tokoyami's suggestion&lt;/a&gt; takes us one step closer. Install &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4932&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;diffchar&lt;/code&gt;&lt;/a&gt; (&lt;a href=&quot;https://github.com/rickhowe/diffchar.vim&quot; rel=&quot;noreferrer&quot;&gt;Github link&lt;/a&gt; for those using a plugin autoloader). Since v4.7, with the plugin enabled, Vim automatically shows more exact differences:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/quTvW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You can press &lt;kbd&gt;F7&lt;/kbd&gt; (the default keymap) to toggle between the usual and the plugin. Reassign with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;key&amp;gt; &amp;lt;Plug&amp;gt;ToggleDiffCharAllLines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;replacing &lt;code&gt;&amp;lt;key&amp;gt;&lt;/code&gt; with an appropriate key code.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use more colors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:DiffColors=100&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="3338" LastEditDate="2018-06-03T15:39:18.093" LastActivityDate="2018-06-03T15:39:18.093" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="501" PostTypeId="1" AcceptedAnswerId="502" CreationDate="2015-02-06T09:05:57.943" Score="11" ViewCount="2715" Body="&lt;p&gt;If I open vim with multiple files on the command line, for example &lt;code&gt;vim debug.log*&lt;/code&gt; which loads &lt;code&gt;debug.log&lt;/code&gt;, &lt;code&gt;debug.log.1&lt;/code&gt; and &lt;code&gt;debug.log.2&lt;/code&gt;, can I navigate between them, assign them to multiple windows (&lt;code&gt;:split&lt;/code&gt;/&lt;code&gt;:vsplit&lt;/code&gt;) or such?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only shortcut I know for this mode of operation is &lt;code&gt;:n&lt;/code&gt;, which loads the next file on the list. What more can I do in this multi-file operation mode? (or which help subject covers that?)&lt;/p&gt;&#xA;" OwnerUserId="351" LastEditorUserId="351" LastEditDate="2015-02-06T09:18:12.763" LastActivityDate="2015-10-25T17:40:16.083" Title="Navigating multiple files" Tags="|multiple-files|load|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="502" PostTypeId="2" ParentId="501" CreationDate="2015-02-06T09:23:51.567" Score="13" Body="&lt;p&gt;The most relevant help topic is &lt;a href=&quot;https://vimhelp.appspot.com/windows.txt.html#%3Als&quot;&gt;&lt;code&gt;:ls&lt;/code&gt;&lt;/a&gt;, also known as &#xA;&lt;a href=&quot;https://vimhelp.appspot.com/windows.txt.html#%3Afiles&quot;&gt;&lt;code&gt;:files&lt;/code&gt;&lt;/a&gt; or &#xA;&lt;a href=&quot;https://vimhelp.appspot.com/windows.txt.html#%3Abuffers&quot;&gt;&lt;code&gt;:buffers&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;vim debug.log*&lt;/code&gt; example, if you gave the &lt;code&gt;:ls&lt;/code&gt; command, you would see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls&#xA;  1 %a   &quot;debug.log&quot;                    line 1&#xA;  2      &quot;debug.log.1&quot;                  line 0&#xA;  3      &quot;debug.log.2&quot;                  line 0&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… indicating that the first one is the active buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To open &lt;code&gt;debug.log.2&lt;/code&gt; in the current window, give the &lt;a href=&quot;https://vimhelp.appspot.com/windows.txt.html#%3Ab&quot;&gt;&lt;code&gt;:b 3&lt;/code&gt;&lt;/a&gt; or &lt;code&gt;:b debug.log.2&lt;/code&gt; command to show buffer 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To split the window and open buffer 2 in it, give the &lt;a href=&quot;https://vimhelp.appspot.com/windows.txt.html#%3Asb&quot;&gt;&lt;code&gt;:sb 2&lt;/code&gt;&lt;/a&gt; command.  The vertical-split version of that is &lt;a href=&quot;https://vimhelp.appspot.com/windows.txt.html#%3Avertical&quot;&gt;&lt;code&gt;:vert sb 2&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many variants of the &lt;code&gt;:b&lt;/code&gt; command; browse the help topics cited here to get a feel for them.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In addition, you can invoke &lt;code&gt;vim -o debug.log*&lt;/code&gt; to open all of the files, each in its own split, or &lt;code&gt;vim -O debug.log*&lt;/code&gt; to open them each in a vertical split.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-06T19:14:55.557" LastActivityDate="2015-02-06T19:14:55.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="503" PostTypeId="1" CreationDate="2015-02-06T09:25:42.930" Score="4" ViewCount="101" Body="&lt;p&gt;When I've jumped from a buffer to another buffer I use &lt;code&gt;C-o&lt;/code&gt; to return and after that I use &lt;code&gt;C-i&lt;/code&gt; if I want to jump to that same buffer again. I think this is the common approach. The problem is that this requires you to step through &lt;em&gt;every&lt;/em&gt; preceding jumplist entry until you get back to the previous buffer. I'm in the habit of jumping around files with &lt;code&gt;M-{&lt;/code&gt; and &lt;code&gt;M-}&lt;/code&gt; so there is usually tons of unimportant clutter in the jumplist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2015-02-06T09:33:23.360" Title="Return to previous buffer without going through every jumplist entry" Tags="|buffers|jumplist|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ClosedDate="2017-02-15T14:34:51.790" ContentLicense="CC BY-SA 3.0" />
  <row Id="504" PostTypeId="2" ParentId="3694" CreationDate="2015-02-06T09:33:23.360" Score="5" Body="&lt;p&gt;&lt;code&gt;&amp;lt;C-6&amp;gt;&lt;/code&gt; is what you need, that takes you back to the previous buffer you had open before the current one. There are also &lt;code&gt;:bprev&lt;/code&gt;&amp;amp; &lt;code&gt;:bnext&lt;/code&gt; which you could use for the same.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-06T09:33:23.360" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="505" PostTypeId="2" ParentId="495" CreationDate="2015-02-06T09:41:47.317" Score="30" Body="&lt;p&gt;You can use &lt;code&gt;:retab&lt;/code&gt;, as stated, however, this will change &lt;em&gt;all&lt;/em&gt; tabs to spaces, &lt;em&gt;not&lt;/em&gt; only tabs at the start of the line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this (where &lt;code&gt;⇥&lt;/code&gt; is a tab character):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if :; do&#xA;⇥echo &quot;⇥hello&quot;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gets changed to (where &lt;code&gt;␣&lt;/code&gt; is a space character):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if :; do&#xA;␣␣echo &quot;␣␣hello&quot;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can produce unexpected side-effects in some scenarios, and it's even more of an issue when changing spaces to tabs!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I wrote a little function to change &lt;em&gt;only&lt;/em&gt; tabs/spaces at the &lt;em&gt;start&lt;/em&gt; of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; :retab changes *everything*, not just start of lines&#xA;fun! Retab(expandtab)&#xA;    let l:spaces = repeat(' ', &amp;amp;tabstop)&#xA;&#xA;    &quot; Replace tabs with spaces&#xA;    if a:expandtab&#xA;        silent! execute '%substitute#^\%(' . l:spaces . '\)\+#\=repeat(&quot;\t&quot;, len(submatch(0)) / &amp;amp;tabstop)#e'&#xA;    &quot; Replace spaces with tabs&#xA;    else&#xA;        silent! execute '%substitute#^\%(\t\)\+#\=repeat(&quot;' . l:spaces . '&quot;, len(submatch(0)))#e'&#xA;    endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this version, you have to manually specify &lt;code&gt;expandtab&lt;/code&gt; in the function call&#xA;(ie. &lt;code&gt;:call Retab(1)&lt;/code&gt; to change tabs to spaces), but you could also modify it&#xA;to take the current value of &lt;code&gt;&amp;amp;expandtab&lt;/code&gt; (as it already does with &lt;code&gt;&amp;amp;tabstop&lt;/code&gt;)&#xA;just like &lt;code&gt;:retab&lt;/code&gt; does. (I happen to prefer to specify it manually).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="15826" LastEditDate="2018-01-05T07:38:47.493" LastActivityDate="2018-01-05T07:38:47.493" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="506" PostTypeId="1" AcceptedAnswerId="507" CreationDate="2015-02-06T10:44:58.473" Score="10" ViewCount="681" Body="&lt;p&gt;I sometimes want to check the length of a piece of text, for example in this&#xA;example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;str = 'Hello, world!'&#xA;if len(str) == 13:&#xA;    print('Hello back to you!')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to know the length of the string &lt;code&gt;Hello, world!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I do now, is have the column number in &lt;code&gt;rulerformat&lt;/code&gt; with &lt;code&gt;%c&lt;/code&gt;, I put my&#xA;cursor on the first character, then go to the last, and manually substract.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is rather awkward, though. What I want is, for example, the length of my&#xA;selection in virtual mode in the ruler, but there is no option for this as far&#xA;as I can see.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this be done? Or in some other easier way?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="343" LastEditDate="2017-12-06T11:11:06.660" LastActivityDate="2017-12-06T11:11:06.660" Title="How can I easily get the length of a piece of text?" Tags="|cursor-motions|visual-mode|counting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="507" PostTypeId="2" ParentId="506" CreationDate="2015-02-06T10:56:39.390" Score="13" Body="&lt;p&gt;You can set the &lt;code&gt;showcmd&lt;/code&gt; option. From Vim's help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Show (partial) command in the last line of the screen.  Set this&#xA;option off if your terminal is slow.&#xA;In Visual mode the size of the selected area is shown:&#xA;- When selecting characters within a line, the number of characters.&#xA;  If the number of bytes is different it is also displayed: &quot;2-6&quot;&#xA;  means two characters and six bytes.&#xA;- When selecting more than one line, the number of lines.&#xA;- When selecting a block, the size in screen characters:&#xA;  {lines}x{columns}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should be on by default on Vim if you have &lt;code&gt;nocompatible&lt;/code&gt; set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, simply select what you want, and Vim will display the number of characters, or lines selected on the bottom right.&lt;/p&gt;&#xA;" OwnerUserId="246" LastActivityDate="2015-02-06T10:56:39.390" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="508" PostTypeId="2" ParentId="487" CreationDate="2015-02-06T11:53:32.960" Score="4" Body="&lt;p&gt;Use line ranges with the :w command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim provides simple abbreviations in such ranges for places like first line &lt;code&gt;1&lt;/code&gt;, current line &lt;code&gt;.&lt;/code&gt;, and last line &lt;code&gt;$&lt;/code&gt;. Ranges can also accept calculated values, so e.g. &lt;code&gt;$-5&lt;/code&gt; is the fifth line from end of file. Using these abbreviations can make your task much easier:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go the the first line that should be in the second file, then write everything above that line to Part1.md&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,-1 w! Part1.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and write everything on and after that line to Part2.md&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,$ w! Part2.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information on line ranges see &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#:range&quot; rel=&quot;nofollow&quot;&gt;:help range&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="182" LastEditorUserId="182" LastEditDate="2015-02-06T14:57:32.057" LastActivityDate="2015-02-06T14:57:32.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="509" PostTypeId="1" AcceptedAnswerId="511" CreationDate="2015-02-06T12:15:29.463" Score="45" ViewCount="22259" Body="&lt;p&gt;The only reason why I'd ever edit a text file in Pico or Nano, and not in Vim was its &quot;Justify&quot; command &lt;kbd&gt;^J&lt;/kbd&gt;. It would reformat a paragraph of text, creating line breaks at word breaks so that the text would float on fixed width screen nicely - format the text to fit predefined 80 columns, creating line breaks only between words. As limited the function was, it was very useful, whether to format lengthy comment blocks, documentation files, or just replacing an endless line of parameters with something more readable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I do something like that in Vim?&lt;/p&gt;&#xA;" OwnerUserId="351" LastEditorUserId="24" LastEditDate="2015-02-06T16:36:37.107" LastActivityDate="2020-08-16T05:42:53.940" Title="Can I justify text in Vim?" Tags="|wrapping|word-processing|alignment|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="510" PostTypeId="1" AcceptedAnswerId="517" CreationDate="2015-02-06T12:29:46.810" Score="24" ViewCount="16041" Body="&lt;p&gt;I know I can &lt;code&gt;:!&lt;/code&gt; or &lt;code&gt;:r!&lt;/code&gt; to execute external command and optionally insert its output into text. I can even perform &lt;code&gt;:!sh&lt;/code&gt; and I'll spawn a shell that will live until I exit it - but while the shell is active, Vim is 'asleep' and inaccessible. I must quit the shell, and spawn a new one if I want to return to Vim for a moment - not very useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can access shell on the opposite end, by suspending Vim with &lt;kbd&gt;^Z&lt;/kbd&gt; and manage the Vim job through &lt;code&gt;bg&lt;/code&gt;, &lt;code&gt;fg&lt;/code&gt; and &lt;code&gt;jobs&lt;/code&gt;. This makes more sense but is very cumbersome in the long run. I can use &lt;code&gt;Screen&lt;/code&gt; if it's available (it often isn't), or open several windows of my window manager (and ssh to target host from each of them in sequence, to have both vim and shell on the remote host, cumbersome again.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be neatest if Vim allowed me to open a shell session and keep it, say, in one of its (internal) windows, or allow me to switch to it and back. Is something like this possible?&lt;/p&gt;&#xA;" OwnerUserId="351" LastEditorUserId="21062" LastEditDate="2019-08-08T14:04:36.653" LastActivityDate="2021-01-14T19:03:04.747" Title="Can I issue an interactive shell in Vim window?" Tags="|external-command|shell|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="511" PostTypeId="2" ParentId="509" CreationDate="2015-02-06T12:35:33.930" Score="45" Body="&lt;p&gt;You can use the &lt;code&gt;gq&lt;/code&gt; or &lt;code&gt;gw&lt;/code&gt; operators combined with a motion command. By default, formatting of applicable text is done by Vim and to the best of my knowledge it does not justify the lines (you will get ragged right margins). Alternatively, an external program (e.g. the &lt;code&gt;fmt&lt;/code&gt; command on Linux) can be used to do the formatting by specifying it with the &lt;code&gt;formatprg&lt;/code&gt; setting.&lt;/p&gt;&#xA;&lt;p&gt;The way I use it is to &lt;code&gt;gwip&lt;/code&gt; (normal mode) with the cursor on a paragraph. This will format the current paragraph keeping the cursor on the same position. I use it this way to make sure that only the current paragraph is formatted. When editing a text file, issuing &lt;code&gt;gwG&lt;/code&gt; (normal mode) at the begining of the file will format the whole text. As a good practice, be sure to leave at least one blank line between paragraphs.&lt;/p&gt;&#xA;&lt;p&gt;There is a lot of configuration that can be done. To begin with, here are some relevant help: &lt;code&gt;:h gq&lt;/code&gt;, &lt;code&gt;:h gw&lt;/code&gt;, &lt;code&gt;:h fo&lt;/code&gt; (format options), &lt;code&gt;:h fp&lt;/code&gt; (format program), &lt;code&gt;:h fo-table&lt;/code&gt; (an explanation of the possible options).&lt;/p&gt;&#xA;" OwnerUserId="259" LastEditorUserId="11054" LastEditDate="2020-08-16T05:42:53.940" LastActivityDate="2020-08-16T05:42:53.940" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="512" PostTypeId="2" ParentId="509" CreationDate="2015-02-06T12:35:39.767" Score="18" Body="&lt;p&gt;From &lt;code&gt;:help usr_25&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;JUSTIFYING TEXT                                                                 &#xA;&#xA;Vim has no built-in way of justifying text.  However, there is a neat macro     &#xA;package that does the job.  To use this package, execute the following          &#xA;command:                                                                        &#xA;&#xA;        :runtime macros/justify.vim                                             &#xA;&#xA;This Vim script file defines a new visual command &quot;_j&quot;.  To justify a block of  &#xA;text, highlight the text in Visual mode and then execute &quot;_j&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, all you have to do is run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ru macros/justify.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to justify the text in the entire file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Of course, you could also add &lt;code&gt;ru macros/justify.vim&lt;/code&gt; to your .vimrc so you don't have to type it every time.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: this does &lt;em&gt;not&lt;/em&gt; add line breaks for you. You have to add those manually with &lt;code&gt;gq&lt;/code&gt;. For this you must also set the &lt;code&gt;textwidth&lt;/code&gt; (default is 0) to your desired value via&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and—if you want—automatic text wrapping by setting the &lt;code&gt;t&lt;/code&gt;-flag via&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set formatoptions+=t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want, you can set a mapping in your .vimrc to do the entire thing for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-j&amp;gt; gggqG_j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This moves to the beginning of the file (&lt;code&gt;gg&lt;/code&gt;), wraps all the lines (&lt;code&gt;gq&lt;/code&gt; until &lt;code&gt;G&lt;/code&gt;), and then &lt;code&gt;_j&lt;/code&gt;ustifies the text.&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="88" LastEditDate="2015-04-04T00:54:14.933" LastActivityDate="2015-04-04T00:54:14.933" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="513" PostTypeId="2" ParentId="509" CreationDate="2015-02-06T12:58:01.017" Score="6" Body="&lt;p&gt;While nano's help call the &lt;code&gt;^J&lt;/code&gt; command &quot;Justify&quot; it actually doesn't &lt;a href=&quot;http://en.wikipedia.org/wiki/Typographic_alignment#Justified&quot; rel=&quot;noreferrer&quot;&gt;justify&lt;/a&gt; the text, it reformat the text breaking the lines before the right margin of the screen (or at some configurable column, I guess).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do the same thing in VIM by setting the variable &lt;code&gt;textwidth&lt;/code&gt;, from &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27textwidth%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'textwidth'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Maximum width of text that is being inserted.  A longer line will be&#xA;  broken after white space to get this width.  A zero value disables&#xA;  this.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is to say: while you are typing, if a line is longer than &lt;code&gt;textwidth&lt;/code&gt; characters, VIM will wrap the line at the first space to keep the line length less or equal to &lt;code&gt;textwidth&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this to work the option &lt;code&gt;formatoptions&lt;/code&gt; must contain the letter &lt;code&gt;t&lt;/code&gt;. See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27formatoptions%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'formatoptions'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#fo-table&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help fo-table&lt;/code&gt;&lt;/a&gt; for the available options, for example you may be interested in the &lt;code&gt;c&lt;/code&gt; option to make formatting work with comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: you can perform the same operation, without the need to put &lt;code&gt;t&lt;/code&gt; in &lt;code&gt;formatoptions&lt;/code&gt;, using the command &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#gw&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;gw{motion}&lt;/code&gt;&lt;/a&gt;, it formats the text between the current cursor position and the position of the cursor after &lt;code&gt;{motion}&lt;/code&gt;. The &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#v_gw&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;gw&lt;/code&gt;&lt;/a&gt; command is available also in visual mode, it format the selected text.&lt;/p&gt;&#xA;" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2015-02-06T13:14:13.210" LastActivityDate="2015-02-06T13:14:13.210" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="514" PostTypeId="1" AcceptedAnswerId="515" CreationDate="2015-02-06T12:58:32.447" Score="237" ViewCount="175750" Body="&lt;p&gt;I am working on split (using ^w+v, ^w+s) buffers, but sometimes I would like to widen a current split or change its height. How can I achieve that?&lt;/p&gt;&#xA;" OwnerUserId="162" LastEditorUserId="162" LastEditDate="2019-08-09T09:28:05.873" LastActivityDate="2021-09-26T17:17:15.060" Title="How do I change the current split's width and height?" Tags="|split|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="515" PostTypeId="2" ParentId="514" CreationDate="2015-02-06T13:02:03.350" Score="350" Body="&lt;p&gt;There are several window commands that allow you to do this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+W&lt;/kbd&gt; &lt;kbd&gt;+/-&lt;/kbd&gt;: increase/decrease height (ex. &lt;code&gt;20&amp;lt;C-w&amp;gt;+&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+W&lt;/kbd&gt; &lt;kbd&gt;&gt;/&amp;lt;&lt;/kbd&gt;: increase/decrease width (ex. &lt;code&gt;30&amp;lt;C-w&amp;gt;&amp;lt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+W&lt;/kbd&gt; &lt;kbd&gt;_&lt;/kbd&gt;: set height (ex. &lt;code&gt;50&amp;lt;C-w&amp;gt;_&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+W&lt;/kbd&gt; &lt;kbd&gt;|&lt;/kbd&gt;: set width (ex. &lt;code&gt;50&amp;lt;C-w&amp;gt;|&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+W&lt;/kbd&gt; &lt;kbd&gt;=&lt;/kbd&gt;: equalize width and height of all windows&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;code&gt;:help CTRL-W&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="8493" LastEditDate="2017-07-14T17:13:01.803" LastActivityDate="2017-07-14T17:13:01.803" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="517" PostTypeId="2" ParentId="510" CreationDate="2015-02-06T13:15:40.557" Score="17" Body="&lt;p&gt;There are a couple of vim plugins that allow for this. I use &lt;a href=&quot;https://code.google.com/p/conque/&quot;&gt;Conque&lt;/a&gt; (&lt;a href=&quot;https://github.com/jewes/Conque-Shell&quot;&gt;Github&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After putting it in your plugins directory all you have to do is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ConqueTermSplit bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you will have an interactive bash shell in vim. You can then use your regular vim gestures to do anything else you may want to do in the window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the other plugin is &lt;a href=&quot;https://github.com/Shougo/vimshell.vim&quot;&gt;vimshell&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="192" LastEditorUserId="51" LastEditDate="2015-02-06T13:25:54.327" LastActivityDate="2015-02-06T13:25:54.327" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="518" PostTypeId="2" ParentId="514" CreationDate="2015-02-06T13:31:28.133" Score="83" Body="&lt;p&gt;You can also use the &lt;code&gt;resize&lt;/code&gt; commands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:resize [+-]N&lt;/code&gt; - resize a horizontal split, increasing or decreasing height by N characters.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:vertical resize [+-]N&lt;/code&gt; - resize a vertical split, increasing or decreasing height by N characters.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:resize N&lt;/code&gt; - resize a horizontal split, setting height to N characters.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:vertical resize N&lt;/code&gt; - resize a vertical split, setting width to N characters.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These are equivalent to the &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; commands. See &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#window-resize&quot;&gt;&lt;code&gt;:help window-resize&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-02-06T13:31:28.133" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="519" PostTypeId="1" AcceptedAnswerId="523" CreationDate="2015-02-06T13:46:52.590" Score="9" ViewCount="207" Body="&lt;p&gt;I have a source file containing a long list of deeply nested heterogenous structures. Since the structures are long, I would like to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use the &lt;code&gt;:split&lt;/code&gt; command to split the screen into two.&lt;/li&gt;&#xA;&lt;li&gt;Scroll down one window and up the other window. When the cursor on window 1 is over a parenthesis, and the other parenthesis is visible in the other window, I want the other parenthesis in the other window to become highlighted (just as it would had it been displaying in the same window).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How can I accomplish the second step?&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="24" LastEditDate="2015-02-09T15:44:11.980" LastActivityDate="2015-02-09T15:44:11.980" Title="Can I force parentheses matching to show up across multiple windows?" Tags="|split|delimiter-matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="521" PostTypeId="2" ParentId="514" CreationDate="2015-02-06T13:58:07.517" Score="57" Body="&lt;p&gt;This is one of the few reasons I like to use vim's mouse mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use the GUI version, or your terminal supports sending drag events (such as xterm or rxvt-unicode) you can click on the split line and drag to resize the window exactly where you want, without a lot of guess work using the ctrl-w plus,minus,less,greater combinations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terminal versions, you have to set mouse mode properly for this to work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set mouse=n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I use 'n', but 'a' also works)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and you have to set the tty mouse type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ttymouse=xterm2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A lot of people say that a lot of time is wasted using the mouse (mostly due to the time it takes to move your hand from the keyboard to the mouse and back), but I find that, in this case, the time saved by having immediate feedback while adjusting the window sizes and the quickness of re-resizing (keep moving the mouse instead of typing another key sequence) outweighs the delay of moving my hand.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="18158" LastEditDate="2020-02-17T07:47:37.067" LastActivityDate="2020-02-17T07:47:37.067" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="522" PostTypeId="2" ParentId="501" CreationDate="2015-02-06T14:05:48.777" Score="6" Body="&lt;p&gt;In addition to the raw vim functionality mentioned by 200_success, Vim's ecosystem is full of plugins to provide extra functionality, such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim-scripts/FuzzyFinder&quot; rel=&quot;nofollow noreferrer&quot;&gt;FuzzyFinder&lt;/a&gt; (my plugin of choice)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim-scripts/LustyExplorer&quot; rel=&quot;nofollow noreferrer&quot;&gt;LustyExplorer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;ctrlp.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/wincent/Command-T&quot; rel=&quot;nofollow noreferrer&quot;&gt;Command-T&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Many others, a bunch of which were mentioned in a &lt;a href=&quot;https://stackoverflow.com/questions/9148887/buffer-explorer-for-vim&quot;&gt;Stack Overflow question&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, before you go and start using plugins, it's best to fully understand buffers and windows in vim.&lt;/p&gt;&#xA;" OwnerUserId="306" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-02-06T14:05:48.777" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="523" PostTypeId="2" ParentId="519" CreationDate="2015-02-06T14:13:06.280" Score="9" Body="&lt;p&gt;I don't think there's any way to do this, however a better approach in this case would be to leverage vim's folding to fold away part of the code between the structures you're interested in and that can make it a lot more easy for you to visually see the matching brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;%&lt;/code&gt; to jump between the start &amp;amp; end parenthesis too to get a fair idea of where's what.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-06T14:13:06.280" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="524" PostTypeId="2" ParentId="510" CreationDate="2015-02-06T14:22:38.227" Score="3" Body="&lt;p&gt;With VIM I believe the plugins that are there to do this aren't all that great, though IMO vimshell comes the closest. However you need to understand that it's a 2 part problem.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;VIM wasn't designed to be able to do things like this, especially cumbersome is being able to execute any long running task and talking to it asynchronously without blocking VIM. In this case it's not only the shell itself but also other tasks that you might execute within the shell process.&lt;/li&gt;&#xA;&lt;li&gt;VIM's modal philosophy doesn't play all that well with the way we interact with a shell. In a shell only the current line is editable, although you can scroll and see the older text of your history with shell you can't edit it. This does not fit into the VIM's philosophy at all, if you were to press ESC and go back to normal mode it would becomes quite hard to disallow a user to go back and edit parts of the history above.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In my opinion there are 2 approaches that work much better in this regards.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Using TMUX / Screen and multiplex terminal windows to have both the vim and the shell. That way the two are neatly separated and yet you can view both with very little effort and the two can work to the best of their potential without conflicting with each other's flow.&lt;/li&gt;&#xA;&lt;li&gt;Using plugins like &lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow&quot;&gt;tpope/vim-dispatch&lt;/a&gt; and the likes you can easily launch one off shell commands and have them run asynchronously in the background in an actual terminal shell and pull back the results into vim once it's complete. This also provides you with the same level of isolation between the two and hence the two can again work to the best of their abilities without stepping on each others' toes.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I should add that there is a good likelihood that NeoVIM may bring about a change in this aspect since one of it's core goals is being able to execute jobs asynchronously. But until then this is the best we can get in my opinion.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-06T14:22:38.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="525" PostTypeId="2" ParentId="124" CreationDate="2015-02-06T15:10:40.453" Score="7" Body="&lt;p&gt;You can tell a Vim server to reload the vimrc file like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --servername MARTIN --remote-send '&amp;lt;Esc&amp;gt;:source $MYVIMRC&amp;lt;CR&amp;gt;' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can get a list of all servers with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --serverlist&#xA;MARTIN&#xA;CARPETSMOKER&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be combined with a &lt;code&gt;for&lt;/code&gt; loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ for s in $(vim --serverlist); do vim --servername &quot;$s&quot; --remote-send '&amp;lt;Esc&amp;gt;:source $MYVIMRC&amp;lt;CR&amp;gt;'; done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since that's a lot of typing, you could put it in a shell script in &lt;code&gt;~/bin/reload-vimrc&lt;/code&gt;; you can of course also call it from within Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!reload-vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're running Linux, and want to get really crazy, you could use &lt;a href=&quot;http://linux.die.net/man/1/inotifywatch&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;inotifywatch&lt;/code&gt;&lt;/a&gt; from &lt;a href=&quot;https://github.com/rvoicilas/inotify-tools&quot; rel=&quot;noreferrer&quot;&gt;inotify-tools&lt;/a&gt; to monitor your vimrc file(s) for changes, and execute this automatically on every change (untested, example adapted from manpage)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ inotifywatch -v -e modify -t 60 -r ~/.vimrc ~/.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wouldn't recommend this, though ... If you accidentally save a file with a&#xA;syntax error you could bork all your vim session...&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-06T15:15:47.730" LastActivityDate="2015-02-06T15:15:47.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="526" PostTypeId="1" AcceptedAnswerId="527" CreationDate="2015-02-06T15:34:40.263" Score="4" ViewCount="103" Body="&lt;p&gt;I'm having a problem using the command-line window (&lt;code&gt;help cmdwin&lt;/code&gt;),&#xA;which is extremely useful, but it doesn't play well with macros.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;cmdwin is invoked with &lt;code&gt;q:&lt;/code&gt;, so if there is a macro being recorded, the 'q' ends the recording.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the general chain of events:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qw          # start recording a macro in register w&#xA;q:          # enter cmdwin to perform a command,&#xA;            # expecting it to be recorded, but the q cancels the&#xA;            # macro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't think it's relevant, but I have &lt;code&gt;:&lt;/code&gt; mapped to &lt;code&gt;q:&lt;/code&gt;, making&#xA;cmdwin the default way of invoking commands.  I &lt;em&gt;love&lt;/em&gt; cmdwin, but&#xA;macros are essential.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make them play nicely?&lt;/p&gt;&#xA;" OwnerUserId="319" LastEditorUserId="51" LastEditDate="2015-02-06T19:56:42.430" LastActivityDate="2015-02-06T19:56:42.430" Title="Can the command-line window be entered without interrupting macro recording?" Tags="|command-line|macro|command-line-window|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="527" PostTypeId="2" ParentId="526" CreationDate="2015-02-06T15:38:52.670" Score="7" Body="&lt;p&gt;You can access the command line window with the alternate command &lt;code&gt;:&amp;lt;C-F&amp;gt;&lt;/code&gt;, i.e. press &lt;kbd&gt;Ctrl-F&lt;/kbd&gt; when in command line mode. Eventually you can rebind &lt;code&gt;:&lt;/code&gt; to &lt;code&gt;:&amp;lt;C-F&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2015-02-06T16:14:12.170" LastActivityDate="2015-02-06T16:14:12.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="528" PostTypeId="1" AcceptedAnswerId="593" CreationDate="2015-02-06T16:14:15.740" Score="6" ViewCount="834" Body="&lt;p&gt;It is easy to move to a specific character on the same line with &lt;code&gt;t&lt;/code&gt; or &lt;code&gt;f&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However often it is useful to move to the specific character that is positioned on a different line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider this example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;smth smth smth&#xA;bla bla bla &#xA;|&#xA;&#xA;more bla bla bla&#xA;&#xA;maybe some more bla&#xA;&#xA;the end ```&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here &lt;code&gt;|&lt;/code&gt; represents the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an easy way to move the cursor to the three ticks after the &lt;code&gt;end&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What seems to be required is for &lt;code&gt;f&lt;/code&gt; or &lt;code&gt;t&lt;/code&gt; commands to ignore the new line symbol. But I don't know how to achieve that.&lt;/p&gt;&#xA;" OwnerUserId="307" LastActivityDate="2015-02-07T20:35:39.953" Title="Move vertically to a specific character on a different line" Tags="|cursor-movement|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="529" PostTypeId="1" AcceptedAnswerId="532" CreationDate="2015-02-06T16:20:11.510" Score="6" ViewCount="77" Body="&lt;p&gt;I have somewhat customised vim to my needs what I would like to do would be to add a cheatsheet, documenting these customisations and other things I often forget to the vim help system. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that it can be extended by plugins is there another way to expand the vim help system? writing a plugin seems overkill for what I want to achieve. &lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2015-02-06T16:35:39.223" Title="Is there any way to add to the help system without developing a plugin" Tags="|help-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="531" PostTypeId="2" ParentId="528" CreationDate="2015-02-06T16:25:36.653" Score="5" Body="&lt;p&gt;You could check out the &lt;a href=&quot;https://github.com/Lokaltog/vim-easymotion&quot;&gt;EasyMotion&lt;/a&gt; plugin.  With that you could do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;&amp;lt;Leader&amp;gt;f`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which would show you all of the backticks you could possibly jump to and give you a shortcut for doing so.&lt;/p&gt;&#xA;" OwnerUserId="93" LastActivityDate="2015-02-06T16:25:36.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="532" PostTypeId="2" ParentId="529" CreationDate="2015-02-06T16:35:39.223" Score="8" Body="&lt;p&gt;Adding a help file is actually fairly easy: as documented in &lt;a href=&quot;http://vimhelp.appspot.com/usr_05.txt.html#05.5&quot;&gt;&lt;code&gt;:help add-local-help&lt;/code&gt;&lt;/a&gt;, you plop it in &lt;code&gt;~/.vim/doc&lt;/code&gt; and then run &lt;code&gt;:helptags ~/.vim/doc&lt;/code&gt;. That's (part of) what your plugin manager is doing for you when you install a plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can confirm its been added by running &lt;code&gt;:help local-additions&lt;/code&gt;; all the local help files should be listed there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need help writing help files, there is some advice in &lt;a href=&quot;http://vimhelp.appspot.com/helphelp.txt.html#help-writing&quot;&gt;&lt;code&gt;:help help-writing&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="31" LastActivityDate="2015-02-06T16:35:39.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="533" PostTypeId="2" ParentId="528" CreationDate="2015-02-06T16:38:19.947" Score="5" Body="&lt;p&gt;IMO it isn't useful to move to a character on a separate line. There are only 26 characters in the english language and it doesn't take a lot of characters before most of the characters repeat enough times for them to not be unique.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although in rare case it is still possible to encounter such a situation but I think making that assumption would be wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion when you have to move to another section within the same file you have to resort to other better motions that vim provides. There are far too many options at your disposal to list here but the most common that comes to my mind is via searching. You can always enable &lt;code&gt;incsearch&lt;/code&gt; and just start searching with &lt;code&gt;/t&lt;/code&gt; and that would be a better way to get to your character on another line than the character motions like &lt;code&gt;f&lt;/code&gt;,&lt;code&gt;t&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-06T16:38:19.947" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="534" PostTypeId="1" AcceptedAnswerId="535" CreationDate="2015-02-06T16:42:47.877" Score="11" ViewCount="5682" Body="&lt;p&gt;I'm trying to fold some PHP code, and I have included a cut-down version of some of the code I'm trying to fold at the end of the post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried the following vim commands, but only the ex commands below work. The non-ex commands don't work and produce a white-on-red message in the status line saying: I can't find any folds.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help folding&#xA;:help fold-commands&#xA;:help foldmethod&#xA;&#xA;:set foldmethod=syntax&#xA;&#xA;zi - toggle folding&#xA;&#xA;zj - move to top of next fold&#xA;zk - move to bottom of previous fold&#xA;&#xA;za - toggle current fold open and closed&#xA;zo - open current fold&#xA;zc - close current fold&#xA;&#xA;zA - toggle all current folds at the current cursor position&#xA;zO - open all current folds at the current cursor position&#xA;zC - close all current folds at the current cursor position&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get vim to find the folds (e.g. I want to fold code between &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;, or between &lt;code&gt;(&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some sample code (just to show that it is syntactically correct and hence the vim commands should work):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function getTree() {&#xA;&#xA;  return array(&#xA;    &quot;node1&quot; =&amp;gt; array(&#xA;      &quot;node11&quot; =&amp;gt; array(&#xA;        &quot;node111&quot; =&amp;gt; &quot;leaf111&quot;,&#xA;        &quot;node112&quot; =&amp;gt; &quot;leaf112&quot;,&#xA;        &quot;node113&quot; =&amp;gt; &quot;leaf113&quot;,&#xA;      ),&#xA;          &quot;node12&quot; =&amp;gt; array(&#xA;        &quot;node121&quot; =&amp;gt; &quot;leaf121&quot;,&#xA;        &quot;node122&quot; =&amp;gt; &quot;leaf122&quot;,&#xA;        &quot;node123&quot; =&amp;gt; &quot;leaf123&quot;,&#xA;      ),&#xA;      &quot;node13&quot; =&amp;gt; array(&#xA;        &quot;node131&quot; =&amp;gt; &quot;leaf131&quot;,&#xA;        &quot;node132&quot; =&amp;gt; &quot;leaf132&quot;,&#xA;        &quot;node133&quot; =&amp;gt; &quot;leaf133&quot;,&#xA;      ),&#xA;    ),&#xA;    &quot;node2&quot; =&amp;gt; array(&#xA;      &quot;node21&quot; =&amp;gt; array(&#xA;        &quot;node211&quot; =&amp;gt; &quot;leaf211&quot;,&#xA;        &quot;node212&quot; =&amp;gt; &quot;leaf212&quot;,&#xA;        &quot;node213&quot; =&amp;gt; &quot;leaf213&quot;,&#xA;      ),&#xA;          &quot;node22&quot; =&amp;gt; array(&#xA;        &quot;node221&quot; =&amp;gt; &quot;leaf221&quot;,&#xA;        &quot;node222&quot; =&amp;gt; &quot;leaf222&quot;,&#xA;        &quot;node223&quot; =&amp;gt; &quot;leaf223&quot;,&#xA;      ),&#xA;      &quot;node23&quot; =&amp;gt; array(&#xA;        &quot;node231&quot; =&amp;gt; &quot;leaf231&quot;,&#xA;        &quot;node232&quot; =&amp;gt; &quot;leaf232&quot;,&#xA;        &quot;node233&quot; =&amp;gt; &quot;leaf233&quot;,&#xA;      ),&#xA;    ),&#xA;    &quot;node3&quot; =&amp;gt; array(&#xA;      &quot;node31&quot; =&amp;gt; array(&#xA;        &quot;node311&quot; =&amp;gt; &quot;leaf311&quot;,&#xA;        &quot;node312&quot; =&amp;gt; &quot;leaf312&quot;,&#xA;        &quot;node313&quot; =&amp;gt; &quot;leaf313&quot;,&#xA;      ),&#xA;          &quot;node32&quot; =&amp;gt; array(&#xA;        &quot;node321&quot; =&amp;gt; &quot;leaf321&quot;,&#xA;        &quot;node322&quot; =&amp;gt; &quot;leaf322&quot;,&#xA;        &quot;node323&quot; =&amp;gt; &quot;leaf323&quot;,&#xA;      ),&#xA;      &quot;node33&quot; =&amp;gt; array(&#xA;        &quot;node331&quot; =&amp;gt; &quot;leaf331&quot;,&#xA;        &quot;node332&quot; =&amp;gt; &quot;leaf332&quot;,&#xA;        &quot;node333&quot; =&amp;gt; &quot;leaf333&quot;,&#xA;      ),&#xA;    ),&#xA;  );&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastEditorUserId="24" LastEditDate="2015-02-06T21:39:03.673" LastActivityDate="2015-02-06T21:39:03.673" Title="Folding fails: vim can't find any fold" Tags="|ide|folding|filetype-php|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="535" PostTypeId="2" ParentId="534" CreationDate="2015-02-06T16:52:18.583" Score="11" Body="&lt;p&gt;Vim doesn't come with PHP syntax folding built-in. However, if all of your code is properly indented (as your example is), you can use a different fold method:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set foldmethod=indent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-06T16:52:18.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="536" PostTypeId="2" ParentId="528" CreationDate="2015-02-06T16:53:51.853" Score="5" Body="&lt;p&gt;A search would do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/`&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-06T16:53:51.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="537" PostTypeId="2" ParentId="241" CreationDate="2015-02-06T16:59:40.730" Score="18" Body="&lt;p&gt;The simplest way to do this is probably with session files, which are vim scripts (that vim can automatically produce for you) that will restore a previous editing environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create a new session file using &lt;code&gt;:mksession &amp;lt;filename&amp;gt;&lt;/code&gt;. You can restore that session by executing the generated session script, &lt;code&gt;:source &amp;lt;filename&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, you could save the current session prior to maximizing a window and restore it when you want to &quot;unmaximize&quot; the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this, you could remap the appropriate windowing commands to save a session beforehand, and add a new mapping for one to &quot;undo&quot; the last windowing command by restoring the session. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap &amp;lt;C-w&amp;gt;o :mksession! ~/session.vim&amp;lt;CR&amp;gt;:wincmd o&amp;lt;CR&amp;gt;&lt;/code&gt; and so on for all the windowing commands you want to support (see &lt;code&gt;:help CTRL-W&lt;/code&gt;, there's a lot). The &lt;code&gt;!&lt;/code&gt; prevents errors relating to overwriting an existing session file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap &amp;lt;C-w&amp;gt;u :source ~/session.vim&amp;lt;CR&amp;gt;&lt;/code&gt; to &quot;undo&quot; the last windowing command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you wanted to be particularly robust, you could extend this via functions to save the session files in a stack and pop them off to get a full undo chain, although at that point it's probably more efficient to write a bunch of functions to track the window command history in memory... at which point you are likely duplicating the plugins that do this sort of thing already.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-02-06T16:59:40.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="538" PostTypeId="1" CreationDate="2015-02-06T17:06:41.467" Score="7" ViewCount="2390" Body="&lt;p&gt;Here is a simple text-based flowchart I made in Vim for a weblog post:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;               [DNS request]&#xA;                    |&#xA;                    |&#xA;                 [Adsuck]&#xA;                    |&#xA;                    |&#xA;                 &amp;lt;block?&amp;gt;&#xA;                    |&#xA;                   / \&#xA;                  /   \&#xA;              &amp;lt;YES&amp;gt;    \-&amp;gt; &amp;lt;NO&amp;gt; --&amp;gt; [unbound lookup]&#xA;                |&#xA;                v&#xA;            [noop.py]&#xA;                |&#xA;                |&#xA;        &amp;lt;Have noop script?&amp;gt;&#xA;                |&#xA;               / \&#xA;              /   \&#xA;           &amp;lt;YES&amp;gt;   \-&amp;gt; &amp;lt;NO&amp;gt; --&amp;gt; [serve empty GIF]&#xA;             |&#xA;             v&#xA;    [serve noop script]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is, is that it can be rather painstaking; change one thing, and you need to change everything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything I can do to make this easier? I don't really care about the above layout of the flowchart &lt;em&gt;as such&lt;/em&gt;, as long as it looks flowchart-y it's fine. Flowcharts may also be horizontal as far as I'm concerned, although I prefer vertical like above.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="24" LastEditDate="2015-02-06T22:44:48.290" LastActivityDate="2015-02-06T22:44:48.290" Title="Creating &amp; maintaining flowcharts in Vim" Tags="|alignment|ascii-art|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="539" PostTypeId="2" ParentId="538" CreationDate="2015-02-06T17:12:26.517" Score="-1" Body="&lt;p&gt;You might try the &lt;a href=&quot;https://github.com/vim-scripts/DrawIt&quot; rel=&quot;nofollow&quot;&gt;DrawIt&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;DrawIt is a plugin which allows one to draw lines left, right, up,&#xA;  down, and along both slants. Optionally one may &quot;cap&quot; the lines with&#xA;  arrowheads.  One may change the horizontal, vertical, slant, and&#xA;  crossing characters to whichever characters one wishes.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="93" LastActivityDate="2015-02-06T17:12:26.517" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="540" PostTypeId="2" ParentId="534" CreationDate="2015-02-06T17:13:10.977" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/rayburgemeestre/phpfolding.vim&quot;&gt;phpfolding.vim&lt;/a&gt; provides this. The advantage of this over &lt;code&gt;:set foldmethod=indent&lt;/code&gt; is that it's &quot;smarter&quot; because it looks at the actual PHP syntax, and not just the indentation. From the README:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;It remembers fold settings. If you add functions and execute the script again,   your opened folds will not be closed.&lt;/li&gt;&#xA;  &lt;li&gt;It will not be confused by brackets in comment blocks or string literals.&lt;/li&gt;&#xA;  &lt;li&gt;The folding of class properties with their PhpDoc comments.&lt;/li&gt;&#xA;  &lt;li&gt;The folding of all class properties into one fold.&lt;/li&gt;&#xA;  &lt;li&gt;Folding the original marker style folds too.&lt;/li&gt;&#xA;  &lt;li&gt;An &quot;**&quot; postfixing the fold indicates PhpDoc is inside (configurable).&lt;/li&gt;&#xA;  &lt;li&gt;An &quot;**#@+&quot; postfixing the fold indicates PhpDocBlock is inside (configurable).&lt;/li&gt;&#xA;  &lt;li&gt;Empty lines postfixing the folds can be configured to be included in the fold.&lt;/li&gt;&#xA;  &lt;li&gt;Nested folds are supported (functions inside functions, etc.)&lt;/li&gt;&#xA;  &lt;li&gt;Folding private, public, protected class variables + multi-line param.&lt;/li&gt;&#xA;  &lt;li&gt;Foloding the class is now an option disabled by default.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Install it by downloading the &lt;code&gt;.vim&lt;/code&gt; script, and putting it in &lt;code&gt;~/.vim/ftplugin/php/&lt;/code&gt; (or use your plugin manager, if you use one). It will fold automatically, which you can disable with &lt;code&gt;let g:DisableAutoPHPFolding = 1&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-06T17:13:10.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="541" PostTypeId="2" ParentId="538" CreationDate="2015-02-06T18:01:15.387" Score="15" Body="&lt;p&gt;Rather than use vim to directly attempt to manipulate ASCII art, why not use vim to edit a file format that defines a graph? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.graphviz.org/pdf/dotguide.pdf&quot;&gt;dot format&lt;/a&gt; is a fairly compact way to represent graphs. A rough approximation of the graph  you outlined in your example would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digraph {&#xA;  start -&amp;gt; adsuck;&#xA;  adsuck -&amp;gt; block;&#xA;  block -&amp;gt; noop[label=&quot;yes&quot;];&#xA;  block -&amp;gt; unbound[label=&quot;no&quot;];&#xA;  noop -&amp;gt; serve_noop[label=&quot;yes&quot;];&#xA;  noop -&amp;gt; serve_empty[label=&quot;no&quot;];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can use Perl's &lt;a href=&quot;http://search.cpan.org/~tels/Graph-Easy/lib/Graph/Easy.pm&quot;&gt;Graph::Easy&lt;/a&gt; module to render the graph into a variety of output formats, including ASCII text. It can also produce HTML pages, SVG, PNG, et cetera. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install Perl if you don't have it, install Graph::Easy (&lt;code&gt;cpanm Graph::Easy&lt;/code&gt;, see &lt;a href=&quot;http://www.cpan.org/modules/INSTALL.html&quot;&gt;here&lt;/a&gt; for details). This will give you a &lt;code&gt;graph-easy&lt;/code&gt; command-line tool. Create &lt;code&gt;yourgraph.dot&lt;/code&gt; or whatever (vim has syntax knowledge of the dot format already, and there are also &lt;a href=&quot;https://github.com/wannesm/wmgraphviz.vim&quot;&gt;related plugins&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run &lt;code&gt;graph-easy --as ascii yourgraph.dot output.txt&lt;/code&gt; and you'll get something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                      +-------------+&#xA;                      |    start    |&#xA;                      +-------------+&#xA;                        |&#xA;                        |&#xA;                        v&#xA;                      +-------------+&#xA;                      |   adsuck    |&#xA;                      +-------------+&#xA;                        |&#xA;                        |&#xA;                        v&#xA;+------------+  no    +-------------+&#xA;|  unbound   | &amp;lt;----- |    block    |&#xA;+------------+        +-------------+&#xA;                        |&#xA;                        | yes&#xA;                        v&#xA;+------------+  yes   +-------------+&#xA;| serve_noop | &amp;lt;----- |    noop     |&#xA;+------------+        +-------------+&#xA;                        |&#xA;                        | no&#xA;                        v&#xA;                      +-------------+&#xA;                      | serve_empty |&#xA;                      +-------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's not quite as pretty, but it's a heck of lot easier to edit the dot file than to manipulate all the ASCII art. I found that &lt;a href=&quot;http://melp.nl/2013/08/flow-charts-in-code-enter-graphviz-and-the-dot-language/&quot;&gt;this article&lt;/a&gt; was a pretty nice write-up about building flowcharts with the dot format.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-02-06T18:01:15.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="542" PostTypeId="2" ParentId="477" CreationDate="2015-02-06T18:06:34.450" Score="4" Body="&lt;p&gt;You can use the command &lt;code&gt;folddoopen&lt;/code&gt; to execute a command only on the lines that are &lt;em&gt;not&lt;/em&gt; within a closed fold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you can remove whitespace from the end of lines with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\s\+$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To apply this only to the lines that are currently not within a closed fold, add &lt;code&gt;folddopen&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%folddoopen s/\s\+$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;folddoopen&lt;/code&gt; can also be abbreviated to &lt;code&gt;foldd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using Vim as your source control's diff tool, then you can use this to apply edits only to changed lines whilst viewing the diff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that by default, Vim's diff mode displays a few lines before and after each changed section. So in order not to affect lines that are immediately before or after changed lines you'll need to first set &lt;code&gt;context&lt;/code&gt; in &lt;code&gt;diffopt&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt; e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set diffopt=filler,context:0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For manual edits, you might also find the &lt;code&gt;foldopen&lt;/code&gt; option to be useful. It defines which types of commands will cause folds to open. Although note that it does &lt;em&gt;not&lt;/em&gt; prevent editing from taking place within the folds in the way that the &lt;code&gt;folddoopen&lt;/code&gt; command does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If you mean something else by &quot;the lines of the files which were actually modified&quot; then you're going to have to find a way of folding away the unchanged lines before you run the command: the easiest way is to keep an unchanged copy of the file and use vimdiff manually.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2015-02-08T09:27:07.117" LastActivityDate="2015-02-08T09:27:07.117" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="543" PostTypeId="1" AcceptedAnswerId="548" CreationDate="2015-02-06T18:17:07.917" Score="26" ViewCount="1608" Body="&lt;p&gt;I know many people store their .vimrc on GitHub to make it easier to get right to work on new machines, and that makes complete sense to me. Including plugins, however, is problematic, because the plugins I use are already git repositories. How does one create a repo that will track both their .vimrc and any plugins that might be installed?&lt;/p&gt;&#xA;" OwnerUserId="163" LastEditorUserId="51" LastEditDate="2015-02-06T18:54:42.883" LastActivityDate="2015-02-10T14:02:26.233" Title="GitHub for .vimrc and plugins" Tags="|vimrc|plugin-system|" AnswerCount="5" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="544" PostTypeId="2" ParentId="310" CreationDate="2015-02-06T18:46:20.420" Score="2" Body="&lt;p&gt;I think adding something like this to your &lt;code&gt;.vimrc&lt;/code&gt; may solve your problems (note, however, that I don't actually use this and have only done minimal testing, it may do strange things in some cases):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! OpenArgumentsInTabs()&#xA;  ardo tabedit&#xA;  if tabpagenr(&quot;$&quot;) &amp;gt; 1&#xA;    tabclose&#xA;  endif&#xA;endfunction&#xA;&#xA;autocmd VimEnter * call OpenArgumentsInTabs()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you noted, &lt;code&gt;argdo tabedit&lt;/code&gt; will leave you an empty extra tab. So you can simply close that tab automatically. However, you can't just invoke &lt;code&gt;tabclose&lt;/code&gt; unchecked, or vim will give you an error when you launch it without arguments or a single file (you &quot;can't close the last tab&quot;). Instead, check to see if the total number of tabs is greater than one (that's what &lt;code&gt;$&lt;/code&gt; causes &lt;code&gt;tabpagenr&lt;/code&gt; to return) and only then do you need to close the last tab.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That said, I feel like it's worth pointing out that &lt;a href=&quot;https://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers/103590#103590&quot;&gt;vim's tabs aren't quite like other editors' tabs&lt;/a&gt;, and that's something to keep in mind when considering how to use tabs in your workflow (you seem to be aware of this, but I want to make the point for the benefit of future readers who might not so they can make their own decisions).&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-06T18:57:00.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="545" PostTypeId="2" ParentId="543" CreationDate="2015-02-06T18:49:00.577" Score="24" Body="&lt;p&gt;You don't need to store plugins in your VCS; you can also use a Vim package manager. Since yesterday, I use &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;noreferrer&quot;&gt;vim-plug&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can define plugins in your vimrc like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'embear/vim-localvimrc'&#xA;Plug 'kchmck/vim-coffee-script'&#xA;&quot; ... etc&#xA;&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then restart Vim, and then install plugins with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PlugInstall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, you can add &lt;a href=&quot;https://github.com/junegunn/vim-plug/wiki/faq#automatic-installation&quot; rel=&quot;noreferrer&quot;&gt;this snippet from the FAQ&lt;/a&gt; to your vimrc file before the &lt;code&gt;plug#begin()&lt;/code&gt; call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if empty(glob('~/.vim/autoload/plug.vim'))&#xA;  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs&#xA;    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;  autocmd VimEnter * PlugInstall&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will put the plugins in &lt;code&gt;~/.vim/plugged&lt;/code&gt;. &lt;em&gt;You do not need to keep this file in your VCS&lt;/em&gt;. If you want to use this vimrc on another machine, just call &lt;code&gt;:PlugInstall&lt;/code&gt; on that machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to remove a plugin, remove it from the vimrc file and run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PlugClean&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that vim-plug doesn't support installing scripts from the Vim scripts website, but &lt;a href=&quot;https://github.com/vim-scripts&quot; rel=&quot;noreferrer&quot;&gt;those scripts are mirrored on GitHub&lt;/a&gt;, so there's no need to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also some additional advantages to this such as easier updating of plugin, and on-demand loading for better performance. You're also not running the risk of violating the license terms of the plugins you're distributing with your vimrc files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/388/51&quot;&gt;What is the difference between the vim package managers?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/624/51&quot;&gt;How to install a plugin in vim/vi?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-09T02:17:20.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="546" PostTypeId="2" ParentId="543" CreationDate="2015-02-06T18:56:57.397" Score="4" Body="&lt;p&gt;You can just add this line to your &lt;code&gt;.gitignore&lt;/code&gt; to ignore all your plugins and not commit them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim/bundle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, you said that it's problematic that it would include the plugin code because they're already github repos. I guess you mean that you don't want to duplicate the code, but I've heard it said that you should go ahead and duplicate code that's a dependency so that you can always go back to a particular point in your code and &lt;em&gt;know&lt;/em&gt; that it will work. Here are some articles by James Shore that talk about that: &lt;a href=&quot;http://www.letscodejavascript.com/v3/blog/2014/12/the_reliable_build&quot; rel=&quot;nofollow&quot;&gt;http://www.letscodejavascript.com/v3/blog/2014/12/the_reliable_build&lt;/a&gt;, &lt;a href=&quot;http://www.letscodejavascript.com/v3/blog/2014/03/the_npm_debacle&quot; rel=&quot;nofollow&quot;&gt;http://www.letscodejavascript.com/v3/blog/2014/03/the_npm_debacle&lt;/a&gt;. He's talking about programming code and npm (as opposed to vim), but I think the argument still applies, you want a reliable environment to code or write in.&lt;/p&gt;&#xA;" OwnerUserId="226" LastEditorUserId="226" LastEditDate="2015-02-06T20:23:21.387" LastActivityDate="2015-02-06T20:23:21.387" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="547" PostTypeId="1" AcceptedAnswerId="551" CreationDate="2015-02-06T18:58:28.677" Score="8" ViewCount="655" Body="&lt;p&gt;I'm currently doing a lot of work with both Ruby and JavaScript. I know that I can run my Ruby files with &lt;code&gt;:! ruby %&lt;/code&gt; and likewise my JavaScript with &lt;code&gt;:! node %&lt;/code&gt;, and that I can bind either of those to, eg, &lt;code&gt;,b&lt;/code&gt;. How can I set things up so that I can just bind a single command that will check the extension of the file I'm editing and run the appropriate command?&lt;/p&gt;&#xA;" OwnerUserId="163" LastEditorUserId="24" LastEditDate="2015-02-09T15:41:42.953" LastActivityDate="2015-02-09T15:41:42.953" Title="Run shell commands on current file based on file extension" Tags="|key-bindings|external-command|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="548" PostTypeId="2" ParentId="543" CreationDate="2015-02-06T19:04:33.747" Score="18" Body="&lt;p&gt;How to deal with repositories-within-repositories has been an ongoing question with git. Git's &lt;a href=&quot;http://git-scm.com/docs/git-submodule&quot;&gt;submodules&lt;/a&gt; are one way of addressing the situation, at the expense of adding a little more complexity to keep track of. The git site has &lt;a href=&quot;http://git-scm.com/book/en/v2/Git-Tools-Submodules&quot;&gt;an introduction to submodules&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic idea is to keep a reference to another git repository associated with a path on your repository. These references are stored in a file &lt;code&gt;.gitmodules&lt;/code&gt; in the root of your repository (which is managed by git, so leave it alone). Some of the complexity comes in to play when cloning a repo which has submodules: you must explicitly &lt;code&gt;git submodule init&lt;/code&gt; to create the &lt;code&gt;.gitmodules&lt;/code&gt; file, and then &lt;code&gt;git submodule update&lt;/code&gt; to clone the submodules.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's a walkthrough of how I'll add a new vim plugin to my dotfiles repository (I have &lt;code&gt;~/.vim/&lt;/code&gt; aliased to this repo's &lt;code&gt;.vim/&lt;/code&gt;) using a submodule:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd dotfiles/&#xA;$ git submodule add https://github.com/elixir-lang/vim-elixir.git .vim/bundle/vim-elixir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After the &lt;code&gt;submodule add&lt;/code&gt;, a &lt;code&gt;git status&lt;/code&gt; would show that you've modified (or created) the &lt;code&gt;.gitmodules&lt;/code&gt; file, with something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[submodule &quot;.vim/bundle/vim-elixir&quot;]&#xA;    path = .vim/bundle/vim-elixir&#xA;    url = https://github.com/elixir-lang/vim-elixir.git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should also show &lt;code&gt;.vim/bundle/vim-elixir&lt;/code&gt; as a new file. Git treats that path specially now: it's a normal directory on your file system (so vim loads it up normally), but &lt;code&gt;git diff&lt;/code&gt; will treat it as a specific commit from its repository. When looking at diffs or logs for that path (e.g. &lt;code&gt;git log -1 -u .vim/bundle/vim-elixir&lt;/code&gt;), git will show it as a one-line string like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Subproject commit 2d59d1d52a9bcf9342d42fa7d6b59e6a1aaa7b9e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Updating to the latest version of the plugin corresponds to going into the submodule's repository and checking out a new commit, and then committing &lt;em&gt;that&lt;/em&gt; to your repository:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd .vim/bundle/vim-elixir&#xA;$ git remote -v            # note: the submodule repo's origin, not my repo's&#xA;origin  https://github.com/elixir-lang/vim-elixir.git (fetch)&#xA;origin  https://github.com/elixir-lang/vim-elixir.git (push)&#xA;&#xA;$ git pull&#xA;# ...&#xA;&#xA;$ cd -     # back to my repository's root&#xA;$ git status&#xA;# ...&#xA;    modified:   .vim/bundle/vim-elixir (new commits)&#xA;&#xA;$ git diff .vim/bundle/vim-elixir&#xA;# ...&#xA;-Subproject commit 2d59d1d52a9bcf9342d42fa7d6b59e6a1aaa7b9e&#xA;+Subproject commit d59784e7afbd0d55c501e40c43b57cbe6f6e04c2&#xA;&#xA;$ git commit -m &quot;update vim-elixir&quot; .vim/bundle/vim-elixir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2015-02-06T20:18:39.953" LastActivityDate="2015-02-06T20:18:39.953" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="549" PostTypeId="2" ParentId="501" CreationDate="2015-02-06T19:11:36.557" Score="5" Body="&lt;p&gt;If you want to open a particular file without needing to go through &lt;code&gt;:ls&lt;/code&gt;, you can use any of the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:vs filename&lt;/code&gt; opens the file in a vertical split&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:sp filename&lt;/code&gt; does the same, but in a horizontal split&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabe filename&lt;/code&gt; opens in a new tab&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It's worth knowing, too, that if you don't specify a filename, you will open a new split/tab of the current file, which can be handy for long files.&lt;/p&gt;&#xA;" OwnerUserId="163" LastEditorUserId="163" LastEditDate="2015-02-09T23:06:11.840" LastActivityDate="2015-02-09T23:06:11.840" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="550" PostTypeId="2" ParentId="543" CreationDate="2015-02-06T19:12:28.690" Score="5" Body="&lt;p&gt;If you would like to stick with Pathogen, one way could be to use &lt;a href=&quot;http://git-scm.com/docs/git-submodule&quot; rel=&quot;nofollow&quot;&gt;Git submodules&lt;/a&gt;. When you add a submodule, git recognizes it as from another repository and leaves its contents alone (unless it has been changed, in which case, it will show up as having untracked content when you do &lt;code&gt;git status&lt;/code&gt;). If you all your Github-based plugins are in &lt;code&gt;bundle/&lt;/code&gt;, then adding them as submodules is a fairly simple task with a good shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for f in bundle/*/ &#xA;do &#xA;    git submodule add $(awk '/url =/{print $3}' &quot;$f/.git/config&quot;) &quot;$f&quot;&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can have a look at how submodules show up at &lt;a href=&quot;https://github.com/murukeshm/vimrc/tree/master/bundle&quot; rel=&quot;nofollow&quot;&gt;my vimrc repo&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you add a file to a submodule, or make some changes that don't affect the repository, &lt;code&gt;git status&lt;/code&gt; will still complain about the submodule having uncommitted changes or untracked files. You can make git ignore such changes by adding &lt;code&gt;ignore = dirty&lt;/code&gt; to the submodule configuration in the &lt;code&gt;.gitmodules&lt;/code&gt; file. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[submodule &quot;bundle/LaTeX-Box&quot;]&#xA;    path = bundle/syntastic&#xA;    url = https://github.com/scrooloose/syntastic.git&#xA;    ignore = dirty&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;One benefit of submodules is that revision of the submodule is added to the git repository, so that a &lt;code&gt;git init&lt;/code&gt; automatically takes care of checking out up that particular revision. You can throw that away and tell git to ignore submodules once you have added them by adding &lt;code&gt;ignore = all&lt;/code&gt; to their configuration in the &lt;code&gt;.gitmodules&lt;/code&gt; file. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[submodule &quot;bundle/LaTeX-Box&quot;]&#xA;    path = bundle/LaTeX-Box&#xA;    url = https://github.com/LaTeX-Box-Team/LaTeX-Box.git&#xA;    ignore = all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Lastly, one command to update them all!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git submodule foreach git pull&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Word of caution: I am new to submodules. I am not really sure how they behave.&lt;/h3&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-02-10T14:02:26.233" LastActivityDate="2015-02-10T14:02:26.233" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="551" PostTypeId="2" ParentId="547" CreationDate="2015-02-06T19:13:17.510" Score="10" Body="&lt;p&gt;You could use &lt;code&gt;:make&lt;/code&gt; for this; you can set &lt;code&gt;makeprg&lt;/code&gt; (short for make program) to any command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType ruby set makeprg=ruby\ %&#xA;au FileType javascript set makeprg=node\ %&#xA;au FileType python set makeprg=python\ %&#xA;au FileType coffeescript set makeprg=coffee\ -c\ %&#xA;&#xA;noremap ,b :make&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:make&lt;/code&gt; was originally intended to run the &lt;code&gt;make&lt;/code&gt; tool to build the project, but languages such as Ruby or Javascript don't need compiling, to setting it to something that will run the code makes sense.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-06T19:22:47.343" LastActivityDate="2015-02-06T19:22:47.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="552" PostTypeId="2" ParentId="543" CreationDate="2015-02-06T19:32:11.773" Score="5" Body="&lt;p&gt;I store my vimrc in github and the plugins as submodules of my repository.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the readme.md file I put a one liner that pulls the repository then runs the setup script, this way I can copy one line into an editor and it sets up everything. It does a bit more than just vim (but not much).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/Loki-Astari/UnixConfig&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Loki-Astari/UnixConfig&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd&#xA;git clone git@github.com:Loki-Astari/UnixConfig.git ~/.config&#xA;cd .config&#xA;git submodule init&#xA;git submodule update&#xA;chmod +x init&#xA;./init&#xA;cd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS. Willing to take any advice (as I did this ages ago and have not touched it since).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: My favorite part is that it sets up git as well and sets it up to use vim as the diff tool for git. Vimdiff is the the best diff tool.&lt;/p&gt;&#xA;" OwnerUserId="383" LastEditorUserId="383" LastEditDate="2015-02-06T19:41:44.130" LastActivityDate="2015-02-06T19:41:44.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="553" PostTypeId="2" ParentId="501" CreationDate="2015-02-06T19:46:01.003" Score="7" Body="&lt;p&gt;You can also open vim with different parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Opens files in tabs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -p debug.log*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Opens files in vertical splits:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -o debug.log*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There is a cool and quite powerful plugin called CtrlSpace:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/szw/vim-ctrlspace&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/szw/vim-ctrlspace&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is very handy if you need to work with many files. Simply you can imagine ctrl-space as own buffer list for every tab. It provides very easy way to navigate between the files, as the author states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim-CtrlSpace is a Vim plugin to control and organize your working&#xA;  space in Vim. Including managing buffers, files, tabs, sessions, and&#xA;  finally projects. Its approach is somewhat unique, but certainly you&#xA;  will feel at home, especially if you use already split windows, tabs,&#xA;  buffers, etc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="258" LastEditorUserId="258" LastEditDate="2015-02-09T07:54:53.510" LastActivityDate="2015-02-09T07:54:53.510" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="554" PostTypeId="1" AcceptedAnswerId="561" CreationDate="2015-02-06T19:51:51.780" Score="15" ViewCount="5757" Body="&lt;p&gt;Occasionally someone sends me a &lt;code&gt;.odt&lt;/code&gt;, &lt;code&gt;.doc&lt;/code&gt;, and &lt;code&gt;.docx&lt;/code&gt; file; opening them in OpenOffice is always a pain because, well, OpenOffice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I use a variety of commandline tools (such as &lt;code&gt;odt2txt&lt;/code&gt;) to convert these files to plain text, save the plain text to a temporary file, and then view (and maybe edit) it in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this be made easier? Perhaps something with autogroups? Or maybe there are better ways? I would like to just do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim file.odt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And have Vim take care of the converting for me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even better (bonus points) would be if I was also able to save the file (to &lt;code&gt;file.txt&lt;/code&gt;), but that this would &lt;em&gt;not&lt;/em&gt; be created until I do a write...&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-07T12:45:02.943" LastActivityDate="2015-08-07T12:45:02.943" Title="Is it possible to easily work with .odt, .doc, .docx, .rtf, and other non-plain-text formats in Vim?" Tags="|autocmd|load|word-processing|file-formats|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="555" PostTypeId="1" AcceptedAnswerId="560" CreationDate="2015-02-06T19:56:41.683" Score="59" ViewCount="15220" Body="&lt;p&gt;How can I see the Unicode code point of the character where the cursor is? For example, if my cursor is on a &lt;code&gt;⌘&lt;/code&gt; character, I'd like Vim to tell me that it is &lt;a href=&quot;https://codepoints.net/U+2318&quot;&gt;U+2318&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternative information, such as the base-10 representation (8984) or the UTF-8 representation (E2 8C 98) would be acceptable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ask about Unicode and UTF-8 because they are most common, but if the answer generalizes to other character sets and encodings, that would be good to know as well.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="51" LastEditDate="2015-04-26T09:47:50.433" LastActivityDate="2020-05-31T15:51:02.987" Title="See the Unicode code point of the current character" Tags="|statusline|unicode|encoding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="556" PostTypeId="5" CreationDate="2015-02-06T19:58:23.320" Score="0" Body="&lt;p&gt;In Vim's command-line window you can edit the command line just like editing&#xA;text in any window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be opened with &lt;code&gt;q:&lt;/code&gt; or &lt;code&gt;c_CTRL_F&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-07T01:24:20.397" LastActivityDate="2015-02-07T01:24:20.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="557" PostTypeId="4" CreationDate="2015-02-06T19:58:23.320" Score="0" Body="In Vim's command-line window you can edit the command line just like editing&#xD;&#xA;text in any window." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-07T01:24:27.070" LastActivityDate="2015-02-07T01:24:27.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="558" PostTypeId="5" CreationDate="2015-02-06T20:00:54.150" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-06T20:00:54.150" LastActivityDate="2015-02-06T20:00:54.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="559" PostTypeId="4" CreationDate="2015-02-06T20:00:54.150" Score="0" Body="Questions about editing prose (sentences and paragraphs)" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-07T01:24:23.403" LastActivityDate="2015-02-07T01:24:23.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="560" PostTypeId="2" ParentId="555" CreationDate="2015-02-06T20:09:57.247" Score="73" Body="&lt;p&gt;You can use &lt;code&gt;%b&lt;/code&gt; or &lt;code&gt;%B&lt;/code&gt; in &lt;code&gt;statusline&lt;/code&gt; or &lt;code&gt;rulerformat&lt;/code&gt;. From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27statusline%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help statusline&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b N   Value of character under cursor. &#xA;B N   As above, in hexadecimal. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%b\ 0x%B&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Gives you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;8984 0x2318&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another way is to use &lt;code&gt;ga&lt;/code&gt; or the &lt;code&gt;:ascii&lt;/code&gt; command. From &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#ga&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help ga&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:as[cii]        or                                      ga :as :ascii&#xA;ga                      Print the ascii value of the character under the&#xA;                        cursor in decimal, hexadecimal and octal.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will give you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;⌘&amp;gt; 8984, Hex 2318, Octal 21430&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another useful mapping is &lt;code&gt;g8&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;e2 8c 98&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which prints the hex value of the actual bytes stored in the file (this command assumes UTF-8).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition there are some plugins you could use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/chrisbra/unicode.vim&quot; rel=&quot;noreferrer&quot;&gt;unicode.vim&lt;/a&gt; adds various useful unicode-related commands. Use &lt;code&gt;:UnicodeName&lt;/code&gt; to get details of the character under the cursor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-characterize&quot; rel=&quot;noreferrer&quot;&gt;characterize.vim&lt;/a&gt;; this expands the &lt;code&gt;ga&lt;/code&gt; command with the unicode name, similar to unicode.vim.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;My own &lt;a href=&quot;https://github.com/arp242/uni&quot; rel=&quot;noreferrer&quot;&gt;uni&lt;/a&gt; CLI tool has a little &lt;a href=&quot;https://github.com/arp242/uni/blob/master/uni.vim&quot; rel=&quot;noreferrer&quot;&gt;Vim integration script&lt;/a&gt; which provides &lt;code&gt;:UnicodeName&lt;/code&gt; from unicode.vim (but none of the other features).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-05-31T15:51:02.987" LastActivityDate="2020-05-31T15:51:02.987" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="561" PostTypeId="2" ParentId="554" CreationDate="2015-02-06T20:13:53.043" Score="15" Body="&lt;p&gt;You should be able to add something like this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost *.odt :%!odt2txt %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will send the entire buffer through the &lt;code&gt;odt2txt&lt;/code&gt; program after it's read in by vim, but only if the file name ends with &lt;code&gt;.odt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1432&quot;&gt;textutil.vim&lt;/a&gt; plugin that says it can do what you're talking about for a few of those file types (but I haven't personally used it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're willing to edit in something slightly more structured than plain text, like markdown, you could also use &lt;a href=&quot;http://johnmacfarlane.net/pandoc/&quot;&gt;pandoc&lt;/a&gt; to do the conversion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost *.docx :%!pandoc -f docx -t markdown&#xA;autocmd BufWritePost *.docx :!pandoc -f markdown -t docx % &amp;gt; tmp.docx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't actually tested these conversions, but they should work. You may need to use different tools depending on the file format.&lt;/p&gt;&#xA;" OwnerUserId="126" LastEditorUserId="51" LastEditDate="2015-02-07T19:31:03.690" LastActivityDate="2015-02-07T19:31:03.690" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="562" PostTypeId="1" CreationDate="2015-02-06T23:16:04.997" Score="13" ViewCount="510" Body="&lt;p&gt;From time to time while working on multiple projects, and / or what ever, it leaves me with (too) many Vim instances open – as happens, I open a file which already is opened elsewhere, leaving me with the option of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[O]pen Read-only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there some built in way to raise the instance, as in GUI / terminal, holding the open file? Ideally bringing the file in question to the foreground (if multiple buffers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As of now I am using a bash script that extract PID from swap, check if that PID belongs to Vim, and if so uses &lt;code&gt;wmctrl&lt;/code&gt; to raise the window. While this works fine, at least for GUI and on X11 Linux, I am asking if there is a more native way.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="51" LastEditDate="2015-02-06T23:27:41.590" LastActivityDate="2015-09-24T19:40:04.653" Title="Raise window holding swap file" Tags="|swap-file|x11|linux|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="563" PostTypeId="1" AcceptedAnswerId="571" CreationDate="2015-02-07T01:36:03.467" Score="11" ViewCount="660" Body="&lt;p&gt;I can already map a key combination in insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap abc &amp;lt;do stuff&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this has a few drawbacks:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;When typing a partial version of the sequence, such as &lt;code&gt;ab&lt;/code&gt;, the characters aren't actually displayed for a short amount of time, since it's &quot;waiting&quot; to see whether you're going to type the full command. This is undesirable; I want to map a chain of letters without pausing if a partial substring of the chain is entered.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I type &lt;code&gt;ab&lt;/code&gt;, then pause (and wait until the characters actually appear as mentioned in the above point), then type the &lt;code&gt;c&lt;/code&gt;, the command is not executed. I want the command to be executed no matter how long I wait.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would use an &lt;code&gt;iab&lt;/code&gt;, but that doesn't work because:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It requires entering a space after the string&lt;/li&gt;&#xA;&lt;li&gt;I can't execute arbitrary commands with it, only insert a string of text.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is there any way to execute a command or keystrokes if a certain string is entered in insert mode, without using a map (which will annoyingly pause every time I type an &lt;code&gt;a&lt;/code&gt; and not work if I wait too long)?&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="1841" LastEditDate="2015-08-13T08:43:07.907" LastActivityDate="2019-05-15T19:23:05.767" Title="Map a sequence of letters in insert mode" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="564" PostTypeId="1" AcceptedAnswerId="649" CreationDate="2015-02-07T01:48:30.037" Score="18" ViewCount="477" Body="&lt;p&gt;Let's say I have this Markdown file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Lorem ipsum dolor sit ](http://vi.stackexchange.com/many-links-are-often-very)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Lookin' good. But the link isn't finished it, so I type &lt;code&gt;-long&lt;/code&gt;, and now Vim&#xA;breaks the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Lorem ipsum dolor sit&#xA;](http://vi.stackexchange.com/many-links-are-often-very-long)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because of my &lt;code&gt;textwidth=80&lt;/code&gt; setting... While breaking a link mid-tag is&#xA;technically valid markdown, it looks very unsightly IMHO; having nice looking&#xA;source files is sort of the point of markdown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; the problem is often even worse:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.&#xA;Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec&#xA;[Lorem ipsum dolor sit](http://vi.stackexchange.com/many-links-are-often-very-very-long)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Becomes this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.&#xA;Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec [Lorem&#xA;ipsum dolor&#xA;sit](http://vi.stackexchange.com/many-links-are-often-very-very-long)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can tell Vim or the markdown syntax to not break links in this way? &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Maybe by treating the entire link (from &lt;code&gt;[&lt;/code&gt; to &lt;code&gt;)&lt;/code&gt;) as a single word.     &lt;/li&gt;&#xA;&lt;li&gt;I have the same problem with &lt;code&gt;[this][type]&lt;/code&gt; of markdown link.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="6590" LastEditDate="2016-08-12T16:41:08.867" LastActivityDate="2016-08-12T16:41:08.867" Title="Prevent Vim from breaking up links mid-tag in markdown" Tags="|word-processing|wrapping|line-breaks|filetype-markdown|markup|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="565" PostTypeId="1" AcceptedAnswerId="566" CreationDate="2015-02-07T02:01:16.053" Score="22" ViewCount="900" Body="&lt;p&gt;What is the proper way to capitalize 'vim'? I have seen these variants being used:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vim&lt;/li&gt;&#xA;&lt;li&gt;Vim&lt;/li&gt;&#xA;&lt;li&gt;ViM&lt;/li&gt;&#xA;&lt;li&gt;VIM&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Which is the correct one? Or are they all considered correct? If I look at the &lt;code&gt;:help&lt;/code&gt; files, I see several styles being used.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="23502" LastEditDate="2022-10-30T17:53:13.860" LastActivityDate="2022-10-30T17:53:13.860" Title="What is the correct capitalization of 'Vim'?" Tags="|help-system|history-of|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="566" PostTypeId="2" ParentId="565" CreationDate="2015-02-07T02:06:18.400" Score="36" Body="&lt;p&gt;This actually took quite some searching, but the correct way is 'Vim'. From&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/intro.txt.html#pronounce&quot;&gt;&lt;code&gt;:help pronounce&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim is pronounced as one word, like Jim, not vi-ai-em.  It's written with a capital, since it's a name, again like Jim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Some parts of the Vim documentation does the all-caps 'VIM' though, this seems&#xA;to be older documentation.&lt;br&gt;&#xA;I could not find any references 'ViM' in the documentation, except for a single obvious typo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure about the spelling of Gvim; it's spelled as 'gvim', 'Gvim', 'GVim', and 'gVim' at various places in the documentation; but 'gvim '(no capitals) is the most common by far (560, 57, 5, and 8). I suspect because gvim is just a name of a commandline tool (as a convenient alias of &lt;code&gt;vim -g&lt;/code&gt;) rather than a proper name in it's own right. &lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-11T20:41:45.880" LastActivityDate="2015-02-11T20:41:45.880" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="567" PostTypeId="1" CreationDate="2015-02-07T03:54:42.947" Score="3" ViewCount="480" Body="&lt;p&gt;&lt;code&gt;gn&lt;/code&gt; is a very useful command that selects the next search result. For example, if I insert&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into a file, move to the beginning, type &lt;code&gt;/[aeiou].&lt;/code&gt;, and press &lt;code&gt;gn&lt;/code&gt;, it would select &lt;code&gt;oo&lt;/code&gt; in a visual selection. Pressing &lt;code&gt;dgn&lt;/code&gt; would delete that and then select &lt;code&gt;ar&lt;/code&gt; in a visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, let's say I have the following file (where &lt;strong&gt;&lt;code&gt;[x]&lt;/code&gt;&lt;/strong&gt; represents the cursor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;This is some text.&#xA;&#xA;Blah blah blah.&#xA;&#xA;Lorem ipsum.&#xA;&#xA;Foo bar b&lt;b&gt;[a]&lt;/b&gt;z quux.&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I've searched for &lt;code&gt;. .&lt;/code&gt; (any character, a space, then any character). Pressing &lt;code&gt;dgn&lt;/code&gt; would delete the &lt;code&gt;z q&lt;/code&gt;, since it's the first search result after my cursor. However, pressing &lt;code&gt;gn&lt;/code&gt; from here now has no effect, since this motion does not &quot;wrap around&quot; back to the beginning of the file like &lt;code&gt;n&lt;/code&gt; does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make &lt;code&gt;gn&lt;/code&gt; wrap to the first search result if there are no results after the cursor (but still have no effect (or give an error, without moving the cursor) if there are no more results in the entire file), just like the &lt;code&gt;n&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After discussion in the comments: This may be system-specific. I'm running Vim 7.4.52 on Ubuntu 14.04.&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="88" LastEditDate="2015-02-07T04:21:03.940" LastActivityDate="2015-02-07T04:40:22.110" Title="How can I make the &quot;gn&quot; motion wrap to the beginning of the file?" Tags="|search|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="568" PostTypeId="2" ParentId="567" CreationDate="2015-02-07T04:32:09.390" Score="3" Body="&lt;p&gt;Hopefully there would be a better solution, but one solution is to upgrade.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Ubuntu-based systems there's &lt;a href=&quot;https://launchpad.net/~pi-rho/+archive/ubuntu/dev?field.series_filter=trusty&quot; rel=&quot;nofollow noreferrer&quot;&gt;a PPA&lt;/a&gt; you can try (if you're unfamiliar with PPAs, see &lt;a href=&quot;https://askubuntu.com/questions/4983/what-are-ppas-and-how-do-i-use-them&quot;&gt;What are PPAs and how do I use them?&lt;/a&gt;). It currently has Vim 7.4.589, and &lt;code&gt;gn&lt;/code&gt; wraps at least as of 7.4.580.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-add-repository ppa:pi-rho/dev&#xA;sudo apt-get update&#xA;sudo apt-get install vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Looking at &lt;a href=&quot;http://ftp.vim.org/pub/vim/patches/7.4/README&quot; rel=&quot;nofollow noreferrer&quot;&gt;the README&lt;/a&gt;, I think the particular patch that introduced this was 76:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1894  7.4.076  &quot;cgn&quot; does not wrap around the end of the file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if you're comfortable with recompiling vim to add a patch, this should be it.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.647" LastActivityDate="2015-02-07T04:40:22.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="569" PostTypeId="2" ParentId="457" CreationDate="2015-02-07T04:48:12.527" Score="31" Body="&lt;p&gt;I rarely use ex-mode, but when I need it I'm grateful for its existance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I sometimes access systems via ssh over VPN, and these connections can sometimes get slow. Making the problem worse, I sometimes need to edit a file on the remote side which is, in addition to being behind ssh and VPN, is over a slow serial connection (so, 9600 baud plus a lot of network latency).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is times like this that having visual feedback and screen updates becomes more of a hindrance because what I see is delayed (the effect is kind of like talking into a mic but with speakers far away, like in a sports stadium. One's actions become choppy and sometimes confused due to the delayed feedback).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, having the changes not echoed back is a useful advantage, since I can get more done in less time when I'm not waiting for the screen to update.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I'm done making the edits, I go back to visual mode for a one-time screen update to review my work. Then I can go back to ex-mode or save because I'm done.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="24" LastEditDate="2015-02-07T08:26:07.970" LastActivityDate="2015-02-07T08:26:07.970" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="570" PostTypeId="1" CreationDate="2015-02-07T04:55:59.957" Score="41" ViewCount="4403" Body="&lt;p&gt;I know that Vim keeps history for ex commands, searches, jump locations, changes, and possibly others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;showcmd&lt;/code&gt; set, Vim also shows you what keys you have entered so far for a normal mode command, until that command is executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes, when in normal mode, I mistype and actions occur. I can undo these actions, but I sometimes want to know how the edits during my blunder occurred. Sometimes the edit looks cool and I want to know how to repeat it in the future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there any way of seeing the history of key presses in normal mode, preferably delimited when an actual edit or action (like movement or mode change) occurred?&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="24" LastEditDate="2015-02-09T01:48:40.480" LastActivityDate="2015-02-18T18:11:39.267" Title="Can I see the history of key presses in normal mode?" Tags="|command-history|normal-mode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="571" PostTypeId="2" ParentId="563" CreationDate="2015-02-07T05:44:16.140" Score="11" Body="&lt;p&gt;Here's one way to do that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:inputBuffer = ''&#xA;&#xA;augroup _silentInsertTrigger&#xA;    autocmd!&#xA;    autocmd InsertCharPre * call &amp;lt;sid&amp;gt;OnPreEnterChar()&#xA;    autocmd InsertLeave * call &amp;lt;sid&amp;gt;OnInsertLeave()&#xA;augroup END&#xA;&#xA;function! s:OnPreEnterChar()&#xA;    let s:inputBuffer .= v:char&#xA;&#xA;    if s:inputBuffer[-3:] ==# 'abc'&#xA;        echo '&amp;lt;do stuff&amp;gt;'&#xA;    endif&#xA;&#xA;    return v:char&#xA;endfunction&#xA;&#xA;function! s:OnInsertLeave()&#xA;    let s:inputBuffer = ''&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="132" LastActivityDate="2015-02-07T05:44:16.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="572" PostTypeId="1" CreationDate="2015-02-07T08:20:01.310" Score="61" ViewCount="7509" Body="&lt;p&gt;As it says under &lt;a href=&quot;https://vimhelp.appspot.com/uganda.txt.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help iccf&lt;/code&gt;&lt;/a&gt;…&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim is Charityware.  You can use and copy it as much as you like, but&#xA;  you are encouraged to make a donation for needy children in Uganda. &#xA;  Please see &lt;a href=&quot;https://vimhelp.appspot.com/uganda.txt.html#kcc&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;kcc&lt;/code&gt;&lt;/a&gt; below or visit the ICCF web site, available at these URLs:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;a href=&quot;http://iccf-holland.org/&quot; rel=&quot;noreferrer&quot;&gt;http://iccf-holland.org/&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&quot;http://www.vim.org/iccf/&quot; rel=&quot;noreferrer&quot;&gt;http://www.vim.org/iccf/&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&quot;http://www.iccf.nl/&quot; rel=&quot;noreferrer&quot;&gt;http://www.iccf.nl/&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;You can also sponsor the development of Vim.  Vim sponsors can vote&#xA;  for features.  See &lt;a href=&quot;https://vimhelp.appspot.com/sponsor.txt.html#sponsor&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;sponsor&lt;/code&gt;&lt;/a&gt;.  The money goes to Uganda anyway.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is there any estimate of how much money has been raised for Uganda thanks to Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that an exact number is unobtainable, since donations are not always annotated with the reason. An upper/lower bound or order-of-magnitude figure will do.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="1841" LastEditDate="2016-05-27T11:43:16.680" LastActivityDate="2022-09-21T12:43:49.810" Title="How much money has been raised for needy children in Uganda from Vim?" Tags="|history-of|" AnswerCount="1" CommentCount="2" ClosedDate="2018-09-13T19:22:34.873" ContentLicense="CC BY-SA 3.0" />
  <row Id="573" PostTypeId="1" CreationDate="2015-02-07T09:04:32.740" Score="19" ViewCount="1972" Body="&lt;p&gt;Can I use Vi or Vim with screen readers and/or Braille devices? If so, how would I go about it? Does it require any special setup?&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="51" LastEditDate="2015-02-07T19:33:43.843" LastActivityDate="2019-07-29T02:18:42.607" Title="Can I use Vi or Vim with screen readers and/or Braille devices?" Tags="|options|input-devices|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="574" PostTypeId="1" CreationDate="2015-02-07T11:34:48.443" Score="25" ViewCount="30625" Body="&lt;p&gt;The code standard that I use indicates that lines should have less than 80 chars. I want to indicate this automatically while I write to avoid raising the error later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is a good way of showing it?&lt;/p&gt;&#xA;" OwnerUserId="403" LastEditorUserId="24" LastEditDate="2015-02-09T15:39:30.617" LastActivityDate="2015-03-10T23:26:26.203" Title="Keeping lines to less than 80 characters" Tags="|line-breaks|" AnswerCount="3" CommentCount="1" ClosedDate="2015-02-11T11:41:43.600" ContentLicense="CC BY-SA 3.0" />
  <row Id="575" PostTypeId="1" AcceptedAnswerId="581" CreationDate="2015-02-07T11:37:14.530" Score="7" ViewCount="1216" Body="&lt;p&gt;Can I easily keep my vimrc files consistent across multiple computers? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have different  computers (laptop, desktop home and desktop work) and I want&#xA;to keep my Vim configuration consistent, including plugins.&lt;/p&gt;&#xA;" OwnerUserId="403" LastEditorUserId="51" LastEditDate="2015-02-07T14:10:30.480" LastActivityDate="2015-02-07T14:58:37.287" Title="Sharing vimrc options in different computers" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ClosedDate="2015-02-08T01:40:37.780" ContentLicense="CC BY-SA 3.0" />
  <row Id="576" PostTypeId="2" ParentId="574" CreationDate="2015-02-07T11:38:47.890" Score="35" Body="&lt;p&gt;If you have Vim 7.3 or later, you can set &lt;code&gt;colorcolumn&lt;/code&gt;, or &lt;code&gt;cc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set colorcolumn=80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;colorcolumn&amp;#39;&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help colorcolumn&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'colorcolumn' is a comma separated list of screen columns that are&#xA;  highlighted with ColorColumn hl-ColorColumn. Useful to align text.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can also set it relative to your &lt;code&gt;textwidth&lt;/code&gt; variable, which is maybe more&#xA;useful than setting it to an absolute value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set colorcolumn=+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or set multiple columns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set colorcolumn=-1,+30&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To change the color of the &lt;code&gt;colorcolumn&lt;/code&gt; use &lt;code&gt;:highlight ColorColumn&lt;/code&gt;, for&#xA;example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight ColorColumn ctermbg=lightgrey guibg=lightgrey&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="153" LastEditorUserId="205" LastEditDate="2015-03-10T23:26:26.203" LastActivityDate="2015-03-10T23:26:26.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="578" PostTypeId="2" ParentId="509" CreationDate="2015-02-07T11:54:49.157" Score="19" Body="&lt;p&gt;There is a great VimCast on this topic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimcasts.org/episodes/formatting-text-with-par/&quot;&gt;http://vimcasts.org/episodes/formatting-text-with-par/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, you need to install &lt;code&gt;par&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ brew install par&#xA;# or&#xA;$ sudo apt-get install par&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then, since you want columns to be wrapped in 80 columns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatprg=par\ -w80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use the &lt;code&gt;gq&lt;/code&gt; operator, like in other answers (e.g. &lt;code&gt;gqip&lt;/code&gt;), and it will use Par instead of Vim's built-in formatter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Par is quite advanced, and it will format comments like this nicely:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* This is a long */&#xA;/* multiline comment */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="401" LastActivityDate="2015-02-07T11:54:49.157" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="579" PostTypeId="1" AcceptedAnswerId="602" CreationDate="2015-02-07T12:12:03.597" Score="6" ViewCount="489" Body="&lt;p&gt;Python is whitespace dependent, and it can't be totally autoindented for that reason, but there are a lot of extra stuff that should be possible to do automatically to comply with PEP8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things like whitespaces around operators, two new lines before a class and one before a method, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any &lt;code&gt;equalprg&lt;/code&gt; compatible utility for that? If not, how to program one?&lt;/p&gt;&#xA;" OwnerUserId="403" LastEditorUserId="24" LastEditDate="2015-02-08T05:15:21.680" LastActivityDate="2015-02-09T01:14:21.723" Title="equalprg to use for Python" Tags="|ide|indentation|whitespace|filetype-python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="580" PostTypeId="1" AcceptedAnswerId="33015" CreationDate="2015-02-07T12:24:04.777" Score="21" ViewCount="4118" Body="&lt;p&gt;Assigning every useful function to a key works well for frequently used tools, but there are some operations I use so rarely, that I would prefer to assign them to some popup menu defined in my &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen plugins like CtrlP open a popup list so this should be possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to define a custom popup menu which can run various commands?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: this should run in a terminal too.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Something like CtrlP plugin or dmenu on X11 would be ideal, where you can refine the options as you type, but a different kind of menu would be useful too.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="23502" LastEditDate="2022-10-30T17:49:21.210" LastActivityDate="2022-10-30T17:49:21.210" Title="How to define a custom popup / menu in vimrc?" Tags="|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="581" PostTypeId="2" ParentId="575" CreationDate="2015-02-07T14:58:37.287" Score="5" Body="&lt;p&gt;A lot of tools provide solutions to keep your &lt;em&gt;dotfiles&lt;/em&gt; (that is what your .vimrc is, a dotfile) up to date. Personally I use &lt;a href=&quot;https://github.com/andsens/homeshick&quot; rel=&quot;nofollow noreferrer&quot;&gt;homeshick&lt;/a&gt; for this task. From its README.md:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;By the power of git, homeshick enables you to bring the symphony of settings you have poured your heart into with you to remote computers&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Homeshick uses Git, so your &lt;em&gt;dotfiles&lt;/em&gt; are also under version control. Below a comphrensive outline how to work with &lt;code&gt;homeshick&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Generate a `castle` named 'dotfiles'.&#xA;user@local $ homeshick generate dotfiles&#xA;user@local $ git remote add origin git@github.com:username/dotfiles.git&#xA;user@local $ git track dotfiles ~/.vimrc&#xA;user@local $ git commit -m &amp;quot;Initial commit.&amp;quot;&#xA;user@local $ git push origin master&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;On an other machine you can also install &lt;code&gt;homeshick&lt;/code&gt; and clone your dotfiles:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;user@remote $ homeshick clone username/dotfiles&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now you've &lt;code&gt;dotfiles&lt;/code&gt; on your remote machine.&lt;/p&gt;&#xA;&lt;p&gt;When you've edited a tracked &lt;code&gt;dotfile&lt;/code&gt; you can commit it.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;user@local $ homeshick cd dotfiles&#xA;user@local $ git add . &amp;amp;&amp;amp; git commit -m &amp;quot;Update something.&amp;quot;&#xA;user@local $ git push origin master&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Update your remote machines:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;user@remote $ homeshick refresh dotfiles&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here a link to &lt;a href=&quot;https://github.com/OrangeTux/dotfiles/&quot; rel=&quot;nofollow noreferrer&quot;&gt;my dotfiles&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Bonus&lt;/strong&gt; Add &lt;code&gt;homeshick refresh dotfiles&lt;/code&gt; to your &lt;code&gt;~/.profile&lt;/code&gt;, &lt;code&gt;~/.bashrc&lt;/code&gt; or &lt;code&gt;~/.zshrc&lt;/code&gt; and your dotfiles are always up to date.&lt;/p&gt;&#xA;" OwnerUserId="153" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-02-07T14:58:37.287" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="582" PostTypeId="1" CreationDate="2015-02-07T15:56:54.890" Score="2" ViewCount="176" Body="&lt;p&gt;I have been using vim for over 5 years and I only ever use basic cursor movements and character/line replacements.  I'm not using multiple windows or buffers or registers or splits. When I want to edit a different file I &lt;code&gt;:wq&lt;/code&gt;, navigate to the other file, and &lt;code&gt;vi file&lt;/code&gt;. I often find myself in &lt;code&gt;VISUAL&lt;/code&gt; mode, not knowing how I got there or what it's for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure there are many features that would improve my workflow that I don't even know to look for. Is there a utility or tutorial mode, either within &lt;code&gt;vim&lt;/code&gt; or without, that helps competent users become aware of the less-obvious features of &lt;code&gt;vim&lt;/code&gt; and when to use them?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="51" LastEditDate="2015-02-08T00:12:50.287" LastActivityDate="2015-02-08T00:12:50.287" Title="Does vim have a learning mode to help me get used to more advanced operations?" Tags="|help-system|" AnswerCount="1" CommentCount="2" ClosedDate="2015-02-07T18:46:23.753" ContentLicense="CC BY-SA 3.0" />
  <row Id="583" PostTypeId="2" ParentId="582" CreationDate="2015-02-07T16:09:11.997" Score="4" Body="&lt;p&gt;There is &lt;code&gt;:help tutor&lt;/code&gt; from within Vim. You can also start this from the commandline as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vimtutor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're using MS Windows, you can find it in the start menu under the 'Vim' group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is an &lt;em&gt;interactive&lt;/em&gt; tutorial, where you learn by &lt;em&gt;doing&lt;/em&gt;, rather than&#xA;reading &amp;amp; trying to memorize.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim also has some tutorials in the help files, you can view them with &lt;a href=&quot;http://vimhelp.appspot.com/howto.txt.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help howto&lt;/code&gt;&lt;/a&gt;. The &lt;a href=&quot;http://vim.wikia.com/wiki/Tutorial&quot; rel=&quot;nofollow&quot;&gt;Vim wiki also has a&#xA;tutorial&lt;/a&gt;, which may be useful as a&#xA;reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also check out &lt;a href=&quot;http://vim-adventures.com/&quot; rel=&quot;nofollow&quot;&gt;Vim Adventures&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19" LastEditorUserId="51" LastEditDate="2015-02-07T16:24:19.880" LastActivityDate="2015-02-07T16:24:19.880" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="584" PostTypeId="2" ParentId="570" CreationDate="2015-02-07T16:21:47.777" Score="-4" Body="&lt;p&gt;There is &lt;code&gt;q:&lt;/code&gt; which shows a command history. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also find it useful that you can press up  in a partially completed command to cycle through matches.  E.g. &#xA;&lt;code&gt;&#xA;/abc&#xA;&lt;/code&gt;&#xA;Then pressing up will cycle through your history of searches starting with 'abc' &lt;/p&gt;&#xA;" OwnerUserId="19" LastActivityDate="2015-02-07T16:21:47.777" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="585" PostTypeId="2" ParentId="474" CreationDate="2015-02-07T17:36:03.077" Score="7" Body="&lt;p&gt;To use Python in Vim, your Vim must be compiled with support for it. Most Linux distributions (Debian-based, CentOS, Arch, for example) have support for Python2, but not for Python3. To check for Python support you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;:echo has('python')&#xA;:echo has('python3')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it echoes &lt;code&gt;1&lt;/code&gt;, it means Vim has this feature (&lt;code&gt;python&lt;/code&gt; is Python 2). If it echoes &lt;code&gt;0&lt;/code&gt;, it means Vim &lt;em&gt;doesn't&lt;/em&gt; have this feature.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The simplest way to use Python is to do:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;:python some statement&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this will become unwieldy very quickly, so instead &lt;a href=&quot;http://vimhelp.appspot.com/if_pyth.txt.html#python-commands&quot; rel=&quot;nofollow&quot;&gt;we can do&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:python &amp;lt;&amp;lt;EOF&#xA;print('it is an')&#xA;print('ex-parrot')&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now, to get to the question. This can be accomplished using a fairly simple function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PythonBox()&#xA;    python &amp;lt;&amp;lt;EOF&#xA;import vim&#xA;this_buffer = vim.current.buffer&#xA;(row,col)   = vim.current.window.cursor&#xA;this_line   = vim.current.line&#xA;this_buffer.append ('#'*80, row - 1)&#xA;this_buffer[row] = '{:#^80}'.format(' ' + this_line + ' ')&#xA;this_buffer.append ('#'*80, row + 1)&#xA;EOF&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;import vim&lt;/code&gt; only works when loaded in &lt;code&gt;vim&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/if_pyth.txt.html#python-current&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;vim.current.buffer&lt;/code&gt;, &lt;code&gt;vim.current.window&lt;/code&gt; and &lt;code&gt;vim.current.line&lt;/code&gt;&lt;/a&gt; are exactly what they sound like.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/if_pyth.txt.html#python-buffer&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;vim.current.buffer&lt;/code&gt;&lt;/a&gt; is list-like and mutable, with each line a member. The list is indexed from &lt;code&gt;0&lt;/code&gt;, so line 1 is &lt;code&gt;vim.current.buffer[0]&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;We can add a line to a buffer using &lt;pre&gt;buffer.append(&lt;em&gt;str&lt;/em&gt; [, &lt;em&gt;linenum&lt;/em&gt;])&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;Aligning and padding the line is fairly simple with &lt;a href=&quot;https://docs.python.org/3/library/string.html#format-examples&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;str.format&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-04-27T07:37:38.797" LastActivityDate="2016-04-27T07:37:38.797" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="586" PostTypeId="1" AcceptedAnswerId="592" CreationDate="2015-02-07T18:12:04.403" Score="5" ViewCount="1247" Body="&lt;p&gt;I am using Vim in my windows PC . Currently I am working with a web project and I want to use Vim as code editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to download and add the &lt;a href=&quot;http://emmet.io/&quot; rel=&quot;nofollow&quot;&gt;http://emmet.io/&lt;/a&gt; plugin to Vim editor from &lt;a href=&quot;https://github.com/mattn/emmet-vim&quot; rel=&quot;nofollow&quot;&gt;this site&lt;/a&gt; but couldn't get how to do it. The documentation I found is only for Linux machine. Can any body help? &lt;/p&gt;&#xA;" OwnerUserId="408" LastEditorUserId="51" LastEditDate="2015-04-30T11:42:25.253" LastActivityDate="2015-04-30T11:42:25.253" Title="Adding emmet plugin to Vim in Windows" Tags="|microsoft-windows|plugin-emmet-vim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="587" PostTypeId="2" ParentId="570" CreationDate="2015-02-07T18:26:39.513" Score="23" Body="&lt;p&gt;Following the link from @WChargin a bit further, I found this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can start vim with the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/starting.html#-w&quot;&gt;&lt;code&gt;-w&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/starting.html#-W&quot;&gt;&lt;code&gt;-W&lt;/code&gt;&lt;/a&gt; option as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -w keys.txt my_file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;All the characters that you type are recorded in the file {scriptout}, until you exit Vim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;-w&lt;/code&gt; will append to the specified file if it exists; &lt;code&gt;-W&lt;/code&gt; will overwrite it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't quite get you what you want, but it's the right direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Update:&lt;/em&gt; It looks like vim actually buffers all the keystrokes until you quit vim, but there is a one-line patch &lt;a href=&quot;https://gist.github.com/kana/4202311&quot;&gt;here&lt;/a&gt; that will write the keystrokes immediately.&lt;/p&gt;&#xA;" OwnerUserId="126" LastEditorUserId="126" LastEditDate="2015-02-18T18:11:39.267" LastActivityDate="2015-02-18T18:11:39.267" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="588" PostTypeId="1" AcceptedAnswerId="707" CreationDate="2015-02-07T18:29:07.063" Score="44" ViewCount="14630" Body="&lt;p&gt;Is there any way to use a non-monospace font in either &lt;code&gt;vim&lt;/code&gt; or &lt;code&gt;gvim&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried changing the font for gVim with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set guifont=Dejavu\ Serif\ 12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this gives me some rather ugly results:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rS5am.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get the same results if I use the menu (Edit -&gt; Select font)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help guifont&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Note that the fonts must be mono-spaced (all characters have the same&#xA;width).  An exception is GTK 2: all fonts are accepted, but&#xA;mono-spaced fonts look best.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I think the above results count as &quot;not looking best&quot;? Can this be improved&#xA;upon, somehow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried setting a non-monospace font in my terminal (&lt;code&gt;xterm&lt;/code&gt;), but that&#xA;seems to have roughly the same effect: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Fy7V8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't mind using a different terminal emulator for this btw.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2023-10-09T08:52:44.037" Title="Can I use a non-monospaced font in either Vim or gVim?" Tags="|terminal|gvim|font|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="589" PostTypeId="5" CreationDate="2015-02-07T19:10:36.293" Score="0" Body="&lt;p&gt;&lt;strong&gt;Insert Mode&lt;/strong&gt; is the mode in Vi and Vim where you can insert text in the&#xA;document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can go from Normal mode to Insert mode in several different ways, the&#xA;difference is the placement of the cursor before starting Insert mode:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;a&lt;/kbd&gt;; append, move the cursor one character forward.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;A&lt;/kbd&gt;; append line, move the cursor to the end of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;i&lt;/kbd&gt;; insert, doesn't move the cursor.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;I&lt;/kbd&gt;; insert before, move the cursor to the first non-whitespace&#xA;character of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;o&lt;/kbd&gt;; open, begin a new line below the cursor.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;O&lt;/kbd&gt;; open, begine a new line above the cursor.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In addition to these commands, Vim has 2 additional commands to start Insert&#xA;mode:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;I&lt;/kbd&gt;; insert before, move the cursor to the first column.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;; insert previous, move the cursor to the position&#xA;Insert mode was stopped the last time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To get back to Normal mode press the &lt;kbd&gt;Esc&lt;/kbd&gt; key, which will set you back&#xA;into normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;/questions/tagged/normal-mode&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'normal-mode'&quot; rel=&quot;tag&quot;&gt;normal-mode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;/questions/tagged/visual-mode&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'visual-mode'&quot; rel=&quot;tag&quot;&gt;visual-mode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerDisplayName="user254" LastEditorUserId="51" LastEditDate="2015-02-08T04:47:25.390" LastActivityDate="2015-02-08T04:47:25.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="590" PostTypeId="4" CreationDate="2015-02-07T19:10:36.293" Score="0" Body="The mode in Vi and Vim in which you can insert text to the open document." OwnerDisplayName="user254" LastEditorDisplayName="user254" LastEditDate="2015-02-07T20:09:05.383" LastActivityDate="2015-02-07T20:09:05.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="591" PostTypeId="2" ParentId="580" CreationDate="2015-02-07T19:22:16.003" Score="11" Body="&lt;p&gt;Doing this out-of-the-box would require a fair amount of work, but I think you can do something fairly straight-forward using the &lt;a href=&quot;https://github.com/Shougo/unite.vim&quot; rel=&quot;nofollow&quot;&gt;Unite.vim plugin&lt;/a&gt;. It provides an integration interface for creating menus from various sources. (In fact, some have even &lt;a href=&quot;http://mouki.io/2013/08/15/Vim-CtrlP-behaviour-with-Unite.html&quot; rel=&quot;nofollow&quot;&gt;replaced CtrlP with Unite&lt;/a&gt;.) &lt;a href=&quot;https://github.com/Shougo/unite.vim/blob/9b20ab305/doc/unite.txt#L662-L674&quot; rel=&quot;nofollow&quot;&gt;This example in the Unite documentation&lt;/a&gt; (or take a look at &lt;code&gt;:help g:unite_source_menu_menus&lt;/code&gt;, once you've installed Unite)  details how to create a basic menu of commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following that documentation, I've come up with a simple example that offers a menu of commands. For demonstration purposes, I've set it up with commands for opening NERDTree (from the NERDTree plugin), showing a git blame (from the fugitive.vim plugin) and grepping for TODOs in a project (using the built-in &lt;code&gt;:grep&lt;/code&gt;). I've defined a mapping to open the menu with &lt;code&gt;&amp;lt;Leader&amp;gt;c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Initialize Unite's global list of menus&#xA;if !exists('g:unite_source_menu_menus')&#xA;    let g:unite_source_menu_menus = {}&#xA;endif&#xA;&#xA;# Create an entry for our new menu of commands&#xA;let g:unite_source_menu_menus.my_commands = {&#xA;\    'description': 'My Commands'&#xA;\ }&#xA;&#xA;# Define the function that maps our command labels to the commands they execute&#xA;function! g:unite_source_menu_menus.my_commands.map(key, value)&#xA;    return {&#xA;    \   'word': a:key,&#xA;    \   'kind': 'command',&#xA;    \   'action__command': a:value&#xA;    \ }&#xA;endfunction&#xA;&#xA;# Define our list of [Label, Command] pairs&#xA;let g:unite_source_menu_menus.my_commands.command_candidates = [&#xA;\   ['Open/Close NERDTree', 'NERDTreeToggle'],&#xA;\   ['Git Blame', 'Gblame'],&#xA;\   ['Grep for TODOs', 'grep TODO']&#xA;\ ]&#xA;&#xA;# Create a mapping to open our menu&#xA;nnoremap &amp;lt;Leader&amp;gt;c :&amp;lt;C-U&amp;gt;Unite menu:my_commands -start-insert -ignorecase&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can copy this into your &lt;code&gt;vimrc&lt;/code&gt;, and edit the list of commands defined by the array &lt;code&gt;g:unite_source_menu_menus.my_commands.command_candidates&lt;/code&gt;. Each item of the array is an array of the form &lt;code&gt;[Label, Command]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my example, &lt;code&gt;my_commands&lt;/code&gt; was a name I chose to identify my menu. You can use any name you'd like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT: Added &lt;code&gt;-start-insert&lt;/code&gt; and &lt;code&gt;-ignorecase&lt;/code&gt; options to the mapping to make the menu start in narrowing mode (like a fuzzy-search).&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="51" LastEditDate="2015-03-17T14:11:56.527" LastActivityDate="2015-03-17T14:11:56.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="592" PostTypeId="2" ParentId="586" CreationDate="2015-02-07T20:10:01.530" Score="6" Body="&lt;p&gt;First, lets view the steps listed in the &lt;code&gt;README&lt;/code&gt; for installing the plugin in Linux. the steps are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Download the zip.&lt;/li&gt;&#xA;&lt;li&gt;run &lt;code&gt;cd ~/.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;run &lt;code&gt;unzip emmet-vim.zip&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm assuming you know how to do the first step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second step requires you to &lt;strong&gt;c&lt;/strong&gt;hange &lt;strong&gt;d&lt;/strong&gt;irectory into the &lt;code&gt;~/.vim&lt;/code&gt; folder - the folder where (also) the plugins are saved on Linux systems. This folder on windows gVim is called &lt;code&gt;vimfiles&lt;/code&gt;, so just open the file explorer in the installation directory of gVim, and open the &lt;code&gt;vimfiles&lt;/code&gt; folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third step is extracting the contents of &lt;code&gt;emmet-vim.zip&lt;/code&gt; into the folder you navigated to in the previous step. You should be able to do that quite easily in windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer is based on the following doc: &lt;a href=&quot;http://www.vim.org/ugrankar.pdf&quot;&gt;Simple steps to help you install gVim on windows 7&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="342" LastActivityDate="2015-02-07T20:10:01.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="593" PostTypeId="2" ParentId="528" CreationDate="2015-02-07T20:20:14.970" Score="5" Body="&lt;p&gt;If you want &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt; to work beyond the line where the cursor is you could use the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3877&quot;&gt;ft_improved&lt;/a&gt; plugin. This allows you to use the &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt; for not only inside the current line, but move to whatever line, where the character is found. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But as others have written I think &lt;code&gt;/{char}&lt;/code&gt; works nicely for that. The only inconvenience would be if you have &lt;code&gt;hlsearch&lt;/code&gt; set. In that case all occurrences of &lt;code&gt;{char}&lt;/code&gt; would become highlighted as a side effect.&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="51" LastEditDate="2015-02-07T20:35:39.953" LastActivityDate="2015-02-07T20:35:39.953" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="594" PostTypeId="1" AcceptedAnswerId="20726" CreationDate="2015-02-07T20:53:05.023" Score="16" ViewCount="5953" Body="&lt;p&gt;If I have a text file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alpha: 1&#xA;beta: 2&#xA;gamma: 3&#xA;delta: 4&#xA;epsilon: 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to align the numbers like so?:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alpha:   1&#xA;beta:    2&#xA;gamma:   3&#xA;delta:   4&#xA;epsilon: 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="409" LastEditorUserId="24" LastEditDate="2015-02-08T05:07:43.720" LastActivityDate="2019-07-26T14:06:46.930" Title="How to left-align two columns of text?" Tags="|alignment|" AnswerCount="7" CommentCount="3" ClosedDate="2019-07-26T18:24:10.907" ContentLicense="CC BY-SA 3.0" />
  <row Id="595" PostTypeId="2" ParentId="594" CreationDate="2015-02-07T21:28:54.150" Score="8" Body="&lt;p&gt;You can do this with the &lt;a href=&quot;https://github.com/tommcdo/vim-lion&quot;&gt;vim-lion&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install it, then place your cursor on the first line. In normal mode, type &lt;code&gt;glip/&lt;/code&gt;. You'll be prompted to type in a pattern, so just type &lt;code&gt;\d&lt;/code&gt; to match any digit, and press Enter. It will line up the numbers for you.&lt;/p&gt;&#xA;" OwnerUserId="411" LastEditorUserId="51" LastEditDate="2015-02-07T21:33:18.013" LastActivityDate="2015-02-07T21:33:18.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="596" PostTypeId="5" CreationDate="2015-02-07T23:49:23.187" Score="0" Body="&lt;p&gt;&lt;strong&gt;Neovim&lt;/strong&gt; is a project that seeks to aggressively refactor Vim in order to:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Simplify maintenance and encourage contributions&lt;/li&gt;&#xA;&lt;li&gt;Split the work between multiple developers&lt;/li&gt;&#xA;&lt;li&gt;Enable advanced UIs without modifications to the core&lt;/li&gt;&#xA;&lt;li&gt;Maximize extensibility&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/neovim/neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub project&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Please note that the spelling is &amp;quot;Neovim&amp;quot; with lowercase &amp;quot;v&amp;quot;, in contrast to &amp;quot;Vim&amp;quot; with uppercase &amp;quot;V&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="307" LastEditorUserId="10604" LastEditDate="2023-10-30T14:30:10.813" LastActivityDate="2023-10-30T14:30:10.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="597" PostTypeId="4" CreationDate="2015-02-07T23:49:23.187" Score="0" Body="A project that seeks to refactor Vim. Use this tag for questions specifically regarding Neovim-only features (i.e. features not found in Vim and other Vi-like editors)." OwnerUserId="307" LastEditorUserId="578" LastEditDate="2019-01-28T20:56:02.390" LastActivityDate="2019-01-28T20:56:02.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="598" PostTypeId="1" AcceptedAnswerId="601" CreationDate="2015-02-08T00:07:19.100" Score="33" ViewCount="18760" Body="&lt;p&gt;Here's how I usually copy a block of text or code:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Select the block with Visual mode (&lt;kbd&gt;V&lt;/kbd&gt;) and delete it with&#xA;&lt;kbd&gt;d&lt;/kbd&gt;; or if it's just a single line, just use&#xA;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Go to where I want the text to be, I am too stupid to remember the difference&#xA;between &lt;kbd&gt;p&lt;/kbd&gt; and &lt;kbd&gt;P&lt;/kbd&gt;, so I get this right about 50% of time.&#xA;(if I get it wrong: undo a try again).&lt;/li&gt;&#xA;&lt;li&gt;Sometimes, the indentation needs adjusting, so I go to Visual mode with&#xA;&lt;kbd&gt;V&lt;/kbd&gt; again and reselect the same block, and use &lt;kbd&gt;&amp;gt;&lt;/kbd&gt; or&#xA;&lt;kbd&gt;&amp;lt;&lt;/kbd&gt; to fix that.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is there an easier way? In some editors I've seen that you can &quot;pick up&quot; a block&#xA;of text, as it were, and move it around; here's an example from Emacs (but I've&#xA;also seen this in other editors):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1wAve.gif&quot; alt=&quot;Emacs&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or perhaps there is another (even better) way?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="24" LastEditDate="2015-02-19T10:07:43.367" LastActivityDate="2022-09-22T17:26:52.347" Title="Faster way to move a block of text" Tags="|cut-copy-paste|visual-mode|" AnswerCount="8" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="599" PostTypeId="5" CreationDate="2015-02-08T00:20:15.737" Score="0" Body="&lt;p&gt;gVim supports several diffferent toolkits: Win32, GTK+ 2, GTK+ 1, Athena, Motif, and Photon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For MS Windows systems, the native Win32 toolkit is almost always used. For Linux and UNIX systems, GTK+ 2 is the most common.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see &lt;code&gt;:help gui&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;gVim also has GNOME session support. See &lt;code&gt;:help gnome&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-08T04:47:33.900" LastActivityDate="2015-02-08T04:47:33.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="600" PostTypeId="4" CreationDate="2015-02-08T00:20:15.737" Score="0" Body="gVim is the GUI version of Vim (opposed to Vim running in a terminal emulator). It behaves exactly the same, but has additional graphical features." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-08T04:47:06.617" LastActivityDate="2015-02-08T04:47:06.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="601" PostTypeId="2" ParentId="598" CreationDate="2015-02-08T00:27:20.967" Score="13" Body="&lt;p&gt;There's a plugin for that: &lt;a href=&quot;https://github.com/atweiden/vim-dragvisuals&quot; rel=&quot;nofollow noreferrer&quot;&gt;dragvisuals.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It doesn't bind any keys by default, so you'll have to do that yourself. I like to map them to &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;Arrow key&lt;/kbd&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xmap &amp;lt;expr&amp;gt; &amp;lt;C-Left&amp;gt; DVB_Drag('left')&#xA;xmap &amp;lt;expr&amp;gt; &amp;lt;C-Right&amp;gt; DVB_Drag('right')&#xA;xmap &amp;lt;expr&amp;gt; &amp;lt;C-Down&amp;gt; DVB_Drag('down')&#xA;xmap &amp;lt;expr&amp;gt; &amp;lt;C-Up&amp;gt; DVB_Drag('up')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It also comes with a bonus key to duplicate the current selection:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xmap &amp;lt;expr&amp;gt; D DVB_Duplicate()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Advantages of this plugin over the other answers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Doesn't make any text disappear if you try to move further up than the first line.&lt;/li&gt;&#xA;&lt;li&gt;It will expand the file if you move below the last line.&lt;/li&gt;&#xA;&lt;li&gt;Moving to the left/right works a bit better.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Another useful trick to complement this, are these keybinds:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;gt; &amp;gt;gv&#xA;xnoremap &amp;lt; &amp;lt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will re-select the last visual  selection after you use &lt;kbd&gt;&amp;gt;&lt;/kbd&gt; while in Visual mode, so you can adjust the alignment more easily (you can also use the arrow keys, but this will move it by one character, and not one &lt;code&gt;shiftwidth&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="411" LastEditorUserId="23502" LastEditDate="2022-06-20T01:50:48.773" LastActivityDate="2022-06-20T01:50:48.773" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="602" PostTypeId="2" ParentId="579" CreationDate="2015-02-08T00:30:05.857" Score="3" Body="&lt;p&gt;Yes, &lt;a href=&quot;https://github.com/tell-k/vim-autopep8&quot; rel=&quot;nofollow&quot;&gt;vim-autopep8&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need to &lt;code&gt;pip install autopep8&lt;/code&gt; as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then call &lt;code&gt;:Autopep8&lt;/code&gt; and it will fix most of the issues in your code. You can configure which issues to fix using either an inclusion list or an exclusion list, based on the errors in the &lt;a href=&quot;http://pep8.readthedocs.org/en/latest/intro.html#error-codes&quot; rel=&quot;nofollow&quot;&gt;Pep8 error codes&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will also spit out a nice diff showing exactly what changed when you run it.&lt;/p&gt;&#xA;" OwnerUserId="411" LastEditorUserId="411" LastEditDate="2015-02-09T01:14:21.723" LastActivityDate="2015-02-09T01:14:21.723" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="603" PostTypeId="2" ParentId="598" CreationDate="2015-02-08T00:30:56.260" Score="10" Body="&lt;p&gt;For step 3, you can use &lt;code&gt;gv=&lt;/code&gt; instead (&lt;code&gt;=&lt;/code&gt; means indent, and &lt;code&gt;gv&lt;/code&gt; means &quot;reselect last visual selection&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the Emacs behavior, it'd be pretty simple to add some mappings in your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;down&amp;gt; dpV`]&#xA;vnoremap &amp;lt;up&amp;gt; dkPV`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use the up and down arrow keys to move around a visual line selection. (Of course, you could map to different keys as well if you hate arrows.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(You could do this with normal visual selections and moving them left and right too: &lt;code&gt;vnoremap &amp;lt;left&amp;gt; dhPgvhoho&lt;/code&gt; and &lt;code&gt;vnoremap &amp;lt;right&amp;gt; dpgvlolo&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="51" LastEditDate="2015-02-08T01:06:13.970" LastActivityDate="2015-02-08T01:06:13.970" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="604" PostTypeId="2" ParentId="183" CreationDate="2015-02-08T02:36:22.783" Score="2" Body="&lt;p&gt;This should work, note that &lt;code&gt;&amp;lt;01&amp;gt;&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; literal text, it is the 0x01 character. You can enter it with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; followed by &lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;1&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;b:current_syntax&quot;)&#xA;        finish&#xA;endif&#xA;&#xA;syn case ignore&#xA;&#xA;syn match fixPrice         &quot;&amp;lt;01&amp;gt;44=[^&amp;lt;01&amp;gt;]*&quot;&#xA;syn match fixSendingTime   &quot;&amp;lt;01&amp;gt;52=[^&amp;lt;01&amp;gt;]*&quot;&#xA;syn match fixSide          &quot;&amp;lt;01&amp;gt;54=[^&amp;lt;01&amp;gt;]*&quot;&#xA;syn match fixTransactTime  &quot;&amp;lt;01&amp;gt;60=[^&amp;lt;01&amp;gt;]*&quot;&#xA;syn match fixCorrelation   &quot;&amp;lt;01&amp;gt;9717=[^&amp;lt;01&amp;gt;]*&quot;&#xA;&#xA;hi def link fixPrice         Label&#xA;hi def link fixSendingTime   Number&#xA;hi def link fixSide          Identifier&#xA;hi def link fixTransactTime  Include&#xA;hi def link fixCorrelation   String&#xA;&#xA;let b:current_syntax = &quot;fix&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you copy/pasted it, you can fix it up with: &lt;code&gt;:%s/&amp;lt;01&amp;gt;/&amp;lt;01&amp;gt;/g&lt;/code&gt;, where the first &lt;code&gt;&amp;lt;01&amp;gt;&lt;/code&gt; is literal text, and the &lt;em&gt;second&lt;/em&gt; is the 0x01 character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regexp explained:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;01&amp;gt;&lt;/code&gt; - match 0x01 character&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;44=&lt;/code&gt; - followed by your 'magic' number and a &lt;code&gt;=&lt;/code&gt; sign&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^&amp;lt;01&amp;gt;]*&lt;/code&gt; - followed by 0 or more of any character &lt;em&gt;except&lt;/em&gt; the 0x01 character.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could maybe make the text stand out more by using bold text, or different background colours. But I'll leave that up to you ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I removed all of the legacy cruft for &lt;em&gt;very&lt;/em&gt;, &lt;em&gt;very&lt;/em&gt; old Vim versions. You don't need it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screenshot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rtooK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-08T20:51:31.867" LastActivityDate="2015-02-08T20:51:31.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="605" PostTypeId="1" CreationDate="2015-02-08T03:11:48.723" Score="6" ViewCount="2648" Body="&lt;p&gt;When using ctags, one can move back through the tag stack by using [count]&lt;kbd&gt;CTRL-T&lt;/kbd&gt; or &lt;code&gt;:[count]pop&lt;/code&gt;, and forward using &lt;code&gt;:[count]tag&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when using cscope instead of ctags and setting &lt;code&gt;'cscopetag'&lt;/code&gt;, only the backwards direction works (that is, &lt;code&gt;:[count]pop&lt;/code&gt; works, but &lt;code&gt;:[count]tag&lt;/code&gt; gives &lt;code&gt;E433: No tags file&lt;/code&gt; and &lt;code&gt;E426: tag not found&lt;/code&gt; with the name of the tag at that point in the tagstack).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to enable the forward direction when using cscope?&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="343" LastEditDate="2017-12-06T11:28:55.313" LastActivityDate="2018-11-08T07:36:36.367" Title="Bidirectional tag stack movement with cscope in vim" Tags="|tags|count|cscope|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="606" PostTypeId="2" ParentId="594" CreationDate="2015-02-08T04:58:26.033" Score="7" Body="&lt;p&gt;Here's a method not using any plugin.  The strategy is to use tabs as a temporary column delimiter, then reformat the tabs as spaces.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start by setting &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27noexpandtab%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:set noexpandtab&lt;/code&gt;&lt;/a&gt; (&lt;code&gt;noet&lt;/code&gt; for short)&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Type the text, using the &lt;kbd&gt;Tab&lt;/kbd&gt; key to insert a horizontal tab character after each colon.  It will probably look slightly wrong, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alpha:  1&#xA;beta:   2&#xA;gamma:  3&#xA;delta:  4&#xA;epsilon:        5&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27tabstop%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:set tabstop=9&lt;/code&gt;&lt;/a&gt;  (&lt;code&gt;:set ts=9&lt;/code&gt; for short) makes it look as desired:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alpha:   1&#xA;beta:    2&#xA;gamma:   3&#xA;delta:   4&#xA;epsilon: 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the whitespace is actually a horizontal tab character, not spaces.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;To indicate that you want spaces instead of tabs, &lt;code&gt;:set et&lt;/code&gt;.  Then, &lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#%3Aretab&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:%retab&lt;/code&gt;&lt;/a&gt; to perform the tabs-to-spaces conversion.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-08T15:09:19.593" LastActivityDate="2015-02-08T15:09:19.593" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="607" PostTypeId="5" CreationDate="2015-02-08T05:07:29.007" Score="0" Body="&lt;p&gt;This tag is for questions about Vim's cscope integration features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cscope itself allows a user to query information such as a list of callers to a function or list of files that include another file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Vim integration allows these queries to be added to the tag stack or quickfix list for enhanced browsing of source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information about cscope in vim can be found via &lt;a href=&quot;http://vimhelp.appspot.com/if_cscop.txt.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help cscope&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-02-08T05:28:36.160" LastActivityDate="2015-02-08T05:28:36.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="608" PostTypeId="4" CreationDate="2015-02-08T05:07:29.007" Score="0" Body="Cscope allows more powerful examination of C code than c-tags. Vim has builtin support for using the cscope utility as a tags source." OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-02-08T05:12:48.210" LastActivityDate="2015-02-08T05:12:48.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="609" PostTypeId="1" CreationDate="2015-02-08T06:37:20.847" Score="31" ViewCount="6340" Body="&lt;p&gt;When refactoring code it would be useful to be able to swap function arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changing for eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo[0], bar(), baz.spam)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(baz.spam, foo[0], bar())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there some way to swap arguments to the left/right, keeping function parentheses and commas in place?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note, this &lt;em&gt;could&lt;/em&gt; become quite involved if you want to account for arguments which themselves are function calls with their own arguments - eg: &lt;code&gt;func(baz-&amp;gt;spam, foo[0], bar(a, b, c))&lt;/code&gt; - supporting these cases would likely involve some more comprehensive parsing.&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="246" LastEditDate="2015-02-09T03:14:27.537" LastActivityDate="2016-06-27T09:41:11.967" Title="Swap function arguments" Tags="|macro|refactor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="610" PostTypeId="2" ParentId="609" CreationDate="2015-02-08T07:31:29.407" Score="32" Body="&lt;h3&gt;Without plugins&lt;/h3&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;| indicates cursor position&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo[0], bar(), |baz.spam)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;dt)&lt;/code&gt; will delete &lt;code&gt;baz.spam&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Ff&lt;/code&gt; will move the cursor to the character f in &lt;code&gt;foo[0]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vt,p&lt;/code&gt; will delete foo[0] and replace it with &lt;code&gt;baz.spam&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$P&lt;/code&gt; will paste the foo[0] before the parens&lt;/li&gt;&#xA;&lt;li&gt;Repeat steps 1-4 for any others.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;With plugins&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/PeterRincker/vim-argumentative&quot; rel=&quot;noreferrer&quot;&gt;vim-argumentative&lt;/a&gt; by &lt;em&gt;Peter Rincker&lt;/em&gt; : Provides text objects for moving around function arguments (Default mappings: &lt;code&gt;&amp;lt;,&lt;/code&gt; and &lt;code&gt;&amp;gt;,&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tommcdo/vim-exchange.git&quot; rel=&quot;noreferrer&quot;&gt;vim-exchange&lt;/a&gt; by &lt;em&gt;Tom McDonald&lt;/em&gt; : Provides handy mappings to exchange two selections (Default mappings: &lt;code&gt;cx&lt;/code&gt; in normal mode and &lt;code&gt;X&lt;/code&gt; in visual mode).&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/AndrewRadev/sideways.vim&quot; rel=&quot;noreferrer&quot;&gt;vim-sideways&lt;/a&gt; by &lt;em&gt;Andrew Radev&lt;/em&gt; : Move function arguments (and other delimited-by-something items) left and right (Default mappings: &lt;code&gt;NA&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/machakann/vim-swap&quot; rel=&quot;noreferrer&quot;&gt;vim-swap&lt;/a&gt; by &lt;em&gt;machakann&lt;/em&gt; : Reorder delimited items (Default mappings: &lt;code&gt;g&amp;lt;&lt;/code&gt; and &lt;code&gt;g&amp;gt;&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="246" LastEditorUserId="1292" LastEditDate="2016-06-27T09:41:11.967" LastActivityDate="2016-06-27T09:41:11.967" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="612" PostTypeId="2" ParentId="598" CreationDate="2015-02-08T11:44:14.487" Score="8" Body="&lt;p&gt;You can remap some keys to move lines around. For example, arrows up and down if you are used to move around through &lt;code&gt;hjkl&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g on .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;down&amp;gt; :m .+1&amp;lt;CR&amp;gt;==&#xA;nnoremap &amp;lt;up&amp;gt; :m .-2&amp;lt;CR&amp;gt;==&#xA;vnoremap &amp;lt;down&amp;gt; :m '&amp;gt;+1&amp;lt;CR&amp;gt;gv=gv&#xA;vnoremap &amp;lt;up&amp;gt; :m '&amp;lt;-2&amp;lt;CR&amp;gt;gv=gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:m&lt;/code&gt;, normal command to move a line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;+1&lt;/code&gt; or &lt;code&gt;-2&lt;/code&gt; to  indicate a line up or down (-1 keeps the line on the same place)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gv&lt;/code&gt; to select again the same text in &lt;code&gt;VISUAL&lt;/code&gt; mode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution does not interfere with the registers, so any copied text will still be available, as well as reformat the code to set proper indentation, etc.&lt;/p&gt;&#xA;" OwnerUserId="403" LastActivityDate="2015-02-08T11:44:14.487" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="613" PostTypeId="1" AcceptedAnswerId="614" CreationDate="2015-02-08T12:32:58.450" Score="143" ViewCount="196389" Body="&lt;p&gt;How do I install a plugin in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it matter:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Whether I use vi or Vim?&lt;/li&gt;&#xA;&lt;li&gt;Whether I use gVim?&lt;/li&gt;&#xA;&lt;li&gt;Which version of Vim I'm using?&lt;/li&gt;&#xA;&lt;li&gt;What my OS is?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="342" LastEditorUserId="927" LastEditDate="2017-06-29T21:44:00.723" LastActivityDate="2020-01-24T17:13:44.243" Title="How do I install a plugin in Vim/vi?" Tags="|plugin-system|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="614" PostTypeId="2" ParentId="613" CreationDate="2015-02-08T13:20:00.247" Score="86" Body="&lt;p&gt;To install a plugin, we need to know what form it comes in. It can be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a single &lt;code&gt;.vim&lt;/code&gt; file&lt;/li&gt;&#xA;&lt;li&gt;a Vimball file&lt;/li&gt;&#xA;&lt;li&gt;a set of files in directories that follow an expected structure (&lt;code&gt;plugin/*&lt;/code&gt;, &lt;code&gt;syntax/*&lt;/code&gt;, etc.) (&lt;a href=&quot;https://vi.stackexchange.com/questions/285/what-makes-a-plugin-vundle-compatible-and-are-other-plugin-managers-interchangea&quot;&gt;What makes a plugin Vundle compatible and are other plugin managers interchangeable?&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A single &lt;code&gt;.vim&lt;/code&gt; file is supposed to be placed in the &lt;code&gt;.vim/plugin&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Vimball file &lt;a href=&quot;https://vi.stackexchange.com/questions/491/how-do-i-install-a-vimball-plugin&quot;&gt;can be installed&lt;/a&gt; by opening it in Vim and running &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%3Asource&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:source %&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A set of files in the standard directory layout can be installed either by copying them to &lt;code&gt;.vim&lt;/code&gt;, or using a &lt;a href=&quot;https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-package-managers&quot;&gt;plugin package manager&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plugins may depend on certain features. Therefore:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It may matter if you're using Vi or Vim,&lt;/li&gt;&#xA;&lt;li&gt;It may matter if you're using gVim or not (gVim typically has more features enabled at compile time than Vim on the same distribution).&lt;/li&gt;&#xA;&lt;li&gt;It may matter which version of Vim you're on, since a feature may have been added after your version of Vim.&lt;/li&gt;&#xA;&lt;li&gt;It may matter which OS you're on, especially if the plugin calls in external commands.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For most plugins, though, it may not matter.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="4735" LastEditDate="2018-06-26T21:15:05.897" LastActivityDate="2018-06-26T21:15:05.897" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="615" PostTypeId="2" ParentId="613" CreationDate="2015-02-08T13:25:18.500" Score="26" Body="&lt;h1&gt;Pathogen&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Pathogen is a runtime path manager, which loads plugins within Vim. It makes plugin installation simple; here's how it works:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;note: If you're using Windows, replace &lt;code&gt;~/.vim&lt;/code&gt; with &lt;code&gt;$HOME\vimfiles&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Copy &lt;a href=&quot;https://github.com/tpope/vim-pathogen/blob/master/autoload/pathogen.vim&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;pathogen.vim&lt;/code&gt;&lt;/a&gt; to &lt;code&gt;~/.vim/autoload/pathogen.vim&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create the &lt;code&gt;~/.vim/bundle&lt;/code&gt; directory, if it does not exist already.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add the following line to the very beginning of your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You're done! When you want to add a plugin, simply copy the entire plugin's directory to &lt;code&gt;~/.vim/bundle&lt;/code&gt;, or &lt;code&gt;git clone&lt;/code&gt; it there. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim/bundle&#xA;git clone https://github.com/tpope/vim-surround&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;* Caveat: If your plugin comes in the form of a &lt;code&gt;.vim&lt;/code&gt; file, it won't work with Pathogen. Copy it to &lt;code&gt;~/.vim/plugin&lt;/code&gt; instead (you may have to create this directory if it doesn't exist).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="88" LastEditorUserId="88" LastEditDate="2017-12-07T05:22:44.977" LastActivityDate="2017-12-07T05:22:44.977" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="616" PostTypeId="1" AcceptedAnswerId="617" CreationDate="2015-02-08T14:33:36.327" Score="4" ViewCount="777" Body="&lt;p&gt;I am trying to set up the Node.js version of &lt;a href=&quot;https://github.com/beautify-web/js-beautify&quot; rel=&quot;nofollow&quot;&gt;js-beautify&lt;/a&gt; as an &lt;code&gt;equalprg&lt;/code&gt; command when I am editing a JavaScript file, so that the Vim &lt;code&gt;=&lt;/code&gt; indent commands reflow my JavaScript at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially, I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType javascript setlocal equalprg=js-beautify -f -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(the &lt;code&gt;-f -&lt;/code&gt; is necessary because js-beautify otherwise doesn't read from stdin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, that fails with an error like this when I open a JavaScript file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing FileType Auto commands for &quot;javascript&quot;:&#xA;E518: Unknown option: -f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So then I tried adding surrounding quotes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType javascript setlocal equalprg=&quot;js-beautify -f -&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That seems to work (JavaScript files open without error), but then &lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;G&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;G&lt;/kbd&gt; (or any other &lt;kbd&gt;=&lt;/kbd&gt; command) seems to work in exactly the same way as the standard vim behaviour, and it appears it's not set up correctly - if I type &lt;code&gt;:set equalprg&lt;/code&gt;, I see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;equalprg=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I remove the &lt;code&gt;-f -&lt;/code&gt;, the &lt;code&gt;equalprg&lt;/code&gt; is set, but it doesn't work, because js-beautify tries to read from a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Must define at least one file.&#xA;Run `js-beautify -h` for help.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can pass these command-line options into js-beautify as part of setting equalprg?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note I am aware that I could use the js-beautify vim plugin, but I'm trying not to overwhelm my vim setup with plugins, and instead setup the standard vim &lt;code&gt;=&lt;/code&gt; keymapping.&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="51" LastEditDate="2015-02-08T18:10:20.400" LastActivityDate="2015-02-08T18:10:20.400" Title="How can I specify a command-line command with options as an equalprg?" Tags="|indentation|filetype-javascript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="617" PostTypeId="2" ParentId="616" CreationDate="2015-02-08T14:39:38.660" Score="6" Body="&lt;p&gt;Close, but you have to use single quotes instead of double quotes, because Vim interprets &lt;code&gt;&quot;&lt;/code&gt; as a comment in this context:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType javascript setlocal equalprg='js-beautify -f -'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or just escape the spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType javascript setlocal equalprg=js-beautify\ -f\ -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastEditorUserId="88" LastEditDate="2015-02-08T14:47:03.820" LastActivityDate="2015-02-08T14:47:03.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="618" PostTypeId="2" ParentId="609" CreationDate="2015-02-08T15:38:18.130" Score="6" Body="&lt;p&gt;I present 3 methods. The first two are particular cases, which require less keystrokes. The last one is generic.&#xA;&lt;code&gt;|&lt;/code&gt; represents the cursor position.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Swap adjacent arguments (doesn't work for last two)&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;function func(foo[0], |bar(), baz.spam, qux-&amp;gt;norf)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Steps:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;dW&lt;/code&gt; delete the current Word (argument)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;W&lt;/code&gt; go to the first char of the next argument&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt; paste before the cursor&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2&gt;Swap last two arguments&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;function func(foo[0], bar()|, baz.spam, qux-&amp;gt;norf)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Steps:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;dt,&lt;/code&gt; delete until next comma&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;E&lt;/code&gt; go to last character of the next argument&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt; paste before the cursor&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2&gt;Swap any two arguments&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;function func(|foo[0], bar(), baz.spam, qux-&amp;gt;norf)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Steps:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;vt,d&lt;/code&gt; visually delete until comma&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;W&lt;/code&gt; several times until you reach the argument you want to swap with&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gP&lt;/code&gt; paste before cursor and place cursor on the char after pasted content&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dt,&lt;/code&gt; delete until next comma. replace &lt;code&gt;,&lt;/code&gt; by &lt;code&gt;)&lt;/code&gt; if this is the last argument&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt; `&amp;lt;&lt;/code&gt; go back to the beggining of the last visual area (cursor will be placed at the comma)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt; paste before the cursor&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Edit: as pointed by @aharris88 the OP wants the last argument to be the first and move all the others right.&lt;/p&gt;&#xA;&lt;h2&gt;Rotate arguments to the right&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;function func(foo[0], bar(), baz.spam|, qux-&amp;gt;norf)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Steps:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;dw&lt;/code&gt; delete &lt;code&gt;,␣&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dt)&lt;/code&gt; delete last argument&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%p&lt;/code&gt; jump to opening parentheses and paste last argument&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a,␣&lt;/code&gt; insert a comma and space&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; return to normal mode&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Or, if you don't want to ever leave normal mode:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;quot;rdw&lt;/code&gt; delete &lt;code&gt;,␣&lt;/code&gt; into a register &lt;code&gt;r&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dt)&lt;/code&gt; delete last argument&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%p&lt;/code&gt; jump to opening parentheses and paste last argument&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;quot;rp&lt;/code&gt; paste content of register &lt;code&gt;r&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Bonus: a GIF for each case:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/s7Y0e.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;swap1&lt;/a&gt;, &lt;a href=&quot;https://i.stack.imgur.com/y34mT.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;swap2&lt;/a&gt;, &lt;a href=&quot;https://i.stack.imgur.com/aHPzV.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;swap3&lt;/a&gt; and &lt;a href=&quot;https://i.stack.imgur.com/qJSKt.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;rotate&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-02-09T19:57:12.003" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="619" PostTypeId="1" AcceptedAnswerId="620" CreationDate="2015-02-08T19:00:36.673" Score="17" ViewCount="2395" Body="&lt;p&gt;I understand that we can extend the power of Vim in order to add new features or modify existing ones and enhance our editing experience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although being myself a Vim user for quite a long time, I am now in an uncharted territory: what is exactly a Vim plugin? What are the prerequisites for writing a plugin, so I can write my own plugins in the near future?&lt;/p&gt;&#xA;" OwnerUserId="106" LastActivityDate="2015-02-08T19:32:09.680" Title="What is a Vim plugin?" Tags="|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="620" PostTypeId="2" ParentId="619" CreationDate="2015-02-08T19:32:09.680" Score="19" Body="&lt;p&gt;A plugin is a way to extend vim's functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim categorizes plugins into &quot;global&quot; plugins (which load and operate unconditionally) and &quot;filetype&quot; plugins (which only load and operate for specific file types, see &lt;code&gt;:help filetype&lt;/code&gt;). Vim looks for plugins in specific locations, assuming you have not altered the runtime path (manually or with plugins like Pathogen or Vundle):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;On *nix and OS X, the default is &lt;code&gt;~/.vim/plugin&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;On Windows, the default is &lt;code&gt;$HOME/vimfiles/plugin&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Filetype plugins use &lt;code&gt;ftplugin&lt;/code&gt; instead, and must be named (or in a subdirectory named) for the filetype they correspond to (such as &lt;code&gt;foo.vim&lt;/code&gt; for the &lt;code&gt;foo&lt;/code&gt; filetype).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plugins are just vim script, so you can use them to define functions, mappings and commands just like you might in your &lt;code&gt;.vimrc&lt;/code&gt;, although when writing a plugin you generally want to write your vim script with a little more generality than you might if you were just hacking on your own &lt;code&gt;.vimrc&lt;/code&gt;. If your vim is compiled with the appropriate option, you can also write plugins in other languages such as Python, Ruby or Lua.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plugins are usually more than just a single &lt;code&gt;.vim&lt;/code&gt; file that sits in the appropriate directory, however. They frequently also include autoload scripts (&lt;code&gt;:help autoload&lt;/code&gt;), syntax scripts (&lt;code&gt;:help syntax&lt;/code&gt;) and indent handling scripts. Packaged together all of the code in these scripts provide for powerful hooks to augment vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's built-in help (&lt;code&gt;:help plugin&lt;/code&gt;) contains all sorts of additional specifics. Writing plugins is a pretty broad topic, but vim's built-in help can be extremely useful. Additionally, there are some excellent resources on the internet such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com&quot; rel=&quot;noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; for general vim script needs and&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://stevelosh.com/blog/2011/09/writing-vim-plugins/&quot; rel=&quot;noreferrer&quot;&gt;Writing Vim Plugins&lt;/a&gt; for plugins, specifically&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Using a plugin (whether one you've written or one you've download from the internet) is a simple matter of placing it in the appropriate directory (or directories, if applicable) and launching vim. Some plugins may have more complex installation procedures (such as the popular &lt;a href=&quot;https://valloric.github.io/YouCompleteMe/&quot; rel=&quot;noreferrer&quot;&gt;YouCompleteMe&lt;/a&gt; completion plugin, which has a compiled component), of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These days, plugin-management plugins such as &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;noreferrer&quot;&gt;Pathogen&lt;/a&gt; and &lt;a href=&quot;https://github.com/gmarik/Vundle.vim&quot; rel=&quot;noreferrer&quot;&gt;Vundle&lt;/a&gt; are a popular alternative to manually installing plugin files, especially since plugins &lt;em&gt;usually&lt;/em&gt; come with more than one file (as noted above). &lt;a href=&quot;https://vi.stackexchange.com/questions/613/how-to-install-a-plugin-in-vim-vi&quot;&gt;See this question&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-08T19:32:09.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="621" PostTypeId="1" AcceptedAnswerId="622" CreationDate="2015-02-08T20:09:03.360" Score="4" ViewCount="6241" Body="&lt;p&gt;I am familiar with the &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;p&lt;/code&gt; method of copying and pasting a line within Vim; however, I have been unsuccessful in finding a straight forward method for copying multiple lines which have been yanked in visual mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;the idea would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Shift + v&#xA;down arrow n times&#xA;y&#xA;:q!&#xA;open new file, or switch buffer&#xA;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When yanking with visual mode, it will copy the first line of the yanked block to your Registers in &lt;code&gt;.viminfo&lt;/code&gt;, but nothing else&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would assume you need to create an instance of a clipboard which is global to all sessions of vim attached to a specific user, but I am not well versed enough in Vim to code this up myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit:&#xA;As it would appear, I made a mistake in my approach. Using &lt;code&gt;Shift&lt;/code&gt;+&lt;code&gt;v&lt;/code&gt; is the prescribed method to use when copying and pasting between sessions. Thanks for the help @Doorknob&lt;/p&gt;&#xA;" OwnerUserId="416" LastEditorUserId="416" LastEditDate="2015-02-09T13:30:07.140" LastActivityDate="2018-07-28T17:04:54.170" Title="How does one perform a multi-line copy and paste between two sessions in Vim?" Tags="|cut-copy-paste|sessions|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="622" PostTypeId="2" ParentId="621" CreationDate="2015-02-08T20:18:18.810" Score="4" Body="&lt;p&gt;Assuming you have a viminfo file (located at &lt;code&gt;~/.viminfo&lt;/code&gt; on Linux/Unix systems and &lt;code&gt;$HOME\_viminfo&lt;/code&gt; on Windows), all of your buffers should be persistent across Vim sessions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if you're on a Linux/Unix system, this file must be owned by you (&lt;code&gt;ls -l ~/.viminfo&lt;/code&gt; to verify that it is and &lt;code&gt;chown $USER ~/.viminfo&lt;/code&gt; if it's not). Otherwise, it will have no effect.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-08T20:18:18.810" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="623" PostTypeId="2" ParentId="572" CreationDate="2015-02-08T20:38:42.683" Score="52" Body="&lt;p&gt;tl;dr: as of 2022, it would seem that about €1.6 million has been raised.&lt;/p&gt;&#xA;&lt;p&gt;ICCF &amp;amp; Vim seem very intertwined, and &lt;em&gt;probably&lt;/em&gt; a majority of the donations&#xA;came from Vim users, but there is no way &lt;em&gt;anyone&lt;/em&gt; can be certain about this.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The ICCF has published &lt;a href=&quot;http://www.iccf.nl/iccf.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;financial reports&lt;/a&gt;, summing up the numbers:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;'94-'96   €     5 000 (estimate)&#xA;&#xA;1997      €     7 241 (ƒ15 958)&#xA;1998      €    10 010 (ƒ22 060)&#xA;1999      €    15 122 (ƒ33 326)&#xA;2000      €    17 333 (ƒ38 198)&#xA;2001      €    26 441&#xA;2002      €    29 258&#xA;2003      €    28 625&#xA;2004      €    29 262&#xA;2005      €    36 937&#xA;2006      €    46 163&#xA;2007      €    47 688&#xA;2008      €    46 050&#xA;2009      €    50 309&#xA;2010      €    47 297&#xA;2011      €    54 790&#xA;2012      €    50 150&#xA;2013      €    55 595&#xA;2014      €    73 350&#xA;2015      €    68 872&#xA;2016      €    62 558&#xA;2017      €    65 562&#xA;2018      €    69 790&#xA;2019      €    78 147&#xA;2020      €    84 892&#xA;2021      €   119 078 &#xA;&#xA;2002 .de  €    10 140 (estimate)&#xA;2003 .de  €     9 920 (estimate)&#xA;2004 .de  €    10 140 (estimate)&#xA;2005 .de  €    12 799 (estimate)&#xA;2006 .de  €    15 995 (estimate)&#xA;2007 .de  €    16 523 (estimate)&#xA;2008 .de  €    15 955 (estimate)&#xA;2009 .de  €    17 430 (estimate)&#xA;2010 .de  €    16 386 (estimate)&#xA;2011 .de  €    18 981 (estimate)&#xA;2012 .de  €    17 373 (estimate)&#xA;2013 .de  €    19 259 (estimate)&#xA;2014 .de  €    25 421 (estimate)&#xA;2015 .de  €    23 867 (estimate)&#xA;2016 .de  €    21 679 (estimate)&#xA;2017 .de  €    22 720 (estimate)&#xA;2018 .de  €    24 185 (estimate)&#xA;2019 .de  €    27 081 (estimate)&#xA;2020 .de  €    29 418 (estimate)&#xA;2021 .de  €    41 264 (estimate)&#xA;Total .de €   396 536 (estimate)&#xA;&#xA;Total     € 1 622 056&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The German donations are mentioned separately; the 2002 report mentions:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Most sponsors and donors from Germany started paying through MISEREOR in 2002.&#xA;This gives them a tax advantage. In 2002 about 10 140 euro has been received by&#xA;MISEREOR. This money goes directly to the project and can therefore not be found&#xA;in the ICCF Holland figures. When adding MISEREOR to the total amount that&#xA;sponsors and donors have contributed towards the project, the increase is almost&#xA;50%.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;And the report from 2003 and onwards either don't mention a figure, or mention a&#xA;figure of &amp;quot;more than 10 000&amp;quot;. I've grown this amount with the same amount as the&#xA;other donations for 2003 and onwards, which should give a reasonable-ish&#xA;estimate. &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_use/ifBJbw72Itc&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bram has mentioned these are slightly too&#xA;high&lt;/a&gt; after I&#xA;announced that about a million Euro had been raised:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The estimate for the German donations are a bit too high though.  Last&#xA;year [2016] was about 16 000 euro.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;So how long has Vim been involved with ICCF? The oldest version of Vim I've been&#xA;able to find if Vim 3.0 from March 1996 (&lt;a href=&quot;http://vim.mirror.fr/unix/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;);&#xA;this already has the &amp;quot;charityware&amp;quot; license, in the &lt;code&gt;uganda.txt&lt;/code&gt; it says:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Summer 1993 I spent one month in Uganda with a Dutch team. I was very&#xA;impressed with what I experienced there. Together with local people we built a&#xA;nursery school in Kibaale. In only three weeks from nothing to a roofed&#xA;building!&lt;/p&gt;&#xA;&lt;p&gt;[..]&lt;/p&gt;&#xA;&lt;p&gt;The work is very well organized. Every dollar is spent on something useful.&#xA;Our team brought about $2000.&lt;/p&gt;&#xA;&lt;p&gt;[..]&lt;/p&gt;&#xA;&lt;p&gt;How do you know that the money will be spent right? First of all you have my&#xA;personal guarantee as the author of Vim. Further the project is co-sponsored&#xA;and inspected by World Vision, Save the Children Fund and International Child&#xA;Care Fund. I will work for the project as a volunteer from September 1994 to&#xA;August 1995.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I don't have the figures from 1994 to 1996; based on the above figures, I'll add&#xA;an estimate of €5 000 for these 2 years.&lt;/p&gt;&#xA;&lt;p&gt;So how much of this money comes from Vim users? All the financial reports have a&#xA;statement similar to this one:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Donations have been received for the use of Vim, but this is not mentioned&#xA;separately, because it is not always clear if a donation was because of using&#xA;Vim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This makes sense. I once did a (one-time) donation to ICCF, and just transferred&#xA;some money to the bank account; there is no way to know that I donated because I&#xA;use Vim and read about Uganda there.&lt;/p&gt;&#xA;&lt;p&gt;The announcement of the &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_dev/2czE8NAWetM&quot; rel=&quot;nofollow noreferrer&quot;&gt;2014 financial report&lt;/a&gt; also mentions:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I am very glad to see the amount has gone up quite a bit.  Mostly because of&#xA;one-time donations.  I'm not sure this is because of Vim users, but I expect&#xA;so&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Vim does keep a &amp;quot;&lt;a href=&quot;http://www.vim.org/sponsor/hall_of_honour.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;hall of honours&lt;/a&gt;&amp;quot; of people who donated more than €100;&#xA;however, this list is probably &lt;em&gt;very&lt;/em&gt; incomplete as well. The total amount&#xA;listed here is about €25 000. But for many people the donation amount is&#xA;concealed, and there are probably many more who aren't listed at all. So for the&#xA;purpose of this question, it's not very useful.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2022-09-21T12:43:49.810" LastActivityDate="2022-09-21T12:43:49.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="624" PostTypeId="2" ParentId="613" CreationDate="2015-02-08T21:08:23.633" Score="57" Body="&lt;h1&gt;vim-plug&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I like to use the &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;noreferrer&quot;&gt;vim-plug&lt;/a&gt; plugin manager.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with manually installing a plugin is that it's rather difficult to&#xA;&lt;em&gt;remove&lt;/em&gt; a plugin; you often have several different files in different&#xA;directories, you have to manually find them &amp;amp; remove them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Upgrading problems is similarly difficult: What if &lt;code&gt;autoload/old-name.vim&lt;/code&gt; gets&#xA;renamed to &lt;code&gt;autoload/new-name.vim&lt;/code&gt;? You now have &lt;em&gt;both&lt;/em&gt; an old and new version&#xA;of a plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim-plug&lt;/code&gt; solves this by storing each plugin in it's own directory; it also&#xA;includes command to easily install/remove a plugin, so you don't have to muck&#xA;about with unzipping plugins and the like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A key advantage of vim-plug over&#xA;&lt;a href=&quot;https://vi.stackexchange.com/a/615/51&quot;&gt;Pathogen&lt;/a&gt; is that vim-plug allows you to&#xA;install and remove plugins more easily. All that Pathogen does is allow each&#xA;plugin to be in a separate contained directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim-plug relies on &lt;a href=&quot;http://www.git-scm.com/&quot; rel=&quot;noreferrer&quot;&gt;git&lt;/a&gt;; for MS Windows, you want&#xA;&lt;a href=&quot;http://msysgit.github.io/&quot; rel=&quot;noreferrer&quot;&gt;msysgit&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can define plugins in your vimrc like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;&#xA;&quot; For MS Windows, this is probably better:&#xA;&quot;call plug#begin('~/vimfiles/plugged')&#xA;&#xA;Plug 'embear/vim-localvimrc'&#xA;Plug 'kchmck/vim-coffee-script'&#xA;&quot; ... etc&#xA;&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then restart Vim, and then install plugins with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PlugInstall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will put the plugins in &lt;code&gt;~/.vim/plugged&lt;/code&gt; or &lt;code&gt;$HOME\vimfiles\plugged&lt;/code&gt; for MS&#xA;Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add&#xA;&lt;a href=&quot;https://github.com/junegunn/vim-plug/wiki/faq#automatic-installation&quot; rel=&quot;noreferrer&quot;&gt;this snippet from the FAQ&lt;/a&gt; to&#xA;your vimrc file before the &lt;code&gt;plug#begin()&lt;/code&gt; call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if empty(glob('~/.vim/autoload/plug.vim'))&#xA;  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs&#xA;    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;  autocmd VimEnter * PlugInstall&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note you need &lt;code&gt;curl&lt;/code&gt; for this to work. This is almost always available on Linux and OSX, but not on MS Windows; so this trick won't work there...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To remove a plugin, remove it from the vimrc file and run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PlugClean&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that vim-plug doesn't support installing scripts from the Vim scripts&#xA;website, but &lt;a href=&quot;https://github.com/vim-scripts&quot; rel=&quot;noreferrer&quot;&gt;those scripts are mirrored on&#xA;GitHub&lt;/a&gt;, so there's no need to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also some additional advantages to this such as easier updating of&#xA;plugin, and on-demand loading for better performance. You can also easily copy&#xA;your vimrc to another computer, run &lt;code&gt;:PlugInstall&lt;/code&gt;, and have all your plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note there are more plugin managers; I happen to use &lt;code&gt;vim-plug&lt;/code&gt;.&#xA;See also: &lt;a href=&quot;https://vi.stackexchange.com/q/388/51&quot;&gt;What is the difference between the vim package managers?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-08T21:08:23.633" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="625" PostTypeId="1" CreationDate="2015-02-08T21:17:40.317" Score="208" ViewCount="281880" Body="&lt;p&gt;I use Vim as my primary editor.&lt;/p&gt;&#xA;&lt;p&gt;I would also like to use vim to diff files and modify the files while doing the diff to fix easy changes (rather than most diff techniques which are a cycle of diff, fix, diff, fix).&lt;/p&gt;&#xA;&lt;p&gt;Additionally are there easy ways to integrate Vim into diff tools used by source control tools/sites?&lt;/p&gt;&#xA;&lt;p&gt;I am specifically thinking of git but I am sure other people would be interested in integration with other source control tools/sites.&lt;/p&gt;&#xA;" OwnerUserId="383" LastEditorUserId="23502" LastEditDate="2022-10-30T17:47:22.670" LastActivityDate="2022-10-30T17:47:22.670" Title="How do I use Vim as a diff tool?" Tags="|vimdiff|" AnswerCount="11" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="626" PostTypeId="2" ParentId="625" CreationDate="2015-02-08T21:17:58.380" Score="215" Body="&lt;p&gt;vim has this functionality built in (with the correct command line flag).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -d &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This opens each file in a view and highlights the differences.&lt;br&gt;&#xA;Any code that is identical is &lt;code&gt;folded&lt;/code&gt; away so you do not need to look at identical code or scroll through huge chunks of identical code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there is also a wrapper application &lt;code&gt;vimdiff&lt;/code&gt; that correctly invokes vim with the correct flags.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff source1.cpp source2.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are using git you can set up an external diff tool. So it is easy to set up vimdiff to be the diff tool for git.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git config --global diff.tool vimdiff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When using vimdiff you can edit either side and diff highlighting keeps pace to show you the differences.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: When editing from a git diff. If you try and edit the repository stored version of the file your changes will be discarded when you exit (git does not trust you with the original so you are diffing against a tmp copy) but you can edit the local copy to your hearts content and save it over you current version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some basic commands that are useful in &lt;code&gt;vimdiff&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dp             diffput: puts changes under the cursor into the other file&#xA;                        making them identical (thus removing the diff).&#xA;do             diffget: (o =&amp;gt; obtain). The change under the cursor is replaced&#xA;                        by the content of the other file making them identical.&#xA;&#xA;&#xA;]c             Jump to the next diff&#xA;[c             Jump to the previous diff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other vim settings I use to work with highliting with vimdiff&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;diff&#xA;    highlight! link DiffText MatchParen&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This turns off highlighting on the bits of code that are changed. So the line that is changed is highlighted so I can spot the changes, but the actual text that has changed stands out on the line (as it is not highlighted).&lt;/p&gt;&#xA;" OwnerUserId="383" LastEditorUserId="383" LastEditDate="2015-02-08T21:40:51.210" LastActivityDate="2015-02-08T21:40:51.210" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="627" PostTypeId="1" AcceptedAnswerId="715" CreationDate="2015-02-08T21:55:13.213" Score="21" ViewCount="12522" Body="&lt;p&gt;When I start Vim without any files, I always see this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;              VIM - Vi IMproved&#xA;&#xA;               version 7.4.580&#xA;           by Bram Moolenaar et al.&#xA; Vim is open source and freely distributable&#xA;&#xA;        Become a registered Vim user!&#xA;type  :help register&amp;lt;Enter&amp;gt;   for information&#xA;&#xA;type  :q&amp;lt;Enter&amp;gt;               to exit&#xA;type  :help&amp;lt;Enter&amp;gt;  or  &amp;lt;F1&amp;gt;  for on-line help&#xA;type  :help version7&amp;lt;Enter&amp;gt;   for version info&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I change this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, I'd like to put the output of a shell command (&lt;code&gt;fortune&lt;/code&gt;) here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know about &lt;a href=&quot;https://github.com/mhinz/vim-startify&quot;&gt;vim-startify&lt;/a&gt;; but I don't need all those features. I just want to show some simple text...&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="24" LastEditDate="2015-02-09T02:27:44.370" LastActivityDate="2023-05-23T16:51:56.810" Title="How can I change Vim's start or intro screen?" Tags="|external-command|startup|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="628" PostTypeId="2" ParentId="627" CreationDate="2015-02-08T22:21:59.170" Score="7" Body="&lt;p&gt;Actually the answer is in startify. In &lt;a href=&quot;https://github.com/mhinz/vim-startify/blob/master/plugin/startify.vim&quot; rel=&quot;noreferrer&quot;&gt;startify.vim&lt;/a&gt; around line 15 we can see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; autocmd VimEnter * nested&#xA;\ if !argc() &amp;amp;&amp;amp; (line2byte('$') == -1) &amp;amp;&amp;amp; (v:progname =~? '^[-gmnq]\=vim\=x\=\%[\.exe]$')&#xA;\ | if get(g:, 'startify_session_autoload') &amp;amp;&amp;amp; filereadable('Session.vim')&#xA;\ | source Session.vim&#xA;\ | else&#xA;\ | call startify#insane_in_the_membrane()&#xA;\ | endif&#xA;\ | endif&#xA;\ | autocmd! startify VimEnter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the relevant thing is the &lt;code&gt;VimEnter&lt;/code&gt; auto command which is called &quot;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#VimEnter&quot; rel=&quot;noreferrer&quot;&gt;after doing all the startup stuff&lt;/a&gt;&quot;.&lt;br&gt;&#xA;The following &lt;code&gt;if&lt;/code&gt; checks whether this is an empty session (by checking for arguments like &lt;code&gt;filename&lt;/code&gt;). Basically you can put your code in the place of the second &lt;code&gt;if&lt;/code&gt;, which is the startify-specific code.&lt;/p&gt;&#xA;" OwnerUserId="59" LastEditorUserId="51" LastEditDate="2015-02-08T22:39:18.363" LastActivityDate="2015-02-08T22:39:18.363" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="629" PostTypeId="5" CreationDate="2015-02-08T23:01:03.953" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-08T23:01:03.953" LastActivityDate="2015-02-08T23:01:03.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="630" PostTypeId="4" CreationDate="2015-02-08T23:01:03.953" Score="0" Body="Command mode is the mode when you start the editor. Vim also calls this Normal mode. Not to be confused with command-line mode, which is what you get after you press :." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-09T02:28:32.217" LastActivityDate="2015-02-09T02:28:32.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="631" PostTypeId="1" AcceptedAnswerId="632" CreationDate="2015-02-08T23:04:34.697" Score="8" ViewCount="2564" Body="&lt;p&gt;I often use &lt;code&gt;:Ex&lt;/code&gt; or &lt;code&gt;:Sex&lt;/code&gt; to explore the filesystem from an opened file directory, or just invoke vim passing a directory to start exploring the filesystem and then opening a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, while navigating the directory tree, using the &lt;code&gt;:edit {file}&lt;/code&gt; command to open new files always takes paths relative to the current directory from which vim was executed; so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~# vim .&#xA;-&amp;gt; navigate to Development/&#xA;-&amp;gt; open a file&#xA;:e &amp;lt;tab&amp;gt; will complete path from home dir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~# vim Development/&#xA;-&amp;gt; open a file&#xA;:Sex&#xA;:e &amp;lt;tab&amp;gt; will complete paths from Development/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is it possible (automagically or with a command) to change vim current working directory to the current selected directory while navigating the filesystem? &lt;/p&gt;&#xA;" OwnerUserId="188" LastEditorUserId="51" LastEditDate="2015-02-20T11:55:48.507" LastActivityDate="2015-02-20T11:55:48.507" Title="Make :edit {file} use current directory during :Explore" Tags="|filesystem|working-directory|netrw|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="632" PostTypeId="2" ParentId="631" CreationDate="2015-02-08T23:22:19.500" Score="6" Body="&lt;p&gt;It is possible by setting the netrw configuration variable &lt;code&gt;g:netrw_keepdir&lt;/code&gt; to 0  (default is 1).&lt;br&gt;&#xA;To make it permanent, add in the .vimrc file this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_keepdir=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="311" LastEditorUserId="311" LastEditDate="2015-02-08T23:40:54.883" LastActivityDate="2015-02-08T23:40:54.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="633" PostTypeId="2" ParentId="631" CreationDate="2015-02-08T23:23:12.713" Score="7" Body="&lt;p&gt;Yes, vim has a &lt;code&gt;:cd&lt;/code&gt; command, which either prints the current directory or changes the current directory.  In the help is this - note the last lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cd[!] {path}           Change the current directory to {path}.&#xA;                        If {path} is relative, it is searched for in the&#xA;                        directories listed in |'cdpath'|.&#xA;                        Does not change the meaning of an already opened file,&#xA;                        because its full path name is remembered.  Files from&#xA;                        the |arglist| may change though!&#xA;                        On MS-DOS this also changes the active drive.&#xA;                        To change to the directory of the current file: &amp;gt;&#xA;                                :cd %:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As noted at the top of the help for &lt;code&gt;:cd&lt;/code&gt;, this affects vim's working directory, not just what &lt;code&gt;:Ex&lt;/code&gt; returns to or internal commands use, so external commands will also use the new location.&lt;/p&gt;&#xA;" OwnerUserId="238" LastActivityDate="2015-02-08T23:23:12.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="634" PostTypeId="5" CreationDate="2015-02-09T02:15:29.733" Score="0" Body="&lt;p&gt;Vim starts in &lt;em&gt;normal mode&lt;/em&gt; (unless you &lt;code&gt;:set insertmode&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt;).  In this mode Vim executes &lt;em&gt;commands&lt;/em&gt; when you press keys on the keyboard.  This is opposed to &lt;em&gt;insert mode&lt;/em&gt; where pressing keys inserts text into the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Normal mode&lt;/em&gt; is often referred to as the &lt;em&gt;command mode&lt;/em&gt;.  The commands that can be performed in normal mode are &lt;em&gt;vi commands&lt;/em&gt; (not to be confused with &lt;em&gt;ex commands&lt;/em&gt;, see &lt;a href=&quot;/questions/tagged/ex-mode&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;ex-mode&amp;#39;&quot; rel=&quot;tag&quot;&gt;ex-mode&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can leave the normal mode by pressing:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;i&lt;/kbd&gt; to enter &lt;a href=&quot;/questions/tagged/insert-mode&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;insert-mode&amp;#39;&quot; rel=&quot;tag&quot;&gt;insert-mode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;v&lt;/kbd&gt;, &lt;kbd&gt;V&lt;/kbd&gt; or &lt;kbd&gt;Ctrl+v&lt;/kbd&gt; to enter &lt;a href=&quot;/questions/tagged/visual-mode&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;visual-mode&amp;#39;&quot; rel=&quot;tag&quot;&gt;visual-mode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Q&lt;/kbd&gt; to enter &lt;a href=&quot;/questions/tagged/ex-mode&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;ex-mode&amp;#39;&quot; rel=&quot;tag&quot;&gt;ex-mode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt;, &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;H&lt;/kbd&gt; or &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;Ctrl+h&lt;/kbd&gt; to enter &lt;a href=&quot;/questions/tagged/select-mode&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;select-mode&amp;#39;&quot; rel=&quot;tag&quot;&gt;select-mode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;/&lt;/kbd&gt;, &lt;kbd&gt;?&lt;/kbd&gt;, &lt;kbd&gt;!&lt;/kbd&gt; or &lt;kbd&gt;:&lt;/kbd&gt; to enter commands in &lt;em&gt;command-line-mode&lt;/em&gt; and then return to normal mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/intro.html#Normal-mode&quot; rel=&quot;nofollow&quot;&gt;:h Normal-mode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27insertmode%27&quot; rel=&quot;nofollow&quot;&gt;:h insertmode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="5229" LastEditDate="2016-06-30T07:24:02.700" LastActivityDate="2016-06-30T07:24:02.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="635" PostTypeId="4" CreationDate="2015-02-09T02:15:29.733" Score="0" Body="Command mode is the initial mode. Vim calls this Normal mode. Not to be confused with command-line-mode, which is what you get after you press :, /, ?, or !" OwnerUserId="24" LastEditorUserId="7700" LastEditDate="2016-06-30T00:09:38.010" LastActivityDate="2016-06-30T00:09:38.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="636" PostTypeId="1" CreationDate="2015-02-09T02:18:44.097" Score="4" ViewCount="522" Body="&lt;p&gt;I found that when I am using Vim to compose git commit messages (which I have been doing for a very long time now) that there are occasionally some quirks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example today I wrote a commit message that began with the word &quot;do&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This actually forces the second line to be indented for me. Likely because do is often a keyword that initiates a &lt;code&gt;do&lt;/code&gt;...&lt;code&gt;while&lt;/code&gt; loop. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make modifications to syntax definitions to remove this behavior? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I am in this situation, the &lt;code&gt;formatoptions&lt;/code&gt; is set to &lt;code&gt;caq1njwtl&lt;/code&gt;. However, I don't think that this is relevant because I don't really care about having my message auto-wrapped, I just want it to not apply any indentation. &lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="24" LastEditDate="2015-02-09T15:37:23.113" LastActivityDate="2015-02-09T15:37:23.113" Title="Why does Vim force programming indentation when in &quot;gitcommit&quot; filetype?" Tags="|indentation|filetype-git|version-control-systems|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="637" PostTypeId="5" CreationDate="2015-02-09T02:29:29.810" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-09T02:29:29.810" LastActivityDate="2015-02-09T02:29:29.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="638" PostTypeId="4" CreationDate="2015-02-09T02:29:29.810" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-09T02:29:29.810" LastActivityDate="2015-02-09T02:29:29.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="639" PostTypeId="5" CreationDate="2015-02-09T02:31:18.923" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-09T02:31:18.923" LastActivityDate="2015-02-09T02:31:18.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="640" PostTypeId="4" CreationDate="2015-02-09T02:31:18.923" Score="0" Body="Activity that occurs after invocation but before the first document is displayed" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-09T12:27:32.823" LastActivityDate="2015-02-09T12:27:32.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="641" PostTypeId="2" ParentId="562" CreationDate="2015-02-09T03:11:33.727" Score="4" Body="&lt;p&gt;One solution would be to use a single instance of vim per project, which would prevent this issue unless your multiple projects had overlapping files.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm going to assume that you are looking for a automated solution, instead of a suggestion on changing your behavior though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is the possibility of another solution in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#FocusLost&quot; rel=&quot;nofollow&quot;&gt;FocusLost&lt;/a&gt; that is more native to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The FocusLost autocommand event works in GUI Vim, and in some console terminals. You could, instead of switching to the file in the version of vim which is open (which, if you are using multiple gui windows is messy), persist any changes that weren't written in the other instance of vim are not lost (a separate git branch, save then undo so it's in the undo tree, or simply saving it) and open it in the new instance with an indication that it was opened before.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another potentially useful autocommand event, available in vim 7, is &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#SwapExists&quot; rel=&quot;nofollow&quot;&gt;SwapExists&lt;/a&gt;, which indicates that a swap file exists for the file, IE it's open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you kept everything in tmux or screen, there is probably a way to switch to the appropriate window/pane.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A brief github search also brings up &lt;a href=&quot;https://github.com/lynnard/editexisting.vim&quot; rel=&quot;nofollow&quot;&gt;https://github.com/lynnard/editexisting.vim&lt;/a&gt; which seems to work for specific window managers like Xmonad.  &lt;/p&gt;&#xA;" OwnerUserId="233" LastActivityDate="2015-02-09T03:11:33.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="642" PostTypeId="5" CreationDate="2015-02-09T04:11:04.373" Score="0" Body="&lt;p&gt;This tag is for questions about interacting with Vim's buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#windows-intro&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help windows-intro&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A buffer is the in-memory text of a file&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A buffer is a file loaded into memory for editing.  The original file remains unchanged until you write the buffer to the file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For questions about Vim windows (the &quot;viewport&quot; onto a buffer) see &lt;a href=&quot;/questions/tagged/window-management&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'window-management'&quot; rel=&quot;tag&quot;&gt;window-management&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Buffers and windows are coupled topics. For more information about both, see &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help windows.txt&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-02-09T12:27:51.997" LastActivityDate="2015-02-09T12:27:51.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="643" PostTypeId="4" CreationDate="2015-02-09T04:11:04.373" Score="0" Body="The representation of a file loaded into memory. Edits are performed on buffers." OwnerUserId="227" LastEditorUserId="51" LastEditDate="2015-05-12T19:10:15.803" LastActivityDate="2015-05-12T19:10:15.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="644" PostTypeId="5" CreationDate="2015-02-09T04:29:14.293" Score="0" Body="&lt;p&gt;This tag is for questions pertaining to registers in all vi-like editors, and for enhanced register operation in Vim-like editors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has documentation on registers at &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#registers&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help registers&lt;/code&gt;&lt;/a&gt;, with additional information at  &lt;a href=&quot;http://vimhelp.appspot.com/usr_07.txt.html#07.5&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help 07.5&lt;/code&gt;&lt;/a&gt; under section header &lt;code&gt;USING REGISTERS&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-02-09T12:27:28.563" LastActivityDate="2015-02-09T12:27:28.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="645" PostTypeId="4" CreationDate="2015-02-09T04:29:14.293" Score="0" Body="Registers store snippets of text for yank (copy), delete (cut), put (paste). In Vim, registers are also used for macro playback and some registers are special and can reference the OS clipboard or evaluate expressions." OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-02-09T12:27:38.547" LastActivityDate="2015-02-09T12:27:38.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="646" PostTypeId="5" CreationDate="2015-02-09T05:11:37.323" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-09T05:11:37.323" LastActivityDate="2015-02-09T05:11:37.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="647" PostTypeId="4" CreationDate="2015-02-09T05:11:37.323" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-09T05:11:37.323" LastActivityDate="2015-02-09T05:11:37.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="648" PostTypeId="2" ParentId="636" CreationDate="2015-02-09T07:35:39.987" Score="6" Body="&lt;p&gt;Here is how I solved the problem, by adding to my &lt;code&gt;.vimrc&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType gitcommit set nosmartindent | set formatoptions-=t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This removes the option that causes the lines to auto-wrap (which is another tweak I also made -- take out the last part including the &lt;code&gt;|&lt;/code&gt; if you do not want to change this). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The take-away here is that &lt;code&gt;nosmartindent&lt;/code&gt; is the trick to addressing any undesired auto indentation behaviors. &lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2015-02-09T07:35:39.987" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="649" PostTypeId="2" ParentId="564" CreationDate="2015-02-09T11:38:12.067" Score="11" Body="&lt;p&gt;In the past I had similar problem with function signatures. Here is solution adapted to your problem. Add to &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au CursorMovedI *.md call ModifyTextWidth() &quot; Use only within *.md files&#xA;&#xA;function! ModifyTextWidth()&#xA;    if getline(&quot;.&quot;)=~'^.*\[.*\](.*)$' &quot; If the line ends with Markdown link - set big value for textwidth&#xA;        setlocal textwidth=500&#xA;    else&#xA;        setlocal textwidth=80 &quot; Otherwise use normal textwidth&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, you may want to change &lt;code&gt;'^.*\[.*\](.*)$'&lt;/code&gt; regex. Currently if there is any text after the link, line may be broken as in your example. However, if the regex would match lines with links anywhere inside, another problem can appear:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Some info [here](https://www.google.com). Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this example line break is not inserted after &lt;code&gt;amet,&lt;/code&gt; and should be added manually.&lt;/p&gt;&#xA;" OwnerUserId="362" LastEditorUserId="51" LastEditDate="2015-02-12T13:55:05.530" LastActivityDate="2015-02-12T13:55:05.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="650" PostTypeId="2" ParentId="241" CreationDate="2015-02-09T11:45:41.427" Score="13" Body="&lt;p&gt;Another option could be to open your current window in a new tab, then simply close the tab when you're done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:split&lt;/code&gt; (or &lt;code&gt;:sp&lt;/code&gt; for short) command, without an argument, has the effect of opening a new split with the same buffer as the current split. The &lt;code&gt;:tab&lt;/code&gt; command can run many window-related commands, changing them to use a tab instead. Combining these together gives &lt;code&gt;:tab sp&lt;/code&gt;, which will open a new tab with the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Afterward, you can close the new tab with &lt;code&gt;:q&lt;/code&gt; or &lt;code&gt;:tabclose&lt;/code&gt; (&lt;code&gt;:tabc&lt;/code&gt; for short).&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-02-09T11:45:41.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="651" PostTypeId="2" ParentId="444" CreationDate="2015-02-09T12:01:13.250" Score="14" Body="&lt;p&gt;If you've ever run an external command from Vim that modifies the current buffer, you may have noticed that it prompts you to reload the file since changes have been made to disk. You can actually invoke this prompt using the &lt;code&gt;:checktime&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-02-09T12:01:13.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="652" PostTypeId="2" ParentId="588" CreationDate="2015-02-09T13:45:42.523" Score="10" Body="&lt;p&gt;It's definitely not supported in GUI Vim, and I'd be surprised if there were more than handful of terminal emulators that support proportional fonts in the way that you're hoping for: it would break too many of the standard things for which terminals are used. As so many parts of Unix and other command-line environments presume monospaced fonts, this type of display couldn't be used as a general purpose terminal, so the terminal's developer would have to have carried out additional work for little benefit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there does exist at least one Terminal emulator that's implemented using web technologies (&lt;a href=&quot;http://antony.lesuisse.org/software/ajaxterm/HEADER.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ajaxterm&lt;/a&gt;), and as this uses HTML/CSS for rendering, it's possible to make it to use a proportional font using CSS. &lt;a href=&quot;https://cjshayward.com/terminal/&quot; rel=&quot;nofollow noreferrer&quot;&gt;CJS Hayward has done just this, but it requires using a very old browser.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you were to run Vim in such a terminal, then you'd get what you're asking for; just be prepared for wacky hijinx when you use any column-based features. (e.g. &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, blockwise visual mode, or the &lt;code&gt;'colorcolumn'&lt;/code&gt; option)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt; As original question-asker &lt;a href=&quot;https://vi.stackexchange.com/questions/588/can-i-use-a-non-monospaced-font-in-either-vim-or-gvim/652#comment853_652&quot;&gt;Carpetsmoker points out in a comment&lt;/a&gt;, Emacs has proper proportional font support and also includes a terminal emulator (&lt;code&gt;M-x term&lt;/code&gt;), inside which you can run Vim. Dedicated proportional-font enthusiasts might also like to look into &lt;a href=&quot;https://www.emacswiki.org/emacs/Evil&quot; rel=&quot;nofollow noreferrer&quot;&gt;Emacs's Evil&lt;/a&gt; to get a Vim-like experience within Emacs.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-09-17T12:16:32.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="653" PostTypeId="1" AcceptedAnswerId="654" CreationDate="2015-02-09T14:22:03.177" Score="5" ViewCount="4964" Body="&lt;p&gt;How to configure on the &lt;code&gt;.vimrc&lt;/code&gt; file to use a particular set options for a particular filetype, but others for a different filetype?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I want to enable expand tab (set tabs to be spaces) for Python files, but disable it for C++ files.&lt;/p&gt;&#xA;" OwnerUserId="403" LastActivityDate="2015-02-09T14:44:49.290" Title="Set an option dependent on the filetype" Tags="|vimrc|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ClosedDate="2015-02-09T15:47:25.997" ContentLicense="CC BY-SA 3.0" />
  <row Id="654" PostTypeId="2" ParentId="653" CreationDate="2015-02-09T14:44:49.290" Score="5" Body="&lt;p&gt;I put this sort of thing in &lt;code&gt;$HOME/.vim/ftdetect/{FILETYPE}.vim&lt;/code&gt;.  To accomplish what you want I would have the following files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For python...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;$HOME/.vim/ftdetect/python.vim&#xA;autocmd BufRead,BufNewFile *.py set noexpandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And for C++...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;$HOME/.vim/ftdetect/cpp.vim&#xA;autocmd BufRead,BufNewFile *.cpp set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What these commands do is set the &lt;code&gt;expandtab&lt;/code&gt; or &lt;code&gt;noexpandtab&lt;/code&gt; options for a specific buffer which gets created for, or reads in, a file that matches one of the patterns &lt;code&gt;*.py&lt;/code&gt; or &lt;code&gt;*.cpp&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="93" LastActivityDate="2015-02-09T14:44:49.290" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="655" PostTypeId="2" ParentId="631" CreationDate="2015-02-09T14:51:52.893" Score="7" Body="&lt;p&gt;I set the following two options to ensure that Vim's current working directory is always the same as the current buffer's.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autochdir                   &quot; Changes the cwd to the directory of the current&#xA;                                &quot; buffer whenever you switch buffers.&#xA;set browsedir=current           &quot; Make the file browser always open the current&#xA;                                &quot; directory.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="93" LastActivityDate="2015-02-09T14:51:52.893" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="656" PostTypeId="1" AcceptedAnswerId="657" CreationDate="2015-02-09T16:13:37.067" Score="18" ViewCount="1724" Body="&lt;p&gt;In Bash, when there are several files with the same prefix and I type part of the prefix and hit &lt;kbd&gt;Tab&lt;/kbd&gt;, it completes the common prefix and allows me to continue typing to differentiate among the possible results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim, when there are several files with the same prefix and I type part of the prefix and hit &lt;kbd&gt;Tab&lt;/kbd&gt;, it completes the entire first match and lets me then select among all the matches. To reduce the set, I have to backspace until I get to the end of the common part, then type some more and hit &lt;kbd&gt;Tab&lt;/kbd&gt; again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often have &lt;em&gt;lots&lt;/em&gt; of files where there is a long common prefix, and the file I want is not among the first (for example, a directory of project files containing, among other things, various makefiles all with the name &lt;code&gt;Makefile.{whatever}&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I make Vim complete more like Bash to save lots of key strokes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus if this can apply to other completions as well (for example, enum values that all have the same prefix)&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-02-09T16:23:08.590" Title="Bash-like partial tab-complete for filenames in Vim" Tags="|command-line|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="657" PostTypeId="2" ParentId="656" CreationDate="2015-02-09T16:17:46.727" Score="18" Body="&lt;p&gt;You can use the &lt;code&gt;wildmode&lt;/code&gt; option to control this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;:set wildmode=list:longest&lt;/code&gt;, you get behaviour similar to bash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally prefer to use &lt;code&gt;:set wildmode=list:longest,full&lt;/code&gt;; this will list completions, but on the &lt;em&gt;second&lt;/em&gt; &lt;kbd&gt;Tab&lt;/kbd&gt; press, you can cycle between the entries (and &lt;kbd&gt;Shift+Tab&lt;/kbd&gt; to cycle in the reverse).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This applies to &lt;em&gt;all&lt;/em&gt; completions done by Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27wildmode%27&quot;&gt;&lt;code&gt;:help 'wildmode'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-09T16:23:08.590" LastActivityDate="2015-02-09T16:23:08.590" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="658" PostTypeId="2" ParentId="356" CreationDate="2015-02-09T16:54:28.493" Score="16" Body="&lt;p&gt;Vim 7.3 brings the &lt;code&gt;colorcolumn&lt;/code&gt; option, as detailed very well in other answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you don't have version 7.3 for whatever reason, you can still achieve a visual indication that you are exceeding a particular column count using vim's &lt;code&gt;match&lt;/code&gt; functionality (see &lt;code&gt;:help match&lt;/code&gt; for details).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, the match commands allow you to create persistent highlights for text matching a given regular expression. &lt;code&gt;:match ColorColumn &quot;\%80v.&quot;&lt;/code&gt; will highlight text in column 80 with the &quot;ColorColumn&quot; group. You can of course substitute any highlight group, and any column value. If you want a strong visual indication, the expression &lt;code&gt;&quot;\%&amp;gt;79v.\+&quot;&lt;/code&gt; will highlight column 80 and beyond.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;\%80v&lt;/code&gt; means &quot;match in virtual column 80,&quot; and &lt;code&gt;\%&amp;gt;79v&lt;/code&gt; means &quot;match &lt;em&gt;after&lt;/em&gt; virtual column 79; see &lt;code&gt;:help /\%c&lt;/code&gt; for more.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This approach will only highlight when there are actual characters present in the specified columns, however, which makes it visually less consistent than &lt;code&gt;colorcolumn&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-02-09T16:54:28.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="659" PostTypeId="2" ParentId="574" CreationDate="2015-02-09T17:45:01.690" Score="6" Body="&lt;p&gt;Instead of showing a line showing the maximum size, the extra characters can also been highlighted through&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:let w:m1=matchadd('ErrorMsg', '\%&amp;gt;80v.\+', -1)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will set the extra characters to be marked as error (normally, red background, but it depends on the color scheme).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be added to &lt;code&gt;.vimrc&lt;/code&gt; to do it automatically on each file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%&amp;gt;80v.\+', -1)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="403" LastActivityDate="2015-02-09T17:45:01.690" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="660" PostTypeId="1" CreationDate="2015-02-09T18:43:14.927" Score="15" ViewCount="3320" Body="&lt;p&gt;When merging branches under source control there is often the issue of a merge conflict with other developers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that &lt;a href=&quot;https://vi.stackexchange.com/q/625/383&quot;&gt;we can use vimdiff to diff code changes against source control&lt;/a&gt;, but is there also a way we can use vimdiff to help resolve merge conflicts conflicts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I am interested more in git but it would be useful to understand if there are plugins/techniques for other source control tools/systems.&lt;/p&gt;&#xA;" OwnerUserId="383" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-19T17:05:39.120" Title="vimdiff and merge conflicts" Tags="|vimdiff|version-control-systems|merge|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="661" PostTypeId="2" ParentId="660" CreationDate="2015-02-09T18:43:27.317" Score="19" Body="&lt;p&gt;I normally use git on the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when there is a merge conflict I use Vim to resolve them with (personally I do it with with the fugitive plugin). Note: fugitive is good for a lot of git manipulation from within Vim. My favorite feature is the 3 way diff of a merge conflict.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;git supports this in vimdiff via git mergetool. I have installed fugitive but you can set it up manually (Thanks @Jay Thompson).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Manual Set up:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git config --global merge.tool vimdiff&#xA;git mergetool &amp;lt;file with conflicts&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output is slightly different to what is described below (I have not personally used this). But the principle is the same but you have a fourth window at the bottom containing the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Je2ey.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Set up with Fugitive&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;noreferrer&quot;&gt;vim-fugitive&lt;/a&gt; is a git wrapper/integration plugin for Vim; it can do many things, and resolving conflicts is one of them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Install the Fugitive Plugin&amp;gt;&#xA;vim &amp;lt;file with conflicts&amp;gt;&#xA;:Gdiff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;View 2 (left) : The code that was on your branch.&lt;/li&gt;&#xA;&lt;li&gt;View 1 (middle) : The merged code (with conflicts)&lt;/li&gt;&#xA;&lt;li&gt;View 3 (right) : The code that was merged into your code.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can now pull and get text from the two other views into the central view (which is going to contain all the manual fixes). Once you have resolved all the conflicts manually simply exit vimdiff&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ibbG6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though you can use &lt;code&gt;:diffget &amp;lt;view number&amp;gt;&lt;/code&gt; and &lt;code&gt;:diffput &amp;lt;view number&amp;gt;&lt;/code&gt; to pull and push things between views. I don't personally find that very useful. All the code is already in the middle view. So I just like to edit that view manually until the conflict is resolved. Being able to see both versions of the code on either side of my editor window though is extremely useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also a very good demo of its use &lt;a href=&quot;http://vimcasts.org/episodes/fugitive-vim-resolving-merge-conflicts-with-vimdiff/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="383" LastEditorUserId="51" LastEditDate="2015-02-10T09:05:33.297" LastActivityDate="2015-02-10T09:05:33.297" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="662" PostTypeId="1" CreationDate="2015-02-09T19:18:50.120" Score="12" ViewCount="2115" Body="&lt;p&gt;Related to &lt;a href=&quot;https://vi.stackexchange.com/questions/656/bash-like-partial-tab-complete-for-filenames-in-vim&quot;&gt;Bash-like partial tab-complete for filenames in Vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the truly fantastic features of &lt;code&gt;zsh&lt;/code&gt; is that you can type, for example, &lt;code&gt;ls /u/s/m/m/who.1&lt;/code&gt;, press &lt;kbd&gt;Tab&lt;/kbd&gt; and have it complete to &#xA;&lt;code&gt;ls /usr/share/man/man1/who.1.gz&lt;/code&gt;. Once you get used to it, it's really annoying to to go back to &lt;code&gt;/u&amp;lt;tab&amp;gt;/s&amp;lt;tab&amp;gt;/m&amp;lt;tab&amp;gt;/m&amp;lt;tab&amp;gt;...&lt;/code&gt;, especially when the entire partial path can only resolve to one actual path, but each individual component may have multiple completions. Can this be achieved in Vim, for example, when using &lt;code&gt;:e&lt;/code&gt; or &lt;code&gt;:cd&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other useful path-related features in zsh, such as using &lt;code&gt;cd foo bar&lt;/code&gt; to move to an equivalent path with &lt;code&gt;foo&lt;/code&gt; replaced with &lt;code&gt;bar&lt;/code&gt; (i.e., &lt;code&gt;/blah/foo/baz/yada&lt;/code&gt; becomes &lt;code&gt;/blah/bar/baz/yada&lt;/code&gt;). If there's a solution that brings in these as well (essentially handing over shell-related tasks to a shell that does those very well), it would be great.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-11T10:11:09.567" Title="Zsh-like tab completion of partial paths" Tags="|command-line|autocompletion|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="663" PostTypeId="1" AcceptedAnswerId="669" CreationDate="2015-02-09T20:48:57.947" Score="12" ViewCount="401" Body="&lt;p&gt;While fonts can be manually selected in GVim from the menu, I have a few preferred fonts I would like to switch between depending on the task at hand &lt;em&gt;(small bitmap, larger OTF... etc)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can setup key-binding to cycle over a list of fonts predefined in my vimrc?&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="51" LastEditDate="2015-04-30T15:39:38.637" LastActivityDate="2015-04-30T15:39:38.637" Title="Quickly switch between fonts at runtime" Tags="|key-bindings|gvim|font|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="664" PostTypeId="2" ParentId="663" CreationDate="2015-02-09T21:17:46.247" Score="7" Body="&lt;p&gt;I have the following defined in my .vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can set that up as a mapping like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;Leader&amp;gt;f :set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 10&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add additional mappings for other fonts.&lt;/p&gt;&#xA;" OwnerUserId="93" LastActivityDate="2015-02-09T21:17:46.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="665" PostTypeId="1" AcceptedAnswerId="668" CreationDate="2015-02-09T21:51:02.970" Score="5" ViewCount="97" Body="&lt;p&gt;The plugin transwrd.vim allows to to easily swap two words by pressing &lt;code&gt;&amp;lt;A-t&amp;gt;&lt;/code&gt; while having cursor on the latter word.&#xA;For example:  &lt;code&gt;two words&lt;/code&gt; becomes &lt;code&gt;words two&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the pattern which designates a word is contained in the &lt;code&gt;g:transwrd_wordpattern&lt;/code&gt; variable and is (as default) the following: &lt;code&gt;\k\+&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to define an advanced pattern which allows to be more programming language savvy (while still working for normal words)? Eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;param[0], param[1]  --&amp;gt;  param[1], param[0]&#xA;int call1()         --&amp;gt;  call1() int&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way it could also be used to swap function arguments (related to this other &lt;a href=&quot;https://vi.stackexchange.com/questions/609/swap-function-arguments&quot;&gt;question&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="311" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-09T22:22:28.593" Title="Programming-oriented word swap using transwrd.vim" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="666" PostTypeId="1" AcceptedAnswerId="667" CreationDate="2015-02-09T22:16:49.227" Score="70" ViewCount="73155" Body="&lt;p&gt;In Sublime Text 2, you get vertical guides where your indentation is, like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/nxPrP.png&quot; alt=&quot;Sublime Text screenshot&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;but Vim doesn't:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/LEnqM.png&quot; alt=&quot;vim screenshot&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to show lines like that in Vim?&lt;/p&gt;&#xA;&lt;p&gt;By the way, my indentation is 2 spaces.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set tabstop=2 softtabstop=2 shiftwidth=2 expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="226" LastEditorUserId="23502" LastEditDate="2022-10-28T07:26:55.933" LastActivityDate="2022-10-28T07:26:55.933" Title="How to add indentation guides/lines?" Tags="|indentation|alignment|colorscheme|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="667" PostTypeId="2" ParentId="666" CreationDate="2015-02-09T22:20:31.003" Score="57" Body="&lt;p&gt;Unified answer:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;If you are using tabs&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I'd try using listchars:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set listchars=tab:\|\ &#xA;:set list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;note: there is a space after the last &lt;code&gt;\&lt;/code&gt; above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method is good because it uses Vim's built-in support for showing this kind of thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|       if (1) {&#xA;|       |       func();&#xA;|       }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/KrK5w.png&quot; alt=&quot;screenshot of text sample above&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this doesn't work for leading spaces. As pointed out by @Josh Petrie, &lt;a href=&quot;http://vim.1045645.n5.nabble.com/Patch-support-for-the-quot-space-quot-argument-for-quot-listchars-quot-td1210494.html&quot; rel=&quot;noreferrer&quot;&gt;there is a patch to work for spaces&lt;/a&gt;, but then you'd have to recompile Vim, which is beyond the scope of this answer.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;If you are using spaces, and don't mind using a plugin&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Vaibhav Sagar points out the plugin &lt;a href=&quot;https://github.com/Yggdroot/indentLine&quot; rel=&quot;noreferrer&quot;&gt;indentLine&lt;/a&gt; performs this functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install in the normal way (see &lt;a href=&quot;https://vi.stackexchange.com/questions/613/how-to-install-a-plugin-in-vim-vi&quot;&gt;installing Plugins&lt;/a&gt;) and it seems to magically just work without further input. If you don't mind the ASCII bars, you don't need to do anything with your fonts. Example output of your example after setting your indentation settings and running &lt;code&gt;:IndentLinesReset&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;45   ¦ var move = function(direction) {&#xA;46   ¦ ¦ if(!initialized) { initialize(); }&#xA;47 &#xA;48   ¦ ¦ if(shiftBoard(direction)) {&#xA;49   ¦ ¦ ¦ setTimeout(addRandomPiece, 100);&#xA;50   ¦ ¦ }&#xA;51   ¦ };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/JyLPY.png&quot; alt=&quot;screenshot of example with spaces&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin requires Vim 7.3 or later, and makes cleaver use of that version's Conceal feature. Instead of actually hiding text, it replaces text with bars in the view, but not the actual buffer. The result is you see the bars but they don't get saved into the file (since they are actually spaces)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Caveat&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Both of these methods assume &quot;properly&quot; indented code. They don't place the indentation lines at the level of indent when a &quot;block&quot; is opened (which sublime appears to do) but instead places lines at regular intervals based on your indentation settings. Additionally, it only shows the bars on lines where there is actually space (which is why the line in the vim output under the first &lt;code&gt;if&lt;/code&gt; has no bars, making a visual gap)&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-10T17:33:38.580" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="668" PostTypeId="2" ParentId="665" CreationDate="2015-02-09T22:22:28.593" Score="5" Body="&lt;p&gt;Yes, if you can come up with a regular expression that will, alone, capture everything you consider to be a &quot;word.&quot; The plugin uses the pattern stored in &lt;code&gt;g:transwrd_wordpattern&lt;/code&gt; to identify words by finding two matches and then swapping the characters in the matched ranges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing &lt;code&gt;let g:transwrd_wordpattern='[a-zA-Z0-9\[\]\(\)]\+'&lt;/code&gt; will, for example, let it match both of your examples.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-02-09T22:22:28.593" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="669" PostTypeId="2" ParentId="663" CreationDate="2015-02-09T22:29:57.733" Score="13" Body="&lt;p&gt;The basic idea could be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Define a list of the fonts you want to use, and the index in the &#xA;&quot; list of the default font. See :help Lists&#xA;let g:fc_list = [&#xA;\   &quot;DejaVu Sans Mono 9&quot;,&#xA;\   &quot;Source Code Pro 12&quot;,&#xA;\   &quot;GohuFont 11&quot;&#xA;\   ]&#xA;let g:fc_current = 0&#xA;&#xA;&quot; Set default font&#xA;let &amp;amp;guifont = g:fc_list[g:fc_current]&#xA;&#xA;function! FontCycle()&#xA;  &quot; Increment circular list. See :help expr-%&#xA;  let g:fc_current = (g:fc_current + 1) % len(g:fc_list)&#xA;  let &amp;amp;guifont = g:fc_list[g:fc_current]&#xA;endfunction&#xA;&#xA;noremap &amp;lt;leader&amp;gt;fc :call FontCycle()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2015-02-10T10:54:03.367" LastActivityDate="2015-02-10T10:54:03.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="670" PostTypeId="2" ParentId="666" CreationDate="2015-02-10T00:08:50.100" Score="10" Body="&lt;p&gt;I've found the &lt;a href=&quot;https://github.com/Yggdroot/indentLine&quot;&gt;indentLine&lt;/a&gt; plugin to be the best for this. You do need a font with the appropriate symbols though, I find Consolas on Windows and Menlo on Mac OS X work well. As is pointed out in the unified answer above, it works by (ab)using vim's &lt;code&gt;conceal&lt;/code&gt; feature to put vertical bars (from the font used) in the right place. I'm pretty happy with this solution but the disadvantage to it is that my vertical bars are part of the box-drawing glyphs and they are center-aligned instead of left-aligned like in other editors. I've gotten used to it but it can be fixed by manually patching your font or using a font like &lt;a href=&quot;https://github.com/belluzj/fantasque-sans&quot;&gt;Fantasque Sans Mono&lt;/a&gt; (note how the screenshots in the linked github repo use indentLine).&lt;/p&gt;&#xA;" OwnerUserId="159" LastEditorUserId="159" LastEditDate="2015-02-10T09:51:20.767" LastActivityDate="2015-02-10T09:51:20.767" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="671" PostTypeId="5" CreationDate="2015-02-10T03:51:50.220" Score="0" Body="&lt;p&gt;This tag is for questions about using the vi family of editors in the context of version control systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Questions about a specific VSC plugin should use a plugin-* tag instead of this one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Appropriate questions include methods of invoking the editor (e.g. command line arguments to use) from a VCS, or about options for interfacing with a VCS from within the editor, such as which plugins provide a feature.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-02-10T10:08:59.770" LastActivityDate="2015-02-10T10:08:59.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="672" PostTypeId="4" CreationDate="2015-02-10T03:51:50.220" Score="0" Body="Version control systems (VCS) keep track of file or project history. Many of these systems can us the vi family of editors for tasks (such as editing commit messages), and many Vim plugins provide interaction with VCSs from within Vim itself." OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-02-10T06:07:37.930" LastActivityDate="2015-02-10T06:07:37.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="673" PostTypeId="2" ParentId="666" CreationDate="2015-02-10T07:01:44.993" Score="21" Body="&lt;p&gt;For the sake of completeness, there is also the &lt;a href=&quot;https://github.com/nathanaelkane/vim-indent-guides&quot; rel=&quot;noreferrer&quot;&gt;Indent Guides&lt;/a&gt; plugin, which shows the indentation levels by alternating the colors of white spaces. It requires version 7.2 or later. Since it uses the &lt;code&gt;tabstop&lt;/code&gt; and &lt;code&gt;shiftwidth&lt;/code&gt; variables, it will probably work for your indentation settings right away. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cAVSZ.png&quot; alt=&quot;Imgur&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the plugin is installed, you can simply use&lt;code&gt;:IndentGuidesEnable&lt;/code&gt; or &lt;code&gt;:IndentGuidesDisable&lt;/code&gt;. If you are using terminal vim, note that, according to the manual,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;At the moment Terminal Vim only has basic support. This means is that colors won't be automatically calculated based on your colorscheme. Instead, some preset colors are used depending on whether background is set to dark or light.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In order to change the colors of the guides for the screenshot, I used the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:indent_guides_auto_colors=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so the colors are not recalculated when buffers are swapped, and then set the colors using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi IndentGuidesEven ctermbg=238&#xA;hi IndentGuidesOdd ctermbg=236&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As with the other solutions presented, it only shows the indent guides on lines were there are spaces.&lt;/p&gt;&#xA;" OwnerUserId="259" LastActivityDate="2015-02-10T07:01:44.993" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="674" PostTypeId="2" ParentId="662" CreationDate="2015-02-10T10:07:02.237" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/fweep/vim-zsh-path-completion&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-zsh-path-completion&lt;/a&gt; purports to do exactly what you're asking for (the first part, at least), but I have never tried it. (I hadn't even heard of it until &lt;a href=&quot;https://vi.stackexchange.com/questions/662/zsh-like-tab-completion-of-partial-paths/674#comment820_662&quot;&gt;romainl linked to an SO answer by its author&lt;/a&gt;, although its documentation does also mention several limitations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to this, there are various fuzzy-file finders that achieve something similar for opening files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My favoured plugin for this is &lt;a href=&quot;http://kien.github.io/ctrlp.vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;CtrlP&lt;/a&gt;. When used for opening files, it searches for any files whose full paths contain the characters that you type in in the correct order&amp;mdash;you don't &lt;em&gt;have&lt;/em&gt; to type in parts of every component of the path (and all the path separators) as you have in your example, but it works perfectly well if you do. It also uses the same interface for opening recently used files and currently open buffers, and more besides.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, it maps &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt; in normal mode to open the CtrlP prompt. The prompt displays a list of files, which is narrowed down as you type in characters. You can press &lt;kbd&gt;Enter&lt;/kbd&gt; at any point to open the currently selected file, or use &lt;code&gt;&amp;lt;c-k&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt; to move the selection up and down through the list of currently-matched files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another popular alternative is &lt;a href=&quot;https://wincent.com/products/command-t&quot; rel=&quot;nofollow noreferrer&quot;&gt;Command-T&lt;/a&gt;, but I favour CtrlP because it's implemented in VimScript; Command-T has a Ruby component.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-11T10:11:09.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="675" PostTypeId="2" ParentId="662" CreationDate="2015-02-10T12:27:19.070" Score="6" Body="&lt;p&gt;I used to use CtrlP and other related plugins heavily earlier until I truly discovered the native powers of vim. Let me explain a few ways of doing this without requiring an external plugin :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:e&lt;/code&gt;, the nice thing about :e is you can do something like &lt;code&gt;:e /u*/s*/m*/m*/&amp;lt;Tab&amp;gt;&lt;/code&gt; and vim will expand that automatically for you to &lt;code&gt;:e /usr/share/man/man&lt;/code&gt;. That is much shorter and simple than what you posted, but an even better way is to do &lt;code&gt;:e /usr/**/man&amp;lt;Tab&amp;gt;&lt;/code&gt;, that way it will look recursively under &lt;code&gt;/usr&lt;/code&gt; and list out all matching paths, this can take time though depending on how large the set is, but in a project this works wonders because you can do something like &lt;code&gt;:e ap**/jav**/user&amp;lt;Tab&amp;gt;&lt;/code&gt; and it will complete all incomplete paths and give you a list of matching paths and works super great.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:b&lt;/code&gt;, To open existing buffers. This is really powerful because it accepts partials by default so you can just do something like &lt;code&gt;:b usr*man&amp;lt;Tab&amp;gt;&lt;/code&gt; and it will complete the file name if it's already been loaded in the buffer list. This is especially good because it's near instant and really fast. Also I use vim sessions heavily, with the help of &lt;a href=&quot;https://github.com/tpope/vim-obsession&quot; rel=&quot;nofollow&quot;&gt;tpope/vim-obsession&lt;/a&gt; and &lt;a href=&quot;https://github.com/dhruvasagar/vim-prosession&quot; rel=&quot;nofollow&quot;&gt;dhruvasagar/vim-prosession&lt;/a&gt;, that keeps all the files I open in the buffer list and they are available even if I exist vim and come back to it from the project directory.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="74" LastEditorUserId="74" LastEditDate="2015-02-10T17:56:41.033" LastActivityDate="2015-02-10T17:56:41.033" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="676" PostTypeId="1" CreationDate="2015-02-10T14:00:28.773" Score="28" ViewCount="5053" Body="&lt;p&gt;It is common to use either camelCase or snake_case to separate multiple words which form an identifier. It would be nice if the &quot;word&quot; movements (&lt;kbd&gt;b&lt;/kbd&gt;, &lt;kbd&gt;w&lt;/kbd&gt;, &lt;kbd&gt;e&lt;/kbd&gt;) would detect those inner-identifier boundaries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can this behavior be achieved? (Plugin/vimrc/...?)&lt;/p&gt;&#xA;" OwnerUserId="79" LastEditorUserId="51" LastEditDate="2015-02-10T15:47:59.003" LastActivityDate="2019-01-18T11:13:12.327" Title="How to make movements respect camelCase or snake_case?" Tags="|cursor-movement|letter-case|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="677" PostTypeId="2" ParentId="676" CreationDate="2015-02-10T17:37:30.983" Score="16" Body="&lt;p&gt;The plugin &lt;a href=&quot;https://github.com/bkad/CamelCaseMotion&quot; rel=&quot;noreferrer&quot;&gt;CamelCaseMotion&lt;/a&gt; does what you want. By default it maps to the keys &lt;code&gt;,w&lt;/code&gt;, &lt;code&gt;,b&lt;/code&gt;, &lt;code&gt;,e&lt;/code&gt; which are equivalent to normal &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;e&lt;/code&gt;. It works for both CamelCase and snake_case:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;camelCaseWord&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;d,w&lt;/code&gt; will remove &lt;code&gt;camel&lt;/code&gt;; using it again will remove &lt;code&gt;Case&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or with snake case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snake_case_word&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;d,w&lt;/code&gt; will remove &lt;code&gt;snake_&lt;/code&gt;, and on the second time it will remove &lt;code&gt;case_&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Inner&quot; motions (such as &lt;code&gt;diw&lt;/code&gt;) should also work as expected (as &lt;code&gt;di,w&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you prefer, you could also override the default &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, and &lt;code&gt;e&lt;/code&gt; with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; w &amp;lt;Plug&amp;gt;CamelCaseMotion_w&#xA;map &amp;lt;silent&amp;gt; b &amp;lt;Plug&amp;gt;CamelCaseMotion_b&#xA;map &amp;lt;silent&amp;gt; e &amp;lt;Plug&amp;gt;CamelCaseMotion_e&#xA;sunmap w&#xA;sunmap b&#xA;sunmap e&#xA;omap &amp;lt;silent&amp;gt; iw &amp;lt;Plug&amp;gt;CamelCaseMotion_iw&#xA;xmap &amp;lt;silent&amp;gt; iw &amp;lt;Plug&amp;gt;CamelCaseMotion_iw&#xA;omap &amp;lt;silent&amp;gt; ib &amp;lt;Plug&amp;gt;CamelCaseMotion_ib&#xA;xmap &amp;lt;silent&amp;gt; ib &amp;lt;Plug&amp;gt;CamelCaseMotion_ib&#xA;omap &amp;lt;silent&amp;gt; ie &amp;lt;Plug&amp;gt;CamelCaseMotion_ie&#xA;xmap &amp;lt;silent&amp;gt; ie &amp;lt;Plug&amp;gt;CamelCaseMotion_ie&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="362" LastEditorUserId="362" LastEditDate="2019-01-18T11:13:12.327" LastActivityDate="2019-01-18T11:13:12.327" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="678" PostTypeId="1" AcceptedAnswerId="679" CreationDate="2015-02-10T19:24:09.923" Score="60" ViewCount="27251" Body="&lt;p&gt;Suppose I start Vim to edit a new file in a directory that is not yet created:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim nonExisitingDirectory/newFile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will happily show me an empty buffer and I can start writing my new file. But when I want to write the file to disk I get this error: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E212: Can't Open file for writing.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I presume this is because the directory does not yet exists. Is there a way to force Vim into creating the directory for me? &lt;/p&gt;&#xA;" OwnerUserId="12" LastEditorUserId="205" LastEditDate="2016-05-27T02:51:46.777" LastActivityDate="2023-08-19T01:13:09.813" Title="How do I save a file in a directory that does not yet exist?" Tags="|save|autocmd|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="679" PostTypeId="2" ParentId="678" CreationDate="2015-02-10T19:43:15.907" Score="49" Body="&lt;p&gt;As far as I know there is no setting or some such to do this. But not all is lost, we can of course use the &lt;code&gt;BufWritePre&lt;/code&gt; autocommand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is executed before the buffer is written to the disk. So we can create the directory there if it doesn't exist yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup Mkdir&#xA;  autocmd!&#xA;  autocmd BufWritePre * call mkdir(expand(&quot;&amp;lt;afile&amp;gt;:p:h&quot;), &quot;p&quot;)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;afile&amp;gt;&lt;/code&gt; refers to the file we're trying to save; &lt;code&gt;:p&lt;/code&gt; is a modifier to expand it to the full pathname (rather than relative), and &lt;code&gt;:h&lt;/code&gt; removes the last path component (the file).&lt;/li&gt;&#xA;&lt;li&gt;We then call &lt;code&gt;mkdir()&lt;/code&gt; if required. We need the &lt;code&gt;p&lt;/code&gt; flag for &lt;code&gt;mkdir()&lt;/code&gt; to make all parents directories (i.e. in the case of &lt;code&gt;nonexistent/more_nonexisting/file&lt;/code&gt;), which also ensures it won't error out if the directory already exists.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could, of course, also run the &lt;code&gt;mkdir()&lt;/code&gt; command from the Vim commandline, or bind it to a keybind, ie:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;m :call mkdir(expand(&quot;%:p:h&quot;), &quot;p&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here I used &lt;code&gt;%&lt;/code&gt; instead of &lt;code&gt;&amp;lt;afile&amp;gt;&lt;/code&gt;, since that's only valid from within an autocommand (&lt;code&gt;%&lt;/code&gt; refers to the currently active buffer, which would not work with &lt;code&gt;:wa&lt;/code&gt; for example; &lt;code&gt;&amp;lt;afile&amp;gt;&lt;/code&gt; refers to the filename of the buffer that triggers the autocmd).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also ask for a confirmation before writing a directory if you want. See this question for more details: &lt;a href=&quot;https://vi.stackexchange.com/q/695/51&quot;&gt;How can I stop Vim from writing a file in BufWritePre autocommand?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The above snippet will create the directory on the first write (&lt;code&gt;:w&lt;/code&gt;). You could, if you wanted, also create the directory when you first open it (i.e. just after typing &lt;code&gt;vim ...&lt;/code&gt;) by using the &lt;code&gt;BufNewFile&lt;/code&gt; autocmd instead of &lt;code&gt;BufWritePre&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There is also a plugin called &lt;a href=&quot;https://github.com/DataWraith/auto_mkdir/blob/master/plugin/auto_mkdir.vim&quot; rel=&quot;noreferrer&quot;&gt;auto_mkdir&lt;/a&gt; which is effectively the same a the above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://travisjeffery.com/b/2011/11/saving-files-in-nonexistent-directories-with-vim/&quot; rel=&quot;noreferrer&quot;&gt;On this page&lt;/a&gt;&#xA;there is a slightly expanded snippet which also asks you if you want to create the directory first, which some may consider to be useful.   It also has converts the filename of the encoding before writing it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call mkdir(iconv(expand(&quot;%:p:h&quot;), &amp;amp;encoding, &amp;amp;termencoding), 'p')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if this is actually required though, but if you mix encodings a lot and get weird filenames, you could try it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I put all of the above in an &lt;a href=&quot;https://github.com/Carpetsmoker/auto_mkdir2.vim&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;auto_mkdir2.vim&lt;/code&gt; plugin&lt;/a&gt; for easier installation.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-05-07T11:42:54.063" LastActivityDate="2020-05-07T11:42:54.063" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="682" PostTypeId="1" CreationDate="2015-02-11T08:44:48.153" Score="1" ViewCount="77" Body="&lt;p&gt;I want to make Vim highlight the entire margin past column 79. I've seen other people's editors have a nice indicator bar or margin for maximum line length. What do I add to my config?&lt;/p&gt;&#xA;" OwnerUserId="465" LastEditorUserId="24" LastEditDate="2015-02-19T08:48:21.097" LastActivityDate="2015-02-19T08:48:21.097" Title="How do I make Vim highlight a margin?" Tags="|alignment|" AnswerCount="0" CommentCount="0" ClosedDate="2015-02-11T08:49:10.023" ContentLicense="CC BY-SA 3.0" />
  <row Id="683" PostTypeId="1" AcceptedAnswerId="687" CreationDate="2015-02-11T08:58:10.293" Score="4" ViewCount="2678" Body="&lt;p&gt;I am thinking on a similar solution, which Eclipse also does: during the editing, the editor tries to always hold in a &quot;well-indented&quot; format of the edited textual data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, it would happen very strong: the best were if anything breaking the well-formatting would be corrected on the spot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it somehow possible?&lt;/p&gt;&#xA;" OwnerUserId="28" LastEditorUserId="153" LastEditDate="2015-02-11T10:32:38.773" LastActivityDate="2015-02-11T11:03:14.540" Title="How to make auto-indent XML in vim?" Tags="|indentation|markup|filetype-xml|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="684" PostTypeId="1" AcceptedAnswerId="685" CreationDate="2015-02-11T10:13:37.627" Score="9" ViewCount="402" Body="&lt;p&gt;Vim spell check feature works great in most cases - it is even smart enough to distinguish code from literals and comments in most languages. However I have problems with HTML spell check:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &amp;lt;div title=&quot;text with mistaek #1&quot; data-text=&quot;text with mistaek #2&quot;&amp;gt;text with mistaek #3&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In example above only mistake inside &lt;code&gt;div&lt;/code&gt; is highlighted (#3). It would be great to have all relevant attributes checked - at least &lt;code&gt;title&lt;/code&gt; and &lt;code&gt;data-*&lt;/code&gt;, ideally - configurable list of attributes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it achievable via configuration or VimScript? Plugin will also do, but ideally it should be configurable for different &lt;code&gt;HTML&lt;/code&gt;-like files (for example, ASP .NET MVC &lt;code&gt;cshtml&lt;/code&gt; files).&lt;/p&gt;&#xA;" OwnerUserId="362" LastEditorUserId="51" LastEditDate="2015-02-11T12:51:55.990" LastActivityDate="2015-02-16T09:46:00.393" Title="How can I check spelling in HTML attributes?" Tags="|spell-checking|filetype-html|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="685" PostTypeId="2" ParentId="684" CreationDate="2015-02-11T10:36:58.767" Score="5" Body="&lt;p&gt;The syntax items within which Vim will highlight spelling mistakes are defined using the &lt;code&gt;@Spell&lt;/code&gt; and &lt;code&gt;@NoSpell&lt;/code&gt; clusters. See &lt;code&gt;:help spell-syntax&lt;/code&gt; (and the rest of the &lt;code&gt;:help spell&lt;/code&gt; and &lt;code&gt;:help syntax&lt;/code&gt; files) for full details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quick and dirty fix to get your desired result is to create a new file in your Vim config directory: &lt;code&gt;.vim/after/syntax/html.vim&lt;/code&gt; with the contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region htmlString contained start=+&quot;+ end=+&quot;+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc,@Spell&#xA;syn region htmlString contained start=+'+ end=+'+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc,@Spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These lines define the syntax highlighting for HTML attributes, and were copied from the html.vim file that is included within Vim's standard syntax files. I then added the &lt;code&gt;@Spell&lt;/code&gt; cluster to the &lt;code&gt;contains&lt;/code&gt; field in order to enable spell-checking within each syntax item.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to apply this only to &quot;title&quot; and &quot;data-*&quot; attributes requires fine-tuning the regular expression used for matching the items, and slightly more extensive editing of the way HTML highlighting works. Here's a solution that works for &quot;title&quot; attributes only:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region htmlStringSpell contained start=+title=[&quot;']+hs=s+6 end=+[&quot;']+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc,@Spell containedin=htmlTag,ScriptTag&#xA;hi def link htmlStringSpell String&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The regular expression now includes the name of the &lt;code&gt;title&lt;/code&gt; attribute, and an offset so that this part of the syntax item is not included in the highlighting. (See &lt;code&gt;:help syn-pattern-offset&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;The syntax item now has its own name, and therefore needs to (i) be &lt;code&gt;containedin&lt;/code&gt; all the syntax items that htmlStrings are contained in via their respective &lt;code&gt;contains&lt;/code&gt; settings. (ii) have its own highlighting applied.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2015-02-16T09:46:00.393" LastActivityDate="2015-02-16T09:46:00.393" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="686" PostTypeId="2" ParentId="684" CreationDate="2015-02-11T10:39:59.797" Score="3" Body="&lt;p&gt;From &lt;code&gt;/usr/share/vim/vim74/syntax/html.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region  htmlString   contained start=+&quot;+ end=+&quot;+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc&#xA;syn region  htmlString   contained start=+'+ end=+'+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To add spelling support, we need to add the &lt;code&gt;@Spell&lt;/code&gt; keyword (see &lt;code&gt;:help spell-syntax&lt;/code&gt;) like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region  htmlString   contained start=+&quot;+ end=+&quot;+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc,@Spell&#xA;syn region  htmlString   contained start=+'+ end=+'+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc,@Spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to put this in &lt;code&gt;~/.vim/after/syntax/html.vim&lt;/code&gt; so it will override the default syntax rules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus tip:&lt;br&gt;&#xA;The first line is for attributes in double-quoted strings (&lt;code&gt;attr=&quot;value&quot;&lt;/code&gt;), and the&#xA;second one if for single-quoted strings (&lt;code&gt;attr='value'&lt;/code&gt;). You can also override&#xA;just &lt;em&gt;one&lt;/em&gt; of these, so you can choose whether you have spell checking.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-11T10:39:59.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="687" PostTypeId="2" ParentId="683" CreationDate="2015-02-11T11:03:14.540" Score="3" Body="&lt;p&gt;I commented out my entire .vimrc file, then added a few indentation related things. Using the process of elimination, I landed on the following line being solely responsible getting my XML indentation to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this only worked when loaded from the .vimrc file. Manually typing it in had no effect for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;code&gt;:h filetype-indent-on&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can enable loading the indent file for specific file types with:&#xA;         :filetype indent on&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If filetype detection was not switched on yet, it will be as well.&#xA;  This actually loads the file &quot;indent.vim&quot; in 'runtimepath'.&#xA;  The result is that when a file is edited its indent file is loaded (if there&#xA;  is one for the detected filetype). |indent-expression|&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you have &lt;code&gt;filetype indent on&lt;/code&gt; enabled in your .vimrc and don't have indentation, you're probably missing the indentation definition file.&lt;/p&gt;&#xA;" OwnerUserId="306" LastActivityDate="2015-02-11T11:03:14.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="688" PostTypeId="1" AcceptedAnswerId="690" CreationDate="2015-02-11T11:09:42.367" Score="27" ViewCount="12636" Body="&lt;p&gt;I have a text file like this (using gVim on Windows)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;foo bar baz quux &#xA;corge grault garply &#xA;waldo fred plugh &#xA;[...150 more lines...]&#xA;xyzzy thud&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I want to add a number to each line in the file. Not using &lt;code&gt;:set number&lt;/code&gt;, but to add the number as text preceding each line, as follows, so the number is part of the file.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1. foo bar baz quux &#xA;2. corge grault garply &#xA;3. waldo fred plugh &#xA;[...~150 more lines...]&#xA;155. xyzzy thud&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There are some relevant answers on &lt;a href=&quot;http://stackoverflow.com/questions/252766/add-line-numbers-to-source-code-in-vim&quot;&gt;this StackOverflow question&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="398" LastEditorUserId="10604" LastEditDate="2021-03-06T17:34:12.963" LastActivityDate="2021-03-06T17:34:12.963" Title="How to add permanent line numbers to a file?" Tags="|text-generation|" AnswerCount="8" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="689" PostTypeId="2" ParentId="574" CreationDate="2015-02-11T11:18:40.500" Score="8" Body="&lt;p&gt;In addition to the colorcolumn option, you can tell vim to automatically push you down to the next line by putting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into your .vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the docs (&lt;code&gt;:h textwidth&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Maximum width of text that is being inserted.  A longer line will be&#xA;  broken after white space to get this width.  A zero value disables&#xA;  this.  'textwidth' is set to 0 when the 'paste' option is set.  When&#xA;  'textwidth' is zero, 'wrapmargin' may be used.  See also&#xA;  'formatoptions' and ins-textwidth.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When 'formatexpr' is set it will be used to break the line.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;NOTE: This option is set to 0 when 'compatible' is set.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="306" LastActivityDate="2015-02-11T11:18:40.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="690" PostTypeId="2" ParentId="688" CreationDate="2015-02-11T11:21:24.910" Score="43" Body="&lt;p&gt;In pure Vim fashion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^/\=line('.').&quot;. &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^/            &quot; the substitution will be applied to the beginning of every line&#xA;\=                &quot; the rest of the replacement part is an expression&#xA;line('.').&quot;. &quot;    &quot; the expression returns the current line number concatenated with a dot and a space&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help \=&lt;/code&gt; and &lt;code&gt;:help line()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using an expression in the replacement part is very powerful and FWIW a pretty good point of entry to vimscript.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-02-12T10:24:35.383" LastActivityDate="2015-02-12T10:24:35.383" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="691" PostTypeId="2" ParentId="688" CreationDate="2015-02-11T11:29:37.970" Score="11" Body="&lt;p&gt;One nice thing about Vim macros is that they can recurse (they can invoke themselves):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Clear out register q: &lt;code&gt;qqq&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Add the number to the first line: &lt;code&gt;ggI1.&lt;/code&gt; (don't forget the space!)&lt;/li&gt;&#xA;&lt;li&gt;Move back to start of line and start recording a macro: &lt;code&gt;0qq&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Copy the number: &lt;code&gt;yW&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move down a line and paste the number: &lt;code&gt;+P&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move back to the start of the line and increment the number: &lt;code&gt;0&amp;lt;c-a&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move back to the start of the line (so the macro doesn't break when it gets to double figures!): &lt;code&gt;0&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Call the macro once, to make it recursive. At this point, there is still nothing in register q, so nothing will happen: &lt;code&gt;@q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Save the macro: &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Call the macro one more time, and watch the sparks fly!: &lt;code&gt;@@&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The macro will then continue invoking itself until it reaches the end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the recursive macro trick for lots of other similar problems, so it's a good one to be aware of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to use a recursive macro for some reason, you can omit steps 1 and 8, and use a &lt;em&gt;count&lt;/em&gt; to run the macro multiple times, e.g. &lt;code&gt;100@q&lt;/code&gt; will run macro &lt;code&gt;q&lt;/code&gt; 100 times.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2015-02-11T15:53:56.950" LastActivityDate="2015-02-11T15:53:56.950" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="692" PostTypeId="2" ParentId="613" CreationDate="2015-02-11T11:32:13.027" Score="14" Body="&lt;p&gt;Let us not forget the great &amp;amp; mighty &lt;a href=&quot;https://github.com/gmarik/Vundle.vim&quot;&gt;Vundle&lt;/a&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vundle is a complete plugin manager, with functionality for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Searching for plugins (using &lt;code&gt;:PluginSearch&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Installing plugins (using &lt;code&gt;:PluginInstall&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Updating plugins (using &lt;code&gt;:PluginUpdate&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Managing the plugin load path in the .vimrc (simply comment out plugin entries you don't want to load)&lt;/li&gt;&#xA;&lt;li&gt;Removing plugins you no longer want (using &lt;code&gt;:PluginClean&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As you can see, it's a lot like the vim-plug manager mentioned by Carpetsmoker. I don't know which one came first, but their APIs look very similar to me, as does the &lt;a href=&quot;https://github.com/gmarik/Vundle.vim#quick-start&quot;&gt;setup process&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="306" LastActivityDate="2015-02-11T11:32:13.027" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="693" PostTypeId="2" ParentId="120" CreationDate="2015-02-11T12:27:24.240" Score="9" Body="&lt;p&gt;You may use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4841&quot; rel=&quot;nofollow noreferrer&quot;&gt;JumpToVerticalOccurrence&lt;/a&gt; plugin (default mapped to &lt;kbd&gt;]|&lt;/kbd&gt; and &lt;kbd&gt;[|&lt;/kbd&gt;). There are few others like &lt;kbd&gt;]V{char}&lt;/kbd&gt; which works like &lt;kbd&gt;f&lt;/kbd&gt;, but vertically. You can of course remap them as required.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you don't want to use plugins, you may try to use &lt;code&gt;:search&lt;/code&gt; with &lt;code&gt;virtcol(.)&lt;/code&gt;, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call search('\%' . virtcol('.') . 'v\S', 'bW')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;virtcol('.')&lt;/code&gt; gives you the current column,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\S&lt;/code&gt; stands for non-whitespace&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;bW&lt;/code&gt; is for backward search&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Check &lt;code&gt;:help search&lt;/code&gt; to learn more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it easier to use, you can map it, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;C-k&amp;gt; :call search('\%' . virtcol('.') . 'v\S', 'bW')&amp;lt;CR&amp;gt;&#xA;:map &amp;lt;C-j&amp;gt; :call search('\%' . virtcol('.') . 'v\S', 'W')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if your code contains brackets, use &lt;kbd&gt;%&lt;/kbd&gt; to jump between matching them (e.g. &lt;code&gt;{&lt;/code&gt;, &lt;code&gt;}&lt;/code&gt;, &lt;code&gt;[&lt;/code&gt;, &lt;code&gt;]&lt;/code&gt;, etc.) or use whole paragraph jumps (&lt;kbd&gt;{&lt;/kbd&gt;, &lt;kbd&gt;}&lt;/kbd&gt; with &lt;kbd&gt;Shift&lt;/kbd&gt; if necessary).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Links/sources:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/20882722/move-to-the-next-row-which-has-non-white-space-character-in-the-same-column-in-v&quot;&gt;Move to the next row which has non-white space character in the same column in vim?&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-04-19T11:02:55.680" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="694" PostTypeId="2" ParentId="119" CreationDate="2015-02-11T12:34:46.977" Score="24" Body="&lt;p&gt;If you are already in Vim, you can use the &lt;code&gt;:argdo&lt;/code&gt; or &lt;code&gt;:bufdo&lt;/code&gt; commands to execute a command on every item in the argument list or buffer list, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. to run a &lt;code&gt;:&lt;/code&gt; command on every file in the argument list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdo StripWhitespace&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or to invoke a function from every file in the buffer list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo call StripWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or to run macro &lt;code&gt;q&lt;/code&gt; on every file in the arguments list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdo normal @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then save all changed buffers with &lt;code&gt;:wall&lt;/code&gt;, or save all and quit Vim with &lt;code&gt;:wqall&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to write the files as you go along, you can add in a call to &lt;code&gt;:update&lt;/code&gt;, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdo s/foo/bar/ge | update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are various ways you can get the files into Vim in the first place, including:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Supply parameters to the vim command line: &lt;code&gt;vim *&lt;/code&gt; (this adds all the files to the argument list),&lt;/li&gt;&#xA;&lt;li&gt;Use the &lt;code&gt;:args&lt;/code&gt; command (which supports wildcards and backtick expressions) to populate the argument list, or the &lt;code&gt;:argadd&lt;/code&gt; command to add files to it,&lt;/li&gt;&#xA;&lt;li&gt;Just open them all manually with &lt;code&gt;:e&lt;/code&gt;, &lt;code&gt;:Ex&lt;/code&gt;, or a file-opening plugin.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2015-03-04T07:52:13.803" LastActivityDate="2015-03-04T07:52:13.803" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="695" PostTypeId="1" AcceptedAnswerId="697" CreationDate="2015-02-11T13:15:56.180" Score="10" ViewCount="852" Body="&lt;p&gt;I'm trying to improve the code from &lt;a href=&quot;https://vi.stackexchange.com/questions/678/how-do-i-save-a-file-in-a-directory-that-does-not-yet-exist/679#679&quot;&gt;this answer&lt;/a&gt; to ask for confirmation before creating the missing directory, this is what I write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CreateDirectoryAskConfirmation(path)&#xA;    if !isdirectory(a:path)&#xA;        echohl Question&#xA;        echo &quot;Create directory &quot; . a:path . &quot;?&quot;&#xA;        echohl None&#xA;&#xA;        let response = nr2char(getchar())&#xA;        if response ==? &quot;y&quot;&#xA;            call mkdir(a:path, &quot;p&quot;)&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&#xA;autocmd BufWritePre * call CreateDirectoryAskConfirmation(expand(&quot;&amp;lt;afile&amp;gt;:p:h&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One thing I'm missing: when I don't press &lt;code&gt;y&lt;/code&gt; at the prompt I'd like Vim to abort the write so I don't get the error &lt;code&gt;E212: Can't open file for writing&lt;/code&gt; and I don't need to hit another key to make the error message disappear. There is a way to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="13" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-03-06T08:00:51.433" Title="How can I stop Vim from writing a file without throwing an error?" Tags="|save|autocmd|error|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="697" PostTypeId="2" ParentId="695" CreationDate="2015-02-11T13:39:31.693" Score="9" Body="&lt;p&gt;Instead of using the &lt;code&gt;BufWritePre&lt;/code&gt; autocmd, you can use the &lt;code&gt;BufWriteCmd&lt;/code&gt;&#xA;autocmd, from &lt;code&gt;:help BufWriteCmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Should do the writing of the file and reset 'modified' if successful, unless&#xA;  '+' is in 'cpo' and writing to another file cpo-+.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;We can just call &lt;code&gt;:write&lt;/code&gt; from the autocmd. This will take care of setting &lt;code&gt;modified&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the logic would then be modified to call &lt;code&gt;:write&lt;/code&gt; when the directory already exist, and call &lt;code&gt;:write&lt;/code&gt; after creating the directory if it doesn't exist yet. If you press &lt;code&gt;n&lt;/code&gt;, we do nothing. This will leave the buffer as-is, and won't re-set &lt;code&gt;modified&lt;/code&gt;, so &lt;code&gt;:q&lt;/code&gt; will still give you a &lt;code&gt;E37: No write since last change&lt;/code&gt; error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CreateDirectoryAskConfirmation(path, dir)&#xA;    silent doautocmd BufWritePre&#xA;&#xA;    &quot; Directory exists, :write and return&#xA;    if isdirectory(a:dir)&#xA;        execute 'write ' . a:path&#xA;        silent doautocmd BufWritePost&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; Ask for confirmation to create this directory&#xA;    echohl Question&#xA;    echo &quot;Create directory `&quot; . a:dir . &quot;' [y/N]?&quot;&#xA;    echohl None&#xA;&#xA;    let response = nr2char(getchar())&#xA;    &quot; mkdir() and :write if we want to make a directory&#xA;    if response ==? &quot;y&quot;&#xA;        call mkdir(a:dir, &quot;p&quot;)&#xA;        execute 'write ' . a:path&#xA;        silent doautocmd BufWritePost&#xA;    endif&#xA;endfunction&#xA;&#xA;autocmd BufWriteCmd * call CreateDirectoryAskConfirmation(expand(&quot;&amp;lt;amatch&amp;gt;:p&quot;), expand(&quot;&amp;lt;amatch&amp;gt;:p:h&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-13T14:15:07.923" LastActivityDate="2015-02-13T14:15:07.923" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="698" PostTypeId="1" AcceptedAnswerId="720" CreationDate="2015-02-11T13:40:27.517" Score="6" ViewCount="564" Body="&lt;p&gt;In my .vimrc I have &lt;code&gt;set backspace=eol,start&lt;/code&gt;, which allows me to backspace over line breaks and the start of what I wrote since I entered Insert mode. This does not allow me to backspace over autoindents though. For that one can add &lt;code&gt;indent&lt;/code&gt; to the &lt;code&gt;backspace&lt;/code&gt; list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If one doesn't use &lt;code&gt;indent&lt;/code&gt; they may be unable to delete an empty line they just added, because if an autoindent was created it cannot be deleted and therefore the line break cannot be reached and deleted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, when using &lt;code&gt;indent&lt;/code&gt; the backspace key deletes only one tab at a time (not sure what it does when indenting with spaces). This can be annoying if you are writing say a deep nested loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is: while in Insert mode, is there a way to delete all the autoindents in one line by using the backspace key only once?&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="356" LastEditDate="2020-02-09T11:16:34.457" LastActivityDate="2020-02-09T11:16:34.457" Title="Deleting groups of autoindents in Insert mode" Tags="|indentation|insert-mode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="699" PostTypeId="2" ParentId="698" CreationDate="2015-02-11T14:15:26.907" Score="5" Body="&lt;p&gt;You can do &lt;code&gt;0&amp;lt;C-d&amp;gt;&lt;/code&gt; to delete all indent in the current line in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-- edit --&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The right way to get help for &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; in insert mode is &lt;code&gt;:help i_ctrl-d&lt;/code&gt;. The &lt;code&gt;i_&lt;/code&gt; prefix indicates insert mode so you can also use &lt;code&gt;v_&lt;/code&gt; for visual mode or &lt;code&gt;c_&lt;/code&gt; for command-line mode. &lt;code&gt;0&amp;lt;C-d&amp;gt;&lt;/code&gt; is a few lines below &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-02-11T21:32:46.403" LastActivityDate="2015-02-11T21:32:46.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="700" PostTypeId="2" ParentId="688" CreationDate="2015-02-11T14:25:41.013" Score="4" Body="&lt;p&gt;I think the chosen answer is the best, but in the sprit of variety, I'll offer an alternative using an external program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!cat -n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will filter your entire buffer (as denoted by &lt;code&gt;%&lt;/code&gt;) through the external program, &lt;code&gt;cat&lt;/code&gt;, where the &lt;code&gt;-n&lt;/code&gt; flag prepends each line of input with a line number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This, of course, requires that you have &lt;code&gt;cat&lt;/code&gt; installed, which is true for (probably) all Unix-like systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out &lt;code&gt;:help :range!&lt;/code&gt; for more details on filtering through external programs.&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="64" LastEditDate="2015-02-11T14:49:22.630" LastActivityDate="2015-02-11T14:49:22.630" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="701" PostTypeId="1" AcceptedAnswerId="702" CreationDate="2015-02-11T14:28:06.023" Score="6" ViewCount="1304" Body="&lt;p&gt;Occasionally I have a stray forgotten buffer in which I ran &lt;code&gt;:diffthis&lt;/code&gt;. Later when I run &lt;code&gt;:diffthis&lt;/code&gt; on some unrelated buffer that second buffer is immediately and unintentionally highlighted with the diff. At this point I don't know which buffer is the first in which &lt;code&gt;:diffthis&lt;/code&gt; was run and I don't know how to &lt;code&gt;:diffoff&lt;/code&gt; on that buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I solve this? Can I simply &lt;code&gt;:diffoff&lt;/code&gt; on all buffers, even buffers not in any window?&lt;/p&gt;&#xA;" OwnerUserId="268" LastEditorUserId="24" LastEditDate="2015-02-12T00:08:05.260" LastActivityDate="2015-02-12T00:08:05.260" Title="diffoff on all buffers" Tags="|buffers|vimdiff|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="702" PostTypeId="2" ParentId="701" CreationDate="2015-02-11T14:31:05.967" Score="9" Body="&lt;p&gt;You can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo diffoff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Abufdo&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:bufdo&lt;/code&gt;&lt;/a&gt; command runs a given command on all buffers. It works by cycling through all buffers and executing the command, so you will end up on the last buffer.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Caveat&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;From the help:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: While this command is executing, the Syntax autocommand event is disabled by adding it to 'eventignore'.  This considerably speeds up editing each buffer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This usually has the undesirable side-effect that syntax highlighting will be turned off in many buffers. When you switch to a buffer affected by this, you can simply run &lt;code&gt;:edit&lt;/code&gt; (or &lt;code&gt;:e&lt;/code&gt; for short) to trigger the Syntax autocommand that normally gets triggered.&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="205" LastEditDate="2015-02-11T20:47:32.620" LastActivityDate="2015-02-11T20:47:32.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="703" PostTypeId="2" ParentId="688" CreationDate="2015-02-11T14:32:45.897" Score="5" Body="&lt;p&gt;A modification of &lt;a href=&quot;https://vi.stackexchange.com/a/690/51&quot;&gt;romainl's answer&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(\d\+\. \)\?/\=line('.').&quot;. &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will not just &lt;em&gt;add&lt;/em&gt; line numbers, it will also &lt;em&gt;replace&lt;/em&gt; exiting line numbers it they're already there. Of, if you've inserted a line mid-way, it will renumber everything as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works by replacing any number followed by a . and a space at the start of the line with a new number. This will obviously break if you have a line that already starts with this pattern, so use with thought.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The added part:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; - Start of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(&lt;/code&gt; - Start new subgroup&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\d\+&lt;/code&gt; - Match a digit once or more&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\.&lt;/code&gt; &lt;code&gt;&lt;/code&gt; - Match a dot (&lt;code&gt;.&lt;/code&gt;) and a space &lt;code&gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\)&lt;/code&gt; - End subgroup&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\?&lt;/code&gt; - Make the group optional, so that it works as before if there's no number on this line yet.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Bonus hint:&lt;br&gt;&#xA;To &lt;em&gt;remove&lt;/em&gt; the line numbers, you can use the same pattern with the repalce part empty:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(\d\+\. \)\?//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-11T14:32:45.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="704" PostTypeId="1" AcceptedAnswerId="705" CreationDate="2015-02-11T15:33:39.510" Score="26" ViewCount="28861" Body="&lt;p&gt;I have set &lt;code&gt;expandtab&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; file to convert &lt;code&gt;tab&lt;/code&gt; to multiple &lt;code&gt;space&lt;/code&gt; characters. However some files (like Makefile) need actual the &lt;code&gt;tab&lt;/code&gt; character inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an easy way to force the insertion the &lt;code&gt;tab&lt;/code&gt; while I am typing?&lt;/p&gt;&#xA;" OwnerUserId="464" LastActivityDate="2015-03-04T16:18:57.487" Title="Insert tabs in INSERT mode when expandtab is set" Tags="|insert-mode|tab-characters|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="705" PostTypeId="2" ParentId="704" CreationDate="2015-02-11T15:34:32.530" Score="46" Body="&lt;p&gt;Instead of just pressing &lt;kbd&gt;Tab&lt;/kbd&gt;, first press &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; and then press &lt;kbd&gt;Tab&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be used to insert a variety of special chars. See &lt;code&gt;:help i_CTRL-V&lt;/code&gt; for details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl-V&lt;/kbd&gt; also works in command-line mode (&lt;code&gt;:help c-CTRL-V&lt;/code&gt;), and even in some other programs entirely. (e.g. bash, mutt.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; mapped to something else, try &lt;kbd&gt;Ctrl-Q&lt;/kbd&gt;. This has the same effect in Vim as &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;, but some terminals use it for control flow, in which case Vim won't ever see it.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2015-03-04T16:18:57.487" LastActivityDate="2015-03-04T16:18:57.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="706" PostTypeId="2" ParentId="438" CreationDate="2015-02-11T17:26:11.780" Score="4" Body="&lt;p&gt;@Carpetsmoker's answer definitely satisfies the &quot;most relevant&quot; criteria, because the completions will almost always contain what you're looking for. However, there's also the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/helphelp.html#:helpgrep&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:helpgrep&lt;/code&gt;&lt;/a&gt; command, which works just like the &lt;code&gt;:grep&lt;/code&gt; command but searches the text of all the help files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can browse through the results with &lt;code&gt;:cnext&lt;/code&gt; or see all the results with &lt;code&gt;:cwindow&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="126" LastActivityDate="2015-02-11T17:26:11.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="707" PostTypeId="2" ParentId="588" CreationDate="2015-02-11T17:45:28.060" Score="34" Body="&lt;p&gt;I found &lt;a href=&quot;http://mlterm.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;mlterm&lt;/code&gt;&lt;/a&gt;, which supports this. Aside from Emacs' built-in terminal (M-x term) this is the &lt;em&gt;only&lt;/em&gt; terminal I've found that supports this (I've tried about 15-20 different ones).&lt;br&gt;&#xA;I've found that &lt;code&gt;mlterm&lt;/code&gt; works better than Emacs due to the sceen ratio settings, and you also avoid having to run Vim inside an Emacs session (I'm not even sure that is legally allowed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screenshot (it looks ugly unless you open it &lt;a href=&quot;https://i.stack.imgur.com/6Vj4t.png&quot; rel=&quot;noreferrer&quot;&gt;full size&lt;/a&gt; due to scaling in the browser): &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6Vj4t.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does require some configure love, though. After starting, press &lt;kbd&gt;Ctrl&lt;/kbd&gt; + middle click&#xA;anywhere, this will open the configure screen. I set these options&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Font tab:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Check &quot;Anti-alias&quot;&lt;/li&gt;&#xA;&lt;li&gt;Check &quot;Variable column width&quot;; this is the &quot;key feature&quot; missing from most other terminal&#xA;emulators&lt;/li&gt;&#xA;&lt;li&gt;Set font to &quot;DejaVu Sans Book 16&quot; (or whatever else you prefer)&lt;/li&gt;&#xA;&lt;li&gt;Set &quot;screen ratio against font size&quot; width to 60; this lies to programs about the width of the&#xA;terminal, of you don't do this, you're only using ~50% of the screen size. The best value for this&#xA;depends on the font used, so experiment a bit...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The Right-click configure screen seems a bit flaky, I also edited my &lt;code&gt;~/.mlterm/vaafont&lt;/code&gt; since this&#xA;wasn't updated:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISO10646_UCS4_1 = 22,DejaVu Sans 18;21,DejaVu Sans 16;16,DejaVu Sans 16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And my &lt;code&gt;~/.mlterm/main&lt;/code&gt; (these are the settings I set above, plus some personal&#xA;preferences):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;type_engine = xft&#xA;bel_mode = none&#xA;scrollbar_mode = none&#xA;fontsize = 22&#xA;use_anti_alias = true&#xA;use_variable_column_width = true&#xA;line_space = 5&#xA;use_multi_column_char = true&#xA;col_size_of_width_a = 1&#xA;screen_width_ratio = 50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are some artefacts, which are to be expected, but writing emails or posts such as this, it&#xA;seems to work quite well!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created an alias in my shell for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias pvim mlterm -e vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also created a little function to remove most UI chrome:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! WriteMode()&#xA;    &quot; Disable a lot of stuff&#xA;    setlocal nocursorline nocursorcolumn statusline= showtabline=0 laststatus=0 noruler&#xA;&#xA;    &quot; Hack a right margin with number&#xA;    setlocal number&#xA;    setlocal numberwidth=3&#xA;&#xA;    &quot; White text, so it's 'invisible'&#xA;    highlight LineNr ctermfg=15&#xA;    &quot; If you're using a black background:&#xA;    &quot; highlight LineNr ctermfg=1&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's also &lt;a href=&quot;https://github.com/junegunn/goyo.vim&quot; rel=&quot;noreferrer&quot;&gt;goyo.vim&lt;/a&gt; which goes roughly the same, but that&#xA;didn't work very well for me (too much mucking about with margins). YMMV though.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-11T21:04:44.770" LastActivityDate="2015-02-11T21:04:44.770" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="708" PostTypeId="2" ParentId="704" CreationDate="2015-02-11T18:33:46.753" Score="25" Body="&lt;p&gt;Rather than change your behavior (which is error prone).&lt;br&gt;&#xA;I would set up vim to behave differently for this file type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in my normal editing I expand tabs. But specifically for &lt;code&gt;make&lt;/code&gt; files I set the &lt;code&gt;noexpandtab&lt;/code&gt; so that tabs are retained.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following to your ~/.vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Normal action&#xA;set expandtab&#xA;&#xA;if has(&quot;autocmd&quot;)&#xA;&#xA;    &quot; If the filetype is Makefile then we need to use tabs&#xA;    &quot; So do not expand tabs into space.&#xA;    autocmd FileType make   set noexpandtab&#xA;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="383" LastActivityDate="2015-02-11T18:33:46.753" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="710" PostTypeId="1" AcceptedAnswerId="711" CreationDate="2015-02-11T20:12:59.770" Score="4" ViewCount="277" Body="&lt;p&gt;When I yank a line with &lt;code&gt;y&lt;/code&gt; and paste it with &lt;code&gt;p&lt;/code&gt;, it's okay. But when I need to delete a line with &lt;code&gt;dd&lt;/code&gt; before pasting my yank buffer changes. Can I still paste my yanked line? Is there a way to do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerDisplayName="user473" LastEditorUserId="51" LastEditDate="2015-02-11T20:15:35.820" LastActivityDate="2015-02-11T21:42:56.807" Title="Can I paste a yanked line even if I delete a line?" Tags="|cut-copy-paste|register|" AnswerCount="2" CommentCount="0" ClosedDate="2015-02-11T22:20:48.613" ContentLicense="CC BY-SA 3.0" />
  <row Id="711" PostTypeId="2" ParentId="710" CreationDate="2015-02-11T20:29:37.860" Score="6" Body="&lt;p&gt;One way could be to overwrite that line instead of deleting it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Copy the content&lt;/li&gt;&#xA;&lt;li&gt;Move to line to be deleted and press &lt;code&gt;V&lt;/code&gt; to select the whole line (or use &lt;code&gt;v&lt;/code&gt; and manually select whichever region you need)&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;p&lt;/code&gt; to paste.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-02-11T20:29:37.860" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="712" PostTypeId="5" CreationDate="2015-02-11T20:50:32.673" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-11T20:50:32.673" LastActivityDate="2015-02-11T20:50:32.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="713" PostTypeId="4" CreationDate="2015-02-11T20:50:32.673" Score="0" Body="FreeBSD is a UNIX-like operating system with roots in the original UNIX from Bell labs. Use this tag only for questions that are specific to FreeBSD." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-11T20:50:32.673" LastActivityDate="2015-02-11T20:50:32.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="714" PostTypeId="2" ParentId="710" CreationDate="2015-02-11T21:42:56.807" Score="5" Body="&lt;p&gt;Yanked text is kept in register &lt;code&gt;&quot;0&lt;/code&gt; until the next explicit yank. This means that you can cut as many lines as you want, &lt;code&gt;&quot;0p&lt;/code&gt; will still put the same text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to use the black hole register, &lt;code&gt;&quot;_&lt;/code&gt; to actually delete text instead of the default &quot;cut&quot; behavior. This will preserve the unnamed register and let you &lt;code&gt;p&lt;/code&gt; from it as much as you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help registers&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-02-11T21:42:56.807" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="715" PostTypeId="2" ParentId="627" CreationDate="2015-02-11T21:59:25.227" Score="6" Body="&lt;p&gt;Here's the code that I extracted from &lt;code&gt;vim-startify&lt;/code&gt;; the key parts are creating a new buffer on the &lt;code&gt;VimEnter&lt;/code&gt; autocmd, putting some text in that, and then mapping the &lt;code&gt;i&lt;/code&gt; to start a new buffer and then go to insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I put the below in a &lt;a href=&quot;https://github.com/Carpetsmoker/startscreen.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;little plugin&lt;/a&gt; which adds some settings and such, but the basic concept is exactly the same.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Start()&#xA;    &quot; Don't run if: we have commandline arguments, we don't have an empty&#xA;    &quot; buffer, if we've not invoked as vim or gvim, or if we'e start in insert mode&#xA;    if argc() || line2byte('$') != -1 || v:progname !~? '^[-gmnq]\=vim\=x\=\%[\.exe]$' || &amp;amp;insertmode&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; Start a new buffer ...&#xA;    enew&#xA;&#xA;    &quot; ... and set some options for it&#xA;    setlocal&#xA;        \ bufhidden=wipe&#xA;        \ buftype=nofile&#xA;        \ nobuflisted&#xA;        \ nocursorcolumn&#xA;        \ nocursorline&#xA;        \ nolist&#xA;        \ nonumber&#xA;        \ noswapfile&#xA;        \ norelativenumber&#xA;&#xA;    &quot; Now we can just write to the buffer, whatever you want.&#xA;    call append('$', &quot;&quot;)&#xA;    for line in split(system('fortune -a'), '\n')&#xA;        call append('$', '        ' . l:line)&#xA;    endfor&#xA;&#xA;    &quot; No modifications to this buffer&#xA;    setlocal nomodifiable nomodified&#xA;&#xA;    &quot; When we go to insert mode start a new buffer, and start insert&#xA;    nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt; e :enew&amp;lt;CR&amp;gt;&#xA;    nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt; i :enew &amp;lt;bar&amp;gt; startinsert&amp;lt;CR&amp;gt;&#xA;    nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt; o :enew &amp;lt;bar&amp;gt; startinsert&amp;lt;CR&amp;gt;&#xA;endfun&#xA;&#xA;&quot; Run after &quot;doing all the startup stuff&quot;&#xA;autocmd VimEnter * call Start()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2018-01-03T20:48:41.097" LastActivityDate="2018-01-03T20:48:41.097" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="716" PostTypeId="1" AcceptedAnswerId="717" CreationDate="2015-02-11T22:10:29.620" Score="6" ViewCount="4021" Body="&lt;p&gt;In NERDTree, if I select a file node and hit &lt;kbd&gt;o&lt;/kbd&gt;, it opens the file in a window in the current tab. However, if that particular file is already open in another tab, NERDTree switches to that tab. I find this quite disorienting in my workflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an option to tell NERDTree to stay in the current tab?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update: I opened a pull request on the NERDTree repo at Github to add an option to prevent this tab-switching: &lt;a href=&quot;https://github.com/scrooloose/nerdtree/pull/417&quot; rel=&quot;nofollow&quot;&gt;https://github.com/scrooloose/nerdtree/pull/417&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="333" LastEditorUserId="333" LastEditDate="2015-04-23T20:53:17.447" LastActivityDate="2017-09-06T13:37:52.707" Title="Prevent NERDTree from switching tabs when opening a file node?" Tags="|load|tabbed-user-interface|plugin-nerdtree|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="717" PostTypeId="2" ParentId="716" CreationDate="2015-02-11T22:23:17.160" Score="4" Body="&lt;p&gt;There is currently no way to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the source code (ref. &lt;a href=&quot;https://github.com/scrooloose/nerdtree/blob/c2dd750860288b8cf81f6bd5ff49dc5ee76a34d5/lib/nerdtree/opener.vim#L238&quot; rel=&quot;nofollow&quot;&gt;lib/nerdtree/opener.vim line 238&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Opener._openFile()&#xA;    if self._reuse &amp;amp;&amp;amp; self._reuseWindow()&#xA;        return&#xA;    endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the &lt;code&gt;_reuseWindow()&lt;/code&gt; function (ref. &lt;a href=&quot;https://github.com/scrooloose/nerdtree/blob/c2dd750860288b8cf81f6bd5ff49dc5ee76a34d5/lib/nerdtree/opener.vim#L309&quot; rel=&quot;nofollow&quot;&gt;line 309&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Opener._reuseWindow()&#xA;    &quot;check the current tab for the window&#xA;    let winnr = bufwinnr('^' . self._path.str() . '$')&#xA;    if winnr != -1&#xA;        call nerdtree#exec(winnr . &quot;wincmd w&quot;)&#xA;        call self._checkToCloseTree(0)&#xA;        return 1&#xA;    else&#xA;        &quot;check other tabs&#xA;        let tabnr = self._path.tabnr()&#xA;        if tabnr&#xA;            call self._checkToCloseTree(1)&#xA;            call nerdtree#exec('normal! ' . tabnr . 'gt')&#xA;            let winnr = bufwinnr('^' . self._path.str() . '$')&#xA;            call nerdtree#exec(winnr . &quot;wincmd w&quot;)&#xA;            return 1&#xA;        endif&#xA;    endif&#xA;    return 0&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It wouldn't be too hard, however, to simply remove the entire &lt;code&gt;else&lt;/code&gt;  block in the code above (or comment it out). Since we're on the Vim site, why not do it with Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim &quot;+/function! s:Opener._reuseWindow()&quot; &quot;+/else&quot; &quot;+normal d9j&quot; &quot;+wq&quot; lib/nerdtree/opener.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Run this command from the directory in which the NERDTree plugin is located to automagically remove this functionality.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-11T22:23:17.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="718" PostTypeId="1" AcceptedAnswerId="719" CreationDate="2015-02-12T00:48:46.317" Score="19" ViewCount="11792" Body="&lt;p&gt;I have a file with a line that looks like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;foofoo.xy.barbar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I want to change the &lt;code&gt;xy&lt;/code&gt; to &lt;code&gt;gh&lt;/code&gt;. I tried to do &lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt; -&amp;gt; &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt;, but obviously that didn't work, as it replaced the &lt;code&gt;xy&lt;/code&gt; with &lt;code&gt;gg&lt;/code&gt; and then moved my cursor one spot to the left.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to do this without entering insert mode, or without using a lot more keystrokes (e.g. &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="134" LastEditorUserId="23502" LastEditDate="2022-10-30T17:40:13.633" LastActivityDate="2023-12-07T09:11:28.067" Title="How to replace more than one character without entering insert mode?" Tags="|replace|repeated-commands|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="719" PostTypeId="2" ParentId="718" CreationDate="2015-02-12T01:17:18.977" Score="24" Body="&lt;p&gt;If the new text is the same length as the old text, Vim's &lt;strong&gt;replace mode&lt;/strong&gt; is an option. From normal mode, &lt;kbd&gt;R&lt;/kbd&gt; (that's a capital &quot;r&quot;) brings you into replace mode. This is similar to &quot;overwrite&quot; in some other text editors: instead of inserting new characters like in insert mode, typing will replace the character under the cursor, and then advance to the next cursor. (Think of it like the lower-case &lt;code&gt;r&lt;/code&gt;, but for more than just a single character at a time.) Find the documentation for replace mode with &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#mode-replace&quot;&gt;&lt;code&gt;:help replace-mode&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case: with the cursor between the &lt;code&gt;.&lt;/code&gt; and the &lt;code&gt;x&lt;/code&gt;, get in to replace mode by pressing &lt;kbd&gt;R&lt;/kbd&gt;. Now when you type &lt;kbd&gt;g&lt;/kbd&gt; it replaces the &quot;x&quot; and moves to the next character, so you can type &lt;kbd&gt;h&lt;/kbd&gt; to replace the &quot;y&quot;. Your edit is done now, so &lt;kbd&gt;Escape&lt;/kbd&gt; to return to to normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This works when your replacement text is the same length as the old text, but if your replacement is longer or shorter, &lt;code&gt;c&lt;/code&gt; might be all you need: it will replace&lt;sup&gt;1&lt;/sup&gt; the text within a movement, with the text you then type. There are many ways to do use &lt;code&gt;c&lt;/code&gt;, for example: with the cursor between the &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;x&lt;/code&gt;, &lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;.&lt;/kbd&gt;&lt;code&gt;ABC&lt;/code&gt;&lt;kbd&gt;Escape&lt;/kbd&gt; says to &lt;strong&gt;c&lt;/strong&gt;hange the text (up '&lt;strong&gt;t&lt;/strong&gt;il the next &lt;strong&gt;&lt;em&gt;&lt;code&gt;.&lt;/code&gt;&lt;/em&gt;&lt;/strong&gt;) with &quot;ABC&quot;.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; It'll yank the text in the movement into &lt;a href=&quot;http://usevim.com/2012/04/13/registers/&quot;&gt;the unnamed/&lt;code&gt;&quot;&lt;/code&gt; register&lt;/a&gt; and then switch into insert mode, so that you can type something to replace it, and then &lt;kbd&gt;Escape&lt;/kbd&gt; back to normal mode.&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2015-02-12T08:30:14.297" LastActivityDate="2015-02-12T08:30:14.297" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="720" PostTypeId="2" ParentId="698" CreationDate="2015-02-12T01:45:07.990" Score="2" Body="&lt;p&gt;I like to use &lt;Kbd&gt;Ctrl+U&lt;/Kbd&gt;. If there are any characters on the line, it deletes to the beginning of the text. Press again to delete to column 1 (the indentation), and again to remove the line and put the cursor at the end of the line above. This is quicker than &lt;Kbd&gt;Ctrl+D&lt;/Kbd&gt; when there are several levels of indent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This requires &lt;code&gt;indent&lt;/code&gt; set in your backspace option.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set backspace=eol,start,indent        &quot; or set backspace=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="227" LastEditorUserId="356" LastEditDate="2015-02-12T02:02:56.820" LastActivityDate="2015-02-12T02:02:56.820" CommentCount="1" CommunityOwnedDate="2015-02-12T01:45:07.990" ContentLicense="CC BY-SA 3.0" />
  <row Id="721" PostTypeId="2" ParentId="718" CreationDate="2015-02-12T01:51:25.537" Score="5" Body="&lt;p&gt;There are a couple ways you could do this, but the simplest I can think of is:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;TL;DR&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;fxcw&amp;lt;REPLACEMENT TEXT&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Explanation&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;fx&lt;/code&gt; jumps you to the x (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#f&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;help *f*&lt;/code&gt;&lt;/a&gt;) &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cw&lt;/code&gt; says to change the word (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#c&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h *c*&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#w&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help *w*&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#cw&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help cw&lt;/code&gt;&lt;/a&gt; for more information), removing the &quot;xy&quot; text and entering insert mode, letting you put whatever you want right there.&lt;/li&gt;&#xA;&lt;li&gt;&amp;lt; REPLACEMENT TEXT &gt; is whatever you want to replace it with - &quot;gh&quot; in your example.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;One advantage of this approach is that it uses very commonly used text manipulation &amp;amp; navigation commands. Another is that &quot;xy&quot; could be of any length, and this would still work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;cw&lt;/code&gt; works because your text object is surrounded by periods (&lt;code&gt;.&lt;/code&gt;), which act as a boundary to the word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your cursor is already on the  &quot;y&quot; character (or any character in the text to be replaced), you could use &lt;code&gt;ciw&amp;lt;REPLACEMENT TEXT&amp;gt;&lt;/code&gt;. This tells vim to change the word you're in, even if you're not at the beginning of it. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help text-objects&lt;/code&gt;&lt;/a&gt; for more information on &lt;code&gt;ciw&lt;/code&gt; and text objects in general.&lt;/p&gt;&#xA;" OwnerUserId="306" LastEditorUserId="342" LastEditDate="2015-02-13T10:01:15.003" LastActivityDate="2015-02-13T10:01:15.003" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="722" PostTypeId="2" ParentId="718" CreationDate="2015-02-12T07:44:30.030" Score="3" Body="&lt;p&gt;Replace mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Rgh&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is the most obvious solution if the replacement is the same length as the original but you could also do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2sgh&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cegh&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-02-12T07:44:30.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="723" PostTypeId="2" ParentId="573" CreationDate="2015-02-12T08:16:20.013" Score="10" Body="&lt;p&gt;According to the site &lt;a href=&quot;http://www.pjb.com.au/blin/&quot;&gt;Things I have learned about Linux for the Blind&lt;/a&gt;, vim has issues unless you &lt;code&gt;:set noruler&lt;/code&gt;. According to him, &lt;a href=&quot;http://www.pjb.com.au/blin/#edi&quot;&gt;elvis has a screen-reader friendly mode&lt;/a&gt; that doesn't use curses. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what Tyler Spivey (a blind CLI user) &lt;a href=&quot;https://tspivey.wordpress.com/2007/11/14/my-thoughts-on-the-current-state-of-command-line-accessibility/&quot;&gt;wrote&lt;/a&gt;, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The problem with these is that a screen reader&#xA;  doesn’t know that, for example, j will move&#xA;  the cursor to the next line in Vim. Nor does it know that l&#xA;  will move to the next character. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;if I type&#xA;  j in vim, or ^n in emacs, the screen&#xA;  reader will attempt to read what has changed on the&#xA;  screen, which is usually nothing – just&#xA;  the position of the cursor. At this point,&#xA;  the screen reader isn’t sure if I typed a j because I wanted to insert a j, or&#xA;  if I typed a j because I wanted to move to the next line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sadly, it seems that screen-reader support for vi-based editors could use some improvement, though elvis seems to provide a good experience.&lt;/p&gt;&#xA;" OwnerUserId="306" LastEditorUserId="306" LastEditDate="2015-02-12T15:50:47.407" LastActivityDate="2015-02-12T15:50:47.407" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="725" PostTypeId="5" CreationDate="2015-02-12T13:33:49.197" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-12T13:33:49.197" LastActivityDate="2015-02-12T13:33:49.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="726" PostTypeId="4" CreationDate="2015-02-12T13:33:49.197" Score="0" Body="Questions about using the right commands to minimize the number of keystrokes to perform a given task." OwnerUserId="134" LastEditorUserId="134" LastEditDate="2015-02-12T14:31:42.147" LastActivityDate="2015-02-12T14:31:42.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="727" PostTypeId="1" AcceptedAnswerId="729" CreationDate="2015-02-12T15:18:32.383" Score="12" ViewCount="5975" Body="&lt;p&gt;My goal were to somehow make visible, if a whitespace is space, tab, or even newline (and, ideally, in case of newline I would be happy to see &lt;code&gt;\r\n&lt;/code&gt; and &lt;code&gt;\n&lt;/code&gt; differently).&lt;/p&gt;&#xA;&lt;p&gt;I am thinking to a similar thing as the GUI text editors can do.&lt;/p&gt;&#xA;&lt;p&gt;Is it somehow with Vim also possible?&lt;/p&gt;&#xA;" OwnerUserId="28" LastEditorUserId="23502" LastEditDate="2022-10-31T12:45:31.040" LastActivityDate="2022-10-31T12:45:31.040" Title="How to differentiate visually the white spaces in Vim?" Tags="|whitespace|" AnswerCount="2" CommentCount="0" ClosedDate="2015-02-13T23:18:24.027" ContentLicense="CC BY-SA 4.0" />
  <row Id="728" PostTypeId="2" ParentId="727" CreationDate="2015-02-12T15:28:06.473" Score="6" Body="&lt;p&gt;This can be done with &lt;code&gt;:set list&lt;/code&gt;. The Characters displayed for the different whitespace chars can be controlled by &lt;code&gt;:set listchars&lt;/code&gt;. See the help topics for detailed information. Here's an example from my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list&#xA;set listchars=tab:&amp;gt;-,trail:.,extends:#,nbsp:.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="117" LastActivityDate="2015-02-12T15:28:06.473" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="729" PostTypeId="2" ParentId="727" CreationDate="2015-02-12T15:28:54.163" Score="17" Body="&lt;p&gt;Yes, look at &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27listchars%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help listchars&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;listchars&lt;/code&gt; is a string that will be parsed when &lt;code&gt;list&lt;/code&gt; is set to determine what to render for certain special characters. You can set &lt;code&gt;listchars&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set listchars=eol:!,tab:&amp;gt;=,trail:.&#xA;set list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will use the &lt;code&gt;!&lt;/code&gt; character to show the end of every line, tabs like &lt;code&gt;&amp;gt;===&lt;/code&gt; (assuming four-space tabs), and &lt;em&gt;trailing&lt;/em&gt; spaces with a &lt;code&gt;.&lt;/code&gt; character. The characters are highlighted with the &lt;code&gt;SpecialKey&lt;/code&gt; group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, you can include the following tokens in &lt;code&gt;listchars&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;extends:&amp;lt;character&amp;gt;&lt;/code&gt; for the last character in a long line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;precedes:&amp;lt;character&amp;gt;&lt;/code&gt; for the first character in a long line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;conceal:&amp;lt;character&amp;gt;&lt;/code&gt; for concealed text &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nbsp:&amp;lt;character&amp;gt;&lt;/code&gt; for non-breaking spaces&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that you cannot get vim to display visible whitespace for spaces that are not trailing without a relatively modern version of vim; check &lt;code&gt;if has(&quot;patch710&quot;)&lt;/code&gt; to see if &lt;code&gt;space&lt;/code&gt; is supported in &lt;code&gt;listchars&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorDisplayName="user72" LastEditDate="2016-02-12T16:58:34.537" LastActivityDate="2016-02-12T16:58:34.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="730" PostTypeId="1" AcceptedAnswerId="734" CreationDate="2015-02-12T15:34:59.337" Score="12" ViewCount="12737" Body="&lt;p&gt;How I paste now:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Right-click/Copy or simply highlight.&lt;/li&gt;&#xA;&lt;li&gt;Right-click/Paste or Middle Click or CTRL+SHFT+V&lt;/li&gt;&#xA;&lt;li&gt;Indents appear at increasing intervals: 0, 2, 4, 6, +&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Question at hand:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From prior research, I found that the quick and dirty solution is entering the following in my &lt;code&gt;.vimrc&lt;/code&gt; file: &lt;code&gt;set paste&lt;/code&gt;. However, those who suggested that command said that &lt;code&gt;set paste&lt;/code&gt; affects other settings. (Off the top of my head, I forget.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know what option I can set that simply pastes without extra indentation. &lt;em&gt;If that ends up being &lt;code&gt;'paste'&lt;/code&gt;&lt;/em&gt;, then I would like to know what exactly that command does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only see one difference. When in Vim, &lt;code&gt;-- INSERT --&lt;/code&gt; becomes &lt;code&gt;-- INSERT (paste) --&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user486" LastEditorUserId="343" LastEditDate="2017-10-20T08:43:31.247" LastActivityDate="2021-10-31T05:33:42.420" Title="How can I copy/paste new text without auto-indentation at every new line?" Tags="|vimrc|indentation|os-clipboard|" AnswerCount="7" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="731" PostTypeId="2" ParentId="730" CreationDate="2015-02-12T15:59:05.743" Score="7" Body="&lt;p&gt;If you are using a fairly modern terminal emulator, you can install the &lt;a href=&quot;https://github.com/ConradIrwin/vim-bracketed-paste&quot; rel=&quot;noreferrer&quot;&gt;vim-bracketed-paste plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the docs: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;xterm, urxvt, iTerm2, gnome-terminal (and other terminals using&#xA;  libvte) are known to work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After installing, you can simply paste as normal in insert mode, and it will take care of setting and unsetting paste for you.&lt;/p&gt;&#xA;" OwnerUserId="411" LastActivityDate="2015-02-12T15:59:05.743" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="732" PostTypeId="1" AcceptedAnswerId="733" CreationDate="2015-02-12T16:12:23.287" Score="84" ViewCount="37317" Body="&lt;p&gt;I know how to &lt;a href=&quot;https://vi.stackexchange.com/questions/64/is-it-possible-to-split-vim-window-to-view-multiple-files-at-once&quot;&gt;split windows in vim&lt;/a&gt;, but it's possible to open multiple files using vim in split mode (at startup) from the command line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim file1 file2 file3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim *.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2020-07-26T09:44:44.117" Title="How to open multiple files in split mode?" Tags="|command-line|split|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="733" PostTypeId="2" ParentId="732" CreationDate="2015-02-12T16:16:38.680" Score="96" Body="&lt;p&gt;You can use the option &lt;code&gt;-o&lt;/code&gt; to open the files in horizontal splits or &lt;code&gt;-O&lt;/code&gt; (letter &amp;quot;O&amp;quot;) to open vertical splits. The following commands open a window for each file specified:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim -o *.cpp&#xA;vim -O foo bar baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can tell Vim the maximum number of windows to open by putting an integer after &lt;code&gt;o&lt;/code&gt; or &lt;code&gt;O&lt;/code&gt; options, the following example will open at most two windows no matter how many file matches, you will see the first two file specified on the command line, the rest will remain hidden:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim -o2 *.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#-o&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help -o&lt;/code&gt;&lt;/a&gt; for all the details.&lt;/p&gt;&#xA;" OwnerUserId="13" LastEditorUserId="26004" LastEditDate="2020-07-26T09:44:44.117" LastActivityDate="2020-07-26T09:44:44.117" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="734" PostTypeId="2" ParentId="730" CreationDate="2015-02-12T16:22:42.087" Score="15" Body="&lt;p&gt;OK, here is a &amp;quot;yank &amp;amp; put&amp;quot; primer…&lt;/p&gt;&#xA;&lt;p&gt;In Vim, the primary commands for yanking (copying) and putting (pasting) are &lt;code&gt;y&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Yanking places the yanked text in a register. That register is the unnamed register, &lt;code&gt;&amp;quot;&lt;/code&gt;, by default but one can use other registers:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;ay    &amp;quot; yank into register a&#xA;&amp;quot;by    &amp;quot; yank into register b&#xA;&amp;quot;+y    &amp;quot; yank into clipboard register&#xA;[…]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Similarly, putting inserts text from a register. That register is the unnamed register by default but one can use other registers:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;ap    &amp;quot; put from register a&#xA;&amp;quot;+p    &amp;quot; put from clipboard register&#xA;&amp;quot;3p    &amp;quot; put from the register 3&#xA;[…]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Those commands are prefered to &amp;quot;Right-click/Paste or Middle Click or CTRL+SHFT+V&amp;quot; because the text is &amp;quot;put&amp;quot; into the buffer without any special treatment. With &amp;quot;Right-click/Paste or Middle Click or CTRL+SHFT+V&amp;quot;, the text is inserted in the buffer &lt;em&gt;&lt;strong&gt;as if you typed it&lt;/strong&gt;&lt;/em&gt; and is thus subjected to automatic indenting/formatting.&lt;/p&gt;&#xA;&lt;p&gt;If you can't use &lt;code&gt;&amp;quot;+p&lt;/code&gt; or &lt;code&gt;&amp;quot;*p&lt;/code&gt; — working over SSH without X forwarding or Vim built without clipboard support — the &lt;code&gt;paste&lt;/code&gt; option disables automatic indenting and a bunch of other very useful options so that your &lt;em&gt;typed&lt;/em&gt; text is not alrered.&lt;/p&gt;&#xA;&lt;p&gt;As noted in &lt;code&gt;:help 'paste'&lt;/code&gt;, the options has potentially very bad side effects so it is important to disable it right after you pasted your text:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set paste&#xA;(paste)&#xA;:set nopaste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;That dance is obviously a pain in the ass so there is another option that lets you define a special shortcut for toggling &lt;code&gt;paste&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set pastetoggle=&amp;lt;F12&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;That slightly reduces the pain:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;F12&amp;gt;&#xA;(paste)&#xA;&amp;lt;F12&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But it is still a pain.&lt;/p&gt;&#xA;&lt;p&gt;If you can, it is recommended to install a proper Vim with clipboard support so you can use &lt;code&gt;&amp;quot;*p&lt;/code&gt; or &lt;code&gt;&amp;quot;+p&lt;/code&gt; (depending on how you copied your text) to paste text &lt;em&gt;the right way&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;On Mac OS X: install MacVim,&lt;/li&gt;&#xA;&lt;li&gt;on Debian-based systems: install the vim-gnome or vim-gtk package,&lt;/li&gt;&#xA;&lt;li&gt;on CentOS: install the vim-enhanced package.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Reference:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:help p&#xA;:help y&#xA;:help registers&#xA;:help 'paste'&#xA;:help 'pastetoggle'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="18609" LastEditDate="2020-09-16T11:54:24.033" LastActivityDate="2020-09-16T11:54:24.033" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="735" PostTypeId="1" AcceptedAnswerId="736" CreationDate="2015-02-12T16:29:32.403" Score="20" ViewCount="6958" Body="&lt;p&gt;How to efficiently exit Vim when editing multiple files in the split mode at one go?&lt;/p&gt;&#xA;&lt;p&gt;It seems when I'm having e.g. 10 split windows, I've to repeat 10 times &lt;code&gt;:q!&lt;/code&gt; command for each window which is a bit time consuming.&lt;/p&gt;&#xA;&lt;p&gt;Are there any better methods of quitting the editor?&lt;/p&gt;&#xA;&lt;p&gt;As for dirty workaround, it can be quit by pressing &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;Z&lt;/kbd&gt; and typing &lt;code&gt;kill %1&lt;/code&gt; to kill it.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="23502" LastEditDate="2022-10-30T18:00:03.353" LastActivityDate="2022-10-30T18:00:03.353" Title="How to exit Vim from split mode?" Tags="|split|quit|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="736" PostTypeId="2" ParentId="735" CreationDate="2015-02-12T16:32:55.077" Score="24" Body="&lt;p&gt;Use the command &lt;code&gt;:qall!&lt;/code&gt;, &lt;code&gt;:qa!&lt;/code&gt; for short, or its safer alternative &lt;code&gt;:qall&lt;/code&gt; that prevent to discard modified buffers. To save all buffers before quitting use the command &lt;code&gt;:wqall&lt;/code&gt;. See &lt;code&gt;:help window-exit&lt;/code&gt; for the full set of commands to quit multiple windows at once.&lt;/p&gt;&#xA;" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2015-02-12T16:38:02.843" LastActivityDate="2015-02-12T16:38:02.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="737" PostTypeId="1" AcceptedAnswerId="738" CreationDate="2015-02-12T16:49:22.870" Score="27" ViewCount="11174" Body="&lt;p&gt;I would like to edit content in vim which was dynamically generated from the command-line without having the file yet.&lt;/p&gt;&#xA;&lt;p&gt;In example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ echo This is example. | vim /dev/stdin&#xA;$ cat /etc/hosts | vim /dev/stdin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but it's failing with the errors:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Vim: Warning: Input is not from a terminal&lt;/p&gt;&#xA;&lt;p&gt;Vim: Error reading input, exiting...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It is possible to achieve that?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-04-24T22:16:30.487" Title="How to edit content from the standard input?" Tags="|command-line|invocation|unix|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="738" PostTypeId="2" ParentId="737" CreationDate="2015-02-12T16:52:05.830" Score="40" Body="&lt;p&gt;You have to use &lt;code&gt;-&lt;/code&gt; in place of the file name on the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo This is example. | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above command will open an unnamed buffer filled with the text read from the standard input.  &lt;/p&gt;&#xA;" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2015-02-12T19:20:55.517" LastActivityDate="2015-02-12T19:20:55.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="739" PostTypeId="2" ParentId="730" CreationDate="2015-02-12T16:54:18.123" Score="8" Body="&lt;p&gt;VIM has another setting &lt;code&gt;pastetoggle&lt;/code&gt; that defines the mapping for toggling paste mode. That's what you'd want to do and then you can just enable paste mode and then paste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I find that a little less intuitive and have often found &lt;code&gt;]p&lt;/code&gt; to be a better way to paste code instead of using just &lt;code&gt;p&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-02-12T16:54:18.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="740" PostTypeId="2" ParentId="737" CreationDate="2015-02-12T16:54:27.327" Score="4" Body="&lt;p&gt;In bash I've found it useful to use process substitution using the &lt;code&gt;&amp;lt;(command)&lt;/code&gt; syntax, in example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim &amp;lt;(echo This is example.)&#xA;vim &amp;lt;(cat /etc/hosts)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/788/467&quot;&gt;How to edit files non-interactively (e.g. in pipeline)?&lt;/a&gt; at Vi SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/102089/how-to-pipe-the-result-of-a-grep-search-into-a-new-vi-file&quot;&gt;How to pipe the result of a grep search into a new vi file&lt;/a&gt; at unix SE&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-18T11:50:47.753" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="741" PostTypeId="2" ParentId="737" CreationDate="2015-02-12T19:09:09.293" Score="9" Body="&lt;p&gt;This is just mostly a fun note about &lt;code&gt;bash&lt;/code&gt; and &lt;code&gt;readline&lt;/code&gt;, but if you set your &lt;code&gt;EDITOR&lt;/code&gt; environment variable to &lt;code&gt;vim&lt;/code&gt;, hitting &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt; will open up the current line in &lt;code&gt;vim&lt;/code&gt;. Further, if you type &lt;kbd&gt;Meta(Alt/Opt/Esc)&lt;/kbd&gt;+&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt;, bash will perform an in place expansion on the current command line, i.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo $EDITOR # Assuming EDITOR was set&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;kbd&gt;Meta(Alt/Opt/Esc)&lt;/kbd&gt;+&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt; would become&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo vim # Assuming EDITOR was set&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt; would become&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 echo vim # Assuming EDITOR was set&#xA;~&#xA;~&#xA;/tmp/sometmpbufferfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that upon quitting vim, the contents of the vim buffer are executed on the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These features become very useful for me when I want to do multi-line commands in bash such as for loops or programs requiring here statements, and provides an interesting way to save a bit of command-line history to file for later use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to answer the original question, you could also write,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ This is an example&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then hit &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt; to load it up in &lt;code&gt;vim&lt;/code&gt;. Also you could have,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; $ $(cat /etc/hosts)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and do &lt;kbd&gt;Meta(Alt/Opt/Esc)&lt;/kbd&gt;+&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt; then &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt;, which would put all of the hosts file on one line and load it up in &lt;code&gt;vim&lt;/code&gt; (probably not the best use of these features--however, the usefulness of these methods can be extrapolated from the few examples discussed here).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I assume that your &lt;code&gt;readline&lt;/code&gt; is set to &lt;code&gt;emacs&lt;/code&gt; mode. If your &lt;code&gt;readline&lt;/code&gt; is set to &lt;code&gt;vim&lt;/code&gt; mode you can easily discover the relevant bindings by using the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bind -p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and searching for &lt;code&gt;edit-and-execute-command&lt;/code&gt; or &lt;code&gt;shell-expand-line&lt;/code&gt;, which were respectively associated with the bindings &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt; and &lt;kbd&gt;Meta(Alt/Opt/Esc)&lt;/kbd&gt;+&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="44" LastEditorUserId="44" LastEditDate="2015-02-12T19:37:58.743" LastActivityDate="2015-02-12T19:37:58.743" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="742" PostTypeId="1" AcceptedAnswerId="786" CreationDate="2015-02-12T19:58:27.617" Score="13" ViewCount="11005" Body="&lt;p&gt;When using &lt;code&gt;set showcmd&lt;/code&gt; Vim shows partial commands in the last line of the screen. For example, in Normal mode when typing the command &lt;code&gt;dt.&lt;/code&gt; the last line shows &lt;code&gt;dt&lt;/code&gt; and then, when you hit &lt;code&gt;.&lt;/code&gt; the command is complete and therefore nothing is shown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to show full commands? For example when typing &lt;code&gt;dt.gU(&lt;/code&gt;, first &lt;code&gt;dt.&lt;/code&gt; would be shown; and when starting to type the second command the first would be cleared, so that in the end only &lt;code&gt;gU(&lt;/code&gt; would is displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This could be useful for example in illustrating GIFs; and to check that you typed what you wanted if you face some unexpected result.&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="51" LastEditDate="2015-02-12T20:36:31.437" LastActivityDate="2015-02-19T12:53:08.630" Title="Showing command history with showcmd" Tags="|options|command-history|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="743" PostTypeId="1" AcceptedAnswerId="745" CreationDate="2015-02-12T20:59:08.177" Score="6" ViewCount="86" Body="&lt;p&gt;&lt;strong&gt;Notes&lt;/strong&gt;: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have &lt;code&gt;set path=$PWD/**&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;I am using Vim 7.3&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Often times, I am sitting with Vim open at the root of my project and I enter &lt;code&gt;:find somef&amp;lt;Tab&amp;gt;&lt;/code&gt; to find and open a file at an arbitrary depth. This &lt;em&gt;always&lt;/em&gt; works when I am sitting at the project root with no file open. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I have a file open, however, I can't just type &lt;code&gt;:find anotherfi&amp;lt;Tab&amp;gt;&lt;/code&gt; to get a list of possible options - Vim gives me a quick &lt;code&gt;:find anotherfi...&lt;/code&gt; and then leaves me with &lt;code&gt;:find anotherfi&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make tab completion with &lt;code&gt;:find&lt;/code&gt; work with my &lt;code&gt;path&lt;/code&gt; when I am visiting any file as it does when I am sitting at the root with nothing open?&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastEditorUserId="356" LastEditDate="2015-02-17T14:52:44.097" LastActivityDate="2015-02-17T14:52:44.097" Title="Tab to complete filenames with :find at an arbitrary depth" Tags="|autocompletion|load|filesystem|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="744" PostTypeId="1" AcceptedAnswerId="751" CreationDate="2015-02-12T21:02:10.117" Score="9" ViewCount="852" Body="&lt;p&gt;I have a file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi.stackexchange.com&#xA;example.com&#xA;duckduckgo.com&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to be able to open these sites with &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;; this doesn't work because there's no protocol (&lt;code&gt;http://&lt;/code&gt;) in front of these sites.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to make a script to add the &lt;code&gt;http://&lt;/code&gt; prefix (this is trivial), but I'm not sure how I can then pass my string to &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Goto(site)&#xA;    let l:site = a:site&#xA;    if l:site !~? '^https\?:\/\/'&#xA;        let l:site = 'https://' . l:site&#xA;    endif&#xA;&#xA;    &quot; Problem: how to I pass l:site to gx?&#xA;    exe 'normal gx'&#xA;endfun&#xA;&#xA;nnoremap &amp;lt;Leader&amp;gt;g :call Goto(getline('.'))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I looked at &lt;code&gt;/usr/share/vim/vim74/plugin/netrwPlugin.vim&lt;/code&gt; to see how it's mapped:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(&quot;g:netrw_nogx&quot;)&#xA; if maparg('gx','n') == &quot;&quot;&#xA;  if !hasmapto('&amp;lt;Plug&amp;gt;NetrwBrowseX')&#xA;   nmap &amp;lt;unique&amp;gt; gx &amp;lt;Plug&amp;gt;NetrwBrowseX&#xA;  endif&#xA;  nno &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;NetrwBrowseX :call netrw#BrowseX(expand((exists(&quot;g:netrw_gx&quot;)? g:netrw_gx :            █'&amp;lt;cfile&amp;gt;')),netrw#CheckIfRemote())&amp;lt;cr&amp;gt;&#xA; endif&#xA; if maparg('gx','v') == &quot;&quot;&#xA;  if !hasmapto('&amp;lt;Plug&amp;gt;NetrwBrowseXVis')&#xA;   vmap &amp;lt;unique&amp;gt; gx &amp;lt;Plug&amp;gt;NetrwBrowseXVis&#xA;  endif&#xA;  vno &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;NetrwBrowseXVis :&amp;lt;c-u&amp;gt;call netrw#BrowseXVis()&amp;lt;cr&amp;gt;&#xA; endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't call &lt;code&gt;&amp;lt;Plug&amp;gt;NetrwBrowseX&lt;/code&gt; (AFAIK?) ... Is there some other way to do this?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="24" LastEditDate="2015-02-12T21:34:12.970" LastActivityDate="2015-02-13T09:45:28.920" Title="Can I pass a custom string to the 'gx' command?" Tags="|vimscript|external-command|netrw|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="745" PostTypeId="2" ParentId="743" CreationDate="2015-02-12T21:29:16.997" Score="3" Body="&lt;p&gt;The issue is caused by a changing path due to Tim Pope's &lt;code&gt;vim-classpath&lt;/code&gt; plugin. To fix the issue, simply remove that plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To confirm this, either run vim with &lt;code&gt;vim -u NONE&lt;/code&gt; and manually run &lt;code&gt;:set path=$PWD/**&lt;/code&gt; to test, or temporarily remove the plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you require the plugin this may not be a viable option.&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastActivityDate="2015-02-12T21:29:16.997" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="746" PostTypeId="1" AcceptedAnswerId="748" CreationDate="2015-02-12T22:19:14.653" Score="8" ViewCount="506" Body="&lt;p&gt;I'm looking for something like &lt;code&gt;[[&lt;/code&gt; (or &lt;code&gt;[]&lt;/code&gt;, &lt;code&gt;]]&lt;/code&gt;, &lt;code&gt;][&lt;/code&gt;) that works with non-top-level function definitions instead of the next line with a top-level class or function definition on the first character.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Foo():&#xA;  def __init__(self):&#xA;    pass&#xA;&#xA;  def baz(self): #jump from here...&#xA;    pass&#xA;&#xA;  def box(self): #... to here without searching or...&#xA;    pass&#xA;&#xA;biz = 123&#xA;&#xA;def bar(): #... without going straight here&#xA;  pass&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems like, by default, vim ignores variable definitions and other things that start on the first character of a line, but when I'm looking through class methods, my only recourse is to search for &lt;code&gt;def XYZ&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="488" LastEditorUserId="488" LastEditDate="2017-11-09T16:00:13.523" LastActivityDate="2017-11-09T16:00:13.523" Title="Motion for moving to non-top-level Python function definition" Tags="|cursor-movement|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="747" PostTypeId="1" CreationDate="2015-02-12T22:23:40.353" Score="33" ViewCount="635" Body="&lt;p&gt;Quotation marks in LaTeX are different than in normal text, in that they're formatted &lt;code&gt;``like this''&lt;/code&gt; (or &lt;code&gt;`like this'&lt;/code&gt; for single quotes). This makes it difficult to navigate through them in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I usually use something like &lt;code&gt;T`ct'&lt;/code&gt; (backwards until &lt;code&gt;`&lt;/code&gt;, change until &lt;code&gt;'&lt;/code&gt;). However, this is clunky and unnatural. I would prefer to be able to use something along the lines of &lt;code&gt;ciq&lt;/code&gt; (&quot;change in quotes&quot;), just like I can do &lt;code&gt;ciw&lt;/code&gt;, &lt;code&gt;ca)&lt;/code&gt;, &lt;code&gt;ci&quot;&lt;/code&gt;, &lt;code&gt;ca'&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to tell Vim to treat &lt;code&gt;``LaTeX'' `quotes'&lt;/code&gt; as text objects? (As a plus, is there any way to only trigger this while editing a &lt;code&gt;.tex&lt;/code&gt; file?)&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="1292" LastEditDate="2019-01-24T12:48:28.793" LastActivityDate="2021-12-30T13:05:34.917" Title="How can I treat LaTeX quotes as a text object?" Tags="|cursor-motions|filetype-tex|custom-text-object|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="748" PostTypeId="2" ParentId="746" CreationDate="2015-02-12T22:29:36.023" Score="12" Body="&lt;p&gt;&lt;code&gt;]m&lt;/code&gt; (and &lt;code&gt;[m&lt;/code&gt;) seem to fit the bill. From &lt;code&gt;:help ]m&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *]m*&#xA;]m          Go to [count] next start of a method (for Java or&#xA;            similar structured language).  When not before the&#xA;            start of a method, jump to the start or end of the&#xA;            class.  When no '{' is found after the cursor, this is&#xA;            an error.  |exclusive| motion. {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Simply pressing &lt;code&gt;]m&lt;/code&gt; will jump to the exact place you want to.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-12T22:29:36.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="750" PostTypeId="2" ParentId="747" CreationDate="2015-02-12T23:19:08.097" Score="12" Body="&lt;p&gt;I don't know LaTeX but this seems to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap iq :&amp;lt;C-U&amp;gt;silent! normal! t'vT`&amp;lt;CR&amp;gt;&#xA;omap iq :normal viq&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I based this off the information over here: &lt;a href=&quot;http://vim.wikia.com/wiki/Creating_new_text_objects&quot;&gt;http://vim.wikia.com/wiki/Creating_new_text_objects&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add support for &lt;code&gt;aq&lt;/code&gt; as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap aq :&amp;lt;C-U&amp;gt;silent! normal! f'vF`&amp;lt;CR&amp;gt;&#xA;omap aq :normal vaq&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="195" LastEditorUserId="195" LastEditDate="2015-02-16T23:25:28.170" LastActivityDate="2015-02-16T23:25:28.170" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="751" PostTypeId="2" ParentId="744" CreationDate="2015-02-13T04:41:19.943" Score="10" Body="&lt;p&gt;The &lt;code&gt;gx&lt;/code&gt; mapping is calling &lt;code&gt;netrw#BrowseX()&lt;/code&gt;, so you could call that at the end of your function, passing in the &lt;code&gt;l:site&lt;/code&gt; variable you've constructed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call netrw#BrowseX(l:site, netrw#CheckIfRemote())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would also suggest that instead of &lt;code&gt;getline('.')&lt;/code&gt;, you use &lt;code&gt;expand('&amp;lt;cfile&amp;gt;')&lt;/code&gt;, which evaluates to the filename under the cursor. This will work when the URL is on a line containing other content as well.&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="51" LastEditDate="2015-02-13T09:45:28.920" LastActivityDate="2015-02-13T09:45:28.920" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="753" PostTypeId="1" CreationDate="2015-02-13T10:02:12.143" Score="5" ViewCount="5236" Body="&lt;p&gt;I find it sometimes useful to add a certain string to the beginning of a line, and sometimes I would like to do this to a few lines, and I don't like moving to each line and change it. Assuming I know how to select the lines that interest me in Visual mode, how can I add the prefix?&lt;/p&gt;&#xA;" OwnerUserId="342" LastActivityDate="2015-02-17T13:27:34.230" Title="How can I add a prefix to a few lines?" Tags="|repeated-commands|" AnswerCount="3" CommentCount="0" ClosedDate="2015-02-13T21:22:12.793" ContentLicense="CC BY-SA 3.0" />
  <row Id="754" PostTypeId="2" ParentId="753" CreationDate="2015-02-13T10:10:43.040" Score="10" Body="&lt;p&gt;What I do to achieve this is to make a visual rectangular selection with &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; at the place where I want to add the prefix, and once all lines are selected, just press &lt;kbd&gt;I&lt;/kbd&gt; (that's a capital i) and type in the text. When exiting insert mode the text will be copied to all the lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the sequence in images:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Visual selection of the place of insertion&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/eQZhe.png&quot; alt=&quot;vim1&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Type in the text&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/izHlE.png&quot; alt=&quot;vim2&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Back to normal mode and the insertion is done&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DAzXg.png&quot; alt=&quot;vim3&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this works anywhere, not only at the beginning of the line.&lt;/p&gt;&#xA;" OwnerUserId="259" LastEditorUserId="259" LastEditDate="2015-02-13T10:22:58.357" LastActivityDate="2015-02-13T10:22:58.357" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="755" PostTypeId="2" ParentId="753" CreationDate="2015-02-13T10:17:58.997" Score="3" Body="&lt;p&gt;Usually it goes like this for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Esc + Shift-V + select lines + :&#xA;s//prefix[Enter]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;Why I like it is that it's still quick and when sometimes you want to use something more then this is nice base to start from, like next adding line numbers, ore expanding regex further&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s//\=printf('%2d', line('.'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="492" LastEditorUserId="492" LastEditDate="2015-02-13T10:26:58.503" LastActivityDate="2015-02-13T10:26:58.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="756" PostTypeId="1" AcceptedAnswerId="763" CreationDate="2015-02-13T10:53:09.790" Score="31" ViewCount="10419" Body="&lt;p&gt;I have installed a plugin that doesn't provide a mechanism to disable the key mappings it defines. I want to redefine one of the mappings (&lt;code&gt;&amp;lt;leader&amp;gt;cc&lt;/code&gt;) defined by the plugin for my own pursope, I've tried to put the following line in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;leader&amp;gt;cc echo &quot;my purpose&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this doesn't work, &lt;code&gt;&amp;lt;leader&amp;gt;cc&lt;/code&gt; is still executing the plugin command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I define my mapping so that it overrides those defined by the plugin?&lt;/p&gt;&#xA;" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2015-02-15T19:12:52.970" LastActivityDate="2022-04-08T14:24:05.867" Title="How can I redefine plugin key mappings?" Tags="|vimrc|key-bindings|plugin-system|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="757" PostTypeId="2" ParentId="753" CreationDate="2015-02-13T12:15:29.633" Score="2" Body="&lt;p&gt;Assuming you'd like to add prefix to 5 lines at the beginning of the line, then you can use &lt;a href=&quot;http://vim.wikia.com/wiki/Search_and_replace&quot; rel=&quot;nofollow noreferrer&quot;&gt;Search and replace&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,+5s/^/prefix_/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or at the end of the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,+5s/$/suffix_/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See more at: &lt;a href=&quot;https://vi.stackexchange.com/q/130/467&quot;&gt;How to comment out a set of lines which are selected in visual mode?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-17T13:27:34.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="758" PostTypeId="1" AcceptedAnswerId="762" CreationDate="2015-02-13T12:52:14.780" Score="7" ViewCount="3421" Body="&lt;p&gt;It is possible to convert all windows into different split mode while editing? Instead of &lt;a href=&quot;https://vi.stackexchange.com/questions/514/how-to-change-the-current-splits-width-and-height&quot;&gt;one by one&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In example (having multiple windows) from horizontal to vertical split and opposite, or from tab split all files into horizontal/vertical view and back?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar as it works at start when &lt;a href=&quot;https://vi.stackexchange.com/q/732/467&quot;&gt;opening multiple files&lt;/a&gt; with &lt;code&gt;-p&lt;/code&gt;, &lt;code&gt;-o&lt;/code&gt;, or &lt;code&gt;-O&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2019-11-13T00:46:38.587" Title="How to convert all windows into horizontal, vertical or tab splits?" Tags="|vim-windows|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="759" PostTypeId="1" AcceptedAnswerId="760" CreationDate="2015-02-13T13:09:02.513" Score="63" ViewCount="19090" Body="&lt;p&gt;I'm using complex repeats to record my operations (&lt;kbd&gt;qq&lt;/kbd&gt; to record, &lt;em&gt;some operations&lt;/em&gt;, &lt;kbd&gt;q&lt;/kbd&gt; to stop) and I did a mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to see what I've recorded and correct the mistake, instead of doing it again?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Invoking recorded characters by &lt;kbd&gt;@q&lt;/kbd&gt; works, but I can't see it in my mappings (&lt;kbd&gt;:map q&lt;/kbd&gt; - &lt;code&gt;No mapping found&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And there is not much information in help by typing: &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#recording&quot;&gt;&lt;code&gt;:help recording&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="1111" LastEditDate="2015-02-28T10:45:01.360" LastActivityDate="2023-04-03T16:47:52.760" Title="How can I view and edit my recording (i.e. recorded macro)?" Tags="|macro|register|command-history|repeated-commands|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="760" PostTypeId="2" ParentId="759" CreationDate="2015-02-13T13:20:39.213" Score="63" Body="&lt;p&gt;&lt;em&gt;Note: I'm assuming you're using the &lt;code&gt;a&lt;/code&gt; register for the entirety of this answer, but you can use any register&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note2: &lt;code&gt;&amp;lt;1b&amp;gt;&lt;/code&gt; is &lt;kbd&gt;Esc&lt;/kbd&gt;; you can insert this with &lt;kbd&gt;Ctrl+v&lt;/kbd&gt; and then &lt;kbd&gt;Esc&lt;/kbd&gt;. It may also show up as &lt;code&gt;^[&lt;/code&gt; (depending on the &lt;code&gt;display&lt;/code&gt; setting).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It's not a mapping; so it makes sense that &lt;code&gt;:map&lt;/code&gt; doesn't work. It's recorded in a register, and you can see &amp;amp; edit it like any register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All that &lt;kbd&gt;q&lt;/kbd&gt; does is &lt;em&gt;&quot;clear this register, and append any keystroke to it&quot;&lt;/em&gt;, and all that &lt;kbd&gt;@&lt;/kbd&gt; does is &lt;em&gt;&quot;evaluate a register as commands&quot;&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is nothing &quot;different&quot; about a macro, you can invoke any register as a macro.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To &lt;strong&gt;view&lt;/strong&gt; just use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo @a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just like any register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;:registers&lt;/code&gt; to view all registers.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To &lt;strong&gt;edit&lt;/strong&gt; you can do several things:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest way you be to just assign to &lt;code&gt;@a&lt;/code&gt;, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a='iasd&amp;lt;1b&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will start insert mode (&lt;code&gt;i&lt;/code&gt;), insert &lt;code&gt;asd&lt;/code&gt;, and Escape back to normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This isn't very useful for extensive editing; you could use functions (ie. &lt;code&gt;substitute()&lt;/code&gt;), or maybe appending something (&lt;code&gt;:let @a=@a . 'more'&lt;/code&gt;), but changing something in the middle isn't that easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found that the best way for this, is to start a new buffer with &lt;code&gt;:split&lt;/code&gt; or &lt;code&gt;:tabnew&lt;/code&gt; and edit the register by inserting it there, editing it, and then copying it back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;kbd&gt;&quot;ap&lt;/kbd&gt; which will insert the text in the buffer (where &lt;code&gt;a&lt;/code&gt; is your register):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iThis is A&amp;lt;1b&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I can just change the line to maybe:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iThis is an edited macro&amp;lt;1b&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I do &lt;kbd&gt;^v$&quot;ay&lt;/kbd&gt; to yank (copy) this line to the &lt;code&gt;a&lt;/code&gt; register:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;^&lt;/kbd&gt; for start of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;v&lt;/kbd&gt; for visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;$&lt;/kbd&gt; for end of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;&quot;ay&lt;/kbd&gt; yank the selection to register &lt;code&gt;a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you wish, you can do this without using visual mode with &lt;kbd&gt;^&quot;ay$&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can now use &lt;kbd&gt;@a&lt;/kbd&gt;, as if this is what you originally recorded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also just use &lt;kbd&gt;yy&lt;/kbd&gt;, and then &lt;kbd&gt;@&quot;&lt;/kbd&gt;, which is a bit faster. This will also copy the trailing newline, though, and may cause side-effects...  Another way to make this faster is to use a macro :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="88" LastEditDate="2016-06-05T19:37:42.570" LastActivityDate="2016-06-05T19:37:42.570" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="762" PostTypeId="2" ParentId="758" CreationDate="2015-02-13T14:21:46.097" Score="7" Body="&lt;p&gt;You could accomplish something like this using the argument list. The general idea is to collect all of the open windows into the argument list, then close all the splits, then use the argument list to open everything in a new way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, clear the argument list, in case it's already populated.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdelete *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, collect all the windows into the argument list.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabdo windo argadd %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabdo&lt;/code&gt; performs a command on each tab, visiting one at a time&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:windo&lt;/code&gt; does the same in each window of the current tabpage&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:argadd %&lt;/code&gt; adds the current buffer to the argument list&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now we have all of the windows in the argument list. Let's close all but one window.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabonly | only&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabonly&lt;/code&gt; closes all tab pages except the current one&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:only&lt;/code&gt; closes all windows except the current window in the current tab page&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Flip to the first argument.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:first&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now we'll cycle through all of our arguments and open them in the style of our choosing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdo tabedit %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change &lt;code&gt;tabedit&lt;/code&gt; to &lt;code&gt;split&lt;/code&gt; or &lt;code&gt;vsplit&lt;/code&gt; as desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: I haven't figured out why yet, but this duplicates the last window. We can just close it with &lt;code&gt;:quit&lt;/code&gt; (or &lt;code&gt;:q&lt;/code&gt; for short).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Caveats&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This clobbers your argument list, if you had one&lt;/li&gt;&#xA;&lt;li&gt;If you have &lt;code&gt;'equalalways'&lt;/code&gt; turned off (i.e. &lt;code&gt;:set noequalalways&lt;/code&gt;) and you're using this for opening windows in splits, you may quickly run out of screen space before opening all the windows&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="64" LastEditorUserId="64" LastEditDate="2015-02-13T14:39:54.997" LastActivityDate="2015-02-13T14:39:54.997" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="763" PostTypeId="2" ParentId="756" CreationDate="2015-02-13T14:35:13.010" Score="28" Body="&lt;p&gt;Plugins are sourced &lt;em&gt;after&lt;/em&gt; your &lt;code&gt;vimrc&lt;/code&gt; so there's no way to override a plugin mapping in your &lt;code&gt;vimrc&lt;/code&gt; if the plugin doesn't provide a way to do so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Placing your custom mapping in &lt;code&gt;~/.vim/after/plugin/mystuff.vim&lt;/code&gt; (the name of the file doesn't matter) should allow you to override the plugin mapping.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-02-13T15:24:45.193" LastActivityDate="2015-02-13T15:24:45.193" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="764" PostTypeId="1" CreationDate="2015-02-13T15:05:59.027" Score="15" ViewCount="32782" Body="&lt;p&gt;I've been receiving logged data in a text file that is just one long line with each value separated by a space. Is there a command or set of commands that will split one line into multiple lines?&lt;/p&gt;&#xA;" OwnerUserId="25" LastEditorUserId="24" LastEditDate="2015-02-15T09:11:20.123" LastActivityDate="2023-01-01T00:46:10.580" Title="How to split a line into multiple lines efficiently?" Tags="|command-line|whitespace|line-breaks|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="765" PostTypeId="2" ParentId="764" CreationDate="2015-02-13T15:09:39.573" Score="26" Body="&lt;p&gt;You could simply replace any consecutive space on the line with a newline using the command &lt;code&gt;:s/\s\+/\r/g&lt;/code&gt;. &lt;code&gt;\s\+&lt;/code&gt; mean one or more whitespace characters, and &lt;code&gt;\r&lt;/code&gt; is a newline, see &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Asubstitute&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :substitute&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#regexp&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help regexp&lt;/code&gt;&lt;/a&gt; for details. If you run the command on a line like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar&#xA;baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you have &lt;code&gt;hlsearch&lt;/code&gt; enabled and you don't want to clutter your screen with highlighted spaces everywhere, you can write a little function like the following to avoid it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SplitLineNicely()&#xA;    &quot; Save previous value of last search register&#xA;    let saved_last_search_pattern = @/&#xA;&#xA;    &quot; :substitute replaces the content of the search register with the `\s\+` &#xA;    &quot; pattern highlighting all whitespaces in the file&#xA;    substitute /\s\+/\r/g&#xA;&#xA;    &quot; Restore previous search register&#xA;    let @/ = saved_last_search_pattern&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2019-05-01T17:57:25.370" LastActivityDate="2019-05-01T17:57:25.370" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="766" PostTypeId="1" AcceptedAnswerId="2141" CreationDate="2015-02-13T18:25:16.847" Score="8" ViewCount="538" Body="&lt;p&gt;I am writing a VimL function that, in insert mode, allows a &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; through the opening part of a pair (&lt;code&gt;[&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt;, etc.) to delete the closing part of the pair if it is the next character after the cursor (much like &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;noreferrer&quot;&gt;auto-pairs&lt;/a&gt; and &lt;a href=&quot;https://github.com/Townk/vim-autoclose&quot; rel=&quot;noreferrer&quot;&gt;vim-autoclose&lt;/a&gt;). This function will be different because the closing part of the pair will &lt;strong&gt;not&lt;/strong&gt; be deleted if there are unbalanced pairs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The format is &lt;code&gt;&amp;lt;initial&amp;gt;  =&amp;gt;  &amp;lt;result-after-backspace&amp;gt;&lt;/code&gt; where my cursor is in front of the &lt;code&gt;|&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;((|)    =&amp;gt;   (|)&#xA;&#xA;((|))   =&amp;gt;   (|)&#xA;&#xA;(|)     =&amp;gt;   |&#xA;&#xA;(defn   =&amp;gt;   (defn&#xA;  (|)          |)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I determine whether or not the pairs are unbalanced before I go ahead and delete the closing pair?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tested both &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;noreferrer&quot;&gt;auto-pairs&lt;/a&gt; and &lt;a href=&quot;https://github.com/Townk/vim-autoclose&quot; rel=&quot;noreferrer&quot;&gt;vim-autoclose&lt;/a&gt;. With both plugins the closing part of the pair is always deleted. &lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastEditorUserId="24" LastEditDate="2015-02-14T05:46:54.377" LastActivityDate="2015-02-23T16:27:25.930" Title="Automatically delete closing pair without causing unbalanced pairs" Tags="|vimscript|delimiter-matching|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="767" PostTypeId="1" AcceptedAnswerId="777" CreationDate="2015-02-13T18:28:58.373" Score="6" ViewCount="12086" Body="&lt;p&gt;In my default Vim settings I've enabled a gutter and line numbers. Sometimes I copy some lines to clipboard in order to paste somewhere else. Currently I need to  disable line numbers and the gutter. Otherwise they are included selection and thus in the copied text. Then I select the lines with my mouse and copy them using &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;. After copying I can re-enable line numbers and gutter again. Is it possible without disabling line numbers and gutter?&lt;/p&gt;&#xA;" OwnerUserId="153" LastActivityDate="2015-02-13T21:23:15.903" Title="How to select and copy lines to clipboard which are selected by mouse without linenumbers and gutter?" Tags="|cut-copy-paste|os-clipboard|mouse|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="768" PostTypeId="2" ParentId="764" CreationDate="2015-02-13T18:33:55.300" Score="6" Body="&lt;p&gt;Using &lt;code&gt;vim&lt;/code&gt;'s substitution is probably one of the better ways to accomplish your task, but you can use a macro as well. Suppose we have the following data, with the cursor somewhere on line 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 a b c d e f&#xA;~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Starting in normal mode, hitting &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; will start recording a macro callable via &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;. Anything typed after &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; will be repeatable via aforementioned call. Our goal is to record normal commands that will be general enough to allow for seamless repetition. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, we may type &lt;kbd&gt;0&lt;/kbd&gt; to bring the cursor to the start of the line, then &lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;space&lt;/kbd&gt; to move the cursor to the first space. This allows us to then type &lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;enter&lt;/kbd&gt;, resulting in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 a&#xA;2 b c d e f&#xA;~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hitting &lt;kbd&gt;q&lt;/kbd&gt; now is a good idea as our reusable macro is ready for repetition. Somewhat arbitrarily, we note that there are 4 spaces left to replace with newlines. Thus by hitting, &lt;kbd&gt;4&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;, we repeat the &lt;code&gt;q&lt;/code&gt; macro 4 times resulting in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 a&#xA;2 b&#xA;3 c&#xA;4 d&#xA;5 e&#xA;6 f&#xA;~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that because of the way we set up the macro, it would have been safe to repeat the command over 9000 times, as it would only affect the current line, and since there were no spaces to the right of the last data entry, &lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;space&lt;/kbd&gt; will 'nicely' fail, preventing data from being replaced with newlines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to repeat from the beginning:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;space&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;enter&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;9001&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;provides our result.&lt;/p&gt;&#xA;" OwnerUserId="44" LastActivityDate="2015-02-13T18:33:55.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="769" PostTypeId="1" CreationDate="2015-02-13T18:37:24.763" Score="7" ViewCount="321" Body="&lt;p&gt;Is it possible to configure vim (obviously with &lt;code&gt;:set mouse=a&lt;/code&gt;) and/or gvim such that the visual selection modes automatically integrate with X's selection buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware of how to setup the copy registers to integrate with the clipboard, but I would like to integrate the selection system as well. Is it possible and, if so, how?&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="24" LastEditDate="2015-02-19T16:47:05.380" LastActivityDate="2015-02-19T16:47:05.380" Title="Can visual select mode be integrated with the Unix selection clipboard?" Tags="|visual-mode|gvim|mouse|os-clipboard|unix|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="770" PostTypeId="2" ParentId="767" CreationDate="2015-02-13T19:06:48.300" Score="4" Body="&lt;p&gt;A good general rule when using Vim is to not use the mouse&amp;mdash;Vim is designed from the ground up to be used with keyboard commands. In order to copy text, you can use the &lt;code&gt;y&lt;/code&gt; command to yank a particular selection or chunk of text. Like all other Vim commands, you can think of &lt;code&gt;y&lt;/code&gt; as a verb and give it modifiers, like &lt;code&gt;y2j&lt;/code&gt; to yank the current line and the next two down, or &lt;code&gt;ytm&lt;/code&gt; to yank from the current cursor position until just before the occurrence of m on the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're copying to the clipboard in order to paste into a different application, the Vim Tips wiki page on &lt;a href=&quot;http://vim.wikia.com/wiki/Accessing_the_system_clipboard&quot; rel=&quot;nofollow&quot;&gt;accessing the system clipboard&lt;/a&gt; may be of use to you. The specifics will probably depend on what OS you're using, and what version of Vim. I run Vim on Linux, and in my vimrc file I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard=unnamedplus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This lets me yank into the system clipboard, so I can &lt;code&gt;yy&lt;/code&gt; to grab the current line in Vim and then paste into whatever else I'm using.&lt;/p&gt;&#xA;" OwnerUserId="163" LastActivityDate="2015-02-13T19:06:48.300" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="771" PostTypeId="1" AcceptedAnswerId="776" CreationDate="2015-02-13T19:18:10.627" Score="8" ViewCount="954" Body="&lt;p&gt;When using gVim (on Windows; see below) to diff two files which both have very long paths relative to the current working directory, the dreaded &quot;press enter&quot; prompt appears during load, before rendering any of the useful diff information. &quot;Very long paths&quot; here are basically those that are long enough that both of them joined together are longer than whatever &lt;code&gt;columns&lt;/code&gt; is set to in my &lt;code&gt;.gvimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is extremely annoying. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I prevent this prompt from appearing in diff mode?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I am aware of &lt;code&gt;shortmess&lt;/code&gt; and currently have it set to &lt;code&gt;asI&lt;/code&gt;. &lt;code&gt;t&lt;/code&gt; and &lt;code&gt;T&lt;/code&gt; do not seem to have any appreciable effect.&lt;/li&gt;&#xA;&lt;li&gt;I would &lt;em&gt;prefer&lt;/em&gt; a solution that did not involve setting &lt;code&gt;cmdheight&lt;/code&gt; to some arbitrary large value, because that wastes precious vertical screen space.&lt;/li&gt;&#xA;&lt;li&gt;In my case, gVim is being invoked by an external program (Perforce), so I do not have control over the working directory I'm in before launching vim (it wouldn't matter anyhow, as one of the paths is always long and absolute); nor do I have any real control over ridiculous length of the paths.&lt;/li&gt;&#xA;&lt;li&gt;I &lt;em&gt;do&lt;/em&gt; have control over the arguments passed as part of the diff operation.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A gvim invocation that reproduces the issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim -u NONE -d C:\this\folder_creates_a_very_long\path_which_reproduces_the_problem\for_people_on_stackexchange\to_look_at\a.txt C:\that\folder_creates_a_very_long\path_which_reproduces_the_problem\for_people_on_stackexchange\to_look_at\a.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It causes vim to print the message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;C:\this\folder_creates_a_very_long\path_which_reproduces_the_problem\for_people_on_stackexchange\to_look_at\a.txt&quot; 1L, 3C&#xA;&quot;C:\this\folder_creates_a_very_long\path_which_reproduces_the_problem\for_people_on_stackexchange\to_look_at\a.txt&quot; 1L, 3C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user72" LastEditorDisplayName="user72" LastEditDate="2015-02-13T20:21:48.657" LastActivityDate="2018-05-27T23:11:33.170" Title="How can I suppress the &quot;press enter&quot; prompt when opening files in diff mode?" Tags="|vimdiff|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="772" PostTypeId="2" ParentId="769" CreationDate="2015-02-13T19:26:46.123" Score="5" Body="&lt;p&gt;I understand that you are set up with the features necessary for copy and pasting with the system clipboard, but I want to be a tad redundant as those registers can be a tad challenging to set up. It's all about the features that are enabled with your install of Vim. In OS X and Linux, the clipboard feature needs to be enabled, and Linux usually also requires the xterm_clipboard setting. You can tell if these are set by running &lt;code&gt;vim --version&lt;/code&gt; and seeing if there is a &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;-&lt;/code&gt; for on or off respectively next to the feature name. There are notes on how to do this with &lt;a href=&quot;https://stackoverflow.com/questions/677986/vim-copy-selection-to-os-x-clipboard&quot;&gt;OS X here&lt;/a&gt;, and &lt;a href=&quot;https://askubuntu.com/questions/347519/unable-to-copy-from-vim-to-system-clipboard&quot;&gt;Ubuntu here&lt;/a&gt;. There is also a &lt;a href=&quot;http://vimcasts.org/episodes/accessing-the-system-clipboard-from-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;nice summary of this information on a blog here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;https://superuser.com/questions/348207/prevent-macvim-copying-every-visual-selection-to-clipboard&quot;&gt;this superuser post&lt;/a&gt;, macvim (and most likely gvim in general) will (assuming the clipboard is set up properly) automatically copy selections into the system clipboard if &lt;code&gt;set guioptions+=a&lt;/code&gt; is set. This seems to be the key to working with X's selection buffer. Quickly viewing the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27guioptions%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim documentation on guioptions&lt;/a&gt;, putting &lt;code&gt;set guioptions+=a&lt;/code&gt; should do as you desire for gVim. For more info check out this post &lt;a href=&quot;https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim&quot;&gt;by Carpetsmoker here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For console Vim I found this &lt;a href=&quot;http://choorucode.com/2014/05/20/how-to-disable-autoselect-in-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;article on how to disable what you are after&lt;/a&gt;... it seems that putting the following in your &lt;code&gt;.vimrc&lt;/code&gt; will result in happy days:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; set clipboard += autoselect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For me, this successfully copied visual selections into the &lt;code&gt;+&lt;/code&gt; register.&lt;/p&gt;&#xA;" OwnerUserId="44" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-13T23:42:57.957" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="773" PostTypeId="1" AcceptedAnswerId="822" CreationDate="2015-02-13T19:38:49.987" Score="24" ViewCount="23032" Body="&lt;p&gt;I'm using the Taglist and NerdTree plugins quite often. Usually the window that opens in the left side is too small and I need to extend it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I usually do: &lt;kbd&gt;10&lt;/kbd&gt; &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;w&lt;/kbd&gt; &lt;kbd&gt;&amp;gt;&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to change the default width of the window of NerdTree and Taglist?&lt;/p&gt;&#xA;" OwnerUserId="496" LastEditorUserId="24" LastEditDate="2015-02-19T10:32:05.910" LastActivityDate="2015-02-19T10:32:05.910" Title="How do I change the default size of plugin window (NerdTree, Taglist, etc)?" Tags="|plugin-nerdtree|vim-windows|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="774" PostTypeId="1" CreationDate="2015-02-13T19:42:51.443" Score="1" ViewCount="20" Body="&lt;p&gt;Sometimes I delete a line and when I want to yank it somewhere else I found out that I need to delete another line.&#xA;How can I delete the new line without overriding the the content of the line that I deleted before in the register ?&lt;/p&gt;&#xA;" OwnerUserId="496" LastEditorUserId="51" LastEditDate="2015-02-15T00:43:03.403" LastActivityDate="2015-02-15T00:43:03.403" Title="do a command without altering the register" Tags="|cut-copy-paste|register|" AnswerCount="0" CommentCount="1" ClosedDate="2015-02-13T21:43:15.707" ContentLicense="CC BY-SA 3.0" />
  <row Id="775" PostTypeId="2" ParentId="773" CreationDate="2015-02-13T20:02:23.867" Score="4" Body="&lt;p&gt;I have this problem all the time with splits not being tall enough so I've added this key binding to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; open the current split all the way&#xA;map &amp;lt;c-o&amp;gt; :res 100&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can adapt this to make the split wider by using &lt;code&gt;:vertical resize&lt;/code&gt;. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;c-o&amp;gt; :vertical resize +10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will increase the vertical size of the split by 10 columns when you type &lt;code&gt;Control + o&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="446" LastActivityDate="2015-02-13T20:02:23.867" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="776" PostTypeId="2" ParentId="771" CreationDate="2015-02-13T20:37:04.260" Score="7" Body="&lt;p&gt;This is controlled with the &lt;code&gt;shortmess&lt;/code&gt; option; specifically, &lt;code&gt;set shortmess=Ot&lt;/code&gt; seems to do the trick for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meaning of the &lt;code&gt;Ot&lt;/code&gt; flags:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      O     message for reading a file overwrites any previous message.&#xA;            Also for quickfix message (e.g., &quot;:cn&quot;).&#xA;      t     truncate file message at the start if it is too long to fit&#xA;            on the command-line, &quot;&amp;lt;&quot; will appear in the left most column.&#xA;            Ignored in Ex mode.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that setting &lt;code&gt;compatible&lt;/code&gt; should also work, the default for &lt;code&gt;shortmess&lt;/code&gt; is &lt;code&gt;filnxtToO&lt;/code&gt; when this is enabled, and it's empty when it's disabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27shortmess%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'shortmess'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-13T20:45:53.177" LastActivityDate="2015-02-13T20:45:53.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="777" PostTypeId="2" ParentId="767" CreationDate="2015-02-13T21:23:15.903" Score="7" Body="&lt;p&gt;The trick is to enable the mouse with &lt;code&gt;:set mouse=a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, Vim doesn't handle the mouse; the terminal emulator does, and from the terminal emulator's perspective &quot;it's all text&quot;, it can't distinguish between your &quot;number&quot; or gutter.&lt;br&gt;&#xA;gVim &quot;emulates&quot; a terminal emulator in many ways, and acts in the same way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then enabling the mouse, it's Vim that does all the mouse handling, and Vim &lt;em&gt;does&lt;/em&gt; know what your gutter is, and what your actual text buffer is, so it can handle selection more intelligently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that using &lt;code&gt;set mouse=a&lt;/code&gt; has some side-effects; clicking anywhere in Vim will put the cursor there, and you can now scroll Vim buffers with your mouse wheel, instead of your terminal's scrollback (both can be considered either bugs or features, depending on your preferences).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-13T21:23:15.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="778" PostTypeId="1" AcceptedAnswerId="790" CreationDate="2015-02-13T21:39:20.137" Score="52" ViewCount="34512" Body="&lt;p&gt;I know that &lt;a href=&quot;https://vi.stackexchange.com/questions/625/how-do-i-use-vim-as-a-diff-tool&quot;&gt;Vim's diff mode&lt;/a&gt; (&lt;code&gt;vimdiff&lt;/code&gt;) allows us to compare the contents of two (or more) files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it is possible to compare content of multiple files across directories in order to merge two directories recursively (like DiffMerge and similar tools)?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2021-07-11T03:01:43.040" Title="How to diff and merge two directories?" Tags="|filesystem|vimdiff|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="779" PostTypeId="1" CreationDate="2015-02-13T22:00:43.740" Score="29" ViewCount="13811" Body="&lt;p&gt;On Linux systems, packaged Vim typically has only one of either &lt;code&gt;python&lt;/code&gt; or &lt;code&gt;python3&lt;/code&gt; enabled. It is possible for &lt;a href=&quot;http://vimhelp.appspot.com/if_pyth.txt.html#python-2-and-3&quot; rel=&quot;noreferrer&quot;&gt;both to be enabled&lt;/a&gt; (using &lt;code&gt;python/dyn&lt;/code&gt; and &lt;code&gt;python3/dyn&lt;/code&gt;), but during a session, only one can be used. &lt;a href=&quot;https://www.mail-archive.com/vim_dev@googlegroups.com/msg22562.html&quot; rel=&quot;noreferrer&quot;&gt;This mailing list discussion said&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It depends on how the Python libraries are built. On Debian-based systems&#xA;  (for reasons I don't recall offhand), they're built such that RTLD_GLOBAL&#xA;  has to be used to get access to the symbols.  This prevents loading both&#xA;  libpython2.x and libpython3.x in the same process.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What can be done to enable loading of both in the same session?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Options that I can see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Rebuild the Python{2,3} packages so that &lt;code&gt;RTLD_GLOBAL&lt;/code&gt; (whatever that may be) isn't needed.&lt;/li&gt;&#xA;&lt;li&gt;Somehow get the library loaded earlier to be unloaded (?!) by Vim. (Is that even possible?)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For any particulars of the distro, assume, in increasing order of specificity:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Debian-based &lt;/li&gt;&#xA;&lt;li&gt;Ubuntu &lt;/li&gt;&#xA;&lt;li&gt;Ubuntu 14.04&lt;/li&gt;&#xA;&lt;li&gt;Or, Arch Linux, if a Debian-based system is too complex.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that I have &lt;a href=&quot;https://askubuntu.com/a/585259/158442&quot;&gt;got Vim to build&lt;/a&gt; with dynamic loading support for both, so building Vim isn't a problem.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.647" LastActivityDate="2016-09-14T00:53:08.057" Title="How do I get Vim to be able to run both python and python3 on a Linux system in the same session?" Tags="|linux|vimscript-python|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="780" PostTypeId="1" AcceptedAnswerId="784" CreationDate="2015-02-13T22:07:27.380" Score="69" ViewCount="24626" Body="&lt;p&gt;How to jump between matching tags (such as &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt;, etc.) when editing HTML/XHTML/XML documents similarly as &lt;kbd&gt;%&lt;/kbd&gt; is used to jump between matching parentheses?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="51" LastEditDate="2015-02-13T22:15:09.160" LastActivityDate="2021-03-20T23:22:04.277" Title="How to jump between matching HTML/XML tags?" Tags="|cursor-movement|delimiter-matching|filetype-xml|filetype-html|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="781" PostTypeId="5" CreationDate="2015-02-13T22:47:15.173" Score="0" Body="" OwnerUserId="51" LastEditorUserId="24" LastEditDate="2015-02-19T10:51:47.500" LastActivityDate="2015-02-19T10:51:47.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="782" PostTypeId="4" CreationDate="2015-02-13T22:47:15.173" Score="0" Body="Questions about interaction with the desktop windowing environment. For questions about windows for viewing buffers within Vim, use [vim-windows]." OwnerUserId="51" LastEditorUserId="24" LastEditDate="2015-02-19T10:51:33.697" LastActivityDate="2015-02-19T10:51:33.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="783" PostTypeId="2" ParentId="780" CreationDate="2015-02-14T00:19:04.183" Score="47" Body="&lt;p&gt;You can jump between tags using visual operators, for example:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Place the cursor on the tag.&lt;/li&gt;&#xA;&lt;li&gt;Enter visual mode by pressing &lt;kbd&gt;v&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Select the outer tag block by pressing &lt;kbd&gt;a&lt;/kbd&gt;+&lt;kbd&gt;t&lt;/kbd&gt; or &lt;kbd&gt;i&lt;/kbd&gt;+&lt;kbd&gt;t&lt;/kbd&gt; for inner tag block.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Your cursor should jump forward to the matching closing html/xml tag. To jump backwards from closing tag, press &lt;kbd&gt;o&lt;/kbd&gt; or &lt;kbd&gt;O&lt;/kbd&gt; to jump to opposite tag.&lt;/p&gt;&#xA;&lt;p&gt;Now you can either exit visual by pressing &lt;kbd&gt;Esc&lt;/kbd&gt;, change it by &lt;kbd&gt;c&lt;/kbd&gt; or copy by &lt;kbd&gt;y&lt;/kbd&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;To record that action into register, press &lt;kbd&gt;qq&lt;/kbd&gt; to start recording, perform tag jump as above (including &lt;kbd&gt;Esc&lt;/kbd&gt;), press &lt;kbd&gt;q&lt;/kbd&gt; to finish. Then to invoke jump, press &lt;kbd&gt;@q&lt;/kbd&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;See more help at &lt;code&gt;:help visual-operators&lt;/code&gt; or &lt;code&gt;:help v_it&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;kbd&gt;at&lt;/kbd&gt;      a &lt;code&gt;&amp;lt;tag&amp;gt; &amp;lt;/tag&amp;gt;&lt;/code&gt; block (with tags)&lt;/p&gt;&#xA;&lt;p&gt;&lt;kbd&gt;it&lt;/kbd&gt;      inner &lt;code&gt;&amp;lt;tag&amp;gt; &amp;lt;/tag&amp;gt;&lt;/code&gt; block&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Alternatively use plugin such as &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=39&quot; rel=&quot;noreferrer&quot;&gt;matchit.vim&lt;/a&gt; or &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;noreferrer&quot;&gt;surround.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/126/using-in-languages-without-curly-braces&quot;&gt;Using % in languages without curly braces&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/500989/jump-to-matching-xml-tags-in-vim&quot;&gt;Jump to matching XML tags in Vim&lt;/a&gt; at stackoverflow SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/4116362/how-can-i-find-the-close-html-tag-quickly-in-vim&quot;&gt;How can I find the close html tag quickly in vim?&lt;/a&gt; at stackoverflow SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/6270396/navigating-html-tags-in-vim&quot;&gt;Navigating HTML tags in Vim&lt;/a&gt; at stackoverflow SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://superuser.com/questions/189815/vim-how-to-navigate-between-begin-and-end-html-tag&quot;&gt;How to navigate between begin and end html tag?&lt;/a&gt; at superuser SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/38187/vim-jump-from-one-xml-tag-to-the-closing-one&quot;&gt;VIM jump from one xml tag to the closing one&lt;/a&gt; at Unix SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://superuser.com/questions/182355/how-can-i-select-an-html-tags-content-in-vim&quot;&gt;How can I select an html tag's content in Vim?&lt;/a&gt; at superuser SE&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="14340" LastEditDate="2020-07-31T16:20:55.253" LastActivityDate="2020-07-31T16:20:55.253" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="784" PostTypeId="2" ParentId="780" CreationDate="2015-02-14T01:10:15.403" Score="61" Body="&lt;p&gt;Vim ships with a macro called matchit that does this for you; all you need to do is activate it with &lt;code&gt;runtime macros/matchit.vim&lt;/code&gt; in your vimrc. This will enable you to jump from, eg, a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; to its &lt;code&gt;&amp;lt;/div&amp;gt;&lt;/code&gt;. Note that your cursor will have to be inside the angle brackets; if you're on the angle brackets, &lt;kbd&gt;%&lt;/kbd&gt; will jump from one bracket to the other as normal.&lt;/p&gt;&#xA;" OwnerUserId="163" LastActivityDate="2015-02-14T01:10:15.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="785" PostTypeId="2" ParentId="756" CreationDate="2015-02-14T04:28:33.333" Score="26" Body="&lt;p&gt;As mentioned in other answers, the plugins are sourced after the vimrc is done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to keep your overrides in your vimrc instead of doing an after plugin, you can use this &quot;trick&quot; anywhere in your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * noremap &amp;lt;leader&amp;gt;cc echo &quot;my purpose&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#VimEnter&quot;&gt;&lt;code&gt;:help VimEnter&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;VimEnter: After doing all the startup stuff, including loading .vimrc files, executing the &quot;-c cmd&quot; arguments, creating all windows and loading the buffers in them.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, anything you put in a VimEnter auto command gets run after Vim is ready. Using VimEnter this way allows you to keep all your mappings with your other settings where you are used to keeping them: &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-02-14T04:28:33.333" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="786" PostTypeId="2" ParentId="742" CreationDate="2015-02-14T05:45:02.227" Score="10" Body="&lt;p&gt;I couldn't find any way to do this in a regular Vim. However, if you are willing to patch Vim, the following may work for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The very simple patch (applied against Vim-7.4.052) disables the actual update to the screen that clears the history at the end of a normal command. It does this by returning whether or not &lt;code&gt;showcmd_is_clear&lt;/code&gt; is set prior to updating the display,. (alternatively, you can comment out the if statement and leave just the one original &lt;code&gt;return&lt;/code&gt; line. &lt;strong&gt;note&lt;/strong&gt;: The patch below didn't paste very well; you may have to apply this by hand, though it is just a short one-liner. &lt;strong&gt;note&lt;/strong&gt;: I did &lt;em&gt;not&lt;/em&gt; comment out the actual &lt;code&gt;display_showcmd()&lt;/code&gt; because it appears to be used in visual mode to update the display of the number of selected lines or other possibly other stuff. I have not extensively tested this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- src/normal.c    2015-02-14 00:21:23.286352257 -0500&#xA;+++ src/normal.c    2015-02-14 00:21:25.238352173 -0500&#xA;@@ -4029,6 +4029,7 @@&#xA;    /* Don't actually display something if there is nothing to clear. */&#xA;    if (showcmd_is_clear)&#xA;        return;&#xA;+   return;&#xA;     }&#xA;&#xA;     display_showcmd()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Dg1gi.gif&quot; alt=&quot;Screencast showing the patch&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few interesting things to note:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This shows even simple movements, like &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, etc.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;x&lt;/code&gt; command actually becomes &lt;code&gt;dl&lt;/code&gt; in the showcmd_buf.&lt;/li&gt;&#xA;&lt;li&gt;Commands that change the bottom line obliterate the showcmd area (for example, using the &lt;code&gt;:&lt;/code&gt; command, or entering insert mode (at least in my setup))&lt;/li&gt;&#xA;&lt;li&gt;The capture program stopped recording many strokes after I typed a &lt;code&gt;&quot;&lt;/code&gt;, but my key sequence is visible in the vim window for my long register specified yank.&lt;/li&gt;&#xA;&lt;li&gt;Not shown in the cast, but hitting &lt;kbd&gt;esc&lt;/kbd&gt; in normal mode shows &lt;code&gt;^[&lt;/code&gt; in the showcmd area&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-02-14T05:45:02.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="787" PostTypeId="2" ParentId="778" CreationDate="2015-02-14T06:33:32.187" Score="4" Body="&lt;p&gt;I've wanted the same for a while. The best solution I found was to use &lt;a href=&quot;https://github.com/Osse/vdwrap&quot; rel=&quot;nofollow&quot;&gt;vdwrap&lt;/a&gt;, which works amazingly well. All it does is wrap &lt;code&gt;git difftool --dir-diff&lt;/code&gt; for &lt;code&gt;vimdiff&lt;/code&gt;. It doesn't require any vim plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you need to do is tell &lt;code&gt;git difftool&lt;/code&gt; to use &lt;code&gt;vdwrap&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git config --global difftool.vdwrap.cmd '/full/path/vdwrap $LOCAL $REMOTE'&#xA;git config --global diff.tool vdwrap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The next time you use git difftool, it will open Vim with separate Vim tabs for each pairs of files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A caveat is that it's a Zsh script. It should be pretty simple to convert it to a bash script but I haven't given that a go.&lt;/p&gt;&#xA;" OwnerUserId="246" LastActivityDate="2015-02-14T06:33:32.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="788" PostTypeId="1" AcceptedAnswerId="789" CreationDate="2015-02-14T12:03:11.130" Score="29" ViewCount="14159" Body="&lt;p&gt;I would like to edit files passed in pipeline input using vim in non-interactive way or edit files in-place (similar to &lt;code&gt;sed&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Few examples using &lt;code&gt;sed&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sed -i'.bak' s/foo/test/g file   # Edit file in-place.&#xA;$ cat file | sed s/foo/test/g      # Parse file in pipeline.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I could read in &lt;a href=&quot;http://mywiki.wooledge.org/BashFAQ/021#Using_nonstandard_tools&quot;&gt;here&lt;/a&gt;, that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;sed&lt;/code&gt; is a &lt;strong&gt;S&lt;/strong&gt;tream &lt;strong&gt;ED&lt;/strong&gt;itor, not a file editor. Nevertheless, people everywhere tend to abuse it for trying to edit files. It doesn't edit files.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Secondly some options such as in-place editing (&lt;code&gt;-i&lt;/code&gt;) is portable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How the same functionality can be achieved in vim?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-10-17T17:29:35.277" LastActivityDate="2015-10-17T17:29:35.277" Title="How to edit files non-interactively (e.g. in pipeline)?" Tags="|command-line|substitute|ex-mode|invocation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="789" PostTypeId="2" ParentId="788" CreationDate="2015-02-14T12:15:50.463" Score="39" Body="&lt;p&gt;To edit file non-interactively using &lt;code&gt;ex&lt;/code&gt; (&lt;code&gt;vi&lt;/code&gt; is the visual mode for &lt;code&gt;ex&lt;/code&gt;), you can use &lt;code&gt;+{command}&lt;/code&gt; or &lt;code&gt;-c {command}&lt;/code&gt; parameters which allows you to execute the vi commands after the first file has been read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;ex&lt;/code&gt; is a standard command-line editor (similar to &lt;code&gt;ed&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;a href=&quot;http://linux.die.net/man/1/vipe&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;vipe&lt;/code&gt;&lt;/a&gt; (a Vim command pipe editor) should be used which is part of &lt;code&gt;moreutils&lt;/code&gt; package and it will allows you to run your editor in the middle of a unix pipeline and edit the data that is being piped between programs.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Examples&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Simple standard input and output using pipes can be achieved by this shell syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex -sc'%p|q!' &amp;lt;(echo Example)&#xA;$ echo Example | ex -sc'%p|q!' /dev/stdin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is simple example how to print the file after substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex /etc/hosts +%s/127/128/ge -sc'%p|q!'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More examples for editing files in-place:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +'%s/127/128/g' -cswq file&#xA;$ ex -sc '%s/olddomain\.com/newdomain.com/g|x' file&#xA;$ printf '%s\n' 'g/olddomain\.com/s//newdomain.com/g' w q | ex -s file&#xA;$ ex -s &quot;$file&quot; &amp;lt;&amp;lt;&amp;lt; $'g/old/s//new/g\nw\nq'&#xA;$ ex -sc 'argdo %s/old/new/ge|x' ./**&#xA;$ find . -type f -exec ex -sc '%s/old/new/g|x' {} \;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;-s {scriptin}&lt;/code&gt; so the commands are loaded from the file, in example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ printf &quot;%s\n&quot; '%s/foo/test/ge' 'wq' &amp;gt; cmds.vim&#xA;$ vim -s cmds.vim -es file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or using I/O redirection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim file &amp;lt; cmds.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To edit one file and save the changes to another, check the following examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +%s/127/128/g -sc'wq! new_file' /etc/hosts&#xA;$ cat /etc/hosts /etc/fstab | vim - -es '+:%s/foo/test/g' '+:wq! file3'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;More practical examples.&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikibooks.org/wiki/Learning_the_vi_Editor/Vim/Modes#Ex-mode&quot; rel=&quot;noreferrer&quot;&gt;Real live example&lt;/a&gt; from the &lt;a href=&quot;https://en.wikipedia.org/wiki/RPM_Package_Manager&quot; rel=&quot;noreferrer&quot;&gt;RPM&lt;/a&gt; specification:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -E -s Makefile &amp;lt;&amp;lt;-EOF&#xA;   :%substitute/CFLAGS = -g$/CFLAGS =-fPIC -DPIC -g/&#xA;   :%substitute/CFLAGS =$/CFLAGS =-fPIC -DPIC/&#xA;   :%substitute/ADAFLAGS =$/ADAFLAGS =-fPIC -DPIC/&#xA;   :update&#xA;   :quit&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://unix.stackexchange.com/q/6389/21471&quot;&gt;Extracting html tags&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -s +'bufdo!/&amp;lt;div.*id=.the_div_id/norm nvatdggdG&quot;2p' +'bufdo!%p' -cqa! *.html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/30040839/55075&quot;&gt;Removing XML tags&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -s +'%s/&amp;lt;[^&amp;gt;].\{-}&amp;gt;//ge' +%p +q! file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/33053842/55075&quot;&gt;Removing style tag from the header&lt;/a&gt; and print the parsed output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;curl -s http://example.com/ | ex -s +'/&amp;lt;style.*/norm nvatd' +%p -cq! /dev/stdin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/33053678/55075&quot;&gt;Parse html&lt;/a&gt; with multiple complex rules:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -V1 $PAGE &amp;lt;&amp;lt;-EOF&#xA;  &quot; Correcting missing protocol, see: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2359 &quot;&#xA;  %s,'//,'http://,ge&#xA;  %s,&quot;//,&quot;http://,ge&#xA;  &quot; Correcting relative paths, see: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2359 &quot;&#xA;  %s,[^,]\zs'/\ze[^&amp;gt;],'http://www.example.com/,ge&#xA;  %s,[^,]\zs&quot;/\ze[^&amp;gt;],&quot;http://www.example.com/,ge&#xA;  &quot; Remove the margin on the left of the main block. &quot;&#xA;  %s/id=&quot;doc_container&quot;/id=&quot;doc_container&quot; style=&quot;min-width:0px;margin-left : 0px;&quot;/g&#xA;  %s/&amp;lt;div class=&quot;outer_page/&amp;lt;div style=&quot;margin: 0px;&quot; class=&quot;outer_page/g&#xA;  &quot; Remove useless html elements. &quot;&#xA;  /&amp;lt;div.*id=&quot;global_header&quot;/norm nvatd&#xA;  wq &quot; Update changes and quit.&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even more examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://mywiki.wooledge.org/BashFAQ/021&quot; rel=&quot;noreferrer&quot;&gt;How can I replace a string with another string in a variable, a stream, a file, or in all the files in a directory?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://superuser.com/questions/22455/vim-what-is-the-ex-mode-for-batch-processing-for&quot;&gt;What is the EX-mode for batch processing for?&lt;/a&gt; at superuser SE&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/29736874/55075&quot;&gt;Convert tabs to spaces in every file of a directory?&lt;/a&gt; at SO&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/23657918/55075&quot;&gt;Remove trailing whitespaces from all files recursively?&lt;/a&gt; at SO&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/798/how-to-write-whole-buffer-to-standard-output-from-the-command-line&quot;&gt;How to write whole buffer to standard output from the command line?&lt;/a&gt; at Vim SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/14107/is-it-possible-to-execute-a-vim-script-in-a-non-interactive-mode&quot;&gt;Is it possible to execute a VIM script in a non-interactive mode?&lt;/a&gt; at unix SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/10686183/pipe-vim-buffer-to-stdout&quot;&gt;Pipe Vim buffer to stdout&lt;/a&gt; at SO&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/3219479/vim-write-buffer-content-to-stdout&quot;&gt;write buffer content to stdout&lt;/a&gt; at SO&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikibooks.org/wiki/Learning_the_vi_Editor/Vim/Modes&quot; rel=&quot;noreferrer&quot;&gt;Learning the vi Editor/Vim/Modes&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/3299/467&quot;&gt;How to remove inner content of html tag conditionally?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-10-17T00:19:19.873" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="790" PostTypeId="2" ParentId="778" CreationDate="2015-02-14T13:12:33.723" Score="44" Body="&lt;p&gt;There is &lt;a href=&quot;https://github.com/will133/vim-dirdiff&quot; rel=&quot;noreferrer&quot;&gt;DirDiff.vim&lt;/a&gt; plugin to diff and merge two directories recursively.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;It performs a recursive diff on two directories and generate a diff&#xA;&amp;quot;window&amp;quot;. Based on that window you can perform various diff operations&#xA;such as opening two files in Vim's diff mode, copy the file or&#xA;directory recursively to the other, or remove the directory tree from&#xA;the source directory.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Usage:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:DirDiff &amp;lt;dir1&amp;gt; &amp;lt;dir2&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For more information / help: &lt;code&gt;:help dirdiff&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thus from the command line: &lt;code&gt;vim -c 'DirDiff foo bar'&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;See the screenshot:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/will133/vim-dirdiff#vim-dirdiff&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CM7U2.png&quot; alt=&quot;wlee screenshot&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(video) &lt;a href=&quot;http://www.youtube.com/watch?v=LQZBiHRo_UU&quot; rel=&quot;noreferrer&quot;&gt;DirDiff.vim, diff and merge two directories recursively&lt;/a&gt; by Yu-Jie Lin at YouTube&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://web.archive.org/web/20150618154142/http://dedm.livejournal.com:80/115224.html&quot; rel=&quot;noreferrer&quot;&gt;Recursively compare and merge directories?&lt;/a&gt; at dedm blog&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://dedm.livejournal.com/115224.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LHG23.png&quot; alt=&quot;two random directories&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="51" LastEditDate="2021-07-11T03:01:43.040" LastActivityDate="2021-07-11T03:01:43.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="792" PostTypeId="1" AcceptedAnswerId="794" CreationDate="2015-02-14T14:23:35.307" Score="18" ViewCount="11068" Body="&lt;p&gt;I've a file of source code written in a programming language (e.g. PHP) and I would like to convert it into a HTML file, so I can publish it on web in order to share my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By conversion I mean, for example, converting new lines into &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt; tags so that the text will keep the same formatting both in the text editor and in the web browser. Ideally it should also preserve syntax highlighting so it can be also printed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this achievable in Vim? If so, how?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="13" LastEditDate="2015-02-16T12:02:45.970" LastActivityDate="2015-02-18T13:23:04.260" Title="How to convert a source code file into HTML?" Tags="|filetype-html|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="793" PostTypeId="2" ParentId="792" CreationDate="2015-02-14T14:42:12.240" Score="6" Body="&lt;p&gt;As I understood you, you want to convert content of current window to HTML.&#xA;Try to run this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:runtime! syntax/2html.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;more info here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help convert-to-HTML&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastActivityDate="2015-02-14T14:42:12.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="794" PostTypeId="2" ParentId="792" CreationDate="2015-02-14T14:52:12.920" Score="25" Body="&lt;p&gt;The following vim command would creates an html rendering of the current file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:TOhtml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It saves the file in the same folder (with .html extension) and it will include styles, foreground/background colours and &lt;a href=&quot;https://en.wikipedia.org/wiki/Syntax_highlighting&quot; rel=&quot;noreferrer&quot;&gt;syntax highlighting&lt;/a&gt;, so the file can be straight web published as well as printed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more options (like adding line numbers, compability with old browsers, etc.), check: &lt;code&gt;:help TOhtml&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To convert file non-interactively, try the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -E -s -c &quot;let g:html_no_progress=1&quot; -c &quot;syntax on&quot; -c &quot;set ft=c&quot; -c &quot;runtime syntax/2html.vim&quot; -cwqa myfile.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/2915547/convert-codes-to-html-with-css-style&quot;&gt;Convert codes to HTML with CSS style&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-18T13:23:04.260" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="795" PostTypeId="1" AcceptedAnswerId="796" CreationDate="2015-02-14T15:02:51.390" Score="6" ViewCount="715" Body="&lt;p&gt;In example, I would like to paste the current time or date into editor by using external commands (such as &lt;code&gt;date&lt;/code&gt;) without leaving vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How this can be achieved?&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2019-10-23T19:56:59.543" Title="How to dump output from external command into editor?" Tags="|external-command|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="796" PostTypeId="2" ParentId="795" CreationDate="2015-02-14T15:14:10.587" Score="7" Body="&lt;p&gt;Simply run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!date&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(or whatever command you wish to dump into the current buffer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will replace the entire buffer with the command's output. If you don't want this, use &lt;code&gt;read&lt;/code&gt; instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:read !date&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, you can replace a certain line with the output of an external command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:2!date  replace line 2 with the current date&#xA;:$!date  replace the last line with the current date&#xA;:.!date  replace the current line with the current date&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also works with &lt;code&gt;read&lt;/code&gt;, but appends after that line instead (ex. use &lt;code&gt;:$read !date&lt;/code&gt; to append the current date to the file).&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-14T15:14:10.587" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="797" PostTypeId="2" ParentId="795" CreationDate="2015-02-14T16:49:18.357" Score="2" Body="&lt;p&gt;In addition Doorknob answer, it's also possible to use the shortcut for &lt;code&gt;read&lt;/code&gt; as &lt;code&gt;r!&lt;/code&gt;, in example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r!date&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some other useful example would include doing some math like calculating number of bytes in gigabyte:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r! echo $((1024**3))&#xA;:r! echo $((1024*1024*1024))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-02-14T16:49:18.357" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="798" PostTypeId="1" AcceptedAnswerId="800" CreationDate="2015-02-14T17:15:23.933" Score="10" ViewCount="4379" Body="&lt;p&gt;I would like to write whole buffer into standard output (&lt;code&gt;/dev/stdout&lt;/code&gt;) instead of the file and the following command works as expected while editing the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w &amp;gt;&amp;gt; /dev/stdout&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Hint: Press &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;L&lt;/kbd&gt; to refresh the screen.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work as expected when I'm trying to do the same from the command line (&lt;a href=&quot;https://vi.stackexchange.com/q/788/467&quot;&gt;non-interactively&lt;/a&gt;), in example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo This is example. | vim - '+:w &amp;gt;&amp;gt; /dev/stdout' '+:q!'&#xA;Vim: Reading from stdin...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The same with &lt;code&gt;:w !tee&lt;/code&gt;, &lt;code&gt;:x! /dev/stdout&lt;/code&gt;, &lt;code&gt;:%print&lt;/code&gt; and similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before quit, it's saying: &lt;code&gt;[Device] 1L, 17C appended&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way of forcing vim to write the standard input into standard output in the middle of a pipe? Maybe it's somehow buffered?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-07-28T22:28:49.497" Title="How to write whole buffer to standard output from the command line?" Tags="|command-line|invocation|unix|ex-mode|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="799" PostTypeId="2" ParentId="798" CreationDate="2015-02-14T18:01:25.360" Score="3" Body="&lt;p&gt;&lt;a href=&quot;http://manpages.ubuntu.com/vipe.1&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;vipe&lt;/code&gt;&lt;/a&gt; is a convenient tool for editing pipelines, part of the &lt;code&gt;moreutils&lt;/code&gt; package. It is a wrapper for editors (including the &lt;code&gt;vi&lt;/code&gt; which gives it its name). It uses the &lt;code&gt;EDITOR&lt;/code&gt; environment variable to set the editor, so, like with other tools that make use of &lt;code&gt;EDITOR&lt;/code&gt; (such as &lt;code&gt;crontab&lt;/code&gt;, &lt;code&gt;visudo&lt;/code&gt;, etc.), you can script actions using that variable. For example, you can change it to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo foo | EDITOR='vim +:s/foo/bar/ +wq' vipe | tail&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, complicated actions might devolve to quoting hell, so you could write a script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#! /bin/sh&#xA;&#xA;vim &quot;+:s/foo/bar&quot; '+wq' &quot;$@&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And use &lt;code&gt;EDITOR=&quot;sh /path/to/script&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-02-14T19:16:19.893" LastActivityDate="2015-02-14T19:16:19.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="800" PostTypeId="2" ParentId="798" CreationDate="2015-02-14T18:07:35.180" Score="10" Body="&lt;p&gt;To print buffer to shell standard output, &lt;code&gt;vim&lt;/code&gt; needs to start in Ex mode, otherwise it'll open &quot;normal&quot; way with its own window and clear any output buffers on quit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the simplest working example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo foo | vim -e '+%print' '+q!' /dev/stdin&#xA;foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or even shorter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo foo | ex +%p -cq! /dev/stdin&#xA;$ echo foo | ex +&quot;%p|q!&quot; /dev/stdin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: The command &lt;code&gt;vim -e&lt;/code&gt; is basically equivalent to &lt;a href=&quot;https://en.wikipedia.org/wiki/Ex_(text_editor)&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;ex&lt;/code&gt;&lt;/a&gt; command.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Special file descriptor to standard input needs to be specified (&lt;code&gt;/dev/stdin&lt;/code&gt;) in order to prevent extra annoying messages (as explained below).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And here are some examples with parsing strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo This is example. | vim -e '+s/example/test/g' '+%print' '+q!' /dev/stdin&#xA;This is test.&#xA;$ echo This is example. | vim - -es '+s/example/test/g' '+%print' '+q!'&#xA;Vim: Reading from stdin...&#xA;This is test.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: The last example shows extra annoying message which is not possible to hide it, it's because a standard strategy of reading the whole file into memory and saying it was read from the standard input. The first example works without the message, because the file produce endless data without an end-of-file (&lt;a href=&quot;https://en.wikipedia.org/wiki/End-of-file&quot; rel=&quot;nofollow noreferrer&quot;&gt;EOF&lt;/a&gt;) signal, so it'll will never reach the end of its input reading.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/3219479/how-to-write-buffer-content-to-stdout&quot;&gt;How to write buffer content to stdout?&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/10686183/pipe-vim-buffer-to-stdout&quot;&gt;Pipe Vim buffer to stdout&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2017-07-28T22:28:49.497" LastActivityDate="2017-07-28T22:28:49.497" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="801" PostTypeId="1" AcceptedAnswerId="802" CreationDate="2015-02-14T18:13:42.317" Score="2" ViewCount="1069" Body="&lt;p&gt;I often just need to create a &lt;code&gt;notes.txt&lt;/code&gt; file in Windows to just quickly paste some text from some other place, save it from the &lt;code&gt;gvim&lt;/code&gt; UI, and close the file. I want to be able to perform this operation quickly without having to press &lt;code&gt;i&lt;/code&gt; on the keyboard, and &lt;code&gt;gvim&lt;/code&gt; is my editor of choice on Windows and all files with the &lt;code&gt;.txt&lt;/code&gt; extension have been associated with &lt;code&gt;gvim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I want to configure my &lt;code&gt;_Vimrc&lt;/code&gt; so that when a &lt;code&gt;.txt&lt;/code&gt; file is opened, insert mode is enabled by default. For other files, if at all possible, starting in command mode is preferable as I often start a &lt;code&gt;gvim&lt;/code&gt; session by jumping to a line number in command mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the above is not possible, then how can I simply configure &lt;code&gt;gvim&lt;/code&gt; to start in insert mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="51" LastEditDate="2015-02-15T00:40:27.690" LastActivityDate="2015-02-15T00:40:27.690" Title="How can I have (g)vim start in insert mode by default (when opening a .txt file)?" Tags="|vimrc|insert-mode|" AnswerCount="1" CommentCount="1" ClosedDate="2015-02-14T20:28:45.030" ContentLicense="CC BY-SA 3.0" />
  <row Id="802" PostTypeId="2" ParentId="801" CreationDate="2015-02-14T18:34:39.473" Score="3" Body="&lt;p&gt;This should do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead *.txt startinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="502" LastActivityDate="2015-02-14T18:34:39.473" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="803" PostTypeId="1" AcceptedAnswerId="804" CreationDate="2015-02-14T19:02:20.533" Score="11" ViewCount="1835" Body="&lt;p&gt;I am using a keyboard layout in which the backtick (&lt;code&gt;`&lt;/code&gt;) is a &lt;a href=&quot;http://en.wikipedia.org/wiki/Keyboard_layout#Dead_keys&quot; rel=&quot;noreferrer&quot;&gt;dead key&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that when I type a backtick followed by a vowel (for example &lt;code&gt;`a&lt;/code&gt;) what Vim sees is an accented character (&lt;code&gt;à&lt;/code&gt;). So if I set a mark with &lt;code&gt;ma&lt;/code&gt; I can jump to the line of the mark with &lt;code&gt;'a&lt;/code&gt;. But jumping to the specific location of the mark with &lt;code&gt;`a&lt;/code&gt; won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a workaround for this: when typing a dead key I can make Vim receive a backtick by striking the backtick and then the space bar. So if I want to go to mark &lt;code&gt;a&lt;/code&gt; I type &lt;code&gt;`␣a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to jump to the mark without having to strike that extra space? With no side effects?&lt;/p&gt;&#xA;" OwnerUserId="356" LastActivityDate="2020-05-15T17:14:48.737" Title="Using marks with dead keys" Tags="|cursor-movement|keyboard-layout|mark|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="804" PostTypeId="2" ParentId="803" CreationDate="2015-02-14T19:30:53.093" Score="15" Body="&lt;p&gt;Try making it a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Mapping dead keys in normal mode&#xA;nmap á 'a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way, when Vim gets the accented a, it interprets it as &lt;kbd&gt;`&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;nmap&lt;/code&gt; allows this to happen in normal mode only; in insert mode or command mode, you'll get the accented &lt;code&gt;a&lt;/code&gt; as you'd expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to apply this to other keys:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap à `a&#xA;nmap Á 'A&#xA;nmap À `A&#xA;nmap ç 'c&#xA;nmap Ç 'C&#xA;nmap é 'e&#xA;nmap è `e&#xA;nmap É 'E&#xA;nmap È `E&#xA;nmap í 'i&#xA;nmap ì `i&#xA;nmap Í 'I&#xA;nmap Ì `I&#xA;nmap ó 'o&#xA;nmap ò `o&#xA;nmap Ó 'O&#xA;nmap Ò `O&#xA;nmap ú 'u&#xA;nmap ù `u&#xA;nmap Ú 'U&#xA;nmap Ù `U&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="227" LastEditorUserId="1841" LastEditDate="2015-09-02T03:59:19.490" LastActivityDate="2015-09-02T03:59:19.490" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="805" PostTypeId="1" CreationDate="2015-02-14T21:27:04.757" Score="4" ViewCount="277" Body="&lt;p&gt;Is there a way to exclude specific files and directories from Vim's &lt;code&gt;path&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was hoping a syntax like this would work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path+=./**,!./ignoredirectory,!./ignoredirectory2,!./ignorefile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would use &lt;code&gt;wildignore&lt;/code&gt; but I don't think it supports relative path expansion if I used something like &lt;code&gt;set wildignore+=ignoredirectory,ignoredirectory2,ignorefile.txt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastEditorUserId="24" LastEditDate="2015-02-15T08:53:53.357" LastActivityDate="2015-02-15T14:24:55.737" Title="Can the path include negative entries (exceptions to a wildcard)?" Tags="|filesystem|load|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="807" PostTypeId="1" AcceptedAnswerId="812" CreationDate="2015-02-14T21:58:45.530" Score="31" ViewCount="11325" Body="&lt;p&gt;I would like to generate one or few random numbers separated by new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How this can be done?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="51" LastEditDate="2015-02-15T15:41:35.180" LastActivityDate="2022-06-25T19:35:05.697" Title="How to generate random numbers?" Tags="|text-generation|" AnswerCount="8" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="808" PostTypeId="1" CreationDate="2015-02-14T22:06:38.233" Score="3" ViewCount="144" Body="&lt;p&gt;I've few lines (or paragraph if easier - &lt;kbd&gt;{&lt;/kbd&gt;, &lt;kbd&gt;}&lt;/kbd&gt;) which I would like to convert to numbered/ordered list, in example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Item one&#xA;Item two&#xA;Item three&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. Item one&#xA;2. Item two&#xA;3. Item three&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would assume that it needs to be done either by macro or some plugin. But any method would be ok.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="51" LastEditDate="2015-02-15T03:12:24.480" LastActivityDate="2015-02-16T11:26:04.487" Title="How to convert lines to numbered list?" Tags="|macro|text-generation|enumerate|" AnswerCount="0" CommentCount="2" ClosedDate="2015-02-15T08:05:15.183" ContentLicense="CC BY-SA 3.0" />
  <row Id="809" PostTypeId="2" ParentId="805" CreationDate="2015-02-14T22:22:09.557" Score="1" Body="&lt;p&gt;Why do you think such a syntax should work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h :set&lt;/code&gt; is your entry point to Vim's documentation on &lt;code&gt;:set&lt;/code&gt;. Scroll down a little to find out how to remove an item from a comma-separated list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set path-=whatever&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-02-14T22:22:09.557" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="810" PostTypeId="2" ParentId="807" CreationDate="2015-02-14T23:03:57.637" Score="3" Body="&lt;p&gt;I don't think there's a native function for random numbers in Vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A way using &lt;code&gt;:python&lt;/code&gt; (use it in a function, perhaps, with 10000 and 60 replaced by parameters):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:python &amp;lt;&amp;lt;EOF&#xA;import vim&#xA;import random&#xA;&#xA;line = vim.current.window.cursor[0]&#xA;r = getattr(__builtins__, 'xrange', range) # To make it work for both Python 2 &amp;amp; 3&#xA;vim.current.buffer[line:line] = list(map(str, random.sample(r(10000), 60)))&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See my answer to &lt;a href=&quot;https://vi.stackexchange.com/questions/474/making-a-box-in-vim-via-python/585#585&quot;&gt;Making a box in vim via python&lt;/a&gt; for a quick intro on Python scripting in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;vim.current.buffer&lt;/code&gt; is a list of strings, we can assign a list of strings to it the way we would in Python. &lt;a href=&quot;https://docs.python.org/2/library/random.html#random.sample&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;random.sample&lt;/code&gt;&lt;/a&gt; is just the simplest way I can think of to get a list of random integers in Python.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-15T00:51:11.520" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="811" PostTypeId="2" ParentId="688" CreationDate="2015-02-14T23:31:56.600" Score="10" Body="&lt;h2&gt;Add numbers to all lines&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It's possible to use &lt;a href=&quot;http://manpages.ubuntu.com/nl.1posix&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:%!nl -ba&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;http://manpages.ubuntu.com/cat.1&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:%!cat -n&lt;/code&gt;&lt;/a&gt; commands which will add line numbers to all the lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&lt;sup&gt;On Windows, you've to have Cygwin/MSYS/SUA installed.&lt;/sup&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Add numbers to selected lines&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To add numbers only for selected lines, please select them in visual mode (&lt;kbd&gt;v&lt;/kbd&gt; and cursors), then when finished - execute the command: &lt;code&gt;:%!nl&lt;/code&gt; (ignore blank lines) or &lt;code&gt;:%!cat -n&lt;/code&gt; (blank lines included).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Formatting&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To remove extra spaces, select them in visual block (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;) and remove them (&lt;kbd&gt;x&lt;/kbd&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To add some characters (&lt;code&gt;.&lt;/code&gt;, &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;)&lt;/code&gt;) after the numbers, select them in visual block (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;), then append the character (&lt;kbd&gt;A&lt;/kbd&gt;, type the character, then finish with &lt;kbd&gt;Esc&lt;/kbd&gt;).&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="205" LastEditDate="2015-02-20T21:53:41.160" LastActivityDate="2015-02-20T21:53:41.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="812" PostTypeId="2" ParentId="807" CreationDate="2015-02-14T23:32:22.123" Score="26" Body="&lt;p&gt;Starting with Vim &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.2342&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.2342&lt;/a&gt;, you can make use of the &lt;code&gt;rand()&lt;/code&gt; and &lt;code&gt;srand()&lt;/code&gt; functions.&lt;/p&gt;&#xA;&lt;p&gt;Here is an example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:seed = srand()&#xA;echo rand(g:seed) % 100   &amp;quot; to echo a random number between 0-99&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For older Vims, you'll have to fall back to calling some external commands (or use the Python, Perl, Tcl, MzScheme, Ruby, Lua language interfaces, if your Vim comes with those enabled).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;UNIX Shell (&lt;code&gt;/bin/sh&lt;/code&gt;)&lt;/h2&gt;&#xA;&lt;p&gt;Calling:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;strings -n 1 &amp;lt; /dev/urandom | tr -d '[:space:]' | head -c15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;with &lt;code&gt;system()&lt;/code&gt; is a good way. You can get only numbers by replacing &lt;code&gt;tr&lt;/code&gt; with &lt;code&gt;grep&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;strings -n 1 &amp;lt; /dev/urandom | grep -o '[[:digit:]]' | head -c15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can use this in Vim like so:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:echo system(&amp;quot;strings -n 1 &amp;lt; /dev/urandom | grep -o '[[:digit:]]'  | head -c15&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The number 15 is the amount of numbers you want (adjust accordingly). This should work on Linux, BSD, OSX, and other UNIX systems. It won't work on MS Windows.&lt;/p&gt;&#xA;&lt;p&gt;Also see my weblog post &amp;quot;&lt;a href=&quot;https://www.arp242.net/cli-passwords.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Generate passwords from the commandline&lt;/a&gt;&amp;quot; (there are a lot of bad solutions for this out there).&lt;/p&gt;&#xA;&lt;h2&gt;Ruby&lt;/h2&gt;&#xA;&lt;p&gt;Ruby is probably the next best choice, since Ruby scripting seems to be a bit more common than Python scripting. Getting a random number is easy:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:ruby puts Random.rand(10)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or to get 15 numbers:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:ruby 15.times { puts Random.rand(10) }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Python&lt;/h2&gt;&#xA;&lt;p&gt;You can use the &lt;a href=&quot;https://docs.python.org/2/library/random.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;random&lt;/a&gt; module; to get a single number:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:py import random; print(random.randint(0, 9))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or a 15 numbers:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:py import random&#xA;:py for i in range(0, 15): print(random.randint(0, 9))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This should work for both Python 2 &amp;amp; 3.&lt;/p&gt;&#xA;&lt;h2&gt;Windows PowerShell&lt;/h2&gt;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://web.archive.org/web/20151104185850/http://blogs.msdn.com/b/powershell/archive/2008/04/27/get-random.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Get-Random&lt;/code&gt;&lt;/a&gt;&#xA;to get a random number:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:echo system('Get-Random')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Windows &lt;code&gt;cmd.exe&lt;/code&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Windows 7 and later should ship with PowerShell, but if you want maximum&#xA;compatibility you can use &lt;code&gt;cmd.exe&lt;/code&gt;. It has a special variable &lt;code&gt;%RANDOM%&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:echo system('@echo %RANDOM%')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note: &lt;a href=&quot;https://devblogs.microsoft.com/oldnewthing/20100617-00/?p=13673&quot; rel=&quot;nofollow noreferrer&quot;&gt;This is not very random!&lt;/a&gt;&#xA;, it uses the time (!)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Note that you don't need to use the Ruby or Python bindings to use the Ruby or&#xA;Python solutions; you could also create a separate script and call them with&#xA;&lt;code&gt;system(&amp;quot;python -c '...'&amp;quot;)&lt;/code&gt; (this does require that ruby/python is installed,&#xA;obviously.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="11357" LastEditDate="2022-06-25T16:22:08.647" LastActivityDate="2022-06-25T16:22:08.647" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="813" PostTypeId="2" ParentId="688" CreationDate="2015-02-14T23:48:32.607" Score="5" Body="&lt;pre&gt;&lt;code&gt;I1. &amp;lt;esc&amp;gt;^qqyWjP^&amp;lt;C-a&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This numbers the first two lines, and you can press &lt;code&gt;@q&lt;/code&gt; to number subsequent lines (or type ex. &lt;code&gt;18@q&lt;/code&gt; if you want to number 20 lines total).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I1. &amp;lt;esc&amp;gt;  Number the first line&#xA;hqq        Go back to the start of the line and start recording a macro&#xA;yWjP       Copy the line number to the next line&#xA;^&amp;lt;C-a&amp;gt;     Increment the next line's line number&#xA;q          Finish recording&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The benefit of this is that it doesn't require any external commands, which is useful if you're working with Vim on Windows, for example.&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="88" LastEditDate="2015-02-15T14:18:37.890" LastActivityDate="2015-02-15T14:18:37.890" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="814" PostTypeId="2" ParentId="778" CreationDate="2015-02-15T00:32:32.550" Score="4" Body="&lt;p&gt;I use a wrapper script in &lt;code&gt;python&lt;/code&gt; to merge files (see below). This is a&#xA;simplified version of what I use to merge my &lt;code&gt;~/.vim&lt;/code&gt; dirs and such.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should work in Python 2 and 3; but probably not in very old versions of&#xA;Python as shipped with CentOS and some other distros.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be aware that some checks (like the one for binary files, or if the files are&#xA;the same) are not very fast (it reads the entire file); you could remove them if&#xA;you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also doesn't report if a is only present in one of the directories...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python&#xA;from __future__ import print_function&#xA;import hashlib, os, subprocess, sys&#xA;&#xA;if len(sys.argv) &amp;lt; 3:&#xA;    print('Usage: {} dir1 dir2'.format(sys.argv[0]))&#xA;    sys.exit(1)&#xA;&#xA;dir1 = os.path.realpath(sys.argv[1])&#xA;dir2 = os.path.realpath(sys.argv[2])&#xA;&#xA;for root, dirs, files in os.walk(dir1):&#xA;    for f in files:&#xA;        f1 = '{}/{}'.format(root, f)&#xA;        f2 = f1.replace(dir1, dir2, 1)&#xA;&#xA;        # Don't diff files over 1MiB&#xA;        if os.stat(f1).st_size &amp;gt; 1048576 or os.stat(f2).st_size &amp;gt; 1048576: continue&#xA;&#xA;        # Check if files are the same; in which case a diff is useless&#xA;        h1 = hashlib.sha256(open(f1, 'rb').read()).hexdigest()&#xA;        h2 = hashlib.sha256(open(f2, 'rb').read()).hexdigest()&#xA;        if h1 == h2: continue&#xA;&#xA;        # Don't diff binary files&#xA;        if open(f1, 'rb').read().find(b'\000') &amp;gt;= 0: continue&#xA;&#xA;        subprocess.call(['vimdiff', f1, f2])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-15T00:32:32.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="815" PostTypeId="2" ParentId="265" CreationDate="2015-02-15T00:40:05.947" Score="4" Body="&lt;p&gt;While infuriating, a number of vim-latex's features can be customised without editing the source code.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Disable the &lt;code&gt;EEA&lt;/code&gt; mapping&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;.vim/after/ftplugin/tex.vim&lt;/code&gt;, add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call IMAP('EEA', 'EEA', 'tex')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;EEA&lt;/code&gt; in insert mode will no longer insert the &lt;code&gt;eqnarray&lt;/code&gt; environment.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;code&gt;F5&lt;/code&gt; prompted environments&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;.vim/ftplugin/tex/texrc&lt;/code&gt;, add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Tex_PromptedEnvironments = 'equation,\[,align,align*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This removes &lt;code&gt;eqnarray&lt;/code&gt; and some of the other discouraged/redundant environments from the &lt;code&gt;F5&lt;/code&gt; prompt. Of course, you can add your own environments here as well.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;code&gt;^F1&lt;/code&gt;-&lt;code&gt;^F4&lt;/code&gt; keybindings&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are also keybindings for &lt;code&gt;^F1&lt;/code&gt; through to &lt;code&gt;^F4&lt;/code&gt;. In &lt;code&gt;.vim/ftplugin/tex/texrc&lt;/code&gt;, add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Tex_HotKeyMappings = 'bmatrix'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, you can customise this to suit your needs. (&lt;code&gt;bmatrix&lt;/code&gt; is one of vim-latex's defaults.)&lt;/p&gt;&#xA;" OwnerUserId="501" LastActivityDate="2015-02-15T00:40:05.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="816" PostTypeId="5" CreationDate="2015-02-15T00:42:14.437" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-15T00:42:14.437" LastActivityDate="2015-02-15T00:42:14.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="817" PostTypeId="4" CreationDate="2015-02-15T00:42:14.437" Score="0" Body="Questions about cutting, copying, and pasting text. In Vim, &quot;cut&quot; is also called &quot;delete&quot;, &quot;copy&quot; is also called &quot;yank&quot;, and &quot;paste&quot; is also called &quot;put&quot;." OwnerUserId="51" LastEditorUserId="88" LastEditDate="2015-03-01T18:15:41.513" LastActivityDate="2015-03-01T18:15:41.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="818" PostTypeId="2" ParentId="688" CreationDate="2015-02-15T03:03:59.577" Score="9" Body="&lt;p&gt;I like to use the vim global command to accomplish tasks like this. This applies to adding iteration to the beginning of a line or modify a symbol in the text. It looks more complicated than the other solutions, but is a pretty flexible pattern to use when you have it handy, and is easy to modify without a lot of thought.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, pick your range (which lines you want to apply this). I usually use marks (e.g. &lt;code&gt;ma&lt;/code&gt; on the first line and &lt;code&gt;mb&lt;/code&gt; on the second, but you can also use line numbers or visual selection), then enter a modification of the following command (currently tweaked for your use case)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i=1|'a,'bg/^/s/^/\=i.&quot;. &quot;/|let i=i+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Deconstruction&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets up variable &lt;code&gt;i&lt;/code&gt; with a start value. Usually lists start with 1, so I'm setting i to 1.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The bar starts a new command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'a,'b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets the range of the next command. I'm going from mark &lt;code&gt;a&lt;/code&gt; to mark &lt;code&gt;b&lt;/code&gt;, which would be set on the first line and last line of your list.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the global command. It searches the file (or range) for a given regular expression, and will execute the rest of the command line on &lt;em&gt;each&lt;/em&gt; of the lines that matched. I'm matching every line by searching for &quot;beginning of line&quot;. If you had text like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Item some txt&#xA;other text&#xA;&#xA;Item second item&#xA;whatever&#xA;Item third&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and only want to put these labels in front of &lt;code&gt;Item&lt;/code&gt; and ignore the other lines, do &lt;code&gt;g/Item/&lt;/code&gt; or &lt;code&gt;g/^Item/&lt;/code&gt; instead (assuming the literal Item text)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/^/\=i.&quot;. &quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This executes the regular expression to replace the beginning of the line with the value of &lt;code&gt;i&lt;/code&gt; concatenated with a &lt;code&gt;.&lt;/code&gt;. Generally you can do this to anything (replace the label &lt;code&gt;Item&lt;/code&gt; with the number, for example).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|let i=i+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even though the bar starts a new command, it sets up a second command to run within the global command, instead of after the global is complete. The result is we increment &lt;code&gt;i&lt;/code&gt; before the next line is processed by g. Here is another place of flexibility. The modification of i can be anything (increment by 2, call a function that generates the next element of the Fibonacci sequence, whatever).&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-02-15T03:03:59.577" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="819" PostTypeId="2" ParentId="807" CreationDate="2015-02-15T14:10:08.103" Score="4" Body="&lt;p&gt;Vim doesn't offer native random generator, however if you have vim compiled with Python, the following method will append a random digit at the end of your line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py import vim, random; vim.current.line += str(random.randint(0, 9))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: To check if your vim supports Python, try: &lt;code&gt;:echo has('python')&lt;/code&gt; (1 for yes).&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use shell which offers &lt;code&gt;$RANDOM&lt;/code&gt; variable (works with bash/ksh/zsh) which returns a pseudorandom (0-32767), in example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r! echo $RANDOM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put =system('echo $RANDOM')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r! od -An -td -N1 /dev/urandom&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;On Windows, you've to have Cygwin/MSYS/SUA installed, or use &lt;code&gt;%RANDOM%&lt;/code&gt; variable as &lt;a href=&quot;https://vi.stackexchange.com/a/812/467&quot;&gt;Carpetsmoker&lt;/a&gt; suggested.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have access to shell and Python, as for workaround, you use last few digits from the current timestamp, in example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put =reltimestr(reltime())[-2:]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: If you're using it quite often, write a simple function which will &lt;code&gt;return reltimestr(reltime())[-4:]&lt;/code&gt;.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: Above methods returns only a pseudorandom integer which should not be used to generate an encryption key.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To add more random numbers please press &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt; to repeat the command again. Or prefix with number (like &lt;kbd&gt;10&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;) to add much more of random numbers separated by new lines.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/20430493/vim-generate-random-numbers-in-the-buffer&quot;&gt;VIM generate random numbers in the buffer&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/1194882/generate-random-number&quot;&gt;Generate random number in bash&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-16T18:28:56.027" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="820" PostTypeId="2" ParentId="805" CreationDate="2015-02-15T14:24:55.737" Score="2" Body="&lt;p&gt;I did a bit of experimentation with &lt;code&gt;wildignore&lt;/code&gt;. I don't think it supports relative paths, or even absolute paths.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I have:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A file at &lt;code&gt;~/devel/scratchpad/c++/ms.cpp&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Vim opened with current directory &lt;code&gt;~/devel&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set path=~/devel/**&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildignore=scratchpad/**/*&#xA;set wildignore=~/devel/scratchpad/**/*&#xA;set wildignore=./scratchpad/**/*&#xA;set wildignore=/home/muru/devel/scratchpad/**/*&#xA;set wildignore=*/scratchpad/**/*&#xA;set wildignore=**/scratchpad/**/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Only the last two prevented tab completion from filling &lt;code&gt;:find ms.&lt;/code&gt; to &lt;code&gt;:find ms.cpp&lt;/code&gt;. I'm not sure how to explain the results.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-02-15T14:24:55.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="821" PostTypeId="2" ParentId="758" CreationDate="2015-02-15T14:49:49.760" Score="2" Body="&lt;p&gt;To close all splits but current windows, use: &lt;code&gt;:on&lt;/code&gt; (&lt;code&gt;:only&lt;/code&gt;), or use the shortcut &lt;kbd&gt;Ctrl&lt;/kbd&gt;+(&lt;kbd&gt;w&lt;/kbd&gt;,&lt;kbd&gt;o&lt;/kbd&gt;).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:on[ly][!]      Make the current window the only one on the screen. All other windows are closed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To &lt;strong&gt;split all&lt;/strong&gt; the buffers again, use: &lt;code&gt;:ba&lt;/code&gt; to split horizontally or &lt;code&gt;:vert ba&lt;/code&gt; to split vertically.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:[N]ba[ll] [N]&#xA;  :[N]sba[ll] [N] Rearrange the screen to open one window for each buffer in the buffer list.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;:vert[ical] {cmd} Execute {cmd}.  If it contains a command that splits a window, it will be split vertically.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To quit: &lt;code&gt;:qa&lt;/code&gt; (See: &lt;a href=&quot;https://vi.stackexchange.com/questions/735/how-to-exit-vim-from-split-mode&quot;&gt;How to exit vim from split mode?&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://superuser.com/questions/323781/how-do-i-open-separate-tabs-windows-for-all-buffers-in-vim&quot;&gt;How do I open separate tabs/windows for all buffers in Vim?&lt;/a&gt; at superuser&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-20T11:25:26.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="822" PostTypeId="2" ParentId="773" CreationDate="2015-02-15T16:26:14.273" Score="35" Body="&lt;p&gt;The examples below set the width to 60 columns. Adjust to your preferences.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;NERDTree&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;NERDTree uses a variable for just this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:NERDTreeWinSize=60&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will set the width to 60. You can put this line into your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Taglist&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For taglist, you set a similar option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:Tlist_WinWidth=60&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Like with NERDTree, you can put this line into your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Others&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Unfortunately there is no generally applicable method. Many plugins do (or should) offer a parameter for this (like above). Others allow you to apply a workaround by setting things you can key off of for an autocommand (such as the filetype, for example, if NERDTree didn't offer the option to set it, you could have done &lt;code&gt;:au FileTupe nerdtree :vert resize 60&lt;/code&gt;, since NERDTree sets the filetype on the buffer). I've found that trying to do an autocmd on the WinEnter event based on the buffer name doesn't generally work when the buffer is created, but does if you leave the window and come back to it; plugins often create the window before setting up the buffer. You'll have to experiment with other plugins or request the plugin author to add a parameter.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-02-16T01:05:39.640" LastActivityDate="2015-02-16T01:05:39.640" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="823" PostTypeId="5" CreationDate="2015-02-15T16:47:40.017" Score="0" Body="&lt;p&gt;Can be checked by: &lt;code&gt;:echo has('unix')&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-02-16T04:09:35.637" LastActivityDate="2015-02-16T04:09:35.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="824" PostTypeId="4" CreationDate="2015-02-15T16:47:40.017" Score="0" Body="Unix version of Vim." OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-02-16T04:09:13.027" LastActivityDate="2015-02-16T04:09:13.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="825" PostTypeId="5" CreationDate="2015-02-15T16:50:53.757" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-15T16:50:53.757" LastActivityDate="2015-02-15T16:50:53.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="826" PostTypeId="4" CreationDate="2015-02-15T16:50:53.757" Score="0" Body="The X Window System (often just called X11) provides graphics on Unix-like systems." OwnerUserId="467" LastEditorUserId="51" LastEditDate="2015-05-12T19:12:34.087" LastActivityDate="2015-05-12T19:12:34.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="827" PostTypeId="5" CreationDate="2015-02-15T16:53:08.743" Score="0" Body="&lt;p&gt;For help, check &lt;code&gt;:help opening-window&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-02-16T04:09:49.650" LastActivityDate="2015-02-16T04:09:49.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="828" PostTypeId="4" CreationDate="2015-02-15T16:53:08.743" Score="0" Body="Questions about splitting current window into multiple viewports." OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-02-15T21:07:30.383" LastActivityDate="2015-02-15T21:07:30.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="830" PostTypeId="1" AcceptedAnswerId="833" CreationDate="2015-02-15T23:26:39.540" Score="16" ViewCount="3053" Body="&lt;p&gt;From &lt;code&gt;:help swap-file&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Updating the swapfile&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The swap file is updated after typing 200 characters or when you have&#xA;  not typed anything for four seconds.  This only happens if the buffer&#xA;  was changed, not when you only moved around.  The reason why it is not&#xA;  kept up to date all the time is that this would slow down normal work&#xA;  too much.  You can change the 200 character count with the&#xA;  'updatecount' option.  You can set the time with the 'updatetime'&#xA;  option.  The time is given in milliseconds.  After writing to the swap&#xA;  file Vim syncs the file to disk.  This takes some time, especially on&#xA;  busy Unix systems.  If you don't want this you can set the 'swapsync'&#xA;  option to an empty string.  The risk of losing work becomes bigger&#xA;  though.  On some non-Unix systems (MS-DOS, Amiga) the swap file won't&#xA;  be written at all.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From this I have a few questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Does this mean Vim autosaves your work from time to time?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;After writing to the swap file Vim syncs the file to disk.&quot; What does this mean? Is this refering to the file being written first to memory and then to the disk or is it something else?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Say I'm taking class notes: I write fast and there's little need for me to leave Insert mode. But many times I change to Normal just to save my work. Do I need to do this or does Vim make sure that most of my work is saved even if I don't leave Insert mode?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="356" LastActivityDate="2019-04-19T11:44:13.067" Title="Does Vim autosave?" Tags="|save|swap-file|backup|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="831" PostTypeId="1" AcceptedAnswerId="832" CreationDate="2015-02-15T23:38:01.767" Score="3" ViewCount="326" Body="&lt;p&gt;After running &lt;code&gt;:make&lt;/code&gt;, the quickfix window displays the compile command and other &lt;code&gt;stdout&lt;/code&gt; messages from the makefile, but it doesn't display any errors. Everything but &lt;code&gt;stderr&lt;/code&gt; messages are displaying. How do I enable &lt;code&gt;stderr&lt;/code&gt; messages?&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2018-01-25T14:24:47.567" Title="Quickfix window not displaying stderr messages?" Tags="|vimrc|quickfix|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="832" PostTypeId="2" ParentId="831" CreationDate="2015-02-15T23:38:01.767" Score="2" Body="&lt;p&gt;You have to add this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shellpipe=2&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...to enable &lt;code&gt;stderr&lt;/code&gt; output in the quickfix window.&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2015-02-15T23:38:01.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="833" PostTypeId="2" ParentId="830" CreationDate="2015-02-15T23:58:28.813" Score="12" Body="&lt;ol&gt;&#xA;&lt;li&gt;Yes it saves to swap file.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can do a quick test to get a &lt;em&gt;feel&lt;/em&gt; of this. Go to a directory. Say &lt;code&gt;vim notest.txt&lt;/code&gt; and write some text. You do not even have to save the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you list files in the working directory you will find a swap file. Copy it to a different directory (where you have no &quot;notes.txt&quot; file, as say &lt;code&gt;vim notest.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You get a note about swap existing, it being modified, and the options of open as read only, recover etc. Choose recover and voila! A &quot;copy&quot; of your file.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Yes, swap is held in memory.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;When Vim reads a file it adds it to RAM. That is both for existing and new (still unsaved files). As swap is saved it is flushed to disk. The HDD. From RAM.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Yes and no.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;With default settings &lt;em&gt;most&lt;/em&gt; of your work are saved. That is for every 200 characters entered, or when yo have a 4 second pause. Though I &lt;em&gt;trust&lt;/em&gt; the swap file to be saved, I &lt;em&gt;like&lt;/em&gt; to save my work when I know I'm on an unstable system. But, that said, one are fairly certain to keep the work unless one should be very unlucky and the hosting system going panic just after writing a &lt;em&gt;very&lt;/em&gt; important sentence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short it is enough to save when the lecture is over. If the system should halt for what ever reason in midst of a class, the work is till there in the swap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course: If you are very unlucky a crash can occur whilst swap file is being written. As a result swap file &lt;em&gt;could&lt;/em&gt; be corrupted. Have never experienced this, and not sure which parts of the file might be messed up, but might worth a thought. As the swap file is &lt;em&gt;binary&lt;/em&gt; (in lack of a better word), it seems to reason it is more fragile then a plain text file.&lt;/p&gt;&#xA;&#xA;&lt;hr /&gt;&#xA;&#xA;&lt;p&gt;As a side-note. At least when using working directory for swap, the swap file is location agnostic when it comes to recovery. As such you can &lt;em&gt;copy&lt;/em&gt; the swap file to a new location and &lt;em&gt;recover&lt;/em&gt; the file as a &lt;em&gt;new&lt;/em&gt; file. Only note that the file-name is hard coded into the swap. As such you can not say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cp .foo.txt.swp .bar.txt.swp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim bar.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and expect the swap file of &lt;code&gt;foo.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are &lt;em&gt;very&lt;/em&gt; interested you can do (on *nix):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xxd -s 108 -l 800 -ps .foo.txt.swp | xxd -r -p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to get the path (with some quirks) of original file. As you'll see the full path is added, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~user/blah/blah/notes.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;but&lt;/em&gt; only the &lt;em&gt;basename&lt;/em&gt; is used on swap check.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that regard you can also check out the &lt;code&gt;vim -r&lt;/code&gt; option - which lists swap files in current and lower directories. See &lt;code&gt;:h crash-recovery&lt;/code&gt; with sub-topics.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2015-02-16T00:35:20.877" LastActivityDate="2015-02-16T00:35:20.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="834" PostTypeId="1" CreationDate="2015-02-16T00:50:38.193" Score="12" ViewCount="360" Body="&lt;p&gt;To add to this &lt;a href=&quot;https://stackoverflow.com/questions/15895432/how-to-start-vim-in-private-mode&quot;&gt;stackoverflow question&lt;/a&gt;, what should one put in their &lt;code&gt;.vimrc&lt;/code&gt; to ensure 'private editing' of certain file extensions (e.g. &lt;code&gt;.gpg&lt;/code&gt; files). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without compromising the effectiveness of the session, no info about work done should be saved, including registers, search history, command history, views, swaps, etc. For &lt;code&gt;gpg&lt;/code&gt; files, one can use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3645&quot; rel=&quot;nofollow noreferrer&quot;&gt;this vim plugin&lt;/a&gt;, but besides editing the plugin, how would one extend these discussed ideas to arbitrary file types?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We'll probably make use of the following commands,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;lt;ft in privacy_ext_list&amp;gt;&#xA;  set noswapfile&#xA;  set noundofile&#xA;  set viminfo=&#xA;endif &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but besides the appropriate conditional statement, what's missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further, is there a way with Vimscript to make an array of file extensions and then evaluate if the current filetype is within the array?&lt;/p&gt;&#xA;" OwnerUserId="44" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-19T10:42:35.217" Title="Prevent Vim from recording events for certain filetypes" Tags="|vimrc|register|command-history|persistent-state|security|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="835" PostTypeId="1" CreationDate="2015-02-16T02:49:58.643" Score="14" ViewCount="517" Body="&lt;p&gt;When doing spell checking, keying &lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;, brings up a selection list, as shown bellow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/GA3Eh.png&quot; alt=&quot;select correct&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see the correct spelling; &quot;i.e.&quot; is not shown as any of the options.&#xA;I would like to enhance this menu, so that I can instead just type in &quot;i.e.&quot; and press enter and have it replaced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would also be nice, if as part of the same step if I could start typing the name of one of the presented options and tab compete to that -- my mind works better on replacing words by entering words rather than by entering numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect this needs to be done with a plug-in but I'm not certain that it is not just a config option.&lt;/p&gt;&#xA;" OwnerUserId="360" LastActivityDate="2015-02-19T04:17:39.410" Title="How can I make the spellcheck selection window allow me to type my own correction?" Tags="|spell-checking|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="836" PostTypeId="1" AcceptedAnswerId="845" CreationDate="2015-02-16T04:01:23.537" Score="40" ViewCount="5882" Body="&lt;p&gt;I see &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; quite often in other people's vimrc files.&#xA;&lt;a href=&quot;http://amix.dk/vim/vimrc.html&quot;&gt;Like this one.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is it? &#xA;What does it do?&lt;/p&gt;&#xA;" OwnerUserId="360" LastEditorUserId="51" LastEditDate="2015-02-20T22:57:17.970" LastActivityDate="2015-07-06T13:38:51.710" Title="What is &lt;Leader&gt;?" Tags="|key-bindings|terminology|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="837" PostTypeId="2" ParentId="836" CreationDate="2015-02-16T04:15:40.667" Score="15" Body="&lt;p&gt;To quote &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#mapleader&quot;&gt;&lt;code&gt;:help &amp;lt;Leader&amp;gt;&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To define a mapping which uses the &quot;mapleader&quot; variable, the special string&#xA;  &quot;&lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;&quot; can be used.  It is replaced with the string value of &quot;mapleader&quot;.&#xA;  If &quot;mapleader&quot; is not set or empty, a backslash is used instead.  Example:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   :map &amp;lt;Leader&amp;gt;A  oanother line&amp;lt;Esc&amp;gt;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Works like:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   :map \A  oanother line&amp;lt;Esc&amp;gt;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;But after:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   :let mapleader = &quot;,&quot;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;It works like:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   :map ,A  oanother line&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In other words, it lets the first key of mappings (specified in terms of &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;) be user defined.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="51" LastEditDate="2015-02-16T12:57:36.490" LastActivityDate="2015-02-16T12:57:36.490" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="838" PostTypeId="1" CreationDate="2015-02-16T05:59:48.210" Score="2" ViewCount="6692" Body="&lt;p&gt;I know how to remove trailing white spaces at the end of lines.&#xA;Does anyone know how to remove white spaces in the middle of a line?&#xA;The white space I mean is before tab and after tab characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance (tabs are shown as &lt;code&gt;^I&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct {&#xA;^Iint a;&#xA;^I int b; // Here we've got an extra whitespace after the tab. I want to ditch it.&#xA;^I}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="496" LastEditorUserId="28" LastEditDate="2015-02-17T09:50:34.457" LastActivityDate="2015-02-18T21:15:42.937" Title="How can I remove additional whitespace in the middle of line?" Tags="|whitespace|tab-characters|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="839" PostTypeId="1" CreationDate="2015-02-16T10:16:43.907" Score="29" ViewCount="2984" Body="&lt;p&gt;Let's assume I am editing some Python code in Vim that looks a bit like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;myobj.myfunc(&amp;quot;Some string parameter that goes on and on and on and on and sometimes doesn't&amp;quot;&#xA;             &amp;quot;split very&amp;quot;&#xA;             &amp;quot;neatly over different lines so that&amp;quot;&#xA;             &amp;quot;it is formatted attractively&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I would prefer to reformat this so it reflows up to the &lt;code&gt;textwidth&lt;/code&gt; I have set:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;myobj.myfunc(&amp;quot;Some string parameter that goes on and on and &amp;quot;&#xA;             &amp;quot;on and on and sometimes doesn't split very &amp;quot;&#xA;             &amp;quot;neatly over different lines so that it is &amp;quot;&#xA;             &amp;quot;formatted attractively&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is there an easy way to do this?&lt;/p&gt;&#xA;&lt;p&gt;If this were a conventional text paragraph, &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; or similar would be useful, but this won't handle the quotes used to delinate the string.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: I am asking specifically about Python here, but ideally, this answer would be relevant for many types of programming language that allow string continuation.&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="23502" LastEditDate="2022-10-30T17:57:01.413" LastActivityDate="2022-10-30T17:57:01.413" Title="How can I reformat a multi-line string in Vim when using the Python filetype?" Tags="|formatting|line-breaks|filetype-python|" AnswerCount="5" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="840" PostTypeId="2" ParentId="64" CreationDate="2015-02-16T10:52:45.930" Score="27" Body="&lt;p&gt;You can either split vim windows by &lt;a href=&quot;https://vi.stackexchange.com/q/732/467&quot;&gt;opening multiple files&lt;/a&gt; using &lt;code&gt;-o&lt;/code&gt;, &lt;code&gt;-O&lt;/code&gt;, &lt;code&gt;-o2&lt;/code&gt; parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or if you're already editing multiple files in one window, you can use &lt;code&gt;:ba&lt;/code&gt; to &lt;a href=&quot;https://vi.stackexchange.com/q/758/467&quot;&gt;split horizontally&lt;/a&gt; or &lt;code&gt;:vert ba&lt;/code&gt; to split vertically.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:[N]ba[ll] [N]&#xA;  :[N]sba[ll] [N] Rearrange the screen to open one window for each buffer in the buffer list.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;:vert[ical] {cmd} Execute {cmd}.  If it contains a command that splits a window, it will be split vertically.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/735/467&quot;&gt;To quit&lt;/a&gt;, use: &lt;code&gt;:qa&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/732/467&quot;&gt;How to open multiple files in split mode?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/758/467&quot;&gt;How to convert all windows into horizontal, vertical or tab splits?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-16T10:52:45.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="841" PostTypeId="2" ParentId="838" CreationDate="2015-02-16T11:01:37.053" Score="4" Body="&lt;p&gt;This command will remove all whitespaces on both sides of one or more tabs in every line of the current buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/ *\([\t]\+\) */\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2015-02-16T11:39:09.873" LastActivityDate="2015-02-16T11:39:09.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="842" PostTypeId="2" ParentId="838" CreationDate="2015-02-16T11:44:30.730" Score="3" Body="&lt;p&gt;To delete white spaces after tabs, use the following substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^I \+/^I/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;^I&lt;/code&gt; is a special character which appears when you press &lt;kbd&gt;Tab&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To delete all whitespaces between non-whitespace characters, use the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(\S\) \+\(\S\)/\1\2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To double-check if all middle spaces are gone, use: &lt;code&gt;/^I \+&lt;/code&gt; command to find them. If there are some, vim would highlight them for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you'd like to highlight them, check: &lt;a href=&quot;https://vi.stackexchange.com/a/843/467&quot;&gt;How to strip trailing whitespaces in a file?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To convert tabs to spaces, while maintaining text alignment: &lt;a href=&quot;https://vi.stackexchange.com/q/495/467&quot;&gt;How to replace tabs with spaces?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Search_and_replace&quot; rel=&quot;nofollow noreferrer&quot;&gt;Search and replace&lt;/a&gt; at vim wikia&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Remove_unwanted_spaces&quot; rel=&quot;nofollow noreferrer&quot;&gt;Remove unwanted spaces&lt;/a&gt; at vim wikia&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/VimTip396&quot; rel=&quot;nofollow noreferrer&quot;&gt;Highlight unwanted spaces&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/454/467&quot;&gt;What's the simplest way to strip trailing whitespace from all lines in a file?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-18T21:15:42.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="843" PostTypeId="2" ParentId="454" CreationDate="2015-02-16T11:54:59.900" Score="21" Body="&lt;p&gt;To delete all trailing whitespace (at the end of each line), you can use the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/ \+$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To include tabs, use &lt;code&gt;\s&lt;/code&gt; instead of space.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;From the command-line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +'%s/\s\+$//e' -cwq file.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All the files in the current directory (recursively use &lt;code&gt;**/*.*&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +'bufdo!%s/\s\+$//e' -cxa *.*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Python way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py import vim&#xA;:pydo vim.current.buffer[linenr - 1] = vim.current.buffer[linenr - 1].strip()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py import vim&#xA;:py for i, l in enumerate(vim.current.buffer): vim.current.buffer[i] = l.rstrip()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Use &lt;code&gt;lstrip()&lt;/code&gt; for left strip (trailing), &lt;code&gt;rstrip()&lt;/code&gt; for right strip (leading) or &lt;code&gt;strip()&lt;/code&gt; to remove from both ends.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is useful function which removes superfluous white space from the end of a line which you can add to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Removes superfluous white space from the end of a line&#xA;function! RemoveWhiteSpace()&#xA;   :%s/\s*$//g&#xA;    :'^&#xA;    &quot;`.&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3967&quot; rel=&quot;noreferrer&quot;&gt;DeleteTrailingWhitespace&lt;/a&gt; plugin for that.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Highlighting white spaces&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To double-check if all trailing spaces are gone, use:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Type &lt;code&gt;/ $&lt;/code&gt; to find them. If there are some, vim would highlight them for you.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use colours to highlight them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight ws ctermbg=red guibg=red&#xA;:match ws /\s\+$/&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use visible characters (&lt;a href=&quot;https://stackoverflow.com/a/26299952/55075&quot;&gt;source&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set encoding=utf-8&#xA;:set listchars=trail:·&#xA;:set list&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;a href=&quot;http://vim.wikia.com/wiki/VimTip396&quot; rel=&quot;noreferrer&quot;&gt;Highlight unwanted spaces&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To highlight trailing whitespace by default, you may configure your &lt;code&gt;.vimrc&lt;/code&gt; as follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight ws ctermbg=red guibg=red&#xA;match ws /\s\+$/&#xA;autocmd BufWinEnter * match ws /\s\+$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Removing white spaces by default&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like to make sure that all trailing whitespace in a file are removed automatically on save, you may add the following command into your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre *.c,*.php :%s/\s\+$//ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which may not be recommended, as it'll unconditionally strip trailing whitespace from every file of that type saved by an user saves and there's not a good way to prevent that where trailing whitespace might be desired (which should be rare, but still.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Remove_unwanted_spaces&quot; rel=&quot;noreferrer&quot;&gt;Remove unwanted spaces&lt;/a&gt; at vim wikia&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/1185524/how-to-trim-whitespace-including-tabs&quot;&gt;How to trim whitespace (including tabs)?&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/356126/how-can-you-automatically-remove-trailing-whitespace-in-vim&quot;&gt;How can you automatically remove trailing whitespace?&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="18609" LastEditDate="2020-04-22T19:01:53.713" LastActivityDate="2020-04-22T19:01:53.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="844" PostTypeId="2" ParentId="495" CreationDate="2015-02-16T12:23:44.203" Score="30" Body="&lt;p&gt;Vim provides &lt;code&gt;:retab!&lt;/code&gt; command which will replace all sequences of &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; with new strings of white-space using the new tabstop (e.g. &lt;code&gt;:set tabstop=2&lt;/code&gt;) value given, but &lt;strong&gt;all tabs inside of strings can be modified&lt;/strong&gt; (e.g. in a C program, you should use &lt;code&gt;\t&lt;/code&gt; to avoid this)!&lt;/p&gt;&#xA;&lt;p&gt;So alternatively you can change all tabs into spaces using the following command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\t/  /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or as suggested by &lt;a href=&quot;https://vi.stackexchange.com/questions/495/how-to-replace-tabs-with-spaces/844?noredirect=1#comment20357_844&quot;&gt;@Shahbaz&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\t\+/ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;sup&gt;So only the tabs used in indentation are converted.&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: there is a subtle difference between both commands. The first one will replace each Tab character by &lt;em&gt;two&lt;/em&gt; spaces, the second one replace any number of leading Tab characters in a line by a &lt;em&gt;single&lt;/em&gt; space.&lt;/p&gt;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt; represents the entire buffer/file (&lt;code&gt;:help :%&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s&lt;/code&gt; stands for substitute (&lt;code&gt;:help sub-replace-special&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\t&lt;/code&gt;, or &lt;code&gt;^I&lt;/code&gt; stands for tab&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;  &lt;/code&gt; - use as many spaces as you need per one tab&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g&lt;/code&gt; - stands for global, and it'll convert multiple occurences of tabs in the same line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Then to correct indentation of the entire file, you may try: &lt;kbd&gt;gg=G&lt;/kbd&gt;. Check: &lt;a href=&quot;https://vi.stackexchange.com/q/236/467&quot;&gt;Re-indenting badly indented code&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&lt;p&gt;To use spaces by default instead of tabs, you need to add the following settings into your &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=2     &amp;quot; (ts) width (in spaces) that a &amp;lt;tab&amp;gt; is displayed as&#xA;set expandtab     &amp;quot; (et) expand tabs to spaces (use :retab to redo entire file)&#xA;set shiftwidth=2  &amp;quot; (sw) width (in spaces) used in each step of autoindent (aswell as &amp;lt;&amp;lt; and &amp;gt;&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Alternative solution is to use &lt;code&gt;tidy&lt;/code&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Converting_tabs_to_spaces&quot; rel=&quot;nofollow noreferrer&quot;&gt;Converting tabs to spaces&lt;/a&gt; at vim wikia&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/6753219/indenting-with-spaces-but-still-use-preferred-shiftwidth-in-vim&quot;&gt;Indenting with spaces but still use preferred shiftwidth in Vim?&lt;/a&gt; at stackoverflow SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://askubuntu.com/questions/20937/how-can-i-easily-retab-html-files-according-to-some-sane-default&quot;&gt;How can I easily retab html files according to some sane default?&lt;/a&gt; at askubuntu SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://softwareengineering.stackexchange.com/questions/110160/using-vim-is-there-a-way-to-automatically-un-tab-everything-in-your-source-file&quot;&gt;Is there a way to automatically un-tab everything in your source file by using a command?&lt;/a&gt; at programmers&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/236/467&quot;&gt;Re-indenting badly indented code&lt;/a&gt; at Vim SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/234564/tab-key-4-spaces-and-auto-indent-after-curly-braces-in-vim&quot;&gt;Tab key == 4 spaces and auto-indent after curly braces in Vim&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/6753219/indenting-with-spaces-but-still-use-preferred-shiftwidth-in-vim&quot;&gt;Indenting with spaces but still use preferred shiftwidth in Vim?&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;li&gt;(opposite) &lt;a href=&quot;https://stackoverflow.com/questions/9104706/how-can-i-convert-spaces-to-tabs-in-vim-or-linux&quot;&gt;How can I convert spaces to tabs in Vim or Linux?&lt;/a&gt; at stackoverflow SE&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="71" LastEditDate="2023-01-20T10:18:54.537" LastActivityDate="2023-01-20T10:18:54.537" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="845" PostTypeId="2" ParentId="836" CreationDate="2015-02-16T13:13:56.597" Score="25" Body="&lt;p&gt;Vim is full of various commands, which are assigned to almost all keys on the keyboard. But this causes a problem: Which commands can we use for our own commands, without interfering with existing ones? And at this moment, the &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; key comes into play. Think about &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;-key like a namespace for any user-defined commands. You can assign any command to a mapping with a leading &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; and you can be fully confident that your mapping won't break anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Default key for &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; is backslash.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="205" LastEditDate="2015-07-06T13:38:51.710" LastActivityDate="2015-07-06T13:38:51.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="846" PostTypeId="1" AcceptedAnswerId="1880" CreationDate="2015-02-16T13:19:11.890" Score="10" ViewCount="4831" Body="&lt;p&gt;In my &lt;code&gt;~/.vimrc&lt;/code&gt;, I have a command defined approximately like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;n ':new ~/Notes/' . strftime('%F') . '-'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is designed for creating notes files that contain the current date in the filename. The keybinding is designed to leave my cursor on the command line so that I can type the topic of the note and hit &lt;kbd&gt;Return&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works from within vim fine. However, I am also trying to specify a terminal command that I can use to open vim and then fire this command. I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c '\n'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(my Leader is set to the default of &lt;code&gt;\&lt;/code&gt;, which I would prefer not to change)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this doesn't work - instead I just get &lt;strong&gt;Error detected while processing command line: E10: \ should be followed by /, ? or &amp;amp;&lt;/strong&gt;. I'm not sure if this is a bug in vim or if I'm doing something wrong. I also tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c '&amp;lt;Leader&amp;gt;n'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this gives: &lt;strong&gt;Error detected while processing command line: E488: Trailing characters: n Press ENTER or type command to continue&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to achieve what I want?&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="24" LastEditDate="2015-02-19T07:13:46.833" LastActivityDate="2016-01-10T16:47:44.147" Title="How can I start vim and then execute a particular command that includes a \, from the command line?" Tags="|command-line|key-bindings|invocation|startup|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="847" PostTypeId="2" ParentId="846" CreationDate="2015-02-16T13:28:33.383" Score="8" Body="&lt;p&gt;&lt;code&gt;-c&lt;/code&gt; doesn't execute keybinds in normal mode; it executes commands (what you normally do with &lt;kbd&gt;:&lt;/kbd&gt;). So you need to use the &lt;code&gt;execute&lt;/code&gt; command, which seems to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -c 'execute &quot;normal \\t&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We need the double &lt;code&gt;\\&lt;/code&gt; because we're issuing a shell command (and don't want&#xA;the shell to interpret this as an escape sequence).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tested with the keybind:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;t :echo &quot;TEST!&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't get &lt;code&gt;:execute &quot;normal &amp;lt;Leader&amp;gt;t&quot;&lt;/code&gt; to work; getting the value of &lt;code&gt;mapleader&lt;/code&gt; &lt;a href=&quot;https://vi.stackexchange.com/questions/281/how-can-i-find-out-what-leader-is-set-to?s=2|0.3927&quot;&gt;is also slightly more involved&lt;/a&gt; since you get an error if you &lt;em&gt;didn't&lt;/em&gt; set &lt;code&gt;mapleader&lt;/code&gt; to anything and use the default of &lt;code&gt;\&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-16T13:33:51.827" LastActivityDate="2015-02-16T13:33:51.827" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="848" PostTypeId="1" AcceptedAnswerId="1895" CreationDate="2015-02-16T13:59:33.657" Score="8" ViewCount="6811" Body="&lt;p&gt;I've the following sample html code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim http://example.com/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way to actually render html inside vim editor?&#xA;In example using markdown formatting or something similar?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example scenario: I'm logged on remote machine when I don't have access to GUI and I'd like to check how the html code looks like without opening external web browsers.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="51" LastEditDate="2015-02-16T14:11:11.677" LastActivityDate="2015-02-19T14:43:01.137" Title="How to render html file?" Tags="|external-command|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="849" PostTypeId="1" AcceptedAnswerId="851" CreationDate="2015-02-16T14:04:08.180" Score="11" ViewCount="2463" Body="&lt;p&gt;I've the following sample code which modifies the current line using Python statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py import vim; vim.current.line=&quot;[&quot;+vim.current.line+&quot;]&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How I can execute this statement for each line in the current file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related: &lt;a href=&quot;https://stackoverflow.com/questions/501585/how-can-you-use-python-in-vim&quot;&gt;How can you use Python in Vim?&lt;/a&gt; at stackoverflow&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-02-17T14:09:38.253" Title="How to execute python statement for each line?" Tags="|vimscript-python|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="850" PostTypeId="2" ParentId="849" CreationDate="2015-02-16T14:46:24.683" Score="7" Body="&lt;p&gt;You can get the current buffer with &lt;code&gt;vim.current.buffer&lt;/code&gt;, which is an iterable; you can use use a &lt;code&gt;for&lt;/code&gt; loop to get each line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change the lines by assigning to them; so putting that together, we get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py from vim import *&#xA;:py for i, line in enumerate(current.buffer): current.buffer[i] = '[%s]' % line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://vimhelp.appspot.com/if_pyth.txt.html#python-buffer&quot;&gt;&lt;code&gt;:help python-buffer&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-16T14:46:24.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="851" PostTypeId="2" ParentId="849" CreationDate="2015-02-16T15:25:25.527" Score="10" Body="&lt;p&gt;You can use the &lt;code&gt;pydo&lt;/code&gt; command available since Vim 7.4, the manual describe how it works better than I could:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:[range]pydo {body}   &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Execute Python function &quot;def _vim_pydo(line, linenr): {body}&quot; for each&#xA;  line in the [range], with the function arguments being set to the text&#xA;  of each line in turn, without a trailing &amp;lt;EOL&amp;gt;, and the current line&#xA;  number. The function should return a string or None. If a string is&#xA;  returned, it becomes the text of the line in the current turn. The&#xA;  default for [range] is the whole file: &quot;1,$&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For your example you can use a command like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:python import vim&#xA;:pydo vim.current.buffer[linenr - 1] = '[%s]' % line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;linenr - 1&lt;/code&gt; bit is there because lines in &lt;code&gt;vim.current.buffer&lt;/code&gt; are 0-indexed but Vim start to count lines from 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The nice thing is that you can easily define a custom command to execute your Python code on a range of lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% BracketLines &#xA;    \ &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;pydo vim.current.buffer[linenr - 1] = '[%s]' % line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2015-02-17T14:09:38.253" LastActivityDate="2015-02-17T14:09:38.253" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="852" PostTypeId="2" ParentId="835" CreationDate="2015-02-16T15:28:10.110" Score="2" Body="&lt;p&gt;Without adding any plugins you can add a known good word to your spell file.  Rather than &lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt; to bring up the spelling suggestions, visually select the text you want to add to the spell file and press &lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should also note that from within the spell suggestion window you can use the mouse to select the one you want as long as you have enabled the mouse for NORMAL mode.  I have &lt;code&gt;set mouse=a&lt;/code&gt; set in my .vimrc, for instance, which enables the mouse in all modes whether I am in Vim or gVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think the other things you want can be accomplished without a plugin or changing Vim itself.&lt;/p&gt;&#xA;" OwnerUserId="93" LastEditorUserId="93" LastEditDate="2015-02-19T02:58:58.443" LastActivityDate="2015-02-19T02:58:58.443" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="853" PostTypeId="5" CreationDate="2015-02-16T15:43:32.827" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-16T15:43:32.827" LastActivityDate="2015-02-16T15:43:32.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="854" PostTypeId="4" CreationDate="2015-02-16T15:43:32.827" Score="0" Body="Questions about calling external (shell) commands from within Vi or Vim." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-16T15:43:32.827" LastActivityDate="2015-02-16T15:43:32.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="855" PostTypeId="5" CreationDate="2015-02-16T15:45:40.970" Score="0" Body="&lt;p&gt;The documentation for this feature can be found at &lt;code&gt;:help complex-repeat&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.B. In most of the Vim documentation, &quot;macro&quot; is used as a synonym for &quot;mapping&quot;. However, the Vim community mostly uses the term to refer to Vim's &quot;Complex repeats&quot; feature.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="343" LastEditDate="2017-12-18T10:20:24.430" LastActivityDate="2017-12-18T10:20:24.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="856" PostTypeId="4" CreationDate="2015-02-16T15:45:40.970" Score="0" Body="A macro is a recording of typed commands that can be executed later. Macros are stored in registers; recording a macro can be done with q, and you can run them with @." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-16T15:45:40.970" LastActivityDate="2015-02-16T15:45:40.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="857" PostTypeId="5" CreationDate="2015-02-16T15:47:04.040" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-16T15:47:04.040" LastActivityDate="2015-02-16T15:47:04.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="858" PostTypeId="4" CreationDate="2015-02-16T15:47:04.040" Score="0" Body="A terminal emulator (or terminal, for short) displays characters, colours, and the cursor on the screen. Vi &amp; Vim are run inside of a terminal, gVim is not." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-16T15:47:04.040" LastActivityDate="2015-02-16T15:47:04.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="859" PostTypeId="2" ParentId="835" CreationDate="2015-02-16T16:28:09.450" Score="5" Body="&lt;p&gt;Looking at the &lt;code&gt;spell_suggest()&lt;/code&gt; function in &lt;code&gt;spell.c&lt;/code&gt; this doesn't seem possible with &lt;kbd&gt;z=&lt;/kbd&gt;. After getting &amp;amp; displaying all the possible suggestions, it does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Ask for choice. */&#xA;selected = prompt_for_number(&amp;amp;mouse_used);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;prompt_for_number()&lt;/code&gt; lives in &lt;code&gt;misc1.c&lt;/code&gt;, and does exactly what you would expect it to do: it prompts for a number (also see &lt;code&gt;get_number()&lt;/code&gt; in the same file). Mappings or other input isn't allowed.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A second option is to use Vim's spell &quot;completion&quot; through &lt;kbd&gt;Ctrl x&lt;/kbd&gt; + &lt;kbd&gt;s&lt;/kbd&gt; or &lt;kbd&gt;Ctrl x&lt;/kbd&gt; + &lt;kbd&gt;Ctrl s&lt;/kbd&gt;&lt;sup&gt;1&lt;/sup&gt; in insert mode. This does roughly what you want. You can choose from the completions with &lt;kbd&gt;Ctrl n&lt;/kbd&gt; and &lt;kbd&gt;Ctrl p&lt;/kbd&gt; or the arrow keys, or type your own improvement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;a href=&quot;https://github.com/ervandew/supertab&quot; rel=&quot;nofollow&quot;&gt;supertab&lt;/a&gt; plugin to do this with your &lt;kbd&gt;Tab&lt;/kbd&gt; key. &lt;code&gt;:help ins-completion&lt;/code&gt; also has a &lt;code&gt;CleverTab()&lt;/code&gt; function which you could adapt for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#ins-completion&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help ins-completion&lt;/code&gt;&lt;/a&gt;,&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-X_s&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help i_CTRL-X_s&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Finally, Vim has the &lt;code&gt;spellsuggest()&lt;/code&gt; function, which returns a list of spelling suggestions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo spellsuggest('hellz')&#xA;['hells', 'hello', 'hell', 'help', 'halls', 'heals', 'heels', 'hills', 'hulls', 'hell''s',&#xA; 'hellos', 'hell’s', 'held', 'helm', 'tell', 'well', 'bells', 'cells', 'dells', 'fells',&#xA; 'helot', 'helve', 'hertz', 'hilly', 'holly']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could use this function to construct your own spell suggestion screen.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Footnote&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;1&lt;/em&gt;: Note that using &lt;kbd&gt;Ctrl s&lt;/kbd&gt; may not work, as the docs mention:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;NOTE: CTRL-S suspends display in many Unix terminals.  Use 's' instead.  Type&#xA;  CTRL-Q to resume displaying.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you're using gVim, using &lt;kbd&gt;Ctrl s&lt;/kbd&gt; should work. Or you could disable this in your terminal with &lt;code&gt;stty -ixon&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-16T20:46:42.217" LastActivityDate="2015-02-16T20:46:42.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="860" PostTypeId="5" CreationDate="2015-02-16T18:34:30.720" Score="0" Body="&lt;p&gt;The Python interface is available only when Vim was compiled with the&#xA;+python or +python3 feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check if it's available, run: &lt;code&gt;:echo has('python')&lt;/code&gt; (1 stands for yes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;code&gt;:help python&lt;/code&gt; for help.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-02-17T02:34:43.757" LastActivityDate="2015-02-17T02:34:43.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="861" PostTypeId="4" CreationDate="2015-02-16T18:34:30.720" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-16T18:34:30.720" LastActivityDate="2015-02-16T18:34:30.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="862" PostTypeId="1" AcceptedAnswerId="863" CreationDate="2015-02-16T19:36:37.503" Score="12" ViewCount="376" Body="&lt;p&gt;I use &lt;code&gt;:r !uuidgen&lt;/code&gt; frequently to insert a new uuid into the buffer. This works, but I am generally attempting to insert the uuid between quotes, and &lt;code&gt;:r !uuidgen&lt;/code&gt; prints the uuid on a new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get around this issue, I am currently using a simple keymap:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-u&amp;gt; mm:r!uuidgen&amp;lt;CR&amp;gt;dW&quot;_dd`mp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This macro sets the mark &lt;code&gt;mm&lt;/code&gt;, inserts the uuid &lt;code&gt;r!uuidgen&lt;/code&gt;, deletes the inserted uuid &lt;code&gt;dW&lt;/code&gt;, deletes the extra line &lt;code&gt;&quot;_dd&lt;/code&gt;, goes back to the mark &lt;code&gt;BACKTICKm&lt;/code&gt;, and finally paste the uuid &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to &lt;code&gt;:r&lt;/code&gt; right after the cursor without this macro/keybinding that wastes a register?&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastEditorDisplayName="user489" LastEditDate="2015-02-16T19:55:19.903" LastActivityDate="2017-01-11T05:49:16.943" Title=":read after cursor instead of after line" Tags="|external-command|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="863" PostTypeId="2" ParentId="862" CreationDate="2015-02-16T20:11:32.900" Score="9" Body="&lt;p&gt;You can use the expression register &lt;code&gt;&quot;=&lt;/code&gt; and &lt;code&gt;system()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;=system(&quot;uuidgen | tr -d '\n'&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would look like that in an insert mode mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;key&amp;gt; &amp;lt;C-r&amp;gt;=system(&quot;uuidgen | tr -d '\n'&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or, with an expression mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;key&amp;gt; system(&quot;uuidgen \| tr -d '\n'&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-02-16T20:16:51.697" LastActivityDate="2015-02-16T20:16:51.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="864" PostTypeId="2" ParentId="862" CreationDate="2015-02-16T20:17:34.843" Score="5" Body="&lt;p&gt;From insert mode, you can hit &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;, and then type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;=system('uuidgen')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this will add a trailing newline, because that's what &lt;code&gt;uuidgen&lt;/code&gt; outputs; to fix this, we could use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;=system('uuidgen')[:-2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To remove the newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-R&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help i_CTRL-R&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Insert the contents of a register.  Between typing CTRL-R and the second&#xA;  character, '&quot;' will be displayed to indicate that you are expected to enter&#xA;  the name of a register.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[..]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;'='     the expression register: you are prompted to enter an expression (see&#xA;  expression)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To bind this to &lt;kbd&gt;Ctrl-u&lt;/kbd&gt; like your example, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-u&amp;gt; i&amp;lt;C-r&amp;gt;=system('uuidgen')[:-2]&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-16T20:23:51.180" LastActivityDate="2015-02-16T20:23:51.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="865" PostTypeId="2" ParentId="862" CreationDate="2015-02-16T20:28:20.317" Score="2" Body="&lt;p&gt;One more, with &lt;code&gt;:python&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py import uuid, vim; vim.command(':normal i' + str(uuid.uuid1()))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could map as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;key&amp;gt; &amp;lt;esc&amp;gt;:py import uuid, vim; vim.command(':normal a' + str(uuid.uuid1()))&amp;lt;cr&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The UUIDs are generated by the &lt;a href=&quot;https://docs.python.org/2/library/uuid.html&quot; rel=&quot;nofollow&quot;&gt;Python UUID module&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-02-16T20:28:20.317" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="869" PostTypeId="1" AcceptedAnswerId="870" CreationDate="2015-02-17T05:53:31.317" Score="5" ViewCount="266" Body="&lt;p&gt;Vim has excellent inbuilt autocompletions. I've noticed that using &lt;code&gt;C-x C-k&lt;/code&gt; (see &lt;code&gt;:h i_CTRL-X_CTRL-K&lt;/code&gt; for more) for dictionary completion will not respect the case by default. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if I type &lt;code&gt;Carr&lt;/code&gt;, Vim might suggest &lt;code&gt;carrot&lt;/code&gt; instead of &lt;code&gt;Carrot&lt;/code&gt;. Is there a way to have vim respect case (or at least offer to respect case) with dictionary autocompletion?&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2015-02-17T08:36:38.557" Title="How to make `C-x C-k` dictionary completion respect case?" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="870" PostTypeId="2" ParentId="869" CreationDate="2015-02-17T08:36:38.557" Score="5" Body="&lt;p&gt;Adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set smartcase&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your &lt;code&gt;vimrc&lt;/code&gt; should fix your problem&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-02-17T08:36:38.557" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="871" PostTypeId="2" ParentId="328" CreationDate="2015-02-17T13:16:34.317" Score="4" Body="&lt;p&gt;Personally, I use the &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt; keybinding from Tim Pope's excellent &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow&quot;&gt;vim-unimpaired&lt;/a&gt; plugin for exactly this reason. From his documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A toggle has not been provided for 'paste' because the typical use&#xA;  case of wrapping of a solitary insertion is so wasteful:  You toggle&#xA;  twice, but you only paste once (YOPO).  Instead, press &lt;code&gt;yo&lt;/code&gt; or &lt;code&gt;yO&lt;/code&gt; to&#xA;  invoke &lt;code&gt;|o|&lt;/code&gt; or &lt;code&gt;|O|&lt;/code&gt; with 'paste' already set.  Leaving insert mode sets&#xA;  'nopaste' automatically.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It might be overkill to install the plugin simply for your question, but I find it provides a wealth of other useful keybindings too (more information in &lt;a href=&quot;https://github.com/tpope/vim-unimpaired/blob/master/README.markdown&quot; rel=&quot;nofollow&quot;&gt;the README&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="91" LastActivityDate="2015-02-17T13:16:34.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="872" PostTypeId="2" ParentId="130" CreationDate="2015-02-17T13:27:06.887" Score="2" Body="&lt;p&gt;Assuming you'd like to add prefix to 5 lines at the beginning of the line, then you can use &lt;a href=&quot;http://vim.wikia.com/wiki/Search_and_replace&quot; rel=&quot;nofollow noreferrer&quot;&gt;Search and replace&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,+5s/^/prefix_/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or at the end of the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,+5s/$/suffix_/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or use visual mode (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;) to select vertical block of text, then enter insert mode (&lt;kbd&gt;I&lt;/kbd&gt;) and type something and press &lt;kbd&gt;Esc&lt;/kbd&gt; to confirm and apply the changes to other lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/1174274/how-can-i-prepend-text-to-multiple-lines-in-vim&quot;&gt;How can I prepend text to multiple lines in Vim?&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/8763837/create-a-vim-function-to-prefix-all-lines&quot;&gt;Create a Vim function to prefix all lines&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://superuser.com/questions/345877/prepend-only-lines-with-text-in-vim&quot;&gt;Prepend only lines with text in vim&lt;/a&gt; at superuser&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://superuser.com/questions/201383/vim-seeing-all-lines-change-when-inserting-to-a-visual-block&quot;&gt;Seeing &lt;em&gt;all&lt;/em&gt; lines change when inserting to a visual block&lt;/a&gt; at superuser&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-17T13:27:06.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1871" PostTypeId="1" AcceptedAnswerId="1882" CreationDate="2015-02-17T14:35:31.983" Score="12" ViewCount="1014" Body="&lt;p&gt;&lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; allow the completion of words found within the current document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am taking some notes and writing say &lt;code&gt;{0,1}^n&lt;/code&gt; and &lt;code&gt;(E,D)&lt;/code&gt; many times. These are WORDs constituted by several words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to complete WORDs with &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; (or other related &lt;code&gt;ins-completion&lt;/code&gt; command)?&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="356" LastEditDate="2015-02-17T18:51:59.183" LastActivityDate="2015-02-22T04:40:32.943" Title="Ins-completion of WORDs" Tags="|autocompletion|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1872" PostTypeId="2" ParentId="848" CreationDate="2015-02-17T17:05:27.703" Score="9" Body="&lt;p&gt;Not really. Vim's rendering engine is not designed for this sort of thing. It just renders text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you could use a text-mode browser such as &lt;a href=&quot;http://w3m.sourceforge.net/&quot;&gt;&lt;code&gt;w3m&lt;/code&gt;&lt;/a&gt; to turn your HTML into text and then load that into vim. Create a new buffer and use &lt;code&gt;:r !&lt;/code&gt; (see &lt;code&gt;:help :r&lt;/code&gt;) to read in the result of the &lt;code&gt;w3m&lt;/code&gt; conversion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r !w3m -dump your-html-file.html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-02-17T17:05:27.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1873" PostTypeId="1" AcceptedAnswerId="1878" CreationDate="2015-02-17T17:19:07.207" Score="14" ViewCount="3763" Body="&lt;p&gt;I've noticed while editing along a line in a .txt file in insert mode the cursor will move to the start of the line following a write using key sequence:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;esc&amp;gt;:w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to &lt;strong&gt;change this behavior such that the cursor will stay in position following a :write.&lt;/strong&gt; Is this possible? I don't need the cursor to remain in insert mode, I'd just like it to maintain its last position following a write.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using gVim 7.4 on windows. My .vimrc is very basic, I don't believe any of my settings interfere with this behavior. I have also removed sourcing of mswin.vim and example.vim from my .vimrc (as bundled with the official vim.org windows installer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading the comments below I looked at the issue again and realized the cursor only slides to the far left after a write on lines which are entirely made up of trailing white space. In other words, the cursor &lt;strong&gt;only slides to the far left upon esc-:w when the line is a hanging indent with no other characters besides spaces&lt;/strong&gt;. The .vimrc is handling indent behaviors with these settings: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4&#xA;set softtabstop=4&#xA;set shiftwidth=4&#xA;set expandtab&#xA;set autoindent &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, a new line created below an indented line will contain 4 trailing white spaces as the first 4 spaces of the line (which I want to keep). Upon the 'esc' key press the cursor slides to the far left of the buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to retain cursor position upon hitting 'esc' to return to normal mode, on a line made up of trailing white spaces (as indentation)?&lt;/p&gt;&#xA;" OwnerUserId="231" LastEditorUserId="630" LastEditDate="2015-03-08T18:27:28.530" LastActivityDate="2015-03-08T18:27:28.530" Title="Why does the cursor move to the start of the line after &lt;Esc&gt;?" Tags="|cursor-movement|save|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1874" PostTypeId="1" CreationDate="2015-02-17T19:58:55.373" Score="15" ViewCount="1172" Body="&lt;p&gt;If I have windows arranged into four quadrants, as from the following sequence of commands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabnew&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:vsplit&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:split&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-W&amp;gt;l&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:split&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;then entering a command like &lt;code&gt;&amp;lt;C-W&amp;gt;J&lt;/code&gt; will cause these to no longer be square; in this case, it will force one window to float at the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do the opposite—that is, force the windows back into a square formation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've read &lt;code&gt;:help window-moving&lt;/code&gt; but didn't see anything useful.&lt;/p&gt;&#xA;" OwnerUserId="142" LastEditorUserId="24" LastEditDate="2015-02-19T10:31:41.263" LastActivityDate="2015-02-22T08:24:01.913" Title="How can I get my windows back into a grid formation?" Tags="|vim-windows|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1875" PostTypeId="5" CreationDate="2015-02-17T20:06:07.277" Score="0" Body="&lt;p&gt;In Vim, a &lt;strong&gt;window&lt;/strong&gt; is a visual view of a buffer.&#xA;There can be multiple (or no) windows associated with any given buffer, and each window can be in a different state (e.g., viewing a different part of the buffer).&#xA;Windows are grouped together in tab pages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some common operations on windows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Quickly create windows with the &lt;code&gt;:split&lt;/code&gt; and &lt;code&gt;:vsplit&lt;/code&gt; commands.&#xA;Execute &lt;code&gt;:split&lt;/code&gt; to divide the current window horizontally into two&#xA;views of the same buffer, and use &lt;code&gt;:vsplit&lt;/code&gt; to divide the window&#xA;vertically. By providing an argument to &lt;code&gt;:split&lt;/code&gt; or &lt;code&gt;:vsplit&lt;/code&gt;, you&#xA;can specify a different file to view in the new window.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Switch windows with the &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; commands. Press &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; and then one&#xA;of &lt;code&gt;h&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, or &lt;code&gt;l&lt;/code&gt; to move left, down, up, or to the right,&#xA;respectively.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Close a window with &lt;code&gt;&amp;lt;C-W&amp;gt;c&lt;/code&gt; or &lt;code&gt;:q&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help windows&lt;/code&gt; within Vim for more information.&lt;/p&gt;&#xA;" OwnerUserId="142" LastEditorUserId="51" LastEditDate="2015-02-17T21:55:41.327" LastActivityDate="2015-02-17T21:55:41.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1876" PostTypeId="4" CreationDate="2015-02-17T20:06:07.277" Score="0" Body="A Vim window is a view of a buffer. A tab page comprises one or more windows. Not to be confused with [tag:microsoft-windows]." OwnerUserId="142" LastEditorUserId="51" LastEditDate="2015-02-17T21:53:57.583" LastActivityDate="2015-02-17T21:53:57.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1877" PostTypeId="2" ParentId="838" CreationDate="2015-02-17T20:07:38.387" Score="4" Body="&lt;p&gt;Are you trying to remove the unnecessary spaces or are you just trying to format your code correctly. Because there are different solutions to the problem.&lt;/p&gt;&#xA;&lt;h2&gt;Do correct formatting:&lt;/h2&gt;&#xA;&lt;p&gt;You can get vim to correctly indent your code by using &lt;code&gt;={motion}&lt;/code&gt; command&lt;/p&gt;&#xA;&lt;p&gt;The easiest way to use this is to use visual mode.&lt;br /&gt;&#xA;Go to the start of the section you want correctly indented. Hit Ctrl-V. Move the cursor to the end of the section you want correctly indented (can be the whole file). Hit &lt;code&gt;=&lt;/code&gt; key and your code will be correctly formatted.&lt;/p&gt;&#xA;&lt;h2&gt;Replace space (where you have tabs to indent).&lt;/h2&gt;&#xA;&lt;p&gt;Since you are using tabs.&lt;br /&gt;&#xA;The following assumes you don't have &lt;code&gt;expandtabs&lt;/code&gt; set&lt;/p&gt;&#xA;&lt;p&gt;The following should preserve the normal indentation of your lines. Any lines with extra space characters at the end of the initial indentation will change slightly as those extra spaces will be removed.&lt;/p&gt;&#xA;&lt;p&gt;If you do this a lot (as it is several steps) it may be worth wrapping this in some type of function. But my vim foo is not that strong yet. The following assumes you have your tab stop set at 4 you may need to alter a couple of the searches if you use a different size.&lt;/p&gt;&#xA;&lt;p&gt;I would do it in three steps.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; :retab 1&#xA; :% s/^I/ /g&#xA; :retab 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This converts all you tabs to spaces first (without messing with the indentation). (by first resizing your tabs replacing them with space then setting the tab size back to its original size).&lt;/p&gt;&#xA;&lt;p&gt;Now you can convert all the leading space on a line into tabs.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; :% g/^    /s/    /^I/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The above searches for all lines that begin with four spaces (use the number of spaces you have in your tab stop size). And replaces from left to right each group of four spaces with a tab character.&lt;/p&gt;&#xA;&lt;p&gt;So now all your lines have leading tabs and any extra space is on the end of the initial tab indented line. So now you can just remove any trailing white space as we expect this is unneeded.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; :% s/^\(^I*\) */\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This searches for lines that begin with zero or more tabs followed by zero or more spaces. It then replaces the match with the initial number of tabs you found. Thus effectively removing space from the indentation.&lt;/p&gt;&#xA;" OwnerUserId="383" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-02-18T21:07:07.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1878" PostTypeId="2" ParentId="1873" CreationDate="2015-02-17T21:02:06.540" Score="12" Body="&lt;p&gt;Looking at the documentation for autoindent has an answer as to why and how to work around it. &lt;code&gt;:help 'autoindent'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Copy indent from current line when starting a new line (typing &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&#xA;          in Insert mode or when using the &quot;o&quot; or &quot;O&quot; command).  If you do not&#xA;          type anything on the new line except &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; or &lt;code&gt;CTRL-D&lt;/code&gt; and then type&#xA;          &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, &lt;code&gt;CTRL-O&lt;/code&gt; or &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, the indent is deleted again.  Moving the cursor&#xA;          to another line has the same effect, unless the 'I' flag is included&#xA;          in 'cpoptions'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In other words, if you want it to not lose the indent, type &lt;em&gt;something&lt;/em&gt; and then backspace it &lt;em&gt;before&lt;/em&gt; hitting &lt;kbd&gt;Esc&lt;/kbd&gt;, and the leading space will remain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if you just want to be back at the indent-level when you go back into insert mode and are using &lt;code&gt;'cindent'&lt;/code&gt; as well, use &lt;kbd&gt;Shift-S&lt;/kbd&gt; instead of &lt;kbd&gt;i&lt;/kbd&gt;, which will clear the (already empty) line, and start at the appropriate indentation level. This is not as general a solution as the one above, but I prefer this when I'm writing C code, so that my files don't actually get saved with white-space only lines.&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-02-17T21:02:06.540" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1879" PostTypeId="1" CreationDate="2015-02-17T21:33:33.580" Score="3" ViewCount="2342" Body="&lt;p&gt;I am using Vim on windows. Any time I edited a file, Vim is created temporary files. When I created a file,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    mysql-build-properties.xml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim is creating files like these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    mysql-build-properties.xml~&#xA;    mysql-build-properties.xml~~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are these files Vim temporary files? If so, how do to stop it?&lt;/p&gt;&#xA;" OwnerUserId="408" LastEditorUserId="927" LastEditDate="2015-02-21T20:42:34.923" LastActivityDate="2015-02-21T20:42:34.923" Title="Vim Windows creating temporary files" Tags="|swap-file|backup|" AnswerCount="1" CommentCount="0" ClosedDate="2015-02-17T23:08:32.997" ContentLicense="CC BY-SA 3.0" />
  <row Id="1880" PostTypeId="2" ParentId="846" CreationDate="2015-02-17T21:41:44.600" Score="7" Body="&lt;p&gt;You could make a function that creates the new entry, and then use the function as part of your mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;t :call NewEntry()&amp;lt;cr&amp;gt;&#xA;function! NewEntry()&#xA;  let title = expand('~/Notes/') . strftime('%F') . '-' . input(&quot;Title: &quot;)&#xA;  execute 'edit ' . title&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mapping may be called as described by @Carpetsmoker:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c 'execute &quot;normal \\t&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-02-17T21:41:44.600" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1881" PostTypeId="2" ParentId="1879" CreationDate="2015-02-17T21:44:36.993" Score="2" Body="&lt;p&gt;I think these are the vim backup files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should turn them off:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nobackup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There will still be one while vim is actually writing the file (e.g, during the &lt;code&gt;:w&lt;/code&gt; command; use &lt;code&gt;set nowritebackup&lt;/code&gt; to disable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a swap file, another temporary file. That exists only when vim is running; its purpose is to recover unsaved changes if e.g., vim crashes. To disable this as well, &lt;code&gt;set noswapfile&lt;/code&gt;. You can also put these in a different directory via the &lt;code&gt;directory&lt;/code&gt; setting.&lt;/p&gt;&#xA;" OwnerUserId="31" LastActivityDate="2015-02-17T21:44:36.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1882" PostTypeId="2" ParentId="1871" CreationDate="2015-02-17T21:45:01.120" Score="5" Body="&lt;h2&gt;Insert mode completion with &lt;kbd&gt;Ctrl-n&lt;/kbd&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I don't know if you could do WORD completion outside of writing your own function (like omnifunc). However, if you don't mind expanding what a word is to match your characters, you can add those characters to 'iskeyword'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, my 'iskeyword' defaults to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iskeyword=@,48-57,_,192-255&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then set it to that plus the additional characters above&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set iskeyword=@,48-57,_,192-255,{,},,,(,),^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This adds &lt;code&gt;{&lt;/code&gt;, &lt;code&gt;}&lt;/code&gt;, &lt;code&gt;,&lt;/code&gt;, &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;)&lt;/code&gt;, and &lt;code&gt;^&lt;/code&gt; to the characters that make up a word (in addition to what already did)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, typing &lt;code&gt;{&lt;/code&gt;&lt;kbd&gt;Ctrl-n&lt;/kbd&gt; completes to &lt;code&gt;{0,1}^n&lt;/code&gt; (in a file containing only those two examples you gave)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: It would be better to do a &lt;code&gt;:set iskeyword+=&lt;/code&gt; with just the additional stuff, as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set iskeyword+={,},,,(,),^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, you leave whatever other things make up a keyword already by appending the new characters to the existing setting.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Expansion with abbreviations&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Although not part of the original question, another similar(ish) functionality is to use nvi or Vim's abbreviation functionality. Unlike keyword completion, abbreviations don't have to look like the final text. Also unlike keyword completion, abbreviations expand automatically, instead of only when you ask for them. Depending on your goal and usage, this can save a lot of typing, and let you type lots of text without the interruption of asking for a completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Abbreviations are good for a small set of keywords and when you can define them ahead of time (they aren't discovered from your text like word completion is).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic idea behind abbreviations is that you associate a WORD with some other text, and any time the editor detects that you typed that WORD (that is, the text you typed is surrounded by white space, where the completion action is adding the whitespace after the keyword or leaving insert mode), it is replaced with that other text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say your file contains &lt;code&gt;{0,1}^n&lt;/code&gt; a lot, and there aren't other variations of it. Typing that is a bit of a finger stretch, so maybe you want to just type &lt;code&gt;01n&lt;/code&gt; or &lt;code&gt;myvalue&lt;/code&gt; and have it expand to &lt;code&gt;{0,1}^n&lt;/code&gt;, but only when &lt;code&gt;01n&lt;/code&gt; or &lt;code&gt;myvalue&lt;/code&gt; is a word on its own (that is, if it happens to appear within another word, don't change it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In nvi, you can do &lt;code&gt;:abbrev 01n {0,1}^n&lt;/code&gt;. You can do the same in Vim, but I recommend using &lt;code&gt;:iabbrev 01n {0,1}^n&lt;/code&gt; to restrict the expansion to insert mode only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, if you have some text (where &lt;code&gt;|&lt;/code&gt; represents the cursor)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;We find that the value 01n|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then you hit &lt;kbd&gt;Esc&lt;/kbd&gt; or &lt;kbd&gt;Space&lt;/kbd&gt; or &lt;kbd&gt;Tab&lt;/kbd&gt; or otherwise move the cursors, the text gets replaced, and you have (example for using space)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;We find that the value {0,1}^n |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you can continue typing without interruption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is usually used to auto-correct common typos (e.g. changing 'teh' into 'the') but it can be equally useful for your use case, again assuming that you don't mind setting up the mappings ahead of time.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-02-22T04:40:32.943" LastActivityDate="2015-02-22T04:40:32.943" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1883" PostTypeId="2" ParentId="300" CreationDate="2015-02-17T23:09:29.517" Score="7" Body="&lt;p&gt;If you have an US English keyboard, pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;[&lt;/kbd&gt; is equivalent for pressing &lt;kbd&gt;Esc&lt;/kbd&gt;. This provides an easy way to exit from insert mode. Alternatively use &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;c&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you've vim in easy mode (&lt;code&gt;-y&lt;/code&gt;), then you've to press &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;l&lt;/kbd&gt; (Control-L) to exit insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;o&lt;/kbd&gt; which will only temporary exit insert mode just to execute one command and return back to insert mode (see: &lt;code&gt;:help i_CTRL-O&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt;, but it's only for inserting content of register or expression, e.g. &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt;, &lt;kbd&gt;=5*5&lt;/kbd&gt; (see: &lt;code&gt;:help i_CTRL-R&lt;/code&gt;, &lt;code&gt;:help c_CTRL-R&lt;/code&gt; and &lt;a href=&quot;https://stackoverflow.com/a/2960630/55075&quot;&gt;stackoverflow post&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read more at: &lt;a href=&quot;http://vim.wikia.com/wiki/Avoid_the_escape_key&quot; rel=&quot;noreferrer&quot;&gt;Avoid the escape key&lt;/a&gt; at vim wikia&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-19T08:43:20.833" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1884" PostTypeId="2" ParentId="1874" CreationDate="2015-02-17T23:22:32.887" Score="4" Body="&lt;p&gt;As far as I know, there is no easy way to arrange open splits into a grid of splits. In this case, the easiest way to get back into a grid is to manually rectify the structure: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;close the split floating at the top&lt;/li&gt;&#xA;&lt;li&gt;return to the split taking up half the screen&lt;/li&gt;&#xA;&lt;li&gt;re-split it with &lt;code&gt;:split &amp;lt;file&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This will return you to a grid. The way to maneuver splits without affecting the window layout is to use [count]&lt;kbd&gt; Ctrl &lt;/kbd&gt;-&lt;kbd&gt;W&lt;/kbd&gt; &lt;kbd&gt;x &lt;/kbd&gt;, which exchanges the current window with the [count] window.&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2015-02-17T23:22:32.887" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1885" PostTypeId="2" ParentId="104" CreationDate="2015-02-17T23:25:22.127" Score="142" Body="&lt;p&gt;Register &lt;code&gt;%&lt;/code&gt; contains the name of the current file.&lt;/p&gt;&#xA;&lt;p&gt;The following commands could be entered to display the information shown:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:echo @%                |&amp;quot; directory/name of file&#xA;:echo expand('%:t')     |&amp;quot; name of file ('tail')&#xA;:echo expand('%:p')     |&amp;quot; full path&#xA;:echo expand('%:p:h')   |&amp;quot; directory containing file ('head')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or alternatively, using the shell's echo:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:!echo %&#xA;:!echo %:t&#xA;:!echo %:p&#xA;:!echo %:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If all that is wanted is to display the name of the current file, type &lt;code&gt;:f&lt;/code&gt;/&lt;code&gt;:ls&lt;/code&gt; or press &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;g&lt;/kbd&gt; (for full path press &lt;kbd&gt;1&lt;/kbd&gt; then &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;g&lt;/kbd&gt;).&lt;/p&gt;&#xA;&lt;p&gt;In insert mode, type &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;r&lt;/kbd&gt; then &lt;kbd&gt;%&lt;/kbd&gt; to insert the name of the current file.&lt;/p&gt;&#xA;&lt;p&gt;The following commands insert lines consisting of the full path of the current and alternate files into the buffer:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:put =expand('%:p')&#xA;:put =expand('#:p')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://vim.wikia.com/wiki/Get_the_name_of_the_current_file&quot; rel=&quot;noreferrer&quot;&gt;Get the name of the current file&lt;/a&gt; at vim wikia&lt;/p&gt;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/4111696/how-do-you-display-the-filename-of-the-file-you-are-working-on-in-vim&quot;&gt;How do you display the filename of the file you are working on in vim?&lt;/a&gt; at stackoverflow SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/104901/how-to-find-out-which-file-is-currently-opened-in-vim&quot;&gt;How to find out which file is currently opened in vim?&lt;/a&gt; at unix SE&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="14340" LastEditDate="2023-08-30T13:31:09.583" LastActivityDate="2023-08-30T13:31:09.583" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1886" PostTypeId="2" ParentId="104" CreationDate="2015-02-18T00:35:09.133" Score="11" Body="&lt;p&gt;There are aleady better answers, but if (for some reason) you wanted to use the shell to get the full path of the file (this is more useful if you're going to perform some other operation on the file with the shell), on a Unix-like system you could run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!realpath %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!realpath %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to insert the path into the document over the current selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Register &lt;code&gt;%&lt;/code&gt; always contains the name of the file. A realworld example might be if you're editing a config file, but don't have write permissions (and don't want ot run Vim as root), you could edit the file, then run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w ! sudo tee %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to save the file (a tiny bit offtopic there, but it's a good example of what else can be done with the &lt;code&gt;%&lt;/code&gt; register).&lt;/p&gt;&#xA;" OwnerDisplayName="anon" LastEditorDisplayName="anon" LastEditDate="2017-06-30T21:52:32.597" LastActivityDate="2017-06-30T21:52:32.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1887" PostTypeId="1" AcceptedAnswerId="1888" CreationDate="2015-02-18T02:32:37.573" Score="16" ViewCount="4110" Body="&lt;p&gt;I have a list of words, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;these are&#xA;some&#xA;words that I want&#xA;to convert to&#xA;camel case&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need a way to turn, for example, &lt;code&gt;camel case&lt;/code&gt; into &lt;code&gt;camelCase&lt;/code&gt; within a macro (or a way to turn every line of a visual line selection into camel case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could use something like &lt;code&gt;wgUlhx&lt;/code&gt; as many times as necessary, but the problem is that this doesn't work for words of varying lengths (so, for example, &lt;code&gt;wgUlhxwgUlhx&lt;/code&gt; would work for &lt;code&gt;convert this please&lt;/code&gt; but not for &lt;code&gt;convert these pretty please&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The desired output for the above lines would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;theseAre&#xA;some&#xA;wordsThatIWant&#xA;toConvertTo&#xA;camelCase&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way to automate this?&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-09-09T02:21:19.660" Title="How can I convert words to camelCase in a macro?" Tags="|letter-case|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1888" PostTypeId="2" ParentId="1887" CreationDate="2015-02-18T02:45:41.950" Score="18" Body="&lt;h2&gt;A One Liner&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I found a simple regular expression replacement (assuming 'magic' is set):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/ \([a-zA-Z]\)/\u\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This match any single letter after a space, saving the letter. Then, it replaces it with the saved letter made upper case (&lt;code&gt;\u&lt;/code&gt; = upper case, &lt;code&gt;\1&lt;/code&gt; = first saved match), for every match in the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apply over the entire file by putting a &lt;code&gt;%&lt;/code&gt; between &lt;code&gt;:&lt;/code&gt; and &lt;code&gt;s&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The downside to this solution is that it is linewise (which works for your examples), but would fall short if you only wanted to camel case a few words out of many within a line.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;A fuller solution&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;g~ :set opfunc=MyCamelCase&amp;lt;CR&amp;gt;g@&#xA;function! MyCamelCase(type, ...)&#xA;  let searchsave=@/&#xA;    silent s/\%&amp;gt;'\[ \([a-zA-Z]\)\%&amp;lt;']/\u\1/g&#xA;  let @/=searchsave&#xA; endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This creates a new operator that can operate on a motion. If you have &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; as &lt;code&gt;\&lt;/code&gt;, then given the following text (with &lt;code&gt;|&lt;/code&gt; as the cursor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is some |example text to work with.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;\g~3w&lt;/code&gt; gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is some exampleTextTo work with.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, we camel cased over 3 words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Description of that substitution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s/&lt;/code&gt; starts the substitution.&lt;br&gt;&#xA;&lt;code&gt;\%&amp;gt;'\[&lt;/code&gt; is a bit painful. The &lt;code&gt;\%&amp;gt;'m&lt;/code&gt; says to match to the right of a mark. We want mark &lt;code&gt;[&lt;/code&gt;, but that also has to be escaped in this pattern. So, this starts the match after the motion given to the operator.&lt;br&gt;&#xA;&lt;code&gt;\([a-zA-Z\)&lt;/code&gt; is the same as from the one-liner above.&lt;br&gt;&#xA;&lt;code&gt;\%&amp;lt;']&lt;/code&gt; this is the other end, matching before the end of the motion.&lt;br&gt;&#xA;&lt;code&gt;/\u\1/g&lt;/code&gt; is the replacement from the one-liner above.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-02-18T05:57:13.307" LastActivityDate="2015-02-18T05:57:13.307" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1889" PostTypeId="1" CreationDate="2015-02-18T03:25:28.700" Score="13" ViewCount="17724" Body="&lt;p&gt;I get this problem when I start Vim with &lt;code&gt;-p&lt;/code&gt; option. Suppose, I started out with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -p first.txt second.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then after editing &lt;code&gt;first.txt&lt;/code&gt; I move to &lt;code&gt;second.txt&lt;/code&gt; using &lt;code&gt;gt&lt;/code&gt;. I press the keys &lt;code&gt;gg&lt;/code&gt; and &lt;code&gt;G&lt;/code&gt; again. This produces the error &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vim: Caught deadly signal SEGV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From this point, Vim doesn't respond to any signal including &lt;kbd&gt;Ctrl&lt;/kbd&gt; &lt;kbd&gt;D&lt;/kbd&gt;. I can close this session only by killing the terminal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem arises only when I invoke Vim with &lt;code&gt;-p&lt;/code&gt; option. If I open &lt;code&gt;first.txt&lt;/code&gt; first and then use &lt;code&gt;:tabe&lt;/code&gt; to open &lt;code&gt;second.txt&lt;/code&gt;, this problem doesn't arise. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas why this might occur?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Output of &lt;code&gt;vim --version&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:40:46)&#xA;Included patches: 1-52&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by buildd@&#xA;Huge version with GTK2-GNOME GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;+balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;+browse          +folding         +mouse_xterm     +tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;+clientserver    -hangul_input    +netbeans_intg   +title&#xA;+clipboard       +iconv           +path_extra      +toolbar&#xA;+cmdline_compl   +insert_expand   +perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python          +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con_gui  +lua             +rightleft       +windows&#xA;+diff            +menu            +ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      +X11&#xA;+dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     +xim&#xA;+emacs_tags      +mouseshape      -sniff           +xsmp_interact&#xA;+eval            +mouse_dec       +startuptime     +xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    +xpm&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/harfbuzz   -pthread -DORBIT2=1 -D_REENTRANT -I/usr/include/libgnomeui-2.0 -I/usr/include/libart-2.0 -I/usr/include/gconf/2 -I/usr/include/gnome-keyring-1 -I/usr/include/libgnome-2.0 -I/usr/include/libbonoboui-2.0 -I/usr/include/libgnomecanvas-2.0 -I/usr/include/gtk-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gnome-vfs-2.0 -I/usr/lib/i386-linux-gnu/gnome-vfs-2.0/include -I/usr/include/dbus-1.0 -I/usr/lib/i386-linux-gnu/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/orbit-2.0 -I/usr/include/libbonobo-2.0 -I/usr/include/bonobo-activation-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/gail-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/atk-1.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/cairo -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/libpng12     -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     -I/usr/include/tcl8.6  -D_REENTRANT=1  -D_THREAD_SAFE=1  -D_LARGEFILE64_SOURCE=1  &#xA;Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfontconfig -lgobject-2.0 -lglib-2.0 -lfreetype     -lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnomevfs-2 -lgnomecanvas-2 -lgnome-2 -lpopt -lbonobo-2 -lbonobo-activation -lORBit-2 -lart_lgpl_2 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfontconfig -lfreetype -lgconf-2 -lgthread-2.0 -lgmodule-2.0 -lgobject-2.0 -lglib-2.0   -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector -L/usr/local/lib  -L/usr/lib/perl/5.18/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config-i386-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions  -L/usr/lib/i386-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-1.9.1 -lpthread -lrt -ldl -lcrypt -lm  -L/usr/lib   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output of &lt;code&gt;uname -a&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Linux nitish 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:37:48 UTC 2015 i686 i686 i686 GNU/Linux&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Based on comments by @Carpetsmoker, I found out that the problem is because of my &lt;code&gt;.vimrc&lt;/code&gt; file. So I checked ran the problem causing command with some portions of the &lt;code&gt;.vimrc&lt;/code&gt; file commented. Finally I found out that the problem is with the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set columns=1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can so innocent command cause this problem? &lt;code&gt;:help columns&lt;/code&gt; didn't give any useful information regarding this.&lt;/p&gt;&#xA;" OwnerUserId="534" LastEditorUserId="24" LastEditDate="2015-02-19T11:17:54.430" LastActivityDate="2017-06-02T19:37:58.447" Title="Vim -p: Caught deadly signal SEGV?" Tags="|crash|" AnswerCount="3" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="1890" PostTypeId="1" AcceptedAnswerId="1891" CreationDate="2015-02-18T04:44:45.180" Score="13" ViewCount="3271" Body="&lt;p&gt;While trying to match up my terminal's colour palette and GVim's I noticed this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;When I open GVim and Vim, I see:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ALGee.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;(That's the same file, my &lt;code&gt;vimrc&lt;/code&gt;.)&lt;/li&gt;&#xA;&lt;li&gt;If I do &lt;code&gt;:set t_Co=256&lt;/code&gt;, nothing happens in GVim (except it blinks), whereas the colours in the terminal now look different. If I do &lt;code&gt;:set bg=dark&lt;/code&gt; now, it makes no difference (again GVim blinks).&#xA;If I then do &lt;code&gt;:set bg=light&lt;/code&gt; and then &lt;code&gt;:set bg=dark&lt;/code&gt; again, I get:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/85eAY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Both &lt;code&gt;:set bg=dark&lt;/code&gt; and &lt;code&gt;:set t_Co=256&lt;/code&gt; are present in my &lt;a href=&quot;https://github.com/murukeshm/vimrc/blob/master/vimrc&quot; rel=&quot;noreferrer&quot;&gt;vimrc&lt;/a&gt;. Why aren't my &lt;code&gt;:set bg&lt;/code&gt; and &lt;code&gt;:set t_Co&lt;/code&gt; sticking, and why does setting &lt;code&gt;:set bg=dark&lt;/code&gt; again after &lt;code&gt;:set bg=light&lt;/code&gt; make a difference where it originally didn't?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Arch Linux, the terminal is GNOME Terminal, and I don't have a &lt;code&gt;.gvimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb  4 2015 08:03:11)&#xA;Included patches: 1-617&#xA;Compiled by Arch Linux&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;+balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;+browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;+clientserver    -hangul_input    +netbeans_intg   +title&#xA;+clipboard       +iconv           +path_extra      +toolbar&#xA;+cmdline_compl   +insert_expand   +perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       -python          +viminfo&#xA;+cscope          +lispindent      +python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con_gui  +lua             +rightleft       +windows&#xA;+diff            +menu            +ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      +X11&#xA;+dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     +xim&#xA;+emacs_tags      +mouseshape      -sniff           +xsmp_interact&#xA;+eval            +mouse_dec       +startuptime     +xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;   system vimrc file: &quot;/etc/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;/etc/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz  -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype  -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lncurses -lelf -lnsl   -lacl -lattr -lgpm -ldl  -L/usr/lib -llua -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc  -L/usr/lib/python3.4/config-3.4m -lpython3.4m -lpthread -ldl -lutil -lm  -lruby -lpthread -lgmp -ldl -lcrypt -lm  -L/usr/lib&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-02-18T05:08:36.780" LastActivityDate="2015-02-18T08:21:02.580" Title="Why does the order of :set bg=dark and :set bg=light matter?" Tags="|vimrc|colorscheme|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1891" PostTypeId="2" ParentId="1890" CreationDate="2015-02-18T08:21:02.580" Score="10" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The elflord colorscheme does &lt;code&gt;set background=dark&lt;/code&gt;. Since it is sourced &lt;em&gt;after&lt;/em&gt; your &lt;code&gt;set bg=light&lt;/code&gt; it will override it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;set t_Co=256&lt;/code&gt; is &lt;em&gt;pointless&lt;/em&gt;. It doesn't do anything in GVim and you should set your terminal emulator up properly instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, elflord only uses basic ANSI colors in color terminals so it doesn't really matter if you force Vim to see 256 colors or if you set your &lt;code&gt;TERM&lt;/code&gt; to a 256colors value; your colorscheme won't use that extended palette anyway. What happens instead is that your original &lt;code&gt;TERM&lt;/code&gt; is probably &lt;code&gt;xterm&lt;/code&gt; or &lt;code&gt;screen&lt;/code&gt; or some other value that restricts Vim to 8 colors. But Elflord uses both &quot;dark&quot; and &quot;light&quot; colors which need a &lt;code&gt;TERM&lt;/code&gt; above 8. So, forcing 256 colors will alter your colors.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Recommendations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Don't change the value of &lt;code&gt;'t_Co'&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Don't &lt;code&gt;set background&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-02-18T08:21:02.580" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1892" PostTypeId="2" ParentId="410" CreationDate="2015-02-18T11:45:32.587" Score="32" Body="&lt;p&gt;This happens when vim is invoked and it's connected to the previous pipeline's output, instead of the terminal and it's receiving different unexpected input (like NULs).&#xA;The same happens when you run: &lt;code&gt;vim &amp;lt; /dev/null&lt;/code&gt;, so &lt;code&gt;reset&lt;/code&gt; command in this case helps. This is explained well by &lt;a href=&quot;https://superuser.com/a/336020/87805&quot;&gt;grawity at superuser&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using &lt;code&gt;find&lt;/code&gt; to pass file names to edit, you don't need &lt;code&gt;xargs&lt;/code&gt;, just use &lt;code&gt;-exec&lt;/code&gt;, in example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -name '*.java' -exec vim {} +&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you'd like to use &lt;code&gt;xargs&lt;/code&gt;, on Unix/macOS you should use &lt;code&gt;-o&lt;/code&gt; parameter, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -name '*.java' | xargs -o vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;sup&gt;&lt;code&gt;-o&lt;/code&gt; Reopen stdin as /dev/tty in the child process before executing the command.  This is useful if you want xargs to run an interactive application.&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -name &quot;*.java&quot; -type f -print0 | xargs -o -0 vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: Using &lt;code&gt;-print0&lt;/code&gt;/&lt;code&gt;-0&lt;/code&gt; will support filenames with whitespaces.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;find&lt;/code&gt; + &lt;a href=&quot;https://www.unix.com/man-page/freebsd/1/xargs/&quot; rel=&quot;noreferrer&quot;&gt;BSD &lt;code&gt;xargs&lt;/code&gt;&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;On Unix/macOS you can try the following workaround:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -name '*.java' | xargs -J% sh -c 'vim &amp;lt; /dev/tty $@'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;a href=&quot;https://en.wikipedia.org/wiki/Command_substitution&quot; rel=&quot;noreferrer&quot;&gt;command substitution&lt;/a&gt; syntax, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim $(find . -name '*.java')&#xA;vim `find . -name '*.java`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively use GNU &lt;code&gt;parallel&lt;/code&gt; instead of &lt;code&gt;xargs&lt;/code&gt; to force tty allocation, in example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -name '*.java' | parallel -X --tty vi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: &lt;code&gt;parallel&lt;/code&gt;on Unix/OSX won't work as it has different parameters and it doesn't support tty.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Many other popular commands provides pseudo-tty allocation as well (like &lt;code&gt;-t&lt;/code&gt; in &lt;code&gt;ssh&lt;/code&gt;), so check for help.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other suggestion would be to use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Ex_(text_editor)&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;ex&lt;/code&gt;&lt;/a&gt; command-line editor to parse the data or use Ex mode, for more details see:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/788/467&quot;&gt;How to edit files non-interactively (e.g. in pipeline)?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://linux.die.net/man/1/vipe&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;vipe&lt;/code&gt;&lt;/a&gt; (a Vim command pipe)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;use the following simple script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;# usage: find ... | vip&#xA;exec vim &amp;lt; /dev/tty &quot;$@&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim/issues/982&quot; rel=&quot;noreferrer&quot;&gt;Bug GH-982: vim does not handle STDIN set to /dev/null&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://superuser.com/questions/336016/invoking-vi-through-find-xargs-breaks-my-terminal-why&quot;&gt;Invoking vi through find | xargs breaks my terminal. Why?&lt;/a&gt; at superuser SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/16517568/vim-exec-command-in-command-line-and-vim-warning-input-is-not-from-a-terminal&quot;&gt;Vim exec command in command line, and Vim: Warning: Input is not from a terminal&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/45782/trying-to-locate-and-then-open-a-file&quot;&gt;Trying to “locate” and then open a file&lt;/a&gt; at unix SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://askubuntu.com/questions/443205/less-vim-not-working-on-my-ubuntu-12-04-lts&quot;&gt;less.vim not working on my Ubuntu 12.04 lts&lt;/a&gt; at askubuntu SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/77395/grep-l-xargs-vim-generates-a-warning-why&quot;&gt;&lt;code&gt;grep -l .. | xargs vim&lt;/code&gt; generates a warning, why?&lt;/a&gt; [dup] at unix SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/24281304/vim-input-is-not-from-a-terminal&quot;&gt;Vim Input is not from a terminal&lt;/a&gt; [dup] at stackoverflow SE&lt;/li&gt;&#xA;&lt;li&gt;BashFAQ/021: &lt;a href=&quot;http://mywiki.wooledge.org/BashFAQ/021&quot; rel=&quot;noreferrer&quot;&gt;How can I replace a string with another string in a variable, a stream, a file, or in all the files in a directory?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2018-11-03T15:46:44.923" LastActivityDate="2018-11-03T15:46:44.923" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1893" PostTypeId="2" ParentId="1887" CreationDate="2015-02-18T11:58:41.470" Score="5" Body="&lt;p&gt;You can create a recursive macro that does this for a single line with the following keystrokes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqqqqf xgUl@qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Note that the space between the &lt;code&gt;f&lt;/code&gt; and the &lt;code&gt;x&lt;/code&gt; is a tap of the spacebar, not a pause)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In detail:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Clear out the q register. This is necessary because we are creating a recursive macro. (See step 5.): &lt;code&gt;qqq&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Start recording a macro in register q: &lt;code&gt;qq&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can't use the &lt;code&gt;w&lt;/code&gt; motion here, because you want the macro to abort when it gets to the end of the line, rather than leaping to the next line. Instead, jump to the next space character on the line by pressing the &lt;code&gt;f&lt;/code&gt; key followed by the spacebar: &lt;code&gt;f&amp;lt;space&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Delete the space and upper-case the following letter: &lt;code&gt;xgUl&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Recurse. Because we cleared the &lt;code&gt;q&lt;/code&gt; register in step 1, there's nothing in it yet, so this will do nothing: &lt;code&gt;@q&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Save the macro: &lt;code&gt;q&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can then apply this macro to multiple lines by using a range:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apply the macro to every line in the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%normal @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Apply the macro to lines 2&amp;ndash;5 inclusive:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:2,5normal @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make a visual selection, and then type &lt;code&gt;:normal @q&lt;/code&gt;. This will pre-populate the command line when you press the &lt;code&gt;:&lt;/code&gt; key, resulting in a command which applies the macro to every line in the selection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;normal @a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2015-02-21T08:20:37.573" LastActivityDate="2015-02-21T08:20:37.573" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1894" PostTypeId="1" AcceptedAnswerId="1898" CreationDate="2015-02-18T13:12:08.307" Score="3" ViewCount="2518" Body="&lt;p&gt;How I can activate option which will display my pressed keystrokes or executed commands in normal mode on the screen?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Especially it would be good, if it would give a slight info what specific keystroke did (like in case of errors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to use &lt;code&gt;:set showcmd&lt;/code&gt;, but it doesn't show single keystrokes like &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know it's possible to &lt;a href=&quot;https://vi.stackexchange.com/questions/570/can-i-see-the-history-of-key-presses-in-normal-mode&quot;&gt;show a command history&lt;/a&gt; by &lt;code&gt;q:&lt;/code&gt;, but I'm looking for some method of displaying them automatically on the screen while using/pressing them.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-18T15:36:40.387" Title="How to display invoked keystrokes and commands in normal mode?" Tags="|command-history|options|normal-mode|" AnswerCount="1" CommentCount="7" ClosedDate="2015-02-18T18:33:50.377" ContentLicense="CC BY-SA 3.0" />
  <row Id="1895" PostTypeId="2" ParentId="848" CreationDate="2015-02-18T14:28:38.547" Score="3" Body="&lt;p&gt;Rendering html can be implemented by using a text-based web browser which can extract a formatted view of the text from an html file or a web page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!links -dump %&#xA;:!elinks -dump %&#xA;:!lynx -dump %&#xA;:!w3m -dump %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To define your own html preview command, try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! ViewHtml execute ':!links -dump %'&#xA;:ViewHtml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can associate this custom command with some key for easier access, by e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Leader&amp;gt;H :ViewHtml&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then pressing &lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;H&lt;/kbd&gt; will preview html of the current file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To preview current file in separate window or to open hyperlinks, you may try to use the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ViewHtmlText(url)&#xA;  if !empty(a:url)&#xA;    new&#xA;    setlocal buftype=nofile bufhidden=hide noswapfile&#xA;    execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0)&#xA;    1d&#xA;  endif&#xA;endfunction&#xA;&quot; Save and view text for current html file.&#xA;nnoremap &amp;lt;Leader&amp;gt;H :update&amp;lt;Bar&amp;gt;call ViewHtmlText(expand('%:p'))&amp;lt;CR&amp;gt;&#xA;&quot; View text for visually selected url.&#xA;vnoremap &amp;lt;Leader&amp;gt;h y:call ViewHtmlText(@@)&amp;lt;CR&amp;gt;&#xA;&quot; View text for URL from clipboard.&#xA;&quot; On Linux, use @* for current selection or @+ for text in clipboard.&#xA;nnoremap &amp;lt;Leader&amp;gt;h :call ViewHtmlText(@+)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Source: &lt;a href=&quot;http://vim.wikia.com/wiki/Preview_current_HTML_file&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim wikia&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using above code, you can press &lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;H&lt;/kbd&gt; to save and preview the current file. To preview currently selected hyperlink, press &lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Preview_current_HTML_file&quot; rel=&quot;nofollow noreferrer&quot;&gt;Preview current HTML file&lt;/a&gt; at vim wikia&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/7371674/is-there-a-way-to-dynamically-examine-html-output-with-vim&quot;&gt;Is there a way to dynamically examine html output with vim?&lt;/a&gt; at stackoverflow SE&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-19T14:43:01.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1896" PostTypeId="1" CreationDate="2015-02-18T14:32:59.190" Score="9" ViewCount="4797" Body="&lt;p&gt;I often program with lines no more than 80 characters long.  I start with an 80-character-wide terminal, but sometimes due to a plugin runs or after creating a vsplit results in the editing area being less than 80 characters wide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;code&gt;:set number&lt;/code&gt; will take four columns from the editing area and use them for line numbers.  After this, using &lt;code&gt;:vertical resize&lt;/code&gt;, only changes the size relative to other splits, it doesn't widen the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to keep the width of the editing area at a fixed width or to quickly resize the editing area or the window to a specified width?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="24" LastEditDate="2015-02-19T10:31:24.987" LastActivityDate="2023-03-04T19:19:01.437" Title="How do I automatically size a window?" Tags="|vim-windows|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1897" PostTypeId="2" ParentId="1896" CreationDate="2015-02-18T15:02:34.560" Score="3" Body="&lt;p&gt;Take a look at the various window functions. For example &lt;code&gt;ctrl-w =&lt;/code&gt; will set all splits to equal width. There are also methods to set the window to a certain width, increase/decrease width by N, always maintain equal width, etc...&#xA;&lt;code&gt;:help window-resize&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="19" LastEditorUserId="67" LastEditDate="2015-02-18T17:21:13.970" LastActivityDate="2015-02-18T17:21:13.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1898" PostTypeId="2" ParentId="1894" CreationDate="2015-02-18T15:07:59.463" Score="1" Body="&lt;p&gt;Possibly related: &lt;a href=&quot;https://vi.stackexchange.com/questions/570/can-i-see-the-history-of-key-presses-in-normal-mode&quot;&gt;Can I see the history of key presses in normal mode?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That question is about displaying the history of the commands in normal mode. If you are asking about the ex command history, then do&#xA;&lt;code&gt;&#xA;q:&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="19" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-18T15:07:59.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1899" PostTypeId="2" ParentId="1889" CreationDate="2015-02-18T17:15:35.780" Score="6" Body="&lt;p&gt;The SEGV signal, also known as a segfault, is almost always due to a bug in the program you're running—in this case, vim. (Other causes are things like defective hardware, or once in a blue moon, kernel bugs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, really, you need to report a bug. &lt;a href=&quot;http://vimhelp.appspot.com/intro.txt.html#bug-reports&quot;&gt;&lt;code&gt;:help bug-reports&lt;/code&gt;&lt;/a&gt; provides instructions on how to report a bug. It sounds like you've already got a minimal set of steps to reproduce the problem, so that's most of the work there. You should probably test a newer version of Vim first though, just to make sure it hasn't already been fixed.&lt;/p&gt;&#xA;" OwnerUserId="31" LastActivityDate="2015-02-18T17:15:35.780" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1900" PostTypeId="1" AcceptedAnswerId="1901" CreationDate="2015-02-18T18:49:27.743" Score="1" ViewCount="173" Body="&lt;p&gt;In insert mode, using beam-cursor, the column number is, at least for me, not intuitive. Having for example the text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abcde&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and using &lt;code&gt;%v&lt;/code&gt; on &lt;code&gt;statusline&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If cursor is before &lt;code&gt;a&lt;/code&gt; it say &lt;code&gt;1&lt;/code&gt;, after &lt;code&gt;e&lt;/code&gt; it say &lt;code&gt;6&lt;/code&gt; etc. Perhaps only me being difficult, and at least picky, but how to show one less on status bar in Vim? I would like it to show length of line / string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before &lt;code&gt;a&lt;/code&gt; = &lt;code&gt;0&lt;/code&gt;, after &lt;code&gt;e&lt;/code&gt; = &lt;code&gt;5&lt;/code&gt; etc. In normal mode, with block-cursor, the column number is fine.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-02-18T18:49:27.743" Title="Subtract 1 from column number on statusbar in insert mode" Tags="|statusline|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1901" PostTypeId="2" ParentId="1900" CreationDate="2015-02-18T18:49:27.743" Score="2" Body="&lt;p&gt;One way to solve it is to use a custom function for status line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ImColnr()&#xA;    return printf(&quot;%d&quot;, mode() == &quot;i&quot; ? col(&quot;.&quot;) - 1 : col(&quot;.&quot;))&#xA;endfun&#xA;&#xA;set statusline=%{ImColnr()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my usage I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ImColnr()&#xA;    return printf(&quot;,%04d&quot;, mode() == &quot;i&quot; ? col(&quot;.&quot;) - 1 : col(&quot;.&quot;))&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as I like fixed with with leading zeroes. My &lt;code&gt;statusline&lt;/code&gt;, (somewhat bloated), in full is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%F%m%r%h%w[%L][%{&amp;amp;ff}]%{(&amp;amp;fenc!=''?&amp;amp;fenc:&amp;amp;enc)}%y[%p%%][%04l%{ImColnr()}]\ \ \ F[%2n]:\ %t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-02-18T18:49:27.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1902" PostTypeId="2" ParentId="241" CreationDate="2015-02-18T19:35:49.467" Score="5" Body="&lt;p&gt;What you are describing sounds exactly like the feature that goes by the name of &quot;zooming&quot;.  There is already a great answer &lt;a href=&quot;https://stackoverflow.com/a/26551079/1698426&quot;&gt;on SO&lt;/a&gt; that does it very well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Explicit answer, copied and pasted from &lt;a href=&quot;https://stackoverflow.com/a/26551079/1698426&quot;&gt;SO&lt;/a&gt;.  I put the snippet below in my .vimrc and then invoke&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ZoomToggle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my vim command prompt.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Zoom / Restore window.&#xA;function! s:ZoomToggle() abort&#xA;    if exists('t:zoomed') &amp;amp;&amp;amp; t:zoomed&#xA;        execute t:zoom_winrestcmd&#xA;        let t:zoomed = 0&#xA;    else&#xA;        let t:zoom_winrestcmd = winrestcmd()&#xA;        resize&#xA;        vertical resize&#xA;        let t:zoomed = 1&#xA;    endif&#xA;endfunction&#xA;command! ZoomToggle call s:ZoomToggle()&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-A&amp;gt; :ZoomToggle&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="532" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-18T21:50:56.687" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1903" PostTypeId="2" ParentId="742" CreationDate="2015-02-18T19:55:41.613" Score="5" Body="&lt;p&gt;Apart of &lt;a href=&quot;https://vi.stackexchange.com/a/786/467&quot;&gt;John&lt;/a&gt; solution, there is another way to show all vim keystrokes which were pressed by using &lt;code&gt;-w&lt;/code&gt; parameter which record all the characters that you type in the file. The problem is, that vim writes keystrokes only when you exit Vim. This is how &lt;a href=&quot;http://www.vimgolf.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;VimGolf&lt;/a&gt; works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To workaround this, &lt;a href=&quot;https://github.com/kana&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kana Natsuno&lt;/a&gt; came up with this &lt;a href=&quot;https://gist.github.com/kana/4202311&quot; rel=&quot;nofollow noreferrer&quot;&gt;single-line patch&lt;/a&gt;, which disables buffering of the &lt;code&gt;-w&lt;/code&gt; option, so you have access to realtime stream of keystrokes. Then it's a matter of reading them (e.g. &lt;code&gt;tail -f&lt;/code&gt;), parsing or you can try to display them in the statusbar (&lt;code&gt;:set statusline&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out a custom build of Vim using Drew's &lt;a href=&quot;https://github.com/nelstrom/macvim/commit/c65e7e650b806682152681c58078d29cb1904bfe&quot; rel=&quot;nofollow noreferrer&quot;&gt;live-stream-keystrokes branch&lt;/a&gt; of MacVim, to get the realtime stream of keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://vimcasts.org/blog/2013/05/vimprint---a-vim-keystroke-parser/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimprint - a Vim keystroke parser&lt;/a&gt; at Drew Neil blog&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is useful if you'd like to reveal the Vim pressed keystrokes in video tutorials or GIFs. &lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-19T12:53:08.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1904" PostTypeId="1" CreationDate="2015-02-18T20:13:46.980" Score="2" ViewCount="320" Body="&lt;p&gt;How can I select a block with a mouse when line numbering is enabled.&#xA;The selection includes the line numbering.&#xA;Is there a way to exclude the line numbering from mouse selection ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clarification:&#xA;The questions if for VIM, not GVIM&lt;/p&gt;&#xA;" OwnerUserId="496" LastActivityDate="2015-02-18T21:12:53.707" Title="Selecting block with a mouse when line numbering is enabled" Tags="|mouse|" AnswerCount="1" CommentCount="3" ClosedDate="2015-02-19T02:15:19.770" ContentLicense="CC BY-SA 3.0" />
  <row Id="1905" PostTypeId="1" AcceptedAnswerId="1906" CreationDate="2015-02-18T20:47:00.620" Score="25" ViewCount="2720" Body="&lt;p&gt;I am using Vim to program in Java 8, and am having a problem with syntax highlighting.&lt;/p&gt;&#xA;&lt;p&gt;A new feature in Java 8 is lambda support, which resulted in the creation of the arrow operator: &lt;code&gt;-&amp;gt;&lt;/code&gt;.  Vim does not recognize this as a valid operator in a *.java file.  As such, it highlights this operator in bright red to draw attention to the &amp;quot;syntax error.&amp;quot;  (Of course, this really is valid syntax.)&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to update Vim's &amp;quot;dictionary&amp;quot; of allowed operators and/or fix the syntax highlighting to avoid this issue?&lt;/p&gt;&#xA;&lt;p&gt;The first two lines of &lt;code&gt;:version&lt;/code&gt; state:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:39:32)&lt;/p&gt;&#xA;&lt;p&gt;Included patches: 1-52&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="239" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-05-17T18:23:20.327" Title="Vim's syntax highlighting considers a lambda (-&gt;) in Java an error" Tags="|syntax-highlighting|filetype-java|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1906" PostTypeId="2" ParentId="1905" CreationDate="2015-02-18T21:03:53.583" Score="32" Body="&lt;h3&gt;2016 update&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The Vim syntax file &lt;a href=&quot;https://github.com/vim/vim/commit/f3c2afb77f8b1f2591337fcaa90ba0fb45365cbc#diff-eda7359419b4ac52df5a77541cf1e82f&quot; rel=&quot;noreferrer&quot;&gt;was updated for this in v7.4.649&lt;/a&gt; (March 2015); so if you have this patch you don't need to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way to fix this is probably by downloading the &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/syntax/java.vim&quot; rel=&quot;noreferrer&quot;&gt;newer &lt;code&gt;syntax/java.vim&lt;/code&gt; file&lt;/a&gt; and putting it in &lt;code&gt;~/.vim/syntax/java.vim&lt;/code&gt; so it will override the default &lt;code&gt;$VIMRUNTIME/syntax/java.vim&lt;/code&gt;. You will also need to symlink &lt;code&gt;html.vim&lt;/code&gt; for this to work as &lt;code&gt;java.vim&lt;/code&gt; depends on this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ln -s /usr/share/vim/vim74/syntax/html.vim ~/.vim/syntax/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Original answer&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;/usr/share/vim/vim74/syntax/java.vim&lt;/code&gt; has this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match javaError &quot;&amp;lt;&amp;lt;&amp;lt;\|\.\.\|=&amp;gt;\|||=\|&amp;amp;&amp;amp;=\|[^-]-&amp;gt;\|\*\/&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See the &lt;code&gt;[^-]-&amp;gt;&lt;/code&gt; part? That causes the error highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can override this rule by adding a &lt;code&gt;~/.vim/after/syntax/java.vim&lt;/code&gt; file,&#xA;with the same pattern minus the lambda syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn clear javaError&#xA;syn match javaError &quot;&amp;lt;&amp;lt;&amp;lt;\|\.\.\|=&amp;gt;\|||=\|&amp;amp;&amp;amp;=\|\*\/&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And for bonus points, we can add this line to highlight this as a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match javaFuncDef &quot;[^-]-&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Consider filing a bug report. &lt;code&gt;:help bug-reports&lt;/code&gt; explains how. There seem to be more (new?) constructs that are highlighted as an error, such as the &lt;code&gt;...&lt;/code&gt; in &lt;code&gt;public static void main(String... args)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-07-26T15:43:37.730" LastActivityDate="2016-07-26T15:43:37.730" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1907" PostTypeId="2" ParentId="1904" CreationDate="2015-02-18T21:12:53.707" Score="2" Body="&lt;p&gt;OK. So this does not use the mouse.&lt;br&gt;&#xA;But that's the whole point of vim (not needing to use the mouse).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the vim normal copy command (which will not select the line numbers). To get it into the system clipboard just use the buffer &lt;code&gt;*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;*&amp;lt;Normal Yank Command&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have now yanked the text you want into the system clipboard and it can be pasted as normal. The Yank command you use can be any normal vim yank command.&lt;/p&gt;&#xA;" OwnerUserId="383" LastActivityDate="2015-02-18T21:12:53.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1908" PostTypeId="1" CreationDate="2015-02-19T01:33:06.393" Score="6" ViewCount="207" Body="&lt;p&gt;I am a programmer and use Vim primarily for that, but I have found that enabling Vim's spell check is a somewhat useful feature to have just to help slightly incentivize cleaning up the parts of files that are written in English. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now what I thought about just now is I think it would be cool if I could have this system mark certain arbitrary word sequences like &quot;the the&quot; as an error for me. Is this possible? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can use &lt;code&gt;zw&lt;/code&gt; to mark a word as bad, but I want to do it for a sequence of words that I want to also treat as wrong (but which may be made up of words that are fine).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(use &lt;code&gt;:set spell&lt;/code&gt; to enable spell check in Vim)&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2015-03-17T15:05:10.763" Title="Spell-check blacklisting word sequences" Tags="|spell-checking|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1909" PostTypeId="2" ParentId="1908" CreationDate="2015-02-19T01:49:53.877" Score="9" Body="&lt;p&gt;Alright, so I looked it up this way since I had Vim's source code lying around: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd ~/Documents/vim&#xA;$ ack 'the the'&#xA;&#xA;...&#xA;&#xA;runtime/doc/spell.txt&#xA;399:It can also be used to recognize &quot;the the&quot; and highlight it.&#xA;1206:&quot;the the&quot; in the .dic file:&#xA;1208:   the the/! ~&#xA;1463:   REP the_the the ~&#xA;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OK so &lt;a href=&quot;https://vimhelp.appspot.com/spell.txt.html#spellfile-cleanup&quot; rel=&quot;nofollow&quot;&gt;Vim's documentation&lt;/a&gt; itself appears to explain the situation (though not to my own satisfaction):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;WORD COMBINATIONS&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;It is possible to spell-check words that include a space.  This is&#xA;  used to recognize words that are invalid when used by themselves, e.g.&#xA;  for &quot;et al.&quot;. It can also be used to recognize &quot;the the&quot; and highlight&#xA;  it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There's a bunch more documentation that goes in depth into how and what the spell system is capable of. It's mostly sort of boring. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also discovered the best way to easily add a word sequence to the &quot;bad spelling&quot; list. &lt;strong&gt;Just use&lt;/strong&gt; &lt;code&gt;zw&lt;/code&gt; &lt;strong&gt;in visual mode&lt;/strong&gt; after selecting the sequence you want to mark as bad (the mnemonic is &lt;code&gt;w&lt;/code&gt; for &quot;wrong&quot;). It works great. What it does automatically is add the word sequence to the spellfile such as &lt;code&gt;~/.vim/spell/en.utf-8.add&lt;/code&gt; in a line ending with &lt;code&gt;/!&lt;/code&gt; which means it's a &quot;bad word&quot;.&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="390" LastEditDate="2015-03-17T15:05:10.763" LastActivityDate="2015-03-17T15:05:10.763" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1910" PostTypeId="2" ParentId="1887" CreationDate="2015-02-19T02:18:37.607" Score="12" Body="&lt;p&gt;For an alternative I use the &lt;a href=&quot;https://github.com/tpope/vim-abolish#coercion&quot;&gt;vim-abolish&lt;/a&gt; plugin that offers a coercion feature:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Want to turn &lt;code&gt;fooBar&lt;/code&gt; into &lt;code&gt;foo_bar&lt;/code&gt;?  Press &lt;code&gt;crs&lt;/code&gt; (coerce to&#xA;  snake_case).  MixedCase (&lt;code&gt;crm&lt;/code&gt;), camelCase (&lt;code&gt;crc&lt;/code&gt;), snake_case&#xA;  (&lt;code&gt;crs&lt;/code&gt;), and UPPER_CASE (&lt;code&gt;cru&lt;/code&gt;) are all just 3 keystrokes away.  These&#xA;  commands support &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot;&gt;repeat.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="544" LastActivityDate="2015-02-19T02:18:37.607" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1911" PostTypeId="2" ParentId="835" CreationDate="2015-02-19T03:50:38.817" Score="3" Body="&lt;p&gt;I'm going to expand/consolidate @quincy-bowers answer:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You can not enter you own suggestions from the spell suggestions screen.&lt;/li&gt;&#xA;&lt;li&gt;It doesn't make much sense (in VIM) to enter your own suggestions form the spell suggestions screen.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;VIM is a text editor. Since that is what it does best it leaves the editing to itself. In other words the answer to change a misspelled word to your own custom suggestion just press &lt;kbd&gt;enter&lt;/kbd&gt; to dismiss the suggestion list and then change the word to your correct spelling manually. (&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; works perfect for that).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then (as @quincy-bowers suggested) if you want the custom correct spelling to show up in subsequent suggestion lists type &lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt; when the cursor is on the word and it will be added to your spelling dictionary (see &lt;code&gt;:help zg&lt;/code&gt; for details).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, after saying all that, it hasn't stopped the clever folks who use VIM from finding alternatives (unlimited ways to skin a cat they say) and so you could try an alternative plugin for example &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4929&quot; rel=&quot;nofollow&quot;&gt;unite-spell-suggest&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="544" LastEditorUserId="544" LastEditDate="2015-02-19T04:17:39.410" LastActivityDate="2015-02-19T04:17:39.410" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1912" PostTypeId="1" AcceptedAnswerId="1993" CreationDate="2015-02-19T05:19:49.930" Score="1" ViewCount="1553" Body="&lt;p&gt;I'm pretty new to vim and am working on a node.js project with ejs files. I have syntax highlighting turned on with &lt;code&gt;syntax on&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; file. I also have an ejs file that contains JavaScript code within a tag. Here's a basic example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;input type=&quot;text&quot; &amp;lt;%- typeof due == 'undefined' ? '' : ('value=&quot;' + due + '&quot; ') %&amp;gt;/&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is that the &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; characters that enclose the JavaScript are both highlighted in bright red. I assume this is supposed to indicate an error, but there is no error in this code. How can I let vim know that something like this is okay?&lt;/p&gt;&#xA;" OwnerUserId="178" LastEditorUserId="24" LastEditDate="2015-02-19T08:47:46.307" LastActivityDate="2015-02-19T18:01:54.420" Title="How can I remove the red highlighting of ejs code braces?" Tags="|syntax-highlighting|filetype-html|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1913" PostTypeId="2" ParentId="1896" CreationDate="2015-02-19T05:51:01.790" Score="2" Body="&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt;+ &lt;code&gt;(n)&lt;/code&gt; &lt;kbd&gt;&gt;&lt;/kbd&gt;/&lt;kbd&gt;&amp;lt;&lt;/kbd&gt;: For right/left&lt;br&gt;&#xA;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt;+ &lt;code&gt;(n)&lt;/code&gt; &lt;kbd&gt;+&lt;/kbd&gt;/&lt;kbd&gt;-&lt;/kbd&gt;: For up/down&lt;br&gt;&#xA;where n = any number.&lt;/p&gt;&#xA;" OwnerUserId="571" LastActivityDate="2015-02-19T05:51:01.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1914" PostTypeId="1" AcceptedAnswerId="1965" CreationDate="2015-02-19T06:09:36.437" Score="3" ViewCount="1337" Body="&lt;p&gt;Currently I have JavaScript (.js) files that contain multiline strings. Vim's syntax highlighting does not seem to support these, as seen in the image below:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/3o8HH.png&quot; alt=&quot;Improper multiline syntax highlighting&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anything below the first line is not properly recognized as a string, and everything after the end quote is incorrectly considered a string. Any way to fix this?&lt;/p&gt;&#xA;" OwnerUserId="178" LastEditorUserId="24" LastEditDate="2015-02-19T06:49:07.527" LastActivityDate="2015-02-19T14:39:04.373" Title="How can I get syntax highlighting to support multiline JavaScript strings?" Tags="|syntax-highlighting|line-breaks|filetype-javascript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1915" PostTypeId="1" AcceptedAnswerId="1916" CreationDate="2015-02-19T06:50:06.823" Score="116" ViewCount="108767" Body="&lt;p&gt;In vim, I often need to delete, or yank/put large blocks of text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can count the lines of text and enter something like &lt;code&gt;50dd&lt;/code&gt; to delete 50 lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that's a bit of a pain. How can I delete this large block of text &lt;em&gt;without&lt;/em&gt; having to know how many lines to delete in advance?&lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastActivityDate="2021-10-04T23:22:10.113" Title="How do I delete a large block of text without counting the lines?" Tags="|cut-copy-paste|" AnswerCount="16" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1916" PostTypeId="2" ParentId="1915" CreationDate="2015-02-19T06:50:06.823" Score="131" Body="&lt;p&gt;Go to the starting line of your block, and type &lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; (mark &quot;a&quot;, though you can of course use &lt;em&gt;different&lt;/em&gt; letters, and even &lt;em&gt;multiple&lt;/em&gt; letters for different marks provided you can keep it straight in your head what each letter is a mark of).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then go to the last line and enter &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; (delete to mark &quot;a&quot;) or &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; (yank to mark &quot;a&quot;) &lt;sup&gt;(a)&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That will delete/yank all lines from the current to the marked one (inclusive).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can paste it somewhere else with the normal paste commands, such as &lt;kbd&gt;p&lt;/kbd&gt; or &lt;kbd&gt;P&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also compatible with &lt;code&gt;vi&lt;/code&gt; as well as &lt;code&gt;vim&lt;/code&gt;, on the off chance that your environment is not blessed with the latter.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;(a)&lt;/sup&gt; I also use this to save my place in the file if I have to go looking elsewhere for something like, for example, copy-pasting the definition of a function I want to call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I simply mark the current line in the same way, &lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;, then wander off to find whatever you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, once I've found it and copied it to a register, I just enter &lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; to go back to mark &quot;a&quot;, the line I saved beforehand, where I can then paste it.&lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastEditorUserId="1306" LastEditDate="2015-06-24T23:54:38.977" LastActivityDate="2015-06-24T23:54:38.977" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1917" PostTypeId="2" ParentId="1915" CreationDate="2015-02-19T07:02:02.150" Score="78" Body="&lt;p&gt;In Vim, use &lt;a href=&quot;https://vimhelp.appspot.com/visual.txt.html&quot;&gt;visual line mode&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Put your cursor on the top line of the block of text/code to remove &lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;V&lt;/kbd&gt; (That's capital &quot;V&quot; : &lt;kbd&gt;Shift&lt;/kbd&gt; + &lt;kbd&gt;v&lt;/kbd&gt; )&lt;/li&gt;&#xA;&lt;li&gt;Move your cursor down to the bottom of the block of text/code to remove &lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt; d &lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For deleting large blocks of text this is preferred over simple visual mode because you don't need to worry about which column the cursor is at.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="890" LastEditDate="2015-03-02T15:20:40.857" LastActivityDate="2015-03-02T15:20:40.857" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1918" PostTypeId="2" ParentId="1915" CreationDate="2015-02-19T07:06:12.127" Score="6" Body="&lt;p&gt;If it is delimited blocks (eg: code or XML/HTML tags) that you're dealing with, you can position the cursor at the start of the block and use the visual mode along with &lt;code&gt;%&lt;/code&gt; to quickly select entire blocks of code and then hit &lt;code&gt;d&lt;/code&gt; to delete them.&lt;/p&gt;&#xA;" OwnerUserId="224" LastActivityDate="2015-02-19T07:06:12.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1919" PostTypeId="2" ParentId="1915" CreationDate="2015-02-19T07:12:03.347" Score="43" Body="&lt;p&gt;You can &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27relativenumber%27&quot;&gt;&lt;code&gt;:set relativenumber&lt;/code&gt;&lt;/a&gt;, so you don't have to count. ;)&lt;/p&gt;&#xA;" OwnerUserId="586" LastEditorUserId="205" LastEditDate="2015-02-19T08:04:37.037" LastActivityDate="2015-02-19T08:04:37.037" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1920" PostTypeId="1" AcceptedAnswerId="1921" CreationDate="2015-02-19T07:14:32.897" Score="23" ViewCount="265" Body="&lt;p&gt;In the article, &lt;a href=&quot;http://web.archive.org/web/20080306034905/http://www.geocities.com/volontir/&quot;&gt;Vim Regular Expressions&lt;/a&gt;, Oleg Raisky gives the following command to reduce multiple blank lines to a single blank:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^$/,/./-j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can someone please describe how this works? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know &lt;code&gt;:g&lt;/code&gt; command and regular expressions. But I didn't understand what the part &lt;code&gt;/,/./-j&lt;/code&gt; does. &lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastEditorUserId="23502" LastEditDate="2022-10-31T12:54:13.763" LastActivityDate="2022-10-31T12:54:13.763" Title="How does :g/^$/,/./-j (reduce multiple blank lines to a single blank) work in Vim?" Tags="|line-breaks|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1921" PostTypeId="2" ParentId="1920" CreationDate="2015-02-19T07:14:32.897" Score="26" Body="&lt;p&gt;It really is quite ingenious. Let's break it down. The &lt;code&gt;ex&lt;/code&gt; command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^$/xyzzy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will search for all empty lines and execute the &lt;code&gt;xyzzy&lt;/code&gt; command (an arbitrary &lt;code&gt;ex&lt;/code&gt; command) on each of them. Note that &lt;code&gt;xyzzy&lt;/code&gt; is not a &lt;em&gt;real&lt;/em&gt; &lt;code&gt;ex&lt;/code&gt; command, it's only there as a placeholder, as per the next paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tricky bit here is that the &lt;code&gt;xyzzy&lt;/code&gt; &quot;command&quot; in your case is &lt;em&gt;yet another&lt;/em&gt; search command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;,/./-j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;,/./-&lt;/code&gt; specifies a range. This is of the form &lt;code&gt;&amp;lt;start&amp;gt;,&amp;lt;end&amp;gt;&lt;/code&gt; and, because there's nothing before the comma, it assumes the current line (the one where you found the blank line) is the start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the comma is &lt;code&gt;/./-&lt;/code&gt; which means search for the next character (&lt;code&gt;.&lt;/code&gt; means any character) then back up one line (&lt;code&gt;/./-&lt;/code&gt; is short for &lt;code&gt;/./-1&lt;/code&gt; since the one is implied if no value is given). You'll find that pattern &lt;code&gt;.&lt;/code&gt; on the first non-blank line following the one you're operating on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, the end of the range is the last blank line after or at the one you're currently operating on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you execute a join over that range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the start and the end of the range were equal (only one blank line was in the section), join does nothing. If they're not equal, join will join them all up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's the way in which it combines multiple blank lines into one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets look at an example (the line numbers are for explanation only, they are not in the actual file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 Line 1&#xA;2&#xA;3 Line 3&#xA;4 Line 4&#xA;5&#xA;6&#xA;7&#xA;8&#xA;9 Line 9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;g/^$/&lt;/code&gt; command will find all empty lines and perform its operation on them (these are the lines 2, 5, 6, 7 and 8).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For line 2, &lt;code&gt;,/./-j&lt;/code&gt; will set up a range from 2 to 2 (the next &lt;code&gt;.&lt;/code&gt; is found on line 3 then subtract 1 to get 2). A join on the range 2,2 does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For line 5, &lt;code&gt;,/./-j&lt;/code&gt; will set up a range from 5 to 8 (next &lt;code&gt;.&lt;/code&gt; found on line 9 then subtract 1). A join on the range 5,8 will join all those lines together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The operation is not performed on lines that disappear as part of an earlier operation. That's because it would make no sense to process lines that have been deleted earlier in the cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, because lines 6 through 8 are deleted (combined with line 5), the global command doesn't operate on them after that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's based on the fact that the &lt;code&gt;vim&lt;/code&gt; documentation states a two-pass algorithm, one to mark the lines, one to perform the operation.&lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastEditorDisplayName="user579" LastEditDate="2018-09-14T11:00:08.023" LastActivityDate="2018-09-14T11:00:08.023" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1922" PostTypeId="1" AcceptedAnswerId="1926" CreationDate="2015-02-19T07:25:58.843" Score="48" ViewCount="22545" Body="&lt;p&gt;How does one get vim to replace a character within the visual selection &lt;strong&gt;only&lt;/strong&gt; and not elsewhere on the line? Example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Line: &lt;code&gt;int arr[] = { 00 01 02 03 04 05 05 /* ... lots more like this*/};&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;Visual Selection: &lt;code&gt;{ 00 01 02 03 04 05 05 /*... lots more like this*/}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Command: &lt;code&gt;:'&amp;lt;,'&amp;gt;s/\ /\,0x/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Expected: &lt;code&gt;int arr[] = {0x00,0x01,0x02,0x03 /* and so on*/};&lt;/code&gt; &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After performing these actions however, the actual result is: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;int,0xarr[],0x=,0x{0x00,0x01,0x02,0x03 /* and so on*/};&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to modify the command above to produce the expected result? Doesn't &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; define the range on which the search (and replace) commands work?&lt;/p&gt;&#xA;" OwnerUserId="224" LastEditorUserId="467" LastEditDate="2019-02-22T11:18:40.977" LastActivityDate="2021-05-01T15:03:09.117" Title="How to replace only within visual selection?" Tags="|substitute|visual-mode|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1923" PostTypeId="1" AcceptedAnswerId="1925" CreationDate="2015-02-19T07:28:36.963" Score="4" ViewCount="582" Body="&lt;p&gt;I &lt;em&gt;knew&lt;/em&gt; this site would teach me more about my beloved &lt;code&gt;vim&lt;/code&gt; :-) In posting a question/answer on &lt;a href=&quot;https://vi.stackexchange.com/questions/1915/how-do-i-delete-a-large-block-of-text-without-counting-the-lines&quot;&gt;how to delete large blocks without having to count lines&lt;/a&gt;, one of the answers taught me something I didn't know, that being relative line numbers along the lines of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  2 This is line 1&#xA;  1 This is line 2&#xA;3   This is line 3, the current line.&#xA;  1 This is line 4.&#xA;  2 Line 5.&#xA;  3 Line 6.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, if you wanted to delete lines 3, 4 and 5, you can simply add one to the relative line number (2) and use that to set the count, the command being &lt;code&gt;3dd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, adding one seems a bit obscure so I was wondering if you could configure the line numbers in relative mode to be more like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  2 This is line 1&#xA;  1 This is line 2&#xA;3 1 This is line 3, the current line.&#xA;  2 This is line 4.&#xA;  3 Line 5.&#xA;  4 Line 6.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way you could simply transcribe the number into the command without having to think about it.&lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-19T08:21:05.267" Title="Can relative number be changed so that current line is 1?" Tags="|line-numbers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1924" PostTypeId="2" ParentId="1915" CreationDate="2015-02-19T07:47:59.650" Score="24" Body="&lt;p&gt;You can use motions and/or text objects. For instance, you can delete everything from the cursor to the next blank line with &lt;code&gt;d}&lt;/code&gt;. If the cursor is inside a paragraph, the paragraph may be deleted with &lt;code&gt;dip&lt;/code&gt; or &lt;code&gt;dap&lt;/code&gt;. If the cursor is within a HTML tag, you can delete it with &lt;code&gt;dit&lt;/code&gt; or &lt;code&gt;dat&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good mnemonics for these are &quot;&lt;strong&gt;d&lt;/strong&gt;elete &lt;strong&gt;i&lt;/strong&gt;nside&quot; and &quot;&lt;strong&gt;d&lt;/strong&gt;elete &lt;strong&gt;a&lt;/strong&gt;round&quot; (paragraph / tag / parenthesis).&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="20201" LastEditDate="2018-12-15T09:10:14.617" LastActivityDate="2018-12-15T09:10:14.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1925" PostTypeId="2" ParentId="1923" CreationDate="2015-02-19T08:07:45.383" Score="19" Body="&lt;p&gt;Don't do that.  A numbering system that goes from -1 to +1 without a zero in between is just asking for trouble.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an alternative habit, I suggest &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; — &quot;delete this line and the next two lines&quot;.  That works both ways: &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; deletes upward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A long-winded ex command version of that would be &lt;code&gt;:+2d&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2015-02-19T08:07:45.383" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1926" PostTypeId="2" ParentId="1922" CreationDate="2015-02-19T08:08:31.360" Score="61" Body="&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V\ /\,0x/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%V&lt;/code&gt; matches inside the visual area. See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%25V&quot;&gt;&lt;code&gt;:help %V&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="587" LastEditorUserId="205" LastEditDate="2015-02-19T08:39:16.013" LastActivityDate="2015-02-19T08:39:16.013" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1927" PostTypeId="2" ParentId="1923" CreationDate="2015-02-19T08:21:05.267" Score="2" Body="&lt;p&gt;Maybe: &lt;code&gt;d&amp;lt;number&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="586" LastActivityDate="2015-02-19T08:21:05.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1928" PostTypeId="2" ParentId="300" CreationDate="2015-02-19T08:27:09.063" Score="4" Body="&lt;p&gt;In terminal vi and Vim,&#xA;&lt;kbd&gt;alt&lt;/kbd&gt; + &lt;code&gt;single-normal-mode-key&lt;/code&gt; will work for quick edits in most terminals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works because most terminals send the alt modifier as the escape character. For example, when you type &lt;kbd&gt;alt+k&lt;/kbd&gt; the terminal emulator sends two character to the running program: &lt;code&gt;esc&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;. Vi and Vim interpret this as you would expect; it leaves insert mode (because of the escape) and executes the normal mode command (in the example, moving the cursor up one line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be a convenient way to exit insert mode if your keyboard has the alt key next to the space bar (so that it can be pressed by thumb, leaving your fingers on the home row), so long as you are using a terminal emulator with this behaviour and don't mind running a normal mode command.&lt;/p&gt;&#xA;" OwnerUserId="593" LastEditorUserId="227" LastEditDate="2015-02-20T05:23:03.290" LastActivityDate="2015-02-20T05:23:03.290" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1929" PostTypeId="2" ParentId="737" CreationDate="2015-02-19T08:34:28.560" Score="0" Body="&lt;p&gt;If using a pipeline to a new Vim is not a requirement, you can use Vim's ability to pull in the output of commands into the current buffer, coupled with having a non-file backed buffer (as with &lt;code&gt;:new&lt;/code&gt; or editing a non-existent file)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:read!cat /etc/hosts&lt;/code&gt; in command-mode will place the output into your current buffer below the current cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from having to delete the empty first line that remains when this is done on an empty buffer, this works well and is especially convenient if Vim is already running.&lt;/p&gt;&#xA;" OwnerUserId="593" LastEditorUserId="227" LastEditDate="2015-02-20T05:14:18.687" LastActivityDate="2015-02-20T05:14:18.687" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1930" PostTypeId="5" CreationDate="2015-02-19T08:40:31.773" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-19T08:40:31.773" LastActivityDate="2015-02-19T08:40:31.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1931" PostTypeId="4" CreationDate="2015-02-19T08:40:31.773" Score="0" Body="Overwriting text with the r or R commands. For search-and-replace operations, use the [substitute] tag." OwnerUserId="24" LastEditorUserId="343" LastEditDate="2023-08-17T10:54:04.180" LastActivityDate="2023-08-17T10:54:04.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1932" PostTypeId="5" CreationDate="2015-02-19T08:44:09.390" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-19T08:44:09.390" LastActivityDate="2015-02-19T08:44:09.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1933" PostTypeId="4" CreationDate="2015-02-19T08:44:09.390" Score="0" Body="Any operation involving regular expression based substitution of text, such as the ex-mode `:s` command. Not to be confused with the [replace] tag." OwnerDisplayName="user579" LastEditorUserId="24" LastEditorDisplayName="user579" LastEditDate="2019-05-10T05:19:42.483" LastActivityDate="2019-05-10T05:19:42.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1934" PostTypeId="2" ParentId="1915" CreationDate="2015-02-19T09:00:21.533" Score="48" Body="&lt;p&gt;You can easily delete large block of text if you know its structure.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If it's a paragraph, use &lt;code&gt;d{&lt;/code&gt; or &lt;code&gt;d}&lt;/code&gt; or &lt;code&gt;dap&lt;/code&gt; (or &lt;code&gt;3d{&lt;/code&gt; for 3 paragraphs and so on).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If it's within parenthesis, use &lt;code&gt;d%&lt;/code&gt; or &lt;code&gt;dab&lt;/code&gt; or &lt;code&gt;da(&lt;/code&gt; or &lt;code&gt;da)&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If it's the text till end of the file, use &lt;code&gt;dG&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you know how it ends, use &lt;code&gt;d/&lt;/code&gt; and type the ending text followed by &lt;kbd&gt;Enter&lt;/kbd&gt; (you can also use a regular expression, so the possibilities are endless).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Alternatively use visual line mode (&lt;code&gt;V&lt;/code&gt;) and use motion keys to quickly select the text (e.g. by &lt;code&gt;{&lt;/code&gt;) and remove it (&lt;code&gt;d&lt;/code&gt; or &lt;code&gt;x&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Or as Lie Ryan suggested, use &lt;code&gt;d/search-string/e&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; to delete text from current cursor to searched string.&lt;/p&gt;&#xA;&lt;p&gt;See: &lt;code&gt;:help d&lt;/code&gt; and &lt;code&gt;:help motion&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="10604" LastEditDate="2021-10-04T23:22:10.113" LastActivityDate="2021-10-04T23:22:10.113" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1935" PostTypeId="2" ParentId="130" CreationDate="2015-02-19T09:37:02.487" Score="4" Body="&lt;p&gt;I'm a big fan of &lt;a href=&quot;https://github.com/tomtom/tcomment_vim&quot; rel=&quot;nofollow&quot;&gt;TComment&lt;/a&gt; for this; not only can I do filetype specific comment styles, but even specify block vs per-line for languages that support block comments.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    gc{motion}   :: Toggle comments (for small comments within one line &#xA;                    the &amp;amp;filetype_inline style will be used, if &#xA;                    defined)&#xA;    gcc          :: Toggle comment for the current line&#xA;&#xA;Explicit commenting/uncommenting:&#xA;&#xA;    g&amp;lt;{motion}   :: Uncomment region&#xA;    g&amp;lt;c          :: Uncomment the current line&#xA;    g&amp;lt;b          :: Uncomment the current region as block&#xA;&#xA;    g&amp;gt;{motion}   :: Comment region&#xA;    g&amp;gt;c          :: Comment the current line&#xA;    g&amp;gt;b          :: Comment the current region as block&#xA;&#xA;In visual mode:&#xA;&#xA;    gc           :: Toggle comments&#xA;    gC           :: Comment selected text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="609" LastEditorUserId="609" LastEditDate="2015-02-19T17:06:37.300" LastActivityDate="2015-02-19T17:06:37.300" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1936" PostTypeId="2" ParentId="1896" CreationDate="2015-02-19T09:41:25.983" Score="1" Body="&lt;p&gt;&lt;code&gt;:vertical resize 80&lt;/code&gt; will set your current vsplit to 80 characters wide&lt;/p&gt;&#xA;" OwnerUserId="609" LastActivityDate="2015-02-19T09:41:25.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1937" PostTypeId="1" AcceptedAnswerId="1938" CreationDate="2015-02-19T09:46:36.093" Score="21" ViewCount="12242" Body="&lt;p&gt;I'd like to have my editors give me as much screen real estate as possible since it increases my ability to see most of the code at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that &lt;code&gt;gvim&lt;/code&gt; seems to give me either an 80x25 window or remember the last non-maximised size, depending on how I invoke it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how can I force it to be as large as possible, irrespective of any remembered state?&lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastEditorUserId="24" LastEditDate="2015-02-19T10:36:31.293" LastActivityDate="2022-05-20T18:00:25.407" Title="How do I get gvim to start maximised in Windows?" Tags="|gvim|microsoft-windows|window-management|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1938" PostTypeId="2" ParentId="1937" CreationDate="2015-02-19T09:46:36.093" Score="25" Body="&lt;p&gt;You can put this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd GUIEnter * simalt ~x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;at the end of your &lt;code&gt;gvimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method uses the &lt;code&gt;autocmd&lt;/code&gt; feature to weave its magic. The command &lt;code&gt;autocmd GUIEnter *&lt;/code&gt; specifies a command to run after successfully starting the GUI for a file pattern of &lt;code&gt;*&lt;/code&gt; (any file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command it will execute, &lt;code&gt;simalt ~x&lt;/code&gt; (in Windows variants of &lt;code&gt;vim&lt;/code&gt; only), will simulate the keystroke &lt;kbd&gt;Alt Spacebar&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;, which are the keystrokes that will maximise the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use the shortened version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au GUIEnter * sim ~x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I prefer fully expanded commands myself, especially since it's the sort of thing you set and forget, only entering &lt;em&gt;once&lt;/em&gt; when installing &lt;code&gt;vim&lt;/code&gt; onto a Windows system.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Keep in mind that this is simulating keystrokes in order to achieve its ends. On English versions, it will work fine since &lt;kbd&gt;Alt-Space&lt;/kbd&gt;&lt;kbd&gt;X&lt;/kbd&gt; is how you maximise a window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't work for you, you should investigate the keystrokes in whatever locale you're using. For example, the French version will use &lt;code&gt;Agrandir&lt;/code&gt; (enlarge) with the &lt;code&gt;n&lt;/code&gt; as the control keystroke, so the command you would need there is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd GUIEnter * simalt ~n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(which would actually &lt;em&gt;minimise&lt;/em&gt; your window in English).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're some &lt;em&gt;other&lt;/em&gt; (non-English, non-French) variant, just press &lt;kbd&gt;Alt-Space&lt;/kbd&gt; on a window to bring up the system menu, and find out what key should be used (it should be underlined).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To &lt;em&gt;find&lt;/em&gt; your &lt;code&gt;gvimrc&lt;/code&gt; file for adding whatever command you need, you can enter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:version&#xA;:echo $VIM&#xA;:echo $HOME&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you should get a list of startup files and variables like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;system gvimrc file = &quot;$VIM/gvimrc&quot;&#xA;  user gvimrc file = &quot;$HOME/_gvimrc&quot;&#xA;&#xA;C:\Program Files (x86)\Vim&#xA;C:\Users\Pax\Documents&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user579" LastEditorDisplayName="user579" LastEditDate="2015-05-20T08:51:40.980" LastActivityDate="2015-05-20T08:51:40.980" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1939" PostTypeId="2" ParentId="130" CreationDate="2015-02-19T09:51:33.180" Score="6" Body="&lt;p&gt;After you have selected the lines, simply type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm I#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:&lt;/code&gt; will automatically put &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; on your command line, which is a range from the start of your selection to the end; &lt;code&gt;norm&lt;/code&gt; executes a normal mode command, and will act on that range; &lt;code&gt;I#&lt;/code&gt; is the normal mode command which inserts a '#' at the start of the line.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-02-19T09:51:33.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1940" PostTypeId="2" ParentId="834" CreationDate="2015-02-19T10:03:51.037" Score="7" Body="&lt;p&gt;Here is the full list of settings which should be added to your &lt;code&gt;.vimrc&lt;/code&gt; if you want to prevent any leakage of sensitive files.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nobackup&#xA;set nowritebackup&#xA;set noundofile&#xA;set noswapfile&#xA;set viminfo=&quot;&quot;&#xA;set noshelltemp&#xA;set history=0&#xA;set nomodeline&#xA;set secure&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I recommend you create a new configuration file called &lt;code&gt;.vimrc_secure&lt;/code&gt; and run Vim with &lt;code&gt;vim -u ~/.vimrc_secure&lt;/code&gt; (or create a script/alias) when you want to edit your sensitive file. This will minimize the risk of a malicious plugin or buggy feature.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-02-19T10:03:51.037" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1941" PostTypeId="2" ParentId="1915" CreationDate="2015-02-19T10:28:27.777" Score="16" Body="&lt;p&gt;I usually do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:&amp;lt;start&amp;gt;,&amp;lt;end&amp;gt;d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will delete every line between the start and end line numbers provided (including the given lines).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that both &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; can be absolute line numbers, patterns, or offsets from another position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see doubleDown's comment about viewing Vim's &lt;em&gt;range&lt;/em&gt; documentation, it has some useful tips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you have the following file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. The quick brown&#xA;2. fox jumps&#xA;3. over the&#xA;4. lazy dog.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then by using the command &lt;code&gt;:2,3d&lt;/code&gt; or &lt;code&gt;:/fox/,/over/d&lt;/code&gt; or &lt;code&gt;:/quick/+1,/lazy/-1&lt;/code&gt; or &lt;code&gt;:+1,+2d&lt;/code&gt; if you're on the first line or &lt;code&gt;:-1,.d&lt;/code&gt; if you're on the third line, you end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. The quick brown&#xA;4. lazy dog.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="621" LastEditorUserId="14283" LastEditDate="2019-05-02T04:43:46.037" LastActivityDate="2019-05-02T04:43:46.037" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1942" PostTypeId="1" CreationDate="2015-02-19T10:33:54.627" Score="95" ViewCount="68089" Body="&lt;p&gt;&lt;code&gt;:!&amp;lt;command&amp;gt;&lt;/code&gt; can be used to execute a command in the shell. But this &quot;takes over&quot; my terminal and fills it with &lt;code&gt;stdout&lt;/code&gt; of that particular command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I execute a command in the background that only notifies me on a non-zero exit code?&lt;/p&gt;&#xA;" OwnerUserId="153" LastEditorUserId="51" LastEditDate="2015-02-19T10:52:35.017" LastActivityDate="2018-11-28T10:08:22.760" Title="How to execute shell commands silently?" Tags="|external-command|" AnswerCount="9" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1943" PostTypeId="5" CreationDate="2015-02-19T10:36:04.133" Score="0" Body="&lt;p&gt;In Vim, a &lt;strong&gt;window&lt;/strong&gt; is a visual view of a buffer.&#xA;There can be multiple (or no) windows associated with any given buffer, and each window can be in a different state (e.g., viewing a different part of the buffer).&#xA;Windows are grouped together in tab pages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some common operations on windows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Quickly create windows with the &lt;code&gt;:split&lt;/code&gt; and &lt;code&gt;:vsplit&lt;/code&gt; commands.&#xA;Execute &lt;code&gt;:split&lt;/code&gt; to divide the current window horizontally into two&#xA;views of the same buffer, and use &lt;code&gt;:vsplit&lt;/code&gt; to divide the window&#xA;vertically. By providing an argument to &lt;code&gt;:split&lt;/code&gt; or &lt;code&gt;:vsplit&lt;/code&gt;, you&#xA;can specify a different file to view in the new window.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Switch windows with the &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; commands. Press &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; and then one&#xA;of &lt;code&gt;h&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, or &lt;code&gt;l&lt;/code&gt; to move left, down, up, or to the right,&#xA;respectively.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Close a window with &lt;code&gt;&amp;lt;C-W&amp;gt;c&lt;/code&gt; or &lt;code&gt;:q&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help windows&lt;/code&gt; within Vim for more information.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-19T12:31:35.327" LastActivityDate="2015-02-19T12:31:35.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1944" PostTypeId="4" CreationDate="2015-02-19T10:36:04.133" Score="0" Body="A Vim window is a view of a buffer. A tab page comprises one or more windows. For questions about interaction with the Microsoft operating system, use [microsoft-windows]. For questions about interaction with the desktop windowing system, use [window-management]." OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-19T15:33:22.057" LastActivityDate="2015-02-19T15:33:22.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1945" PostTypeId="5" CreationDate="2015-02-19T10:56:00.400" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-19T10:56:00.400" LastActivityDate="2015-02-19T10:56:00.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1946" PostTypeId="4" CreationDate="2015-02-19T10:56:00.400" Score="0" Body="Questions about the history of Vi. DO NOT use this for command history." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-19T15:33:52.123" LastActivityDate="2015-02-19T15:33:52.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1947" PostTypeId="2" ParentId="1942" CreationDate="2015-02-19T11:05:55.110" Score="77" Body="&lt;p&gt;&lt;code&gt;:silent exec &quot;!command&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that your vim session will still be occupied while your command is executing. This is due to Vim's synchronous nature. You can still get back to your shell by pressing CTRL+z (to send Vim to the background) and then resume vim with the command &lt;code&gt;fg&lt;/code&gt; as usual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do things asynchronously, take a look at Tim Pope's plugin &lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;noreferrer&quot;&gt;vim-dispatch&lt;/a&gt; or the project NeoVim which has native support for asynchronous command execution, which you can easily leverage using the plugin NeoMake. The latest version of Vim also has support for asynchronous tasks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3Asilent&quot; rel=&quot;noreferrer&quot;&gt;:h :silent&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="628" LastEditorUserId="628" LastEditDate="2016-11-15T14:44:39.933" LastActivityDate="2016-11-15T14:44:39.933" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="1948" PostTypeId="2" ParentId="236" CreationDate="2015-02-19T11:10:26.347" Score="2" Body="&lt;p&gt;To re-indent the whole block of a braced or bracketed block automatically, place your cursor on the same line where is a bracket, and try &lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;%&lt;/kbd&gt;. To change your shift width, use e.g. &lt;code&gt;:set sw=2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this won't work as expected, to decrease indent manually (&lt;a href=&quot;https://english.stackexchange.com/questions/149511/the-oppsite-word-of-indent-is-outdent-or-unindent&quot;&gt;outdent&lt;/a&gt;), try &lt;kbd&gt;&amp;lt;&lt;/kbd&gt;&lt;kbd&gt;%&lt;/kbd&gt; and repeat with &lt;kbd&gt;.&lt;/kbd&gt; (if necessary). Use &lt;kbd&gt;&gt;&lt;/kbd&gt;&lt;kbd&gt;%&lt;/kbd&gt; for opposite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;else&#xA;       {&#xA;         // some code&#xA;       }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;else&#xA;{&#xA;  // some code&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For specific code, to re-indent one line or few lines automatically, try:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;==&lt;/kbd&gt; to re-indent the current line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;5==&lt;/kbd&gt; to re-indent 5 lines&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To increase/decrease indent manually for one line or few lines, try:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;&amp;lt;&amp;lt;&lt;/kbd&gt; to de-indent the current line by shiftwidth spaces&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;5&amp;lt;&amp;lt;&lt;/kbd&gt; to de-indent 5 lines by shiftwidth spaces&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;&gt;&gt;&lt;/kbd&gt; to indent the current line by shiftwidth spaces&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;5&gt;&gt;&lt;/kbd&gt; to indent 5 lines by shiftwidth spaces&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;.&lt;/kbd&gt; to repeat if necessary&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can also do indentation in visual mode (&lt;kbd&gt;v&lt;/kbd&gt;) by selecting text and pressing &lt;kbd&gt;=&lt;/kbd&gt; (auto-indent), &lt;kbd&gt;&amp;lt;&lt;/kbd&gt; (de-indent) or &lt;kbd&gt;&gt;&lt;/kbd&gt;(indent).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another trick is to correct indentation of the entire file by: &lt;kbd&gt;gg=G&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you've tabs instead of spaces, use: &lt;code&gt;:retab&lt;/code&gt; which will replace all Tabs with spaces (See: &lt;a href=&quot;https://vi.stackexchange.com/q/495/467&quot;&gt;How to replace tabs with spaces?&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For external methods, you can try:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.lacusveris.com/PythonTidy/&quot; rel=&quot;nofollow noreferrer&quot;&gt;pythonTidy&lt;/a&gt; for reformat Python code, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!pythonTidy&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/235839/indent-multiple-lines-quickly-in-vi&quot;&gt;Indent multiple lines quickly in vi&lt;/a&gt; at stackoverflow SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/6428559/vim-reformat-a-source-file-to-go-from-2-space-indentations-to-3&quot;&gt;How to reformat a source file to go from 2 space indentations to 3?&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/6504507/vim-indenting-and-alignment-combining-spaces-and-tabs&quot;&gt;Vim indenting and alignment: combining spaces and tabs&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-02-28T16:40:00.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1949" PostTypeId="2" ParentId="1874" CreationDate="2015-02-19T11:48:03.863" Score="4" Body="&lt;p&gt;You could save your favourite layout using the &lt;code&gt;winsaveview&lt;/code&gt; command.  Here I am mapping it to &lt;code&gt;\sv&lt;/code&gt; for convenience:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;sv :let g:myLayout = winsaveview()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Be sure to run that before you break your layout!  ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you ever accidentally break your layout, you can restore it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;rv :call winrestview(g:myLayout)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-02-19T11:48:03.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1950" PostTypeId="2" ParentId="1889" CreationDate="2015-02-19T11:50:48.693" Score="4" Body="&lt;p&gt;If your vim crashes because of &lt;a href=&quot;https://en.wikipedia.org/wiki/Segmentation_fault&quot; rel=&quot;nofollow noreferrer&quot;&gt;segmentation fault&lt;/a&gt;, that indicates memory access violation which is caused either by software bug or hardware issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this happens repeatedly, you should do in order:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Disable plugins by running: &lt;code&gt;vim -u NONE&lt;/code&gt; and see if that helps.&lt;/li&gt;&#xA;&lt;li&gt;Upgrade your vim to the latest stable version.&lt;/li&gt;&#xA;&lt;li&gt;Upgrade your vim to the latest development version.&lt;/li&gt;&#xA;&lt;li&gt;Optionally double check the same vim version on different machine (maybe it's caused by hardware issues). &lt;/li&gt;&#xA;&lt;li&gt;Try to run &lt;code&gt;vim&lt;/code&gt; under debugger, e.g.: &lt;code&gt;gdb vim&lt;/code&gt; and check for the backtrace (after SEGV, in &lt;code&gt;gdb&lt;/code&gt;: type &lt;code&gt;bt&lt;/code&gt; or &lt;code&gt;bt full&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;If the backtrace doesn't have symbols, you've to recompile your vim to include these.&lt;/li&gt;&#xA;&lt;li&gt;If you've complete backtrace, please check for similar issues or report a new bug in &lt;a href=&quot;https://github.com/vim/vim/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim's bug tracker&lt;/a&gt; (for plain vim) or check for &lt;code&gt;:help bugs&lt;/code&gt;. If you've different version of vim (like gVim, MacVim, NeoVim), please report it to the right maintainers.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2017-06-02T19:37:58.447" LastActivityDate="2017-06-02T19:37:58.447" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1951" PostTypeId="2" ParentId="1874" CreationDate="2015-02-19T11:52:12.840" Score="4" Body="&lt;p&gt;The default keys to re-arrange windows only work within their local split group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-W x   Exchange current window with next (in group)&#xA;CTRL-W r   Rotate windows down/right (in group)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or they break the window out to the top group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-W  H | J | K | L   Move window to left/top/bottom/right-most edge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These are inadequate when you want to move the buffer into one of the other split groups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But on such occasions, &lt;strong&gt;the &lt;a href=&quot;https://github.com/wesQ3/vim-windowswap&quot; rel=&quot;nofollow&quot;&gt;WindowSwap plugin&lt;/a&gt; can help&lt;/strong&gt;.  It lets you to swap the buffers of any two arbitrary windows.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;leader&amp;gt; yw   &quot;Yank window&quot;: Yank the current window&#xA;&#xA;&amp;lt;leader&amp;gt; pw   &quot;Paste window&quot;: Swap the current window with the yanked window&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-02-22T08:24:01.913" LastActivityDate="2015-02-22T08:24:01.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1952" PostTypeId="2" ParentId="1942" CreationDate="2015-02-19T12:15:49.883" Score="12" Body="&lt;h1&gt;A quick and dirty solution (in pure Vimscript)&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This can start a process in the background:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!slow_command_here &amp;gt; /tmp/output 2&amp;gt;&amp;amp;1 &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But Vim needs a way to find out when the process has completed, and how, so let's use a marker file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!(rm -f /tmp/finished; slow_command_here &amp;gt; /tmp/output 2&amp;gt;&amp;amp;1; echo &quot;$?&quot; &amp;gt; /tmp/finished) &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now we can ask Vim to check every so often whether the process has completed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:augroup WaitForCompletion&#xA;:autocmd!&#xA;:autocmd CursorHold * if filereadable('/tmp/finished') | exec &quot;augroup WaitForCompletion&quot; | exec &quot;au!&quot; | exec &quot;augroup END&quot; | echo &quot;Process completed with exit code &quot;.readfile('/tmp/finished')[0] | end&#xA;:augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hey it's not pretty, but it sort-of works!&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Disadvantages&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Unfortunately the autocmd above won't trigger until you move the cursor.  And if you wanted to run more than one background process at a time, you would need to add unique IDs to those files, and to the autocmd group name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you can handle an extra dependency, you might be better off using a tried-and-tested solution like the vim-dispatch plugin mentioned in another answer.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Displaying output&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you want to see the &lt;strong&gt;output&lt;/strong&gt; of the process, rather than just the &lt;strong&gt;exit code&lt;/strong&gt;, then replace the final &lt;code&gt;echo&lt;/code&gt; above with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent botright pedit /tmp/output&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That would open the preview window.  To use the quickfix error list instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent cget /tmp/output | copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The quickfix list lets you easily navigate to errors using &lt;code&gt;:cnext&lt;/code&gt;. However &lt;code&gt;copen&lt;/code&gt; moves your cursor into the quickfix window when it opens, which will probably be surprising/annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(A workaround for that would be to open the QF window with &lt;code&gt;:copen&lt;/code&gt; when initially starting the process, so you will &lt;em&gt;not&lt;/em&gt; need to call it at the end.)&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-02-24T21:30:56.710" LastActivityDate="2015-02-24T21:30:56.710" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1953" PostTypeId="5" CreationDate="2015-02-19T12:20:34.953" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-19T12:20:34.953" LastActivityDate="2015-02-19T12:20:34.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1954" PostTypeId="4" CreationDate="2015-02-19T12:20:34.953" Score="0" Body="A crash is when a program exits unexpectedly. This is usually (but not always) due to a bug in the software." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-19T15:33:45.347" LastActivityDate="2015-02-19T15:33:45.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1955" PostTypeId="5" CreationDate="2015-02-19T12:23:04.287" Score="0" Body="&lt;p&gt;Saving is writing a file open in Vi/Vim to a storage medium, such as a HDD or SSD. This can be done using the &lt;code&gt;:write&lt;/code&gt; command, but often, people will use &lt;code&gt;:w&lt;/code&gt; instead, as this saves time.&lt;/p&gt;&#xA;" OwnerDisplayName="user254" LastEditorDisplayName="user254" LastEditDate="2015-02-20T12:35:08.787" LastActivityDate="2015-02-20T12:35:08.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1956" PostTypeId="4" CreationDate="2015-02-19T12:23:04.287" Score="0" Body="Writing files to a persistent storage medium (usually a hard drive or SSD). In Vi, this is done with the :write command." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-19T15:33:35.173" LastActivityDate="2015-02-19T15:33:35.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1957" PostTypeId="2" ParentId="598" CreationDate="2015-02-19T12:27:28.847" Score="3" Body="&lt;p&gt;The easiest way I found to do this is documented here: &lt;a href=&quot;http://vimrcfu.com/snippet/77&quot; rel=&quot;nofollow&quot;&gt;http://vimrcfu.com/snippet/77&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the following in your .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap J :m '&amp;gt;+1&amp;lt;CR&amp;gt;gv=gv&#xA;vnoremap K :m '&amp;lt;-2&amp;lt;CR&amp;gt;gv=gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="644" LastActivityDate="2015-02-19T12:27:28.847" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1958" PostTypeId="2" ParentId="1942" CreationDate="2015-02-19T12:40:17.057" Score="43" Body="&lt;p&gt;To execute a command without triggering the Enter message, like:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Press ENTER or type command to continue&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;try the following simple example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent !echo Hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;L&lt;/kbd&gt; (or &lt;code&gt;:redraw!&lt;/code&gt;) to refresh the screen when back to Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid need for refresh, you can define your own custom command, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -nargs=1 Silent execute ':silent !'.&amp;lt;q-args&amp;gt; | execute ':redraw!'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, you can use the new Vim command to run a shell command (note: without &lt;em&gt;!&lt;/em&gt; and with capital &lt;em&gt;S&lt;/em&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Silent ps&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://vim.wikia.com/wiki/Avoiding_the_%22Hit_ENTER_to_continue%22_prompts&quot; rel=&quot;noreferrer&quot;&gt;Avoiding the &quot;Hit ENTER to continue&quot; prompts&lt;/a&gt; at the Vim Wikia site&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="927" LastEditDate="2017-09-25T06:39:22.047" LastActivityDate="2017-09-25T06:39:22.047" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1959" PostTypeId="2" ParentId="1915" CreationDate="2015-02-19T13:27:45.760" Score="5" Body="&lt;p&gt;The &lt;a href=&quot;http://myusuf3.github.io/numbers.vim/&quot;&gt;numbers.vim&lt;/a&gt; plugin is very useful for this. It's an enhanced way to precede each line with a line number. Like &lt;code&gt;'number'&lt;/code&gt; and &lt;code&gt;'relativenumber'&lt;/code&gt;, both roled into one!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's enabled by default after installation, you also want to add &lt;code&gt;set number&lt;/code&gt; to your vimrc if you haven't got it already, since it behaves in strange ways if you don't have it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;em&gt;normal mode&lt;/em&gt; it looks similar to &lt;code&gt;:set relativenumber&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  3 call plug#begin('~/.vim/plugged')&#xA;  2 &#xA;  1 Plug 'myusuf3/numbers.vim'&#xA;7   set number█&#xA;  1 &#xA;  2 &quot; Add indentation 'guidelines' (:IndentLinesToggle or &amp;lt;F11&amp;gt;)&#xA;  3 Plug 'Yggdroot/indentLine'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It shows you relative line numbers, &lt;strong&gt;except&lt;/strong&gt; for the line where the cursor is on, where it shows the absolute line number (7 in this case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we then switch to &lt;em&gt;insert mode&lt;/em&gt;, it will behave as if &lt;code&gt;number&lt;/code&gt; was set by always showing absolute line numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  4 call plug#begin('~/.vim/plugged')&#xA;  5 &#xA;  6 Plug 'myusuf3/numbers.vim'&#xA;  7 set number█&#xA;  8   &#xA;  9 &quot; Add indentation 'guidelines' (:IndentLinesToggle or &amp;lt;F11&amp;gt;)&#xA; 10 Plug 'Yggdroot/indentLine'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are some more options and a few commands (check the homepage), but the defaults should work for most people.&lt;/p&gt;&#xA;" OwnerUserId="655" LastEditorUserId="51" LastEditDate="2015-02-25T12:52:44.617" LastActivityDate="2015-02-25T12:52:44.617" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1960" PostTypeId="1" AcceptedAnswerId="1970" CreationDate="2015-02-19T13:46:11.440" Score="0" ViewCount="229" Body="&lt;p&gt;Is there any way to replace Vim's syntax highlighting?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I now have this test script to make everything between quotes red:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python&#xA;import re, sys&#xA;print(re.sub(r'&quot;(.*?)&quot;', r'\033[91m&quot;\1&quot;\033[0m', sys.stdin.read()))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I use this in Vim instead of Vim's built-in &lt;code&gt;syntax&lt;/code&gt; option? (Note that this script is just an example to show my idea). Or is there another way to do this?&lt;/p&gt;&#xA;" OwnerUserId="28" LastEditorUserId="51" LastEditDate="2015-02-19T15:44:20.050" LastActivityDate="2015-02-19T15:44:20.050" Title="Can I replace Vim's syntax highlighting with my own script?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1961" PostTypeId="2" ParentId="1937" CreationDate="2015-02-19T13:58:46.287" Score="3" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27lines%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'lines'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Number of lines of the Vim window.&lt;br /&gt;&#xA;[...]&lt;br /&gt;&#xA;When Vim is running in the GUI or in a resizable window, setting this&#xA;option will cause the window size to be changed.&lt;br /&gt;&#xA;[..]&lt;br /&gt;&#xA;You can use this command to get the tallest window possible:&lt;br /&gt;&#xA;&lt;code&gt;:set lines=999&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The &lt;code&gt;columns&lt;/code&gt; option does the same, except for the width (in characters).&lt;/p&gt;&#xA;&lt;p&gt;So you could, for example, put this in your vimrc file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set lines=55&#xA;set columns=120&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is &lt;em&gt;not&lt;/em&gt; the same as being maximized (even if you use the &lt;code&gt;999&lt;/code&gt; value as described above), since &amp;quot;being maximized&amp;quot; is a special flag put on the window, and subtly changes some operations (like moving), but it should solve your problem of having a small 80x25 window size by default.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="27109" LastEditDate="2022-05-20T18:00:25.407" LastActivityDate="2022-05-20T18:00:25.407" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="1964" PostTypeId="2" ParentId="82" CreationDate="2015-02-19T14:32:00.700" Score="8" Body="&lt;p&gt;YouCompleteMe (&lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot;&gt;Link&lt;/a&gt;) plugin has been work great for me. It uses libclang to generate the autocomplete feature, providing accurate completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has a lot of customization, specially when working with compilation flags. You can edit the &quot;flag generator&quot; editing a python script per project (&lt;a href=&quot;https://github.com/Valloric/ycmd/blob/master/cpp/ycm/.ycm_extra_conf.py&quot;&gt;Example&lt;/a&gt;). But, to me the main advantage is that it supports &lt;strong&gt;Clang Compilation Database&lt;/strong&gt; (&lt;a href=&quot;http://clang.llvm.org/docs/JSONCompilationDatabase.html&quot;&gt;Link!&lt;/a&gt;). This means that you can compile your code normally and ask clang to spit all the flags its used for the compilation, and use those flags with YouCompleteMe. Very handy if you want your autocompletion tool to be aware of your macro definitions or the location of all the headers files in your system without any effort of typing it manually.&lt;/p&gt;&#xA;" OwnerUserId="669" LastActivityDate="2015-02-19T14:32:00.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1965" PostTypeId="2" ParentId="1914" CreationDate="2015-02-19T14:39:04.373" Score="2" Body="&lt;p&gt;The &lt;code&gt;/usr/share/vim/vim74/syntax/javascript.vim&lt;/code&gt; uses this to define what a &quot;string region&quot; is in Javascript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region javaScriptStringD start=+&quot;+ skip=+\\\\\|\\&quot;+ end=+&quot;\|$+ contains=javaScriptSpecial,@htmlPreproc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;end&lt;/code&gt; option matches either the &lt;code&gt;&quot;&lt;/code&gt; character, &lt;em&gt;or&lt;/em&gt; the end of the line &lt;code&gt;$&lt;/code&gt;, which is why the syntax highlighting stops after the first line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can override this by making a &lt;code&gt;~/.vim/after/syntax/javascript.vim&lt;/code&gt; file with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region javaScriptStringD start=+&quot;+ skip=+\\\\\|\\&quot;+ end=+&quot;+ contains=javaScriptSpecial,@htmlPreproc&#xA;syn region javaScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=javaScriptSpecial,@htmlPreproc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One line for &lt;code&gt;&quot;strings&quot;&lt;/code&gt;, and another for &lt;code&gt;'strings'&lt;/code&gt;. We just removed the &lt;code&gt;|$&lt;/code&gt; part (&lt;code&gt;|&lt;/code&gt; for &quot;or&quot;, &lt;code&gt;$&lt;/code&gt; for end of line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I think it would be better to &lt;em&gt;only&lt;/em&gt; highlight the string if the previous line escapes the &lt;code&gt;\n&lt;/code&gt; (ie. ends with &lt;code&gt;\&lt;/code&gt;). I happen to know that the C syntax does this, but I can't seem to &lt;s&gt;steal&lt;/s&gt; borrow that and get it working in Javascript :-/&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-19T14:39:04.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1966" PostTypeId="2" ParentId="484" CreationDate="2015-02-19T14:54:53.557" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;https://code.google.com/p/lh-vim/source/browse/cpp/trunk/doc/lh-cpp-readme.txt#367&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:GOTOIMPL&lt;/code&gt;&lt;/a&gt; command from &lt;a href=&quot;https://code.google.com/p/lh-vim/wiki/lhCpp&quot; rel=&quot;nofollow&quot;&gt;lh-cpp&lt;/a&gt; is able to jump to a function definition from its declaration, or to provide a default empty definition in the case none was found. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some features I can think of:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The command already understands comments, exception specifications, keywords that shall not be copied (but possibly copied within comments)(&lt;code&gt;virtual&lt;/code&gt;, &lt;code&gt;static&lt;/code&gt;, ...). &lt;/li&gt;&#xA;&lt;li&gt;The current scope of the function is decoded (namespaces::classes::...) and correctly reported (i.e. it won't prefix with &lt;code&gt;ns::&lt;/code&gt; if we are within &lt;code&gt;namespace ns{&lt;/code&gt; or a &lt;code&gt;using namespace ns;&lt;/code&gt; context.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Templates are not (yet) understood.&lt;/li&gt;&#xA;&lt;li&gt;Function body are to be built manually one after the other -- i.e. I haven't yet took the time to execute :GOTOIMPL on all function declarations that ctags could points me.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastActivityDate="2015-02-19T14:54:53.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1969" PostTypeId="2" ParentId="388" CreationDate="2015-02-19T15:18:10.570" Score="10" Body="&lt;p&gt;As far as I'm concerned, I want the plugin manager I use to support dependencies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reasons are that I'm maintaining several plugins and I have a lot of inter-dependencies : a generic library is used by all, the template/snippet engine is used by the C++ suite, the refactoring plugin uses also the ctags library-plugin, and so on. Requiring end-user to execute up to 10 lines to install the plugins they are interested in doesn't appear to me as a good solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, I only know of two such plugins: &lt;a href=&quot;https://github.com/MarcWeber/vim-addon-manager&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-addon-manager&lt;/a&gt;, and &lt;a href=&quot;https://github.com/Shougo/neobundle.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;NeoBundle&lt;/a&gt;. VAM has forked its database code to &lt;a href=&quot;https://bitbucket.org/vimcommunity/vim-pi&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-pi&lt;/a&gt; after many exchanges on vim official mailing list. The idea was that NeoBundle (and any other plugin interested in managing dependencies) could eventually exploit vim-pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've recently came across &lt;a href=&quot;http://github.com/kana/vim-flavor&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-flavor&lt;/a&gt; that also handles dependencies. On the subject it checks plugin versions to install the right one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Since my initial answer, &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;NeoBundle development has stopped ;&lt;/li&gt;&#xA;&lt;li&gt;and while vim-pi updates regularly its database from plugins on vim.org, and that VAM can still be used to express dependencies, it seems no longer possible to add alias to vim-pi database: MR/PR aren't merged anymore&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;AFAIK, none of these plugin clone/install/update plugins in background/parallel. As I don't install a new vim environment, nor update the plugins I've installed once a month, honestly, I don't care. They of course update &lt;code&gt;'helptags'&lt;/code&gt;, take care of &lt;code&gt;'rtp'&lt;/code&gt;, and so on.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-09-10T07:22:12.993" LastActivityDate="2018-09-10T07:22:12.993" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1970" PostTypeId="2" ParentId="1960" CreationDate="2015-02-19T15:34:57.970" Score="1" Body="&lt;p&gt;If you don't like the stock syntax rules that come in, you are free to override them with your own. However, at some level, these rules will have to be defined via Viml.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help syntax&lt;/code&gt; will tell you all of the rules and conventions for how to do this, but you may wish to copy the existing syntax and modify it. If you run &lt;code&gt;:scriptnames&lt;/code&gt;, you can see a list of all files currently loaded and find the path to the syntax file for the language you're interested in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you truly object to using VimL to define syntax, you could always create a python wrapper that has the interface you desire and calls &lt;code&gt;:syn match/region/keyword&lt;/code&gt; under the hood. However, I'm hard-pressed to think of a way to simplify things enough to warrant the additional level of abstraction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find vim's syntax to be more powerful and clean than any python code I've seen that tries to accomplish the same. For instance, to define a string as something surrounded in double quotes that can contain &lt;code&gt;\\&lt;/code&gt; or &lt;code&gt;\&quot;&lt;/code&gt;, you would say something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region String start=/&quot;/ end=/&quot;/ skip=/\\\\\|\\&quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Having to backslash-escape \ and | is a little unfortunate I suppose, but &lt;code&gt;skip&lt;/code&gt; is just one of may features that make defining a syntax element easier than trying to cram it all in one regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A note on &quot;make a string red&quot;-- you have to do this in two steps in Vim:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Say everything in this regex is called a string (typically in a syntax file)&lt;/li&gt;&#xA;&lt;li&gt;Say that a string is red (typically in a colorscheme file)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is intentionally done so that you can use any colorscheme with any syntax.&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-02-19T15:34:57.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1971" PostTypeId="1" CreationDate="2015-02-19T15:38:25.743" Score="13" ViewCount="7381" Body="&lt;p&gt;If I have a vim session with two splits, when I execute a &lt;code&gt;:!&lt;/code&gt; command, the result is shown in the entire window. Is it possible to have the output shown just on the active split?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="51" LastEditDate="2015-02-19T15:40:01.990" LastActivityDate="2018-12-09T00:49:23.320" Title="Is it possible to have the output of a :! command in a split rather than the whole window?" Tags="|external-command|split|vim-windows|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1972" PostTypeId="2" ParentId="1971" CreationDate="2015-02-19T15:42:28.463" Score="1" Body="&lt;p&gt;That won't be possible. You'll have to split your screen with another tool like tmux (IIRC), screen, ... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't need to interact with the program executed, you can however import its results directly in any window (in the vim sense &lt;code&gt;:h windows&lt;/code&gt;) you wish with &lt;code&gt;:r!command line&lt;/code&gt;. &lt;code&gt;:h :r!&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2015-02-19T16:00:34.083" LastActivityDate="2015-02-19T16:00:34.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1973" PostTypeId="1" AcceptedAnswerId="1975" CreationDate="2015-02-19T15:46:12.827" Score="60" ViewCount="18307" Body="&lt;p&gt;Sometimes when I'm working on a file, I'll open up multiple files just to get an idea of the current flow of the code up to a point. However this sometimes leads to multiple files being open at a time by split. Is there a command to quit all except the selected window? &lt;/p&gt;&#xA;" OwnerUserId="25" LastEditorUserId="51" LastEditDate="2015-02-19T15:51:35.690" LastActivityDate="2019-01-16T17:58:36.193" Title="Close all split files, except the one currently focused?" Tags="|command-line|split|vim-windows|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1974" PostTypeId="2" ParentId="34" CreationDate="2015-02-19T15:47:49.397" Score="55" Body="&lt;p&gt;I'm specifically addressing:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why should I care?  As a user, what's the difference for me?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The thing I am most excited about as a Vim user are the new kinds of plugins, integrations, and interfaces that will be enabled by the changes under Neovim's hood.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As time goes by you will begin to see really impressive plugins and programs that work with Neovim but not Vim.  There's a list of Neovim-specific plugins: &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Related-projects#plugins&quot; rel=&quot;noreferrer&quot;&gt;here in neovim's github&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how up-to-date it is, but I am excited to see it grow as we get more tools to make coding more efficient and enjoyable.&lt;/p&gt;&#xA;" OwnerUserId="684" LastEditorUserId="12815" LastEditDate="2017-06-20T07:04:15.757" LastActivityDate="2017-06-20T07:04:15.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1975" PostTypeId="2" ParentId="1973" CreationDate="2015-02-19T15:56:27.643" Score="74" Body="&lt;p&gt;If you want to close all windows(splits) except the current one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:only&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to close all tabs except the current one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabonly&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to delete all hidden buffers (files open but not visible in any window on any tab), you'll have to add a function to your vimrc. Some people have posted possible functions to &lt;a href=&quot;https://stackoverflow.com/questions/1534835/how-do-i-close-all-buffers-that-arent-shown-in-a-window-in-vim&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://stackoverflow.com/questions/8450919/how-can-i-delete-all-hidden-buffers&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure exactly which of these you were trying to accomplish, but hopefully some combination of these commands does the trick.&lt;/p&gt;&#xA;" OwnerUserId="680" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-02-19T15:56:27.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1976" PostTypeId="2" ParentId="1973" CreationDate="2015-02-19T16:00:22.063" Score="53" Body="&lt;p&gt;Press &lt;kbd&gt;Ctrl+w&lt;/kbd&gt;,&lt;kbd&gt;o&lt;/kbd&gt; to quickly close all split windows, but current one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively use the command: &lt;code&gt;:on&lt;/code&gt; (&lt;code&gt;:only&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:on[ly][!]      Make the current window the only one on the screen. All other windows are closed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/758/467&quot;&gt;How to convert all windows into horizontal, vertical or tab splits?&lt;/a&gt; at Vim SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/4809729/cancel-split-window-in-vim&quot;&gt;How to cancel splitted windows?&lt;/a&gt; at stackoverflow SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/64/467&quot;&gt;Is it possible to split Vim window to view multiple files at once?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2019-01-16T17:58:36.193" LastActivityDate="2019-01-16T17:58:36.193" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1977" PostTypeId="1" AcceptedAnswerId="2062" CreationDate="2015-02-19T16:08:03.357" Score="19" ViewCount="28445" Body="&lt;p&gt;Can I jump to a function declaration or definition in a multiple C++ source files project?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say I have a header file &lt;code&gt;foo.hpp&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int bar();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and a source file &lt;code&gt;foo.cpp&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;foo.hpp&quot;&#xA;int bar() { return 42; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and a main file &lt;code&gt;main.cpp&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;foo.hpp&quot;&#xA;int main() { bar(); return 0; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can vim find both the definition and declaration of the function &lt;code&gt;bar()&lt;/code&gt; from the &lt;code&gt;main&lt;/code&gt; function?&lt;/p&gt;&#xA;" OwnerUserId="669" LastEditorUserId="915" LastEditDate="2015-02-23T01:29:38.803" LastActivityDate="2019-10-24T09:23:27.853" Title="Can I jump to a function declaration or definition in a multiple C++ source files project?" Tags="|ide|filetype-c++|ctags|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1979" PostTypeId="2" ParentId="1942" CreationDate="2015-02-19T16:26:59.243" Score="4" Body="&lt;p&gt;Not sure if this suits your needs, (does not handle background processes as in &lt;code&gt;foo &amp;amp;&lt;/code&gt;  – not sure if that is what you mean by &lt;em&gt;“in the background”&lt;/em&gt;), but a custom command could be used as in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:PraeceptumTacet(cmd)&#xA;    silent let f = systemlist(a:cmd)&#xA;    if v:shell_error&#xA;        echohl Error&#xA;        echom &quot;ERROR #&quot; . v:shell_error&#xA;        echohl WarningMsg&#xA;        for e in f&#xA;            echom e&#xA;        endfor&#xA;        echohl None&#xA;    endif&#xA;endfun&#xA;&#xA;command! -nargs=+ PT call s:PraeceptumTacet(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then use as e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PT ls -l&#xA;:PT foobar&#xA;ERROR #127&#xA;/bin/bash: foobar: command not found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you do not need / want the error message a simple  &lt;code&gt;system()&lt;/code&gt; could suffice, then check for &lt;code&gt;v:shell_error&lt;/code&gt; and report by e.g &lt;code&gt;echo Error!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;em&gt;help v:shell_error&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                        v:shell_error shell_error-variable&#xA;v:shell_error   Result of the last shell command.  When non-zero, the last&#xA;                shell command had an error.  When zero, there was no problem.&#xA;                This only works when the shell returns the error code to Vim.&#xA;                The value -1 is often used when the command could not be&#xA;                executed.  Read-only.&#xA;                Example: &amp;gt;&#xA;    :!mv foo bar&#xA;    :if v:shell_error&#xA;    :  echo 'could not rename &quot;foo&quot; to &quot;bar&quot;!'&#xA;    :endif&#xA;                &quot;shell_error&quot; also works, for backwards compatibility.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2015-02-19T16:41:29.587" LastActivityDate="2015-02-19T16:41:29.587" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1980" PostTypeId="2" ParentId="1977" CreationDate="2015-02-19T16:33:56.753" Score="4" Body="&lt;p&gt;So far I can name two solutions to the problem of finding either the declaration or the definition of a function. I know there is another well know tags based solution, but as I don't use it, I'll let others give it to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The more trendy one first: &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouCompleteMe&lt;/a&gt; has a &lt;code&gt;:GoToDefinition&lt;/code&gt; and a &lt;code&gt;:GoToDeclaration&lt;/code&gt; pair of commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The one I use (it's hard to change 10years long habits). My &lt;a href=&quot;http://lh-vim.googlecode.com/svn/tags/trunk/lh-tags-addon-info.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-tags&lt;/a&gt; plugin has a way to generate a ctags database and to update it incrementally. And also it offers a way (&lt;code&gt;CTRL+W Meta+Down&lt;/code&gt;) to present all declarations and definitions that match what is under the cursor (/what is selected). As this solution relies on ctags, it won't be able to know which overload the identifier under the cursor is really related too. Other ctags based solutions should as bad (/as good) on this topic. However YCM should be much better here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Discl.: I did implement lh-tags as a more ergonomic alternative to &lt;code&gt;:tselect&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Actually I remember a third solution: I had started a fork of &lt;a href=&quot;https://github.com/LucHermitte/clang_indexer&quot; rel=&quot;nofollow noreferrer&quot;&gt;clang-indexer&lt;/a&gt; and the related &lt;a href=&quot;https://github.com/LucHermitte/vim-clang&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim plugin&lt;/a&gt; that would have encapsulated it. But with YCM around, I'd to forget this solution)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: As of 2019, the most efficient solution rely on &lt;a href=&quot;https://langserver.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;LSP servers&lt;/a&gt;. I'm using &lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;COC&lt;/a&gt;+&lt;a href=&quot;https://github.com/MaskRay/ccls/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ccls&lt;/a&gt; to index, jump and do many more things. I'm falling back to tags based solutions when I'm too lazy to configure COC for a project on which I won't spend much time or where I cannot install recent versions of clang and ccls.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2019-10-24T09:23:27.853" LastActivityDate="2019-10-24T09:23:27.853" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1981" PostTypeId="1" CreationDate="2015-02-19T16:34:30.560" Score="10" ViewCount="1071" Body="&lt;p&gt;Currently, I have two similar methods to replace the entire buffer with some other text (say in clipboard).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Method #1:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;delete all lines: &lt;code&gt;:%d&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;paste text: &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt; ( or similar: &lt;code&gt;:put+&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Method #2:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;visually select all lines: &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;G&lt;/kbd&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;paste text: &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;However I couldn't seem to find an one-command-fire way to do that. The most close one I found is &lt;code&gt;:change&lt;/code&gt; command. But it doesn't seem to work well with registers. Of course I can create some function and/or map a key to do that. But before I could make all these customizations, I want to make sure:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there some built-in command to replace a range of lines with some other text?&#xA;  Like, you could &lt;code&gt;:%replace+&lt;/code&gt; to replace the entire buffer with text in clipboard?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="682" LastEditorUserId="24" LastEditDate="2015-02-19T21:50:49.777" LastActivityDate="2015-10-25T18:24:56.637" Title="Most efficient way to replace the entire buffer?" Tags="|cut-copy-paste|buffers|replace|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="1982" PostTypeId="2" ParentId="1977" CreationDate="2015-02-19T16:36:05.940" Score="0" Body="&lt;p&gt;I think that ctags it's what you need. Vim is integrated with ctags natively,  and can jump easily to function definitions and declarations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look on this article &lt;a href=&quot;http://andrew.stwrt.ca/posts/vim-ctags&quot; rel=&quot;nofollow&quot;&gt;http://andrew.stwrt.ca/posts/vim-ctags&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="702" LastActivityDate="2015-02-19T16:36:05.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1983" PostTypeId="1" AcceptedAnswerId="1985" CreationDate="2015-02-19T16:38:23.630" Score="66" ViewCount="26254" Body="&lt;p&gt;I'm editing my &lt;code&gt;.vimrc&lt;/code&gt; file, and I am including comments. When I have a comment like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; example comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then hit enter at the end of the line after finishing the comment, the next line is automatically set up as a comment (the quotes are automatically inserted):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; example comment&#xA;&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I stop this behavior?&lt;/p&gt;&#xA;" OwnerUserId="178" LastEditorUserId="51" LastEditDate="2015-04-30T15:37:33.303" LastActivityDate="2020-02-07T13:36:50.857" Title="How can I get vim to stop putting comments in front of new lines?" Tags="|formatting|comments|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1984" PostTypeId="1" AcceptedAnswerId="1987" CreationDate="2015-02-19T16:44:47.597" Score="4" ViewCount="3228" Body="&lt;p&gt;I am pasting several lines of text into vim at once (from another application, so I am using the OS's copy and paste and insert mode in vim). The longest of these lines is below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with this line is that vim inserts a new line after &quot;to&quot; so it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; :PluginClean      - confirms removal of unused plugins; append `!` to &#xA;&quot; auto-approve removal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I keep this line together when pasting?&lt;/p&gt;&#xA;" OwnerUserId="178" LastActivityDate="2015-02-19T18:35:55.130" Title="How can I get vim to not auto-wrap pasted text?" Tags="|vimrc|cut-copy-paste|" AnswerCount="2" CommentCount="2" ClosedDate="2015-02-20T00:38:15.600" ContentLicense="CC BY-SA 3.0" />
  <row Id="1985" PostTypeId="2" ParentId="1983" CreationDate="2015-02-19T16:47:11.533" Score="87" Body="&lt;p&gt;This is controlled with the &lt;code&gt;formatoptions&lt;/code&gt; setting; from &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#fo-table&quot;&gt;&lt;code&gt;:help fo-table&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can use the &lt;code&gt;'formatoptions'&lt;/code&gt; option  to influence how Vim formats text.&#xA;      &lt;code&gt;'formatoptions'&lt;/code&gt; is a string that can contain any of the letters below.  The&#xA;      default setting is &lt;code&gt;tcq&lt;/code&gt;.  You can separate the option letters with commas for&#xA;      readability.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that the statement about the &quot;defaults&quot; is somewhat misleading, since many filetypes change the formatoptions to best suit the file type; for example in &lt;code&gt;/usr/share/vim/vim74/ftplugin/vim.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set 'formatoptions' to break comment lines but not other lines,&#xA;&quot; and insert the comment leader when hitting &amp;lt;CR&amp;gt; or using &quot;o&quot;.&#xA;setlocal fo-=t fo+=croql&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can view the current &lt;code&gt;formatoptions&lt;/code&gt; with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set fo?&#xA;  formatoptions=jcroql&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And see where they were set like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set fo?&#xA;  formatoptions=jcroql&#xA;      Last set from /usr/share/vim/vim74/ftplugin/vim.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, you want to remove the &lt;code&gt;r&lt;/code&gt; flag, but perhaps also the &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;o&lt;/code&gt; flags:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;r       Automatically insert the current comment leader after hitting&#xA;        &amp;lt;Enter&amp;gt; in Insert mode.&#xA;c       Auto-wrap comments using textwidth, inserting the current comment&#xA;        leader automatically.&#xA;o       Automatically insert the current comment leader after hitting 'o' or&#xA;        'O' in Normal mode.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be done like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatoptions-=r formatoptions-=c formatoptions-=o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that using &lt;code&gt;:set formatoptions-=cro&lt;/code&gt; won't work as expected (since it's a string, it will look for the string &lt;code&gt;cro&lt;/code&gt;, in that order, which often won't work.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To set the changes &lt;em&gt;only&lt;/em&gt; for the current buffer, use &lt;code&gt;:setlocal&lt;/code&gt; instead of &lt;code&gt;:set&lt;/code&gt;. If you want to &lt;em&gt;always&lt;/em&gt; have these options, it's probably best to use an &lt;code&gt;autocmd&lt;/code&gt; in your vimrc; for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType vim setlocal fo-=c fo-=r fo-=o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will set the options &lt;em&gt;only&lt;/em&gt; for the 'vim' filetype, and won't interfere with other filetypes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to &lt;em&gt;always&lt;/em&gt; set it, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType * set fo-=c fo-=r fo-=o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just using &lt;code&gt;set fo-=cro&lt;/code&gt; won't work since many filetypes set/expand &lt;code&gt;formatoption&lt;/code&gt; (like shown above); the FileType autocmd is executed &lt;em&gt;after&lt;/em&gt; the filetype files have loaded.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-26T17:30:27.963" LastActivityDate="2015-02-26T17:30:27.963" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1986" PostTypeId="2" ParentId="1971" CreationDate="2015-02-19T16:57:41.820" Score="6" Body="&lt;p&gt;You can make a command to do just this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open a new split (or tab)&lt;/li&gt;&#xA;&lt;li&gt;Run a command and show the results in that split (or tab)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The command would be something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Rsplit command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Rtab command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;.vimrc&lt;/code&gt; you can write this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; execute a command and show its output in a split window&#xA;command! -nargs=* -complete=shellcmd Rsplit execute &quot;new | r! &amp;lt;args&amp;gt;&quot;&#xA;&#xA;&quot; execute a command and show its output in a new tab&#xA;command! -nargs=* -complete=shellcmd Rtab execute &quot;tabnew | r! &amp;lt;args&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find how to make your own commands with &lt;code&gt;:help :command&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="701" LastEditorUserId="-1" LastEditDate="2018-12-09T00:49:23.320" LastActivityDate="2018-12-09T00:49:23.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1987" PostTypeId="2" ParentId="1984" CreationDate="2015-02-19T16:59:50.343" Score="7" Body="&lt;p&gt;Before pasting, do &lt;code&gt;:set paste&lt;/code&gt;. This changes a bunch of settings like 'textwidth' and 'autoindent' for specifically this purpose. Then enter insert mode, paste with your OS, hit &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to leave insert mode, and do &lt;code&gt;:set nopaste&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also toggle settings with a &lt;code&gt;!&lt;/code&gt;, i.e. &lt;code&gt;:set paste!&lt;/code&gt; to turn it on/off.&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-02-19T16:59:50.343" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1988" PostTypeId="1" CreationDate="2015-02-19T17:32:52.880" Score="14" ViewCount="265" Body="&lt;p&gt;I've defined mappings in my &lt;code&gt;vimrc&lt;/code&gt; to automatically enter close parentheses and braces when I enter opening ones with &lt;code&gt;inoremap ( ()&amp;lt;esc&amp;gt;i&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to do the same for &lt;code&gt;&quot;&lt;/code&gt; and &lt;code&gt;'&lt;/code&gt;, but only when the cursor currently isn't inside a string - as inside a string &lt;code&gt;'&lt;/code&gt; is probably an apostrophe rather than a string delimiter. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="666" LastEditorUserId="51" LastEditDate="2015-04-30T15:39:04.887" LastActivityDate="2015-05-01T11:01:27.977" Title="Automatically add a closing &quot; or ' when inserting one, but only if the cursor isn't inside a string already" Tags="|key-bindings|vimscript|delimiter-matching|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1989" PostTypeId="5" CreationDate="2015-02-19T17:43:37.557" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-19T17:43:37.557" LastActivityDate="2015-02-19T17:43:37.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1990" PostTypeId="4" CreationDate="2015-02-19T17:43:37.557" Score="0" Body="For questions about The Python interface to Vim; DO NOT use for questions with Python examples or about syntax highlighting in Python." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-20T15:57:39.090" LastActivityDate="2015-02-20T15:57:39.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1991" PostTypeId="5" CreationDate="2015-02-19T17:43:52.903" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-19T17:43:52.903" LastActivityDate="2015-02-19T17:43:52.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1992" PostTypeId="4" CreationDate="2015-02-19T17:43:52.903" Score="0" Body="Configuring and using vi/vim to edit python code. For scripting vim using python, use the /vimscript-python tag." OwnerUserId="31" LastEditorUserId="31" LastEditDate="2015-02-19T22:34:43.877" LastActivityDate="2015-02-19T22:34:43.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1993" PostTypeId="2" ParentId="1912" CreationDate="2015-02-19T18:01:54.420" Score="1" Body="&lt;p&gt;I ended up using &lt;a href=&quot;https://github.com/briancollins/vim-jst&quot; rel=&quot;nofollow&quot;&gt;this plugin&lt;/a&gt;, installed with &lt;a href=&quot;https://github.com/gmarik/Vundle.vim&quot; rel=&quot;nofollow&quot;&gt;Vundle&lt;/a&gt; using &lt;code&gt;Bundle 'briancollins/vim-jst'&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;. Note for those who haven't used Vundle before, there's a bunch of other stuff you have to put in the &lt;code&gt;.vimrc&lt;/code&gt; as well, see its github for more detail.&lt;/p&gt;&#xA;" OwnerUserId="178" LastActivityDate="2015-02-19T18:01:54.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1994" PostTypeId="2" ParentId="1984" CreationDate="2015-02-19T18:35:55.130" Score="3" Body="&lt;p&gt;To paste text into vim without auto-indentation, you need to put Vim in Paste mode. This is useful if you want to cut or copy some text from one window and paste it in Vim.  This will avoid unexpected effects. See: &lt;code&gt;:help paste&lt;/code&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make a life easier, there is &lt;code&gt;pastetoggle&lt;/code&gt; variable which specifies the key sequence that toggles the 'paste' option (&lt;code&gt;:set invpaste&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In example if you'd like to use &lt;kbd&gt;F2&lt;/kbd&gt; to disable autoindenting if pasting into terminal in X, you may use the following code into your &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; :set invpaste paste?&amp;lt;CR&amp;gt;&#xA;set pastetoggle=&amp;lt;F2&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-02-19T18:35:55.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1995" PostTypeId="2" ParentId="730" CreationDate="2015-02-19T18:37:35.757" Score="3" Body="&lt;p&gt;To paste text into vim without auto-indentation, you need to put Vim in Paste mode. This is useful if you want to cut or copy some text from one window and paste it in Vim.  This will avoid unexpected effects. See: &lt;code&gt;:help paste&lt;/code&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make a life easier, there is &lt;code&gt;pastetoggle&lt;/code&gt; variable which specifies the key sequence that toggles the 'paste' option (&lt;code&gt;:set invpaste&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In example if you'd like to use &lt;kbd&gt;F2&lt;/kbd&gt; to disable autoindenting if pasting into terminal in X, you may use the following code into your &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; :set invpaste paste?&amp;lt;CR&amp;gt;&#xA;set pastetoggle=&amp;lt;F2&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-02-19T18:37:35.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1996" PostTypeId="2" ParentId="1988" CreationDate="2015-02-19T19:14:57.063" Score="5" Body="&lt;p&gt;One approach might be to use &lt;code&gt;syn*&lt;/code&gt; functions. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Qtx(qt)&#xA;    let x = synIDattr(synIDtrans(synID(line(&quot;.&quot;), col(&quot;.&quot;), 1)), &quot;name&quot;)&#xA;    if x != &quot;String&quot; &amp;amp;&amp;amp; x != &quot;Comment&quot; &amp;amp;&amp;amp; x != &quot;Constant&quot;&#xA;        return a:qt . a:qt&#xA;    endif&#xA;    return a:qt&#xA;endfun&#xA;&#xA;&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; ' Qtx(&quot;'&quot;)&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; &quot; Qtx('&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Idea is to take advantage of the syntax for buffer at cursor position. This can perhaps be solved better. But hopefully a start.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2015-02-19T19:20:06.023" LastActivityDate="2015-02-19T19:20:06.023" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1997" PostTypeId="2" ParentId="1988" CreationDate="2015-02-19T21:24:02.280" Score="2" Body="&lt;p&gt;As it has been said, you'll have to check the syntax-context. The old &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets&quot; rel=&quot;nofollow&quot;&gt;lh-brackets&lt;/a&gt; API provides functions for that purpose: &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets#the-viml-library&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Map*Context()&lt;/code&gt; functions&lt;/a&gt;. Since then the brackets definitions has been encapsulated in &lt;code&gt;:Bracket&lt;/code&gt; which will take the context (strings or comments) into consideration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default context aware mappings are defined for all the usual brackets pairs like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  :Brackets! ( )&#xA;  :Brackets! [ ] -visual=0&#xA;  :Brackets! [ ] -insert=0 -trigger=&amp;lt;leader&amp;gt;[&#xA;&#xA;  :Brackets! &quot; &quot; -visual=0 -insert=1&#xA;  :Brackets! &quot; &quot; -visual=1 -insert=0 -trigger=&quot;&quot;&#xA;  :Brackets! ' ' -visual=0 -insert=1 -but=function('lh#ft#is_text')&#xA;  :Brackets! ' ' -visual=1 -insert=0 -trigger=''&#xA;&#xA;  :Brackets! &amp;lt; &amp;gt; -visual=1 -insert=0 -trigger=&amp;lt;localleader&amp;gt;&amp;lt;&#xA;&#xA;  :Brackets! { }&#xA;  :Brackets! { } -visual=1 -insert=0 -nl -trigger=&amp;lt;leader&amp;gt;{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2015-05-01T11:01:27.977" LastActivityDate="2015-05-01T11:01:27.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1998" PostTypeId="2" ParentId="1915" CreationDate="2015-02-19T21:31:29.637" Score="4" Body="&lt;p&gt;Another approach is if you are trying to delete to a specific pattern, you can simply type &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;code&gt;delim&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="754" LastActivityDate="2015-02-19T21:31:29.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1999" PostTypeId="1" AcceptedAnswerId="2000" CreationDate="2015-02-19T21:47:36.350" Score="3" ViewCount="13121" Body="&lt;p&gt;I am trying to write a regular expression that will match all double quoted strings across newlines. I have been fiddling around with the following pattern but it seems to only match strings on the same line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v&quot;\zs(.*|\n*)\ze&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pattern should match something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;This is an example&#xA; of a multi, line -- %123 string with&#xA; some random 123 symbol's &#xA; `inside` \\//&amp;gt;&amp;lt;&amp;gt;&amp;lt; of it&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is wrong with the pattern I have?&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastActivityDate="2015-02-19T21:59:34.730" Title="Regex to search double quoted strings on multiple lines" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2000" PostTypeId="2" ParentId="1999" CreationDate="2015-02-19T21:59:34.730" Score="8" Body="&lt;p&gt;You can simply use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v&quot;([^&quot;]|\n)*&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;       quotation mark&#xA;(...)*  followed by 0 or more of...&#xA;  [^&quot;]    character that is not a quotation mark&#xA;  |\n     or a newline&#xA;&quot;       followed by another quotation mark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will also &quot;work&quot; for &quot;multiple&quot; strings &quot;in the same&quot; file, because &lt;code&gt;[^&quot;]&lt;/code&gt; makes sure that the regex never matches past another quotation mark.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's an alternative that's shorter but a bit harder to read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v&quot;\_.{-}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;    quotation mark&#xA;\_.  any character, including a newline (see `:help /\_.')&#xA;{-}  non-greedy version of * (see `:help non-greedy')&#xA;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also works for multiple strings in the same file due to &lt;code&gt;{-}&lt;/code&gt;, which is the lazy equivalent of &lt;code&gt;*&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-19T21:59:34.730" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2001" PostTypeId="1" AcceptedAnswerId="2002" CreationDate="2015-02-19T22:02:36.473" Score="137" ViewCount="40023" Body="&lt;p&gt;I often make changes to the middle of a big file, use &lt;code&gt;gg&lt;/code&gt; to jump to the top to check something, and then realize I forgot to set a mark where I was editing. Is there a built-in way to jump to the location of the last-changed line?&lt;/p&gt;&#xA;" OwnerUserId="671" LastEditorUserId="24" LastEditDate="2015-02-21T08:14:56.733" LastActivityDate="2019-12-10T15:02:01.293" Title="How do I jump to the location of my last edit?" Tags="|cursor-movement|command-history|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2002" PostTypeId="2" ParentId="2001" CreationDate="2015-02-19T22:07:00.693" Score="179" Body="&lt;p&gt;The &lt;code&gt;`.&lt;/code&gt; command will bring you to your last change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;`&lt;/code&gt; goes to a mark, and &lt;code&gt;.&lt;/code&gt; is a &quot;special&quot; mark which is automatically set to the position where the last change was made. See &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%60.&quot;&gt;&lt;code&gt;:help `.&lt;/code&gt;&lt;/a&gt; for some more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;code&gt;``&lt;/code&gt; which will bring you back to where the cursor was before you made your last jump. See &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%60%60&quot;&gt;:help &lt;code&gt;``&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another useful mark is &lt;code&gt;`^&lt;/code&gt;; this is the position where the cursor was the last time when insert mode was stopped. See &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%60%5E&quot;&gt;&lt;code&gt;:help `^&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#mark-motions&quot;&gt;&lt;code&gt;:help mark-motions&lt;/code&gt;&lt;/a&gt; for some more general info about using marks (including some other &quot;special&quot; marks that are automatically set).&lt;/p&gt;&#xA;" OwnerUserId="687" LastEditorUserId="671" LastEditDate="2015-02-19T23:00:03.887" LastActivityDate="2015-02-19T23:00:03.887" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2003" PostTypeId="1" AcceptedAnswerId="2004" CreationDate="2015-02-19T22:08:02.847" Score="111" ViewCount="34811" Body="&lt;p&gt;I have a problem in Vim, and I think it may be in my &lt;code&gt;vimrc&lt;/code&gt; file (or have been &lt;em&gt;told&lt;/em&gt; it could be my &lt;code&gt;vimrc&lt;/code&gt; file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I verify this? If it &lt;em&gt;is&lt;/em&gt; my &lt;code&gt;vimrc&lt;/code&gt; file, how do I know where &lt;em&gt;exactly&lt;/em&gt; the problem lies?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorDisplayName="user579" LastEditDate="2018-09-12T06:36:18.460" LastActivityDate="2023-01-20T19:55:13.243" Title="How do I debug my vimrc file?" Tags="|vimrc|" AnswerCount="8" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2004" PostTypeId="2" ParentId="2003" CreationDate="2015-02-19T22:08:02.847" Score="109" Body="&lt;p&gt;The first thing you want to do is to start Vim with the default settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-u NONE&lt;/code&gt; prevents Vim from loading your vimrc, &lt;code&gt;-U NONE&lt;/code&gt; prevents Vim from&#xA;loading your gvimrc, and &lt;code&gt;-N&lt;/code&gt; tells Vim to use no-compatible mode (this isn't&#xA;required, but most Vim users are not used to &quot;compatible&quot; mode).&#xA;Note that the &lt;code&gt;NONE&lt;/code&gt; is &lt;em&gt;required&lt;/em&gt; to be in all-caps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Windows you can &lt;a href=&quot;https://superuser.com/questions/29569/how-to-add-command-line-options-to-shortcut&quot;&gt;add these flags by creating a new shortcut&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If the problem stays, then you know it's &lt;em&gt;not&lt;/em&gt; something in your vimrc.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the problem disappears, you now it's caused by &lt;em&gt;something&lt;/em&gt; in your vimrc&#xA;file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;It's not my vimrc!&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Hurray! Go and ask your question. Be sure to mention that you tried starting Vim&#xA;without a vimrc file!&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;So it's my vimrc, now what?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;If you haven't already, you probably want to save a backup copy of your vimrc&#xA;file first.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Check the plugins&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The next thing you probably want to do is disable all plugins first; plugins can&#xA;alter quite a bit in Vim. If this fixes the problem, then try to find out&#xA;&lt;em&gt;which&lt;/em&gt; plugin by re-enabling them one-by-one. After you've found out which&#xA;plugin exactly causes the problem, you can try &amp;amp; fix it by reading this plugin's&#xA;documentation, and/or by asking a question tagged with &lt;code&gt;plugin-&amp;lt;name&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's &lt;em&gt;not&lt;/em&gt; a plugin, and you don't have &lt;em&gt;any&lt;/em&gt; idea what's causing your&#xA;problem, then it's a trial-and-error procedure. Comment out one or more lines in&#xA;your vimrc, start Vim, check if the problem occurs, and repeat this procedure&#xA;until the problem stops occurring. The fastest way of doing this is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Comment out (or remove) about half your vimrc file.&lt;/li&gt;&#xA;&lt;li&gt;Restart Vim, or open a new Vim (reloading the vimrc is &lt;em&gt;not&lt;/em&gt; good enough, as&#xA;settings aren't unset).&lt;/li&gt;&#xA;&lt;li&gt;Is the problem now gone? Put back the part you removed out (keeping Vim&#xA;open and using undo is useful here) and repeat step 1 on the part you added&#xA;back.&lt;/li&gt;&#xA;&lt;li&gt;Does the problem still occur? Go to step 1.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In the end you should have a single option or a combination of a few options&#xA;that causes your problem. You can find out more about any option in Vim by&#xA;using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'option_name'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The quotes are important here, it &lt;em&gt;usually&lt;/em&gt; works without them, but sometimes&#xA;you end up on the wrong page if you omit them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're still confused after reading the help page, you know where to ask a&#xA;question ;-)&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Debugging a single plugin&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;If you want to isolate a single plugin, perhaps to ask a question about it, you want to load as little as&#xA;possible but &lt;em&gt;still&lt;/em&gt; load the plugin; you can easily do this with Vim's packages&#xA;feature. This requires Vim 8 or a reasonably recent version of Neovim.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Create a new empty directory; we'll use the &lt;code&gt;~/plugin&lt;/code&gt; path in this example.&#xA;Now put the plugin in the regular &lt;code&gt;pack/plugins/start/$name&lt;/code&gt; directory. For&#xA;example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/fatih/vim-go.git ~/plugin/pack/plugins/start/vim-go&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create a &lt;code&gt;test-vimrc&lt;/code&gt; file with the following contents; this will ensure that&#xA;Vim will load plugins from the &lt;code&gt;~/plugin&lt;/code&gt; directory and &lt;em&gt;not&lt;/em&gt; the &lt;code&gt;~/.vim&lt;/code&gt;&#xA;directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set packpath=~/plugin,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,~/plugin/after&#xA;packloadall!&#xA;&#xA;syntax on&#xA;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Start Vim with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -U NONE -u ~/test-vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You now have a minimal vimrc with just this single plugin.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Footnotes&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; For example: on 64 bit Windows, the shortcut would look something like this: &lt;code&gt;&quot;C:\Program Files (x86)\Vim\vim74\vim.exe&quot; -u NONE -U NONE -N&lt;/code&gt;. To create it, right click in File Explorer where you want the shortcut, then select New -&gt; Shortcut and paste the shortcut text. You may need to change the Vim path if your Vim is installed in another location.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="7547" LastEditDate="2018-09-19T11:47:07.820" LastActivityDate="2018-09-19T11:47:07.820" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="2005" PostTypeId="1" AcceptedAnswerId="2007" CreationDate="2015-02-19T22:14:39.933" Score="13" ViewCount="2068" Body="&lt;p&gt;I am using the following regular expression to match a documentation string underneath a Clojure function definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\vdefn.*\n\s*\zs&quot;([^&quot;]|\n)*&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to run the normal mode &lt;code&gt;gq&lt;/code&gt; (format lines) command on all matches of this pattern in a given file?&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastActivityDate="2015-02-20T00:30:33.323" Title="Apply normal mode command to regex matches" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2006" PostTypeId="1" AcceptedAnswerId="2008" CreationDate="2015-02-19T22:20:26.963" Score="10" ViewCount="795" Body="&lt;p&gt;Occasionally, my pinky will graze the &lt;code&gt;'&lt;/code&gt; key while reaching for enter, resulting in &lt;code&gt;:w'&amp;lt;Enter&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cabbrev w' :w&#xA;cabbrev w\' :w&#xA;cabbrev &quot;w'&quot; :w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;None of them work.  Is there a way to alias &lt;code&gt;:w'&lt;/code&gt; to &lt;code&gt;:w&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also use cmdwin (&lt;code&gt;:help cmdwin&lt;/code&gt; + &lt;code&gt;nnoremap : :&amp;lt;C-F&amp;gt;&lt;/code&gt;) instead of the normal command-line, so bonus points if it works there too.&lt;/p&gt;&#xA;" OwnerUserId="319" LastEditorUserId="319" LastEditDate="2015-02-20T16:09:08.470" LastActivityDate="2015-02-20T16:09:08.470" Title="Is there a way to alias `:w'` to `:w`, to avoid creating files named '?" Tags="|command-line|save|key-bindings|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2007" PostTypeId="2" ParentId="2005" CreationDate="2015-02-19T22:24:39.593" Score="12" Body="&lt;p&gt;Power of &lt;code&gt;g&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\vdefn.*\n\s*\zs&quot;([^&quot;]|\n)*&quot;/normal gngq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The part between the &lt;code&gt;/&lt;/code&gt;s is fairly self-explanatory, since it's the regex from your original question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;normal gngq&lt;/code&gt; at the end is somewhat interesting. &lt;code&gt;gn&lt;/code&gt; will select the next match of the regular expression, and &lt;code&gt;gq&lt;/code&gt;, of course, formats this selection (as you mentioned in your question).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:g&lt;/code&gt; is the really great part. This is, in my opinion, one of Vim's most useful features. The &lt;code&gt;g&lt;/code&gt; ex command takes a regex and an Ex command, and it executes the command on every line the regex matches. If you haven't learned about &lt;code&gt;:g&lt;/code&gt; already, I highly recommend doing so, as it'll vastly increase your productivity. A few resources are Vim's own &lt;code&gt;:help :g&lt;/code&gt; or &lt;a href=&quot;http://vim.wikia.com/wiki/Power_of_g&quot; rel=&quot;noreferrer&quot;&gt;Power of g&lt;/a&gt; on Vim wiki.&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorDisplayName="user489" LastEditDate="2015-02-20T00:30:33.323" LastActivityDate="2015-02-20T00:30:33.323" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="2008" PostTypeId="2" ParentId="2006" CreationDate="2015-02-19T22:29:12.383" Score="8" Body="&lt;p&gt;As Peter Rincker points out, &lt;code&gt;cmap&lt;/code&gt;s can expand in other places as well, so a &lt;a href=&quot;https://stackoverflow.com/questions/7513380/vim-change-x-function-to-delete-buffer-instead-of-save-quit&quot;&gt;&lt;code&gt;cnoreabbrev&lt;/code&gt; would be better&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev w' w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, the safest, again thanks to Peter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev &amp;lt;expr&amp;gt; w' getcmdtype() == &quot;:&quot; &amp;amp;&amp;amp; getcmdline() == &quot;w'&quot; ? &quot;w&quot; : &quot;w'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By explicitly checking if the command line contains only &lt;code&gt;w'&lt;/code&gt;, unwanted expansions in situations can be avoided.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use a &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Acmap&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;cmap&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmap w' w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'd still have to press &lt;kbd&gt;Enter&lt;/kbd&gt;, but an accidental &lt;code&gt;'&lt;/code&gt; should be ignored now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using &lt;code&gt;cmdwin&lt;/code&gt;, a &lt;code&gt;inoremap&lt;/code&gt; set by &lt;code&gt;autocmd&lt;/code&gt; might be useful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CmdwinEnter * inoremap w' w&#xA;autocmd CmdwinLeave * iunmap w'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-20T00:04:30.753" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="2009" PostTypeId="1" AcceptedAnswerId="2206" CreationDate="2015-02-19T23:02:35.887" Score="10" ViewCount="2589" Body="&lt;p&gt;When I want to edit my &lt;code&gt;zshrc&lt;/code&gt;, I just type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim .zshrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without specifying the full path (&lt;code&gt;~/.zshrc&lt;/code&gt;), if I am in a different directory, this will instead start a new file. This is very annoying, since I only have one &lt;code&gt;.zshrc&lt;/code&gt;, in &lt;code&gt;~&lt;/code&gt;, and only one &lt;code&gt;vimrc&lt;/code&gt;, in &lt;code&gt;~/.vim/&lt;/code&gt;. So, how do I get vim to open &lt;code&gt;~/.zshrc&lt;/code&gt; or &lt;code&gt;~/.vim/vimrc&lt;/code&gt; when I do &lt;code&gt;vim .zshrc&lt;/code&gt; or &lt;code&gt;vim vimrc&lt;/code&gt; in some other directory?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;While creating some configuration for each individual file is one way, I was thinking of something along the lines of &lt;code&gt;CDPATH&lt;/code&gt;. &lt;code&gt;CDPATH&lt;/code&gt; is a variable in some shells that contains a list of paths where &lt;code&gt;cd&lt;/code&gt; will look for a directory. For example, if I had &lt;code&gt;CDPATH=:/home/muru&lt;/code&gt;, and I were in &lt;em&gt;any&lt;/em&gt; directory that doesn't contain a directory named &lt;code&gt;Desktop&lt;/code&gt;, I could do &lt;code&gt;cd Desktop&lt;/code&gt; and reach &lt;code&gt;/home/muru/Desktop&lt;/code&gt;. Simple, elegant, flexible. If &lt;code&gt;vim&lt;/code&gt; had a &lt;code&gt;VIMPATH&lt;/code&gt; where it would look for files to edit, that would be the best option.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="24" LastEditDate="2015-02-20T05:01:31.370" LastActivityDate="2016-07-06T20:00:43.167" Title="How do I make vim look in a set of directories for a file, if it doesn't exist in the current directory?" Tags="|filesystem|load|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2010" PostTypeId="1" AcceptedAnswerId="2156" CreationDate="2015-02-19T23:27:06.797" Score="13" ViewCount="32959" Body="&lt;p&gt;I imported the solarized colorscheme and palette. My terminal has the correct colors and background, gvim has the correct colors and background, but vim has an incorrectly colored background. The text is all correct, but the background appears to be pure black.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LZnB3.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LZnB3.png&quot; alt=&quot;This is a comparison of Terminal, GVim, and Vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax enable&#xA;&#xA;if has('gui_running')&#xA;    set background=dark&#xA;else&#xA;    set background=dark&#xA;endif&#xA;&#xA;:set t_Co=256&#xA;let g:solarized_termcolors=256&#xA;colorscheme solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If anyone has any suggestions on what could be causing this, I would be much obliged. I run xubuntu with the default terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should also mention that the light option results in a very yellow background for Vim.&lt;/p&gt;&#xA;" OwnerUserId="779" LastEditorUserId="24" LastEditDate="2015-02-20T04:22:37.617" LastActivityDate="2019-02-13T09:31:30.063" Title="Colorscheme's background not correct in terminal" Tags="|vimrc|terminal|colorscheme|x11|" AnswerCount="9" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2012" PostTypeId="2" ParentId="2009" CreationDate="2015-02-19T23:33:31.100" Score="3" Body="&lt;p&gt;Alternative is to make some commands that will make this easier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Evimrc e ~/.vimrc&#xA;command! Svimrc sp ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using the &lt;code&gt;E&lt;/code&gt;/&lt;code&gt;S&lt;/code&gt; pattern that &lt;a href=&quot;https://github.com/tpope/vim-rails&quot; rel=&quot;nofollow&quot;&gt;rails.vim&lt;/a&gt;/&lt;a href=&quot;https://github.com/tpope/vim-projectionist&quot; rel=&quot;nofollow&quot;&gt;projectionist.vim&lt;/a&gt; uses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :command&#xA;:h :e&#xA;:h :sp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-02-19T23:33:31.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2013" PostTypeId="1" AcceptedAnswerId="2017" CreationDate="2015-02-19T23:59:34.927" Score="3" ViewCount="930" Body="&lt;p&gt;How do I run vim with file.txt and &lt;strong&gt;screen center&lt;/strong&gt; at line 100?&#xA;Basically I would like to use &lt;code&gt;zz&lt;/code&gt; mapping when starting Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This does not work: &lt;code&gt;vim -c &quot;zz&quot; file.txt +100&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="784" LastEditorUserId="88" LastEditDate="2015-02-20T01:56:33.190" LastActivityDate="2015-02-20T01:56:33.190" Title="How can I automatically execute normal mode keystrokes with a terminal command when opening Vim?" Tags="|invocation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2014" PostTypeId="1" AcceptedAnswerId="2021" CreationDate="2015-02-20T00:05:45.513" Score="5" ViewCount="1826" Body="&lt;p&gt;I have a multiline text file. Some lines have URL's.&#xA;What would be the most efficient way to extract those URL's?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote macros and did a bunch of unnecessary things.&#xA;Now I'm thinking about regex groups or global command...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;text example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.&#xA;Ut enim ad minim veniam, https://en.wikipedia.org/wiki/Lorem_ipsum#1  quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&#xA;Duis aute irure dolor in reprehenderit https://en.wikipedia.org/wiki/Lorem_ipsum#2 in voluptate velit esse cillum https://en.wikipedia.org/wiki/Lorem_ipsum#3 dolore eu fugiat nulla pariatur.&#xA;Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;expectation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;https://en.wikipedia.org/wiki/Lorem_ipsum#1&#xA;https://en.wikipedia.org/wiki/Lorem_ipsum#2&#xA;https://en.wikipedia.org/wiki/Lorem_ipsum#3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="179" LastEditorUserId="24" LastEditDate="2015-02-20T04:48:03.857" LastActivityDate="2015-02-20T09:08:17.580" Title="How do I parse URL's from the text" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2015" PostTypeId="1" AcceptedAnswerId="2022" CreationDate="2015-02-20T00:06:50.513" Score="11" ViewCount="30965" Body="&lt;p&gt;I use gnu &lt;code&gt;screen&lt;/code&gt; and I run &lt;code&gt;vim file1.txt&lt;/code&gt; and &lt;code&gt;vim file2.txt&lt;/code&gt; in two windows.&lt;/p&gt;&#xA;&lt;p&gt;How can I copy part of the text from &lt;code&gt;file1.txt&lt;/code&gt; and paste it to &lt;code&gt;file2.txt&lt;/code&gt;&#xA;without using temporary files or opening two files under the same Vim instance?&lt;/p&gt;&#xA;&lt;p&gt;Basically I would like to yank in first window and paste in second one. I need shared clipboard.&lt;/p&gt;&#xA;" OwnerUserId="784" LastEditorUserId="23502" LastEditDate="2022-10-31T12:51:05.277" LastActivityDate="2023-11-06T11:28:15.057" Title="How do I copy and paste between two Vim instances - shared clipboard?" Tags="|command-line|cut-copy-paste|os-clipboard|" AnswerCount="6" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="2016" PostTypeId="2" ParentId="2006" CreationDate="2015-02-20T00:07:26.410" Score="0" Body="&lt;p&gt;This method works for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ca w' w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can set up your vim to save the current buffer when you hit Esc twice, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;Esc&amp;gt;&amp;lt;Esc&amp;gt; :w&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or use the following mapping to save file either by &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;s&lt;/kbd&gt; or &lt;kbd&gt;F2&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;c-s&amp;gt; :w&amp;lt;CR&amp;gt;&#xA;vmap &amp;lt;c-s&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;c-s&amp;gt;gv&#xA;imap &amp;lt;c-s&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;c-s&amp;gt;&#xA;&#xA;nmap &amp;lt;F2&amp;gt; :update&amp;lt;CR&amp;gt;&#xA;vmap &amp;lt;F2&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;F2&amp;gt;gv&#xA;imap &amp;lt;F2&amp;gt; &amp;lt;c-o&amp;gt;&amp;lt;F2&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: F2 only saves if necessary, and returns the user to insert mode (or restores their visual selection), as needed.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://vim.wikia.com/wiki/Saving_a_file&quot; rel=&quot;nofollow&quot;&gt;Saving a file&lt;/a&gt; at vim wikia&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or use the following alternatives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:up&lt;/code&gt; (&lt;code&gt;:update&lt;/code&gt;) for &lt;code&gt;:w&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;ZQ&lt;/kbd&gt; for &lt;code&gt;:q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;ZZ&lt;/kbd&gt; for &lt;code&gt;:wq&lt;/code&gt; or &lt;code&gt;:x&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-02-20T11:41:11.780" LastActivityDate="2015-02-20T11:41:11.780" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2017" PostTypeId="2" ParentId="2013" CreationDate="2015-02-20T00:11:01.647" Score="4" Body="&lt;p&gt;&lt;code&gt;zz&lt;/code&gt; is a normal mode command, so use &lt;code&gt;:normal&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim &quot;+normal zz&quot; file.txt +100&#xA;vim -c &quot;normal zz&quot; file.txt +100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="88" LastEditDate="2015-02-20T00:39:45.293" LastActivityDate="2015-02-20T00:39:45.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2018" PostTypeId="2" ParentId="2015" CreationDate="2015-02-20T00:20:14.457" Score="1" Body="&lt;p&gt;It really depends on your environment. Basically, we're talking about inter-process communications and this is very much OS specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;System clipboard&lt;/li&gt;&#xA;&lt;li&gt;Tmux or screen buffer&lt;/li&gt;&#xA;&lt;li&gt;tmp file&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="179" LastActivityDate="2015-02-20T00:20:14.457" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="2019" PostTypeId="2" ParentId="2010" CreationDate="2015-02-20T00:23:11.010" Score="10" Body="&lt;p&gt;There's two reasons why I think this may be happening:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The solarized color scheme you are using does not declare &lt;code&gt;ctermfg&lt;/code&gt; and &lt;code&gt;ctermbg&lt;/code&gt; for any of the features you want to highlight. Try out this &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1243&quot; rel=&quot;noreferrer&quot;&gt;color scheme&lt;/a&gt;, should look essentially the same both inside your terminal and gvim, if this is the case then you may need to look into using a color scheme that declares &lt;code&gt;ctermfg&lt;/code&gt; and &lt;code&gt;ctermbg&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You may need to make sure your terminal emulator supports the colors you are trying to display:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ensure that the file &lt;a href=&quot;http://packages.ubuntu.com/search?keywords=ncurses-term&amp;amp;searchon=names&amp;amp;suite=all&amp;amp;section=all&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;ncurses-term&lt;/code&gt; package&lt;/a&gt; (which provides the file &lt;code&gt;/usr/share/terminfo/x/xterm+256color&lt;/code&gt;) is installed.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/256_colors_in_vim&quot; rel=&quot;noreferrer&quot;&gt;Set the value of your &lt;code&gt;TERM&lt;/code&gt; environment variable&lt;/a&gt; by running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export TERM=xterm+256colors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;at the shell.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Then start &lt;code&gt;vim&lt;/code&gt; in that shell.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that both of this things could be happening at the same time, but it is hard to diagnose this without more information about your system.&lt;/p&gt;&#xA;" OwnerUserId="788" LastEditorUserId="24" LastEditDate="2015-02-20T04:42:14.270" LastActivityDate="2015-02-20T04:42:14.270" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2020" PostTypeId="2" ParentId="2013" CreationDate="2015-02-20T00:25:03.777" Score="5" Body="&lt;p&gt;Another option would be to run multiple commands in one line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim README.md +&quot;56;norm zz&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="179" LastActivityDate="2015-02-20T00:25:03.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2021" PostTypeId="2" ParentId="2014" CreationDate="2015-02-20T00:34:21.300" Score="8" Body="&lt;p&gt;The tricky part is getting a valid URL. Take some reasonable regex (say &lt;code&gt;/http[s]\?:\/\/[[:alnum:]%\/_#.-]*/&lt;/code&gt; - or if you want to be pedantic, &lt;a href=&quot;https://stackoverflow.com/questions/161738/what-is-the-best-regular-expression-to-check-if-a-string-is-a-valid-url&quot;&gt;this one&lt;/a&gt;). First get the URLs on individual lines, and then delete lines which aren't URLs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.\{-}\(http[s]\?:\/\/[[:alnum:]%\/_#.-]*\)/\1\r/g&#xA;:g!//d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The substitution uses a &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#non-greedy&quot; rel=&quot;nofollow noreferrer&quot;&gt;non-greedy&lt;/a&gt; regex to match characters before a URL. Otherwise, if multiple URLs were present in the same line, all but the last would be covered by &lt;code&gt;.*&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The second command specifies an empty regex, reusing the last regex used. The initial &lt;code&gt;.\{-}&lt;/code&gt; will match the empty string, so this regex can be reused without problems. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you have &lt;code&gt;grep&lt;/code&gt; with &lt;code&gt;-o&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!grep -o 'http[s]\?:\/\/[[:alnum:]\%\/_\#.-]*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;%&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; have to escaped to prevent vim from interpreting them.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-20T09:08:17.580" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2022" PostTypeId="2" ParentId="2015" CreationDate="2015-02-20T00:34:28.820" Score="11" Body="&lt;p&gt;One way is to just copy it to the system clipboard from the first instance, then copy it from the system clipboard in the second instance.  How exactly you would do this depends on your OS and also your vim &lt;code&gt;clipboard&lt;/code&gt; setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to use &lt;a href=&quot;https://github.com/svermeulen/vim-easyclip&quot; rel=&quot;noreferrer&quot;&gt;vim-easyclip&lt;/a&gt; which has the ability to share one clipboard across all vim instances (including sharing a history of yanks as well).  Internally what it does is mirror your clipboard to a temporary file, so it bypasses using your system clipboard entirely.&lt;/p&gt;&#xA;" OwnerUserId="132" LastEditorUserId="67" LastEditDate="2015-02-21T04:56:54.527" LastActivityDate="2015-02-21T04:56:54.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2024" PostTypeId="2" ParentId="598" CreationDate="2015-02-20T01:11:33.417" Score="5" Body="&lt;p&gt;There are few plugins for this but I prefer Tim Pope's &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1590&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-unimpaired&lt;/a&gt; (&lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;) (Ingo Karkat &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4140&quot; rel=&quot;nofollow noreferrer&quot;&gt;LineJuggler&lt;/a&gt; is similar).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You visually select your block of text then do &lt;code&gt;]e&lt;/code&gt; (e for exchange) to move the block downwards (&lt;code&gt;[e&lt;/code&gt; for the other direction). Use &lt;code&gt;.&lt;/code&gt; to repeat the action (You do have &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;repeat.vim&lt;/a&gt; installed don't you). If you go too far then just undo via &lt;code&gt;u&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now personally I think &lt;code&gt;p&lt;/code&gt; and &lt;code&gt;P&lt;/code&gt; are such common commands that it would be best to learn them before creating bad habits. Then you could use &lt;code&gt;]p&lt;/code&gt; to paste at the same indent. If you are using unimpaired you can do &lt;code&gt;&amp;gt;p&lt;/code&gt; to paste an indention level deeper or &lt;code&gt;=p&lt;/code&gt; to paste and reformat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have trouble remembering &lt;code&gt;p&lt;/code&gt; and &lt;code&gt;P&lt;/code&gt; then it might help you to think of them in terms of the &lt;code&gt;o&lt;/code&gt; and &lt;code&gt;O&lt;/code&gt; commands which is a kind of symmetry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As others have noted you can use &lt;code&gt;gv&lt;/code&gt; to reselect a visual selection. However if you just put/pasted text you will have lost your visual selection. Don't fret because every change (and yanks!) will set &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt; around the changed area. So you can indent via &lt;code&gt;&amp;gt;']&lt;/code&gt; (read: shift right until end of last change) and use the &lt;code&gt;.&lt;/code&gt; to repeat the indention until you have the text in the right spot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h p&#xA;:h P&#xA;:h ]p&#xA;:h o&#xA;:h O&#xA;:h .&#xA;:h u&#xA;:h &amp;gt;&#xA;:h ']&#xA;:h gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="1292" LastEditDate="2018-04-13T14:43:31.093" LastActivityDate="2018-04-13T14:43:31.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2025" PostTypeId="1" CreationDate="2015-02-20T02:49:49.953" Score="3" ViewCount="157" Body="&lt;p&gt;I would like to be able to save my ViEmu macros between sessions of Visual Studio 2013.  This feature was &lt;a href=&quot;http://www.viemu.com/forum/viewtopic.php?id=1248&quot; rel=&quot;nofollow&quot;&gt;requested&lt;/a&gt; in 2010 and apparently almost made the cut for ViEmu 2.5:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I was wondering if there is a way to set a macro in the .viemurc file,&#xA;  so I don't have to redo it every time I start up VS. I know that it&#xA;  can be done in regular Vim via:&lt;br&gt;&#xA;  &lt;code&gt;:let @s=&quot;0ftwwy$bp&quot;&lt;/code&gt;&lt;br&gt;&#xA;  This will set a&#xA;  macro on register 's' for example. Doing the same in .viemurc so far&#xA;  just got me an error message.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I was indeed planning to add this to ViEmu 2.5, but I've had to drop&#xA;  it or I would never finish it. I will add it in later. ViEmu 2.5 does&#xA;  have multiple-key mappings and a few other exciting features.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As of ViEmu 3.2.1, this feature still does not seem to be implemented.  I tried adding &lt;code&gt;:let&lt;/code&gt; statements to &lt;code&gt;_viemurc&lt;/code&gt; and simply got errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How might I work around this missing feature?  Never closing Visual Studio is not going to work forever.&lt;/p&gt;&#xA;" OwnerUserId="811" LastEditorUserId="88" LastEditDate="2015-02-20T03:45:34.403" LastActivityDate="2015-02-20T03:45:34.403" Title="How can I work around the inability to save macros in ViEmu?" Tags="|vimrc|macro|" AnswerCount="0" CommentCount="6" ClosedDate="2015-02-21T14:19:56.077" ContentLicense="CC BY-SA 3.0" />
  <row Id="2026" PostTypeId="2" ParentId="2001" CreationDate="2015-02-20T03:05:58.020" Score="24" Body="&lt;p&gt;&lt;code&gt;g;&lt;/code&gt; will go to the previously edited line.&lt;/p&gt;&#xA;" OwnerUserId="815" LastEditorUserId="205" LastEditDate="2015-02-20T03:17:58.250" LastActivityDate="2015-02-20T03:17:58.250" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2027" PostTypeId="2" ParentId="2001" CreationDate="2015-02-20T03:31:16.260" Score="30" Body="&lt;p&gt;To add to dnetserr's answer and Peter Rincker's comment, Vim maintains a list of changes, and has some commands associated with this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:changes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will list the changes, showing you where they were and what they were. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;change line  col text&#xA;    2     8   17 #include &amp;lt;stdio.h&amp;gt;&#xA;    1     3    0 #include &quot;stm32f407.auto.h&quot;&#xA;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The line with the &lt;code&gt;&amp;gt;&lt;/code&gt; shows where in the change stack you are, kind of like the jump list (&lt;code&gt;:jumps&lt;/code&gt;) or tag stack (&lt;code&gt;:tags&lt;/code&gt;). Also like the jump list and tag stack, you can traverse this list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal mode, the motions are &lt;code&gt;g;&lt;/code&gt; to go to a previous change location, and &lt;code&gt;g,&lt;/code&gt; to go to the next one. You can also type the number of the change prior to &lt;code&gt;g;&lt;/code&gt; or &lt;code&gt;g,&lt;/code&gt; to go to that change from the list. Above, &lt;code&gt;2g;&lt;/code&gt; would take me to where the change involving stdio.h occurred.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When in the middle of the stack, the numbers from &lt;code&gt;:changes&lt;/code&gt; updates to show the relative distances. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;change line  col text&#xA;    1     8   17 #include &amp;lt;stdio.h&amp;gt;&#xA;&amp;gt;   0     3    0 #include &quot;stm32f407.auto.h&quot;&#xA;    1    10    4 other&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This shows that I can go back one (&lt;code&gt;1g;&lt;/code&gt; or just &lt;code&gt;g;&lt;/code&gt;) or forward one (&lt;code&gt;1g,&lt;/code&gt; or just &lt;code&gt;g,&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is great if the change you want to get to actually occurred a few modifications ago&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The disadvantage of this is that it doesn't appear to act like a normal motion. For example, you cannot do &lt;code&gt;dg;&lt;/code&gt; to delete from the cursor to the previous change location, whereas &lt;code&gt;d'.&lt;/code&gt; and &lt;code&gt;d'^&lt;/code&gt; do work as motions.&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-02-20T03:31:16.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2028" PostTypeId="2" ParentId="1915" CreationDate="2015-02-20T04:54:16.033" Score="2" Body="&lt;p&gt;You can use the normal procedure of entering &lt;kbd&gt;d&lt;/kbd&gt; plus a motion (as already explained in the other answers). The EasyMotion plugin, provides new motions you can use that could solve your problem in a quick and easy way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you want to to delete from the current cursor position to the end of any given word on the screen, the motion keys would be &lt;kbd&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt; (akin to the normal &lt;code&gt;e&lt;/code&gt; motion). Then type the highlighted letter(s) that appear at the end of the word in question. There is also a line motion so you can delete the current line down to the line in question with &lt;kbd&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have my &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; key set to &lt;kbd&gt;,&lt;/kbd&gt;. So, the full command is &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;{highlighted letter(s)}.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help easymotion&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;EasyMotion provides a much simpler way to use some motions in vim. It takes&#xA;  the &lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt; out of &lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;w or &lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;f&lt;code&gt;{char}&lt;/code&gt; by highlighting all possible &#xA;  choices and allowing you to press one key to jump directly to the target.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When one of the available motions is triggered, all visible text preceding or&#xA;  following the cursor is faded, and motion targets are highlighted.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EasyMotion's &lt;a href=&quot;https://github.com/Lokaltog/vim-easymotion&quot; rel=&quot;nofollow&quot;&gt;github repository&lt;/a&gt; is at &lt;a href=&quot;https://github.com/Lokaltog/vim-easymotion&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Lokaltog/vim-easymotion&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;a href=&quot;http://www.reddit.com/r/vim/comments/1yfzg2/does_anyone_actually_use_easymotion/&quot; rel=&quot;nofollow&quot;&gt;reddit about people using easymotion&lt;/a&gt; might be a fun read.&lt;/p&gt;&#xA;" OwnerUserId="813" LastEditorUserId="813" LastEditDate="2015-02-20T17:44:47.033" LastActivityDate="2015-02-20T17:44:47.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2029" PostTypeId="2" ParentId="2010" CreationDate="2015-02-20T04:59:23.560" Score="0" Body="&lt;p&gt;This was a pain to get working (I use terminal Vim in Linux Mint), and unfortunately I didn't write down the specifics of everything I did. Here is the relevant section of my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax enable&#xA;set background=dark&#xA;set t_Co=16&#xA;colo solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It may also be worth checking out &lt;a href=&quot;https://github.com/Anthony25/gnome-terminal-colors-solarized&quot; rel=&quot;nofollow&quot;&gt;this project on GitHub&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="163" LastEditorUserId="24" LastEditDate="2015-02-20T05:06:57.380" LastActivityDate="2015-02-20T05:06:57.380" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2030" PostTypeId="2" ParentId="2010" CreationDate="2015-02-20T05:10:13.293" Score="4" Body="&lt;p&gt;I guess it is an issue of compatibility of this &lt;code&gt;colorscheme&lt;/code&gt; with terminal.&#xA;The plugin &lt;code&gt;csaprox&lt;/code&gt; miraculously solve a bunch of this issues. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Synopsis:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It's hard to find colorschemes for terminal Vim.  Most colorschemes are &#xA;  written to only support GVim, and don't work at all in terminal Vim. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This plugin makes GVim-only colorschemes Just Work in terminal Vim, as long &#xA;  as the terminal supports 88 or 256 colors - and most do these days.  This &#xA;  usually requires no user interaction (but see the help for what to do if &#xA;  things don't Just Work).  After getting this plugin happily installed, any &#xA;  time you use &lt;code&gt;:colorscheme&lt;/code&gt; it will do its magic and make the colorscheme Just &#xA;  Work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Links to the plugin:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2390&quot; rel=&quot;nofollow&quot;&gt;vim.org&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/godlygeek/csapprox&quot; rel=&quot;nofollow&quot;&gt;Github&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="819" LastEditorUserId="24" LastEditDate="2015-02-20T07:18:04.687" LastActivityDate="2015-02-20T07:18:04.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2031" PostTypeId="2" ParentId="2001" CreationDate="2015-02-20T05:20:01.910" Score="35" Body="&lt;p&gt;Here's another approach that fits your given scenario, and will jump to where you were immediately prior to the &lt;code&gt;gg&lt;/code&gt; (not to the last changed line).&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Use &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;O&lt;/kbd&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;When you press &lt;code&gt;gg&lt;/code&gt;, your old cursor position is pushed onto the &lt;strong&gt;jump list&lt;/strong&gt;. From &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#jumplist&quot;&gt;&lt;code&gt;:help jumplist&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Jumps are remembered in a jump list.  With the &lt;code&gt;CTRL-O&lt;/code&gt; and &lt;code&gt;CTRL-I&lt;/code&gt;&#xA;  command you can go to cursor positions before older jumps, and back&#xA;  again.  Thus you can move up and down the list.  There is a separate&#xA;  jump list for each window. The maximum number of entries is fixed at&#xA;  100.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[&amp;hellip;]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If you use a jump command, the current line number is inserted at the&#xA;  end of the jump list.  If the same line was already in the jump list,&#xA;  it is removed. The result is that when repeating &lt;code&gt;CTRL-O&lt;/code&gt; you will get&#xA;  back to old positions only once.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This requires that you be using Vim (not vi) with the &lt;code&gt;+jumplist&lt;/code&gt; feature.&#xA;If &lt;code&gt;:echo has('jumplist')&lt;/code&gt; prints &lt;code&gt;1&lt;/code&gt;, then you can use this.&lt;/p&gt;&#xA;" OwnerUserId="142" LastEditorUserId="142" LastEditDate="2015-02-20T23:38:12.107" LastActivityDate="2015-02-20T23:38:12.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2032" PostTypeId="1" AcceptedAnswerId="2034" CreationDate="2015-02-20T06:11:29.590" Score="5" ViewCount="1203" Body="&lt;p&gt;I have a file containing nothing but integers and words, separated by arbitrary numbers of spaces, along the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 alpha plural 1   0&#xA;6   1440&#xA;3 1 4 1 5 9 2 6 5 3 5 8 9&#xA;2 7 1 8 2 8 1 8 2 8 4 5 9&#xA;42   972 insert point here&#xA;16 7 88&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the software that a third party has written to &lt;em&gt;read&lt;/em&gt; that file requires that it be floating point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how can I add &lt;code&gt;.0&lt;/code&gt; to all the numbers, and leave the words and spacing intact?&lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastEditorUserId="23502" LastEditDate="2022-10-31T12:49:26.740" LastActivityDate="2022-10-31T12:49:26.740" Title="How to change all numbers in file into float format?" Tags="|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2033" PostTypeId="2" ParentId="2032" CreationDate="2015-02-20T06:11:29.590" Score="1" Body="&lt;p&gt;You can actually do this in two passes, one to handle numbers at the end of the line and one to handle numbers followed by a space:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\([0-9]\)$/s//\1.0/&#xA;:g/\([0-9]\) /s//\1.0 /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first simply finds a digit at the end of the line and replaces it with that digit and an additional &lt;code&gt;.0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It uses a capture group &lt;code&gt;()&lt;/code&gt; to actually &lt;em&gt;store&lt;/em&gt; the character that satisfied the search, and a reference &lt;code&gt;\1&lt;/code&gt; to use that stored character in the replacement text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second one is very similar but with the following changes.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It finds a digit followed by a space, rather than at the end of a line.&lt;/li&gt;&#xA;&lt;li&gt;It incorporates the space into the replacement string.&lt;/li&gt;&#xA;&lt;li&gt;It does it multiple times per line to change &lt;em&gt;all&lt;/em&gt; integers, not necessary in the first case since there is only &lt;em&gt;one&lt;/em&gt; end of line per line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The result of running those two commands is, as requested:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.0 alpha plural 1.0   0.0&#xA;6.0   1440.0&#xA;3.0 1.0 4.0 1.0 5.0 9.0 2.0 6.0 5.0 3.0 5.0 8.0 9.0&#xA;2.0 7.0 1.0 8.0 2.0 8.0 1.0 8.0 2.0 8.0 4.0 5.0 9.0&#xA;42.0   972.0 insert point here&#xA;16.0 7.0 88.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now be aware that you can actually do this with the &lt;code&gt;s&lt;/code&gt; command rather than &lt;code&gt;g&lt;/code&gt;, I prefer the latter since you don't have to specify lines and it allows you to carry out much more powerful actions (the &lt;code&gt;s&lt;/code&gt; part of the &lt;code&gt;g&lt;/code&gt; command can be replaced with other more powerful commands, rather than just substitute).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to use &lt;code&gt;g&lt;/code&gt; for some reason, you can do this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,$s/\([0-9]\)$/\1.0/&#xA;:1,$s/\([0-9]\) /\1.0 /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user579" LastActivityDate="2015-02-20T06:11:29.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2034" PostTypeId="2" ParentId="2032" CreationDate="2015-02-20T06:19:37.360" Score="6" Body="&lt;p&gt;I think the following substitution would be sufficient:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\&amp;lt;\d\+\&amp;gt;/&amp;amp;.0/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The effect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.0 alpha plural 1.0   0.0&#xA;6.0   1440.0&#xA;3.0 1.0 4.0 1.0 5.0 9.0 2.0 6.0 5.0 3.0 5.0 8.0 9.0&#xA;2.0 7.0 1.0 8.0 2.0 8.0 1.0 8.0 2.0 8.0 4.0 5.0 9.0&#xA;42.0   972.0 insert point here&#xA;16.0 7.0 88.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\d&lt;/code&gt; matches digits, &lt;code&gt;&amp;amp;&lt;/code&gt; is the text that matched the whole pattern.&lt;/li&gt;&#xA;&lt;li&gt;We use word boundaries (&lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt;) so that digits in the middle of a word are not affected.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-02-21T08:44:43.740" LastActivityDate="2015-02-21T08:44:43.740" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2035" PostTypeId="2" ParentId="2009" CreationDate="2015-02-20T06:21:43.503" Score="3" Body="&lt;p&gt;This is not a solution, but it is what I do in order to have easy access to &lt;code&gt;.vimrc&lt;/code&gt; and &lt;code&gt;.zshrc&lt;/code&gt;. Personally I think this is pretty neat:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;ev :e ~/.vim/vimrc&amp;lt;cr&amp;gt;&#xA;map &amp;lt;leader&amp;gt;ez :e ~/.zshrc&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-02-20T06:21:43.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2036" PostTypeId="1" AcceptedAnswerId="2041" CreationDate="2015-02-20T08:33:19.407" Score="39" ViewCount="47738" Body="&lt;p&gt;I have a list of items where I want to replace the first two characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a) item 1&#xA;b) item 2&#xA;c) item 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the fastest way to make this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* item 1&#xA;* item 2&#xA;* item 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have an approach with visual mode (Ctr-v, jjj, but need to do two replace commands. Iirc, this replacement can be done with 1 command)&lt;/p&gt;&#xA;" OwnerUserId="833" LastActivityDate="2018-04-16T20:31:26.177" Title="How to block replace code in visual mode?" Tags="|visual-mode|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2037" PostTypeId="5" CreationDate="2015-02-20T08:50:22.930" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-20T08:50:22.930" LastActivityDate="2015-02-20T08:50:22.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2038" PostTypeId="4" CreationDate="2015-02-20T08:50:22.930" Score="0" Body="questions regarding finding and opening (loading) files" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-02-20T15:57:30.767" LastActivityDate="2015-02-20T15:57:30.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2039" PostTypeId="5" CreationDate="2015-02-20T08:59:38.530" Score="0" Body="&lt;p&gt;Related Vim features include:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Acd&quot; rel=&quot;nofollow noreferrer&quot;&gt;:cd&lt;/a&gt;: changing or displaying the current working directory.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Afind&quot; rel=&quot;nofollow noreferrer&quot;&gt;:find&lt;/a&gt;: searching sections of the filesystem for files matching a pattern.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/tagsrch.txt.html#tags&quot; rel=&quot;nofollow noreferrer&quot;&gt;tags&lt;/a&gt;: identifiers or labels that can be used to jump between files.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vi.stackexchange.com/questions/16/can-i-use-some-file-tree-selector-which-exists-on-graphical-ides&quot;&gt;Can I use some file-tree selector which exists on graphical IDEs?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="25" LastEditDate="2021-09-17T20:47:54.177" LastActivityDate="2021-09-17T20:47:54.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2040" PostTypeId="4" CreationDate="2015-02-20T08:59:38.530" Score="0" Body="For questions regarding searching and navigating the filesystem." OwnerUserId="205" LastEditorUserId="25" LastEditDate="2021-09-17T20:47:54.177" LastActivityDate="2021-09-17T20:47:54.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2041" PostTypeId="2" ParentId="2036" CreationDate="2015-02-20T09:11:32.100" Score="44" Body="&lt;p&gt;&lt;strong&gt;Visual-block selection:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;&#xA;jjl&#xA;c*&#xA;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;code&gt;:normal&lt;/code&gt;:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:,+2norm! cE*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Substitution:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:,+2s/^.\{2}/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Dot formula:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cE*&amp;lt;Esc&amp;gt;&#xA;j.&#xA;j.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="11054" LastEditDate="2018-02-27T05:48:33.920" LastActivityDate="2018-02-27T05:48:33.920" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2042" PostTypeId="2" ParentId="2001" CreationDate="2015-02-20T09:38:12.303" Score="6" Body="&lt;p&gt;Since the undo command in Vi will act as a re-do when the last command was undo, I have used &lt;code&gt;uu&lt;/code&gt; as a means to go back to where I last edited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're running Vim with &lt;code&gt;nocompatible&lt;/code&gt; set (as most people do), you want to use &lt;code&gt;u&lt;/code&gt; followed by &lt;code&gt;CTRL+R&lt;/code&gt; to undo &amp;amp; redo. Otherwise &lt;code&gt;uu&lt;/code&gt; will work as in Vi.&lt;/p&gt;&#xA;" OwnerUserId="843" LastEditorUserId="51" LastEditDate="2015-02-27T01:17:06.020" LastActivityDate="2015-02-27T01:17:06.020" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2043" PostTypeId="2" ParentId="598" CreationDate="2015-02-20T09:56:57.217" Score="3" Body="&lt;p&gt;If you know the line number that you want to move the block of text to, then you can use a range or visual selection with the &lt;code&gt;:move&lt;/code&gt; command to move the block to there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I have the following file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 aaa&#xA;2 bbb&#xA;3 ccc&#xA;4 ddd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to move the line of a's to after the line of c's, I put the cursor on the line of a's and enter &lt;code&gt;:m3&lt;/code&gt;, and the line is then shifted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also works with +/- offsets. In the example above, the same result could be accomplished with &lt;code&gt;:m+2&lt;/code&gt; to move the line 2 lines down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For blocks of text, the only difference is adding in a range or selection. To move the aaa and bbb lines to the end of the file, use a command like &lt;code&gt;:1,2m$&lt;/code&gt; ($ = last line) or visually select the lines and &lt;code&gt;:m$&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="842" LastEditorUserId="842" LastEditDate="2015-02-20T10:05:29.397" LastActivityDate="2015-02-20T10:05:29.397" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2044" PostTypeId="1" AcceptedAnswerId="2045" CreationDate="2015-02-20T10:28:03.347" Score="15" ViewCount="9978" Body="&lt;p&gt;Sometimes I'm on a system without Vim, and use the default &lt;code&gt;nvi&lt;/code&gt; (BSD systems)&#xA;or the original &lt;code&gt;vi&lt;/code&gt; (Arch Linux).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are quite a few differences, but the largest annoyance is that I can undo&#xA;&lt;em&gt;only&lt;/em&gt; my last operation. Pressing &lt;kbd&gt;u&lt;/kbd&gt; the second time works are a&#xA;&quot;redo&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to get this working?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-22T17:55:42.613" LastActivityDate="2016-12-26T15:10:21.870" Title="Can I undo multiple times in nvi and/or the original vi?" Tags="|undo-redo|nvi|original-vi|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2045" PostTypeId="2" ParentId="2044" CreationDate="2015-02-20T10:28:03.347" Score="19" Body="&lt;p&gt;From &lt;a href=&quot;http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/ex.1?query=vi&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;nvi(1)&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; u       Undo the last change made to the file.  If repeated, the u command&#xA;         alternates between these two states.  The . command, when used&#xA;         immediately after u, causes the change log to be rolled forward or&#xA;         backward, depending on the action of the u command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So press &lt;kbd&gt;u&lt;/kbd&gt;, and then keep pressing &lt;kbd&gt;.&lt;/kbd&gt; for more undo; If you press &lt;kbd&gt;u&lt;/kbd&gt; again, it will 'reverse' direction and pressing &lt;kbd&gt;.&lt;/kbd&gt; will be a redo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I never knew about this until yesterday; and thought it was somehow a new feature, but it seems&#xA;like it has &lt;a href=&quot;https://github.com/freebsd/freebsd/blob/59cc89c2c2e686da3bdab2d5cfac4f33462d29fe/contrib/nvi/docs/help&quot; rel=&quot;noreferrer&quot;&gt;worked like this since at least nvi 1.79 from 1996&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;em&gt;doesn't&lt;/em&gt; work in the &lt;a href=&quot;http://ex-vi.cvs.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;original vi&lt;/strong&gt;&lt;/a&gt;;&#xA;where the undo is documented as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   u      Undoes the last change made to the current buffer.  If repeated,&#xA;          will alternate  between  these  two  states,  thus  is  its  own&#xA;          inverse.  When  used after an insert which inserted text on more&#xA;          than one line, the lines are saved in the numeric named  buffers&#xA;          (3.5).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is really a complicated way of saying that pressing &lt;kbd&gt;u&lt;/kbd&gt; again&#xA;will redo your changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which is also what Vim's &lt;code&gt;:help undo&lt;/code&gt; says (and why I assumed it also wouldn't&#xA;work in &lt;code&gt;nvi&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; u                       Undo [count] changes.  {Vi: only one level}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-22T17:56:33.313" LastActivityDate="2015-02-22T17:56:33.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2046" PostTypeId="1" CreationDate="2015-02-20T10:29:56.047" Score="69" ViewCount="51224" Body="&lt;p&gt;Instead of &lt;code&gt;gdbtui&lt;/code&gt; or &lt;code&gt;ctrl+x&lt;/code&gt; under &lt;code&gt;gdb&lt;/code&gt; which shows source code on top of the screen I would like to see this in my Vim editor that would jump between tabs, and buffers accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="784" LastEditorUserId="24" LastEditDate="2015-02-21T08:29:36.337" LastActivityDate="2024-02-05T18:02:44.403" Title="How can I integrate gdb with Vim?" Tags="|external-command|ide|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2047" PostTypeId="1" CreationDate="2015-02-20T10:47:50.040" Score="55" ViewCount="19522" Body="&lt;p&gt;There are a number of Tex plugins for vim (&lt;a href=&quot;http://vim-latex.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;vim-latex&lt;/a&gt;, &lt;a href=&quot;http://atp-vim.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;AutomaticLatexPlugin&lt;/a&gt; to say a couple).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the differences in the provided functionalities between these (the ones I named and possibly others) TeX plugins?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is a couple of related questions on SO:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/3723493/4063051&quot;&gt;Latex and Vim usage&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/541848/4063051&quot;&gt;What are the necessary plugins in VIM for Latex?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="602" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-12-07T07:14:15.680" Title="What are the differences between LaTeX plugins?" Tags="|filetype-tex|plugin-vim-latex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2048" PostTypeId="2" ParentId="2046" CreationDate="2015-02-20T10:48:19.390" Score="12" Body="&lt;p&gt;You have several plugins that integrates gdb.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We used to have &lt;a href=&quot;http://pyclewn.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;pyclewn&lt;/a&gt;. The &lt;a href=&quot;https://bitbucket.org/xdegaye/etc-merge/issues/1/looking-for-pyclewn#comment-42145498&quot; rel=&quot;noreferrer&quot;&gt;project has been discontinued&lt;/a&gt; after version 2.3. The last commit has been made in 2016. For the curious ones there is still a &lt;a href=&quot;https://github.com/xdegaye/pyclewn&quot; rel=&quot;noreferrer&quot;&gt;mirror on github&lt;/a&gt; where its author has archived his work. Note: pyclewn used to be the last stage step in the evolution of the other Xavier Degaye's *clewn projects.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/idanarye/vim-vebugger&quot; rel=&quot;noreferrer&quot;&gt;vim-debugger&lt;/a&gt;, that integrates several other debuggers&lt;/li&gt;&#xA;&lt;li&gt;notEvil's &lt;a href=&quot;https://github.com/notEvil/vim-debug&quot; rel=&quot;noreferrer&quot;&gt;vim-debug&lt;/a&gt;, which acts as as &lt;em&gt;&quot;convenience layer for pyclewn to overcome some drawbacks&quot;&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And there is also a plugin that integrates lldb (from LLVM project)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/gilligan/vim-lldb&quot; rel=&quot;noreferrer&quot;&gt;vim-lldb&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It seems that Bram is currently (september 2017) working on the integration of gdb from within vim thanks to the new &lt;code&gt;:terminal&lt;/code&gt; feature. To use it, we need to load &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;termdebug&lt;/code&gt; packet&lt;/a&gt; (with &lt;code&gt;:packadd termdebug&lt;/code&gt;), then we'll be able to start a gdb console in a vim window with &lt;code&gt;:TermDebug (+options)&lt;/code&gt;. IMO, we can consider it to be the future of GDB integration under Vim.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-07-04T13:56:00.363" LastActivityDate="2018-07-04T13:56:00.363" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="2049" PostTypeId="2" ParentId="735" CreationDate="2015-02-20T11:05:05.960" Score="0" Body="&lt;p&gt;These commands also works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:windo :q&lt;/code&gt; - executes &lt;code&gt;:q&lt;/code&gt; in each window&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:bufdo :q&lt;/code&gt; - executes &lt;code&gt;:q&lt;/code&gt; in each buffer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/510325/how-do-i-close-all-open-tabs-in-vim-at-once&quot;&gt;How do I close all open tabs at once?&lt;/a&gt; at stackoverflow&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-02-20T11:33:38.413" LastActivityDate="2015-02-20T11:33:38.413" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2050" PostTypeId="2" ParentId="730" CreationDate="2015-02-20T11:14:00.277" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow&quot;&gt;Unimpaired.vim&lt;/a&gt; solves this problem in the most efficient way I've seen. It provides some mappings to enter Insert mode with &lt;code&gt;'paste'&lt;/code&gt; enabled, then automatically disables it when you return to Normal mode. &lt;code&gt;yo&lt;/code&gt; opens a new line below the cursor; &lt;code&gt;yO&lt;/code&gt; above. (Just like &lt;code&gt;o&lt;/code&gt; and &lt;code&gt;O&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin also provides a suite of other useful mappings for navigating lists, changing common settings, and some nifty text conversions. The mappings are exemplary: they feel native to Vim without stepping on existing functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only provide the details in the previous paragraph because many would be reluctant to install a plugin to solve the problem at hand. However, I think they'd be happy with the other (unrelated) things Unimpaired.vim has to offer.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-02-20T11:14:00.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2051" PostTypeId="1" AcceptedAnswerId="2053" CreationDate="2015-02-20T11:50:15.147" Score="6" ViewCount="1182" Body="&lt;p&gt;When running &lt;code&gt;gvim&lt;/code&gt; by double clicking with a file in a graphical file manager, like nautilus, the vim instance is called with a strange current directory (seems root sometime, but I am not sure). This has the effect that file name completion (&lt;code&gt;C-x C-f&lt;/code&gt;) is, well, not so useful. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a map that solve this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;F3&amp;gt; :lchdir %:p:h &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so that I can hit &lt;code&gt;F3&lt;/code&gt; and I am done. I was trying to make it happens automatically whenever I start editing, so I tried: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileReadPost *.tex :lchdir %:p:h &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and with &lt;code&gt;BufReadPost&lt;/code&gt; too, but it doesn't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Notice&lt;/em&gt;: Although &lt;code&gt;set autochdir&lt;/code&gt; is working, it is doing this globally; in the help there is a scary notice: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: When this option is on some plugins may not work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So it would be nice to be able to select for which buffers I want to do it, and not setting it globally.&lt;/p&gt;&#xA;" OwnerUserId="854" LastEditorUserId="24" LastEditDate="2015-02-21T08:24:44.703" LastActivityDate="2015-02-21T08:24:44.703" Title="Switching to the local directory after loading a file?" Tags="|autocmd|invocation|gvim|working-directory|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2052" PostTypeId="2" ParentId="2051" CreationDate="2015-02-20T12:01:36.320" Score="4" Body="&lt;p&gt;Try the autodir setting in vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autochdir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="826" LastActivityDate="2015-02-20T12:01:36.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2053" PostTypeId="2" ParentId="2051" CreationDate="2015-02-20T12:16:24.453" Score="5" Body="&lt;p&gt;I just installed nautilus, and it seems the current working directory is always set to the directory nautilus was started from (ie. Vim inherits nautilus' working directory).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a problem in nautilus (IMHO), and not Vim. When nautilus starts a new process (Vim) it can set the working directory, but doesn't. If I check &lt;code&gt;/proc/22656/cwd&lt;/code&gt; it's set to &lt;code&gt;/home/martin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have space-fm installed, and if I open the same file in that, &lt;code&gt;/proc/22803/cwd&lt;/code&gt; is set to &lt;code&gt;/home/martin/code&lt;/code&gt; (where I would expect it to be).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So, now we know what the problem is, let's look at your autocmd:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileReadPost * :lchdir %:p:h &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;FileReadPost&lt;/code&gt; does something different from what you expect, from &lt;code&gt;:help FileReadPost&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;After reading a file with a &quot;:read&quot; command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But that's not what we're doing; when you open a file Vim doesn't use &lt;code&gt;:read&lt;/code&gt;. What you want to use instead, is &lt;code&gt;BufReadPost&lt;/code&gt;, from &lt;code&gt;:help BufReadPost&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When starting to edit a new buffer&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In Vi &amp;amp; Vim, when you think &quot;file&quot;, or &lt;em&gt;usually&lt;/em&gt; (though not always) want to think &quot;buffer&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this is what you want to use. You also don't need the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; here; that's just for key mappings (not autocmd)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a working solution would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost * :lchdir %:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But wait, there's more!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has the &lt;code&gt;autochdir&lt;/code&gt; option which does the same thing! From &lt;code&gt;:help autochdir&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When on, Vim will change the current working directory whenever you&#xA;          open a file, switch buffers, delete a buffer or open/close a window.&#xA;          It will change to the directory containing the file which was opened&#xA;          or selected.&lt;br&gt;&#xA;          Note: When this option is on some plugins may not work. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The note about plugins not working also applies to the autocmd.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-20T12:16:24.453" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2054" PostTypeId="2" ParentId="2051" CreationDate="2015-02-20T12:17:12.777" Score="2" Body="&lt;p&gt;I think the &lt;code&gt;ReadPost&lt;/code&gt; events aren't applicable since the documentation describes them as related to the &lt;code&gt;:read&lt;/code&gt; command. You could try the &lt;code&gt;Enter&lt;/code&gt; events, either &lt;code&gt;BufEnter&lt;/code&gt; or &lt;code&gt;BufWinEnter&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWinEnter *.tex  lchdir %:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-02-20T12:17:12.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2055" PostTypeId="2" ParentId="2036" CreationDate="2015-02-20T12:20:19.193" Score="26" Body="&lt;p&gt;Here is more efficient way of doing this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Having cursor on the first item and 1st letter (&lt;kbd&gt;0&lt;/kbd&gt;), enter 'blockwise' visual mode &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; and select the 1st column of your current paragraph by &lt;kbd&gt;}&lt;/kbd&gt; (if your list is finished by new line), otherwise use different methods like &lt;em&gt;arrow keys&lt;/em&gt; (to move around the selection), or pattern search &lt;kbd&gt;/c)&lt;/kbd&gt; where &lt;code&gt;c&lt;/code&gt; is your last element).&lt;/li&gt;&#xA;&lt;li&gt;Move to the last symbol of your list by &lt;kbd&gt;k&lt;/kbd&gt; and &lt;kbd&gt;l&lt;/kbd&gt; (or using &lt;em&gt;arrow keys&lt;/em&gt;), so two columns are selected which you want to change.&lt;/li&gt;&#xA;&lt;li&gt;Change the selected text by pressing &lt;kbd&gt;c&lt;/kbd&gt; and type your bullet symbol (&lt;code&gt;*&lt;/code&gt;) and finish by hitting &lt;kbd&gt;Esc&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Works more efficiently especially in the longer lists.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2018-04-16T20:31:26.177" LastActivityDate="2018-04-16T20:31:26.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2056" PostTypeId="2" ParentId="2015" CreationDate="2015-02-20T12:57:45.137" Score="-1" Body="&lt;p&gt;In ideal situation it would be great if you could open two files under one instance:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim file1.txt file2.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If not possible, then you can still do it if the files are accessible on the same host, by opening 1st  file and:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Copy text in &lt;code&gt;file1.txt&lt;/code&gt; (e.g. enter visual mode &lt;kbd&gt;V&lt;/kbd&gt;, select the text, and yank/copy them by &lt;kbd&gt;y&lt;/kbd&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Open 2nd file by &lt;code&gt;:Sex&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sup&gt;You may also use: &lt;code&gt;:e file2.txt&lt;/code&gt;, then if you need to use full path, go to 2nd instance and check by &lt;kbd&gt;1&lt;/kbd&gt;,&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;g&lt;/kbd&gt;.&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Paste your text (e.g. &lt;kbd&gt;p&lt;/kbd&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;sup&gt;Above steps can be done opposite, by opening &lt;code&gt;file2.txt&lt;/code&gt;, then &lt;code&gt;file1.txt&lt;/code&gt; to copy the text, back to the original file and paste it there.&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or simply use &lt;code&gt;screen&lt;/code&gt; buffer to copy and paste between screen windows (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt;,&lt;kbd&gt;[&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt;,&lt;kbd&gt;]&lt;/kbd&gt;).&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-02-20T13:02:49.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2057" PostTypeId="2" ParentId="1915" CreationDate="2015-02-20T13:00:18.027" Score="1" Body="&lt;p&gt;There is a simple solution that can solve your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Place your cursor at the begining of the text block you want to remove, and do &lt;code&gt;d50gg&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will delete all the lines from your current position to the 50th line of your text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.q: if your cursor is at line &lt;strong&gt;46&lt;/strong&gt;, &lt;code&gt;d50gg&lt;/code&gt; will delete &lt;strong&gt;4&lt;/strong&gt; lines.&lt;/p&gt;&#xA;" OwnerUserId="861" LastActivityDate="2015-02-20T13:00:18.027" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2058" PostTypeId="2" ParentId="2010" CreationDate="2015-02-20T14:11:17.583" Score="1" Body="&lt;p&gt;So this is what works for me (on all terminals I used to use – xterm, konsole, gnome-terminal, iterm2, roxterm – on both Linux and OS X, also with gvim and macvim):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; no other configuration than this needed for solarized&#xA;colorscheme solarized&#xA;highlight SpecialKey ctermfg=11 ctermbg=8&#xA;&#xA;if &amp;amp;term =~ '256color'&#xA;  &quot; Disable Background Color Erase (BCE) so that color schemes work&#xA;  &quot; properly within 256-color terminals&#xA;  set t_ut=&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="869" LastActivityDate="2015-02-20T14:11:17.583" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2059" PostTypeId="2" ParentId="358" CreationDate="2015-02-20T14:57:25.827" Score="30" Body="&lt;p&gt;The other answers have already answered your question, but for the sake of completeness:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just want to &lt;em&gt;temporarily&lt;/em&gt; get a larger window for your help-viewing, you can use either or both of the &lt;code&gt;Ctrl-w _&lt;/code&gt; and &lt;code&gt;Ctrl-w |&lt;/code&gt; mappings to maximise the help window as much as possible vertically or horizontally, respectively, but &lt;em&gt;without closing your existing split windows.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you subsequently close the help window with &lt;code&gt;Ctrl-w c&lt;/code&gt; or &lt;code&gt;:q&lt;/code&gt;, your window layout will be returned to exactly how it was before you opened the help window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is useful if you have a slightly more complicated window layout which you would like to preserve.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2015-02-20T14:57:25.827" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2060" PostTypeId="2" ParentId="2046" CreationDate="2015-02-20T15:26:03.107" Score="39" Body="&lt;p&gt;Among all the plugins I have tried, I found &lt;a href=&quot;https://github.com/vim-scripts/Conque-GDB&quot; rel=&quot;noreferrer&quot;&gt;ConqueGDB&lt;/a&gt; to be the best approach. ConqueGDB uses &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2771&quot; rel=&quot;noreferrer&quot;&gt;Conque Shell&lt;/a&gt; to embed an interactive shell inside vim, that is used by GDB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The workflow with ConqueGDB consists not entering GDB commands on the GDB terminal, you use shortcuts on the vim source code. But you can continue using the GDB prompt if you want, for more advanced commands, or scroll to see the whole debug session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some ConqueGDB default mappings, for example: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt; : run &lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt; : continue&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt; : step&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; : print variable under cursor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Notice how the vim cursor line has been used to issue a GDB 'print row', the current execution of code is in another line (14) and there's a breakpoint on line 10. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/83EXU.png&quot; alt=&quot;vim with CongueGDB&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To install with Vundle for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'vim-scripts/Conque-GDB'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use these plugin options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ConqueTerm_Color = 2         &quot; 1: strip color after 200 lines, 2: always with color&#xA;let g:ConqueTerm_CloseOnEnd = 1    &quot; close conque when program ends running&#xA;let g:ConqueTerm_StartMessages = 0 &quot; display warning messages if conqueTerm is configured incorrectly  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="874" LastEditorUserId="205" LastEditDate="2015-02-20T20:31:27.247" LastActivityDate="2015-02-20T20:31:27.247" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2061" PostTypeId="2" ParentId="438" CreationDate="2015-02-20T15:30:37.300" Score="11" Body="&lt;p&gt;Help for &lt;strong&gt;Ex commands&lt;/strong&gt; is always listed with the colon included:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help :display&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Help for &lt;strong&gt;settings&lt;/strong&gt; is always listed with surrounding quotes, &lt;a href=&quot;https://vi.stackexchange.com/a/441/343&quot;&gt;as Carpetsmoker already described&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help 'display'&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Specific help files&lt;/strong&gt; are listed by their file name:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help undo.txt&lt;/code&gt; (cf. &lt;code&gt;:help undo&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Help for &lt;strong&gt;built-in functions&lt;/strong&gt; is listed with trailing parentheses:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help split()&lt;/code&gt; (cf. &lt;code&gt;:help split&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Documentation for Vim's &lt;strong&gt;command arguments&lt;/strong&gt; (i.e. those passed when invoking Vim from the shell) is listed with preceding hyphens:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help -r&lt;/code&gt; (cf. &lt;code&gt;:help r&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Help for subtopics within the documentation for various Vim features usually has an appropriate hyphenated prefix:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help hl-Menu&lt;/code&gt; (cf. &lt;code&gt;:help Menu&lt;/code&gt;)&lt;br /&gt;&#xA;&lt;code&gt;:help syn-on&lt;/code&gt; (cf. &lt;code&gt;:help on&lt;/code&gt;)&lt;br /&gt;&#xA;&lt;code&gt;:help help-writing&lt;/code&gt; (cf. &lt;code&gt;:help writing&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Similarly, help topics within &lt;strong&gt;plugins&lt;/strong&gt; generally use the plugin's name as a prefix:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help surround-mappings&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Finally, something I didn't realise until I'd been using Vim for a while* is that the help includes topics for the default mappings in all modes.&lt;/p&gt;&#xA;&lt;p&gt;For example, &lt;code&gt;Ctrl-v&lt;/code&gt; does something very different in Normal mode to what it does in Insert mode.&lt;/p&gt;&#xA;&lt;p&gt;To get to the different topics, use the &lt;code&gt;i_&lt;/code&gt;, &lt;code&gt;c_&lt;/code&gt;, and &lt;code&gt;v_&lt;/code&gt; prefixes for &lt;strong&gt;Insert, Command, and Visual mode mappings&lt;/strong&gt;, respectively, or no prefix for the &lt;strong&gt;Normal mode mapping&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help ctrl-v&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help i_ctrl-v&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help c_ctrl-v&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help v_ctrl-v&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;*&lt;sub&gt; ...despite the fact that it's virtually the first thing you'll read if you type a plain &lt;code&gt;:help&lt;/code&gt; with no arguments! See &amp;quot;Get specific help&amp;quot; a few paragraphs down. (&lt;code&gt;:help help-context&lt;/code&gt;)&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2022-07-27T10:00:09.437" LastActivityDate="2022-07-27T10:00:09.437" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2062" PostTypeId="2" ParentId="1977" CreationDate="2015-02-20T15:35:46.453" Score="21" Body="&lt;p&gt;Exuberant ctags is the simplest way to achieve this. &#xA;Under GNU/Linux (e.g. Ubuntu or Debian) you should be able to just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install exuberant-ctags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(For OSX &quot;$ brew install ctags&quot; should suffice; for Windows you might want to visit &lt;a href=&quot;http://ctags.sourceforge.net/&quot;&gt;http://ctags.sourceforge.net/&lt;/a&gt; and download the standalone executable)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then navigate to your project's root folder and run &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctags -R --exclude=.git .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will scan your entire project and create a ./tags file which vim will automatically use to provide you with the ability to jump to functions at the press of a key. Namely:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ctrl + ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with your cursor placed on the function you want to see the implementation for.&#xA;There are other combinations and many command mode functions that let you navigate through your code by ctags as well (e.g. &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;t&lt;/kbd&gt; to jump to older tag stack entry). See &lt;code&gt;:help 29.1&lt;/code&gt; for an overview.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; that you have to re-run ctags for each significant change in the code and let it re-index your project. You can either do that manually, or teach vim to do it on hotkey or on write. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Hint:&lt;/em&gt; if you make extensive use of ctags, maybe the vim-taglist (&lt;a href=&quot;http://vim-taglist.sourceforge.net&quot;&gt;http://vim-taglist.sourceforge.net&lt;/a&gt;) plugin is worth a look as well. It gives you an IDE-style outline with a list of all functions for that class/file.&lt;/p&gt;&#xA;" OwnerUserId="875" LastEditorUserId="467" LastEditDate="2015-02-20T15:44:00.790" LastActivityDate="2015-02-20T15:44:00.790" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2063" PostTypeId="1" AcceptedAnswerId="2065" CreationDate="2015-02-20T16:22:10.797" Score="21" ViewCount="7533" Body="&lt;p&gt;It seems to me that neither &lt;code&gt;&quot;+p&lt;/code&gt; nor &lt;code&gt;&quot;*p&lt;/code&gt; works for me. How can I know if my Vim is installed and set up properly to make them available? And if it's not set up, what can I do to set it up?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running Fedora 20 with Mate 18.1. I've installed the &lt;code&gt;vim-enhanced&lt;/code&gt; and &lt;code&gt;vim-x11&lt;/code&gt; packages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And my Vim version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 13 2014 08:56:57)&#xA;Included patches: 1-207, 209-475&#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;-clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   +perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python/dyn      +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      +lua/dyn         +rightleft       +windows&#xA;+diff            +menu            +ruby/dyn        +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            +mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;   system vimrc file: &quot;/etc/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/etc&quot;&#xA; f-b for $VIMRUNTIME: &quot;/usr/share/vim/vim74&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -L. -Wl,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags  -Wl,-z,relro  -L/usr/local/lib -Wl,--as-needed -o vim        -lm -lnsl  -lselinux  -lncurses -lacl -lattr -lgpm -ldl   -Wl,--enable-new-dtags  -fstack-protector  -L/usr/lib64/perl5/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc       &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="82" LastEditorUserId="51" LastEditDate="2015-02-22T17:27:50.540" LastActivityDate="2015-02-22T17:27:50.540" Title="How do I get +clipboard support in Fedora 20?" Tags="|os-clipboard|x11|linux|installing|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2064" PostTypeId="2" ParentId="2003" CreationDate="2015-02-20T17:23:36.360" Score="41" Body="&lt;p&gt;There is &lt;code&gt;-D&lt;/code&gt; Vim parameter specially for debugging which will go to debugging mode after executing the first command from a script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. to run Vim in debug mode without any plugins, run as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --noplugin -D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Type &lt;code&gt;n&lt;/code&gt;/&lt;code&gt;next&lt;/code&gt; to parse the next line and keep pressing &lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;cont&lt;/code&gt; or &lt;code&gt;q&lt;/code&gt; to go back to &lt;code&gt;vim&lt;/code&gt; interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using a GUI version, put a &lt;code&gt;gui&lt;/code&gt; command in your vimrc to start the debugging right after that command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;d&lt;/kbd&gt; for list of available commands&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read more:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Debug_unexpected_option_settings&quot;&gt;Debug unexpected option settings&lt;/a&gt; at Vim tips wiki&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#debug-scripts&quot;&gt;&lt;code&gt;:help debug-scripts&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="51" LastEditDate="2015-02-20T22:32:31.100" LastActivityDate="2015-02-20T22:32:31.100" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2065" PostTypeId="2" ParentId="2063" CreationDate="2015-02-20T17:57:56.920" Score="32" Body="&lt;p&gt;So, installing &lt;code&gt;vim-enhanced&lt;/code&gt; and &lt;code&gt;vim-X11&lt;/code&gt; is enough, but is not at the same time. To enable the system funtcions like &lt;code&gt;+clipboard&lt;/code&gt;, &lt;strong&gt;you moreover need to use the &lt;code&gt;vimx&lt;/code&gt; executable rather than &lt;code&gt;vim&lt;/code&gt; or &lt;code&gt;vi&lt;/code&gt;&lt;/strong&gt; (even though they are probably identical, the name changes the behaviour).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way how to do that permanently is by adding aliases in your &lt;code&gt;.bashrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vi='vimx'&#xA;alias vim='vimx'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The complete list of features that get enabled this way is:&#xA;&lt;code&gt;+balloon_eval&lt;/code&gt;,&#xA;&lt;code&gt;+browse&lt;/code&gt;,&#xA;&lt;code&gt;+clientserver&lt;/code&gt;,&#xA;&lt;code&gt;+clipboard&lt;/code&gt;,&#xA;&lt;code&gt;+dnd&lt;/code&gt;,&#xA;&lt;code&gt;+mouseshape&lt;/code&gt;,&#xA;&lt;code&gt;+toolbar&lt;/code&gt;,&#xA;&lt;code&gt;+X11&lt;/code&gt;,&#xA;&lt;code&gt;+xim&lt;/code&gt;,&#xA;&lt;code&gt;+xsmp_interact&lt;/code&gt;,&#xA;&lt;code&gt;+xterm_clipboard&lt;/code&gt;,&#xA;&lt;code&gt;+xpm&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, some of them are probably irrelevant for the terminal version of &lt;code&gt;vimx&lt;/code&gt; and only do something for GVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;Information on how to use the &lt;code&gt;+clipboard&lt;/code&gt; feature is in &lt;a href=&quot;https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim&quot;&gt;How can I copy text to the system clipboard from Vim?&lt;/a&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="82" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-20T17:57:56.920" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2066" PostTypeId="1" AcceptedAnswerId="2081" CreationDate="2015-02-20T18:10:37.330" Score="5" ViewCount="277" Body="&lt;p&gt;This question is a follow-up to &lt;a href=&quot;https://vi.stackexchange.com/questions/2051/switching-to-the-local-directory-after-loading-a-file&quot;&gt;Switching to the local directory after loading a file?&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost *.tex lchdir %:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the intent of setting the current directory to the same as the edited file for &lt;code&gt;*.tex&lt;/code&gt; files, &lt;em&gt;without&lt;/em&gt; setting the global &lt;code&gt;autochdir&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works if I call: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; gvim /home/romano/education/IntroEle-SAP-135/Lab-T1/LabTestExample.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Look at the full filename in status line here: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/InnzF.png&quot; alt=&quot;Working autocmd lchdir&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it &lt;strong&gt;does not&lt;/strong&gt; work if I call: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --servername desktop_0 --remote-tab-silent /home/romano/education/IntroEle-SAP-135/Lab-T1/LabTestExample.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Screenshot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/b9Yrx.png&quot; alt=&quot;Not working autocmd&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(the culprit seems to be the &lt;code&gt;--remote-tab-silent&lt;/code&gt; switch). How can I correct this so that the &lt;code&gt;autocmd&lt;/code&gt; works in the two cases? &lt;/p&gt;&#xA;" OwnerUserId="854" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-05-22T12:21:29.730" Title="Different autocmd behavior when using --remote-tab-silent?" Tags="|autocmd|tabbed-user-interface|clientserver|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2067" PostTypeId="2" ParentId="1915" CreationDate="2015-02-20T19:08:05.250" Score="1" Body="&lt;p&gt;Use visual mode with line highlighting.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Put your cursor on the top line of the block of text/code to remove &lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;Shift&lt;/kbd&gt; + &lt;kbd&gt;v&lt;/kbd&gt; &lt;/li&gt;&#xA;&lt;li&gt;Move your cursor down to the bottom of the block of text/code to remove &lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt; d &lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I prefer this method for deleting blocks of code because it deletes whole lines compared to simply using visual mode where you have to position the cursor in the right column to delete what you want.&lt;/p&gt;&#xA;" OwnerUserId="890" LastEditorUserId="205" LastEditDate="2015-02-20T20:56:09.493" LastActivityDate="2015-02-20T20:56:09.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2068" PostTypeId="1" AcceptedAnswerId="2214" CreationDate="2015-02-20T22:59:23.877" Score="5" ViewCount="1078" Body="&lt;p&gt;We can use dictionaries to help us complete keywords. To set a new dictionary you can use &lt;code&gt;set dictionary+=path/to/dict&lt;/code&gt;. This way you will be able to complete from a dictionary by typing &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; in Insert mode; and then use &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; to browser the suggestions. Moreover, you can &lt;code&gt;set complete+=k&lt;/code&gt; and now you can type &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; right away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help 'dictionary'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Each file should&#xA;          contain a list of words.  This can be one word per line, or several&#xA;          words per line, separated by non-keyword characters (white space is&#xA;          preferred).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But maybe I would like a term&#xA;    &lt;code&gt;Monty Python&lt;/code&gt;&#xA;in my dictionary, such that when I write &lt;code&gt;Mon&lt;/code&gt; one of the suggestions would be &lt;code&gt;Monty Python&lt;/code&gt;. The &lt;a href=&quot;https://www.gnu.org/software/miscfiles/&quot; rel=&quot;noreferrer&quot;&gt;GNU Miscfiles&lt;/a&gt; &lt;code&gt;web2a&lt;/code&gt; is an example of a dicionary in which each line is made up of two words that go together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to include dictionary terms which have spaces?&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="356" LastEditDate="2015-02-20T23:06:12.910" LastActivityDate="2015-02-25T18:00:03.137" Title="Including dictionary terms with spaces" Tags="|autocompletion|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2069" PostTypeId="5" CreationDate="2015-02-20T23:04:35.620" Score="0" Body="&lt;p&gt;For a general overview of how syntax highlighting works in Vim see &lt;a href=&quot;http://vi.stackexchange.com/a/8773/51&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="51" LastEditDate="2016-08-08T00:55:20.783" LastActivityDate="2016-08-08T00:55:20.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2070" PostTypeId="4" CreationDate="2015-02-20T23:04:35.620" Score="0" Body="Syntax highlighting is the use of colours, size, typeface, or other attributes to visually indicate it has a special meaning and therefore make it easier to understand the text. For example, marking language keywords with a specific colour." OwnerUserId="51" LastEditorDisplayName="user579" LastEditDate="2018-09-13T10:18:01.263" LastActivityDate="2018-09-13T10:18:01.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2071" PostTypeId="1" CreationDate="2015-02-20T23:52:43.017" Score="18" ViewCount="6312" Body="&lt;p&gt;Say I'm editing file &lt;code&gt;foo&lt;/code&gt;. I want to copy/write what I have in the buffer to &lt;code&gt;bar&lt;/code&gt; and change the buffer to be editing &lt;code&gt;bar&lt;/code&gt; instead of &lt;code&gt;foo&lt;/code&gt;. I can achieve this with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w bar&#xA;:e bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that has a few problems&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If &lt;code&gt;bar&lt;/code&gt; is actually &lt;code&gt;/usr/local/share/long/path/to/bar&lt;/code&gt;, I really don't want to type that in twice, even with tab completion.&lt;/li&gt;&#xA;&lt;li&gt;It reloads the file, potentially messing with the settings/folds/etc. I had for that buffer.&lt;/li&gt;&#xA;&lt;li&gt;The working directory is left the same. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;1 is the biggest problem I'd like a solution to address; 2 would be really helpful, 3 is more of a &quot;nice to have.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a cleaner way to do this? &lt;/p&gt;&#xA;" OwnerUserId="9" LastEditorUserId="51" LastEditDate="2015-02-20T23:59:53.570" LastActivityDate="2021-09-13T15:12:20.740" Title="How can I copy the current file and start editing the copy instead of the current file?" Tags="|save|multiple-files|file-operations|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2072" PostTypeId="2" ParentId="2071" CreationDate="2015-02-21T00:21:50.370" Score="14" Body="&lt;p&gt;Here's a relatively simple solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:saveas bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This solves problems #1 and #2. It doesn't address problem #3, however.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this still leaves the old file open in another buffer. For example, &lt;code&gt;:w&amp;nbsp;foo&amp;lt;cr&gt;:saveas&amp;nbsp;bar&amp;lt;cr&gt;:ls&amp;lt;cr&gt;&lt;/code&gt; will list two buffers, &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;bar&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-21T00:21:50.370" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2074" PostTypeId="2" ParentId="2071" CreationDate="2015-02-21T00:40:20.380" Score="2" Body="&lt;p&gt;Write the file as usual: &lt;code&gt;:w bar&lt;/code&gt; and press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;^&lt;/kbd&gt; (or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;6&lt;/kbd&gt;) to alternate the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For splits (&lt;code&gt;:ba&lt;/code&gt;/&lt;code&gt;:vert ba&lt;/code&gt;), check: &lt;a href=&quot;https://vi.stackexchange.com/q/758/467&quot;&gt;How to convert all windows into horizontal, vertical or tab splits?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;code&gt;:help ctrl-6&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-21T00:40:20.380" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2075" PostTypeId="2" ParentId="766" CreationDate="2015-02-21T03:41:59.080" Score="1" Body="&lt;p&gt;If I understand your question correctly, the key is to determine whether the character on the cursor is a matched delimiter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the normal mode commands &lt;code&gt;v%&quot;zy&lt;/code&gt; and &lt;code&gt;v%%&quot;zy&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the cursor is on a matched delimiter, then the first command will yank a string of length at least 2&amp;mdash;the delimiter, its pair, and any text in the middle&amp;mdash;into &lt;code&gt;@z&lt;/code&gt;.&#xA;The second will yank a string of length exactly 1&amp;mdash;again, the delimiter itself&amp;mdash;into &lt;code&gt;@z&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If the cursor is on an unmatched delimiter, then the first command will yank a string of length 1&amp;mdash;the delimiter itself&amp;mdash;into &lt;code&gt;@z&lt;/code&gt;. Abort.&lt;/li&gt;&#xA;&lt;li&gt;If the cursor is not on a delimiter and there is a delimiter in the line, then the second command will yank a string of length greater than 1 into &lt;code&gt;@z&lt;/code&gt;.&#xA;Abort.&lt;/li&gt;&#xA;&lt;li&gt;If the cursor is not on a delimiter and there is no other delimiter in the line, then the first command will yank a string of length exactly 1&amp;mdash;the character itself&amp;mdash;into &lt;code&gt;@z&lt;/code&gt;.&#xA;Abort.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thus, we have the following result:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;The cursor is on a matched delimiter if and only if the normal mode command &lt;code&gt;v%&quot;zy&lt;/code&gt; yanks a string of length at least 2 into &lt;code&gt;@z&lt;/code&gt; and the normal mode command &lt;code&gt;v%%&quot;zy&lt;/code&gt; yanks a string of length exactly 1 into &lt;code&gt;@z&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Hints for VimL: &lt;code&gt;:norm ...&lt;/code&gt; and &lt;code&gt;strlen(@z)&lt;/code&gt; will help here.&lt;/p&gt;&#xA;" OwnerUserId="142" LastActivityDate="2015-02-21T03:41:59.080" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2076" PostTypeId="1" AcceptedAnswerId="2077" CreationDate="2015-02-21T04:05:20.123" Score="39" ViewCount="14250" Body="&lt;p&gt;I don't know much of the theory behind Vim. It looks as if we &lt;code&gt;set&lt;/code&gt; some variables, and &lt;code&gt;let&lt;/code&gt; other variables. What's the difference, and when is one required over the other?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the solarized vim colorscheme says to &lt;code&gt;let g:blabla...&lt;/code&gt; what is the significance of &lt;code&gt;g:&lt;/code&gt; in this instance?&lt;/p&gt;&#xA;" OwnerUserId="810" LastEditorUserId="51" LastEditDate="2015-04-30T15:42:19.007" LastActivityDate="2015-04-30T15:42:19.007" Title="What's the difference between let and set?" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2077" PostTypeId="2" ParentId="2076" CreationDate="2015-02-21T04:14:10.223" Score="49" Body="&lt;p&gt;&lt;code&gt;let&lt;/code&gt; assigns a value to a variable, and &lt;code&gt;set&lt;/code&gt; assigns a value to one of Vim's internal options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you would use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let mystring='Hello!'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to declare a new variable, but you would use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set tabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to set one of Vim's options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;code&gt;:help let&lt;/code&gt;, &lt;code&gt;:help set&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:&lt;/code&gt; simply signifies a global variable. There are several of these &quot;variable namespaces&quot;—from &lt;code&gt;:help internal-variables&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        (nothing) In a function: local to a function; otherwise: global&#xA;|buffer-variable|    b:   Local to the current buffer.&#xA;|window-variable|    w:   Local to the current window.&#xA;|tabpage-variable|   t:   Local to the current tab page.&#xA;|global-variable|    g:   Global.&#xA;|local-variable|     l:   Local to a function.&#xA;|script-variable|    s:   Local to a |:source|'ed Vim script.&#xA;|function-argument|  a:   Function argument (only inside a function).&#xA;|vim-variable|       v:   Global, predefined by Vim.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-21T04:14:10.223" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2078" PostTypeId="2" ParentId="2076" CreationDate="2015-02-21T05:01:12.263" Score="14" Body="&lt;p&gt;&lt;code&gt;:set&lt;/code&gt; is used for internal options and handles the types of the option. It allows things like inversion of boolean options (e.g. &lt;code&gt;:set invpaste&lt;/code&gt;) adding and removing settings from a list (e.g. &lt;code&gt;:set dictionary-=/tmp/myfile&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:let&lt;/code&gt;, on the other hand, allows access to a plethora of changeable things in vim, including regular variables, options, registers, etc. and the value being set is the result of evaluating an expression, instead of a simple value like with &lt;code&gt;:set&lt;/code&gt;, which means &lt;code&gt;:let&lt;/code&gt; gives you access to math, string manipulation, and functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you can &lt;code&gt;:let &amp;amp;dictionary=/tmp/myfile&lt;/code&gt; to set the option &lt;code&gt;'dictionary'&lt;/code&gt; to &lt;code&gt;/tmp/myfile&lt;/code&gt; (thus modifying the same option shown above in the &lt;code&gt;:set&lt;/code&gt; example)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can set a global variable with &lt;code&gt;:let g:myvar=42&lt;/code&gt;. The prefix you asked about provides scope. &lt;a href=&quot;https://vi.stackexchange.com/a/2077/227&quot;&gt;Doorknob's answer&lt;/a&gt; covers the scoping very well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can &lt;code&gt;:let @a=&quot;Some text&quot;&lt;/code&gt; to change the contents of register a to contain &lt;code&gt;Some text&lt;/code&gt;, which you could later paste with &lt;code&gt;&quot;ap&lt;/code&gt; for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can &lt;code&gt;:let $PATH = $PATH . &quot;:/home/me/bin&quot;&lt;/code&gt; to append your own bin directory to the &lt;code&gt;PATH&lt;/code&gt; environment variable, which is passed to any external commands executed by Vim (this works for any environment variable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although &lt;code&gt;let&lt;/code&gt; has some pretty powerful abilities (like &lt;code&gt;:let $MYFILE = @%&lt;/code&gt; to set an environment variable to the filename of the current buffer), it doesn't know that a setting is a boolean, so it doesn't offer nice accesses or error checking like &lt;code&gt;:set&lt;/code&gt; does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end, it's about using the best tool for the job. If you want to simply modify an option, &lt;code&gt;:set&lt;/code&gt; is your tool. If you want to move information around between registers, options, variables, or base your value on the result of an expression, then &lt;code&gt;:let&lt;/code&gt; is your tool.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although you explicitly asked about Vim, another thing to note is that &lt;code&gt;:set&lt;/code&gt; is more common in the vi/Vim families, where &lt;code&gt;:let&lt;/code&gt; is less common (for example, nvi doesn't have a &lt;code&gt;let&lt;/code&gt; command, and viemu doesn't provide access to registers via &lt;code&gt;let&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-21T05:01:12.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2079" PostTypeId="1" AcceptedAnswerId="2080" CreationDate="2015-02-21T10:14:11.893" Score="1" ViewCount="2214" Body="&lt;p&gt;I am trying to write a regular expression that will match a link-attribute in .png  files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: I have a lot of .png like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;https://jnTb6EZom8c/s144/800px-s%25252Ct%252529%2520%25282%2529.png&#xA;https://jnTb6EZom8c/s1300/800px-s%25252Ct%252529%2520%25282%2529.png&#xA;https://jnTb6EZom8c/s50/800px-s%25252Ct%252529%2520%25282%2529.png&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to search for &lt;code&gt;/s144&lt;/code&gt; &lt;code&gt;/s1300&lt;/code&gt; &lt;code&gt;/s50&lt;/code&gt; and so on and replace it with &lt;code&gt;/s400+c&lt;/code&gt;. My Regex &lt;code&gt;/\/s\B\d{2,4}/&lt;/code&gt; works fine in Regex-Tester. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to do the job with vim, but I always get 'pattern not found'. What is wrong with my regular-expression?&lt;/p&gt;&#xA;" OwnerUserId="911" LastEditorUserId="467" LastEditDate="2015-02-21T11:45:28.620" LastActivityDate="2015-02-21T16:58:16.433" Title="How to replace URL resource path with regex?" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2080" PostTypeId="2" ParentId="2079" CreationDate="2015-02-21T10:24:02.470" Score="3" Body="&lt;p&gt;There's a few problems with your version. &lt;code&gt;/&lt;/code&gt; needs to be backslash escaped in the Vim find command line*, and &lt;code&gt;{2,4}&lt;/code&gt; type repeats also need a preceding backslash. The &lt;code&gt;\B&lt;/code&gt; zero-width non-word boundary atom does not exist in Vim-flavour regular expressions, but I don't think it's actually required for your purpose, anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try &lt;code&gt;/\/s\d\{2,4}/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help pattern-overview&lt;/code&gt; for details of Vim's regular expressions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* Note that in other contexts, such as in an &lt;code&gt;:s&lt;/code&gt; command, you can use almost any non-alphanumeric character as a regular expression delimiter. If you want to include &lt;code&gt;/&lt;/code&gt; characters in your expression, just use a different character for your delimiter.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2015-02-21T16:58:16.433" LastActivityDate="2015-02-21T16:58:16.433" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2081" PostTypeId="2" ParentId="2066" CreationDate="2015-02-21T10:37:46.707" Score="1" Body="&lt;p&gt;I found a half workaround. The trick is that if you use &lt;code&gt;--remote-send&lt;/code&gt; instead of &lt;code&gt;--remote&lt;/code&gt; you can make all the &lt;code&gt;autocmd&lt;/code&gt; working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I subsituted &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --servername $desktop --remote-tab-silent &quot;$file&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; gvim --servername $desktop --remote-send &quot;&amp;lt;ESC&amp;gt;:tabe $file&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and the &lt;code&gt;autocmd&lt;/code&gt; works now. &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; is needed because the instance can be in input mode (annoyingly beeps if not) and the double &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is needed because otherwise vim is asking me to press a key --- I do not know why. Now, this &lt;strong&gt;do not work&lt;/strong&gt; if &lt;code&gt;$file&lt;/code&gt; has spaces in it; but this is OT here I think. Or &lt;a href=&quot;https://vi.stackexchange.com/questions/2082/how-to-escape-a-whole-string-in-a-command&quot;&gt;maybe another question&lt;/a&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, there is no &lt;code&gt;--remote-send-silent&lt;/code&gt; option do my script for double clicking on a file in nautilus and have it opened in the existing desktop-local gvim instance or open a new one has got a bit more complex (if anyone want to see it I can post it here, but it seems a bit OT). &lt;/p&gt;&#xA;" OwnerUserId="854" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-21T11:04:13.230" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2082" PostTypeId="1" AcceptedAnswerId="2300" CreationDate="2015-02-21T10:52:02.460" Score="14" ViewCount="1866" Body="&lt;p&gt;Let's see. I have a &lt;code&gt;gvim&lt;/code&gt; running and I want open a file, respecting the &lt;code&gt;autocmd&lt;/code&gt;s (&lt;a href=&quot;https://vi.stackexchange.com/questions/2066/different-autocmd-behavior-when-using-remote-tab-silent&quot;&gt;which rules out &lt;code&gt;--remote-tab&lt;/code&gt;&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I know I can do (basically, with some tweak): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --remote-send &quot;:tabe my_file&amp;lt;CR&amp;gt;&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works. But if a file has spaces or strange chars in it, I have to do the following: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --remote-send &quot;:tabe my\\ file&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(the double &lt;code&gt;\\&lt;/code&gt; is because one of them is eaten by the shell; this is equivalent to manually type &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`:tabe my\ file` &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;vim&lt;/code&gt; and it works). Now, I can find a way to create that string in the shell or whatever, but I hoped I could &quot;globally quote&quot; the string in the &quot;:tabe&quot; command, like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; gvim --remote-send &quot;:tabe 'my file'&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; gvim --remote-send &quot;:tabe \&quot;my file\&quot;&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;--- this is equivalent to writing directly in the vim command line &lt;code&gt;:tabe &quot;my file&quot;&lt;/code&gt;; it seems it is not working. I can explicitly quote all space in the string with the shell, doing something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# &amp;lt;ESC&amp;gt; because the gvim instance can be in a mode different from normal&#xA;# the double CR: do not ask. &#xA;# the argument MUST be a full path&#xA;file=&quot;$(readlink -f &quot;$@&quot;)&quot;&#xA;fileq=&quot;$(echo &quot;$file&quot; |  awk '{gsub(/ /,&quot;\\\ &quot;)}1')&quot; # quote spaces FIXME add other chars&#xA;exec gvim 2&amp;gt;/dev/null --servername $desktop --remote-send &quot;&amp;lt;ESC&amp;gt;:tabe $fileq &amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it works just for spaces and not other special chars like tabs and &lt;code&gt;&quot;&lt;/code&gt; (nor newlines, but if you have newlines in your file names you deserve it!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The question&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Independently on the particular shell, with which I will deal after :-), is there a way &lt;em&gt;when directly typing&lt;/em&gt; in the vim &lt;code&gt;tabe:&lt;/code&gt; line to globally quote a filename without going to quote the &quot;strange&quot; chars one by one? &lt;/p&gt;&#xA;" OwnerUserId="854" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-05-22T14:32:28.197" Title="How to escape a whole string in a : command?" Tags="|command-line|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="2083" PostTypeId="1" CreationDate="2015-02-21T14:15:32.303" Score="3" ViewCount="657" Body="&lt;p&gt;When I checkout different branches, I sometimes notice that files in the repo are not available to Vim plugins that search based on the ctags index.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have a definitive test that's shown the files are missing due to versioning, but I usually notice that the missing files are those that were recently added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I occasionally notice other missing lookups, e.g. with function names or other symbols, and assume it's the same matter.  I'll quickly provide any details if someone has ideas.&lt;/p&gt;&#xA;" OwnerUserId="915" LastEditorUserId="51" LastEditDate="2015-02-22T01:29:05.620" LastActivityDate="2015-02-22T01:29:05.620" Title="Is there a way to hook ctag changes to git branch checkouts and pulls?" Tags="|ide|version-control-systems|git|ctags|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2084" PostTypeId="2" ParentId="2083" CreationDate="2015-02-21T14:50:03.043" Score="6" Body="&lt;p&gt;Depending on how you update your ./tags file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do not commit your ./tags file to your branch/repository you can use a git hook that calls &lt;code&gt;ctags -R .&lt;/code&gt; on each pull/checkout you do - this way your ./tags file will always contain data on all present files in the current version you have checked out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;em&gt;do&lt;/em&gt; want to commit your ./tags file, you can also save that to a hook on push/commit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;could&lt;/em&gt; teach vim to do that, but this is something git can handle nicely for you.&lt;/p&gt;&#xA;" OwnerUserId="875" LastActivityDate="2015-02-21T14:50:03.043" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2085" PostTypeId="2" ParentId="510" CreationDate="2015-02-21T23:46:06.183" Score="3" Body="&lt;p&gt;In &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/tips.html#shell-window&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help shell-window&lt;/code&gt;&lt;/a&gt; we can read about executing shell commands in a window:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There have been questions for the possibility to execute a shell in a&#xA;  window inside Vim.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;The answer: you can't!&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Including this would add a&#xA;  lot of code to Vim, which is a good reason not to do this.  After all,&#xA;  &lt;strong&gt;Vim is an editor&lt;/strong&gt;, it is not supposed to do non-editing tasks. &#xA;  However, to get something like this, you might try splitting your&#xA;  terminal screen or display window with the &quot;&lt;strong&gt;splitvt&lt;/strong&gt;&quot; program.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;An alternative is the&#xA;  &quot;&lt;strong&gt;window&lt;/strong&gt;&quot; command, found on BSD Unix systems, which supports multiple&#xA;  overlapped windows.  Or the &quot;&lt;strong&gt;screen&lt;/strong&gt;&quot; program.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However there are few solutions which you can use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;use &lt;code&gt;screen&lt;/code&gt; which is specially designed for that kind of things, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt;, &lt;kbd&gt;S&lt;/kbd&gt; to split the current window horizontally&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt;, &lt;kbd&gt;Tab&lt;/kbd&gt; to switch between windows&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt;, &lt;kbd&gt;X&lt;/kbd&gt; to remove current region&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt;, &lt;kbd&gt;Q&lt;/kbd&gt; to remove all regions but one&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See more at: &lt;a href=&quot;https://stackoverflow.com/questions/70614/gnu-screen-survival-guide&quot;&gt;GNU Screen Survival Guide&lt;/a&gt; at stackoverflow SE&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or: &lt;a href=&quot;http://tomlee.co/2011/10/gnu-screen-splitting/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GNU Screen Splitting&lt;/a&gt;, &lt;a href=&quot;http://aperiodic.net/screen/quick_reference&quot; rel=&quot;nofollow noreferrer&quot;&gt;screen Quick Reference&lt;/a&gt; for more details.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.wana.at/vimshell/&quot; rel=&quot;nofollow noreferrer&quot;&gt;VIM-Shell&lt;/a&gt; - a third-party patch&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The VIM-shell is a extension for VIM which features split windows,&#xA;  and this patch makes it possible to start shells in those windows. It&#xA;  is only available for POSIX systems&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/sollidsnake/vterm&quot; rel=&quot;nofollow noreferrer&quot;&gt;vterm&lt;/a&gt; - Terminal emulator inside vim.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The goal of vterm is to provide a clone of unix terminal inside vim that works right out of the box without any dependencies.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/benmills/vimux&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimux&lt;/a&gt; - easily interact with tmux from vim.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Inspired by &lt;a href=&quot;https://github.com/kikijump/tslime.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;tslime.vim&lt;/a&gt;, a plugin that lets you send input to tmux, vimux is to make interacting with tmux from vim effortless.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;other already mentioned: &lt;a href=&quot;https://code.google.com/p/conque/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Conque&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Related: &lt;a href=&quot;https://stackoverflow.com/questions/1236563/how-to-run-a-terminal-inside-of-vim&quot;&gt;How to run a terminal inside of vim?&lt;/a&gt; at stackoverflow&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-07-31T10:03:16.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2086" PostTypeId="1" CreationDate="2015-02-22T02:21:25.153" Score="8" ViewCount="292" Body="&lt;p&gt;I would like to have a keystroke to show a &lt;strong&gt;list of recently used files&lt;/strong&gt; to choose one to edit.  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What do I need to provide that?  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And related,  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How do I manage the history of recently used files to use?  &lt;/li&gt;&#xA;&lt;li&gt;This should support excluding filenames or subdirectories.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="925" LastEditorUserId="24" LastEditDate="2015-02-22T03:24:13.090" LastActivityDate="2015-02-25T18:09:59.290" Title="How to access recently used files by choosing from a list?" Tags="|command-history|load|persistent-state|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2087" PostTypeId="2" ParentId="2086" CreationDate="2015-02-22T02:31:30.933" Score="10" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Abrowse&quot;&gt;&lt;code&gt;:browse&lt;/code&gt;&lt;/a&gt; command for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:browse oldfiles&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For a keystroke, map it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;o :browse oldfiles&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can press &lt;kbd&gt;Leader o&lt;/kbd&gt; in normal mode to view a list of files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#%3Aoldfiles&quot;&gt;&lt;code&gt;:help v:oldfiles&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                        v:oldfiles oldfiles-variable&#xA;v:oldfiles      List of file names that is loaded from the viminfo file on&#xA;                startup.  These are the files that Vim remembers marks for.&#xA;                The length of the List is limited by the ' argument of the&#xA;                'viminfo' option (default is 100).&#xA;                When the viminfo file is not used the List is empty.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, to limit at, say, 50 files, you can set &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27viminfo%27&quot;&gt;&lt;code&gt;viminfo&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viminfo+='50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't see an easy way of excluding files from this, other than disabling &lt;code&gt;viminfo&lt;/code&gt; using &lt;code&gt;autocmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNew *.sh set viminfo=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has the &lt;em&gt;huge&lt;/em&gt; flaw of disabling all history for any session that involves  matching files.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="51" LastEditDate="2015-02-25T18:09:59.290" LastActivityDate="2015-02-25T18:09:59.290" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2088" PostTypeId="2" ParentId="2086" CreationDate="2015-02-22T02:33:55.030" Score="4" Body="&lt;p&gt;Check out &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ctrl-P&lt;/a&gt;'s MRU feature. Once you've installed it, type &lt;code&gt;:CtrlPMRUFiles&lt;/code&gt; and it'll pop open a fuzzy finder at the bottom of the screen that you can fuzzy search through.&lt;img src=&quot;https://i.stack.imgur.com/UfG8f.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="133" LastActivityDate="2015-02-22T02:33:55.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2089" PostTypeId="1" AcceptedAnswerId="2092" CreationDate="2015-02-22T02:49:55.380" Score="39" ViewCount="15150" Body="&lt;p&gt;These commands transform one set of keystrokes to another in some way, but I am somewhat fuzzy on which one is most appropriate for some situation. In addition, there are the &lt;code&gt;!&lt;/code&gt; variants of them as well. At the moment, my usage of them is pretty haphazard, so could I know what are the pitfalls associated with each? In particular notes about the various mode versions could be useful, since I learnt from Peter Rincker &lt;a href=&quot;https://vi.stackexchange.com/questions/2006/is-there-a-way-to-alias-w-to-w-to-avoid-creating-files-named/2008#comment1345_2008&quot;&gt;in a comment&lt;/a&gt; that &lt;code&gt;cmap&lt;/code&gt; can expand pretty much anywhere in the line and not only when I'm using &lt;code&gt;:&lt;/code&gt; commands. What precautions can I take against potential pitfalls?&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-23T01:08:03.293" Title="What are the differences between the map, noremap, abbrev and noreabbrev commands?" Tags="|key-bindings|abbreviations|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2090" PostTypeId="5" CreationDate="2015-02-22T03:28:06.890" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-22T03:28:06.890" LastActivityDate="2015-02-22T03:28:06.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2091" PostTypeId="4" CreationDate="2015-02-22T03:28:06.890" Score="0" Body="Doing an action when pressing a key. These are also called key mappings or mappings. For questions about default key bindings, as well as creating or redefining key bindings." OwnerUserId="205" LastEditorUserId="51" LastEditDate="2016-03-14T00:25:09.323" LastActivityDate="2016-03-14T00:25:09.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2092" PostTypeId="2" ParentId="2089" CreationDate="2015-02-22T03:48:43.570" Score="42" Body="&lt;p&gt;First, &lt;code&gt;map&lt;/code&gt; and &lt;code&gt;noremap&lt;/code&gt; are similar in that that each create mappings for normal,  visual, select and operator pending modes &lt;em&gt;simultaneously&lt;/em&gt;. Vim details this in &lt;code&gt;:help map-overview&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Overview of which map command works in which mode.  More details below.&#xA;     COMMANDS                    MODES ~&#xA;:map   :noremap  :unmap     Normal, Visual, Select, Operator-pending&#xA;:nmap  :nnoremap :nunmap    Normal&#xA;:vmap  :vnoremap :vunmap    Visual and Select&#xA;:smap  :snoremap :sunmap    Select&#xA;:xmap  :xnoremap :xunmap    Visual&#xA;:omap  :onoremap :ounmap    Operator-pending&#xA;:map!  :noremap! :unmap!    Insert and Command-line&#xA;:imap  :inoremap :iunmap    Insert&#xA;:lmap  :lnoremap :lunmap    Insert, Command-line, Lang-Arg&#xA;:cmap  :cnoremap :cunmap    Command-line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As per the above help, if you wanted to restrict the mapping to a specific mode, you have to prepend:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;'n' (for normal), 'v' (for visual and select), 'c' (for command), 'x' (for visual mode), 's' (for select), 'o' (for operator pending).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nmap n nzz&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;will create a normal mode, recursive mapping of &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, &lt;code&gt;noremap&lt;/code&gt; is just a non-recursive version of &lt;code&gt;map&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what is non-recursive mapping? Vim has the answer to that too, with &lt;code&gt;:help map-recursive&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If you include the {lhs} in the {rhs} you have a recursive mapping.  When&#xA;{lhs} is typed, it will be replaced with {rhs}.  When the {lhs} which is&#xA;included in {rhs} is encountered it will be replaced with {rhs}, and so on.&#xA;This makes it possible to repeat a command an infinite number of times.  The&#xA;only problem is that the only way to stop this is by causing an error.  The&#xA;macros to solve a maze uses this, look there for an example.  There is one&#xA;exception: If the {rhs} starts with {lhs}, the first character is not mapped&#xA;again (this is Vi compatible).&#xA;For example: &amp;gt;&#xA;   :map ab abcd&#xA;will execute the &quot;a&quot; command and insert &quot;bcd&quot; in the text.  The &quot;ab&quot; in the&#xA;{rhs} will not be mapped again.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An example of this is mapping the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:imap j k&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:imap k j&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, vim will replace j with k and k with j infinite number of times, and will therefore show you an error that you have created a recursive mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is why it is generally recommended that you &lt;em&gt;almost always&lt;/em&gt; (except when you have &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mappings or similar) use non-recursive mappings. This prevents Vim hanging when you inadvertently create recursive mappings. The non-recursive mapping is therefore a more safer way to map commands in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the above information at hand, we can see that &lt;code&gt;:noreabbrev&lt;/code&gt; is just a non-recursive version of &lt;code&gt;:abbrev&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:abbrev&lt;/code&gt; only in insert, replace and command modes. &lt;code&gt;:abbrev&lt;/code&gt; is used for creating abbreviations, (aka shortcuts that Vim can expand). The short expanation is to use &lt;code&gt;:map&lt;/code&gt;/&lt;code&gt;:noremap&lt;/code&gt; to create mappings, &lt;code&gt;:abbrev&lt;/code&gt;/&lt;code&gt;:noreabbrev&lt;/code&gt; to create abbreviations, or whenever you want Vim to expand out your typing.&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="246" LastEditDate="2015-02-23T01:08:03.293" LastActivityDate="2015-02-23T01:08:03.293" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2093" PostTypeId="1" CreationDate="2015-02-22T05:02:01.570" Score="3" ViewCount="252" Body="&lt;p&gt;Is there a good way to use folding with &quot;plain text&quot; files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what do I mean by &quot;plain text&quot;?&lt;br&gt;&#xA;I'm thinking of text like it is used in human communication when no formal structure is required.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has some &lt;strong&gt;ad-hoc structure&lt;/strong&gt;, like paragraphs, indentation changes, maybe ranges of cited lines.&lt;br&gt;&#xA;But with &lt;strong&gt;no clear rules&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's certainly &lt;strong&gt;possible&lt;/strong&gt; to use folding for this kind of text: it can be done manually.&lt;br&gt;&#xA;I am looking for ways to make that easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to answer this could be to use a plugin that provides a &lt;strong&gt;set of support functions&lt;/strong&gt;, used loosely together.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They could implement things like&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;handling folding for &lt;strong&gt;structured sections&lt;/strong&gt; of text, while tolerating the other parts&lt;/li&gt;&#xA;&lt;li&gt;check or &lt;strong&gt;enforce rules&lt;/strong&gt; of some kind of minimal structure&lt;/li&gt;&#xA;&lt;li&gt;support &lt;strong&gt;restructuring&lt;/strong&gt; of the text&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A different approach, related to the third item, would be to require to change the text to be more structured.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this, a valid, but suboptimal solution is to require the user to &lt;strong&gt;reformat the text to Markdown&lt;/strong&gt;,&#xA;and then use a standard Markdown filetype plugin to handle the folding.&lt;/p&gt;&#xA;" OwnerUserId="925" LastEditorUserId="925" LastEditDate="2015-02-22T08:03:26.890" LastActivityDate="2015-02-22T08:03:26.890" Title="Using folding with plain text?" Tags="|folding|" AnswerCount="0" CommentCount="6" FavoriteCount="0" ClosedDate="2015-02-23T08:12:50.870" ContentLicense="CC BY-SA 3.0" />
  <row Id="2094" PostTypeId="1" AcceptedAnswerId="2134" CreationDate="2015-02-22T05:50:45.617" Score="11" ViewCount="8683" Body="&lt;p&gt;Is there a way to make certain vimrc configuration valid only for files under a defined directory tree? Or alternatively, is there a way to have a .vimrc file in a directory, and make its setting override all $HOME/.vimrc for that directory and subdirectories (and maybe, additional vimrc file in subdirectory would override again what was overridden by the directory-tree-root vimrc) ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- ~&#xA;+- .vimrc&#xA;+- Development&#xA;   +- proj&#xA;      +- src &#xA;         +- .vimrc (overrides ~/.vimrc for files in Development/proj/src and subdirs)&#xA;      +- res&#xA;         +- .vimrc (overrides ~/.vimrc for files in Development/proj/res and subdirs)&#xA;         +- cc&#xA;            +- .vimrc (overrides ../.vimrc and ~/.vimrc for files in Development/proj/res/cc)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="188" LastActivityDate="2015-03-04T12:12:24.790" Title="How to make vimrc settings applicable for a directory tree only" Tags="|vimrc|" AnswerCount="2" CommentCount="7" ClosedDate="2015-02-23T18:43:23.933" ContentLicense="CC BY-SA 3.0" />
  <row Id="2096" PostTypeId="2" ParentId="2094" CreationDate="2015-02-22T06:22:43.470" Score="1" Body="&lt;p&gt;I've used the LocalVimrc plugin with success, very handy indeed!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/embear/vim-localvimrc&quot; rel=&quot;nofollow&quot;&gt;https://github.com/embear/vim-localvimrc&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="592" LastActivityDate="2015-02-22T06:22:43.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2097" PostTypeId="1" AcceptedAnswerId="2098" CreationDate="2015-02-22T15:52:30.800" Score="5" ViewCount="3092" Body="&lt;p&gt;I have 2 pieces of text, what is a proper way to switch those pieces of text. around e.g. I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is one piece of text.&#xA;Here is another sentence.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to switch around the 3 first words in these sentences, so it becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Here is another piece of text.&#xA;This is one sentence.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another variant of a similar thing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &amp;lt;paragraph&amp;gt;Some text here&amp;lt;/paragraph&amp;gt;&#xA; &amp;lt;paragraph&amp;gt;&amp;lt;note&amp;gt;And something else here&amp;lt;/note&amp;gt;&amp;lt;/paragraph&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I'd want to switch the innermost text so it becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &amp;lt;paragraph&amp;gt;And something else here&amp;lt;/paragraph&amp;gt;&#xA; &amp;lt;paragraph&amp;gt;&amp;lt;note&amp;gt;Some text here&amp;lt;/note&amp;gt;&amp;lt;/paragraph&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="960" LastEditorUserId="51" LastEditDate="2015-02-22T16:39:25.360" LastActivityDate="2015-02-22T17:45:37.077" Title="How do I switch around 2 pieces of text?" Tags="|cut-copy-paste|cursor-movement|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2098" PostTypeId="2" ParentId="2097" CreationDate="2015-02-22T16:27:07.243" Score="4" Body="&lt;p&gt;There are a number of ways to do this, but I would say the most useful &amp;amp; generic way is to use visual mode (&lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#visual-mode&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help visual-mode&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your first example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is one piece of text.&#xA;Here is another sentence.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would put the cursor on the first &lt;code&gt;T&lt;/code&gt; (in &lt;code&gt;This&lt;/code&gt;), start visual mode with &lt;kbd&gt;v&lt;/kbd&gt;, and select the text you want to replace by using &lt;kbd&gt;l&lt;/kbd&gt; (that's a lower case L) or the arrow key, and select the text up to and including the &lt;code&gt;e&lt;/code&gt; in &lt;code&gt;one&lt;/code&gt;).&lt;br&gt;&#xA;You can then delete the text with &lt;kbd&gt;d&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;kbd&gt;d&lt;/kbd&gt; doesn't actually &lt;em&gt;delete&lt;/em&gt; the text, it copies the text to the unnamed register (&lt;code&gt;&quot;&quot;&lt;/code&gt;), and then removes it from the buffer. So it's more like &quot;cut&quot; (&lt;kbd&gt;Ctrl+x&lt;/kbd&gt;) as used in many applications, and not delete (also see &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#quotequote&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help &quot;&quot;&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Armed with this information, we can now go to the second line, start visual mode with &lt;kbd&gt;v&lt;/kbd&gt; again, and select the text we want to replace (in this case, &lt;code&gt;Here is another&lt;/code&gt;), and press &lt;kbd&gt;p&lt;/kbd&gt;.&lt;br&gt;&#xA;The &lt;kbd&gt;p&lt;/kbd&gt; is for &quot;put&quot;, which is Vi-speak for &quot;paste&quot;. Because we've selected some text with visual mode, it will replace this text. But again, this text is not lost: it's put in the unnamed register (replacing the text that was there before).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can now go to the start of the first line, and press &lt;kbd&gt;P&lt;/kbd&gt;, this will put the text from the second line at the cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;p&lt;/kbd&gt; and &lt;kbd&gt;P&lt;/kbd&gt; both &quot;put&quot; (paste) text, the difference is that the former puts the text &lt;em&gt;after&lt;/em&gt; the cursor, while the latter puts it &lt;em&gt;before&lt;/em&gt; this cursor.  I often use the wrong one by accident: remember that you can use &lt;kbd&gt;u&lt;/kbd&gt; to undo and then use the correct one :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope it will be obvious how to use this technique in your second example :-)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus tip: The motion picture&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Above I told you to select the text with &lt;kbd&gt;l&lt;/kbd&gt; or the arrow keys, but there are better ways!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, we could also have used &lt;kbd&gt;v3wd&lt;/kbd&gt;. The &lt;kbd&gt;v&lt;/kbd&gt; starts visual mode, and &lt;kbd&gt;3w&lt;/kbd&gt; selects the next 3 words, and the &lt;kbd&gt;d&lt;/kbd&gt; deletes it. This is obviously a lot quicker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, you don't even need visual mode, just using &lt;kbd&gt;3wd&lt;/kbd&gt; will work the same. I personally prefer to start visual mode, because you can easily see what you're about to delete, and adjust if required.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus tip 2: The wrath of motions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your second example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;paragraph&amp;gt;And something else here&amp;lt;/paragraph&amp;gt;&#xA;&amp;lt;paragraph&amp;gt;&amp;lt;note&amp;gt;Some text here&amp;lt;/note&amp;gt;&amp;lt;/paragraph&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would put the cursor on the &lt;code&gt;A&lt;/code&gt; of &lt;code&gt;And&lt;/code&gt;, and type &lt;kbd&gt;t&amp;lt;&lt;/kbd&gt;. This put the cursor just before the first occurrence &lt;code&gt;&amp;lt;&lt;/code&gt;; very useful!&lt;br&gt;&#xA;There's also &lt;kbd&gt;f&lt;/kbd&gt;, which puts the cursor &lt;em&gt;on&lt;/em&gt; the first occurrence of what you find, and you could also use &lt;kbd&gt;2t&amp;lt;&lt;/kbd&gt; to put the cursor before the &lt;em&gt;second&lt;/em&gt; occurrence of &lt;code&gt;&amp;lt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#navigation&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help cursor-motions&lt;/code&gt;&lt;/a&gt; for more information about cursor motions. Note that you could also use the mouse to do all of this if you've enable it, but that's of course not the &lt;em&gt;true&lt;/em&gt; Vi way ;-)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus tip 3: The search for registers&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;kbd&gt;d&lt;/kbd&gt; and &lt;kbd&gt;p&lt;/kbd&gt; use the unnamed register by default, but you can specify a register; for example, &lt;kbd&gt;&quot;ad&lt;/kbd&gt; would delete (&quot;cut') the text to the &lt;code&gt;a&lt;/code&gt; register (leaving the unnamed &lt;code&gt;&quot;&lt;/code&gt; register alone), and &lt;kbd&gt;&quot;ap&lt;/kbd&gt; would put (&quot;paste&quot;) from this register. This can be quite useful in a number of scenarios.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#registers&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help registers&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-22T17:45:37.077" LastActivityDate="2015-02-22T17:45:37.077" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2099" PostTypeId="2" ParentId="2097" CreationDate="2015-02-22T16:53:42.110" Score="5" Body="&lt;p&gt;@Carpetsmoker has given a very nice and thorough answer with good explanations. However, in this particular case, I think the best solution is to use the basic &lt;i&gt;delete three words&lt;/i&gt; command, that is, &lt;kbd&gt;d3w&lt;/kbd&gt;. The words can then be inserted at the desired spot with &lt;kbd&gt;p&lt;/kbd&gt; or &lt;kbd&gt;P&lt;/kbd&gt;. A detailed description:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Put cursor on first letter of first word in first sentence&lt;/li&gt;&#xA;&lt;li&gt;Do &lt;kbd&gt;d3w&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Put cursor on first letter of first word in second sentence&lt;/li&gt;&#xA;&lt;li&gt;Do &lt;kbd&gt;Pd3w&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Go back to beginning of first sentence&lt;/li&gt;&#xA;&lt;li&gt;Do &lt;kbd&gt;P&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2015-02-22T17:14:51.520" LastActivityDate="2015-02-22T17:14:51.520" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2100" PostTypeId="2" ParentId="2097" CreationDate="2015-02-22T17:09:43.047" Score="5" Body="&lt;p&gt;Another way would be to use the &lt;a href=&quot;https://github.com/tommcdo/vim-exchange&quot; rel=&quot;nofollow&quot;&gt;vim-exchange&lt;/a&gt; plugin. This plugin provides the &lt;kbd&gt;cx&lt;/kbd&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be used by going to the start of the first line, and pressing &lt;kbd&gt;cx3w&lt;/kbd&gt;; the &lt;kbd&gt;3w&lt;/kbd&gt; in this case represents the 3 words you want to replace.&lt;br&gt;&#xA;This text is then highlighted, you can now move the cursor and use &lt;kbd&gt;cx3w&lt;/kbd&gt; again, which will swap the text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your second example, you can put the cursor on the &lt;code&gt;S&lt;/code&gt; in &lt;code&gt;Some&lt;/code&gt;, use &lt;kbd&gt;cx3t&lt;/kbd&gt;; then go to the second line, put the cursor on the &lt;code&gt;A&lt;/code&gt; in &lt;code&gt;And&lt;/code&gt;, and use &lt;kbd&gt;cx3t&lt;/kbd&gt; again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, when you have the &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow&quot;&gt;vim-repeat&lt;/a&gt; plugin installed: &lt;kbd&gt;cx3wj.&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="962" LastEditorUserId="51" LastEditDate="2015-02-22T17:25:02.477" LastActivityDate="2015-02-22T17:25:02.477" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2101" PostTypeId="5" CreationDate="2015-02-22T18:04:09.187" Score="0" Body="&lt;p&gt;The original &lt;code&gt;vi&lt;/code&gt; is &lt;a href=&quot;http://ex-vi.cvs.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;available from here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-22T20:09:35.540" LastActivityDate="2015-02-22T20:09:35.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2102" PostTypeId="4" CreationDate="2015-02-22T18:04:09.187" Score="0" Body="Questions that are specific to the original vi written by Bill Joy in the '70's for 1BSD, which was open sourced in 2002. It is sometimes also called &quot;traditional vi&quot; or &quot;2BSD vi&quot;." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-22T20:09:21.150" LastActivityDate="2015-02-22T20:09:21.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2103" PostTypeId="1" AcceptedAnswerId="2104" CreationDate="2015-02-22T18:05:41.063" Score="8" ViewCount="5116" Body="&lt;p&gt;I've the following example line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aa ... abc abc abc ... zz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm aware that &lt;code&gt;:s/abc/ok/&lt;/code&gt; will change the first occurrence of &lt;code&gt;abc&lt;/code&gt; in the current line and adding &lt;code&gt;g&lt;/code&gt; flag will change all of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I change last occurrence of the string (without knowing how many there are and what's after the last)?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-02-22T18:22:25.933" LastActivityDate="2015-02-22T18:22:25.933" Title="How to change last occurrence of the string in the line?" Tags="|substitute|" AnswerCount="1" CommentCount="0" ClosedDate="2017-05-24T15:27:06.397" ContentLicense="CC BY-SA 3.0" />
  <row Id="2104" PostTypeId="2" ParentId="2103" CreationDate="2015-02-22T18:21:36.180" Score="11" Body="&lt;p&gt;Greedy matching:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/.*\zsabc//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;.*&lt;/code&gt; will consume as many characters as possible (therefore leaving you at the last occurrence), and the &lt;code&gt;\zs&lt;/code&gt; sets the start of the actual match (&lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; are useful substitutes for positive lookaheads/lookbehinds in Vim) so that the text before isn't removed as well.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-22T18:21:36.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2105" PostTypeId="1" CreationDate="2015-02-22T19:48:59.040" Score="33" ViewCount="15031" Body="&lt;p&gt;How can I reverse the order of lines so that the first line appears at the end and the last line appears first?  (Could be all the lines in a buffer, an address range, or a linewise visual mode selection.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to transform&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rat&#xA;ox&#xA;tiger&#xA;⋮&#xA;dog&#xA;pig&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pig&#xA;dog&#xA;⋮&#xA;tiger&#xA;ox&#xA;rat&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;without resorting to an external command such as &lt;code&gt;tac&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2018-08-22T11:30:22.287" Title="How to reverse the order of lines?" Tags="|rearrangement|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2106" PostTypeId="2" ParentId="2105" CreationDate="2015-02-22T20:16:16.393" Score="40" Body="&lt;p&gt;The power of global  will work here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/exe &quot;normal ddggP&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, more simply (thanks @tommcdo)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/move 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first will match every line and for each line, delete it and paste it to the top of the file. As it moves through the file, it reverses the text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second similarly matches every line and moves it to the top of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Both of these work on the &lt;em&gt;whole file&lt;/em&gt; and will not apply correctly to reversing a subset of the lines. See &lt;a href=&quot;https://vi.stackexchange.com/a/2107/227&quot;&gt;Ingo Karkat's answer&lt;/a&gt; for a solution that works within a range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Description:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g&lt;/code&gt; global command&lt;br&gt;&#xA;&lt;code&gt;/^/&lt;/code&gt; match any line that has a beginning (i.e. all lines)&lt;br&gt;&#xA;&lt;code&gt;exe&lt;/code&gt; execute the following string&lt;br&gt;&#xA;&lt;code&gt;&quot;normal&lt;/code&gt; perform normal mode commands&lt;br&gt;&#xA;&lt;code&gt;dd&lt;/code&gt; delete line&lt;br&gt;&#xA;&lt;code&gt;gg&lt;/code&gt; move to top of file&lt;br&gt;&#xA;&lt;code&gt;P&lt;/code&gt; paste above current position&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;move 0&lt;/code&gt; moves the current line to below line 0 (which puts it at position 1, or the first line of the file)&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2015-02-22T21:01:41.720" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="2107" PostTypeId="2" ParentId="2105" CreationDate="2015-02-22T20:29:58.277" Score="14" Body="&lt;p&gt;This one-liner (for your &lt;code&gt;~/.vimrc&lt;/code&gt;) defines a &lt;code&gt;:Reverse&lt;/code&gt; command; you can also use the &lt;code&gt;:global&lt;/code&gt; part directly, but the syntax of the &lt;code&gt;:move&lt;/code&gt; (which iteratively shifts the lines to before the start of the range, thereby reversing it) isn't easy to memorize:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -bar -range=% Reverse &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;global/^/m&amp;lt;line1&amp;gt;-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-02-22T20:29:58.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2108" PostTypeId="1" AcceptedAnswerId="2110" CreationDate="2015-02-22T22:06:41.630" Score="17" ViewCount="3875" Body="&lt;p&gt;If I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabedit file1 file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E172: Only one file name allowed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way to use &lt;code&gt;:tabedit&lt;/code&gt; with multiple file names? Or another way to open multiple tabs at once?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-22T22:31:15.133" LastActivityDate="2017-07-14T19:10:09.430" Title="How can I open multiple tabs at once?" Tags="|tabbed-user-interface|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2109" PostTypeId="2" ParentId="2108" CreationDate="2015-02-22T22:06:41.630" Score="12" Body="&lt;p&gt;As far as I know, the only built-in way to do this is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args *.vim&#xA;:tab all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First, the &lt;code&gt;:args&lt;/code&gt; will replace the argument list. The argument list lists the files you opened Vim with; so &lt;code&gt;vim file1 file2&lt;/code&gt; means that the argument list contains &lt;code&gt;file1&lt;/code&gt; and &lt;code&gt;file2&lt;/code&gt;.&lt;br&gt;&#xA;We can modify this at runtime, and Vim will open a buffer for every new entry in the argument list.&lt;br&gt;&#xA;See  &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#argument-list&quot;&gt;&lt;code&gt;:help argument-list&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:all&lt;/code&gt; command opens a window for every entry in the argument list, the &lt;code&gt;:tab&lt;/code&gt; command executes a command, and opens a new tab when the command given would open  a new window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Caveats&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some caveats to this method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, there is no check for duplicates, so you can end up with 2 or more tabs for the same buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the largest problem is that it replaces all your tabs with what is in the argument list; so you &lt;em&gt;lost&lt;/em&gt; all existing tabs.&lt;br&gt;&#xA;You can slightly circumvent this by using &lt;code&gt;:argadd *.vim&lt;/code&gt; to &lt;em&gt;add&lt;/em&gt; to the argument list, instead of replacing it; but commands such as &lt;code&gt;:edit&lt;/code&gt; or &lt;code&gt;:tabedit&lt;/code&gt; do &lt;em&gt;not&lt;/em&gt; alter the argument list, and you will lose those tabs unless you add them to the argument list (you still have them in the buffer list, though). You may also not want to open everything in your argument list in a tab, perhaps you just want to open 2 files as an additional tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could perhaps make this slightly better by first adding adding all currently open tabs to the argument list (which I can't really get to work), but this still is far from perfect. If a tab has 2 or more windows, it will still modify them...&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-22T22:06:41.630" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2110" PostTypeId="2" ParentId="2108" CreationDate="2015-02-22T22:08:48.413" Score="12" Body="&lt;p&gt;Given the problems &amp;amp; complexity in &lt;a href=&quot;https://vi.stackexchange.com/a/2109/51&quot;&gt;my other answer&lt;/a&gt; using the &quot;built-in&quot; way by modifying the argument list, I've added by own small function to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Open multiple tabs at once&#xA;fun! OpenMultipleTabs(pattern_list)&#xA;    for p in a:pattern_list&#xA;        for c in glob(l:p, 0, 1)&#xA;            execute 'tabedit ' . l:c&#xA;        endfor&#xA;    endfor&#xA;endfun&#xA;&#xA;command! -bar -bang -nargs=+ -complete=file Tabedit call OpenMultipleTabs([&amp;lt;f-args&amp;gt;])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can now use &lt;code&gt;:Tabedit *.vim&lt;/code&gt;. This function will expand all globbing patterns, and execute &lt;code&gt;:tabedit &amp;lt;f&amp;gt;&lt;/code&gt; for every file. You can add as many pathnames as you want, for example this all works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Tabedit file.rb&#xA;:Tabedit *.c&#xA;:Tabedit file1.py file2.py _*.py&#xA;:Tabedit /etc/hosts file{1,2}.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well, and so forth...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I put this in a little &lt;a href=&quot;https://github.com/Carpetsmoker/globedit.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;globedit.vim&lt;/a&gt; plugin, which also contains command for &lt;code&gt;:Edit&lt;/code&gt;, &lt;code&gt;:Split&lt;/code&gt;, etc.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-07-14T19:10:09.430" LastActivityDate="2017-07-14T19:10:09.430" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2111" PostTypeId="5" CreationDate="2015-02-22T22:33:53.093" Score="0" Body="&lt;p&gt;It is very useful to expand and collapse sections of a text file using folding, as it makes it easier to navigate around the document and to work on whole regions as they were single lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Folding is activated via the &lt;code&gt;foldmethod&lt;/code&gt; (abbreviated to &lt;code&gt;fdm&lt;/code&gt;) option, which is local to each of the &lt;a href=&quot;/questions/tagged/vim-windows&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'vim-windows'&quot; rel=&quot;tag&quot;&gt;vim-windows&lt;/a&gt; and determines what kind of folding applies in the current window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possible values for &lt;code&gt;foldmethod&lt;/code&gt; are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;manual&lt;/code&gt; – folds must be defined by entering commands (such as &lt;code&gt;zf&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;indent&lt;/code&gt; – groups of lines with the same indent form a fold&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;syntax&lt;/code&gt; – folds are defined by &lt;a href=&quot;/questions/tagged/syntax-highlighting&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'syntax-highlighting'&quot; rel=&quot;tag&quot;&gt;syntax-highlighting&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;expr&lt;/code&gt; – folds are defined by a user-defined expression&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In addition, &lt;code&gt;foldmethod&lt;/code&gt; may have values:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;marker&lt;/code&gt; – special characters can be manually or automatically added to your text to flag the start and end of folds&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;diff&lt;/code&gt; – used to fold unchanged text when viewing differences (automatically set in &lt;a href=&quot;/questions/tagged/vimdiff&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'vimdiff'&quot; rel=&quot;tag&quot;&gt;vimdiff&lt;/a&gt; mode)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more information: &lt;a href=&quot;http://vim.wikia.com/wiki/Folding&quot; rel=&quot;nofollow&quot;&gt;Folding on vim.wikia&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="188" LastEditorUserId="188" LastEditDate="2015-02-23T01:29:43.923" LastActivityDate="2015-02-23T01:29:43.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2112" PostTypeId="4" CreationDate="2015-02-22T22:33:53.093" Score="0" Body="A feature which lets visually hide (and toggle) regions of a text file, by replacing its contents with a single outline line." OwnerUserId="188" LastEditorUserId="188" LastEditDate="2015-02-23T01:29:20.443" LastActivityDate="2015-02-23T01:29:20.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2113" PostTypeId="5" CreationDate="2015-02-23T00:06:28.070" Score="0" Body="&lt;p&gt;Exuberant Ctags is an external library that many Vi/Vim plugins use for rapidly moving to symbols and definitions located throughout a codebase.  Popular plugins for Ctags use include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimawesome.com/plugin/vim-tags&quot; rel=&quot;nofollow&quot;&gt;vim-tags&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimawesome.com/plugin/tagbar&quot; rel=&quot;nofollow&quot;&gt;tagbar&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimawesome.com/plugin/unite-outline-shouldve-said-no&quot; rel=&quot;nofollow&quot;&gt;Unite Outline&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimawesome.com/plugin/taglist-vim&quot; rel=&quot;nofollow&quot;&gt;taglist&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="915" LastEditorUserId="915" LastEditDate="2015-02-23T01:29:31.527" LastActivityDate="2015-02-23T01:29:31.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2114" PostTypeId="4" CreationDate="2015-02-23T00:06:28.070" Score="0" Body="Questions that deal with plugins or code that relies upon Exuberant Ctags for their symbol lookup." OwnerUserId="915" LastEditorUserId="915" LastEditDate="2015-02-23T01:29:27.340" LastActivityDate="2015-02-23T01:29:27.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2115" PostTypeId="1" AcceptedAnswerId="3151" CreationDate="2015-02-23T00:20:08.807" Score="18" ViewCount="902" Body="&lt;p&gt;I've been using the &lt;a href=&quot;https://vi.stackexchange.com/questions/6/how-can-i-use-the-undofile?s=3|0.0000&quot;&gt;undofile feature&lt;/a&gt; in Vim for a while now. It's a very nice feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, one annoyance is that it's very easy to accidentally undo changes that I did the last time I opened the file; which may be 2 minutes ago, an hour ago, last week, or a month ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's say I open a file, make a few changes, go off and change some other files, and discover that my changes weren't required, or perhaps they were just a few temporary debug statements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Previously, I could just hold the &lt;kbd&gt;u&lt;/kbd&gt; key until Vim said &quot;Already at oldest change&quot;, &lt;code&gt;:wq&lt;/code&gt;, and be done. But now I have to be very careful not to undo the changes I did last time I opened the file. There is no obvious way to see when you are doing this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to either make this more explicit? For example by showing it somewhere, issuing a warning, or even asking for a confirmation.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-23T02:39:51.410" LastActivityDate="2017-07-26T11:20:34.030" Title="Can I be notified when I'm undoing changes from the undofile?" Tags="|persistent-state|undo-redo|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2116" PostTypeId="1" AcceptedAnswerId="2117" CreationDate="2015-02-23T00:27:21.997" Score="18" ViewCount="3248" Body="&lt;p&gt;In scripts it is customary to do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:save_cpo = &amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;&#xA;... script ...&#xA;&#xA;let &amp;amp;cpo = s:save_cpo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To ensure nocompatible mode for the script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cpo&amp;amp;vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;some sort of special syntax, as in &lt;code&gt;foo &amp;amp; bar&lt;/code&gt;? Or is it more like a command, trigger line or something else?&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2018-04-12T12:59:19.200" Title="Is cpo&amp;vim a special syntax?" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2117" PostTypeId="2" ParentId="2116" CreationDate="2015-02-23T00:36:52.253" Score="17" Body="&lt;p&gt;Yes, it's a special syntax to reset options to the Vim defaults. From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%3Aset-%26vim&quot;&gt;&lt;code&gt;:help :set-&amp;amp;vim&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:se[t] {option}&amp;amp;        Reset option to its default value.  May depend on the&#xA;                        current value of 'compatible'. {not in Vi}&#xA;:se[t] {option}&amp;amp;vi      Reset option to its Vi default value. {not in Vi}&#xA;:se[t] {option}&amp;amp;vim     Reset option to its Vim default value. {not in Vi}&#xA;&#xA;:se[t] all&amp;amp;             Set all options, except terminal options, to their&#xA;                        default value.  The values of 'term', 'lines' and&#xA;                        'columns' are not changed. {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found it by just typing &lt;code&gt;:help &amp;amp;vim&lt;/code&gt; (which also goes to &lt;code&gt;:help :set-&amp;amp;vim&lt;/code&gt;) :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-23T00:43:13.107" LastActivityDate="2015-02-23T00:43:13.107" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2118" PostTypeId="2" ParentId="2115" CreationDate="2015-02-23T01:55:42.477" Score="3" Body="&lt;p&gt;Oooh, ooh, finally a chance to show off &lt;em&gt;this&lt;/em&gt; nifty command!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim can &quot;go back in time.&quot; It has an &lt;a href=&quot;http://vimhelp.appspot.com/undo.txt.html#%3Aearlier&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:earlier&lt;/code&gt;&lt;/a&gt; command...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        :ea :earlier            &#xA;:earlier {count}        Go to older text state {count} times.                   &#xA;:earlier {N}s           Go to older text state about {N} seconds before.        &#xA;:earlier {N}m           Go to older text state about {N} minutes before.        &#xA;:earlier {N}h           Go to older text state about {N} hours before.          &#xA;:earlier {N}d           Go to older text state about {N} days before.           &#xA;&#xA;:earlier {N}f           Go to older text state {N} file writes before.          &#xA;                        When changes were made since the last write             &#xA;                        &quot;:earlier 1f&quot; will revert the text to the state when    &#xA;                        it was written.  Otherwise it will go to the write      &#xA;                        before that.                                            &#xA;                        When at the state of the first file write, or when      &#xA;                        the file was not written, &quot;:earlier 1f&quot; will go to      &#xA;                        before the first change.                                &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... which can revert the file back to a previous state. This can be used in a number of ways.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If you can make a ballpark estimate of how long it took you to make these changes, you can feed a time into this command. Or, for example, if you know you hadn't changed the file (except for the changes you want to undo) in the past day, you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:earlier 1d&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you've only written (saved) the file once since the changes you want to undo, or you haven't saved the file at all, you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:earlier 1f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As described in the &lt;code&gt;:help&lt;/code&gt; text, this will revert to the previously written version if you just wrote the file, or revert to the last time it was saved if you don't have any saved changes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This doesn't answer your question precisely, but it sounds like a bit of an XY problem.&lt;/p&gt;&#xA;" OwnerUserId="88" LastEditorUserId="51" LastEditDate="2015-06-28T15:24:06.720" LastActivityDate="2015-06-28T15:24:06.720" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2119" PostTypeId="1" CreationDate="2015-02-23T02:51:07.230" Score="8" ViewCount="2286" Body="&lt;p&gt;The Vim spell checker is code-aware; it uses the syntax file to disable spell checking for the parts where it usually doesn't make any sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, on occasion I &lt;em&gt;do&lt;/em&gt; want to spell-check this. Exampels include markdown code blocks, HTML attributes, variable/function names, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I'm *not looking for a filetype-specific solution, but rather something generic that tells Vim to &quot;just spell check it all&quot;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note: this question &lt;a href=&quot;https://stackoverflow.com/q/27253387/660921&quot;&gt;previously came up on SO&lt;/a&gt;, but only has a filetype-specific workaround. Also related is &lt;a href=&quot;https://vi.stackexchange.com/questions/684/how-can-i-check-spelling-in-html-attributes?s=4|0.5882&quot;&gt;How can I check spelling in HTML attributes?&lt;/a&gt;; which also a file-type specific workaround.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-05-26T06:55:22.027" Title="Can I make Vim's spell check not syntax-aware, and check everything?" Tags="|syntax-highlighting|spell-checking|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2120" PostTypeId="2" ParentId="319" CreationDate="2015-02-23T02:52:47.913" Score="8" Body="&lt;p&gt;I wrote a plugin called &lt;a href=&quot;https://github.com/tommcdo/vim-express&quot;&gt;express.vim&lt;/a&gt; that can help with this. The plugin defines an operator &lt;code&gt;g=&lt;/code&gt; that lets you evaluate a VimScript expression over a motion (or Visual selection). It prompts for an expression, in which you can use &lt;code&gt;v:val&lt;/code&gt; as a placeholder for the text covered by the motion (or, again, Visual selection).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, a useful expression would use the &lt;code&gt;system()&lt;/code&gt; function, which runs an external command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;system('tr a-z A-Z', v:val)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Here I used &lt;code&gt;tr&lt;/code&gt; as a simple example external command.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way to use express.vim for this problem would be to select the text with Visual mode, then type &lt;code&gt;g=&lt;/code&gt; followed by that expression, then hit &lt;code&gt;Enter&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g=system('tr a-z A-Z', v:val)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'll admit, it's not easy to use. (In fact, I rarely use this plugin myself!) I'm considering adding a shortcut to invoke an external command, such as starting the expression with &lt;code&gt;!&lt;/code&gt;. I'll post an update here if I end up doing that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've modified express.vim to treat expressions beginning with &lt;code&gt;!&lt;/code&gt; as external commands. So, sticking with the &lt;code&gt;tr&lt;/code&gt; example, the above becomes a lot simpler. After a Visual selection, type the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g=!tr a-z A-Z&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Invoke the express operator with &lt;code&gt;g=&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Enter &lt;code&gt;!tr a-z A-Z&lt;/code&gt; as the expression&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;Enter&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="64" LastEditorUserId="64" LastEditDate="2015-02-23T03:43:12.027" LastActivityDate="2015-02-23T03:43:12.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2121" PostTypeId="1" CreationDate="2015-02-23T08:03:45.380" Score="19" ViewCount="4997" Body="&lt;p&gt;Using vim editor, a common task is to browse buffers.&#xA;I now use standard commands like &lt;code&gt;:ls&lt;/code&gt; or a &lt;code&gt;:bnext&lt;/code&gt;. In fact I set in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;move amongs buffers with CTRL&#xA;map &amp;lt;C-J&amp;gt; :bnext&amp;lt;CR&amp;gt;&#xA;map &amp;lt;C-K&amp;gt; :bprev&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to browse buffers as list in quickfix window,&#xA;in the simple (=excellent) way &lt;a href=&quot;https://github.com/yegappan/mru&quot; rel=&quot;noreferrer&quot;&gt;MRU plugin&lt;/a&gt; implements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin as simple as MRU but acting on buffers ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, a possible solution could be to use &lt;code&gt;:CtrlpBuffers&lt;/code&gt; command, part of &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;noreferrer&quot;&gt;Ctrlp plugin&lt;/a&gt; but I'm not a big fan of Ctrlp, because sometime have strange beahviours I do not fully understand (the fuzzy-mode selections...); &#xA;so I'm look for something really simple as MRU plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I joked with &lt;code&gt;:cexpr {expr}&lt;/code&gt; command, trying populate the quickfix windows with content of &lt;code&gt;:buffers&lt;/code&gt; list, without success (maybe because my ignorance programming vimscripts)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestion ?&lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="983" LastEditDate="2015-02-23T11:51:06.103" LastActivityDate="2022-04-09T20:41:28.250" Title="How do I have buffers listed in a quickfix window in Vim?" Tags="|buffers|quickfix|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2122" PostTypeId="2" ParentId="2119" CreationDate="2015-02-23T08:10:25.563" Score="3" Body="&lt;p&gt;If you want this to be something you can turn on and off (as you implied by writing &quot;on occasion&quot;) I think you're going to need a script that can remove all the &lt;code&gt;@Spell&lt;/code&gt; and &lt;code&gt;@NoSpell&lt;/code&gt; clusters from the existing loaded syntax items. (See &lt;code&gt;:help spell-syntax&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way that you might be able to implement this would be to use &lt;code&gt;:redir&lt;/code&gt; to redirect the output from a call to &lt;code&gt;:syntax&lt;/code&gt; to a file, and then parse that file resetting all the syntax items within, but removing references to &lt;code&gt;@Spell&lt;/code&gt; and &lt;code&gt;@NoSpell&lt;/code&gt; clusters. &lt;a href=&quot;https://stackoverflow.com/a/2573054/328936&quot;&gt;It's also possible to redirect the output into a variable&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're happy to enable spell checking everywhere &lt;em&gt;permanently&lt;/em&gt;, then it would be easier to write a script to remove the clusters from the actual installed syntax files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a cleaner solution though, I think you're going to have to edit Vim itself.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-24T07:09:28.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2123" PostTypeId="2" ParentId="2121" CreationDate="2015-02-23T08:44:25.477" Score="1" Body="&lt;p&gt;Have a look at the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=42&quot; rel=&quot;nofollow noreferrer&quot;&gt;bufexplorer plugin&lt;/a&gt;. It opens a browsable list of all buffers in a sidebar, similar to the mentioned MRU plugin. Also, there are several more such plugins on &lt;a href=&quot;http://www.vim.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim.org&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: &lt;a href=&quot;https://stackoverflow.com/questions/28669101/having-buffers-list-as-quickfix-window-in-vim-editor/28669716#28669716&quot;&gt;You've asked the same question on Stack Overflow&lt;/a&gt;; please don't submit the identical question to multiple sites in parallel!&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-23T08:44:25.477" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2124" PostTypeId="2" ParentId="2121" CreationDate="2015-02-23T10:41:21.990" Score="10" Body="&lt;p&gt;You should try this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gb :ls&amp;lt;CR&amp;gt;:b&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the prompt, type the desired buffer number and hit Enter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fJoLZ.png&quot; alt=&quot;gb&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-01-07T13:15:31.060" LastActivityDate="2016-01-07T13:15:31.060" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2125" PostTypeId="5" CreationDate="2015-02-23T11:37:37.427" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-23T11:37:37.427" LastActivityDate="2015-02-23T11:37:37.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2126" PostTypeId="4" CreationDate="2015-02-23T11:37:37.427" Score="0" Body="Regular expressions (often shortened to &quot;regex&quot;) are expressions written in a declarative language used for matching patterns within strings." OwnerUserId="188" LastEditorUserId="188" LastEditDate="2015-02-23T16:41:01.150" LastActivityDate="2015-02-23T16:41:01.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2127" PostTypeId="2" ParentId="2121" CreationDate="2015-02-23T11:38:32.813" Score="25" Body="&lt;p&gt;You can populate the quickfix list with each buffer like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setqflist(map(filter(range(1, bufnr('$')), 'buflisted(v:val)'), '{&quot;bufnr&quot;: v:val}'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;setqflist()&lt;/code&gt; takes a List of Dictionary items describing each error (filename, line number, position, etc.). In this case we're specifying a minimal set of information: the buffer number&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;map()&lt;/code&gt; takes a List and an expression (a string) and returns a new List of the expression applied to each item of the input List. Here, we're taking a List of listed buffer numbers and formatting them for use in &lt;code&gt;setqflist()&lt;/code&gt; (&lt;code&gt;'{&quot;bufnr&quot;: v:val}'&lt;/code&gt;, where &lt;code&gt;v:val&lt;/code&gt; is the value of the item in the list)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;filter()&lt;/code&gt; filters a List, removing elements that don't satisfy a given expression. Here the expression is &lt;code&gt;buflisted(v:val)&lt;/code&gt;, meaning the buffer number exists and is listed, i.e. appears in &lt;code&gt;:ls&lt;/code&gt; output&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;range(a, b)&lt;/code&gt; generates a List of numbers from &lt;code&gt;a&lt;/code&gt; to &lt;code&gt;b&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;bufnr()&lt;/code&gt; returns the number of a given buffer name. If the argument is &lt;code&gt;'$'&lt;/code&gt;, it returns the highest buffer number&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That's a lot to type, and not very memorable, so you can wrap it in a command in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Qbuffers call setqflist(map(filter(range(1, bufnr('$')), 'buflisted(v:val)'), '{&quot;bufnr&quot;:v:val}'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can just use &lt;code&gt;:Qbuffers&lt;/code&gt; to populate the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want this to be updated automatically as new buffers are added, you can do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufAdd * Qbuffers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wouldn't recommend this, however, as it will render the quickfix list pretty unusable for things like &lt;code&gt;:make&lt;/code&gt; or &lt;code&gt;:grep&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-02-23T11:38:32.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2128" PostTypeId="2" ParentId="1915" CreationDate="2015-02-23T12:12:28.457" Score="6" Body="&lt;p&gt;Apart from all the other good advice I'm adding &lt;kbd&gt;d&lt;/kbd&gt;+&lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;L&lt;/kbd&gt; for deleting everything from the current cursor position to the last visible line on the screen. Repeating the command will get you down relatively fast. &lt;/p&gt;&#xA;" OwnerUserId="645" LastActivityDate="2015-02-23T12:12:28.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2129" PostTypeId="1" CreationDate="2015-02-23T12:17:56.333" Score="88" ViewCount="76726" Body="&lt;p&gt;One way to select a buffer in Vim could be to browse the buffers list, using standard commands as &lt;code&gt;:ls&lt;/code&gt;, or with &lt;a href=&quot;https://vi.stackexchange.com/questions/2121/how-do-i-have-buffers-listed-in-a-quickfix-window-in-vim&quot;&gt;some external plugin / vimscript code to browse a list in a window&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let's say I want to jump to a buffer directly, as fast as possible.&lt;/p&gt;&#xA;&lt;p&gt;To traverse the buffer list in sequential mode, I now use &lt;code&gt;&amp;lt;C-J&amp;gt;&lt;/code&gt; &lt;code&gt;&amp;lt;C-K&amp;gt;&lt;/code&gt; shortcuts, having set in my .vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; move among buffers with CTRL&#xA;map &amp;lt;C-J&amp;gt; :bnext&amp;lt;CR&amp;gt;&#xA;map &amp;lt;C-K&amp;gt; :bprev&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Another way (direct access) could be &lt;a href=&quot;http://vim.wikia.com/wiki/Easier_buffer_switching#Switching_by_number&quot; rel=&quot;noreferrer&quot;&gt;switching by number&lt;/a&gt;: knowing the buffer number, it is possible to switch directly by entering the buffer number followed by &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;. So if I want to switch to buffer number 5, I would press &lt;code&gt;5&amp;lt;C-^&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But this seem not working for me (I use vim 7.4 on ubuntu box, from a Windows guest, with &lt;em&gt;Italian keyboard&lt;/em&gt;). I suspect that's because the &lt;code&gt;^&lt;/code&gt; character is in the upper case key &lt;code&gt;^ì&lt;/code&gt; in the Italian keyboard, so in fact to got &lt;code&gt;^&lt;/code&gt; I need to press &lt;code&gt;SHIFT-^&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="23502" LastEditDate="2022-10-31T13:03:46.707" LastActivityDate="2024-01-20T11:21:28.077" Title="Fastest way to switch to a buffer in Vim?" Tags="|vimrc|buffers|" AnswerCount="9" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="2130" PostTypeId="2" ParentId="2105" CreationDate="2015-02-23T12:58:37.397" Score="8" Body="&lt;p&gt;Pure Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/m0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;According to &lt;code&gt;:help multi-repeat&lt;/code&gt;, &lt;code&gt;:g&lt;/code&gt; and its cousin &lt;code&gt;:v&lt;/code&gt; work in a two-pass manner.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The first pass of &lt;code&gt;:g&lt;/code&gt; marks every line matching &lt;code&gt;{pattern}&lt;/code&gt;, while the second pass (apparently performed starting at the file's beginning and proceeding to the end) performs the &lt;code&gt;[cmd]&lt;/code&gt;. The above use of &lt;code&gt;:g&lt;/code&gt; takes advantage of the order the lines are processed in (which is probably okay, though probably not technically guaranteed).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;It works by first marking every line, then moving the first marked line to the top of the file, then moving the second to the top of the file (above the line moved previously), then the third marked line (again above the previously moved line), and so on until the last line in the file is moved to the top, effectively reversing the file.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Note that if &lt;code&gt;:g&lt;/code&gt; processed lines in any order other than from top to bottom, this command would not work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://vim.wikia.com/wiki/Reverse_all_lines&quot; rel=&quot;nofollow noreferrer&quot;&gt;Reverse all lines&lt;/a&gt; and &lt;a href=&quot;http://vim.wikia.com/wiki/Power_of_g&quot; rel=&quot;nofollow noreferrer&quot;&gt;Power of g&lt;/a&gt; at vim wikia.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Few examples using external commands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;tac&lt;/code&gt; (part of &lt;a href=&quot;http://www.gnu.org/software/coreutils/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GNU coreutils&lt;/a&gt; - &lt;code&gt;cat&lt;/code&gt; reversed):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!tac                                                                                                                                                                                                                                                              &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;tail&lt;/code&gt; on BSD/OSX (not POSIX-compliant):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!tail -r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;-r&lt;/code&gt;      The -r option causes the input to be displayed in reverse order, by line.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Check: &lt;code&gt;man tar&lt;/code&gt; for more details.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more ideas, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/742466/how-can-i-reverse-the-order-of-lines-in-a-file&quot;&gt;How can I reverse the order of lines in a file?&lt;/a&gt; at stackoverflow SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/418280/filter-to-reverse-lines-of-a-text-file&quot;&gt;How to reverse lines of a text file?&lt;/a&gt; at stackoverflow SE&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/9356/how-can-i-print-lines-from-file-backwards-without-using-tac&quot;&gt;How can I print lines from file backwards (without using “tac”)?&lt;/a&gt; at Unix SE&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-02-23T16:14:52.097" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="2131" PostTypeId="2" ParentId="2129" CreationDate="2015-02-23T13:02:41.873" Score="95" Body="&lt;p&gt;The &lt;code&gt;:b&lt;/code&gt; command can also take a &lt;em&gt;substring&lt;/em&gt; of the name of the file of the buffer which you want to travel to, which is very convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you have three buffers &lt;code&gt;foo&lt;/code&gt;, &lt;code&gt;bar&lt;/code&gt;, and &lt;code&gt;baz&lt;/code&gt;, then&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:b bar&lt;/code&gt; will switch to the &lt;code&gt;bar&lt;/code&gt; file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:b o&lt;/code&gt; will switch to the &lt;code&gt;foo&lt;/code&gt; file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:b a&lt;/code&gt; will give you an error because it could mean either &lt;code&gt;bar&lt;/code&gt; or &lt;code&gt;baz&lt;/code&gt;, but you can fix the name to be more specific with, for example, &lt;kbd&gt;:&lt;/kbd&gt; &lt;kbd&gt;↑&lt;/kbd&gt; &lt;kbd&gt;r&lt;/kbd&gt; &lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This can be very useful, because it means instead of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:buffer very/very/long/path/to/a/veryVeryLongFileName.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:b LongFileName&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is much shorter and easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command can also take a number, if you want to use that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:b 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-02-23T13:02:41.873" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2132" PostTypeId="1" CreationDate="2015-02-23T13:05:15.020" Score="6" ViewCount="1137" Body="&lt;p&gt;I have the below settings in my .vimrc relating to Perl code folding. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I type &lt;code&gt;za&lt;/code&gt; to toggle folding, it works on any &lt;code&gt;sub { }&lt;/code&gt; by just folding up the sub. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I &lt;code&gt;za&lt;/code&gt; a non-sub block (e.g. &lt;code&gt;if&lt;/code&gt;&lt;sup&gt;*&lt;/sup&gt; or &lt;code&gt;for&lt;/code&gt; or &lt;code&gt;while&lt;/code&gt;) it folds up the entire rest of the file, not just the block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want to fold up the block. How might I achieve this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Perl auto-folding&#xA;set foldmethod=syntax&#xA;set foldlevelstart=3&#xA;let perl_fold = 1&#xA;let perl_fold_blocks = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;* &lt;code&gt;if&lt;/code&gt;s are officially statements rather than blocks in Perl, but I would still like to fold them.&lt;/p&gt;&#xA;" OwnerUserId="993" LastEditorUserId="993" LastEditDate="2015-02-23T13:50:25.167" LastActivityDate="2019-03-17T11:55:48.163" Title="Perl folding with perl_fold_blocks" Tags="|vimrc|folding|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2133" PostTypeId="2" ParentId="1977" CreationDate="2015-02-23T13:36:43.173" Score="3" Body="&lt;p&gt;There are few alternatives. The first one is &lt;code&gt;ctags&lt;/code&gt;. If you need a more advanced indexer then &lt;code&gt;cscope&lt;/code&gt; is a better alternative. For instance it will allow you to list &lt;em&gt;all callers&lt;/em&gt; of given function. These tools will index your code without really understanding it properly (they do have a simple grammar definition to know what given symbol means). It's also relatively easy to extend that grammar. The &lt;code&gt;taglist&lt;/code&gt; plugin is a must have for these and it's possible to extend indexer grammar to show results in taglist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need something more than indexer then like syntax checking then &lt;code&gt;YouCompleteMe&lt;/code&gt; is probably the way to go. It's build on top of the &lt;code&gt;llvm&lt;/code&gt; and thus has proper parser. This allows to check the code &lt;em&gt;syntax and semantics&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then if you work with a code that has domain specific language or embedded code then you often end up just greping thru files. Alternative is &lt;code&gt;Ack&lt;/code&gt; perl script that tries to help with this task.&lt;/p&gt;&#xA;" OwnerUserId="784" LastActivityDate="2015-02-23T13:36:43.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2134" PostTypeId="2" ParentId="2094" CreationDate="2015-02-23T13:43:04.547" Score="11" Body="&lt;p&gt;There are several ways to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you specified &lt;code&gt;directory tree&lt;/code&gt;, it excludes the &lt;code&gt;.exrc&lt;/code&gt; approach (as it only works for one directory), and the &lt;em&gt;modelines&lt;/em&gt; as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remains the hand-rolled way: you put an autocommand in your &lt;code&gt;.vimrc&lt;/code&gt; for pattern or specific directories. It's not my preferred approach as it clutters the &lt;code&gt;.vimrc&lt;/code&gt; with yet another thing -- and also because my mind have been compromised with the &lt;code&gt;Single Responsibility Principle&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, there is also the plugin &lt;em&gt;Project&lt;/em&gt; -- one of the oldest on vim.org. As I'm not using it, I won't detail how it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, there are many, and many, plugins with a name that looks like &lt;em&gt;local vimrc&lt;/em&gt;. I've even been maintaining one for years: &lt;a href=&quot;https://github.com/LucHermitte/local_vimrc&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/LucHermitte/local_vimrc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding its features, &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It answers your question: being sourced for each file in a hierarchy -- actually each time we enter a related vim window, the matching &lt;code&gt;_vimrc_local&lt;/code&gt; file&lt;em&gt;s&lt;/em&gt; are sourced.&lt;/li&gt;&#xA;&lt;li&gt;The plugin will look for files named &lt;code&gt;_vimrc_local.vim&lt;/code&gt;, though the pattern used to search for files can be configured (as a string or a list of patterns)&lt;/li&gt;&#xA;&lt;li&gt;It permit plugins that uses per project settings to force loading the &lt;code&gt;_vimrc_local&lt;/code&gt; file before anything else. For instance, when I run &lt;code&gt;gvim foobar.cpp&lt;/code&gt; from the shell my template expander plugin (TEP) (&lt;a href=&quot;http://code.google.com/p/lh-vim/wiki/muTemplate&quot; rel=&quot;noreferrer&quot;&gt;mu-template&lt;/a&gt;) automatically fills in the project name, the project style (copyright headers, namespaces, naming conventions, ...). As TEP and &lt;code&gt;vimrc_local&lt;/code&gt; plugins usually use the same vim event, there is a race on the event, and there is no guaranty project settings can be loaded before expanding any template. So, there is a way with my plugin to fix this kind of races. &lt;/li&gt;&#xA;&lt;li&gt;On the official site, you'll found some explanations on how to write the &lt;code&gt;_vimrc_local.vim&lt;/code&gt; project files.&lt;/li&gt;&#xA;&lt;li&gt;It's being regularly tested and used on Windows (with/without cygwin), *nixes. &lt;/li&gt;&#xA;&lt;li&gt;It stops searching for project configuration at $HOME, or the root directory (&lt;code&gt;/&lt;/code&gt;, &lt;code&gt;//ip/&lt;/code&gt;), or don't even try to on remote files (http, ftp, ...).&lt;/li&gt;&#xA;&lt;li&gt;It supports black and white lists, and also ask-to-the-user and sandbox lists which will work in the same way: what is done of the project-file will depend on the kind the list the project-file belongs to.&lt;/li&gt;&#xA;&lt;li&gt;Someday, I'll eventually have &lt;a href=&quot;https://code.google.com/p/lh-vim/wiki/BTW&quot; rel=&quot;noreferrer&quot;&gt;templates to generate project configurations&lt;/a&gt; for C &amp;amp; C++ project managed with/without CMake, generating (or not) Doxygen documentation, ...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2015-03-04T12:12:24.790" LastActivityDate="2015-03-04T12:12:24.790" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2135" PostTypeId="1" CreationDate="2015-02-23T14:03:05.520" Score="13" ViewCount="873" Body="&lt;p&gt;When I have automatic wrapping enabled, I can write some text like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This line is starting to get fairly long so&#xA;it has been wrapped&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I start writing a comment, I get fairly sensible behaviour:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# When I reach the maximum line width in a&#xA;# comment, the next line gets commented&#xA;# too!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If, however, I'm writing some Ruby and I'm in the middle of a string on an indented line...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;str = &quot;If I'm trying to write a ruby string, &#xA;       and then it tries to wrap, I get a &#xA;       surprise newline and a bunch of space!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While this is valid Ruby code, a better way to write this would be the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;str = &quot;Really, what I'd like it to do is &quot;\&#xA;      &quot;notice that I'm in the middle of a &quot;\&#xA;      &quot;string and sort it out for me&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin or option to add special rules for wrapping certain lines, so that relevant characters can be added in a context-aware fashion?&lt;/p&gt;&#xA;" OwnerUserId="708" LastEditorUserId="708" LastEditDate="2015-05-16T13:59:10.313" LastActivityDate="2015-09-02T15:25:39.173" Title="Can I add an end-of-line string when Vim wraps a line due to textwidth?" Tags="|line-breaks|wrapping|" AnswerCount="1" CommentCount="6" ClosedDate="2016-01-13T14:53:31.843" ContentLicense="CC BY-SA 3.0" />
  <row Id="2136" PostTypeId="1" AcceptedAnswerId="2137" CreationDate="2015-02-23T14:30:29.630" Score="136" ViewCount="17330" Body="&lt;p&gt;In Vim's built-in help system, how do I…&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;search for topics that I want help on?&lt;/li&gt;&#xA;&lt;li&gt;follow hyperlinks?&lt;/li&gt;&#xA;&lt;li&gt;browse around for related material?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="54" LastEditorUserId="24" LastEditDate="2015-02-23T20:17:40.160" LastActivityDate="2022-01-22T14:12:25.270" Title="How do I navigate to topics in Vim's documentation?" Tags="|cursor-movement|help-system|search|tags|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2137" PostTypeId="2" ParentId="2136" CreationDate="2015-02-23T14:30:29.630" Score="155" Body="&lt;p&gt;Vim comes with an exhaustive and fully indexed documentation that contains the answers to most of the questions you may have on using Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the documentation is huge and may look to the neophyte as an impenetrable maze. Here are a few guidelines to help you find what you need…&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;:help&lt;/code&gt; command is your gateway to Vim's documentation. Read the first screen &lt;em&gt;now&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's go meta:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help help&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can complete the arguments with &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; and display the list of possible completions with &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help buf&amp;lt;Tab&amp;gt;&#xA;:help :w&amp;lt;C-d&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By the way, here is an explanation of key notation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help key-notation&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Most Ex commands can be shortened to a few characters. That's true for &lt;code&gt;:help&lt;/code&gt; too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;:help&lt;/code&gt; command and its tab-completion are case-insensitive so the two commands below will get you to the same section:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h BufWritePost&#xA;:h bufwritepost&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;A&lt;/code&gt; are both legitimate commands so case-insensitivity doesn't apply.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you only have a generic keyword to search for, use &lt;code&gt;:helpgrep&lt;/code&gt; and open the quickfix window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helpgrep quickfix&#xA;:copen&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; on the highlighted words to jump to the corresponding tag, use &lt;code&gt;&amp;lt;C-t&amp;gt;&lt;/code&gt; to come back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help tags&lt;/code&gt; for more.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Scroll around to see if there's a related option or command that better suits your needs. That's a great way to learn new tricks, too.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the right syntax to search more efficiently:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :command                        &quot; help for ex-command 'command'&#xA;:h 'option'                        &quot; help for option 'option'&#xA;:h function()                      &quot; help for function 'function'&#xA;:h modifier-key                    &quot; help for 'modifier'-'key' in normal mode&#xA;:h mode_modifier-key               &quot; help for 'modifier'-'key' in 'mode'&#xA;:h mode_modifier-key_modifier-key  &quot; help for 'modifier'-'key' 'modifier'-'key' in 'mode'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :sort&#xA;:h 'ai                &quot; only one quote needed&#xA;:h bufnr(             &quot; no need for both parenthesis&#xA;:h v_ctrl-g&#xA;:h i_ctrl-x_ctrl-o&#xA;:h ctrl-w             &quot; no mode required for normal mode&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Anatomy of a &lt;code&gt;:help&lt;/code&gt; section:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help ballooneval'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/eSNa7.png&quot; alt=&quot;:help ballooneval&amp;#39;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The words highlighted in red are the tags associated with that option.&lt;/li&gt;&#xA;&lt;li&gt;The words in green are the long form and the short form of the option name.&lt;/li&gt;&#xA;&lt;li&gt;The first line in white says that it's a boolean option and that it's off by default, see &lt;code&gt;:help options&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The second line in white says that the option is global, see &lt;code&gt;:help option-summary&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The purple lines are self-explanatory.&lt;/li&gt;&#xA;&lt;li&gt;Then comes the description of the option.&lt;/li&gt;&#xA;&lt;li&gt;The turquoise words are &quot;tags&quot; that let you jump to another part of the documentation. Don't be afraid to follow them.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use your brain, find logical patterns that will help you for future searches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have found the handy &lt;code&gt;:help list-functions&lt;/code&gt;, where to look for string-related functions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have found &lt;code&gt;:help i_ctrl-x_ctrl-o&lt;/code&gt;, how can you find help for &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; in insert mode?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;RTFM is not an insult. You will learn a lot more by reading the documentation than by asking short-sighted questions to random strangers so make sure you at least tried to &lt;em&gt;R&lt;/em&gt;ead &lt;em&gt;T&lt;/em&gt;he &lt;em&gt;F&lt;/em&gt;antastic &lt;em&gt;M&lt;/em&gt;anual before asking.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-12-26T19:01:19.510" LastActivityDate="2016-12-26T19:01:19.510" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2138" PostTypeId="2" ParentId="2105" CreationDate="2015-02-23T15:20:32.923" Score="6" Body="&lt;p&gt;In the spirit of functional VimL:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setline(1, reverse(getline(1, line('$'))))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;getline(1, line('$'))&lt;/code&gt; returns a list of all the lines in the buffer.  &lt;code&gt;'$'&lt;/code&gt; is a special argument for &lt;code&gt;line()&lt;/code&gt; which indicates the last line in the buffer.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;reverse(...)&lt;/code&gt; reverses the input list, in-place.  One would need to use &lt;code&gt;reverse(copy(...))&lt;/code&gt; if the input list shouldn't be modified.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;setline(1, ...)&lt;/code&gt; replaces the specified line with the second argument.  When the second argument is a list, the same number of lines as the length of the list is replaced with the content of the list.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you like, you can also define a command which takes a range (default &lt;code&gt;%&lt;/code&gt; entire buffer)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -bar -range=% Reverse call setline(&amp;lt;line1&amp;gt;, reverse(getline(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastEditorUserId="1292" LastEditDate="2018-08-22T11:30:22.287" LastActivityDate="2018-08-22T11:30:22.287" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2139" PostTypeId="2" ParentId="2010" CreationDate="2015-02-23T15:38:46.507" Score="4" Body="&lt;p&gt;The solarized terminal-Vim colorscheme can work in one of two different ways.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;A 16-colour mode: Solarized only contains 16 colours, so in this mode you set your &lt;em&gt;terminal&lt;/em&gt; to use the solarized colours as its 16 colours, and the Vim colorscheme just uses these. So for example, the Vim colorscheme will request terminal colour &quot;1&quot;, and the terminal displays this as the hex colour #dc322f.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A 256-colour mode, where it picks the closest matches for its 16 colours from a 256-color palette.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The former method is &lt;a href=&quot;https://github.com/altercation/solarized/tree/master/vim-colors-solarized#important-note-for-terminal-users&quot; rel=&quot;nofollow noreferrer&quot;&gt;strongly recommended by the author&lt;/a&gt; (and by me), and it sounds as though you are happy to use this method because you state that your &quot;terminal has the correct colors and background&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it appears from your screenshot that your terminal does &lt;em&gt;not&lt;/em&gt; have the correct colours set. (White is not a colour in the solarized set, and although I haven't eyedroppered it, the other text colour in the screenshot doesn't look to me like it's Solarized &quot;Violet&quot; (#6c71c4), either.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you remove the lines setting &lt;code&gt;t_Co&lt;/code&gt; and &lt;code&gt;g:solarized_termcolors&lt;/code&gt; from your vimrc*, and configure your terminal colours correctly, then you should find that the 16-colour solarized colorscheme will start to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* These lines switch solarized to using its (less faithful) 256-colour mode. This should also work, (I suspect that &lt;a href=&quot;https://vi.stackexchange.com/a/2058/343&quot;&gt;@Jubal is correct in suggesting that BCE is the problem here&lt;/a&gt;), but the 16-colour mode is preferable unless you explicitly &lt;em&gt;don't&lt;/em&gt; want to use solarized in your terminal.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-02-13T09:31:30.063" LastActivityDate="2019-02-13T09:31:30.063" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2140" PostTypeId="2" ParentId="2108" CreationDate="2015-02-23T15:53:59.423" Score="4" Body="&lt;p&gt;You can use &lt;code&gt;:next&lt;/code&gt; command instead, in example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:n file1 file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:n *.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-02-23T16:21:12.513" LastActivityDate="2015-02-23T16:21:12.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2141" PostTypeId="2" ParentId="766" CreationDate="2015-02-23T16:27:25.930" Score="1" Body="&lt;p&gt;Ok so I ended up going through paredit.vim and pulling out some functions to create this: &lt;a href=&quot;https://github.com/mtbrooks33/vim-pear&quot; rel=&quot;nofollow&quot;&gt;vim-pear&lt;/a&gt;. It inserts and deletes delimiters in pairs while maintaining a balanced state. &lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastActivityDate="2015-02-23T16:27:25.930" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2142" PostTypeId="2" ParentId="2105" CreationDate="2015-02-23T16:32:00.683" Score="5" Body="&lt;p&gt;Per the Vim Documentation &lt;a href=&quot;https://vimhelp.appspot.com/usr_12.txt.html#12.4&quot; rel=&quot;noreferrer&quot;&gt;usr_12.txt - Clever Tricks&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h3&gt;12.4 Reverse line order&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;The &lt;code&gt;:global&lt;/code&gt; command can be combined with the &lt;code&gt;:move&lt;/code&gt; command to move&#xA;  all the lines before the first line, resulting in a reversed file. &#xA;  The command is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/^/m 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Abbreviated:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/m 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;The &lt;code&gt;^&lt;/code&gt; regular expression matches the beginning of the line (even if&#xA;  the line is blank).  The &lt;code&gt;:move&lt;/code&gt; command moves the matching line to&#xA;  after the mythical zeroth line, so the current matching line becomes&#xA;  the first line of the file. As the &lt;code&gt;:global&lt;/code&gt; command is not confused&#xA;  by the changing line numbering, &lt;code&gt;:global&lt;/code&gt; proceeds to match all&#xA;  remaining lines of the file and puts each as the first.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This also works on a range of lines.  First move to above the first&#xA;  line and mark it with &lt;code&gt;mt&lt;/code&gt;.  Then move the cursor to the last line in&#xA;  the range and type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'t+1,.g/^/m 't&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="895" LastEditorUserId="24" LastEditDate="2015-02-23T16:36:13.437" LastActivityDate="2015-02-23T16:36:13.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2143" PostTypeId="2" ParentId="758" CreationDate="2015-02-23T16:45:40.730" Score="7" Body="&lt;p&gt;To convert all splits into horizontal splits, you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:windo wincmd K&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For vertical splits:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:windo wincmd H&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How this works: &lt;code&gt;windo&lt;/code&gt; means 'do the following command for all windows'. &lt;code&gt;wincmd H/K&lt;/code&gt; is the same as if you pressed &lt;code&gt;&amp;lt;C-W&amp;gt; H/K&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-W H        Move the current window to be at the far left, using the&#xA;                full height of the screen.  This works like closing the&#xA;                current window and then creating another one with&#xA;                &quot;:vert topleft split&quot;, except that the current window contents&#xA;                is used for the new window.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:wincmd J/L&lt;/code&gt; appears to create an infinite loop, unfortunately. Note that this may change the order of your splits to something unexpected. You can switch two windows' positions with &lt;code&gt;&amp;lt;C-W&amp;gt; X&lt;/code&gt; after running the command if you'd like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you like having a lot of splits open and sometimes find yourself running low on screen real estate, you may be interested in my &lt;a href=&quot;https://github.com/mattboehm/vim-accordion&quot;&gt;accordion plugin&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-02-23T16:45:40.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2144" PostTypeId="1" AcceptedAnswerId="2147" CreationDate="2015-02-23T19:07:51.697" Score="9" ViewCount="504" Body="&lt;p&gt;I have a bunch of splits up right now, and it took me a while to find these files (basically I'm chasing down a bug through 50 interconnected files).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command like &lt;code&gt;:ls &amp;gt; /tmp/filelist&lt;/code&gt; that will write out the current splits/buffers that I have open to a file?&lt;/p&gt;&#xA;" OwnerUserId="1011" LastEditorUserId="24" LastEditDate="2015-02-23T23:11:23.573" LastActivityDate="2015-02-23T23:11:23.573" Title="Is there a way to write out the results of &quot;:ls&quot; to a file?" Tags="|command-line|save|buffers|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2147" PostTypeId="2" ParentId="2144" CreationDate="2015-02-23T20:13:16.300" Score="9" Body="&lt;p&gt;You may try the following 3 commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir &amp;gt; filelist.txt | :ls | :redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;redi[r][!] &amp;gt; {file}&lt;/code&gt; Redirect messages to file &lt;code&gt;{file}&lt;/code&gt;. The messages which&#xA;                          are the output of commands are written to that file,&#xA;                          until redirection ends.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;To stop the messages and commands from being echoed to the screen, put the commands in a function and call it with &lt;code&gt;:silent call Function()&lt;/code&gt;. An alternative is to use the &lt;code&gt;verbosefile&lt;/code&gt; option, this can be used in combination with &lt;code&gt;:redir&lt;/code&gt;. The difference with &lt;code&gt;:redir&lt;/code&gt; is that verbose messages are not displayed when &lt;code&gt;verbosefile&lt;/code&gt; is set.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See: &lt;code&gt;:help redir&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-02-23T20:19:15.157" LastActivityDate="2015-02-23T20:19:15.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2148" PostTypeId="1" AcceptedAnswerId="2149" CreationDate="2015-02-23T21:43:29.197" Score="10" ViewCount="6592" Body="&lt;p&gt;How do I open a file to view in a new tab? Specifically, I want the read-only equivalent of &lt;code&gt;:tabe[dit] &amp;lt;filename&amp;gt;&lt;/code&gt;. I have tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tab :view &amp;lt;filename&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that does not create a new tab as the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/tabpage.html#:tab&quot;&gt;documentation&lt;/a&gt; would suggest.&lt;/p&gt;&#xA;" OwnerUserId="1014" LastEditorUserId="467" LastEditDate="2015-02-23T21:53:47.427" LastActivityDate="2015-02-24T00:01:07.983" Title="How do I open a file to view in a new tab?" Tags="|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2149" PostTypeId="2" ParentId="2148" CreationDate="2015-02-23T21:49:37.543" Score="8" Body="&lt;p&gt;&lt;code&gt;:tab &amp;lt;cmd&amp;gt;&lt;/code&gt; opens a tab where a &lt;code&gt;&amp;lt;cmd&amp;gt;&lt;/code&gt; would have opened a window. &lt;code&gt;:view&lt;/code&gt; doesn't open a window, so &lt;code&gt;:tab view&lt;/code&gt; doesn't open a tab :-) See &lt;a href=&quot;http://vimhelp.appspot.com/tabpage.txt.html#%3Atab&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :tab&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, we also have the &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#splitview&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:sview&lt;/code&gt;&lt;/a&gt; command, which does:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Same as &quot;:split&quot;, but set 'readonly' option for this buffer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This &lt;em&gt;does&lt;/em&gt; open a window. So &lt;code&gt;:tab sview file&lt;/code&gt; opens a tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:sview&lt;/code&gt; is short for &quot;split view&quot;. You can abbreviate to to &lt;code&gt;:sv&lt;/code&gt;, and you can also leave out the second &lt;code&gt;:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Postscript:&lt;br&gt;&#xA;Your question suggests you're not very familiar with Vi/Vim terminology. Many people are confused about this, so don't worry :-) &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#window&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help window&lt;/code&gt;&lt;/a&gt; is a good read for an introduction. It has a useful summary at the start:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A buffer is the in-memory text of a file.&lt;br&gt;&#xA;  A window is a viewport on a buffer.&lt;br&gt;&#xA;  A tab page is a collection of windows.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-24T00:01:07.983" LastActivityDate="2015-02-24T00:01:07.983" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2150" PostTypeId="2" ParentId="2115" CreationDate="2015-02-23T22:27:46.850" Score="7" Body="&lt;p&gt;I had this exact problem. Here's what I added to my vimrc to fix it for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Always write undo history, but only read it on demand&#xA;&quot; use &amp;lt;leader&amp;gt;u to load old undo info&#xA;&quot; modified from example in :help undo-persistence&#xA;&#xA;if has('persistent_undo')&#xA;  set undodir=~/.vim/undo &quot; location to store undofiles&#xA;  nnoremap &amp;lt;leader&amp;gt;u :call ReadUndo()&amp;lt;CR&amp;gt;&#xA;  au BufWritePost * call WriteUndo()&#xA;endif&#xA;&#xA;func! ReadUndo()&#xA;  let undofile = undofile(expand('%'))&#xA;  if filereadable(undofile)&#xA;    let undofile = escape(undofile,'% ')&#xA;    exec &quot;rundo &quot; . undofile&#xA;  endif&#xA;endfunc&#xA;&#xA;func! WriteUndo()&#xA;  let undofile = escape(undofile(expand('%')),'% ')&#xA;  exec &quot;wundo &quot; . undofile&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you &lt;em&gt;don't&lt;/em&gt; set the &lt;code&gt;undofile&lt;/code&gt; option; you need to remove in from your vimrc if you have it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Undo now works as &quot;normal&quot;. But we &lt;em&gt;do&lt;/em&gt; manually write to the undo file with the &lt;code&gt;wundo&lt;/code&gt; command in &lt;code&gt;BufWritePost&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;ReadUndo()&lt;/code&gt; function manually reads the undo file with &lt;code&gt;rundo&lt;/code&gt; and sets the &lt;code&gt;undofile&lt;/code&gt; option. Now we can use &lt;kbd&gt;u&lt;/kbd&gt; to go further back into history. I mapped this to &lt;code&gt;&amp;lt;Leader&amp;gt;u&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This could probably be better. It overwrites the previous undo info, so you can't go back to the previous previous time you edited the file. But I haven't needed that myself.&lt;/p&gt;&#xA;" OwnerUserId="195" LastEditorUserId="195" LastEditDate="2015-04-22T01:41:10.337" LastActivityDate="2015-04-22T01:41:10.337" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2151" PostTypeId="5" CreationDate="2015-02-23T23:37:02.873" Score="0" Body="&lt;p&gt;Using Visual mode consists of three parts:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Mark the start of the text with &lt;code&gt;v&lt;/code&gt;, &lt;code&gt;V&lt;/code&gt; or &lt;code&gt;&amp;lt;CTRL-V&amp;gt;&lt;/code&gt;.&#xA;The character under the cursor will be used as the start.&lt;/li&gt;&#xA;&lt;li&gt;Move to the end of the text.&#xA;The text from the start of the Visual mode up to and including the&#xA;character under the cursor is highlighted.&lt;/li&gt;&#xA;&lt;li&gt;Type an operator command. The highlighted characters will be operated upon.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Full documentation: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html&quot; rel=&quot;nofollow&quot;&gt;visual vimdoc&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="188" LastEditorUserId="188" LastEditDate="2015-02-24T00:00:33.010" LastActivityDate="2015-02-24T00:00:33.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2152" PostTypeId="4" CreationDate="2015-02-23T23:37:02.873" Score="0" Body="Visual mode is a flexible and easy way to select a piece of text for an&#xD;&#xA;operator." OwnerUserId="188" LastEditorUserId="188" LastEditDate="2015-02-24T00:00:14.283" LastActivityDate="2015-02-24T00:00:14.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2153" PostTypeId="5" CreationDate="2015-02-23T23:55:12.880" Score="0" Body="&lt;p&gt;In &lt;a href=&quot;/questions/tagged/insert-mode&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'insert-mode'&quot; rel=&quot;tag&quot;&gt;insert-mode&lt;/a&gt; and &lt;a href=&quot;/questions/tagged/replace-mode&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'replace-mode'&quot; rel=&quot;tag&quot;&gt;replace-mode&lt;/a&gt;, there are several commands to complete part of a keyword or line that has been typed.  This is useful if you are using complicated keywords (e.g., function names with capitals and underscores).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Completion can be done for:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;whole lines                              &lt;code&gt;|i_CTRL-X_CTRL-L|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;keywords in the current file             &lt;code&gt;|i_CTRL-X_CTRL-N|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;keywords in &lt;a href=&quot;/questions/tagged/dictionary&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'dictionary'&quot; rel=&quot;tag&quot;&gt;dictionary&lt;/a&gt;             &lt;code&gt;|i_CTRL-X_CTRL-K|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;keywords in &lt;a href=&quot;/questions/tagged/thesaurus&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'thesaurus'&quot; rel=&quot;tag&quot;&gt;thesaurus&lt;/a&gt;, thesaurus-style     &lt;code&gt;|i_CTRL-X_CTRL-T|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;keywords in the current and included files       &lt;code&gt;|i_CTRL-X_CTRL-I|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;/questions/tagged/tags&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'tags'&quot; rel=&quot;tag&quot;&gt;tags&lt;/a&gt;                           &lt;code&gt;|i_CTRL-X_CTRL-]|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;file names                       &lt;code&gt;|i_CTRL-X_CTRL-F|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;definitions or &lt;a href=&quot;/questions/tagged/macro&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'macro'&quot; rel=&quot;tag&quot;&gt;macro&lt;/a&gt;s              &lt;code&gt;|i_CTRL-X_CTRL-D|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Vim &lt;a href=&quot;/questions/tagged/command-line&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'command-line'&quot; rel=&quot;tag&quot;&gt;command-line&lt;/a&gt;                   &lt;code&gt;|i_CTRL-X_CTRL-V|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;user defined completion             &lt;code&gt;|i_CTRL-X_CTRL-U|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;omni completion                 &lt;code&gt;|i_CTRL-X_CTRL-O|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;/questions/tagged/spell-checking&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'spell-checking'&quot; rel=&quot;tag&quot;&gt;spell-checking&lt;/a&gt; suggestions                &lt;code&gt;|i_CTRL-X_s|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;keywords in 'complete'              &lt;code&gt;|i_CTRL-N|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;All these (except 2) are done in &lt;code&gt;CTRL-X&lt;/code&gt; mode.  This is a sub-mode of Insert&#xA;and Replace modes.  You enter CTRL-X mode by typing &lt;kbd&gt;CTRL-X&lt;/kbd&gt; and one of the CTRL-X commands.  You exit CTRL-X mode by typing a key that is not a valid&#xA;CTRL-X mode command.  Valid keys are the &lt;kbd&gt;CTRL-X&lt;/kbd&gt; command itself, &lt;kbd&gt;CTRL-N&lt;/kbd&gt; (next), and &lt;kbd&gt;CTRL-P&lt;/kbd&gt; (previous).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When completion is active you can use &lt;kbd&gt;CTRL-E&lt;/kbd&gt; to stop it and go back to the originally typed text.  The &lt;kbd&gt;CTRL-E&lt;/kbd&gt; will not be inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the popup menu is displayed you can use &lt;kbd&gt;CTRL-Y&lt;/kbd&gt; to stop completion and&#xA;accept the currently selected entry.  The &lt;kbd&gt;CTRL-Y&lt;/kbd&gt; is not inserted.  Typing a&#xA;&lt;kbd&gt;space&lt;/kbd&gt;, &lt;kbd&gt;Enter&lt;/kbd&gt;, or some other unprintable character will leave completion mode and insert that typed character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full documentation: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#ins-completion&quot; rel=&quot;nofollow&quot;&gt;vimdoc ins-completion&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="188" LastEditorUserId="188" LastEditDate="2015-02-24T00:28:18.087" LastActivityDate="2015-02-24T00:28:18.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2154" PostTypeId="4" CreationDate="2015-02-23T23:55:12.880" Score="0" Body="For questions about the several commands to complete part of a&#xD;&#xA;keyword or line that has been typed." OwnerUserId="188" LastEditorUserId="188" LastEditDate="2015-02-24T00:28:21.367" LastActivityDate="2015-02-24T00:28:21.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2155" PostTypeId="1" AcceptedAnswerId="2175" CreationDate="2015-02-24T00:10:37.997" Score="8" ViewCount="3175" Body="&lt;p&gt;If I do this from the shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sleep 100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can make it go to the background by doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^Z&#xA;$ bg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then continue using my shell. You can get the same effect by adding a &lt;code&gt;&amp;amp;&lt;/code&gt; to the end of the command, but I often forget this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim, I often do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!sleep 100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here also, I often forget to add the &lt;code&gt;&amp;amp;&lt;/code&gt;. Can I put this process in the background and continue using Vim like in the shell?&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-24T21:42:08.403" Title="Put a process started with ! in the background" Tags="|external-command|unix|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2156" PostTypeId="2" ParentId="2010" CreationDate="2015-02-24T03:49:09.660" Score="6" Body="&lt;p&gt;Great news, everyone. @Tom and @Rich set me on the right path. I found a solution provided &lt;a href=&quot;https://github.com/sgerrand/xfce4-terminal-colors-solarized&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. I set my .vimrc to the simple&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax enable&#xA;set background=dark&#xA;set t_Co=16&#xA;colorscheme solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to fix everything. The colors don't seem to be as bright in the &lt;a href=&quot;http://ethanschoonover.com/solarized/img/terminus12&quot; rel=&quot;noreferrer&quot;&gt;font examples&lt;/a&gt;, but that could very well just be me. To anyone who wants to use the Solarized colorscheme and uses xfce4-terminal, just changing the terminalrc and the .vimrc seemed to solve my main problems. Thanks to everyone for your help!&lt;/p&gt;&#xA;" OwnerUserId="779" LastActivityDate="2015-02-24T03:49:09.660" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2157" PostTypeId="1" AcceptedAnswerId="2159" CreationDate="2015-02-24T04:03:13.817" Score="16" ViewCount="3628" Body="&lt;p&gt;I'm a fan of the way that Atom and Sublime Text handle line folding, where the first line of each fold is visible (complete with syntax highlighting), and a marker is appended to the end of the line that indicates the fold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the screenshot below comparing Vim's indent folding (top) versus Atom's (bottom):&lt;img src=&quot;https://i.stack.imgur.com/qpYNG.png&quot; alt=&quot;Vim vs. Atom code folding&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim dedicates two lines for each fold. The first line serves as a heading, and the second line describes some information about the fold (number of lines and text inside the fold).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Atom only uses one line, and uses a small marker at the end of the line to indicate the fold, along with color added to the line numbers on the left. Atom's folding style uses less screen real estate but still communicates all the information I really need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm partial to the Atom folding style. It seems cleaner and more consistent, in my opinion, particularly when listing multiple methods or attributes in a row (as in the above screenshot).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to roughly approximate Atom's folding style in Vim?&lt;/p&gt;&#xA;" OwnerUserId="1019" LastActivityDate="2016-07-15T13:06:42.460" Title="Collapse vim folds to a single line, similar to Atom or Sublime Text" Tags="|folding|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2158" PostTypeId="2" ParentId="2155" CreationDate="2015-02-24T06:52:37.627" Score="1" Body="&lt;p&gt;You can put the command in a shell script that backgrounds itself.  The contents, for example, might be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;sleep 100 &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="554" LastEditorUserId="51" LastEditDate="2015-02-24T14:31:16.637" LastActivityDate="2015-02-24T14:31:16.637" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2159" PostTypeId="2" ParentId="2157" CreationDate="2015-02-24T08:18:16.890" Score="14" Body="&lt;h1&gt;Two lines vs. one line&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;In Vim, all lines within a fold will be collapsed to a &lt;em&gt;single&lt;/em&gt; line, and the &lt;code&gt;'foldtext'&lt;/code&gt; option then determines the synopsis of those lines (usually dashes, the number of folded lines, and content from the first (or all) lines).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your example, in Vim only the &lt;code&gt;{...}&lt;/code&gt; parameter block itself is folded; the line above (that uses the parameters) isn't part of the fold. In contrast, in the other editor, that line using the parameters belongs to the fold, and its foldtext (to use Vim terminology) is the contents of that line plus the appended marker.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Adapting&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In Vim, folds can be generated via different means (see &lt;code&gt;:help fold-methods&lt;/code&gt;), and depends on the &lt;code&gt;'filetype'&lt;/code&gt; of the buffer. The difficulty of including the above line in the fold depends on that; check with &lt;code&gt;:setlocal foldmethod?&lt;/code&gt;. With &lt;em&gt;indent&lt;/em&gt; folding, there's nothing you can influence; you have to switch to another method. For &lt;em&gt;syntax&lt;/em&gt; folding, that would mean adapting the syntax definitions, and could be very tricky. You'll have better luck if an &lt;em&gt;expression&lt;/em&gt; is used, but it would still mean understanding and changing the logic. (It's unlikely that the filetype plugin author provided a configuration to influence this.)&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Syntax highlighting of the folded line&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;That unfortunately isn't possible at all. Vim always uses the &lt;code&gt;Folded&lt;/code&gt; highlight group for the entire folded line. You can tweak that via &lt;code&gt;:highlight&lt;/code&gt; commands in your &lt;code&gt;~/.vimrc&lt;/code&gt;, but the individual differentiation of syntax will be lost.&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2015-02-24T11:01:53.440" LastActivityDate="2015-02-24T11:01:53.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2160" PostTypeId="2" ParentId="2155" CreationDate="2015-02-24T08:23:40.493" Score="5" Body="&lt;p&gt;As &lt;code&gt;&amp;lt;C-z&amp;gt;&lt;/code&gt; will suspend Vim itself, not just the launched shell command, that won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would do is abort the long-running command with &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt;, then relaunch the same command in the background via&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!! &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The &lt;code&gt;:!!&lt;/code&gt; command comes handy for recalling the previous external command here; you could also use the Ex command history via &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-02-24T08:23:40.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2161" PostTypeId="2" ParentId="2157" CreationDate="2015-02-24T08:26:28.897" Score="7" Body="&lt;p&gt;Vim already displays folds as a single line. However, in Vim's &lt;code&gt;indent&lt;/code&gt; folding, all the lines that have the &lt;em&gt;same&lt;/em&gt; indent are included in a fold. So in your screenshot, the lines you are referring to as &quot;headers&quot; (e.g., the one starting &lt;code&gt;collection_base_url&lt;/code&gt;) are &lt;em&gt;not&lt;/em&gt; within the folds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can achieve something similar to Atom's folding by using Vim's &lt;code&gt;foldexpr&lt;/code&gt; &lt;code&gt;foldmethod&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Finds the indent of a line. The indent of a blank line is the indent of the&#xA;&quot; first non-blank line above it.&#xA;function! FindIndent(line_number, indent_width)&#xA;    &quot; Regular expression for a &quot;blank&quot; line&#xA;    let regexp_blank = &quot;^\s*$&quot;&#xA;&#xA;    let non_blank_line = a:line_number&#xA;    while non_blank_line &amp;gt; 0 &amp;amp;&amp;amp; getline(non_blank_line) =~ regexp_blank&#xA;        let non_blank_line = non_blank_line - 1&#xA;    endwhile&#xA;    return indent(non_blank_line) / a:indent_width&#xA;endfunction&#xA;&#xA;&quot; 'foldexpr' for Atom-style indent folding&#xA;function! AtomStyleFolding(line_number)&#xA;    let indent_width = &amp;amp;shiftwidth&#xA;&#xA;    &quot; Find current indent&#xA;    let indent = FindIndent(a:line_number, indent_width)&#xA;&#xA;    &quot; Now find the indent of the next line&#xA;    let indent_below = FindIndent(a:line_number + 1, indent_width)&#xA;&#xA;    &quot; Calculate indent level&#xA;    if indent_below &amp;gt; indent&#xA;        return indent_below&#xA;    elseif indent_below &amp;lt; indent&#xA;        return &quot;&amp;lt;&quot; . indent&#xA;    else&#xA;        return indent&#xA;    endif&#xA;endfunction&#xA;&#xA;set foldexpr=AtomStyleFolding(v:lnum)&#xA;set foldmethod=expr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This defines a fold expression (see &lt;code&gt;:help fold-expr&lt;/code&gt;) as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For lines immediately preceding indented lines, it returns the indentation of the block that follows.&lt;/li&gt;&#xA;&lt;li&gt;For indented lines, it returns the indentation. (Divided by the shiftwidth so each level of indentation increments the returned value by 1)&lt;/li&gt;&#xA;&lt;li&gt;For lines at the end of a block of indented lines, it returns a string &lt;code&gt;&quot;&amp;lt;N&quot;&lt;/code&gt;, where N is set to the indent. This tells Vim that a fold of level N &lt;em&gt;finishes&lt;/em&gt; on that line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Update&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;@alxndr asks in the comments whether it's possible to extend this to include Ruby's outdented &lt;code&gt;end&lt;/code&gt;s within the folds. You could start by replacing the &lt;code&gt;&quot; Calculate indent level&lt;/code&gt; section with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if indent_below &amp;gt; indent&#xA;    return indent_below&#xA;elseif getline(a:line_number) =~ '^\s*end\s*$'&#xA;    return &quot;&amp;lt;&quot; . (indent + 1)&#xA;else&#xA;    return indent&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As it is, this isn't the most robust solution (e.g. it will fail if the &lt;code&gt;end&lt;/code&gt; statement is on the same line, after a semi-colon). You could tweak the regular-expression and surrounding code to address this, but as you're now within the realms of parsing the actual syntax of the file, I suspect things could get a lot more complicated before you have a good solution.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-07-15T13:06:42.460" LastActivityDate="2016-07-15T13:06:42.460" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2162" PostTypeId="1" AcceptedAnswerId="2163" CreationDate="2015-02-24T11:52:01.890" Score="237" ViewCount="212117" Body="&lt;p&gt;Trying to delete characters in insert mode with the &lt;kbd&gt;backspace&lt;/kbd&gt; key sometimes doesn't seem to work. I can &lt;kbd&gt;backspace&lt;/kbd&gt; &lt;em&gt;sometimes&lt;/em&gt;, but at other times it does nothing; the cursor doesn't go to the left, and absolutely nothing seems to happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed this using gVim in Windows.&#xA;The &lt;kbd&gt;backspace&lt;/kbd&gt; seems to work as expected while using Vim from the terminal in most Linux systems however.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why does this happen?&lt;/li&gt;&#xA;&lt;li&gt;How can I make the &lt;kbd&gt;backspace&lt;/kbd&gt; key delete characters as usual?&lt;/li&gt;&#xA;&lt;li&gt;Is this behaviour intended as a feature? In other words: are there better alternatives to the &lt;kbd&gt;backspace&lt;/kbd&gt; to delete characters in insert mode?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="602" LastEditorUserId="4472" LastEditDate="2017-08-31T05:05:41.710" LastActivityDate="2022-05-18T11:22:23.863" Title="Why doesn't the backspace key work in insert mode?" Tags="|insert-mode|" AnswerCount="6" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2163" PostTypeId="2" ParentId="2162" CreationDate="2015-02-24T11:59:03.457" Score="293" Body="&lt;p&gt;tl;dr: Add this to your &lt;a href=&quot;https://vimhelp.org/starting.txt.html#vimrc&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;vimrc&lt;/code&gt;&lt;/a&gt; to make the backspace work like in most other programs:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set backspace=indent,eol,start&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;Longer answer&lt;/h1&gt;&#xA;&lt;p&gt;Though the default behaviour may be surprising, the backspace &amp;quot;not working&amp;quot; can be considered a &lt;em&gt;feature&lt;/em&gt;; it can prevent you from accidentally removing indentation, and from removing too much text by restricting it to the current line and/or the start of the insert.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27backspace%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'backspace'&lt;/code&gt;&lt;/a&gt; tells us:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Influences the working of `&amp;lt;BS&amp;gt;`, `&amp;lt;Del&amp;gt;`, `CTRL-W` and `CTRL-U` in Insert&#xA;mode.  This is a list of items, separated by commas.  Each item allows&#xA;a way to backspace over something:&#xA;&#xA;value     effect&#xA;indent    allow backspacing over autoindent&#xA;eol       allow backspacing over line breaks (join lines)&#xA;start     allow backspacing over the start of insert; CTRL-W and CTRL-U&#xA;          stop once at the start of insert.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So what do these values mean exactly?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;indent&lt;/strong&gt;&lt;br /&gt;&#xA;Vim adds automatic indentation for many filetypes; by default, you're &lt;em&gt;not&lt;/em&gt; allowed to backspace over this; the rules of what is considered to be 'autoindentation' are somewhat subtle, for example, if we would type this (where █ is the cursor):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if (true) {&#xA;    █&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Backspacing won't work.&lt;/p&gt;&#xA;&lt;p&gt;But if we would then add a command and the &lt;code&gt;}&lt;/code&gt;, and go back up, we &lt;em&gt;are&lt;/em&gt; allowed to remove the indentation:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if (true) {&#xA;    █fun()&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is because in the first example, Vim determined it should add 1 level of indentation when you pressed Enter; but in the second example, Vim didn't autoindent anything, it's just Tab characters or a few spaces.&lt;/p&gt;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27autoindent%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'autoindent'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;eol&lt;/strong&gt;&lt;br /&gt;&#xA;This should be the most obvious, pressing Backspace also removes EOL markers (&lt;code&gt;\n&lt;/code&gt; or &lt;code&gt;\r\n&lt;/code&gt;); if disabled, Backspace will do nothing if you try to delete a EOL marker.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;start&lt;/strong&gt;&lt;br /&gt;&#xA;This means you can &lt;em&gt;only&lt;/em&gt; delete text that you've inserted since insert mode started, and you can't delete any text that was previously inserted.&lt;/p&gt;&#xA;&lt;h2&gt;So what's the default setting?&lt;/h2&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I noticed this using GVIM in windows. The backspace seems to work as expected while using VIM from the terminal in most Linux systems however.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The reason for this is because many Linux distro's ship with pre-made vimrc files which set some common options. For example on my Arch Linux system I have &lt;code&gt;/usr/share/vim/vimfiles/archlinux.vim&lt;/code&gt; with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set backspace=indent,eol,start&#xA;&amp;quot; ... and a few more...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you install Vim on Windows, the default is to use the default vimrc and gvimrc that Vim ships with.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;em&gt;Vim&lt;/em&gt; default is an empty value for &lt;code&gt;backspace&lt;/code&gt;. The Arch Linux, Debian, CentOS, or &lt;code&gt;$other_distro&lt;/code&gt; default may be different.&lt;/p&gt;&#xA;&lt;h1&gt;Normal mode&lt;/h1&gt;&#xA;&lt;p&gt;This question is about Backspace in insert mode, but let me also add some brief remarks about Backspace in normal mode.&lt;/p&gt;&#xA;&lt;p&gt;In normal mode, the Backspace acts as &lt;code&gt;h&lt;/code&gt;, it just goes to the left.&lt;/p&gt;&#xA;&lt;p&gt;By default, the backspace will go to the previous line if at the start of a line (as if &lt;code&gt;eol&lt;/code&gt; was in &lt;code&gt;backspace&lt;/code&gt;); you can control this behaviour with the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27ww%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'whichwrap'&lt;/code&gt;&lt;/a&gt; option  through the &lt;code&gt;b&lt;/code&gt; flag (enabled by default).&lt;/p&gt;&#xA;&lt;p&gt;You can also make backspace delete characters by mapping it to the &lt;code&gt;X&lt;/code&gt; command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;BS&amp;gt; X&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-08-10T06:50:45.007" LastActivityDate="2020-08-10T06:50:45.007" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2165" PostTypeId="1" AcceptedAnswerId="2169" CreationDate="2015-02-24T13:05:18.090" Score="16" ViewCount="2288" Body="&lt;p&gt;I got a plain text file with whitespace separated columns of values.&#xA;Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AU 3030 .... ... ....  &#xA;AU 3031 .... ... ....  &#xA;AU 3032 .... ... .... &#xA;AU 3033 .... ... .... &#xA;IT 48100 ... .. .....&#xA;IT 40100 ... .. .....&#xA;IT 48123 ... .. .....&#xA;UK 3333 ... ... ..... &#xA;UK 4444 ... ... .....&#xA;UK 5555 ... ... .....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also got this regex which will match any adjacent line with the same value in the first column (assume the file is sorted on the first column) except the last:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^\(\([A-Z0-9]\+\)\s\+.*\n\)\(\2\)\@=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(or to make it less &quot;hairy&quot;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^\v([A-Z0-9]+)\s+.*\n(\1)@=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to fold lines over the line which was not matched? Having this result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+-- 4 lines AU ....&#xA;+-- 3 lines IT ....&#xA;+-- 3 lines UK ....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="188" LastEditorUserId="188" LastEditDate="2015-02-24T14:48:43.920" LastActivityDate="2015-03-30T09:22:05.533" Title="Folding by regex search pattern" Tags="|regular-expression|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2168" PostTypeId="2" ParentId="2155" CreationDate="2015-02-24T14:00:32.303" Score="1" Body="&lt;p&gt;Normally when a process is started, you don't have much control on it other than terminating it (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt;) or suspending it (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;z&lt;/kbd&gt;, but including the parent process).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However depending on the process type and operating system, here are few tricks that you can try:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Sending &lt;code&gt;SIGTSTP&lt;/code&gt; or &lt;code&gt;SIGSTOP&lt;/code&gt; will stop the process (the same signal sent by &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;z&lt;/kbd&gt;), and &lt;code&gt;SIGCONT&lt;/code&gt; will continue (resume) the process. Testing with &lt;code&gt;sleep&lt;/code&gt; doesn't work, so you've to test it with specific software how it handles the signals. E.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;killall -SIGSTOP sleep&#xA;killall -SIGTSTP sleep&#xA;kill -SIGTSTP PID&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SIGSTOP         stop process            stop (cannot be caught or ignored)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;SIGTSTP         stop process            stop signal generated from keyboard&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sending &lt;code&gt;SIGHUP&lt;/code&gt; to the process. By default this signal terminates the process, however if the process implements SIGHUP signal, it should detach from controlling tty and re-run in the background with new process id (usually it's used with daemons). Unfortunately many applications do not handle it correctly and simply die (including &lt;code&gt;sleep&lt;/code&gt;). E.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;killall -SIGHUP sleep&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;SIGHUP&lt;/code&gt;          terminate process       terminal line hangup&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Other solution could use tools such as &lt;code&gt;retty&lt;/code&gt; (reattach to a pseudo-tty), &lt;a href=&quot;http://inglorion.net/software/detach/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;detach&lt;/code&gt;&lt;/a&gt; (detaches a process from the terminal), &lt;code&gt;nohup&lt;/code&gt; (&lt;a href=&quot;https://unix.stackexchange.com/a/148698/21471&quot;&gt;disconnects the process from the terminal&lt;/a&gt;) or &lt;code&gt;gdb&lt;/code&gt; (attach to existing process &lt;code&gt;-p&lt;/code&gt; and close its file descriptors such as tty, similar &lt;a href=&quot;https://stackoverflow.com/questions/593724/redirect-stderr-stdout-of-a-process-after-its-been-started-using-command-lin&quot;&gt;example&lt;/a&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more info, check: &lt;a href=&quot;https://en.wikipedia.org/wiki/Job_control_(Unix)#Implementation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Job control (Unix) - Implementation&lt;/a&gt; at Wikipedia.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;code&gt;man kill&lt;/code&gt; or &lt;code&gt;man sigaction&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-02-24T21:20:00.483" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2169" PostTypeId="2" ParentId="2165" CreationDate="2015-02-24T14:58:19.660" Score="17" Body="&lt;p&gt;Do &lt;code&gt;set foldmethod=expr&lt;/code&gt; and use &lt;code&gt;'foldexpr'&lt;/code&gt; to set a vim script expression that will define the fold start points.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=expr&#xA;set foldexpr=get(split(getline(v:lnum-1)),0,'')!=get(split(getline(v:lnum)),0,'')?'&amp;gt;1':'='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This looks more complicated than it is, because we can't easily use spaces in &lt;code&gt;:set&lt;/code&gt;, but with spaces, and a newline or 2, it looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;get(split(getline(v:lnum - 1)), 0, '') != get(split(getline(v:lnum)), 0, '')&#xA;    \ ? '&amp;gt;1'&#xA;    \ : '='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Overview&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Basically this compares the first word of each line with the previous line. If the words are different then the line is start of the fold, &lt;code&gt;&amp;gt;1&lt;/code&gt;. Otherwise it keeps the same fold level, &lt;code&gt;=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Glory of Details&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;set foldmethod=expr&lt;/code&gt; to tell Vim to use a vim script expression to determine the foldings&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'foldexpr'&lt;/code&gt; option holds the vim script expression&lt;/li&gt;&#xA;&lt;li&gt;Evaluating the condition with a ternary that returns &lt;code&gt;&amp;gt;1&lt;/code&gt; when a fold should start and &lt;code&gt;=&lt;/code&gt; when the fold level should continue&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v:lnum&lt;/code&gt; is the current line that that &lt;code&gt;'foldexpr'&lt;/code&gt; is running on to update the folds&lt;/li&gt;&#xA;&lt;li&gt;Get the contents the current line (&lt;code&gt;v:lnum&lt;/code&gt;) and the previous line (&lt;code&gt;v:lnum - 1&lt;/code&gt;) via &lt;code&gt;getline()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Split each line into words via &lt;code&gt;split()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;get()&lt;/code&gt; to get the first index of the freshly split words&lt;/li&gt;&#xA;&lt;li&gt;Use a default value of &lt;code&gt;''&lt;/code&gt; in case of a blank line. e.g. &lt;code&gt;get(words, 0, '')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Compare the first word of the current line with the first word of the previous line in the condition portion of the ternary&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note: this method may have some performance issues with very large documents&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'foldmethod'&#xA;:h 'foldexpr'&#xA;:h getline(&#xA;:h v:lnum&#xA;:h split(&#xA;:h get(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-02-24T21:09:55.380" LastActivityDate="2015-02-24T21:09:55.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2170" PostTypeId="1" AcceptedAnswerId="2173" CreationDate="2015-02-24T16:29:10.973" Score="3" ViewCount="1254" Body="&lt;p&gt;How can I make a command that allows me to insert LaTeX environments in the current text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;E&lt;/kbd&gt; or type &lt;code&gt;:texenv&lt;/code&gt; and then enter the environment name in the bottom line, e.g. &lt;code&gt;:texenv itemize&lt;/code&gt;. Which would then insert a&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{itemize}&#xA;\end{itemize}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideally placing the curser after the begin's closing brace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect I could do this with &lt;code&gt;command&lt;/code&gt; but how do I paste the text into the buffer?&lt;/p&gt;&#xA;" OwnerUserId="852" LastEditorUserId="51" LastEditDate="2015-02-24T16:33:44.970" LastActivityDate="2015-02-24T21:58:12.223" Title="Command to create \begin{} \end{} environment in LaTeX" Tags="|text-generation|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2171" PostTypeId="2" ParentId="2170" CreationDate="2015-02-24T16:35:30.700" Score="1" Body="&lt;p&gt;&lt;em&gt;snippets&lt;/em&gt; are like the built-in &lt;code&gt;:abbreviate&lt;/code&gt; on steroids, usually with parameter insertions, mirroring, and multiple stops inside them. One of the first, very famous (and still widely used) Vim plugins is &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2540&quot; rel=&quot;nofollow&quot;&gt;snipMate&lt;/a&gt; (inspired by the &lt;em&gt;TextMate&lt;/em&gt; editor); unfortunately, it's not maintained any more; though there is &lt;a href=&quot;https://github.com/garbas/vim-snipmate&quot; rel=&quot;nofollow&quot;&gt;a fork&lt;/a&gt;. A modern alternative (that requires Python though) is &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2715&quot; rel=&quot;nofollow&quot;&gt;UltiSnips&lt;/a&gt;. There are more, see &lt;a href=&quot;http://vim.wikia.com/wiki/Category:Automated_Text_Insertion&quot; rel=&quot;nofollow&quot;&gt;this list on the Vim Tips Wiki&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are three things to evaluate: First, the features of the snippet engine itself, second, the quality and breadth of snippets provided by the author or others; third, how easy it is to add new snippets.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;For &lt;em&gt;snipMate&lt;/em&gt;, your snippet would look like this; it would be triggered by typing &lt;code&gt;texenv&amp;lt;Tab&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet texenv&#xA;    \begin{${1:environment-name}}&#xA;    \end{$1}$2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-02-24T16:35:30.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2172" PostTypeId="1" AcceptedAnswerId="2174" CreationDate="2015-02-24T16:47:57.693" Score="5" ViewCount="860" Body="&lt;p&gt;I am working with an HTML file and within a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag specifically. I usually fold my code using the marker method. However an annoying behavior sometimes happens with my syntax highlighting when I fold code. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&#xA;    // init {{{1&#xA;    window.onload = init;                                            &#xA;    function init()                                                  &#xA;    {                                                                &#xA;        window.addEventListener('message', messageHandler, false);   &#xA;        GDT_MSG.requestSliceInfo();                                  &#xA;        GDT_MSG.requestSelected();                                   &#xA;        GDT_MSG.requestNetworkGraph();                               &#xA;    }                                                                &#xA;+-- 11 lines: Parser: GLOBAL VARIABLES ------------------------------&#xA;&#xA;+-- 60 lines: Message Handler ---------------------------------------&#xA;&#xA;    // Live Monitoring: Global Variables {{{1                        &#xA;    /* arrays and important settings for live monitoring*/           &#xA;    var pkts = [];                                                   &#xA;    var bytes= [];                                                   &#xA;    var dataset;                                                     &#xA;    var accum_data;                                                  &#xA;    var totalPoints = 900;                                           &#xA;    var displayPoints = 60; // Initially displays the last minute    &#xA;    var plot;                                                        &#xA;    var updateInterval = 5000;                                &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code that is above &quot;GLOBAL VARIABLES&quot; is correctly highlighted whereas the code below &quot;Message handler&quot; is not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This annoyance fades away when I unfold all my folds... but of course this is not what I want. Does anyone know how to fix this?&lt;/p&gt;&#xA;" OwnerUserId="977" LastEditorUserId="51" LastEditDate="2015-02-24T16:53:30.567" LastActivityDate="2015-02-24T17:17:14.567" Title="Why I am losing syntax highlighting when folding code within a &lt;script&gt; tag?" Tags="|syntax-highlighting|folding|filetype-html|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2173" PostTypeId="2" ParentId="2170" CreationDate="2015-02-24T16:49:21.380" Score="2" Body="&lt;p&gt;You can create a simple function to insert text with the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#append%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;append()&lt;/code&gt;&lt;/a&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! TexEnv(name)&#xA;        let l:l = line(&quot;.&quot;) - 1&#xA;        call append(l:l, &quot;\\end{&quot; . a:name . &quot;}&quot;)&#xA;        call append(l:l, &quot;\\begin{&quot; . a:name . &quot;}&quot;)&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use &lt;code&gt;command&lt;/code&gt; to call this; with &lt;code&gt;-nargs=1&lt;/code&gt; we tell it to require one argument, and we pass this to our function with &lt;code&gt;&amp;lt;args&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Texenv call TexEnv(&quot;&amp;lt;args&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Custom commands have to start with an upper case, so I've named it &lt;code&gt;Texenv&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can use the same function with a key mapping; the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#input%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;input()&lt;/code&gt;&lt;/a&gt; function asks you for your TeX environment name, and passes that on to the &lt;code&gt;TexEnv()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-e&amp;gt; :call TexEnv(input(&quot;TeX environment name: &quot;))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; is already bound to scrolling the screen (which is rather useful IMHO), so you're overwriting that mapping...&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-24T16:49:21.380" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2174" PostTypeId="2" ParentId="2172" CreationDate="2015-02-24T17:17:14.567" Score="5" Body="&lt;p&gt;You can read more about why this happens by looking at &lt;code&gt;:help :syn-sync&lt;/code&gt;. The short answer is that vim decides to redraw the screen and starts from some point in the middle of the file. It incorrectly guesses the syntax at this starting point and it messes up the rest of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this, I generally use this mapping, which I got from Steve Losh's &lt;a href=&quot;https://bitbucket.org/sjl/dotfiles/src/603bb1ae9da27c6e08ab115df1cb5d8f6a1442c3/vim/vimrc?at=default#cl-445&quot; rel=&quot;noreferrer&quot;&gt;dotfiles&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap U :syntax sync fromstart&amp;lt;cr&amp;gt;:redraw!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-02-24T17:17:14.567" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2175" PostTypeId="2" ParentId="2155" CreationDate="2015-02-24T17:36:52.327" Score="1" Body="&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This answer only seems to work with the &lt;code&gt;tcsh&lt;/code&gt; and &lt;code&gt;fish&lt;/code&gt; shells. I also tried &lt;code&gt;bash&lt;/code&gt;, &lt;code&gt;dash&lt;/code&gt;, &lt;code&gt;mksh&lt;/code&gt;, and &lt;code&gt;zsh&lt;/code&gt;, and it &lt;em&gt;doesn't&lt;/em&gt; work there; I'm not sure why, because if I do the same actions from these shells without Vim, it &lt;em&gt;does&lt;/em&gt; work as expected... (&lt;code&gt;:!&lt;/code&gt; commands are executed though the shell).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I happen to use &lt;code&gt;tcsh&lt;/code&gt;, so it works for me...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:set shell=/bin/tcsh&lt;/code&gt; to set your shell; this is global, though. So only use it if you think this is a very important feature :-)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^Z&lt;/code&gt; send a &lt;code&gt;SIGTSTP&lt;/code&gt; signal, you can send this signal with &lt;code&gt;kill&lt;/code&gt;, and then use &lt;code&gt;SIGCONT&lt;/code&gt; to continue (resume) the process. This will detach the process from Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because it's difficult to show with this &lt;code&gt;sleep&lt;/code&gt; (how do you know it has continued execution?), I'll use &lt;code&gt;gitk&lt;/code&gt; as an example (but any GUI program will do):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!gitk %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then in another terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ps ax | grep gitk&#xA;30105 pts/10   S+     0:00 -bin/tcsh -c gitk&#xA;30108 pts/10   Sl+    0:00 wish /sbin/gitk --&#xA;&#xA;$ kill -TSTP 30108&#xA;$ kill -CONT 30108&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can of course also use &lt;code&gt;killall&lt;/code&gt;, or &lt;code&gt;pkill&lt;/code&gt;; for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ killall -TSTP wish&#xA;$ killall -CONST wish&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You do need to open another terminal for this, which is not ideal, but it will allow you to continue using both your Vim and your external process.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-24T21:42:08.403" LastActivityDate="2015-02-24T21:42:08.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2176" PostTypeId="1" AcceptedAnswerId="2178" CreationDate="2015-02-24T18:15:00.873" Score="12" ViewCount="7439" Body="&lt;p&gt;I have read the help page about fold-expr (&lt;a href=&quot;http://vimhelp.appspot.com/fold.txt.html#fold-expr&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h fold-expr&lt;/code&gt;&lt;/a&gt;) but it didn't explain what's the syntax used in the expression.&lt;/p&gt;&#xA;&lt;p&gt;There were there four examples:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:set foldexpr=getline(v:lnum)[0]==\&amp;quot;\\t\&amp;quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set foldexpr=MyFoldLevel(v:lnum)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set foldexpr=getline(v:lnum)=~'^\\s*$'&amp;amp;&amp;amp;getline(v:lnum+1)=~'\\S'?'&amp;lt;1':1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set foldexpr=getline(v:lnum-1)=~'^\\s*$'&amp;amp;&amp;amp;getline(v:lnum)=~'\\S'?'&amp;gt;1':1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I understood that &lt;code&gt;v:lnum&lt;/code&gt; is the line that needs an indention level, and that expression two is a call to a function.&lt;/p&gt;&#xA;&lt;p&gt;what about expressions 1,3 and 4? Can someone please explain them to me?&lt;/p&gt;&#xA;" OwnerUserId="342" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2022-10-07T17:31:24.717" Title="How to write a fold-expr?" Tags="|folding|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2178" PostTypeId="2" ParentId="2176" CreationDate="2015-02-24T18:58:58.843" Score="17" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27fde%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'foldexpr'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;It is evaluated for each line to obtain its fold level&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The &lt;code&gt;foldexpr&lt;/code&gt; is evaluated, so it needs to be VimL code; there is no mention of &amp;quot;special syntax&amp;quot; or the like. The result of this evaluation controls what Vim considers a fold or not.&lt;/p&gt;&#xA;&lt;p&gt;Possible values are&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  0                     the line is not in a fold&#xA;  1, 2, ..              the line is in a fold with this level&#xA;  &amp;quot;&amp;lt;1&amp;quot;, &amp;quot;&amp;lt;2&amp;quot;, ..        a fold with this level ends at this line&#xA;  &amp;quot;&amp;gt;1&amp;quot;, &amp;quot;&amp;gt;2&amp;quot;, ..        a fold with this level starts at this line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is &lt;em&gt;not&lt;/em&gt; the full list; just the ones used in the examples in your question. See &lt;code&gt;:help fold-expr&lt;/code&gt; for the full list.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;First&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The first one is fairly simple once we add some spaces and remove the backslashes we need to get this working in a &lt;code&gt;:set&lt;/code&gt; command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;getline(v:lnum)[0] == &amp;quot;\t&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;getline(v:lnum)&lt;/code&gt; gets the entire line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[0]&lt;/code&gt; gets the first character of that&lt;/li&gt;&#xA;&lt;li&gt;and &lt;code&gt;== &amp;quot;\t&amp;quot;&lt;/code&gt; checks if that is a tab character.&lt;/li&gt;&#xA;&lt;li&gt;VimL doesn't have &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;, it just uses &amp;quot;0&amp;quot; for false, and &amp;quot;1&amp;quot; for true. So if this line starts with a tab, it's folded at foldlevel 1. If it doesn't, it's not in a fold (0).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;If you would expand this to &lt;em&gt;count&lt;/em&gt; the number of tabs you would have indentation-based folding (at least, when &lt;code&gt;expandtab&lt;/code&gt; isn't enabled).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Third&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The third one is really not that much more complicated as the first one; as with the first example, we first want to make it more readable:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;getline(v:lnum) =~ '^\s*$' &amp;amp;&amp;amp; getline(v:lnum + 1) =~ '\S' ? '&amp;lt;1' : 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We get the entire line with &lt;code&gt;getline(v:lnum)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;We match that as a regexp with &lt;code&gt;=~&lt;/code&gt; to &lt;code&gt;'^\s*$'&lt;/code&gt;; &lt;code&gt;^&lt;/code&gt; anchors to the start, &lt;code&gt;\s&lt;/code&gt; means any whitespace character, &lt;code&gt;*&lt;/code&gt; means repeat the previous zero or more times, and &lt;code&gt;$&lt;/code&gt; anchors to the end. So this regexp matches (returns true) for blank lines or lines with &lt;em&gt;only&lt;/em&gt; whitespace.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;getline(v:lnum + 1)&lt;/code&gt; gets the &lt;em&gt;next&lt;/em&gt; line.&lt;/li&gt;&#xA;&lt;li&gt;We match this to &lt;code&gt;\S&lt;/code&gt;, which matches any non-whitespace character anywhere on this line.&lt;/li&gt;&#xA;&lt;li&gt;If these 2 conditions are true, we evaluate to &lt;code&gt;&amp;lt;1&lt;/code&gt;, otherwise, &lt;code&gt;1&lt;/code&gt;. This is done with the &amp;quot;ternary&amp;quot;  &lt;code&gt;if&lt;/code&gt; known from C and some other languages: &lt;code&gt;condition ? return_if_true : return_if_false&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;1&lt;/code&gt; means a fold ends on this line, and &lt;code&gt;1&lt;/code&gt; means foldlevel one.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;So, If we &lt;em&gt;end&lt;/em&gt; a fold if the line is blank and the next line is &lt;em&gt;not&lt;/em&gt; blank. Otherwise, we're at foldlevel 1. Or, as &lt;code&gt;:h fold-expr&lt;/code&gt; says it:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This will make a fold out of paragraphs separated by blank lines&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Fourth&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The fourth behaves the same as the third one, but does it in a slightly different way. Expanded, it's:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;getline(v:lnum - 1) =~ '^\s*$' &amp;amp;&amp;amp; getline(v:lnum) =~ '\S' ? '&amp;gt;1' : 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If the &lt;em&gt;previous&lt;/em&gt; line is a blank line, and the &lt;em&gt;current&lt;/em&gt; line is a non-blank line, we start a fold on this line (&lt;code&gt;&amp;gt;1&lt;/code&gt;), if not, we're setting the foldlevel to 1.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Afterword&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;So the logic on all 3 examples is really quite simple. Most of the difficulty comes in the lack of spaces and some of the backslash usage.&lt;/p&gt;&#xA;&lt;p&gt;I suspect that calling a function has some overhead, and since this is evaluated for every line you want to have a decent performance. I don't know how great the difference is on modern machines though, and would recommend that you use a function (as in the 2nd example) unless you have performance problems. Remember The Knuth: &lt;em&gt;&amp;quot;premature optimisation is the root of all evil&amp;quot;&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This question &lt;a href=&quot;https://stackoverflow.com/q/5977895/660921&quot;&gt;is also on StackOverflow&lt;/a&gt;, which has a slightly different answer. But mine is of course better ;-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2022-10-07T17:31:24.717" LastActivityDate="2022-10-07T17:31:24.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2179" PostTypeId="2" ParentId="2176" CreationDate="2015-02-24T18:59:47.877" Score="3" Body="&lt;p&gt;You're essentially asking what the other elements in these expressions are, which can be found by calling &lt;code&gt;:help&lt;/code&gt; for any of them in turn:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v:lnum: the line being evaluated&#xA;getline(): get the line of text for a line number&#xA;==: equals&#xA;=~: matches&#xA;&amp;lt;cond&amp;gt;?&amp;lt;if-true&amp;gt;:&amp;lt;if-false&amp;gt;: evaluates to &amp;lt;if-true&amp;gt; if &amp;lt;cond&amp;gt; is true, else to &amp;lt;if-false&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've broken down these expressions by their parts below to help illustrate their meaning:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 Will return 1 for all lines starting with a tab and 0 for other lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v:lnum                      the current line number&#xA;getline(v:lnum)             the text of the current line&#xA;getline(v:lnum)[0]          the first character of the current line&#xA;getline(v:lnum)[0]==\&quot;\\t\&quot; the first char of the current line is 'tab'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;3 Ends folds on blank lines after paragraphs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; getline(v:lnum)=~'^\\s*$'                                       current line is only spaces&#xA;                              getline(v:lnum+1)=~'\\S'           next line has non-space&#xA;(getline(v:lnum)=~'^\\s*$' &amp;amp;&amp;amp; getline(v:lnum+1)=~'\\S') ? '&amp;lt;1'   if both of these: &amp;lt;1&#xA;                                                              :1 otherwise: 1&#xA;(getline(v:lnum)=~'^\\s*$' &amp;amp;&amp;amp; getline(v:lnum+1)=~'\\S') ? '&amp;lt;1':1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;4 Starts folds on blank lines beginning paragraphs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(getline(v:lnum-1)=~'^\\s*$'                                     previous line only spaces&#xA;                                getline(v:lnum)=~'\\S'           this line has non-space&#xA;(getline(v:lnum-1)=~'^\\s*$' &amp;amp;&amp;amp; getline(v:lnum)=~'\\S') ? '&amp;gt;1'   if both of these: &amp;gt;1&#xA;                                                              :1 otherwise: 1&#xA;(getline(v:lnum-1)=~'^\\s*$' &amp;amp;&amp;amp; getline(v:lnum)=~'\\S') ? '&amp;gt;1':1 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The meanings of &lt;code&gt;&amp;lt;1&lt;/code&gt;, &lt;code&gt;&amp;gt;1&lt;/code&gt;, etc. are right below these expressions in &lt;code&gt;:help fold-expr&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="680" LastEditorUserId="51" LastEditDate="2015-02-24T19:00:47.737" LastActivityDate="2015-02-24T19:00:47.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2180" PostTypeId="2" ParentId="2176" CreationDate="2015-02-24T19:01:16.123" Score="1" Body="&lt;p&gt;Accidentally posted my answer as a comment and submitted it early. Darn mobile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My understanding is that the expression should return a number, and that number will be used to determine at which level the given line will be folded. 0 is not folded, 1 is the outermost fold, 2 is a fold nested inside a level 1 fold, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The expressions in the examples look like they'd evaluate to true or false. VimScript doesn't have a proper Boolean type, so this will really be 1 or 0, which are valid fold levels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could write your own expression using VimScript that is as simple as returning 1 or 0, or more complicated, allowing for nested folds.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-02-24T19:01:16.123" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2181" PostTypeId="1" AcceptedAnswerId="2185" CreationDate="2015-02-24T19:01:20.807" Score="2" ViewCount="553" Body="&lt;p&gt;In my vimrc file, &lt;code&gt;nmap &amp;lt;tab&amp;gt; v&amp;gt;&lt;/code&gt; doesn't work. But other key binding, such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;s-tab&amp;gt; v&amp;lt;&#xA;vmap &amp;lt;tab&amp;gt; &amp;gt;gv&#xA;vmap &amp;lt;s-tab&amp;gt; &amp;lt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to search for &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; in vimrc, and found just one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;tab&amp;gt; v&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my complete vimrc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/arcticlion/dotfile/blob/master/.vimrc&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arcticlion/dotfile/blob/master/.vimrc&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/arcticlion/dotfile/blob/master/.vim/plugin.vim&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arcticlion/dotfile/blob/master/.vim/plugin.vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1037" LastEditorUserId="51" LastEditDate="2015-02-24T19:09:17.070" LastActivityDate="2015-02-24T21:29:39.400" Title="Why doesn't `nmap &lt;tab&gt; v&gt;` work?" Tags="|key-bindings|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="2185" PostTypeId="2" ParentId="2181" CreationDate="2015-02-24T21:29:39.400" Score="2" Body="&lt;p&gt;Most likely, this is conflicting with some other mapping in your .vimrc or in a plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After launching vim, see what &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; is mapped to (and what last mapped it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose nmap &amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should expect this to say something along the lines of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n &amp;lt;tab&amp;gt;          * v&amp;gt;&#xA;        Last set from ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In general when you suspect that a plugin/customization may be interfering with something, you should follow the steps outlined in the aforementioned &quot;&lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file?s=1%7C0.5919&quot;&gt;How do I debug my vimrc file?&lt;/a&gt;&quot;. When dealing specifically with mappings, the steps I outlined above are sometimes a quick shortcut to diagnosing the problem.&lt;/p&gt;&#xA;" OwnerUserId="680" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-24T21:29:39.400" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2186" PostTypeId="2" ParentId="2170" CreationDate="2015-02-24T21:58:12.223" Score="0" Body="&lt;p&gt;If you are using &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow&quot;&gt;surround.vim&lt;/a&gt;. For example add the following to &lt;code&gt;~/.vim/after/ftplugin/latex.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:surround_{char2nr('e')} = &quot;\\begin{\1environment: \1}\r\\end{\1\1}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can do &lt;code&gt;&amp;lt;c-s&amp;gt;b&lt;/code&gt; in insert mode to add the surrounding. You can also surround text with other surround operators like &lt;code&gt;ys&lt;/code&gt;, &lt;code&gt;yS&lt;/code&gt; and &lt;code&gt;v_S&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h surround&#xA;:h surround-customizing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-02-24T21:58:12.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2187" PostTypeId="2" ParentId="2129" CreationDate="2015-02-24T22:20:50.977" Score="42" Body="&lt;p&gt;This is what I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;b :ls&amp;lt;CR&amp;gt;:b&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now pressing &lt;code&gt;\b&lt;/code&gt; will &lt;strong&gt;list the available buffers&lt;/strong&gt; and prepare &lt;code&gt;:b&lt;/code&gt; for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can just type the &lt;strong&gt;buffer number&lt;/strong&gt;, and hit Enter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can type &lt;strong&gt;part of the filename&lt;/strong&gt;, and hit Enter.  (However I usually hit Tab before hitting Enter, to check I got the right buffer.  If not, I continue cycling with Tab until I get the one I wanted.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In fact, I use a slightly tweaked version of the above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-e&amp;gt; :set nomore &amp;lt;Bar&amp;gt; :ls &amp;lt;Bar&amp;gt; :set more &amp;lt;CR&amp;gt;:b&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will prevent the &lt;code&gt;-- More --&lt;/code&gt; prompt from appearing when you have more buffers than available lines to display them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you usually have the &lt;code&gt;'more'&lt;/code&gt; option disabled anyway, this mapping will really annoy you, because it re-enables the &lt;code&gt;'more'&lt;/code&gt; option after doing &lt;code&gt;ls&lt;/code&gt;!&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-02-24T22:20:50.977" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="2188" PostTypeId="1" CreationDate="2015-02-25T00:43:06.350" Score="2" ViewCount="229" Body="&lt;p&gt;Would like to send a line to an external programme and inspect output in the minibuffer or a new buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't want the output to replace original text. How to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In gnu emacs there's &lt;code&gt;M-|&lt;/code&gt; (shell-command-on-region) which will use the either minibuffer or a dedicated &quot;command output&quot; buffer , determined by output length .&lt;/p&gt;&#xA;" OwnerUserId="1047" LastEditorUserId="51" LastEditDate="2015-08-07T12:45:11.367" LastActivityDate="2015-08-07T12:45:11.367" Title="inspect filter output in minibuffer or a new buffer" Tags="|external-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2189" PostTypeId="1" AcceptedAnswerId="2190" CreationDate="2015-02-25T00:47:43.653" Score="5" ViewCount="301" Body="&lt;p&gt;Say that I have some semi-complex keymaps like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;s :%s/\s\+$//e&#xA;nnoremap &amp;lt;Leader&amp;gt;u mz:r!uuidgen&amp;lt;CR&amp;gt;dW&quot;_dd`zp&quot;&#xA;nnoremap &amp;lt;Leader&amp;gt;d g/\v&quot;([^&quot;]|\n)*&quot;\ze\n\s*\[.*\]/normal gngq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In general, how does one translate an arbitrary keymap to a VimL function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following does not work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Trim()&#xA;  normal mz:%s/\s\+$//e&amp;lt;cr&amp;gt;`z&#xA;endfunction&#xA;command! Trim call Trim()&#xA;&#xA;function! UUID()&#xA;  normal mz:r!uuidgen&amp;lt;CR&amp;gt;dW&quot;_dd`zp&#xA;endfunction&#xA;command! UUID call UUID()&#xA;&#xA;function! FormatClojureDocStrings()&#xA;  normal mz:g/\v&quot;([^&quot;]|\n)*&quot;\ze\n\s*\[.*\]/normal gngq&amp;lt;cr&amp;gt;`z&#xA;endfunction&#xA;command! FormatClojureDocStrings call FormatClojureDocStrings()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user489" LastEditorUserId="51" LastEditDate="2015-03-23T14:21:30.893" LastActivityDate="2015-03-23T17:53:08.373" Title="Translating Keymaps to Ex Commands" Tags="|key-bindings|ex-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2190" PostTypeId="2" ParentId="2189" CreationDate="2015-02-25T01:29:12.490" Score="3" Body="&lt;p&gt;This is because special keys like &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; are not translated to their actual meaning in normal commands.  Thus, &lt;code&gt;normal &amp;lt;esc&amp;gt;&lt;/code&gt; translates to literally typing &lt;code&gt;less-than e s c greater-than&lt;/code&gt;.  You can get around this by doing something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal &amp;lt;esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your case, it would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Trim()&#xA;  execute &quot;normal mz:%s/\s\+$//e&amp;lt;cr&amp;gt;`z&quot;&#xA;endfunction&#xA;command! Trim call Trim()&#xA;&#xA;function! UUID()&#xA;  execute &quot;normal mz:r!uuidgen&amp;lt;CR&amp;gt;dW\&quot;_dd`zp&quot;&#xA;endfunction&#xA;command! UUID call UUID()&#xA;&#xA;function! FormatClojureDocStrings()&#xA;  execute &quot;normal mz:g/\v\&quot;([^\&quot;]|\n)*\&quot;\ze\n\s*\[.*\]/normal gngq&amp;lt;cr&amp;gt;`z&quot;&#xA;endfunction&#xA;command! FormatClojureDocStrings call FormatClojureDocStrings()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that these special keys will only be translated if they are in double quotes.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="343" LastEditDate="2015-03-23T17:53:08.373" LastActivityDate="2015-03-23T17:53:08.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2191" PostTypeId="2" ParentId="2189" CreationDate="2015-02-25T01:56:18.760" Score="4" Body="&lt;p&gt;Typically you divide your commands up into 3 categories:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Normal commands that need to run via &lt;code&gt;:normal&lt;/code&gt;/&lt;code&gt;:normal!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Ex-commands which can be run without  the leading &lt;code&gt;:&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Commands that need to &quot;built up&quot; use &lt;code&gt;execute&lt;/code&gt;. e.g. &lt;code&gt;execute &quot;s/&quot; . pat . &quot;/&quot;. rep . &quot;/g&quot;&lt;/code&gt;. (This is actually just a specialization of the previous rule)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Lets take a do a quick-n-dirty attempt at your UUID command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! UUID call s:uuid()&#xA;function s:uuid()&#xA;  normal! mz&#xA;  r!uuidgen&#xA;  normal! dW&quot;_dd`zp&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now we have a few issues with this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We are mutating the &lt;code&gt;z&lt;/code&gt; mark and the unnamed register so this may cause surprises. The typical solution is to save the register and restore the register later in the function&lt;/li&gt;&#xA;&lt;li&gt;Ex-commands typically do things linewise so this command is a bit out of the ordinary. (This may be better as a mapping &lt;code&gt;&amp;lt;c-r&amp;gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; perhaps)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Fixing/side-stepping the mutation issues by using the expression register, &lt;code&gt;&quot;=,&lt;/code&gt; and the &lt;code&gt;system()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! UUID execute &quot;normal! a\&amp;lt;c-r&amp;gt;=substitute(system('uuidgen'), '\\n', '', '')\&amp;lt;cr&amp;gt;\&amp;lt;esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :normal&#xA;:h :execute&#xA;:h i_ctrl-r&#xA;:h system(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may also want to look at Steve Losh's &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-02-25T02:44:42.950" LastActivityDate="2015-02-25T02:44:42.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2192" PostTypeId="2" ParentId="2188" CreationDate="2015-02-25T02:20:12.517" Score="6" Body="&lt;p&gt;Assuming you want to send the current line, you can do it this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yy                 &quot; Yank the current line&#xA;:new               &quot; Split open a new buffer/window&#xA;Vp                 &quot; Paste, replacing the empty line&#xA;:%!&amp;lt;command&amp;gt;       &quot; Process buffer with your command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know if there is a shorter way.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's combine this, and Matt Boehm's suggestion, into a mapping for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;&amp;lt;Bar&amp;gt; &quot;zyy:new&amp;lt;CR&amp;gt;:set buftype=nofile bufhidden=wipeout noswapfile&amp;lt;CR&amp;gt;V&quot;zp:redraw&amp;lt;CR&amp;gt;:%!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put that in your ~/.vimrc and now you can just hit &lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;|&lt;/kbd&gt; when you want to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I took the liberty of changing Matt's &lt;code&gt;bufhidden=hide&lt;/code&gt; to &lt;code&gt;bufhidden=wipeout&lt;/code&gt; which will will make the scratch buffer &lt;em&gt;very&lt;/em&gt; temporary.  Now it will automatically destroy itself if you close the newly split window (for example with &lt;kbd&gt;Ctrl-W C&lt;/kbd&gt;).  But beware: it will also &lt;strong&gt;discard any unsaved changes&lt;/strong&gt;.  Choose whichever behaviour you prefer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We use the 'z' register in this mapping to avoid clobbering the default yank register, which might have something useful in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:redraw&lt;/code&gt; helps to show what is going on but is entirely optional.  Without it, you won't see the split window until you have executed (or cancelled) the external command.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-02-26T07:58:26.563" LastActivityDate="2015-02-26T07:58:26.563" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2193" PostTypeId="1" CreationDate="2015-02-25T02:33:56.683" Score="9" ViewCount="1689" Body="&lt;p&gt;I needed to edit a lot of files recently for a small change in each file.  To get to each file, I browsed through NERDtree and opened one file after another.  As I opened more and more files, I noticed that my memory usage grew a LOT.  Closing vim gave me a lot of memory back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have quite a few plugins installed, but I'm thinking that the reason my memory usage grew so drastically was due to the number of buffers I had open after a few edits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to limit the number of buffers that vim allows to be open at one time, automatically closing old buffers with respect to editing time?&lt;/p&gt;&#xA;" OwnerUserId="922" LastActivityDate="2020-08-01T15:25:32.613" Title="Automatically close oldest buffers?" Tags="|buffers|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2194" PostTypeId="2" ParentId="2193" CreationDate="2015-02-25T04:50:56.190" Score="3" Body="&lt;p&gt;I am not sure how to get the oldest buffers with respect to editing time, but one could, instead, try to close the oldest unedited buffers. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function CloseLast ()&#xA;    python &amp;lt;&amp;lt;EOF&#xA;import vim&#xA;N = 10&#xA;listed_buffers = [b for b in vim.buffers if b.options['buflisted'] and not b.options['modified']]&#xA;for i in range (0, len (listed_buffers) - N):&#xA;    vim.command (':bd' + str (listed_buffers[i].number))&#xA;EOF&#xA;endfunction&#xA;&#xA;autocmd BufNew * call CloseLast()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vim.buffers&lt;/code&gt; is a list of every buffer opened in the current session, so it also includes unlisted buffers. It is not the same as the list returned by &lt;code&gt;:ls&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Therefore, we must filter out the hidden or deleted buffers. This can be checked using &lt;code&gt;options['buflisted']&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Similarly, &lt;code&gt;options['modified']&lt;/code&gt; lets us check if the buffer is modified.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;N&lt;/code&gt; is the number of unmodified, listed buffers you want open.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks to &lt;a href=&quot;https://vi.stackexchange.com/a/2198/205&quot;&gt;Luc Hermitte's answer&lt;/a&gt; from which I learnt how to get the timestamps, you could use the following instead, to get the oldest inactive kicked out first:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;listed_buffers = (b for b in vim.buffers if b.options['buflisted'] and not b.options['modified'])&#xA;oldest_buffers = sorted (listed_buffers, key = lambda b: eval('getftime(&quot;' + b.name + '&quot;)'))&#xA;for i in range (0, len (oldest_buffers) - N):&#xA;    vim.command (':bd' + str (oldest_buffers[i].number))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2015-02-25T14:37:20.160" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2195" PostTypeId="1" AcceptedAnswerId="2205" CreationDate="2015-02-25T08:04:26.797" Score="8" ViewCount="753" Body="&lt;p&gt;While trying to devise a solution to &lt;a href=&quot;https://vi.stackexchange.com/q/2009/205&quot;&gt;How do I make vim look in a set of directories for a file, if it doesn&amp;#39;t exist in the current directory?&lt;/a&gt;, I have got so far using Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function LookupFiles ()&#xA;    python &amp;lt;&amp;lt;EOF&#xA;from os.path import *&#xA;from vim import *&#xA;current_file = eval ('expand(&quot;%&quot;)')&#xA;PATHS = ['~', '~/.vim', '/etc']&#xA;&#xA;if not isabs (current_file):&#xA;    for p in map (expanduser, PATHS):&#xA;        if isfile (join (p, current_file)):&#xA;            current.buffer.name = join (p, current_file)&#xA;            break&#xA;EOF&#xA;endfunction&#xA;&#xA;autocmd BufNewFile * call LookupFiles() | e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Simply assigning a path to &lt;code&gt;buffer.name&lt;/code&gt; doesn't cause it to load that file. So I had to call &lt;code&gt;:edit&lt;/code&gt; manually, which tried both with &lt;code&gt;vim.command('e')&lt;/code&gt; and the &lt;code&gt;| e&lt;/code&gt; that you see now. However, for a file opened this way, syntax highlighting isn't present (as well as other plugin effects, from what I can tell). If I manually do &lt;code&gt;:e&lt;/code&gt; again, everything becomes all right. Why is this, and how can I use Python to correctly open the file? I'd rather not open another buffer unnecessarily, but if that's the case, so be it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Assigning to &lt;code&gt;current.buffer.name&lt;/code&gt; has its own problem: even though vim can load the buffer just fine with &lt;code&gt;e&lt;/code&gt;, Vim continues to see it as an entirely new file, and attempts to write through a warning that the file already exists. So I adapted to this version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function LookupFiles ()&#xA;    python &amp;lt;&amp;lt;EOF&#xA;from os.path import *&#xA;from vim import *&#xA;current_file = eval ('expand(&quot;%&quot;)')&#xA;current_index = str (current.buffer.number)&#xA;PATHS = ['~', '~/.vim', '/etc']&#xA;&#xA;if current_file != '' and  not isfile (current_file):&#xA;    for p in map (expanduser, PATHS):&#xA;        f = join (p, current_file)&#xA;        if isfile (f):          &#xA;            command ('bad ' + f)&#xA;            command ('bd ' + current_index)&#xA;            break&#xA;EOF&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem of syntax highlighting and other plugin effects still show with this method.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-26T13:26:33.933" Title="Why don't I get syntax highlighting when I open a file in an autocmd?" Tags="|syntax-highlighting|vimscript|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2196" PostTypeId="1" AcceptedAnswerId="2200" CreationDate="2015-02-25T11:11:19.163" Score="4" ViewCount="781" Body="&lt;p&gt;I am working on an omni-completion script where I use &lt;code&gt;taglist()&lt;/code&gt; to search for the existence of a certain word. After obtaining that tag I now need to quickly jump to where the tag is defined and analyze the code around it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this in a VimScript? Because I need to do this within an omni-completion script, I cannot change the window context and would prefer to keep the jump list intact.&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="599" LastEditDate="2015-03-05T21:46:32.057" LastActivityDate="2015-03-17T12:58:01.303" Title="Following a tag in a VimScript" Tags="|vimscript|tags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2197" PostTypeId="2" ParentId="310" CreationDate="2015-02-25T12:15:56.240" Score="9" Body="&lt;p&gt;After some experimentation I've found this to be the best way; it should behave the same as &lt;code&gt;vim -p&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup open-tabs&#xA;    au!&#xA;    au VimEnter * ++nested if !&amp;amp;diff | tab all | tabfirst | endif&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;tab all&lt;/code&gt; opens all the entries in the argument list (&lt;code&gt;:args&lt;/code&gt;) in a tab. The argument list is a list of files you passed to Vim on startup. And the &lt;code&gt;tabfirst&lt;/code&gt; makes sure the first tab is focused rather than the last (this is optional).&lt;/p&gt;&#xA;&lt;p&gt;We &lt;em&gt;don't&lt;/em&gt; do any of this if &lt;code&gt;&amp;amp;diff&lt;/code&gt; is set; if it is, we're using &lt;code&gt;vimdiff&lt;/code&gt; or &lt;code&gt;vim -d&lt;/code&gt;, where we &lt;em&gt;want&lt;/em&gt; to have 2 windows, and not 2 tabs.&lt;/p&gt;&#xA;&lt;p&gt;In &lt;a href=&quot;https://vi.stackexchange.com/a/2109/51&quot;&gt;this answer&lt;/a&gt; I've also written a bit about the argument list and &lt;code&gt;tab all&lt;/code&gt; which may be of interest.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;++nested&lt;/code&gt; part is required to run autocommands such as &lt;code&gt;BufRead&lt;/code&gt; for the files we open.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Some notes about the other solutions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;tab ball&lt;/code&gt; opens a tab for every entry in the &lt;em&gt;buffer list&lt;/em&gt;, not the argument list. The &amp;quot;problem&amp;quot; is that the buffer list may be saved in the viminfo file when quiting and is restored on startup if &lt;code&gt;%&lt;/code&gt; is in &lt;code&gt;'viminfo'&lt;/code&gt; (not enabled by default). So if you just type &lt;code&gt;vim&lt;/code&gt; it will open those files. Personally I wouldn't want that, though I can imagine some people finding it useful; so use what you prefer.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;set tabpagemax=9999&lt;/code&gt; is not required; the default of &lt;code&gt;10&lt;/code&gt; should be fine. You can increase this in your vimrc if you want more, but &lt;code&gt;9999&lt;/code&gt; is a silly number. If you use &lt;code&gt;-p&lt;/code&gt;, you also get &lt;code&gt;tabpagemax&lt;/code&gt; tabs so this should respect that. Remember that this will open (read) a buffer on startup, so it's rather slow.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;autocmd VimEnter * argdo tabedit&lt;/code&gt; is just the same way of saying &lt;code&gt;tab all&lt;/code&gt;. However, the initial buffer isn't cleared, so you're left with that extra tab (&lt;code&gt;tab all&lt;/code&gt; replaces all tabs). To fix this, you need the workaround in Josh Petrie's answer.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-10-27T21:35:44.353" LastActivityDate="2020-10-27T21:35:44.353" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2198" PostTypeId="2" ParentId="2193" CreationDate="2015-02-25T14:12:03.120" Score="6" Body="&lt;p&gt;The following should answer your question.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! s:SortTimeStamps(lhs, rhs)&#xA;  return a:lhs[1] &amp;gt; a:rhs[1] ?  1&#xA;     \ : a:lhs[1] &amp;lt; a:rhs[1] ? -1&#xA;     \ :                        0&#xA;endfunction&#xA;&#xA;function! s:Close(nb_to_keep)&#xA;  let saved_buffers = filter(range(0, bufnr('$')), 'buflisted(v:val) &amp;amp;&amp;amp; ! getbufvar(v:val, &amp;quot;&amp;amp;modified&amp;quot;)')&#xA;  let times = map(copy(saved_buffers), '[(v:val), getftime(bufname(v:val))]')&#xA;  call filter(times, 'v:val[1] &amp;gt; 0')&#xA;  call sort(times, function('s:SortTimeStamps'))&#xA;  let nb_to_keep = min([a:nb_to_keep, len(times)])&#xA;  let buffers_to_strip = map(copy(times[0:(nb_to_keep-1)]), 'v:val[0]')&#xA;  exe 'bw '.join(buffers_to_strip, ' ') &#xA;endfunction&#xA;&#xA;&amp;quot; Two ways to use it&#xA;&amp;quot; - manually&#xA;command! -nargs=1 CloseOldBuffers call s:Close(&amp;lt;args&amp;gt;)&#xA;&amp;quot; - or automatically&#xA;augroup CloseOldBuffers&#xA;  au!&#xA;  au BufNew * call s:Close(g:nb_buffers_to_keep)&#xA;augroup END&#xA;&amp;quot; and don't forget to set the option in your .vimrc&#xA;let g:nb_buffers_to_keep = 42&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is to be dropped into a plugin or in your vimrc config. Then, you'll have to choose how to use it.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2020-08-01T15:25:32.613" LastActivityDate="2020-08-01T15:25:32.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2199" PostTypeId="1" AcceptedAnswerId="2201" CreationDate="2015-02-25T14:28:49.303" Score="45" ViewCount="11760" Body="&lt;p&gt;To insert an &lt;a href=&quot;http://www.thepunctuationguide.com/en-dash.html&quot;&gt;en dash&lt;/a&gt;, I use &lt;code&gt;^v u 2014&lt;/code&gt; which is seven keypresses. Is there an easier way? (I was looking at digraphs and didn't find en dash there.)&lt;/p&gt;&#xA;" OwnerUserId="1056" LastEditorUserId="24" LastEditDate="2015-02-25T18:06:39.150" LastActivityDate="2017-09-06T22:43:08.237" Title="What is the easiest way to insert en dash in Vim?" Tags="|insert-mode|unicode|input-methods|" AnswerCount="7" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="2200" PostTypeId="2" ParentId="2196" CreationDate="2015-02-25T14:36:20.747" Score="4" Body="&lt;p&gt;You can obtain the filename and the line number (/search command) from the selected tag.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let tag = taglist()[42]&#xA;exe 'e '. (tag.filename)&#xA;exe ':'.(tag.cmd)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this won't push your 'open-and-go-to-the-right-place' into the tag stack as &lt;code&gt;:tag&lt;/code&gt; would have. I've been able to trick vim into doing it in my lh-tags plugin.&#xA;The current version of the (GPLv3) code that do so is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; # Tag push/pop {{{2&#xA;&quot; internal tmp tags file {{{3&#xA;if !exists('s:tags_jump')&#xA;  let s:tags_jump = tempname()&#xA;  let &amp;amp;tags .= ','.s:tags_jump&#xA;  let s:lines = []&#xA;endif&#xA;&#xA;let s:lines = []&#xA;&#xA;&quot; lh#tags#jump {{{3&#xA;let s:k_tag_name__ = '__jump_tag__'&#xA;let s:k_nb_digits  = 5 &quot; works with ~1 million jumps. Should be enough&#xA;function! lh#tags#jump(tagentry)&#xA;  let last = len(s:lines)+1&#xA;  &quot; Assert s:tagentry.filename == expand('%:p')&#xA;  let filename = expand('%:p')&#xA;&#xA;  let tag_name = s:k_tag_name__.repeat('0', s:k_nb_digits-strlen(last)).last&#xA;  let l = tag_name&#xA;    \ . &quot;\t&quot; . (filename)&#xA;    \ . &quot;\t&quot; . (a:tagentry.cmd)&#xA;&#xA;&#xA;  &quot; test whether a new digit is used. In that case renumber every tags to have&#xA;  &quot; a lexical order&#xA;  call add(s:lines, l)&#xA;  call writefile(s:lines, s:tags_jump)&#xA;  if exists('&amp;amp;l:tags')&#xA;    exe 'setlocal tags+='.s:tags_jump&#xA;  endif&#xA;  exe 'tag '.tag_name&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The plugin is maintained there: &lt;a href=&quot;https://github.com/LucHermitte/lh-tags&quot; rel=&quot;nofollow&quot;&gt;https://github.com/LucHermitte/lh-tags&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update since the clarifications in the question: You can use &lt;code&gt;readfile()&lt;/code&gt; (IIRC) to load the file associated to the selected tag, without moving the cursor or anything. Then, if the tags file uses line numbers, finding the context will be trivial. If the command is a search command, use &lt;code&gt;filter()&lt;/code&gt;, or better &lt;code&gt;match()&lt;/code&gt; to get the context you are interesting in.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2015-03-17T12:58:01.303" LastActivityDate="2015-03-17T12:58:01.303" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2201" PostTypeId="2" ParentId="2199" CreationDate="2015-02-25T14:36:29.860" Score="60" Body="&lt;p&gt;You can use digraphs: &lt;kbd&gt;Ctrl+k&lt;/kbd&gt;&lt;kbd&gt;-&lt;/kbd&gt;&lt;kbd&gt;N&lt;/kbd&gt; (with a capital &lt;code&gt;N&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Insert mode, digraphs are entered by &lt;kbd&gt;Ctrl+k&lt;/kbd&gt; followed by a two-character sequence. For en-dash, the sequence is &lt;code&gt;-N&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Quincy pointed out, &lt;code&gt;U+2014&lt;/code&gt; is em-dash. If you want to enter that using digraphs, the sequence is &lt;code&gt;-M&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="6471" LastEditDate="2016-02-18T04:37:15.520" LastActivityDate="2016-02-18T04:37:15.520" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2202" PostTypeId="2" ParentId="2199" CreationDate="2015-02-25T14:39:39.090" Score="10" Body="&lt;p&gt;If there isn't a predefined digraph or you want a more memorable key sequence, then you can define digraphs in your vimrc.  For example, the below will define two digraphs for en dash (8211) and em dash (8212) which mirror their XCompose sequences.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digraph -. 8211 -- 8212&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:digraph&lt;/code&gt; command expects the value to be specified in decimal rather than hex, which is why it's 8211 for en dash rather than 2013.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2015-02-25T14:45:28.293" LastActivityDate="2015-02-25T14:45:28.293" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2203" PostTypeId="2" ParentId="2193" CreationDate="2015-02-25T14:58:23.267" Score="7" Body="&lt;p&gt;Let's solve the problem, not treat the symptoms. Vim shouldn't normally use large amounts of memory. It would be best isolate the issue. Some tips to help find the culprit:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Disable plugins (use a binary search to make it faster)&lt;/li&gt;&#xA;&lt;li&gt;Reduce your &lt;code&gt;~/.vimrc&lt;/code&gt; down to see if anything in there is the problem&lt;/li&gt;&#xA;&lt;li&gt;Disable your &lt;code&gt;~/.vimrc&lt;/code&gt; completely via &lt;code&gt;vim -u NONE&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file?s=1|0.9748&quot;&gt;How do I debug my vimrc file?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find a memory bug with a plugin then contact the plugin developer. If you find a memory bug with Vim then submit a bug report with steps to reproduce the error. See &lt;code&gt;:h bugs&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="51" LastEditDate="2015-02-25T16:31:30.990" LastActivityDate="2015-02-25T16:31:30.990" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2204" PostTypeId="2" ParentId="2199" CreationDate="2015-02-25T15:02:04.733" Score="3" Body="&lt;p&gt;On my French AZERTY Mac keyboard, I can insert an en dash with &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;-&lt;/kbd&gt;. Your mileage may obviously vary.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-02-25T15:02:04.733" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2205" PostTypeId="2" ParentId="2195" CreationDate="2015-02-25T15:18:19.243" Score="6" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-nested&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help autocmd-nested&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;By default, autocommands do not nest.  If you use &quot;:e&quot; or &quot;:w&quot; in an&#xA;autocommand, Vim does not execute the BufRead and BufWrite autocommands for&#xA;those commands.  If you do want this, use the &quot;nested&quot; flag for those commands&#xA;in which you want nesting.  For example: &amp;gt;&#xA;  :autocmd FileChangedShell *.c nested e!&#xA;The nesting is limited to 10 levels to get out of recursive loops.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your case, instead of this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;current.buffer.name = join (p, current_file)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim.command(&quot;edit &quot; + join(p, current_file))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And to have the syntax highlighting work, you need to update your autocmd to read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile * nested call LookupFiles()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="680" LastEditorUserId="205" LastEditDate="2015-02-26T13:26:33.933" LastActivityDate="2015-02-26T13:26:33.933" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2206" PostTypeId="2" ParentId="2009" CreationDate="2015-02-25T15:27:15.783" Score="6" Body="&lt;p&gt;Vim's &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27path%27&quot;&gt;&lt;code&gt;'path'&lt;/code&gt;&lt;/a&gt; option allows you to specify directories which commands like &lt;code&gt;gf&lt;/code&gt; and &lt;code&gt;:find&lt;/code&gt; will search for a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only want this functionality to trigger for a specific set of files, then you could use an autocmd to automatically &quot;redirect&quot; your &lt;code&gt;:edit&lt;/code&gt; command to the file in one of the &lt;code&gt;'path'&lt;/code&gt; directories.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path+=~/&#xA;function! FindInPath(name)&#xA;    let found = findfile(a:name)&#xA;    if !empty(found)&#xA;        exe 'silent keepalt file '. fnameescape(found)&#xA;        edit&#xA;    endif&#xA;endfunction&#xA;autocmd BufNewFile .vimrc,.zshrc nested call FindInPath(expand('&amp;lt;afile&amp;gt;'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses the &lt;code&gt;BufNewFile&lt;/code&gt; autocmd as a trigger for &lt;code&gt;file not found, so try to find it somewhere else&lt;/code&gt;.  When that situation is detected, use &lt;code&gt;findfile()&lt;/code&gt; to try to find the file in the &lt;code&gt;'path'&lt;/code&gt; directories.  If it is found, change the name of the current buffer to that file and re-edit the buffer, otherwise just continue using the new buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;nested&lt;/code&gt; qualifier is required here since autocmds don't normally nest.  In this case, you do want the typical autocmds to trigger when the &lt;code&gt;:edit&lt;/code&gt; command opens your file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this will still create an extra buffer as compared to just editing the file manually.  By the time &lt;code&gt;BufNewFile&lt;/code&gt; is run, the buffer for the originally specified file name is already created.  Using &lt;code&gt;:file&lt;/code&gt; to change the name of a buffer creates a new, unloaded buffer with the original name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you always want to search in &lt;code&gt;'path'&lt;/code&gt;, then the autocmd can simply be changed to use the &lt;code&gt;*&lt;/code&gt; file pattern rather than specifying certain files.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's an updated version which should match your requirements better.  It uses &lt;code&gt;:find&lt;/code&gt; to directly open the file instead of setting the buffer name based on the result of &lt;code&gt;findfile()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FindInPath(name)&#xA;    let path=&amp;amp;path&#xA;    &quot; Add any extra directories to the normal search path&#xA;    set path+=~,~/.vim,/etc&#xA;    &quot; If :find finds a file, then wipeout the buffer that was created for the &quot;new&quot; file&#xA;    setlocal bufhidden=wipe&#xA;    exe 'silent! keepalt find '. fnameescape(a:name)&#xA;    &quot; Restore 'path' and 'bufhidden' to their normal values&#xA;    let &amp;amp;path=path&#xA;    set bufhidden&amp;lt;&#xA;endfunction&#xA;autocmd BufNewFile * nested call FindInPath(expand('&amp;lt;afile&amp;gt;'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This solves the problem in the previous function where Vim would complain when trying to save the &lt;code&gt;:file&lt;/code&gt;-named buffer.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2015-02-26T15:02:56.527" LastActivityDate="2015-02-26T15:02:56.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2207" PostTypeId="1" AcceptedAnswerId="2208" CreationDate="2015-02-25T15:28:07.163" Score="36" ViewCount="23351" Body="&lt;p&gt;When I do &lt;code&gt;vimdiff file2 file1&lt;/code&gt;, &lt;code&gt;file2&lt;/code&gt; naturally goes on the left and &lt;code&gt;file1&lt;/code&gt; on the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes I find that I put them the wrong way round, so I'd like to be able to switch them round without leaving Vim. Is that possible?&lt;/p&gt;&#xA;" OwnerUserId="180" LastEditorUserId="51" LastEditDate="2015-02-25T15:55:30.233" LastActivityDate="2015-02-27T20:26:52.287" Title="In Vimdiff, how do I switch the left and right panes?" Tags="|split|vimdiff|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2208" PostTypeId="2" ParentId="2207" CreationDate="2015-02-25T15:38:56.260" Score="34" Body="&lt;p&gt;You can use &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;-&lt;kbd&gt;x&lt;/kbd&gt;. From &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#CTRL-W_x&quot;&gt;&lt;code&gt;:he  CTRL-W_x&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-W x                                            CTRL-W_x CTRL-W_CTRL-X&#xA;CTRL-W CTRL-X   Without count: Exchange current window with next one.  If there&#xA;                is no next window, exchange with previous window.&#xA;                With count: Exchange current window with Nth window (first&#xA;                window is 1).  The cursor is put in the other window.&#xA;                When vertical and horizontal window splits are mixed, the&#xA;                exchange is only done in the row or column of windows that the&#xA;                current window is in.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-02-25T15:38:56.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2209" PostTypeId="2" ParentId="2207" CreationDate="2015-02-25T15:43:26.113" Score="14" Body="&lt;p&gt;As you would switch any other window, &lt;code&gt;&amp;lt;c-w&amp;gt;x&lt;/code&gt; or &lt;code&gt;&amp;lt;c-w&amp;gt;r&lt;/code&gt; are two options. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having only two windows opended &lt;code&gt;&amp;lt;c-w&amp;gt;k&lt;/code&gt; will switch them and leave the cursor in the window where it was before the switch (i.e. if before the switch the focused window is on the left, after the switch it will be on the left).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;x&lt;/code&gt; will switch the windows and move the cursor in the switched window (i.e. the focused window remain on the left if it was on the left).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#window-moving&quot;&gt;&lt;code&gt;:help window-moving&lt;/code&gt;&lt;/a&gt; for more command to move windows aroud.&lt;/p&gt;&#xA;" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2015-02-25T15:54:12.387" LastActivityDate="2015-02-25T15:54:12.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2210" PostTypeId="2" ParentId="365" CreationDate="2015-02-25T15:53:30.740" Score="11" Body="&lt;p&gt;Because I was curious how well this would work, I've hacked something together&#xA;that sort of works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2AA8m.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned in the comments on the earlier answer, the only way to do this is&#xA;to fill up regions with spaces; which is exactly what we do; before write, we&#xA;remove these spaces, so you shouldn't be bothering anyone else with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this example is very specific for the markdown filetype!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Side effects&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Copying text will also copy a lot of spaces&lt;/li&gt;&#xA;&lt;li&gt;Using &lt;kbd&gt;$&lt;/kbd&gt; and &lt;kbd&gt;End&lt;/kbd&gt; no longer work as expected (it goes to column 80), and keys such as&#xA;&lt;kbd&gt;j&lt;/kbd&gt; and &lt;kbd&gt;k&lt;/kbd&gt; also behave different.&lt;/li&gt;&#xA;&lt;li&gt;The background is not displayed when &lt;code&gt;'list'&lt;/code&gt; is enabled&lt;/li&gt;&#xA;&lt;li&gt;Completely blank lines don't work, you need to manually add a tab or 4 spaces&lt;/li&gt;&#xA;&lt;li&gt;... Perhaps more?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;First, you need to add this to your &lt;code&gt;~/.vim/after/syntax/markdown.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn clear markdownCodeBlock                                                 &#xA;syn region markdownCodeBlock start=&quot;    \|\t&quot; end=&quot;$&quot;                       &#xA;hi def markdownCodeBlock ctermbg=230 guibg=lightyellow                      &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can adjust the colours to your liking, of course ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, add this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! MarkdownBlocks()                                                       &#xA;    fun! s:fill(line)                                                       &#xA;        &quot; Remove all trailing whitespace                                    &#xA;        let l:line = substitute(a:line, &quot; *$&quot;, &quot;&quot;, &quot;&quot;)                      &#xA;&#xA;        &quot; Add trailing whitespace up to 'textwidth' length                  &#xA;        return l:line . repeat(' ', (&amp;amp;tw &amp;gt; 0 ? &amp;amp;tw : 80) - strdisplaywidth(l:line))&#xA;    endfun                                                                  &#xA;&#xA;    &quot; Get all lines in a list                                               &#xA;    let l:lines = getline(1, line('$'))                                     &#xA;&#xA;    &quot; Map s:fill() to the lines that are a code block                       &#xA;    call map(l:lines, 'v:val[0] == &quot;\t&quot; || v:val[:3] == &quot;    &quot; ? s:fill(v:val) : v:val')&#xA;&#xA;    &quot; Reset the buffer to the lines                                         &#xA;    call setline(1, l:lines)                                                &#xA;endfun                                                                      &#xA;&#xA;&quot; Remove all the trailing spaces                                            &#xA;fun! MarkdownBlocksClean()                                                  &#xA;    let l:save_cursor = getpos(&quot;.&quot;)                                         &#xA;    silent %s/^\(    \|\t\)\(.\{-}\)\( *\)$/\1\2/e                          &#xA;    call setpos('.', l:save_cursor)                                         &#xA;endfun                                                                      &#xA;au BufWritePre *.markdown call MarkdownBlocksClean()                        &#xA;&#xA;&quot; Set spaces on loading the file, leaving insert mode, and after writing it &#xA;au FileType markdown call MarkdownBlocks()                                  &#xA;au InsertLeave *.markdown call MarkdownBlocks()                             &#xA;au BufWritePost *.markdown call MarkdownBlocks()                            &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not going to explain the code line-by-line, the comments should make&#xA;the general gist of it clear ;-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-25T15:53:30.740" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2211" PostTypeId="2" ParentId="2009" CreationDate="2015-02-25T16:09:25.253" Score="1" Body="&lt;p&gt;In the spirit of &lt;code&gt;CDPATH&lt;/code&gt;, I wrote a Python-based function to do this (with &lt;a href=&quot;https://vi.stackexchange.com/a/2205/205&quot;&gt;help from Matt Boehm&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function LookupFiles ()&#xA;    python &amp;lt;&amp;lt;EOF&#xA;from os.path import *&#xA;from vim import *&#xA;current_file = eval ('expand(&quot;%&quot;)')&#xA;current_index = str (current.buffer.number)&#xA;PATHS = ['~', '~/.vim', '/etc']&#xA;&#xA;if current_file != '' and  not isfile (current_file):&#xA;    for p in map (expanduser, PATHS):&#xA;        f = join (p, current_file)&#xA;        if isfile (f):          &#xA;            command ('bad ' + f)&#xA;            command ('bd ' + current_index)&#xA;            break&#xA;EOF&#xA;endfunction&#xA;&#xA;autocmd BufWinEnter * nested call LookupFiles() &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I used &lt;code&gt;BufWinEnter&lt;/code&gt; instead of &lt;code&gt;BufNewFile&lt;/code&gt; because the latter didn't seem to behave reliably when multiple such filenames where given.&lt;/li&gt;&#xA;&lt;li&gt;After a bit of trial and error, I settled on &lt;code&gt;bad&lt;/code&gt; followed by &lt;code&gt;bd&lt;/code&gt; as a reliable way to close the buffer opened for the unused file. This still doesn't work when I do &lt;code&gt;:tabe some-file&lt;/code&gt; (no new tab is opened). However, that's a question for another day. &lt;/li&gt;&#xA;&lt;li&gt;Like with &lt;code&gt;CDPATH&lt;/code&gt;, I can easily add more directories by editing &lt;code&gt;PATHS&lt;/code&gt;, or making it a Vim-level variable and modifying it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What the other answers miss, IMO, is that I don't want to create configuration for each &lt;em&gt;file&lt;/em&gt;, but for each &lt;em&gt;directory&lt;/em&gt;. I don't care whether I'm opening &lt;code&gt;fstab&lt;/code&gt; or &lt;code&gt;vimrc&lt;/code&gt;, I just wanted Vim to search for files in some set of directories if it didn't exist in the current directory. +1 to all of them for the file-specific efforts, though.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-25T16:09:25.253" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2212" PostTypeId="1" AcceptedAnswerId="2213" CreationDate="2015-02-25T16:42:21.833" Score="17" ViewCount="2534" Body="&lt;p&gt;I have just discovered the &lt;code&gt;:bwipeout&lt;/code&gt; command, for which the &lt;code&gt;:help&lt;/code&gt; states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Like &lt;code&gt;:bdelete&lt;/code&gt;, but really delete the buffer.  Everything&#xA;  related to the buffer is lost.  All marks in this buffer&#xA;  become invalid, option settings are lost, etc. Don't use this&#xA;  unless you know what you are doing.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Other than the obvious, I'm unclear on what the downside to using this command is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My option settings will almost always be reset to the same values when I next open the file in question, and losing my marks doesn't seem to warrant the ominous warning: &quot;Don't use this unless you know what you are doing.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is included in the &quot;etc.&quot;, and what terrible consequences could there be that I'm not foreseeing?&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2015-02-25T17:17:27.933" Title="What bad things can happen if I use :bwipeout?" Tags="|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2213" PostTypeId="2" ParentId="2212" CreationDate="2015-02-25T17:17:27.933" Score="23" Body="&lt;p&gt;&quot;Bad&quot; is a bit relative (your hard drive won't be erased or anything).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;bdelete&lt;/code&gt; makes the buffer unlisted, but doesn't purge marks, options, the buffer name, the buffer number, and so on. If you reload the buffer that information is retained (less what may be modified by autocommands), which may be useful because&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it allows you to keep using any marks, or the buffer number, you may have in your short-term memory.&lt;/li&gt;&#xA;&lt;li&gt;it prevents vim from having to reparse &lt;code&gt;viminfo&lt;/code&gt; for the relevant information (trading the cost of keeping that info in RAM for the cost of reading that file from the disk, which is admittedly something we don't generally need to consciously worry about that much on modern computers).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;bwipeout&lt;/code&gt;, on the other, gets rid of &lt;em&gt;all&lt;/em&gt; of that (everything that is associated with the buffer), so that if you reopen the buffer it will be as if vim never saw that buffer before during this session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not really as &quot;dangerous&quot; as the documentation implies. I presume the dire writing is simply to warn you that wiping out a buffer is significantly more destructive of an action than simply deleting it.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-02-25T17:17:27.933" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2214" PostTypeId="2" ParentId="2068" CreationDate="2015-02-25T18:00:03.137" Score="4" Body="&lt;p&gt;I looked at the source code last week, and I don't think this is possible. As xaizek pointed out in a comment, this would make completion ambiguous.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I've thought of a workaround :-) There's the &lt;code&gt;CompleteDone&lt;/code&gt; autocmd, which is run when:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;After Insert mode completion is done.  Either when something was completed or abandoning completion.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What we can do is write a dictionary not with spaces, but with another character; and use the &lt;code&gt;CompleteDone&lt;/code&gt; autocmd to replace this character afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my example, I use the underscore (&lt;code&gt;_&lt;/code&gt;). I originally tried to use a more &quot;special&quot; character (such as &lt;code&gt;·&lt;/code&gt;), but that doesn't seem to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example &lt;code&gt;dictionary&lt;/code&gt; file looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Monty_Python&#xA;Monty_Python_Flying_Circus&#xA;The_Black_Adder&#xA;Captain_Darling&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And with this &lt;code&gt;autocmd&lt;/code&gt; the underscores get replaced with spaces; it should be fairly obvious how it works, so I'll not explain that any further:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! CompleteSpace()&#xA;    &quot; Save cursor position&#xA;    let l:save_cursor = getpos(&quot;.&quot;)&#xA;&#xA;    &quot; Get word we just completed ('borrowed' from: http://stackoverflow.com/a/23541748/660921)&#xA;    let l:word = matchstr(strpart(getline('.'), 0, col('.') - 1), '\k\+$')&#xA;&#xA;    &quot; Replace _ with space&#xA;    let l:new = substitute(l:word, &quot;_&quot;, &quot; &quot;, &quot;g&quot;)&#xA;&#xA;    &quot; Run :s&#xA;    exe &quot;s/&quot; . l:word . &quot;/&quot; . l:new . &quot;/e&quot;&#xA;&#xA;    &quot; Restore cursor&#xA;    call setpos(&quot;.&quot;, l:save_cursor)&#xA;endfun&#xA;&#xA;if has(&quot;patch-7.3-598&quot;)&#xA;    au CompleteDone * call CompleteSpace()&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This could perhaps be optimized a bit, but this seems to be 'good enough' for now ;-)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Caveat!&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this autocmd is not perfect, as documented in the &lt;code&gt;todo.txt&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The CompleteDone autocommand needs some info passed to it:&lt;br&gt;&#xA;  - The word that was selected (empty if abandoned complete)&lt;br&gt;&#xA;  - Type of completion: tag, omnifunc, user func.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[..]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Patch to add v:completed_item. (Shougo Matsu, 2013 Nov 29).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The problem is that it might cause side-effects when completing source code as well; for example &lt;code&gt;my_variable_name()&lt;/code&gt; gets &quot;fixed&quot; to &lt;code&gt;my variable name&lt;/code&gt;. The &lt;code&gt;autocmd&lt;/code&gt; below is for &lt;em&gt;all&lt;/em&gt; files, you can restrict the autocmd for certain files... There is &lt;a href=&quot;https://groups.google.com/forum/?fromgroups=#!searchin/vim_dev/CompleteDone$20Shougo/vim_dev/fhGAStSCAMg/q5BIr2EcH4YJ&quot; rel=&quot;nofollow&quot;&gt;actually a patch&lt;/a&gt; floating around which seems to fix this, but it's not applied yet for whatever reason. Perhaps it's simply forgotten, or maybe it needs some love to fix a minor issue; you could pursue it :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-02-25T18:00:03.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2215" PostTypeId="5" CreationDate="2015-02-25T18:16:51.457" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-25T18:16:51.457" LastActivityDate="2015-02-25T18:16:51.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2216" PostTypeId="4" CreationDate="2015-02-25T18:16:51.457" Score="0" Body="Questions about techniques to input text other than what is literally labelled on keycaps on a keyboard" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-25T18:41:35.353" LastActivityDate="2015-02-25T18:41:35.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2217" PostTypeId="5" CreationDate="2015-02-25T18:19:12.757" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-02-25T18:19:12.757" LastActivityDate="2015-02-25T18:19:12.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2218" PostTypeId="4" CreationDate="2015-02-25T18:19:12.757" Score="0" Body="Alternatives to traditional keyboards and mouse-like pointing devices" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-02-25T18:41:27.333" LastActivityDate="2015-02-25T18:41:27.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2219" PostTypeId="1" AcceptedAnswerId="2221" CreationDate="2015-02-25T19:15:18.907" Score="5" ViewCount="818" Body="&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; This question is a &quot;manual migration&quot; from here: &lt;a href=&quot;https://superuser.com/q/875751/199803&quot;&gt;https://superuser.com/q/875751/199803&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My Vim syntax highlighter for &lt;code&gt;ft=cpp&lt;/code&gt; is prematurely ending some macros mid-line. For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZL4HY.png&quot; alt=&quot;highlighting error example&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The italicization may make this example a little hard to understand; the final character in the second line is &lt;code&gt;\&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is part of a multi-line macro; note that the transition from blue (the &quot;macro&quot; style) to grey and italicized (the &quot;comment&quot; style) occurs *mid-word. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any ideas what's going on here? I tried googling to see if this was a known issue, but I didn't see anyone stating that they had this particular problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;vim-gtk&lt;/code&gt; (Vim 7.4) from the Wheezy-Backports repo.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It appears that the macro highlighting style ends as soon as the first &lt;code&gt;0&lt;/code&gt; is encountered anywhere other than at the start of a token. For instance, the number &lt;code&gt;0&lt;/code&gt; itself does not end the macro, nor does the word &lt;code&gt;0DIAGNOSTIC&lt;/code&gt;, but &lt;code&gt;DIAGNOSTIC0&lt;/code&gt; &lt;em&gt;does&lt;/em&gt; (regardless of what follows the &lt;code&gt;0&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Since the problem is reproducible even with &lt;code&gt;-N -u NONE&lt;/code&gt; (see comments on Ingo Karkat's answer), here's the complete output of &lt;code&gt;vim --version&lt;/code&gt;, just in case it's helpful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 14 2014 15:36:29)&#xA;Included patches: 1-488&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by buildd@&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;+balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;+browse          +folding         +mouse_xterm     +tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;+clientserver    -hangul_input    +netbeans_intg   +title&#xA;+clipboard       +iconv           +path_extra      +toolbar&#xA;+cmdline_compl   +insert_expand   +perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python          +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con_gui  +lua             +rightleft       +windows&#xA;+diff            +menu            +ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      +X11&#xA;+dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     +xim&#xA;+emacs_tags      +mouseshape      -sniff           +xsmp_interact&#xA;+eval            +mouse_dec       +startuptime     +xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    +xpm&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12     -g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     -I/usr/include/tcl8.5  -D_REENTRANT=1  -D_THREAD_SAFE=1  -D_LARGEFILE64_SOURCE=1  &#xA;Linking: gcc   -L. -Wl,-z,relro -rdynamic -Wl,-export-dynamic -Wl,-E  -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0   -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector -L/usr/local/lib  -L/usr/lib/perl/5.14/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions  -L/usr/lib -ltcl8.5 -ldl -lpthread -lieee -lm -lruby-1.9.1 -lpthread -lrt -ldl -lcrypt -lm  -L/usr/lib   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'm using the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=383&quot; rel=&quot;nofollow noreferrer&quot;&gt;SyntaxAttr plugin&lt;/a&gt; to get information about the last macro-highlighted character and the first comment-highlighted character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last macro character: &lt;code&gt;group: cDefine-&amp;gt;PreProc guifg=5(5) guibg=-1(-1)&lt;/code&gt;&#xA;First non-macro character: &lt;code&gt;cCppOut2-&amp;gt;Comment guifg=6(6) guibg=-1(-1)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;:scriptnames&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: /usr/share/vim/vim74/menu.vim&#xA;2: /usr/share/vim/vim74/autoload/paste.vim&#xA;3: /usr/share/vim/vim74/syntax/syntax.vim&#xA;4: /usr/share/vim/vim74/syntax/synload.vim&#xA;5: /usr/share/vim/vim74/syntax/syncolor.vim&#xA;6: /usr/share/vim/vim74/filetype.vim&#xA;7: /usr/share/vim/vim74/syntax/cpp.vim&#xA;8: /usr/share/vim/vim74/syntax/c.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1060" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2015-02-28T20:16:10.670" Title="Vim `cpp` Syntax highlighter prematurely ends macros mid-word" Tags="|syntax-highlighting|filetype-c++|filetype-c|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2220" PostTypeId="1" AcceptedAnswerId="2756" CreationDate="2015-02-25T19:21:17.310" Score="12" ViewCount="469" Body="&lt;p&gt;Is there an easier way to find a particular change in Vim's undo tree than just looking at random old versions of the file one at a time (either using vanilla VIM commands, Gundo, or another plugin)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I'd like to enter a search pattern to be matched against all of the diffs shown in the preview pane by Gundo, and then have Gundo show me which versions have diffs that match that search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://superuser.com/q/416658/199803&quot;&gt;This question&lt;/a&gt; asks something almost identical, but the asker has accepted an answer that simply recommends Gundo, which, wonderful though it is, doesn't appear to do what I'm asking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have pitched this as a &lt;a href=&quot;https://bitbucket.org/sjl/gundo.vim/issue/45/search-through-diffs&quot; rel=&quot;nofollow noreferrer&quot;&gt;new feature for Gundo&lt;/a&gt;, but received no response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; There is an &lt;a href=&quot;https://github.com/mbbill/undotree/issues/48&quot; rel=&quot;nofollow noreferrer&quot;&gt;open request&lt;/a&gt; for this feature for undotree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; This question has been &quot;manually migrated&quot; from &lt;a href=&quot;https://superuser.com/q/704519/199803&quot;&gt;superuser&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1060" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2016-10-24T20:48:40.263" Title="Search all versions of a file in the undo tree" Tags="|undo-redo|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2221" PostTypeId="2" ParentId="2219" CreationDate="2015-02-25T19:45:41.733" Score="5" Body="&lt;p&gt;&lt;code&gt;cCppOut2&lt;/code&gt; comes from &lt;code&gt;c.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region  cCppOut2    contained start=&quot;0&quot; end=&quot;^\s*\(%:\|#\)\s*\(endif\&amp;gt;\|else\&amp;gt;\|elif\&amp;gt;\)&quot; contains=cSpaceError,cCppSkip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is &lt;code&gt;contained&lt;/code&gt;, and the definition for &lt;code&gt;cDefine&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region  cDefine     start=&quot;^\s*\(%:\|#\)\s*\(define\|undef\)\&amp;gt;&quot; skip=&quot;\\$&quot; end=&quot;$&quot; keepend contains=ALLBUT,@cPreProcGroup,@Spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The use of the special &lt;code&gt;ALLBUT&lt;/code&gt; value at the start of the contains list means that everything except the listed groups can be contained in &lt;code&gt;cDefine&lt;/code&gt;... including &lt;code&gt;cCppOut2&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Prior to &lt;a href=&quot;https://code.google.com/p/vim/source/diff?spec=svnbd18da914be9d43a70713f6af02770a0d3280159&amp;amp;r=bd18da914be9d43a70713f6af02770a0d3280159&amp;amp;format=side&amp;amp;path=/runtime/syntax/c.vim&quot; rel=&quot;nofollow&quot;&gt;October 2nd, 2014&lt;/a&gt;, the definition of &lt;code&gt;cCppOut2&lt;/code&gt; was guarded by &lt;code&gt;c_no_cformat&lt;/code&gt; existing (which is not the case by default) and thus you could only experience this by setting that option to some value. You can thus fix it by unletting that option (reload the file via &lt;code&gt;:e&lt;/code&gt; afterwards).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As of the October 2nd change, however, &lt;code&gt;cCppOut2&lt;/code&gt; is &lt;em&gt;always&lt;/em&gt; defined, so this bug will be much more prevalent. This was reported as a bug in &lt;code&gt;c.vim&lt;/code&gt; (&lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_dev/W3nUTRhOeUo&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your version of vim is built with the October 2nd changes, your options are to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Re-link &lt;code&gt;cCppOut2&lt;/code&gt; to &lt;code&gt;cDefine&lt;/code&gt; to &quot;hide&quot; the problem until an official fix makes it in. To do this in &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`hi link cCppOut2 PreProc`&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Attempt the fix yourself, as described below.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It appears that &lt;code&gt;@cStringGroup&lt;/code&gt; should be listed in the contains set of the &lt;code&gt;cDefine&lt;/code&gt; and &lt;code&gt;cPreProc&lt;/code&gt; regions (added at the end, here):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region  cDefine     start=&quot;^\s*\(%:\|#\)\s*\(define\|undef\)\&amp;gt;&quot; skip=&quot;\\$&quot; end=&quot;$&quot; keepend contains=ALLBUT,@cPreProcGroup,@Spell,@cStringGroup&#xA;syn region  cPreProc    start=&quot;^\s*\(%:\|#\)\s*\(pragma\&amp;gt;\|line\&amp;gt;\|warning\&amp;gt;\|warn\&amp;gt;\|error\&amp;gt;\)&quot; skip=&quot;\\$&quot; end=&quot;$&quot; keepend contains=ALLBUT,@cPreProcGroup,@Spell,@cStringGroup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user72" LastEditorUserId="1060" LastEditDate="2015-02-26T17:55:21.163" LastActivityDate="2015-02-26T17:55:21.163" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="2222" PostTypeId="1" AcceptedAnswerId="2229" CreationDate="2015-02-25T20:37:55.137" Score="14" ViewCount="1750" Body="&lt;p&gt;I saw a skilled vim ninja do this a while back but I have no idea were to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A) Is there a way to set up vims background colour so that consecutive lines with identical content get highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;B) If somebody knows how to do that a nice tweak to this would be if the highlighting happened on consecutive lines but only consider the first word (not the whole line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A second tweak if the highlighting could be configured to different colours are used based on the number of matching lines (or words depending on A B is active). So of we only have two consecutive lines that match then green,  3-5 consecutive lines then orange, 6+ then red.&lt;/p&gt;&#xA;" OwnerUserId="383" LastEditorUserId="51" LastEditDate="2015-02-25T22:10:39.963" LastActivityDate="2015-02-25T22:18:06.340" Title="Auto Highlighting identical lines text" Tags="|syntax-highlighting|highlight|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2223" PostTypeId="1" AcceptedAnswerId="2227" CreationDate="2015-02-25T21:07:05.717" Score="19" ViewCount="7113" Body="&lt;p&gt;I'm trying to open an &lt;code&gt;.xlsx&lt;/code&gt; file in Vim, but got an error saying:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;***error*** (zip#Browse) unzip not available on your system  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I know it's a binary file, but I want to do some checksums and probably convert to hex.&lt;/p&gt;&#xA;&lt;p&gt;I noticed that if I change the extension, Vim no longer tries to unzip it. Which leads me to my question:&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to tell Vim to open a file without attempting to unzip it?&lt;/p&gt;&#xA;&lt;p&gt;FWIW, I'm using Vim 7.4 under Windows 7.&lt;/p&gt;&#xA;" OwnerUserId="475" LastEditorUserId="23502" LastEditDate="2022-10-31T13:01:26.057" LastActivityDate="2022-10-31T13:01:26.057" Title="How to tell Vim not to try to unzip a file?" Tags="|filetype|binary-file|plugin-zip|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2224" PostTypeId="2" ParentId="2223" CreationDate="2015-02-25T21:17:42.610" Score="12" Body="&lt;p&gt;This seems to the the &quot;zip&quot; plugin, which is shipped with Vim and enabled by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pi_zip.txt.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help zip&lt;/code&gt;&lt;/a&gt; has some information about it, among other things:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;PREVENTING LOADING&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If for some reason you do not wish to use vim to examine zipped files,&#xA;   you may put the following two variables into your &amp;lt;.vimrc&gt; to prevent&#xA;   the zip plugin from loading:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:loaded_zipPlugin= 1                                               &#xA;let g:loaded_zip      = 1                                               &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After adding these 2 lines, I'm able to open a &lt;code&gt;.zip&lt;/code&gt; file as any other file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't know about this either, by the way; but the error message mentioned &lt;code&gt;zip#Browse&lt;/code&gt;, so I just typed &lt;code&gt;:help zip&lt;/code&gt; and landed on the right documentation page :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vi.stackexchange.com/questions/2136/how-do-i-navigate-to-topics-in-vims-documentation&quot;&gt;How do I navigate to topics in Vim's documentation?&lt;/a&gt; for some more information &amp;amp; tips about Vim's help system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will also work for the &lt;code&gt;tar&lt;/code&gt; plugin, except you use &lt;code&gt;g:loaded_tarPlugin&lt;/code&gt; &amp;amp; &lt;code&gt;g_loaded_tar&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-03-03T15:44:46.373" LastActivityDate="2015-03-03T15:44:46.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2225" PostTypeId="5" CreationDate="2015-02-25T21:27:07.313" Score="0" Body="&lt;p&gt;To disable it, add this to your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:loaded_zipPlugin = 1&#xA;let g:loaded_zip = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-25T21:27:07.313" LastActivityDate="2015-02-25T21:27:07.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2226" PostTypeId="4" CreationDate="2015-02-25T21:27:07.313" Score="0" Body="The zip plugin allows you to display and edit the contents of a .zip file when you open it with Vim. It is shipped (&amp; enabled) with Vim by default." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-02-25T21:27:07.313" LastActivityDate="2015-02-25T21:27:07.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2227" PostTypeId="2" ParentId="2223" CreationDate="2015-02-25T21:36:10.393" Score="20" Body="&lt;p&gt;Functionality like this is handled by &lt;a href=&quot;http://vimhelp.appspot.com/usr_40.txt.html#40.3&quot;&gt;autocmds&lt;/a&gt;.  In order to disable autocmds for a specific command, you can use &lt;code&gt;:noautocmd&lt;/code&gt; (abbreviated &lt;code&gt;:noau&lt;/code&gt;).  In this case&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noau e foo.xlsx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will simply open the raw file rather than triggering the autocmds that try to open the zip file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use this from your shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -c 'noau e foo.xlsx'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want more granularity than disabling all autocmds, you could temporarily disable the &lt;code&gt;BufRead&lt;/code&gt;/&lt;code&gt;BufReadPre&lt;/code&gt; autocmds using the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27eventignore%27&quot;&gt;&lt;code&gt;'eventignore'&lt;/code&gt;&lt;/a&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ei=BufRead,BufReadPre&#xA;:e foo.xlsx&#xA;:set ei=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastEditorUserId="51" LastEditDate="2015-03-03T15:50:38.183" LastActivityDate="2015-03-03T15:50:38.183" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2228" PostTypeId="2" ParentId="2222" CreationDate="2015-02-25T22:07:54.300" Score="8" Body="&lt;p&gt;As a starting point, here's a search pattern that matches duplicate lines (ignoring changes in leading whitespace):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;              \zs                marks start of the pattern. Everything before here will not be highlighted&#xA; ^                               start of the line&#xA;  \s*                            leading whitespace&#xA;       .\+                       match 1 or more non-newline characters&#xA;     \(   \)                     and use parens to capture this in match group 1&#xA;&#xA;            \n                   match the newline character&#xA;                 \(        \)\+  1 or more&#xA;                      \1         copies of what was in the match group 1&#xA;                   \s*  \n       with leading whitespace followed by a newline&#xA;/^\s*\(.\+\)\n\zs\(\s*\1\n\)\+   the full regex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help pattern&lt;/code&gt; will provide more info on how to make regexes like this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help syntax&lt;/code&gt; will show you how to take this regular expression and turn it into something that is highlighted for you&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Learning to write syntax scripts can be tough, so a good short-term solution is to do this 'on the fly' by making sure &lt;code&gt;'incsearch'&lt;/code&gt; is set so that searches are highlighted and mapping a key to do the above search, i.e. &lt;code&gt;nnoremap &amp;lt;F5&amp;gt; /^\s*\(.\+\)\n\zs\(\s*\1\n\)\+&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="680" LastEditorUserId="680" LastEditDate="2015-02-25T22:18:06.340" LastActivityDate="2015-02-25T22:18:06.340" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2229" PostTypeId="2" ParentId="2222" CreationDate="2015-02-25T22:08:29.943" Score="11" Body="&lt;p&gt;The following &lt;code&gt;match&lt;/code&gt; sets seem to work for (A):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn match Low /\v(.+)\n(\1\n)/&#xA;:syn match Medium /\v(.+)\n(\1\n){2,4}/&#xA;:syn match Critical /\v(.+)\n(\1\n){5,}/&#xA;:hi Critical  ctermfg=red&#xA;:hi Medium  ctermfg=yellow&#xA;:hi Low  ctermfg=green&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems the order is crucial here. If the &lt;code&gt;Low&lt;/code&gt; or &lt;code&gt;Medium&lt;/code&gt; matches come after &lt;code&gt;Critical&lt;/code&gt;, it gets subsumed by the looser requirements of these, and similarly for &lt;code&gt;Low&lt;/code&gt; w.r.t. &lt;code&gt;Medium&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The highlighting doesn't appear immediately after you add, say, a 3rd or 6th dupe line, but once you move around a bit after adding them. I'm not sure what triggers it, exactly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For B, I imagine you could replace the regex with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v(\S+).*\n(\1.*\n)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In general, replace all the &lt;code&gt;(.*)&lt;/code&gt; with &lt;code&gt;(\S+).*&lt;/code&gt; and &lt;code&gt;\1&lt;/code&gt; with &lt;code&gt;\1.*&lt;/code&gt;, or whatever constitutes a word for you.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-02-25T22:08:29.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2230" PostTypeId="1" AcceptedAnswerId="2236" CreationDate="2015-02-25T22:25:09.983" Score="0" ViewCount="589" Body="&lt;p&gt;Okay, here's the thing: let's say you have a buffer, 1000 lines long (a source code for example). And you want a super-fast navigation, jumping to the right place. Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are on a line 42, on character 44 (quotation after exclamation mark). You would like to access line 20, character 34 (&lt;code&gt;w&lt;/code&gt; of &lt;code&gt;which_has&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;20    def very_interesting_function(which_has, some_interesting, arguments):&#xA;...&#xA;42         s = &quot;I want to master the universe!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's the quickest way to get there? Plugins, custom keybinds are welcome!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My solutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;?whichi&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;22k%a&lt;/code&gt; -- requires simple math&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;20ggf(a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;hold &lt;code&gt;k&lt;/code&gt; and then &lt;code&gt;f(a&lt;/code&gt; -- takes too long&lt;/li&gt;&#xA;&lt;li&gt;hold &lt;code&gt;{&lt;/code&gt; or &lt;code&gt;(&lt;/code&gt;, then &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt; if needed, &lt;code&gt;f(a&lt;/code&gt; -- too lame&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But this is just an easy example. The use case may be far more complicated -- getting to a position of the screen, where 2) and 3) are unfeasible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what you guys use? I feel like searching (&lt;code&gt;/&lt;/code&gt;, &lt;code&gt;?&lt;/code&gt;) is most superior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: looks like my question may be a dupe of &lt;a href=&quot;https://vi.stackexchange.com/questions/528/move-vertically-to-a-specific-character-on-a-different-line&quot;&gt;this one&lt;/a&gt;. The main difference is that &lt;a href=&quot;https://vi.stackexchange.com/users/778/peter-rincker&quot;&gt;Peter&lt;/a&gt; provided very precise answer (I couldn't find such an excellent answer in the former question).&lt;/p&gt;&#xA;" OwnerUserId="1056" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-03-11T16:55:30.853" Title="Quickest navigation within a buffer" Tags="|cursor-movement|" AnswerCount="1" CommentCount="4" ClosedDate="2015-02-26T03:48:49.180" ContentLicense="CC BY-SA 3.0" />
  <row Id="2231" PostTypeId="2" ParentId="779" CreationDate="2015-02-25T22:30:43.067" Score="17" Body="&lt;p&gt;&lt;em&gt;I'm the current Vim maintainer for Debian and the person quoted in the referenced mailing list discussion.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you stated, this isn't a question about Vim.  It's about building the software that Vim links against in a way that meets your needs.  There's a more thorough discussion (at least for the Debian aspect) of the issue in a bug &lt;a href=&quot;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=729924&quot; rel=&quot;noreferrer&quot;&gt;requesting Python3 to be enabled&lt;/a&gt; in Debian's Vim packaging.&lt;/p&gt;&#xA;&lt;p&gt;This boils down to&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Debian's Python packaging doesn't link the Python extensions against the relevant libpython shared library.  This is what causes Debian's Vim packaging to require using &lt;code&gt;RTLD_GLOBAL&lt;/code&gt; when using &lt;code&gt;dlopen()&lt;/code&gt; to dynamically load the Python language bindings.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There aren't good ways to express the relationship between the Vim packages and the dynamically loaded libraries to ensure they're upgraded together when appropriate.  Even if the first point were resolved, this issue would still prevent me from enabling dynamic loading of the Python support.&lt;/p&gt;&#xA;&lt;p&gt;The main point of dynamically loading the language support in Vim is to not require users to install libraries they won't use.  This means the Vim packaging can't specify a hard dependency on a minimum version of a library.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, if Vim is built against a newer version of a library that isn't backwards compatible with the older version and the user doesn't upgrade them together, Vim will crash.  This isn't something I want the users of the packages to encounter.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I'd love to be able to re-enable (it was available for a short time back in 2010-2011) dynamic loading of language support, but the above issues have to be resolved first.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;As of version &lt;a href=&quot;https://tracker.debian.org/news/796236&quot; rel=&quot;noreferrer&quot;&gt;2:7.4.2330-1&lt;/a&gt;, Debian's packaging has switched to using Python3 instead of Python2 for the Python bindings.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;As an alternative, the neovim package supports use of both Python2 and Python3 from the same nvim process, since the Python support is provided by external modules (the &lt;a href=&quot;https://packages.debian.org/python-neovim&quot; rel=&quot;noreferrer&quot;&gt;python-neovim&lt;/a&gt; and &lt;a href=&quot;https://packages.debian.org/python3-neovim&quot; rel=&quot;noreferrer&quot;&gt;python3-neovim&lt;/a&gt; packages).  Externalizing the Python code, rather than embedding it like Vim does, avoids the issue of dealing with how libpython is built.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-09-14T00:53:08.057" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="2232" PostTypeId="1" CreationDate="2015-02-25T23:14:41.343" Score="174" ViewCount="342431" Body="&lt;p&gt;Is there a neat way I can view binary files as hex in Vim, and save it back to binary from the hex?&lt;/p&gt;&#xA;" OwnerUserId="960" LastEditorUserId="927" LastEditDate="2017-06-24T23:16:30.700" LastActivityDate="2020-02-22T22:43:27.453" Title="How can I use Vim as a hex editor?" Tags="|binary-file|" AnswerCount="2" CommentCount="0" ClosedDate="2015-02-26T02:59:54.223" ContentLicense="CC BY-SA 3.0" />
  <row Id="2234" PostTypeId="2" ParentId="2232" CreationDate="2015-02-25T23:26:58.230" Score="251" Body="&lt;p&gt;You can use the &lt;code&gt;xxd&lt;/code&gt; command to transform a file in Vim to hex representation, doing&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%!xxd&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:&lt;/code&gt; enters command-line mode, &lt;code&gt;%&lt;/code&gt; matches whole file as a range, &lt;code&gt;!&lt;/code&gt; filters that range through an external command, &lt;code&gt;xxd&lt;/code&gt; is that external shell command&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Giving an output like this, this is split into octet count/line (octets per line may be changed with parameter &lt;code&gt;-c&lt;/code&gt; on &lt;code&gt;xxd&lt;/code&gt; command), hex representation, and text representation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0000000: 5468 6973 2069 7320 6120 7465 7374 0a41  This is a test.A&#xA;0000010: 6e6f 7468 6572 206c 696e 650a 416e 6420  nother line.And &#xA;0000020: 7965 7420 616e 6f74 6865 720a            yet another.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once you make the changes (in the hex part), you can go back to text with &lt;code&gt;-r&lt;/code&gt; command on xxd, so&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%!xxd -r&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a little rudimentary, though I like it in its simplicity and to keep in mind &lt;code&gt;xxd&lt;/code&gt;, which is an interesting command line tool (I don't have to do a lot of work on hex, though). You can use some recipes to handle this transformation in a more automatic way like the one described in &lt;em&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Improved_hex_editing&quot; rel=&quot;noreferrer&quot;&gt;Improved hex editing&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And rembember you can also use syntax highlighting for hex editing in vim with that command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ft=xxd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="403" LastEditorUserId="23433" LastEditDate="2020-02-22T22:43:27.453" LastActivityDate="2020-02-22T22:43:27.453" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="2236" PostTypeId="2" ParentId="2230" CreationDate="2015-02-26T00:10:06.457" Score="9" Body="&lt;p&gt;So many options besides the ones you provided:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you know the line number then use &lt;code&gt;G&lt;/code&gt; with a count or just a range to jump to the line. e.g. &lt;code&gt;20G&lt;/code&gt; or &lt;code&gt;:20&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Turn on &lt;code&gt;'relativenumber'&lt;/code&gt; via &lt;code&gt;:set relativenumber&lt;/code&gt; to make short jumps easier&lt;/li&gt;&#xA;&lt;li&gt;Jump to the start of previous method definition via &lt;code&gt;[m&lt;/code&gt;. (&lt;code&gt;[m&lt;/code&gt; can take a count as well)&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;[[&lt;/code&gt; or &lt;code&gt;]]&lt;/code&gt; to move to the previous or next section respectively (usually function definitions).&lt;/li&gt;&#xA;&lt;li&gt;If the word is somewhere else near the cursor then do &lt;code&gt;#&lt;/code&gt;/&lt;code&gt;*&lt;/code&gt; and spam &lt;code&gt;n&lt;/code&gt; till you get there. (&lt;code&gt;n&lt;/code&gt; can take a count)&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;H&lt;/code&gt; (high), &lt;code&gt;M&lt;/code&gt; (middle), or &lt;code&gt;L&lt;/code&gt; (low) to jump to screen positions to shorten the distance.&lt;/li&gt;&#xA;&lt;li&gt;Possibly use &lt;code&gt;gd&lt;/code&gt; (go-to-definition) if you are on the word&lt;/li&gt;&#xA;&lt;li&gt;If you use ctags then use commands such as &lt;code&gt;&amp;lt;c-]&amp;gt;&lt;/code&gt; or &lt;code&gt;:tag&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Maybe use &lt;code&gt;:cscope&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:vimgrep/which_has/ %&lt;/code&gt; and use the quickfix list commands like &lt;code&gt;:cn&lt;/code&gt; or &lt;code&gt;:copen&lt;/code&gt; (good for very large jumps)&lt;/li&gt;&#xA;&lt;li&gt;Use a plugin like &lt;a href=&quot;https://github.com/Lokaltog/vim-easymotion&quot; rel=&quot;nofollow&quot;&gt;easymotion&lt;/a&gt; or &lt;a href=&quot;https://github.com/justinmk/vim-sneak&quot; rel=&quot;nofollow&quot;&gt;sneak.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Personally each situation calls for something different but it's hard to go wrong with searching with &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h G&#xA;:h :[range]&#xA;:h 'rnu'&#xA;:h [[&#xA;:h [m&#xA;:h H&#xA;:h gd&#xA;:h ctags&#xA;:h :vimgrep&#xA;:h c_%&#xA;:h quickfix&#xA;:h :cn&#xA;:h :copen&#xA;:h /&#xA;:h quickref&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-03-11T16:55:30.853" LastActivityDate="2015-03-11T16:55:30.853" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2237" PostTypeId="2" ParentId="2232" CreationDate="2015-02-26T00:23:26.890" Score="30" Body="&lt;p&gt;Taken from &lt;code&gt;:h hex-editing&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If one has a particular extension that one uses for binary files (such as exe,&#xA;bin, etc), you may find it helpful to automate the process with the following&#xA;bit of autocmds for your &amp;lt;.vimrc&amp;gt;.  Change that &quot;*.bin&quot; to whatever&#xA;comma-separated list of extension(s) you find yourself wanting to edit:&#xA;&#xA;&quot; vim -b : edit binary using xxd-format!&#xA;augroup Binary&#xA;  au!&#xA;  au BufReadPre  *.bin let &amp;amp;bin=1&#xA;  au BufReadPost *.bin if &amp;amp;bin | %!xxd&#xA;  au BufReadPost *.bin set ft=xxd | endif&#xA;  au BufWritePre *.bin if &amp;amp;bin | %!xxd -r&#xA;  au BufWritePre *.bin endif&#xA;  au BufWritePost *.bin if &amp;amp;bin | %!xxd&#xA;  au BufWritePost *.bin set nomod | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may want to look at: &lt;a href=&quot;https://vi.stackexchange.com/q/2136/778&quot;&gt;How do I navigate to topics in Vim's documentation?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-26T00:23:26.890" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2238" PostTypeId="1" AcceptedAnswerId="2240" CreationDate="2015-02-26T00:38:57.450" Score="12" ViewCount="6642" Body="&lt;p&gt;In normal mode &lt;code&gt;(&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt; move to the previous or next first character in the sentence, respectively.&#xA;How do I move to the very &lt;em&gt;last&lt;/em&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all of my sentences end with a period I can use &lt;code&gt;)T.&lt;/code&gt; (first character of the next sentence, then backwards to the first period) but I want a more robust solution to use in a macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know about &lt;code&gt;as&lt;/code&gt; and &lt;code&gt;is&lt;/code&gt; while in visual mode, so &lt;code&gt;vis&amp;lt;ESC&amp;gt;&lt;/code&gt; works (visual mode, then select inside the sentence, then exit visual mode), but that seems&#xA;pretty ugly to me, and I can't use it as a motion with other commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm at a loss.  Help!&lt;/p&gt;&#xA;" OwnerUserId="141" LastEditorUserId="51" LastEditDate="2015-02-26T11:46:39.263" LastActivityDate="2021-10-21T15:14:14.933" Title="How do I move to the last character in a sentence?" Tags="|cursor-movement|cursor-motions|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2239" PostTypeId="1" AcceptedAnswerId="2242" CreationDate="2015-02-26T03:37:17.203" Score="21" ViewCount="2521" Body="&lt;p&gt;Open an empty buffer and insert a tab character then exit to normal mode. When you place the cursor (normal mode) on the tab it will be at the right side of the whitespace. I'm looking for a way so the cursor will be at the left side of the whitespace instead. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="200" LastEditorUserId="200" LastEditDate="2015-02-26T16:00:09.630" LastActivityDate="2020-03-30T10:18:58.843" Title="How can I make Vim position the cursor at the start of a tab character instead of the end?" Tags="|cursor-movement|whitespace|tab-characters|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2240" PostTypeId="2" ParentId="2238" CreationDate="2015-02-26T04:02:27.103" Score="11" Body="&lt;p&gt;From my research into this, you need to define at least two custom motions. The first will be for just moving the cursor, and the second will be for use in operators. For a full functioning setup, it is much more complicated, and I would recommend looking at the code in &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1905&quot; rel=&quot;nofollow noreferrer&quot;&gt;CamelCaseMotion&lt;/a&gt; by &lt;a href=&quot;https://vi.stackexchange.com/users/970/ingo-karkat&quot;&gt;Ingo Karkat&lt;/a&gt; which shows significantly more thought on doing this right than I do below. Most of my answer is based on quick information found in Vim help and experimentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the following examples, I'm going to &lt;em&gt;remap&lt;/em&gt; the &lt;code&gt;)&lt;/code&gt; and &lt;code&gt;(&lt;/code&gt; motions to do the each end of a sentence. You can use other characters as you wish by modifying the example. I'm also going your example of &lt;code&gt;vis&amp;lt;ESC&amp;gt;&lt;/code&gt; as the more robust option (compared to &lt;code&gt;)T.&lt;/code&gt;). In doing so, if you are &lt;em&gt;already&lt;/em&gt; at the end of a sentence, you end up staying at the end instead of moving to the end after this one, because of the way &lt;code&gt;is&lt;/code&gt; works. You can try replacing it with &lt;code&gt;as&lt;/code&gt; for different results. This should actually work for turning either side of a text object into a motion.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;First, the normal mode movement&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; This doesn't work in visual mode or operator pending mode&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MoveToEnd(type, ...)&#xA;    exe &quot;normal `]&quot;&#xA;endfunction&#xA;map &amp;lt;silent&amp;gt; \) :set opfunc=MoveToEnd&amp;lt;CR&amp;gt;g@&#xA;nmap ) \)is&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First, we define a new function called &lt;code&gt;MoveToEnd&lt;/code&gt; whose sole job is to put the cursor at the the &quot;last character of the previously changed or yanked text&quot;, which is the &lt;code&gt;]&lt;/code&gt; mark (see &lt;code&gt;:help ']&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, we create a custom operator &lt;code&gt;\)&lt;/code&gt; that calls our &lt;code&gt;MoveToEnd&lt;/code&gt; function on whatever motion is given to it. In this way, the &lt;code&gt;]&lt;/code&gt; mark becomes the end of the selection given to our new operator. (see &lt;code&gt;:help map-operator&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, we map &lt;code&gt;)&lt;/code&gt; to call our custom operator with the &lt;code&gt;is&lt;/code&gt; mostion, thereby effectively giving the equivalent of &lt;code&gt;vis&amp;lt;ESC&amp;gt;&lt;/code&gt; without changing the last visual selection and without changing modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reverse is similar, just using the other directions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MoveToBeginning(type, ...)&#xA;    exe &quot;normal `[&quot;&#xA;endfunction&#xA;map &amp;lt;silent&amp;gt; \( :set opfunc=MoveToBeginning&amp;lt;CR&amp;gt;g@&#xA;:nmap ( \(is&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Second, the operator movement&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This one is trickier. Our motion above destroys the start position, so operators like 'd' end up working against nothing. What we need is to be able to save our start position and add the end position. &lt;code&gt;:help omap-info&lt;/code&gt; (operator pending mapping) gives a tip on doing this, which is to actually use visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What we'll do then, is save our position to one end of the visual selection register, use our normal mode motion from above, set the other visual selection register, and then activate visual mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SelectToEnd()&#xA;    normal m&amp;lt;  &quot;Set start point of visual selection&#xA;    normal )   &quot;Move to end of sentance (relies on mapping from earlier)&#xA;    normal m&amp;gt;  &quot;Set end point of visual selection&#xA;    normal gv  &quot; 'Go Visual' activate visual mode using selection marks&#xA;endfunction&#xA;omap ) :call SelectToEnd()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And for our back motion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SelectToBeginning()&#xA;    normal m&amp;gt;  &quot;Set end point to current position (since we are moving backwards)&#xA;    normal (   &quot;Move to beginning of sentence (relies on mapping from earlier)&#xA;    normal m&amp;lt;  &quot;Set start point&#xA;    normal gv  &quot;Activate visual mode based on our new marks&#xA;endfunction&#xA;omap ( :call SelectToBeginning()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this, you can do &lt;code&gt;d)&lt;/code&gt; to delete to the end of the sentence (instead of the original of deleting to the beginning of the next one). All other operators should work as well.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2015-02-26T04:07:32.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2241" PostTypeId="2" ParentId="2239" CreationDate="2015-02-26T04:19:35.043" Score="6" Body="&lt;p&gt;The cursor in normal mode is on the character not to either side. So you can do &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;a&lt;/code&gt; to go to insert mode to the left or right of the tab respectively.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-02-26T04:19:35.043" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2242" PostTypeId="2" ParentId="2239" CreationDate="2015-02-26T06:48:23.703" Score="12" Body="&lt;p&gt;It's only a clumsy workaround, but if you &lt;code&gt;:set list&lt;/code&gt; the cursor will be positioned on the other &quot;side&quot; of the tab.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-02-26T06:48:23.703" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2243" PostTypeId="2" ParentId="2219" CreationDate="2015-02-26T08:00:37.633" Score="2" Body="&lt;p&gt;This looks like &lt;a href=&quot;https://code.google.com/p/vim/issues/detail?id=281&quot; rel=&quot;nofollow&quot;&gt;issue 281&lt;/a&gt; and should be fixed with the latest runtime updates. So make sure to update your runtime files and check again.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-02-26T08:00:37.633" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2244" PostTypeId="2" ParentId="1915" CreationDate="2015-02-26T08:17:36.300" Score="1" Body="&lt;p&gt;I don't like to have &lt;code&gt;relativenumber&lt;/code&gt; on all the time, so I configured my Vim to enable it only when I am in Visual Mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Entering Visual mode&#xA;nnoremap &amp;lt;silent&amp;gt;     v :set relativenumber cursorcolumn&amp;lt;CR&amp;gt;v&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-q&amp;gt; :set relativenumber cursorcolumn&amp;lt;CR&amp;gt;&amp;lt;C-q&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;    gv :set relativenumber cursorcolumn&amp;lt;CR&amp;gt;gv&#xA;nnoremap &amp;lt;silent&amp;gt;     V :set relativenumber&amp;lt;CR&amp;gt;V&#xA;&#xA;&quot; When finished&#xA;augroup ClearCursorColumnAndLine&#xA;    autocmd!&#xA;    autocmd CursorHold * set norelativenumber nocursorcolumn nocursorline&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes your task easy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V49jd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;because after hitting &lt;kbd&gt;V&lt;/kbd&gt; you can see how far away the target line is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This may prove annoying in the long run (the text shifts right and left when relativenumber is enabled/disabled), but so far I am quite enjoying it.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-02-26T16:18:13.057" LastActivityDate="2015-02-26T16:18:13.057" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2245" PostTypeId="1" CreationDate="2015-02-26T12:25:18.750" Score="0" ViewCount="349" Body="&lt;p&gt;Playing with abbreviation in insert mode i noticed the following unexpected behaviour, &lt;em&gt;when using gvim with vim-latex plugin&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Defining an abbreviation such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:iab m &amp;lt;m&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or any similar &quot;container&quot; abbreviation such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:iab m \(m\)&#xA;:iab m \m\&#xA;:iab m [m]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on, i get the expected behaviour when simply typing in insert mode&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;m&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;m&amp;lt;shift&amp;gt;&amp;lt;enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;m&amp;lt;ctrl&amp;gt;&amp;lt;enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the &quot;container characters&quot; are doubled, for example in the first two cases above I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;&amp;lt;m&amp;gt;&amp;gt;&#xA;\(\(m\)\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't find this kind of behaviour in the abbreviations section of the man page, nor in the relative vim.wikia page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the vim version 7.4, and I can reproduce this both on Arch Linux and Windows 7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does this happen? Can I prevent it? How?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Developers mailing list&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I submitted the problem on the &lt;a href=&quot;http://sourceforge.net/projects/vim-latex/&quot; rel=&quot;nofollow&quot;&gt;vim-latex mailing list&lt;/a&gt;.&#xA;&lt;a href=&quot;http://sourceforge.net/p/vim-latex/mailman/vim-latex-devel/thread/542A8FBE.4000206@mathematik.tu-chemnitz.de/&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is the response I got:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Hi,&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;this seems to be a strange interaction with the IMAP-features of the&#xA;  latex-suite.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:iab a (m)&#xA;:iab m [a]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Now, &lt;code&gt;a&amp;lt;space&amp;gt;&lt;/code&gt;  =&gt;  &lt;code&gt;(m)&lt;/code&gt; &lt;code&gt;a&amp;lt;s-space&amp;gt;&lt;/code&gt; =&gt; &lt;code&gt;([a])&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Here, first &lt;code&gt;a&lt;/code&gt; is expanded to &lt;code&gt;(m)&lt;/code&gt; and the inner &lt;code&gt;m&lt;/code&gt; is expanded to &lt;code&gt;[a]&lt;/code&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If one uses&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; let Imap_FreezeImap=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; triggers no expansions, but &lt;code&gt;&amp;lt;s-space&amp;gt;&lt;/code&gt; works correctly.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;I have no clue how to fix this.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Best regards, Gerd&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h2&gt;Other unexpected behaviours&lt;/h2&gt;&#xA;&#xA;&lt;h3&gt;Using inoreab&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Following a suggestion in the comments I tried with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoreab n &amp;lt;n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I do this something else happens: typing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;produces&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* &amp;lt;n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with a * character coming from nowhere.&#xA;Typing instead&#xA;&lt;code&gt;n&amp;lt;shift&amp;gt;&amp;lt;space&amp;gt;&lt;/code&gt;&#xA;or &lt;code&gt;n&amp;lt;enter&amp;gt;&lt;/code&gt; or &lt;code&gt;n&amp;lt;ctrl&amp;gt;&amp;lt;enter&amp;gt;&lt;/code&gt;&#xA;I get the expected output &lt;code&gt;&amp;lt;n&amp;gt;&lt;/code&gt;.&#xA;Can you reproduce this?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Without set backspace=eol,indent,start&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Even without using recursive abbreviations, there is a problem if&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set keyboard=eol,start,indent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is &lt;em&gt;not&lt;/em&gt; used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Defining an abbreviation like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:iab alice bob&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and using it typing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alice&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;does not&lt;/strong&gt; substitute &lt;code&gt;alice&lt;/code&gt; with &lt;code&gt;bob&lt;/code&gt;. Instead places &lt;code&gt;bob&lt;/code&gt; at the right of &lt;code&gt;alice&lt;/code&gt;, producing an output like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alice bob&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, using &lt;code&gt;&amp;lt;ctrl&amp;gt;&amp;lt;space&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;enter&amp;gt;&lt;/code&gt; the substitution is made correctly.&lt;/p&gt;&#xA;" OwnerUserId="602" LastEditorUserId="24" LastEditDate="2015-02-27T19:04:40.357" LastActivityDate="2015-02-27T19:04:40.357" Title="Strange behaviour of abbreviations triggered with shift+enter in gvim+vim-latex" Tags="|gvim|plugin-vim-latex|abbreviations|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2246" PostTypeId="2" ParentId="2238" CreationDate="2015-02-26T12:31:44.587" Score="4" Body="&lt;h1&gt;Ninja Feet&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I wrote a plugin called &lt;a href=&quot;https://github.com/tommcdo/vim-ninja-feet&quot; rel=&quot;nofollow&quot;&gt;ninja-feet.vim&lt;/a&gt; that aims to help with this problem.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Motiony Operators&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It defines some motiony operators&lt;sup&gt;1&lt;/sup&gt; that allow you to operate on text from your cursor to one end of a text object. Using &lt;code&gt;[&lt;/code&gt; or &lt;code&gt;]&lt;/code&gt; between the operator and text object causes the operator to operate on text from the cursor to the left or right (respectively) boundary of the text object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also Normal mode operators for starting Insert mode at the beginning or end of a text object: &lt;code&gt;z[&lt;/code&gt; and &lt;code&gt;z]&lt;/code&gt;, respectively.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example 1: Change from here to the end of the string&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In this example, let &lt;code&gt;|&lt;/code&gt; denote the cursor position.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo(&quot;This is a string| with superfluous text at the end&quot;, bar);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;d]i&quot;&lt;/code&gt; will change this to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo(&quot;This is a string&quot;, bar);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;d&lt;/code&gt;: use the delete operator&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;]&lt;/code&gt;: to the end of the following text object &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;i&quot;&lt;/code&gt;: quoted string text object&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;Example 2: Start inserting after the current sentence&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Again, let &lt;code&gt;|&lt;/code&gt; denote the cursor position.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Here is |some sentence. And here is another.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;z]is&lt;/code&gt; will start Insert mode at the end of the first sentence.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;z]&lt;/code&gt;: start Insert mode after the following text object&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;is&lt;/code&gt;: sentence text object&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Caveats&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;These mappings are not repeatable with &lt;code&gt;.&lt;/code&gt;. It's quite tricky and I'm trying to get it right.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; operators (used between operator and text object) only work for text objects that begin with &lt;code&gt;i&lt;/code&gt; or &lt;code&gt;a&lt;/code&gt;. Technically, that's because they're really maps for &lt;code&gt;[i&lt;/code&gt;, &lt;code&gt;]i&lt;/code&gt;, &lt;code&gt;[a&lt;/code&gt; and &lt;code&gt;]a&lt;/code&gt;. I would love to improve this, but it's also very tricky.&lt;/li&gt;&#xA;&lt;li&gt;There are no Normal mode motions to simply move your cursor to an end of a text object. I have gotten it to work, but at the price of the motion actually being an operator (meaning &lt;code&gt;.&lt;/code&gt; will repeat the motion). I don't find that behaviour acceptable.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; I call them motiony operators because they're operators mapped in Operator-pending mode, which is the mode you're in between typing an operator and a motion (e.g. between the &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;w&lt;/code&gt; in &lt;code&gt;dw&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="64" LastEditDate="2015-02-26T14:09:26.657" LastActivityDate="2015-02-26T14:09:26.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2247" PostTypeId="2" ParentId="2129" CreationDate="2015-02-26T13:37:01.857" Score="9" Body="&lt;p&gt;In addition to really useful answers by joeytwiddle and Doorknob don't forget about &lt;code&gt;:b#&lt;/code&gt;, which switches to most recently used buffer. It can also be done with just &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;. When you have a lot of buffers and you constantly switch between them, the most recent buffer is usually the most common destination. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I use combination of many methods. When I'm working with mainly two buffers and the rest is opened just for occasional reference, I tend to switch between them with &lt;code&gt;:b#&lt;/code&gt; or &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;. When I have to work with more of them and switch more often, I use either numbers (as in joeytwiddle tip), or part of names (as in Doorknob tip) with TAB to complete them. When the names are confusing, and there are many buffers opened (usually over 10), I use Ctrl-P plugin more often (&lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;noreferrer&quot; title=&quot;ctrlp&quot;&gt;https://github.com/kien/ctrlp.vim&lt;/a&gt;) With two fast keystrokes I got the list of them all and I'm able to use powerful fuzzy search over them to find quickly what I want. &lt;/p&gt;&#xA;" OwnerUserId="1055" LastActivityDate="2015-02-26T13:37:01.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2248" PostTypeId="1" AcceptedAnswerId="2253" CreationDate="2015-02-26T16:16:08.783" Score="6" ViewCount="634" Body="&lt;p&gt;I mostly want it to automatically create folds for between a &lt;code&gt;begin&lt;/code&gt; and an &lt;code&gt;end&lt;/code&gt;, although if there's anything more advanced that would be welcome too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked in the help for the pascal syntax and it doesn't support syntax folding.&lt;/p&gt;&#xA;" OwnerUserId="1093" LastEditorUserId="23502" LastEditDate="2022-10-31T13:00:07.510" LastActivityDate="2022-10-31T13:00:07.510" Title="How to create syntax folding for pascal?" Tags="|syntax-highlighting|folding|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2249" PostTypeId="1" AcceptedAnswerId="2272" CreationDate="2015-02-26T16:35:23.563" Score="5" ViewCount="940" Body="&lt;p&gt;I have been using Vim as a research database, and I use tags in the form of &lt;code&gt;@tag&lt;/code&gt; for each note, written in the second line after the title. I might have more than one tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make dictionary completion (C-x C-k in insert mode) look in a &lt;code&gt;'tags'&lt;/code&gt; when triggered after an &lt;code&gt;@&lt;/code&gt; sign in insert mode?&lt;/p&gt;&#xA;" OwnerUserId="1095" LastEditorUserId="15" LastEditDate="2015-02-27T14:39:44.537" LastActivityDate="2015-03-04T06:22:35.563" Title="How do I make dictionary completion look in a different file if triggered after the @ sign?" Tags="|autocompletion|tags|word-processing|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2250" PostTypeId="2" ParentId="2220" CreationDate="2015-02-26T16:51:47.173" Score="6" Body="&lt;p&gt;In &lt;em&gt;some&lt;/em&gt; cases, this might be enough:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:changes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately it doesn't show a complete summary of your editing history.  It appears to show only &lt;strong&gt;the line of text which you landed on&lt;/strong&gt; after each change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is good enough to display all single-line inserts or edits, but only the last line of a multi-line insert, and no deleted text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can only be searched visually, not automatically, although you could grab &lt;a href=&quot;https://github.com/joeytwiddle/rc_files/blob/c8264794527c6be685829f08f63fd8dfa2903528/.vim/plugin/joeycommands.vim#L112-131&quot; rel=&quot;noreferrer&quot;&gt;this command&lt;/a&gt; and then do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PipeCmd changes | less&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which would allow searching with &lt;code&gt;/&lt;/code&gt;.  Or just pipe to &lt;code&gt;grep&lt;/code&gt; instead of &lt;code&gt;less&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative way to search that list would be to install the &lt;a href=&quot;https://github.com/Shougo/unite.vim&quot; rel=&quot;noreferrer&quot;&gt;Unite plugin&lt;/a&gt; and then do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Unite change&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-02-26T18:58:08.277" LastActivityDate="2015-02-26T18:58:08.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2252" PostTypeId="2" ParentId="2248" CreationDate="2015-02-26T17:12:31.290" Score="3" Body="&lt;p&gt;The easiest way to create some simple folding is using the &lt;code&gt;foldexpr&lt;/code&gt; option. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim runs this code for every line, you can get the line contents, do some logic with it, and return a number (and some other special values) to tell Vim what the fold level should be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! PascalFold(lnum)&#xA;        &quot; Get the line for which Vim wants to know the folding level&#xA;        let l:line = getline(a:lnum)&#xA;&#xA;        &quot; Does this line begin with 'begin'? Then tell Vim this starts a fold&#xA;        &quot; with level 1&#xA;        if l:line =~ '^begin'&#xA;                return '&amp;gt;1'&#xA;        &quot; Does this line begin with 'end'? Then tell Vim this ends a fold&#xA;        &quot; with level 1&#xA;        elseif l:line =~ '^end'&#xA;                return '&amp;lt;1'&#xA;        &quot; Else use the foldlevel of the previous line (0 or 1)&#xA;        else&#xA;                return '='&#xA;        endif&#xA;endfun&#xA;&#xA;&quot; Set this only for Pascal files&#xA;au FileType pascal setlocal foldmethod=expr foldexpr=PascalFold(v:lnum)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The logic is not very complicated, and should be self-explanatory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have never programmed Pascal, so I don't know the syntax, which is required to give a really good answer (specifically, the &lt;em&gt;anything more advanced&lt;/em&gt; part). If this is not enough to get you started, then perhaps you should explain what you want to fold, exactly, by example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/fold.txt.html#fold-expr&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help fold-expr&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#folding-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help folding-functions&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/2176/51&quot;&gt;How to write a foldexpr?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/2165/51&quot;&gt;Folding by regex search pattern&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;PS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another (perhaps better) way to do this is to set &lt;code&gt;foldmethod=syntax&lt;/code&gt; and modify the &lt;code&gt;syntax/pascal.vim&lt;/code&gt; file... but that requires a bit more work from the looks of it.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-02-26T17:21:52.567" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2253" PostTypeId="2" ParentId="2248" CreationDate="2015-02-26T17:55:02.123" Score="7" Body="&lt;p&gt;The following seems to patch syntax folding onto the Pascal syntax that ships with Vim. Put this into &lt;code&gt;~/.vim/after/syntax/pascal.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn clear pascalLabel pascalStatement pascalStruct&#xA;&#xA;syn keyword pascalLabel     goto label&#xA;syn keyword pascalStatement procedure function&#xA;syn keyword pascalStatement program const var type&#xA;if !exists(&quot;pascal_traditional&quot;)&#xA;  syn keyword pascalStatement   constructor destructor implementation inherited&#xA;  syn keyword pascalStatement   unit uses&#xA;  syntax region pascalInterface matchgroup=pascalStatement start=&quot;\&amp;lt;interface\&amp;gt;&quot; end=&quot;\&amp;lt;end\&amp;gt;&quot; transparent fold&#xA;  syntax region pascalObject matchgroup=pascalStruct start=&quot;\&amp;lt;object\&amp;gt;&quot; end=&quot;\&amp;lt;end\&amp;gt;&quot; transparent fold&#xA;endif&#xA;syn keyword pascalRecordCaseLabel case contained containedin=pascalRecord&#xA;&#xA;syntax region pascalBlock matchgroup=pascalStatement start=&quot;\&amp;lt;begin\&amp;gt;&quot; end=&quot;\&amp;lt;end\&amp;gt;&quot; transparent fold&#xA;syntax region pascalCase matchgroup=pascalLabel start=&quot;\&amp;lt;case\&amp;gt;&quot; end=&quot;\&amp;lt;end\&amp;gt;&quot; transparent fold&#xA;syntax region pascalRecord matchgroup=pascalStruct start=&quot;\&amp;lt;record\&amp;gt;&quot; end=&quot;\&amp;lt;end\&amp;gt;&quot; transparent fold contains=TOP,pascalCase&#xA;&#xA;highlight def link pascalRecordCaseLabel pascalLabel&#xA;&#xA;setlocal foldmethod=syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I had to &lt;code&gt;:syn-clear&lt;/code&gt; some existing definitions. It would be better if the author of the syntax plugin included this into the main script. Also note that I'm not too familiar with Pascal syntax, and hacked this together quickly. No warranties :-)&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-02-26T17:55:02.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2254" PostTypeId="1" AcceptedAnswerId="2256" CreationDate="2015-02-26T21:51:43.973" Score="34" ViewCount="10823" Body="&lt;p&gt;When writing documents occasionally I want to insert Unicode characters into the text. Sometimes I know the character code and sometimes I look it up on the web.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I go to insert mode and then use &lt;code&gt;&amp;lt;Ctrl-V&amp;gt;u{four digit hex number}&lt;/code&gt;, which can be very laborious. Is there an easier way of inserting the characters (maybe some form of pasting)?&lt;/p&gt;&#xA;" OwnerUserId="383" LastEditorUserId="927" LastEditDate="2015-09-13T11:15:07.583" LastActivityDate="2015-12-31T12:32:50.367" Title="What is the easiest way to insert Unicode characters into a document?" Tags="|insert-mode|unicode|input-methods|" AnswerCount="5" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2255" PostTypeId="2" ParentId="2254" CreationDate="2015-02-26T22:22:02.690" Score="20" Body="&lt;p&gt;To insert Unicode characters such as the euro or copyright symbols, or diacritical marks such as the German umlaut or accent grave, &lt;code&gt;digraphs&lt;/code&gt; can be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in insert mode press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;k&lt;/kbd&gt; and type the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Spanish: &lt;code&gt;a'&lt;/code&gt; for &lt;code&gt;á&lt;/code&gt;, &lt;code&gt;E'&lt;/code&gt; for &lt;code&gt;É&lt;/code&gt;, &lt;code&gt;n?&lt;/code&gt; for &lt;code&gt;ñ&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;German: &lt;code&gt;a:&lt;/code&gt; for &lt;code&gt;ä&lt;/code&gt;, &lt;code&gt;ss&lt;/code&gt; for &lt;code&gt;ß&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;other accented letters: &lt;code&gt;a!&lt;/code&gt; for &lt;code&gt;à&lt;/code&gt;, &lt;code&gt;a&amp;gt;&lt;/code&gt; for &lt;code&gt;â&lt;/code&gt; for &lt;code&gt;ê&lt;/code&gt;, &lt;code&gt;a?&lt;/code&gt; for &lt;code&gt;ã&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;Greek: &lt;code&gt;a*&lt;/code&gt; for &lt;code&gt;α&lt;/code&gt; (alpha), &lt;code&gt;b*&lt;/code&gt; for &lt;code&gt;β&lt;/code&gt; (beta), &lt;code&gt;g*&lt;/code&gt; for &lt;code&gt;γ&lt;/code&gt; (gamma), &lt;code&gt;d*&lt;/code&gt; for &lt;code&gt;δ&lt;/code&gt; (delta).&lt;/li&gt;&#xA;&lt;li&gt;square numbers: &lt;code&gt;22&lt;/code&gt; for &lt;code&gt;²&lt;/code&gt;, &lt;code&gt;33&lt;/code&gt; or &lt;code&gt;³&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;currencies: &lt;code&gt;Eu&lt;/code&gt; for &lt;code&gt;€&lt;/code&gt; (Euro), &lt;code&gt;Pd&lt;/code&gt; for &lt;code&gt;£&lt;/code&gt; (Pound),&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Co&lt;/code&gt; for &lt;code&gt;©&lt;/code&gt; (Copyright), &lt;code&gt;DG&lt;/code&gt; for &lt;code&gt;°&lt;/code&gt; (Degree),&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;OK&lt;/code&gt; for &lt;code&gt;✓&lt;/code&gt;, &lt;code&gt;XX&lt;/code&gt; for &lt;code&gt;✗&lt;/code&gt;, &lt;code&gt;Sb&lt;/code&gt; for &lt;code&gt;∙&lt;/code&gt; (bullet),&lt;/li&gt;&#xA;&lt;li&gt;punctuation marks: &lt;code&gt;-N&lt;/code&gt; for &lt;code&gt;–&lt;/code&gt; (en dash), &lt;code&gt;-M&lt;/code&gt; for &lt;code&gt;—&lt;/code&gt; (em dash)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When the digraph option is set (&lt;code&gt;:set dg&lt;/code&gt;), you can also use the following method:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;a&lt;/code&gt;&lt;kbd&gt;Backspace&lt;/kbd&gt;&lt;code&gt;:&lt;/code&gt; for &lt;code&gt;ä&lt;/code&gt;, &lt;code&gt;E&lt;/code&gt;&lt;kbd&gt;Backspace&lt;/kbd&gt;&lt;code&gt;u&lt;/code&gt;for &lt;code&gt;€&lt;/code&gt;, etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To list currently defined digraphs type: &lt;code&gt;:digraphs&lt;/code&gt; (&lt;code&gt;:dig&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://vim.wikia.com/wiki/Entering_special_characters&quot; rel=&quot;nofollow noreferrer&quot;&gt;Entering special characters&lt;/a&gt; at the Vim &lt;a href=&quot;https://en.wikipedia.org/wiki/Wikia&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikia&lt;/a&gt; site.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;OS X&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using OS&amp;nbsp;X, it's very easy to type accented letters anywhere by the following method:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Option&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt;, then &lt;kbd&gt;a&lt;/kbd&gt; for &lt;code&gt;á&lt;/code&gt;, &lt;kbd&gt;e&lt;/kbd&gt; for &lt;code&gt;é&lt;/code&gt;, &lt;kbd&gt;i&lt;/kbd&gt; for &lt;code&gt;í&lt;/code&gt; and similar,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Option&lt;/kbd&gt;+&lt;kbd&gt;n&lt;/kbd&gt;, then &lt;kbd&gt;a&lt;/kbd&gt; for &lt;code&gt;ã&lt;/code&gt;, &lt;kbd&gt;n&lt;/kbd&gt; for &lt;code&gt;ñ&lt;/code&gt; and similar,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Option&lt;/kbd&gt;+&lt;kbd&gt;u&lt;/kbd&gt;, then &lt;kbd&gt;u&lt;/kbd&gt; for &lt;code&gt;ü&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;upside-down punctuation marks: &lt;kbd&gt;Option&lt;/kbd&gt;+&lt;kbd&gt;1&lt;/kbd&gt; for &lt;code&gt;¡&lt;/code&gt;, &lt;kbd&gt;Option&lt;/kbd&gt;+&lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;?&lt;/kbd&gt; for &lt;code&gt;¿&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Working_with_Unicode&quot; rel=&quot;nofollow noreferrer&quot;&gt;Working with Unicode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/2199/what-is-the-easiest-way-to-insert-en-dash-in-vim&quot;&gt;What is the easiest way to insert en dash in Vim?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-12-31T12:32:50.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2256" PostTypeId="2" ParentId="2254" CreationDate="2015-02-26T22:57:02.470" Score="24" Body="&lt;p&gt;&lt;strong&gt;Preface&lt;/strong&gt;: This has nothing to do with Vim as such, but I will show you what I consider to be the &quot;best&quot; way to insert these characters by far; Vim's digraph system is more or less the same, but it only works with Vim. This will work in &lt;em&gt;all&lt;/em&gt; applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This will only work for X11 systems&lt;/strong&gt; (Linux, BSD, etc.). &lt;strong&gt;For Windows, there's &lt;a href=&quot;http://sourceforge.net/projects/allchars/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AllChars&lt;/a&gt;&lt;/strong&gt;. It hasn't been updated in a while, but I can confirm it works well with Windows&amp;nbsp;7 (used it at my previous job). I believe OS&amp;nbsp;X also has good facilities to do this built in the OS; if you use OS&amp;nbsp;X, I encourage you to check them out, but as I've never really used OS&amp;nbsp;X I can't point you to them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The below is (part of) a draft weblog article I have in the pipeline. Unfortunately a truly comprehensive guide doesn't exist (yet), and the below doesn't describe &lt;em&gt;all&lt;/em&gt; the features it offers (for example, some parts about dead keys are missing) and could be better written in some parts, but I think it's still &quot;useful enough&quot;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A ‘compose sequence’ is pressing the &lt;kbd&gt;Compose&lt;/kbd&gt; key and then one or more characters to produce some character not found on your keyboard, for example, pressing  &lt;kbd&gt;Compose&lt;/kbd&gt;, immediately followed by &lt;kbd&gt;&quot;&lt;/kbd&gt; and &lt;kbd&gt;a&lt;/kbd&gt; might produce an &lt;code&gt;ä&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, &lt;kbd&gt;Compose&lt;/kbd&gt; isn’t bound to any key&lt;sup&gt;1&lt;/sup&gt;; the Right &lt;kbd&gt;Alt&lt;/kbd&gt; key (aka. &lt;kbd&gt;Alt Gr&lt;/kbd&gt;) is often used, but you set this to any key you want.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Set it using xmodmap&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;http://www.x.org/archive/current/doc/man/man1/xmodmap.1.xhtml&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;xmodmap&lt;/code&gt;&lt;/a&gt;&#xA;to set this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ xmodmap -e 'keysym Alt_R = Multi_key'     # Set it right Alt&#xA;$ xmodmap -e 'keysym Caps_Lock = Multi_key' # Set it to Caps Lock&#xA;$ xmodmap -e 'keysym F12 = Multi_key'       # You're free to use *any* key, like F12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You probably want to add this to your &lt;code&gt;~/.Xmodmap&lt;/code&gt; file&lt;sup&gt;2&lt;/sup&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;! Set compose key&#xA;keysym Alt_R = Multi_key&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Set it using XKB&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can also set the compose key as an option to XKB with&#xA;&lt;a href=&quot;http://linux.die.net/man/1/setxkbmap&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;setxkbmap&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setxkbmap -option compose:ralt  # Right alt&#xA;setxkbmap -option compose:caps  # Caps Lock&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make these permanent, add the command to your X startup file, or&#xA;alternatively, you can also set it in &lt;code&gt;/etc/X11/xorg.conf&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Section &quot;InputDevice&quot;&#xA;    Identifier &quot;Keyboard0&quot;&#xA;    Driver &quot;kbd&quot;&#xA;    Option &quot;XkbOptions&quot; &quot;compose:ralt&quot;&#xA;    #Option &quot;XkbOptions&quot; &quot;compose:caps&quot;&#xA;EndSection&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, in a more ‘modern’ style, you can create a file&#xA;&lt;code&gt;/etc/X11/xorg.conf.d/90-compose.conf&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Section &quot;InputClass&quot;&#xA;    Identifier &quot;Set compose key&quot;&#xA;    MatchIsKeyboard &quot;on&quot;&#xA;    Option &quot;XkbOptions&quot; &quot;compose:ralt&quot;&#xA;EndSection&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A list of possible values can be found in &lt;a href=&quot;http://www.dsm.fordham.edu/cgi-bin/man-cgi.pl?topic=xkeyboard-config&amp;amp;ampsect=7&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;xkeyboard-config(7)&lt;/code&gt;&lt;/a&gt;, section ‘Position of Compose key’&lt;sup&gt;3&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Setting up dead keys&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A dead key is chiefly used to add a accent or diacritic to a letter (such as the umlaut, accent grave, etc.), although it can be used to create any character. It works by...TODO&#xA;&lt;kbd&gt;'&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;keycode 133 = dead_greek NoSymbol SuperR&#xA;&#xA;http://zuttobenkyou.wordpress.com/2011/08/24/xorg-using-the-us-international-altgr-intl-variant-keyboard-layout/&#xA;http://stackoverflow.com/questions/14922007/how-to-enter-greek-alpha-under-xor&#xA;keycode 48 = dead_grave apostrophe&#xA;&#xA;&#xA;&amp;lt;dead_grave&amp;gt; &amp;lt;space&amp;gt;       : &quot;`&quot;   grave # GRAVE ACCENT&#xA;&amp;lt;dead_grave&amp;gt; &amp;lt;dead_grave&amp;gt;  : &quot;`&quot;   grave # GRAVE ACCENT&#xA;&amp;lt;dead_grave&amp;gt; &amp;lt;a&amp;gt;           : &quot;À&quot;   agrave # LATIN CAPITAL LETTER A WITH GRAVE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Making a ~/.XCompose file&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The default Compose file if &lt;code&gt;~/.XCompose&lt;/code&gt; is missing is&#xA;&lt;code&gt;/usr/share/X11/locale/$LANG/Compose&lt;/code&gt;. Having your own &lt;code&gt;~/.XCompose&lt;/code&gt; overrides the default, but you can still include the default with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;include &quot;%L&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Changes to any Compose file takes effect when you restart an application. You don't need to restart X.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Compose key&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A 'compose sequence' is pressing the &lt;kbd&gt;Compose&lt;/kbd&gt; key and then one or more characters to produce some character, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Multi_key&amp;gt; &amp;lt;quotedbl&amp;gt; &amp;lt;a&amp;gt; : &quot;ä&quot; adiaeresis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Means that pressing &lt;kbd&gt;Compose&lt;/kbd&gt;, immediately followed by &lt;kbd&gt;&quot;&lt;/kbd&gt; and&#xA;&lt;kbd&gt;a&lt;/kbd&gt; produces an &lt;code&gt;ä&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;Multi_key&amp;gt;&lt;/code&gt; denotes that we're using the &lt;kbd&gt;Compose&lt;/kbd&gt; key.&#xA;we then follow this by a list of one or more keys, these have to be &lt;code&gt;keysyms&lt;/code&gt;, which are symbolic representations of keys used by X (See the Keysyms section).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Followed by a &lt;code&gt;:&lt;/code&gt;, followed by the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Multi_key&amp;gt; &amp;lt;a&amp;gt;          :  &quot;ä&quot; adiaeresis&#xA;&amp;lt;Multi_key&amp;gt; &amp;lt;b&amp;gt; &amp;lt;b&amp;gt;      :  &quot;ä&quot; adiaeresis&#xA;&amp;lt;Multi_key&amp;gt; &amp;lt;c&amp;gt; &amp;lt;c&amp;gt; &amp;lt;c&amp;gt;  :  &quot;ä&quot; adiaeresis&#xA;&amp;lt;Multi_key&amp;gt; Alt &amp;lt;d&amp;gt;      :  &quot;ä&quot; adiaeresis&#xA;&amp;lt;Multi_key&amp;gt; Ctrl &amp;lt;e&amp;gt;     :  &quot;ä&quot; adiaeresis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: A Compose file is case-sensitive, so &lt;code&gt;A&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; the same as &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Dead keys&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;TODO&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Make it work in GTK &amp;amp; Qt&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Set the environment variables &lt;code&gt;GTK_IM_MODULE&lt;/code&gt; &amp;amp; &lt;code&gt;QT_IM_MODULE&lt;/code&gt; to &lt;code&gt;xim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bourne shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Make compose key work for GTK, Qt&#xA;export GTK_IM_MODULE=xim&#xA;export QT_IM_MODULE=xim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;C shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Make compose key work for GTK, Qt&#xA;setenv GTK_IM_MODULE xim&#xA;setenv QT_IM_MODULE xim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;See Also&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.x.org/releases/X11R7.7/doc/man/man5/Compose.5.xhtml&quot; rel=&quot;nofollow noreferrer&quot;&gt;Compose(5)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.x.org/wiki/XKB/&quot; rel=&quot;nofollow noreferrer&quot;&gt;XKB&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://wiki.edubuntu.org/ComposeKey&quot; rel=&quot;nofollow noreferrer&quot;&gt;ComposeKey at edubuntu wiki&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://help.ubuntu.com/community/ComposeKey&quot; rel=&quot;nofollow noreferrer&quot;&gt;ComposeKey at Ubuntu wiki&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://wiki.archlinux.org/index.php/Keyboard_Configuration_in_Xorg&quot; rel=&quot;nofollow noreferrer&quot;&gt;ArchLinux Wiki&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/60884/how-to-make-compose-work-in-gtk-and-qt-apps&quot;&gt;How to make Compose work in GTK and Qt apps?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Compose_key&quot; rel=&quot;nofollow noreferrer&quot;&gt;Compose key at Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Dead_key&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dead key at Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://sourceforge.net/projects/allchars/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AllChars&lt;/a&gt; (compose key for MS Windows)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://help.gnome.org/users/gnome-help/stable/tips-specialchars.html.en&quot; rel=&quot;nofollow noreferrer&quot;&gt;Enabling Compose Key in GNOME&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;My &lt;code&gt;~/.XCompose&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://bitbucket.org/Carpetsmoker/config/src/tip/modules/x11/XCompose?at=default&quot; rel=&quot;nofollow noreferrer&quot;&gt;This is the &lt;code&gt;~/.XCompose&lt;/code&gt; that I use&lt;/a&gt;;&#xA;I used a script to generate this, but I accidentally overwrote this when compiling it &gt;_&amp;lt; So I need to rewrite it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also take note of this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Multi_key&amp;gt; &amp;lt;i&amp;gt; &amp;lt;b&amp;gt; : &quot;NL65AEGO0721647952&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;Compose ib&lt;/kbd&gt; will insert this string (a random test IBAN number); very useful for testing applications where such a number is required to create some object (Person, Organisation); XCompose can also serve as a &quot;snippet&quot; tool :-)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Footnotes&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;1:&#xA;Some UNIX keyboards had a dedicated &lt;kbd&gt;Compose&lt;/kbd&gt; key (&lt;a href=&quot;http://en.wikipedia.org/wiki/Compose_key#mediaviewer/File:Compose_key_on_Sun_Type_5c_keyboard.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;like this&#xA;SUN&lt;/a&gt;),&#xA;but this is fairly uncommon these days.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2:&#xA;Depending on your existing setup, this may or may not be read at startup,&#xA;depending on your config, add the line &lt;code&gt;xmodmap ~/.Xmodmap&lt;/code&gt; to either&#xA;&lt;code&gt;~/.xinitrc&lt;/code&gt; or &lt;code&gt;~/.xsession&lt;/code&gt;;&#xA;&lt;a href=&quot;https://wiki.archlinux.org/index.php/Xmodmap#Activating_the_custom_table&quot; rel=&quot;nofollow noreferrer&quot;&gt;also see the ArchLinux wiki&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3:&#xA;Reproduced for your benefit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Position of Compose key&#xA;    +------------------------------------------------------+&#xA;    |Option                Description                     |&#xA;    +------------------------------------------------------+&#xA;    |compose:ralt          Right Alt                       |&#xA;    |compose:lwin          Left Win                        |&#xA;    |compose:lwin-altgr    3rd level of Left Win           |&#xA;    |compose:rwin          Right Win                       |&#xA;    |compose:rwin-altgr    3rd level of Right Win          |&#xA;    |compose:menu          Menu                            |&#xA;    |compose:menu-altgr    3rd level of Menu               |&#xA;    |compose:lctrl         Left Ctrl                       |&#xA;    |compose:lctrl-altgr   3rd level of Left Ctrl          |&#xA;    |compose:rctrl         Right Ctrl                      |&#xA;    |compose:rctrl-altgr   3rd level of Right Ctrl         |&#xA;    |compose:caps          Caps Lock                       |&#xA;    |compose:caps-altgr    3rd level of Caps Lock          |&#xA;    |compose:102           &amp;lt;Less/Greater&amp;gt;                  |&#xA;    |compose:102-altgr     3rd level of &amp;lt;Less/Greater&amp;gt;     |&#xA;    |compose:paus          Pause                           |&#xA;    |compose:prsc          PrtSc                           |&#xA;    |compose:sclk          Scroll Lock                     |&#xA;    +------------------------------------------------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2015-09-13T11:14:55.563" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="2257" PostTypeId="2" ParentId="2254" CreationDate="2015-02-27T01:29:42.587" Score="3" Body="&lt;p&gt;In adition to using the predefined digraphs (Run &lt;code&gt;:dig&lt;/code&gt; to get a list), you can also define your own digraphs in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:digr e: 235 a: 228&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/digraph.html&quot; rel=&quot;nofollow&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/digraph.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1101" LastActivityDate="2015-02-27T01:29:42.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2258" PostTypeId="2" ParentId="2254" CreationDate="2015-02-27T08:33:42.710" Score="4" Body="&lt;p&gt;For commonly used characters, &lt;code&gt;:digraph&lt;/code&gt; or external means such as the mentioned &lt;em&gt;Compose&lt;/em&gt; key are great. For rarely used ones, I define abbreviations, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;norea &amp;lt;unique&amp;gt; unicode_smiley &#xA;norea &amp;lt;unique&amp;gt; unicode_skull ☠&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then use my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2926&quot; rel=&quot;nofollow&quot;&gt;SnippetComplete plugin&lt;/a&gt; to get a popup menu that list all such abbreviations, e.g. : &lt;code&gt;unicode_&amp;lt;C-x&amp;gt;]&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-02-27T08:33:42.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2259" PostTypeId="2" ParentId="2245" CreationDate="2015-02-27T10:55:19.697" Score="2" Body="&lt;p&gt;Your updated findings give it away: The Latex plugin (incorrectly, that's why &lt;code&gt;:inoremap&lt;/code&gt; causes the addition of a &lt;code&gt;*&lt;/code&gt;) parses the output of the &lt;code&gt;:iab&lt;/code&gt; command in &lt;code&gt;s:LookupCharacter(char)&lt;/code&gt; from &lt;code&gt;plugin/imaps.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            &quot; An extremeley wierd way to get around the fact that vim&#xA;            &quot; doesn't have the equivalent of the :mapcheck() function for&#xA;            &quot; abbreviations.&#xA;            let _a = @a&#xA;            exec &quot;redir @a | silent! iab &quot;.lastword.&quot; | redir END&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, the problem is with the plugin's &lt;code&gt;IMAP()&lt;/code&gt; function, which purportedly has the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Motivation:&#xA;&quot; this script provides a way to generate insert mode mappings which do not&#xA;&quot; suffer from some of the problem of mappings and abbreviations while allowing&#xA;&quot; cursor placement after the expansion. It can alternatively be thought of as&#xA;&quot; a template expander.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Therefore, it's a bug in the plugin; you either need to wait for / submit a patch, or avoid the problem by not defining such &lt;code&gt;:iab&lt;/code&gt; yourself. (Maybe using the provided &lt;code&gt;IMAP()&lt;/code&gt; function consistently will solve this?)&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-02-27T10:55:19.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2260" PostTypeId="1" AcceptedAnswerId="2263" CreationDate="2015-02-27T13:05:19.860" Score="9" ViewCount="720" Body="&lt;p&gt;I am in the slightly unusual position of using two different keyboard layouts on a regular basis (&lt;a href=&quot;http://www.kaufmann.no/roland/dvorak/index.html&quot; rel=&quot;noreferrer&quot;&gt;Programmers-Dvorak&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Keyboard_layout#mediaviewer/File:KB_Turkey_f_yeni.svg&quot; rel=&quot;noreferrer&quot;&gt;Turkish-F&lt;/a&gt;). These layouts are quite different from each-other and I am only able to be proficient in vim with one set of muscle memories. I'm pretty proficient with vim commands in the Dvorak layout, but it's almost impossible to use if my keyboard is in the Turkish-F layout. Unfortunately I regularly edit files in both English and Turkish and even mixed languages. My proficiency is such that I can type either language in it's respective keyboard layout rather well, but my brain refuses to cross-wire them and type even a few letters of a word in Turkish from the Dvorak layout or vise versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two-key-salute bindings for changing the layout in Xorg, but even this leaves me with an awkward workflow in vim when editing mixed language files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;vim commands…&amp;gt;i&amp;lt;switch to tr&amp;gt;…content…&amp;lt;escape&amp;gt;&amp;lt;switch to en&amp;gt;&amp;lt;vim commands…&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to be able to shorten this to something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;vim commands…&amp;gt;&amp;lt;leader&amp;gt;i…content…&amp;lt;escape&amp;gt;&amp;lt;vim commands…&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...such that using &lt;code&gt;&amp;lt;leader&amp;gt;i&lt;/code&gt; sets a bunch of &lt;code&gt;:imap&lt;/code&gt; values to emulate the Turkish layout without changing the system keyboard layout. At the same time, &lt;code&gt;i&lt;/code&gt; would switch to insert mode but without the extra &lt;code&gt;:imap&lt;/code&gt; values. The values themselves are easy, I just need the alphabet mappings something like these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap a u&#xA;:imap A U&#xA;:imap o i&#xA;:imap O İ&#xA;&quot;etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The question is, how to setup two insert modes, one normal insert mode and one pseudo insert mode that is identical except for a bunch of mappings, and how can I trigger these modes with &lt;code&gt;&amp;lt;leader&amp;gt;i&lt;/code&gt;, &lt;code&gt;&amp;lt;leader&amp;gt;a&lt;/code&gt;, etc.?&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="24" LastEditDate="2015-02-28T08:34:50.337" LastActivityDate="2015-02-28T10:05:36.687" Title="How can I create a pseudo insert mode with a different keymap?" Tags="|key-bindings|insert-mode|keyboard-layout|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2261" PostTypeId="1" AcceptedAnswerId="2262" CreationDate="2015-02-27T13:14:50.067" Score="4" ViewCount="1621" Body="&lt;p&gt;When editing Python files at work I have to include 20+ lines of boilerplate legalese at the start of the file. &quot;start of the file&quot; is not that strict: I'm allowed to include the Python docstring, and future imports before the boilerplate. But the boilerplate itself is very strict, I have to include it verbatim from a company template. Specifically: I am not allowed to indent it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Python I use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set foldmethod=indent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I would like to be able to fold away that boilerplate as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to tweak the indent foldmethod to fold lines starting/ending with '#' as well? Or will I need to change to &lt;code&gt;foldmethod=expr&lt;/code&gt; and write my own folding function?&lt;/p&gt;&#xA;" OwnerUserId="182" LastEditorUserId="23502" LastEditDate="2022-10-31T12:59:22.020" LastActivityDate="2022-10-31T12:59:22.020" Title="Can I get Vim to fold comments when using foldmethod=indent?" Tags="|indentation|folding|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2262" PostTypeId="2" ParentId="2261" CreationDate="2015-02-27T13:39:42.313" Score="4" Body="&lt;p&gt;The cleanest would be to re-implement Vim's indent-folding via a custom &lt;code&gt;'foldexpr'&lt;/code&gt;, and make that consider the legalese via a special case. &lt;code&gt;:help fold-indent&lt;/code&gt; even gives implementation hints:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;  The indent() function can be used in 'foldexpr' to get the indent of a line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Another option is described nearby:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;Some lines are ignored and get the fold level of the line above or below it,&#xA;whichever is lower.  These are empty or white lines and lines starting&#xA;with a character in 'foldignore'.  White space is skipped before checking for&#xA;characters in 'foldignore'.  For C use &quot;#&quot; to ignore preprocessor lines.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To use this, you'd need to have non-commented indented Python statements both above and below the block of legalese, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    some Python statement&#xA;# legalese&#xA;# is comments&#xA;# starting in first column&#xA;    another Python statement&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;:setlocal foldmethod=indent foldignore=#&lt;/code&gt;, the above will be folded as one block.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-02-27T13:39:42.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2263" PostTypeId="2" ParentId="2260" CreationDate="2015-02-27T13:45:31.980" Score="7" Body="&lt;p&gt;Vim has something like this in the form of &lt;em&gt;keymaps&lt;/em&gt;. From &lt;code&gt;:help mbyte-keymap&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;When the keyboard doesn't produce the characters you want to enter in your&#xA;text, you can use the 'keymap' option.  This will translate one or more&#xA;(English) characters to another (non-English) character.  This only happens&#xA;when typing text, not when typing Vim commands.  This avoids having to switch&#xA;between two keyboard settings.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Insert-mode_only_Caps_Lock&quot;&gt;Insert-mode only Caps Lock&lt;/a&gt; describes such a mapping for emulation of Caps Lock; as you can see there, the mappings file is similar to what you outline in your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You enable this setting via &lt;code&gt;:set iminsert=1&lt;/code&gt; or dynamically via &lt;code&gt;i_CTRL-^&lt;/code&gt;. It also works for &lt;code&gt;/search&lt;/code&gt; with the &lt;code&gt;'imsearch'&lt;/code&gt; option.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-02-27T13:45:31.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2264" PostTypeId="1" AcceptedAnswerId="2265" CreationDate="2015-02-27T14:48:44.463" Score="4" ViewCount="210" Body="&lt;p&gt;I'm trying to vimify a task of editing bulk file move commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Fossil-SCM to manage a bunch of files and have some changes in directory structure. To get SCM to grasp the move, I have to supply the command &lt;code&gt;fossil mv oldname newname&lt;/code&gt; for each file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since it is some hundrets of files and different directories that changed, I have saved the output of fossil into a file showing on each line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MISSING    /path/to/missing/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to change that to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fossil mv &quot;/path/to/missing/file&quot; &quot;/path/to/missing/file&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From there on theres nothing left than walk manually through the lines and change directory names as needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this conversion could safe much time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using RegEx, but somehow seems VIM to not accept the grouping... I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1;$s/^MISSING (.*)$/^fossil mv \&quot;\1\&quot; \&quot;\1\&quot;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But as soon as i try to use parentheses in the search definition, vim states the pattern could not be found. So what would be the most vimic way to solve this?&lt;/p&gt;&#xA;" OwnerUserId="826" LastEditorUserId="24" LastEditDate="2015-02-27T19:01:53.257" LastActivityDate="2015-02-27T19:01:53.257" Title="Duplicating line content by substitution" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2265" PostTypeId="2" ParentId="2264" CreationDate="2015-02-27T14:52:42.270" Score="9" Body="&lt;p&gt;Usually, &lt;code&gt;vim&lt;/code&gt; uses something akin to Basic Regular Expressions (BRE). You need to use &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^MISSING *\(.*\)$/fossil mv &quot;\1&quot; &quot;\1&quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or prefix the pattern with &lt;code&gt;\v&lt;/code&gt;. From &lt;code&gt;:he regexp&lt;/code&gt; (more specifically, &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2Fmagic&quot;&gt;&lt;code&gt;:he /magic&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;after:    \v       \m       \M       \V         matches&#xA;                'magic' 'nomagic'    &#xA;          $        $        $        \$         matches end-of-line&#xA;          .        .        \.       \.         matches any character&#xA;          *        *        \*       \*         any number of the previous atom&#xA;          ()       \(\)     \(\)     \(\)       grouping into an atom&#xA;          |        \|       \|       \|         separating alternatives  &#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the magical expression would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v^MISSING *(.*)$/fossil mv &quot;\1&quot; &quot;\1&quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-02-27T14:52:42.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2266" PostTypeId="1" AcceptedAnswerId="2267" CreationDate="2015-02-27T15:01:40.647" Score="30" ViewCount="7327" Body="&lt;p&gt;I want to open up two different parts of a document in horizontal splits (using &lt;code&gt;:sp&lt;/code&gt;) and scroll both of them left and right together. For vertical scrolling, you would use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/scroll.html&quot;&gt;&lt;code&gt;scrollbind&lt;/code&gt;&lt;/a&gt;. However, I'm not sure what to use for horizontal scrolling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the capability must be available because when I use &lt;code&gt;vimdiff&lt;/code&gt;, it scrolls horizontally in both documents at the same time.&lt;/p&gt;&#xA;" OwnerUserId="1111" LastActivityDate="2015-02-27T18:41:58.220" Title="How can I get both splits to scroll left or right at the same time?" Tags="|split|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2267" PostTypeId="2" ParentId="2266" CreationDate="2015-02-27T15:08:16.487" Score="32" Body="&lt;p&gt;To scroll two windows together in vim, need to run &lt;code&gt;:set scrollbind&lt;/code&gt; in each of them. As you noted, by default, this only binds vertical scrolling. In the docs for scrollbind, it mentions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The behavior of 'scrollbind' can be modified by the 'scrollopt' option.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help scrollopt&lt;/code&gt; reveals that you want to say &lt;code&gt;:set scrollopt+=hor&lt;/code&gt; to enable horizontal scrolling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just want horizontal scrolling (i.e. disable vertical scrolling), then you will also want to say &lt;code&gt;:set scollopt-=ver&lt;/code&gt; or explicitly set scrollopt via &lt;code&gt;set scrollopt=hor&lt;/code&gt; or &lt;code&gt;:set scrollopt=hor,jump&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="680" LastEditorUserId="680" LastEditDate="2015-02-27T18:41:58.220" LastActivityDate="2015-02-27T18:41:58.220" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2268" PostTypeId="1" AcceptedAnswerId="2279" CreationDate="2015-02-27T15:18:55.777" Score="20" ViewCount="3538" Body="&lt;p&gt;Many Unix tools' regular expression syntaxes are often the POSIX-codified Basic and Extended Regular Expressions (BRE and ERE, respectively), and, in some modern implementations, Perl-style (PCRE being an implementation of this). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a one-to-one correspondence between Vim's levels of magic and such externally defined, but well-known, classes? It looks like &lt;code&gt;\m&lt;/code&gt; is BRE and &lt;code&gt;\v&lt;/code&gt; is ERE, except POSIX doesn't include lookarounds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If such a correspondence exists, is it defined somewhere? &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html&quot;&gt;&lt;code&gt;pattern.txt&lt;/code&gt;&lt;/a&gt; has only one mention of &lt;code&gt;POSIX&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or do we have to stick with &quot;magic&quot; to describe Vim regular expressions?&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-02-28T01:33:13.200" Title="Are Vim's regex magics compatible with well-known regex classes?" Tags="|regular-expression|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2269" PostTypeId="1" CreationDate="2015-02-27T17:04:25.907" Score="4" ViewCount="1277" Body="&lt;p&gt;In 'nomagic' mode, &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt; have a special meaning and no others do. Why were these selected, rather than making people type &lt;code&gt;\^&lt;/code&gt; and &lt;code&gt;\$&lt;/code&gt; just as they do for &lt;code&gt;\.&lt;/code&gt; and &lt;code&gt;\*&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I have been able to confirm that this behavior, and the magic option, goes back to ex version 1.1 (&lt;a href=&quot;http://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/ex-1.1/ex_re.c&quot; rel=&quot;nofollow&quot;&gt;regex implementation&lt;/a&gt;, &lt;a href=&quot;http://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/ex-1.1/ex_set.c&quot; rel=&quot;nofollow&quot;&gt;options&lt;/a&gt;). The structure also suggests an answer for &lt;code&gt;^&lt;/code&gt;: It is handled specially outside the main loop.&lt;/p&gt;&#xA;" OwnerUserId="880" LastEditorUserId="205" LastEditDate="2015-02-27T20:45:43.997" LastActivityDate="2015-02-27T20:45:43.997" Title="Why are ^ and $ still magic in nomagic mode?" Tags="|regular-expression|options|history-of|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2270" PostTypeId="2" ParentId="2269" CreationDate="2015-02-27T18:47:19.450" Score="3" Body="&lt;p&gt;Apparently magic/nomagic dates back to Ex (mentioned in the &lt;a href=&quot;http://roguelife.org/~fujita/COOKIES/HISTORY/1BSD/exrefm.pdf&quot; rel=&quot;nofollow&quot;&gt;pdf user manual&lt;/a&gt;), but I'm not sure of the reasoning behind the original decision. If you're using Vim, there are 4 levels of 'magic' you can use. The two additional modes are explained in &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2Fmagic&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help /magic&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Use of &quot;\v&quot; means that in the pattern after it all ASCII characters except&#xA;'0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning.  &quot;very magic&quot;&#xA;&#xA;Use of &quot;\V&quot; means that in the pattern after it only the backslash has a&#xA;special meaning.  &quot;very nomagic&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This at least seems to have some logic to it. If you want no characters to have special meaning besides &lt;code&gt;\&lt;/code&gt; in Vim, you can start your pattern with &lt;code&gt;\V&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="680" LastEditorUserId="205" LastEditDate="2015-02-27T20:43:56.387" LastActivityDate="2015-02-27T20:43:56.387" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2271" PostTypeId="2" ParentId="2269" CreationDate="2015-02-27T19:21:54.640" Score="5" Body="&lt;p&gt;The &lt;code&gt;nomagic&lt;/code&gt; setting was created to support the &lt;code&gt;edit&lt;/code&gt; mode, which was &quot;designed for more casual or beginning users&quot;, rather than as a general &quot;nothing is a metacharacter&quot; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/exrefm/exrefma.n&quot; rel=&quot;nofollow&quot;&gt;From the ex reference manual&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The &lt;em&gt;ex&lt;/em&gt; default setting of &lt;em&gt;magic&lt;/em&gt; gives quick access to a powerful set of regular expression metacharacters. The disadvantage of &lt;em&gt;magic&lt;/em&gt; is that the user must remember that these metacharacters are &lt;em&gt;magic&lt;/em&gt; and precede them with the character '\' to use them as &quot;ordinary&quot; characters. With &lt;em&gt;nomagic&lt;/em&gt;, the default for &lt;em&gt;edit&lt;/em&gt;, regular expressions are much simpler, there being only two metacharacters. The power of the other metacharacters is still available by preceding the (now) ordinary character with a '\'. Note that '\' is thus always a metacharacter.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The remainder of the discussion of regular expressions assumes that that the setting of this option is &lt;em&gt;magic&lt;/em&gt;. To discern what is true with &lt;em&gt;nomagic&lt;/em&gt; it suffices to remember that the only special characters in this case will be '^' at the beginning of a regular expression, '$' at the end of a regular expression, and '\'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When started as &lt;code&gt;edit&lt;/code&gt;, ex 1.1 sets &lt;code&gt;noopen&lt;/code&gt; (not permitted to enter visual mode), &lt;code&gt;nomagic&lt;/code&gt;, and &lt;code&gt;notify=1&lt;/code&gt; (ex default is 5, &lt;code&gt;notify&lt;/code&gt; is equivalent to vim &lt;code&gt;report&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;nomagic&lt;/code&gt; setting also affects the usage of &lt;code&gt;&amp;amp;&lt;/code&gt; and &lt;code&gt;~&lt;/code&gt; in substitution commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Still no idea why, but we'd probably have to ask someone who was at Berkeley in the '70s for that.)&lt;/p&gt;&#xA;" OwnerUserId="880" LastEditorUserId="880" LastEditDate="2015-02-27T19:48:21.140" LastActivityDate="2015-02-27T19:48:21.140" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2272" PostTypeId="2" ParentId="2249" CreationDate="2015-02-27T20:19:46.897" Score="4" Body="&lt;p&gt;Does it have to be dictionary completion, triggered via &lt;code&gt;i_CTRL-X_CTRL-K&lt;/code&gt;? If another trigger key is fine (e.g. &lt;code&gt;i_CTRL-X_CTRL-@&lt;/code&gt;), you can do this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Save the &lt;code&gt;'dictionary'&lt;/code&gt; option value&lt;/li&gt;&#xA;&lt;li&gt;Change it to point to your tags file&lt;/li&gt;&#xA;&lt;li&gt;Install an &lt;code&gt;:autocmd CompleteDone&lt;/code&gt; handler that resets the option value&lt;/li&gt;&#xA;&lt;li&gt;Trigger dictionary completion&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;Alternative&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you don't actually need dictionary completion, just some values from a particular file, you can alternatively look at my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=5073&quot; rel=&quot;nofollow&quot;&gt;EntryComplete plugin&lt;/a&gt;; it provides configuable sources.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-02-27T20:19:46.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2273" PostTypeId="2" ParentId="2207" CreationDate="2015-02-27T20:26:52.287" Score="11" Body="&lt;p&gt;I find the following commands much more intuitive than &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;-&lt;kbd&gt;x&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help CTRL-W_K&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The following commands can be used to change the window layout.  For example,&#xA;when there are two vertically split windows, CTRL-W K will change that in&#xA;horizontally split windows.  CTRL-W H does it the other way around.&#xA;&#xA;                        *CTRL-W_K*&#xA;CTRL-W K    Move the current window to be at the very top, using the full&#xA;        width of the screen.  This works like closing the current&#xA;        window and then creating another one with &quot;:topleft split&quot;,&#xA;        except that the current window contents is used for the new&#xA;        window.&#xA;&#xA;                        *CTRL-W_J*&#xA;CTRL-W J    Move the current window to be at the very bottom, using the&#xA;        full width of the screen.  This works like closing the current&#xA;        window and then creating another one with &quot;:botright split&quot;,&#xA;        except that the current window contents is used for the new&#xA;        window.&#xA;&#xA;                        *CTRL-W_H*&#xA;CTRL-W H    Move the current window to be at the far left, using the&#xA;        full height of the screen.  This works like closing the&#xA;        current window and then creating another one with&#xA;        &quot;:vert topleft split&quot;, except that the current window contents&#xA;        is used for the new window.&#xA;        {not available when compiled without the |+vertsplit| feature}&#xA;&#xA;                        *CTRL-W_L*&#xA;CTRL-W L    Move the current window to be at the far right, using the full&#xA;        height of the screen.  This works like closing the&#xA;        current window and then creating another one with&#xA;        &quot;:vert botright split&quot;, except that the current window&#xA;        contents is used for the new window.&#xA;        {not available when compiled without the |+vertsplit| feature}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These commands can change the window's size, however, so be aware of that.&lt;/p&gt;&#xA;" OwnerUserId="93" LastActivityDate="2015-02-27T20:26:52.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2274" PostTypeId="1" CreationDate="2015-02-27T20:48:39.450" Score="0" ViewCount="227" Body="&lt;p&gt;Just like in the title. I know most Linux distributions ship with vim and most BSDs use nvi, but I was wondering if there are any &quot;obscure&quot; versions of vi on some commercial UNIX or other platform, with their own extended commands that are not covered by the POSIX standard. Or, for that matter, any platforms that use some other vi clone (Elvis, Vile, etc) for the purpose.&lt;/p&gt;&#xA;" OwnerUserId="880" LastEditorUserId="880" LastEditDate="2015-02-27T21:57:17.697" LastActivityDate="2015-03-02T13:03:31.930" Title="Are there any platforms whose native `vi` is not vim, nvi, or original vi?" Tags="|history-of|" AnswerCount="1" CommentCount="2" ClosedDate="2015-03-07T03:24:07.077" ContentLicense="CC BY-SA 3.0" />
  <row Id="2275" PostTypeId="1" AcceptedAnswerId="2277" CreationDate="2015-02-27T21:10:40.093" Score="20" ViewCount="3959" Body="&lt;p&gt;Vim's documentation has this to say about the &lt;code&gt;:open&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This command is in Vi, but Vim only simulates it:&#xA;&#xA;                                                        *:o* *:op* *:open*&#xA;:[range]o[pen]                      Works like |:visual|: end Ex mode.&#xA;                                {Vi: start editing in open mode}&#xA;&#xA;:[range]o[pen] /pattern/    As above, additionally move the cursor to the&#xA;                                column where &quot;pattern&quot; matches in the cursor&#xA;                                line.&#xA;&#xA;Vim does not support open mode, since it's not really useful.  For those&#xA;situations where &quot;:open&quot; would start open mode Vim will leave Ex mode, which&#xA;allows executing the same commands, but updates the whole screen instead of&#xA;only one line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does not comment on the nature of the &quot;simulation&quot;, and why this is considered to be a simulation rather than a real command with different behavior. When run from ex mode (Q), it does indeed behave as described.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there also appears to be a different open command. When run from the normal command line, or from ex mode with different arguments, it &lt;em&gt;appears&lt;/em&gt; to be a synonym for &lt;code&gt;:edit&lt;/code&gt;. When run from command mode &lt;em&gt;with&lt;/em&gt; a &lt;code&gt;/pattern/&lt;/code&gt;, it positions the cursor &lt;em&gt;and&lt;/em&gt; apparently runs &lt;code&gt;:edit&lt;/code&gt; (with the cursor position only being evident if :edit fails.) It can also be run as &lt;code&gt;:open /pattern/ file&lt;/code&gt;, which positions the cursor and runs &lt;code&gt;:edit file&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: Why is this not documented? Are there any differences from &lt;code&gt;:edit&lt;/code&gt; that I am not noticing? Was &lt;code&gt;:open&lt;/code&gt; once a synonym for &lt;code&gt;:edit&lt;/code&gt; and only changed later in an attempt to halfway comply with POSIX?&lt;/p&gt;&#xA;" OwnerUserId="880" LastEditorUserId="23502" LastEditDate="2022-10-31T12:57:49.103" LastActivityDate="2022-10-31T12:57:49.103" Title="What does :open do in Vim?" Tags="|ex-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2276" PostTypeId="2" ParentId="2275" CreationDate="2015-02-27T22:07:27.333" Score="12" Body="&lt;p&gt;From &lt;a href=&quot;http://ex-vi.sourceforge.net/viin/paper-7.html#section53&quot; rel=&quot;noreferrer&quot;&gt;An Introduction to Display Editing with Vi&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you are on a hardcopy terminal or a terminal which does not have a cursor which can move off the bottom line, you can still use the command set of vi, but in a different mode. When you give a vi command, the editor will tell you that it is using open mode. This name comes from the open command in ex, which is used to get into the same mode.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The only difference between visual mode and open mode is the way in which the text is displayed.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;In open mode the editor uses a single line window into the file, and moving backward and forward in the file causes new lines to be displayed, always below the current line. Two commands of vi work differently in open: z and ^R. The z command does not take parameters, but rather draws a window of context around the current line and then returns you to the current line.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If you are on a hardcopy terminal, the ^R command will retype the current line. On such terminals, the editor normally uses two lines to represent the current line. The first line is a copy of the line as you started to edit it, and you work on the line below this line. When you delete characters, the editor types a number of \'s to show you the characters which are deleted. The editor also reprints the current line soon after such changes so that you can see what the line looks like again.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;It is sometimes useful to use this mode on very slow terminals which can support vi in the full screen mode. You can do this by entering ex and using an open command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:open&lt;/code&gt; is an artifact of Vim's origin as a Vi clone that is completely useless today. I can only assume that it remains there for POSIX compatibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Despite vague similarities, &lt;code&gt;:open&lt;/code&gt; is &lt;strong&gt;&lt;em&gt;not&lt;/em&gt;&lt;/strong&gt; an alternative to &lt;code&gt;:edit&lt;/code&gt; by any stretch of the imagination.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-02-27T22:07:27.333" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2277" PostTypeId="2" ParentId="2275" CreationDate="2015-02-27T22:09:11.320" Score="16" Body="&lt;p&gt;The &quot;open mode&quot; of vi was useful for terminals that had a single line, such as hardcopy terminals. In open mode, vi had a &quot;single line view&quot; of the file. Moving the cursor around would redraw the entire line, and deleted characters printed differently. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;simulation&quot; that vim does is simply supporting the command, making it act (as the documentation says) like &lt;code&gt;:visual&lt;/code&gt; and since &lt;code&gt;:visual&lt;/code&gt; is &quot;otherwise the same as &lt;code&gt;:edit&lt;/code&gt;,&quot; that's probably why you see it acting like &lt;code&gt;:edit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a source code perspective, &lt;code&gt;:open&lt;/code&gt; is implemented in &lt;code&gt;ex_docmd.c&lt;/code&gt; (&lt;code&gt;ex_open()&lt;/code&gt;). It does some stuff to deal with the case where it is provided a regular expression, but always ends with a call to &lt;code&gt;do_exedit()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The implementation of &lt;code&gt;:edit&lt;/code&gt;, &lt;code&gt;:badd&lt;/code&gt; and &lt;code&gt;:visual&lt;/code&gt; is contained in the &lt;code&gt;ex_edit()&lt;/code&gt; function in the same file, and that function is a &lt;em&gt;direct call&lt;/em&gt; to &lt;code&gt;do_exedit()&lt;/code&gt; (nothing else). Thus, other than when handling the regular expression parameter, the same code gets called. &lt;code&gt;do_exedit()&lt;/code&gt; is a bit hairy, and it's behavior is modified heavily based on the actual command that was issued, but it never explicitly checks for the command tokens for open/edit/visual. Thus, the three commands result in more-or-less the same code getting run in &lt;code&gt;do_exedit()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorDisplayName="user72" LastEditDate="2015-02-27T22:36:16.250" LastActivityDate="2015-02-27T22:36:16.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2278" PostTypeId="1" AcceptedAnswerId="2289" CreationDate="2015-02-28T00:19:53.677" Score="23" ViewCount="3366" Body="&lt;p&gt;Lets say I want to produce the following text in my document:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%&#xA;%            Not Important&#xA;%    O -------------------------&amp;gt;&#xA;%    |&#xA;%  S |&#xA;%  o |&#xA;%  m |&#xA;%  e |&#xA;%    |&#xA;%  M |&#xA;%  s |&#xA;%  g |&#xA;%    |&#xA;%    V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any easy way of writing the &quot;Some Msg&quot; vertically as above without having to manually insert each character in each line?&lt;/p&gt;&#xA;" OwnerUserId="669" LastEditorUserId="51" LastEditDate="2015-03-11T09:49:21.200" LastActivityDate="2015-03-11T09:49:21.200" Title="How to write vertically?" Tags="|insert-mode|formatting|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2279" PostTypeId="2" ParentId="2268" CreationDate="2015-02-28T01:21:00.583" Score="29" Body="&lt;p&gt;In summary, no. Vim's regex is a unique flavour, and there are no options to make it behave more like another flavour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this is a good thing.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Magic&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;'magic'&lt;/code&gt; option doesn't change the flavour of regex that Vim uses. It simply inverts the behaviour of many &lt;code&gt;\&lt;/code&gt;-escaped atoms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, by default, &lt;code&gt;+&lt;/code&gt; is a literal &lt;code&gt;+&lt;/code&gt; character, where &lt;code&gt;\+&lt;/code&gt; means &quot;one or more of the preceding atom&quot;. In contrast, &lt;code&gt;*&lt;/code&gt; means &quot;zero or more of the preceding atom&quot;, while &lt;code&gt;\*&lt;/code&gt; is a literal &lt;code&gt;*&lt;/code&gt;. Many people find this quite confusing. Using &lt;code&gt;\v&lt;/code&gt; in your pattern makes it a bit more consistent. &lt;code&gt;:help 'magic'&lt;/code&gt; gives a good summary:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;after:    \v       \m       \M       \V         matches ~&#xA;                'magic' 'nomagic'&#xA;          $        $        $        \$         matches end-of-line&#xA;          .        .        \.       \.         matches any character&#xA;          *        *        \*       \*         any number of the previous atom&#xA;          ()       \(\)     \(\)     \(\)       grouping into an atom&#xA;          |        \|       \|       \|         separating alternatives&#xA;          \a       \a       \a       \a         alphabetic character&#xA;          \\       \\       \\       \\         literal backslash&#xA;          \.       \.       .        .          literal dot&#xA;          \{       {        {        {          literal '{'&#xA;          a        a        a        a          literal 'a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Personally, I think the default behaviour is nice for code files, where it's not uncommon to search for things like &lt;code&gt;foo(&lt;/code&gt;, using the literal &lt;code&gt;(&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Vim's own regex flavour&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I've witnessed many people wishing Vim supported PCRE. Personally, I wish other tools supported Vim's flavour of regex. It has some capabilities that are either impossible or too cumbersome to achieve in PCRE.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Impossible in PCRE&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.regular-expressions.info/lookaround.html&quot;&gt;Lookaround&lt;/a&gt; is a common feature where you can assert that a pattern either does or does not match before or after the pattern you're trying to match. For example, the PCRE pattern &lt;code&gt;q(?!u)&lt;/code&gt; (or Vim regex pattern &lt;code&gt;qu\@!&lt;/code&gt;) matches a &lt;code&gt;q&lt;/code&gt; that's not followed by a &lt;code&gt;u&lt;/code&gt;. (This is more correct than &lt;code&gt;q[^u]&lt;/code&gt;, which requires that there is &lt;em&gt;some&lt;/em&gt; character after the &lt;code&gt;q&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Variable-length negative lookbehind&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;PCRE, and many other flavours, have a restriction that a negative lookbehind pattern must be of a fixed length. That means that a pattern like &lt;code&gt;(?&amp;lt;![a-z]{3})foo&lt;/code&gt;, meaning &quot;the string &lt;code&gt;foo&lt;/code&gt; &lt;em&gt;not preceded by&lt;/em&gt; exactly 3 lowercase letters&quot;) is fine, but &lt;code&gt;(?&amp;lt;![a-z]+)foo&lt;/code&gt; (meaning &quot;the string &lt;code&gt;foo&lt;/code&gt; not preceded by &lt;em&gt;any number&lt;/em&gt; of lowercase letters&quot;) is not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This restriction doesn't exist in Vim. In Vim, a pattern like &lt;code&gt;\([a-z]\+\)\@&amp;lt;!foo&lt;/code&gt;, while maybe a bit ugly to look at, is perfectly valid.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Easier in Vim regex&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Some things are a lot nicer in Vim's flavour of regex.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Start and end of match anchors&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The most notable, in my opinion, are the &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; anchors. These allow you to specify the start and end of the match. For example, &lt;code&gt;foo(\zs.*\ze)&lt;/code&gt; matches only what's between the &lt;code&gt;(&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt; in a function call like &lt;code&gt;foo(...)&lt;/code&gt;. This can be done in PCRE, but it requires the use of lookaround, which is slightly tedious: &lt;code&gt;(?&amp;lt;=foo\().*(?=\))&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Prefix matching&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Another cool thing that Vim can do is match any prefix (including the empty prefix) of a particular sequence of characters. For example, to match on &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;fo&lt;/code&gt;, &lt;code&gt;foo&lt;/code&gt;, or &lt;code&gt;food&lt;/code&gt;, the pattern &lt;code&gt;f\%[ood]&lt;/code&gt; can be used. In PCRE, such a pattern would look like &lt;code&gt;f(o(od?)?)?&lt;/code&gt;. (Imagine that for a longer string!)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Matching cursor, line, and column positions&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim's regex has some anchors for matching positions in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\%23c&lt;/code&gt; matches column 23&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%&amp;lt;23c&lt;/code&gt; matches &lt;em&gt;before&lt;/em&gt; column 23&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%&amp;gt;23c&lt;/code&gt; matches &lt;em&gt;after&lt;/em&gt; column 23&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%16l&lt;/code&gt; matches line 16&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Similar to column, there are anchors for &lt;em&gt;before&lt;/em&gt; or &lt;em&gt;after&lt;/em&gt; a line number&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%#&lt;/code&gt; matches the cursor position&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is useful for things like &lt;a href=&quot;http://vim.wikia.com/wiki/Highlight_unwanted_spaces&quot;&gt;highlighting trailing whitespace except when you're typing at the end of the line&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I think it's worth-while to embrace Vim's flavour of regex. It's well-suited for use in a text editor used primarily for programming, and it's quite powerful.&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="51" LastEditDate="2015-02-28T01:33:13.200" LastActivityDate="2015-02-28T01:33:13.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2280" PostTypeId="1" CreationDate="2015-02-28T02:00:07.170" Score="64" ViewCount="57159" Body="&lt;p&gt;&lt;strong&gt;Is there a way to hide all lines that did not match, while going through the list of result lines?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In a long file, I would like to search for a pattern that will match roughly 200 lines or so. The matched lines are in random places in the file.&lt;br /&gt;&#xA;When a line matches, only the line itself is relevant, no context above or below.&lt;/p&gt;&#xA;&lt;p&gt;Normally, I would search with &lt;code&gt;/&lt;/code&gt; and jump through the matches with &lt;code&gt;n&lt;/code&gt;.&lt;br /&gt;&#xA;But that means there are only one or two relevant lines on the screen at a time.&lt;/p&gt;&#xA;&lt;p&gt;A brute force approach would be to delete all non-matching lines, and undo that deletion later. But that's ugly in various ways, even if it would not end up in persistent undo.&lt;/p&gt;&#xA;" OwnerUserId="925" LastEditorUserId="14340" LastEditDate="2020-10-10T14:05:26.797" LastActivityDate="2020-10-10T14:05:26.797" Title="How to show only matching lines?" Tags="|search|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2281" PostTypeId="2" ParentId="2280" CreationDate="2015-02-28T02:49:52.493" Score="10" Body="&lt;p&gt;If order doesn't matter then just move the lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/pat/m0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :g&#xA;:h :m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-02-28T02:49:52.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2282" PostTypeId="2" ParentId="2280" CreationDate="2015-02-28T03:07:59.723" Score="18" Body="&lt;p&gt;You can use the &lt;code&gt;foldmethod&lt;/code&gt; and &lt;code&gt;foldexpr&lt;/code&gt; options to fold away irrelevant lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After searching, the last search is stored in the &lt;code&gt;@/&lt;/code&gt; register. So, you can readily fold away everything that doesn't match like this (for one-line matches only):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setlocal foldexpr=getline(v:lnum)=~@/?0:1 foldmethod=expr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More advanced methods, like adding multiple levels of folding for context lines you can show or hide, or matching multiple lines, can be found on the &lt;a href=&quot;http://vim.wikia.com/wiki/Folding_with_Regular_Expression&quot;&gt;Vim Tips Wiki&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1094" LastActivityDate="2015-02-28T03:07:59.723" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2283" PostTypeId="1" CreationDate="2015-02-28T03:19:55.550" Score="5" ViewCount="743" Body="&lt;p&gt;A search pattern used with &lt;code&gt;/&lt;/code&gt;, entered on the vim command line,&#xA;can be very complex.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But even for a normal regular expression pattern, syntax highlight of the expression syntax would be helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pattern syntax in &lt;code&gt;vim&lt;/code&gt; provides a large number of special pattern atoms. Some of them use multiple characters.&lt;br&gt;&#xA;I do need to look them up to use them - that's easy.&lt;br&gt;&#xA;The harder part is to continue editing the pattern, because it can become hard to read quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think even a very simple kind of syntax highlight for the pattern input would be helpful, like three colors for text, standard pattern atoms and special pattern atoms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would help users new to writing nontrivial patterns a lot - and also, it would help experienced users, new to writing even more advanced patterns, just the same way.&lt;/p&gt;&#xA;" OwnerUserId="925" LastActivityDate="2015-03-04T19:34:30.243" Title="Entering search pattern with syntax highlighting?" Tags="|syntax-highlighting|command-line|regular-expression|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2284" PostTypeId="2" ParentId="2260" CreationDate="2015-02-28T09:53:53.300" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/2263/267&quot;&gt;Ingo Karkat's answer&lt;/a&gt; seems like it was exactly the right solution and has solved my situation. However here are a little bit more verbose instructions for anyone else just getting started with vim's language map functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, you need a language map file. As in the Caps Lock example, you'll want to put something like the following in &lt;code&gt;~/.vim/keymap/dvorak2turkishf.vim&lt;/code&gt; (download &lt;a href=&quot;https://github.com/alerque/que-vim/blob/master/.vim/keymap/dvorak2turkishf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;my full mapping from Githu&lt;/a&gt;b):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:keymap_name = &quot;dvorak2turkishf&quot;&#xA;loadkeymap&#xA;; f&#xA;, g&#xA;. ğ&#xA;p ı&#xA;y o&#xA;f d&#xA;g r&#xA;&quot; etc...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With that in place, it remains to setup bindings to activate it in some cases but not others. You'll want to add something to your &lt;code&gt;~/.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, bind the search keymap to the input one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set imsearch=-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then set which keymap will be used for alternate-language input mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set keymap=dvorak2turkishf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Turn off the alternate input mode so by default there will be no change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iminsert=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setup an auto-command to run whenever leaving insert mode to turn off the alternate language switch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertLeave * set iminsert=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add bindings for all the various ways you might end up in the alternate-language input mode so that using &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; (Usually &lt;code&gt;\&lt;/code&gt;) before them sets the language map swtich to on before switching:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;i :set iminsert=1&amp;lt;Cr&amp;gt;i&#xA;nnoremap &amp;lt;leader&amp;gt;I :set iminsert=1&amp;lt;Cr&amp;gt;I&#xA;nnoremap &amp;lt;leader&amp;gt;a :set iminsert=1&amp;lt;Cr&amp;gt;a&#xA;nnoremap &amp;lt;leader&amp;gt;A :set iminsert=1&amp;lt;Cr&amp;gt;A&#xA;nnoremap &amp;lt;leader&amp;gt;c :set iminsert=1&amp;lt;Cr&amp;gt;c&#xA;nnoremap &amp;lt;leader&amp;gt;C :set iminsert=1&amp;lt;Cr&amp;gt;C&#xA;nnoremap &amp;lt;leader&amp;gt;r :set iminsert=1&amp;lt;Cr&amp;gt;r&#xA;nnoremap &amp;lt;leader&amp;gt;R :set iminsert=1&amp;lt;Cr&amp;gt;R&#xA;nnoremap &amp;lt;leader&amp;gt;o :set iminsert=1&amp;lt;Cr&amp;gt;o&#xA;nnoremap &amp;lt;leader&amp;gt;O :set iminsert=1&amp;lt;Cr&amp;gt;O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set a different cursor color for when the map is enabled:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight Cursor guifg=NONE guibg=Green&#xA;:highlight lCursor guifg=NONE guibg=Cyan&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All together, here is &lt;a href=&quot;https://github.com/alerque/que-vim/commit/8a195b8c81b710b82d865b6749b698f24a52a9d7#diff-4e12c6a37ff2cbb2c93d1b33324a6051&quot; rel=&quot;nofollow noreferrer&quot;&gt;what changed in my config&lt;/a&gt;. As a final note, one you are in insert mode you can toggle the language map option on and off using &lt;code&gt;&amp;lt;ctrl&amp;gt;+^&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-02-28T10:05:36.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2285" PostTypeId="2" ParentId="454" CreationDate="2015-02-28T10:26:41.847" Score="105" Body="&lt;h2&gt;Use a keybinding to strip all trailing whitespace&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Since some pages that I edit actually need trailing whitespaces (e.g. markdown) and others don't, I set up a keybinding to &lt;kbd&gt;F5&lt;/kbd&gt; so that it's trivial to do without being automatic. To do so, add the &lt;a href=&quot;http://vim.wikia.com/wiki/Remove_unwanted_spaces#Simple_commands_to_remove_unwanted_whitespace&quot; rel=&quot;noreferrer&quot;&gt;code below (from vim.wikia)&lt;/a&gt; or some variation of it to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Remove all trailing whitespace by pressing F5&#xA;nnoremap &amp;lt;F5&amp;gt; :let _s=@/&amp;lt;Bar&amp;gt;:%s/\s\+$//e&amp;lt;Bar&amp;gt;:let @/=_s&amp;lt;Bar&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt;&lt;/code&gt; does a nonrecursive mapping to the key &lt;code&gt;F5&lt;/code&gt; in normal mode  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:let _s=@/&lt;/code&gt; stores the last search term (from the macro &lt;code&gt;@/&lt;/code&gt;) in the variable &lt;code&gt;_s&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Bar&amp;gt;&lt;/code&gt; Functions as a pipe symbol &lt;code&gt;|&lt;/code&gt; to separate commands, however &lt;code&gt;|&lt;/code&gt; would end a command in this context, so &lt;code&gt;&amp;lt;Bar&amp;gt;&lt;/code&gt; must be used instead.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s/\s\+$//e&lt;/code&gt; searches for trailing whitespace and deletes it everywhere in the buffer (see &lt;a href=&quot;https://vi.stackexchange.com/a/456/1111&quot;&gt;CarpetSmoker's answer&lt;/a&gt; for a detailed breakdown of this expression)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;let @/=_s&lt;/code&gt; restores your last search term to the macro &lt;code&gt;@/&lt;/code&gt;, so that it will be available the next time you hit &lt;code&gt;n&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; ends the mapping&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;... or be more selective&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you have cases in which you don't want to strip all of the trailing whitespace, you can use a pattern to be more selective. For example, the following code shows how I strip trailing whitespace only if it comes after a semicolon (here it's tied to &lt;kbd&gt;F8&lt;/kbd&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F8&amp;gt; :let _s=@/&amp;lt;Bar&amp;gt;:%s/;\s\+$/;/e&amp;lt;Bar&amp;gt;:let @/=_s&amp;lt;Bar&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is useful if, like me, you have some files with markdown-like &lt;a href=&quot;https://en.wikipedia.org/wiki/Here_document&quot; rel=&quot;noreferrer&quot;&gt;heredocs&lt;/a&gt; interspersed among semicolon-terminated programming statements. &lt;/p&gt;&#xA;" OwnerUserId="1111" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-04-06T13:18:20.907" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="2286" PostTypeId="1" AcceptedAnswerId="2288" CreationDate="2015-02-28T10:30:43.033" Score="28" ViewCount="10464" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/454/whats-the-simplest-way-to-strip-trailing-whitespace-from-all-lines-in-a-file/2285#2285&quot;&gt;In answering a question just now&lt;/a&gt;, I mentioned using a normal mode key mapping that can be found at &lt;a href=&quot;https://vim.fandom.com/wiki/Vim_Tips_Wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;the Vim Tips Wiki&lt;/a&gt;. In the middle of explaining the key mapping, I realized that I had no idea what &lt;code&gt;&amp;lt;Bar&amp;gt;&lt;/code&gt; meant. What does it mean?&lt;/p&gt;&#xA;&lt;p&gt;I tried replacing it with a pipe &lt;code&gt;|&lt;/code&gt;, with and without spaces before, around, and after it, but each one broke my &lt;code&gt;.vimrc&lt;/code&gt; file with the following error message:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/bottomsc/.vimrc:&#xA;line  173:&#xA;E488: Trailing characters: :nohl&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1111" LastEditorUserId="1238" LastEditDate="2020-08-10T21:08:23.720" LastActivityDate="2020-08-10T21:08:23.720" Title="What does `&lt;Bar&gt;` mean?" Tags="|key-bindings|error|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2287" PostTypeId="2" ParentId="2286" CreationDate="2015-02-28T10:34:09.453" Score="6" Body="&lt;p&gt;If you type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help &amp;lt;Bar&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you will read that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Bar&amp;gt;           vertical bar            |       124     &amp;lt;Bar&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="66" LastActivityDate="2015-02-28T10:34:09.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2288" PostTypeId="2" ParentId="2286" CreationDate="2015-02-28T10:34:49.957" Score="46" Body="&lt;p&gt;It's the code for &lt;a href=&quot;http://vimhelp.appspot.com/intro.txt.html#%3CBar%3E&quot;&gt;the pipe character&lt;/a&gt;: &lt;code&gt;|&lt;/code&gt;. The pipe is used the way the semicolon is used in C-style languages, as a statement separator. You cannot use it directly in a mapping, since it would be seen as marking the end of the mapping. Hence, the code has to be used instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are exceptions to this, such as autocmd definitions, where the bar delimits the actions of the autocmd, but not the definition itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3Abar&quot;&gt;&lt;code&gt;:help :bar&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'|' can be used to separate commands, so you can give multiple commands in one line. If you want to use '|' in an argument, precede it with '\'. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and from &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#map_bar&quot;&gt;&lt;code&gt;:help map_bar&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                            *map_bar*&#xA;Since the '|' character is used to separate a map command from the next&#xA;command, you will have to do something special to include  a '|' in {rhs}.&#xA;There are three methods:&#xA;   use       works when                    example      ~&#xA;   &amp;lt;Bar&amp;gt;     '&amp;lt;' is not in 'cpoptions'     :map _l :!ls &amp;lt;Bar&amp;gt; more^M&#xA;   \|        'b' is not in 'cpoptions'     :map _l :!ls \| more^M&#xA;   ^V|       always, in Vim and Vi         :map _l :!ls ^V| more^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-02-28T13:09:27.873" LastActivityDate="2015-02-28T13:09:27.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2289" PostTypeId="2" ParentId="2278" CreationDate="2015-02-28T15:20:25.950" Score="17" Body="&lt;p&gt;Really good solution would probably require some more work, but &quot;not bad&quot; is&#xA;not very hard to achieve.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Idea&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;All we need is to move one line down after each character, so let's do just&#xA;that via &lt;code&gt;InsertCharPre&lt;/code&gt; auto-command!&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Code&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Put it into &lt;code&gt;.vimrc&lt;/code&gt; or better yet to some file under &lt;code&gt;plugin/&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; enters insert mode to write vertically&#xA;function! VertStart()&#xA;    augroup Vert&#xA;        autocmd!&#xA;        &quot; handles each entered character and moves cursor down&#xA;        autocmd InsertCharPre * call feedkeys(&quot;\&amp;lt;left&amp;gt;\&amp;lt;down&amp;gt;&quot;, 'n')&#xA;        autocmd InsertLeave * call VertEnd()&#xA;    augroup END&#xA;&#xA;    inoremap &amp;lt;BS&amp;gt; &amp;lt;Up&amp;gt;&amp;lt;Del&amp;gt;&#xA;    startinsert&#xA;endfunction&#xA;&#xA;&quot; cleans up on leaving insert mode&#xA;function! VertEnd()&#xA;    iunmap &amp;lt;BS&amp;gt;&#xA;    augroup Vert&#xA;        autocmd!&#xA;    augroup END&#xA;endfunction&#xA;&#xA;&quot; command to start writing vertically&#xA;command! Vert call VertStart()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Usage&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Enter &lt;code&gt;:Vert&lt;/code&gt; command to start writing vertically.  Leaving insert mode&#xA;automatically disables this &quot;mode&quot;.  Of course, you can map it to a shortcut&#xA;if you need to use this command often.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Known Issues&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Vertical writing won't be disabled if you leave insert mode via&#xA;&lt;kbd&gt;Ctrl-C&lt;/kbd&gt; (this is a result of &lt;kbd&gt;Ctrl-C&lt;/kbd&gt; being implemented in a slightly strange way with regard to &lt;code&gt;InsertLeave&lt;/code&gt; event, which is not fired; thus using the key requires one to be careful).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="860" LastEditorUserId="970" LastEditDate="2015-03-02T09:27:17.113" LastActivityDate="2015-03-02T09:27:17.113" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="2290" PostTypeId="2" ParentId="2278" CreationDate="2015-02-28T15:21:02.180" Score="4" Body="&lt;p&gt;You can type as usual and then convert the current horizontal text into vertical by using substitution in Vim as follow (applies to the current line):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\(.\)/\1\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or much easier to remember method is to execute one of the following commands (for all lines):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!fold -w1&#xA;:%!grep -o .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To apply only for the current line or more lines, precede with &lt;kbd&gt;V&lt;/kbd&gt;, expand the area for more lines if needed, and execute above (but without &lt;code&gt;%&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;For PowerShell on Windows, check &lt;a href=&quot;https://stackoverflow.com/questions/20442878/a-specific-bash-command-in-powershell-fold-w1&quot;&gt;the substitution for fold&lt;/a&gt;.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To define simple key mapping (e.g. &lt;kbd&gt;F2&lt;/kbd&gt;), try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;F2&amp;gt; V:!fold -w1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then type something and press &lt;kbd&gt;F2&lt;/kbd&gt; to make the text vertical, simple as that.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Other alternative is to set automatic word wrapping, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set tw=1 &quot; textwidth&#xA;:set formatoptions+=t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will automatically wrap text as close to 1 character as white space allows. The disadvantage is that each letter needs to be followed by space (so it's almost the same as you would be pressing &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-02-28T17:19:12.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2291" PostTypeId="2" ParentId="2283" CreationDate="2015-02-28T19:08:37.057" Score="4" Body="&lt;p&gt;There's no highlighting in the &lt;em&gt;command-line&lt;/em&gt;; that's not implemented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is open the &lt;em&gt;command-line window&lt;/em&gt; via &lt;code&gt;q/&lt;/code&gt;, and &lt;code&gt;:set syntax=...&lt;/code&gt; there (also automatically via &lt;code&gt;:autocmd CmdwinEnter / setlocal syntax=...&lt;/code&gt;). Unfortunately, even the syntax for Vimscript doesn't provide any differentiation in &lt;code&gt;/.../&lt;/code&gt; patterns. So, you'd have to write such syntax (e.g. named &lt;code&gt;vimregexp&lt;/code&gt;) yourself. A worthwhile challenge, and such plugin would probably be well received by the Vim community (and could even be included in / be an extension of the &lt;code&gt;syntax/vim.vim&lt;/code&gt; plugin).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-02-28T19:08:37.057" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2292" PostTypeId="2" ParentId="2280" CreationDate="2015-02-28T19:11:14.123" Score="41" Body="&lt;p&gt;You can list all matching lines with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/{pattern}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The &lt;code&gt;:print&lt;/code&gt; command can be omitted; it is the default for &lt;code&gt;:g&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-02-28T19:11:14.123" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="2293" PostTypeId="2" ParentId="2280" CreationDate="2015-02-28T20:00:14.150" Score="3" Body="&lt;p&gt;If you want to list all matching lines (as in my other answer), and then &lt;em&gt;jump&lt;/em&gt; to one particular match, my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4922&quot; rel=&quot;nofollow&quot;&gt;FindOccurrence plugin&lt;/a&gt; provides a &lt;code&gt;[/&lt;/code&gt; mapping for that (and &lt;code&gt;[n&lt;/code&gt; for the last search pattern, instead of querying for one). &lt;code&gt;[/pattern&lt;/code&gt; lists like &lt;code&gt;:g/pattern&lt;/code&gt;, but then asks for the number of the match to jump to.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-02-28T20:00:14.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2295" PostTypeId="2" ParentId="2199" CreationDate="2015-02-28T21:10:36.110" Score="8" Body="&lt;p&gt;The standard way of inserting an en dash in Vim is to use a digraph, as &lt;a href=&quot;https://vi.stackexchange.com/a/2201/343&quot;&gt;tommcdo explained&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I find digraphs in general, and &lt;em&gt;particularly&lt;/em&gt; this one (&lt;kbd&gt;Ctrl+k&lt;/kbd&gt;, &lt;kbd&gt;-&lt;/kbd&gt;, &lt;kbd&gt;Shift+N&lt;/kbd&gt;) pretty awkward to type. For faster input of dashes, you could add the following pair of insert-mode mappings to a filetype file, such as &lt;code&gt;.vim/after/ftplugin/markdown.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For en/em dashes, respectively:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;buffer&amp;gt; --&amp;lt;space&amp;gt; –&amp;lt;space&amp;gt;&#xA;inoremap &amp;lt;buffer&amp;gt; -- —&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. The &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; means this mapping will only apply to Markdown files. This is necessary because there are some contexts (e.g. programming) where I&lt;/em&gt; don't &lt;em&gt;want two hyphens to be replaced with dashes.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These mappings take advantage of the fact that in the contexts I usually use them, en dashes are surrounded by spaces, and em dashes are &lt;em&gt;not&lt;/em&gt;.&lt;sup&gt;*&lt;/sup&gt; Using these mappings therefore means that I can use exactly the same keypresses in the less capable text editors I'm sometimes forced to use and still get a sensible output.&lt;sup&gt;**&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I actually use a slightly more complicated solution than the above, because, for typographical reasons, I like to surround my em-dashes with &lt;a href=&quot;http://en.wikipedia.org/w/index.php?title=Whitespace_character&amp;amp;oldid=638829317#Hair_spaces_around_dashes&quot; rel=&quot;nofollow noreferrer&quot;&gt;hair spaces&lt;/a&gt;. Having these in the Markdown makes it less readable, but luckily, Vim has a solution for this, with its &quot;conceal&quot; function, which allows you to hide certain syntax items when the cursor is on a different line:&lt;sup&gt;***&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;buffer&amp;gt; --&amp;lt;space&amp;gt; –&amp;lt;space&amp;gt;&#xA;inoremap &amp;lt;buffer&amp;gt; -- &amp;amp;#8202;—&amp;amp;#8202;&#xA;&#xA;syntax match entity_hairspace &quot;&amp;amp;#8202;&quot; conceal&#xA;setl conceallevel=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* If I ever need to use an en dash unspaced, then I can simply press the backspace after typing the mapping.&lt;/sub&gt;&lt;br&gt;&#xA;&lt;sub&gt;** If you don't generally use en-dashes like this, or if you don't ever venture out of Vim, you could use something else to trigger the mappings: e.g. &lt;code&gt;--.&lt;/code&gt; and &lt;code&gt;---&lt;/code&gt;. If you use other triggers, you could also place this directly in your .vimrc, and remove the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; options.&lt;/sub&gt;&lt;br&gt;&#xA;&lt;sub&gt;*** You can also use a conceal character &lt;code&gt;cchar&lt;/code&gt; to replace syntax items with a single character, instead of hiding them entirely. If you're worried about encoding issues, you can use this to get Vim to display &lt;code&gt;&amp;amp;ndash;&lt;/code&gt; HTML entities in the file as en dashes.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2016-02-19T10:53:20.000" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="2296" PostTypeId="1" CreationDate="2015-02-28T21:23:08.740" Score="1" ViewCount="53" Body="&lt;p&gt;Let's say we handle a file that needs various speciffic settings:&#xA;We have a file type, syntax, colorscheme, highlights, tab widths and more.&#xA;Also, we have multiple plugins with &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, we want to derive another file from that, like extracting matching lines. &#xA;The extracted lined share many properties with the original file, but not all: The syntax has possibly changed: Maybe there were no consecutive lines of the matched lines possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say we handle a file that needs various speciffic settings:&#xA;We have a file type, syntax, colorscheme, highlights, tab widths and more.&#xA;Also, we have multiple plugins with file speciffic settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we derive a new file, say we extract matching lines. How can we transfer the settings from the old file to the new? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There may be two different cases to handle: in one case, the new file is created from the old one by a series of changes on a copy of the file content - the copy could possibly include the settings, so they can be just kept the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other case is that the new file is created independently, like output of a shell command. Here, the settings really need to be copied over.&lt;/p&gt;&#xA;" OwnerUserId="925" LastEditorUserId="24" LastEditDate="2015-03-01T04:58:50.450" LastActivityDate="2015-03-01T13:24:50.923" Title="Transfer file-related settings over to a new, derived file?" Tags="|multiple-files|options|" AnswerCount="1" CommentCount="2" ClosedDate="2015-03-07T03:24:17.663" ContentLicense="CC BY-SA 3.0" />
  <row Id="2297" PostTypeId="1" AcceptedAnswerId="2298" CreationDate="2015-03-01T03:01:19.493" Score="4" ViewCount="4179" Body="&lt;p&gt;I am having a rough time getting the colors right with my vim setup and the color scheme I want to use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OSX 10.10.2&lt;/li&gt;&#xA;&lt;li&gt;Vim 7.4&lt;/li&gt;&#xA;&lt;li&gt;iTerm2 (Set to report terminal type as &quot;xterm-256color&quot;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/morhetz/gruvbox&quot; rel=&quot;nofollow&quot;&gt;gruvbox theme&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Using the &lt;a href=&quot;https://github.com/morhetz/gruvbox/wiki/Terminal-specific#a-recommended-256-color-gruvbox-palette-shellscript&quot; rel=&quot;nofollow&quot;&gt;gruvbox provided osx script&lt;/a&gt; to adjust color &lt;/li&gt;&#xA;&lt;li&gt;Have tried adjusting the &lt;code&gt;set t_Co=256&lt;/code&gt; setting in my vimrc&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Not matter what I have tried, the comment highlighting in my editor &lt;a href=&quot;https://camo.githubusercontent.com/26c7f6f2495059d00675afe881d2e4709f0801ad/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f323331343037342f313236323431302f37326165323337362d326333652d313165332d383330622d3063363235376434656462362e706e67&quot; rel=&quot;nofollow&quot;&gt;looks like the screenshot of  they show as an example what it should NOT look like.&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However - I did try download MacVim, and that worked just fine, but I am NOT interested in using MacVim, so please don't suggest that.&lt;/p&gt;&#xA;" OwnerUserId="1133" LastEditorUserId="24" LastEditDate="2015-03-01T05:00:13.903" LastActivityDate="2015-03-01T15:31:26.880" Title="I can't get 256 colours to work with Vim in iTerm2 on MacOS X" Tags="|terminal|colorscheme|macos|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2298" PostTypeId="2" ParentId="2297" CreationDate="2015-03-01T03:16:58.597" Score="4" Body="&lt;p&gt;It looks like gruvbox sets italic on by default for the Comment syntax group if you're running terminal vim, which is a big problem if the terminal does not support italics. iTerm does but you have to get a specific termcap to enable it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it looks gruvbox recently fixed this &lt;a href=&quot;https://github.com/morhetz/gruvbox/pull/47&quot; rel=&quot;nofollow&quot;&gt;issue&lt;/a&gt;. So, simply update your gruvbox colorscheme and the issue should be fixed.&lt;/p&gt;&#xA;" OwnerUserId="246" LastActivityDate="2015-03-01T03:16:58.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2299" PostTypeId="1" AcceptedAnswerId="2303" CreationDate="2015-03-01T06:27:06.957" Score="10" ViewCount="3559" Body="&lt;p&gt;I have a file with a lot of characters represented like this: &lt;code&gt;\u05E2&lt;/code&gt;. (These are the actual characters in the file: backslash, lowercase u, and four hexadecimal digits.) Due to that, the file is impossible to read. Is there a way to translate the code to the actual symbol? (in the example above, ע).&lt;/p&gt;&#xA;" OwnerUserId="342" LastEditorUserId="24" LastEditDate="2015-03-02T17:07:57.370" LastActivityDate="2022-12-29T08:59:52.773" Title="How to translate Unicode escape sequences to the Unicode character?" Tags="|substitute|unicode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2300" PostTypeId="2" ParentId="2082" CreationDate="2015-03-01T10:14:55.560" Score="2" Body="&lt;p&gt;For general info, and thanks to all the comments, this is the script I use to have an &quot;open in a tab on the gvim on this desktop&quot; script: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash -x&#xA;#&#xA;# this is convoluted because it has to finish in an exec to keep the DM happy&#xA;# remember to set StartupNotify=false in the .desktop file&#xA;#&#xA;desktop=desktop_$(xprop -root -notype  _NET_CURRENT_DESKTOP | perl -pe 's/.*?= (\d+)/$1/')&#xA;&#xA;if ! vim --serverlist | grep -iq $desktop; then #we need to start the server&#xA;    if [ $# != 0 ]; then &#xA;        exec gvim 2&amp;gt;/dev/null --servername $desktop &quot;$@&quot;&#xA;    else&#xA;        exec gvim 2&amp;gt;/dev/null --servername $desktop  #no files &#xA;    fi&#xA;fi&#xA;# the only case here is if we need to open a tab in an existing server&#xA;if [ $# != 0 ]; then  &#xA;        # Do not use --remote-tab, see http://vi.stackexchange.com/questions/2066/different-autocmd-behavior-when-using-remote-tab-silent&#xA;        # &amp;lt;ESC&amp;gt; because the gvim instance can be in a mode different from normal&#xA;        # the double CR: do not ask. &#xA;        # the argument MUST be a full path&#xA;        file=&quot;$(readlink -f &quot;$@&quot;)&quot;&#xA;        #fileq=&quot;$(echo &quot;$file&quot; |  awk '{gsub(/ /,&quot;\\\ &quot;)}1')&quot; # quote spaces FIXME add other chars&#xA;        fileq=${file// /\\ } # quote spaces FIXME add other chars&#xA;        exec gvim 2&amp;gt;/dev/null --servername $desktop --remote-send &quot;&amp;lt;ESC&amp;gt;:tabe $fileq &amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&quot;&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="854" LastActivityDate="2015-03-01T10:14:55.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2301" PostTypeId="1" CreationDate="2015-03-01T13:00:34.440" Score="5" ViewCount="531" Body="&lt;p&gt;I would like to know how a &quot;d3fg&quot; command works in vi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have done some research on Google and found that &lt;code&gt;d&lt;/code&gt; is delete and &lt;code&gt;fg&lt;/code&gt; means foreground. Suppose, if we want to stop the session of vi and resume it afterwards, we can press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;z&lt;/kbd&gt; to come out of the vi session. Then type &lt;code&gt;fg&lt;/code&gt; to go back to the same vi session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I wanted to know how this &lt;code&gt;d3fg&lt;/code&gt; works in vi editor.&lt;/p&gt;&#xA;" OwnerUserId="1138" LastEditorUserId="246" LastEditDate="2015-03-02T06:23:33.733" LastActivityDate="2015-03-02T06:23:33.733" Title="How does the &quot;d3fg&quot; command work?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2302" PostTypeId="2" ParentId="2296" CreationDate="2015-03-01T13:24:50.923" Score="1" Body="&lt;p&gt;I do not completly understand what kind of problem you want to solve. But usually, if I want to keep all settings and variables attached to a single buffer, I use the &lt;code&gt;:f &amp;lt;newfile&amp;gt;&lt;/code&gt; command to copy everything under a new file. Then you can remove all lines you do not need. Variables and settings however should remain as for the original buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this what you are trying to achieve?&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-03-01T13:24:50.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2303" PostTypeId="2" ParentId="2299" CreationDate="2015-03-01T13:43:45.820" Score="14" Body="&lt;p&gt;If I understand you correctly, you have a file where certain characters are represented by their decimal value in the format &lt;code&gt;\uXXXX&lt;/code&gt;, with &lt;strong&gt;X&lt;/strong&gt; being any hexadecimal character but always 4, correct?&lt;/p&gt;&#xA;&lt;p&gt;If so, you can transform those sequences into the actual values they represent by doing a clever search and replace. In this particular case, I would do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\\u\(\x\{4\}\)/\=nr2char('0x'.submatch(1),1)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This translates to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%s/      - start a search/replace command in the complete buffer&#xA;\\u       - Search for the characters \u&#xA;\(...\)   - remember the next chars&#xA;\x\{4\}   - 4 hexadecimal characters - they will be remembered and be available as submatch(1)&#xA;/         - replace each match by&#xA;\=        - evaluate the following as an expression&#xA;nr2char(  - return the character for the number given&#xA;'0x'      - put a '0x' in front of the number to force hexadecimal value&#xA;.         - append&#xA;submatch(1) - the hexadecimal number remembered above&#xA;)         - closing paren of nr2char()&#xA;/g        - replace for every occurrence in each line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;While this will replace each occurrence of the pattern \u\x\x\x\x that does not necessarily mean,&#xA;there will be a glyph available for that character. In such cases it could be shown as a blank square or a '?'.&lt;/p&gt;&#xA;&lt;p&gt;Note, if you also have less than 4 or more than 4 hexadecimal characters after&#xA;the \u (or you had an upper 'U' instead of the lower 'u') you would need to&#xA;adjust the search pattern. This is left as an exercise to the reader.&lt;/p&gt;&#xA;&lt;p&gt;See the help at &lt;code&gt;:h sub-replace-special&lt;/code&gt; and &lt;code&gt;:h nr2char()&lt;/code&gt; (among others)&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2022-12-29T08:59:52.773" LastActivityDate="2022-12-29T08:59:52.773" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2304" PostTypeId="2" ParentId="2301" CreationDate="2015-03-01T14:50:13.147" Score="17" Body="&lt;p&gt;In fact, &lt;code&gt;fg&lt;/code&gt; is &quot;foreground&quot; in Bash, but not in Vi(m). &lt;code&gt;d3fg&lt;/code&gt; means:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d - Delete until...&#xA;3 - Do the next motion 3 times&#xA;f - Go to the next occurrence of the next character pressed.&#xA;g - The character to go to.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus, &lt;code&gt;d3fg&lt;/code&gt; will delete up to (including) the third letter &lt;code&gt;g&lt;/code&gt; on the line after the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus the following text, with the cursor on the &lt;code&gt;0&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;01g2g3g4g5g6&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Becomes after &lt;code&gt;d3fg&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;4g5g6&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="989" LastEditorUserId="54" LastEditDate="2015-03-01T15:27:54.537" LastActivityDate="2015-03-01T15:27:54.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2305" PostTypeId="2" ParentId="2297" CreationDate="2015-03-01T15:25:55.893" Score="2" Body="&lt;p&gt;I would suggest you to read &lt;a href=&quot;https://alexpearce.me/2014/05/italics-in-iterm2-vim-tmux/&quot; rel=&quot;nofollow&quot;&gt;this blog post&lt;/a&gt;, it explains how to add italic fonts to iterm2, tmux and vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changing iterm2 .terminfo, worked like a charm for me.&lt;/p&gt;&#xA;" OwnerUserId="812" LastEditorUserId="812" LastEditDate="2015-03-01T15:31:26.880" LastActivityDate="2015-03-01T15:31:26.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2306" PostTypeId="1" CreationDate="2015-03-01T17:22:51.130" Score="10" ViewCount="5282" Body="&lt;p&gt;I was wondering which is the best way to use syntax folding for HTML files. Specially if it can recognize javascript code within &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I typed &lt;code&gt;set foldmethod=syntax&lt;/code&gt; but it does not seem to do any folding. Do I have to add something else to my .vimrc? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know for javascript, for instance, I need to add &lt;code&gt;let javaScript_fold=1&lt;/code&gt; but I am unsure whether I have to add something similar for HTML. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="977" LastEditorUserId="23502" LastEditDate="2022-10-31T17:26:43.900" LastActivityDate="2022-10-31T17:26:43.900" Title="HTML syntax folding in Vim?" Tags="|folding|filetype-html|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2307" PostTypeId="1" AcceptedAnswerId="2308" CreationDate="2015-03-02T02:10:14.497" Score="3" ViewCount="1707" Body="&lt;p&gt;My web service log file has a line that's 34151 characters wide (lots of Soap XML). When wrapped it fills more than 1 screen. How can I scroll it smoothly in vim? Using navigation keys like $ and w isn't quite working, is there another key that jumps say 1000 characters at a time?&lt;/p&gt;&#xA;" OwnerUserId="398" LastActivityDate="2015-03-02T04:55:55.003" Title="How to scroll through a really long line?" Tags="|cursor-movement|" AnswerCount="1" CommentCount="3" ClosedDate="2015-03-02T11:27:19.817" ContentLicense="CC BY-SA 3.0" />
  <row Id="2308" PostTypeId="2" ParentId="2307" CreationDate="2015-03-02T04:48:40.933" Score="7" Body="&lt;p&gt;Vim as a line based editor. It's movement commands and it's ranges are all based on lines. This partly due to it's origins from Vi designed to edit most text documents that span multiple lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case there are a few options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Optimize for the editor. Since Vim is line based use a lint program to pretty print the XML (SOAP) document into multiple lines instead of one long line. This has the advantage of organizing the chaos and increase in performance and ultimately productivity.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create some mappings to help with the limited column based movements. This solution has the disadvantage that all the commands are rendered pretty useless (any command starting with &lt;code&gt;:&lt;/code&gt; is effectively the same as &lt;code&gt;:%&lt;/code&gt; with one line). But it does have the advantage of not having to reformat the document.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The first solution is easy using Vim's filter command &lt;code&gt;:%!xmllint&lt;/code&gt; (with the xmllint program installed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second option you could use the &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;/&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; commands (&lt;code&gt;10&lt;/code&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;/&lt;code&gt;10&lt;/code&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; also). Then there are the word and sentence movements like: &lt;kbd&gt;w&lt;/kbd&gt;/&lt;kbd&gt;W&lt;/kbd&gt;, &lt;kbd&gt;b&lt;/kbd&gt;/&lt;kbd&gt;B&lt;/kbd&gt;, &lt;kbd&gt;e&lt;/kbd&gt;/&lt;kbd&gt;E&lt;/kbd&gt;, and &lt;kbd&gt;(&lt;/kbd&gt;/&lt;kbd&gt;)&lt;/kbd&gt;. And finally if you happen to know the column number you can use it with the &lt;kbd&gt;|&lt;/kbd&gt; movement as in &lt;code&gt;1024&lt;/code&gt;&lt;kbd&gt;|&lt;/kbd&gt; to jump to the 1024&lt;sup&gt;th&lt;/sup&gt; character of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly I can't forget about the find movements. As you know you can type a &lt;kbd&gt;/&lt;/kbd&gt; to search for a pattern or use &lt;kbd&gt;f&lt;/kbd&gt;/&lt;kbd&gt;F&lt;/kbd&gt; and &lt;kbd&gt;t&lt;/kbd&gt;/&lt;kbd&gt;T&lt;/kbd&gt; keys to search by characters. For example you can type &lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;&amp;gt;&lt;/kbd&gt; to jump to the next &lt;code&gt;&amp;gt;&lt;/code&gt; character then press &lt;kbd&gt;;&lt;/kbd&gt; and &lt;kbd&gt;,&lt;/kbd&gt; keys to move to the next or previous &lt;code&gt;&amp;gt;&lt;/code&gt; character.&lt;/p&gt;&#xA;" OwnerUserId="544" LastEditorUserId="544" LastEditDate="2015-03-02T04:55:55.003" LastActivityDate="2015-03-02T04:55:55.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2309" PostTypeId="2" ParentId="2274" CreationDate="2015-03-02T13:03:31.930" Score="2" Body="&lt;p&gt;Elvis is the default vi that ships with Slackware, Frugalware, KateOS, and MINIX 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Elvis_(text_editor)&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Elvis_(text_editor)&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="411" LastActivityDate="2015-03-02T13:03:31.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2310" PostTypeId="1" AcceptedAnswerId="2312" CreationDate="2015-03-02T13:46:57.873" Score="13" ViewCount="3028" Body="&lt;p&gt;Is there a way to interact with the command-line mode while always remaining in the home position?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, the following two actions are cumbersome, requiring moving the fingers away to the arrow keys and sometimes worse, the mouse.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Moving around: Is there a way to move back and forth in the command-line mode while remaining in the usual position?&lt;/li&gt;&#xA;&lt;li&gt;How can you copy and paste on the command-line? I mean copying both from part of the command-line itself to another part, or from the text or even clipboard.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="850" LastEditorUserId="850" LastEditDate="2015-10-30T14:36:04.607" LastActivityDate="2018-04-30T12:51:23.127" Title="How to work with command-line mode the vi way?" Tags="|command-line|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2311" PostTypeId="2" ParentId="2278" CreationDate="2015-03-02T14:08:36.050" Score="2" Body="&lt;p&gt;I find that macros are an awesome way to do unusual stuff if you are interested in doing that no more than once in a blue moon. Let's say you have the following table:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%&#xA;%            Not Important&#xA;%    O -------------------------&amp;gt;&#xA;%    | Stuff in side the table&#xA;%  S |&#xA;%  o | So you can't just write your&#xA;%  m |&#xA;%  e | text and transform it into&#xA;%    |&#xA;%  M | the shape that you want&#xA;%  s |&#xA;%  g | Macros help here&#xA;%    |&#xA;%    V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And let's say you want to replace &lt;code&gt;Some Msg&lt;/code&gt; with &lt;code&gt;Other Message&lt;/code&gt;. First off, let's extend the table for the extra character (line before last &lt;code&gt;yy5p&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%&#xA;%            Not Important&#xA;%    O -------------------------&amp;gt;&#xA;%    | Stuff in side the table&#xA;%  S |&#xA;%  o | So you can't just write your&#xA;%  m |&#xA;%  e | text and transform it into&#xA;%    |&#xA;%  M | the shape that you want&#xA;%  s |&#xA;%  g | Macros help here&#xA;%    |&#xA;%    |&#xA;%    |&#xA;%    |&#xA;%    |&#xA;%    |&#xA;%    V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The macro I'm going to come up with is going to take care of converting the text from horizontal to vertical while replacing the old text. Start by typing the text in the first location (cursor is at the end of &lt;code&gt;Other Message&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%&#xA;%            Not Important&#xA;%    O -------------------------&amp;gt;&#xA;%    | Stuff in side the table&#xA;%  SOther Message |&#xA;%  o | So you can't just write your&#xA;%  m |&#xA;%  e | text and transform it into&#xA;%    |&#xA;%  M | the shape that you want&#xA;%  s |&#xA;%  g | Macros help here&#xA;%    |&#xA;%    |&#xA;%    |&#xA;%    |&#xA;%    |&#xA;%    |&#xA;%    V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Record the following macro:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt;: start recording macro named &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt;: go to beginning of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;3l&lt;/code&gt;: move to the column where the text is going to be placed&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;x&lt;/code&gt;: delete the old character&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;l&lt;/code&gt;: move right, leaving one character from the message in place of the old character:&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v&lt;/code&gt;: go to visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f|&lt;/code&gt;: jump to &lt;code&gt;|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2h&lt;/code&gt;: move back two characters&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d&lt;/code&gt;: cut selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt;: move down&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt;: paste before cursor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: terminate recording the macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;At this point you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%&#xA;%            Not Important&#xA;%    O -------------------------&amp;gt;&#xA;%    | Stuff in side the table&#xA;%  O |&#xA;%  other Message | So you can't just write your&#xA;%  m |&#xA;%  e | text and transform it into&#xA;%    |&#xA;%  M | the shape that you want&#xA;%  s |&#xA;%  g | Macros help here&#xA;%    |&#xA;%    |&#xA;%    |&#xA;%    |&#xA;%    |&#xA;%    |&#xA;%    V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Repeat the macro enough number of times (i.e, the number of characters, but you don't need to know it in advance. Just underestimate, and continue once you see how close your estimate was). So let's go with &lt;code&gt;10@q&lt;/code&gt;. You get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%&#xA;%            Not Important&#xA;%    O -------------------------&amp;gt;&#xA;%    | Stuff in side the table&#xA;%  O |&#xA;%  t | So you can't just write your&#xA;%  h |&#xA;%  e | text and transform it into&#xA;%  r |&#xA;%    | the shape that you want&#xA;%  M |&#xA;%  e | Macros help here&#xA;%  s |&#xA;%  s |&#xA;%  a |&#xA;%   ge |&#xA;%    |&#xA;%    |&#xA;%    V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ok, one more (&lt;code&gt;@q&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%&#xA;%            Not Important&#xA;%    O -------------------------&amp;gt;&#xA;%    | Stuff in side the table&#xA;%  O |&#xA;%  t | So you can't just write your&#xA;%  h |&#xA;%  e | text and transform it into&#xA;%  r |&#xA;%    | the shape that you want&#xA;%  M |&#xA;%  e | Macros help here&#xA;%  s |&#xA;%  s |&#xA;%  a |&#xA;%  g |&#xA;%   e |&#xA;%    |&#xA;%    V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your cursor is now on the last &lt;code&gt;e&lt;/code&gt;. The macro doesn't work well with the last letter (you can try with &lt;code&gt;@q&lt;/code&gt; and then &lt;code&gt;u&lt;/code&gt; (undo) for unsatisfactory results). Simply adjust it yourself (&lt;code&gt;X&lt;/code&gt; for backspace).&lt;/p&gt;&#xA;" OwnerUserId="850" LastActivityDate="2015-03-02T14:08:36.050" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2312" PostTypeId="2" ParentId="2310" CreationDate="2015-03-02T14:19:23.670" Score="19" Body="&lt;p&gt;There's the &lt;em&gt;command-line&lt;/em&gt; (that you know), and there's the &lt;em&gt;command-line window&lt;/em&gt; (the command-line in a special buffer, which you can edit just like any other). You enter this either via &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; from the command-line (also for &lt;code&gt;/&lt;/code&gt; searches etc.) when you feel the need for more &quot;editing power&quot;, or directly from normal mode via the dedicated &lt;code&gt;q:&lt;/code&gt;, &lt;code&gt;q/&lt;/code&gt;, etc. commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read more about this at &lt;code&gt;:help command-line-window&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-02T14:19:23.670" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2313" PostTypeId="1" AcceptedAnswerId="2314" CreationDate="2015-03-02T14:28:36.583" Score="2" ViewCount="544" Body="&lt;p&gt;I am looking for a digraph to enter the bullet symbol • (Unicode 8226, hex 2022), but it seems there is none. So, in absence of such a digraph, is there an alternative way to enter the bullet easily?&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2015-03-02T14:41:30.353" Title="Digraph for the &quot;bullet&quot; (8226 hex 2022)" Tags="|unicode|" AnswerCount="1" CommentCount="1" ClosedDate="2015-03-02T15:58:42.137" ContentLicense="CC BY-SA 3.0" />
  <row Id="2314" PostTypeId="2" ParentId="2313" CreationDate="2015-03-02T14:41:30.353" Score="5" Body="&lt;p&gt;You can define your own digraph like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:digraph .. 8226&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could use the pre-existing digraph &lt;code&gt;Sb&lt;/code&gt; which gives you Unicode 8729.  Not the exact code point you were looking for but it is probably pretty similar visually, if not the same, in most fonts.&lt;/p&gt;&#xA;" OwnerUserId="93" LastActivityDate="2015-03-02T14:41:30.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2315" PostTypeId="2" ParentId="2280" CreationDate="2015-03-02T16:39:21.967" Score="69" Body="&lt;pre&gt;&lt;code&gt;:vimgrep pattern %&#xA;:cwindow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#grep&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;vimgrep&lt;/code&gt;&lt;/a&gt; will search for your pattern in the current file (&lt;code&gt;%&lt;/code&gt;), or whatever files you specify.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3Acwin&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;cwindow&lt;/code&gt;&lt;/a&gt; will then open a buffer in your window that will only show the desired lines. You can use pretty much any navigating/search command within the &lt;code&gt;cwin&lt;/code&gt; buffer. Press return to jump to the line under your cursor in the source file.&lt;/p&gt;&#xA;&lt;p&gt;For help:&lt;br /&gt;&#xA;&lt;code&gt;:help vimgrep&lt;/code&gt;&lt;br /&gt;&#xA;&lt;code&gt;:help cwindow&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1155" LastEditorUserId="14340" LastEditDate="2020-10-09T17:50:58.517" LastActivityDate="2020-10-09T17:50:58.517" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="2316" PostTypeId="1" AcceptedAnswerId="2318" CreationDate="2015-03-02T17:17:55.493" Score="4" ViewCount="1287" Body="&lt;p&gt;I have two installations of vim: 7.4 in cygwin and 7.2 in a Linux virtual machine.  The vim in the virtual machine can undo multiple edits by repeatedly pressing the &lt;code&gt;u&lt;/code&gt; key.  The vim in cygwin can only undo the most recent change.  Pressing it a second time is a &quot;redo&quot; (which in the virtual machine can be accomplished with the Ctrl-r sequence).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to get the cygwin installation to be able to undo multiple edits through repeatedly pressing the u key, like it does in the virtual machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried comparing the features included in both installations, but I have not identified what could be causing this difference in behavior.  Another post on this website suggested I could use the &lt;code&gt;.&lt;/code&gt; key after using the &lt;code&gt;u&lt;/code&gt; to undo multiple times, but that has not worked for me in the cygwin installation.  I also haven't found any settings in the vimrc files that seem like they would modify this behavior.&lt;/p&gt;&#xA;" OwnerUserId="1162" LastEditorUserId="51" LastEditDate="2015-03-02T22:44:28.457" LastActivityDate="2015-03-02T22:44:28.457" Title="Undo multiple changes in Cygwin's vim" Tags="|undo-redo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2317" PostTypeId="2" ParentId="759" CreationDate="2015-03-02T17:39:42.523" Score="18" Body="&lt;p&gt;To get something to work with...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;qajjjq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Will start recording a macro into the &lt;code&gt;a&lt;/code&gt; register.&lt;/p&gt;&#xA;&lt;p&gt;You can see many of your current registers (used for macros, yanking, deleting, etc.) with the &lt;code&gt;:reg&lt;/code&gt; command or you can specify a register to display by providing its name. For example, to show register &lt;code&gt;a&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:reg a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;yields&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;--- Registers ---&#xA;&amp;quot;a   jjj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can append to an existing named register by using the corresponding capital letter. This works not just for recording macros, but for yanking as well. For example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;qAkkkq&#xA;:reg a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;yields&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;--- Registers ---&#xA;&amp;quot;a   jjjkkk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you want to use the let syntax to edit an existing macro, you can do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let @a='&amp;lt;C-r&amp;gt;a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which will expand to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let @a='jjjkkk'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and you can then change the individual keystrokes.&lt;/p&gt;&#xA;&lt;p&gt;Note that you can use the &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; (that is, &lt;kbd&gt;Ctrl + r&lt;/kbd&gt;) to paste from any register into command-line mode (or in insert mode, for that matter).&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, when you are in command-line mode, if you type &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; this will pop up the command-line window, where you can see/edit past commands issued, and you can edit your current command before calling it. Press enter on the command you want to submit.&lt;/p&gt;&#xA;&lt;p&gt;The benefit of this is that you can use your normal movement/substitution commands inside this buffer to edit your macro. For example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let @a='&amp;lt;C-r&amp;gt;a'&amp;lt;C-f&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;will bring up:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:118 reg&#xA;:119 reg a&#xA;:120 let @a='jjjkkk'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you're on command 120, you can do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s/kkk/}&#xA;&amp;lt;return&amp;gt;&#xA;:reg a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;yields&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;--- Registers ---&#xA;&amp;quot;a   jjj}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can, of course, paste the contents of the register into your buffer, and change it there. But you can do everything you need to without contaminating your working buffer.&lt;/p&gt;&#xA;" OwnerUserId="1155" LastEditorUserId="5298" LastEditDate="2023-04-03T16:47:52.760" LastActivityDate="2023-04-03T16:47:52.760" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2318" PostTypeId="2" ParentId="2316" CreationDate="2015-03-02T17:50:18.883" Score="6" Body="&lt;p&gt;Try to &lt;code&gt;:set nocompatible&lt;/code&gt; and see if that does it.  vi had only one undo level so Vim's ability to behave differently is one of the non-compatible changes the &lt;code&gt;nocompatible&lt;/code&gt; setting implements.&lt;/p&gt;&#xA;" OwnerUserId="93" LastActivityDate="2015-03-02T17:50:18.883" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2319" PostTypeId="1" CreationDate="2015-03-02T19:46:21.087" Score="35" ViewCount="3324" Body="&lt;p&gt;I often find myself typing commands like &lt;code&gt;gg&quot;+yG&lt;/code&gt; or &lt;code&gt;ggdG&lt;/code&gt; and would like a more efficient way to do this without having to move the cursor twice. Is there any command that I can use e.g. &lt;code&gt;y[movement]&lt;/code&gt; to copy the entire buffer without moving the cursor?&lt;/p&gt;&#xA;" OwnerUserId="880" LastEditorUserId="1292" LastEditDate="2019-01-24T12:48:43.217" LastActivityDate="2020-05-09T15:06:43.707" Title="Is there a text object for the entire buffer?" Tags="|cut-copy-paste|cursor-motions|custom-text-object|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2320" PostTypeId="2" ParentId="2319" CreationDate="2015-03-02T19:58:39.460" Score="46" Body="&lt;p&gt;Since vim uses the percent sign to reference the current buffer, you can use it to get everything quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%y&lt;/code&gt; will yank the entire buffer&#xA;&lt;code&gt;:%y+&lt;/code&gt; will yank it to the &lt;code&gt;+&lt;/code&gt; register (and presumably the clipboard, provided vim was compiled with the proper options). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%d&lt;/code&gt; and &lt;code&gt;:%d+&lt;/code&gt; will do the same for deletion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In each of these cases, the cursor remains in place.&lt;/p&gt;&#xA;" OwnerUserId="1166" LastEditorUserId="1166" LastEditDate="2015-03-03T17:13:05.613" LastActivityDate="2015-03-03T17:13:05.613" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2321" PostTypeId="2" ParentId="2319" CreationDate="2015-03-02T20:06:04.267" Score="10" Body="&lt;p&gt;There is no text object for the whole file by default, but it is possible to create them using &lt;code&gt;omap&lt;/code&gt;.  In this case, it would look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap f :&amp;lt;c-u&amp;gt;normal! mzggVG&amp;lt;cr&amp;gt;`z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a breakdown of how it works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap f &quot; make 'f' the text object name&#xA;:&amp;lt;c-u&amp;gt; &quot; use &amp;lt;c-u&amp;gt; to prevent vim from inserting visual selection marker at the beginning of the command automatically.&#xA;normal! &quot; use normal to make key presses ignoring any user mappings&#xA;mzggVG&amp;lt;cr&amp;gt;`z &quot; make a marker in register z, select the entire file in visual line mode and enter the normal command, and go back to the z marker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Notes:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;u&lt;/kbd&gt; can be used in the command line mode to delete everything to the left of the cursor position.  The reason why this is done is because if you enter the command line straight from visual mode, it will automatically insert &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; on the command line, and that isn't what we want.  I would also suggest you use something other than &lt;code&gt;f&lt;/code&gt;, because &lt;code&gt;f&lt;/code&gt; is normally used to move to the next searched character on the line.  For example, &lt;code&gt;fi&lt;/code&gt; will go to the next &lt;code&gt;i&lt;/code&gt; on the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relevant help topics:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help omap-info&#xA;:help :normal&#xA;:help c_CTRL-U&#xA;:help v_:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-11-29T13:47:06.427" LastActivityDate="2015-11-29T13:47:06.427" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2322" PostTypeId="1" AcceptedAnswerId="2325" CreationDate="2015-03-02T20:36:34.010" Score="6" ViewCount="661" Body="&lt;p&gt;How can I store a series of search and replace statements so I can run them later in sequence?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possibly after I have close and re-opened vim...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance I might run the following in sequence to convert a pasted table into a wiki formatted table with headers:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;1,1s/^\|\t/|!/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1,1s/$/|/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2,$s/^\|\t/|/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2,$s/$/|/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="24" LastEditDate="2015-03-05T05:21:48.280" LastActivityDate="2015-03-05T05:21:48.280" Title="How can I store a series of regular expression search and replace commands and run them later?" Tags="|substitute|persistent-state|" AnswerCount="4" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2323" PostTypeId="2" ParentId="2254" CreationDate="2015-03-02T20:56:06.617" Score="9" Body="&lt;p&gt;My &lt;a href=&quot;https://github.com/chrisbra/unicode.vim&quot;&gt;unicode plugin&lt;/a&gt; allows for easy input of unicode characters. Specifically it allows&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:Digraph &amp;lt;name&amp;gt;&lt;/code&gt; - Search digraphs for character&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:UnicodeTable&lt;/code&gt; - Displays a characterset table&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:UnicodeName&lt;/code&gt; - Identify character under cursor&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Completing of characters using their names or values from the unicode table (&lt;code&gt;:h i_CTRL-X_CTRL-Z&lt;/code&gt;) or the digarphs (&lt;code&gt;:h i_CTRL-X_CTRL_G&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Read the help for more info on how to use my plugin.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-03-02T20:56:06.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2324" PostTypeId="2" ParentId="2322" CreationDate="2015-03-02T21:59:47.597" Score="5" Body="&lt;p&gt;You can run all of them in the same command by joining them with a &lt;code&gt;|&lt;/code&gt; (vertical bar):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,1s/^\|\t/|!/g | 1,1s/$/|/g | 2,$s/^\|\t/|/g | 2,$s/$/|/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will then be available in your command history (&lt;kbd&gt;:&lt;/kbd&gt; &lt;kbd&gt;↑&lt;/kbd&gt; or &lt;kbd&gt;q&lt;/kbd&gt; &lt;kbd&gt;:&lt;/kbd&gt;), which should be persistent across Vim sessions as long as you have your &lt;code&gt;.viminfo&lt;/code&gt; set up corectly.&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-03-02T21:59:47.597" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2325" PostTypeId="2" ParentId="2322" CreationDate="2015-03-02T22:03:36.023" Score="7" Body="&lt;p&gt;Put them in a function (into your vimrc or a file in the plugin folder):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Stuff()&#xA;    1,1s/^\|\t/|!/g&#xA;    1,1s/$/|/g&#xA;    2,$s/^\|\t/|/g&#xA;    2,$s/$/|/g&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use &lt;code&gt;:call Stuff()&amp;lt;cr&amp;gt;&lt;/code&gt; to run them or make a custom command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command DoStuff call Stuff()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And just do &lt;code&gt;:DoStuff&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanna run them directly from a buffer first copy them and then do &lt;code&gt;:@&quot;&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also copy commands you've run earlier by doing &lt;code&gt;q:&lt;/code&gt; and copying them from there&lt;/p&gt;&#xA;" OwnerUserId="1172" LastEditorUserId="64" LastEditDate="2015-03-03T01:37:34.973" LastActivityDate="2015-03-03T01:37:34.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2326" PostTypeId="1" AcceptedAnswerId="2346" CreationDate="2015-03-02T22:53:05.827" Score="4" ViewCount="1649" Body="&lt;p&gt;When I write VHDL Vim uses a mix of tabs and spaces which aim to align columns beneath the last parenthesis. For example, Vim will produce something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Inst_IMem: IMem PORT MAP(&#xA;                            CLK =&amp;gt; clk,&#xA;                            ADDR =&amp;gt; foo,&#xA;                            DATA =&amp;gt; bar&#xA;                        );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Inst_IMem: IMem PORT MAP(&#xA;    CLK =&amp;gt; clk,&#xA;    ADDR =&amp;gt; foo,&#xA;    DATA =&amp;gt; bar&#xA;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I make Vim indent VHDL as it would indent programming languages such as C and Java? I.e. a new indentation level (either a tab or say four spaces) for every new nesting level.&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="51" LastEditDate="2015-03-03T15:58:36.607" LastActivityDate="2015-03-03T16:07:12.793" Title="Indenting VHDL as other programming languages" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2327" PostTypeId="1" AcceptedAnswerId="2339" CreationDate="2015-03-03T03:21:20.143" Score="5" ViewCount="870" Body="&lt;p&gt;I want to fold sections in a document. Each new section should define a top-level fold instead of a nested fold. I want to use a single delimiter to define a fold. Consider an example document:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; first fold&#xA;also in first fold&#xA;&amp;gt;&amp;gt;&amp;gt; second fold&#xA;still in second fold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to fold like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+----2 lines: first fold&#xA;+----2 lines: second fold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;foldnestmax=0&lt;/code&gt; does not affect &lt;code&gt;foldmethod=marker&lt;/code&gt;, it only works on &lt;code&gt;indent&lt;/code&gt; and &lt;code&gt;syntax&lt;/code&gt; fold methods. Using &lt;code&gt;foldmarker=&amp;gt;&amp;gt;&amp;gt;,&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; does not work, it creates nested folds. The only option I have found is to use fold numbers, e.g. &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;1 first fold&lt;/code&gt;, but I'd like to avoid that. Is that possible?&lt;/p&gt;&#xA;" OwnerUserId="1176" LastActivityDate="2015-03-03T11:27:06.377" Title="Fold with markers, but disable nesting?" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2328" PostTypeId="1" AcceptedAnswerId="2330" CreationDate="2015-03-03T04:04:48.783" Score="9" ViewCount="476" Body="&lt;p&gt;For example, I'd like to set&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4&#xA;set shiftwidth=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4&#xA;set shiftwidth=tabstop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I can set both values by only changing a single number?&lt;/p&gt;&#xA;" OwnerUserId="200" LastEditorUserId="1682" LastEditDate="2015-06-24T21:24:21.113" LastActivityDate="2015-06-24T21:24:21.113" Title="Is there a way to set an option to the value of another option?" Tags="|options|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2329" PostTypeId="2" ParentId="2328" CreationDate="2015-03-03T05:02:07.090" Score="2" Body="&lt;p&gt;Might be a better way but you could always do this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;exec 'set shiftwidth=' . &amp;amp;tabstop&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="132" LastActivityDate="2015-03-03T05:02:07.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2330" PostTypeId="2" ParentId="2328" CreationDate="2015-03-03T05:06:20.657" Score="15" Body="&lt;p&gt;You can use the &lt;code&gt;let&lt;/code&gt; command instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let &amp;amp;shiftwidth = &amp;amp;tabstop&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;amp;&lt;/code&gt; specifies that the variable name is a Vim option. You can also do &lt;code&gt;:help let-option&lt;/code&gt; to know more about it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let &amp;amp;{option-name} = {expr1}&#xA;        Set option {option-name} to the result of the&#xA;        expression {expr1}.  A String or Number value is&#xA;        always converted to the type of the option.&#xA;        For an option local to a window or buffer the effect&#xA;        is just like using the |:set| command: both the local&#xA;        value and the global value are changed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="246" LastActivityDate="2015-03-03T05:06:20.657" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2331" PostTypeId="1" AcceptedAnswerId="2332" CreationDate="2015-03-03T07:13:15.927" Score="5" ViewCount="2049" Body="&lt;p&gt;How can I start a build with my &lt;code&gt;makeprg&lt;/code&gt; running in a different directory than the working directory of vim and still catch errors in quickfix so that I can jump between them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that quickfix doesn't know how to find the error locations as reported by the &lt;code&gt;makeprg&lt;/code&gt; due to the different paths. (The particular build system I have in mind is CMake and Ninja.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that there is a path variable in Vim that to which I can add the other path. The last time I tried that it seemed less than convenient but maybe there's a good autocommand trick to fix that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I set my &lt;code&gt;makeprg&lt;/code&gt; to a shell script that pipes build errors through a &lt;code&gt;sed&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2019-04-23T02:39:40.593" Title="Quickfix with makeprg running in a different directory" Tags="|quickfix|makeprg|path|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2332" PostTypeId="2" ParentId="2331" CreationDate="2015-03-03T07:40:21.787" Score="3" Body="&lt;p&gt;Make and Ninja offer a &lt;code&gt;-C&lt;/code&gt; flag. From Ninja:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-C DIR   change to DIR before doing anything else&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I run Ninja in a shell with the &lt;code&gt;-C&lt;/code&gt; flag pointing somewhere that isn't the working directory, then the reported paths are the same as if I had &lt;code&gt;cd&lt;/code&gt;'d over to the build directory. Nonetheless, Vim knows to become more intelligent when you use this flag in your &lt;code&gt;makeprg&lt;/code&gt; and quickfix can then figure out where it should jump to. In the quickfix window, the reported paths are changed to be relative to Vim's working directory.&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2015-03-03T07:40:21.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2333" PostTypeId="2" ParentId="2306" CreationDate="2015-03-03T07:56:31.813" Score="15" Body="&lt;p&gt;The &lt;code&gt;'foldmethod'&lt;/code&gt; is a window-local option; setting it from your &lt;code&gt;~/.vimrc&lt;/code&gt; doesn't necessarily have the right effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because syntax folding is bound to the &lt;code&gt;html&lt;/code&gt; &lt;em&gt;filetype&lt;/em&gt;, these settings belong to &lt;code&gt;~/.vim/after/ftplugin/html.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal foldmethod=syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This depends on having &lt;code&gt;filetype plugin on&lt;/code&gt; in your &lt;code&gt;~/.vimrc&lt;/code&gt;, which you probably have. You can also configure other related options there, e.g. &lt;code&gt;foldcolumn=4&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also note that so far (as of Vim 7.4.1830), the default HTML syntax script only folds a multi-line tag itself, &lt;strong&gt;not the text between the opening and closing tag&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, this gets folded:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&#xA;    class=&quot;foo&quot;&#xA;    style=&quot;width: 100&quot;&#xA;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this doesn't:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;    &amp;lt;b&amp;gt;stuff in between&amp;lt;/b&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get this, you need to extend the syntax script, e.g. via the following, best placed into &lt;code&gt;~/.vim/after/syntax/html.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Alternative 1&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Folding is performed between all but void html elements (those which don't  have a closing sibling, like &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt;). &lt;sup&gt;Contributed by @zanona; thanks!&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region htmlFold start=&quot;&amp;lt;\z(\&amp;lt;\(area\|base\|br\|col\|command\|embed\|hr\|img\|input\|keygen\|link\|meta\|para\|source\|track\|wbr\&amp;gt;\)\@![a-z-]\+\&amp;gt;\)\%(\_s*\_[^/]\?&amp;gt;\|\_s\_[^&amp;gt;]*\_[^&amp;gt;/]&amp;gt;\)&quot; end=&quot;&amp;lt;/\z1\_s*&amp;gt;&quot; fold transparent keepend extend containedin=htmlHead,htmlH\d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Alternative 2&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Folding is performed between certain explicitly named structural (e.g. &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;), paragraph-level (e.g. &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt;) and ancillary (e.g. &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt;) HTML tags.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region htmlFold start=&quot;&amp;lt;\z(p\|h\d\|i\?frame\|table\|colgroup\|thead\|tfoot\|tbody\|t[dhr]\|pre\|[diou]l\|li\|span\|div\|head\|script\|style\|blockquote\|form\)\%(\_s*\_[^/]\?&amp;gt;\|\_s\_[^&amp;gt;]*\_[^&amp;gt;/]&amp;gt;\)&quot; end=&quot;&amp;lt;/\z1\_s*&amp;gt;&quot; fold transparent keepend extend containedin=htmlHead,htmlH\d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2016-06-03T06:59:07.010" LastActivityDate="2016-06-03T06:59:07.010" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="2334" PostTypeId="1" AcceptedAnswerId="2338" CreationDate="2015-03-03T08:46:44.543" Score="1" ViewCount="2462" Body="&lt;p&gt;I am using Vim 7.4.488 in iTerm2. Currently I've configured the 'linespace' setting in iTerm2's preferences. However, I would like to set a different linespace for Vim. I know that &lt;code&gt;:set linespace=1&lt;/code&gt; should to the trick. However this does not work, as seen &lt;a href=&quot;https://stackoverflow.com/a/8206341/739972&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know if there is some kind of trick or setting that allows me to set different linespaces for iTerm and Vim, instead of using iTerm's 'global' preferences.&lt;/p&gt;&#xA;" OwnerUserId="480" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-03-03T11:44:33.680" Title="Linespace in Vim using iTerm2" Tags="|vimrc|terminal|iterm2|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2335" PostTypeId="2" ParentId="2328" CreationDate="2015-03-03T09:39:25.930" Score="0" Body="&lt;p&gt;Specifically in this case:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27softtabstop%27&quot; rel=&quot;nofollow&quot;&gt;http://vimhelp.appspot.com/options.txt.html#%27softtabstop%27&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When 'sts' is negative, the value of 'shiftwidth' is used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27shiftwidth%27&quot; rel=&quot;nofollow&quot;&gt;http://vimhelp.appspot.com/options.txt.html#%27shiftwidth%27&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When ['shiftwidth' is] zero the 'ts' value will be used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1182" LastActivityDate="2015-03-03T09:39:25.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2336" PostTypeId="1" AcceptedAnswerId="2337" CreationDate="2015-03-03T10:07:41.577" Score="18" ViewCount="8637" Body="&lt;p&gt;How do I change the colour of the statusline of the currently focused window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen colorschemes modify this. Is this some sort of highlight group? Or something else?&lt;/p&gt;&#xA;" OwnerUserId="581" LastEditorUserId="24" LastEditDate="2015-03-03T17:44:42.807" LastActivityDate="2015-03-03T17:44:42.807" Title="How do I change the colour of the statusline of the currently focused window?" Tags="|vim-windows|colorscheme|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2337" PostTypeId="2" ParentId="2336" CreationDate="2015-03-03T10:49:14.743" Score="25" Body="&lt;p&gt;You can change it in your vimrc. The currently focused window is highlight group &lt;code&gt;Statusline&lt;/code&gt;, other windows are &lt;code&gt;StatuslineNC&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example for terminal Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi StatusLine                  ctermfg=8     ctermbg=2     cterm=NONE&#xA;hi StatusLineNC                ctermfg=2     ctermbg=8     cterm=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the GUI, use &lt;code&gt;guifg&lt;/code&gt; and &lt;code&gt;guibg&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="911" LastEditorUserId="51" LastEditDate="2015-03-03T11:13:02.963" LastActivityDate="2015-03-03T11:13:02.963" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2338" PostTypeId="2" ParentId="2334" CreationDate="2015-03-03T11:10:42.133" Score="5" Body="&lt;p&gt;Terminal Vim has no control over, or knowledge of, the line spacing that is currently being used in the terminal within which it is running. It just sends characters to the terminal (in your case, iTerm2), which renders them according to its own settings. There isn't, therefore, a clean way to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you &lt;em&gt;can&lt;/em&gt; do, however, is tell iTerm2 to switch profiles on the fly by using its &lt;a href=&quot;https://iterm2.com/documentation-escape-codes.html&quot; rel=&quot;nofollow&quot;&gt;proprietary escape codes&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to switch line-spacing when you exit and enter Vim:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create a copy of your iTerm2 profile: (With &lt;em&gt;Preferences... -&gt; Profiles -&gt; Other Actions... -&gt; Duplicate Profile&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;Set the name of your new profile: Under the &lt;em&gt;General&lt;/em&gt; tab set the &lt;em&gt;Name&lt;/em&gt; to &lt;strong&gt;LineSpaced&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Set up the required line spacing: Under the &lt;em&gt;Text&lt;/em&gt; tab, click on &lt;em&gt;Change Font&lt;/em&gt; and drag the slider for &lt;em&gt;Character Spacing -&gt; Vertical&lt;/em&gt; to your preferred value.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add the following code to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('$ITERM_PROFILE')&#xA;  silent !printf '\e]50;SetProfile=LineSpaced\x7'&#xA;  autocmd VimLeave * silent !printf '\e]50;SetProfile=Default\x7'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will switch to the iTerm2 profile named &quot;LineSpaced&quot; when you run Vim, and sets up an &lt;code&gt;autocommand&lt;/code&gt; to switch back to the profile named &quot;Default&quot; when you exit Vim.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This has the side-effect of changing the height of the iTerm2 window (because you are changing the line-spacing without changing the number of lines). If you don't want this to happen, you can use some AppleScript to tell iTerm2 to change the number of rows dynamically, in order to keep the height of the window roughly consistent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('$ITERM_PROFILE')&#xA;  silent !printf '\e]50;SetProfile=LineSpaced\x7'&#xA;  silent !osascript -e &quot;tell application \&quot;iTerm\&quot; to tell the current terminal to set number of rows to 36&quot;&#xA;  autocmd VimLeave * silent !printf '\e]50;SetProfile=Default\x7'&#xA;  autocmd VimLeave * silent !osascript -e &quot;tell application \&quot;iTerm\&quot; to tell the current terminal to set number of rows to 48&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. You might need to tweak the number of rows specified to work well with the line-spacings you have set for your two profiles.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2015-03-03T11:44:33.680" LastActivityDate="2015-03-03T11:44:33.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2339" PostTypeId="2" ParentId="2327" CreationDate="2015-03-03T11:27:06.377" Score="6" Body="&lt;p&gt;You can do that with a &lt;em&gt;fold expression&lt;/em&gt;. Cp. &lt;code&gt;:help fold-expr&lt;/code&gt;. When the current line starts with your fold marker &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;, start a new fold (of level 1); else, continue with the same level as before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal foldmethod=expr foldexpr=getline(v:lnum)=~#'^&amp;gt;&amp;gt;&amp;gt;'?'&amp;gt;1':'='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-03T11:27:06.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2340" PostTypeId="1" AcceptedAnswerId="2369" CreationDate="2015-03-03T13:28:28.477" Score="3" ViewCount="249" Body="&lt;p&gt;I am looking for a &lt;code&gt;g8&lt;/code&gt; equivalent that prints the hex values of the character under the cursor according to the file encoding of the file loaded in a buffer rather than assuming it's utf-8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there such a thing?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="23502" LastEditDate="2022-10-31T17:25:45.160" LastActivityDate="2022-10-31T17:25:45.160" Title="Is there something similar to g8 but shows the values according to the file encoding?" Tags="|unicode|encoding|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2341" PostTypeId="1" AcceptedAnswerId="2342" CreationDate="2015-03-03T14:05:47.313" Score="3" ViewCount="2583" Body="&lt;p&gt;I have the same text that I want to replace in multiple files (say, I'm updating version numbers in multiple files). Even using the command history to reuse commands, it sure is tedious to open each one, search and replace in it, and then save it. Can I do just all of this in one search and replace operation on all of these files?&lt;/p&gt;&#xA;" OwnerUserId="1111" LastActivityDate="2016-09-12T01:01:06.653" Title="How can I search and replace within multiple files?" Tags="|search|multiple-files|replace|" AnswerCount="1" CommentCount="5" ClosedDate="2015-03-04T12:32:27.843" ContentLicense="CC BY-SA 3.0" />
  <row Id="2342" PostTypeId="2" ParentId="2341" CreationDate="2015-03-03T14:05:47.313" Score="8" Body="&lt;p&gt;Let's say that you decided that you want to update the text &lt;code&gt;use 5.008&lt;/code&gt; to &lt;code&gt;use 5.010&lt;/code&gt; in multiple Perl script and Perl modules.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:arg *.pl       &#xA;:argadd *.pm&#xA;:argdo %s/use 5\.008/use 5\.010/ge | update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;note that you need to escape '.', since it it's the wildcard for one character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:arg *.pl&lt;/code&gt; fills the argument list with all of the files ending in &lt;code&gt;.pl&lt;/code&gt; in the current directory.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:argadd *.pm&lt;/code&gt; adds all of the files ending in &lt;code&gt;.pm&lt;/code&gt; to the argument list.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:argdo %s/use 5.008/use 5.010/ge | update&lt;/code&gt; Does the search and replace on each file in the argument list and &lt;em&gt;saves each file&lt;/em&gt; for you.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vim.wikia.com/wiki/Search_and_replace_in_multiple_buffers&quot; rel=&quot;nofollow&quot;&gt;Search and Replace in Multiple Buffers&lt;/a&gt; for more details and variations.&lt;/p&gt;&#xA;" OwnerUserId="1111" LastEditorUserId="9187" LastEditDate="2016-09-12T01:01:06.653" LastActivityDate="2016-09-12T01:01:06.653" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2343" PostTypeId="2" ParentId="2047" CreationDate="2015-03-03T15:12:59.523" Score="13" Body="&lt;p&gt;I can't do comparison, as Vim-LaTeX is the only LaTeX plugin I've used. I have been using Vim-LaTeX for almost a year.&#xA;So I will talk about Vim-LaTeX alone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are &lt;em&gt;many&lt;/em&gt; features present in Vim-LaTeX. I don't remember all of them. I'll just talk about features that I know and use constantly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: These are &lt;em&gt;my limited user experience&lt;/em&gt;, which may be &lt;em&gt;very misleading&lt;/em&gt;. I'm not a seasoned Vim user. And I know of nothing about vimscript.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;IMAP() and &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; Jumpping&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;IMAP()&lt;/code&gt; function and &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; jumpping functions are provided separately as a plugin &lt;code&gt;imaps.vim&lt;/code&gt; in Vim-LaTeX bundle. They are powerful features and could be very useful even when you are not writing LaTeX.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;IMAP()&lt;/code&gt; function provides a more natural way to do insert mode mappings and templating in general than the built-in &lt;code&gt;imap&lt;/code&gt; and &lt;code&gt;iabbrev&lt;/code&gt;, IMO.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; jumpping is utilized by many Vim-LaTeX completion features. A jumpping point is indicated by &lt;code&gt;&amp;lt;++&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Built-in insert mode key mappings are implemented as &lt;code&gt;IMAP()&lt;/code&gt; calls. For example, you can find a long list of useful &lt;code&gt;IMAP()&lt;/code&gt; calls in &lt;code&gt;main.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call IMAP ('__', '_{&amp;lt;++&amp;gt;}&amp;lt;++&amp;gt;', &quot;tex&quot;)&#xA;call IMAP ('()', '(&amp;lt;++&amp;gt;)&amp;lt;++&amp;gt;', &quot;tex&quot;)&#xA;call IMAP ('[]', '[&amp;lt;++&amp;gt;]&amp;lt;++&amp;gt;', &quot;tex&quot;)&#xA;call IMAP ('{}', '{&amp;lt;++&amp;gt;}&amp;lt;++&amp;gt;', &quot;tex&quot;)&#xA;...&#xA;call IMAP ('((', '\left( &amp;lt;++&amp;gt; \right)&amp;lt;++&amp;gt;', &quot;tex&quot;)&#xA;call IMAP ('[[', '\left[ &amp;lt;++&amp;gt; \right]&amp;lt;++&amp;gt;', &quot;tex&quot;)&#xA;call IMAP ('{{', '\left\{ &amp;lt;++&amp;gt; \right\}&amp;lt;++&amp;gt;', &quot;tex&quot;)&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then when you type say &lt;code&gt;()&lt;/code&gt;, the cursor will reside automatically between the parenthese, replacing the first &lt;code&gt;&amp;lt;++&amp;gt;&lt;/code&gt;. After you finished typing inside, you kick &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; and bang, the cursor will move out of parenthese and you just keep typing forward. Once you are used to it, it begins to form a typing flow which is kinda addictive...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You see from above a &lt;code&gt;\left&lt;/code&gt; &lt;code&gt;\right&lt;/code&gt; pair can be typed easily with double stroke of its opening bracket. And &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; jumpping makes typing flow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One major glitch of &lt;code&gt;IMAP()&lt;/code&gt; and &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; thing is that &lt;em&gt;they messes up your last change history&lt;/em&gt;. (One bug I wish to fix for a long time.) Therefore, you may encounter unexpected behavior when trying to redo your last change by &lt;code&gt;.&lt;/code&gt; if your &quot;supposed last change&quot; contains these function calls.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You can do all kinds of mappings using &lt;code&gt;IMAP()&lt;/code&gt;, from simple key mappings to more complex templating. Here are some examples of my mappings (&lt;code&gt;ftplugin/tex.vim&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call IMAP('*EEQ',&quot;\\begin{equation*}\&amp;lt;CR&amp;gt;&amp;lt;++&amp;gt;\&amp;lt;CR&amp;gt;\\end{equation*}&amp;lt;++&amp;gt;&quot;,'tex')&#xA;call IMAP('DEF',&quot;\\begin{definition}[&amp;lt;++&amp;gt;]\&amp;lt;CR&amp;gt;&amp;lt;++&amp;gt;\&amp;lt;CR&amp;gt;\\end{definition}&amp;lt;++&amp;gt;&quot;,'tex')&#xA;call IMAP('BIC','\binom{&amp;lt;++&amp;gt;}{&amp;lt;++&amp;gt;}&amp;lt;++&amp;gt;','tex')&#xA;call IMAP('PVERB','\PVerb{&amp;lt;++&amp;gt;}&amp;lt;++&amp;gt;','tex')&#xA;call IMAP('VERB','\verb|&amp;lt;++&amp;gt;|&amp;lt;++&amp;gt;','tex')&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;An interesting fact about &lt;code&gt;imaps.vim&lt;/code&gt; plugin is that it's a global plugin, which implies its potential usage beyond LaTeX. Indeed, I do use &lt;code&gt;&amp;lt;++&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; jumppings (combining with other plugins) to build code snippet templates in C.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;&lt;code&gt;&amp;lt;F5&amp;gt; &amp;lt;F7&amp;gt;&lt;/code&gt; Insertion of Commands and Environments&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;One disadvantage of &lt;code&gt;IMAP()&lt;/code&gt; is that the key combination can not be used in normal text anymore (unless you undo the mapping by &lt;code&gt;u&lt;/code&gt;). In the cases that you just want to &lt;em&gt;trigger&lt;/em&gt; the mapping as you wish, the &lt;code&gt;&amp;lt;F5&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;F7&amp;gt;&lt;/code&gt; come in handy. These two keys are used for &lt;em&gt;triggering&lt;/em&gt; environments and inline commands insertion, respectively. And they behave differently based on the mode and customizations from user.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;In Insert/Normal Mode, when the cursor is attaching a word or is in the word, pressing &lt;code&gt;&amp;lt;F5&amp;gt;&lt;/code&gt; will by default insert a basic environment of the form&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{word}&#xA;&amp;lt;Cursor&amp;gt;&#xA;\end{word}&amp;lt;++&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;based on the word; pressing &lt;code&gt;&amp;lt;F7&amp;gt;&lt;/code&gt; will by default insert a basic inline command of the form &lt;code&gt;\word{}&amp;lt;++&amp;gt;&lt;/code&gt; based on the word. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;By default&quot;, I mean you can customize the behavior of a specific word when triggered by &lt;code&gt;&amp;lt;F5&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;F7&amp;gt;&lt;/code&gt;. Here are some of my settings (&lt;code&gt;.vimrc&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Tex_Com_newcommand = &quot;\\newcommand{&amp;lt;++&amp;gt;}[&amp;lt;++&amp;gt;]{&amp;lt;++&amp;gt;}&amp;lt;++&amp;gt;&quot;&#xA;let g:Tex_Com_latex = &quot;{\\LaTeX}&amp;lt;++&amp;gt;&quot;&#xA;let g:Tex_Com_D = &quot;\\D{&amp;lt;++&amp;gt;}{&amp;lt;++&amp;gt;}&amp;lt;++&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In Insert/Normal Mode, when the cursor is &lt;em&gt;not&lt;/em&gt; attached to anything (a.k.a &lt;em&gt;alone&lt;/em&gt;), pressing &lt;code&gt;&amp;lt;F5&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;F7&amp;gt;&lt;/code&gt; will prompt to you a menu to select environment/command to insert. Or you can type the name of desired environment/command at the bottom. Personally, I rarely use &lt;code&gt;&amp;lt;F5&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;F7&amp;gt;&lt;/code&gt; this way.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;code&gt;&amp;lt;F5&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;F7&amp;gt;&lt;/code&gt; after visually selecting a piece of text will prompt a menu for &lt;em&gt;wrapping text&lt;/em&gt;. Then the selected text will be wrapped in the environment/command you selected or typed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In Insert/Normal Mode, when the cursor is in the scope of an environment/command, press &lt;code&gt;&amp;lt;Shift&amp;gt;+&amp;lt;F5&amp;gt;/&amp;lt;F7&amp;gt;&lt;/code&gt; will prompt a menu for &lt;em&gt;changing environment/command&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Misc Key Mappings&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Greek Letters. &lt;code&gt;`a&lt;/code&gt; to &lt;code&gt;`z&lt;/code&gt; and corresponding capitals.&lt;/li&gt;&#xA;&lt;li&gt;Symbols like &lt;code&gt;`8&lt;/code&gt; for &lt;code&gt;\infty&lt;/code&gt;, &lt;code&gt;`&amp;lt;&lt;/code&gt; for &lt;code&gt;\le&lt;/code&gt;, &lt;code&gt;`I&lt;/code&gt; for &lt;code&gt;\int_{&amp;lt;++&amp;gt;}^{&amp;lt;++&amp;gt;}&amp;lt;++&amp;gt;&lt;/code&gt;, etc.&lt;/li&gt;&#xA;&lt;li&gt;Pressing &lt;code&gt;&quot;&lt;/code&gt; twice gets a pair of TeX double quotes. So to type literal &lt;code&gt;&quot;&lt;/code&gt; character, you have to use .&lt;/li&gt;&#xA;&lt;li&gt;Pressing  in several enumeration environments will insert appropriate &lt;code&gt;\item&lt;/code&gt; tag.&lt;/li&gt;&#xA;&lt;li&gt;You can wrap visually selected part of math in &lt;code&gt;\left&lt;/code&gt; &lt;code&gt;\right&lt;/code&gt; pair by &lt;code&gt;`(&lt;/code&gt;, &lt;code&gt;`[&lt;/code&gt; and &lt;code&gt;`{&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Folding is customizable. Three global variable control what can be folded: &lt;code&gt;Tex_FoldedSections&lt;/code&gt;, &lt;code&gt;Tex_FoldedMisc&lt;/code&gt;, and &lt;code&gt;Tex_FoldedEnvironments&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Sometimes the built-in mappings have just gone too far or are not quit what you want. You can override the built-in mappings by redefining them in &lt;code&gt;after/ftplugin/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call IMAP('`|','\abs{&amp;lt;++&amp;gt;}&amp;lt;++&amp;gt;','tex')&#xA;call IMAP('ETE',&quot;\\begin{table}\&amp;lt;CR&amp;gt;\\centering\&amp;lt;CR&amp;gt;\\caption{&amp;lt;+Caption text+&amp;gt;}\&amp;lt;CR&amp;gt;\\label{tab:&amp;lt;+label+&amp;gt;}\&amp;lt;CR&amp;gt;\\begin{tabular}{&amp;lt;+dimensions+&amp;gt;}\&amp;lt;CR&amp;gt;&amp;lt;++&amp;gt;\&amp;lt;CR&amp;gt;\\end{tabular}\&amp;lt;CR&amp;gt;\\end{table}&amp;lt;++&amp;gt;&quot;,'tex')&#xA;call IMAP('==','==','tex')&#xA;call IMAP('`\','`\','tex')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Set Multiple Compilation Engine&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I always need to switch between &lt;code&gt;pdflatex&lt;/code&gt; and &lt;code&gt;xelatex&lt;/code&gt; engine. Thus, I have the following lines in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;switch to pdflatex&#xA;function SetpdfLaTeX()&#xA;    let g:Tex_CompileRule_pdf = 'pdflatex --interaction=nonstopmode -synctex=1 -src-specials $*'&#xA;endfunction&#xA;noremap &amp;lt;Leader&amp;gt;lp :&amp;lt;C-U&amp;gt;call SetpdfLaTeX()&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;switch to xelatex&#xA;function SetXeLaTeX()&#xA;    let g:Tex_CompileRule_pdf = 'xelatex --interaction=nonstopmode -synctex=1 -src-specials $*'&#xA;endfunction&#xA;noremap &amp;lt;Leader&amp;gt;lx :&amp;lt;C-U&amp;gt;call SetXeLaTeX()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;View PDF, Forward and Backward Search between Vim and PDF viewer&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This is a messy and complicated topic. With certain PDF viewer and &lt;em&gt;a certain amount of luck&lt;/em&gt;, it can be very easy. But it's mainly a matter of google search.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Suggestions&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You should find your balance between LaTeX way and Vim-LaTeX way.&lt;/li&gt;&#xA;&lt;li&gt;Vim-LaTeX is no light-weight at all. There are some features and/or key mappings you'll possibly never gonna use and you have to manually override them.&lt;/li&gt;&#xA;&lt;li&gt;You use Vim. You know what &lt;em&gt;patience&lt;/em&gt; mean. :-)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Overall, I think it will work well if you are willing to invest some time to tame the beast. That being said, had I time and adequate knowledge, I will surely thin off the overhead features and explore the potentials of integration with other plugins.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;References&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim-latex.sourceforge.net/index.php?subject=manual&amp;amp;title=Manual#user-manual&quot;&gt;Official user manual&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://michaelgoerz.net/refcards/vimlatexqrc.pdf&quot;&gt;Cheat sheet&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="682" LastEditorUserId="51" LastEditDate="2015-03-03T15:19:48.983" LastActivityDate="2015-03-03T15:19:48.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2344" PostTypeId="2" ParentId="2310" CreationDate="2015-03-03T15:36:25.417" Score="16" Body="&lt;p&gt;In addition to providing &lt;a href=&quot;https://vi.stackexchange.com/a/2312/343&quot;&gt;the command-line window&lt;/a&gt;, Vim also offers some limited features allowing you to interact with the command-line whilst in command-line mode (&lt;em&gt;without&lt;/em&gt; using the arrow keys).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Movement&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;ctrl-b&amp;gt;&lt;/code&gt; move the cursor to the beginning of the command-line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;ctrl-e&amp;gt;&lt;/code&gt; move the cursor to the end of the command-line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Editing&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;ctrl-h&amp;gt;&lt;/code&gt; delete the character before the cursor (like backspace)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;ctrl-w&amp;gt;&lt;/code&gt; delete the word before the cursor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;ctrl-u&amp;gt;&lt;/code&gt; delete all the way from the cursor back to the start of the command-line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could of course add command-line mappings with &lt;code&gt;:cnoremap&lt;/code&gt; to emulate &lt;a href=&quot;http://vimhelp.appspot.com/tips.txt.html#emacs-keys&quot; rel=&quot;noreferrer&quot;&gt;certain other programs' navigation keys&lt;/a&gt;. Or install Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-rsi&quot; rel=&quot;noreferrer&quot;&gt;RSI plugin&lt;/a&gt; to use the de facto standard Readline bindings.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Pasting&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can paste the contents of any register into the command-line at the position of the cursor by pressing &lt;code&gt;&amp;lt;ctrl-r&amp;gt;&lt;/code&gt; followed by the character specifying the register. e.g. &lt;code&gt;&amp;lt;ctrl-r&amp;gt;&lt;/code&gt;,&lt;code&gt;+&lt;/code&gt; will insert the contents of the clipboard into the command-line; &lt;code&gt;&amp;lt;ctrl-r&amp;gt;&lt;/code&gt;,&lt;code&gt;&quot;&lt;/code&gt; will insert the contents of the &quot;unnamed&quot; register (i.e. the contents of your last delete or yank).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help cmdline.txt&lt;/code&gt; for further details of all the above.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-04-30T12:51:23.127" LastActivityDate="2018-04-30T12:51:23.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2345" PostTypeId="1" CreationDate="2015-03-03T15:40:04.963" Score="1" ViewCount="201" Body="&lt;p&gt;The tar.vim plugin tries to give a special view of tar files. Its filetype &quot;detection&quot; matches against the filename.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I try to download a tar file from the web and get an HTML error page, I cannot open it in vim without first renaming the file. Vim instead shows me tar.vim's error output (&quot;gzip: file not in gzip format, tar: this does not look like a tar archive&quot;), and I cannot seem to switch to editing as a regular file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command line option to disable the tar.vim plugin, or filetype detection? I don't want to have to temporarily edit my .vimrc or rename the file (I want to overwrite it with the archive once I figure out the problem).&lt;/p&gt;&#xA;" OwnerUserId="1176" LastEditorUserId="51" LastEditDate="2015-03-03T15:42:44.957" LastActivityDate="2015-03-03T15:42:44.957" Title="Disable tar.vim plugin from command line?" Tags="|filetype|" AnswerCount="0" CommentCount="0" ClosedDate="2015-03-04T12:32:42.750" ContentLicense="CC BY-SA 3.0" />
  <row Id="2346" PostTypeId="2" ParentId="2326" CreationDate="2015-03-03T15:58:20.953" Score="2" Body="&lt;p&gt;This seems to be fairly simple, you only need to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:vhdl_indent_genportmap = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you're done :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this in &lt;code&gt;/usr/share/vim/vim74/indent/vhdl.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; option to disable alignment of generic/port mappings&#xA;if !exists(&quot;g:vhdl_indent_genportmap&quot;)&#xA;  let g:vhdl_indent_genportmap = 1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is used further below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if g:vhdl_indent_genportmap&#xA;  return ind2 + stridx(prevs_noi, '(') + &amp;amp;sw&#xA;else&#xA;  return ind2 + &amp;amp;sw&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if it's off (0), it will only indent a single &lt;code&gt;shiftwidth&lt;/code&gt;, if it's on (1), it uses the location of the &lt;code&gt;(&lt;/code&gt; on the previous line + `shiftwidth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This (and some other things) are also documented in &lt;a href=&quot;http://vimhelp.appspot.com/indent.txt.html#ft-vhdl-indent&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help ft-vhdl-indent&lt;/code&gt;&lt;/a&gt;; I found this page by typing &lt;code&gt;:help vhdl&lt;/code&gt; (a number of filetypes have their own help pages).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-03-03T16:07:12.793" LastActivityDate="2015-03-03T16:07:12.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2347" PostTypeId="1" AcceptedAnswerId="2348" CreationDate="2015-03-03T18:07:01.840" Score="6" ViewCount="1584" Body="&lt;p&gt;I am very new to vim and would like to know if I could have a script in my &lt;code&gt;vimrc&lt;/code&gt; file that automatically adds a &lt;code&gt;;&lt;/code&gt; to the end of every line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only exceptions is if the line has the strings &lt;code&gt;for(&lt;/code&gt;, &lt;code&gt;while(&lt;/code&gt;, &lt;code&gt;#include&lt;/code&gt;, &lt;code&gt;//&lt;/code&gt;, &lt;code&gt;/*&lt;/code&gt;, &lt;code&gt;*/&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like this to be turned on by default and toggled on and off via the shortcut &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;;&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="205" LastEditDate="2015-03-03T21:07:21.033" LastActivityDate="2015-03-06T10:18:25.293" Title="How do I automatically add a character at end of line?" Tags="|text-generation|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="2348" PostTypeId="2" ParentId="2347" CreationDate="2015-03-03T19:30:10.117" Score="6" Body="&lt;p&gt;As has been stated, your list of exceptions is by no means comprehensive and you will probably find that this often creates more problems than it solves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it's still doable and it was kind of fun to write out the code to do so, so here goes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;When hitting Enter, if the line doesn't start with a /*, insert a semicolon&#xA;:inoremap &amp;lt;CR&amp;gt; &amp;lt;C-R&amp;gt;=match(getline('.'), '\s*/\*')==-1?';':''&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Feel free to expand this regex to capture your conditions above. I didn't want to write all of that out as I feel like it would obfuscate what I was writing and would still not be a complete solution for what your intent is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would probably want to only do this for certain filetypes, in which case you'd want to add the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; argument to this command and do it inside an &lt;code&gt;autocmd Filetype&lt;/code&gt; block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To disable the mapping, you would say &lt;code&gt;:iunmap &amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-03-03T19:30:10.117" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="2349" PostTypeId="2" ParentId="747" CreationDate="2015-03-03T20:17:35.550" Score="10" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I just discovered the &lt;a href=&quot;https://github.com/rbonvall/vim-textobj-latex&quot; rel=&quot;noreferrer&quot;&gt;vim-textobject-latex&lt;/a&gt; plugin, which adds the exact functionality you're looking for (in addition to a few other things). From the plugin's README: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently supported text objects are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a   i   Description&#xA;a\\ i\\ Inline math surrounded by ``\\(`` and ``\\)``.&#xA;a$  i$  Inline math surrounded by dollar signs.&#xA;aq  iq  Single-quoted text ``\`like this'``.&#xA;aQ  iQ  Double-quoted text ``\``like this''``.&#xA;ae  ie  Environment ``\begin{...}–\end{...}``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can use &lt;code&gt;caq&lt;/code&gt; and the like as you wanted. I tested it, and it works as advertised, but note that it is dependent on the &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;noreferrer&quot;&gt;vim-textobject-user&lt;/a&gt; plugin. Also note &lt;em&gt;you must make sure that the &lt;code&gt;textobject-user&lt;/code&gt; plugin loads first&lt;/em&gt;, otherwise things won't work.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you don't want to mess with plugins, however, my original answer remains useful:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding these two lines to your &lt;code&gt;.vimrc&lt;/code&gt; will cover &lt;em&gt;most&lt;/em&gt; of what you want.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap aq :&amp;lt;c-u&amp;gt;normal! F`vf'&amp;lt;cr&amp;gt;&#xA;onoremap iq :&amp;lt;c-u&amp;gt;normal! T`vt'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These create new text objects (&lt;code&gt;aq&lt;/code&gt; and &lt;code&gt;iq&lt;/code&gt;) which go back to the previous &lt;code&gt;`&lt;/code&gt;, enter visual selection mode, then select up to the next &lt;code&gt;'&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will work for &lt;code&gt;ciq&lt;/code&gt;, &lt;code&gt;caq&lt;/code&gt;, &lt;code&gt;yiq&lt;/code&gt;, and &lt;code&gt;diq&lt;/code&gt;. However, &lt;code&gt;yaq&lt;/code&gt; and &lt;code&gt;daq&lt;/code&gt; will not yank/delete the outer quotes, so I created another text object, &lt;code&gt;a&quot;&lt;/code&gt;, to handle that (&lt;code&gt;i&quot;&lt;/code&gt; is not needed, but I added to keep things consistent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap a&quot; :&amp;lt;c-u&amp;gt;normal! 2F`v2f'&amp;lt;cr&amp;gt;&#xA;onoremap i&quot; :&amp;lt;c-u&amp;gt;normal! 2T`v2t'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The major downside here is that this will break normal &lt;code&gt;ca&quot;&lt;/code&gt;, etc. use. If you preface them with &lt;code&gt;au FileType tex&lt;/code&gt;, you'll only have that issue in &lt;code&gt;.tex&lt;/code&gt; files, but it still might occasionally be an annoyance. You could also name the object something like &lt;code&gt;ad&lt;/code&gt;/&lt;code&gt;id&lt;/code&gt; ('d' for 'double' quote), but that seemed less intuitive to me (I was aiming for the least difference from normal operation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way I can think of to wrap these up into just two text objects would be to write a function that checks for another quote outside of the first set and set the &lt;code&gt;aq&lt;/code&gt; text objects to call that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: There are a couple other minor issues with these:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Yanking might leave your cursor in an unexpected place (this could be fixed by adding using a mark in the commands (e.g. &lt;code&gt;ma2F`v2f'&amp;lt;cr&amp;gt;`a&lt;/code&gt;), just make sure not to use one you frequently use manually)&lt;/li&gt;&#xA;&lt;li&gt;The cursor must be inside the quotes; weird things happen if it is on the quotes.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To wrap all of that up, this is what I personally would add to my &lt;code&gt;.vimrc&lt;/code&gt; for this issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetype_latex&#xA;    au!&#xA;    au FileType tex,plaintex onoremap a' :&amp;lt;c-u&amp;gt;normal! muF`vf'&amp;lt;cr&amp;gt;`u&#xA;    au FileType tex,plaintex onoremap i' :&amp;lt;c-u&amp;gt;normal! muT`vt'&amp;lt;cr&amp;gt;`u&#xA;    au FileType tex,plaintex onoremap a&quot; :&amp;lt;c-u&amp;gt;normal! mu2F`v2f'&amp;lt;cr&amp;gt;`u&#xA;    au FileType tex,plaintex onoremap i&quot; :&amp;lt;c-u&amp;gt;normal! mu2T`v2t'&amp;lt;cr&amp;gt;`u&#xA;end augroup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, I opted for breaking normal &lt;code&gt;ca'&lt;/code&gt;/&lt;code&gt;ya&quot;&lt;/code&gt;/etc functionality so I wouldn't have to learn new commands for them since I wouldn't be using the normal functionality as much within LaTeX anyways. That's just a personal preference; not hard to switch the object names. I also added in the filetype detection and marks.&lt;/p&gt;&#xA;" OwnerUserId="1166" LastEditorUserId="1166" LastEditDate="2015-03-03T22:09:44.310" LastActivityDate="2015-03-03T22:09:44.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2350" PostTypeId="1" AcceptedAnswerId="2363" CreationDate="2015-03-03T21:48:36.533" Score="85" ViewCount="92883" Body="&lt;p&gt;I'm trying to map &lt;kbd&gt;Alt&lt;/kbd&gt; key in the following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;A-j&amp;gt; j&#xA;:map &amp;lt;A-k&amp;gt; k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it doesn't work (bell is rang on &lt;kbd&gt;Alt + j&lt;/kbd&gt;/&lt;kbd&gt;Alt + k&lt;/kbd&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Terminal on OSX, the same happens on remote Linux.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On &lt;kbd&gt;Ctrl + v&lt;/kbd&gt;, &lt;kbd&gt;Alt + j&lt;/kbd&gt;, I've got: &lt;code&gt;?~H~F&lt;/code&gt; (&lt;code&gt;∆&lt;/code&gt; when &lt;code&gt;encoding=utf-8&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On &lt;kbd&gt;Ctrl + v&lt;/kbd&gt;, &lt;kbd&gt;Alt + k&lt;/kbd&gt;, I've got: &lt;code&gt;?~Z&lt;/code&gt; (&lt;code&gt;˚&lt;/code&gt; when &lt;code&gt;encoding=utf-8&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running vim without plugins (&lt;code&gt;-u NONE&lt;/code&gt;) doesn't make any difference.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="1067" LastEditDate="2020-04-24T14:35:51.430" LastActivityDate="2022-07-14T03:02:05.560" Title="How to map Alt key?" Tags="|key-bindings|terminal|" AnswerCount="8" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2351" PostTypeId="2" ParentId="2322" CreationDate="2015-03-03T21:50:05.110" Score="2" Body="&lt;p&gt;One of the simplest ways is save these commands to a file and &lt;code&gt;:source&lt;/code&gt; the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example, add the following to &lt;code&gt;foo.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1,1s/^\|\t/|!/g&#xA;1,1s/$/|/g&#xA;2,$s/^\|\t/|/g&#xA;2,$s/$/|/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can source the file via &lt;code&gt;:source foo.vim&lt;/code&gt; to run those commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find yourself using these commands often then you may want to create a command (possibly using a function)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :source&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-03-03T21:50:05.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2352" PostTypeId="2" ParentId="2322" CreationDate="2015-03-03T22:33:36.730" Score="1" Body="&lt;p&gt;One easy way to save any kind of action is to record it as a macro. These are stored in the named registers, &lt;code&gt;&quot;a&lt;/code&gt; to &lt;code&gt;&quot;z&lt;/code&gt;, and with the default &lt;code&gt;'viminfo'&lt;/code&gt; setting, these registers will be saved to the .viminfo file and thus persisted across Vim restarts. (See &lt;code&gt;:h 'viminfo'&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for example, the following series of keystrokes would store your first example substitution command in the &lt;code&gt;&quot;a&lt;/code&gt; register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa1,1s/^\|\t/|!/g&amp;lt;CR&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(where &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; designates a press of the &lt;kbd&gt;Return&lt;/kbd&gt; key.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then replay this macro by pressing &lt;code&gt;@a&lt;/code&gt; from Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could of course store your example entire sequence of substitutions in a single macro if they are always to be run in succession.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So long as your &lt;code&gt;'viminfo'&lt;/code&gt; is set up to save registers, then this macro will persist until you (or a poorly written script) overwrites this register, so although technically your commands could be saved forever, this method is better suited for storing things for a finite and reasonably short-lived period of time.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2015-03-03T22:33:36.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2353" PostTypeId="2" ParentId="2319" CreationDate="2015-03-03T23:38:03.677" Score="4" Body="&lt;p&gt;Here are some quick n' dirty mappings to accomplish the task:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap yY :%yank &amp;lt;c-r&amp;gt;=v:register&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;nnoremap dD :%delete &amp;lt;c-r&amp;gt;=v:register&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use &lt;code&gt;yY&lt;/code&gt; and &lt;code&gt;dD&lt;/code&gt; to yank/delete respectively. It's not as nice as using a full blown text object, but sometimes the simplest solutions are best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :y&#xA;:h :d&#xA;:h [range]&#xA;:h v:register&#xA;:h c_ctrl-r&#xA;:h @=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-03-03T23:38:03.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2355" PostTypeId="2" ParentId="2249" CreationDate="2015-03-04T06:15:13.213" Score="0" Body="&lt;p&gt;Thank you jamessa, Matt and Ingo. I followed Ingo's suggestion and, after digging a bit around Internet, wrote a small function to toggle the dictionaries I use (English and Spanish) and the tags file (actually &lt;code&gt;.tags&lt;/code&gt;). Now I can press F6 to switch from English to Spanish, and from Spanish to tags, and from tags to no dictionary. Now, on each setting, I can press  to trigger the dictionary completion, and it works great.&lt;/p&gt;&#xA;" OwnerUserId="1095" LastActivityDate="2015-03-04T06:15:13.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2356" PostTypeId="2" ParentId="2249" CreationDate="2015-03-04T06:20:35.410" Score="0" Body="&lt;p&gt;In case someone is interested, here is the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;====================================================================&#xA;&quot;  myspell.vim&#xA;&quot;  &#xA;&quot;  This fuction allows switching spellchecking in two languages, and&#xA;&quot;  to have a local spell file and/or a local tags file for each &#xA;&quot;  project. The local spell files is called 'local.utf-8.add' and the&#xA;&quot;  tags file is '.tags'.&#xA;&quot;  &#xA;&quot;  Using tags:&#xA;&quot;  &#xA;&quot;  The 'tags' file is a text file that lists one tag per line, organized&#xA;&quot;  alphabetically. A tag is a keyword preceded by the '@' sign. For&#xA;&quot;  instance @novel. This tag file is used to autocomplete tags in&#xA;&quot;  reference files. Autocomplete is triggered by C-X.&#xA;&quot;&#xA;&quot;  Note: To create a '.local.utf-8.add' file, open it in Vim, save it,&#xA;&quot;  and run: mkspell to generate the local spell file.&#xA;&quot;&#xA;&quot;  Note: To create a 'tags' file, go to the root folder of a given&#xA;&quot;  project and issue ':maketags.sh'. This will create a 'tags' file.&#xA;&quot;  Make sure that the '.local.vimrc' in the root file for the project&#xA;&quot;  includes the line 'let g:localroot=&amp;lt;project's root&amp;gt;'&#xA;&quot;&#xA;&quot;  Inspired by:&#xA;&quot;  http://vim.wikia.com/wiki/Toggle_spellcheck_with_function_keys&#xA;&quot;====================================================================&#xA;if exists(&quot;loaded_myspell&quot;)&#xA;    finish&#xA;endif&#xA;let loaded_myspell = 1&#xA;&#xA;let g:myLangList  = [ &quot;nospell&quot;,     &quot;en_us&quot;,      &quot;es&quot;,      &quot;&quot;     ]&#xA;let g:myLangName  = [ &quot;No spelling&quot;, &quot;US English&quot;, &quot;Spanish&quot;, &quot;Tags&quot; ]&#xA;let g:myLangShort = [ &quot;&quot;, &quot;EN&quot;, &quot;SP&quot;, &quot;T&quot; ]&#xA;&#xA;&#xA;function! MySpellLang()&#xA;    &quot; Check if 'g:myLang' exists for the buffer in question, and if it&#xA;    &quot; doesn't check if spell is set and adjust 'g:myLang' accordingly.&#xA;    if !exists( &quot;g:myLang&quot;)&#xA;        if &amp;amp;spell&#xA;            let g:myLang=index(g:myLangList, &amp;amp;spelllang)&#xA;        else&#xA;            let g:myLang = 0&#xA;        endif&#xA;    endif&#xA;    &quot; Spellfile&#xA;    &quot; g:localroot can be configured in '.local.vimrc' at the root&#xA;    &quot; level of any project. This configuration is read by the plugin&#xA;    &quot; 'vim-localrc' (which also reads any other configuration settings).&#xA;    if !exists(&quot;g:localroot&quot;)&#xA;        let g:localroot=expand('%:p:h')&#xA;    endif&#xA;    let g:localspell=fnameescape(g:localroot).'/.local.utf-8.add'&#xA;    &quot; Loop through languages&#xA;    let g:myLang += 1&#xA;    if  g:myLang &amp;gt;= len(g:myLangList) | let g:myLang = 0 | endif&#xA;    if  g:myLang == 0&#xA;        set nospell&#xA;        set spellfile=&#xA;        set dictionary=&#xA;    elseif g:myLang == 1&#xA;        set spell spelllang=en_us&#xA;        &quot; 'set' needst to be use for '~' to be resolved here&#xA;        set spellfile=~/.vim/spell/en.utf-8.add&#xA;        set dictionary=&#xA;    elseif g:myLang == 2&#xA;        set spell spelllang=es&#xA;        set spellfile=~/.vim/spell/es.utf-8.add&#xA;        set dictionary=&#xA;    elseif g:myLang == 3&#xA;        set nospell spellfile=&#xA;        let b:localtag=fnameescape(g:localroot).'/.tags'&#xA;        if !filereadable(b:localtag) &#xA;            &quot; Save current directory, removing new-line and escaping spaces&#xA;            let b:savedir = fnameescape(substitute(system('pwd'),'\n','','g'))&#xA;            &quot; Go to the local root &#xA;            :execute &quot;cd &quot;.fnameescape(g:localroot)&#xA;            &quot; Call the tag maker script&#xA;            :execute &quot;silent !maketags.sh &quot;.b:localtag&#xA;            &quot; Change directory back&#xA;            :execute &quot;cd &quot;.b:savedir&#xA;        endif &#xA;        exec &quot;:set dictionary+=&quot;.b:localtag&#xA;    endif&#xA;    if g:myLang&amp;gt;0 &amp;amp;&amp;amp; g:myLang&amp;lt;3 &amp;amp;&amp;amp; filereadable(g:localspell) &#xA;        exec &quot;set spellfile+=&quot;.g:localspell&#xA;    endif &#xA;    echo &quot;language: &quot; g:myLangName[g:myLang]&#xA;endf&#xA;&#xA;map &amp;lt;F6&amp;gt; :call MySpellLang()&amp;lt;CR&amp;gt;&#xA;imap &amp;lt;F6&amp;gt; &amp;lt;C-o&amp;gt;:call MySpellLang()&amp;lt;CR&amp;gt;&#xA;&quot;================================================================ EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1095" LastActivityDate="2015-03-04T06:20:35.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2357" PostTypeId="2" ParentId="2249" CreationDate="2015-03-04T06:22:35.563" Score="0" Body="&lt;p&gt;And this is the shell script that creates the &lt;code&gt;.tags&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#! /bin/bash&#xA;# maketags&#xA;# This program generates tags for all of the md files in and under the&#xA;# folder from which it is called as long as the tags are of the form &#xA;# '@tag' and separated by spaces. If an arument is give, it is used&#xA;# as the name of the tag file.&#xA;&#xA;if [ -z &quot;$1&quot; ]&#xA;then&#xA;    TAGFILE=&quot;.tags&quot;&#xA;else&#xA;    TAGFILE=&quot;$1&quot;&#xA;fi&#xA;&#xA;touch temp.text&#xA;&#xA;find &quot;$PWD&quot; -name '*.md' -type f -exec awk '{&#xA;        if (index($0,&quot;@&quot;) &amp;gt; 0) {&#xA;            line = $0&#xA;            do { &#xA;                tag  = &quot;&quot;&#xA;                iB   = index(line,&quot;@&quot;)&#xA;                if ( iB &amp;gt; 0 ) {&#xA;                    line = substr(line,iB)&#xA;                    iE   = index(line,&quot; &quot;)&#xA;                    if (iE == 0) iE = length(line) + 1&#xA;                    tag  = substr(line,1,iE-1)&#xA;                    line = substr(line,2)&#xA;                    printf(&quot;%s\n&quot;, tag) &amp;gt;&amp;gt; &quot;temp.text&quot;&#xA;                }&#xA;            } while ( tag != &quot;&quot;)&#xA;        }&#xA;     }' &quot;{}&quot; \;&#xA;&#xA;sort temp.text &amp;gt; tags.txt&#xA;rm temp.text&#xA;uniq tags.txt &amp;gt; &quot;$TAGFILE&quot;&#xA;rm tags.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1095" LastActivityDate="2015-03-04T06:22:35.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2358" PostTypeId="1" AcceptedAnswerId="2360" CreationDate="2015-03-04T10:43:46.333" Score="14" ViewCount="3012" Body="&lt;p&gt;Can I integrate some form of symbol completion to Vim? Dedicated TeX editors like TeXMaker provide a list of symbols for completion (for example, &lt;code&gt;\al&lt;/code&gt; shows a list with &lt;code&gt;\alpha&lt;/code&gt;, &lt;code&gt;\la&lt;/code&gt; shows &lt;code&gt;\lambda&lt;/code&gt; and &lt;code&gt;\langle&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that TeX has a rather large number of symbols, so suggestions involving manual mapping of &lt;code&gt;\al&lt;/code&gt; to &lt;code&gt;\alpha&lt;/code&gt; would be useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related plugins I have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ervandew/supertab&quot; rel=&quot;nofollow noreferrer&quot;&gt;SuperTab&lt;/a&gt; with &lt;code&gt;let g:SuperTabDefaultCompletionType=&quot;context&quot;&lt;/code&gt; and&#xA;&lt;code&gt;set omnifunc=syntaxcomplete#Complete&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/LaTeX-Box-Team/LaTeX-Box&quot; rel=&quot;nofollow noreferrer&quot;&gt;LaTeX-Box&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If it matters, I use XeLaTeX for compiling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://tex.stackexchange.com/questions/14/how-to-look-up-a-symbol-or-identify-a-math-symbol-or-character&quot;&gt;How to look up a symbol or identify a math symbol or character?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:34:32.317" LastActivityDate="2015-03-04T19:40:11.307" Title="How can I lookup LaTeX symbols in Vim?" Tags="|autocompletion|filetype-tex|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2359" PostTypeId="2" ParentId="2358" CreationDate="2015-03-04T11:38:15.553" Score="1" Body="&lt;p&gt;You could use a snippet completion plugin like &lt;a href=&quot;https://github.com/garbas/vim-snipmate&quot; rel=&quot;nofollow&quot;&gt;Snipmate&lt;/a&gt; or &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow&quot;&gt;Ultisnips&lt;/a&gt;, in conjunction with &lt;a href=&quot;https://github.com/honza/vim-snippets&quot; rel=&quot;nofollow&quot;&gt;this multi-language snippets collection&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-03-04T11:38:15.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2360" PostTypeId="2" ParentId="2358" CreationDate="2015-03-04T11:39:28.093" Score="11" Body="&lt;p&gt;To expand commands in LaTeX, I use a dictionary copied from &lt;a href=&quot;https://github.com/gerw/vim-latex-suite&quot; rel=&quot;nofollow noreferrer&quot;&gt;latex-suite&lt;/a&gt; (in details, &lt;a href=&quot;https://github.com/gerw/vim-latex-suite/blob/master/ftplugin/latex-suite/dictionaries/dictionary&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;) and put it in &lt;code&gt;~/.vim/dictionaries&lt;/code&gt; and then using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType * exec(&quot;setlocal dictionary+=&quot;.$HOME.&quot;/.vim/dictionaries/&quot;.expand('&amp;lt;amatch&amp;gt;'))&#xA;set completeopt=menuone,longest,preview&#xA;set complete+=k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Idea from &lt;a href=&quot;https://stackoverflow.com/questions/3723493/latex-and-vim-usage&quot;&gt;here&lt;/a&gt;. I use it with supertab; the dictionary file is not really complete (it has &lt;code&gt;\alpha&lt;/code&gt; but not &lt;code&gt;\langle&lt;/code&gt;) but that would be a matter of completing it...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One option for adding symbols would be to parse (not complex --- just a bit of shell magic will do it) the &lt;a href=&quot;https://raw.githubusercontent.com/kirel/detexify/master/lib/latex/symbols.yaml&quot; rel=&quot;nofollow noreferrer&quot;&gt;detexify database&lt;/a&gt;. For example, one could use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ curl -sL https://raw.githubusercontent.com/kirel/detexify/master/lib/latex/symbols.yaml |&#xA;   grep -Po '(?&amp;lt;=\\)[[:alpha:]]{2,}';&#xA;   curl -sL https://raw.githubusercontent.com/gerw/vim-latex-suite/master/ftplugin/latex-suite/dictionaries/dictionary&#xA;} | sort -u | tee ~/.vim/dictionaries/tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="854" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-03-04T19:40:11.307" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2361" PostTypeId="2" ParentId="2350" CreationDate="2015-03-04T11:45:08.740" Score="21" Body="&lt;p&gt;With help of &lt;a href=&quot;https://vi.stackexchange.com/questions/2350/how-to-map-alt-key#comment2107_2350&quot;&gt;Carpetsmoker&lt;/a&gt;, it seems that Terminal wasn't configured to 'Use Alt/option as meta key' (this is especially common for GUI Terminals).&lt;/p&gt;&#xA;&lt;p&gt;For Terminal on OSX, it's in &lt;em&gt;Preferences -&amp;gt; Settings -&amp;gt; Keyboard tab -&amp;gt; 'Use option as meta key'&lt;/em&gt;. Check: &lt;a href=&quot;https://apple.stackexchange.com/questions/54777/how-can-i-change-terminal-so-that-i-dont-have-to-press-esc-every-time-i-want-to&quot;&gt;How can I change Terminal to use option as meta key?&lt;/a&gt; (&lt;a href=&quot;https://apple.stackexchange.com/questions/146485/can-you-enable-the-meta-key-in-mavericks&quot;&gt;Mavericks&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;For XTerm, check: &lt;a href=&quot;http://frequal.com/linux/XTermMetaSendsEscape.html&quot; rel=&quot;noreferrer&quot;&gt;Configuring XTerm to Default to Meta Sends Escape&lt;/a&gt; which says:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Add this line anywhere in your personal .Xdefaults file (&lt;code&gt;~/.Xdefaults&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xterm*metaSendsEscape: true&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then reload the config with xrdb. Without this step the changes in &lt;code&gt;.Xdefaults&lt;/code&gt; won't take effect until the next X restart:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xrdb -l ~/.Xdefaults&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Then standard mappings with &lt;kbd&gt;Alt&lt;/kbd&gt; key like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;A-j&amp;gt; j&#xA;:map &amp;lt;A-k&amp;gt; k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;works fine.&lt;/p&gt;&#xA;&lt;p&gt;For help, see: &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap-alt-keys&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :map-alt-keys&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-03-04T22:05:07.427" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2363" PostTypeId="2" ParentId="2350" CreationDate="2015-03-04T18:25:14.970" Score="93" Body="&lt;p&gt;That's how I do it on Linux or Cygwin:&lt;/p&gt;&#xA;&lt;p&gt;First check what chars are sent by your terminal when you press &lt;kbd&gt;ALT&lt;/kbd&gt;+&lt;kbd&gt;J&lt;/kbd&gt;:&lt;/p&gt;&#xA;&lt;p&gt;In order to do this I go to console and run &lt;code&gt;sed -n l&lt;/code&gt; (you can also use &lt;code&gt;cat&lt;/code&gt; for it). Then I press &lt;kbd&gt;ALT&lt;/kbd&gt;+&lt;kbd&gt;J&lt;/kbd&gt; and see that the chars on the screen are &lt;code&gt;^[j&lt;/code&gt; .&lt;/p&gt;&#xA;&lt;p&gt;I replace &lt;code&gt;^[&lt;/code&gt; with &lt;code&gt;\e&lt;/code&gt; (because that's what is sent by my terminal when I press &lt;kbd&gt;esc&lt;/kbd&gt;) and the final string for me is &lt;code&gt;\ej&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then I write it to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;execute &amp;quot;set &amp;lt;M-j&amp;gt;=\ej&amp;quot;&#xA;nnoremap &amp;lt;M-j&amp;gt; j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And the mapping works.&lt;/p&gt;&#xA;" OwnerUserId="1067" LastEditorUserId="1238" LastEditDate="2021-03-11T21:33:36.660" LastActivityDate="2021-03-11T21:33:36.660" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="2364" PostTypeId="2" ParentId="2283" CreationDate="2015-03-04T19:34:30.243" Score="1" Body="&lt;p&gt;You can quickly check if your regexp search pattern works by using &lt;a href=&quot;https://github.com/haya14busa/incsearch.vim&quot; rel=&quot;nofollow&quot;&gt;IncSearch.vim&lt;/a&gt; plugin. It incrementally highlights ALL pattern matches as you type it.&lt;/p&gt;&#xA;" OwnerUserId="1067" LastActivityDate="2015-03-04T19:34:30.243" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2365" PostTypeId="1" AcceptedAnswerId="2366" CreationDate="2015-03-04T19:44:36.033" Score="25" ViewCount="2017" Body="&lt;p&gt;Vim has (at least) two sets of commands that search in opposite directions. Typing &lt;code&gt;/&lt;/code&gt; and then a pattern will search forward through the document for the pattern; typing &lt;code&gt;?&lt;/code&gt; and then a pattern will search backward. The same relationship exists between the &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I don’t like is that these commands also set the search direction for the &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; commands. After using &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;n&lt;/code&gt; goes forward through the document and &lt;code&gt;N&lt;/code&gt; goes backward; after using &lt;code&gt;?&lt;/code&gt;, &lt;code&gt;n&lt;/code&gt; goes backward and &lt;code&gt;N&lt;/code&gt; goes forward. (In other words, &lt;code&gt;n&lt;/code&gt; always goes in the same direction as the original search and &lt;code&gt;N&lt;/code&gt; always goes in the other direction.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get &lt;code&gt;n&lt;/code&gt; to go forward through the document, and &lt;code&gt;N&lt;/code&gt; to go backward, regardless of which direction I started searching in?&lt;/p&gt;&#xA;" OwnerUserId="671" LastEditorUserId="51" LastEditDate="2015-03-04T20:08:44.063" LastActivityDate="2018-05-26T18:52:38.973" Title="How can I get ‘n’ to go forward even if I started searching with ‘?’ or ‘#’?" Tags="|cursor-movement|key-bindings|search|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2366" PostTypeId="2" ParentId="2365" CreationDate="2015-03-04T19:51:49.153" Score="39" Body="&lt;p&gt;You can change the behaviour of &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; to search consistently downwards/upwards by useing the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; n 'Nn'[v:searchforward]&#xA;nnoremap &amp;lt;expr&amp;gt; N 'nN'[v:searchforward]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; How does it work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This uses expression-maps, which maps the lhs of the map to an expression that will be evaluated, everytime the lhs is encountered. See &lt;code&gt;:h map-expression&lt;/code&gt; in the help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens is, that the v:searchforward variable (which determines the internal state of which direction the last search was, see &lt;code&gt;:h v:searchforward&lt;/code&gt;) is used as an index for the string in front of it. So in case of the first map, if the last search direction was forward, the n will be mapped to 'n' (index of 1, meaning return the second character) and if it was backward, the 'n' will be mapped to 'N' (because the v:searchforward variable is 0 and therefore the 'N' will be returned. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative way to write those maps would be (which might be clearer):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; n (v:searchforward ? 'n' : 'N')&#xA;nnoremap &amp;lt;expr&amp;gt; N (v:searchforward ? 'N' : 'n')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are also some plugins, that do that (ie the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4949&quot;&gt;SearchRepeat plugin&lt;/a&gt; and possibly others as well).&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-03-05T06:59:51.273" LastActivityDate="2015-03-05T06:59:51.273" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="2367" PostTypeId="1" AcceptedAnswerId="2368" CreationDate="2015-03-04T20:23:15.100" Score="42" ViewCount="28411" Body="&lt;p&gt;Right now I'm working with some blocks of text that are over 1000 lines long. Is there a simple way to move to the beginning of the next paragraph? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My workaround for now is searching for two consecutive newline characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\n\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another workaround would be &lt;code&gt;vip&lt;/code&gt; &lt;kbd&gt;Esc&lt;/kbd&gt; &lt;code&gt;j&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;vip&lt;/code&gt; &lt;strong&gt;v&lt;/strong&gt;isually select &lt;strong&gt;i&lt;/strong&gt;n &lt;strong&gt;p&lt;/strong&gt;aragraph (which also takes you to the end of the paragraph)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; Escape from visual selection&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;j&lt;/code&gt; move down &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1111" LastEditorUserId="1111" LastEditDate="2015-03-04T20:31:39.923" LastActivityDate="2018-05-21T00:43:16.183" Title="How can I jump to the next &quot;paragraph&quot;?" Tags="|cursor-movement|cursor-motions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2368" PostTypeId="2" ParentId="2367" CreationDate="2015-03-04T20:31:23.797" Score="60" Body="&lt;p&gt;Yes, you can use the &lt;kbd&gt;}&lt;/kbd&gt; and &lt;kbd&gt;{&lt;/kbd&gt; paragraph motions to move a paragraph forwards or backwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#paragraph&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help paragraph&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A paragraph begins after each empty line, and also at each of a set of&#xA;  paragraph macros, specified by the pairs of characters in the &lt;code&gt;'paragraphs'&lt;/code&gt;&#xA;  option.  The default is &lt;code&gt;IPLPPPQPP TPHPLIPpLpItpplpipbp&lt;/code&gt;, which corresponds to&#xA;  the macros &lt;code&gt;.IP&lt;/code&gt;, &lt;code&gt;.LP&lt;/code&gt;, etc.  (These are &lt;code&gt;nroff&lt;/code&gt; macros, so the dot must be in&#xA;  the first column).  A section boundary is also a paragraph boundary.&#xA;  Note that a blank line (only containing white space) is NOT a paragraph&#xA;  boundary.&lt;br&gt;&#xA;  Also note that this does not include a &lt;code&gt;'{'&lt;/code&gt; or &lt;code&gt;'}'&lt;/code&gt; in the first column.  When&#xA;  the &lt;code&gt;'{'&lt;/code&gt; flag is in &lt;code&gt;'cpoptions'&lt;/code&gt; then &lt;code&gt;'{'&lt;/code&gt; in the first column is used as a&#xA;  paragraph boundary posix.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Like you would expect, you can of course add a count and/or operator; eg. &lt;kbd&gt;2}&lt;/kbd&gt; to move 2 paragraps fowards. Or to delete the previous 2 paragraphs you can use &lt;kbd&gt;3d{&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#object-motions&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help object-motions&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="2587" LastEditDate="2018-05-21T00:43:16.183" LastActivityDate="2018-05-21T00:43:16.183" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2369" PostTypeId="2" ParentId="2340" CreationDate="2015-03-04T20:53:02.043" Score="3" Body="&lt;p&gt;There's nothing built-in, but the following mapping seems to do the trick.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; g9                Print the hex values of the bytes used in the&#xA;&quot;                   character under the cursor / selected text, using the&#xA;&quot;                   actual 'fileencoding' of the buffer.&#xA;function! s:ShowHexFileEncodingCharacter( isSelection )&#xA;    let l:text = (a:isSelection ? ingo#selection#Get() : ingo#text#GetChar(getpos('.')[1:2]))&#xA;    if empty(l:text)&#xA;        echomsg 'NUL'&#xA;        return&#xA;    endif&#xA;&#xA;    let l:encoding = (empty(&amp;amp;l:fileencoding) ? &amp;amp;encoding : &amp;amp;l:fileencoding)&#xA;    let l:output = ingo#buffer#temp#Call(function('GetHexFileEncodingCharacters'), [l:encoding, l:text])&#xA;    let l:hex = substitute(l:output, '0a\%(00\)*$\|\%(00\)\+0a$', '', '') &quot; Remove the encoding of the trailing LF.&#xA;    echomsg substitute(l:hex, '..\zs', ' ', 'g')&#xA;endfunction&#xA;function! GetHexFileEncodingCharacters( fileencoding, text )&#xA;    let [l:save_fileencoding, l:save_fileformat] = [&amp;amp;l:fileencoding, &amp;amp;l:fileformat]&#xA;    let [&amp;amp;l:fileencoding, &amp;amp;l:fileformat] = [a:fileencoding, 'unix'] &quot; Always use Unix fileformat to make the removal of the newline easier.&#xA;    try&#xA;        silent call ingo#lines#PutWrapper(1, 'put', a:text)&#xA;        silent 1delete _&#xA;        %!xxd -ps -c 999&#xA;    finally&#xA;        let [&amp;amp;l:fileencoding, &amp;amp;l:fileformat] = [l:save_fileencoding, l:save_fileformat]&#xA;    endtry&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; g9 :&amp;lt;C-u&amp;gt;call &amp;lt;SID&amp;gt;ShowHexFileEncodingCharacter(0)&amp;lt;CR&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; g9 :&amp;lt;C-u&amp;gt;call &amp;lt;SID&amp;gt;ShowHexFileEncodingCharacter(1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses the &lt;code&gt;:!&lt;/code&gt; command to filter the character through the external &lt;code&gt;xxd&lt;/code&gt; command (which ships with Vim and performs a hex dump). This uses some functions of my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4433&quot; rel=&quot;nofollow&quot;&gt;ingo-library plugin&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2015-03-05T08:30:28.147" LastActivityDate="2015-03-05T08:30:28.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2370" PostTypeId="1" CreationDate="2015-03-04T21:06:28.050" Score="9" ViewCount="6668" Body="&lt;p&gt;With &lt;a href=&quot;https://github.com/vim-scripts/vimwiki&quot; rel=&quot;noreferrer&quot;&gt;vimwiki&lt;/a&gt; you can fold headers and lists as following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example for headers and list folding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;= My current task =&#xA;  * [ ] Do stuff 1&#xA;    * [ ] Do substuff 1.1&#xA;    * [ ] Do substuff 1.2&#xA;      * [ ] Do substuff 1.2.1&#xA;      * [ ] Do substuff 1.2.2&#xA;    * [ ] Do substuff 1.3&#xA;  * [ ] Do stuff 2&#xA;  * [ ] Do stuff 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hit &lt;kbd&gt;zM&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;= My current task = [8] --------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hit &lt;kbd&gt;zr&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;= My current task =&#xA;  * [ ] Do stuff 1 [5] --------------------------------------&#xA;  * [ ] Do stuff 2&#xA;  * [ ] Do stuff 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hit &lt;kbd&gt;zr&lt;/kbd&gt; one more time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;= My current task =&#xA;  * [ ] Do stuff 1&#xA;    * [ ] Do substuff 1.1&#xA;    * [ ] Do substuff 1.2 [2] -------------------------------&#xA;  * [ ] Do substuff 1.3&#xA;  * [ ] Do stuff 2&#xA;  * [ ] Do stuff 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The header-folding (&lt;code&gt;= Header =&lt;/code&gt;) does works for me, but list-folding (&lt;code&gt;* [ ] list&lt;/code&gt;) doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vimwiki says this about list-folding, but I don't understand what it exaclty means:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;NOTE: If you use the default vimwiki syntax, folding on list items will work&#xA;  properly only if all of them are indented using current shiftwidth.&#xA;  For MediaWiki, &lt;code&gt;*&lt;/code&gt; or &lt;code&gt;#&lt;/code&gt; should be in the first column.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My vimrc is as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call vundle#begin()&#xA;Plugin 'vimwiki'&#xA;call vundle#end()&#xA;&#xA;set nocompatible&#xA;filetype plugin on&#xA;syntax on&#xA;set foldmethod=syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1214" LastEditorUserId="51" LastEditDate="2015-03-05T13:14:20.517" LastActivityDate="2015-03-07T01:44:20.933" Title="Vimwiki: can't fold list items" Tags="|folding|plugin-vimwiki|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2371" PostTypeId="1" CreationDate="2015-03-05T00:05:52.880" Score="4" ViewCount="592" Body="&lt;p&gt;I'm using gVim on my Windows 8.1 computer with a standard QWERTY keyboard, and neither the &lt;kbd&gt;j&lt;/kbd&gt; and &lt;kbd&gt;k&lt;/kbd&gt; keys, nor the &lt;kbd&gt;Up&lt;/kbd&gt; and &lt;kbd&gt;Down&lt;/kbd&gt; arrow keys let me move up and down in my text field while in normal mode. &lt;kbd&gt;h&lt;/kbd&gt; and &lt;kbd&gt;l&lt;/kbd&gt; for left/right work fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behaviour of up and down is somewhat sporadic. Sometimes it doesn't work at all. Other times, like right now, it jumps from the top of the file to the bottom of the file. The cursor never jumps higher than the last position it was at when going up, and it always goes to the bottom left when going down. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used &lt;code&gt;map&lt;/code&gt; to check for custom mappings, which said 'no mapping found'. I also tried starting without a vimrc file, and that didn't fix it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I find out why and fix it?&lt;/p&gt;&#xA;" OwnerUserId="1220" LastEditorUserId="51" LastEditDate="2015-03-05T09:49:38.840" LastActivityDate="2015-03-05T09:49:38.840" Title="j and k keys not working like they should" Tags="|cursor-movement|key-bindings|microsoft-windows|" AnswerCount="0" CommentCount="10" ClosedDate="2015-03-13T03:46:13.003" ContentLicense="CC BY-SA 3.0" />
  <row Id="2372" PostTypeId="2" ParentId="2370" CreationDate="2015-03-05T05:36:58.747" Score="10" Body="&lt;h2&gt;Folding lists in VimWiki&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;According to the documentation in vimwiki version 2.1 (the latest I found), there are a few fold methods, and of them only one works for folding list items.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The setting is in the variable &lt;code&gt;g:vimwiki_folding&lt;/code&gt;. from &lt;code&gt;:help g:vimwiki_folding&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Enable/disable vimwiki's folding (outline) functionality. Folding in vimwiki&#xA;  can uses either the 'expr' or the 'syntax' foldmethod of Vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Value           Description  &#xA;''              Disable folding.  &#xA;'expr'          Folding based on expression (folds sections and code blocks).  &#xA;'syntax'        Folding based on syntax (folds sections; slower than 'expr').  &#xA;'list'          Folding based on expression (folds list subitems; much slower).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Default: &lt;code&gt;''&lt;/code&gt;   &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since your vimrc is setting &lt;code&gt;foldmethod=syntax&lt;/code&gt; explicitly, and you don't mention setting &lt;code&gt;g:vimwiki_folding&lt;/code&gt;, my guess is that you are getting the syntax setting, which only supports sections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vimwiki_folding='list'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your vimrc and it should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also run that command and then reopen the file (e.g. with ':e') and observe the folding work.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Shift Width&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You also asked about shift width indentation. In Vim, the &lt;code&gt;shiftwidth&lt;/code&gt; is used in auto-indentation and shift commands (e.g. &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;). The default is 8 and is equal to the &lt;code&gt;tabstop&lt;/code&gt;. If you don't mess with those settings, you'll be fine with your indented lists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do change them but don't have them equal, you'll still be okay as long as your list is indented with either &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt;, or the VimWiki specific &lt;code&gt;glm&lt;/code&gt; and &lt;code&gt;gll&lt;/code&gt; commands, which both use the &lt;code&gt;shiftwidth&lt;/code&gt; setting and thus would be compatible with the folding.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="205" LastEditDate="2015-03-05T10:41:12.313" LastActivityDate="2015-03-05T10:41:12.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2373" PostTypeId="2" ParentId="2319" CreationDate="2015-03-05T09:44:14.950" Score="17" Body="&lt;p&gt;Another solution is to use a plugin called &lt;a href=&quot;https://github.com/kana/vim-textobj-entire&quot;&gt;vim-textobj-entire&lt;/a&gt;. By default, this plugin provides the text object &lt;code&gt;ae&lt;/code&gt; for the entire buffer, &lt;code&gt;ie&lt;/code&gt; for the entire buffer except leading and trailing empty lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin depends on &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot;&gt;vim-textobj-user&lt;/a&gt; by the same author, which lets users define any text objects comfortably. There are &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot;&gt;many plugins&lt;/a&gt; that make good use of this.&lt;/p&gt;&#xA;" OwnerUserId="466" LastActivityDate="2015-03-05T09:44:14.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2374" PostTypeId="1" AcceptedAnswerId="2375" CreationDate="2015-03-05T10:47:40.883" Score="2" ViewCount="1049" Body="&lt;p&gt;I have just tried to install c.vim from this &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=213&quot; rel=&quot;nofollow&quot;&gt;URL&lt;/a&gt;. The only issue is I do not think it is working. This is because I cannot view the help by doing &lt;code&gt;:help csupport&lt;/code&gt;. How would I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it helps here is my &lt;code&gt;.vim&lt;/code&gt; tree.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.vim&#xA;├── c-support&#xA;│   ├── codesnippets&#xA;│   │   ├── Makefile&#xA;│   │   ├── Makefile.multi-target.template&#xA;│   │   ├── calloc_double_matrix.c&#xA;│   │   ├── calloc_int_matrix.c&#xA;│   │   ├── main.c&#xA;│   │   ├── main.cc&#xA;│   │   ├── print_double_array.c.noindent&#xA;│   │   └── print_int_array.c.noindent&#xA;│   ├── doc&#xA;│   │   ├── ChangeLog&#xA;│   │   ├── c-hotkeys.pdf&#xA;│   │   └── c-hotkeys.tex&#xA;│   ├── rc&#xA;│   │   ├── customization.ctags&#xA;│   │   ├── customization.gvimrc&#xA;│   │   ├── customization.indent.pro&#xA;│   │   └── customization.vimrc&#xA;│   ├── scripts&#xA;│   │   └── wrapper.sh&#xA;│   ├── templates&#xA;│   │   ├── Templates&#xA;│   │   ├── c.comments.template&#xA;│   │   ├── c.cpp.template&#xA;│   │   ├── c.idioms.template&#xA;│   │   ├── c.preprocessor.template&#xA;│   │   ├── c.statements.template&#xA;│   │   ├── cpp.comments.template&#xA;│   │   ├── cpp.cpp.template&#xA;│   │   ├── cpp.idioms.template&#xA;│   │   ├── cpp.preprocessor.template&#xA;│   │   └── cpp.statements.template&#xA;│   └── wordlists&#xA;│       ├── c-c++-keywords.list&#xA;│       ├── k+r.list&#xA;│       └── stl_index.list&#xA;├── doc&#xA;│   └── csupport.txt&#xA;├── ftplugin&#xA;│   └── c.vim&#xA;└── plugin&#xA;    ├── c.vim&#xA;    └── cvim&#xA;        ├── README.csupport&#xA;        ├── c-support&#xA;        │   ├── codesnippets&#xA;        │   │   ├── Makefile&#xA;        │   │   ├── Makefile.multi-target.template&#xA;        │   │   ├── calloc_double_matrix.c&#xA;        │   │   ├── calloc_int_matrix.c&#xA;        │   │   ├── main.c&#xA;        │   │   ├── main.cc&#xA;        │   │   ├── print_double_array.c.noindent&#xA;        │   │   └── print_int_array.c.noindent&#xA;        │   ├── doc&#xA;        │   │   ├── ChangeLog&#xA;        │   │   ├── c-hotkeys.pdf&#xA;        │   │   └── c-hotkeys.tex&#xA;        │   ├── rc&#xA;        │   │   ├── customization.ctags&#xA;        │   │   ├── customization.gvimrc&#xA;        │   │   ├── customization.indent.pro&#xA;        │   │   └── customization.vimrc&#xA;        │   ├── scripts&#xA;        │   │   └── wrapper.sh&#xA;        │   ├── templates&#xA;        │   │   ├── Templates&#xA;        │   │   ├── c.comments.template&#xA;        │   │   ├── c.cpp.template&#xA;        │   │   ├── c.idioms.template&#xA;        │   │   ├── c.preprocessor.template&#xA;        │   │   ├── c.statements.template&#xA;        │   │   ├── cpp.comments.template&#xA;        │   │   ├── cpp.cpp.template&#xA;        │   │   ├── cpp.idioms.template&#xA;        │   │   ├── cpp.preprocessor.template&#xA;        │   │   └── cpp.statements.template&#xA;        │   └── wordlists&#xA;        │       ├── c-c++-keywords.list&#xA;        │       ├── k+r.list&#xA;        │       └── stl_index.list&#xA;        ├── doc&#xA;        │   └── csupport.txt&#xA;        ├── ftplugin&#xA;        │   └── c.vim&#xA;        └── plugin&#xA;            └── c.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also if you need to know this is using vim inside the Mac terminal&lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="51" LastEditDate="2015-03-05T11:16:25.630" LastActivityDate="2015-03-05T12:03:00.787" Title="Why is the c.vim plugin not working?" Tags="|plugin-c.vim|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2375" PostTypeId="2" ParentId="2374" CreationDate="2015-03-05T12:03:00.787" Score="4" Body="&lt;p&gt;The old way to install plugins is directly within &lt;code&gt;~/.vim/&lt;/code&gt;, and the doc database was to be updated with &lt;code&gt;:helptags ~/.vim/doc&lt;/code&gt;. Now, with plugin managers around, we tend to install them into &lt;code&gt;~/.vim/addons/&lt;/code&gt; or &lt;code&gt;~/.vim/bundle/&lt;/code&gt; (depending on the plugin manager used).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it seems you've chosen another place to install your plugin. So, to use it, in your .vimrc, you'll have to fix your runtimepath -&gt; &lt;code&gt;:set rtp+=~/.vim/c-support&lt;/code&gt;, and you may have to update the doc database as well: &lt;code&gt;:helptags ~/.vim/c-support/doc&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2015-03-05T12:03:00.787" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2376" PostTypeId="1" CreationDate="2015-03-05T12:41:44.420" Score="13" ViewCount="2406" Body="&lt;p&gt;At some point my Vim would undo an entire word when I hit &lt;code&gt;u&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;[i]typing some words[C-c][u]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would result in&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;typing some&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the undo granularity seems to have changed to deleting one letter at a time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;[i]typing some words[C-c][u]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Results in&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;typing some word&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I remember reading something about customising undo granularity in Practical Vim, but I can't remember how to control it. Any help appreciated!&lt;/p&gt;&#xA;" OwnerUserId="124" LastActivityDate="2015-03-05T18:45:29.213" Title="How to change undo granularity in Vim?" Tags="|undo-redo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2377" PostTypeId="2" ParentId="2376" CreationDate="2015-03-05T15:35:55.663" Score="13" Body="&lt;h2&gt;Manually breaking the undo sequence&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can manually break the undo sequence in Insert mode with &lt;code&gt;&amp;lt;C-G&amp;gt;u&lt;/code&gt;. From &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-G_u&quot;&gt;the help&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-G u        break undo sequence, start new change&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iHello&amp;lt;C-G&amp;gt;u world!&amp;lt;Esc&amp;gt;u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will leave you with the text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Breakdown of commands&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i                           &quot; Enter Insert mode&#xA; Hello                      &quot; Type 'Hello'&#xA;      &amp;lt;C-G&amp;gt;u                &quot; Break the undo sequence&#xA;             world!         &quot; Type ' world!'&#xA;                   &amp;lt;Esc&amp;gt;    &quot; Return to Normal mode&#xA;                        u   &quot; Undo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Automatic solution&lt;/h2&gt;&#xA;&#xA;&lt;h3&gt;Finer-grained undo-level control&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Here's a small &lt;a href=&quot;https://gist.github.com/tommcdo/8d8444d94b444ee38b90&quot;&gt;snippet of VimScript&lt;/a&gt; that uses &lt;code&gt;&amp;lt;C-G&amp;gt;u&lt;/code&gt; to create undo breaks when you start deleting text, and also when you start entering text again after a deletion.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:start_delete(key)&#xA;    let l:result = a:key&#xA;    if !s:deleting&#xA;        let l:result = &quot;\&amp;lt;C-G&amp;gt;u&quot;.l:result&#xA;    endif&#xA;    let s:deleting = 1&#xA;    return l:result&#xA;endfunction&#xA;&#xA;function! s:check_undo_break(char)&#xA;    if s:deleting&#xA;        let s:deleting = 0&#xA;        call feedkeys(&quot;\&amp;lt;BS&amp;gt;\&amp;lt;C-G&amp;gt;u&quot;.a:char, 'n')&#xA;    endif&#xA;endfunction&#xA;&#xA;augroup smartundo&#xA;    autocmd!&#xA;    autocmd InsertEnter * let s:deleting = 0&#xA;    autocmd InsertCharPre * call s:check_undo_break(v:char)&#xA;augroup END&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;BS&amp;gt; &amp;lt;SID&amp;gt;start_delete(&quot;\&amp;lt;BS&amp;gt;&quot;)&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-W&amp;gt; &amp;lt;SID&amp;gt;start_delete(&quot;\&amp;lt;C-W&amp;gt;&quot;)&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-U&amp;gt; &amp;lt;SID&amp;gt;start_delete(&quot;\&amp;lt;C-U&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Notes&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This will work for &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; (delete a word), and &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; (delete to beginning of line). If there are more ways to delete in Insert mode, they can be supported by adding additional &lt;code&gt;inoremap&lt;/code&gt; calls at the end.&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="64" LastEditDate="2015-03-05T18:45:29.213" LastActivityDate="2015-03-05T18:45:29.213" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="2378" PostTypeId="1" AcceptedAnswerId="2379" CreationDate="2015-03-05T15:53:53.190" Score="12" ViewCount="524" Body="&lt;p&gt;I want to have my .vimrc synced through github so it has to be public file, but at the same time i have to put some sensitive data (for example db passwords/hosts for dbext.vim) in it, without giving them away to others. What is the best way and how to do it?&lt;/p&gt;&#xA;" OwnerUserId="1067" LastEditorUserId="51" LastEditDate="2015-06-26T17:18:43.517" LastActivityDate="2021-11-25T12:48:15.440" Title="How to use sensitive data in .vimrc?" Tags="|vimrc|security|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2379" PostTypeId="2" ParentId="2378" CreationDate="2015-03-05T16:13:44.163" Score="23" Body="&lt;p&gt;You can include another file using the &lt;code&gt;source&lt;/code&gt; command. Simply put this at the top of your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source($MYVIMRC . &quot;.private&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming your vimrc is &lt;code&gt;~/.vimrc&lt;/code&gt;, that will expand to &lt;code&gt;~/.vimrc.private&lt;/code&gt;. From now on, you can define variables in that file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let my_db_password = &quot;bacon&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can simply refer to them by name in your main vimrc.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Notes&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can call the private vimrc file whatever you want, it can even be in a different directory.&lt;/li&gt;&#xA;&lt;li&gt;If you want to use &lt;code&gt;~&lt;/code&gt; in the path, you will need to use &lt;code&gt;expand()&lt;/code&gt;. For example: &lt;code&gt;source expand(&quot;~/.private-vimrc&quot;)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;To concatenate the variable's value with a string, use the &lt;code&gt;.&lt;/code&gt; operator. For example: &lt;code&gt;&quot;jdbc:mysql://example.com/waffles?user=admin&amp;amp;password=&quot; . my_db_password&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1230" LastEditorUserId="1230" LastEditDate="2015-03-05T16:43:30.980" LastActivityDate="2015-03-05T16:43:30.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2380" PostTypeId="1" AcceptedAnswerId="2389" CreationDate="2015-03-05T18:27:11.847" Score="3" ViewCount="179" Body="&lt;p&gt;I am trying to map &lt;kbd&gt;Cmd&lt;/kbd&gt;+&lt;kbd&gt;Alt&lt;/kbd&gt; to start searching in vim (&lt;code&gt;/&lt;/code&gt;). The only question is: how would I do this? I know to map &lt;kbd&gt;Alt&lt;/kbd&gt; in vimscript is by typing &lt;code&gt;&amp;lt;A&amp;gt;&lt;/code&gt; but I do not know how to do &lt;kbd&gt;Cmd&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also want to press the keys at the same time (not one after the other)&lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="467" LastEditDate="2015-03-06T13:08:14.137" LastActivityDate="2020-04-12T13:29:51.210" Title="How to map CMD+Alt alone to the command?" Tags="|key-bindings|terminal|macos|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2381" PostTypeId="1" AcceptedAnswerId="2385" CreationDate="2015-03-05T18:36:19.997" Score="3" ViewCount="1315" Body="&lt;p&gt;I don't like the &lt;code&gt;cterm=reverse&lt;/code&gt; used on the StatusLine. Without &lt;code&gt;reverse&lt;/code&gt;, I also don't care for &lt;code&gt;bold&lt;/code&gt;, so I ended up with &lt;code&gt;hi StatusLine cterm=none&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this lead the spaces caused by the &lt;code&gt;%=&lt;/code&gt; in my statusline to be displayed as &lt;code&gt;^&lt;/code&gt;'s, which is quite obnoxious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my statusline code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('statusline')&#xA;    if version &amp;gt;= 700&#xA;        &quot; Fancy status line.&#xA;        set statusline =&#xA;        set statusline+=%n                                 &quot;buffer number&#xA;        set statusline+=%{'/'.bufnr('$')}\                 &quot;buffer count&#xA;        set statusline+=%f%m\                              &quot;file name/modified flag&#xA;        set statusline+=(%{strlen(&amp;amp;ft)?&amp;amp;ft:'none'})        &quot;file type&#xA;        set statusline+=%=                                 &quot;indent right&#xA;        set statusline+=U+%04B\                            &quot;Unicode char under cursor&#xA;        set statusline+=%-6.(%l/%{line('$')},%c%V%)\ %&amp;lt;%P  &quot;position&#xA;    endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's causing that to happen? And can I change it or do I have to settle for &lt;code&gt;cterm=bold&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1166" LastEditorUserId="205" LastEditDate="2015-03-05T20:08:07.303" LastActivityDate="2015-03-05T21:44:56.817" Title="hi StatusLine cterm=none displays whitespace characters" Tags="|statusline|highlight|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2382" PostTypeId="1" AcceptedAnswerId="2498" CreationDate="2015-03-05T18:39:42.327" Score="1" ViewCount="195" Body="&lt;p&gt;I have recently installed the c.vim plugin. The only issue is when I type &lt;code&gt;\im&lt;/code&gt; (automatically adds the main function) this is the way how it displays it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        int&#xA;main ( int argc, char *argv[] )&#xA;{&#xA;        return EXIT_SUCCESS;&#xA;}                               /* ----------  end of function main  ---------- */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see it looks a bit messy (I think so at least!). Because of this is there a way how I can format it like this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main ( int argc, char *argv[] )&#xA;{&#xA;    return EXIT_SUCCESS;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To me this is much neater which is why I want to change it.&lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="51" LastEditDate="2015-03-11T09:49:12.533" LastActivityDate="2015-03-11T16:28:07.673" Title="Change formating of `\im' command in c.vim" Tags="|plugin-c.vim|formatting|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2383" PostTypeId="2" ParentId="2340" CreationDate="2015-03-05T19:40:50.303" Score="1" Body="&lt;p&gt;For completeness, note that &lt;code&gt;ga&lt;/code&gt; uses the &lt;code&gt;encoding&lt;/code&gt; (not fileencoding) when it is a non-unicode encoding. You should be aware of the other consequences of setting &lt;code&gt;encoding&lt;/code&gt; to a value other than utf-8, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;encoding&lt;/code&gt; setting is actually the internal encoding used in vim (almost always utf-8 these days - setting it to a different unicode encoding is interpreted as utf-8 as well) - it's used for buffer contents, variables, options, etc. Having it as something other than UTF-8 limits what characters you can have any of those places, and changing it while vim is running will change the meaning of any values (including buffer contents) that are already loaded with non-ASCII text. This also explains why &lt;code&gt;ga&lt;/code&gt; and &lt;code&gt;g8&lt;/code&gt; &lt;em&gt;normally&lt;/em&gt; always return unicode and UTF-8 values - because the buffer is in &lt;code&gt;encoding&lt;/code&gt; (= utf-8) regardless of what encoding the file was in.&lt;/p&gt;&#xA;" OwnerUserId="880" LastEditorUserId="880" LastEditDate="2015-03-05T20:02:43.993" LastActivityDate="2015-03-05T20:02:43.993" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2384" PostTypeId="2" ParentId="2380" CreationDate="2015-03-05T21:33:34.847" Score="3" Body="&lt;p&gt;Looking at the &lt;a href=&quot;http://vimhelp.appspot.com/intro.txt.html#keycodes&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;keycodes&lt;/code&gt;&lt;/a&gt;, towards the end of the table is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;M-...&amp;gt;         alt-key or meta-key             meta alt &amp;lt;M-&#xA;&amp;lt;A-...&amp;gt;         same as &amp;lt;M-...&amp;gt;                 &amp;lt;A-&#xA;&amp;lt;D-...&amp;gt;         command-key (Macintosh only)    &amp;lt;D-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Combinations would look like &lt;code&gt;&amp;lt;D-M-x&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though I don't think a combination of modifiers alone can be mapped (&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;Shift&lt;/kbd&gt;,&lt;kbd&gt;Cmd&lt;/kbd&gt;-&lt;kbd&gt;Alt&lt;/kbd&gt;, etc.).&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-03-05T22:00:40.397" LastActivityDate="2015-03-05T22:00:40.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2385" PostTypeId="2" ParentId="2381" CreationDate="2015-03-05T21:44:56.817" Score="3" Body="&lt;p&gt;No. There is no way around that. This is done on purpose whenever the Statusline highlighting is not different than the normal highlighting.&#xA;You could however try to set the Statusline highlighting to a particular highlighting. That should prevent that this happens. E.g. if you are using this in a black terminal, try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi StatusLine ctermbg=0 term=none&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That means, by setting the highlighting group of the statusline to a particular color it will be different than the Normal highlighting and therefore, the replacement of the fillchars to '^' will not occurr. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also want to consider to set the StatuslineNC highlighting to a similar highlighting.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-03-05T21:44:56.817" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="2387" PostTypeId="1" AcceptedAnswerId="2388" CreationDate="2015-03-06T01:48:45.583" Score="14" ViewCount="25084" Body="&lt;p&gt;Recently on starting vim I've been getting an error message like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E575: viminfo: Illegal starting char in line: wait_until(lambda&#xA;_:&amp;lt;80&amp;gt;&amp;lt;fc&amp;gt;^B ^[ldWA)^[:w^Mkkkdd^[:w^M&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;c&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;b248Gwwi_zzz^[:w^M&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;c&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;bkkkkj/refresh^M^c^[ma/browser.rfer&amp;lt;80&amp;gt;kb&amp;lt;80&amp;gt;kb&amp;lt;80&amp;gt;kbresh^[/refresh^MnN^ceb&amp;lt;80&amp;gt;kbdrie&amp;lt;80&amp;gt;kbver^[:w^M&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;c&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;b&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;c&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;b&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;c&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;b&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;c&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;b&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;,&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;-&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;.^[^[^[^[&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;W&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;,&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;.&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;c&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;b&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;c&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;b&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;c&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;bjodisplay_remaining_hours=&amp;lt;80&amp;gt;kb = trello9&quot;&amp;lt;80&amp;gt;kb&amp;lt;80&amp;gt;kb(&quot;^V^V&quot;)^[^wwwwdt/..:w^M/zzz^Mkkjo@display_remaining_staff_hours^[ma/ldispla&amp;lt;80&amp;gt;kb&amp;lt;80&amp;gt;kb^[&amp;lt;80&amp;gt;kb^[ggjjjjjjjjjjjjjjjjjjjjjjjjjjjlkkkllllllllllllllllis&amp;lt;80&amp;gt;kb_staff^[*A.acceptance_test(&quot;At&amp;lt;80&amp;gt;kbT1&quot;)^[:w^Mjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhdt(^[:w^M&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;L&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;L&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;L&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;L&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;,&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;.&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;L&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;L&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;c&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;b&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;c&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;b&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;c&amp;lt;80&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't happen when I launch with &lt;code&gt;vim -u NONE&lt;/code&gt; but it does happen if I clear out my entire &lt;code&gt;~/.vimrc&lt;/code&gt; and move my &lt;code&gt;~/.vim&lt;/code&gt; directory. It looks like there's an error in a tags file somewhere but I can't find with one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="1079" LastEditorUserId="24" LastEditDate="2015-03-06T08:00:18.883" LastActivityDate="2023-04-19T14:14:36.057" Title="`E575: viminfo: Illegal starting char in line: ...` on startup" Tags="|startup|error|" AnswerCount="10" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2388" PostTypeId="2" ParentId="2387" CreationDate="2015-03-06T01:49:29.377" Score="17" Body="&lt;p&gt;Turns out the answer was in the error message all along.. the offending file was &lt;code&gt;~/.viminfo&lt;/code&gt; which was somehow corrupted.&lt;/p&gt;&#xA;" OwnerUserId="1079" LastActivityDate="2015-03-06T01:49:29.377" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2389" PostTypeId="2" ParentId="2380" CreationDate="2015-03-06T04:20:22.607" Score="6" Body="&lt;p&gt;This is not possible. In the terminal, no key code is generated for modifiers alone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gvim also has no support for this, partly because there is no valid way to represent the key using the map commands.&lt;/p&gt;&#xA;" OwnerUserId="499" LastActivityDate="2015-03-06T04:20:22.607" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2390" PostTypeId="2" ParentId="839" CreationDate="2015-03-06T06:48:48.403" Score="6" Body="&lt;p&gt;Oh that's a tough one. I think the best approach is possibly a macro but more likely a plugin. Here is an example I whipped up (I need a better hobby). It seemed to work for me but would need the python indenting plugin to indent properly. Try it out.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function ReformatMultiLines()&#xA;  let brx = '^\s*&quot;'&#xA;  let erx = '&quot;\s*$'&#xA;  let fullrx = brx . '\(.\+\)' . erx&#xA;  let startLine = line(&quot;.&quot;)&#xA;  let endLine   = line(&quot;.&quot;)&#xA;  while getline(startLine) =~ fullrx&#xA;    let startLine -= 1&#xA;  endwhile&#xA;  if getline(endLine) =~ erx&#xA;    let endLine += 1&#xA;  endif&#xA;  while getline(endLine) =~ fullrx&#xA;    let endLine += 1&#xA;  endwhile&#xA;  if startLine != endLine&#xA;    exec endLine . ' s/' . brx . '//'&#xA;    exec startLine . ' s/' . erx . '//'&#xA;    exec startLine . ',' . endLine . ' s/' . fullrx . '/\1/'&#xA;    exec startLine . ',' . endLine . ' join'&#xA;  endif&#xA;  exec startLine&#xA;  let orig_tw = &amp;amp;tw&#xA;  if &amp;amp;tw == 0&#xA;    let &amp;amp;tw = &amp;amp;columns&#xA;    if &amp;amp;tw &amp;gt; 79&#xA;      let &amp;amp;tw = 79&#xA;    endif&#xA;  endif&#xA;  let &amp;amp;tw -= 3 &quot; Adjust for missing quotes and space characters&#xA;  exec &quot;normal A%-%\&amp;lt;Esc&amp;gt;gqq&quot;&#xA;  let &amp;amp;tw = orig_tw&#xA;  let endLine = search(&quot;%-%$&quot;)&#xA;  exec endLine . ' s/%-%$//'&#xA;  if startLine == endLine&#xA;    return&#xA;  endif&#xA;  exec endLine&#xA;  exec 'normal I&quot;'&#xA;  exec startLine&#xA;  exec 'normal A &quot;'&#xA;  if endLine - startLine == 1&#xA;    return&#xA;  endif&#xA;  let startLine += 1&#xA;  while startLine != endLine&#xA;    exec startLine&#xA;    exec 'normal I&quot;'&#xA;    exec 'normal A &quot;'&#xA;    let startLine += 1&#xA;  endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you could use it with &lt;code&gt;:call ReformatMultiLines()&lt;/code&gt; and/or use it in a mapping.&lt;/p&gt;&#xA;" OwnerUserId="544" LastActivityDate="2015-03-06T06:48:48.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2391" PostTypeId="5" CreationDate="2015-03-06T08:06:26.843" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-03-06T08:06:26.843" LastActivityDate="2015-03-06T08:06:26.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2392" PostTypeId="4" CreationDate="2015-03-06T08:06:26.843" Score="0" Body="Requests to interpret and troubleshoot error messages from Vi / Vim." OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-03-06T11:54:28.733" LastActivityDate="2015-03-06T11:54:28.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2393" PostTypeId="2" ParentId="2347" CreationDate="2015-03-06T10:18:25.293" Score="3" Body="&lt;p&gt;I think what you really want is an automatic syntax checking. Try &lt;a href=&quot;https://github.com/scrooloose/syntastic&quot; rel=&quot;nofollow&quot;&gt;Syntastic&lt;/a&gt;. The plugin shows you syntax errors so you don't have to go back and forth to the compiler to catch syntax issues like missing semicolons.&lt;/p&gt;&#xA;" OwnerUserId="632" LastActivityDate="2015-03-06T10:18:25.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2394" PostTypeId="1" AcceptedAnswerId="2395" CreationDate="2015-03-06T10:44:40.887" Score="-3" ViewCount="629" Body="&lt;p&gt;I would like to set gvim as the default program for opening files which do not have an extension (e.g. no &lt;code&gt;.txt&lt;/code&gt;, &lt;code&gt;.php&lt;/code&gt;, &lt;code&gt;.js&lt;/code&gt;, &lt;code&gt;.css&lt;/code&gt;, &lt;code&gt;.html&lt;/code&gt; etc...) suffix as part of the file name.&lt;/p&gt;&#xA;&lt;p&gt;e.g.: &lt;code&gt;README&lt;/code&gt; or &lt;code&gt;INSTALL&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I would like to do this on any version of Windows (although I am currently running Windows 7).&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="23502" LastEditDate="2022-10-31T17:24:10.380" LastActivityDate="2022-10-31T17:24:10.380" Title="How to associate gvim with extensionless files on Windows?" Tags="|invocation|gvim|microsoft-windows|" AnswerCount="1" CommentCount="3" ClosedDate="2015-03-08T18:27:48.243" ContentLicense="CC BY-SA 4.0" />
  <row Id="2395" PostTypeId="2" ParentId="2394" CreationDate="2015-03-06T14:26:11.770" Score="2" Body="&lt;p&gt;You must have full Administrator privileges to set the default program to launch when files with no extension are clicked. From a DOS prompt:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;assoc&lt;/code&gt; command with the extension &lt;code&gt;.&lt;/code&gt; (which is used to denote the case where no file extension is present) and specify &quot;No Extension&quot; as the file type to associate with such extension:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;assoc .=&quot;No Extension&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now use the ftype command to specify the command to run when a file with no extension is clicked (the following assumes the latest version of Vim is installed in its default location on the &lt;code&gt;C:&lt;/code&gt; drive):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ftype &quot;No Extension&quot;=&quot;C:\Program Files (x86)\Vim\vim74\gvim.exe&quot; &quot;%1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-06T14:26:11.770" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2396" PostTypeId="1" AcceptedAnswerId="2424" CreationDate="2015-03-06T14:47:32.160" Score="2" ViewCount="969" Body="&lt;p&gt;I use windows XP for testing and running some programs. I installed Vim on the machine, but when I run &lt;code&gt;vimdiff&lt;/code&gt; on two files, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&quot;&quot;C:\Program' is not recognized as an internal or external command,&#xA;operable program or batch file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;along with errors &lt;a href=&quot;http://vimhelp.appspot.com/diff.txt.html#E810&quot; rel=&quot;nofollow&quot;&gt;E810 and E97&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking around the web, it seems that some variable in Vim is not quoted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it's the &lt;code&gt;VIMRUNTIME&lt;/code&gt;, but I'm not sure, and cannot find where to change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the default vimrc (&lt;code&gt;_vimrc&lt;/code&gt; on windows).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As requested in the comments by @Ben, in order to run vimdiff I use the following command: &lt;code&gt;vimdiff file1 file2&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="342" LastEditorUserId="342" LastEditDate="2015-03-07T17:12:00.533" LastActivityDate="2015-03-08T05:21:41.720" Title="c:\Program is not recognized error while running vimdiff" Tags="|vimdiff|microsoft-windows|error|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2397" PostTypeId="1" AcceptedAnswerId="2398" CreationDate="2015-03-06T15:46:25.177" Score="11" ViewCount="674" Body="&lt;p&gt;Many times I run across a situation where a line is not indented properly. Ether through a paste, bad / not preferred indent plugin, or most often extra spaces offsetting the indent value. I usually fix this by &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; the line a few times to fix it up. In the case of extra spaces I'll do a &lt;code&gt;100&amp;lt;&amp;lt;&lt;/code&gt; then a &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; for each indent level I actually want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is, like the &lt;kbd&gt;|&lt;/kbd&gt; motion that lets you set the column by number &lt;code&gt;10|&lt;/code&gt; sends the cursor to the 10th column. How can I specify the indent level?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example (this does not work) with &lt;code&gt;shiftwidth=4 expandtab&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The quick (indent level 0)&#xA;••••Brown Fox (indent level 1)&#xA;••••••••••Jumped over the lazy dog (indent level 2 with two extra spaces)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case I currently have to count the indent level of the last line (2) and add one for the extra spaces then type &lt;code&gt;3&amp;lt;&amp;lt;&lt;/code&gt; then count the indent level of what I then &lt;code&gt;1&amp;gt;&amp;gt;&lt;/code&gt; (or use &lt;code&gt;autoindent&lt;/code&gt; and &lt;code&gt;==&lt;/code&gt; command).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm asking for something like &lt;code&gt;1==&lt;/code&gt; to force the indent to be indent level 1. Or in some cases &lt;code&gt;0==&lt;/code&gt; for removing an indent all together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize the above example does auto indenting on 1 or 0 lines (respectively) and so does not do what I'd like but hoped it would help illustrate the question better.&lt;/p&gt;&#xA;" OwnerUserId="544" LastEditorUserId="51" LastEditDate="2015-03-06T16:17:11.107" LastActivityDate="2015-03-06T18:36:25.890" Title="How do I shift the line indent to a specific value?" Tags="|indentation|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2398" PostTypeId="2" ParentId="2397" CreationDate="2015-03-06T16:26:16.543" Score="18" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Aleft&quot;&gt;&lt;code&gt;:left&lt;/code&gt;&lt;/a&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;:[range]le[ft] [indent]&lt;/code&gt;&lt;br&gt;&#xA;  Left-align lines in &lt;code&gt;[range]&lt;/code&gt;.  Sets the indent in the  lines to &lt;code&gt;[indent]&lt;/code&gt; (default 0).  {not in Vi}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;:left&lt;/code&gt; sets the indent to &lt;em&gt;n&lt;/em&gt; spaces, and is not aware of &lt;code&gt;shiftwidth&lt;/code&gt; or &lt;code&gt;tabstop&lt;/code&gt;, so using &lt;code&gt;:left 8&lt;/code&gt; will use 8 spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to set the indentation level, you can easily define a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Left execute 'left ' . &amp;amp;sw * &amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;:Left 2&lt;/code&gt; will set the indentation to 8 spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To map this to &lt;kbd&gt;&amp;lt;Leader&amp;gt;=&lt;/kbd&gt;, you could use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;= ':left ' . str2nr(nr2char(getchar())) * &amp;amp;sw . '&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if this is the best way, but it's the only way I can manage... &lt;kbd&gt;\=2&lt;/kbd&gt; will indent the current line to 8 spaces, and &lt;kbd&gt;5\=3&lt;/kbd&gt; will indent the next 5 lines to 12 spaces.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A related hint that also solves your problem is setting the &lt;code&gt;shiftround&lt;/code&gt; option.  From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27nosr%27&quot;&gt;&lt;code&gt;:help 'shiftround'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Round indent to multiple of &lt;code&gt;'shiftwidth'&lt;/code&gt;.  Applies to &lt;code&gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;&lt;/code&gt;&#xA;  commands.  CTRL-T and CTRL-D in Insert mode always round the indent to&#xA;  a multiple of &lt;code&gt;'shiftwidth'&lt;/code&gt; (this is Vi compatible).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your example, the first &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; will &quot;round&quot; to 8 spaces. So your problem (using &lt;code&gt;3&amp;lt;&amp;lt;&lt;/code&gt; and then &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;) is solved. And as the help page says, you can also use &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; from insert mode.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-03-06T18:36:25.890" LastActivityDate="2015-03-06T18:36:25.890" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2399" PostTypeId="1" AcceptedAnswerId="2400" CreationDate="2015-03-06T17:42:20.877" Score="7" ViewCount="1420" Body="&lt;p&gt;When I install plugins, I like to keep them organised in folders. For example, I have downloaded plugins that turn vim into a programming IDE. This file contains 16 folders and files which are installed in the &lt;code&gt;~/.vim&lt;/code&gt; directory. Is there a way I can have all of these files and folders stored in &lt;code&gt;~/.vim/ide_support&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="24" LastEditDate="2015-03-06T22:58:53.143" LastActivityDate="2015-03-06T22:58:53.143" Title="Add plugin directory" Tags="|plugin-system|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2400" PostTypeId="2" ParentId="2399" CreationDate="2015-03-06T18:38:22.643" Score="9" Body="&lt;p&gt;Unpack the plugin into &lt;code&gt;~/.vim/ide_support&lt;/code&gt; then add the following to your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath+=~/.vim/ide_support&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will now look in &lt;code&gt;~/.vim/ide_support&lt;/code&gt; for plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is one of the things that a plugin manager such as &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot;&gt;pathogen&lt;/a&gt; does for you automatically.&lt;/p&gt;&#xA;" OwnerUserId="93" LastActivityDate="2015-03-06T18:38:22.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2403" PostTypeId="1" AcceptedAnswerId="2404" CreationDate="2015-03-07T04:18:32.297" Score="29" ViewCount="19560" Body="&lt;p&gt;I am running Debian Jessie and use the current vim-nox (with +python -python3). I am having a hard time trying to program in Python 3, as I struggle with Python 3 code completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;YouCompleteMe doesn't support Python3 at all. jedi-vim does support Python 3 completion, but only if I would have the +python3 option if I understand it correctly. From several posts from Debian Developers it seems that compiling Vim with the +python3 flag is not really working. Therefore I am left with the python-mode plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides the fact that python-mode seems unmaintained (see open pull-requests and last commits) and it currently has a huge bug concerning rope in its master branch, it interferes with YouCompleteMe. I do get some Python 3 code completion to work, but only if I disable YouCompleteMe totally. Blacklisting YCM for python filetypes or disabling YCM completion for python files doesn't work, I get a YCM warning each time I open vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my questions are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get a Python 3 autocompletion to work on a current Debian distribution while not deactivating YouCompleteMe (which I want for other programmming languages)? How come an unmaintained plugin is the only choice at the moment for code completion for such an important programming language (Python 3 can no longer be considered new..)?&lt;/p&gt;&#xA;" OwnerUserId="1256" LastEditorUserId="51" LastEditDate="2015-03-07T04:31:58.063" LastActivityDate="2018-12-28T13:40:51.637" Title="Vim Code Completion for Python 3" Tags="|autocompletion|filetype-python|" AnswerCount="6" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="2404" PostTypeId="2" ParentId="2403" CreationDate="2015-03-07T04:38:58.900" Score="18" Body="&lt;p&gt;The ideal way is to get Vim's source and compile it yourself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 1: For Debian-like systems, get the required packages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get build-dep vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Step 2: Clone Vim's source code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /tmp &amp;amp;&amp;amp; git clone https://github.com/vim/vim.git &amp;amp;&amp;amp; cd vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Step 3: Configure, Make, Install&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --with-features=huge --enable-multibyte --enable-python3interp \&#xA;    --enable-gui=gtk-2 --prefix=/usr&#xA;&#xA;make VIMRUNTIMEDIR=/usr/share/vim/vim74&#xA;sudo make install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Step 4: Done! You should have a huge version of vim, with +python3 support. It also has +clipboard support so you can use it with your system clipboard, and a gui version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you can remove configure flags you don't want or add some in. YouCompleteMe actually has a fairly length wiki dedicated to explaining how to build Vim from source &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="246" LastEditDate="2015-11-01T23:47:45.433" LastActivityDate="2015-11-01T23:47:45.433" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="2405" PostTypeId="2" ParentId="2403" CreationDate="2015-03-07T06:28:26.253" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/davidhalter/jedi-vim&quot; rel=&quot;noreferrer&quot;&gt;jedi-vim&lt;/a&gt; works fine for me now with +python3 support in vim. In added the following option to my .vimrc:&#xA;&lt;code&gt;let g:jedi#force_py_version = 3&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1256" LastActivityDate="2015-03-07T06:28:26.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2406" PostTypeId="1" AcceptedAnswerId="2407" CreationDate="2015-03-07T13:36:26.637" Score="10" ViewCount="6758" Body="&lt;p&gt;I am making my own function to call a bash script that compiles and runs my program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I have tried.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Compile_and_run(game, major, minor)&#xA;    !_compile a:game a:major a:minor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only issue is it seems to parse &lt;code&gt;a:game&lt;/code&gt; instead of the value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I get &lt;code&gt;a:game&lt;/code&gt;, &lt;code&gt;a:major&lt;/code&gt;, &lt;code&gt;a:minor&lt;/code&gt; to parse their value to the function?&lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="64" LastEditDate="2015-03-07T14:22:54.197" LastActivityDate="2015-03-07T14:22:54.197" Title="function to call shell script with arguments" Tags="|vimscript|external-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2407" PostTypeId="2" ParentId="2406" CreationDate="2015-03-07T14:08:54.223" Score="14" Body="&lt;h2&gt;Using &lt;code&gt;:execute&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;All command arguments in Vim are interpreted literally unless designed to be evaluated. To build a command dynamically, you can use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Aexecute&quot;&gt;&lt;code&gt;:execute&lt;/code&gt;&lt;/a&gt;. Each argument to &lt;code&gt;:execute&lt;/code&gt; is evaluated, and they are all joined by a space to produce the final command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Compile_and_run(game, major, minor)&#xA;    execute '!_compile' a:game a:major a:minor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Incorporating &lt;code&gt;shellescape()&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It's a good idea to escape arguments being passed to the shell using &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#shellescape%28%29&quot;&gt;&lt;code&gt;shellescape()&lt;/code&gt;&lt;/a&gt;. It takes a string and escapes it for use in a shell command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Compile_and_run(game, major, minor)&#xA;    execute '!_compile' shellescape(a:game) shellescape(a:major) shellescape(a:minor)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-03-07T14:08:54.223" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2408" PostTypeId="1" AcceptedAnswerId="2409" CreationDate="2015-03-07T14:34:19.580" Score="4" ViewCount="3119" Body="&lt;p&gt;I am making a function to compile and run my application. I have been able to get it to run the shell command however I cannot get it to save the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try 1)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Compile_and_run(game, major, minor)&#xA;    :w &amp;lt;CR&amp;gt;&#xA;    execute '!_compile' shellescape(a:game) shellescape(a:major) shellescape(a:minor)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try 2)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Compile_and_run(game, major, minor)&#xA;    execute &quot;:w &amp;lt;CR&amp;gt;&quot;&#xA;    execute '!_compile' shellescape(a:game) shellescape(a:major) shellescape(a:minor)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is it that Im doing wrong? How would I get this function to save before the &lt;code&gt;execute '!_compile'&lt;/code&gt; command?&lt;/p&gt;&#xA;" OwnerUserId="1168" LastActivityDate="2015-03-07T15:13:29.243" Title="Vimscript save file" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2409" PostTypeId="2" ParentId="2408" CreationDate="2015-03-07T15:13:29.243" Score="11" Body="&lt;p&gt;Something like &lt;code&gt;:w&amp;lt;CR&amp;gt;&lt;/code&gt; makes sense for creating a Normal mode mapping. In Normal mode, you need the &lt;code&gt;:&lt;/code&gt; to enter Command-line mode, and the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to execute the command and return to Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Writing VimScript&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here, since you're writing VimScript, every line is interpreted as if it's in Command-line mode already. You don't need to lead with a &lt;code&gt;:&lt;/code&gt; (though it's harmless if you do), and you don't need the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to execute the command (and in this case, it's incorrect to use it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You only need &lt;code&gt;write&lt;/code&gt; (or &lt;code&gt;w&lt;/code&gt; for short) in this context.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Compile_and_run(game, major, minor)&#xA;    write&#xA;    execute '!_compile' shellescape(a:game) shellescape(a:major) shellescape(a:minor)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Take a look at &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#vim-script-intro&quot;&gt;&lt;code&gt;:help vim-script-intro&lt;/code&gt;&lt;/a&gt; to learn more.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-03-07T15:13:29.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2410" PostTypeId="1" AcceptedAnswerId="2411" CreationDate="2015-03-07T15:43:12.003" Score="51" ViewCount="16390" Body="&lt;p&gt;I want to make a function that has optional arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In python I would do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def functionName(arg1,arg2=false,arg3=false):&#xA;    if arg2:&#xA;        #Do stuff with arguments&#xA;    else:&#xA;        #Do stuff without arguments&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried doing &lt;code&gt;function FunctionName(arg1,arg2=false,arg3=false)&lt;/code&gt;, but it just gives me a error saying invalid argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I do this in vimscript?&lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="28" LastEditDate="2017-12-30T23:19:09.450" LastActivityDate="2023-07-06T13:24:05.093" Title="How to make a vimscript function with optional arguments?" Tags="|vimscript|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2411" PostTypeId="2" ParentId="2410" CreationDate="2015-03-07T16:36:20.960" Score="53" Body="&lt;p&gt;Yes, you can take optional arguments in a function.  It is not as convenient as python's way of doing it, but this is how you do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function FooBar(...) &quot; This is like *args in python&#xA;    echom a:0 &quot; a:0 contains an integer which is the number of arguments passed to the function&#xA;    echom a:1 &quot; a:1 contains the first argument passed, a:2 contains the second and so on&#xA;    echo a:000 &quot; a:000 contains a list of all arguments that were passed to the function&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you may only have up to 20 arguments in this fashion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relevant help topics:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :function&#xA;:help function-argument&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-03-07T16:36:20.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2412" PostTypeId="2" ParentId="2410" CreationDate="2015-03-07T16:40:16.150" Score="8" Body="&lt;p&gt;I'm not well versed in vimscript, but this is how I would do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Func(foo, ...)&#xA;  if a:0 &amp;lt; 1&#xA;    let bar = &quot;Unspecified bar&quot;&#xA;  else&#xA;    let bar = a:1&#xA;  endif&#xA;  if a:0 &amp;lt; 2&#xA;    let baz = &quot;Unspecified baz&quot;&#xA;  else&#xA;    let baz = a:2&#xA;  endif&#xA;&#xA;  echo a:foo&#xA;  echo bar&#xA;  echo baz&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then &lt;code&gt;call Func(&quot;Hello&quot;, &quot;World&quot;)&lt;/code&gt;, and see that it prints &quot;Hello&quot;, &quot;World&quot;, &quot;Unspecified baz&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is using the varargs feature of vim functions, which lets you pass an arbitrary number of extra arguments to the function. The arguments are stored in variables which, depending on &lt;code&gt;a:0&lt;/code&gt; (the length of the extra arguments list), either get set to their corresponding argument or a default value.&lt;/p&gt;&#xA;" OwnerUserId="499" LastActivityDate="2015-03-07T16:40:16.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2413" PostTypeId="1" AcceptedAnswerId="2414" CreationDate="2015-03-07T17:14:03.557" Score="1" ViewCount="144" Body="&lt;p&gt;I'm writing code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (!p){&#xA;    return 0; &amp;lt;-- cursor is on this line&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to start appending immediately after the code block, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (!p){&#xA;    return 0;&#xA;}&#xA;&amp;lt;-- cursor is on this line, in Insert mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a command for this? Usually I use &lt;code&gt;jo&lt;/code&gt; to go down a line and then append a new line, or &lt;code&gt;]}o&lt;/code&gt; if there's more than one line of code inside the brackets, but both of these solutions feel kind of verbose.&lt;/p&gt;&#xA;" OwnerUserId="40" LastActivityDate="2015-03-07T18:34:24.787" Title="How can I append after a code block?" Tags="|cursor-movement|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2414" PostTypeId="2" ParentId="2413" CreationDate="2015-03-07T17:44:18.893" Score="2" Body="&lt;h2&gt;Ninja Feet&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I made a plugin called &lt;a href=&quot;https://github.com/tommcdo/vim-ninja-feet&quot; rel=&quot;nofollow&quot;&gt;ninja-feet.vim&lt;/a&gt; that, among other things, defines operators &lt;code&gt;z[&lt;/code&gt; and &lt;code&gt;z]&lt;/code&gt; for entering Insert mode before and after a text object, respectively. Like other operators, they take a &lt;code&gt;{motion}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your use case, you could use the &lt;code&gt;ip&lt;/code&gt; text object: &lt;code&gt;z]ip&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Caveat&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This operator is not repeatable with &lt;code&gt;.&lt;/code&gt;; it will simply repeat the insertion at the cursor position.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-03-07T17:44:18.893" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2415" PostTypeId="1" AcceptedAnswerId="2418" CreationDate="2015-03-07T17:46:29.293" Score="7" ViewCount="130" Body="&lt;p&gt;I find my self often, especially after this site was created, opening Vim just to type &lt;code&gt;:h ...&lt;/code&gt; or &lt;code&gt;:helpgrep ...&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What I would like to do is to run Vim and immediately open the help topic that I want. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="342" LastEditorUserId="23502" LastEditDate="2022-10-31T17:22:00.787" LastActivityDate="2022-10-31T17:22:00.787" Title="How to search the help docs from a command prompt?" Tags="|invocation|help-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2416" PostTypeId="5" CreationDate="2015-03-07T17:47:34.853" Score="0" Body="&lt;p&gt;A first reading about Vim's command line options should be &lt;a href=&quot;http://linux.die.net/man/1/vim&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;man&#xA;vim&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim can be started from the shell in different ways, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vim&lt;/code&gt;  The &quot;normal&quot; way, everything is default.  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ex&lt;/code&gt;   Start in Ex mode. Go to Normal mode with the &lt;code&gt;:vi&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;view&lt;/code&gt; Start in read-only mode. You will be protected from writing the files.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gvim&lt;/code&gt;/&lt;code&gt;gview&lt;/code&gt; The GUI version. Starts a new window. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also some common options are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;-u&lt;/code&gt; allows to specify a file to use as configuration file other than&#xA;the &lt;code&gt;.vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-c&lt;/code&gt; allows to specify an ex mode command to be executed after the first file&#xA;was read.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-w&lt;/code&gt; allows to record in a file every keystrokes issued in Vim.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="205" LastEditDate="2015-09-28T07:23:39.440" LastActivityDate="2015-09-28T07:23:39.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2417" PostTypeId="4" CreationDate="2015-03-07T17:47:34.853" Score="0" Body="Questions about the different options that vim can take from the shell and the different commands to start the editor." OwnerUserId="342" LastEditorUserId="1841" LastEditDate="2015-09-28T07:23:53.137" LastActivityDate="2015-09-28T07:23:53.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2418" PostTypeId="2" ParentId="2415" CreationDate="2015-03-07T17:48:56.883" Score="8" Body="&lt;p&gt;Use the &lt;code&gt;-c&lt;/code&gt; argument to execute a command after Vim starts up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c ':help TOPIC' -c :only&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may want to define a shell function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimhelp () {&#xA;  vim -c &quot;:help $1&quot; -c :only&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2015-03-08T17:11:17.880" LastActivityDate="2015-03-08T17:11:17.880" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2419" PostTypeId="1" AcceptedAnswerId="2425" CreationDate="2015-03-07T18:32:27.023" Score="12" ViewCount="4351" Body="&lt;p&gt;I am trying to map &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;s&lt;/kbd&gt; to save my file however it does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-s&amp;gt; :w &amp;lt;CR&amp;gt; :echo &quot;Saved&quot; &amp;lt;CR&amp;gt;&#xA;imap &amp;lt;C-s&amp;gt; &amp;lt;Esc&amp;gt; :w &amp;lt;CR&amp;gt; :echo &quot;Saved&quot; &amp;lt;CR&amp;gt; i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When in insert mode I see &lt;code&gt;/:echo &quot;Saved&quot;&lt;/code&gt; in the bottom corner instead of &lt;code&gt;saved&lt;/code&gt; and when I am in normal mode I see the same thing. What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is at the very top of my vimrc so my other code should not be causing a issue. I am running Vim inside the OSX Terminal.&lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="51" LastEditDate="2015-03-07T18:58:25.627" LastActivityDate="2020-11-16T04:17:10.303" Title="Mapping Ctrl+s does not work" Tags="|key-bindings|terminal|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2421" PostTypeId="2" ParentId="2396" CreationDate="2015-03-07T18:39:16.407" Score="2" Body="&lt;p&gt;I can reproduce the problem on my Windows 7 VM, I installed gVim, clicked the &quot;install .bat files for commandline usage&quot;, typed &lt;code&gt;vimdiff a.txt b.txt&lt;/code&gt; in a cmd window, and got the same error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how I fixed it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:set diffexpr?&lt;/code&gt; gives &lt;code&gt;diffexprr=MyDiff()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:echo $MYVIMRC&lt;/code&gt; gives me &lt;code&gt;C:\Program Files\Vim\_vimrc&lt;/code&gt;; I opened this file and see the &lt;code&gt;MyDifff()&lt;/code&gt; is defined here.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I copied this file to &lt;code&gt;C:\Users\IEUser\_vimrc&lt;/code&gt;, I started Vim and used &lt;code&gt;:echo $MYVIMRC&lt;/code&gt; again to verify it's actually being used. We can now use this file to fix the &lt;code&gt;MyDiff()&lt;/code&gt; function.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On line 20, there's:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let cmd = '&quot;&quot;' . $VIMRUNTIME . '\diff&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The double &lt;code&gt;&quot;&quot;&lt;/code&gt; is wrong, this is probably a typo, so remove one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; let cmd = '&quot;' . $VIMRUNTIME . '\diff&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It still doesn't work :-/ I replaced the &lt;code&gt;silent execute&lt;/code&gt; in the last line with &lt;code&gt;echo&lt;/code&gt;, I notice that the command ends with a &lt;code&gt;&quot;&lt;/code&gt;, but I don't see an opening &lt;code&gt;&quot;&lt;/code&gt; anywhere. This is caused by the &lt;code&gt;. eq&lt;/code&gt; part, so I removed that.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We now have a working &lt;code&gt;vimdiff&lt;/code&gt;! I still need to press enter twice on startup, though; I am not sure why this is... If I run the command that Vim runs in &lt;code&gt;cmd&lt;/code&gt;, it seems to work just fine ... This may have to do with the way Windows cmd.exe works, but I'm not sure...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm not sure the above is the &lt;em&gt;best&lt;/em&gt; way to fix it, but it's &lt;em&gt;a&lt;/em&gt; way. &lt;strong&gt;This is a bug in Vim&lt;/strong&gt;; you should report it as such. Feel free to copy this post :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-03-07T18:39:16.407" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2422" PostTypeId="2" ParentId="2419" CreationDate="2015-03-07T19:04:12.587" Score="2" Body="&lt;p&gt;Thanks to @Carpetsmoker for the links.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding this script into &lt;code&gt;bash_profile&lt;/code&gt; worked for me.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim()&#xA;{&#xA;    # osx users, use stty -g&#xA;    local STTYOPTS=&quot;$(stty --save)&quot;&#xA;    stty stop '' -ixoff&#xA;    command vim &quot;$@&quot;&#xA;    stty &quot;$STTYOPTS&quot;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a link to it. &lt;a href=&quot;http://vim.wikia.com/wiki/Map_Ctrl-S_to_save_current_or_new_files&quot; rel=&quot;nofollow&quot;&gt;http://vim.wikia.com/wiki/Map_Ctrl-S_to_save_current_or_new_files&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also had to remove the space before the :&lt;/p&gt;&#xA;" OwnerUserId="1168" LastActivityDate="2015-03-07T19:04:12.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2423" PostTypeId="1" CreationDate="2015-03-07T21:52:31.387" Score="4" ViewCount="900" Body="&lt;p&gt;Depending on how I launch Vim, suspending with &lt;code&gt;&amp;lt;C-z&amp;gt;&lt;/code&gt; or with &lt;code&gt;:suspend&lt;/code&gt; causes Vim to drop into an empty terminal (no shell) and get stuck there. I know I can unmap &lt;code&gt;&amp;lt;C-z&amp;gt;&lt;/code&gt; like so &lt;code&gt;map &amp;lt;C-z&amp;gt; &amp;lt;Nop&amp;gt;&lt;/code&gt; but is there a way I can prevent &lt;code&gt;:suspend&lt;/code&gt; from running? Or redefine it to be an empty function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;don't&lt;/em&gt; want to run Vim in restricted mode &lt;code&gt;vim -Z&lt;/code&gt; because this doesn't allow things like &lt;code&gt;:sh&lt;/code&gt; which actually do still work.&lt;/p&gt;&#xA;" OwnerUserId="200" LastEditorUserId="200" LastEditDate="2015-03-07T23:33:04.643" LastActivityDate="2015-03-09T19:49:20.787" Title="Prevent vim from running a built-in function?" Tags="|command-line|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2424" PostTypeId="2" ParentId="2396" CreationDate="2015-03-08T05:21:41.720" Score="4" Body="&lt;p&gt;&lt;strong&gt;Getting a fixed Vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This specific bug was fixed in &lt;a href=&quot;https://code.google.com/p/vim/source/detail?r=v7-4-103&quot; rel=&quot;nofollow&quot;&gt;7.4.103&lt;/a&gt; back in 2013.  Bram typically only publishes Windows installers on vim.org for major releases, so the installer there doesn't have this fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://sourceforge.net/projects/cream/&quot; rel=&quot;nofollow&quot;&gt;Cream&lt;/a&gt; project regularly builds a Windows installer containing the latest Vim patches and provides them in their &lt;a href=&quot;http://sourceforge.net/projects/cream/files/Vim/&quot; rel=&quot;nofollow&quot;&gt;Vim without Cream&lt;/a&gt; download.  This is a commonly recommended resource for Windows users.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using their installer and having it overwrite the common _vimrc will fix the &lt;code&gt;MyDiff&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Avoiding the problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, there's no need to use the &lt;code&gt;MyDiff&lt;/code&gt; function defined in that &lt;code&gt;_vimrc&lt;/code&gt;.  If you just create your own &lt;code&gt;$HOME\_vimrc&lt;/code&gt;, then the system one won't be used.  This is what I do and have never had a problem using vimdiff on Windows without a custom &lt;code&gt;'diffexpr'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd recommend creating your own &lt;code&gt;_vimrc&lt;/code&gt; anyway so you can freely customize it without risking it being overwritten next time you upgrade Vim.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-03-08T05:21:41.720" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2425" PostTypeId="2" ParentId="2419" CreationDate="2015-03-08T10:43:35.157" Score="10" Body="&lt;p&gt;To ensure that this workaround runs even when Vim is started by a &lt;strong&gt;separate tool&lt;/strong&gt; (such as git), I have this in my &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Allow us to use Ctrl-s and Ctrl-q as keybinds&#xA;silent !stty -ixon&#xA;&#xA;&amp;quot; Restore default behaviour when leaving Vim.&#xA;autocmd VimLeave * silent !stty ixon&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This has been working for me on Linux, GVim, Mac OS X and MacVim.&lt;/p&gt;&#xA;&lt;p&gt;Caveats:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;On Windows, or any other OS lacking the &lt;code&gt;stty&lt;/code&gt; command, the above will likely throw up errors every time Vim starts!  (&lt;code&gt;silent!&lt;/code&gt; might mute that.)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If your shell already had this TTY setting disabled, of course the &lt;code&gt;VimLeave&lt;/code&gt; autocommand will turn it back on again!  iProgram's approach manages that by detecting the settings at startup.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;A combination of this and iProgram's solution, which handles compatibility concerns under OS X and Windows, would be great to post up here and/or on the Wiki!&lt;/p&gt;&#xA;&lt;p&gt;To avoid choosing between &lt;code&gt;stty -g&lt;/code&gt; and &lt;code&gt;stty --save&lt;/code&gt;, you could try the following test for just the &lt;code&gt;ix&lt;/code&gt; option.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;call system(&amp;quot;stty -a | grep '\( \|^\)ixon\&amp;gt;' &amp;gt;/dev/null&amp;quot;)&#xA;let g:ix_at_startup = (v:shell_error == 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2020-11-16T04:17:10.303" LastActivityDate="2020-11-16T04:17:10.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2426" PostTypeId="1" AcceptedAnswerId="2427" CreationDate="2015-03-08T12:55:04.510" Score="16" ViewCount="2257" Body="&lt;p&gt;Is there a way to configure vim regarding what file types it considers &quot;suitable&quot; for opening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me clarify by an example. Imagine you are working on a latex document. Once you build your file, you have the following in your directory (along with other files related to the build):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;X.aux  X.log  X.out  X.pdf  X.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if you are working on another file (say &lt;code&gt;Y.tex&lt;/code&gt;), and you want to &lt;code&gt;:sp X.tex&lt;/code&gt;, you can use &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; to cycle through possible files, i.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sp X&amp;lt;Tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that vim already makes a selection of what files you are most likely to want, and autocompletes to those files first. This is the order in which my vim is autocompleting files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;X.pdf&#xA;X.tex&#xA;X.aux&#xA;X.log&#xA;X.out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, it looks like vim has decided I probably want to open either the &lt;code&gt;.pdf&lt;/code&gt; or &lt;code&gt;.tex&lt;/code&gt; file and is presenting them to me first and in alphabetical order. Then it shows the rest of the files, again in alphabetical order. First, is my understanding correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, how can I tell vim that it shouldn't think I am interested in opening &lt;code&gt;.pdf&lt;/code&gt; files with it? This way, the first &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; would immediately get me the &lt;code&gt;.tex&lt;/code&gt; file as the file I am really looking for.&lt;/p&gt;&#xA;" OwnerUserId="850" LastEditorUserId="205" LastEditDate="2015-03-08T23:04:02.473" LastActivityDate="2015-03-08T23:04:02.473" Title="How do I exclude certain file extensions from completion?" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2427" PostTypeId="2" ParentId="2426" CreationDate="2015-03-08T13:29:22.623" Score="21" Body="&lt;p&gt;You can use &lt;code&gt;wildignore&lt;/code&gt;, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildignore+=*.pdf,*.o,*.obj,*.jpg,*.png&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to list them, but give low priority – list at end, one option is to use &lt;code&gt;suffixes&lt;/code&gt;, for example with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set suffixes+=.pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PDF files are going to be listed, but at the end of file list. Read up on &lt;code&gt;:h suffixes&lt;/code&gt; with links for more detail.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2015-03-08T13:49:01.933" LastActivityDate="2015-03-08T13:49:01.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2428" PostTypeId="1" CreationDate="2015-03-08T15:10:39.357" Score="11" ViewCount="2453" Body="&lt;p&gt;My project has these files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ find . -type f -and -name 'peop*'&#xA;./app/assets/stylesheets/admin/sections/people.css.sass&#xA;./app/controllers/admin/people_controller.rb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As I got tired of typing &lt;code&gt;:e app/assets/stylesheets/admin/sections/people.css.sass&lt;/code&gt;, I thought that &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot;&gt;ctrlp&lt;/a&gt; might be a good way to save some typing. However, I can't get it to match files in what I consider to be a sane way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I use &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; and type &lt;code&gt;peop&lt;/code&gt;, and that gives me these results (&quot;first&quot; match is at the bottom):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; app/models/attribute_group.rb&#xA;&amp;gt; app/models/contract_template.rb&#xA;&amp;gt; app/policies/contract_policy.rb&#xA;&amp;gt; app/uploaders/photo_uploader.rb&#xA;&amp;gt; app/policies/invoice_policy.rb&#xA;&amp;gt; app/views/layouts/pdf.pdf.haml&#xA;&amp;gt; app/uploaders/logo_uploader.rb&#xA;&amp;gt; app/models/property_object.rb&#xA;&amp;gt; app/policies/person_policy.rb&#xA;&amp;gt; app/policies/photo_policy.rb    &#xA;&amp;gt;&amp;gt;&amp;gt; peop_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These results are horrible. Neither files with &lt;code&gt;peop&lt;/code&gt; in them are there. Even when I expand it to &lt;code&gt;people&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; app/policies/contract_template_policy.rb&#xA;&amp;gt; app/models/concerns/exportable.rb&#xA;&amp;gt; app/models/contract_template.rb&#xA;&amp;gt; app/uploaders/photo_uploader.rb&#xA;&amp;gt; app/uploaders/logo_uploader.rb&#xA;&amp;gt; app/views/admin/people/_show.html.haml&#xA;&amp;gt; app/views/admin/people/_form.html.haml&#xA;&amp;gt; app/views/admin/people/show.html.haml&#xA;&amp;gt; app/views/admin/people/edit.html.haml&#xA;&amp;gt; app/views/admin/people/new.html.haml &#xA;&amp;gt;&amp;gt;&amp;gt; people_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't list either of them (!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I went through &lt;code&gt;:help ctrlp-options&lt;/code&gt;, and found a single option that improves things somewhat:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Set this to 1 to set searching by filename (as opposed to full path) as the&#xA;default:&#xA;  let g:ctrlp_by_filename = 0&#xA;&#xA;Can be toggled on/off by pressing &amp;lt;c-d&amp;gt; inside the prompt.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After setting this, I get the following results on &lt;code&gt;peop&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; app/controllers/admin/organisation_people_controller.rb&#xA;&amp;gt; app/assets/stylesheets/admin/sections/people.css.sass&#xA;&amp;gt; doc/formulieren/opdrachtverlening-woningbeheer.pdf&#xA;&amp;gt; doc/formulieren/hulptabellen-object-unit-soort.pdf&#xA;&amp;gt; doc/formulieren/brandpreventievoorjongeren.pdf&#xA;&amp;gt; app/policies/organisation_person_policy.rb&#xA;&amp;gt; doc/prototype-admin/prototype/inspectiemodule_apparaten.html&#xA;&amp;gt; app/policies/property_object_policy.rb&#xA;&amp;gt; app/policies/person_policy.rb&#xA;&amp;gt; app/controllers/admin/people_controller.rb&#xA;&amp;gt;d&amp;gt; peop_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Okay, so this is slightly better, I get at least one of the expected files at the first result, and the other one as the 9th. It still conciders &lt;code&gt;hulptabellen-object-unit-soort.pdf&lt;/code&gt; to be a better match than &lt;code&gt;people.css.sass&lt;/code&gt; though (!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;people&lt;/code&gt; finally gives me the 2 expected files as the first 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; app/controllers/admin/organisation_people_controller.rb&#xA;&amp;gt; app/assets/stylesheets/admin/sections/people.css.sass&#xA;&amp;gt; app/controllers/admin/people_controller.rb&#xA;&amp;gt;&amp;gt;&amp;gt; people_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I make this matching better? I don't mind &quot;fuzzy matching&quot;, but it should not be so fuzzy it matches everything and everyone... In this case, I would expect typing &lt;code&gt;&amp;lt;c-P&amp;gt;peop&lt;/code&gt; to have &lt;code&gt;app/assets/stylesheets/admin/sections/people.css.sass&lt;/code&gt; as either the 1st or 2nd match.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-03-08T15:18:15.113" LastActivityDate="2015-03-09T20:35:44.070" Title="How can I make ctrlp do better filename matching?" Tags="|filesystem|plugin-ctrlp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2429" PostTypeId="1" CreationDate="2015-03-08T21:55:32.583" Score="41" ViewCount="22568" Body="&lt;p&gt;Is there a way to get the name and extension of a file using vimscript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so I would like the name and extension separately. &lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="205" LastEditDate="2015-03-08T23:02:21.977" LastActivityDate="2021-08-21T04:01:24.617" Title="How do I get the name and extension of the current file?" Tags="|vimscript|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2430" PostTypeId="2" ParentId="2429" CreationDate="2015-03-08T22:58:16.090" Score="41" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#filename-modifiers&quot;&gt;&lt;code&gt;:he filename-modifiers&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    :t      Tail of the file name (last component of the name).  Must&#xA;            precede any :r or :e.&#xA;    :r      Root of the file name (the last extension removed).  When&#xA;            there is only an extension (file name that starts with '.',&#xA;            e.g., &quot;.vimrc&quot;), it is not removed.  Can be repeated to remove&#xA;            several extensions (last one first).&#xA;&#xA;    :e      Extension of the file name.  Only makes sense when used alone.&#xA;            When there is no extension the result is empty.&#xA;            When there is only an extension (file name that starts with&#xA;            '.'), the result is empty.  Can be repeated to include more&#xA;            extensions.  If there are not enough extensions (but at least&#xA;            one) as much as possible are included.&#xA;Examples, when the file name is &quot;src/version.c&quot;, current dir&#xA;&quot;/home/mool/vim&quot;:&#xA;  :p                    /home/mool/vim/src/version.c&#xA;  :t                                       version.c&#xA;  :t:r                                     version&#xA;  :e                                               c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expand%28%29&quot;&gt;&lt;code&gt;expand&lt;/code&gt;&lt;/a&gt; function to expand these and obtain their values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let b:baz=expand('%:e')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim '+ exe &quot;:normal i&quot; . expand(&quot;%:t&quot;) . &quot;^M&quot; . expand(&quot;%:e&quot;)' +wqa foo.bar; cat foo.bar&#xA;foo.bar&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-03-08T22:58:16.090" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2431" PostTypeId="2" ParentId="2429" CreationDate="2015-03-08T22:58:33.893" Score="17" Body="&lt;p&gt;You can use &lt;code&gt;expand()&lt;/code&gt;, see &lt;a href=&quot;http://vimdoc.sourceforge.net/cgi-bin/help?tag=expand%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h expand()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a script you could do this to get file-name:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let file_name = expand('%:t:r')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get extension you could do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let extension = expand('%:e')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;expand()&lt;/code&gt; function can expand wildcards and special &lt;em&gt;symbols&lt;/em&gt;. Here I have used &lt;code&gt;%&lt;/code&gt; which expands to current file-name.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="26577" LastEditDate="2020-01-20T11:01:53.020" LastActivityDate="2020-01-20T11:01:53.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2432" PostTypeId="1" AcceptedAnswerId="2441" CreationDate="2015-03-09T00:47:33.283" Score="10" ViewCount="1497" Body="&lt;p&gt;When using Vim you can use &lt;code&gt;:Explore&lt;/code&gt; to browser through files and folders.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simple way to start Vim in &quot;Explore mode&quot; from the terminal? Can I do this by just giving Vim some argument?&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="51" LastEditDate="2015-03-11T00:26:36.670" LastActivityDate="2015-11-24T19:30:53.037" Title="Can :Explore be started from the terminal?" Tags="|invocation|netrw|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2433" PostTypeId="2" ParentId="2432" CreationDate="2015-03-09T01:07:52.973" Score="12" Body="&lt;p&gt;The &quot;Explore Mode&quot; you are talking about is netrw, a vim plugin which is provided by default.  It should open in that &quot;mode&quot; if you just try to open a directory with vim, eg. &lt;code&gt;vim foo/bar/baz/&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-03-09T01:07:52.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2434" PostTypeId="1" AcceptedAnswerId="2435" CreationDate="2015-03-09T02:09:50.810" Score="6" ViewCount="1162" Body="&lt;p&gt;I'm using &lt;code&gt;vim&lt;/code&gt; from a terminal emulator, and I'd like to be able to print using KDE's native print dialogue. This would let me select options such as printer, collating, number of copies and pages per piece of paper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(There is an older tip &lt;a href=&quot;http://vim.wikia.com/wiki/Printing_using_kprinter&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; explaining how to link vim with &lt;code&gt;kprinter&lt;/code&gt;, but this does not work, and I suspect &lt;code&gt;kprinter&lt;/code&gt; has been deprecated.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can &quot;print&quot; to a postscript file with &lt;code&gt;:ha &amp;gt; foo.ps&lt;/code&gt; (or &lt;code&gt;:hardcopy&lt;/code&gt;), then open this up with a GUI viewer, such as &lt;code&gt;okular&lt;/code&gt;, but is there a way to get directly to the print dialogue from &lt;code&gt;vim&lt;/code&gt;? (Also, I assume it's impossible, but can I open up a print preview window too?)&lt;/p&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="24" LastEditDate="2015-03-13T20:41:53.920" LastActivityDate="2020-07-22T00:31:43.023" Title="How can I print from vim using the native KDE print dialogue?" Tags="|linux|printing|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2435" PostTypeId="2" ParentId="2434" CreationDate="2015-03-09T02:33:20.840" Score="10" Body="&lt;p&gt;The loss of kprinter in the move to kde4 was one of the reasons I stuck with kde3 for as long as I could.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some searching, I found this &quot;3rd party&quot; replacement: &lt;a href=&quot;http://kde-apps.org/content/show.php/KPrinter4?content=163537&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://kde-apps.org/content/show.php/KPrinter4?content=163537&lt;/a&gt;, &lt;a href=&quot;https://github.com/credativ/kprinter4&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/credativ/kprinter4&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like you have to compile it yourself (Its not included in distros since it isn't core kde). The result works like the old one that came with kde3, but in the kde4 environment. It is used the same way, except the executable is called kprinter4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Some non-KDE alternatives are presented at the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried following the instructions at the vimwiki link you posted to use it, but I found those difficult to follow (too many escaped characters), so I based my vimrc on the function method found in &lt;code&gt;:help pexpr-option&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Building the executable&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This bit isn't about Vim, but is a prereq to the solution. I'm writing this with limited assumptions about your (or whoever else finds this answer useful) knowledge of building software.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Download the &quot;latest&quot; source to kprinter4 from the link above. I used &lt;a href=&quot;http://kde-apps.org/content/download.php?content=163537&amp;amp;id=1&amp;amp;tan=32050597&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://kde-apps.org/content/download.php?content=163537&amp;amp;id=1&amp;amp;tan=32050597&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Extract into some directory: &lt;code&gt;tar xf 163537-kprinter4-12.tar.xz&lt;/code&gt; (filename may be different for a newer version)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Cd into the source directory: &lt;code&gt;cd kprinter4-12&lt;/code&gt; (directory may be different in a newer version)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create a build directory and change into it: &lt;code&gt;mkdir build &amp;amp;&amp;amp; cd build&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run cmake. I used the options given at the kde-apps page, but changed the INSTALL_PREFIX such that I don't need to be administrator to install (but the install is only for me):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/john/opt/kprinter4 ..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The trailing &lt;code&gt;..&lt;/code&gt; is important. The INSTALL_PREFIX can be whatever you want, but it will be used in your vimrc (see below). You'll at least want to replace my username with your own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the command fails, it will probably tell you that you are missing libraries (for me it was missing LIBSPECTRE). Install whatever is missing and loop until cmake is successful. (e.g. in my case: &lt;code&gt;apt-get install libspectre-dev&lt;/code&gt;) Depending on your distro and setup, different commands and package names may be needed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run make: &lt;code&gt;make&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Install: &lt;code&gt;make install&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;Configure Vim&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I'm using the install path  from my sample isntructions above (which include my home directory). Change the paths as appropriate for your system (e.g. replacing my username with yours, or whatever you did for the INSTALL_PREFIX in the above section)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function PrintFile(fname)&#xA;   call system(&quot;/home/john/opt/kprinter4/bin/kprinter4 &quot; . a:fname)&#xA;   call delete(a:fname)&#xA;   return v:shell_error&#xA;endfunction&#xA;set printexpr=PrintFile(v:fname_in)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This creates a function that calls your newly built &lt;code&gt;kprinter4&lt;/code&gt; program and then cleans up the file whenever you run :hardcopy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, run &lt;code&gt;:hardcopy&lt;/code&gt; on a document and get a pretty printer selector:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XbFIR.png&quot; alt=&quot;Screenshot of kprinter4 on top of a vim session that had just run :hardcopy&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Non-KDE Alternatives&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Some Linux distributions provide &lt;code&gt;gpr&lt;/code&gt; and/or &lt;code&gt;gtklp&lt;/code&gt; (thanks @derobert and @Sparhawk for pointing out and testing these in the comments/chat)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;gpr&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Example for using gpr (presently available on Ubuntu but not Arch). Note that this errors on my system due to a missing PPD file or something. Your mileage may vary.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function PrintFile(fname)&#xA;   call system(&quot;gpr &quot; . a:fname)&#xA;   call delete(a:fname)&#xA;   return v:shell_error&#xA;endfunction&#xA;set printexpr=PrintFile(v:fname_in)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PhEOa.png&quot; alt=&quot;Screenshot of gpr after :hardcopy&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;gtklp&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Example for using gtklp (Available on both Ubuntu and Arch)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function PrintFile(fname)&#xA;   call system(&quot;gtklp &quot; . a:fname)&#xA;   call delete(a:fname)&#xA;   return v:shell_error&#xA;endfunction&#xA;set printexpr=PrintFile(v:fname_in)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2MAyF.png&quot; alt=&quot;Screenshot of gtklp after :hardcopy&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Alternative gtklp&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;At least one person has had an issue where gtklp on Arch Linux doesn't accept files specified on the command line. Below is an alternative method that works in that case (or in any case) that passes the contents of the file instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function PrintFile(fname)&#xA;   call system(&quot;cat &quot; . a:fname . &quot; | gtklp&quot;)&#xA;   call delete(a:fname)&#xA;   return v:shell_error&#xA;endfunction&#xA;set printexpr=PrintFile(v:fname_in)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jHbLD.png&quot; alt=&quot;Screenshot of gtklp after :hardcopy but with a pipe&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that with this method, gtklp doesn't even have a files tab displayed, but it does in fact print the document when &lt;code&gt;print&lt;/code&gt; is selected.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-03-13T04:07:28.330" LastActivityDate="2015-03-13T04:07:28.330" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="2436" PostTypeId="1" AcceptedAnswerId="2442" CreationDate="2015-03-09T07:10:42.350" Score="6" ViewCount="3035" Body="&lt;p&gt;I installed Cygwin/x on my PC, and I've set the terminal to xterm-256. But when I start vim from cygwin terminal, the look and feel of the same color scheme is different on cygwin and gvim. gvim always looks more pleasant, more clear. How can I make the look and feel of vim in cygwin be the same as gvim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/WhMkj.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="205" LastEditDate="2015-03-09T12:48:40.937" LastActivityDate="2015-05-28T11:04:35.217" Title="Why does the same color scheme look better in gvim than Cygwin?" Tags="|gvim|colorscheme|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2437" PostTypeId="2" ParentId="2410" CreationDate="2015-03-09T08:16:02.710" Score="28" Body="&lt;p&gt;This pattern will let you assign meaningful names to each argument, and provide a default value for any arguments that were not provided:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function FunctionName(foo, ...)&#xA;  let bar = a:0 &amp;gt;= 1 ? a:1 : 0&#xA;  let baz = a:0 &amp;gt;= 2 ? a:2 : 0&#xA;  ...&#xA;  &quot; Code that makes use of a:foo, bar and baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As pointed out by Boris Brodski:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;a:0&lt;/code&gt; counts the number of optional arguments passed&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;a:1&lt;/code&gt;, &lt;code&gt;a:2&lt;/code&gt;, ... let us access the optional arguments&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The mandatory arguments (just &lt;code&gt;foo&lt;/code&gt; in the example above) are not counted&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;condition ? result_if_true : result_if_false&lt;/code&gt; is the conditional (ternary) expression, which evaluates to the second or third term depending on whether the first term was true or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if no third argument is provided, &lt;code&gt;baz&lt;/code&gt; will take the default value of &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One concern with the above example is that &lt;code&gt;a:foo&lt;/code&gt; can &lt;strong&gt;only&lt;/strong&gt; be accessed with the &lt;code&gt;a:&lt;/code&gt; prefix, whilst &lt;code&gt;bar&lt;/code&gt; and &lt;code&gt;baz&lt;/code&gt; can do without a prefix.  Since this is not very consistent, you may prefer to pull out all of the arguments into local variables, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function FunctionName(...)&#xA;  let foo = a:1                  &quot; Will throw an error if no arg was provided&#xA;  let bar = a:0 &amp;gt;= 2 ? a:2 : 0&#xA;  let baz = a:0 &amp;gt;= 3 ? a:3 : 0&#xA;  ...&#xA;  &quot; Code that makes use of foo, bar and baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Technically, you can use the &lt;code&gt;l:&lt;/code&gt; prefix to refer to local variables inside a function, for example &lt;code&gt;l:baz&lt;/code&gt;, but this is redundant so I would not recommend it.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But I do recommend that you use this form whenever possible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:FunctionName(...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;!&lt;/code&gt; allows you to redefine your function at runtime (e.g. by reloading the script), and the &lt;code&gt;s:&lt;/code&gt; limits the function to script scope.  That avoids polluting the global namespace (and risking collision) if your function is only referenced from elsewhere inside the script. It is generally the preferred way to define functions when they do not need to be globally visible. ;-)&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2018-05-01T14:44:02.440" LastActivityDate="2018-05-01T14:44:02.440" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2438" PostTypeId="1" AcceptedAnswerId="2439" CreationDate="2015-03-09T08:27:05.690" Score="20" ViewCount="4986" Body="&lt;p&gt;Recently I learned from &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/1934356980&quot;&gt;Practical Vim&lt;/a&gt; a way to copy or move block of lines without having to move the cursor from the current position. This is done in command line mode. e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:123,133m.  # moves lines from 123 to 133 below the cursor position.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While I like it, it is a pain to type the long line numbers, especially when the file has too many lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At times, the lines to move are relatively near the cursor (but I don't want to move my cursor, yank, come back where I was, paste!). It would be great if I could use relative numbers, similar to how we do in normal mode. It is like saying &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;move 5 lines which are 10 lines above the current line to here&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In short, how to use relative numbers in command line mode (similar to normal mode)?&lt;/p&gt;&#xA;" OwnerUserId="1283" LastEditorUserId="205" LastEditDate="2015-03-09T13:44:05.637" LastActivityDate="2015-03-09T17:14:42.263" Title="How do I use relative line numbers in command line mode?" Tags="|command-line|line-numbers|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2439" PostTypeId="2" ParentId="2438" CreationDate="2015-03-09T08:36:43.367" Score="25" Body="&lt;p&gt;Assuming your lines span from 15 to 10 lines above the current one, you can achieve what you requested using relative line numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:-10,-15m.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately when specifying a backwards range, Vim asks you to confirm if that is what you really wanted. To avoid the confirmation step, you can type &lt;code&gt;silent&lt;/code&gt; before your command, or just specify a forwards range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:-15,-10m.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you might expect &lt;code&gt;+&lt;/code&gt; can be used to refer to lines below the current one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Detailed help can be found with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help cmdline-ranges&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-03-09T08:49:58.300" LastActivityDate="2015-03-09T08:49:58.300" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2440" PostTypeId="2" ParentId="2423" CreationDate="2015-03-09T08:51:02.183" Score="3" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://www.vim.org/script.php?script_id=746&quot; rel=&quot;nofollow&quot;&gt;cmdalias.vim - Create aliases for Vim commands&lt;/a&gt; plugin to override the &lt;code&gt;:suspend&lt;/code&gt; command with an empty one (e.g. &lt;code&gt;:echo&lt;/code&gt;), but because the overriding is done via command-line mappings, it will only work when typing the command interactively. If there's a &lt;code&gt;:suspend&lt;/code&gt; in a script / function, there's nothing that can disable that (except for disabling the command in the source code and compiling a special version of Vim yourself).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-09T08:51:02.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2441" PostTypeId="2" ParentId="2432" CreationDate="2015-03-09T08:53:42.590" Score="16" Body="&lt;p&gt;Alternatively (the passing of directory argument(s) as in @EvergreenTree's answer relies on the autocmds of the netrw plugin, and aren't a general solution), you can pass any Ex command to Vim on startup via the &lt;code&gt;-c&lt;/code&gt; argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -c Explore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;+&lt;/code&gt;, which is exactly the same as &lt;code&gt;-c&lt;/code&gt;, except slightly shorter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim +Explore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="51" LastEditDate="2015-03-09T15:35:26.707" LastActivityDate="2015-03-09T15:35:26.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2442" PostTypeId="2" ParentId="2436" CreationDate="2015-03-09T09:01:01.927" Score="8" Body="&lt;h3&gt;Cygwin terminal limitations&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The default Cygwin terminal is based on the Windows console and inherits its limitations (very few colors, no font styles like bold or italic). You can find out how many colors are available to Vim via&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set t_Co?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For me, that gives a meager &lt;code&gt;8&lt;/code&gt;. To get 256 colors, you need to use a terminal emulator that support high colors, e.g. PuTTY:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;putty.exe -ssh localhost&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Need colorscheme with terminal support&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Of course, all of this assumes you've chosen a colorscheme that actually supports color terminals. This is the case if the &lt;code&gt;:highlight&lt;/code&gt; output contains &lt;code&gt;ctermfg=&lt;/code&gt; / &lt;code&gt;ctermbg=&lt;/code&gt; definitions, not just ones starting with &lt;code&gt;gui&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if you have a GUI-only colorscheme (but you like it)? Plugins like &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2390&quot; rel=&quot;nofollow&quot;&gt;CSApprox&lt;/a&gt; can take the GUI color definitions and convert them to a closely matching 256-color &lt;code&gt;cterm&lt;/code&gt; color palette for high-color terminals. This helps with colorschemes that otherwise only pick from the bland default 16-color terminal color palette, or only provide GUI color definitions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is taken by &lt;a href=&quot;https://github.com/KevinGoodsell/vim-csexact&quot; rel=&quot;nofollow&quot;&gt;csexact&lt;/a&gt;, which modifies the (supported) terminal's palette to exactly match Vim's GUI colors.&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2015-05-28T11:04:35.217" LastActivityDate="2015-05-28T11:04:35.217" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2443" PostTypeId="2" ParentId="2438" CreationDate="2015-03-09T09:04:17.277" Score="3" Body="&lt;p&gt;You can use relative addressing (e.g. &lt;code&gt;.-10,.+3&lt;/code&gt;) with any Ex command, cp. &lt;code&gt;:help :range&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, have a look at my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4140&quot; rel=&quot;nofollow&quot;&gt;LineJuggler plugin&lt;/a&gt;; it provides several short mappings to move lines around or duplicate them, and all those mappings take a relative line offset as &lt;code&gt;[count]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-09T09:04:17.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2444" PostTypeId="1" AcceptedAnswerId="2448" CreationDate="2015-03-09T12:48:00.410" Score="2" ViewCount="134" Body="&lt;p&gt;When motion &lt;code&gt;ge&lt;/code&gt; is used with an operator, such as &lt;code&gt;d&lt;/code&gt;, the operator acts not only on the current character (which is just inconvenient -- i would prefer that the current character be excluded), but also on the last character of the previous word, which in most cases makes the operation useless. Is this behavior a bug? There is no explanation in Vim's help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a workaround, i plan to set&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap ge ?\&amp;gt;&amp;lt;CR&amp;gt;&#xA;noremap gE ?\&amp;gt;\s&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1248" LastEditorUserId="1248" LastEditDate="2015-03-09T15:52:03.127" LastActivityDate="2015-03-10T17:40:29.690" Title="Is the current behavior of `ge` in Operator-pending mode a bug?" Tags="|cursor-movement|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2445" PostTypeId="2" ParentId="2432" CreationDate="2015-03-09T15:20:37.360" Score="2" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +Ex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It'll execute &lt;code&gt;:Ex&lt;/code&gt; (&lt;code&gt;:Explore&lt;/code&gt;) on vim startup to explore the current directory.&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-03-09T15:20:37.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2446" PostTypeId="1" CreationDate="2015-03-09T16:45:26.397" Score="1" ViewCount="718" Body="&lt;p&gt;In college sometimes we are not allowed to use MS Word (because we cant use autocorrect or the red underline) and I also want to use VIM so I can type quicker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way how I can make and edit rich text documents while having access to things such as centurial text, bold, underline and colour etc.?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have looked at &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1432&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; plugin but I am not sure if it does what I want and if so how to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="51" LastEditDate="2015-04-30T11:41:43.317" LastActivityDate="2015-04-30T11:41:43.317" Title="Editing rich text document (.rtf)" Tags="|external-command|file-formats|" AnswerCount="0" CommentCount="2" ClosedDate="2015-03-11T02:58:24.027" ContentLicense="CC BY-SA 3.0" />
  <row Id="2447" PostTypeId="2" ParentId="2438" CreationDate="2015-03-09T17:14:42.263" Score="13" Body="&lt;p&gt;You can use hard numbers in your range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:200,300command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or relative numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:-27,+46command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or manual marks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'a,'bcommand&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or automatic marks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'[,'&amp;gt;command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or searches:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:?foo?,/bar/command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or line shortcuts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,$command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or any combination of the tricks above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:?foo?,+46command&#xA;:'a,$command&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-03-09T17:14:42.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2448" PostTypeId="2" ParentId="2444" CreationDate="2015-03-09T17:22:11.517" Score="6" Body="&lt;p&gt;I wouldn't call it a bug. Looking at &lt;code&gt;:h ge&lt;/code&gt; this is said:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ge                      Backward to the end of word [count] inclusive.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now let's see what inclusive means &lt;code&gt;:h inclusive&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A character motion is either inclusive or exclusive.  When inclusive, the&#xA;start and end position of the motion are included in the operation.  When&#xA;exclusive, the last character towards the end of the buffer is not&#xA;included. Linewise motions always include the start and end position.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means, that ge will always include the character further to the beginning of the document, e.g. where the cursor jumps to. You can force it to be exclusive using the &lt;code&gt;v&lt;/code&gt; modifier (&lt;code&gt;:h o_v&lt;/code&gt;). But that means in this case only that the starting point will be excluded from the operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I gues what what you want, is something more like this map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:onoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;ge  :norm! ge &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will make it exclusive to the char where the cursor jumps to (e.g. the beginning of the visual selection). If you want both ends to be exclusive, you can use this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:onoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;ge  :norm! vge oh&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, that both mappings depend on your &lt;code&gt;'selection'&lt;/code&gt; option to be at the default of &lt;code&gt;inclusive&lt;/code&gt;. For a truly robust mapping, you would have to save and restore that option and use a mapping that works under a defined option value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the mapping make use of a count, something like this should do it. (For better understandability let's make use of a function):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! MyCustomGE()&#xA;    return &quot;\&amp;lt;c-u&amp;gt;:norm! &quot;.v:count1.&quot;ge &quot;&#xA;endfu&#xA;onoremap &amp;lt;leader&amp;gt;ge :&amp;lt;c-u&amp;gt;&amp;lt;c-r&amp;gt;=MyCustomGE()&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you can use &lt;code&gt;ge&lt;/code&gt; for the standard Vim behaviour and &lt;code&gt;&amp;lt;Leader&amp;gt;ge&lt;/code&gt; for your special case. See &lt;code&gt;:h &amp;lt;Leader&amp;gt;&lt;/code&gt; for the Leader key (default backslash)&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-03-10T17:40:29.690" LastActivityDate="2015-03-10T17:40:29.690" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="2449" PostTypeId="2" ParentId="2428" CreationDate="2015-03-09T18:55:37.400" Score="7" Body="&lt;p&gt;A similar question was just asked on the Vim reddit &lt;a href=&quot;http://www.reddit.com/r/vim/comments/2yg5ss/has_your_ctrlp_gotten_slow_change_the_indexer_and/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. I started using &lt;a href=&quot;https://github.com/JazzCore/ctrlp-cmatcher/&quot; rel=&quot;noreferrer&quot;&gt;ctrlp-cmatcher&lt;/a&gt;  myself quite awhile ago which I find to be much more intelligent at matching the right file. Note that it does require a compiled component. Otherwise you'll have to try some of the approaches in the &lt;a href=&quot;http://blog.patspam.com/2014/super-fast-ctrlp&quot; rel=&quot;noreferrer&quot;&gt;article&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19" LastActivityDate="2015-03-09T18:55:37.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2450" PostTypeId="2" ParentId="2423" CreationDate="2015-03-09T19:49:20.787" Score="3" Body="&lt;p&gt;Looking at the source code, there doesn't seem to be a way to prevent Vim from suspending if the &lt;code&gt;:suspend&lt;/code&gt; command is executed. See &lt;a href=&quot;https://vi.stackexchange.com/a/2440&quot;&gt;Ingo Karkat's answer&lt;/a&gt; for a discussion of how to prevent the command from being executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless, that is, one changes the Vim binary. Write the following code to a file &lt;code&gt;override_kill.c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define _GNU_SOURCE&#xA;#include &amp;lt;dlfcn.h&amp;gt;&#xA;#include &amp;lt;signal.h&amp;gt;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;sys/types.h&amp;gt;&#xA;#include &amp;lt;unistd.h&amp;gt;&#xA;int kill(pid_t pid, int sig) {&#xA;    int (*original_kill)(pid_t, int) = dlsym(RTLD_NEXT, &quot;kill&quot;);&#xA;    if (pid == 0 &amp;amp;&amp;amp; sig == SIGSTOP) {&#xA;        /*Don't suspend, initiate resuming*/&#xA;        original_kill(0, SIGCONT);&#xA;        return 0;&#xA;    } else {&#xA;        return original_kill(pid, sig);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Compile with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gcc -O -Wall -fPIC -shared -o override_kill.so override_kill.c -dl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of directly running Vim from a terminal emulator, run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;env LD_PRELOAD=/path/to/override_kill.so vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will go through the motions of suspending but immediately resume execution. (Only on a terminal: the GUI version will iconify as usual.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only tested under Linux; this probably works under most Unix-like operating system, except that they may require different compiler options. OSX should work with &lt;code&gt;DYLD_PRELOAD&lt;/code&gt; instead of &lt;code&gt;LD_PRELOAD&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This technique cannot be generalize to overriding arbitrary commands: only library calls can be overridden this way, not calls to functions that are internal to the Vim binary. (That's why the modified program still goes through the motions and only the actual suspension is overridden.)&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-03-09T19:49:20.787" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2451" PostTypeId="2" ParentId="2436" CreationDate="2015-03-09T20:23:18.000" Score="3" Body="&lt;p&gt;When I started with Vim something that droves me crazy was this issue, I see pretty colors on gVim but ugly ones on vim in the console. What you need to know is that in the color schemes there are special params defined for console and for GUI. This is because basic limitations on the colors that common consoles can display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, look at this line in the github color scheme:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi LineNr   ctermfg=246 ctermbg=15 guifg=#959595 guibg=#ECECEC gui=bold cterm=bold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means that it will display a &quot;more precise&quot; color for the background on gui (look at guibg=#ECECEC) than on console vim (just a plain almost white &quot;15&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe this doesn't resolve your issue, but you should understand this point about Vim on console versus on GUI.&lt;/p&gt;&#xA;" OwnerUserId="515" LastActivityDate="2015-03-09T20:23:18.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2452" PostTypeId="2" ParentId="2428" CreationDate="2015-03-09T20:35:44.070" Score="4" Body="&lt;p&gt;CtrlP has a few different modes, &lt;code&gt;Ctrl-R&lt;/code&gt; and &lt;code&gt;Ctrl-D&lt;/code&gt;. &lt;code&gt;Ctrl-R&lt;/code&gt; uses your input as raw Regex, meaning you'll only find matches with &lt;code&gt;people&lt;/code&gt; in it explicitly. &lt;code&gt;Ctrl-D&lt;/code&gt; matches only the filename, ignoring the path. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe the default CtrlP functionality is just joining &lt;code&gt;.*&lt;/code&gt; to every character as a raw character, so a period is treated as a period. If you knew in advance the file was at least 2 directories deep, you could do &lt;code&gt;//people&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="488" LastActivityDate="2015-03-09T20:35:44.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2453" PostTypeId="1" AcceptedAnswerId="2456" CreationDate="2015-03-09T20:57:09.437" Score="3" ViewCount="151" Body="&lt;p&gt;One thing I need to do frequently is to increment the &lt;em&gt;2nd&lt;/em&gt; number on a line. Increasing the first is very comfortable by just pressing &lt;kbd&gt;Control-a&lt;/kbd&gt;, but I just can't find a nice way to increase the 2nd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no useful substring (as in, a word or a token or whatever) in that line that I can use for searches or jumps by text objects.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="51" LastEditDate="2015-03-09T20:59:16.493" LastActivityDate="2015-03-09T23:45:59.003" Title="How to increase the 2nd number on a line" Tags="|key-bindings|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2454" PostTypeId="2" ParentId="2453" CreationDate="2015-03-09T21:03:30.610" Score="2" Body="&lt;p&gt;I'm not sure if this is the 'best' way, but 'a' way would be to create a mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Leader&amp;gt;a ^/\d\+&amp;lt;CR&amp;gt;n&amp;lt;C-a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; to go to the start of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/\d+&amp;lt;CR&amp;gt;&lt;/code&gt; to search for the first number&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt; to go to the next (second) match&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; to increment the number under the cursor, which should be the second number now.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Or perhaps a slightly better way is to use a script&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! IncSecond()&#xA;    normal ^&#xA;    call search('\d\+')&#xA;    call search('\d\+')&#xA;    execute &quot;normal \&amp;lt;C-a&amp;gt;&quot;&#xA;endfun&#xA;noremap &amp;lt;Leader&amp;gt;a :call IncSecond()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Calling &lt;code&gt;search()&lt;/code&gt; doesn't set the &lt;code&gt;/&lt;/code&gt; register and doesn't start highlighting if you have &lt;code&gt;hlsearch&lt;/code&gt; set.&lt;br&gt;&#xA;You could cram those lines in a keybind without a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Leader&amp;gt;a ^&amp;lt;Bar&amp;gt;:call search('\d\+')&amp;lt;Bar&amp;gt;:call search('\d\+')&amp;lt;Bar&amp;gt;:execute &quot;normal \&amp;lt;C-a&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I would go for the readability of the function...&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-03-09T21:27:05.670" LastActivityDate="2015-03-09T21:27:05.670" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2455" PostTypeId="1" AcceptedAnswerId="2458" CreationDate="2015-03-09T23:36:05.547" Score="29" ViewCount="6623" Body="&lt;p&gt;I'm learning Vim by watching screencasts. And I'm wondering, why do a lot of&#xA;people use gVim or MacVim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I can see, the GUI Vim version only have additional features that&#xA;involves using mouse. But isn't this against the &quot;Vim philosophy&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain what additional features the GUI Vim version offer versus the&#xA;terminal-based Vim?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="51" LastEditDate="2015-03-10T00:35:14.900" LastActivityDate="2021-03-18T07:29:28.347" Title="What additional features do gVim and/or MacVim offer compared to Vim inside a terminal emulator?" Tags="|gvim|macvim|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2456" PostTypeId="2" ParentId="2453" CreationDate="2015-03-09T23:45:59.003" Score="3" Body="&lt;p&gt;I mean, it's basically a hack, but assuming you're at the start of the line with the number on it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-A&amp;gt;&amp;lt;C-X&amp;gt;w&amp;lt;C-A&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Go to the next number, increment it, decrement it, go to the start of the next word, increment the next number. This jumps past and increments the second number. Unfortunately it's not easy to chain as you need to repeat most of the keys again.&lt;/p&gt;&#xA;" OwnerUserId="488" LastActivityDate="2015-03-09T23:45:59.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2457" PostTypeId="2" ParentId="2455" CreationDate="2015-03-10T01:08:54.600" Score="5" Body="&lt;p&gt;I just can talk about gVim. Besides basic differences, I found that using gVim help me a lot at the beginning to learn basic commands (for example one way of copying selected text to the clipboard with &quot;+y) by reading each of the shortcuts displayed on the menu. It may sound silly, but you really should spend some time traversing the menu and not just click on an item, but to actually test the shortcut it shows. Personal opinion.&lt;/p&gt;&#xA;" OwnerUserId="515" LastActivityDate="2015-03-10T01:08:54.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2458" PostTypeId="2" ParentId="2455" CreationDate="2015-03-10T02:12:04.083" Score="37" Body="&lt;p&gt;Some features that will &lt;em&gt;only&lt;/em&gt; work with gVim:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;24-bit color support out of the box (to get the same amount of colors in terminal vim, you have to try a little harder, see &lt;a href=&quot;https://superuser.com/questions/556480/24-bit-true-color-in-konsole/703891#703891&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;https://gist.github.com/XVilka/8346728&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt;). For true italics, the same holds true (see &lt;a href=&quot;https://www.reddit.com/r/vim/comments/24g8r8/italics_in_terminal_vim_and_tmux/&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;https://jsatk.us/vim-tmux-italics-and-insanity-9a96b69eeca6&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt;). Note that you should be using a font that supports true italics.&lt;/li&gt;&#xA;&lt;li&gt;Some other more advanced graphical features, such as &amp;quot;wiggly lines&amp;quot; for spell checking, more flexible cursor shapes, etc. A terminal can only do &amp;quot;blocks of monospaced characters&amp;quot;.&lt;/li&gt;&#xA;&lt;li&gt;Enables &lt;a href=&quot;http://vimhelp.appspot.com/gui.txt.html#gui-mouse&quot; rel=&quot;noreferrer&quot;&gt;mouse support&lt;/a&gt;, if otherwise left alone (including &lt;a href=&quot;http://vimhelp.appspot.com/gui.txt.html#drag-n-drop&quot; rel=&quot;noreferrer&quot;&gt;drag-and-drop&lt;/a&gt; for files). Terminal Vim can also handle the mouse quite well, but not drag-and-drop.&lt;/li&gt;&#xA;&lt;li&gt;Offers a nice, &lt;a href=&quot;http://vimhelp.appspot.com/gui.txt.html#creating-menus&quot; rel=&quot;noreferrer&quot;&gt;customizable&lt;/a&gt; menu system, where each option has the corresponding Vim command listed.&lt;/li&gt;&#xA;&lt;li&gt;gVim can offer you scrollbars which scroll the Vim buffer (and not the Terminal scrollback).&lt;/li&gt;&#xA;&lt;li&gt;You can have popup &lt;a href=&quot;https://stackoverflow.com/q/8534055/660921&quot;&gt;&amp;quot;balloons&amp;quot;&lt;/a&gt; (aka. &amp;quot;tooltips&amp;quot;).&lt;/li&gt;&#xA;&lt;li&gt;Has &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27guifont%27&quot; rel=&quot;noreferrer&quot;&gt;integrated font support&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Some keybindings work out of the box with gVim like &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;Space&lt;/kbd&gt;, &lt;kbd&gt;Meta&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt;... while they require more tweaking of the terminal in the other case.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/options.txt.html#%27guioptions%27&quot; rel=&quot;noreferrer&quot;&gt;Autoselect&lt;/a&gt;: If set, any visual selection is automatically yanked to primary/clipboard.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Secondly, even if you prefer using Vim, installing a GUI version may offer more compile-time features than the version without, at least in some distros (such as &lt;code&gt;clipboard&lt;/code&gt; and &lt;code&gt;clientserver&lt;/code&gt; support on Debian-based system in &lt;code&gt;vim-nox&lt;/code&gt; vs &lt;code&gt;vim-gnome&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Also, under Windows, a gVim window can be resized more easily than a console Vim window.&lt;/p&gt;&#xA;&lt;p&gt;Things gVim &lt;strong&gt;doesn't&lt;/strong&gt; do:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;:!&lt;/code&gt; ex command in gVim doesn't offer a (full) terminal emulator, so starting external programs that use a lot of terminal features won't work very well. For example try using &lt;code&gt;:!vim&lt;/code&gt;, &lt;code&gt;:!mutt&lt;/code&gt;, or &lt;code&gt;:!irssi&lt;/code&gt; from gVim, or pressing &lt;kbd&gt;K&lt;/kbd&gt; over a word (which, by default, opens the manpage for that word). Also &lt;a href=&quot;https://vi.stackexchange.com/q/4152/51&quot;&gt;see this&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;However, if you need such a feature, you can use the &lt;code&gt;:terminal&lt;/code&gt; command to run a shell (or other external commands) from within vim. This needs at least a Vim version &lt;a href=&quot;https://www.vim.org/vim-8.1-released.php&quot; rel=&quot;noreferrer&quot;&gt;8.1&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="71" LastEditDate="2021-03-18T07:29:28.347" LastActivityDate="2021-03-18T07:29:28.347" CommentCount="6" CommunityOwnedDate="2015-03-10T14:45:38.313" ContentLicense="CC BY-SA 4.0" />
  <row Id="2459" PostTypeId="2" ParentId="2455" CreationDate="2015-03-10T02:52:41.650" Score="6" Body="&lt;p&gt;Some of us are stuck in Windows land, so the terminal options are less convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Windows Explorer you can right-click a file and open it immediately with gVim. That's a lot easier and faster than opening a terminal (cygwin or whatever), navigating to the directory, and vimming the file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(On my work PC, gVim and MinGW bash cover most of my editing needs)&lt;/p&gt;&#xA;" OwnerUserId="398" LastActivityDate="2015-03-10T02:52:41.650" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2460" PostTypeId="1" CreationDate="2015-03-10T06:28:09.157" Score="2" ViewCount="4779" Body="&lt;p&gt;I've set up cygwin on my PC, now I want to configure vim to use solarized color scheme. I'm following the github page: &lt;a href=&quot;https://github.com/altercation/vim-colors-solarized&quot; rel=&quot;nofollow&quot;&gt;https://github.com/altercation/vim-colors-solarized&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;there's a section: IMPORTANT NOTE FOR TERMINAL USERS in the page, advising the terminal user better to use the solarized palette. But after reading, I still don't have a clue how to do it. Could some help here?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="51" LastEditDate="2015-06-26T08:08:49.367" LastActivityDate="2015-06-26T08:08:49.367" Title="How to set my terminal to use solarized palette?" Tags="|terminal|colorscheme|plugin-solarized|" AnswerCount="1" CommentCount="2" ClosedDate="2015-03-10T15:41:57.427" ContentLicense="CC BY-SA 3.0" />
  <row Id="2461" PostTypeId="2" ParentId="2460" CreationDate="2015-03-10T07:07:02.413" Score="3" Body="&lt;p&gt;That part of the documentation explains it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I've included palettes for some popular terminal emulator as well as Xdefaults in the official Solarized download available from &lt;a href=&quot;http://ethanschoonover.com/solarized&quot; rel=&quot;nofollow&quot;&gt;Solarized homepage&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need to use one of &lt;a href=&quot;https://github.com/altercation/solarized&quot; rel=&quot;nofollow&quot;&gt;these palettes&lt;/a&gt; depending on the terminal client you're using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is unrelated to vim.&lt;/p&gt;&#xA;" OwnerUserId="1300" LastActivityDate="2015-03-10T07:07:02.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2462" PostTypeId="1" AcceptedAnswerId="2463" CreationDate="2015-03-10T08:01:02.710" Score="23" ViewCount="7086" Body="&lt;p&gt;Is there a way I can move my cursor to the middle of the current line? By middle, I don't mean the middle of the screen, but the middle of the line of text, regardless of length.&lt;/p&gt;&#xA;&lt;p&gt;The shortcut &lt;kbd&gt;M&lt;/kbd&gt; moves the cursor to the middle of the screen - is there an equivalent shortcut to move the cursor to the middle of the line?&lt;/p&gt;&#xA;" OwnerUserId="53" LastEditorUserId="21251" LastEditDate="2021-07-11T16:27:31.380" LastActivityDate="2021-07-11T16:29:02.357" Title="How do I move the cursor to the center of current line?" Tags="|cursor-movement|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2463" PostTypeId="2" ParentId="2462" CreationDate="2015-03-10T08:55:29.887" Score="16" Body="&lt;p&gt;I don't know of any builtin ways to do this. However, you can easily make a map to do it:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap µ :exe 'normal! '.(virtcol('$')/2).'\|'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Ingo Karkat proposed the following variant &lt;a href=&quot;https://vi.stackexchange.com/questions/2462/how-do-i-move-the-cursor-to-the-center-of-current-line#comment4560_2463&quot;&gt;in the comments&lt;/a&gt; that also works in visual mode.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;expr&amp;gt; gM (virtcol('$') / 2) . '&amp;lt;Bar&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Unfortunately, it's also triggered in select mode. As a consequence, I prefer using two mappings, one for each mode:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; gM (virtcol('$') / 2) . '&amp;lt;Bar&amp;gt;'&#xA;xnoremap &amp;lt;expr&amp;gt; gM (virtcol('$') / 2) . '&amp;lt;Bar&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="21251" LastEditDate="2021-07-11T16:28:15.227" LastActivityDate="2021-07-11T16:28:15.227" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2464" PostTypeId="1" CreationDate="2015-03-10T09:30:43.373" Score="1" ViewCount="443" Body="&lt;p&gt;I'm using vim in cygwin, I want to use &lt;a href=&quot;https://github.com/maksimr/vim-jsbeautify&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/maksimr/vim-jsbeautify&lt;/a&gt; to format my javascript code.&#xA;but whenever I use &lt;code&gt;:call JsBeautify()&lt;/code&gt;, there's an error thrown:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E117: Unknown function:JsBeautify&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whenever I press the keys I mapped for calling JsBeautify, following error occurs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/D9iw6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="51" LastEditDate="2015-03-10T09:33:32.800" LastActivityDate="2016-02-04T07:28:43.180" Title="Why vim-jsbeautify cannot find module?" Tags="|filetype-javascript|plugin-vim-jsbeautify|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2465" PostTypeId="2" ParentId="2462" CreationDate="2015-03-10T10:00:06.080" Score="4" Body="&lt;p&gt;To add to Luc's answer, there's also the &lt;a href=&quot;https://github.com/Lokaltog/vim-easymotion&quot; rel=&quot;nofollow&quot;&gt;Easymotion&lt;/a&gt; plugin, which makes moving quickly to a specific position a breeze. Pressing &lt;code&gt;&amp;lt;Leader&amp;gt;&amp;lt;Leader&amp;gt;w&lt;/code&gt; will highlight which key you can press to move to a specific word. That way you could easily move to a word in the middle of the current line.&lt;/p&gt;&#xA;" OwnerUserId="1301" LastActivityDate="2015-03-10T10:00:06.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2466" PostTypeId="1" AcceptedAnswerId="2467" CreationDate="2015-03-10T11:21:47.877" Score="26" ViewCount="23352" Body="&lt;p&gt;I have vim 7.4 installed, but I'm not sure what patch level it was at when I installed it. How do I check?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Gives &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 15 2014 16:18:44)&#xA;....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't give the patch level or a minor version number.&lt;/p&gt;&#xA;" OwnerUserId="1111" LastActivityDate="2015-03-10T12:40:29.710" Title="How do I know the patch version of my vim?" Tags="|version|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2467" PostTypeId="2" ParentId="2466" CreationDate="2015-03-10T11:31:57.367" Score="32" Body="&lt;p&gt;You seem to simply have an unpatched version of vim, otherwise the &lt;code&gt;:version&lt;/code&gt; command or the &lt;code&gt;--version&lt;/code&gt; parameter would list the patches on the second line. For example on my machine it says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep 10 2014 09:36:33)&#xA;Included patches: 1-207, 209-355, 357-430&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is &quot;patchlevel&quot; 430, but it skips patches 208 &amp;amp; 356.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim doesn't have a &quot;minor version number&quot; beyond &lt;em&gt;major.minor&lt;/em&gt;; although I believe that some distributions may use the &quot;patchlevel&quot; as such.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As shown above, not all patches may be included, so if you want to use this value you can't just check if a number is higher than a certain version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually, the best way is to use &lt;code&gt;has(&quot;patch-7.4-399&quot;)&lt;/code&gt;; this will return true if:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We're running Vim 7.4 with patch 399 included.&lt;/li&gt;&#xA;&lt;li&gt;We're running Vim 7.5 or later.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can also use the form of &lt;code&gt;has('patch399')&lt;/code&gt;, which is typically used like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if v:version == 704 &amp;amp;&amp;amp; has('patch399')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But be aware; this will be &lt;em&gt;false&lt;/em&gt; for Vim 7.5; use this only in very specific cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#feature-list&quot;&gt;&lt;code&gt;:help feature-list&lt;/code&gt;&lt;/a&gt; for some more information.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I can't find a way to list all the included patches, other than redirecting &lt;code&gt;:version&lt;/code&gt; and parsing that ... I'm also not sure how this would be useful anyway, as &lt;code&gt;has()&lt;/code&gt; should be enough :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="1111" LastEditDate="2015-03-10T12:40:29.710" LastActivityDate="2015-03-10T12:40:29.710" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2468" PostTypeId="2" ParentId="2455" CreationDate="2015-03-10T11:41:34.677" Score="1" Body="&lt;p&gt;To add a trivial thing: When using gvim, the window list of my Desktop shows a nice Vim-symbol rather then an Xterm-symbol, which makes it easier to switch to the editor if a lot of xterms are open.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastActivityDate="2015-03-10T11:41:34.677" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2469" PostTypeId="2" ParentId="2462" CreationDate="2015-03-10T13:26:13.377" Score="23" Body="&lt;p&gt;The built-in &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#gm&quot;&gt;&lt;code&gt;gm&lt;/code&gt;&lt;/a&gt; does exactly this.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-03-10T13:26:13.377" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2470" PostTypeId="1" AcceptedAnswerId="2472" CreationDate="2015-03-10T13:59:31.367" Score="1" ViewCount="968" Body="&lt;p&gt;I learned about &lt;a href=&quot;https://vi.stackexchange.com/a/189/1111&quot;&gt;using &lt;code&gt;:profile&lt;/code&gt; here&lt;/a&gt;, so I just tried to install vim with profiling enabled. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --prefix=/home/username --with-features=profile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in the output from configure I got the message&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sorry, profile is not supported&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does that mean that profile is not an option for me at all because of my OS, or is there something that I can do to make it &quot;supported&quot;?&lt;/p&gt;&#xA;" OwnerUserId="1111" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-03-10T14:49:48.753" Title="How do I enable profile in vim?" Tags="|installing|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2471" PostTypeId="2" ParentId="2470" CreationDate="2015-03-10T14:46:55.380" Score="2" Body="&lt;p&gt;&lt;code&gt;--with-features=profile&lt;/code&gt; doesn't seem to be valid option; &lt;code&gt;:help profile&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The +profile feature is required for this. It is only included when Vim was compiled with &quot;huge&quot; features.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ./configure --with-features=huge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-03-10T14:46:55.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2472" PostTypeId="2" ParentId="2470" CreationDate="2015-03-10T14:49:48.753" Score="5" Body="&lt;p&gt;I don't think you can enable the &lt;em&gt;profile&lt;/em&gt; feature via &lt;code&gt;./configure&lt;/code&gt;; you either have to define &lt;code&gt;FEAT_PROFILE&lt;/code&gt; or simply build a &lt;em&gt;huge&lt;/em&gt; version of Vim, which then includes that feature. From &lt;code&gt;src/feature.h&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;* +profile      Profiling for functions and scripts.&#xA;*/&#xA;#if defined(FEAT_HUGE) \&#xA;        &amp;amp;&amp;amp; defined(FEAT_EVAL) \&#xA;        &amp;amp;&amp;amp; ((defined(HAVE_GETTIMEOFDAY) &amp;amp;&amp;amp; defined(HAVE_SYS_TIME_H)) \&#xA;                || defined(WIN3264))&#xA;# define FEAT_PROFILE&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;TL;DR&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --with-features=huge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-10T14:49:48.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2473" PostTypeId="1" CreationDate="2015-03-10T14:58:30.297" Score="3" ViewCount="2959" Body="&lt;p&gt;Let us say we have the following &lt;code&gt;for&lt;/code&gt; loop in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; len; ++i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to change the variable &lt;code&gt;i&lt;/code&gt; to &lt;code&gt;j&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to do it manually for each &lt;code&gt;i&lt;/code&gt;. Is there a way in Vim so that when I change one &lt;code&gt;i&lt;/code&gt;, and it also changes the rest?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use ultisnips and when I create a &lt;code&gt;for&lt;/code&gt; loop for example, I am able to change all &lt;code&gt;i&lt;/code&gt;'s at the same time, but I would also like to do that even once I'm done with the snippet. Is that possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've just realized what I should have asked instead for was a way to refactor the code like you can do in an IDE, but from what I can see this is not possible with vim, nonetheless, I appreciate all the useful tips for doing so in vim.&lt;/p&gt;&#xA;" OwnerUserId="1305" LastEditorUserId="23502" LastEditDate="2022-10-31T17:29:06.737" LastActivityDate="2022-10-31T17:29:06.737" Title="Changing multiple instances of a local variable at the same time" Tags="|substitute|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2474" PostTypeId="2" ParentId="2473" CreationDate="2015-03-10T15:07:49.383" Score="3" Body="&lt;p&gt;You could do it with a substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5,20s/\&amp;lt;i\&amp;gt;/j/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;5,20&lt;/code&gt;: Between lines 5 and 20,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s&lt;/code&gt;: substitute,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/\&amp;lt;i\&amp;gt;/&lt;/code&gt; all instances of the &lt;em&gt;word&lt;/em&gt; i (the &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; match word boundaries,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; with the letter j,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/g&lt;/code&gt;: everywhere in the line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you don't want to use line numbers, you could instead first select the area where you want to make the substitution in visual mode, and then Vim will pre-populate the command line with a range specifying the selection when you press &lt;code&gt;:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to make the replacement &lt;em&gt;everywhere&lt;/em&gt; in the current buffer, you can use the &lt;code&gt;%&lt;/code&gt; range, instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\&amp;lt;i\&amp;gt;/j/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2015-03-10T15:13:17.777" LastActivityDate="2015-03-10T15:13:17.777" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2475" PostTypeId="2" ParentId="2473" CreationDate="2015-03-10T15:09:18.243" Score="5" Body="&lt;p&gt;You can use the &lt;code&gt;:substitute&lt;/code&gt; command (optionally with a suitable &lt;code&gt;[range]&lt;/code&gt; if the loop variable is spread over multiple lines) with the &lt;code&gt;g&lt;/code&gt; flag to replace all occurrences:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\&amp;lt;i\&amp;gt;/j/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;\&amp;lt;...\&amp;gt;&lt;/code&gt; for a &lt;em&gt;full word&lt;/em&gt; match (to avoid changing &lt;code&gt;int&lt;/code&gt; to &lt;code&gt;jnt&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Plugin suggestion&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4321&quot; rel=&quot;noreferrer&quot;&gt;ChangeGlobally plugin&lt;/a&gt; provides a &lt;code&gt;gc{motion}&lt;/code&gt; command that works like built-in &lt;code&gt;c&lt;/code&gt;hange, but then applies that change to all other occurrences in the line. With it, your example can be edited via &lt;code&gt;^Wgclj&amp;lt;Esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-10T15:09:18.243" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2476" PostTypeId="1" AcceptedAnswerId="2477" CreationDate="2015-03-10T15:41:05.873" Score="3" ViewCount="171" Body="&lt;p&gt;In Debian packaging, a version number looks like: &lt;code&gt;x:y~z&lt;/code&gt;, where &lt;code&gt;x&lt;/code&gt; is called the epoch. According to &lt;a href=&quot;https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version&quot; rel=&quot;nofollow&quot;&gt;the Debian policy&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It is provided to allow mistakes in the version numbers of older versions of a package, and also a package's previous version numbering schemes, to be left behind.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;While looking at the Debian packages of Vim, I noticed that they used an epoch number as well. What was surprising is that the epoch number was 2, indicating that it had changed twice. What happened during these changes? Were they a purely Debian change, not related to an upstream one?&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="24" LastEditDate="2015-03-19T21:26:01.220" LastActivityDate="2015-03-19T21:26:01.220" Title="Did Vim ever use a different versioning scheme?" Tags="|history-of|version|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2477" PostTypeId="2" ParentId="2476" CreationDate="2015-03-10T16:57:41.657" Score="6" Body="&lt;p&gt;Yes, they were both caused by changes to the packaging and unrelated to Vim itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first epoch bump (since all packages without an explicit epoch have an implicit 0 epoch) was introduced when the versioning of the package changed from &lt;code&gt;x.y.patch-debrev&lt;/code&gt; to &lt;code&gt;x.y-patch+debrev&lt;/code&gt; (i.e., &lt;code&gt;6.1.263-2&lt;/code&gt; to &lt;code&gt;6.1-266+1&lt;/code&gt;).  The latter sorts earlier than the former, so the epoch was needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second epoch bump was introduced due to another change in how the packages were versioned.  This time it was related to versioning of pre-releases for major Vim releases.  Initially they were being versioned as &lt;code&gt;x.y.patch~snapshot-debrev&lt;/code&gt; but then it changed to &lt;code&gt;x.ysnapshot.patch-debrev&lt;/code&gt; (&lt;code&gt;1:7.2.0~a-1&lt;/code&gt; to &lt;code&gt;2:7.2b.001-1&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-03-10T16:57:41.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2478" PostTypeId="2" ParentId="2473" CreationDate="2015-03-10T17:48:08.243" Score="3" Body="&lt;p&gt;It's not really a good example, but you can make use of the &lt;code&gt;gn&lt;/code&gt; operation, if you do not want to use the &lt;code&gt;:s&lt;/code&gt; solution suggested above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First search for your variable &lt;code&gt;/\&amp;lt;i\&amp;gt;&lt;/code&gt; to make sure, only the single variable &lt;strong&gt;i&lt;/strong&gt; will be caught and not e.g. a word like variable.&#xA;Then do &lt;code&gt;cgnj&lt;/code&gt; to change your first match to a &lt;strong&gt;j&lt;/strong&gt;. Now you can repeat the change with the &lt;code&gt;.&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-03-10T17:48:08.243" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2479" PostTypeId="1" AcceptedAnswerId="2485" CreationDate="2015-03-10T18:31:38.747" Score="4" ViewCount="286" Body="&lt;p&gt;From time to time I do a &lt;code&gt;source&lt;/code&gt; of a script and N errors and warnings manifest. As the errors/warnings show it is impossible to scroll buffer/window. Cursor, at least in gvim is a bold white &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;log&lt;/em&gt;  part of Vim is typically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Error detected while processing function Foo:&#xA; line  16:&#xA; E123: blah&#xA; E456: blah&#xA; line  38:&#xA; E789 blah&#xA; Press Enter or type a command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My want is to be able to scroll the buffer, typically to investigate reported errors, &lt;em&gt;while&lt;/em&gt; the errors are showing. (So I do not have to memorize it for each run …).&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-03-11T09:59:38.763" Title="Scroll buffer-window whilst Ex-log open" Tags="|vimscript|error|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2480" PostTypeId="1" AcceptedAnswerId="2481" CreationDate="2015-03-10T18:41:07.970" Score="4" ViewCount="280" Body="&lt;p&gt;When Vim reports errors within a function it typically reports relative line numbers. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function Foo:&#xA;line  11:&#xA;E123: Blah blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here indicating the issue is at line 11 &lt;em&gt;relative to start of function Foo&lt;/em&gt;. Guess this is a result of how Vim load functions etc. – but is there a way to make it report absolute line numbers? As in line-number of script-file holding the function.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-03-10T19:48:28.320" Title="Absolute script-file line-numbers in Vim-function errors" Tags="|vimscript|error|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2481" PostTypeId="2" ParentId="2480" CreationDate="2015-03-10T19:22:16.860" Score="5" Body="&lt;p&gt;There was an &lt;a href=&quot;http://article.gmane.org/gmane.editors.vim.devel/42809&quot; rel=&quot;nofollow&quot;&gt;RFC&lt;/a&gt; suggesting this, but there was no response from Bram at the time.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2015-03-10T19:48:28.320" LastActivityDate="2015-03-10T19:48:28.320" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2482" PostTypeId="2" ParentId="2473" CreationDate="2015-03-10T19:39:41.647" Score="1" Body="&lt;p&gt;To simplify the other substitute solutions given, one thing that no one has mentioned so far is that you can use the &lt;code&gt;*&lt;/code&gt; command to search for the word under your cursor. This pulls the word into the &lt;code&gt;&quot;/&lt;/code&gt; register WITH the &lt;code&gt;\&amp;lt;\&amp;gt;&lt;/code&gt;, so you don't have to type it yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, when you go to make your substitution, you can leave the search text blank (it will automatically search for what is in the &lt;code&gt;&quot;/&lt;/code&gt; buffer). The process could look like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for(int i = 0; i &amp;lt; len; ++i);&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/i &amp;lt;return&amp;gt;&#xA;*&#xA;:s//j/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This finds &lt;code&gt;i&amp;lt;space&amp;gt;&lt;/code&gt;, searches for &lt;code&gt;\&amp;lt;i\&amp;gt;&lt;/code&gt;, and i with j on the current line, resulting in:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for(int j = 0; j &amp;lt; len; ++j);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can combine this easily with line-wise visual selection (&lt;code&gt;V&lt;/code&gt;) to select the lines you want to change. You could even &lt;code&gt;v&lt;/code&gt; or &lt;code&gt;ctrl+v&lt;/code&gt; to make a visual selection or visual blocks. With the latter two, if you have a match on the same line, but outside your visual selection, you'll need to use the \%V atom and paste (&lt;code&gt;ctrl-r /&lt;/code&gt;) the &lt;code&gt;/&lt;/code&gt; register in the search command to only substitute within the visual selection. For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for(int i = 0; i &amp;lt; len; ++i); i&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/i &amp;lt;return&amp;gt;&#xA;*&#xA;vi(&#xA;:s/\%V&amp;lt;ctrl-r&amp;gt;//j/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last line becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;s/\%V\&amp;lt;i\&amp;gt;/j/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This finds &lt;code&gt;i&amp;lt;space&amp;gt;&lt;/code&gt;, searches for &lt;code&gt;\&amp;lt;i\&amp;gt;&lt;/code&gt;, selects inside the parentheses, and replaces i with j ONLY within the visual selection, resulting in:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for(int j = 0; j &amp;lt; len; ++j); i&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But again, that only applies if you have matches on a selected line, but outside a visual selection (like that trailing i).&lt;/p&gt;&#xA;" OwnerUserId="1155" LastActivityDate="2015-03-10T19:39:41.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2483" PostTypeId="2" ParentId="2473" CreationDate="2015-03-10T20:01:39.603" Score="1" Body="&lt;p&gt;For a simple solution, you can check out the &lt;a href=&quot;https://github.com/terryma/vim-multiple-cursors&quot; rel=&quot;nofollow&quot;&gt;multiple-cursors&lt;/a&gt; plugin, allowing you to mouse over &lt;code&gt;i&lt;/code&gt;, hit &lt;code&gt;Ctrl-N&lt;/code&gt; a few times and changing the letter to &lt;code&gt;j&lt;/code&gt; with &lt;code&gt;cej&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="488" LastActivityDate="2015-03-10T20:01:39.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2484" PostTypeId="1" AcceptedAnswerId="2520" CreationDate="2015-03-10T21:10:57.237" Score="4" ViewCount="1456" Body="&lt;p&gt;I'm trying to remap Control + [hjkl] to navigate among splits, by setting this in my rc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; splits navigation&#xA;nnoremap &amp;lt;C-h&amp;gt; &amp;lt;C-w&amp;gt;h&#xA;nnoremap &amp;lt;C-j&amp;gt; &amp;lt;C-w&amp;gt;j&#xA;nnoremap &amp;lt;C-k&amp;gt; &amp;lt;C-w&amp;gt;k&#xA;nnoremap &amp;lt;C-l&amp;gt; &amp;lt;C-w&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; isn't working; it moves the cursor left a character, as if I had hit backspace (i.e. it traverses lines, unlike my &lt;code&gt;h&lt;/code&gt;). The other movements work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Asking (neo)vim for mapping information about &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; doesn't show anything suspicious looking:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose map &amp;lt;C-h&amp;gt;&#xA;n  &amp;lt;C-H&amp;gt;         &amp;lt;C-W&amp;gt;h&#xA;        Last set from ~/workspace/dotfiles/.nvimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I ask about &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; (which works as expected), it says that &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; is involved?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose map &amp;lt;C-j&amp;gt;&#xA;n  &amp;lt;NL&amp;gt;          &amp;lt;C-W&amp;gt;j&#xA;        Last set from ~/workspace/dotfiles/.nvimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Changing the order of my &lt;code&gt;nnoremap&lt;/code&gt;s doesn't seem to change the behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I debug this?&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="226" LastEditDate="2015-03-12T19:00:48.717" LastActivityDate="2015-03-12T20:12:13.500" Title="remap not working; &lt;NL&gt; in appears in other binding" Tags="|key-bindings|neovim|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2485" PostTypeId="2" ParentId="2479" CreationDate="2015-03-10T21:16:33.583" Score="4" Body="&lt;p&gt;I don't believe it's possible to scroll the buffer while the Ex-command output is displaying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A workaround is to redirect the output to a new file, which you can then open in a split.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir &amp;gt; output.txt&#xA;:source script.vim&#xA;:redir END&#xA;:split output.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if it's a script you're writing yourself, you could investigate the Decho plugin, which provides debug commands that can log output to a variety of destinations. Decho is included with the standard installation of Vim (&lt;code&gt;:help Decho.vim&lt;/code&gt;). &lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2015-03-10T21:16:33.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2486" PostTypeId="1" AcceptedAnswerId="2489" CreationDate="2015-03-10T21:43:20.313" Score="11" ViewCount="893" Body="&lt;p&gt;The &lt;code&gt;echon&lt;/code&gt; and &lt;code&gt;echohl&lt;/code&gt; commands are very useful for outputting lines of text with multiple highlight groups within the same line. This can be used to for instance create nice status messages for plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a plugin I am working on, I am using this exact method of outputting colored status messages. However, sometimes I would want to add these messages to the &lt;code&gt;message-history&lt;/code&gt; in a similar way to  what you get with &lt;code&gt;echomsg&lt;/code&gt;. Is this somehow possible? I don't believe there are any intrinsic functionality for this, but perhaps one could add the functionality with vim script?&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="24" LastEditDate="2015-03-13T20:52:51.900" LastActivityDate="2015-03-13T20:52:51.900" Title="`echon` for `echomsg`" Tags="|statusline|highlight|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2487" PostTypeId="2" ParentId="2455" CreationDate="2015-03-10T22:32:50.653" Score="1" Body="&lt;p&gt;Changing the cursor shape depending on the mode (e.g. Normal vs Insert) works very well with gVim.  This ought to work when using vim in a terminal program like Konsole, but I have never seen it work.&lt;/p&gt;&#xA;" OwnerUserId="532" LastActivityDate="2015-03-10T22:32:50.653" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2488" PostTypeId="2" ParentId="2464" CreationDate="2015-03-11T02:06:53.230" Score="1" Body="&lt;p&gt;I didn't find a solution to resolve this issue directly, but I find another Plugin: &lt;a href=&quot;https://github.com/Chiel92/vim-autoformat&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Chiel92/vim-autoformat&lt;/a&gt;. To use this plugin to format javascript, you have to install a global &lt;code&gt;js-beautify&lt;/code&gt; node module first: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;npm install -g js-beautify&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After the npm module is installed, the plugin will automatically detect it and format js code properly.&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="205" LastEditDate="2015-03-11T02:13:42.470" LastActivityDate="2015-03-11T02:13:42.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2489" PostTypeId="2" ParentId="2486" CreationDate="2015-03-11T03:17:57.057" Score="11" Body="&lt;p&gt;This is not currently possible in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Internally, &lt;code&gt;:echomsg&lt;/code&gt; is implemented as &lt;code&gt;:execute&lt;/code&gt;, except that when invoked as &lt;code&gt;:echomsg&lt;/code&gt; the result of execution is displayed with the attribute of the last &lt;code&gt;:echohl&lt;/code&gt; and saved to the message list (reference &lt;code&gt;src/eval.c&lt;/code&gt; functions &lt;code&gt;ex_echohl&lt;/code&gt; and &lt;code&gt;ex_execute&lt;/code&gt;), which is how you get any color on a saved message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The actual message history is a collection (linked list) of strings with attributes, and is stored and retrieved in &lt;code&gt;src/message.c&lt;/code&gt;. Each string is a message (consisting of one or more lines), and the attribute determines, among other things, the highlight group to use for display. Because of this, each message must be highlighted as a whole (single highlight group), and no more than one message may be on the same line. (reference &lt;code&gt;src/message.c&lt;/code&gt; structure &lt;code&gt;msg_hist&lt;/code&gt; and function &lt;code&gt;ex_messages&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot find any way around this (I thought of using &lt;code&gt;:echohl&lt;/code&gt; and &lt;code&gt;:echon&lt;/code&gt; to display a message, but store a plain message in history. Unfortunately, the ability to add to the history without also displaying the message doesn't appear to be exposed to any ex-commands) without modifying the Vim source code.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-03-13T04:04:54.183" LastActivityDate="2015-03-13T04:04:54.183" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2490" PostTypeId="1" AcceptedAnswerId="2492" CreationDate="2015-03-11T09:40:03.883" Score="5" ViewCount="470" Body="&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Working with text and various markup languages in Vim I have recently experimented with the conceal feature to hide some of the more verbose markup. I switch conceal off when writing and editing and switch it on when searching and reading. Conceal increases readability, but it ruins paragraph formatting, which decreases readability. To benefit from conceal without losing formatting I would like to be able to format a paragraph as if the concealed markup was not there. How can I achieve this?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Context&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I normally use MacVim with Vim 7.4.258.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;par&lt;/code&gt; to format my text. My &lt;code&gt;'formatprg'&lt;/code&gt; is set to &lt;code&gt;par -qw79&lt;/code&gt; and I use &lt;code&gt;gqip&lt;/code&gt; and friends to apply formatting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have read the help topic on &lt;code&gt;formatexpr&lt;/code&gt; and it gave me the idea to write something in VimL that removes the concealed markup before filtering the text through &lt;code&gt;formatprg&lt;/code&gt;, then reapplies it to the formatted paragraph. Is this a reasonable approach? It strikes me as possible but difficult and I am hoping there is a simpler way.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Example&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here is a current example using &lt;code&gt;vim-latex-1.8.23 (latex suite)&lt;/code&gt; and its default concealment. There are worse cases but this will illustrate my problem. Compare the following paragraph with minor &lt;code&gt;LaTeX&lt;/code&gt; markup as it is appears in a buffer with &lt;code&gt;conceallevel=0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Let me begin with the former idea, the modal orientation. The traditional&#xA;question that I mentioned above, i.e., Are there genuine naming devices? is&#xA;a \textit{semantical} question. Kripke's distinctive strategy is to tackle it&#xA;by attending first to a \textit{metaphysical} question. We focus on objects,&#xA;the design\textit{ata}, and their modal properties. We do not begin our&#xA;semantical investigation by looking at the design\textit{ators} and their&#xA;purely linguistic features. Not at all. The intuitive test for rigidity that&#xA;Kripke devises (N&amp;amp;N, 48/9) reflects this point. We start with an individual&#xA;(Nixon), and we observe that \textit{that} individual couldn't have failed to&#xA;be Nixon. Thus, the property \textit{being Nixon} applies to him necessarily&#xA;(or at least essentially, a distinction to which we shall return below).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the same paragraph when the markup is concealed&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Let me begin with the former idea, the modal orientation. The traditional&#xA;question that I mentioned above, i.e., Are there genuine naming devices? is&#xA;a semantical question. Kripke's distinctive strategy is to tackle it&#xA;by attending first to a metaphysical question. We focus on objects,&#xA;the designata, and their modal properties. We do not begin our&#xA;semantical investigation by looking at the designators and their&#xA;purely linguistic features. Not at all. The intuitive test for rigidity that&#xA;Kripke devises (N&amp;amp;N, 48/9) reflects this point. We start with an individual&#xA;(Nixon), and we observe that that individual couldn't have failed to&#xA;be Nixon. Thus, the property being Nixon applies to him necessarily&#xA;(or at least essentially, a distinction to which we shall return below).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="51" LastEditDate="2015-03-11T09:55:26.600" LastActivityDate="2015-03-11T11:36:15.530" Title="How can I make text formatting ignore concealed characters?" Tags="|syntax-highlighting|external-command|formatting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2491" PostTypeId="2" ParentId="2479" CreationDate="2015-03-11T09:59:38.763" Score="4" Body="&lt;p&gt;Vim stores up to 20 error messages by default in its messages history. This list can be reviewed using the command &lt;code&gt;:messages&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For further information check:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :messages&#xA;:help 'shortmess'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="599" LastActivityDate="2015-03-11T09:59:38.763" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2492" PostTypeId="2" ParentId="2490" CreationDate="2015-03-11T11:36:15.530" Score="5" Body="&lt;p&gt;The &lt;em&gt;conceal&lt;/em&gt; feature is entirely visual; i.e. it only affects what is displayed in Vim (to make it easier on the eye). As such, there is no interaction with Vim commands that change the actual text in the buffer (such as &lt;code&gt;:substitute&lt;/code&gt; or reformatting); movement commands will just jump over the concealed characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that, it is indeed difficult to implement a &lt;code&gt;'formatexpr'&lt;/code&gt; that breaks the text as it appears with conceal turned on. As conceal is implemented by syntax highlighting, you'd either have to interact with the buffer text and query for the syntax attributes (via &lt;code&gt;synID()&lt;/code&gt; and &lt;code&gt;synconcealed()&lt;/code&gt;), which is cumbersome and likely slow, or you'd have to duplicate the conceal definitions and provide those to your custom format expression, effectively reimplementing conceal there.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I can see your motivation, but given the described difficulties (and that it forces Vim into the direction of WYSIWYG, for which it expressly isn't designed), I would advise to live with the discrepancies. For Latex in particular, there are several &quot;real&quot; WYSIWYG editors you could alternatively use.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-11T11:36:15.530" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2493" PostTypeId="1" AcceptedAnswerId="31321" CreationDate="2015-03-11T12:58:08.453" Score="20" ViewCount="1247" Body="&lt;p&gt;I recently removed the YankRing plugin from my setup partly because it was causing some problems with macros, but mostly because I decided it would be better to train myself to use Vim's registers instead&amp;thinsp;&amp;mdash;&amp;thinsp;in particular, the way that deleted text is stored initially in register &lt;code&gt;&quot;1&lt;/code&gt; and then shifted up through &lt;code&gt;&quot;2&lt;/code&gt;, &lt;code&gt;&quot;3&lt;/code&gt;, etc. as further deletions are made is very useful. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when a deletion/change removes less than one line of text, it is instead stored in the &lt;code&gt;&quot;-&lt;/code&gt; small delete register (with a few exceptions for certain movement commands). If subsequent small deletions are made, that bit of text is lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to get Vim to store &lt;em&gt;all&lt;/em&gt; deletions in register &lt;code&gt;&quot;1&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap d &quot;1d&lt;/code&gt; &lt;em&gt;almost&lt;/em&gt; works, but you end up with the text in both registers &lt;code&gt;&quot;1&lt;/code&gt; &lt;em&gt;and&lt;/em&gt; &lt;code&gt;&quot;2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't mind whether or not the functionality of the small delete register is affected. Suggesting I change my behaviour to save small deletions to a named register would definitely not be a helpful answer&amp;thinsp;&amp;mdash;&amp;thinsp;that's what I'm currently doing.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2021-05-19T10:56:45.273" Title="Can I make Vim also save &quot;small deletions&quot; into register &quot;1?" Tags="|register|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2494" PostTypeId="2" ParentId="2493" CreationDate="2015-03-11T13:13:48.053" Score="12" Body="&lt;p&gt;This used to work in older Vim 7.3 versions when you &lt;code&gt;:set clipboard=unnamed&lt;/code&gt; (see &lt;a href=&quot;http://www.reddit.com/r/vim/comments/yyq4a/is_there_anyway_to_configure_vim_to_use_the/&quot;&gt;this Reddit discussion&lt;/a&gt;, as a result of a bug, which &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/pbN4rAw8LmI/jR54qQjvuOsJ&quot;&gt;I've reported here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That thread contains a patch by Aryeh Leib Taurog which introduces a &lt;code&gt;'regone'&lt;/code&gt; option. This has made it into the (overly long) todo list, but it's unlikely to be incorporated soon. So, you currently only have the option to downgrade to an outdated Vim, or build Vim yourself with that patch (and push for adoption on the &lt;a href=&quot;http://www.vim.org/community.php&quot;&gt;vim_dev mailing list&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-11T13:13:48.053" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2495" PostTypeId="1" AcceptedAnswerId="2497" CreationDate="2015-03-11T13:31:50.980" Score="0" ViewCount="583" Body="&lt;p&gt;I installed &lt;a href=&quot;https://github.com/marijnh/tern_for_vim&quot; rel=&quot;nofollow&quot;&gt;ternjs_for_vim&lt;/a&gt; plugin but can't figure out how to use it properly. RTFM didn't help. What I get is list random JS-methods in the omni-completion. But things like completing for Node.JS modules doesn't work. For example if I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var fs = require('fs');&#xA;fs.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and after &lt;code&gt;.&lt;/code&gt; there is no relevant completion (like methods &lt;code&gt;readFile&lt;/code&gt;, &lt;code&gt;readFileSync&lt;/code&gt; etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my .tern-project file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    &quot;libs&quot;: [&#xA;        &quot;underscore&quot;,&#xA;        &quot;jquery&quot;&#xA;    ],&#xA;    &quot;plugins&quot;: {&#xA;        &quot;node&quot;: {}&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="500" LastEditorUserId="15" LastEditDate="2015-03-11T14:46:27.223" LastActivityDate="2015-03-11T15:32:55.440" Title="Ternjs plugin is not working as expected" Tags="|filetype-javascript|plugin-ternjs|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2496" PostTypeId="2" ParentId="2495" CreationDate="2015-03-11T14:53:33.567" Score="1" Body="&lt;p&gt;The documentation states (emphasis added):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In JavaScript files, the package will hook into &lt;strong&gt;omni completion&lt;/strong&gt; to handle autocompletion&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/version7.txt.html#new-omni-completion&quot; rel=&quot;nofollow&quot;&gt;Omni completion&lt;/a&gt; doesn't automatically get triggered.  It has to be manually invoked using the key sequence &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; in insert mode.  Then you can use &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#popupmenu-keys&quot; rel=&quot;nofollow&quot;&gt;various keys&lt;/a&gt; to navigate the resulting completion menu and select the completion you want.  For example, &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt; will accept the completion and &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; aborts the completion leaving you with the original text.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-03-11T14:53:33.567" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2497" PostTypeId="2" ParentId="2495" CreationDate="2015-03-11T15:32:55.440" Score="0" Body="&lt;p&gt;Actually, there was a problem in my .vimrc config.&lt;br&gt;&#xA;A long time ago I created some settings regarding Omni completion and forgot about them. So I just deleted this lines from my config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ofu=syntaxcomplete#Complete&#xA;autocmd FileType python set omnifunc=pythoncomplete#Complete&#xA;autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS&#xA;autocmd FileType html set omnifunc=htmlcomplete#CompleteTags&#xA;autocmd FileType css set omnifunc=csscomplete#CompleteCSS&#xA;autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags&#xA;autocmd FileType php set omnifunc=phpcomplete#CompletePHP&#xA;autocmd FileType c set omnifunc=ccomplete#Complete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and everything works like a charm now.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2015-03-11T15:32:55.440" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2498" PostTypeId="2" ParentId="2382" CreationDate="2015-03-11T16:22:10.350" Score="1" Body="&lt;p&gt;You need to edit &lt;code&gt;c-support/codesnippets/main.c&lt;/code&gt; for C code and &lt;code&gt;c-support/codesnippets/main.cc&lt;/code&gt; for C++&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise it looks like the local version is stored in &lt;code&gt;~/.vim/bundle/cvim/c-support/templates&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a file called &lt;code&gt;c.idioms.template&lt;/code&gt; that contains the &lt;code&gt;main&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using pathogen so my path looks a little different. Per the c.vim documentation&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The master template file is '$HOME/.vim/c-support/templates/Templates' for&#xA;  a user installation and  '$VIM/vimfiles/c-support/templates/Templates' for&#xA;  a system-wide installation (see csupport-system-wide).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;More info at &lt;code&gt;:help csupport-templates-files&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2015-03-11T16:28:07.673" LastActivityDate="2015-03-11T16:28:07.673" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2499" PostTypeId="1" AcceptedAnswerId="2500" CreationDate="2015-03-11T18:19:49.330" Score="0" ViewCount="437" Body="&lt;p&gt;I have pathogen setup however when it finishes loading I have to press the &lt;kbd&gt;Enter&lt;/kbd&gt; key as shown in this screen shot.&lt;br&gt;&lt;img src=&quot;https://i.stack.imgur.com/X2gzD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way how to disable the 'Press Enter or type command to continue' prompt but keep it when other shell scripts are run usng the &lt;code&gt;.vimrc&lt;/code&gt; file or another method?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have had a look at &lt;a href=&quot;https://vi.stackexchange.com/questions/771/how-can-i-suppress-the-press-enter-prompt-when-opening-files-in-diff-mode&quot;&gt;How can I suppress the &amp;quot;press enter&amp;quot; prompt when opening files in diff mode?&lt;/a&gt; however the answer looks like it disables the prompt for all scripts when I want it disabled &lt;strong&gt;only&lt;/strong&gt; when pathogen loads.&lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-03-13T21:04:19.287" Title="Prevent 'Press ENTER' when pathogen loads but keep for other scripts" Tags="|startup|plugin-managers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2500" PostTypeId="2" ParentId="2499" CreationDate="2015-03-11T18:24:04.613" Score="9" Body="&lt;p&gt;Change the &lt;code&gt;call pathogen#runtime_append_all_bundles()&lt;/code&gt; line in your vimrc to &lt;code&gt;call pathogen#infect()&lt;/code&gt;, as the message suggests.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-03-11T18:24:04.613" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2502" PostTypeId="1" CreationDate="2015-03-11T22:49:17.047" Score="1" ViewCount="66" Body="&lt;p&gt;Let's say I have the following bit of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v = [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to know how many elements are in v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current solution, if &lt;code&gt;v&lt;/code&gt; isn't too large, requires a bit of counting, but it makes for more readable code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v = [0,0,0,0,&#xA;     0,1,0,0,&#xA;     0,0,0,0,&#xA;     0,0,0,0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is less helpful when &lt;code&gt;v&lt;/code&gt; is large.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also occurs to me that I could just pipe the line into the shell (assume it's line 1)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :1 ! tr -dc ',' | wc -c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this replaces the contents of line 1 with 15 (which is the answer I am looking for ... nothing undo cannot fix)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better vim command to count how many times a character appears in a selection/line/range?&lt;/p&gt;&#xA;" OwnerUserId="1104" LastEditorUserId="343" LastEditDate="2017-12-06T11:10:53.630" LastActivityDate="2017-12-06T11:10:53.630" Title="How can I count instances of character &quot;x&quot;?" Tags="|counting|" AnswerCount="0" CommentCount="0" ClosedDate="2015-03-11T23:44:10.200" ContentLicense="CC BY-SA 3.0" />
  <row Id="2503" PostTypeId="1" AcceptedAnswerId="2504" CreationDate="2015-03-11T23:45:40.080" Score="2" ViewCount="151" Body="&lt;p&gt;the key combination &lt;code&gt;dw&lt;/code&gt; is to delete a word. I've also defined my own key combination, e.g. &lt;code&gt;&amp;lt;leader&amp;gt;j&lt;/code&gt; to move to a window below. My question is how much time is left between the first and second keystroke to make the combination work? Is there some place I can customize this setting?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="24" LastEditDate="2015-03-13T21:00:41.950" LastActivityDate="2015-03-13T21:00:41.950" Title="Where to find the time interval for a key combination to work?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2504" PostTypeId="2" ParentId="2503" CreationDate="2015-03-12T00:05:51.680" Score="3" Body="&lt;p&gt;The setting you are looking for is &lt;code&gt;ttimeoutlen&lt;/code&gt; and &lt;code&gt;timeoutlen&lt;/code&gt;.  &lt;code&gt;timeoutlen&lt;/code&gt; sets the time (in milliseconds) that is waited for mapped sequence or key code to be completed.  If you want a different timeout length for key codes, you can set &lt;code&gt;ttimeoutlen&lt;/code&gt;.  If &lt;code&gt;ttimeoutlen&lt;/code&gt; is set to anything but &lt;code&gt;-1&lt;/code&gt;, &lt;code&gt;timeoutlen&lt;/code&gt; is used to set the timeout of key mappings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'ttimeoutlen'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-03-12T00:05:51.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2505" PostTypeId="1" AcceptedAnswerId="2510" CreationDate="2015-03-12T09:27:40.463" Score="5" ViewCount="3815" Body="&lt;p&gt;I use &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;nofollow&quot;&gt;YouCompleteMe&lt;/a&gt; and it works great (after some setting up woes) for both C/C++ and Python code.  However, it tries to complete things in text files such as ReStructured text, markdown, etc...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error I keep getting is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- User defined completion (^U^N^P) Pattern not found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I stop it form doing so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType c,cpp,python let g:ycm_global_ycm_extra_conf = &quot;~/.ycm_extra_conf.py&quot;&#xA;autocmd FileType c,cpp,python let g:ycm_collect_identifiers_from_tags_files = 1&#xA;autocmd FileType c,cpp,python let g:ycm_complete_in_comments = 0&#xA;autocmd FileType c,cpp,python let g:ycm_complete_in_strings = 0&#xA;autocmd FileType c,cpp,python let g:syntastic_enable_signs=1&#xA;autocmd FileType c,cpp,python let g:syntastic_error_symbol = '✗'&#xA;autocmd FileType c,cpp,python let g:syntastic_warning_symbol = '⚠'&#xA;autocmd FileType c,cpp,python let g:ycm_confirm_extra_conf = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the error still persists.  I even tried adding a &lt;code&gt;g:ycm_filetype_specific_completion_to_disable&lt;/code&gt; command like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_filetype_specific_completion_to_disable = {&#xA;      \ 'rst': 1&#xA;      \}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the error still persists.&lt;/p&gt;&#xA;" OwnerUserId="622" LastEditorUserId="622" LastEditDate="2015-03-12T13:57:28.563" LastActivityDate="2015-03-12T14:00:40.533" Title="YouCompleteMe in non-code files yields -- User defined completion (^U^N^P) Pattern not found" Tags="|autocompletion|plugin-you-complete-me|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2506" PostTypeId="5" CreationDate="2015-03-12T10:17:17.570" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/Valloric/YouCompleteMe#intro&quot; rel=&quot;nofollow&quot;&gt;YouCompleteMe&lt;/a&gt; is a fast, as-you-type, fuzzy-search code completion engine for Vim. From the git repository:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It has several completion engines: an identifier-based engine that&#xA;  works with every programming language, a semantic, Clang-based engine&#xA;  that provides native semantic code completion for&#xA;  C/C++/Objective-C/Objective-C++ (from now on referred to as &quot;the&#xA;  C-family languages&quot;), a Jedi-based completion engine for Python, an&#xA;  OmniSharp-based completion engine for C# and an omnifunc-based&#xA;  completer that uses data from Vim's omnicomplete system to provide&#xA;  semantic completions for many other languages (Ruby, PHP etc.).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="622" LastEditorUserId="622" LastEditDate="2015-03-12T10:43:50.633" LastActivityDate="2015-03-12T10:43:50.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2507" PostTypeId="4" CreationDate="2015-03-12T10:17:17.570" Score="0" Body="For questions about the YouCompleteMe plugin. This plugin is an alternative completion engine for Vim." OwnerUserId="-1" LastEditorUserId="25" LastEditDate="2021-12-09T02:47:11.543" LastActivityDate="2021-12-09T02:47:11.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2508" PostTypeId="2" ParentId="2505" CreationDate="2015-03-12T12:17:41.710" Score="1" Body="&lt;p&gt;This would be a generic answer, since I don't know &lt;code&gt;YouCompleteMe&lt;/code&gt;. You mentioned in the comments that you would be ok with enabling this plugin on a per-file basis, so here is the solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType c,cpp &amp;lt;command&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command above executes &lt;code&gt;command&lt;/code&gt; whenever a &lt;code&gt;c&lt;/code&gt; or &lt;code&gt;cpp&lt;/code&gt; filetype is detected. If you have filetype detection enabled on startup, this means the command would execute when you open a &lt;code&gt;c&lt;/code&gt; or &lt;code&gt;cpp&lt;/code&gt; file. Furthermore, remember that the effect may be on all opened splits (see &lt;code&gt;set&lt;/code&gt; vs &lt;code&gt;setlocal&lt;/code&gt;). &lt;code&gt;:h autocmd&lt;/code&gt; and &lt;code&gt;:h filetypes&lt;/code&gt; have additional information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, you need to find the command that enables/disables &lt;code&gt;YouCompleteMe&lt;/code&gt; and stick it in an autocommand.&lt;/p&gt;&#xA;" OwnerUserId="850" LastActivityDate="2015-03-12T12:17:41.710" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2509" PostTypeId="1" AcceptedAnswerId="2519" CreationDate="2015-03-12T13:09:07.410" Score="5" ViewCount="85" Body="&lt;p&gt;In &lt;em&gt;Normal&lt;/em&gt; and &lt;em&gt;Visual&lt;/em&gt; modes you can execute a motion or other operation using the contents of a register with &lt;code&gt;@&lt;/code&gt;.  This &lt;code&gt;@&lt;/code&gt; key does not work however in &lt;em&gt;Operator-pending&lt;/em&gt; mode.  Is there another way to use a motion from a register with an operator?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;em&gt;Operator-pending&lt;/em&gt; mode it is still possible to use commands as motions, for example: &lt;code&gt;:call &amp;lt;SID&amp;gt;MyAction()&amp;lt;CR&amp;gt;&lt;/code&gt;.  What would be the reason for not allowing registers?&lt;/p&gt;&#xA;" OwnerUserId="1248" LastActivityDate="2015-03-12T18:34:54.390" Title="Is it possible to use registers in Operator-pending mode? If not, why?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2510" PostTypeId="2" ParentId="2505" CreationDate="2015-03-12T14:00:40.533" Score="8" Body="&lt;p&gt;The command &lt;code&gt;g:ycm_filetype_whitelist&lt;/code&gt; was the one I needed!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_filetype_whitelist = { 'cpp': 1, 'c': 1, 'python':1 }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, to get ride of this message altogether, the &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe#i-get-annoying-messages-in-vims-status-area-when-i-type&quot;&gt;answer is in the FAQ&lt;/a&gt;. Basically, update to Vim 7.4.314 or later and it shall go away.&lt;/p&gt;&#xA;" OwnerUserId="622" LastActivityDate="2015-03-12T14:00:40.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2511" PostTypeId="2" ParentId="2493" CreationDate="2015-03-12T16:26:13.517" Score="6" Body="&lt;p&gt;I've got a proof-of-concept solution that works for the &lt;code&gt;d&lt;/code&gt; command with motions and in visual mode. It's not a fully robust solution yet (for example, &lt;a href=&quot;https://vi.stackexchange.com/q/2543/343&quot;&gt;&lt;code&gt;d[count]d&lt;/code&gt; doesn't work&lt;/a&gt;, and neither does &lt;code&gt;[count]D&lt;/code&gt;), but it very nearly covers all my actual use cases.&lt;/p&gt;&#xA;&lt;p&gt;It works by setting a custom operator function that:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;stores the contents of the registers 1–8 in a dictionary,&lt;/li&gt;&#xA;&lt;li&gt;performs the deletion into register 1,&lt;/li&gt;&#xA;&lt;li&gt;sets registers 2–9 to the previously saved contents of registers 1–8.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;See &lt;code&gt;:help map-operator&lt;/code&gt; for an explanation of how operator functions work.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! ShiftingDeleteOperator(type)&#xA;  let reg_dict = {}&#xA;  for k in range(1, 8)&#xA;    execute printf(&amp;quot;let reg_dict[%d]=getreg('%d', 1)&amp;quot;, k, k)&#xA;  endfor&#xA;&#xA;  if a:type ==# 'v'&#xA;    execute 'normal! `&amp;lt;v`&amp;gt;d'&#xA;  elseif a:type ==# 'V'&#xA;    execute 'normal! `&amp;lt;V`&amp;gt;d'&#xA;  elseif a:type ==# &amp;quot;\&amp;lt;C-V&amp;gt;&amp;quot;&#xA;    execute &amp;quot;normal! `&amp;lt;\&amp;lt;C-V&amp;gt;`&amp;gt;d&amp;quot;&#xA;  elseif a:type ==# 'char'&#xA;    execute 'normal! `[v`]d'&#xA;  elseif a:type ==# 'line'&#xA;    execute &amp;quot;normal! '[V']d&amp;quot;&#xA;  else&#xA;    return&#xA;  endif&#xA;&#xA;  let deleted = getreg('&amp;quot;', 1)&#xA;  call setreg(1, deleted)&#xA;&#xA;  for [k, v] in items(reg_dict)&#xA;    execute printf(&amp;quot;call setreg(%d, v)&amp;quot;, k + 1)&#xA;  endfor&#xA;endfunction&#xA;&#xA;&amp;quot; Call the function for d{motion} via operatorfunc&#xA;nnoremap &amp;lt;silent&amp;gt; d :set operatorfunc=ShiftingDeleteOperator&amp;lt;CR&amp;gt;g@&#xA;&amp;quot; Call the function when d or x are hit in visual mode&#xA;vnoremap d :&amp;lt;C-U&amp;gt;call ShiftingDeleteOperator(visualmode())&amp;lt;CR&amp;gt;&#xA;vnoremap x :&amp;lt;C-U&amp;gt;call ShiftingDeleteOperator(visualmode())&amp;lt;CR&amp;gt;&#xA;&amp;quot; Use the d{motion} as defined above to add limited support for `D` command&#xA;nmap D d$&#xA;&amp;quot; Use the standard dd command&#xA;nnoremap dd dd &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2021-05-19T10:53:37.793" LastActivityDate="2021-05-19T10:53:37.793" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2512" PostTypeId="1" CreationDate="2015-03-12T16:33:43.017" Score="3" ViewCount="2879" Body="&lt;p&gt;In a compilation log file whenever I get error it shows full path from root directory and line number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After opening file in vim say following is the content of file,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;..&#xA;..&#xA;Dir1/Dir2/src/ipv4.c 1223&#xA;..&#xA;..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In vim in esc mode When I take cursor on above line and type &lt;kbd&gt;ctrl+w&lt;/kbd&gt;&lt;kbd&gt;shift+f&lt;/kbd&gt; it will split the window horizontally and open file &lt;code&gt;ipv4.c&lt;/code&gt; and take cursor to line number &lt;code&gt;1223&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;go to line  of file under cursor in split window. I want to set a small shortcut say &lt;code&gt;gf&lt;/code&gt; which should be mapped to &lt;kbd&gt;ctrl+w&lt;/kbd&gt;&lt;kbd&gt;shift+f&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So everytime typing &lt;kbd&gt;ctrl+w&lt;/kbd&gt;&lt;kbd&gt;shift+f&lt;/kbd&gt; to do so is headache. So I want to map this to some custom shortcut say &lt;code&gt;gf&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt; file. So How to do it?&lt;/p&gt;&#xA;" OwnerUserId="1334" LastEditorUserId="24" LastEditDate="2015-03-13T20:47:45.480" LastActivityDate="2015-03-13T20:47:45.480" Title="How to remap “ctrl+w+shift+f” to “gf” in vim to go to line of file under cursor in split window?" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2513" PostTypeId="2" ParentId="2512" CreationDate="2015-03-12T16:52:12.473" Score="7" Body="&lt;p&gt;A simple mapping could do the trick. Add the following to your &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gf &amp;lt;c-w&amp;gt;F&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Thoughts&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;May want to map &lt;code&gt;&amp;lt;c-w&amp;gt;F&lt;/code&gt; to &lt;code&gt;gf&lt;/code&gt; so that the functionality is swapped&lt;/li&gt;&#xA;&lt;li&gt;Maybe remap the window key, &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt;, as that sounds like a pain point. e.g. &lt;code&gt;nnoremap &amp;lt;space&amp;gt; &amp;lt;c-w&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use regular &lt;code&gt;gf&lt;/code&gt; and use &lt;code&gt;&amp;lt;c-6&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; to get back to the log file&lt;/li&gt;&#xA;&lt;li&gt;Set a upper case mark, e.g. &lt;code&gt;mM&lt;/code&gt;, so that you can get back to the log file, e.g. &lt;code&gt;`M&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;May want this mapping to only apply to log files. Then add &lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; gf &amp;lt;c-w&amp;gt;gF&lt;/code&gt; to &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt; where &lt;code&gt;python&lt;/code&gt; is your filetype.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h gf&#xA;:h Ctrl-w_F&#xA;:h mapping&#xA;:h Ctrl-6&#xA;:h Ctrl-o&#xA;:h m&#xA;:h mark-motions&#xA;:h after-directory&#xA;:h ftplugin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-03-12T19:23:44.723" LastActivityDate="2015-03-12T19:23:44.723" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2514" PostTypeId="1" AcceptedAnswerId="2515" CreationDate="2015-03-12T17:16:22.310" Score="7" ViewCount="1572" Body="&lt;p&gt;I've been using Neovim for a few days with no problem, so I decided to switch my git config to use Neovim instead of vim. Here's what I put in my global &lt;code&gt;.gitconfig&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[core]&#xA;    editor = nvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here's the warning when I run &lt;code&gt;git commit&lt;/code&gt; now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Warning: Cannot find word list &quot;en.utf-8.spl&quot; or &quot;en.ascii.spl&quot;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After pressing a key, it works fine, except that it doesn't do spell checking like vim used to do. Here's what I've got in my &lt;code&gt;.nvimrc&lt;/code&gt; to turn on spell checking in git commit messages.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype gitcommit setlocal spell textwidth=72&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="226" LastEditorUserId="51" LastEditDate="2015-03-15T17:51:44.483" LastActivityDate="2015-03-15T17:51:44.483" Title="Warning when opening commit message with Neovim" Tags="|spell-checking|neovim|git|filetype-git|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2515" PostTypeId="2" ParentId="2514" CreationDate="2015-03-12T17:21:18.610" Score="7" Body="&lt;p&gt;If I run &lt;code&gt;:set spell&lt;/code&gt;, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;spellfile#LoadFile(): There is no writable spell directory&#xA;Shall I create /Users/adamharris/.nvim/spell&#xA;(Y)es, [N]o: &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Select y&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Cannot find spell file for &quot;en&quot; in utf-8&#xA;Do you want me to try downloading it?&#xA;(Y)es, [N]o: &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Select y, and it will download the file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In which directory do you want to write the file:&#xA;1. /Users/adamharris/.nvim/spell&#xA;[C]ancel, (1):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Select 1&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Do you want me to try to get the .sug file?&#xA;This will improve making suggestions for spelling mistakes,&#xA;but it uses quite a bit of memory.&#xA;[N]o, (Y)es:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I selected y, and downloaded the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then spellchecking works just fine!&lt;/p&gt;&#xA;" OwnerUserId="226" LastActivityDate="2015-03-12T17:21:18.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2516" PostTypeId="2" ParentId="2512" CreationDate="2015-03-12T17:38:36.777" Score="3" Body="&lt;p&gt;This is not a direct answer to your question, because I wonder if Vim might already have a more comprehensive solution for your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has support for running a compilation process, opening the compilation output (in the QuickFix List), and jumping to lines where errors were reported.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Option 1&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you use a GNU Makefile, and you are in the same folder, then all you need to do to compile is type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:make&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Option 2&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;But if you compile in a different way, you should first tell Vim how:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set makeprg=gcc\ file.c\ -o\ myapp&#xA;&#xA;&quot; Or to avoid escaping those spaces, you can instead do:&#xA;&#xA;:let &amp;amp;makeprg=&quot;gcc file.c -o myapp&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then you can compile using your specified method, by doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:make&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Option 3&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you don't want to run the compilation from inside Vim, but you still want to open the logfile in the QuickFix List, then do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cfile my_compilation.log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Viewing the errors&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The QuickFix List is useful because it can recognise some error log formats, and help you to navigate them.  To step forwards or backwards through errors, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cnext&#xA;:cprev&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To view all the errors, open the QuickFix Window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In that window you can jump to source of an error by pressing &lt;kbd&gt;Enter&lt;/kbd&gt;.  To open in a newly split window, hit &lt;kbd&gt;Ctrl+W Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Further information&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;For more details on the whole process, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :make&#xA;:help 'makeprg'&#xA;:help quickfix&#xA;:help errorformat&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-03-12T17:43:46.210" LastActivityDate="2015-03-12T17:43:46.210" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2517" PostTypeId="1" AcceptedAnswerId="2518" CreationDate="2015-03-12T17:49:56.647" Score="3" ViewCount="416" Body="&lt;p&gt;If I type a URL and I want to extract the parameters from the query string quickly in VIM how would I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance if I have: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://www.somesite.org/page2014.html?utm_source=facebook&amp;amp;utm_medium=eventlinkonwall&amp;amp;utm_term=trapshoot&amp;amp;utm_content=calendar_event_on_wall&amp;amp;utm_campaign=trapshoot2014&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to end up with something close to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;utm_source=facebook&#xA;utm_medium=eventlinkonwall&#xA;utm_term=trapshoot&#xA;utm_content=calendar_event_on_wall&#xA;utm_campaign=trapshoot2014&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="51" LastEditDate="2015-03-12T17:55:26.080" LastActivityDate="2015-03-16T10:27:01.773" Title="How do I extract the parameters from a URL in Vim?" Tags="|vimscript|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2518" PostTypeId="2" ParentId="2517" CreationDate="2015-03-12T17:57:40.507" Score="4" Body="&lt;p&gt;What about:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;df?:s/&amp;amp;/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;df?&lt;/code&gt; to delete everything up to &amp;amp; including the first &lt;code&gt;?&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:s/&amp;amp;/\r/g&lt;/code&gt; to replace every &lt;code&gt;&amp;amp;&lt;/code&gt; with a newline&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could prefix this with either &lt;code&gt;^&lt;/code&gt; to go the start of the line, or &lt;code&gt;B&lt;/code&gt; to go to the start of the word; use whatever is appropriate in the scenario. Be careful with automatically adding &lt;code&gt;B&lt;/code&gt; in a keybind or command though, because if you're on the first character of the URL it will go to the word &lt;em&gt;before&lt;/em&gt; the URL!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will only work on well-formed URLs, the web would not be the web if there weren't a bunch of malformed URLs floating around ;-) Specifically, URL's which omit the &lt;code&gt;?&lt;/code&gt; and just use &lt;code&gt;&amp;amp;key=value&lt;/code&gt; to start the first parameter seem to be common.&lt;br&gt;&#xA;To fix this, you could search for either the first &lt;code&gt;?&lt;/code&gt;, OR the first &lt;code&gt;&amp;amp;&lt;/code&gt;, which is unfortunately a bit more typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d/[?&amp;amp;]&amp;lt;CR&amp;gt;x:s/&amp;amp;/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is the enter key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do this sort of thing often, you could map it to a key:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Leader&amp;gt;p df?:s/&amp;amp;/\r/g&amp;lt;CR&amp;gt;&#xA;:nnoremap &amp;lt;Leader&amp;gt;p d/[?&amp;amp;]&amp;lt;CR&amp;gt;x:s/&amp;amp;/\r/&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or make a command out of it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! SplitURL exe 'normal df?'|:s/&amp;amp;/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-03-12T18:47:33.910" LastActivityDate="2015-03-12T18:47:33.910" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2519" PostTypeId="2" ParentId="2509" CreationDate="2015-03-12T18:34:54.390" Score="6" Body="&lt;p&gt;The technical reason is that the &lt;code&gt;@&lt;/code&gt; command isn't defined in operator pending mode. Why? Probably because it wasn't in vi, and because it only makes sense when the register actually contains a motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can work around this via &lt;code&gt;:normal&lt;/code&gt;, though, e.g. &lt;code&gt;qq3eqgU:normal! @q&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-12T18:34:54.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2520" PostTypeId="2" ParentId="2484" CreationDate="2015-03-12T18:37:40.337" Score="4" Body="&lt;p&gt;This is due to a &lt;a href=&quot;https://github.com/neovim/neovim/issues/2048&quot; rel=&quot;nofollow&quot;&gt;bug&lt;/a&gt; in Neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A suggested &lt;a href=&quot;https://github.com/neovim/neovim/issues/2048#issuecomment-78045837&quot; rel=&quot;nofollow&quot;&gt;workaround&lt;/a&gt; in that bug is to run the following commands to adjust your terminal's terminfo entry to match what Neovim expects:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' &amp;gt; $TERM.ti&#xA;tic $TERM.ti&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2015-03-12T20:12:13.500" LastActivityDate="2015-03-12T20:12:13.500" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2521" PostTypeId="1" CreationDate="2015-03-12T20:01:07.213" Score="2" ViewCount="91" Body="&lt;p&gt;If I type &lt;code&gt;:registers&lt;/code&gt;, I see a lot of &lt;code&gt;&amp;lt;09&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;1   &amp;lt;09&amp;gt;&amp;lt;09&amp;gt;&amp;lt;09&amp;gt;d = self / i.to_f^J&amp;lt;09&amp;gt;&amp;lt;09&amp;gt;&amp;lt;09&amp;gt;r = d.to_s^J&amp;lt;09&amp;gt;&amp;lt;09&amp;gt;&amp;lt;09&amp;gt;p r =~ /0$/^J&#xA;&quot;2   &amp;lt;09&amp;gt;&amp;lt;09&amp;gt;&amp;lt;09&amp;gt;puts ''^J&#xA;&quot;3   &amp;lt;09&amp;gt;&amp;lt;09&amp;gt;&amp;lt;09&amp;gt;p &quot;#{self}, #{i}&quot;^J&amp;lt;09&amp;gt;&amp;lt;09&amp;gt;&amp;lt;09&amp;gt;p d^J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;09&amp;gt;&lt;/code&gt; represents a Tab character; they're displayed in blue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use &lt;code&gt;:set display&amp;amp;vim&lt;/code&gt;, I get something marginally better:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;1   ^I^I^Id = self / i.to_f^J^I^I^Ir = d.to_s^J^I^I^Ip r =~ /0$/^J&#xA;&quot;2   ^I^I^Iputs ''^J&#xA;&quot;3   ^I^I^Ip &quot;#{self}, #{i}&quot;^J^I^I^Ip d^J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it's still not useful enough to easily scan the output for the line I want..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this is a feature, and I understand why it's there, but I find this extremely unhelpful when looking for the register I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to either not show it at all or show them as spaces?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-03-12T20:41:12.543" LastActivityDate="2015-03-12T20:58:21.800" Title="Don't show tab characters as ^I or &lt;09&gt; in the output of :registers" Tags="|register|tab-characters|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2522" PostTypeId="2" ParentId="2521" CreationDate="2015-03-12T20:15:23.043" Score="4" Body="&lt;p&gt;You chose to have them displayed that way by adding the &lt;code&gt;uhex&lt;/code&gt; setting to the &lt;code&gt;'display'&lt;/code&gt; option.  You can &lt;code&gt;:set display-=uhex&lt;/code&gt; to restore the default behavior of displaying them as &lt;code&gt;^I&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Getting &lt;code&gt;:reg&lt;/code&gt; to display them differently would require a Vim patch, but some plugins provide displays of the registers in a scratch buffer, which may help.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/dahu/vim-lotr&quot; rel=&quot;nofollow&quot;&gt;Lord of the Regs&lt;/a&gt; provides a sidebar to display all the registers.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/dahu/vimple&quot; rel=&quot;nofollow&quot;&gt;vimple&lt;/a&gt; is a general Vim library, but it has a handy concept called an &lt;a href=&quot;https://github.com/dahu/vimple/blob/master/autoload/overlay.vim&quot; rel=&quot;nofollow&quot;&gt;overlay&lt;/a&gt; (&lt;a href=&quot;https://github.com/dahu/vimple/blob/master/demo/jumplist.vim&quot; rel=&quot;nofollow&quot;&gt;example&lt;/a&gt;).  You could use that to build a scratch buffer of the registers.  It's also easy to setup actions in that buffer.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2015-03-12T20:58:21.800" LastActivityDate="2015-03-12T20:58:21.800" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2523" PostTypeId="1" AcceptedAnswerId="2525" CreationDate="2015-03-12T21:11:06.967" Score="7" ViewCount="1485" Body="&lt;p&gt;I frequently find myself wanting to make a copy of, eg, a function that I just wrote and modify it slightly. In such a situation, I'll generally use something like &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; to copy what I just wrote. I then have to &lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; or &lt;kbd&gt;`&lt;/kbd&gt;&lt;kbd&gt;`&lt;/kbd&gt; to get back to where I just was before &lt;kbd&gt;p&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I'm at the start of what I want to copy, &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; will not move the cursor to the end of what I just yanked, meaning that I still have to &lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; before I &lt;kbd&gt;p&lt;/kbd&gt;. This behavior is mentioned briefly in the help files:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;After applying the operator the cursor is mostly left at the start of&#xA;  the text that was operated upon.  For example, &quot;yfe&quot; doesn't move the&#xA;  cursor, but &quot;yFe&quot; moves the cursor leftwards to the &quot;e&quot; where the yank&#xA;  started.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But it doesn't give a rationale for which motions move the cursor and which don't, or a way to change these behaviors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, long story short: how can I yank upwards (or in any particular direction) without moving the cursor?&lt;/p&gt;&#xA;" OwnerUserId="163" LastEditorUserId="24" LastEditDate="2015-03-13T20:44:35.213" LastActivityDate="2015-03-13T20:44:35.213" Title="Keep cursor from moving when yanking upwards" Tags="|cursor-movement|cut-copy-paste|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2524" PostTypeId="2" ParentId="2523" CreationDate="2015-03-12T22:01:35.860" Score="5" Body="&lt;p&gt;Every command that modified the buffer (and yanks) will set the &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt; marks around the changed area. So you can go to the end of the the freshly yanked text via &lt;code&gt;']&lt;/code&gt; and then do your put, &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are just yanking line-winse then you can use the &lt;code&gt;:yank&lt;/code&gt; command with a range.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.-5,.yank&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command will yank the 5 lines above the current line to the current line. Or even shorter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:-5,y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Details:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Current line is represented by &lt;code&gt;.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.-5&lt;/code&gt; means subtract 5 from the current line&lt;/li&gt;&#xA;&lt;li&gt;The current line can be assumed so leave it out&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:y&lt;/code&gt; is short for &lt;code&gt;:yank&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :y&#xA;:h range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-03-12T22:11:06.340" LastActivityDate="2015-03-12T22:11:06.340" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2525" PostTypeId="2" ParentId="2523" CreationDate="2015-03-12T22:33:30.150" Score="8" Body="&lt;p&gt;You can take a different approach for this exact situation.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Paste differently&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#gP&quot;&gt;&lt;code&gt;gP&lt;/code&gt;&lt;/a&gt; command pastes before your cursor like &lt;code&gt;P&lt;/code&gt;, but leaves your cursor to the end of the pasted text instead of before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is effectively identical to manually restoring your cursor position before pasting with &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-03-12T22:33:30.150" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2526" PostTypeId="1" CreationDate="2015-03-13T02:44:00.040" Score="12" ViewCount="4615" Body="&lt;p&gt;I use an example of javascript code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1        var a = 1;&#xA;2        var b = |{};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The cursor is at the position of &lt;code&gt;|&lt;/code&gt;( on the character &quot;{&quot; when the cursor shape is block), I find out that I want &lt;code&gt;a&lt;/code&gt; should be assigned an object, so I want to modify it like below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1        var a = {};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I want to know when cursor is on &quot;{&quot;, how to quickly delete all the contents before &quot;{&quot; until the blank after the &quot;=&quot; sign at line 1?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other normal editors, I'll just press backspace key to delete the code. But I don't how to achieve this in vim.&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="467" LastEditDate="2015-03-13T11:44:09.287" LastActivityDate="2015-03-15T20:47:19.667" Title="How to delete content backwards until &quot;=&quot; at the previous line?" Tags="|insert-mode|normal-mode|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2527" PostTypeId="2" ParentId="2526" CreationDate="2015-03-13T02:52:11.547" Score="25" Body="&lt;p&gt;Not sure if I totally understand the question, but if you wanted to delete until you only have  &lt;code&gt;var a = {};&lt;/code&gt;, you could, from the cursor position, use &lt;kbd&gt;d?1&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;d&lt;/kbd&gt; takes a motion, and you can give it a search pattern with &lt;kbd&gt;/&lt;/kbd&gt; for a forward search or &lt;kbd&gt;?&lt;/kbd&gt; for a backward search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a small gif demonstrating this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gr2TJ.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="246" LastEditDate="2015-03-13T10:09:32.777" LastActivityDate="2015-03-13T10:09:32.777" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2528" PostTypeId="1" AcceptedAnswerId="2532" CreationDate="2015-03-13T07:33:56.107" Score="8" ViewCount="3609" Body="&lt;p&gt;I usually jump to next mark in file using &lt;code&gt;]'&lt;/code&gt; and &lt;code&gt;['&lt;/code&gt; commands. But I am not able to find a way to discover whether there are any marks set on current line.&lt;/p&gt;&#xA;" OwnerUserId="230" LastEditorUserId="343" LastEditDate="2015-03-13T09:55:40.097" LastActivityDate="2015-03-13T10:39:10.787" Title="How do I display any marks that are set on the current line?" Tags="|mark|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2529" PostTypeId="1" AcceptedAnswerId="2530" CreationDate="2015-03-13T08:58:55.957" Score="5" ViewCount="2153" Body="&lt;p&gt;Take markdown file  as an example. I often found that some downloaded files suffixed with &lt;code&gt;.md&lt;/code&gt; (rather than &lt;code&gt;.markdown&lt;/code&gt;) can be recognized as markdown file, and syntax-highlighted as such. However, it won't work if I plainly create a file suffixed with &lt;code&gt;.md&lt;/code&gt; and open it. I have to &lt;code&gt;:set syntax=markdown&lt;/code&gt; so that Vim can highlight the file properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I noticed that the syntax in some system files with strange suffix such as &lt;code&gt;.list&lt;/code&gt; can be magically highlighted. For example, on my Ubuntu system there is a file &lt;code&gt;/etc/apt/sources.list&lt;/code&gt;. Upon opening it, Vim can correctly recognize the syntax in the file is &lt;code&gt;debsources&lt;/code&gt;. But it won't be so if I copy the file to &lt;code&gt;~/Desktop&lt;/code&gt; and open again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another example, in the same directory &lt;code&gt;/etc/apt/apt.conf.d&lt;/code&gt;, there are files with no extension at all, and they can all be recognized having &lt;code&gt;aptconf&lt;/code&gt; syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how does Vim determine which syntax to use for highlighting when encountering strange extensions or no extension at all?&lt;/p&gt;&#xA;" OwnerUserId="682" LastEditorUserId="24" LastEditDate="2015-03-13T20:43:58.530" LastActivityDate="2015-03-13T20:43:58.530" Title="How does Vim know how to syntax-highlight some files with strange extension or without extension at all?" Tags="|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2530" PostTypeId="2" ParentId="2529" CreationDate="2015-03-13T09:43:38.770" Score="10" Body="&lt;p&gt;In the file recognition procedure used to detect what syntax highlighting to use, there can be a few kinds of checks. The most known one is checking the the file extension. This is done by a command of the following structure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.my             setfiletype my-type&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another way, used for makefiles for example, is assigning the auto-cmd too the file name. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The methods that confused you are checking the file path, and checking the file contents in order to detect the file type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to check file contents you can write code similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if did_filetype()       &quot; filetype already set..&#xA;   finish                &quot; ..don't do these checks&#xA;endif&#xA;if getline(1) =~ '^#!.*\&amp;lt;mine\&amp;gt;'&#xA;  setfiletype mine&#xA;elseif getline(1) =~? '\&amp;lt;drawing\&amp;gt;'&#xA;  setfiletype drawing&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More info can be fond in &lt;a href=&quot;http://vimhelp.appspot.com/filetype.txt.html#new-filetype&quot;&gt;&lt;code&gt;:help new-filetype&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="342" LastActivityDate="2015-03-13T09:43:38.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2531" PostTypeId="2" ParentId="2526" CreationDate="2015-03-13T10:06:47.980" Score="7" Body="&lt;h2&gt;Delete Up&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For this specific example, &lt;code&gt;dgk&lt;/code&gt; is one of the quickest ways to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;d&lt;/code&gt; command, as &lt;a href=&quot;https://vi.stackexchange.com/a/2527/343&quot;&gt;Akshay explained&lt;/a&gt;, can be followed by a motion, deleting all the characters between where the cursor begins, and where the motion takes it to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your code, you want to to delete everything between the cursor position and the same column one row further up, so moving the cursor upwards with the &lt;code&gt;gk&lt;/code&gt; motion (which when used with an operator is non-linewise) will achieve your goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; BobH &lt;a href=&quot;https://vi.stackexchange.com/questions/2526/how-to-delete-content-backwards-until-at-the-previous-line/2531#comment2492_2531&quot;&gt;points out in the comments&lt;/a&gt; that this method only works when &lt;code&gt;'wrap'&lt;/code&gt; is set. As such, unless you &lt;em&gt;always&lt;/em&gt; have wrap set, you're probably better off using &lt;code&gt;dvk&lt;/code&gt; or &lt;code&gt;vkd&lt;/code&gt;, as suggested by the other answers on this page.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Delete Words Backwards&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You could also use: &lt;code&gt;d5b&lt;/code&gt; or &lt;code&gt;d4B&lt;/code&gt;, which will delete 5 words or 4 WORDs backwards, respectively. (&lt;code&gt;1;&lt;/code&gt; is one WORD, but two regular words).&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2015-03-15T20:47:19.667" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="2532" PostTypeId="2" ParentId="2528" CreationDate="2015-03-13T10:25:55.200" Score="11" Body="&lt;p&gt;There is no way to make marks &lt;strong&gt;visible&lt;/strong&gt; in vim proper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is however enough to just list them you can issue the &lt;code&gt;:marks&lt;/code&gt; &lt;em&gt;normal&lt;/em&gt;-mode command, which will give you a list of all marks in the current buffer and all global marks (the one with capitalized letters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally there is a plugin called &lt;em&gt;showmarks&lt;/em&gt; that will do the job. It displays a column left to the linenumbers-column which will contain the names of the marks on a specific line. This includes global marks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few versions of this plugin exist, i've found that Jacques Bodin-Hullin's version is the only one that seems to work without problems in any current version of vim (greater or equal than 7.4). It is located on github: &lt;a href=&quot;https://github.com/jacquesbh/vim-showmarks&quot;&gt;jacquesbh/vim-showmarks&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using &lt;a href=&quot;https://github.com/gmarik/Vundle.vim&quot;&gt;Vundle&lt;/a&gt; as your plugin manager you can register it with the following line in your &lt;em&gt;.vimrc&lt;/em&gt;, after doing a &lt;code&gt;:PluginInstall jacquesbh/vim-showmarks&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call vundle#begin()&#xA;&quot; ... other plugins&#xA;Plugin 'jacquesbh/vim-showmarks'&#xA;call vundle#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After you've installed showmarks you can make the marks visible with &lt;code&gt;:DoShowMarks&lt;/code&gt; and hide them again with &lt;code&gt;:NoShowMarks&lt;/code&gt; - an &lt;code&gt;!&lt;/code&gt; at the end will execute the command for all buffers.&lt;/p&gt;&#xA;" OwnerUserId="1335" LastEditorUserId="1335" LastEditDate="2015-03-13T10:39:10.787" LastActivityDate="2015-03-13T10:39:10.787" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2533" PostTypeId="2" ParentId="2526" CreationDate="2015-03-13T10:58:56.807" Score="11" Body="&lt;p&gt;If you are using vim (and not classic vi), then in your example you could do &lt;code&gt;vkd&lt;/code&gt; (or &lt;code&gt;vkx&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;v&lt;/code&gt; will put it into 'visual' (select) mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;k&lt;/code&gt; will go up one line to put the cursor on the '1', selecting the portion you want deleted&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d&lt;/code&gt; or &lt;code&gt;x&lt;/code&gt; will delete the selection&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1344" LastActivityDate="2015-03-13T10:58:56.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2534" PostTypeId="2" ParentId="2526" CreationDate="2015-03-13T12:57:13.880" Score="1" Body="&lt;p&gt;I can't yet comment, so I need to make a new answer. The keys &lt;kbd&gt;d&#xA;&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; given by Rich don't work for me even when using the nocompatible option. A reason might be that the motion &lt;kbd&gt;k&lt;/kbd&gt; is considered linewise by vim, in which case both lines are deleted. From &lt;code&gt;:help d&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An exception for the d{motion} command: If the motion is not linewise, the&#xA;  start and end of the motion are not in the same line, and there are only&#xA;  blanks before the start and after the end of the motion, the delete becomes&#xA;  linewise.  This means that the delete also removes the line of blanks that you&#xA;  might expect to remain. Use the |o_v| operator to force the motion to be&#xA;  characterwise&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It also shows the remedy: Use &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; to force the motion to be character-wise. This does the trick for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't know o_v before, so here's &lt;code&gt;:help o_v&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;v               &lt;/p&gt;&#xA;  &#xA;  &lt;blockquote&gt;&#xA;    &lt;p&gt;When used after an operator, before the motion command: Force&#xA;                  the operator to work characterwise, also when the motion is&#xA;                 linewise.  If the motion was linewise, it will become&#xA;                |exclusive|.&#xA;               If the motion already was characterwise, toggle&#xA;              inclusive/exclusive.  This can be used to make an exclusive&#xA;                   motion inclusive and an inclusive motion exclusive&lt;/p&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="1296" LastEditDate="2015-03-13T13:03:13.473" LastActivityDate="2015-03-13T13:03:13.473" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2536" PostTypeId="2" ParentId="2517" CreationDate="2015-03-13T13:34:49.880" Score="0" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/[?&amp;amp;]\ze.\{-}=[^&amp;amp;\r[:blank:]]\+/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It replaces all &lt;code&gt;?&lt;/code&gt; and &lt;code&gt;&amp;amp;&lt;/code&gt; (&lt;code&gt;[?&amp;amp;]&lt;/code&gt;) with new line (&lt;code&gt;\r&lt;/code&gt;) which are followed by &lt;code&gt;a=b&lt;/code&gt; patterns ending with &lt;code&gt;&amp;amp;&lt;/code&gt;, new line or space characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; - Is the start and end of a pattern (these can be used independently).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[?&amp;amp;]&lt;/code&gt; - Match either &lt;code&gt;?&lt;/code&gt; or &lt;code&gt;&amp;amp;&lt;/code&gt; character.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.\{-}&lt;/code&gt; - Non-greedy quantifier which match as few as possible characters.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^&amp;amp;\r[:blank:]]&lt;/code&gt; - Match all characters which are NOT &lt;code&gt;&amp;amp;&lt;/code&gt;, new line, space and tab characters.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-03-13T18:46:07.987" LastActivityDate="2015-03-13T18:46:07.987" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2537" PostTypeId="2" ParentId="2517" CreationDate="2015-03-13T14:20:10.933" Score="0" Body="&lt;p&gt;If you're not doing this a lot of times, it's pretty quick to do it manually:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;?&lt;/kbd&gt;: Delete to the start of the parameters,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;&amp;amp;&lt;/kbd&gt;: Jump to the next parameter&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;: Replace the &lt;code&gt;&amp;amp;&lt;/code&gt; with a newline,&lt;/li&gt;&#xA;&lt;li&gt;Then just mash &lt;kbd&gt;;&lt;/kbd&gt;&lt;kbd&gt;.&lt;/kbd&gt; repeatedly until you've separated all the parameters. (&lt;kbd&gt;;&lt;/kbd&gt; jumps forward to the next occurrence of the last &lt;kbd&gt;f&lt;/kbd&gt; command, and &lt;kbd&gt;.&lt;/kbd&gt; repeats the last edit operation.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Depending on how many parameters there are, it won't be many more keypresses that the answers already posted using &lt;code&gt;:substitute&lt;/code&gt;, but, for me at least, it requires even less brainpower.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2015-03-16T10:27:01.773" LastActivityDate="2015-03-16T10:27:01.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2538" PostTypeId="1" AcceptedAnswerId="2539" CreationDate="2015-03-13T19:12:13.347" Score="7" ViewCount="3151" Body="&lt;p&gt;I have this sample line in the buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export PS1=&quot;\[${Cyan}\]$(((SHLVL&amp;gt;1)) &amp;amp;&amp;amp; echo &quot;${SHLVL}\[${IBlack}\].&quot;)\[${IGreen}\]\u\[${IBlack}\]@\[${Purple}\]\h\[${IYellow}\] \w \$ \[${Color_Off}\]&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and i want to delete all &lt;code&gt;\[&lt;/code&gt; so while the cursor is on the line i write &lt;code&gt;:s/\\[//g&lt;/code&gt; and get the error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E486: Pattern not found: \\[//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What do i do wrong? Somehow vim thinks that &lt;code&gt;//g&lt;/code&gt; is part of the pattern?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When i search with &lt;code&gt;/\\[&lt;/code&gt; i get proper results.&lt;/p&gt;&#xA;" OwnerUserId="1067" LastEditorUserId="24" LastEditDate="2015-03-13T20:36:49.590" LastActivityDate="2015-03-15T14:06:07.340" Title="regex: how to replace &quot;\[&quot;?" Tags="|regular-expression|substitute|error|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2539" PostTypeId="2" ParentId="2538" CreationDate="2015-03-13T19:30:47.313" Score="6" Body="&lt;p&gt;I found the reason: &lt;code&gt;[&lt;/code&gt; is special character so vim treats next characters as part of the set (&lt;code&gt;[...]&lt;/code&gt;) although it doesn't have the closing bracket. The proper replace should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\\\[//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(One backslash more)&lt;/p&gt;&#xA;" OwnerUserId="1067" LastActivityDate="2015-03-13T19:30:47.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2540" PostTypeId="2" ParentId="2538" CreationDate="2015-03-13T19:34:02.613" Score="3" Body="&lt;p&gt;The error gives it away: Vim interprets the whole &lt;code&gt;\\[//g&lt;/code&gt; as the pattern. It doesn't recognize the &lt;code&gt;/&lt;/code&gt; separator because the &lt;code&gt;[&lt;/code&gt; starts an (unclosed) collection. You either need to escape (via another backslash: &lt;code&gt;:s/\\\[//g&lt;/code&gt;, or use &lt;em&gt;very nomagic&lt;/em&gt; mode via &lt;code&gt;\V&lt;/code&gt;: &lt;code&gt;:s/\V\\[//g&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2015-03-13T19:49:47.287" LastActivityDate="2015-03-13T19:49:47.287" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2541" PostTypeId="1" AcceptedAnswerId="3571" CreationDate="2015-03-13T20:01:53.273" Score="6" ViewCount="200" Body="&lt;p&gt;Is there any way to make vim treat bash variables (anything prefixed with a &lt;code&gt;$&lt;/code&gt;, really) as distinct words? For instance, with the following lines: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;name $suffix.ext&quot;&#xA;&quot;name$suffix.ext&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the cursor somewhere in &lt;code&gt;$suffix&lt;/code&gt;, the motion &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; should leave me with &lt;code&gt;&quot;name .ext&quot;&lt;/code&gt; and &lt;code&gt;&quot;name.ext&quot;&lt;/code&gt;, respectively. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My primary reason for wanting this is to enable me to use some mappings I have for wrapping words in quotes/parens/etc with bash variables. I'm okay with changing the mapping as long as it still works with normal words, but I would prefer not to have to make this a syntax-specific mapping (but if there's no easy way around that, I can deal with it). (Here's one of the quote wrapping mappings I referenced: &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;&quot; viw&amp;lt;esc&amp;gt;a&quot;&amp;lt;esc&amp;gt;hbi&quot;&amp;lt;esc&amp;gt;lel&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially, I thought I could do this with &lt;code&gt;set iskeyword&lt;/code&gt;, but I could only make that work for cases such as &lt;code&gt;name $suffix.ext&lt;/code&gt;, and it then makes performance for &lt;code&gt;name$suffix.ext&lt;/code&gt; cases worse, in my opinion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My other thoughts were along the lines of getting vim to recognize &lt;code&gt;$&lt;/code&gt; and &lt;code&gt;[any word separator]&lt;/code&gt; as either&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a matching pair (like &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;( this seems like too much potential for bad side effects)) &lt;/li&gt;&#xA;&lt;li&gt;or a &quot;tag&quot; (i.e., like html/xml tags that &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;) recognizes (never messed with those, so I wasn't sure where to begin there)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1166" LastEditorUserId="24" LastEditDate="2015-03-13T20:34:41.297" LastActivityDate="2015-06-12T19:26:14.560" Title="Recognize bash variable as distinct word" Tags="|cursor-motions|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2542" PostTypeId="1" AcceptedAnswerId="2619" CreationDate="2015-03-13T21:46:35.140" Score="7" ViewCount="1067" Body="&lt;p&gt;I'm using airline in vim on the terminal (as part of spf-13, fyi). However, all kinds of other random info (including other open buffers) tends to fill up the line and push out or cover what the name of the current file I'm editing is, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NORMAL  +5 ~1 -0  master  &amp;lt;.test --ipdb      python  env_awi  utf-8[unix]   33%   44:  2 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.test --ipdb&lt;/code&gt; is the the name of one of the open buffers (not the current one) and is partially cut off by the &lt;code&gt;&amp;lt;.&lt;/code&gt; to the left of which are the other open buffers which are covered up.  Any way to make the current file the only one that shows up, so I know which file I'm currently editing?&lt;/p&gt;&#xA;" OwnerUserId="1336" LastEditorUserId="51" LastEditDate="2015-03-14T00:20:46.373" LastActivityDate="2015-03-18T15:38:55.320" Title="Current filename not visible in airline" Tags="|vimrc|plugin-airline|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2543" PostTypeId="1" AcceptedAnswerId="2546" CreationDate="2015-03-13T22:14:58.327" Score="21" ViewCount="3000" Body="&lt;p&gt;&lt;em&gt;N.B. This is&lt;/em&gt; not &lt;em&gt;a duplicate of &lt;a href=&quot;https://vi.stackexchange.com/questions/2301/how-does-the-d3fg-command-work&quot;&gt;How does the &amp;quot;d3fg&amp;quot; command work?&lt;/a&gt; Please read it before voting to close!&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've come to a bit of an impasse in my &lt;a href=&quot;https://vi.stackexchange.com/questions/2493/can-i-make-vim-also-save-small-deletions-into-register-1&quot;&gt;quest to get small deletions work like big ones&lt;/a&gt;. The problem I've got is that I can't figure out how to remap commands like &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;. In fact, I can't even understand how they work in the first place, nor find any mention of them in Vim's help.*&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; is straightforward: it applies the &lt;code&gt;d&lt;/code&gt; operator to the &lt;code&gt;3j&lt;/code&gt; motion,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; is also straightforward: it runs the &lt;code&gt;dd&lt;/code&gt; command with a &quot;count&quot; of 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; &lt;em&gt;looks&lt;/em&gt; like it should be straightforward, it applies the &lt;code&gt;d&lt;/code&gt; operator to the&amp;hellip; but what is &lt;code&gt;3d&lt;/code&gt;? It's not a motion. If you type &lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; on its own, Vim treats it as a count followed by an operator, and waits patiently for further input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you can't apply operators to other operators. &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; isn't described in the help as a sequence of two operators. It's a separate, two-keystroke command. (cf. &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;, which does nothing.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also doesn't appear to be the case that the positioning of the count is flexible for commands that require two keystrokes: &lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; moves the cursor down two screen-lines, but &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; discards the first two keypresses entirely and moves the cursor down one line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how does it work? Is this just a special case in Vim's internal code? Is there any way I can create a &lt;code&gt;d[count]d&lt;/code&gt; mapping?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: Is it a text object? &lt;code&gt;:h text-objects&lt;/code&gt; doesn't include it in the list of &quot;text object selection commands&quot;, but then it &lt;em&gt;does&lt;/em&gt; include dd in a list of deletions &quot;grouped from small to big objects&quot;. And &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; does delete the word under the cursor and the following one. On the other hand, &lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* I'm sure some mention of them must exist, but I can't find it. I've read &lt;code&gt;:help deleting&lt;/code&gt;, &lt;code&gt;:help motion.txt&lt;/code&gt;, and tried &lt;code&gt;:helpgrep dNd&lt;/code&gt; for all values of N from 1&amp;ndash;9&lt;/sub&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-12-06T11:22:17.207" LastActivityDate="2017-12-06T11:22:17.207" Title="How can I map d[count]d?" Tags="|key-bindings|cut-copy-paste|normal-mode|count|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2544" PostTypeId="1" AcceptedAnswerId="2749" CreationDate="2015-03-13T22:45:35.393" Score="7" ViewCount="1897" Body="&lt;p&gt;When working on a git project in vim, I use the &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;noreferrer&quot;&gt;fugitive&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like to open a &lt;code&gt;:Gstatus&lt;/code&gt; split, press &lt;code&gt;-&lt;/code&gt; to add file and then press &lt;code&gt;C&lt;/code&gt; to commit my changes. I also have a git pre-commit hook, it runs some test. In case of an error, it prompts me&#xA;to make sure if I still want to commit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, when following this pattern, I don't see the output for the tests, neither the final prompt. Instead, vim freezes while the tests are running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I make fugitive and a pre-commit hook get along together smoothly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: This is the prompt in the git pre-commit hook:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;exec &amp;lt; /dev/tty&#xA;&#xA;while true; do&#xA;  read -p &quot;There were some errors in the test, do you still want to commit? (Y/n) &quot; yn&#xA;  if [ &quot;$yn&quot; = &quot;&quot; ]; then&#xA;    yn='Y'&#xA;  fi&#xA;  case $yn in&#xA;      [Yy] ) break;;&#xA;      [Nn] ) exit;;&#xA;      * ) echo &quot;Answer y or n.&quot;;;&#xA;  esac&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="812" LastEditorUserId="51" LastEditDate="2015-03-26T21:32:42.063" LastActivityDate="2015-03-26T21:32:42.063" Title="How to manage fugitive commit with a git pre-commit hook?" Tags="|git|plugin-fugitive|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2545" PostTypeId="1" AcceptedAnswerId="2559" CreationDate="2015-03-13T23:18:33.050" Score="14" ViewCount="4806" Body="&lt;p&gt;I would like to run an autocmd in the following scenarios when I start Vim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;With no filename specified.&lt;/li&gt;&#xA;&lt;li&gt;When the file is new.&lt;/li&gt;&#xA;&lt;li&gt;When the file exists but is completely blank.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In all of the above three cases I would like to run an autocmd; specifically, I'd like to &lt;a href=&quot;https://vi.stackexchange.com/questions/257/automatically-load-vi-into-insert-mode&quot;&gt;start insert mode automatically&lt;/a&gt; for &lt;em&gt;only&lt;/em&gt; the above scenarios (and not when I'm opening a file that already exists &amp;amp; isn't blank).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried placing the following in my &lt;code&gt;_vimrc&lt;/code&gt;, but no luck (plus I'm not sure whether there is a function in vim that counts the number of characters in a file (to see if it is zero) before opening it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if @% == &quot;&quot; || filereadable(@%)&#xA;  autocmd BufRead,BufNewFile * startinsert&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-03-15T03:40:50.237" Title="How can I run an autocmd when starting Vim with no file, a non-existing file, or a blank file (but not when starting with an existing file)?" Tags="|vimrc|insert-mode|autocmd|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="2546" PostTypeId="2" ParentId="2543" CreationDate="2015-03-14T00:15:29.583" Score="35" Body="&lt;h1&gt;Operator-pending mode&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Between typing an operator (like &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;, or &lt;code&gt;gU&lt;/code&gt;) and a motion (like &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;i}&lt;/code&gt;, or &lt;code&gt;/foo&amp;lt;CR&amp;gt;&lt;/code&gt;), Vim is in Operator-pending mode. You can create mappings for this using &lt;code&gt;:omap&lt;/code&gt; and &lt;code&gt;:onoremap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my examples, I'm going to map the Operator-pending &lt;code&gt;d&lt;/code&gt; to &lt;code&gt;w&lt;/code&gt;. This is a random choice, because I don't know what you actually wanted to use it for.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Create an omap&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Let's create a mapping for &lt;code&gt;d&lt;/code&gt; in Operator pending mode. I'm gonna assume we're writing VimScript here (such as in your &lt;code&gt;.vimrc&lt;/code&gt;), so I'll omit leading &lt;code&gt;:&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap d w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes &lt;code&gt;dd&lt;/code&gt; act like &lt;code&gt;dw&lt;/code&gt;. It also makes &lt;code&gt;d[count]d&lt;/code&gt; act like &lt;code&gt;d[count]w&lt;/code&gt;. But I bet you didn't want to affect the behaviour of &lt;code&gt;dd&lt;/code&gt; (i.e., no &lt;code&gt;[count]&lt;/code&gt; supplied).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Expression mappings&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Expression mappings let you evaluate a VimScript expression to produce the right-hand-side of the mapping. The expression should evaluate to a string. Expression mappings are denoted by the &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; keyword.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim also has some built-in variables that get populated at various times, and are often useful during mappings. One of them is &lt;code&gt;v:count&lt;/code&gt;, which is the &lt;code&gt;[count]&lt;/code&gt; supplied to an operator or motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's put that all together. If no &lt;code&gt;[count]&lt;/code&gt; is supplied, &lt;code&gt;v:count&lt;/code&gt; will be &lt;code&gt;0&lt;/code&gt;. We can tell our mapping to just use &lt;code&gt;d&lt;/code&gt; in that case.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;expr&amp;gt; d v:count == 0 ? 'd' : 'w'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;dd&lt;/code&gt; behaves like the default (deletes a line), but &lt;code&gt;d[count]d&lt;/code&gt; behaves like &lt;code&gt;d[count]w&lt;/code&gt;. Cool!&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Restrict it to use after the &lt;code&gt;d&lt;/code&gt; operator&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You might notice something, though. Now &lt;code&gt;cd&lt;/code&gt; also behaves like &lt;code&gt;cw&lt;/code&gt;. This may not be a problem, but for completeness, let's restrict it so it only works after the &lt;code&gt;d&lt;/code&gt; operator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has another variable, &lt;code&gt;v:operator&lt;/code&gt;, which contains the operator most recently used. Let's check that, too, before doing anything special.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;expr&amp;gt; d (v:count == 0 \|\| v:operator != 'd') ? 'd' : 'w'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Since &lt;code&gt;:map&lt;/code&gt; commands can be chained with &lt;code&gt;|&lt;/code&gt;, we have to escape them in our expression here. So the logical OR operator &lt;code&gt;||&lt;/code&gt; becomes &lt;code&gt;\|\|&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cool, so &lt;code&gt;cd&lt;/code&gt; and &lt;code&gt;c[count]d&lt;/code&gt; are back to doing nothing, just like they used to. This is good so that other plugins can define &lt;code&gt;cd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;I don't want to just delete some other motion&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you wanted to map &lt;code&gt;d[count]d&lt;/code&gt; to something totally different, nothing to do with deleting text, we can make that work too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you're typing commands in Normal mode, and you start typing a command by mistake, you can hit &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to cancel that command. The same applies to your mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's make &lt;code&gt;d[count]d&lt;/code&gt; change the current line to whatever &lt;code&gt;[count]&lt;/code&gt; is.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;expr&amp;gt; d (v:count == 0 \|\| v:operator != 'd') ? 'd' : '&amp;lt;Esc&amp;gt;cc' . v:count . '&amp;lt;Esc&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last part of the mapping is a VimScript expression: &lt;code&gt;&amp;lt;Esc&amp;gt;cc' . v:count . '&amp;lt;Esc&amp;gt;'&lt;/code&gt;. That's &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to cancel the pending &lt;code&gt;d&lt;/code&gt; command, then &lt;code&gt;cc&lt;/code&gt; to change the current line, &lt;code&gt;v:count&lt;/code&gt; to type the value of the &lt;code&gt;[count]&lt;/code&gt; (in Insert mode), and &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to return to Normal mode. Note that we're building a string here using the VimScript concatenation operator, &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your actual use case is probably going to be different from what I've outlined here, but hopefully this helps you to get the ball rolling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Happy Vimming!&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-03-14T00:15:29.583" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2547" PostTypeId="1" AcceptedAnswerId="2551" CreationDate="2015-03-14T08:22:17.010" Score="5" ViewCount="1252" Body="&lt;p&gt;I have a handful of files (LaTeX documents) that have one specific proper name that is really obnoxious to type out but used frequently. I've eased the pain of this with an abbreviation like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iab Eİ Elçilerin İşleri&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works great, but I don't want to pollute my global vimrc with document specific hacks like this. Is there a way to set an abbrieviation in the modeline? I tried appending it as is, but modelines appear to only work with &lt;code&gt;set&lt;/code&gt; commands.&lt;/p&gt;&#xA;" OwnerUserId="267" LastActivityDate="2015-03-17T08:02:21.283" Title="Is there a way to set an abbreviation in a modeline so it is always available local to one file buffer?" Tags="|abbreviations|modeline|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2548" PostTypeId="2" ParentId="2547" CreationDate="2015-03-14T09:18:43.457" Score="12" Body="&lt;p&gt;&lt;code&gt;:help modeline&lt;/code&gt; is pretty specific about this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;No other commands than &quot;set&quot; are supported, for security reasons (somebody&#xA;  might create a Trojan horse text file with modelines).  And not all options&#xA;  can be set.  For some options a flag is set, so that when it's used the&#xA;  |sandbox| is effective[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Hint: If you would like to do something else than setting an option, you could&#xA;  define an autocommand that checks the file for a specific string.  For&#xA;  example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   au BufReadPost * if getline(1) =~ &quot;VAR&quot; | call SetVar() | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;And define a function SetVar() that does something with the line containing&#xA;  &quot;VAR&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you're looking for a workaround, you could try using a local &lt;code&gt;.vimrc&lt;/code&gt; with &lt;code&gt;:set exrc&lt;/code&gt;. Before doing so, be sure to consider the security implications mentioned in &lt;code&gt;:help 'exrc'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2015-03-14T09:18:43.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2549" PostTypeId="2" ParentId="2541" CreationDate="2015-03-14T09:24:17.123" Score="0" Body="&lt;p&gt;You could add &lt;code&gt;$&lt;/code&gt; to the &lt;code&gt;iskeyword&lt;/code&gt; option for shell scripts in your &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup shellscript&#xA;    autocmd!&#xA;    autocmd FileType sh setlocal iskeyword+=$&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could do that in &lt;code&gt;~/.vim/after/ftplugin/sh.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal iskeyword+=$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-03-14T09:24:17.123" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2550" PostTypeId="1" AcceptedAnswerId="2558" CreationDate="2015-03-14T10:43:45.163" Score="4" ViewCount="1185" Body="&lt;p&gt;I'm writing a script that creates a window that I'd like to be completely transient, like a help window. Specifically, if the user closes every window but this one, I want Vim to quit. (In the same way that if you have a single window open with no unsaved files, then the string of commands: &lt;code&gt;:help&lt;/code&gt;, &lt;kbd&gt;Ctrl-W&lt;/kbd&gt;, &lt;code&gt;:quit&lt;/code&gt;, will cause Vim to quit.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd also like the buffer not to appear in the buffer list and be deleted when the window closes, but my current code (below) achieves this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The window works exactly how I want if I &lt;code&gt;buftype&lt;/code&gt; to be &lt;code&gt;help&lt;/code&gt; or &lt;code&gt;quickfix&lt;/code&gt;, but as the documentation states, &quot;you are not supposed to set this manually&quot;/&quot;You are not supposed to change this!&quot;. Also, these buftypes will be reflected in some people's status lines, which is not ideal&amp;thinsp;&amp;mdash;&amp;thinsp;the buffer is not actually either of these things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current settings for the buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal buftype=nofile&#xA;setlocal bufhidden=delete&#xA;setlocal nobuflisted&#xA;setlocal noswapfile&#xA;setlocal nomodifiable&#xA;setlocal readonly&#xA;setlocal nomodified&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I had a look to see if I could hack it by setting up an autocmd to quit Vim if all the other windows are closed, but there doesn't appear to be a event for window closes.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2015-03-25T04:03:42.650" Title="How can I get a window to close automatically when all other windows have closed?" Tags="|buffers|vim-windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2551" PostTypeId="2" ParentId="2547" CreationDate="2015-03-14T12:24:39.863" Score="7" Body="&lt;p&gt;As it has been said, it's not possible by design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want something like modelines, you'll have to write your own plugin. In the early 2000 I wrote &lt;a href=&quot;https://github.com/LucHermitte/lh-misc/blob/master/plugin/let-modeline.vim&quot; rel=&quot;noreferrer&quot;&gt;let-modeline&lt;/a&gt; that decodes a slightly different format of modelines (i.e. &lt;code&gt;Vim: let var=expr&lt;/code&gt;) to set variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For something more complex than a variable, I'd also use a local vimrc. However I wouldn't use &lt;code&gt;.exrc&lt;/code&gt; that works only for files in the same directory where the &lt;code&gt;.exrc&lt;/code&gt; file is. Plugins like &lt;a href=&quot;https://github.com/LucHermitte/local_vimrc&quot; rel=&quot;noreferrer&quot;&gt;local_vimrc&lt;/a&gt; support hierarchies of directories.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2015-03-17T08:02:21.283" LastActivityDate="2015-03-17T08:02:21.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2552" PostTypeId="1" AcceptedAnswerId="2555" CreationDate="2015-03-14T15:01:38.383" Score="14" ViewCount="1744" Body="&lt;p&gt;Without plugins like &lt;code&gt;ctrlp&lt;/code&gt; and &lt;code&gt;NERDTree&lt;/code&gt;, what would be the most efficient way to find and open files deep in a project tree? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting the &lt;code&gt;path&lt;/code&gt; to &lt;code&gt;**/*&lt;/code&gt; results in useless files in &lt;code&gt;.git&lt;/code&gt; and other hidden directories, so that appears to be out of the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to set the path in a &lt;em&gt;smart&lt;/em&gt; manner, so that it only includes files in &lt;code&gt;git ls-files&lt;/code&gt; or something?&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastEditorUserId="467" LastEditDate="2015-03-15T13:13:11.243" LastActivityDate="2017-02-08T19:59:55.167" Title="Efficient way to find &amp; open files deep in a project tree?" Tags="|multiple-files|path|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2553" PostTypeId="1" CreationDate="2015-03-14T15:37:44.973" Score="2" ViewCount="202" Body="&lt;p&gt;I want Vim to treat the following as separate words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FirstSecondThird&#xA;firstSecondThird&#xA;first_second_third&#xA;first.second.third&#xA;first-second-third&#xA;first#second#third&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the best solution for this? As I understand&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword=@,48-57,_,192-255,-,#,.,?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Coupled with &lt;code&gt;camelcasemotion&lt;/code&gt; should do the trick.&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="237" LastEditDate="2015-03-16T11:06:16.973" LastActivityDate="2015-05-27T16:58:22.973" Title="What's the best way to arrange subwords navigation?" Tags="|cursor-motions|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2555" PostTypeId="2" ParentId="2552" CreationDate="2015-03-14T17:59:58.913" Score="27" Body="&lt;p&gt;Here are the relevant parts of my setup:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;enable the wildmenu,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmenu&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;make filename-completion skip these files and directories,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildignore+=*.swp,*.bak&#xA;set wildignore+=*.pyc,*.class,*.sln,*.Master,*.csproj,*.csproj.user,*.cache,*.dll,*.pdb,*.min.*&#xA;set wildignore+=*/.git/**/*,*/.hg/**/*,*/.svn/**/*&#xA;set wildignore+=*/min/*&#xA;set wildignore+=tags,cscope.*&#xA;set wildignore+=*.tar.*&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;make it case-insensitive,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildignorecase&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;list files and let the user choose with the wildmenu,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmode=list:full&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;add the directory of the current file and every directory under the working directory to Vim's &lt;code&gt;path&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path=.,**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;WARNING! The path option is &lt;em&gt;extremely&lt;/em&gt; useful. The value above — &lt;code&gt;.,**&lt;/code&gt; — works for &lt;em&gt;me&lt;/em&gt; but the languages I use don't have a standard library. The &lt;em&gt;proper&lt;/em&gt; value depends entirely on &lt;em&gt;your&lt;/em&gt; needs.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;a bunch of &lt;code&gt;:find&lt;/code&gt; mappings, the uppercase variants start the search from the directory of the current file for better performance,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ,f :find *&#xA;nnoremap ,F :find &amp;lt;C-R&amp;gt;=expand('%:p:h').'/**/*'&amp;lt;CR&amp;gt;&#xA;nnoremap ,s :sfind *&#xA;nnoremap ,S :sfind &amp;lt;C-R&amp;gt;=expand('%:p:h').'/**/*'&amp;lt;CR&amp;gt;&#xA;nnoremap ,v :vert sfind *&#xA;nnoremap ,V :vert sfind &amp;lt;C-R&amp;gt;=expand('%:p:h').'/**/*'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And here is how it looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/d00pr.gif&quot; alt=&quot;:find&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2017-02-08T19:59:55.167" LastActivityDate="2017-02-08T19:59:55.167" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2556" PostTypeId="2" ParentId="2552" CreationDate="2015-03-14T20:19:04.813" Score="1" Body="&lt;p&gt;My method include the following shell function in &lt;code&gt;~/.bash_profile&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimf() {&#xA;  vim $(find . -name $1)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then to open any file deep in the project tree, just type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimf some_file.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-03-14T20:19:04.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2558" PostTypeId="2" ParentId="2550" CreationDate="2015-03-15T03:18:15.330" Score="5" Body="&lt;p&gt;You can use the autocommand for WinEnter to accomplish this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, mark your buffer with a token for your plugin. We'll use a buffer local variable of our choosing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MakeMyWindow()&#xA;    &quot; Stuff like your setlocal buftype and such goes here&#xA;    let b:mypluginmarker = 1    &quot; re-label this variable to be named after your plugin&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then make a function that looks for the token if there is only one window, and quit if that is the case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function TestMyWindowIsOnlyWindow()&#xA;    if winnr('$') == 1 &amp;amp;&amp;amp; exists(&quot;b:mypluginmarker&quot;) &amp;amp;&amp;amp; b:mypluginmarker == 1&#xA;        quit&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function call &lt;code&gt;winnr('$')&lt;/code&gt; returns the window number of the last window in the current tab. If the last window is 1, then there is only one window open. If that's the case, we check if the marker variable we created on our buffer exists in the current (only) window, and if it exists, we check that it is equal to 1 (the value we set before). If these conditions exist, we quit (on this window). I like the extra check for the value on top of the exists check to allow someone to prevent the closure by changing the variable's value without them having to know how to &lt;code&gt;:unlet&lt;/code&gt; a variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, Set an autocommand to call our test function on WinEnter.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au WinEnter * call TestMyWindowIsOnlyWindow()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason this works is that when someone closes (or quits) a window and there are other windows, the window where the cursor goes gets a WinEnter event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; We use a buffer local variable instead of a window local variable since it is the window holding the buffer which is &quot;transient&quot; (thanks @Rich for pointing this out). If we used a window local variable, and the buffer changed, vim would still exit if the window became the last, which isn't what a user would expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; This method will not close the tab (or Vim) if the cursor was already in your window when the other window(s) are closed (for example, by executing &lt;kbd&gt;Ctrl+W&lt;/kbd&gt; &lt;kbd&gt;O&lt;/kbd&gt;). This behaviour is probably what people would expect anyway though, and does behave like the help window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; This method &lt;em&gt;will&lt;/em&gt; close the tab if the other window was active and closed by a method other than &lt;code&gt;:quit&lt;/code&gt; (for example, &lt;kbd&gt;Ctrl+W&lt;/kbd&gt; &lt;kbd&gt;C&lt;/kbd&gt;), which is unlike the behaviour of a help window. This may or may not be an issue for you.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-03-25T04:03:42.650" LastActivityDate="2015-03-25T04:03:42.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2559" PostTypeId="2" ParentId="2545" CreationDate="2015-03-15T03:40:50.237" Score="12" Body="&lt;p&gt;This works for all 3 of your cases for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function InsertIfEmpty()&#xA;    if @% == &quot;&quot;&#xA;        &quot; No filename for current buffer&#xA;        startinsert&#xA;    elseif filereadable(@%) == 0&#xA;        &quot; File doesn't exist yet&#xA;        startinsert&#xA;    elseif line('$') == 1 &amp;amp;&amp;amp; col('$') == 1&#xA;        &quot; File is empty&#xA;        startinsert&#xA;    endif&#xA;endfunction&#xA;&#xA;au VimEnter * call InsertIfEmpty()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These could probably be condensed into just the last check for a file being empty, since no filename or a file that doesn't exist typically start as empty buffers. However, it is probably possible that some other plugin pre-fills some stuff in one of the first two cases (like some template plugins), so it is best to check all three.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first test you already had.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second test needs to check &lt;code&gt;filereadable&lt;/code&gt; against the value of zero (doesn't exist) to decide if it is new (opposite of what you had).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last test checks that the number of the last line in the file is 1 (which is also the first line, meaning that there is only one line), and that the column number of the end of line (column after the last character in the line) is 1, which would mean there are 0 characters. If there is only 1 line with 0 characters in it, then the file must be empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One final note: The way you have your statements in the question can result in some surprising results. Namely, you are setting &lt;code&gt;BufRead&lt;/code&gt; and &lt;code&gt;BufNewFile&lt;/code&gt; only if conditions are met at startup, but then those autocommands exist for the rest of your session. So, if you were to start on an empty file, which sets these commands, every subsequent file opened (new or not, empty or not) would start in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The autocommand &lt;code&gt;VimEnter&lt;/code&gt; is run at the end of Vim's startup and only once for the whole session. This way, your tests only run when you start Vim and not any other time.&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-03-15T03:40:50.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2560" PostTypeId="1" CreationDate="2015-03-15T04:37:49.703" Score="7" ViewCount="1841" Body="&lt;p&gt;I'm writing javascript code using vim and I really like to have outline view for the current javascript file I'm editing. I find tagbar is the popular plugin for this purpose. And on its wiki, for javascript to work, it recommends jsctags depends on Tern. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I have installed vim plugins: tagbar and tern_for_vim.&lt;/li&gt;&#xA;&lt;li&gt;I've installed exuberant ctags and put its bin into path&lt;/li&gt;&#xA;&lt;li&gt;I have installed jsctags&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I open a js file in vim, and open the tagbar outline view, but there's no tags showing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I try running jsctags against a js file in command line directly, still, nothing is outputted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;has anyone successfully make this combination work? Can someone share some thoughts?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="24" LastEditDate="2015-04-08T13:47:40.860" LastActivityDate="2016-02-03T23:17:24.093" Title="How to view javascript tags in vim using tagbar + jsctags + tern_for_vim + ctags_exuberant?" Tags="|microsoft-windows|filetype-javascript|ctags|plugin-tagbar|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2561" PostTypeId="2" ParentId="13" CreationDate="2015-03-15T05:28:35.963" Score="3" Body="&lt;p&gt;Does enabling mouse helps? This way you should be able at least do selections via touch. Maybe navigate files and buffers/tabs. Depends on plugins I guess.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="237" LastActivityDate="2015-03-15T05:28:35.963" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2562" PostTypeId="1" AcceptedAnswerId="2563" CreationDate="2015-03-15T06:16:34.973" Score="4" ViewCount="144" Body="&lt;p&gt;In some editors, if you press &lt;kbd&gt;↓&lt;/kbd&gt; while in the middle of the last line, it takes you to the end of the line (or, equivalently, the document). I have grown somewhat used to this. How do I obtain the same behaviour in Vim?&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-03-15T17:42:51.410" Title="How can I make a down movement at the last line go to the end of the line?" Tags="|cursor-movement|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2563" PostTypeId="2" ParentId="2562" CreationDate="2015-03-15T06:25:59.357" Score="7" Body="&lt;p&gt;This seems to do what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap &amp;lt;expr&amp;gt; &amp;lt;Down&amp;gt; line('.') == line('$') ? '$' : 'j'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We use the &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; keyword to tell Vim to expect an expression, and use the value of that.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;line('.')&lt;/code&gt; gets the current line number, &lt;code&gt;line('$')&lt;/code&gt; gets the last line number&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For insert mode, you can use a slightly different version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;expr&amp;gt; &amp;lt;Down&amp;gt; line('.') == line('$') ? '&amp;lt;End&amp;gt;' : '&amp;lt;Down&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses &lt;code&gt;&amp;lt;End&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Down&amp;gt;&lt;/code&gt;, rather than &lt;code&gt;$&lt;/code&gt; and &lt;code&gt;j&lt;/code&gt; (actually, those will work in &lt;code&gt;noremap&lt;/code&gt; as well).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="88" LastEditDate="2015-03-15T17:42:51.410" LastActivityDate="2015-03-15T17:42:51.410" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2564" PostTypeId="2" ParentId="2560" CreationDate="2015-03-15T08:42:02.290" Score="4" Body="&lt;pre&gt;&lt;code&gt;:g/func/#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives you an actionable outline of the current JavaScript buffer without installing any third party plugin or requiring any external program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;func\|var&lt;/code&gt; to include variable declarations.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-03-15T08:42:02.290" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2565" PostTypeId="2" ParentId="2538" CreationDate="2015-03-15T14:06:07.340" Score="0" Body="&lt;p&gt;If this would be slash, you could use another delimiter, however backslash (&lt;code&gt;\&lt;/code&gt;) is metacharacter  which escapes any separator, so there is no way to omit two backslashes for backslash it-self. The same with &lt;code&gt;[&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However using different delimiter can still improve the readability:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s,\\\[,,g&#xA;:s@\\\[@@g&#xA;:s#\\\[##g&#xA;:s|\\\[||g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried to test with &lt;code&gt;&amp;lt;Bslash&amp;gt;&lt;/code&gt;,  but it seems substitute doesn't accept it.&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-03-15T14:06:07.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2566" PostTypeId="1" CreationDate="2015-03-15T17:34:14.400" Score="9" ViewCount="9775" Body="&lt;p&gt;I installed &lt;code&gt;ttf-font-awesome&lt;/code&gt; in Arch Linux; if I open up a file which contains icons from Font awesome it recognizes the file as utf-8 but the icons are displayed as squares. Does anyone know how to fix this?&lt;/p&gt;&#xA;" OwnerUserId="977" LastEditorUserId="22516" LastEditDate="2019-06-04T01:55:50.230" LastActivityDate="2020-12-29T22:59:29.593" Title="How to display Font Awesome in Vim?" Tags="|gvim|font|linux-arch|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2567" PostTypeId="2" ParentId="2566" CreationDate="2015-03-15T17:48:41.027" Score="9" Body="&lt;p&gt;First off, Vim can only display a file in a single font, you can't use multiple fonts at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For gVim, you can use &lt;code&gt;guifont&lt;/code&gt; to set this to Font Awesome:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Font\ Awesome\ 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which seems to work fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Terminal Vim, you will need to configure your terminal emulator to use Font Awesome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For xterm, this doesn't seem to work, for gnome-terminal, it does... Other terminal emulators may or may not work...&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-03-15T17:48:41.027" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2569" PostTypeId="1" AcceptedAnswerId="2570" CreationDate="2015-03-16T07:41:48.527" Score="25" ViewCount="8453" Body="&lt;p&gt;In Vimscript, how can I check the current value of a Vim option?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To elaborate, I want to make a command to switch from Full-GUI Mode ( &lt;code&gt;guioptions=+tM&lt;/code&gt;) to Hacker Mode (&lt;code&gt;guioptions=-tM&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I can't seem to find a way to parse the &lt;code&gt;:set guioptions?&lt;/code&gt; value&lt;/p&gt;&#xA;" OwnerUserId="583" LastEditorUserId="51" LastEditDate="2015-03-16T09:21:32.567" LastActivityDate="2015-03-16T09:48:53.690" Title="How do I check the value of a Vim option in Vimscript?" Tags="|vimscript|options|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2570" PostTypeId="2" ParentId="2569" CreationDate="2015-03-16T08:24:52.160" Score="23" Body="&lt;p&gt;You can use the &lt;code&gt;&amp;amp;{option-name}&lt;/code&gt; in an if-statement like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;guioptions ==# &quot;Trl&quot;&#xA;    echo &quot;Toolbars and scrollbars are present!&quot;&#xA;elseif &amp;amp;guioptions ==# &quot;&quot;&#xA;    echo &quot;No toolbars and scrollbars present!&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;amp;&lt;/code&gt; specifies that the variable name is a Vim option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Alet-%26&quot;&gt;&lt;code&gt;:help :let-&amp;amp;&lt;/code&gt;&lt;/a&gt; for the full documentation.&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="51" LastEditDate="2015-03-16T09:32:57.353" LastActivityDate="2015-03-16T09:32:57.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2571" PostTypeId="1" AcceptedAnswerId="2573" CreationDate="2015-03-16T08:31:04.907" Score="11" ViewCount="3851" Body="&lt;p&gt;If I use the command &lt;code&gt;:copen&lt;/code&gt; the quickfix buffer will be opened as a horizontal split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way (a command) to open it in a vertical split instead?&lt;/p&gt;&#xA;" OwnerUserId="1317" LastEditorUserId="24" LastEditDate="2015-03-16T08:42:48.173" LastActivityDate="2015-03-16T08:42:48.173" Title="Open quickfix in vertical split" Tags="|vim-windows|quickfix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2572" PostTypeId="1" AcceptedAnswerId="2574" CreationDate="2015-03-16T08:38:28.257" Score="74" ViewCount="25818" Body="&lt;p&gt;Can I retrieve the current operating system (Windows, Linux, OS X, ..) using &lt;em&gt;pure&lt;/em&gt; Vimscript (no Python or Perl)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to enable different settings in my (synchronized) &lt;em&gt;.vimrc&lt;/em&gt; for different types of operation systems I am using.  &lt;/p&gt;&#xA;" OwnerUserId="1317" LastActivityDate="2021-07-08T20:30:47.700" Title="Detect OS in Vimscript" Tags="|vimscript|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2573" PostTypeId="2" ParentId="2571" CreationDate="2015-03-16T08:38:59.683" Score="13" Body="&lt;p&gt;Prefixing your command with &lt;a href=&quot;https://vimhelp.appspot.com/windows.txt.html#%3Avert&quot;&gt;&lt;code&gt;:vert&lt;/code&gt;&lt;/a&gt; modifies it to use a vertical split:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vert copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24" LastActivityDate="2015-03-16T08:38:59.683" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2574" PostTypeId="2" ParentId="2572" CreationDate="2015-03-16T09:12:44.050" Score="75" Body="&lt;p&gt;The best way is to use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#has%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;has()&lt;/code&gt;&lt;/a&gt;, with&#xA;this function you can check for features of Vim; OS specific features from&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#feature-list&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help feature-list&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;macunix                 Macintosh version of Vim, using Unix files (OS-X).&#xA;unix                    Unix version of Vim.&#xA;win32                   Win32 version of Vim (MS-Windows 95 and later, 32 or&#xA;                        64 bits)&#xA;win32unix               Win32 version of Vim, using Unix files (Cygwin)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And some older (semi-deprecated) systems:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;amiga                   Amiga version of Vim.&#xA;os2                     OS/2 version of Vim.&#xA;win16                   Win16 version of Vim (MS-Windows 3.1).&#xA;win64                   Win64 version of Vim (MS-Windows 64 bit).&#xA;win95                   Win32 version for MS-Windows 95/98/ME.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('win32')&#xA;    echo &quot;Someone please open the Window(s)!&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An alternative way with more flexibility is to call the external &lt;code&gt;uname&lt;/code&gt;, this&#xA;also allows you to get the version number and such:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let uname = system('uname -a')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;uname&lt;/code&gt; isn't present on most Windows systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's generally best to use &lt;em&gt;feature detection&lt;/em&gt;, rather than &lt;em&gt;OS detection&lt;/em&gt;. For example by using one of the features in &lt;code&gt;has()&lt;/code&gt; or checking if some path exists. &lt;a href=&quot;https://vi.stackexchange.com/a/2575/51&quot;&gt;200_success' post&lt;/a&gt; gives a good overview of that, so I'll not repeat the same content here.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2015-03-16T09:18:06.340" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2575" PostTypeId="2" ParentId="2572" CreationDate="2015-03-16T09:13:23.837" Score="8" Body="&lt;p&gt;Environment variables would be useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To detect &lt;code&gt;tmux&lt;/code&gt;, you could check &lt;code&gt;if !empty($TMUX)&lt;/code&gt; or &lt;code&gt;if $TERM == 'screen'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also deduce the operating system from environment variables such as &lt;code&gt;$MACHTYPE&lt;/code&gt; (&lt;a href=&quot;https://www.gnu.org/software/bash/manual/bashref.html#Bash-Variables&quot; rel=&quot;noreferrer&quot;&gt;which is set by Bash&lt;/a&gt;) or &lt;code&gt;$PATH&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To detect whether a feature such as TFS is installed, you can use the &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#executable%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;executable()&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2015-03-16T09:13:23.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2576" PostTypeId="2" ParentId="2569" CreationDate="2015-03-16T09:48:53.690" Score="4" Body="&lt;p&gt;Akshay solved it:&#xA;Just posting the resulting function case other people might need / want it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleMenuBar()&#xA;    let l:menu_option = strridx(&amp;amp;guioptions, &quot;m&quot;)&#xA;    let l:toolbar_option = strridx(&amp;amp;guioptions, &quot;T&quot;)&#xA;    if l:menu_option &amp;gt; 0&#xA;        set guioptions-=m&#xA;    else&#xA;        set guioptions+=m&#xA;    endif&#xA;    if l:toolbar_option &amp;gt; 0&#xA;        set guioptions-=T&#xA;    else&#xA;        set guioptions+=T&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="583" LastActivityDate="2015-03-16T09:48:53.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2577" PostTypeId="2" ParentId="2572" CreationDate="2015-03-16T10:22:13.130" Score="39" Body="&lt;p&gt;&lt;code&gt;has()&lt;/code&gt; sounds like a good idea until you try it on Mac OS X: in the default &lt;code&gt;/usr/bin/vim&lt;/code&gt;, &lt;code&gt;has('unix')&lt;/code&gt; is &lt;em&gt;true&lt;/em&gt; but both &lt;code&gt;has('macunix')&lt;/code&gt; and &lt;code&gt;has('mac')&lt;/code&gt; are &lt;em&gt;false&lt;/em&gt; while, in the regular MacVim download, all three are &lt;em&gt;true&lt;/em&gt; whether you use the GUI or the TUI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the best solution is a mix of &lt;code&gt;has('winXX')&lt;/code&gt; for Windows and &lt;code&gt;uname&lt;/code&gt; on unix-like systems. Note that the output of &lt;code&gt;uname&lt;/code&gt; ends with a newline so it must be cleaned before use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I've been using for a while, updated for &lt;code&gt;win64&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(&quot;g:os&quot;)&#xA;    if has(&quot;win64&quot;) || has(&quot;win32&quot;) || has(&quot;win16&quot;)&#xA;        let g:os = &quot;Windows&quot;&#xA;    else&#xA;        let g:os = substitute(system('uname'), '\n', '', '')&#xA;    endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After that, you can use the &lt;code&gt;g:os&lt;/code&gt; variable anywhere in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;gui_running&quot;)&#xA;    if g:os == &quot;Darwin&quot;&#xA;        set guifont=Fira\ Mono:h12&#xA;    elseif g:os == &quot;Linux&quot;&#xA;        set guifont=Fira\ Mono\ 10&#xA;    elseif g:os == &quot;Windows&quot;&#xA;        set guifont=Fira_Mono:h12:cANSI&#xA;    endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-03-16T15:20:41.930" LastActivityDate="2015-03-16T15:20:41.930" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="2578" PostTypeId="2" ParentId="2572" CreationDate="2015-03-16T10:34:26.883" Score="5" Body="&lt;p&gt;As others have already indicated, a reliable detection can be tricky. Better not reinvent the wheel, so I'd like to mention the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4597&quot; rel=&quot;noreferrer&quot;&gt;vim-misc library&lt;/a&gt;, which provides &lt;code&gt;xolox#misc#os#is_mac()&lt;/code&gt; and &lt;code&gt;xolox#misc#os#is_win()&lt;/code&gt; functions.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-16T10:34:26.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2579" PostTypeId="2" ParentId="2553" CreationDate="2015-03-16T11:03:53.447" Score="1" Body="&lt;p&gt;Right now I am using &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1905&quot; rel=&quot;nofollow&quot;&gt;camelcasemotion&lt;/a&gt; plugin with the following mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'vim-scripts/camelcasemotion'&#xA;map w &amp;lt;Plug&amp;gt;CamelCaseMotion_w&#xA;map b &amp;lt;Plug&amp;gt;CamelCaseMotion_b&#xA;map e &amp;lt;Plug&amp;gt;CamelCaseMotion_e&#xA;sunmap w&#xA;sunmap b&#xA;sunmap e&#xA;nmap cw ce&#xA;omap iw ie&#xA;xmap iw ie&#xA;omap iw &amp;lt;Plug&amp;gt;CamelCaseMotion_iw&#xA;xmap iw &amp;lt;Plug&amp;gt;CamelCaseMotion_iw&#xA;omap ib &amp;lt;Plug&amp;gt;CamelCaseMotion_ib&#xA;xmap ib &amp;lt;Plug&amp;gt;CamelCaseMotion_ib&#xA;omap ie &amp;lt;Plug&amp;gt;CamelCaseMotion_ie&#xA;xmap ie &amp;lt;Plug&amp;gt;CamelCaseMotion_ie&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="237" LastEditorUserId="778" LastEditDate="2015-05-27T16:58:22.973" LastActivityDate="2015-05-27T16:58:22.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2580" PostTypeId="1" CreationDate="2015-03-16T13:30:25.970" Score="1" ViewCount="432" Body="&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: For those of you who do not know VHDL do not worry, I will explain the problem with an example.&lt;/p&gt;&#xA;&lt;h1&gt;Motivation&lt;/h1&gt;&#xA;&lt;p&gt;I have a VHDL file which is a big mess of buses. I have declared many &lt;code&gt;signals&lt;/code&gt; and I think I have some unused signals. I want to delete unnecessary declarations.&lt;/p&gt;&#xA;&lt;h1&gt;Example&lt;/h1&gt;&#xA;&lt;p&gt;Imagine I have the following signal declarations&lt;/p&gt;&#xA;&lt;pre&gt;&#xA;signal exmem_wb_we_in : std_logic;&#xA;signal exmem_const_in : std_logic_vector(15 downto 0);&#xA;signal exmem_data_in : std_logic_vector(15 downto 0);&#xA;signal exmem_addr_in : std_logic_vector(15 downto 0);&#xA;signal &lt;b&gt;exmem_foo_in&lt;/b&gt; : std_logic;&#xA;signal exmem_mem_en_in : std_logic;&#xA;signal &lt;b&gt;exmem_bar_in&lt;/b&gt; : std_logic_vector(15 downto 0);&#xA;signal exmem_jump_cond_in : std_logic_vector(3 downto 0);&#xA;&lt;/pre&gt;&#xA;&lt;p&gt;Say the signals in bold (&lt;code&gt;exmem_foo_in&lt;/code&gt; and &lt;code&gt;exmem_bar_in&lt;/code&gt;) are never used. Then those words occur only once in the file. I want the lines where they appear to be deleted.&lt;/p&gt;&#xA;&lt;h1&gt;The question&lt;/h1&gt;&#xA;&lt;p&gt;Is it possible to get Vim to delete all lines which hold a single occurrence of a word in a file? The solution should use Vim commands that are 'always available', rather than OS dependent commands. A single command would be preferred. But multiple commands are also welcome.&lt;/p&gt;&#xA;&lt;h3&gt;Some assumptions&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;assume only one signal is declared per line;&lt;/li&gt;&#xA;&lt;li&gt;there are no occurrences of numbers who appear only once in the file and could get us a line deleted when we in fact want that line;&lt;/li&gt;&#xA;&lt;li&gt;there are no comments which introduce a single word occurrence.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Bonus points if you can make it still work without some of those assumptions.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Clarifications&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I don't know which words I want to delete beforehand.&lt;/li&gt;&#xA;&lt;li&gt;A VHDL file might look like &lt;a href=&quot;https://i.stack.imgur.com/PxbPA.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="356" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-03-16T14:39:13.447" Title="Delete all lines which contain any word not used anywhere else in the buffer" Tags="|search|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="2581" PostTypeId="2" ParentId="2580" CreationDate="2015-03-16T13:35:53.120" Score="1" Body="&lt;p&gt;Just to delete all lines containing some specific word you can by just typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/exmem_bar_in/d&#xA;:g/exmem_foo_in/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The signature is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]g[lobal]/{pattern}/[cmd]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(can be found by :h :g)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to know the list of unique words, it actually heavily depends on what you indeed want to treat as a unique word. I doubt that you actually mean any unique word but rather something unique in the signal section. If it is so, then I'd just create a separate buffer, copied eveything there, then&#xA;remove all besides &quot;signal :&quot; prefix:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(.*\):.*/\1/ &quot;deleting all after last semicolon&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then leave only unique value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sort u.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I have a list of unique words I can work with. &lt;/p&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="1302" LastEditDate="2015-03-16T14:39:13.447" LastActivityDate="2015-03-16T14:39:13.447" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2582" PostTypeId="1" CreationDate="2015-03-16T14:45:20.017" Score="4" ViewCount="1096" Body="&lt;p&gt;How does one keep the cursor in its place after a file-replace using &lt;code&gt;:%s/find/replace/g&lt;/code&gt; ? I looked at &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/tips.html#restore-position&quot; rel=&quot;nofollow&quot;&gt;restoring cursor position&lt;/a&gt;, but not quite what I was looking for, and I could jump back to previous position using &lt;code&gt;''&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="1389" LastEditorUserId="51" LastEditDate="2015-03-16T14:53:12.533" LastActivityDate="2022-07-22T13:44:01.067" Title="Keep Cursor In Current Position After Find-Replace" Tags="|cursor-movement|substitute|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2583" PostTypeId="2" ParentId="2582" CreationDate="2015-03-16T15:04:38.493" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3800&quot; rel=&quot;nofollow&quot;&gt;anwolib plugin&lt;/a&gt; has a &lt;code&gt;:KeepView&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:KeepView %s/find/replace/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-16T15:04:38.493" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2585" PostTypeId="1" AcceptedAnswerId="2586" CreationDate="2015-03-16T19:24:08.163" Score="2" ViewCount="462" Body="&lt;p&gt;I use quite a lot &lt;code&gt;cw&lt;/code&gt; to change a word. I put the cursor on the start of the word, then &lt;code&gt;cw&lt;/code&gt; followed by the new word and then &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, so good. My problem is that after that the cursor is at the end of the (new) word. I know I can move back with &lt;code&gt;b&lt;/code&gt;, but it's possible to define a modified version of &lt;code&gt;cw&lt;/code&gt; so that the movement is automatic at the end of the insert? &lt;/p&gt;&#xA;" OwnerUserId="854" LastActivityDate="2015-03-16T20:57:11.703" Title="Move back the cursor after a &quot;cw&quot; command" Tags="|cursor-movement|replace|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2586" PostTypeId="2" ParentId="2585" CreationDate="2015-03-16T20:57:11.703" Score="4" Body="&lt;p&gt;You can use a &lt;code&gt;:help :map-expression&lt;/code&gt; that defines a fire-once autocmd on &lt;code&gt;InsertLeave&lt;/code&gt; (i.e. when you're done with the change) to move back the cursor. I've used &lt;code&gt;&amp;#96;[;&lt;/code&gt; instead of the &lt;code&gt;b&lt;/code&gt; motion, because that also handles multiple inserted words. Since I wouldn't want to override &lt;code&gt;cw&lt;/code&gt;, I've chosen &lt;code&gt;c,w&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToStartOfChange()&#xA;    augroup ToStartOfChange&#xA;        autocmd ToStartOfChange InsertLeave * execute 'normal! g`[' | autocmd! ToStartOfChange&#xA;    augroup END&#xA;    return 'cw'&#xA;endfunction&#xA;nnoremap &amp;lt;expr&amp;gt; c,w ToStartOfChange()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-16T20:57:11.703" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2587" PostTypeId="1" AcceptedAnswerId="2588" CreationDate="2015-03-16T21:31:35.633" Score="10" ViewCount="2741" Body="&lt;p&gt;I'm trying to write a function that will delete each line that matches a pattern. But that pattern will change based on the words held in a list (made from a dictionary). I was thinking it would be a simple &lt;code&gt;for&lt;/code&gt; loop but the &lt;code&gt;for&lt;/code&gt; loop variable doesn't expand inside the pattern.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for key in sort(keys(myDict))&#xA;    %g/^The key/d&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the loop looks for &lt;code&gt;^The key&lt;/code&gt; instead of &lt;code&gt;^The red&lt;/code&gt;, &lt;code&gt;^The green&lt;/code&gt;, &lt;code&gt;^The blue&lt;/code&gt;, etc. It doesn't expand the &lt;code&gt;key&lt;/code&gt; variable to whatever it's holding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I use a variable inside a regex pattern and have the variable expand? Or is there a better way entirely of achieving my goal?&lt;/p&gt;&#xA;" OwnerUserId="1154" LastActivityDate="2016-03-13T03:36:46.267" Title="Using a variable in a regex pattern" Tags="|vimscript|regular-expression|" AnswerCount="1" CommentCount="0" ClosedDate="2016-03-13T03:36:57.533" ContentLicense="CC BY-SA 3.0" />
  <row Id="2588" PostTypeId="2" ParentId="2587" CreationDate="2015-03-16T21:37:42.873" Score="11" Body="&lt;p&gt;You need to &quot;build&quot; your global command using &lt;code&gt;:execute&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for key in sort(keys(myDict))&#xA;    execute '%g/^The ' . key . '/d'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h :exe&lt;/code&gt; for more help using &lt;code&gt;:execute&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some thoughts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You may need to escaping your keys&lt;/li&gt;&#xA;&lt;li&gt;Might consider alternation. e.g. &lt;code&gt;\(red\|blue\|green\)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;You may want to &lt;code&gt;:delete&lt;/code&gt; into the black hole register to prevent any surprises. e.g. &lt;code&gt;:d_&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-03-16T21:37:42.873" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2589" PostTypeId="2" ParentId="2552" CreationDate="2015-03-16T23:53:07.877" Score="3" Body="&lt;p&gt;See &lt;code&gt;:h :command-completion-custom&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can adapt the last example to complete only files listed by git.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -bang -complete=customlist,GitFindComplete&#xA;      \ GitFind edit&amp;lt;bang&amp;gt; &amp;lt;args&amp;gt;&#xA;&#xA;function! GitFindComplete(ArgLead, CmdLine, CursorPos)&#xA;  let search_pattern = &quot;*&quot; . a:ArgLead . &quot;*&quot;&#xA;  let shell_cmd = &quot;git ls-files &quot; . shellescape(search_pattern)&#xA;  return split(system(shell_cmd), &quot;\n&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use auto-completion to open the files listed by git:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:GitFind ome_f&amp;lt;Tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that in a custom completion function, we must do more than simply list the files which could be completed.  We must also &lt;strong&gt;filter&lt;/strong&gt; the list relative to the current commandline argument &lt;code&gt;ArgLead&lt;/code&gt;.  In this example, we ask &lt;code&gt;git&lt;/code&gt; to do the filtering for us, by passing it the argument wrapped in &lt;code&gt;*&lt;/code&gt; wildcards.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-03-16T23:53:07.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2590" PostTypeId="1" CreationDate="2015-03-17T00:44:06.850" Score="3" ViewCount="1014" Body="&lt;p&gt;I use the following wildmenu settings: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmenu&#xA;set wildmode=list:full&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which results in this after typing &lt;code&gt;:find *foo&amp;lt;tab&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/y6yUG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to highlight the options in the wildmode list as opposed to (or in addition to) the highlighted options in the wildmenu?&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastEditorUserId="51" LastEditDate="2015-03-18T15:12:33.853" LastActivityDate="2015-03-26T20:32:58.873" Title="Highlight or underline the current selection in the wildmode list" Tags="|wildmenu|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2591" PostTypeId="1" AcceptedAnswerId="2592" CreationDate="2015-03-17T01:00:24.480" Score="2" ViewCount="124" Body="&lt;p&gt;I'm reading through a very large web service log, and I want to pull a single line out from the file, and write it to a new file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The log lines consist of web service request XML, so they are long and unwieldy.&lt;/p&gt;&#xA;" OwnerUserId="398" LastEditorUserId="398" LastEditDate="2015-03-17T01:57:16.443" LastActivityDate="2015-03-17T02:28:39.330" Title="How to copy the current line(s) out to a new file?" Tags="|cut-copy-paste|file-operations|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2592" PostTypeId="2" ParentId="2591" CreationDate="2015-03-17T01:15:15.627" Score="5" Body="&lt;p&gt;&lt;code&gt;w&lt;/code&gt; can operate on ranges, so you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.w foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Awrite&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help :w&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]w[rite]! [++opt] {file}&#xA;                    Write the specified lines to {file}.  Overwrite an&#xA;                    existing file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any range would do, so the following will write lines N-M inclusive to file &lt;code&gt;foo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:N,Mw foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;.&lt;/code&gt; in the first command stands for the current line. See &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3Arange&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help :range&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-03-17T02:28:39.330" LastActivityDate="2015-03-17T02:28:39.330" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2593" PostTypeId="2" ParentId="2590" CreationDate="2015-03-17T02:28:24.767" Score="1" Body="&lt;p&gt;The &lt;code&gt;WildMenu&lt;/code&gt; highlight group is the highlighting for the current wildmenu match.&#xA;This would put an underline under your current match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight WildMenu cterm=underline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A screenshot of it in action:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/TnM1b.png&quot; alt=&quot;wildmenu underline&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-03-17T02:28:24.767" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2594" PostTypeId="1" CreationDate="2015-03-17T06:00:30.263" Score="5" ViewCount="2284" Body="&lt;p&gt;I use &lt;a href=&quot;https://github.com/bling/vim-airline&quot; rel=&quot;nofollow&quot;&gt;airline&lt;/a&gt; to manage my status-line and tab-line. This worked great until I started to code for an MVC project that has way too many modules and files going on. I now have tabs coming out my ears. More to the point: they don't fit in my tab line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to configure airline to run over into multiple lines? Alternatively is there an alternate way to take a gander at what tabs I have open?&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="205" LastEditDate="2015-04-13T15:12:32.453" LastActivityDate="2020-09-01T05:16:36.900" Title="What can I do with more tabs than fit in one (airline) tab-line?" Tags="|tabbed-user-interface|plugin-airline|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2595" PostTypeId="2" ParentId="2594" CreationDate="2015-03-17T08:31:04.763" Score="15" Body="&lt;p&gt;This is an inherent issue with the tab metaphor and every solution introduces more problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;multiple lines are harder to parse and take up too much space,&lt;/li&gt;&#xA;&lt;li&gt;tab groups make it impossible to see what's in them at a glance and thus defeat the whole purpose of having a tab-line,&lt;/li&gt;&#xA;&lt;li&gt;arrows to scroll the tab-line are also very impractical and contrary to the purpose of the tab-line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You should learn how to use buffers without relying on a mostly useless and wasteful visible list (that &quot;requires&quot; a mostly useless and wasteful plugin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put these in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmenu&#xA;nnoremap gb :ls&amp;lt;CR&amp;gt;:b&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and enjoy the ride.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;code&gt;:b &amp;lt;Tab&amp;gt;&lt;/code&gt;.    &lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-03-17T08:31:04.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2596" PostTypeId="1" CreationDate="2015-03-17T10:04:34.327" Score="6" ViewCount="184" Body="&lt;p&gt;I'm using Vim for some months now, but originally was using &lt;a href=&quot;http://www.sublimetext.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sublime Text&lt;/a&gt;. While I missed many of Sublime's features first, I have now found Vim-based replacements for most of them. There is only one thing I haven't found a solution for: The command palette. Sublime Text enables plugin developers to define commands and keybindings for it, just like Vim does. But instead of only triggering these commands by its (internal) name or bound key mapping, there is also a &quot;pretty name&quot;, that may e.g. contain spaces and special characters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This comes comes in very handy when there is a command you need regularly, but not as regular, as creating a keybinding for it would justify (for me this is e.g. base64 conversion and renaming HTML tags). Using a special key binding, a menu opens that enables a fuzzy search for commands. The search is context-sensitive, so that e.g. commands only applicable to HTML files are only shown, when such a document is currently opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know of any plugin (or internal mechanism) that provides a similar functionality for Vim, and displays a list of context-sensitive commands and allow a fuzzy search for them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ekpo9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1317" LastEditorUserId="51" LastEditDate="2015-04-27T19:16:24.480" LastActivityDate="2015-04-27T19:16:24.480" Title="Searchable list of custom commands for Vim?" Tags="|command-line|" AnswerCount="0" CommentCount="3" ClosedDate="2015-03-19T21:24:05.690" ContentLicense="CC BY-SA 3.0" />
  <row Id="2597" PostTypeId="2" ParentId="2594" CreationDate="2015-03-17T11:12:10.997" Score="2" Body="&lt;p&gt;Instead of relying on a visible list, you should try something like &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;nofollow&quot; title=&quot;ctrl-p&quot;&gt;ctrl-p&lt;/a&gt;. With this plugin you can navigate to a file by pressing &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; and adding some letters of the file name you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the following is added to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_cmd = 'CtrlPBuffer'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it will search only in the open buffer list, which makes it more appropriate and fast if the file you're looking for is already opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There many more options that you can use to customize this plugin in the most efficient way for your personal work flow.&lt;/p&gt;&#xA;" OwnerUserId="599" LastActivityDate="2015-03-17T11:12:10.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2598" PostTypeId="1" AcceptedAnswerId="2599" CreationDate="2015-03-17T11:55:06.833" Score="12" ViewCount="1248" Body="&lt;p&gt;I recently &lt;a href=&quot;https://vi.stackexchange.com/q/2547/267&quot;&gt;asked a question&lt;/a&gt; in which I learned that it is not possible to pass anything except parameters to &lt;code&gt;:set&lt;/code&gt; in vim modelines. I understand the security concerns, but I'm wondering if there isn't another way around this. A &lt;a href=&quot;https://stackoverflow.com/q/29097673/313192&quot;&gt;recent question on SO&lt;/a&gt; about setting large batches of parameters to comply with a coding standard got me to thinking—would it be possible to define a &quot;group&quot; of things in my rc file that can be turned on or off from the modeline?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Excuse the pseudo code, but is there a way to create a function that is triggered from a set parameter?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set_function! codestyle()&#xA;    if &amp;amp;1 == 'psr-2'&#xA;        set ts=4&#xA;        set sw=4&#xA;    endfi&#xA;    if &amp;amp;1 == 'drupal7'&#xA;        set ts=2&#xA;        set sw=2&#xA;        iab D8 Drupal 8&#xA;    endif&#xA;endset_function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This could then be triggered by a modeline such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: codestyle=psr-2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would be in some ways be similar to file type matching, but allow manual overrides. It would also setting up the environment in other pre-defined ways, avoiding the security issues of having a file run other arbitrary commands in vim but allowing a more customized environment. Is there a way to do this?&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-03-17T14:43:38.027" Title="Is it possible to create custom &quot;set&quot; commands in my rc file and call them from a modeline?" Tags="|vimrc|vimscript|modeline|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2599" PostTypeId="2" ParentId="2598" CreationDate="2015-03-17T12:48:45.580" Score="11" Body="&lt;p&gt;You have a few choices.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;First one: You can write your own kind of modeline decoder, i.e. a plugin. This is a very similar answer to the one I gave to your other question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, we cannot add new vim options (that can be set with &lt;code&gt;:set&lt;/code&gt;), but we can add new variables. And we cannot use the standard modelines to do more than setting vim options. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Second possibility: &lt;a href=&quot;https://raw.githubusercontent.com/LucHermitte/lh-misc/master/plugin/let-modeline.vim&quot;&gt;let-modeline&lt;/a&gt; could be exploited through the &lt;em&gt;callback&lt;/em&gt; feature to call one function or another. You could have your &lt;code&gt;CodeStyle()&lt;/code&gt; function in your &lt;code&gt;.vimrc&lt;/code&gt; or a (autoload?) plugin, then have your files contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# VIM: let b:codestyle='psr-2' b:ModeLine_CallBack='CodeStyle'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if your need is this precise and if you really don't want plugins like &lt;a href=&quot;https://github.com/LucHermitte/local_vimrc&quot;&gt;local_vimrc&lt;/a&gt;, then write your own modeline-like decoder.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The third, and IMO, better choice in that case would be to define a new filetype and set &lt;code&gt;'ft'&lt;/code&gt; to this filetype in modelines with: &lt;code&gt;# vim: set ft=php.psr2&lt;/code&gt;. With &lt;code&gt;php&lt;/code&gt; being the global usual filetype (I'm not sure about this one), and &lt;code&gt;psr2&lt;/code&gt; being the specialized filetype that'll correspond to your coding styles. You'll have to define two ftplugins: ftplugin/psr2.vim and and ftplugin/drupal7.vim where you'll put your calls to &lt;code&gt;:setlocal&lt;/code&gt; (and not &lt;code&gt;:set&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2015-03-17T14:43:38.027" LastActivityDate="2015-03-17T14:43:38.027" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2600" PostTypeId="1" CreationDate="2015-03-17T15:02:12.653" Score="4" ViewCount="635" Body="&lt;p&gt;I am going to be pasting a lot of characters into a file. Each time I paste something, the pasted element will need to be wrapped in quotes and followed by a comma. Is there a way to automatically wrap these characters after each paste in vim? The paste will be coming from the system clipboard, not a vim paste buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, say the system clipboard contains &lt;code&gt;a&lt;/code&gt;, when pasting this into vim using a middle-click, I would like it to insert &lt;code&gt;&quot;a&quot;,&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="51" LastEditDate="2015-03-17T18:48:10.310" LastActivityDate="2015-03-18T07:50:50.327" Title="Is it possible to wrap characters around text every time you paste something from the system clipboard?" Tags="|insert-mode|os-clipboard|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2601" PostTypeId="1" AcceptedAnswerId="2604" CreationDate="2015-03-17T15:05:45.680" Score="4" ViewCount="79" Body="&lt;p&gt;as we know that we can use Vim to browse a directory. My question is what does &lt;kbd&gt;number + Enter&lt;/kbd&gt; do on a file list?&lt;br&gt;&#xA;I thought it equivalent to &lt;kbd&gt;number + j + Enter&lt;/kbd&gt;, however, after I enter into a file, using &lt;code&gt;:b#&lt;/code&gt; leads me to another &quot;unpredictable&quot; location. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eg, suppose we have &lt;code&gt;/A/B/f1 /A/B/f2 /A/B/f3 /A/C/f4 /A/C/f5&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I enter into folder A from Vim and the cursor is on &lt;code&gt;../&lt;/code&gt;, what will happen if I type &lt;kbd&gt;2 + Enter&lt;/kbd&gt; or &lt;kbd&gt;3 + Enter&lt;/kbd&gt;? When a file is open, what will happen when I type &lt;code&gt;:b#&lt;/code&gt; in this case?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="51" LastEditDate="2015-03-17T15:36:00.307" LastActivityDate="2015-03-17T17:35:51.200" Title="What does number+enter do in Explore?" Tags="|filesystem|netrw|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2602" PostTypeId="2" ParentId="2600" CreationDate="2015-03-17T15:38:12.523" Score="7" Body="&lt;p&gt;Do you need to use the mouse (middle-klick)? I'd go for a macro:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; to start recording&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;*&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;`&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; to first insert the first set of quote, then paste from the system clipboard, go to the end of the paste and append quote and comma&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;q&lt;/kbd&gt; to stop recording&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then, each time you want to paste that way, simply hit &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: If you're on X, you might need to use &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt; instead of &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;*&lt;/kbd&gt;, dpending on which clipboard you really want to use. See &lt;code&gt;:h x11-selection&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note2: This pastes before your cursor. Change the first &lt;kbd&gt;i&lt;/kbd&gt; to &lt;kbd&gt;a&lt;/kbd&gt; to paste after your cursor.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="1296" LastEditDate="2015-03-18T07:50:50.327" LastActivityDate="2015-03-18T07:50:50.327" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2603" PostTypeId="2" ParentId="2600" CreationDate="2015-03-17T17:05:11.883" Score="4" Body="&lt;p&gt;Assuming your vim includes clipboard support (&lt;code&gt;:version&lt;/code&gt; shows &lt;code&gt;+clipboard&lt;/code&gt;) and you intend to do this in more than one editing session, I would recommend creating a mapping that does this for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt; i&quot;&quot;,&amp;lt;Esc&amp;gt;h&quot;+P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;F5&amp;gt;&lt;/code&gt;: what you'll hit to trigger the mapping. Could be any combination of keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;i&quot;&quot;,&amp;lt;Esc&amp;gt;&lt;/code&gt;: &lt;code&gt;&quot;&quot;,&lt;/code&gt; and escape insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;h&lt;/code&gt;: move the cursor left 1 character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;+P&lt;/code&gt;: paste from the system clipboard before the current character. If pasting via middle-click, you'd want &quot;*P instead&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is currently formulated to work when in normal mode, but could work in insert mode by removing the leading &lt;code&gt;i&lt;/code&gt; (and perhaps adding one at the end)&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-03-17T17:05:11.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2604" PostTypeId="2" ParentId="2601" CreationDate="2015-03-17T17:35:51.200" Score="4" Body="&lt;p&gt;The &lt;kbd&gt;Enter&lt;/kbd&gt; binding of netrw is documented in the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#netrw-cr&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;netrw-cr&lt;/code&gt;&lt;/a&gt; help section. It mentions nothing about any use of the count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect the count is simply &quot;falling through&quot; to an internal function of netrw that is not prepared to handle it. Most of my own attempts resulted in the error message &lt;code&gt;Invalid range: call s:UseBufWinVars()&lt;/code&gt;, and those that didn't did not form any recognizable pattern, though I did notice ending up in directories that were multiple steps away from the one that I had been browsing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calling it with a very large count like 100 results in many instances of the same error message, suggesting something is being executed a number of times corresponding to the count.&lt;/p&gt;&#xA;" OwnerUserId="880" LastActivityDate="2015-03-17T17:35:51.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2605" PostTypeId="2" ParentId="2600" CreationDate="2015-03-17T19:13:51.760" Score="4" Body="&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3355&quot; rel=&quot;nofollow&quot;&gt;UnconditionalPaste plugin&lt;/a&gt; provides a &lt;code&gt;g,&quot;p&lt;/code&gt; mapping that pastes each line in the register (prepend &lt;code&gt;&quot;+&lt;/code&gt; for the system clipboard, as usual) surrounded by double quotes and delimited by commas, all in one line. This is just one particular variant from a plethora of similar mappings; some even query for the separator.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-17T19:13:51.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2606" PostTypeId="1" AcceptedAnswerId="2612" CreationDate="2015-03-17T23:52:22.690" Score="3" ViewCount="210" Body="&lt;p&gt;I currently have a single file that has nearly 10000 lines of text in it. Each section that I want is broken up like so -&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Chapter 1: Chapter 1&#xA;TEXT GOES HERE&#xA;Chapter 2: Chapter 2&#xA;TEXT GOES HERE&#xA;Chapter 3: Chapter 3&#xA;TEXT GOES HERE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to break up each chapter so that I save a file like 01.tex, 02.tex, and 03.tex that contains all of that text for that chapter. Is there a way to regex through the file and make a save for each chapter?&lt;/p&gt;&#xA;" OwnerUserId="1417" LastActivityDate="2015-03-18T13:14:41.473" Title="How do I cut a single large file into manageable chunks by regex?" Tags="|regular-expression|save|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2607" PostTypeId="1" AcceptedAnswerId="2608" CreationDate="2015-03-18T00:45:22.397" Score="19" ViewCount="7871" Body="&lt;p&gt;I want to edit several files matching a glob expression. For example, to edit all git config files in child directories, I can do this in the shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim */.git/config&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the Vim &lt;code&gt;:&lt;/code&gt; command line, I expected &lt;code&gt;:find */.git/config&lt;/code&gt; to do something similar (i.e., open all files matching the glob expression), but instead it complains &lt;code&gt;E77: Too many file names&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there Vim command or one-liner to open multiple files matching a wildcard/glob expression (that doesn't involve writing a function)?&lt;/p&gt;&#xA;" OwnerUserId="578" LastEditorUserId="467" LastEditDate="2015-03-18T12:15:13.930" LastActivityDate="2022-09-23T22:59:25.503" Title="How to open multiple files matching a wildcard expression?" Tags="|multiple-files|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2608" PostTypeId="2" ParentId="2607" CreationDate="2015-03-18T02:43:24.330" Score="16" Body="&lt;p&gt;You can use &lt;code&gt;:args {glob}&lt;/code&gt;. In your glob, &lt;code&gt;**&lt;/code&gt; will traverse directories recursively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will populate the argument list, which is the same list that gets populated when you start Vim with one or more filenames as arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once your argument list is populated, you can navigate through it using &lt;code&gt;:next&lt;/code&gt; and &lt;code&gt;:previous&lt;/code&gt;. You can also jump to the first and last item with the &lt;code&gt;:first&lt;/code&gt; and &lt;code&gt;:last&lt;/code&gt; commands.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-03-18T02:43:24.330" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2609" PostTypeId="1" CreationDate="2015-03-18T06:03:50.037" Score="1" ViewCount="42" Body="&lt;p&gt;I use the following mapping to initiate keyword completion, followed by user defined completion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-n&amp;gt; pumvisible() ? &quot;\&amp;lt;c-x&amp;gt;\&amp;lt;c-o&amp;gt;&quot; : &quot;\&amp;lt;c-n&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I rewrite this mapping so that repeatedly pressing &lt;code&gt;&amp;lt;c-n&amp;gt;&lt;/code&gt; results in the cycling of keyword and user defined completion?&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastEditorUserId="51" LastEditDate="2015-03-18T15:11:34.003" LastActivityDate="2015-03-18T15:11:34.003" Title="Cycle between keyword &amp; user defined completion with C-N" Tags="|key-bindings|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2610" PostTypeId="2" ParentId="2609" CreationDate="2015-03-18T08:14:13.540" Score="2" Body="&lt;p&gt;I'm not sure when exactly you would initiate the cycling (as you typically use &lt;code&gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; to both trigger and go through the list of matches), but the key to implementing this is via a boolean flag stored in a variable. To be able to use &lt;code&gt;:let&lt;/code&gt; to toggle this, you need to move from an inline expression to a function (which still returns the chosen completion key).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-n&amp;gt; TriggerOrToggleCompletion()&#xA;function! TriggerOrToggleCompletion()&#xA;    ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-18T08:14:13.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2611" PostTypeId="2" ParentId="2607" CreationDate="2015-03-18T08:22:51.013" Score="4" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;At the Vim &lt;code&gt;:&lt;/code&gt; command line, I expected &lt;code&gt;:find */.git/config&lt;/code&gt; to do something similar (i.e., open all files matching the glob expression), but instead it complains &lt;code&gt;E77: Too many file names&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Don't expect anything before reading the documentation.&lt;/p&gt;&#xA;&lt;p&gt;In addition to Tom's answer, you can directly use &lt;code&gt;:next&lt;/code&gt; as an alternative to &lt;code&gt;:args&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2022-09-23T22:59:25.503" LastActivityDate="2022-09-23T22:59:25.503" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2612" PostTypeId="2" ParentId="2606" CreationDate="2015-03-18T08:27:45.520" Score="5" Body="&lt;p&gt;That's a job for &lt;code&gt;:global&lt;/code&gt;, with which you can split the file into ranges, here from a line starting with &lt;code&gt;Chapter&lt;/code&gt; to the one before the next such line. To correctly handle the last range, insert a dummy line containing &lt;code&gt;EOF&lt;/code&gt; at the end first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To build the filespec, I would usually use &lt;code&gt;:execute&lt;/code&gt;, but that doesn't handle ranges. So, I use the more obscure &lt;em&gt;backtick expression&lt;/em&gt; (&lt;code&gt;:help `=&lt;/code&gt;). Instead of a variable counter, I just grab the first number from the current (first of the range) line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/^Chapter/,/^Chapter\|^EOF/-1write `='path/to/dir' . matchstr(getline('.'), '\d\+') . '.tex'`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This basically searches for all lines starting with &lt;code&gt;Chapter&lt;/code&gt;, and then &lt;code&gt;:write&lt;/code&gt; the following range: &lt;code&gt;.,/^Chapter\|^EOF/-1&lt;/code&gt; (the &lt;code&gt;.&lt;/code&gt; is implicit by the positioning of &lt;code&gt;:global&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2015-03-18T13:14:41.473" LastActivityDate="2015-03-18T13:14:41.473" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2614" PostTypeId="1" AcceptedAnswerId="2620" CreationDate="2015-03-18T11:57:27.920" Score="18" ViewCount="2179" Body="&lt;p&gt;I'm experiencing a weird problem with a normal mode mapping of &lt;kbd&gt;Esc&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you create the file &lt;code&gt;escmapvimrc&lt;/code&gt; with the contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set showcmd &quot; Doesn't affect the problem: just makes it easier to see&#xA;nnoremap &amp;lt;Esc&amp;gt; :noh&amp;lt;CR&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then start vim using this vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --noplugin -u escmapvimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then vim will start in operator-pending mode with a &lt;code&gt;c&lt;/code&gt; command waiting for further input, displaying an empty file, and with the command-line displaying &lt;code&gt;:noh&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you remove the &lt;code&gt;nnoremap&lt;/code&gt; line, then the problem goes away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you debug and step through everything you get the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Entering Debug mode.  Type &quot;cont&quot; to continue.&#xA;/[...]/escmapvimrc&#xA;line 1: set nocompatible&#xA;&amp;gt;s&#xA;/[...]/escmapvimrc&#xA;line 2: set showcmd &quot; Doesn't affect the problem: just makes it easier to see&#xA;&amp;gt;s&#xA;/[...]/escmapvimrc&#xA;line 3: nnoremap &amp;lt;Esc&amp;gt; :noh&amp;lt;CR&amp;gt;&amp;lt;esc&amp;gt;&#xA;&amp;gt;s&#xA;/[...]/escmapvimrc&#xA;line 4: End of sourced file&#xA;&amp;gt;s&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After you press enter, the Vim startup screen is displayed, and underneath:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Entering Debug mode.  Type &quot;cont&quot; to continue.&#xA;cmd: noh&#xA;&amp;gt;s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Vim startup screen then disappears, and you're in operator-pending mode, as described above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's going on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Behaviour is as described in Vim 7.3. In Vim 7.4.52, the &lt;code&gt;nmap&lt;/code&gt; causes Vim to start up in Replace mode when starting Vim without a file. (If Vim 7.4.52 is started &lt;em&gt;with&lt;/em&gt; a file, however, it also starts up with a c-command underway.) Either way, the problem goes away when the nmap is removed.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-11-21T10:53:47.560" LastActivityDate="2021-10-08T09:10:42.637" Title="Why does this &lt;Esc&gt; normal mode mapping affect startup?" Tags="|vimrc|key-bindings|startup|escape|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2615" PostTypeId="2" ParentId="2614" CreationDate="2015-03-18T13:25:12.993" Score="15" Body="&lt;p&gt;The Linux terminal uses ANSI escape sequences (i.e. strings of characters starting with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;) to send special keys to Vim, and as part of the communication protocol with which the application queries for its capabilities. Your mapping interferes with that, and thereby leads to these &quot;strange&quot; behaviors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, &lt;strong&gt;don't map &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;&lt;/strong&gt;. Use another key. The problem is less pronounced in GVIM, but I wouldn't recommend it there, neither.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-18T13:25:12.993" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2616" PostTypeId="1" AcceptedAnswerId="2617" CreationDate="2015-03-17T11:14:42.700" Score="3" ViewCount="869" Body="&lt;p&gt;In &lt;a href=&quot;http://vim.org/&quot; rel=&quot;nofollow&quot;&gt;vim&lt;/a&gt; you can include &lt;code&gt;modelines&lt;/code&gt; in comments at the start/end of a file, like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// vim:sw=4 ts=4 et&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I regularly work with PHP and try to stick to &lt;a href=&quot;https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md&quot; rel=&quot;nofollow&quot;&gt;PSR-2&lt;/a&gt; but Drupal (of course *rolls eyes*) has to be different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to be able to include something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// vim:codestyle=psr-2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// vim:codestyle=drupal7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and have this trigger various setup options in my &lt;code&gt;.vimrc&lt;/code&gt; that define that code style, for example &lt;code&gt;ts=2 sw=2 et&lt;/code&gt; for &lt;code&gt;drupal7&lt;/code&gt; and &lt;code&gt;ts=4 sw=4 et&lt;/code&gt; for &lt;code&gt;psr-2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? (well I suppose I'm hoping it is, so what I really mean is How can I do this?)&lt;/p&gt;&#xA;" OwnerUserId="1406" OwnerDisplayName="artfulrobot" LastEditorUserId="51" LastEditDate="2015-03-18T15:06:18.707" LastActivityDate="2015-03-18T19:03:57.047" Title="Is it possible to include coding style vim modelines e.g. psr-2 or drupal?" Tags="|vimrc|modeline|" AnswerCount="2" CommentCount="4" ClosedDate="2015-03-19T11:21:00.810" ContentLicense="CC BY-SA 3.0" />
  <row Id="2617" PostTypeId="2" ParentId="2616" CreationDate="2015-03-17T12:01:58.123" Score="3" Body="&lt;p&gt;Per the answers to &lt;a href=&quot;https://vi.stackexchange.com/q/2547/267&quot;&gt;a question&lt;/a&gt; I recently asked on the &lt;a href=&quot;http://vi.stackexchange.com&quot;&gt;Vi and Vim Stack Exchange&lt;/a&gt;, the vim modeline can only be used to trigger a predefined subset of parameters to the &lt;code&gt;:set&lt;/code&gt; command already built into vim. It sounds like you could hack something up using &lt;code&gt;.exrc&lt;/code&gt;, but a more promising direction that is probably better for your use case is setting up per-project rc files using a plugin such as &lt;a href=&quot;https://github.com/LucHermitte/local_vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;local_vimrc&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="267" OwnerDisplayName="Caleb" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-03-17T12:01:58.123" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2618" PostTypeId="1" AcceptedAnswerId="2621" CreationDate="2015-03-18T15:06:24.910" Score="3" ViewCount="171" Body="&lt;p&gt;Is there a way to mix user defined completion and keyword completion in one menu triggered by &lt;code&gt;&amp;lt;c-n&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keyword completion is probably the most useful method, but syntax completion triggered by &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; after:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;setlocal omnifunc=syntaxcomplete#Complete&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;really adds efficiency as well. There must be a way to send them both to the same popup menu using &lt;code&gt;complete_add()&lt;/code&gt; or something similar - I'm just not exactly sure how to do it.&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastEditorUserId="51" LastEditDate="2015-03-18T15:25:17.747" LastActivityDate="2015-03-18T19:01:00.310" Title="One pop up menu with keyword and user defined completion" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2619" PostTypeId="2" ParentId="2542" CreationDate="2015-03-18T15:30:05.490" Score="2" Body="&lt;p&gt;With like 5min work  reading &lt;code&gt;:help airline&lt;/code&gt; I now realize airline is super customizable. I added the following to my .vimrc which replaces the line number percentage 33%   44:  2 (which I never use) with the current filename:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_section_z = '%t'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1336" LastEditorUserId="51" LastEditDate="2015-03-18T15:38:55.320" LastActivityDate="2015-03-18T15:38:55.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2620" PostTypeId="2" ParentId="2614" CreationDate="2015-03-18T18:56:52.600" Score="18" Body="&lt;p&gt;Vim sends during startup some special terminal codes (that usually contain the &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; key) to determine several things (colors, bs,...) If you mapped &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; this will most likely confuse the parser of the return codes and weird things can happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, use your above map only after everything has been setup correctly (e.g. via a VimEnter autocommand).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-03-18T18:56:52.600" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2621" PostTypeId="2" ParentId="2618" CreationDate="2015-03-18T19:01:00.310" Score="5" Body="&lt;p&gt;Not directly; the built-in completions feed directly into the popup menu; there's no extension point there. You have to re-implement the built-in completion, and then can add the results from another completion function, e.g. &lt;code&gt;'omnifunc'&lt;/code&gt;. My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3914&quot; rel=&quot;noreferrer&quot;&gt;CompleteHelper plugin&lt;/a&gt; makes this quite simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BuiltInComplete( findstart, base )&#xA;    if a:findstart&#xA;        &quot; Locate the start of the keyword.&#xA;        let l:startCol = searchpos('\k*\%#', 'bn', line('.'))[1]&#xA;        if l:startCol == 0&#xA;            let l:startCol = col('.')&#xA;        endif&#xA;        return l:startCol - 1 &quot; Return byte index, not column.&#xA;    else&#xA;        &quot; Find matches starting with a:base.&#xA;        let l:matches = []&#xA;        call CompleteHelper#FindMatches( l:matches, '\V\&amp;lt;' . escape(a:base, '\') . '\k\+', {'complete': &amp;amp;complete})&#xA;&#xA;        &quot; Now add the matches from omni completion.&#xA;        let l:matches += call(&amp;amp;omnifunc, [0, a:base])&#xA;&#xA;        return l:matches&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;General critique&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;As you can see by the list of completions implemented with the help of my plugin, I favor the opposite: many distinct completions, each triggered by separate keys. At least for me, the overhead of choosing from a long list of completion candidates is much more than the little cognitive processing in choosing the right completion.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-18T19:01:00.310" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2622" PostTypeId="2" ParentId="2616" CreationDate="2015-03-18T19:03:57.047" Score="1" Body="&lt;p&gt;I tend to support file type specific configs using filetype plugins. Then using &lt;code&gt;ft=myType&lt;/code&gt; in my modeline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// vim:set sw=2 ts=2 et ft=php fdm=marker:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it all woks right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use autocommands to find file type and executs scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you can use a local &lt;code&gt;./.vimrc&lt;/code&gt; if &lt;code&gt;:set exrc&lt;/code&gt; is on.&lt;/p&gt;&#xA;" OwnerUserId="544" LastActivityDate="2015-03-18T19:03:57.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2623" PostTypeId="1" AcceptedAnswerId="2624" CreationDate="2015-03-18T19:11:08.993" Score="2" ViewCount="785" Body="&lt;p&gt;From my .vimrc: &lt;code&gt;match ErrorMsg '\%&amp;gt;80v.\+'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And a screenshot: &lt;img src=&quot;https://i.stack.imgur.com/LADSi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried a minimal vimrc and it still doesn't work in the left splits.&lt;/p&gt;&#xA;" OwnerUserId="581" LastEditorUserId="51" LastEditDate="2015-03-18T19:15:50.937" LastActivityDate="2015-10-08T21:31:59.870" Title="I have a something in my vimrc to match text over 80 characters as an error. It only works in the right most split. Any ideas?" Tags="|vimrc|syntax-highlighting|split|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2624" PostTypeId="2" ParentId="2623" CreationDate="2015-03-18T19:22:20.980" Score="4" Body="&lt;p&gt;From &lt;code&gt;:help :match&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Define a pattern to highlight in the &lt;strong&gt;current&lt;/strong&gt; window&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is fixed by making the original command into an autocommand:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd WinEnter * match ErrorMsg '\%&amp;gt;80v.\+'&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="581" LastEditorUserId="581" LastEditDate="2015-10-08T21:31:59.870" LastActivityDate="2015-10-08T21:31:59.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2625" PostTypeId="2" ParentId="2623" CreationDate="2015-03-18T19:30:44.720" Score="5" Body="&lt;p&gt;Recent Vim versions have the &lt;code&gt;'colorcolumn'&lt;/code&gt; option. It provides the following&#xA;benefits:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can just globally &lt;code&gt;:set&lt;/code&gt; it; no &lt;code&gt;:autocmd&lt;/code&gt; is needed.&lt;/li&gt;&#xA;&lt;li&gt;You get to keep the &lt;code&gt;:match&lt;/code&gt; highlighting for something else.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-18T19:30:44.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2626" PostTypeId="1" AcceptedAnswerId="3141" CreationDate="2015-03-19T03:58:43.867" Score="5" ViewCount="2070" Body="&lt;p&gt;Our company has recently changed to networked home directories. This includes setting enviroment variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has created the odd situation that gvim thinks my home directory is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo $HOME&#xA;H:\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I cannot change the current directory to that drive or edit any files there. This also means that my &lt;code&gt;vimrc&lt;/code&gt; is not loaded. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cd H:\&#xA;E344: Can't find directory &quot;H:\&quot; in cdpath&#xA;E472: Command failed &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Can any one help me get vim to change to H:\ and edit files there?&lt;/strong&gt;&lt;br&gt;&#xA;I use Windows 7, gvim 7.4 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;I tried later CREAM versions 7.4.638 (the latest) and 7.4.099 (closest to 7.4.096 suggested by Christian Brabandt), both had the same error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for suggestions, but none have helped so far. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can change to &lt;code&gt;h:\&lt;/code&gt; in the vim.exe file which comes with Git on windows (vim 7.3, 32 bit windows console version, but not any of the gvim versions I have tried.&lt;/p&gt;&#xA;" OwnerUserId="1438" LastEditorUserId="1438" LastEditDate="2015-03-30T11:36:40.903" LastActivityDate="2015-05-01T06:15:08.933" Title="Can't change directory to network drive" Tags="|error|microsoft-windows|working-directory|" AnswerCount="3" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2627" PostTypeId="1" AcceptedAnswerId="2628" CreationDate="2015-03-19T07:04:34.687" Score="2" ViewCount="150" Body="&lt;p&gt;When gvim is opened it saves the cursor position whether it is minimized or not. So I'm curious whether it is possible to add a string starting from the cursor blinking position by running a shell script or through a terminal.&lt;/p&gt;&#xA;" OwnerUserId="1107" LastEditorUserId="24" LastEditDate="2015-03-19T10:31:23.083" LastActivityDate="2015-03-19T10:49:50.050" Title="How to add a string to cursor point of gvim through a shell script" Tags="|cursor-movement|terminal|invocation|gvim|persistent-state|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2628" PostTypeId="2" ParentId="2627" CreationDate="2015-03-19T08:18:17.720" Score="2" Body="&lt;p&gt;Take note of the server name of your GVim window by looking at its title, it should have something like &lt;code&gt;VIM&lt;/code&gt; or &lt;code&gt;VIM1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then use this command to insert &lt;code&gt;foo&lt;/code&gt; at the current cursor position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --servername VIM --remote-send &quot;ifoo&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information, see &lt;code&gt;:help clientserver&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-03-19T08:18:17.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2629" PostTypeId="2" ParentId="2627" CreationDate="2015-03-19T10:49:50.050" Score="0" Body="&lt;p&gt;&lt;code&gt;vim -c &lt;i&gt;command&lt;/i&gt;&lt;/code&gt; lets you specify a command to be executed on the first loaded file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When last exiting, Vim saved the location of the cursor as the mark named &lt;code&gt;&quot;&lt;/code&gt;.  The normal-mode command to go to that mark would be &lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;.  The ex-command version of that would be &lt;code&gt;:norm '&quot;&lt;/code&gt;.  Once at that location, to insert the string &lt;code&gt;hello&lt;/code&gt;, you would use &lt;code&gt;ihello&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -c &quot;norm '\&quot;ihello&quot; file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24" LastActivityDate="2015-03-19T10:49:50.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2630" PostTypeId="1" CreationDate="2015-03-19T12:09:37.223" Score="7" ViewCount="928" Body="&lt;p&gt;I am developing main in Rails using SASS, Slim and Coffeescript. I have Exuberant Ctags installed and using &lt;a href=&quot;http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html&quot; rel=&quot;noreferrer&quot;&gt;tpope's setup&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It kind of works so at least I can move around my ruby code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I would like to be able to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SASS&#xA;color: $whatever    &amp;lt;- go to that color&#xA;@extend %something  &amp;lt;- go to that mixin&#xA;+another()          &amp;lt;- go to that include&#xA;&#xA;HTML/SLIM&#xA;.nice_class         &amp;lt;- go to that class in .sass file&#xA;#id                 &amp;lt;- find JS files using this #id&#xA;&#xA;RUBY&#xA;has_many :something &amp;lt;- go to that class&#xA;concerns :important &amp;lt;- go to that symbol&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And maybe the most important – I want to autocomplete on the above. So I can reuse CSS classes, HTML ID's and Ruby symbols in the project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to set up Ctags to cover css classes, html id's, sass mixins, and everything else used in modern web development? &lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="237" LastEditDate="2015-04-15T11:09:58.083" LastActivityDate="2015-04-15T11:09:58.083" Title="How to set up tags for Ruby, SASS, Slim and Coffescript?" Tags="|autocompletion|tags|ctags|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2631" PostTypeId="2" ParentId="2630" CreationDate="2015-03-19T13:36:22.740" Score="3" Body="&lt;p&gt;Vim is a powerful text editor. The &lt;em&gt;tags&lt;/em&gt; feature is based on a simple foundation: Vim can read one or several &lt;em&gt;tags databases&lt;/em&gt;, which contain line-based records consisting of a tag (basically a string), a corresponding file and address (search pattern) to locate it, and optional additional information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's what you get: If you build a tags file covering your Ruby, SASS, and CoffeeScript, you can jump to defined tags and use completion. However, beyond this simple, easy-to-understand mechanism, Vim has no capabilities of distinguishing various languages and symbols based on syntax or sigils. While you could build come custom intelligence around this, you'd move into the direction of building an IDE, which Vim isn't. Better accept the limitations and use Vim where it excels, and stick to an IDE for the rest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR: Vim is a language-agnostic text editor with basic navigation means, for full capabilities, use an IDE for navigation.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-19T13:36:22.740" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2632" PostTypeId="2" ParentId="2626" CreationDate="2015-03-19T16:02:06.673" Score="0" Body="&lt;p&gt;Perhaps try &lt;code&gt;:cd H:&lt;/code&gt;? Purely guessing based on the contents of &lt;code&gt;:help dos-:cd&lt;/code&gt; &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/os_dos.html#dos-:cd&quot; rel=&quot;nofollow&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/os_dos.html#dos-:cd&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-03-19T16:02:06.673" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2633" PostTypeId="2" ParentId="2594" CreationDate="2015-03-19T16:56:42.953" Score="6" Body="&lt;p&gt;Vim provides 3 concepts for working with multiple files:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Buffers: one for each file you've opened.&lt;/li&gt;&#xA;&lt;li&gt;Windows/Splits: view multiple things at the same time.&lt;/li&gt;&#xA;&lt;li&gt;Tabs: For multiple sets of windows. Useful for managing multiple tasks.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;By conflating them all into the same thing, you're losing out on a lot of power. You should consider other ways which you can use these three things in your workflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everyone has their own preferred technique for doing this. Here are a few distinct tasks you probably want the ability to do and some methods for doing them:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Switch to a file you were recently looking at&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a plugin that manages buffers. There are a &lt;a href=&quot;http://vim.wikia.com/wiki/Easier_buffer_switching#Scripts&quot;&gt;ton&lt;/a&gt; to choose from, but most either utilize fuzzy search or listing them all and allowing you to switch via keyboard/mouse&lt;/li&gt;&#xA;&lt;li&gt;Just use a regular fuzzy file opener. I use &lt;code&gt;:CtrlPMRUFiles&lt;/code&gt; a lot. Even though &lt;code&gt;:CtrlPBuffer&lt;/code&gt; limits to only the buffers currently opened, MRU mode prioritizes these while still letting me open any file in a few keystrokes, whether it's already in a buffer or not.&lt;/li&gt;&#xA;&lt;li&gt;Layout everything in splits/tabs and switch based on their position. See #2 for more info about this&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Group related files&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use tabs for separate tasks. If you want to really embrace this idea, check out &lt;a href=&quot;https://github.com/szw/vim-ctrlspace&quot;&gt;ctrl-space&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Put related files in splits next to each other. If you want to look at many files this way (i.e. 10 levels of a call stack), put them in parallel splits and try my &lt;a href=&quot;https://github.com/mattboehm/vim-accordion&quot;&gt;accordion&lt;/a&gt; plugin.&lt;/li&gt;&#xA;&lt;li&gt;Use the quickfix list to store lists of files (i.e. :grep/Ack/Ag to populate it with occurrences of a phrase.) Note that you can cycle between multiple lists with &lt;code&gt;:colder&lt;/code&gt; and &lt;code&gt;:cnewer&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Jump to specific places in the codebase&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Jump to definition by setting up tags or using &lt;code&gt;gd&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Jump to corresponding test/template by installing and configuring &lt;a href=&quot;https://github.com/tpope/vim-projectionist&quot;&gt;projectionist&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;If a file is jumped to especially often, create a mapping to jump right to it&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Try to figure out what works best for you. I personally use a combination of organizing files in splits/tabs and using fuzzy openers, but many people are more comfortable/efficient with other techniques.&lt;/p&gt;&#xA;" OwnerUserId="680" LastEditorUserId="680" LastEditDate="2015-03-19T17:10:57.223" LastActivityDate="2015-03-19T17:10:57.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2634" PostTypeId="1" AcceptedAnswerId="6192" CreationDate="2015-03-19T17:29:59.890" Score="4" ViewCount="1120" Body="&lt;p&gt;Inside vim, I often use &lt;a href=&quot;https://code.google.com/p/conque/&quot; rel=&quot;nofollow&quot;&gt;conque&lt;/a&gt; plugin, so I can run a bash shell inside a vim buffer. I also may try out &lt;a href=&quot;https://github.com/Shougo/vimshell.vim&quot; rel=&quot;nofollow&quot;&gt;VimShell&lt;/a&gt; soon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In conque, lets say I start typing some bash command, and before I enter it, I realize I have a typo. Since this is vim, naturally I want to go to normal mode, navigate to the typo, and modify it using some vim command. But when I try that it either says 'change mode disabled within shell' or it does look like it changed, but when I try to run the command, it runs it with the original typo in tact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible to do in conque? If not, is there an alternative that allows this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that it would not make sense to change text from the shell that has already been entered as a command or that is output from some program, but I would still like to change a command that is partially typed out, before I enter it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What about VimShell, does that allow this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Further thoughts&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After further thought, I take back something I said here. I think it does make sense to be able to edit the output of another program and edit commands I previously entered. Mind you I don't think editing them should do anything other than change what I see in front of me, but this is a Vim buffer, so I  don't see any reason why I can't do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have some thoughts on how I would like commands I am currently typing out to be truly editable before entering them. The plugin should just do whatever it takes to make the command that is eventually entered match what I see on the screen after the prompt. After each edit of the not yet entered command, it could translate those into keystrokes that would result in the same output and current cursor position thus far. Such an approach should also preserve the ability to use tab completion, up and down arrows, and other things that the prompt interprets in a special way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything out there that allows something like this?&lt;/p&gt;&#xA;" OwnerUserId="1410" LastEditorUserId="1410" LastEditDate="2015-03-19T18:59:57.710" LastActivityDate="2016-01-20T18:42:29.953" Title="When using bash or another shell from a buffer, how do I modify text?" Tags="|buffers|terminal|plugin-conque|plugin-vimshell|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2635" PostTypeId="2" ParentId="2626" CreationDate="2015-03-19T17:55:59.090" Score="4" Body="&lt;p&gt;This was a bug, that was fixed in 7.4.096. (You didn't specify exact version, so I assume, you are using plain 7.4 version and I used to have the same problem when cding into a UNC path)&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="15" LastEditDate="2015-03-19T17:59:23.033" LastActivityDate="2015-03-19T17:59:23.033" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2637" PostTypeId="1" AcceptedAnswerId="2648" CreationDate="2015-03-19T20:49:59.570" Score="1" ViewCount="2322" Body="&lt;p&gt;I'm using &lt;a href=&quot;http://majutsushi.github.io/tagbar/&quot; rel=&quot;nofollow&quot;&gt;Tagbar&lt;/a&gt; (with C++) and I would like to understand if and how it is possible to navigate the code as follow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Find all references of a variable or methods (where the variable or method is used/called... Something like &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;G&lt;/kbd&gt; in Eclipse). It would be great if they would list in the Quickfix list.&lt;/li&gt;&#xA;&lt;li&gt;Leave &lt;em&gt;fixed&lt;/em&gt; the Tagbar window while I moving around in my files. So I would like to have a toggle to stop Tagbar &lt;em&gt;following&lt;/em&gt; me.&lt;/li&gt;&#xA;&lt;li&gt;Regenerate the tags from the root folder (the current folder when I opened Vim)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1450" LastEditorUserId="24" LastEditDate="2015-03-19T20:59:41.950" LastActivityDate="2015-03-20T09:40:01.443" Title="Navigation with Tagbar" Tags="|tags|filetype-c++|ctags|plugin-tagbar|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2638" PostTypeId="5" CreationDate="2015-03-19T21:01:43.727" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://majutsushi.github.io/tagbar/&quot; rel=&quot;nofollow&quot;&gt;Tagbar&lt;/a&gt; is a Vim plugin that provides an easy way to browse the tags of the current file and get an overview of its structure. It does this by creating a sidebar that displays the &lt;a href=&quot;/questions/tagged/ctags&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'ctags'&quot; rel=&quot;tag&quot;&gt;ctags&lt;/a&gt;-generated tags of the current file, ordered by their scope. This means that for example methods in C++ are displayed under the class they are defined in.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-03-20T11:07:29.240" LastActivityDate="2015-03-20T11:07:29.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2639" PostTypeId="4" CreationDate="2015-03-19T21:01:43.727" Score="0" Body="A class outline viewer for Vim" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-03-20T11:07:05.440" LastActivityDate="2015-03-20T11:07:05.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2640" PostTypeId="5" CreationDate="2015-03-19T21:20:34.940" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/bling/vim-airline&quot; rel=&quot;nofollow&quot;&gt;vim-airline&lt;/a&gt; is a lightweight, extensible plugin implemented in &lt;a href=&quot;/questions/tagged/vimscript&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'vimscript'&quot; rel=&quot;tag&quot;&gt;vimscript&lt;/a&gt; to enhance the status bar. It integrates with a variety of plugins, including:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;/questions/tagged/plugin-fugitive&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'plugin-fugitive'&quot; rel=&quot;tag&quot;&gt;plugin-fugitive&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;/questions/tagged/plugin-ctrlp&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'plugin-ctrlp'&quot; rel=&quot;tag&quot;&gt;plugin-ctrlp&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;/questions/tagged/plugin-nerdtree&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'plugin-nerdtree'&quot; rel=&quot;tag&quot;&gt;plugin-nerdtree&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;/questions/tagged/plugin-tagbar&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'plugin-tagbar'&quot; rel=&quot;tag&quot;&gt;plugin-tagbar&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;… and more.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-03-20T11:08:04.670" LastActivityDate="2015-03-20T11:08:04.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2641" PostTypeId="4" CreationDate="2015-03-19T21:20:34.940" Score="0" Body="Vim plugin to enhance the status bar" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-03-20T11:06:56.903" LastActivityDate="2015-03-20T11:06:56.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2642" PostTypeId="5" CreationDate="2015-03-19T21:29:03.580" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-03-19T21:29:03.580" LastActivityDate="2015-03-19T21:29:03.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2643" PostTypeId="4" CreationDate="2015-03-19T21:29:03.580" Score="0" Body="An annotation at the beginning or end of a text document to configure the editor for that document" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-03-20T11:07:14.940" LastActivityDate="2015-03-20T11:07:14.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2644" PostTypeId="1" AcceptedAnswerId="2653" CreationDate="2015-03-19T23:57:13.157" Score="7" ViewCount="1649" Body="&lt;p&gt;I'd like to write the modified buffer I'm currently editing to a temporary file periodically. In the background I could then, for example, use external tools to analyze the file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to write the file to it real location in this process - I want the user to be in charge of that through the normal &lt;code&gt;:w&lt;/code&gt; command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this in a vimscript called by the &lt;code&gt;CursorHold&lt;/code&gt; autocommand? Vim 7.4 and up is fine. &lt;/p&gt;&#xA;" OwnerUserId="1451" LastEditorUserId="51" LastEditDate="2015-03-20T01:18:23.747" LastActivityDate="2018-04-08T17:28:41.080" Title="Writing modified buffer to a temporary file" Tags="|vimscript|autocmd|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2645" PostTypeId="1" AcceptedAnswerId="2647" CreationDate="2015-03-20T02:42:52.947" Score="3" ViewCount="359" Body="&lt;p&gt;I've been messing about with file type specific commands this evening (which is going to be very useful) and I'm trying to write a markdown comment command at the moment. I'm not sure how to go about this though. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So If I have the following text : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a bit &#xA;of text that &#xA;I'm going &#xA;to comment &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can run &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;visual line&#xA;highlight text to comment&#xA;shift i to insert at beginning&#xA;enter &quot;[//]: # (&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That does the start, and I think that all of this could be put to a key command. But then I'm left with the end. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how it should look : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[//]: # (This is a bit &#xA;of text that &#xA;I'm going &#xA;to comment)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Happy to correct any wonky terminology, thanks! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit - possible 'tag' suggestion of &lt;code&gt;ftplugin&lt;/code&gt; :)&lt;/p&gt;&#xA;" OwnerUserId="1443" LastActivityDate="2015-03-20T17:11:57.140" Title="write a key command for a markdown comment" Tags="|vimscript|filetype|comments|filetype-markdown|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2646" PostTypeId="1" AcceptedAnswerId="2654" CreationDate="2015-03-20T08:34:54.533" Score="9" ViewCount="13150" Body="&lt;p&gt;I am trying to build vim from source, especially gvim, to get some of the bug fixes that have been plaguing me in the office repository. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can compile vim fine but gvim is not being generated due to some library missing. I am sure all I am missing is some -devel packages, but which ones?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --prefix=$HOME --enable-multibyte --enable-pythoninterp --with-fea&#xA;tures=big --enable-gui=gnome2 --with-x=yes&#xA;[...]&#xA;checking for X... (cached) libraries , headers &#xA;[...]&#xA;checking if X11 header files can be found... no&#xA;checking --enable-gui argument... no GUI support&#xA;[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;; sudo yum install -y libX11-devel&#xA;Loaded plugins: fastestmirror, langpacks, priorities, remove-with-leaves&#xA;Loading mirror speeds from cached hostfile&#xA; * base: mirror.ox.ac.uk&#xA; * epel: mirror.serverbeheren.nl&#xA; * extras: mirror.econdc.com&#xA; * updates: mirror.ox.ac.uk&#xA;Package libX11-devel-1.6.0-2.1.el7.x86_64 already installed and latest version&#xA;Nothing to do&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a canonical list anywhere?&lt;/p&gt;&#xA;" OwnerUserId="622" LastEditorUserId="467" LastEditDate="2015-03-20T11:45:02.310" LastActivityDate="2018-04-10T12:58:36.413" Title="How to build vim from sources with GUI support?" Tags="|gvim|linux|installing|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2647" PostTypeId="2" ParentId="2645" CreationDate="2015-03-20T08:50:41.520" Score="5" Body="&lt;p&gt;Vim creates marks for the beginning and the end of the last visual selection in the current buffer. You can use &lt;code&gt;'&amp;lt;&lt;/code&gt; to move to the beginning and &lt;code&gt;'&amp;gt;&lt;/code&gt; to move to end. In this way you can conveniently add any text you want before and after the visual selection. For example, I have a map for inserting a LaTeX underline command that spans the current visual selection, like so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;buffer&amp;gt; &amp;lt;localleader&amp;gt;mu &amp;lt;ESC&amp;gt;`&amp;gt;a}&amp;lt;ESC&amp;gt;`&amp;lt;i\uline{&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;: leave visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`&amp;gt;&lt;/code&gt;: go to end of last visual selection &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a}&lt;/code&gt;: insert closing curly bracket after&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;: leave insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`&amp;lt;&lt;/code&gt;: go to beginning of last visual selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;i\uline{&lt;/code&gt;: insert the characters &lt;code&gt;\uline&lt;/code&gt; that make up the underline command and the opening curly bracket&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;: leave insert mode&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I can use this as &lt;code&gt;viwee,mu&lt;/code&gt; to visually select current word and the two following and 'surround' them with the underline command (&lt;code&gt;,&lt;/code&gt; is my local leader). This turns &lt;code&gt;&quot;Ja|g ska bara&quot;, sa Alfons Åberg.&lt;/code&gt; into &lt;code&gt;&quot;\uline{|Jag ska bara}&quot;, sa Alfons Åberg.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be able to adapt this for your situation. Perhaps try something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;ESC&amp;gt;`&amp;gt;a)&amp;lt;ESC&amp;gt;`&amp;lt;i[//]: # (&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="1015" LastEditDate="2015-03-20T15:54:11.813" LastActivityDate="2015-03-20T15:54:11.813" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2648" PostTypeId="2" ParentId="2637" CreationDate="2015-03-20T09:14:17.163" Score="5" Body="&lt;ul&gt;&#xA;&lt;li&gt;A variety of methods are at your disposal&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There are some very useful commands listed &lt;a href=&quot;http://vim.wikia.com/wiki/Displaying_a_variable/macro_definition&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, most notably &lt;code&gt;[I&lt;/code&gt;, which will &lt;strong&gt;display all lines in the current and all included files containing the keyword under the cursor&lt;/strong&gt;. See &lt;code&gt;:h [I&lt;/code&gt; and &lt;code&gt;:h include-search&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You can &lt;code&gt;:grep&lt;/code&gt; or &lt;code&gt;:vimgrep&lt;/code&gt; to search for occurrences of a particular symbol (or any pattern for that matter), and the results will be loaded into the Quickfix (or location) list which you can browse using &lt;code&gt;:copen&lt;/code&gt; (or &lt;code&gt;:lopen&lt;/code&gt;). See &lt;code&gt;:h :grep&lt;/code&gt;. There is also &lt;a href=&quot;https://github.com/rking/ag.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Ag.vim&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You could make use of cscope, as suggested in the first part of this &lt;a href=&quot;https://stackoverflow.com/a/9616315/1208424&quot;&gt;answer&lt;/a&gt; to a similar question&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Try &lt;code&gt;:TagbarTogglePause&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Use one of the handful of tag generation plugins floating around, or create a mapping that runs ctags. As far as Tagbar being able to do this for you, I'm uncertain. Browse &lt;code&gt;:h tagbar&lt;/code&gt; and find out for yourself.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1452" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-03-20T09:40:01.443" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2649" PostTypeId="5" CreationDate="2015-03-20T09:26:57.937" Score="0" Body="&lt;p&gt;From the CentOS site:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The CentOS Linux distribution is a stable, predictable, manageable and&#xA;  reproduceable platform derived from the sources of Red Hat Enterprise&#xA;  Linux.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="622" LastEditorUserId="622" LastEditDate="2015-03-20T12:50:12.293" LastActivityDate="2015-03-20T12:50:12.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2650" PostTypeId="4" CreationDate="2015-03-20T09:26:57.937" Score="0" Body="Related to CentOS Linux distribution." OwnerUserId="622" LastEditorUserId="622" LastEditDate="2015-03-20T12:50:17.093" LastActivityDate="2015-03-20T12:50:17.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2651" PostTypeId="5" CreationDate="2015-03-20T09:31:55.130" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-03-20T09:31:55.130" LastActivityDate="2015-03-20T09:31:55.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2652" PostTypeId="4" CreationDate="2015-03-20T09:31:55.130" Score="0" Body="Questions about the installation procedure of Vim and potential errors encountered in the process." OwnerUserId="-1" LastEditorUserId="1841" LastEditDate="2016-04-15T22:43:45.540" LastActivityDate="2016-04-15T22:43:45.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2653" PostTypeId="2" ParentId="2644" CreationDate="2015-03-20T10:27:21.653" Score="8" Body="&lt;p&gt;This is rather simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd CursorHold *&#xA;\   let save_modified = &amp;amp;modified |&#xA;\       silent! execute 'write' fnameescape(tempname()) |&#xA;\   let &amp;amp;modified = save_modified&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this has the side effect of naming a &lt;code&gt;:new&lt;/code&gt; buffer on the first triggering. (It doesn't affect existing files; this is the difference between &lt;code&gt;:write&lt;/code&gt; and &lt;code&gt;:saveas&lt;/code&gt;.) You can either add another check (&lt;code&gt;empty(bufname(''))&lt;/code&gt;) and undo that via &lt;code&gt;:0file&lt;/code&gt;, or move to lower-level functions altogether:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd CursorHold * call writefile(getline(1, '$'), tempname())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The caveat of this approach is that the file contents will always be persisted&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;with Vim's &lt;code&gt;'encoding'&lt;/code&gt; setting, i.e. you lose any custom &lt;code&gt;'fileencoding'&lt;/code&gt; of the original buffer, and &lt;/li&gt;&#xA;&lt;li&gt;with Unix (LF) line endings (which you could restore with a &lt;code&gt;map()&lt;/code&gt; over the list returned by &lt;code&gt;getline()&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="970" LastEditorUserId="16806" LastEditDate="2018-04-08T17:28:41.080" LastActivityDate="2018-04-08T17:28:41.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2654" PostTypeId="2" ParentId="2646" CreationDate="2015-03-20T11:23:35.463" Score="9" Body="&lt;p&gt;For configuration command you've specified &lt;code&gt;gnome2&lt;/code&gt; as your main GUI (&lt;code&gt;--enable-gui=gnome2&lt;/code&gt;), are you sure it's the right one? Or maybe &lt;code&gt;gnome2&lt;/code&gt; is not enough to enable GUI, so try to add extra &lt;code&gt;--enable-gui&lt;/code&gt;, &lt;code&gt;--with-x&lt;/code&gt; parameters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also configure so your GUI would be detected automatically by &lt;code&gt;--enable-gui=auto&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also make sure that you have all your dependencies such as &lt;code&gt;build-dep&lt;/code&gt; and &lt;code&gt;vim-gtk&lt;/code&gt; (&lt;code&gt;sudo yum builddep vim-X11&lt;/code&gt; or &lt;code&gt;sudo apt-get build-dep vim-gtk&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the problem is still happening, check your &lt;code&gt;config.log&lt;/code&gt; which should be generated by your &lt;code&gt;./configure&lt;/code&gt; to check exact details of the failure for GUI section.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://askubuntu.com/questions/345593/how-to-build-vim-with-gui-option-from-sources&quot;&gt;How to build vim with gui option from sources?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2018-04-10T12:58:36.413" LastActivityDate="2018-04-10T12:58:36.413" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2655" PostTypeId="2" ParentId="839" CreationDate="2015-03-20T15:36:57.990" Score="6" Body="&lt;p&gt;If this is a regular occurrence, you'd be best off looking for a plugin or using @Sukima 's function. If I were doing this on the fly however, here's what I'd probably do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Add a newline after the opening paren and before the closing paren so that strings are on separate lines. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myobj.myfunc(&#xA;             &quot;Some string parameter that goes on and on and on and on and sometimes doesn't&quot;&#xA;             &quot;split very&quot;&#xA;             &quot;neatly over different lines so that&quot;&#xA;             &quot;it is formatted attractively&quot;&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Select lines with strings and delete surrounding quotes: &lt;code&gt;:norm ^x$x&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Reduce textwidth (to account for missing quotes) &lt;code&gt;:set tw-=2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Re-select and format: &lt;code&gt;gvgq&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Fix textwidth: &lt;code&gt;:set tw+=2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Re-add quotes: &lt;code&gt;gv:norm I&quot;&amp;lt;Esc&amp;gt;A&quot;&lt;/code&gt;. Instead of &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; you want to insert a literal escape by typing ctrl-v followed by the escape key. Since I map jj to escape, I usually just type jj here.&lt;/li&gt;&#xA;&lt;li&gt;Optionally use J to re-join the first two/last two lines. When I have a very long string in python like this, I typically prefer to start it on the next line and only indent it one level more than the previous line. This gives more horizontal space for the string and just feels more natural to me. Alternatively, you could save the string to a variable somewhere above. Assuming it's a static string, you could even save it to a global variable so that it's at a much lower indentation level and can fit on fewer lines. Note that you are to rejoin the closing paren on the same line, you probably want to decrement/increment textwidth by 3 instead of 2.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-03-20T15:36:57.990" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2656" PostTypeId="2" ParentId="2614" CreationDate="2015-03-20T15:56:24.413" Score="3" Body="&lt;p&gt;I tried setting up an autocommand to set the mapping later on in startup, but the problem still occurred.&lt;sup&gt;*&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;p&gt;I eventually created an autocommand to occur the first time I enter Insert mode. This is obviously not a perfect solution, but for me it'll work most of the time, and it seems to be the best I can do:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;FURTHER UPDATE&lt;/strong&gt;: If you’re using a vaguely recent version of Vim, &lt;a href=&quot;https://vi.stackexchange.com/a/19073/343&quot;&gt;@BLayer’s answer to this duplicate question&lt;/a&gt; is a much nicer solution. (It uses the &lt;code&gt;timers&lt;/code&gt; feature to delay setup of the mapping instead of my Insert mode hack.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: After using the longer version below without issue for a few years, I decided it was possibly slightly over-engineered, and since then I've used this much simpler version, which instead just resets the mapping every time you enter insert mode:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup escape_mapping&#xA;  autocmd!&#xA;  autocmd InsertEnter * call s:setupEscapeMap()&#xA;augroup END&#xA;&#xA;function! s:setupEscapeMap()&#xA;  nnoremap &amp;lt;Esc&amp;gt; :noh&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The mapping doesn't &lt;em&gt;need&lt;/em&gt; to be reset every time you enter insert mode, but it also doesn't do any harm for Vim to do so.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;ORIGINAL VERSION&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('g:escape_mapped')  &amp;quot; Only need to set the mapping up once.&#xA;  augroup escape_mapping&#xA;    autocmd!&#xA;    &amp;quot; Create the autocommand, to fire when Insert mode is entered&#xA;    autocmd InsertEnter * call s:setupEscapeMap()&#xA;  augroup END&#xA;endif&#xA;&#xA;function! s:setupEscapeMap()&#xA;  &amp;quot; Actually create the mapping&#xA;  nnoremap &amp;lt;Esc&amp;gt; :noh&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt; &#xA;&#xA;  &amp;quot; Now the map exists, so we won't ever need the autocommand again.&#xA;  let g:escape_mapped = 1&#xA;&#xA;  &amp;quot; Tidy up the autocommand and group&#xA;  autocmd! escape_mapping InsertEnter *&#xA;  augroup! escape_mapping&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;sup&gt;* I tried attaching it to various events: &lt;code&gt;VimEnter&lt;/code&gt;, &lt;code&gt;BufReadPost&lt;/code&gt;, &lt;code&gt;BufWinEnter&lt;/code&gt;, and even &lt;code&gt;CursorMoved&lt;/code&gt;(!), but these all seem to fire too early.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-12-05T08:40:30.767" LastActivityDate="2020-12-05T08:40:30.767" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="2658" PostTypeId="2" ParentId="2645" CreationDate="2015-03-20T17:11:57.140" Score="3" Body="&lt;p&gt;Adding/removing/toggling comments is a common request. As such there are a few approaches&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Commenting Plugins&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Using a plugin like &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow&quot;&gt;commentary&lt;/a&gt; (which I use), &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow&quot;&gt;Nerd Commenter&lt;/a&gt;, &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=23&quot; rel=&quot;nofollow&quot;&gt;EnhCommentify&lt;/a&gt;, &lt;a href=&quot;https://github.com/tomtom/tcomment_vim&quot; rel=&quot;nofollow&quot;&gt;tComment&lt;/a&gt;, ..., &lt;a href=&quot;http://vimawesome.com/?q=comment&quot; rel=&quot;nofollow&quot;&gt;etc&lt;/a&gt; make managing comments for all sorts of filetypes much easier as well has giving a consistent interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example commentary use &lt;code&gt;gcc&lt;/code&gt; to toggle an entire line or use &lt;code&gt;gc&lt;/code&gt; followed by a motion to toggle out an entire motion. e.g. &lt;code&gt;gcip&lt;/code&gt; to toggle a paragraph.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Surround.vim&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Using Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow&quot;&gt;surround.vim&lt;/a&gt; plugin can make surrounding with quotes, parens, braces, and tags pairs very simple. It can also be customized so you can add your own &quot;surroundings&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following to &lt;code&gt;~/.vim/after/ftplugin/markdown.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:surround_{char2nr('#')} = &quot;[//]: # (\r)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can select your text via &lt;code&gt;v&lt;/code&gt; and then surround via &lt;code&gt;S#&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help with surround see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h surround&#xA;:h surround-customizing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Change and paste&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Example assuming you have text selected via &lt;code&gt;v&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;c[//]: # (&amp;lt;c-r&amp;gt;&quot;)&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works because &lt;code&gt;c&lt;/code&gt; by default will &quot;cut&quot; the text to the default/unnamed register. Using &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt; we can recall a register while in insert mode. The register in the example above is &lt;code&gt;&quot;&lt;/code&gt; aka unnamed register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do this often enough it might be worth creating a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap gc c[//]: # (&amp;lt;c-r&amp;gt;&quot;)&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Thoughts&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Personally I would install a commenting plugin because it can be such a common operation and creating new mappings for all the filetypes you come across can get annoying quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also recommend looking into surround.vim which feels like a very natural extension of Vim. Install &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow&quot;&gt;repeat.vim&lt;/a&gt; to bring back the glory of &lt;code&gt;.&lt;/code&gt; when using certain plugins.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-03-20T17:11:57.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2659" PostTypeId="1" AcceptedAnswerId="2660" CreationDate="2015-03-20T17:31:01.310" Score="14" ViewCount="2286" Body="&lt;p&gt;Is there a good reason why VimScript functions that I put in my &lt;code&gt;.vimrc&lt;/code&gt; or &lt;code&gt;_vimrc&lt;/code&gt; have to begin with a capital letter?  &lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="205" LastEditDate="2015-03-20T18:20:50.190" LastActivityDate="2015-03-23T11:46:12.587" Title="Do VimScript functions have to start with a capital letter and if so, why?" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2660" PostTypeId="2" ParentId="2659" CreationDate="2015-03-20T17:33:54.710" Score="12" Body="&lt;p&gt;To quote &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#user-functions&quot;&gt;&lt;code&gt;:help user-functions&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The function name must start with an uppercase letter, to avoid confusion with&#xA;  builtin functions.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The same restriction is placed on user-defined commands, although there are a few builtin commands (&lt;code&gt;:N[ext]&lt;/code&gt;, &lt;code&gt;:P[rint]&lt;/code&gt;, &lt;code&gt;:X&lt;/code&gt;) which start with capital letters.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2015-03-20T17:38:57.240" LastActivityDate="2015-03-20T17:38:57.240" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2661" PostTypeId="1" AcceptedAnswerId="2662" CreationDate="2015-03-20T18:25:39.780" Score="7" ViewCount="4488" Body="&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/filetype.html&quot; rel=&quot;noreferrer&quot;&gt;From &lt;code&gt;:help filetype&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If the first line of a *.tex file has the form    &lt;code&gt;%&amp;amp;&amp;lt;format&amp;gt;&lt;/code&gt; then this&#xA;  determined the file type:  plaintex (for plain TeX), context (for&#xA;  ConTeXt), or tex (for LaTeX).&lt;br&gt;&#xA;  Otherwise, the file is searched for keywords to choose context or tex.  If &gt; no keywords are found, it&#xA;  defaults to plaintex. &#xA;  You can change the default by defining the&#xA;  variable &lt;code&gt;g:tex_flavor&lt;/code&gt; to the format (not the file type) you use most. &#xA;  Use one of these:&lt;br&gt;&#xA;  &lt;code&gt;let g:tex_flavor = &quot;plain&quot;&lt;/code&gt;&lt;br&gt;&#xA;  &lt;code&gt;let g:tex_flavor = &quot;context&quot;&lt;/code&gt;&lt;br&gt;&#xA;  &lt;code&gt;let g:tex_flavor = &quot;latex&quot;&lt;/code&gt; &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I open a file from the terminal using &lt;code&gt;vim t.tex&lt;/code&gt; then run &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ft?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It returns&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype=plaintex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should be &lt;code&gt;filetype=latex&lt;/code&gt; shouldn't it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I open a previous document (that was written in TexMaker) within vim and run &lt;code&gt;:set ft?&lt;/code&gt; it returns &lt;code&gt;filetype=tex&lt;/code&gt;. hmm. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have added &lt;code&gt;let g:tex_flavour = &quot;latex&quot;&lt;/code&gt; to my vimrc, but this doesn't seem to make a difference. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what's best here, and what should be the prefered option. I appreciate that the question perhaps part LaTeX part Vim, but the issues I'm having aren't related to LaTeX afaik.&lt;/p&gt;&#xA;" OwnerUserId="1443" LastEditorUserId="1443" LastEditDate="2015-03-21T16:37:45.797" LastActivityDate="2015-03-21T16:37:45.797" Title="Filetype that LaTeX should be" Tags="|vimrc|filetype|filetype-tex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2662" PostTypeId="2" ParentId="2661" CreationDate="2015-03-20T18:36:51.927" Score="14" Body="&lt;p&gt;When there's not enough information to decide otherwise, &lt;code&gt;'filetype'&lt;/code&gt; is set to the most basic -- &lt;code&gt;plaintex&lt;/code&gt;.  Your existing file must have had enough content for the detection to determine that it was actually LaTeX, so &lt;code&gt;'filetype'&lt;/code&gt; was set to &lt;code&gt;tex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The required command to prefer LaTex when there isn't enough information is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tex_flavor = &quot;latex&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, that's &lt;code&gt;flavor&lt;/code&gt;, not &lt;code&gt;flavour&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-03-20T18:36:51.927" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2663" PostTypeId="1" AcceptedAnswerId="2666" CreationDate="2015-03-21T10:36:43.970" Score="3" ViewCount="1104" Body="&lt;p&gt;How to embed first part of the command (operator pending mode) in airline? For example, I'd like to have separate section on the right side to show me this partial command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I set this simply with &lt;code&gt;:set showcmd&lt;/code&gt;, it's displayed under airline status bar. Is it possible to have it displayed in the special section of the status bar, instead of beneath it? &lt;/p&gt;&#xA;" OwnerUserId="1055" LastActivityDate="2015-03-21T13:33:20.680" Title="Embed showcmd in airline" Tags="|plugin-airline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2664" PostTypeId="2" ParentId="2659" CreationDate="2015-03-21T12:20:49.123" Score="5" Body="&lt;p&gt;Old style public function names do indeed have to start with a capital letter. However script function names &lt;code&gt;s:getSNR()&lt;/code&gt;, or autoloaded function names (&lt;code&gt;lh#option#get()&lt;/code&gt;) do not -- I do it more and more often in my plugins.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="51" LastEditDate="2015-03-23T11:46:12.587" LastActivityDate="2015-03-23T11:46:12.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2665" PostTypeId="1" AcceptedAnswerId="2667" CreationDate="2015-03-21T12:46:25.540" Score="7" ViewCount="387" Body="&lt;p&gt;I quite often start typing the &lt;em&gt;s&lt;/em&gt; before fully releasing the shift key, and having to correct the command afterwards is a bit annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to make &lt;code&gt;:Set ...&lt;/code&gt; an alias for &lt;code&gt;:set ...&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1461" LastEditorUserId="23502" LastEditDate="2022-11-01T09:24:57.047" LastActivityDate="2022-11-01T09:24:57.047" Title="How can I bind :Set to work exactly like :set?" Tags="|command-line|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2666" PostTypeId="2" ParentId="2663" CreationDate="2015-03-21T13:33:20.680" Score="3" Body="&lt;p&gt;Outside of &lt;code&gt;:set showcmd&lt;/code&gt;, there's no way to programmatically access the currently typed command, so there's no chance to have airline (or any other plugin) display it, unfortunately.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-21T13:33:20.680" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2667" PostTypeId="2" ParentId="2665" CreationDate="2015-03-21T13:39:46.073" Score="14" Body="&lt;p&gt;While you cannot define custom commands starting with lowercase characters (like the built-in ones), nothing prevents you from doing the opposite, defining user commands that mirror the built-in ones.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -nargs=* -complete=option Set set &amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you do this for additional commands, just ensure the number of arguments / taken &lt;code&gt;:range&lt;/code&gt; / bang (&lt;code&gt;[!]&lt;/code&gt;) matches. See &lt;code&gt;:help :command-nargs&lt;/code&gt; (and following paragraphs) for the available options.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Warning&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Sloppy typing won't get you very far with Vim; instead of relying on such workarounds (which don't work as well in other areas like mappings and motions), better deliberately slow down for a period of time and work on your typing precision. Investing in a higher-quality keyboard might help, too.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-21T13:39:46.073" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2668" PostTypeId="2" ParentId="2665" CreationDate="2015-03-21T13:52:30.263" Score="5" Body="&lt;p&gt;You could remap &lt;code&gt;;&lt;/code&gt; to &lt;code&gt;:&lt;/code&gt;, that way there's no more Shift key involved:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap ; :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has the obvious downside of losing the function of the &lt;code&gt;;&lt;/code&gt; key (&lt;em&gt;&quot;Repeat latest f, t, F or T [count] times.&quot;&lt;/em&gt;), to map this to &lt;code&gt;:&lt;/code&gt; (and thus swapping &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;:&lt;/code&gt;), you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap ; :&#xA;:noremap : ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with that, though, is that once you're used to it, you'll be semi-crippled in a default Vim installation....&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-03-21T13:52:30.263" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2669" PostTypeId="2" ParentId="2665" CreationDate="2015-03-21T15:03:17.247" Score="3" Body="&lt;p&gt;You can simply define an abbreviation. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cab Set set&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As carpetsmoker mentioned this will replace &lt;code&gt;Set&lt;/code&gt; with &lt;code&gt;set&lt;/code&gt; everywhere in the command line. To avoid this use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cnoreab Set set&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="2082" LastEditDate="2015-05-14T20:14:11.040" LastActivityDate="2015-05-14T20:14:11.040" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2670" PostTypeId="1" AcceptedAnswerId="2672" CreationDate="2015-03-21T16:45:27.540" Score="2" ViewCount="1547" Body="&lt;p&gt;I'm using Processing. I've created a Python script that enables me to compile a sketch from the directory that the processing file is in. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm currently running as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!./make.py &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works, but when It's running the Vim window (that I was in) is taken over by the output of the programme. I think that It would be nicer if I could see the code whilst the programme is running. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this means that I want to run the script as a background process? I have tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!./make.py &amp;amp; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that didn't work. But then again that doesn't work if I do it directly from the shell either, so I'm not sure why it should really work from within Vim... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way that I could do this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I would be able to map whatever it is to &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="1443" LastActivityDate="2018-05-01T04:53:26.347" Title="Run an external script from within Vim to compile (not C++)" Tags="|linux|plugin-vimshell|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2671" PostTypeId="2" ParentId="2670" CreationDate="2015-03-21T18:55:41.467" Score="2" Body="&lt;p&gt;The best idea it would be to define your own &lt;code&gt;:make&lt;/code&gt; by setting &lt;code&gt;makeprg&lt;/code&gt; option and then you can run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:make | copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It'll run the command and open a window to show the current list of errors. However it doesn't run in the background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So probably you should use &lt;code&gt;screen&lt;/code&gt; for that, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!screen -dm &quot;!./make.py&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or use &lt;code&gt;:execute &quot;!./foo.py &amp;amp;&quot;&lt;/code&gt; or &lt;code&gt;:call system(&quot;./foo.py &amp;amp;&quot;)&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window&quot; rel=&quot;nofollow noreferrer&quot;&gt;Display output of shell commands in new window&lt;/a&gt; at vim wikia&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/2155/put-a-process-started-with-in-the-background&quot;&gt;Put a process started with ! in the background at Vim SE&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-03-21T18:55:41.467" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2672" PostTypeId="2" ParentId="2670" CreationDate="2015-03-21T19:06:07.277" Score="4" Body="&lt;p&gt;One way, which I don't like all that much, could be to use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#system%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;system()&lt;/code&gt;&lt;/a&gt;. &lt;code&gt;system()&lt;/code&gt; saves the output and returns it, so unless you capture it in a variable or echo it, the output won't show up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call system('./make.py')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;system&lt;/code&gt; doesn't seem to have any indication of whether the command was successful or not, and aside from a blinking cursor (or lack thereof), there's not much visual indication as to whether the command has finished execution. You'd still want to save the output in a variable or something, just to know if the command failed.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.1045645.n5.nabble.com/suppress-output-from-shell-command-tp1174022p1174023.html&quot; rel=&quot;nofollow&quot;&gt;Vim mailing list discussion&lt;/a&gt; on suppressing output of shell commands.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-03-21T19:18:51.977" LastActivityDate="2015-03-21T19:18:51.977" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2673" PostTypeId="1" AcceptedAnswerId="2675" CreationDate="2015-03-21T19:25:50.393" Score="15" ViewCount="24164" Body="&lt;p&gt;I can highlight the current line like this &lt;code&gt;:set cursorline&lt;/code&gt;, which underlines the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/LS4qN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I would like to highlight the entire line in a lighter color. How can I achieve this look?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/w84R6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1464" LastEditorUserId="51" LastEditDate="2015-03-21T23:14:46.050" LastActivityDate="2024-01-30T10:40:32.363" Title="How can I change the colour of the line highlighted with the 'cursorline' option?" Tags="|vimrc|syntax-highlighting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2674" PostTypeId="1" AcceptedAnswerId="2676" CreationDate="2015-03-21T19:41:12.323" Score="138" ViewCount="204761" Body="&lt;p&gt;What is the command (or shortcut) to move a line up or down in vim? My current workflow is to yank (copy) the line and than delete that line and than to put (paste) that line.&lt;/p&gt;&#xA;" OwnerUserId="1464" LastEditorUserId="51" LastEditDate="2015-03-21T23:15:05.373" LastActivityDate="2023-05-12T19:08:02.893" Title="How can I easily move a line?" Tags="|key-bindings|command-line|cut-copy-paste|" AnswerCount="8" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2675" PostTypeId="2" ParentId="2673" CreationDate="2015-03-21T19:48:17.597" Score="22" Body="&lt;p&gt;According to &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27cursorline%27&quot;&gt;&lt;code&gt;:help cursorline&lt;/code&gt;&lt;/a&gt;, the highlight label is &lt;code&gt;CursorLine&lt;/code&gt;. So you can try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight CursorLine ctermbg=LightBlue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help highlight-cterm&lt;/code&gt; for more options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Experiment with the colours to see which suits you. &lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-03-21T19:48:17.597" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2676" PostTypeId="2" ParentId="2674" CreationDate="2015-03-21T20:08:27.690" Score="138" Body="&lt;p&gt;First, you do not need to yank &lt;em&gt;and&lt;/em&gt; delete; the latter will also put the deleted contents into the (default or specified) register. Therefore, &lt;code&gt;ddp&lt;/code&gt; / &lt;code&gt;ddkP&lt;/code&gt; are common commands to move a line one down / up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can use the &lt;code&gt;:move&lt;/code&gt; command, i.e. &lt;code&gt;:move +1&lt;/code&gt; / &lt;code&gt;:move -2&lt;/code&gt;; this doesn't clobber the register, and you can also move entire ranges. You can easily define key mappings to shorten this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't mind plugins (and the additional comfort that often comes with them), both Tim Pope's &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1590&quot;&gt;unimpaired plugin&lt;/a&gt; and my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4140&quot;&gt;LineJuggler plugin&lt;/a&gt; provide &lt;code&gt;]e&lt;/code&gt; / &lt;code&gt;[e&lt;/code&gt; mappings to move lines (and several more; Tim's for a variety of uses, mine focused on handling line(s)).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-21T20:08:27.690" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2677" PostTypeId="1" CreationDate="2015-03-22T07:46:33.880" Score="4" ViewCount="1385" Body="&lt;p&gt;Is there a way to copy the error message that YCM shows at the bottom of vim? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kb8xx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example in the above image, it says: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;unused parameter 'sortFunction'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I had an idea of using &quot;howdoi [paste]&quot; in another terminal and get a solution easily :)&lt;/p&gt;&#xA;" OwnerUserId="101" LastEditorUserId="246" LastEditDate="2015-03-22T10:16:15.560" LastActivityDate="2015-03-22T10:16:15.560" Title="How do I copy the error message I get from YCM" Tags="|cut-copy-paste|plugin-you-complete-me|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2678" PostTypeId="2" ParentId="2674" CreationDate="2015-03-22T09:29:42.163" Score="9" Body="&lt;p&gt;FWIW, here is what I've used for years. It moves the current line up and down in normal mode or the selection in visual mode, while adjusting the indentation automatically.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ,&amp;lt;Up&amp;gt;   :&amp;lt;C-u&amp;gt;silent! move-2&amp;lt;CR&amp;gt;==&#xA;nnoremap ,&amp;lt;Down&amp;gt; :&amp;lt;C-u&amp;gt;silent! move+&amp;lt;CR&amp;gt;==&#xA;xnoremap ,&amp;lt;Up&amp;gt;   :&amp;lt;C-u&amp;gt;silent! '&amp;lt;,'&amp;gt;move-2&amp;lt;CR&amp;gt;gv=gv&#xA;xnoremap ,&amp;lt;Down&amp;gt; :&amp;lt;C-u&amp;gt;silent! '&amp;lt;,'&amp;gt;move'&amp;gt;+&amp;lt;CR&amp;gt;gv=gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-03-22T09:29:42.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2679" PostTypeId="2" ParentId="2677" CreationDate="2015-03-22T09:37:49.380" Score="6" Body="&lt;p&gt;If YCM uses the proper mechanisms, that message should be in either &lt;code&gt;v:statusmsg&lt;/code&gt; or &lt;code&gt;v:errmsg&lt;/code&gt;. You can put those values into the system clipboard via:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @+ = v:statusmsg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-22T09:37:49.380" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="2680" PostTypeId="1" AcceptedAnswerId="2688" CreationDate="2015-03-22T12:05:55.217" Score="13" ViewCount="5050" Body="&lt;p&gt;Imagine you want to quote the word below. If &lt;code&gt;|&lt;/code&gt; is the cursor position you can easily quote the word with &lt;code&gt;cw&quot;&quot;&amp;lt;Esc&amp;gt;P&lt;/code&gt; from Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|below&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to achieve the same behaviour in Command-line mode. My question is how can I say to the Command-line mode that I want to type an &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. I tried &lt;code&gt;:norm cw&quot;&quot;&amp;lt;Esc&amp;gt;P&lt;/code&gt; and some other variations but I just get &lt;code&gt;&quot;&quot;&amp;lt;Esc&amp;gt;P&lt;/code&gt; instead of &lt;code&gt;&quot;below&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still related to this I would like to know how can I make Command-line mode type Ctrl commands. For example I could quote the aforementioned word with &lt;code&gt;cw&quot;&amp;lt;C-r&amp;gt;&quot;&quot;&amp;lt;Esc&amp;gt;&lt;/code&gt; instead. But then I would need Command-line to type &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; for me. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="356" LastActivityDate="2016-03-23T17:16:26.457" Title="Make Command-line mode type &lt;Esc&gt; and Ctrl commands" Tags="|command-line|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2681" PostTypeId="2" ParentId="2680" CreationDate="2015-03-22T12:21:58.287" Score="11" Body="&lt;p&gt;This is because special keys like &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; are not translated in &lt;code&gt;normal&lt;/code&gt; commands, and are treated like you pressed &lt;kbd&gt;&amp;lt;&lt;/kbd&gt;&lt;kbd&gt;E&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;&gt;&lt;/kbd&gt;.  To remedy this, you can use an &lt;code&gt;exec&lt;/code&gt; command.  Like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec &quot;norm cw\&quot;\&quot;\&amp;lt;Esc&amp;gt;P&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you must put a backslash before the quotes and the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, and using single quotes instead of double quotes will not work.&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-03-22T12:21:58.287" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2682" PostTypeId="2" ParentId="2674" CreationDate="2015-03-22T12:57:00.900" Score="105" Body="&lt;p&gt;The easiest is: &lt;code&gt;:m+&lt;/code&gt; or &lt;code&gt;:m-2&lt;/code&gt; which is abbreviation for &lt;code&gt;:move&lt;/code&gt; as Ingo suggested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or using visual mode (&lt;kbd&gt;V&lt;/kbd&gt;) by cutting the line (&lt;kbd&gt;d&lt;/kbd&gt;/&lt;kbd&gt;x&lt;/kbd&gt;) then paste it (&lt;kbd&gt;p&lt;/kbd&gt; - below cursor, &lt;kbd&gt;P&lt;/kbd&gt; above cursor) after you moved your cursor to the right place before pasting (so in summary it's &lt;kbd&gt;Vxp&lt;/kbd&gt;/&lt;kbd&gt;Vdp&lt;/kbd&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When moving multiple lines in visual mode, then you've to use &lt;code&gt;:m '&amp;gt;+1&lt;/code&gt; (to move one line down) or &lt;code&gt;:m '&amp;lt;-2&lt;/code&gt; (to move one line up).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is sample useful mapping (&lt;kbd&gt;Shift+ ↑&lt;/kbd&gt;/&lt;kbd&gt;Shift+↓&lt;/kbd&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;S-Up&amp;gt; :m-2&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;S-Down&amp;gt; :m+&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;S-Up&amp;gt; &amp;lt;Esc&amp;gt;:m-2&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;S-Down&amp;gt; &amp;lt;Esc&amp;gt;:m+&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is similar to Sublime Text (&lt;a href=&quot;http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/reference/keyboard_shortcuts_win.html&quot; rel=&quot;noreferrer&quot;&gt;Win&lt;/a&gt; / &lt;a href=&quot;http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/reference/keyboard_shortcuts_osx.html&quot; rel=&quot;noreferrer&quot;&gt;OSX&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some suggested at &lt;a href=&quot;http://vim.wikia.com/wiki/Moving_lines_up_or_down&quot; rel=&quot;noreferrer&quot;&gt;vim wikia&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;A-j&amp;gt; :m .+1&amp;lt;CR&amp;gt;==&#xA;nnoremap &amp;lt;A-k&amp;gt; :m .-2&amp;lt;CR&amp;gt;==&#xA;inoremap &amp;lt;A-j&amp;gt; &amp;lt;Esc&amp;gt;:m .+1&amp;lt;CR&amp;gt;==gi&#xA;inoremap &amp;lt;A-k&amp;gt; &amp;lt;Esc&amp;gt;:m .-2&amp;lt;CR&amp;gt;==gi&#xA;vnoremap &amp;lt;A-j&amp;gt; :m '&amp;gt;+1&amp;lt;CR&amp;gt;gv=gv&#xA;vnoremap &amp;lt;A-k&amp;gt; :m '&amp;lt;-2&amp;lt;CR&amp;gt;gv=gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In normal mode or in insert mode, press Alt-j to move the current line down, or press Alt-k to move the current line up.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;After visually selecting a block of lines (for example, by pressing V then moving the cursor down), press Alt-j to move the whole block down, or press Alt-k to move the block up.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/741814/55075&quot;&gt;Move entire line up and down in Vim&lt;/a&gt; at SO&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Moving_lines_up_or_down&quot; rel=&quot;noreferrer&quot;&gt;Moving lines up or down&lt;/a&gt; at vim wikia&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="21810" LastEditDate="2019-04-23T12:32:43.970" LastActivityDate="2019-04-23T12:32:43.970" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2683" PostTypeId="1" AcceptedAnswerId="2685" CreationDate="2015-03-22T14:04:00.147" Score="19" ViewCount="1262" Body="&lt;p&gt;This seems like a really daft question, but I have a Python file that has a number in it that's a thousand digits long and that file seems to be running very slowly, I'm not sure if there's some kind of processing going on that I'm unaware of. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I press line up &lt;code&gt;j&lt;/code&gt; and there's a definite pause of ~1 second thats very painful! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only have this on the Python file though, it doesn't happen on others. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After deleting the number the file works normally again... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the number : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;number=(&quot;&quot;&quot;7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450&quot;&quot;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's not even a number really, its a string.&lt;/p&gt;&#xA;" OwnerUserId="1443" LastEditorUserId="23502" LastEditDate="2022-11-01T09:23:56.067" LastActivityDate="2022-11-01T09:23:56.067" Title="Do large numbers make Vim run slowly?" Tags="|filetype-python|performance|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2684" PostTypeId="2" ParentId="2680" CreationDate="2015-03-22T18:26:30.933" Score="2" Body="&lt;p&gt;Command-line mode is different; you cannot use the same (normal mode) editing commands there. You can find a list of commands at &lt;code&gt;:help c_CTRL-V&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, there's the &lt;em&gt;command-line window&lt;/em&gt; (&lt;code&gt;:help command-line-window&lt;/code&gt;), which can be entered via &lt;code&gt;q:&lt;/code&gt; from normal- and &lt;code&gt;&amp;lt;C-F&amp;gt;&lt;/code&gt; from command-line mode. In &lt;em&gt;that&lt;/em&gt; window, you can use all normal commands and mappings, so that would be option 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 2 is special mappings for command-line mode. As I said, you cannot use the approach via &lt;code&gt;:normal&lt;/code&gt; et al. Key to defining those is the &lt;code&gt;:help c_CTRL-\_e&lt;/code&gt; mapping, which &quot;evaluate[s] {expr} and replace[s] the whole command line with the result.&quot; Here's a simple example that only works correctly at the end of the command-line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cnoremap &amp;lt;F1&amp;gt; &amp;lt;C-\&amp;gt;esubstitute(getcmdline(), '\w\+$', '&quot;&amp;amp;&quot;', '')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-22T18:26:30.933" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2685" PostTypeId="2" ParentId="2683" CreationDate="2015-03-22T18:40:50.800" Score="24" Body="&lt;p&gt;I can reproduce this with the &lt;code&gt;syntax/python.vim&lt;/code&gt; that ships with Vim 7.4.663.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:syntime&lt;/code&gt;, this seems to be caused by the following syntax group / pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TOTAL      COUNT  MATCH   SLOWEST     AVERAGE   NAME               PATTERN&#xA;73.870736   20     0       3.940215    3.693537  pythonNumber       \%(^\|\W\)\@&amp;lt;=\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should report this problem to its maintainer (his name and email address is in the script's header).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally, I originally could not reproduce this, because I use an alternative syntax script from &lt;a href=&quot;https://github.com/hdima/python-syntax&quot;&gt;here&lt;/a&gt;. Switching to that (if it fits your requirements), would be a viable workaround, too.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Looking further into the probably cause, this seems to be due to pathological performance of the new NFA-based regexp engine. With &lt;code&gt;:set regexpengine=1&lt;/code&gt;, I don't see that huge slowdown. So one possible workaround / fix would be switching to the old engine for that syntax match; this can be done by prepending &lt;code&gt;\%#=1&lt;/code&gt; to the pattern (cp. &lt;code&gt;:help NFA&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="205" LastEditDate="2015-03-22T21:46:13.200" LastActivityDate="2015-03-22T21:46:13.200" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2686" PostTypeId="1" AcceptedAnswerId="2687" CreationDate="2015-03-22T19:15:13.870" Score="3" ViewCount="206" Body="&lt;p&gt;If i type, for example, &lt;code&gt;y/foo&amp;lt;CR&amp;gt;&lt;/code&gt; in Normal mode, i &quot;yank&quot; all the text until the next occurrence of &quot;foo&quot; without side effects.  However, if i type &lt;code&gt;y?foo&amp;lt;CR&amp;gt;&lt;/code&gt; in Normal mode, i &quot;yank&quot; the text alright, but unfortunately the cursor jumps to the occurrence of &quot;foo&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this the expected behavior?  Is there an easy workaround?&lt;/p&gt;&#xA;" OwnerUserId="1248" LastEditorUserId="1248" LastEditDate="2015-03-22T22:29:20.930" LastActivityDate="2015-03-22T22:29:20.930" Title="Backward motions in Operator-pending mode move cursor" Tags="|cursor-movement|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2687" PostTypeId="2" ParentId="2686" CreationDate="2015-03-22T20:41:27.780" Score="6" Body="&lt;p&gt;The yank command always places the cursor at the &lt;em&gt;start&lt;/em&gt; of the yanked text. If you use operator-pending backwards search, you basically have a reverse selection, with the jump target &lt;em&gt;before&lt;/em&gt; the start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the &lt;code&gt;']&lt;/code&gt; mark has the end of the executed yank, you can return to that original cursor position via &lt;code&gt;g`]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-22T20:41:27.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2688" PostTypeId="2" ParentId="2680" CreationDate="2015-03-22T20:47:36.803" Score="13" Body="&lt;p&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; is what you are looking for. It allows you to enter literal characters (e.g., a literal &lt;code&gt;Esc&lt;/code&gt; instead of the string &quot;Esc&quot;) without requiring you to escape anything.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm cw&quot;&quot;&amp;lt;C-v&amp;gt;&amp;lt;Esc&amp;gt;P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;displays as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm cw&quot;&quot;^[P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and will do what you want (i.e., quote the word). You can also use this with other &lt;code&gt;&amp;lt;C-?&amp;gt;&lt;/code&gt; mappings. For example, your second request:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm cw&quot;&amp;lt;C-v&amp;gt;&amp;lt;C-r&amp;gt;&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;displays as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm cw&quot;^R&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And will result in the same as the above. There's no need to include the extra &lt;code&gt;Esc&lt;/code&gt; at the end.&lt;/p&gt;&#xA;" OwnerUserId="1155" LastEditorUserId="205" LastEditDate="2016-03-23T17:16:26.457" LastActivityDate="2016-03-23T17:16:26.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2689" PostTypeId="1" CreationDate="2015-03-23T11:23:05.823" Score="1" ViewCount="141" Body="&lt;p&gt;I work in two broadly different ways in vim (that are relevant to this question):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I am writing text or markdown-formatted content, writing paragraphs of text. In this case I am generally writing new content, so it is most elegant for &lt;code&gt;sidescrolloff&lt;/code&gt; to be set to 0, otherwise the window content jumps left when I near the end of a line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I am editing existing programming code (e.g. python), which may have line lengths longer than it 'should' have (e.g. longer than &lt;code&gt;textwidth&lt;/code&gt;). In this case I don't want to reformat those lines - I want to work with them at the length they are. In this case it is more elegant if &lt;code&gt;sidescrolloff&lt;/code&gt; is, for example, 20, so that when my cursor gets nearer the end of the window/line on the right I can see the text to the right more clearly.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is there an elegant way to set the value of &lt;code&gt;sidescrolloff&lt;/code&gt; differently depending if I am appending at the end of a line versus in the middle of it (i.e. the middle of the content)? Or perhaps a way to set it depending if I am in insert mode or normal mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, are there any other elegant solutions to my problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In both these cases I use &lt;code&gt;textwidth=78&lt;/code&gt; and &lt;code&gt;nowrap&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="91" LastActivityDate="2015-03-23T13:06:38.590" Title="Is there a way to have sidescrolloff behave differently depending if I am end of a line?" Tags="|scrolling|formatting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2690" PostTypeId="5" CreationDate="2015-03-23T12:34:31.823" Score="0" Body="&lt;p&gt;Vim in Ex mode (also aliases as &lt;code&gt;ex&lt;/code&gt;) is useful when:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You're in need of editing (multiple) files non-interactively (as part of the script).&lt;/li&gt;&#xA;&lt;li&gt;Your connection is very slow or screen is not updated after your actions.&lt;/li&gt;&#xA;&lt;li&gt;Mappings and abbreviations are disabled.&lt;/li&gt;&#xA;&lt;li&gt;Common keys such as &lt;kbd&gt;Escape&lt;/kbd&gt; or &lt;kbd&gt;Control&lt;/kbd&gt; doesn't work.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There is Ex mode (&lt;code&gt;vim -e&lt;/code&gt;) and improved Ex mode which allows for more advanced commands than the vi compatible Ex-mode (&lt;code&gt;vim -E&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-03-23T18:39:16.660" LastActivityDate="2015-03-23T18:39:16.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2691" PostTypeId="4" CreationDate="2015-03-23T12:34:31.823" Score="0" Body="ex is an advanced version of the standard Unix editor ed. It is the direct predecessor of vi." OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-03-23T17:31:00.873" LastActivityDate="2015-03-23T17:31:00.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2692" PostTypeId="2" ParentId="457" CreationDate="2015-03-23T12:40:36.777" Score="126" Body="&lt;p&gt;Vim in Ex mode is useful when:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You're in need of editing (multiple) files non-interactively (as part of the script).&lt;/li&gt;&#xA;&lt;li&gt;Your connection is very slow or screen is not updated after your actions.&lt;/li&gt;&#xA;&lt;li&gt;Mappings and abbreviations are disabled.&lt;/li&gt;&#xA;&lt;li&gt;Common keys such as &lt;kbd&gt;Escape&lt;/kbd&gt; or &lt;kbd&gt;Control&lt;/kbd&gt; doesn't work properly.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Basically &lt;code&gt;vi&lt;/code&gt; is the visual mode for &lt;code&gt;ex&lt;/code&gt; therefore Vim Ex Mode is just emulation of &lt;code&gt;ex&lt;/code&gt; (they still run the same code), so it is possible to get to the command mode of &lt;code&gt;ex&lt;/code&gt; from within vi and vice-versa. There are actually two modes: Ex mode (&lt;code&gt;vim -e&lt;/code&gt;) and improved Ex mode which allows for more advanced commands than the vi compatible Ex-mode (&lt;code&gt;vim -E&lt;/code&gt;). See: &lt;a href=&quot;https://vi.stackexchange.com/q/2694/467&quot;&gt;What is the difference between Ex mode and improved Ex mode?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Ex is the root of a family of editors: &lt;code&gt;edit&lt;/code&gt;, &lt;code&gt;ex&lt;/code&gt; and &lt;code&gt;vi&lt;/code&gt;.  Ex is a super‐&#xA;  set of &lt;code&gt;ed&lt;/code&gt;, with the most notable  extension  being  a  display  editing&#xA;  facility.&lt;sup&gt;ex(1)&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Editing files non-interactively is the most common usage and people using it in similar way as &lt;code&gt;sed&lt;/code&gt; and &lt;code&gt;awk&lt;/code&gt;, however they're are more stream oriented - they only read the file forward from beginning to end (they're not designed to work with multiple lines) while &lt;code&gt;vim&lt;/code&gt; is buffer oriented - you can move forward and backward in the file as you like which makes it so powerful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;sed&lt;/code&gt; is a &lt;strong&gt;S&lt;/strong&gt;tream &lt;strong&gt;ED&lt;/strong&gt;itor, not a file editor. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Nevertheless, people seems to abuse it for trying to edit files and the truth is that it doesn't edit files. Secondly its options such as in-place (&lt;code&gt;-i&lt;/code&gt;) are non-standard FreeBSD extensions and may not be available on other operating systems. So if you want to avoid unportable code, I/O overhead and bad side effects (such as destroying symlinks) you should use &lt;code&gt;ex&lt;/code&gt; which is the standard UNIX command-based editor (along with &lt;code&gt;ed&lt;/code&gt;)&lt;sup&gt;&lt;a href=&quot;http://mywiki.wooledge.org/BashFAQ/021&quot; rel=&quot;noreferrer&quot;&gt;BashFAQ&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Other things which I find useful in Ex mode is to use it as a playground (similar to &lt;code&gt;python&lt;/code&gt; console) where you can execute many commands in a row, working/debugging regular expressions, checking vim configuration, executing external commands or working with registers, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @d = '&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;'&#xA;let @r = '&amp;lt;tr&amp;gt;' . repeat(@d, 5) . '&amp;lt;/tr&amp;gt;'&#xA;echo @r&#xA;let @t = '&amp;lt;table&amp;gt;' . repeat(@r, 5) . '&amp;lt;/table&amp;gt;'&#xA;reg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is more easier in Ex mode than in normal mode (where you can see only your last command).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Practical usages&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I've the following aliases in my &lt;a href=&quot;https://github.com/kenorb/dotfiles/blob/master/.bash_aliases&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;.bash_aliases&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias trim=&quot;ex +'bufdo!%s/\s\+$//e' -scxa&quot;&#xA;alias retab=&quot;ex +'set ts=2' +'bufdo retab' -scxa&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: Using &lt;code&gt;bufdo&lt;/code&gt; is not &lt;a href=&quot;https://unix.stackexchange.com/a/253820/21471&quot;&gt;&lt;code&gt;ex&lt;/code&gt; POSIX-compliant method&lt;/a&gt; (as per &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html&quot; rel=&quot;noreferrer&quot;&gt;manual&lt;/a&gt;), so then you can consider using it with &lt;code&gt;find&lt;/code&gt; instead. The &lt;code&gt;!&lt;/code&gt; is used to force switching the buffers without saving (otherwise warning is generated).&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first one I'm using to trim the trailing spaces in all my source files, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;trim **/*.php&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second one converts &lt;strong&gt;all&lt;/strong&gt; tabs into spaces (recursively), e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;retab **/*.php&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For me using &lt;code&gt;retab&lt;/code&gt; is enough, but there are some downsides described in &lt;a href=&quot;https://vi.stackexchange.com/q/495/467&quot;&gt;here&lt;/a&gt;. Add extra &lt;code&gt;-V&lt;/code&gt; for increased verbosity output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note that above examples using zsh/bash4 &lt;a href=&quot;http://www.linuxjournal.com/content/globstar-new-bash-globbing-option&quot; rel=&quot;noreferrer&quot;&gt;globbing&lt;/a&gt; (&lt;code&gt;**&lt;/code&gt;), so make sure your shell supports it and it's enabled.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more practical examples (like parsing html files), check:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/788/467&quot;&gt;How to edit files non-interactively (e.g. in pipeline)?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/792/467&quot;&gt;How to convert a source code file into HTML?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -E -s -c &quot;let g:html_no_progress=1&quot; -c &quot;syntax on&quot; -c &quot;set ft=c&quot; -c &quot;runtime syntax/2html.vim&quot; -cwqa myfile.c&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also learn further about Ex-mode at:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikibooks.org/wiki/Learning_the_vi_Editor/Vim/Modes#Ex-mode&quot; rel=&quot;noreferrer&quot;&gt;Learning the vi Editor/Vim/Modes: Ex-mode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2017-11-30T13:08:22.133" LastActivityDate="2017-11-30T13:08:22.133" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="2693" PostTypeId="2" ParentId="2689" CreationDate="2015-03-23T13:06:38.590" Score="2" Body="&lt;p&gt;The &lt;code&gt;'sidescrolloff'&lt;/code&gt; option so far is a global option; i.e. it can have only one fixed value. However, you can use &lt;code&gt;:autocmd&lt;/code&gt;s to dynamically switch its value based on the current buffer's filetype (Markdown vs. Python), or syntax (inside comments vs. inside code (can use my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4085&quot; rel=&quot;nofollow&quot;&gt;OnSyntaxChange plugin&lt;/a&gt; for that)), or use the &lt;code&gt;CursorMoved[I]&lt;/code&gt; events (for inserting in the middle vs. end).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-23T13:06:38.590" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2694" PostTypeId="1" AcceptedAnswerId="2695" CreationDate="2015-03-23T13:52:06.407" Score="14" ViewCount="3316" Body="&lt;p&gt;There are two vim Ex modes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the vi compatible Ex-mode (&lt;code&gt;vim -e -s&lt;/code&gt;),&lt;/li&gt;&#xA;&lt;li&gt;vim improved Ex mode (&lt;code&gt;vim -E -s&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Vim improved Ex mode allows for more advanced commands than the vi compatible Ex-mode, however what are the main differences? Or where I can find them?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="51" LastEditDate="2015-03-23T14:20:59.010" LastActivityDate="2015-03-23T14:49:21.470" Title="What is the difference between Ex mode and improved Ex mode?" Tags="|ex-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2695" PostTypeId="2" ParentId="2694" CreationDate="2015-03-23T14:19:55.830" Score="17" Body="&lt;p&gt;This is actually documented in a somewhat 'hidden' non-obvious way, from &lt;a href=&quot;http://vimhelp.appspot.com/intro.txt.html#E501&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help Ex-mode&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Q                       Switch to &quot;Ex&quot; mode.  This is a bit like typing &quot;:&quot;&#xA;                        commands one after another, except:&#xA;                        - You don't have to keep pressing &quot;:&quot;.&#xA;                        - The screen doesn't get updated after each command.&#xA;                        - There is no normal command-line editing.&#xA;                        - Mappings and abbreviations are not used.&#xA;                        In fact, you are editing the lines with the &quot;standard&quot;&#xA;                        line-input editing commands (&amp;lt;Del&amp;gt; or &amp;lt;BS&amp;gt; to erase,&#xA;                        CTRL-U to kill the whole line).&#xA;                        Vim will enter this mode by default if it's invoked as&#xA;                        &quot;ex&quot; on the command-line.&#xA;                        Use the &quot;:vi&quot; command :visual to exit &quot;Ex&quot; mode.&#xA;                        Note: In older versions of Vim &quot;Q&quot; formatted text,&#xA;                        that is now done with gq.  But if you use the&#xA;                        vimrc_example.vim script &quot;Q&quot; works like &quot;gq&quot;.&#xA;&#xA;                                        gQ&#xA;gQ                      Switch to &quot;Ex&quot; mode like with &quot;Q&quot;, but really behave&#xA;                        like typing &quot;:&quot; commands after another.  All command&#xA;                        line editing, completion etc. is available.&#xA;                        Use the &quot;:vi&quot; command :visual to exit &quot;Ex&quot; mode.&#xA;                        {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first paragraph (&lt;code&gt;Q&lt;/code&gt;) documents ex mode (&lt;code&gt;-e&lt;/code&gt;), and the second one documents the improved ex mode (&lt;code&gt;-E&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With ex mode (&lt;code&gt;-e&lt;/code&gt;), Vim tries to &quot;emulate&quot; Ex as much as possible, and a number of Vim improvements won't work (such as mappings, user-defined functions, line editing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With improved ex mode (&lt;code&gt;-E&lt;/code&gt;), Vim &quot;really behaves like typing &quot;:&quot; commands after another&quot;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-03-23T14:49:21.470" LastActivityDate="2015-03-23T14:49:21.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2696" PostTypeId="1" AcceptedAnswerId="2699" CreationDate="2015-03-23T14:24:25.397" Score="8" ViewCount="293" Body="&lt;p&gt;I would expect &lt;code&gt;[count]%&lt;/code&gt; to jump back and forth between matching braces &lt;code&gt;count&lt;/code&gt; times or something like that, but instead, typing that command seems to move the cursor to a random place in the buffer.  It seems to always go to the same place for constant &lt;code&gt;count&lt;/code&gt;, but different places for different &lt;code&gt;count&lt;/code&gt;. So what exactly does that command do?&lt;/p&gt;&#xA;" OwnerUserId="1487" LastEditorUserId="343" LastEditDate="2017-12-06T11:24:55.920" LastActivityDate="2018-05-23T05:55:38.800" Title="What does [count]% do?" Tags="|cursor-movement|count|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2697" PostTypeId="5" CreationDate="2015-03-23T14:24:51.103" Score="0" Body="&lt;p&gt;Vim in Ex mode (also aliases as &lt;code&gt;ex&lt;/code&gt;) is useful when:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You're in need of editing (multiple) files non-interactively (as part of the script).&lt;/li&gt;&#xA;&lt;li&gt;Your connection is very slow or screen is not updated after your actions.&lt;/li&gt;&#xA;&lt;li&gt;Mappings and abbreviations are disabled.&lt;/li&gt;&#xA;&lt;li&gt;Common keys such as &lt;kbd&gt;Escape&lt;/kbd&gt; or &lt;kbd&gt;Control&lt;/kbd&gt; doesn't work.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There is Ex mode (&lt;code&gt;vim -e&lt;/code&gt;) and improved Ex mode which allows for more advanced commands than the vi compatible Ex-mode (&lt;code&gt;vim -E&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-03-23T15:11:04.683" LastActivityDate="2015-03-23T15:11:04.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2698" PostTypeId="4" CreationDate="2015-03-23T14:24:51.103" Score="0" Body="Vim's ex mode is similar to the command line mode which is designed for Batch processing." OwnerUserId="467" LastEditorUserId="51" LastEditDate="2015-06-28T16:56:09.627" LastActivityDate="2015-06-28T16:56:09.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2699" PostTypeId="2" ParentId="2696" CreationDate="2015-03-23T14:29:52.900" Score="12" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#N%25&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help N%&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Go to &lt;code&gt;{count}&lt;/code&gt; percentage in the file, on the first non-blank in the line &lt;code&gt;|linewise|&lt;/code&gt;.  To compute the new line number this formula is used:&lt;br&gt;&#xA;  (&lt;code&gt;{count}&lt;/code&gt; * number-of-lines + 99) / 100&lt;br&gt;&#xA;  See also &lt;code&gt;'startofline'&lt;/code&gt; option.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I didn't know this either, by the way. But I typed &lt;code&gt;:help %&amp;lt;C-d&amp;gt;&lt;/code&gt;, and &lt;code&gt;N%&lt;/code&gt; looked like a good match ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see: &lt;a href=&quot;https://vi.stackexchange.com/q/2136/51&quot;&gt;How do I navigate to topics in Vim's documentation?&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-03-23T14:29:52.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2700" PostTypeId="1" AcceptedAnswerId="2701" CreationDate="2015-03-23T14:39:16.083" Score="2" ViewCount="56" Body="&lt;p&gt;I'm trying to repeat register couple of times and assign it to another register whilst concatenating the strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @d = '&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;'&#xA;let @r = '&amp;lt;tr&amp;gt;' . 10@d . '&amp;lt;/tr&amp;gt;'&#xA;let @t = '&amp;lt;table&amp;gt;' . 10@r . '&amp;lt;/table&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However this syntax is not allowed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any different syntax or workaround to achieve that without repeating &lt;em&gt;n&lt;/em&gt;-times?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="51" LastEditDate="2015-03-23T15:16:39.037" LastActivityDate="2015-03-23T15:16:39.037" Title="How to repeat register on assignment to another register?" Tags="|vimscript|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2701" PostTypeId="2" ParentId="2700" CreationDate="2015-03-23T15:16:06.607" Score="6" Body="&lt;p&gt;There's the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#repeat%28%29&quot;&gt;&lt;code&gt;repeat()&lt;/code&gt;&lt;/a&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;repeat({expr}, {count})&lt;/code&gt;&lt;br&gt;&#xA;  Repeat &lt;code&gt;{expr}&lt;/code&gt; &lt;code&gt;{count}&lt;/code&gt; times and return the concatenated result.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Example usage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @d = '&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;'&#xA;:let @r = '&amp;lt;tr&amp;gt;' . repeat(@d, 3) . '&amp;lt;/tr&amp;gt;'&#xA;:let @t = '&amp;lt;table&amp;gt;' . repeat(@r, 2) . '&amp;lt;/table&amp;gt;'&#xA;&#xA;:echo @r&#xA;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&#xA;:echo @t&#xA;&amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-03-23T15:16:06.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2702" PostTypeId="1" AcceptedAnswerId="2731" CreationDate="2015-03-23T15:34:47.390" Score="38" ViewCount="8905" Body="&lt;p&gt;I'm using VIm for all kinds of things (or gVim in this case), including monitoring output written to a file; I use &lt;code&gt;autoread&lt;/code&gt; to make Vim reread the file, which it does whenever I switch the keyboard focus to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to make Vim update the buffer even if I don't switch the keyboard focus? I've tried setting &lt;code&gt;checktime&lt;/code&gt; but it doesn't appear to have any effect while keyboard focus is elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output I'm monitoring is replacing the output file completely; and I'm not looking to &lt;code&gt;tail -f&lt;/code&gt; it. There are other options, like piping into a new instance every time, or piping into &lt;code&gt;less&lt;/code&gt; or something, but it'd be cool if it could be done with VIm.&lt;/p&gt;&#xA;" OwnerUserId="1489" LastEditorUserId="51" LastEditDate="2015-03-25T21:03:25.330" LastActivityDate="2022-09-28T15:14:03.827" Title="How can I make Vim autoread a file while it doesn't have focus?" Tags="|filesystem|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2703" PostTypeId="1" AcceptedAnswerId="2707" CreationDate="2015-03-23T16:15:28.310" Score="8" ViewCount="2237" Body="&lt;p&gt;Let say I've register which has string stored in it, but I'd like to use &lt;em&gt;substitute&lt;/em&gt; command to change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I've 5x5 html table:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @t='&amp;lt;table&amp;gt;'.repeat('&amp;lt;tr&amp;gt;'.repeat('&amp;lt;td&amp;gt;_&amp;lt;/td&amp;gt;',5).'&amp;lt;/tr&amp;gt;',5).'&amp;lt;/table&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'd like to replace placeholder (&lt;code&gt;_&lt;/code&gt;) with some other data ideally by modifying existing register (not assigning to another).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried the following syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;ts/_/test/g&#xA;&quot;@ts/_/test/g &quot; with modifiable set&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which doesn't give any errors, but it doesn't work as expected (in similar way as prefixing with &lt;code&gt;%&lt;/code&gt; works).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the proper way of doing that?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="24" LastEditDate="2015-03-24T08:26:40.600" LastActivityDate="2015-03-24T08:26:40.600" Title="How to use substitution on register?" Tags="|substitute|register|ex-mode|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2704" PostTypeId="2" ParentId="2703" CreationDate="2015-03-23T16:25:58.833" Score="5" Body="&lt;p&gt;Apart from using the let-statement and dealing with vim-script, you need to paste it into a buffer and then yank it back to the register:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;code&gt;.s/_/test/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1296" LastActivityDate="2015-03-23T16:25:58.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2705" PostTypeId="1" AcceptedAnswerId="2706" CreationDate="2015-03-23T18:25:50.420" Score="11" ViewCount="2662" Body="&lt;p&gt;In my vimrc I have &lt;code&gt;&amp;lt;C-H&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-J&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-K&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; mapped to navigate between split windows in normal mode.  When I use diff mode I only ever have windows in vertical splits, so I'd like to re-purpose &lt;code&gt;&amp;lt;C-J&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-K&amp;gt;&lt;/code&gt; to jump to the previous/next diff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help diff&lt;/code&gt; mentions &lt;code&gt;&amp;amp;diff&lt;/code&gt; when using vimdiff to determine whether you are in diff mode.  It looks like this also gets set when you start a diff from an existing vim session, so I assume I should leverage this somehow to re-set the mappings, but I'm not exactly sure how.  Based on my 2 second test just before posting this, I tried checking &lt;code&gt;&amp;amp;diff&lt;/code&gt; in my vimrc and performing the mapping as needed, but as I suspected the vimrc doesn't get read in again when going into diff mode from an existing vim session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the best way to detect going to/from diff mode and re-setting the mappings accordingly?&lt;/p&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2015-03-23T21:13:54.423" Title="Create mappings that only apply to diff mode" Tags="|key-bindings|vimdiff|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2706" PostTypeId="2" ParentId="2705" CreationDate="2015-03-23T18:45:00.773" Score="21" Body="&lt;p&gt;You can create an expression mapping that checks &lt;code&gt;&amp;amp;diff&lt;/code&gt;. This is done using the &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; keyword.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-J&amp;gt; &amp;amp;diff ? ']c' : '&amp;lt;C-W&amp;gt;j'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this, each time you type &lt;code&gt;&amp;lt;C-J&amp;gt;&lt;/code&gt;, the expression &lt;code&gt;&amp;amp;diff ? ']c' : '&amp;lt;C-W&amp;gt;h'&lt;/code&gt; is evaluated, and the result (a string) is used for your map. So, in diff-mode, &lt;code&gt;&amp;lt;C-J&amp;gt;&lt;/code&gt; will be like &lt;code&gt;]c&lt;/code&gt; (jump to start of next change); otherwise, it will be like &lt;code&gt;&amp;lt;C-W&amp;gt;j&lt;/code&gt; (move to window below).&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-03-23T18:45:00.773" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2707" PostTypeId="2" ParentId="2703" CreationDate="2015-03-23T18:54:27.303" Score="11" Body="&lt;p&gt;Ex commands work on the buffer contents; for register (or variable) contents, you need to use a corresponding Vimscript function (if it exists).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;:substitute&lt;/code&gt;, the equivalent is &lt;code&gt;substitute()&lt;/code&gt; (that was easy, right?) So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @t = substitute(@t, '_', 'test', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-23T18:54:27.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2708" PostTypeId="2" ParentId="2705" CreationDate="2015-03-23T19:21:00.690" Score="3" Body="&lt;p&gt;I use this feature to change the highligting during diffs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;diff&#xA;&#xA;    &quot; Your setting you want to set when using diff mode.&#xA;    &quot;&#xA;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="383" LastEditorUserId="383" LastEditDate="2015-03-23T21:13:54.423" LastActivityDate="2015-03-23T21:13:54.423" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2709" PostTypeId="1" AcceptedAnswerId="2710" CreationDate="2015-03-24T01:45:24.567" Score="8" ViewCount="2062" Body="&lt;p&gt;I have a situation where sometimes my friend and I are working in the same file at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim will tell me if the file has changed when I try to overwrite it.  Can I have vim notify me as soon as the file changes, all by itself, before I save?&lt;/p&gt;&#xA;" OwnerUserId="318" LastEditorUserId="318" LastEditDate="2015-03-24T01:55:49.413" LastActivityDate="2020-09-12T07:11:20.810" Title="How can I have vim automatically notify me when a file that I am editing changes?" Tags="|save|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2710" PostTypeId="2" ParentId="2709" CreationDate="2015-03-24T02:31:31.590" Score="6" Body="&lt;p&gt;Did you try the &lt;code&gt;autoread&lt;/code&gt; option? From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27autoread%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'autoread'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When a file has been detected to have been changed outside of Vim and it has not been changed inside of Vim, automatically read it again.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="515" LastEditorUserId="51" LastEditDate="2015-03-24T11:45:41.367" LastActivityDate="2015-03-24T11:45:41.367" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2711" PostTypeId="5" CreationDate="2015-03-24T08:30:16.407" Score="0" Body="&lt;p&gt;See &lt;code&gt;:help count&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An optional number that may precede the command to multiply&#xA;  or iterate the command.  If no number is given, a count of one&#xA;  is used, unless otherwise noted.  Note that in this manual the&#xA;  [count] is not mentioned in the description of the command,&#xA;  but only in the explanation.  This was done to make the&#xA;  commands easier to look up.  If the 'showcmd' option is on,&#xA;  the (partially) entered count is shown at the bottom of the&#xA;  window.  You can use &amp;lt;Del&gt; to erase the last digit.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="343" LastEditDate="2017-12-06T11:40:09.810" LastActivityDate="2017-12-06T11:40:09.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2712" PostTypeId="4" CreationDate="2015-03-24T08:30:16.407" Score="0" Body="Vim's &quot;count&quot; feature allows you to multiply or iterate a command by passing it an optional number. Questions about counting things should use the &quot;counting&quot; tag instead." OwnerUserId="24" LastEditorUserId="343" LastEditDate="2022-09-15T13:38:17.820" LastActivityDate="2022-09-15T13:38:17.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2713" PostTypeId="1" CreationDate="2015-03-24T15:42:16.310" Score="2" ViewCount="1911" Body="&lt;p&gt;I have the following piece of HTML:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;  &amp;lt;section&amp;gt;&#xA;  &amp;lt;/section&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to wrap the 2 section tags in a single article like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;  &amp;lt;article&amp;gt;&#xA;    &amp;lt;section&amp;gt;&#xA;    &amp;lt;/section&amp;gt;&#xA;  &amp;lt;/article&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow&quot;&gt;vim-surround&lt;/a&gt; installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;S&lt;/kbd&gt;&lt;kbd&gt;&amp;lt;article&amp;gt;&lt;/kbd&gt; I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;article&amp;gt;&#xA;  &amp;lt;section&amp;gt;&#xA;  &amp;lt;/section&amp;gt;&#xA;&amp;lt;/article&amp;gt;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I surround the lines inside the tag object?&lt;/p&gt;&#xA;" OwnerUserId="1503" LastEditorUserId="467" LastEditDate="2015-03-24T17:11:07.367" LastActivityDate="2015-03-25T17:01:50.117" Title="How can I surround the lines inside the html tag object?" Tags="|visual-mode|filetype-html|plugin-vim-surround|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2714" PostTypeId="2" ParentId="2713" CreationDate="2015-03-24T16:07:42.080" Score="2" Body="&lt;p&gt;&lt;kbd&gt;vitVS&amp;lt;article&gt;&lt;/kbd&gt; seems to do what you want.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;v&lt;/kbd&gt; to start select mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;it&lt;/kbd&gt; to select &quot;inner tag&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;V&lt;/kbd&gt; to start line-wise visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;S&amp;lt;article&gt;&lt;/kbd&gt; to surround&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It would be better to start with line-wise visual mode, and go from there, but &lt;kbd&gt;it&lt;/kbd&gt; changes it back to 'normal' (non-line wise) visual mode.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-03-24T16:07:42.080" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2715" PostTypeId="2" ParentId="2713" CreationDate="2015-03-24T17:02:37.610" Score="1" Body="&lt;p&gt;&lt;em&gt;Discl.&lt;/em&gt;: This is not a Surround answer, just (three into) one that give(s) the result your are expecting -- note: there is a big limitation, Surround can work with any tag, here you'll have to known your tags in advance (well, lh-brackets could ask for the tag to insert, but that wouldn't be very ergonomic) .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-brackets&lt;/a&gt;, it'll be solved with: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Brackets &amp;lt;div&amp;gt; &amp;lt;/div&amp;gt; -nl -insert=0 -trigger=µ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you select your lines and hit &lt;code&gt;µ&lt;/code&gt;. The magic is in the &lt;code&gt;-nl&lt;/code&gt; flag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you have the old way (define your own mapping) ... As I though, I've answered to a very similar question not so long ago, but on &lt;a href=&quot;https://stackoverflow.com/questions/28699590/wrapping-of-selected-string/28700179#28700179&quot;&gt;SO&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:xnoremap µ S&amp;lt;div&amp;gt;&amp;lt;cr&amp;gt;&amp;lt;c-r&amp;gt;&quot;&amp;lt;/div&amp;gt;&amp;lt;esc&amp;gt;&#xA;&quot; select your lines, hit µ, and then, you'll need to reindent&#xA;&#xA;&quot; or&#xA;xnoremap µ &amp;lt;esc&amp;gt;`&amp;gt;o&amp;lt;div&amp;gt;&amp;lt;esc&amp;gt;`&amp;lt;O&amp;lt;/div&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-03-24T17:02:37.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2716" PostTypeId="2" ParentId="2713" CreationDate="2015-03-24T18:13:13.107" Score="2" Body="&lt;p&gt;Unfortunately, the &lt;code&gt;it&lt;/code&gt; text-object starts right after the opening tag with a zero-width match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only solution I see is to visually select the lines you want with &lt;code&gt;V{motion}&lt;/code&gt; before pressing &lt;code&gt;S&lt;/code&gt;. It is less magical than &lt;code&gt;ysit&amp;lt;article&amp;gt;&lt;/code&gt; but oh well…&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-03-24T18:13:13.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2717" PostTypeId="1" AcceptedAnswerId="2718" CreationDate="2015-03-24T18:27:20.683" Score="3" ViewCount="524" Body="&lt;p&gt;I currently use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=896&quot; rel=&quot;nofollow&quot;&gt;Ricardo Signes's plugin&lt;/a&gt; to allow me to use a single command to both check my Perl syntax and save my code only if it is syntactically correct.  However, isn't there a simpler way to do this without a plugin and/or a lot of code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can save and then check the syntax for already saved files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w %&amp;lt;bar&amp;gt;! perl -c %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that saves it no matter if the syntax is correct or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read somewhere that this was supposed to be easy. Now, I've been Googling for it, but haven't been able to find it.&lt;/p&gt;&#xA;" OwnerUserId="1111" LastEditorUserId="51" LastEditDate="2015-03-26T14:22:15.633" LastActivityDate="2015-03-26T22:48:10.860" Title="Is there a simple way to require clean syntax before saving?" Tags="|vimrc|save|external-command|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2718" PostTypeId="2" ParentId="2717" CreationDate="2015-03-24T18:51:07.147" Score="5" Body="&lt;p&gt;The mentioned plugin either uses a custom &lt;code&gt;:Write&lt;/code&gt; command, or employs autocmds to hook into the saving. Those are the two possible integrations into Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end, any custom solution will probably re-implement large parts of the plugin. The most lightweight approach I can think of is executing the external check command first, and then only executing the &lt;code&gt;:write&lt;/code&gt; in case that prior command succeeded:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 'write ! perl -c' | if ! v:shell_error | w | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2015-03-24T19:08:18.387" LastActivityDate="2015-03-24T19:08:18.387" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2719" PostTypeId="1" AcceptedAnswerId="2720" CreationDate="2015-03-25T03:55:05.870" Score="-1" ViewCount="2297" Body="&lt;p&gt;I just installed Powerline for the first time and the Powerline bar shows up at the top of my Vim window instead of at the bottom. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is both on MacVim and on terminal Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running OS X 10.10 and iTerm2, with Vim version 7.4.258. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Powerline was installed with Vundle as such: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0X0z2.png&quot; alt=&quot;Powerline at top instead of bottom. Works fine otherwise. &quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1507" LastEditorUserId="205" LastEditDate="2016-04-24T18:01:52.900" LastActivityDate="2023-01-22T04:18:00.993" Title="Vim Powerline is at top of window instead of bottom" Tags="|plugin-powerline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2720" PostTypeId="2" ParentId="2719" CreationDate="2015-03-25T08:12:14.040" Score="5" Body="&lt;p&gt;That is not Powerline, that is Airline. The plugin has a feature that displays a fake tabline at the top of the screen and that's what you see.&lt;/p&gt;&#xA;&lt;p&gt;How to enable that feature is probably explained somewhere in &lt;code&gt;:help airline&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Also, you need &lt;code&gt;set laststatus=2&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt; to enable the &lt;em&gt;actual&lt;/em&gt; statusline for all windows.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="51" LastEditDate="2023-01-22T04:18:00.993" LastActivityDate="2023-01-22T04:18:00.993" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="2722" PostTypeId="1" CreationDate="2015-03-25T10:41:11.093" Score="1" ViewCount="408" Body="&lt;p&gt;Currently in my MacVim, the English font (Source Code Pro Light) is fine, but the Chinese font is being rendered in a very ugly manner. Is there any way to specify what font to use/fontsize for CJK characters, in a similar way as one is able to do so in LaTeX? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1315" LastActivityDate="2015-03-25T10:43:26.123" Title="Macvim - CJK-specific font settings?" Tags="|unicode|font|macvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2723" PostTypeId="2" ParentId="2722" CreationDate="2015-03-25T10:43:26.123" Score="1" Body="&lt;p&gt;Sorry it seems that I didn't Google enough... A quick Googling tells me that &lt;code&gt;set guifontwide&lt;/code&gt; is the way to go(in the same way as &lt;code&gt;set guifont&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1315" LastActivityDate="2015-03-25T10:43:26.123" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2724" PostTypeId="1" AcceptedAnswerId="2727" CreationDate="2015-03-25T12:37:07.353" Score="4" ViewCount="1126" Body="&lt;p&gt;The main project I work on is split up into multiple git projects. I'd like to be able to Ctrl-P search for files in a different project than the one I'm currently in, but as far as I can tell, I can't make Ctrl-P search anything other than the current git project (since it stops when it finds the .git ancestor).&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to tell Ctrl-P to search in multiple .git projects?&lt;/p&gt;&#xA;" OwnerUserId="697" LastEditorUserId="23502" LastEditDate="2022-11-01T09:22:08.310" LastActivityDate="2022-11-01T09:22:08.310" Title="How to add multiple git projects to Ctrl-P search path?" Tags="|plugin-ctrlp|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2725" PostTypeId="1" AcceptedAnswerId="2726" CreationDate="2015-03-25T14:11:31.320" Score="5" ViewCount="1098" Body="&lt;p&gt;I have&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt; &lt;a href=&quot;https://github.com/jalanb/dotjab/blob/master/vim/vimrc#L91&quot; rel=&quot;nofollow noreferrer&quot;&gt;mapped to &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;enter&lt;/kbd&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Q&lt;/kbd&gt; &lt;a href=&quot;https://github.com/jalanb/dotjab/blob/master/vim/vimrc#L202&quot; rel=&quot;nofollow noreferrer&quot;&gt;mapped to &lt;kbd&gt;&amp;lt;esc&amp;gt;&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;!&lt;/kbd&gt;&lt;kbd&gt;enter&lt;/kbd&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;which means&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;quit, unless something needs to be saved&lt;/li&gt;&#xA;&lt;li&gt;just quit&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;My meanings for these keys clashes with vim's idea that &lt;code&gt;stdin&lt;/code&gt; needs to be saved, e.g.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;$ git log | vim -&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;vim says &lt;code&gt;No write since last change ...&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Look at keyboard, find &lt;kbd&gt;shift&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Q&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;And I can then quit.&lt;/p&gt;&#xA;&lt;p&gt;How can I tell vim to ignore file saving when using &amp;quot;-&amp;quot; to read for input from stdin?&lt;/p&gt;&#xA;" OwnerUserId="182" LastEditorUserId="182" LastEditDate="2023-11-13T16:52:08.100" LastActivityDate="2023-11-13T16:52:08.100" Title="How to force quit if input was stdin?" Tags="|key-bindings|save|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2726" PostTypeId="2" ParentId="2725" CreationDate="2015-03-25T14:27:35.197" Score="6" Body="&lt;p&gt;I would start vim with a command that tells it the current file is a scratch buffer (which vim will not prompt you to save):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git log | vim -c &quot;setlocal buftype=nofile bufhidden=hide noswapfile&quot; -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because I do this a lot, I save the scratch buffer settings to a command in my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;:ScratchBuffer makes current buffer disposable&#xA;command! ScratchBuffer setlocal buftype=nofile bufhidden=hide noswapfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also add a bash function in my .bashrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v() {&#xA;    vim -c ScratchBuffer -&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means I can type &lt;code&gt;git log | v&lt;/code&gt; to achieve the desired effect&lt;/p&gt;&#xA;" OwnerUserId="680" LastEditorUserId="51" LastEditDate="2015-03-25T15:19:19.797" LastActivityDate="2015-03-25T15:19:19.797" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2727" PostTypeId="2" ParentId="2724" CreationDate="2015-03-25T15:14:58.033" Score="7" Body="&lt;p&gt;There are a few options depending on the layout of directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all these repos are contained in a single root folder that you want to search, then you can search that directory explicitly by running &lt;code&gt;:CtrlP myproject&lt;/code&gt;. Alternatively, I believe you could say &lt;code&gt;let g:ctrlp_root_markers=['.root']&lt;/code&gt; and make a .root file in the root (myproject) directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If for some strange reason you can't put all these directories in one root, you could make a directory somewhere else, put symlinks in it to all the directories you want searched, put &lt;code&gt;let g:ctrlp_follow_symlinks=1&lt;/code&gt; in your .vimrc, and explicitly tell CtrlP to use this directory when running (&lt;code&gt;:CtrlP mynewroot&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Failing that, you could modify &lt;code&gt;ctrlp_user_command&lt;/code&gt;, but doing so gets complicated and will ignore other ctrlp settings.&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-03-25T15:14:58.033" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2728" PostTypeId="2" ParentId="2725" CreationDate="2015-03-25T16:28:13.000" Score="7" Body="&lt;p&gt;You can run vim in read-only mode (as you're not opening a proper file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git log | vim -R -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then standard &lt;kbd&gt;q&lt;/kbd&gt; should work, without asking you to save your changes.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-03-25T22:50:12.630" LastActivityDate="2015-03-25T22:50:12.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2729" PostTypeId="2" ParentId="2713" CreationDate="2015-03-25T17:01:50.117" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;yS&lt;/code&gt; along with &lt;code&gt;at&lt;/code&gt; to surround the &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt; tags instead of doing a surrounding inside with &lt;code&gt;it&lt;/code&gt; on the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;. So you command will look like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;cr&amp;gt;ySat&amp;lt;article&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; just moves to the start to the next line, a &lt;code&gt;j&lt;/code&gt; would do just as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The alternative is to use visual mode linewise as other suggested. e.g. &lt;code&gt;vitVS&amp;lt;article&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h yS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-03-25T17:01:50.117" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2730" PostTypeId="2" ParentId="2709" CreationDate="2015-03-25T18:22:13.967" Score="4" Body="&lt;p&gt;This question has been answered in StackOverflow: &lt;a href=&quot;https://stackoverflow.com/questions/2490227/how-does-vims-autoread-work&quot;&gt;How does Vim's autoread work?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Solution 1&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Follow explanations in Vim Wikia page &lt;a href=&quot;http://vim.wikia.com/wiki/Have_Vim_check_automatically_if_the_file_has_changed_externally&quot; rel=&quot;nofollow noreferrer&quot;&gt;Have Vim check automatically if the file has changed externally&lt;/a&gt;.&#xA;This solution requires the addition of a function to your vimrc file and that a new command is called on the buffers you want to watch.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Solution 2&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This solution was proposed by @GregSexton in the question I linked above. The idea is to force the modification check whenever one of the following happens:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Entering the buffer.&lt;/li&gt;&#xA;&lt;li&gt;No key was pressed for &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27updatetime%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;'updatetime'&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Cursor moved.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can find the code that implements this below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup checktime&#xA;    au!&#xA;    if !has(&quot;gui_running&quot;)&#xA;        &quot;silent! necessary otherwise throws errors when using command&#xA;        &quot;line window.&#xA;        autocmd BufEnter        * silent! checktime&#xA;        autocmd CursorHold      * silent! checktime&#xA;        autocmd CursorHoldI     * silent! checktime&#xA;        &quot;these two _may_ slow things down. Remove if they do.&#xA;        autocmd CursorMoved     * silent! checktime&#xA;        autocmd CursorMovedI    * silent! checktime&#xA;    endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add and/or remove &lt;code&gt;autocmd&lt;/code&gt; as best suits your workflow. Check &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocmd-events&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for the list of events that can be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27autoread%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;autoread&lt;/a&gt; is also enabled, file will be automatically read if not modified:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoread&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="599" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-03-25T18:22:13.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2731" PostTypeId="2" ParentId="2702" CreationDate="2015-03-25T21:02:19.997" Score="24" Body="&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27autoread%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'autoread'&lt;/code&gt;&lt;/a&gt; doesn't have a lot of information on how it works, but Vim checks if an open file is modified in certain events (it always does this), and will reload it automatically if &lt;code&gt;autoread&lt;/code&gt; is abled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, it checks when:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:checktime&lt;/code&gt; is used;&lt;/li&gt;&#xA;&lt;li&gt;a buffer is entered;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:diffupdate&lt;/code&gt; is used;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:e&lt;/code&gt; is issued for a file that already has a buffer;&lt;/li&gt;&#xA;&lt;li&gt;executing an external command with &lt;code&gt;!&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;returning to the foreground (&lt;code&gt;^Z&lt;/code&gt;, &lt;code&gt;fg&lt;/code&gt;, only if the shell has job control);&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;for gVim, this is also done when:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;closing the &quot;right-click&quot; menu (either by selecting something, or just by closing it);&lt;/li&gt;&#xA;&lt;li&gt;focus is changed (this is what you already noticed);&lt;/li&gt;&#xA;&lt;li&gt;closing the file browsers dialog that pops up if you use &quot;file -&gt; open&quot;, &quot;file -&gt; save as&quot; from the menu (as well as some other places).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I gathered this information from the Vim source by locating all calls to the &lt;code&gt;buf_check_timestamp()&lt;/code&gt;, &lt;code&gt;check_timestamps()&lt;/code&gt; functions, and locations where &lt;code&gt;need_check_timestamps&lt;/code&gt; is set to &lt;code&gt;TRUE&lt;/code&gt;. This list may be outdated because I looked at it 2015, but at a quick glance it seems to still be (mostly) accurate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key thing is that Vim only checks if the file is modified in a very limited set of circumstances. This makes sense, because polling a potentially large number of buffers every &lt;em&gt;n&lt;/em&gt; seconds can be rather expensive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since Vim 7.4.1578 (March 2016) there are timers, which you can use to run &lt;code&gt;checktime&lt;/code&gt; every &lt;em&gt;n&lt;/em&gt; seconds (a previous version of this answer from 2015 used hackish workarounds).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to do this only for certain buffers you can use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoread&#xA;fun! s:checktime(timer_id)&#xA;    checktime&#xA;endfun&#xA;autocmd BufNewFile,BufReadPost xxx&#xA;            \ call timer_start(3000, function('s:checktime'), {'repeat': -1})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has the disadvantage of setting a lot of timers, so perhaps a better method is to set one which loops over all the buffers and then sets the timer again (so you don't risk having two run simultaneously):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoread&#xA;fun! s:checktime(timer_id)&#xA;    for buf in filter(map(getbufinfo(), {_, v -&amp;gt; v.bufnr}), {_, v -&amp;gt; buflisted(v)})&#xA;        echom buf&#xA;        exe 'checktime' buf&#xA;    endfor&#xA;    call timer_start(3000, function('s:checktime'))&#xA;endfun&#xA;call timer_start(3000, function('s:checktime'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did notice Vim blinks a bit even if nothing changes; not sure if there's a way to work around that (didn't look at it); so you might want to add it as a command to run only when needed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoread&#xA;let s:autoread_timer = -1&#xA;fun! s:checktime(timer_id)&#xA;    checktime&#xA;endfun&#xA;&#xA;command! -bang Autoread &#xA;            \  if &amp;lt;bang&amp;gt;0&#xA;            \|   call timer_stop(s:autoread_timer)&#xA;            \| else&#xA;            \|   let s:autoread_timer = timer_start(1000,&#xA;            \        function('s:checktime'), {'repeat': -1})&#xA;            \| endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are many ways to improve on this further, such as enabling it only for the current buffer, more control on how often to run, etc. etc. but the idea should be clear :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-04-28T13:21:42.477" LastActivityDate="2020-04-28T13:21:42.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2732" PostTypeId="1" AcceptedAnswerId="2736" CreationDate="2015-03-25T23:17:03.710" Score="2" ViewCount="298" Body="&lt;p&gt;I'm writing some vimscript and would like to preserve the cursor position after a yank occurs in visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ths issue is that I can't find any way to get the cursor position while in visual mode.  It's always at the beginning or the end of the selection but it's not clear which one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are the &lt;code&gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;&lt;/code&gt; marks to get the beginning/end of the selection.  There is also &lt;code&gt;v&lt;/code&gt; which appears to work nearly identical to &lt;code&gt;&amp;lt;&lt;/code&gt;.   And of course there is &lt;code&gt;.&lt;/code&gt; for cursor position but when in visual mode this returns the beginning of the selection instead.&lt;/p&gt;&#xA;" OwnerUserId="132" LastEditorUserId="51" LastEditDate="2015-03-26T08:57:26.500" LastActivityDate="2015-03-26T08:57:26.500" Title="How do you get which &quot;side&quot; of the visual mode selection the cursor is on in vimscript?" Tags="|vimscript|cut-copy-paste|visual-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2735" PostTypeId="2" ParentId="137" CreationDate="2015-03-26T00:33:30.000" Score="-1" Body="&lt;p&gt;The same happens on OSX. After investigating the problem, I've found it works with plain &lt;code&gt;vi&lt;/code&gt;, but it doesn't work with &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the fix could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EDITOR=vi crontab -e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However &lt;code&gt;vi&lt;/code&gt; is usually linked to &lt;code&gt;vim&lt;/code&gt; (e.g. on OSX) so it's the same thing.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This can be solved by the following line in your &lt;em&gt;vimrc&lt;/em&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead crontab.* set nobackup | set nowritebackup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There is another workaround for this by adding the following lines to &lt;em&gt;.vimrc&lt;/em&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if $VIM_NOBACKUP&#xA;  set nobackup&#xA;  set nowritebackup&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and run the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM_NOBACKUP=1 crontab -e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may also try to define the following variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EDITOR='VIM_NOBACKUP=1 vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://drawohara.com/post/6344279/crontab-temp-file-must-be-edited-in-place&quot; rel=&quot;nofollow&quot;&gt;crontab: temp file must be edited in place&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The reason what this is happening has to do with the way &lt;code&gt;vim&lt;/code&gt;/&lt;code&gt;vi&lt;/code&gt; treats backup files.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-03-26T15:17:10.393" LastActivityDate="2015-03-26T15:17:10.393" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="2736" PostTypeId="2" ParentId="2732" CreationDate="2015-03-26T08:11:37.250" Score="3" Body="&lt;p&gt;Not 100% sure if this is what you're trying to do, but following command will restore the cursor to the position it was in during the last visual mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal! gv\&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This may or may not be what you want, depending on what actions you're applying to the text selected in visual mode. (It works well if you're just yanking the text.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to know the cursor position &lt;em&gt;before&lt;/em&gt; doing anything with the selection, you could try using &lt;code&gt;:execute &quot;normal! \&amp;lt;esc&amp;gt;&quot;&lt;/code&gt;, grabbing the cursor position, and then using &lt;code&gt;:normal! gv&lt;/code&gt; to reset the visual selection. &lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2015-03-26T08:53:40.797" LastActivityDate="2015-03-26T08:53:40.797" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2737" PostTypeId="1" CreationDate="2015-03-26T13:32:04.733" Score="7" ViewCount="3531" Body="&lt;p&gt;I found a command in NERDCommenter like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[count]&amp;lt;leader&amp;gt;cc |NERDComComment|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have installed the plugin. But, I don't know how to make it work. So what's the meaning of that command? How can I make it work?&lt;/p&gt;&#xA;" OwnerUserId="1526" LastEditorUserId="343" LastEditDate="2017-12-06T11:25:47.887" LastActivityDate="2017-12-06T11:25:47.887" Title="What does [count]&lt;leader&gt; mean?" Tags="|key-bindings|count|plugin-nerdcommenter|leader|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2738" PostTypeId="2" ParentId="2737" CreationDate="2015-03-26T13:50:10.553" Score="13" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[count]&lt;/code&gt; is optional. If given, the mapping works for &lt;em&gt;count&lt;/em&gt; lines (ie. comments out &lt;em&gt;count&lt;/em&gt; lines).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; is usually the backslash key (&lt;code&gt;\&lt;/code&gt;), although this can be remapped (also see &lt;a href=&quot;https://vi.stackexchange.com/q/836/51&quot;&gt;What is &amp;lt;Leader&gt;?&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/q/281/51&quot;&gt;How can I find out what &amp;lt;Leader&gt; is set to? And is it possible to remap &amp;amp;ltLeader&gt;?&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cc&lt;/code&gt; is exactly that: two &lt;code&gt;c&lt;/code&gt;'s.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;NERDComComment&lt;/code&gt; has nothing to do with this key mapping, it's the help tag for more information.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, if you want to comment out the current line: use &lt;code&gt;\cc&lt;/code&gt; from normal mode. For the current and next line, use &lt;code&gt;2\cc&lt;/code&gt;, etc.&lt;br&gt;&#xA;You you can select lines with visual mode and then press &lt;code&gt;\cc&lt;/code&gt; to comment out all the selected lines.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2015-03-26T13:50:10.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2739" PostTypeId="2" ParentId="2737" CreationDate="2015-03-26T14:02:20.923" Score="2" Body="&lt;p&gt;The command is used in normal mode by typing first a count, like &lt;code&gt;10&lt;/code&gt;, followed by the &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; key (default is &lt;code&gt;\&lt;/code&gt;) and finally &lt;code&gt;cc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example; type &lt;code&gt;10\cc&lt;/code&gt; in normal mode to comment out 10 lines starting at the cursor position. Omit the count to only comment out the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many people like to remap the &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; key to &lt;code&gt;,&lt;/code&gt;. More info here: &lt;a href=&quot;http://usevim.com/2012/07/20/vim101-leader/&quot; rel=&quot;nofollow&quot;&gt;http://usevim.com/2012/07/20/vim101-leader/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1527" LastActivityDate="2015-03-26T14:02:20.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2740" PostTypeId="1" AcceptedAnswerId="2741" CreationDate="2015-03-26T14:31:02.887" Score="10" ViewCount="3937" Body="&lt;p&gt;I'm aware of the following comparison:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if @% == &quot;/tmp/crontab.zi5NeVPGRc&quot;&#xA;  set nobackup&#xA;  set nowritebackup&#xA;  set noundofile&#xA;  set noswapfile&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how can I use regular expression? For example if the filename contains &quot;crontab&quot;, then do this and that?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-03-28T10:58:01.807" LastActivityDate="2015-03-28T10:58:01.807" Title="How to write condition with regular expression?" Tags="|vimrc|vimscript|regular-expression|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2741" PostTypeId="2" ParentId="2740" CreationDate="2015-03-26T14:39:09.597" Score="11" Body="&lt;p&gt;You just have to use one of &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-%3D%7E&quot; rel=&quot;noreferrer&quot;&gt;the regular expression match operators&lt;/a&gt;. For example, using &lt;code&gt;=~#&lt;/code&gt; to perform a case sensitive match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if @% =~# 'crontab'&#xA;  # the file name contains 'crontab', &#xA;  # do this and that&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2015-03-26T14:50:33.583" LastActivityDate="2015-03-26T14:50:33.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2742" PostTypeId="2" ParentId="2740" CreationDate="2015-03-26T14:39:21.727" Score="8" Body="&lt;p&gt;Use an autocmd. Your vimrc file is executed &lt;em&gt;only&lt;/em&gt; the first time Vim starts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, &lt;code&gt;filetype.vim&lt;/code&gt; should already do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Crontab&#xA;au BufNewFile,BufRead crontab,crontab.*,*/etc/cron.d/*      call s:StarSetf('crontab')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType crontab setlocal backupcopy=yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;nobackup&lt;/code&gt; is not required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note I'm also using &lt;code&gt;setlocal&lt;/code&gt;, to prevent leaking this setting to other buffers, consider when you use &lt;code&gt;crontab -e&lt;/code&gt; and then &lt;code&gt;:tabe /other_file&lt;/code&gt;. Your &lt;code&gt;:set&lt;/code&gt; commands will then 'leak' to this new buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to rely on the filetype for some reason:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead crontab,crontab.*,*/etc/cron.d/* setlocal backupcopy=yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-03-26T14:39:21.727" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2743" PostTypeId="2" ParentId="2108" CreationDate="2015-03-26T15:37:33.383" Score="1" Body="&lt;p&gt;You actually can open new tabs and keep your current tabs without writing new functions (see this answer on &lt;a href=&quot;https://stackoverflow.com/a/11430615/200234&quot;&gt;Stack Overflow&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args file1 file2 | argdo tabe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may want to open a new empty tab (&lt;code&gt;:tabe&lt;/code&gt;) before doing that, because the first file will open in the current tab. Also, an extra empty tab will be left open (see &lt;code&gt;:help argdo&lt;/code&gt; to understand why).&lt;/p&gt;&#xA;" OwnerUserId="1528" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-04-18T22:02:00.383" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2744" PostTypeId="1" CreationDate="2015-03-26T15:40:35.920" Score="2" ViewCount="731" Body="&lt;p&gt;When using &lt;code&gt;netrw&lt;/code&gt; or the &lt;em&gt;native&lt;/em&gt; vim file explorer, every time I click on &lt;code&gt;../&lt;/code&gt;, the cursor moves to the top of the page. This is very irritating when I'm trying to go up multiple directories - I have to scroll back down to the &lt;code&gt;../&lt;/code&gt; and click again, only to have my cursor sent to the top of the buffer yet again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to prevent this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim 7.4, with the following &lt;code&gt;netrw&lt;/code&gt; specific setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_liststyle=3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user489" LastEditorDisplayName="user489" LastEditDate="2015-03-26T16:00:33.597" LastActivityDate="2015-06-24T22:40:19.543" Title="Prevent cursor movement when clicking &quot;../&quot; in netrw" Tags="|netrw|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2745" PostTypeId="2" ParentId="2744" CreationDate="2015-03-26T20:17:32.640" Score="2" Body="&lt;p&gt;This seems to be a bug in netrw. I looked at the code and tried to fix it, but after a few minutes I gave up. The code is not exactly readable...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did notice that pressing &lt;kbd&gt;Enter&lt;/kbd&gt; while on the first line makes the cursor jump to the &lt;code&gt;../&lt;/code&gt; line; so pressing &lt;kbd&gt;Enter&lt;/kbd&gt; twice works, this may be an acceptable work-around for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, I suggest contacting the netrw author as listed in &lt;a href=&quot;http://vimhelp.appspot.com/pi_netrw.txt.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help pi_netrw.txt&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS.&lt;br&gt;&#xA;I discovered what seems to be another bug, if I start Vim with &lt;code&gt;vim /home/martin&lt;/code&gt;, then press &lt;kbd&gt;jj&amp;lt;Enter&lt;/kbd&gt; to open the first directory, and go back up to &lt;code&gt;../&lt;/code&gt;, I need to select it &lt;em&gt;twice&lt;/em&gt; before I go to the root directory.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-03-26T20:17:32.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2746" PostTypeId="2" ParentId="2590" CreationDate="2015-03-26T20:32:58.873" Score="2" Body="&lt;p&gt;This would indeed be rather useful, but unfortunately this isn't possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;showmatches()&lt;/code&gt; function in &lt;code&gt;ex_getln.c&lt;/code&gt; shows the list of completions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * Show all matches for completion on the command line.&#xA; * Returns EXPAND_NOTHING when the character that triggered expansion should&#xA; * be inserted like a normal character.&#xA; */&#xA;    static int&#xA;showmatches(xp, wildmenu)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I see no code for highlighting anything, except directory entries...&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-03-26T20:32:58.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2747" PostTypeId="5" CreationDate="2015-03-26T20:36:52.827" Score="0" Body="&lt;p&gt;Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-fugitive&lt;/code&gt;&lt;/a&gt; plugin;&#xA;see also &lt;a href=&quot;/questions/tagged/git&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;git&amp;#39;&quot; rel=&quot;tag&quot;&gt;git&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="23696" LastEditDate="2021-05-25T19:27:49.870" LastActivityDate="2021-05-25T19:27:49.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2748" PostTypeId="4" CreationDate="2015-03-26T20:36:52.827" Score="0" Body="For questions pertaining to Time Pope's Git wrapper for Vim." OwnerUserId="51" LastEditorUserId="23696" LastEditDate="2021-05-25T19:25:50.400" LastActivityDate="2021-05-25T19:25:50.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2749" PostTypeId="2" ParentId="2544" CreationDate="2015-03-26T21:26:06.183" Score="4" Body="&lt;p&gt;On line 1019 of &lt;code&gt;plugin/fugive.vim&lt;/code&gt; we can see how the &lt;code&gt;:Gcommit&lt;/code&gt; command executes &lt;code&gt;git&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noautocmd silent execute '!'.command.' &amp;gt; '.outfile.' 2&amp;gt; '.errorfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the variables replaced, the command looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!env GIT_EDITOR=false git --git-dir=/home/martin/git-test/.git commit  &amp;gt; /tmp/vC4Lbak/1 2&amp;gt; /tmp/vC4Lbak/2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice the &lt;code&gt;env GIT_EDITOR=false&lt;/code&gt;, this is just to prepare the &lt;code&gt;.git/COMMIT_EDITMSG&lt;/code&gt; and checking if any error occurred! We then open a new buffer with &lt;code&gt;COMMIT_EDITMSG&lt;/code&gt; which the user can edit, and after this is saved, we run &lt;code&gt;git commit&lt;/code&gt; again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fugitive also uses stderr for error checking, and the pre-commit hook outputs to stderr (not stdout!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could work around this by extensively modifying this function, but I would say that running interactive pre-commit hooks is incompatible with how &lt;code&gt;:Gcommit&lt;/code&gt; works, the hook would be run twice, and you lose error detection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you'll have to run &lt;code&gt;git commit&lt;/code&gt; from outside of Vim, or use &lt;code&gt;!git commit&lt;/code&gt; from Vim which will work fine, except that it will launch a &lt;em&gt;second&lt;/em&gt; Vim instance for the commit message (unless you use &lt;code&gt;-m&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create a command for this like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! Commit !git commit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-03-26T21:26:06.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2750" PostTypeId="2" ParentId="2717" CreationDate="2015-03-26T22:42:54.240" Score="0" Body="&lt;p&gt;I have found that the &lt;a href=&quot;https://github.com/scrooloose/syntastic&quot; rel=&quot;nofollow noreferrer&quot;&gt;syntasic&lt;/a&gt; plugin works wonders for this. It uses an auto command that on every write will parse it through a syntax checker (like jshint or perl -c) and the result is placed in VIM's gutter so you see right off where the errors are. There are many more features. It has save numerous problems from heading off to production. It's even caught problems I didn't even know I had.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Syntastic is a syntax checking plugin for Vim that runs files through external syntax checkers and displays any resulting errors to the user. This can be done on demand, or automatically as files are saved. If syntax errors are detected, the user is notified and is happy because they didn't have to compile their code or execute their script to find them.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;… syntastic has checking plugins for ActionScript, Ada, API Blueprint, AppleScript, AsciiDoc, ASM, BEMHTML, Bro, Bourne shell, C, C++, C#, Cabal, Chef, CoffeeScript, Coco, Coq, CSS, Cucumber, CUDA, D, Dart, DocBook, Dust, Elixir, Erlang, eRuby, Fortran, Gentoo metadata, GLSL, Go, Haml, Haskell, Haxe, Handlebars, HSS, HTML, Java, JavaScript, JSON, JSX, LESS, Lex, Limbo, LISP, LLVM intermediate language, Lua, Markdown, MATLAB, Mercury, NASM, Objective-C, Objective-C++, OCaml, Perl, Perl POD, PHP, gettext Portable Object, OS X and iOS property lists, Puppet, Python, R, Racket, Relax NG, reStructuredText, RPM spec, Ruby, SASS/SCSS, Scala, Slim, SML, Tcl, TeX, Texinfo, Twig, TypeScript, Vala, Verilog, VHDL, VimL, xHtml, XML, XSLT, YACC, YAML, z80, Zope page templates, and zsh. See the &lt;a href=&quot;https://github.com/scrooloose/syntastic/wiki/Syntax-Checkers&quot; rel=&quot;nofollow noreferrer&quot;&gt;wiki&lt;/a&gt; for details about the corresponding supported checkers.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QUJZt.png&quot; alt=&quot;Screenshot of Syntastic&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="544" LastEditorUserId="544" LastEditDate="2015-03-26T22:48:10.860" LastActivityDate="2015-03-26T22:48:10.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2751" PostTypeId="1" AcceptedAnswerId="2752" CreationDate="2015-03-26T23:28:25.573" Score="4" ViewCount="4513" Body="&lt;p&gt;Is there a way to substitute a pattern only if it occurs inside the brace pair that the cursor is on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if I have the text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int bar()&#xA;  {&#xA;  ...&#xA;  }&#xA;&#xA;int foo()&#xA;  {&#xA;  char bar;&#xA;&#xA;  bar = 'a';&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can change all instances of bar to baz in the second brace pair using line numbers, e.g. &lt;code&gt;:7,11s/bar/baz/g&lt;/code&gt;. Is it possible to do this without the line numbers, only having the cursor on one of the braces?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The version of Vi I have is 3.10, which doesn't appear to have visual mode&lt;/p&gt;&#xA;" OwnerUserId="763" LastEditorUserId="763" LastEditDate="2015-03-27T22:02:02.250" LastActivityDate="2015-03-27T22:02:02.250" Title="Substitute pattern between braces" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2752" PostTypeId="2" ParentId="2751" CreationDate="2015-03-27T00:21:55.033" Score="8" Body="&lt;h1&gt;First Solution&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;hr&gt;&#xA;This requires some advanced &lt;code&gt;cmdline-range&lt;/code&gt; magic to work. Here is what I have come up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:?{?,/}/s=bar=baz=g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, to break it down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;?{?&lt;/code&gt; - Searches backwards for the first line containing a &lt;code&gt;{&lt;/code&gt;.  You can&#xA;  use any regex in the place of &lt;code&gt;{&lt;/code&gt; if you need to match more specific&#xA;  cases.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;,&lt;/code&gt; - This takes the lines in front of and in back of it, and matches&#xA;all lines in between.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/}/&lt;/code&gt; - Searches forwards for the first line containing a &lt;code&gt;}&lt;/code&gt;.  Once again,&#xA;this could be any regex to match your specific needs.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s=bar=baz=g&lt;/code&gt; - This is just a normal search and replace statement, using&#xA;&lt;code&gt;=&lt;/code&gt; as the seperator.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that you must have the cursor between the two parentheses, otherwise it will not work.  These two help pages are very useful on the subject of &lt;code&gt;cmdline-ranges&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 10.3&#xA;:help cmdline-ranges&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Second Solution&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;hr&gt;&#xA;There is also a slightly simpler way of doing it as well.  These are the keys you have to press:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi{:s/bar/baz/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is how this works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vi{&lt;/code&gt; - Visually select an &quot;inner block&quot;.  See &lt;code&gt;:help text-objects&lt;/code&gt; for&#xA;more on this.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:&lt;/code&gt; - Key to start a command as usual, however when in visual select mode,&#xA;vim automatically inserts markers for the beginning and ending of the &#xA;selection.  Like so: &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt;  This is more special &lt;code&gt;cmdline-range&lt;/code&gt; syntax,&#xA;where &lt;code&gt;'&lt;/code&gt; means the line at marker &lt;code&gt;&amp;lt;&lt;/code&gt;, which in this case is the marker&#xA;which is always set to the beginning of the visual selection.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s/bar/baz/g&lt;/code&gt; - Normal substitution command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-03-27T00:49:55.057" LastActivityDate="2015-03-27T00:49:55.057" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2753" PostTypeId="1" CreationDate="2015-03-27T00:51:33.983" Score="4" ViewCount="953" Body="&lt;p&gt;How would one vertically rotate a visual block of text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example given this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;h&#xA;e&#xA;l&#xA;l&#xA;o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Select those characters in visual block and rotate them once:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;o&#xA;h&#xA;e&#xA;l&#xA;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you see, every character is moved down one line, and the last character (&lt;code&gt;o&lt;/code&gt;) is wrapped around and put on top&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastEditorUserId="7161" LastEditDate="2016-05-02T12:11:09.117" LastActivityDate="2016-05-02T23:51:15.923" Title="Vertically rotate visual block" Tags="|visual-mode|visual-block|rearrangement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2754" PostTypeId="2" ParentId="308" CreationDate="2015-03-27T00:57:12.800" Score="2" Body="&lt;p&gt;There aren't enough examples but I think this does what you want.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.*\zsp.\{-}u.\{-}t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would match &lt;code&gt;put&lt;/code&gt; in your example instead of &lt;code&gt;public void put&lt;/code&gt;. Basically the &lt;code&gt;.*&lt;/code&gt; forces the regex engine to start searching the string backwards, since the &lt;code&gt;.*&lt;/code&gt; consumes the whole string first then backtracks, to find the latest match of &lt;code&gt;p.\{-}u.\{-}t&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2015-03-27T00:57:12.800" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2755" PostTypeId="2" ParentId="2753" CreationDate="2015-03-27T01:22:49.640" Score="7" Body="&lt;p&gt;You can do it like this:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;select the lines you want to rotate (with &lt;code&gt;V&lt;/code&gt; or &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;:&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; to get rid of the &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; that appeared after the &lt;code&gt;:&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;'&amp;gt; move '&amp;lt;-1&lt;/code&gt;, or the short version &lt;code&gt;'&amp;gt;m'&amp;lt;-&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;press &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;move&lt;/code&gt; command accepts a range to move and an address to where the content should be moved (see &lt;code&gt;:help move&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;In this case &lt;code&gt;'&amp;gt;&lt;/code&gt; is the range. It translates to &amp;quot;the last line of the visual selection&amp;quot;. On the other hand, &lt;code&gt;'&amp;lt;-&lt;/code&gt; is the address where we want the selected range to be moved to. It means &amp;quot;the line before (&lt;code&gt;-&lt;/code&gt;) the first visually selected line (&lt;code&gt;'&amp;lt;&lt;/code&gt;)&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;This can be difficult to type and you have to get rid of the &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; that appears when you type &lt;code&gt;:&lt;/code&gt; in Visual mode.&lt;/p&gt;&#xA;&lt;h2&gt;Solution 2&lt;/h2&gt;&#xA;&lt;p&gt;It is much easier to just select all the lines but the last and type &lt;code&gt;dp&lt;/code&gt;. This will delete the selected lines (&lt;code&gt;hell&lt;/code&gt;) and put them after the &lt;code&gt;o&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-05-02T23:51:15.923" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2756" PostTypeId="2" ParentId="2220" CreationDate="2015-03-27T03:05:29.320" Score="3" Body="&lt;p&gt;There is now a &lt;a href=&quot;https://github.com/simnalamburt/vim-mundo&quot; rel=&quot;nofollow&quot;&gt;gundo fork&lt;/a&gt; called &quot;mundo&quot; with this feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While in the undo-tree window, &lt;code&gt;/&lt;/code&gt; will search the history rather than the text displayed in the window itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note: this feature appears to have been adopted from a &lt;a href=&quot;https://github.com/dsummersl/gundo.vim&quot; rel=&quot;nofollow&quot;&gt;different gundo fork&lt;/a&gt;. I'm not sure where credit for the implementation belongs, and I have &lt;strong&gt;not&lt;/strong&gt; tried both forks to see which one works better.)&lt;/p&gt;&#xA;" OwnerUserId="1060" LastEditorUserId="1060" LastEditDate="2016-10-24T20:48:40.263" LastActivityDate="2016-10-24T20:48:40.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2757" PostTypeId="1" CreationDate="2015-03-27T07:08:47.937" Score="6" ViewCount="2197" Body="&lt;p&gt;Is there any possible way to do expand trigger in UltiSnips with &lt;kbd&gt;enter&lt;/kbd&gt;? I've tried &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Return&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;. It works to trigger but doesn't work for new line. And I've tried to &lt;code&gt;&amp;lt;S-Enter&amp;gt;&lt;/code&gt;, but vim doesn't seems like recognize that I press &lt;kbd&gt;Shift&lt;/kbd&gt; button.&lt;/p&gt;&#xA;" OwnerUserId="1526" LastEditorUserId="8136" LastEditDate="2022-11-14T23:04:55.287" LastActivityDate="2022-11-14T23:04:55.287" Title="Triggering UltiSnips with enter" Tags="|key-bindings|autocompletion|insert-mode|plugin-ultisnips|snippets|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2758" PostTypeId="1" AcceptedAnswerId="2759" CreationDate="2015-03-27T08:54:49.643" Score="17" ViewCount="13115" Body="&lt;p&gt;Not easy to find a nice title for my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware of inserting in front of a text-block:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;v&lt;/kbd&gt; &lt;em&gt;select lines&lt;/em&gt; &lt;kbd&gt;I&lt;/kbd&gt; &lt;em&gt;type text&lt;/em&gt; &lt;kbd&gt;ESC&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I would like to do this but also with replacing a part in my block selection. Currently I'm doing two operations&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;v&lt;/kbd&gt; &lt;em&gt;select block&lt;/em&gt; &lt;kbd&gt;x&lt;/kbd&gt; &lt;em&gt;go back to start&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Followed by the sequence I mentioned above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to combine these two operations by selecting (&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;v&lt;/kbd&gt;) the block only once?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a small example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to transform the following block&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1  text&#xA;2  text&#xA;3  text&#xA;4  text&#xA;5  text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;new text &#xA;new text &#xA;new text &#xA;new text &#xA;new text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doing only one &quot;operation&quot;.&lt;/p&gt;&#xA;" OwnerUserId="1542" LastEditorUserId="1542" LastEditDate="2015-11-07T16:27:21.907" LastActivityDate="2020-02-27T09:32:43.353" Title="How to partially replace text in a selected text-block?" Tags="|visual-mode|replace|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2759" PostTypeId="2" ParentId="2758" CreationDate="2015-03-27T09:53:52.557" Score="25" Body="&lt;p&gt;Typing &lt;kbd&gt;c&lt;/kbd&gt; after selecting your block instead of &lt;kbd&gt;x&lt;/kbd&gt; will remove the text in the selection block and will enter insert mode. Once you type something and exit insert mode you should have the same change on every line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;v&lt;/kbd&gt; -- select block -- &lt;kbd&gt;c&lt;/kbd&gt; -- insert whatever -- &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="1545" LastActivityDate="2015-03-27T09:53:52.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2760" PostTypeId="2" ParentId="2753" CreationDate="2015-03-27T11:55:36.433" Score="5" Body="&lt;p&gt;Here's a solution that works even if there are surrounding characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;kdjP`]lx`&amp;lt;P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be mapped to a key like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;C-r&amp;gt; kdjP`]lx`&amp;lt;P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Explanation (here, bolded letters symbolize the cursor / selected text):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initial text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.......&#xA;...&lt;b&gt;h&lt;/b&gt;...&#xA;...&lt;b&gt;e&lt;/b&gt;...&#xA;...&lt;b&gt;l&lt;/b&gt;...&#xA;...&lt;b&gt;l&lt;/b&gt;...&#xA;...&lt;b&gt;o&lt;/b&gt;...&#xA;.......&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;kdjP&lt;/code&gt;: cut all but the last letter and paste it one row down:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.......&#xA;......&#xA;...&lt;b&gt;h&lt;/b&gt;...&#xA;...e...&#xA;...l...&#xA;...lo...&#xA;.......&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;`]lx&lt;/code&gt;: go to the end of the text that was just pasted (&lt;code&gt;`]&lt;/code&gt;), move to the character next to it (&lt;code&gt;l&lt;/code&gt;), and cut it (&lt;code&gt;x&lt;/code&gt;)&lt;sup&gt;1&lt;/sup&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.......&#xA;......&#xA;...h...&#xA;...e...&#xA;...l...&#xA;...l&lt;b&gt;.&lt;/b&gt;..&#xA;.......&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;`&amp;lt;P&lt;/code&gt;: go back to the beginning of the original visual selection (&lt;code&gt;`&amp;lt;&lt;/code&gt;), and paste the last character you just deleted (&lt;code&gt;P&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.......&#xA;...&lt;b&gt;o&lt;/b&gt;...&#xA;...h...&#xA;...e...&#xA;...l...&#xA;...l...&#xA;.......&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1: the dot to the right of the &lt;code&gt;l&lt;/code&gt; is bolded, although it's hard to see.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2015-03-27T11:55:36.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2761" PostTypeId="1" AcceptedAnswerId="2770" CreationDate="2015-03-27T12:27:12.283" Score="25" ViewCount="6154" Body="&lt;p&gt;With the current colourscheme I have been using, it is hard to find where the cursor is positioned when navigating through search results. The highlighting colour and the cursor colour are blending in making it hard to find the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I set the cursor colour different when it is on a highlighted word?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/asPFP.png&quot; alt=&quot;Screenshot of the problem&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1479" LastEditorUserId="1479" LastEditDate="2015-03-27T12:39:25.810" LastActivityDate="2019-08-16T14:25:29.183" Title="Set cursor colour different when on a highlighted word" Tags="|syntax-highlighting|colorscheme|highlight|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2762" PostTypeId="2" ParentId="2761" CreationDate="2015-03-27T13:42:07.440" Score="3" Body="&lt;p&gt;You can choose a better color. Just put this on your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Cursor guifg=#121212 guibg=#afd700&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="177" LastEditorUserId="51" LastEditDate="2015-03-27T13:42:51.283" LastActivityDate="2015-03-27T13:42:51.283" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2763" PostTypeId="2" ParentId="2757" CreationDate="2015-03-27T14:08:03.467" Score="3" Body="&lt;p&gt;Apparently Ultisnips only does this for tab as early adopters of the plugin complained that it broke supertab. It's worth asking the maintainer whether he'd be willing to fix this for &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, there is a workaround that's described in &lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/09876e008495e171f59ed8ce876666d5f8e16ee3/doc/UltiSnips.txt#L292&quot; rel=&quot;nofollow&quot;&gt;the docs&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ulti_expand_or_jump_res = 0 &quot;default value, just set once&#xA;function! Ulti_ExpandOrJump_and_getRes()&#xA;    call UltiSnips#ExpandSnippetOrJump()&#xA;    return g:ulti_expand_or_jump_res&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;CR&amp;gt; &amp;lt;C-R&amp;gt;=(Ulti_ExpandOrJump_and_getRes() &amp;gt; 0)?&quot;&quot;:&quot;\n&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you probably don't want to use &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; as your jump shortcut, as this would prevent you from filling in parts of a snippet with multi-line strings.&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-03-27T14:08:03.467" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2764" PostTypeId="1" AcceptedAnswerId="2765" CreationDate="2015-03-27T14:22:24.020" Score="19" ViewCount="6225" Body="&lt;p&gt;Recently there was an add-on to NeoVim which allows opening terminal in a vim buffer. This has appealing possibilities to send text from one vim window to another replicating, for example, a REPL like behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the past I was using tmux for this kind of configuration. However now I would like to try it out using only NeoVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is - how can I send a block of text from one vim split to another? Or maybe rather - how can I automate the sequence of selecting text, yanking it, changing splits and then pasting?&lt;/p&gt;&#xA;" OwnerUserId="307" LastEditorUserId="1708" LastEditDate="2015-05-25T18:05:06.820" LastActivityDate="2019-02-24T18:44:21.810" Title="Send text from one split window to another" Tags="|split|vim-windows|neovim|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2765" PostTypeId="2" ParentId="2764" CreationDate="2015-03-27T14:50:23.817" Score="17" Body="&lt;p&gt;Basically when you have text selected, you want to remap a key sequence to copy, switch to terminal, paste, and then possibly switch windows back and reselect the text. If you have two splits open, this would look something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;F5&amp;gt; y&amp;lt;c-w&amp;gt;wp&amp;lt;c-w&amp;gt;pgv&#xA;&quot;explanation:&#xA;xnoremap &amp;lt;F5&amp;gt;                   Remap F5 in visual/select mode (could be any key combo)&#xA;              y                 copy selected text&#xA;               &amp;lt;c-w&amp;gt;w           switch to next window&#xA;                     p          paste (for terminals this sends the text to the terminal)&#xA;                      &amp;lt;c-w&amp;gt;p    switch to previous window&#xA;                            gv  reselect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If there are more than two splits and the terminal is not the one after where your text is selected, you'd want to either use a different mapping that works for your layout (i.e. &lt;code&gt;&amp;lt;c-w&amp;gt;t&lt;/code&gt; moves to the top left window) or you'd want to write a function that loops through all windows and finds the right one.&lt;/p&gt;&#xA;" OwnerUserId="680" LastEditorUserId="680" LastEditDate="2015-03-28T04:35:10.543" LastActivityDate="2015-03-28T04:35:10.543" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2766" PostTypeId="1" CreationDate="2015-03-27T15:32:26.903" Score="5" ViewCount="265" Body="&lt;p&gt;Sometimes a regular expression starts to get pretty complex, and it's hard to edit in Vim's commandline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems the obvious way is to edit the search term as though it's a file and be able to switch between editing it and testing it as an actual search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="878" LastEditorUserId="51" LastEditDate="2015-03-27T15:41:06.447" LastActivityDate="2023-01-12T06:51:31.147" Title="How can I edit a regular expression search string as if it were a file?" Tags="|command-line|regular-expression|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="2767" PostTypeId="2" ParentId="2766" CreationDate="2015-03-27T15:38:15.467" Score="6" Body="&lt;p&gt;Use &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; from the command-line or &lt;code&gt;q/&lt;/code&gt; from normal mode to open the command-line window.&lt;/p&gt;&#xA;&lt;p&gt;Note that &lt;code&gt;q/&lt;/code&gt; specifically opens your command-line history in the command-line window but &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; is contextually aware: it will open the right history for the current command-line and is thus the exact answer to your question.&lt;/p&gt;&#xA;&lt;p&gt;See this documentation from &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#cmdwin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help cmdline-window&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;There are two ways to open the command-line window:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;From Command-line mode, use the key specified with the &lt;code&gt;'cedit'&lt;/code&gt; option.    The default is &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;F&lt;/kbd&gt; when &lt;code&gt;'compatible'&lt;/code&gt; is not set.&lt;/li&gt;&#xA;&lt;li&gt;From Normal mode, use the &lt;code&gt;q:&lt;/code&gt;, &lt;code&gt;q/&lt;/code&gt; or &lt;code&gt;q?&lt;/code&gt; command.    This starts editing an Ex command-line (&lt;code&gt;q:&lt;/code&gt;) or search string (&lt;code&gt;q/&lt;/code&gt; or&#xA;&lt;code&gt;q?&lt;/code&gt;).  Note that this is not possible while recording is in progress&#xA;(the    &lt;code&gt;q&lt;/code&gt; stops recording then).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="54" LastEditorUserId="7244" LastEditDate="2023-01-12T06:51:31.147" LastActivityDate="2023-01-12T06:51:31.147" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="2768" PostTypeId="1" CreationDate="2015-03-27T17:04:04.850" Score="35" ViewCount="11007" Body="&lt;p&gt;I've got a few tabs open with different window setups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to open a new blank buffer in the current window, without having any more splits/windows or tabs&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I could do something like &lt;code&gt;:n&lt;/code&gt; then &lt;code&gt;C-w j&lt;/code&gt; then &lt;code&gt;:q&lt;/code&gt; but that seems a bit messy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or similar with tabs: &lt;code&gt;:tabe&lt;/code&gt; &lt;code&gt;gT&lt;/code&gt; &lt;code&gt;:q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm slightly confused about the relationship between windows and buffers in general - you can have lots of buffers open without being visible which you can clean up using &lt;code&gt;bd&lt;/code&gt; but if they aren't visible then they must be saved, because you can't hide them (using :q) without either saving or discarding changes... that seems a little odd.&lt;/p&gt;&#xA;" OwnerUserId="1518" LastActivityDate="2021-11-10T16:39:26.113" Title="How do you open a new buffer in the current window?" Tags="|buffers|vim-windows|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2769" PostTypeId="2" ParentId="2768" CreationDate="2015-03-27T17:15:57.800" Score="37" Body="&lt;p&gt;The answer is to use &lt;code&gt;:ene[w]&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Hah I should have looked at the help before!&lt;/p&gt;&#xA;&lt;p&gt;My first instinct was to try &lt;code&gt;:e&lt;/code&gt; without any arguments.&lt;/p&gt;&#xA;&lt;p&gt;I looked at the help for this and a bit further down is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:ene[w]     Edit a new, unnamed buffer.  This fails when changes&#xA;            have been made to the current buffer, unless 'hidden'&#xA;            is set or 'autowriteall' is set and the file can be&#xA;            written.&#xA;            If 'fileformats' is not empty, the first format given&#xA;            will be used for the new buffer.  If 'fileformats' is&#xA;            empty, the 'fileformat' of the current buffer is used.&#xA;            {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1518" LastEditorUserId="33926" LastEditDate="2021-11-10T16:39:26.113" LastActivityDate="2021-11-10T16:39:26.113" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="2770" PostTypeId="2" ParentId="2761" CreationDate="2015-03-27T17:37:43.707" Score="17" Body="&lt;p&gt;I use this snippet from Damian Conway's fantastic talk, &lt;a href=&quot;https://youtu.be/aHm36-na4-4#t=4m59s&quot; rel=&quot;noreferrer&quot;&gt;More Instantly Better Vim&lt;/a&gt; (at 4m 59s). It causes the entire highlight to blink briefly when you leap between search results. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Damian Conway's Die Blinkënmatchen: highlight matches&#xA;nnoremap &amp;lt;silent&amp;gt; n n:call HLNext(0.1)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; N N:call HLNext(0.1)&amp;lt;cr&amp;gt;&#xA;&#xA;function! HLNext (blinktime)&#xA;  let target_pat = '\c\%#'.@/&#xA;  let ring = matchadd('ErrorMsg', target_pat, 101)&#xA;  redraw&#xA;  exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'&#xA;  call matchdelete(ring)&#xA;  redraw&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want the change in highlighting to be more persistent, you could tweak this to call &lt;code&gt;matchdelete&lt;/code&gt; at some other time (e.g. when the cursor moves).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;UPDATE:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/13551/343&quot;&gt;I recently wrote this more advanced version&lt;/a&gt; in response to another question. It has the following changes::&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;(Optionally) blinks repeatedly: Conway's original version just blinks once: on and then off,&lt;/li&gt;&#xA;&lt;li&gt;Allows you to interrupt the blinking by typing other commands (such as pressing &lt;code&gt;n&lt;/code&gt; again to jump to the next match.) This allows you to set a longer time&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;UPDATE 2:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/qxxxb/vim-searchhi/blob/master/README.md&quot; rel=&quot;noreferrer&quot;&gt;vim-searchhi&lt;/a&gt; plugin provides the originally requested feature.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-02-15T22:16:47.233" LastActivityDate="2019-02-15T22:16:47.233" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="2771" PostTypeId="2" ParentId="2761" CreationDate="2015-03-28T01:54:21.017" Score="3" Body="&lt;p&gt;The only way I can think of is by using the &lt;code&gt;CursorMoved&lt;/code&gt; and &lt;code&gt;CursorMovedI&lt;/code&gt; autocmds, these are invoked every time the cursor is moved...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some code which does exactly that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! CursorColour()&#xA;    if !g:searching | return | endif&#xA;&#xA;    let l:prev_end = 0&#xA;&#xA;    &quot; Loop until we've found all matches of the current search pattern&#xA;    while 1&#xA;        let l:start = match(getline('.'), @/, l:prev_end)&#xA;&#xA;        &quot; No more matches: stop looping&#xA;        if l:start == -1 | break | endif&#xA;&#xA;        let l:cursor = col('.')&#xA;        &quot; Check if the cursor is inside the string&#xA;        if l:cursor &amp;gt; l:start &amp;amp;&amp;amp; l:cursor &amp;lt;= l:start + strlen(@/)&#xA;            hi Cursor guifg=#121212 guibg=#afd700&#xA;            return&#xA;        endif&#xA;&#xA;        &quot; Set start location for next loop iteration&#xA;        let l:prev_end = l:start + strlen(@/)&#xA;    endwhile&#xA;&#xA;    &quot; We return if we're on a highlighted string, if we're here we didn't&#xA;    &quot; match anything&#xA;    call ResetCursorColour()&#xA;endfun&#xA;&#xA;fun! ResetCursorColour()&#xA;    hi Cursor guifg=#ffffff guibg=#000000&#xA;endfun&#xA;&#xA;autocmd CursorMoved,CursorMovedI * call CursorColour()&#xA;&#xA;let g:searching=0&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-L&amp;gt; :nohlsearch&amp;lt;CR&amp;gt;:let g:searching=0&amp;lt;CR&amp;gt;:call ResetCursorColour()&amp;lt;CR&amp;gt;&amp;lt;C-L&amp;gt;&#xA;nnoremap / :let g:searching=1&amp;lt;CR&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are some &lt;strong&gt;caveats&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;This only works for gVim, as changing the cursor colour isn't possible in terminal Vim (this is something you configure in your terminal emulator, and not something Vim can control in most terminals).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I can't find an obvious way to check if the character I'm on is part of the current search term and/or is being highlighted; the only way is to get the line, and regexp that (again) with &lt;code&gt;@/&lt;/code&gt;. There may be some minor differences on regexp interpretation between &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;match()&lt;/code&gt; depending on your settings (see &lt;code&gt;:help match()&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I can't find out a way to check if we're currently actually highlighting something, the &lt;code&gt;@/&lt;/code&gt; register contains the last used search, regardless of what we're highlighting. So what I did is remap &lt;code&gt;/&lt;/code&gt; to first set the &lt;code&gt;g:searching&lt;/code&gt; variable to indicate we're doing an active search, and with &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; we call &lt;code&gt;:nohlsearch&lt;/code&gt; to clear the highlighting, and set &lt;code&gt;g:searching&lt;/code&gt; to false to indicate that we're not searching...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This is run &lt;em&gt;every time the cursor moves&lt;/em&gt;, it may not be very fast especially for large files/lines, slow systems or complicated regexps (it seems to work okay for me though).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-03-28T01:54:21.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2772" PostTypeId="1" AcceptedAnswerId="4266" CreationDate="2015-03-28T18:14:03.557" Score="6" ViewCount="2288" Body="&lt;p&gt;In gVim, I want to open a file that starts with an exclamationmark, say, for example, &lt;code&gt;!this_is_my_file_whose_name_is_rather_long.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So, I type &lt;code&gt;:e !this&lt;/code&gt; followed by pressing the tabulator.&lt;/p&gt;&#xA;&lt;p&gt;gVim expands the filename, but also prepends it with a backslash, so that the command line reads&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:e \!this_is_my_file_whose_name_is_rather_long.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I now press enter, thinking this will open my desired file, gVim will instead create a new buffer whose name also has the backslash.&lt;/p&gt;&#xA;&lt;p&gt;This is of course not what I want. So after pressing the tabulator, I move the cursor to the backslash and delete it. Then, gVim will open the file that I want.&lt;/p&gt;&#xA;&lt;p&gt;I &lt;em&gt;assume&lt;/em&gt; that behaviour is ms-Windows related. Currently, I cannot go to a Unix machine to verify if I'd encounter this problem on Unix as well.&lt;/p&gt;&#xA;&lt;p&gt;So, is there a way to turn this behaviour off?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="23502" LastEditDate="2022-11-01T19:54:30.013" LastActivityDate="2022-11-01T19:54:30.013" Title="How do I open a file that starts with an exclamation mark using filename completion?" Tags="|filesystem|microsoft-windows|" AnswerCount="1" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2773" PostTypeId="1" AcceptedAnswerId="2774" CreationDate="2015-03-28T18:40:38.697" Score="6" ViewCount="399" Body="&lt;p&gt;Is there a way to disable a plugin (or a set of keymaps) on a specific filetype? &lt;code&gt;vim-surround&lt;/code&gt; causes a delay in &lt;code&gt;netrw&lt;/code&gt; when pressing &lt;code&gt;d&lt;/code&gt; to create a new directory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking that this might be possible with an auto command that looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd Filetype netrw ...something...&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an open issue &lt;a href=&quot;https://github.com/tpope/vim-surround/issues/98&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastEditorUserId="51" LastEditDate="2015-04-26T09:50:38.797" LastActivityDate="2015-04-26T09:50:38.797" Title="Disable vim-surround in a netrw buffer" Tags="|key-bindings|netrw|plugin-vim-surround|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2774" PostTypeId="2" ParentId="2773" CreationDate="2015-03-28T20:08:19.043" Score="5" Body="&lt;p&gt;The surround plugin defines global mappings. Unfortunately, you can only &lt;em&gt;override&lt;/em&gt; those with buffer-local ones, but not &lt;code&gt;:unmap&lt;/code&gt; them only in the buffer. Temporarily disabling and re-defining the global surround mappings would be possible, but is cumbersome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the best solution would be patching the netrw plugin to add the &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; argument to the &lt;code&gt;d&lt;/code&gt; mapping (and all other buffer-local plugin mappings). This would fix the timeout issue, and you probably don't need to invoke the other (surround et al.) mappings on a netrw buffer, anyway.&#xA;Unfortunately, netrw's &lt;code&gt;d&lt;/code&gt; mapping invokes a script-local function (&lt;code&gt;:call &amp;lt;SID&amp;gt;NetrwMakeDir(&quot;&quot;)&lt;/code&gt;), so it's difficult to redefine the mapping with an &lt;code&gt;:autocmd FileType netrw&lt;/code&gt;; you'd need the &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; of netrw. So please suggest that enhancement to netrw's author, Chip Campbell; you'll find his address in the script header.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-28T20:08:19.043" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2775" PostTypeId="1" AcceptedAnswerId="2780" CreationDate="2015-03-29T09:10:38.663" Score="1" ViewCount="86" Body="&lt;p&gt;I noticed that whenever I quit Gvim, it will remember the line and position within the line that the cursor was on, unless the cursor was on line 1.  If the cursor was on line 1, then it will not remember the position within line 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if I have the cursor at the end of line 2 and I quit Gvim, then the next time I open the same file in Gvim, it will place the cursor at the end of line 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I have the cursor at the end of line 1 and I quit Gvim, then the next time I open the same file in Gvim, it will place the cursor at the &lt;em&gt;beginning&lt;/em&gt; of line 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a bug in Gvim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running Gvim 7.2 on Windows.&lt;/p&gt;&#xA;" OwnerUserId="334" LastActivityDate="2015-03-29T19:53:17.640" Title="Gvim doesn't remember cursor position within line if previous session ended on line 1" Tags="|cursor-movement|gvim|microsoft-windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2776" PostTypeId="1" AcceptedAnswerId="2777" CreationDate="2015-03-29T09:53:49.950" Score="92" ViewCount="48281" Body="&lt;p&gt;One of the open questions I have about Vim is if there is a way to perform a search/replace in the current project (bear with me if I use this notion inherited from other editors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, let's assume I want to search my project files for a method name, and rename all the instances of that method call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how I can proceed with Sublime.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wRGOZ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you do this in Vim (possibly MacVim) without relying on other programs such as &lt;code&gt;ack&lt;/code&gt; or &lt;code&gt;sed&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1558" LastActivityDate="2022-05-28T13:28:33.870" Title="Vim search replace all files in current (project) folder" Tags="|search|macvim|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2777" PostTypeId="2" ParentId="2776" CreationDate="2015-03-29T10:50:03.173" Score="99" Body="&lt;p&gt;There are several ways to do this.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Inside Current Directory&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you want to perform the search/replace in a project tree, you can use Vim's &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#argument-list&quot;&gt;argument list&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply open Vim and then use the &lt;code&gt;:args&lt;/code&gt; command to populate the argument list. You can pass in multiple filenames or even globs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;code&gt;:args **/*.rb&lt;/code&gt; will recursively search the current directory for ruby files. Notice that this is also like opening Vim with &lt;code&gt;vim **/*.rb&lt;/code&gt;. You can even use the shell's &lt;code&gt;find&lt;/code&gt; command to get a list of all files in the current directory by running: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args `find . -type f`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can view the current args list by running &lt;code&gt;:args&lt;/code&gt; by itself. If you want to add or delete files from the list, you can use the &lt;code&gt;:argadd&lt;/code&gt; or the &lt;code&gt;:argdelete&lt;/code&gt; commands respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you're happy with the list, now you can use Vim's powerful &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Aargdo&quot;&gt;&lt;code&gt;:argdo&lt;/code&gt;&lt;/a&gt; command which runs a command for every file in the argument list: &lt;code&gt;:argdo %s/search/replace/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some tips for searching (based on some of the comments):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use a word boundary if you wanted to search for &quot;foo&quot; but not &quot;foo_bar&quot;. Use the &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; constructs around the search pattern like so: &lt;code&gt;:argdo %s/\&amp;lt;search\&amp;gt;/foobar/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use a &lt;code&gt;/c&lt;/code&gt; search flag if you want Vim to ask for confirmation before replacing a search term.&lt;/li&gt;&#xA;&lt;li&gt;Use a &lt;code&gt;/e&lt;/code&gt; search flag if you want to skip the &quot;pattern not found&quot; errors.&lt;/li&gt;&#xA;&lt;li&gt;You can also choose to save the file after performing the search: &lt;code&gt;:argdo %s/search/replace/g | update&lt;/code&gt;. Here, &lt;code&gt;:update&lt;/code&gt; is used because it will only save the file if it has changed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;Open buffers&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you already have buffers open you want to do the search/replace on, you can use &lt;code&gt;:bufdo&lt;/code&gt;, which runs a command for every file in your buffer list (&lt;code&gt;:ls&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command is very similar to &lt;code&gt;:argdo&lt;/code&gt;:  &lt;code&gt;:bufdo %s/search/replace/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar to &lt;code&gt;:argdo&lt;/code&gt; and &lt;code&gt;:bufdo&lt;/code&gt;, there is &lt;code&gt;:windo&lt;/code&gt; and &lt;code&gt;:tabdo&lt;/code&gt; that act on windows and tabs respectively. They are less often used but still useful to know.&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="246" LastEditDate="2015-03-30T00:12:15.783" LastActivityDate="2015-03-30T00:12:15.783" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2778" PostTypeId="2" ParentId="2776" CreationDate="2015-03-29T14:51:33.300" Score="3" Body="&lt;p&gt;Although not a VIM solution, if you are using VI/VIM you might find it easier to use a CLI solution. To change all files in the current directory, use &lt;code&gt;perl&lt;/code&gt; as it was made for situations like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ perl -pi -e 's/foo/bar/g' *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need to do it in subdirectories too, I usually pair &lt;code&gt;perl&lt;/code&gt; with &lt;code&gt;find&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ find . -name '*' -print0 | xargs -0 perl -pi -e 's/foo/bar/g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The nice thing about this is that you can easily further refine the list to specific file types. For instance, to restrict to python files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ perl -pi -e 's/foo/bar/g' *.py&#xA;$ find . -name '*.py' -print0 | xargs -0 perl -pi -e 's/foo/bar/g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="989" LastActivityDate="2015-03-29T14:51:33.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2779" PostTypeId="1" AcceptedAnswerId="2805" CreationDate="2015-03-29T18:17:08.493" Score="9" ViewCount="4566" Body="&lt;h2&gt;What I want&lt;/h2&gt;&#xA;&lt;p&gt;To temporarily change the timeout value for certain key commands&lt;/p&gt;&#xA;&lt;h2&gt;Where I've looked&lt;/h2&gt;&#xA;&lt;p&gt;From &lt;code&gt;:help 'timeout'&lt;/code&gt; I have :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;The timeout only happens when the 'timeout' and 'ttimeout' options&#xA;tell so.  A useful setting would be &amp;gt;&#xA;    :set timeout timeoutlen=3000 ttimeoutlen=100&#xA;(time out on mapping after three seconds, time out on key codes after&#xA;a tenth of a second).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'm not sure how I would implement this in a key command though, or how to check the current setting of timeout.&lt;/p&gt;&#xA;&lt;p&gt;For example, I wanted to try and set &lt;code&gt;hh&lt;/code&gt; to go to the start of a line, but I wanted the timeout for that particular key command to be pretty quick, say 100 milliseconds.&lt;/p&gt;&#xA;&lt;h2&gt;What I've tried&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set timeout timeoutlen=100 ttimeoutlen=100&#xA;nmap hh &amp;lt;S-^&amp;gt;&#xA;:set timeoutlen=1000 ttimeoutlen=1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1443" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-04-01T07:17:09.297" Title="How to change the value of timeout for one key command?" Tags="|vimrc|key-bindings|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2780" PostTypeId="2" ParentId="2775" CreationDate="2015-03-29T19:53:17.640" Score="4" Body="&lt;p&gt;You probably use the &lt;code&gt;:autocmd&lt;/code&gt; from &lt;code&gt;:help line()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) | exe &quot;normal! g`\&quot;&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just drop the first branch of the conditional (&lt;code&gt;line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp;&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-29T19:53:17.640" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2781" PostTypeId="1" AcceptedAnswerId="3077" CreationDate="2015-03-30T00:19:45.263" Score="10" ViewCount="835" Body="&lt;p&gt;I'm working on fairly large php codebase (~1.3 mil lines of code). I have generated tags and now when I'm typing something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$data-&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;YouCompleteMe lags really hard and basically freezes Vim when trying to fetch list of all possible completions from tags. Is there a way to fix this? For example by limiting number of suggestions, e.g. displaying only 10 top suggestions instead of loading whole list.&lt;/p&gt;&#xA;" OwnerUserId="428" LastEditorUserId="246" LastEditDate="2015-03-30T01:35:04.423" LastActivityDate="2015-04-26T01:46:30.223" Title="How can I limit number of suggestions when using YouCompleteMe?" Tags="|autocompletion|plugin-you-complete-me|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2782" PostTypeId="1" AcceptedAnswerId="2783" CreationDate="2015-03-30T00:25:15.690" Score="25" ViewCount="27105" Body="&lt;p&gt;What files do I need to create? What should be inside these files? Is there a default colorscheme file somewhere that I can use and change color values accordingly?&lt;/p&gt;&#xA;" OwnerUserId="428" LastActivityDate="2021-02-09T16:11:09.087" Title="How can I create my own colorscheme?" Tags="|colorscheme|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2783" PostTypeId="2" ParentId="2782" CreationDate="2015-03-30T01:22:20.463" Score="20" Body="&lt;h3&gt;Colorscheme locations&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;First, Vim looks in its runtime folders for a &lt;code&gt;colors&lt;/code&gt; directory. Here is where all the colorschemes should be stored (&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27runtimepath%27&quot;&gt;&lt;code&gt;:help 'runtimepath'&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means you will need one file that lives in the &lt;code&gt;~/.vim/colors&lt;/code&gt; folder. Default colorschemes are located in &lt;code&gt;$VIMRUNTIME/colors&lt;/code&gt;, where &lt;code&gt;$VIMRUNTIME&lt;/code&gt; is usually &lt;code&gt;/usr/share/vim/vim74&lt;/code&gt; or the &lt;code&gt;/usr/local/share/vim/vim74&lt;/code&gt; directories, depending on how Vim is installed (substitute vim74 for vim73 for Vim version 7.3)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to get to the fun part.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Creating a colorscheme&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;To get started with creating your own colorscheme, I highly suggest taking a look at the default colorschemes and experiment with modifying them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So copy the default colorscheme from &lt;code&gt;$VIMRUNTIME/colors&lt;/code&gt; folder to your &lt;code&gt;~/.vim/colors&lt;/code&gt; folder. Name it something that distinguishes itself from the default colorscheme name. So if you copied the &lt;code&gt;desert&lt;/code&gt; colorscheme that comes with Vim by default, name the file as &lt;code&gt;default_mod.vim&lt;/code&gt; or something to that effect. Open up the colorscheme file and change the &lt;code&gt;let g:colors_name&lt;/code&gt; to also distinguish itself from the default colorscheme file. By convention, this should be the same as the colorscheme file name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the colorscheme, all you have to do is give the colors for &lt;code&gt;ctermbg&lt;/code&gt;, &lt;code&gt;ctermfg&lt;/code&gt;, &lt;code&gt;guibg&lt;/code&gt;, &lt;code&gt;guifg&lt;/code&gt; (for terminal background, terminal foreground, gui background, gui foreground colors respectively) for the different built in highlight groups. To check out the list of highlight groups you can modify, check out &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#highlight-default&quot;&gt;&lt;code&gt;:help highlight-default&lt;/code&gt;&lt;/a&gt;. Optionally, you can also use the &lt;code&gt;cterm&lt;/code&gt; and &lt;code&gt;gui&lt;/code&gt; attributes to specify that you want a highlight group to be bold or italic. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, this will set a green color for a String:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight String ctermbg=NONE ctermfg=107 guibg=NONE guifg=#95B47B&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use highlight links to link a highlight group to another group. This is useful if you want two highlight groups to be the same colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, you could link the &lt;code&gt;diffAdded&lt;/code&gt; highlight group to the String highlight group defined above:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;highlight link diffAdded String&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="15" LastEditDate="2015-03-30T04:11:35.137" LastActivityDate="2015-03-30T04:11:35.137" CommentCount="4" CommunityOwnedDate="2015-03-30T01:22:20.463" ContentLicense="CC BY-SA 3.0" />
  <row Id="2784" PostTypeId="1" AcceptedAnswerId="2786" CreationDate="2015-03-30T04:39:00.330" Score="5" ViewCount="9267" Body="&lt;p&gt;I have a &lt;code&gt;README.txt&lt;/code&gt; file as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This document is a list of&#xA;a) Known issues in the services or test environment, i.e. things expected to fail&#xA;b) Things to be improved in the test suite&#xA;c) Possible bugs to be followed up&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I add anything to line 2, gVim automagically wraps it as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a) Known issues in the services or test environment, i.e. things expected to&#xA;fail blahblah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is super annoying. &#xA;I am running gVim on Windows, with the plugins &quot;solarized&quot; and &quot;airline&quot;. I have tried to tame this behaviour with the following in my &lt;code&gt;vimrc&lt;/code&gt;: (to no avail)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nowrap              &quot; don't wrap by default&#xA;set tw=0                &quot; don't jump to newline after col 80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It only seems to happen with a &lt;code&gt;.txt&lt;/code&gt; file, others are OK.&lt;/p&gt;&#xA;" OwnerUserId="398" LastActivityDate="2016-10-10T09:47:24.413" Title="How to stop gVim wrapping text at column 80" Tags="|gvim|split|wrapping|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2785" PostTypeId="2" ParentId="2782" CreationDate="2015-03-30T04:41:10.637" Score="9" Body="&lt;p&gt;Check out sites like &lt;a href=&quot;http://bytefluent.com/vivify/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vivify&lt;/a&gt;. They basically let you graphically create or tweak a scheme and then download the necessary files.&lt;/p&gt;&#xA;" OwnerUserId="19" LastEditorUserId="21251" LastEditDate="2020-04-03T15:07:10.937" LastActivityDate="2020-04-03T15:07:10.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2786" PostTypeId="2" ParentId="2784" CreationDate="2015-03-30T06:34:14.833" Score="8" Body="&lt;p&gt;Try turning off automatic formatting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set formatoptions=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this works, you're going to want to try to track down how it's having an effect. There are two possibilities. Either you have &lt;code&gt;'wrapmargin'&lt;/code&gt; set (which causes Vim to insert newlines when you get within a certain distance of the edge of the window), or something is setting &lt;code&gt;'textwidth'&lt;/code&gt; after your &lt;code&gt;.vimrc&lt;/code&gt; has been read. Use &lt;code&gt;:verbose set wrapmargin?&lt;/code&gt; and &lt;code&gt;:verbose set textwidth?&lt;/code&gt; to find out their values and what set them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also possible that something is overriding your &lt;code&gt;'wrap'&lt;/code&gt; setting, causing the lines to &lt;em&gt;display&lt;/em&gt; on several screen-lines, but you'd probably know if this were the case, because the wrapping would occur at the end of the window. Using the &lt;code&gt;'ruler'&lt;/code&gt; or &lt;code&gt;'showbreak'&lt;/code&gt; settings make this sort of wrapping easier to see.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;UPDATE:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;It turns out that the &lt;code&gt;textwidth&lt;/code&gt; was set by an autocommand created in a file &lt;code&gt;vimrc_example.vim&lt;/code&gt; in the Vim installation, which was being loaded at startup by the line &lt;code&gt;source $VIMRUNTIME/vimrc_example.vim&lt;/code&gt; in the OP's &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other answerers have suggested editing the example file, or overriding the autocommand with further autocommands, but a cleaner solution would be to edit your .vimrc &lt;em&gt;not&lt;/em&gt; to source the example file. If the example contains some settings you &lt;em&gt;do&lt;/em&gt; want, these can be copied into your own .vimrc.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-10-10T09:47:24.413" LastActivityDate="2016-10-10T09:47:24.413" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2789" PostTypeId="1" CreationDate="2015-03-30T15:34:23.913" Score="4" ViewCount="277" Body="&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; contains&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set hidden&#xA;set shortmess=fotx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I start Vim 7.3 with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim a b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I modify &lt;code&gt;a&lt;/code&gt; (optional), then I save it and switch to the next file with &lt;code&gt;:wn&lt;/code&gt;. Then I use &lt;code&gt;:prev&lt;/code&gt; to return to the previous file. I modify the file some more (optional) and again run &lt;code&gt;:wn&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first time I ran &lt;code&gt;:wn&lt;/code&gt;, I switched instantly to the next buffer, thanks to &lt;code&gt;shortmess=o&lt;/code&gt;. But the second time, I had a two-line prompt and needed to press &lt;kbd&gt;Enter&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;a&quot; 1854 lines, 56709 characters written&#xA;&quot;b&quot; 1854 lines --0%-- (2 of 2)&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's something going on that I don't understand with the &lt;code&gt;hidden&lt;/code&gt; option. When I start Vim, the status line shows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;a&quot; 1854 lines, 56709 characters                              1,1           Top&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get a similar line after switching to &lt;code&gt;b&lt;/code&gt;. But after switching back to &lt;code&gt;a&lt;/code&gt; with &lt;code&gt;:prev&lt;/code&gt;, the status line is different:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;a&quot; 1854 lines --0%-- (1 of 2)                                1,1           Top&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I remove the &lt;code&gt;hidden&lt;/code&gt; option, I never see the &lt;code&gt;--0%--&lt;/code&gt; form of the status line, and the &lt;code&gt;shortmess=o&lt;/code&gt; option has the desired effect of not requiring a confirmation after &lt;code&gt;:wn&lt;/code&gt;. But I do want &lt;code&gt;set hidden&lt;/code&gt;, because I want to be able to switch buffers without saving.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is &lt;code&gt;set hidden&lt;/code&gt; changing the format of the status line? More importantly, why is it causing me to have to acknowledge a &lt;code&gt;:wn&lt;/code&gt; by pressing &lt;kbd&gt;Enter&lt;/kbd&gt; the second time, in spite of &lt;code&gt;set shortmess=fotx&lt;/code&gt; still being on? How do I get the benefits of both &lt;code&gt;hidden&lt;/code&gt; and &lt;code&gt;shortmess=o&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2015-04-26T21:39:28.590" Title="Strange interaction of set hidden, shortmess and the status line" Tags="|buffers|options|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2790" PostTypeId="1" AcceptedAnswerId="2815" CreationDate="2015-03-30T17:22:33.203" Score="2" ViewCount="2223" Body="&lt;p&gt;I work a bit on a lua project (not small, but most of the code is not my own), and I'd like to get tags working. Current ctags contains bug, which can be fixed by getting the latest code from svn apparently, but even without that bug, it's not very usefull to me, since it does not know about the structure of tables. To give an example, a file might contain&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;function table1:func1(arg1,arg2)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and then I have a call&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;table1:func1(a1,a2)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;somewhere in my code. When the cursor is on &lt;code&gt;table1:func1&lt;/code&gt;, &lt;kbd&gt;Ctrl-]&lt;/kbd&gt; should take me to the first mentioned file (assuming it's uniqe or the first in the list), but actually it can't find the tag. Using &lt;code&gt;:ts /table1:func1&lt;/code&gt; kinda does the job, but isn't nice to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, long story short, does someone have a nice working setup for working with lua? How did you deal with the tag thing? I found some plugins that look kinda nice, but nothing seems to include a remedy to the tag problem.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="51" LastEditDate="2015-03-30T18:29:54.023" LastActivityDate="2015-04-03T15:13:21.290" Title="Vim, lua and ctags" Tags="|tags|ctags|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2791" PostTypeId="1" CreationDate="2015-03-31T01:50:26.697" Score="8" ViewCount="1894" Body="&lt;p&gt;I'm working on a plugin that allows users to create custom operators. The operators would apply a VimL expression to the motion or text object that the operator moves over.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Keeping a clean user interface&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I think the cleanest interface for defining the custom operators would be to use a command. I've defined a command &lt;code&gt;:MapExpress&lt;/code&gt; that would be invoked something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:MapExpress cd '/* ' . v:val . ' */'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would create a Normal mode operator and a Visual mode mapping for &lt;code&gt;cd&lt;/code&gt; that would surround the motion or selection in C-style comment delimiters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, here lies a problem. You can't call a command that's defined in a plugin from your &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Less-than-satisfying workarounds&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I've come up with a few workarounds that I'm not entirely happy with.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;User uses &lt;code&gt;autocmd VimEnter *&lt;/code&gt; to call the command&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;While this would work, it adds a lot of &quot;mental overhead&quot;. I would guess that a lot of Vim users don't have a solid grasp on how &lt;code&gt;autocmd&lt;/code&gt; works.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;User creates a file in &lt;code&gt;~/.vim/after/plugin/&lt;/code&gt; which calls the command&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Again, this would work, but it has the drawback that this piece of configuration is off in its own file, easily lost and forgotten.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;I move the command definitions into my plugin's &lt;code&gt;autoload/&lt;/code&gt; directory, and the user calls some method that triggers the file to be loaded, and thus the commands to be defined&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call express#init()&#xA;MapExpress cd '/* ' . v:val . ' */'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Slightly better, but this would cause confusion about whether the &lt;code&gt;express#init()&lt;/code&gt; method is necessary for the plugin to work at all.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Alternatives to using a command&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I also considered some alternatives to using a command to define the operator, but each has its caveats.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;User calls a function to define the operators&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This would look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call express#operator('cd', '&quot;/* &quot;.v:val.&quot; */&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not terrible, but it has the disadvantage of requiring a quoted expression. That can be annoying when you want to use quotes in your expression.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;User uses an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;expr&amp;gt; cd express#nmap('&quot;/* &quot;.v:val.&quot; */&quot;')&#xA;xmap &amp;lt;expr&amp;gt; cd express#xmap('&quot;/* &quot;.v:val.&quot; */&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has the same tedious quoted expression requirement, and also violates &lt;a href=&quot;http://en.wikipedia.org/wiki/Don%27t_repeat_yourself&quot;&gt;DRY&lt;/a&gt; unless you introduce a variable (not ideal).&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Okay, so what?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Here are all of my ideas and why I don't like any of them. Am I being too fussy? Is there some better solution I haven't thought of?&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="23502" LastEditDate="2022-11-01T19:51:29.313" LastActivityDate="2022-11-01T19:51:29.313" Title="How to design a command in a plugin that can be called from vimrc?" Tags="|vimscript|command-line|plugin-system|" AnswerCount="2" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2792" PostTypeId="1" AcceptedAnswerId="2793" CreationDate="2015-03-27T19:05:11.887" Score="8" ViewCount="1963" Body="&lt;p&gt;Can I share Vim command history across instances in real time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By that I mean what people do in bash this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export PROMPT_COMMAND=&quot;history -a; history -c; history -r; $PROMPT_COMMAND&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, when I run a command &lt;code&gt;echo test1&lt;/code&gt; in one shell, and then press &lt;kbd&gt;Up&lt;/kbd&gt; in another one, I see &lt;code&gt;echo test1&lt;/code&gt;. (To be precise, one has to press &lt;kbd&gt;Enter&lt;/kbd&gt; before &lt;kbd&gt;Up&lt;/kbd&gt; for it to work.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible with Vim? At first I thought using the &lt;code&gt;+clientserver&lt;/code&gt; option would work out. But that seems to be something else.&lt;/p&gt;&#xA;" OwnerUserId="1553" OwnerDisplayName="x-yuri" LastEditorUserId="23502" LastEditDate="2022-11-01T19:55:44.307" LastActivityDate="2022-11-01T19:55:44.307" Title="Is there a way to share Vim command history?" Tags="|command-history|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2793" PostTypeId="2" ParentId="2792" CreationDate="2015-03-27T19:41:43.530" Score="14" Body="&lt;p&gt;The command history is stored in the &lt;em&gt;viminfo&lt;/em&gt; file (&lt;code&gt;:help viminfo&lt;/code&gt;). Usually that is read on startup and written on exit, but you could explicitly persist and sync between Vim instances with a combination of &lt;code&gt;:wviminfo&lt;/code&gt; and &lt;code&gt;:rviminfo&lt;/code&gt;. Note that this will sync the entire information; i.e. also register contents, marks, buffer lists, etc.&lt;/p&gt;&#xA;" OwnerUserId="970" OwnerDisplayName="Ingo Karkat" LastActivityDate="2015-03-27T19:41:43.530" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2794" PostTypeId="2" ParentId="2791" CreationDate="2015-03-31T06:50:45.253" Score="5" Body="&lt;p&gt;It seems to me you are looking for &lt;code&gt;:runtime&lt;/code&gt;. You can perfectly run commands defined in plugins from your .vimrc, but you have to know the plugin name (that defines it) before that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; 1- Prepare the plugin-suite if it's managed through VAM/Vundle/NeoBundle/...&#xA;ActivateAddons FooBar&#xA;&#xA;&quot; 2- Be sure the plugin is loaded&#xA;runtime plugin/foobar.vim&#xA;&#xA;&quot; 3- And finally run (defensively) the command&#xA;if !exists(':FooBar')&#xA;   echo &quot;Sorry some initializations will be ignored as foobar is nowhere to be found&quot;&#xA;else&#xA;   FooBar abc&#xA;   FooBar 135468&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: unlike the autoload solution, this approach won't crash .vimrc sourcing. If an autoload plugin cannot be found (through the execution of a function), vim throws an error. &lt;code&gt;:runtime&lt;/code&gt; stays silent if no plugin can be loaded.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2015-03-31T06:50:45.253" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2795" PostTypeId="2" ParentId="2791" CreationDate="2015-03-31T07:30:39.820" Score="2" Body="&lt;p&gt;A list would IMO be the easiest solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:pluginname_my_operators = [&#xA;    ['cd', '/* ' . v:val . ' */'],&#xA;    ['cm', '&amp;lt;em&amp;gt;' . v:val . '&amp;lt;/em&amp;gt;']&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check for &lt;code&gt;g:pluginname_my_operators&lt;/code&gt; when you initialize your plugin and run &lt;code&gt;:MapExpress&lt;/code&gt; on each item if applicable while still allowing your users to use the command for on-the-fly definition.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-03-31T07:30:39.820" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2796" PostTypeId="1" AcceptedAnswerId="2799" CreationDate="2015-03-31T10:01:58.240" Score="13" ViewCount="3764" Body="&lt;p&gt;assume I have following texts:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;aaa-dd-e: &quot;aaa&quot;,&lt;br&gt;&#xA;bb-x: &quot;bb&quot;,&lt;br&gt;&#xA;c-9: &quot;c&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to do selection like below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;aaa-dd-e:&lt;/code&gt; &quot;aaa&quot;,&lt;br&gt;&#xA;&lt;code&gt;bb-x:&lt;/code&gt; &quot;bb&quot;,&lt;br&gt;&#xA;&lt;code&gt;c-9:&lt;/code&gt; &quot;c&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using c-v to create a visual block, but after I create selection on the first column and I press &quot;f:&quot;( I meant to expand the selection to colon mark on every line like above), what I get is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;aaa-&lt;/code&gt;dd-e: &quot;aaa&quot;,&lt;br&gt;&#xA;&lt;code&gt;bb-x&lt;/code&gt;: &quot;bb&quot;,&lt;br&gt;&#xA;&lt;code&gt;c-9:&lt;/code&gt; &quot;c&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the selection stops at the first colon and creates a rectangle.&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="64" LastEditDate="2015-03-31T13:01:12.377" LastActivityDate="2018-12-15T09:53:13.487" Title="How to achieve selection different length of texts on different lines?" Tags="|visual-mode|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2797" PostTypeId="2" ParentId="2115" CreationDate="2015-03-31T10:10:07.647" Score="4" Body="&lt;p&gt;I have the following, which stops and beeps when undo reaches the persisted buffer contents.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime autoload/repeat.vim &quot; Must load the plugin now so that the plugin's mappings can be overridden.&#xA;let s:undoPosition = []&#xA;function! s:StopAtSavedPosition( action )&#xA;    &quot; Buffers of type &quot;nofile&quot; and &quot;nowrite&quot; never are 'modified', so only do&#xA;    &quot; the check for normal buffers representing files. (Otherwise, the warning&#xA;    &quot; annoyingly happens on every undo.)&#xA;    if ingo#buffer#IsPersisted() &amp;amp;&amp;amp; ! &amp;amp;l:modified &amp;amp;&amp;amp; s:undoPosition != ingo#record#PositionAndLocation(1)&#xA;        &quot; We've reached the undo position where the buffer contents correspond&#xA;        &quot; to the persisted file. Stop and beep, and only continue when undo is&#xA;        &quot; pressed again at the same position.&#xA;        call ingo#msg#WarningMsg(a:action . ' reached saved buffer state')&#xA;        execute &quot;normal! \&amp;lt;C-\&amp;gt;\&amp;lt;C-n&amp;gt;\&amp;lt;Esc&amp;gt;&quot; | &quot; Beep.&#xA;&#xA;        let s:undoPosition = ingo#record#PositionAndLocation(1)&#xA;        return 1&#xA;    else&#xA;        let s:undoPosition = []&#xA;        return 0&#xA;    endif&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; u     :&amp;lt;C-U&amp;gt;if ! &amp;amp;l:modifiable&amp;lt;Bar&amp;gt;execute 'normal! u'&amp;lt;Bar&amp;gt;elseif ! &amp;lt;SID&amp;gt;StopAtSavedPosition('Undo')&amp;lt;Bar&amp;gt;call repeat#wrap('u',v:count)&amp;lt;Bar&amp;gt;endif&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-R&amp;gt; :&amp;lt;C-U&amp;gt;if ! &amp;amp;l:modifiable&amp;lt;Bar&amp;gt;execute &quot;normal! \&amp;lt;lt&amp;gt;C-R&amp;gt;&quot;&amp;lt;Bar&amp;gt;elseif ! &amp;lt;SID&amp;gt;StopAtSavedPosition('Redo')&amp;lt;Bar&amp;gt;call repeat#wrap(&quot;\&amp;lt;Lt&amp;gt;C-R&amp;gt;&quot;,v:count)&amp;lt;Bar&amp;gt;endif&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This integrates with the repeat.vim plugin; it requires my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4433&quot; rel=&quot;nofollow&quot;&gt;ingo-library plugin&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-31T10:10:07.647" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2798" PostTypeId="2" ParentId="2796" CreationDate="2015-03-31T10:40:35.223" Score="15" Body="&lt;p&gt;Vim only supports rectangular blockwise selections, with the exception of the jagged right border when you press &lt;code&gt;$&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are plugins (like &lt;a href=&quot;https://github.com/terryma/vim-multiple-cursors&quot;&gt;vim multiple cursors&lt;/a&gt;) that can emulate multiple selections, but you should also be able to achieve your actual goal (which you unfortunately didn't mention) with pure Vim commands, for example &lt;code&gt;:global&lt;/code&gt; and &lt;code&gt;:substitute&lt;/code&gt; (if you can formulate a regular expression that matches the selection in each line), or by repeating macros (if there's a particular motion that covers the selection in each line).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-03-31T10:40:35.223" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2799" PostTypeId="2" ParentId="2796" CreationDate="2015-03-31T11:12:36.850" Score="7" Body="&lt;p&gt;Selection is generally a mean to an end, more so in Vim where selection is often not necessary in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you still want to put quotes around property names in your non-JSON file to turn it into proper JSON:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;select the lines to modify, character-wise or line-wise, it doesn't matter,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;norm I&quot;^[f:i&quot;&lt;/code&gt; (&lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; is automatically inserted for you and &lt;code&gt;^[&lt;/code&gt; is obtained with &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you have the beautiful surround plugin, step 2 becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;norm ^vt:S&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With a substitution, step 2 could become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/^\s*\([^:]*\):/&quot;\1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-03-31T11:18:13.683" LastActivityDate="2015-03-31T11:18:13.683" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2801" PostTypeId="1" AcceptedAnswerId="2980" CreationDate="2015-03-31T13:13:26.160" Score="24" ViewCount="3768" Body="&lt;p&gt;By default, if a buffer in vim contains a URL such as &lt;code&gt;http://www.google.com&lt;/code&gt;, &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt; in normal mode will open a browser with that URL. That's very handy. However, if the URL has URL parameters (e.g. &lt;code&gt;http://www.google.com/search?q=stuff&lt;/code&gt;), then the URL parameters are missed out (i.e. just &lt;code&gt;http://www.google.com/search&lt;/code&gt; is opened).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using MacVim 7.4 patch 183, with Chrome as the primary browser (on OS X 10.9).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an easy way, ideally with minimal customization, to make &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt; recognise a full URL?&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="51" LastEditDate="2015-03-31T13:30:22.030" LastActivityDate="2020-08-29T20:23:38.493" Title="How can I make gx recognise full URLs in vim?" Tags="|external-command|netrw|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="2802" PostTypeId="2" ParentId="2796" CreationDate="2015-03-31T15:50:14.640" Score="1" Body="&lt;p&gt;Just to throw another hat into the ring, if you really want to use visual selection you can use the &lt;a href=&quot;https://github.com/godlygeek/tabular&quot; rel=&quot;nofollow&quot; title=&quot;Tabular&quot;&gt;Tabular&lt;/a&gt; plugin to line up the colons, then make your visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you take your original text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaa-dd-e: &quot;aaa&quot;,&#xA;bb-x: &quot;bb&quot;,&#xA;c-9: &quot;c&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:Tab /:\zs&lt;/code&gt; will align everything after the colon, as below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaa-dd-e:  &quot;aaa&quot;,&#xA;bb-x:      &quot;bb&quot;,&#xA;c-9:       &quot;c&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then you can make your visual block selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As others have said, though, visual selection is probably not necessary in this situation. Using &lt;code&gt;norm&lt;/code&gt; or substitution can probably accomplish what you want without fussing with visual selections.&lt;/p&gt;&#xA;" OwnerUserId="1155" LastActivityDate="2015-03-31T15:50:14.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2803" PostTypeId="1" CreationDate="2015-03-31T19:05:49.413" Score="1" ViewCount="894" Body="&lt;p&gt;Why vim keep printing strange characters when I hit non-characters key?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Insert&lt;/kbd&gt; prints &lt;code&gt;[2~&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Delete&lt;/kbd&gt; prints &lt;code&gt;[3~&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Page Up&lt;/kbd&gt; prints &lt;code&gt;[5~&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Page Down&lt;/kbd&gt; prints &lt;code&gt;[6~&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Home&lt;/kbd&gt; prints &lt;code&gt;OH&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;End&lt;/kbd&gt; prints &lt;code&gt;OF&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Arrow Up&lt;/kbd&gt; prints &lt;code&gt;OA&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Arrow Down&lt;/kbd&gt; prints &lt;code&gt;OB&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Arrow Right&lt;/kbd&gt; prints &lt;code&gt;OC&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Arrow Left&lt;/kbd&gt; prints &lt;code&gt;OD&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="1526" LastEditorUserId="51" LastEditDate="2015-03-31T19:24:03.837" LastActivityDate="2015-04-01T11:11:37.263" Title="Vim printing strange characters when hit &quot;home&quot;, &quot;end&quot; stc" Tags="|key-bindings|terminal|keyboard-layout|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="2804" PostTypeId="1" AcceptedAnswerId="2813" CreationDate="2015-04-01T00:35:24.623" Score="4" ViewCount="468" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/terryma/vim-multiple-cursors&quot; rel=&quot;noreferrer&quot;&gt;multiple cursors&lt;/a&gt; plugin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to do the same thing as the second example in their github page.&#xA;Just trying to add double quote around each of the weekday:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mon&#xA;tue&#xA;wed&#xA;thu&#xA;fri&#xA;sat&#xA;sun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can add one double quote at the beginning of each line by creating a visual block with c-v and press &quot;ctrl-n&quot; to enter multiple cursors. But when I press &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; to escape insertion mode, I lost all the cursors. Then I have to do all over again just to resume the multiple cursors and append a double quote on each line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some easy way to do that? Am I doing it stupidly? Why in the example, the screenshot shows the cursors are not lost?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastActivityDate="2015-04-02T15:13:30.857" Title="How to resume previous multiple cursors?" Tags="|cursor-movement|visual-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2805" PostTypeId="2" ParentId="2779" CreationDate="2015-04-01T07:17:09.297" Score="2" Body="&lt;p&gt;The &lt;code&gt;'timeoutlen'&lt;/code&gt; option is a global one, and it applies at mapping &lt;em&gt;invocation&lt;/em&gt;, not during &lt;em&gt;definition&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can understand your motivation (using a special &lt;code&gt;hh&lt;/code&gt; mapping while still being able to quickly move via &lt;code&gt;h&lt;/code&gt;, &lt;code&gt;h&lt;/code&gt;), but I would nonetheless advise against such tricks. Better choose another mapping that doesn't overlap with a built-in command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really must, have a look at the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2425&quot; rel=&quot;nofollow&quot;&gt;arpeggio plugin&lt;/a&gt;. It performs some tricks to map simultaneously pressed keys.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-01T07:17:09.297" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2806" PostTypeId="1" CreationDate="2015-04-01T11:02:35.913" Score="0" ViewCount="1898" Body="&lt;p&gt;I want to enable html snippets for php files. The Ultisnips manual said what I need to do is put &lt;code&gt;extends html&lt;/code&gt; command at the beginning of the &lt;code&gt;php.snippets&lt;/code&gt; file. But it doesn't work. HTML snippets still aren't showing up. How do I extend it properly?&lt;/p&gt;&#xA;" OwnerUserId="1526" LastEditorUserId="865" LastEditDate="2015-06-27T17:41:12.873" LastActivityDate="2017-08-28T08:58:21.693" Title="How to extends php.snippets to html in Ultisnips?" Tags="|plugin-ultisnips|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2807" PostTypeId="2" ParentId="2803" CreationDate="2015-04-01T11:11:37.263" Score="3" Body="&lt;p&gt;According to Terminator's &lt;a href=&quot;https://code.google.com/p/jessies/wiki/TerminatorFAQ&quot; rel=&quot;nofollow&quot;&gt;FAQ&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You should set &lt;code&gt;TERM = terminator&lt;/code&gt; because it uses a non-conventional terminfo file.&lt;/li&gt;&#xA;&lt;li&gt;You should guarantee that you don't have vim-minimal (or similar) package, because it might not include support for terminfo.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="599" LastActivityDate="2015-04-01T11:11:37.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2808" PostTypeId="1" CreationDate="2015-04-01T13:22:35.647" Score="1" ViewCount="320" Body="&lt;h2&gt;Environment&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ubuntu 14.04&lt;/li&gt;&#xA;&lt;li&gt;Vim 7&lt;/li&gt;&#xA;&lt;li&gt;Tmux&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm just trying to create some snippets for UltiSnips and writing bib files. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What I want&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To create custom snippets that will make writing bib files (that I can't download) a bit more straightforward from Vim. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What I've tried&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have opened a .bib file, and then run &lt;code&gt;:UltiSnipsEdit&lt;/code&gt; from within Vim. I created a new snip named &lt;code&gt;online&lt;/code&gt; and copied the following into it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@online{$1,&#xA;    author = {},&#xA;    title = {},&#xA;    year = ,&#xA;    url = {},&#xA;    urldate = {}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The snippet looks like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet online &quot;Cite from website&quot; &#xA;@online{$1,&#xA;    author = {},&#xA;    title = {},&#xA;    year = ,&#xA;    url = {},&#xA;    urldate = {}&#xA;}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then when I reopen [1] my &lt;code&gt;.bib&lt;/code&gt; file and type &lt;code&gt;online&lt;/code&gt; I don't get any prompt for this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I type &lt;code&gt;@online{onli&lt;/code&gt; I will get the prompt appear that I created. However when I try to select this prompt using my assigned key command [2] nothing actually happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some steps that don't work for me : &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Open new file with &lt;code&gt;vim h.bib&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:UltiSnipsEdit&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create the following snip :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet mouse &quot;Description&quot;&#xA;something something snippet&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Return to &lt;code&gt;h.bib&lt;/code&gt; (thats still open from the split)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Enter insert mode&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;mous&lt;/code&gt; expecting prompt - no prompt&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;@x{mou&lt;/code&gt; -&gt; prompt appears&lt;/li&gt;&#xA;&lt;li&gt;Tab to the prompt (mouse) and then enter the command for completion&#xA;(&lt;code&gt;&amp;lt;leader&amp;gt;df&lt;/code&gt; or &lt;code&gt;,df&lt;/code&gt;) - this doesn't do anything.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;What's going wrong&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The first error (that nothing appears) seems to be related to bib files being in comment mode by default. I'm not sure whether UltiSnips can work inside comments? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure why it's not autocompleting when the prompt does appear though. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps a vim function or something would be more appropriate, I've never written one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Edit&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I've tried using this outside of tmux (default terminal) and muting YouCompleteme, neither of which have helped. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Footnotes&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;[1] I know this isn't meant to be needed, I just thought I'd try it anyway. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;[2] the key that I have assigned for UltiSnips is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;Leader&amp;gt;df&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as YouCompleteMe is using the &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1443" LastEditorUserId="51" LastEditDate="2016-03-14T05:58:09.003" LastActivityDate="2016-03-14T05:58:09.003" Title="Problem using LaTex .bib file with UltiSnips completion" Tags="|autocompletion|filetype-tex|plugin-ultisnips|" AnswerCount="0" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2809" PostTypeId="1" AcceptedAnswerId="2810" CreationDate="2015-04-01T19:54:39.107" Score="10" ViewCount="1642" Body="&lt;p&gt;When I used &lt;code&gt;:silent&lt;/code&gt; to run a terminal command in the background, my vim screen goes blank, until I navigate through my code, at which point each line I move to reappears. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What gives?&lt;/p&gt;&#xA;" OwnerUserId="1596" LastEditorUserId="51" LastEditDate="2015-04-01T21:42:48.193" LastActivityDate="2023-02-05T07:51:18.323" Title=":silent makes my vim go blank" Tags="|command-line|external-command|terminal|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2810" PostTypeId="2" ParentId="2809" CreationDate="2015-04-01T20:04:15.867" Score="10" Body="&lt;p&gt;This works as designed, and is documented under &lt;code&gt;:help :silent&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;      &quot;:silent&quot; will also avoid the hit-enter prompt.  When&#xA;      using this for an external command, this may cause the&#xA;      screen to be messed up.  Use |CTRL-L| to clean it up&#xA;      then.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can also use the &lt;code&gt;:redraw&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-01T20:04:15.867" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2811" PostTypeId="1" AcceptedAnswerId="2812" CreationDate="2015-04-02T02:43:57.567" Score="11" ViewCount="2861" Body="&lt;p&gt;I often want a new empty vertical pane (vim window / viewport ...) in my current Vim tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can get a new empty horizontal pane by doing &lt;code&gt;control+w n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can split the current pane into two identical vertical copies with &lt;code&gt;control+w v&lt;/code&gt;, but then I always resort to the awkward workaround of opening a new empty horizontal pane within this vertical pane and then closing the duplicate view of the original pane which I didn't want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a built in way to just get a blank vertical pane?&lt;/p&gt;&#xA;" OwnerUserId="878" LastActivityDate="2021-07-15T13:43:10.197" Title="Vertical equivalent of &quot;control+w n&quot;?" Tags="|split|vim-windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2812" PostTypeId="2" ParentId="2811" CreationDate="2015-04-02T03:16:34.143" Score="18" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Avnew&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help vnew&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    Like |:new|, but split vertically.  If 'equalalways' is set&#xA;    and 'eadirection' isn't &amp;quot;ver&amp;quot; the windows will be spread out&#xA;    horizontally, unless a width was specified.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, it seems like Vim does not provide a mapping for &lt;code&gt;:vnew&lt;/code&gt; which creates a new &lt;em&gt;blank&lt;/em&gt; vertical split. It's easy to create this mapping yourself. For instance:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;v :vnew&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="246" LastEditorUserId="30266" LastEditDate="2021-07-15T13:43:10.197" LastActivityDate="2021-07-15T13:43:10.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2813" PostTypeId="2" ParentId="2804" CreationDate="2015-04-02T15:13:30.857" Score="6" Body="&lt;p&gt;Try adding the following to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:multi_cursor_exit_from_insert_mode = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;From &lt;code&gt;:help multiple-cursors-global-options&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;g:multi_cursor_exit_from_insert_mode&lt;/em&gt; (Default: 1)&lt;/p&gt;&#xA;&lt;p&gt;If set to 0, then pressing |g:multi_cursor_quit_key| in Insert mode will not quit and delete all existing cursors. This is useful if you want to press Escape and go back to Normal mode, and still be able to operate on all the&#xA;cursors.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-04-02T15:13:30.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2814" PostTypeId="1" AcceptedAnswerId="14671" CreationDate="2015-04-02T21:40:27.947" Score="0" ViewCount="266" Body="&lt;p&gt;I'm having some trouble getting the &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;C-G&lt;/kbd&gt; command in normal mode to yank the current commit SHA. Currently it only yanks the file name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h fugitive&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[&quot;x]y&amp;lt;C-G&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; Yank the commit SHA and path to the current object.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've tried running &lt;code&gt;:Gedit&lt;/code&gt; after which &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;C-G&lt;/kbd&gt; yanks &lt;code&gt;:0:file-name.ext&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm confused. Am I using this keyboard shortcut correctly, or is there a bug?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It exhibits the same behavior in both gui mode and text mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the most recent version of &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow&quot;&gt;vim-fugitive&lt;/a&gt; (as of 2015-04-02).&lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2017-12-28T19:34:46.920" Title="y&lt;C-G&gt; not yanking commit SHA in fugitive?" Tags="|key-bindings|git|plugin-fugitive|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2815" PostTypeId="2" ParentId="2790" CreationDate="2015-04-03T01:09:39.430" Score="6" Body="&lt;p&gt;&lt;code&gt;&amp;lt;c-]&amp;gt;&lt;/code&gt; only looks at the keyword under the cursor. Normally &lt;code&gt;:&lt;/code&gt; is not defined as a keyword character. To define &lt;code&gt;:&lt;/code&gt; as a keyword character you can put&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal iskeyword+=:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;~/.vim/ftplugin/lua.vim&lt;/code&gt; so that this happens automatically for lua files (and only for lua files)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Or if you just want to add something to your vimrc, you can add the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetype_lua&#xA;    autocmd!&#xA;    autocmd FileType lua setlocal iskeyword+=:&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This creates an autocmd that only activates on the lua filetype to set the &lt;code&gt;:&lt;/code&gt; as a keyword character. The &lt;code&gt;augroup&lt;/code&gt; command creates a autocmd group which stops the autocmd from being defined multiple times if you resource your vimrc.&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2015-04-03T15:13:21.290" LastActivityDate="2015-04-03T15:13:21.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2816" PostTypeId="1" AcceptedAnswerId="2919" CreationDate="2015-04-03T05:57:35.643" Score="5" ViewCount="1018" Body="&lt;p&gt;When I open a new split Vim is scrolling both buffers up despite having enough space.&lt;/p&gt;&#xA;&lt;p&gt;Here is an &lt;a href=&quot;https://asciinema.org/a/18333&quot; rel=&quot;nofollow noreferrer&quot;&gt;asciicast&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This behaviour comes out-of-the box in &lt;code&gt;vim -u NONE&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It is really annoying. My guess it tries to keep the cursor in the middle of the screen or something. But even if the both splits end up well above the middle line the buffers are being scrolled up.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to turn it off?&lt;/p&gt;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="23502" LastEditDate="2022-11-01T19:47:19.140" LastActivityDate="2022-11-01T19:47:19.140" Title="How to prevent Vim from scrolling buffers when I open split?" Tags="|split|scrolling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2817" PostTypeId="1" CreationDate="2015-04-03T10:30:29.247" Score="2" ViewCount="194" Body="&lt;p&gt;I like formating code this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class A&#xA;{&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;unlike another common way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class B {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The thing is, when using the &lt;code&gt;%&lt;/code&gt; command to go to the enclosing bracket, which is very useful for copying/deleting loops/functions, it doesn't work so well on the first case - it just doesn't work if my cursor is on the line without the brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to change this?&lt;/p&gt;&#xA;" OwnerUserId="342" LastEditorUserId="51" LastEditDate="2015-05-03T23:56:13.113" LastActivityDate="2015-05-03T23:56:13.113" Title="Using the % command on a line without a bracket" Tags="|cursor-movement|cursor-motions|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2818" PostTypeId="1" CreationDate="2015-04-03T10:43:50.230" Score="3" ViewCount="83" Body="&lt;p&gt;The &lt;code&gt;%&lt;/code&gt; command is quite nice, and I use it to copy/delete whole loops, functions and classes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In c++ though, you need to add a &lt;code&gt;;&lt;/code&gt; after your class declaration, so trying to motion over a whole class won't work with the &lt;code&gt;%&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get the command to carry on the motion? I guess just adding a &lt;code&gt;f;&lt;/code&gt; will be enough, but I'm not sure how.&lt;/p&gt;&#xA;" OwnerUserId="342" LastEditorUserId="51" LastEditDate="2015-04-03T10:53:12.873" LastActivityDate="2015-04-03T17:22:04.933" Title="Using the % command in c++" Tags="|cursor-movement|filetype-c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2820" PostTypeId="1" AcceptedAnswerId="2821" CreationDate="2015-04-03T13:44:56.593" Score="4" ViewCount="948" Body="&lt;p&gt;In hope of answering&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/2817/using-the-command-on-a-line-without-a-bracket&quot;&gt;Using the % command on a line without a bracket&lt;/a&gt;&#xA;I tried to write my first Vim script.&lt;/p&gt;&#xA;&lt;p&gt;My thought was to check if there was a &lt;code&gt;{&lt;/code&gt; on the current line. If there was one I wanted &lt;code&gt;%&lt;/code&gt; to behave as usual. If not &lt;code&gt;%&lt;/code&gt; would be called on the next line by doing &lt;code&gt;j%&lt;/code&gt;. This is what I wrote&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function Percent_nextline()&#xA;    let line = getline('.')&#xA;    if line =~ &amp;quot;{&amp;quot;&#xA;        normal %&#xA;    else&#xA;        normal j%&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap g% :call Percent_nextline()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then I tried it on this file&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;{&#xA;    { }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With the cursor on the first line typing &lt;code&gt;g%&lt;/code&gt; does indeed move the cursor to the last &lt;code&gt;}&lt;/code&gt;. Then I tried &lt;code&gt;dg%&lt;/code&gt;, meaning to delete all the block. This failed, and made the bell sound. The buffer was left unchanged.&lt;/p&gt;&#xA;&lt;p&gt;So I have two questions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;How could I make commands like &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt;, etc. work with this new mapping?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I want to use just &lt;code&gt;%&lt;/code&gt; rather than &lt;code&gt;g%&lt;/code&gt; how could I stop the function from recursing?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="356" LastEditorUserId="23502" LastEditDate="2022-11-01T19:44:28.727" LastActivityDate="2022-11-01T19:44:28.727" Title="How to make a movement function work with delete, yank, etc" Tags="|cursor-movement|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2821" PostTypeId="2" ParentId="2820" CreationDate="2015-04-03T17:16:06.387" Score="3" Body="&lt;p&gt;&lt;em&gt;how could I make commands like c, y, d, etc. work with this new mapping?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim, it's all in the &lt;em&gt;modes&lt;/em&gt;. The one after commands like &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, etc., where Vim is waiting for the &lt;code&gt;{motion}&lt;/code&gt;, is called &lt;em&gt;operator-pending mode&lt;/em&gt;. &lt;code&gt;:help omap-info&lt;/code&gt; explains that you can visually select the block to work upon. Likewise, you probably want to define a visual-mode mapping, too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap % :&amp;lt;C-u&amp;gt;call Percent_nextline()&amp;lt;cr&amp;gt;&#xA;:xnoremap % :&amp;lt;C-u&amp;gt;execute 'normal! gv'&amp;lt;Bar&amp;gt;call Percent_nextline()&amp;lt;cr&amp;gt;&#xA;:onoremap % :&amp;lt;C-u&amp;gt;execute 'normal! V'&amp;lt;Bar&amp;gt;call Percent_nextline()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; removes the range inserted in visual mode (and if you use a &lt;code&gt;[count]&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;the visual mode mapping first re-creates the existing selection with &lt;code&gt;gv&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;likewise, the &lt;code&gt;:omap&lt;/code&gt; goes into line-wise (I think this makes the most sense here) selection&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;if I want to use just % rather than g% how could I stop the function from recursing?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By using &lt;code&gt;:normal!&lt;/code&gt; (with &lt;code&gt;!&lt;/code&gt;), existing mappings are ignored. Like &lt;code&gt;:noremap&lt;/code&gt;, you should always use this, unless you explicitly need mappings to apply. Here, you only lose the functionality of the &lt;em&gt;matchit&lt;/em&gt; plugin (in case you have that installed), but for pure &lt;code&gt;{&lt;/code&gt;...&lt;code&gt;}&lt;/code&gt; matching, you don't need that. You might consider sticking to the &lt;code&gt;g%&lt;/code&gt; alternative mapping (or using a filetype-specific &lt;code&gt;:map &amp;lt;buffer&amp;gt; %&lt;/code&gt; only for C/C++).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Open issues&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When there's no matching &lt;code&gt;{&lt;/code&gt;...&lt;code&gt;}&lt;/code&gt;, your mappings go one line down, which I find irritating. I think you can fix that easily yourself.&lt;/li&gt;&#xA;&lt;li&gt;Drop the &lt;code&gt;:&lt;/code&gt; sigil; in a script, this isn't needed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-03T17:16:06.387" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2822" PostTypeId="2" ParentId="2818" CreationDate="2015-04-03T17:22:04.933" Score="5" Body="&lt;p&gt;You can force a motion to be linewise; then, the &lt;code&gt;%&lt;/code&gt; would include the full last line, including the trailing &lt;code&gt;;&lt;/code&gt;, for example &lt;code&gt;yV%&lt;/code&gt;. Unfortunately, if you use the &lt;em&gt;matchit&lt;/em&gt; plugin, that doesn't work any more, but you can instead use visual mode: &lt;code&gt;V%y&lt;/code&gt; (interestingly, this is the reverse of the above!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could define a custom motion for that.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-03T17:22:04.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2823" PostTypeId="2" ParentId="2817" CreationDate="2015-04-03T18:07:27.020" Score="5" Body="&lt;p&gt;I tried to figure if Vim had some option for this and I believe it doesn't. So I wrote a Vim script to do the job. Just add it to your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Percent_nextline()&#xA;    let line = getline('.')&#xA;    if line =~ &quot;{&quot;&#xA;        normal! %&#xA;    else&#xA;        let line = getline(line('.')+1)&#xA;        if line =~ &quot;{&quot;&#xA;            normal! j%&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap g% :&amp;lt;C-u&amp;gt;call Percent_nextline()&amp;lt;cr&amp;gt;&#xA;onoremap g% :&amp;lt;C-u&amp;gt;execute 'normal! V'&amp;lt;Bar&amp;gt;call Percent_nextline()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This script maps the behaviour you want to &lt;code&gt;g%&lt;/code&gt;. With the cursor on the line &lt;code&gt;class A&lt;/code&gt; you can type &lt;code&gt;g%&lt;/code&gt; and the cursor will jump to the closing curly bracket. It can be preceded with commands like &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I implemented this by simply checking if the current line contains a &lt;code&gt;{&lt;/code&gt;. If it does then the command behaves as &lt;code&gt;%&lt;/code&gt;. If it doesn't the following line is checked and if a &lt;code&gt;{&lt;/code&gt; is found the &lt;code&gt;%&lt;/code&gt; command is called upon that line. The &lt;code&gt;onoremap&lt;/code&gt; makes it possible to use the mapping in &lt;em&gt;operator-pending mode&lt;/em&gt;, which is used by &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sure this script could be improved. It is my first :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;I want to thank @IngoKarkat for helping me in &lt;a href=&quot;https://vi.stackexchange.com/questions/2820/how-to-make-a-movement-function-work-with-delete-yank-etc/&quot;&gt;How to make a movement function work with delete, yank, etc&lt;/a&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-04-03T18:19:03.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2824" PostTypeId="1" CreationDate="2015-04-03T18:14:28.473" Score="2" ViewCount="915" Body="&lt;p&gt;I wrote this little function to update my plugins from within vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! UpdatePlugins()&#xA;  call system('for f in ~/.vim/bundle/*; do cd $f; git pull; done')&#xA;endfunction&#xA;command! UpdatePlugins call UpdatePlugins()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get the output of this to be piped into a new buffer in real time? By real time, I mean this: If I were to run that system command in my shell, over the course of a few seconds each git pull would run and print lines to the standard output. I would like for those lines to be piped into a buffer as they are printed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can do this to open a new buffer with the results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! UpdatePlugins()&#xA;  let x = system('for f in ~/.vim/bundle/*; do cd $f; git pull; done')&#xA;  tabnew&#xA;  put=x&#xA;endfunction&#xA;command! UpdatePlugins call UpdatePlugins()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But waiting for the pulls to complete is less than ideal.&lt;/p&gt;&#xA;" OwnerDisplayName="user489" LastEditorUserId="24" LastEditDate="2015-04-05T13:34:50.137" LastActivityDate="2015-04-05T13:34:50.137" Title="Pipe shell command into buffer in real-time" Tags="|vimscript|external-command|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2825" PostTypeId="2" ParentId="2824" CreationDate="2015-04-03T19:08:31.960" Score="3" Body="&lt;p&gt;You could simply do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! UpdatePlugins :!for f in ~/.vim/bundle/*; do cd $f; git pull; done&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and see the output scroll in your shell.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-04-03T20:22:47.113" LastActivityDate="2015-04-03T20:22:47.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2826" PostTypeId="2" ParentId="2824" CreationDate="2015-04-03T19:20:16.450" Score="1" Body="&lt;p&gt;Your &lt;code&gt;UpdatePlugins()&lt;/code&gt; function could be this instead&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! UpdatePlugins()&#xA;    let x = system('for f in ~/.vim/bundle/*; do cd $f; git pull; done')&#xA;    call writefile(split(x, '\n'), 'vim_update_log.txt')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will write the output of &lt;code&gt;system()&lt;/code&gt; into &lt;code&gt;vim_update_log.txt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="356" LastActivityDate="2015-04-03T19:20:16.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2829" PostTypeId="1" AcceptedAnswerId="2832" CreationDate="2015-04-05T09:05:19.820" Score="1" ViewCount="145" Body="&lt;p&gt;I have a mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;expr&amp;gt; zj FindNext()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;FindNext&lt;/code&gt; will calculate which line to go, and return something like &lt;code&gt;10G&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works without a count, but with a count the line number becomes incorrect. For example, if the count is &lt;code&gt;2&lt;/code&gt;, &lt;code&gt;10G&lt;/code&gt; will become &lt;code&gt;210G&lt;/code&gt;. So I'm looking for a way to erase the count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is easy with &lt;code&gt;:&amp;lt;C-U&amp;gt;execute 'normal! ' . FindNext()&amp;lt;CR&amp;gt;&lt;/code&gt; mapping, but it doesn't work in visual mode.&lt;/p&gt;&#xA;" OwnerUserId="1272" LastEditorUserId="343" LastEditDate="2017-12-06T11:23:02.263" LastActivityDate="2017-12-06T11:23:02.263" Title="How can I clear normal mode command count in mappings?" Tags="|key-bindings|cursor-movement|count|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2830" PostTypeId="1" AcceptedAnswerId="2831" CreationDate="2015-04-05T13:29:34.320" Score="6" ViewCount="2943" Body="&lt;p&gt;I would like to reformat code in an entire file from this brace style:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (condition)&#xA;{&#xA;    body;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… into this brace style&lt;sup&gt;1&lt;/sup&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (condition) {&#xA;    body;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The bulk of the task should be accomplishable by relocating the opening braces.  I would like to do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^M *{$/ {/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… but substitutions don't seem to work across line breaks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make substitutions work across line breaks?  If not, what is the next-best solution that does not involve an external command or plugin?  (I'm more interested in text-editing technique than in specialized programming tools.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; No flame wars about the choice of brace style, please!&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-04-05T13:35:11.667" LastActivityDate="2015-04-05T14:28:55.477" Title="How to substitute text across line breaks?" Tags="|substitute|line-breaks|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2831" PostTypeId="2" ParentId="2830" CreationDate="2015-04-05T14:06:27.347" Score="10" Body="&lt;p&gt;You can use &lt;code&gt;\n&lt;/code&gt; to do substitutions across multiple lines.  There are also special characters which start with &lt;code&gt;\_&lt;/code&gt; that are the same as their normal counterparts, except it adds newline to their character class.  For instance, &lt;code&gt;\_s&lt;/code&gt; is the same as &lt;code&gt;\s&lt;/code&gt;, except it also matches newline characters.  Here is your search and replace statement with this special character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\n *{$/ {/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, you can make the regex more specific, since this one may match more than you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Search_across_multiple_lines&quot;&gt;http://vim.wikia.com/wiki/Search_across_multiple_lines&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \_&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-04-05T14:28:55.477" LastActivityDate="2015-04-05T14:28:55.477" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2832" PostTypeId="2" ParentId="2829" CreationDate="2015-04-05T22:44:03.623" Score="1" Body="&lt;p&gt;I think you can make it work in Visual mode by using Normal mode but re-creating the visual selection first with the &lt;code&gt;gv&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:&amp;lt;C-u&amp;gt;execute 'normal! gv' . FindNext()&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then use the mapping specific to Visual and Select modes (&lt;code&gt;:vnoremap&lt;/code&gt;&#xA;, &lt;code&gt;:xnoremap&lt;/code&gt;, &lt;code&gt;:snoremap&lt;/code&gt;). See &lt;code&gt;:help mapmode-x&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You didn't supply much information on what your function does, so I'm not sure it this helps. I tried this simple function and mappings&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Bar()&#xA;    echo &quot;the count was &quot; . v:count1&#xA;endfunction&#xA;&#xA;noremap foo :&amp;lt;C-u&amp;gt;call Bar()&amp;lt;cr&amp;gt;&#xA;xnoremap foo :&amp;lt;C-u&amp;gt;call Bar()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result is correct both in Normal and Visual modes. For example &lt;code&gt;10foo&lt;/code&gt; results in &quot;the count was 10&quot; in either mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you use the mappings bellow (which execute 2 commands one after another) it doesn't work anymore. &lt;code&gt;2foo&lt;/code&gt; always results in &quot;the count was 1&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap foo :&amp;lt;C-u&amp;gt;exec 'normal! j ' &amp;lt;bar&amp;gt; call Bar()&amp;lt;cr&amp;gt;&#xA;xnoremap foo :&amp;lt;C-u&amp;gt;exec 'normal! gv j ' &amp;lt;bar&amp;gt; call Bar()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My conclusion from this is that the first command resets &lt;code&gt;v:count1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Bar()&#xA;    let x = v:count1&#xA;    normal! j&#xA;    echo &quot;the count was &quot; . x&#xA;endfunction&#xA;&#xA;noremap foo :&amp;lt;C-u&amp;gt;call Bar()&amp;lt;cr&amp;gt;&#xA;xnoremap foo :&amp;lt;C-u&amp;gt;call Bar()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it works again. Note that &lt;code&gt;v:count1&lt;/code&gt; has to be saved before the &lt;code&gt;normal!&lt;/code&gt; is executed. Otherwise its value will be lost.&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="356" LastEditDate="2015-04-06T21:15:39.350" LastActivityDate="2015-04-06T21:15:39.350" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2833" PostTypeId="2" ParentId="2814" CreationDate="2015-04-06T00:22:04.833" Score="2" Body="&lt;p&gt;Thats because you should be on a fugitive-revision for that to work. (:h fugitive-revision).&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2015-04-06T00:22:04.833" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2834" PostTypeId="1" AcceptedAnswerId="3084" CreationDate="2015-04-06T11:35:15.760" Score="9" ViewCount="2957" Body="&lt;p&gt;From time to time I see something like in the status bar when I open a file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;Gemfile&amp;quot; 112L, 2941C&#xA;&amp;quot;Gemfile&amp;quot; 112 lines --62%--&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where is it coming from? How to disable it forever?&lt;/p&gt;&#xA;&lt;p&gt;This is seriously getting out of hand, I am editing wrong lines in files because when I switch to the file it is off by one line.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;When multiple files are opened in buffers and you bring Vim to foreground especially after some changes like &lt;code&gt;git merge&lt;/code&gt; Vim seem to reload files.&lt;/p&gt;&#xA;&lt;p&gt;Settings &lt;code&gt;cmdheight&lt;/code&gt; to 2 doesn't help because there might be more messages. This is what I just had after merge:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;NORMAL  +3 ~9 departments  ... STATUS BAR&#xA;&amp;quot;app/assets/stylesheets/_menu.sass.erb&amp;quot; 144L, 3372C&#xA;&amp;quot;app/assets/stylesheets/_users.sass&amp;quot; 120L, 2110C&#xA;&amp;quot;spec/factories/users.rb&amp;quot; 19L, 469C&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There should be a way to get rid of this.&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="23502" LastEditDate="2022-11-01T19:40:43.637" LastActivityDate="2022-11-01T19:40:43.637" Title="Vim is displaying some info and &quot;Press ENTER ...&quot; when I open a file" Tags="|load|statusline|file-operations|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="2835" PostTypeId="1" CreationDate="2015-04-06T14:26:53.440" Score="4" ViewCount="946" Body="&lt;p&gt;This could be a rare issue related to individual environment. But it's so annoying that can't help me asking for help. Please have a look at following captured photos which is fine before scrolling and wrong afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I use keyboard in most of time, which makes me blind on this issue. But when I use a mouse and demo the code it just bugs me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/vDTl4.jpg&quot; width=&quot;400&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QJPxl.jpg&quot; width=&quot;400&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MacVim 7.4 on Yosemite 10.10.3. .vimrc is not relative and has been removed before testing. Btw, vim in terminal is fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Version as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 27 2014 00:31:46)&#xA;MacOS X (unix) version&#xA;Included patches: 1-258&#xA;Compiled by Homebrew&#xA;Huge version with MacVim GUI.  Features included (+) or not (-):&#xA;+acl             +cmdline_hist    +dnd             -footer          +linebreak       -mouse_gpm       +odbeditor       +rightleft       +tag_old_static  +virtualedit     +xim&#xA;+arabic          +cmdline_info    -ebcdic          +fork()          +lispindent      -mouse_jsbterm   +path_extra      +ruby            -tag_any_white   +visual          -xsmp&#xA;+autocmd         +comments        +emacs_tags      +fullscreen      +listcmds        +mouse_netterm   +perl            +scrollbind      +tcl             +visualextra     -xterm_clipboard&#xA;+balloon_eval    +conceal         +eval            -gettext         +localmap        +mouse_sgr       +persistent_undo +signs           +terminfo        +viminfo         -xterm_save&#xA;+browse          +cryptv          +ex_extra        -hangul_input    -lua             -mouse_sysmouse  +postscript      +smartindent     +termresponse    +vreplace        -xpm&#xA;++builtin_terms  +cscope          +extra_search    +iconv           +menu            +mouse_urxvt     +printer         -sniff           +textobjects     +wildignore&#xA;+byte_offset     +cursorbind      +farsi           +insert_expand   +mksession       +mouse_xterm     +profile         +startuptime     +title           +wildmenu&#xA;+cindent         +cursorshape     +file_in_path    +jumplist        +modify_fname    +multi_byte      +python          +statusline      +toolbar         +windows&#xA;+clientserver    +dialog_con_gui  +find_in_path    +keymap          +mouse           +multi_lang      -python3         -sun_workshop    +transparency    +writebackup&#xA;+clipboard       +diff            +float           +langmap         +mouseshape      -mzscheme        +quickfix        +syntax          +user_commands   -X11&#xA;+cmdline_compl   +digraphs        +folding         +libcall         +mouse_dec       +netbeans_intg   +reltime         +tag_binary      +vertsplit       -xfontset&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/Applications/MacVim.app/Contents/Resources/vim&quot;&#xA;Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X_UNIX  -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Sys&#xA;tem/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG&#xA;-Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     -I/System/Library/Frameworks/Tcl.fr&#xA;amework/Headers  -D_REENTRANT=1  -D_THREAD_SAFE=1  -D_DARWIN_C_SOURCE=1&#xA;Linking: clang   -L. -L/usr/local/var/rbenv/versions/2.2.0/lib  -fstack-protector -L/usr/local/lib -L. -L/usr/local/var/rbenv/versions/2.2.0/lib  -fstack-protector -L/usr/local/lib -L/System/Library/Fr&#xA;ameworks/Python.framework/Versions/2.7/lib/python2.7/config -framework CoreFoundation -lpython2.7 -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework Coco&#xA;a   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python  -F/System/Library/Frameworks -framework Tcl -framework CoreFoundation -lruby-static -framewo&#xA;rk CoreFoundation -lgmp -lobjc -L/usr/local/var/rbenv/versions/2.2.0/lib  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1632" LastActivityDate="2015-06-24T11:09:04.353" Title="MacVim Text rendering problem when scroll up and down" Tags="|macvim|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2836" PostTypeId="1" AcceptedAnswerId="2903" CreationDate="2015-04-06T21:38:04.463" Score="3" ViewCount="558" Body="&lt;p&gt;I'm asking about some sort of specialized diff highlighting mode. I need to diff, line by line, files A and B, which look similar to this in vimdiff:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A                             B&#xA;repo/manipulate_1.0.1.out  |  package ../manipulate-1.0.1-x86_64-1.txz created.&#xA;repo/evaluate_0.5.5.out    |  package ../evaluate-0.5.5-x86_64-1.txz created.&#xA;repo/formatR_1.1.out       |  package ../formatR-1.1-x86_64-1.txz created.&#xA;repo/highr_0.4.1.out       |  package ../highr-0.4.1-x86_64-1.txz created.&#xA;...                        |  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like for vim to highlight &lt;strong&gt;only&lt;/strong&gt; the common subsequence of the file names on both sides, that is, &lt;strong&gt;manipulate&lt;/strong&gt;, &lt;strong&gt;evaluate&lt;/strong&gt;, &lt;strong&gt;formatR&lt;/strong&gt; and &lt;strong&gt;highr&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? How?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It occurs to me that what I want is a way to highlight (or highlight differently from the rest of the line) the &lt;strong&gt;longest common subsequence (lcs)&lt;/strong&gt; between each pair of lines; but there might be other, possibly easier, ways to frame this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a graphic comparison of the current state (top) vs. what I want to achive (bottom). Note that the fourth line shows two different highlights (green and red) because both strings qualify as the lcs of length five:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/38pfN.png&quot; alt=&quot;vim diff default highlight vs. longest common subsequence highlight&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1634" LastEditorUserId="1634" LastEditDate="2015-04-13T12:10:42.827" LastActivityDate="2015-04-13T12:10:42.827" Title="Highlight longest common subsequence between two files? line by line" Tags="|vimscript|syntax-highlighting|vimdiff|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2837" PostTypeId="1" AcceptedAnswerId="2838" CreationDate="2015-04-06T23:06:23.450" Score="6" ViewCount="9022" Body="&lt;p&gt;This &lt;a href=&quot;http://vim.wikia.com/wiki/Search_patterns&quot; rel=&quot;noreferrer&quot;&gt;page&lt;/a&gt; says that I can find duplicate words using a regular expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The suggested command is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(\&amp;lt;\w\+\&amp;gt;\)\_s*\&amp;lt;\1\&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does &quot;\w&quot; mean here? Suppose the target pattern is &quot;123\t123&quot; where \t is the tab. Would the command be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\(\&amp;lt;\1\+\&amp;gt;\)\t\&amp;lt;\1\&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\(\&amp;lt;1\+\&amp;gt;\)\t\&amp;lt;\1\&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="865" LastEditDate="2016-09-16T12:17:08.667" LastActivityDate="2016-09-16T12:17:08.667" Title="searching duplicate words" Tags="|regular-expression|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2838" PostTypeId="2" ParentId="2837" CreationDate="2015-04-06T23:42:36.113" Score="6" Body="&lt;p&gt;&lt;a href=&quot;https://vimhelp.appspot.com/pattern.txt.html#%2f/w&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help /\w&lt;/code&gt;&lt;/a&gt; shows that &lt;code&gt;\w&lt;/code&gt; is a regex metacharacter matching a word character -- any character that is either an underscore (&lt;code&gt;_&lt;/code&gt;) or in the ranges &lt;code&gt;0-9&lt;/code&gt;, &lt;code&gt;a-z&lt;/code&gt;, or &lt;code&gt;A-Z&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example regex is parsed as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(        \)                Capture the match so it can be reused later&#xA;  \&amp;lt;    \&amp;gt;      \&amp;lt;  \&amp;gt;      Match (with zero-width) beginning/end of word&#xA;    \w\+                    Match one or more word characters&#xA;            \_s*            Match zero or more whitespace characters,&#xA;                              including newlines&#xA;                  \1        Match the same text as the first capture&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This style of search is useful when you don't exactly know the contents of whatever is going to match inside the &lt;code&gt;\( \)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming that there's more possible variety in your suggested text to match (any 3-digit number, rather than just &lt;code&gt;123&lt;/code&gt;), you could use the style of regex as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(\d\d\d\)\t\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-04-06T23:42:36.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2839" PostTypeId="1" CreationDate="2015-04-07T08:22:45.963" Score="2" ViewCount="647" Body="&lt;p&gt;I use CtrlP with vim, installed it with &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow&quot;&gt;Plug&lt;/a&gt; and have it set up mostly to default settings. Whenever I use the plugin though, it seems to search through all my files on my entire machine. So instead of looking for the nearest &lt;code&gt;.git&lt;/code&gt; directory or just using the current working directory, it literally searches everywhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I have been searching for the issue several times, I can't seem to find any solution. I vaguely remember finding something related to Mac but the fix not working for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I barely changed any of the CtrlP configuration settings, but here's what I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_cmd = 'CtrlPMixed'&#xA;let g:ctrlp_working_path_mode = 'ra'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm running vim 7.4 on Mac OS X 10.10.2, here's a bit of &lt;code&gt;vim --version&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 10 2015 09:51:02)&#xA;MacOS X (unix) version&#xA;Included patches: 1-488&#xA;Compiled by Homebrew&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1639" LastEditorUserId="51" LastEditDate="2015-05-28T15:46:58.833" LastActivityDate="2016-02-07T22:10:10.763" Title="CtrlP searches entire machine" Tags="|plugin-ctrlp|macos|" AnswerCount="1" CommentCount="10" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2840" PostTypeId="1" AcceptedAnswerId="2842" CreationDate="2015-04-07T09:33:39.783" Score="1" ViewCount="5256" Body="&lt;p&gt;I have to find a word and append some other text to in in Vim:&#xA;for instance I have to append to every occurrence of the word &quot;&lt;code&gt;public_html&lt;/code&gt;&quot; the text &quot;&lt;code&gt;/Text-Analysis-Tool&lt;/code&gt;&quot; to obtain &quot;&lt;code&gt;public_html/Text-Analysis-Tool&lt;/code&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried using the following command: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/public_html/public_html/Text-Analysis-Tool/gg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But is is producing the error &lt;code&gt;E488: trailing characters&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please tell me how can I do this?&lt;/p&gt;&#xA;" OwnerUserId="1331" LastEditorUserId="13" LastEditDate="2015-04-07T11:51:21.097" LastActivityDate="2015-04-07T15:48:49.007" Title="How to find every occurrence of a word and append some text to it?" Tags="|replace|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2841" PostTypeId="2" ParentId="2836" CreationDate="2015-04-07T09:43:30.193" Score="0" Body="&lt;p&gt;If you can change your files A and B to include a diff unit delimiter, diffchar might be help to see the LCS. For example, replace '/' and '_' with a space character in A, and remove '../' and replace the first '-' with a space in B. And let t:DiffUnit=&quot;Word2&quot; and try F7. Does it look like this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Lc4Rg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1641" LastEditorUserId="1641" LastEditDate="2015-04-07T09:58:40.200" LastActivityDate="2015-04-07T09:58:40.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2842" PostTypeId="2" ParentId="2840" CreationDate="2015-04-07T11:30:57.330" Score="9" Body="&lt;p&gt;The problem here is that Vim is interpreting the &lt;code&gt;/&lt;/code&gt; character in your &lt;em&gt;replacement&lt;/em&gt; as a delimiter character used by the &lt;code&gt;:substitute&lt;/code&gt; command. The syntax of the &lt;code&gt;:s&lt;/code&gt; command is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]s/pattern/replacement/flags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above syntax uses the &lt;code&gt;/&lt;/code&gt; character to delimit &lt;em&gt;pattern&lt;/em&gt;, &lt;em&gt;replacement&lt;/em&gt;, and &lt;em&gt;flags&lt;/em&gt;; however, some other characters (usually punctuation or symbols) can be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix your problem, you have two options.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Option 1&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Escape any &lt;code&gt;/&lt;/code&gt; characters in your &lt;em&gt;pattern&lt;/em&gt; and &lt;em&gt;replacement&lt;/em&gt; using &lt;code&gt;\&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/public_html/public_html\/Text-Analysis-Tool/gg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Option 2&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Use a different delimiter character. To avoid escaping, choose one that does not appear in your &lt;em&gt;pattern&lt;/em&gt; or &lt;em&gt;replacement&lt;/em&gt;. For this case, let's use &lt;code&gt;#&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s#public_html#public_html/Text-Analysis-Tool#gg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Bonus&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Appending to a search pattern is a special situation where we can use some features that are fairly unique to Vim's flavour of regex. Vim has zero-width anchors &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; that define the start and end (respectively) of the part of your pattern that you want to match. Anything before &lt;code&gt;\zs&lt;/code&gt; or after &lt;code&gt;\ze&lt;/code&gt; in your &lt;em&gt;pattern&lt;/em&gt; will not be part of the patch, and thus will remain unaffected by &lt;em&gt;replacement&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of repeating the &lt;em&gt;pattern&lt;/em&gt; part in the &lt;em&gt;replacement&lt;/em&gt;, we can define the start of the match as the end of the pattern. Below, I'll continue with the technique from &lt;strong&gt;Option 2&lt;/strong&gt; to avoid escaping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s#public_html\zs#/Text-Analysis-Tool#gg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can look at it like this: we're replacing an empty string that follows &lt;code&gt;public_html&lt;/code&gt; with &lt;code&gt;/Text-Analysis-Tool&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that omitting either of these zero-width anchors is like having &lt;code&gt;\zs&lt;/code&gt; at the start of the pattern and/or &lt;code&gt;\ze&lt;/code&gt; at the end of the pattern.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Side note&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I noticed you're using &lt;code&gt;gg&lt;/code&gt; for your &lt;em&gt;flags&lt;/em&gt;. This is identical to not using any &lt;code&gt;g&lt;/code&gt; in your &lt;em&gt;flags&lt;/em&gt; at all -- each &lt;code&gt;g&lt;/code&gt; inverts the &lt;em&gt;global&lt;/em&gt; behaviour. If this wasn't merely a typo, I suspect that you might have the &lt;code&gt;'gdefault'&lt;/code&gt; option enabled. This has the effect that using &lt;code&gt;g&lt;/code&gt; will make the substitution &lt;em&gt;not&lt;/em&gt; global, and no &lt;code&gt;g&lt;/code&gt; in &lt;em&gt;flags&lt;/em&gt; (or &lt;code&gt;gg&lt;/code&gt;) will make it global.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turning this option off (rather, not turning it on, as it's off by default) will let you use a single &lt;code&gt;g&lt;/code&gt; for the global behaviour.&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="64" LastEditDate="2015-04-07T15:48:49.007" LastActivityDate="2015-04-07T15:48:49.007" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2843" PostTypeId="1" AcceptedAnswerId="2844" CreationDate="2015-04-07T18:27:52.950" Score="6" ViewCount="2453" Body="&lt;p&gt;I'm using Dispatch.vim, and often when there's a test error, some lines in the quickfix list are really long. I don't use soft wrapping for my code, so quickfix also isn't wrapped. Is it possible to automatically &lt;code&gt;setlocal wrap&lt;/code&gt; only for the quickfix window?&lt;/p&gt;&#xA;" OwnerUserId="401" LastActivityDate="2015-04-07T19:14:10.430" Title="How to automatically set wrapping for quickfix window?" Tags="|wrapping|quickfix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2844" PostTypeId="2" ParentId="2843" CreationDate="2015-04-07T19:14:10.430" Score="14" Body="&lt;p&gt;Autocommands to the rescue!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put these lines in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup quickfix&#xA;    autocmd!&#xA;    autocmd FileType qf setlocal wrap&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's also this slightly cleaner method:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;create &lt;code&gt;~/.vim/after/ftplugin/qf.vim&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and put this line in it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal wrap&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The first method adds yet another autocommand to the possibly large pile of autocommands already in your config.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second method takes advantage of the fact that Vim already runs its own set of autocommands to determine filetype and source the appropriate ftplugins.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-04-07T19:14:10.430" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2845" PostTypeId="1" CreationDate="2015-04-07T21:52:17.213" Score="5" ViewCount="1606" Body="&lt;p&gt;When using netrw, (by :Vex or :Sex), the files can be displayed in different ways by pressing &quot;i&quot;. And there is a view that the sizes of the files are displayed. However, the sizes are in bytes. Is there any way to show the sizes in a human readable way? like &quot;ls -sh&quot; in shell?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="51" LastEditDate="2015-09-06T19:13:41.190" LastActivityDate="2015-11-23T20:35:37.613" Title="How to display file size in netrw in a human readable way?" Tags="|netrw|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2846" PostTypeId="1" AcceptedAnswerId="2848" CreationDate="2015-04-08T00:51:01.910" Score="20" ViewCount="3952" Body="&lt;p&gt;I'm currently writing a lot of plain text (and LaTeX with minimal formatting in paragraphs), and it would be nice if I could set up vim to keep each sentence (for simplicity, text terminated by a '. ',  '! ', or '? '; that is a terminating punctuation followed by a space so as to avoid breaking on decimal numbers) on its own line so the VCS diffs will be more useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Minimally, I'd like &lt;code&gt;gq&lt;/code&gt; to format text from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;He lay flat on the brown, pine-needled floor of the forest, his chin on his&#xA;folded arms, and high overhead the wind blew in the tops of the pine trees.&#xA;The mountainside sloped gently where he lay; but below it was steep and he&#xA;could see the dark of the oiled road winding through the pass. There was a&#xA;stream alongside the road and far down the pass he saw a mill beside the&#xA;stream and the falling water of the dam, white in the summer sunlight. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;He lay flat on the brown, pine-needled floor of the forest, his chin on his folded arms, and high overhead the wind blew in the tops of the pine trees.&#xA;The mountainside sloped gently where he lay; but below it was steep and he could see the dark of the oiled road winding through the pass.&#xA;There was a stream alongside the road and far down the pass he saw a mill beside the stream and the falling water of the dam, white in the summer sunlight.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it would be nice if vim would also perform this formatting as I type (like it does with textwidth reflow). Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current solution is to join a paragraph with &lt;code&gt;J&lt;/code&gt;, then run &lt;code&gt;:'&amp;lt;,'&amp;gt;s/\. /.\r/g&lt;/code&gt; which is pretty good as there are few exclamation and question marks, but it would be much better if I could make gq slightly smarter.&lt;/p&gt;&#xA;" OwnerUserId="1402" LastEditorUserId="1402" LastEditDate="2015-04-08T01:02:05.217" LastActivityDate="2018-02-09T16:19:42.847" Title="How to set up Vim to work with one sentence per line?" Tags="|line-breaks|formatting|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2847" PostTypeId="2" ParentId="2846" CreationDate="2015-04-08T01:42:01.090" Score="1" Body="&lt;p&gt;Well you can setup up some maps and autocommands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddSentenceMaps()&#xA;  imap .&amp;lt;Space&amp;gt; .&amp;lt;CR&amp;gt;&#xA;  imap !&amp;lt;Space&amp;gt; !&amp;lt;CR&amp;gt;&#xA;  imap ?&amp;lt;Space&amp;gt; ?&amp;lt;CR&amp;gt;&#xA;  exec &quot;nmap gq vipJ:s/\\([.!?]\\)\\s\\+/\\1\\r/g&amp;lt;CR&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;autocmd Filetype customtxt call AddSentenceMaps()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then just set the file type to customtxt or call the &lt;code&gt;AddSentenceMaps&lt;/code&gt; function manually.&lt;/p&gt;&#xA;" OwnerUserId="544" LastEditorUserId="16281" LastEditDate="2018-02-09T16:19:42.847" LastActivityDate="2018-02-09T16:19:42.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2848" PostTypeId="2" ParentId="2846" CreationDate="2015-04-08T02:26:20.120" Score="25" Body="&lt;h2&gt;The &lt;code&gt;'formatexpr'&lt;/code&gt; option&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can achieve this using the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27formatexpr%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'formatexpr'&lt;/code&gt;&lt;/a&gt; option. From the help:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Expression which is evaluated to format a range of lines for the gq operator or automatic formatting (see 'formatoptions').  When this option is empty 'formatprg' is used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Setting your &lt;code&gt;'formatexpr'&lt;/code&gt; correctly will work both when using &lt;code&gt;gq&lt;/code&gt; and while inserting text.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;A simple example&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here's a simple VimScript function and corresponding &lt;code&gt;'formatexpr'&lt;/code&gt; value that should do the job. I haven't tested it around all the edge cases, but it worked nicely for my simple tests.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFormatExpr(start, end)&#xA;    silent execute a:start.','.a:end.'s/[.!?]\zs /\r/g'&#xA;endfunction&#xA;&#xA;set formatexpr=MyFormatExpr(v:lnum,v:lnum+v:count-1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Explanation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The expression is a call to the function &lt;code&gt;MyFormatExpr()&lt;/code&gt;, passing in the starting and ending lines over which the formatting will be applied. These lines are computed using the automatically populated variables &lt;code&gt;v:lnum&lt;/code&gt; (the first line to be formatted) and &lt;code&gt;v:count&lt;/code&gt; (the number of lines to be formatted).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;MyFormatExpr()&lt;/code&gt; function constructs a &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Asubstitute&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:substitute&lt;/code&gt;&lt;/a&gt; command with the passed in range, and replaces a whitespace following an end-of-sentence punctuation mark (&lt;code&gt;.&lt;/code&gt;, &lt;code&gt;!&lt;/code&gt;, or &lt;code&gt;?&lt;/code&gt;) with a newline (&lt;code&gt;\r&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Caveats&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;MyFormatExpr()&lt;/code&gt; function doesn't preserve leading indentation. Some more sophisticated logic would be needed to fix that.&lt;/li&gt;&#xA;&lt;li&gt;There may be other edge cases where this falls apart. Give it a test drive and tweak as necessary!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="64" LastEditorUserId="64" LastEditDate="2016-05-21T11:41:19.753" LastActivityDate="2016-05-21T11:41:19.753" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2849" PostTypeId="1" AcceptedAnswerId="2851" CreationDate="2015-04-08T04:49:25.657" Score="4" ViewCount="5983" Body="&lt;p&gt;I have gVim 7.4.608 installed on Windows 7 at work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked in &lt;code&gt;C:\&lt;/code&gt; , &lt;code&gt;C:\Users\&amp;lt;username&amp;gt;\AppData&lt;/code&gt; , &lt;code&gt;C:\Program Files\vim&lt;/code&gt; , &lt;code&gt;C:\Temp&lt;/code&gt; but there's no sign of it. It must exist somewhere, command history is working OK. I just want to read the file, I don't care where it actually is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help viminfo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The default name of the viminfo file is &quot;$HOME/.viminfo&quot; for Unix and OS/2,&#xA;&quot;s:.viminfo&quot; for Amiga, &quot;$HOME\_viminfo&quot; for MS-DOS and Win32.  For the last&#xA;two, when $HOME is not set, &quot;$VIM\_viminfo&quot; is used.  When $VIM is also not&#xA;set, &quot;c:\_viminfo&quot; is used.  For OS/2 &quot;$VIM/.viminfo&quot; is used when $HOME is&#xA;not set and $VIM is set.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The variables &lt;code&gt;%HOME%&lt;/code&gt; and &lt;code&gt;%VIM%&lt;/code&gt; were not set in my Windows environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't look in directory &lt;code&gt;C:\Users\&amp;lt;username&amp;gt;\Application Data&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="398" LastEditorUserId="398" LastEditDate="2015-04-08T15:20:19.190" LastActivityDate="2018-07-20T17:34:40.750" Title="Where is my viminfo file on Windows?" Tags="|gvim|persistent-state|microsoft-windows|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2850" PostTypeId="1" AcceptedAnswerId="2854" CreationDate="2015-04-08T06:30:43.727" Score="2" ViewCount="769" Body="&lt;p&gt;I have a log file with lots of web service XML data (example follows). Ideally I would like to just go to a line and type &lt;code&gt;,x&lt;/code&gt; to create pretty formatted XML for readability.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Response XML: &amp;lt;ZZZZZ_EXBListLocalEftposRS xmlns=&quot;http://types.wise.zzzzz.com/2005/06&quot;&amp;gt;&amp;lt;PayLoad&amp;gt;&amp;lt;TimeStamp&amp;gt;2015-04-07T10:25:18.797+12:00&amp;lt;/TimeStamp&amp;gt;&amp;lt;/PayLoad&amp;gt;&amp;lt;Success/&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;true&quot; ProbablyLocal=&quot;true&quot;&amp;gt;TEST_EFTD&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;true&quot; ProbablyLocal=&quot;true&quot;&amp;gt;TEST_EFT&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;false&quot; ProbablyLocal=&quot;false&quot;&amp;gt;TESTBadD1&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;false&quot; ProbablyLocal=&quot;false&quot;&amp;gt;TESTBadD2&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;false&quot; ProbablyLocal=&quot;false&quot;&amp;gt;TESTBadD3&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;false&quot; ProbablyLocal=&quot;false&quot;&amp;gt;TESTBadNoP&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;false&quot; ProbablyLocal=&quot;false&quot;&amp;gt;TESTBadS&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;false&quot; ProbablyLocal=&quot;false&quot;&amp;gt;TESTBadS2&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;false&quot; ProbablyLocal=&quot;false&quot;&amp;gt;TESTBadS3&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;false&quot; ProbablyLocal=&quot;false&quot;&amp;gt;TESTBadS4&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;false&quot; ProbablyLocal=&quot;false&quot;&amp;gt;TESTBadS5&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;false&quot; ProbablyLocal=&quot;false&quot;&amp;gt;TESTBadS6&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;false&quot; ProbablyLocal=&quot;true&quot;&amp;gt;TESTBadScl&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;EftposTerminalID CurrentlyMapped=&quot;false&quot; ProbablyLocal=&quot;false&quot;&amp;gt;TESTBadTyp&amp;lt;/EftposTerminalID&amp;gt;&amp;lt;/ZZZZZ_EXBListLocalEftposRS&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently, I can format the line as follows&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;put the XML stuff on a new line (If you don't do this xmllint has problems)&lt;/li&gt;&#xA;&lt;li&gt;get the line number I need (199 in this case)  &lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;call &lt;a href=&quot;http://vim.wikia.com/wiki/Format_your_xml_document_using_xmllint&quot; rel=&quot;nofollow&quot;&gt;xmllint.exe&lt;/a&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:199 :!C:\apps\xmllint.exe % --format&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is there some way to automate some or all of this process? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using gvim on windows, and xmllint.exe from google code.&lt;/p&gt;&#xA;" OwnerUserId="398" LastEditorUserId="51" LastEditDate="2015-05-04T01:50:59.947" LastActivityDate="2015-05-04T01:50:59.947" Title="Tips for quickly formatting a single line of XML?" Tags="|vimscript|formatting|filetype-xml|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2851" PostTypeId="2" ParentId="2849" CreationDate="2015-04-08T08:02:21.083" Score="6" Body="&lt;p&gt;For Windows, the home directory is set in &lt;code&gt;%USERPROFILE%&lt;/code&gt;. I believe vim will use this as &lt;code&gt;$HOME&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case, the &lt;code&gt;_viminfo&lt;/code&gt; is located in the &lt;code&gt;C:\Users\&amp;lt;username&amp;gt;&lt;/code&gt;, which is the home directory, while the &lt;code&gt;%HOME%&lt;/code&gt; is not set as well. &lt;/p&gt;&#xA;" OwnerUserId="1653" LastEditorUserId="1653" LastEditDate="2015-04-08T08:56:20.137" LastActivityDate="2015-04-08T08:56:20.137" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2852" PostTypeId="2" ParentId="2849" CreationDate="2015-04-08T09:36:24.433" Score="1" Body="&lt;p&gt;Are you sure the &lt;code&gt;HOME&lt;/code&gt; variable isn't set? I have encountered cases where &lt;code&gt;ENV&lt;/code&gt; was not set, but &lt;code&gt;HOME&lt;/code&gt; always seems to be assigned a value in my (G)Vim instances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you type &lt;code&gt;echo $HOME&lt;/code&gt; in command mode, Vim should display what value is set for &lt;code&gt;HOME&lt;/code&gt;. Alternatively, you can try &lt;code&gt;e $HOME\.viminfo&lt;/code&gt; and see if this opens the contents of the .viminfo file. If this is the case, you have found it!&lt;/p&gt;&#xA;" OwnerUserId="367" LastActivityDate="2015-04-08T09:36:24.433" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2853" PostTypeId="1" CreationDate="2015-04-08T09:53:12.890" Score="4" ViewCount="551" Body="&lt;p&gt;I have lots of files named by &lt;code&gt;file.tags, ncl.tags, flod.tags, ...  , fortran.tags&lt;/code&gt;. when  opening &lt;code&gt;file.tags&lt;/code&gt;, I want to &lt;code&gt;set tags=file.tags&lt;/code&gt;.And when opening &lt;code&gt;ncl.tags&lt;/code&gt;, I want to &lt;code&gt;set tags=ncl.tags&lt;/code&gt;,and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I put the following in my .vimrc, it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:current_file=expand(&quot;%:t&quot;)&#xA;au Bufread,BufNewfile tags set filetype=tags tags=g:current_file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1656" LastEditorUserId="24" LastEditDate="2015-04-08T13:42:34.637" LastActivityDate="2015-04-08T13:42:34.637" Title="How to set the opening file as the tags in vim?" Tags="|vimrc|load|tags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2854" PostTypeId="2" ParentId="2850" CreationDate="2015-04-08T10:19:45.390" Score="2" Body="&lt;p&gt;You already have most of the pieces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:199 :!C:\apps\xmllint.exe % --format&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:.&lt;/code&gt; for the current line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.!C:\apps\xmllint.exe % --format&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get rid of the preamble before the XML, you can use &lt;code&gt;0dt&amp;lt;&lt;/code&gt;. Inside a command-line, that's done with &lt;code&gt;:normal!&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute 'normal! 0dt&amp;lt;' | .!C:\apps\xmllint.exe % --format&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, all that is left is creating a mapping (note how some keys need a special format):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ,x :execute 'normal! 0dt&amp;lt;lt&amp;gt;' &amp;lt;Bar&amp;gt; .!C:\apps\xmllint.exe % --format&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-08T10:19:45.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2855" PostTypeId="2" ParentId="2853" CreationDate="2015-04-08T10:29:34.890" Score="6" Body="&lt;p&gt;The &lt;code&gt;g:current_file&lt;/code&gt; is evaluated in your &lt;code&gt;~/.vimrc&lt;/code&gt; at startup, i.e. &lt;em&gt;before any file has been loaded&lt;/em&gt;. You need to do the evaluation inside the &lt;code&gt;:autocmd&lt;/code&gt;; either with &lt;code&gt;:execute&lt;/code&gt;, but for options, it's more elegant to use &lt;code&gt;:let &amp;amp;optionname = ...&lt;/code&gt; instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au Bufread,BufNewfile *tags setlocal filetype=tags | let &amp;amp;tags = expand(&quot;%:t&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-08T10:29:34.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2856" PostTypeId="1" CreationDate="2015-04-08T11:27:58.330" Score="4" ViewCount="1500" Body="&lt;p&gt;I have an XML file that must conform to a particular &lt;a href=&quot;http://www.w3.org/XML/Schema&quot; rel=&quot;nofollow&quot;&gt;XML Schema&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&#xA;&amp;lt;myroot&#xA;  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&#xA;  xsi:noNamespaceSchemaLocation=&quot;/home/nico/schemas/myroot.xsd&quot;&amp;gt;&#xA;    &amp;lt;blabla /&amp;gt;&#xA;&amp;lt;/myroot&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I edit this XML file in Vim, I would like to be told whether the syntax is OK, for instance by showing &lt;code&gt;&amp;lt;blabla /&amp;gt;&lt;/code&gt; in red if it is not allowed by the XML Schema.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most IDEs do that by default. Is it achievable with Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If needed, I am OK with doing some particular configuration for this XML/XML Schema, as I edit this particular XML file very often. It is about a megabyte.&lt;/p&gt;&#xA;" OwnerUserId="1083" LastActivityDate="2015-04-15T15:51:00.337" Title="Highlight XML errors based on this XML file's XML Schema" Tags="|syntax-highlighting|filetype-xml|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2857" PostTypeId="1" AcceptedAnswerId="2865" CreationDate="2015-04-08T15:45:58.900" Score="3" ViewCount="1919" Body="&lt;p&gt;I need to configure Vim in such a way that it has a normal scrolloff of 3 or 5. But in such a way that it keeps the last line at the bottom of the screen. I don't want that as I scroll, the last lines of the buffer to come up to the top of the screen under any circumstance.&#xA;To make this more precise I want this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wtjOb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and no matter what key I press, I explicitly do not want this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/7GJQR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can this be accomplished?&lt;/p&gt;&#xA;" OwnerUserId="155" LastEditorUserId="15" LastEditDate="2015-04-09T15:25:40.977" LastActivityDate="2022-03-15T22:00:30.723" Title="Vim keep last line at bottom of buffer" Tags="|cursor-movement|scrolling|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2858" PostTypeId="1" CreationDate="2015-04-08T16:16:16.983" Score="10" ViewCount="848" Body="&lt;p&gt;I am trying to gather a toolbox of Vim commands/queries, in command or search mode, for navigating a code-base &lt;em&gt;without&lt;/em&gt; using Ctags or other external tools. Ctags are great but support can vary depending on the development environment you are stuck on. I would like to just rely on Vim knowledge.&lt;/p&gt;&#xA;" OwnerUserId="1661" LastEditorUserId="8" LastEditDate="2015-04-09T07:23:28.657" LastActivityDate="2015-04-09T07:23:28.657" Title="Navigating code projects without using external commands" Tags="|search|ide|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2860" PostTypeId="2" ParentId="2858" CreationDate="2015-04-08T18:07:33.767" Score="5" Body="&lt;p&gt;There are a lot of ways for navigating through code (included in Vim and external), I still discover them. What I use in daily work is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Greping text in the project files and navigating via quickfix window&#xA;(I use silver searcher for greping).&lt;/li&gt;&#xA;&lt;li&gt;Using language related plugins, I know there are ones for javascript, ruby, go, that allow to jump between modules of the program (in javascript plugin is &lt;code&gt;gf&lt;/code&gt;-command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Ctrl+O&lt;/code&gt;, &lt;code&gt;Ctrl+I&lt;/code&gt; - jump back or forward in &quot;history&quot; of the navigation&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g;&lt;/code&gt; - jump onto last edited place in the file&lt;/li&gt;&#xA;&lt;li&gt;Using marks for placing &quot;bookmarks&quot; on the particular places. You can place mark with &lt;code&gt;'[some_letter]&lt;/code&gt; command, if letter is capital then you'll get mark which will be reachable from any file (buffer).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="500" LastActivityDate="2015-04-08T18:07:33.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2861" PostTypeId="2" ParentId="2846" CreationDate="2015-04-08T18:16:35.653" Score="0" Body="&lt;p&gt;I want to add my thoughts about this issue. Usually people want this kind of feature because of jumping over wrapped lines when ones navigating through the code with &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; commands which is default behaviour of Vim. For the navigation through wrapped lines I use &lt;code&gt;gj&lt;/code&gt; - move down and &lt;code&gt;gk&lt;/code&gt; - move up. Also there is possibility remap standard &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; command on the g-prefixed counterparts, but IMHO it would be overkill.&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2015-04-08T18:16:35.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2862" PostTypeId="2" ParentId="2858" CreationDate="2015-04-08T19:34:36.010" Score="12" Body="&lt;p&gt;&quot;Include search&quot; is one such tool:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[I and ]I      &quot; search current buffer and included files for&#xA;               &quot; the word under the cursor, skipping comments&#xA;:ilist foo     &quot; same as above but for 'foo'&#xA;:ilist /foo    &quot; same as above but for a word containing 'foo'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Related to &quot;include search&quot;, &quot;definition search&quot; is interesting, too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[D and ]D      &quot; search current buffer and included files for&#xA;               &quot; the definition of the symbol under the cursor&#xA;:dlist foo     &quot; same as above but for definition of 'foo'&#xA;:dlist /foo    &quot; same as above but for a definition containing 'foo'&#xA;&#xA;:dlist /       &quot; list all definitions from the current buffer&#xA;               &quot; and included files&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both tools depend on a variety of options that may or may not be set by your filetype plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help include-search&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;gd&lt;/code&gt; and &lt;code&gt;gD&lt;/code&gt; as lightweight versions of &lt;code&gt;[D&lt;/code&gt;and &lt;code&gt;]D&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help gd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In the current buffer, the command below will list every function definition and its line number:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/func/#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :g&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:grep&lt;/code&gt; and &lt;code&gt;:vimgrep&lt;/code&gt; are also useful, if only because their result is fed into the quickfix list that can be navigated with &lt;code&gt;:cn&lt;/code&gt;, &lt;code&gt;:cp&lt;/code&gt;… and displayed in the very handy quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :grep&lt;/code&gt;, &lt;code&gt;:help :vimgrep&lt;/code&gt; and &lt;code&gt;:help quickfix&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Speaking of the quickfix list/window, I wrote &lt;a href=&quot;https://gist.github.com/romainl/3c7ee68125f822ec550c&quot;&gt;this function&lt;/a&gt; (based on the work of others) to display the results of &lt;code&gt;[I&lt;/code&gt;, &lt;code&gt;]I&lt;/code&gt;, &lt;code&gt;:ilist&lt;/code&gt;, &lt;code&gt;[D&lt;/code&gt;, &lt;code&gt;]D&lt;/code&gt; and &lt;code&gt;:dlist&lt;/code&gt; in the quickfix list/window. YMMV of course.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;While not strictly a navigation tool, I find the preview window very useful for taking a look at the signature of the function I'm working with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help preview-window&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;That said…&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim doesn't know anything about your code beyond a few regex patterns that may or may not fit your coding style or whatever. This means that code navigation is better done with the help of external tools like ctags, cscope or GNU GLOBAL.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-04-08T19:34:36.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2863" PostTypeId="1" CreationDate="2015-04-09T10:16:35.640" Score="1" ViewCount="1745" Body="&lt;p&gt;I'm sure this will have been asked before, but I can't seem to find a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tend to open Vim from the root of my project, let's say:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/dev/project/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which looks something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;project/&#xA;| - app/&#xA;|  | - scripts/&#xA;|  |  | - ...&#xA;|  | - styles/&#xA;|  |  | - ...&#xA;| - index.html&#xA;| - Gruntfile.js&#xA;| - README.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open Vim from the &lt;code&gt;project&lt;/code&gt; directory, I &lt;strong&gt;only want CtrlP to index these files and subdirectories&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, I seem to get indexes for all of the root's sibling directories too and sometimes even further up. This becomes pretty annoying when I want to find a file with a common name across all my projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I remember, I've only ever changed one configuration setting for CtrlP and it's the ignore directive:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:ctrlp_custom_ignore = 'bower_components\|node_modules\|vendor\|.git|static\'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this the default behaviour and if not, how can I change it?&lt;/p&gt;&#xA;" OwnerUserId="124" LastActivityDate="2015-04-09T18:41:57.667" Title="Prevent CtrlP from indexing parent directories" Tags="|vimrc|plugin-ctrlp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2864" PostTypeId="1" AcceptedAnswerId="2869" CreationDate="2015-04-09T11:40:43.073" Score="5" ViewCount="1504" Body="&lt;p&gt;In my &lt;code&gt;vimrc&lt;/code&gt; I have the following line, which figures all the indentation of my files.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When writing C programs sometimes I use preprocessor directives like &lt;code&gt;#ifdef foo&lt;/code&gt; and &lt;code&gt;#endif&lt;/code&gt;. When writing one such directive inside a block Vim indents the directive like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main()&#xA;{&#xA;#ifdef foo&#xA;...&#xA;#endif&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I would like them to be indented as any other statement, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main()&#xA;{&#xA;    #ifdef foo&#xA;    ...&#xA;    #endif&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;indentkeys&lt;/code&gt; might be able to do the job. From &lt;code&gt;:help 'indentkeys'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A list of keys that, when typed in Insert mode, cause reindenting of&#xA;  the current line.  Only happens if 'indentexpr' isn't empty.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But my &lt;code&gt;indentexpr&lt;/code&gt; is empty and I have no idea what I should put there; or if there is a better solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the &lt;a href=&quot;http://vim.wikia.com/wiki/Indenting_source_code&quot;&gt;Vim wiki&lt;/a&gt; I have read&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you plan on using file type based indentation, don't set&#xA;  'smartindent' or 'cindent'. You may still set 'autoindent', since it&#xA;  doesn't interfere.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, since I am using file type based indentation I don't want to use&#xA;&lt;code&gt;smartindent&lt;/code&gt; nor &lt;code&gt;cindent&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve my intended indentation for preprocessor directives?&lt;/p&gt;&#xA;" OwnerUserId="356" LastActivityDate="2015-04-09T16:19:26.473" Title="Indentation of preprocessor directives" Tags="|indentation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2865" PostTypeId="2" ParentId="2857" CreationDate="2015-04-09T13:47:57.447" Score="2" Body="&lt;p&gt;If you try scrolling when you are at the bottom vim assumes you want to move the text up.&lt;/p&gt;&#xA;&lt;p&gt;You can replace commands like &lt;code&gt;ctrl-f&lt;/code&gt; with an additional &amp;quot;move cursor to bottom of screen&amp;quot; using &lt;code&gt;zb&lt;/code&gt;. This modification would need to be added to any other commands you wish this to not occur.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:nnoremap &amp;lt;c-f&amp;gt; &amp;lt;c-f&amp;gt;zb&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now when you &lt;code&gt;ctrl-f&lt;/code&gt; at the bottom of the screen it stays at the bottom, but so does every instance of &lt;code&gt;ctrl-f&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you would like to do it conditionally you'll need to write a little function that compares your current position to the end of the file.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! NoScrollAtEOF()&#xA;  let curpos = getpos('.')&#xA;  let lnum = get(curpos, 1, -1)&#xA;  let len = line('$')&#xA;  if lnum + winheight(0) &amp;gt;= len &#xA;    normal! zb&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;c-f&amp;gt; &amp;lt;c-f&amp;gt;:call NoScrollAtEOF()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This function pulls the current position and the end of file position and calls &lt;code&gt;zb&lt;/code&gt; if the current position plus the height of your window is greater than the end of file...if you can see the end of the file in your window.&lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="22375" LastEditDate="2022-03-15T22:00:30.723" LastActivityDate="2022-03-15T22:00:30.723" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2866" PostTypeId="2" ParentId="2856" CreationDate="2015-04-09T14:13:20.380" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/scrooloose/syntastic&quot; rel=&quot;nofollow&quot;&gt;Syntastic&lt;/a&gt; plugin currently contains support for xmllint from &lt;a href=&quot;http://www.xmlsoft.org&quot; rel=&quot;nofollow&quot;&gt;xmlsoft&lt;/a&gt;. If you know of another xml lint checker that verifies schema or dtd then it will be your easiest bet to create a Syntastic plugin for it.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2015-04-09T14:13:20.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2867" PostTypeId="1" AcceptedAnswerId="2868" CreationDate="2015-04-09T14:21:52.710" Score="42" ViewCount="8942" Body="&lt;p&gt;Suppose you run the following piece of vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @z = system(&quot;date&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will put a string version of the current date into the z register, but the string will end with a newline that I don’t want. Is there a built-in way (similar to Perl’s &lt;a href=&quot;http://perldoc.perl.org/functions/chomp.html&quot;&gt;&lt;code&gt;chomp&lt;/code&gt;&lt;/a&gt;) to get rid of a string’s trailing newlines?&lt;/p&gt;&#xA;" OwnerUserId="671" LastActivityDate="2023-06-01T03:21:50.730" Title="How do you “chomp” a string in Vim?" Tags="|vimscript|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2868" PostTypeId="2" ParentId="2867" CreationDate="2015-04-09T14:41:44.043" Score="29" Body="&lt;p&gt;You can use &lt;code&gt;substitute()&lt;/code&gt;, or define a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Chomp(string)&#xA;    return substitute(a:string, '\n\+$', '', '')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This variant will call &lt;code&gt;system&lt;/code&gt; for you and then chomp the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ChompedSystem( ... )&#xA;    return substitute(call('system', a:000), '\n\+$', '', '')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(This function is also available in my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4433&quot;&gt;ingo-library plugin&lt;/a&gt; as &lt;code&gt;ingo#system#Chomped&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="671" LastEditDate="2015-04-10T01:16:06.193" LastActivityDate="2015-04-10T01:16:06.193" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2869" PostTypeId="2" ParentId="2864" CreationDate="2015-04-09T16:19:26.473" Score="6" Body="&lt;p&gt;This specific behavior is handled by the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27cinkeys%27&quot;&gt;&lt;code&gt;'cinkeys'&lt;/code&gt;&lt;/a&gt; option.  &lt;code&gt;'cinkeys'&lt;/code&gt; is similar to &lt;code&gt;'indentkeys'&lt;/code&gt; but is only used when &lt;code&gt;'cindent'&lt;/code&gt; is enabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, it contains the &lt;code&gt;0#&lt;/code&gt; setting which causes the leading indentation to be removed when a line starts with &lt;code&gt;#&lt;/code&gt;.  To disable this, you could add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal cinkeys-=0#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;code&gt;~/.vim/after/indent/c.vim&lt;/code&gt; and &lt;code&gt;~/.vim/after/indent/cpp.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-04-09T16:19:26.473" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2870" PostTypeId="2" ParentId="2835" CreationDate="2015-04-09T18:32:06.470" Score="2" Body="&lt;p&gt;I have a feeling this is bug in Vim 7.4 since my Windows version does the same thing from time to time.  The only solution I've found so far is to scroll past the corruption so that it fixes itself or call &lt;code&gt;:redraw!&lt;/code&gt; to force it to redraw the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I was going to add this as a comment, but I don't have the requisite reputation.&lt;/p&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2015-04-09T18:32:06.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2871" PostTypeId="2" ParentId="2863" CreationDate="2015-04-09T18:39:53.590" Score="0" Body="&lt;p&gt;I would check your &lt;code&gt;:pwd&lt;/code&gt;. I think you are probably not in the directory you think you are. CtrlP default searches start at your current working directory so you shouldn't be seeing the issues you are unless you are actually in a different directory. The only other option is if you run the function supplying a starting directory like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:CtrlP &amp;lt;directory&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all else fails, try downloading the latest CtrlP and see if there was a bug or if your plugin files were accidentally modified.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2015-04-09T18:39:53.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2872" PostTypeId="2" ParentId="2863" CreationDate="2015-04-09T18:41:57.667" Score="7" Body="&lt;p&gt;If I'm not mistaken, you want to change g:ctrlp_working_path_mode: &lt;a href=&quot;https://github.com/kien/ctrlp.vim/blob/master/doc/ctrlp.txt#L178&quot;&gt;https://github.com/kien/ctrlp.vim/blob/master/doc/ctrlp.txt#L178&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_working_path_mode = '0'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-04-09T18:41:57.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2873" PostTypeId="2" ParentId="2850" CreationDate="2015-04-09T18:43:37.600" Score="1" Body="&lt;p&gt;Another option would be to install &lt;a href=&quot;https://github.com/scrooloose/syntastic&quot; rel=&quot;nofollow&quot;&gt;Syntastic&lt;/a&gt;. It has support for xml lint testing using xmllint. This will do the checking and report errors and not directly fix the problem with the XML however. &lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2015-04-09T18:43:37.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2874" PostTypeId="2" ParentId="2867" CreationDate="2015-04-09T19:56:31.867" Score="28" Body="&lt;pre&gt;&lt;code&gt;let @z = systemlist('date')[0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;removes the newline for you.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-04-09T19:56:31.867" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2875" PostTypeId="1" AcceptedAnswerId="2876" CreationDate="2015-04-10T06:27:09.307" Score="13" ViewCount="5876" Body="&lt;p&gt;Is there anything I can do to keep &lt;code&gt;syntax on&lt;/code&gt; when using Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As soon as I open anything substantial it becomes nearly impossible to edit after a while. Every keypress causes a delay. If I turn syntax highlighting off or relaunch vim – it is fine again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;code&gt;synmaxcol&lt;/code&gt; set to 120. Sample ruby file is only 59 lines long and not exceeding 80 characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;code&gt;vim-ruby&lt;/code&gt; and &lt;code&gt;vim-rails&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the delay seem to accumulate over time. When I open the file from scratch it is fine. After a while it gets slower and slower.&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="51" LastEditDate="2015-05-20T14:20:41.067" LastActivityDate="2015-05-20T14:20:41.067" Title="Vim slows down over time with syntax on" Tags="|syntax-highlighting|performance|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2876" PostTypeId="2" ParentId="2875" CreationDate="2015-04-10T08:11:48.083" Score="16" Body="&lt;p&gt;Recent Vim versions have a &lt;code&gt;:syntime&lt;/code&gt; command to troubleshoot slowness of syntax highlighting by generating a report of how long each syntax group takes to match. This is very helpful and quickly lets you find the culprit; the only downside is that you need a (usually &quot;HUGE&quot;) build of Vim with profiling enabled. &lt;code&gt;:help :syntime&lt;/code&gt; provides good instructions how to employ it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can try removing individual syntax scripts from &lt;code&gt;~/.vim/syntax/&lt;/code&gt; and &lt;code&gt;$VIMRUNTIME/syntax/&lt;/code&gt; (according to the current &lt;code&gt;'filetype'&lt;/code&gt;), and then further drill down by removing parts of the syntax definitions inside the script.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-10T08:11:48.083" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2877" PostTypeId="1" AcceptedAnswerId="2879" CreationDate="2015-04-10T09:26:16.593" Score="13" ViewCount="12222" Body="&lt;p&gt;I'm just doing some testing with JavaScript language feature with no DOM manipulation. So I'm editing a js file and I'm wondering how to simply run it and show the console output? I installed the &lt;a href=&quot;https://github.com/moll/vim-node&quot; rel=&quot;noreferrer&quot;&gt;moll/vim-node&lt;/a&gt; plugin, but no idea how to run js code.&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="51" LastEditDate="2016-11-27T14:57:40.960" LastActivityDate="2021-03-01T16:24:20.287" Title="How can I run javascript directly and show the output?" Tags="|filetype-javascript|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2878" PostTypeId="1" AcceptedAnswerId="2882" CreationDate="2015-04-10T12:24:03.790" Score="4" ViewCount="1190" Body="&lt;p&gt;Assuming the following situation&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$someVar = &quot;Some String with \&quot;escaped\&quot; inner delimiters&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the cursor somewhere in the double-quote delimited string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the quickest way to jump to the final (actually delimiting) double quote? I can only think of &lt;code&gt;3f&quot;&lt;/code&gt;/&lt;code&gt;f&quot;&lt;/code&gt; depending on where the cursor is, or even using a negative lookbehind with &lt;code&gt;/&lt;/code&gt;, but there has to be a better way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there perhaps even something like &quot;jump to the end of the current syntax-highlighted block&quot;?&lt;/p&gt;&#xA;" OwnerUserId="79" LastActivityDate="2015-04-11T00:35:29.117" Title="How to jump to the end of quoted string, considering escaped delimiters" Tags="|cursor-movement|syntax-highlighting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2879" PostTypeId="2" ParentId="2877" CreationDate="2015-04-10T13:42:57.647" Score="5" Body="&lt;p&gt;Per this &lt;a href=&quot;http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window&quot; rel=&quot;noreferrer&quot;&gt;vim wikia&lt;/a&gt; entry you could create a shell execution to new buffer script and then extend it to run your code using node.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(&amp;lt;q-args&amp;gt;)&#xA;function! s:RunShellCommand(cmdline)&#xA;  let isfirst = 1&#xA;  let words = []&#xA;  for word in split(a:cmdline)&#xA;    if isfirst&#xA;      let isfirst = 0  &quot; don't change first word (shell command)&#xA;    else&#xA;      if word[0] =~ '\v[%#&amp;lt;]'&#xA;        let word = expand(word)&#xA;      endif&#xA;      let word = shellescape(word, 1)&#xA;    endif&#xA;    call add(words, word)&#xA;  endfor&#xA;  let expanded_cmdline = join(words)&#xA;  botright new&#xA;  setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap&#xA;  call setline(1, 'You entered:  ' . a:cmdline)&#xA;  call setline(2, 'Expanded to:  ' . expanded_cmdline)&#xA;  call append(line('$'), substitute(getline(2), '.', '=', 'g'))&#xA;  silent execute '$read !'. expanded_cmdline&#xA;  1&#xA;endfunction&#xA;&#xA;command! -complete=file -nargs=* RunJS call s:RunShellCommand('node '.&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then if you run &lt;code&gt;:RunJS %&lt;/code&gt; you should get a new buffer with the output of your node.js execution. Optionally you can call things directly using &lt;code&gt;:Shell &amp;lt;cmd&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2015-04-10T13:42:57.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2880" PostTypeId="1" CreationDate="2015-04-10T14:01:10.037" Score="2" ViewCount="466" Body="&lt;p&gt;I installed spf13-vim on OS X and when I started do edit a file I get the following errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function neosnippet#init#_initialize&#xA;&#xA;Cannot create directory: /Users/.../.cache/neosnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suspect that the error is raised because neosnippet plugin does not have permissions to write in the &lt;code&gt;.cache&lt;/code&gt; directory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anybody can help me to fix that?&lt;/p&gt;&#xA;" OwnerUserId="1685" LastEditorUserId="23502" LastEditDate="2022-10-24T06:19:25.080" LastActivityDate="2022-10-24T06:19:25.080" Title="spf13-vim - Error with neosnippet plugin when editing a file" Tags="|filesystem|plugin-spf13|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2881" PostTypeId="2" ParentId="2878" CreationDate="2015-04-10T14:28:52.100" Score="1" Body="&lt;pre&gt;&lt;code&gt;$F&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This goes to the end of the line, and searches backwards for &lt;code&gt;&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1569" LastEditorUserId="246" LastEditDate="2015-04-11T00:35:29.117" LastActivityDate="2015-04-11T00:35:29.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2882" PostTypeId="2" ParentId="2878" CreationDate="2015-04-10T14:53:50.460" Score="6" Body="&lt;p&gt;@Kent's solution assumes a single string in the line. Another approach is (mis-)using the &lt;em&gt;a / inner quoted string&lt;/em&gt; text object (&lt;code&gt;a&quot;&lt;/code&gt; / &lt;code&gt;i&quot;&lt;/code&gt;), through visual mode:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;va&quot;&amp;lt;Esc&amp;gt;&lt;/code&gt;    for &lt;code&gt;:set selection=inclusive&lt;/code&gt; (default)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vi&quot;&amp;lt;Esc&amp;gt;&lt;/code&gt;    for &lt;code&gt;:set selection=exclusive&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;@Kent's solution also doesn't work as a single, atomic &lt;code&gt;{motion}&lt;/code&gt;, so you cannot use it after commands like &lt;code&gt;d&lt;/code&gt; or &lt;code&gt;y&lt;/code&gt;. That can be done via the &lt;a href=&quot;https://github.com/tommcdo/vim-ninja-feet&quot;&gt;vim ninja feet plugin&lt;/a&gt; as &lt;code&gt;d]i&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-10T14:53:50.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2883" PostTypeId="1" CreationDate="2015-04-10T16:08:22.190" Score="39" ViewCount="3215" Body="&lt;p&gt;I have some concealed characters in the buffer and horizontal scrolling kills the alignment big time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way how to disable it? I could not find any relevant options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/KRQBA.gif&quot; alt=&quot;bad horizontal scrolling demo&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Demo added. You can see vim bases the scrolling offset on the unconcealed portion of the file, therefore the aligment breaks.&lt;/p&gt;&#xA;" OwnerUserId="1687" LastEditorUserId="4472" LastEditDate="2017-09-16T14:35:26.137" LastActivityDate="2023-08-25T10:43:07.310" Title="How to disable horizontal scrolling?" Tags="|scrolling|conceal|" AnswerCount="4" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="2884" PostTypeId="2" ParentId="2846" CreationDate="2015-04-10T19:17:44.327" Score="0" Body="&lt;p&gt;It doesn't answer your specific question about reformatting, but 'set wrap' together with 'set linebreak' can make editing long lines much more pleasant.  Combine this with gj and gk to navigate within wrapped lines.  I map the up and down arrows to gj and gk respectively so that I have a choice between moving up and down real lines or visual lines.  Like wise for Home / End to g0 / g$.&lt;/p&gt;&#xA;" OwnerUserId="1688" LastActivityDate="2015-04-10T19:17:44.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2885" PostTypeId="2" ParentId="2845" CreationDate="2015-04-10T19:41:11.777" Score="3" Body="&lt;p&gt;For local file system listings, the netrw plugin uses Vim's &lt;code&gt;getfsize()&lt;/code&gt; function. Its value would need to be converted to human units. Luckily, my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4433&quot; rel=&quot;nofollow&quot;&gt;ingo-library plugin&lt;/a&gt; provides such a function, so the following patch extends netrw (of the latest alpha version v154a from &lt;a href=&quot;http://www.drchip.org/astronaut/vim/#NETRW&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;) in such way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- netrw.vim.orig  2015-04-10 20:45:06.094760300 +0200&#xA;+++ netrw.vim   2015-04-10 20:47:38.387988100 +0200&#xA;@@ -9934,7 +9934,7 @@ fun! s:LocalListing()&#xA;&quot;   call Decho(&quot;pfile   &amp;lt;&quot;.pfile.&quot;&amp;gt;&quot;)&#xA;&#xA;    if w:netrw_liststyle == s:LONGLIST&#xA;-    let sz   = getfsize(filename)&#xA;+    let sz   = join(ingo#units#FormatBytesBinary(getfsize(filename)))&#xA;    let fsz  = strpart(&quot;               &quot;,1,15-strlen(sz)).sz&#xA;    let pfile= pfile.&quot;\t&quot;.fsz.&quot; &quot;.strftime(g:netrw_timefmt,getftime(filename))&#xA;&quot;    call Decho(&quot;sz=&quot;.sz.&quot; fsz=&quot;.fsz)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you also want relative file modification dates (e.g. &lt;em&gt;5 minutes ago&lt;/em&gt;) via a new option value &lt;code&gt;g:netrw_timefmt = 'relative'&lt;/code&gt;, you can apply the following patch instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- netrw.vim.orig  2015-04-10 20:45:06.094760300 +0200&#xA;+++ netrw.vim   2015-04-10 20:55:40.937242900 +0200&#xA;@@ -9934,9 +9934,9 @@ fun! s:LocalListing()&#xA;&quot;   call Decho(&quot;pfile   &amp;lt;&quot;.pfile.&quot;&amp;gt;&quot;)&#xA;&#xA;    if w:netrw_liststyle == s:LONGLIST&#xA;-    let sz   = getfsize(filename)&#xA;+    let sz   = join(ingo#units#FormatBytesBinary(getfsize(filename)))&#xA;    let fsz  = strpart(&quot;               &quot;,1,15-strlen(sz)).sz&#xA;-    let pfile= pfile.&quot;\t&quot;.fsz.&quot; &quot;.strftime(g:netrw_timefmt,getftime(filename))&#xA;+    let pfile= pfile.&quot;\t&quot;.fsz.&quot;  &quot;.(g:netrw_timefmt ==# 'relative' ? ingo#date#HumanReltime(localtime() - getftime(filename)) : strftime(g:netrw_timefmt,getftime(filename)))&#xA;&quot;    call Decho(&quot;sz=&quot;.sz.&quot; fsz=&quot;.fsz)&#xA;    endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-10T19:41:11.777" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2886" PostTypeId="2" ParentId="2880" CreationDate="2015-04-10T21:10:56.387" Score="2" Body="&lt;p&gt;If It isn't able to read/write to that directory, there are configuration settings to change the cache directory.  According to the &lt;a href=&quot;https://github.com/Shougo/neosnippet.vim/blob/master/doc/neosnippet.txt#L233&quot; rel=&quot;nofollow&quot;&gt;neosnippet documentation&lt;/a&gt;, you can choose the cache directory using the &lt;code&gt;g:neosnippet#data_directory&lt;/code&gt; variable.  Like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:neosnippet#data_directory = &quot;/path/to/cache/&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-05-26T23:35:55.807" LastActivityDate="2015-05-26T23:35:55.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2887" PostTypeId="5" CreationDate="2015-04-10T21:16:09.560" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-04-10T21:16:09.560" LastActivityDate="2015-04-10T21:16:09.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2888" PostTypeId="4" CreationDate="2015-04-10T21:16:09.560" Score="0" Body="Text objects are high level text constructs such as sentences, words, and paragraphs.  These are represented in vim as key shortcuts." OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-04-12T19:07:52.150" LastActivityDate="2015-04-12T19:07:52.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2889" PostTypeId="1" AcceptedAnswerId="2891" CreationDate="2015-04-11T04:04:18.667" Score="4" ViewCount="1150" Body="&lt;p&gt;Is there a way to define a sorting precedence regarding the line's pattern and then use it with &lt;code&gt;:sort&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I have these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 some text (foo) some other text&#xA;2 some text (bar) some other text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to define a sorting precedence which says that a line containing &lt;code&gt;foo&lt;/code&gt; is greater than a line containing &lt;code&gt;bar&lt;/code&gt;, so when I execute &lt;code&gt;:sort&lt;/code&gt;, it will sort the lines like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 some text (bar) some other text&#xA;2 some text (foo) some other text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know adding a pattern after the command and the option &lt;code&gt;r&lt;/code&gt; will sort the line using the matched string on the lines, but still these strings are sorted by their lexicographical order and that doesn't work for me.&lt;/p&gt;&#xA;" OwnerUserId="1690" LastEditorUserId="7161" LastEditDate="2016-05-16T10:24:33.913" LastActivityDate="2016-05-16T10:24:33.913" Title="User-defined sorting precedence" Tags="|vimscript|sort|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2890" PostTypeId="1" AcceptedAnswerId="2892" CreationDate="2015-04-11T04:14:14.480" Score="6" ViewCount="984" Body="&lt;p&gt;I'm trying to make Vim play nice with wrapped lines and I'm running into some problems. The following line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;expr&amp;gt; k ((v:count == 0) || (mode() !=# &quot;V&quot;) ? 'gk' : 'k')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives me the following error when launching Vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /cygdrive/c/Users/Chad/.vimrc:&#xA;line   76:&#xA;E749: empty buffer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I remove either of the conditions the map will work fine but I'd like to combine them. Any ideas? Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="200" LastEditorUserId="51" LastEditDate="2015-05-03T17:14:27.303" LastActivityDate="2015-05-03T17:14:27.303" Title="What is wrong with this mapping expression in my .vimrc?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2891" PostTypeId="2" ParentId="2889" CreationDate="2015-04-11T04:38:44.967" Score="3" Body="&lt;p&gt;I read a little bit more, and there's a function in vimscript called &lt;code&gt;sort()&lt;/code&gt; which can receive a function to compare both items. Here's the help page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;sort({list} [, {func} [, {dict}]])                      sort() E702&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            Sort the items in {list} in-place.  Returns {list}.  If you&#xA;            want a list to remain unmodified make a copy first:&#xA;                    :let sortedlist = sort(copy(mylist))&#xA;            Uses the string representation of each item to sort on.&#xA;            Numbers sort after Strings, Lists after Numbers.&#xA;            For sorting text in the current buffer use :sort.&#xA;            When {func} is given and it is one then case is ignored.&#xA;            {dict} is for functions with the &quot;dict&quot; attribute.  It will be&#xA;            used to set the local variable &quot;self&quot;. Dictionary-function&#xA;            When {func} is a Funcref or a function name, this function&#xA;            is called to compare items.  The function is invoked with two&#xA;            items as argument and must return zero if they are equal, 1 or&#xA;            bigger if the first one sorts after the second one, -1 or&#xA;            smaller if the first one sorts before the second one.&#xA;            Example:&#xA;                    func MyCompare(i1, i2)&#xA;                       return a:i1 == a:i2 ? 0 : a:i1 &amp;gt; a:i2 ? 1 : -1           &#xA;                    endfunc&#xA;                    let sortedlist = sort(mylist, &quot;MyCompare&quot;)&#xA;            A shorter compare version for this specific simple case, which&#xA;            ignores overflow:&#xA;                    func MyCompare(i1, i2)&#xA;                       return a:i1 - a:i2&#xA;                    endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Compare function&#xA;fu! MyCompare(i1, i2)&#xA;    let l:score1 = i1 =~ '.\{-}(foo)' ? 2 : i1 =~ '.\{-}(bar)' ? 1 : 0&#xA;    let l:score2 = i2 =~ '.\{-}(foo)' ? 2 : i2 =~ '.\{-}(bar)' ? 1 : 0&#xA;&#xA;    return l:score1 == l:score2 ? 0 : l:score1 &amp;gt; l:score2 ? 1 : -1    &#xA;endfu&#xA;&#xA;&quot;Function to sort the lines&#xA;fu! SortLines(linestart, lineend)&#xA;    let l:lines = getline(a:linestart, a:lineend)&#xA;    sort(l:lines,&quot;MyCompare&quot;)&#xA;&#xA;    &quot; Put the sorted lines in the file&#xA;    let l:nlines = a:lineend - a:linestart&#xA;    exe 'normal! '.a:linestart.'G'.l:nlines.'dd'&#xA;    let @l = join(l:lines, &quot;\n&quot;)&#xA;    exe 'normal! '.a:linestart.'G&quot;lP'&#xA;endfu&#xA;&#xA;&quot; Calling the function&#xA;:call SortLines(1,2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1690" LastEditorUserId="1690" LastEditDate="2015-04-11T04:47:54.390" LastActivityDate="2015-04-11T04:47:54.390" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2892" PostTypeId="2" ParentId="2890" CreationDate="2015-04-11T05:15:50.217" Score="7" Body="&lt;p&gt;See &lt;code&gt;:h map_bar&lt;/code&gt;. The &lt;code&gt;|&lt;/code&gt; is used also as a command separator in vim, so you are executing a map command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;expr&amp;gt; k ((v:count == 0) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then an empty command line, and after that a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(mode() !=# &quot;V&quot;) ? 'gk' : 'k')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use the &lt;code&gt;|&lt;/code&gt; character in mappings, the two best options in my opinion are &lt;code&gt;&amp;lt;Bar&amp;gt;&lt;/code&gt; or &lt;code&gt;\|&lt;/code&gt;. Your mapping can be written as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;expr&amp;gt; k ((v:count == 0) &amp;lt;Bar&amp;gt;&amp;lt;Bar&amp;gt; (mode() !=# &quot;V&quot;) ? 'gk' : 'k')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for example.&lt;/p&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2015-04-11T05:15:50.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2893" PostTypeId="1" AcceptedAnswerId="2894" CreationDate="2015-04-11T07:13:34.643" Score="2" ViewCount="93" Body="&lt;p&gt;I've installed node plugin, which give possibility to display all lines that contain the keyword under the cursor using &lt;code&gt;[I&lt;/code&gt; hotkey. It looks like this:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/jb6Gv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there possibility to jump to them?&lt;/p&gt;&#xA;" OwnerUserId="500" LastActivityDate="2015-04-11T10:49:32.063" Title="How to jump to the location which [I points to?" Tags="|key-bindings|filetype-javascript|include|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2894" PostTypeId="2" ParentId="2893" CreationDate="2015-04-11T09:13:59.050" Score="3" Body="&lt;p&gt;That feature is built-in, it has nothing to do with that &quot;node&quot; plugin. It's called &quot;include search&quot; and you can read all about it in &lt;code&gt;:help include-search&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have a few ways to jump to an item in the list:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:136&amp;lt;CR&amp;gt;&lt;/code&gt; will jump to line 136 but &lt;em&gt;it is obviously restricted to the current buffer&lt;/em&gt; and you only jump to the line, not the match,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:ijump 3 &amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; will jump to the third item in the list, across buffers,&lt;/li&gt;&#xA;&lt;li&gt;going back to normal mode and doing &lt;code&gt;3[&amp;lt;C-i&amp;gt;&lt;/code&gt; has the same effect as above.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But those methods aren't particularly easy on the fingers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create a simple custom mapping to make it a lot smoother:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap [I [I:ijump  &amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;&amp;lt;S-Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a simplistic demo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/NkD18.gif&quot; alt=&quot;silly demo&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also &lt;a href=&quot;https://gist.github.com/romainl/3c7ee68125f822ec550c&quot; rel=&quot;nofollow noreferrer&quot;&gt;this gist of mine&lt;/a&gt; that overrides the native &lt;code&gt;[I&lt;/code&gt; (among others) to use the much more powerful quickfix list/window:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qIMby.gif&quot; alt=&quot;Ilist()&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-04-11T10:49:32.063" LastActivityDate="2015-04-11T10:49:32.063" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2895" PostTypeId="1" CreationDate="2015-04-11T22:57:05.740" Score="3" ViewCount="470" Body="&lt;p&gt;I decided that I have to get rid of a couple of annoying things which decrease my productivity in Vim. I know they must have a simple solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my first question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I copy a word in clipboard using &lt;code&gt;yw&lt;/code&gt; for example, and I want to copy this word to some other spot (or, very often, more spots), but meanwhile I have to delete something and I use &lt;code&gt;x&lt;/code&gt; or &lt;code&gt;dw&lt;/code&gt;, the clipboard is overwritten, and I am not able to finish the task I intended. I could enter the insert mode and use &lt;code&gt;delete&lt;/code&gt; key but that is of course too much work. How do you behave in this situation and what strategy do you use?&lt;/p&gt;&#xA;" OwnerUserId="1695" LastActivityDate="2015-04-12T00:49:16.993" Title="&quot;x&quot; overwrites clipboard, I am not able to finish the copy-pase action" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ClosedDate="2015-04-12T19:07:38.337" ContentLicense="CC BY-SA 3.0" />
  <row Id="2896" PostTypeId="2" ParentId="2895" CreationDate="2015-04-12T00:49:16.993" Score="5" Body="&lt;p&gt;For the case of yanking one thing, deleting others, then pasting the yanked text instead of deleted text, I use the last-yanked register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;from &lt;code&gt;:help &quot;0&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim fills these registers with text from yank and delete commands.&#xA;     Numbered register 0 contains the text from the most recent yank command,&#xA;  unless the command specified another register with [&quot;x].&#xA;     Numbered register 1 contains the text deleted by the most recent delete or&#xA;  change command, unless the command specified another register or the text is&#xA;  less than one line (the small delete register is used then).  An exception is&#xA;  made for the delete operator with these movement commands: %, (, ), `,&#xA;  /, ?, n, N, { and }.  Register &quot;1 is always used then (this is Vi&#xA;  compatible).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, after &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; and then some &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; (or whatever), I can paste the yanked text with &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more complicated tasks (deleting multiple things and pasting the different multiple things) I either anticipate ahead of time and use named registers (e.g. &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;), or check the contents of the numbered registers after the deletions to see which ones have what I want to paste, using &lt;code&gt;:registers&lt;/code&gt;, which might show something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;0   char *^J&#xA;&quot;1   ^I^I^Iint utf8flag = 1;^J&#xA;&quot;2   ^Istruct window^I^I*w^J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I want the struct window line, I'd then do &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-04-12T00:49:16.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2897" PostTypeId="2" ParentId="2875" CreationDate="2015-04-12T09:24:22.677" Score="2" Body="&lt;p&gt;Here is what I did in the end:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Removed &lt;code&gt;xolox/vim-easytags&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Removed &lt;code&gt;xolox/vim-misc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Replaced&#xA;&lt;code&gt;kien/ctrlp&lt;/code&gt; &lt;code&gt;d11wtq/ctrlp_bdelete&lt;/code&gt; and &lt;code&gt;tacahiroy/ctrlp-funky&lt;/code&gt; with&#xA;&lt;code&gt;junegunn/fzf&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;Set &lt;code&gt;regexpengine=1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Right now Vim is smooth like butter but I don't have tags anymore. Sigh...&lt;/p&gt;&#xA;" OwnerUserId="237" LastActivityDate="2015-04-12T09:24:22.677" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2899" PostTypeId="2" ParentId="2630" CreationDate="2015-04-12T20:06:41.513" Score="1" Body="&lt;p&gt;Try vim-gutentags: &lt;a href=&quot;https://github.com/ludovicchabant/vim-gutentags&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ludovicchabant/vim-gutentags&lt;/a&gt; It automatically generates tags for you. A word of warning though, this plugin will automatically regenerate tags after each save so it might slow you down overall. Also it'll generate tags for whatever file you have opened so you might end up with tags file in your dotfiles folder. If you want to disable tags generation for project read this: &lt;a href=&quot;https://github.com/ludovicchabant/vim-gutentags/commit/7316197a7f884e264e20590cbad90046d8337fbb&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ludovicchabant/vim-gutentags/commit/7316197a7f884e264e20590cbad90046d8337fbb&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I've been using it for quite some time and if configured properly this plugin can be a huge time saver but YMMV.&lt;/p&gt;&#xA;" OwnerUserId="428" LastActivityDate="2015-04-12T20:06:41.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2900" PostTypeId="1" CreationDate="2015-04-12T21:05:57.957" Score="1" ViewCount="238" Body="&lt;p&gt;In a netrw listing, when I press &lt;code&gt;-&lt;/code&gt; key to go up a directory, I would like the cursor placed on the line corresponding to the dir I have just left (exactly how happens on some file managers, e.g. Nemo). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&#xA;I'm in a directory named 'foo', I press &lt;code&gt;-&lt;/code&gt; and on the listing of parent dir, the cursor is placed on the line corresponding to 'foo/'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to instruct netrw to do so?&lt;/p&gt;&#xA;" OwnerUserId="311" LastEditorUserId="311" LastEditDate="2015-04-12T22:33:07.450" LastActivityDate="2015-04-14T21:14:18.507" Title="netrw: have the cursor placed on previous cwd name when going up dir" Tags="|filesystem|netrw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2901" PostTypeId="2" ParentId="2900" CreationDate="2015-04-12T21:05:57.957" Score="2" Body="&lt;p&gt;After some attempts, I found a tailored solution which works for me (feel free to improve on it). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I save the name of current directory, go up dir, then search the name of saved cwd (with trailing &lt;code&gt;/&lt;/code&gt;) to place the cursor on previous directory name line.&lt;br&gt;&#xA;Also I mapped this key-sequence to the &lt;code&gt;&amp;lt;Backspace&amp;gt;&lt;/code&gt; key (to be active on a netrw buffer only).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the line I added to my .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;au FileType netrw nmap &amp;lt;buffer&amp;gt; &amp;lt;Backspace&amp;gt; :let @z=expand(&quot;%:t&quot;)&amp;lt;CR&amp;gt;-/\&amp;lt;&amp;lt;C-R&amp;gt;=@z&amp;lt;CR&amp;gt;/\&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="311" LastEditorUserId="311" LastEditDate="2015-04-14T21:14:18.507" LastActivityDate="2015-04-14T21:14:18.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2902" PostTypeId="2" ParentId="2630" CreationDate="2015-04-13T05:04:22.653" Score="1" Body="&lt;p&gt;There is a nice post on using git hooks for managing ctags by tpope:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html&quot; rel=&quot;nofollow&quot;&gt;http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="237" LastActivityDate="2015-04-13T05:04:22.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2903" PostTypeId="2" ParentId="2836" CreationDate="2015-04-13T12:03:10.357" Score="0" Body="&lt;p&gt;Thanks to &lt;a href=&quot;https://vi.stackexchange.com/users/1641/rick-howe&quot;&gt;Rick Howe&lt;/a&gt;, who &lt;a href=&quot;https://vi.stackexchange.com/a/2841/1634&quot;&gt;answered&lt;/a&gt; and then emailed me the following script, we have a perfect solution for my question. Rick Howe's script highlights the longest common subsequence (LCS) in each line pair of two vimdiff buffers. When equal-length LCS matches are found, they are highlighted in different colors.&lt;/p&gt;&#xA;&lt;h3&gt;Credit&lt;/h3&gt;&#xA;&lt;p&gt;Rick Howe's wrote this script, I didn't. Rick's script is posted here with his permission.&lt;/p&gt;&#xA;&lt;p&gt;I only added a couple of lines to suspend difference highlights so that LCS matches stand out more clearly. I also changed highlighting groups to choices that should work for the standard color scheme in vim and gvim on linux. Resulting colors aren't exactly pretty, but they work in cterm and gui with no need to fiddle them (you &lt;em&gt;can&lt;/em&gt; change &lt;code&gt;g:hlt&lt;/code&gt; if you really want). Here's a vim (top) and gvim (bottom) screencap.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Hvaa4.png&quot; alt=&quot;screen capture of longest common subsequence vim diff script output&quot; /&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Usage&lt;/h3&gt;&#xA;&lt;p&gt;Save the script as &lt;code&gt;lcs.vim&lt;/code&gt; and put it in a folder included in the &lt;code&gt;runtimepath&lt;/code&gt; option list, then start vimdiff: &lt;code&gt;vim -d +&amp;quot;runtime lcs.vim&amp;quot; A B&lt;/code&gt; and press &lt;code&gt;F4&lt;/code&gt; to toggle highlighting LCS.&lt;/p&gt;&#xA;&lt;h3&gt;lcs.vim&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;F4&amp;gt; :call &amp;lt;SID&amp;gt;ToggleHighlightLCS()&amp;lt;CR&amp;gt;&#xA;&#xA;&amp;quot; Cycle through these groups to highlight equal-length LCS in each line.&#xA;&amp;quot; You may change this choice but do not include Diff* groups, i.e., DiffAdd.&#xA;let g:hlt = [&amp;quot;MatchParen&amp;quot;, &amp;quot;TabLineFill&amp;quot;, &amp;quot;Error&amp;quot;, &amp;quot;Folded&amp;quot;]&#xA;&#xA;function! s:ToggleHighlightLCS()&#xA;    if winnr('$') &amp;lt; 2 | echo &amp;quot;Need more windows&amp;quot; | return | endif&#xA;    let win1 = winnr()&#xA;    let win2 = win1 % winnr('$') + 1&#xA;    if exists(&amp;quot;t:mid&amp;quot;)&#xA;        for [w, mid] in t:mid&#xA;            exec w . &amp;quot;wincmd w&amp;quot;&#xA;            call map(mid, 'matchdelete(v:val)')&#xA;        endfor&#xA;        unlet t:mid&#xA;        exec win1 . &amp;quot;wincmd w&amp;quot;&#xA;        exec join(map([&amp;quot;Add&amp;quot;,&amp;quot;Text&amp;quot;,&amp;quot;Change&amp;quot;,&amp;quot;Delete&amp;quot;], '&amp;quot;hi! link Diff&amp;quot;.v:val.&amp;quot; NONE&amp;quot;'),&amp;quot;|&amp;quot;)&#xA;        return&#xA;    endif&#xA;    let ln1 = getbufline(winbufnr(win1), 1, '$')&#xA;    let ln2 = getbufline(winbufnr(win2), 1, '$')&#xA;    let lcs = map(range(min([len(ln1), len(ln2)])),&#xA;                    \'s:FindLCS(ln1[v:val], ln2[v:val])')&#xA;    let t:mid = []&#xA;    for w in [win1, win2]&#xA;        exec w . &amp;quot;wincmd w&amp;quot;&#xA;        let mid = []&#xA;        for n in range(len(lcs))&#xA;            let mid += map(map(copy(lcs[n]),&#xA;                \'(&amp;amp;ic ? &amp;quot;\\c&amp;quot; : &amp;quot;\\C&amp;quot;) .&#xA;                \&amp;quot;\\V\\%&amp;quot; . (n + 1) . &amp;quot;l&amp;quot; .&#xA;                \escape(v:val, &amp;quot;\\&amp;quot;)'),&#xA;                \'matchadd(g:hlt[v:key % len(g:hlt)], v:val)')&#xA;        endfor&#xA;        let t:mid += [[w, mid]]&#xA;    endfor&#xA;    exec win1 . &amp;quot;wincmd w&amp;quot;&#xA;    exec join(map([&amp;quot;Add&amp;quot;,&amp;quot;Text&amp;quot;,&amp;quot;Change&amp;quot;,&amp;quot;Delete&amp;quot;], '&amp;quot;hi! link Diff&amp;quot;.v:val.&amp;quot; Normal&amp;quot;'),&amp;quot;|&amp;quot;)&#xA;endfunction&#xA;&#xA;function! s:FindLCS(str1, str2)&#xA;    let [len1, len2] = [strchars(a:str1), strchars(a:str2)]&#xA;    let [lng, sht, len] = (len1 &amp;gt;= len2) ?&#xA;            \[a:str1, a:str2, len2] : [a:str2, a:str1, len1]&#xA;    let idx = map(range(len + 1), 'byteidx(sht, v:val)')&#xA;    for n in range(len, 1, -1)&#xA;        let lcs = []&#xA;        for p in range(0, len - n)&#xA;            let s = sht[idx[p] : idx[p + n] - 1]&#xA;            if !count(lcs, s, &amp;amp;ic) | let lcs += [s] | endif&#xA;        endfor&#xA;        call filter(lcs, 'lng =~ &amp;quot;\\V&amp;quot; . escape(v:val, &amp;quot;\\&amp;quot;)')&#xA;        if !empty(lcs) | break | endif&#xA;    endfor&#xA;    return lcs&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1634" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-04-13T12:03:10.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2904" PostTypeId="1" AcceptedAnswerId="2905" CreationDate="2015-04-13T14:22:10.977" Score="30" ViewCount="12054" Body="&lt;p&gt;One thing I often do (but rely on the command line to do) is searching/grepping in multiple files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to display search results for all the open buffers?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I'd like to have a new split buffer containing result location and snippet much like &lt;code&gt;grep&lt;/code&gt; does. For example (&lt;code&gt;/statistics&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;models/statistics.php: /*! \file   statistics.php&#xA;controllers/stats.php: $this-&amp;gt;load-&amp;gt;model('statistics');&#xA;controllers/stats.php: // Query statistics...&#xA;controllers/stats.php: $num_exams = $this-&amp;gt;statistics-&amp;gt;countExams();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a bonus, I'd like to be able to search for the term under the cursor, pretty much like &lt;code&gt;gd&lt;/code&gt; does.&lt;/p&gt;&#xA;" OwnerUserId="475" LastActivityDate="2021-03-23T07:31:59.497" Title="How to show search results for all open buffers" Tags="|search|multiple-files|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2905" PostTypeId="2" ParentId="2904" CreationDate="2015-04-13T15:05:56.737" Score="25" Body="&lt;p&gt;You can use &lt;code&gt;:vimgrep /pattern/ {files}&lt;/code&gt; to populate the quickfix list with matching patterns. The problem is that &lt;code&gt;:vimgrep&lt;/code&gt; files option doesn't directly allow for buffers. You can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%   Is replaced with the current file name.       *:_%* *c_%*&#xA;#   Is replaced with the alternate file name.     *:_#* *c_#*&#xA;#n  (where n is a number) is replaced with        *:_#0* *:_#n*&#xA;    the file name of buffer n.  &quot;#0&quot; is the same as &quot;#&quot;.     *c_#n*&#xA;##  Is replaced with all names in the argument list   *:_##* *c_##*&#xA;    concatenated, separated by spaces.  Each space in a name&#xA;    is preceded with a backslash.&#xA;#&amp;lt;n (where n is a number &amp;gt; 0) is replaced with old    *:_#&amp;lt;* *c_#&amp;lt;*&#xA;    file name n.  See |:oldfiles| or |v:oldfiles| to get the&#xA;    number.                         *E809*&#xA;    {only when compiled with the |+eval| and |+viminfo| features}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another option is to write a script that generates a file list from &lt;code&gt;:buffers&lt;/code&gt;. Per &lt;a href=&quot;https://stackoverflow.com/questions/271364/variable-that-holds-list-of-all-open-buffers-in-vim&quot;&gt;this SO post&lt;/a&gt; with a slight tweek we get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BuffersList()&#xA;  let all = range(0, bufnr('$'))&#xA;  let res = []&#xA;  for b in all&#xA;    if buflisted(b)&#xA;      call add(res, bufname(b))&#xA;    endif&#xA;  endfor&#xA;  return res&#xA;endfunction&#xA;&#xA;function! GrepBuffers (expression)&#xA;  exec 'vimgrep/'.a:expression.'/ '.join(BuffersList())&#xA;endfunction&#xA;&#xA;command! -nargs=+ GrepBufs call GrepBuffers(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can now call &lt;code&gt;:GrepBufs &amp;lt;expression&amp;gt;&lt;/code&gt; and get the standard &lt;code&gt;:vimgrep&lt;/code&gt; output but using the buffers instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt; If you would like to call &lt;code&gt;GrepBuffers&lt;/code&gt; using the value under the cursor add this new mapping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;z :call GrepBuffers(&quot;&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you are in normal mode type &lt;code&gt;&amp;lt;leader&amp;gt;z&lt;/code&gt; and you'll &lt;code&gt;:vimgrep&lt;/code&gt; the cursor word over your open buffers.&lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-04-13T20:20:59.643" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2906" PostTypeId="1" CreationDate="2015-04-13T15:06:05.800" Score="8" ViewCount="4142" Body="&lt;p&gt;Vim has some fancy pants indentation stuff. When it works right it's a pleasure to have, but sometimes it just drives me nuts. One that I've never been able to solve has to do with LaTeX syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say you have this file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a test paragraph. Most of it is innocuous, but the \textit{inline markup code happens to fall over a line break} which is a problem.&#xA;&#xA;% vim: autoindent textwidth=79 ft=tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you put your cursor in the first line and hit &lt;code&gt;gqip&lt;/code&gt; to reformat the paragraph, it will format it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a test paragraph. Most of it is innocuous, but the \textit{inline&#xA;    markup code happens to fall over a line break} which is a problem.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what I would like is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a test paragraph. Most of it is innocuous, but the \textit{inline&#xA;markup code happens to fall over a line break} which is a problem.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course I still &lt;em&gt;do&lt;/em&gt; want it to auto-indent when I hit enter on a line ending in &lt;code&gt;{&lt;/code&gt; (or &lt;code&gt;{%&lt;/code&gt;. I also want to follow the indent of the previous line, so if I reformat:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    This is a test paragraph. Most of it is innocuous, but the \textit{inline markup code happens to fall over a line break} which is a problem.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    This is a test paragraph. Most of it is innocuous, but the \textit{inline&#xA;    markup code happens to fall over a line break} which is a problem.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can correct only the use case behavior of formatting paragraphs that have inline markup without affecting other usage scenarios?&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="1292" LastEditDate="2019-07-11T08:01:33.457" LastActivityDate="2019-07-11T08:01:33.457" Title="How can I fix the auto indentation in LaTeX?" Tags="|indentation|filetype-tex|plugin-atp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2907" PostTypeId="2" ParentId="2904" CreationDate="2015-04-13T15:35:04.400" Score="7" Body="&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4173&quot;&gt;GrepCommands plugin&lt;/a&gt; defines variants of the built-in &lt;code&gt;:vimgrep&lt;/code&gt; command which target all arguments, listed buffers, windows in the current tab page or all tab&#xA;pages for its search. Basically, a robust plugin implementation of @jecxjo's answer.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-13T15:35:04.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2908" PostTypeId="5" CreationDate="2015-04-13T17:21:15.127" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-04-13T17:21:15.127" LastActivityDate="2015-04-13T17:21:15.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2909" PostTypeId="4" CreationDate="2015-04-13T17:21:15.127" Score="0" Body="A colorscheme is a Vim script which sets the colors to be used for the highlight groups." OwnerUserId="865" LastEditorUserId="51" LastEditDate="2015-04-28T12:24:12.413" LastActivityDate="2015-04-28T12:24:12.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2910" PostTypeId="2" ParentId="2904" CreationDate="2015-04-13T17:25:52.353" Score="13" Body="&lt;p&gt;Searching in only opened buffers is nice, but there may come a time where you want to search across an entire project. It can be faster and easier than you think!&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Searching across a project&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;grep&lt;/code&gt; is the Unix standard search tool. Worth mentioning due to its ubiquity. Already integrated into Vim via &lt;code&gt;:grep&lt;/code&gt; command. e.g. &lt;code&gt;:grep -r 'foo'&lt;/code&gt;. See &lt;code&gt;:h :grep&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://beyondgrep.com/&quot; rel=&quot;noreferrer&quot;&gt;Ack&lt;/a&gt; is faster than regular grep because it skips VCS directories, binary files, and can search for specific type of filetypes like &lt;code&gt;--perl&lt;/code&gt;. For Vim integration see &lt;a href=&quot;https://github.com/mileszs/ack.vim&quot; rel=&quot;noreferrer&quot;&gt;Ack.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;noreferrer&quot;&gt;Ag the Silver Surfer&lt;/a&gt; is a code-searching tool similar to ack, but faster. Vim plugin: &lt;a href=&quot;https://github.com/rking/ag.vim&quot; rel=&quot;noreferrer&quot;&gt;Ag.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;git grep&lt;/code&gt; searches a repository very quickly. &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;noreferrer&quot;&gt;Fugitive.vim&lt;/a&gt; provides &lt;code&gt;:Ggrep&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/BurntSushi/ripgrep&quot; rel=&quot;noreferrer&quot;&gt;Ripgrep&lt;/a&gt; is even faster than Ag and &lt;code&gt;git grep&lt;/code&gt;. Can be used with &lt;code&gt;:grep&lt;/code&gt; as well.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I recommend both ripgrep, Ag, and &lt;code&gt;git grep&lt;/code&gt; as they are all super fast. I have searched over 4700+ in less than a 1 second. It's pretty hard to beat ripgrep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test out one of these alternatives without a plugin or you simply don't want a plugin you can set your &lt;code&gt;'grepprg'&lt;/code&gt; option accordingly. e.g. &lt;code&gt;set grepprg=ag\ --vimgrep&lt;/code&gt; or &lt;code&gt;set grepprg=rg\ --vimgrep&lt;/code&gt;. See &lt;code&gt;:h 'grepprg'&lt;/code&gt; and &lt;code&gt;:h 'grepformat'&lt;/code&gt; for more information. Now you can search via &lt;code&gt;:grep&lt;/code&gt;. e.g. &lt;code&gt;:grep 'foo'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a final fallback you can use &lt;code&gt;:vimgrep&lt;/code&gt; as it is available on all systems that Vim is available. See &lt;code&gt;:h :vimg&lt;/code&gt; for more help.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;QuickFix List&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;As most of these options use the quickfix list I suggest you use some more friendly mappings to transverse the quickfix list. I use Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;noreferrer&quot;&gt;unimpaired&lt;/a&gt; plugin which uses &lt;code&gt;]q&lt;/code&gt; and &lt;code&gt;[q&lt;/code&gt; for &lt;code&gt;:cnext&lt;/code&gt; and &lt;code&gt;:cprev&lt;/code&gt; respectively. Some people like the quickfix to open after a search is performed then add the following to your &lt;code&gt;~/.vimrc&lt;/code&gt; file: &lt;code&gt;autocmd QuickFixCmdPost *grep* cwindow&lt;/code&gt;. You can also manually open the QuickFix list via &lt;code&gt;:copen&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Want even faster &quot;searches&quot;?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You are going to need to use some tool that uses a prebuilt indexes like &lt;a href=&quot;http://ctags.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;ctags&lt;/a&gt;, &lt;a href=&quot;http://cscope.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;cscope&lt;/a&gt;, or &lt;a href=&quot;http://www.gnu.org/software/global/manual/global.html&quot; rel=&quot;noreferrer&quot;&gt;GNU global&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vim has built in ctag support via &lt;code&gt;:tag&lt;/code&gt;, &lt;code&gt;&amp;lt;c-]&amp;gt;&lt;/code&gt;, and many other commands and options. See &lt;code&gt;:h tags&lt;/code&gt;. Also may want to read &lt;a href=&quot;http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html&quot; rel=&quot;noreferrer&quot;&gt;Effortless Ctags with Git&lt;/a&gt; or look into the &lt;a href=&quot;https://github.com/ludovicchabant/vim-gutentags&quot; rel=&quot;noreferrer&quot;&gt;Gutentags&lt;/a&gt; plugin&lt;/li&gt;&#xA;&lt;li&gt;Cscope support is also built in and can be used via &lt;code&gt;:cscope&lt;/code&gt; command. See &lt;code&gt;:h cscope&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;More help&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I would start with this nice &lt;a href=&quot;http://vimcasts.org/&quot; rel=&quot;noreferrer&quot;&gt;Vimcast&lt;/a&gt; episode: &lt;a href=&quot;http://vimcasts.org/episodes/search-multiple-files-with-vimgrep/&quot; rel=&quot;noreferrer&quot;&gt;Search multiple files with &lt;code&gt;:vimgrep&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more Vim help see the documentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h grep&#xA;:h :vimgrep&#xA;:h :grep&#xA;:h 'grepprg'&#xA;:h 'grepformat'&#xA;:h quickfix&#xA;:h :cnext&#xA;:h tags&#xA;:h cscope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-09-17T14:51:21.547" LastActivityDate="2018-09-17T14:51:21.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2911" PostTypeId="2" ParentId="2906" CreationDate="2015-04-13T23:03:33.703" Score="3" Body="&lt;p&gt;The indentation rules for LaTeX are defined in &lt;code&gt;$VIMRUNTIME/indent/tex.vim&lt;/code&gt;.  There are a few configurable variables in there, such as &lt;code&gt;g:tex_indent_brace&lt;/code&gt;, which is set by default.  You could unset it, but that disables all indenting on braces, which is not what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Getting the behavior that you want probably means digging into the &lt;code&gt;GetTexIndent()&lt;/code&gt; function in that file and fixing the way it handles braces, unless you can find somebody that has already done that.&lt;/p&gt;&#xA;" OwnerUserId="1688" LastEditorUserId="21" LastEditDate="2015-04-14T07:55:01.403" LastActivityDate="2015-04-14T07:55:01.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2912" PostTypeId="1" AcceptedAnswerId="3160" CreationDate="2015-04-14T00:37:20.663" Score="10" ViewCount="399" Body="&lt;p&gt;Is there a way to increase/decrease first digit after/under cursor, not the whole number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know it's not how vim works, but is there a plugin that does that? I was unable to find it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is very useful when editing css and in other cases too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;▐margin: 10px&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press &lt;code&gt;CTRL-A&lt;/code&gt; I want to see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;▐margin: 20px&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Actual:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;▐margin: 11px&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="237" LastEditorUserId="8" LastEditDate="2015-04-14T07:25:30.603" LastActivityDate="2015-06-29T16:54:38.413" Title="Like Ctrl-A and Ctrl-X but modify only the first digit" Tags="|key-bindings|arithmetic|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2913" PostTypeId="2" ParentId="2816" CreationDate="2015-04-14T01:03:14.633" Score="0" Body="&lt;p&gt;If I understand your question correctly you are wishing that the split would&#xA;automatically move the cursor location to the bottom of the screen? If thats&#xA;the case then here is a slightly goofy way to handle it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you create a function that performs a &lt;code&gt;split&lt;/code&gt; and then then &lt;code&gt;zb&lt;/code&gt; on both&#xA;halves then you should get the output you desire.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BetterSplit ()&#xA;  split&#xA;  execute &quot;normal zb&quot;&#xA;  wincmd j&#xA;  execute &quot;normal zb&quot;&#xA;  wincmd k&#xA;endfunction&#xA;&#xA;command! -nargs=0 BetterSplit call BetterSplit()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if you call &lt;code&gt;:BetterSplit&lt;/code&gt; you get your nice output. As an added option you can use &lt;code&gt;cabbrev&lt;/code&gt; to modify how &lt;code&gt;:split&lt;/code&gt; is handled and trigger your new function directly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cabbrev split&amp;lt;c-r&amp;gt;=(getcmdtype()==':' &amp;amp;&amp;amp; getcmdpos()==1 ? 'BetterSplit' : 'split')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;:split&lt;/code&gt; operates like &lt;code&gt;:BetterSplit&lt;/code&gt;. One down side is that this doesn't&#xA;allow for &lt;code&gt;:split {filename}&lt;/code&gt; but you could extend this script further and add&#xA;in this support.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2015-04-14T01:03:14.633" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2914" PostTypeId="2" ParentId="2912" CreationDate="2015-04-14T02:10:37.493" Score="9" Body="&lt;h2&gt;Basic increment&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here is a simple macro to perform the action:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;a m`lv$xh&amp;lt;c-a&amp;gt;p``&#xA;:nnoremap &amp;lt;leader&amp;gt;x m`lv$xh&amp;lt;c-x&amp;gt;p``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In normal mode you&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;m`&lt;/code&gt; Mark your location&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;l&lt;/code&gt; move one character to the right&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v$x&lt;/code&gt; cut to the end of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;h&lt;/code&gt; move back to the original position&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; increment (or decrement)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; paste back your cut&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;``&lt;/code&gt; move back to your mark&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Jump to the next number&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you want to jump to the next number (or stay in your current position if on a number) you need a function that checks the current cursored character and possible jump to the next number.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NextNum()&#xA;  let ch = getline(&quot;.&quot;)[col(&quot;.&quot;)-1]&#xA;  if ch !~ &quot;[0-9]&quot;&#xA;    execute &quot;normal! /[0-9]\&amp;lt;cr&amp;gt;&quot;&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;a :call NextNum()&amp;lt;cr&amp;gt;m`lv$xh&amp;lt;c-a&amp;gt;p``&#xA;nnoremap &amp;lt;leader&amp;gt;x :call NextNum()&amp;lt;cr&amp;gt;m`lv$xh&amp;lt;c-x&amp;gt;p``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;NextNum&lt;/code&gt; gets the character under the cursor, checks if its a number and if not searches for the next number. After that the rest is the same. If you want the mapping different just change the &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;a&lt;/code&gt; to what you wish, for example &lt;code&gt;nnoremap &amp;lt;c-a&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Ignoring negatives and numbers higher than 9&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you want to just cycle through digits and not have them act as signed&#xA;integers the following functions will increment and decrement and roll over at 0 and 9.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NextNum()&#xA;  let ch = getline(&quot;.&quot;)[col(&quot;.&quot;)-1]&#xA;  if ch !~ &quot;[0-9]&quot;&#xA;    execute &quot;normal! /[0-9]\&amp;lt;cr&amp;gt;&quot;&#xA;  endif&#xA;endfunction&#xA;&#xA;function! IncDec(val, dec)&#xA;  if a:dec&#xA;    if a:val == 0&#xA;      return 9&#xA;    else&#xA;      return a:val - 1&#xA;    endif&#xA;  else&#xA;    if a:val == 9&#xA;      return 0&#xA;    else&#xA;      return a:val + 1&#xA;    endif&#xA;  endif&#xA;endfunction&#xA;&#xA;function! DoMath(dec)&#xA;  call NextNum()&#xA;  normal! x&#xA;  let @&quot; = IncDec(@&quot;, a:dec)&#xA;  normal! P&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;a :call DoMath(0)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;x :call DoMath(1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when you are on &lt;code&gt;8&lt;/code&gt; and type &lt;code&gt;&amp;lt;leader&amp;gt;a&lt;/code&gt; you get &lt;code&gt;9&lt;/code&gt;. Doing it again results in &lt;code&gt;0&lt;/code&gt;. If you press &lt;code&gt;&amp;lt;leader&amp;gt;x&lt;/code&gt; on &lt;code&gt;0&lt;/code&gt; you get &lt;code&gt;9&lt;/code&gt;. Same goes for negative numbers. The functions cut a single character, increment, decrement or roll over and then paste in place.&lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2015-04-17T13:41:39.510" LastActivityDate="2015-04-17T13:41:39.510" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="2915" PostTypeId="1" AcceptedAnswerId="2946" CreationDate="2015-04-14T03:14:26.787" Score="13" ViewCount="764" Body="&lt;p&gt;I noticed when I sat down to do some work on my MacBook today that at some point recently something had gotten screwed up with respect to my &lt;code&gt;.gvimrc&lt;/code&gt; settings: when I launched MacVim, everything seemed normal except that my window was very small (approximately the default size). Curious, I tried &lt;code&gt;verbose set columns?&lt;/code&gt; which told me &quot;180, last set from ~/.gvimrc&quot; even though the window was &lt;em&gt;obviously&lt;/em&gt; not 180 columns wide. &lt;code&gt;set columns=180&lt;/code&gt; restored the window to the expected width.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the usual debugging and bisection of my RC files, I noticed something unusual. I'm not sure if this is related to my column sizes not applying or not, either way it's curious and I can't figure it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run: &lt;code&gt;mvim -u NONE -c &quot;set columns=100&quot;&lt;/code&gt;, I get a window like this:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/XzVuy.png&quot; alt=&quot;mvim 1&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run &lt;em&gt;exactly the same command&lt;/em&gt; again, I get this:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/eoSqd.png&quot; alt=&quot;mvim 2&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;verbose set co?&lt;/code&gt; reports 100 and 66, respectively, in both cases saying &quot;last set from -c argument.&quot; Repeating the launch command causes the window state to alternate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried nuking &lt;code&gt;.viminfo&lt;/code&gt; between runs; it has no effect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using MacVim snapshot 74 now, although I was on an earlier version when this started happening and upgraded to see if it was just a versioning thing. I'm on 10.10.3, and it's possible that this behavior is due to a MacVim-specific bug that has surfaced as a result of the OS update (which only happened recently). However if I install MacVim on my wife's laptop (running the same OS version) the behavior does not reproduce.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm at a loss. What on earth could be causing this behavior?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;EDIT: After continued debugging, I've noticed it seems to only reproduce this way if I have an external monitor connected to the laptop. This leads me to believe it's some kind of bug.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorDisplayName="user72" LastEditDate="2015-04-15T17:27:58.520" LastActivityDate="2016-03-19T14:55:10.343" Title="Why is MacVim starting differently every other invocation?" Tags="|macvim|startup|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2916" PostTypeId="2" ParentId="2912" CreationDate="2015-04-14T06:29:15.687" Score="5" Body="&lt;p&gt;Here's a version I wrote using a substitute expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;c-a&amp;gt; :s/\d/\=submatch(0) &amp;lt; 9 ? submatch(0) + 1 : submatch(0)/&amp;lt;CR&amp;gt;&#xA;map &amp;lt;c-x&amp;gt; :s/\d/\=submatch(0) &amp;gt; 0 ? submatch(0) - 1 : submatch(0)/&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each one just looks for the first digit character on the line, and adds or subtracts one if it's in the range [0-8] or [1-9], respectively. It has three issues:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It's mostly text manipulation, and only looks at the first character, so it doesn't know if a number is negative. This is fixable, but I like the current behavior as-is.&lt;/li&gt;&#xA;&lt;li&gt;It clobbers the search register: &lt;code&gt;&quot;/&lt;/code&gt;, and if you have hlsearch on, then all numbers in the current buffer will be highlighted when you use this. You can append &lt;code&gt;:noh&amp;lt;CR&amp;gt;&lt;/code&gt; to each of the above &lt;code&gt;map&lt;/code&gt; commands to stop the highlighting, but I don't know how to nicely stop the register from being clobbered.&lt;/li&gt;&#xA;&lt;li&gt;It works on the first number on the line, not the first number after the cursor.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also, if it were me, I'd map the above to &lt;code&gt;&amp;lt;leader&amp;gt;a&lt;/code&gt; and &lt;code&gt;&amp;lt;leader&amp;gt;x&lt;/code&gt;, rather than to &lt;code&gt;CTRL-A/X&lt;/code&gt;. This way, you have both behaviors available to you. &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; is, by default, the backslash key (&lt;code&gt;\&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1710" LastEditorUserId="343" LastEditDate="2015-04-14T07:54:18.040" LastActivityDate="2015-04-14T07:54:18.040" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2917" PostTypeId="2" ParentId="2906" CreationDate="2015-04-14T07:03:24.207" Score="5" Body="&lt;p&gt;The documentation for the indentation plugin for LaTeX is unfortunately not available in the help files, but it is written in the source code in &lt;code&gt;$VIMRUNTIME/indent/tex.vim&lt;/code&gt;. The following variables are available for customization:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:tex_indent_brace&lt;/code&gt;: Toggle smartindent-like style for &lt;code&gt;{}&lt;/code&gt; and &lt;code&gt;[]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:tex_indent_items&lt;/code&gt;: Indent continuation lines after &lt;code&gt;\item&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:tex_items&lt;/code&gt;: Tokens to be recognized as &lt;code&gt;\item&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:tex_itemize_env&lt;/code&gt;: Environments that allow item indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:tex_noindent_env&lt;/code&gt;: Environments that should not be indented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:tex_indent_and&lt;/code&gt;: Whether to align the line with the first &lt;code&gt;&amp;amp;&lt;/code&gt;, i.e. in tables and align environments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By setting the above variables, you may get a more customized indentation experience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There does exist alternative indentation plugins. I'm developing &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;noreferrer&quot;&gt;vimtex&lt;/a&gt;, which provides a function that IMHO is slightly better, although it is not as customizible (I do accept both pull requests and suggestions for improvements). &lt;a href=&quot;https://github.com/LaTeX-Box-Team/LaTeX-Box&quot; rel=&quot;noreferrer&quot;&gt;LaTeX-Box&lt;/a&gt; also provides an indentation plugin. So does &lt;a href=&quot;http://sourceforge.net/projects/atp-vim/&quot; rel=&quot;noreferrer&quot;&gt;Automatic LaTeX plugin for Vim&lt;/a&gt;, and probably/possibly others.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-04-14T07:03:24.207" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2918" PostTypeId="1" AcceptedAnswerId="2992" CreationDate="2015-04-14T07:36:27.823" Score="5" ViewCount="9035" Body="&lt;p&gt;For readability I try to modify my &lt;code&gt;~/.vimrc&lt;/code&gt; to get some proper highlighting. I found &lt;a href=&quot;http://tuxdiary.com/2014/02/17/customize-vimdiff-color-scheme/&quot;&gt;here&lt;/a&gt; to use e.g. this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight DiffChange cterm=none ctermfg=fg ctermbg=Red gui=none guifg=fg guibg=Red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Like said in the link I am getting following warning then: &lt;code&gt;E419: FG color unknown&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't really understand the suggestion to use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight Normal term=none cterm=none ctermfg=White ctermbg=Black gui=none guifg=White guibg=Black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to get rid of that problem but it works. Still all text in vim is written bold (highlighted) afterwards. How do I get rid of this? Or is there a better/simpler possibilty to manipulate the highlighting colors?&lt;/p&gt;&#xA;" OwnerUserId="820" LastActivityDate="2015-04-18T14:10:32.250" Title="Modify vimdiff highlighting" Tags="|vimdiff|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2919" PostTypeId="2" ParentId="2816" CreationDate="2015-04-14T11:22:46.163" Score="3" Body="&lt;p&gt;I found a &lt;a href=&quot;https://stackoverflow.com/q/12897276/151007&quot;&gt;solution&lt;/a&gt; which came from Vim's own help docs.  It's not perfect but it is an improvement.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-W&amp;gt;s Hmx`` \|:split&amp;lt;CR&amp;gt;`xzt``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1643" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-04-14T11:22:46.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2920" PostTypeId="1" AcceptedAnswerId="2921" CreationDate="2015-04-14T13:42:20.960" Score="16" ViewCount="4655" Body="&lt;p&gt;I have already put the following setting in my &lt;code&gt;.vimrc&lt;/code&gt; file: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set history=1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's been there for a while, I work in vim on a daily basis, so there have been many commands executed by now. I know from vim help, that duplicates and mapped command-lines are not stored, and it also says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Use the 'history' option to set the number of lines that are remembered&#xA;(default: 20).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently there are around 130 lines in my history (&lt;code&gt;:his&lt;/code&gt; and &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt; vary a little bit, second one has about 90 entries), but in my opinion there should be more. There are some commands missing, like opening certain files or some substitution commands with complex regex. There have not been used for a while, but I have this history size increased long enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there another limit, which I didn't know about? Or maybe it's not a correct way of increasing cmdline history size?&lt;/p&gt;&#xA;" OwnerUserId="1055" LastActivityDate="2020-09-08T09:40:34.453" Title="How to further increase cmdline history size?" Tags="|command-history|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2921" PostTypeId="2" ParentId="2920" CreationDate="2015-04-14T14:14:28.577" Score="17" Body="&lt;p&gt;A &lt;code&gt;:&lt;/code&gt; value in your &lt;code&gt;'viminfo'&lt;/code&gt; option may limit the number of persisted commands. See &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#viminfo-%3A&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help viminfo-:&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;: Maximum number of items in the command-line history to be&#xA;  saved.  When not included, the value of 'history' is used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2020-09-08T09:40:34.453" LastActivityDate="2020-09-08T09:40:34.453" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="2923" PostTypeId="1" AcceptedAnswerId="2925" CreationDate="2015-04-14T18:49:46.243" Score="6" ViewCount="2117" Body="&lt;p&gt;Is there a way to select a text block (e.g. a first word &quot;TODO:&quot;) programmatically (with some commands or functions from a script)? Not simply highlight, like with a search, but visually select like with mouse? &lt;/p&gt;&#xA;" OwnerUserId="1378" LastEditorUserId="24" LastEditDate="2015-04-15T01:19:05.603" LastActivityDate="2015-04-15T01:19:05.603" Title="How to programmatically visually select a text block?" Tags="|vimscript|visual-mode|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2924" PostTypeId="2" ParentId="2923" CreationDate="2015-04-14T19:49:22.637" Score="1" Body="&lt;p&gt;Any sequence of key presses can be represented in vimscript with the &lt;code&gt;:normal&lt;/code&gt; command. For instance, to visually select the next occurrence of &lt;code&gt;&quot;TODO:&quot;&lt;/code&gt; you might normally hit the following keys:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/TODO:&amp;lt;CR&amp;gt;        jump to the next occurence of TODO:&#xA;v                 start a visual selection (on the T)&#xA;f:                jump to the next ':'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To simulate these key presses in vimscript, you'd want to write something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! /TODO:&amp;lt;CR&amp;gt;vf:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, typing &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; will literally type &lt;code&gt;&amp;lt; C R &amp;gt;&lt;/code&gt; instead of enter. To get around this, we have to wrap this in an execute command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal! /TODO:\&amp;lt;CR&amp;gt;vf:&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I recommend reading &lt;code&gt;:help normal&lt;/code&gt; and &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/29.html&quot; rel=&quot;nofollow&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="680" LastEditorUserId="680" LastEditDate="2015-04-14T20:49:35.803" LastActivityDate="2015-04-14T20:49:35.803" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2925" PostTypeId="2" ParentId="2923" CreationDate="2015-04-14T19:51:31.723" Score="6" Body="&lt;p&gt;If you are looking to visually select a search pattern you can do it using two commands. For example searching for &quot;TODO....&quot; lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^TODO.*$/s&#xA;v//e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will search your your pattern and then visually select to the end of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to move this to a function and then be able to call it in a single action:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! VisualSelectSearch (query)&#xA;  execute &quot;normal /&quot;.a:query.&quot;/s\&amp;lt;CR&amp;gt;v//e\&amp;lt;CR&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;command! -nargs=+ VSS call VisualSelectSearch(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can type &lt;code&gt;:VSS ^TODO.*$&lt;/code&gt; and visually select the next instance. If you want to call the function directly in a script use &lt;code&gt;VisualSelectSearch(&quot;^TODO.*$&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2015-04-14T19:51:31.723" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2926" PostTypeId="1" AcceptedAnswerId="2929" CreationDate="2015-04-14T20:36:38.397" Score="15" ViewCount="550" Body="&lt;p&gt;Occasionally I absentmindedly type &lt;code&gt;:w&lt;/code&gt; when I'm reading something. This causes the modification time of the file to change and sometimes causes my build system to unnecessarily rebuild a substantial chunk of a project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to set vim to simply not do anything if I try to write a file and it hasn't been changed?&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2015-04-15T06:17:07.193" Title="Don't touch file upon write if the file was not changed" Tags="|save|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2927" PostTypeId="2" ParentId="2926" CreationDate="2015-04-14T20:56:37.343" Score="14" Body="&lt;p&gt;Not directly (that is, the behaviour of &lt;code&gt;:w&lt;/code&gt; can't be changed), but you can learn to use &lt;code&gt;:up&lt;/code&gt; instead of &lt;code&gt;:w&lt;/code&gt;.  It does exactly what you want.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-04-14T20:56:37.343" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2928" PostTypeId="1" AcceptedAnswerId="2935" CreationDate="2015-04-14T21:41:25.757" Score="3" ViewCount="2089" Body="&lt;p&gt;I was playing around with the MiniBufExplorer plugin, and I thought it would be nice if the MBE window could stick to the bottom of my ViM screen, even if I specifically open a new window with e.g. &lt;code&gt;:bot split xyz&lt;/code&gt;.  If I can get that working, then as a bonus I can set laststatus=0 when the MBE window is active, because having a statusline on it doesn't really accomplish anything.  I already have an autocmd that customizes my statusline that I could piggyback off of, so at first I thought I could make a quick tweak to that function like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:RefreshStatus()&#xA;    let l:mbe = 2&#xA;    for nr in range(1, winnr('$'))&#xA;        if '-MiniBufExplorer-' == expand('%')&#xA;            let l:mbe = 0&#xA;            wincmd J&#xA;        else&#xA;            call setwinvar(nr, '&amp;amp;statusline', '%!Status(' . nr . ')')&#xA;        endif&#xA;    endfor&#xA;    call setwinvar (0, '&amp;amp;laststatus', l:mbe)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Oops, of course that didn't work.  I'm not actually jumping through the buffers to set the status line, so &lt;code&gt;expand('%')&lt;/code&gt; and &lt;code&gt;wincmd J&lt;/code&gt; don't actually behave correctly.  So my biggest question is, how do I execute &lt;code&gt;wincmd J&lt;/code&gt; in window #nr?&#xA;EDIT:&#xA;I found the &lt;code&gt;bufname()&lt;/code&gt; function, which solves the problem of correctly identifying the MBE window, but I'd still like to be able to move the window to the bottom when something has snuck in under it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 2:&#xA;MiniBufExplorer seems to have some logic for window positioning built in that interferes with what I am attempting to accomplish, even when using noautocmd.  Here's the function I ended up with, following Ingo's answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FixMBE()  &quot; Now a separate function&#xA;    let l:mbenr = 0&#xA;    for nr in range(1, winnr('$'))&#xA;        if '-MiniBufExplorer-' == bufname(nr)&#xA;            call setwinvar(nr, '&amp;amp;statusline', '')&#xA;            let l:mbenr = nr&#xA;        endif&#xA;    endfor&#xA;    if l:mbenr&#xA;        set laststatus=0&#xA;        let l:active = winnr()&#xA;        try&#xA;            exe 'noautocmd ' . l:mbenr . 'wincmd w'&#xA;            wincmd J&#xA;            if l:active &amp;gt; l:mbenr&#xA;                let l:active = l:active -1   &quot; window numbers will change after we move MBE&#xA;            endif&#xA;        finally&#xA;            exe 'noautocmd ' . l:active . 'wincmd w'&#xA;        endtry&#xA;    else&#xA;        set laststatus=2&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It mostly works with horizontal splits, but goes badly belly up when vertical splits are added to the mix.  However, if I disable the MBE plugin and create a normal window with that name, this script behaves exactly as expected.&lt;/p&gt;&#xA;" OwnerUserId="1688" LastEditorUserId="1688" LastEditDate="2015-04-15T17:20:42.713" LastActivityDate="2023-04-06T07:06:28.553" Title="How to execute a command in an inactive window" Tags="|vimscript|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2929" PostTypeId="2" ParentId="2926" CreationDate="2015-04-14T22:04:34.937" Score="15" Body="&lt;p&gt;Extending @lcd047's answer you can use &lt;code&gt;cabbrev&lt;/code&gt; to modify &lt;code&gt;w&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cabbrev w &amp;lt;c-r&amp;gt;=(getcmdtype()==':' &amp;amp;&amp;amp; getcmdpos()==1 ? 'up' : 'w')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you type &lt;code&gt;:w&lt;/code&gt; you will notice that it will be replaced with &lt;code&gt;:up&lt;/code&gt; when you press return.&lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2015-04-15T02:01:36.107" LastActivityDate="2015-04-15T02:01:36.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2930" PostTypeId="1" AcceptedAnswerId="2931" CreationDate="2015-04-15T00:11:13.067" Score="2" ViewCount="5526" Body="&lt;p&gt;I'm using Ubuntu system. I have files: A.txt, B.txt, C.txt&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can split window in the following way: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim A.txt&#xA;:vs B.txt    // after entering into vim&#xA;:vs C.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way to achieve the same effect using command line? like vim -option A.txt B.txt C.txt ?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim A.txt B.txt    doesn't work, it doesn't show the files simultaneously&#xA;vimdiff *.txt     works, but I really don't need the difference shown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1080" LastActivityDate="2015-04-15T01:46:57.293" Title="How to split window directly from command line?" Tags="|split|vimdiff|multiple-files|linux|command-line-window|" AnswerCount="1" CommentCount="0" ClosedDate="2015-04-15T22:15:45.753" ContentLicense="CC BY-SA 3.0" />
  <row Id="2931" PostTypeId="2" ParentId="2930" CreationDate="2015-04-15T01:46:57.293" Score="7" Body="&lt;p&gt;Vim's &lt;code&gt;-o&lt;/code&gt; and &lt;code&gt;-O&lt;/code&gt; options will open the files while splitting them horizontally or vertically respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taken from Vim's help page &lt;code&gt;:help -o&lt;/code&gt; and &lt;code&gt;:help -O&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *-o*&#xA;-o[N]       Open N windows, split horizontally.  If [N] is not given,&#xA;        one window is opened for every file given as argument.  If&#xA;        there is not enough room, only the first few files get a&#xA;        window.  If there are more windows than arguments, the last&#xA;        few windows will be editing an empty file.&#xA;        {not in Vi}&#xA;&#xA;                            *-O*&#xA;-O[N]       Open N windows, split vertically.  Otherwise it's like -o.&#xA;        If both the -o and the -O option are given, the last one on&#xA;        the command line determines how the windows will be split.&#xA;        {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;vim -o A.txt B.txt C.txt&lt;/code&gt; will open three horizontal splits for each file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vim -O A.txt B.txt C.txt&lt;/code&gt; will open three vertical splits for each file&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="246" LastActivityDate="2015-04-15T01:46:57.293" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2933" PostTypeId="1" AcceptedAnswerId="2934" CreationDate="2015-04-15T06:18:39.733" Score="6" ViewCount="234" Body="&lt;p&gt;Not sure if it's an appropriate question. But I just can't help wondering, why would any Vim user find it necessary to invoke a GUI search prompt instead of search using &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;, why would the designer of &lt;code&gt;gvim&lt;/code&gt;, &lt;code&gt;MacVim&lt;/code&gt; etc. want to add this feature. Or is it because they're just quite some inherent feature of a GUI app anyways?&lt;/p&gt;&#xA;" OwnerUserId="1315" LastActivityDate="2015-04-15T07:58:40.690" Title="What's the point of :promptfind after all" Tags="|gvim|search|macvim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2934" PostTypeId="2" ParentId="2933" CreationDate="2015-04-15T07:58:40.690" Score="6" Body="&lt;p&gt;&lt;code&gt;:promptfind&lt;/code&gt; and related commands are useful for the &lt;em&gt;easy mode&lt;/em&gt; (&lt;code&gt;evim&lt;/code&gt;), which according to &lt;code&gt;:help easy&lt;/code&gt; sets Vim up to &lt;em&gt;work like most click-and-type editors&lt;/em&gt;. As Notepad has such a find dialog, and users coming from such editors expect it / initially feel better with it, Vim has it, too. I personally wouldn't recommend this way for switching to Vim, though.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-15T07:58:40.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2935" PostTypeId="2" ParentId="2928" CreationDate="2015-04-15T08:07:18.453" Score="3" Body="&lt;p&gt;Vim has no means to execute command in a non-active window, and the internal implementation also mostly depends on being in the active one, so it would be hard to implement such. You actually have to briefly move to that window, and then back:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let currentWinNr = winnr()&#xA;execute targetWinNr . 'wincmd w'&#xA;try&#xA;    execute command &quot; This could be your wincmd J&#xA;finally&#xA;silent execute currentWinNr . 'wincmd w'&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this still clobbers the &lt;em&gt;previous window&lt;/em&gt; (i.e. &lt;code&gt;&amp;lt;C-W&amp;gt;p&lt;/code&gt;); additional commands would be necessary to restore that, too. And autocmds might be triggered, which can be avoided via &lt;code&gt;:noautocmd wincmd w&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-15T08:07:18.453" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2936" PostTypeId="1" AcceptedAnswerId="2939" CreationDate="2015-04-15T08:57:18.120" Score="10" ViewCount="886" Body="&lt;p&gt;At my workplace, I want to do a presentation of a custom language I've developed for solving some problems we had. For easier development, I created my own vim syntax file for this particular language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I need to present it on another computer, that will not have that syntax file. For all I know, it might even not have vim installed (but I doubt it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be perfect if I could &lt;code&gt;less -r&lt;/code&gt; a file to get that same syntax highlighting that I do on my own computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I do not know how to either copy&amp;amp;paste while preserving colors (in terminal from gnome on Debian), or how to output the file with its syntax highlighting as raw control chars from vim. I'm more confident in finding a solution from vim, but I have no idea what to look for to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Do you know any way to output the file you opened with its syntax highlighting as ANSI raw-control-chars in another file?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1725" LastActivityDate="2021-05-18T11:20:16.357" Title="How to output highlighted source code into a file to use outside vim" Tags="|command-line|syntax-highlighting|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2937" PostTypeId="2" ParentId="2936" CreationDate="2015-04-15T09:38:47.710" Score="1" Body="&lt;p&gt;[EDIT] : Just noticed cat doesn't do the trick when using vim and script, you can use 'head' however.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;guest@demomachine$ head -c [terminalsize] demo.typescript&#xA;&#xA;EXAMPLE: guest@demomachine$ head -c 3710 demo.typescript&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the presentation machine has a colour terminal available and is *nix based, you could record a script with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;you@yourmachine$ script -c &quot;vim [sourcefile]&quot; demo.typescript&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then just &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;guest@demomachine$ cat demo.typescript&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;cat might not work with vim and script for this very problem, see edit above.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;on the presentation machine. HINT: mind the terminal size during recording, should be smaller or same size as demo machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Script also allows you to record a whole terminal session, so you can record and play a demo using scriptreplay.&lt;/p&gt;&#xA;" OwnerUserId="875" LastEditorUserId="875" LastEditDate="2015-04-15T09:57:33.683" LastActivityDate="2015-04-15T09:57:33.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2938" PostTypeId="1" AcceptedAnswerId="2942" CreationDate="2015-04-15T10:07:55.337" Score="28" ViewCount="15087" Body="&lt;p&gt;I use a tiling window manager (awesome) + a terminal multiplexer (tmux) + splits inside of vim. I have no window decorations at all, so there is no visual split between them at all if the content of the program doesn't give it away. I'm quite comfortable with this paradigm as I use multiple monitors and group tasks by screen anyway. If two windows didn't have a reason to be side by side they wouldn't be there in the first place.&lt;/p&gt;&#xA;&lt;p&gt;However this creates a bit of visual dissonance where the most obvious split visually is the least significant semantically.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Xorg window ‹|› window = nothing at all&lt;/li&gt;&#xA;&lt;li&gt;Tmux pane ‹|› pane = 1px divider line&lt;/li&gt;&#xA;&lt;li&gt;Vim split ‹|› split = 1 character wide colored column&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here's a sample showing one each side by side windows, panes and vim splits:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tFcjO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tFcjOm.png&quot; alt=&quot;windows panes and splits&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Even without clicking through to the full resolution version, the white divider line you see is the least significant split on the screen, the vim panes. (Note the gray column at the right of the vim session is actually an 80th column highlight, not a divider of any kind although I do often work at that size.)&lt;/p&gt;&#xA;&lt;p&gt;I am aware of how to change the character drawn in the split or reduce the color scheme contrast. What I would like to do is use the same split bar as tmux that doesn't take up any width because it's drawn in between columns rather than in one. Is this possible with terminal based vim? Gvim? Neovim? If making a visually unobtrusive separator is not possible, can the divider column be turned off entirely?&lt;/p&gt;&#xA;&lt;p&gt;P.S. The reason using a visually similar separator makes sense is because I use the same key-bindings to navigate between tmux panes and vim splits. The same keys navigate seamlessly between them, it would only make sense if the visual boundaries were the same as well.&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="1238" LastEditDate="2020-08-10T21:08:40.910" LastActivityDate="2020-08-10T21:08:40.910" Title="Can the split separator in vim be less than a full column wide?" Tags="|terminal|highlight|split|tmux|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2939" PostTypeId="2" ParentId="2936" CreationDate="2015-04-15T10:09:16.400" Score="14" Body="&lt;p&gt;You can use the &lt;code&gt;:TOhtml&lt;/code&gt; command that ships with Vim to create an HTML representation of the (syntax highlighted) buffer (or parts of it). Then, your only requirement on the target system would be a browser to display the captured file. See &lt;code&gt;:help :TOhtml&lt;/code&gt; for details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you insist on outputting ANSI escape sequences, you could probably modify the plugin to do that, but I guess that would be a non-trivial effort.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-15T10:09:16.400" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2940" PostTypeId="2" ParentId="2938" CreationDate="2015-04-15T10:26:18.877" Score="5" Body="&lt;p&gt;No, this cannot be done in Vim, and would probably be very hard to implement in GVIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim sticks to the cell-based addressing used in the terminal; within a buffer, this is crucial for consistent vertical navigation with &lt;code&gt;j&lt;/code&gt; / &lt;code&gt;k&lt;/code&gt;. This addressing by cell-based x and y coordinates is so ingrained in Vim's implementation, I guess it's very hard to overcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note &lt;code&gt;:help design-not&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Vim is not a fancy GUI editor that tries to look nice at the cost of&#xA;  being less consistent over all platforms.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-15T10:26:18.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2941" PostTypeId="2" ParentId="2938" CreationDate="2015-04-15T12:25:02.513" Score="6" Body="&lt;p&gt;Even in my own screen-shot, tmux is not using any magic, the split is still a single character wide column. The less obtrusive visual effect is the use of a Unicode box drawing character that is less clunky than vim's ASCII default, and the lack of a highlight background color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very nearly the same effect is possible in vim by adding something like the following lines to the rc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set split separator to Unicode box drawing character&#xA;set encoding=utf8&#xA;set fillchars=vert:│&#xA;&#xA;&quot; Override color scheme to make split the same color as tmux's default&#xA;autocmd ColorScheme * highlight VertSplit cterm=NONE ctermfg=Green ctermbg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The use of &lt;code&gt;autocmd&lt;/code&gt; guarantees that the highlight over-ride stays in effect if you switch color schemes. You may or may not want this behavior as some color scheme have sensible values for this color group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that &lt;code&gt;cterm=NONE&lt;/code&gt; is necessary to over-ride some color schemes that set this value to &lt;code&gt;reverse&lt;/code&gt;, ergo messing with whatever fg/bg values you try to use.&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="267" LastEditDate="2015-04-15T12:32:56.157" LastActivityDate="2015-04-15T12:32:56.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2942" PostTypeId="2" ParentId="2938" CreationDate="2015-04-15T12:26:46.830" Score="42" Body="&lt;p&gt;You are wrong about tmux. Like every terminal-based program — including Vim — it only draws stuff &lt;em&gt;inside&lt;/em&gt; cells. This means that Vim and tmux both use the same method to draw vertical borders: they just use a pipe-like character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tmux uses &lt;code&gt;│&lt;/code&gt; (&lt;code&gt;U+2502&lt;/code&gt;) by default while Vim uses &lt;code&gt;|&lt;/code&gt; (&lt;code&gt;U+007C&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the same separator in Vim, you can simply use the same character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fillchars+=vert:│&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that your colorscheme probably sets the background-color of the vertical split. If that's the case, you can remove the background-color directly in your colorscheme:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi VertSplit ctermbg=NONE guibg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-04-15T12:26:46.830" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2943" PostTypeId="2" ParentId="2856" CreationDate="2015-04-15T15:51:00.337" Score="3" Body="&lt;p&gt;xmllint supports local schema validation, so with Syntastic + xmllint you can accomplish what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once installing both tools, add the following autocmd to your vimrc, tweaking paths to match where the files actually live:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead /home/nico/xml/commonly_edited.xml call s:xml_validate()&#xA;function! s:xml_validate()&#xA;    let g:syntastic_xml_xmllint_args = &quot;--schema /home/nico/schemas/test.xsd&quot;&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will cause xmllint to obey the schema when validating, and tag errors in the signs column on save, as seen here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8S6R0.png&quot; alt=&quot;xml schema validation example&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, there are alternate syntax validators such as &lt;a href=&quot;http://xerces.apache.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Xerces&lt;/a&gt;, which can supposedly validate based on the schemas defined inside the file directly, instead of having to manually specify. One could possibly write a Syntastic checker that uses Xerces to validate XML, but that could be a bit more involved if it doesn't spit errors out in the right format.&lt;/p&gt;&#xA;" OwnerUserId="609" LastActivityDate="2015-04-15T15:51:00.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2944" PostTypeId="1" AcceptedAnswerId="2945" CreationDate="2015-04-15T16:13:16.323" Score="8" ViewCount="6951" Body="&lt;p&gt;I'm interested in using exuberant-tags (ctags) in vim, but I use Vim for all sorts of projects so I need multiple tag files and I need vim to use the correct tag file on a per project basis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there an easy way to manage this?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. I could store tags in files like ~/.vim/tagfiles/-var-www-mywebsite.com then if I was editing a file in /var/www/mywebsite.com/foo/bar/baz.php it could try looking for  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;~/.vim/tagfiles/-var-www-mywebsite.com-foo-bar&lt;br&gt;&#xA;then&lt;br&gt;&#xA;~/.vim/tagfiles/-var-www-mywebsite.com-foo&lt;br&gt;&#xA;then&lt;br&gt;&#xA;~/.vim/tagfiles/-var-www-mywebsite.com&lt;/p&gt;&#xA;&#xA;&lt;p&gt;until it finds a match? But I don't want to reinvent the wheel and spending hours with vimscript if someone's already done it, as I suspect it's a common requirement?&lt;/p&gt;&#xA;" OwnerUserId="1406" LastActivityDate="2016-08-01T15:29:05.090" Title="Can I load different tags per project?" Tags="|ctags|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2945" PostTypeId="2" ParentId="2944" CreationDate="2015-04-15T16:18:51.267" Score="13" Body="&lt;p&gt;If each project is a separate git repo, one can use &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot;&gt;fugitive.vim&lt;/a&gt; which will automatically point tags at &lt;code&gt;.git/tags&lt;/code&gt;, allowing easy per-project tags.&lt;/p&gt;&#xA;" OwnerUserId="609" LastActivityDate="2015-04-15T16:18:51.267" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2946" PostTypeId="2" ParentId="2915" CreationDate="2015-04-15T17:37:04.787" Score="16" Body="&lt;p&gt;After spelunking the MacVim code base for a few hours, I think I can see why this happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When MacVim starts, it reads the previously-saved window position from &lt;code&gt;NSUserDefaults&lt;/code&gt; and tries to restore that position. At the point the window hasn't actually been shown yet, and it's origin is some (possibly OS selected) default that is always on the 'main' screen. If the previous position of the window was on a different monitor, &lt;em&gt;changing&lt;/em&gt; the window's position will trigger a &quot;resized&quot; event (it's possible this is new, or a bug, in 10.10.3, since a corresponding &quot;will resize&quot; event is not generated).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will cause MacVim to try to resize the Vim backend, but it's too early in the execution of the process for the state which is used to effect that resize to be properly constructed. Thus, MacVim requests that Vim resize itself to what is effectively a default value, which causes the window to shrink the next time MacVim gets a response to the resize from the Vim backend (MacVim resizes windows lazily).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;&lt;a href=&quot;https://github.com/macvim-dev/macvim/pull/5&quot; rel=&quot;noreferrer&quot;&gt;This change fixes the bug&lt;/a&gt;, I think. It causes window resizes not to propagate down into the Vim backend until the window has been presented. &lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorDisplayName="user72" LastEditDate="2016-03-19T14:55:10.343" LastActivityDate="2016-03-19T14:55:10.343" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2947" PostTypeId="2" ParentId="122" CreationDate="2015-04-15T19:21:37.350" Score="0" Body="&lt;p&gt;Related to the blackhole register &lt;code&gt;&quot;_&lt;/code&gt; mentioned by @derobert you can find an useful screencast in &lt;a href=&quot;http://vimcasts.org/episodes/meet-the-yank-register/&quot; rel=&quot;nofollow&quot;&gt;http://vimcasts.org/episodes/meet-the-yank-register/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim uses the terms delete, yank, and put, in place of the more&#xA;  standard terminology cut, copy, and paste. Starting with the same&#xA;  letter, put and paste are easily interchangable. Once you get used to&#xA;  the word yank, it becomes synonymous with copy. But Vim’s use of the&#xA;  word ‘delete’ is problematic.In most contexts, the word delete just&#xA;  means remove. But Vim’s delete operation copies the text into a&#xA;  register, then removes it from the document. In other words, Vim’s&#xA;  delete operation behaves like a cut.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1735" LastActivityDate="2015-04-15T19:21:37.350" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2948" PostTypeId="2" ParentId="2944" CreationDate="2015-04-15T19:27:56.507" Score="16" Body="&lt;p&gt;This line should be enough:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tags=./tags;,tags;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It tells Vim to look for a &lt;code&gt;tags&lt;/code&gt; file in the directory of the current file as well as in the working directory, and up, and up, and…&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-04-15T19:27:56.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2949" PostTypeId="1" CreationDate="2015-04-15T19:42:29.157" Score="2" ViewCount="384" Body="&lt;p&gt;I work on a large project with many contributors and everyday I usually have to regenerate to keep this up to date and that is very time consuming. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do any of you have any unique solutions to help with this so that it doesn't stop my workflow? &lt;/p&gt;&#xA;" OwnerUserId="1736" LastEditorUserId="1736" LastEditDate="2015-04-16T12:37:49.370" LastActivityDate="2015-05-08T19:38:04.883" Title="Keeping cscope db updated" Tags="|cscope|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2950" PostTypeId="1" CreationDate="2015-04-15T23:41:36.943" Score="11" ViewCount="5413" Body="&lt;p&gt;In Vim, when I run this command &lt;code&gt;:!bash -c &quot;ll&quot;&lt;/code&gt;, I get this error message &lt;code&gt;bash: ll: command not found&lt;/code&gt;. &lt;code&gt;ll&lt;/code&gt; is an alias in my ~/.bashrc file. If I just enter &lt;code&gt;ll&lt;/code&gt; from bash it works. I created a ~/.bash_profile file and added the following to it: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [ -f ~/.bashrc ]; then&#xA;   source ~/.bashrc&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I looked at my ~/.profile file and saw that it already had this at the beginning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# if running bash&#xA;if [ -n &quot;$BASH_VERSION&quot; ]; then&#xA;    # include .bashrc if it exists&#xA;    if [ -f &quot;$HOME/.bashrc&quot; ]; then&#xA;    . &quot;$HOME/.bashrc&quot;&#xA;    fi&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I even tried setting bash to run in interactive mode, and it still won't recognize my aliases. If I use &lt;code&gt;ls&lt;/code&gt; instead of &lt;code&gt;ll&lt;/code&gt;, it works fine, since &lt;code&gt;ls&lt;/code&gt; is not a custom alias.&lt;/p&gt;&#xA;" OwnerUserId="1410" LastEditorUserId="51" LastEditDate="2015-04-26T23:36:26.167" LastActivityDate="2020-04-22T03:52:57.873" Title="Bash not recognizing aliases when run from Vim" Tags="|external-command|bash|" AnswerCount="3" CommentCount="1" ClosedDate="2018-04-09T08:21:24.663" ContentLicense="CC BY-SA 3.0" />
  <row Id="2951" PostTypeId="2" ParentId="2950" CreationDate="2015-04-16T00:49:53.380" Score="11" Body="&lt;p&gt;Your issue is with bash and not with vim. The problem is that when you run &lt;code&gt;!&amp;lt;cmd&amp;gt;&lt;/code&gt; in vim or &lt;code&gt;/bin/bash -c &amp;lt;cmd&amp;gt;&lt;/code&gt; from another shell you are launching an instance of bash in non-interactive mode. In non-interactive mode alias are not expanded and you get this error. I don't know if you'd be able to enable the shell option &lt;code&gt;expand_aliases&lt;/code&gt; from these types of situations since you're back into a non-interactive shell when you invoke &lt;code&gt;!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you try to start an interactive shell it will put the vim process in the background after your command executes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!/bin/bash -i -c ll&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2015-04-16T02:16:56.940" LastActivityDate="2015-04-16T02:16:56.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2952" PostTypeId="1" AcceptedAnswerId="2953" CreationDate="2015-04-16T10:50:54.680" Score="2" ViewCount="480" Body="&lt;p&gt;I have the following file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#&#xA;#&#xA;NODE  / 11000001       1009.6809       -878.9679        316.3049&#xA;NODE  / 11000001       1009.6809       -878.9679        316.3049&#xA;NODE  / 11000001       1009.6809       -878.9679        316.3049&#xA;NODE  / 11000001       1009.6809       -878.9679        316.3049&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to fold it using the foldexpr method (I tried syntax, but I have other requirements that for now keep me from pursuing that further). There should be 2 folds, one containing the first 2 lines, a second containing the other. If need be, I'd be ok with a third fold containing the other two, but I'd like it better if this could be avoided.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h fold-expr&lt;/code&gt; refers to &lt;code&gt;:h fold-indent&lt;/code&gt; for using foldlevels:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A sequence of lines with the same or higher fold level form a fold,&#xA;  with the lines with a higher level forming a nested fold.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, as far as I can see, I need to have the first 2 lines the same foldlevel, as well as lines 3-6. But lines 1-2 need a higher foldlevel, so the fold for lines 1-2 fold does not include lines 3-6. I can achieve that in the following way&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldexpr=GetPamFold(v:lnum)&#xA;&#xA;function! GetPamFold(lnum)&#xA;  let linestr = getline(a:lnum)&#xA;&#xA;  if linestr =~ '^NODE'&#xA;    return '2'&#xA;  elseif linestr =~ '^#'&#xA;    return '3'&#xA;  endif&#xA;&#xA;  return '0'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can check the foldlevels via &lt;code&gt;echom foldlevel(1)&lt;/code&gt; and such, and it works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does not work is the folding itself. I get 2 folds: 1 containing the first 2 lines (good), and a second containing the first fold and lines 3-6. That's bad. Also, both those folds are each contained in another fold that ONLY contains the other fold, i.e. trivially folds the 1 line (e.g. the folded lines 1-2) into one line. Really bad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Fold1 contains lines 1-2&lt;/li&gt;&#xA;&lt;li&gt;Fold2 contains Fold1&lt;/li&gt;&#xA;&lt;li&gt;Fold3 contains Fold2 and lines 3-6&lt;/li&gt;&#xA;&lt;li&gt;Fold4 contains Fold3&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As far as I can see, it's not what the docs say what would happen. What am I missing? What can I do to achieve my folds?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vim 7.4. Thanks for any pointers!&lt;/p&gt;&#xA;" OwnerUserId="1296" LastActivityDate="2015-04-16T11:54:03.130" Title="Folding via foldexpr" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2953" PostTypeId="2" ParentId="2952" CreationDate="2015-04-16T11:54:03.130" Score="5" Body="&lt;p&gt;I would do it like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A new fold starts (&lt;code&gt;&amp;gt;1&lt;/code&gt;) if the current line starts with one of the keywords &lt;em&gt;and&lt;/em&gt; the previous line has no / a different keyword.&lt;/li&gt;&#xA;&lt;li&gt;Else, if the current line starts with one of the keywords, keep the fold level (&lt;code&gt;1&lt;/code&gt;, or &lt;code&gt;=&lt;/code&gt;), else no fold.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Implementation&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldexpr=GetPamFold(v:lnum)&#xA;function! GetPamFold(lnum)&#xA;  let current  = matchstr(getline(a:lnum), '^\(NODE\|#\)')&#xA;  let previous = matchstr(getline(a:lnum - 1), '^\(NODE\|#\)')&#xA;&#xA;  return ! empty(current) &amp;amp;&amp;amp; current != previous ? '&amp;gt;1' : (empty(current) ? 0 : 1)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-16T11:54:03.130" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2954" PostTypeId="1" AcceptedAnswerId="2956" CreationDate="2015-04-16T12:19:17.720" Score="18" ViewCount="6968" Body="&lt;p&gt;I have the syntastic and python-mode plugins installed and they both include syntax checkers. I think the python-mode syntax checker is more versitle for python files so I would like to just use that one (instead of both).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I disable syntastic just for python files?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="13" LastEditDate="2015-04-16T13:34:00.977" LastActivityDate="2015-04-16T13:34:00.977" Title="How do I disable syntastic for python files?" Tags="|filetype-python|plugin-syntastic|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2955" PostTypeId="1" AcceptedAnswerId="2957" CreationDate="2015-04-16T12:59:18.107" Score="9" ViewCount="2726" Body="&lt;p&gt;I have three vertically split windows. I want the leftmost window to remain as it is, but move the two other windows from a vertical to a horizontal split. How can I achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to get from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----------------&#xA;| b1 | b2 | b3 |&#xA;|    |    |    |&#xA;|    |    |    |&#xA;----------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----------------&#xA;| b1   | b3    |&#xA;|      |-------|&#xA;|      | b2    |&#xA;----------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't figure out how to do this with the &lt;kbd&gt;CTRL-W&lt;/kbd&gt; maps listed in &lt;code&gt;:h window-moving&lt;/code&gt;. The only thing I could think of involves opening and closing windows, not moving them, and before I create a mapping or command for it I wanted to ask if there isn't a way to do it by window movement. Here's what I've got:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;:spl&lt;/kbd&gt; - split middle window&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;:b 3&lt;/kbd&gt; - open the buffer from the rightmost window in the new split&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;CTRL-W&lt;/kbd&gt;+&lt;kbd&gt;l&lt;/kbd&gt; - move cursor to rightmost window&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;CTRL-W&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt; - close current (rightmost) window&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-04-16T13:30:18.087" Title="How can I move windows from a vertical split to a horizontal split?" Tags="|split|vim-windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2956" PostTypeId="2" ParentId="2954" CreationDate="2015-04-16T13:24:45.380" Score="19" Body="&lt;p&gt;The Syntastic documentation (&lt;code&gt;:help syntastic-pymode&lt;/code&gt;) explains what to do:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[...] To avoid both plugins opening error windows, you can either set&#xA;  passive mode for python in syntastic (see syntastic_mode_map), or&#xA;  disable lint checks in &quot;python-mode&quot;, [...]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you should be able to disable automatic syntax checking for Python files with something like the following in your &lt;code&gt;$MYVIMRC&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_mode_map = { 'passive_filetypes': ['python'] }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13" LastActivityDate="2015-04-16T13:24:45.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2957" PostTypeId="2" ParentId="2955" CreationDate="2015-04-16T13:30:18.087" Score="10" Body="&lt;p&gt;I don't know if it is the best way to do what you want, but you can accomplish this only with window movements by doing (start from the rightmost window b3):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 - &lt;kbd&gt;CTRL-W&lt;/kbd&gt;+&lt;kbd&gt;K&lt;/kbd&gt; - You'll have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----------------&#xA;| b3           |&#xA;|------|-------|&#xA;|b1    | b2    |&#xA;----------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2 - Go to b1 with &lt;kbd&gt;CTRL-W&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3 - &lt;kbd&gt;CTRL-W&lt;/kbd&gt;+&lt;kbd&gt;H&lt;/kbd&gt; to move b1 to the left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should have the layout you want now. The only downside I see with this method is that size and position of b1 are changed temporarily during the movement.&lt;/p&gt;&#xA;" OwnerUserId="1232" LastActivityDate="2015-04-16T13:30:18.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2958" PostTypeId="1" CreationDate="2015-04-16T14:10:01.050" Score="4" ViewCount="733" Body="&lt;p&gt;When syntastic or python-mode finds an error in my python file, they create a new column at the left-hand side of the window with flags at the lines where the errors are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OdNAk.png&quot; alt=&quot;Terminal window showing vim with python-mode syntax error flags and line numbers&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This new column not only causes buffer to shift (which I find disruptive), but also prevents my 80-column-width lines from fitting nicely in the window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to have these flags placed in the line number column?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For longer files, I understand these flags would probably replace overwrite the numbers in the lines they appear. I wouldn't have a problem with that.&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="69" LastEditDate="2015-04-16T14:30:55.870" LastActivityDate="2020-04-17T07:52:52.723" Title="Can I force python-mode's (or syntastic's) error flags over the line number columns?" Tags="|plugin-syntastic|signs|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2959" PostTypeId="2" ParentId="2958" CreationDate="2015-04-16T14:29:19.947" Score="5" Body="&lt;p&gt;No, this unfortunately isn't possible. The &lt;em&gt;signs column&lt;/em&gt; is separate, and always with a width of two cells. From &lt;code&gt;:help signs&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When signs are defined for a file, Vim will automatically add a column of two&#xA;  characters to display them in.  When the last sign is unplaced the column&#xA;  disappears again.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could only configure Syntastic to not use signs at all (via &lt;code&gt;let g:syntastic_enable_signs = 0&lt;/code&gt;, thanks @lcd047!).&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2015-04-16T16:02:26.080" LastActivityDate="2015-04-16T16:02:26.080" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2961" PostTypeId="1" CreationDate="2015-04-16T15:35:30.100" Score="2" ViewCount="268" Body="&lt;p&gt;The Mac latex editor 'TeXShop' has a great feature -- I can right-click anywhere in my tex and it shows me the corresponding character of the generated PDF. Similarly I can click on PDF and jump to that character in the tex source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do the same thing in vim, and some PDF viewer? (I'm interested on Mac myself)&lt;/p&gt;&#xA;" OwnerUserId="92" LastEditorUserId="24" LastEditDate="2015-04-16T20:55:50.060" LastActivityDate="2015-04-21T12:01:28.237" Title="PDF viewer syncing" Tags="|filetype-tex|macos|previewing|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2962" PostTypeId="2" ParentId="2961" CreationDate="2015-04-16T16:41:14.137" Score="3" Body="&lt;p&gt;For the first situation (tex selection to PDF) if you have a tex compiler that allows for input from stdin you could echo your visual selection.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EchoPipeCmd(cmd) range&#xA;  echo system('echo ' . shellescape(join(getline(a:firstline, a:lastline), &quot;\n&quot;)) . ' | ' . a:cmd)&#xA;endfunction&#xA;&#xA;command! -range=% -nargs=+ EchoPipeCmd :&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call EchoPipeCmd(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you visually selection a block and enter &lt;code&gt;:'&amp;lt;,'&amp;gt;EchoPipeCmd command&lt;/code&gt; the selection is sent to &lt;code&gt;/bin/echo&lt;/code&gt; as an escaped string and then piped to the command you provide. As an example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;EchoPipeCmd tee /tmp/output.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will use &lt;code&gt;tee&lt;/code&gt; to both echo the selected text and also write it to &lt;code&gt;/tmp/output.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to make a command and hardcode in the tex compiler info you'd do something like this (assuming the command to compile is &lt;code&gt;tex --stdin -o &amp;lt;filename&amp;gt;&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% -nargs=0 CompileTex :&amp;lt;line1&amp;gt;&amp;lt;line2&amp;gt;call EchoPipeCmd(&quot;tex --stdin -o /tmp/output.pdf&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can visually select and call &lt;code&gt;:'&amp;lt;,'&amp;gt;CompileTex&lt;/code&gt; and you'll get a pdf file.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2015-04-16T16:41:14.137" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2963" PostTypeId="1" AcceptedAnswerId="2968" CreationDate="2015-04-16T18:53:16.837" Score="6" ViewCount="5874" Body="&lt;p&gt;I think this is not &lt;em&gt;quite&lt;/em&gt; a duplicate, although it's close.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often work with multiple, slightly different, checkouts of the same multi-directory project. I'd like to be able to jump around using tags and gf, always staying within the current checkout, without having to type anything at startup. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a different tags file at the top-level directory of each checkout. The checkouts are numerous and their locations far from static, so hard-coding in paths is not an acceptable solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tags=tags;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;seems to work acceptably for the tags part. But to get gf to work I need to append the location of the tags files thus found (notably including the top-level directory) to the path somehow. Any ideas on how to do this?&lt;/p&gt;&#xA;" OwnerUserId="1747" LastActivityDate="2015-04-16T21:18:11.593" Title="Set path to location of tags file" Tags="|tags|path|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2964" PostTypeId="1" AcceptedAnswerId="2967" CreationDate="2015-04-16T20:37:33.213" Score="3" ViewCount="185" Body="&lt;p&gt;I just learned of the existence of &lt;a href=&quot;https://vi.stackexchange.com/questions/2858/navigating-code-projects-without-using-external-commands/2862#2862&quot;&gt;include-search&lt;/a&gt;, but even after reading &lt;code&gt;:help include-search&lt;/code&gt;and &lt;code&gt;:help includeexpr&lt;/code&gt; I'm not sure what I need to do to have &lt;code&gt;[I&lt;/code&gt; find included and required files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I configure include-search for both included and required PHP files?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;think&lt;/em&gt; I need to set &lt;code&gt;includeexpr&lt;/code&gt; such that it allow searching files whether they were included using &lt;code&gt;require&lt;/code&gt;, &lt;code&gt;require_once&lt;/code&gt;, &lt;code&gt;include&lt;/code&gt;, or &lt;code&gt;include_once&lt;/code&gt;; but I'm not sure. And I don't quite get what the variable is supposed to have.&lt;/p&gt;&#xA;" OwnerUserId="475" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-04-16T21:00:47.777" Title="Configuring include-search for PHP" Tags="|vimrc|search|include|filetype-php|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2965" PostTypeId="5" CreationDate="2015-04-16T20:57:02.660" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-04-16T20:57:02.660" LastActivityDate="2015-04-16T20:57:02.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2966" PostTypeId="4" CreationDate="2015-04-16T20:57:02.660" Score="0" Body="Visualizing a document that would be generated from source code that is being edited" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-04-17T03:17:25.457" LastActivityDate="2015-04-17T03:17:25.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2967" PostTypeId="2" ParentId="2964" CreationDate="2015-04-16T21:00:47.777" Score="2" Body="&lt;p&gt;The default php ftplugin already does that for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal include=\\\(require\\\|include\\\)\\\(_once\\\)\\\?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add &lt;code&gt;filetype plugin indent on&lt;/code&gt; to your &lt;code&gt;~/.vimrc&lt;/code&gt; if it's not already there to benefit from Vim's filetype detection.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-04-16T21:00:47.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2968" PostTypeId="2" ParentId="2963" CreationDate="2015-04-16T21:18:11.593" Score="8" Body="&lt;pre&gt;&lt;code&gt;let &amp;amp;path += fnamemodify(tagfiles()[0], ':p:h')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should add the path of your &lt;code&gt;tags&lt;/code&gt; file's parent directory to the &lt;code&gt;path&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Updating &lt;code&gt;path&lt;/code&gt; each time you enter a buffer is probably a good idea:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup UpdatePath&#xA;    autocmd!&#xA;    autocmd BufNewFile,BufRead,BufEnter * set path&amp;amp;vim | let &amp;amp;path += fnamemodify(tagfiles()[0], ':p:h')&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-04-16T21:18:11.593" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2969" PostTypeId="1" CreationDate="2015-04-17T08:36:16.980" Score="9" ViewCount="16954" Body="&lt;p&gt;Given:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd ~/Sites/project&#xA;project $ vim&#xA;:NERDTreeFind&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to see NERDTree opening with &lt;code&gt;~/Sites/project&lt;/code&gt; as a root folder. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead I see &lt;code&gt;~/Sites&lt;/code&gt; with &lt;code&gt;project&lt;/code&gt; folder selected. So I have to &lt;code&gt;cd&lt;/code&gt; to the work folder each time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sure there should be a setting for that but I can't find it. Help.&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="237" LastEditDate="2015-11-04T02:03:48.420" LastActivityDate="2020-09-11T22:21:30.420" Title="How to set up NERDTree to CD to current folder when opening it for the first time via :NERDTreeFind" Tags="|plugin-nerdtree|working-directory|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2970" PostTypeId="1" CreationDate="2015-04-17T11:05:14.453" Score="28" ViewCount="3566" Body="&lt;p&gt;Is there a plugin or a built-in feature in Vim that allows for &lt;a href=&quot;http://nickgravgaard.com/elastic-tabstops/&quot; rel=&quot;noreferrer&quot;&gt;elastic tabstops&lt;/a&gt;? I've searched a bit, and I found some references saying it was not possible in Vim, but those were quite old. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to have elastic tabstops in Vim? I am fine with a solution for Neovim as well, as that's what I use anyway.&lt;/p&gt;&#xA;" OwnerUserId="1762" LastEditorUserId="267" LastEditDate="2016-03-07T12:17:13.897" LastActivityDate="2021-01-15T17:09:10.233" Title="Elastic Tabstops in Vim?" Tags="|tab-characters|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2971" PostTypeId="1" CreationDate="2015-04-17T12:32:59.910" Score="3" ViewCount="230" Body="&lt;p&gt;I have a pair of &lt;a href=&quot;https://superuser.com/questions/902499/icacls-viewing-permissions-relative-to-the-root-of-a-folder?noredirect=1#comment1210536_902499&quot;&gt;&quot;Unicode little endian without BOM&quot;&lt;/a&gt; text files that I would like to diff each other via the command line.  Unfortunately when I open them using the command line in vim for Windows they come up as a bunch of unreadable binary symbols because the encoding WinMerge is expecting is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to feed these into vim in a readable format?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2015-04-18T04:27:52.787" Title="Vim Diffing a pair of Unicode little endian without BOM text files in a readable format?" Tags="|vimdiff|encoding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2972" PostTypeId="2" ParentId="2971" CreationDate="2015-04-17T13:10:32.407" Score="6" Body="&lt;p&gt;Vim's name for that encoding is &lt;code&gt;ucs-2le&lt;/code&gt; (&lt;code&gt;ucs-2&lt;/code&gt; for Unicode, 2 byte per character, &lt;code&gt;le&lt;/code&gt; for little endian). You can open that via&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit ++enc=ucs-2le filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;enforcing the encoding, or alternatively (if you open such files often), add that encoding to the list of detected ones:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set fileencodings^=ucs-2le&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-17T13:10:32.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2973" PostTypeId="1" AcceptedAnswerId="2974" CreationDate="2015-04-17T13:33:01.357" Score="44" ViewCount="14401" Body="&lt;p&gt;How does one set a vim option when launching from bash or another shell?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="51" LastEditDate="2015-04-26T09:46:47.967" LastActivityDate="2023-08-04T13:45:16.370" Title="Setting a vim option from the command line?" Tags="|invocation|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2974" PostTypeId="2" ParentId="2973" CreationDate="2015-04-17T13:39:13.933" Score="54" Body="&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;$ vim -c 'set ai'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;code&gt;:h -c&lt;/code&gt;, &lt;code&gt;:h startup&lt;/code&gt; and &lt;code&gt;$ vim --help&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="47290" LastEditDate="2023-08-04T13:45:16.370" LastActivityDate="2023-08-04T13:45:16.370" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="2975" PostTypeId="1" AcceptedAnswerId="2976" CreationDate="2015-04-17T14:11:04.610" Score="1" ViewCount="669" Body="&lt;p&gt;I've opened the files I want to diff using the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\temp\robocopyTasks&amp;gt;vim -c &quot;edit ++enc=ucs-2le&quot; -d C:\temp\robocopyTasks\acl\tasks_temp.txt C:\temp\robocopyTasks\acl\tasks_win.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the file encoding is only set on the first file that is opened, and not on the second one; is there any way to do this from the command line?  &lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2015-04-17T14:31:24.093" Title="How to set both files to the encoding in vim diff from command line?" Tags="|command-line|vimdiff|options|encoding|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2976" PostTypeId="2" ParentId="2975" CreationDate="2015-04-17T14:30:57.873" Score="4" Body="&lt;p&gt;The &lt;code&gt;edit ++enc=ucs-2le [filename]&lt;/code&gt; only applies to the current file; when multiple are passed on the command-line, that's the last opened one. You could open the other with &lt;code&gt;:diffsplit ++enc=ucs-2le file2&lt;/code&gt;, but in this case, it's shorter to augment the &lt;code&gt;'fileencodings'&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --cmd &quot;set fileencodings^=ucs-2le&quot; -d icacls.txt icacls2.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows you to keep the &lt;code&gt;-d&lt;/code&gt; argument for diff mode, and avoids duplication of the encoding name.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-17T14:30:57.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2977" PostTypeId="2" ParentId="2975" CreationDate="2015-04-17T14:31:24.093" Score="0" Body="&lt;p&gt;You can apply a command to all buffers by using &lt;code&gt;bufdo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;bufdo edit ++enc=ucs-2le&quot; -d a.txt b.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastActivityDate="2015-04-17T14:31:24.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2978" PostTypeId="2" ParentId="2928" CreationDate="2015-04-17T14:49:04.923" Score="0" Body="&lt;p&gt;Rather than attempting to find and move the MiniBufExplorer window, you can ensure it's in the correct position simply by closing and reopening it. I do this by invoking the toggle command &lt;code&gt;:MBEToggle&lt;/code&gt; twice in succession. e.g.:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Keep minibuf explorer on top when moving windows&#xA;nnoremap &amp;lt;c-w&amp;gt;H :MBEToggle&amp;lt;cr&amp;gt;&amp;lt;c-w&amp;gt;H:MBEToggle&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;c-w&amp;gt;J :MBEToggle&amp;lt;cr&amp;gt;&amp;lt;c-w&amp;gt;J:MBEToggle&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;c-w&amp;gt;K :MBEToggle&amp;lt;cr&amp;gt;&amp;lt;c-w&amp;gt;K:MBEToggle&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;c-w&amp;gt;L :MBEToggle&amp;lt;cr&amp;gt;&amp;lt;c-w&amp;gt;L:MBEToggle&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-08-25T22:10:41.320" LastActivityDate="2020-08-25T22:10:41.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2979" PostTypeId="2" ParentId="2970" CreationDate="2015-04-17T15:27:09.633" Score="18" Body="&lt;p&gt;As far as I can tell there is no reasonable way to accomplish this in a plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a &lt;a href=&quot;https://github.com/chrisbra/vim-mq-patches/blob/master/var_tabstops&quot;&gt;patch&lt;/a&gt; for it, but it's hard to predict when / if the patch will get merged.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-04-17T15:27:09.633" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="2980" PostTypeId="2" ParentId="2801" CreationDate="2015-04-17T17:10:28.070" Score="15" Body="&lt;p&gt;As @Carpetsmoker points out in his comment, &lt;code&gt;g:netrw_gx&lt;/code&gt; determines what will be considered part of a URI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default it is set to &lt;code&gt;&quot;&amp;lt;cfile&amp;gt;&quot;&lt;/code&gt;. From the docs (&lt;code&gt;:help &amp;lt;cfile&amp;gt;&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;cfile&amp;gt;    is replaced with the path name under the cursor&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It escapes me, &lt;strong&gt;why&lt;/strong&gt; parameter parts (i.e. &lt;code&gt;?&lt;/code&gt;) of a URL are being disregarded as parts of a &quot;path name&quot;, but I finally chose to set the following, as my solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use whole &quot;words&quot; when opening URLs.&#xA;&quot; This avoids cutting off parameters (after '?') and anchors (after '#'). &#xA;&quot; See http://vi.stackexchange.com/q/2801/1631&#xA;let g:netrw_gx=&quot;&amp;lt;cWORD&amp;gt;&quot;                                                                                                                   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now this includes whatever &lt;code&gt;W&lt;/code&gt; would select. (Try &lt;code&gt;viW&lt;/code&gt; on a string in VIM.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the docs:&#xA;&lt;code&gt;&amp;lt;cWORD&amp;gt;    is replaced with the WORD under the cursor&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Hint: Using &lt;code&gt;gx&lt;/code&gt; in &lt;strong&gt;visual mode&lt;/strong&gt;, it will open the visually selected string (regardless of the above configuration).&lt;/p&gt;&#xA;" OwnerUserId="1631" LastEditorUserId="1631" LastEditDate="2015-04-18T10:04:42.970" LastActivityDate="2015-04-18T10:04:42.970" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2981" PostTypeId="1" CreationDate="2015-04-17T18:16:57.037" Score="4" ViewCount="4442" Body="&lt;p&gt;I can find an answer to a similar problem &lt;a href=&quot;https://stackoverflow.com/a/3338480/3130747&quot;&gt;here&lt;/a&gt;, however although I can get that example to function I can't get what I want to do to work.&lt;/p&gt;&#xA;&lt;p&gt;Here is the example text to be edited, a partial section of this site &lt;a href=&quot;http://latexcolor.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://latexcolor.com/&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Anti-flash white    #F2F3F4 \definecolor{anti-flashwhite}{rgb}{0.95, 0.95, 0.96}&#xA;Antique brass   #CD9575 \definecolor{antiquebrass}{rgb}{0.8, 0.58, 0.46}&#xA;Antique fuchsia #915C83 \definecolor{antiquefuchsia}{rgb}{0.57, 0.36, 0.51}&#xA;Antique white   #FAEBD7 \definecolor{antiquewhite}{rgb}{0.98, 0.92, 0.84}&#xA;Ao  #0000FF \definecolor{ao}{rgb}{0.0, 0.0, 1.0}&#xA;Ao (English)    #008000 \definecolor{ao(english)}{rgb}{0.0, 0.5, 0.0}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So what I was trying to do was write a macro that would format each of the entries to the following :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;% Anti-flash white    &#xA;% #F2F3F4 &#xA;\definecolor{anti-flashwhite}{rgb}{0.95, 0.95, 0.96}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I can write a macro that will do this - the problem is when there is a large file I want to run the macro over either the whole file or a selection of it. I find that I'm currently guessing how many lines I need to run it for, as the macros are recursive and just keep running.&lt;/p&gt;&#xA;&lt;h2&gt;So how do I visually select the block of text above then write a macro to format it to the given layout?&lt;/h2&gt;&#xA;&lt;p&gt;The end result will be&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;% Anti-flash white    &#xA;% #F2F3F4 &#xA;\definecolor{anti-flashwhite}{rgb}{0.95, 0.95, 0.96}&#xA;&#xA;% Antique brass   &#xA;% #CD9575 &#xA;\definecolor{antiquebrass}{rgb}{0.8, 0.58, 0.46}&#xA;&#xA;% Antique fuchsia &#xA;% #915C83 &#xA;\definecolor{antiquefuchsia}{rgb}{0.57, 0.36, 0.51}&#xA;&#xA;% Antique white   &#xA;% #FAEBD7 &#xA;\definecolor{antiquewhite}{rgb}{0.98, 0.92, 0.84}&#xA;&#xA;% Ao  &#xA;% #0000FF &#xA;\definecolor{ao}{rgb}{0.0, 0.0, 1.0}&#xA;&#xA;% Ao (English)    &#xA;% #008000 &#xA;\definecolor{ao(english)}{rgb}{0.0, 0.5, 0.0}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;edit - referenced SO post in full&lt;/h1&gt;&#xA;&lt;p&gt;Here is the referenced post copied verbatim so that people can see &lt;strong&gt;what doesn't&lt;/strong&gt; work (I'm not sure if copy pasting like this is cool, keeps it in one place though);&lt;/p&gt;&#xA;&lt;p&gt;For example, the following macro capitalizes every word but the first on a line:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:let @q=&amp;quot;^dwgU$P&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So running it on the following (where the &lt;code&gt;+&lt;/code&gt; lines are selected)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; 0000: a long long time ago&#xA; 0001: in a galaxy far away&#xA;+0002: naboo was under an attack&#xA;+0003: and i thought me and qui-gon jinn&#xA;+0004: could talk the federation in&#xA; 0005: to maybe cutting them a little slack.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With the above &lt;code&gt;normal @q&lt;/code&gt; command, produces:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; 0000: a long long time ago&#xA; 0001: in a galaxy far away&#xA; 0002: naboo WAS UNDER AN ATTACK&#xA; 0003: and I THOUGHT ME AND QUI-GON JINN&#xA; 0004: could TALK THE FEDERATION IN&#xA; 0005: to maybe cutting them a little slack.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1443" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-05-05T14:36:45.517" Title="Run macro over a visual selection with line movements" Tags="|visual-mode|macro|cursor-motions|formatting|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2982" PostTypeId="2" ParentId="2981" CreationDate="2015-04-17T18:27:56.610" Score="5" Body="&lt;p&gt;To run a macro on every line you use &lt;code&gt;:{range}normal! &amp;lt;macro&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for instance if you recorded a macro into &lt;code&gt;q&lt;/code&gt; and visually selected the additional lines to apply the macro to, you'd type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;normal! @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This issue you are seeing is because running a macro in parallel assumes that all lines will stay in place. To perform a macro on lines that move you'd have to write a macro that is position aware and recursive. Then you'd run the macro using &lt;code&gt;{count}@&amp;lt;register&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So make sure your macro always ends in the same position it started but on the next line you wish to apply it. I tend to start a macro with a &lt;code&gt;0&lt;/code&gt; or a &lt;code&gt;^&lt;/code&gt; so I know I'm starting at the beginning of the line. At the end I just need to move the cursor to the next line and not really mind my column position.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Hack Solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Since you know when creating the macro that you'll be inserting newline, instead put in a token in its place (for example the word &quot;NEWLINE&quot;). Create your macro to do all the steps in place. Apply the macro across your selection &lt;code&gt;:'&amp;lt;,'&amp;gt;normal @q&lt;/code&gt;. The last step is to make your previous selection again using &lt;code&gt;gv&lt;/code&gt; and then do a swap of your token &lt;code&gt;:'&amp;lt;,'&amp;gt;s/NEWLINE/\r/&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2015-04-17T19:24:16.330" LastActivityDate="2015-04-17T19:24:16.330" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="2983" PostTypeId="1" AcceptedAnswerId="2985" CreationDate="2015-04-17T18:53:23.837" Score="13" ViewCount="1713" Body="&lt;p&gt;Let's say I have a line like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = x(y(z));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to change it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = y(z);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's the most efficient way to do this?&lt;/p&gt;&#xA;" OwnerUserId="40" LastEditorUserId="895" LastEditDate="2015-04-17T20:50:04.453" LastActivityDate="2015-04-22T19:07:38.630" Title="How can I delete a function call, leaving its inner content intact?" Tags="|cursor-movement|normal-mode|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2984" PostTypeId="2" ParentId="2981" CreationDate="2015-04-17T19:23:41.890" Score="5" Body="&lt;p&gt;So assuming you have the lines currently highlighted, here's what I would do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y              &quot;yank the selection&#xA;:new&amp;lt;CR&amp;gt;       &quot;open an empty new split&#xA;Vp             &quot;paste the lines into the split (replacing the 1 blank line already there)&#xA;qa             &quot;start recording macro a&#xA;  I%&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt; &quot;insert % at beginning of line&#xA;  f#hvgel        &quot;select the space between the # and the previous word&#xA;  c&amp;lt;cr&amp;gt;%&amp;lt;space&amp;gt;  &quot;replace with enter, %, space&#xA;  &amp;lt;esc&amp;gt;          &quot;leave insert mode&#xA;  f\hr&amp;lt;cr&amp;gt;       &quot;replace the space before the \ with an enter&#xA;  o&amp;lt;esc&amp;gt;         &quot;insert a blank line below the current line&#xA;  j              &quot;jump down to the start of the next thing to change&#xA;q              &quot;stop recording&#xA;999@a          &quot;repeat the macro 999 times&#xA;dd             &quot;delete the trailing blank line&#xA;ggyG           &quot;copy the lines&#xA;:q!            &quot;close the window&#xA;gvp            &quot;re-select the selection and paste over it with the new version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some notes:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Since we copied the text into a separate buffer, we can use the &lt;code&gt;999@a&lt;/code&gt; trick because when the macro hits the bottom of the buffer and tries to go down, it will hit an error and stop.&lt;/li&gt;&#xA;&lt;li&gt;The NrrwRgn plugin provides a nifty method for editing parts of a file in a temporary window and is a worthy alternative.&lt;/li&gt;&#xA;&lt;li&gt;There are some multiple cursor plugins that try to solve this problem, but I personally prefer the &quot;good ol' fashioned way&quot;&lt;/li&gt;&#xA;&lt;li&gt;If you didn't want to split into a separate window and really did want to know the number of lines selected, you could calculate this as &lt;code&gt;(line(&quot;'&amp;gt;&quot;) - line(&quot;'&amp;lt;&quot;)) + 1&lt;/code&gt; &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="680" LastEditorUserId="680" LastEditDate="2015-04-28T14:08:48.940" LastActivityDate="2015-04-28T14:08:48.940" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2985" PostTypeId="2" ParentId="2983" CreationDate="2015-04-17T19:53:34.570" Score="3" Body="&lt;p&gt;If you start with your cursor on the &lt;code&gt;x&lt;/code&gt; type&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%x``2x&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt; move to the corresponding parenthesis to the one closest to you, i.e. &lt;code&gt;)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;x&lt;/code&gt; delete it&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;``&lt;/code&gt; jump back to your previous jump, the starting &lt;code&gt;x&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2x&lt;/code&gt; delete the next two characters, &lt;code&gt;x(&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want this to be more robust you can do a find next and delete instead of the &lt;code&gt;2x&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%x``df(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works when your function name is variable length.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2015-04-17T19:53:34.570" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2986" PostTypeId="2" ParentId="2983" CreationDate="2015-04-17T22:41:39.390" Score="9" Body="&lt;p&gt;What I use a mapping that leverages Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-surround&quot;&gt;surround.vim&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; dsf ds)db&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use the mapping &lt;code&gt;dsf&lt;/code&gt; to read as delete surrounding function. Execute this mapping while inside the function call or one of the parens. The mapping is supposed to be the opposite of surround.vim's surround with function mappings, e.g. &lt;code&gt;Sf&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-04-17T22:41:39.390" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2987" PostTypeId="2" ParentId="2969" CreationDate="2015-04-17T22:51:59.137" Score="3" Body="&lt;p&gt;From the documention it would seem that it should be using your &lt;code&gt;~/Sites/project&lt;/code&gt; directory. (See &lt;code&gt;:h :NERDTree&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:NERDTree [&amp;lt;start-directory&amp;gt; | &amp;lt;bookmark&amp;gt;]                         *:NERDTree*&#xA;    Opens a fresh NERD tree. The root of the tree depends on the argument&#xA;    given. There are 3 cases: If no argument is given, the current directory&#xA;    will be used.  If a directory is given, that will be used. If a bookmark&#xA;    name is given, the corresponding directory will be used.  For example: &amp;gt;&#xA;        :NERDTree /home/marty/vim7/src&#xA;        :NERDTree foo   (foo is the name of a bookmark)&#xA;&#xA;:NERDTreeToggle [&amp;lt;start-directory&amp;gt; | &amp;lt;bookmark&amp;gt;]             *:NERDTreeToggle*&#xA;    If a NERD tree already exists for this tab, it is reopened and rendered&#xA;    again.  If no NERD tree exists for this tab then this command acts the&#xA;    same as the |:NERDTree| command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;:NERDTreeToggle&lt;/code&gt; is loading the incorrect directory you need to try the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Verify the shell's current working directory. &lt;code&gt;&amp;lt;c-z&amp;gt;&lt;/code&gt; to suspend Vim and then do &lt;code&gt;pwd&lt;/code&gt;. Use &lt;code&gt;fg&lt;/code&gt; to bring back Vim.&lt;/li&gt;&#xA;&lt;li&gt;Make sure your current working directory is set correctly inside of Vim. Check via &lt;code&gt;:pwd&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Do you have some plugin/customization that would change your current working directory?&lt;/li&gt;&#xA;&lt;li&gt;Error still occurring? Create a ticket in &lt;a href=&quot;https://github.com/scrooloose/nerdtree/issues&quot; rel=&quot;nofollow&quot;&gt;NERDTree's tracker&lt;/a&gt;. Make sure you use a minimal vimrc and no plugins other than NerdTree so that others can reproduce this bug.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="778" LastEditorUserId="343" LastEditDate="2015-06-18T11:52:22.177" LastActivityDate="2015-06-18T11:52:22.177" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2988" PostTypeId="1" AcceptedAnswerId="2989" CreationDate="2015-04-17T22:57:10.743" Score="2" ViewCount="110" Body="&lt;p&gt;The command &lt;code&gt;:%s/foo/bar/gc&lt;/code&gt; is to replace all &quot;foo&quot; by &quot;bar&quot; in the global field with confirmation. There are many &quot;foo&quot;s in my file within first 50 lines not to be changed. How can make this command effective only for lines 51 to last line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1080" LastActivityDate="2015-04-18T23:50:35.077" Title="How to replace patterns after line k" Tags="|command-line|replace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2989" PostTypeId="2" ParentId="2988" CreationDate="2015-04-17T23:15:17.997" Score="5" Body="&lt;p&gt;The find and replace command has a range option. In this case you are performing this action against the entire document &lt;code&gt;%&lt;/code&gt;. You can also select a more specific range. So lets say you want to swap lines 51 through 57&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:51,57s/foo/bar/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to go to end of the document use &lt;code&gt;$&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:51,$s/foo/bar/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Per &lt;code&gt;:h range&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line numbers may be specified with:             :range E14 {address}&#xA;        {number}        an absolute line number&#xA;        .               the current line                          :.&#xA;        $               the last line in the file                 :$&#xA;        %               equal to 1,$ (the entire file)            :%&#xA;        't              position of mark t (lowercase)            :'&#xA;        'T              position of mark T (uppercase); when the mark is in&#xA;                        another file it cannot be used in a range&#xA;        /{pattern}[/]   the next line where {pattern} matches     :/&#xA;        ?{pattern}[?]   the previous line where {pattern} matches :?&#xA;        \/              the next line where the previously used search&#xA;                        pattern matches&#xA;        \?              the previous line where the previously used search&#xA;                        pattern matches&#xA;        \&amp;amp;              the next line where the previously used substitute&#xA;                        pattern matches        &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastActivityDate="2015-04-17T23:15:17.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2990" PostTypeId="1" CreationDate="2015-04-18T02:04:49.057" Score="1" ViewCount="93" Body="&lt;p&gt;I have set some options to configure completion on the command line, for commands that support it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the completion on the commandline very often with the &lt;code&gt;:help&lt;/code&gt; command; That will be my example, but my question is about commandline completion in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have only a vague idea how the help topic, I type a substring I expect in the name, and press tab, showing a list of possible completions.&lt;br&gt;&#xA;The list is often long enough to be not easily read through; this is an example where a search in the list would be useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the screen shown below, the substring entered was &lt;code&gt;CTRL-W&lt;/code&gt;. The first &lt;kbd&gt;Tab&lt;/kbd&gt; listed the four columns. (Note it includes variants not starting with the substring.)&lt;br&gt;&#xA;After pressing &lt;kbd&gt;Tab&lt;/kbd&gt; again, the second to last line was shown, repeating part of the table above it. Further &lt;kbd&gt;Tab&lt;/kbd&gt; presses cycle through that line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~                                                                          &#xA;~                                                                          &#xA;~                                                                          &#xA;:help CTRL-W&#xA;CTRL-W           CTRL-W_b         CTRL-W_g]        CTRL-W_CTRL-I&#xA;CTRL-W_+         CTRL-W_c         CTRL-W_g}        CTRL-W_CTRL-J&#xA;CTRL-W_-         CTRL-W_d         c_CTRL-W         CTRL-W_CTRL-K&#xA;CTRL-W_&amp;lt;         CTRL-W_f         i_CTRL-W         CTRL-W_CTRL-L&#xA;CTRL-W_=         CTRL-W_h         CTRL-W_gF        CTRL-W_CTRL-N&#xA;CTRL-W_&amp;gt;         CTRL-W_i         CTRL-W_gf        CTRL-W_CTRL-O&#xA;CTRL-W_]         CTRL-W_j         CTRL-W_&amp;lt;BS&amp;gt;      CTRL-W_CTRL-P&#xA;CTRL-W_^         CTRL-W_k         CTRL-W_&amp;lt;CR&amp;gt;      CTRL-W_CTRL-Q&#xA;CTRL-W__         CTRL-W_l         CTRL-W_&amp;lt;Up&amp;gt;      CTRL-W_CTRL-R&#xA;CTRL-W_}         CTRL-W_n         CTRL-W_bar       CTRL-W_CTRL-S&#xA;CTRL-W_F         CTRL-W_o         CTRL-W_&amp;lt;Down&amp;gt;    CTRL-W_CTRL-T&#xA;CTRL-W_H         CTRL-W_p         CTRL-W_&amp;lt;Left&amp;gt;    CTRL-W_CTRL-V&#xA;CTRL-W_J         CTRL-W_q         CTRL-W_CTRL-]    CTRL-W_CTRL-W&#xA;CTRL-W_K         CTRL-W_r         CTRL-W_CTRL-^    CTRL-W_CTRL-X&#xA;CTRL-W_L         CTRL-W_s         CTRL-W_CTRL-_    CTRL-W_CTRL-Z&#xA;CTRL-W_P         CTRL-W_t         CTRL-W_CTRL-B    CTRL-W_&amp;lt;Enter&amp;gt;&#xA;CTRL-W_R         CTRL-W_v         CTRL-W_CTRL-C    CTRL-W_&amp;lt;Right&amp;gt;&#xA;CTRL-W_S         CTRL-W_w         CTRL-W_CTRL-D    CTRL-W_g_CTRL-]&#xA;CTRL-W_T         CTRL-W_x         CTRL-W_CTRL-F    c_CTRL-R_CTRL-W&#xA;CTRL-W_W         CTRL-W_z         CTRL-W_CTRL-H&#xA;CTRL-W  CTRL-W_+  CTRL-W_-  CTRL-W_&amp;lt;  CTRL-W_=  CTRL-W_&amp;gt;  CTRL-W_]  CTRL-W_^  &amp;gt;&#xA;:help CTRL-W_&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The list of completions is often longer than one page, which causes a prompt for the next page.&lt;br&gt;&#xA;In that case, the search would be even more helpful.&lt;/p&gt;&#xA;" OwnerUserId="925" LastActivityDate="2015-04-18T03:49:42.917" Title="Can I search in the list of available completions on commandline?" Tags="|command-line|autocompletion|help-system|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2991" PostTypeId="2" ParentId="2990" CreationDate="2015-04-18T03:49:42.917" Score="1" Body="&lt;p&gt;You can try the &lt;a href=&quot;http://vimhelp.appspot.com/helphelp.txt.html#%3Ahelpgrep&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;helpgrep&lt;/code&gt;&lt;/a&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helpg[rep] {pattern}[@xx]&#xA;    Search all help text files and make a list of lines&#xA;    in which {pattern} matches.  Jumps to the first match.&#xA;    The optional [@xx] specifies that only matches in the&#xA;    &quot;xx&quot; language are to be found.&#xA;    You can navigate through the matches with the&#xA;    quickfix commands, e.g., :cnext to jump to the&#xA;    next one.  Or use :cwindow to get the list of&#xA;    matches in the quickfix window.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By default, it opens the first match. You can use &lt;code&gt;:clist&lt;/code&gt; to see the list of all matches:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cl&#xA; 1 cmdline.txt:111 col 11: *c_CTRL-W*&#xA; 2 cmdline.txt:112 col 1: CTRL-W          Delete the |word| before the cursor.  This depends on the&#xA; 3 cmdline.txt:138 col 22: &amp;lt;C-C&amp;gt;).  A &amp;lt;BS&amp;gt; or CTRL-W could still end the command line&#xA; 4 cmdline.txt:171 col 8: CTRL-R CTRL-W                           *c_CTRL-R_CTRL-W* *c_&amp;lt;C-R&amp;gt;_&amp;lt;C-W&amp;gt;*&#xA; 5 cmdline.txt:177 col 4: CTRL-W  the Word under the cursor&#xA; 6 cmdline.txt:181 col 44: currently displayed match is used.  With CTRL-W the part of&#xA; 7 cmdline.txt:190 col 44: CTRL-R CTRL-R {0-9a-z&quot;%#:-=. CTRL-F CTRL-P CTRL-W CTRL-A}&#xA; 8 cmdline.txt:191 col 44: CTRL-R CTRL-O {0-9a-z&quot;%#:-=. CTRL-F CTRL-P CTRL-W CTRL-A}&#xA; 9 editing.txt:320 col 5: |CTRL-W_CTRL-F|.&#xA;10 eval.txt:1033 col 52: \&amp;lt;xxx&amp;gt;  Special key named &quot;xxx&quot;.  e.g. &quot;\&amp;lt;C-W&amp;gt;&quot; for CTRL-W.  This is for use&#xA;11 eval.txt:2288 col 33: &amp;lt;               The number can be used with |CTRL-W_w| and &quot;:wincmd w&quot;&#xA;12 eval.txt:6489 col 39: accessed window is returned (where |CTRL-W_p| goes to).&#xA;13 eval.txt:6492 col 32: The number can be used with |CTRL-W_w| and &quot;:wincmd w&quot;&#xA;14 hebrew.txt:105 col 10: cursor.  CTRL-W and CTRL-U also work in the opposite direction.  &amp;lt;BS&amp;gt;, CTRL-W&#xA;15 index.txt:16 col 28: 2.2. Window commands                    |CTRL-W|&#xA;16 index.txt:91 col 4: |i_CTRL-W|      CTRL-W          delete word before the cursor&#xA;17 index.txt:210 col 2: |CTRL-W|        CTRL-W {char}      window commands, see |CTRL-W|&#xA;18 index.txt:502 col 27: 2.2 Window commands                                             *CTRL-W*&#xA;19 index.txt:506 col 2: |CTRL-W_CTRL-B| CTRL-W CTRL-B      same as &quot;CTRL-W b&quot;&#xA;20 index.txt:507 col 2: |CTRL-W_CTRL-C| CTRL-W CTRL-C      same as &quot;CTRL-W c&quot;&#xA;21 index.txt:508 col 2: |CTRL-W_CTRL-D| CTRL-W CTRL-D      same as &quot;CTRL-W d&quot;&#xA;22 index.txt:509 col 2: |CTRL-W_CTRL-F| CTRL-W CTRL-F      same as &quot;CTRL-W f&quot;&#xA;23 index.txt:510 col 3: CTRL-W CTRL-G      same as &quot;CTRL-W g ..&quot;&#xA;-- More --&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is certainly not the same as searching just through the tags, but might be useful.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-04-18T03:49:42.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2992" PostTypeId="2" ParentId="2918" CreationDate="2015-04-18T14:10:32.250" Score="9" Body="&lt;p&gt;You have a few questions, some explicit and some implicit. I'll try to answer them in order:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;What Do These Commands Do?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You're running two commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight DiffChange cterm=none ctermfg=fg ctermbg=Red gui=none guifg=fg guibg=Red&#xA;&#xA;highlight Normal term=none cterm=none ctermfg=White ctermbg=Black gui=none guifg=White guibg=Black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both of these commands set the colors of highlight groups. A highlight group is how Vim sets the color (and formatting) of an element of the text or editor. The various variables you're setting (&lt;code&gt;ctermbg=Red&lt;/code&gt; for example) are how you tell Vim what colors and formatting you'd like. The variables that end in &lt;code&gt;fg&lt;/code&gt; set the foreground (text) color, the variables that end in &lt;code&gt;bg&lt;/code&gt; set the background color, and the variables without a suffix (&lt;code&gt;term&lt;/code&gt;, &lt;code&gt;cterm&lt;/code&gt;, &lt;code&gt;gui&lt;/code&gt;) set the formatting (like &lt;code&gt;Bold&lt;/code&gt;, or &lt;code&gt;Underline&lt;/code&gt;, etc.). You can find the list of formatting options with &lt;code&gt;:h highlight-term&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case you set the color of the &lt;code&gt;DiffChange&lt;/code&gt; group and the &lt;code&gt;Normal&lt;/code&gt; group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get help on these like this: &lt;code&gt;:h hl-DiffChange&lt;/code&gt; and &lt;code&gt;:h hl-Normal&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DiffChange group tells Vim how to highlight lines that have changed in the diff, while the Normal group sets the color of normal text and the background of the editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So putting it together you're telling vim I would like white text on a black background, and when I do a diff, I would like you to keep the text color (the foreground) the same color as it is normally (this is what &lt;code&gt;fg&lt;/code&gt; means, will discuss that in the next section) and change the background to Red.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Why Doesn't &lt;code&gt;fg&lt;/code&gt; Work Initially?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Vim has a few color names that it knows, like &lt;code&gt;White&lt;/code&gt;, &lt;code&gt;Black&lt;/code&gt;, etc. Some of them (the ones understood by the color terminal) are listed with &lt;code&gt;:h cterm-colors&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *cterm-colors*&#xA;    NR-16   NR-8    COLOR NAME&#xA;    0       0       Black&#xA;    1       4       DarkBlue&#xA;    2       2       DarkGreen&#xA;    3       6       DarkCyan&#xA;    4       1       DarkRed&#xA;    5       5       DarkMagenta&#xA;    6       3       Brown, DarkYellow&#xA;    7       7       LightGray, LightGrey, Gray, Grey&#xA;    8       0*      DarkGray, DarkGrey&#xA;    9       4*      Blue, LightBlue&#xA;    10      2*      Green, LightGreen&#xA;    11      6*      Cyan, LightCyan&#xA;    12      1*      Red, LightRed&#xA;    13      5*      Magenta, LightMagenta&#xA;    14      3*      Yellow, LightYellow&#xA;    15      7*      White&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additionally, there are the 'special' &lt;code&gt;fg&lt;/code&gt; and &lt;code&gt;bg&lt;/code&gt; colors that reference the color of the text and the background. Vim gets the colors for these from the normal highlight group. The vim help has this to say about them: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *E419* *E420*&#xA;When Vim knows the normal foreground and background colors, &quot;fg&quot; and&#xA;&quot;bg&quot; can be used as color names.  This only works after setting the&#xA;colors for the Normal group and for the MS-DOS console.  Example, for&#xA;reverse video: &#xA;    :highlight Visual ctermfg=bg ctermbg=fg&#xA;Note that the colors are used that are valid at the moment this&#xA;command are given.  If the Normal group colors are changed later, the&#xA;&quot;fg&quot; and &quot;bg&quot; colors will not be adjusted.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command that you use, &lt;code&gt;highlight Normal term=none cterm=none ctermfg=White ctermbg=Black gui=none guifg=White guibg=Black&lt;/code&gt;, sets the colors for the Normal group to &lt;code&gt;Black&lt;/code&gt; for the backgrounds of the color terminal (&lt;code&gt;ctermbg&lt;/code&gt;) and GUI (&lt;code&gt;guibg&lt;/code&gt;) and &lt;code&gt;White&lt;/code&gt; for the foregrounds (main text color) for the color terminal (&lt;code&gt;ctermfg&lt;/code&gt;) and the GUI (&lt;code&gt;guifg&lt;/code&gt;). After setting that, Vim knows that &lt;code&gt;fg&lt;/code&gt; is &lt;code&gt;White&lt;/code&gt; and &lt;code&gt;bg&lt;/code&gt; is &lt;code&gt;Black&lt;/code&gt;, but before it doesn't and so you can't use &lt;code&gt;fg&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Why Is All The Text Bold?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This is likely a problem with your terminal and not with Vim. If Vim thinks your terminal can only display 8 colors, than all text will be bold. You should make sure your &lt;code&gt;$TERM&lt;/code&gt; variable in your terminal is set correctly. The exact way to do this depends on your shell, but if for example you're using bash in xterm, its likely your terminal is reporting &lt;code&gt;TERM=&quot;xterm&quot;&lt;/code&gt;, when it should be &lt;code&gt;TERM=&quot;xterm-256color&quot;&lt;/code&gt; if it supports 256 colors (and it should if its a modern version). Some information on this can be found on &lt;a href=&quot;http://vim.wikia.com/wiki/256_colors_in_vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;the vim wikia&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check the number of colors vim thinks it can use with &lt;code&gt;:set t_Co?&lt;/code&gt;. If this reports 8 or lower than that is probably your problem. Fixing &lt;code&gt;$TERM&lt;/code&gt; is the right solution, but a hack is to override &lt;code&gt;t_Co&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt;: &lt;code&gt;set t_Co=256&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you let us know what terminal and shell you're running, I can offer more specific advice.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Is There a Better/Simpler Way?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Setting highlight groups in vim is just messy and ugly. Some people have written plugins or scripts to make it &quot;easier&quot; or &quot;cleaner&quot; (for example &lt;a href=&quot;http://www.cgtk.co.uk/vim-scripts/easycolour&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;EasyColour&quot;&gt;EasyColour&lt;/a&gt;, or &lt;a href=&quot;https://stackoverflow.com/a/2445869&quot;&gt;this vimscript function&lt;/a&gt;), but whether those are preferable is really a personal decision.&lt;/p&gt;&#xA;" OwnerUserId="1402" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-04-18T14:10:32.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2993" PostTypeId="1" AcceptedAnswerId="2994" CreationDate="2015-04-18T18:07:00.227" Score="14" ViewCount="3466" Body="&lt;p&gt;Is there a way to split a one-line instruction into several lines?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I'd like to transform&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal variable_name = condition1 ? &quot;1&quot; : condition2 ? &quot;0&quot; : condition3 ? &quot;a long string&quot; : &quot;another long string&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal variable_name = condition1 ? &quot;1&quot; : &#xA;                         condition2 ? &quot;0&quot; : &#xA;                         condition3 ? &quot;a long string&quot; : &#xA;                                      &quot;another long string&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when I try it like above, it raises &quot;Invalid argument&quot; error.&lt;/p&gt;&#xA;" OwnerUserId="1690" LastActivityDate="2015-04-18T18:40:08.683" Title="Several lines instructions" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2994" PostTypeId="2" ParentId="2993" CreationDate="2015-04-18T18:40:08.683" Score="19" Body="&lt;p&gt;To have multiple lines in a vimscript you need to prepend the next lines with &lt;code&gt;\&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal variable_name = condition1 ? &quot;1&quot; : &#xA;                       \ condition2 ? &quot;0&quot; : &#xA;                       \ condition3 ? &quot;a long string&quot; : &#xA;                       \              &quot;another long string&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastActivityDate="2015-04-18T18:40:08.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2995" PostTypeId="1" AcceptedAnswerId="2996" CreationDate="2015-04-18T20:13:17.537" Score="22" ViewCount="25715" Body="&lt;p&gt;I just found out about the &lt;code&gt;:colorscheme&lt;/code&gt; command. Is there a way that I can get a list of valid color schemes from Vim? I'd like to be able to do this from within Vim, not from a list somewhere on the Internet.&lt;/p&gt;&#xA;" OwnerDisplayName="user2" LastActivityDate="2020-04-24T11:09:17.267" Title="List valid color schemes?" Tags="|colorscheme|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2996" PostTypeId="2" ParentId="2995" CreationDate="2015-04-18T20:49:48.683" Score="23" Body="&lt;p&gt;The easiest way is to use &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-D&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help c_Ctrl-d&lt;/code&gt;&lt;/a&gt; after &lt;code&gt;:colorscheme&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;:colorscheme&lt;/code&gt;&lt;kbd&gt;Ctrl-d&lt;/kbd&gt; will output the colorschemes you have available to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure there is a space after &lt;code&gt;:colorscheme &lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="10604" LastEditDate="2020-02-15T19:50:36.087" LastActivityDate="2020-02-15T19:50:36.087" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="2997" PostTypeId="1" AcceptedAnswerId="2999" CreationDate="2015-04-18T22:11:10.933" Score="7" ViewCount="5605" Body="&lt;p&gt;The following command works as expected within vim:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:args `find . -type f`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;as well as this one (with wildcard):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:args `find . -name \*.inc`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However when I run the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:args `find . -type f -not -path &amp;quot;*/\.*&amp;quot;`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I've the error:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;E79: Cannot expand wildcards&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;`find . -type f -not -path&amp;quot; [New File]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It works from the command line as expected:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ find . -type f -not -path &amp;quot;*/\.*&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Basically the extra &lt;code&gt;-not -path &amp;quot;*/\.*&amp;quot;&lt;/code&gt; means to ignore all the hidden files starting with dot, such as git repository files.&lt;/p&gt;&#xA;&lt;p&gt;What I'm doing wrong? Do some characters needs to be escaped (which one)?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-04-18T23:51:05.623" Title="Why vim cannot expand wildcards from the external command?" Tags="|external-command|multiple-files|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2998" PostTypeId="2" ParentId="2776" CreationDate="2015-04-18T22:46:13.277" Score="1" Body="&lt;p&gt;To replace phrase with another one, you can use Vim Ex mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example (&lt;code&gt;ex&lt;/code&gt; is alias to &lt;code&gt;vim -E&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex -s +'bufdo!%s/foo/bar/g' -cxa *.*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Recursively in bash/zsh (with &lt;code&gt;globstar&lt;/code&gt; set, e.g. &lt;code&gt;shopt -s globstar&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex -s +'bufdo!%s/foo/bar/g' -cxa **/*.*&#xA;$ ex -s +'n **/*.*' +'bufdo!%s/foo/bar/g' -cxa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Recursively (using &lt;code&gt;find&lt;/code&gt; and ignore hidden files such as &lt;code&gt;.git&lt;/code&gt; files):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ find . -type f -not -path '*/\.*' -exec ex -s +'bufdo!%s/foo/bar/g' -cxa {} &quot;+&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: The &lt;code&gt;:bufdo&lt;/code&gt; command is not &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;POSIX&lt;/a&gt;.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: Syntax &lt;code&gt;-not -path '*/\.*'&lt;/code&gt; is used to ignore hidden files (such as &lt;code&gt;.git&lt;/code&gt;).&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2017-11-16T12:24:18.377" LastActivityDate="2017-11-16T12:24:18.377" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2999" PostTypeId="2" ParentId="2997" CreationDate="2015-04-18T23:13:18.953" Score="11" Body="&lt;p&gt;You were close. Enclose the path pattern in single quotes instead of double quotes for the find command like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;args `find . -type f -not -path '*/\.*'`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By the way, a handy way to ignore hidden files is to use &lt;code&gt;:args **&lt;/code&gt;. But this will include folders too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not completely sure why you need to enclose it in single quotes, I believe that Vim will evaluate the special characters inside double quotes. See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-quote&quot;&gt;&lt;code&gt;:help expr-quote&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#literal-string&quot;&gt;&lt;code&gt;:help literal-string&lt;/code&gt;&lt;/a&gt;. A single quote will treat the pattern as a literal string and prevent Vim evaluating special characters inside the quote. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, since &lt;code&gt;\.&lt;/code&gt; is one of the special characters Vim will evaluate in a double quoted string, I believe this was the culprit.&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="246" LastEditDate="2015-04-18T23:51:05.623" LastActivityDate="2015-04-18T23:51:05.623" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3000" PostTypeId="2" ParentId="2988" CreationDate="2015-04-18T23:50:35.077" Score="1" Body="&lt;p&gt;As an alternative, if you don't know the line number you can use &lt;code&gt;:global&lt;/code&gt; to find the pattern that indicates the point where you want to start substituting. E.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/regex pattern/,$s/foo/bar/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;,$&lt;/code&gt; part extends the range until the end of the file.&lt;/p&gt;&#xA;" OwnerUserId="599" LastActivityDate="2015-04-18T23:50:35.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3001" PostTypeId="1" AcceptedAnswerId="3080" CreationDate="2015-04-19T10:48:18.533" Score="8" ViewCount="788" Body="&lt;p&gt;When entering or doing any command mode modifications to a read only file for the first time you will get the warning&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;W10: Warning: Changing a readonly file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's fine, but this also introduces a second or two delay before the action actually &lt;em&gt;happens&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to disable this delay?&lt;/p&gt;&#xA;" OwnerUserId="1787" LastEditorUserId="15" LastEditDate="2015-04-19T12:16:06.673" LastActivityDate="2023-09-19T03:59:09.460" Title="Remove the insert delay after entering insert in a read-only file" Tags="|insert-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3002" PostTypeId="2" ParentId="2607" CreationDate="2015-04-19T14:51:14.773" Score="0" Body="&lt;p&gt;Opening files by &lt;code&gt;vim */.git/config&lt;/code&gt; definitely should work. If it doesn't, you should upgrade your Vim to 7.4 (previous version was more buggy).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively try one of the following (within the editor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:n `find .git/ -name config`&#xA;:args `find . -name config`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-04-19T14:51:14.773" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3003" PostTypeId="1" AcceptedAnswerId="3004" CreationDate="2015-04-19T15:05:00.167" Score="4" ViewCount="295" Body="&lt;p&gt;I would like to be able to add the ’ character to &lt;code&gt;iskeyword&lt;/code&gt; setting.  I'm currently using this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Count ’ as a part of words like I’m and you’re¬&#xA;au FileType plaintex,context,tex,latex,mail,markdown,textile,text set iskeyword+=’&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I'm getting and invalid keyword argument for this on my version of vim.  I believe I'm using the latest vim for my system:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 25 2015 19:31:37)&#xA;MacOS X (unix) version&#xA;Included patches: 1-622&#xA;Compiled by Homebrew&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should I be specifying this differently?  Is it possible to add UTF8 characters to the &lt;code&gt;iskeyword&lt;/code&gt; setting?&lt;/p&gt;&#xA;" OwnerUserId="1008" LastEditorUserId="24" LastEditDate="2015-04-19T19:53:52.413" LastActivityDate="2015-04-19T20:02:02.940" Title="How to use a UTF8 character as part of the iskeyword setting?" Tags="|unicode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3004" PostTypeId="2" ParentId="3003" CreationDate="2015-04-19T19:48:09.593" Score="3" Body="&lt;p&gt;&lt;code&gt;:help 'iskeyword'&lt;/code&gt; points to &lt;code&gt;:help 'isfname'&lt;/code&gt; which says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;only the characters up to 255 are specified with this option&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;’&lt;/code&gt; (&lt;code&gt;U+2019&lt;/code&gt;) is not part of the ASCII (0-127) or Extended ASCII (128-255) tables you can't add it or remove it from &lt;code&gt;'iskeyword'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which is a good thing because it is used as an apostrophe and thus &lt;em&gt;can't&lt;/em&gt; be considered part of a word.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-04-19T20:02:02.940" LastActivityDate="2015-04-19T20:02:02.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3005" PostTypeId="2" ParentId="2995" CreationDate="2015-04-19T19:48:41.643" Score="10" Body="&lt;p&gt;Another way to show the list is by &lt;code&gt;set wildmenu&lt;/code&gt;. With this, after &lt;code&gt;:colorscheme&lt;/code&gt; + &lt;code&gt;space&lt;/code&gt; + &lt;code&gt;tab&lt;/code&gt;, a list of completion is displayed and also selectable with arrow key or &lt;code&gt;Ctrl-N&lt;/code&gt; and &lt;code&gt;Ctrl-P&lt;/code&gt;. This is not only work on colorscheme, but also on other cmdline completion. The behavior is affected by &lt;code&gt;wildmode&lt;/code&gt; and better set to the default value &lt;code&gt;full&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1782" LastActivityDate="2015-04-19T19:48:41.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3006" PostTypeId="1" AcceptedAnswerId="3007" CreationDate="2015-04-19T20:00:05.967" Score="29" ViewCount="19467" Body="&lt;p&gt;How can I move the cursor to the &lt;i&gt;n&lt;/i&gt;&lt;sup&gt;th&lt;/sup&gt; byte in the buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I display the current cursor position in the ruler in terms of the byte offset, rather than lines and columns?  (Follow-up question: can it be displayed in both decimal and hexadecimal?)&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2021-01-28T19:28:28.413" Title="Jumping to a byte offset, and displaying position as byte offset" Tags="|cursor-movement|statusline|binary-file|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3007" PostTypeId="2" ParentId="3006" CreationDate="2015-04-19T20:06:48.340" Score="30" Body="&lt;pre&gt;&lt;code&gt;:goto 2356&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;jumps to the 2356th byte in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;%o&lt;/code&gt; field in &lt;code&gt;'statusline'&lt;/code&gt; or &lt;code&gt;'rulerformat'&lt;/code&gt; to display the byte number of the character under your cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;%O&lt;/code&gt; to display the value in hexadecimal format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :goto&#xA;:help 'statusline'&#xA;:help 'rulerformat'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-04-19T20:06:48.340" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3008" PostTypeId="1" AcceptedAnswerId="21608" CreationDate="2015-04-19T21:49:37.503" Score="4" ViewCount="606" Body="&lt;p&gt;I'm playing with &lt;code&gt;ex&lt;/code&gt; and I've found that removing trailing spaces for multiple files in silent mode doesn't work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following examples doesn't work as expected (whatever I use &lt;code&gt;argdo&lt;/code&gt; or &lt;code&gt;bufdo&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex -s +'argdo! %s/\s\+$//e' -cxa *.*&#xA;$ ex -s +'bufdo! %s/\s\+$//e' -cxa *.*&#xA;(nothing is changed)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My files have trailing spaces as I've tested in git repository, so I could easily check the changes via &lt;code&gt;git diff&lt;/code&gt;. And in addition exactly the same command (without &lt;code&gt;-s&lt;/code&gt;) works as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +'bufdo! %s/\s\+$//e' -cxa *.*&#xA;7 files to edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's more unexpected, silent mode works for other example such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex -s +'bufdo! %s/foo/bar/e' -cxa *.*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'm doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Debugging with &lt;code&gt;-V10&lt;/code&gt; doesn't give me much useful information I guess.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="51" LastEditDate="2015-06-28T16:55:48.907" LastActivityDate="2019-10-22T12:50:17.927" Title="Why substitute doesn't work in silent mode?" Tags="|substitute|ex-mode|silent-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3009" PostTypeId="5" CreationDate="2015-04-19T21:57:03.597" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-04-19T21:57:03.597" LastActivityDate="2015-04-19T21:57:03.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3010" PostTypeId="4" CreationDate="2015-04-19T21:57:03.597" Score="0" Body="Silent mode is only when started Vim as &quot;ex&quot; or when the &quot;-e&quot; option was given before the &quot;-s&quot; option." OwnerUserId="467" LastEditorUserId="15" LastEditDate="2015-04-20T20:50:20.253" LastActivityDate="2015-04-20T20:50:20.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3011" PostTypeId="5" CreationDate="2015-04-19T22:02:52.163" Score="0" Body="&lt;p&gt;Ex is the root of a family of editors: edit, ex and vi.&#xA;The original &lt;code&gt;ex&lt;/code&gt; was an advanced version of the standard Unix editor &lt;code&gt;ed&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read more:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Ex_(text_editor)&quot; rel=&quot;nofollow&quot;&gt;ex&lt;/a&gt; at Wikipedia&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://meta.vi.stackexchange.com/q/1259/467&quot;&gt;What's difference between ex and ex-mode tags?&lt;/a&gt; at Vim SE&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-04-20T08:15:14.447" LastActivityDate="2015-04-20T08:15:14.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3012" PostTypeId="4" CreationDate="2015-04-19T22:02:52.163" Score="0" Body="ex is an advanced version of the standard Unix editor ed. It is the direct predecessor of vi." OwnerUserId="467" LastEditorUserId="51" LastEditDate="2015-05-28T11:25:55.940" LastActivityDate="2015-05-28T11:25:55.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3013" PostTypeId="1" AcceptedAnswerId="3014" CreationDate="2015-04-19T22:27:16.810" Score="11" ViewCount="2379" Body="&lt;p&gt;Let say I have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:letter = 'A'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is there a function that takes &lt;code&gt;l:letter&lt;/code&gt; ascii code and transforms it to &lt;code&gt;'B'&lt;/code&gt;? I mean something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:next_letter = l:letter + 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know there's &lt;code&gt;&amp;lt;Ctrl-A&amp;gt;&lt;/code&gt; with &lt;code&gt;set nf=alpha&lt;/code&gt;, but that requires to have the cursor over the character in the document and I was wondering if it's possible to do it with a variable without modifying the document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I try so far, but as I said, it modifies the document and the cursor position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:get_next_char(letter)&#xA;    set nf=octal,hex,alpha&#xA;    call setline(line('$') + 1, a:letter)&#xA;    exe ':normal! G^'.&quot;\&amp;lt;C-A&amp;gt;&quot;&#xA;    set nf=octal,hex&#xA;&#xA;    let l:next_letter = getline('$')&#xA;    normal! Gdd&#xA;    return l:next_letter&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1690" LastEditorUserId="1690" LastEditDate="2015-04-19T22:45:18.243" LastActivityDate="2018-08-08T12:03:37.673" Title="Manipulate chars with their ascii code" Tags="|vimscript|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3014" PostTypeId="2" ParentId="3013" CreationDate="2015-04-20T00:22:04.977" Score="14" Body="&lt;p&gt;It's easy to do with &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#nr2char%28%29&quot;&gt;&lt;code&gt;:help nr2char()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#char2nr%28%29&quot;&gt;&lt;code&gt;:help char2nr()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example usage:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:let b_char = nr2char(char2nr('A') + 1)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, &lt;code&gt;:echo b_char&lt;/code&gt; will return 'B'&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="246" LastEditDate="2015-04-20T00:38:38.050" LastActivityDate="2015-04-20T00:38:38.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3015" PostTypeId="2" ParentId="3013" CreationDate="2015-04-20T08:34:46.490" Score="4" Body="&lt;p&gt;The question is (emphasis mine):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;is there a &lt;strong&gt;function&lt;/strong&gt; that takes &lt;code&gt;l:letter&lt;/code&gt; ascii code and transforms it to 'B'?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since you want a &lt;em&gt;function&lt;/em&gt;, the first thing to try is &lt;code&gt;:help function&amp;lt;C-d&amp;gt;&lt;/code&gt; which lists every documentation tag containing &lt;code&gt;function&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:function                    list-functions               folding-functions&#xA;function()                   time-functions               history-functions&#xA;functions                    mark-functions               mapping-functions&#xA;function-key                 text-functions               various-functions&#xA;function_key                 compl-function               numbered-function&#xA;function-list                local-function               autoload-functions&#xA;:function-verbose            spell-functions              quickfix-functions&#xA;function-argument            float-functions              complete-functions&#xA;nb-functions                 style-functions              anonymous-function&#xA;function-search-undo         ft-ada-functions             Dictionary-function&#xA;gui-functions                string-functions             completion-functions&#xA;arg-functions                server-functions             window-size-functions&#xA;var-functions                cursor-functions             interactive-functions&#xA;function-range-example       window-functions             command-line-functions&#xA;expr-function                buffer-functions             highlighting-functions&#xA;new-functions-5.2            system-functions             curly-braces-function-names&#xA;date-functions               syntax-functions             python-Function&#xA;dict-functions               xterm-function-keys          :endfunction&#xA;file-functions               vt100-function-keys          :delfunction&#xA;user-functions               bitwise-function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The most obvious candidate is &lt;code&gt;function-list&lt;/code&gt;, let's try it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;There are many functions.  We will mention them here, grouped by what they are&#xA;used for.  You can find an alphabetical list here: |functions|.  Use CTRL-] on&#xA;the function name to jump to detailed help on it.&#xA;&#xA;String manipulation:                    *string-functions*&#xA;    nr2char()       get a character by its ASCII value&#xA;    char2nr()       get ASCII value of a character&#xA;    [...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may have noticed a pattern, here: functions are grouped by theme. This means that, if you need a function to filter a &lt;em&gt;list&lt;/em&gt; you can go directly to &lt;code&gt;:help list-functions&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Vim help pages are very useful; often times &lt;code&gt;:help &amp;lt;keyword&amp;gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; will get you a long way ;-)&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="51" LastEditDate="2018-08-08T12:03:37.673" LastActivityDate="2018-08-08T12:03:37.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3016" PostTypeId="1" AcceptedAnswerId="3020" CreationDate="2015-04-20T11:35:52.287" Score="5" ViewCount="1115" Body="&lt;p&gt;Using &lt;code&gt;:buffers&lt;/code&gt; results&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:buffers&#xA;  1 %a   &quot;my-jspage.md&quot;                 line 11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are there any options so &lt;code&gt;:buffers&lt;/code&gt; will list full path and filename? E.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:buffers&#xA;  1 %a   &quot;d:\projects\self-org\my-jspage.md&quot;                 line 11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm on windows Vim 7.4-656. I'm aware of &lt;code&gt;:ls&lt;/code&gt; :)&lt;/p&gt;&#xA;" OwnerUserId="1373" LastEditorUserId="1373" LastEditDate="2015-04-20T11:41:53.347" LastActivityDate="2015-04-20T12:53:41.830" Title="Buffers comand to show full path and filename" Tags="|buffers|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3017" PostTypeId="2" ParentId="3016" CreationDate="2015-04-20T12:19:53.817" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Are there any options so &lt;code&gt;:buffers&lt;/code&gt; will list full path and filename?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, but you can use &lt;code&gt;fnamemodify()&lt;/code&gt; to find out the full path:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo fnamemodify(bufname(1), ':p')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-04-20T12:19:53.817" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3018" PostTypeId="1" AcceptedAnswerId="3019" CreationDate="2015-04-20T12:22:35.787" Score="2" ViewCount="158" Body="&lt;p&gt;When I have heredoc and I format it with gq I want it to be aligned in a way so each line starts at the same column like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Long text goes here ...                    80 chars |&#xA;    &amp;lt;- whitespace preserved ...                80 chars |&#xA;    &amp;lt;- still whitespace ...                    80 chars |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is what I get instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Long text goes here ...                    80 chars |&#xA;&amp;lt;- whitespace preserved ...                    80 chars |&#xA;&amp;lt;- still whitespace ...                        80 chars |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to reflow the text while preserving the left whitespace?&lt;/p&gt;&#xA;" OwnerUserId="237" LastActivityDate="2015-04-20T12:47:03.243" Title="`gq` with left whitespace intact" Tags="|formatting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3019" PostTypeId="2" ParentId="3018" CreationDate="2015-04-20T12:47:03.243" Score="3" Body="&lt;p&gt;&lt;code&gt;:set autoindent&lt;/code&gt; will ensure that new lines have the same indentation as the previous line. This will also happen when you hit enter in insert mode (or any other time you add a new line, like o/O).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this is a local setting, so it would have to be set in each buffer you want this to happen in. To get around this, you can use autocmds or filetype files so that the setting is applied whenever you open a new buffer with a certain filetype.&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-04-20T12:47:03.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3020" PostTypeId="2" ParentId="3016" CreationDate="2015-04-20T12:53:41.830" Score="10" Body="&lt;p&gt;Vim reduces the filespec of the open buffers to a shorter, relative representation. (That's a feature, not a bug.) You can work around that behavior by switching the current working directory (temporarily) to the file system root / (on Windows:) to a drive not currently used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cd C:/ | buffers | cd -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-20T12:53:41.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3021" PostTypeId="1" CreationDate="2015-04-21T06:02:17.187" Score="4" ViewCount="763" Body="&lt;p&gt;Normally, when I use the up/down arrow keys to move between lines in insert mode (I'm using Vim wrong, I know), Vim remembers which column my cursor is in, so if I move to a line shorter than where my cursor is, then back to a longer line, the cursor pops right back to the same column. This is what I want and expect to happen, as well as what happens most of the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I'm editing a Java sourcecode file and the last character in the shorter line is an opening or closing curly brace, square bracket, or parenthesis, Vim seems to forget entirely that the cursor was ever in any column other than the one immediately after the brace. The result is the I often find my cursor near the beginning of a line of code when I want and expect it to be at the end, so I have to $a to get back. Since this is Java, I have a lot of short lines ending with curly braces- so this is really annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The weird part is that this only happens in insert mode- in normal mode, the arrows as well as j and k work fine. It's also weird that it only happens with those six grouping symbols- blank lines, lines with only whitespace, typical comments, and lines ending with semicolons cause no trouble in either mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not a bug in the Java plugin that I'm using- the exact same behavior happens in a .txt file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried typing &lt;code&gt;:au CursorHold&lt;/code&gt;, as instructed by one or two other answers to related questions, but it only prints &lt;code&gt;--- Auto-Commands ---&lt;/code&gt; in purple text, and nothing to direct me to a bugged script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related: I recently upgraded my Apple-installed version of Vim 7.3 to Homebrew-installed Vim 7.4, which did not have this problem. I'm also on a Mac (and no, I'm not using GVim or MacVim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I derped in writing the last paragraph above. Apple's Vim 7.3 install did not have this issue; Homebrew's Vim 7.4 did. Not that it matters now...&lt;/p&gt;&#xA;" OwnerUserId="1809" LastEditorUserId="1809" LastEditDate="2015-04-22T02:02:03.397" LastActivityDate="2015-04-22T22:41:16.870" Title="Vim forgets cursor column when I move over a line that ends with a brace in insert mode" Tags="|cursor-movement|insert-mode|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3022" PostTypeId="2" ParentId="2961" CreationDate="2015-04-21T12:01:28.237" Score="2" Body="&lt;p&gt;Yes, this is possible. However, the answer depends on the choice of PDF viewer, and it is not necessarily straightforward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to enable such synchronization, you must enable &lt;a href=&quot;https://tex.stackexchange.com/questions/118489/what-exactly-is-synctex&quot;&gt;synctex&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due to the complexity of the answer, I will instead refer you to my LaTeX plugin &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt;, which has implemented such synchronization support for several PDF viewers. More viewers may be added relatively easily if desired/needed. &lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/autoload/vimtex/view.vim#L286&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is an example of how a command may be built that opens a PDF viewer (in this case SumatraPDF, which is only available on Windows) and performs a forward search from the vim location to the corresponding location in the PDF.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="-1" LastEditDate="2017-04-13T12:34:32.317" LastActivityDate="2015-04-21T12:01:28.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3023" PostTypeId="2" ParentId="3021" CreationDate="2015-04-22T02:17:35.920" Score="3" Body="&lt;p&gt;Problem solved! I tried typing :au CursorMovedI as tivn suggested in the comments, which said something about matchparen. I then typed :scriptnames, and lo and behold, it showed a matchparen.vim plugin installed in one of Homebrew's directories. CursorMovedI appeared in that file exactly once, in an augroup that looked like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup matchparen&#xA;  &quot; Replace all matchparen autocommands&#xA;  autocmd! CursorMoved,CursorMovedI,WinEnter * call s:Highlight_Matching_Pair()&#xA;  if exists('##TextChanged')&#xA;    autocmd! TextChanged,TextChangedI * call s:Highlight_Matching_Pair()&#xA;  endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then commented out the third line (the first autocmd! line) by prepending it with a quote, restarted Vim, and everything seems to be working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anything else breaks because of this, I'll know where to look.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to @tivn for pointing out :au CursorMovedI (that's a capital i at the end), which led me to this solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;br&gt;&#xA;This fix appears to break the matching parenthesis highlighting; however, thanks to @tivn again, the source of the problem appears to be a bug in either the getcurpos() or setpos() functions called later in my matchparen.vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both of these commands exist in if statements that appear to use these functions if the exist, or use the winsaveview() or winrestview(). Commenting out these if statements so that the win...view() functions are called no matter what fixes the cursor issue without also breaking the parenthesis highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, here's the code on lines 88-99 of the unedited plugin file installed by Homebrew:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let has_getcurpos = exists(&quot;*getcurpos&quot;)&#xA;    if has_getcurpos&#xA;      &quot; getcurpos() is more efficient but doesn't exist before 7.4.313.&#xA;      let save_cursor = getcurpos()&#xA;    else&#xA;      let save_cursor = winsaveview()&#xA;    endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Commenting out the inner if statement, except the line containing winsaveview(), results in this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let has_getcurpos = exists(&quot;*getcurpos&quot;)&#xA; &quot;   if has_getcurpos&#xA; &quot;     &quot; getcurpos() is more efficient but doesn't exist before 7.4.313.&#xA; &quot;     let save_cursor = getcurpos()&#xA; &quot;   else&#xA;      let save_cursor = winsaveview()&#xA; &quot;   endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Making this change, doing the same to lines 163-169, and uncommenting the autocmd! line above, seems to solve the cursor issue without causing any more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I'm using Vim 7.4.488. A pastebin of my matchparen.vim with these edits is available &lt;a href=&quot;http://pastebin.com/ZkJXadR5&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1809" LastEditorUserId="1809" LastEditDate="2015-04-22T22:41:16.870" LastActivityDate="2015-04-22T22:41:16.870" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3024" PostTypeId="1" AcceptedAnswerId="34946" CreationDate="2015-04-22T04:10:40.850" Score="16" ViewCount="1287" Body="&lt;p&gt;I am looking for English grammar checker for vim-latex suite that checks the grammar as I type but does not highlight what's inside &lt;code&gt;$$&lt;/code&gt; or &lt;code&gt;\begin{equation}&lt;/code&gt; &amp;amp; &lt;code&gt;\end{equation}&lt;/code&gt; commands. Is there any such a thing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that there is a LanguageTool but it seems that it does not work with &lt;code&gt;.tex&lt;/code&gt; file.&lt;/p&gt;&#xA;" OwnerUserId="1819" LastEditorUserId="51" LastEditDate="2015-04-28T14:27:10.570" LastActivityDate="2021-11-10T22:01:22.073" Title="Inline English grammar checker for vim-latex?" Tags="|plugin-vim-latex|filetype-tex|grammar-checking|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3025" PostTypeId="1" AcceptedAnswerId="3027" CreationDate="2015-04-22T05:51:15.230" Score="4" ViewCount="723" Body="&lt;p&gt;How do I search in multiple files for 1st line of file matching a pattern?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. I want to search for files starting with &lt;code&gt;++&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;++ Heading 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and not&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+ Heading 1&#xA;&#xA;++ Heading 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any pointers appreciated.&lt;/p&gt;&#xA;" OwnerUserId="1820" LastEditorUserId="467" LastEditDate="2015-04-22T17:32:19.617" LastActivityDate="2016-04-18T09:27:09.597" Title="How to search for a matching pattern only in the first line across multiple files?" Tags="|search|multiple-files|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3026" PostTypeId="2" ParentId="3025" CreationDate="2015-04-22T08:42:27.423" Score="0" Body="&lt;p&gt;For doing something to multiple files, &lt;code&gt;:argdo&lt;/code&gt; is your friend. You might need to edit the argument list first. It's set to the opened files on vim start, you can output it with &lt;code&gt;:args&lt;/code&gt; and set it with, e.g., &lt;code&gt;:args *.txt&lt;/code&gt;. After that, a simple &lt;code&gt;:argdo /^++&lt;/code&gt; will search for the first line that starts with &lt;code&gt;++&lt;/code&gt; and puts the cursor there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That assumes the cursor is on the first line of each buffer. To assure that, use &lt;code&gt;:argdo :normal 1G&lt;/code&gt; first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you did not specify to do anything special with that line, so I've just performed the search here (search as in &quot;put the cursor there&quot;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: If you wanto to substitute something, just use the usual vim command for argdo, i.e. &lt;code&gt;:argdo %s/^++/--/ge&lt;/code&gt;. Note that for edits you should use &lt;code&gt;:set hidden&lt;/code&gt;, otherwise it won't be able to switch buffers. Use the &lt;code&gt;e&lt;/code&gt; qualifier for the substitution so the command doesn't stop at a buffer with no match.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="1296" LastEditDate="2015-04-22T10:52:08.893" LastActivityDate="2015-04-22T10:52:08.893" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3027" PostTypeId="2" ParentId="3025" CreationDate="2015-04-22T11:46:11.737" Score="5" Body="&lt;p&gt;Use &lt;code&gt;:vimgrep&lt;/code&gt; as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /\%(\%&amp;lt;2l\)foo/ *.*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will search for &lt;code&gt;foo&lt;/code&gt; in all files in the current folders (&lt;code&gt;*.*&lt;/code&gt;) only in the 1st line (&lt;code&gt;&amp;lt;2l&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively may search either in the current file (&lt;code&gt;%&lt;/code&gt;), certain files (&lt;code&gt;*.c&lt;/code&gt;) or recursively (&lt;code&gt;**/*.*&lt;/code&gt;, see: &lt;code&gt;:help starstar-wildcard&lt;/code&gt;). See: &lt;code&gt;:help :vimgrep&lt;/code&gt; and &lt;code&gt;:help /\%&amp;gt;l&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To jump between patterns, use &lt;code&gt;:cn[ext]&lt;/code&gt; and &lt;code&gt;:cp[revious]&lt;/code&gt;. See more at &lt;a href=&quot;https://stackoverflow.com/q/7880372/55075&quot;&gt;SO&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However there is no straight forward solution to use &lt;a href=&quot;https://stackoverflow.com/q/5686206/55075&quot;&gt;substitution on quickfix list&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To search and replace pattern for the first line only for multiple-files, you can use Ex command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +'bufdo!1s/php/bar/ge' -cxa *.*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: The &lt;code&gt;:bufdo&lt;/code&gt; command is not &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;POSIX&lt;/a&gt;.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-04-18T09:27:09.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3028" PostTypeId="1" CreationDate="2015-04-22T14:07:03.780" Score="5" ViewCount="956" Body="&lt;p&gt;As a poor-mans refactoring, I'd like to do a search and replace, but omit strings that are in double quotes (C/C++ quoting rules). For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cout &amp;lt;&amp;lt; &quot;Some variable &quot; &amp;lt;&amp;lt; variable &amp;lt;&amp;lt; endl;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;replacing &lt;code&gt;variable&lt;/code&gt; &lt;code&gt;-&amp;gt;&lt;/code&gt; &lt;code&gt;m_variable&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cout &amp;lt;&amp;lt; &quot;Some variable &quot; &amp;lt;&amp;lt; m_variable &amp;lt;&amp;lt; endl;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I'd like the equivalent of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/variable/m_variable/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but ignoring text in quotes.&#xA;Is there a way to do this in vim?&lt;/p&gt;&#xA;" OwnerUserId="1825" LastActivityDate="2015-04-23T10:46:40.940" Title="Search and replace, but ignore text in quotes" Tags="|substitute|filetype-c++|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3029" PostTypeId="2" ParentId="454" CreationDate="2015-04-22T14:46:07.513" Score="5" Body="&lt;p&gt;Exapnding on &lt;a href=&quot;https://vi.stackexchange.com/questions/454/whats-the-simplest-way-to-strip-trailing-whitespace-from-all-lines-in-a-file/2285#2285&quot;&gt;Christopher Bottoms's answer a bit&lt;/a&gt;: Jonathan Palardy &lt;a href=&quot;https://technotales.wordpress.com/2010/03/31/preserve-a-vim-function-that-keeps-your-state/&quot; rel=&quot;nofollow noreferrer&quot;&gt;wrote a good article on this&lt;/a&gt;. In it, he writes a functions, &lt;code&gt;Preserve(command)&lt;/code&gt;, that preserves the state of the editor (mainly cursor position and last search pattern) while running an arbitrary command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Preserve(command)&#xA;  &quot; Preparation: save window state&#xA;  let l:saved_winview = winsaveview()&#xA;  &quot; Run the command:&#xA;  execute a:command&#xA;  &quot; Clean up: restore previous window position&#xA;  call winrestview(l:saved_winview)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has the advantage being multipurpose, for example you can use it to replace all trailing whitespace (as Jonathan does) by mapping this to :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :call Preserve(&quot;%s/\\s\\+$//e&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use it for a visual mode mapping to just remove the trailing spaces on visually selected lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;F5&amp;gt; :call Preserve(&quot;'&amp;lt;,'&amp;gt;s/\\s\\+$//e&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can use it for other calls, like formatting the whole document using &lt;code&gt;=&lt;/code&gt; while retaining your place (well use a different key this time so as not to conflict):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F6&amp;gt; :call Preserve(&quot;normal gg=G&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All and all, I've found the &lt;code&gt;Preserve(command)&lt;/code&gt; function to be a nice tool to have.&lt;/p&gt;&#xA;" OwnerUserId="1402" LastEditorUserId="1402" LastEditDate="2017-12-14T22:12:36.080" LastActivityDate="2017-12-14T22:12:36.080" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3030" PostTypeId="2" ParentId="3028" CreationDate="2015-04-22T15:30:59.593" Score="5" Body="&lt;p&gt;It can be done by testing the syntax name behind the variable to replace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/variable/\=(match(map(synstack(line('.'), col('.')), 'synIDattr(v:val, &quot;name&quot;)'), '\cstring')==-1 ? 'NEw' : submatch(0))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But nobody will want to use that. Instead, we'd better define a new command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -bang -nargs=1 -range SubstituteUnlesString &#xA;    \ &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call s:SubstituteUnlessString(&quot;&amp;lt;bang&amp;gt;&quot;, &amp;lt;f-args&amp;gt;)&#xA;&#xA;&quot; Function: s:SubstituteUnlessString(bang, repl_arg) {{{3&#xA;function! s:SubstituteUnlessString(bang, repl_arg) range abort&#xA;  let do_loop = a:bang != &quot;!&quot;&#xA;  let sep = a:repl_arg[0]&#xA;  let fields = split(a:repl_arg, sep)&#xA;  let cleansed_fields = map(copy(fields), 'substitute(v:val, &quot;\\\\[&amp;lt;&amp;gt;]&quot;, &quot;&quot;, &quot;g&quot;)')&#xA;  &quot; build the action to execute&#xA;  if fields[1] =~ '^\\='&#xA;    let replacement = matchstr(fields[1], '^\\=\zs.*')&#xA;  elseif fields[1] =~ '&amp;amp;\|\\\d'&#xA;    let replacement = &quot;'&quot;.substitute(fields[1], '&amp;amp;\|\\\(\d\)', '\=string(&quot;.submatch(&quot;.(submatch(0)==&quot;&amp;amp;&quot;?&quot;0&quot;:submatch(1)).&quot;).&quot;)', 'g') .&quot;'&quot;&#xA;  else&#xA;    let replacement = string(fields[1])&#xA;  endif&#xA;  let action = '\=(match(map(synstack(line(&quot;.&quot;), col(&quot;.&quot;)), &quot;synIDattr(v:val, \&quot;name\&quot;)&quot;), &quot;\\cstring&quot;)==-1 ? '.replacement.' : submatch(0))'&#xA;  let cmd = a:firstline . ',' . a:lastline . 's'&#xA;    \. sep . fields[0]&#xA;    \. sep . action&#xA;        \. sep.(len(fields)&amp;gt;=3 ? fields[2] : '')&#xA;  &quot; echomsg cmd&#xA;  exe cmd&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That you would be able to use this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%SubstituteUnlessString/variable/m_variable/g&#xA;&quot; or&#xA;:1,3SubstituteUnlessString#variable#m_&amp;amp;#g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yeah. It's a bit overkill. The &lt;code&gt;c&lt;/code&gt; flag from &lt;code&gt;:substitute&lt;/code&gt; is more than enough.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2015-04-22T16:13:48.390" LastActivityDate="2015-04-22T16:13:48.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3031" PostTypeId="1" AcceptedAnswerId="5583" CreationDate="2015-04-22T16:15:02.120" Score="4" ViewCount="1426" Body="&lt;p&gt;I have vim save my undo history in files named something like &lt;code&gt;.filename.js.un~&lt;/code&gt;, but I don't want this cluttering up my list of file in vim (in Netrw).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to exclude all files with a certain file extension in Netrw?&lt;/p&gt;&#xA;" OwnerUserId="226" LastActivityDate="2015-11-23T19:46:35.833" Title="How to Get Netrw to exclude certain files?" Tags="|netrw|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3032" PostTypeId="2" ParentId="3031" CreationDate="2015-04-22T17:10:33.937" Score="4" Body="&lt;p&gt;Use &lt;code&gt;g:netrw_list_hide&lt;/code&gt;. e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_list_hide= '.*\.swp$'&#xA;let g:netrw_hide = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information see &lt;code&gt;:h g:netrw_list_hide&lt;/code&gt; and &lt;code&gt;:h netrw-edithide&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-04-22T20:26:01.470" LastActivityDate="2015-04-22T20:26:01.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3033" PostTypeId="1" AcceptedAnswerId="3034" CreationDate="2015-04-22T17:38:06.197" Score="6" ViewCount="175" Body="&lt;p&gt;Occasionally, when writing shell scripts and such, I have entries of the form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo=/bar/baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get filename completion (&lt;code&gt;&amp;lt;C-x&amp;gt; &amp;lt;C-f&amp;gt;&lt;/code&gt;) to work, I have to put a space after the &lt;code&gt;=&lt;/code&gt;, and then remove it after completion. I don't have any filenames which contain &lt;code&gt;=&lt;/code&gt;, so I don't care about it being part of the completion. How do I get it to work with the &lt;code&gt;=&lt;/code&gt;? I use Linux primarily, but Windows on occasion too.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2020-08-26T17:31:45.947" Title="How do I get filename completion to ignore a leading `=`?" Tags="|autocompletion|filesystem|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3034" PostTypeId="2" ParentId="3033" CreationDate="2015-04-22T17:38:06.197" Score="12" Body="&lt;p&gt;The list of valid filename characters is given by the &lt;code&gt;isfname&lt;/code&gt; variable. From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27isfname%27&quot;&gt;&lt;code&gt;:he 'isfname'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'isfname' 'isf'     string  (default for MS-DOS, Win32 and OS/2:&#xA;                         &quot;@,48-57,/,\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=&quot;&#xA;                        for AMIGA: &quot;@,48-57,/,.,-,_,+,,,$,:&quot;&#xA;                        for VMS: &quot;@,48-57,/,.,-,_,+,,,#,$,%,&amp;lt;,&amp;gt;,[,],:,;,~&quot;&#xA;                        for OS/390: &quot;@,240-249,/,.,-,_,+,,,#,$,%,~,=&quot;&#xA;                        otherwise: &quot;@,48-57,/,.,-,_,+,,,#,$,%,~,=&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make Vim ignore &lt;code&gt;=&lt;/code&gt; as a filename character, remove &lt;code&gt;=&lt;/code&gt; from this list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set isfname-==&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, completion should work for &lt;code&gt;foo=/ba...&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-04-22T17:38:06.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3035" PostTypeId="2" ParentId="2983" CreationDate="2015-04-22T18:52:32.160" Score="0" Body="&lt;h2&gt;Exchange&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Using &lt;a href=&quot;https://github.com/tommcdo/vim-exchange&quot; rel=&quot;nofollow&quot;&gt;exchange.vim&lt;/a&gt;, when one of the defined regions to exchange is fully inside the other, the smaller one replaces the larger one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, with your cursor on the beginning of the function name, you can use &lt;code&gt;cx%%cxi(&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Explanation&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;cx&lt;/code&gt; operator is used in pairs: the first time defines the first region to be exchanged, and the second time defines the second region and performs the exchange. It takes any motion or text object, given after the operator.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cx%&lt;/code&gt; defines the first region to exchange as the text from the current cursor position (beginning of function name) to where the &lt;code&gt;%&lt;/code&gt; motion goes. When not on a bracket, &lt;code&gt;%&lt;/code&gt; scans forward in the current line until it finds one, then jumps to the matching bracket. After this command, the entire function call will be highlighted.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt; moves the cursor to the closing parenthesis of the function call.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cxi(&lt;/code&gt; defines the second region to exchange as the inner parenthesized term (so, the function arguments). At this point, the exchange is performed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Caveat&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If there is any &lt;code&gt;%&lt;/code&gt;-matchable character before the opening parenthesis for the function call, this pattern falls apart. For example, the following example code would be valid in JavaScript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo[x](arg);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the first region would be defined as &lt;code&gt;foo[x]&lt;/code&gt; and the second one would fail (no matching parenthesized term).&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="64" LastEditDate="2015-04-22T19:07:38.630" LastActivityDate="2015-04-22T19:07:38.630" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3036" PostTypeId="1" AcceptedAnswerId="3039" CreationDate="2015-04-22T19:28:09.237" Score="31" ViewCount="4827" Body="&lt;p&gt;I have encountered many situations in vim where it would be useful to have lookaround statements.  I have tried using the standard lookaround syntax &lt;em&gt;(&lt;code&gt;(?=)&lt;/code&gt;, &lt;code&gt;(?!)&lt;/code&gt; etc ..)&lt;/em&gt;, but it appears vim does not support this.  Does vim have an equivalent syntax for these kinds of statements?&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-04-23T00:50:53.863" Title="Is lookaround possible in vim's regex system?" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3037" PostTypeId="2" ParentId="3036" CreationDate="2015-04-22T19:37:18.627" Score="16" Body="&lt;p&gt;It looks as if this is possible. There is a simple table to go from perl to vim. &lt;code&gt;:h perl-patterns&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;9. Compare with Perl patterns               *perl-patterns*&#xA;&#xA;Vim's regexes are most similar to Perl's, in terms of what you can do.  The&#xA;difference between them is mostly just notation;  here's a summary of where&#xA;they differ:&#xA;&#xA;Capability                  in Vimspeak   in Perlspeak&#xA;----------------------------------------------------------------&#xA;force case insensitivity    \c            (?i)&#xA;force case sensitivity      \C            (?-i)&#xA;backref-less grouping       \%(atom\)     (?:atom)&#xA;conservative quantifiers    \{-n,m}       *?, +?, ??, {}?&#xA;0-width match               atom\@=       (?=atom)&#xA;0-width non-match           atom\@!       (?!atom)&#xA;0-width preceding match     atom\@&amp;lt;=      (?&amp;lt;=atom)&#xA;0-width preceding non-match atom\@&amp;lt;!      (?&amp;lt;!atom)&#xA;match without retry         atom\@&amp;gt;       (?&amp;gt;atom)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So for example if you have the string &lt;code&gt;one two three&lt;/code&gt; and you want to match for &lt;code&gt;one&lt;/code&gt; only if &lt;code&gt;&amp;lt;space&amp;gt;two&lt;/code&gt; follows it you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/one\(\stwo\)\@=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is similar to the perl version&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;m/one(?=\stwo)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2015-04-22T19:43:31.380" LastActivityDate="2015-04-22T19:43:31.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3038" PostTypeId="2" ParentId="716" CreationDate="2015-04-22T19:38:35.867" Score="4" Body="&lt;p&gt;Yes there is a way! It's called silent open. In NERDTree focus your cursor on the file you want to open in new tab then press &lt;kbd&gt;T&lt;/kbd&gt;. this will open it silently in a new tab without switching to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In NERDTree press &lt;kbd&gt;?&lt;/kbd&gt; to check out all the mappings available for you.&lt;/p&gt;&#xA;" OwnerUserId="1832" LastEditorUserId="51" LastEditDate="2015-04-26T08:40:29.340" LastActivityDate="2015-04-26T08:40:29.340" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3039" PostTypeId="2" ParentId="3036" CreationDate="2015-04-22T20:23:55.537" Score="42" Body="&lt;h1&gt;&quot;Zoom&quot; anchors&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;In addition to @jecxjo's answer, there are many situations where you can use the zero-width anchors &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; instead of positive lookaround. These anchors define the start (&lt;code&gt;\zs&lt;/code&gt;) and the end (&lt;code&gt;\ze&lt;/code&gt;) of the match within the full pattern.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Examples&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;foo\zsbar&lt;/code&gt; will match &lt;code&gt;bar&lt;/code&gt; preceded by &lt;code&gt;foo&lt;/code&gt; (&lt;code&gt;foo&lt;/code&gt; not part of the match)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;foo\zebar&lt;/code&gt; will match &lt;code&gt;foo&lt;/code&gt; followed by &lt;code&gt;bar&lt;/code&gt; (&lt;code&gt;bar&lt;/code&gt; not part of the match)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;myFunction(\zs.*\ze)&lt;/code&gt; will match the parameters in a function call &lt;em&gt;(for demonstration purposes, I'm not focusing on greedy vs non-greedy matching)&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Putting it to use&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;These become most useful when using the &lt;code&gt;:substitute&lt;/code&gt; command. For example, say I wanted to replace the parameters in a function call to &lt;code&gt;myFunction()&lt;/code&gt; with &lt;code&gt;foo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/myFunction(\zs.*\ze)/foo/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will leave &lt;code&gt;myFunction(&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt; intact, and you don't have to worry about capturing them in your &lt;em&gt;pattern&lt;/em&gt; or repeating them in your &lt;em&gt;replacement&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could do this using the lookaround feature of Vim's regex, but it's quite clunky: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(myFunction(\)\@&amp;lt;=.*\()\)\@=/foo/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I find this syntax causes me to forget what I was trying to do in the first place.)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;You still need lookaround sometimes&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are still situations where you need lookaround. Using &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; are great for simple situations where you have &lt;em&gt;something before&lt;/em&gt; followed by &lt;em&gt;text to match&lt;/em&gt; followed by &lt;em&gt;something after&lt;/em&gt;. But if it's more complex than that, you'll probably have to stick to the heavier lookaround syntax.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Fun fact&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Though they're considerably uglier, Vim's lookarounds are more powerful than those in PCRE! They support variable-length negative lookbehind, meaning you can assert that some pattern whose length is not predetermined is &lt;em&gt;not&lt;/em&gt; before your match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PCRE doesn't support this, as it's fairly computationally expensive. That's not a huge concern in Vim, since the most common use cases of regex tend to involve interactive searching where the computation time is nearly imperceptible to the user. You'd probably notice it if it were used for syntax highlighting, though.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Relevant Help Topics&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \zs&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \ze&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help perl-patterns&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="64" LastEditorUserId="865" LastEditDate="2015-04-23T00:50:53.863" LastActivityDate="2015-04-23T00:50:53.863" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3040" PostTypeId="5" CreationDate="2015-04-22T21:23:39.453" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-04-22T21:23:39.453" LastActivityDate="2015-04-22T21:23:39.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3041" PostTypeId="4" CreationDate="2015-04-22T21:23:39.453" Score="0" Body="Questions about the use of vim for handling several files at the same time." OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-04-23T00:36:16.353" LastActivityDate="2015-04-23T00:36:16.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3042" PostTypeId="5" CreationDate="2015-04-22T21:26:36.577" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-04-22T21:26:36.577" LastActivityDate="2015-04-22T21:26:36.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3043" PostTypeId="4" CreationDate="2015-04-22T21:26:36.577" Score="0" Body="Questions related to the use of tags files created by programs such as `ctags` to quickly locate language objects such as functions." OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-04-23T00:36:12.597" LastActivityDate="2015-04-23T00:36:12.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3044" PostTypeId="1" AcceptedAnswerId="3049" CreationDate="2015-04-23T04:55:10.180" Score="2" ViewCount="90" Body="&lt;p&gt;If I am using visual block mode to append to a block of text and number of characters exceeds 80, then the line snaps and text is not appended to rest of the block. I want to find a way such that line does not wrap around in visual mode,but when I am done with appending text, lines should automatically wrap after 80 characters.&lt;/p&gt;&#xA;" OwnerUserId="230" LastEditorUserId="230" LastEditDate="2015-04-23T05:10:26.233" LastActivityDate="2015-04-24T18:43:57.813" Title="Is there any way to prevent a line from wrapping around while in visual mode?" Tags="|visual-mode|wrapping|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3046" PostTypeId="1" AcceptedAnswerId="3050" CreationDate="2015-04-23T12:35:50.463" Score="-4" ViewCount="914" Body="&lt;p&gt;I'm looking for a list of the basics, for instance, not a list of all the plugins, but plugin would be on my list; here is what I have so far help me out if I've missed anything or if I've mis-named anything:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;.vimrc&lt;/li&gt;&#xA;&lt;li&gt;vimscript functions&lt;/li&gt;&#xA;&lt;li&gt;regular expressions&lt;/li&gt;&#xA;&lt;li&gt;key mappings&lt;/li&gt;&#xA;&lt;li&gt;plugins&lt;/li&gt;&#xA;&lt;li&gt;swap file&lt;/li&gt;&#xA;&lt;li&gt;tabs&lt;/li&gt;&#xA;&lt;li&gt;panes&lt;/li&gt;&#xA;&lt;li&gt;selection ranges&lt;/li&gt;&#xA;&lt;li&gt;! to run bash commands from vim (whatever that's called)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2015-04-23T14:29:14.087" Title="What is an exhaustive list of &quot;all the things&quot; in vim?" Tags="|terminology|" AnswerCount="3" CommentCount="1" ClosedDate="2015-04-24T02:04:38.117" ContentLicense="CC BY-SA 3.0" />
  <row Id="3047" PostTypeId="2" ParentId="2834" CreationDate="2015-04-23T12:45:07.503" Score="2" Body="&lt;p&gt;So I kind of alleviated it by using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cmdheight=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that is weak sause and I don't think should be the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt; Yep, the next day I had 3 files changed and it asked me to press enter again.&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="237" LastEditDate="2015-04-24T08:23:22.040" LastActivityDate="2015-04-24T08:23:22.040" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3048" PostTypeId="2" ParentId="3046" CreationDate="2015-04-23T13:45:33.373" Score="7" Body="&lt;p&gt;What you are looking for is usually called the vimdoc. An HTML version can be found &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_toc.html&quot;&gt;here&lt;/a&gt;. It can also be accessed from within vim by entering &lt;code&gt;:help&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information on a specific topic or key combination you would use &lt;code&gt;:h pattern&lt;/code&gt; where &lt;code&gt;pattern&lt;/code&gt; is the topic or key cord you are interested in. If you're not sure exactly what something is called you can use &lt;code&gt;:h patt&lt;/code&gt; followed by &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;D&lt;/kbd&gt; to get a list of topics that may match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a more detailed explanation on how to use help see &lt;a href=&quot;http://vim.wikia.com/wiki/Learn_to_use_help&quot;&gt;this wiki&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1154" LastActivityDate="2015-04-23T13:45:33.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3049" PostTypeId="2" ParentId="3044" CreationDate="2015-04-23T13:54:17.957" Score="2" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I initially misunderstood this to be a problem with &lt;em&gt;pasting&lt;/em&gt;; actually, you mean &lt;em&gt;appending&lt;/em&gt; from visual mode. The following mapping should handle that, by temporarily resetting &lt;code&gt;'formatoptions'&lt;/code&gt; until you're done inserting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:xnoremap A &amp;lt;Esc&amp;gt;:let save_fo = &amp;amp;fo&amp;lt;Bar&amp;gt;setl fo=&amp;lt;Bar&amp;gt;augroup TempInsert&amp;lt;Bar&amp;gt;augroup END&amp;lt;Bar&amp;gt;autocmd! TempInsert InsertLeave * let &amp;amp;fo = save_fo&amp;lt;Bar&amp;gt;autocmd! TempInsert&amp;lt;CR&amp;gt;gvA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I only see this effect with auto-formatting, i.e. &lt;code&gt;:set formatoptions+=a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want this when pasting, you could override the command, or provide a special alternative, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Leader&amp;gt;p :let save_fo = &amp;amp;fo&amp;lt;Bar&amp;gt;setl fo-=a&amp;lt;Bar&amp;gt;execute 'normal! &quot;' . v:register . 'p'&amp;lt;Bar&amp;gt;let &amp;amp;fo = save_fo&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2015-04-24T18:43:57.813" LastActivityDate="2015-04-24T18:43:57.813" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3050" PostTypeId="2" ParentId="3046" CreationDate="2015-04-23T14:12:25.317" Score="9" Body="&lt;p&gt;Vim has a user manual (&lt;a href=&quot;http://vimhelp.appspot.com/usr_toc.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help usr_toc&lt;/code&gt;&lt;/a&gt;) that covers all of these topics.  It's good to browse through in general and can be a good starting point when you're thinking &lt;code&gt;How do I do X in Vim?&lt;/code&gt;.  Opening up that help and doing a search is a good place to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another important item for using the help is to get used to using the context-specific help -- &lt;a href=&quot;http://vimhelp.appspot.com/help.txt.html#help-context&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help help-context&lt;/code&gt;&lt;/a&gt;.  Some help topics are ambiguous unless you include the proper context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, here are the sections about the specific topics you bring up.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;.vimrc&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/usr_05.txt.html#vimrc-intro&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help vimrc-intro&lt;/code&gt;&lt;/a&gt; describes the basic info about where the vimrc lives and provides some example settings.  Since the vimrc is just another vim script, the scripting section of the user manual (&lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help usr_41&lt;/code&gt;&lt;/a&gt;) is also useful.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;vimscript functions&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;These are covered in the scripting part of the manual mentioned above, but there are specific sections on using functions (&lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#41.6&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 41.6&lt;/code&gt;&lt;/a&gt;) and defining functions (&lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#41.6&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 41.7&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;regular expressions&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/usr_27.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help usr_27&lt;/code&gt;&lt;/a&gt; describes searching and covers some regular expressions, but &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help pattern.txt&lt;/code&gt;&lt;/a&gt; is the canonical section of the reference manual for all things related to Vim regular expressions&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;key mappings&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/usr_40.txt.html#40.1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 40.1&lt;/code&gt;&lt;/a&gt; covers all the high level details and &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#key-mapping&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help key-mapping&lt;/code&gt;&lt;/a&gt; goes into all the nitty-gritty details.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;plugins&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The basic &lt;code&gt;how&lt;/code&gt; of adding a plugin to your configuration is described at (&lt;a href=&quot;http://vimhelp.appspot.com/usr_05.txt.html#05.4&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 05.4&lt;/code&gt;&lt;/a&gt;) but typically people use a &lt;a href=&quot;https://vi.stackexchange.com/a/614/15&quot;&gt;plugin manager&lt;/a&gt; to handle this now.  Plugin managers provide, at a minimum, better isolation of plugins and the ability to easily enable/disable plugins.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;swap file&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Swap files provide a means of recovery, as described in &lt;a href=&quot;http://vimhelp.appspot.com/usr_11.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help usr_11&lt;/code&gt;&lt;/a&gt;.  In a &lt;a href=&quot;https://vi.stackexchange.com/a/179/15&quot;&gt;related answer&lt;/a&gt;, I've described this as well as ways to manage swap files.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;tabs (tab pages)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Tab pages are basically viewports, or ways to organize windows.  &lt;a href=&quot;http://vimhelp.appspot.com/usr_08.txt.html#08.9&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 08.9&lt;/code&gt;&lt;/a&gt; gives a brief overview of what a tab page is, but &lt;a href=&quot;http://vimhelp.appspot.com/tabpage.txt.html#tab-page&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help tab-page&lt;/code&gt;&lt;/a&gt; gives more info on how to actually use them.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;panes (split windows)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Split windows (&lt;a href=&quot;http://vimhelp.appspot.com/usr_08.txt.html#08.1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 08.1&lt;/code&gt;&lt;/a&gt;) provide a way to view multiple buffers (or different views of the same buffer) at once.  When Vim mentions a horizontal or vertical split, this is referring to the orientation of the actual line that splits two windows, not the orientation of the windows in reference to each other.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;selection ranges (command ranges)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I think you're referring to the ranges automatically added to a command when you press &lt;code&gt;:&lt;/code&gt; in visual mode (&lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt;), however ranges can describe much more than just the visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/usr_10.txt.html#10.3&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 10.3&lt;/code&gt;&lt;/a&gt; describes the general usage, but &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt#cmdline-ranges&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help cmdilne-ranges&lt;/code&gt;&lt;/a&gt; has all the details.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;! (running external commands)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/usr_21.txt#21.2&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 21.2&lt;/code&gt;&lt;/a&gt; describes the various ways that external programs can be used -- directly executing one-off commands (&lt;code&gt;:!&lt;/code&gt;), reading output from a command into the buffer (&lt;code&gt;:r !{cmd}&lt;/code&gt;), sending the buffer to a command as in put (&lt;code&gt;:w !{cmd}&lt;/code&gt;), and filtering a buffer through a program (&lt;code&gt;:[range]!{cmd}&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-04-23T14:12:25.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3051" PostTypeId="2" ParentId="3046" CreationDate="2015-04-23T14:29:14.087" Score="11" Body="&lt;p&gt;The most comprehensive &lt;em&gt;single-page&lt;/em&gt; reference is probably:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help quickref&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="578" LastActivityDate="2015-04-23T14:29:14.087" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3052" PostTypeId="1" AcceptedAnswerId="3054" CreationDate="2015-04-24T12:54:24.130" Score="10" ViewCount="349" Body="&lt;p&gt;Quite often, when using &lt;code&gt;CTRL-O&lt;/code&gt; to jump back to an older position, vim takes me to other files I've been editing previously. Is there a command, to go back within the jumplist &lt;strong&gt;just in the current file&lt;/strong&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1854" LastEditorUserId="1854" LastEditDate="2015-04-24T13:32:36.283" LastActivityDate="2015-04-24T22:45:42.843" Title="How to jump only in currently open file?" Tags="|cursor-movement|jumplist|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3054" PostTypeId="2" ParentId="3052" CreationDate="2015-04-24T13:54:19.110" Score="8" Body="&lt;p&gt;There is command that is close to what you need: &lt;code&gt;g;&lt;/code&gt; will bring you back to &lt;em&gt;older change position&lt;/em&gt;, &lt;code&gt;g,&lt;/code&gt; will go forward to &lt;em&gt;newer change position&lt;/em&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;List of change position can be displayed with &lt;code&gt;:changes&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1782" LastActivityDate="2015-04-24T13:54:19.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3055" PostTypeId="1" AcceptedAnswerId="3057" CreationDate="2015-04-24T14:05:42.603" Score="21" ViewCount="706" Body="&lt;p&gt;A lot of times I'm in a situation similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. &amp;lt;Line 1&amp;gt;&#xA;2. &amp;lt;Line 2&amp;gt;&#xA;3. &amp;lt;Line 3&amp;gt;&#xA;4. &amp;lt;Cursor is here&amp;gt;&#xA;5. &amp;lt;I want to copy line 1 here&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An easy solution is &lt;code&gt;mm:1&amp;lt;CR&amp;gt;yy`mp&lt;/code&gt; - that is, make a mark at line 4, go to line 1, copy it, go back to the mark, and paste. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a shorter/more fluid solution to this? I do this often enough that I'm happy to make a mapping for it. &lt;/p&gt;&#xA;" OwnerUserId="40" LastEditorUserId="40" LastEditDate="2015-04-28T13:43:40.330" LastActivityDate="2015-04-28T13:43:40.330" Title="How can I use a line number to copy a line to where my cursor is?" Tags="|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3056" PostTypeId="2" ParentId="3055" CreationDate="2015-04-24T14:09:29.027" Score="11" Body="&lt;p&gt;You could shorten it by not using marks and yank the line directly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1y&amp;lt;CR&amp;gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Command version of yank takes a &lt;code&gt;{range}&lt;/code&gt; so select a line or a group of lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, the range value can be either absolute or relative. Lines above the cursor are negative distance and below are positive. So yanking two lines above is &lt;code&gt;:-2y&lt;/code&gt; and yanking two lines below is &lt;code&gt;:+2y&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2015-04-24T14:24:06.357" LastActivityDate="2015-04-24T14:24:06.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3057" PostTypeId="2" ParentId="3055" CreationDate="2015-04-24T14:19:34.127" Score="23" Body="&lt;p&gt;Looks like a case for ex copy (&lt;code&gt;:help :co&lt;/code&gt; or &lt;code&gt;:help :t&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1t4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or, using your cursor's position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1t.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does not copy the line to the yank register, which might or might not be what you want.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastActivityDate="2015-04-24T14:19:34.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3058" PostTypeId="2" ParentId="3052" CreationDate="2015-04-24T15:52:01.460" Score="7" Body="&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2695&quot; rel=&quot;noreferrer&quot;&gt;EnhancedJumps plugin&lt;/a&gt; offers separate special mappings that restrict the jump targets to only local locations (in the same buffer) and remote locations (only in other buffers).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-24T15:52:01.460" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3059" PostTypeId="1" AcceptedAnswerId="3061" CreationDate="2015-04-24T17:25:04.920" Score="0" ViewCount="1637" Body="&lt;p&gt;I am writing a plugin that highlights buffer settings violations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;matchadd()&lt;/code&gt; function. In addition I need to add patterns that are force ignored. In order to achieve that I use priorities in &lt;code&gt;matchadd()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the following highlight group to highlight trailing spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highligh FileStyleTrailngSpacesError ctermbg=Cyan guibg=Cyan&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Matching trailing spaces code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matchadd('FileStyleTrailngSpacesError', '\s\+$', 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Force highlight disabling supposed to be (e.g. pattern &lt;code&gt;&amp;gt;\s\+$&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matchadd('Normal', '&amp;gt;\s\+$', 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that this line of code does not disable highlight, but it &quot;works&quot; with other highlight groups e.g. &lt;code&gt;Todo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried to use the following groups:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Has the same result as 'Normal'&#xA;highligh FileStyleIgnorePattern cterm=NONE guibg=NONE&#xA;&#xA;&quot; E420: BG color unknown&#xA;highligh FileStyleIgnorePattern ctermbg=bg guibg=bg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; OS - Ubuntu 14.04&lt;/p&gt;&#xA;" OwnerUserId="1860" LastActivityDate="2015-04-24T18:56:17.273" Title="Override highlight group settings with default values" Tags="|syntax-highlighting|highlight|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3060" PostTypeId="1" AcceptedAnswerId="3062" CreationDate="2015-04-24T18:38:37.347" Score="18" ViewCount="11310" Body="&lt;p&gt;I have an autocommand defined in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWritePost * !./make.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The script &lt;code&gt;make.sh&lt;/code&gt; compiles a &lt;code&gt;.tex&lt;/code&gt; file 3 times and I don't want the output to be displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to suppress the output? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to add &lt;code&gt;silent&lt;/code&gt; one line before the &lt;code&gt;au&lt;/code&gt; command, but it didn't work. I also tried &lt;a href=&quot;https://stackoverflow.com/questions/11073714/suppress-output-from-a-vim-autocmd&quot;&gt;this way&lt;/a&gt; with no success.&lt;/p&gt;&#xA;" OwnerUserId="1837" LastEditorUserId="23502" LastEditDate="2022-11-02T09:02:24.237" LastActivityDate="2022-11-02T09:02:24.237" Title="Suppress output from a Vim autocomand" Tags="|autocmd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3061" PostTypeId="2" ParentId="3059" CreationDate="2015-04-24T18:56:17.273" Score="1" Body="&lt;p&gt;With &lt;code&gt;guibg=NONE&lt;/code&gt;, you actually say &quot;this has &lt;em&gt;no&lt;/em&gt; background color&quot;, i.e. it is transparent. The &lt;code&gt;bg&lt;/code&gt; value is the right approach, but that only works for &lt;code&gt;guibg&lt;/code&gt;; for &lt;code&gt;ctermbg&lt;/code&gt;, you indeed get the &lt;code&gt;E420&lt;/code&gt; error (from the &lt;code&gt;:help E420&lt;/code&gt;: &lt;em&gt;This only works after setting the colors for the Normal group and for the MS-DOS console.&lt;/em&gt;) . So, you need to specify&#xA;the actual background color for color terminals:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight FileStyleIgnorePattern ctermbg=White guibg=bg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could use &lt;code&gt;synIDattr()&lt;/code&gt; to query the color terminal background color, but I guess that will only work if a color has been set explicitly, too.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-24T18:56:17.273" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3062" PostTypeId="2" ParentId="3060" CreationDate="2015-04-24T19:32:30.593" Score="32" Body="&lt;p&gt;Silent should go before &lt;code&gt;!./make.sh&lt;/code&gt;, not before &lt;code&gt;au&lt;/code&gt;.  Putting &lt;code&gt;silent&lt;/code&gt; before &lt;code&gt;au&lt;/code&gt; just means it will register the autocommand silently.  It should look like this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWritePost * silent! !./make.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One issue with running an external command like this with the &lt;code&gt;:silent&lt;/code&gt; command is that the screen does not redraw, leaving you with a blank screen.  However, vim does have a command which redraws the screen, which can be used like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWritePost * silent! execute &quot;!./make.sh &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&quot; | redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason I need to use the execute command is because the &lt;code&gt;:!&lt;/code&gt; command uses any characters found after it, which means I couldn't just do &lt;code&gt;silent! !./make.sh | redraw!&lt;/code&gt; because bash would try to interpret all of the characters after &lt;code&gt;!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Notes&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;:silent!&lt;/code&gt; ignores error messages, whereas &lt;code&gt;:silent&lt;/code&gt; doesn't.  Also, the &lt;code&gt;&amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;/code&gt; part redirects all output of &lt;code&gt;!./make.sh&lt;/code&gt; to &lt;code&gt;/dev/null&lt;/code&gt;.  You can read more about i/o redirection in bash &lt;a href=&quot;http://www.tldp.org/LDP/abs/html/io-redirection.html&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Relevant Help Topics&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :execute&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :silent&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :bar&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-04-24T20:03:51.550" LastActivityDate="2015-04-24T20:03:51.550" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3063" PostTypeId="2" ParentId="3052" CreationDate="2015-04-24T22:45:42.843" Score="1" Body="&lt;p&gt;Yes, backtick-backtick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`` &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;goes back to the previous mark (but &lt;em&gt;only&lt;/em&gt; the previous mark) in the current buffer.&lt;/p&gt;&#xA;" OwnerUserId="578" LastActivityDate="2015-04-24T22:45:42.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3064" PostTypeId="2" ParentId="3060" CreationDate="2015-04-24T23:30:02.663" Score="9" Body="&lt;p&gt;The answer to your direct question is just as @EvergreenTree posted. However I feel like you are missing some of Vim builtin tool for building/compiling/linting projects. Most notably &lt;code&gt;:make&lt;/code&gt; and the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;What does using &lt;code&gt;:make&lt;/code&gt; get us?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:make&lt;/code&gt; allows for you to collect your errors up into a list known as the quickfix list. Using the quickfix you can navigate between the errors in your files, so you are jumping right to where the compiler says the error is (handy right?).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;:make&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:make&lt;/code&gt; will execute the make program, &lt;code&gt;'makeprg'&lt;/code&gt;. Then parse the output with &lt;code&gt;'errorformat'&lt;/code&gt; and put each entry into the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically &lt;code&gt;'makeprg'&lt;/code&gt; defaults to the &lt;code&gt;make&lt;/code&gt; command which runs a &lt;code&gt;Makefile&lt;/code&gt;. However you can change your &lt;code&gt;'makeprg'&lt;/code&gt; via the &lt;code&gt;:compiler&lt;/code&gt; command or set it directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also pass extra arguments to &lt;code&gt;:make&lt;/code&gt;. e.g. &lt;code&gt;:make clean&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: running &lt;code&gt;:make&lt;/code&gt; will often show the output of the command at the bottom of the screen with a prompt asking to press enter. Just press enter as all the output will be available in the quickfix list. You can suppress this via &lt;code&gt;:silent&lt;/code&gt;, e.g. &lt;code&gt;:silent make&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A common custom command for a silent make is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=* -bar Smake silent make &amp;lt;args&amp;gt; &amp;lt;bar&amp;gt; cwindow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;quickfix list&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;After you run &lt;code&gt;:make&lt;/code&gt; your quickfix list will hold the output of compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the following command to navigate the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:copen&lt;/code&gt; to open the quickfix window&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:cclose&lt;/code&gt; to close the quickfix window&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:cnext&lt;/code&gt;/&lt;code&gt;:cprev&lt;/code&gt; to move to the next/previous item&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:cc&lt;/code&gt; to print out at the bottom the current error or &lt;code&gt;:cc 3&lt;/code&gt; to show a specific error in this example 3&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Personally I use Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;unimpaired&lt;/a&gt; plugin to navigate the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;What about running &lt;code&gt;:make&lt;/code&gt; automatically and silently?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can do this with an &lt;code&gt;:autocmd&lt;/code&gt; just like you where.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup auto_make&#xA;    autocmd!&#xA;    autocmd BufWritePost * silent make&#xA;    autocmd QuickFixCmdPost *make* cwindow&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a bonus I added in opening the quickfix window via &lt;code&gt;:cwindow&lt;/code&gt; if there are any errors present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Should be more specific with that file pattern on the &lt;code&gt;BufWritePost&lt;/code&gt; autocmd so that un-related files don't build.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;There even more?!&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This is using just a few of Vim's builtin command plus a few autocmd's for convince. There are of course plugins and tools that might aid you&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dispatch.vim&lt;/a&gt; can be used to run &lt;code&gt;:make&lt;/code&gt; jobs asynchronously.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/scrooloose/syntastic&quot; rel=&quot;nofollow noreferrer&quot;&gt;Syntastic&lt;/a&gt; plugin syntax checks file after &lt;code&gt;:write&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ale.vim&lt;/a&gt; (Asynchronous Lint Engine) is a plugin for providing linting in NeoVim and Vim 8 while you edit your text files.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;Unimpaired.vim&lt;/a&gt; makes managing the quickfix list easy.&lt;/li&gt;&#xA;&lt;li&gt;Plain old Makefiles. Unless your &lt;code&gt;./script.sh&lt;/code&gt; is very complicated you may want to look into using make. It can scale do more tasks later and is a common building tool.&lt;/li&gt;&#xA;&lt;li&gt;You can use &lt;a href=&quot;http://vimawesome.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Awesome&lt;/a&gt; to search for more plugins that might help.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Conclusion&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Personally I integrate &lt;code&gt;:make&lt;/code&gt; and the quickfix into my own workflow. I believe capturing the output of your build process and capturing the errors to be well worth the investment. As an added bonus you will possibly become more comfortable with the quickfix list and can use the list for other applications like &lt;code&gt;:grep&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :make&#xA;:h quickfix&#xA;:h 'makeprg'&#xA;:h 'errorformat'&#xA;:h :compiler&#xA;:h :copen&#xA;:h :cwindow&#xA;:h :cnext&#xA;:h :cc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-05-16T19:05:39.243" LastActivityDate="2017-05-16T19:05:39.243" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3066" PostTypeId="1" AcceptedAnswerId="3067" CreationDate="2015-04-25T04:36:49.577" Score="99" ViewCount="69784" Body="&lt;p&gt;Often, I'll load some information into a temporary buffer, and then close it with &lt;code&gt;:clo!&lt;/code&gt;.  But this hides the buffer rather than unloading it entirely, even though I have &lt;code&gt;nohidden&lt;/code&gt; set.  I find this tiresome since I get an extra confirmation when I quit Vim, about content I already (thought I) discarded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could just use &lt;code&gt;:q!&lt;/code&gt; instead, but that's a bad habit to get into because it will exit Vim entirely if there's only one buffer left, which is also annoying.  Worse, if I typo &lt;code&gt;:qa!&lt;/code&gt;, I could lose a lot of work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a middle ground?  I'd really like some command which kills the current buffer but doesn't exit Vim.  I'm not opposed to writing it in Vimscript, but I'd rather avoid it if the command already exists.&lt;/p&gt;&#xA;" OwnerUserId="920" LastActivityDate="2017-08-18T19:19:59.967" Title="Close and unload a buffer without exiting Vim" Tags="|command-line|buffers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3067" PostTypeId="2" ParentId="3066" CreationDate="2015-04-25T04:41:27.703" Score="118" Body="&lt;p&gt;There is command to do exactly that: &lt;code&gt;:bdelete&lt;/code&gt; or just &lt;code&gt;:bd&lt;/code&gt;. By default it will unload current buffer. To unload other buffer, first get the list of all buffers with &lt;code&gt;:buffers&lt;/code&gt; command, and after that you can specify the number after &lt;code&gt;:bd&lt;/code&gt; to remove it. Also &lt;code&gt;:bd&lt;/code&gt; + &lt;kbd&gt;space&lt;/kbd&gt; + &lt;kbd&gt;tab&lt;/kbd&gt; allows completion using buffer name.&lt;/p&gt;&#xA;" OwnerUserId="1782" LastEditorUserId="1782" LastEditDate="2015-04-25T04:58:04.017" LastActivityDate="2015-04-25T04:58:04.017" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3068" PostTypeId="1" AcceptedAnswerId="3079" CreationDate="2015-04-25T10:42:14.303" Score="1" ViewCount="1749" Body="&lt;p&gt;I want to keep my Vim spelling synchronised across machines. For that reason I put my spelling file&#xA;into Dropbox by adding &lt;code&gt;set spellfile=$HOME/Dropbox/vim/spell/en.utf-8.add&lt;/code&gt; to my &lt;em&gt;.vimrc&lt;/em&gt;. It&#xA;worked just fine for a single language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I've added another spelling file for Ukrainian by changing &lt;code&gt;'spellfile'&lt;/code&gt; value to&#xA;&lt;br&gt; &lt;code&gt;$HOME/Dropbox/vim/spell/en.utf-8.add,$HOME/Dropbox/vim/spell/uk.utf-8.add&lt;/code&gt; it gets ignored. &lt;code&gt;zg&lt;/code&gt; (with &lt;code&gt;:set spelllang=uk&lt;/code&gt;)&#xA;adds a word to en.utf-8.add instead of uk.utf-8.add. Words are added to the correct file when&#xA;doing &lt;code&gt;2zg&lt;/code&gt; but that's not what I want to do manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I make Vim use correct spelling file based on &lt;code&gt;'spellang'&lt;/code&gt; value?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've read Vim help on &lt;code&gt;'spellfile'&lt;/code&gt; and it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Normally one file is used for all regions, but you can add the region  name if you want to.  However, it will then only be used when&#xA;    'spellfile' is set to it, for entries in 'spelllang' only files&#xA;    without region name will be found.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Initialy I've thought it means regions like &lt;code&gt;en_us&lt;/code&gt; &lt;code&gt;en_gb&lt;/code&gt;. Do I misunderstand something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another even better option would be to change location /spell directory location to live outside .vim/&lt;/p&gt;&#xA;" OwnerUserId="418" LastEditorUserId="51" LastEditDate="2015-04-26T08:28:50.137" LastActivityDate="2015-04-26T09:25:36.500" Title="How to make 'spellfile' work for multiple languages?" Tags="|spell-checking|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3070" PostTypeId="1" AcceptedAnswerId="3071" CreationDate="2015-04-25T13:37:23.467" Score="2" ViewCount="1174" Body="&lt;p&gt;I have a common routine where I need to do a text substitution from the current cursor position to the end of the file. I currently count how many lines there are until the end of the file and enter it manually:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,.25s/old/new/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there something I can enter instead of the &lt;code&gt;.25&lt;/code&gt; to make the substitution apply from the current cursor position until the end of the file?&lt;/p&gt;&#xA;" OwnerUserId="69" LastActivityDate="2015-04-26T21:47:30.737" Title="How do I define a range from the current position to the end of the file in an ex command?" Tags="|substitute|ex-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3071" PostTypeId="2" ParentId="3070" CreationDate="2015-04-25T13:44:32.210" Score="12" Body="&lt;p&gt;There is. For last line of a file, the address is &lt;code&gt;$&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,$s/old/new/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%7Baddress%7D&quot;&gt;&lt;code&gt;:help {address}&lt;/code&gt;&lt;/a&gt; for a fill list of possible addresses.&lt;/p&gt;&#xA;" OwnerUserId="1782" LastEditorUserId="51" LastEditDate="2015-04-26T21:47:30.737" LastActivityDate="2015-04-26T21:47:30.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3072" PostTypeId="1" CreationDate="2015-04-25T14:18:30.173" Score="11" ViewCount="7283" Body="&lt;p&gt;I dislike to have to reach up to the &lt;code&gt;Escape&lt;/code&gt; key all the time. For a while I used the program &lt;code&gt;xcape&lt;/code&gt; under Linux to map &lt;code&gt;Caps lock&lt;/code&gt; to be both &lt;code&gt;Control&lt;/code&gt; and &lt;code&gt;Escape&lt;/code&gt;. However, I am currently working more and more on a Mac so I can’t have the same keybinding without much increased effort. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought that the key combination of &lt;code&gt;Control&lt;/code&gt;-&lt;code&gt;Space&lt;/code&gt; would be quite nice. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to rebind with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;NUL&amp;gt; &amp;lt;ESC&amp;gt;&#xA;nmap &amp;lt;NUL&amp;gt; i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that does not work correctly, often inserting the same text again.&lt;/p&gt;&#xA;" OwnerUserId="1869" LastEditorUserId="51" LastEditDate="2015-04-26T10:13:31.963" LastActivityDate="2020-07-18T07:51:39.373" Title="How can I bind Ctrl-Space to be Esc when not in insert mode, and to switch to insert mode otherwise?" Tags="|key-bindings|escape|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3073" PostTypeId="2" ParentId="3072" CreationDate="2015-04-25T14:28:31.780" Score="6" Body="&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-Space&amp;gt; i&#xA;inoremap &amp;lt;C-Space&amp;gt; &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="74" LastActivityDate="2015-04-25T14:28:31.780" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3074" PostTypeId="2" ParentId="3072" CreationDate="2015-04-25T16:12:07.613" Score="12" Body="&lt;p&gt;I found this map works for &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;Space&lt;/kbd&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-@&amp;gt; i&#xA;:inoremap &amp;lt;C-@&amp;gt; &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1782" LastEditorUserId="1782" LastEditDate="2015-04-25T16:18:54.530" LastActivityDate="2015-04-25T16:18:54.530" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3075" PostTypeId="2" ParentId="3068" CreationDate="2015-04-25T18:13:37.340" Score="3" Body="&lt;p&gt;If you have multiple entries in &lt;code&gt;'spellfile'&lt;/code&gt;, you have to supply a &lt;code&gt;[count]&lt;/code&gt; to commands like &lt;code&gt;zg&lt;/code&gt; to choose the correct target file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better approach is to make the &lt;code&gt;'spellfile'&lt;/code&gt; entry always correspond to &lt;code&gt;'spelllang'&lt;/code&gt;. So, set either&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set spelllang=en spellfile=$HOME/Dropbox/vim/spell/en.utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;or&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set spelllang=uk spellfile=$HOME/Dropbox/vim/spell/uk.utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because that is tedious, you can define custom commands or mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -bar SpellEn set spelllang=en spellfile=$HOME/Dropbox/vim/spell/en.utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would only not work if you have mixed-language documents. In that case, there's no way around defining both and using &lt;code&gt;[count]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-25T18:13:37.340" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3076" PostTypeId="1" AcceptedAnswerId="3078" CreationDate="2015-04-26T00:55:46.377" Score="24" ViewCount="32198" Body="&lt;p&gt;I am using Vim on Arch Linux through urxvt. Since there is no &quot;Ctrl-V&quot; or &quot;Ctrl-Shift-V&quot; support in urxvt, there is no way for me to paste things I have copied from my browser (let's say) into my vim buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;code&gt;set clipboard=unnamed&lt;/code&gt; in my .vimrc but this seems to have no effect. Pressing &quot;p&quot; only pastes from the vim clipboard and after copying or cutting from vim, nothing gets added to my system clipboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just in urxvt, I can paste by using middle click on the mouse, which uses the system clipboard, but once I enter vim, even this functionality is replaced by vim's internal clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to enable copy-paste functionality in my vim setup?&lt;/p&gt;&#xA;" OwnerUserId="1872" LastEditorUserId="51" LastEditDate="2015-04-26T08:27:29.697" LastActivityDate="2017-12-29T09:59:59.217" Title="How do I use the system clipboard with Vim in Arch Linux?" Tags="|os-clipboard|linux|x11|linux-arch|" AnswerCount="1" CommentCount="1" ClosedDate="2015-04-26T09:05:00.920" ContentLicense="CC BY-SA 3.0" />
  <row Id="3077" PostTypeId="2" ParentId="2781" CreationDate="2015-04-26T01:46:30.223" Score="5" Body="&lt;p&gt;Whether or not you display all of the suggestions probably won't affect the lag. YouCompleteMe will search through all of the possible completions anyway. There is no way to display the &quot;10 top suggestions&quot; without having considered all possible suggestions - at least with the way YCM works.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still want to, &lt;code&gt;pumheight&lt;/code&gt; sets the menu height. &lt;/p&gt;&#xA;" OwnerUserId="1872" LastActivityDate="2015-04-26T01:46:30.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3078" PostTypeId="2" ParentId="3076" CreationDate="2015-04-26T04:30:20.933" Score="32" Body="&lt;p&gt;Ok. Apparently on native vim in Arch there is no support for X so the &lt;code&gt;+clipboard&lt;/code&gt; feature is missing. &#xA;To fix this, install &lt;code&gt;gvim&lt;/code&gt;, which although conflicts with vim, which was my initial problem with it, retains the exact same functionality if you use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Rather than, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You still need to &lt;code&gt;set clipboard=unnamed&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1872" LastEditorUserId="4472" LastEditDate="2017-12-29T09:59:59.217" LastActivityDate="2017-12-29T09:59:59.217" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3079" PostTypeId="2" ParentId="3068" CreationDate="2015-04-26T08:31:24.653" Score="1" Body="&lt;p&gt;You can &lt;a href=&quot;http://en.wikipedia.org/wiki/Symlink&quot; rel=&quot;nofollow&quot;&gt;symlink&lt;/a&gt; &lt;code&gt;~/.vim/spell&lt;/code&gt; to &lt;code&gt;~/Dropbox/vim/spell&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ rmdir ~/.vim/spell&#xA;$ ln -s ~/Dropbox/vim/spell ~/.vim/spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will work on UNIX-like systems (Linux, BSD, OSX), for Windows, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ mklink /D &quot;$HOME\Dropbox\vim\spell&quot; &quot;$HOME\_vim\spell&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-04-26T09:25:36.500" LastActivityDate="2015-04-26T09:25:36.500" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3080" PostTypeId="2" ParentId="3001" CreationDate="2015-04-26T09:38:56.957" Score="3" Body="&lt;p&gt;Short version: there is no way to disable this, or to  shorten the 1 second timeout :-( The good news is that you can just start typing while this message is being displayed, the characters are still inserted.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Longer version: from &lt;code&gt;misc1.c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if (msg_silent == 0 &amp;amp;&amp;amp; !silent_mode)&#xA;    {&#xA;        out_flush();&#xA;        ui_delay(1000L, TRUE); /* give the user time to think about it */&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;msg_silent&lt;/code&gt; is set when using &lt;code&gt;:silent&lt;/code&gt;, for example &lt;code&gt;:s/./a/&lt;/code&gt; will give the warning, but &lt;code&gt;:silent s/./a/&lt;/code&gt; won't. There is, as far as I can see, no way to start insert mode silently (&lt;code&gt;:silent startinsert&lt;/code&gt; doesn't work).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;silent_mode&lt;/code&gt; is set with &lt;code&gt;-s&lt;/code&gt;, from &lt;code&gt;vim(1)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   -s          Silent  mode.   Only  when started as &quot;Ex&quot; or when the &quot;-e&quot;&#xA;               option was given before the &quot;-s&quot; option.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But as the help message says, this only works when using Vim as &lt;code&gt;ex&lt;/code&gt;, and not when using it as &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-04-26T09:38:56.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3081" PostTypeId="5" CreationDate="2015-04-26T09:49:31.963" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-04-26T09:49:31.963" LastActivityDate="2015-04-26T09:49:31.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3082" PostTypeId="4" CreationDate="2015-04-26T09:49:31.963" Score="0" Body="Allow placement of a 'sign' in the left-hand side of the window and definition of a highlight which will be applied to that line." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-04-26T09:49:31.963" LastActivityDate="2015-04-26T09:49:31.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3084" PostTypeId="2" ParentId="2834" CreationDate="2015-04-26T21:22:55.973" Score="6" Body="&lt;p&gt;This is controlled with the &lt;code&gt;shortmess&lt;/code&gt; option. In particular, you probably want to set the &lt;code&gt;O&lt;/code&gt; (upper-case o) flag with &lt;code&gt;set shortmess+=O&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;O     message for reading a file overwrites any previous message.&#xA;      Also for quickfix message (e.g., &quot;:cn&quot;).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this is included in the Vim default, which is &lt;code&gt;filnxtToO&lt;/code&gt;. So I think you either added this to your vimrc some time in the past and forgot about it, or some plugin is resetting it. In &lt;a href=&quot;https://vi.stackexchange.com/q/771/51&quot;&gt;How do I debug my vimrc file?&lt;/a&gt; you can find some tips on how to figure out where this is being reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27shm%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'shortmess'&lt;/code&gt;&lt;/a&gt;. And &lt;a href=&quot;https://vi.stackexchange.com/q/771/51&quot;&gt;this question&lt;/a&gt; is almost exactly the same.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-12-28T07:37:03.823" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3085" PostTypeId="2" ParentId="2789" CreationDate="2015-04-26T21:39:28.590" Score="2" Body="&lt;p&gt;Adding &lt;code&gt;O&lt;/code&gt; to &lt;code&gt;shortmess&lt;/code&gt; seems to fix this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set hidden&#xA;set shortmess=fotxO&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help shortmess&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;o     overwrite message for writing a file with subsequent message&#xA;      for reading a file (useful for &quot;:wn&quot; or when 'autowrite' on)&#xA;O     message for reading a file overwrites any previous message.&#xA;      Also for quickfix message (e.g., &quot;:cn&quot;).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;o&lt;/code&gt; only takes effect when &lt;em&gt;writing&lt;/em&gt; a file, and &lt;code&gt;O&lt;/code&gt; takes effect when &lt;em&gt;reading&lt;/em&gt; a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless I've missed something, this seems to behave as you expect? I do get a different statusline, but I believe this is because the statusline is different when you open a new buffer vs. showing a previously hidden buffer...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. I don't have a machine with Vim 7.3, but I tested this with Vim 7.4-633, 7.4-160, and 7.2-411, using a vimrc file with only the &lt;code&gt;hidden&lt;/code&gt; and &lt;code&gt;shortmess&lt;/code&gt; lines.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-04-26T21:39:28.590" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3086" PostTypeId="1" AcceptedAnswerId="3088" CreationDate="2015-04-26T22:40:47.933" Score="4" ViewCount="1907" Body="&lt;p&gt;I have encountered some situations where I need to check if a value matches a regex in a list of regexes.  For instance, say I have a list of regexes which match filetypes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['gundo', 'nerdtree', 'git*']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need to find out if the filetype of the current file matches any of these regexes.  The way I would do it currently would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! IsIgnored()&#xA;    for ignored_ft in ignored_filetypes&#xA;        if &amp;amp;filetype =~ ignored_ft&#xA;            return 1&#xA;        endif&#xA;    endfor&#xA;    return 0&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it would be nice if there was a shorter way of doing this.  Does vim have a function to do this, or do I just have to stick with the for loop?&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="51" LastEditDate="2015-04-26T23:18:41.563" LastActivityDate="2015-04-26T23:37:42.440" Title="Check if value matches any regex in a list" Tags="|vimscript|regular-expression|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3087" PostTypeId="2" ParentId="3086" CreationDate="2015-04-26T23:17:55.640" Score="5" Body="&lt;p&gt;This should do the same:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! IsIgnored()&#xA;    return index(map(['gundo', 'nerdtree', 'git*'], '&amp;amp;filetype =~ v:val'), 1) &amp;gt; -1&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We first map the expression &lt;code&gt;&amp;amp;filetype =~ v:val&lt;/code&gt; to every entry in our array, this will return either &lt;code&gt;[0, 0, 0]&lt;/code&gt; if there are no matches, or &lt;code&gt;[0, 1, 0]&lt;/code&gt; if (for example) &lt;code&gt;nerdtree&lt;/code&gt; matches.&lt;br&gt;&#xA;We then use &lt;code&gt;index()&lt;/code&gt; to check if the array that &lt;code&gt;map()&lt;/code&gt; returns has an entry with a value of &lt;code&gt;1&lt;/code&gt; (&lt;code&gt;index()&lt;/code&gt; returns &lt;code&gt;-1&lt;/code&gt; on no matches).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-04-26T23:17:55.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3088" PostTypeId="2" ParentId="3086" CreationDate="2015-04-26T23:37:42.440" Score="5" Body="&lt;p&gt;I did define &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib#lists-related-functions&quot;&gt;&lt;code&gt;lh#list#match_re()&lt;/code&gt;&lt;/a&gt; (based on a loop for the purpose of finding which regex from a list is matched by a text).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in you case, why don't you just test &lt;code&gt;&amp;amp;ft =~ join(ignored_filetypes, '\|')&lt;/code&gt; ? &lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2015-04-26T23:37:42.440" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3089" PostTypeId="1" AcceptedAnswerId="3130" CreationDate="2015-04-27T06:57:13.263" Score="7" ViewCount="1355" Body="&lt;p&gt;I'm using (roughly) the same config for my mac and my ubuntu machine. I use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard=unnamed,unnamedplus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To conveniently share vim's clipboard with the system clipboard. However, lately the clipboard sharing broke under Mac OS X.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea what I did to break it, it still works fine under ubuntu. I've tried completely removing and reinstalling vim (via homebrew), deleting my &lt;code&gt;.vimrc&lt;/code&gt; and &lt;code&gt;.zshrc&lt;/code&gt; files, and still it doesn't seem to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, when I have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard=unnamed,unnamedplus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I cannot paste at all with vim. When I set&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then I can at least paste in vim, but of course it doesn't share the system clipboard (duh). Using &lt;code&gt;:reg&lt;/code&gt; confirms that with anything other than &lt;code&gt;set clipboard=&lt;/code&gt;, nothing is written to vim's registers. &lt;code&gt;:version&lt;/code&gt; gives me &lt;code&gt;+clipboard&lt;/code&gt; and &lt;code&gt;+xterm_clipboard&lt;/code&gt;. I've also tried it in iTerm2 and Terminal.app, both in and outside of tmux (same results). Also, manually copying to the registers (&lt;code&gt;&quot;*yy&lt;/code&gt;, &lt;code&gt;&quot;+yy&lt;/code&gt;) didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly, the the GUI-version (MacVim &lt;code&gt;7.4-74&lt;/code&gt;, also installed via homebrew) still functions fine in this regard, I can happily copy/paste to/from the system register there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you guys have any ideas? Cause I'm desperate at this point...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my &lt;code&gt;.vimrc&lt;/code&gt;: &lt;a href=&quot;https://github.com/DeX3/dotfiles/blob/master/.vimrc&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/DeX3/dotfiles/blob/master/.vimrc&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1842" LastEditorUserId="8" LastEditDate="2015-04-27T13:11:02.723" LastActivityDate="2021-08-07T19:24:05.377" Title="Clipboard sharing broke under MacOS X" Tags="|terminal|os-clipboard|macos|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3090" PostTypeId="1" CreationDate="2015-04-27T10:32:24.947" Score="3" ViewCount="187" Body="&lt;p&gt;I want to complete multiple lines at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, in a buffer (may be hidden):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;using std::cout;&#xA;using std::cin;&#xA;using std::endl;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the current buffer I can complete a whole line with &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;X&lt;/kbd&gt; &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;L&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;using st&#xA;        ^&#xA;   CTRL-X_CTRL-L&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I also complete the line along with the next lines? (they don't have to share a common prefix like in the example)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the help &lt;code&gt;i_CTRL-X_CTRL-L&lt;/code&gt; I found:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-X CTRL-L   After expanding a line you can additionally get the&#xA;        line next to it by typing CTRL-X CTRL-L again, unless&#xA;        a double CTRL-X is used.  Only works for loaded&#xA;        buffers.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which seems to be what I want, but it doesn't work. (If I enter the selection with &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;Y&lt;/kbd&gt; the cursor remains on the same line and pressing &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;X&lt;/kbd&gt; &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;L&lt;/kbd&gt; again completes the same line. If I enter the selection with &lt;kbd&gt;Enter&lt;/kbd&gt; the cursor ends on the next line and pressing &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;X&lt;/kbd&gt; &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;L&lt;/kbd&gt; again completes the same line (but on this new line))&lt;/p&gt;&#xA;" OwnerUserId="1881" LastActivityDate="2015-05-27T11:54:21.047" Title="Complete multiple lines" Tags="|key-bindings|autocompletion|insert-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3091" PostTypeId="2" ParentId="3090" CreationDate="2015-04-27T11:06:46.453" Score="1" Body="&lt;p&gt;It looks like this works if you don't press &lt;code&gt;&amp;lt;C-Y&amp;gt;&lt;/code&gt; to choose the selection. When you've selected the one you want using &lt;code&gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-P&amp;gt;&lt;/code&gt;, just type &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; again.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-04-27T11:06:46.453" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3092" PostTypeId="1" CreationDate="2015-04-27T19:08:44.860" Score="1" ViewCount="292" Body="&lt;p&gt;I just started using Unite and I noticed that searching with &lt;em&gt;file_rec&lt;/em&gt; doesn't return my vimrc. I've tried reinstalling Unite, clearing its cache with  and a few other things but nothing makes this file show up. Searching with the &lt;em&gt;file&lt;/em&gt; option does return my vimrc though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be complete, my vimrc is symlinked from another folder (called .dotfiles). If I cd into .dotfiles, open Vim, activate Unite, and search with the &lt;em&gt;file_rec&lt;/em&gt; option my vimrc will not show up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running Windows 8.1 in Cygwin if it might matter. Thanks for any help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem still occurs with a minimal vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin()&#xA;Plug 'https://github.com/Shougo/unite.vim'&#xA;call plug#end()&#xA;&#xA;call unite#filters#matcher_default#use(['matcher_fuzzy'])&#xA;call unite#custom#default_action('file', 'tabopen')&#xA;call unite#custom#default_action('buffer', 'tabopen')&#xA;call unite#custom#default_action('tab', 'tabopen')&#xA;call unite#custom#default_action('jump_list', 'tabopen')&#xA;&#xA;nnoremap &amp;lt;C-P&amp;gt; :Unite -start-insert file_rec&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-B&amp;gt; :Unite -start-insert buffer&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="200" LastEditorUserId="24" LastEditDate="2015-04-28T05:05:56.300" LastActivityDate="2015-06-28T03:46:57.750" Title="Unite file_rec search misses a file" Tags="|plugin-unite.vim|cygwin|" AnswerCount="1" CommentCount="2" ClosedDate="2015-06-29T14:18:21.640" ContentLicense="CC BY-SA 3.0" />
  <row Id="3093" PostTypeId="1" AcceptedAnswerId="3094" CreationDate="2015-04-27T20:00:42.787" Score="82" ViewCount="135456" Body="&lt;p&gt;Is there a way to change the size of the font in gVim, using native commands?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if not, what script can be used to do it quickly?&lt;/p&gt;&#xA;" OwnerUserId="602" LastEditorUserId="927" LastEditDate="2017-09-21T22:18:36.380" LastActivityDate="2023-11-26T14:31:14.223" Title="How can I change the font size in gVim?" Tags="|gvim|font|" AnswerCount="11" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3094" PostTypeId="2" ParentId="3093" CreationDate="2015-04-27T21:50:41.477" Score="65" Body="&lt;p&gt;Set the &lt;code&gt;guifont&lt;/code&gt; option in your &lt;code&gt;.gvimrc&lt;/code&gt;. See &lt;code&gt;:help guifont&lt;/code&gt; and &lt;code&gt;:help setting-guifont&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, you can do something like: &lt;code&gt;set guifont=Consolas:h11&lt;/code&gt; to use 11-point Consolas in gvim on Windows. There are a few other options you can use (each separated with a &lt;code&gt;:&lt;/code&gt;), such as &lt;code&gt;:b&lt;/code&gt; for bold, although some of these are only available on certain platforms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:h&lt;/code&gt; option to set the font size as demonstrated is probably the most useful, and the one specifically related to changing the &lt;em&gt;size&lt;/em&gt; of the font, as you requested.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-04-27T21:50:41.477" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3095" PostTypeId="5" CreationDate="2015-04-28T05:11:43.363" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/Shougo/unite.vim&quot; rel=&quot;nofollow&quot;&gt;unite or unite.vim plug-in&lt;/a&gt; can search and display information from arbitrary sources like files, buffers, recently used files or registers. You can run several pre-defined actions on a target displayed in the unite window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference between unite and similar plug-ins like fuzzyfinder, ctrl-p or ku is that unite provides an integration interface for several sources and you can create new interfaces using unite.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-04-28T07:52:34.647" LastActivityDate="2015-04-28T07:52:34.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3096" PostTypeId="4" CreationDate="2015-04-28T05:11:43.363" Score="0" Body="Plugin that adds support for searching multiple sources, such as files, buffers, and registers" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-04-28T07:52:39.917" LastActivityDate="2015-04-28T07:52:39.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3097" PostTypeId="1" AcceptedAnswerId="3098" CreationDate="2015-04-28T11:53:55.563" Score="3" ViewCount="179" Body="&lt;p&gt;When I type &lt;code&gt;1. blah blah blah&lt;/code&gt; Vim recognizes the &lt;code&gt;1.&lt;/code&gt; prefix and it indents the rest of the paragraph tidy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to configure Vim to do the same thing with &lt;code&gt;#.&lt;/code&gt; literal prefix, since ReST files autonumbers the paragraphs when started with &lt;code&gt;#.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;https://stackoverflow.com/questions/29907651/indentation-with-start-of-paragraph?noredirect=1#29907651&quot;&gt;this SO answer&lt;/a&gt; I got suggested this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;formatlistpat = '^\s*\%(\d\+\|#\)[\]:.)}\t ]\s*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I added this to my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead,BufNewFile *.rst let &amp;amp;formatlistpat = '^\s*\%(\d\+\|#\)[\]:.)}\t ]\s*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't work. In fact, I modified the regexp and Vim seems to ignore anything I put there.&lt;/p&gt;&#xA;" OwnerUserId="1890" LastEditorUserId="51" LastEditDate="2015-04-28T12:07:07.313" LastActivityDate="2015-04-28T12:13:47.050" Title="Indentation with &quot;#.&quot; start of paragraph" Tags="|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3098" PostTypeId="2" ParentId="3097" CreationDate="2015-04-28T12:06:31.540" Score="7" Body="&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27flp%27&quot;&gt;&lt;code&gt;:help 'formatlistpat'&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A pattern that is used to recognize a list header.  This is used for the &quot;n&quot; flag in 'formatoptions'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27fo%27&quot;&gt;&lt;code&gt;:help 'formatoptions'&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim default: &quot;tcq&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#fo-table&quot;&gt;&lt;code&gt;:help fo-table&lt;/code&gt;&lt;/a&gt; describes the meaning of the &lt;code&gt;n&lt;/code&gt; flag:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;n  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;      When formatting text, recognize numbered lists.  This actually uses the &lt;code&gt;'formatlistpat'&lt;/code&gt; option, thus any kind of list can be used.&lt;br&gt;&#xA;  [..rest snipped..]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I suspect it's probably a matter of just adding this flag to &lt;code&gt;formatoptions&lt;/code&gt;. To add the flag, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set formatoptions+=n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-04-28T12:13:47.050" LastActivityDate="2015-04-28T12:13:47.050" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3099" PostTypeId="1" AcceptedAnswerId="3101" CreationDate="2015-04-28T12:08:40.570" Score="15" ViewCount="2630" Body="&lt;p&gt;I have found some color schemes that I like, but some of them have the feature that the lines below the content of the file on the display - the &lt;code&gt;~&lt;/code&gt; area - have a different background color as shown.. I want it to be the same background color as normal text. When editing the color scheme, what keyword am I looking for to fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using MacVim but I assume this is a universal question. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/WgYmH.png&quot; alt=&quot;Two different backgrounds&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1882" LastEditorUserId="51" LastEditDate="2015-04-28T12:22:50.783" LastActivityDate="2016-12-07T00:38:51.590" Title="When making a colorscheme, what is the label for the ~ area of the screen below EOF?" Tags="|colorscheme|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3100" PostTypeId="2" ParentId="3099" CreationDate="2015-04-28T12:17:19.160" Score="3" Body="&lt;p&gt;In terms of highlight groups, I believe it is called &lt;code&gt;NonText&lt;/code&gt;. From &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#hl-NonText&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:he highlight-groups&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        hl-NonText&#xA;NonText         '~' and '@' at the end of the window, characters from&#xA;                'showbreak' and other characters that do not really exist in&#xA;                the text (e.g., &quot;&amp;gt;&quot; displayed when a double-wide character&#xA;                doesn't fit at the end of the line).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can probably set it to the same colour as the remaining area using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi NonText ctermfg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="51" LastEditDate="2015-04-28T12:51:59.730" LastActivityDate="2015-04-28T12:51:59.730" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3101" PostTypeId="2" ParentId="3099" CreationDate="2015-04-28T12:17:50.747" Score="17" Body="&lt;p&gt;Since Vim 8 there is the &lt;code&gt;EndOfBuffer&lt;/code&gt; highlight group for this; from &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#hl%2dEndOfBuffer&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help hl-EndOfBuffer&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EndOfBuffer filler lines (~) after the last line in the buffer.&#xA;        By default, this is highlighted like hl-NonText.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For earlier Vim versions it's &lt;code&gt;NonText&lt;/code&gt;. From &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#hl-NonText&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help hl-NonText&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NonText         '~' and '@' at the end of the window, characters from&#xA;                'showbreak' and other characters that do not really exist in&#xA;                the text (e.g., &quot;&amp;gt;&quot; displayed when a double-wide character&#xA;                doesn't fit at the end of the line).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I didn't know this either. How I found this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I typed &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27hl%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'highlight'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;I noticed there's a list with highlight &quot;occasions&quot; here with a brief description.&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;/\~&lt;/code&gt; to search for the &lt;code&gt;~&lt;/code&gt; character&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And on &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#E185&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help colorscheme&lt;/code&gt;&lt;/a&gt; I read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi[ghlight] clear {group-name}&#xA;:hi[ghlight] {group-name} NONE&#xA;                        Disable the highlighting for one highlight group.  It&#xA;                        is _not_ set back to the default colors.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:highlight clear NonText&lt;/code&gt; seems to work for me.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-12-07T00:38:51.590" LastActivityDate="2016-12-07T00:38:51.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3102" PostTypeId="1" CreationDate="2015-04-28T13:30:44.973" Score="0" ViewCount="58" Body="&lt;p&gt;When I'm working in a project it would be useful to be able to set some abbreviations / mappings that are specific only to that project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can have file specific mappings in &lt;code&gt;~/.vim/after/ftplugin&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how would I make it so that certain mappings only in the project I'm working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So say I have &lt;code&gt;~/Foo/Bar&lt;/code&gt; , &lt;code&gt;Bar&lt;/code&gt; being the project that I'm working in. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could then have some file &lt;code&gt;.vimProjectConfig&lt;/code&gt; in &lt;code&gt;Bar&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;.vimProjectConfig&lt;/code&gt; I could have something such as : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev ah Aldous Huxley &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or other &lt;code&gt;nnoremap&lt;/code&gt; settings, etc. &lt;/p&gt;&#xA;" OwnerUserId="1443" LastActivityDate="2015-04-29T03:08:57.523" Title="Create project specific mappings and abbreviations" Tags="|vimrc|autocompletion|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ClosedDate="2015-04-29T12:30:13.380" ContentLicense="CC BY-SA 3.0" />
  <row Id="3103" PostTypeId="2" ParentId="77" CreationDate="2015-04-28T14:16:16.527" Score="5" Body="&lt;h2&gt;Central configuration&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If it's okay to configure the specific commands / local exceptions centrally, you can put such autocmds into your &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd BufRead,BufNewFile /path/to/dir/* setlocal ts=4 sw=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is important to use &lt;code&gt;:setlocal&lt;/code&gt; instead of &lt;code&gt;:set&lt;/code&gt;, and likewise &lt;code&gt;:map &amp;lt;buffer&amp;gt; ...&lt;/code&gt; and &lt;code&gt;:command! -buffer ...&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, if you want the specific configuration stored with the project (and don't want to embed this in all files via &lt;em&gt;modelines&lt;/em&gt;), you have the following two options:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Local config with built-in functionality&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you always start Vim from the project root directory, the built-in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set exrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;enables the reading of a &lt;code&gt;.vimrc&lt;/code&gt; file from the current directory. You can place the &lt;code&gt;:set ts=4 sw=4&lt;/code&gt; commands in there.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Local config through plugin&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you need the help of a plugin; there are several on vim.org; I can recommend the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3393&quot; rel=&quot;noreferrer&quot;&gt;localrc plugin&lt;/a&gt;, which even allows local filetype-specific configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note that reading configuration from the file system has security implications; you may want to &lt;code&gt;:set secure&lt;/code&gt;.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-28T14:16:16.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3104" PostTypeId="2" ParentId="3093" CreationDate="2015-04-28T17:25:00.743" Score="22" Body="&lt;p&gt;I have the following in my .vimrc to change font size quickly without changing the font.  Works on Windows and GTK.  I haven't tested other GUIs.  I'm sure I originally copied it from somebody else, but it's been in my rc file so long I don't remember where it came from.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;unix&quot;)&#xA;    function! FontSizePlus ()&#xA;      let l:gf_size_whole = matchstr(&amp;amp;guifont, '\( \)\@&amp;lt;=\d\+$')&#xA;      let l:gf_size_whole = l:gf_size_whole + 1&#xA;      let l:new_font_size = ' '.l:gf_size_whole&#xA;      let &amp;amp;guifont = substitute(&amp;amp;guifont, ' \d\+$', l:new_font_size, '')&#xA;    endfunction&#xA;&#xA;    function! FontSizeMinus ()&#xA;      let l:gf_size_whole = matchstr(&amp;amp;guifont, '\( \)\@&amp;lt;=\d\+$')&#xA;      let l:gf_size_whole = l:gf_size_whole - 1&#xA;      let l:new_font_size = ' '.l:gf_size_whole&#xA;      let &amp;amp;guifont = substitute(&amp;amp;guifont, ' \d\+$', l:new_font_size, '')&#xA;    endfunction&#xA;else&#xA;    function! FontSizePlus ()&#xA;      let l:gf_size_whole = matchstr(&amp;amp;guifont, '\(:h\)\@&amp;lt;=\d\+$')&#xA;      let l:gf_size_whole = l:gf_size_whole + 1&#xA;      let l:new_font_size = ':h'.l:gf_size_whole&#xA;      let &amp;amp;guifont = substitute(&amp;amp;guifont, ':h\d\+$', l:new_font_size, '')&#xA;    endfunction&#xA;&#xA;    function! FontSizeMinus ()&#xA;      let l:gf_size_whole = matchstr(&amp;amp;guifont, '\(:h\)\@&amp;lt;=\d\+$')&#xA;      let l:gf_size_whole = l:gf_size_whole - 1&#xA;      let l:new_font_size = ':h'.l:gf_size_whole&#xA;      let &amp;amp;guifont = substitute(&amp;amp;guifont, ':h\d\+$', l:new_font_size, '')&#xA;    endfunction&#xA;endif&#xA;&#xA;&#xA;if has(&quot;gui_running&quot;)&#xA;    nmap &amp;lt;S-F12&amp;gt; :call FontSizeMinus()&amp;lt;CR&amp;gt;&#xA;    nmap &amp;lt;F12&amp;gt; :call FontSizePlus()&amp;lt;CR&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1688" LastActivityDate="2015-04-28T17:25:00.743" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3105" PostTypeId="1" AcceptedAnswerId="3107" CreationDate="2015-04-28T21:44:19.947" Score="52" ViewCount="10569" Body="&lt;p&gt;A fairly common operation for me in Vim, since I am compulsive-obsessive and like to keep my files free of whitespace, is to delete the &lt;em&gt;contents&lt;/em&gt; of an entire line, but not the line itself (i.e. not the line break).&lt;/p&gt;&#xA;&lt;p&gt;Is there a built-in Vim way to do this? Perhaps a &lt;kbd&gt;d&lt;/kbd&gt;&lt;code&gt;&amp;lt;movement command&amp;gt;&lt;/code&gt; operation?&lt;/p&gt;&#xA;&lt;p&gt;So far, the best I have is (on the line in question) &lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;. Is there a quicker way?&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="23502" LastEditDate="2023-11-15T19:32:43.447" LastActivityDate="2023-11-15T19:32:43.447" Title="Can I delete an entire line, except the line break?" Tags="|key-bindings|cursor-movement|" AnswerCount="7" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3106" PostTypeId="2" ParentId="3105" CreationDate="2015-04-28T22:22:51.523" Score="7" Body="&lt;p&gt;&lt;code&gt;0D&lt;/code&gt; is probably what you want.  It will delete from the cursor to the end of the line while leaving the line (and any characters before the cursor) in place.&lt;/p&gt;&#xA;" OwnerUserId="1896" LastEditorUserId="1896" LastEditDate="2015-04-28T22:24:38.220" LastActivityDate="2015-04-28T22:24:38.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3107" PostTypeId="2" ParentId="3105" CreationDate="2015-04-28T22:26:35.830" Score="55" Body="&lt;p&gt;You can use &lt;code&gt;0D&lt;/code&gt; this will go to the first character on the line and delete until the end of the line.  Note that you can use &lt;code&gt;^D&lt;/code&gt; if you want to leave any preceding whitespace alone.  Also, these operations cannot be repeated by using &lt;code&gt;.&lt;/code&gt;.  If you want an operation which can be repeated with the &lt;code&gt;.&lt;/code&gt; command, refer to David Lord's answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 0&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help D&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help ^&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-04-29T18:20:05.313" LastActivityDate="2015-04-29T18:20:05.313" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3108" PostTypeId="2" ParentId="3105" CreationDate="2015-04-28T22:44:06.840" Score="4" Body="&lt;p&gt;I typically use &lt;code&gt;ddO&lt;/code&gt;. &lt;code&gt;dd&lt;/code&gt; to delete the current line, and &lt;code&gt;O&lt;/code&gt; (that's a capital o) to add a new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is also 3 keystrokes, but &lt;code&gt;dd&lt;/code&gt; counts only as 1 and a half, and I find &lt;code&gt;O&lt;/code&gt; easier to type than &lt;code&gt;$&lt;/code&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's different from the &lt;code&gt;0D&lt;/code&gt; solution in that it does auto-indentation, for example with this code (where &lt;code&gt;!···&lt;/code&gt; is a tab, and █ the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def asd():&#xA;!···if foo:&#xA;!···!···foo()█&#xA;!···!···foobar()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;0D&lt;/code&gt; will leave you with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def asd():&#xA;!···if foo:&#xA;█&#xA;!···!···foobar()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;ddO&lt;/code&gt; will leave you with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def asd():&#xA;!···if foo:&#xA;!···!···█&#xA;!···!···foobar()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if you press &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; immediately after this, Vim should remove the auto-indentation, so you have the same as with &lt;code&gt;0D&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no 'correct' way, it will depend what exactly you'll want to do. I prefer &lt;code&gt;ddO&lt;/code&gt; because it's more flexible, and because it's &quot;in my fingers&quot; :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-04-28T23:28:29.973" LastActivityDate="2015-04-28T23:28:29.973" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3109" PostTypeId="1" AcceptedAnswerId="3121" CreationDate="2015-04-29T01:32:54.260" Score="13" ViewCount="14668" Body="&lt;p&gt;I have a problem I can think of two general approaches for solving, but I don't know specifics for either approach.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;Level 1:    cũng    also&#xA;Level 1:    và      and&#xA;Level 1:    như     like; such as&#xA;Level 2:    các     plural marker&#xA;Level 2:    của     belonging to&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For each line starting &quot;Level n&quot; I want to insert a number, beginning with &quot;01&quot;. For simplicity let's prepend the number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Approach 1: Manually select all the lines with same Level. Invoke magic I am soon to learn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Approach 2: Write a search and replace which matches all lines with given Level which at each match includes a number in the replace text, which increments by one with each match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found similar questions &lt;a href=&quot;https://stackoverflow.com/questions/9903660&quot;&gt;on StackOverflow&lt;/a&gt; or on other Vim sites, but each seems to have one or more of the following problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is about inserting the current line number rather than an arbitrary but incrementing number.&lt;/li&gt;&#xA;&lt;li&gt;Doesn't zero-pad the number.&lt;/li&gt;&#xA;&lt;li&gt;Doesn't actually work for selections on my Vim 7.4 running on Windows 7.&#xA;(These ones result in the error &lt;code&gt;E481: No range allowed&lt;/code&gt;.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am running gVim in Windows with mswin.vim but a solution that works on all vanilla Vim installs without having to customize the setup might be best.&lt;/p&gt;&#xA;" OwnerUserId="878" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-04-29T21:42:46.387" Title="Insert an incrementing number to each line in either a selection or a match" Tags="|macro|replace|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3110" PostTypeId="2" ParentId="3109" CreationDate="2015-04-29T02:37:42.050" Score="4" Body="&lt;p&gt;You could approach it by recording a macro. Starting with your original file, prepend the first instance with the number.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;01 Level 1:    cũng    also&#xA;Level 1:    và      and&#xA;Level 1:    như     like; such as&#xA;Level 2:    các     plural marker&#xA;Level 2:    của     belonging to&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Move your cursor to &lt;code&gt;01&lt;/code&gt;, select and yank it with &lt;code&gt;yiw&lt;/code&gt;. Now you want to record your actions from this point out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;qq/^Level 1&amp;lt;CR&amp;gt;P&amp;lt;C-A&amp;gt;A&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;0yiwq&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; Start a macro in register q&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/^Level 1&amp;lt;CR&amp;gt;&lt;/code&gt; Search for a line starting with &quot;Level 1&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt; paste before cursor (contains your number)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-A&amp;gt;&lt;/code&gt; increments the number&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;&lt;/code&gt; Insert a space after the number&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; Move to the start&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yiw&lt;/code&gt; yank the current number&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; End the macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then repeat this macro by using &lt;code&gt;@q&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2015-04-29T02:43:24.983" LastActivityDate="2015-04-29T02:43:24.983" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3112" PostTypeId="2" ParentId="3092" CreationDate="2015-04-29T03:14:35.507" Score="0" Body="&lt;p&gt;I believe this turned out to be a permission error with Cygwin. Deleting and recloning my dotfiles from github seems to have fixed the problem.&lt;/p&gt;&#xA;" OwnerUserId="200" LastActivityDate="2015-04-29T03:14:35.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3113" PostTypeId="2" ParentId="3105" CreationDate="2015-04-29T07:12:29.393" Score="28" Body="&lt;p&gt;&lt;code&gt;cc &amp;lt;Esc&amp;gt;&lt;/code&gt; will do as you ask, but is more keystrokes than &lt;code&gt;0D&lt;/code&gt;. If you want to put something into that line afterwards, &lt;code&gt;cc&lt;/code&gt; may be best.&lt;/p&gt;&#xA;" OwnerUserId="212" LastEditorUserId="212" LastEditDate="2017-11-29T03:19:55.687" LastActivityDate="2017-11-29T03:19:55.687" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3114" PostTypeId="2" ParentId="3109" CreationDate="2015-04-29T08:10:15.543" Score="3" Body="&lt;p&gt;You can build from &lt;a href=&quot;https://stackoverflow.com/a/4224454/15934&quot;&gt;https://stackoverflow.com/a/4224454/15934&lt;/a&gt; to zero pad your numbers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; A reminder: how to start numbers at the first line&#xA;:'&amp;lt;,'&amp;gt;s/^\s*\zs/\=(line('.') - line(&quot;'&amp;lt;&quot;)+1).'. '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in order to simplify the action of padding numbers, I'd go for a pair of functions and a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command!  -range=% -nargs=? PrependNumbers &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call s:Prepend(&amp;lt;args&amp;gt;)&#xA;&#xA;function! s:ReplExpr(nb_digits, number)&#xA;  return repeat('0', a:nb_digits - strlen(a:number)).a:number&#xA;endfunction&#xA;&#xA;function! s:Prepend(...) range&#xA;  let pattern = a:0 &amp;gt; 0 ? '\ze'. a:1 : '^'&#xA;  let nb_values = (a:lastline - a:firstline) + 1&#xA;  let nb_digits = strlen(nb_values)&#xA;  exe ':'.a:firstline.','a:lastline.'s#'.pattern.'#\=s:ReplExpr(nb_digits, 1+ line(&quot;.&quot;)-'.a:firstline.').&quot; &quot;#'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Than, select your lines and type &lt;code&gt;:PrependNumber&lt;/code&gt; (you'll see &lt;code&gt;:'&amp;lt;,'&amp;gt;PrependNumber&lt;/code&gt;. [Note: The command takes an optional parameter: the pattern before which the number will be inserted]&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-04-29T08:10:15.543" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3115" PostTypeId="1" AcceptedAnswerId="3126" CreationDate="2015-04-29T10:04:01.573" Score="56" ViewCount="185076" Body="&lt;p&gt;I have a file with a bunch of user defaults in. I want to change some of the text, but I'm struggling coming up with a matcher and replacer. Using the following example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;###############################################################################&#xA;# Trackpad, mouse, keyboard, Bluetooth accessories, and input                 #&#xA;###############################################################################&#xA;&#xA;# Trackpad: enable tap to click for this user and for the login screen&#xA;defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to replace &lt;code&gt;# Trackpad: ...&lt;/code&gt; with &lt;code&gt;running &quot;Trackpad: ...&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Breaking the problem down, I came up with something using a regex tester:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\n\n#\s(.*)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I try and use this in Vim it doesn't work for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/\n\n#\s(.*)/running &quot;\1&quot;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess my problem boils down to two specific questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How can I avoid searching for &lt;code&gt;\n&lt;/code&gt; characters, and instead make sure &lt;code&gt;#&lt;/code&gt; doesn't appear at the end of the search group?&lt;/li&gt;&#xA;&lt;li&gt;How can I effectively use capture groups?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There are some great answers below. Hard to choose between all three, however I feel the chosen answer is the most accurate for my original spec. I recommend you try all three answers with the &lt;a href=&quot;https://github.com/squarefrog/dotfiles/blob/f4c5607f1826e85b55fb58e9c81b474a3f67ce91/osx/setup_defaults.sh&quot;&gt;actual file&lt;/a&gt; to see how you feel about them.&lt;/p&gt;&#xA;" OwnerUserId="131" LastEditorUserId="24" LastEditDate="2019-10-07T22:59:32.007" LastActivityDate="2019-10-07T22:59:32.007" Title="Find and replace using regular expressions" Tags="|regular-expression|substitute|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3116" PostTypeId="2" ParentId="3115" CreationDate="2015-04-29T10:18:29.513" Score="9" Body="&lt;p&gt;You can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;search for lines that don't end in &lt;code&gt;#&lt;/code&gt;: &lt;code&gt;:/[^#]$/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;replace &lt;code&gt;#\s(.*)&lt;/code&gt; at the start of the line: &lt;code&gt;s/\v^#\s(.*)/running &quot;\1&quot;/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To use groups, you need to either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;escape the brackets so that they become part of the regex syntax: &lt;code&gt;\(.*\)&lt;/code&gt;, or&lt;/li&gt;&#xA;&lt;li&gt;use &lt;a href=&quot;https://vi.stackexchange.com/a/2279/205&quot;&gt;&quot;magic&quot;&lt;/a&gt; by beginning the expression with &lt;code&gt;\v&lt;/code&gt;: &lt;code&gt;s/\v...&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Combining it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/[^#]$/s/\v^#\s(.*)/running &quot;\1&quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2015-04-29T10:18:29.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3117" PostTypeId="2" ParentId="3105" CreationDate="2015-04-29T10:27:43.763" Score="17" Body="&lt;p&gt;&lt;code&gt;S&lt;/code&gt; and then &lt;code&gt;Ctrl+C&lt;/code&gt; or &lt;code&gt;Esc&lt;/code&gt; seems to accomplish the exact same function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can then be repeated with &lt;code&gt;.&lt;/code&gt; as it constitutes a single action.&lt;/p&gt;&#xA;" OwnerUserId="662" LastEditorUserId="662" LastEditDate="2015-04-29T15:39:28.827" LastActivityDate="2015-04-29T15:39:28.827" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3118" PostTypeId="2" ParentId="3115" CreationDate="2015-04-29T10:29:19.620" Score="19" Body="&lt;p&gt;I would use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/^#\s\+\(.\{-}\):/running &quot;\1&quot;:/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^#&lt;/code&gt; to match the &lt;code&gt;#&lt;/code&gt; character anchored at the start of the line (this answers question 1)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s\+&lt;/code&gt; to match any whitespace one or more times&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(&lt;/code&gt; to start a group (this answers question 2)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.\{-}\&lt;/code&gt; to match any character 0 or more times &lt;em&gt;in a non-greedy way&lt;/em&gt;; this is diffferent from &lt;code&gt;.*&lt;/code&gt; in that it tries to match as little as possible, and not as much as possible. Try adding a &lt;code&gt;:&lt;/code&gt; character in the comment to see why this matters&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\)&lt;/code&gt; to end the subgroup.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:&lt;/code&gt; matches a literal &lt;code&gt;:&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;We then replace this with the text you want, and use &lt;code&gt;\1&lt;/code&gt; to refer to the group we captured.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I came up with something using a regex tester&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Regular expression syntax is a bit like wiki syntax: there are a bunch of them, they all look alike at a glance, none of them is obviously better than any other, but there are many differences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Today, the so called &quot;Perl compatible&quot; regular expressions are the de-facto default in most languages, but Vim regular expressions are &lt;em&gt;not&lt;/em&gt; compatible with Perl-compatible expressions! Vim regexp syntax goes back to at least the '70's, when Perl wasn't even around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see this with the subgroups, where you have to use &lt;code&gt;\(&lt;/code&gt; and not &lt;code&gt;(&lt;/code&gt; (this is compatible with POSIX 'basic' syntax, but not with the more common POSIX 'extended' syntax or Perl syntax). You can control this by adding the &lt;code&gt;\v&lt;/code&gt; flag in a pattern (See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#/%5CV&quot;&gt;&lt;code&gt;:help /\v&lt;/code&gt;&lt;/a&gt; for details), this will make it &quot;more compatible&quot;, but not completely (You still have to use &lt;code&gt;.{-}&lt;/code&gt; for non-greedy matches for example)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this might explain why using &quot;a regex tester&quot; almost, but not quite,  works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.vimregex.com/&quot;&gt;http://www.vimregex.com/&lt;/a&gt; as a good overview/cheatsheet of Vim regexps.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-04-29T10:29:19.620" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3119" PostTypeId="1" CreationDate="2015-04-29T12:06:27.203" Score="8" ViewCount="2170" Body="&lt;p&gt;I tried mapping control-H, J, K, and L respectively in insert mode to move around splits.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-h&amp;gt; &amp;lt;ESC&amp;gt;&amp;lt;C-W&amp;gt;&amp;lt;C-h&amp;gt;i &#xA;inoremap &amp;lt;C-l&amp;gt; &amp;lt;ESC&amp;gt;&amp;lt;C-W&amp;gt;&amp;lt;C-l&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press control L, it moves along fine, but when I press control H, it does a backspace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My understanding is that control-H is backspace in terminal, which is why I can't do this. Is there any workaround? The following says that control h is not mapped&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose imap &amp;lt;C-h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1907" LastEditorUserId="1238" LastEditDate="2019-12-19T22:44:04.257" LastActivityDate="2019-12-19T22:44:04.257" Title="Mapping control-H in insert mode doesn't work; it always works like backspace" Tags="|key-bindings|insert-mode|terminal|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3120" PostTypeId="2" ParentId="3119" CreationDate="2015-04-29T12:59:35.667" Score="7" Body="&lt;p&gt;The problem is that many terminal emulators emit a &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; (0x08) when you press &lt;code&gt;&amp;lt;Backspace&amp;gt;&lt;/code&gt;, there is no way for Vim to see if the user pressed Backspace, or &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So one thing you can do, is remap the &lt;code&gt;&amp;lt;Backspace&amp;gt;&lt;/code&gt; key:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Backspace&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;C-W&amp;gt;&amp;lt;C-h&amp;gt;a&#xA;inoremap &amp;lt;C-l&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;C-W&amp;gt;&amp;lt;C-l&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should work are you expect, with the obvious downside that you've now lost your backspace key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not all is lost, there is also &lt;em&gt;another&lt;/em&gt; common keycode for the backspace key: &lt;code&gt;&amp;lt;C-?&amp;gt;&lt;/code&gt; (0x7f, or the &lt;code&gt;DEL&lt;/code&gt; character). So you'll need to configure your terminal emulator to send that key instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;xterm&lt;/code&gt; setting &lt;code&gt;xterm.*backarrowKey: false&lt;/code&gt; in &lt;code&gt;~/.Xdefaults&lt;/code&gt; is usually enough, though the logic that xterm uses in deciding which character to send is quite complex, see the &lt;code&gt;backarrowKeyIsErase&lt;/code&gt; in &lt;code&gt;xterm(1)&lt;/code&gt; for more information.&lt;br&gt;&#xA;You need to load this file with &lt;code&gt;xrdb ~/.Xdefaults&lt;/code&gt; and open a new terminal window for this to take effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For other terminal emulators, the procedure will differ. For example in &lt;code&gt;gnome-terminal&lt;/code&gt; you can configure this in &lt;code&gt;Edit -&amp;gt; Profile preferences -&amp;gt; Backspace key generates&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, you want to tell Vim to accept &lt;code&gt;^?&lt;/code&gt; as the backspace character with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_kb=^?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't type &lt;code&gt;^?&lt;/code&gt;, you need to insert the escape code, so use &lt;code&gt;&amp;lt;C-v&amp;gt;x7f&lt;/code&gt; to insert it (or, if you've reloaded the terminal settings, pressing &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;BS&amp;gt;&lt;/code&gt; should also work).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should now be able to remap &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-h&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;C-W&amp;gt;&amp;lt;C-h&amp;gt;a&#xA;inoremap &amp;lt;C-l&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;C-W&amp;gt;&amp;lt;C-l&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Related: &lt;a href=&quot;https://vi.stackexchange.com/questions/2419/mapping-ctrls-does-not-work&quot;&gt;Mapping Ctrl+s does not work&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-04-29T13:05:14.473" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3121" PostTypeId="2" ParentId="3109" CreationDate="2015-04-29T21:00:54.540" Score="22" Body="&lt;p&gt;Similar to the answer at &lt;a href=&quot;https://vi.stackexchange.com/a/818/227&quot;&gt;https://vi.stackexchange.com/a/818/227&lt;/a&gt;, you can use the global command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With it you can instruct vim to search for lines matching a pattern, and then perform commands on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, you wish to prepend text to lines starting with &quot;Level N:&quot;, so our global command could be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^Level \d:/{COMMANDS}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Using the substitute command (regular expression replacement) for the command&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The commands is more fun. I usually like to do a regular expression replacement for stuff like this, since it is easy to use variables.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Example for your question&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i = 1 | g/^Level \d:/s/^/\=printf(&quot;%02d &quot;, i)/ | let i = i+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;How it works&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In the replacement section of a substitution command can be an expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing we'll do is set a variable &lt;code&gt;i&lt;/code&gt; to be the starting number. I chose 1, but any number will do. &lt;code&gt;let i = 1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we run our global command, which sets us up to do an action on matched lines. &lt;code&gt;g/^Level \d:/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We'll have our global command insert the value and increment our counter using the substitution command and the let command. &lt;code&gt;s/^/\=printf(&quot;%02d &quot;, i)/ | let i = i+1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The substitution command's regular expression finds the beginning of the line &lt;code&gt;^&lt;/code&gt; and replaces it with an expression, and our expression will be the result of a formatted print. Like in the C language, vim's printf takes formatting parameters. &lt;code&gt;%02d&lt;/code&gt; means convert an argument as though it was a decimal number &lt;code&gt;d&lt;/code&gt;, occupying at least 2 spaces &lt;code&gt;2&lt;/code&gt; and pad with 0 &lt;code&gt;0&lt;/code&gt;. For details and other conversion options (including floating point formatting), see &lt;code&gt;:help printf&lt;/code&gt;. We give printf our counting variable &lt;code&gt;i&lt;/code&gt; and it gives us &lt;code&gt;01&lt;/code&gt; the first time, &lt;code&gt;02&lt;/code&gt; the second time, etc. This gets used by the substitution command to replace the beginning of the line, effectively inserting the result of the printf at the beginning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I put a space after the d: &lt;code&gt;&quot;%02d &quot;&lt;/code&gt;. You didn't ask for it in the question (and I didn't see example output), but I suspected you wanted to separate the number from the word &quot;Level&quot;. Remove the space from the string given to printf to have the inserted number right next to the L in Level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, that &lt;code&gt;let i = i + 1&lt;/code&gt; increments our counter after each substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be applied generally for replacing parts of lines that are matched by other criteria with arbitrary functional data.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Using combined normal commands&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This is good for simple insertions or complex editing. Like with substitute, we'll use global to match, but instead of regular expression substitution, we'll execute a series of operations as if typed by the user.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Example for your question&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i = 1 | g/^Level \d:/execute &quot;normal! I&quot; . printf(&quot;%02d &quot;, i) | let i = i+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;How it works&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The values used are very similar to the substitute (we're still using printf to format our number to make it 0 padded with 2 digits), but the operation is different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here we use the execute command, which takes a string and runs the string as an ex command (&lt;code&gt;:help :exe&lt;/code&gt;). We construct a string that combines &quot;normal! I&quot; with our data, which will be &quot;normal! I01 &quot; the first time and &quot;normal! I02 &quot; the second time, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;normal&lt;/code&gt; command performs operations as if in normal mode. In this example, our normal command is &lt;code&gt;I&lt;/code&gt;, which inserts at the beginning of the line. If we had used &lt;code&gt;dd&lt;/code&gt; it would delete the line, &lt;code&gt;o&lt;/code&gt; would open a new line after the matched line. It is as if you typed &lt;code&gt;I&lt;/code&gt; (or any other operations) yourself in normal mode. we use the &lt;code&gt;!&lt;/code&gt; after &lt;code&gt;normal&lt;/code&gt; to make sure no mappings get in our way. See &lt;code&gt;:help :normal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is inserted then is the value of our printf, as in the first example of using substitute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method can be fancier than regex, because you can do things like &lt;code&gt;execute &quot;normal! ^2wy&quot; . i . &quot;th$p&quot;&lt;/code&gt;, which will go to the beginning of the text &lt;code&gt;^&lt;/code&gt;, move forward 2 words &lt;code&gt;2w&lt;/code&gt;, yank until the ith 'h' character &lt;code&gt;y&quot; . i . &quot;th&lt;/code&gt;, move to the end of the line &lt;code&gt;$&lt;/code&gt;, and paste &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is almost like running a macro, but doesn't actually use up a register and can combine strings from any expressions. I find this to be very powerful.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Approach where each level has its own counter&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You might want each level to get its own counter. If you know the maximum number of levels ahead of time, you can do the following (adding extra code to find the largest level might not be too difficult, but would make this answer too long. This is getting long as it is).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, lets free i, in case we already used it as an integer. We can't convert i to a list, we have to create it that way.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:unlet! i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, lets set i to be a list containing the number of levels. You showed 2 in your question, but lets assume 10 for the fun of it. Since list indexing is 0 based, and I don't want to bother correcting for 1 based like your list, we'll just create enough elements (11) and never use the 0 index.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let j = 0&#xA;:let i = []&#xA;:while j &amp;lt; 11 | let i += [1] | let j += 1 | endwhile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, we need a way to get the level number. Fortunately, substitute is available as a function as well, so we'll give it our line and extract the level number &lt;code&gt;substitute(getline(&quot;.&quot;), &quot;^Level \\(\\d\\):.*&quot;, &quot;\\=submatch(1)&quot;, &quot;&quot;)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since i is now a list of 11 &lt;code&gt;1&lt;/code&gt;s (each index is the counter for our level), we can now adjust either of the above examples to use the result of this substitution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Via substitute command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:unlet! i | unlet! j | let j = 0 | let i = [] | while j &amp;lt; 11 | let i += [1] | let j += 1 | endwhile&#xA;:g/^Level \d:/let ind=str2nr(substitute(getline(&quot;.&quot;), &quot;^Level \\(\\d\\):.*&quot;, &quot;\\=submatch(1)&quot;, &quot;&quot;)) | s/^/\=printf(&quot;%02d &quot;, i[ind])/ | let i[ind] += 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Via normal command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:unlet! i | unlet! j | let j = 0 | let i = [] | while j &amp;lt; 11 | let i += [1] | let j += 1 | endwhile&#xA;:g/^Level \d:/let ind=str2nr(substitute(getline(&quot;.&quot;), &quot;^Level \\(\\d\\):.*&quot;, &quot;\\=submatch(1)&quot;, &quot;&quot;)) | execute &quot;normal! I&quot; . printf(&quot;%02d &quot;, i[ind]) | let i[ind] += 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example input:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Level 1: stuff&#xA;&#xA;Level 1: Stuff&#xA;&#xA;Some text&#xA;Level 3: Other&#xA;&#xA;Level 1: Meh&#xA;&#xA;Level 2: More&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;01 Level 1: stuff&#xA;&#xA;02 Level 1: Stuff&#xA;&#xA;Some text&#xA;01 Level 3: Other&#xA;&#xA;03 Level 1: Meh&#xA;&#xA;01 Level 2: More&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="227" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-04-29T21:42:46.387" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3122" PostTypeId="1" AcceptedAnswerId="3123" CreationDate="2015-04-30T00:53:02.320" Score="2" ViewCount="71" Body="&lt;p&gt;I try to color a word depending on its prior use. For example I have the following text file&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;a&lt;/strong&gt; : Type1&lt;/p&gt;&#xA;&lt;p&gt;b : Type2&lt;/p&gt;&#xA;&lt;p&gt;And now I will take about &lt;strong&gt;a&lt;/strong&gt; and b&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So Ideally I would like to define &lt;code&gt;Type1&lt;/code&gt; within the &lt;code&gt;syntax&lt;/code&gt; file so that &lt;code&gt;a&lt;/code&gt; gets highlighted whenever used afterwards in the text. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="1921" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-04-30T02:32:14.853" Title="Highlight word, depending on its prior use in the file" Tags="|vimrc|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3123" PostTypeId="2" ParentId="3122" CreationDate="2015-04-30T02:27:14.533" Score="3" Body="&lt;p&gt;To accomplish this you'll need to write an expression that matches your &lt;code&gt;var: TypeN&lt;/code&gt; situation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let type1Match = '\(.*\): Type1'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find all matches and store them in a list by using &lt;code&gt;vimgrep&lt;/code&gt; and &lt;code&gt;getqflist()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function FindMatches(regex)&#xA;  try&#xA;    silent execute &quot;vimgrep /&quot; . a:regex . &quot;/j %&quot;&#xA;  catch /^Vim\%((\a\+)\)\=:E480/&#xA;    return []&#xA;  endtry&#xA;  return split(join(map(copy(getqflist()), 'matchlist(v:val.text, a:regex)[1]')))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function returns a list containing all match cases or and empty list if none are found. To find all cases of &lt;code&gt;var: Type1&lt;/code&gt; use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo FindMatches(type1Match)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last step is to execute &lt;code&gt;syntax match&lt;/code&gt; on this list.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;syntax match type1Keyword \&quot;\\&amp;lt;\\(&quot; . join(FindMatches(type1Match), '\|') . &quot;\\)\\&amp;gt;\&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add this into your syntax file and when the file is saved and loaded it will execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing to note. This will highlight all cases of the match value. In your example the  &lt;code&gt;a&lt;/code&gt; in &lt;code&gt;a: Type1&lt;/code&gt; and in &lt;code&gt;And now I will talk about a and b&lt;/code&gt; will both be highlighted. You can make your syntax highlighter smarter by highlighting the specific &lt;code&gt;a: Type1&lt;/code&gt; situation differently but requires a match case of &lt;code&gt;.*:\s*Type[0-9]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2015-04-30T02:32:14.853" LastActivityDate="2015-04-30T02:32:14.853" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3124" PostTypeId="1" AcceptedAnswerId="3125" CreationDate="2015-04-30T05:32:22.977" Score="23" ViewCount="11763" Body="&lt;p&gt;How can I fold and unfold lines selected in visual mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say I have three paragraphs and I want to fold the first or last two into one line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Test&#xA;====&#xA;Lorem Ipsum es simplemente el texto de relleno de las imprentas y archivos&#xA;de texto. Lorem Ipsum ha sido el texto de relleno estándar de las industrias..&#xA;&#xA;Lorem Ipsum es simplemente el texto de relleno de las imprentas y archivos&#xA;de texto. Lorem Ipsum ha sido el texto de relleno estándar de las industrias..&#xA;&#xA;Lorem Ipsum es simplemente el texto de relleno de las imprentas y archivos&#xA;de texto. Lorem Ipsum ha sido el texto de relleno estándar de las industrias..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;za&lt;/code&gt; folds only one paragraph.&lt;/p&gt;&#xA;" OwnerUserId="147" LastEditorUserId="147" LastEditDate="2015-04-30T06:58:51.133" LastActivityDate="2015-04-30T06:58:51.133" Title="Fold selected lines" Tags="|visual-mode|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3125" PostTypeId="2" ParentId="3124" CreationDate="2015-04-30T05:58:16.470" Score="40" Body="&lt;p&gt;You can press &lt;kbd&gt;V&lt;/kbd&gt; to go into Visual Line mode, select the lines to be folded, then &lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; to make a manual fold.  You'll need to &lt;code&gt;:set foldmethod=manual&lt;/code&gt; if it isn't already set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can open the fold with &lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt;, or delete the fold with &lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2015-04-30T06:27:28.107" LastActivityDate="2015-04-30T06:27:28.107" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3126" PostTypeId="2" ParentId="3115" CreationDate="2015-04-30T07:21:02.547" Score="42" Body="&lt;p&gt;Just to be clear… I believe you asked for this to be the result of the substitution?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;###############################################################################&#xA;# Trackpad, mouse, keyboard, Bluetooth accessories, and input                 #&#xA;###############################################################################&#xA;&#xA;running &quot;Trackpad: enable tap to click for this user and for the login screen&quot;&#xA;defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In that case, I recommend the following command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/\n\n#\s\+\(.*\)/&lt;b&gt;&lt;i&gt;^M^M&lt;/i&gt;&lt;/b&gt;running &quot;\1&quot;/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Explanation of the pattern&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:s/&lt;i&gt;PATTERN&lt;/i&gt;/&lt;i&gt;REPLACEMENT&lt;/i&gt;/&lt;/code&gt; is the &lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#%3Asubstitute&quot; rel=&quot;noreferrer&quot;&gt;substitute&lt;/a&gt; command.  The percent sign in &lt;code&gt;:%s&lt;/code&gt; makes it work on the whole file, rather than just the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\n\n&lt;/code&gt; says that the line of interest must occur after a blank line.  If you didn't care about the preceding blank line, then &lt;code&gt;^&lt;/code&gt; would suffice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;#\s\+&lt;/code&gt; matches a hash character followed by one or more whitespace characters.  &lt;code&gt;\(.*\)&lt;/code&gt; captures all subsequent text on the line.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Explanation of the replacement text&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&lt;b&gt;&lt;i&gt;^M^M&lt;/i&gt;&lt;/b&gt;&lt;/code&gt; inserts two ends of lines to replace the &lt;code&gt;\n\n&lt;/code&gt; that were present in the pattern.  Otherwise, the text would get moved to the end of the line preceding the blank line.  To type each &lt;code&gt;&lt;b&gt;&lt;i&gt;^M&lt;/i&gt;&lt;/b&gt;&lt;/code&gt;, press &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; &lt;kbd&gt;Ctrl-M&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, insert the string &lt;code&gt;running&lt;/code&gt;, followed by whatever was captured in the parentheses within double-quotes.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="14244" LastEditDate="2018-07-15T03:06:44.617" LastActivityDate="2018-07-15T03:06:44.617" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3127" PostTypeId="1" AcceptedAnswerId="3129" CreationDate="2015-04-30T09:09:53.967" Score="12" ViewCount="1698" Body="&lt;p&gt;I've remapped &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; (enter) to &lt;code&gt;za&lt;/code&gt; so I can quickly open/close folds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, now when I use the quickfix window and hit enter it no longer jumps to the line with the error (because it's trying to open/close a fold that does not exist in the quick fix window).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to disable my mapping or re-set it locally when entering a quickfix window?&lt;/p&gt;&#xA;" OwnerUserId="1406" LastEditorUserId="1292" LastEditDate="2018-08-20T13:47:35.623" LastActivityDate="2018-08-20T13:47:35.623" Title="How to map Enter to custom command EXCEPT in quick fix?" Tags="|key-bindings|folding|quickfix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3128" PostTypeId="1" AcceptedAnswerId="3144" CreationDate="2015-04-30T09:28:25.780" Score="9" ViewCount="370" Body="&lt;p&gt;I've noticed that vim's fold method affects the efficiency of autocomplete, e.g. &lt;code&gt;C-N&lt;/code&gt; is slow, and &lt;code&gt;C-X L&lt;/code&gt; is hideously slow in medium sized files with relatively expensive &lt;code&gt;foldexpr&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't see the value in having foldexpr consulted while running through auto completes, so would like to disable this somehow so I get usable autocomplete back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;EDIT: Test case&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A test case: No plugins; and only this, which must be the &lt;strong&gt;most minimal&lt;/strong&gt; foldexpr function possible (and is completely useless, except for counting invocations) in &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:c = 0 &#xA;function! Myfoldexpr() &#xA;   let g:c = 1 + g:c &#xA;   return '0' &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now start vim with a blank document. We'll copy the first 100 lines of Vim's own help file, and then run autocomplete line, choosing the 10th suggestion, then see how many times foldexpr was called.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help&#xA;y100j:q&#xA;P:set foldexpr=Myfoldexpr()&#xA;:set fdm=expr&#xA;O&amp;lt;C-X&amp;gt;&amp;lt;C-L&amp;gt;&amp;lt;C-L&amp;gt;&amp;lt;C-L&amp;gt;&amp;lt;C-L&amp;gt;&amp;lt;C-L&amp;gt;&amp;lt;C-L&amp;gt;&amp;lt;C-L&amp;gt;&amp;lt;C-L&amp;gt;&amp;lt;C-L&amp;gt;&amp;lt;C-L&amp;gt;&amp;lt;Esc&amp;gt;&#xA;:echo g:c&#xA;2088&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now that's a 100 line file, with relatively short lines and the foldexpr was called 2088 times (although 100 of these are done when first setting the foldexpr). Efficient foldexpr is obviously good, but we programmers ask a lot of our foldexpr, so they are necessarily non-trivial, and when their execution time is multiplied by several thousand it makes you choose between autocomplete &lt;em&gt;or&lt;/em&gt; indent for productivity. Being greedy/lazy I'd like to be able to use both! Beyond attempting to rewrite several pretty well established foldexpr-based folding plugins (I've tried rewriting php-folding and after days of trying to optimise it to a workable state I gave up on foldexpr for php), perhaps there's a way to use a mapping to turn &lt;code&gt;fdm=manual&lt;/code&gt; before autocomplete or some such?&lt;/p&gt;&#xA;" OwnerUserId="1406" LastEditorUserId="1406" LastEditDate="2015-05-01T17:37:56.903" LastActivityDate="2015-05-01T18:28:51.363" Title="Is there a way to disable the foldexpr during autocomplete?" Tags="|autocompletion|folding|performance|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3129" PostTypeId="2" ParentId="3127" CreationDate="2015-04-30T10:12:38.810" Score="16" Body="&lt;p&gt;Using an expression mapping is the easiest way to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; &amp;amp;buftype ==# 'quickfix' ? &quot;\&amp;lt;CR&amp;gt;&quot; : 'za'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This defines a mapping that checks whether you are in the quickfix window, and then performs either a &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;za&lt;/code&gt; accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :map-expr&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h 'buftype'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h expr1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h string&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Mapping to a function&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can also define a function that carries out a regular enter when invoked from the quickfix window, and does 'za' otherwise. This isn't efficient for what you're trying to do, but I'm leaving it here because it's useful info for if you want to map to something more complicated than a normal mode command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FoldingEnter()&#xA;  if &amp;amp;buftype ==# 'quickfix'&#xA;    execute &quot;normal! \&amp;lt;CR&amp;gt;&quot;&#xA;  else&#xA;    normal! za&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;CR&amp;gt; :call FoldingEnter()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-12T10:24:32.760" LastActivityDate="2018-02-12T10:24:32.760" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3130" PostTypeId="2" ParentId="3089" CreationDate="2015-04-30T10:42:31.063" Score="4" Body="&lt;h2&gt;MacVim&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Under OS X, it's best to use &lt;a href=&quot;https://macvim-dev.github.io/macvim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MacVim&lt;/a&gt;. OS X behaves differently to other operating systems when it comes to things like clipboard management. MacVim is specifically designed to address the areas where Vim falls short on the Mac.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Coming to a terminal near you&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Although MacVim runs as a GUI (like GVim) by default, you can use MacVim in the terminal using &lt;code&gt;mvim -v&lt;/code&gt;. I'd recommend an alias such as the following (I'm using bash syntax; adjust according to your shell):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vim='mvim -v'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="64" LastEditorUserId="6852" LastEditDate="2016-12-03T10:19:09.567" LastActivityDate="2016-12-03T10:19:09.567" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3131" PostTypeId="1" CreationDate="2015-04-30T11:28:46.960" Score="3" ViewCount="1790" Body="&lt;p&gt;I have a script that writes output to a text file which I have open in a split side-by-side my code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use &lt;code&gt;:! python %&lt;/code&gt; it will close the window to display the terminal, show the script's terminal output and ask me to press enter to get back to my editor screen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since all I care about can be seen in the text file I already have open, I want to be able to just run the script and have no disruptions on screen. Alternatively, is it possible to have a 'mini-terminal' open as a split so that I can see the output of the script if need be? &lt;/p&gt;&#xA;" OwnerUserId="1872" LastEditorUserId="51" LastEditDate="2015-04-30T11:33:12.767" LastActivityDate="2015-04-30T17:14:38.613" Title="Run a python script without closing buffer" Tags="|external-command|" AnswerCount="1" CommentCount="3" ClosedDate="2015-04-30T17:24:48.780" ContentLicense="CC BY-SA 3.0" />
  <row Id="3132" PostTypeId="7" CreationDate="2015-04-30T15:31:13.233" Score="0" Body="&lt;p&gt;&lt;b&gt;Vi and Vim Stack Exchange&lt;/b&gt; is a question and answer site for people using the Vi and Vim families of text editors. It's built and run &lt;i&gt;by you&lt;/i&gt; as part of the &lt;a href=&quot;https://stackexchange.com&quot;&gt;Stack Exchange&lt;/a&gt; network of Q&amp;amp;A sites. With your help, we're working together to build a library of detailed answers to every question about Vi and Vim family of editors.&lt;/p&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="37004" LastEditDate="2021-07-13T11:29:58.507" LastActivityDate="2021-07-13T11:29:58.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3133" PostTypeId="2" ParentId="3131" CreationDate="2015-04-30T17:14:38.613" Score="2" Body="&lt;p&gt;For your situation, I believe you could do &lt;code&gt;:call system('python '.%)&lt;/code&gt; to run the same thing without showing the output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I have a script that can write to stdout, I usually open a new window and do &lt;code&gt;:r !python #&lt;/code&gt; to append the python output to the buffer directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that neither of these solutions are asynchronous-- vim will pause while the script is running. For async, you'd want to look at dispatch (or one of the underlying techniques it uses) or neovim.&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-04-30T17:14:38.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3134" PostTypeId="1" AcceptedAnswerId="3136" CreationDate="2015-04-30T18:43:42.990" Score="5" ViewCount="1301" Body="&lt;p&gt;I am trying to create a mapping that has 2 functions: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On 1st use: redefine itself to be used&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After: execute the newly saved mapping&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The workflow could be : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;leader&amp;gt;r&lt;/code&gt; -&gt; &lt;code&gt;map &amp;lt;leader&amp;gt;r dd&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;leader&amp;gt;r&lt;/code&gt; -&gt; &lt;code&gt;dd&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;leader&amp;gt;r&lt;/code&gt; -&gt; &lt;code&gt;dd&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I came up with this mapping : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map &amp;lt;Leader&amp;gt;r :nnoremap &amp;lt;Leader&amp;gt;r&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I get :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;leader&amp;gt;r&lt;/code&gt; -&gt; &lt;code&gt;:nnoremap  r&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My leader key is &lt;code&gt;\&amp;lt;Space&amp;gt;&lt;/code&gt;  and so a space is inserted and now I can trigger the mapping but with only pressing &lt;code&gt;r&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know a method to &quot;escape&quot; the leader key in a mapping ?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="24" LastEditDate="2015-05-01T08:26:19.507" LastActivityDate="2015-05-01T08:26:19.507" Title="Override a mapping with leader key" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3135" PostTypeId="2" ParentId="3134" CreationDate="2015-04-30T19:15:13.303" Score="4" Body="&lt;p&gt;From reading the Vim source, it would seem that all occurrences of &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; in a mapping are replaced by the leader character, you can't escape this. From &lt;code&gt;term.c&lt;/code&gt; &lt;code&gt;replace_keycodes()&lt;/code&gt; (abbreviated):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (strncmp(src, &quot;&amp;lt;Leader&amp;gt;&quot;, 8) == 0) {&#xA;    p = get_var_value(&quot;g:mapleader&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I only did a quick reading, so perhaps I missed something.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The easiest workaround I can figure out is using a character code to &quot;hide&quot; the &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; part from this piece of code, which seems to run &lt;em&gt;before&lt;/em&gt; the code that replaces the character codes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;Leader&amp;gt;r :nnoremap &amp;lt;Char-0x3c&amp;gt;Leader&amp;gt;r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;Char-0x3c&amp;gt;&lt;/code&gt; is the hex code for the &lt;code&gt;&amp;lt;&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note I didn't know about the &lt;code&gt;&amp;lt;Char-&lt;/code&gt; syntax either by the way, I found it by typing &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#key-mapping&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help key-mapping&lt;/code&gt;&lt;/a&gt;; at the top of the page there's an index and the &quot;Mapping special keys&quot; and &quot;Special characters&quot; sections looked interesting enough to skim, which is where I found this ;-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-04-30T19:15:13.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3136" PostTypeId="2" ParentId="3134" CreationDate="2015-04-30T19:46:08.693" Score="3" Body="&lt;p&gt;Inside a mapping, escape &lt;code&gt;&amp;lt;&lt;/code&gt; with &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt; (and &lt;code&gt;|&lt;/code&gt; with &lt;code&gt;&amp;lt;Bar&amp;gt;&lt;/code&gt;). The following example shows a working demo of your idea:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Leader&amp;gt;r :nnoremap &amp;lt;lt&amp;gt;Leader&amp;gt;r :echo &quot;hi&quot;&amp;lt;lt&amp;gt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/05.html&quot; rel=&quot;nofollow&quot;&gt;You should use &lt;code&gt;:noremap&lt;/code&gt;&lt;/a&gt; for the initial mapping, too.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-04-30T19:46:08.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3138" PostTypeId="1" AcceptedAnswerId="3140" CreationDate="2015-04-30T22:06:32.073" Score="11" ViewCount="3953" Body="&lt;p&gt;I recently have noticed that entering and then exiting insert mode will move your cursor one space to the left.  This is a default behavior of vim, since it still occurs with &lt;code&gt;vim -u NONE -U NONE -N&lt;/code&gt;.  I found &lt;a href=&quot;https://stackoverflow.com/questions/2295410/prevent-cursor-from-moving-back-one-character-on-insert-mode-exit&quot;&gt;this&lt;/a&gt; answer and stackoverflow, but it doesn't really explain why this is default behavior.  Why is this default behavior, and should I use I use a workaround like his answer suggests?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I were to use a workaround, it would look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Esc&amp;gt; &amp;lt;Esc&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, I did try &lt;code&gt;set virtualedit=onemore&lt;/code&gt; but that just seems to do what it says on its help page and nothing more.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-05-01T00:43:15.537" Title="Cursor moves one character backwards on exiting insert mode" Tags="|cursor-movement|insert-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3139" PostTypeId="1" CreationDate="2015-05-01T00:42:57.793" Score="1" ViewCount="198" Body="&lt;p&gt;I'm trying to make my own syntax highlighting for vim. I was following the instructions in &lt;a href=&quot;https://superuser.com/questions/844004/creating-a-simple-vim-syntax-highlighting&quot;&gt;here&lt;/a&gt; (first answer) but I need to set a group for import and pack, and another group for func, lib, group. How can I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vim on osx Yosemite.&lt;/p&gt;&#xA;" OwnerUserId="1806" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2015-05-01T18:54:23.583" Title="Vim-SyntaxHighlight: Custom Syntax Highlighting With Vim" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="4" ClosedDate="2015-05-01T18:54:15.563" ContentLicense="CC BY-SA 3.0" />
  <row Id="3140" PostTypeId="2" ParentId="3138" CreationDate="2015-05-01T00:43:15.537" Score="17" Body="&lt;p&gt;First you should understand that the cursor is between characters in insert mode and on a character in normal mode. This means that when you exit insert mode the cursor needs to move onto a character. (This is more noticeable in gvim or MacVim, where the default insert mode cursor is a pipe instead of a block)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you enter insert mode with &lt;code&gt;a&lt;/code&gt; then hitting &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; will place the cursor back exactly where it was. When vim exits insert mode, it needs to move the cursor back onto some character. However since appending is indistinguishable from inserting, one of them was chosen as a default. In this case moving left was chosen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you changed the default so that &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; went to the character on the right, people would be complaining that &lt;code&gt;a&amp;lt;esc&amp;gt;&lt;/code&gt; was moving the cursor to the right.&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2015-05-01T00:43:15.537" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3141" PostTypeId="2" ParentId="2626" CreationDate="2015-05-01T06:15:08.933" Score="2" Body="&lt;p&gt;I solved this problem myself by using &lt;a href=&quot;https://bitbucket.org/Haroogan&quot; rel=&quot;nofollow&quot;&gt;Haroogan vim&lt;/a&gt;. When I cd to h:\ in Haroogan vim it works, and it also successfully runs my vimrc files there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess this was either something strange about my work's network drive and/or a bug in vim that will eventually be resolved. Still, if you have this problem, I would try Haroogan vim.&lt;/p&gt;&#xA;" OwnerUserId="1438" LastActivityDate="2015-05-01T06:15:08.933" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3142" PostTypeId="1" AcceptedAnswerId="3143" CreationDate="2015-05-01T17:31:35.300" Score="3" ViewCount="143" Body="&lt;p&gt;Looked through the options through &lt;code&gt;:help Ag&lt;/code&gt; but didn't see anything. The closest I got was &lt;code&gt;lhandler&lt;/code&gt; but that's only controlling the new window that opens.&lt;/p&gt;&#xA;" OwnerUserId="488" LastActivityDate="2015-05-01T17:33:18.843" Title="Using the Ag plugin, how to not automatically open the first result?" Tags="|plugin-ag.vim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3143" PostTypeId="2" ParentId="3142" CreationDate="2015-05-01T17:33:18.843" Score="5" Body="&lt;p&gt;It was right there, if you append a &lt;code&gt;!&lt;/code&gt; to the command, it'll not open the first result. I'll map &lt;code&gt;:Ag&lt;/code&gt; to &lt;code&gt;:Ag!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Ag[!] [options] {pattern} [{directory}]                               *:Ag*&#xA;&#xA;    Search recursively in {directory} (which defaults to the current&#xA;    directory) for the {pattern}.  Behaves just like the |:grep| command, but&#xA;    will open the |Quickfix| window for you. If [!] is not given the first&#xA;    error is jumped to.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="488" LastActivityDate="2015-05-01T17:33:18.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3144" PostTypeId="2" ParentId="3128" CreationDate="2015-05-01T18:27:51.957" Score="5" Body="&lt;p&gt;I had a problem a while back with syntax folding PHP where typing &lt;code&gt;{&lt;/code&gt; would interfere with subsequent folds until I typed the corresponding closing &lt;code&gt;}&lt;/code&gt;. I found a suggestion somewhere (I think it was on the Vim Wiki) to temporarily set the foldmethod to manual while in insert mode. I don't know if this is &lt;em&gt;à propos&lt;/em&gt; enough to make an answer rather than a comment, but code in comments is discouraged and possibly you can adapt it for your circumstances. Here are the two relevant lines from my .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&amp;amp;foldmethod | setlocal foldmethod=manual | endif&#xA;autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &amp;amp;l:foldmethod=w:last_fdm | unlet w:last_fdm | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-05-01T18:27:51.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3145" PostTypeId="2" ParentId="3128" CreationDate="2015-05-01T18:28:51.363" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;perhaps there's a way to use a mapping to turn &lt;code&gt;fdm=manual&lt;/code&gt; before autocomplete or some such?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, this does that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-x&amp;gt; &amp;lt;Esc&amp;gt;:setlocal foldmethod=manual&amp;lt;CR&amp;gt;a&amp;lt;C-x&amp;gt;&#xA;autocmd CompleteDone * :setlocal foldmethod=expr&#xA;autocmd InsertLeave * :setlocal foldmethod=expr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We remap &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt; to first set the &lt;code&gt;foldmethod&lt;/code&gt; to &lt;code&gt;manual&lt;/code&gt; before calling &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt;, and with the &lt;code&gt;CompleteDone&lt;/code&gt; and &lt;code&gt;InsertLeave&lt;/code&gt; autocommands we reset it to &lt;code&gt;expr&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested this by pressing &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; 11 times; my &lt;code&gt;g:c&lt;/code&gt; values:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;After Vim startup: 202&lt;/li&gt;&#xA;&lt;li&gt;With this hack: 408&lt;/li&gt;&#xA;&lt;li&gt;Without this hack: 2130&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As I've said in the comments: this hack shouldn't be required. You mentioned &quot;relatively expensive &lt;code&gt;foldexpr&lt;/code&gt;s&quot;, I suspect that this is the &lt;em&gt;real&lt;/em&gt; problem; I can't be sure of course, because you didn't post your &lt;code&gt;foldexpr&lt;/code&gt;, but I think it's worth asking a new question about this (&lt;em&gt;&quot;How can I make this foldexpr faster?&quot;&lt;/em&gt;).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-05-01T18:28:51.363" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3146" PostTypeId="5" CreationDate="2015-05-01T18:32:44.520" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/rking/ag.vim&quot; rel=&quot;nofollow&quot;&gt;Homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-01T18:32:44.520" LastActivityDate="2015-05-01T18:32:44.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3147" PostTypeId="4" CreationDate="2015-05-01T18:32:44.520" Score="0" Body=" Run the_silver_searcher (also known as ag) from within Vim." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-01T18:32:44.520" LastActivityDate="2015-05-01T18:32:44.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3148" PostTypeId="1" AcceptedAnswerId="3149" CreationDate="2015-05-02T00:03:51.033" Score="16" ViewCount="9002" Body="&lt;p&gt;I noticed that when I use &lt;code&gt;:nohlsearch&lt;/code&gt; that it does not actually do the same thing as &lt;code&gt;:set nohlsearch&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, the &lt;code&gt;hlsearch&lt;/code&gt; setting is not actually switched off (which is what &lt;code&gt;:set hlsearch&lt;/code&gt;) accomplishes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To demonstrate what I mean: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set hlsearch&#xA;:nohlsearch&#xA;:echo &amp;amp;hlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This prints &lt;code&gt;1&lt;/code&gt; (&lt;strong&gt;hlsearch is still set!&lt;/strong&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set hlsearch&#xA;:set nohlsearch&#xA;:echo &amp;amp;hlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This prints &lt;code&gt;0&lt;/code&gt; because we switched hlsearch off using the standard way to switch a setting off in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm sort of wondering because there has to be some actual reason for the &lt;code&gt;:nohlsearch&lt;/code&gt; ex command to exist. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason why I care is that I now have a need in my vim scripting to test whether the search highlight is active, and since I was using &lt;code&gt;:nohlsearch&lt;/code&gt; instead of &quot;:set nohlsearch&quot; in my other scripting, my &lt;code&gt;&amp;amp;hlsearch&lt;/code&gt; test always returns &lt;code&gt;1&lt;/code&gt;. So I am wondering what I'm changing by no longer using the &lt;code&gt;nohlsearch&lt;/code&gt; ex command.&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2015-05-04T08:34:16.653" Title="What is the functional difference between :nohlsearch and :set nohlsearch?" Tags="|search|highlight|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3149" PostTypeId="2" ParentId="3148" CreationDate="2015-05-02T00:23:59.673" Score="17" Body="&lt;p&gt;From &lt;code&gt;:h :nohlsearch&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;                                                        :noh :nohlsearch&#xA;:noh[lsearch]           Stop the highlighting for the 'hlsearch' option.  It&#xA;                        is automatically turned back on when using a search&#xA;                        command, or setting the 'hlsearch' option.&#xA;                        This command doesn't work in an autocommand, because&#xA;                        the highlighting state is saved and restored when&#xA;                        executing autocommands autocmd-searchpat.&#xA;                        Same thing for when invoking a user function.&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key point is that it automatically turns the highlighting back on when you start a new search. &lt;code&gt;:set nohlsearch&lt;/code&gt; actually turns &lt;code&gt;hlsearch&lt;/code&gt; off, which means the next time you search for something no highlighting occurs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: Assume &lt;code&gt;hlsearch&lt;/code&gt; is on, If you are currently searching for &quot;hello&quot; in a buffer, all &quot;hello&quot;s will be highlighted . If you use &lt;code&gt;:nohlsearch&lt;/code&gt; nothing will be highlighted. But if you then search for &quot;world&quot;, all &quot;world&quot;s will be highlighted. If you had used &lt;code&gt;set nohlsearch&lt;/code&gt; instead &quot;world&quot; would not be highlighted.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also note that this command does basically nothing inside a user function. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NoHlsearch()&#xA;    nohlsearch&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;has no visible effect when run.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To see if hlsearch is actually active you want to check the variable &lt;code&gt;v:hlsearch&lt;/code&gt;. When &lt;code&gt;v:hlsearch = 0&lt;/code&gt; highlighting is off, and when &lt;code&gt;v:hlsearch = 1&lt;/code&gt; highlighting is on. You should probably make sure the &lt;code&gt;&amp;amp;hlsearch = 1&lt;/code&gt; before checking &lt;code&gt;v:hlsearch&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h v:hlsearch&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;                                        v:hlsearch hlsearch-variable&#xA;v:hlsearch      Variable that determines whether search highlighting is on.&#xA;                Makes sense only if 'hlsearch' is enabled which requires&#xA;                +extra_search. Setting this variable to zero acts the like&#xA;                :nohlsearch command, setting it to one acts like&#xA;                        let &amp;hlsearch = &amp;hlsearch&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2015-05-02T00:41:23.143" LastActivityDate="2015-05-02T00:41:23.143" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3151" PostTypeId="2" ParentId="2115" CreationDate="2015-05-02T22:24:47.760" Score="4" Body="&lt;p&gt;&lt;strong&gt;Update 2015-06-28&lt;/strong&gt;: I fixed a small bug, and &lt;a href=&quot;http://code.arp242.net/undofile_warn.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;released this as a&#xA;plugin&lt;/a&gt;. The plugin code is slightly&#xA;better, in that it warns again after moving the cursor; I recommend you use the&#xA;plugin.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The answer from &lt;a href=&quot;https://vi.stackexchange.com/a/2150/51&quot;&gt;superjer&lt;/a&gt; works great, but has the unfortunate side-effect that you can only undo changes from the last Vim session, and not &lt;em&gt;all&lt;/em&gt; previous Vim sessions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is because &lt;code&gt;wundo&lt;/code&gt; overwrites the undo file; it's not merged. As far as I know, there is no way to fix this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here's my alternative solution, it will show a big red warning message when you're undoing changes from the undo file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is similar to &lt;a href=&quot;https://vi.stackexchange.com/a/2797/51&quot;&gt;Ingo Karkat's answer&lt;/a&gt;, but it doesn't require an external plugin and has some subtle differences (displays warning instead of beep, doesn't require you to press &lt;code&gt;u&lt;/code&gt; twice).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note this &lt;em&gt;only&lt;/em&gt; modifies the &lt;code&gt;u&lt;/code&gt; and &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; binds, and &lt;em&gt;not&lt;/em&gt; the &lt;code&gt;U&lt;/code&gt;, &lt;code&gt;:undo&lt;/code&gt;, and &lt;code&gt;:redo&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use the undo file&#xA;set undofile&#xA;&#xA;&quot; When loading a file, store the curent undo sequence&#xA;augroup undo&#xA;    autocmd!&#xA;    autocmd BufReadPost,BufCreate,BufNewFile * let b:undo_saved = undotree()['seq_cur'] | let b:undo_warned = 0&#xA;augroup end &#xA;&#xA;&quot; Remap the keys&#xA;nnoremap u :call Undo()&amp;lt;Cr&amp;gt;u&#xA;nnoremap &amp;lt;C-r&amp;gt; &amp;lt;C-r&amp;gt;:call Redo()&amp;lt;Cr&amp;gt;&#xA;&#xA;&#xA;fun! Undo()&#xA;    &quot; Don't do anything if we can't modify the buffer or there's no filename&#xA;    if !&amp;amp;l:modifiable || expand('%') == '' | return | endif&#xA;&#xA;    &quot; Warn if the current undo sequence is lower (older) than whatever it was&#xA;    &quot; when opening the file&#xA;    if !b:undo_warned &amp;amp;&amp;amp; undotree()['seq_cur'] &amp;lt;= b:undo_saved&#xA;        let b:undo_warned = 1&#xA;        echohl ErrorMsg | echo 'WARNING! Using undofile!' | echohl None&#xA;        sleep 1&#xA;    endif&#xA;endfun&#xA;&#xA;fun! Redo()&#xA;    &quot; Don't do anything if we can't modify the buffer or there's no filename&#xA;    if !&amp;amp;l:modifiable || expand('%') == '' | return | endif&#xA;&#xA;    &quot; Reset the warning flag&#xA;    if &amp;amp;l:modifiable &amp;amp;&amp;amp; b:undo_warned &amp;amp;&amp;amp; undotree()['seq_cur'] &amp;gt;= b:undo_saved&#xA;        let b:undo_warned = 0&#xA;    endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-06-28T15:30:32.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3152" PostTypeId="2" ParentId="77" CreationDate="2015-05-02T22:33:40.003" Score="0" Body="&lt;p&gt;I wrote this and added it to my .vimrc to allow me to place .vimsettings files in projects and sub-projects.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Search for any .vimsettings files in the path to the file.&#xA;&quot; Source them if you find them.&#xA;function! ApplyLocalSettings(dirname)&#xA;    &quot; Don't try to walk a remote directory tree -- takes too long, too many&#xA;    &quot; what if's&#xA;    let l:netrwProtocol = strpart(a:dirname, 0, stridx(a:dirname, &quot;://&quot;))&#xA;    if l:netrwProtocol != &quot;&quot;&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; Convert windows paths to unix style (they still work)&#xA;    let l:curDir = substitute(a:dirname, &quot;\\&quot;, &quot;/&quot;, &quot;g&quot;)&#xA;    let l:parentDir = strpart(l:curDir, 0, strridx(l:curDir, &quot;/&quot;))&#xA;    if isdirectory(l:parentDir)&#xA;        &quot; Recursively walk to the top of the path&#xA;        call ApplyLocalSettings(l:parentDir)&#xA;    endif&#xA;&#xA;    &quot; Now walk back down the path and source .vimsettings as you find them. This&#xA;    &quot; way child directories can 'inherit' from their parents&#xA;    let l:settingsFile = a:dirname . &quot;/.vimsettings&quot;&#xA;    if filereadable(l:settingsFile)&#xA;        exec &quot;:source &quot; . l:settingsFile&#xA;    endif&#xA;endfunction&#xA;autocmd! BufEnter * call ApplyLocalSettings(expand(&quot;&amp;lt;afile&amp;gt;:p:h&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="897" LastActivityDate="2015-05-02T22:33:40.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3153" PostTypeId="1" AcceptedAnswerId="3161" CreationDate="2015-05-03T05:55:45.290" Score="7" ViewCount="11642" Body="&lt;p&gt;I'm using plugin &lt;a href=&quot;https://github.com/Chiel92/vim-autoformat&quot; rel=&quot;noreferrer&quot;&gt;Chiel92/vim-autoformat&lt;/a&gt; auto formatting xml files. So the default format program used for xml file is &lt;code&gt;tidy&lt;/code&gt;. The way it formats xml file is like below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;List id='list' items='{/sss}' mode='{device&amp;amp;gt;/listMode}' noDataText='{i18n&amp;amp;gt;masterListNoDataText}' select='onSelect' growing='true' growingScrollToLoad='true'&amp;gt;&#xA;    &amp;lt;items&amp;gt;&#xA;        &amp;lt;ObjectListItem type='{device&amp;amp;gt;/listItemType}' press='onSelect' title='{Name}' number='{ path: &quot;Price&quot;, formatter: &quot;exp.ind.cli.util.Formatter.currencyValue&quot; }' numberUnit='USD'&amp;gt;&amp;lt;/ObjectListItem&amp;gt;&#xA;    &amp;lt;/items&amp;gt;&#xA;&amp;lt;/List&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see the attributes of the tags are on one line, and it can last very long even goes out of the screen. What I want is all the attributes to be formatted on separate lines( vertically aligned ).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;List id='list' &#xA;    items='{/sss}' &#xA;    mode='{device&amp;amp;gt;/listMode}' &#xA;    noDataText='{i18n&amp;amp;gt;masterListNoDataText}' &#xA;    select='onSelect' &#xA;    growing='true' &#xA;    growingScrollToLoad='true'&amp;gt;&#xA;&#xA;    &amp;lt;items&amp;gt;&#xA;        &amp;lt;ObjectListItem type='{device&amp;amp;gt;/listItemType}' &#xA;                    press='onSelect' &#xA;                    title='{Name}' &#xA;                    number='{ path: &quot;Price&quot;, formatter: &quot;exp.ind.cli.util.Formatter.currencyValue&quot; }' &#xA;                    numberUnit='USD'&amp;gt;&#xA;        &amp;lt;/ObjectListItem&amp;gt;&#xA;    &amp;lt;/items&amp;gt;&#xA;&amp;lt;/List&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think it makes easier to spot the attributes and improve the readability of the xml file. Is there any way to achieve this? &lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="51" LastEditDate="2015-05-04T01:05:34.020" LastActivityDate="2016-04-08T15:42:13.973" Title="How to format xml or html's attributes into multiple lines instead of lining up on one line?" Tags="|formatting|filetype-xml|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3154" PostTypeId="1" AcceptedAnswerId="3155" CreationDate="2015-05-03T10:27:36.013" Score="-3" ViewCount="478" Body="&lt;p&gt;&lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; works ok for me, number is incremented. But &lt;code&gt;&amp;lt;C-z&amp;gt;&lt;/code&gt; does not decrement. Instead gvim window is minimized to be background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I disable that &lt;code&gt;&amp;lt;C-z&amp;gt;&lt;/code&gt; behaviour and have it increment numbers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Gvim 7.4 on windows 7 64its and &lt;em&gt;not&lt;/em&gt; using mswin.vim. I just source a copy of it with most stuff disabled, only minimal mappings. &lt;code&gt;&amp;lt;C-z&amp;gt;&lt;/code&gt; does not exist in my custom mswin.vim.&lt;/p&gt;&#xA;" OwnerUserId="590" LastEditorUserId="205" LastEditDate="2015-05-03T12:07:36.810" LastActivityDate="2015-05-03T13:15:07.123" Title="&lt;C-z&gt; on gvim (windows) hides the window instead of decrementing the number on cursor" Tags="|gvim|" AnswerCount="1" CommentCount="2" ClosedDate="2015-06-29T14:18:39.923" ContentLicense="CC BY-SA 3.0" />
  <row Id="3155" PostTypeId="2" ParentId="3154" CreationDate="2015-05-03T11:16:09.780" Score="7" Body="&lt;p&gt;Decrement is &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt;, not &lt;code&gt;&amp;lt;C-z&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#v_CTRL-Z&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help CTRL-Z&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-Z                  Suspend Vim, like &quot;:stop&quot;.&#xA;                        Works in Normal and in Visual mode.  In Insert and&#xA;                        Command-line mode, the CTRL-Z is inserted as a normal&#xA;                        character.  In Visual mode Vim goes back to Normal&#xA;                        mode.&#xA;                        Note: if CTRL-Z undoes a change see mswin.vim.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this works as expected ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to make &lt;code&gt;&amp;lt;C-z&amp;gt;&lt;/code&gt; behave as &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt;, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-z&amp;gt; &amp;lt;C-x&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-03T13:15:07.123" LastActivityDate="2015-05-03T13:15:07.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3156" PostTypeId="1" AcceptedAnswerId="3157" CreationDate="2015-05-03T15:54:37.813" Score="18" ViewCount="1602" Body="&lt;p&gt;I recently saw a substitute command where the author had the &lt;code&gt;/&lt;/code&gt; replaced by a &lt;code&gt;!&lt;/code&gt; like this: &lt;code&gt;:s!abc!ABC!g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to find some documentation on this usage but I couldn't find anything relevant. So I tried to experiment by myself and once again I couldn't figure out the real difference between the two signs. Here's what I found:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It's not possible to mix &lt;code&gt;!&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt; in a command. For example &lt;code&gt;:s!abc/ABC&lt;/code&gt; fails.&lt;/li&gt;&#xA;&lt;li&gt;It may be useful to use &lt;code&gt;!&lt;/code&gt; to avoid escaping a &lt;code&gt;/&lt;/code&gt;in a pattern. For example if I want to replace &lt;code&gt;&amp;lt;/&lt;/code&gt; with &lt;code&gt;%&lt;/code&gt; I can use &lt;code&gt;:%s!&amp;lt;/!%!g&lt;/code&gt; instead of &lt;code&gt;:%s/&amp;lt;\//%/g&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;li&gt;It seems that in some case some regex won't work with &lt;code&gt;/&lt;/code&gt; and works properly with &lt;code&gt;!&lt;/code&gt; but as I'm not really a regex expert i'm not sure of that.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So my question is simple: What is the advantage of using &lt;code&gt;!&lt;/code&gt; in a substitute command and when should I decide to use it instead of &lt;code&gt;/&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-09-01T21:48:10.147" LastActivityDate="2021-07-22T02:28:47.620" Title="What does it mean to replace slashes (/) by exclamation marks (!) in a substitute command?" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3157" PostTypeId="2" ParentId="3156" CreationDate="2015-05-03T16:32:01.363" Score="27" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.org/repeat.txt.html#E148&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :global&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Instead of the '/' which surrounds the &lt;code&gt;{pattern}&lt;/code&gt;, you can use any other&#xA;single byte character, but not an alphabetic character, '', '&amp;quot;' or '|'.&#xA;This is useful if you want to include a '/' in the search pattern or&#xA;replacement string.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://vimhelp.org/change.txt.html#pattern-delimiter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help pattern-delimiter&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As you already devised from your experimentation, this is to prevent the so-called &amp;quot;&lt;a href=&quot;http://en.wikipedia.org/wiki/Leaning_toothpick_syndrome&quot; rel=&quot;nofollow noreferrer&quot;&gt;leaning toothpick syndrome&lt;/a&gt;&amp;quot;. Consider this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\/home\/martin\/test/\/home\/jake\/x/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;versus:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%s!/home/martin/test!/home/jake/x!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The second form is obviously a lot more readable. I prefer to use &lt;code&gt;!&lt;/code&gt; or &lt;code&gt;|&lt;/code&gt; for this as it's the most similar to &lt;code&gt;/&lt;/code&gt;, but other prefer &lt;code&gt;@&lt;/code&gt;, &lt;code&gt;#&lt;/code&gt;, &lt;code&gt;^&lt;/code&gt;, or something else.&lt;/p&gt;&#xA;&lt;p&gt;This is the only reason you can change the delimiter; to make it more readable for us humans. The computer doesn't care.&lt;/p&gt;&#xA;&lt;p&gt;Some other programs are even more flexible by the way, in GNU sed for example you can use &lt;code&gt;x&lt;/code&gt; as delimiter if you wanted. &lt;code&gt;sed sxaxbxg file&lt;/code&gt; is the same as &lt;code&gt;sed s/a/b/g file&lt;/code&gt;, although I don't think that's especially readable.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2021-07-22T02:28:47.620" LastActivityDate="2021-07-22T02:28:47.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3158" PostTypeId="2" ParentId="2761" CreationDate="2015-05-03T23:24:05.200" Score="7" Body="&lt;p&gt;Based on &lt;a href=&quot;https://vi.stackexchange.com/a/2770/51&quot;&gt;Rich's answer here&lt;/a&gt; with some differences:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It will highlight the match current indefinitely, I found the blinking annoying, and there's a small 0.1s delay before any other keypress is registered.&lt;/li&gt;&#xA;&lt;li&gt;It incorporates the answer from &lt;a href=&quot;https://vi.stackexchange.com/a/2366/51&quot;&gt;How can I get ‘n’ to go forward even if I started searching with ‘?’ or ‘#’?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can clear the highlighting with &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! SearchHighlight()&#xA;    silent! call matchdelete(b:ring)&#xA;    let b:ring = matchadd('ErrorMsg', '\c\%#' . @/, 101)&#xA;endfun&#xA;&#xA;fun! SearchNext()&#xA;    try&#xA;        execute 'normal! ' . 'Nn'[v:searchforward]&#xA;    catch /E385:/&#xA;        echohl ErrorMsg | echo &quot;E385: search hit BOTTOM without match for: &quot; . @/ | echohl None&#xA;    endtry&#xA;    call SearchHighlight()&#xA;endfun&#xA;&#xA;fun! SearchPrev()&#xA;    try&#xA;        execute 'normal! ' . 'nN'[v:searchforward]&#xA;    catch /E384:/&#xA;        echohl ErrorMsg | echo &quot;E384: search hit TOP without match for: &quot; . @/ | echohl None&#xA;    endtry&#xA;    call SearchHighlight()&#xA;endfun&#xA;&#xA;&quot; Highlight entry&#xA;nnoremap &amp;lt;silent&amp;gt; n :call SearchNext()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; N :call SearchPrev()&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Use &amp;lt;C-L&amp;gt; to clear some highlighting&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-L&amp;gt; :silent! call matchdelete(b:ring)&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;:set nolist nospell&amp;lt;CR&amp;gt;&amp;lt;C-L&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-05-06T10:03:36.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3159" PostTypeId="2" ParentId="2817" CreationDate="2015-05-03T23:55:12.893" Score="0" Body="&lt;p&gt;With the &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow&quot;&gt;vim-textobj-user&lt;/a&gt; plugin, it is very easy to define your own motions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You didn't mention which language you're using, but a naive example for C++ might be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call textobj#user#plugin('cpp', {&#xA;    \   'code': {&#xA;        \     'pattern': ['^class .*\n{', '^}'],&#xA;        \     'select-a': 'ac',&#xA;        \     'select-i': 'ic',&#xA;    \ },&#xA;\})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;vac&lt;/code&gt; to select &quot;A class&quot;, or &lt;code&gt;vic&lt;/code&gt; to select the inner class; or &lt;code&gt;dic&lt;/code&gt; to delete the entire inner class, &lt;code&gt;yic&lt;/code&gt; to yank it, etc.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-05-03T23:55:12.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3160" PostTypeId="2" ParentId="2912" CreationDate="2015-05-04T00:16:50.930" Score="6" Body="&lt;p&gt;This seems to work quite well, and does fairly sane things when using &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; on&#xA;a 9 (95 becomes 105), or using &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt; on a 0 (105 becomes 95):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap g&amp;lt;C-a&amp;gt; :call search('\d', 'c')&amp;lt;CR&amp;gt;a &amp;lt;Esc&amp;gt;h&amp;lt;C-a&amp;gt;lxh&#xA;nnoremap g&amp;lt;C-x&amp;gt; :call search('\d', 'c')&amp;lt;CR&amp;gt;a &amp;lt;Esc&amp;gt;h&amp;lt;C-x&amp;gt;lxh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First, we search for any digit, &lt;code&gt;search()&lt;/code&gt; has the advantage of not resetting &lt;code&gt;@/&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a &amp;lt;Esc&amp;gt;h&lt;/code&gt; - Go to insert mode, add a space after the digit, and go to the left so that the cursor is on top of the digit.&lt;/li&gt;&#xA;&lt;li&gt;We can now use &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;We use &lt;code&gt;lxh&lt;/code&gt; to remove the space we added.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've mapped this to &lt;code&gt;g&amp;lt;C-a&amp;gt;&lt;/code&gt; and &lt;code&gt;g&amp;lt;C-x&amp;gt;&lt;/code&gt;, so you can still call the original.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A slightly different version which will only search for numbers on the current&#xA;line (but will leave a dangling space if there's no number on the current line):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap g&amp;lt;C-a&amp;gt; :call search('\d', 'c', line('.'))&amp;lt;CR&amp;gt;a &amp;lt;Esc&amp;gt;h&amp;lt;C-a&amp;gt;lxh&#xA;nnoremap g&amp;lt;C-x&amp;gt; :call search('\d', 'c', line('.'))&amp;lt;CR&amp;gt;a &amp;lt;Esc&amp;gt;h&amp;lt;C-x&amp;gt;lxh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And here's another version which uses the same concept as before, but also adds&#xA;a space &lt;em&gt;before&lt;/em&gt; the digit. This will make &lt;code&gt;g&amp;lt;C-a&amp;gt;&lt;/code&gt; ignore any munis sign before&#xA;the number (by default, &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; on &lt;code&gt;-42&lt;/code&gt; will 'increment' it to &lt;code&gt;-41&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also accepts a count, so that &lt;code&gt;5g&amp;lt;C-a&amp;gt;&lt;/code&gt; will increment the number by 5:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Increment(dir, count)&#xA;    &quot; No number on the current line&#xA;    if !search('\d', 'c', getline('.'))&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; Store cursor position&#xA;    let l:save_pos = getpos('.')&#xA;&#xA;    &quot; Add spaces around the number&#xA;    s/\%#\d/ \0 /&#xA;    call setpos('.', l:save_pos)&#xA;    normal! l&#xA;&#xA;    &quot; Increment or decrement the number&#xA;    if a:dir == 'prev'&#xA;        execute &quot;normal! &quot; . repeat(&quot;\&amp;lt;C-x&amp;gt;&quot;), a:count&#xA;    else&#xA;        execute &quot;normal! &quot; . repeat(&quot;\&amp;lt;C-a&amp;gt;&quot;, a:count)&#xA;    endif&#xA;&#xA;    &quot; Remove the spaces&#xA;    s/\v (\d{-})%#(\d) /\1\2/&#xA;&#xA;    &quot; Restore cursor position&#xA;    call setpos('.', l:save_pos)&#xA;endfun&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; g&amp;lt;C-a&amp;gt; :&amp;lt;C-u&amp;gt;call Increment('next', v:count1)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; g&amp;lt;C-x&amp;gt; :&amp;lt;C-u&amp;gt;call Increment('prev', v:count1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-06-29T16:54:38.413" LastActivityDate="2015-06-29T16:54:38.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3161" PostTypeId="2" ParentId="3153" CreationDate="2015-05-04T00:54:19.857" Score="8" Body="&lt;p&gt;This should &lt;em&gt;almost&lt;/em&gt; work, it aligns the attributes slightly different than your example, but it's probably &quot;close enough&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType xml let g:formatprg_args_expr_xml .= '.&quot; --indent-attributes 1&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will format it like as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;List id='list'&#xA;      items='{/sss}'&#xA;      mode='{device&amp;amp;gt;/listMode}'&#xA;      noDataText='{i18n&amp;amp;gt;masterListNoDataText}'&#xA;      select='onSelect'&#xA;      growing='true'&#xA;      growingScrollToLoad='true'&amp;gt;&#xA;    &amp;lt;items&amp;gt;&#xA;        &amp;lt;ObjectListItem type='{device&amp;amp;gt;/listItemType}'&#xA;                        press='onSelect'&#xA;                        title='{Name}'&#xA;                        number='{ path: &quot;Price&quot;, formatter: &quot;exp.ind.cli.util.Formatter.currencyValue&quot; }'&#xA;                        numberUnit='USD'&amp;gt;&amp;lt;/ObjectListItem&amp;gt;&#xA;    &amp;lt;/items&amp;gt;&#xA;&amp;lt;/List&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, figuring this out was actually quite easy :-) Here's what I did:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I looked at the &lt;a href=&quot;https://github.com/Chiel92/vim-autoformat&quot; rel=&quot;noreferrer&quot;&gt;vim-autoformat&lt;/a&gt; homepage to see how it formatted XML files, and it says: &lt;em&gt;&quot;&lt;code&gt;tidy&lt;/code&gt; for XHTML and XML&quot;&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;So, we need to see if the &lt;code&gt;tidy&lt;/code&gt; tool supports formatting the attributes like you want. After installing &lt;code&gt;tidy&lt;/code&gt;, I ran &lt;code&gt;tidy -h&lt;/code&gt; to see the help for this program. This told me that &lt;code&gt;-help-config&lt;/code&gt; lists all configuration options, so I ran that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ tidy -help-config&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gave me a very long list, so I put the output in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ tidy -help-config | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Since we want to do something with &lt;em&gt;attributes&lt;/em&gt;, I used &lt;code&gt;/attr&lt;/code&gt; to search for that, and after pressing &lt;code&gt;n&lt;/code&gt; once I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;indent-attributes           Boolean    y/n, yes/no, t/f, true/false, 1/0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have no idea what this does, but it looks like it might be what we want?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Let's try adding this option. I went back to the vim-autoformat homepage, and noticed the &lt;em&gt;&quot;How can I change the behaviour of formatters, or add one myself?&quot;&lt;/em&gt; section, which is how I figured out how to add the above option (this is the only part that required some effort, since the section isn't brilliantly written).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-04T01:03:46.473" LastActivityDate="2015-05-04T01:03:46.473" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3162" PostTypeId="2" ParentId="3148" CreationDate="2015-05-04T08:34:16.653" Score="2" Body="&lt;p&gt;Does your script require that the current state of highlighting be known?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To turn off &lt;code&gt;hlsearch&lt;/code&gt; for the current search only, I use &lt;code&gt;Ctrl-l&lt;/code&gt;, with this in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-l&amp;gt; :&amp;lt;C-u&amp;gt;nohlsearch&amp;lt;CR&amp;gt;&amp;lt;C-l&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Search highlighting returns with the next search when using the above command. &lt;code&gt;Ctrl-l&lt;/code&gt; is convenient because it's normal use is to clear and redraw the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To change the search highlighting state on or off persistently, I use F3 as my toggle:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F3&amp;gt; :set hlsearch! hlsearch?&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1967" LastActivityDate="2015-05-04T08:34:16.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3163" PostTypeId="1" CreationDate="2015-05-04T10:28:13.703" Score="3" ViewCount="1753" Body="&lt;p&gt;I am using AG to simplifying and improve the search in my Vim. I remapped K to search for the current selected word as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if executable('ag')&#xA;  set grepprg=ag\ --nogroup\ --nocolor&#xA;  command -nargs=+ -complete=file -bar Ag silent! grep! &amp;lt;args&amp;gt;|cwindow|redraw!&#xA;&#xA;  nnoremap K :grep! &amp;quot;\b&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;\b&amp;quot;&amp;lt;CR&amp;gt;:cw&amp;lt;CR&amp;gt;&#xA;  nnoremap ff :Ag&amp;lt;SPACE&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However this doesn't work as expected. When I hit the keyboard K, a small windows opens up in the bottom, showing the following message:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/iRtXN.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, I hit &lt;kbd&gt;Enter&lt;/kbd&gt; and it goes to the results. How can I avoid this window message and go directly to the result page?&lt;/p&gt;&#xA;" OwnerUserId="1620" LastEditorUserId="23502" LastEditDate="2022-11-02T09:00:49.047" LastActivityDate="2022-11-02T09:00:49.047" Title="How to setup AG (the silver searcher) in Vim?" Tags="|key-bindings|external-command|search|the-silver-searcher|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3164" PostTypeId="1" CreationDate="2015-05-04T12:24:02.673" Score="5" ViewCount="508" Body="&lt;p&gt;At first I am going try to explain you &quot;order of opening&quot;. For example, if I'll open files in this order:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1_file.c&#xA;2_file.c&#xA;3_file.c&#xA;4_file.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:ls&lt;/code&gt; command will give me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls&#xA;  1      &quot;1_file.c&quot;                     line 1&#xA;  2      &quot;2_file.c&quot;                     line 1&#xA;  3 #    &quot;3_file.c&quot;                     line 1&#xA;  4 %a   &quot;4_file.c&quot;                     line 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After if I'll jump into buffers &lt;code&gt;:b3&lt;/code&gt;, &lt;code&gt;:b2&lt;/code&gt;, &lt;code&gt;:b4&lt;/code&gt;, then if I'll invoke &lt;code&gt;:bp&lt;/code&gt; command then I would go in the buffer 3 or if i'll invoke (from buffer 4) &lt;code&gt;:bn&lt;/code&gt; I would go in the buffer 1. So I'll jump between buffers in order of opening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I want to simple method to jump between files in &quot;order of accessing&quot;, for example from previous example if I'll jump into buffers &lt;code&gt;:b3&lt;/code&gt;, &lt;code&gt;:b2&lt;/code&gt;, &lt;code&gt;:b4&lt;/code&gt;. I want to jump back like: &lt;code&gt;buffer 2&lt;/code&gt;, &lt;code&gt;buffer 3&lt;/code&gt;, and after jump forward like &lt;code&gt;buffer 2&lt;/code&gt;, &lt;code&gt;buffer 4&lt;/code&gt;. I hope you guys understand what I mean. Is there native command in vim to achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was searching on the Internet about this facility, but no luck. There are commands for jumping in history with &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;O&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;I&lt;/kbd&gt; but it cause jumping inside of same file too.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="51" LastEditDate="2015-05-06T06:52:18.783" LastActivityDate="2015-05-15T15:18:44.443" Title="Is it possible switch buffers in order of accessing but not opening?" Tags="|buffers|jumplist|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3165" PostTypeId="1" AcceptedAnswerId="3169" CreationDate="2015-05-04T12:39:55.287" Score="15" ViewCount="1668" Body="&lt;p&gt;is it possible to edit more than one word simultaneously, which are on the same line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's say I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Spam and Eggs is all you need for a healthy breakfast&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I would like to change the line to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;organic_Spam and organic_Eggs is all you need for a healthy breakfast&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to highlight &quot;Spam&quot; and &quot;Eggs&quot; and prepend &quot;organic_&quot; simultaneously to &quot;Spam&quot; and &quot;Eggs&quot;. A bit like using visual block to write simultaneously on different lines, but here write stuff on the same line. I saw a colleague doing this with Sublime Text, and tried googling but to no avail. &lt;/p&gt;&#xA;" OwnerUserId="1968" LastEditorUserId="500" LastEditDate="2015-05-04T16:28:08.180" LastActivityDate="2015-05-05T16:37:04.617" Title="Edit different words simultaneously, one the same line like in Sublime Text with multiplie selections" Tags="|cursor-movement|insert-mode|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3166" PostTypeId="2" ParentId="3165" CreationDate="2015-05-04T12:52:42.170" Score="21" Body="&lt;p&gt;In Vim there are no multi-cursors like in Sublime Text (but there are some plugins as I remember). But it seeems not so important stuff for vim because there is another way to achieve this. For example you have this line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Spam and Eggs is all you need for a healthy breakfast&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would doing something like this: place cursor in normal mode on the first letter of the &lt;code&gt;Spam&lt;/code&gt; and enter &lt;kbd&gt;i&lt;/kbd&gt;&lt;code&gt;organic_&lt;/code&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;, then two times &lt;kbd&gt;w&lt;/kbd&gt; to jump on the &lt;code&gt;Eggs&lt;/code&gt; and press &lt;kbd&gt;.&lt;/kbd&gt; (dot) to repeat last action. So for me this is a lot more productive than in Sumlime Text but maybe not so fancy and intuitively though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway there is somekind of preprocessing stuff for this action in both editors, in Sublime Text is a selecting places for new multi-cursor position with some hotkey, and after all of this you can edit words simultaneously. In Vim this kind of &quot;preprocessing&quot; happens actually at time of editing of the line, I mean all of this &lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;.&lt;/kbd&gt; stuff.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2015-05-05T16:37:04.617" LastActivityDate="2015-05-05T16:37:04.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3167" PostTypeId="2" ParentId="3164" CreationDate="2015-05-04T13:18:06.237" Score="3" Body="&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2695&quot; rel=&quot;nofollow&quot;&gt;EnhancedJumps plugin&lt;/a&gt; provides (among other variants) &lt;code&gt;&amp;lt;Leader&amp;gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Leader&amp;gt;&amp;lt;C-I&amp;gt;&lt;/code&gt; commands that work like built-in &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt;, but skip over jumps inside the same buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally use the old &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=207&quot; rel=&quot;nofollow&quot;&gt;MruMenu plugin&lt;/a&gt; for buffer recall. It uses the menu (in GVIM), is file-based instead of showing the current buffers, and limits to N entries, though.&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2015-05-04T14:44:06.683" LastActivityDate="2015-05-04T14:44:06.683" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3168" PostTypeId="2" ParentId="3163" CreationDate="2015-05-04T13:45:29.237" Score="3" Body="&lt;p&gt;I use silver searcher too and actually I ended up with this binding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap K :silent grep! &quot;\b\s?&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;\b&quot;&amp;lt;CR&amp;gt;:cw&amp;lt;CR&amp;gt;:redr!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See at &lt;code&gt;:redr!&lt;/code&gt; command at the end it cause to redrawing whole screen because sometime after opening results in terminal window, vim doesn't redraw whole screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And also there is &lt;code&gt;\s?&lt;/code&gt; in regular expression. Without it vim would delete first &lt;code&gt;b&lt;/code&gt; letter of the word.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2015-05-23T17:23:14.770" LastActivityDate="2015-05-23T17:23:14.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3169" PostTypeId="2" ParentId="3165" CreationDate="2015-05-04T13:53:59.260" Score="18" Body="&lt;p&gt;I agree with Alexander here. In day to day editing I would probably use the &lt;kbd&gt;.&lt;/kbd&gt; command as well, but if you want to execute just one command I would use the substitute command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/S\|E/organic_&amp;amp;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;whereas the &lt;code&gt;&amp;amp;&lt;/code&gt; is the matched pattern from &lt;code&gt;/S\|E/&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="376" LastEditorUserId="376" LastEditDate="2015-05-04T16:14:43.383" LastActivityDate="2015-05-04T16:14:43.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3170" PostTypeId="1" CreationDate="2015-05-04T17:50:21.940" Score="6" ViewCount="434" Body="&lt;p&gt;I have been using Vim for coding LaTeX files for some time now, but did not like vim-latex at first sight and therefore never used it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the the project-wide(!) ref/cite completion of vim-latex seems to pretty awesome. Long story short: I would like to use this single feature, but nothing else. No  magic, no (other) mappings, nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to do that? (In a perfect world I would also like to be able to add more and more features of vim-latex as I like, just not all of them at once.    I am a creature of habit.)&lt;/p&gt;&#xA;" OwnerUserId="1955" LastActivityDate="2015-05-04T21:16:48.070" Title="Use only some features (ref/cite completion) of vim-latex" Tags="|plugin-vim-latex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3171" PostTypeId="2" ParentId="3170" CreationDate="2015-05-04T21:16:48.070" Score="6" Body="&lt;p&gt;I can not answer your question regarding vim-latex (aka LaTeX-Suite), however, I can recommend two plugins that provide good label and bibliography completion:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;vimtex&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Vimtex is a simple and lightweight LaTeX plugin for vim that is initially based on LaTeX-Box. The code is now very much diverged from LaTeX-Box, and the plugin is IMHO better maintained and more actively developed. &lt;em&gt;Disclaimer: vimtex is written and maintained by me.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for your question, vimtex supports a modular approach where you may enable/disable functionality that you want to use. If you only want the completion functionality, then you may achieve this in &lt;a href=&quot;https://github.com/lervag/vimtex&quot;&gt;vimtex&lt;/a&gt; by disabling all the other functionalities. Place the following in your &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vimtex_fold_enabled = 0&#xA;let g:vimtex_indent_enabled = 0&#xA;let g:vimtex_indent_bib_enabled = 0&#xA;let g:vimtex_labels_enabled = 0&#xA;let g:vimtex_toc_enabled = 0&#xA;let g:vimtex_mappings_enabled = 0&#xA;let g:vimtex_motion_enabled = 0&#xA;let g:vimtex_latexmk_enabled = 0&#xA;let g:vimtex_view_enabled = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can disable vimtex completely and then only enable the completion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vimtex_enabled = 0&#xA;call vimtex#complete#init(0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;LaTeX-Box&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;https://github.com/LaTeX-Box-Team/LaTeX-Box&quot;&gt;LaTeX-Box&lt;/a&gt; one can not selectively enable or disable functionality (I believe), but it is a simple and lightweight plugin with good completion functionality.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-05-04T21:16:48.070" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3173" PostTypeId="2" ParentId="3165" CreationDate="2015-05-05T09:58:11.107" Score="3" Body="&lt;p&gt;If you &lt;em&gt;really&lt;/em&gt; want multiple cursor support like Sublime, you can use this plugin: &lt;a href=&quot;https://github.com/terryma/vim-multiple-cursors&quot; rel=&quot;nofollow&quot;&gt;https://github.com/terryma/vim-multiple-cursors&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not the &lt;em&gt;vim way&lt;/em&gt;, but I use it often and it works well&lt;/p&gt;&#xA;" OwnerUserId="248" LastActivityDate="2015-05-05T09:58:11.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3174" PostTypeId="1" CreationDate="2015-05-05T10:54:50.893" Score="9" ViewCount="466" Body="&lt;p&gt;When I move lines with &lt;code&gt;m&lt;/code&gt; (e.g. &lt;code&gt;:m+1&lt;/code&gt;) all my folds are closed. I can then open the folding with &lt;code&gt;zv&lt;/code&gt; again and the cursor will be at the position I moved to.&#xA;I use folding with &lt;code&gt;{{{ }}}&lt;/code&gt; marks and have &lt;code&gt;set foldmethod=marker&lt;/code&gt; in my .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I prevent vim from closing folds when moving lines?&lt;/p&gt;&#xA;" OwnerUserId="1982" LastActivityDate="2016-12-06T09:40:54.763" Title="Problem: Moving lines vertically closes folds" Tags="|folding|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="3175" PostTypeId="1" AcceptedAnswerId="3176" CreationDate="2015-05-05T14:01:43.473" Score="20" ViewCount="14236" Body="&lt;p&gt;I tried today to perform a search on every files of a project.&#xA;I use &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ctrl-P&lt;/a&gt; and search on lines like so : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wCgWm.png&quot; alt=&quot;screenshot&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the result of the search is only on the previously opened file. Here I open only &lt;code&gt;main.php&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know a way to search on all files without having to open them one by one ?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="11068" LastEditDate="2020-05-06T08:05:04.067" LastActivityDate="2020-05-06T08:05:04.067" Title="How to use Ctrl-P to interactively search file contents for all files in a project?" Tags="|search|plugin-ctrlp|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3176" PostTypeId="2" ParentId="3175" CreationDate="2015-05-05T14:16:03.320" Score="14" Body="&lt;p&gt;&lt;code&gt;:CtrlPLine&lt;/code&gt; is actually supposed to work on listed buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;em&gt;absolutely&lt;/em&gt; want to use that feature on every file in your project, you could add them to the argument list (and thus the buffer list) with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argadd **/*.php&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that doesn't sound like a very good idea for performance reasons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:vimgrep&lt;/code&gt; or &lt;code&gt;:grep&lt;/code&gt; sounds a lot better to me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vim foo **/*.php&#xA;:cw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You lose the &quot;fuzziness&quot; of CtrlP, obviously, but you get reliability and flexibility in return.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :argadd&#xA;:help :vimgrep&#xA;:help :grep&#xA;:help :cwindow&#xA;:help quickfix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-05-06T07:40:25.273" LastActivityDate="2015-05-06T07:40:25.273" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3177" PostTypeId="1" AcceptedAnswerId="3178" CreationDate="2015-05-05T18:08:05.637" Score="11" ViewCount="1886" Body="&lt;p&gt;I have an ftplugin under &lt;code&gt;&amp;amp;runtimepath/ftplugin/c.vim&lt;/code&gt; which sets all my preferred options for c files.  However, I would also like to use the same settings for &lt;code&gt;cpp&lt;/code&gt; files.  I could just copy the settings over, but that seems redundant.  Is there a way of loading an ftplugin for more than one filetype?&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2020-05-01T14:22:00.627" Title="Use single ftplugin for more than one filetype" Tags="|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3178" PostTypeId="2" ParentId="3177" CreationDate="2015-05-05T18:20:42.950" Score="11" Body="&lt;p&gt;The default ftplugin (&lt;code&gt;/usr/share/vim/vim74/ftplugin/cpp.vim&lt;/code&gt; on my system) should already do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Only do this when not done yet for this buffer&#xA;if exists(&quot;b:did_ftplugin&quot;)&#xA;  finish&#xA;endif&#xA;&#xA;&quot; Behaves just like C&#xA;runtime! ftplugin/c.vim ftplugin/c_*.vim ftplugin/c/*.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;runtime&lt;/code&gt; should be relative to the &lt;code&gt;runtimepath&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There can be multiple &lt;code&gt;{file}&lt;/code&gt; arguments, separated by spaces.  Each &lt;code&gt;{file}&lt;/code&gt; is&#xA;  searched for in the first directory from &lt;code&gt;'runtimepath'&lt;/code&gt;, then in the second&#xA;  directory, etc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I create a &lt;code&gt;~/.vim/ftplugin/c.vim&lt;/code&gt;, this also gets executed for C++ files without doing anything!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have this file in your Vim version,, you can create a new &lt;code&gt;~/.vim/ftplugin/cpp.vim&lt;/code&gt; file with the &lt;code&gt;runtime!&lt;/code&gt; statement.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Or, if you're on a UNIX-y system you can use a symlink:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ln -s ~/.vim/ftplugin/c.vim ~/.vim/ftplugin/cpp.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-05T18:26:36.880" LastActivityDate="2015-05-05T18:26:36.880" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3179" PostTypeId="1" AcceptedAnswerId="3249" CreationDate="2015-05-06T09:32:15.163" Score="1" ViewCount="465" Body="&lt;p&gt;Using gvim on Microsoft Windows, I find myself unable to use some control keys. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I cannot navigate the &lt;code&gt;:help&lt;/code&gt; topics using &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;]&lt;/kbd&gt;. Likewise, I cannot escape insert mode using &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do anyone know the reason for this behaviour and an possible way to have force the right behaviour?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: the issue seems related to the use of the &quot;United Kingdom (extended)&quot; keyboard layout. &lt;/p&gt;&#xA;" OwnerUserId="1057" LastEditorUserId="51" LastEditDate="2015-05-12T23:24:30.493" LastActivityDate="2015-05-12T23:58:06.457" Title="Special control keys in windows 7 don't work with the 'extended english keyboard (UK)' layout" Tags="|key-bindings|gvim|microsoft-windows|keyboard-layout|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3180" PostTypeId="1" AcceptedAnswerId="3181" CreationDate="2015-05-06T18:30:44.720" Score="8" ViewCount="363" Body="&lt;p&gt;I have the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;silent&amp;gt; &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;:echo 'Enter pressed'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works as expected; the &lt;code&gt;:echo&lt;/code&gt; command runs every time I press &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in the command line. This is done when entering the commandline with &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;?&lt;/code&gt;, &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt;= (in insert), etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to get the &lt;code&gt;:echo&lt;/code&gt; command to run &lt;em&gt;only&lt;/em&gt; if I enter the commandline with &lt;code&gt;/&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-05-06T18:54:42.707" Title="Run a cmap only when searching" Tags="|key-bindings|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3181" PostTypeId="2" ParentId="3180" CreationDate="2015-05-06T18:54:42.707" Score="13" Body="&lt;p&gt;Here is a mapping from my &lt;code&gt;vimrc&lt;/code&gt; where I check if the command type is either &lt;em&gt;forward search&lt;/em&gt; &lt;code&gt;OR&lt;/code&gt; &lt;em&gt;backward search&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; getcmdtype() == &quot;/&quot; \|\| getcmdtype() == &quot;?&quot; ? &quot;&amp;lt;CR&amp;gt;/&amp;lt;C-r&amp;gt;/&quot; : &quot;&amp;lt;C-z&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help getcmdtype()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more granularity, you could use &lt;code&gt;getcmdline()&lt;/code&gt; like I did in the function below. The value of &lt;code&gt;getcmdline()&lt;/code&gt; is checked against a bunch of patterns to decide what to return instead of &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Shortcut()&#xA;    let cmdline = getcmdline()&#xA;    if cmdline =~ '\C^ls'&#xA;        return &quot;\&amp;lt;CR&amp;gt;:b&quot;&#xA;    elseif cmdline =~ '/#$'&#xA;        return &quot;\&amp;lt;CR&amp;gt;:&quot;&#xA;    elseif cmdline =~ '\v\C^(dli|il)'&#xA;        return &quot;\&amp;lt;CR&amp;gt;:&quot; . cmdline[0] . &quot;jump  &quot; . split(cmdline, &quot; &quot;)[1] . &quot;\&amp;lt;S-Left&amp;gt;\&amp;lt;Left&amp;gt;&quot;&#xA;    elseif cmdline =~ '\v\C^(cli|lli)'&#xA;        return &quot;\&amp;lt;CR&amp;gt;:silent &quot; . repeat(cmdline[0], 2) . &quot;\&amp;lt;Space&amp;gt;&quot;&#xA;    elseif cmdline =~ '\C^old'&#xA;        return &quot;\&amp;lt;CR&amp;gt;:edit #&amp;lt;&quot;&#xA;    else&#xA;        return &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; Shortcut()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help getcmdline()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-05-06T18:54:42.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3182" PostTypeId="1" AcceptedAnswerId="3183" CreationDate="2015-05-06T22:00:41.980" Score="7" ViewCount="222" Body="&lt;p&gt;I find that if you enter a numeric prefix prior to executing an ex command, the convention that it applies is to set up the command to prep an operation across a line range. It is explained in the documentation, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A NUMBER OF LINES&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When you know how many lines you want to change, you can type the&#xA;  number and then &quot;:&quot;.  For example, when you type &quot;5:&quot;, you will get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    :.,.+4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Now you can type the command you want to use.  It will use the range&#xA;  &quot;.&quot; (current line) until &quot;.+4&quot; (four lines down).  Thus it spans five&#xA;  lines.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now what I am dealing with is a custom function of mine, this one: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyAmazingEnhancedDot()&#xA;    if v:hlsearch == 1&#xA;        :normal! .n&#xA;    else&#xA;        :normal! .j&#xA;    endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is just a way to streamline repetitive tasks that include repeating an operation on a range of lines or over a series of search matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This function is bound to a hotkey. Such as &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;.&lt;/kbd&gt; or whatever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My aim is to be able to do something very powerful: I should be able to type &lt;code&gt;/varName&amp;lt;CR&amp;gt;ciwnew-var&amp;lt;ESC&amp;gt;n9&amp;lt;Alt+.&amp;gt;&lt;/code&gt; to achieve renaming 10 instances of &lt;code&gt;varName&lt;/code&gt; to &lt;code&gt;new-var&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What actually happens if I do this is that it does not perform the renaming and the 9 lines are manipulated with my &lt;code&gt;.&lt;/code&gt;-saved edit operation from column 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can only assume that Vim is interpreting my keystrokes thus: &lt;code&gt;:.,.+8 normal! .n&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the glass-half-full side, the &lt;code&gt;:normal! .j&lt;/code&gt; case of the bind actually works, because the &lt;code&gt;j&lt;/code&gt; motion having no effect is of no consequence in this situation. (I still need the &lt;code&gt;j&lt;/code&gt; to make it work in a non-numeric-prefixed interactive use case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is how can I override the line-expansion behavior that Vim applies to my bind? What would be fantastic is if I can read in the numeric prefix as an argument or something like that.&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="51" LastEditDate="2015-05-06T22:04:38.773" LastActivityDate="2015-05-07T02:39:27.090" Title="Is it possible to make a numerically-prefixed hotkey run a function that many times?" Tags="|vimscript|normal-mode|repeated-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3183" PostTypeId="2" ParentId="3182" CreationDate="2015-05-06T22:24:23.777" Score="6" Body="&lt;p&gt;By default vim treats all functions as if they are default ex commands, i.e. any prefixed numbers are used as &lt;code&gt;{range}&lt;/code&gt;. To change this you need to modify your function and your map to use a count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Map with count&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maps can take a count and are made available via &lt;code&gt;v:count&lt;/code&gt; and &lt;code&gt;v:count1&lt;/code&gt;. The first contains 0 if no count is provided and the later contains 1 as the default. You can create a map to your function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;M-.&amp;gt; :&amp;lt;C-u&amp;gt;call MyAmazingEnhancedDot(v:count1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more info &lt;code&gt;:h v:count&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Commands with count&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Commands can have the option of either a &lt;code&gt;{range}&lt;/code&gt; or a &lt;code&gt;count&lt;/code&gt; as a prefix. When creating the command the flag &lt;code&gt;-count&lt;/code&gt; disables the range option and defaults the &lt;code&gt;&amp;lt;count&amp;gt;&lt;/code&gt; variable to 0. Optionally a default value can be provided &lt;code&gt;-count=N&lt;/code&gt;. The prefix value is then available via the variable &lt;code&gt;count&lt;/code&gt; in your function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A command using count would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command -count=1 EDot call MyAmazingEnhancedDot(&amp;lt;count&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when you call &lt;code&gt;9EDot&lt;/code&gt; your function is called with the count of &lt;code&gt;9&lt;/code&gt; instead of a range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info see &lt;code&gt;:h command-count&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Both examples&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyAmazingEnhancedDot(count)&#xA;  let c = a:count&#xA;  while c &amp;gt; 0&#xA;    if v:hlsearch == 1&#xA;      :normal! .n&#xA;    else&#xA;      :normal! .j&#xA;    endif&#xA;    let c -= 1&#xA;  endwhile&#xA;endfunction&#xA;&#xA;command -count=1 EDot call MyAmazingEnhancedDot(&amp;lt;count&amp;gt;)&#xA;&#xA;nnoremap &amp;lt;M-.&amp;gt; :&amp;lt;C-u&amp;gt;exe v:count1 . &quot;EDot&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can do your example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/varName&amp;lt;CR&amp;gt;ciwvar-name&amp;lt;esc&amp;gt;n9&amp;lt;M-.&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2015-05-07T02:39:27.090" LastActivityDate="2015-05-07T02:39:27.090" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3184" PostTypeId="1" AcceptedAnswerId="3185" CreationDate="2015-05-07T08:51:28.887" Score="2" ViewCount="1139" Body="&lt;p&gt;A server only has old versions of vim available in the repo, so I compile and run vim from my ~.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting vim it complains&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line    2:&#xA;E484: Can't open file /usr/local/share/vim/syntax/syntax.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where line 2 is where I have &lt;code&gt;syntax on&lt;/code&gt;. This is obviously caused by the file not being present on the system.&#xA;Setting &lt;code&gt;let $VIMRUNTIME=&quot;/home/[user]/vim74/runtime/&quot;&lt;/code&gt; makes the error go away, however I still get no syntax highlightning what so ever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've checked that &lt;code&gt;/home/[user]/vim74/runtime/&quot;&lt;/code&gt; has a syntax directory containing hundreds of [language].vim files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried commenting out the rest of my settings to make sure I have nothing else interfering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar  6 2015 15:34:54)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2004" LastActivityDate="2015-05-07T17:48:50.140" Title="Syntax highlightning with custom runtime path" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3185" PostTypeId="2" ParentId="3184" CreationDate="2015-05-07T09:35:25.323" Score="2" Body="&lt;p&gt;When you compile Vim source code and would like to install it on custom directory, this directory can be specified with &lt;code&gt;--prefix&lt;/code&gt; option to the &lt;code&gt;./configure&lt;/code&gt; command. Usually I will go as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ./configure --with-features=huge --prefix=$HOME/local&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After this, proceed with &lt;code&gt;make&lt;/code&gt; and then &lt;code&gt;make install&lt;/code&gt;. This will install the Vim binaries under subdirectory &lt;code&gt;bin&lt;/code&gt;, and also manual pages under subdirectory &lt;code&gt;share/man&lt;/code&gt;. These path can then be added to your &lt;code&gt;PATH&lt;/code&gt; and &lt;code&gt;MANPATH&lt;/code&gt; respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, assuming Vim source code is extracted into &lt;code&gt;$HOME/vim74&lt;/code&gt;, the &lt;code&gt;--prefix&lt;/code&gt; and &lt;code&gt;make install&lt;/code&gt; may be omitted, if you specify the following in your &lt;code&gt;.vimrc&lt;/code&gt;. Please note that this is only based on experiment so it is not recommended -- something may break.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; let $VIM         = $HOME . &quot;/vim74&quot;    &#xA; let $VIMRUNTIME  = $HOME . &quot;/vim74/runtime&quot;&#xA; set runtimepath^=$VIMRUNTIME           &#xA; set helpfile=$VIMRUNTIME/doc/help.txt  &#xA; syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1782" LastEditorUserId="1782" LastEditDate="2015-05-07T17:48:50.140" LastActivityDate="2015-05-07T17:48:50.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3186" PostTypeId="1" AcceptedAnswerId="3187" CreationDate="2015-05-07T12:33:49.407" Score="13" ViewCount="1999" Body="&lt;p&gt;I have a &lt;code&gt;nofile&lt;/code&gt; buffer that contains vimscript, and I want to execute it.  However, &lt;code&gt;:so %&lt;/code&gt;  will not work because it requires a saved file, not a buffer.  Is there a vim command to do this by default?  If not, is it possible to create a function which does the same things?&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-05-07T16:03:29.240" Title="Execute content of buffer as vimscript" Tags="|vimscript|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3187" PostTypeId="2" ParentId="3186" CreationDate="2015-05-07T12:49:47.733" Score="15" Body="&lt;p&gt;Yes, you can yank the whole buffer with &lt;code&gt;ggyG&lt;/code&gt; or &lt;code&gt;:%y&lt;/code&gt; and execute it with &lt;code&gt;:@&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%y|@&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Used in a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :%y|@&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Used in a flexible command that works on the whole buffer by default or an optional range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar -range=% Foo execute &amp;lt;line1&amp;gt; . ',' . &amp;lt;line2&amp;gt; . 'y|@&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-05-07T16:03:29.240" LastActivityDate="2015-05-07T16:03:29.240" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3188" PostTypeId="1" AcceptedAnswerId="3194" CreationDate="2015-05-07T15:42:22.530" Score="2" ViewCount="423" Body="&lt;p&gt;I use two servers, both using redhat, and I need to most of work on server, not on my PC. My sysadmin did not update vim for a very long time, like, system's default vim version is 6.x, which is really horrible. Since I cannot get sudo privilege, I thought it would be good to compile vim myself from its source just for myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed instructions posted &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&quot; rel=&quot;nofollow&quot;&gt;HERE&lt;/a&gt;, but I only used &lt;code&gt;enable-pythoninterp&lt;/code&gt;, &lt;code&gt;prefix&lt;/code&gt;, and &lt;code&gt;with-python-config-dir&lt;/code&gt; options for configure.&#xA;After I compiled vim (version 7.4.691) for the first machine, I moved on to the second one, with the same source code. I did the same &lt;code&gt;./configure&lt;/code&gt; and &lt;code&gt;make&lt;/code&gt;, but it took forever (about an hour before I hit &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt;) so I am really confused right now. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked the output, and I found out that everything is being repeated with following message, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;config.status: creating auto/config.h&#xA;make: Warning: File `Makefile' has modification time 2.4e+09 s in the future&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why this behaviour, and how to solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="2009" LastActivityDate="2015-05-08T01:54:04.000" Title="infinite loop when compiling vim from source code" Tags="|installing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3189" PostTypeId="1" AcceptedAnswerId="3191" CreationDate="2015-05-07T16:22:22.993" Score="9" ViewCount="1836" Body="&lt;p&gt;This may be a weird question, because I already have this setup in my dotfiles somewhere, I just don't know how to tell a friend to set it up in their dotfiles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know how to get a nice git diff displayed in your gitcommit file, whenever you compose a git commit message with vim. Here are &lt;a href=&quot;https://github.com/aharris88/dotfiles&quot; rel=&quot;noreferrer&quot;&gt;my dotfiles&lt;/a&gt; if that helps. I couldn't find the answer online and it was hard to search without knowing what to search for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Y2p3W.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="226" LastActivityDate="2015-05-09T01:47:43.903" Title="How to get git diff in vim when writing a commit message?" Tags="|filetype-git|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3190" PostTypeId="1" CreationDate="2015-05-07T16:29:46.820" Score="4" ViewCount="2789" Body="&lt;p&gt;I tried &lt;a href=&quot;https://stackoverflow.com/questions/18158772/how-to-add-c11-support-to-syntastic-vim-plugin&quot;&gt;this solution&lt;/a&gt; using instead of C++11 C++14, but it doesn't work, I still get for this line:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;auto number(0);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'auto' type specifier is incompatible with C++98&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;with syntastic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is syntastic still using C++98 and not C++14?&lt;/p&gt;&#xA;" OwnerUserId="1463" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-05-08T09:48:43.207" Title="syntastic C++14 support" Tags="|filetype-c++|plugin-syntastic|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="3191" PostTypeId="2" ParentId="3189" CreationDate="2015-05-07T17:10:31.460" Score="14" Body="&lt;p&gt;This behavior seems to come from calling &lt;code&gt;git commit -v&lt;/code&gt; or &lt;code&gt;git commit --verbose&lt;/code&gt;. Not sure where you're doing that in your dotfiles, but I'd recommend telling him to set an alias in his git config that does that.&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-05-07T17:10:31.460" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3192" PostTypeId="2" ParentId="3190" CreationDate="2015-05-07T19:26:28.190" Score="4" Body="&lt;p&gt;In my .vimrc, I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_cpp_checkers = ['gcc']&#xA;let g:syntastic_cpp_compiler = 'gcc'&#xA;let g:syntastic_cpp_compiler_options = '-std=c++14'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And, if you have YCM enabled:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_show_diagnostics_ui = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now it works!&lt;/p&gt;&#xA;" OwnerUserId="1463" LastEditorUserId="1463" LastEditDate="2015-05-08T09:48:43.207" LastActivityDate="2015-05-08T09:48:43.207" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3194" PostTypeId="2" ParentId="3188" CreationDate="2015-05-08T01:54:04.000" Score="3" Body="&lt;p&gt;OK. I solved problem by myself, and I wanted to share what I found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I downloaded the most recent version from &lt;a href=&quot;https://code.google.com/p/vim/&quot; rel=&quot;nofollow&quot;&gt;Google&lt;/a&gt; as a &lt;code&gt;zip&lt;/code&gt; format, and I uploaded to my server, unzip, and tried to compile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is, files inside .zip did not have any &lt;code&gt;Timestamp&lt;/code&gt;. While extracting, arbitrary timestamps were inserted. In my first server, all missing timestamps are filled with some arbitrary number, either too large or too small. Some files were stamped as year 1953, while some critical files, such as &lt;code&gt;configure&lt;/code&gt; had year 2092-08-05. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Makefile compared timestamps and got error. This caused infinitely looping &lt;code&gt;make&lt;/code&gt; procedure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution? I just &lt;code&gt;scp&lt;/code&gt;ed all &lt;em&gt;extracted&lt;/em&gt; source codes from my 1st server, since it had no problem installing it. As I thought, those source codes had consistent timestamps. (By consistent, I mean, &lt;em&gt;after unix epoch&lt;/em&gt;. They all had like 1979.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, it is highly unlikely anybody experiencing the same problem, but if so, you should check the timestamps.&lt;/p&gt;&#xA;" OwnerUserId="2009" LastActivityDate="2015-05-08T01:54:04.000" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3195" PostTypeId="2" ParentId="3189" CreationDate="2015-05-08T05:17:54.887" Score="3" Body="&lt;p&gt;Additionally, Do try out &lt;a href=&quot;https://github.com/rhysd/committia.vim&quot; rel=&quot;nofollow&quot;&gt;committia.vim&lt;/a&gt;, a plugin for writing a commit message. When &lt;code&gt;git commit&lt;/code&gt;ing, it splits the window and shows the diff and status window very nicely.&lt;/p&gt;&#xA;" OwnerUserId="466" LastActivityDate="2015-05-08T05:17:54.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3196" PostTypeId="1" AcceptedAnswerId="3198" CreationDate="2015-05-08T07:20:53.570" Score="6" ViewCount="1172" Body="&lt;p&gt;When using the command-line history window, I'd like to go back to the file I use it on to see what I'm working with. When revisualizing a block of code (&lt;code&gt;gv&lt;/code&gt;), the cursor will go to the top after entering command-line history (&lt;code&gt;q:&lt;/code&gt;). How do I switch between these two windows/panes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/extHS.png&quot; alt=&quot;command-line history&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2020" LastEditorUserId="51" LastEditDate="2015-05-10T01:36:16.397" LastActivityDate="2015-05-10T01:36:16.397" Title="How do I switch between the command-line history and file panes?" Tags="|visual-mode|vim-windows|command-line-window|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3198" PostTypeId="2" ParentId="3196" CreationDate="2015-05-08T09:18:52.370" Score="4" Body="&lt;h2&gt;&lt;em&gt;Generic&lt;/em&gt; answer:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-w&amp;gt;p&lt;/code&gt; moves the cursor to the &lt;em&gt;previous&lt;/em&gt; window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help window-move-cursor&lt;/code&gt; and, more generally, &lt;code&gt;:help windows&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;em&gt;Specific&lt;/em&gt; answer:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can't switch to another window while the command-line window is focused, as stated in &lt;code&gt;:help cmdline-window&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In the command-line window the command line can be edited just like editing&#xA;text in any window.  It is a special kind of window, because you cannot leave&#xA;it in a normal way.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-05-08T09:41:39.683" LastActivityDate="2015-05-08T09:41:39.683" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3199" PostTypeId="1" AcceptedAnswerId="3200" CreationDate="2015-05-08T09:24:59.220" Score="6" ViewCount="256" Body="&lt;p&gt;To take a look at the mappings in my current session I fired:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to list all current mappings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output opens in some sort of read only awkward window. It's only possible to scroll. It's not even searchable.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is it possible to get the output of &lt;code&gt;:map&lt;/code&gt; and redirect it to a normal buffer? How?&lt;/li&gt;&#xA;&lt;li&gt;What is this kind of window/buffer? (I'm curious about it)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2022" LastEditorUserId="2022" LastEditDate="2015-05-08T10:14:15.060" LastActivityDate="2019-04-07T16:31:35.937" Title="Put current mappings into a buffer" Tags="|key-bindings|buffers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3200" PostTypeId="2" ParentId="3199" CreationDate="2015-05-08T09:33:30.820" Score="9" Body="&lt;p&gt;That &quot;window&quot; is a simplistic built-in pager similar in spirit to &lt;code&gt;more&lt;/code&gt; or &lt;code&gt;less&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help pager&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how you get the output of a command in a more usable form:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, redirect the output of &lt;code&gt;:map&lt;/code&gt; to an arbitrary register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @a&amp;lt;CR&amp;gt;&#xA;:map&amp;lt;CR&amp;gt;&#xA;:redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, put that register into a new buffer in a new window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnew&amp;lt;CR&amp;gt;&#xA;&quot;aP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :redir&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-05-08T09:33:30.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3201" PostTypeId="2" ParentId="3196" CreationDate="2015-05-08T09:48:22.030" Score="4" Body="&lt;p&gt;Sadly you can't. You have to close the window first. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the help &lt;code&gt;:h E11&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The command-line window is not a normal window.&lt;br&gt;&#xA;  It is &lt;strong&gt;not possible to move to another window&lt;/strong&gt; or edit another&#xA;  buffer.&lt;br&gt;&#xA;  All &lt;strong&gt;commands&lt;/strong&gt; that would do this &lt;strong&gt;are disabled&lt;/strong&gt; in the&#xA;  command-line window.&lt;br&gt;&#xA;  Of course it &lt;em&gt;is&lt;/em&gt; possible to execute any&#xA;  command that you entered in the command-line window.&lt;br&gt;&#xA;  Other text edits are discarded when closing the window.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2022" LastActivityDate="2015-05-08T09:48:22.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3202" PostTypeId="2" ParentId="3164" CreationDate="2015-05-08T12:07:40.613" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/Shougo/unite.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Unite&lt;/a&gt; plugin's &lt;code&gt;buffer&lt;/code&gt; source remembers the order of accessing. I just opened the files in the order you wrote, and the buffer-chooser window looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/aKAKf.png&quot; alt=&quot;unite buffer and list of buffers&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can open the Unite with &lt;code&gt;:Unite buffer -direction=botright&lt;/code&gt;, press &lt;code&gt;&amp;lt;Down&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to go to the next buffer and &lt;code&gt;&amp;lt;Up&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt; for the previous.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make life simpler, here's the mappings to go to the older/newer buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map  &amp;lt;C-Y&amp;gt;  :Unite buffer -direction=botright&amp;lt;CR&amp;gt;&amp;lt;Up&amp;gt;&amp;lt;CR&amp;gt;&#xA;map  &amp;lt;C-E&amp;gt;  :Unite buffer -direction=botright&amp;lt;CR&amp;gt;&amp;lt;Down&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2024" LastActivityDate="2015-05-08T12:07:40.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3203" PostTypeId="1" AcceptedAnswerId="3204" CreationDate="2015-05-08T12:46:08.550" Score="3" ViewCount="503" Body="&lt;p&gt;Despite there being no mention on the keystroke &lt;code&gt;&amp;lt;Leader&amp;gt;l&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;, this combination opens the current fold on my installation of &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;gvim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not mentioned under &lt;code&gt;:map&lt;/code&gt;. Is it a standard thing or might it be due to a plug-in?&lt;/p&gt;&#xA;" OwnerUserId="2026" LastActivityDate="2015-05-08T13:11:10.380" Title="Why does &lt;Leader&gt;l open my folds?" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3204" PostTypeId="2" ParentId="3203" CreationDate="2015-05-08T13:11:10.380" Score="13" Body="&lt;p&gt;If &lt;code&gt;&amp;lt;Leader&amp;gt;l&lt;/code&gt;isn't mapped to anything, than this is effictivly the same as the motion &lt;code&gt;l&lt;/code&gt;. And this will open your folds. If you don't want this, tune the &lt;code&gt;'foldopen'&lt;/code&gt; setting like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set foldopen-=hor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-05-08T13:11:10.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3205" PostTypeId="1" AcceptedAnswerId="3208" CreationDate="2015-05-08T16:26:06.220" Score="4" ViewCount="556" Body="&lt;p&gt;I've run into a weird problem with Vim on Win8 that I just can't get my head around. Some of the stuff I'm going to mention happened months ago and therefore aren't fresh in my memory anymore, so please forgive me if I accidentally leave things out or can't be definitive on some details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So several months ago, while looking into combining Vim and LaTeX, I discovered LaTeX-Suite (or Vim-LaTeX). When installing this plug-in, one is &lt;a href=&quot;http://vim-latex.sourceforge.net/index.php?subject=download&quot; rel=&quot;nofollow&quot;&gt;instructed&lt;/a&gt; to set a few things in one's &lt;code&gt;_vimrc&lt;/code&gt; file. I did this and added just a few settings of my own. I was going to add more as I went along but I got distracted from Vim and now here we are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway. I'm pretty sure I did all this in the commandline, which I think is relevant to my problem, because I've now discovered that the contents of my &lt;code&gt;_vimrc&lt;/code&gt; file depend on the manner in which I open it. In particular, those lines I added a couple months ago, are missing from the file if I open it with gVim (regardless of whether I use the context menu or launch gVim from the commandline). Same song for any other graphical text editor. Only if I open it with Vim from the commandline, the lines are there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is going on here? Are these lines somehow trapped in Vim limbo? Do I need to call the Ghostbusters? How can the same file have different contents depending on the text editor?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I FOUND A CLUE!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In trying to determine which file was being copied depending on whether I did so from the commandline or from the context menu in Windows Explorer, I found out a crucial detail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to copy files in the Program Files (x86) folder, one needs to run &lt;code&gt;cmd.exe&lt;/code&gt; as admin. I discovered that my extra lines in the &lt;code&gt;_vimrc&lt;/code&gt; file were absent if I opened it with Vim in an admin commandline. So copying as admin copies the file with the limited contents, copying it without admin rights (to the Documents folder for example) will copy the file with the extra lines. Still weird (because I don't have admin rights when I simply open the file with gVim from the context menu) but at least this sheds some light on the underlying cause. Is anyone able to connect the dots for me?&lt;/p&gt;&#xA;" OwnerUserId="2030" LastEditorUserId="205" LastEditDate="2015-05-11T19:50:07.933" LastActivityDate="2015-05-11T19:50:07.933" Title="Contents of _vimrc file depend on how it is opened" Tags="|vimrc|microsoft-windows|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3206" PostTypeId="1" AcceptedAnswerId="3207" CreationDate="2015-05-08T17:08:38.390" Score="4" ViewCount="1741" Body="&lt;p&gt;Is there any way to determine within Vim that the file which I'm editing is either in text or binary format?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim http://example.com/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim http://cdn.sstatic.net/vi/img/apple-touch-icon.png&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Something that would return either True or False based on the content of the current file. One &lt;a href=&quot;https://vi.stackexchange.com/q/3211/467&quot;&gt;possible scenario&lt;/a&gt; would be, if the file is in gzip format, I'd like to perform uncompression of it.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2022-05-10T19:38:29.107" Title="How to check if file is binary?" Tags="|vimscript|binary-file|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3207" PostTypeId="2" ParentId="3206" CreationDate="2015-05-08T17:33:25.897" Score="8" Body="&lt;p&gt;Most programs (such as &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;git&lt;/code&gt;, &lt;code&gt;mercurial&lt;/code&gt;, etc.) consider a file to be binary if it contains a NULL byte.&lt;/p&gt;&#xA;&lt;p&gt;You can check this with Vim like so:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fun! IsBinary()&#xA;    return !!search('\%u0000', 'wn')&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that this searches the entire buffer; and won't be very fast for large files. A faster way would be to use the &lt;code&gt;file&lt;/code&gt; utility:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fun! IsBinary2()&#xA;    return system('file -ib ' . shellescape(expand('%:p'))) !~# '^text/'&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;file&lt;/code&gt; has a list known &amp;quot;magic&amp;quot; patterns it can check against, and will be a lot faster for some files. The downside is that &lt;code&gt;file&lt;/code&gt; isn't available by default on some systems (Windows, some Linuxes).&lt;/p&gt;&#xA;&lt;p&gt;It gets the MIME type, so you can do more advanced matching, such as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fun! IsGzip()&#xA;    return system('file -ib ' . shellescape(expand('%:p'))) =~# '^application/x-gzip'&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;if the file is in gzip format, I'd like to perform uncompression of it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;gzip files pretty much always end in &lt;code&gt;.gz&lt;/code&gt;; in fact, some &lt;code&gt;gzip&lt;/code&gt; flavours won't even work if the file &lt;em&gt;doesn't&lt;/em&gt; end in .gz; with GNU gzip:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ gzip z&#xA;$ mv z.gz aaaaa&#xA;$ gzip -d aaaaa&#xA;gzip: aaaaa: unknown suffix -- ignored&#xA;Exit 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So matching the filename with an autocmd would probably be a better solution. In fact, there's already an example of this in the help: &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#gzip-example&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help gzip-example&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="25220" LastEditDate="2022-05-10T19:38:29.107" LastActivityDate="2022-05-10T19:38:29.107" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3208" PostTypeId="2" ParentId="3205" CreationDate="2015-05-08T19:23:33.360" Score="8" Body="&lt;p&gt;You're seeing the effects of the Windows &lt;a href=&quot;https://msdn.microsoft.com/de-de/library/windows/desktop/aa384187%28v%3Dvs.85%29.aspx&quot;&gt;File System Redirector&lt;/a&gt;. When you edit files in &lt;code&gt;%ProgramFiles%&lt;/code&gt; without administrative rights / user account elevation (which isn't allowed in modern version of Windows), Windows redirects the file access to another location inside your user's home directory (to support legacy applications that were written to persist runtime data into their installation location inside &lt;code&gt;%ProgramFiles%&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, Vim instances run with / without user elevation see different &lt;code&gt;.vimrc&lt;/code&gt; configurations. (Something similar can happen if you use both 32- and 64-bit versions concurrently.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, &lt;strong&gt;do not modify any Vim runtime files at the installation location&lt;/strong&gt;! Instead, put your &lt;code&gt;.vimrc&lt;/code&gt; (and any plugins you install) inside your user's home directory (Usually &lt;code&gt;C:\Users\&amp;lt;username&amp;gt;&lt;/code&gt;); cp. &lt;code&gt;:help .vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-08T19:23:33.360" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3209" PostTypeId="2" ParentId="3206" CreationDate="2015-05-08T19:29:38.683" Score="2" Body="&lt;p&gt;Your mentioned automatic uncompression of ZIP files (and other archive formats) is already built into Vim, cp. &lt;code&gt;:help pi_zip&lt;/code&gt;. The plugin sets up &lt;code&gt;:autocmd&lt;/code&gt;s that detect ZIP files based on their file extension (&lt;code&gt;:au zip&lt;/code&gt; lists them all), not on their contents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's no detection built in, because it doesn't make much sense to edit non-text files with a text editor such as Vim. That said, Vim has some support via &lt;code&gt;:set binary&lt;/code&gt;, and conversion to / from hexdump format via &lt;code&gt;xxd&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-08T19:29:38.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3210" PostTypeId="2" ParentId="2949" CreationDate="2015-05-08T19:38:04.883" Score="2" Body="&lt;p&gt;I use a shell function to perform &lt;code&gt;git checkout&lt;/code&gt;.  (I call it &lt;code&gt;gco&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This function performs some index updating, if the checkout succeeds.  (In my case I am interested in updating my &lt;code&gt;cindex&lt;/code&gt;, while you want to update your &lt;code&gt;cscope&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gco() {&#xA;    git checkout &quot;$@&quot;&#xA;    local ret_status=&quot;$?&quot;&#xA;    if [ &quot;$ret_status&quot; = 0 ] &amp;amp;&amp;amp; [ -n &quot;$POST_GIT_CHECKOUT&quot; ]&#xA;    then &quot;$POST_GIT_CHECKOUT&quot; &quot;$@&quot;&#xA;    fi&#xA;    return &quot;$ret_status&quot;&#xA;}&#xA;&#xA;POST_GIT_CHECKOUT=update_cindex     # update_cindex is another shell function!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see it &lt;a href=&quot;https://github.com/joeytwiddle/rc_files/blob/0b83ca33a222bbfb4abc0393abc7bd90d247ea2a/j/config/auto.sh/git_aliases#L249&quot; rel=&quot;nofollow&quot;&gt;in context here&lt;/a&gt;.  (In the end I found I could run &lt;code&gt;cindex&lt;/code&gt; in the background, and with &lt;code&gt;ionice&lt;/code&gt;, so it didn't delay my progress.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other users may want to trigger these kind of updates after a &lt;code&gt;git pull&lt;/code&gt; or an &lt;code&gt;svn update&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-05-08T19:38:04.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3211" PostTypeId="1" AcceptedAnswerId="3216" CreationDate="2015-05-08T19:48:00.747" Score="2" ViewCount="1577" Body="&lt;p&gt;In &lt;a href=&quot;https://vi.stackexchange.com/a/3209/467&quot;&gt;here&lt;/a&gt; it's suggested that Vim can do automatic uncompression of gzip/zip files (including other formats) and it's something built-in.&lt;/p&gt;&#xA;&lt;p&gt;How do I open compressed file then?&lt;/p&gt;&#xA;&lt;p&gt;Sample scenario:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;curl https://html1-f.scribdassets.com/3ltyujem84drr4o/pages/4-e661572124.jsonp | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastEditorUserId="23502" LastEditDate="2022-11-02T09:06:36.357" LastActivityDate="2022-11-02T09:06:36.357" Title="How to make Vim to uncompress archive formats?" Tags="|binary-file|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3212" PostTypeId="2" ParentId="3211" CreationDate="2015-05-08T19:48:00.747" Score="2" Body="&lt;p&gt;Using external Unix tools is easy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!gzip -d&#xA;:%!gunzip -d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-05-08T19:48:00.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3213" PostTypeId="1" AcceptedAnswerId="3215" CreationDate="2015-05-08T20:47:46.620" Score="6" ViewCount="10147" Body="&lt;p&gt;I'd like to remove everything apart of my pattern match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I've the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;window.page4_callback([&quot;here \&quot;is\&quot; some text&quot;]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'd like to leave the text only within the double quotes, so the expected output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;here \&quot;is\&quot; some text &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Matching pattern is &lt;code&gt;/&quot;.*&quot;&lt;/code&gt; and its removal can be performed by using substitute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/&quot;.*&quot;//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however how do you do opposite?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to use vglobal (&lt;code&gt;:v/pattern/d&lt;/code&gt;), but it would normally remove the whole line, but in my case it's saying:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Pattern found in every line: &lt;code&gt;&quot;.*&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've found similar issue &lt;a href=&quot;https://stackoverflow.com/q/6249172/55075&quot;&gt;here&lt;/a&gt;, but I'm even more confused.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-05-11T11:10:33.660" Title="How to delete part of a line that does not match a pattern?" Tags="|regular-expression|substitute|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3214" PostTypeId="1" AcceptedAnswerId="3220" CreationDate="2015-05-08T20:57:33.317" Score="0" ViewCount="137" Body="&lt;p&gt;After installing &lt;code&gt;ctrlp&lt;/code&gt; via pathogen, my default spelling dictionary is located at:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/bundle/ctrlp.vim/spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of its previous location:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While I can always dig into the root cause and modify the plugin, or symlink the directory, is this normal/intentional?&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="205" LastEditDate="2015-05-09T17:03:21.487" LastActivityDate="2015-05-09T17:03:21.487" Title="How do I prevent ctrlp plugin from changing the default spell location?" Tags="|spell-checking|plugin-ctrlp|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3215" PostTypeId="2" ParentId="3213" CreationDate="2015-05-08T20:58:49.957" Score="8" Body="&lt;p&gt;There are probably a bunch of ways to do this; here's my attempt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.*&quot;\(.\{-}\)&quot;.*/\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key part is &lt;code&gt;&quot;\(.\{-}\)&quot;&lt;/code&gt;; this non-greedily matches everything in between quotes. This will match:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;window.page4_callback([&lt;code&gt;&quot;here is some text&quot;&lt;/code&gt;]);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The parentheses are there to start a subgroup, so we can reference it with &lt;code&gt;\1&lt;/code&gt; on the replacing side. We surround this with &lt;code&gt;.*&lt;/code&gt; on both ends to match the rest of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this doesn't really &quot;delete a non-matching pattern&quot;, as the title says. Rather, it deletes the &lt;em&gt;entire line&lt;/em&gt;, and replaces it with a specific subgroup we matched earlier. The effect is the same, and for me, this is an easier way to think about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conclusion: capturing subgroups is good. Subgroups are your friends.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To also work after your edited post :-)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^.\{-}&quot;\(.*\)&quot;.\{-}$/\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a variant of the above, but notice we use &lt;code&gt;.\{-}&lt;/code&gt; before and after the   &lt;code&gt;&quot;&lt;/code&gt; now, to match as little as possible; plus, we anchor it to the start and end of the line with &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then replace the &lt;code&gt;\&quot;&lt;/code&gt; with a second &lt;code&gt;:substitute&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\\&quot;/&quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This still won't work with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;window.function(&quot;arg1&quot;, &quot;arg2&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will leave you with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arg1&quot;, &quot;arg2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'm not sure if that's a requirement :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="343" LastEditDate="2015-05-11T09:25:47.953" LastActivityDate="2015-05-11T09:25:47.953" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3216" PostTypeId="2" ParentId="3211" CreationDate="2015-05-08T21:13:31.737" Score="5" Body="&lt;p&gt;Starting it 2005 vim added support for editing zip files natively. The build in support uses native zip utilities (zip, gzip, jar, xpi, etc) to manipulate these files. It does not look as if there is a direct way to interact with a compressed stream of data unless you use external tools.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim &amp;lt;zipfile&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should open a buffer listing all files in the zip file. Move the cursor over and press &lt;kbd&gt;Enter&lt;/kbd&gt; and the file is opened in a buffer. Currently there is no support to add new files to a zip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information see &lt;code&gt;:h zip&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2015-05-08T21:20:31.763" LastActivityDate="2015-05-08T21:20:31.763" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3217" PostTypeId="2" ParentId="3213" CreationDate="2015-05-08T21:41:11.073" Score="3" Body="&lt;pre&gt;&lt;code&gt;yi[       &quot; yank what's between the brackets&#xA;S         &quot; delete line and start insert&#xA;&amp;lt;C-r&amp;gt;0    &quot; insert last yanked text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-05-08T21:41:11.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3218" PostTypeId="2" ParentId="3213" CreationDate="2015-05-09T01:39:00.777" Score="4" Body="&lt;p&gt;The easiest way is to use &lt;code&gt;grep --only-matching&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!grep --only-matching --extended-regexp '&quot;.*&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However if you want a completely Vim solution then you can use &lt;code&gt;:s&lt;/code&gt; with an expression replacement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=&quot;&quot;&#xA;:%s//\=setreg('A', submatch(0), 'l')/g&#xA;:%d _&#xA;:pu a&#xA;:0d _&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or all on a single line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=&quot;&quot;|%s/&quot;.*&quot;/\=setreg('A', submatch(0), 'l')/g|%d _|pu a|0d _&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In brief, this uses a substitution to append each match into register &quot;a&quot; linewise then replace the entire buffer with the contents of register &quot;a&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See my answer at &quot;&lt;a href=&quot;https://stackoverflow.com/a/4521486/660921&quot;&gt;Remove everything except regex match in Vim&lt;/a&gt;&quot; for a fuller explanation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Concerns:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This will trash one of your registers. This example trashed &lt;code&gt;@a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Uses the last search pattern. Although you can modify the substitute command with whatever pattern you want: &lt;code&gt;%s/&amp;lt;pattern&amp;gt;/\=setreg('A', submatch(0), 'l')/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="778" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-05-10T01:45:32.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3219" PostTypeId="2" ParentId="3189" CreationDate="2015-05-09T01:47:43.903" Score="3" Body="&lt;p&gt;Alternatively you can use Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow&quot;&gt;fugitive.vim&lt;/a&gt;. It provides &lt;code&gt;:Gcommit&lt;/code&gt; which is a wrapper around &lt;code&gt;git commit&lt;/code&gt; (So you can do &lt;code&gt;:Gcommit --verbose&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably the more preferred way would be to use &lt;code&gt;:Gstatus&lt;/code&gt; and execute &lt;code&gt;cvc&lt;/code&gt;. Then just create your commit message and then save and quit (I use &lt;code&gt;:x&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help with fugitive.vim I recommend Vimcasts episodes mentioned in this article: &lt;a href=&quot;http://vimcasts.org/blog/2011/05/the-fugitive-series/&quot; rel=&quot;nofollow&quot;&gt;The Fugitive Series - a retrospective&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :Gcommit&#xA;:h :Gstatus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-05-09T01:47:43.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3220" PostTypeId="2" ParentId="3214" CreationDate="2015-05-09T12:24:48.393" Score="4" Body="&lt;p&gt;The instructions found at &lt;a href=&quot;http://kien.github.io/ctrlp.vim&quot; rel=&quot;nofollow&quot;&gt;http://kien.github.io/ctrlp.vim&lt;/a&gt; assume you don't have a plugin manager. So it tells you to do the runtime path fiddling yourself (which is an incorrect assumption in this case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you read &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27spellfile%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help 'spellfile'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When a word is added while this option is empty Vim will set it for&#xA;you: Using the first directory in 'runtimepath' that is writable.  If&#xA;there is no &quot;spell&quot; directory yet it will be created.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will see that vim uses the first directory that is writable in your runtime path to place the spellfile. The first directory is the ctrlp directory since you used &lt;code&gt;set rtp^=&lt;/code&gt; to prepend the path to the runtime path. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first solution would just be to remove the &lt;code&gt;set rtp^=~/.vim/bundle/ctrlp.vim&lt;/code&gt; line from your vimrc since, that's what pathogen does for you. The second solution would be to change the spellfile with &lt;code&gt;set spellfile=&amp;lt;absolute_path_to_new_file&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As an FYI, a more up-to-date fork of ctrlp is found at &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ctrlpvim/ctrlp.vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="205" LastEditDate="2015-05-09T17:02:48.290" LastActivityDate="2015-05-09T17:02:48.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3221" PostTypeId="1" AcceptedAnswerId="3222" CreationDate="2015-05-09T17:03:46.000" Score="17" ViewCount="712" Body="&lt;p&gt;I do a fair amount of transcription in which I type at 100+ wpm without looking at the screen. I think it would be useful if Vim could give me some sort of audible cue if the spell-checker has just marked the last word (likely indicating that I made a typo and should double-check what I wrote).&lt;/p&gt;&#xA;&lt;p&gt;The spell-checker can definitely syntax-highlight words that are misspelled as soon as I hit the spacebar. How does this work? Is there a way to run some sort of command at the same time?&lt;/p&gt;&#xA;&lt;p&gt;I always use Vim in the terminal; I don't have the terminal bell sound set up right now, but if that is the easiest way to do it, I can probably get that working.&lt;/p&gt;&#xA;" OwnerUserId="2036" LastEditorUserId="23502" LastEditDate="2022-11-02T09:05:36.037" LastActivityDate="2022-11-02T09:05:36.037" Title="How can I have Vim sound the terminal bell when I misspell a word?" Tags="|spell-checking|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3222" PostTypeId="2" ParentId="3221" CreationDate="2015-05-09T19:11:30.530" Score="15" Body="&lt;p&gt;The last misspelled word is not directly accessible, nor can the highlighting be queried. You have to retrieve the word before the cursor yourself, and spell-check that one separately. Fortunately, there's such &lt;code&gt;spellbadword()&lt;/code&gt; function. The following sets up a trigger on each inserted key that checks the last word:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorMovedI * if &amp;amp;spell &amp;amp;&amp;amp; spellbadword(matchstr(strpart(getline('.'), 0, col('.') - 1), '\S\+\s$') )[1] ==# 'bad' | execute &quot;normal! \&amp;lt;C-\&amp;gt;\&amp;lt;C-n&amp;gt;\&amp;lt;Esc&amp;gt;&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of beeping (via the &lt;code&gt;:normal! &amp;lt;Esc&amp;gt;&lt;/code&gt;), you could also invoke an external tool via &lt;code&gt;system()&lt;/code&gt; that plays a brief sound. That would also avoid problems with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; stopping the cursor move, which I've seen happen sometimes.&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2015-05-09T19:43:38.253" LastActivityDate="2015-05-09T19:43:38.253" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3223" PostTypeId="2" ParentId="3196" CreationDate="2015-05-09T21:24:08.147" Score="2" Body="&lt;p&gt;As others have mentioned, window commands are very limited for the cmdline window and there is no way to move the cursor to the previous window while keeping the cmdline window open. Here is a suggestion that, though it won't allow ordinary 'window switching', may simplify returning to look at the content of the buffer from which you summoned the cmdline window.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! JJCmdWinResume()&#xA;    let cmd = 'q:'&#xA;    if exists('g:CmdWinCurPos')&#xA;        let cmd .= ':call setpos(&quot;.&quot;, g:CmdWinCurPos)^M'&#xA;    endif&#xA;    return cmd&#xA;endfunc&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;q JJCmdWinResume()&#xA;&#xA;:autocmd CmdWinEnter * nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;q :let g:CmdWinCurPos = getpos('.')&amp;lt;CR&amp;gt;:q&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to allow storing the position of the cursor in the cmdline window when leaving it, and to allow returning to that cursor position when reentering it. We create a general expression map for &lt;kbd&gt;Leader&lt;/kbd&gt;+&lt;kbd&gt;q&lt;/kbd&gt;that simply evaluates to opening the cmdline window (&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;) if there is no cursor position stored, but if a position is stored, then it also sets the cursor to this position. Then with an &lt;code&gt;autocmd&lt;/code&gt; we set a buffer specific map for the cmdline window, with the same &lt;code&gt;lhs&lt;/code&gt;, that stores the cursor position before quitting the cmdline window. This way you can quit the cmdline window with &lt;kbd&gt;Leader&lt;/kbd&gt;+&lt;kbd&gt;q&lt;/kbd&gt;, look at the buffer you are working on, then reenter the cmdline window with the same keys and continue from where you left off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;^M&lt;/code&gt; in the function is a literal carriage return, to be entered with &lt;kbd&gt;CTRL-V&lt;/kbd&gt;+&lt;kbd&gt;RETURN&lt;/kbd&gt;. (If you yank-put this code you will have to replace the two characters &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;M&lt;/code&gt; in this way.)&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-05-09T21:24:08.147" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3224" PostTypeId="2" ParentId="3213" CreationDate="2015-05-11T11:10:33.660" Score="2" Body="&lt;p&gt;You could build up a list of the matches, delete everything, and then paste the match list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let old_c = @c&#xA;&#xA;let @c=&quot;&quot;&#xA;exec a:firstline .','. a:lastline .'sub//\=setreg(&quot;C&quot;, submatch(0), &quot;l&quot;)/g'&#xA;exec a:firstline .','. a:lastline .'delete _'&#xA;put! c&#xA;&#xA;let @c = old_c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/idbrii/vim-searchsavvy&quot; rel=&quot;nofollow&quot;&gt;vim-searchsavvy&lt;/a&gt; provides a &lt;code&gt;:ClearAllButMatches&lt;/code&gt; command that &lt;a href=&quot;https://github.com/idbrii/vim-searchsavvy/blob/master/autoload/searchsavvy.vim#L28-L49&quot; rel=&quot;nofollow&quot;&gt;uses the above code&lt;/a&gt;. You do your search, call the command, and only text that matched the command remain. Multiple matches on one line will be put on separate lines.&lt;/p&gt;&#xA;" OwnerUserId="2045" LastActivityDate="2015-05-11T11:10:33.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3225" PostTypeId="1" AcceptedAnswerId="3570" CreationDate="2015-05-11T20:26:15.813" Score="28" ViewCount="3819" Body="&lt;p&gt;For switching back from Insert mode I'm used to &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. Now I'm looking to retrain myself to &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; instead of  &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. For that i need to disable &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to help with the retraining.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problems is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;Esc&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;also disables &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt;. For vim they seem to be the same thing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to disable one without the other?&lt;/p&gt;&#xA;" OwnerUserId="2022" LastEditorUserId="2022" LastEditDate="2015-05-11T20:32:17.387" LastActivityDate="2015-06-12T00:08:26.823" Title="Disable &lt;Esc&gt; but keep &lt;C-[&gt;" Tags="|key-bindings|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3227" PostTypeId="1" CreationDate="2015-05-12T03:01:39.820" Score="32" ViewCount="5176" Body="&lt;p&gt;When I try to open a file from multiple vim instances, I get an error with several options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Swap file &quot;~/.vim/tmp/file.swp&quot; already exists!&#xA;[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the difference between &quot;Quit&quot; and &quot;Abort&quot;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first guess was, when I'm trying to open multiple files and only one is being edited elsewhere, &quot;quit&quot; may skip that one and &quot;abort&quot; quit the program, but that is evidently incorrect -- both just abandon the whole attempt at editing and drop back to the terminal.&lt;/p&gt;&#xA;" OwnerUserId="9" LastActivityDate="2017-01-30T15:02:16.030" Title="What's the difference between &quot;quit&quot; and &quot;abort&quot;?" Tags="|swap-file|quit|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3228" PostTypeId="1" CreationDate="2015-05-12T05:23:25.543" Score="4" ViewCount="1382" Body="&lt;p&gt;Looks like the issue is caused by &lt;code&gt;vim-jsx&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  componentDidMount: function() { ▐$.ajax({ });&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I press enter to move $.ajax onto a new line and the top line folds as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;componentDidMount: function() { &#xA;$.ajax({ });&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is really annoying as I have to correct indentation in both lines now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also then I do &lt;code&gt;==&lt;/code&gt; it collapses all indentation as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything I am missing?&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="51" LastEditDate="2015-05-12T23:17:33.100" LastActivityDate="2016-02-08T18:45:24.010" Title="How to prevent vim-jsx from mangling my indentation?" Tags="|formatting|file-formats|plugin-vim-jsx|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3229" PostTypeId="2" ParentId="3227" CreationDate="2015-05-12T06:49:19.607" Score="28" Body="&lt;p&gt;Try this: run &lt;code&gt;vim file1&lt;/code&gt; in a terminal, then run &lt;code&gt;vim -p file1 file2&lt;/code&gt; in a different terminal.  The second command will prompt you as above.  If you answer &lt;code&gt;Quit&lt;/code&gt;, you still get to edit &lt;code&gt;file2&lt;/code&gt;.  If you answer &lt;code&gt;Abort&lt;/code&gt; you just quit Vim, thus &quot;aborting any further commands&quot;.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="1577" LastEditDate="2015-05-12T07:51:11.760" LastActivityDate="2015-05-12T07:51:11.760" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3230" PostTypeId="2" ParentId="3227" CreationDate="2015-05-12T10:41:58.593" Score="6" Body="&lt;p&gt;@FDinoff suggested checking &lt;a href=&quot;http://vimhelp.appspot.com/usr_11.txt.html#swap-exists-choices&quot; rel=&quot;nofollow noreferrer&quot;&gt;the vim help&lt;/a&gt;. In case anyone wanted to see these more easily:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WHAT TO DO?                                     *swap-exists-choices*&#xA;&#xA;If dialogs are supported you will be asked to select one of five choices:&#xA;&#xA;  Swap file &quot;.main.c.swp&quot; already exists! ~&#xA;  [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort, (D)elete it: ~&#xA;&#xA;O  Open the file readonly.  Use this when you just want to view the file and&#xA;   don't need to recover it.  You might want to use this when you know someone&#xA;   else is editing the file, but you just want to look in it and not make&#xA;   changes.&#xA;&#xA;E  Edit the file anyway.  Use this with caution!  If the file is being edited&#xA;   in another Vim, you might end up with two versions of the file.  Vim will&#xA;   try to warn you when this happens, but better be safe then sorry.&#xA;&#xA;R  Recover the file from the swap file.  Use this if you know that the swap&#xA;   file contains changes that you want to recover.&#xA;&#xA;Q  Quit.  This avoids starting to edit the file.  Use this if there is another&#xA;   Vim editing the same file.&#xA;      When you just started Vim, this will exit Vim.  When starting Vim with&#xA;   files in several windows, Vim quits only if there is a swap file for the&#xA;   first one.  When using an edit command, the file will not be loaded and you&#xA;   are taken back to the previously edited file.&#xA;&#xA;A  Abort.  Like Quit, but also abort further commands.  This is useful when&#xA;   loading a script that edits several files, such as a session with multiple&#xA;   windows.&#xA;&#xA;D  Delete the swap file.  Use this when you are sure you no longer need it.&#xA;   For example, when it doesn't contain changes, or when the file itself is&#xA;   newer than the swap file.&#xA;      On Unix this choice is only offered when the process that created the&#xA;   swap file does not appear to be running.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as I can tell abort is for when you use vim to check through multiple files, like so: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim file1.txt file2.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the first one is locked and you call quit, it will go on to file2.txt, whereas abort will break out of the application entirely.&lt;/p&gt;&#xA;" OwnerUserId="2051" LastEditorUserId="11085" LastEditDate="2017-01-30T15:02:16.030" LastActivityDate="2017-01-30T15:02:16.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3231" PostTypeId="1" AcceptedAnswerId="3232" CreationDate="2015-05-12T11:04:21.520" Score="51" ViewCount="16843" Body="&lt;p&gt;Say that I am on line 20 and I would like to yank line 4, how can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And similarly, how can I yank a line relative to my cursor position, say the one 3 lines up?&lt;/p&gt;&#xA;" OwnerUserId="634" LastActivityDate="2024-01-12T14:34:31.153" Title="How to yank a line with a certain line number?" Tags="|cut-copy-paste|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3232" PostTypeId="2" ParentId="3231" CreationDate="2015-05-12T11:26:52.163" Score="71" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#E850&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :yank&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:[range]y[ank] [x]      Yank `[range]` lines [into register x].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So, to yank line 4, one would type:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:4yank&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note you can easily do this from insert mode with &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;; this allows you to&#xA;execute one command, after which you're returned to insert mode; for example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-o&amp;gt;:4yank&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can, of course, also use other ranges. Some examples:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Lines 1 to 3: &lt;code&gt;:1,3yank&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The entire buffer: &lt;code&gt;:%yank&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;From the current line to the end of the buffer: &lt;code&gt;:.,$:yank&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The current line and the next 3: &lt;code&gt;:.,+3yank&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The current line and the previous 3: &lt;code&gt;:-3,.yank&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The line 3 lines above the current line: &lt;code&gt;:-3yank&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The most useful things to remember about ranges:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It's in the form of &lt;code&gt;:line1,line2command&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;A &lt;code&gt;.&lt;/code&gt; is the current line (you can actually omit the dot in most cases; &lt;code&gt;:.,+3yank&lt;/code&gt; and &lt;code&gt;:,+3yank&lt;/code&gt; are the same)&lt;/li&gt;&#xA;&lt;li&gt;You specify lines relative to the current position with &lt;code&gt;+n&lt;/code&gt; and &lt;code&gt;-n&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;By default the lines will be yanked into the default register (&lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;). If you want to use a named register, add a space an then the name of the register (naked, not prefixed with a double quote), eg:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:30,30yank a&#xA;&amp;gt; 10 lines yanked into &amp;quot;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#E16&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help [range]&lt;/code&gt;&lt;/a&gt; for more&#xA;information.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="33210" LastEditDate="2021-01-21T13:39:28.637" LastActivityDate="2021-01-21T13:39:28.637" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3233" PostTypeId="2" ParentId="3231" CreationDate="2015-05-12T12:24:01.880" Score="43" Body="&lt;p&gt;In addition to Carpetsmoker's answer, I should point out the awesome &lt;code&gt;:help :m&lt;/code&gt; and &lt;code&gt;:help :t&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The canonical behavior of &lt;code&gt;:&amp;lt;range&amp;gt;t&amp;lt;address&amp;gt;&lt;/code&gt; and &lt;code&gt;:&amp;lt;range&amp;gt;m&amp;lt;address&amp;gt;&lt;/code&gt; is to copy/move the lines in &lt;code&gt;&amp;lt;range&amp;gt;&lt;/code&gt; &lt;strong&gt;below&lt;/strong&gt; the given &lt;code&gt;&amp;lt;address&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you want to copy line 4 &lt;strong&gt;right below&lt;/strong&gt; the current line you can do this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:4t.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where…&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;4&lt;/code&gt; is the line you want to copy,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt; is the current line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;See &lt;code&gt;:help :range&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you want to copy line 4 &lt;strong&gt;right above&lt;/strong&gt; the current line, you can do this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:4t-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where…&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;4&lt;/code&gt; is still the line to copy,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-&lt;/code&gt; is the line &lt;em&gt;above&lt;/em&gt; the current line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2024-01-12T14:34:31.153" LastActivityDate="2024-01-12T14:34:31.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3234" PostTypeId="1" AcceptedAnswerId="3235" CreationDate="2015-05-12T13:46:44.923" Score="15" ViewCount="3091" Body="&lt;p&gt;How do I check if Vim is compiled as 64-bit or 32-bit from within vimscript? Specifically on Windows.&lt;/p&gt;&#xA;" OwnerUserId="260" LastActivityDate="2019-09-02T09:19:58.473" Title="How to check whether Vim is built as a 32-bit or 64-bit application?" Tags="|vimscript|microsoft-windows|version|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3235" PostTypeId="2" ParentId="3234" CreationDate="2015-05-12T14:02:26.763" Score="16" Body="&lt;p&gt;Testing the value of the &lt;code&gt;win64&lt;/code&gt; feature should tell you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo has(&quot;win64&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the output is &lt;code&gt;1&lt;/code&gt;, then your Vim installation is 64-bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help has()&#xA;:help feature-list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and search for &lt;code&gt;64&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="343" LastEditDate="2019-09-02T09:19:58.473" LastActivityDate="2019-09-02T09:19:58.473" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3238" PostTypeId="5" CreationDate="2015-05-12T19:09:14.863" Score="0" Body="&lt;p&gt;Indentation of code typically involves using whitespace or tabs to help readability. Vi/Vim have many built in ways to both configure and show indentations to make it an automatic process for the user.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="25" LastEditDate="2021-06-23T23:36:31.860" LastActivityDate="2021-06-23T23:36:31.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3239" PostTypeId="4" CreationDate="2015-05-12T19:09:14.863" Score="0" Body="For questions about prefixing lines with whitespace to aid in readability." OwnerUserId="51" LastEditorUserId="25" LastEditDate="2021-06-23T23:36:31.860" LastActivityDate="2021-06-23T23:36:31.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3240" PostTypeId="5" CreationDate="2015-05-12T19:11:09.847" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://geoff.greer.fm/ag/&quot; rel=&quot;nofollow&quot;&gt;The Silver Searcher&lt;/a&gt; is a tool for searching code. It started off as a clone of &lt;a href=&quot;http://beyondgrep.com/&quot; rel=&quot;nofollow&quot;&gt;Ack&lt;/a&gt;, but their feature sets have since diverged slightly. In typical usage, Ag is 5-10x faster than Ack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;nofollow&quot;&gt;the GitHub page&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="24" LastEditDate="2015-09-11T07:24:59.203" LastActivityDate="2015-09-11T07:24:59.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3241" PostTypeId="4" CreationDate="2015-05-12T19:11:09.847" Score="0" Body="A faster alternative for grep; usually installed as the 'ag' command." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-12T19:11:09.847" LastActivityDate="2015-05-12T19:11:09.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3242" PostTypeId="5" CreationDate="2015-05-12T19:13:52.320" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-12T19:13:52.320" LastActivityDate="2015-05-12T19:13:52.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3243" PostTypeId="4" CreationDate="2015-05-12T19:13:52.320" Score="0" Body="File encoding(s) such as ASCII, ISO-8859, UTF-8, etc." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-12T19:13:52.320" LastActivityDate="2015-05-12T19:13:52.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3244" PostTypeId="5" CreationDate="2015-05-12T19:17:11.987" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-12T19:17:11.987" LastActivityDate="2015-05-12T19:17:11.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3245" PostTypeId="4" CreationDate="2015-05-12T19:17:11.987" Score="0" Body="Comments are programmer-readable annotations in source code which are ignored by the parser." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-12T19:17:11.987" LastActivityDate="2015-05-12T19:17:11.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3246" PostTypeId="2" ParentId="3231" CreationDate="2015-05-12T21:32:22.990" Score="3" Body="&lt;p&gt;Simply type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:4y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to yank line 4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it will go into the unnamed register. Then, (for example) you can use &lt;code&gt;p&lt;/code&gt; to put it elsewhere. You can also use &lt;code&gt;[n]p&lt;/code&gt;, e.g. 10p to paste it 10 times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can put it into a named register such as &quot;a&quot; with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:4y a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2041" LastEditorUserId="15" LastEditDate="2015-06-15T14:05:18.120" LastActivityDate="2015-06-15T14:05:18.120" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3247" PostTypeId="5" CreationDate="2015-05-12T23:17:52.367" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/mxw/vim-jsx&quot; rel=&quot;nofollow&quot;&gt;Homepage&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-12T23:17:52.367" LastActivityDate="2015-05-12T23:17:52.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3248" PostTypeId="4" CreationDate="2015-05-12T23:17:52.367" Score="0" Body="React JSX syntax highlighting and indenting for Vim." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-12T23:17:52.367" LastActivityDate="2015-05-12T23:17:52.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3249" PostTypeId="2" ParentId="3179" CreationDate="2015-05-12T23:58:06.457" Score="2" Body="&lt;p&gt;I can reproduce this; and the problem seems to be that this keyboard layout doesn't send any characters on&#xA;&lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-#&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;C-\&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I managed to figure this out (and more importantly: fix it) by using the&#xA;&lt;a href=&quot;https://msdn.microsoft.com/en-us/goglobal/bb964665.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;Microsoft Keyboard Layout&#xA;Creator&lt;/a&gt;, or MSKLC for&#xA;short. You'll need to download &amp;amp; install it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the normal UK layout:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fxNGK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here's the Extenxed UK layout:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/CfHcQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice the &lt;code&gt;[&lt;/code&gt;, &lt;code&gt;]&lt;/code&gt;, &lt;code&gt;#&lt;/code&gt;, and &lt;code&gt;\&lt;/code&gt; are blank?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, to fix this, I did:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Go to &quot;File -&gt; Load existing keyboard&quot;.&lt;/li&gt;&#xA;&lt;li&gt;Choose &quot;United Kingdom Extended&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Check the &quot;Ctrl&quot; checkbox on the left, and click on each of the problematic keys; filling&#xA;in the values below that I copied from the UK keyboard layout (you need to&#xA;click 'Advanced view' before you get to see the &lt;code&gt;Ctrl+&amp;lt;key&amp;gt;&lt;/code&gt; field in the popup dialog):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[&lt;/code&gt; -&gt; U+001b, scan code 1a&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;]&lt;/code&gt; -&gt; U+001d, scan code 1b&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;#&lt;/code&gt; -&gt; U+001c, scan code 2b (this is above the enter key)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\&lt;/code&gt; -&gt; U+001c, scan code 56 (this is between the Z and left shift)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After this, I saved the &quot;source file&quot; (not required, I think), and went to&#xA;&quot;Project -&gt; Build DLL an setup package&quot; to make a &lt;code&gt;setup.exe&lt;/code&gt;; after running&#xA;this I have my &quot;UK Extended (custom)&quot; layout.&lt;br&gt;&#xA;Strangely, this shows up as&#xA;&quot;Welsh&quot;, and not 'English', but does seem to work. But after removing and adding it again from the&#xA;control panel, it does show up as Enlish...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be aware that Windows has a Left-shift+Left Alt shortcut to switch keyboard layouts, which is very ease to accidentally use. And I've also experienced some special magic-fu method to automatically switch keyboard layout depending on the locale off the application. To minimize the confusion, I've always found it best to remove all keyboard layouts except the ones you really need (you can always re-add them later) (SU also has some info, &lt;a href=&quot;https://superuser.com/questions/66561/how-to-avoid-keyboard-layout-automatically-changing-on-windows?s=1|0.0000&quot;&gt;for example here&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclaimer: I only tested this with my US-international keyboard, as I don't own a UK keyboard. But I believe this should fix your problem :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-03-20T10:04:45.077" LastActivityDate="2015-05-12T23:58:06.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3250" PostTypeId="1" AcceptedAnswerId="3256" CreationDate="2015-05-13T00:47:53.830" Score="8" ViewCount="3013" Body="&lt;p&gt;I'm currently using vim-dispatch to run tests on my code which outputs the test results to the quickfix panel via tmux. However, all colors seem to be disabled in the output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's &lt;a href=&quot;https://github.com/tpope/vim-dispatch/issues/51&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; two year old issue where tpope talks about it a bit, but that's all i've managed to find.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to colorize the quickfix output to improve legibility?&lt;/p&gt;&#xA;" OwnerUserId="2061" LastEditorUserId="51" LastEditDate="2015-05-13T01:02:36.330" LastActivityDate="2015-05-13T05:15:57.290" Title="Showing colors in vim's quickfix window from Dispatch tasks" Tags="|quickfix|plugin-dispatch|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3251" PostTypeId="5" CreationDate="2015-05-13T01:03:16.077" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow&quot;&gt;Homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-13T01:03:16.077" LastActivityDate="2015-05-13T01:03:16.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3252" PostTypeId="4" CreationDate="2015-05-13T01:03:16.077" Score="0" Body="Asynchronous build and test dispatcher." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-13T01:03:16.077" LastActivityDate="2015-05-13T01:03:16.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3253" PostTypeId="1" AcceptedAnswerId="3258" CreationDate="2015-05-13T01:03:53.513" Score="1" ViewCount="822" Body="&lt;p&gt;I have the following one-line &lt;code&gt;~/.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Line 1/1: &lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;ESC&amp;gt; :nohlsearch&amp;lt;CR&amp;gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever I edit a new document, now, I am placed immediately in Replace mode after opening the file (&lt;code&gt;vim file.txt&lt;/code&gt; opens the file in Vim placing me directly in replace mode). Does anyone know what might be happening (I have included my Vim version below for more information).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:39:32)&#xA;Included patches: 1-52&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian. Compiled by buildd@&#xA;&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;-clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   -perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python          +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            -ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            +mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;system vimrc file: &quot;$VIM/vimrc&quot;&#xA;    user vimrc file: &quot;$HOME/.vimrc&quot;&#xA;2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;    user exrc file: &quot;$HOME/.exrc&quot;&#xA;fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl    -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions `&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2062" LastEditorUserId="51" LastEditDate="2015-05-13T01:08:54.470" LastActivityDate="2015-05-13T05:49:12.430" Title="vimrc Line Placing me In Replace Mode" Tags="|vimrc|replace|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3254" PostTypeId="1" AcceptedAnswerId="3255" CreationDate="2015-05-13T02:16:10.297" Score="4" ViewCount="1274" Body="&lt;p&gt;I want to add a new item to Vim context menu. I select a word, right click on the word, select the new menu item, auto delete rows contain selected word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should i do?&lt;/p&gt;&#xA;" OwnerUserId="2063" LastActivityDate="2015-05-13T04:52:54.870" Title="How to add an item to Vim context menu?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3255" PostTypeId="2" ParentId="3254" CreationDate="2015-05-13T04:35:09.607" Score="7" Body="&lt;p&gt;The menu you are referring to is called &quot;PopUp&quot;. To create new menu entries you use the command &lt;code&gt;menu&lt;/code&gt; (It has all the same variations as &lt;code&gt;map&lt;/code&gt;, plus a special one &lt;code&gt;amenu&lt;/code&gt; for all modes)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following command will add a PopUp menu that will delete all rows containing the word under the cursor when you right click.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremenu PopUp.Delete\ Rows :&amp;lt;c-u&amp;gt;g/\&amp;lt;&amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;\&amp;gt;/d&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this creates an menu entry called &quot;Delete Rows&quot;, when you click it will run &lt;code&gt;:&amp;lt;c-u&amp;gt;g/\&amp;lt;&amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;\&amp;gt;/d&amp;lt;cr&amp;gt;&lt;/code&gt;. The command it is running is a global command that deletes every line that contains the word under the cursor. The word under the cursor is retrieved with &lt;code&gt;&amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To change the location in the list you need to modify the priority of the menu command. To do this you can place &lt;code&gt;.&amp;lt;number&amp;gt;&lt;/code&gt;. (The dot represents that we are in a submenu). The number represents how high in the list the menu item will be. So &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremenu .1 PopUp.Delete\ Rows :&amp;lt;c-u&amp;gt;g/\&amp;lt;&amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;\&amp;gt;/d&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will probably be placed first in the list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To find out the priorities of the entries in the PopUp menu you can run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;menu PopUp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and look at the numbers left of the menu item. If you don't specify a priority, the menu item will be assigned a priority of 500.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Required readings &lt;code&gt;:help menu&lt;/code&gt;, &lt;code&gt;:help sub-menu-priority&lt;/code&gt;, &lt;code&gt;:help c_CTRL-R_CTRL-W&lt;/code&gt; and &lt;code&gt;:help :global&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After doing all of this, you should take note that learning how to use vim commands would be faster. For instance all you need to do is hit &lt;code&gt;*&lt;/code&gt; on the word you want to delete and then run &lt;code&gt;:g//d&lt;/code&gt; to delete all lines containing that word. &lt;code&gt;*&lt;/code&gt; searches for the word under the cursor, and if you leave out the regex in &lt;code&gt;g&lt;/code&gt; it uses the last search.&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2015-05-13T04:52:54.870" LastActivityDate="2015-05-13T04:52:54.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3256" PostTypeId="2" ParentId="3250" CreationDate="2015-05-13T05:13:28.497" Score="12" Body="&lt;p&gt;If you want your tests to embed colour codes (presumably ANSI) in their output and then have the colours show in the quickfix window, you're out of luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the quickfix buffer is just a buffer, you can add highlighting patterns to it.  For example to highlight &lt;code&gt;Ok:&lt;/code&gt; and &lt;code&gt;Err:&lt;/code&gt; you could create a file &lt;code&gt;~/.vim/after/syntax/qf.vim&lt;/code&gt;, with contents something like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight TestOk    ctermbg=green&#xA;highlight TestError ctermbg=red&#xA;&#xA;syn match TestOk    &quot;\&amp;lt;Ok:&quot;&#xA;syn match TestError &quot;\&amp;lt;Err:&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just make sure to write the regexps in the &lt;code&gt;syn&lt;/code&gt; clauses so that they don't match the filename or the error column.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-05-13T05:13:28.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3257" PostTypeId="2" ParentId="3250" CreationDate="2015-05-13T05:15:57.290" Score="4" Body="&lt;p&gt;Color is represented using ansi escape sequences. On my computer &lt;code&gt;^[[0m^[[01;34mWord^[[0m&lt;/code&gt; represents a blue word. (&lt;code&gt;^[&lt;/code&gt; is the escape character`) Obviously this isn't useful to have in the output if you are writing to a file. So most program recognize that they are not writing to a tty and suppress the color output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the program you are running supports it you can force it to output the ansi escape sequences anyways and then use the plugin &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=302&quot; rel=&quot;nofollow&quot;&gt;AnsiEsc.vim&lt;/a&gt; with the &lt;code&gt;:AnsiEsc&lt;/code&gt; command to conceal the ansi escape output and colorize the output. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However this will most likely break all the parsing that the quick fix window does for you and it will still show the escape sequences if you aren't in the quick fix window since it is only concealing them.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A better options would be to write a highlight script that highlights the output in the quickfix window.&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2015-05-13T05:15:57.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3258" PostTypeId="2" ParentId="3253" CreationDate="2015-05-13T05:26:55.203" Score="4" Body="&lt;p&gt;Mapping anything to &lt;kbd&gt;Esc&lt;/kbd&gt; is a really bad idea.  I suggest someyhing like this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;M-\&amp;gt;  :set hlsearch!&amp;lt;CR&amp;gt;&amp;lt;Bar&amp;gt;:echo 'hlsearch: ' . {0:'Off', 1:'On'}[&amp;amp;hlsearch]&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;kbd&gt;Meta&lt;/kbd&gt;-&lt;kbd&gt;\&lt;/kbd&gt; toggles &lt;code&gt;hlsearch&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="1577" LastEditDate="2015-05-13T05:49:12.430" LastActivityDate="2015-05-13T05:49:12.430" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3259" PostTypeId="1" AcceptedAnswerId="3263" CreationDate="2015-05-13T08:03:38.247" Score="5" ViewCount="447" Body="&lt;p&gt;VIM knows to identify the start and end of code functions with the &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]}&lt;/code&gt; commands. &lt;strong&gt;How might I use this to colour the gutters or line number backgrounds differently for each function?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is that I often maintain large PHP files written by inexperienced people who lack the concept of maintainability. These files often contain tens of function definitions each spanning thousands of lines. My current nightmare is a function that spans over 3000 lines in a file of 18000 lines. Narrowing plugins don't work very well with PHP (I'll elaborate on that in the comments if needed) so I need another way of determining when I've &lt;code&gt;n&lt;/code&gt;ed into another function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My line of thinking is to base a random colour on a hash of the function name, and use that colour as the background for the line numbers. I've gone up and down the vim documentation and googling but have come up with absolutely nothing that could help me. I'm using standard VIM in a KDE Konsole session on Kubuntu:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 20 2014 16:09:22)&#xA;Included patches: 1-273&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by buildd@&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;-clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   -perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python          +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            -ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            +mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl    -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="989" LastActivityDate="2015-05-13T14:53:08.860" Title="Different gutter colours for each code function" Tags="|colorscheme|line-numbers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3260" PostTypeId="2" ParentId="3259" CreationDate="2015-05-13T08:22:27.743" Score="3" Body="&lt;p&gt;You can't highlight line numbers individually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Signs may help you but you would need to place an awful lot of them to achieve your goal. See &lt;code&gt;:help signs&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I find myself in a similar situation, I just use folding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;zM    &quot; close every fold&#xA;zA    &quot; open the current fold &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-05-13T08:22:27.743" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3261" PostTypeId="1" CreationDate="2015-05-13T09:34:56.933" Score="18" ViewCount="519" Body="&lt;p&gt;Often when I'm in Insert mode, I'll hit &lt;kbd&gt;Esc&lt;/kbd&gt; to get into Normal mode, and then immediately hit &lt;kbd&gt;O&lt;/kbd&gt; to begin a new line above the cursor and go into Insert mode there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I do that, there is a 1-second delay after I hit the &lt;kbd&gt;O&lt;/kbd&gt; before there is any visible response. Furthermore if I begin typing the new text during that 1-second delay, if the new text begins with any of a certain set of characters (e.g. &lt;kbd&gt;j&lt;/kbd&gt;,&lt;kbd&gt;k&lt;/kbd&gt;,&lt;kbd&gt;m&lt;/kbd&gt;,&lt;kbd&gt;n&lt;/kbd&gt;,&lt;kbd&gt;o&lt;/kbd&gt;), I end up in the middle of some other operation I didn't intend, often making a mess, at which point I have to stop and fumble around with undos and redos until I am reasonably sure I have undone the damage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid that unpleasantness, I've gotten in the habit of pausing for one second after every time I type &lt;kbd&gt;O&lt;/kbd&gt;. But this slows me down and prevents me from being the vim speed demon I would otherwise be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What causes this? Is there a fix or workaround?&lt;/p&gt;&#xA;" OwnerUserId="2065" LastEditorUserId="1154" LastEditDate="2015-05-13T15:26:41.013" LastActivityDate="2015-05-27T01:20:35.457" Title="Speed bump on &lt;Esc&gt;O (Insert to Normal to Insert new line above cursor)" Tags="|insert-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3262" PostTypeId="2" ParentId="3261" CreationDate="2015-05-13T10:49:58.233" Score="17" Body="&lt;p&gt;This happens only in the terminal, but not in GVIM, right? The reason is that Vim cannot distinguish between the individual types keys and an ANSI Escape sequence starting with the same keys (i.e. &lt;code&gt;^[O...&lt;/code&gt;, &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; followed by &lt;code&gt;O&lt;/code&gt; in your case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read about all the underlying complexities at &lt;code&gt;:help 'timeout'&lt;/code&gt; (and following options). There you also find a suggested configuration that alleviates the problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set timeout timeoutlen=1000 ttimeoutlen=100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-13T10:49:58.233" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3263" PostTypeId="2" ParentId="3259" CreationDate="2015-05-13T14:53:08.860" Score="6" Body="&lt;p&gt;Here's a different solution which may be of help: put the current function name in the &lt;code&gt;statusline&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EAUKa.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim doesn't really have a concept of a &quot;dynamic&quot; statusline; but we can work around that by setting a new statusline on certain autocmd events and/or key mappings.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;First, let us define a statusline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=&#xA;let &amp;amp;statusline .= '%&amp;lt;%f '        &quot; Filename, truncate right&#xA;let &amp;amp;statusline .= '%h%m%r'       &quot; [Help] [modified] [read-only]&#xA;let &amp;amp;statusline .= &quot; PHP_FUN &quot;&#xA;&#xA;&quot; Save the statusline, we need this later&#xA;let g:original_statusline = &amp;amp;statusline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since you can't append a part to the statusline (the default is empty), you need to &quot;re-create&quot; the original which is what the first 3 lines do. We will replace the text &lt;code&gt;PHP_FUN&lt;/code&gt; later on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#E542&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'statusline'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/17.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chapter 17 of Learn Vimscript the Hard Way&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Next, we need some code to get the PHP function name, and put that in the statusline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! PHPFunctionInStatusLine()&#xA;    &quot; Not a PHP file; remove the &quot;PHP_FUN&quot; part&#xA;    if &amp;amp;filetype != 'php'&#xA;        let &amp;amp;statusline = substitute(g:original_statusline, 'PHP_FUN', '', '')&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; Save the cursor position&#xA;    let l:save_cursor = getpos(&quot;.&quot;)&#xA;&#xA;    &quot; Search for the previous function definition&#xA;    call search('\s\=function\s', 'bc')&#xA;&#xA;    &quot; Get this line, and prepare it for displaying&#xA;    let l:line = substitute(getline('.'), '^\s*', '', '')&#xA;    let l:line = substitute(l:line, ' \={ \=', '', '')&#xA;&#xA;    &quot; Put it in the statusline&#xA;    let &amp;amp;statusline = substitute(g:original_statusline, 'PHP_FUN', ' ' . l:line . ' ', '')&#xA;&#xA;    &quot; Go back to where we were&#xA;    call setpos('.', l:save_cursor)&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The contents of this function should be obvious: we used the saved &lt;code&gt;g:original_statusline&lt;/code&gt; variable as a &quot;template&quot;, try to find a function, and put it in place of &lt;code&gt;PHP_FUN&lt;/code&gt;. For non-PHP files we blank this out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can run &lt;code&gt;:call PHPFunctionInStatusLine()&lt;/code&gt;, and you should see something like the screenshot above.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To make it fill in the function name &lt;em&gt;automatically&lt;/em&gt;, we can define some autocommands, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup php&#xA;    autocmd!&#xA;    &quot; When entering the buffer&#xA;    autocmd BufEnter * call PHPFunctionInStatusLine()&#xA;&#xA;    &quot; Starting &amp;amp; leaving Insert mode&#xA;    autocmd InsertEnter,InsertLeave *.php call PHPFunctionInStatusLine()&#xA;&#xA;    &quot; The user doesn't press a key for a while in normal &amp;amp; insert mode&#xA;    autocmd CursorHold,CursorHoldI *.php call PHPFunctionInStatusLine()&#xA;&#xA;    &quot; Moving the cursor in normal &amp;amp; insert mode&#xA;    &quot; This won't be very fast!&#xA;    &quot;autocmd CursorMoved,CursorMovedI *.php call PHPFunctionInStatusLine()&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The status line won't be updated instantly when you move to a new function, you can achieve that with the &lt;code&gt;CursorMoved&lt;/code&gt; autocmd, but this is run every time the cursor is moved, so this won't be very fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also strategically run this function on some key mappings, for example for &lt;code&gt;n&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap n n:silent call PHPFunctionInStatusLine()&amp;lt;CR&amp;gt;&#xA;nnoremap N N:silent call PHPFunctionInStatusLine()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will first run &lt;code&gt;n&lt;/code&gt;, and immediately after that this function to update the statusline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another useful mapping might be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;:silent call PHPFunctionInStatusLine()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will update the statusline after we've pressed the enter key in the Vim command-line.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-05-13T14:53:08.860" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3264" PostTypeId="2" ParentId="3261" CreationDate="2015-05-13T16:28:29.933" Score="5" Body="&lt;p&gt;As a workaround, instead of &#xA;&lt;kbd&gt;ESC&lt;/kbd&gt;&lt;kbd&gt;O&lt;/kbd&gt;, use &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;O&lt;/kbd&gt;&lt;kbd&gt;O&lt;/kbd&gt;. The &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;O&lt;/kbd&gt; puts you in normal mode for one command, then returns you to insert mode when it is done.&lt;/p&gt;&#xA;" OwnerUserId="1149" LastEditorUserId="1149" LastEditDate="2015-05-27T01:20:35.457" LastActivityDate="2015-05-27T01:20:35.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3265" PostTypeId="2" ParentId="3261" CreationDate="2015-05-13T17:49:28.953" Score="1" Body="&lt;p&gt;How about:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; &lt;kbd&gt;O&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some &lt;a href=&quot;https://unix.stackexchange.com/questions/53633/does-using-ctrlc-instead-of-esc-to-exit-insert-mode-break-anything-in-vi&quot;&gt;subtleties&lt;/a&gt; when using &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; you should be aware of.&lt;/p&gt;&#xA;" OwnerUserId="2075" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2015-05-13T17:49:28.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3267" PostTypeId="1" CreationDate="2015-05-13T19:05:48.983" Score="5" ViewCount="4319" Body="&lt;p&gt;Suppose I have a file that contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Time: 60 minutes&#xA;Seconds: 3600&#xA;Milliseconds: 36000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to replace any word with &lt;code&gt;seconds&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/seconds/time/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am looking for is after the replace,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Time: 60 minutes&#xA;Time: 3600&#xA;MilliTime: 36000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, I would like to know how I can be more specific about only replacing lines that have Seconds in the string, and avoiding the others if there were more than just these 3 lines.&lt;/p&gt;&#xA;" OwnerUserId="2077" LastEditorUserId="205" LastEditDate="2015-05-13T23:22:39.043" LastActivityDate="2015-05-13T23:22:39.043" Title="How to replace specific lines with regex?" Tags="|regular-expression|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3268" PostTypeId="2" ParentId="3267" CreationDate="2015-05-13T19:33:21.987" Score="8" Body="&lt;p&gt;Swapping via regular expressions is performed by the ex command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:{range}s/pattern/string/{flags} {count}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you wish to replace instances of a work on a specific line you can supply the exact line with the absolute location. To swap matches only on line 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:2s/Seconds/time&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can use a relative location using &lt;code&gt;-/+&lt;/code&gt;. To swap only on a line two above the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:-2s/Seconds/time&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Range can also be defined by using visual mode to select the area to perform the search. Visually select a region and press &lt;code&gt;:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/Second/time&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ranges can also be absolute or relative&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:2,4s/Second/time&#xA;:-2,+2s/Second/time&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first does lines 2 through 4 and the second does 2 lines above the cursor to two lines below the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to swap all cases you can supply the range and the flag &lt;code&gt;g&lt;/code&gt; which finds all matches. Supply the &lt;code&gt;%&lt;/code&gt; range for the entire document.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/Seconds/time/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some commonly used flags are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;c&lt;/code&gt;: Confirms each substitution (yes/no/abort/quit)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g&lt;/code&gt;: Replace all occurrences in a line. Without this flag only the first instance on a line is swapped.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;i&lt;/code&gt;: Ignore the case of the pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;I&lt;/code&gt;: DO NOT ignore the case of the pattern&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For further information check out the built in help &lt;code&gt;:h :substitute&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2015-05-13T19:41:13.337" LastActivityDate="2015-05-13T19:41:13.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3270" PostTypeId="2" ParentId="3267" CreationDate="2015-05-13T22:28:16.830" Score="3" Body="&lt;p&gt;Aside from jecxjo's answer, there are also 2 other ways to replace only &lt;code&gt;seconds&lt;/code&gt; and leave milliseconds` alone (without using ranges, which may be unwieldy for large files):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Anchor the pattern to the start of the line with &lt;code&gt;^&lt;/code&gt;: &lt;code&gt;%s/^seconds/time/&lt;/code&gt;; works in this specific case, but (obviously) won't work if you have an instance of &lt;code&gt;seconds&lt;/code&gt; somewhere that &lt;em&gt;isn't&lt;/em&gt; at the start of the line&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;More flexible is using a &quot;word&quot; match: &lt;code&gt;%s/\&amp;lt;seconds\&amp;gt;/time/&lt;/code&gt;. The &lt;code&gt;\&amp;lt;&lt;/code&gt; matches the &quot;beginning of a word&quot;, and the &lt;code&gt;\&amp;gt;&lt;/code&gt; matches the &quot;end of a word&quot;; so adding them both only matches if &lt;code&gt;seconds&lt;/code&gt; is a word on it's own (and not part of a word); in this case, you could also use &lt;code&gt;:%s/\&amp;lt;seconds/time/&lt;/code&gt;, because in &lt;code&gt;milliseconds&lt;/code&gt;, &lt;code&gt;seconds&lt;/code&gt; isn't at the start of the word.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-05-13T22:28:16.830" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3271" PostTypeId="1" CreationDate="2015-05-14T05:50:06.533" Score="1" ViewCount="163" Body="&lt;p&gt;My directory structure is as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vim/ &#xA;-vim74/&#xA;   -autoload/&#xA;   -emmet-vim-master/&#xA;      -autoload&#xA;          -emmet/&#xA;      -plugin&#xA;      -doc&#xA;  -plugin/&#xA;  -color/&#xA;  -ftplugin/&#xA;-vimfiles/&#xA;  -autoload/&#xA;      -vim-pathogen-master&#xA;  -bundle/&#xA;      -vim-kolor-master/&#xA;      -emmet-vim-master/&#xA;&#xA;  -plugin&#xA;-_vimrc&#xA;-_vimrc~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to install vim plugin but can't. Where am I missing ?&lt;/p&gt;&#xA;" OwnerUserId="2086" LastEditorUserId="1841" LastEditDate="2018-10-09T14:37:16.550" LastActivityDate="2018-10-09T14:37:16.550" Title="I am unable to install emmet plugin on windows" Tags="|microsoft-windows|plugin-emmet-vim|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3272" PostTypeId="1" CreationDate="2015-05-14T07:19:57.877" Score="4" ViewCount="219" Body="&lt;p&gt;I'd like to create a new symbol to use in my vimrc that's &lt;code&gt;&amp;lt;normal&amp;gt;&lt;/code&gt;, so I do not have to type &lt;code&gt;&amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; to get to do the &quot;go to normal mode&quot; command, nor clutter the vimrc file with combinations that I might not remember.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In C it would have been done with &lt;code&gt;#define&lt;/code&gt;, how is this done in VimL?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C like example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define &amp;lt;normal&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;&#xA;&#xA;nmap &amp;lt;leader&amp;gt;q &amp;lt;normal&amp;gt;@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;q &amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2082" LastEditorUserId="895" LastEditDate="2015-05-14T13:16:32.423" LastActivityDate="2017-01-30T10:54:25.473" Title="Is there a way to make preprocessor definitions in vimrc?" Tags="|vimscript|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3273" PostTypeId="1" CreationDate="2015-05-14T09:07:03.787" Score="1" ViewCount="250" Body="&lt;p&gt;I'm using the server mode in vim and already have an instance open with a couple of files in.  I'd like to add the contents of a session file to this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However doing &lt;code&gt;vim --servername vim -S mySessionFile&lt;/code&gt; ends up opening it in a new server (VIM1 - from doing &lt;code&gt;:echo v:servername&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried &lt;code&gt;vim --servername vim --remote-silent -S .\vimSession&lt;/code&gt; which opened in the correct instance but perhaps not surprisingly just added two new buffers for the final two arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also doesnt work:&lt;code&gt;vim --servername vim -S .\vimSession --remote-silent&lt;/code&gt;!&#xA;It complains of missing arguments (its expecting a file list), and if you add one in then it just ignores the session parameter and gives a blank buffer with the name&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="1518" LastActivityDate="2015-10-31T14:22:11.473" Title="How do you open a session in an existing server?" Tags="|microsoft-windows|sessions|clientserver|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3274" PostTypeId="2" ParentId="3271" CreationDate="2015-05-14T10:15:19.137" Score="3" Body="&lt;p&gt;You are missing the fact that Vim's default runtime files and directories are off limits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put your plugins in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%userprofile%\vimfiles\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and your settings in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%userprofile%\vimfiles\vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For non-Windows users, plugins go into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and settings go into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you still use 7.3 or share your config between machines that have 7.3 or 7.4, you can keep the scheme above and add this line to &lt;code&gt;%userprofile%\_vimrc&lt;/code&gt; (on Windows) or &lt;code&gt;~/.vim&lt;/code&gt;(on other systems):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-05-14T10:15:19.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3275" PostTypeId="2" ParentId="3272" CreationDate="2015-05-14T13:37:15.843" Score="4" Body="&lt;p&gt;VimL doesn't have preprocessor macros.  You can still do it, sort of, but I'm afraid it's a case of a medicine being worse than the disease it's supposed to cure:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-viml prettyprint-override&quot;&gt;&lt;code&gt;let normal = '&amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;'&#xA;exe 'nmap &amp;lt;leader&amp;gt;q ' . normal . '@q'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="343" LastEditDate="2017-01-30T10:54:25.473" LastActivityDate="2017-01-30T10:54:25.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3276" PostTypeId="1" AcceptedAnswerId="3278" CreationDate="2015-05-14T15:28:51.583" Score="4" ViewCount="1217" Body="&lt;p&gt;I've the following example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -E http://example.com/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where I'd like to search for &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that search only works when the lines are separated, but when the lines are joined together (&lt;code&gt;%j&lt;/code&gt;) then it doesn't work and it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Search hit BOTTOM, continuing at TOP&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What I'm doing is simply:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&amp;lt;head&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above search works when lines are separated, but not when everything is in one line (just run &lt;code&gt;%j&lt;/code&gt; before doing search).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea why or how to search properly for pattern in Ex mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm expecting after search that the cursor would be placed under the found pattern (similar as in visual mode), so I'm able to perform further changes (for example removing inner tag content by: &lt;code&gt;norm vitd&lt;/code&gt;), but it doesn't work when the cursor is not placed on the tag it-self. In other words it seems to work only when the tag is at the beginning of the line, but not when it's in the middle.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-05-14T20:10:25.357" LastActivityDate="2015-05-14T21:23:21.550" Title="How to search in Ex mode and place the cursor on the matched pattern?" Tags="|search|ex-mode|filetype-html|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3277" PostTypeId="1" CreationDate="2015-05-14T15:40:40.130" Score="6" ViewCount="2900" Body="&lt;p&gt;HackerRank.com allows to solve their own set of programming problems with an online editor wich supports Emacs, Vim and 'Normal' modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Vim mode can't really replace a customized local vim and after a while is very annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking for a way to solve HRank problems from my local vim session and somehow submit the code through vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Already tried this plugins, with no success:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/pankajmore/hackerrank.vim&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/pankajmore/hackerrank.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/jaspal-dhillon/hackerrank&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/jaspal-dhillon/hackerrank&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;They don't seem to be active anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect it should be a very common problem. Any working solution around? Or suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Worst case scenario is to write it myself, but won't be my favourite task and I don't want to reinvent the wheel...&lt;/p&gt;&#xA;" OwnerUserId="2022" LastEditorUserId="2022" LastEditDate="2015-05-15T07:20:18.783" LastActivityDate="2015-05-15T10:07:05.947" Title="Vim to edit and submit to [Hackerrank]" Tags="|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3278" PostTypeId="2" ParentId="3276" CreationDate="2015-05-14T17:25:07.437" Score="2" Body="&lt;p&gt;In vim we can read (&lt;code&gt;:help :range&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;/{pattern}[/]&lt;/code&gt;   - the next line where {pattern} matches&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That means if there is no next line - no match can be found, because there is only one current line (all lines together).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to search starting from the first/current line, we need to use &lt;code&gt;0;/foo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;0;/that&lt;/code&gt;         - the first line containing &quot;that&quot;, also matches in the first line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However specifying &lt;code&gt;;&lt;/code&gt; makes that the cursor isn't moved, so as workaround, you can manually jump to the next found phrase by: &lt;code&gt;norm n&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-05-14T21:23:21.550" LastActivityDate="2015-05-14T21:23:21.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3279" PostTypeId="1" AcceptedAnswerId="3281" CreationDate="2015-05-14T18:31:06.790" Score="4" ViewCount="1012" Body="&lt;p&gt;I have a log file for what should be simple counter values, formatted as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0 1 2 3 4 5 6 7&#xA;8 9 10 11 12 13 14 15&#xA;16 17 18 19 20 21 22 23&#xA;etc...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm looking for a way to find if there's anywhere in the log where the counter glitched, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0 3 2 3 4 5 6 7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;0 3 2&lt;/code&gt; part is erroneous and what I'm looking to find. Is there a way to do this in vim? Eg, something along the lines of &lt;code&gt;/\(\d\+\)\s\(\=submatch(1)+1\)\@!&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that vim supports &lt;code&gt;\=submatch()&lt;/code&gt; but that can only be used in the &lt;code&gt;:substitute&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="889" LastActivityDate="2015-05-14T19:45:07.257" Title="Arithmetic in Regular Expression?" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3280" PostTypeId="2" ParentId="3276" CreationDate="2015-05-14T19:04:29.583" Score="1" Body="&lt;pre&gt;&lt;code&gt;$ vim http://example.com/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't download anything so your buffer is empty and the search reaches the end of the buffer without finding anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim http://example.com/index.html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;actually downloads a file and populates the buffer, which allows you to search for &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&amp;lt;head&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;find the first line containing that pattern, make it the current line and print it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TACxl.gif&quot; alt=&quot;Ex mode&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's nothing complicated, here.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-05-14T19:04:29.583" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3281" PostTypeId="2" ParentId="3279" CreationDate="2015-05-14T19:07:35.043" Score="8" Body="&lt;p&gt;I doubt Vim's regex's are powerful enough to handle that kind of pattern. However you can use any kind of generic programing language to fit your need. Here is an awk version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!awk '{for(i=1;i&amp;lt;=NF;i++) { if(i+$1-1\!=$i) { print; break;}}}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;code&gt;!&lt;/code&gt; command to filter the entire file, &lt;code&gt;%&lt;/code&gt;, with an awk program that verifies each field is ascending correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: the &lt;code&gt;!&lt;/code&gt; in &lt;code&gt;!=&lt;/code&gt; needs to be escaped as it has special meaning to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h filter&#xA;:h range&#xA;:h :!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-05-14T19:07:35.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3282" PostTypeId="1" AcceptedAnswerId="3284" CreationDate="2015-05-14T19:14:00.323" Score="5" ViewCount="415" Body="&lt;p&gt;&lt;code&gt;synID()&lt;/code&gt; lets you get the syntax ID associated with a particular character at a particular line and column. This syntax ID is useful for querying other aspects of the syntax highlighting group (such as the name, colors, et cetera).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've &lt;a href=&quot;https://github.com/jpetrie/vim-mixology&quot; rel=&quot;noreferrer&quot;&gt;written a plugin&lt;/a&gt; that uses &lt;code&gt;synID&lt;/code&gt; to let you interactively tweak the color of specific groups. I would like to &lt;a href=&quot;https://github.com/jpetrie/vim-mixology/issues/2&quot; rel=&quot;noreferrer&quot;&gt;support editing groups that don't ever appear in the document text&lt;/a&gt; (the cursor can never be over those, generally). The most reasonable way to do this would require me to look up a syntax ID based on the group's name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a built-in function to look up this mapping? Or do I need to build a look-up table myself?&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-05-14T19:51:49.040" Title="How can I get the syntax ID of a named group?" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3283" PostTypeId="2" ParentId="3279" CreationDate="2015-05-14T19:45:07.257" Score="3" Body="&lt;p&gt;Unlike Perl, Vim does not allow Vimscript expressions inside a &lt;code&gt;{pattern}&lt;/code&gt;, so you're limited to textual interpretation. With a sufficiently complex pattern, you could do some such assertions (using look-behind and look-ahead, as in &lt;em&gt;1 not preceded by start-of-line or 0, not succeeded by end-of-line or 2; or 2 not preceeded by ...&lt;/em&gt;), but I would not recommend that.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-14T19:45:07.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3284" PostTypeId="2" ParentId="3282" CreationDate="2015-05-14T19:51:49.040" Score="5" Body="&lt;p&gt;You're looking for &lt;code&gt;hlID()&lt;/code&gt;, and the odd &lt;code&gt;hl&lt;/code&gt;-prefix probably made you not find it.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo hlID(&quot;Comment&quot;)&#xA;46&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-14T19:51:49.040" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3285" PostTypeId="1" CreationDate="2015-05-15T09:17:03.327" Score="0" ViewCount="141" Body="&lt;p&gt;What's the quickest way to change a specific number of characters? I want to edit the next N number of characters without using replace mode.&lt;/p&gt;&#xA;" OwnerUserId="662" LastEditorUserId="662" LastEditDate="2015-05-15T15:46:33.933" LastActivityDate="2015-05-15T15:46:33.933" Title="Quickest way to change a certain number of characters in INSERT mode?" Tags="|insert-mode|" AnswerCount="1" CommentCount="4" ClosedDate="2015-05-28T06:51:51.763" ContentLicense="CC BY-SA 3.0" />
  <row Id="3286" PostTypeId="2" ParentId="3285" CreationDate="2015-05-15T09:17:03.327" Score="2" Body="&lt;p&gt;Several straightforward ways, where the number of characters is, say, 5:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Space&lt;/kbd&gt; can be substituted with &lt;kbd&gt;l&lt;/kbd&gt; or &lt;kbd&gt;→&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of those will remove the desired number of characters first (in this case 5) and then put you in &lt;code&gt;INSERT&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid entering &lt;code&gt;INSERT&lt;/code&gt; mode, refer to &lt;a href=&quot;https://vi.stackexchange.com/questions/718/how-to-replace-more-than-one-character-without-entering-insert-mode&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="662" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-05-15T09:40:58.230" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3287" PostTypeId="2" ParentId="3277" CreationDate="2015-05-15T10:07:05.947" Score="6" Body="&lt;h1&gt;Disclaimer&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I think the question is on topic for vi.SE because it is about doing something with Vim. I'm not so sure about my answer, however, since it focuses more on what to do outside of Vim, even if the purpose is to enable one to use Vim in the way requested. If the question were about Vimperator I gather it would be off topic, per &lt;a href=&quot;https://area51.meta.stackexchange.com/questions/19295/would-questions-relating-to-gvim-elvis-nvi-be-relevant&quot;&gt;this discussion&lt;/a&gt;, but does that mean that an answer suggesting it is &quot;off topic&quot; or inappropriate for this site? Maybe the mods could indicate whether this kind of answer is OK, and I can make edits accordingly.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Answer&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;There are browser plugins that allow you to edit text for a text area or field in an external editor. I am not familiar with the website in question, but if you have the option to make your submission by typing text into a HTML text are, then chances are you can use one of these plugins and do the editing in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Firefox with the Vimperator plugin and am typing this answer in Vim (MacVim). In my .vimperatorrc I have the following line, defining my external editor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set editor=&quot;/usr/local/bin/mvim -f&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-f&lt;/code&gt; flag is to prevent forking when running Vim with GUI ('f' is for 'foreground').&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To begin editing with an external editor in Vimperator I navigate to the input control on the webpage and hit &lt;kbd&gt;Ctrl-i&lt;/kbd&gt;. This opens a new MacVim window and I can do my editing. When I am done editing I write and quit the buffer (&lt;kbd&gt;:wq&lt;/kbd&gt;), and the text is entered into the text area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On vi.SE and other SE sites, as on many other websites with WYSIWYG editors, the page defines some access keys of its own upon load. Particularly, for SE sites, &lt;kbd&gt;Ctrl-i&lt;/kbd&gt; is overridden to insert &lt;code&gt;*emphasized text*&lt;/code&gt;. In order to get around this I have an additional mapping in my .vimperatorrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Leader&amp;gt;i &amp;lt;C-i&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; key is &lt;kbd&gt;-&lt;/kbd&gt; so I can then use &lt;kbd&gt;-i&lt;/kbd&gt; to do the above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vimperator is a &quot;vimitator&quot; that lets you navigate and to some degree script the browser in a Vimlike fashion and the ability to use an external editor is only a minor feature. There are other plugins which focus particularly on that and if you are not keen on the rest of Vimperator's features you may want to look into one of those. (I believe there is one called &quot;It's all text&quot; that seems popular).&lt;/p&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="-1" LastEditDate="2017-05-03T08:41:04.867" LastActivityDate="2015-05-15T10:07:05.947" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3288" PostTypeId="1" AcceptedAnswerId="3289" CreationDate="2015-05-15T10:28:22.923" Score="10" ViewCount="4951" Body="&lt;p&gt;I've set the background color of the current line to light gray like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi CursorLine cterm=NONE ctermbg=253&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that my color scheme is black-on-white.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this way any background colors set by syntax highlighting is overridden by this, i.e. if a word on the current line is highlighted, say, white-on-red, I see the text as white-on-light gray. I only see that the line (or part of it) is supposed to be highlighted red if I move the cursor to another line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like is that only the part of the current line for which no special background color is set is highlighted light-gray by cursorline, but that the cursorline highlighting is overridden by syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: The specific case where I've encountered this issue is the second line in a git commit tmp-file, where the text on the second line is white-on-red (for whatever reason).&lt;/p&gt;&#xA;" OwnerUserId="2100" LastEditorUserId="1708" LastEditDate="2015-05-17T19:04:49.087" LastActivityDate="2015-05-17T19:04:49.087" Title="Override cursorline background color by syntax highlighting" Tags="|vimrc|syntax-highlighting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3289" PostTypeId="2" ParentId="3288" CreationDate="2015-05-15T11:25:08.960" Score="7" Body="&lt;p&gt;I had once &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/RscKIpSI3iA/YFeGoycV9GIJ&quot; rel=&quot;noreferrer&quot;&gt;suggested a change on the vim_dev mailing list&lt;/a&gt;, but Bram was against it, with the following reasoning:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Having the syntax background color overrule the 'cursorline' background color will result in the cursorline to be broken in pieces or hardly viewable.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h3&gt;Alternative&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;With the &lt;code&gt;matchadd()&lt;/code&gt; function, you can specify a &lt;code&gt;{priority}&lt;/code&gt; that determines whether the highlighting will be in front of or behind the cursorline. Unfortunately, this is totally different from syntax highlighting, and even scoped differently. Therefore, it doesn't help with syntax issues, but enables other uses, e.g. highlightings by my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2666&quot; rel=&quot;noreferrer&quot;&gt;Mark plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Workaround&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can keep the syntax background color if you use the &lt;code&gt;reverse&lt;/code&gt; attribute. For instance, instead of defining&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi Todo guifg=Black guibg=Yellow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi Todo guifg=Yellow guibg=Black gui=reverse&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, now you have another problem: The text (foreground) color changes from black to the cursorline color. This works well for the white-on-red error highlighting you mention (turning to (bright)-cursorline-on-red), but less well for my &lt;code&gt;Todo&lt;/code&gt; example (cursorline-on-Yellow). Additionally, the &lt;code&gt;reverse&lt;/code&gt; attribute is not supported in all terminals.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Summary&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, there's no easy fix. Despite the shortcomings, I use the above workaround (kudos to @romainl, in whose config I first saw this!)&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-15T11:25:08.960" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3290" PostTypeId="1" AcceptedAnswerId="3294" CreationDate="2015-05-15T12:49:36.677" Score="1" ViewCount="94" Body="&lt;p&gt;How to search for continuation line, as detected by c-indent in vim ?&#xA;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/indent.html&quot; rel=&quot;nofollow&quot;&gt;ie. the +N cinoption&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2056" LastActivityDate="2015-05-15T14:35:24.230" Title="Search for continuation line" Tags="|search|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3291" PostTypeId="1" AcceptedAnswerId="3293" CreationDate="2015-05-15T13:32:16.213" Score="3" ViewCount="400" Body="&lt;p&gt;How to search for line containing unclosed parenthesis.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/([^)]*$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works only for non-nested parenthesis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the closing parenthesis is present in the next lines, it should still be a match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for example :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo( bar, bar&#xA;     bar, bar );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be a match.&lt;/p&gt;&#xA;" OwnerUserId="2056" LastEditorUserId="205" LastEditDate="2016-05-16T21:56:27.223" LastActivityDate="2016-05-16T21:56:27.223" Title="How do I search for line containing an unclosed parenthesis?" Tags="|search|delimiter-matching|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3292" PostTypeId="2" ParentId="3291" CreationDate="2015-05-15T13:39:11.423" Score="3" Body="&lt;p&gt;It is hard to match balanced parentheses with regular expressions, but fortunately, Vim has built-in motions for &lt;code&gt;(&lt;/code&gt; and &lt;code&gt;{&lt;/code&gt;. See &lt;code&gt;:help [(&lt;/code&gt; and &lt;code&gt;:help [{&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-15T13:39:11.423" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3293" PostTypeId="2" ParentId="3291" CreationDate="2015-05-15T14:05:29.353" Score="2" Body="&lt;p&gt;Done it myself&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Unclosed(pattern, pattern2)&#xA;&#xA;    &quot; Store current pos&#xA;    let l:matchpos = getpos('.')&#xA;&#xA;    &quot; Initialize return&#xA;    let l:ret = 0 &#xA;&#xA;    &quot; Search Pattern, no wrap&#xA;    while search(a:pattern, &quot;W&quot;, &quot;&quot;, &quot;&quot;) &amp;gt; 0 &#xA;&#xA;        &quot; Search for pair only in current line&#xA;        if eval(searchpair(a:pattern, '', a:pattern2, '', '', line(&quot;.&quot;)))&#xA;            continue&#xA;        endif&#xA;&#xA;        &quot; found store position and line&#xA;        let l:matchpos = getpos('.')&#xA;        let l:ret = line(&quot;.&quot;)&#xA;        break&#xA;    endwhile&#xA;&#xA;    &quot; Set cursor to position and return&#xA;    call setpos('.', l:matchpos)&#xA;    return l:ret&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2056" LastActivityDate="2015-05-15T14:05:29.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3294" PostTypeId="2" ParentId="3290" CreationDate="2015-05-15T14:35:24.230" Score="3" Body="&lt;p&gt;Vim's source code has a section dedicated to do this, and it's a lot more complicated than a simple regex. Here's a link to the &lt;a href=&quot;https://github.com/neovim/neovim/blob/0bce4dc54427d05ab320a88f6269a9c1b05ea899/src/nvim/indent_c.c&quot; rel=&quot;nofollow&quot;&gt;neovim file&lt;/a&gt; that does this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This leaves you with 2 options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Write your own regex to do a &quot;close enough&quot; guess job&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you're using the +N option and can define continuation lines as lines that are indented N spaces more than the line before. You can use a regex to find these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v^( +)\S.*\n\1    \zs\S&#xA;\v                       &quot;very magic mode&quot; so we don't have to escape too many things&#xA;  ^                      start of a line&#xA;   ( +)                  all the spaces, captured in group 1&#xA;       \S                a non-space character&#xA;         .*              the rest of this line&#xA;           \n            newline&#xA;             \1          the same number of spaces again&#xA;                   \zs   N extra spaces, then start the match&#xA;                      \S a non-space&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-05-15T14:35:24.230" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3295" PostTypeId="2" ParentId="3164" CreationDate="2015-05-15T15:18:44.443" Score="1" Body="&lt;p&gt;I just found a plugin on &lt;a href=&quot;https://www.reddit.com/r/vim/comments/2agj70/name_your_2_favorite_plugins_requirement_must_be/&quot; rel=&quot;nofollow&quot;&gt;reddit&lt;/a&gt; which does exactly what you want: &lt;a href=&quot;https://github.com/ton/vim-bufsurf&quot; rel=&quot;nofollow&quot;&gt;bufsurf&lt;/a&gt;. From the readme:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... This plugin supplies the user with the commands :BufSurfForward&#xA;  and :BufSurfBack to navigate buffers forwards and backwards according to the&#xA;  navigation history. ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2024" LastActivityDate="2015-05-15T15:18:44.443" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3296" PostTypeId="1" AcceptedAnswerId="3297" CreationDate="2015-05-15T15:27:51.770" Score="6" ViewCount="902" Body="&lt;p&gt;How to count the number of whitespace in the beginning of a line ( aka indentation ).&#xA;eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo()&#xA;    foo()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command(2)&#xA;4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2056" LastEditorUserId="343" LastEditDate="2017-12-06T11:10:41.340" LastActivityDate="2017-12-06T11:10:41.340" Title="Count the number of whitespace in the beginning of a line" Tags="|indentation|counting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3297" PostTypeId="2" ParentId="3296" CreationDate="2015-05-15T15:52:03.263" Score="13" Body="&lt;p&gt;so easy i'm ashamed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo indent(2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2056" LastEditorUserId="2056" LastEditDate="2015-05-16T19:55:24.093" LastActivityDate="2015-05-16T19:55:24.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3298" PostTypeId="1" AcceptedAnswerId="3304" CreationDate="2015-05-15T20:39:18.347" Score="23" ViewCount="20749" Body="&lt;p&gt;Vim normally writes &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; for the last line only when there was one in the original file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to make vim to write a new line at the end of a file all the time (when the file is not binary and there isn't already one)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tested &lt;code&gt;eol&lt;/code&gt; option, but it didn't work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;a href=&quot;http://vim.wikia.com/wiki/Preserve_missing_end-of-line_at_end_of_text_files&quot; rel=&quot;noreferrer&quot;&gt;Preserve missing end-of-line at end of text files&lt;/a&gt;, but opposite. And: &lt;a href=&quot;https://stackoverflow.com/q/729692/55075&quot;&gt;Why should files end with a newline?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2020-01-15T05:13:30.420" Title="How to make vim automatically add a newline to the end of a file?" Tags="|vimrc|save|line-breaks|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3299" PostTypeId="1" AcceptedAnswerId="3302" CreationDate="2015-05-15T20:52:59.110" Score="2" ViewCount="775" Body="&lt;p&gt;I've html file (e.g. &lt;code&gt;curl -o page.html http://example.com/&lt;/code&gt;) where I would like to remove inner html block for given html tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've the following code which works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex -V1 page.html &amp;lt;&amp;lt;-EOF&#xA;/&amp;lt;h1&amp;gt;&#xA;norm nvitd &quot; Jump to next match and remove the inner tag block.&#xA;wq&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I'd like to make the condition to execute &lt;code&gt;norm nvitd&lt;/code&gt; only when the pattern &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; is found. For example when testing with &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; then the next line is executed generating the warnings, despite the pattern is not found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to make such condition? It's possible to make it in one line (like a ternary operator)?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-05-16T00:19:12.353" LastActivityDate="2015-05-16T09:23:12.390" Title="How to remove inner content of html tag conditionally?" Tags="|vimscript|search|substitute|filetype-html|ex-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3300" PostTypeId="1" AcceptedAnswerId="3303" CreationDate="2015-05-16T09:01:33.207" Score="2" ViewCount="619" Body="&lt;p&gt;I have just reinstalled gvim 7.4 on my 64 bit Windows 7 system. &lt;code&gt;gvim.exe&lt;/code&gt; now does not start, (or appears not to start - it may be exiting immediately)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I start &lt;code&gt;vim.exe&lt;/code&gt; then it works fine. This is about the GUI version not starting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What might be the problem, and what strategies might I adopt to get further insights into what's wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can run it with a --version attribute, and I get the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 10 2013 14:38:33)&#xA;MS-Windows 32-bit GUI version with OLE support&#xA;Compiled by mool@tororo&#xA;Big version with GUI.  Features included (+) or not (-):&#xA;+arabic             +ex_extra           +mouseshape         +syntax&#xA;+autocmd            +extra_search       +multi_byte_ime/dyn +tag_binary&#xA;+balloon_eval       +farsi              +multi_lang         +tag_old_static&#xA;+browse             +file_in_path       -mzscheme           -tag_any_white&#xA;++builtin_terms     +find_in_path       +netbeans_intg      +tcl/dyn&#xA;+byte_offset        +float              +ole                -tgetent&#xA;+cindent            +folding            +path_extra         -termresponse&#xA;+clientserver       -footer             +perl/dyn           +textobjects&#xA;+clipboard          +gettext/dyn        +persistent_undo    +title&#xA;+cmdline_compl      -hangul_input       -postscript         +toolbar&#xA;+cmdline_hist       +iconv/dyn          +printer            +user_commands&#xA;+cmdline_info       +insert_expand      -profile            +vertsplit&#xA;+comments           +jumplist           +python/dyn         +virtualedit&#xA;+conceal            +keymap             +python3/dyn        +visual&#xA;+cryptv             +langmap            +quickfix           +visualextra&#xA;+cscope             +libcall            +reltime            +viminfo&#xA;+cursorbind         +linebreak          +rightleft          +vreplace&#xA;+cursorshape        +lispindent         +ruby/dyn           +wildignore&#xA;+dialog_con_gui     +listcmds           +scrollbind         +wildmenu&#xA;+diff               +localmap           +signs              +windows&#xA;+digraphs           -lua                +smartindent        +writebackup&#xA;-dnd                +menu               -sniff              -xfontset&#xA;-ebcdic             +mksession          +startuptime        -xim&#xA;+emacs_tags         +modify_fname       +statusline         -xterm_save&#xA;+eval               +mouse              -sun_workshop       +xpm_w32&#xA;   system vimrc file: &quot;$VIM\vimrc&quot;&#xA;     user vimrc file: &quot;$HOME\_vimrc&quot;&#xA; 2nd user vimrc file: &quot;$HOME\vimfiles\vimrc&quot;&#xA; 3rd user vimrc file: &quot;$VIM\_vimrc&quot;&#xA;      user exrc file: &quot;$HOME\_exrc&quot;&#xA;  2nd user exrc file: &quot;$VIM\_exrc&quot;&#xA;  system gvimrc file: &quot;$VIM\gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME\_gvimrc&quot;&#xA;2nd user gvimrc file: &quot;$HOME\vimfiles\gvimrc&quot;&#xA;3rd user gvimrc file: &quot;$VIM\_gvimrc&quot;&#xA;    system menu file: &quot;$VIMRUNTIME\menu.vim&quot;&#xA;Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32   -DFEAT_CSCOPE &#xA;-DFEAT_NETBEANS_INTG   -DFEAT_XPM_W32   -DWINVER=0x0400 -D_WIN32_WINNT=0x040&#xA;0  /Fo.\ObjGOLYHTRi386/ /Ox /GL -DNDEBUG  /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME &#xA;-DDYNAMIC_IME -DFEAT_GUI_W32 -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL &#xA;-DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\&quot;tcl85.dll\&quot; -DDYNAMIC_TCL_VER=\&quot;8.5\&quot; &#xA;-DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\&quot;python27.dll\&quot; &#xA;-DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\&quot;python32.dll\&quot; &#xA;-DFEAT_PERL -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\&quot;perl514.dll\&quot; -DFEAT_RUBY &#xA;-DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=19 -DDYNAMIC_RUBY_DLL=\&quot;msvcrt-ruby192.dll\&quot; &#xA;-DFEAT_BIG /Fd.\ObjGOLYHTRi386/ /Zi&#xA;Linking: link /RELEASE /nologo /subsystem:windows /LTCG:STATUS oldnames.lib kernel32.lib &#xA;advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib uuid.lib /machine:i386 /nodefaultlib gdi32.lib &#xA;version.lib   winspool.lib comctl32.lib advapi32.lib shell32.lib  /machine:i386 /nodefaultlib libcmt.lib &#xA;oleaut32.lib  user32.lib      /nodefaultlib:python27.lib /nodefaultlib:python32.lib   &#xA;&quot;E:\tcl\lib\tclstub85.lib&quot; WSock32.lib xpm\x86\lib\libXpm.lib /PDB:gvim.pdb -debug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="460" LastEditorUserId="51" LastEditDate="2015-05-16T17:06:11.803" LastActivityDate="2016-09-10T13:32:04.880" Title="Why won't gvim start after reinstall?" Tags="|gvim|microsoft-windows|startup|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3301" PostTypeId="2" ParentId="3298" CreationDate="2015-05-16T09:12:24.350" Score="10" Body="&lt;p&gt;Vim only omits the EOL if the file is opened as &lt;code&gt;'binary'&lt;/code&gt; &lt;em&gt;and&lt;/em&gt; the &lt;code&gt;'endofline'&lt;/code&gt; option is reset (when the binary file didn't have an EOL when opening, or you explicitly reset the option). In other words, Vim only honors a missing EOL for binary files. &lt;strong&gt;For text files, it always writes with an (added) EOL.&lt;/strong&gt; (That's why you need solutions like my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4550&quot;&gt;PreserveNoEOL plugin&lt;/a&gt; to keep text files without EOL.) You can find all the details at &lt;code&gt;:help 'endofline'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you only need to ensure to &lt;strong&gt;open the file as non-binary&lt;/strong&gt; in order to have Vim automatically write an EOL.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-16T09:12:24.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3302" PostTypeId="2" ParentId="3299" CreationDate="2015-05-16T09:23:12.390" Score="2" Body="&lt;p&gt;A sequence of normal mode commands aborts as soon as one command (e.g. a search) fails. So, if the &lt;code&gt;n&lt;/code&gt; jump to the next match fails (with &lt;code&gt;Pattern not found: &amp;lt;h1&amp;gt;&lt;/code&gt;), the following &lt;code&gt;vitd&lt;/code&gt; isn't executed. That's your condition, and it works for me that way (using Vim in Ex mode via &lt;code&gt;vim -e&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you have another bug in your script: By first searching for &lt;code&gt;/&amp;lt;h1&amp;gt;&lt;/code&gt;, that already positions the cursor on the first match. The following &lt;code&gt;n&lt;/code&gt; command then moves to the &lt;em&gt;next&lt;/em&gt; match, so this effectively clears the &lt;em&gt;second&lt;/em&gt; H1 tag, not the first. You should instead combine both, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&amp;lt;h1&amp;gt;/norm vitd&#xA;wq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, if you want to clear &lt;em&gt;all&lt;/em&gt; H1 tags, use &lt;code&gt;:global&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-16T09:23:12.390" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3303" PostTypeId="2" ParentId="3300" CreationDate="2015-05-16T09:39:14.247" Score="6" Body="&lt;p&gt;You can capture a full log of a Vim session with &lt;code&gt;gvim -V20vimlog&lt;/code&gt;. After quitting Vim, examine the &lt;code&gt;vimlog&lt;/code&gt; log file for suspect commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it may be something in your configuration, so try launching with &lt;code&gt;gvim -N -u NONE&lt;/code&gt; (which ignores plugins and your &lt;code&gt;.vimrc&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-16T09:39:14.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3304" PostTypeId="2" ParentId="3298" CreationDate="2015-05-16T11:28:13.243" Score="25" Body="&lt;h3&gt;Basic info&lt;/h3&gt;&#xA;&lt;p&gt;Vim doesn't show latest newline in the buffer but actually vim always place EOL at the end of the file when you write it, because it standard for text files in Unix systems. You can find more information about this &lt;a href=&quot;https://unix.stackexchange.com/questions/18743/whats-the-point-in-adding-a-new-line-to-the-end-of-a-file&quot;&gt;here&lt;/a&gt;. In short you don't have to worry about the absence a new lines at the end of the file in vim.&lt;/p&gt;&#xA;&lt;h3&gt;Experiment 1&lt;/h3&gt;&#xA;&lt;p&gt;You can do this small experiment to check this behaviour. In the terminal execute:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ vim test_test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Enter the character &lt;code&gt;1&lt;/code&gt; and save the file &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;wq&lt;/kbd&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You have only one character in the file, right? Actually no :) You now have in your file &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;LF&lt;/code&gt; characters. Let's check it, with hexdump utility:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ hexdump test_test&#xA;0000000 31 0a&#xA;0000002&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;31&lt;/code&gt; is ASCII code for character &lt;code&gt;1&lt;/code&gt;, and &lt;code&gt;0a&lt;/code&gt; is ASCII code for non-printing &lt;code&gt;LF&lt;/code&gt; character which for the UNIX as you may already know code for end of line.&lt;/p&gt;&#xA;&lt;h3&gt;Experiment 2&lt;/h3&gt;&#xA;&lt;p&gt;But what if we will open file which don't have &lt;code&gt;eol&lt;/code&gt; symbol at the end of the file. Let's check it too. Let's create file without eol at the end, for example like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ echo -n &amp;quot;1&amp;quot; &amp;gt; test_without_eol&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then again let's look inside it with hexdump:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ hexdump test_without_eol&#xA;000000 31&#xA;0000001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So there are no any &lt;code&gt;eol&lt;/code&gt; characters here. Let's open this file in vim:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ vim test_without_eol&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;At the bottom of editor you'll see:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;test_without_eol&amp;quot; [noeol] 1L, 1C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And if you'll save this file &lt;code&gt;eol&lt;/code&gt; character will be putted automatically.&lt;/p&gt;&#xA;&lt;h3&gt;What we can do about this?&lt;/h3&gt;&#xA;&lt;p&gt;If you really need to see end of the file. Try to use this command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set listchars=eol:$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;it will show all &lt;code&gt;eol&lt;/code&gt; characters as &lt;code&gt;$&lt;/code&gt; sign.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-01-15T05:13:30.420" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3305" PostTypeId="2" ParentId="3298" CreationDate="2015-05-16T11:48:25.450" Score="5" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/a/3304/467&quot;&gt;Alexander&lt;/a&gt; mentioned, Vim doesn't show EOL at EOF, that's why it's so confusing (especially with &lt;a href=&quot;https://stackoverflow.com/q/2287967/55075&quot;&gt;empty/blank new line&lt;/a&gt; which is another thing), therefore it actually writes every-time on file save.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is simple test how to test if that works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ printf foo &amp;gt; foo.txt&#xA;$ cat foo.txt&#xA;foo$ wc foo.txt&#xA;0 1 3 foo.txt&#xA;$ vim -cwq foo.txt&#xA;$ cat foo.txt&#xA;foo&#xA;$ wc foo.txt&#xA;1 1 4 foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice how shell prompt behave when there is no EOL (it goes mixed with the next line). When re-saving file with Vim, it adds it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;wc&lt;/code&gt; we can count lines, words and characters before saving and after, so we can see that it actually changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why this is so important? To keep our files &lt;a href=&quot;https://stackoverflow.com/q/729692/55075&quot;&gt;POSIX compliant&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-03-09T00:25:43.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3306" PostTypeId="1" CreationDate="2015-05-16T16:53:08.267" Score="2" ViewCount="885" Body="&lt;p&gt;If my file already has &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{{{&#xA;  fold contents here&#xA;  ...&#xA;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;blocks I want them to be automatically folded when I run &lt;code&gt;za&lt;/code&gt;; but&#xA;I want the ability to create a manual fold using &lt;code&gt;zf%&lt;/code&gt;, say on just &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;&#xA;  fold contents here&#xA;  ....&#xA;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;without vim automatically modifying my file to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{/*{{{*/&#xA;&#xA;fold contents here&#xA;...&#xA;&#xA;}/*}}}*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought that &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help fold-create-marker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;might be relevant, but I do not understand it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a workaround, but would like a cleaner solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.vimrc&lt;/code&gt; workaround:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;Leader&amp;gt;Zf :set fdm=marker&amp;lt;CR&amp;gt;za:set fdm=manual&amp;lt;CR&amp;gt;za|&quot;create marker method fold, but return to manual fold method&#xA;&quot; Above intended for case where '{{{' preexists on currentline, and matching '}}}' exists on subsequent line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2120" LastEditorUserId="1708" LastEditDate="2015-05-17T19:05:11.427" LastActivityDate="2015-06-19T07:38:30.730" Title="Benefits of 'set foldmethod=marker', but stop 'zf' from adding markers" Tags="|folding|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3307" PostTypeId="1" AcceptedAnswerId="3312" CreationDate="2015-05-16T22:18:09.530" Score="10" ViewCount="1389" Body="&lt;p&gt;Is there a way to get vim's &lt;code&gt;gf&lt;/code&gt; command (or something similar) to recognize a &lt;code&gt;+{cmd}&lt;/code&gt; argument for file-paths?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One can start vim and go directly to a search term by doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim +/coding_effort ~/project/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly, in command mode you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e +/coding_effort ~/project/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I often take notes and refer to other files like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;For more info see +/coding_effort ~/project/file where there's a detailed discussion.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd love to be able to select &lt;code&gt;+/coding_effort ~/project/file&lt;/code&gt;, type something like &lt;code&gt;gf&lt;/code&gt;, and have vim do the right thing.&lt;/p&gt;&#xA;" OwnerUserId="1039" LastActivityDate="2017-10-02T00:47:07.000" Title="Can I use &quot;gf&quot; (or similar) to open a file and jump to a search term?" Tags="|key-bindings|command-line|search|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3308" PostTypeId="1" AcceptedAnswerId="3309" CreationDate="2015-05-17T00:03:12.607" Score="13" ViewCount="6363" Body="&lt;p&gt;I like the &lt;code&gt;-&lt;/code&gt; and &lt;code&gt;&amp;lt;C-M&amp;gt;&lt;/code&gt; normal-mode keys for going to the first non-whitespace character of the previous/next line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there coresponding keys for going to the &lt;em&gt;last&lt;/em&gt; non-whitespace character on the previous/next line?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastEditorUserId="51" LastEditDate="2015-05-17T00:56:18.613" LastActivityDate="2015-05-17T18:14:14.243" Title="Go to last non-whitespace character of previous/next line?" Tags="|cursor-movement|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3309" PostTypeId="2" ParentId="3308" CreationDate="2015-05-17T01:10:51.683" Score="16" Body="&lt;p&gt;&lt;code&gt;g_&lt;/code&gt; moves the cursor to the last non-blank character of the &lt;em&gt;current&lt;/em&gt; line. From Vim's &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#g_&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help g_&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g_          To the last non-blank character of the line and&#xA;            [count - 1] lines downward |inclusive|. {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I think the only options you have to move to the non-blank character of the previous/next line is &lt;code&gt;kg_&lt;/code&gt; or &lt;code&gt;jg_&lt;/code&gt; respectively or using a count to move downwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it is easy to map them to something easier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F3&amp;gt; kg_&#xA;nnoremap &amp;lt;F4&amp;gt; jg_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="246" LastActivityDate="2015-05-17T01:10:51.683" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3310" PostTypeId="2" ParentId="3308" CreationDate="2015-05-17T18:14:14.243" Score="0" Body="&lt;p&gt;If you mean the next non-whitespace character of the previous/next lines (by going vertically), then try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-k&amp;gt; :call search('\%' . virtcol('.') . 'v\S', 'bW')&amp;lt;CR&amp;gt;&#xA;map &amp;lt;C-j&amp;gt; :call search('\%' . virtcol('.') . 'v\S', 'wW')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-05-17T18:14:14.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3311" PostTypeId="1" AcceptedAnswerId="3313" CreationDate="2015-05-17T18:51:08.293" Score="4" ViewCount="1662" Body="&lt;p&gt;In expression &lt;code&gt;:s/foo/bar\n/g&lt;/code&gt;&#xA;When replacing &lt;code&gt;\n&lt;/code&gt; inserts a null byte, according to the docs I have to use &lt;code&gt;\r&lt;/code&gt;. Since I insert newlines more frequently than null bytes, is there a way to change this mapping? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I want &lt;code&gt;:s/foo/bar\n/g&lt;/code&gt; to insert a newline, not nullbyte. &lt;/p&gt;&#xA;" OwnerUserId="2130" LastActivityDate="2015-05-18T13:06:13.557" Title="Change '\r' to '\n' for search and replace?" Tags="|search|regular-expression|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3312" PostTypeId="2" ParentId="3307" CreationDate="2015-05-17T19:51:10.293" Score="6" Body="&lt;p&gt;No, the first problem is that the necessary space between command and filename is not part of the '&lt;code&gt;isfname'&lt;/code&gt; option, and adding it would mean file borders couldn't be recognized at all. You'd either have to always use a visual selection (of both command and filename), or implement custom parsing in a &lt;code&gt;gf&lt;/code&gt; command overload.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, the built-in &lt;code&gt;gf&lt;/code&gt; doesn't recognize the &lt;code&gt;+{cmd}&lt;/code&gt; syntax, so there's really no way around implementing your own custom mapping. This is certainly possible (using functions like &lt;code&gt;expand('&amp;lt;cfile&amp;gt;')&lt;/code&gt;, &lt;code&gt;getline()&lt;/code&gt;, etc.), but probably takes a few lines of Vimscript function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you choose a different syntax (&lt;code&gt;filename:+command&lt;/code&gt;), you can keep the original &lt;code&gt;gf&lt;/code&gt; commands and implement the splitting in an &lt;code&gt;:autocmd&lt;/code&gt;, similar to what the very related &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2184&quot; rel=&quot;noreferrer&quot;&gt;file:line&lt;/a&gt; plugin does for &lt;code&gt;filespec:linenumber&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-17T19:51:10.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3313" PostTypeId="2" ParentId="3311" CreationDate="2015-05-17T19:56:15.307" Score="6" Body="&lt;p&gt;You could do this via a &lt;code&gt;:cnoremap &amp;lt;expr&amp;gt; \r&lt;/code&gt; that checks (via &lt;code&gt;getcmdtype()&lt;/code&gt; and &lt;code&gt;getcmdpos()&lt;/code&gt;) that the current command-line is a &lt;code&gt;:s&lt;/code&gt; Ex command, and you're editing the replacement part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend against this, and just accept and learn that &lt;code&gt;\r&lt;/code&gt; has to be used. Otherwise, you'll become dependent on your mapping and will struggle on systems that are not yours / do not have your configuration.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-17T19:56:15.307" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3314" PostTypeId="1" CreationDate="2015-05-17T20:27:10.530" Score="2" ViewCount="1474" Body="&lt;p&gt;Is there a way to shorten the displayed name of the buffer, for example, on the image, path(...)/application_controller.rb to simply &quot;application_controller.rb&quot;?&#xA;If I have many buffers with such long names, things get messy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My buffer menu :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmenu  &#xA;&#xA;set wildmode=longest:full,full  &#xA;&#xA;set wildcharm='&amp;lt;'C-Y&amp;gt;  &#xA;&#xA;nnoremap '&amp;lt;'F3&amp;gt; :b '&amp;lt;'C-Y&amp;gt;&amp;lt;right&amp;gt;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rpVBz.png&quot; alt=&quot;screenshot&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2131" LastEditorUserId="24" LastEditDate="2015-05-18T01:44:43.413" LastActivityDate="2015-05-18T06:45:57.560" Title="Short buffer name" Tags="|vimrc|buffers|statusline|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3315" PostTypeId="2" ParentId="3314" CreationDate="2015-05-17T20:49:45.143" Score="2" Body="&lt;p&gt;If all you want to do is shorten the filename shown on the status line, search &lt;code&gt;statusline&lt;/code&gt; or &lt;code&gt;stl&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt;, and replace &lt;code&gt;%f&lt;/code&gt; with &lt;code&gt;%t&lt;/code&gt;.  See &lt;code&gt;:help statusline&lt;/code&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-05-17T20:49:45.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3316" PostTypeId="2" ParentId="3307" CreationDate="2015-05-17T20:53:34.073" Score="2" Body="&lt;p&gt;Here's a function which should replicate the built-in &lt;code&gt;gf&lt;/code&gt; behaviour, and &lt;em&gt;also&lt;/em&gt; scans for works starting with &lt;code&gt;+&lt;/code&gt; which then gets passed to &lt;code&gt;:edit&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! GotoWithCommand()&#xA;        let l:file = expand('&amp;lt;cfile&amp;gt;')&#xA;&#xA;        &quot; Replace ~ with the home directory&#xA;        let l:file = substitute(l:file, '^\~', $HOME, '')&#xA;&#xA;        &quot; File doesn't exist; return&#xA;        if !filereadable(l:file)&#xA;                echohl ErrorMsg&#xA;                echomsg &quot;E447: Can't find file \&quot;&quot; . l:file . '&quot; in path'&#xA;                echohl None&#xA;                return 0&#xA;        endif&#xA;&#xA;        &quot; Save cursor postion&#xA;        let l:save_cursor = getpos(&quot;.&quot;)&#xA;&#xA;        &quot; Make sure we go to the previous word (B on the first character of the&#xA;        &quot; filename goes to the previous word, B anywhere else goes to the start of&#xA;        &quot; the filename)&#xA;        call search('\(\s\|^\)', 'b')&#xA;&#xA;        &quot; Try to find argument to be executed; these start with a `+'&#xA;        let l:commands = ''&#xA;        while 1&#xA;                &quot; Go one WORD backwards&#xA;                normal! B&#xA;&#xA;                &quot; Not a +; stop the loop&#xA;                if getline('.')[col('.') - 1] != '+'&#xA;                        break&#xA;                endif&#xA;&#xA;                let l:commands .= ' ' . expand('&amp;lt;cWORD&amp;gt;')&#xA;        endwhile&#xA;&#xA;        &quot; Restore cursor postion&#xA;        call setpos('.', l:save_cursor)&#xA;&#xA;        &quot; Now, open the new file...&#xA;        execute ':edit ' . l:commands . ' ' . l:file&#xA;endfun&#xA;&#xA;nnoremap &amp;lt;Leader&amp;gt;gf :call GotoWithCommand()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The comments should explain what the function does in more detail ... I wrote this on the train the morning, and (obviously) didn't test it extensively ;-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-05-17T20:53:34.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3317" PostTypeId="1" AcceptedAnswerId="3318" CreationDate="2015-05-18T05:36:58.123" Score="9" ViewCount="10902" Body="&lt;p&gt;I'm in folder &lt;code&gt;E:\dir\python_file.py&lt;/code&gt;, &lt;code&gt;:pwd&lt;/code&gt; shows &lt;code&gt;E:\dir&lt;/code&gt;. &lt;code&gt;:e tags&lt;/code&gt; opens the tags file I generated with &lt;code&gt;ctags -R&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got &lt;code&gt;tags&lt;/code&gt; set to what seems reasonable: &lt;code&gt;set tags?&lt;/code&gt; shows &lt;code&gt;set tags=./tags,tags;E:\&lt;/code&gt;. Verbose &lt;code&gt;set tags&lt;/code&gt; shows only my vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:tag method_name&lt;/code&gt; throws two errors: &lt;code&gt;E433: No tags file&lt;/code&gt; and &lt;code&gt;E426: tag not found: method_name&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm on Windows.&lt;/p&gt;&#xA;" OwnerUserId="488" LastEditorUserId="23502" LastEditDate="2022-11-02T19:57:57.260" LastActivityDate="2022-11-02T19:57:57.260" Title="Why can't Vim see the tags file, despite being in the same directory?" Tags="|tags|ctags|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3318" PostTypeId="2" ParentId="3317" CreationDate="2015-05-18T06:06:41.873" Score="8" Body="&lt;p&gt;&lt;code&gt;wildignore&lt;/code&gt; had a trailing comma.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vimrc had &lt;code&gt;set wildignore=*.png,&lt;/code&gt; which had a trailing comma. Changing it do &lt;code&gt;set wildignore=*.png&lt;/code&gt; solved my issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out, after looking at &lt;code&gt;:set&lt;/code&gt; for a while, that &lt;code&gt;ftplugin/python.vim&lt;/code&gt;  does &lt;code&gt;set wildignore+=*.pyc&lt;/code&gt; somewhere, because just &lt;code&gt;set wildignore=*.png,&lt;/code&gt; isn't enough to break the tags. So the wildignore that I had, once I opened a .py file, was &lt;code&gt;wildcard=*.png,,*.pyc&lt;/code&gt;, and if you open vim with &lt;code&gt;vim -u NONE -U NONE&lt;/code&gt;, tags will break.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim must do some concatenation adding a comma if the setting isn't empty, but doesn't check for an existing trailing comma. Think I just found a bug.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Turns out it was a bug, and it has since been &lt;a href=&quot;https://github.com/vim/vim/issues/365&quot; rel=&quot;noreferrer&quot;&gt;resolved&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="488" LastEditorUserId="488" LastEditDate="2016-07-16T18:50:43.263" LastActivityDate="2016-07-16T18:50:43.263" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3319" PostTypeId="2" ParentId="3314" CreationDate="2015-05-18T06:45:57.560" Score="1" Body="&lt;p&gt;As the path that is shown in the &lt;em&gt;statusline&lt;/em&gt; by default is relative to the current working directory, you could shorten it by &lt;code&gt;:cd&lt;/code&gt;'ing to a &quot;closer&quot; subdirectory, or the file's directory itself (&lt;code&gt;:cd %:p:h&lt;/code&gt;). With &lt;code&gt;:set autochdir&lt;/code&gt;, this will be done automatically whenever you switch buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, this is a more invasive change than simply changing the &lt;code&gt;'statusline'&lt;/code&gt; display itself.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-18T06:45:57.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3320" PostTypeId="1" AcceptedAnswerId="3321" CreationDate="2015-05-18T09:03:05.533" Score="6" ViewCount="1177" Body="&lt;p&gt;I'm facing a behavior that I find unatural when trying to paste a block of text selected with visual block mode (&lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;): I can't insert it between two lines without messing with the already existing line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have this file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc&#xA;def&#xA;hij&#xA;klm&#xA;&#xA;This is a text&#xA;on several lines&#xA;and this is another line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's say I want to put the first letters of each of the 4 first lines between the 2 others lines of text.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First I'll select the 4 letters: &lt;code&gt;&amp;lt;C-v&amp;gt; 3j y&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Then I put my cursor on the &lt;code&gt;o&lt;/code&gt; of the last line&lt;/li&gt;&#xA;&lt;li&gt;Finally I put my letters before my cursor with &lt;code&gt;P&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The result I get is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a text&#xA;aon several lines&#xA;dand this is another line&#xA;g&#xA;j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where as what I expected was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is a text &#xA;a&#xA;d&#xA;g&#xA;j&#xA;on several lines&#xA;and this is another line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it means that each time I want to past a block this way I have to insert the corresponding number of empty lines before I past which is pretty unatural in my opinion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a vim tip suggesting to use &lt;code&gt;1vp&lt;/code&gt; to select a corresponding number of lines before pasting but that allows a replacement not an insertion of the block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So my question is:&lt;/strong&gt; What is the good way to insert a visually selecting block between two existing lines?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Also&lt;/strong&gt; I once saw a plugin (which I can't remember the name) which &quot;improved&quot; visual block mode, but I'd like not to add a plugin just to enable this behavior.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="7161" LastEditDate="2016-05-02T12:11:56.073" LastActivityDate="2023-04-19T13:05:38.270" Title="Insert a text selected via visual block" Tags="|cut-copy-paste|visual-mode|visual-block|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3321" PostTypeId="2" ParentId="3320" CreationDate="2015-05-18T10:34:33.483" Score="5" Body="&lt;p&gt;That plugin you're referring to might be my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3355&quot;&gt;UnconditionalPaste plugin&lt;/a&gt;, which provides (among many related other commands) the exact &lt;code&gt;glp&lt;/code&gt; (force linewise paste) command you're looking for here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As its author, I surely think the plugin provides very helpful functionality that warrants installing it, but you can achieve the same via a simple built-in command. After yanking, execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg('', '', 'ac')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then paste with &lt;code&gt;P&lt;/code&gt;. This changes the &lt;em&gt;type&lt;/em&gt; of the default register from blockwise to characterwise. (As there's no &lt;code&gt;setregtype()&lt;/code&gt; function, it does this by appending (&lt;code&gt;a&lt;/code&gt;) nothing (&lt;code&gt;''&lt;/code&gt;) to the register.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;setreg()&lt;/code&gt; approach also works for other such conversions (e.g. characterwise to linewise with &lt;code&gt;'al'&lt;/code&gt; parameter.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your particular example, there's an even shorter (but less general) way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will always paste in new lines.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-18T10:34:33.483" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3323" PostTypeId="1" AcceptedAnswerId="3324" CreationDate="2015-05-18T17:32:34.810" Score="5" ViewCount="1759" Body="&lt;p&gt;Ok, it's a curiosity more than a real question, I apologize in advance for long post:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually I code with vim on a ubuntu headless, as a virtualbox guest on my stupid windows 7 host; I access linux terminal using amazing putty (&lt;a href=&quot;http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I love putty full-screen mode (Alt-Enter) and here a screenshot of a editing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/L4LT2.jpg&quot; alt=&quot;vim screeenshot using putty&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yesterday I tryied to port my ubuntu vim environment using &lt;a href=&quot;http://www.vim.org/download.php#pc&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.vim.org/download.php#pc&lt;/a&gt; native gVim on windows...:&#xA;I copied &quot;as is&quot; my .vimrc and plugins directories from the ubuntu to windows, to have my beloved configurations, plugins, colorscheme (BTW, I use &quot;Monokay-Refined&quot; colorscheme).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, the environment is perfectly replicated, a part the Session.vim (that seem incompatible).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;gVim configuration:&#xA;After some moments of panic with gVim configuration... by example I spent some time to understand how to make configurations persistent (changing and fixing the awful default font, remove menubar/toolbar, etc.) achieving a full-screen experience similar to that I use with putty.... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I found excellent beautiful utility to do that: &lt;a href=&quot;https://github.com/derekmcloughlin/gvimfullscreen_win32/tree/master&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/derekmcloughlin/gvimfullscreen_win32/tree/master&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, with gVim on windows I finally got the &quot;same&quot; full-screen feeling I usually have using vim on ubuntu through putty, see:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/qqSPa.jpg&quot; alt=&quot;gVim screenshot on windows&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT, to be meticulous, as you can see here below... screenshots are similar but not exactly the SAME!?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mean, I realized that COLORS are a bit differents accessingsame ruby file (by example) on the ubuntu through putty, and a copy of the same file on windows, acccessed with gVim ?!  despite the colorscheme, font and all other configs are identical! It seems to me that colors on the gVim installation are a bit &quot;better&quot;... and last but not least some character attributes (italic, bold, etc.) are bettere visualized on gVim that on putty ssh access...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a question of putty color/font &quot;rendering&quot; ?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, visualized code is from my ruby project: &lt;a href=&quot;https://github.com/solyaris/pere&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/solyaris/pere&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks&#xA;giorgio&lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="983" LastEditDate="2015-05-19T06:13:20.493" LastActivityDate="2015-05-19T06:13:20.493" Title="Visual Differences between vim on virtualbox Ubuntu guest (through putty) OR gVim on Windows host" Tags="|syntax-highlighting|gvim|microsoft-windows|colorscheme|font|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3324" PostTypeId="2" ParentId="3323" CreationDate="2015-05-18T19:02:34.430" Score="10" Body="&lt;p&gt;PuTTY, like other high-color terminals, only supports a fixed color palette of 256 colors. GVIM can use the full 24-bit RGB color space; that's why you see &quot;finer&quot; nuances there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for attributes, GVIM offers &lt;em&gt;undercurl&lt;/em&gt;, which is not present in any terminal, and free mixture of bold (depending on configuration shown with lighter color instead) and italic (not offered in PuTTY).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-18T19:02:34.430" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3325" PostTypeId="2" ParentId="2969" CreationDate="2015-05-18T22:02:20.240" Score="1" Body="&lt;p&gt;From the NERDTree docs, you should be able to add the following to your .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Open NERDTree if no files specified&#xA;autocmd StdinReadPre * let s:std_in=1&#xA;autocmd VimEnter * if argc() == 0 &amp;amp;&amp;amp; !exists(&quot;s:std_in&quot;) | NERDTree | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will open the present working directory if you do not specify a file to be opened when you call &lt;code&gt;vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope that helps!&lt;/p&gt;&#xA;" OwnerUserId="2143" LastActivityDate="2015-05-18T22:02:20.240" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3326" PostTypeId="2" ParentId="1937" CreationDate="2015-05-19T12:36:45.810" Score="11" Body="&lt;p&gt;In alternative to the maximized window, why do not gain more space for a full vim multiwindows editing experience with an autostart FULL SCREEN mode? ;-) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;FULL SCREEN screenshot of the final result (= ALL THE VIDEO pixels capacity):&#xA;&lt;img src=&quot;https://i.stack.imgur.com/HSJE0.jpg&quot; alt=&quot;video full screen screenshot&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion that's better than a windows maximize: a complete FULL SCREEN (as I used to do with puTTY with ALT-Enter when editing on remote unix terminal...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I explain how to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install the excellent beautiful utility to allow full screen use in gvim on Windows: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/derekmcloughlin/gvimfullscreen_win32/tree/master&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/derekmcloughlin/gvimfullscreen_win32/tree/master&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to download DLL file &lt;strong&gt;gvimfullscreen.dll&lt;/strong&gt; and put it in the same directory where gvim.exe is ($VIM/vim74 with gVim release 7.4). To download the DLL (without using git): &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/derekmcloughlin/gvimfullscreen_win32/raw/master/gvimfullscreen.dll&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/derekmcloughlin/gvimfullscreen_win32/raw/master/gvimfullscreen.dll&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit &lt;strong&gt;.vimrc&lt;/strong&gt; file (inside vim: &lt;code&gt;:e $HOME/.vimrc&lt;/code&gt;), inserting these commands to autostart full screen and allowing a F11 function key to toggle modes among 3 states: full screen, window maximized, original/default windows size:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;run the command immediately when starting vim&#xA;autocmd VimEnter * call libcallnr(&quot;gvimfullscreen.dll&quot;, &quot;ToggleFullScreen&quot;, 0)&#xA;&#xA;&quot; activate/deactivate full screen with function key &amp;lt;F11&amp;gt;  &#xA;map &amp;lt;F11&amp;gt; &amp;lt;Esc&amp;gt;:call libcallnr(&quot;gvimfullscreen.dll&quot;, &quot;ToggleFullScreen&quot;, 0)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit &lt;strong&gt;.gvimrc&lt;/strong&gt; file  (inside vim: &lt;code&gt;:split $HOME/.gvimrc&lt;/code&gt;) inserting these commands to avoid menu bar and useless stuff:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guioptions-=m  &quot;remove menu bar&#xA;set guioptions-=T  &quot;remove toolbar&#xA;set guioptions-=r  &quot;remove right-hand scroll bar&#xA;set guioptions-=L  &quot;remove left-hand scroll bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="983" LastEditorUserId="983" LastEditDate="2015-05-20T10:02:26.537" LastActivityDate="2015-05-20T10:02:26.537" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3327" PostTypeId="1" CreationDate="2015-05-19T12:52:03.817" Score="5" ViewCount="1170" Body="&lt;p&gt;I have some C++ sources files which are in a few mega-bytes (a few tens thousands lines) to view and edit. The performance looks really bad in Vim. Refersh (&lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt;) or input single char in insert mode take several seconds to complete. I tried &lt;code&gt;:syn off&lt;/code&gt; then all previous operations responded immediately. I also tried set &lt;code&gt;maxlines&lt;/code&gt; and &lt;code&gt;minlines&lt;/code&gt; to just a few hundred lines, but it doesn't help this situation. Syntax highlighting is not required to be accurate, but editing  without it looks a little crazy. Any suggestion to fix such performance issue on syntax highlighting with large files in Vim (I am using gVim)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; I profiled one refresh operation with my large CPP file, and there are many lines like below, how to understand such lines and find out the culprit?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TOTAL    COUNT MATCH SLOWEST  AVERAGE  NAME       PATTERN&#xA;0.248213 58529 28680 0.000127 0.000004 IndentLine \%(^\S\+\)\@&amp;lt;=\%9c&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="477" LastEditorUserId="205" LastEditDate="2015-05-21T08:40:41.363" LastActivityDate="2020-05-14T06:48:57.913" Title="Improve performance of syntax highlighting in Vim" Tags="|syntax-highlighting|performance|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3328" PostTypeId="1" AcceptedAnswerId="3376" CreationDate="2015-05-19T15:08:25.553" Score="34" ViewCount="3171" Body="&lt;p&gt;When I have to replace a word with another word I yank before, I usually use a workflow which seems unnatural to me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say I have this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar buzz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to yank &lt;code&gt;foo&lt;/code&gt; and replace &lt;code&gt;bar&lt;/code&gt; with what I yanked before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After yanking &lt;code&gt;foo&lt;/code&gt;, I see the following options:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Option 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Place the cursor on &lt;code&gt;bar&lt;/code&gt; with &lt;code&gt;w&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Put &lt;code&gt;foo&lt;/code&gt; in front of &lt;code&gt;bar&lt;/code&gt; with &lt;code&gt;P&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Put the cursor on the &lt;code&gt;b&lt;/code&gt; of the remaining &lt;code&gt;bar&lt;/code&gt; and delete the word with &lt;code&gt;de&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Option 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Put the cursor on bar with &lt;code&gt;w&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;de&lt;/code&gt; to erase &lt;code&gt;bar&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Put the content of the register 0 with &lt;code&gt;&quot;0P&lt;/code&gt; (since I erased &lt;code&gt;bar&lt;/code&gt;, &lt;code&gt;foo&lt;/code&gt; isn't accessible anymore with a simple &lt;code&gt;p&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Both ways seems over-complicated to me and I'm sure there is a more efficient way to achieve this action but I can't find how. This idea would be to combine the delete and the put actions in only one, or at least avoid to keep the deleted word in the yank register so as I can put the desired word with a simple &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I know the replace mode triggered with &lt;code&gt;R&lt;/code&gt; but it doesn't allow to put what was yanked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;: How to replace a word with the content of the yank register?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="23502" LastEditDate="2022-11-02T19:56:51.663" LastActivityDate="2022-11-03T17:22:41.897" Title="How to replace a word with a yanked word in normal mode?" Tags="|cut-copy-paste|replace|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3329" PostTypeId="2" ParentId="3328" CreationDate="2015-05-19T15:17:14.833" Score="39" Body="&lt;p&gt;Assuming you've already yanked &lt;code&gt;foo&lt;/code&gt; with &lt;code&gt;ye&lt;/code&gt; or something similar, and that the cursor is somewhere on &lt;code&gt;foo&lt;/code&gt;, you can use &lt;code&gt;Wvep&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;W&lt;/code&gt; to go to &lt;code&gt;bar&lt;/code&gt; (this is obviously optional and will depend on the current cursor position);&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v&lt;/code&gt; to start visual mode;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;e&lt;/code&gt; to go to the end of the word (you can also use other motions here, like &lt;code&gt;iw&lt;/code&gt;);&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; to paste &lt;code&gt;foo&lt;/code&gt;; this will replace the current visual selection (which is put in the unnamed register, &lt;code&gt;&quot;&quot;&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-05-19T15:17:14.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3330" PostTypeId="2" ParentId="2875" CreationDate="2015-05-19T18:50:26.087" Score="7" Body="&lt;p&gt;Another typical bottleneck in vim's syntax highlight is folding. Editing can become very slow if a fold contains many syntax items (which basically means it goes over many lines), because vim will refresh all syntax for every inserted character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is what you are experiencing then I suggest the use of &lt;a href=&quot;https://github.com/Konfekt/FastFold&quot; rel=&quot;noreferrer&quot;&gt;FastFold&lt;/a&gt; plugin. This plugin identifies syntax folds and replaces them with manual folds, making vim's syntax highlight much faster.&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="599" LastEditDate="2015-05-20T10:49:09.093" LastActivityDate="2015-05-20T10:49:09.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3331" PostTypeId="2" ParentId="3307" CreationDate="2015-05-19T18:55:57.183" Score="2" Body="&lt;p&gt;One option would be (assuming the &lt;code&gt;+cmd file/path&lt;/code&gt; is selected) to yank the selection to a register, then insert that register in the command prompt. I did this with the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vnoremap gsf &quot;0y:e &amp;lt;c-r&amp;gt;0&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1039" LastActivityDate="2015-05-19T18:55:57.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3332" PostTypeId="1" AcceptedAnswerId="3335" CreationDate="2015-05-19T20:26:41.157" Score="4" ViewCount="52" Body="&lt;p&gt;I've written a Vim script that inserts Unicode mathematical notation into what I'm editing. It's basically a few hundred lines of code that look like &lt;code&gt;:map! \bbq ℚ&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Sometimes I want to enable all of these definitions together. And sometimes I want to switch them all back off again. Really I want some kind of mode where they are enabled. But I'd like to switch them on and off while editing other types of file, like C++ source or plain text. What's the best way to organize this? Do I need to write a few hundred &lt;code&gt;unmap&lt;/code&gt;s? Or is there some way of undoing a whole lot of mappings in bulk? Can I wrap this up in some kind of mode?&lt;/p&gt;&#xA;" OwnerUserId="2160" LastEditorUserId="23502" LastEditDate="2022-11-02T19:55:51.473" LastActivityDate="2022-11-02T19:55:51.473" Title="How to make many definitions available as some kind of mode?" Tags="|key-bindings|unicode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3333" PostTypeId="1" AcceptedAnswerId="3454" CreationDate="2015-05-19T20:27:30.940" Score="7" ViewCount="6228" Body="&lt;p&gt;I love vim, i use it all the time for write codes, but now I want to write some personal notes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying &lt;a href=&quot;https://github.com/vim-pandoc/vim-pandoc&quot; rel=&quot;noreferrer&quot;&gt;vim-pandoc&lt;/a&gt; (with vim-pandoc-syntax) and it's nice to have 'rich text' features like titles, items, bold, italic fonts and even tables, but doen't have 'arbitrary colored text'. For the colored text I have tried &lt;a href=&quot;http://txtfmt.webs.com/&quot; rel=&quot;noreferrer&quot;&gt;txtfmt&lt;/a&gt; but this plugin uses special characters for the colors and I cant read them on others computers using the same configuration files (home and work computers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some alternative to txtfmt to achieve colored text?  More explicitly: how can I highlight some arbitrary part of my text with colors?&lt;/p&gt;&#xA;" OwnerUserId="2145" LastEditorUserId="24" LastEditDate="2015-05-28T21:02:04.267" LastActivityDate="2015-06-04T15:49:34.097" Title="Colorizing plain text" Tags="|syntax-highlighting|word-processing|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3334" PostTypeId="1" CreationDate="2015-05-19T21:25:10.890" Score="1" ViewCount="2102" Body="&lt;p&gt;When I populate the quickfix window (say with grep or Ag.vim), I can scroll through the entries, and all the positions inside the quickfix window show up in &lt;code&gt;:jumps&lt;/code&gt;. But as soon as I navigate away (say I &lt;code&gt;gf&lt;/code&gt; on a quickfix entry to go to the file), and then attempt to &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;, it doesn't take me back to the quickfix window, and indeed &lt;code&gt;:jumps&lt;/code&gt; has been pruned of all my quickfix locations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to &lt;code&gt;gf&lt;/code&gt; into a file, poke around, and then &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; back to the quickfix buffer -- is there anyway to get this behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe I've seen this behavior before but I'm not sure if there's some option I set to change it.&lt;/p&gt;&#xA;" OwnerUserId="1998" LastActivityDate="2015-10-14T13:18:37.723" Title="Keeping quickfix jumps in the jump list" Tags="|quickfix|jumplist|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3335" PostTypeId="2" ParentId="3332" CreationDate="2015-05-19T21:29:38.983" Score="3" Body="&lt;p&gt;If you need those mappings only for certain kinds of files, define them in a script separate from your &lt;code&gt;~/.vimrc&lt;/code&gt; and as &lt;em&gt;buffer-local&lt;/em&gt; mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map! &amp;lt;buffer&amp;gt; \bbq ℚ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then &lt;code&gt;:source path/to/script.vim&lt;/code&gt; on demand. Alternatively, by putting the script into &lt;code&gt;~/.vim/ftplugin/{filetype}_mappings.vim&lt;/code&gt;, they will be automatically loaded whenever Vim's filetype detection (cp. &lt;code&gt;:help filetype&lt;/code&gt;) recognizes &lt;code&gt;{filetype}&lt;/code&gt; (e.g. &lt;code&gt;tex&lt;/code&gt; for Latex documents).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still need to remove the mappings for the particular buffer, there's no way around defining corresponding &lt;code&gt;:unmap &amp;lt;buffer&amp;gt;&lt;/code&gt; commands, or maybe using the hack of &lt;code&gt;:set paste&lt;/code&gt; (which disables all mappings and has other side effects).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-19T21:29:38.983" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3336" PostTypeId="2" ParentId="3333" CreationDate="2015-05-19T21:34:51.600" Score="1" Body="&lt;p&gt;It really depends on where you want to read those documents. Inside Vim, you can define your own &lt;em&gt;syntax highlighting&lt;/em&gt;, and then have any sort of words or marked-up text highlighted according to Vim's capabilities. That makes it non-portable, though: You need to have your syntax script around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a portable, no-install solution, you need an external viewer, anyway. The most common, lowest-denominator one today is the web browser. Using HTML markup, you can easily (if not as succinctly as Markdown) format your documents, and use arbitrary colors and formats (and with CSS even animations and other gimmicks).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-19T21:34:51.600" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3337" PostTypeId="2" ParentId="3334" CreationDate="2015-05-19T22:26:17.670" Score="6" Body="&lt;p&gt;I don't think you took the time to read &lt;code&gt;:help quickfix&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your &lt;code&gt;:grep&lt;/code&gt; results populate the &quot;quickfix list&quot; which is then optionally displayed in the &quot;quickfix window&quot;. The whole quickfix mechanism is completely independent from the jumplist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using the quickfix window, you are supposed to press &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to jump to the location of the current entry while leaving the window open for further use. &lt;code&gt;&amp;lt;C-w&amp;gt;p&lt;/code&gt; is the generic command for jumping back to the previous window; you can use it to go back to the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, Vim makes it possible to go down and up that list with &lt;code&gt;:cnext&lt;/code&gt;, &lt;code&gt;:cprevious&lt;/code&gt;, &lt;code&gt;:clast&lt;/code&gt; and so on &lt;em&gt;without&lt;/em&gt; opening the quickfix window. This means that you can still navigate the list if you accidentally closed the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Jumps and &lt;code&gt;gf&lt;/code&gt; are totally useless when dealing with the quickfix list/window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My setup is probably a bit too heavily customized for the gif below to be a good demo but I tried to show how one typically uses the quickfix list and the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XVgOQ.gif&quot; alt=&quot;quickfix&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-05-19T22:34:56.740" LastActivityDate="2015-05-19T22:34:56.740" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3338" PostTypeId="2" ParentId="3320" CreationDate="2015-05-20T05:59:20.237" Score="6" Body="&lt;p&gt;You can get the behavior you want with: &lt;kbd&gt;O&lt;/kbd&gt;&lt;kbd&gt;Ctrl+R&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl+R&lt;/kbd&gt; in Insert mode pastes a register -- in this case, the default &lt;code&gt;&quot;&lt;/code&gt; register.  Since you're in Insert mode, it ignores the block-ness of the buffer.&lt;/p&gt;&#xA;" OwnerUserId="1077" LastActivityDate="2015-05-20T05:59:20.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3339" PostTypeId="2" ParentId="3306" CreationDate="2015-05-20T06:48:41.493" Score="3" Body="&lt;p&gt;You could do a global match on all fold markers to create manual folds.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/{{{/normal! $Nzf%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes that {} braces are balanced inside the fold markers, but if you use the &quot;matchit&quot; plugin distributed with Vim, you can make this better with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let b:match_words = '{{{:}}}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It also assumes that there's only one opening fold marker per line, but I don't see a good way to remove that assumption short of custom scripting.&lt;/p&gt;&#xA;" OwnerUserId="1077" LastActivityDate="2015-05-20T06:48:41.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3340" PostTypeId="1" AcceptedAnswerId="3426" CreationDate="2015-05-20T10:59:33.263" Score="4" ViewCount="669" Body="&lt;p&gt;Can anyone can help me, my vim always shows the cursorline, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/MbYFP.png&quot; alt=&quot;14 lines of underlined text&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have  &lt;code&gt;set nocursorline&lt;/code&gt; in the ~/.vimrc, but it has no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim version is: 7.4.622&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/l4MxV.png&quot; alt=&quot;VIM Version 7.4.622&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim is run on OSX 10.10.3, how to remove the white line.&lt;/p&gt;&#xA;" OwnerUserId="2168" LastEditorUserId="1841" LastEditDate="2015-08-20T08:59:44.493" LastActivityDate="2020-07-05T08:55:23.983" Title="Why is the cursorline always showing after the cursor moves over a line?" Tags="|macvim|macos|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3341" PostTypeId="1" AcceptedAnswerId="3416" CreationDate="2015-05-20T13:49:08.797" Score="7" ViewCount="4723" Body="&lt;p&gt;I have a Debian 7.0 with gnome, and I am fully satisfied with the standard vim version installed on it, except for the lack of +clipboard and/or +xterm_clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got the sources using mercurial, but I cannot find a way to enable just those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have read &lt;a href=&quot;https://vi.stackexchange.com/a/96&quot;&gt;this answer&lt;/a&gt; or &lt;a href=&quot;https://stackoverflow.com/questions/11416069/compile-vim-with-clipboard-and-xterm&quot;&gt;that question&lt;/a&gt;. But I don't want to install a full GUI version. It seems overkill to me that I should add all those options just to enable one feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a nice way to do it, or should I dive into the code (probably starting from feature.h), to hopefully get what I want..?&lt;/p&gt;&#xA;" OwnerUserId="2170" LastEditorUserId="23502" LastEditDate="2022-11-02T19:54:52.473" LastActivityDate="2022-11-02T19:54:52.473" Title="Compiling Vim from source just enabling clipboard" Tags="|os-clipboard|installing|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3342" PostTypeId="1" AcceptedAnswerId="3343" CreationDate="2015-05-20T14:00:15.863" Score="12" ViewCount="1657" Body="&lt;h2&gt;Background&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I work at a research laboratory and use three different OS's daily. On the Windows and Mac machines I make use of &lt;a href=&quot;http://www.zhornsoftware.co.uk/caffeine/&quot; rel=&quot;noreferrer&quot;&gt;Caffeine&lt;/a&gt; to keep those machines from enabling the screensaver while I work on a different machine (Linux doesn't have this problem). It's very annoying to have to log in again when I switch back.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;When vim or gvim are in insert mode, the character &lt;code&gt;&amp;lt;F15&amp;gt;&lt;/code&gt; sporadically appears in the document. I tracked it back to Caffeine after a bit of research. The website for Caffeine states that the software works by occasionally simulating a &lt;code&gt;&amp;lt;F15&amp;gt;&lt;/code&gt; key press event:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Of all the key presses available, F15 is probably the least intrusive (I've never seen a PC keyboard with that key!), and least likely to interfere with your work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So Caffeine is the obvious culprit. However, I still prefer to use my favorite text editor on all three machines, and don't intend to change that just to accommodate using Caffeine.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there something I can put in my &lt;code&gt;vimrc&lt;/code&gt; to make vim ignore &lt;code&gt;&amp;lt;F15&amp;gt;&lt;/code&gt; key press events?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Edit For Clarity&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I can't disable the screensaver timeout; it is set by the IT department for security purposes. So with the Caffeine work-around, in order to remain compliant, I have to manually lock my machines when I step away from my desk. That's not so bad; but unlocking them every few minutes is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I didn't write Caffeine, so I don't know why the developer chose to click &lt;code&gt;&amp;lt;F15&amp;gt;&lt;/code&gt; once a minute. I probably would have done it differently, perhaps with a slight mouse motion or touchpad tap, as @Random832 suggested.&lt;/p&gt;&#xA;" OwnerUserId="1862" LastEditorUserId="1862" LastEditDate="2015-05-21T16:18:49.497" LastActivityDate="2021-09-01T18:39:55.363" Title="Using vim and Caffeine on the same machine" Tags="|key-bindings|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3343" PostTypeId="2" ParentId="3342" CreationDate="2015-05-20T14:12:25.227" Score="20" Body="&lt;p&gt;You can map a key to &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; (short for &quot;no operation&quot;) to make it &quot;do nothing&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should make Vim ignore the &lt;code&gt;&amp;lt;F15&amp;gt;&lt;/code&gt; key in all modes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap &amp;lt;F15&amp;gt; &amp;lt;nop&amp;gt; &#xA;:noremap! &amp;lt;F15&amp;gt; &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will &lt;em&gt;probably&lt;/em&gt; fix your problem, but I haven't tested it in your specific situation, as I don't have various Windows/OSX machines with Caffeine  installed standing by  :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-20T14:23:13.437" LastActivityDate="2015-05-20T14:23:13.437" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3346" PostTypeId="2" ParentId="3333" CreationDate="2015-05-20T20:09:49.907" Score="0" Body="&lt;p&gt;On the &lt;a href=&quot;https://github.com/vim-pandoc/vim-pandoc&quot; rel=&quot;nofollow&quot;&gt;pandoc webpage&lt;/a&gt;, they write&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;vim-pandoc doesn't provide syntax support. The user needs to install &lt;a href=&quot;https://github.com/vim-pandoc/vim-pandoc-syntax&quot; rel=&quot;nofollow&quot;&gt;vim-pandoc/vim-pandoc-syntax&lt;/a&gt; alongside it (see below). The reason for this is we have found cleaner to keep the bug tracking of the syntax file and the rest of the system separate.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Have you tried that? From what I can understand, they provide a syntax support with their other source.&lt;/p&gt;&#xA;" OwnerUserId="2170" LastActivityDate="2015-05-20T20:09:49.907" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3347" PostTypeId="1" AcceptedAnswerId="3348" CreationDate="2015-05-21T07:59:14.753" Score="12" ViewCount="35910" Body="&lt;p&gt;I have this code snippet:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# import ipdb; ipdb.set_trace()&#xA;def foo():&#xA;    ...&#xA;    import ipdb; ipdb.set_trace()&#xA;    ...&#xA;    # import ipdb; ipdb.set_trace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How should I specify search query, that it would find only the uncommented &lt;code&gt;ipdb&lt;/code&gt; lines?&lt;/p&gt;&#xA;&lt;p&gt;I guess the command could look something like: &lt;code&gt;/import ipdb/(line start flag)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="147" LastEditorUserId="23502" LastEditDate="2022-11-02T19:53:58.597" LastActivityDate="2022-11-02T19:53:58.597" Title="Search for lines starting with given string in Vim?" Tags="|search|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3348" PostTypeId="2" ParentId="3347" CreationDate="2015-05-21T08:14:24.183" Score="15" Body="&lt;p&gt;How about this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^[^#]*ipdb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first &lt;code&gt;^&lt;/code&gt; will anchor the match to the start of the line, &lt;code&gt;[^#]&lt;/code&gt; will match&#xA;any character &lt;em&gt;except&lt;/em&gt; a &lt;code&gt;#&lt;/code&gt; (the &lt;code&gt;^&lt;/code&gt; means to match any character &lt;em&gt;except&lt;/em&gt;&#xA;those given), and the &lt;code&gt;*&lt;/code&gt; repeats this 0 or more times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#/%5E&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help /^&lt;/code&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#/collection&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help /[&lt;/code&gt;&lt;/a&gt; for some more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this will match all lines with &lt;code&gt;ipdb&lt;/code&gt; which don't start with a comment, including:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import other_module, ipdb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you only want to match those starting with &lt;code&gt;import ipdb&lt;/code&gt;, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^\s*import ipdb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;^&lt;/code&gt; will again anchor the match to the start of the line, &lt;code&gt;\s&lt;/code&gt; will match any whitespace character, and &lt;code&gt;*&lt;/code&gt; repeats this 0 or more times.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-21T08:27:02.637" LastActivityDate="2015-05-21T08:27:02.637" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3350" PostTypeId="1" AcceptedAnswerId="3351" CreationDate="2015-05-21T14:04:54.807" Score="3" ViewCount="538" Body="&lt;p&gt;I have a file whose content could be like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo1&#xA;bar1&#xA;foo2&#xA;bar2&#xA;bar3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to delete from the file all the lines matching the pattern &lt;code&gt;^foo&lt;/code&gt; and put them altogether somewhere else, possibly in a different file, using the &lt;code&gt;p&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried using the command &lt;code&gt;:g/^foo/&quot;Ad&lt;/code&gt; supposing each deleted line would be appended to the register &lt;code&gt;a&lt;/code&gt;. However the command doesn't delete anything nor appends anything to the register &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's wrong with the command I used? Store/append to register is not supposed to work inside a &lt;code&gt;global&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other commands I can use to achieve what I want?&lt;/p&gt;&#xA;" OwnerUserId="13" LastActivityDate="2015-05-21T14:32:47.580" Title="Append to register inside a global command" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3351" PostTypeId="2" ParentId="3350" CreationDate="2015-05-21T14:32:47.580" Score="7" Body="&lt;p&gt;You can to use the &lt;code&gt;:normal&lt;/code&gt; command along with your usage of &lt;code&gt;:global&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^foo/norm &quot;Add&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can use &lt;code&gt;:delete&lt;/code&gt; ex command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^foo/d A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :d&#xA;:h :norm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-05-21T14:32:47.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3352" PostTypeId="1" AcceptedAnswerId="3354" CreationDate="2015-05-21T14:50:17.420" Score="7" ViewCount="1433" Body="&lt;p&gt;If editing a buffer in the right side window when using two vertical split windows in a big display screen, we have to move our eyes all across the screen to the bottom left corner to see any messages Vim is displaying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is specially important because many times I need to re-indent the code I've just pasted, so I look at the &quot;X more lines&quot; message to understand how many lines I need to indent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to modify the location of these messages depending in which window the cursor is located?&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="599" LastEditDate="2015-05-21T19:05:10.857" LastActivityDate="2015-05-21T19:05:10.857" Title="Is it possible to change the message display location?" Tags="|command-line|options|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3353" PostTypeId="2" ParentId="3352" CreationDate="2015-05-21T15:50:07.393" Score="2" Body="&lt;p&gt;The &lt;em&gt;command-line&lt;/em&gt; will always span the entire width of Vim's application window; it cannot be moved or restricted; you can only influence its height via the &lt;code&gt;'cmdheight'&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to have this, you'd have to modify Vim's source code and recompile; adding static padding should be fairly easy once you've found the right place to do so.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-21T15:50:07.393" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3354" PostTypeId="2" ParentId="3352" CreationDate="2015-05-21T15:55:12.643" Score="4" Body="&lt;p&gt;Messages are displayed in the commandline, and there is no way to change the position of the commandline, except for changing the height.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only workaround I can think of is using the message history (&lt;code&gt;:messages&lt;/code&gt;), and putting that in the statusline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;:echo&lt;/code&gt; will &lt;em&gt;not&lt;/em&gt; put the message in the message history, only &lt;code&gt;:echomsg&lt;/code&gt; and &lt;code&gt;:echoerr&lt;/code&gt; do, so it won't replicate what you see in the commandline completely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, we make a function to get the last message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! LastMessage()&#xA;    redir =&amp;gt; l:test&#xA;        silent messages&#xA;    redir end&#xA;    return split(l:test, '\n')[-1]&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, we put that in the statusline with &lt;code&gt;%{&lt;/code&gt;, which will eval any expression. Note that the &lt;code&gt;statusline&lt;/code&gt; is empty by default, and created internally, so we'll have to &quot;re-create&quot; the default statusline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For bonus points, I'm also using &lt;code&gt;%1*&lt;/code&gt; to make it a different colour (the &lt;code&gt;User1&lt;/code&gt; highlight group) so it stands out a bit more.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=&#xA;let &amp;amp;stl .= '%&amp;lt;%f'                      &quot; Filename, truncate right&#xA;let &amp;amp;stl .= ' %h%m%r'                   &quot; [Help] [modified] [read-only]&#xA;let &amp;amp;stl .= ' %1*[%{LastMessage()}]%0*' &quot; Show last message from history&#xA;highlight User1 ctermbg=0 ctermfg=150 cterm=bold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's what it looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OKIOb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the bottom statusline isn't updated. This will be updated once you switch to that window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My original idea was to put 2 lines in the statusline (and putting the message above or below the default statusline), but as far as I can find out this is also not possible.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-05-21T15:55:12.643" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3355" PostTypeId="1" AcceptedAnswerId="3356" CreationDate="2015-05-21T16:30:07.003" Score="14" ViewCount="4294" Body="&lt;p&gt;I would like to highlight (part of) my statusline with &lt;code&gt;%1*&lt;/code&gt;, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%1*%f%0*&#xA;highlight User1 ctermbg=0 ctermfg=10 cterm=bold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this always shows up as &quot;empty&quot; (the default terminal colours):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Z0HOr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I type &lt;code&gt;:highlight User1&lt;/code&gt;, it shows &lt;code&gt;User1 xxx cleared&lt;/code&gt;, and if I type &lt;code&gt;:highlight User1 ctermbg=0 ctermfg=10 cterm=bold&lt;/code&gt; in the command window, it does seem to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I put this in my &lt;code&gt;.vimrc&lt;/code&gt; file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My full vimrc file I used for testing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set background=light&#xA;colorscheme default&#xA;set laststatus=2&#xA;set statusline=%1*%f%0*&#xA;&#xA;highlight User1 ctermbg=0 ctermfg=10 cterm=bold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="205" LastEditDate="2017-01-06T15:09:05.460" LastActivityDate="2017-01-06T15:09:05.460" Title="Why do custom highlights in my vimrc get cleared or reset to default?" Tags="|statusline|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3356" PostTypeId="2" ParentId="3355" CreationDate="2015-05-21T16:30:07.003" Score="17" Body="&lt;p&gt;The problem is that many (all?) colorschemes will clear all highlights with &lt;code&gt;highlight clear&lt;/code&gt; before setting their own colours. For example from &lt;code&gt;/usr/share/vim/vim74/colors/peachpuff.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; First remove all existing highlighting.&#xA;set background=light&#xA;hi clear&#xA;if exists(&quot;syntax_on&quot;)&#xA;  syntax reset&#xA;endif&#xA;&#xA;let colors_name = &quot;peachpuff&quot;&#xA;&#xA;hi Normal guibg=PeachPuff guifg=Black&#xA;&#xA;hi SpecialKey term=bold ctermfg=4 guifg=Blue&#xA;&quot; ... Many more highlights follow ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &lt;em&gt;also&lt;/em&gt; clears the &lt;code&gt;User1..9&lt;/code&gt; groups (which doesn't make a lot of sense, IMHO).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to put custom &lt;code&gt;User1..9&lt;/code&gt; highlights in the &lt;code&gt;ColorScheme&lt;/code&gt; autocmd. From &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#ColorScheme&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help ColorScheme&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;After loading a color scheme. &lt;code&gt;:colorscheme&lt;/code&gt; The pattern is matched against&#xA;  the colorscheme name. &lt;code&gt;&amp;lt;afile&amp;gt;&lt;/code&gt; can be used for the name of the actual file&#xA;  where this option was set, and &lt;code&gt;&amp;lt;amatch&amp;gt;&lt;/code&gt; for the new colorscheme name.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So instead of using a &quot;bare&quot; &lt;code&gt;highlight&lt;/code&gt; command, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd ColorScheme *&#xA;        \ highlight User1 ctermbg=0 ctermfg=10 cterm=bold |&#xA;        \ highlight User2 ctermbg=0 ctermfg=9 cterm=bold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you frequently switch colorschemes, you can even use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd ColorScheme colorscheme_one_name  highlight User1 ctermbg=0 ctermfg=10 cterm=bold&#xA;autocmd ColorScheme another_scheme        highlight User1 ctermbg=0 ctermfg=11 cterm=bold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to get colours matched to specific colorschemes.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-05-21T16:30:07.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3357" PostTypeId="1" AcceptedAnswerId="3387" CreationDate="2015-05-21T19:01:43.323" Score="1" ViewCount="204" Body="&lt;p&gt;With this &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap [ :lp^M&#xA;nnoremap ] :lne^M&#xA;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim&lt;/code&gt; becomes sluggish when switching between &quot;errors&quot; of location list with square brackets. As opposed to using &lt;code&gt;lprevious&lt;/code&gt;/&lt;code&gt;lnext&lt;/code&gt; directly. The same goes for mapping brackets to &lt;code&gt;cprevious&lt;/code&gt;/&lt;code&gt;cnext&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything is okay without enabling filetype plugins (just &lt;code&gt;filetype on&lt;/code&gt;). Or if &lt;code&gt;filetype plugin on&lt;/code&gt; is executed after &lt;code&gt;vim&lt;/code&gt; has started. Or if &lt;code&gt;vim&lt;/code&gt; is started as follows: &lt;code&gt;vim -u ~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1553" LastActivityDate="2015-05-25T04:55:39.023" Title="`filetype plugin on` and square brackets" Tags="|key-bindings|vimrc|filetype|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3358" PostTypeId="1" AcceptedAnswerId="3361" CreationDate="2015-05-22T03:38:22.087" Score="5" ViewCount="4849" Body="&lt;p&gt;Auto-complete window can be pop-ed up when I use &lt;code&gt;&amp;lt;C-N&amp;gt;&lt;/code&gt;, could I set it to pop up automatically when input keyword exceeds some length (3 characters)? YCM can do this but I don't want to install it. Does the default completion support this?&lt;/p&gt;&#xA;" OwnerUserId="477" LastActivityDate="2017-11-03T18:48:45.587" Title="Pop up auto-complete suggestion automatically?" Tags="|autocompletion|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3359" PostTypeId="1" AcceptedAnswerId="3363" CreationDate="2015-05-22T05:33:57.393" Score="87" ViewCount="102535" Body="&lt;p&gt;I installed the &lt;a href=&quot;https://github.com/bling/vim-airline&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;Airline&lt;/strong&gt;&lt;/a&gt; plugin in order to have a custom status bar, as seen in the figure below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ehqwL.gif&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, my status bar is presenting the symbols &lt;kbd&gt;&amp;lt;&lt;/kbd&gt;, &lt;kbd&gt;&gt;&gt;&lt;/kbd&gt; and &lt;kbd&gt;&amp;lt;&lt;/kbd&gt;. How do I fix this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fTd5U.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/StcxB.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/pCaOC.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2179" LastEditorUserId="927" LastEditDate="2017-07-15T15:22:35.860" LastActivityDate="2024-01-27T12:33:19.010" Title="How do I fix the status bar symbols in the Airline plugin?" Tags="|plugin-airline|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3360" PostTypeId="2" ParentId="3359" CreationDate="2015-05-22T06:13:35.753" Score="16" Body="&lt;p&gt;From the &lt;a href=&quot;https://github.com/bling/vim-airline#user-content-integrating-with-powerline-fonts&quot;&gt;README&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h1&gt;Integrating with powerline fonts&lt;/h1&gt;&#xA;  &#xA;  &lt;p&gt;For the nice looking powerline symbols to appear, you will need to install a patched font.  Instructions can be found in the official powerline &lt;a href=&quot;https://powerline.readthedocs.org/en/master/installation.html#patched-fonts&quot;&gt;documentation&lt;/a&gt;.  Prepatched fonts can be found in the &lt;a href=&quot;https://github.com/Lokaltog/powerline-fonts&quot;&gt;powerline-fonts&lt;/a&gt; repository.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Finally, you can add the convenience variable &lt;code&gt;let g:airline_powerline_fonts = 1&lt;/code&gt; to your vimrc which will automatically populate the &lt;code&gt;g:airline_symbols&lt;/code&gt; dictionary with the powerline symbols.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-05-22T06:13:35.753" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3361" PostTypeId="2" ParentId="3358" CreationDate="2015-05-22T07:16:42.227" Score="11" Body="&lt;p&gt;Automatic completion suggestions aren't built into Vim; plugins (like YouCompleteMe) implement this via &lt;code&gt;:autocmd CursorMovedI&lt;/code&gt; triggers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another plugin is &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1879&quot;&gt;AutoComplPop&lt;/a&gt;; it purely implements the automatic suggestions. Unlike YCM, it doesn't offer additional completions or any other extensions, so that may be a good alternative to try if you don't want to install YCM.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-22T07:16:42.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3362" PostTypeId="1" CreationDate="2015-05-22T07:18:58.003" Score="3" ViewCount="396" Body="&lt;p&gt;I'm using a script to load files in vim remotely into one gvim instance per desktop viewport. It works fine, except that it causes an empty additional window, that will remain after closing all others, and needs extra keystrokes to quit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there simple means of quitting in that situation, without messing up &#xA;others like creating a new text initially empty, which creates the same situation of one empty window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, the situation before the one empty window is having a second tab containing one window.&lt;br&gt;&#xA;So that could be made use of, by checking the state after closing a tab.&lt;br&gt;&#xA;But that's more of a workaround than a clean solution.&lt;/p&gt;&#xA;" OwnerUserId="925" LastEditorUserId="51" LastEditDate="2015-05-26T11:03:19.700" LastActivityDate="2015-11-10T05:48:28.670" Title="Exit when only one empty window remains" Tags="|vim-windows|quit|clientserver|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3363" PostTypeId="2" ParentId="3359" CreationDate="2015-05-22T08:20:17.907" Score="70" Body="&lt;p&gt;At first I too didn't understand what needs to be done to get this nice looking toolbar. Yes I know about the README and other stuff, but I think there should be a &lt;code&gt;getting started&lt;/code&gt; or &lt;code&gt;minimum settings&lt;/code&gt; section in the help file.&lt;/p&gt;&#xA;&lt;p&gt;Anyway here are the settings.&lt;/p&gt;&#xA;&lt;h3&gt;Installing the appropriate fonts&lt;/h3&gt;&#xA;&lt;p&gt;You need to install fonts into your system with symbols like branching, big triangles etc. They are not standard symbols so you need to install a patched font. You can find a lot of patched fonts here: &lt;a href=&quot;https://github.com/powerline/fonts&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/powerline/fonts&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;&lt;code&gt;.vimrc&lt;/code&gt; settings&lt;/h3&gt;&#xA;&lt;p&gt;From &lt;code&gt;:help airline-customization&lt;/code&gt;, place this code into your .vimrc file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; air-line&#xA;let g:airline_powerline_fonts = 1&#xA;&#xA;if !exists('g:airline_symbols')&#xA;    let g:airline_symbols = {}&#xA;endif&#xA;&#xA;&amp;quot; unicode symbols&#xA;let g:airline_left_sep = '»'&#xA;let g:airline_left_sep = '▶'&#xA;let g:airline_right_sep = '«'&#xA;let g:airline_right_sep = '◀'&#xA;let g:airline_symbols.linenr = '␊'&#xA;let g:airline_symbols.linenr = '␤'&#xA;let g:airline_symbols.linenr = '¶'&#xA;let g:airline_symbols.branch = '⎇'&#xA;let g:airline_symbols.paste = 'ρ'&#xA;let g:airline_symbols.paste = 'Þ'&#xA;let g:airline_symbols.paste = '∥'&#xA;let g:airline_symbols.whitespace = 'Ξ'&#xA;&#xA;&amp;quot; airline symbols&#xA;let g:airline_left_sep = ''&#xA;let g:airline_left_alt_sep = ''&#xA;let g:airline_right_sep = ''&#xA;let g:airline_right_alt_sep = ''&#xA;let g:airline_symbols.branch = ''&#xA;let g:airline_symbols.readonly = ''&#xA;let g:airline_symbols.linenr = ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;code&gt;unicode symbols&lt;/code&gt; section is unnecessary here if you already have a patched font but it gives you a nice fallback if you try to use other font which doesn't have the appropriate symbols.&lt;/p&gt;&#xA;&lt;h3&gt;Font settings&lt;/h3&gt;&#xA;&lt;p&gt;If you use Vim in terminal you should switch to the appropriate font in profile preferences of your terminal.&lt;/p&gt;&#xA;&lt;p&gt;If you use gui version of Vim (MacVim, GVim) you need to set the font in &lt;code&gt;.vimrc&lt;/code&gt;, for example: &lt;code&gt;set guifont=DejaVu\ Sans:s12&lt;/code&gt;. You can find more information here &lt;code&gt;:help guifont&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="1238" LastEditDate="2020-07-27T21:41:21.260" LastActivityDate="2020-07-27T21:41:21.260" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="3364" PostTypeId="1" AcceptedAnswerId="3369" CreationDate="2015-05-22T11:43:34.070" Score="95" ViewCount="32848" Body="&lt;p&gt;The normal mode command &lt;code&gt;gf&lt;/code&gt; go to a file with the path &#xA;the cursor currently is at.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it does so in the current window, replacing the current text. &#xA;That means you need to navigate back explicitly to go to the back later,&#xA;and that you need to write changes in the current buffer potentially.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure it's possible with opening the file under cursor in a new tabview instead?&lt;/p&gt;&#xA;" OwnerUserId="925" LastEditorUserId="925" LastEditDate="2019-07-15T03:31:51.160" LastActivityDate="2021-12-08T11:07:59.757" Title="Open filename under cursor like gf, but in a new tab (or split)?" Tags="|key-bindings|tabbed-user-interface|multiple-files|file-operations|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3365" PostTypeId="2" ParentId="3364" CreationDate="2015-05-22T12:09:53.090" Score="15" Body="&lt;p&gt;You can use bindings for this:&lt;/p&gt;&#xA;&lt;p&gt;opening in a new window (split):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gf &amp;lt;C-W&amp;gt;f&#xA;vnoremap gf &amp;lt;C-W&amp;gt;f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;opening in a new tab:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gf &amp;lt;C-W&amp;gt;gf&#xA;vnoremap gf &amp;lt;C-W&amp;gt;gf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;also you can check this help page:&#xA;&lt;code&gt;:help CTRL-W_gf&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2021-05-05T16:30:12.813" LastActivityDate="2021-05-05T16:30:12.813" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3367" PostTypeId="1" AcceptedAnswerId="3368" CreationDate="2015-05-22T14:16:27.757" Score="2" ViewCount="1317" Body="&lt;p&gt;Inside a &quot;logical&quot; line (I mean a vim &quot;paragraph&quot; = chars sequence terminated by a LF/CR), I would like to move cursor from the phisical line where the cursor is positionated to near lines, (e.g. &lt;strong&gt;one line UP or one line DOWN the current cursor position&lt;/strong&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By example, in the parapraph here below, I would like to move the cursor from the bottom line to one line up to sub-word &quot;&lt;em&gt;rniamo&lt;/em&gt;&quot; and again one line up word &quot;&lt;em&gt;atmosfera&lt;/em&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6DeCz.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a way to do it, just with a UP/DOWN cursor movement ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course the workaround is to jump directly to the word (eg with &lt;code&gt;/atmosfera&lt;/code&gt;), but that's time consuming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last but not least, I would prefere a way to do that in &quot;insert&quot; mode, if possible (or in normal mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea ? Suggestions ? &lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="51" LastEditDate="2015-05-22T14:29:58.327" LastActivityDate="2015-05-22T14:29:58.327" Title="Move cursor among lines inside the same paragraph?" Tags="|cursor-movement|" AnswerCount="1" CommentCount="0" ClosedDate="2015-05-22T14:27:27.550" ContentLicense="CC BY-SA 3.0" />
  <row Id="3368" PostTypeId="2" ParentId="3367" CreationDate="2015-05-22T14:24:17.523" Score="7" Body="&lt;p&gt;You can override your up and down movements to recognize wrapped text by remapping them to add the &lt;code&gt;g&lt;/code&gt; key&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap j gj&#xA;nnoremap k gk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastActivityDate="2015-05-22T14:24:17.523" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3369" PostTypeId="2" ParentId="3364" CreationDate="2015-05-22T15:08:55.337" Score="138" Body="&lt;p&gt;&lt;em&gt;EDIT: Suggest nicely symmetric mappings for the vertical split case, since Vim by default has two mappings for the horizontal split case.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several ways to edit the &quot;file under cursor&quot;, and while you certainly can remap &lt;kbd&gt;gf&lt;/kbd&gt; to edit in a new tabpage as @alexander-myshov mentions, that means you have two ways to edit it in a new tabpage, but no way to edit it in the current window, which you may also sometimes want to do. It is not hard to use the standard mappings, but if you want to remap one of them to &lt;kbd&gt;gf&lt;/kbd&gt;, I'd suggest &lt;em&gt;switching&lt;/em&gt; the mappings, so that you don't lose one of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the ways to edit a filename under the cursor are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;gf&lt;/kbd&gt; - Edit existing file under cursor in same window&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;C-W&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;  - Edit existing file under cursor in split window&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;C-W&lt;/kbd&gt;&lt;kbd&gt;C-F&lt;/kbd&gt;  - Edit existing file under cursor in split window&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;C-W&lt;/kbd&gt;&lt;kbd&gt;gf&lt;/kbd&gt; - Edit existing file under cursor in new tabpage&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There is no standard mapping to edit existing file under cursor in a vertical split, but you can achieve it by first splitting the window vertically and then editing the file under cursor in the current window.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;C-W&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;+&lt;kbd&gt;gf&lt;/kbd&gt; - Edit existing file under cursor in vertically split window&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As you can see above, there are two default mappings for editing file under cursor in a horizontal split. You can therefore remap one of them to the keystring above, extending the group of maps to also cover the vertical split case. You can bind anything, of course, but this seems to complete the symmetry nicely: &lt;code&gt;nnoremap &amp;lt;C-W&amp;gt;&amp;lt;C-F&amp;gt; &amp;lt;C-W&amp;gt;vgf&lt;/code&gt;. Now you have&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;gf&lt;/kbd&gt; - Edit existing file under cursor in same window&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;C-W&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;  - Edit existing file under cursor in split window&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;C-W&lt;/kbd&gt;&lt;kbd&gt;C-F&lt;/kbd&gt;  - Edit existing file under cursor in vertically split window&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;C-W&lt;/kbd&gt;&lt;kbd&gt;gf&lt;/kbd&gt; - Edit existing file under cursor in new tabpage&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also go to a particular line in the file, if the filename under the cursor is followed by a line number. If you have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filename:10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can edit the file and have the cursor move to line 10 with &lt;kbd&gt;gF&lt;/kbd&gt;. The equivalent is true for &lt;kbd&gt;C-W&lt;/kbd&gt;&lt;kbd&gt;F&lt;/kbd&gt; for a split and &lt;kbd&gt;C-W&lt;/kbd&gt;&lt;kbd&gt;gF&lt;/kbd&gt; for a tabpage. Completing the symmetry for a vertical split is not as straightforward here, but I would suggest that the &lt;kbd&gt;C-W&lt;/kbd&gt;&lt;kbd&gt;C-S-F&lt;/kbd&gt; map obtained with &lt;code&gt;nnoremap &amp;lt;C-W&amp;gt;&amp;lt;C-S-F&amp;gt; &amp;lt;C-W&amp;gt;vgF&lt;/code&gt;, imitating the &lt;kbd&gt;F&lt;/kbd&gt; or &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;f&lt;/kbd&gt; from the default maps as a candidate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:&lt;/code&gt; is an example, you can use any character that is not a filename character (see &lt;code&gt;:h 'isfname'&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;All these commands come with apple sauce, such as&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;expand wildchars&lt;/li&gt;&#xA;&lt;li&gt;look in more places than the current directory, according to your &lt;code&gt;'path'&lt;/code&gt; option&lt;/li&gt;&#xA;&lt;li&gt;adding a file extension to the filename, according to your &lt;code&gt;'suffixesadd'&lt;/code&gt; option&lt;/li&gt;&#xA;&lt;li&gt;otherwise modify the given filname to find a match, according to your &lt;code&gt;'includeexpr'&lt;/code&gt; option&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Read more at &lt;code&gt;:help gf&lt;/code&gt; and the help topics for these various options.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If the filename under the cursor names a file that does not exist, you may be better of using the standard edit commands with &lt;code&gt;&amp;lt;cfile&amp;gt;&lt;/code&gt;, like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit &amp;lt;cfile&amp;gt; // edit non-existent file under cursor in current window&#xA;:split &amp;lt;cfile&amp;gt; // edit non-existent file under cursor in split window&#xA;:vsplit &amp;lt;cfile&amp;gt; // edit non-existent file under cursor in vertical split window&#xA;:tabe &amp;lt;cfile&amp;gt; // edit non-existent file under cursor in new tabpage&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and with these of course you can use things like &lt;code&gt;:spl+10 filename&lt;/code&gt; to move the cursor to a particular line or &lt;code&gt;:tabe+/cologne filename&lt;/code&gt; to move the cursor to the first occurrence of a pattern.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="1306" LastEditDate="2016-01-24T19:25:26.090" LastActivityDate="2016-01-24T19:25:26.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3370" PostTypeId="1" AcceptedAnswerId="3371" CreationDate="2015-05-22T16:09:03.383" Score="13" ViewCount="3038" Body="&lt;p&gt;Normal command :sort can sort lines based on column or virtual column (&lt;code&gt;\%c&lt;/code&gt; or &lt;code&gt;\%v&lt;/code&gt;), could the higher level logical column be used as sorting key? Using regular expression looks a little complex for this scenario (the column is around the end of the line?) and it looks similar as what the sort utility does (&lt;code&gt;sork -k&lt;/code&gt;), but sort with this functionality is unavailable on Windows. Vim plug-in will also help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I'd like to sort the 2 lines below according to the last column separated by comma. My real scenario has much more columns and string pattern. Specify column delimiter will simplify it a lot.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xxx,yyy,zzz,0x123&#xA;zzxz,xxxx,yyyy,0x121&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="477" LastEditorUserId="467" LastEditDate="2016-11-14T12:29:38.833" LastActivityDate="2016-11-14T12:29:38.833" Title="Sort based on comma separated words" Tags="|regular-expression|sort|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3371" PostTypeId="2" ParentId="3370" CreationDate="2015-05-22T17:45:38.440" Score="11" Body="&lt;p&gt;Vim's sort allows you to either skip &lt;code&gt;{pattern}&lt;/code&gt;, or only consider it (with the &lt;code&gt;r&lt;/code&gt; flag). A regular expression for the last comma-delimited column is easy to formulate: Skip everything until and including the last comma in a line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sort/.*,/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For any other column, I would use the &lt;code&gt;r&lt;/code&gt; flag, and skip N (here: &lt;code&gt;2&lt;/code&gt;) previous columns via &lt;code&gt;\zs&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sort/\([^,]*,\)\{2}\zs[^,]*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2015-05-23T09:55:43.320" LastActivityDate="2015-05-23T09:55:43.320" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3372" PostTypeId="1" AcceptedAnswerId="3373" CreationDate="2015-05-22T21:51:47.657" Score="5" ViewCount="320" Body="&lt;p&gt;In my &lt;code&gt;.vimrc&lt;/code&gt; I have &lt;code&gt;set relativenumber&lt;/code&gt; and &lt;code&gt;set number&lt;/code&gt; it works in the editor but not in &lt;code&gt;:Explore&lt;/code&gt;. I have to set it manually every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I always get &lt;code&gt;set relativenumber&lt;/code&gt; and &lt;code&gt;set number&lt;/code&gt; in &lt;code&gt;:Explore&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2177" LastEditorUserId="8120" LastEditDate="2017-01-16T16:08:30.887" LastActivityDate="2017-01-16T16:08:30.887" Title="How do I setnumber and relativenumber for :Explore in .vimrc" Tags="|vimrc|line-numbers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3373" PostTypeId="2" ParentId="3372" CreationDate="2015-05-22T22:48:22.870" Score="6" Body="&lt;p&gt;You can set it in &lt;code&gt;g:netrw_bufsettings&lt;/code&gt;.  The default is &lt;code&gt;&quot;noma nomod nonu nobl nowrap ro nornu&quot;&lt;/code&gt;, so this should do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_bufsettings = &quot;noma nomod nu nobl nowrap ro rnu&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-05-22T22:48:22.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3374" PostTypeId="1" CreationDate="2015-05-23T08:17:15.587" Score="4" ViewCount="1592" Body="&lt;p&gt;I want to select some lines in visual mode, and enter a custom command &lt;code&gt;:Ex&amp;lt;CR&amp;gt;&lt;/code&gt; so that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;!expand -t4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is run to expand all tabs in selected range. How to define  the &lt;code&gt;Ex&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried things like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range Ex !expand -t4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that command just hangs, it seems that the range was not forwarded.&lt;/p&gt;&#xA;" OwnerUserId="2038" LastEditorUserId="205" LastEditDate="2015-09-20T18:51:20.860" LastActivityDate="2015-09-20T18:51:20.860" Title="How to define a custom user defined command to filter a range?" Tags="|external-command|user-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3375" PostTypeId="2" ParentId="3374" CreationDate="2015-05-23T08:17:15.587" Score="7" Body="&lt;p&gt;Ranges are not forwarded automatically, you need to use &lt;code&gt;&amp;lt;line1&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;line2&amp;gt;&lt;/code&gt; for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range Ex &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;!expand -t4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should read the manuals of &lt;code&gt;:help :command&lt;/code&gt; about &lt;code&gt;-range&lt;/code&gt; and &lt;code&gt;&amp;lt;line1&amp;gt;&lt;/code&gt;. Basically:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;if &lt;code&gt;Ex&lt;/code&gt; is called with a range, &lt;code&gt;&amp;lt;line1&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;line2&amp;gt;&lt;/code&gt; expand to that range&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;otherwise, the default value of range is used. Without any default specified, &lt;code&gt;&amp;lt;line1&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;line2&amp;gt;&lt;/code&gt; both expand to the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use: &lt;code&gt;-range=%&lt;/code&gt; to act on the entire file by default.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2038" LastActivityDate="2015-05-23T08:17:15.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3376" PostTypeId="2" ParentId="3328" CreationDate="2015-05-23T09:44:23.083" Score="10" Body="&lt;p&gt;&lt;strong&gt;EDIT 5 years later&lt;/strong&gt; I had forgotten about this question but it turns out that the perfect solution for me is &lt;a href=&quot;https://github.com/svermeulen/vim-subversive&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-subversive&lt;/a&gt; which provides two new operator motions to make it easy to perform quick substitutions.&lt;/p&gt;&#xA;&lt;p&gt;I installed the plugin and added this to my config:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nmap gc  &amp;lt;plug&amp;gt;(SubversiveSubstitute)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;this created a new command like &lt;code&gt;y&lt;/code&gt; or &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;d&lt;/code&gt; named &lt;code&gt;gc&lt;/code&gt; which delete the text targeted by the motion without putting it in the unnamed register and replace it with the content of the unnamed register.&lt;/p&gt;&#xA;&lt;p&gt;Beware, this command is so natural that it quickly becomes essential in your worklow and you will miss it a lot when you're not on your config.&lt;/p&gt;&#xA;&lt;p&gt;So after having Martin's answer accepted for 5 years I'm changing to accept this one because it's the solution I've been using daily.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Original answer&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have found another way to do it, it is a little bit similar to the option 2 but it has the advantage of not messing the state of the registers.&lt;/p&gt;&#xA;&lt;p&gt;The idea is to use the &amp;quot;&lt;strong&gt;black hole register&lt;/strong&gt;&amp;quot;: This register is accessible via &lt;code&gt;&amp;quot;_&lt;/code&gt; and has the particularity that you can write into it but not read from it, so like a black hole this register makes totally disappear anything which goes into it. Here we can use it so &lt;strong&gt;&lt;code&gt;foo&lt;/code&gt; stays in the yank register even after &lt;code&gt;bar&lt;/code&gt; deletion.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;With this solution the worflow after yanking &lt;code&gt;foo&lt;/code&gt; would be:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Going to &lt;code&gt;bar&lt;/code&gt; with &lt;code&gt;W&lt;/code&gt; (or any needed word of course)&lt;/li&gt;&#xA;&lt;li&gt;Using the &amp;quot;black hole register&amp;quot; to delete &lt;code&gt;bar&lt;/code&gt; with &lt;code&gt;&amp;quot;_de&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Putting &lt;code&gt;foo&lt;/code&gt; from the yank register with &lt;code&gt;P&lt;/code&gt;. The yank register still contains &lt;code&gt;foo&lt;/code&gt; since &lt;code&gt;bar&lt;/code&gt; went into the black hole.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I'm not sure that's is a better solution than @Martin's one (&lt;em&gt;In term of vimgolf @Martin wins&lt;/em&gt;) but I didn't know about the black hole register and I thought some might be interested to know it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="51" LastEditDate="2022-11-03T17:22:41.897" LastActivityDate="2022-11-03T17:22:41.897" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3377" PostTypeId="1" AcceptedAnswerId="3381" CreationDate="2015-05-23T14:20:02.137" Score="5" ViewCount="770" Body="&lt;p&gt;How can I get the relative number feature on old Vim versions (7.2 to be exact in my scenario) ?&lt;/p&gt;&#xA;&lt;p&gt;I cannot install a newer version because other people are also using Vim on the same server.&lt;/p&gt;&#xA;" OwnerUserId="1262" LastEditorUserId="23502" LastEditDate="2022-11-02T19:53:04.300" LastActivityDate="2022-11-02T19:53:04.300" Title="Relative number on old Vim versions" Tags="|line-numbers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3378" PostTypeId="1" AcceptedAnswerId="3380" CreationDate="2015-05-23T14:32:57.383" Score="5" ViewCount="6743" Body="&lt;p&gt;How do I refresh file tree in NERDTree ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!touch SomeNewFile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is not rendered in the tree.&lt;/p&gt;&#xA;" OwnerUserId="1262" LastActivityDate="2016-10-22T21:18:17.307" Title="Refresh files in NERDTree?" Tags="|plugin-nerdtree|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3379" PostTypeId="1" AcceptedAnswerId="3456" CreationDate="2015-05-23T14:44:15.453" Score="15" ViewCount="8761" Body="&lt;p&gt;How can I have different cursor shapes when running vim inside tmux under cygwin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;WITHOUT tmux these lines would be enough to achieve what I want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;t_SI = &quot;\e[5 q&quot;&#xA;let &amp;amp;t_EI = &quot;\e[2 q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But somehow my tmux breaks it - cursor has block shape no matter what vim mode I'm in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My specs:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Windows 7 x64  &lt;/li&gt;&#xA;&lt;li&gt;Cygwin x86  &lt;/li&gt;&#xA;&lt;li&gt;TMUX 1.9a  &lt;/li&gt;&#xA;&lt;li&gt;Vim 7.4.726 (compiled with +cursorshape)  &lt;/li&gt;&#xA;&lt;li&gt;terminal emulator: mintty 1.1.3  &lt;/li&gt;&#xA;&lt;li&gt;used in Cygwin Terminal or Cmder (either way, cursor shapes work only without TMUX)  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;echo $TERM&lt;/code&gt; gives me &lt;code&gt;screen-256color&lt;/code&gt; (in TMUX and outside of it, because i have &lt;code&gt;export TERM=screen-256color&lt;/code&gt; in my &lt;code&gt;.bashrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.tmux.conf&lt;/code&gt; contains:&lt;br&gt;&#xA;&lt;code&gt;set -g default-terminal &quot;screen-256color&quot;&#xA;setw -g xterm-keys on&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What i tried already&lt;/strong&gt; without success:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;export TERM=xterm&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;export TERM=vt100&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&quot;rightclick on bar &gt; Options &gt; Looks &gt; Cursor&quot; (it changes the cursor permanently, vim modes still don't change it)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1067" LastEditorUserId="1067" LastEditDate="2015-05-29T13:21:56.770" LastActivityDate="2015-05-29T13:21:56.770" Title="Cursor shape under vim + tmux" Tags="|tmux|cygwin|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="3380" PostTypeId="2" ParentId="3378" CreationDate="2015-05-23T14:46:11.057" Score="13" Body="&lt;p&gt;The NERD tree quick help is accessible from the NERD tree window by typing &lt;kbd&gt;?&lt;/kbd&gt; There I read:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot; Filesystem mappings~&lt;br&gt;&#xA;  ...&lt;br&gt;&#xA;  &quot; r: refresh cursor dir&lt;br&gt;&#xA;  &quot; R: refresh current root  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;These should do what you ask.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-05-23T14:46:11.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3381" PostTypeId="2" ParentId="3377" CreationDate="2015-05-23T14:46:46.360" Score="5" Body="&lt;p&gt;Relative numbers were officially added to Vim with the 7.3 release.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can't update Vim or can't compile your own you will need to install a plugin like &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2351&quot;&gt;DrChip's RltvNmbr&lt;/a&gt;. Maybe there are others. Note that it requires the &lt;code&gt;+signs&lt;/code&gt; feature which you may or may not have.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-05-23T14:46:46.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3382" PostTypeId="1" AcceptedAnswerId="3383" CreationDate="2015-05-24T10:15:44.297" Score="16" ViewCount="3643" Body="&lt;p&gt;I recently read about the black hole register &lt;code&gt;&quot;_&lt;/code&gt; which is a write-only register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim documentation describes it this way:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;9&quot;&gt;&#xA;  &lt;li&gt;Black hole register &quot;_&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;  &#xA;  &lt;p&gt;When writing to this register, nothing happens.  This can be used to delete&#xA;  text without affecting the normal registers.  When reading from this register, nothing is returned.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In all the articles and books I read the authors always use the same example which is to use this register when we need to delete some text without erasing what we previously yanked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand this use but I'm surprised by the fact that I can't find other use cases of this register, which leads me to 2 questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Is this register useful in some other use cases&lt;/strong&gt;? If yes, which ones?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the only purpose of this register is to be used in the use case I quoted before, &lt;strong&gt;why did the creators of Vim decided to solve this problem with such a register&lt;/strong&gt;? I mean &lt;a href=&quot;https://vi.stackexchange.com/a/3329/1841&quot;&gt;this answer&lt;/a&gt; shows a solution to the problem which implies less keystrokes than using &lt;code&gt;&quot;_&lt;/code&gt;. Using &lt;code&gt;&quot;0&lt;/code&gt; can also avoid the use of the black hole register so why did they create it?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2018-03-04T17:28:21.347" Title="What is the use of the black hole register (&quot;_)?" Tags="|register|history-of|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3383" PostTypeId="2" ParentId="3382" CreationDate="2015-05-24T11:54:07.217" Score="20" Body="&lt;p&gt;The black hole register is used in the same situations as &lt;code&gt;/dev/null&lt;/code&gt;: when you do an action that normally outputs something but you have no use for that output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's default behavior is to &quot;cut&quot;, not &quot;delete&quot;. In most cases it doesn't matter but, sometimes, users may actually need to &quot;delete&quot;. That's where the black hole register comes handy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is this register useful in some other use cases?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The black hole register is here to let us cut stuff without clobbering the unnamed register and the numbered registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The possible use cases are numerous but all unsurprisingly very similar:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;provide an actual &quot;delete&quot;,&lt;/li&gt;&#xA;&lt;li&gt;have a better control over registers, mainly the unnamed one,&lt;/li&gt;&#xA;&lt;li&gt;keep the numbered registers in a stable state,&lt;/li&gt;&#xA;&lt;li&gt;cut something while retaining the ability to put from the unnamed register, giving us &quot;repeatable puts&quot;,&lt;/li&gt;&#xA;&lt;li&gt;put something over something you don't care about,&lt;/li&gt;&#xA;&lt;li&gt;prevent side effects in scripts…&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;One could use &lt;code&gt;&quot;0p&lt;/code&gt; for the &quot;repeated puts&quot; scenario (the most common use case, hence its ubiquity in the Vim literature) but that register is far from being as useful as &lt;code&gt;&quot;_&lt;/code&gt; for the other scenarios.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-05-24T11:54:07.217" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3384" PostTypeId="1" AcceptedAnswerId="3385" CreationDate="2015-05-24T16:20:10.640" Score="0" ViewCount="319" Body="&lt;p&gt;I do some automatic setup in my vimrc that calls git clone, before any other plugins (such as dispatch.vim) are installed. It's called after some other messages are displayed using &lt;code&gt;echom&lt;/code&gt;, and I'd like to to execute without clearing the screen at all. I've been messing around with &lt;code&gt;redir&lt;/code&gt;, &lt;code&gt;shellredir&lt;/code&gt; and &lt;code&gt;shortmess&lt;/code&gt;, but nothing has worked so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; some other messages are displayed and in the buffer ...&#xA;&#xA;&quot; install neobundle&#xA;if $HAS_GIT == 1&#xA;&#xA;  &quot; display the inline message notifying user neobundle is being installed,&#xA;  &quot; I want this to displayed inline with the other messages&#xA;  echom 'installing neobundle ...'&#xA;&#xA;  &quot; trying to use shellredir to temporarily disable external command&#xA;  &quot; from displaying any output and causing the screen refresh - doesn't work&#xA;  let shellredir_restore = &amp;amp;shellredir&#xA;  let &amp;amp;shellredir = '&amp;gt;/dev/null'&#xA;&#xA;  &quot; trying to use redir to temporarily disable external command&#xA;  &quot; from displaying any output and causing the screen refresh - doesn't work&#xA;  redir &amp;gt;&amp;gt; /dev/null&#xA;&#xA;  &quot; silently execute git clone as a synchronous task - desired behavior. &#xA;  silent execute '!git clone ' g:neobundle_url . ' ' . g:neobundle_dir . '&amp;amp;&amp;gt;/dev/null'&#xA;&#xA;  &quot; once this command completes, the screen is cleared and additional&#xA;  &quot; 'inline' messages (that should be displayed) are, but with the&#xA;  &quot; previous messages removed. all output after this point is written at&#xA;  &quot; the *bottom* of the buffer.&#xA;&#xA;  &quot; end vim output redirection&#xA;  redir END&#xA;&#xA;  &quot; check if git clone completely successfully&#xA;  if v:shell_error == 0&#xA;    let s:neobundle_installed = 1&#xA;  else&#xA;    let s:neobundle_installed = 0&#xA;  endif&#xA;&#xA;  &quot; restore shellredir to original value&#xA;  let &amp;amp;shellredir = shellredir_restore&#xA;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So to clarify:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;i want to suppress all output from git clone&lt;/li&gt;&#xA;&lt;li&gt;i want to prevent the refresh by the git clone, which clears previous messages&lt;/li&gt;&#xA;&lt;li&gt;i want additional messages after the git clone to be drawn 'inline' as normal, not at the bottom of the screen&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="2207" LastActivityDate="2015-05-24T17:07:25.163" Title="Avoid Redraw When Running External Command" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3385" PostTypeId="2" ParentId="3384" CreationDate="2015-05-24T17:07:25.163" Score="4" Body="&lt;p&gt;For running &lt;code&gt;git&lt;/code&gt; without screen refreshes I suggest leaving alone all shell-related options and redirs, and doing it like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:neobundle_installed = 0&#xA;if executable('git')&#xA;    call system('git clone ' . shellescape(g:neobundle_url) . ' ' . shellescape(g:neobundle_dir))&#xA;    let s:neobundle_installed = v:shell_error == 0&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have no idea what you mean by &quot;additional messages&quot;, and by &quot;drawing&quot; them &quot;inline&quot;.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-05-24T17:07:25.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3386" PostTypeId="1" AcceptedAnswerId="3394" CreationDate="2015-05-25T01:09:20.600" Score="27" ViewCount="7523" Body="&lt;p&gt;Sometimes I need to move windows into an already existing tab, and I was wondering if there was a command/keyboard shortcut that could do this.  I know I can close the window, switch to the tab, and then open it in a new split, but I was wondering if there was a shorter way of accomplishing this.  Note that I want to move it to an &lt;em&gt;existing&lt;/em&gt; tab, not a new tab like &lt;code&gt;&amp;lt;C-w&amp;gt;T&lt;/code&gt; does.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="24" LastEditDate="2015-05-26T08:39:44.553" LastActivityDate="2021-06-27T00:49:02.480" Title="Move existing window to existing tab" Tags="|vim-windows|tabbed-user-interface|" AnswerCount="7" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3387" PostTypeId="2" ParentId="3357" CreationDate="2015-05-25T04:55:39.023" Score="1" Body="&lt;p&gt;Thanks to &lt;a href=&quot;https://vi.stackexchange.com/questions/3357/filetype-plugin-on-and-square-brackets#comment4692_3357&quot;&gt;@romainl&lt;/a&gt;, it turns out the delay is caused by ftplugin &lt;a href=&quot;https://github.com/vim-ruby/vim-ruby/blob/vim7.4/ftplugin/ruby.vim#L149-165&quot; rel=&quot;nofollow noreferrer&quot;&gt;defining&lt;/a&gt; mappings starting with &lt;code&gt;[&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1553" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-05-25T04:55:39.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3388" PostTypeId="1" AcceptedAnswerId="3389" CreationDate="2015-05-25T09:05:30.377" Score="48" ViewCount="30412" Body="&lt;p&gt;I wrote a little Vim function that moves the cursor to the first character of the current line. If the cursor was already on the first character, then the cursor is moved to the first column instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Jump to first character or column&#xA;noremap H :call FirstCharOrFirstCol()&amp;lt;cr&amp;gt;&#xA;&#xA;:function! FirstCharOrFirstCol()&#xA;:  let current_col = virtcol('.')&#xA;:  normal ^&#xA;:  let first_char = virtcol('.')&#xA;:  if current_col == first_char&#xA;:    normal 0&#xA;:  endif&#xA;:endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I call this function silently? I’d rather ‘:call FirstCharOrFirstCol()’ wasn’t displayed in the status line. Simply changing to &lt;code&gt;noremap H :silent call…&lt;/code&gt; doesn’t seem to be enough.&lt;/p&gt;&#xA;" OwnerUserId="2191" LastActivityDate="2022-02-22T23:19:39.757" Title="Call a Vim function silently" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3389" PostTypeId="2" ParentId="3388" CreationDate="2015-05-25T09:41:39.240" Score="60" Body="&lt;p&gt;You can call the function silently by defining a silent map:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; H :call FirstCharOrFirstCol()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For more info, see &lt;code&gt;:h :map-&amp;lt;silent&amp;gt;&lt;/code&gt;. Note in particular that this will only ensure that the command is not echoed to screen when the mapping is executed. The &lt;code&gt;:silent&lt;/code&gt; command is used to silence output from the function itself, and with a &lt;code&gt;!&lt;/code&gt; to silence all errors (see &lt;code&gt;:h :silent&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="10604" LastEditDate="2021-01-06T14:50:48.627" LastActivityDate="2021-01-06T14:50:48.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3390" PostTypeId="2" ParentId="2764" CreationDate="2015-05-25T14:53:27.543" Score="18" Body="&lt;p&gt;Neovim terminal buffers always have an associated job id, so one way is to use the job control API to send the text. Add this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup Terminal&#xA;  au!&#xA;  au TermOpen * let g:last_terminal_job_id = b:terminal_job_id&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will save the the job id of the last created terminal into the &lt;code&gt;g:last_terminal_job_id&lt;/code&gt; variable. Then you can create some functions/commands/mappings that will send the data using the &lt;code&gt;jobsend&lt;/code&gt; function, here's an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! REPLSend(lines)&#xA;  call jobsend(g:last_terminal_job_id, add(a:lines, ''))&#xA;endfunction&#xA;&#xA;command! REPLSendLine call REPLSend([getline('.')])&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;f6&amp;gt; :REPLSendLine&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above would send the current line, but you can extend it to send visual selection.&lt;/p&gt;&#xA;" OwnerUserId="2218" LastActivityDate="2015-05-25T14:53:27.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3391" PostTypeId="1" AcceptedAnswerId="3393" CreationDate="2015-05-25T15:15:07.990" Score="16" ViewCount="1818" Body="&lt;p&gt;I have some plugins installed for vim, I would like to know how can I find out what plugin uses most resources (CPU, RAM) ?&lt;/p&gt;&#xA;" OwnerUserId="1262" LastEditorUserId="51" LastEditDate="2015-05-25T18:05:34.827" LastActivityDate="2022-06-13T22:16:49.113" Title="Detect most resource hungry plugin" Tags="|plugin-system|performance|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3392" PostTypeId="2" ParentId="3328" CreationDate="2015-05-25T15:57:38.343" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to start of &quot;foo&quot;. Press &lt;code&gt;yiw&lt;/code&gt;. That yanks the inner word.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to &quot;bar&quot; pressing the letter &lt;code&gt;w&lt;/code&gt;. Then select it and yank back: &lt;code&gt;viw&quot;0p&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;ciw&lt;/code&gt; and &lt;code&gt;yiw&lt;/code&gt; a lot.&lt;/p&gt;&#xA;" OwnerUserId="2220" LastEditorUserId="51" LastEditDate="2015-05-29T23:00:39.497" LastActivityDate="2015-05-29T23:00:39.497" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3393" PostTypeId="2" ParentId="3391" CreationDate="2015-05-25T16:17:46.137" Score="14" Body="&lt;p&gt;This isn't really possible.  Vim doesn't have any concept of isolation, everything lives in a big, happy, single-threaded process, and resources are democratically shared among all plugins.  The best you can do is enable profiling (see &lt;code&gt;:help profiling&lt;/code&gt;) and see which functions take the most time to run, but that won't tell you much about either CPU or memory use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might consider asking the neovim people though, they might have pondered about these issues.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-05-25T16:17:46.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3394" PostTypeId="2" ParentId="3386" CreationDate="2015-05-26T08:13:03.613" Score="16" Body="&lt;p&gt;Though there are commands to move existing windows around in the current tab page (i.e. affect the window layout by rotating, resizing, and moving), there are no commands to move a window to another tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a window is just a viewport into a loaded buffer, you have to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Note the buffer number displayed in the current window.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:close!&lt;/code&gt; the window.&lt;/li&gt;&#xA;&lt;li&gt;Switch to the existing target tab page.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:sbuffer&lt;/code&gt; the buffer number to re-open it.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You'll lose any window-specific options by this. You could save and restore those in a script, too.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-26T08:13:03.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3395" PostTypeId="1" CreationDate="2015-05-26T10:10:54.300" Score="3" ViewCount="852" Body="&lt;p&gt;How to define a specified RGB value as color with customized name in Vim script, much like the existing color &lt;code&gt;Black&lt;/code&gt;, &lt;code&gt;Gray&lt;/code&gt;, etc. &lt;/p&gt;&#xA;" OwnerUserId="477" LastActivityDate="2015-05-26T11:01:01.873" Title="Define color with customized name" Tags="|colorscheme|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3396" PostTypeId="2" ParentId="3395" CreationDate="2015-05-26T10:32:41.933" Score="4" Body="&lt;p&gt;tl;dr: it seems you can't do this. Sorry :-(&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Longer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For terminals, there is a static list of 28 colors in &lt;code&gt;syntax.c&lt;/code&gt; which defined&#xA;the names (around line 7306):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static char *(color_names[28]) = {&#xA;            &quot;Black&quot;, &quot;DarkBlue&quot;, &quot;DarkGreen&quot;, &quot;DarkCyan&quot;,&#xA;            &quot;DarkRed&quot;, &quot;DarkMagenta&quot;, &quot;Brown&quot;, &quot;DarkYellow&quot;,&#xA;            &quot;Gray&quot;, &quot;Grey&quot;,&#xA;            &quot;LightGray&quot;, &quot;LightGrey&quot;, &quot;DarkGray&quot;, &quot;DarkGrey&quot;,&#xA;            &quot;Blue&quot;, &quot;LightBlue&quot;, &quot;Green&quot;, &quot;LightGreen&quot;,&#xA;            &quot;Cyan&quot;, &quot;LightCyan&quot;, &quot;Red&quot;, &quot;LightRed&quot;, &quot;Magenta&quot;,&#xA;            &quot;LightMagenta&quot;, &quot;Yellow&quot;, &quot;LightYellow&quot;, &quot;White&quot;, &quot;NONE&quot;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The exact value of those colours will depend on your terminal, but the most used is probably:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* for xterm with 256 colors... */&#xA;static int color_numbers_256[28] = {0, 4, 2, 6,&#xA;                                    1, 5, 130, 130,&#xA;                                    248, 248,&#xA;                                    7, 7, 242, 242,&#xA;                                    12, 81, 10, 121,&#xA;                                    14, 159, 9, 224, 13,&#xA;                                    225, 11, 229, 15, -1};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no way I see in the code to add a colour name from VimScript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For gVim, the code is slightly different. The function &lt;code&gt;gui_mch_get_color()&lt;/code&gt; in&#xA;the &lt;code&gt;gui_*.c&lt;/code&gt; files handles this. The precise content differs for every GUI&#xA;backend,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, for the GTK2 GUI it uses the &lt;code&gt;gdk_color_parse()&lt;/code&gt; function, for X11&#xA;it uses &lt;code&gt;XParseColor&lt;/code&gt;, and for Windows it seems to use a static list.&#xA;Perhaps some of these systems allow defining custom colour names; but this is&#xA;not something you can do from within VimScript as such.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-26T11:01:01.873" LastActivityDate="2015-05-26T11:01:01.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3397" PostTypeId="1" AcceptedAnswerId="3400" CreationDate="2015-05-26T16:12:24.440" Score="7" ViewCount="3035" Body="&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; chooses my preferred color scheme (solarized) which is installed via  plugin management system. Yet on some systems which don't have that plugin the &lt;code&gt;:colorscheme solarized&lt;/code&gt; command runs but the result is whacky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;how do I conditionally test if solarized is indeed installed and use it if it is but use a different (built in) color scheme if not?&lt;/p&gt;&#xA;" OwnerUserId="544" LastActivityDate="2015-05-26T17:22:29.540" Title="How do I conditionally set :colorscheme?" Tags="|vimscript|vimrc|colorscheme|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3398" PostTypeId="2" ParentId="3397" CreationDate="2015-05-26T16:46:27.370" Score="3" Body="&lt;p&gt;If you want to accomplish this programmatically you will need to check the list of available colorschemes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this in &lt;code&gt;:Ex&lt;/code&gt; mode is fairly trivial (type &lt;code&gt;:colorscheme&lt;/code&gt; and then tab complete through a list of available colors). While this is a great way to check available colorschemes in general it will not solve your specific problem..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to verify that a colorscheme like solarized (not installed by default) is installed you will need to check the file is installed in the &lt;code&gt;~/.vim/colors/yourscheme.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this you will need to add the following conditional check to your &lt;code&gt;vimrc&lt;/code&gt; (may vary depending on your install):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !empty(glob(&quot;~/.vim/colors/solarized.vim&quot;))&#xA;  colorscheme solarized&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;glob&lt;/code&gt; will expand the directory and return a string with the full pathname if the file is present. When no file is present it will return an empty string. Hopefully this approach is enough to take care of those pesky machines that don't have solarized installed!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Edit&lt;/em&gt;&lt;/strong&gt;&#xA;If you prefer to use &lt;code&gt;filereadable&lt;/code&gt; (will simply return true/false) you will need to use &lt;code&gt;expand&lt;/code&gt; in order to get the global directory.&lt;/p&gt;&#xA;" OwnerUserId="2189" LastActivityDate="2015-05-26T16:46:27.370" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3400" PostTypeId="2" ParentId="3397" CreationDate="2015-05-26T17:22:29.540" Score="16" Body="&lt;h3&gt;Lets fail with Style!&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! colorscheme evening&#xA;silent! colorscheme solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:silent!&lt;/code&gt; will ignore the errors at start up. Just put color schemes in reverse order of what you really want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :silent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-05-26T17:22:29.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3402" PostTypeId="1" AcceptedAnswerId="3404" CreationDate="2015-05-26T21:20:41.727" Score="10" ViewCount="6038" Body="&lt;p&gt;When I learned to program, I would press both the opening and closing brackets/etc then the left arrow key then enter the text. So to put in &lt;code&gt;[hello]&lt;/code&gt; I would type &lt;code&gt;[]&lt;/code&gt;, and then the left arrow so that it is over the first bracket (&lt;code&gt;[&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like that because I know I always have the right number of brackets/etc and otherwise I feel like my hand has to move back and forth to the bracket/etc key&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, in sticking with the Vim mindset, I don't want to continually reach for the arrow keys. Is there anything I could do that didn't involve using the arrow keys or having to continually switch out of insert mode to just press &lt;code&gt;h&lt;/code&gt; and go back in?&lt;/p&gt;&#xA;" OwnerUserId="217" LastEditorUserId="23502" LastEditDate="2022-11-02T09:08:40.623" LastActivityDate="2022-11-02T09:08:40.623" Title="Using Vim when press both opening and closing parenthesis/brackets/etc" Tags="|cursor-movement|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3403" PostTypeId="2" ParentId="3402" CreationDate="2015-05-26T22:01:39.433" Score="8" Body="&lt;p&gt;There are plenty of &lt;a href=&quot;http://vimawesome.com/?q=pair&quot;&gt;&quot;pair&quot; plugins&lt;/a&gt; that do this for you automatically. However all of them rub me the wrong way. I tend to use Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-surround&quot;&gt;surround.vim&lt;/a&gt; plugin. I do the following: &lt;code&gt;&amp;lt;c-s&amp;gt;]&lt;/code&gt; in insert mode to insert &lt;code&gt;[]&lt;/code&gt; with the cursor in the middle of the brackets.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-05-26T22:01:39.433" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3404" PostTypeId="2" ParentId="3402" CreationDate="2015-05-26T22:49:29.247" Score="5" Body="&lt;p&gt;You might be looking for the &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot;&gt;auto-pairs&lt;/a&gt; plugin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you type a character like &lt;code&gt;{&lt;/code&gt;, &lt;code&gt;(&lt;/code&gt; or &lt;code&gt;[&lt;/code&gt; this plugin will automatically add the symetric character and replace your cursor in insert mode between the two brackets. It is also able to be &quot;smart&quot; while deleting those characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also if I may give you an advice &lt;strong&gt;forget the arrow keys&lt;/strong&gt;. Whatever you want to do, there is always a faster motion accessible without moving your hands from the home row. It may take some time to get used to it, but once it is an habit you won't even miss them.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-05-26T22:49:29.247" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3405" PostTypeId="1" AcceptedAnswerId="3406" CreationDate="2015-05-27T07:02:51.003" Score="10" ViewCount="335" Body="&lt;p&gt;I'm planning to implement some utility mappings for my &lt;a href=&quot;https://github.com/lervag/vimtex&quot;&gt;LaTeX plugin&lt;/a&gt; to simplify typing of mathematics. For instance, I want to create abbreviations similar to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`a : \alpha&#xA;`b : \beta&#xA;-&amp;gt; : \to&#xA;=&amp;gt; : \Rightarrow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And similar. I want (some of) the mappings only to be available inside math environments, and not outside.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can recognize math environments through the syntax groups, i.e. &lt;code&gt;texMathZoneE&lt;/code&gt; and &lt;code&gt;texMathZoneX&lt;/code&gt;. However, I do not know how to use this in order to make context sensitive mappings or abbreviations.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="51" LastEditDate="2015-05-27T13:49:25.643" LastActivityDate="2015-05-27T13:49:25.643" Title="Context sensitive insert mode mapping or abbreviation" Tags="|key-bindings|filetype-tex|abbreviations|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3406" PostTypeId="2" ParentId="3405" CreationDate="2015-05-27T08:40:03.580" Score="5" Body="&lt;p&gt;Perhaps like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:TeXmaps = {&#xA;    \ '`a': '\alpha',&#xA;    \ '`b': '\beta',&#xA;    \ '-&amp;gt;': '\to',&#xA;    \ '=&amp;gt;': '\Rightarrow' }&#xA;&#xA;function! &amp;lt;SID&amp;gt;IsTeXMath()&#xA;    return &amp;amp;ft ==# 'tex' &amp;amp;&amp;amp; match(map( synstack(line('.'), col('.')), 'synIDattr(v:val, &quot;name&quot;)' ), '\m^texMathZone[EX]$') &amp;gt;= 0&#xA;endfunction&#xA;&#xA;for s:k in keys(s:TeXmaps)&#xA;    silent! exec 'inoremap &amp;lt;silent&amp;gt; ' . s:k . ' &amp;lt;C-r&amp;gt;=&amp;lt;SID&amp;gt;IsTeXMath()?' . string(s:TeXmaps[s:k]) . ':' . string(s:k) . '&amp;lt;CR&amp;gt;'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-05-27T08:40:03.580" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3407" PostTypeId="1" AcceptedAnswerId="3409" CreationDate="2015-05-27T10:20:02.837" Score="2" ViewCount="156" Body="&lt;p&gt;I'm using &lt;strong&gt;nvi&lt;/strong&gt; on Mac OS X 10.10.3, installed from MacPorts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever I start the editor, the following message is displayed in my console:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./en_US.UTF-8: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm just curious as to what it tries to do. &lt;code&gt;en_US.UTF-8&lt;/code&gt; happens to be my locale setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ locale&#xA;LANG=&quot;en_US.UTF-8&quot;&#xA;LC_COLLATE=&quot;en_US.UTF-8&quot;&#xA;LC_CTYPE=&quot;en_US.UTF-8&quot;&#xA;LC_MESSAGES=&quot;en_US.UTF-8&quot;&#xA;LC_MONETARY=&quot;en_US.UTF-8&quot;&#xA;LC_NUMERIC=&quot;en_US.UTF-8&quot;&#xA;LC_TIME=&quot;en_US.UTF-8&quot;&#xA;LC_ALL=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2252" LastEditorUserId="51" LastEditDate="2015-05-28T15:30:44.910" LastActivityDate="2015-05-28T15:34:25.233" Title="I get the error &quot;./en_US.UTF-8: No such file or directory&quot; when starting nvi" Tags="|startup|nvi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3408" PostTypeId="2" ParentId="3405" CreationDate="2015-05-27T10:22:22.407" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/LucHermitte/lh-brackets&quot; rel=&quot;nofollow&quot;&gt;lh-brackets&lt;/a&gt; provides the &lt;code&gt;Map4TheseContexts()&lt;/code&gt; function that takes care of detecting the context to do different things.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; To be defined in a tex ftplugin -&amp;gt; ~/.vim/ftplugin/tex/your-shortcuts.vim&#xA;:inoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; `a &amp;lt;c-r&amp;gt;=Map4TheseContexts('`a', 'texMathZone', '\\alpha', '`a')&amp;lt;cr&amp;gt;&#xA;&quot; or:&#xA;:inoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; `a Map4TheseContexts('`a', 'texMathZone', '\\alpha', '`a')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: If you have installed latex-suite, you'll have instead to use its &lt;code&gt;IMAP()&lt;/code&gt; function to define your new mappings -- this is because latex-suite is quite intrusive regarding mappings.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2015-05-27T10:32:27.267" LastActivityDate="2015-05-27T10:32:27.267" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3409" PostTypeId="2" ParentId="3407" CreationDate="2015-05-27T10:24:06.510" Score="4" Body="&lt;p&gt;This seems to be an &lt;em&gt;old&lt;/em&gt; but &lt;a href=&quot;https://trac.macports.org/ticket/25733&quot; rel=&quot;nofollow&quot;&gt;known problem on OS X&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This issue has &lt;a href=&quot;https://trac.macports.org/attachment/ticket/25733/nvilangmsg.patch&quot; rel=&quot;nofollow&quot;&gt;a patch&lt;/a&gt;, which is unfortunately not yet incorporated. You can apply it manually to fix your &lt;code&gt;nvi&lt;/code&gt; build.&lt;/p&gt;&#xA;" OwnerUserId="2252" LastEditorUserId="51" LastEditDate="2015-05-28T15:34:25.233" LastActivityDate="2015-05-28T15:34:25.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3410" PostTypeId="2" ParentId="3402" CreationDate="2015-05-27T10:31:45.087" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/LucHermitte/lh-brackets#the-bracketing-subsystem&quot; rel=&quot;nofollow&quot;&gt;lh-brackets&lt;/a&gt; provides insert, normal and visual mode mappings to insert pair of brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Adding new bracket pairs is quite easy. &lt;/li&gt;&#xA;&lt;li&gt;The insert mode mappings are context sensitive -- i.e. not expanded within string or comment contexts, ... &lt;/li&gt;&#xA;&lt;li&gt;Unlike surround plugin, the surrounding mappings are intuitive, but not in vim style. i.e. hitting &lt;code&gt;(&lt;/code&gt; in visual mode will surround (by default), we don't have to hit &lt;code&gt;si(&lt;/code&gt; or similar sequences.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastActivityDate="2015-05-27T10:31:45.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3411" PostTypeId="1" AcceptedAnswerId="3413" CreationDate="2015-05-27T13:17:59.330" Score="21" ViewCount="14923" Body="&lt;p&gt;I have a repetitive configuration file and I'd like to match a regex and delete a range of lines before, and after a match.  I'd also like delete the match in one command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can use...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:g/match/-1d&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...several times to delete more than one line from before a match...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...and combine it with a few calls to...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:g/match/+1d&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...to delete more than one line after the match...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But is there any way to delete a range of lines, before, after and including, the match with one command?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="51" LastEditDate="2015-05-27T13:46:06.347" LastActivityDate="2015-05-27T13:46:06.347" Title="Deleting a range of n lines before and after a matched line?" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3412" PostTypeId="2" ParentId="3391" CreationDate="2015-05-27T13:26:40.123" Score="4" Body="&lt;p&gt;Maybe one approach could be&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim --startuptime vim.log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then you can sort vim.log output to get the most time consuming plugin. You can then profile vim startup with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim -c 'profile start vim.log' -c 'profile func *' -c 'q'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is rather verbose, but will print every function loading time, this way you can measure which function/plugin delay vim loading.&lt;/p&gt;&#xA;&lt;p&gt;Take a look at this post&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://medium.com/usevim/improving-vims-startup-time-beb3f83cbfe8&quot; rel=&quot;nofollow noreferrer&quot;&gt;Improving Vim's Startup Time&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="515" LastEditorUserId="23502" LastEditDate="2022-06-13T22:16:49.113" LastActivityDate="2022-06-13T22:16:49.113" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3413" PostTypeId="2" ParentId="3411" CreationDate="2015-05-27T13:29:08.700" Score="32" Body="&lt;p&gt;You're almost there; you can also specify a range of lines, which is in the form of &lt;code&gt;[line1],[line2][command]&lt;/code&gt;, instead of just &lt;code&gt;[line][command]&lt;/code&gt; (like you're using now).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;.&lt;/code&gt; to refer to the current line.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For the current &amp;amp; next line: &lt;code&gt;:g/match/.,+1d&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;For the current &amp;amp; previous line: &lt;code&gt;:g/match/-1,.d&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;For the previous, current, and next line: &lt;code&gt;:g/match/-1,+1d&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#E16&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help [range]&lt;/code&gt;&lt;/a&gt; for more information, and &lt;a href=&quot;https://vi.stackexchange.com/a/3232/51&quot;&gt;in this answer there are a few more examples&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-05-27T13:29:08.700" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3414" PostTypeId="5" CreationDate="2015-05-27T13:57:47.427" Score="0" Body="&lt;p&gt;File type determine a number of Vim behaviors:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The indentation&lt;/li&gt;&#xA;&lt;li&gt;The comment&lt;/li&gt;&#xA;&lt;li&gt;The reference to other files (e.g. include, modules, ...)&lt;/li&gt;&#xA;&lt;li&gt;The syntax&lt;/li&gt;&#xA;&lt;li&gt;The auto-completion&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This tag to group questions about how the file type tex control these behaviors.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="23502" LastEditDate="2023-02-24T13:50:30.020" LastActivityDate="2023-02-24T13:50:30.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3415" PostTypeId="4" CreationDate="2015-05-27T13:57:47.427" Score="0" Body="Questions about editing Tex documents, either with or without a frontend such a LaTeX." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-27T13:57:47.427" LastActivityDate="2015-05-27T13:57:47.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3416" PostTypeId="2" ParentId="3341" CreationDate="2015-05-27T14:19:49.873" Score="6" Body="&lt;p&gt;vim doesn't need gnome or gtk to get &lt;code&gt;+clipboard&lt;/code&gt;, but it does need x11. From my tests, the minimum amount of dependencies needed are the xorg header files and x11 dbus support.  In Debian&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apt-get install x11-dev dbus-x11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will do the job. Then you can&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --with-features=huge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;em&gt;vioala&lt;/em&gt;, &lt;code&gt;+clipboard&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="69" LastEditDate="2015-07-13T19:21:25.617" LastActivityDate="2015-07-13T19:21:25.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3417" PostTypeId="2" ParentId="3402" CreationDate="2015-05-27T15:03:55.987" Score="4" Body="&lt;p&gt;If you just need to move one space, &lt;Kbd&gt;ctrl-o&lt;/kbd&gt; in insert mode makes your next input a normal command, so &lt;kbd&gt;ctrl-o&lt;/kbd&gt;, &lt;kbd&gt;h&lt;/kbd&gt; will move back one. The modeline will display &lt;code&gt;--- (insert) ---&lt;/code&gt; until you input the normal command.&lt;/p&gt;&#xA;" OwnerUserId="2257" LastEditorUserId="51" LastEditDate="2015-05-27T15:08:26.990" LastActivityDate="2015-05-27T15:08:26.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3418" PostTypeId="2" ParentId="3402" CreationDate="2015-05-27T15:39:02.377" Score="2" Body="&lt;p&gt;I'm personally not a big fan of automagic insertion of characters; you can easily define a set of mappings to insert text &amp;amp; more the cursor to where you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Add brackets with closing bracket&#xA;inoremap &amp;lt;C-a&amp;gt;[ []&amp;lt;Left&amp;gt;&#xA;inoremap &amp;lt;C-a&amp;gt;( ()&amp;lt;Left&amp;gt;&#xA;&#xA;&quot; For C &amp;amp; C-like languages&#xA;inoremap &amp;lt;C-a&amp;gt;{ {&amp;lt;Cr&amp;gt;&amp;lt;Cr&amp;gt;}&amp;lt;Up&amp;gt;&#xA;&#xA;&quot; For Ruby&#xA;inoremap &amp;lt;C-a&amp;gt;def def&amp;lt;Cr&amp;gt;end&amp;lt;Up&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that a plugin like &lt;a href=&quot;https://github.com/sirver/ultisnips&quot; rel=&quot;nofollow&quot;&gt;ultisnips&lt;/a&gt; also does stuff like this, but more advanced. For example in Javascript I can type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if&amp;lt;Tab&amp;gt;hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (hello) {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add a simple snippet for completing the brackets; this is a special .snippet file that lives in &lt;code&gt;~/.vim/UltiSnips/all.snippets&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet (&#xA;(${0})&#xA;endsnippet&#xA;&#xA;snippet [&#xA;[${0}]&#xA;endsnippet&#xA;&#xA;snippet {&#xA;{&#xA;${0}&#xA;}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;${0}&lt;/code&gt; is the cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;see &lt;code&gt;:help UltiSnips-adding-snippets&lt;/code&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that ultisnips requires Python; another well-known plugin is &lt;a href=&quot;https://github.com/garbas/vim-snipmate&quot; rel=&quot;nofollow&quot;&gt;vim-snipmate&lt;/a&gt;. &lt;a href=&quot;http://vim.wikia.com/wiki/Category:Automated_Text_Insertion&quot; rel=&quot;nofollow&quot;&gt;The Vim Wiki has a full list of snippet plugins&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-05-27T15:39:02.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3419" PostTypeId="1" AcceptedAnswerId="3474" CreationDate="2015-05-27T17:33:10.543" Score="2" ViewCount="3403" Body="&lt;p&gt;I have installed jedi-vim using Vundle, adding this line to my &lt;code&gt;.vimrc&lt;/code&gt; and running &lt;code&gt;:PluginInstall&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'davidhalter/jedi-vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/davidhalter/jedi-vim#installation&quot; rel=&quot;nofollow noreferrer&quot;&gt;jedi-vim docs&lt;/a&gt; say I can install jedi using &lt;code&gt;git submodule update --init&lt;/code&gt; from within the &lt;code&gt;jedi-vim&lt;/code&gt; git repo. I've tried that and exits right away (maybe Vundle took care of the submodule for me).&lt;/p&gt;&#xA;&lt;p&gt;In &lt;code&gt;.vim/bundle/jedi-vim&lt;/code&gt; I have a &lt;code&gt;jedi&lt;/code&gt; directory and a &lt;code&gt;jedi_vim.py&lt;/code&gt; file. I can load &lt;code&gt;python3&lt;/code&gt; and &lt;code&gt;import jedi&lt;/code&gt; from that directory with no problem.&lt;/p&gt;&#xA;&lt;p&gt;I've also tried installing jedi with &lt;code&gt;pip3 install jedi&lt;/code&gt; and &lt;code&gt;apt-get install python3-jedi&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;vim --version&lt;/code&gt; shows &lt;code&gt;-python&lt;/code&gt; and &lt;code&gt;+python3&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;No matter what I do, when I open a python file, Vim says:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Please install Jedi if you want to use jedi-vim.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Hey &lt;code&gt;Vim&lt;/code&gt;, I've installed it three different ways! What's going on?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="23502" LastEditDate="2022-11-02T09:08:10.853" LastActivityDate="2022-11-02T09:08:10.853" Title="Vim doesn't find jedi, even though it's right there!" Tags="|plugin-vundle|plugin-jedi-vim|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="3420" PostTypeId="1" CreationDate="2015-05-27T18:35:11.147" Score="2" ViewCount="171" Body="&lt;p&gt;I open vim and then use the command :Explore. Then I got these errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function netrw#Explore..netrw#LocalBrowseCheck..&amp;lt;SNR&amp;gt;16_NetrwBrowse..&amp;lt;SNR&amp;gt;16_NetrwGetBuffer..&amp;lt;SNR&amp;gt;16_NetrwEnew..&amp;lt;SNR&amp;gt;16_NetrwOptionRestore:&#xA;line   66:&#xA;E341: Internal error: lalloc(0, )&#xA;Pattern not found: @$&#xA;Error detected while processing function netrw#Explore..netrw#LocalBrowseCheck..&amp;lt;SNR&amp;gt;16_NetrwBrowse..&amp;lt;SNR&amp;gt;16_PerformListing..&amp;lt;SNR&amp;gt;16_NetrwOptionRestore:&#xA;line   66:&#xA;E341: Internal error: lalloc(0, )&#xA;&#xA;Error detected while processing function netrw#Explore:&#xA;line  501:&#xA;E341: Internal error: lalloc(0, )&#xA;line  502:&#xA;E341: Internal error: lalloc(0, )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After I type Enter and I am able to go to the Explore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea what they mean. Should I be worried? What can I do to stop them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am on Mac OS X and using vim 7.4.&lt;/p&gt;&#xA;" OwnerUserId="2177" LastEditorUserId="51" LastEditDate="2015-05-27T18:45:30.710" LastActivityDate="2015-05-27T18:45:30.710" Title="Explore command causing errors" Tags="|macvim|netrw|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3421" PostTypeId="2" ParentId="3379" CreationDate="2015-05-27T18:39:22.687" Score="5" Body="&lt;p&gt;The correct value of &lt;code&gt;$TERM&lt;/code&gt; environments variable is very important. Make sure that it is different from &lt;code&gt;screen-256color&lt;/code&gt;. Set it to &lt;code&gt;xterm-256color&lt;/code&gt; for example.&lt;/p&gt;&#xA;" OwnerUserId="1145" LastActivityDate="2015-05-27T18:39:22.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3423" PostTypeId="1" AcceptedAnswerId="3425" CreationDate="2015-05-27T21:04:19.400" Score="6" ViewCount="281" Body="&lt;p&gt;I use the mapping &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;m :w \|silent make\|redraw!\|cw&amp;lt;CR&amp;gt;&lt;/code&gt; which allows me to run make while I am editing a file by pressing &lt;code&gt;&amp;lt;leader&amp;gt;m&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It annoys me that if my cursor is in the middle of a line when I run this command, after the command finishes, my cursor is moved to the start of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to prevent this behavior? I noticed that even when I run &lt;code&gt;:make&lt;/code&gt;, the same thing happens.&lt;/p&gt;&#xA;" OwnerUserId="2270" LastActivityDate="2015-05-28T01:55:22.430" Title="Can I run :make without moving the cursor?" Tags="|external-command|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3424" PostTypeId="2" ParentId="3423" CreationDate="2015-05-27T21:22:45.547" Score="2" Body="&lt;p&gt;I did not find a way to fix this using the built-in &lt;code&gt;:make&lt;/code&gt; command. I decided to install  &lt;a href=&quot;https://github.com/benekastah/neomake&quot; rel=&quot;nofollow&quot;&gt;Neomake&lt;/a&gt; instead, with the mapping &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;m :w\|:Neomake!&amp;lt;CR&amp;gt;&lt;/code&gt;. This fixed my issue.&lt;/p&gt;&#xA;" OwnerUserId="2270" LastActivityDate="2015-05-27T21:22:45.547" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3425" PostTypeId="2" ParentId="3423" CreationDate="2015-05-28T01:55:22.430" Score="8" Body="&lt;h2&gt;Go out with a bang&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3Amake&quot;&gt;:help :make&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;7&quot;&gt;&#xA;  &lt;li&gt;If [!] is not given the first error is jumped to.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:make!&lt;/code&gt; will execute the command given by &lt;code&gt;'makeprg'&lt;/code&gt; (just as &lt;code&gt;:make&lt;/code&gt; does), but will not jump to the first position in the quickfix list. Thus, your cursor position remains intact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quickfix list will still be populated. Just as after running &lt;code&gt;:make&lt;/code&gt;, &lt;code&gt;:cfirst&lt;/code&gt; will jump to the first position; &lt;code&gt;:copen&lt;/code&gt; will open the quickfix window; etc.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-05-28T01:55:22.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3426" PostTypeId="2" ParentId="3340" CreationDate="2015-05-28T02:46:37.043" Score="2" Body="&lt;p&gt;Maybe it's font problem, not vim. I change my font size from 18 to 19, and it works. You can make it as what I have done. I didn't change the font of vim, I just change the font size of terminal.&lt;/p&gt;&#xA;" OwnerUserId="2168" LastEditorUserId="2168" LastEditDate="2015-06-01T04:09:52.887" LastActivityDate="2015-06-01T04:09:52.887" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3427" PostTypeId="1" AcceptedAnswerId="3428" CreationDate="2015-05-28T11:10:26.610" Score="1" ViewCount="76" Body="&lt;p&gt;For example, if I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MY_VAR = &quot;hello world&quot;&#xA;print &quot;the var %s&quot; % MY_VAR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I position the cursor on &lt;code&gt;MY_VAR&lt;/code&gt; and press &lt;code&gt;*&lt;/code&gt;, Vim highlights both matches. Suppose I want to rename this to &lt;code&gt;HELLO_WORLD_VAR&lt;/code&gt;, how might I achieve this?&lt;/p&gt;&#xA;" OwnerUserId="131" LastActivityDate="2015-05-28T11:20:46.580" Title="How do you substitute on previous matches?" Tags="|search|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3428" PostTypeId="2" ParentId="3427" CreationDate="2015-05-28T11:20:46.580" Score="3" Body="&lt;p&gt;Since you pressed &lt;code&gt;*&lt;/code&gt;, your last search was for &lt;code&gt;MY_VAR&lt;/code&gt;, i.e. equivalent to &lt;code&gt;/MY_VAR&lt;/code&gt;. If you don't specify a search pattern in a substitution, the last search pattern is used, which is &lt;code&gt;MY_VAR&lt;/code&gt; in your case. So you can simply use &lt;code&gt;:%s//HELLO_WORLD_VAR/g&lt;/code&gt; to do the renaming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I used the &lt;code&gt;g&lt;/code&gt; flag to indicate that all occurences should be replaced, not only the first on any line. It's not neccessary in your case, but probably makes sense in another context.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastActivityDate="2015-05-28T11:20:46.580" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3429" PostTypeId="1" AcceptedAnswerId="3430" CreationDate="2015-05-28T12:33:49.383" Score="5" ViewCount="599" Body="&lt;p&gt;I was writing a small plugin, when I decided that I should give the option of customizing which key triggers the plugin's function.  Here is an example of this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:foo_key = &quot;\&amp;lt;Tab&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While this works for part of the plugin's functionality, I also need that variable as a literal string, which would be &lt;code&gt;'\&amp;lt;Tab&amp;gt;'&lt;/code&gt; in this case.  Is it possible to convert from the resulting key code to a literal string?  Is there a standard way of handling this kind of option?&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-05-29T09:13:56.370" Title="How do you convert between non-literal strings and literal strings?" Tags="|vimscript|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3430" PostTypeId="2" ParentId="3429" CreationDate="2015-05-28T13:07:38.497" Score="4" Body="&lt;p&gt;The hex value of &lt;code&gt;g:foo_key&lt;/code&gt; will be 0x09 (a tab). You can use the&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#strtrans%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;strtrans()&lt;/code&gt;&lt;/a&gt;&#xA;function to get a readable representation of this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo strtrans(&quot;\&amp;lt;Tab&amp;gt;&quot;)&#xA;&amp;lt;09&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this prints &lt;code&gt;&amp;lt;09&amp;gt;&lt;/code&gt;, and not &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;. They are the same, and there is no way to know which one the user has entered. It may also show up as &lt;code&gt;^I&lt;/code&gt; (depends on value of &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27dy%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;display&lt;/code&gt;&lt;/a&gt;).&lt;br&gt;&#xA;Getting the key name is not something I can figure out how to do with a simple&#xA;function call, but in the &lt;code&gt;key_name_entry&lt;/code&gt; struct in &lt;code&gt;misc2.c&lt;/code&gt; you can find a&#xA;list of keynames; making a function for this is easy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:chars = {&#xA;    \ '&amp;lt;09&amp;gt;': '&amp;lt;Tab&amp;gt;',&#xA;    \ '&amp;lt;1b&amp;gt;': '&amp;lt;Esc&amp;gt;',&#xA;\ }&#xA;&#xA;fun! StringTrans(char)&#xA;    if get(g:chars, a:char, -1) != -1&#xA;        return g:chars[a:char]&#xA;    else&#xA;        return strtrans(a:char)&#xA;    endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You probably want to expand &lt;code&gt;g:chars&lt;/code&gt;; note that you have to type the literal&#xA;hex value with &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this &lt;em&gt;still&lt;/em&gt; won't return exactly what the user has typed, since there are multiple names for some characters (for example &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Newline&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;Linefeed&amp;gt;&lt;/code&gt; are all the same).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Doing the &lt;em&gt;reverse&lt;/em&gt; with &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#eval%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;eval()&lt;/code&gt;&lt;/a&gt;&#xA;is perhaps easier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let foo = '\&amp;lt;Tab&amp;gt;'&#xA;:echo foo&#xA;\&amp;lt;Tab&amp;gt;&#xA;&#xA;:let foo_expanded =  eval('&quot;' . foo . '&quot;')&#xA;:echo strtrans(foo_expanded)&#xA;&amp;lt;09&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-29T09:13:56.370" LastActivityDate="2015-05-29T09:13:56.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3431" PostTypeId="1" CreationDate="2015-05-28T13:22:48.540" Score="0" ViewCount="75" Body="&lt;p&gt;I would like to make a new tab page from part of the current text.&#xA;I would use visual selection, or other means to specify a text range.&lt;br&gt;&#xA;Is there a single command like &quot;New tab from selection&quot;?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Writing this, I see the command is not exactly of &lt;code&gt;vim&lt;/code&gt; style. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case, a small script may solve it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possibly there is a related plugin containing it?&lt;br&gt;&#xA; Here, one could reasonably hope for useful related features like creating a new file with derived name.&lt;/p&gt;&#xA;" OwnerUserId="925" LastEditorUserId="51" LastEditDate="2015-05-28T16:17:16.473" LastActivityDate="2015-05-28T16:17:16.473" Title="Moving a visual range to a new tabpage?" Tags="|buffers|multiple-files|tabbed-user-interface|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3432" PostTypeId="2" ParentId="3431" CreationDate="2015-05-28T13:43:02.697" Score="8" Body="&lt;h3&gt;Persisted&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you intend to persist the selected lines under a new filename (and it's complete lines), you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;w new-name | '&amp;lt;,'&amp;gt;delete _ | tabedit #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; range is inserted automatically when you enter command-line mode from visual mode. &lt;code&gt;:write&lt;/code&gt; can take a range, and afterwards, the filename is accessible via the &lt;em&gt;alternate file&lt;/em&gt; (&lt;code&gt;#&lt;/code&gt;) shortcut.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Unpersisted&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you just need a &lt;em&gt;scratch buffer&lt;/em&gt; that is not written to disk, you have to &lt;em&gt;delete&lt;/em&gt; and &lt;em&gt;put&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d:tabedit +set\ buftype=nofile new-name | put!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use this frequently, I would write a custom command (that also saves and restores the original register contents) for it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want &lt;em&gt;cloning&lt;/em&gt;, not &lt;em&gt;moving&lt;/em&gt;, drop the &lt;code&gt;:delete&lt;/code&gt; / change &lt;code&gt;d&lt;/code&gt; into &lt;code&gt;y&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-28T13:43:02.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3433" PostTypeId="2" ParentId="2806" CreationDate="2015-05-28T14:47:12.537" Score="4" Body="&lt;p&gt;It's difficult to point out where your problem is, since you didn't really&#xA;describe what &lt;em&gt;exactly&lt;/em&gt; you did; but this is how I added a custom PHP snippet&#xA;file:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I installed &lt;a href=&quot;http://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow&quot;&gt;http://github.com/SirVer/ultisnips&lt;/a&gt; and &lt;a href=&quot;http://github.com/honza/vim-snippets&quot; rel=&quot;nofollow&quot;&gt;http://github.com/honza/vim-snippets&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I created &lt;code&gt;~/.vim/UltiSnips/php.snippets&lt;/code&gt; with the contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;extends php, html&#xA;&#xA;snippet 42&#xA;The universe, life, and everything&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After opening a new Vim, I can use &lt;code&gt;42&amp;lt;Tab&amp;gt;&lt;/code&gt;, and the standard PHP&#xA;snippets (eg. &lt;code&gt;if&amp;lt;Tab&amp;gt;&lt;/code&gt;), and HTML snippets (eg. &lt;code&gt;div&amp;lt;Tab&amp;gt;&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help UltiSnips-adding-snippets&lt;/code&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-06-27T16:37:49.173" LastActivityDate="2015-06-27T16:37:49.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3434" PostTypeId="1" AcceptedAnswerId="3436" CreationDate="2015-05-28T15:37:22.177" Score="25" ViewCount="17047" Body="&lt;p&gt;Vim always adds a new line at the end of my files when saving, and it is causing errors in my PHP scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make vim not add this new line on save?&lt;/p&gt;&#xA;" OwnerUserId="2276" LastActivityDate="2021-01-17T12:19:47.357" Title="Don't add new line at the end of a file" Tags="|save|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3436" PostTypeId="2" ParentId="3434" CreationDate="2015-05-28T15:53:15.813" Score="16" Body="&lt;p&gt;This isn't a full empty line, just a final newline at the end of the last line. Unix tools (like Vim's heritage) insist on adding that, whereas the Windows operating system is not so strict. You can read more on that at &lt;a href=&quot;https://stackoverflow.com/questions/729692/why-should-files-end-with-a-newline&quot;&gt;Why should files end with a newline?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, it's quite complex to prevent Vim from writing the final newline. My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4550&quot; rel=&quot;noreferrer&quot;&gt;PreserveNoEOL plugin&lt;/a&gt; can do this. For a discussion of approaches, also see &lt;a href=&quot;https://stackoverflow.com/questions/1050640/vim-disable-automatic-newline-at-end-of-file&quot;&gt;VIM Disable Automatic Newline At End Of File&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-05-28T15:53:15.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3438" PostTypeId="1" AcceptedAnswerId="3547" CreationDate="2015-05-28T15:57:35.073" Score="1" ViewCount="1556" Body="&lt;p&gt;I am using the Lid.vim plugin to navigate my C++ project. &#xA;Once I run &lt;code&gt;:Lid&lt;/code&gt;, it shows me the list of matching tags in the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I switch to the quickfix window, select the occurence I'm interested in and press &lt;code&gt;Enter&lt;/code&gt; it produces an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E73: tag stack empty&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and does not go to the location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of &lt;code&gt;Enter&lt;/code&gt; if I use &lt;code&gt;Ctrl-Enter&lt;/code&gt; it opens a new window and goes to the location correctly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to open the quickfix location in the current window itself. Why is this error happening?&lt;/p&gt;&#xA;" OwnerUserId="2277" LastEditorUserId="51" LastEditDate="2015-05-28T16:00:10.950" LastActivityDate="2015-06-08T14:07:20.167" Title="Enter in Quickfix window gives &quot;E73: tag stack empty&quot; error" Tags="|quickfix|plugin-lid.vim|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3439" PostTypeId="5" CreationDate="2015-05-28T16:01:19.943" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=251&quot; rel=&quot;nofollow&quot;&gt;Homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-28T16:01:19.943" LastActivityDate="2015-05-28T16:01:19.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3440" PostTypeId="4" CreationDate="2015-05-28T16:01:19.943" Score="0" Body="Integrate GNU id-utils tool with Vim" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-28T16:01:19.943" LastActivityDate="2015-05-28T16:01:19.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3441" PostTypeId="5" CreationDate="2015-05-28T16:06:24.480" Score="0" Body="&lt;p&gt;There are 2 different plugins by the same name:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;nofollow&quot;&gt;The original CtrlP&lt;/a&gt; has last been updated in July 2013.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;nofollow&quot;&gt;A fork&lt;/a&gt; that receives regular updates. It is recommended to install this one.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-28T16:06:24.480" LastActivityDate="2015-05-28T16:06:24.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3442" PostTypeId="4" CreationDate="2015-05-28T16:06:24.480" Score="0" Body="Full path fuzzy file, buffer, mru, tag, ... finder for Vim" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-28T16:06:24.480" LastActivityDate="2015-05-28T16:06:24.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3443" PostTypeId="5" CreationDate="2015-05-28T16:10:40.480" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;Plugin Homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="25" LastEditDate="2021-10-20T22:13:22.210" LastActivityDate="2021-10-20T22:13:22.210" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3444" PostTypeId="4" CreationDate="2015-05-28T16:10:40.480" Score="0" Body="For questions about the plugin nerdtree: A tree explorer plugin for Vim." OwnerUserId="51" LastEditorUserId="25" LastEditDate="2021-10-20T22:13:22.210" LastActivityDate="2021-10-20T22:13:22.210" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3445" PostTypeId="5" CreationDate="2015-05-28T16:16:13.153" Score="0" Body="&lt;p&gt;Questions about the vim-surround plugin which provides mappings to easily delete, change and add surroundings in pairs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As of of 2018, according to &lt;a href=&quot;https://vimawesome.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;VimAwesome&lt;/a&gt; &lt;code&gt;vim.surround&lt;/code&gt; is the third most popular plugin.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;External Links&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;Homepage&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.futurile.net/2016/03/19/vim-surround-plugin-tutorial/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Futurile: Vim surround plugin tutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="1841" LastEditDate="2018-06-13T07:46:49.853" LastActivityDate="2018-06-13T07:46:49.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3446" PostTypeId="4" CreationDate="2015-05-28T16:16:13.153" Score="0" Body="surround.vim is a plugin by tpope to ease quoting and parenthesizing" OwnerUserId="51" LastEditorUserId="5078" LastEditDate="2018-06-13T03:39:42.680" LastActivityDate="2018-06-13T03:39:42.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3447" PostTypeId="5" CreationDate="2015-05-28T16:18:14.480" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/davidhalter/jedi-vim&quot; rel=&quot;nofollow&quot;&gt;Homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-28T16:18:14.480" LastActivityDate="2015-05-28T16:18:14.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3448" PostTypeId="4" CreationDate="2015-05-28T16:18:14.480" Score="0" Body="Using the jedi autocompletion library for Vim" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-05-28T16:18:14.480" LastActivityDate="2015-05-28T16:18:14.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3449" PostTypeId="5" CreationDate="2015-05-28T16:30:04.630" Score="0" Body="&lt;p&gt;The Netrw it standard plugin of Vim that give access to the folder structure.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="23502" LastEditDate="2023-02-23T20:22:38.597" LastActivityDate="2023-02-23T20:22:38.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3450" PostTypeId="4" CreationDate="2015-05-28T16:30:04.630" Score="0" Body="Questions about the Netrw plugin which adds directory listing to Vim, and allows you to open files over the network (ftp, http, scp, etc). " OwnerUserId="51" LastEditorUserId="23502" LastEditDate="2023-02-23T20:21:04.573" LastActivityDate="2023-02-23T20:21:04.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3452" PostTypeId="1" AcceptedAnswerId="3453" CreationDate="2015-05-28T18:46:27.500" Score="5" ViewCount="112" Body="&lt;p&gt;I would like to auto-indent text blocks that I have just &lt;code&gt;put&lt;/code&gt;. At a minimum, I would like to &lt;code&gt;retab&lt;/code&gt; the new block of text, since otherwise I sometimes end up with tabs in files that shouldn't have tabs when I copy them from files that &lt;em&gt;do&lt;/em&gt; have tabs without noticing.&lt;/p&gt;&#xA;" OwnerUserId="1060" LastActivityDate="2015-05-28T18:46:27.500" Title="Auto-indenting copied text" Tags="|cut-copy-paste|indentation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3453" PostTypeId="2" ParentId="3452" CreationDate="2015-05-28T18:46:27.500" Score="2" Body="&lt;p&gt;This is my current solution, but I'm certianly open to better ones:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap p pV`]=&#xA;nnoremap P PV`]=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes use of the &lt;code&gt;]&lt;/code&gt; built-in mark, which is the &quot;last character of the previously changed or yanked text&quot; (from &lt;code&gt;:help marks&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd prefer not to remap primitive fundamental keys such as &lt;code&gt;p&lt;/code&gt;, and this won't work with other methods of pasting (e.g. the middle-click in X11). Also, I haven't used this for very long so I'm not sure yet if there are any behavioral oddities.&lt;/p&gt;&#xA;" OwnerUserId="1060" LastActivityDate="2015-05-28T18:46:27.500" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3454" PostTypeId="2" ParentId="3333" CreationDate="2015-05-28T19:45:54.780" Score="2" Body="&lt;p&gt;@Ingo Karkat &#xA;Your Txtfmt files should look the same on different computers. If they don't, it could be that Vim is using a different encoding on the different computers (e.g., utf-8 vs latin-1), and you haven't set Txtfmt's 'tokrange' option explicitly. Recommended approach is to set 'tokrange' to a value that will work on all your systems in a &quot;Txtfmt modeline&quot; in the file itself. This prevents Txtfmt from picking a default (which could be different on different systems).&#xA;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;txtfmt:tokrange=180X&#xA;vim:ft=txtfmt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: The example above places all Txtfmt tokens near the end of the latin-1 char set. If you can force use of utf-8 on all your systems (e.g., by setting Vim's encoding option in your vimrc), you might do this instead...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;txtfmt:tokrange=0xE000X&#xA;vim:ft=txtfmt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...which places all Txtfmt tokens in the Unicode &quot;Private Use Area&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help txtfmt-'tokrange'&#xA;:help txtfmt-modeline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2281" LastEditorUserId="2281" LastEditDate="2015-06-04T15:49:34.097" LastActivityDate="2015-06-04T15:49:34.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3455" PostTypeId="1" AcceptedAnswerId="3457" CreationDate="2015-05-29T05:21:02.933" Score="19" ViewCount="2618" Body="&lt;p&gt;When using Vim to edit a read only file it will just provide a warning the first time it is edited but allow any changes to take place. I can understand this behaviour could be useful for someone intending on saving the file under another name; but I sometimes open files that I don't have write access to, then forget and make changes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to enter a mode where Vim will allow the file to be viewed but block any option that makes changes?&lt;/p&gt;&#xA;" OwnerUserId="2283" LastActivityDate="2023-05-01T12:55:12.030" Title="Blocking changes to read only file" Tags="|filetype|formatting|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3456" PostTypeId="2" ParentId="3379" CreationDate="2015-05-29T06:15:22.117" Score="12" Body="&lt;p&gt;It seems the problem is that tmux doesn't send your cursor-changing escape codes to the terminal emulator. You need to wrap your desired escape codes in a special sequence that tells tmux that it should pass it on to the outer terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sequence you need to wrap your escape sequence in is &lt;code&gt;\&amp;lt;Esc&amp;gt;Ptmux;\&amp;lt;Esc&amp;gt; ... \&amp;lt;Esc&amp;gt;\\&lt;/code&gt;(&lt;a href=&quot;http://comments.gmane.org/gmane.comp.terminal-emulators.tmux.user/1322&quot;&gt;Source&lt;/a&gt;). The &lt;code&gt;...&lt;/code&gt; is your escape sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, try doing something like this in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('$TMUX')&#xA;    let &amp;amp;t_SI = &quot;\&amp;lt;Esc&amp;gt;Ptmux;\&amp;lt;Esc&amp;gt;\e[5 q\&amp;lt;Esc&amp;gt;\\&quot;&#xA;    let &amp;amp;t_EI = &quot;\&amp;lt;Esc&amp;gt;Ptmux;\&amp;lt;Esc&amp;gt;\e[2 q\&amp;lt;Esc&amp;gt;\\&quot;&#xA;else&#xA;    let &amp;amp;t_SI = &quot;\e[5 q&quot;&#xA;    let &amp;amp;t_EI = &quot;\e[2 q&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't use your terminal emulator or cygwin, so I couldn't test this code. But the method worked for me (I just wrapped other escape codes that suit my terminal).&lt;/p&gt;&#xA;" OwnerUserId="1814" LastActivityDate="2015-05-29T06:15:22.117" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3457" PostTypeId="2" ParentId="3455" CreationDate="2015-05-29T07:20:37.767" Score="16" Body="&lt;p&gt;I found a solution. Setting &lt;code&gt;nomodifiable&lt;/code&gt; prevents the file being edited (as used in help windows). I created a simple function to set or unset &lt;code&gt;modifiable&lt;/code&gt; depending on if &lt;code&gt;readonly&lt;/code&gt; is set and attached it to an autocmd. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Don't allow editing of read only files&#xA;autocmd BufRead * call RONoEdit()&#xA;&#xA;function! RONoEdit()&#xA;  if &amp;amp;readonly == 1&#xA;    set nomodifiable&#xA;  else&#xA;    set modifiable&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2283" LastEditorUserId="51" LastEditDate="2015-05-29T09:11:57.213" LastActivityDate="2015-05-29T09:11:57.213" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3458" PostTypeId="1" AcceptedAnswerId="3459" CreationDate="2015-05-29T09:21:26.833" Score="3" ViewCount="1159" Body="&lt;p&gt;Is there a way to effectively combine &lt;code&gt;:w&lt;/code&gt; and &lt;code&gt;:e&lt;/code&gt; commands so that the current file is saved and a new one is opened for editing in one go? And to do so in a way that allows tab completion of path and filename on the command line?&lt;/p&gt;&#xA;" OwnerUserId="2287" LastActivityDate="2015-05-29T09:31:31.473" Title="Save current file and open another for editing" Tags="|command-line|multiple-files|file-operations|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3459" PostTypeId="2" ParentId="3458" CreationDate="2015-05-29T09:29:35.323" Score="6" Body="&lt;p&gt;You can use &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Acommand&quot;&gt;&lt;code&gt;command&lt;/code&gt;&lt;/a&gt; to add new commands. These have to start with a capital letter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this should do what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=file WE write | edit &amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:WE new-file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;-nargs=1&lt;/code&gt; -  accept one argument&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-complete=file&lt;/code&gt; - do file completion&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;WE&lt;/code&gt; - the command name&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;write | edit &amp;lt;args&amp;gt;&lt;/code&gt; - first call &lt;code&gt;:w&lt;/code&gt;, and then &lt;code&gt;:e&lt;/code&gt; with the argument we gave it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that there's also the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27noaw%27&quot;&gt;&lt;code&gt;autowrite&lt;/code&gt;&lt;/a&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Write the contents of the file, if it has been modified, on each&#xA;  &lt;code&gt;:next&lt;/code&gt;, &lt;code&gt;:rewind&lt;/code&gt;, &lt;code&gt;:last&lt;/code&gt;, &lt;code&gt;:first&lt;/code&gt;, &lt;code&gt;:previous&lt;/code&gt;, &lt;code&gt;:stop&lt;/code&gt;, &lt;code&gt;:suspend&lt;/code&gt;, &lt;code&gt;:tag&lt;/code&gt;, &lt;code&gt;:!&lt;/code&gt;,&#xA;  &lt;code&gt;:make&lt;/code&gt;, &lt;code&gt;CTRL-]&lt;/code&gt; and &lt;code&gt;CTRL-^&lt;/code&gt; command; and when a &lt;code&gt;:buffer&lt;/code&gt;, &lt;code&gt;CTRL-O&lt;/code&gt;, &lt;code&gt;CTRL-I&lt;/code&gt;,&#xA;  &lt;code&gt;'{A-Z0-9}&lt;/code&gt;, or &lt;code&gt;`{A-Z0-9}&lt;/code&gt; command takes one to another file. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27noawa%27&quot;&gt;&lt;code&gt;autowriteall&lt;/code&gt;&lt;/a&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Like &lt;code&gt;'autowrite'&lt;/code&gt;, but also used for commands &lt;code&gt;:edit&lt;/code&gt;, &lt;code&gt;:enew&lt;/code&gt;, &lt;code&gt;:quit&lt;/code&gt;,&#xA;  &lt;code&gt;:qall&lt;/code&gt;, &lt;code&gt;:exit&lt;/code&gt;, &lt;code&gt;:xit&lt;/code&gt;, &lt;code&gt;:recover&lt;/code&gt; and closing the Vim window.&#xA;  Setting this option also implies that Vim behaves like &lt;code&gt;'autowrite'&lt;/code&gt; has&#xA;  been set.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-05-29T09:29:35.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3461" PostTypeId="1" AcceptedAnswerId="3497" CreationDate="2015-05-29T14:24:17.157" Score="1" ViewCount="257" Body="&lt;p&gt;When adding a new pair of eruby tag like &lt;code&gt;&amp;lt;%= %&amp;gt;&lt;/code&gt; surrounding &lt;code&gt;Time.now&lt;/code&gt;, just type below keys:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does the job &lt;code&gt;&amp;lt;%= *Time.now %&amp;gt;&lt;/code&gt;. I have no idea how to do the opposite by removing it without using 'undo'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-surround/pull/107/files&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; it is probably the fix, but how to use it?&lt;/p&gt;&#xA;" OwnerUserId="2289" LastActivityDate="2015-06-08T14:56:43.057" Title="delete surrounding eruby tag in rails" Tags="|plugin-vim-surround|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3462" PostTypeId="1" CreationDate="2015-05-29T16:33:49.630" Score="1" ViewCount="185" Body="&lt;p&gt;Just noticed that using single quotes in javascript blows up automatic formatting sometimes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the &lt;code&gt;public/sass/*.sass&lt;/code&gt; line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Double quotes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gulp.task('compile-sass', function(){&#xA;  gulp&#xA;    .src(&quot;public/sass/*.sass&quot;)&#xA;    .pipe(sourcemaps.init())&#xA;    .pipe(sass({ indentedSyntax: true, errLogToConsole: true }))&#xA;    .pipe(sourcemaps.write())&#xA;    .pipe(gulp.dest('public/stylesheets'));&#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Single quotes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gulp.task('compile-sass', function(){&#xA;  gulp&#xA;    .src('public/sass/*.sass')&#xA;                       .pipe(sourcemaps.init())&#xA;                       .pipe(sass({ indentedSyntax: true, errLogToConsole: true }))&#xA;                       .pipe(sourcemaps.write())&#xA;                       .pipe(gulp.dest('public/stylesheets'));&#xA;                       });&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In fact I was noticing some peculiarities of automatic indenter before, but only now I was able to pinpoint it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Questions are usual - what gives and how to fix it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="237" LastEditDate="2015-05-30T03:24:21.857" LastActivityDate="2015-05-30T03:24:21.857" Title="Using single quotes blows up syntax formatting in .js" Tags="|indentation|formatting|filetype-javascript|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3463" PostTypeId="2" ParentId="3333" CreationDate="2015-05-29T18:19:46.247" Score="1" Body="&lt;p&gt;Have you tried any note taking plugin ? I use &lt;a href=&quot;https://github.com/xolox/vim-notes&quot; rel=&quot;nofollow&quot;&gt;vim-notes&lt;/a&gt; for personal notes and I think it does its job very well.&lt;/p&gt;&#xA;" OwnerUserId="1453" LastActivityDate="2015-05-29T18:19:46.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3464" PostTypeId="2" ParentId="1981" CreationDate="2015-05-29T21:41:23.223" Score="2" Body="&lt;p&gt;You could do &lt;code&gt;ggvG&amp;lt;CTRL-G&amp;gt;&lt;/code&gt; to visually select the whole buffer and enter &lt;code&gt;Select-mode&lt;/code&gt;. This is the easiest way to replace the buffer with text you're planning on typing out. You may even be able to make a &lt;code&gt;Select-mode&lt;/code&gt; mapping with &lt;code&gt;:smap&lt;/code&gt; that solves your problem.&lt;/p&gt;&#xA;" OwnerUserId="1008" LastActivityDate="2015-05-29T21:41:23.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3465" PostTypeId="1" AcceptedAnswerId="3466" CreationDate="2015-05-29T22:11:10.330" Score="1" ViewCount="443" Body="&lt;p&gt;I just opened a file and found what looked like a bunch of garbage at the beginning and ending of each line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[[35m^[[KsampleA.trimmed.count.20_to_30.not_in_ref.MULTI_in_sample.sam^[[m^[[K^[[36m^[[K:^[[m^[[K7&#xA;^[[35m^[[KsampleA.trimmed.count.20_to_30.not_in_ref.in_sample.sam^[[m^[[K^[[36m^[[K:^[[m^[[K4&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was wondering if Vim was in some funny UTF-8 mode or something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This file was simply created using &lt;code&gt;grep&lt;/code&gt; on Linux:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;grep -c 'NM:i:0' *.sam &amp;gt; grep_example.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They look fine with &lt;code&gt;more&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XwPNT.jpg&quot; alt=&quot;Image with the command &amp;quot;more grep_example.txt&amp;quot; followed by two lines in color showing the results.&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it has all these funny characters when using &lt;code&gt;vim&lt;/code&gt;:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/rQBZQ.jpg&quot; alt=&quot;Image showing the vim console with &amp;quot;extra&amp;quot; characters before and after the text that shows up as colored with more&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1111" LastActivityDate="2015-05-29T22:11:10.330" Title="This file looks fine with the more command. Why do I see all of these extra characters in vim?" Tags="|encoding|" AnswerCount="1" CommentCount="0" ClosedDate="2015-05-29T22:46:44.283" ContentLicense="CC BY-SA 3.0" />
  <row Id="3466" PostTypeId="2" ParentId="3465" CreationDate="2015-05-29T22:11:10.330" Score="3" Body="&lt;p&gt;Those characters are actually color encoding. Don't you think it odd that when you type &lt;code&gt;more&lt;/code&gt; you get color instead of black-and-white characters?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You must have &lt;code&gt;grep&lt;/code&gt; set as an alias to &lt;code&gt;grep --color=always&lt;/code&gt;. You're probably going to want to make a separate grep alias for viewing results in the console versus extracting text from files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, vim is being honest and showing you the actual characters in the file. More is also honest, but it sends those characters to your console, which interprets them as color encoding instead of text.&lt;/p&gt;&#xA;" OwnerUserId="1111" LastActivityDate="2015-05-29T22:11:10.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3467" PostTypeId="1" AcceptedAnswerId="3495" CreationDate="2015-05-30T00:43:30.337" Score="3" ViewCount="1583" Body="&lt;p&gt;The title says most of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the curious, folding is something I haven't yet included in my workflow.&#xA;I use &lt;a href=&quot;/questions/tagged/gvim&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;gvim&amp;#39;&quot; rel=&quot;tag&quot;&gt;gvim&lt;/a&gt; most of the time and I often have my hand on the mouse, scrolling through code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way I can fold/unfold using the mouse?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some IDE editors would have a &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;-&lt;/code&gt; sign where unfolding/folding is possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to add this to the GUI?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As with all things vim, I'm looking for a quick way to do it (least amount of clicks possible).&lt;/p&gt;&#xA;" OwnerUserId="475" LastActivityDate="2015-06-01T18:53:24.750" Title="Can I use the mouse for folding/unfolding in Gvim?" Tags="|gvim|folding|mouse|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3468" PostTypeId="1" AcceptedAnswerId="3470" CreationDate="2015-05-30T05:31:37.870" Score="3" ViewCount="409" Body="&lt;p&gt;Suppose I am editing a file.tex. How would I open file.pdf in zathura (or any pdf viewer) from vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand how to reference file.tex using '%' but I'm not sure how to reference file.pdf.&lt;/p&gt;&#xA;" OwnerUserId="2296" LastEditorUserId="8" LastEditDate="2015-05-31T00:41:53.857" LastActivityDate="2015-05-31T00:41:53.857" Title="Call PDF viewer on the compiled tex file" Tags="|command-line|external-command|filetype-tex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3469" PostTypeId="2" ParentId="3468" CreationDate="2015-05-30T08:05:42.743" Score="2" Body="&lt;p&gt;You can do something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let main = expand('%')&#xA;let pdf = fnamemod(main, ':r') . '.pdf'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above steps may of course be combined into a single step. Given the above, you can now open the file in zathura as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent execute 'zathura' . pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I propose you combine all of the above in one function, which makes it easy to map. E.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; \lv :call OpenInZathura()&amp;lt;cr&amp;gt;&#xA;function! OpenInZathura()&#xA;  let main = expand('%')&#xA;  let pdf = fnamemod(main, ':r') . '.pdf'&#xA;  silent execute 'zathura' . pdf&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'll take the liberty of mentioning my LaTeX-plugin &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow&quot;&gt;vimtex&lt;/a&gt;, which has support for zathura and other pdf viewers. For zathura, vimtex sets up both forward and backward search with synctex. It also handles more complex cases such as multifile projects.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-05-30T08:05:42.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3470" PostTypeId="2" ParentId="3468" CreationDate="2015-05-30T08:30:02.973" Score="7" Body="&lt;p&gt;&lt;code&gt;%&lt;/code&gt; indeed stands for the current file. &lt;code&gt;%:r&lt;/code&gt; (see &lt;code&gt;:help filename-modifiers&lt;/code&gt;) strips off the file extension. You can then use &lt;code&gt;:!&lt;/code&gt; to launch an external command, e.g. the PDF viewer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! zathura %:r.pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-30T08:30:02.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3471" PostTypeId="2" ParentId="398" CreationDate="2015-05-30T13:07:09.853" Score="5" Body="&lt;p&gt;You can tell Vim regex engine where to start next match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I know there are 2 ways:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;\ze&lt;/code&gt; to set the end of a match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region GitLog&#xA;    \ start=/^===* Log/&#xA;    \ end=/\ze^===* Diff/&#xA;    \ contains=@gitlog&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use positive lookahead, &lt;code&gt;\@=&lt;/code&gt;, which is called zero-width matching in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region GitLog&#xA;    \ start=/^===* Log/&#xA;    \ end=/\(^===* Diff\)\@=/&#xA;    \ contains=@gitlog&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So the end-of-match &quot;pointer&quot; kind of rewinds to the beginning of &lt;code&gt;^===* Diff&lt;/code&gt; line, such that &lt;code&gt;region Diff&lt;/code&gt;'s &lt;code&gt;start&lt;/code&gt; will start its matching at &lt;code&gt;^===* Diff&lt;/code&gt; line again.&lt;/p&gt;&#xA;" OwnerUserId="2295" LastEditorUserId="2295" LastEditDate="2017-03-01T10:38:01.713" LastActivityDate="2017-03-01T10:38:01.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3472" PostTypeId="2" ParentId="3362" CreationDate="2015-05-30T21:06:54.380" Score="0" Body="&lt;p&gt;I found possible solution in this answer at SuperUser &lt;a href=&quot;https://superuser.com/a/668612&quot;&gt;&quot;Vim: quit if buffer list is empty&quot;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd BufDelete * if len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 | quit | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2303" LastEditorUserId="-1" LastEditDate="2017-03-20T10:04:45.077" LastActivityDate="2015-05-30T21:40:35.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3474" PostTypeId="2" ParentId="3419" CreationDate="2015-05-31T02:55:27.657" Score="2" Body="&lt;p&gt;It turns out I had a compiled version of python in &lt;code&gt;/usr/local&lt;/code&gt; that I had completely forgotten about, and vim was compiled against that one. I verified this by using &lt;code&gt;:py print(sys.path)&lt;/code&gt;, which showed directories under &lt;code&gt;/usr/local&lt;/code&gt;. I removed the compiled version of python and recompiled vim against the standard version, and all is well.&lt;/p&gt;&#xA;" OwnerUserId="69" LastActivityDate="2015-05-31T02:55:27.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3475" PostTypeId="2" ParentId="3386" CreationDate="2015-05-31T08:05:25.727" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;go to the existing target tab&lt;/li&gt;&#xA;&lt;li&gt;split it however you want&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:b ab&lt;/code&gt;(tab-complete the rest)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ab&lt;/code&gt; are just random letters, replace with the beginning of your desired file name. &lt;code&gt;:b&lt;/code&gt; tab-completion has performed very well for me, it can usually find the right source buffer based on just one letter and 1-2 &lt;code&gt;Tab&lt;/code&gt; keypresses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The benefit of this approach over Ingo's is the lack of noting or remembering anything, meaning less cognitive load. File name you already know anyway.&lt;/p&gt;&#xA;" OwnerUserId="2301" LastEditorUserId="2301" LastEditDate="2015-05-31T13:47:22.640" LastActivityDate="2015-05-31T13:47:22.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3476" PostTypeId="1" CreationDate="2015-05-31T12:59:55.557" Score="2" ViewCount="668" Body="&lt;p&gt;This is more gVim (Linux) related since Vim doesn't have a &quot;window&quot; of its own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to wrap a text at (say) 80th character, visual wrap only, no changes in file, hence no textwidth or wrapmargin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tried using columns=80 but this resizes the window and also counts in lines numbering (set number) which is both undesired. The former is absolutely undesired, the latter I can live with though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to have long lines wrapped at a certain column without having to physically format the text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is for readability/convenience purpose only so workarounds are welcome as well.&lt;/p&gt;&#xA;" OwnerUserId="2311" LastActivityDate="2015-05-31T19:20:40.743" Title="Force (visual-only) wrap at specific column regardless window size in gVim" Tags="|gvim|wrapping|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3477" PostTypeId="2" ParentId="3455" CreationDate="2015-05-31T13:13:47.343" Score="0" Body="&lt;p&gt;As much as the answers above are correct, there is another thing to take into account: as long as the file is &quot;read-only&quot;, there should be no way of changing the file's content unless you're the owner of the file or have the right to make that file writable. And even then vim doesn't write changes to the file unless you explicitly override the &quot;read-only&quot; state by &quot;:w!&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can in fact edit a file which is supposed to be read-only, you may want to recheck the rights, there may be a security misconfiguration. If you only make vim unable to edit the file, other ways of editing will still be in place so if the file is not to be changed, it should have the rights set properly. In windows, you can force the file to be read-only by explicitly denying the change right to everyone, in Linux you can use the &quot;immutable&quot; extended attribute (chattr +i).&lt;/p&gt;&#xA;" OwnerUserId="2311" LastActivityDate="2015-05-31T13:13:47.343" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3478" PostTypeId="1" AcceptedAnswerId="3479" CreationDate="2015-05-31T14:11:45.993" Score="7" ViewCount="691" Body="&lt;p&gt;I'm trying to write a simple mapping that will pre-populate the vim ex command line but leave the user there to execute the command on their own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use-case is for the user to type &lt;code&gt;&amp;lt;leader&amp;gt;/foo&lt;/code&gt; which would then open the command line with &lt;code&gt;:e **/foo&lt;/code&gt; and the user could either further refine, press ctrl-d to see possible matches, etc&lt;/p&gt;&#xA;" OwnerUserId="2312" LastEditorUserId="24" LastEditDate="2015-05-31T20:07:01.630" LastActivityDate="2017-02-16T16:38:41.427" Title="Populate ex command line" Tags="|command-line|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3479" PostTypeId="2" ParentId="3478" CreationDate="2015-05-31T14:20:08.290" Score="9" Body="&lt;p&gt;That kind of mapping is very, very common:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;/ :edit **/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jHCAW.gif&quot; alt=&quot;:edit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Might I suggest the following slightly smarter alternative?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path=.,**&#xA;nnoremap &amp;lt;leader&amp;gt;/ :find *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;'path'&lt;/code&gt; option tells Vim to look for files matching the argument given to &lt;code&gt;:find&lt;/code&gt; in the directory of the file associated with the current buffer and any subdirectory of the working directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :find&#xA;:help 'path'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-06-01T08:25:44.867" LastActivityDate="2015-06-01T08:25:44.867" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3480" PostTypeId="1" AcceptedAnswerId="3481" CreationDate="2015-05-31T15:55:48.247" Score="11" ViewCount="7988" Body="&lt;p&gt;I'm trying to define a function that will make it easier to see where the cursor is location by putting cross-hairs around it for 100ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my attempt: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Flash()&#xA;    set cursorline cursorcolumn&#xA;    sleep 100m&#xA;    set nocursorline nocursorcolumn&#xA;endfunction&#xA;nnoremap &amp;lt;leader&amp;gt;fl :call Flash()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems though that the above function is calling the sleep at the beginning rather than in between the two &quot;set&quot; calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something fundamental about &quot;sleep&quot; that I am misunderstanding?&lt;/p&gt;&#xA;" OwnerUserId="2312" LastActivityDate="2015-05-31T16:02:32.420" Title="vimL sleep within a function" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3481" PostTypeId="2" ParentId="3480" CreationDate="2015-05-31T16:02:32.420" Score="18" Body="&lt;p&gt;The problem is that Vim doesn't redraw the screen until after the function is completed. I'm not sure what Vim's logic on when to redraw is &lt;em&gt;exactly&lt;/em&gt;, but in this sort of case you often have to call &lt;code&gt;redraw&lt;/code&gt; manually:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Flash()&#xA;    set cursorline cursorcolumn&#xA;    redraw&#xA;    sleep 100m&#xA;    set nocursorline nocursorcolumn&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You probably also want to add &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to the key mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;fl :call Flash()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-05-31T16:02:32.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3482" PostTypeId="2" ParentId="3476" CreationDate="2015-05-31T16:17:53.137" Score="3" Body="&lt;p&gt;This is not a direct solution but a hack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With your editing window open, &lt;code&gt;:vnew&lt;/code&gt; a vertical split and then go back to the window then use &lt;code&gt;:vert resize N&lt;/code&gt; where &lt;code&gt;N&lt;/code&gt; is your desired width / column size.&lt;/p&gt;&#xA;" OwnerUserId="2295" LastActivityDate="2015-05-31T16:17:53.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3483" PostTypeId="2" ParentId="3476" CreationDate="2015-05-31T19:20:40.743" Score="2" Body="&lt;p&gt;If you don't want to reduce the physical width of your Vim / GVIM instance, you have to create a dummy window next to the current one, and set its size so that the current one has proper width.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3238&quot; rel=&quot;nofollow&quot;&gt;LimitWindowSize plugin&lt;/a&gt; does the size calculations for you, and offers a simple &lt;code&gt;:LimitWindowWidth [{width}]&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-05-31T19:20:40.743" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3484" PostTypeId="1" AcceptedAnswerId="3485" CreationDate="2015-05-31T21:38:32.003" Score="5" ViewCount="1932" Body="&lt;p&gt;I normally like to keep swap files on, but if I am editing huge log files I usually don't want them.  Since I am just viewing the files in vim, it is unnecessary to have a swap file.  I could just run &lt;code&gt;set noswapfile&lt;/code&gt; for &lt;code&gt;*.log&lt;/code&gt; files, but I was wondering if I could just disable it if the file is larger than a specified amount.&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-05-31T21:38:32.003" Title="Disable swap file for large files" Tags="|buffers|swap-file|" AnswerCount="1" CommentCount="0" ClosedDate="2015-05-31T22:19:25.690" ContentLicense="CC BY-SA 3.0" />
  <row Id="3485" PostTypeId="2" ParentId="3484" CreationDate="2015-05-31T21:38:32.003" Score="5" Body="&lt;p&gt;You can combine autocommands with the &lt;code&gt;getfsize(file)&lt;/code&gt; function to automatically disable options for large files.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; A global variable that contains the size of which a file is considered&#xA;&quot; large.  In this case, it is 10 megabytes.&#xA;let g:large_file = 1024 * 1024 * 10&#xA;&#xA;&quot; This autocmd runs before reading the file into the buffer.  It&#xA;&quot; gets the file that the autocmd is running on by running expand on&#xA;&quot; &amp;lt;afile&amp;gt;, which is short for the path to the file that the autocmd&#xA;&quot; is running on.  Then, it gets the size of the file running&#xA;&quot; getfsize on the file and sees if it is larger than the size&#xA;&quot; specified in g:large_file.  If it is, it disables the swap file.&#xA;autocmd BufReadPre * let f=expand(&quot;&amp;lt;afile&amp;gt;&quot;) | if getfsize(f)&#xA;            \ &amp;gt; g:large_file | set noswapfile | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you can add any other options you want where &lt;code&gt;set noswapfile&lt;/code&gt; is to improve performance on large files.  If you have a lot of them, you might want to create a function which sets all of them, and then add a call to that function where &lt;code&gt;set noswapfile&lt;/code&gt; is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related to performance when editing large files, here are some options that can help:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'bufhidden'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'buftype'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'eventignore'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'undolevels'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For instance, those options can be set to the below for better performance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal bufhidden=unload &quot; (save memory when other file is viewed)&#xA;setlocal buftype=nowrite &quot; (is read-only)&#xA;setlocal eventignore+=Filetype &quot; (ignores autocommands with FileType as their trigger event)&#xA;setlocal undolevels=-1 &quot; (no undo possible)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Related help topics:&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getfsize()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help expand()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help &amp;lt;afile&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I got some of this information from &lt;a href=&quot;http://vim.wikia.com/wiki/Faster_loading_of_large_files&quot; rel=&quot;noreferrer&quot;&gt;http://vim.wikia.com/wiki/Faster_loading_of_large_files&lt;/a&gt; which has useful information on performance when editing large files.&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-05-31T21:38:32.003" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3487" PostTypeId="1" CreationDate="2015-06-01T10:20:47.270" Score="3" ViewCount="208" Body="&lt;p&gt;I decided to write a plugin for vim. I want to write it mainly in python, as I am most proficient in it. I started development with this example: &lt;a href=&quot;http://brainacle.com/how-to-write-vim-plugins-with-python.html&quot; rel=&quot;nofollow&quot;&gt;http://brainacle.com/how-to-write-vim-plugins-with-python.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the problem I have - I want to use some non-standard library modules and I wonder - how should I add them? My guess is that vim uses it's own python that is compiled in it, therefore I cannot really use pip to install these modules. Should I just provide the modules I want to use within the plugin itself?&lt;/p&gt;&#xA;" OwnerUserId="162" LastActivityDate="2015-06-06T19:05:35.630" Title="What is the best way to embed external python modules to vim plugin?" Tags="|plugin-system|vimscript-python|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3489" PostTypeId="1" AcceptedAnswerId="3545" CreationDate="2015-06-01T12:44:26.867" Score="11" ViewCount="3626" Body="&lt;p&gt;When using &lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot;&gt;NERDTree plugin&lt;/a&gt; the default behavior is to open a new file and keeping the NERDTree buffer open. What I want to do is to keep this default behavior but also overriding it when I want so the NERDTree buffer will be closed after I opened a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can use &lt;code&gt;let NERDTreeQuitOnOpen=1&lt;/code&gt; to automatically close the NERDTree buffer when I open a new file but this option totally overrides the default behavior (which is not what I want).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I would like to know if there is a built-in feature in NERDTree to do what I want. (I've been searching but didn't find anything like that so I suppose it doesn't exists actually)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if that doesn't exists I had two ideas: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First one is to create a function which would set &lt;code&gt;NERDTreeQuitOnOpen&lt;/code&gt; to &lt;code&gt;1&lt;/code&gt;, open the file and then set again &lt;code&gt;NERDTreeQuitOnOpen&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Second one is to create the following mapping: &lt;code&gt;map d&amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt; :NERDTree &amp;lt;CR&amp;gt; :bd&amp;lt;CR&amp;gt;&lt;/code&gt; which opens the file (first &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;), goes back to NERDTree buffer (&lt;code&gt;:NERDTree &amp;lt;CR&amp;gt;&lt;/code&gt;) and close this buffer (&lt;code&gt;:bd &amp;lt;CR&amp;gt;&lt;/code&gt;). I should improve it so the mapping only exists in the NERDTree buffer but I feel that's a pretty ugly solution and I thik it can be improved. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Which idea would be the best and why? Or is there an even better option?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-06-03T10:16:45.127" LastActivityDate="2015-07-15T12:12:52.953" Title="NERDTree How to open a file and automatically close the explorer buffer" Tags="|plugin-nerdtree|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3490" PostTypeId="2" ParentId="3402" CreationDate="2015-06-01T13:41:29.730" Score="2" Body="&lt;p&gt;Previous answers are very good. But I think you might want something easier.&#xA;Personally I use &lt;code&gt;h&lt;/code&gt; &lt;code&gt;j&lt;/code&gt; &lt;code&gt;k&lt;/code&gt; &lt;code&gt;l&lt;/code&gt; for moving around. Therefore, I have added to my .vimrc the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-j&amp;gt; &amp;lt;esc&amp;gt;ji&#xA;inoremap &amp;lt;c-k&amp;gt; &amp;lt;esc&amp;gt;ki&#xA;inoremap &amp;lt;c-h&amp;gt; &amp;lt;esc&amp;gt;i&#xA;inoremap &amp;lt;c-l&amp;gt; &amp;lt;esc&amp;gt;2li&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just a small tip. You said that your procedure is &lt;code&gt;i&lt;/code&gt;, &lt;code&gt;[]&lt;/code&gt;, &lt;code&gt;&amp;lt;Esc&amp;gt;hi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is Operator-Pending Mappings, Which means you can &lt;code&gt;ci[&lt;/code&gt; or &lt;code&gt;di[&lt;/code&gt; or &lt;code&gt;ii[&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2263" LastEditorUserId="51" LastEditDate="2015-06-01T14:20:35.340" LastActivityDate="2015-06-01T14:20:35.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3491" PostTypeId="1" CreationDate="2015-06-01T14:59:45.287" Score="6" ViewCount="912" Body="&lt;p&gt;Something that helps in text editing and proofreading is that for Insert mode, I have set an IMAP:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap zz ^[:w^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and when I type &lt;code&gt;zz&lt;/code&gt; I return to command mode and also write the current buffer. This makes &lt;code&gt;latexmk&lt;/code&gt; reprocess my &lt;code&gt;.tex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I also make smaller changes like replacing single characters with &lt;code&gt;r&lt;/code&gt; or &lt;code&gt;daw&lt;/code&gt; for deleting a word or pasting a register. How can I tell Vim to write the current buffer every time I do such changes?&lt;/p&gt;&#xA;" OwnerUserId="2017" LastActivityDate="2015-06-01T15:27:52.697" Title="How to write a file automatically after every change?" Tags="|key-bindings|save|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3492" PostTypeId="2" ParentId="3491" CreationDate="2015-06-01T15:15:30.960" Score="5" Body="&lt;p&gt;Use event-based autocommands: I suggest &lt;code&gt;TextChanged&lt;/code&gt; for normal mode, and &lt;code&gt;InsertLeave&lt;/code&gt; for insert mode - which can also replace your &lt;code&gt;zz&lt;/code&gt; mapping.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-06-01T15:15:30.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3493" PostTypeId="2" ParentId="3491" CreationDate="2015-06-01T15:27:52.697" Score="6" Body="&lt;p&gt;If your main motivation is updating an alternative (compiled) representation in another tool, you can use the &lt;code&gt;FocusLost&lt;/code&gt; event (present in GVIM and some terminals), so updates will happen when you leave Vim (for the other tool).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd FocusLost * update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For certain filetypes / buffers, replace &lt;code&gt;*&lt;/code&gt; with &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; and define in &lt;code&gt;~/.vim/after/ftplugin/{filetype}.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add additional &lt;code&gt;:help autocmd-events&lt;/code&gt;, e.g. &lt;code&gt;CursorHold,CursorHoldI,InsertLeave&lt;/code&gt;. What you literally asked for is &lt;code&gt;TextChanged,TextChangedI&lt;/code&gt;, but its &lt;code&gt;:help&lt;/code&gt; explicitly warns:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Careful: This is triggered very often, don't&#xA;    do anything that the user does not expect or&#xA;    that is slow.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-06-01T15:27:52.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3495" PostTypeId="2" ParentId="3467" CreationDate="2015-06-01T18:53:24.750" Score="7" Body="&lt;p&gt;Credits to &lt;a href=&quot;https://stackoverflow.com/a/13924974/2072269&quot;&gt;Ingo Karkat&lt;/a&gt;, you just need to set &lt;code&gt;foldcolumn&lt;/code&gt; for using the mouse to open and close folds. From &lt;a href=&quot;http://vimhelp.appspot.com/fold.txt.html#fold-foldcolumn&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:he fold-foldcolumn&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FOLDCOLUMN                                              fold-foldcolumn&#xA;&#xA;'foldcolumn' is a number, which sets the width for a column on the side of the&#xA;window to indicate folds.  When it is zero, there is no foldcolumn.  A normal&#xA;value is 4 or 5.  The minimal useful value is 2, although 1 still provides&#xA;some information.  The maximum is 12.&#xA;&#xA;An open fold is indicated with a column that has a '-' at the top and '|'&#xA;characters below it.  This column stops where the open fold stops.  When folds&#xA;nest, the nested fold is one character right of the fold it's contained in.&#xA;&#xA;A closed fold is indicated with a '+'.&#xA;&#xA;Where the fold column is too narrow to display all nested folds, digits are&#xA;shown to indicate the nesting level.&#xA;&#xA;The mouse can also be used to open and close folds by clicking in the&#xA;fold column:&#xA;- Click on a '+' to open the closed fold at this row.&#xA;- Click on any other non-blank character to close the open fold at this row.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even though it says &lt;code&gt;2&lt;/code&gt; is the minimal useful value, I'd say &lt;code&gt;1&lt;/code&gt; is enough (&lt;code&gt;:set foldcolumn=1&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/oSEnm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Higher values make a better visual experience, but you still need to hit the &lt;code&gt;+&lt;/code&gt; exactly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On a side note, this section is the only instance of the word &lt;code&gt;mouse&lt;/code&gt; in &lt;code&gt;fold.text&lt;/code&gt;. (&lt;code&gt;:he folding&lt;/code&gt;, &lt;code&gt;/mouse&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-06-01T18:53:24.750" CommentCount="0" CommunityOwnedDate="2015-06-01T18:53:24.750" ContentLicense="CC BY-SA 3.0" />
  <row Id="3496" PostTypeId="1" CreationDate="2015-06-02T07:39:38.893" Score="2" ViewCount="938" Body="&lt;p&gt;I installed Vagrant within Windows, box is ubuntu server 14.04.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co=256&#xA;colorscheme solarized&#xA;&quot; colorscheme molokai&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't works, and I got no solutions with Google.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Who can tell me how to do?&lt;/p&gt;&#xA;" OwnerUserId="2332" LastEditorUserId="7161" LastEditDate="2016-05-16T10:24:36.993" LastActivityDate="2016-05-16T10:24:36.993" Title="How to set vim theme in Vagrant?" Tags="|vimrc|colorscheme|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3497" PostTypeId="2" ParentId="3461" CreationDate="2015-06-02T18:13:36.497" Score="2" Body="&lt;p&gt;Put the following in your &lt;code&gt;~/.vim/after/ftplugin/eruby.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;buffer&amp;gt; ds= ds&amp;lt;ds%dw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is we delete each surrounding in turn. First &lt;code&gt;&amp;lt;&lt;/code&gt; then &lt;code&gt;%&lt;/code&gt;. Next we remove the &lt;code&gt;=&lt;/code&gt; and the extra space.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-06-08T14:56:43.057" LastActivityDate="2015-06-08T14:56:43.057" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3498" PostTypeId="1" AcceptedAnswerId="3500" CreationDate="2015-06-02T23:46:35.807" Score="11" ViewCount="1356" Body="&lt;p&gt;How can I bring up the path to the current file in the command line, so as to type a similar file name? I don't want an abbreviation that would be replaced by the current file name, I want to edit the file name, complete with its directory path. For example, I want to &lt;code&gt;:edit&lt;/code&gt; a file with a similar name, or in a similar directory, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim src/submodule/frontend/frobnicate2.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and now I want to edit &lt;code&gt;../trunk/src/submodule/frontend/frobnicate.c&lt;/code&gt;, and I only want to insert the &lt;code&gt;../trunk&lt;/code&gt; and remove the &lt;code&gt;2&lt;/code&gt;, not retype the full path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can of course drop back to the shell and use its command history, or I could copy-paste the path through the GUI, but I'm looking for a more efficient way that doesn't require leaving Vim.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2015-07-02T12:27:49.847" Title="Bring up the current file name for edition in the command line" Tags="|command-line|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3499" PostTypeId="2" ParentId="3498" CreationDate="2015-06-03T00:12:56.877" Score="5" Body="&lt;p&gt;Oh. Search for “file name” in &lt;code&gt;:help :&lt;/code&gt;! It's simple: &lt;code&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#c_CTRL-R&quot; rel=&quot;noreferrer&quot;&gt;CTRL-R&lt;/a&gt; &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#quote_%&quot; rel=&quot;noreferrer&quot;&gt;%&lt;/a&gt;&lt;/code&gt; to insert the special &lt;strong&gt;r&lt;/strong&gt;egister &lt;code&gt;%&lt;/code&gt;, meaning the current file name.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2015-06-03T00:12:56.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3500" PostTypeId="2" ParentId="3498" CreationDate="2015-06-03T00:15:58.553" Score="14" Body="&lt;p&gt;In addition to inserting the &lt;code&gt;%&lt;/code&gt; register as you've discovered yourself, you can also use &lt;code&gt;:edit %&amp;lt;Tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#cmdline-special&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help cmdline-special&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In Ex commands, at places where a file name can be used, the following&#xA;characters have a special meaning.  These can also be used in the expression&#xA;function `expand()`.&#xA;&#xA;        %       Is replaced with the current file name.           :_% c_%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can, for example, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit %.orig&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to edit &lt;code&gt;file.txt.orig&lt;/code&gt;. For your example, you'd type &lt;code&gt;:e ../trunk/%&lt;/code&gt;, press &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; to get the file name with the relative path, and remove the &lt;code&gt;2&lt;/code&gt; before pressing &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add some modifiers to the path to modify it; I found &lt;code&gt;:h&lt;/code&gt; to be particularly useful, it gets the &quot;dirname&quot; (or &quot;head&quot; in Vim-speak&quot;) of the current path:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit file/in/a/deeply/nested/subdirectory/here.txt&#xA;:edit %:h/in_same_dir_as_above.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can even use &lt;code&gt;:h&lt;/code&gt; multiple times. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit %:h:h:h/file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will open &lt;code&gt;file/in/a/deeply/file.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also &lt;code&gt;:p&lt;/code&gt; which gives you the full path and which could be useful in your case: type &lt;code&gt;:e %:p&lt;/code&gt;, press &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; and edit the path as desired. You can even use multiple modifiers, eg: &lt;code&gt;:e %:p:h&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#filename-modifiers&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help filename-modifiers&lt;/code&gt;&lt;/a&gt; for the full list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: if you &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;, Vim will expand the &lt;code&gt;%&lt;/code&gt;. If you use &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt;, Vim won't expand the &lt;code&gt;%&lt;/code&gt; (but does substitute the &lt;code&gt;%&lt;/code&gt; while completing the path).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-07-02T12:27:49.847" LastActivityDate="2015-07-02T12:27:49.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3501" PostTypeId="2" ParentId="3498" CreationDate="2015-06-03T08:33:29.903" Score="0" Body="&lt;p&gt;Here is a mapping you can try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;a-q&amp;gt; &amp;lt;c-c&amp;gt;:let @a=expand('%')&amp;lt;CR&amp;gt;:&amp;lt;Up&amp;gt;&amp;lt;c-r&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This saves the current command then sets register 'a' to the name of the current file. Then the last command is recalled and appended with the 'a' register contents. Of course if you have something useful in the 'a' register this will overwrite it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to change the mapped characters to something else. I like to use the Alt key but it doesn't work in some terminals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Carpetsmoker pointed out in his answer you can change the function call to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expand('%:p')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to force the full path.&lt;/p&gt;&#xA;" OwnerUserId="2346" LastActivityDate="2015-06-03T08:33:29.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3502" PostTypeId="2" ParentId="3498" CreationDate="2015-06-03T09:19:59.207" Score="3" Body="&lt;p&gt;If you have set your vim &lt;code&gt;path&lt;/code&gt; variable, you have the full power of the &lt;code&gt;:find&lt;/code&gt; command, namely tab-completion of file names (without the need to specify the directory part!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path=./**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;may be all you need for &lt;code&gt;:fin frob&amp;lt;tab&amp;gt;&lt;/code&gt; to work. For the gory details, &lt;code&gt;:help find&lt;/code&gt;, &lt;code&gt;:help file-searching&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2347" LastActivityDate="2015-06-03T09:19:59.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3503" PostTypeId="1" CreationDate="2015-06-03T11:22:43.920" Score="1" ViewCount="218" Body="&lt;p&gt;I have some autocmd triggering on &lt;code&gt;TextChanged&lt;/code&gt;, that I want to have persisted between Vim restarts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could make a big if-elseif construct in the vimrc, sure, but I prefer saving the autocmd only for the specific file, as the autocmd cmd changes with each file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this be done using view sessions? Do you have better ways to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="2349" LastEditorUserId="51" LastEditDate="2015-06-03T11:39:31.387" LastActivityDate="2015-06-03T12:55:49.773" Title="Persist autocmd per file (not per filetype) without vimrc" Tags="|vimscript|autocmd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3504" PostTypeId="2" ParentId="3503" CreationDate="2015-06-03T12:42:13.030" Score="3" Body="&lt;p&gt;In your &lt;code&gt;~/.vimrc&lt;/code&gt;, you can define an &lt;code&gt;:autocmd&lt;/code&gt; that targets the opening of the particular file, and then define the &lt;code&gt;TextChanged&lt;/code&gt; autocmd for the particular buffer in there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead /path/to/the/special/file autocmd TextChanged &amp;lt;buffer&amp;gt; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2015-06-03T12:42:13.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3505" PostTypeId="2" ParentId="3273" CreationDate="2015-06-03T12:45:42.440" Score="1" Body="&lt;p&gt;Quick and dirty way of &amp;quot;storing a list of open files&amp;quot;, as requested in your comment.  (I don't have enough reputation to answer a comment).&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:tabs&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;gives all currently open filenames, arranged by tab number.&lt;/p&gt;&#xA;&lt;p&gt;So if you do something like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; command! SaveTabs :execute &amp;quot;redir! &amp;gt; tabs_&amp;quot; . v:servername . &amp;quot;.txt &#xA;     \ | echo v:servername strftime(\&amp;quot;%c\&amp;quot;) | pwd | tabs | redir END&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;you will have a new command&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:SaveTabs&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;which will create a file named something like &lt;code&gt;tabs_GVIM27.txt&lt;/code&gt; (yeah that's how many servers I have open...) containing all the filenames, with a &amp;quot;header&amp;quot; at the top with the:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;servername&lt;/li&gt;&#xA;&lt;li&gt;current working directory&lt;/li&gt;&#xA;&lt;li&gt;date/time that the list was created.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When in a new/different session later on, you can open the tabs file in a window and &lt;code&gt;&amp;lt;c-w&amp;gt;f&lt;/code&gt; on any of those filenames to open a new split on the file, effectively &amp;quot;importing&amp;quot; it into your current session.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Variations:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you want you could put the date/time in the filename itself, see &lt;code&gt;:help strftime()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Put the list on the clipboard instead of in a file: use &lt;code&gt;redir @+&lt;/code&gt; instead of &lt;code&gt;redir! &amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Other explanatory notes:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The working directory is because &lt;code&gt;:tabs&lt;/code&gt; shows relative paths, so files in the working directory do not have their paths (but others do)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:execute&lt;/code&gt; is needed because &lt;code&gt;:redir&lt;/code&gt; won't allow variables in its argument&lt;/li&gt;&#xA;&lt;li&gt;The command doesn't have to be split over two lines, I just did that so it would be easier to read here&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Insane variation for importing all the files at once:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you want to import all the files at once you can probably do something like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;grep &amp;quot;^  &amp;quot; tabs_OLD.txt | xargs | vim --servername NEW --remote-silent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;(untested but you get the idea)&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;(actually if you got that working, you could then just define it as an alias in your shell, so you could in future just type&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;addfiles foo bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to add all the files from a previous vim server &amp;quot;foo&amp;quot; to a currently-running vim server called &amp;quot;bar&amp;quot;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2343" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-06-03T12:56:08.780" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3506" PostTypeId="2" ParentId="3503" CreationDate="2015-06-03T12:55:49.773" Score="0" Body="&lt;p&gt;Two methods I can think of are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;initiating vim with a &lt;code&gt;-u filename.vimrc&lt;/code&gt; for each file you want to specify the modifications with, and have &lt;em&gt;it&lt;/em&gt; source your primary &lt;code&gt;.vimrc&lt;/code&gt; to bring in the rest of your normal work environment.&lt;/li&gt;&#xA;&lt;li&gt;creating a separate autocmd file for specific subset paths or files, then &lt;code&gt;source&lt;/code&gt;ing that from your main &lt;code&gt;.vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For the external &lt;code&gt;autuocmd&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup the_file_types&#xA;  autocmd!&#xA;  autocmd BufReadPost my.fun.file call MyFunction('arg1')&#xA;augroup END&#xA;autocmd BufWrite my.other.file do_something_else&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first sounds annoying to me to have to remember every time I start up the editor; the second is more versatile and less harrying.&lt;/p&gt;&#xA;" OwnerUserId="2303" LastActivityDate="2015-06-03T12:55:49.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3507" PostTypeId="1" AcceptedAnswerId="3509" CreationDate="2015-06-03T16:13:00.243" Score="11" ViewCount="4601" Body="&lt;p&gt;Is there a way to get argument completion for python?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently using a combination of ctags, python-mode and YouCompleteMe, but I am missing a function to autocomplete the arguments of a function (or show them at least.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a Plugin that supports that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using vim/gvim 7.4 and Ubuntu 14.04&lt;/p&gt;&#xA;" OwnerUserId="2353" LastActivityDate="2018-10-28T04:27:40.360" Title="Argument completion for python" Tags="|autocompletion|ide|filetype-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3509" PostTypeId="2" ParentId="3507" CreationDate="2015-06-04T01:58:33.093" Score="10" Body="&lt;p&gt;By default, (with a minimal vimrc, and no plugins installed), this is already possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim ships with multiple filetype plugins and some of these plugins offer omni-completion right out of the box. For example, python comes with pythoncomplete.vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use the default pythoncomplete.vim that ships with Vim, (i.e. no YouCompleteMe, no python-mode, no jedi-vim), you get a preview window when you complete a function, that shows the keyword arguments. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you need is Vim with &lt;code&gt;+python&lt;/code&gt; feature (&lt;code&gt;:echo has('python')&lt;/code&gt; shows 1). If you do, then this is all it takes to enable the default python omni-completion with your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;filetype plugin indent on&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After hunting down many other completion solutions for python (jedi, python-mode), I've come to like pythoncomplete.vim that is shipped with Vim a lot more. It's simple, and most important to me, it's very stable, especially compared to solutions like jedi-vim/python-mode and YouCompleteMe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what the default solution looks like. It doesn't offer completion of arguments, but just shows them in the preview window so it's easy for you to fill the keyword arguments in like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xXBXh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="15" LastEditDate="2018-10-28T04:27:40.360" LastActivityDate="2018-10-28T04:27:40.360" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3510" PostTypeId="1" AcceptedAnswerId="3511" CreationDate="2015-06-04T04:42:20.777" Score="3" ViewCount="1911" Body="&lt;p&gt;There may be any number of nested vertical and horizontal splits on a Vim screen. I'd like to find the (x, y) coords, in terms of columns and lines inside Vim, of the top-left corner of the current window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's easy to find the dimensions of the current window (&lt;code&gt;winheight(0)&lt;/code&gt; and &lt;code&gt;winwidth(0)&lt;/code&gt;), how many windows there are (&lt;code&gt;winnr('$')&lt;/code&gt;), as well as all of their widths and heights (&lt;code&gt;winrestcmd()&lt;/code&gt;), but this doesn't say enough about the adjacency of windows to each other. All we know is that windows with smaller numbers will generally be towards the top and left of those with larger numbers. Also, I'm not even sure how to find the number of lines and columns of the whole Vim screen (including all of the windows and the command line)...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I'm doing this. It's suitable for me, but it makes the mouse cursor flicker a bit.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;funct! CountLinesAboveWindow()&#xA;    let lz_setting = &amp;amp;lazyredraw&#xA;    set lazyredraw&#xA;    let original_nr = winnr()&#xA;    let last_nr = original_nr&#xA;    let lines_above = 0&#xA;    while 1&#xA;        wincmd k&#xA;        let nr = winnr()&#xA;        if nr == last_nr&#xA;            break&#xA;        endif&#xA;        let lines_above = lines_above + winheight(0) + 1&#xA;        let last_nr = nr&#xA;    endwhile&#xA;    exe original_nr . &quot;wincmd w&quot;&#xA;    let &amp;amp;lazyredraw = lz_setting&#xA;    return lines_above&#xA;endfunct!&#xA;#And similarly for CountColumnsToTheLeftOfWindow()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a more elegant way? It has to be faster than the above, which excludes &lt;code&gt;:mksession&lt;/code&gt; as an option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I want this is to write functions &lt;code&gt;screenline()&lt;/code&gt; and &lt;code&gt;screencol()&lt;/code&gt;, analogous to the built-in &lt;code&gt;winline()&lt;/code&gt; and &lt;code&gt;wincol()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2334" LastActivityDate="2015-06-04T05:31:57.670" Title="Get the offset/position of the current window in the layout" Tags="|vimscript|vim-windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3511" PostTypeId="2" ParentId="3510" CreationDate="2015-06-04T05:31:57.670" Score="7" Body="&lt;p&gt;&lt;code&gt;screenrow()&lt;/code&gt; and &lt;code&gt;screencol()&lt;/code&gt; give you the coordinates relative to the top left corner of the &quot;screen&quot; (i.e. of Vim's window).  The manual warns you that something like &lt;code&gt;:echo screencol()&lt;/code&gt; will return the column in the command line (i.e. 1).  It works better from within a map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; GG :echom screencol()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-06-04T05:31:57.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3512" PostTypeId="1" AcceptedAnswerId="3513" CreationDate="2015-06-04T06:29:04.710" Score="21" ViewCount="10914" Body="&lt;p&gt;The syntax &lt;code&gt;foldmethod&lt;/code&gt; is great, but sometimes I just want to fold the comments in a source file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also syntax folding of comments only works for C-Style comments like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; ...&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But not for comment boilerplate like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//&#xA;//&#xA;// ...&#xA;//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even for comment blocks in non-C-like languages like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#&#xA;#&#xA;# ...&#xA;#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I configure this with vim?&lt;/p&gt;&#xA;" OwnerUserId="2357" LastEditorUserId="20347" LastEditDate="2022-11-02T16:09:55.023" LastActivityDate="2022-11-02T16:09:55.023" Title="How to fold comments?" Tags="|folding|comments|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3513" PostTypeId="2" ParentId="3512" CreationDate="2015-06-04T10:44:46.347" Score="21" Body="&lt;p&gt;Folding only the comments is fairly easy by using &lt;code&gt;foldmethod=expr&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=expr foldexpr=getline(v:lnum)=~'^\\s*'.&amp;amp;commentstring[0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will simply check if the line starts with any amount of whitespace followed by a comment character. Note that this is fairly naïve and may not work for all languages since &lt;code&gt;commentstring&lt;/code&gt; can be more complex than just a single character. So you may want to use a autocmd to be more specific:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType c      setlocal foldmethod=expr foldexpr=getline(v:lnum)=~'^\\s*//'&#xA;autocmd FileType python setlocal foldmethod=expr foldexpr=getline(v:lnum)=~'^\\s*#'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information about fold-expr, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/fold.txt.html#fold-expr&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help fold-expr&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#folding-functions&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help folding-functions&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/2176/51&quot;&gt;How to write a foldexpr?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/2165/51&quot;&gt;Folding by regex search pattern&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Using syntax folding &lt;em&gt;and&lt;/em&gt; comment folding is more involved; this would require modifing the syntax file in &lt;code&gt;/usr/share/vim/vim74/syntax/*.vim&lt;/code&gt;, and will be specific to the language you're using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;em&gt;some&lt;/em&gt; filetypes already do this! For example from &lt;code&gt;ruby.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(&quot;ruby_no_comment_fold&quot;)&#xA;  syn region rubyMultilineComment start=&quot;\%(\%(^\s*#.*\n\)\@&amp;lt;!\%(^\s*#.*\n\)\)\%(\(^\s*#.*\n\)\{1,}\)\@=&quot; end=&quot;\%(^\s*#.*\n\)\@&amp;lt;=\%(^\s*#.*\n\)\%(^\s*#\)\@!&quot; contains=rubyC&#xA;  syn region rubyDocumentation    start=&quot;^=begin\ze\%(\s.*\)\=$&quot; end=&quot;^=end\%(\s.*\)\=$&quot; contains=rubySpaceError,rubyTodo,@Spell fold&#xA;else&#xA;  syn region rubyDocumentation    start=&quot;^=begin\s*$&quot; end=&quot;^=end\s*$&quot; contains=rubySpaceError,rubyTodo,@Spell&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-05-08T00:47:54.617" LastActivityDate="2020-05-08T00:47:54.617" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3514" PostTypeId="1" AcceptedAnswerId="3515" CreationDate="2015-06-04T12:22:24.313" Score="8" ViewCount="4268" Body="&lt;p&gt;I'm using a &lt;a href=&quot;http://myusuf3.github.io/numbers.vim/&quot; rel=&quot;noreferrer&quot;&gt;really clever plugin&lt;/a&gt; that changes the line number style (relative/normal) contextually. Basically when you enter insert mode you have normal line numbers and when you leave insert mode it switches to relative numbers. A missing feature is to have normal line numbers when your in command-line mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at &lt;a href=&quot;https://github.com/myusuf3/numbers.vim/blob/master/plugin/numbers.vim#L104-L111&quot; rel=&quot;noreferrer&quot;&gt;how it is implemented&lt;/a&gt; it uses Vim's events system to trigger the change. I've looked but Vim's documentation seems to only offer events on insert enter/leave. (Funny aside: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#UserGettingBored&quot; rel=&quot;noreferrer&quot;&gt;UserGettingBored&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first I thought of adding &lt;code&gt;nnoremap : :call MyFunc()&amp;lt;CR&amp;gt;:&lt;/code&gt; which works on enter but not on exit. Also relying on a map seems flaky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I trigger a function when the user enters command-line mode (presses &lt;kbd&gt;:&lt;/kbd&gt;)? And how do I trigger a function when the user leaves this mode (presses &lt;kbd&gt;enter&lt;/kbd&gt;, &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt; or &lt;kbd&gt;esc&lt;/kbd&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="544" LastEditorUserId="544" LastEditDate="2015-06-05T12:26:51.490" LastActivityDate="2017-10-22T20:22:29.330" Title="How do I trigger an autocommand when user enters/leaves command mode" Tags="|key-bindings|vimscript|autocmd|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3515" PostTypeId="2" ParentId="3514" CreationDate="2015-06-04T12:37:58.807" Score="6" Body="&lt;p&gt;You can use mappings to override &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, and &lt;code&gt;?&lt;/code&gt; to do some action first:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap : :set number&amp;lt;CR&amp;gt;:&#xA;nnoremap / :set number&amp;lt;CR&amp;gt;/&#xA;nnoremap ? :set number&amp;lt;CR&amp;gt;?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because we use &lt;em&gt;non-recursive&lt;/em&gt; mappings, the &lt;code&gt;:&lt;/code&gt; at the end will call the original built-in &lt;code&gt;:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To hide the numbers again, you can use command-line mappings to override &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;silent&amp;gt; &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;:set nonumber&amp;lt;CR&amp;gt;&#xA;cnoremap &amp;lt;silent&amp;gt; &amp;lt;Esc&amp;gt; &amp;lt;Esc&amp;gt;:set nonumber&amp;lt;CR&amp;gt;&#xA;cnoremap &amp;lt;silent&amp;gt; &amp;lt;C-c&amp;gt; &amp;lt;C-c&amp;gt;:set nonumber&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This same trick should also work with the commands from your plugin.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-06-04T12:37:58.807" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3516" PostTypeId="1" AcceptedAnswerId="3517" CreationDate="2015-06-04T14:59:13.227" Score="8" ViewCount="1772" Body="&lt;p&gt;I use relative line numbers along with an absolute line number for the current line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number&#xA;set relativenumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The absolute current line number is always aligned to the left, and the help pages (or Google) don't seem to provide an option to change this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to prevent this left align, or will I have to learn to live with it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cCatW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2362" LastActivityDate="2015-06-04T15:24:33.720" Title="Current line number aligned to the left with number and relativenumber" Tags="|vimrc|line-numbers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3517" PostTypeId="2" ParentId="3516" CreationDate="2015-06-04T15:13:35.943" Score="14" Body="&lt;p&gt;From &lt;code&gt;screen.c&lt;/code&gt;, &lt;code&gt;win_line()&lt;/code&gt; function (around line 3707):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* 'number' + 'relativenumber' */&#xA;num = lnum;&#xA;fmt = &quot;%-*ld &quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;%-&lt;/code&gt; makes it left-aligned (See &lt;code&gt;sprintf(3)&lt;/code&gt;). As you can see, this value is hard-coded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want this, you can modify it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fmt = &quot;%*ld &quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and recompile. The result should be something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/poWa2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, this might make a good candidate for an option/patch :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-06-04T15:24:33.720" LastActivityDate="2015-06-04T15:24:33.720" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3518" PostTypeId="1" AcceptedAnswerId="3520" CreationDate="2015-06-04T18:09:19.937" Score="4" ViewCount="303" Body="&lt;p&gt;I wanted to know if there is some way of fetching a random &quot;article&quot; (maybe article is not the proper term here) from the vim documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found nearly nothing on the subject on vim documentation and on internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of my ideas was to list every file of documentation and then pick one randomly. But even &quot;list every file&quot; or &quot;list every article&quot; ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that with one character, there is a possibility to have a list :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h a&amp;lt;Tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This expands to a list of (I think) a list of every help entry available...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea ? &lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2017-01-14T17:52:39.833" Title="Randomly select a documentation article" Tags="|help-system|undocumented-behaviour|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3519" PostTypeId="2" ParentId="3518" CreationDate="2015-06-04T18:41:58.643" Score="2" Body="&lt;p&gt;The documentation files are stored are text files in &lt;code&gt;$VIMRUNTIME/doc&lt;/code&gt;. You can start the documentation by just calling one of the filesnames, eg: &lt;code&gt;:help usr_41.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get a list of these files with the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#glob%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;glob()&lt;/code&gt;&lt;/a&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo glob(&quot;$VIMRUNTIME/doc/*.txt&quot;, '', 1)&#xA;['/usr/share/vim/vim74/doc/arabic.txt', '/usr/share/vim/vim74/doc/autocmd.txt', ...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, as far as I know there is no straight-forward way of getting a random item of a list, but &lt;a href=&quot;https://vi.stackexchange.com/q/807/51&quot;&gt;How to generate random numbers?&lt;/a&gt; lists a number of work-arounds. All them use an external tool to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since we're using an external tool (I used Python here) , we might as well use that for getting the files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py import glob, random; print(random.choice(glob.glob(vim.eval(&quot;$VIMRUNTIME&quot;) + '/doc/*.txt'))&#xA;/usr/share/vim/vim74/doc/indent.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And to open a help page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py import vim, glob, random, os; vim.command (':help ' +  os.path.basename(random.choice(glob.glob(vim.eval(&quot;$VIMRUNTIME&quot;) + '/doc/*.txt'))))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a one-liner it's a bit unreadable, so here's a script which does the same, but more readable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! RandomHelp()&#xA;python &amp;lt;&amp;lt; EOF&#xA;import vim, glob, random, os&#xA;all_pages = glob.glob(vim.eval(&quot;$VIMRUNTIME&quot;) + '/doc/*.txt')&#xA;random_page = os.path.basename(random.choice(all_pages))&#xA;vim.command(':help ' + random_page)&#xA;EOF&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you don't have Python, you could use the shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute ':help ' . system(&quot;ls $VIMRUNTIME/doc/ | shuf -n1&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;shuf&lt;/code&gt; is a non-standard tool, and may not be available on your system.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-06-04T18:47:15.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3520" PostTypeId="2" ParentId="3518" CreationDate="2015-06-04T19:29:41.213" Score="3" Body="&lt;p&gt;I think the 'article' you're looking for is 'help tag' - if so, look no further than: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/mhinz/vim-randomtag&quot; rel=&quot;nofollow&quot;&gt;https://github.com/mhinz/vim-randomtag&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-06-04T19:29:41.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3521" PostTypeId="2" ParentId="3518" CreationDate="2015-06-04T19:35:53.483" Score="1" Body="&lt;p&gt;Your &quot;article&quot; may correspond to the tags created with &lt;code&gt;:helptags&lt;/code&gt; and which divide the help files into subject sections (see &lt;code&gt;:help helptags&lt;/code&gt;) and are the section names that you can see when you complete your help command with &lt;code&gt;:help a&amp;lt;Tab&amp;gt;&lt;/code&gt; or &lt;code&gt;:help a&amp;lt;C-D&amp;gt;&lt;/code&gt;. They live in a tags file in &lt;code&gt;$VIMRUNTIME/doc/tags&lt;/code&gt;. The first five lines of mine are&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!        change.txt    /*!*  &#xA;!!       change.txt    /*!!*  &#xA;#        pattern.txt   /*#*  &#xA;$        motion.txt    /*$*  &#xA;$HOME    options.txt   /*$HOME*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can extract a list of all the help tags from this file, but how to best do that may depend on how you're going to use the list. If for example you want to use this list with Vim's help command, then you may want to read the first field of each line of this file and then execute the help command with the content of that field. If on the other hand you want to read off content of the help section to use somewhere outside of Vim's help, you may be better served by using the second field to locate the correct file for a topic and the third field as a search pattern to find the section. If you do this, then remember that you should indicate that the pattern is not magic (i.e., begin the pattern with &lt;code&gt;\M&lt;/code&gt; or &lt;code&gt;\V&lt;/code&gt;) since the &lt;code&gt;*&lt;/code&gt; in the third field of the tags file is a literal asterisk, not the pattern multi item (&lt;code&gt;:help /star&lt;/code&gt;) with the same name. &lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-06-04T19:35:53.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3523" PostTypeId="1" AcceptedAnswerId="3526" CreationDate="2015-06-05T15:54:53.573" Score="3" ViewCount="349" Body="&lt;p&gt;If I open a file in vi like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi /etc/httpd/conf/httpd.conf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then vi shows in the bottom left corner of the window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;/etc/httpd/conf/httpd.conf&quot; 1009L, 34418C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I edit the file with a or i then this line disappears.&lt;br&gt;&#xA;And even when pressing Esc to exit the editing mode it wont come back.&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get this line back after editing?&lt;/p&gt;&#xA;" OwnerUserId="2372" LastActivityDate="2015-06-05T18:11:50.533" Title="How to show the path to the current opened file?" Tags="|command-line|statusline|path|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3524" PostTypeId="1" AcceptedAnswerId="3525" CreationDate="2015-06-05T16:00:44.370" Score="3" ViewCount="500" Body="&lt;p&gt;Suppose I am searching for &lt;strong&gt;pattern&lt;/strong&gt; in my text file using vim. Is there a way to store 0 in a variable &lt;em&gt;foo&lt;/em&gt; if no matches to &lt;strong&gt;pattern&lt;/strong&gt; are found and store 1 if at least 1 match is found?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2369" LastActivityDate="2015-06-05T17:00:42.050" Title="To Return a True Value if Pattern Match is Found Else Return a False Value" Tags="|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3525" PostTypeId="2" ParentId="3524" CreationDate="2015-06-05T16:14:51.413" Score="5" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#search%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;search()&lt;/code&gt;&lt;/a&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When a match has been found its line number is returned. If there is no match a 0 is returned and the cursor doesn't move.  No error message is given.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You probably want to set the &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;w&lt;/code&gt;, and &lt;code&gt;n&lt;/code&gt; flags:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;c&lt;/code&gt;     accept a match at the cursor position&lt;br&gt;&#xA;  &lt;code&gt;n&lt;/code&gt;     do Not move the cursor&lt;br&gt;&#xA;  &lt;code&gt;w&lt;/code&gt;     wrap around the end of the file  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo search('search', 'cwn')&#xA;5127&#xA;:echo search('jabberwocky', 'cwn')&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you really want only &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt; add &lt;code&gt;&amp;gt; 0&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo search('search', 'cwn') &amp;gt; 0&#xA;1&#xA;:echo search('jabberwocky', 'cwn') &amp;gt; 0&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want, you can of course make a function for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! HasPattern(p)&#xA;    return search(a:p, 'cwn') &amp;gt; 0&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -nargs=1 HasPattern :echo search(&amp;lt;f-args&amp;gt;, 'cwn')&amp;gt;0&#xA;&#xA;:HasPattern search&#xA;1&#xA;:HasPattern jabberwocky&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="227" LastEditDate="2015-06-05T17:00:42.050" LastActivityDate="2015-06-05T17:00:42.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3526" PostTypeId="2" ParentId="3523" CreationDate="2015-06-05T18:11:50.533" Score="4" Body="&lt;p&gt;If you save, you can then use &lt;code&gt;:e&lt;/code&gt; again, to display &lt;em&gt;that&lt;/em&gt; information. Also, you can use &lt;code&gt;g Ctrl-g&lt;/code&gt; and/or &lt;code&gt;Ctrl-g&lt;/code&gt; at any time to find out some (or the other) of the original info.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-06-05T18:11:50.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3527" PostTypeId="2" ParentId="149" CreationDate="2015-06-06T06:42:06.213" Score="10" Body="&lt;p&gt;The LargeFile.vim plugin is designed to make editing large files faster.  See &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#LARGEFILE&quot; rel=&quot;noreferrer&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#LARGEFILE&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Allows much quicker editing of large files (default: 100MB+ are &quot;large&quot;), at the price of turning off events, undo, syntax highlighting, etc. Also available at vim.sf.net where you may rank it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;According to the manual, the plugin works just by having it installed. You can set the cutoff by changing &lt;code&gt;g:LargeFile&lt;/code&gt;, to an integer number of MB, which it says defaults to 20MB (in contrast to the project description which says 100)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin also provides commands &lt;code&gt;:UnLarge&lt;/code&gt;, &lt;code&gt;:Large&lt;/code&gt; and &lt;code&gt;:Large!&lt;/code&gt; to disable, reenable, or force enable (for small files) respectively on the currently loaded file.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastEditorUserId="227" LastEditDate="2015-06-06T15:30:05.987" LastActivityDate="2015-06-06T15:30:05.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3528" PostTypeId="1" AcceptedAnswerId="3529" CreationDate="2015-06-06T07:02:39.797" Score="2" ViewCount="954" Body="&lt;p&gt;If I have something stored in the named register &lt;code&gt;n&lt;/code&gt;, then from the normal mode hitting&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/&amp;lt;C-R&amp;gt;n&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;would search for what is stored inside the register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But suppose I want to write a function which searches for what is stored in the &lt;code&gt;n&lt;/code&gt; register.&#xA;What do I do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SearchTheDataInnReg()&#xA;   &amp;lt;C-R&amp;gt;l&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get an error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E488: Trailing characters: &amp;lt;09&amp;gt;&amp;lt;C-R&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2369" LastEditorUserId="51" LastEditDate="2015-06-06T12:56:42.590" LastActivityDate="2015-06-06T12:56:42.590" Title="Searching For a String Stored in a Register From Within a Function" Tags="|vimscript|search|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3529" PostTypeId="2" ParentId="3528" CreationDate="2015-06-06T07:39:21.287" Score="4" Body="&lt;p&gt;From function you can access to named registers via &lt;code&gt;@&lt;/code&gt;.&#xA;For explanation &lt;code&gt;:he let-@&lt;/code&gt; and similars topics.&#xA;For search pattern call &lt;code&gt;search()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code may look like this. In this example we search pattern in &lt;code&gt;l&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! SearchTheDataInnReg()&#xA;    call search(@l)&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1145" LastEditorUserId="1841" LastEditDate="2015-06-06T12:55:32.040" LastActivityDate="2015-06-06T12:55:32.040" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3530" PostTypeId="1" AcceptedAnswerId="3533" CreationDate="2015-06-06T08:18:46.410" Score="2" ViewCount="164" Body="&lt;p&gt;I want to write a function which takes two strings &lt;strong&gt;this&lt;/strong&gt; and &lt;strong&gt;that&lt;/strong&gt; as its arguments and replaces all instances of &lt;strong&gt;this&lt;/strong&gt; with &lt;strong&gt;that&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the function should look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReplaceThisWithThat(this, that)&#xA;       &quot;Main Stuff&#xA;.&#xA;.&#xA;.&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can somebody please help?&lt;/p&gt;&#xA;" OwnerUserId="2369" LastEditorUserId="1682" LastEditDate="2016-09-17T18:36:47.463" LastActivityDate="2016-09-17T18:36:47.463" Title="Understanding Vimscripts Through an Easy Example" Tags="|vimscript|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3531" PostTypeId="2" ParentId="3530" CreationDate="2015-06-06T08:24:31.593" Score="1" Body="&lt;p&gt;Function arguments have &lt;code&gt;a:&lt;/code&gt; prefix.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReplaceThisWithThat(this, that)&#xA;       &quot;Main Stuff&#xA; echo a:this &quot;named argument 'this'&#xA; echo a:that&#xA;&#xA; echo a:0 &quot; postioned first argument&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1145" LastActivityDate="2015-06-06T08:24:31.593" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3533" PostTypeId="2" ParentId="3530" CreationDate="2015-06-06T10:06:49.010" Score="7" Body="&lt;p&gt;You can do it very simply with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReplaceThisWithThat(this, that)&#xA;    execute &quot;%s/&quot; . a:this . &quot;/&quot; . a:that . &quot;/g&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will substitute every occurrence of &lt;code&gt;a:this&lt;/code&gt; with &lt;code&gt;a:that&lt;/code&gt; in the whole buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to perform that substitution on the content of some variable or register, you can use &lt;code&gt;substitute()&lt;/code&gt; in your function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReplaceThisWithThat(something, this, that)&#xA;    return substitute(a:something, a:this, a:that, &quot;g&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which doesn't make much sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, everything you need to know is in &lt;code&gt;:help eval.txt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="970" LastEditDate="2015-06-06T10:26:19.043" LastActivityDate="2015-06-06T10:26:19.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3534" PostTypeId="1" AcceptedAnswerId="3536" CreationDate="2015-06-06T18:59:06.980" Score="3" ViewCount="286" Body="&lt;p&gt;I'm working on large files for wikisource, along with another guy. I generate a big text file (a few Mb) witch I format a bit using scripts, then I upload the text to a temporary page, where the other guy does some more formatting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My friends computer and internet connection are not the best in the market, and he asked me not to upload more than 400Kb of data, so his computer can handle all the text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the file is formatted like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;==header 1==&#xA;.&#xA;.&#xA;.&#xA;==header 2==&#xA;.&#xA;.&#xA;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and has a few hundreds of headers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I need to do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to yank at most 400Kb (as close as I can to this number), but I also need to yank all the text between headers - I can't have the text between headers to split over a few files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can find the next header using &lt;code&gt;\^={2}[^=]+={2}$&lt;/code&gt;, but I don't know how to carry on yanking until I have ~400Kb of data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="342" LastActivityDate="2015-06-07T20:27:29.127" Title="yanking a certain amount of bytes" Tags="|cut-copy-paste|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3535" PostTypeId="2" ParentId="3534" CreationDate="2015-06-06T19:35:59.160" Score="3" Body="&lt;p&gt;You can try something like this: place you cursor on the next line after a header, and hit: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;y/\_.\{0,400000}==$/e&lt;/code&gt;(Enter)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or (more precise):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;y/\_.\{0,400000}\n^==[^=]\+==$/e&lt;/code&gt;(Enter)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(translation: yank from cursor at most 400000 characters (not exactly bytes, though), including newlines, ending with two equals at the end of the line (the next header)). The &lt;code&gt;e&lt;/code&gt; is needed to move the cursor (here: the yank range) to the end of the match. As the search is greedy, it can contain more than one section, but will end with a new heading and fit into the specified limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To repeat, move cursor on next line after the new header, and hit &lt;code&gt;y/&lt;/code&gt;(Enter). To &lt;em&gt;view&lt;/em&gt; the selection before copying it, use &lt;code&gt;v/&lt;/code&gt;(Enter)  and, if all is ok, &lt;code&gt;y&lt;/code&gt; to yank it.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-06-07T00:07:31.637" LastActivityDate="2015-06-07T00:07:31.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3536" PostTypeId="2" ParentId="3534" CreationDate="2015-06-06T20:31:51.437" Score="2" Body="&lt;p&gt;Ok, this is somewhat of a quick hack, let's hope it works:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! &amp;lt;SID&amp;gt;Chunk()&#xA;    &quot; find first header&#xA;    let l_start = search('\m^==[^=]\+==$', 'cW')&#xA;    if !l_start&#xA;        &quot; beep&#xA;        execute &quot;normal \&amp;lt;Esc&amp;gt;&quot;&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; translate to byte position&#xA;    let b_start = line2byte(l_start)&#xA;    if b_start &amp;lt; 0&#xA;        &quot; beep&#xA;        execute &quot;normal \&amp;lt;Esc&amp;gt;&quot;&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; start marking&#xA;    execute 'normal V'&#xA;&#xA;    &quot; mode 400 KB down&#xA;    execute 'goto ' . (b_start + 400 * 1024)&#xA;    if line('.') == line('$')&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; find previous header&#xA;    let l_end  = search('\m^==[^=]\+==$', 'bcsW', l_start)&#xA;&#xA;    if l_end &amp;lt;= l_start || l_end &amp;lt;= 0&#xA;        &quot; not found&#xA;        &quot; go to beginning of line&#xA;        execute 'normal 0'&#xA;&#xA;        &quot; search next header&#xA;        let l_end  = search('\m^==[^=]\+==$', 'sW')&#xA;        if l_end &amp;lt;= 0&#xA;            &quot; not found&#xA;            &quot; go to end of file&#xA;            execute 'normal G$'&#xA;            return&#xA;        endif&#xA;    endif&#xA;&#xA;    &quot; move up&#xA;    exec 'normal k$'&#xA;    return&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;H :call &amp;lt;SID&amp;gt;Chunk()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It marks the next ~400 KB region of full headers.  After yanking it you can go to the end of the marked region with &lt;code&gt;'&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="1577" LastEditDate="2015-06-07T06:08:24.433" LastActivityDate="2015-06-07T06:08:24.433" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3537" PostTypeId="1" AcceptedAnswerId="3538" CreationDate="2015-06-07T01:47:58.660" Score="6" ViewCount="2944" Body="&lt;p&gt;I want to write a function which copies, say, the last word of the next line which contains &lt;code&gt;keyword&lt;/code&gt; into a variable say &lt;code&gt;var&lt;/code&gt; or any named register say &lt;code&gt;l&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did something inelegant:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CopyIntoVar()&#xA;          &quot;go to the next line which contains keyword&#xA;    /keyword&#xA;&#xA;          &quot;go to the last word and copy it like one does using normal mode&#xA;    normal $vb&quot;ly&#xA;    let var=@l&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I am not particularly interested in the last word. Just want to see how to copy a desired string into a register or variable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2369" LastActivityDate="2015-06-07T02:12:10.373" Title="Copying a String to a Variable or a Register from Within a Function" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3538" PostTypeId="2" ParentId="3537" CreationDate="2015-06-07T02:12:10.373" Score="6" Body="&lt;p&gt;I think you're looking for the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expand%28%29&quot;&gt;&lt;code&gt;expand()&lt;/code&gt;&lt;/a&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Expand wildcards and the following special keywords in `{expr}`.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;cWORD&amp;gt;&lt;/code&gt; special keywords:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;cword&amp;gt;     word under the cursor&#xA;&amp;lt;cWORD&amp;gt;     WORD under the cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your function would then look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CopyIntoVar()&#xA;    &quot; Go to the next line which contains keyword&#xA;    /keyword&#xA;&#xA;    &quot; Go to the last word&#xA;    normal $&#xA;&#xA;    &quot; Get the value of the word under the cursor&#xA;    let var = expand('&amp;lt;cword&amp;gt;')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This still has 2 side-effects though:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It will move the cursor&lt;/li&gt;&#xA;&lt;li&gt;Using &lt;code&gt;/&lt;/code&gt; will set the &lt;code&gt;&quot;/&lt;/code&gt; register (and pressing &lt;code&gt;n&lt;/code&gt; now searches for that pattern).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This may or may not be what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can use the &lt;code&gt;search()&lt;/code&gt; function to avoid setting &lt;code&gt;&quot;/&lt;/code&gt;, and use &lt;code&gt;getpos()&lt;/code&gt; and &lt;code&gt;setpos()&lt;/code&gt; to set &amp;amp; restore the cursor position:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another advantage of &lt;code&gt;search()&lt;/code&gt; it's not affected by settings such as &lt;code&gt;wrapscan&lt;/code&gt; or &lt;code&gt;magic&lt;/code&gt;; it always behaves the same.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CopyIntoVar()&#xA;    &quot; Save cursor position&#xA;    let l:save_cursor = getpos(&quot;.&quot;)   &#xA;&#xA;    &quot; Go to the next line which contains keyword&#xA;    call search('keyword')&#xA;&#xA;    &quot; Go to the last word&#xA;    normal $&#xA;&#xA;    &quot; Get the value of the word under the cursor&#xA;    let var = expand('&amp;lt;cword&amp;gt;')&#xA;&#xA;    &quot; Restore cursor position&#xA;    call setpos('.', l:save_cursor)   &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-06-07T02:12:10.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3539" PostTypeId="1" AcceptedAnswerId="3540" CreationDate="2015-06-07T12:30:08.093" Score="7" ViewCount="920" Body="&lt;p&gt;When writing markdown, a double space at the end of a line indicates a line break. Currently, neither single trailing whitespaces nor double-whitespaces are being highlighted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to have vim highlight trailing whitespace in one colour and markdown breaks (double trailing whitespace as another?). Not essential, but preferably this functionality will be toggleable.&lt;/p&gt;&#xA;" OwnerUserId="1872" LastActivityDate="2015-06-07T14:22:40.977" Title="Highlight double space in markdown" Tags="|syntax-highlighting|filetype-markdown|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3540" PostTypeId="2" ParentId="3539" CreationDate="2015-06-07T14:22:40.977" Score="8" Body="&lt;p&gt;Quick answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Todo &quot;\s$&quot;&#xA;syntax match Error &quot;\s\{2}$&quot;&#xA;syntax match Visual &quot;\s\{3,}$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses match groups already available from your colorscheme to highlight differently 1,2 or 3+ trailing spaces. You can define your own match groups instead (with more meaningful names for your usage and colored as you please) - see &lt;code&gt;h: match&lt;/code&gt; for a quick example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight MarkdownTrailingSpaces ctermbg=green guibg=green&#xA;syntax match MarkdownTrailingSpaces &quot;\s\{2}$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-06-07T14:22:40.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3541" PostTypeId="2" ParentId="3534" CreationDate="2015-06-07T20:27:29.127" Score="1" Body="&lt;p&gt;I'd do this in a shell script, which has the advantage that not only can you do this from Vim, with &lt;code&gt;:!./dosplit %&lt;/code&gt;, but you can also do it from the command line or as part of a bigger script that also uploads the files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a &lt;code&gt;dosplit&lt;/code&gt; script written in awk. It's usable out of the box on Unix-like systems, and requires an awk program to be installed on Windows (it's available ).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/awk -f&#xA;BEGIN {max = 409600}&#xA;/^==/ {    # It's a header line&#xA;    # Decide whether to start a new file&#xA;    if (length(chunk) + size &amp;gt; max) {++n; size=0}&#xA;    # Write the previous chunk&#xA;    size += length(chunk);&#xA;    printf &quot;%s&quot;, chunk &amp;gt;sprintf(&quot;output-%04d.txt&quot;, n);&#xA;    chunk = &quot;&quot;;&#xA;}&#xA;END {printf &quot;%s&quot;, chunk &amp;gt;sprintf(&quot;output-%04d.txt&quot;, n)} # Write the last chunk&#xA;{chunk = chunk $0 &quot;\n&quot;} # Accumulate the current chunk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8" LastActivityDate="2015-06-07T20:27:29.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3542" PostTypeId="1" AcceptedAnswerId="3544" CreationDate="2015-06-07T21:28:37.313" Score="7" ViewCount="722" Body="&lt;p&gt;I use Vim to edit LaTeX files frequently. I want to use &lt;code&gt;%&lt;/code&gt; to jump between matching &lt;code&gt;$&lt;/code&gt; which can be used to delimit where mathematical expressions are written.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried using matchit and, separately, I have tried using a filetype.vim (&lt;code&gt;tex.vim&lt;/code&gt;) file to add a match to the &lt;code&gt;matchpairs&lt;/code&gt; variable (&lt;code&gt;au FileType tex setmps+=$:$&lt;/code&gt;). I have managed to get both attempts to jump from the &lt;code&gt;$&lt;/code&gt;. However, the match that is found is for a different delimiter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, considering the string &lt;code&gt;$ { test text } $&lt;/code&gt;, placing my cursor over the first &lt;code&gt;$&lt;/code&gt; and pressing &lt;code&gt;%&lt;/code&gt; would jump me to the closing &lt;code&gt;}&lt;/code&gt;, not the last &lt;code&gt;$&lt;/code&gt;. Continued use of &lt;code&gt;%&lt;/code&gt; jumps me between &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;. Thus, I am stuck inside the match that I want to consider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how I might accomplish a jump from the first &lt;code&gt;$&lt;/code&gt; to the last &lt;code&gt;$&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2062" LastEditorUserId="205" LastEditDate="2016-02-14T14:07:54.633" LastActivityDate="2024-03-25T10:01:15.630" Title="Make % jump between identical delimiters" Tags="|filetype-tex|delimiter-matching|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3543" PostTypeId="2" ParentId="3542" CreationDate="2015-06-07T22:20:18.680" Score="3" Body="&lt;p&gt;Your &lt;code&gt;$&lt;/code&gt; match is ignored, &lt;code&gt;%&lt;/code&gt; searches forward for the first character in a pair that it knows about: so it finds &lt;code&gt;{&lt;/code&gt; and then the matching &lt;code&gt;}&lt;/code&gt;, and moves between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h mps&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Only character pairs are allowed that are different,&lt;br&gt;&#xA;    thus you cannot jump between two double quotes.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;One solution would be: to use the 'matchit' plugin (which allows for regular expressions as pairs, but has the same start != end delimiter) AND use the LaTeX math delimiters &lt;code&gt;\(&lt;/code&gt; &lt;code&gt;\)&lt;/code&gt;, which are different. Or, define two new TeX different commands for start &amp;amp; end inline math environment, that both resolve to &lt;code&gt;$&lt;/code&gt;, and use them as pairs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you can do in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime! macros/matchit.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And, for TeX files (e.g. in a function called from a &lt;code&gt;BufEnter&lt;/code&gt; autocmd):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:match_words = '\\(:\\)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you &lt;em&gt;have&lt;/em&gt; to use the &lt;code&gt;$&lt;/code&gt; sign, you can cheat a little and use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:match_words = '\s\$:\$\s'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... which will match a &lt;code&gt;$&lt;/code&gt; preceded by space as start delimiter with a &lt;code&gt;$&lt;/code&gt; followed by a space as end delimiter. But then you'll have to be consistent inside your formulas and use no space after the start delimiter, or before the end one. E.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ␣$\cos (2\theta) = \cos^2 \theta - \sin^2 \theta$␣ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-06-07T22:38:13.613" LastActivityDate="2015-06-07T22:38:13.613" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3544" PostTypeId="2" ParentId="3542" CreationDate="2015-06-08T06:54:44.223" Score="6" Body="&lt;p&gt;What you ask is possible, but the solution is nontrivial. Both &lt;a href=&quot;https://github.com/LaTeX-Box-Team/LaTeX-Box&quot;&gt;LaTeX-Box&lt;/a&gt; and &lt;a href=&quot;https://github.com/lervag/vimtex&quot;&gt;vimtex&lt;/a&gt; has implemented solutions for this, see here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/LaTeX-Box-Team/LaTeX-Box/blob/master/ftplugin/latex-box/motion.vim#L57&quot;&gt;LaTeX-Box/ftplugin/latex-box/motion.vim:57&lt;/a&gt; (&lt;code&gt;s:FindMatchingPair&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/autoload/vimtex/motion.vim#L303&quot;&gt;vimtex/autoload/vimtex/motion.vim:303&lt;/a&gt; (&lt;code&gt;s:highlight_matching_pair&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These functions are run by autocommands whenever the cursor is moved, see &lt;a href=&quot;https://github.com/LaTeX-Box-Team/LaTeX-Box/blob/master/ftplugin/latex-box/motion.vim#L167&quot;&gt;here (LaTeX-Box)&lt;/a&gt; and &lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/autoload/vimtex/motion.vim#L19&quot;&gt;here (vimtex)&lt;/a&gt;. The original matchparen plugin is disabled, and the LaTeX-specific function, e.g. &lt;code&gt;s:highlight_matching_pair&lt;/code&gt;, is enabled as a custom matchparen-plugin. Note that both these functions also enable matching of other LaTeX-delimiters such as &lt;code&gt;begin/end&lt;/code&gt; pairs and pairs like &lt;code&gt;\left(..\right)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The links above are linked to line numbers in evolving codes. These line numbers might change in the future. The function names will probably stay the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Other LaTeX-plugins might also implement this feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: I'm the author of vimtex.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-06-08T06:54:44.223" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3545" PostTypeId="2" ParentId="3489" CreationDate="2015-06-08T08:06:16.910" Score="5" Body="&lt;p&gt;As the question doesn't seem to generate a lot of answer I'll just answer it with the suggestion of @muru which is what I have used for a week before I switched to the netrw explorer. (Of course if a better option answer comes up I'll gladly unmark mine as accepted and accept the new one)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to use the folowing mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map d&amp;lt;cr&amp;gt; &amp;lt;cr&amp;gt;:NERDTreeClose&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which opens the file as it is done usually and then calls the function which close the NERDTree buffer no matter where the cursor is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I recently switched back to NERDTree and reworked my solution: The mapping I suggested before was working but as it existed in every buffer I had to double press &lt;kbd&gt;d&lt;/kbd&gt; each time I wanted to delete something which is pretty annoying. &lt;em&gt;(Maybe I could have changed the &lt;code&gt;timeout&lt;/code&gt; settings but I like the way it is currently set for me, also I didn't want to map it on another key combination).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I replaced my first solution by the following lines to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter NERD_tree_* nmap  d&amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt; :NERDTreeToggle &amp;lt;CR&amp;gt;&#xA;autocmd BufLeave NERD_tree_* unmap d&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way the mapping is created only in the &lt;code&gt;NERDTree&lt;/code&gt; buffers and it doesn't mess with my workflow in the other buffers.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-07-15T12:12:52.953" LastActivityDate="2015-07-15T12:12:52.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3547" PostTypeId="2" ParentId="3438" CreationDate="2015-06-08T14:07:20.167" Score="1" Body="&lt;p&gt;The issue was that i had  a mapping &lt;code&gt;map &amp;lt;C-m&amp;gt; :tnext&amp;lt;CR&amp;gt;&lt;/code&gt; in my vimrc . &#xA;In vim, &lt;code&gt;&amp;lt;C-m&amp;gt;&lt;/code&gt; is equivalent to &lt;code&gt;Enter&lt;/code&gt;. &#xA;More detailed answer at &lt;a href=&quot;https://stackoverflow.com/questions/3935970/vim-how-to-map-ctrl-m-without-affecting-return-keypress-as-well&quot;&gt;how to map Ctrl-m without affecting return keypress&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2277" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-06-08T14:07:20.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3548" PostTypeId="1" CreationDate="2015-06-08T15:40:41.847" Score="4" ViewCount="744" Body="&lt;p&gt;I have a file that has dates in this format: &lt;code&gt;Fri Jun 05, 2015&lt;/code&gt;.  It's essentially a diary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have created the syntax keywords &lt;code&gt;Day&lt;/code&gt;, &lt;code&gt;Month&lt;/code&gt;, &lt;code&gt;dateNum&lt;/code&gt;, and &lt;code&gt;Year&lt;/code&gt; for the various components of the date but I want to highlight the date as a single entity.  Is it possible to create a syntax rule that is a sequence of keywords?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the contents of my syntax file so far.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match Code '`.*`'&#xA;syn match Time '[01][0-9]:[0-5][0-9]\(:[0-5][0-9]\)\?'&#xA;&#xA;syn keyword Day Mon, Tue, Wed, Thu, Fri, Sat, Sun, nextgroup=Month&#xA;syn keyword Month Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec nextgroup=dateNum&#xA;&#xA;syn match dateNum '[0-3][0-9],'  nextgroup=Year&#xA;syn match Year '\d\{4}'&#xA;&#xA;syn region Code start=&quot;`&quot; end=&quot;`&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am manually setting the highlighting for these groups for the time being (e.g. &lt;code&gt;hi Time gui=bold&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a sample diary file.  Note that the highlighting for &lt;code&gt;Time&lt;/code&gt; and &lt;code&gt;Code&lt;/code&gt; already work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sun Jun 07, 2015&#xA;&#xA;23:48 Checked out `bleeding-edge` branch.&#xA;&#xA;Mon Jun 08, 2015&#xA;&#xA;09:17 Woke up&#xA;&#xA;09:18 Hit snooze.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2399" LastEditorUserId="2399" LastEditDate="2015-06-08T16:20:05.370" LastActivityDate="2015-06-08T16:20:05.370" Title="Highlighting Date in Vim" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3549" PostTypeId="2" ParentId="3548" CreationDate="2015-06-08T15:54:39.847" Score="4" Body="&lt;p&gt;Yes; you can just combine the keywords in a long &lt;code&gt;:syntax match&lt;/code&gt; sequence. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup diary&#xA;    autocmd!&#xA;    autocmd ColorScheme,BufRead,BufNewFile *&#xA;        \  syntax match DiaryDate &quot;\v(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d, \d\d\d\d&quot;&#xA;        \| highlight DiaryDate ctermbg=green guibg=green&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/m2TJL.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-06-08T15:54:39.847" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3551" PostTypeId="1" AcceptedAnswerId="3553" CreationDate="2015-06-09T03:52:11.720" Score="5" ViewCount="195" Body="&lt;p&gt;I am trying out MacVim for the first time and Vim seems to think I have a surplus of closing parentheses:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/LzXZi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, Vim seems to change it's mind. Each highlighted closing parenthesis is no longer highlighted after placing the cursor over it. I demonstrate this in a short video:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=0O9pthxkSRE&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=0O9pthxkSRE&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Notice the highlighted closing parentheses at the end of the 1st, 3rd, and 4th procedure definition.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I confirmed that the parentheses are balanced using DrRacket, and the code does compile and run properly. In an attempt to troubleshoot, I tested the code using MacVim on a different user account on the same computer. Parentheses were still being highlighted as if they were surplus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The full text of the file, named &lt;code&gt;yetanotherscm.scm&lt;/code&gt; is here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(define atom?&#xA;  (lambda (x)&#xA;    (and (not (pair? x)) (not (null? x)))))&#xA;&#xA;(define lat?&#xA;  (lambda (l)&#xA;    (cond&#xA;      ((null? l) #t)&#xA;      ((atom? (car l))(lat? (cdr l)))&#xA;      (else #f))))&#xA;&#xA;(define member?&#xA;  (lambda (a lat)&#xA;    (cond&#xA;      ((null? lat) #f)&#xA;      ((eq? a (car lat)) #t)&#xA;      (else (member? a (cdr lat))))))&#xA;&#xA;&#xA;(define rember&#xA;  (lambda (a lat)&#xA;    (cond &#xA;      ((null? lat) lat)&#xA;      ((eq? a (car lat))(cdr lat))&#xA;      (else (cons (car lat) (rember a (cdr lat)))))))&#xA;&#xA;(define firsts&#xA;  (lambda (l)&#xA;    (cond&#xA;      ((null? l) '())&#xA;      (else (cons (car (car l)) (firsts (cdr l)))))))&#xA;&#xA;&#xA;&#xA;&#xA;(define sbst &#xA;  (lambda (new old lat)&#xA;    (cond&#xA;      ((null? lat) '() )&#xA;      ((eq? (car lat) old)(cons new (cdr lat)))&#xA;      (else (cons (car lat) (sbst new old (cdr lat)) )))))&#xA;(sbst 'joseph 'hpesoj '(joseph spelt backwords is hpesoj is it not?))&#xA;&#xA;&#xA;&#xA;(define multirember&#xA;  (lambda (a lat)&#xA;    (cond&#xA;      ((null? lat) lat)&#xA;      ((eq? (car lat) a)(multirember a (cdr lat)))&#xA;      ((cons (car lat) (multirember a (cdr lat)))))))&#xA;&#xA;(define multiinsertR&#xA;  (lambda (new old lat)&#xA;    (cond &#xA;      ((null? lat) lat)&#xA;      ((eq? (car lat) old)(cons old (cons new (multiinsertR new old (cdr lat)))))&#xA;      (else (cons (car lat) (multiinsertR new old (cdr lat)))))))&#xA;&#xA;(multiinsertR 'new 'old '(this table is old and i am happy that it is old so old happy))&#xA;&#xA;&#xA;&#xA;(define multiinsertL2&#xA;  (lambda (new old lat)&#xA;    (cond&#xA;    ((null? lat) lat)&#xA;    ((eq? (car lat) old)(cons new (cons old (multiinsertL2 new old (cdr lat)))))&#xA;    (else (cons (car lat) (multiinsertL2 new old (cdr lat))))&#xA;    )))&#xA;&#xA;(multiinsertL2 'fried 'fish '(chips and fish or fish and fried))&#xA;&#xA;&#xA;(define multisubst&#xA;  (lambda (new old lat)&#xA;    (cond&#xA;      ((null? lat) lat)&#xA;      ((eq? (car lat) old) (cons new (multisubst new old (cdr lat))))&#xA;      (else (cons (car lat) (multisubst new old (cdr lat)))))))&#xA;&#xA;(multisubst 'joe 'joseph '(joseph is a pretty cool guy joseph was not here joseph))&#xA;&#xA;(define two-in-a-row&#xA;  (lambda (lat)&#xA;    (cond&#xA;      ((null? lat) #f)&#xA;      ((eq? (car lat) (car (cdr lat) #t)))&#xA;      (else (two-in-a-row (cdr lat))))))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The version of Vim/MacVim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun  8 2015 16:45:59)&#xA;MacOS X (unix) version&#xA;Included patches: 1-712&#xA;Compiled by Homebrew&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do you have any idea what's going on?&lt;/li&gt;&#xA;&lt;li&gt;What steps can i take to correct this?&lt;/li&gt;&#xA;&lt;li&gt;Is there a user preferences file(s)/folder(s) i can delete, so I can&#xA;reinstall MacVim through Homebrew?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2407" LastEditorUserId="2407" LastEditDate="2015-06-09T04:11:41.837" LastActivityDate="2015-06-09T07:21:10.383" Title="MacVim thinks I have unmatching parentheses, until I place cursor over each parenthesis" Tags="|syntax-highlighting|macvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3552" PostTypeId="1" AcceptedAnswerId="3554" CreationDate="2015-06-09T07:16:36.773" Score="2" ViewCount="1334" Body="&lt;p&gt;Vim diff opens 2 files for diffing, but it doesn't navigate to the first diff section automatically on startup. Can I add something to startup script (like _vimrc) to do this?&lt;/p&gt;&#xA;" OwnerUserId="477" LastEditorUserId="24" LastEditDate="2015-06-09T20:15:25.280" LastActivityDate="2023-08-25T18:47:29.553" Title="Navigate to first diff in diff mode on startup?" Tags="|cursor-movement|vimdiff|autocmd|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3553" PostTypeId="2" ParentId="3551" CreationDate="2015-06-09T07:21:10.383" Score="7" Body="&lt;p&gt;I can reproduce the problem on my Linux system running Vim 7.4.729 as &lt;code&gt;gvim&lt;/code&gt;. The problem appears to be the synchronizing of Vim's syntax highlighting engine. To save time, Vim doesn't always look at the whole file to figure out how to highlight it. In this case, Vim isn't looking back far enough in the file to see the opening parenthesis, so it thinks any parenthesis that would close it is extra. See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :syn-sync&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can fix the problem by executing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax sync fromstart&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To fix the problem permanently, at the expense of taking longer to open larger Scheme files, you can put that statement in a file named &lt;code&gt;~/.vim/after/syntax/scheme.vim&lt;/code&gt;. &lt;code&gt;~/.vim&lt;/code&gt; would be the directory on a Unix system for your personal configuration files. I think the location is the same or similar on a Mac. See also&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help mysyntaxfile-add&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-06-09T07:21:10.383" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3554" PostTypeId="2" ParentId="3552" CreationDate="2015-06-09T07:49:04.857" Score="7" Body="&lt;p&gt;&lt;code&gt;]c&lt;/code&gt; doesn't jump to the &lt;em&gt;first&lt;/em&gt; difference, it jumps to the &lt;em&gt;next&lt;/em&gt; difference. If your first difference is on the first line, &lt;code&gt;]c&lt;/code&gt; would jump to the the second one which is not what you want. One could work around that with &lt;code&gt;]c[c&lt;/code&gt; (jump to next difference then jump to previous).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -d -c 'norm ]c[c' filea fileb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;seems to do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think it is necessarily a good idea to put that in your startup sciript.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-06-09T14:44:49.537" LastActivityDate="2015-06-09T14:44:49.537" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3555" PostTypeId="1" AcceptedAnswerId="3556" CreationDate="2015-06-09T13:58:11.823" Score="14" ViewCount="3835" Body="&lt;p&gt;If I have a file with a lot of comments in it and I want to delete all of the comments from say, line 3 to the end of the file, what's the best way to do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm stuck, since what I first tried doesn't seem to do quite what I want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:3,$/^#/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of looking for the pattern and deleting lines with it in the range from 3 to the end of the file it deletes all of the lines from 3 to through a line that matches the pattern, and then stops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how do I apply an ex command to a range of lines.  In this case it's to to the end of a file, but would it be different if I were to do it to a mark, or between lines 10 and 20 or other ranges?&lt;/p&gt;&#xA;" OwnerUserId="1828" LastActivityDate="2021-01-10T09:01:40.550" Title="delete lines that match a pattern from a given line to the end of the file" Tags="|ex-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3556" PostTypeId="2" ParentId="3555" CreationDate="2015-06-09T14:17:55.307" Score="19" Body="&lt;p&gt;Use the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_10.html#10.4&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:global&lt;/code&gt;&lt;/a&gt; command for that:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:3,$g/^#/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can apply it to lines &lt;strong&gt;not&lt;/strong&gt; matching a pattern:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:3,$g!/^#/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can use the full range mechanism with it (see &lt;code&gt;:help :range&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:.,/#define/+3g/^#/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And you can use it with any command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:3,$g/^#/s/foo/bar/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It's one of the most powerful commands in Vim, please see &lt;code&gt;:help :global&lt;/code&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="19031" LastEditDate="2021-01-10T09:01:40.550" LastActivityDate="2021-01-10T09:01:40.550" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3557" PostTypeId="1" AcceptedAnswerId="3558" CreationDate="2015-06-09T14:52:15.983" Score="35" ViewCount="13391" Body="&lt;p&gt;I have a file with the character &lt;code&gt;ã&lt;/code&gt; (lowercase a + combining tilde).  &lt;code&gt;Encoding&lt;/code&gt; and &lt;code&gt;fileencoding&lt;/code&gt; are both &lt;code&gt;utf-8&lt;/code&gt;.  &lt;code&gt;ga&lt;/code&gt; shows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;a&amp;gt; 97, hex 61, octal 141 &amp;lt;~&amp;gt; 771, Hex 0303, Octal 1403&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(but with the actual combining tilde in the &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt;) and &lt;code&gt;g8&lt;/code&gt; shows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;61 + cc 83&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Searching with &lt;code&gt;/a\%u0303&lt;/code&gt; works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Searching for just &lt;code&gt;\%u0303&lt;/code&gt; gives E486 Pattern not Found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I search for just the combining character without also searching for the base character?&lt;/p&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="24" LastEditDate="2015-06-09T20:14:16.563" LastActivityDate="2015-06-09T20:14:16.563" Title="Can I search for a Unicode combining character in Vim?" Tags="|search|regular-expression|unicode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3558" PostTypeId="2" ParentId="3557" CreationDate="2015-06-09T16:13:50.823" Score="38" Body="&lt;p&gt;Type in normal mode &lt;code&gt;/&amp;lt;ctr-v&amp;gt;u0303&lt;/code&gt;&#xA;&lt;br/&gt;&lt;code&gt;/&lt;/code&gt; - start search&#xA;&lt;br/&gt;&lt;code&gt;&amp;lt;Ctr-v&amp;gt;u&lt;/code&gt; - init utf-8 code input&#xA;&lt;br/&gt;&lt;code&gt;0303&lt;/code&gt; - hex code combine character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:he unicode&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also &lt;code&gt;:he mbyte-combining&lt;/code&gt; and &lt;code&gt;:he utf-8-char-arg&lt;/code&gt; the last one covered case with commands like &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt; and so on.&lt;/p&gt;&#xA;" OwnerUserId="1145" LastActivityDate="2015-06-09T16:13:50.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3559" PostTypeId="1" AcceptedAnswerId="3560" CreationDate="2015-06-10T15:30:27.020" Score="6" ViewCount="431" Body="&lt;p&gt;I added the following key mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;Up&amp;gt;   &amp;lt;C-o&amp;gt;gk&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;Down&amp;gt; &amp;lt;C-o&amp;gt;gj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The goal was that &lt;code&gt;j&lt;/code&gt;/&lt;code&gt;k&lt;/code&gt; would still work the way that I was used to, but that I could use the arrow keys as an alternative to more easily navigate wrapped lines.  Now I've discovered that these mappings interfere with omnicompletion.  If I hit an arrow key, &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; ends the omnicomplete, and &lt;code&gt;gj&lt;/code&gt; (or &lt;code&gt;gk&lt;/code&gt;) is inserted at the cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found an mailing list exchange from 2006 where Bram &lt;a href=&quot;http://vim.1045645.n5.nabble.com/Bug-or-feature-Mappings-in-omni-completion-popup-menu-td1196760.html&quot;&gt;acknowledges the issue&lt;/a&gt;, but can't find any mention of it more recently.  Is this still an unresolved issue?  Is there any way to make imap bindings beginning with &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; compatible with omnicompletion?&lt;/p&gt;&#xA;" OwnerUserId="1688" LastEditorUserId="51" LastEditDate="2015-06-10T15:51:58.497" LastActivityDate="2016-03-11T11:19:56.247" Title="imap beginning with &lt;C-o&gt; interferes with omnicomplete" Tags="|key-bindings|autocompletion|insert-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3560" PostTypeId="2" ParentId="3559" CreationDate="2015-06-10T15:44:57.013" Score="10" Body="&lt;p&gt;You can use the more powerful &quot;expression mappings&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;Up&amp;gt;   pumvisible() ? &quot;\&amp;lt;Up&amp;gt;&quot; : &quot;\&amp;lt;C-o&amp;gt;gk&quot;&#xA;:inoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;Down&amp;gt; pumvisible() ? &quot;\&amp;lt;Down&amp;gt;&quot; : &quot;\&amp;lt;C-o&amp;gt;gj&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that we added the &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; keyword here. Now Vim expects that the right-hand is some (valid) VimScript expression. This expression is evaluated every time the key is pressed and the result is used as the action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here we use the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#pumvisible%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;pumvisible()&lt;/code&gt;&lt;/a&gt; function (short for &quot;pop-up menu visible&quot;) to check if the popup menu is visible. If it is, just go up/down. If it isn't, use your special mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap-expression&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help :map-expression&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Expression mappings were introduced with Vim 7, which was released in May 2006 (after the maillist post you linked to), which is why no one mentioned this as a solution back then :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-03-11T11:19:56.247" LastActivityDate="2016-03-11T11:19:56.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3561" PostTypeId="1" AcceptedAnswerId="3566" CreationDate="2015-06-10T23:32:34.833" Score="24" ViewCount="14440" Body="&lt;p&gt;It's really frustrating when I need to edit a file as root and use &lt;code&gt;sudo vim somefile.conf&lt;/code&gt; and I can't use any of my keybindings and settings and plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get all my customizations when I need to edit as root?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using vim-plug for my plugins.&lt;/p&gt;&#xA;" OwnerUserId="2221" LastActivityDate="2023-03-10T16:32:22.567" Title="Settings and plugins when root (`sudo vim`)?" Tags="|vimrc|plugin-system|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3562" PostTypeId="2" ParentId="3561" CreationDate="2015-06-10T23:32:34.833" Score="8" Body="&lt;p&gt;It looks like all you have to do is symlink root's &lt;code&gt;~/.vimrc&lt;/code&gt; and &lt;code&gt;~/.vim/&lt;/code&gt; to your's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just run as root:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ln -s /home/&amp;lt;user&amp;gt;/.vimrc /root/.vimrc&#xA;ln -s /home/&amp;lt;user&amp;gt;/.vim/ /root/.vim/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that should do it!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;(P.S.  I figured this out just now and wanted to share with any other noobs.  Please let me know if there's a better way.)&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="2221" LastActivityDate="2015-06-10T23:32:34.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3563" PostTypeId="1" AcceptedAnswerId="3565" CreationDate="2015-06-11T00:14:22.470" Score="23" ViewCount="1934" Body="&lt;p&gt;Is there a faster way to erase the text on a line than&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;pressing &lt;kbd&gt;0&lt;/kbd&gt; to jump to the start, then&lt;/li&gt;&#xA;&lt;li&gt;pressing &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt; to delete until the end of the line?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also, what if I wanted to delete everything &lt;em&gt;except&lt;/em&gt; the indentation?  Is there a way to do that?&lt;/p&gt;&#xA;" OwnerUserId="2221" LastActivityDate="2015-07-01T17:16:06.260" Title="Clear a line faster than [0][d][$]" Tags="|key-bindings|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3564" PostTypeId="2" ParentId="3563" CreationDate="2015-06-11T00:14:22.470" Score="9" Body="&lt;p&gt;Yep.  If there's one thing I'm liking about Vim, it's that the answer to &quot;Can I do that?&quot; is almost always an emphatic &lt;strong&gt;yes&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;D&lt;/kbd&gt; Jumps to the beginning, then deletes through the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;^&lt;/kbd&gt;&lt;kbd&gt;D&lt;/kbd&gt; (not Ctrl+D) will jump to the first non-whitespace character, then delete through the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;(P.S.  I figured this out just now and wanted to share with any other noobs.  Please let me know if there's a better way.)&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="2221" LastActivityDate="2015-06-11T00:14:22.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3565" PostTypeId="2" ParentId="3563" CreationDate="2015-06-11T02:08:34.620" Score="38" Body="&lt;p&gt;As you said, there are multiple ways, and you can also take into account on what your next action will be after you clear or delete the current line.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;dd&lt;/kbd&gt; will delete the current line (not clear)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;0D&lt;/kbd&gt; will clear the current line including whitespace&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;^D&lt;/kbd&gt; will clear the current line &lt;em&gt;not&lt;/em&gt; including whitespace (&lt;kbd&gt;^dg_&lt;/kbd&gt; saves trailing space)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;0C&lt;/kbd&gt; will clear the current line including whitespace and put you into insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;^C&lt;/kbd&gt; will clear the current line &lt;em&gt;not&lt;/em&gt; including whitespace and put you into insert mode (&lt;kbd&gt;^cg_&lt;/kbd&gt; saves trailing space)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;cc&lt;/kbd&gt; or &lt;kbd&gt;S&lt;/kbd&gt; will function as either 4. or 5. if 'autoindent' is off or on respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So use whatever fits the action at hand. I believe that &lt;kbd&gt;0D&lt;/kbd&gt; is the fastest to clear the line, but you can map that to something if you wish, to make it even faster.&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="2221" LastEditDate="2015-06-30T15:17:56.490" LastActivityDate="2015-06-30T15:17:56.490" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3566" PostTypeId="2" ParentId="3561" CreationDate="2015-06-11T06:18:21.157" Score="19" Body="&lt;p&gt;Rather than opening vim as root, you can simply save as root by redirecting to tee. Here is an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !sudo tee % &amp;gt; /dev/null&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This may be useful to alias in your .vimrc, I use &lt;code&gt;:Sw&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=0 Sw w !sudo tee % &amp;gt; /dev/null&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2425" LastActivityDate="2015-06-11T06:18:21.157" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3567" PostTypeId="2" ParentId="3563" CreationDate="2015-06-11T07:49:53.763" Score="3" Body="&lt;p&gt;With Kana's &quot;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3886&quot; rel=&quot;nofollow&quot;&gt;vim-textobj-line&lt;/a&gt;&quot; plugin, you can use operations on indented line with &lt;code&gt;il&lt;/code&gt; (e.g. &lt;code&gt;dil&lt;/code&gt;), or entire line without the newline, with &lt;code&gt;al&lt;/code&gt; (e.g. &lt;code&gt;yal&lt;/code&gt;). The advantage of this approach is subtle: instead of having to think of &lt;em&gt;both&lt;/em&gt; motions (start, end) for the desired operation, you specify the text-object &lt;em&gt;directly&lt;/em&gt;: &lt;strong&gt;i&lt;/strong&gt;n &lt;strong&gt;l&lt;/strong&gt;ine, &lt;strong&gt;a&lt;/strong&gt; &lt;strong&gt;l&lt;/strong&gt;ine.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-07-01T17:16:06.260" LastActivityDate="2015-07-01T17:16:06.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3568" PostTypeId="2" ParentId="3561" CreationDate="2015-06-11T09:52:07.630" Score="12" Body="&lt;p&gt;Two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;$ sudo -e file&lt;/code&gt; to edit &lt;code&gt;file&lt;/code&gt; with &lt;code&gt;$EDITOR&lt;/code&gt;. Add &lt;code&gt;export EDITOR=/path/to/vim&lt;/code&gt; if &lt;code&gt;$EDITOR&lt;/code&gt; is not already set.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Going vanilla is an excellent way to fight your plugin addiction.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-06-11T09:52:07.630" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3569" PostTypeId="2" ParentId="3563" CreationDate="2015-06-11T13:02:06.070" Score="7" Body="&lt;p&gt;Clear the line with one (shifted) key: &lt;kbd&gt;S&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also keeps the indent. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You go into insert mode at the first position after the indent, or at start of line - just what you need to substitute a line - therefore the name &lt;code&gt;S&lt;/code&gt; - like substitute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help S&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&quot;x]S   Delete [count] lines [into register x] and start&#xA;        insert.  Synonym for &quot;cc&quot; |linewise|.&#xA;&#xA;[&quot;x]cc  Delete [count] lines [into register x] and start&#xA;        insert |linewise|.  If 'autoindent' is on, preserve&#xA;        the indent of the first line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="925" LastEditorUserId="205" LastEditDate="2015-06-14T19:37:36.960" LastActivityDate="2015-06-14T19:37:36.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3570" PostTypeId="2" ParentId="3225" CreationDate="2015-06-12T00:08:26.823" Score="42" Body="&lt;p&gt;First, a bit of history. In the old days, when you typed some text on a &lt;a href=&quot;http://en.wikipedia.org/wiki/Teletype_Corporation&quot; rel=&quot;noreferrer&quot;&gt;terminal&lt;/a&gt;, each key sent a character to the application. As the machines that the terminal was connected to became more powerful, terminals standardized on a &lt;a href=&quot;http://en.wikipedia.org/wiki/Control_key#History&quot; rel=&quot;noreferrer&quot;&gt;control key&lt;/a&gt;, which would send some special characters, which were not printed but had some kind of function. The eventually triumphant character set was &lt;a href=&quot;http://en.wikipedia.org/wiki/ASCII&quot; rel=&quot;noreferrer&quot;&gt;ASCII&lt;/a&gt;, with 128 characters out of which 32 are control characters. Pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt; together with a letter or other symbol written 10xxxxx₂ (binary notation) sends the control character whose code is 00xxxxx₂, e.g. &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; sends character number 27₁₀ = 0011011₂ because &lt;code&gt;[&lt;/code&gt; is 91₁₀ = 1011011₂.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few function keys on terminals sent control characters:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Backspace&lt;/kbd&gt; = &lt;code&gt;Ctrl-H&lt;/code&gt; (BS = BackSpace)¹&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Tab&lt;/kbd&gt; = &lt;code&gt;Ctrl-I&lt;/code&gt; (HT = Horizontal Tab)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Linefeed&lt;/kbd&gt; = &lt;code&gt;Ctrl-J&lt;/code&gt; (LF = Line Feed) (few terminals ever had this key)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Return&lt;/kbd&gt; or &lt;kbd&gt;Enter&lt;/kbd&gt; = &lt;code&gt;Ctrl-M&lt;/code&gt; (CR = Carriage Return)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Escape&lt;/kbd&gt; = &lt;code&gt;Ctrl-[&lt;/code&gt; (ESC = Escape)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When terminals had more function keys, there weren't enough control characters to represent them all. So they sent &lt;em&gt;sequences&lt;/em&gt; of character, and the universal convention is that these character sequences begin with the escape character, &lt;code&gt;Ctrl-[&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As time went by, hardware terminals became rarer and rarer; nowadays there are &lt;a href=&quot;https://unix.stackexchange.com/questions/116629/how-do-keyboard-input-and-text-output-work&quot;&gt;many levels of translation between the keyboard and the application&lt;/a&gt;. The limitation in numbers of available characters and the hard-coded correspondences between certain key combinations and certain control characters is no longer relevant. However, applications have remained compatible with existing terminals, and terminals have remained compatible with existing applications, which made it difficult to change anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So even today, on Unix-like systems, applications running in a terminal emulator receive the character &lt;code&gt;Ctrl-I&lt;/code&gt; when the user presses the &lt;kbd&gt;Tab&lt;/kbd&gt; key, the character &lt;code&gt;Ctrl-[&lt;/code&gt; when the user presses &lt;kbd&gt;Esc&lt;/kbd&gt;, etc. If Vim is running in a Unix terminal, it can't distinguish between &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Ctrl-[&amp;gt;&lt;/code&gt; because the terminal sends the same information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim running in other environments doesn't have this limitation, so in principle it would be possible for them to send different information. Given that Vim uses the &lt;code&gt;Ctrl-[&lt;/code&gt; character to represent &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; in a lot of places, changing that would be impractical; instead &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; could be made to send a different input event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not aware of any version of Vim itself that does differentiate between &lt;kbd&gt;Esc&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; (but it isn't like I'd ever used any). Gvim, for one, seems to &lt;a href=&quot;https://superuser.com/questions/770068/in-vim-how-can-i-remap-tab-without-also-remapping-ctrli&quot;&gt;emulate a garden variety terminal&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ironically, your best bet may be Vim running in a terminal emulator. Some terminal emulators allow you to customize escape sequences sent by keys and keychords. So you might arrange for &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; to send not the ␛ (&lt;code&gt;Ctrl-[&lt;/code&gt;) character, but some escape sequence. Xterm, the “reference” terminal emulator for Unix-like systems, supports two such schemes. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; sends &lt;code&gt;␛&lt;/code&gt; and &lt;kbd&gt;Tab&lt;/kbd&gt; sends &lt;code&gt;␉&lt;/code&gt;, in all configurations.&lt;/li&gt;&#xA;&lt;li&gt;With &lt;code&gt;?.VT100.modifyOtherKeys: 0&lt;/code&gt; (default) or &lt;code&gt;?.VT100.modifyOtherKeys: 1&lt;/code&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; sends &lt;code&gt;␛&lt;/code&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;I&lt;/kbd&gt; sends &lt;code&gt;␉&lt;/code&gt;. &lt;code&gt;?.VT100.modifyOtherKeys: 1&lt;/code&gt; only affects meta combinations and control combinations that lack an ASCII character.&lt;/li&gt;&#xA;&lt;li&gt;With &lt;code&gt;?.VT100.modifyOtherKeys: 2&lt;/code&gt; and &lt;code&gt;?.VT100.formatOtherKeys: 0&lt;/code&gt; (default),  &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; sends &lt;code&gt;␛[27;5;91~&lt;/code&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;I&lt;/kbd&gt; sends &lt;code&gt;␛[27;5;105~&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;With &lt;code&gt;?.VT100.modifyOtherKeys: 2&lt;/code&gt; and &lt;code&gt;?.VT100.formatOtherKeys: 1&lt;/code&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; sends &lt;code&gt;␛[91;5u&lt;/code&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;I&lt;/kbd&gt; sends &lt;code&gt;␛[105;5u&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Support can be turned on by setting the &lt;code&gt;modifyOtherKeys&lt;/code&gt; &lt;a href=&quot;http://invisible-island.net/xterm/manpage/xterm.html#h2-RESOURCES&quot; rel=&quot;noreferrer&quot;&gt;resource&lt;/a&gt; when starting xterm (and &lt;code&gt;formatOtherKeys&lt;/code&gt; to select between the two schemes), or it can be turned on and off dynamically by the application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has no built-in support that I know of. You can write your own bindings for these escape sequences. It may be possible to get Vim to automatically set the terminal in the &lt;code&gt;modifyOtherKeys&lt;/code&gt; mode by feeding it a modified terminal definition, but doing so is beyond the scope of this answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neovim &lt;a href=&quot;https://github.com/neovim/neovim/issues/176&quot; rel=&quot;noreferrer&quot;&gt;has built-in support for one of the variants&lt;/a&gt;. As far as I understand, it doesn't switch support on if the terminal supports it, that's up to the user to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;¹ Increasingly and most commonly nowadays, &lt;kbd&gt;Backspace&lt;/kbd&gt; sends character 127.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2015-06-12T00:08:26.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3571" PostTypeId="2" ParentId="2541" CreationDate="2015-06-12T12:14:15.347" Score="4" Body="&lt;p&gt;This can be a case deserving a new text object. With Kana's framework (&lt;code&gt;vim-textobj-user&lt;/code&gt;) in place, it would be something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; define av/iv to select a bash variable:&#xA;call textobj#user#plugin('bash', {&#xA;        \  'avar': {&#xA;        \   'pattern': '\$\w\+\&amp;gt;',&#xA;        \   'select': [ 'av'],&#xA;        \  },&#xA;        \  'ivar': {&#xA;        \   'pattern': '\$\zs\w\+\&amp;gt;',&#xA;        \   'select': [ 'iv'],&#xA;        \  },&#xA;        \  'var': {&#xA;        \   'pattern': ['\${', '}'],&#xA;        \   'select-i': [ 'iV'],&#xA;        \   'select-a': [ 'aV'],&#xA;        \  },&#xA;        \ })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and then I can use 'div', 'yav' etc. to delete inside the object (skipping the &lt;code&gt;$&lt;/code&gt;) or yank the whole variable, and use &lt;code&gt;iV&lt;/code&gt;/&lt;code&gt;aV&lt;/code&gt; for the &lt;code&gt;${var}&lt;/code&gt; format. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope a more enterprising soul can unify those formats, to use a single code letter (e.g. &lt;code&gt;v&lt;/code&gt;) in both cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this won't work with the mapping you mentioned for a few reasons. First, the mapping would need to be recursive to take advantage of the new text object. Second, the map would need to use different movements to reach the start/end of the word. Staying approximately similar to what you have already, this mapping should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;&quot; vav&amp;lt;esc&amp;gt;`&amp;gt;a&quot;&amp;lt;esc&amp;gt;`&amp;lt;i&quot;&amp;lt;esc&amp;gt;f&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses the selection based movements &lt;code&gt;`&amp;gt;&lt;/code&gt; and &lt;code&gt;`&amp;lt;&lt;/code&gt; to reach the end and beginning of the selection, respectively. However, this might not play well with other mappings/plugins/etc that you may have, so be wary of that. Furthermore, this will not allow the mapping to work for normal words. To do that you would have to modify the text object to overwrite the default &lt;code&gt;w&lt;/code&gt; behavior.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1166" LastEditDate="2015-06-12T19:26:14.560" LastActivityDate="2015-06-12T19:26:14.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3572" PostTypeId="1" AcceptedAnswerId="3573" CreationDate="2015-06-12T16:48:35.560" Score="3" ViewCount="65" Body="&lt;p&gt;I want to delete all the comments from a program.  Vim already knows (in some sense) where all the comments are because it is correctly formatting them based on the syntax file the particular language I'm using.  So, I'd like to do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/[sComments]/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Possible?&lt;/p&gt;&#xA;" OwnerUserId="2452" LastActivityDate="2015-06-12T17:33:45.027" Title="Match by syntax highlighting instead of expressions" Tags="|syntax-highlighting|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3573" PostTypeId="2" ParentId="3572" CreationDate="2015-06-12T17:12:51.457" Score="2" Body="&lt;p&gt;I think that  the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=848&quot; rel=&quot;nofollow&quot;&gt;SrchRplcHiGrp.vim plugin&lt;/a&gt; might be what you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can install it with your favorite method. For example with Vundle just put this line in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'vim-scripts/SrchRplcHiGrp.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can select the highlighting group you want to work with by placing your cursor on the comment and running &lt;code&gt;:SRChooseHiGrp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can use &lt;code&gt;:SRHiGrp&lt;/code&gt; to replace the members of the higlighting group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll find the documentation on the page linked at the beggining of my answer.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-06-12T17:33:45.027" LastActivityDate="2015-06-12T17:33:45.027" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3574" PostTypeId="1" AcceptedAnswerId="3635" CreationDate="2015-06-12T19:07:51.263" Score="5" ViewCount="837" Body="&lt;p&gt;I want  to map a key to the system command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`tmux set-buffer $var`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where $var is the value of @0 register. &#xA;How do i insert the @0 value into the map command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;t :!tmux set-buffer @0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2277" LastEditorUserId="1577" LastEditDate="2015-06-14T18:38:23.177" LastActivityDate="2015-06-18T13:13:12.577" Title="How to use the value of a register in a key mapping?" Tags="|key-bindings|vimrc|bash|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3576" PostTypeId="1" AcceptedAnswerId="10041" CreationDate="2015-06-13T11:31:10.473" Score="17" ViewCount="36065" Body="&lt;p&gt;I don't have a full understanding of how my color scheme is interacting with the &lt;code&gt;term&lt;/code&gt; setting in vim and this is impeding my ability to get it to display correctly in neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my .vimrc file, correct behavior of the color scheme in question requires setting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set term=xterm&#xA;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Omitting either of those settings results in incorrect display of the color scheme:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;correct&lt;/em&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/DTNll.png&quot; alt=&quot;Correct Color Display&quot;&gt;&#xA;&lt;em&gt;incorrect&lt;/em&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/zdpYg.png&quot; alt=&quot;Incorrect Color Display&quot;&gt;&#xA;&lt;em&gt;different incorrect&lt;/em&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/6bEJ5.png&quot; alt=&quot;Different Incorrect Color Display&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The scheme looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=dark&#xA;hi clear&#xA;if exists(&quot;syntax_on&quot;)&#xA;    syntax reset&#xA;endif&#xA;let g:colors_name=&quot;impact3&quot;&#xA;&#xA;if exists(&quot;g:impact_transbg&quot;)&#xA;    hi Normal       ctermfg=255 ctermbg=none&#xA;    hi NonText      ctermfg=DarkGray  ctermbg=none&#xA;&#xA;    hi Statement    ctermfg=Blue      ctermbg=none&#xA;    hi Comment      ctermfg=DarkGray  ctermbg=none cterm=bold term=bold&#xA;    hi Constant     ctermfg=173  ctermbg=none&#xA;    hi Identifier   ctermfg=Cyan      ctermbg=none&#xA;    hi Type         ctermfg=DarkGreen ctermbg=none&#xA;    hi Folded       ctermfg=0 ctermbg=235 cterm=underline term=none&#xA;    hi Special      ctermfg=Blue      ctermbg=none&#xA;    hi PreProc      ctermfg=LightGray ctermbg=none cterm=bold term=bold&#xA;    hi Scrollbar    ctermfg=Blue      ctermbg=none&#xA;    hi Cursor       ctermfg=white     ctermbg=none&#xA;    hi ErrorMsg     ctermfg=Red       ctermbg=none cterm=bold term=bold&#xA;    hi WarningMsg   ctermfg=Yellow    ctermbg=none&#xA;    hi VertSplit    ctermfg=0     ctermbg=0&#xA;    hi Directory    ctermfg=Cyan      ctermbg=DarkBlue&#xA;    hi Visual       ctermfg=White     ctermbg=Gray cterm=underline term=none&#xA;    hi Title        ctermfg=255     ctermbg=Blue&#xA;    hi String       ctermfg=Blue   ctermbg=none&#xA;&#xA;    hi StatusLine   term=bold cterm=bold,underline ctermfg=White ctermbg=Black&#xA;    hi StatusLineNC term=bold cterm=bold,underline ctermfg=Gray  ctermbg=Black&#xA;    hi LineNr       term=bold cterm=bold ctermfg=2 ctermbg=None&#xA;    hi Search       ctermfg=Black ctermbg=2&#xA;    hi TabLine      ctermfg=0 ctermbg=DarkGray&#xA;    hi TabLineFill  ctermfg=DarkGray ctermbg=DarkGray&#xA;else&#xA;    hi Normal       ctermfg=White ctermbg=Black&#xA;    hi NonText      ctermfg=DarkGray  ctermbg=Black&#xA;&#xA;    hi Statement    ctermfg=Blue      ctermbg=Black&#xA;    hi Comment      ctermfg=DarkGray  ctermbg=Black cterm=bold term=bold&#xA;    hi Constant     ctermfg=DarkCyan  ctermbg=Black&#xA;    hi Identifier   ctermfg=Cyan      ctermbg=Black&#xA;    hi Type         ctermfg=DarkGreen ctermbg=Black&#xA;    hi Folded       ctermfg=DarkGreen ctermbg=Black cterm=underline term=none&#xA;    hi Special      ctermfg=Blue      ctermbg=Black&#xA;    hi PreProc      ctermfg=LightGray ctermbg=Black cterm=bold term=bold&#xA;    hi Scrollbar    ctermfg=Blue      ctermbg=Black&#xA;    hi Cursor       ctermfg=white     ctermbg=Black&#xA;    hi ErrorMsg     ctermfg=Red       ctermbg=Black cterm=bold term=bold&#xA;    hi WarningMsg   ctermfg=Yellow    ctermbg=Black&#xA;    hi VertSplit    ctermfg=White     ctermbg=Black&#xA;    hi Directory    ctermfg=Cyan      ctermbg=DarkBlue&#xA;    hi Visual       ctermfg=White     ctermbg=DarkGray cterm=underline term=none&#xA;    hi Title        ctermfg=White     ctermbg=DarkBlue&#xA;&#xA;    hi StatusLine   term=bold cterm=bold,underline ctermfg=White ctermbg=Black&#xA;    hi StatusLineNC term=bold cterm=bold,underline ctermfg=Gray  ctermbg=Black&#xA;    hi LineNr       term=bold cterm=bold ctermfg=White ctermbg=Black&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In neovim, &lt;code&gt;term&lt;/code&gt; cannot be set. I tried invoking neovim with a manually set $TERM like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TERM=xterm nvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This produced the correct display of colors in regular vim (i.e. equivalent to setting term in .vimrc), but in neovim it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Kz7IT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why is the combination of &lt;code&gt;set term=xterm&lt;/code&gt; and &lt;code&gt;set t_Co=256&lt;/code&gt; necessary to produce the correct display of this color scheme in vim and why does the equivalent combination of settings produce a different result in neovim?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The default is&lt;/em&gt; &lt;code&gt;$TERM=xterm256-color&lt;/code&gt;, &lt;em&gt;which for some reason has to be overridden to &lt;code&gt;xterm&lt;/code&gt; in regular vim to make the color display correctly. With the environment variable at the 256 default, neovim looks like this:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1nfki.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;This is identical to regular vim with &lt;code&gt;xterm256-color&lt;/code&gt;, but not as intended. My goal is to understand why the xterm hack is necessary/working in vim, and why it doesn't look the same in neovim.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note that many of the colors appear correctly with the above term env variable setting, notable exceptions being line numbers and background. I suspect that the way the colors are specified in this specific color scheme may be involved.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="783" LastEditorUserId="783" LastEditDate="2015-06-13T23:07:19.387" LastActivityDate="2018-09-18T12:55:52.873" Title="Trouble Using Color Scheme in NeoVim" Tags="|colorscheme|neovim|iterm2|" AnswerCount="8" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3577" PostTypeId="2" ParentId="3576" CreationDate="2015-06-13T13:52:54.380" Score="0" Body="&lt;p&gt;Try setting your &lt;code&gt;$TERM&lt;/code&gt;environment variable like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TERM=xterm-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also try starting nvim like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export TERM=xterm-256color; nvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If that works, set the &lt;code&gt;$TERM&lt;/code&gt; variable in your shell permanently.&lt;/p&gt;&#xA;" OwnerUserId="2460" LastEditorUserId="1841" LastEditDate="2015-06-14T02:46:22.150" LastActivityDate="2015-06-14T02:46:22.150" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3578" PostTypeId="2" ParentId="3576" CreationDate="2015-06-13T15:22:30.763" Score="2" Body="&lt;p&gt;I see you use iTerm2, so you can try this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open prefernces window &lt;kbd&gt;⌘&lt;/kbd&gt;+&lt;kbd&gt;,&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Go to &lt;code&gt;profiles&lt;/code&gt; tab&lt;/li&gt;&#xA;&lt;li&gt;Check your current profile in the left list&lt;/li&gt;&#xA;&lt;li&gt;Click on the tab &lt;code&gt;terminal&lt;/code&gt; at right&lt;/li&gt;&#xA;&lt;li&gt;In the &lt;code&gt;Report terminal type&lt;/code&gt; choose &lt;code&gt;xterm-256color&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Done.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="500" LastActivityDate="2015-06-13T15:22:30.763" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3579" PostTypeId="1" AcceptedAnswerId="3582" CreationDate="2015-06-13T18:10:18.930" Score="1" ViewCount="227" Body="&lt;p&gt;I added a few lines to my .vimrc to autoclose tags like&#xA;&lt;code&gt;[]&lt;/code&gt;, &lt;code&gt;&quot;&quot;&lt;/code&gt;, &lt;code&gt;''&lt;/code&gt;, &lt;code&gt;()&lt;/code&gt;&#xA;these all work fine but somehow the autoclosing of &lt;code&gt;{}&lt;/code&gt; adds a space in between them and I have no idea how this comes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;auto complete brackets&#xA;33 inoremap { {}&amp;lt;Esc&amp;gt;i                                                                                                                          &#xA;34 inoremap [ []&amp;lt;Esc&amp;gt;i&#xA;35 inoremap ( ()&amp;lt;Esc&amp;gt;i&#xA;36 inoremap &quot; &quot;&quot;&amp;lt;Esc&amp;gt;i&#xA;37 inoremap ' ''&amp;lt;Esc&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Anyone has an idea? Ask if you think it's handy for me to post the rest of my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="2464" LastEditorUserId="1841" LastEditDate="2015-06-14T02:45:56.220" LastActivityDate="2015-06-14T07:51:13.140" Title="making vim autoclose {} tags adds a space" Tags="|tags|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3580" PostTypeId="1" AcceptedAnswerId="3581" CreationDate="2015-06-13T18:54:33.747" Score="14" ViewCount="15276" Body="&lt;p&gt;I use Kubuntu 14.04 with its default installation (bash, Konsole).  I want to learn a powerful, all-keyboard, text editor, and settled on one of these: Vi, Vim, Emacs, (and I'll learn Nano since it's simple).  I have a little experience with the command line: Bash and Python, so I'm ready to add another skill in my pursuit of using Linux without a Windows system. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From Bash, Typing &lt;code&gt;vim&lt;/code&gt; or &lt;code&gt;emacs&lt;/code&gt; prompt me to install packages.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;vi&lt;/code&gt; works.  It runs an editor, So I thought it must be Vi. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the splash screen, if you call it that in Bash, says &lt;code&gt;VIM Vi Improved&lt;/code&gt; and that it's &lt;code&gt;Running in Vi compatible mode&lt;/code&gt;. So now I figure it must be Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So which is it and why does typing &lt;code&gt;vim&lt;/code&gt; in bash not run my editor?&lt;/p&gt;&#xA;" OwnerUserId="2466" LastEditorUserId="205" LastEditDate="2015-06-15T10:54:36.293" LastActivityDate="2024-04-05T06:33:19.927" Title="How do I tell if Vi or Vim is installed on my Linux distribution?" Tags="|invocation|linux|version|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3581" PostTypeId="2" ParentId="3580" CreationDate="2015-06-13T21:03:38.697" Score="16" Body="&lt;p&gt;Vim started as a clone of vi and has almost all of the commands and features of the original vi, plus a lot of enhancements. (See &lt;code&gt;:help design-compatible&lt;/code&gt;.) It can be compiled into one of basically five configurations: tiny, small, normal, big and huge. (See &lt;code&gt;:help :version&lt;/code&gt;.) It can also be configured at run time to disable the extended features and use only those features found in the original vi. (See &lt;code&gt;:help 'compatible'&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since it can be made to behave very closely to the original vi, many Linux distributions include it as their &lt;code&gt;vi&lt;/code&gt;, the basic visual editor found on almost all Unix systems. When you run &lt;code&gt;vi&lt;/code&gt;, you usually get either the tiny or small version of Vim running in vi-compatible mode. That is why you get the Vim splash screen when you run &lt;code&gt;vi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This vi, though, is not the full-featured Vim that most users want for regular use. Most Linux distributions offer that version of vim, often the huge version, in an optional package such as &lt;code&gt;vim&lt;/code&gt; or &lt;code&gt;vim-enhanced&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-06-13T21:03:38.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3582" PostTypeId="2" ParentId="3579" CreationDate="2015-06-14T00:17:27.457" Score="1" Body="&lt;p&gt;It is possible that it comes from a trailing space at the end of the line 33 of your &lt;code&gt;.vimrc&lt;/code&gt;. If a space is present after the last &lt;code&gt;i&lt;/code&gt; character of your line, vim will interpret it literally and add it between your curly brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you might be interested in the &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow&quot;&gt;auto-pair&lt;/a&gt; plugin: it automatically insert matching characters and it also handle smarly the deletion of those characters.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-06-14T07:51:13.140" LastActivityDate="2015-06-14T07:51:13.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3583" PostTypeId="1" CreationDate="2015-06-14T01:40:48.733" Score="9" ViewCount="189" Body="&lt;p&gt;It doesn't happen as often as you'd think, but it happens occasionally, and I don't even own a cat. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically if you mash the number row or numpad and then happen to hit a keycombo that triggers a repeatable command, it is possible to inadvertently command Vim to perform a task several thousand, million, or even billion times. This easily gets out of control and may result in data loss. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I wonder if there is a configuration or something in the source code we can change to serve as a sanity check to prevent this sort of DoS. &lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="1841" LastEditDate="2015-08-14T13:11:08.170" LastActivityDate="2015-11-12T14:21:37.567" Title="How can I prevent (or at least prompt to confirm) absurdly large numbers from being used to prefix commands?" Tags="|normal-mode|repeated-commands|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3584" PostTypeId="2" ParentId="3576" CreationDate="2015-06-14T05:25:24.883" Score="7" Body="&lt;p&gt;In the case of Neovim, &lt;code&gt;t_Co&lt;/code&gt; and &lt;code&gt;TERM&lt;/code&gt; make no difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are calling &lt;code&gt;set background=dark&lt;/code&gt;before &lt;em&gt;and&lt;/em&gt; after the call to &lt;code&gt;colorscheme impact3&lt;/code&gt;. Move &lt;code&gt;set background=dark&lt;/code&gt; to the bottom of the colorscheme, and &lt;em&gt;remove&lt;/em&gt; the other call from your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help 'background'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When 'background' is set Vim will adjust the default color &#xA;groups for the new value.&#xA;...&#xA;When a color scheme is loaded (the &quot;g:colors_name&quot; variable &#xA;is set) setting 'background' will cause the color scheme to &#xA;be reloaded.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;a href=&quot;https://github.com/justinmk/molokai/commit/aa1cc201c743dd7d1b80bb2e2b5fbb7894ebfe5f&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/justinmk/molokai/commit/aa1cc201c743dd7d1b80bb2e2b5fbb7894ebfe5f&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My goal is to understand why the xterm hack is necessary/working in vim, and why it doesn't look the same in neovim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Neovim doesn't care about &lt;code&gt;t_Co&lt;/code&gt; because it assumes 256 unless you &lt;a href=&quot;https://github.com/neovim/neovim/wiki/FAQ#how-can-i-use-true-color-in-the-terminal&quot; rel=&quot;nofollow noreferrer&quot;&gt;enable &quot;true color&quot;&lt;/a&gt;.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In fact Neovim ignores all &lt;code&gt;t_*&lt;/code&gt; options, see &lt;code&gt;:help t_xx&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Neovim doesn't allow &lt;code&gt;&amp;amp;term&lt;/code&gt; to be set because it is meaningless. Neovim uses &lt;a href=&quot;https://github.com/mauke/unibilium&quot; rel=&quot;nofollow noreferrer&quot;&gt;unibilium&lt;/a&gt; and other mechanisms to detect terminal capabilities.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="578" LastEditorUserId="578" LastEditDate="2018-09-18T12:55:52.873" LastActivityDate="2018-09-18T12:55:52.873" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3585" PostTypeId="2" ParentId="3576" CreationDate="2015-06-14T11:40:14.777" Score="2" Body="&lt;p&gt;You're missing an awesome NeoVim feature. There's an env var that helps with this stuff. Try putting this in your nvimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $NVIM_TUI_ENABLE_TRUE_COLOR=1 &quot; True gui colors in terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export NVIM_TUI_ENABLE_TRUE_COLOR=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the shell.&lt;/p&gt;&#xA;" OwnerUserId="2471" LastActivityDate="2015-06-14T11:40:14.777" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3586" PostTypeId="2" ParentId="3580" CreationDate="2015-06-14T12:50:23.847" Score="10" Body="&lt;p&gt;Since you're on Ubuntu, verify if Vim is installed by running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dpkg -l | grep vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check the available alternatives to Vi by running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;update-alternatives --list vi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set your favorite alternative to Vi by running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;update-alternatives --config vi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2472" LastActivityDate="2015-06-14T12:50:23.847" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3587" PostTypeId="1" AcceptedAnswerId="3588" CreationDate="2015-06-14T13:31:22.650" Score="8" ViewCount="173" Body="&lt;p&gt;In his (very good) book &quot;Pratical Vim&quot; Drew Neil shows how to collect all the lines containing the word &quot;TODO&quot; into a register to use them latter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do so he simply use a global command: &lt;code&gt;:g/TODO/yank A&lt;/code&gt; (The capital &lt;code&gt;A&lt;/code&gt; allows to happen lines to the named register &lt;code&gt;a&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that's a pretty cool trick but I need to improve it: I'm trying to insert the number of the line before it's content. I think the solution would be to get the line number and use it in the last part of the command I mentioned before. The problem is that I don't know how to get this line number. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So my question is:&lt;/strong&gt; How in a global command can I get the number of the matched line and how can I use this number?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to be clear here is an example. Let's consider this file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1  //TODO: Hey this is a todo&#xA;2  int main(void){&#xA;3      //TODO: and this is another one&#xA;4      printf(&quot;Hello world&quot;);&#xA;5&#xA;6      return 0;&#xA;7  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I type &lt;code&gt;:g/TODO/yank A&lt;/code&gt; and I put the content of the register in a file I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//TODO: Hey this is a todo&#xA;    //TODO: and this is another one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I would like to get is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 //TODO: Hey this is a todo&#xA;3    //TODO: and this is another one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus&lt;/strong&gt; the yank also include the indentation of the line, it would be pretty cool if I could remove it directly from the global command.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-06-14T13:36:37.890" LastActivityDate="2015-06-14T14:05:24.640" Title="How to get and use the number of each matched line in a global command" Tags="|line-numbers|ex-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3588" PostTypeId="2" ParentId="3587" CreationDate="2015-06-14T13:44:06.510" Score="7" Body="&lt;p&gt;One way to do it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;clear the register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=''&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;append search results in it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/TODO/let @A = getpos('.')[1] . ' ' . getline('.') . &quot;\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Re: BONUS remove indentation in the global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    :g/TODO/let @A = getpos('.')[1] . ' ' . substitute(getline('.'), '^\s*', '', '') . &quot;\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-06-14T14:05:24.640" LastActivityDate="2015-06-14T14:05:24.640" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="3589" PostTypeId="2" ParentId="3583" CreationDate="2015-06-14T18:36:53.543" Score="2" Body="&lt;p&gt;I find that you are usually able to interrupt the repetition process by sending a SIGINT (&lt;kbd&gt;Ctrl+C&lt;/kbd&gt;). As long as some vimscript is not running a really long inner loop, there is no DoS concern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vi.stackexchange.com/questions/3182/is-it-possible-to-make-a-numerically-prefixed-hotkey-run-a-function-that-many-ti&quot;&gt;here&lt;/a&gt; for an example of a plugin may contain a function that loops depending on the entered number. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For almost all intents and purposes this issue here is a hypothetical one.&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-06-14T22:06:53.257" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3591" PostTypeId="2" ParentId="149" CreationDate="2015-06-14T20:09:27.933" Score="0" Body="&lt;p&gt;Another pager you may like to try is &lt;code&gt;most&lt;/code&gt;:&#xA;&lt;a href=&quot;http://www.jedsoft.org/most/&quot; rel=&quot;nofollow&quot;&gt;http://www.jedsoft.org/most/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, rotate your logs and as this may contribute to less larger logs.&lt;/p&gt;&#xA;" OwnerUserId="2475" LastActivityDate="2015-06-14T20:09:27.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3592" PostTypeId="1" AcceptedAnswerId="3596" CreationDate="2015-06-14T20:31:44.410" Score="6" ViewCount="100" Body="&lt;p&gt;Within vim you can fold away some data that doesn't pertain to what you're looking for at that moment. So I'd like to save that unfolded data to a separate file and look at it closer, but I don't know the correct/exact combinations to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know &lt;code&gt;:folddoopen .:w &amp;gt;&amp;gt; file.ext&lt;/code&gt; will appended the non-folded data to an existing file, so my temporary work around is just &lt;code&gt;touch file.ext&lt;/code&gt; before opening vi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:folddoopen :w &amp;gt; file.ext&lt;/code&gt; won't work as this writes the entire open file to the file and even loops through it over and over and over. Doing this in my case resulted in a 4.5GB file!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vim-lite on freeBSD: &lt;a href=&quot;https://www.freshports.org/editors/vim-lite/&quot;&gt;https://www.freshports.org/editors/vim-lite/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, is unfolded the correct term?&lt;/p&gt;&#xA;" OwnerUserId="2475" LastEditorUserId="24" LastEditDate="2015-06-14T23:17:53.580" LastActivityDate="2015-06-14T23:17:53.580" Title="save unfolded data to separate file" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3593" PostTypeId="2" ParentId="74" CreationDate="2015-06-14T20:36:53.783" Score="2" Body="&lt;p&gt;As others have indicated, vim has a swap file (.swp) that will be created where ever your original file is, but in your .vimrc file, you can set the .swp directory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need to create the directory with &lt;code&gt;mkdir&lt;/code&gt; and then set your .vimrc to that location.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set backup &quot; make backup files&#xA;set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2475" LastEditorUserId="2475" LastEditDate="2015-06-15T02:03:28.917" LastActivityDate="2015-06-15T02:03:28.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3594" PostTypeId="2" ParentId="3561" CreationDate="2015-06-14T21:27:05.123" Score="-1" Body="&lt;p&gt;Another option is to run &lt;code&gt;sudo -E vim somefile.conf&lt;/code&gt; to edit, which will preserve your environment, hence your &lt;code&gt;.vimrc&lt;/code&gt; and plugins will be used.&lt;/p&gt;&#xA;" OwnerUserId="2476" LastEditorUserId="2221" LastEditDate="2015-06-17T00:43:49.713" LastActivityDate="2015-06-17T00:43:49.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3595" PostTypeId="2" ParentId="2003" CreationDate="2015-06-14T21:51:37.103" Score="22" Body="&lt;p&gt;As already mentioned, first try &lt;code&gt;vim -u NONE -U NONE -N&lt;/code&gt; to make sure your vanilla vim is working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then start vim normally and check&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:messages&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from inside vim after the problem, which will show all warnings and errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally start vim with the following command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -V9logfile.log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will create a logfile called &lt;code&gt;logfile.log&lt;/code&gt;, &lt;code&gt;-V9&lt;/code&gt; is the logging level and try to reproduce your problem.&lt;/p&gt;&#xA;" OwnerUserId="2476" LastActivityDate="2015-06-14T21:51:37.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3596" PostTypeId="2" ParentId="3592" CreationDate="2015-06-14T22:34:27.450" Score="8" Body="&lt;p&gt;Use a &lt;code&gt;!&lt;/code&gt; to force the writing, even if the file doesn't exist:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:folddoopen .:w! &amp;gt;&amp;gt; file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-06-14T22:34:27.450" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3597" PostTypeId="2" ParentId="3576" CreationDate="2015-06-15T03:02:03.713" Score="1" Body="&lt;p&gt;Note that the specific color scheme is really two sets of color schemes within an if-else clause. The existence of the variable&lt;code&gt;g:impact_transbg&lt;/code&gt; selects the desired set of colors, and was originally intended to account for transparent backgrounds in the color scheme from which this is &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1326&quot; rel=&quot;nofollow&quot;&gt;derived&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Commenting out the 2nd color scheme and the if-else statement (leaving only the desired color scheme and doing away with &lt;code&gt;g:impact_transbg&lt;/code&gt;) yields the intended behavior in both vim and neovim even with &lt;code&gt;set term=xterm&lt;/code&gt; and &lt;code&gt;set t_Co=256&lt;/code&gt; removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This implies that with &lt;code&gt;$TERM=xterm-256colors&lt;/code&gt; in both vim and neovim, the conditional &lt;code&gt;if exists(&quot;g:impact_transbg&quot;)&lt;/code&gt; fails, but that the combination of setting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set term=xterm&#xA;set t_co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;allowed the conditional to succeed. &lt;strong&gt;Removing the if-else clause&lt;/strong&gt; as described above solves the material issue, but there's still a mystery regarding the interaction between the pair of .vimrc term settings and &lt;code&gt;g:impact_transbg&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="783" LastActivityDate="2015-06-15T03:02:03.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3598" PostTypeId="2" ParentId="3231" CreationDate="2015-06-15T07:52:58.660" Score="1" Body="&lt;p&gt;Besides the ex-mode commands that you've got you can achieve that also it in command mode, e.g. by: &lt;code&gt;4GY''&lt;/code&gt; - which means: goto line 4 (&lt;code&gt;4G&lt;/code&gt;), yank line (&lt;code&gt;Y&lt;/code&gt;), and return to previous line (&lt;code&gt;''&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use jump marks; for your second question, e.g. by: &lt;code&gt;mm3kY'm&lt;/code&gt; - which means: set mark m (&lt;code&gt;mm&lt;/code&gt;), go three lines up (&lt;code&gt;3k&lt;/code&gt;), yank line (&lt;code&gt;Y&lt;/code&gt;), return to mark m (&lt;code&gt;'m&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2015-06-15T07:52:58.660" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3599" PostTypeId="1" AcceptedAnswerId="3610" CreationDate="2015-06-15T08:22:51.187" Score="14" ViewCount="3566" Body="&lt;p&gt;As far as I understand the default &lt;code&gt;vimdiff&lt;/code&gt; is doing only line-wise diffs. However sometimes is useful to do word level diff, especially for text files like Markdown, LaTeX etc. There are some tools like &lt;code&gt;wdiff&lt;/code&gt; or &lt;code&gt;dwdiff&lt;/code&gt; which do the diff in word level.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to use them in Vim to compare side-by-side two text files?&lt;/p&gt;&#xA;" OwnerUserId="292" LastEditorUserId="23502" LastEditDate="2022-11-02T19:59:11.930" LastActivityDate="2022-11-02T19:59:11.930" Title="Word level diffs in Vim" Tags="|vimdiff|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3600" PostTypeId="1" AcceptedAnswerId="3601" CreationDate="2015-06-16T02:50:40.507" Score="1" ViewCount="790" Body="&lt;p&gt;I know I can execute the current file, lets say a bash file, with &lt;code&gt;:! bash %&lt;/code&gt;.&#xA;But what can I do if I want to execute the current file in a different directory (such as the location of the current file) than the current vim working directory. &#xA;I know that I could change to the working directory of the current file by &lt;code&gt;:cd %:p:h&lt;/code&gt; and then execute the file but then I would need to jump back again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would really appreciate any help. &lt;/p&gt;&#xA;" OwnerUserId="436" LastEditorUserId="436" LastEditDate="2015-06-16T03:17:49.737" LastActivityDate="2019-01-17T22:39:08.490" Title="Execute current file outside of working directory" Tags="|working-directory|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3601" PostTypeId="2" ParentId="3600" CreationDate="2015-06-16T07:05:19.523" Score="1" Body="&lt;p&gt;There are various possibilities, but I think you'd either have to jump back (&lt;code&gt;cd -&lt;/code&gt;), or execute the command in a subshell; e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! cd somedir; bash ~-/% ; cd -&#xA;&#xA;:! bash -c 'cd somedir ; bash ~-/%'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2015-06-16T07:05:19.523" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3602" PostTypeId="2" ParentId="3561" CreationDate="2015-06-16T08:08:42.637" Score="1" Body="&lt;p&gt;If you know ahead of time that you need to be editing a file as root, using the commands &lt;code&gt;sudoedit &amp;lt;file&amp;gt;&lt;/code&gt; or &lt;code&gt;sudo -e &amp;lt;file&amp;gt;&lt;/code&gt; will get you setup in a special environment for doing so with your usual editor preferences. A copy of the file is made and your editor is launched to edit it (as your user). When you exit the file is copied back to it's original location as root.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is the safest and recommended way, but in the event that a) you don't realize ahead of time you will need to write as root or b) want to edit and save incremental changes in-place, you will need something else. To this end the solution using &lt;code&gt;sudo tee&lt;/code&gt; &lt;a href=&quot;https://vi.stackexchange.com/a/3566/267&quot;&gt;proposed by smpl&lt;/a&gt; is definitely on the right track, but there are some minor improvements that can be made to handle edge cases. Notably the difference in handling the sudo password prompt in a GUI vs. console interfaces is worth some attention.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An easier way to set this up is to use the &lt;a href=&quot;https://github.com/tpope/vim-eunuch&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-eunuch&lt;/a&gt; plugin. It has this particular issue and a few other handy things rolled up into a handy package. Usage is as simple as calling &lt;code&gt;:SudoWrite&lt;/code&gt;. I even use a slightly handier access mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmap w!! call SudoWrite()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should get you the ability to write a any file as root using &lt;code&gt;:w!!&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-06-16T08:14:39.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3603" PostTypeId="1" CreationDate="2015-06-16T09:22:09.423" Score="8" ViewCount="408" Body="&lt;p&gt;If I set a custom &lt;code&gt;make&lt;/code&gt; program, is there any way to provide a list of tab completion options that would get activated when I type &lt;code&gt;:make&lt;/code&gt;+&lt;kbd&gt;Space&lt;/kbd&gt;+&lt;kbd&gt;Tab&lt;/kbd&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With custom commands I can do f.i.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* -complete=customlist,MakeComplete -bar MakeGitbook call MakeGitbook(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any similar mechanism for builtin commands, and in particular for &lt;code&gt;:make&lt;/code&gt;?  Or should I just define a custom command wrapper that calls the built in one but also adds tab completion?&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="1577" LastEditDate="2015-06-16T11:28:43.733" LastActivityDate="2016-01-18T14:26:54.980" Title="Autocomplete for make" Tags="|command-line|autocompletion|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3604" PostTypeId="1" CreationDate="2015-06-16T12:30:15.337" Score="2" ViewCount="228" Body="&lt;p&gt;I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;e.printStackTrace();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the block cursor over the semicolon, what is the easiest way to delete that and end up with the cursor where the first &lt;code&gt;e&lt;/code&gt; is?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;dd&lt;/code&gt; for deleting the line is out, I guess &lt;code&gt;ciw&lt;/code&gt; would only delete the &lt;code&gt;();&lt;/code&gt; part of the line, or I could press &lt;code&gt;v&lt;/code&gt; to highlight go to the beginning of the line using &lt;code&gt;^&lt;/code&gt; and then pressing &lt;code&gt;d&lt;/code&gt; to delete the highlighted part, then into insert mode and then to tab in to the right indent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is quite a lot of keys which I don't particularly mind, but I am not sure whether I am thinking in a Vim like manner...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions / eye openers / mind openers would be really useful and appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2488" LastEditorUserId="51" LastEditDate="2015-06-16T12:44:55.730" LastActivityDate="2015-07-13T10:05:27.737" Title="Easiest way to delete e.printStackTrace();" Tags="|key-bindings|visual-mode|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3605" PostTypeId="2" ParentId="3604" CreationDate="2015-06-16T13:31:15.410" Score="4" Body="&lt;p&gt;I'm not sure that is the optimal way, but I'd basically do: &lt;code&gt;dB&lt;/code&gt;. That will keep the &lt;code&gt;;&lt;/code&gt;, so that depending on whether I want to instantly continue adding new text at the place of the replacement or just also remove the &lt;code&gt;;&lt;/code&gt; while staying in command mode I'd do one of: &lt;code&gt;dBx&lt;/code&gt; or &lt;code&gt;dBs&lt;/code&gt;. In visual mode that would be one of: &lt;code&gt;vBd&lt;/code&gt; or &lt;code&gt;vBs&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2015-06-16T13:31:15.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3606" PostTypeId="2" ParentId="3604" CreationDate="2015-06-16T14:57:42.083" Score="2" Body="&lt;p&gt;&lt;code&gt;dB&lt;/code&gt; deletes to the &lt;strong&gt;b&lt;/strong&gt;eginning of the word (whitespace-separated words, since it's a capital &lt;code&gt;B&lt;/code&gt;), but that excludes the current character, so to remove the &lt;code&gt;;&lt;/code&gt; as well you'll need &lt;code&gt;dBx&lt;/code&gt;, or &lt;code&gt;dBs&lt;/code&gt; to go to insert mode immediately. Or you can use an inclusive motion, but again with a whitespace-sparated word: &lt;code&gt;diW&lt;/code&gt;, or &lt;code&gt;ciW&lt;/code&gt; to go to insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, move back then delete: &lt;code&gt;BdW&lt;/code&gt; or &lt;code&gt;BcW&lt;/code&gt;. If there was additional stuff on the line after the semicolon, that would delete everything up to the end of the next sequence of whitespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you consider the text to delete to be everything except the indentation, rather than just the current word, then you would need &lt;code&gt;cv^&lt;/code&gt; (&lt;code&gt;c^&lt;/code&gt; is transformed into a linewise command, so deletes the indendation as well; &lt;code&gt;v&lt;/code&gt; makes it characterwise). Unfortunately &lt;code&gt;^&lt;/code&gt; is exclusive, so the &lt;code&gt;;&lt;/code&gt; stays behind. But in this case moving then deleting is shorter anyway: &lt;code&gt;^D&lt;/code&gt; or &lt;code&gt;^C&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2015-06-16T14:57:42.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3607" PostTypeId="1" AcceptedAnswerId="3608" CreationDate="2015-06-16T15:04:04.717" Score="6" ViewCount="387" Body="&lt;p&gt;I like using &lt;kbd&gt;Ctrl-f&lt;/kbd&gt; and &lt;kbd&gt;Ctrl-b&lt;/kbd&gt; to &quot;page-up&quot; and &quot;page-down&quot;, but I was wondering if there was a way to do that without losing my current position in a row? For example, I like to work with tab-delimited files and scroll up and down columns.&lt;/p&gt;&#xA;" OwnerUserId="1111" LastEditorUserId="343" LastEditDate="2015-06-17T08:53:43.200" LastActivityDate="2015-06-17T08:53:43.200" Title="How can I advance a page without losing my column position?" Tags="|cursor-movement|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3608" PostTypeId="2" ParentId="3607" CreationDate="2015-06-16T15:14:03.940" Score="9" Body="&lt;p&gt;Simply add &lt;code&gt;set nostartofline&lt;/code&gt; to your &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'startofline'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-06-16T15:14:03.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3609" PostTypeId="2" ParentId="3604" CreationDate="2015-06-16T15:52:13.663" Score="5" Body="&lt;p&gt;Probably the best thing you can do in this case is use &lt;code&gt;cc&lt;/code&gt;/&lt;code&gt;S&lt;/code&gt; and just retype the &lt;code&gt;e&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Se&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However as you look like you are using a language that uses &lt;code&gt;;&lt;/code&gt; as endings and &lt;code&gt;.&lt;/code&gt;'s, then you probably just want to do something like &lt;code&gt;cT.&lt;/code&gt; to make your changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion it is probably not worth optimizing your keystrokes to save typing one character of text on a line. Best to just clear the line and start over.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-06-16T16:20:30.370" LastActivityDate="2015-06-16T16:20:30.370" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3610" PostTypeId="2" ParentId="3599" CreationDate="2015-06-16T17:38:49.233" Score="7" Body="&lt;p&gt;One solution, as suggested by &lt;a href=&quot;https://vi.stackexchange.com/users/205/muru&quot;&gt;muru&lt;/a&gt; (thanks), is to use the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4932&quot; rel=&quot;nofollow noreferrer&quot;&gt;diffchar.vim&lt;/a&gt; plugin and setting the &lt;code&gt;let g:DiffUnit=&quot;Word1&quot;&lt;/code&gt;. This plugin should be used in the standard &lt;code&gt;vimdiff&lt;/code&gt; session.&lt;/p&gt;&#xA;" OwnerUserId="292" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-06-16T17:38:49.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3611" PostTypeId="2" ParentId="3604" CreationDate="2015-06-16T22:11:26.647" Score="2" Body="&lt;p&gt;In this particular case I would do it with 2 keystrokes: &lt;code&gt;^C&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; Allows you to go back to the first non white character (which is the &quot;e&quot; in your case).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C&lt;/code&gt; Triggers the &lt;code&gt;change&lt;/code&gt; command from the cursor to the end of the line. It is the equivalent to &lt;code&gt;c$&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This way you keep the indentation, and you only need one key to delete the content and switch to insert mode.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-06-16T22:11:26.647" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3612" PostTypeId="1" AcceptedAnswerId="3614" CreationDate="2015-06-17T06:35:22.040" Score="11" ViewCount="2236" Body="&lt;p&gt;Vim keeps unindenting the lines I want to keep indented if I don't write anything on them... I'll give an example, where the | is the caret.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Caret is indented and I press enter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if expression:&#xA;    print(&quot;hello world&quot;)&#xA;    |&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Caret is indented on the next line, and now I press the up arrow&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if expression:&#xA;    print(&quot;hello world&quot;)&#xA;&#xA;    |&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now the caret isn't indented anymore, what happened?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if expression:&#xA;    print(&quot;hello world&quot;)&#xA;|&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So how do I keep the indent?&lt;/p&gt;&#xA;" OwnerUserId="2497" LastActivityDate="2015-06-17T08:41:15.060" Title="How do I prevent Vim from unindenting empty lines?" Tags="|vimrc|indentation|gvim|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3613" PostTypeId="2" ParentId="3612" CreationDate="2015-06-17T07:45:12.490" Score="4" Body="&lt;p&gt;To keep the indent ... write something on that line, before moving to other lines! Otherwise, since you are a good Vim user and stay mostly in normal mode (right?), when you have to write something on that line, just go there and press &lt;code&gt;S&lt;/code&gt; - you'll find yourself at the correct indent level and ready to type. Vim does this to avoid useless ('trailing') tabs/spaces on empty lines.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-06-17T07:45:12.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3614" PostTypeId="2" ParentId="3612" CreationDate="2015-06-17T08:41:15.060" Score="4" Body="&lt;p&gt;What you're seeing is the normal behavior of &lt;code&gt;'autoindent'&lt;/code&gt; which the Python indent plugin uses. See &lt;code&gt;:help 'ai'&lt;/code&gt;. You can watch what happens to the indent as you type by executing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no way that I know of to make Vim automatically preserve your indent in the case you describe. Setting the &lt;code&gt;I&lt;/code&gt; flag of &lt;code&gt;'cpoptions'&lt;/code&gt; doesn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can work around this problem by using the following mapping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;cr&amp;gt; &amp;lt;space&amp;gt;&amp;lt;bs&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will cause Vim to leave an indentation of spaces when you type &lt;code&gt;Enter&lt;/code&gt; on an empty line. I don't recommend doing that as it will leave your file cluttered with unnecessary spaces until you remove them with something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\s\+$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;before saving the file, but you may find that less annoying than the normal indent behavior.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-06-17T08:41:15.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3615" PostTypeId="1" AcceptedAnswerId="3617" CreationDate="2015-06-17T09:29:39.247" Score="3" ViewCount="133" Body="&lt;p&gt;If I have the folowing file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;XX:YY:ZZ foobar: some text&#xA;XX:YY:ZZ foobar: some other text&#xA;a text breaking the pattern&#xA;XX:YY:ZZ foobar: some more text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to operate on the differents parts &lt;code&gt;XX:YY:ZZ foobar:&lt;/code&gt; of the lines. When I am on the first line I can select the text that I want with, for example, &lt;code&gt;v3f:&lt;/code&gt;. Now when I am on the second or on the last line how can I select this same text without type once again &lt;code&gt;v3f:&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I insist on the fact that I need to select the texts sequentially and not all the occurences at the same time.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the command &lt;code&gt;gv&lt;/code&gt; which allows to re-select the last selected area but in my case it will select the 16 first characters of the first line which is not what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To sum it up&lt;/strong&gt; How can I execute again the last selection command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Also I wasn't sure about the tags I should use for this question don't hesitate to edit/suggest the right ones to use)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-06-17T13:05:50.487" Title="How to select with the same movement but on a different line" Tags="|cursor-movement|search|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3616" PostTypeId="2" ParentId="3615" CreationDate="2015-06-17T09:35:49.693" Score="3" Body="&lt;p&gt;I think the 'vim way' does not rely on using the visual mode to do something with the selection, but the other way around: do something on the &lt;code&gt;3f:&lt;/code&gt; - in your case: e.g. &lt;code&gt;d3f:&lt;/code&gt;. If you do the latter, you can move on the line you want and simply press &lt;code&gt;.&lt;/code&gt; to repeat that operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer strictly to your question, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm v3f:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm ^v3f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from the command line, and repeat that on any line you want, with &lt;code&gt;@:&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-06-17T09:35:49.693" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3617" PostTypeId="2" ParentId="3615" CreationDate="2015-06-17T10:39:32.077" Score="2" Body="&lt;p&gt;You could simply create a quick mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;key&amp;gt; 0v3f:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or use a macro recording:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq&#xA;0v3f:&#xA;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is another method, lifted from the &quot;experimental&quot; part of my config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetVisualSelection()&#xA;  let old_reg = @v&#xA;  normal! gv&quot;vy&#xA;  let raw_search = @v&#xA;  let @v = old_reg&#xA;  return substitute(escape(raw_search, '\/.*$^~[]'), &quot;\n&quot;, '\\n', &quot;g&quot;)&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;key&amp;gt; *``gn&amp;lt;C-g&amp;gt;&#xA;inoremap &amp;lt;key&amp;gt; &amp;lt;C-o&amp;gt;gn&amp;lt;C-g&amp;gt;&#xA;xnoremap &amp;lt;key&amp;gt; &amp;lt;Esc&amp;gt;:let @/ = GetVisualSelection()&amp;lt;CR&amp;gt;gn&amp;lt;C-g&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Select your text with &lt;code&gt;v3f:&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;&amp;lt;key&amp;gt;&lt;/code&gt; to enter insert mode.&lt;/li&gt;&#xA;&lt;li&gt;Edit the selection directly.&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;&amp;lt;key&amp;gt;&lt;/code&gt; again to jump to the next match.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;GOTO 3&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;--- edit ---&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;GetVisualSelection()&lt;/code&gt; returns a representation of the selected text suitable for use as a search pattern (escaped slashes and so on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The normal mode mapping jumps to the next occurrence of the word under the cursor (with &lt;code&gt;*&lt;/code&gt;), comes back (with ``), selects the last search (with &lt;code&gt;gn&lt;/code&gt;, here it is the word under the cursor) and switches to select mode (&lt;code&gt;&amp;lt;C-&amp;gt;g&lt;/code&gt;) to allow us to type right away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The insert mode mapping temporarily jumps out of insert mode (with &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;) to jump to and select the next occurrence (with &lt;code&gt;gn&lt;/code&gt;) and switches to select mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The visual mode mapping has the same function as the normal mode mapping but it is implemented differently: it goes out of visual mode (with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;), places a &quot;prepared&quot; representation of the selected text in the search register (with &lt;code&gt;:let @/ = GetVisualSelection()&amp;lt;CR&amp;gt;&lt;/code&gt;), jumps to and select the next occurrence (with &lt;code&gt;gn&lt;/code&gt;) and switches to select mode (with &lt;code&gt;&amp;lt;C-g&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--- endedit ---&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-06-17T13:05:50.487" LastActivityDate="2015-06-17T13:05:50.487" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3618" PostTypeId="1" AcceptedAnswerId="3619" CreationDate="2015-06-17T14:49:42.603" Score="1" ViewCount="171" Body="&lt;p&gt;I have a modeline in a file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: set filetype=sshconfig :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets &lt;code&gt;filetype&lt;/code&gt; correctly in vim, but when opening the file in vimdiff, the filetype is set to &lt;code&gt;conf&lt;/code&gt;. How can I tell vimdiff to read the modeline?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim 7.4.258 from MacPorts on Mac OS X.&lt;/p&gt;&#xA;" OwnerUserId="2500" LastEditorUserId="2500" LastEditDate="2015-06-17T18:58:58.987" LastActivityDate="2015-06-17T19:52:56.210" Title="Vimdiff does not read modeline" Tags="|vimdiff|modeline|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3619" PostTypeId="2" ParentId="3618" CreationDate="2015-06-17T19:52:56.210" Score="0" Body="&lt;p&gt;&lt;strong&gt;Tracked it down&lt;/strong&gt;&lt;br&gt;&#xA;I had installed &lt;a href=&quot;https://github.com/vim-scripts/diffchar.vim&quot; rel=&quot;nofollow&quot;&gt;vim-scripts/diffchar&lt;/a&gt; using Vundle, but it wasn't working so I commented it out and forgot about it. Running &lt;code&gt;:PluginClean&lt;/code&gt; did the trick.&lt;/p&gt;&#xA;" OwnerUserId="2500" LastActivityDate="2015-06-17T19:52:56.210" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3631" PostTypeId="1" CreationDate="2015-06-18T07:48:58.487" Score="3" ViewCount="149" Body="&lt;p&gt;I'm writing code in a language called choicescript, and it defines global variables like so: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*create &amp;lt;variable name&amp;gt; &amp;lt;initial value&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Global variables are defined only in a single file named startup.txt, and their scope is all files in the project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Local variables are defined like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*temp &amp;lt;variable name&amp;gt; &amp;lt;initial value&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Their scope is only the file in which they're defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples of variables being used in the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*temp str &quot;Dogs&quot;&#xA;*set str &quot;Cats&quot;&#xA;I like ${str} the most.&#xA;*if (str = &quot;Dogs&quot;)&#xA;    I like dogs the most.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Choicescript also has labels for the *goto command. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*if str = &quot;Dogs&quot;&#xA;    *goto dogs&#xA;&#xA;*label dogs&#xA;Some text about dogs here.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Scope of labels is the file in which they're defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like to be able to do is for Vim to maintain a list of variables and labels for autocompletion. How can I set this up?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the syntax file I created (which is still doesn't contain folding and is still a work in progress since my Vim experience is still noob level):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;b:current_syntax&quot;)&#xA;    finish&#xA;endif&#xA;&#xA;let b:current_syntax = &quot;choicescript&quot;&#xA;&#xA;setlocal iskeyword+=#&#xA;setlocal iskeyword+=*&#xA;&#xA;set breakindent&#xA;&#xA;syntax match csOption '#.*$'&#xA;&#xA;syntax keyword csCond *if *else *elseif *elsif *selectable_if &#xA;&#xA;syntax keyword csRare *delete *allow_reuse *goto_random_scene *share_this_game *link *more_games *print *script *check_achievements&#xA;&#xA;syntax keyword csGoto *ending *finish *gosub *gosub_scene *goto_scene *goto *gotoref *return&#xA;&#xA;syntax keyword csChoice *choice *fake_choice&#xA;&#xA;syntax keyword csReuse *disable_reuse *hide_reuse &#xA;&#xA;syntax keyword csSet *create *temp *set *setref &#xA;&#xA;syntax keyword csOther *input_text *input_number *image *line_break *page_break *rand *stat_chart *achieve *achievement&#xA;&#xA;syntax keyword csLabel *label &#xA;&#xA;syntax match csComment '^\s*\*comment.*$'&#xA;&#xA;hi def link csOption    Special&#xA;hi def link csCond  Statement&#xA;hi def link csRare  Todo    &#xA;hi def link csGoto  Constant&#xA;hi def link csChoice    Identifier&#xA;hi def link csReuse Type     &#xA;hi def link csSet   Keyword &#xA;hi def link csOther PreProc&#xA;hi def link csLabel     Function&#xA;hi def link csComment   Comment&#xA;&#xA;hi Comment guifg=green gui=italic&#xA;hi Identifier gui=bold &#xA;hi Constant gui=bold&#xA;hi Statement guifg=blue&#xA;hi Function guifg=orange gui=bold&#xA;hi Keyword guifg=maroon gui=bold&#xA;hi Special gui=bold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2511" LastActivityDate="2015-06-18T07:48:58.487" Title="How do I add autocompletion for variable names for a new language?" Tags="|autocompletion|" AnswerCount="0" CommentCount="2" ClosedDate="2017-01-02T07:29:06.003" ContentLicense="CC BY-SA 3.0" />
  <row Id="3632" PostTypeId="1" AcceptedAnswerId="3633" CreationDate="2015-06-18T09:31:08.863" Score="18" ViewCount="4525" Body="&lt;p&gt;I have in my &lt;code&gt;.vimrc&lt;/code&gt; some simple mappings to resize split windows easily:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Leader&amp;gt;&amp;lt;UP&amp;gt;    &amp;lt;C-w&amp;gt;+&#xA;noremap &amp;lt;Leader&amp;gt;&amp;lt;DOWN&amp;gt;  &amp;lt;C-w&amp;gt;-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That works pretty fine but for example, when I want to resize the window of 10 lines I have to press and release &lt;kbd&gt;Leader&lt;/kbd&gt;+&lt;kbd&gt;UP&lt;/kbd&gt; 10 times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I repeat this mapping while the keys are pressed?&lt;/strong&gt; What I want is when I press &lt;kbd&gt;Leader&lt;/kbd&gt;+&lt;kbd&gt;UP&lt;/kbd&gt; the mapping will be applied once then after a short duration it will be applied once again and so on while I hold the keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; I know it is possible to prefix &lt;code&gt;&amp;lt;C-w&amp;gt;+&lt;/code&gt; with a count and I could hardcode it in the mapping or simply input a count before using the mapping but that's not how I want to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note2:&lt;/em&gt; I also know that a popular mapping to resize windows is to use &lt;kbd&gt;+&lt;/kbd&gt; and &lt;kbd&gt;-&lt;/kbd&gt; keys which are easier to press several times but I don't want to use those keys to do that neither.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-07-20T08:45:48.243" LastActivityDate="2019-10-30T23:04:21.063" Title="How to repeat a mapping when keeping key pressed" Tags="|key-bindings|vim-windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3633" PostTypeId="2" ParentId="3632" CreationDate="2015-06-18T09:38:31.157" Score="19" Body="&lt;p&gt;You could try entering a ... Vim &lt;a href=&quot;https://github.com/kana/vim-submode&quot;&gt;submode&lt;/a&gt;! For your case, something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call submode#enter_with('grow/shrink', 'n', '', '&amp;lt;leader&amp;gt;&amp;lt;up&amp;gt;', '&amp;lt;C-w&amp;gt;+')&#xA;call submode#enter_with('grow/shrink', 'n', '', '&amp;lt;leader&amp;gt;&amp;lt;down&amp;gt;', '&amp;lt;C-w&amp;gt;-')&#xA;call submode#map('grow/shrink', 'n', '', '&amp;lt;down&amp;gt;', '&amp;lt;C-w&amp;gt;-')&#xA;call submode#map('grow/shrink', 'n', '', '&amp;lt;up&amp;gt;', '&amp;lt;C-w&amp;gt;+')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means, you enter the submode with &lt;code&gt;Leader-Up&lt;/code&gt; or &lt;code&gt;Leader-Down&lt;/code&gt; (which will also grow/shrink the window once) and then - you'll only have to press &lt;code&gt;Up&lt;/code&gt; or &lt;code&gt;Down&lt;/code&gt; to grow/shrink the window, until you exit the submode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also the help, for timeout issues, but, to disable it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;disable submode timeouts:&#xA;let g:submode_timeout = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... which means you'll stay in that submode indefinitely, until you press a key other than &lt;code&gt;Up&lt;/code&gt; or &lt;code&gt;Down&lt;/code&gt;, or until you hit &lt;code&gt;Esc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aaand, the next useful tip I'd recommend:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; don't consume submode-leaving key&#xA;let g:submode_keep_leaving_key = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... which allows you to move directly to your next commands, when pressing a different key. For instance, pressing &lt;code&gt;:&lt;/code&gt; will both leave the submode &lt;em&gt;and&lt;/em&gt; open the command line.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-06-18T11:40:31.810" LastActivityDate="2015-06-18T11:40:31.810" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3634" PostTypeId="1" CreationDate="2015-06-18T10:20:08.763" Score="1" ViewCount="829" Body="&lt;p&gt;Is it possible to get a list of all files in the buffer? And if so can we highlight all of them in NERDTree? &lt;/p&gt;&#xA;" OwnerUserId="2512" LastActivityDate="2015-06-18T10:20:08.763" Title="Highlight all files open in buffer in NERDTree" Tags="|plugin-nerdtree|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3635" PostTypeId="2" ParentId="3574" CreationDate="2015-06-18T13:13:12.577" Score="8" Body="&lt;p&gt;You can use &lt;code&gt;:execute {expr1}&lt;/code&gt; to execute a string from evaluation of &lt;code&gt;{expr1}&lt;/code&gt; as an Ex command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec &quot;!tmux set-buffer&quot; getreg(&quot;0&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will first combine the string &lt;code&gt;!tmux set-buffer&lt;/code&gt; with the results of &lt;code&gt;getreg(&quot;0&quot;)&lt;/code&gt;, adding a space in between, and then execute the resulting command. Presumably you want this only in normal mode, so it is advisable to use &lt;code&gt;nnoremap&lt;/code&gt; instead of &lt;code&gt;map&lt;/code&gt; as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mapping itself should be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;t :exec &quot;!tmux set-buffer&quot; getreg(&quot;0&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2015-06-18T13:13:12.577" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3636" PostTypeId="1" AcceptedAnswerId="3637" CreationDate="2015-06-18T14:18:36.593" Score="1" ViewCount="1307" Body="&lt;p&gt;I have set this &lt;code&gt;let g:ycm_key_invoke_completion = &quot;&amp;lt;c-q&amp;gt;&quot;&lt;/code&gt;, and then I can see the pop menu without parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I press Ctrl+q, the pop menu is the same one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can it complete a global function with parameters.&lt;/p&gt;&#xA;" OwnerUserId="2514" LastActivityDate="2015-06-18T17:03:16.133" Title="YouCompleteMe cannot complete C function with parameters" Tags="|plugin-you-complete-me|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3637" PostTypeId="2" ParentId="3636" CreationDate="2015-06-18T17:03:16.133" Score="1" Body="&lt;p&gt;Sounds like issues &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/issues/234&quot; rel=&quot;nofollow noreferrer&quot;&gt;294&lt;/a&gt; and &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/issues/1193&quot; rel=&quot;nofollow noreferrer&quot;&gt;1193&lt;/a&gt; on GitHub.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Valloric commented on Nov 18, 2014:&lt;/p&gt;&#xA;&lt;p&gt;This is on my TODO list, but I mostly don't have time for a large-scale feature like this. Sometimes I find some of it, but it's rare (every few months).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2500" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-06-18T17:03:16.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3638" PostTypeId="1" AcceptedAnswerId="3644" CreationDate="2015-06-19T12:37:06.823" Score="5" ViewCount="1171" Body="&lt;p&gt;I am using gvim 7.4 on Windows (32 bit) and using the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1191&quot;&gt;wc&lt;/a&gt; word-counting macro &lt;code&gt;:WC&lt;/code&gt; by jcline.  When I manually set a range and run the macro, e.g., &lt;code&gt;:'a,.WC&amp;lt;CR&amp;gt;&lt;/code&gt;, I get the expected &lt;code&gt;counted XXX words&lt;/code&gt; output.  &lt;code&gt;:WC&lt;/code&gt; produces this using &lt;code&gt;echo &quot;counted &quot; . wc_count . &quot; words&quot; . stop&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem: when I select text in visual mode and then run the macro with, e.g., &lt;code&gt;vap:WC&amp;lt;CR&amp;gt;&lt;/code&gt; (command line &lt;code&gt;'&amp;lt;,'&amp;gt;WC&lt;/code&gt;), the &quot;&lt;code&gt;counted&lt;/code&gt;&quot; output flickers for a moment and then disappears at the same time the visual highlighting disappears from the window.  Usually it is too fast for me to read the word count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question: Is there any way to leave the &lt;code&gt;echo&lt;/code&gt; output visible when existing visual mode so that I can use visual mode to select the text input to &lt;code&gt;:WC&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="205" LastEditDate="2015-06-20T12:18:55.557" LastActivityDate="2015-06-20T12:18:55.557" Title="How to prevent &quot;echo&quot; output from being overwritten when leaving visual mode?" Tags="|command-line|gvim|visual-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3640" PostTypeId="2" ParentId="3638" CreationDate="2015-06-19T12:44:59.913" Score="5" Body="&lt;p&gt;You can't prevent Vim from erasing the status line.  You can however make the output recallable, by changing &lt;code&gt;echo&lt;/code&gt; in the body of the plugin to &lt;code&gt;echomsg&lt;/code&gt;.  You'd then be able to recall the results with &lt;code&gt;:mes&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-06-19T12:44:59.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3641" PostTypeId="1" CreationDate="2015-06-19T14:08:27.907" Score="2" ViewCount="179" Body="&lt;p&gt;When I run vim in a win32 console window, after I exit I end up with a bunch of junk on the screen - old command output, etc, because cmd doesn't clear line contents when scrolling down. I've included an example below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/CFFFW.png&quot; alt=&quot;Screenshot&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make vim clear the whole screen buffer (not just the part that is visible), either when starting it or on exit? Or to save the entire state (buffer contents, scroll position, and cursor position) and restore afterward?&lt;/p&gt;&#xA;" OwnerUserId="880" LastEditorUserId="880" LastEditDate="2015-06-19T14:17:27.517" LastActivityDate="2015-08-18T14:55:26.580" Title="Avoid junk in the console buffer on win32" Tags="|terminal|microsoft-windows|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3642" PostTypeId="2" ParentId="3641" CreationDate="2015-06-19T14:17:16.243" Score="1" Body="&lt;p&gt;On further investigation, the &lt;code&gt;restorescreen&lt;/code&gt; option was being set incorrectly in my vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had this code (I don't know where I got it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&amp;amp;restorescreen)&#xA;    if has(&quot;win32&quot;)&#xA;        set restorescreen&#xA;    else&#xA;        set norestorescreen&#xA;    endif&#xA;else&#xA;    set t_ti= t_te=&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but &lt;code&gt;exists(&amp;amp;restorescreen)&lt;/code&gt; actually evaluates to 0.&lt;/p&gt;&#xA;" OwnerUserId="880" LastActivityDate="2015-06-19T14:17:16.243" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3643" PostTypeId="1" AcceptedAnswerId="3651" CreationDate="2015-06-19T14:44:54.413" Score="1" ViewCount="73" Body="&lt;p&gt;The real &lt;code&gt;start&lt;/code&gt; command on MS Windows uses ShellExecute and can therefore open directories and documents in addition to commands. I therefore have a habit of using &lt;code&gt;start .&lt;/code&gt; to open Explorer in the current directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the special handling of &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/os_win32.html#:!start&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:!start&lt;/code&gt;&lt;/a&gt; apparently does not support this. To get the desired behavior (no popup and can open directories or documents) I have to run &lt;code&gt;:!start /b cmd /c start .&lt;/code&gt; I can simply use &lt;code&gt;:! start .&lt;/code&gt; but then I still get the popup console which has to be dismissed manually. Is there any way to change the &lt;code&gt;:!start&lt;/code&gt; command to use ShellExecute and therefore be able to handle directories and documents?&lt;/p&gt;&#xA;" OwnerUserId="880" LastActivityDate="2015-06-21T21:16:55.977" Title="Why doesn't :!start work with non-commands?" Tags="|external-command|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3644" PostTypeId="2" ParentId="3638" CreationDate="2015-06-19T16:12:02.983" Score="4" Body="&lt;p&gt;I found a solution thanks to the lead from @lcd047, which I greatly appreciate!  I edited the script to run &lt;code&gt;redraw&lt;/code&gt; before the &lt;code&gt;echo&lt;/code&gt; per &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#:echo-redraw&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help :echo-redraw&lt;/code&gt;&lt;/a&gt;.  At least in my particular situation, the message now stays visible until I start scrolling.  The relevant portion of the script is below for anyone who would like it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func JCWC(line1, line2)&#xA;  let wc_start_line = 1&#xA;  let wc_end_line = 1&#xA;  if a:line2 &amp;gt;= a:line1&#xA;    let wc_start_line = a:line1&#xA;    let wc_end_line = a:line2&#xA;  else&#xA;    let wc_start_line = a:line2&#xA;    let wc_end_line = a:line1&#xA;  endif&#xA;&#xA;  let wc_count = 0&#xA;&#xA;  let stop = &quot;&quot;&#xA;  let n = wc_start_line&#xA;  while n &amp;lt;= wc_end_line&#xA;      let line = getline(n)&#xA;      if match(line, &quot;^--------&quot;) &amp;gt;= 0&#xA;          let stop = &quot; until '^--------'&quot;&#xA;          break&#xA;      endif&#xA;      let c = JCWC_line(line)&#xA;      let wc_count = wc_count + c&#xA;      let n = n + 1&#xA;  endwhile&#xA;&#xA;  redraw &quot; &amp;lt;----- Added this&#xA;  echo &quot;counted &quot; . wc_count . &quot; words&quot; . stop&#xA;&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="205" LastEditDate="2015-06-19T16:33:10.003" LastActivityDate="2015-06-19T16:33:10.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3645" PostTypeId="1" AcceptedAnswerId="3662" CreationDate="2015-06-19T21:23:36.057" Score="6" ViewCount="1008" Body="&lt;p&gt;I'm having trouble with vim wanting to treat the &lt;code&gt;p&lt;/code&gt; element as an inline element rather than a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements&quot; rel=&quot;noreferrer&quot;&gt;block level&lt;/a&gt; one. What vim's auto indent should produce is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;body&amp;gt;&#xA;  &amp;lt;p&amp;gt;&#xA;    Aaaaaaaaaaaaaa bbbbbbbbbbbbbb cccccccccccccccccccccccccccccccc dd&#xA;    eeeeeeeeeeeee ffffffffffffff gggggggggggggggggggggggggggggggg eee&#xA;  &amp;lt;p&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when typing this out and going to the second line in the paragraph, vim will move the indentation inwards one space like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;body&amp;gt;&#xA;  &amp;lt;p&amp;gt;&#xA;  Aaaaaaaaaaaaaa bbbbbbbbbbbbbb cccccccccccccccccccccccccccccccc dd&#xA;  eeeeeeeeeeeee ffffffffffffff gggggggggggggggggggggggggggggggg eee&#xA;  &amp;lt;p&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think this is because most people write their html like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;body&amp;gt;&#xA;  &amp;lt;p&amp;gt;Aaaaaaaaaaaaaa bbbbbbbbbbbbbb cccccccccccccccccccccccccccccccc&#xA;     eeeeeeeeeeeee ffffffffffffff gggggggggggggggggggggggggggggggg&amp;lt;p&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get around this and make vim format all block level elements in the same manner?&lt;/p&gt;&#xA;" OwnerUserId="2524" LastActivityDate="2015-06-22T16:11:43.983" Title="How do I get vim to auto indent block-level html elements?" Tags="|filetype-html|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3646" PostTypeId="1" CreationDate="2015-06-19T23:36:29.223" Score="4" ViewCount="398" Body="&lt;p&gt;I wonder if there is any method that I can use to check a function name against its prototype, which may help a lot when I make typo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I once wrote a function prototype this way:&lt;code&gt;void printOneNode();&lt;/code&gt;;but when I defined it afterward, I make a typo and wrote:&lt;code&gt;void PrintOneNode(){...}&lt;/code&gt;.So you see, I mistake the uppercase &lt;code&gt;P&lt;/code&gt; for the lowercase &lt;code&gt;p&lt;/code&gt;, and that give me link error. That little bug cost me lots of time. So I wonder if there is method in vim to help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, if language involved, I'm using C.&lt;/p&gt;&#xA;" OwnerUserId="2206" LastEditorUserId="24" LastEditDate="2015-06-22T22:09:54.057" LastActivityDate="2015-06-23T14:32:11.207" Title="Customize vim to automatically check function name against its prototype" Tags="|ide|filetype-c|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3648" PostTypeId="1" AcceptedAnswerId="3649" CreationDate="2015-06-20T18:35:16.473" Score="0" ViewCount="307" Body="&lt;p&gt;I want to use &lt;a href=&quot;https://github.com/stephpy/vim-php-cs-fixer&quot; rel=&quot;nofollow&quot;&gt;https://github.com/stephpy/vim-php-cs-fixer&lt;/a&gt; plugin. I have installed both php-cs-fixer in my path and also the plugin itself via Vundle. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Documentation says &lt;code&gt;Default mapping is &amp;lt;leader&amp;gt;pcd&lt;/code&gt; - and I dont understand how to use it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google said that leader is backslash (I havent overridden this in .vimrc). So on my keyboard I directly typed &quot;\pcd&quot;. When I type &quot;\&quot; nothing happens, but when I type &quot;p&quot; then vim inserts a piece of text I yanked a minute ago. And this is not what I want to happen..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what exactly am I supposed to type?&lt;/p&gt;&#xA;" OwnerUserId="2530" LastActivityDate="2015-06-20T20:46:29.200" Title="How to execute &lt;leader&gt;pcd mapping?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3649" PostTypeId="2" ParentId="3648" CreationDate="2015-06-20T20:46:29.200" Score="2" Body="&lt;p&gt;You are supposed to press &lt;code&gt;\pcd&lt;/code&gt; in rapid succession because Vim waits a bit (default is 1 second) to decide what exactly you are trying to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help mapleader&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-06-20T20:46:29.200" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3650" PostTypeId="1" AcceptedAnswerId="3677" CreationDate="2015-06-20T22:36:09.940" Score="4" ViewCount="143" Body="&lt;p&gt;As per other questions, most of us know that if we want to enter paste mode we can toggle &lt;code&gt;:set paste&lt;/code&gt; and &lt;code&gt;:set nopaste&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And for auto-indenting we can &lt;code&gt;:set autoindent&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I was thinking today, I &lt;em&gt;only ever paste&lt;/em&gt; when I am at the beginning of a line and otherwise always want auto-indenting. I can set up hot keys to toggle the two quickly, but is there some way perhaps to tell vim in settings to be in paste mode when at the beginning of a line and to otherwise be in auto-indent mode to avoid the need to manually toggle?&lt;/p&gt;&#xA;" OwnerUserId="2531" LastEditorUserId="205" LastEditDate="2015-06-20T23:09:25.330" LastActivityDate="2015-06-23T22:48:48.623" Title="Set paste mode when at beginning of line but auto-indent mode when anywhere else on the line?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3651" PostTypeId="2" ParentId="3643" CreationDate="2015-06-21T01:23:50.990" Score="2" Body="&lt;p&gt;&lt;code&gt;:help :!&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ...Vim redraws the screen after the command is finished,&#xA;because it may have printed any text.  This requires a&#xA;hit-enter prompt, so that you can read any messages.&#xA;To avoid this use: &#xA;    `:silent !{cmd}`&#xA;The screen is not redrawn then, thus you have to use&#xA;CTRL-L or &quot;:redraw!&quot; if the command did display&#xA;something.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;First method:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent ! start .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;:silent !&lt;/code&gt; method works not only on Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also. &lt;code&gt;:he :!&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For Win32 also see &lt;code&gt;:!start&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/os_win32.txt.html#%3A%21start&quot; rel=&quot;nofollow&quot;&gt;Let's see:&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Q. How do I avoid getting a window for programs that I run asynchronously?&#xA;A. You have two possible solutions depending on what you want:&#xA;   1) You may use the /min flag in order to run program in a minimized state&#xA;      with no other changes. It will work equally for console and GUI&#xA;      applications.&#xA;   2) You can use the /b flag to run console applications without creating a&#xA;      console window for them (GUI applications are not affected). But you&#xA;      should use this flag only if the application you run doesn't require any&#xA;      input.  Otherwise it will get an EOF error because its input stream&#xA;      (stdin) would be redirected to \\.\NUL (stdout and stderr too).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Second method:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!start /b start .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can avoid &lt;code&gt;cmd /c&lt;/code&gt; here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally, you can alias this long line as a command of your own. It's not exactly what you asked but works as you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPD.&#xA;No. &lt;code&gt;start .&lt;/code&gt; does not use &lt;code&gt;ShellExecute&lt;/code&gt;. It just starts &lt;code&gt;explorer.exe&lt;/code&gt; for the current path. &lt;/p&gt;&#xA;" OwnerUserId="1145" LastEditorUserId="205" LastEditDate="2015-06-21T21:16:55.977" LastActivityDate="2015-06-21T21:16:55.977" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3652" PostTypeId="1" AcceptedAnswerId="3653" CreationDate="2015-06-21T04:30:04.620" Score="1" ViewCount="307" Body="&lt;p&gt;Suppose the content in register b is: &lt;code&gt;a^Jbcdefg, ^Jhijkl^J^J&lt;/code&gt;, I want to format it by substituting &lt;code&gt;^J&lt;/code&gt; with a space to make it looks like this: &lt;code&gt;a bcdefg,  hijkl&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've consulted many documentations but found no answer. &lt;a href=&quot;https://stackoverflow.com/questions/11360856/macvim-modify-the-content-of-the-clipboard-register-before-pasting-it/11362748#11362748&quot;&gt;This answer&lt;/a&gt; is the closest one on StackExchange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are my commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @b=substitute(@b,'^J',' ','g')&#xA;let @b=substitute(@b,'\^J',' ','g')&#xA;let @b=substitute(@b,'NL',' ','g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought maybe the linebreak is not &lt;kbd&gt;^&lt;/kbd&gt; appending &lt;kbd&gt;J&lt;/kbd&gt; so I just copied it from the register when running &lt;code&gt;:reg&lt;/code&gt; using the mouse manually, but also got a wrong result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I replace the line break with a space? Or remove the line break?&lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-06-21T12:47:01.393" Title="How to substitute line break on register?" Tags="|substitute|register|line-breaks|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3653" PostTypeId="2" ParentId="3652" CreationDate="2015-06-21T05:13:15.683" Score="3" Body="&lt;p&gt;You have to use &lt;code&gt;\n&lt;/code&gt; to match newlines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @b=substitute(@b,'\n',' ','g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also works in &lt;code&gt;s///&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\n/ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to do it the other way around, replace spaces with newlines, it works the way you expect with a register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @b=substitute(@b,' ','\n','g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However,&lt;/strong&gt; you need to use &lt;code&gt;\r&lt;/code&gt; instead of &lt;code&gt;\n&lt;/code&gt; in replacement values in &lt;code&gt;s///&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/ /\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="1577" LastEditDate="2015-06-21T05:27:16.017" LastActivityDate="2015-06-21T05:27:16.017" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3654" PostTypeId="1" CreationDate="2015-06-21T14:51:57.520" Score="1" ViewCount="215" Body="&lt;p&gt;I'm trying to figure out how to use an environment variable name in a function, passed in as a function argument, i.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! myautoloadfunc#set_default_env_var(name, value)&#xA;  if empty($a:name)&#xA;     let $a:name = a:value&#xA;  endif&#xA;endfunction&#xA;&#xA;call myautoload#set_default_env_var('SOME_VAR', 'SOME_VALUE')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously that doesn't work, I'm pretty sure I can do this with &lt;code&gt;exec&lt;/code&gt;, but not sure if there's a more efficient way. Any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit: It seems that the following works:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call myautoload#set_default_env_var('$SOME_VAR', 'SOME_VALUE')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2207" LastEditorUserId="2207" LastEditDate="2015-06-21T15:54:04.020" LastActivityDate="2015-08-11T14:02:48.223" Title="Using an environment variable name as function argument" Tags="|vimscript|" AnswerCount="0" CommentCount="5" ClosedDate="2016-03-02T12:37:02.377" ContentLicense="CC BY-SA 3.0" />
  <row Id="3655" PostTypeId="1" CreationDate="2015-06-22T01:42:15.050" Score="6" ViewCount="2024" Body="&lt;p&gt;I'm writing a script that does a search like so: &lt;code&gt;normal /needle^M&lt;/code&gt;. This works like I want, except that I want to be able to use &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;N&lt;/code&gt; to repeat the search. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case it helps, here's the full function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MakeChoices()&#xA;    let start = line('.')&#xA;&#xA;    let choiceStartLine = search('^*choice', 'bW')&#xA;&#xA;    let choiceEndLine = search('^\S.*', 'W') &quot;End is first line that starts with non-whitespace&#xA;&#xA;    &quot;If above search fails, might be at bottom of buffer&#xA;    if choiceEndLine == 0&#xA;        let choiceEndLine = search('^$', 'W') &quot;End is first empty line&#xA;    endif&#xA;&#xA;    &quot;Now go back up to the last *goto&#xA;    let choiceEndLine = search('*goto', 'bW')&#xA;&#xA;    &quot;Get the entire *choice block and put it in gotoBlock&#xA;    let gotoBlock = getline(choiceStartLine, choiceEndLine)&#xA;&#xA;    &quot;Make labelArray (contains all labels to goto)&#xA;    let labelArray = []&#xA;&#xA;    for cur in gotoBlock&#xA;        if match(cur, '*goto') != -1&#xA;            &quot;echo 'cur: '.cur&#xA;            let curParsed = matchlist(cur, '*goto \(\S\+\)')&#xA;            &quot;echo curParsed&#xA;            if len(curParsed) &amp;gt; 1&#xA;                let curLabel = curParsed[1]&#xA;            else&#xA;                echo 'ERROR: Bad *goto ('.cur.')'&#xA;                return -1&#xA;            endif&#xA;            call add(labelArray, curLabel)  &#xA;        endif&#xA;    endfor&#xA;&#xA;    &quot;Make newline after choice block if needed&#xA;    if strlen(getline(choiceEndLine+1)) &amp;gt; 0&#xA;        echo 'big line: '.getline(choiceEndLine+1)&#xA;        call cursor(choiceEndLine, 1)&#xA;        put=''&#xA;    endif&#xA;&#xA;    call cursor(choiceEndLine+1, 1)&#xA;&#xA;    &quot;Put the new label blocks&#xA;    let skippedLabels = ''&#xA;    let numNewLabels = 0&#xA;    for cur in labelArray&#xA;        if !search('*label '.cur, 'wn')&#xA;            let numNewLabels += 1&#xA;            put='*label '.cur&#xA;            put='[This option is yet to be written.]'&#xA;            put=''&#xA;        else&#xA;            let skippedLabels .= cur.' '&#xA;        endif&#xA;    endfor&#xA;&#xA;    &quot;Remove trailing blank lines (Up to a point)&#xA;    let nextlines = getline(line('.')+1, line('.')+3)&#xA;    if len(nextlines) == 3&#xA;        if nextlines[0] == '' &amp;amp;&amp;amp; nextlines[1] == '' &amp;amp;&amp;amp; nextlines[2] == ''&#xA;            normal &quot;_3dd&#xA;        elseif nextlines[0] == '' &amp;amp;&amp;amp; nextlines[1] == ''&#xA;            normal &quot;_2dd&#xA;        elseif nextlines[0] == ''&#xA;            normal &quot;_dd&#xA;        endif&#xA;    endif&#xA;&#xA;    &quot;Move to first label's text (use ctrl-v ctrl-m to input the &amp;lt;CR&amp;gt; at&#xA;    &quot;end)&#xA;    if numNewLabels != 0&#xA;        call cursor(choiceEndLine, 1)&#xA;        normal /\[This option is yet to be written.\]&#xA;    endif&#xA;&#xA;    &quot;Print status message&#xA;    if len(skippedLabels) &amp;gt; 0&#xA;        echo 'Skipped: '.skippedLabels&#xA;    else&#xA;        echo 'New labels created: '.numNewLabels&#xA;    endif&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The line in question is near the end, and you can probably just ignore the rest of the code. Basically, this function parses some code (in a language called ChoiceScript) and outputs a set of stock templates based on that code, then jumps (via the vim search command in question) to the first stock template. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's say I begin with this ChoiceScript code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*choice&#xA;    #Option A&#xA;        *goto optionA&#xA;    #Option B&#xA;        *goto optionB&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, after running the function, the file becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*choice&#xA;    #Option A&#xA;        *goto optionA&#xA;    #Option B&#xA;        *goto optionB&#xA;&#xA;*label optionA&#xA;[This option is yet to be written.]&#xA;&#xA;*label optionB&#xA;[This option is yet to be written.]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The cursor will be on the first &quot;[This option is yet to be written.]&quot;, and I want to be able to hit &lt;code&gt;n&lt;/code&gt; to jump to the second if that's the option I want to work on first.&lt;/p&gt;&#xA;" OwnerUserId="2511" LastEditorUserId="2511" LastEditDate="2015-07-02T19:57:42.100" LastActivityDate="2018-08-14T07:30:07.380" Title="How can I make a search in vimscript let n and N look for more?" Tags="|vimscript|search|" AnswerCount="3" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3656" PostTypeId="1" AcceptedAnswerId="3660" CreationDate="2015-06-22T13:00:06.260" Score="3" ViewCount="444" Body="&lt;p&gt;I am writing a vim plugin that at one point define a buffer only mapping :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:DoStuff()&#xA;    tabnew&#xA;&#xA;    &quot; ...&#xA;&#xA;    nnoremap &amp;lt;buffer&amp;gt; q :tabclose&amp;lt;CR&amp;gt;&#xA;endfunction&#xA;&#xA;call s:DoStuff()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I call my file for testing with : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u plugin.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when in my newly created tab and I hit &lt;code&gt;q&lt;/code&gt; I get : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabclose&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of inserting &lt;code&gt;tabclose&lt;/code&gt; and actually closing the tab. When I hit &lt;code&gt;enter&lt;/code&gt; to excute the command I get an error : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/69fuu.png&quot; alt=&quot;A result&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/pqIKA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have an idea ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am on OS X with tmux and MacVim 7.4.383.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-06-22T15:01:56.793" Title="Plugin nnoremap insert &lt;CR&gt; instead of executing command" Tags="|vimscript|command-line|tabbed-user-interface|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3657" PostTypeId="2" ParentId="3655" CreationDate="2015-06-22T13:49:41.723" Score="1" Body="&lt;p&gt;You probably are doing that inside a function, which will reset the &lt;code&gt;/&lt;/code&gt; after it completes. From &lt;code&gt;:help quote_/&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Note that the valued is restored when returning from a function |function-search-undo|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To overcome this behavior you need to manually update the &lt;em&gt;Last search pattern register&lt;/em&gt; by adding the following command to the function along with the search &lt;code&gt;/needle&lt;/code&gt; call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @/='needle'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: using &lt;code&gt;needle&lt;/code&gt; only as an example search.&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="599" LastEditDate="2015-07-03T11:23:25.203" LastActivityDate="2015-07-03T11:23:25.203" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3659" PostTypeId="1" AcceptedAnswerId="3661" CreationDate="2015-06-22T14:52:39.073" Score="5" ViewCount="3130" Body="&lt;p&gt;I'm currently using vim 7.3 on Windows 7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first question I have is it even possible to create the patch file from within vim itself? I understand the basic idea, but anytime I attempt to run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diff -u file.txt file_new.txt &amp;gt; file.patch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get a &lt;code&gt;E488: Trailing characters&lt;/code&gt; error. However, using the Windows command prompt to run &lt;code&gt;diff.exe&lt;/code&gt; from the vim folder seems to work just fine. I'm not sure if I'm doing something wrong here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second - and I'm sure there's an explanation in the manual but &lt;code&gt;:help diff&lt;/code&gt; didn't seem to show anything - what's the difference between &lt;code&gt;diff -u&lt;/code&gt; and &lt;code&gt;diff -c&lt;/code&gt;? From what I saw online, both &lt;code&gt;-u&lt;/code&gt; and &lt;code&gt;-c&lt;/code&gt; were both used to create a patch file. When I tested it myself using the command prompt, they both appeared to generate identical files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[Edit] I realized I must have done something wrong as I just checked again and the files generated by &lt;code&gt;diff -u&lt;/code&gt; and &lt;code&gt;diff -c&lt;/code&gt; are different. Still curious what the differences are and when I should use one or the other.&lt;/p&gt;&#xA;" OwnerUserId="2543" LastEditorUserId="205" LastEditDate="2015-06-22T15:50:33.203" LastActivityDate="2015-06-22T15:50:33.203" Title="Using Vim Diff To Create A Patch File?" Tags="|external-command|vimdiff|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3660" PostTypeId="2" ParentId="3656" CreationDate="2015-06-22T15:01:56.793" Score="1" Body="&lt;p&gt;Ok so I found the solution : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to be in &lt;code&gt;nocompatible&lt;/code&gt; mode to execute the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I can add the &lt;code&gt;set nocompatible&lt;/code&gt; at the first line of my plugin (but I think it's not a good way to do). Or I can start vim with the &lt;code&gt;-N&lt;/code&gt; flag that set &lt;code&gt;nocompatible&lt;/code&gt; at vim startup. (thanks @romainl)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the documentation, I saw that &lt;code&gt;nnoremap&lt;/code&gt; was not in Vi.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-06-22T15:01:56.793" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3661" PostTypeId="2" ParentId="3659" CreationDate="2015-06-22T15:48:47.173" Score="3" Body="&lt;p&gt;&lt;code&gt;:!&amp;lt;cmd&amp;gt;&lt;/code&gt; is how we usually run external commands from within Vim. See &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3A%21&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:he :!&lt;/code&gt;&lt;/a&gt;. &lt;code&gt;:diff&lt;/code&gt; presumably calls Vim's &lt;code&gt;:diffget&lt;/code&gt; command, but definitely not the external &lt;code&gt;diff&lt;/code&gt; program as you intended it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help diff&lt;/code&gt; won't say anything about difference between &lt;code&gt;diff -u&lt;/code&gt; and &lt;code&gt;diff -c&lt;/code&gt;, because those are options for the external &lt;code&gt;diff&lt;/code&gt; program, and nothing to do with Vim. Assuming you're using GNU &lt;code&gt;diff&lt;/code&gt; (POSIX &lt;code&gt;diff&lt;/code&gt; doesn't specify &lt;code&gt;-u&lt;/code&gt;), &lt;code&gt;-u&lt;/code&gt; produces  &lt;em&gt;unified&lt;/em&gt; diffs, and &lt;code&gt;-c&lt;/code&gt; produces a &lt;em&gt;context&lt;/em&gt; diff with, 3 lines of context. See the &lt;a href=&quot;http://www.gnu.org/software/diffutils/manual/diffutils.html#Context-Format&quot; rel=&quot;nofollow&quot;&gt;GNU &lt;code&gt;diff&lt;/code&gt; manual&lt;/a&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It seems you must be using GNU &lt;code&gt;diff&lt;/code&gt;, since the GNU docs say about unified diffs:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;At present, only GNU diff can produce this format and only GNU patch can automatically apply diffs in this format.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-06-22T15:48:47.173" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3662" PostTypeId="2" ParentId="3645" CreationDate="2015-06-22T16:11:43.983" Score="3" Body="&lt;p&gt;I had to add the code below to my &lt;code&gt;vimrc&lt;/code&gt; to get the &lt;code&gt;p&lt;/code&gt; tag to work. I also included all the block level elements that are listed in the link in the original question as well (though this is overkill) to prevent any other changes (like Vim patch 7.4.356) from overriding my preferred settings.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&#xA;&quot; HTML indentation&#xA;&quot;&#xA;&#xA;let g:html_indent_script1 = &quot;inc&quot;&#xA;let g:html_indent_style1 = &quot;inc&quot;&#xA;let g:html_indent_inctags = &quot;address,article,aside,audio,blockquote,canvas,dd,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,main,nav,noscript,ol,output,p,pre,section,table,tfoot,ul,video&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2524" LastActivityDate="2015-06-22T16:11:43.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3663" PostTypeId="1" AcceptedAnswerId="3664" CreationDate="2015-06-22T16:18:12.110" Score="3" ViewCount="643" Body="&lt;p&gt;I have an nvi session that got interrupted, and I'd like to recover my edits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I type &lt;code&gt;vi -r&lt;/code&gt;, it tells me &quot;no files to recover.&quot;  But there is a recovery file in &lt;code&gt;/var/tmp/vi.recover&lt;/code&gt;, and when I run &lt;code&gt;strings&lt;/code&gt; on that file, I can see that it contains text from the interrupted session.  So if I can point nvi to that recovery file, I should be able to recover my edits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there appears to be no (documented) way to specify a recovery file.  The -r option does not take any parameters of its own; the only thing that can follow it is the name of the original file.  But since vi has apparently lost the association between the original file and the recovery file, &lt;code&gt;vi -r myfile&lt;/code&gt; just tells me, &quot;No files named myfile, readable by you, to recover&quot;.  How can I tell it to use a given recovery file?  Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2545" LastEditorUserId="51" LastEditDate="2015-06-22T16:38:33.083" LastActivityDate="2015-06-22T16:38:33.083" Title="specifying a recovery file in nvi" Tags="|swap-file|nvi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3664" PostTypeId="2" ParentId="3663" CreationDate="2015-06-22T16:37:55.867" Score="2" Body="&lt;p&gt;It seems that &lt;code&gt;nvi&lt;/code&gt; uses a special &quot;index file&quot; in &lt;code&gt;/var/tmp/vi.recover/&lt;/code&gt;, named &lt;code&gt;recover.XXXXX&lt;/code&gt; (where &lt;code&gt;XXXXX&lt;/code&gt; is randomly generated). On my system the contents look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;X-vi-recover-file: /home/martin/recover&#xA;X-vi-recover-path: /var/tmp/vi.recover/vi.AI8Iqs&#xA;Reply-To: root&#xA;From: root (Nvi recovery program)&#xA;To: martin&#xA;Subject: Nvi saved the file recover&#xA;Precedence: bulk&#xA;&#xA;On Mon Jun 22 17:30:01 2015, the user martin was editing a&#xA;file named /home/martin/recover on the machine&#xA;martin-xps.lico.nl, when it was saved for recovery. You can&#xA;recover most, if not all, of the changes to this file using&#xA;the -r option to nvi:&#xA;&#xA;        nvi -r /home/martin/recover&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By creating a new &lt;code&gt;/var/tmp/vi.recover/recover.XXXXXX&lt;/code&gt; file with the above contents, and changing the first two &quot;headers&quot; (&lt;code&gt;X-vi-recover-file&lt;/code&gt; and &lt;code&gt;X-vi-recover-path&lt;/code&gt;) to the correct paths, you should be able tell &lt;code&gt;nvi&lt;/code&gt; to pick up your recovery file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... This seems to be the &quot;easiest&quot; way, as far as I can see ...&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-06-22T16:37:55.867" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3665" PostTypeId="1" AcceptedAnswerId="3689" CreationDate="2015-06-23T09:55:07.800" Score="6" ViewCount="788" Body="&lt;p&gt;I have a windows 7 machine with an azerty keyboard running gVim 7.4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; simply does nothing: When I'm in an help page I can't follow the tags links. As I have an azerty keyboard I have to use the keys &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;AltGr&lt;/kbd&gt;+&lt;kbd&gt;]&lt;/kbd&gt; I thought that was causing the problem but when I use Vim on a distant machine via ssh in a cygwin console &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; works properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; It also works correctly when I use a local vim instance in a cygwin console. So it seems to be a gVim issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;https://stackoverflow.com/questions/11562654/vim-ctrl-keys-not-working&quot;&gt;a question&lt;/a&gt; mentionning this problem but none of the answers works for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I used &lt;code&gt;:verbose nmap &amp;lt;C-]&amp;gt;&lt;/code&gt; to check if a mapping was already present but I gave me &lt;code&gt;no mapping found&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do to have this key combinaison working properly?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2023-07-30T15:47:58.947" Title="Gvim &lt;C-]&gt; not working with azerty keyboard" Tags="|key-bindings|keyboard-layout|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="3666" PostTypeId="2" ParentId="3646" CreationDate="2015-06-23T10:27:44.790" Score="2" Body="&lt;p&gt;I think you might solve your problem with the &lt;a href=&quot;http://vim.wikia.com/wiki/Omni_completion&quot; rel=&quot;nofollow&quot;&gt;Omni Completion function&lt;/a&gt; working with a program like &lt;a href=&quot;http://ctags.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;exuberant ctags&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to generate a tags file containing the different classes, constants, fields, etc... of your code and letting Vim use this list to generate the autocomplete suggestions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do so:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Install exuberant ctags:&lt;/strong&gt; &lt;code&gt;$ sudo apt-get install exuberant-ctags&lt;/code&gt; (or the equivalent command for your distribution).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Generate the tags file:&lt;/strong&gt; &lt;code&gt;$ ctags *.c *.h&lt;/code&gt; a file named &lt;code&gt;tags&lt;/code&gt;shoud be generated on your folder.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Let Vim knows where is your tags file:&lt;/strong&gt; &lt;code&gt;:tags=./tags,tags&lt;/code&gt; with these settings Vim looks for a tags file in the directory of the current file&#xA;and in the working directory. Note that you can use &lt;code&gt;:set tags?&lt;/code&gt; to check your current configuration.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Call the Tag Completion:&lt;/strong&gt; Now when writing a word and hitting &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; Vim will use this tags list to autocomplete your word.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Bonus:&lt;/em&gt; As you might have noticed your tags file will not update automatically, which means that when you write new prototypes the tag completion will not suggest them. If your codebase isn't too big you could put this line in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd BufWritePost * call system(&quot;ctags -R&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will simply regenerate the tags file each time you save a file. It is important to note that if your codebase is important, this trick might considerably slow down your workflow.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="15" LastEditDate="2015-06-23T14:32:11.207" LastActivityDate="2015-06-23T14:32:11.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3667" PostTypeId="1" CreationDate="2015-06-23T11:27:03.683" Score="5" ViewCount="2190" Body="&lt;p&gt;Is it possible to write .nvimrc for NeoVim in Lua? Is it planned for the future?&lt;/p&gt;&#xA;" OwnerUserId="2554" LastEditorUserId="51" LastEditDate="2015-06-23T12:24:13.553" LastActivityDate="2015-06-28T01:55:13.983" Title="Is it possible to write .nvimrc for NeoVim in Lua?" Tags="|neovim|vimscript-lua|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3668" PostTypeId="1" CreationDate="2015-06-23T12:41:53.647" Score="4" ViewCount="504" Body="&lt;p&gt;I've been using PHP Storm IDE for some time and I want to try out Vim. PHP Storm automatically allowed me to jump to classess/interfaces defined somewhere in my code (by &lt;code&gt;use&lt;/code&gt; and &lt;code&gt;implements&lt;/code&gt; statements, and alike) by double clicking on them. Can I do the same in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I am in &lt;code&gt;/app/models/User.php&lt;/code&gt; that implements &lt;code&gt;UserInterface&lt;/code&gt; defined in &lt;code&gt;app/interfaces/UserInterface.php&lt;/code&gt;. I want to double click on that name and it would automatically take me to that file.&lt;/p&gt;&#xA;" OwnerUserId="2530" LastEditorUserId="51" LastEditDate="2015-06-23T13:03:54.190" LastActivityDate="2015-06-24T13:54:35.773" Title="How can I navigate to a class interface?" Tags="|ide|filetype-php|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3669" PostTypeId="2" ParentId="3668" CreationDate="2015-06-23T13:26:13.637" Score="5" Body="&lt;p&gt;You can use the external program &lt;a href=&quot;http://ctags.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;exuberant cTags&lt;/a&gt; to help you doing that: It will create a tags file indexing the keywords of your codebase and allow you to navigate through them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The first steps comes from &lt;a href=&quot;https://vi.stackexchange.com/a/3666/1841&quot;&gt;another answer&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Install exuberant cTags:&lt;/strong&gt; &lt;code&gt;$ sudo apt-get install exuberant-ctags&lt;/code&gt; (or the equivalent command for your distribution).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Generate the tags file:&lt;/strong&gt; &lt;code&gt;$ ctags *.php&lt;/code&gt; a file named &lt;code&gt;tags&lt;/code&gt; should be generated on your folder.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Let Vim knows where is your tags file:&lt;/strong&gt; &lt;code&gt;:tags=./tags,tags&lt;/code&gt; with these settings Vim looks for a tags file in the directory of the current file&#xA;and in the working directory. Note that you can use &lt;code&gt;:set tags?&lt;/code&gt; to check your current configuration.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Jump from keyword to declaration&lt;/strong&gt; and inversely with &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; and &lt;code&gt;g&amp;lt;C-]&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Open a preview window showing the declaration&lt;/strong&gt; with &lt;code&gt;&amp;lt;C-w&amp;gt;}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've never used it with php but it should work just like with other languages&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-06-24T13:54:35.773" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3670" PostTypeId="1" AcceptedAnswerId="3765" CreationDate="2015-06-23T14:46:29.437" Score="28" ViewCount="13515" Body="&lt;p&gt;I have the following mappings to make it easy to move out of a terminal pane in Neovim:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;tnoremap &amp;lt;C-h&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&amp;lt;C-w&amp;gt;h&#xA;&amp;quot; Workaround since &amp;lt;C-h&amp;gt; isn't working in Neovim right now&#xA;tnoremap &amp;lt;C-w&amp;gt;h &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&amp;lt;C-w&amp;gt;h&#xA;tnoremap &amp;lt;C-j&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&amp;lt;C-w&amp;gt;j&#xA;tnoremap &amp;lt;C-k&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&amp;lt;C-w&amp;gt;k&#xA;tnoremap &amp;lt;C-l&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&amp;lt;C-w&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The only problem is that when I move back into the terminal pane, I have to press &lt;code&gt;i&lt;/code&gt; to get back into insert mode. I always want it to be in insert mode when I move into a Neovim pane that is running terminal. What's the best way to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="226" LastEditorUserId="23502" LastEditDate="2024-01-04T17:08:38.320" LastActivityDate="2024-01-04T17:08:38.320" Title="How to enter insert mode when entering Neovim terminal pane?" Tags="|key-bindings|neovim|insert-mode|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3671" PostTypeId="1" CreationDate="2015-06-23T15:04:28.707" Score="4" ViewCount="1889" Body="&lt;p&gt;When I open up &lt;code&gt;:Vexplore&lt;/code&gt; in a split and open a file in it, the file in the other split ends up with &lt;code&gt;buftype=nofile&lt;/code&gt; set so I can't write in that file or anything.&lt;br&gt;&#xA;But the new buffer that was opened with &lt;code&gt;:Explore&lt;/code&gt; has &lt;code&gt;buftype=.&lt;/code&gt; This is annoying as all hell and I want to fix it. Anybody know how?&lt;/p&gt;&#xA;" OwnerUserId="2559" LastEditorUserId="51" LastEditDate="2015-06-23T15:36:42.067" LastActivityDate="2016-12-20T22:15:51.743" Title="Buftype=nofile when switching buffers with :Vexplore" Tags="|buffers|split|netrw|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3672" PostTypeId="2" ParentId="3667" CreationDate="2015-06-23T15:38:29.890" Score="2" Body="&lt;p&gt;As of of June 2015, the lua to VimsSript transpiler integration is still being worked on, so currently you cannot use Lua to write &lt;code&gt;.nvimrc&lt;/code&gt;, unfortunately. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this issue: &lt;a href=&quot;https://github.com/neovim/neovim/issues/1536&quot; rel=&quot;nofollow&quot;&gt;https://github.com/neovim/neovim/issues/1536&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14" LastEditorUserId="51" LastEditDate="2015-06-28T01:55:13.983" LastActivityDate="2015-06-28T01:55:13.983" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3673" PostTypeId="1" CreationDate="2015-06-23T15:40:30.670" Score="9" ViewCount="950" Body="&lt;p&gt;After reading &lt;code&gt;help textwith&lt;/code&gt; and &lt;code&gt;help fo-table&lt;/code&gt;, I expected that when I set&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=20  &quot; for demonstration&#xA;set formatoptions=tcq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then inserting text would always eventually cause a line to wrap, but that isn't the case. Wrapping only happens at (or before) my cursor. And if I paste, wrapping doesn't happen at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example (Vim 7.4):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12345678901234567890&#xA;This is a long line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The line will auto-wrap if I hit &lt;code&gt;A&lt;/code&gt; and start typing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I hit &lt;code&gt;02wi&lt;/code&gt; and type &quot;still &quot;, it doesn't wrap:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12345678901234567890&#xA;This is still a long line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to type another 7 characters before it will wrap, and then the problem continues on the next line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12345678901234567890&#xA;This is still more &amp;lt;-- it wraps here&#xA;typing and again a long line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pasting doesn't trigger a wrap either:    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12345678901234567890&#xA;This is a long line This text is pasted and not wrapped&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think what I want is &lt;code&gt;set fo+=a&lt;/code&gt; but that applies at the paragraph level, whereas I don't want auto-formatting of one line to spread to other lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or am I missing an option?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be clear, after launching &lt;code&gt;vim -u NONE&lt;/code&gt;, this is what I type (less comments):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set textwidth=20&amp;lt;CR&amp;gt;&#xA;:set formatoptions=tcq&amp;lt;CR&amp;gt;&#xA;iThis is a long line&amp;lt;ESC&amp;gt;&#xA;02wistill &amp;lt;ESC&amp;gt;                &quot; no wrap happens, but I'd like it to&#xA;u&#xA;:let @r = &quot;This text is pasted and not wrapped&quot;&amp;lt;CR&amp;gt;&#xA;$&quot;rp                           &quot; no wrap happens, but I'd like it to&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2560" LastEditorUserId="2560" LastEditDate="2015-06-24T05:36:41.210" LastActivityDate="2015-10-18T11:05:22.287" Title="Auto-format: wrapping later in line when inserting text" Tags="|formatting|wrapping|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3674" PostTypeId="1" AcceptedAnswerId="3675" CreationDate="2015-06-23T17:38:21.200" Score="8" ViewCount="5714" Body="&lt;p&gt;Sometimes I use Command-T to browse files. When I find the file I needed, I would like to switch the current working directory to the opened file's directory. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="2562" LastEditorUserId="2562" LastEditDate="2015-06-23T17:51:19.780" LastActivityDate="2015-06-23T17:51:19.780" Title="change working directory to current opened file" Tags="|working-directory|" AnswerCount="1" CommentCount="1" ClosedDate="2015-06-23T18:09:56.253" ContentLicense="CC BY-SA 3.0" />
  <row Id="3675" PostTypeId="2" ParentId="3674" CreationDate="2015-06-23T17:47:24.880" Score="18" Body="&lt;p&gt;&lt;code&gt;:cd %:h&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explain:&lt;br&gt;&#xA;&lt;code&gt;:cd&lt;/code&gt; change directory Vim command&lt;br&gt;&#xA;&lt;code&gt;%&lt;/code&gt; - full path to current file&lt;br&gt;&#xA;&lt;code&gt;%:h&lt;/code&gt; - full path to current file without filename itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help expand&lt;/code&gt; and &lt;code&gt;:help :cd&lt;/code&gt; for more information&lt;/p&gt;&#xA;" OwnerUserId="1145" LastActivityDate="2015-06-23T17:47:24.880" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3676" PostTypeId="2" ParentId="3655" CreationDate="2015-06-23T19:26:18.973" Score="7" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#function%2dsearch%2dundo&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help function-search-undo&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The last used search pattern and the redo command &quot;.&quot;&#xA;  will not be changed by the function.  This also&#xA;  implies that the effect of &lt;code&gt;:nohlsearch&lt;/code&gt; is undone&#xA;  when the function returns.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is a bit of a &quot;hidden&quot; feature... Another &quot;hidden&quot; feature is that assigning&#xA;directly to &lt;code&gt;@/&lt;/code&gt; overrides this behaviour:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! X()&#xA;    /Hello&#xA;    let @/ = 'Hello'&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-07-03T09:18:36.330" LastActivityDate="2015-07-03T09:18:36.330" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3677" PostTypeId="2" ParentId="3650" CreationDate="2015-06-23T22:48:48.623" Score="3" Body="&lt;p&gt;This can be done with an auto command (&quot;autocmd&quot;). There's the &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#CursorMoved&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;CursorMoved&lt;/code&gt;&lt;/a&gt; event which is triggered every time the cursor is moved. &lt;code&gt;CursorMovedI&lt;/code&gt; does the same, but for insert mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup autopaste&#xA;    autocmd!&#xA;    autocmd CursorMoved,CursorMovedI * let &amp;amp;paste = col('.') == 1&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, only on blank lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup autopaste&#xA;    autocmd!&#xA;    autocmd CursorMoved,CursorMovedI * let &amp;amp;paste = getline('.') == ''&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help autocmd.txt&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/12.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; (it has more chapters on autocmds, so be sure to look further than just this page).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As mentioned in the comments, this &lt;em&gt;may&lt;/em&gt; not be the best way to do this. Usually pasting directly from the clipboard is more convenient. This can be done fairly easily with these mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Interface with system clipboard&#xA;noremap &amp;lt;Leader&amp;gt;y &quot;*y&#xA;noremap &amp;lt;Leader&amp;gt;p &quot;*p&#xA;noremap &amp;lt;Leader&amp;gt;Y &quot;+y&#xA;noremap &amp;lt;Leader&amp;gt;P &quot;+p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vi.stackexchange.com/q/84/51&quot;&gt;How can I copy text to the system clipboard from Vim?&lt;/a&gt; for more information on how to interface with the system's clipboard.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-06-23T22:48:48.623" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3678" PostTypeId="2" ParentId="388" CreationDate="2015-06-24T06:50:53.977" Score="13" Body="&lt;p&gt;I especially like &lt;a href=&quot;https://github.com/MarcWeber/vim-addon-manager&quot;&gt;VAM&lt;/a&gt; for its self-deployment: all you need is your &lt;code&gt;.vimrc&lt;/code&gt; and then start vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you don't need the &lt;code&gt;To Install&lt;/code&gt; line used by most other plugin-managers (the first step of installing the plugin manager itself).&lt;/p&gt;&#xA;" OwnerUserId="2476" LastActivityDate="2015-06-24T06:50:53.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3679" PostTypeId="2" ParentId="2835" CreationDate="2015-06-24T11:09:04.353" Score="0" Body="&lt;p&gt;This has been a bug in MacVim for a long time. If you go into preferences (apple-,) and turn off the native fullscreen support then it will start work. This is only a work-around as the fullscreen window will cover your desktop rather than exist in a separate space. The other way to fix it is by hitting pgup/pgdown to refresh the current view.&lt;/p&gt;&#xA;" OwnerUserId="2571" LastActivityDate="2015-06-24T11:09:04.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3680" PostTypeId="1" CreationDate="2015-06-24T13:52:10.387" Score="3" ViewCount="1981" Body="&lt;p&gt;I have a line looking like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pattern1 any text pattern2 any text pattern2 any text pattern2 any text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want it to become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pattern1 any text&#xA;pattern1 pattern2 any text&#xA;pattern1 pattern2 any text&#xA;pattern1 pattern2 any text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'll be applying this to thousands of lines&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command: &lt;code&gt;%s/\(pattern1\).\{-}\zs.\(pattern2\)\|\(pattern2\)/\r\1 \2 \3/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is only producing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pattern1 any text&#xA;pattern1 pattern2  any text&#xA;  pattern2 any text&#xA;  pattern2 any text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because of the &lt;code&gt;\|&lt;/code&gt; in the search string I think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers?&lt;/p&gt;&#xA;" OwnerUserId="2572" LastEditorUserId="24" LastEditDate="2015-06-25T05:11:32.350" LastActivityDate="2015-06-25T05:11:32.350" Title="Insert a pattern before another one" Tags="|regular-expression|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3681" PostTypeId="1" AcceptedAnswerId="3693" CreationDate="2015-06-24T13:53:49.170" Score="5" ViewCount="1893" Body="&lt;p&gt;On MS Windows using gVim, is it possible to select several files from the explorer and open them in the same instance of gVim in different buffers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment if I select 3 different files on Windows graphical explorer and press &lt;kbd&gt;enter&lt;/kbd&gt; they get open in 3 different instances of gVim. What I want is to open them in the same instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I work on linux and I want to edit all the files of a directory with vim I can simply from command line do the folowing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim ./*.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will open all the files in the same instance of vim in different buffers. I'm looking for a way to do the same but from Windows GUI with gVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 1:&lt;/strong&gt; Using MS Windows command line is not an option here neither is using a cygwin console.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 2&lt;/strong&gt;: I know that I can open only one file and then, from gVim open the others but that would be slower than simply openning them all in one time from GUI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 3 (edit):&lt;/strong&gt; Out of curiosity I just tried to do it on a Debian Jessie with a gVim 7.3 and it worked as I want (one instance - several buffers) out of the box with the same &lt;code&gt;.vimrc&lt;/code&gt; as the one of the windows machine (without any &lt;code&gt;.gvimrc&lt;/code&gt; file). So I deduce that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It is possible to do what I want.&lt;/li&gt;&#xA;&lt;li&gt;The behavior of gVim depends on the OS running it which is a little bit disturbing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-06-25T07:59:09.977" LastActivityDate="2016-02-16T12:49:38.830" Title="Gvim how to open several files in different buffers from MS Windows explorer" Tags="|gvim|microsoft-windows|filesystem|multiple-files|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3682" PostTypeId="1" CreationDate="2015-06-24T14:00:06.827" Score="8" ViewCount="2937" Body="&lt;p&gt;One of my friend told me that I can use the trick below to remove a pair of curly brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the cursor inside the curly bracket pair you want to remove.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;y&lt;/kbd&gt; &lt;kbd&gt;i&lt;/kbd&gt; &lt;kbd&gt;{&lt;/kbd&gt; to yank the text in braces , then &lt;kbd&gt;v&lt;/kbd&gt; &lt;kbd&gt;a&lt;/kbd&gt; &lt;kbd&gt;{&lt;/kbd&gt; then paste &lt;kbd&gt;p&lt;/kbd&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works well like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; s.length(); i++) {&#xA;        int index = s[i] - c;&#xA;        if(root-&amp;gt;next[index] == NULL)&#xA;            root-&amp;gt;next[index] = new TrieNode;&#xA;        root = root-&amp;gt;next[index];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After execute the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; s.length(); i++)&#xA;    int index = s[i] - c;&#xA;    if(root-&amp;gt;next[index] == NULL)&#xA;        root-&amp;gt;next[index] = new TrieNode;&#xA;    root = root-&amp;gt;next[index];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;until I met this situation(The space before the first curly bracket is missing).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; s.length(); i++){&#xA;        int index = s[i] - c;&#xA;        if(root-&amp;gt;next[index] == NULL)&#xA;            root-&amp;gt;next[index] = new TrieNode;&#xA;        root = root-&amp;gt;next[index];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After executing those commands the text block becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; s.length(); i++&#xA;        int index = s[i] - c;&#xA;        if(root-&amp;gt;next[index] == NULL)&#xA;            root-&amp;gt;next[index] = new TrieNode;&#xA;        root = root-&amp;gt;next[index];&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The area I select in the visual mode seems good, but why does the parentheses goes down?&lt;/p&gt;&#xA;" OwnerUserId="2573" LastEditorUserId="2573" LastEditDate="2015-06-25T14:20:28.113" LastActivityDate="2015-07-07T12:20:52.580" Title="How to simply remove braces" Tags="|cut-copy-paste|visual-mode|cursor-motions|macvim|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="3683" PostTypeId="1" CreationDate="2015-06-24T14:49:23.177" Score="11" ViewCount="3473" Body="&lt;p&gt;This might be more suitable for IDE, not for Vim, but still I would appreciate if there was a way that would allow me to connect to either local or remote MySQL/SQLite databases. Is there such a way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it could be placed in a split window or in its own tab. I would want to read, update, delete rows, import/export sql. Some advanced features like foreign keys could be, obviously, omitted.&lt;/p&gt;&#xA;" OwnerUserId="2530" LastEditorUserId="51" LastEditDate="2015-06-24T14:53:25.283" LastActivityDate="2022-05-16T10:54:03.127" Title="How can I interact with a SQLite or MySQL database?" Tags="|ide|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3685" PostTypeId="2" ParentId="3680" CreationDate="2015-06-24T15:37:03.100" Score="0" Body="&lt;p&gt;Why not just replace &lt;code&gt;pattern2&lt;/code&gt; by &lt;code&gt;\n&lt;/code&gt; &lt;code&gt;pattern1 pattern2&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/pattern2/\rpattern1 pattern2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or without repeating &lt;code&gt;pattern2&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(pattern2\)/\rpattern1 \1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both change  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pattern1 any text pattern2 any text pattern2 any text pattern2 any text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pattern1 any text &#xA;pattern1 pattern2 any text &#xA;pattern1 pattern2 any text &#xA;pattern1 pattern2 any text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="925" LastActivityDate="2015-06-24T15:37:03.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3686" PostTypeId="1" CreationDate="2015-06-24T16:35:51.250" Score="18" ViewCount="9636" Body="&lt;p&gt;Is there a quick way to copy the full path of current buffer to system clip board or some register? &lt;code&gt;:put=expand('%:p')&lt;/code&gt; then use other copy commands(like &lt;code&gt;dd&lt;/code&gt;) works but the typing is a little long.&lt;/p&gt;&#xA;" OwnerUserId="477" LastEditorUserId="477" LastEditDate="2015-06-24T17:22:23.510" LastActivityDate="2022-05-27T17:39:15.337" Title="Copy the full path of current buffer to clipboard" Tags="|register|os-clipboard|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3687" PostTypeId="2" ParentId="3686" CreationDate="2015-06-24T16:45:52.790" Score="28" Body="&lt;p&gt;You can assign to the clipboard with the special &lt;code&gt;+&lt;/code&gt; register:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:let @+ = expand('%:p')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;code&gt;:p&lt;/code&gt; makes it an absolute path; drop it if you want the relative path.&lt;/p&gt;&#xA;&lt;p&gt;If you want to make this easier, you could create a command, so you only have to type &lt;code&gt;:CopyBuffer&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:command! CopyBuffer let @+ = expand('%:p')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and/or map it to a key:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Leader&amp;gt;c :let @+=expand('%:p')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The post &amp;quot;&lt;a href=&quot;https://vi.stackexchange.com/a/96/51&quot;&gt;How can I copy text to the system clipboard from Vim?&lt;/a&gt;&amp;quot; has much more information on how to interface with the system's clipboard.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;:put=expand('%:p')&lt;/code&gt; works but the typing is a little long.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This doesn't copy the path of the buffer to the clipboard, but inserts it in the buffer...?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2022-05-27T17:39:15.337" LastActivityDate="2022-05-27T17:39:15.337" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3688" PostTypeId="2" ParentId="3682" CreationDate="2015-06-24T17:46:13.437" Score="6" Body="&lt;p&gt;Install the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1697&quot; rel=&quot;nofollow&quot;&gt;&quot;surround&quot; plugin&lt;/a&gt;. Then you can just do &lt;kbd&gt;d&lt;/kbd&gt; &lt;kbd&gt;s &lt;/kbd&gt; &lt;kbd&gt;B &lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the project page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Surround.vim is all about &quot;surroundings&quot;: parentheses, brackets, quotes, XML tags, and more. The plugin provides mappings to easily delete, change and add such surroundings in pairs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;ds&lt;/code&gt; followed by any text object (&lt;code&gt;B&lt;/code&gt; in this case, for &quot;Block&quot;, as in the &lt;code&gt;aB&lt;/code&gt; or &lt;code&gt;iB&lt;/code&gt; text object) will delete the surrounding characters that define the text object. Thus, &lt;kbd&gt;d&lt;/kbd&gt; &lt;kbd&gt;s &lt;/kbd&gt; &lt;kbd&gt;B &lt;/kbd&gt; in your case accomplishes what you wanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other commands include &lt;kbd&gt;c&lt;/kbd&gt; &lt;kbd&gt;s &lt;/kbd&gt; &lt;kbd&gt;B &lt;/kbd&gt; &lt;kbd&gt;b&lt;/kbd&gt;, if you wanted to &lt;em&gt;change&lt;/em&gt; the surrounding &lt;code&gt;{...}&lt;/code&gt; into &lt;code&gt;(...)&lt;/code&gt;, or &lt;kbd&gt;y&lt;/kbd&gt; &lt;kbd&gt;s &lt;/kbd&gt; &lt;em&gt;{any cursor motion or text object}&lt;/em&gt; &lt;kbd&gt;B &lt;/kbd&gt; to add surrounding &lt;code&gt;{...}&lt;/code&gt; to the text selected by the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the plugin page and documentation for more details.&lt;/p&gt;&#xA;" OwnerUserId="1094" LastEditorUserId="1094" LastEditDate="2015-06-24T20:01:57.327" LastActivityDate="2015-06-24T20:01:57.327" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3689" PostTypeId="2" ParentId="3665" CreationDate="2015-06-24T17:52:18.300" Score="4" Body="&lt;p&gt;As it was asked in the comment I'll leave here what I have done so far:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the solution suggested by @romainl in the comments which is using &lt;code&gt;&amp;lt;C-$&amp;gt;&lt;/code&gt; instead of &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;. That might not be the most elegant way but it works and I haven't found any drawback for the moment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it is important to also mention @lcd047's suggestion of using the option &lt;code&gt;langmap&lt;/code&gt;. From what I understood this option allows to map a character to another. For example I tried to put this &lt;code&gt;set langmap+=]$&lt;/code&gt; in my &lt;code&gt;vimrc&lt;/code&gt; to let vim replace &lt;code&gt;]&lt;/code&gt; with &lt;code&gt;$&lt;/code&gt; but I haven't been able to make this solution work I will update this answer if I manage to make the second solution work or if I find a better way.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-06-24T17:52:18.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3690" PostTypeId="2" ParentId="3682" CreationDate="2015-06-24T21:33:24.237" Score="6" Body="&lt;p&gt;Since you aren't asking for the cursor to be returned to its original position, &lt;code&gt;[{x]}x&lt;/code&gt; does the job. It's 6 characters long with two presses of &lt;kbd&gt;Shift&lt;/kbd&gt; but the principle is straightforward so it's easy to remember.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to go back to the original position, you can use &lt;code&gt;[{x``]}x``&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2015-06-24T21:33:24.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3691" PostTypeId="2" ParentId="3680" CreationDate="2015-06-24T21:57:57.630" Score="2" Body="&lt;p&gt;That answer works for plain text, but not for patterns - you can't have patterns in the replace string unless you use an evaluated expression \=.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've figured this out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/pattern2/\=&quot;\r&quot; . matchstr(getline('.'), 'pattern1') . submatch(0)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in my actual file, I'd use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pattern1 = .\{-}:  (everything up to the first colon)&#xA;pattern2 = \d\+ \a\+: (a date in the format dd mmm:)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;resulting in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\d\+ \a\+:/\=&quot;\r&quot; . matchstr(getline('.'), '.\{-}:') . submatch(0)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2572" LastActivityDate="2015-06-24T21:57:57.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3693" PostTypeId="2" ParentId="3681" CreationDate="2015-06-25T08:43:00.193" Score="4" Body="&lt;p&gt;By default gVim for Windows adds an option to the Explorer right-click menu that contains an option &lt;em&gt;Edit with single Vim&lt;/em&gt; when multiple files are selected and that works as expected, opening them in a single window. That doesn't handle pressing &lt;kbd&gt;Enter&lt;/kbd&gt; with multiple files selected though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a solution presented on the &lt;a href=&quot;http://vim.wikia.com/wiki/Launch_files_in_new_tabs_under_Windows&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim wiki&lt;/a&gt; though. In short, you need to modify the registry (using Registry Editor, &lt;code&gt;regedit.exe&lt;/code&gt;) so that the appropriate file associations call &lt;code&gt;gvim.exe&lt;/code&gt; with the &lt;code&gt;--remote-tab-silent&lt;/code&gt; option. Searching for any occurrences of the vim executable with a full path and &lt;code&gt;&quot;%1&quot;&lt;/code&gt; as a parameter and changing them to include that parameter before the &lt;code&gt;&quot;%1&quot;&lt;/code&gt; should do it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just did this and the only occurrence I found was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;HKEY_CLASSES_ROOT\Applications\gvim.exe\shell\edit\command&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See below for the key &lt;strong&gt;after&lt;/strong&gt; editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/CMxQS.png&quot; alt=&quot;gVim registry key&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the change was made, hitting &lt;kbd&gt;Enter&lt;/kbd&gt; with multiple files associated with gVim opened them all in the same session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You almost certainly need Administrator privileges to edit that registry key.&lt;/p&gt;&#xA;" OwnerUserId="2582" LastEditorUserId="51" LastEditDate="2015-06-25T08:49:00.743" LastActivityDate="2015-06-25T08:49:00.743" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3694" PostTypeId="1" AcceptedAnswerId="4077" CreationDate="2015-06-25T13:04:03.627" Score="22" ViewCount="8298" Body="&lt;p&gt;I would like to go to the file I just edited last and next kind of like MRU plugins do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:bnext&lt;/code&gt; and &lt;code&gt;:bprev&lt;/code&gt; works sometimes, but more often than not I just end up in some obscure file I don't remember editing and forced to fall back to MRU plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Ctrl-^&lt;/code&gt; swaps between two last files. What is the best way to navigate between more?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand it might be tricky but I would agree to anything that can improve current &lt;code&gt;:bn&lt;/code&gt; &lt;code&gt;:bp&lt;/code&gt; behavior. The buffers I often see are totally out of place. Maybe there is a plugin that can keep track of the recent files and provide hooks so I can create mappings?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replying to comments cleared up my thoughts a bit. I believe what I want is to be able to move through files in order of latest saves. That way if I go back in history the order won't change until I save the file which then becomes last and make one step &quot;back&quot; to the file saved right before that, i.e. the one I've started from. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like &lt;code&gt;Ctrl-O&lt;/code&gt; &lt;code&gt;Ctrl-I&lt;/code&gt; pair that switches files immediately without jumping around the current buffer. Sort of like &lt;code&gt;u&lt;/code&gt; and &lt;code&gt;U&lt;/code&gt; in &lt;code&gt;netrw&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;u   Change to recently-visited directory                 |netrw-u|&#xA;U   Change to subsequently-visited directory             |netrw-U|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="237" LastEditorUserId="18609" LastEditDate="2020-04-19T20:42:22.243" LastActivityDate="2020-04-19T20:42:22.243" Title="Is there a way to reliably go back and forth in file history" Tags="|buffers|multiple-files|" AnswerCount="4" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="3696" PostTypeId="1" CreationDate="2015-06-25T14:55:37.160" Score="5" ViewCount="198" Body="&lt;p&gt;I have some strange troubles with opening an url in vim. Judging from this &lt;a href=&quot;https://stackoverflow.com/a/3153102/1423473&quot;&gt;answer&lt;/a&gt;, this should be pretty easy, but when I'm doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim http://www.ietf.org/rfc/rfc7386.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I getting a message&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!links 'http://www.ietf.org/rfc/rfc7386.txt' -source &amp;gt; '/tmp/vmEga7/1.txt'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and empty buffer (there is no &lt;code&gt;/tmp/vmEga7/1.txt&lt;/code&gt; file also). I don't fully understand, where I should look for the options that are related to the &lt;code&gt;links&lt;/code&gt; (some vim options, xdg configuration, etc.) - probably someone know about this and can explain it to me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD&lt;/strong&gt; I'm trying to debug this problem&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -V20vimlog http://www.ietf.org/rfc/rfc7386.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;a href=&quot;https://gist.githubusercontent.com/erthalion/7f53f268d2d2c5b90ce3/raw/66688a36cc353d98099d7d3c82e140bef3e85d88/vimlog&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; is the part of vimlog. Is this line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function netrw#Nread..netrw#NetRead..&amp;lt;SNR&amp;gt;24_FileReadable returning #1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;means, that resulting temporary file isn't readable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD&lt;/strong&gt; I'm still struggling with this trouble, no luck. It's strange, but the same is perfectly working in NeoVim. I figured out, that everything is ok about temporary files (they are created well and are readable). It looks like temporary file should be opened here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   &quot; edit temporary file (ie. read the temporary file in)&#xA;   if     rfile =~ '\.zip$'&#xA;&quot;    call Decho(&quot;handling remote zip file with zip#Browse(tfile&amp;lt;&quot;.tfile.&quot;&amp;gt;)&quot;)&#xA;    call zip#Browse(tfile)&#xA;   elseif rfile =~ '\.tar$'&#xA;&quot;    call Decho(&quot;handling remote tar file with tar#Browse(tfile&amp;lt;&quot;.tfile.&quot;&amp;gt;)&quot;)&#xA;    call tar#Browse(tfile)&#xA;   elseif rfile =~ '\.tar\.gz$'&#xA;&quot;    call Decho(&quot;handling remote gzip-compressed tar file&quot;)&#xA;    call tar#Browse(tfile)&#xA;   elseif rfile =~ '\.tar\.bz2$'&#xA;&quot;    call Decho(&quot;handling remote bz2-compressed tar file&quot;)&#xA;    call tar#Browse(tfile)&#xA;   elseif rfile =~ '\.tar\.xz$'&#xA;&quot;    call Decho(&quot;handling remote xz-compressed tar file&quot;)&#xA;    call tar#Browse(tfile)&#xA;   elseif rfile =~ '\.txz$'&#xA;&quot;    call Decho(&quot;handling remote xz-compressed tar file (.txz)&quot;)&#xA;    call tar#Browse(tfile)&#xA;   else&#xA;&quot;    call Decho(&quot;edit temporary file&quot;)&#xA;    NetrwKeepj e!&#xA;   endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when control flow reaches line &lt;code&gt;NetrwKeepj e!&lt;/code&gt; nothing is happening.&lt;/p&gt;&#xA;" OwnerUserId="30" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-06-27T18:18:18.007" Title="Cannot open an url (empty buffer)" Tags="|invocation|netrw|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3697" PostTypeId="1" CreationDate="2015-06-25T15:05:48.363" Score="4" ViewCount="1031" Body="&lt;p&gt;When writing a Vim help file, it's often useful to set the &lt;code&gt;filetype&lt;/code&gt; to &lt;code&gt;help&lt;/code&gt;&#xA;to show syntax highlighting and such.&#xA;But I find this annoying to work with when editing the document due to the&#xA;&quot;concealed&quot; characters; my cursor behaves in &quot;strange&quot; ways and I often remove&#xA;the concealed characters by accident.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I now set the &lt;code&gt;filetype&lt;/code&gt; to &lt;code&gt;text&lt;/code&gt; before editing, and setting it back again to&#xA;&lt;code&gt;help&lt;/code&gt; when I want to check if my changed are valid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to do this automatically. I know I can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter *.txt setlocal filetype=txt&#xA;autocmd InsertLeave *.txt setlocal filetype=help&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how can I do this &lt;em&gt;only&lt;/em&gt; for help files and not other &lt;code&gt;.txt&lt;/code&gt; files?&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-06-30T15:19:47.107" Title="How can I switch to filetype=txt when entering insert mode for Vim help files?" Tags="|autocmd|help-system|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3698" PostTypeId="2" ParentId="3697" CreationDate="2015-06-25T15:05:48.363" Score="8" Body="&lt;h1&gt;Asked: Setting the filetype&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The autocommands in the question are a good start, and with 2 extra pieces of&#xA;knowledge we can finish it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You can define autocommands everywhere. &lt;code&gt;autocmd&lt;/code&gt; and &lt;code&gt;augroup&lt;/code&gt; are &quot;just&quot;&#xA;regular Vim commands, not special syntax or keywords. So defining an autocmd&#xA;from &lt;em&gt;within an autocmd&lt;/em&gt; is perfectly fine.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can define autocommands to be buffer-local (see: &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#E680&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help autocmd-buffer-local&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Armed with this information, the solution is fairly easy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup help_start&#xA;    autocmd!&#xA;    autocmd FileType help call SetHelpFiletype()&#xA;augroup end&#xA;&#xA;fun! SetHelpFiletype()&#xA;    augroup help_insert&#xA;        autocmd!&#xA;        autocmd InsertEnter &amp;lt;buffer&amp;gt; setlocal filetype=txt&#xA;        autocmd InsertLeave &amp;lt;buffer&amp;gt; setlocal filetype=help&#xA;    augroup end&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used a function here since nesting multiple &lt;code&gt;augroup&lt;/code&gt;s inline does seem to be&#xA;problematic (the first &lt;code&gt;augroup end&lt;/code&gt; seems to end &lt;em&gt;both&lt;/em&gt; groups; you can opt to&#xA;not use an &lt;code&gt;augroup&lt;/code&gt; for the inner &lt;code&gt;autocmd&lt;/code&gt;s, but this can lead to them being&#xA;executed multiple times after reloading the vimrc file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need a modeline which sets the &lt;code&gt;filetype&lt;/code&gt;. It's pretty much standard to&#xA;add a modeline to the end of Vim help files, so this is probably already&#xA;present:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim:tw=78:ts=8:ft=help:norl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Better: configuring concealed characters&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;There is another (probably better) way to solve this problem: by showing the&#xA;concealed characters in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ftplugin for help files does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal conceallevel=2 concealcursor=nc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;conceallevel=2&lt;/code&gt; tells Vim to actual conceal characters which are marked as&#xA;such, but &lt;code&gt;concealcursor=nc&lt;/code&gt; tells Vim to conceal the characters &lt;em&gt;only&lt;/em&gt; in&#xA;normal and cmdline mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this still confusing:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The characters don't show up very clearly as they are still hidden due to the&#xA;syntax highlighting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight helpBar&#xA;helpBar        xxx links to Ignore&#xA;&#xA;:highlight Ignore&#xA;Ignore         xxx ctermfg=15 guifg=bg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;15&lt;/code&gt; is &lt;code&gt;white&lt;/code&gt;, which is my terminal's background colour (this always&#xA;matches your terminal's background colour).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Only the characters for the current line show up. This can be considered both&#xA;a feature and a bug, but I don't like it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;We can fix this with:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;:highlight clear Ignore&lt;/code&gt;. This will clear the syntax highlighting for&#xA;the &lt;code&gt;Ignore&lt;/code&gt; group.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Tell Vim to set &lt;code&gt;conceallevel&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt; (always show all concealed characters)&#xA;when entering insert mode.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Putting this together, we end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup help_start&#xA;    autocmd!&#xA;    autocmd FileType help call SetHelpFiletype()&#xA;augroup end&#xA;&#xA;fun! SetHelpFiletype()&#xA;    augroup help_insert&#xA;        autocmd!&#xA;        autocmd InsertEnter &amp;lt;buffer&amp;gt; setlocal conceallevel=0 | highlight clear Ignore&#xA;        autocmd InsertLeave &amp;lt;buffer&amp;gt; setlocal conceallevel=2&#xA;    augroup end&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will show the formatting characters, &lt;em&gt;and&lt;/em&gt; still shows the syntax&#xA;highlighting in insert mode. In normal mode, it will show the help file as the&#xA;user sees it when reading it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method is also also a bit faster than setting the filetype since Vim&#xA;doesn't have to source a bunch of filetype/syntax files.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Preview split&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;(With thanks to @PeterRincker's comment).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;conceallevel&lt;/code&gt; is a window local setting. This means you can easily use splits. One for editing with &lt;code&gt;set conceallevel=0&lt;/code&gt; and the other window with the default &lt;code&gt;set conceallevel=2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is especially useful in combination with &lt;a href=&quot;https://vi.stackexchange.com/q/2266/51&quot;&gt;How can I get both splits to scroll left or right at the same time?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create a command to show a &quot;preview split&quot; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! HelpPreview setlocal scrollbind | split | setlocal conceallevel=0 | highlight clear Ignore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-06-26T09:00:35.947" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3699" PostTypeId="1" AcceptedAnswerId="3702" CreationDate="2015-06-25T15:08:46.187" Score="13" ViewCount="11775" Body="&lt;p&gt;I've set up a bunch of key mappings that would cause many Vim users to cringe. Now I am unable to get into Visual Block mode using Ctrl-V (Ctrl-Q isn't mapped, but it doesn't work). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any command that I can type to enter Visual Block mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I could set something up so that &lt;code&gt;:vb&lt;/code&gt; would enter visual block mode.&lt;/p&gt;&#xA;" OwnerUserId="2276" LastEditorUserId="7161" LastEditDate="2016-05-02T10:05:47.877" LastActivityDate="2016-05-02T10:05:47.877" Title="Is there a command to enter Visual Block mode?" Tags="|key-bindings|visual-mode|user-commands|visual-block|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3700" PostTypeId="2" ParentId="3696" CreationDate="2015-06-25T15:16:23.690" Score="4" Body="&lt;p&gt;I get a different result when I go this: the buffer consists of garbled text (gziped?). Perhaps your version of &lt;code&gt;links&lt;/code&gt; and/or &lt;code&gt;vim&lt;/code&gt; does something different with gzip-encoded text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Netrw, the plugin bundled with Vim which reads URLs tries a bunch of different commands to get the source of a page, but you can also set it explicitly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to set it to &lt;code&gt;curl&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Command name&#xA;let g:netrw_http_cmd = 'curl'&#xA;&#xA;&quot; Arguments passed to the command&#xA;let g:netrw_http_xcmd = '-o'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can try &lt;code&gt;wget&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_http_cmd = 'wget'&#xA;let g:netrw_http_xcmd = '-q -O'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;code&gt;:help g:netrw_http_cmd&lt;/code&gt; and &lt;code&gt;:help g:netrw_http_xcmd&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-06-25T15:28:26.370" LastActivityDate="2015-06-25T15:28:26.370" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3701" PostTypeId="2" ParentId="3699" CreationDate="2015-06-25T15:27:07.980" Score="10" Body="&lt;p&gt;As far as I can find, there is no built-in command to start visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can easily add these commands to Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! Visual      normal! v&#xA;:command! VisualLine  normal! V&#xA;:command! VisualBlock execute &quot;normal! \&amp;lt;C-v&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can change the names of these commands to whatever you want, but all user-defined commands &lt;em&gt;must&lt;/em&gt; start with an upper-case letter (so you can't use &lt;code&gt;:vb&lt;/code&gt;, but &lt;code&gt;:Vb&lt;/code&gt; is okay).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-06-25T15:27:07.980" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3702" PostTypeId="2" ParentId="3699" CreationDate="2015-06-25T15:36:31.010" Score="18" Body="&lt;p&gt;There is no built in command to start visual block mode in vim, but you can define one yourself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Vb normal! &amp;lt;C-v&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a breakdown of how it works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;command! Vb&lt;/code&gt; - This creates a command called &quot;Vb&quot;.  The &lt;code&gt;!&lt;/code&gt; after &lt;code&gt;command&lt;/code&gt; means that vim will not throw an error if the command is already defined.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal! &amp;lt;C-v&amp;gt;&lt;/code&gt; - This command tells vim to take all characters after it and act like you had pressed them in normal mode.  The &lt;code&gt;!&lt;/code&gt; makes it so that all user defined mappings are ignored.  This means that if &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; is mapped to something else, it will still work the way it does by default.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here are some relevant help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :command&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :normal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;NOTE&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;User defined commands must start with a capital letter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, there may be a conflicting mapping which prevents you from using &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; to enter visual block mode.  To check for any conflicting mappings for &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;, you can run &lt;code&gt;:verbose map &amp;lt;C-v&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-11-28T22:45:47.017" LastActivityDate="2015-11-28T22:45:47.017" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3703" PostTypeId="1" CreationDate="2015-06-25T19:37:39.733" Score="6" ViewCount="101" Body="&lt;p&gt;Why does using &lt;code&gt;:split&lt;/code&gt; and &lt;code&gt;:Explore&lt;/code&gt; cause the filetype to change?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, edit a file named &lt;code&gt;text.man&lt;/code&gt;, and the filetype is set to &lt;code&gt;man&lt;/code&gt;.  Change the filetype to &lt;code&gt;txt&lt;/code&gt;, then &lt;code&gt;:split&lt;/code&gt; and &lt;code&gt;:Explore&lt;/code&gt; in the new window.  The filetype in the original window changes back to &lt;code&gt;man&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also occurs when using &lt;code&gt;:Sexplore&lt;/code&gt; rather than separate &lt;code&gt;:split&lt;/code&gt; and &lt;code&gt;:Explore&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It only seems to happen once.  If I close the explore window, set the filetype back to &lt;code&gt;txt&lt;/code&gt;, then &lt;code&gt;:split&lt;/code&gt; and &lt;code&gt;:Explore&lt;/code&gt; again, the filetype remains set to &lt;code&gt;txt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2588" LastActivityDate="2015-06-25T19:37:39.733" Title="Filetype changes when using :split and :Explore" Tags="|split|filetype|netrw|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3704" PostTypeId="1" AcceptedAnswerId="3706" CreationDate="2015-06-26T03:31:44.550" Score="4" ViewCount="229" Body="&lt;p&gt;I'm trying to set a custom &lt;code&gt;breakat&lt;/code&gt; for plain text files. Aiming for a very small set of characters -- just hyphens, slashes, and whitespace. That means I need to add tabs, which I do by setting &lt;code&gt;breakat+=^I&lt;/code&gt;. (Right?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first, I didn't understand how control characters worked, and appended &lt;code&gt;^&lt;/code&gt; &lt;code&gt;I&lt;/code&gt; to my &lt;code&gt;breakat&lt;/code&gt; value. Naturally, as a result, my files started breaking at capital I's. -_-'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So then I went digging, and found &lt;a href=&quot;http://dailyvim.blogspot.tw/2009/10/ctrl-v-for-literal-characters.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;: &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; followed by any control key should produce the literal control character. Great! Except it seems to work on all the control characters I've tried &lt;em&gt;except&lt;/em&gt; &lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; (which prints a regular tab, rather than &lt;code&gt;^I&lt;/code&gt; with the special/bolded syntax highlighting I see for other literal control characters). What gives?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I thought maybe it was because various plugins map &lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; to lots of things, so I moved my &quot;bundle&quot; folder elsewhere, reloaded vim, and tried again! Still no luck.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it helps/matters, I'm running gVim 7.4 on Windows. I also found &lt;a href=&quot;https://stackoverflow.com/a/4781099/4865822&quot;&gt;this&lt;/a&gt;, but &lt;code&gt;&amp;lt;C-q&amp;gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; doesn't do it, either.&lt;/p&gt;&#xA;" OwnerUserId="2593" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-06-26T08:22:03.663" Title="&lt;C-v&gt; &lt;C-i&gt; not working to print literal tab!" Tags="|insert-mode|tab-characters|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3705" PostTypeId="1" AcceptedAnswerId="3707" CreationDate="2015-06-26T05:18:48.190" Score="1" ViewCount="1569" Body="&lt;p&gt;I using solarized in both terminal.app and vim, but in vim the background, airline and other things are not the color scheme's appearance which is different with MacVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how to deal with it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried iTerm2 and it is the same result in terminal.app.&lt;/p&gt;&#xA;" OwnerUserId="2514" LastEditorUserId="51" LastEditDate="2015-06-26T08:07:54.227" LastActivityDate="2015-06-26T08:07:54.227" Title="solarized in xterm256(terminal.app) has wrong background" Tags="|terminal|colorscheme|plugin-solarized|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3706" PostTypeId="2" ParentId="3704" CreationDate="2015-06-26T06:07:12.453" Score="2" Body="&lt;p&gt;You can do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;breakat = &quot;-/ \t&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set&lt;/code&gt; syntax is weird, you probably want to avoid it if possible.  Fortunately &lt;code&gt;set option=...&lt;/code&gt; is equivalent to &lt;code&gt;let &amp;amp;option = ...&lt;/code&gt;, and &lt;code&gt;let&lt;/code&gt; syntax is nicer.  In particular &lt;code&gt;let&lt;/code&gt; allows you to use full expressions as values, such as the above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a related topic, &lt;code&gt;setlocal option=...&lt;/code&gt; is equivalent to &lt;code&gt;let &amp;amp;l:option = ...&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-06-26T06:07:12.453" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3707" PostTypeId="2" ParentId="3705" CreationDate="2015-06-26T07:01:01.003" Score="5" Body="&lt;p&gt;&lt;a href=&quot;http://ethanschoonover.com/solarized/vim-colors-solarized&quot; rel=&quot;noreferrer&quot;&gt;http://ethanschoonover.com/solarized/vim-colors-solarized&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;IMPORTANT NOTE FOR TERMINAL USERS:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are going to use Solarized in Terminal mode (i.e. not in a GUI version like gvim or macvim), &lt;strong&gt;please please please&lt;/strong&gt; consider setting your terminal emulator’s colorscheme to use the Solarized palette. I’ve included palettes for some popular terminal emulator as well as Xdefaults in the official Solarized download available from Solarized homepage. If you use Solarized without these colors, Solarized will need to be told to degrade its colorscheme to a set compatible with the limited 256 terminal palette (whereas by using the terminal’s 16 ansi color values, you can set the correct, specific values for the Solarized palette).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do use the custom terminal colors, solarized.vim should work out of the box for you. If you are using a terminal emulator that supports 256 colors and don’t want to use the custom Solarized terminal colors, you will need to use the degraded 256 colorscheme. To do so, simply add the following line before the colorschem solarized line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:solarized_termcolors=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, I recommend just changing your terminal colors to Solarized values either manually or via one of the many terminal schemes available for import.&lt;/p&gt;&#xA;" OwnerUserId="1145" LastEditorUserId="1577" LastEditDate="2015-06-26T07:05:15.403" LastActivityDate="2015-06-26T07:05:15.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3708" PostTypeId="2" ParentId="3683" CreationDate="2015-06-26T07:16:49.937" Score="1" Body="&lt;p&gt;I'm myself trying to work it out these days. I think &lt;a href=&quot;https://github.com/vim-scripts/dbext.vim&quot; rel=&quot;nofollow&quot;&gt;dbext&lt;/a&gt; might help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find many third-parties from &lt;a href=&quot;https://github.com/vim-scripts&quot; rel=&quot;nofollow&quot;&gt;vim-scripts&lt;/a&gt; on GitHub.&lt;/p&gt;&#xA;" OwnerUserId="1788" LastActivityDate="2015-06-26T07:16:49.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3709" PostTypeId="2" ParentId="3704" CreationDate="2015-06-26T08:06:39.190" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm running gVim 7.4 on Windows.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-V&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help i_CTRL-V&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: When &lt;code&gt;CTRL-V&lt;/code&gt; is mapped (e.g., to paste text) you can often use &lt;code&gt;CTRL-Q&lt;/code&gt; instead &lt;code&gt;i_CTRL-Q&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/gui_w32.txt.html#mswin.vim&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;mswin.vim&lt;/code&gt;&lt;/a&gt; maps &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; to paste text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, using &lt;code&gt;\t&lt;/code&gt; as suggested by lcd047 is probably better here, since it's more readable and easier to edit.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-06-26T08:22:03.663" LastActivityDate="2015-06-26T08:22:03.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3710" PostTypeId="1" CreationDate="2015-06-26T09:39:38.200" Score="7" ViewCount="1337" Body="&lt;p&gt;In my vimrc I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F4&amp;gt; :SyntasticToggleMode&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I also have the &lt;a href=&quot;https://github.com/chrisbra/unicode.vim&quot; rel=&quot;noreferrer&quot;&gt;unicode.vim&lt;/a&gt; plugin installed, which overrides this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !hasmapto('&amp;lt;Plug&amp;gt;(MakeDigraph)', 'n')&#xA;    nmap &amp;lt;F4&amp;gt; &amp;lt;Plug&amp;gt;(MakeDigraph)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I &quot;fixed&quot; this by doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F13&amp;gt; &amp;lt;Plug&amp;gt;(MakeDigraph)&#xA;vnoremap &amp;lt;F13&amp;gt; &amp;lt;Plug&amp;gt;(MakeDigraph)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;&amp;lt;F13&amp;gt;&lt;/code&gt; is a key I happen to not use... But this is obviously fragile and doesn't scale well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-06-26T11:06:14.990" Title="How can I prevent plugins from overwriting my key mappings?" Tags="|key-bindings|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3711" PostTypeId="1" AcceptedAnswerId="3712" CreationDate="2015-06-26T10:25:25.527" Score="4" ViewCount="2243" Body="&lt;p&gt;I usually exit vim to open other files, I know it is not productive and I want to avoid it. I want to use &lt;em&gt;netrw&lt;/em&gt; instead to open the files I want. Is there any way to prevent me from exiting vim, using &lt;code&gt;:x&lt;/code&gt;, &lt;code&gt;:wq&lt;/code&gt; and others ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found out &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1072&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; script but it requires a graphical vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot recompile vim. Below I've included version information:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb  4 2012 09:50:29)&#xA;Included patches: 1-108&#xA;Compiled by 'http://www.opensuse.org/'&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent &#xA;-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments &#xA;+cryptv +cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic &#xA;+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path &#xA;+float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand &#xA;+jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap &#xA;+menu +mksession +modify_fname +mouse -mouseshape +mouse_dec -mouse_gpm &#xA;-mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte &#xA;+multi_lang -mzscheme -netbeans_intg -osfiletype +path_extra -perl +postscript &#xA;+printer +profile -python +quickfix +reltime +rightleft -ruby +scrollbind &#xA;+signs +smartindent +sniff +statusline -sun_workshop +syntax +tag_binary &#xA;+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title&#xA; -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo &#xA;+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp&#xA; -xterm_clipboard -xterm_save &#xA;   system vimrc file: &quot;/etc/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/etc&quot;&#xA; f-b for $VIMRUNTIME: &quot;/usr/share/vim/current&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe -fno-strict-aliasing -fstack-protector-all        &#xA;Linking: gcc   -L/usr/local/lib -o vim       -lm -lncurses -lacl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1262" LastEditorUserId="24" LastEditDate="2015-06-27T16:18:25.153" LastActivityDate="2015-06-27T16:18:25.153" Title="How do I avoid exiting vim to open a new file?" Tags="|quit|habit-breaking|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3712" PostTypeId="2" ParentId="3711" CreationDate="2015-06-26T10:39:20.673" Score="7" Body="&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I created a &lt;a href=&quot;http://code.arp242.net/confirm_quit.vim&quot;&gt;confirm_quit.vim&lt;/a&gt; plugin; it has some additional options, like only asking for confirmation when quiting the last buffer (rather than closing &lt;em&gt;any&lt;/em&gt; buffer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will leave the below code as-is because it demonstrates how you can achieve something like this in a simple way, but I recommend you use the code from the link :-)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update2&lt;/strong&gt;: After re-reading your post and reading &lt;em&gt;statox&lt;/em&gt;'s answer, I had another idea; instead of asking for confirmation, why not run &lt;code&gt;:Explore&lt;/code&gt; when using &lt;code&gt;:q&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My plugin now supports this with the &lt;code&gt;confirm_quit#command()&lt;/code&gt; function. It's not mapped by default (this would be too surprising), but you can map it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:confirm_quit_nomap = 1&#xA;cnoremap &amp;lt;silent&amp;gt; x&amp;lt;CR&amp;gt;  :call confirm_quit#confirm(1, 'last')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; ZZ     :call confirm_quit#confirm(1, 'last')&amp;lt;CR&amp;gt;&#xA;cnoremap &amp;lt;silent&amp;gt; q&amp;lt;CR&amp;gt;  :call confirm_quit#command(0, 'last', 'Explore')&amp;lt;CR&amp;gt;&#xA;cnoremap &amp;lt;silent&amp;gt; wq&amp;lt;CR&amp;gt; :call confirm_quit#command(1, 'last', 'Explore')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;confirm_quit#command()&lt;/code&gt; for some more information.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original&lt;/strong&gt;: The &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1072&quot;&gt;script you link to&lt;/a&gt; also works without a GUI. The only reason it doesn't is because it's wrapped in &lt;code&gt;&quot;if has(&quot;gui_running&quot;)&lt;/code&gt;...&lt;br&gt;&#xA;I'm not sure why the author thinks this only runs with gVim; perhaps he was confused/mistaken, or perhaps something changed in Vim in the 11 years since that plugin was published.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a modified version which works in terminal Vim. It also fixes a bug where &lt;code&gt;:wq&lt;/code&gt; didn't work, I added a mapping for &lt;code&gt;ZZ&lt;/code&gt;, and made a few small improvements.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ConfirmQuit(writeFile)&#xA;    if (a:writeFile)&#xA;        if expand('%') == ''&#xA;            echohl ErrorMsg | echomsg 'E32: No file name' | echohl None&#xA;            return&#xA;        endif&#xA;        write&#xA;    endif&#xA;&#xA;    let l:confirmed = confirm('Do you really want to quit?', &quot;&amp;amp;Yes\n&amp;amp;No&quot;, 2)&#xA;    if l:confirmed == 1&#xA;        quit&#xA;    endif&#xA;endfun&#xA;&#xA;cnoremap &amp;lt;silent&amp;gt; q&amp;lt;CR&amp;gt;  :call ConfirmQuit(0)&amp;lt;CR&amp;gt;&#xA;cnoremap &amp;lt;silent&amp;gt; wq&amp;lt;CR&amp;gt; :call ConfirmQuit(1)&amp;lt;CR&amp;gt;&#xA;cnoremap &amp;lt;silent&amp;gt; x&amp;lt;CR&amp;gt;  :call ConfirmQuit(1)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; ZZ     :call ConfirmQuit(1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also add more commands if you want (such as &lt;code&gt;:quit&lt;/code&gt;, &lt;code&gt;:q!&lt;/code&gt;, etc.)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-06-26T13:18:55.350" LastActivityDate="2015-06-26T13:18:55.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3713" PostTypeId="2" ParentId="3710" CreationDate="2015-06-26T11:06:14.990" Score="2" Body="&lt;p&gt;There is no good solution, at least as far as I know.  Well-written plugins allow you to configure their key combinations.  But if a plugin really doesn't &quot;cooperate&quot;, there isn't much you can do to stop it from hogging the keys it wants.  At best you can wait for it to do its thing, then re-assign its keys to something else from some &lt;code&gt;after&lt;/code&gt; file, or after it has finished loading.  But re-assigning keys isn't always possible, since some maps reference &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; and other file-scoped symbols, and there may not be any global symbol to hook to.  There is no equivalent of &lt;code&gt;lockvar&lt;/code&gt; for key maps.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-06-26T11:06:14.990" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3714" PostTypeId="2" ParentId="3711" CreationDate="2015-06-26T12:08:41.310" Score="2" Body="&lt;p&gt;&lt;em&gt;&#xA;Edit: Maybe I didn't understood your question correctly in the first place: I thought you didn't know how to access new files an open them but actually the script you're linking in your question is about exiting vim when you don't want to so my answer might be totally off topic. If it's the case let me know and I'll just delete it :-)&#xA;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A plugin which is pretty convenient for what you want to do is &lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot; rel=&quot;nofollow&quot;&gt;nerdTree Explorer&lt;/a&gt;. You can install it just like any other plugin &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the readme the author advise to use &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow&quot;&gt;pathogen&lt;/a&gt;, I used &lt;a href=&quot;https://github.com/gmarik/Vundle.vim&quot; rel=&quot;nofollow&quot;&gt;Vundle&lt;/a&gt; which works really good, you simply need to had the following line to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'scrooloose/nerdtree'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This plugin allows you to open a split windows into vim which contains a file explorer similar to a GUI explorer. Once it is installed you can open the explorer with the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:NERDTree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Personnaly I added the following line in my vimrc to open the explorer with &lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Leader&amp;gt;o :NERDTree &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once in the window you can navigate in the files with &lt;kbd&gt;j&lt;/kbd&gt; and &lt;kbd&gt;k&lt;/kbd&gt;. The parents directories are accessibles via the line &lt;code&gt;..&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To open a file simply use &lt;kbd&gt;Enter&lt;/kbd&gt; to open it in a new buffer or &lt;kbd&gt;s&lt;/kbd&gt; to open it in a vertical split windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Ones might say that NerdTree doesn't follow the workflow of vim and might prefer &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;nofollow&quot;&gt;ctrlp&lt;/a&gt; but NerdTree is easier to use for a debutant in my opnion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 2:&lt;/strong&gt; Using netrw as you mentionned is also a good option since it is a built-in vim feature but I'm not familiar enough with it to help you using it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-06-26T12:26:20.543" LastActivityDate="2015-06-26T12:26:20.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3715" PostTypeId="2" ParentId="3694" CreationDate="2015-06-26T13:46:58.070" Score="7" Body="&lt;p&gt;You can use &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Als&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:ls&lt;/code&gt;&lt;/a&gt; to show all buffers. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls&#xA;  1      &quot;vim.markdown&quot;                 line 160&#xA;  2      &quot;ext.markdown&quot;                 line 0&#xA;  3 #    &quot;~/to&quot;                         line 1&#xA;  4 %a   &quot;~/TODO&quot;                       line 68&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To go back to buffer &lt;code&gt;ext.markdown&lt;/code&gt;, use &lt;code&gt;:e +Nbuf&lt;/code&gt;, where &lt;code&gt;N&lt;/code&gt; is the buffer number from the first column. For example: &lt;code&gt;:e +2buf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create a simple function for a more interactive experience:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ChooseBuf()&#xA;    redir =&amp;gt; buffers&#xA;        silent ls&#xA;    redir end&#xA;&#xA;    echo l:buffers&#xA;    let l:choice = input('Which one: ')&#xA;    execute ':edit +' . l:choice . 'buf'&#xA;endfun&#xA;command! ChooseBuf call ChooseBuf()&#xA;nnoremap &amp;lt;Leader&amp;gt;b :call ChooseBuf()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After using &lt;code&gt;:ChooseBuf&lt;/code&gt; or &lt;code&gt;&amp;lt;Leader&amp;gt;b&lt;/code&gt; you can just type the number of the buffer you want to edit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not &lt;em&gt;quite&lt;/em&gt; &quot;most recently used&quot;, since the order is &quot;most recently opened&quot; (this is probably also why &lt;code&gt;:bnext&lt;/code&gt;/&lt;code&gt;:bprev&lt;/code&gt; don't work as you expect).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-06-26T13:46:58.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3716" PostTypeId="1" AcceptedAnswerId="3717" CreationDate="2015-06-26T14:51:04.663" Score="8" ViewCount="1573" Body="&lt;p&gt;Some time ago I found an interesting trick on &lt;a href=&quot;https://github.com/thoughtstream/Damian-Conway-s-Vim-Setup/blob/master/.vimrc#L875-887&quot; rel=&quot;noreferrer&quot;&gt;Damian Conway's vimrc&lt;/a&gt; &#xA;which allows to open help files in new tabs instead of split windows. &#xA;The code is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Only apply to .txt files...&#xA;augroup HelpInTabs&#xA;    autocmd!&#xA;    autocmd BufEnter  *.txt   call HelpInNewTab()&#xA;augroup END&#xA;&#xA;&quot;Only apply to help files...&#xA;function! HelpInNewTab ()&#xA;    if &amp;amp;buftype == 'help' &amp;amp;&amp;amp; g:help_in_tabs&#xA;        &quot;Convert the help window to a tab...&#xA;        execute &quot;normal \&amp;lt;C-W&amp;gt;T&quot;&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course this piece of code works well but I'd like to improve it: I feel that opening the &#xA;help file into a new tab isn't that convenient and I rather open it into a new buffer and&#xA;give the focus on this buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm looking for a command which would replace this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal \&amp;lt;C-W&amp;gt;T&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and more precisely &lt;code&gt;&amp;lt;C-W&amp;gt;T&lt;/code&gt; to turn the window into a new buffer instead of a new tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I could find anything which could help me in the documentation. So is it possible?&#xA;And if it is, how can I do it?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2022-09-18T12:57:20.713" Title="Open help windows in new buffer instead of split windows" Tags="|vim-windows|help-system|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3717" PostTypeId="2" ParentId="3716" CreationDate="2015-06-26T15:55:37.873" Score="7" Body="&lt;p&gt;We can open help in the current window by &lt;code&gt;set buftype=help&lt;/code&gt; and then using the &lt;code&gt;:help&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have the following problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;restore the &lt;code&gt;'buftype'&lt;/code&gt; value of the previous buffer, &lt;code&gt;#&lt;/code&gt;, in the success case&lt;/li&gt;&#xA;&lt;li&gt;restore the &lt;code&gt;'buftype'&lt;/code&gt; value of the current buffer, &lt;code&gt;%&lt;/code&gt;, in the error case&lt;/li&gt;&#xA;&lt;li&gt;let the &lt;code&gt;:h&lt;/code&gt; error message through correctly&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:h&lt;/code&gt; command like so many of Vim's command will set &lt;code&gt;v:errmsg&lt;/code&gt; when an error messages occurs. This means we can detect the error message. However this will give a &quot;stack trace&quot; when used inside of a function. We can overcome this by suppressing the error via &lt;code&gt;:silent!&lt;/code&gt;. Now we can check &lt;code&gt;v:errmsg&lt;/code&gt; and restore &lt;code&gt;'buftype'&lt;/code&gt; correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you still want to keep the error message we will use &lt;code&gt;:execute&lt;/code&gt; in the &lt;code&gt;:command&lt;/code&gt; definition and have the function return the failed help command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the resulting code (Put this in your &lt;code&gt;vimrc&lt;/code&gt; file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:help(subject)&#xA;  let buftype = &amp;amp;buftype&#xA;  let &amp;amp;buftype = 'help'&#xA;  let v:errmsg = ''&#xA;  let cmd = &quot;help &quot; . a:subject&#xA;  silent! execute  cmd&#xA;  if v:errmsg != ''&#xA;    let &amp;amp;buftype = buftype&#xA;    return cmd&#xA;  else&#xA;    call setbufvar('#', '&amp;amp;buftype', buftype)&#xA;  endif&#xA;endfunction&#xA;command! -nargs=? -bar -complete=help H execute &amp;lt;SID&amp;gt;help(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This creates the &lt;code&gt;:H&lt;/code&gt; command which behave just like &lt;code&gt;:h&lt;/code&gt; except open in the same window.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Thoughts&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You may want to look into something like &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=746&quot; rel=&quot;noreferrer&quot;&gt;cmdallias.vim&lt;/a&gt; to make this command easier to type&lt;/li&gt;&#xA;&lt;li&gt;Maybe instead of all this trouble just promote the help window to its own tab via &lt;code&gt;&amp;lt;c-w&amp;gt;T&lt;/code&gt; (my preference)&lt;/li&gt;&#xA;&lt;li&gt;the technique will need to be adjusted to take into consideration if there is a different a window with &lt;code&gt;buftype=help&lt;/code&gt; already open&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;More help&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'buftype'&#xA;:h :h&#xA;:h :silent&#xA;:h v:errmsg&#xA;:h :exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-06-26T15:55:37.873" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3718" PostTypeId="1" AcceptedAnswerId="3720" CreationDate="2015-06-26T16:38:40.347" Score="4" ViewCount="1888" Body="&lt;p&gt;I am wondering how to resize the gVim application on Windows 7. For example, I want to grab the corner of the window with my mouse and resize the application so it takes up more space on my screen. Does anyone know how to do this? This question seems silly, but searching on Google just brings back results on resizing Vim windows and splits, not the Vim program as a whole.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using gVim 7.4 on Windows 7. When I start it up it is a very small window, not even 30 lines long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;gVim Easy lets me resize the application, but I don't want to use gVim Easy. &lt;/p&gt;&#xA;" OwnerUserId="1552" LastActivityDate="2015-07-08T17:17:22.170" Title="How to resize vim on Windows 7?" Tags="|gvim|microsoft-windows|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3719" PostTypeId="2" ParentId="3711" CreationDate="2015-06-26T16:40:32.253" Score="7" Body="&lt;p&gt;From your post it sounds like you have a problem of exiting Vim. You mention a plugin that may help, but lets get to the root of the problem which is you have a created &lt;em&gt;bad habit&lt;/em&gt;. As with all bad habits you need to break them. Maybe stick with using &lt;code&gt;:w&lt;/code&gt; to write files and using &lt;code&gt;:close&lt;/code&gt;/&lt;code&gt;&amp;lt;c-w&amp;gt;c&lt;/code&gt; to close windows until you fully break your habit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also mention wanting to open files with netrw. This is the easy part:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:Explore&lt;/code&gt; or &lt;code&gt;:E&lt;/code&gt; for short to open up netrw&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:edit&lt;/code&gt;/&lt;code&gt;:split&lt;/code&gt;/&lt;code&gt;:vsplit&lt;/code&gt;/... with a directory to open up a netrw buffer for that directory. e.g. &lt;code&gt;:e.&lt;/code&gt; to open the current working directory&lt;/li&gt;&#xA;&lt;li&gt;Make a mapping to &lt;a href=&quot;https://github.com/tpope/vim-vinegar&quot;&gt;make this easier&lt;/a&gt;. e.g. &lt;code&gt;nnoremap - :e %:h&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Nice &lt;a href=&quot;http://vimcasts.org/&quot;&gt;Vimcast&lt;/a&gt; episode on this: &lt;a href=&quot;http://vimcasts.org/episodes/the-file-explorer/&quot;&gt;The file explorer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Protip on netrw usage: &lt;code&gt;:Rex&lt;/code&gt; will re-open/resume your last netrw session.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Personally I rarely use any file explorers like netrw or NerdTree as I feel that they are just too slow and convoluted for my workflow. Instead I get by with using &lt;code&gt;:e&lt;/code&gt; with tab completion and &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; to list completions for simple file exploring purposes. As I often am editing well structured projects I use a combination of &lt;a href=&quot;https://github.com/tpope/vim-projectionist&quot;&gt;projectionist.vim&lt;/a&gt; and ctags/GNU global/cscope. For a more generalized file switching I use &lt;code&gt;:find&lt;/code&gt; or a fuzzy finder like &lt;a href=&quot;http://kien.github.io/ctrlp.vim/&quot;&gt;CtrlP&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :close&#xA;:h netrw&#xA;:h :Explore&#xA;:h :e&#xA;:h cmdline-completion&#xA;:h ctags&#xA;:h cscope&#xA;:h :find&#xA;:h 'path'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-06-26T17:16:10.170" LastActivityDate="2015-06-26T17:16:10.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3720" PostTypeId="2" ParentId="3718" CreationDate="2015-06-26T16:52:01.323" Score="7" Body="&lt;p&gt;You can set the &#xA;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#E593&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'lines'&lt;/code&gt;&lt;/a&gt; and &#xA;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#E594&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'columns'&lt;/code&gt;&lt;/a&gt;&#xA;options from within Vim to resize the window. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set lines=55&#xA;:set columns=120&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add this to your vimrc file to do it automatically. This will work on gVim on any platform, and in &lt;em&gt;most&lt;/em&gt; terminal emulators.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related question: &lt;a href=&quot;https://vi.stackexchange.com/q/1937/51&quot;&gt;How do I get gvim to start maximised in Windows?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-06-26T16:52:01.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3721" PostTypeId="1" AcceptedAnswerId="3723" CreationDate="2015-06-26T20:18:47.650" Score="9" ViewCount="2988" Body="&lt;p&gt;The command is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;; :execute &quot;normal! mqA;\&amp;lt;esc&amp;gt;`q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you then press &lt;code&gt;&amp;lt;leader&amp;gt;;&lt;/code&gt;, you will &lt;code&gt;E114: Missing quote: &quot;normal! mqA;\&lt;/code&gt; followed by &lt;code&gt;E15: Invalid expression: &quot;normal! mqA;\&lt;/code&gt;. Why is this? The command works fine if input directly into the commandline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command adds a &lt;code&gt;;&lt;/code&gt; at the end of the current line, without changing the cursors position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realise that I can just do &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;; mqA;&amp;lt;esc&amp;gt;`q&lt;/code&gt; which works, the question is why the above doesn't work, and what can be done to make it work in the execute-normal form.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess would be that some level of nested escaping is needed, but I couldn't find one that works.&lt;/p&gt;&#xA;" OwnerUserId="2604" LastActivityDate="2020-05-03T07:41:49.290" Title="Why do I get a missing quote error when using the following in a mapping using execute and normal?" Tags="|key-bindings|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3722" PostTypeId="2" ParentId="3721" CreationDate="2015-06-26T20:30:02.360" Score="5" Body="&lt;p&gt;You need to escape the &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; in command mode.  This is done by prefixing it with &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;.  You also need a trailing &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to actually run it.  Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;; :execute &quot;normal! mqA;&amp;lt;C-v&amp;gt;&amp;lt;ESC&amp;gt;`q&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-06-26T20:30:02.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3723" PostTypeId="2" ParentId="3721" CreationDate="2015-06-26T21:54:20.543" Score="10" Body="&lt;p&gt;You need to escape the &lt;code&gt;&amp;lt;&lt;/code&gt; via &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;; :execute &quot;normal! mqA;\&amp;lt;lt&amp;gt;esc&amp;gt;`q&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: added &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to execute the command as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However this can be simplified quite a bit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;; mqA;&amp;lt;esc&amp;gt;`q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using an expression mapping you can make your mapping conditional based on a trailing &lt;code&gt;;&lt;/code&gt; character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;; getline('.') =~ ';$' ? '' : &quot;mqA;\&amp;lt;esc&amp;gt;`q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h &amp;lt;lt&amp;gt;&#xA;:h map-&amp;lt;expr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-06-26T21:54:20.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3724" PostTypeId="1" AcceptedAnswerId="3733" CreationDate="2015-06-26T23:45:03.567" Score="1" ViewCount="802" Body="&lt;p&gt;Are there any features/plugins/external tools which can be used to get tag navigation that understands RequireJS imports? &lt;/p&gt;&#xA;" OwnerUserId="2605" LastEditorUserId="51" LastEditDate="2015-06-27T20:52:50.723" LastActivityDate="2015-06-28T08:37:49.187" Title="Is it possible to get tag navigation that works with RequireJS?" Tags="|tags|ctags|filetype-javascript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3725" PostTypeId="1" CreationDate="2015-06-27T04:53:38.477" Score="86" ViewCount="48170" Body="&lt;p&gt;Say the following is the current structure of my window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;+-----+----------------------------&#xA;|     |&#xA;|  A  |&#xA;|     |&#xA;+-----+&#xA;|     |&#xA;|  B  |&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The order of A and B is not quite natural. It would be better if B was on top.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I go &lt;code&gt;&amp;lt;C-w&amp;gt;K&lt;/code&gt;, B will be the very top of all windows, which is not what I want. How can I put B above A, but not above any other window that is already above A?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if two windows are vertically split, how can I change them to horizontally split?&lt;/p&gt;&#xA;" OwnerUserId="1097" LastEditorUserId="8" LastEditDate="2015-06-27T12:13:02.543" LastActivityDate="2022-03-24T04:28:43.547" Title="Swap the position of two windows" Tags="|split|vim-windows|" AnswerCount="7" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3726" PostTypeId="1" AcceptedAnswerId="3843" CreationDate="2015-06-27T11:04:54.163" Score="10" ViewCount="335" Body="&lt;p&gt;English language users probably don't have this trouble, but vim is pretty dumb when it comes to regular expressions. In my case most letters in the Turkish alphabet outside the EN alphabet don't seem to qualify as word characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given a document that contains a Turkish word:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;gerçekleşiyor&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The search expression&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/ger\wek&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;…will not match the start of the word. For whatever reason ç is not a word character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This becomes maddening when plugins use &lt;code&gt;\w&lt;/code&gt; as part of their regular expression repertoire. A case in point is &lt;code&gt;neocompcache&lt;/code&gt; (which I use instead of &lt;code&gt;neocomplete&lt;/code&gt; because it in compatible with Neovim). Baring extra matching rule sets for some language syntax, autocomplete only happens in word sized chunks. When I'm writing large amounts of Turkish prose it would actually be handy to have functional autocomplete, but with most words being broken into smaller chunks with the Turkish characters left out it is beyond useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I convince vim (preferably neovim if it matters) to accept a larger range of characters as &quot;word&quot; characters?&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="1577" LastEditDate="2015-06-27T11:06:42.777" LastActivityDate="2015-09-18T18:05:04.807" Title="How can I make vim stop splitting my words into chunks?" Tags="|autocompletion|regular-expression|neovim|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3727" PostTypeId="2" ParentId="3726" CreationDate="2015-06-27T12:02:14.883" Score="6" Body="&lt;p&gt;Looks like there's not an easy way to redefine &lt;code&gt;\w&lt;/code&gt;.  See, for example, &lt;a href=&quot;https://stackoverflow.com/a/19386177/2877364&quot;&gt;Vim regex matches unicode characters are as non-word&lt;/a&gt; and&#xA;&lt;a href=&quot;https://unix.stackexchange.com/a/60600/63804&quot;&gt;Match word containing characters beyond a-zA-Z&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you might be able to use a custom range if you don't mind retyping it regularly (ha):&#xA;&lt;code&gt;[a-zA-Z\%u00c7-\%u015f]&lt;/code&gt;.  That will unfortunately match lots of non-Turkish characters as well, but if those characters don't appear in your text, that might be OK.&lt;/p&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-06-27T14:11:48.637" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3728" PostTypeId="1" AcceptedAnswerId="3729" CreationDate="2015-06-27T13:53:17.210" Score="45" ViewCount="29842" Body="&lt;p&gt;My terminal doesn't allow me to type &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt;, because that's a shortcut for closing a terminal tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like working with splits, but I can't find any way to do so without using &lt;code&gt;C-W&lt;/code&gt;. This forced me to use tabs, because I can switch between them with &lt;code&gt;gt&lt;/code&gt;, &lt;code&gt;gT&lt;/code&gt; or &lt;code&gt;#gt&lt;/code&gt; where # is a number, but I find this less convenient than splits as I can only see the contents of one file at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't use &lt;code&gt;mouse=a&lt;/code&gt; either since my terminal doesn't support that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I work with splits in Vim without the &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; combo available?&lt;/p&gt;&#xA;" OwnerUserId="2612" LastEditorUserId="205" LastEditDate="2016-05-12T22:45:40.987" LastActivityDate="2021-05-28T10:49:35.380" Title="How can I work with splits in Vim without Ctrl-W?" Tags="|key-bindings|vim-windows|split|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3729" PostTypeId="2" ParentId="3728" CreationDate="2015-06-27T14:09:16.130" Score="42" Body="&lt;p&gt;You can remap &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; to another combination, for example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-e&amp;gt; &amp;lt;C-w&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can now use &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; and it will act as if you've pressed &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This will overwrite the default &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; mapping (scroll down). Vim already uses every key on the keyboard, and the only way to prevent this is using the leader key, which acts like a &amp;quot;prefix&amp;quot;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Leader&amp;gt;w &amp;lt;C-w&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Unless you've remapped &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;, you can now use &lt;code&gt;\w&lt;/code&gt; (after each other). I actually prefer this since I don't like CTRL+key combinations.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vi.stackexchange.com/q/836/51&quot;&gt;What is &amp;lt;Leader&amp;gt;?&lt;/a&gt; and&#xA;&lt;a href=&quot;https://vi.stackexchange.com/q/281/51&quot;&gt;How can I find out what &amp;lt;Leader&amp;gt; is set to? And is it possible to remap &amp;lt;Leader&amp;gt;?&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You don't &lt;em&gt;need&lt;/em&gt; to use the &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; key, you can use anything as a prefix, for example &lt;code&gt;;&lt;/code&gt; works just as well:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap ; &amp;lt;C-w&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And now &lt;code&gt;;w&lt;/code&gt;, &lt;code&gt;;s&lt;/code&gt;, etc. will work.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2021-05-28T10:49:35.380" LastActivityDate="2021-05-28T10:49:35.380" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3730" PostTypeId="1" AcceptedAnswerId="3837" CreationDate="2015-06-27T14:36:02.113" Score="12" ViewCount="14406" Body="&lt;p&gt;I'm trying to move my &lt;code&gt;.viminfo&lt;/code&gt; file into my &lt;code&gt;.vim/&lt;/code&gt; folder for cleaner syncing across multiple machines. (I have my &lt;code&gt;.vim&lt;/code&gt; stored on Dropbox, and then create symlinks to it from my home directory.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this morning, I found &lt;a href=&quot;https://stackoverflow.com/a/6286925/4865822&quot;&gt;this answer&lt;/a&gt; on how to do just that. Great! Unfortunately, I use Windows at work and Mac at home, so &lt;code&gt;~/.vim&lt;/code&gt; is actually sometimes &lt;code&gt;~/vimfiles&lt;/code&gt;. As a result, a one-line solution&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viminfo+=n~/.vim/viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;has now become a 5-line solution&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('unix')&#xA;  set viminfo+=n~/.vim/viminfo&#xA;elseif has('win32')&#xA;  set viminfo+=n~/vimfiles/viminfo&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which just feels clumsy to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some kind of default environment variable I can use to access the user-specific runtime path, à la &lt;code&gt;$VIMRUNTIME&lt;/code&gt; or &lt;code&gt;$MYVIMRC&lt;/code&gt;? Or is this something I just have to dance around?&lt;/p&gt;&#xA;" OwnerUserId="2593" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-09-01T16:35:16.773" Title="Environment Variable for Personal Runtime Path? (~/.vim on *nix, ~/vimfiles on win32)" Tags="|vimrc|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3731" PostTypeId="2" ParentId="3730" CreationDate="2015-06-27T14:58:09.490" Score="5" Body="&lt;p&gt;Assuming you didn't change it, the first item in &lt;code&gt;&amp;amp;runtimepath&lt;/code&gt; is your runtime directory by default:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$HOME/.vim        on unix-like systems&#xA;$HOME\vimfiles    on windows&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use that value to tell Vim where to put your &lt;code&gt;viminfo&lt;/code&gt; file with this platform-agnostic one liner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;viminfo .= ',n' . split(&amp;amp;rtp, ',')[0] . '/viminfo'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Resources:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :let-option&#xA;:h split()&#xA;:h runtimepath&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-06-27T20:39:13.843" LastActivityDate="2015-06-27T20:39:13.843" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3732" PostTypeId="1" AcceptedAnswerId="3747" CreationDate="2015-06-27T15:09:14.430" Score="13" ViewCount="5302" Body="&lt;p&gt;I've been working on modularizing &amp;amp; converting a code in my &lt;code&gt;vimrc&lt;/code&gt; into some self-contained and reusable bundles/plugins plugins. I've run into an issue with autoloading &amp;amp; scope that I'm having difficulty understanding. I've read through &lt;code&gt;:h autoload&lt;/code&gt;, &lt;code&gt;:h &amp;lt;sid&amp;gt;&lt;/code&gt;, &lt;code&gt;:h script-local&lt;/code&gt;, but I'm still not quite clear on how this works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been looking at some well-developed plugins to figure out some commonly used patterns, and have structured my plugins as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/autoload/myplugin.vim&#xA;&#xA;if exists('g:loaded_myplugin')&#xA;  finish&#xA;endif&#xA;&#xA;let g:loaded_myplugin = 1&#xA;let g:myplugin_version = 0.0.1&#xA;&#xA;&quot; Save cpoptions.&#xA;let s:cpo_save = &amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;&#xA;function! myplugin#init() &quot; {{{&#xA;  &quot; Default 'init' function. This will run the others with default values,&#xA;  &quot; but the intent is that they can be called individually if not all are&#xA;  &quot; desired.&#xA;  call myplugin#init_thing_one()&#xA;  call myplugin#init_thing_two()&#xA;endfunction&quot; }}}&#xA;&#xA;function! myplugin#init_thing_one() &quot; {{{&#xA;  &quot; init thing one&#xA;  call s:set_default('g:myplugin_thing_one_flag', 1)&#xA;  &quot; do some things ...&#xA;endfunction &quot; }}}&#xA;&#xA;function! myplugin#init_thing_two() &quot; {{{&#xA;  &quot; init thing two&#xA;  call s:set_default('g:myplugin_thing_two_flag', 1)&#xA;  &quot; do some things ...&#xA;endfunction &quot; }}}&#xA;&#xA;function! s:set_default(name, default) &quot; {{{&#xA;&quot; Helper function for setting default values.&#xA;  if !exists(a:name)&#xA;    let {a:name} = a:default&#xA;  endif&#xA;endfunction &quot; }}}&#xA;&#xA;&quot; Restore cpotions.&#xA;let &amp;amp;cpo = s:cpo_save&#xA;unlet s:cpo_save&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the start of my vimrc, I run the plugin with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('vim_starting')&#xA;  if &amp;amp;compatible | set nocompatible | endif&#xA;  let g:myplugin_thing_one_flag = 0&#xA;  let g:myplugin_thing_two_flag = 2&#xA;  call myplugin#init()&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This all seems to work correctly and as expected - but each time a function is called, the &lt;code&gt;s:set_default(...)&lt;/code&gt; function is called for each flag, which is ineffecient - so I attempted to move them out the functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/autoload/myplugin.vim&#xA;&quot; ...&#xA;set cpo&amp;amp;vim&#xA;&#xA;&quot; Set all defaults once, the first time this plugin is referenced:&#xA;call s:set_default('g:myplugin_thing_one_flag', 1)&#xA;call s:set_default('g:myplugin_thing_two_flag', 1)&#xA;&#xA;function! myplugin#init() &quot; {{{&#xA;&quot; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this causes errors that I'm unsure how I should resolve:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /Users/nfarrar/.vim/myplugin.vim&#xA;line   40:&#xA;E117: Unknown function: &amp;lt;SNR&amp;gt;3_set_default&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I still don't solidly understand vim's scoping, but from what I've read - it seems that vim implements a form of name-mangling with scripts to provide 'scope'. It assigns (not sure how exactly this process works) a unique SID for each file that is loaded at runtime - and when you call a function that is prefixed with a script-scope identifier (&lt;code&gt;s:&lt;/code&gt;), it transparently replaces that identifier with a mapped SID.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In some cases, I've seen scripts that call functions like this (but it doesn't work in my case, I don't understand why, and hoping someone can explain this):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call &amp;lt;SID&amp;gt;set_default('g:myplugin_thing_one_flag', 1)&#xA;call &amp;lt;SNR&amp;gt;set_default('g:myplugin_thing_one_flag', 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following does work, but I'm unsure if it's a good pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/autoload/myplugin.vim&#xA;&quot; ...&#xA;set cpo&amp;amp;vim&#xA;&#xA;&quot; Set all defaults once, the first time this plugin is referenced:&#xA;call myplugin#set_default('g:myplugin_thing_one_flag', 1)&#xA;call myplugin#set_default('g:myplugin_thing_two_flag', 1)&#xA;&#xA;function! myplugin#init() &quot; {{{&#xA;&quot; ...&#xA;&#xA;function! myplugin#set_default(name, default) &quot; {{{&#xA;    &quot; ...&#xA;endfunction &quot; }}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In script local, it states:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When executing an autocommand or a user command, it will run in the context of&#xA;the script it was defined in.  This makes it possible that the command calls a&#xA;local function or uses a local mapping.&#xA;&#xA;Otherwise, using &quot;&amp;lt;SID&amp;gt;&quot; outside of a script context is an error.&#xA;&#xA;If you need to get the script number to use in a complicated script, you can&#xA;use this function:&#xA;&#xA;    function s:SID()&#xA;      return matchstr(expand('&amp;lt;sfile&amp;gt;'), '&amp;lt;SNR&amp;gt;\zs\d\+\ze_SID$')&#xA;    endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It sees like this &lt;em&gt;might&lt;/em&gt; be the approach I need to take, but I'm not completely sure why, or exactly how to use it. Can anyone provide some insight?&lt;/p&gt;&#xA;" OwnerUserId="2207" LastActivityDate="2015-06-28T08:59:27.137" Title="Vimscript: Help with Autoloading, Scope &amp; &lt;SID&gt;" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3733" PostTypeId="2" ParentId="3724" CreationDate="2015-06-27T15:28:10.140" Score="4" Body="&lt;h1&gt;Built-in definition search&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Vim is able to follow &quot;includes&quot; for completion and for navigation. What constitutes an &quot;include&quot; can be defined with the &lt;code&gt;'include'&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sadly, Vim's include mechanism is not flexible enough to work with RequireJS's standard way to define multiple dependencies in a same line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;define(foo, [&quot;bar&quot;, &quot;module/baz&quot;], function(Bar, Baz) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but we can sort of work around that limitation by putting every dependency on its own line (which is a lot cleaner anyway… I'm looking at you, K. ;-)):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;define(foo, [&#xA;    &quot;bar&quot;,&#xA;    &quot;module/baz&quot;&#xA;], function(Bar, Baz) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is possible (but not really straightforward) to craft an &lt;code&gt;'include'&lt;/code&gt; value that deals with the notation above &lt;em&gt;and&lt;/em&gt; the new &lt;code&gt;import&lt;/code&gt; from ES6 or its bastard copycats found in recent libraries like RequireJS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding the code below to &lt;code&gt;~/.vim/after/ftplugin/javascript.vim&lt;/code&gt; should give you a reasonably working setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal define=^\\s*\\(function\\\|var\\\|define\\)[('\&quot;]\\{-\\}&#xA;setlocal suffixesadd+=.js&#xA;if &amp;amp;expandtab&#xA;    let &amp;amp;l:include = '^\s\{,' . &amp;amp;shiftwidth . &quot;}\\(import[^'\\\&quot;]*\\)*['\\\&quot;]\\zs[^'\\\&quot;]*\\ze&quot;&#xA;else&#xA;    let &amp;amp;l:include = &quot;^\t\\(import[^'\\\&quot;]*\\)*['\\\&quot;]\\zs[^'\\\&quot;]*\\ze&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With that, you should be able to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:dlist foobar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in this buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;define(main, [&#xA;    &quot;imports/imports&quot;&#xA;], function(imports) {&#xA;    return &quot;main&quot;;&#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and get a list like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imports/imports.js&#xA;  1:    2     function foobar() {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, Vim can now search for stuff in the current buffer &lt;em&gt;and&lt;/em&gt; imported files which will make the features below work with your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:dlist foo     list possible definitions of foo&#xA;[D             jump to definition of current word&#xA;:ilist bar     list occurrences of bar&#xA;[I             jump to first occurrence of current word&#xA;gf             jump to include under the cursor&#xA;&amp;lt;C-n&amp;gt;/&amp;lt;C-p&amp;gt;    keyword completion from many sources including includes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be slower than tag-based navigation but it is often a lot more accurate: &lt;code&gt;:dlist foo&lt;/code&gt; will only list the &lt;code&gt;foo&lt;/code&gt; that are relevant to your current context (from the current buffer, the files &quot;included&quot; in the current file and the files included in those &quot;includes&quot;) whereas &lt;code&gt;tselect foo&lt;/code&gt; will list every &lt;code&gt;foo&lt;/code&gt; in your project.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Resources&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help include-search&#xA;:help 'include'&#xA;:help 'suffixesadd'&#xA;:help 'define'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Tags&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ctags.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;Ctags&lt;/a&gt; doesn't follow includes: it merely indexes whatever indexable files it finds where you tell it to search. Tag search being a bit naïve, it can be cumbersome to find the right tag in large projects with many dependencies. This is not a JavaScript issue, though, the same applies to every supported language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://cscope.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;Cscope&lt;/a&gt; follows includes in some languages and is generally smarter than ctags but its &quot;oldschool&quot; JavaScript parser obviously doesn't care about your fancy ES6 imports or RequireJS dependencies. Like ctags, it can perfectly be used to search methods and such across your project but don't expect anything &quot;smart&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ternjs.net/&quot; rel=&quot;nofollow&quot;&gt;Tern&lt;/a&gt; is a code-analysis engine designed to work with &quot;modern&quot; JavaScript so you can expect it to find your definitions and usages, even in large projects. I find it too slow but it is really good at what it does.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Resources&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help tags&#xA;:help ctags&#xA;:help cscope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-06-28T08:37:49.187" LastActivityDate="2015-06-28T08:37:49.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3734" PostTypeId="2" ParentId="3732" CreationDate="2015-06-27T16:07:27.573" Score="14" Body="&lt;p&gt;I recommend this structure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.&#xA;└── myplugin&#xA;    ├── LICENSE.txt&#xA;    ├── README.md&#xA;    ├── autoload&#xA;    │   └── myplugin.vim&#xA;    ├── doc&#xA;    │   └── myplugin.txt&#xA;    └── plugin&#xA;        └── myplugin.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is compatible to all modern plugin managers, and keeps things clean.  Of these:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;myplugin/doc/myplugin.txt&lt;/code&gt; should be the help file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;myplugin/plugin/myplugin.vim&lt;/code&gt; should contain:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;checks for any prerequisits your plugin needs, such as minimal Vim version and Vim compile-time features&lt;/li&gt;&#xA;&lt;li&gt;key mappings&lt;/li&gt;&#xA;&lt;li&gt;one time initialisation, such as setting defaults&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;myplugin/autoload/myplugin.vim&lt;/code&gt; should contain the main code of your plugin.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Scopes are actually pretty simple:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;functions with names starting with &lt;code&gt;s:&lt;/code&gt; may appear anywhere, but are local to the file they are defined in; you can only call them from the file where they are defined;&lt;/li&gt;&#xA;&lt;li&gt;functions in &lt;code&gt;myplugin/autoload/myplugin.vim&lt;/code&gt; must have names &lt;code&gt;myplugin#function()&lt;/code&gt; and are global; you can call them from everywhere (but beware that calling them causes the file &lt;code&gt;myplugin/autoload/myplugin.vim&lt;/code&gt; to be loaded);&lt;/li&gt;&#xA;&lt;li&gt;all other functions must have names starting with an upper case letter, such as &lt;code&gt;Function()&lt;/code&gt;, and are also global; you can call them from everywhere.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; are used for mappings, and they are a topic that you should probably avoid until you have a full understanding of how they work and what problem they are supposed to solve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;SNR&amp;gt;&lt;/code&gt; is something that you should never use directly.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="1577" LastEditDate="2015-06-27T17:16:31.150" LastActivityDate="2015-06-27T17:16:31.150" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3735" PostTypeId="2" ParentId="3730" CreationDate="2015-06-27T21:08:41.420" Score="0" Body="&lt;p&gt;What I did was rename Windows' viminfo folder to .vim (or copy the former's contents into the latter and then delete the former) and then symlink them with &lt;code&gt;mklink /d viminfo .vim&lt;/code&gt;. (Note that mklink takes its arguments in the opposite order from Unix' ln command.)&lt;/p&gt;&#xA;" OwnerUserId="2618" LastActivityDate="2015-06-27T21:08:41.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3736" PostTypeId="2" ParentId="3697" CreationDate="2015-06-27T21:19:07.987" Score="1" Body="&lt;p&gt;Try this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter *.txt if &amp;amp;buftype == 'help' | setlocal filetype=txt | endif&#xA;autocmd InsertLeave *.txt if &amp;amp;buftype == 'help' | setlocal filetype=help | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter *.txt if &amp;amp;filetype == 'help' | setlocal filetype=txt | endif&#xA;autocmd InsertLeave *.txt if &amp;amp;filetype == 'help' | setlocal filetype=help | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2618" LastEditorUserId="51" LastEditDate="2015-06-30T15:19:47.107" LastActivityDate="2015-06-30T15:19:47.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3737" PostTypeId="2" ParentId="3728" CreationDate="2015-06-27T21:39:53.407" Score="26" Body="&lt;p&gt;I actually use &lt;code&gt;:wincmd&lt;/code&gt; more often than &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; because I find it easier to type the abbreviated &lt;code&gt;:winc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the equivalent to &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; &lt;kbd&gt;L&lt;/kbd&gt; is &lt;code&gt;:winc l&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2425" LastActivityDate="2015-06-27T21:39:53.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3738" PostTypeId="1" AcceptedAnswerId="3743" CreationDate="2015-06-27T23:24:52.290" Score="2" ViewCount="1349" Body="&lt;p&gt;Currently, I use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F7&amp;gt; &amp;lt;Esc&amp;gt;:if has(&quot;gui_running&quot;)&amp;lt;Bar&amp;gt;hi comment gui=bold&amp;lt;Bar&amp;gt;else&amp;lt;Bar&amp;gt;hi comment cterm=bold&amp;lt;Bar&amp;gt;endif&amp;lt;LF&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It turns comments bold in terminal or in GUI when I press &lt;code&gt;&amp;lt;F7&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I would like it also to toggle the bold text. Is there a way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if hi comment gui == bold&#xA;    hi comment gui=none&#xA;else&#xA;    hi comment gui=bold&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2620" LastEditorUserId="1682" LastEditDate="2015-09-03T05:31:28.063" LastActivityDate="2015-09-03T05:31:28.063" Title="Toggle bold highlighting for comments in term/GUI" Tags="|syntax-highlighting|highlight|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3739" PostTypeId="2" ParentId="3738" CreationDate="2015-06-27T23:51:29.297" Score="3" Body="&lt;p&gt;This mapping is probably more suited to a mapping which calls a function, since it contains so many commands.  Here is my best shot at this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This just uses the call command to run the ToggleBoldComments function&#xA;nnoremap &amp;lt;F7&amp;gt; :call ToggleBoldComments()&amp;lt;CR&amp;gt;&#xA;&#xA;function! ToggleBoldComments()&#xA;    &quot; Make a variable in the current buffer to keep track of whether the&#xA;    &quot; comments are bold or not.&#xA;    if !exists(&quot;g:comments_bold&quot;)&#xA;        let g:comments_bold = 0&#xA;    endif&#xA;&#xA;    &quot; If comments aren't already bold, make it so.&#xA;    if g:comments_bold == 0&#xA;        let g:comments_bold = 1&#xA;        hi comment gui=bold cterm=bold&#xA;        return 0&#xA;    elseif g:comments_bold == 1&#xA;        &quot; Same, except the other way around.&#xA;        let g:comments_bold = 0&#xA;        hi comment gui=none cterm=none&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are the relevant help topics &lt;em&gt;(I recommend you read these if you want to know more about how this mapping works)&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :function&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :call&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help exists()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help g:&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help internal-variables&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :highlight&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-06-28T11:59:32.873" LastActivityDate="2015-06-28T11:59:32.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3740" PostTypeId="1" AcceptedAnswerId="3741" CreationDate="2015-06-27T23:52:39.570" Score="15" ViewCount="4210" Body="&lt;p&gt;I have a file full of text (say Markdown or LaTeX). I would like to count the number of words in a part of this file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can do &lt;kbd&gt;:! wc -w %&lt;/kbd&gt; to run wc -w on the current buffer. And I know that I can yank the section of interest into a named register. I'm guessing there's a way to send a named register to the operating system for use in a command or pipe, but I haven't been able to find one. Or is there a better way to count the words in a register?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My use case is that I do a lot of non-programming writing (notes, thesis, etc) in vim, and I would like to count how many words I've added to a given section of the file in the middle of an editing session.&lt;/p&gt;&#xA;" OwnerUserId="648" LastEditorUserId="343" LastEditDate="2017-12-06T11:10:32.823" LastActivityDate="2017-12-06T11:10:32.823" Title="How do I count the words in a part of a file, without leaving vim?" Tags="|external-command|counting|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3741" PostTypeId="2" ParentId="3740" CreationDate="2015-06-27T23:59:13.120" Score="21" Body="&lt;p&gt;You can use &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;CTRL+g&lt;/kbd&gt;, which will give you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Col 1 of 118-121; Line 1 of 5; Word 1 of 142; Byte 1 of 678&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use this from visual mode, if you want to get the word count for just the selection, which is especially useful combined with text objects such as &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#ip&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;ip&lt;/code&gt;&lt;/a&gt;. (e.g. you can use &lt;code&gt;vipg&amp;lt;C-g&amp;gt;&lt;/code&gt; to get the word count of the current paragraph).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#word-count&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help word-count&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#text-objects&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help text-objects&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The above option is probably better, but you can also use &lt;code&gt;wc&lt;/code&gt; utility to count the number of words in a section. Aside from the &lt;code&gt;:! wc -w %&lt;/code&gt; form you use, you can also use&lt;code&gt;:%!wc -w&lt;/code&gt;. This will filter a motion to a shell tool (in this case &lt;code&gt;%&lt;/code&gt;, the entire buffer), but you can also use other ranges (such as &lt;code&gt;:1,5!wc -w&lt;/code&gt; for the first 5 lines, &lt;code&gt;!,+5!wc -w&lt;/code&gt; for the current and next 5 lines, etc.). You can also select text in visual mode, and type &lt;code&gt;:!wc -w&lt;/code&gt; to filter your selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this will replace the motion with the output of the shell tool, but you can &lt;code&gt;u&lt;/code&gt; to undo this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Arange%21&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :range!&lt;/code&gt;&lt;/a&gt;, &#xA;&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%7Baddress%7D&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help range&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;https://vi.stackexchange.com/a/3232/51&quot;&gt;this answer&lt;/a&gt; where I give more examples of ranges.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-06-28T02:55:34.580" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3742" PostTypeId="2" ParentId="3740" CreationDate="2015-06-28T00:00:13.377" Score="3" Body="&lt;p&gt;There are two ways this can be accomplished, the pure vimscript way and the &lt;code&gt;wc&lt;/code&gt; way.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The pure vim way&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can use the search and replace command to do this.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\&amp;lt;\w\{-}\&amp;gt;//gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this does is instead of replacing a given pattern with something, it just counts the occurrences of the pattern.  This is because of the &lt;code&gt;n&lt;/code&gt; flag.  To count the words in a specific section (in this case lines 5 through 15), you could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5,15s/\&amp;lt;\w\{-}\&amp;gt;//gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This removes the need to yank the contents of a selection into a register.  To see more possibilities for what can be put in place of &lt;code&gt;5-15&lt;/code&gt;, read the help topic for &lt;code&gt;cmdline-ranges&lt;/code&gt;.  If you want to do this often, it is probably good to create a mapping (or command) for it.  Also, if you have &lt;code&gt;hlsearch&lt;/code&gt; enabled, you might want to run &lt;code&gt;:nohlsearch&lt;/code&gt; afterwards to clear the highlighting.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The &lt;code&gt;wc&lt;/code&gt; way&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The same thing can be accomplished with &lt;code&gt;wc&lt;/code&gt;.   In the same way you can use &lt;code&gt;cmdline-ranges&lt;/code&gt; to select the area with the &lt;code&gt;:s&lt;/code&gt; command, you can use them with external commands.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5,15!wc -w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This runs lines 5 through 15 through the &lt;code&gt;wc&lt;/code&gt; command.  The downside to this is that it replaces that range of lines with the output of the command.  You can undo this change by pressing &lt;code&gt;u&lt;/code&gt;.  Also note that the vimscript solution may not work with different languages, because &lt;code&gt;\w&lt;/code&gt; does not match what would normally be word characters in other languages.  &lt;code&gt;wc&lt;/code&gt; may do better at this than &lt;code&gt;\w&lt;/code&gt;.  Also, here is a fancy command to make it faster to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -range=% -addr=lines WordCount execute '&amp;lt;count&amp;gt;!wc -w' | .y a | undo | echo @a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this clobbers the &lt;code&gt;a&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Note&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;It appears that this can also be accomplished in visual mode with the &lt;code&gt;g&amp;lt;C-g&amp;gt;&lt;/code&gt; key combination.  See Carpetsmoker's answer for an explanation of this.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-06-28T01:42:34.460" LastActivityDate="2015-06-28T01:42:34.460" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3743" PostTypeId="2" ParentId="3738" CreationDate="2015-06-28T00:11:58.603" Score="5" Body="&lt;p&gt;You can get the current settings of a highlight group with the &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#E415&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:highlight&lt;/code&gt;&lt;/a&gt; command. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight Comment&#xA;Comment        xxx term=bold ctermfg=4 guifg=Blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will just output the text; there is (as far as I know), no VimScript function to get the same text in a string, but not all is lost, since we can use the &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3Aredir&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:redir&lt;/code&gt;&lt;/a&gt; command to redirect the output of a command to a variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can then match this, and call the appropriate &lt;code&gt;:highlight&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting that all together, we end up with this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ToggleHighlight()&#xA;    &quot; Redirect output of :highlight to l:current&#xA;    redir =&amp;gt; l:current&#xA;        silent highlight Comment&#xA;    redir END&#xA;&#xA;    if l:current =~# '\(cterm\|gui\)=bold'&#xA;        highlight Comment gui=none cterm=none&#xA;    else&#xA;        highlight Comment gui=none cterm=bold&#xA;    endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can map this function to &lt;code&gt;&amp;lt;F7&amp;gt;&lt;/code&gt; with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F7&amp;gt; &amp;lt;Esc&amp;gt;:call ToggleComments()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-06-28T11:13:08.033" LastActivityDate="2015-06-28T11:13:08.033" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3744" PostTypeId="5" CreationDate="2015-06-28T01:56:10.020" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-06-28T01:56:10.020" LastActivityDate="2015-06-28T01:56:10.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3745" PostTypeId="4" CreationDate="2015-06-28T01:56:10.020" Score="0" Body="Lua programming interface to Vim. DO NOT use for questions with Lua examples or about syntax highlighting in Lua." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-06-28T01:56:10.020" LastActivityDate="2015-06-28T01:56:10.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3746" PostTypeId="1" AcceptedAnswerId="3748" CreationDate="2015-06-28T02:09:15.043" Score="57" ViewCount="16833" Body="&lt;p&gt;I'd like to open a file from another branch in the current git repository. I have seen &lt;a href=&quot;https://stackoverflow.com/q/7856416/2072269&quot;&gt;this SO question&lt;/a&gt;, but the suggestions for combining it with Vim are cumbersome (pipe to Vim, open stdin, set filetype, etc. manually). Is there a simpler way that retains syntax highlighting, filetype settings, etc.?&lt;/p&gt;&#xA;&lt;p&gt;If it helps:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have the &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;noreferrer&quot;&gt;fugitive&lt;/a&gt; plugin installed (though rarely used).&lt;/li&gt;&#xA;&lt;li&gt;I don't need to modify the file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The file can be the file for the currently open buffer, or a different one.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2020-08-11T02:04:42.547" LastActivityDate="2022-03-16T02:43:07.097" Title="How do I open a file from another git branch?" Tags="|git|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3747" PostTypeId="2" ParentId="3732" CreationDate="2015-06-28T02:24:28.123" Score="4" Body="&lt;p&gt;In the first case, the error you are getting is that you are trying to call a function prior to its existance. That is, Vim is progressing through your script. When it sees the &lt;code&gt;call&lt;/code&gt; line, it hasn't yet processed the &lt;code&gt;function&lt;/code&gt; line that creates what you want to call, resulting in the error &lt;code&gt;unknown function&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you move your call to setup defaults to the end of your script (before you restore &lt;code&gt;cpo&lt;/code&gt; but after all of your &lt;code&gt;function&lt;/code&gt;s, there won't be an error, because Vim will have processed the script to create the functions first, so once it gets to the &lt;code&gt;call&lt;/code&gt; lines, the functions exist. e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;....&#xA;&#xA;function! s:set_default(name, default) &quot; {{{&#xA;  &quot; Helper function for setting default values.&#xA;  if !exists(a:name)&#xA;    let {a:name} = a:default&#xA;  endif&#xA;endfunction &quot; }}}&#xA;&#xA;&quot; Set all defaults once, the first time this plugin is referenced:&#xA;call s:set_default('g:myplugin_thing_one_flag', 1)&#xA;call s:set_default('g:myplugin_thing_two_flag', 1)&#xA;&#xA;&quot; Restore cpotions.&#xA;let &amp;amp;cpo = s:cpo_save&#xA;unlet s:cpo_save&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do not know why the alternative syntax of calling your &lt;code&gt;set_default&lt;/code&gt; as an autoload function from within the autoload script works when the function hasn't yet been defined. My guess is this is a side effect of the implementation (where an already read script isn't re-read, or you'd have infinite recursion). I wouldn't count on it always working that way.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="1577" LastEditDate="2015-06-28T08:59:27.137" LastActivityDate="2015-06-28T08:59:27.137" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3748" PostTypeId="2" ParentId="3746" CreationDate="2015-06-28T02:30:22.497" Score="68" Body="&lt;p&gt;You can use &lt;code&gt;:Gedit&lt;/code&gt;/&lt;code&gt;:Gsplit&lt;/code&gt;/&lt;code&gt;:Gvsplit&lt;/code&gt;/... with the form &lt;code&gt;{revision}:{filename}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Gedit branch:/foo/bar.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: If the file is the same as the current file you can abbreviate the command like so: &lt;code&gt;:Gsplit branch:%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is often the case that a diff of the current file is preferred than just opening the file on a different branch. You can do this via &lt;code&gt;:Gdiff {branch}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h fugitive-:Gedit&#xA;:h fugitive-revision&#xA;:h fugitive-:Gdiff&#xA;:h c_%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may also want to check out &lt;a href=&quot;http://vimcasts.org/&quot;&gt;Vimcasts&lt;/a&gt; episodes in the &lt;a href=&quot;http://vimcasts.org/blog/2011/05/the-fugitive-series/&quot;&gt;Fugitive Series&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-06-28T02:54:18.510" LastActivityDate="2015-06-28T02:54:18.510" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3749" PostTypeId="2" ParentId="3746" CreationDate="2015-06-28T02:40:32.303" Score="20" Body="&lt;p&gt;This is a little more broad than what OP asked, but for people not wanting to use plugins, and possibly other revision control systems, this little snippet tends to work fairly well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new&#xA;:r! git show branch:file&#xA;:1d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It creates a new window and shows the file there by reading the output of the given command into the new buffer. This of course works with any external command, not just git.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example for bzr (where REV syntax can specify a branch):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new&#xA;:r! bzr cat -r REV file&#xA;:1d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example for hg (not sure about branches in hg; don't use it enough)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new&#xA;:r! hg cat -r REV file&#xA;:1d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example for svn (&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new&#xA;:r! svn cat file@REV&#xA;:1d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would still probably want to set the filetype to get syntax highlighting like in the SO posts, but at least you don't have to mess with piping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once opened you can save it under a new name with &lt;code&gt;:w filename&lt;/code&gt; or &lt;code&gt;:saveas filename&lt;/code&gt;, since Vim won't have a filename for it yet. If you don't want to be able to edit it, you can also throw in a &lt;code&gt;:setlocal readonly&lt;/code&gt; and/or &lt;code&gt;:setlocal nomodifiable&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;-Edit: Automatic Filetype-&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It's a little more work, but you can ask Vim to guess the filetype with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype detect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, since Vim doesn't have a name yet, this doesn't always work well (for example, I pulled in some C code and it guessed &lt;code&gt;filtype=conf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can give it a name by saving it, but we don't want to overwrite a possibly existing file. We can also just set the filename (Thanks @PeterRincker!), but again, we don't want to risk collisions. Since it is unlikely that a file exists that is both the branchname and filename together, we'll concatenate them with some arbitrary separator&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;silent file &quot; . &quot;branch&quot; . &quot;-&quot; . &quot;file&quot;&#xA;:filetype detect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;&quot;file&quot;&lt;/code&gt; is replaced with the actual filename and &lt;code&gt;&quot;branch&quot;&lt;/code&gt; with the branch name&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, at this point we are almost writing a plugin ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thowing it all together, here it is as a git specific function you could drop in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GitFile(branch,file)&#xA;    new&#xA;    exe &quot;silent r! git show &quot; . a:branch . &quot;:&quot; . a:file&#xA;    1d&#xA;    exe &quot;silent file &quot; . a:branch . &quot;-&quot; . a:file&#xA;    filetype detect&#xA;    setlocal readonly     &quot;don't allow saving&#xA;    setlocal nomodified   &quot;allow easy quitting without saving&#xA;    setlocal nomodifiable &quot;don't allow modification&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which you could wrap in a command or call directly e.g. &lt;code&gt;call GitFile(&quot;whateverBranch&quot;,&quot;myfile.c&quot;)&lt;/code&gt;. You'll get a new window with a buffer named &lt;code&gt;whateverBranch-myfile.c&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2015-06-28T06:15:40.790" LastActivityDate="2015-06-28T06:15:40.790" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3750" PostTypeId="2" ParentId="3725" CreationDate="2015-06-28T03:11:04.293" Score="7" Body="&lt;p&gt;In order to swap &lt;code&gt;window&lt;/code&gt; positions, the effect is equivalent to swapping buffers that those two windows show.&lt;br&gt;&#xA;e.g. If window A has buffer 2 and window B has buffer 8, you'll want to go to Window A, select buffer 8, then to Window B, select buffer 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This idea inspired me to script it - and it's already in my own toolbox as well&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Function Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! WinBufSwap()&#xA;  let thiswin = winnr()&#xA;  let thisbuf = bufnr(&quot;%&quot;)&#xA;  let lastwin = winnr(&quot;#&quot;)&#xA;  let lastbuf = winbufnr(lastwin)&#xA;&#xA;  exec  lastwin . &quot; wincmd w&quot; .&quot;|&quot;.&#xA;      \ &quot;buffer &quot;. thisbuf .&quot;|&quot;.&#xA;      \ thiswin .&quot; wincmd w&quot; .&quot;|&quot;.&#xA;      \ &quot;buffer &quot;. lastbuf&#xA;endfunction&#xA;&#xA;command! Wswap :call WinBufSwap()&#xA;map &amp;lt;Leader&amp;gt;bs &amp;lt;C-c&amp;gt;:call WinBufSwap()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Select window A&lt;/li&gt;&#xA;&lt;li&gt;Select window B  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:call WinBufSwap()&lt;/code&gt;&lt;br&gt;&#xA;This swaps the buffers in the two pre-selected windows, leaving the cursor in the original window.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Selecting the two desired windows to be swapped ahead of time is the key detail, as that is needed to specify for Vim which ones to work with.&lt;/p&gt;&#xA;" OwnerUserId="2303" LastActivityDate="2015-06-28T03:11:04.293" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3751" PostTypeId="1" AcceptedAnswerId="3753" CreationDate="2015-06-28T10:47:59.593" Score="1" ViewCount="518" Body="&lt;p&gt;This happens with either stock Yosemite terminal, or iterm2.  When I exit vim, this is my terminal.  As you can see, colors are messed up in my terminal after exiting vim and it doesn't come back until I terminate terminal app (not a pun :P).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ynWRe.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to add that I'm a bit new to vim (a couple of months) and reaaaaaally new to Mac OS (less than a month).  The same vimrc works well in Linux.&lt;/p&gt;&#xA;" OwnerUserId="2627" LastEditorUserId="205" LastEditDate="2015-06-30T13:43:31.720" LastActivityDate="2015-06-30T13:43:31.720" Title="Terminal in Mac OS X Yosemite gets messed up after exiting vim" Tags="|terminal|macos|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3752" PostTypeId="1" CreationDate="2015-06-28T12:27:31.503" Score="19" ViewCount="1707" Body="&lt;p&gt;This is &lt;em&gt;kind of&lt;/em&gt; two questions in one. Lately I've been spending a lot of time learning vimscript in-depth, learning vim's internals &amp;amp; taking my first steps writing vim plugins. During this process, I've been keeping extensive notes in individual markdown files &amp;amp; add lots of inline 'documentation' comments to the vimscript files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I feel like I've finally got some code that's worth sharing, and want to start adding some &lt;em&gt;actual&lt;/em&gt; documentation. I haven't authored any of my own helpdoc files yet, so I'm still figuring out that process. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without any experience yet or solid understanding of this workflow, there are two tasks I'm trying to figure out:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Generating helpdoc files from my markdown 'notes' files on vim/vimscript, so I can read/reference quickly &amp;amp; easily from vim at any time.&lt;/li&gt;&#xA;&lt;li&gt;Parsing the inline documentation from my vimscript files (similar to the way &lt;a href=&quot;https://github.com/rtomayko/shocco&quot; rel=&quot;noreferrer&quot;&gt;shocco&lt;/a&gt; works for shell scripts) to generate the associated helpdoc for the vimscripts.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any suggestions or advice on the ideas (&lt;em&gt;this is a bad idea because ..., a better idea is ...&lt;/em&gt;), or how to accomplish them would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2207" LastEditorUserId="205" LastEditDate="2015-06-29T00:05:00.150" LastActivityDate="2021-07-15T13:54:48.717" Title="How do I generate Vim documentation from Markdown notes or inline comments, or are there better ways to add documentation?" Tags="|vimscript|help-system|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3753" PostTypeId="2" ParentId="3751" CreationDate="2015-06-28T14:00:30.203" Score="3" Body="&lt;p&gt;It seems that was a bug in the version of &lt;code&gt;vim-airline&lt;/code&gt; I had.  Following the posts instructions on how to debug my &lt;code&gt;vimrc&lt;/code&gt;, I commented out the plugins and everything worked ok.  So I started commenting out one by one each plugin, and when i did so in &lt;code&gt;vim-airline&lt;/code&gt; it bugged again.  So i found out how to update my plugins (i use Vundle as a plugin manager, so &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +PluginUpdate &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PluginUpdate &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from inside vim as @Edward reminded me) and now everything works ok.  Thnx @Carpetsmoker and @Edward.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, just a reminder, plugins can have bugs as well, so investigate when in doubt.&lt;/p&gt;&#xA;" OwnerUserId="2627" LastEditorUserId="205" LastEditDate="2015-06-30T13:41:58.383" LastActivityDate="2015-06-30T13:41:58.383" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3754" PostTypeId="2" ParentId="3752" CreationDate="2015-06-28T16:16:05.590" Score="9" Body="&lt;p&gt;As far as I know there is currently no good solution for either problem, but a lot of people would be interested in solving them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Markdown is a superset of HTML, so I'd say a frontal approach to conversion from markdown to Vim help is unlikely to succeed.  If you can speak Haskell you could try to write a Vim help backend for &lt;a href=&quot;http://pandoc.org/&quot; rel=&quot;noreferrer&quot;&gt;pandoc&lt;/a&gt;.  That would be a very nice solution even if it isn't perfect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There have been a few attempts at doing it the other way around, convert Vim help pages to some useful format.  There are a few scripts floating around that produce HTML and PDF versions of the official help, with varying degrees of success.  But they all rely on the help being more or less homogenous in style.  Even a Vim help reader for something like &lt;a href=&quot;http://pandoc.org/&quot; rel=&quot;noreferrer&quot;&gt;pandoc&lt;/a&gt; would be a worthwhile project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for extracting documentation from Vim code, there's a parser for VimL in Python, JavaScript, and VimL itself, named &lt;a href=&quot;https://github.com/ynkdir/vim-vimlparser&quot; rel=&quot;noreferrer&quot;&gt;vimlparser&lt;/a&gt;.  It's pretty good, it shouldn't be hard to write something that parses VimL sources and dumps special crafted comments.  Being able to convert these comments to something like, say, &lt;a href=&quot;https://en.wikipedia.org/wiki/Plain_Old_Documentation&quot; rel=&quot;noreferrer&quot;&gt;POD&lt;/a&gt; would be highly useful too.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-06-28T16:16:05.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3755" PostTypeId="1" CreationDate="2015-06-28T22:32:01.793" Score="5" ViewCount="1658" Body="&lt;p&gt;I want to color the background of a keyword but also for the whole line where it is found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The file has entries like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{frame}&#xA;\frametitle{title}&#xA;\framesubtitle{subtile}&#xA;\end{frame}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Lines with frametitle should be red in background.&lt;/li&gt;&#xA;&lt;li&gt;Lines with framesubtitle should get a light blue background. &lt;/li&gt;&#xA;&lt;li&gt;Lines that contain otherwise the word frame should get a light gray background&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My approach did not succed so far, I have put this into .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax keyword framesubtike framesubtitle&#xA;syntax keyword frametitle frametitle&#xA;hi frame term=bold ctermbg=1  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What did I miss?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;Thanks to Carpetsmoker's answer this works good enough for now: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region regionone matchgroup=framesubtitlecolorblue start=/^.*framesubtitle.*/ end=/$/ &#xA;syntax region regiontwo matchgroup=framesubtitlecolorred start=/^.*frametitle.*/ end=/$/      &#xA;hi framesubtitlecolorblue ctermfg=blue guifg=red&#xA;hi framesubtitlecolorred ctermfg=red guifg=red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2632" LastEditorUserId="1841" LastEditDate="2015-06-28T23:55:41.230" LastActivityDate="2015-07-29T19:07:59.157" Title="syntax highlight for whole line" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3756" PostTypeId="1" CreationDate="2015-06-29T06:46:39.920" Score="6" ViewCount="5133" Body="&lt;p&gt;At home I use iTerm2 on MacOS X, and at work, I have a laptop with CygWin. I have another PC where I use gnome-terminal or terminator, and sometimes I use tmux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking to configure the cursor shape in Vim in a way that will work in all above terminals emulators. I want the cursor to be a upright bar in insert mode and solid block in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone can help here?  It's really uncomfortable when the cursor's shape is inconsistent when I switch between all my devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the my current vimrc for cursur shape change, I got it from an online example, but it doesn't work in gnome-teriminal, terminator, tmux:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;term == &quot;^xterm&quot; || &amp;amp;term == &quot;^screen&quot;&#xA;    let &amp;amp;t_SI = &quot;\e[5 q&quot;&#xA;    let &amp;amp;t_EI = &quot;\e[2 q&quot;&#xA;endif&#xA;&#xA;if exists(&quot;$TMUX&quot;)&#xA;    let &amp;amp;t_EI = &quot;\&amp;lt;Esc&amp;gt;Ptmux;\&amp;lt;Esc&amp;gt;\&amp;lt;Esc&amp;gt;]50;CursorShape=0\x7\&amp;lt;Esc&amp;gt;\\&quot;&#xA;    let &amp;amp;t_SI = &quot;\&amp;lt;Esc&amp;gt;Ptmux;\&amp;lt;Esc&amp;gt;\&amp;lt;Esc&amp;gt;]50;CursorShape=1\x7\&amp;lt;Esc&amp;gt;\\&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="1276" LastEditDate="2015-06-29T08:14:23.643" LastActivityDate="2017-11-14T22:41:53.093" Title="Change cursor shape in different terminals" Tags="|terminal|tmux|cursor|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3757" PostTypeId="1" AcceptedAnswerId="3758" CreationDate="2015-06-29T10:38:55.510" Score="2" ViewCount="535" Body="&lt;p&gt;So, I decided to manage my vimfiles (not dotfiles yet :P).  I copied &lt;code&gt;.vim&lt;/code&gt; and &lt;code&gt;.vimrc&lt;/code&gt; inside a &lt;code&gt;dotfiles&lt;/code&gt; folder (and removed the &lt;code&gt;dot&lt;/code&gt; from the filenames). I initialized &lt;code&gt;git&lt;/code&gt; dir and pushed it to Github.  When I pull the files from Github, i have issues running Vim.  It has trouble running &lt;code&gt;Vundle&lt;/code&gt; commands (&lt;code&gt;vundle#start&lt;/code&gt; and &lt;code&gt;vundle#end&lt;/code&gt;, and all Plugin statements).  I started believing that it was a second loaded &lt;code&gt;.vimrc&lt;/code&gt;, so running :version shows this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   system vimrc file: &quot;$VIM/vimrc&quot;                                                                                                                                                         &#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;                                                                                                                                                       &#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;                                                                                                                                                       &#xA;      user exrc file: &quot;$HOME/.exrc&quot;                                                                                                                                                        &#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The 2nd user &lt;code&gt;vimrc&lt;/code&gt; file doesn't exist physically, so i'm utterly confused.  Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bYYig.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2627" LastEditorUserId="205" LastEditDate="2015-06-29T10:48:58.870" LastActivityDate="2015-06-30T06:47:47.900" Title="Vim - Dotfiles - Vundle not recognized" Tags="|plugin-vundle|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3758" PostTypeId="2" ParentId="3757" CreationDate="2015-06-29T10:55:50.903" Score="3" Body="&lt;p&gt;I assume you installed Vundle the usual way (&lt;code&gt;git clone https://github.com/gmarik/Vundle.vim ~/.vim/bundle/...&lt;/code&gt;). When you initialized a Git repository on &lt;code&gt;.vim&lt;/code&gt;, Vundle's directory will be seen as a &lt;a href=&quot;https://stackoverflow.com/a/4162672/2072269&quot;&gt;Git link&lt;/a&gt; instead of a &lt;a href=&quot;http://git-scm.com/book/en/v2/Git-Tools-Submodules&quot; rel=&quot;nofollow noreferrer&quot;&gt;Git submodule&lt;/a&gt;. This complicates things, since there's no simple way to add the plugins as part of the overall repo. What you could do is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;remove the plugin directories from git, but not their actual contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git rm --cached bundle/Vundle.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Re-add it as a submodule:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git submodule add https://github.com/gmarik/Vundle.vim.git bundle/Vundle.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then commit your changes. Depending on where Vundle is keeping your other plugins, you might want to add them as submodules too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at your Github repository, you should find the Vundle directory looking like these:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/03w8e.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are plugins in my &lt;code&gt;~/.vim/bundle&lt;/code&gt;, added as submodules by &lt;a href=&quot;https://github.com/murukeshm/vimrc/tree/master/bundle&quot; rel=&quot;nofollow noreferrer&quot;&gt;my git vim repo&lt;/a&gt;. Note the revision numbers added to each. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have to initialize and update the submodules for the actual Vundle code to appear:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git submodule init&#xA;# or&#xA;git submodule update --init&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can also be done at the time of cloning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/my/vim/repo ~/.vim --recursive&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-06-30T06:47:47.900" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3759" PostTypeId="2" ParentId="3755" CreationDate="2015-06-29T17:03:22.753" Score="6" Body="&lt;p&gt;It's not possible to color complete lines using syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can however use signs (&lt;code&gt;:help signs&lt;/code&gt;) for highlighting complete lines. This has the drawback that you need to update the signs manually on changes of the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a &lt;a href=&quot;https://github.com/chrisbra/DynamicSigns&quot; rel=&quot;noreferrer&quot;&gt;plugin (DynamicSigns)&lt;/a&gt; that allows this kind of manipulations and updates the signs on changes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you need to define a function that checks the lines. For example like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HiglightLines(line)&#xA;  let line=getline(a:line)&#xA;  if line =~ '\\frametitle\&amp;gt;'&#xA;      return 'SignLine4'&#xA;  elseif line =~ '\\framesubtitle\&amp;gt;'&#xA;      return 'SignLine3'&#xA;  elseif line =~ '\&amp;lt;frame\&amp;gt;'&#xA;      return 'SignLine1'&#xA;  else&#xA;      return 0&#xA;  endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you call the plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SignExpression HighlightLines(v:lnum)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works similar to the 'foldexpr' option and evaluates all lines for the&#xA;keywords and depending on the word found, it will use one of the several predefined highlighting groups SignLine1-SignLine5 to highlight the lines accordingly. Read the help at &lt;code&gt;:help Signs-Hooks&lt;/code&gt; for an explanation and other possibilities. Note: you can change the SignLine1 highlighting groups manually, but the defaults already match with what you want.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="1306" LastEditDate="2015-07-29T19:07:59.157" LastActivityDate="2015-07-29T19:07:59.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3760" PostTypeId="1" CreationDate="2015-06-29T18:38:43.150" Score="2" ViewCount="1283" Body="&lt;p&gt;I've installed solarized with the bundled togglebg.vim plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my vimrc I set &lt;code&gt;background&lt;/code&gt; to &lt;code&gt;light&lt;/code&gt; and &lt;code&gt;colorscheme&lt;/code&gt; to &lt;code&gt;solarized&lt;/code&gt;, so I have light background and matching font colors from solarized-light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I change &lt;code&gt;background&lt;/code&gt; to &lt;code&gt;dark&lt;/code&gt; in my vimrc and restart vim, it starts with dark background and matching colors from solarized-dark - as advertised.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I use togglebg, it changes background to dark (but not dark like in solarized, almost black) and to some different colorscheme. Manual &lt;code&gt;:colorscheme solarized&lt;/code&gt; doesn't fix the problem. After running togglebg double it doesn't go back to first state, but to solarized-light scheme with the same almost black background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have only solarized with togglebg, ctrlP and Powerline installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim running in iTerm on OS X 10.8.5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my full .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()                                                                                          &#xA;&#xA;syntax enable                                                                                                      &#xA;set background=light                                                                                               &#xA;colorscheme solarized                                                                                              &#xA;set t_Co=256                                                                                                       &#xA;let g:solarized_termcolors=256                                                                                     &#xA;&#xA;let g:Powerline_symbols='fancy'                                                                                    &#xA;&#xA;set encoding=utf-8                                                                                                 &#xA;filetype plugin indent on                                                                                          &#xA;&#xA;set nocompatible                                                                                                   &#xA;set modelines=0                                                                                                    &#xA;&#xA;set tabstop=2                                                                                                      &#xA;set shiftwidth=2                                                                                                   &#xA;set softtabstop=2                                                                                                  &#xA;set expandtab                                                                                                      &#xA;&#xA;set ruler                                                                                                          &#xA;set relativenumber                                                                                                 &#xA;&#xA;set laststatus=2                                                                                                   &#xA;&#xA;set ignorecase                                                                                                     &#xA;set smartcase                                                                                                      &#xA;set gdefault                                                                                                       &#xA;&#xA;inoremap jk &amp;lt;Esc&amp;gt;                                                                                                  &#xA;call togglebg#map(&quot;&amp;lt;F5&amp;gt;&quot;)   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2641" LastEditorUserId="51" LastEditDate="2015-06-29T22:35:09.260" LastActivityDate="2015-10-14T00:05:38.733" Title="Togglebg from solarized changes to incorrect colorscheme" Tags="|colorscheme|plugin-solarized|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3761" PostTypeId="1" AcceptedAnswerId="3762" CreationDate="2015-06-30T07:33:59.667" Score="5" ViewCount="3230" Body="&lt;p&gt;How can I find out if the vim I'm using is 32 or 64 bit? I'm using Ubuntu so &lt;a href=&quot;https://vi.stackexchange.com/questions/3234/how-to-check-whether-vim-is-built-as-a-32-bit-or-64-bit-application&quot;&gt;this&lt;/a&gt; doesn't apply to me, I think. Also I checked&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and got this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May  4 2012 04:21:49)&#xA;Inklusive der Korrekturen: 1-429&#xA;Verändert von pkg-vim-maintainers@lists.alioth.debian.org&#xA;Übersetzt von buildd@&#xA;Riesige Version mit GTK2 GUI. Ein- (+) oder ausschließlich (-) der Eigenschaften:&#xA;+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info&#xA; +comments +conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff +digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra&#xA;+extra_search +farsi +file_in_path +find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap&#xA;+langmap +libcall +linebreak +lispindent +listcmds +localmap +lua +menu +mksession +modify_fname +mouse +mouseshape +mouse_dec +mouse_gpm&#xA;-mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +mouse_urxvt +multi_byte +multi_lang -mzscheme +netbeans_intg +path_extra +perl&#xA;+persistent_undo +postscript +printer +profile +python -python3 +quickfix +reltime +rightleft +ruby +scrollbind +signs +smartindent -sniff&#xA;+startuptime +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white +tcl +terminfo +termresponse +textobjects +title&#xA;+toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup +X11&#xA;-xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save&#xA;          System-vimrc-Datei: &quot;$VIM/vimrc&quot;&#xA;        Benutzer-vimrc-Datei: &quot;$HOME/.vimrc&quot;&#xA;         Benutzer-exrc-Datei: &quot;$HOME/.exrc&quot;&#xA;         System-gvimrc-Datei: &quot;$VIM/gvimrc&quot;&#xA;       Benutzer-gvimrc-Datei: &quot;$HOME/.gvimrc&quot;&#xA;           System-Menü-Datei: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;     Voreinstellung für $VIM: &quot;/usr/share/vim&quot;&#xA;Übersetzt: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/&#xA;include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0&#xA;-I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12     -g -O2 -fstack-protecto&#xA;r --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     -I/usr/include/tcl8.5  -&#xA;D_REENTRANT=1  -D_THREAD_SAFE=1  -D_LARGEFILE64_SOURCE=1&#xA;Linken: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic -Wl,-export-dynamic  -Wl,-E  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-nee&#xA;ded -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfo&#xA;ntconfig -lgobject-2.0 -lglib-2.0   -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/&#xA;lib -llua5.1  -Wl,-E  -fstack-protector -L/usr/local/lib  -L/usr/lib/perl/5.14/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config&#xA; -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions  -L/usr/lib -ltcl8.5 -ldl -lpthread -lieee -lm -&#xA;lruby1.8 -lpthread -lrt -ldl -lcrypt -lm  -L/usr/lib&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it doesn't look like it tells me what I want to know.&lt;/p&gt;&#xA;" OwnerUserId="2645" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-07-01T17:54:51.937" Title="How can I check if Vim is 32 bit or 64 bit? (On Linux!)" Tags="|linux|version|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3762" PostTypeId="2" ParentId="3761" CreationDate="2015-06-30T07:46:30.770" Score="12" Body="&lt;p&gt;Since you're on Ubuntu, use the &lt;a href=&quot;http://manpages.ubuntu.com/file.1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;file&lt;/code&gt;&lt;/a&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ file -L &quot;$(command -v vim)&quot;&#xA;/usr/bin/vim.gnome: ELF 64-bit LSB  shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=acb723f1249782755116f93ed45a30e7115ff423, stripped&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, my &lt;code&gt;vim&lt;/code&gt; is 64-bit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We need to use  &lt;code&gt;-L&lt;/code&gt; since &lt;code&gt;/usr/bin/vim&lt;/code&gt; on Ubuntu is a symlink, managed by the &lt;a href=&quot;https://wiki.debian.org/DebianAlternatives&quot; rel=&quot;nofollow noreferrer&quot;&gt;Debian alternatives system&lt;/a&gt;, and GNU &lt;code&gt;file&lt;/code&gt; by default doesn't follow symlinks (thanks to Random832 for pointing this out!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can check the package architecture:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ dpkg-query -f '${Package;10}\t${Architecture}\n' -W vim vim-gnome&#xA;       vim  amd64&#xA; vim-gnome  amd64&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Both of the above commands check the default &lt;code&gt;vim&lt;/code&gt; as Carpetsmoker notes. Within Vim, you can do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if system('file -L &quot;' . exepath(v:progpath) . '&quot;') =~ &quot;64-bit&quot;&#xA;    echo &quot;yes&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or we can use Carpetsmoker's suggestion of the &lt;code&gt;/proc/$PID/exe&lt;/code&gt; special link, which should be the most portable across Linux systems:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if system('file -L /proc/' . getpid() . '/exe' ) =~ &quot;64-bit&quot;&#xA;    echo &quot;yes&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/proc/$PID/exe&lt;/code&gt; is special. You can obtain the original executable for that process from &lt;code&gt;/proc/$PID/exe&lt;/code&gt; even if it has been deleted, moved or replaced. In such cases, the output of &lt;a href=&quot;http://manpages.ubuntu.com/readlink.1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;readlink&lt;/code&gt;&lt;/a&gt; or &lt;code&gt;resolve()&lt;/code&gt; on it may not be what you expect. For example, using a temporary copy of &lt;code&gt;bash&lt;/code&gt; for illustration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ readlink  -f /proc/$$/exe&#xA;/tmp/bash (deleted)&#xA;$ file &quot;$(readlink -f /proc/$$/exe)&quot;&#xA;/tmp/bash (deleted): ERROR: cannot open `/tmp/bash (deleted)' (No such file or directory)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, instructing &lt;code&gt;file&lt;/code&gt; to follow the symlink, or using &lt;code&gt;file - &amp;lt; /proc/self/exe&lt;/code&gt; to read directly from it, which works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ file -L /proc/$$/exe&#xA;/proc/10958/exe: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=b73723270773c893cf697d20c8d698f86a51635d, stripped&#xA;$ file - &amp;lt; /proc/self/exe&#xA;/dev/stdin: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=b73723270773c893cf697d20c8d698f86a51635d, stripped&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We can't use the &lt;code&gt;/proc/self/exe&lt;/code&gt; shortcut in Vim's call to &lt;code&gt;system()&lt;/code&gt;, or as an argument to &lt;code&gt;file&lt;/code&gt;, since then &lt;code&gt;self&lt;/code&gt; will refer to the shell used to execute the command (if we used &lt;code&gt;file - &amp;lt;/proc/self/exe&lt;/code&gt;), or to &lt;code&gt;file&lt;/code&gt; itself (if we used &lt;code&gt;file -L /proc/self/exe&lt;/code&gt;). We &lt;em&gt;could&lt;/em&gt; use &lt;code&gt;/proc/self/exe&lt;/code&gt; if we were to read the file from Vim directly - which is what &lt;a href=&quot;https://vi.stackexchange.com/a/3763/205&quot;&gt;Carpetsmoker's answer&lt;/a&gt; does.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-07-01T01:56:43.877" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="3763" PostTypeId="2" ParentId="3761" CreationDate="2015-06-30T08:38:09.130" Score="6" Body="&lt;p&gt;A &quot;pure&quot; Vim way, just because we can:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let is_64_bits = match(strpart(readfile(resolve('/proc/' . getpid() . '/exe'), 'b', 1)[0], 4, 1), '\%x02') != -1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, how does it work? Split up in multiple commands:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Get the path to the Vim binary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let file = resolve('/proc/' . getpid() . '/exe')&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Read the first &quot;line&quot; of the current binary. Reading a &quot;line&quot; makes little&#xA;sense for binary files, but AFAIK I can't tell Vim to read a &lt;em&gt;n&lt;/em&gt; number of bytes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let contents = readfile(file, 'b', 1)[0]&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Get the fifth byte:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let magic = strpart(contents, 4, 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Check if this byte matches 0x02, if it does, it's a 64-bit binary. Using &lt;code&gt;== '\%x02'&lt;/code&gt; or &lt;code&gt;=~ '\%x02'&lt;/code&gt;  doesn't seem to work, so we use &lt;code&gt;match()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let is_64_bits = match(magic, '\%x02') != -1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I got the &quot;magic&quot; byte value &lt;a href=&quot;https://raw.githubusercontent.com/file/file/master/magic/Magdir/elf&quot; rel=&quot;nofollow&quot;&gt;from the &lt;code&gt;magic&lt;/code&gt; file that the &lt;code&gt;file&lt;/code&gt;&#xA;command uses&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0   string      \177ELF     ELF&#xA;!:strength *2&#xA;&amp;gt;4  byte        0       invalid class&#xA;&amp;gt;4  byte        1       32-bit&#xA;&amp;gt;4  byte        2       64-bit&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note that just using &lt;code&gt;file&lt;/code&gt; as per muru's answer is probably better; I'm not&#xA;sure if this works on all platforms/architectures (although a casual reading of the magic file suggests it would). I was mostly just curious to see if&#xA;this could be done from within VimScript without any external tools ;-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-07-01T17:54:51.937" LastActivityDate="2015-07-01T17:54:51.937" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3765" PostTypeId="2" ParentId="3670" CreationDate="2015-06-30T11:06:47.973" Score="31" Body="&lt;p&gt;A terminal buffer name always starts with &lt;code&gt;term://&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufWinEnter,WinEnter term://* startinsert&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this will always put you in insert mode when you move to the terminal window, regardless of the mode you were using when leaving the window.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also use a similar autocommand to always get back in normal mode when you leave the terminal window, no matter how you leave this window:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufLeave term://* stopinsert&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2646" LastActivityDate="2015-06-30T11:06:47.973" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3767" PostTypeId="1" CreationDate="2015-06-30T12:09:49.213" Score="2" ViewCount="3231" Body="&lt;p&gt;Okay the &lt;code&gt;/usr/share/vim/vim74/syntax/sh.vim&lt;/code&gt; file that came with my system was apparently buggy, so I want to replace it with &lt;a href=&quot;http://www.drchip.org/astronaut/vim/syntax/&quot; rel=&quot;nofollow&quot;&gt;the version by &quot;Dr. Chip&quot;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I really should not edit the files under &lt;code&gt;/usr/share/vim/&lt;/code&gt; directory, so can I 'override' the buggy version with the new version by simply sticking the (new) &lt;code&gt;sh.vim&lt;/code&gt; file somewhere?&lt;/p&gt;&#xA;" OwnerUserId="2647" LastActivityDate="2015-06-30T14:06:43.727" Title="How to safely 'override' existing syntax highlighting file?" Tags="|vimscript|syntax-highlighting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3768" PostTypeId="2" ParentId="3767" CreationDate="2015-06-30T13:59:33.300" Score="5" Body="&lt;p&gt;When you enter the command &lt;code&gt;:help syn-file&lt;/code&gt; they say:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;&lt;p&gt;Create your user runtime directory.   You would normally use the first item&#xA;  of the 'runtimepath' option.  Example for Unix: &#xA;  &lt;code&gt;mkdir ~/.vim&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Create a directory in there called &quot;syntax&quot;.  For Unix: &#xA;  &lt;code&gt;mkdir ~/.vim/syntax&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Write the Vim syntax file.  Or download one from the internet.  Then write&#xA;  it in your syntax directory.  For example, for the &quot;mine&quot; syntax: &#xA;  &lt;code&gt;:w ~/.vim/syntax/mine.vim&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;  &#xA;  &lt;p&gt;Now you can start using your syntax file manually: &#xA;   &lt;code&gt;:set syntax=mine&lt;/code&gt;&#xA;  You don't have to exit Vim to use this.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think that should do the trick for your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I'm not sure how buggy is your original file but &lt;a href=&quot;https://stackoverflow.com/a/7451388/4194289&quot;&gt;this answer&lt;/a&gt; may interest you. For the tl;dr version: including the first line &lt;code&gt;#!/bin/bash&lt;/code&gt; (or whatever is the shell you're using) helps vim to determine which syntax should be used (but I don't know if it is relevant in your case).&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-06-30T14:06:43.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3769" PostTypeId="1" CreationDate="2015-06-30T14:00:41.057" Score="5" ViewCount="1355" Body="&lt;p&gt;We can copy to &lt;a href=&quot;https://vi.stackexchange.com/a/96/205&quot;&gt;both the + and * registers&lt;/a&gt;, but this doesn't actually copy the content to X's memory (apparently). If you copy something from Vim using the &lt;code&gt;*&lt;/code&gt; or &lt;code&gt;+&lt;/code&gt; registers and quit Vim, poof! There's nothing left to paste. With other applications, this isn't the case - at least with the clipboard if not with primary. This &lt;a href=&quot;https://stackoverflow.com/q/6453595/2072269&quot;&gt;StackOverflow post&lt;/a&gt; suggests using &lt;code&gt;xsel&lt;/code&gt; or other external utilities. Is there a way to do this without using an external utility?&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-12-17T16:02:00.010" Title="Can Vim add to the X11 clipboard or primary buffers without an external utility?" Tags="|cut-copy-paste|os-clipboard|x11|" AnswerCount="1" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="3770" PostTypeId="2" ParentId="3769" CreationDate="2015-06-30T14:46:37.083" Score="13" Body="&lt;p&gt;TL;DR: This isn't really possible without a clipboard manager (e.g. &lt;a href=&quot;http://clipit.rspwn.com&quot; rel=&quot;nofollow&quot;&gt;clipit&lt;/a&gt;, &lt;a href=&quot;https://launchpad.net/diodon&quot; rel=&quot;nofollow&quot;&gt;diodon&lt;/a&gt;, &lt;a href=&quot;https://launchpad.net/glipper&quot; rel=&quot;nofollow&quot;&gt;glipper&lt;/a&gt;, &lt;a href=&quot;http://parcellite.sourceforge.net&quot; rel=&quot;nofollow&quot;&gt;parcellite&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's an explicit design choice of X to not store the data for the X &lt;a href=&quot;http://tronche.com/gui/x/icccm/sec-2.html#s-2&quot; rel=&quot;nofollow&quot;&gt;selections&lt;/a&gt;, whether that's the &lt;code&gt;PRIMARY&lt;/code&gt; (what Vim calls &lt;code&gt;&quot;*&lt;/code&gt;) or &lt;code&gt;CLIPBOARD&lt;/code&gt; (what Vim calls &lt;code&gt;&quot;+&lt;/code&gt;) selection.  When a user performs a copy in an application, the application just tells X &lt;code&gt;Hey, I'm asserting ownership of the PRIMARY selection, just in case someone asks for the data.&lt;/code&gt;, but that's it.  It takes another application to actually request the data for X to bother shuttling it between the two applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is likely due to the other design choice of explicitly being a client/server model to easily have X and applications running on different computers.  In that setup, why would you ever want to copy the data across the network on a Copy if there may never be an actual Paste that uses the data?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you've ruled out using a different tool (commonly called a clipboard manager) to listen for the assertion, consume all the data, and then assert it now has ownership of the selection, you're almost out of luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's one avenue left, called the &lt;a href=&quot;http://tronche.com/gui/x/icccm/sec-3.html#s-3&quot; rel=&quot;nofollow&quot;&gt;cut buffers&lt;/a&gt;.  These can hold data, but only a small, fixed amount of data and it must be ISO-8859-1 encoded.  When Vim exits, if it still has an assertion on the PRIMARY selection, it will attempt to dump the contents into &lt;code&gt;CUT_BUFFER0&lt;/code&gt;.  Similarly, when you try to paste from the &lt;code&gt;PRIMARY&lt;/code&gt; selection, many applications will, when no one is asserting ownership of the PRIMARY selection, fallback to looking for data in &lt;code&gt;CUT_BUFFER0&lt;/code&gt;.  If &lt;code&gt;CUT_BUFFER0&lt;/code&gt; does have data, then that will be pasted.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2015-12-17T16:02:00.010" LastActivityDate="2015-12-17T16:02:00.010" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3771" PostTypeId="1" AcceptedAnswerId="3774" CreationDate="2015-06-30T16:27:12.810" Score="21" ViewCount="7944" Body="&lt;p&gt;Suppose that I'm editing a file, then I press &lt;code&gt;:w&lt;/code&gt; to store it. And then I use &lt;code&gt;:e.&lt;/code&gt; to navigate its containing folder in the netrw. Suppose its containing folder is &lt;code&gt;./A/B/&lt;/code&gt;. In netrw, I open a file with path &lt;code&gt;./D/E&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is when I enter into the file &lt;code&gt;./D/E&lt;/code&gt;, how can I return to &lt;code&gt;./D/&lt;/code&gt; or &lt;code&gt;./A/B/&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;:b#&lt;/code&gt;, but only to return to the previous edited file, not to the netrw. I know that I can use &lt;code&gt;:e.&lt;/code&gt; again to return to &lt;code&gt;./A/B/&lt;/code&gt; since it's current path. Is there any way to return to &lt;code&gt;./D/&lt;/code&gt;, the containing folder of the currently being edited file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="1080" LastActivityDate="2018-11-21T23:06:07.667" Title="How to return to netrw from a file" Tags="|buffers|netrw|path|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3772" PostTypeId="2" ParentId="3771" CreationDate="2015-06-30T17:23:59.783" Score="4" Body="&lt;p&gt;&lt;code&gt;:e %:h&lt;/code&gt; navigates to the directory of the current file. See &lt;code&gt;:help expand()&lt;/code&gt; for more info. Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-vinegar&quot; rel=&quot;nofollow&quot;&gt;Vinegar&lt;/a&gt; plugin essentially binds &lt;code&gt;-&lt;/code&gt; to this, and introduces a few small other conveniences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; to navigate to the previous jump/file shown in the current window.&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-06-30T17:23:59.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3773" PostTypeId="1" AcceptedAnswerId="3778" CreationDate="2015-06-30T19:22:56.597" Score="11" ViewCount="243" Body="&lt;p&gt;Is it possible to define a text object in vim that will act on a rectangular region? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, suppose I have vertically aligned columns of text, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;column 1 co    column 2 col&#xA;lumn 1 colu    umn 2 column&#xA;mn 1 column    2 column 2 c&#xA;1 column 1     olumn 2 colu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would it be possible to define a textobject &lt;code&gt;c&lt;/code&gt; for columns, such that &lt;code&gt;dac&lt;/code&gt; would delete a column, &lt;code&gt;yac&lt;/code&gt; would yank it, &lt;code&gt;cac&lt;/code&gt; would change it, and so on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I know about Control-V for selecting a rectangular region, and I know you can then use &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, etc to delete, yank etc the selected region. But I'm specifically curious about what's possible using text objects.)&lt;/p&gt;&#xA;" OwnerUserId="2657" LastEditorUserId="1292" LastEditDate="2019-01-24T12:49:00.930" LastActivityDate="2019-01-24T12:49:00.930" Title="Rectangular regions as text objects?" Tags="|cursor-motions|custom-text-object|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3774" PostTypeId="2" ParentId="3771" CreationDate="2015-06-30T20:44:41.683" Score="16" Body="&lt;pre&gt;&lt;code&gt;:E[xplore]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does the same thing as &lt;code&gt;:e %:h&lt;/code&gt;, and is shorter to type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look up &lt;code&gt;:help :Explore&lt;/code&gt;, you can see that there are also variations to open the directory of the current file in a new tab or split instead of in the current window.&lt;/p&gt;&#xA;" OwnerUserId="2659" LastActivityDate="2015-06-30T20:44:41.683" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3775" PostTypeId="1" CreationDate="2015-06-30T23:00:15.630" Score="4" ViewCount="265" Body="&lt;p&gt;I'm working with handlebars right now and I'd like to get tags like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{{#component 'whatever'}}&#xA;&#xA;{{/component}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{{#if}}&#xA;&#xA;{{else}}&#xA;&#xA;{{/if}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to increase the indent count. Unfortunately, it doesn't look like you can add handlebars with &lt;code&gt;g:html_indent_tags&lt;/code&gt; or &lt;code&gt;indentkeys&lt;/code&gt;. Even Tim Pope's &lt;code&gt;ragtag&lt;/code&gt; doesn't seem to support handlebars.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how I can add handlebars to html.vim so that they increase the indent count?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Progress&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm hacking the html5.vim package to try to move this forward. I've gotten the increase in indentation working by adding these changes to &lt;code&gt;html5.vim/indent/html.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;add the pattern to tags&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call add(s:tags, 'view')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Modify HtmlIndentOpen Function&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;original:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; [-- count indent-increasing tags of line a:lnum --]&#xA;fun! &amp;lt;SID&amp;gt;HtmlIndentOpen(lnum, pattern)&#xA;    let s = substitute('x'.getline(a:lnum),&#xA;    \ '.\{-}\(\(&amp;lt;\)\('.a:pattern.'\)\&amp;gt;\)', &quot;\1&quot;, 'g')&#xA;    let s = substitute(s, &quot;[^\1].*$&quot;, '', '')&#xA;    return strlen(s)&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;modified:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; [-- count indent-increasing tags of line a:lnum --]&#xA;fun! &amp;lt;SID&amp;gt;HtmlIndentOpen(lnum, pattern)&#xA;    let s = substitute('x'.getline(a:lnum),&#xA;    \ '.\{-}\(\(&amp;lt;\|{{#\)\('.a:pattern.'\)\&amp;gt;\)', &quot;\1&quot;, 'g')&#xA;    let s = substitute(s, &quot;[^\1].*$&quot;, '', '')&#xA;    return strlen(s)&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only change is in the regex that &lt;code&gt;substitute&lt;/code&gt; is using. I've changed the first group from &lt;code&gt;&amp;lt;&lt;/code&gt; (i.e. match only an opening bracket) to &lt;code&gt;&amp;lt;\|{{#&lt;/code&gt; (i.e. match an opening bracket or an opening handlebar expression).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And it works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{{#view 'thing'}}&#xA;  stuff about things&#xA;  {{/view}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The indentation gets increased on the &lt;code&gt;{{#view 'thing'}}&lt;/code&gt; line. But, the closing tag &lt;code&gt;{{/view}}&lt;/code&gt; isn't decreasing the indent count yet.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Modify HtmlIndentClose Function&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;original:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; [-- count indent-decreasing tags of line a:lnum --]&#xA;fun! &amp;lt;SID&amp;gt;HtmlIndentClose(lnum, pattern)&#xA;    let s = substitute('x'.getline(a:lnum),&#xA;    \ '.\{-}\(\(&amp;lt;\)/\('.a:pattern.'\)\&amp;gt;&amp;gt;\)', &quot;\1&quot;, 'g')&#xA;    let s = substitute(s, &quot;[^\1].*$&quot;, '', '')&#xA;    return strlen(s)&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;modified:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; [-- count indent-decreasing tags of line a:lnum --]&#xA;fun! &amp;lt;SID&amp;gt;HtmlIndentClose(lnum, pattern)&#xA;    let s = substitute('x'.getline(a:lnum),&#xA;    \ '.\{-}\(\(&amp;lt;\|{{\)/\('.a:pattern.'\)\&amp;gt;&amp;gt;\|}}\)', &quot;\1&quot;, 'g')&#xA;    let s = substitute(s, &quot;[^\1].*$&quot;, '', '')&#xA;    return strlen(s)&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, the original is looking for &lt;code&gt;a:pattern&lt;/code&gt; inside of &lt;code&gt;&amp;lt;/&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt;. I've tried to modify it to look for &lt;code&gt;a:pattern&lt;/code&gt; inside of &lt;code&gt;&amp;lt;/&lt;/code&gt; or &lt;code&gt;{{/&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;}}&lt;/code&gt; but it's matching every handlebar expression (e.g. this regex is matching &lt;code&gt;{{outlet}}&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help on figuring out the regex would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="446" LastEditorUserId="446" LastEditDate="2015-07-01T16:11:28.610" LastActivityDate="2015-07-01T16:11:28.610" Title="Is there a way to add handlebars to html.vim?" Tags="|indentation|filetype-html|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3778" PostTypeId="2" ParentId="3773" CreationDate="2015-07-01T12:19:01.493" Score="5" Body="&lt;p&gt;Yes, this is possible. @PeterRincker suggests the plugin &lt;a href=&quot;https://github.com/coderifous/textobj-word-column.vim&quot; rel=&quot;nofollow&quot;&gt;textobj-word-column&lt;/a&gt;, which defines four text objects (&lt;code&gt;ic&lt;/code&gt;, &lt;code&gt;ac&lt;/code&gt;, &lt;code&gt;iC&lt;/code&gt;, and &lt;code&gt;aC&lt;/code&gt;) for word-based columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea behind this functionality is to create a function that defines a column based motion, and then to map this function appropriately to visual/select mode mappings and operator pending mappings. To use the above mentioned plugin as an example, it creates the following mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;silent&amp;gt; ac :&amp;lt;C-u&amp;gt;call TextObjWordBasedColumn(&quot;aw&quot;)&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; aC :&amp;lt;C-u&amp;gt;call TextObjWordBasedColumn(&quot;aW&quot;)&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; ic :&amp;lt;C-u&amp;gt;call TextObjWordBasedColumn(&quot;iw&quot;)&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; iC :&amp;lt;C-u&amp;gt;call TextObjWordBasedColumn(&quot;iW&quot;)&amp;lt;cr&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; ac :call TextObjWordBasedColumn(&quot;aw&quot;)&amp;lt;cr&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; aC :call TextObjWordBasedColumn(&quot;aW&quot;)&amp;lt;cr&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; ic :call TextObjWordBasedColumn(&quot;iw&quot;)&amp;lt;cr&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; iC :call TextObjWordBasedColumn(&quot;iW&quot;)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;TextObjWordBasedColumn(...)&lt;/code&gt; defines the column motion and is mapped to both visual/select mode with &lt;code&gt;xnoremap&lt;/code&gt; and operator pending mode with &lt;code&gt;onoremap&lt;/code&gt;. Note that the function is slightly complex in order to handle indendation and to find the appropriate motion boundaries.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-07-01T12:19:01.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3779" PostTypeId="2" ParentId="3773" CreationDate="2015-07-01T14:39:08.357" Score="4" Body="&lt;p&gt;Is it possible? Absolutely! Case and point: &lt;a href=&quot;https://github.com/coderifous/textobj-word-column.vim&quot; rel=&quot;nofollow&quot;&gt;textobj-word-column.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;How to make your own text objects&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Typically visual mode is used to create a new text object. The visual mode can be line-wise, character-wise (typically), or visual-block. Here is the basics of what you will need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An unused key combination typically &lt;code&gt;a{char}&lt;/code&gt; or &lt;code&gt;i{char}&lt;/code&gt; where &lt;code&gt;{char}&lt;/code&gt; is both descriptive and unused. e.g. &lt;code&gt;i/&lt;/code&gt; as an example text object between &lt;code&gt;/&lt;/code&gt;'s.&lt;/li&gt;&#xA;&lt;li&gt;Need a way to find the start of your text-object. e.g. &lt;code&gt;T/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Need a way to find the end of your text-object. e.g. &lt;code&gt;t/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Choose a visual mode. e.g. &lt;code&gt;v&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Create a visual mode (only) mapping via &lt;code&gt;xnoremap&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Create a operator pending mode mapping that uses the visual mode mapping via &lt;code&gt;onoremap&lt;/code&gt; and &lt;code&gt;:normal&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now for an example of our simple &lt;code&gt;i/&lt;/code&gt; which creates a text-object between &lt;code&gt;/&lt;/code&gt;'s:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap i/ :&amp;lt;c-u&amp;gt;normal! T/vt/&amp;lt;cr&amp;gt;&#xA;onoremap i/ :normal vi/&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As long as you follow the basic ingredients you can create text-objects for all sorts of things.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Advanced text-object creation with vim-textobj-user&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow&quot;&gt;vim-textobj-user&lt;/a&gt; plugin provides a common way to define custom text-objects in a more declarative fashion. For example here is a php tag text-object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call textobj#user#plugin('php', {&#xA;\   'code': {&#xA;\     'pattern': ['&amp;lt;?php\&amp;gt;', '?&amp;gt;'],&#xA;\     'select-a': 'aP',&#xA;\     'select-i': 'iP',&#xA;\   },&#xA;\ })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help with vim-textobj-user see its help doc: &lt;code&gt;:h textobj-user-introduction&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;For more help&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h map-overview&#xA;:h visual-start&#xA;:h :norm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As well as the &lt;a href=&quot;http://vim.wikia.com/wiki/Creating_new_text_objects&quot; rel=&quot;nofollow&quot;&gt;Creating new text objects&lt;/a&gt; Vim wiki page.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-07-01T14:39:08.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3780" PostTypeId="1" CreationDate="2015-07-01T14:50:45.790" Score="5" ViewCount="268" Body="&lt;p&gt;In insert mode, typing normally moves the cursor right and pushes text to the right of the cursor farther to the right on the line.  I am typing some right-aligned text and am wondering - is there a way to tell vim to leave the cursor where it is while inserting, and move text &lt;em&gt;preceding&lt;/em&gt; the cursor to the &lt;em&gt;left&lt;/em&gt;?  (Discarding whatever falls off the beginning of the line is fine.)  I can't find a way on SO or wikia, and there may not be one, but I thought I'd check.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest thing I have found is &lt;code&gt;gR&amp;lt;Ctl-D&amp;gt;&lt;/code&gt; (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#vreplace-mode&quot; rel=&quot;noreferrer&quot;&gt;virtual replace mode&lt;/a&gt;), but that lets me blithely overwrite what is past the cursor position where I started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use case: I have this situation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;line of source code that does something&amp;gt; &amp;lt;tricky part&amp;gt;&#xA;        comment explaining tricky part(*) ^^^^^^^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and want to add text at the place marked &lt;code&gt;(*)&lt;/code&gt; without moving the &lt;code&gt;^^^^^^^^^^^^^&lt;/code&gt;, by pushing &lt;code&gt;comment explaining tricky part&lt;/code&gt; to the left.&lt;/p&gt;&#xA;" OwnerUserId="1430" LastActivityDate="2015-07-02T09:15:32.963" Title="Is there a way to push existing text left while inserting (e.g., insert right-aligned text)?" Tags="|insert-mode|formatting|alignment|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3781" PostTypeId="2" ParentId="3780" CreationDate="2015-07-01T16:38:11.170" Score="6" Body="&lt;p&gt;(EDITED version)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;============ in your vimrc =================&#xA;&#xA;command! TogglePush  :call TogglePush()&#xA;inoremap &amp;lt;Insert&amp;gt; &amp;lt;Esc&amp;gt;:TogglePush&amp;lt;CR&amp;gt;a&#xA;nnoremap &amp;lt;Insert&amp;gt; :TogglePush&amp;lt;CR&amp;gt;&#xA;&#xA;command! EnablePush  :call EnablePush()&#xA;command! DisablePush :call DisablePush()&#xA;&#xA;&quot;============= in a script file =============&#xA;&#xA;let s:push_enabled = 0&#xA;function! TogglePush()&#xA;    if (s:push_enabled)&#xA;        call DisablePush()&#xA;        let s:push_enabled = 0&#xA;        echo &quot;PUSH disabled&quot;&#xA;    else&#xA;        call EnablePush()&#xA;        let s:push_enabled = 1&#xA;        echo &quot;PUSH enabled&quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;function! DisablePush()&#xA;    augroup PushLeft&#xA;        autocmd!&#xA;    augroup END&#xA;    let s:push_enabled = 0&#xA;endfunction&#xA;&#xA;function! EnablePush()&#xA;    augroup PushLeft&#xA;        autocmd!&#xA;        autocmd TextChangedI * call AfterChange()&#xA;    augroup END&#xA;    let s:push_enabled = 1&#xA;    let s:cursor_column = getpos(&quot;.&quot;)[2]&#xA;endfunction&#xA;&#xA;&#xA;let s:cursor_column = -1&#xA;&#xA;function! AfterChange()&#xA;    let l = getline(&quot;.&quot;)&#xA;    let lnum = getpos(&quot;.&quot;)[1]&#xA;    let c = getpos(&quot;.&quot;)[2] &quot;get cursor column&#xA;    let col_diff = c - s:cursor_column&#xA;    if (col_diff &amp;gt; 0) &quot; at actual text insertion&#xA;        call setline('.', strpart(getline('.'), col_diff))&#xA;    else&#xA;        let filler = ''&#xA;        while col_diff &amp;lt; 0&#xA;            let filler .= ' '&#xA;            let col_diff += 1&#xA;        endwhile&#xA;        call setline('.', filler . getline('.'))&#xA;    endif&#xA;        call cursor(lnum, s:cursor_column)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a somewhat improved version of the original answer. When you enable the push (in the example below, pressing the &lt;code&gt;Insert&lt;/code&gt; key, or with &lt;code&gt;:EnablePush&lt;/code&gt; from vim cmd-line), the current column number is saved as the &quot;pinned cursor column&quot; position and an 'after-text-was-changed-in-insert-mode' event is enabled, that will try to keep the cursor on &lt;em&gt;that&lt;/em&gt; column, and preserve the text &lt;em&gt;after&lt;/em&gt; the cursor. The text &lt;em&gt;before&lt;/em&gt; the cursor is altered like follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if characters were added, all text before the cursor is moved to the &lt;em&gt;left&lt;/em&gt;, and the characters at the beginning of the line disappear (i.e. they &quot;fall&quot; behind the left margin).&lt;/li&gt;&#xA;&lt;li&gt;if backspace was pressed, text before the cursor is moved to the &lt;em&gt;right&lt;/em&gt;, by inserting &lt;code&gt;space&lt;/code&gt; chars at line start.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;NOTES:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This adds a &quot;pin cursor to column&quot; functionality.&lt;/li&gt;&#xA;&lt;li&gt;If cursor doesn't seem to be on the right column, it means there are some real tabs on the left of the cursor, and what you &lt;em&gt;see&lt;/em&gt; is the &quot;virtual cursor&quot; position (I didn't use &lt;code&gt;virtcol()&lt;/code&gt; etc.).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-07-02T09:15:32.963" LastActivityDate="2015-07-02T09:15:32.963" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3782" PostTypeId="1" AcceptedAnswerId="3783" CreationDate="2015-07-01T22:51:19.980" Score="1" ViewCount="81" Body="&lt;p&gt;I have this function and mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! TwiceToQuit()&#xA;    sil! q&#xA;&#xA;    if v:errmsg == 'E37: No write since last change (add ! to override)'&#xA;        echohl ErrorMsg&#xA;        echo 'No write since last change, really quit?'&#xA;        echohl None&#xA;        if !exists('w:countofq')&#xA;            let w:countofq = 0&#xA;        endif&#xA;        let w:countofq += 1&#xA;        if w:countofq == 2&#xA;            q!&#xA;        endif&#xA;    endif&#xA;endfun&#xA;&#xA;noremap &amp;lt;F2&amp;gt; &amp;lt;Esc&amp;gt;:call TwiceToQuit()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when I press &lt;kbd&gt;F2&lt;/kbd&gt; at a modified file it asks me if I really want to quit, if so I press &lt;kbd&gt;F2&lt;/kbd&gt; again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works, but I have a few problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When I have 2 windows, one with some regular file and the second one with &lt;code&gt;help&lt;/code&gt; and I press F2 when the first window is active, it closes the whole vim. I have found some autocommand event related to this - &lt;code&gt;QuitPre&lt;/code&gt;, but there aren't any autocommands associated with it so I don't know why is this happening.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I accidentally hold &lt;kbd&gt;F2&lt;/kbd&gt;, it just spams the command so everything gets closed. I don't want that.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I want to reset the variable &lt;code&gt;w:countofq&lt;/code&gt; if I press some other key than &lt;kbd&gt;F2&lt;/kbd&gt;. Is that possible?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2620" LastEditorUserId="205" LastEditDate="2015-07-02T02:32:27.750" LastActivityDate="2015-07-02T19:33:33.910" Title="Don't close regular + help window at once, reset a variable on keypress" Tags="|vimscript|quit|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3783" PostTypeId="2" ParentId="3782" CreationDate="2015-07-02T10:07:44.593" Score="2" Body="&lt;p&gt;Here's how I would do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! TwiceToQuit()&#xA;    &quot; Buffer is not modified. We can quit&#xA;    if !&amp;amp;modified&#xA;        quit&#xA;        return&#xA;    endif&#xA;&#xA;    echohl ErrorMsg&#xA;    echo 'No write since last change; press again to force quit.'&#xA;    echohl None&#xA;&#xA;    &quot; Get a single character&#xA;    let l:char = getchar()&#xA;&#xA;    &quot; If this is &amp;lt;F2&amp;gt;, quit&#xA;    if char2nr(l:char) == 128 &amp;amp;&amp;amp; l:char[1:] ==# 'k2'&#xA;        quit!&#xA;    else&#xA;        &quot; This clears the red error message in the &quot; commandline&#xA;        execute &quot;normal! \&amp;lt;C-l&amp;gt;&quot; &#xA;&#xA;        &quot; Try and execute the character&#xA;        if !empty(nr2char(l:char))&#xA;            execute 'normal! ' . nr2char(l:char)&#xA;        endif&#xA;    endif&#xA;endfun &#xA;&#xA;noremap &amp;lt;F2&amp;gt; &amp;lt;Esc&amp;gt;:call TwiceToQuit()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We don't need to call &lt;code&gt;:quit&lt;/code&gt; to see if the buffer is modified, we can use the&#xA;&quot;special&quot; &lt;code&gt;'modified'&lt;/code&gt; setting for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that we use the &lt;code&gt;getchar()&lt;/code&gt; function to get the next character; which is&#xA;an easier way of doing things than keeping some state variable.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I accidentally hold F2, it just spams the command so everything gets&#xA;  closed. I don't want that.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is no obvious way to prevent this. As far as I know, Vim can't see if&#xA;you've pressed &lt;code&gt;&amp;lt;F2&amp;gt;&lt;/code&gt; twice, or held the key for 5 seconds.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-07-02T10:07:44.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3784" PostTypeId="1" AcceptedAnswerId="3786" CreationDate="2015-07-02T11:07:26.067" Score="3" ViewCount="1415" Body="&lt;p&gt;when I use  to autocomplete in neovim, I get two completion lists. The following screenshot was taken with an empty .nvimrc.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/9GIXB.png&quot; alt=&quot;Neovim with two completion lists&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To reproduce: Open &lt;code&gt;nvim&lt;/code&gt;, enter &lt;code&gt;:e&lt;/code&gt;, tab &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; to get the (in this case) blue completion list, then tab &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; again to get the second interactive list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to disable the blue completion list, is that possible?&#xA;I also noticed that &lt;code&gt;vim&lt;/code&gt; does indeed only shows me the second list. &lt;/p&gt;&#xA;" OwnerUserId="2675" LastEditorUserId="51" LastEditDate="2015-07-02T11:45:18.623" LastActivityDate="2015-07-02T11:45:18.623" Title="Disable command bar completion list" Tags="|neovim|wildmenu|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3785" PostTypeId="1" CreationDate="2015-07-02T11:32:49.890" Score="2" ViewCount="158" Body="&lt;p&gt;I would like to open new tabs for each file matching an expression, each file in a new tab and as read only. I do not want to replace my current buffer, just append the new tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This comes very close, but unfortunately it replaces any existing tabs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command OpenLogs args X:\Path\ToLogs\*Log.txt | tab all | tabdo set readonly&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="2676" LastEditorUserId="51" LastEditDate="2015-07-02T12:09:49.987" LastActivityDate="2015-07-02T12:12:36.350" Title="Open multiple files in new tabs as read only" Tags="|multiple-files|tabbed-user-interface|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3786" PostTypeId="2" ParentId="3784" CreationDate="2015-07-02T11:45:08.763" Score="7" Body="&lt;p&gt;The yellow &quot;interactive&quot; list is called the &quot;wildmenu&quot;. You can enable &amp;amp; disable&#xA;this with the &lt;code&gt;'wildmenu'&lt;/code&gt; setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;'wildmode'&lt;/code&gt; setting controls when to show this menu. If this contains the&#xA;&lt;code&gt;list&lt;/code&gt; keyword, it will list all possible completions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably want to use &lt;code&gt;set wildmode=full&lt;/code&gt;, but see &lt;code&gt;:help wildmode&lt;/code&gt; for more&#xA;options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The defaults are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;wildmenu&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vim: Off&lt;/li&gt;&#xA;&lt;li&gt;NeoVim: On&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;wildmode&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vim: &lt;code&gt;full&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;NeoVim: &lt;code&gt;list:longest,full&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-07-02T11:45:08.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3787" PostTypeId="1" CreationDate="2015-07-02T11:54:52.750" Score="3" ViewCount="152" Body="&lt;p&gt;I’m trying to use the &lt;a href=&quot;http://atp-vim.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;Automatic LATEX Plugin for Vim (ATP)&lt;/a&gt;, and found it has quite neat features. However, I do not like input abbreviations, so I tried to disable them using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:atp_no_env_maps=1&#xA;let g:atp_imap_define_greek_letters = 0&#xA;let g:atp_imap_define_math = 0&#xA;let g:atp_imap_define_math_misc = 0&#xA;let g:atp_imap_define_diacritics = 0&#xA;let g:atp_imap_define_fonts = 0&#xA;let g:atp_tab_map = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;.vimrc&lt;/code&gt;. But that did not cut it, it seems. In particular, when I&#xA;enter &lt;code&gt;'&lt;/code&gt; or &lt;code&gt;`&lt;/code&gt; or &lt;code&gt;\s&lt;/code&gt; or &lt;code&gt;\c&lt;/code&gt;, the cursor does not advance until I press the&#xA;next key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the recommended way to disable these imaps, but still have the&#xA;&lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; imap?&lt;/p&gt;&#xA;" OwnerUserId="1937" LastEditorUserId="1841" LastEditDate="2015-08-02T12:33:55.517" LastActivityDate="2016-02-28T17:25:54.810" Title="Disabling Automatic Latex Plugin (ATP) mappings" Tags="|key-bindings|filetype-tex|abbreviations|plugin-atp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3788" PostTypeId="2" ParentId="3785" CreationDate="2015-07-02T12:12:36.350" Score="1" Body="&lt;p&gt;I ended up using Carpetsmoker's solution here: &lt;a href=&quot;https://vi.stackexchange.com/q/2108/51&quot;&gt;How can I open multiple tabs at once?&lt;/a&gt;, simply replacing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'tabedit ' . l:c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'tabedit ' . l:c . '| setlocal readonly'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2676" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-07-02T12:12:36.350" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3789" PostTypeId="1" AcceptedAnswerId="11973" CreationDate="2015-07-02T12:31:27.010" Score="12" ViewCount="691" Body="&lt;p&gt;I'm using the &lt;code&gt;a&quot;&lt;/code&gt; motion rather often in vim; e.g. using &lt;code&gt;ca&quot;&lt;/code&gt; while refactoring a piece of code to replace a hardcoded argument with a variable name. The problem with this approach is that &lt;code&gt;a&quot;&lt;/code&gt; &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#a%60&quot;&gt;includes leading whitespace if there is no trailing whitespace&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Any trailing white space is included, unless there is none, then leading white space is included.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus, when I edit a function call like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aFunction(arg1, &quot;toBeReplaced&quot;, arg3) #original&#xA;aFunction(arg1, replacedArg, arg3)    #refactored&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to manually re-insert the space before &lt;code&gt;replacedArg&lt;/code&gt; as &lt;code&gt;ca&quot;&lt;/code&gt; deletes it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any similar motion that does not include this white space, or is there anything else I can use instead of &lt;code&gt;ca&quot;&lt;/code&gt; that saves me from having to type an extra space?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;cf&quot;&lt;/code&gt; does what I want as long as the string doesn't contain any escaped quotes, but requires me to have the cursor at the beginning of the string. I'd like something I can use from anywhere within the string, and &lt;code&gt;?&quot;&amp;lt;Enter&amp;gt;cf&quot;&lt;/code&gt; is rather awkward to type.&lt;/li&gt;&#xA;&lt;li&gt;It's less about the single &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; keystroke and more about the fact that I often initially forget to include the space, costing me at least four extra keystrokes (&lt;code&gt;bi&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;) and breaking my focus. Thus the length of the replacement command is not as important, as long as it deletes only the text between the given chars and then enters insert mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="117" LastActivityDate="2017-04-04T12:07:46.600" Title="Is there a motion similar to a&quot; that never includes leading whitespace?" Tags="|replace|cursor-motions|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3790" PostTypeId="2" ParentId="3789" CreationDate="2015-07-02T12:51:28.887" Score="10" Body="&lt;p&gt;There is, in Wellle's &lt;a href=&quot;https://github.com/wellle/targets.vim&quot; rel=&quot;noreferrer&quot;&gt;targets.vim&lt;/a&gt; plugin. To quote the relevant part (inside the section &amp;quot;&lt;strong&gt;A Quote&lt;/strong&gt;&amp;quot; ):&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;a' a&amp;quot; a&lt;/code&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Select a quote.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This overrides Vim's default text object to support seeking.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Unlike Vim's quote text objects, &lt;em&gt;this includes no surrounding whitespace&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-07-02T13:02:22.107" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3791" PostTypeId="2" ParentId="3789" CreationDate="2015-07-02T14:39:13.733" Score="5" Body="&lt;p&gt;As an alternative you can use an argument/parameter text object. Now Vim does not have native argument text objects but there are a few plugins out there that do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/PeterRincker/vim-argumentative&quot;&gt;argumentative.vim&lt;/a&gt; (I wrote this one)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/AndrewRadev/sideways.vim&quot;&gt;sideways.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/b4winckler/vim-angry&quot;&gt;vim-angry&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/wellle/targets.vim&quot;&gt;targets.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2699&quot;&gt;argtextobj.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2979&quot;&gt;parameter_objects.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Probably &lt;a href=&quot;http://vimawesome.com/?q=argument&quot;&gt;more&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Personally I use my own plugin, argumentative.vim, however I have heard good things about both sideways.vim and targets.vim.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-07-02T14:39:13.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3792" PostTypeId="1" CreationDate="2015-07-02T17:39:58.433" Score="3" ViewCount="1267" Body="&lt;p&gt;I have &lt;code&gt;'a&lt;/code&gt; and &lt;code&gt;'b&lt;/code&gt; bounding some lines of text.  I want to convert all the &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;h&lt;/code&gt;, &lt;code&gt;n&lt;/code&gt;, and &lt;code&gt;m&lt;/code&gt; variables to upper case.  A sample line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f(w,h,n,m) | w &amp;lt;= 0 | h &amp;lt;= 0 | n &amp;lt; 0 | m &amp;lt; 0 = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to me that this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'a,'b g/\&amp;lt;[whnm]\&amp;gt;/normal ~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't work.  It matches the line, but does not match the individual variables.  It leaves the cursor at the beginning of the line and capitalizes the &lt;code&gt;f&lt;/code&gt; there.  How do I make it perform the &lt;code&gt;~&lt;/code&gt; action at every match in the range?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this particular example can be done simply with a regex substitution.  I don't want to do that.  I want to run an arbitrary command at every location that matches a search pattern, which seems like something obvious to do, but so far appears impossible to do in vim.&lt;/p&gt;&#xA;" OwnerUserId="2678" LastEditorUserId="8" LastEditDate="2015-07-03T02:53:07.353" LastActivityDate="2019-10-29T10:04:42.447" Title="Apply a command to each occurrence of a pattern in a range" Tags="|search|mark|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3793" PostTypeId="2" ParentId="3792" CreationDate="2015-07-02T17:53:51.803" Score="3" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'a,'b s/\v(&amp;lt;[whnm]&amp;gt;)/\U\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Short expl.:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\v&lt;/code&gt; - very magic&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(...)&lt;/code&gt; - create 1st group&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\U\1&lt;/code&gt; - make 1st group uppercase&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good references: &lt;a href=&quot;http://vimregex.com/&quot; rel=&quot;nofollow&quot;&gt;vimregex&lt;/a&gt;, &lt;a href=&quot;http://dahu.github.io/vim_waz_ere/&quot; rel=&quot;nofollow&quot;&gt;W.A.Zintz'&lt;/a&gt;s articles&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To operate &lt;em&gt;on each match&lt;/em&gt;, repeatedly, using a &quot;normal-mode&quot; command, you could do this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\C\v&amp;lt;[whnm]&amp;gt; ENTER&#xA;~       (&amp;lt;- or any other command(s) operating on the match)&#xA;qqn.q   (&amp;lt;- create a macro with &quot;go to next result, repeat command(s) above&quot;)&#xA;20@q    (&amp;lt;- repeat the macro 20 times)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use any number instead of 20, ideally bigger than than the number of matches, the condition being that your command applied to the match makes it a non-match for a second search round - when the search hits bottom and starts again from the top (hence the &lt;code&gt;\C&lt;/code&gt; - case sensitive search).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-07-02T18:39:08.883" LastActivityDate="2015-07-02T18:39:08.883" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3794" PostTypeId="1" CreationDate="2015-07-02T18:08:41.997" Score="5" ViewCount="328" Body="&lt;p&gt;When I'm nearing the right-hand side of my vim window, the vim-jedi's pop has some weird line-wrapping behavior:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QlPCO.png&quot; alt=&quot;simple vim window with line-wrapped vim-jedi popup&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this normal behavior? How can I get the popup window to be shifted leftwards and appear all on one line?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="69" LastEditDate="2015-07-02T18:23:49.147" LastActivityDate="2016-03-11T07:26:58.730" Title="Why does the vim-jedi popup have weird line wrapping?" Tags="|wrapping|plugin-jedi-vim|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3795" PostTypeId="2" ParentId="3792" CreationDate="2015-07-02T18:26:01.840" Score="3" Body="&lt;p&gt;You can use the the &lt;code&gt;gn&lt;/code&gt; motion to operation on the current search pattern match and repeat your operation via the &lt;code&gt;.&lt;/code&gt; command. Example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/foo&lt;/code&gt; - set pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gUgn&lt;/code&gt; - uppercase (&lt;code&gt;gU&lt;/code&gt;) the current match, &lt;code&gt;gn&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt; move to the next match&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt; to repeat your last operation, &lt;code&gt;gUgn&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note: I find this method doesn't work the best with single character matches as &lt;code&gt;gn&lt;/code&gt; will select the current charter to the next match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need Vim 7.4 to use &lt;code&gt;gn&lt;/code&gt; motion and 7.4.110+ to use &lt;code&gt;gUgn&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h gn&#xA;:h gU&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is also a nice &lt;a href=&quot;http://vimcasts.org/&quot; rel=&quot;nofollow&quot;&gt;Vimcasts&lt;/a&gt; episode on this: &lt;a href=&quot;http://vimcasts.org/episodes/operating-on-search-matches-using-gn/&quot; rel=&quot;nofollow&quot;&gt;Operating on search matches using gn&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-07-02T18:31:43.197" LastActivityDate="2015-07-02T18:31:43.197" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3796" PostTypeId="2" ParentId="3782" CreationDate="2015-07-02T19:33:33.910" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;That is the way, Vims &lt;code&gt;:q&lt;/code&gt; command works. Until recently there was not really a way around it. Vim doesn't consider a help window to be important, so whenever only a help buffer is open, it will silently quit. You could try either to use &lt;code&gt;:helpclose&lt;/code&gt; explictly to close all help windows or use &lt;code&gt;:.q&lt;/code&gt; to explicitly close only the current window. Both are relative recent additions and won't work in older Vims. Put this in your function to check for the number on windows currently open (&lt;code&gt;:h winnr()&lt;/code&gt;) and you should be able to get it working.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Not possible.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;not really possible,except you really want to map every other character &#xA;away and reset the variable.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-07-02T19:33:33.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3797" PostTypeId="2" ParentId="3787" CreationDate="2015-07-02T19:42:25.617" Score="2" Body="&lt;p&gt;If nothing helps, you can always explicitly &lt;code&gt;:unmap&lt;/code&gt;/&lt;code&gt;:unabbreviate&lt;/code&gt; the keys in a filetype event autocommand or using the ftplugin/tex.vim file. That should make it work. Don't forget, that you probably need the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; modifier for those commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But perhaps, you want to ask the author of that plugin directly. It seems, he will be better suited to answer this question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the help, it seems &lt;code&gt;:ToggleIMaps&lt;/code&gt; should at least partially get rid of the &lt;kbd&gt;`&lt;/kbd&gt; and &lt;kbd&gt;'&lt;/kbd&gt; mappings.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-07-02T19:42:25.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3798" PostTypeId="1" AcceptedAnswerId="3799" CreationDate="2015-07-02T20:31:09.520" Score="1" ViewCount="702" Body="&lt;p&gt;Please excuse my ignorance, I'm probably missing something pretty fundamental here in regards to how 256 color terminals actually work with vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to create a custom color scheme for vim and upon looking at the source of some existing color schemes such as &lt;a href=&quot;https://github.com/junegunn/seoul256.vim/blob/master/colors/seoul256.vim&quot; rel=&quot;nofollow&quot;&gt;seoul256&lt;/a&gt; and &lt;a href=&quot;https://github.com/sjl/badwolf/blob/master/colors/badwolf.vim&quot; rel=&quot;nofollow&quot;&gt;badwolf&lt;/a&gt;, I notice that they are defining their own custom color palettes that are not a part of the standard 256 colors. I was under the impression that the colors available are confined to the &lt;a href=&quot;http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html&quot; rel=&quot;nofollow&quot;&gt;256 terminal colors?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are they simply overriding the default colors? Am I able to replace any 8-bit addressable color with my own arbitrary ones?&lt;/p&gt;&#xA;" OwnerUserId="2061" LastActivityDate="2015-07-02T21:36:16.307" Title="Defining a custom rgb map for creating a color scheme?" Tags="|terminal|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3799" PostTypeId="2" ParentId="3798" CreationDate="2015-07-02T21:36:16.307" Score="3" Body="&lt;p&gt;The &lt;code&gt;s:rgb_map&lt;/code&gt; in seoul256 and all the &lt;code&gt;s:bwc.*&lt;/code&gt; in badwolf do not define colors outside of the xterm palette. Rather, they are just there to &lt;em&gt;map&lt;/em&gt; the finely-tuned hexadecimal colors used in GUI Vim with their closest equivalent in the xterm palette used in color terminals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taking seoul256 as an example, &lt;code&gt;#999872&lt;/code&gt; will be used for some highlight groups in GVim/MacVim while the similar but slightly darker &lt;code&gt;101&lt;/code&gt; (&lt;code&gt;#87875f&lt;/code&gt;) will be used for the same highlight groups in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Such compromises are &lt;em&gt;very&lt;/em&gt; commonplace in the colorscheme business. If you don't like that, I see four &quot;solutions&quot; which all come with their own issues and compromises:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Choose all your colors from the xterm palette&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is the path I chose when I started work on &lt;a href=&quot;https://github.com/romainl/Apprentice&quot; rel=&quot;nofollow&quot;&gt;my own colorscheme&lt;/a&gt;. The good side is that your colorscheme is more or less guaranteed to look the same in Vim &lt;em&gt;and&lt;/em&gt; GVim but you will soon find out that the xterm palette has &lt;em&gt;many&lt;/em&gt; shortcomings (no browns, dark colors too intense…) that will restrict your creativity.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Ask your users to change their xterm palette&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Programs like &lt;a href=&quot;https://github.com/trapd00r/colorcoke&quot; rel=&quot;nofollow&quot;&gt;colorcoke&lt;/a&gt; let you change the xterm palette in &lt;a href=&quot;https://github.com/trapd00r/colorcoke/wiki&quot; rel=&quot;nofollow&quot;&gt;many crazy ways&lt;/a&gt;. If using a very specific palette is an important part of your concept you can make that program — or some script that you generated with it — part of the requirements for installing/using your colorscheme.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Target custom builds or Neovim running in a handful of terminal emulators&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can patch Vim so that it can use the &lt;code&gt;rgb(00,00,00)&lt;/code&gt; notation in the &lt;a href=&quot;https://gist.github.com/XVilka/8346728&quot; rel=&quot;nofollow&quot;&gt;terminal emulators that support that feature&lt;/a&gt;. &lt;a href=&quot;https://bitbucket.org/ZyX_I/vim/commits/branch/24-bit-xterm&quot; rel=&quot;nofollow&quot;&gt;That patch&lt;/a&gt; recently found its way in Neovim so that could be another option for you.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Build your colorscheme for 16 colors terminal emulators&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;…and give your users a ready made palette for customizing their terminal emulator.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;So…&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;My preference goes to the first process because all the others have too many requirements and dependencies that make installation and support too hard.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-07-02T21:36:16.307" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3800" PostTypeId="1" AcceptedAnswerId="3801" CreationDate="2015-07-02T21:37:27.177" Score="3" ViewCount="415" Body="&lt;p&gt;I want to be able to insert the results of -&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;date +&quot;%y-%m-%d %H:%M:00&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;at the cursor in vim. How would you run the above command in BASH but get the results and insert them directly at the cursor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I am running the command as -&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r!date +&quot;\%y-\%m-\%d \%H:\%M:\%S&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this inserts the contents on a new line. What is the correct method to evaluate a bash script AT the cursor?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Current Issue -&#xA;Date:&#xA;15-07-02 14:36:24&#xA;&#xA;Expected Result -&#xA;Date: 15-07-02 14:36:24&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1417" LastEditorUserId="51" LastEditDate="2015-07-02T22:18:17.330" LastActivityDate="2015-07-02T22:18:17.330" Title="How do you run a command in VIM that outputs at cursor?" Tags="|command-line|bash|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3801" PostTypeId="2" ParentId="3800" CreationDate="2015-07-02T21:45:52.833" Score="5" Body="&lt;p&gt;The built-in &lt;code&gt;strftime()&lt;/code&gt; does exactly what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;=strftime('%y-%m-%d %H:%M:%S')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To turn that into a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;key&amp;gt; strftime('%y-%m-%d %H:%M:%S')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can of course use whatever external command you need but it is important to keep in mind that the output of Unix commands usually ends with a newline character that needs to be removed in one way or another. The general solution is to strip that newline from the output before inserting it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;=substitute(system(&quot;date +'%y-%m-%d %H:%M:%S'&quot;), &quot;\n&quot;, &quot;&quot;, &quot;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is an ideal client for a mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help strftime()&#xA;:help system()&#xA;:help substitute()&#xA;:help i_ctrl-r&#xA;:help &quot;=&#xA;:help :map-expression&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-07-02T22:08:43.590" LastActivityDate="2015-07-02T22:08:43.590" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3802" PostTypeId="1" AcceptedAnswerId="3803" CreationDate="2015-07-02T23:09:47.663" Score="9" ViewCount="3460" Body="&lt;p&gt;I use, e.g., &lt;code&gt;dw&lt;/code&gt; to delete a word based on word boundaries defined by changing character classes, so that this command applied on &lt;code&gt;abc,def,ghi&lt;/code&gt; will result in &lt;code&gt;,def,ghi&lt;/code&gt;. (So far so good, and it worked for me for decades.) Now, since just recently, that does not work any more on dots (&lt;code&gt;.&lt;/code&gt;); that &lt;code&gt;dw&lt;/code&gt; command applied on &lt;code&gt;abc.def;ghi&lt;/code&gt; will result in &lt;code&gt;;ghi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain what happens here; maybe whether I changed some setting by accident. - How can that misbehaviour be fixed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Following Peter's hint in his answer I obtained:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  iskeyword=@,48-57,_,192-255,.&#xA;        Last set from /usr/share/vim/vim73/syntax/sh.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and found this content in &lt;code&gt;/usr/share/vim/vim73/syntax/sh.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; AFAICT &quot;.&quot; should be considered part of the iskeyword.  Using iskeywords in&#xA;&quot; syntax is dicey, so the following code permits the user to prevent/override&#xA;&quot; its setting.&#xA;if exists(&quot;g:sh_isk&quot;)          &quot; override support&#xA; exe &quot;setlocal isk=&quot;.g:sh_isk&#xA;elseif !exists(&quot;g:sh_noisk&quot;)   &quot; prevent modification support&#xA; setlocal isk+=.&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now this seems to be a system setting. I have no reservations against changing that file - only that it will be changed again on system updates, I fear. But since I am not familiar with vim's script language I'd be interested to know what the correct way to fix it would be. Personally I'd just remove the &lt;code&gt;.&lt;/code&gt; so that the &lt;code&gt;+=&lt;/code&gt; becomes a no-op, but I guess the whole &lt;code&gt;if&lt;/code&gt; statement need to be fixed. (What's that &lt;code&gt;&quot;g:sh_noisk&quot;&lt;/code&gt;?)&lt;/p&gt;&#xA;" OwnerUserId="2479" LastEditorUserId="2479" LastEditDate="2015-07-03T01:33:57.623" LastActivityDate="2015-07-03T01:42:11.420" Title="Define word boundaries" Tags="|normal-mode|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3803" PostTypeId="2" ParentId="3802" CreationDate="2015-07-02T23:40:39.973" Score="11" Body="&lt;p&gt;Sounds like &lt;code&gt;'iskeyword'&lt;/code&gt; changed recently. You can do &lt;code&gt;:verbose set iskeyword?&lt;/code&gt; to see where &lt;code&gt;'iskeyword'&lt;/code&gt; was last set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your specific issue is with the &lt;code&gt;sh&lt;/code&gt; filetype. Here is an excerpt from &lt;code&gt;:h g:sh_isk&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The shell languages appear to let &quot;.&quot; be part of words, commands, etc;&#xA;consequently it should be in the isk for sh.vim.  As of v116 of syntax/sh.vim,&#xA;syntax/sh.vim will append the &quot;.&quot; to 'iskeyword' by default; you may control&#xA;this behavior with:&#xA;    let g:sh_isk  = '..whatever characters you want as part of iskeyword'&#xA;    let g:sh_noisk= 1  &quot; otherwise, if this exists, the isk will NOT chg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to this you will need to add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:sh_noisk = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'iskeyword'&#xA;:h :set-verbose&#xA;:h local-options&#xA;:h g:sh_isk&#xA;:h ft-sh-syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-07-03T01:42:11.420" LastActivityDate="2015-07-03T01:42:11.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3804" PostTypeId="5" CreationDate="2015-07-03T00:10:44.080" Score="0" Body="&lt;p&gt;Examples of motion commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;w       to start of next word&#xA;b       to begin of current word&#xA;4j      four lines down&#xA;/The&amp;lt;CR&amp;gt;    to next occurrence of &quot;The&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more details see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/intro.html#%7Bmotion%7D&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h {motion}&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#motion.txt&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h motion.txt&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="1841" LastEditDate="2016-05-01T09:31:06.157" LastActivityDate="2016-05-01T09:31:06.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3805" PostTypeId="4" CreationDate="2015-07-03T00:10:44.080" Score="0" Body="Commands that moves the cursor. A motion command is used after an operator command to move over the text that is to be operated upon." OwnerUserId="51" LastEditorUserId="1841" LastEditDate="2016-05-01T09:31:06.157" LastActivityDate="2016-05-01T09:31:06.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3806" PostTypeId="1" CreationDate="2015-07-03T01:50:38.443" Score="2" ViewCount="90" Body="&lt;p&gt;Screen capture says it all:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/0iRnp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, the vertical highlighting is continuous, but because I have long lines word-wrapping around, only one character gets highlighted. Is there a way to fix this?&lt;/p&gt;&#xA;" OwnerUserId="2684" LastActivityDate="2015-07-03T05:37:58.507" Title="CursorColumn isn't a continuous line anymore when wordwrap is on" Tags="|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3807" PostTypeId="2" ParentId="3806" CreationDate="2015-07-03T05:37:58.507" Score="3" Body="&lt;p&gt;No, this is the way the CursorColumn works.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-07-03T05:37:58.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3808" PostTypeId="1" AcceptedAnswerId="3810" CreationDate="2015-07-03T08:27:47.860" Score="4" ViewCount="757" Body="&lt;p&gt;I am aware of the &lt;code&gt;startinsert&lt;/code&gt; command which switch to insert mode as if the &lt;code&gt;i&lt;/code&gt; key was pressed. With the &lt;code&gt;!&lt;/code&gt; it behaves like &lt;code&gt;A&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know if there is some kind of option to go to insert mode like we press the &lt;code&gt;a&lt;/code&gt; key?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-07-03T08:35:20.843" LastActivityDate="2015-07-03T09:17:17.897" Title="Vimscript insert after cursor" Tags="|vimscript|insert-mode|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3809" PostTypeId="1" AcceptedAnswerId="4928" CreationDate="2015-07-03T09:15:23.247" Score="8" ViewCount="1596" Body="&lt;p&gt;I'm having the following CSS class structure &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.mAIcon&#xA;.mAIcon-reject&#xA;.mAIcon-edit&#xA;.mAIcon-accept&#xA;.event&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside my HTML files I want to autocomplete these class names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;span class=&quot;mAIcon mA|&quot;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to autocomplete the rest the only thing I get is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;span class=&quot;mAIcon mAIcon|&quot;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get what I really want I have to type an extra &lt;code&gt;-&lt;/code&gt; and for example &lt;code&gt;e&lt;/code&gt; and use the autocompletion again.&#xA;But then I get everything that starts with an &lt;code&gt;e&lt;/code&gt;, even the class &lt;code&gt;event&lt;/code&gt;.&#xA;This is really annoying and makes the autocompletion rather useless in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Vim's generic keyword completion with the &lt;code&gt;i_CTRL-N&lt;/code&gt; command and I don't have any additional completion plugins installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to include the &lt;code&gt;-&lt;/code&gt; to the detection of CSS class names for the autocompletion?&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2015-07-05T15:41:41.460" LastActivityDate="2015-09-30T13:59:07.170" Title="How to Autocomplete CSS class names that include a minus character?" Tags="|autocompletion|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3810" PostTypeId="2" ParentId="3808" CreationDate="2015-07-03T09:17:17.897" Score="0" Body="&lt;p&gt;Here is a workaround with manually detecting if the cursor is at the end of the line : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if col('.') == col('$') - 1&#xA;    startinsert! &quot; `A`&#xA;else&#xA;    normal l     &quot; `l`&#xA;    startinsert  &quot; `i`&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;col('$')&lt;/code&gt; is the last column + 1 so if the cursor is at the end of the line we must substract 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;reference : &lt;a href=&quot;https://stackoverflow.com/a/19544043/2558252&quot;&gt;https://stackoverflow.com/a/19544043/2558252&lt;/a&gt; (thanks to the robert-audi comment)&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-07-03T09:17:17.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3811" PostTypeId="2" ParentId="3809" CreationDate="2015-07-03T09:48:02.757" Score="10" Body="&lt;p&gt;Yes, you can define what characters are considered part of keywords with the &lt;code&gt;'iskeyword'&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal iskeyword+=-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add the following snippet to your &lt;code&gt;vimrc&lt;/code&gt; to restrict that option to CSS and HTML files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup css&#xA;    autocmd!&#xA;    autocmd FileType css,html setlocal iskeyword+=-&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-07-05T07:51:25.267" LastActivityDate="2015-07-05T07:51:25.267" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3812" PostTypeId="1" AcceptedAnswerId="3813" CreationDate="2015-07-03T11:52:09.707" Score="18" ViewCount="3167" Body="&lt;p&gt;Let's say I have four open files: &lt;code&gt;file0.txt&lt;/code&gt;, &lt;code&gt;file1.txt&lt;/code&gt;, &lt;code&gt;file2.txt&lt;/code&gt;, and &lt;code&gt;file3.txt&lt;/code&gt;. I open all of them in that order as tabs. So my tab ordering is this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;file0.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;file1.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;file2.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;file3.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then let's say that I want to instead reorder my tabs so that &lt;code&gt;file2.txt&lt;/code&gt; comes before &lt;code&gt;file1.txt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;file0.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;file2.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;file1.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;file3.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How do I do that? Is there a Vim command to move the current tab to the left or right, or otherwise reorder the currently opened tabs?&lt;/p&gt;&#xA;" OwnerUserId="2683" LastEditorUserId="1577" LastEditDate="2015-07-03T12:41:15.460" LastActivityDate="2015-07-05T17:03:34.990" Title="How do I reorder open tabs?" Tags="|multiple-files|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3813" PostTypeId="2" ParentId="3812" CreationDate="2015-07-03T12:02:43.017" Score="23" Body="&lt;p&gt;You can use the &lt;code&gt;tabmove&lt;/code&gt; command. (&lt;code&gt;:help tabmove&lt;/code&gt; will tell you all you need to know)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command takes two kind of parameters:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A sign (&lt;code&gt;+&lt;/code&gt; or &lt;code&gt;-&lt;/code&gt;) followed by a number:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabmove +2&lt;/code&gt; will move your tab of 2 places to the right &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabmove -2&lt;/code&gt; will do the same to the left.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can also use the command with a simple number to set the position of the tab:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabmove 0&lt;/code&gt; will put the tab as the first one &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabmove 2&lt;/code&gt; will put the tab in the third position&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabmove&lt;/code&gt; will put the tab as the last one&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also I put those lines in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; move current tab to left/right&#xA;noremap &amp;lt;Leader&amp;gt;&amp;lt;Left&amp;gt;  :execute 'silent! tabmove ' . (tabpagenr()-2)&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;Leader&amp;gt;&amp;lt;Right&amp;gt; :execute 'silent! tabmove ' . tabpagenr()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They allow you to move the current tab of one place with the combination &lt;kbd&gt;Leader&lt;/kbd&gt;+&lt;kbd&gt;Right arrow&lt;/kbd&gt; and &lt;kbd&gt;Leader&lt;/kbd&gt;+&lt;kbd&gt;Left arrow&lt;/kbd&gt; maybe they could be useful to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; As @TomMcDo pointed out in the comments the previous mappings could be simplified and still work properly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Leader&amp;gt;&amp;lt;Left&amp;gt;  :tabmove -1&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;Leader&amp;gt;&amp;lt;Right&amp;gt; :tabmove +1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-07-05T17:03:34.990" LastActivityDate="2015-07-05T17:03:34.990" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3814" PostTypeId="1" CreationDate="2015-07-03T13:25:32.423" Score="26" ViewCount="9105" Body="&lt;p&gt;I recently realized that my &lt;code&gt;vimrc&lt;/code&gt; is now more than 400 lines long (which IMO is too much I'll try to reduce that) and to make it easier to navigate, read and edit it I decided to investigate the concept of folding in vim &lt;em&gt;(which I wasn't familiar with)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I tried to set the folding method to &lt;code&gt;indent&lt;/code&gt; but I didn't like the result (It was too messy mostly because a great part of my &lt;code&gt;vimrc&lt;/code&gt; isn't really indented). &lt;/li&gt;&#xA;&lt;li&gt;I also tried to set &lt;code&gt;foldmethod&lt;/code&gt; to &lt;code&gt;expr&lt;/code&gt; and &lt;code&gt;syntax&lt;/code&gt; but I wasn't able to fold anything properly.&lt;/li&gt;&#xA;&lt;li&gt;Here using &lt;code&gt;diff&lt;/code&gt; as folding method doesn't seem relevant. (Or if it is I didn't understand how to use it)&lt;/li&gt;&#xA;&lt;li&gt;So for now I'm using the &lt;code&gt;marker&lt;/code&gt; method which doesn't totally satisfy me because of the &lt;code&gt;&quot;{{{&lt;/code&gt; and &lt;code&gt;&quot;}}}&lt;/code&gt; markers which I found &quot;noisy&quot; in the file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So I'd like to know if there are best practices or common guidelines about properly folding a &lt;code&gt;vimrc&lt;/code&gt;&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 1:&lt;/strong&gt; As we all know SO isn't a forum and isn't made to collect personal opinions and that's not what I'm looking for: of course I guess some people has their preferences but I'd like to know why using markers (for example) improves the readability more than using indent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 2:&lt;/strong&gt; Also my main goal is to make my &lt;code&gt;vimrc&lt;/code&gt; as clear as possible so if other best practices exists to create a nice &lt;code&gt;vimrc&lt;/code&gt; I'm curious about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 1:&lt;/strong&gt; I should have precised that my &lt;code&gt;vimrc&lt;/code&gt; is already subdivided in sections (and sometimes subsection) the main ones being &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;general options&lt;/li&gt;&#xA;&lt;li&gt;plugins (containing a subsection for each plugin and its configuration)&lt;/li&gt;&#xA;&lt;li&gt;mappings&lt;/li&gt;&#xA;&lt;li&gt;navigation (also containing subsection)&lt;/li&gt;&#xA;&lt;li&gt;color&lt;/li&gt;&#xA;&lt;li&gt;etc...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And it's this structure which made me thought of folding: I feel that being able to output only the section I'm interested in at a certain point is something pretty convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt; Answer mentioning subdivisions of the &lt;code&gt;vimrc&lt;/code&gt; in several files are valid, but as a personal preference I'd rather use folding because I think it is easier to maintain only one file in the git repo containing my dotfiles. That is only a personal preference and I'm aware that is it possible to also use this approach but I'd prefer to use folding.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-11T15:03:52.910" LastActivityDate="2020-08-29T19:03:47.000" Title="Is there a best practice to fold a vimrc file" Tags="|vimrc|folding|" AnswerCount="8" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3815" PostTypeId="2" ParentId="3728" CreationDate="2015-07-03T13:42:55.300" Score="13" Body="&lt;p&gt;I have set up the following remaps in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-h&amp;gt; &amp;lt;C-w&amp;gt;h&#xA;nmap &amp;lt;C-j&amp;gt; &amp;lt;C-w&amp;gt;j&#xA;nmap &amp;lt;C-k&amp;gt; &amp;lt;C-w&amp;gt;k&#xA;nmap &amp;lt;C-l&amp;gt; &amp;lt;C-w&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I can use &lt;code&gt;Ctrl+h&lt;/code&gt; to move to the left window, &lt;code&gt;Ctrl+l&lt;/code&gt; to move to the right window, etc. It just seems to logically fit with the normal navigation of Vim.&lt;/p&gt;&#xA;" OwnerUserId="2688" LastActivityDate="2015-07-03T13:42:55.300" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3816" PostTypeId="2" ParentId="3814" CreationDate="2015-07-03T13:46:09.180" Score="2" Body="&lt;p&gt;Basic best practises: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Divide into sections:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Plugins&lt;/li&gt;&#xA;&lt;li&gt;Settings&lt;/li&gt;&#xA;&lt;li&gt;Rebinds&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Comment each section/rebind&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;(backup your &lt;code&gt;.vimrc&lt;/code&gt; or &lt;code&gt;_vimrc&lt;/code&gt; on Github)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Just my personal preference. Maybe not so much help though. &lt;/p&gt;&#xA;" OwnerUserId="2689" LastEditorUserId="8" LastEditDate="2015-07-04T06:18:18.067" LastActivityDate="2015-07-04T06:18:18.067" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3817" PostTypeId="2" ParentId="3814" CreationDate="2015-07-03T13:49:24.533" Score="10" Body="&lt;p&gt;I use my primary &lt;code&gt;vimrc&lt;/code&gt; as a link to several other categorized files, sourcing each as it goes along, e.g. Vim options in one file, plugin settings in another. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;--- Vim Options&#xA;source ~/.vim/config/vim_options.vim&#xA;&#xA;&quot;--- Here Be Functions!&#xA;&quot; (need to be sourced before stuff that uses 'em)&#xA;runtime! functions/*.vim&#xA;&#xA;&quot;--- Key Mapping&#xA;source ~/.vim/config/key_mapping.vim&#xA;&#xA;&quot;--- Folding&#xA;source ~/.vim/config/folding.vim&#xA;&#xA;&quot;--- Autocmds&#xA;source ~/.vim/config/autocmds.vim&#xA;&#xA;&quot;--- We Are Plugged In!&#xA;source ~/.vim/config/plugins.vim&#xA;&#xA;&quot; vim: ft=vim fdm=marker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a more direct answer to OP question, I do use the marker method, but off to the right side with spacing, and around more categories than individual, for the most part. I do each plugin separately though. &lt;/p&gt;&#xA;" OwnerUserId="2303" LastActivityDate="2015-07-03T13:49:24.533" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3818" PostTypeId="2" ParentId="3814" CreationDate="2015-07-03T14:15:36.733" Score="9" Body="&lt;p&gt;You could say that &quot;best practice&quot; is preeminently a matter of opinion, :) but there are two approaches that (1) make obvious sense, and (2) can be applied to all config files, not only Vim's: folding by logical sections and subsections (or even deeper, if you feel brave), and splitting your config into several smaller files and &lt;code&gt;:source&lt;/code&gt;-ing them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally prefer folding because it makes things easier to access, while still giving me some hierarchy to pick up from.  Folding functions and &lt;code&gt;autocmd&lt;/code&gt;s at innermost levels is also a good idea, since these make &quot;natural&quot; logical units.  &lt;code&gt;marker&lt;/code&gt; folding makes most sense for all this, because logical hierarchies are not necessarily reflected into indent levels, or into syntax highlighting.  I also increase &lt;code&gt;foldcolumn&lt;/code&gt;, which gives me a visual hint of where I am:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: filetype=vim foldmethod=marker foldlevel=0 foldcolumn=3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On a side note, this &lt;code&gt;foldtext&lt;/code&gt; function (a modification of a similar function by Drew Neil, IIRC) makes more sense to me than the default:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFoldText()&#xA;    let line = getline(v:foldstart)&#xA;&#xA;    let nucolwidth = &amp;amp;foldcolumn + &amp;amp;number * &amp;amp;numberwidth&#xA;    let windowwidth = winwidth(0) - nucolwidth - 3&#xA;    let foldedlinecount = v:foldend - v:foldstart&#xA;&#xA;    &quot; expand tabs into spaces&#xA;    let chunks = split(line, &quot;\t&quot;, 1)&#xA;    let line = join(map(chunks[:-2], 'v:val . repeat(&quot; &quot;, &amp;amp;tabstop - strwidth(v:val) % &amp;amp;tabstop)'), '') . chunks[-1]&#xA;&#xA;    let line = strpart(line, 0, windowwidth - 2 - len(foldedlinecount))&#xA;    let fillcharcount = windowwidth - len(line) - len(foldedlinecount) - 1&#xA;    return line . '...' . repeat(' ', fillcharcount) . foldedlinecount . ' '&#xA;endfunction&#xA;set foldtext=MyFoldText()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the other approach, split files, the main problems are finding things, and switching from one file to another.  A very nice way to address both is to use a plugin such as &lt;a href=&quot;https://github.com/dyng/ctrlsf.vim&quot;&gt;CtrlSF&lt;/a&gt;, &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot;&gt;CtrlP&lt;/a&gt;, or similar.  But you're probably already using one of those anyway.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="1577" LastEditDate="2015-07-03T14:48:41.983" LastActivityDate="2015-07-03T14:48:41.983" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3820" PostTypeId="2" ParentId="3814" CreationDate="2015-07-03T15:44:58.863" Score="25" Body="&lt;p&gt;I have the following modelines at the bottom of my &lt;code&gt;vimrc&lt;/code&gt; which I copied from godlygeek, the author of &lt;a href=&quot;https://github.com/godlygeek/tabular&quot; rel=&quot;nofollow noreferrer&quot;&gt;tabular&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;&amp;quot; vim:fdm=expr:fdl=0&#xA;&amp;quot;&amp;quot; vim:fde=getline(v\:lnum)=~'^&amp;quot;&amp;quot;'?'&amp;gt;'.(matchend(getline(v\:lnum),'&amp;quot;&amp;quot;*')-2)\:'='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will make any line starting with 2+ &lt;code&gt;&amp;quot;&lt;/code&gt;'s a fold. The more &lt;code&gt;&amp;quot;&lt;/code&gt;'s the deeper the fold. This allows you to sub divide sections if you need.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; As noted in a comment below the second modeline now causes an error in Vim. Here's a note from the patch that introduced the change:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Patch 8.1.1366&lt;/p&gt;&#xA;&lt;p&gt;Problem:    Using expressions in a modeline is unsafe.&lt;/p&gt;&#xA;&lt;p&gt;Solution:   Disallow using expressions in a modeline, unless the&#xA;'modelineexpr' option is set.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;And, no, you can't set &lt;code&gt;'modelineexpr'&lt;/code&gt; from the modeline! You could try setting &lt;code&gt;'fde'&lt;/code&gt; as above in an autocmd (e.g. &lt;code&gt;autocmd Filetype vim ...&lt;/code&gt;). I (&lt;em&gt;B Layer&lt;/em&gt;) didn't test this but I did test it manually. You need to escape the &lt;code&gt;&amp;quot;&lt;/code&gt;s.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set fde=getline(v\:lnum)=~'^\&amp;quot;\&amp;quot;'?'&amp;gt;'.(matchend(getline(v\:lnum),'\&amp;quot;\&amp;quot;*')-2)\:'='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="11054" LastEditDate="2020-08-29T19:03:47.000" LastActivityDate="2020-08-29T19:03:47.000" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3821" PostTypeId="1" AcceptedAnswerId="3823" CreationDate="2015-07-04T03:44:05.383" Score="23" ViewCount="1909" Body="&lt;p&gt;I already know that you can copy something to the a register using:&#xA;(plus a yank, delete, etc. command)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also understand that you can append to the a register using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In addition I understand how to copy something to the clipboard register using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What do I type to append to the clipboard register?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:59) Huge version with GTK2 GUI.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="2695" LastEditDate="2016-03-02T01:22:24.493" LastActivityDate="2022-02-10T21:05:45.940" Title="How does one append to the clipboard register in vim?" Tags="|cut-copy-paste|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3822" PostTypeId="2" ParentId="3821" CreationDate="2015-07-04T06:26:51.403" Score="9" Body="&lt;p&gt;You can call &lt;code&gt;setreg('+', lines, 'a')&lt;/code&gt;, but as far as I can tell there is no way to do that with normal mode commands.  You have to use one of the upper case letter registers for that.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="1577" LastEditDate="2015-07-04T06:32:27.147" LastActivityDate="2015-07-04T06:32:27.147" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3823" PostTypeId="2" ParentId="3821" CreationDate="2015-07-04T07:08:11.530" Score="13" Body="&lt;p&gt;There is no normal mode command for that but you can simply append to another register and &lt;code&gt;:let&lt;/code&gt; the clipboard register to the content of that register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Ay&#xA;&quot;Ay&#xA;&quot;Ay&#xA;:let @+ = @A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-07-04T07:08:11.530" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3824" PostTypeId="1" AcceptedAnswerId="3829" CreationDate="2015-07-04T22:00:30.680" Score="-4" ViewCount="230" Body="&lt;p&gt;I initially posted a question assuming there was something to type that would signal append other than just using upper-case letters.&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/3821/how-does-one-append-to-the-clipboard-register-in-vim&quot;&gt;How does one append to the clipboard register in vim?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this resulted in finding out the impossibility of that type of solution, so I decided to reword the question.&#xA;I was given many a reference to this post &lt;a href=&quot;https://stackoverflow.com/questions/6303882/vim-append-to-clipboard&quot;&gt;vim append to clipboard&lt;/a&gt;, which I don't understand. In that post they use &lt;code&gt;my_expression&lt;/code&gt;, what does that refer to? Does it refer to the letter I want to set as &lt;code&gt;+&lt;/code&gt;? If so, would I use the capital version?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question boils down to: I want a thorough description of what to do to set clipboard register to a different name so it can be appended using the capital form. Answers have been copied and pasted with little explanation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DO NOT PASTE &lt;code&gt;let @+ .= my_expression&lt;/code&gt; here and call it a day.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If needed here is my vim version: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:59) Huge version with GTK2 GUI.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-07-05T10:46:19.247" Title="How does one change the name of the clipboard register?" Tags="|os-clipboard|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3825" PostTypeId="1" AcceptedAnswerId="3827" CreationDate="2015-07-04T23:45:41.227" Score="-2" ViewCount="3976" Body="&lt;p&gt;Currently all I have to do is type &lt;code&gt;vim file_name&lt;/code&gt; and it will make that file in the current directory (usually user because that is where the command line start at if you don't use the cd command). It would annoy me tremendously to have to move to the documents folder every time I want to open a vim file. Would there be a way to do this automatically? Maybe using aliases? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim version info:&#xA;VIM - Vi IMproved 7.4&#xA;Huge version with GTK2 GUI&lt;/p&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="1841" LastEditDate="2015-07-05T10:47:20.240" LastActivityDate="2021-03-16T18:35:53.473" Title="How to change the directory to save a file" Tags="|filesystem|working-directory|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3826" PostTypeId="2" ParentId="3825" CreationDate="2015-07-04T23:58:09.170" Score="-1" Body="&lt;p&gt;A hot-fix is to just put in the following alias:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias dim='cd /home/usr/Documents/; vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="51" LastEditDate="2015-07-05T21:39:01.790" LastActivityDate="2015-07-05T21:39:01.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3827" PostTypeId="2" ParentId="3825" CreationDate="2015-07-05T09:11:03.610" Score="4" Body="&lt;p&gt;First of all wherever you open vim, you have access to the whole filesystem from within vim.&lt;/p&gt;&#xA;&lt;p&gt;If you open vim without parameters or if you open a new buffer inside of vim with &lt;code&gt;:new&lt;/code&gt; you can then save it to the drive with &lt;code&gt;:w \path\to\file&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then to access to those files you have a lot of different options. For example :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;netrw&lt;/strong&gt; which is the built in file Explorer of vim, you can call it with &lt;code&gt;:Explore&lt;/code&gt;. More info &lt;a href=&quot;http://vimcasts.org/episodes/the-file-explorer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strike&gt;&lt;strong&gt;NERDTree&lt;/strong&gt; an excellent file explorer for the beginners because it reminds a lot of the classical system file explorers... Ones might say that it is not &amp;quot;the vim way&amp;quot; to navigate files but it is worth a try. See &lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/strike&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I wrote that 6 years ago, when I didn't knew better. Since then I've seen dozens of questions showing how this plugin confuses newcomers (including myself), how buggy it can be and how many bad practices it pushes. Please refrain from using NERDTree &lt;em&gt;especially&lt;/em&gt; if you are new to vim. I strongly encourage you to read &lt;a href=&quot;http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt; to convince you that this is not a good idea. If &lt;code&gt;netrw&lt;/code&gt; doesn't fit your needs you could have a look at &lt;a href=&quot;https://github.com/tpope/vim-vinegar&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-vinegar&lt;/a&gt; which tries to improve it a bit.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;ctrlp&lt;/strong&gt; a really good fuzzy finder which can be confusing for beginners. See &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; If you want to go the fuzzy way in 2021+ I recommend &lt;a href=&quot;https://github.com/junegunn/fzf.vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf&lt;/a&gt; instead because it is faster, however it is a much larger tool which can be overwhelming for a new user.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Of course you have a lot of other options but Google should be your friend to find them.&lt;/p&gt;&#xA;&lt;p&gt;Also I don't know your workflow and what kind of files you're editing but that sounds pretty weird to edit your files in only 2 folders (&lt;code&gt;user&lt;/code&gt; and &lt;code&gt;documents&lt;/code&gt; if I'm right) so your answer with an alias to change of directory before opening vim is far from being ideal: if you need to edit files in another directory will you create another alias? And what if you use 10 or 100 directories? That's why I presented different file exploring solution.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2021-03-16T18:35:53.473" LastActivityDate="2021-03-16T18:35:53.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3828" PostTypeId="2" ParentId="3760" CreationDate="2015-07-05T09:48:09.507" Score="2" Body="&lt;p&gt;If you want to toggle background, add this to your &lt;code&gt;vimrc&lt;/code&gt;, (edit mapping according to what you like)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use this on OS X 10.10.2 on &lt;code&gt;iTerm&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BgToggleSol()&#xA;  if &amp;amp;background == &quot;light&quot;&#xA;    execute &quot;:set background=dark&quot;&#xA;  else&#xA;    execute &quot;:set background=light&quot;&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;ct :call BgToggleSol()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check out &lt;a href=&quot;http://github.com/bk2dcradle/Dotfiles&quot; rel=&quot;nofollow&quot;&gt;git&lt;/a&gt; for more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tip: Since you are using a mac, pasting using Command+V must be a pain. Add this to your vimrc as well&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;term =~ &quot;xterm.*&quot;&#xA;    let &amp;amp;t_ti = &amp;amp;t_ti . &quot;\e[?2004h&quot;&#xA;    let &amp;amp;t_te = &quot;\e[?2004l&quot; . &amp;amp;t_te&#xA;    function XTermPasteBegin(ret)&#xA;        set pastetoggle=&amp;lt;Esc&amp;gt;[201~&#xA;        set paste&#xA;        return a:ret&#xA;    endfunction&#xA;    map &amp;lt;expr&amp;gt; &amp;lt;Esc&amp;gt;[200~ XTermPasteBegin(&quot;i&quot;)&#xA;    imap &amp;lt;expr&amp;gt; &amp;lt;Esc&amp;gt;[200~ XTermPasteBegin(&quot;&quot;)&#xA;    cmap &amp;lt;Esc&amp;gt;[200~ &amp;lt;nop&amp;gt;&#xA;    cmap &amp;lt;Esc&amp;gt;[201~ &amp;lt;nop&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2704" LastEditorUserId="2704" LastEditDate="2015-07-05T09:54:28.437" LastActivityDate="2015-07-05T09:54:28.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3829" PostTypeId="2" ParentId="3824" CreationDate="2015-07-05T10:46:19.247" Score="4" Body="&lt;p&gt;You wouldn't have to spam us with all those questions if you took the time to read — and try to understand — the documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is only one clipboard register, &lt;code&gt;&quot;+&lt;/code&gt; and you can't &lt;em&gt;append&lt;/em&gt; to that register directly like you could with &lt;code&gt;&quot;a-z&lt;/code&gt;, simply because there is no such thing as &quot;capital +&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want several yankings to end up in the clipboard register, the simplest solution is to append to a temporary register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Ay&#xA;&quot;Ay&#xA;&quot;Ay&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and, when you have everything, export the content of that temporary register to your system clipboard with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @+ = @a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A more involved way would still imply to append to some named register and export to your system clipboard with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg('+', @a, getregtype('a'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that's the end of the story.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum it all up:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can't rename the clipboard register.&lt;/li&gt;&#xA;&lt;li&gt;You can't append to the clipboard register the same way you can append to named registers.&lt;/li&gt;&#xA;&lt;li&gt;Don't fight against Vim.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-07-05T10:46:19.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3830" PostTypeId="1" AcceptedAnswerId="4454" CreationDate="2015-07-05T13:44:51.430" Score="2" ViewCount="149" Body="&lt;p&gt;Dumb question, but I can't find the answer in vim.org or Wikia - is there a reference for the @ tags (@Author, @License, ...) at the top of some of the vim scripts in the registry?  For example, &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2289&quot; rel=&quot;nofollow&quot;&gt;loremipsum.vim&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; loremipsum.vim&#xA;&quot; @Author:      Thomas Link (micathom AT gmail com?subject=[vim])&#xA;&quot; @Website:     http://www.vim.org/account/profile.php?user_id=4037&#xA;&quot; @License:     GPL (see http://www.gnu.org/licenses/gpl.txt)&#xA;&quot; @Created:     2008-07-10.&#xA;&quot; @Last Change: 2008-07-11.&#xA;&quot; @Revision:    66&#xA;&quot; GetLatestVimScripts: 2289 0 loremipsum.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Context: wondering how a script with two authors should be tagged).&lt;/p&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="1430" LastEditDate="2015-07-05T14:29:59.123" LastActivityDate="2015-08-22T19:35:32.603" Title="vimscript documentation header @tag reference?" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3831" PostTypeId="1" AcceptedAnswerId="3922" CreationDate="2015-07-05T14:09:26.937" Score="2" ViewCount="236" Body="&lt;p&gt;I need a vim shortcut to display all non-duplicate &lt;code&gt;struct&lt;/code&gt; names in the file being edited. I have made &lt;a href=&quot;https://stackoverflow.com/questions/31202598/search-and-print-all-non-duplicate-struct-names-inside-input-file&quot;&gt;this C program&lt;/a&gt; which does this, however I have to leave the editor and execute the program in &lt;code&gt;bash&lt;/code&gt; and return back to editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say the file being edited is &lt;a href=&quot;https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/smsc/smsc911x.c?id=965b2aa78fbcb831acf4f669f494da201f4bcace&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;linux/drivers/net/ethernet/smsc/smsc911x.c&lt;/code&gt;&lt;/a&gt;. The output should be like following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 0. smsc911x_data&#xA; 1. smsc911x_ops&#xA; 2. smsc911x_platform_config&#xA; 3. phy_device&#xA; 4. mii_bus&#xA; 5. net_device&#xA; 6. napi_struct&#xA; 7. regulator_bulk_data&#xA; 8. clk&#xA; 9. platform_device&#xA;10. sk_buff&#xA;11. net_device_stats&#xA;12. netdev_hw_addr&#xA;13. sockaddr&#xA;14. ethtool_drvinfo&#xA;15. ethtool_eeprom&#xA;16. ethtool_ops&#xA;17. net_device_ops&#xA;18. resource&#xA;19. device_node&#xA;20. dev_pm_ops&#xA;21. of_device_id&#xA;22. platform_driver&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: The &lt;code&gt;Parse()&lt;/code&gt; vim routine defined in the answer posted below doesn't prints all the struct names. It's output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0. clk&#xA;1. device_node&#xA;2. ethtool_drvinfo&#xA;3. ethtool_eeprom&#xA;4. mii_bus&#xA;5. napi_struct&#xA;6. net_device&#xA;7. netdev_hw_addr&#xA;8. phy_device&#xA;9. regulator_bulk_data&#xA;10. resource&#xA;11. sk_buff&#xA;12. smsc911x_data&#xA;13. smsc911x_platform_config&#xA;14. sockaddr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess its because it is not able to handle cases like &lt;code&gt;struct { ... } name;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2706" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-07-12T08:50:30.130" Title="How to find non duplicate &lt;type:keywords&gt; of a file?" Tags="|vimscript|command-line|search|external-command|" AnswerCount="3" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3832" PostTypeId="1" AcceptedAnswerId="3834" CreationDate="2015-07-05T16:54:09.257" Score="7" ViewCount="1679" Body="&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Since 8.1.2342, Vim introduced a &lt;code&gt;rand()&lt;/code&gt; function as described by &lt;a href=&quot;https://vi.stackexchange.com/a/27719/1841&quot;&gt;@Maxim Kim's answer&lt;/a&gt;. I'll keep the question here for historical reference.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I recently needed to generate a random number in vim and &lt;a href=&quot;https://vi.stackexchange.com/questions/807/how-to-generate-random-numbers/&quot;&gt;this question&lt;/a&gt; gave me all the solutions I needed.&lt;/p&gt;&#xA;&lt;p&gt;But I still have a question: &lt;strong&gt;Why is there no built-in function to generate a random number?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I mean the vimscript language provides functions to work with numbers like &lt;code&gt;round()&lt;/code&gt;, &lt;code&gt;min()&lt;/code&gt;, the basic operators &lt;code&gt;+-*/&lt;/code&gt;, so what explains that the absence of a &lt;code&gt;rand()&lt;/code&gt; function?&lt;/p&gt;&#xA;&lt;p&gt;For now I see 2 possible explanations but I wasn't able to validate any of them:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Technical limitations: I know the bad reputation of this language but I don't see what would make it unable to generate a random number.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&amp;quot;Ideological&amp;quot; limitation: The creator of vim script could have decided that the language being made to edit text, doesn't need to generate random numbers and this functionality shouldn't be available to the user. I'm not a Vim guru but I don't understand how including such a function would hurt anything or anyone.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Is there another reason that I couldn't figure out by myself? Could someone enlighten me on this?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2020-10-19T12:11:12.533" LastActivityDate="2020-10-19T14:01:18.200" Title="Why doesn't vimscript provide a random number generator?" Tags="|history-of|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="3833" PostTypeId="2" ParentId="3832" CreationDate="2015-07-05T17:09:33.933" Score="7" Body="&lt;p&gt;Well, generating random numbers isn't really the task of a an editor, IMHO. And with Vim, &quot;the Unix way&quot; to do it is to rely on other tools, that do it ... better. E.g. you can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;on *nix systems, read &quot;/dev/urandom&quot; or similar&lt;/li&gt;&#xA;&lt;li&gt;call a program that does it&lt;/li&gt;&#xA;&lt;li&gt;write a plugin in python, ruby, lua etc. - all languages with 'random' support.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Simple, non-security concerned random functionality can be provided directly with vimscript, though, by reading ... time microseconds values. Here's how it is implemented with the &lt;code&gt;vim-randomtag&lt;/code&gt; plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:randnum(max) abort&#xA;  return str2nr(matchstr(reltimestr(reltime()), '\v\.@&amp;lt;=\d+')[1:]) % a:max&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;P.S. I'm not saying that it won't be useful to have a function in vimscript, though ...&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-07-05T17:29:47.900" LastActivityDate="2015-07-05T17:29:47.900" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3834" PostTypeId="2" ParentId="3832" CreationDate="2015-07-05T17:09:43.253" Score="9" Body="&lt;p&gt;Because &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_dev/dyimEYRG_Ao&quot;&gt;the&lt;/a&gt; &lt;a href=&quot;https://groups.google.com/forum/#!msg/vim_dev/9ELfTp_rbW8/dMgXd3h2nt0J&quot;&gt;patches&lt;/a&gt; have been sitting in the TODO list for almost five years.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't forget, vimscript wasn't &lt;em&gt;designed&lt;/em&gt;: it is only the ever-changing interim result of a slow evolutionary process. Hell, it didn't even have an actual name in the doc until &quot;VimL&quot; was discreetly slipped in a bit before 7.4.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-07-05T19:39:46.137" LastActivityDate="2015-07-05T19:39:46.137" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3835" PostTypeId="1" CreationDate="2015-07-05T19:35:26.317" Score="16" ViewCount="496" Body="&lt;p&gt;The name of the language sometimes known as Vimscript is a topic of debate. Some places use Viml (or is it VimL?), others Vimscript. Does it have an official name, and if it does, what is it and since when is it official?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/4398312/2072269&quot;&gt;SO question on VimL vs Vimscript&lt;/a&gt; (~5 years old)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/3834/205&quot;&gt;A recent post mentioning that it has got an official name&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A run of &lt;code&gt;:helpgrep \cviml\&amp;gt;&lt;/code&gt; leads us to &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#g%3Avimsyn_noerror&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;syntax.txt&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        g:vimsyn_noerror&#xA;Not all error highlighting that syntax/vim.vim does may be correct; VimL is a&#xA;difficult language to highlight correctly. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;a href=&quot;http://vimhelp.appspot.com/version7.txt.html#better-python-interface&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;version7.txt&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Added special python-vars objects also available for python-buffer and &#xA;python-window. They ease access to VimL variables from Python.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it would seem &lt;code&gt;VimL&lt;/code&gt; is the &lt;em&gt;official&lt;/em&gt; term, yet &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;usr_41.txt&lt;/code&gt;&lt;/a&gt;, the file that best documents the language, doesn't have any mention of &lt;code&gt;VimL&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-07-06T10:07:20.180" Title="Does Vimscript have an official name?" Tags="|vimscript|history-of|terminology|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3836" PostTypeId="2" ParentId="3825" CreationDate="2015-07-05T19:56:51.430" Score="4" Body="&lt;p&gt;You could use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autochdir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the vimrc to make the working directory that of the current file. &lt;a href=&quot;http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file&quot; rel=&quot;nofollow&quot;&gt;Apparently&lt;/a&gt; you need to be careful with this option and plugins.&lt;/p&gt;&#xA;" OwnerUserId="2645" LastActivityDate="2015-07-05T19:56:51.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3837" PostTypeId="2" ParentId="3730" CreationDate="2015-07-05T20:02:24.697" Score="12" Body="&lt;p&gt;This should work and is platform/plugin agnostic: &lt;code&gt;fnamemodify(expand(&quot;$MYVIMRC&quot;), &quot;:p:h&quot;)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2709" LastActivityDate="2015-07-05T20:02:24.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3838" PostTypeId="2" ParentId="3825" CreationDate="2015-07-05T20:49:41.927" Score="1" Body="&lt;p&gt;All credit for this answer goes to heemayl from Ask Ubuntu. Apparently that is where this question belonged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No, you can not do that using shell aliases. You need to use a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a simple function to do the job :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dim() {&#xA;cd /home/jason/Documents&#xA;vim &quot;$1&quot;&#xA;cd -&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function dim will take a file name as argument. You can put this code snippet at the end of your &lt;code&gt;~/.bashrc&lt;/code&gt; file and then run it as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dim file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace &lt;code&gt;file.txt&lt;/code&gt; with any file name you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To run it from the current shell session, source the ~/.bashrc file first :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;. ~/.bashrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="205" LastEditDate="2015-07-06T07:55:46.970" LastActivityDate="2015-07-06T07:55:46.970" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3839" PostTypeId="2" ParentId="3835" CreationDate="2015-07-05T21:03:51.030" Score="13" Body="&lt;p&gt;The name &lt;em&gt;VimL&lt;/em&gt; appeared in the documentation &lt;a href=&quot;https://github.com/vim/vim/commit/fae66b13ff51f3c35832245dc2e43aa81b0d944f#diff-c1daf587351a4db5b6b54f1a86a5dd27&quot;&gt;in July 2013&lt;/a&gt;. Vim's scripting language didn't have a name before that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;VimL&lt;/em&gt; is the only name mentioned in the documentation. It doesn't really make it the official name but, well… that's the closest we have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FWIW I don't like it and will probably keep calling it vimscript for some time.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-07-05T21:03:51.030" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3840" PostTypeId="2" ParentId="807" CreationDate="2015-07-05T22:01:35.993" Score="8" Body="&lt;p&gt;This is a method found in the &lt;a href=&quot;https://github.com/mhinz/vim-randomtag&quot; rel=&quot;noreferrer&quot;&gt;vim-randomtag&lt;/a&gt; plugin, which is based on reading ... current time microseconds, usable when you just want &lt;em&gt;some&lt;/em&gt; number, you don't care much about randomness quality, or have security concerns etc.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:randnum(max) abort&#xA;  return str2nr(matchstr(reltimestr(reltime()), '\v\.@&amp;lt;=\d+')[1:]) % a:max&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-07-05T22:01:35.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3841" PostTypeId="1" AcceptedAnswerId="3844" CreationDate="2015-07-06T01:27:11.603" Score="4" ViewCount="2060" Body="&lt;p&gt;I use ctrl-p (and SuperTab with it), quite often to do autocompletion. But what happens quite often is that I press tab to autocomplete, I get the match I want, and then I have to go into normal mode. But when I press escape, it cancels out of the autocompletion. Is there anyway to select the autocompletion choice and then go into normal mode immediately without it canceling?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know continuing to type will accept the autocompletion by default, but quite often I need to jump to a word, delete it, and type out another word, and then jump back to normal mode (I'd imagine I'm not alone in this). It would be useful to have tab autocompletion available in this scenario. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there anything I can press to accept the autocompletion and go into normal mode, without canceling it? &lt;/p&gt;&#xA;" OwnerUserId="2655" LastEditorUserId="21" LastEditDate="2015-07-06T13:27:49.013" LastActivityDate="2015-07-06T13:27:49.013" Title="When I press ctrl-p and autocomplete a word, is there a way to immediately jump into normal mode by pressing escape without canceling the selection?" Tags="|autocompletion|plugin-ctrlp|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3842" PostTypeId="2" ParentId="3835" CreationDate="2015-07-06T09:03:28.330" Score="2" Body="&lt;p&gt;I paste here my answer on SO ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h usr_41.txt&lt;/code&gt; says &lt;em&gt;Vim script language&lt;/em&gt; for the language, and &lt;em&gt;Vim script(s)&lt;/em&gt; for ..., well, scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VimL can be used as an abbreviation for &lt;em&gt;Vim script language&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2015-07-06T09:03:28.330" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3843" PostTypeId="2" ParentId="3726" CreationDate="2015-07-06T11:24:42.990" Score="7" Body="&lt;p&gt;&lt;code&gt;\w&lt;/code&gt; is &lt;em&gt;explicitly&lt;/em&gt; short-hand for &lt;code&gt;[0-9A-Za-z_]&lt;/code&gt;. Use &lt;code&gt;\k&lt;/code&gt; instead if you want to match Unicode characters outside of that range. For example, &lt;code&gt;/ger\kek&lt;/code&gt; matches &lt;code&gt;gerçekleşiyor&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, neocomplete is aware of this but intentionally &lt;em&gt;does not&lt;/em&gt; use &lt;code&gt;\k&lt;/code&gt; (by default) because of performance concerns. You can change neocomplete's &lt;code&gt;g:neocomplete#keyword_patterns&lt;/code&gt; setting. See also:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/Shougo/neocomplete.vim/issues/207&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/Shougo/neocomplete.vim/issues/207&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="578" LastEditorUserId="578" LastEditDate="2015-09-18T18:05:04.807" LastActivityDate="2015-09-18T18:05:04.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3844" PostTypeId="2" ParentId="3841" CreationDate="2015-07-06T11:35:48.857" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;ctrl-e&lt;/code&gt; to cancel a selection, and &lt;code&gt;ctrl-y&lt;/code&gt; to accept it (followed by &lt;code&gt;ESC&lt;/code&gt; to go to normal mode). People usually use &lt;code&gt;ESC&lt;/code&gt; to &lt;em&gt;cancel&lt;/em&gt; a selection (escape from whatever happens), and also map &lt;code&gt;Enter&lt;/code&gt; to complete a selection, if one is active:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;cr&amp;gt; pumvisible() ? &quot;&amp;lt;c-y&amp;gt;&quot; : &quot;&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you still want to &quot;complete and go to normal mode&quot; on hitting &lt;code&gt;ESC&lt;/code&gt;, you can use something like this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;esc&amp;gt; pumvisible() ? &quot;&amp;lt;c-y&amp;gt;&amp;lt;esc&amp;gt;&quot; : &quot;&amp;lt;esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll probably have to rely on &lt;code&gt;ctrl-e&lt;/code&gt; more now, to cancel a selection (or delete characters with &lt;code&gt;BACKSPACE&lt;/code&gt;) ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, check your &lt;code&gt;ESC&lt;/code&gt; mapping - I can very well complete with &lt;code&gt;ctrl-n&lt;/code&gt; and use &lt;code&gt;ESC&lt;/code&gt; with no problems afterwards.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-07-06T11:35:48.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3845" PostTypeId="1" AcceptedAnswerId="3852" CreationDate="2015-07-06T12:31:45.680" Score="12" ViewCount="2513" Body="&lt;p&gt;How can I move X bytes forward, starting from the current cursor location (including line breaks)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#go&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;[count]go&lt;/code&gt;&lt;/a&gt; could be used to move forward X bytes from the start of the buffer. I tried &lt;code&gt;Shift + V, G, [count]go&lt;/code&gt; (assuming that &lt;code&gt;[count]go&lt;/code&gt; would start counting from the begin of my selection), but unfortunately that did not work either because &lt;code&gt;go&lt;/code&gt; only starts counting from the begin of the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried &lt;code&gt;:set rulerformat=%o&lt;/code&gt; to display the current byte offset (as suggested by &lt;a href=&quot;https://vi.stackexchange.com/questions/3006/jumping-to-a-byte-offset-and-displaying-position-as-byte-offset&quot;&gt;Jumping to a byte offset, and displaying position as byte offset&lt;/a&gt;), added the numbers in my head and finally issued &lt;code&gt;[count]go&lt;/code&gt;. This works, but it is not very practical...&lt;/p&gt;&#xA;" OwnerUserId="2720" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-08-02T21:07:06.333" Title="Go to X bytes from here" Tags="|cursor-movement|binary-file|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3846" PostTypeId="2" ParentId="3845" CreationDate="2015-07-06T14:25:31.903" Score="12" Body="&lt;p&gt;This search moves 40 &lt;em&gt;chars&lt;/em&gt; (not bytes, though) forward:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\_.\{40}/e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by searching for exactly 40 chars (&lt;code&gt;\{40}&lt;/code&gt;) of any kind, including newline (&lt;code&gt;\_.&lt;/code&gt;), and placing the cursor at the end of the search (&lt;code&gt;/e&lt;/code&gt;). See: &lt;a href=&quot;http://vimregex.com/#Non-Greedy&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimregex.com/#Non-Greedy&lt;/a&gt;, &lt;code&gt;:help search-offset&lt;/code&gt; and &lt;code&gt;:help \_&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, see &lt;code&gt;:h 23.4&lt;/code&gt; for binary editing.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update: Based on &lt;a href=&quot;https://vi.stackexchange.com/questions/3848/how-to-get-the-current-byte-offset-in-whole-file&quot;&gt;this&lt;/a&gt; answer, here's a function that jumps to byte offset:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:last_jump_bytes = 0&#xA;&#xA;function! JumpTo(byte_nr)&#xA;    let crt_byte = line2byte(line('.')) + col('.')&#xA;    if (a:byte_nr == 0)&#xA;        let dst_byte = crt_byte + s:last_jump_bytes&#xA;    else&#xA;        let dst_byte = crt_byte + a:byte_nr&#xA;        let s:last_jump_bytes = a:byte_nr&#xA;    endif&#xA;    let dst_line = byte2line(dst_byte)&#xA;    let dst_col = dst_byte -line2byte(dst_line)&#xA;    &quot;remove next line if you don't want to record this for `Ctrl-O`&#xA;    execute &quot;normal &quot; . dst_line . &quot;G&quot;&#xA;    call setpos('.', [0, dst_line, dst_col])&#xA;endfunction&#xA;&#xA;command! -nargs=1 JumpToOffset :call JumpTo(&amp;lt;f-args&amp;gt;)&#xA;&#xA;&quot; silly mapping to Ctrl-C (demo)&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;c-c&amp;gt; &quot;:&amp;lt;c-u&amp;gt;call JumpTo(&quot; . v:count . &quot;)&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can be used like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:JumpToOffset 400&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or typing the mapped keyboard mapping,  with a count:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;40CTRL-C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't use a count, the previous count number is re-used. So you can do: &lt;code&gt;40CTRL-C CTRL-C CTRL-C 30CTRL-C CTRL-C&lt;/code&gt; to jump 40, 40, 40, 30, 30 bytes etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hit &lt;code&gt;Ctrl-O&lt;/code&gt; to jump back (see comments inside the function).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-07-06T17:40:11.837" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="3847" PostTypeId="1" CreationDate="2015-07-06T15:46:33.350" Score="2" ViewCount="162" Body="&lt;p&gt;How can I evaluate Ruby code on-the-fly when you are writing it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what it looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5 + 5 # =&amp;gt; 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="237" LastEditorUserId="24" LastEditDate="2015-07-11T04:40:04.520" LastActivityDate="2015-07-11T04:40:04.520" Title="Plugin for on-the-fly # =&gt; evaluation" Tags="|ide|filetype-ruby|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3848" PostTypeId="1" AcceptedAnswerId="3850" CreationDate="2015-07-06T16:03:48.450" Score="14" ViewCount="3251" Body="&lt;p&gt;I saw that you could display the current byte offset in the statusline using &lt;code&gt;%o&lt;/code&gt;, but I found no function or command which does the same.  Is there a way of getting the current byte offset pragmatically?&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="24" LastEditDate="2015-07-11T04:33:48.743" LastActivityDate="2015-07-12T21:20:04.263" Title="How to get the current byte offset in whole file" Tags="|vimscript|binary-file|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3849" PostTypeId="2" ParentId="3847" CreationDate="2015-07-06T16:05:03.767" Score="3" Body="&lt;p&gt;Take a look at the &lt;a href=&quot;https://github.com/SciRuby/iruby&quot; rel=&quot;nofollow&quot;&gt;IRuby&lt;/a&gt; kernel for &lt;a href=&quot;https://jupyter.org/&quot; rel=&quot;nofollow&quot;&gt;Jupyter&lt;/a&gt; / &lt;a href=&quot;http://ipython.org/&quot; rel=&quot;nofollow&quot;&gt;IPython&lt;/a&gt; and &lt;a href=&quot;https://github.com/ivanov/ipython-vimception&quot; rel=&quot;nofollow&quot;&gt;ipython-vimception&lt;/a&gt;.  If you must do it in Vim itself you might try the &lt;a href=&quot;https://github.com/ivanov/vim-ipython&quot; rel=&quot;nofollow&quot;&gt;vim-ipython&lt;/a&gt; plugin, but in my experience this part doesn't work very well.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-07-06T16:05:03.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3850" PostTypeId="2" ParentId="3848" CreationDate="2015-07-06T16:10:26.537" Score="8" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FileOffset()&#xA;    return line2byte(line('.')) + col('.') - 1&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This returns the 1-based offset in file, which is the same as &lt;code&gt;%o&lt;/code&gt; in &lt;code&gt;statusline&lt;/code&gt;.  You can, of course, subtract 1 to get the 0-based offset.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="1577" LastEditDate="2015-07-06T16:13:26.073" LastActivityDate="2015-07-06T16:13:26.073" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3851" PostTypeId="1" AcceptedAnswerId="3906" CreationDate="2015-07-06T17:00:32.367" Score="4" ViewCount="1628" Body="&lt;p&gt;I am using Vim with &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow&quot;&gt;fugitive.vim&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes when diffing files versus their HEAD version from Fugitive's &lt;code&gt;Gstatus&lt;/code&gt; window, Vim shows all lines in a file as changed, when in reality only one or two lines are different (and command-line &lt;code&gt;git diff&lt;/code&gt; shows differences correctly). Why is this happening?&lt;/p&gt;&#xA;" OwnerUserId="2725" LastActivityDate="2015-07-09T17:47:50.307" Title="VimDiff incorrectly showing all lines as changed" Tags="|vimdiff|git|plugin-fugitive|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="3852" PostTypeId="2" ParentId="3845" CreationDate="2015-07-06T17:38:30.447" Score="10" Body="&lt;p&gt;I ended up using the following solution, which implements the logic from my question.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[count]GO&lt;/code&gt; to move &lt;code&gt;[count]&lt;/code&gt; bytes forward.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[count]Go&lt;/code&gt; to move &lt;code&gt;[count]&lt;/code&gt; bytes backwards.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! JumpToByte(byte_nr)&#xA;    &quot; See https://vi.stackexchange.com/a/3911/2720 for the byte counting bug&#xA;    let crt_byte = line2byte(line('.')) + col('.') - 1&#xA;    if version &amp;lt; 781 &amp;amp;&amp;amp; &amp;amp;l:binary == 1 &amp;amp;&amp;amp; &amp;amp;l:eol == 0&#xA;        let crt_byte += 1&#xA;        let crt_byte += line('.') == 1&#xA;    endif&#xA;    let dst_byte = crt_byte + a:byte_nr&#xA;    execute &quot;normal &quot; . dst_byte . &quot;go&quot;&#xA;endfunction&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; GO &quot;:&amp;lt;c-u&amp;gt;call JumpToByte(&quot; . v:count . &quot;)&amp;lt;cr&amp;gt;&quot;&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; Go &quot;:&amp;lt;c-u&amp;gt;call JumpToByte(-&quot; . v:count . &quot;)&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks to VanLaser for his initial implementation, which put me in the right direction.&lt;/p&gt;&#xA;" OwnerUserId="2720" LastEditorUserId="2698" LastEditDate="2016-08-02T21:07:06.333" LastActivityDate="2016-08-02T21:07:06.333" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3853" PostTypeId="1" AcceptedAnswerId="3855" CreationDate="2015-07-06T19:36:38.987" Score="1" ViewCount="159" Body="&lt;p&gt;I am porting autotools project to CMake. So, every directory of the project has &lt;code&gt;CMakeLists.txt&lt;/code&gt; and &lt;code&gt;Makefile.am&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to make a split: &lt;code&gt;CMakeLists.txt&lt;/code&gt; on one side and the corresponding &lt;code&gt;Makefile.am&lt;/code&gt; on the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to automatically arrange it so that When on the one side file is opened, it has to open corresponding file on the other side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonuses:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Add a third split: tree view of the filesystem, filtered to show only &lt;code&gt;CMakeLists.txt&lt;/code&gt;, &lt;code&gt;Makefile.am&lt;/code&gt; and &lt;code&gt;configure.ac&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sometimes there are all three files in the directory; so show both &lt;code&gt;Makefile.am&lt;/code&gt; and &lt;code&gt;configure.ac&lt;/code&gt; that correspond to the &lt;code&gt;CMakeLists.txt&lt;/code&gt; in that dir.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Filters for the tree&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let NERDTreeIgnore = ['\(CMakeLists\.txt\|Makefile\.am\|configure\.ac\)\@&amp;lt;!$[[file]]']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2727" LastEditorUserId="2727" LastEditDate="2015-07-07T18:36:09.057" LastActivityDate="2015-07-10T16:31:55.503" Title="Split: automatically load corresponding file" Tags="|split|vim-windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3854" PostTypeId="1" CreationDate="2015-07-06T22:13:00.630" Score="12" ViewCount="2473" Body="&lt;p&gt;I have a function that does a lot of moving and outputting of text into the current vim buffer, and when I run it, seeing all that happening at blinding speed is a bit disconcerting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I freeze the screen until the function's done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the function in question:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MakeChoices()&#xA;    :let save_view = winsaveview()&#xA;    let start = line('.')&#xA;&#xA;    &quot;Locate previous *choice. (b=backwards, W=nowrap, n=doNot move cursor)&#xA;    let choiceStartLine = search('^*choice', 'bW')&#xA;&#xA;    if !choiceStartLine&#xA;        echo &quot;No *choice found. (*choice must not be indented. This is to avoid finding *choice blocks nested in another *choice block.)&quot;&#xA;        return -1&#xA;    endif&#xA;    &quot;return getline(target_line_num, target_line_num+4)&#xA;    &quot;Locate end of *choice block&#xA;    &quot;echo getline(choiceStartLine, choiceStartLine+2)&#xA;    let choiceEndLine = search('^\S.*', 'W') &quot;End is first line that starts with non-whitespace&#xA;&#xA;    &quot;If above search fails, might be at bottom of buffer&#xA;    if choiceEndLine == 0&#xA;        let choiceEndLine = search('^$', 'W') &quot;End is first empty line&#xA;    endif&#xA;&#xA;    &quot;Now go back up to the last *goto&#xA;    let choiceEndLine = search('*goto', 'bW')&#xA;&#xA;    &quot;Get the entire *choice block and put it in gotoBlock&#xA;    let gotoBlock = getline(choiceStartLine, choiceEndLine)&#xA;&#xA;    &quot;Make labelArray (contains all labels to goto)&#xA;    let labelArray = []&#xA;&#xA;    for cur in gotoBlock&#xA;        if match(cur, '*goto') != -1&#xA;            &quot;echo 'cur: '.cur&#xA;            let curParsed = matchlist(cur, '*goto \(\S\+\)')&#xA;            &quot;echo curParsed&#xA;            if len(curParsed) &amp;gt; 1&#xA;                let curLabel = curParsed[1]&#xA;            else&#xA;                echo 'ERROR: Bad *goto ('.cur.')'&#xA;                return -1&#xA;            endif&#xA;            call add(labelArray, curLabel)  &#xA;        endif&#xA;    endfor&#xA;&#xA;    &quot;Restore window to what it looked like (in case the searches scrolled&#xA;    &quot;it)&#xA;    call winrestview(save_view)&#xA;&#xA;    &quot;Make newline after choice block if needed&#xA;    if strlen(getline(choiceEndLine+1)) &amp;gt; 0&#xA;        echo 'big line: '.getline(choiceEndLine+1)&#xA;        call cursor(choiceEndLine, 1)&#xA;        put=''&#xA;    endif&#xA;&#xA;    call cursor(choiceEndLine+1, 1)&#xA;&#xA;    &quot;Put the new label blocks&#xA;    let skippedLabels = ''&#xA;    let numNewLabels = 0&#xA;    for cur in labelArray&#xA;        if !search('*label '.cur, 'wn')&#xA;            let numNewLabels += 1&#xA;            put='*label '.cur&#xA;            put='[This option is yet to be written.]'&#xA;            put=''&#xA;        else&#xA;            let skippedLabels .= cur.' '&#xA;        endif&#xA;    endfor&#xA;&#xA;    &quot;Remove trailing blank lines (Up to a point)&#xA;    let nextlines = getline(line('.')+1, line('.')+3)&#xA;    if len(nextlines) == 3&#xA;        if nextlines[0] == '' &amp;amp;&amp;amp; nextlines[1] == '' &amp;amp;&amp;amp; nextlines[2] == ''&#xA;            normal &quot;_3dd&#xA;        elseif nextlines[0] == '' &amp;amp;&amp;amp; nextlines[1] == ''&#xA;            normal &quot;_2dd&#xA;        elseif nextlines[0] == ''&#xA;            normal &quot;_dd&#xA;        endif&#xA;    endif&#xA;&#xA;    &quot;Move to first label's text (use ctrl-v ctrl-m to input the &amp;lt;CR&amp;gt; at&#xA;    &quot;end)&#xA;    if numNewLabels != 0&#xA;        call cursor(choiceEndLine, 1)&#xA;        normal /\[This option is yet to be written.\]&#xA;        let @/='\[This option is yet to be written\.\]'&#xA;    endif&#xA;&#xA;    &quot;Print status message&#xA;    if len(skippedLabels) &amp;gt; 0&#xA;        echo 'Skipped: '.skippedLabels&#xA;    else&#xA;        echo 'New labels created: '.numNewLabels&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2511" LastEditorUserId="48490" LastEditDate="2023-08-30T13:32:54.707" LastActivityDate="2023-08-30T13:32:54.707" Title="Prevent refresh of screen until function completes" Tags="|vimscript|functions|debugging|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3855" PostTypeId="2" ParentId="3853" CreationDate="2015-07-07T02:12:48.070" Score="4" Body="&lt;p&gt;As an alternative (pun!) maybe look into file switcher like &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=31&quot; rel=&quot;nofollow&quot;&gt;a.vim&lt;/a&gt;, &lt;a href=&quot;https://github.com/derekwyatt/vim-fswitch&quot; rel=&quot;nofollow&quot;&gt;fswitch&lt;/a&gt;, or &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4202&quot; rel=&quot;nofollow&quot;&gt;altr&lt;/a&gt;. These let you switch between related files. It is often used to switch between &lt;code&gt;.cpp&lt;/code&gt; and &lt;code&gt;.h&lt;/code&gt; files, but they can be customized to switch between other types of files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a quick n' easy switcher than you can use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Alternative(cmd, ...) abort&#xA;  let f = expand(&quot;%:p:gs?\\?/?&quot;)&#xA;  let files = map(copy(get(g:, 'related_files', [])), 'fnamemodify(expand(v:val), &quot;:gs?\\?/?&quot;)')&#xA;  let files = a:0 &amp;amp;&amp;amp; a:1 ? reverse(files) : files&#xA;  let idx = index(map(copy(files), 'f[len(f)-len(v:val)-1:] ==# &quot;/&quot; . v:val'), 1)&#xA;  if idx == -1&#xA;    return 'echoerr &quot;No alternative file&quot;'&#xA;  endif&#xA;  let path = fnamemodify(expand('%:p:h:gs?\\?/?') . repeat(&quot;/..&quot;, len(split(files[idx], &quot;/&quot;))-1), &quot;:p&quot;)&#xA;  let files = files[idx+1 : ] + (idx ? files[0 : idx-1] : [])&#xA;  call filter(files, 'filereadable(path . &quot;/&quot; . v:val)')&#xA;  call map(files, 'a:cmd . &quot; &quot; . path . &quot;/&quot; . v:val')&#xA;  return get(files, 0, 'echoerr &quot;No alternative file&quot;')&#xA;endfunction&#xA;&#xA;let g:related_files = ['CMakeLists.txt', 'Makefile.am', 'configure.ac']&#xA;command! -bang A execute Alternative('edit&amp;lt;bang&amp;gt;')&#xA;command! -bang AS execute Alternative('split&amp;lt;bang&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This behaves much like A.vim. You can just use &lt;code&gt;:A&lt;/code&gt; to cycle through your files and use &lt;code&gt;:AS&lt;/code&gt; to open a related file in a split. Change &lt;code&gt;g:related_files&lt;/code&gt; as you see fit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a more structured project you may want to consider something like &lt;a href=&quot;https://github.com/tpope/vim-projectionist&quot; rel=&quot;nofollow&quot;&gt;projectionist.vim&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-07-07T14:30:12.447" LastActivityDate="2015-07-07T14:30:12.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3856" PostTypeId="1" AcceptedAnswerId="3858" CreationDate="2015-07-07T03:32:44.780" Score="27" ViewCount="10571" Body="&lt;p&gt;I'm a new Vim user, and I want to ask this somewhat elementary question in order to make sure I start learning Vim the right way and don't develop bad habits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use Vim, how do you position your right hand? I find it more natural to start with my fingers on the &lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt;&lt;kbd&gt;;&lt;/kbd&gt; keys, but then I find myself missing the &lt;kbd&gt;h&lt;/kbd&gt; key at times when I'm navigating. Conversely, if I position my fingers on &lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt; then I find myself mistyping words as this isn't the position I was trained to keep my hand on the keyboard, and I find toggling the &lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; keys with my middle and third finger to be awkward.&lt;/p&gt;&#xA;" OwnerUserId="2732" LastEditorUserId="1841" LastEditDate="2015-07-07T07:20:18.717" LastActivityDate="2015-10-07T05:44:35.600" Title="Hand Placement for Vim Navigation" Tags="|cursor-movement|normal-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3858" PostTypeId="2" ParentId="3856" CreationDate="2015-07-07T07:06:31.913" Score="25" Body="&lt;p&gt;First of all I will assume that you are using a QWERTY keyboard. My answer isn't based on my personal preference, I am simply reformulating a part of the amazing &lt;a href=&quot;https://pragprog.com/book/dnvim/practical-vim&quot; rel=&quot;noreferrer&quot;&gt;Practical Vim&lt;/a&gt; written by Drew Neil.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Vim is optimized for the touch typists so your hands should stay where you learned to put them: left hand on &lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;  and right hand on &lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt;&lt;kbd&gt;;&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neil says that putting your right hand on &lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt; is a really bad thing to do. The main reason is that moving your cursor with the keys &lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt; is something that should be very occasional because vim provides much faster word-wise movements or character search motion (&lt;code&gt;w&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll also directly quote this part:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I use the &lt;kbd&gt;h&lt;/kbd&gt; and &lt;kbd&gt;l&lt;/kbd&gt; keys for off-by-one errors, when I narrowly miss my target.&#xA;  Apart from that, I hardly touch them. Given how little I use the &lt;kbd&gt;h&lt;/kbd&gt; key, I’m&#xA;  happy to have to stretch for it on a Qwerty keyboard. On the flip side, I use&#xA;  the character search commands often, so I’m pleased&#xA;  that the ; key rests comfortably beneath my little finger.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus:&lt;/strong&gt; Even if that doesn't seems to be your case here is a tip to get rid of the beginners bad habit consisting in using the arrow keys to move: Simply add the following lines to your &lt;code&gt;.vimrc&lt;/code&gt; to disable totally the arrow keys:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Up&amp;gt;    &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;Down&amp;gt;  &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;Left&amp;gt;  &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt; stands for &quot;No Operation&quot;)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-10-06T01:06:43.700" LastActivityDate="2015-10-06T01:06:43.700" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3860" PostTypeId="2" ParentId="3847" CreationDate="2015-07-07T10:08:04.367" Score="1" Body="&lt;p&gt;Thanks &lt;a href=&quot;https://twitter.com/tomstuart/status/618356806025388032&quot; rel=&quot;nofollow&quot;&gt;@tomstuart&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;a href=&quot;https://github.com/t9md/vim-ruby-xmpfilter&quot; rel=&quot;nofollow&quot;&gt;https://github.com/t9md/vim-ruby-xmpfilter&lt;/a&gt; with xmpfilter.&lt;/p&gt;&#xA;" OwnerUserId="237" LastActivityDate="2015-07-07T10:08:04.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3861" PostTypeId="2" ParentId="3847" CreationDate="2015-07-07T10:13:14.627" Score="3" Body="&lt;p&gt;If you want to evaluate a single line you can do this with a macro simply : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq$hy:r! ruby -e '&amp;lt;C-r&amp;gt;&quot;'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq                &quot; record a new macro&#xA;v$hy              &quot; select the current line minus the ^m&#xA;:r!               &quot; prepare to read a command&#xA;ruby -e '&amp;lt;C-r&amp;gt;&quot;'  &quot; call ruby inline mode executing&#xA;&amp;lt;CR&amp;gt;              &quot; execute the whole thing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You now have the result on the new line, feel free to customize :)&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-07-07T10:16:34.463" LastActivityDate="2015-07-07T10:16:34.463" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3862" PostTypeId="1" AcceptedAnswerId="3864" CreationDate="2015-07-07T10:27:18.583" Score="23" ViewCount="1921" Body="&lt;p&gt;Sometimes in insert mode I hit &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; by mistake  and I have to hit the backspace multiple times (depends on the indentation) to get back where I was.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;  &amp;lt;p&amp;gt; This is some text []&amp;lt;/p&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The cursor is &lt;code&gt;[]&lt;/code&gt; and I hit &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;  &amp;lt;p&amp;gt; This is some text &#xA;  []&amp;lt;/p&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I have to hit backspace twice to get back to the previous line (this case isn't so bad but it doesn't have a lot of indentation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know a better way to do ?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-09-01T15:33:35.243" LastActivityDate="2017-12-31T13:58:57.140" Title="Undo &lt;CR&gt; in insert mode" Tags="|insert-mode|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3864" PostTypeId="2" ParentId="3862" CreationDate="2015-07-07T10:50:48.683" Score="10" Body="&lt;p&gt;How about:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-\&amp;gt; &amp;lt;C-o&amp;gt;:left 0&amp;lt;Cr&amp;gt;&amp;lt;BS&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; will execute a normal mode command (&lt;code&gt;:left 0&lt;/code&gt;), which will remove all indent, this will also put your cursor at the start of the line. &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; will get you back to the last line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a bit like a &quot;backwards &lt;code&gt;J&lt;/code&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, mapping Shift+Enter or Ctrl+Enter doesn't seem possible, so I choose &lt;code&gt;&amp;lt;C-\&amp;gt;&lt;/code&gt;, as being &quot;near the enter&quot;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-07-07T10:50:48.683" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3865" PostTypeId="2" ParentId="3862" CreationDate="2015-07-07T11:13:53.993" Score="22" Body="&lt;p&gt;I have this in my &lt;code&gt;vimrc&lt;/code&gt;, the second part is relevant:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;cr&amp;gt; pumvisible() ? &quot;&amp;lt;c-y&amp;gt;&quot; : &quot;&amp;lt;c-g&amp;gt;u&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this does: everytime you hit &lt;code&gt;Enter&lt;/code&gt; in insert mode, it will also &quot;break the undo sequence, start new change&quot; (see &lt;code&gt;h: i_CTRL-G_u&lt;/code&gt;). This means, if you hit &lt;code&gt;Enter&lt;/code&gt; by mistake, you &lt;em&gt;can&lt;/em&gt; now undo your change without removing previous inserted lines, either with &lt;code&gt;ESC u a&lt;/code&gt;, or with &lt;code&gt;Ctrl-o u&lt;/code&gt;, as Statox proposed. Basically, each line can be undone separately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT/UPDATE: If you happen to use Vim emulation in Emacs, a.k.a. &lt;em&gt;evil-mode&lt;/em&gt;, you can use &lt;a href=&quot;https://github.com/VanLaser/evil-nl-break-undo&quot; rel=&quot;nofollow noreferrer&quot;&gt;this package&lt;/a&gt; for a similar effect.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2017-12-31T13:58:57.140" LastActivityDate="2017-12-31T13:58:57.140" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3866" PostTypeId="2" ParentId="3862" CreationDate="2015-07-07T11:29:37.623" Score="2" Body="&lt;p&gt;My way out of this is (from insert mode) &lt;kbd&gt;Up&lt;/kbd&gt;&lt;kbd&gt;Ctrl-o&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt;&lt;kbd&gt;Del&lt;/kbd&gt;.  Possibly not the most efficient combination, but it's what I'm doing without needing to think about it.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-07-07T11:29:37.623" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3867" PostTypeId="2" ParentId="3682" CreationDate="2015-07-07T12:20:52.580" Score="6" Body="&lt;h1&gt;Summary&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;It's a bug and there's a patch (743).&#xA;The bug affects both your examples, but you don't see it in one case because the character that is moved down is a &lt;kbd&gt; &lt;/kbd&gt; (whitespace).&#xA;The solution is to install the patch, but there are also many workarounds or alternative methods, not affected by the bug.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;NB&lt;/strong&gt;: &lt;kbd&gt;{&lt;/kbd&gt;, &lt;kbd&gt;}&lt;/kbd&gt; and &lt;kbd&gt;B&lt;/kbd&gt; all refer to the same text object: Block (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#aB&quot;&gt;&lt;code&gt;:help aB&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#iB&quot;&gt;&lt;code&gt;:help iB&lt;/code&gt;&lt;/a&gt;) . If this or other answers use a different sign than the one used in the question, that may be why.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h1&gt;The bug&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I don't understand it entirely, but here is towards an explanation, if someone is interested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behaviour you see is due to a bug &lt;a href=&quot;https://groups.google.com/forum/#!searchin/vim_dev/v_p/vim_dev/8yY2NqkRwFo/bRlxxvVhQcQJ&quot;&gt;mentioned by Yukihiro Nakadaira on vim_dev&lt;/a&gt; and his patch is released as &lt;a href=&quot;ftp://ftp.vim.org/pub/vim/patches/7.4/7.4.743&quot;&gt;7.4.743: &quot;p&quot; in Visual mode causes an unexpected line split&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Visual mode put (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#v_p&quot;&gt;&lt;code&gt;:help v_p&lt;/code&gt;&lt;/a&gt;) is supposed to replace the visually selected text with text from a register. The bug happens when a) the register is of linewise type (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#linewise-register&quot;&gt;&lt;code&gt;:help linewise-register&lt;/code&gt;&lt;/a&gt;) but the visual selection is of characterwise type &lt;em&gt;and&lt;/em&gt; b) the visual selection ends at the last column of a line. In your case, if you yank inner Block and then visually select a Block and paste, the yanked register will be linewise and the visual selection will be characterwise. We can yank both inner Block and a Block to named registers and inspect:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; s.length(); i++){  &#xA;    int index = s[i] - c;  &#xA;    if(root-&amp;gt;next[index] == NULL)  &#xA;        root-&amp;gt;next[index] = new TrieNode;  &#xA;    root = root-&amp;gt;next[index];  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;we do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;ayi{&#xA;&quot;bya{&#xA;:registers ab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which shows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Registers ---&#xA;&quot;a       int index = s[i] - c;^J    if(root-&amp;gt;next[index] == NULL)^J        root-&amp;gt;next[index] = new TrieNode;^J    root = root-&amp;gt;next[index];^J&#xA;&quot;b   {^J    int index = s[i] - c;^J    if(root-&amp;gt;next[index] == NULL)^J        root-&amp;gt;next[index] = new TrieNode;^J    root = root-&amp;gt;next[index];^J}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo getregtype('a') &quot; displays 'V' for linewise&#xA;:echo getregtype('b') &quot; displays 'v' for characterwise&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To replace a characterwise visual selection with a linewise register, the lines that hold the beginning and the end of the visual selection must be split in two, so that the text can be inserted in between. This usually works just fine:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running vim as &lt;code&gt;vim -u NONE -U NONE&lt;/code&gt; and typing&lt;br&gt;&#xA;(&lt;strong&gt;a&lt;/strong&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iaaa&#xA;bbb&#xA;ccc&#xA;ddd&amp;lt;Esc&amp;gt;ggYjlvp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;results in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaa&#xA;b&#xA;aaa&#xA;b&#xA;ccc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and (&lt;strong&gt;b&lt;/strong&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iaaa&#xA;bbb&#xA;ccc&#xA;ddd&amp;lt;Esc&amp;gt;ggYjvjp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaa&#xA;&#xA;aaa&#xA;cc&#xA;ddd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when the characterwise visual selection ends at the last column of a line (and does not include the newline &lt;code&gt;/n&lt;/code&gt;/&lt;code&gt;^J&lt;/code&gt;) something goes wrong. It has to do with the cursor position, which is suddenly off by -1 and must be specially incremented, which is what the patch does. Compare (&lt;strong&gt;a&lt;/strong&gt;) with the command &lt;code&gt;&amp;lt;Esc&amp;gt;ggYjllvp&lt;/code&gt;, that is, the same command except move one more column to the right so the cursor is on the last &quot;b&quot; on the line. The result is the same as before!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now take the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (TIRED){&#xA;    goto bed;&#xA;} else {&#xA;    goto work;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the cursor on the second line, your &lt;code&gt;yi{va{p&lt;/code&gt; works just fine and gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (TIRED)&#xA;    goto bed;&#xA; else {&#xA;    goto work;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The yank register is still linewise and the visual selection characterwise, but the visual selection doesn't end in the last column anymore, and everything is fine.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Example texts from the question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;For the two example texts, where the only difference is a blank space between closing parenthesis and opening curly bracket in the first line, it may seem like your command behaves differently, but it really doesn't. In the first case, the one which looks successful, there ought to be a trailing whitespace on the first line once the brackets are removed. That trailing whitespace is instead on the last line. With &lt;code&gt;yi{va{p&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; s.length(); i++) {&#xA;    int index = s[i] - c;&#xA;    if(root-&amp;gt;next[index] == NULL)&#xA;        root-&amp;gt;next[index] = new TrieNode;&#xA;    root = root-&amp;gt;next[index];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; s.length(); i++)&#xA;    int index = s[i] - c;&#xA;    if(root-&amp;gt;next[index] == NULL)&#xA;        root-&amp;gt;next[index] = new TrieNode;&#xA;    root = root-&amp;gt;next[index];&#xA;␣&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;just like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; s.length(); i++){&#xA;    int index = s[i] - c;&#xA;    if(root-&amp;gt;next[index] == NULL)&#xA;        root-&amp;gt;next[index] = new TrieNode;&#xA;    root = root-&amp;gt;next[index];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; s.length(); i++&#xA;    int index = s[i] - c;&#xA;    if(root-&amp;gt;next[index] == NULL)&#xA;        root-&amp;gt;next[index] = new TrieNode;&#xA;    root = root-&amp;gt;next[index];&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Solutions&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The solution would be to install the patch, but there are many other ways to remove the surrounding brackets which don't suffer from the bug. The best workaround is @Gilles answer but the easiest may be to visually select before you yank, to keep the register characterwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-surround&quot;&gt;surround&lt;/a&gt; plugin is excellent, but (at least for me) it does more than remove the brackets: it joins the second line to the first, it removes indentation and it moves the cursor to the beginning of the first line. This leaves some non-trivial cleanup to do. Ingo Karkat and Luc Hermitte have plugins that deal with registers and pasting (I'm sure there are many others) and that should be able to do this. I'm not very familiar with them, but I believe with &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets/&quot;&gt;lh-brackets&lt;/a&gt; you might do &lt;code&gt;&amp;lt;M-b&amp;gt;x&lt;/code&gt; to delete surrounding brackets and for more powerful putting (especially in visual mode) you could look at &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2703&quot;&gt;ReplaceWithRegister&lt;/a&gt; and &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3355&quot;&gt;UnconditionalPaste&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best way is that given in @Gilles answer, &lt;code&gt;[{x]}x&lt;/code&gt;. It is fast, handles nested Blocks well and doesn't join lines inappropriately or mess with indentation. If there is a white space before the opening bracket you can easily add a &lt;code&gt;x&lt;/code&gt; to the command to remove it: &lt;code&gt;[{xx]}x&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Other vanilla commands&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Again, the most appropriate command I can think of is the one in @Gilles' answer, &lt;code&gt;[{x]}x&lt;/code&gt; or &lt;code&gt;[{xx]}x&lt;/code&gt;, but here are two alternatives specifically in light of this bug.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Yank characterwise&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Since the bug occurs only for visual put linewise register over characterwise selection, and since it is only accidental to your inner Block yank that it is linewise, you can choose to yank it characterwise instead. One easy way is to visually select the inner Block before yanking it, and to make sure that visual selection is characterwise (i.e., use &lt;code&gt;v&lt;/code&gt; not &lt;code&gt;V&lt;/code&gt;): &lt;code&gt;vi{yva{p&lt;/code&gt;. This may be the easiest way because it is very similar to how you currently do the operation.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Don't use visual put&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Other commands, like change and delete, are not affected by this bug. You can yank as before, but then delete a Block into the black hole register (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#quote_&quot;&gt;&lt;code&gt;:help quote_&lt;/code&gt;&lt;/a&gt;) and put, or delete a Block and put from the 0 register (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#quote0&quot;&gt;&lt;code&gt;:help quote0&lt;/code&gt;&lt;/a&gt;): &lt;code&gt;yi{&quot;_da{p&lt;/code&gt; or &lt;code&gt;yi{da{&quot;0p&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Generality&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Finally, there are ways similar to @Gilles answer–move to beginning of a Block, delete character, move to end of a Block, delete character–but that are more generic. The only reason to use these would be if the &quot;block&quot; you are deleting around is eccentric and does not have associated motions that work as well as &lt;code&gt;[{&lt;/code&gt; does for a block delimited by curly brackets. There is a chance that the vim-surround plugin can handle these eccentric blocks well, but two vanilla ways would be&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Visually select the eccentric block and leave visual mode. The cursor is on the last character of the selection. Delete it, then go to the beginning of the last selection (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#%60&amp;lt;&quot;&gt;&lt;code&gt;:help `&amp;lt;&lt;/code&gt;&lt;/a&gt;) and delete character. &lt;code&gt;va{&amp;lt;Esc&amp;gt;x`&amp;lt;x&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Search backwards for the beginning of the eccentric block and delete character, then search forward for the end of the eccentric block and delete character. &lt;code&gt;?{&amp;lt;CR&amp;gt;x/}&amp;lt;CR&amp;gt;x&lt;/code&gt; This may not work well with nested blocks.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Character count&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+----+------------------------+----------------------------+------------+&#xA;|    | method                 |          command           | characters |&#xA;+----+------------------------+----------------------------+------------+&#xA;| 1. | vim-surround           | ds{                        |          3 |&#xA;| 2. | @Gilles answer         | [{x]}x                     |          6 |&#xA;| 3. | Characterwise yank     | vi{yva{p                   |          8 |&#xA;| 4. | Delete, not visual put | yi{&quot;_da{p or yi{da{&quot;0p     |          9 |&#xA;| 5. | Visual mark            | va{&amp;lt;Esc&amp;gt;x`&amp;lt;x               |          8 |&#xA;| 6. | Search                 | ?{&amp;lt;CR&amp;gt;x/}&amp;lt;CR&amp;gt;x             |          8 |&#xA;+----+------------------------+----------------------------+------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-07-07T12:20:52.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3868" PostTypeId="1" CreationDate="2015-07-07T13:36:00.387" Score="3" ViewCount="105" Body="&lt;p&gt;&lt;a href=&quot;ftp://ftp.vim.org/pub/vim/patches/7.4/README&quot; rel=&quot;nofollow&quot;&gt;Turns out&lt;/a&gt; my problem with &lt;a href=&quot;https://vi.stackexchange.com/a/3781/1430&quot;&gt;this answer&lt;/a&gt; is that I need patch 7.4.143.  I can't find any download on vim.org for a Windows patched-vim installer.  Is there an official distribution of patched vim 7.4 for Windows?  &lt;a href=&quot;http://vim.wikia.com/wiki/Where_to_download_Vim&quot; rel=&quot;nofollow&quot;&gt;Wikia&lt;/a&gt; says Vim without Cream is the way to go - is that indeed the one?  Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1430" LastActivityDate="2019-07-03T16:13:12.357" Title="Is there a source for pre-built patched Win32/Win64 vims?" Tags="|microsoft-windows|installing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3869" PostTypeId="1" AcceptedAnswerId="3871" CreationDate="2015-07-07T18:34:11.817" Score="4" ViewCount="2473" Body="&lt;p&gt;I have a file that contains words that I want to save, along with other junk that I do not need.  I just want to delete everything except the words that contain a certain pattern. Take email addresses for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;foo foo foo foo foo foo@foo.com&#xA;foo foo foo2@foo2.net&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run some magic and save everything from &lt;code&gt;@&lt;/code&gt; to the previous and next &lt;code&gt;space&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;foo@foo.com foo2@foo2.net&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be useful in so many applications (especially email addresses).&lt;/p&gt;&#xA;" OwnerUserId="318" LastEditorUserId="1800" LastEditDate="2015-07-07T21:55:31.603" LastActivityDate="2015-07-07T21:55:31.603" Title="Delete all of a file except for certain words that contain certain letters" Tags="|command-line|search|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3870" PostTypeId="1" AcceptedAnswerId="3876" CreationDate="2015-07-07T19:17:38.500" Score="10" ViewCount="9766" Body="&lt;p&gt;When I am editing a file in &lt;code&gt;vim&lt;/code&gt; via SSH, I will try to use the number pad on my keyboard to enter long numbers (like IP addresses).  &lt;code&gt;Vim&lt;/code&gt; does not seem to like that very much.  I am using PuTTY for Windows to SSH into a computer running Debian.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;code&gt;123&lt;/code&gt; enters me this regardless of if I am in insert mode or not:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s&#xA;r&#xA;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I use the &quot;normal&quot; (not number pad) number keys, everything works fine.  What is going on here?&lt;/p&gt;&#xA;" OwnerUserId="318" LastEditorUserId="21782" LastEditDate="2019-04-13T16:46:01.680" LastActivityDate="2020-11-22T21:07:05.557" Title="Number pad not working with vi and Putty?" Tags="|terminal|putty|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3871" PostTypeId="2" ParentId="3869" CreationDate="2015-07-07T19:17:55.833" Score="6" Body="&lt;h3&gt;Easy way - &lt;code&gt;grep&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The easiest technique is to use &lt;code&gt;:%!grep -o {pat}&lt;/code&gt;. The &lt;code&gt;-o&lt;/code&gt;/&lt;code&gt;--only-matching&lt;/code&gt; make grep only display the matches.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!grep -o 'foo\w*bar'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: that grep's regex's are a different variant from PCRE and Vim's.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Pure Vim method with plugin - still easy&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;For a pure native vim solution I suggest you look at &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4795&quot; rel=&quot;noreferrer&quot;&gt;ExtractMatches&lt;/a&gt; or &lt;a href=&quot;https://github.com/idanarye/vim-yankitute&quot; rel=&quot;noreferrer&quot;&gt;Yankitute&lt;/a&gt; plugins.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;(Ab)Using &lt;code&gt;:s&lt;/code&gt; for fun and profit&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You want to roll your &quot;extract matches&quot; command with &lt;code&gt;:s&lt;/code&gt; with a sub-replace-expression (&lt;code&gt;\=&lt;/code&gt;) and a list.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let lst = []&#xA;:%s/pattern/\=add(lst, submatch(0))[-1]/g&#xA;:%d&#xA;:pu=lst&#xA;:1d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The basic idea is to add each match to the list, &lt;code&gt;lst&lt;/code&gt;, using a sub-replace-expression for the &lt;code&gt;:s&lt;/code&gt; command. We can use some in-place array trickery to make sure the text doesn't change by always returning the last element of the array (what we just added).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;code&gt;:s&lt;/code&gt; trick is often done in the form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let lst = []&#xA;:%s//\=add(lst, submatch(0))[-1]/g&#xA;:call setreg('&quot;', join(lst, &quot;\n&quot;), 'l')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will capture the current matches (uses last used pattern) into the default register. If you have Vim 7.4 then the &lt;code&gt;:s&lt;/code&gt; can be simplified further: &lt;code&gt;:%s//\=add(lst, submatch(0))/gn&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;More information&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :range!&#xA;:h :s&#xA;:h sub-replace-expression&#xA;:h List&#xA;:h add()&#xA;:h submatch()&#xA;:h :d&#xA;:h :pu&#xA;:h @=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-07-07T21:54:48.867" LastActivityDate="2015-07-07T21:54:48.867" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3873" PostTypeId="2" ParentId="3869" CreationDate="2015-07-07T20:59:15.357" Score="4" Body="&lt;p&gt;An applied answer (pure vim stuff) that keeps email addresses only:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\S\+@\S\+/\r\0\r/g&#xA;:v//d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;place &lt;code&gt;\r&lt;/code&gt; (carriage return, &lt;code&gt;CR&lt;/code&gt;) before and after each email address (i.e. .break lines around each email found, so that each address will go on a separate line);&lt;/li&gt;&#xA;&lt;li&gt;remove all lines which are &lt;em&gt;not&lt;/em&gt; email addresses (last search pattern is used).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Less specific usage&lt;/em&gt;: change &lt;code&gt;\S\+@\S\+&lt;/code&gt; with the desired &lt;code&gt;pattern&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-07-07T21:14:51.740" LastActivityDate="2015-07-07T21:14:51.740" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3874" PostTypeId="2" ParentId="3862" CreationDate="2015-07-08T00:51:43.127" Score="6" Body="&lt;p&gt;The way I do it is &lt;kbd&gt;Ctrl-w&lt;/kbd&gt;&lt;kbd&gt;Backspace&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl-w&lt;/kbd&gt; to delete the last word (I forgot if this is standard vim or not), and since it's just spaces it will take me back to the beginning of the line. Then &lt;kbd&gt;Backspace&lt;/kbd&gt; will take me back to the previous line where I was.&lt;/p&gt;&#xA;" OwnerUserId="2747" LastActivityDate="2015-07-08T00:51:43.127" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3875" PostTypeId="1" AcceptedAnswerId="3877" CreationDate="2015-07-08T00:58:35.640" Score="76" ViewCount="164134" Body="&lt;p&gt;I wonder if I can insert a new line without leaving normal mode. For example, I have two lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is line one&#xA;this is line two&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the cursor is on line one. Now I want a new line between line one and line two, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is line one&#xA;&#xA;this is line two&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know that when I am in normal mode, I can simply press &lt;code&gt;o&lt;/code&gt;. But this would enter insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I insert a new line like and stay in normal mode?&lt;/p&gt;&#xA;" OwnerUserId="2206" LastEditorUserId="1292" LastEditDate="2019-07-13T06:49:52.387" LastActivityDate="2022-02-11T17:58:44.747" Title="How to insert a newline without leaving normal mode" Tags="|normal-mode|" AnswerCount="13" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3876" PostTypeId="2" ParentId="3870" CreationDate="2015-07-08T01:30:34.390" Score="14" Body="&lt;p&gt;Your terminal (PuTTY) is configured to send escape sequences for keypad keys, rather than digits. This is called “application keypad mode” in Unix terminal terminology.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can &lt;a href=&quot;http://vim.wikia.com/wiki/PuTTY_numeric_keypad_mappings&quot; rel=&quot;noreferrer&quot;&gt;configure Vim to understand these escape sequences&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can configure PuTTY to send digits. In the configuration, &lt;a href=&quot;http://the.earth.li/~sgtatham/putty/0.64/htmldoc/Chapter4.html#config-appkeypad&quot; rel=&quot;noreferrer&quot;&gt;in the Keyboard panel&lt;/a&gt;, turn off application keypad mode. Alternatively, turn it off altogether &lt;a href=&quot;http://the.earth.li/~sgtatham/putty/0.64/htmldoc/Chapter4.html#config-features-application&quot; rel=&quot;noreferrer&quot;&gt;in the Features panel&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2015-07-08T01:30:34.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3877" PostTypeId="2" ParentId="3875" CreationDate="2015-07-08T02:25:12.940" Score="46" Body="&lt;p&gt;I use a mapping for that:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Quickly insert an empty new line without entering insert mode&#xA;    nnoremap &amp;lt;Leader&amp;gt;o o&amp;lt;Esc&amp;gt;&#xA;    nnoremap &amp;lt;Leader&amp;gt;O O&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This way you can insert a line under your cursor with &lt;code&gt;&amp;lt;Leader&amp;gt;o&lt;/code&gt; and one on the previous line with &lt;code&gt;&amp;lt;Leader&amp;gt;O&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; One could argue that it requires as many keystrokes as &lt;code&gt;o&amp;lt;Esc&amp;gt;&lt;/code&gt; but hopefully you choosed your leader to make this kind of mapping easy. Also I'm really not sure there is a built-in way to do this.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; I ended up using these mappings instead because there were some edge cases where the new line contained unwanted whitespaces characters:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    nnoremap &amp;lt;Leader&amp;gt;o o&amp;lt;Esc&amp;gt;0&amp;quot;_D&#xA;    nnoremap &amp;lt;Leader&amp;gt;O O&amp;lt;Esc&amp;gt;0&amp;quot;_D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also, the plugin &lt;a href=&quot;https://github.com/tpope/vim-unimpaired/blob/4afbe5ebf32ad85341b4c02b0e1d8ca96a64c561/plugin/unimpaired.vim#L185-L198&quot; rel=&quot;noreferrer&quot;&gt;vim-unimpaired&lt;/a&gt; does it a bit differently:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! BlankUp(count) abort&#xA;  put!=repeat(nr2char(10), a:count)&#xA;  ']+1&#xA;  silent! call repeat#set(&amp;quot;\&amp;lt;Plug&amp;gt;unimpairedBlankUp&amp;quot;, a:count)&#xA;endfunction&#xA;&#xA;function! BlankDown(count) abort&#xA;  put =repeat(nr2char(10), a:count)&#xA;  '[-1&#xA;  silent! call repeat#set(&amp;quot;\&amp;lt;Plug&amp;gt;unimpairedBlankDown&amp;quot;, a:count)&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;Plug&amp;gt;unimpairedBlankUp :call BlankUp(v:count1)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Plug&amp;gt;unimpairedBlankDown :call BlankDown(v:count1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The difference is that my version puts your cursor on the newly created line whereas Pope's version adds the line but leave your cursor on the same place. He also make uses his &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;noreferrer&quot;&gt;vim-repeat&lt;/a&gt; plugin so that the &lt;code&gt;.&lt;/code&gt; command works better.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2021-02-25T14:40:06.027" LastActivityDate="2021-02-25T14:40:06.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3878" PostTypeId="2" ParentId="3875" CreationDate="2015-07-08T02:36:12.983" Score="2" Body="&lt;p&gt;My mapping for this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &quot; Create Blank Newlines and stay in Normal mode&#xA;nnoremap &amp;lt;silent&amp;gt; zj o&amp;lt;Esc&amp;gt;k&#xA;nnoremap &amp;lt;silent&amp;gt; zk O&amp;lt;Esc&amp;gt;j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Different from &lt;a href=&quot;https://vi.stackexchange.com/a/3877/9&quot;&gt;statox's&lt;/a&gt; as this keeps the cursor at the same location. &lt;/p&gt;&#xA;" OwnerUserId="9" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-07-08T02:36:12.983" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3879" PostTypeId="1" AcceptedAnswerId="3899" CreationDate="2015-07-08T04:16:39.073" Score="6" ViewCount="2442" Body="&lt;p&gt;I have opened several files in vim (particularly, in vimdiff). They are opened in multiple (vertically split) windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simple way, in which I can duplicate all this to another tab?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could write a function, which will open a new tab &amp;amp; loop through all buffers in current tab to open in new tab using split/diffsplit. But I wanted to know, if there is an easier way.&lt;/p&gt;&#xA;" OwnerUserId="2749" LastActivityDate="2015-07-09T04:20:29.880" Title="Duplicate tab with windows" Tags="|split|tabbed-user-interface|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3880" PostTypeId="2" ParentId="3875" CreationDate="2015-07-08T04:18:19.573" Score="10" Body="&lt;p&gt;My mapping uses &lt;code&gt;Shift-Enter&lt;/code&gt;.  It differs from the others in that the cursor is returned to the same line &lt;em&gt;and column&lt;/em&gt; using mark o.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Insert new line above without going into insert mode&#xA;&quot; (uses mark o to return to the previous cursor column)&#xA;nnoremap &amp;lt;S-Enter&amp;gt; moO&amp;lt;Esc&amp;gt;`o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="907" LastActivityDate="2015-07-08T04:18:19.573" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3881" PostTypeId="2" ParentId="3875" CreationDate="2015-07-08T06:19:38.337" Score="26" Body="&lt;p&gt;A solution that doesn't go through insert mode, doesn't move the cursor, and allows you to use a counter to append several lines at once (&lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt; etc.):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;o :&amp;lt;C-u&amp;gt;call append(line(&quot;.&quot;),   repeat([&quot;&quot;], v:count1))&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;O :&amp;lt;C-u&amp;gt;call append(line(&quot;.&quot;)-1, repeat([&quot;&quot;], v:count1))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-07-08T06:19:38.337" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3882" PostTypeId="1" AcceptedAnswerId="3900" CreationDate="2015-07-08T09:47:37.583" Score="6" ViewCount="1938" Body="&lt;p&gt;I'm unhappy with the default syntax highlighting in vim and would like to change it. I tried to follow the accepted answer on &lt;a href=&quot;https://stackoverflow.com/questions/1890103/change-syntax-color-in-vim&quot;&gt;this page&lt;/a&gt;, but I think my vim version (7.4) is different. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside &lt;code&gt;/usr/share/vim/vim74/syntax&lt;/code&gt; I have tons of files, so I decided to edit &lt;code&gt;php.vim&lt;/code&gt;. But I find that the format in the file isn't like the one in the link I mentioned. Here's my &lt;a href=&quot;http://pastebin.com/jU2bsmMh&quot; rel=&quot;nofollow noreferrer&quot;&gt;php.vim&lt;/a&gt; file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone help me figure out how to customize vi syntax highlighting?&lt;/p&gt;&#xA;" OwnerUserId="2752" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-07-10T05:29:18.383" Title="Change default syntax highlighting scheme" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3883" PostTypeId="2" ParentId="3879" CreationDate="2015-07-08T10:28:28.890" Score="2" Body="&lt;p&gt;Wrote this function. Worked for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: This will only work for windows split vertically. This was sufficient for me. :-)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set splitright&#xA;function! DuplicateTab()&#xA;    &quot;Note current position &amp;amp; view settings.&#xA;    let cur_win=winnr() - 1&#xA;    let view=winsaveview()&#xA;    &quot;Are we running under vimdiff?&#xA;    let use_diff=&amp;amp;diff&#xA;    &quot;Open new tab&#xA;    tabnew&#xA;    &quot;Go to previous tab&#xA;    tabprev&#xA;    &quot; For every window, open window in next tab&#xA;    windo exec &quot;let localview=winsaveview() | let x=bufnr(\&quot;\&quot;)|tabnext|vnew|exec 'buf ' . x | call winrestview(localview) | tabprev&quot;&#xA;&#xA;    &quot; Reset first tab's position.&#xA;    exec winnr(). &quot;wincmd h&quot;&#xA;    exec cur_win . &quot;wincmd l&quot;&#xA;    call winrestview(view)&#xA;&#xA;    &quot;Go to next tab &amp;amp; close first (empty) window&#xA;    tabnext&#xA;    exec winnr() . &quot;wincmd h&quot;&#xA;    q&#xA;    &quot;Go to the same window being used in current (previous) tab&#xA;    exec cur_win . &quot;wincmd l&quot;&#xA;&#xA;    &quot; If running under vimdiff, start diff view&#xA;    if(use_diff)&#xA;        windo diffthis&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2749" LastActivityDate="2015-07-08T10:28:28.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3884" PostTypeId="2" ParentId="3718" CreationDate="2015-07-08T10:40:23.273" Score="3" Body="&lt;p&gt;@Carpetsmoker♦ 's proposal is great enough. But you can also consider to map those command with some key so you can resize your windows just as using your mouse.&#xA;For example, write this in your &lt;code&gt;_vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-\&amp;gt; :set columns+=1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so every time you hit &lt;code&gt;Crtl+\&lt;/code&gt; you will make your larger with one more column(you can also set it to be two or so).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same,&lt;code&gt;nnoremap &amp;lt;C-\&amp;gt; :set lines+=1&amp;lt;CR&amp;gt;&lt;/code&gt; give you one more line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can try any other key-mappings. Anyway, this is really cool~~&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you want to add columns and lines simultaneously, you can do it with this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-[&amp;gt; :set columns+=1 &amp;lt;bar&amp;gt; set lines+=1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; stand for &lt;code&gt;|&lt;/code&gt;, which enable you to achieve multiple commands on the same line when you are in your gvim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more, see:&lt;a href=&quot;https://stackoverflow.com/questions/3249275/vim-multiple-commands-on-same-line/3249303#3249303&quot;&gt;https://stackoverflow.com/questions/3249275/vim-multiple-commands-on-same-line/3249303#3249303&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and also:&lt;a href=&quot;https://vi.stackexchange.com/questions/3885/how-to-map-two-commands-with-only-one-key/3886#3886&quot;&gt;How to map two commands with only one key&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2206" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-07-08T12:51:54.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3885" PostTypeId="1" AcceptedAnswerId="3886" CreationDate="2015-07-08T10:54:06.743" Score="19" ViewCount="22847" Body="&lt;p&gt;My question comes from this two commands I added on my &lt;code&gt;_vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-[&amp;gt; :set columns+=1&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-]&amp;gt; :set lines+=1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As is known, it will resize your gvim (I am using gvim on windows) with one more column when you hit &lt;kbd&gt;Ctrl-[&lt;/kbd&gt;, and one more line when you hit &lt;kbd&gt;Ctrl-]&lt;/kbd&gt;. That is really cool since you can achieve that resizement as though you are using your mouse. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if I can map those two command with only one key to make it more comfortable.&lt;/p&gt;&#xA;" OwnerUserId="2206" LastEditorUserId="1821" LastEditDate="2015-07-08T10:56:45.493" LastActivityDate="2023-07-19T12:49:43.917" Title="How to map two commands with only one key" Tags="|gvim|vim-windows|window-management|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3886" PostTypeId="2" ParentId="3885" CreationDate="2015-07-08T11:04:35.930" Score="17" Body="&lt;p&gt;You can do this with &lt;code&gt;\|&lt;/code&gt; on unix in the &lt;code&gt;.vimrc&lt;/code&gt; file, or with &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; on windows in the &lt;code&gt;_vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; unix&#xA;nnoremap &amp;lt;C-[&amp;gt; :set columns+=1 \| lines+=1&amp;lt;CR&amp;gt; &#xA;&amp;quot; windows&#xA;nnoremap &amp;lt;C-[&amp;gt; :set columns+=1 &amp;lt;bar&amp;gt; lines+=1&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See the documentation : &lt;code&gt;:help :bar&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;ref: &lt;a href=&quot;https://stackoverflow.com/a/3249303/2558252&quot;&gt;https://stackoverflow.com/a/3249303/2558252&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="12489" LastEditDate="2023-07-19T12:49:43.917" LastActivityDate="2023-07-19T12:49:43.917" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="3887" PostTypeId="2" ParentId="3875" CreationDate="2015-07-08T12:58:55.817" Score="4" Body="&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/1558396/2877364&quot;&gt;This answer&lt;/a&gt; by Maxim Kim was life-changing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;space&amp;gt; :exe &quot;normal i&quot;.nr2char(getchar())&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and my riff on it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;s-space&amp;gt; :exe &quot;normal a&quot;.nr2char(getchar())&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put those lines in your &lt;code&gt;vimrc&lt;/code&gt;.  Then go to the beginning of the second line of your file and hit &lt;kbd&gt;Space&lt;/kbd&gt;, &lt;kbd&gt;Enter&lt;/kbd&gt;, or go to the end of the first line and hit &lt;kbd&gt;Shift+Space&lt;/kbd&gt;, &lt;kbd&gt;Enter&lt;/kbd&gt;.  Either will add the empty line between the first and second lines, and leave you in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use these for any other single key - hit &lt;kbd&gt;Space&lt;/kbd&gt; or &lt;kbd&gt;Shift+Space&lt;/kbd&gt; followed by the key you want and it will insert or append it, respectively.&lt;/p&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-07-08T12:58:55.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3888" PostTypeId="2" ParentId="3885" CreationDate="2015-07-08T13:14:32.090" Score="11" Body="&lt;p&gt;I would recommend you to use for example &lt;code&gt;&amp;lt;C-P&amp;gt;&lt;/code&gt;, since &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; is the same as &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; is used to jump to a definition of the keyword under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can just do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-P&amp;gt; &amp;lt;Esc&amp;gt;:set columns+=1 lines+=1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The another way is to use the command separator &lt;code&gt;|&lt;/code&gt;, but you have to escape it or use &lt;code&gt;&amp;lt;Bar&amp;gt;&lt;/code&gt; to use it as an argument for the &lt;code&gt;nnoremap&lt;/code&gt; command, otherwise it would be recognized as command separator in the vimrc file, not in the mapping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-P&amp;gt; &amp;lt;Esc&amp;gt;:set columns+=1 \| set lines+=1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when you press &lt;code&gt;&amp;lt;C-P&amp;gt;&lt;/code&gt;, this command is executed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set columns+=1 | set lines+=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2620" LastEditorUserId="2620" LastEditDate="2015-07-08T13:35:11.003" LastActivityDate="2015-07-08T13:35:11.003" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3889" PostTypeId="1" AcceptedAnswerId="3890" CreationDate="2015-07-08T14:11:16.107" Score="1" ViewCount="108" Body="&lt;p&gt;I'm running gVim 7.4 on Windows 7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm editing a text file and I insert text like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1 - public SomeResult GenerateResult(IInput input, Action&amp;lt;string&amp;gt; forEachEventAction)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I add a &lt;code&gt;`&lt;/code&gt; before &lt;code&gt;public&lt;/code&gt; and after the closing parenthesis then a new line is automatically inserted, resulting in this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1 - `public SomeResult GenerateResult(IInput input, Action&amp;lt;string&amp;gt;&#xA;forEachEventAction)`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Interestingly, my real text (code) is split into several lines, not just two, tho the only difference from the above is that the identifiers are much longer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set all&lt;/code&gt; includes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;  formatoptions=tcq&#xA;...&#xA;  textwidth=78&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2629" LastEditorUserId="2629" LastEditDate="2015-07-08T15:27:51.953" LastActivityDate="2015-07-08T15:27:51.953" Title="Why are new lines being added automatically when I insert backticks?" Tags="|line-breaks|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3890" PostTypeId="2" ParentId="3889" CreationDate="2015-07-08T15:26:36.620" Score="1" Body="&lt;p&gt;This seems to be due to my editing a file with a &lt;em&gt;.txt&lt;/em&gt; extension. You might notice that I'm using Markdown syntax in my example. I've been mostly editing &lt;em&gt;.md&lt;/em&gt; files previously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on my &lt;code&gt;formatoptions&lt;/code&gt; setting, text is auto-wrapped using &lt;code&gt;textwidth&lt;/code&gt;, hence the new lines (and the different number of new lines depending on the length of the text).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The auto-formatting also was unrelated to backtick characters specifically.&lt;/p&gt;&#xA;" OwnerUserId="2629" LastActivityDate="2015-07-08T15:26:36.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3891" PostTypeId="2" ParentId="3875" CreationDate="2015-07-08T16:11:32.960" Score="14" Body="&lt;p&gt;I personally recommend using Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;noreferrer&quot;&gt;Unimpaired plugin&lt;/a&gt;. It provides many mappings but the ones you will looking for are &lt;code&gt;[&amp;lt;space&amp;gt;&lt;/code&gt; and &lt;code&gt;]&amp;lt;space&amp;gt;&lt;/code&gt; which create blank lines above and below the current line respectively. Unimpaired also provides nice mappings for moving through the quickfix list, buffer list, option toggling, and many others. See &lt;code&gt;:h unimpaired&lt;/code&gt; for more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do not want to use unimpaired plugin but like the mappings below are some quick mappings to put in your &lt;code&gt;~/.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; [&amp;lt;space&amp;gt;  :&amp;lt;c-u&amp;gt;put!=repeat([''],v:count)&amp;lt;bar&amp;gt;']+1&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; ]&amp;lt;space&amp;gt;  :&amp;lt;c-u&amp;gt;put =repeat([''],v:count)&amp;lt;bar&amp;gt;'[-1&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-07-08T16:11:32.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3892" PostTypeId="2" ParentId="3831" CreationDate="2015-07-08T17:14:22.350" Score="3" Body="&lt;p&gt;Here you are : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Parse()&#xA;  &quot; keep only the struct definitions&#xA;  v/\v.*(\s|\()struct (\w+).*/d&#xA;  &quot; keep only the names of the structs&#xA;  %s/\v.*(\s|\()struct (\w+).*/\2/&#xA;  &quot; sort and keep non-duplicate lines&#xA;  %sort u&#xA;  &quot; add line numbers&#xA;  %s/^/\=printf('%-d. ', line('.')-1)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On your file use it with : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call Parse()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the file you provided I didn't match as results as you (but I didn't found any &lt;code&gt;smsc911x_data&lt;/code&gt; for example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want detailed explanation about how I did just ask :)&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-07-09T07:58:27.480" LastActivityDate="2015-07-09T07:58:27.480" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="3893" PostTypeId="2" ParentId="3718" CreationDate="2015-07-08T17:17:22.170" Score="5" Body="&lt;p&gt;You should be able to drag the corner of the window with your mouse. I can resize gVim on Windows 7 this way. The Vim shortcut opens a console window that cannot be resized larger by dragging it with the mouse, so make sure you're running gVim and not Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can use the keyboard to resize gVim. The exact key sequence to access the Size system menu item depends on the setting of &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27winaltkeys%27&quot;&gt;&lt;code&gt;winaltkeys&lt;/code&gt;&lt;/a&gt;. If it is set to &lt;code&gt;yes&lt;/code&gt;, you can use Alt+Space to open the system menu. If set to &lt;code&gt;menu&lt;/code&gt; or &lt;code&gt;no&lt;/code&gt;, you will need to press and release Alt, and then press Space. After the menu appears, press S to go into resize mode. Use an arrow key to select which side of the window to resize, and then arrow keys to resize that side. This is standard functionality for all (normal) Windows applications, although the &lt;code&gt;winaltkeys&lt;/code&gt; setting is particular to gVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another quick keyboard resizing method in Windows 7 is to hold the Windows key and press the left or right arrow keys. This will make gVim half the size of your monitor on either the left or right side of the screen. This is another standard feature in Windows 7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, if you are running Vim (the console version), you can still resize the application. Click the system menu (the Vim icon in the upper-left corner of the window, just left of the window title, or press Alt+Space to open the menu) and choose Properties. The Layout tab contains two up-down edit boxes for the Window Size, and increasing them will enlarge your Vim window. If you want to make the window smaller, edit the Screen Buffer sizes. (Basically, you probably want both the Screen Buffer and Window Sizes to match for a console Vim window, and editing either one of them in this manner will automatically update the other.) This is also a standard Windows feature for any console window.&lt;/p&gt;&#xA;" OwnerUserId="2680" LastActivityDate="2015-07-08T17:17:22.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3894" PostTypeId="1" AcceptedAnswerId="3896" CreationDate="2015-07-08T17:39:19.563" Score="4" ViewCount="7683" Body="&lt;p&gt;I was looking at some of the special characters for use in a status line, and I found one that shows the percentage through file of displayed window (&lt;code&gt;%P&lt;/code&gt;).  However, I can find no way of getting this value through a function or a command that is provided by default.  I did see that this is the value displayed by the &lt;code&gt;ruler&lt;/code&gt; option, but as far as I know, there is no way of capturing that value.  How do you get this percentage?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Note&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I know about the &lt;code&gt;:file&lt;/code&gt; command, but that doesn't display the percentage I want.  (you can capture this value with the &lt;code&gt;:redir&lt;/code&gt; command)&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-07-08T19:25:01.390" Title="Get percentage through file of displayed window" Tags="|statusline|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3895" PostTypeId="2" ParentId="3894" CreationDate="2015-07-08T17:55:05.093" Score="4" Body="&lt;p&gt;A simple way (line number accuracy):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LinePercent()&#xA;    return line('.') * 100 / line('$') . '%'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sample usage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo LinePercent()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And with byte accuracy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BytePercent()&#xA;    let crt_byte = line2byte(line('.')) + col('.') - 1&#xA;    let last_byte = line2byte(line('$')) + col(['$', '$']) - 1&#xA;    return crt_byte * 100 / last_byte . '%'&#xA;endfunction&#xA;&#xA;echo BytePercent()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h ruler&lt;/code&gt; says just that: &quot;relative position in the file&quot;. It's true that the numbers displayed by the ruler are not entirely consistent with the above methods. It may be using &lt;code&gt;line('w0')&lt;/code&gt;, &lt;code&gt;line('w$')&lt;/code&gt;, or some other combination (e.g. the mean between firsts and last visible lines, or chars, or bytes, instead of the current cursor position) when computing the file position (it also shows 'Top' or 'Bottom' ...) . One &lt;em&gt;can&lt;/em&gt; look in Vim source, if needed, but does one really need that?&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-07-08T18:27:14.620" LastActivityDate="2015-07-08T18:27:14.620" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3896" PostTypeId="2" ParentId="3894" CreationDate="2015-07-08T19:25:01.390" Score="5" Body="&lt;p&gt;If you're really determined to do it, it can be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A mostly accurate translation of the &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/buffer.c#L4405-L4434&quot; rel=&quot;noreferrer&quot;&gt;source function&lt;/a&gt; might look like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Stl_P()&#xA;    let above = line('w0') - 1&#xA;    let below = line('$') - line('w$')&#xA;    if below &amp;lt;= 0&#xA;        return above ? 'Bot' : 'All'&#xA;    elseif above &amp;lt;= 0&#xA;        return 'Top'&#xA;    else&#xA;        return printf('%2d%%', above &amp;gt; 1000000 ?&#xA;            \ above / ((above + below) / 100) :&#xA;            \ above * 100 / (above + below))&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't work with &lt;code&gt;diff&lt;/code&gt; buffers where at least one of the files being &lt;code&gt;diff&lt;/code&gt;ed has removed lines, since there is no way to get the &lt;code&gt;w_topfill&lt;/code&gt; in VimL (or perhaps I didn't ponder about it deep enough).  Oh well.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-07-08T19:25:01.390" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3897" PostTypeId="1" AcceptedAnswerId="3898" CreationDate="2015-07-08T19:34:03.293" Score="15" ViewCount="2847" Body="&lt;p&gt;Whenever I open a tmux session in terminal, all of the tabs containing vim sessions are labelled &lt;code&gt;vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: How to configure it to label tmux tabs with the name of the edited file or something like &lt;code&gt;vim | test.cpp&lt;/code&gt; used as the title of the tabs in question.&lt;/p&gt;&#xA;" OwnerUserId="2758" LastEditorUserId="2830" LastEditDate="2015-07-14T22:16:54.460" LastActivityDate="2023-04-18T14:57:57.117" Title="How to label tmux tabs with the name of the file edited in vim?" Tags="|vimrc|terminal|tmux|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3898" PostTypeId="2" ParentId="3897" CreationDate="2015-07-08T20:31:05.227" Score="23" Body="&lt;p&gt;There you go : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call system(&quot;tmux rename-window 'vim | &quot; . expand(&quot;%:t&quot;) . &quot;'&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On buffer read, file read or buffer new file event (see &lt;code&gt;:help autocmd-events&lt;/code&gt;) execute the next command : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call system()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Call a system function and pass it the text : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;tmux rename-window 'vim | &quot;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Rename the current window with a string starting with &lt;code&gt;vim |&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;. expand(&quot;%:t&quot;) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add to the string the filename (see &lt;a href=&quot;http://vim.wikia.com/wiki/Get_the_name_of_the_current_file&quot; rel=&quot;noreferrer&quot;&gt;this article&lt;/a&gt; for the formatting and &lt;a href=&quot;https://stackoverflow.com/questions/10842051/how-to-pass-argument-to-a-script-in-vim-system-call&quot;&gt;this post&lt;/a&gt; for the expand insert)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;. &quot;'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add the final &lt;code&gt;'&lt;/code&gt; to close the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After expanding it will look like (while editing the .vimrc file): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;system(&quot;tmux rename-window 'vim | .vimrc'&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As @erthalion said in the comment, you can clean up when leaving vim with :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimLeave * call system(&quot;tmux rename-window 'tmux'&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-07-16T07:36:42.257" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3899" PostTypeId="2" ParentId="3879" CreationDate="2015-07-08T23:34:40.733" Score="6" Body="&lt;p&gt;You can use &lt;code&gt;:mksession&lt;/code&gt; with a specialized &lt;code&gt;'sessionoptions'&lt;/code&gt; to make this easier.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set sessionoptions=blank,help,folds,winsize,localoptions&#xA;:mksession&#xA;:tabnew&#xA;:source Session.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using this technique we can create an easy to use command. Put the following command in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar DuplicateTabpane&#xA;      \ let s:sessionoptions = &amp;amp;sessionoptions |&#xA;      \ try |&#xA;      \   let &amp;amp;sessionoptions = 'blank,help,folds,winsize,localoptions' |&#xA;      \   let s:file = tempname() |&#xA;      \   execute 'mksession ' . s:file |&#xA;      \   tabnew |&#xA;      \   execute 'source ' . s:file |&#xA;      \ finally |&#xA;      \   silent call delete(s:file) |&#xA;      \   let &amp;amp;sessionoptions = s:sessionoptions |&#xA;      \   unlet! s:file s:sessionoptions |&#xA;      \ endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can just call &lt;code&gt;:DuplicateTabpane&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :mksession&#xA;:h :mkview&#xA;:h 'sessionoptions'&#xA;:h :tabnew&#xA;:h :source&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-07-09T04:20:29.880" LastActivityDate="2015-07-09T04:20:29.880" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3900" PostTypeId="2" ParentId="3882" CreationDate="2015-07-09T03:38:10.240" Score="4" Body="&lt;p&gt;(I'm answering my own question so that it can be closed. All credit to @Nobe4 and @lcd047)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;/usr/share/vim/vim74/syntax&lt;/code&gt; directory doesn't have colors, surprisingly. What is needed to change syntax highlighting in &lt;code&gt;vim&lt;/code&gt; is a colorscheme. These can be placed in &lt;code&gt;~/.vim/colors/&lt;/code&gt; and activated in &lt;code&gt;vi&lt;/code&gt; with &lt;code&gt;set syntax on&lt;/code&gt; and &lt;code&gt;colorscheme cool_color_scheme.vim&lt;/code&gt;. It's also possible to make one's own color schemes; check out &lt;a href=&quot;http://bytefluent.com/vivify/&quot; rel=&quot;nofollow&quot;&gt;http://bytefluent.com/vivify/&lt;/a&gt; for a visual colorscheme maker/editor for vim.&lt;/p&gt;&#xA;" OwnerUserId="2752" LastEditorUserId="2752" LastEditDate="2015-07-10T05:29:18.383" LastActivityDate="2015-07-10T05:29:18.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3901" PostTypeId="2" ParentId="3875" CreationDate="2015-07-09T06:17:17.410" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/alxndr/dotfiles/blob/ca7749140493099da4e2d5de08243d91131b73ef/.nvimrc#L103&quot; rel=&quot;nofollow&quot;&gt;My personal solution&lt;/a&gt; sticks a newline character into the expression register and pastes it after the current line, then jumps back to the original position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap K m`&quot;=&quot;\n&quot;&amp;lt;CR&amp;gt;p``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="67" LastActivityDate="2015-07-09T06:17:17.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3902" PostTypeId="1" AcceptedAnswerId="3903" CreationDate="2015-07-09T07:04:01.130" Score="1" ViewCount="893" Body="&lt;p&gt;I want to execute a shell command in a new buffer from within Vimscript, but do not want to move the focus (cursor) out of the current active buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I'm using the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:ExecuteInShell(command, bang)&#xA;    &quot; http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window&#xA;    let _ = a:bang != '' ? s:_ : a:command == '' ? '' : join(map(split(a:command), 'expand(v:val)'))&#xA;    if (_ != '')&#xA;        let s:_ = _&#xA;        let bufnr = bufnr('%')&#xA;        let winnr = bufwinnr('^' . _ . '$')&#xA;        silent! execute  winnr &amp;lt; 0 ? 'belowright new ' . fnameescape(_) : winnr . 'wincmd w'&#xA;        setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile wrap number&#xA;        silent! :%d&#xA;        let message = 'Execute ' . _ . '...'&#xA;        call append(0, message)&#xA;        echo message&#xA;        silent! 2d | resize 1 | redraw&#xA;        silent! execute 'silent! %!'. _&#xA;        silent! execute 'resize ' . line('$')&#xA;        silent! execute 'syntax on'&#xA;        silent! execute 'autocmd BufUnload &amp;lt;buffer&amp;gt; execute bufwinnr(' . bufnr . ') . ''wincmd w'''&#xA;        silent! execute 'autocmd BufEnter &amp;lt;buffer&amp;gt; execute ''resize '' .  line(''$'')'&#xA;        silent! execute 'nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; :call &amp;lt;SID&amp;gt;ExecuteInShell(''' . _ . ''', '''')&amp;lt;CR&amp;gt;'&#xA;        silent! execute 'nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;LocalLeader&amp;gt;r :call &amp;lt;SID&amp;gt;ExecuteInShell(''' . _ . ''', '''')&amp;lt;CR&amp;gt;'&#xA;        silent! execute 'nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;LocalLeader&amp;gt;g :execute bufwinnr(' . bufnr . ') . ''wincmd w''&amp;lt;CR&amp;gt;'&#xA;        nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;C-W&amp;gt;_ :execute 'resize ' . line('$')&amp;lt;CR&amp;gt;&#xA;        silent! syntax on&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works great but moves the focus to the newly created buffer. &#xA;Can you please tell me how to modify it so the focus stays on the current buffer?&lt;/p&gt;&#xA;" OwnerUserId="1317" LastActivityDate="2015-07-09T14:25:16.050" Title="Execute shell command in new buffer without switching to it" Tags="|vimscript|split|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3903" PostTypeId="2" ParentId="3902" CreationDate="2015-07-09T07:53:12.807" Score="2" Body="&lt;p&gt;Try adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wincmd p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;at the end of the function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the equivalent of &lt;code&gt;Ctrl-w p&lt;/code&gt; (go to previous window). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h wincmd&lt;/code&gt; (and the previous topic, some lines above).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-07-09T14:25:16.050" LastActivityDate="2015-07-09T14:25:16.050" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3904" PostTypeId="2" ParentId="3814" CreationDate="2015-07-09T09:20:33.633" Score="1" Body="&lt;p&gt;If you have large functions like me, you can use this to fold your functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! MyFoldLevel(linenum)&#xA;    if ! exists('w:nextline')&#xA;        let w:nextline = 0&#xA;        let w:insideafun = 0&#xA;    endif&#xA;&#xA;    if w:nextline == 1&#xA;        let w:nextline = 0&#xA;        let w:insideafun = 0&#xA;    endif&#xA;&#xA;    let l:line = getline(a:linenum)&#xA;&#xA;    if l:line =~# '^[[:space:]]*fun'&#xA;        let w:insideafun = 1&#xA;        return '&amp;gt;1'&#xA;    elseif l:line =~# '^[[:space:]]*endf'&#xA;        let w:nextline = 1&#xA;        return '&amp;lt;1'&#xA;    endif&#xA;&#xA;    if w:insideafun == 1&#xA;        return 1&#xA;    else&#xA;        return 0&#xA;    endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And add this modeline to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim:fde=MyFoldLevel(v\:lnum):fdm=expr:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2620" LastActivityDate="2015-07-09T09:20:33.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3906" PostTypeId="2" ParentId="3851" CreationDate="2015-07-09T17:47:50.307" Score="8" Body="&lt;p&gt;I think the most likely culprit is another buffer still in diff-mode. This can happen if you're looking at multiple diffs, one after another, and don't turn off diff-mode between diffs.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Disable diff-mode in irrelevant buffers&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The solution is to find the offending buffer(s) and turn off diff-mode with &lt;code&gt;:diffoff&lt;/code&gt;. If you don't want to search for it, you can use &lt;code&gt;:bufdo diffoff&lt;/code&gt;. &lt;code&gt;:bufdo&lt;/code&gt; visits each buffer sequentially and runs the command provided. This can have the unwanted side-effect of leaving your window displaying a different buffer after running the command.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-07-09T17:47:50.307" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3907" PostTypeId="1" CreationDate="2015-07-10T09:34:10.810" Score="4" ViewCount="448" Body="&lt;p&gt;I have the same vimrc file for both Windows and Ubuntu environments.  It works fine on both platforms, except for one difference.  The line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-[&amp;gt; &amp;lt;C-t&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is working fine on Windows, but on Ubuntu (14.04.2 64 bit) as soon as vim loads it puts me into replace mode and says &quot;at bottom of tag stack&quot;, as if it's running the command immediately instead of just performing the mapping.  I have other nmap lines before/after this one which don't cause any problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm on the latest vim on both platforms; on Ubuntu I'm using vim-gnome(huge build).&lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastEditorUserId="1841" LastEditDate="2015-07-11T16:37:44.197" LastActivityDate="2015-07-11T16:37:44.197" Title="How to remap &lt;C-[&gt; on linux" Tags="|key-bindings|vimrc|linux|escape|" AnswerCount="0" CommentCount="4" ClosedDate="2015-07-20T14:39:23.430" ContentLicense="CC BY-SA 3.0" />
  <row Id="3908" PostTypeId="1" CreationDate="2015-07-10T09:34:41.170" Score="2" ViewCount="93" Body="&lt;p&gt;I'm trying to integrate &lt;a href=&quot;https://github.com/Angles/some-scripts/blob/master/bin/mvimdiff&quot; rel=&quot;nofollow&quot;&gt;mvimdiff&lt;/a&gt; into my workflow - but when I launch it via:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git difftool &amp;lt;filename&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm getting a wonky layout like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_________________________&#xA;|                    |   |&#xA;|                    |   |&#xA;|                    |   |&#xA;|         A          | B |&#xA;|                    |   |&#xA;|                    |   |&#xA;|____________________|___|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've got a double monitor setup, so I figured it might be keying into the wider available display area? Is there any way I can specify it's resolution on startup so that it has a better chance of correctly splitting the window?&lt;/p&gt;&#xA;" OwnerUserId="2778" LastEditorUserId="51" LastEditDate="2015-07-10T09:51:06.420" LastActivityDate="2015-07-10T09:51:06.420" Title="Mvimdiff launches with vertical split on far right" Tags="|vimdiff|git|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3909" PostTypeId="2" ParentId="3831" CreationDate="2015-07-10T13:07:24.647" Score="3" Body="&lt;p&gt;I'd still suggest using the program that you wrote. You can save its output to a scratch buffer and then use tag navigation. Something like (hat-tip to Nobe4):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Parse()&#xA;    let command = &quot;%!/path/to/find_structs &quot; . shellescape(expand('%'))&#xA;    new&#xA;    &quot; http://vim.wikia.com/wiki/Vim_buffer_FAQ &#xA;    &quot; (How is a scratch (temporary) buffer created?)&#xA;    setlocal buftype=nofile&#xA;    setlocal bufhidden=hide&#xA;    setlocal noswapfile&#xA;    set nobuflisted&#xA;    execute command&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-07-10T13:07:24.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3910" PostTypeId="2" ParentId="3853" CreationDate="2015-07-10T16:31:55.503" Score="0" Body="&lt;p&gt;I've added a control from a tree to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;___________________&#xA;|&amp;gt;. |CMake |ATools|&#xA;| . |      |      |&#xA;| . |      |      |&#xA;|&amp;gt;  |      |      |&#xA;| . |      |      |&#xA;-------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the file is opened from the tree with the 'o' key, it opens it in the first split and the next corresponding file in the second split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tree filter is set to only show CMakeLists.txt, Makefile.am and configure.ac in the directories.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;syntax on&#xA;filetype plugin indent on&#xA;&#xA;&quot; toggle between relate files in dir&#xA;function! Alternative(cmd, ...) abort&#xA;  let f = expand(&quot;%:p:gs?\\?/?&quot;)&#xA;  let files = map(copy(get(g:, 'related_files', [])), 'fnamemodify(expand(v:val), &quot;:gs?\\?/?&quot;)')&#xA;  let files = a:0 &amp;amp;&amp;amp; a:1 ? reverse(files) : files&#xA;  let idx = index(map(copy(files), 'f[len(f)-len(v:val)-1:] ==# &quot;/&quot; . v:val'), 1)&#xA;  if idx == -1&#xA;    return 'echoerr &quot;No alternative file&quot;'&#xA;  endif&#xA;  let path = fnamemodify(expand('%:p:h:gs?\\?/?') . repeat(&quot;/..&quot;, len(split(files[idx], &quot;/&quot;))-1), &quot;:p&quot;)&#xA;  let files = files[idx+1 : ] + (idx ? files[0 : idx-1] : [])&#xA;  call filter(files, 'filereadable(path . &quot;/&quot; . v:val)')&#xA;  call map(files, 'a:cmd . &quot; &quot; . path . &quot;/&quot; . v:val')&#xA;  return get(files, 0, 'echoerr &quot;No alternative file&quot;')&#xA;endfunction&#xA;&#xA;let g:related_files = ['CMakeLists.txt', 'Makefile.am', 'configure.ac']&#xA;command! -bang A execute Alternative('edit&amp;lt;bang&amp;gt;')&#xA;command! -bang AS execute Alternative('vsplit&amp;lt;bang&amp;gt;')&#xA;&#xA;&quot; split to the right&#xA;set splitright&#xA;&#xA;&quot; launch the tree immediately&#xA;autocmd VimEnter * NERDTree&#xA;&#xA;autocmd FileType nerdtree nnoremap &amp;lt;buffer&amp;gt; o :only^M :call nerdtree#ui_glue#invokeKeyMap(&quot;o&quot;)^M :AS^M :wincmd t^M&#xA;&#xA;&quot; filter tree for autotools-CMake porting&#xA;let NERDTreeIgnore = ['\(CMakeLists\.txt\|Makefile\.am\|configure\.ac\)\@&amp;lt;!$[[file]]']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently it is not adapted for displaying of all three files at once (but looking too much at configure.ac is not too useful anyways).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And one small thing that may be useful is to always display CMakeLists.txt in the left split and Makefile.am in the right regardless of which file was selected in the tree.&lt;/p&gt;&#xA;" OwnerUserId="2727" LastActivityDate="2015-07-10T16:31:55.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3911" PostTypeId="2" ParentId="3848" CreationDate="2015-07-10T16:53:09.857" Score="6" Body="&lt;p&gt;The &lt;a href=&quot;https://vi.stackexchange.com/questions/3848/how-to-get-the-current-byte-offset-in-whole-file/3850#3850&quot;&gt;other answer&lt;/a&gt; did not work for me when I opened a binary file without line ending. It seems that there is a bug in vim when it comes to counting bytes in a binary file without eol. (edit: yes, this was a bug. I have &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/zX45zm-cnc0/-BWjjh5tlX8J&quot; rel=&quot;nofollow noreferrer&quot;&gt;submitted a patch&lt;/a&gt;, which got &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/PnMWN0rujOk/hRxX91VZAc4J&quot; rel=&quot;nofollow noreferrer&quot;&gt;accepted in 7.4.781&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To find the byte offset, while accounting for the bug in old Vim versions, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let offset = line2byte(line('.')) + col('.') - 1&#xA;if version &amp;lt; 781 &amp;amp;&amp;amp; &amp;amp;l:binary == 1 &amp;amp;&amp;amp; &amp;amp;l:eol == 0&#xA;    &quot; Vim prior 7.4.781 had a bug where the line count is off by 1 or 2.&#xA;    &quot; See https://groups.google.com/forum/#!msg/vim_dev/zX45zm-cnc0/-BWjjh5tlX8J&#xA;    let offset += 1&#xA;    let offset += line('.') == 1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This bug also affects the &lt;code&gt;%o&lt;/code&gt; specifier in e.g. &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;rulerformat&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;rulerformat&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2720" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-07-12T21:20:04.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3912" PostTypeId="1" AcceptedAnswerId="3913" CreationDate="2015-07-11T02:52:31.950" Score="4" ViewCount="170" Body="&lt;p&gt;I sometimes have to cut a line (&lt;code&gt;d&lt;/code&gt;) and paste in in the middle of another line. I'd like to remove the whitespaces that vim has copied (i.e. trim/strip the content). How can I do that in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A common use case is that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;value := getValue()&#xA;if value == &quot;test&quot; {&#xA;    // Do something with value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In go, it is idiomatic to use &lt;code&gt;if value := getValue(); value == &quot;test&quot;&lt;/code&gt; if value is only used within the if. However, sometimes I write the variable declaration outside of the if because I either used the variable after the if (and later moved that code inside the if), or because I simply forgot it. So, I'd like to cut the line &lt;code&gt;value := getValue()&lt;/code&gt; and paste it after &lt;code&gt;if&lt;/code&gt;. If I press &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;P&lt;/code&gt;, it is inserted after (or before) the current line. Can I somehow insert that line onto the current line and remove the starting/trailing whitespaces (tabs, new lines, and &lt;code&gt;&lt;/code&gt;)? I often have to do that in Latex documents, too.&lt;/p&gt;&#xA;" OwnerUserId="2789" LastActivityDate="2015-07-11T17:05:05.597" Title="Cut line, trim it and then paste it on another line" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3913" PostTypeId="2" ParentId="3912" CreationDate="2015-07-11T04:14:11.477" Score="4" Body="&lt;p&gt;You can go to the line with &lt;code&gt;getValue()&lt;/code&gt; and do something like &lt;kbd&gt;^&lt;/kbd&gt;&lt;kbd&gt;D&lt;/kbd&gt; to cut the contents, then go to the space after &lt;code&gt;if&lt;/code&gt; and press &lt;kbd&gt;p&lt;/kbd&gt; to paste it.  This is not perfect because it leaves an empty line (more precisely a line with spaces) where &lt;code&gt;getValue()&lt;/code&gt; has been, and you need to add a space after pasting.  But it's still a lot better than pasting the entire line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you feel like learning something useful, run &lt;code&gt;:h operator&lt;/code&gt; and read the entire chapter there.  Pay particular attention to &quot;text objects&quot;, those are one of the most powerful intermediate level concepts in Vim.  When you feel comfortable with the built-in text objects you can install the &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow&quot;&gt;textobj-user&lt;/a&gt; plugin, and add support for &lt;a href=&quot;https://github.com/kana/vim-textobj-user/wiki&quot; rel=&quot;nofollow&quot;&gt;many other objects&lt;/a&gt;.  In particular the &lt;a href=&quot;https://github.com/fatih/vim-go&quot; rel=&quot;nofollow&quot;&gt;vim-go&lt;/a&gt; plugin adds support for Go functions as objects (among many other things), and &lt;a href=&quot;https://github.com/rbonvall/vim-textobj-latex&quot; rel=&quot;nofollow&quot;&gt;textobj-latex&lt;/a&gt; adds support for equation objects in LaTeX.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="1577" LastEditDate="2015-07-11T17:05:05.597" LastActivityDate="2015-07-11T17:05:05.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3914" PostTypeId="1" CreationDate="2015-07-11T08:31:31.610" Score="1" ViewCount="259" Body="&lt;p&gt;So I am trying out javascript on vim. It is great that it automatically indents the braces for me when I close them etc.. But I was typing some JS and got into a bracket muddle.&#xA;Here is what I had:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;angular.module('functionalities', [])&#xA;.directive(&quot;entering&quot;, function() {_}&#xA;})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have put an underscore to represent where my cursor was when I started typing, in this case it was on this line in between the two braces : &lt;code&gt;.directive(&quot;entering&quot;, function() {_}&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;when I press enter the closing brace stays behind my cursor, is there a way to get it to go to the line underneath my cursor and indent correctly? like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;angular.module('functionalities', [])&#xA;.directive(&quot;entering&quot;, function() {&#xA;    _&#xA;  }&#xA;})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I close braces, it automatically indents them in the right place for me, I am not sure if this due to a plugin I may have installed like Surround.vim but in this kind of situation where I insert text before the brace, it put me into a muddle with my brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suggestions would be incredibly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2488" LastActivityDate="2015-07-11T08:31:31.610" Title="Forcing bracket to go under cursor" Tags="|vimrc|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3915" PostTypeId="1" AcceptedAnswerId="3919" CreationDate="2015-07-11T11:29:38.350" Score="2" ViewCount="833" Body="&lt;p&gt;I really like how the less pager uses &lt;kbd&gt;w&lt;/kbd&gt; to scroll up and &lt;kbd&gt;z&lt;/kbd&gt; to scroll down since they are single keys, in vim I have to use &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;d&lt;/kbd&gt;/&lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;f&lt;/kbd&gt; to get the same effect. Having to hold &lt;kbd&gt;ctrl&lt;/kbd&gt; is a bit of a nuisance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course I could just remap the scroll keys, but that might break plugins, generate bad karma, etc, etc... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a single key shortcut to move down by a screen already?&#xA;Your suggestions?&lt;/p&gt;&#xA;" OwnerUserId="2792" LastEditorUserId="1841" LastEditDate="2015-07-11T12:11:16.067" LastActivityDate="2015-07-11T12:22:50.677" Title="Vim scroll window like in less pager (with single key)?" Tags="|vim-windows|scrolling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3916" PostTypeId="1" AcceptedAnswerId="3917" CreationDate="2015-07-11T11:46:42.003" Score="7" ViewCount="2556" Body="&lt;p&gt;I want to run a bash command on writing a &lt;code&gt;.less&lt;/code&gt; file, saving it and generating the corresponding &lt;code&gt;.css&lt;/code&gt; file with the same name and in the same directory. I do have the bash command which generates the &lt;code&gt;.css&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not used to vimscript except for working with vim and changing some stuff in my &lt;code&gt;.vimrc&lt;/code&gt;, so I'm not sure how to get this to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum it up:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How do I run a bash command on &lt;code&gt;:w&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;How do I get the current file directory (vimscript or bash)?&lt;/li&gt;&#xA;&lt;li&gt;How do I get the current file name (vimscript or bash)?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2020" LastEditorUserId="2020" LastEditDate="2015-07-13T14:24:53.550" LastActivityDate="2015-07-13T14:24:53.550" Title="Run bash command on writing a file with a particular extension?" Tags="|save|autocmd|linux|bash|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3917" PostTypeId="2" ParentId="3916" CreationDate="2015-07-11T11:55:40.993" Score="12" Body="&lt;p&gt;You can use autocommands to run things automatically when certain events occur.  In your case, you could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.less !less &amp;lt;afile&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This autocommand runs every time a buffer with a name that ends in &lt;code&gt;.less&lt;/code&gt; is written.  The command that is being run is a bash command, and &lt;code&gt;&amp;lt;afile&amp;gt;&lt;/code&gt; is the name of the file that is being written.  Essentially, the &lt;code&gt;!&lt;/code&gt; command allows you to run bash commands in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relevant help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :autocmd&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help BufWritePost&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help &amp;lt;afile&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;NOTE&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim doesn't automatically refresh the screen when a bash command is run.  See the below answer for information on that:&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/3060/suppress-output-from-a-vim-autocomand/3062#3062&quot;&gt;Suppress output from a vim autocomand&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-07-11T12:03:08.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3918" PostTypeId="2" ParentId="3915" CreationDate="2015-07-11T12:07:32.757" Score="4" Body="&lt;p&gt;Most of the &quot;single key&quot; shortcuts are used for the more important and useful &lt;strong&gt;editing&lt;/strong&gt; operations. Pagers don't have this problem, since they are by definition viewers, so they have all single keys available for buffer presentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, in read-only Vim buffers (e.g. when reading a help topic), it may make sense to locally re-assign some of keys. If you place the following lines in your &lt;code&gt;.vimrc&lt;/code&gt;, you will remap &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;u&lt;/code&gt; and &lt;code&gt;q&lt;/code&gt; in read-only buffers to scroll down a page, scroll up a page or quit, respectively:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc&#xA;    autocmd!&#xA;    autocmd BufEnter * call s:check_readonly()&#xA;augroup END&#xA;&#xA;function! s:check_readonly()&#xA;    if &amp;amp;readonly&#xA;        nnoremap &amp;lt;buffer&amp;gt; d &amp;lt;PageDown&amp;gt;&#xA;        nnoremap &amp;lt;buffer&amp;gt; u &amp;lt;PageUp&amp;gt;&#xA;        nnoremap &amp;lt;buffer&amp;gt; q :q&amp;lt;cr&amp;gt;&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reference: &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; and vim's help system.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-07-11T12:14:07.613" LastActivityDate="2015-07-11T12:14:07.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3919" PostTypeId="2" ParentId="3915" CreationDate="2015-07-11T12:22:50.677" Score="4" Body="&lt;p&gt;If you are not a member of the clan of arrow keys haters, and if your distribution provider didn't screw up your &lt;code&gt;termcap&lt;/code&gt; / &lt;code&gt;terminfo&lt;/code&gt; database, the &lt;kbd&gt;PgUp&lt;/kbd&gt; and &lt;kbd&gt;PgDown&lt;/kbd&gt; keys should work just fine.  And so would &lt;kbd&gt;Home&lt;/kbd&gt; and &lt;kbd&gt;End&lt;/kbd&gt;, &lt;kbd&gt;Insert&lt;/kbd&gt; and &lt;kbd&gt;Delete&lt;/kbd&gt;, and even the arrow keys, both in insert, normal, select, visual, and Ex modes (and whatever else Vim has in store that I can't remember just now).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, if you &lt;em&gt;are&lt;/em&gt; a member of said clan, you'll have to stop listening to the filthy arrow keys propaganda and just get used to the One True Way of &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;d&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;f&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-07-11T12:22:50.677" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3920" PostTypeId="1" AcceptedAnswerId="3923" CreationDate="2015-07-11T13:11:38.380" Score="14" ViewCount="2590" Body="&lt;p&gt;I am trying to create a small plugin to learn vimscript, my goal is to create some functions processing a selected text and replacing it with the result. The script contains the following items:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Two functions processing text:&lt;/strong&gt; they take a string as parameter an return the string which should be used to replace the original text. For now I have only two but there might by a lot more in a few time.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;A function getting the selected text:&lt;/strong&gt; which simply yank the last selection and return it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;A wrapper function:&lt;/strong&gt; which call a processing function, get its result and replace the old selection with this result.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For now my wrapper function looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Wrapper()&#xA;    &quot; Get the string to insert&#xA;    let @x = Type1ProcessString(GetSelectedText())&#xA;&#xA;    &quot; remove the old selection&#xA;    normal gvd&#xA;&#xA;    &quot; insert the new string&#xA;    normal &quot;xp&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I have to create a second wrapper replacing the line 3 with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @x = Type2ProcessString(GetSelectedText())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to give to my wrapper function a parameter containing the Process function to execute and use a generic call in line 3. For now I have tried using &lt;code&gt;call&lt;/code&gt; different ways like, for example, this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @x = call('a:functionToExecute', GetSelectedText()) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I haven't been really succesful and &lt;code&gt;:h call&lt;/code&gt; hasn't been really helpful on the delegate topic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To sum it up here are my questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I make only one wrapper function for all the processing ones?&lt;/li&gt;&#xA;&lt;li&gt;Is there something which works as a delegate in vimscript?&lt;/li&gt;&#xA;&lt;li&gt;If delegates doesn't exist what would be a &quot;good&quot; way to do what I want?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="205" LastEditDate="2015-07-11T19:26:24.363" LastActivityDate="2020-05-08T10:56:12.443" Title="Is it possible to use a delegate or to pass a function as argument in Vimscript?" Tags="|vimscript|plugin-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3921" PostTypeId="2" ParentId="3920" CreationDate="2015-07-11T13:20:23.087" Score="1" Body="&lt;p&gt;Build the command in a string and use &lt;code&gt;:exe&lt;/code&gt; to run it.  See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#:execute&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help execute&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, &lt;code&gt;execute&lt;/code&gt; is used to make the call to the function and put the result in the register, the different elements of the command must be concatenated with the &lt;code&gt;.&lt;/code&gt; operator as a regular string. The line 3 should then become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;let @x = &quot; . a:functionToExecute . &quot;(GetSelectedText())&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="1841" LastEditDate="2015-07-11T16:37:58.270" LastActivityDate="2015-07-11T16:37:58.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3922" PostTypeId="2" ParentId="3831" CreationDate="2015-07-11T18:25:11.383" Score="3" Body="&lt;pre&gt;&lt;code&gt;:e smsc911x.c&#xA;:new&#xA;:read !grep -o &quot;struct [^ ;,)]\+&quot; # | awk '{print $2}' | sort -u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explaining:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;grep -o&lt;/code&gt;: returns only the match chars (useful for multiple match on one line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^ ;,)]&lt;/code&gt;: remove characters non part of struct name&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;#&lt;/code&gt;: use alternate file (smsc911x.c in this case)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See this gets even more results than your program -once removed that numbered order that I don't know where it comes from-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diff --git 1/your_result 2/my_result&#xA;index 0bee24a..90d7ce4 100644&#xA;--- 1/your_result&#xA;+++ 2/my_result&#xA;@@ -1,9 +1,13 @@&#xA; clk&#xA;+device&#xA; device_node&#xA; dev_pm_ops&#xA;+ethtool_cmd&#xA; ethtool_drvinfo&#xA; ethtool_eeprom&#xA; ethtool_ops&#xA;+ethtool_regs&#xA;+ifreq&#xA; mii_bus&#xA; napi_struct&#xA; netdev_hw_addr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Save this to a mapping or function if you feel you will use it from time to time &lt;/p&gt;&#xA;" OwnerUserId="2779" LastActivityDate="2015-07-11T18:25:11.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3923" PostTypeId="2" ParentId="3920" CreationDate="2015-07-11T18:29:01.707" Score="19" Body="&lt;p&gt;To answer your question: the prototype of &lt;code&gt;call()&lt;/code&gt; in the manual is &lt;code&gt;call({func}, {arglist} [, {dict}])&lt;/code&gt;; the &lt;code&gt;{arglist}&lt;/code&gt; argument needs to be literally a List object, not a list of arguments.  That is, you have to write it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @x = call(a:functionToExecute, [GetSelectedText()])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes &lt;code&gt;a:functionToExecute&lt;/code&gt; is either a Funcref (see &lt;code&gt;:help Funcref&lt;/code&gt;), or the name of a function (i.e. a string, such as &lt;code&gt;'Type1ProcessString'&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, that's a powerful feature that gives Vim a sort of LISP-like quality,  but you'd probably seldom use it as above.  If &lt;code&gt;a:functionToExecute&lt;/code&gt; is a string, the name of a function, then you can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Wrapper(functionToExecute)&#xA;    &quot; ...&#xA;    let s:processing = function(a:functionToExecute)&#xA;    let @x = s:processing(GetSelectedText())&#xA;    &quot; ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you'd call the wrapper with the name of the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call Wrapper('Type1ProcessString')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If on the other hand &lt;code&gt;a:functionToExecute&lt;/code&gt; is a Funcref, you can call it directly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Wrapper(functionToExecute)&#xA;    &quot; ...&#xA;    let @x = a:functionToExecute(GetSelectedText())&#xA;    &quot; ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but you need to call the wrapper like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call Wrapper(function('Type1ProcessString'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can check for existence of functions with &lt;code&gt;exists('*name')&lt;/code&gt;.  This makes possible the following little trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:width = function(exists('*strwidth') ? 'strwidth' : 'strlen')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i.e. a function that uses the built-in &lt;code&gt;strwidth()&lt;/code&gt; if Vim is new enough to have it, and falls back to &lt;code&gt;strlen()&lt;/code&gt; otherwise (I'm not arguing that such a fallback makes sense; I'm just saying it can be done). :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With dictionary functions (see &lt;code&gt;:help Dictionary-function&lt;/code&gt;) you can define something resembling classes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:MyClass = {}&#xA;&#xA;function! g:MyClass.New(...)&#xA;    let newObj = copy(self)&#xA;&#xA;    if a:0 &amp;amp;&amp;amp; type(a:1) == type({})&#xA;        let newObj._attributes = deepcopy(a:1)&#xA;    endif&#xA;    if exists('*MyClassProcess')&#xA;        let newObj._process = function('MyClassProcess')&#xA;    else&#xA;        let newObj._process = function('s:_process_default')&#xA;    endif&#xA;&#xA;    return newObj&#xA;endfunction&#xA;&#xA;function! g:MyClass.getFoo() dict&#xA;    return get(get(self, '_attributes', {}), 'foo')&#xA;endfunction&#xA;&#xA;function! g:MyClass.setFoo(val) dict&#xA;    if !has_key(self, '_attributes')&#xA;        let self._attributes = {}&#xA;    endif&#xA;    let self._attributes['foo'] = a:val&#xA;endfunction&#xA;&#xA;function! g:MyClass.process() dict&#xA;    call self._process()&#xA;endfunction&#xA;&#xA;function! s:_process_default()&#xA;    echomsg 'nothing to see here, define MyClassProcess() to make me interesting'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you'd instantiate objects like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let little_object = g:MyClass.New({'foo': 'bar'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And call its methods:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call little_object.setFoo('baz')&#xA;echomsg little_object.getFoo()&#xA;call little_object.process()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also have class attributes and methods:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:MyClass.__meaning_of_life = 42&#xA;&#xA;function g:MyClass.GetMeaningOfLife()&#xA;    return get(g:MyClass, '__meaning_of_life')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(notice no need for &lt;code&gt;dict&lt;/code&gt; here).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Subclassing is something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:MySubclass = copy(g:MyClass)&#xA;call extend(g:MySubclass, subclass_attributes)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The subtle point here is the use of &lt;code&gt;copy()&lt;/code&gt; instead of &lt;code&gt;deepcopy()&lt;/code&gt;.  The reason for this is to be able to access the attributes of the parent class by reference.  This can be achieved, but it's highly fragile and getting it right is far from trivial.  Another potential problem is that this kind of subclass conflates &lt;code&gt;is-a&lt;/code&gt; with &lt;code&gt;has-a&lt;/code&gt;.  For this reasons class attributes are usually not really worth the pain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, this should be enough to give you some food for thought.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Back to your initial code snippet, there are two details with it that could be improved:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You don't need &lt;code&gt;normal gvd&lt;/code&gt; to remove the old selection, &lt;code&gt;normal &quot;xp&lt;/code&gt; will replace it even if you don't kill it first&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;call setreg('x', [lines], type)&lt;/code&gt; instead of &lt;code&gt;let @x = [lines]&lt;/code&gt;.  This explicitly sets the type of the register &lt;code&gt;x&lt;/code&gt;.  Otherwise you're relying on &lt;code&gt;x&lt;/code&gt; already having the correct type (i.e. characterwise, linewise, or blockwise).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="21251" LastEditDate="2020-05-08T10:56:12.443" LastActivityDate="2020-05-08T10:56:12.443" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="3924" PostTypeId="1" CreationDate="2015-07-12T02:48:14.073" Score="3" ViewCount="46" Body="&lt;p&gt;It happens that you want to save a file in a subdirectory that does&#xA;not exist yet, as in &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w ~/customers/one-met-today/note.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when the directory &lt;code&gt;one-met-today/&lt;/code&gt; does not exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the shell, that would be like running &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir &quot;$(dirname ~/customers/one-met-today/&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;before. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be great if multiple levels could be created, like in shell&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p &quot;$(dirname ~/customers/one-met-today/notes/offer.txt)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w ~/customers/one-met-today/notes/offer.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would prefer using an option for making &lt;code&gt;:w&lt;/code&gt; just support that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As alternatives:&lt;br&gt;&#xA;what would be the command to solve it with shell &lt;code&gt;mkdir&lt;/code&gt; without typing the file name twice?&lt;br&gt;&#xA;Or maybe use &lt;code&gt;autocmd&lt;/code&gt; &lt;code&gt;BufWritePre&lt;/code&gt; and &lt;code&gt;FileWritePre&lt;/code&gt; before &lt;code&gt;:w&lt;/code&gt;? But that feels a little unclean, because it modifies basic behaviour in an obscure way.&lt;/p&gt;&#xA;" OwnerUserId="925" LastEditorUserId="51" LastEditDate="2015-07-12T13:17:38.190" LastActivityDate="2015-07-12T13:17:38.190" Title="How to create intermediate directories with :w automatically?" Tags="|save|autocmd|" AnswerCount="0" CommentCount="1" ClosedDate="2015-07-12T13:16:31.713" ContentLicense="CC BY-SA 3.0" />
  <row Id="3926" PostTypeId="1" AcceptedAnswerId="3927" CreationDate="2015-07-12T16:14:19.873" Score="6" ViewCount="4516" Body="&lt;p&gt;I have a &lt;code&gt;LaTeX&lt;/code&gt; file with a bunch of commands of the form &lt;code&gt;\label{&amp;lt;word&amp;gt;}&lt;/code&gt; where the &lt;code&gt;&amp;lt;word&amp;gt;&lt;/code&gt; represents a string that contains special characters, namely &lt;code&gt;á é í ó ú ý ð þ æ ö&lt;/code&gt;. I'm looking for a quick way to change the special characters into a corresponding ASCII character(s): &lt;code&gt;a e i o u y dh th ae oe&lt;/code&gt;. To give an example, I want to change &lt;code&gt;\label{orðabók}&lt;/code&gt; to &lt;code&gt;\label{ordhabok}&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I wanted just to change, for example, all þ's to th, I would visually select the word inside the &lt;code&gt;\label{}&lt;/code&gt;, exit to normal mode and then use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\%Vþ/th/ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I could give two such commands at the same time using &lt;code&gt;|&lt;/code&gt;, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\%Vþ/th/ge|s/\%Vð/dh/ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess I could just string together all ten commands, but I was hoping for a more elegant way. In particular, I would like to not have to write the &lt;code&gt;\%V&lt;/code&gt; and the &lt;code&gt;g&lt;/code&gt; every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A follow-up question: I have to do this for every &lt;code&gt;\label{}&lt;/code&gt; command in a very long file, and I plan to make a macro or commmand that automates it. My plan was to make a macro that searches for the next occurance of &lt;code&gt;\label{&lt;/code&gt;, visually selects the word inside the &lt;code&gt;{}&lt;/code&gt;, and performs the substitutions I described above. Then I would just count the &lt;code&gt;\label&lt;/code&gt; commands and run the macro that many times. If I get help with the first question, then I know how to implement this. But is there another method that would be faster for a very long file?&lt;/p&gt;&#xA;" OwnerUserId="2804" LastEditorUserId="2804" LastEditDate="2015-07-12T17:00:08.387" LastActivityDate="2015-07-13T17:04:12.137" Title="Multiple search-replace operations on a selection" Tags="|substitute|macro|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3927" PostTypeId="2" ParentId="3926" CreationDate="2015-07-12T17:01:42.320" Score="5" Body="&lt;p&gt;How about ... a substitution inside another one, and all thrown in a loop? E.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:replaceSpecialChars(name)&#xA;    let from = ['á','é','í','ó','ú','ý','ð','þ','æ','ö']&#xA;    let to = ['a','e','i','o','u','y','dh','th','ae','oe']&#xA;&#xA;    let i = 0&#xA;    while i &amp;lt; len(from)&#xA;        exe '%s/' . a:name . '{\zs.\{-}\ze}/\=substitute(submatch(0),from[i], to[i], &quot;g&quot;)/g'&#xA;        let i += 1&#xA;    endwhile&#xA;endfunction&#xA;&#xA;command! -nargs=1 ReplaceSpecialChars call s:replaceSpecialChars(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Copy the above code in a vim file, and &lt;code&gt;source&lt;/code&gt; the file (e.g. &lt;code&gt;:w&lt;/code&gt; and &lt;code&gt;so %&lt;/code&gt; if it's the current file). Then you can run it when you are in your LaTeX buffer like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ReplaceSpecialChars label&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just make sure to keep those lists (from, to) matched (equal nr. of elements).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This function globally replaces, in turn, any number of occurences of one of the characters from the &lt;code&gt;from[]&lt;/code&gt; list to their &lt;code&gt;to[]&lt;/code&gt; correspondent, but only for text found inside the &lt;code&gt;&amp;lt;name&amp;gt;{ }&lt;/code&gt; construct.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-07-13T07:56:06.740" LastActivityDate="2015-07-13T07:56:06.740" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3928" PostTypeId="2" ParentId="3926" CreationDate="2015-07-12T20:26:50.073" Score="5" Body="&lt;p&gt;How about that. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;define your substitution dictionary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let dict_subst = { &#xA;     \ 'á': 'a', &#xA;     \ 'é': 'e', &#xA;     \ 'í': 'i', &#xA;     \ 'ó': 'o', &#xA;     \ 'ú': 'u', &#xA;     \ 'ý': 'y', &#xA;     \ 'ð': 'dh', &#xA;     \ 'þ': 'th', &#xA;     \ 'æ': 'ae', &#xA;     \ 'ö': 'oe'} &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then call your substitution function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;:s/&quot;.join(keys(dict_subst),'\|').'/\=dict_subst[submatch(0)]/g'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="71" LastEditorUserId="205" LastEditDate="2015-07-12T20:31:33.420" LastActivityDate="2015-07-12T20:31:33.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3929" PostTypeId="1" AcceptedAnswerId="3932" CreationDate="2015-07-12T23:59:32.600" Score="4" ViewCount="295" Body="&lt;p&gt;Sometimes, I need to delete until a character up or down the same column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider a file with the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc&#xA;def&#xA;hij&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When cursor is on &lt;code&gt;b&lt;/code&gt;, doing a column-wise &lt;code&gt;dfi&lt;/code&gt; should remove characters &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;e&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt;. That means only the 1-character-width column of characters should be deleted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do column-wise find and till?&lt;/p&gt;&#xA;" OwnerUserId="2295" LastEditorUserId="2295" LastEditDate="2015-07-13T01:14:53.620" LastActivityDate="2015-07-14T20:02:03.583" Title="column-wise f, F, t, T" Tags="|cursor-motions|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3930" PostTypeId="1" AcceptedAnswerId="3933" CreationDate="2015-07-13T01:03:30.397" Score="-1" ViewCount="5677" Body="&lt;p&gt;I recently start using Vundle as plugin manager.&#xA;It nicely installed all my plugins, except NerdTree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when trying to install &lt;code&gt;Plugin 'scroolosse/nerdTree'&lt;/code&gt; &#xA;vundle tries to connect to github, thru https, and asks me for a username and a password. I have tried providing mine but that didn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the other plugins on github, it doesn't ask for such a thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the problem ? How to fix this ?&lt;/p&gt;&#xA;" OwnerUserId="1682" LastActivityDate="2015-07-13T03:14:17.140" Title="cannot install NerdTree pluging with Vundle" Tags="|plugin-nerdtree|plugin-vundle|" AnswerCount="1" CommentCount="0" ClosedDate="2015-07-13T07:36:21.823" ContentLicense="CC BY-SA 3.0" />
  <row Id="3931" PostTypeId="2" ParentId="3604" CreationDate="2015-07-13T02:06:13.490" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;with the block cursor over the semicolon, what is the easiest way to&#xA;  delete that and end up with the cursor where the first e is?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To answer this, precisely, &lt;code&gt;dvF.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;d&lt;/code&gt; &lt;strong&gt;d&lt;/strong&gt;elete &lt;sub&gt;&lt;em&gt;(:help :delete)&lt;/em&gt;&lt;/sub&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;v&lt;/code&gt; inclusively, since &lt;code&gt;F&lt;/code&gt; is an exclusive character motion &lt;sub&gt;&lt;em&gt;(:help o_v)&lt;/em&gt;&lt;/sub&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;F&lt;/code&gt; &lt;strong&gt;f&lt;/strong&gt;ind to the left &lt;sub&gt;&lt;em&gt;(:help F)&lt;/em&gt;&lt;/sub&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;.&lt;/code&gt; literal dot character&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Summing up, this means &lt;em&gt;delete inclusively to the left up to the dot&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have multiple dots, such as, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;e.e.printStackTrace();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can add a &lt;code&gt;count&lt;/code&gt; to &lt;code&gt;F&lt;/code&gt;, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dv2F.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to go into insert mode immediately after deletion, change the operator &lt;sub&gt;&lt;em&gt;(:help operator)&lt;/em&gt;&lt;/sub&gt; from &lt;code&gt;d&lt;/code&gt; to &lt;code&gt;c&lt;/code&gt; (&lt;strong&gt;c&lt;/strong&gt;hange):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cvF.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2295" LastEditorUserId="2295" LastEditDate="2015-07-13T02:14:28.953" LastActivityDate="2015-07-13T02:14:28.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3932" PostTypeId="2" ParentId="3929" CreationDate="2015-07-13T02:56:33.327" Score="5" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://github.com/machakann/vim-columnmove&quot;&gt;&lt;code&gt;vim-columnmove&lt;/code&gt;&lt;/a&gt; plugin and visual-mode block-wise selection to do this. The plugin imitates various groups of motions, and in this case:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h1&gt;columnmove-f&lt;/h1&gt;&#xA;  &#xA;  &lt;hr&gt;&#xA;  &#xA;  &lt;p&gt;columnmove-f and its variants are the commands for bringing cursor to the position assigned by a character in the same column.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This group has six keymappings, that is, &lt;code&gt;columnmove-f&lt;/code&gt;,&#xA;  &lt;code&gt;columnmove-t&lt;/code&gt;, &lt;code&gt;columnmove-F&lt;/code&gt;, &lt;code&gt;columnmove-T&lt;/code&gt;, &lt;code&gt;columnmove-;&lt;/code&gt;,&#xA;  &lt;code&gt;columnmove-,&lt;/code&gt;. Each of them are the imitations of &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;T&lt;/code&gt;,&#xA;  &lt;code&gt;;&lt;/code&gt;, &lt;code&gt;,&lt;/code&gt; commands, but work in vertical direction.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The motions are mapped to &lt;code&gt;&amp;lt;M-f/F/t/F&amp;gt;&lt;/code&gt; by default, but since those combinations were interpreted as something else in my case, I used &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;f &amp;lt;Plug&amp;gt;(columnmove-f)&#xA;map &amp;lt;leader&amp;gt;F &amp;lt;Plug&amp;gt;(columnmove-F)&#xA;map &amp;lt;leader&amp;gt;t &amp;lt;Plug&amp;gt;(columnmove-t)&#xA;map &amp;lt;leader&amp;gt;T &amp;lt;Plug&amp;gt;(columnmove-T)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, by pressing &lt;code&gt;d&amp;lt;C-v&amp;gt;\ti&lt;/code&gt;, I could delete the characters &lt;code&gt;b&lt;/code&gt;, and &lt;code&gt;e&lt;/code&gt;. Without block visual mode, it deletes the first and second lines.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-07-13T03:38:50.847" LastActivityDate="2015-07-13T03:38:50.847" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3933" PostTypeId="2" ParentId="3930" CreationDate="2015-07-13T03:14:17.140" Score="6" Body="&lt;p&gt;Spelling is the issue. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'scroolosse/nerdTree'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'scrooloose/nerdTree'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The double &lt;code&gt;s&lt;/code&gt; is the clincher. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot;&gt;GitHub Scrooloose NerdTree repo&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2303" LastActivityDate="2015-07-13T03:14:17.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3934" PostTypeId="1" AcceptedAnswerId="3938" CreationDate="2015-07-13T04:42:53.067" Score="18" ViewCount="1153" Body="&lt;p&gt;I have been using Vim since 4 years. I am looking forward to contribute to the open source project vim. I would like a few tips on where to start and whom to contact to contribute to Vim. Help from people who have already contributed to Vim would help a lot :). Thanks in advance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS - I am not even sure whether i can post this here but finally decided to post it here as this would be the place with the most Vim enthusiasts to talk with.&lt;/p&gt;&#xA;" OwnerUserId="2339" LastEditorUserId="205" LastEditDate="2015-07-13T17:59:23.563" LastActivityDate="2016-07-30T10:01:35.107" Title="How to Contribute to Vim?" Tags="|vim-development|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="3935" PostTypeId="1" AcceptedAnswerId="3953" CreationDate="2015-07-13T08:57:21.310" Score="2" ViewCount="5224" Body="&lt;p&gt;I have configured the following properly in my .vimrc in the root folder of a project to keep syntastic settings Project specific. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But still Syntastic throws errors saying &quot;No Such File or Directory&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Directory Structure&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--Project    &#xA;    |---include&#xA;         |---foo.h    &#xA;    |---src&#xA;         |---foo.c&#xA;    |---.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;.vimrc Contents&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_c_include_dirs = ['/home/pydi.k/Project/include/']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;foo.c shows a &quot;foo.h no such file or directory&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bottom Line - I want to configure syntastic so that it looks for custom made header files at locations I point to.&lt;/p&gt;&#xA;" OwnerUserId="2339" LastEditorUserId="2339" LastEditDate="2015-07-13T11:27:04.040" LastActivityDate="2015-07-15T16:28:15.230" Title="Syntastic doesn't find C header files despite Configuring" Tags="|vimrc|plugin-syntastic|" AnswerCount="1" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="3936" PostTypeId="2" ParentId="3604" CreationDate="2015-07-13T10:05:27.737" Score="0" Body="&lt;p&gt;There are many ways to do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that text is the only content of the line you could do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ddO&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cc&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;S&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or probbaly other commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that text is part of a longer line, you could do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Fe;D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or maybe:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;T D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-07-13T10:05:27.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3938" PostTypeId="2" ParentId="3934" CreationDate="2015-07-13T16:58:39.433" Score="18" Body="&lt;h2&gt;It's a bit old school&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/users/1577/lcd047&quot;&gt;lcd047&lt;/a&gt; pointed out, there is the &lt;a href=&quot;https://groups.google.com/forum/#!forum/vim_dev&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim_dev Google Group&lt;/a&gt; where you can submit patches. At present, Vim is under version control in a Mercurial repository. You can submit patches by opening a new topic in that group and attaching your patch file (a text file with the diff output). The Vim source is in the process of moving to GitHub, but I don't think it's quite there yet.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The nature of contributing&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;While many open-source projects, including Vim, have a to-do list, it's not likely that you will be assigned anything just by volunteering your services. Most open-source contributions are impromptu: you identify a bug fix or improvement, implement it, and submit it for review, then the maintainer can choose to merge it in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a very simple contribution in the Vim source. I noticed that the &lt;code&gt;i(&lt;/code&gt; text object didn't behave nicely when the contents of the parentheses were on their own lines. In contrast, the analogous &lt;code&gt;i{&lt;/code&gt; text object behaved appropriately in similar situations. I submitted &lt;a href=&quot;https://groups.google.com/forum/#!searchin/vim_dev/patch$207.4.328/vim_dev/fAPwP1bGjsY/4DFgsaR96y0J&quot; rel=&quot;nofollow noreferrer&quot;&gt;my patch&lt;/a&gt; and it was actually merged in swiftly. Of course, this was a &lt;em&gt;very small&lt;/em&gt; change; more significant patches tend to be subject to longer review.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;My advice&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Don't enter into the game with the plan to contribute to Vim. Good ideas don't normally come from trying to think of good ideas. They come when you're trying to do something else. Keep using Vim and an idea may present itself. Then put in the effort to implement it and submit a patch.&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2015-07-13T17:51:16.547" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3939" PostTypeId="2" ParentId="3926" CreationDate="2015-07-13T17:04:12.137" Score="7" Body="&lt;p&gt;Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-abolish&quot; rel=&quot;noreferrer&quot;&gt;abolish.vim&lt;/a&gt; plugin provides a &lt;code&gt;:Subvert&lt;/code&gt; (&lt;code&gt;:S&lt;/code&gt; for short) command that lets you substitute a list of things for another list of things. For example, the following command will change &lt;code&gt;a&lt;/code&gt; to &lt;code&gt;x&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt; to &lt;code&gt;y&lt;/code&gt;, and &lt;code&gt;c&lt;/code&gt; to &lt;code&gt;z&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:S/{a,b,c}/{x,y,z}/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The plugin also provides a lot of other cool functionality that can't be easily articulated; I recommend checking it out.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-07-13T17:04:12.137" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3941" PostTypeId="5" CreationDate="2015-07-13T18:00:14.150" Score="0" Body="" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-07-13T18:00:14.150" LastActivityDate="2015-07-13T18:00:14.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3942" PostTypeId="4" CreationDate="2015-07-13T18:00:14.150" Score="0" Body="Questions regarding development of Vim itself, via adding features, patching bugs, writing documentation, etc." OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-07-13T18:00:14.150" LastActivityDate="2015-07-13T18:00:14.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3943" PostTypeId="1" CreationDate="2015-07-14T00:40:13.883" Score="18" ViewCount="1111" Body="&lt;p&gt;My friend showed me a cool trick on Emacs some days ago where he could just open a file on a remote server and I instantly thought &quot;there should be a way to do that in vim too&quot; and it was true. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can just use &lt;code&gt;:e scp://user@server//filepath&lt;/code&gt; to do that, no problem ;). However, he could just type the server name and then get completion for file paths and names (with tab), something that I haven't been able to do. Does somebody know if this can be done in vim?&lt;/p&gt;&#xA;" OwnerUserId="2819" LastEditorUserId="1841" LastEditDate="2015-08-07T14:27:28.467" LastActivityDate="2016-07-17T11:10:36.953" Title="Filename Completion for Remote Files" Tags="|autocompletion|filesystem|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3944" PostTypeId="1" CreationDate="2015-07-14T01:58:28.487" Score="0" ViewCount="1000" Body="&lt;p&gt;Every time I launch vim I have this in clipboard:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_dirhistmax  =10&#xA;let g:netrw_dirhist_cnt =8&#xA;let g:netrw_dirhist_1=...&#xA;let g:netrw_dirhist_2=...&#xA;let g:netrw_dirhist_3=...&#xA;let g:netrw_dirhist_4=...&#xA;let g:netrw_dirhist_5=...&#xA;let g:netrw_dirhist_6=...&#xA;let g:netrw_dirhist_7=...&#xA;let g:netrw_dirhist_8=...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know, &lt;code&gt;vim -u NONE&lt;/code&gt;, remove plugins one by one... Just thought maybe somebody knows what's causing it.&lt;/p&gt;&#xA;" OwnerUserId="237" LastActivityDate="2015-11-20T22:22:28.793" Title="Vim is polluting clipboard with netrw_dirhist stuff" Tags="|os-clipboard|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3945" PostTypeId="1" AcceptedAnswerId="3946" CreationDate="2015-07-14T11:34:08.657" Score="8" ViewCount="895" Body="&lt;p&gt;I'm often using &lt;code&gt;grep&lt;/code&gt; to search for patterns and then opening the file with vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I've the following result in my shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;interactions/BlockInteraction.js:38:                    .concat(this.prompt.postRender({}, '', renderer))&#xA;Container.js:151:        postRender : function(data, altClassName, renderer){&#xA;Container.js:156:                    return typeof elt.postRender === 'function';&#xA;Container.js:159:                    return elt.postRender(data, '', renderer);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What would enhance my productivity would be to be able to open a file with vim using the &lt;code&gt;path:line&lt;/code&gt; pattern :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim interactions/BlockInteraction.js:38 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do achieve that ?&lt;/p&gt;&#xA;" OwnerUserId="176" LastActivityDate="2015-07-14T14:09:49.503" Title="Open a file at the given line using the colon notation" Tags="|filesystem|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3946" PostTypeId="2" ParentId="3945" CreationDate="2015-07-14T14:09:49.503" Score="10" Body="&lt;p&gt;You can use the relatively popular &lt;a href=&quot;https://github.com/bogado/file-line&quot;&gt;file-line&lt;/a&gt; plugin. Note that this plugin seems relatively unmaintained, and there exists several forks. I have a personal fork where I've made some minor updates and fixed a couple of small bugs, see &lt;a href=&quot;https://github.com/lervag/file-line&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-07-14T14:09:49.503" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3947" PostTypeId="1" CreationDate="2015-07-14T16:20:45.827" Score="4" ViewCount="2684" Body="&lt;p&gt;I wonder how folks navigate efficiently with in a nerdtree window, for example if I'm in a folder like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;├── m1.py&#xA;├── m1.pyc&#xA;├── m2.py&#xA;├── m2.py.bak&#xA;├── m2.pyc&#xA;├── main.py&#xA;├── matplotdemo.py&#xA;├── phonecount.py&#xA;├── haha&#xA;├── helloworld&#xA;│   ├── someothercode.py&#xA;│   └── source&#xA;│       └── somecode.py&#xA;├── images_stat_20150120.tsv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I'm going to &lt;code&gt;helloworld/source/somecode.py&lt;/code&gt;, I would have to &lt;code&gt;jjjj...jjjjojjoj&lt;/code&gt; to get there, which is extremely tiring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I can't even use the easymotion plugin inside nerdtree, so how can I have some efficiency when using nerdtree?&lt;/p&gt;&#xA;" OwnerUserId="2621" LastEditorUserId="2621" LastEditDate="2015-07-15T02:11:09.290" LastActivityDate="2019-04-19T07:34:37.007" Title="navigate within nerdtree" Tags="|cursor-motions|plugin-nerdtree|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3948" PostTypeId="2" ParentId="3947" CreationDate="2015-07-14T18:04:51.390" Score="6" Body="&lt;p&gt;I usually use a combination of &lt;code&gt;j&lt;/code&gt; and the &lt;code&gt;/&lt;/code&gt; search (with the &lt;code&gt;incsearch&lt;/code&gt; setting enabled) to jump to where I want to be.  In your example, I probably would have done something like &lt;code&gt;/hello&amp;lt;enter&amp;gt;&amp;lt;enter&amp;gt;/sou/&amp;lt;enter&amp;gt;&amp;lt;enter&amp;gt;j&amp;lt;enter&amp;gt;&lt;/code&gt;.  One thing I really like about this method is that I can search for any substring.  Some of my directories have multiple files with the same prefix, so it's nice being able to just type in the meat of the file name and jump straight to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It never occurred to me until I was typing that out just now how many times I have to hit &lt;code&gt;&amp;lt;enter&amp;gt;&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt;, but when I'm actually doing it, it doesn't seem so bothersome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use the same navigation movements as when navigating a normal document, so if you are in a directory with a lot of files you could use &lt;code&gt;ctrl-f&lt;/code&gt; and &lt;code&gt;ctrl-b&lt;/code&gt; to jump forward and backward a page and &lt;code&gt;gg&lt;/code&gt; and &lt;code&gt;G&lt;/code&gt; to jump to the top and bottom of the listing.&lt;/p&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2015-07-14T18:04:51.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3949" PostTypeId="2" ParentId="3947" CreationDate="2015-07-14T18:44:23.673" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;and I can't even use the easymotion plugin inside nerdtree, so how can I have some efficiency when using nerdtree?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You navigate that listing exactly like you navigate in any buffer: with &lt;code&gt;/?*#HLM&lt;/code&gt; and any other adequate motion. Beware plugin addiction.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't use mouse, that's not vim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Who said so?&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-07-14T18:44:23.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3950" PostTypeId="2" ParentId="3929" CreationDate="2015-07-14T20:02:03.583" Score="2" Body="&lt;p&gt;To quickly do this without the need for plugins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;/i&amp;lt;cr&amp;gt;x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; to enter column mode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/i&amp;lt;cr&amp;gt;&lt;/code&gt; to search for i&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;x&lt;/code&gt; to delete the visually selected block&lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastActivityDate="2015-07-14T20:02:03.583" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3951" PostTypeId="1" AcceptedAnswerId="3955" CreationDate="2015-07-14T20:26:07.270" Score="17" ViewCount="11685" Body="&lt;p&gt;Many times in vim I would like to delete a line completely, so I use dd. However, I then need to paste that line into some other position within a line, but this inserts a newline before pasting, therefore, making it very difficult for me to get the desired result.&#xA;For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while( pasteInHere )&#xA;{&#xA;    cin &amp;gt;&amp;gt; n; // Delete this line completely with dd&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I do this with the above code I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while( pasteInHere )&#xA;cin &amp;gt;&amp;gt; n; // Delete this line completely with dd&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is very far from the result I want...how can I suppress this newline behaviour, or use another method that does it very efficiently? I don't think d$ is good because I not  only have to go to beginning of line, but if I want to delete the empty line too I need to delete it in another register, I feel like there should be an easier way! Thanks.&lt;/p&gt;&#xA;" OwnerUserId="1305" LastActivityDate="2022-06-11T15:41:38.067" Title="Deleting In Vim and Then Pasting Without new Line" Tags="|cut-copy-paste|" AnswerCount="7" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3952" PostTypeId="2" ParentId="3951" CreationDate="2015-07-14T21:35:45.110" Score="3" Body="&lt;p&gt;You can achieve something that works quite well with an &lt;code&gt;imap&lt;/code&gt;. Add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-a&amp;gt; &amp;lt;c-r&amp;gt;1&amp;lt;esc&amp;gt;k$Jxi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will create a mapping for &lt;kbd&gt;CTRL-a&lt;/kbd&gt; that will paste the last deleted text (with &lt;code&gt;dd&lt;/code&gt; or similar). If you prefer, you may of course use a different key for the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h i_CTRL-R&#xA;:h quote1&#xA;:h J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-07-14T21:35:45.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3953" PostTypeId="2" ParentId="3935" CreationDate="2015-07-15T05:00:53.537" Score="1" Body="&lt;p&gt;The problem is &lt;strong&gt;not in Configuring Syntastic&lt;/strong&gt; but rather letting Vim &lt;strong&gt;load the &lt;code&gt;.vimrc&lt;/code&gt;&lt;/strong&gt; file in the  root directory of your project. The following will solve the problem and ensure that you &lt;strong&gt;load the &lt;code&gt;.vimrc&lt;/code&gt;&lt;/strong&gt; before Syntastic checks for errors.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;After loading vim, explicitly run the command &lt;code&gt;:so location/to/.vimrc&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Configuring your central &lt;code&gt;.vimrc&lt;/code&gt; to load the local &lt;code&gt;.vimrc&lt;/code&gt; file from wherever you are launching vim would be a headache as you should carefully always launch it from the root of the project. Instead add this line to the central &lt;code&gt;.vimrc&lt;/code&gt;: &lt;code&gt;so .vimrc&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the plugin &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3393&quot; rel=&quot;nofollow&quot;&gt;localrc&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2339" LastEditorUserId="1841" LastEditDate="2015-07-15T16:28:15.230" LastActivityDate="2015-07-15T16:28:15.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3954" PostTypeId="2" ParentId="3951" CreationDate="2015-07-15T06:15:52.357" Score="3" Body="&lt;p&gt;Not really simpler, but slightly more efficient, and you can also create normal-mode maps for both sequence:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;yanking: go to the line you want to move, then&#xA;&lt;kbd&gt;^&lt;/kbd&gt;&lt;kbd&gt;D&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;_&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;pasting: go to the word you want to replace, then&#xA;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-07-15T06:15:52.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3955" PostTypeId="2" ParentId="3951" CreationDate="2015-07-15T15:53:42.280" Score="16" Body="&lt;p&gt;You can go anywhere in the line above the line you want to delete, then press &lt;code&gt;JD&lt;/code&gt; and paste it with &lt;code&gt;p&lt;/code&gt; at the desired point. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;J&lt;/code&gt; joins the two lines and moves you at the start of the text you wanted to delete. This deletes a new-line character and the indentation of the line you want to move. &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;D&lt;/code&gt; deletes from the current cursor position to the end of the line but preserves the new-line character. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Hint:&lt;/strong&gt; You can use &lt;code&gt;:pu&lt;/code&gt; if you deleted with &lt;code&gt;D&lt;/code&gt; or yanked with &lt;code&gt;y$&lt;/code&gt; and you want to paste &lt;em&gt;with&lt;/em&gt; a new line. &lt;/p&gt;&#xA;" OwnerUserId="2843" LastActivityDate="2015-07-15T15:53:42.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3956" PostTypeId="1" AcceptedAnswerId="3957" CreationDate="2015-07-15T19:59:39.870" Score="0" ViewCount="252" Body="&lt;p&gt;I'm trying to run a function that is in my vimrc to insert dependencies in a php class.&lt;br&gt;&#xA;The script must enter a parameter type hinting in the construct of my class and assign the result of this parameter to an attribute of the local class.&lt;br&gt;&#xA;I'm using Linux and I found in some posts that these types of characters that are in the function are not used to Linux. But for Mac.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Script php before run the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;use Something\AnotherClass;    &#xA;&#xA;class MyClass {&#xA;&#xA;    public function __construct(AnotherClass $anotherClass)&#xA;    {&#xA;        $this-&amp;gt;anotherClass = $anotherClass;&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Script php after run the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;&#xA;use Something\AnotherClass;    &#xA;use Something\OtherClass;&#xA;&#xA;class MyClass {&#xA;&#xA;    public function __construct(AnotherClass $anotherClass, OtherClass $otherClass)&#xA;    {&#xA;        $this-&amp;gt;anotherClass = $anotherClass;&#xA;        $this-&amp;gt;otherClass = $otherClass;&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The vimrc function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddDependency()&#xA;    let dependency = input('Var Name: ')&#xA;    let namespace = input('Class Path: ')&#xA;&#xA;    let segments = split(namespace, '\')&#xA;    let typehint = segments[-1]&#xA;&#xA;    exec 'normal gg/construct^M:H^Mf)i, ' . typehint . ' $' . dependency . '^[/}^&amp;gt;O$this-&amp;gt;^[a' . dependency . ' = $' . dependency . ';^[?{^MkOprotected $' . dependency . ';^M^[?{^MOuse ' . namespace . ';^M^['&#xA;&#xA;    &quot; Remove opening comma if there is only one dependency&#xA;    exec 'normal :%s/(, /(/g'&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I try to run this function I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function AddDependency:&#xA;line   10:&#xA;E115: Missing quote: 'normal :%s/(, /(/g&#xA;E15: Invalid expression: 'normal :%s/(, /(/g&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is exactly this special chars?&lt;br&gt;&#xA;How can I fixed this and is there some reference to learn about this chars?   &lt;/p&gt;&#xA;" OwnerUserId="2848" LastEditorUserId="2848" LastEditDate="2015-07-15T21:35:40.340" LastActivityDate="2015-07-16T07:29:38.180" Title="Error characters in vimrc function" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3957" PostTypeId="2" ParentId="3956" CreationDate="2015-07-15T21:08:36.500" Score="1" Body="&lt;p&gt;I think the error could be resolved if you change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    exec 'normal :%s/(, /(/g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    %s/\m(, /(/eg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reasoning is that there is no need to use &lt;code&gt;normal&lt;/code&gt; to execute an ex command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclaimer: I have not studied your function in detail, and as such I do not see entirely how it works or what it does.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2015-07-16T07:29:38.180" LastActivityDate="2015-07-16T07:29:38.180" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3958" PostTypeId="2" ParentId="3760" CreationDate="2015-07-15T22:45:55.733" Score="1" Body="&lt;p&gt;First &lt;code&gt;colorscheme solarized&lt;/code&gt;  must be after &lt;code&gt;let g:solarized_termcolors=256&lt;/code&gt;, and that may work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not. You should set &lt;strong&gt;xterm-256&lt;/strong&gt; color in preferences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bellow you can see the settings that works for me nicely. I don't use a keymap for toggle background, instead just use &lt;code&gt;:set bg=light&lt;/code&gt; or &lt;code&gt;:set bg=dark&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Pathogen plugins &#xA;execute pathogen#infect()&#xA;&#xA;filetype on&#xA;filetype indent on&#xA;filetype plugin on&#xA;&#xA;&quot; Enable syntax colors&#xA;syntax enable&#xA;&#xA;&quot; Background color from color  scheme&#xA;set background=dark&#xA;&quot; set background=light&#xA;&#xA;&quot; Solarized scheme color preferences&#xA;let g:solarized_termcolors=256&#xA;let g:solarized_termtrans = 1&#xA;let g:solarized_degrade = 0&#xA;let g:solarized_bold = 1&#xA;let g:solarized_underline = 1&#xA;let g:solarized_italic = 1&#xA;let g:solarized_contrast = &quot;normal&quot;&#xA;let g:solarized_visibility= &quot;normal&quot;&#xA;colorscheme solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2852" LastActivityDate="2015-07-15T22:45:55.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3959" PostTypeId="1" AcceptedAnswerId="3961" CreationDate="2015-07-16T00:00:48.023" Score="2" ViewCount="199" Body="&lt;p&gt;I have a custom function and mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-m&amp;gt; :MyMake&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works as intendeded, the correct function is called etc. But it creates another mapping, running &lt;code&gt;:nmap&lt;/code&gt; shows that &lt;code&gt;CR&lt;/code&gt; is now mapped to &lt;code&gt;:MyMake &amp;lt;CR&amp;gt;&lt;/code&gt; as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on why this is?&lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="1841" LastEditDate="2015-07-16T13:23:42.243" LastActivityDate="2015-07-16T13:23:42.243" Title="Mapping &lt;C-m&gt; also creates a mapping for &lt;CR&gt;" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3960" PostTypeId="2" ParentId="3951" CreationDate="2015-07-16T00:14:18.880" Score="2" Body="&lt;p&gt;This comes up for me a bit too, never thought to optimize it before but this mapping works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap dil ^d$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;dil&lt;/code&gt; is &quot;delete in line&quot;, similar to &lt;code&gt;diw&lt;/code&gt;, &lt;code&gt;di&quot;&lt;/code&gt;, etc. &lt;/p&gt;&#xA;" OwnerUserId="584" LastEditorUserId="205" LastEditDate="2015-07-21T07:08:54.683" LastActivityDate="2015-07-21T07:08:54.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3961" PostTypeId="2" ParentId="3959" CreationDate="2015-07-16T00:55:36.400" Score="3" Body="&lt;p&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; stands for carriage return, and depending on your terminal settings, &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;M&lt;/kbd&gt; gets you a carriage return. Consider using another key combination. See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/3225/disable-esc-but-keep-c&quot;&gt;Disable &amp;lt;Esc&amp;gt; but keep &amp;lt;C-[&amp;gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/3907/how-to-remap-c-on-linux&quot;&gt;How to remap &amp;lt;C-[&amp;gt; on linux&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-07-16T00:55:36.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3962" PostTypeId="1" AcceptedAnswerId="3963" CreationDate="2015-07-16T01:58:16.603" Score="2" ViewCount="1031" Body="&lt;p&gt;Is there a way to set the text color of an ad-hoc selection in vimscript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; change the text color of the first three rows to red&#xA;:1,3 call changeTextColor('red')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2312" LastEditorUserId="205" LastEditDate="2015-07-16T03:43:25.810" LastActivityDate="2015-07-16T04:14:51.190" Title="change color of section dynamically in vimscript" Tags="|vimscript|highlight|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3963" PostTypeId="2" ParentId="3962" CreationDate="2015-07-16T04:08:10.703" Score="5" Body="&lt;p&gt;As the link posted by @muru points out, it can be done, the following will highlight lines 3-5:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight FleetingFlashyFiretrucks ctermfg=red&#xA;match FleetingFlashyFiretrucks /\%&amp;gt;2l\%&amp;lt;6l/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the highlighting defined this way is tied to the line numbers, not to the contents of the file.  If you delete or insert lines before the highlighted region the highlight will stay at lines 3-5, while the contents will move up or down.  For this reason it's almost always better to find a pattern in the text to highlight, rather than a line range.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="1577" LastEditDate="2015-07-16T04:14:51.190" LastActivityDate="2015-07-16T04:14:51.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3964" PostTypeId="1" AcceptedAnswerId="7254" CreationDate="2015-07-16T05:00:17.450" Score="3" ViewCount="2657" Body="&lt;p&gt;I installed vim-airline about 2 weeks ago. At that time I read a section in the &lt;a href=&quot;https://github.com/bling/vim-airline/wiki/FAQ&quot; rel=&quot;nofollow&quot;&gt;FAQs&lt;/a&gt; about a delay occurring after exiting insert mode and into normal mode. I noticed the delay and applied the fix suggested by adding &lt;code&gt;timeoutlen=50&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt;. After setting that vim-commentary started to not work. I would issue the command &lt;code&gt;gcc&lt;/code&gt; and vim would do nothing until I hit hjkl or an arrow key, at which vim would delete the line and enter insert mode. I also noticed that my maps that used &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; wouldn't work. Vim would skip a few characters and then enter visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I narrowed the problem down to the &lt;code&gt;timeoutlen=50&lt;/code&gt;. I then set it to &lt;code&gt;timeoutlen=1000 ttimeoutlen=10&lt;/code&gt; and that resolved all the problems. Now, could anyone explain what's going on with vim when &lt;code&gt;timeoutlen&lt;/code&gt; is set to a number like 50? Why was I having such weird issues? and why is everything resolved by setting &lt;code&gt;timeoutlen&lt;/code&gt; to a much higher number and setting &lt;code&gt;ttimeoutlen&lt;/code&gt;? and why did the FAQ suggest 50 when it created these errors?&lt;/p&gt;&#xA;" OwnerUserId="2807" LastEditorUserId="205" LastEditDate="2015-07-16T05:49:46.237" LastActivityDate="2016-05-08T03:21:56.033" Title="timeoutlen breaks &lt;leader&gt; and vim-commentary" Tags="|key-bindings|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3965" PostTypeId="1" CreationDate="2015-07-17T00:43:53.247" Score="1" ViewCount="942" Body="&lt;p&gt;I have installed the snippets plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'garbas/vim-snipmate'&#xA;Plugin 'honza/vim-snippets'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I've put my own markdown snippets under &lt;code&gt;~/.vim/snippets/markdown.snippets&lt;/code&gt;. There're some triggers in it like &lt;code&gt;ul&lt;/code&gt; which create an unordered list and &lt;code&gt;ol&lt;/code&gt; which creates an ordered list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I edit a markdown file, my own snippets not working. If I try to trigger a custom snippet from &lt;code&gt;~/.vim/snippets/markdown.snippets&lt;/code&gt;, the cursor flashes and erase the trigger word. But if I try to trigger a snippet from &lt;code&gt;honza/vim-snippets&lt;/code&gt;, it still works. Please see the below gif:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qXZ3C.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;==================================================&#xA;Below is my custom markdown.snippet&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;###########################################################################&#xA;#                            Markdown Snippets                            #&#xA;###########################################################################&#xA;&#xA;extends pelican&#xA;&#xA;#############&#xA;#  Headers  #&#xA;#############&#xA;&#xA;snippet h1 &quot;Header h1&quot; b&#xA;# ${1:Header name}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet h1i &quot;Header h1 with id&quot; b&#xA;# ${1:Header name} {#${2:id}}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet h2 &quot;Header h2&quot; b&#xA;## ${1:Header name}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet h2i &quot;Header h2 with id&quot; b&#xA;## ${1:Header name} {#${2:id}}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet h3 &quot;Header h3&quot; b&#xA;### ${1:Header name}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet h3i &quot;Header h3 with id&quot; b&#xA;### ${1:Header name} {#${2:id}}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet h4 &quot;Header h4&quot; b&#xA;#### ${1:Header name}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet h4i &quot;Header h4 with id&quot; b&#xA;#### ${1:Header name} {#${2:id}}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet h5 &quot;Header h5&quot; b&#xA;##### ${1:Header name}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet h5i &quot;Header h5 with id&quot; b&#xA;##### ${1:Header name} {#${2:id}}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet h6 &quot;Header h6&quot; b&#xA;###### ${1:Header name}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet h6i &quot;Header h6 with id&quot; b&#xA;###### ${1:Header name} {#${2:id}}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet hrlnk &quot;Header ID Link&quot;&#xA;[${1:Text}](#${2:Header ID})$0&#xA;endsnippet&#xA;&#xA;snippet hrlac &quot;Header ID Link auto-complete&quot;&#xA;[${1:Text}](#${1/(\w+)(\s*)/\L$1\E(?2:-)/g})$0&#xA;endsnippet&#xA;&#xA;###########&#xA;#  Links  #&#xA;###########&#xA;&#xA;snippet lnk &quot;Inline Link&quot;&#xA;[${1:${VISUAL:Text}}](${3:http://${2:www.url.com}}${4/.+/ &quot;/}${4:opt title}${4/.+/&quot;/})$0&#xA;endsnippet&#xA;&#xA;snippet rlnk &quot;Reference-style link&quot;&#xA;[${1:${VISUAL:Text}}][${2:Reference}]$0&#xA;endsnippet&#xA;&#xA;snippet rdef &quot;Reference-style link ID&quot;&#xA;[${1}]: ${3:http://${2:www.url.com}}&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet flnk &quot;Fast link&quot;&#xA;&amp;lt;http://${1:url}&amp;gt;$0&#xA;endsnippet&#xA;&#xA;&#xA;##############&#xA;#  Emphasis  #&#xA;##############&#xA;&#xA;snippet * &quot;Italic&quot;&#xA;*${1:${VISUAL:Text}}*$0&#xA;endsnippet&#xA;&#xA;snippet _ &quot;Strong&quot;&#xA;__${1:${VISUAL:Text}}__$0&#xA;endsnippet&#xA;&#xA;snippet *_ &quot;Italic and Strong&quot;&#xA;***${1:${VISUAL:Text}}***$0&#xA;endsnippet&#xA;&#xA;&#xA;############&#xA;#  Quotes  #&#xA;############&#xA;&#xA;snippet &amp;gt; &quot;Quote&quot; !b&#xA; &amp;gt; ${1:${VISUAL:Text}:${VISUAL:Text}}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;&#xA;###########&#xA;#  Lists  #&#xA;###########&#xA;&#xA;snippet ol &quot;Ordered List&quot;&#xA;1. ${1}&#xA;2. ${2}&#xA;3. ${3}&#xA;4. ${4}&#xA;$0&#xA;endsnippet&#xA;&#xA;snippet ul &quot;Unordered List&quot;&#xA;* ${1}&#xA;* ${2}&#xA;* ${3}&#xA;* ${4}&#xA;$0&#xA;endsnippet&#xA;&#xA;&#xA;######################&#xA;#  Definition Lists  #&#xA;######################&#xA;&#xA;snippet dl &quot;Definition List&quot; !b&#xA;${1:Word 1}&#xA;: ${2:Definition}&#xA;${3:Word 2}&#xA;: ${4:Definition}&#xA;${5:Word 3}&#xA;: ${6:Definition}&#xA;${7:Word 4}&#xA;: ${8:Definition}&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;&#xA;############&#xA;#  Images  #&#xA;############&#xA;&#xA;snippet img! &quot;Image&quot;&#xA;![${1:pic alt}](${2:path}${3/.+/ &quot;/}${3:opt title}${3/.+/&quot;/})$0&#xA;endsnippet&#xA;&#xA;snippet ilnk &quot;Reference-style Image&quot;&#xA;![${1:${VISUAL:Text}}][${2:Reference}] $0&#xA;endsnippet&#xA;&#xA;snippet idef &quot;Reference-style Image ID&quot;&#xA;  [${1}]: ${2:path}${3/.+/ &quot;/}${3:opt title}${3/.+/&quot;/}&#xA;  $0&#xA;endsnippet&#xA;&#xA;&#xA;############&#xA;#  Tables  #&#xA;############&#xA;&#xA;snippet table &quot;Table&quot;&#xA;${1:First Header}   | ${6:First Header}&#xA;--------------------|--------------------&#xA;${2:Content Cell}   | ${7:Content Cell}&#xA;${3:Content Cell}   | ${8:Content Cell}&#xA;${4:Content Cell}   | ${9:Content Cell}&#xA;${5:Content Cell}   | ${10:Content Cell}&#xA;$0&#xA;endsnippet&#xA;&#xA;&#xA;##########&#xA;#  Code  #&#xA;##########&#xA;&#xA;snippet ` &quot;Inline code&quot;&#xA;\`${1:code}\` $0&#xA;endsnippet&#xA;&#xA;snippet ~ &quot;Code&quot; b&#xA;~~~&#xA;${1:${VISUAL:Code}}&#xA;~~~&#xA;$0&#xA;endsnippet&#xA;&#xA;&#xA;#####################&#xA;#  Horizontal Rule  #&#xA;#####################&#xA;&#xA;snippet hr &quot;Horizontal Rule&quot; b&#xA;----------&#xA;&#xA;$0&#xA;endsnippet&#xA;&#xA;&#xA;###############&#xA;#  Footnotes  #&#xA;###############&#xA;&#xA;snippet ft &quot;Footnote Reference&quot;&#xA;[^${1:Footnote label}]&#xA;endsnippet&#xA;&#xA;snippet ftd &quot;Footnote Definition&quot;&#xA;  [^${1:footnote label}]: ${2:Footnote}&#xA;  $0&#xA;endsnippet&#xA;&#xA;&#xA;##################&#xA;# Abbreviations  #&#xA;##################&#xA;&#xA;&#xA;snippet abb &quot;Abbreviation&quot; b&#xA;*[${1:abbreviation}]: ${2:definition}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="51" LastEditDate="2016-03-02T13:03:30.753" LastActivityDate="2016-03-02T13:03:30.753" Title="Why don't my custom snippets under ~/.vim/snippets/ directory work?" Tags="|plugin-snipmate|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3966" PostTypeId="1" AcceptedAnswerId="3967" CreationDate="2015-07-17T01:35:39.983" Score="8" ViewCount="1865" Body="&lt;p&gt;Let's say that I have the following very simple file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&#xA;b&#xA;c&#xA;d&#xA;e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I've decided that I want to add empty lines after each line. Several different methods immediately jump to my mind. We might &lt;em&gt;just do it&lt;/em&gt; (and thus embrace failure). We might record a macro like &lt;code&gt;qqo&amp;lt;ESC&amp;gt;jq&lt;/code&gt; and repeat it several times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two other methods seemed more obvious to me at the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, I thought I would issue the &lt;code&gt;:norm&lt;/code&gt; command &lt;code&gt;o&lt;/code&gt; on each line. So I run &lt;code&gt;:%norm o&lt;/code&gt;. But what actually happens is that we get 5 blank lines, followed by the un-separated lines as above. I interpret this to mean that by &lt;code&gt;%norm&lt;/code&gt;, vim actually picks up the message &lt;em&gt;issue the following normal command on the first five lines of this five line file&lt;/em&gt;. The &lt;code&gt;o&lt;/code&gt; command creates a new line and vim is &quot;dumb&quot; in the sense that it references by line number and not actually by some other identifier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, I was embarrassed. Sure. I tried a few other things to see if I could make the above method work, but alas, I couldn't. Out of curiosity, I tried my other favorite mass-apply method. This led me to try &lt;code&gt;:g/^/norm o&lt;/code&gt;. To my surprise, this works just fine! So to my eyes, it seems that vim isn't &quot;dumb&quot; here in the same way as above and references lines by more than just line number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What exactly is going on?&lt;/p&gt;&#xA;" OwnerUserId="130" LastActivityDate="2015-07-17T02:27:35.507" Title="Understanding line reference differences through :g/^/norm and through :%norm" Tags="|command-line|normal-mode|repeated-commands|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3967" PostTypeId="2" ParentId="3966" CreationDate="2015-07-17T02:27:35.507" Score="10" Body="&lt;p&gt;Well, &lt;code&gt;%&lt;/code&gt; is shorthand for &lt;code&gt;1,$&lt;/code&gt; (a range from the first line to the last). From &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3Arange&quot;&gt;&lt;code&gt;:he :%&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line numbers may be specified with:             :range E14 {address}&#xA;        {number}        an absolute line number&#xA;        .               the current line                          :.&#xA;        $               the last line in the file                 :$&#xA;        %               equal to 1,$ (the entire file)            :%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And for &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%3Aglobal&quot;&gt;&lt;code&gt;:global&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The global commands work by first scanning through the [range] lines and&#xA;marking each line where a match occurs (for a multi-line pattern, only the&#xA;start of the match matters).&#xA;In a second scan the [cmd] is executed for each marked line with its line&#xA;number prepended.  For &quot;:v&quot; and &quot;:g!&quot; the command is executed for each not&#xA;marked line.  If a line is deleted its mark disappears.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, the first case is like traversing a list while modifying it, so a counter on list elements becomes invalid. In the second case, we mark the elements we want to target in one pass, so that even if the list is modified in the second pass, we still know which elements we want to work on.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-07-17T02:27:35.507" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3968" PostTypeId="1" AcceptedAnswerId="3971" CreationDate="2015-07-17T13:35:01.870" Score="27" ViewCount="6820" Body="&lt;p&gt;I'd like to trigger an &lt;code&gt;autocmd&lt;/code&gt;  on two events but not in a way it is usually done, i.e. if either of the events happened then trigger an &lt;code&gt;autocmd&lt;/code&gt;. I want to trigger it if both events happened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;br/&gt;&#xA;The usual way to do it&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWrite,BufRead *.c *.py *.h :call StripTrailingWhitespaces()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code will call StripTrailingWhiteSpaces() on either BufWrite or BufRead&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype c,cpp,python AND BufWrite :call StripTrailingWhiteSpaces()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words trigger an &lt;code&gt;autcmd&lt;/code&gt; when the filetype is one of c, cpp, python and the write on this buffer happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated.  &lt;/p&gt;&#xA;" OwnerUserId="2865" LastActivityDate="2015-07-19T22:20:38.760" Title="Is there a way to AND events in the autocmd?" Tags="|autocmd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3971" PostTypeId="2" ParentId="3968" CreationDate="2015-07-17T15:20:53.440" Score="17" Body="&lt;p&gt;An autocommand command is executed when one event occurs. You want a command to be executed after a sequence of events has occurred. One way to do that is like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType c,cpp,python&#xA;    \ autocmd BufWritePre &amp;lt;buffer&amp;gt; call StripTrailingWhiteSpaces()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; pattern causes the autocommand to be be triggered when the current buffer is written. See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help autocmd-buflocal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution above is pretty simple and has some flaws that were discussed in the Comments. Here is a more complete solution that addresses some of those flaws. It puts the autocommands in a group and deletes the BufWritePre autocommand, if one exists, before creating a new one. It still creates one autocommand per buffer, but only one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup TrailSpace&#xA;    autocmd FileType c,cpp,python&#xA;        \ autocmd! TrailSpace BufWritePost &amp;lt;buffer&amp;gt; call SkipTrailingWhiteSpaces()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another solution, similar to the answer posted by lcd047, now deleted, is to recognize that when the FileType event occurs, the 'filetype' option is set. Then you can condition the response to the BufWritePost event on the value of 'filetype', as in the following example. It has the advantage over the other solutions that only one autocommand is created.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * if count(['c','cpp','python'],&amp;amp;filetype)&#xA;    \ | call SkipTrailingWhiteSpaces()&#xA;    \ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="2055" LastEditDate="2015-07-18T20:07:53.390" LastActivityDate="2015-07-18T20:07:53.390" CommentCount="19" ContentLicense="CC BY-SA 3.0" />
  <row Id="3972" PostTypeId="1" AcceptedAnswerId="3975" CreationDate="2015-07-17T15:36:42.730" Score="1" ViewCount="95" Body="&lt;p&gt;I have the following setting in my vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType * setlocal tabstop=2 softtabstop=2 shiftwidth=2 expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is just so that every file I open looks consistent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have another setting in after\ftplugin\make.vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks like when I open &lt;code&gt;makefile&lt;/code&gt; settings in make.vim are triggered first and that settings in vimrc are triggered last. Is there a way to make &lt;code&gt;make.vim&lt;/code&gt; settings to be triggered last?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated. &lt;/p&gt;&#xA;" OwnerUserId="2865" LastEditorUserId="2865" LastEditDate="2015-07-17T16:07:24.703" LastActivityDate="2015-07-17T18:38:12.057" Title="How to trigger file type specific settings after they they have been executed in vimrc?" Tags="|tab-characters|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3973" PostTypeId="1" AcceptedAnswerId="3977" CreationDate="2015-07-17T18:00:14.123" Score="1" ViewCount="1375" Body="&lt;p&gt;I have the following settings in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set listchars=tab:►-,eol:¬,trail:●&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I display unprintable characters in my makefile, I get something that looks like the following for one of the targets:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;target:►prereq1►prereq2►►---prereq3►►---prereq4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I expect to see the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;target:►---prereq1►---prereq2►---►---prereq3►---►---prereq4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks like it is displaying some of the tabs as &lt;code&gt;►&lt;/code&gt; instead of &lt;code&gt;►---&lt;/code&gt;. I can't understand why. Can someone explain what is going on and how to fix it?&lt;/p&gt;&#xA;" OwnerUserId="2865" LastEditorUserId="2680" LastEditDate="2015-07-17T21:12:20.853" LastActivityDate="2015-07-17T21:12:20.853" Title="Why are &lt;tab&gt; characters variable width?" Tags="|tab-characters|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3974" PostTypeId="2" ParentId="3973" CreationDate="2015-07-17T18:25:21.867" Score="0" Body="&lt;p&gt;It is because the &lt;code&gt;tab&lt;/code&gt; spans 8 positions. Your &lt;code&gt;prereqX&lt;/code&gt; text covers already 7 positions and therefor the ►- is truncated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to insert the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&amp;lt;tab&amp;gt;b&amp;lt;tab&amp;gt;c&amp;lt;tab&amp;gt;d&amp;lt;tab&amp;gt;e&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also &lt;code&gt;:help tabstop&lt;/code&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your expectation is using almost &lt;code&gt;:set tabstop=11&lt;/code&gt; by the way.&lt;/p&gt;&#xA;" OwnerUserId="2874" LastActivityDate="2015-07-17T18:25:21.867" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3975" PostTypeId="2" ParentId="3972" CreationDate="2015-07-17T18:38:12.057" Score="3" Body="&lt;p&gt;You can just directly put &lt;code&gt;set tabstop=2 softtabstop=2 shiftwidth=2&lt;/code&gt; in your vimrc.  That way it is the default, but it can be overridden ftplugins and anything in the &lt;code&gt;after&lt;/code&gt; directory.  For more about how vim's runtime directories work, see &lt;code&gt;:help 'runtimepath'&lt;/code&gt;.  Also, &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/42.html&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; is a nice summary of what each directory does.&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-07-17T18:38:12.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3976" PostTypeId="2" ParentId="3973" CreationDate="2015-07-17T20:33:16.153" Score="3" Body="&lt;p&gt;Unlike &lt;code&gt;A&lt;/code&gt;, &lt;code&gt;@&lt;/code&gt; or space, tabulations are not &quot;real&quot; characters with a defined glyph and defined metrics and whatnot. When you insert a &quot;tab&quot; you tell your text editor this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I want the next character to be displayed &lt;em&gt;at most&lt;/em&gt; &lt;code&gt;n&lt;/code&gt; spaces from here.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;n&lt;/code&gt; being the value of &lt;code&gt;tabstop&lt;/code&gt; or &lt;code&gt;softtabstop&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the following example, &lt;code&gt;[  ]&lt;/code&gt; represent a 4 spaces wide tabulation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[  ][  ][  ][  ][  ][  ][  ][  ]...&#xA;lorem ipsum dolor sit amet                no tab&#xA;    lorem ipsum dolor sit amet            tab before lorem&#xA;lorem   ipsum dolor sit amet              tab before ipsum&#xA;lorem ipsum     dolor sit amet            tab before dolor&#xA;lorem ipsum dolor   sit amet              tab before sit&#xA;lorem ipsum dolor sit   amet              tab before amet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note how each tab appears to have a different width; 4, 2, 4, 2 and 2. That's because tabulations are here to help you align your text: n. No matter the content, you can be certain that inserting a &quot;tab&quot; will push the rest of the line to the next tabstop, which will always be at most 8 (or whatever value you chose) characters to the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, the value you chose for &lt;code&gt;listchars&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tab:►-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;tells vim to materialize tabulations with a &lt;code&gt;►&lt;/code&gt; followed by zero or more &lt;code&gt;-&lt;/code&gt;, up to &lt;code&gt;&amp;amp;tabstop - 1&lt;/code&gt;. With your settings, tabulations can take any of the forms below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;►&#xA;►-&#xA;►--&#xA;►---&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the sample above...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[  ][  ][  ][  ][  ][  ][  ][  ]...&#xA;lorem ipsum dolor sit amet                no tab&#xA;►---lorem ipsum dolor sit amet            tab before lorem&#xA;lorem ►-ipsum dolor sit amet              tab before ipsum&#xA;lorem ipsum ►---dolor sit amet            tab before dolor&#xA;lorem ipsum dolor ►-sit amet              tab before sit&#xA;lorem ipsum dolor sit ►-amet              tab before amet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In short, everything is A-OK and the behavior you get is exactly the same you should get in any other text editor or word processor.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-07-17T20:33:16.153" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3977" PostTypeId="2" ParentId="3973" CreationDate="2015-07-17T20:39:46.520" Score="7" Body="&lt;p&gt;A tab advances to the next column whose position is a multiple of the tab stop. So, with &lt;code&gt;tabstop=4&lt;/code&gt;, if your cursor is in column 7 and you press &lt;kbd&gt;Tab&lt;/kbd&gt;, the cursor will advance only one column to column 8, as in the first tab in your example. Tabs are not constant width.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can visualize it thus—each &lt;code&gt;↓&lt;/code&gt; is a tab stop, a column that is a multiple of 4:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    ↓   ↓   ↓   ↓   ↓   ↓   ↓   ↓   ↓   ↓   ↓&#xA;target:►prereq1►prereq2►►---prereq3►►---prereq4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that every tab character advances to the next arrow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what allows tabs to line up columns of text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    ↓   ↓&#xA;a►--b►--c&#xA;dd►-ee►-ff&#xA;ggg►hhh►iii&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a   b   c&#xA;dd  ee  ff&#xA;ggg hhh iii&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If every tab was four spaces, it would look like this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a    b    c&#xA;dd    ee    ff&#xA;ggg    hhh    iii&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this only works if every column's length is less than the tab stop size; otherwise it will skip to the next tab stop.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a   b   c&#xA;dddd    eeee    ffff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2680" LastEditorUserId="2680" LastEditDate="2015-07-17T21:11:41.133" LastActivityDate="2015-07-17T21:11:41.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3978" PostTypeId="1" CreationDate="2015-07-17T21:26:14.123" Score="19" ViewCount="1362" Body="&lt;p&gt;I know that I can use &lt;code&gt;.&lt;/code&gt; to repeat the last editing command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to repeat the last UI manipulation command?&#xA;For example, I can write &lt;code&gt;10&amp;lt;C-W&amp;gt;-&lt;/code&gt; to shrink a window by ten rows.&#xA;It'd be nice to be able to press &amp;langle;&lt;em&gt;some key&lt;/em&gt;&amp;rangle; to easily repeat this command if I want to shrink it more.&lt;/p&gt;&#xA;" OwnerUserId="142" LastActivityDate="2023-12-29T21:09:30.460" Title="Can I repeat the last UI command?" Tags="|repeated-commands|" AnswerCount="6" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3979" PostTypeId="2" ParentId="3978" CreationDate="2015-07-18T05:01:50.687" Score="13" Body="&lt;p&gt;The dot command &lt;code&gt;.&lt;/code&gt; works because Vim &quot;keeps track&quot; of commands that change the contents of buffers.  If you run &lt;code&gt;:echo b:changedtick&lt;/code&gt;, you'll see it incrementing with each change to the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But Vim doesn't &quot;keep track&quot; of non-editing commands.  Thus, no, what you're asking for can't be done.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-07-18T05:01:50.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3980" PostTypeId="1" AcceptedAnswerId="3983" CreationDate="2015-07-18T15:32:06.010" Score="2" ViewCount="289" Body="&lt;p&gt;Sourceforge has been down for the last few days. It seems the only way to find what to add to your vimrc to get Vim-LaTeX to work is to download the 'recommended settings' from Sourceforge. This information is not even in the manual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone tell me where else I could find what to put in my vimrc to setup Vim-LaTeX? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be great if you put a copy here for future reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I already have Vim-LaTeX downloaded from a Linux repository, so I just need the &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;" OwnerUserId="2882" LastEditorUserId="205" LastEditDate="2015-07-18T18:10:10.037" LastActivityDate="2015-07-18T18:14:13.477" Title="Alternatives to vimrc for Vim-LaTeX while Sourceforge is down" Tags="|vimrc|plugin-vim-latex|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3981" PostTypeId="2" ParentId="3978" CreationDate="2015-07-18T16:19:41.670" Score="4" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/kana/vim-submode&quot; rel=&quot;nofollow&quot;&gt;submode&lt;/a&gt; plugin can help with this. You could define a &quot;submode&quot; that you enter by typing &lt;code&gt;&amp;lt;C-W&amp;gt;-&lt;/code&gt;, wherein you've defined &lt;code&gt;-&lt;/code&gt; (and perhaps &lt;code&gt;+&lt;/code&gt;) to continue resizing the window.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-07-18T16:19:41.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3982" PostTypeId="2" ParentId="2108" CreationDate="2015-07-18T16:44:06.703" Score="2" Body="&lt;p&gt;From command line you can use: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim file1 ... filen -p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if you forgot to use &lt;code&gt;-p&lt;/code&gt; still you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tab ball&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Btw, don't forget that the variable &lt;code&gt;tabpagemax&lt;/code&gt; (default value 10) limits how many tabs you can open this way.&lt;/p&gt;&#xA;" OwnerUserId="2884" LastEditorUserId="205" LastEditDate="2015-07-18T18:15:41.047" LastActivityDate="2015-07-18T18:15:41.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3983" PostTypeId="2" ParentId="3980" CreationDate="2015-07-18T18:14:13.477" Score="3" Body="&lt;p&gt;Google is your friend. Specifically, &lt;a href=&quot;http://webcache.googleusercontent.com/search?q=cache:BKe8ucxeeSwJ:vim-latex.sourceforge.net/documentation/latex-suite/recommended-settings.html%20&amp;amp;cd=1&amp;amp;hl=en&amp;amp;ct=clnk&amp;amp;gl=in&quot; rel=&quot;nofollow&quot;&gt;Google's cache&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Make sure that you create a few necessary settings in your &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.&#xA;filetype plugin on&#xA;&#xA;&quot; IMPORTANT: win32 users will need to have 'shellslash' set so that latex&#xA;&quot; can be called correctly.&#xA;set shellslash&#xA;&#xA;&quot; IMPORTANT: grep will sometimes skip displaying the file name if you&#xA;&quot; search in a singe file. This will confuse Latex-Suite. Set your grep&#xA;&quot; program to always generate a file-name.&#xA;set grepprg=grep\ -nH\ $*&#xA;&#xA;&quot; OPTIONAL: This enables automatic indentation as you type.&#xA;filetype indent on&#xA;&#xA;&quot; OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to&#xA;&quot; 'plaintex' instead of 'tex', which results in vim-latex not being loaded.&#xA;&quot; The following changes the default filetype back to 'tex':&#xA;let g:tex_flavor='latex'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;In addition, the following settings could go in your&#xA;  &lt;code&gt;~/.vim/ftplugin/tex.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; this is mostly a matter of taste. but LaTeX looks good with just a bit&#xA;&quot; of indentation.&#xA;set sw=2&#xA;&quot; TIP: if you write your \label's as \label{fig:something}, then if you&#xA;&quot; type in \ref{fig: and press &amp;lt;C-n&amp;gt; you will automatically cycle through&#xA;&quot; all the figure labels. Very useful!&#xA;set iskeyword+=:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Though I must say I find nothing particularly unusual in here, except perhaps for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tex_flavor='latex'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-07-18T18:14:13.477" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3984" PostTypeId="2" ParentId="3978" CreationDate="2015-07-18T21:29:18.667" Score="9" Body="&lt;p&gt;There is no way of doing this by default in vim because vim does not keep track of the previously executed wincmd.  However, it is possible to do this through some clever mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Wincmd(count, key)&#xA;    &quot; If count is not zero, use the original count.  If otherwise, don't&#xA;    &quot; include a count.&#xA;    let if_count = a:count ? a:count : &quot;&quot;&#xA;    &quot; This builds a wincmd from the given key, and saves it so&#xA;    &quot; it can be repeated.&#xA;    let g:last_wincmd = &quot;wincmd &quot; . nr2char(a:key)&#xA;    &quot; Execute the built wincmd&#xA;    execute if_count . g:last_wincmd&#xA;endfunction&#xA;&#xA;function! s:WincmdRepeat(count)&#xA;    &quot; If no wincmd has been executed yet, don't do anything&#xA;    if !exists('g:last_wincmd') | return | endif&#xA;    &quot; If a count is given, repeat the last wincmd that amount of times.&#xA;    &quot; If otherwise, just repeat once.&#xA;    let if_count = a:count ? a:count : &quot;&quot;&#xA;    execute if_count . g:last_wincmd&#xA;endfunction&#xA;&#xA;&quot; Overwrite the default &amp;lt;C-w&amp;gt; mapping so that the last wincmd can be kept&#xA;&quot; track of.  The getchar function is what captures the key pressed&#xA;&quot; directly afterwards.  The &amp;lt;C-u&amp;gt; is to remove any cmdline range that vim&#xA;&quot; automatically inserted.&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-w&amp;gt; :&amp;lt;C-u&amp;gt;call &amp;lt;SID&amp;gt;Wincmd(v:count, getchar())&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; This just calls the function which repeats the previous wincmd.  It&#xA;&quot; does accept a count, which is the number of times it should repeat the&#xA;&quot; previous wincmd.  You can also replace Q with whatever key you want. &#xA;nnoremap &amp;lt;silent&amp;gt; Q :&amp;lt;C-u&amp;gt; call &amp;lt;SID&amp;gt;WincmdRepeat(v:count)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that if you have any mappings that use &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; they can only be repeated if they are not of the &lt;code&gt;nore&lt;/code&gt; variety.  Any wincmds issued using &lt;code&gt;:wincmd&lt;/code&gt; will not be repeated.  Also, any wincmds that contain more than one character cannot be performed &lt;em&gt;(such as &lt;code&gt;&amp;lt;C-w&amp;gt;gf&lt;/code&gt;)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Relevant Help Topics&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help v:count&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getchar()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help nr2char()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help expr1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :wincmd&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :execute&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :for&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :map-&amp;lt;silent&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help c_CTRL-U&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help &amp;lt;SID&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2018-02-28T22:14:46.710" LastActivityDate="2018-02-28T22:14:46.710" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3985" PostTypeId="1" AcceptedAnswerId="3986" CreationDate="2015-07-19T02:55:41.790" Score="9" ViewCount="3282" Body="&lt;p&gt;I'm attempting to get something setup that invokes the vimdiff git merge tool externally, but because of the way the setup works, I need to invoke vimdiff manually (without git mergetool). Does anyone know the exact command git runs with vimdiff to get the proper layout (three windows split horizontally and one vertically)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually, &lt;code&gt;git mergetool&lt;/code&gt; results in this layout:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-------------------------&#xA;| LOCAL | BASE | REMOTE |&#xA;-------------------------&#xA;|        MERGED         |&#xA;-------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I can only get either an all horizontal or all vertical layout using the &lt;code&gt;vimdiff ...&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-----------------     -----------------&#xA;| L | B | R | M |     |       L       |&#xA;-----------------     -----------------&#xA;                      |       B       |&#xA;                      -----------------&#xA;                      |       R       |&#xA;                      -----------------&#xA;                      |       M       |&#xA;                      -----------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to know the proper sequence of arguments to either the &lt;code&gt;vim -d&lt;/code&gt; command or &lt;code&gt;vimdiff&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="2888" LastActivityDate="2015-07-19T16:08:03.297" Title="Git mergetool vimdiff command" Tags="|vimdiff|git|merge|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3986" PostTypeId="2" ParentId="3985" CreationDate="2015-07-19T03:10:30.883" Score="10" Body="&lt;p&gt;I used the trick from &lt;a href=&quot;https://stackoverflow.com/questions/10357374/is-it-possible-to-access-vims-command-line-arguments-in-vimscript&quot;&gt;this SO question&lt;/a&gt; to see what the command line was, and got this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe '!tr &quot;\0&quot; &quot; &quot; &amp;lt;/proc/' . getpid() . '/cmdline'&#xA;:!tr &quot;\0&quot; &quot; &quot; &amp;lt;/proc/23932/cmdline&#xA;gvim -f -d -c wincmd J foo ./foo_LOCAL_23800 ./foo_BASE_23800 ./foo_REMOTE_23800&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the trick is using &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#CTRL-W_J&quot; rel=&quot;noreferrer&quot;&gt;&lt;kbd&gt;Ctrl-W&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt;&lt;/a&gt; (via &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Awincmd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:wincmd&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                :winc :wincmd&#xA;:[count]winc[md] {arg}&#xA;                Like executing CTRL-W [count] {arg}.  Example: &#xA;                        :wincmd j&#xA;               Moves to the window below the current one.&#xA;                This command is useful when a Normal mode cannot be used (for&#xA;                the CursorHold autocommand event).  Or when a Normal mode&#xA;                command is inconvenient.&#xA;                                                CTRL-W_J&#xA;CTRL-W J        Move the current window to be at the very bottom, using the&#xA;                full width of the screen.  This works like closing the current&#xA;                window and then creating another one with &quot;:botright split&quot;,&#xA;                except that the current window contents is used for the new&#xA;                window.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;@lcd047 has a better way of getting the arguments: use a (wrapper) script that dumps its arguments before proceeding to &lt;code&gt;exec&lt;/code&gt; them. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat args-echo&#xA;#! /bin/sh&#xA;echo &quot;$0&quot; &quot;$@&quot; &amp;gt; args &#xA;# since I don't really need to merge&#xA;# exec vim &quot;$@&quot;&#xA;$ git config mergetool.gvimdiff.path &quot;${PWD}/args-echo&quot;&#xA;$ yes n | git mergetool&#xA;Merging:&#xA;foo&#xA;&#xA;Normal merge conflict for 'foo':&#xA;  {local}: modified file&#xA;  {remote}: modified file&#xA;Hit return to start merge resolution tool (gvimdiff): &#xA;foo seems unchanged.&#xA;Was the merge successful? [y/n] merge of foo failed&#xA;Continue merging other unresolved paths (y/n) ? &#xA;$ cat args &#xA;/tmp/bar/args-echo -f -d -c wincmd J foo ./foo_LOCAL_18649 ./foo_BASE_18649 ./foo_REMOTE_18649&#xA;$ git config --unset mergetool.gvimdiff.path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-07-19T13:45:29.563" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3987" PostTypeId="1" AcceptedAnswerId="3988" CreationDate="2015-07-19T04:07:18.117" Score="7" ViewCount="940" Body="&lt;p&gt;I know that you can go to the Nth % percentage of a file by typing N% in normal mode. Is it possible to advance the line by a given percentage?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify, for an example, can I type something to advance to 10% of the file, then the same thing to advance to 20% and so on?&lt;/p&gt;&#xA;" OwnerUserId="2889" LastActivityDate="2015-07-19T14:02:50.613" Title="Move cursor by percentage" Tags="|cursor-movement|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3988" PostTypeId="2" ParentId="3987" CreationDate="2015-07-19T06:45:31.480" Score="9" Body="&lt;p&gt;Sure, you can do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! &amp;lt;SID&amp;gt;PercentUp()&#xA;    execute 'normal ' . max([line('.') * 100 / line('$') - v:count1 * 10, 0]) . '%'&#xA;endfunction&#xA;&#xA;function! &amp;lt;SID&amp;gt;PercentDown()&#xA;    execute 'normal ' . min([line('.') * 100 / line('$') + v:count1 * 10, 100]) . '%'&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;- :&amp;lt;C-u&amp;gt;call &amp;lt;SID&amp;gt;PercentUp()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;+ :&amp;lt;C-u&amp;gt;call &amp;lt;SID&amp;gt;PercentDown()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With these &lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;-&lt;/kbd&gt; will recede by 10%, while &lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt; will advance by 10%.  The macros accept counters.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="1577" LastEditDate="2015-07-19T14:02:50.613" LastActivityDate="2015-07-19T14:02:50.613" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3989" PostTypeId="2" ParentId="3985" CreationDate="2015-07-19T16:08:03.297" Score="2" Body="&lt;p&gt;For completeness I use the following git config for mergetool. It uses the &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow&quot;&gt;vim-fugitive&lt;/a&gt; plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[merge]&#xA;  conflictstyle = merge&#xA;  tool = fugitive&#xA;&#xA;[mergetool &quot;fugitive&quot;]&#xA;  cmd = vim &quot;+Gdiff&quot; $MERGED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also dabbled with my own version that handled the three way merge with mutliple tabs for different perspectives. However, I found that the above fugitive version suited my day to day needs better.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[merge]&#xA;  conflictstyle = diff3&#xA;  tool = diffconflicts&#xA;&#xA;[mergetool &quot;diffconflicts&quot;]&#xA;  cmd = diffconflicts vim $BASE $LOCAL $REMOTE $MERGED&#xA;  trustExitCode = false&#xA;  keepBackup = false&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From my &lt;a href=&quot;https://github.com/sukima/dotfiles/blob/master/home/.bin/diffconflicts&quot; rel=&quot;nofollow&quot;&gt;diffconflict&lt;/a&gt; script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;# Use *real* vimdiff to edit merge conflicts in Git&#xA;#&#xA;# Instead of editing a file with  &amp;lt;&amp;lt;&amp;lt;&amp;lt; ==== &amp;gt;&amp;gt;&amp;gt; conflict markers, this opens&#xA;# each &quot;side&quot; of the conflict markers in a two-way vimdiff window.&#xA;#&#xA;# (I'm not clear why this isn't the default behavior for Git's vimdiff&#xA;# mergetool script. What purpose does the 'result' window with the conflict&#xA;# markers serve that vimdiff can't do better on its own?)&#xA;#&#xA;# Layout:&#xA;#&#xA;#   Tab1 is a two-way diff of the conflicts.&#xA;#       +--------------------------------+&#xA;#       |    LCONFL     |    RCONFL      |&#xA;#       +--------------------------------+&#xA;#   Tab2 is a three-way diff of the original files and the merge base.&#xA;#       +--------------------------------+&#xA;#       |  LOCAL   |   BASE   |  REMOTE  |&#xA;#       +--------------------------------+&#xA;#   Tab3 is the MERGED or 'result' file that contains the conflict markers.&#xA;#       +---------------------------------------+&#xA;#       |       &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD                    |&#xA;#       |        LCONFL                         |&#xA;#       |       ||||||| merged common ancestors |&#xA;#       |        BASE                           |&#xA;#       |       =======                         |&#xA;#       |        RCONFL                         |&#xA;#       |       &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; someref                 |&#xA;#       +---------------------------------------+&#xA;#&#xA;# Workflow:&#xA;#&#xA;# 1.    Save your changes to the LCONFL temporary file (the left window on the&#xA;#       first tab; also the only file that isn't read-only).&#xA;# 2.    The LOCAL, BASE, and REMOTE versions of the file are available in the&#xA;#       second tabpage if you want to look at them.&#xA;# 3.    When vimdiff exits cleanly, the file containing the conflict markers&#xA;#       will be updated with the contents of your LCONFL file edits.&#xA;# 4.    Sometimes it helps to edit the MERGED file manually. Making changes in&#xA;#       Tab3 will overwrite / destroy changes in Tab1. In other words only&#xA;#       edit one or the other.&#xA;#&#xA;# NOTE: Use :cq to abort the merge and exit Vim with an error code.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The full script is &lt;a href=&quot;https://github.com/sukima/dotfiles/blob/master/home/.bin/diffconflicts&quot; rel=&quot;nofollow&quot;&gt;on github&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="544" LastActivityDate="2015-07-19T16:08:03.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3990" PostTypeId="1" AcceptedAnswerId="4003" CreationDate="2015-07-19T21:24:07.170" Score="17" ViewCount="1506" Body="&lt;p&gt;Is there a way to have vim not flag HTTP URLs and email addresses as spelling errors? Or, more generally, a way to list regexes of valid spellings?&lt;/p&gt;&#xA;" OwnerUserId="2894" LastEditorUserId="1821" LastEditDate="2015-07-20T05:14:30.800" LastActivityDate="2022-06-16T17:07:02.887" Title="Ignore URLs and email addresses in spell file" Tags="|regular-expression|spell-checking|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3991" PostTypeId="2" ParentId="3968" CreationDate="2015-07-19T22:20:38.760" Score="4" Body="&lt;p&gt;More generally, if you don't know which event will happen first, you can use a helper to track when each one fires and only execute your command when the last one fires:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function StripTrailingWhiteSpacesIfReady(event) abort&#xA;  if !exists('b:events_for_whitespace')&#xA;    let b:events_for_whitespace = {}&#xA;  endif&#xA;  let b:events_for_whitespace[a:event] = 1&#xA;  if has_key(b:events_for_whitespace, 'FileType') &amp;amp;&amp;amp; has_key(b:events_for_whitespace, 'Buf')&#xA;    &quot; Strip trailing whitespace&#xA;    %s/\m\s\+$//&#xA;  endif&#xA;endfunction&#xA;autocmd Filetype c,cpp,python call StripTrailingWhiteSpacesIfReady('FileType')&#xA;autocmd BufWrite,BufRead * StripTrailingWhiteSpacesIfReady('Buf')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="824" LastActivityDate="2015-07-19T22:20:38.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3992" PostTypeId="1" CreationDate="2015-07-19T22:27:27.670" Score="7" ViewCount="627" Body="&lt;p&gt;Is there a built-in command or plugin available to trigger spell checking over the entire current buffer, prompting me for each word it detects to either ignore, add to dictionary, or correct spelling?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been using &lt;code&gt;]s&lt;/code&gt; to skip through spelling suggestions and &lt;code&gt;zg&lt;/code&gt; or &lt;code&gt;z=&lt;/code&gt; to add to dictionary or suggest corrections, but when a buffer as a lot of instances of the same spelling it's kind of annoying skipping past every instance, especially when it's code or config files that have a lot of things that aren't misspelled but don't belong in the dictionary, like variable names or command line gibberish.&lt;/p&gt;&#xA;" OwnerUserId="824" LastActivityDate="2019-09-27T21:38:49.177" Title="How can I spell check an entire buffer?" Tags="|spell-checking|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3993" PostTypeId="1" CreationDate="2015-07-20T03:22:54.737" Score="1" ViewCount="1197" Body="&lt;p&gt;I'm using vim and markdown for note taking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes I find some useful information online, so I'll copy and paste into vim like below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;useful information line1&#xA;useful information line2&#xA;useful information line3&#xA;useful information line4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The annoying thing is, when I preview my markdown notes in html, these lines of texts are on the same line, because in markdown, to break a line, you must add two empty space at the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make vim automatically do this for me?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastActivityDate="2015-07-20T11:21:04.720" Title="How to make vim to automatically break lines in markdown files?" Tags="|filetype-markdown|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3994" PostTypeId="2" ParentId="3993" CreationDate="2015-07-20T04:15:58.273" Score="1" Body="&lt;p&gt;Assuming you know about regular expressions, you can probably use substitution to match every line, and replace that line with itself plus the desired terminated space character at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can match a line against the '\n' escape sequence. Then you can replace that with '\n '. This hasn't been tested, so no guarantees.&lt;/p&gt;&#xA;" OwnerUserId="1983" LastActivityDate="2015-07-20T04:15:58.273" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3997" PostTypeId="1" AcceptedAnswerId="3998" CreationDate="2015-07-20T06:46:36.850" Score="3" ViewCount="536" Body="&lt;p&gt;I want to create a macro that will take a word &lt;code&gt;logThis&lt;/code&gt;, which is selected in visual mode, and turn it into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;console.log 'printing logThis'&#xA;console.log JSON.stringify(logThis, undefined, 2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I realize that I can get my macro to remember &lt;code&gt;logThis&lt;/code&gt; by copying it with &lt;code&gt;yw&lt;/code&gt; or some other register, but I might be using that register for something else, and I don't want the macro to wipe out that register's contents. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use &lt;code&gt;logThis&lt;/code&gt; twice inside this macro without taking up a register?&lt;/p&gt;&#xA;" OwnerUserId="2897" LastActivityDate="2015-08-16T09:08:55.147" Title="Copy a word in macro without using a register" Tags="|macro|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3998" PostTypeId="2" ParentId="3997" CreationDate="2015-07-20T07:05:27.777" Score="8" Body="&lt;p&gt;You could include this command at the beginning of your macro to save the current value of register &lt;code&gt;a&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let old_a = getreg(a)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;yank the highlighted word to register &lt;code&gt;a&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;ay&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and reset register &lt;code&gt;a&lt;/code&gt; once you are done:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setreg(&quot;a&quot;, old_a)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Macros are great but there's always a point where they become too complex to maintain. You should probably consider a proper function instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction()&#xA;    let old_a = getreg(&quot;a&quot;)&#xA;    normal! gv&quot;ay&#xA;    let my_word = getreg(&quot;a&quot;)&#xA;    call setreg(&quot;a&quot;, old_a)&#xA;    &quot; use my_word here&#xA;endfunction&#xA;&#xA;xnoremap &amp;lt;key&amp;gt; :call MyFunction()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-08-16T09:08:55.147" LastActivityDate="2015-08-16T09:08:55.147" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3999" PostTypeId="1" AcceptedAnswerId="4001" CreationDate="2015-07-20T10:28:40.083" Score="1" ViewCount="424" Body="&lt;p&gt;I have posted &lt;a href=&quot;https://github.com/davidhalter/jedi-vim/issues/440&quot; rel=&quot;nofollow noreferrer&quot;&gt;an issue on github&lt;/a&gt;, but I am asking here too to see if someone can point me to an answer...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have installed &lt;code&gt;jedi-vim&lt;/code&gt; and I find it really nice to edit python files. But I came across a problem that I am unable to solve --- it makes editing of LaTeX files much more complex. The problem is the following. I have in my &lt;code&gt;.vimrc&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'davidhalter/jedi-vim'&#xA;    autocmd FileType python setlocal completeopt-=preview &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I edit a LaTeX file, the &lt;code&gt;$...$&lt;/code&gt; marks that define an inline math disappears unless the line is under the cursor. It's like &lt;code&gt;gvim&lt;/code&gt; trying to render the math formula... See: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Case 1, cursor in different line of the math formula (the cursor does not appear on screenshot, but believe me...) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/6414907/8773950/d84d6838-2ed8-11e5-80ef-c24c3814cbfc.png&quot; alt=&quot;selection_036&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Case 2, few instant after, cursor in the same line: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/6414907/8773962/f4f523d6-2ed8-11e5-9d02-97d91bff34ac.png&quot; alt=&quot;selection_037&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This make LaTeX files almost impossible to edit. Is there a way to restrict all of the &lt;code&gt;jedi-vim&lt;/code&gt; effects to python buffers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked that commenting out the plugin line will avoid the problem.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know what's happening here?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;it is a &lt;code&gt;conceallevel&lt;/code&gt; problem. If I open a .tex file, I have the following after issuing &lt;code&gt;:verbose set conceallevel?&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/oYPXp.png&quot; alt=&quot;set conceallevel verbose&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...which I really do not understand. I checked my &lt;code&gt;.vimrc&lt;/code&gt; and I did not find anything that would justify the fact that the python sysntax is loaded for my &lt;code&gt;tex&lt;/code&gt; buffers... but it is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Really puzzled. Anyway, adding &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType tex set  conceallevel=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to my &lt;code&gt;.vimrc&lt;/code&gt; solves (hide?) the problem. &lt;/p&gt;&#xA;" OwnerUserId="854" LastEditorUserId="854" LastEditDate="2015-07-20T12:55:12.280" LastActivityDate="2015-07-20T12:55:12.280" Title="jedi-vim and vim-latex buffers problems?" Tags="|plugin-vim-latex|plugin-jedi-vim|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4000" PostTypeId="2" ParentId="3997" CreationDate="2015-07-20T10:33:10.170" Score="6" Body="&lt;p&gt;Why a macro? You could very well use a snippet instead. For example (with &lt;a href=&quot;https://github.com/Shougo/neosnippet.vim&quot;&gt;NeoSnippet&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a new global snippet with &lt;code&gt;:NeoSnippetEdit _&lt;/code&gt; (replace &lt;code&gt;_&lt;/code&gt; with a filetype if you want a dedicated snippet) and add this content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet log&#xA;    console.log 'printing ${1:TARGET}'&#xA;    console.log JSON.stringify($1, ${2:undefined}, 2)${0}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Save and exit the file.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Usage:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Visually select your text, hit &lt;kbd&gt;Tab&lt;/kbd&gt; (or the key you have configured to trigger a snippet) and you will be asked for the snippet name to be inserted: write 'log', &lt;kbd&gt;Enter&lt;/kbd&gt; and the above code will be inserted, with cursor on &lt;code&gt;1&lt;/code&gt;st position and the &lt;code&gt;TARGET&lt;/code&gt; replaced by your selected text, in both positions. Hit &lt;kbd&gt;Tab&lt;/kbd&gt; again to accept the text and jump to the second marker (&lt;code&gt;undefined&lt;/code&gt;) - you can edit it, or not, and if you hit &lt;kbd&gt;Tab&lt;/kbd&gt; again, the cursor will be placed at the end of the construct ( position &lt;code&gt;0&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, because this is a snippet, you can also use it ... before you have the text to be logged: you write &lt;code&gt;log&lt;/code&gt; and hit &lt;kbd&gt;Tab&lt;/kbd&gt;, and the snippet will be expanded: write &lt;code&gt;logThis&lt;/code&gt; (or whatever text you want to log), hit &lt;kbd&gt;Tab&lt;/kbd&gt;, accept &lt;code&gt;undefined&lt;/code&gt; or change it, hit &lt;kbd&gt;Tab&lt;/kbd&gt; again and ... that's it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you prefer using &lt;code&gt;UltiSnips&lt;/code&gt; instead, see &lt;a href=&quot;http://vimcasts.org/episodes/ultisnips-visual-placeholder/&quot;&gt;this link&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="205" LastEditDate="2015-07-20T11:00:03.623" LastActivityDate="2015-07-20T11:00:03.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4001" PostTypeId="2" ParentId="3999" CreationDate="2015-07-20T11:01:49.547" Score="3" Body="&lt;p&gt;Your problem has nothing to do with &lt;code&gt;jedi-vim&lt;/code&gt;.  It has to do with &lt;code&gt;vim-latex&lt;/code&gt; using the &lt;code&gt;conceal&lt;/code&gt; feature of gVim, where some parts of text are replaced by (supposedly better) graphic representations when you aren't editing the corresponding lines.  In your case a superscript is replaced, but IIRC &lt;code&gt;vim-latex&lt;/code&gt; does that with many other things, such as Greek letters in formulas, and various mathematical symbols.  The result depends a lot of the quality of the font you're using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want that to happen you can set &lt;code&gt;conceallevel&lt;/code&gt; to 0:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set conceallevel=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(There might be a better / &quot;right&quot; way to tell &lt;code&gt;vim-latex&lt;/code&gt; about that, but with SourceForge still down I can't check it right now).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But try it again later with other fonts, you might start to like it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Useful references: &lt;code&gt;:help tex-conceal&lt;/code&gt;, &lt;code&gt;:help conceallevel&lt;/code&gt;, &lt;code&gt;:help concealcursor&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastEditorUserId="1577" LastEditDate="2015-07-20T11:58:51.757" LastActivityDate="2015-07-20T11:58:51.757" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="4002" PostTypeId="2" ParentId="3993" CreationDate="2015-07-20T11:21:04.720" Score="2" Body="&lt;p&gt;Assuming you put the text with &lt;code&gt;&quot;*p&lt;/code&gt; you can remap this command to first do a substitution on the &lt;code&gt;*&lt;/code&gt; register, such that every newline not preceded by two spaces is replaced by a newline preceded by two spaces.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &quot;*p :let @* = substitute(@*, '\(\S\S\)\(\n\)', '\1  \2', 'g')&amp;lt;CR&amp;gt;&quot;*p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use a different command to put (i.e., &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;) or a different register (i.e., &lt;code&gt;&quot;+&lt;/code&gt;) you can adapt it accordingly. Perhaps something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C-v&amp;gt; :let @+ = substitute(@+, '\(\S\S\)\(\n\)', '\1  \2', 'g')&amp;lt;CR&amp;gt;&amp;lt;C-v&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should also probably either make the mapping buffer specific (&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &quot;*p&lt;/code&gt; etc.) or map it to a different left hand expression (e.g., &lt;code&gt;&amp;lt;leader&amp;gt;mdp&lt;/code&gt; for &quot;markdown-put&quot;)  and place the snippet in a file that you source when you need it–either manually or perhaps in an &quot;after script&quot; for the markdown filetype (&lt;code&gt;~/.vim/after/ftplugin/markdown.vim&lt;/code&gt;), or alternatively load it with an autocmd.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-07-20T11:21:04.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4003" PostTypeId="2" ParentId="3990" CreationDate="2015-07-20T13:37:41.167" Score="20" Body="&lt;p&gt;You can add custom syntax rules, and give them the&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/spell.txt.html#spell%2dsyntax&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;@nospell&lt;/code&gt;&lt;/a&gt; keyword,&#xA;this will tell Vim not to apply spell checking to this syntax match. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn match UrlNoSpell &quot;\w\+:\/\/[^[:space:]]\+&quot; contains=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above will work for text files, and &lt;em&gt;some&lt;/em&gt; filetypes (such as&#xA;markdown), but not for all filetypes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I used a fairly simple regex here; see &lt;a href=&quot;https://vi.stackexchange.com/q/2014/51&quot;&gt;How do I parse URL's from the text&lt;/a&gt; for some alternatives.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For other filetypes, you need to do a bit more work. For example, for &lt;code&gt;python&lt;/code&gt; files, comments are contained in a &lt;code&gt;pythonComment&lt;/code&gt;&#xA;group, from &lt;code&gt;/usr/share/vim/vim74/syntax/python.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match   pythonComment   &quot;#.*$&quot; contains=pythonTodo,@Spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To override this, we need to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn match UrlNoSpellComment &quot;\w\+:\/\/[^[:space:]]\+&quot; contains=@NoSpell containedin=pythonComment&#xA;:highlight def link UrlNoSpellComment Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The trick is to add a list of previously matched syntax matches in which our&#xA;custom syntax match may be contained with &lt;code&gt;containedin=&lt;/code&gt; This tells Vim to look for the&#xA;&lt;code&gt;UrlNoSpell&lt;/code&gt; regex &lt;em&gt;within&lt;/em&gt; the &lt;code&gt;pythonComment&lt;/code&gt; matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We also need to use &lt;code&gt;highlight&lt;/code&gt; to set the correct colours, since these aren't&#xA;inherited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to do this in a number of places, for example for Python strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn match UrlNoSpellString &quot;\w\+:\/\/[^[:space:]]\+&quot; contains=@NoSpell containedin=pythonString&#xA;:highlight def link UrlNoSpellString String&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We need 2 different syntax match groups so we can apply the correct syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, for other filestypes you need to use other &lt;code&gt;containedin=&lt;/code&gt; syntax&#xA;matches... There is, AFAIK, no &quot;universal&quot; solution, but looking up the correct&#xA;ones in &lt;code&gt;/usr/share/vim/vim74/syntax/*.vim&lt;/code&gt; should not be too difficult.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that all of the above commands must be executed &lt;em&gt;after&lt;/em&gt; the syntax files;&#xA;there are 2 ways to do this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;From a command or key mapping, this must be invoked manually every time. e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! NoUrlSpell()&#xA;    if &amp;amp;filetype == 'python'&#xA;        :syn match UrlNoSpellComment &quot;\w\+:\/\/[^[:space:]]\+&quot; contains=@NoSpell containedin=pythonComment&#xA;        :highlight def link UrlNoSpellComment Comment&#xA;        :syn match UrlNoSpellString &quot;\w\+:\/\/[^[:space:]]\+&quot; contains=@NoSpell containedin=pythonString&#xA;        :highlight def link UrlNoSpellString String&#xA;    elseif &amp;amp;filetype == 'ruby'&#xA;        &quot; ...&#xA;    else&#xA;        syn match   pythonComment   &quot;#.*$&quot; contains=pythonTodo,@Spell&#xA;    endif&#xA;endfun&#xA;command NoUrlSpell :call NoUrlSpell()&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Put the commands in in the &lt;code&gt;~/.vim/after/syntax/[filetype].vim&lt;/code&gt;. Vim will pick up&#xA;these files and execute them &lt;em&gt;after&lt;/em&gt; the default syntax files (see:&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#after%2ddirectory&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help after-directory&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-07-20T14:49:07.150" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4004" PostTypeId="2" ParentId="3951" CreationDate="2015-07-21T05:38:14.553" Score="0" Body="&lt;p&gt;You can select the text you want to copy by pressing &lt;code&gt;v&lt;/code&gt; and then take it into buffer by pressing &lt;code&gt;y&lt;/code&gt; and then paste it anywhere by &lt;code&gt;p&lt;/code&gt;. It don't inserts any new line.&lt;/p&gt;&#xA;" OwnerUserId="2905" LastEditorUserId="205" LastEditDate="2015-07-21T07:08:34.903" LastActivityDate="2015-07-21T07:08:34.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4005" PostTypeId="1" AcceptedAnswerId="4006" CreationDate="2015-07-21T14:38:37.827" Score="6" ViewCount="5112" Body="&lt;p&gt;I can run this snippit of code within a vimscript block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0read /home/user/.vim/bundle/vim-lorum/lorums/lorum.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As expected, it puts the contents of &quot;lorum.js&quot; into the current buffer&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, I need to make this a little more dynamic. If I try something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:filePath=&quot;/home/user/.vim/bundle/vim-lorum/lorums/lorum.js&quot;&#xA;0read g:filePath&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get this error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E484: Can't open file g:filePath&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried wrapping &lt;em&gt;g:filePath&lt;/em&gt; in &lt;em&gt;expand&lt;/em&gt; and &lt;em&gt;glob&lt;/em&gt; but I get similar errors. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="2312" LastActivityDate="2015-07-21T17:17:45.840" Title="Read file from vimscript variable" Tags="|vimscript|filesystem|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4006" PostTypeId="2" ParentId="4005" CreationDate="2015-07-21T14:50:58.290" Score="9" Body="&lt;p&gt;This is because vim does not evaluate variable names or functions with most commands.  In your case, vim thinks you literally want to read the contents of a file called &lt;code&gt;g:filePath&lt;/code&gt; into the buffer.  What you want can be accomplished with the &lt;code&gt;:execute&lt;/code&gt; command.  This command takes a string as an argument, and will then run that string as a command.  In your case, this is how it would look:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:filePath=&quot;/home/user/.vim/bundle/vim-lorum/lorums/lorum.js&quot;&#xA;:execute &quot;0read &quot; . fnameescape(g:filePath)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;fnameescape&lt;/code&gt; part is just to ensure that all special characters are escaped properly (see &lt;code&gt;:help fnameescape()&lt;/code&gt;).  For more on how to use &lt;code&gt;:execute&lt;/code&gt;, read &lt;code&gt;:help :execute&lt;/code&gt;.  Also note that &lt;code&gt;.&lt;/code&gt; is vim's string concatenation operator.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-07-21T17:17:45.840" LastActivityDate="2015-07-21T17:17:45.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4007" PostTypeId="2" ParentId="4005" CreationDate="2015-07-21T14:51:31.933" Score="6" Body="&lt;p&gt;The solution to this type of problem is the &lt;code&gt;:execute&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute '0read' g:filepath&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :execute&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-07-21T14:51:31.933" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4008" PostTypeId="2" ParentId="4005" CreationDate="2015-07-21T14:58:42.507" Score="6" Body="&lt;p&gt;Commands like &lt;code&gt;read&lt;/code&gt; don't evaluate your variables, it takes the argument to be a literal (a file named &lt;code&gt;g:filePath&lt;/code&gt;). The &lt;code&gt;execute&lt;/code&gt; command, however, takes string arguments, concatenates them and executes the result as if it were a command invocation. You can therefore 'wrap' your command: turn the &lt;code&gt;read&lt;/code&gt; command into a string and pass is together with the variable as arguments to &lt;code&gt;execute&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;0read&quot; g:filePath&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-07-21T14:58:42.507" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4009" PostTypeId="1" AcceptedAnswerId="4011" CreationDate="2015-07-21T23:41:10.763" Score="11" ViewCount="5804" Body="&lt;p&gt;&lt;code&gt;expand(&amp;lt;cword&amp;gt;)&lt;/code&gt; gives me the word under the cursor, but it excludes symbols such as &lt;code&gt;@&lt;/code&gt; or &lt;code&gt;.&lt;/code&gt;. For example, if I call it at the end of &lt;code&gt;@word&lt;/code&gt;, it will get me &lt;code&gt;word&lt;/code&gt; and exclude the &lt;code&gt;@&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way that I could include symbols as part of the current word?&lt;/p&gt;&#xA;" OwnerUserId="2897" LastActivityDate="2015-07-22T08:27:40.967" Title="Include symbols in &lt;cword&gt;" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4010" PostTypeId="1" CreationDate="2015-07-22T00:58:17.737" Score="3" ViewCount="5305" Body="&lt;p&gt;I'm trying to yank to the system clipboard on Ubuntu 14.04. I can't yank into the + or * registers, though. Every time I visually select my text and type &lt;code&gt;&quot;*y&lt;/code&gt; or &lt;code&gt;&quot;+y&lt;/code&gt; the indicator on the bottom right initially indicates the number of lines selected (e.g. &lt;code&gt;4&lt;/code&gt;) while in visual mode. After the next keystroke, &lt;code&gt;&quot;&lt;/code&gt;, it indicates that it is in operator pending mode (lists &lt;code&gt;&quot;&lt;/code&gt; instead of &lt;code&gt;4&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As soon as I press &lt;code&gt;*&lt;/code&gt; the &lt;code&gt;&quot;&lt;/code&gt; changes back to the number of lines selected (&lt;code&gt;4&lt;/code&gt;). Pressing &lt;code&gt;y&lt;/code&gt; after this vim reports that 4 lines were yanked. But they are definitely not in the system clipboard. The exact same thing happens when I try to store the yank in the &lt;code&gt;+&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I have two keyboard layouts configured (Dvorak: primary, QWERTY: secondary). The same thing happens on both layouts.&lt;/li&gt;&#xA;&lt;li&gt;I have stripped down my &lt;code&gt;.vimrc&lt;/code&gt; to an empty file: No luck.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2062" LastActivityDate="2015-07-22T18:32:27.690" Title="Can't yank into * or + registers" Tags="|cut-copy-paste|register|os-clipboard|" AnswerCount="1" CommentCount="10" ClosedDate="2015-07-22T19:17:15.280" ContentLicense="CC BY-SA 3.0" />
  <row Id="4011" PostTypeId="2" ParentId="4009" CreationDate="2015-07-22T01:48:05.597" Score="14" Body="&lt;p&gt;The characters that are included in a Vim &lt;code&gt;word&lt;/code&gt; are set by the &lt;code&gt;'iskeyword'&lt;/code&gt; option. See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help &amp;lt;word&amp;gt;&#xA;:help word&#xA;:help 'iskeyword'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To add another character to this set, such as &lt;code&gt;.&lt;/code&gt;, execute the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set iskeyword+=.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :set+=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the character &lt;code&gt;@&lt;/code&gt; is special, so it has be added like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set iskeyword+=@-@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'isfname'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-07-22T01:48:05.597" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4012" PostTypeId="2" ParentId="4009" CreationDate="2015-07-22T04:10:33.783" Score="9" Body="&lt;p&gt;Use &lt;code&gt;expand(&amp;lt;cWORD&amp;gt;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3a%3ccWORD%3e&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :&amp;lt;cWORD&amp;gt;&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;&amp;lt;cWORD&amp;gt;&lt;/code&gt;    is replaced with the WORD under the cursor (see &lt;code&gt;WORD&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and from &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#WORD&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help WORD&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A WORD consists of a sequence of non-blank characters, separated with white&#xA;  space.  An empty line is also considered to be a WORD.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A sequence of folded lines is counted for one word of a single character.&#xA;  &quot;w&quot; and &quot;W&quot;, &quot;e&quot; and &quot;E&quot; move to the start/end of the first word or WORD after&#xA;  a range of folded lines.  &quot;b&quot; and &quot;B&quot; move to the start of the first word or&#xA;  WORD before the fold.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="21" LastEditorUserId="51" LastEditDate="2015-07-22T08:27:40.967" LastActivityDate="2015-07-22T08:27:40.967" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4013" PostTypeId="1" CreationDate="2015-07-22T15:52:02.083" Score="0" ViewCount="1496" Body="&lt;p&gt;For some reason my Vim won't compile with perl support. Here are my configure options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure \&#xA;   --with-features=huge \&#xA;   --enable-multibyte \&#xA;   --enable-rubyinterp=yes \&#xA;   --enable-pythoninterp=yes \&#xA;   --with-python-config-dir=/usr/lib/python2.7.config-x86_64-linux-gnu \&#xA;   --enable-luainterp \&#xA;   --enable-perlinterp=yes \&#xA;   --enable-gui=gtk2 \&#xA;   --enable-cscope \&#xA;   --prefix=/usr/local&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2865" LastActivityDate="2015-07-22T16:28:05.017" Title="unable to compile vim with perl support on linux" Tags="|linux|installing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4014" PostTypeId="2" ParentId="4013" CreationDate="2015-07-22T16:28:05.017" Score="3" Body="&lt;p&gt;I figured out the problem. libperl-dev package was not installed. Need to have it to have perl enabled in vim.&lt;/p&gt;&#xA;" OwnerUserId="2865" LastActivityDate="2015-07-22T16:28:05.017" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4015" PostTypeId="2" ParentId="4010" CreationDate="2015-07-22T18:32:27.690" Score="1" Body="&lt;p&gt;@statox and @garyjohn, thank you for taking your time to answer. I looked for solutions to this problem before I posted this (I don't like wasting my time). It seems, though, that &lt;a href=&quot;https://askubuntu.com/questions/347519/unable-to-copy-from-vim-to-system-clipboard&quot;&gt;this has been asked before&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, my version of Vim seems not to have been compiled with +clipboard (I had no idea that this was even a thing... How do you guys know everything?). &lt;code&gt;echo has('clipboard')&lt;/code&gt; returns &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@statox, I don't want to recompile Vim. I wouldn't be compiling it again as I downloaded a precompiled binary anyway using apt-get, the aptitude repository manager, but it would still be a pain (making would take forever for vim). So, I have installed vim-gtk and removed vim and I now have access to the system clipboard (checked over ssh). Thanks you guys for pointing me in the right direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a good StackOverflow post &lt;a href=&quot;https://stackoverflow.com/questions/11489428/how-to-make-vim-paste-from-and-copy-to-systems-clipboard&quot;&gt;here&lt;/a&gt; that mentioned this very problem. I may have even read this yesterday when I had my problem but I don't think that I got to this really important paragraph:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Be aware that copying/pasting from the system clipboard will not work if :echo has('clipboard') returns 0. In this case, vim is not compiled with the +clipboard feature and you'll have to install a different version or recompile it. Some linux distros supply a minimal vim installation by default, but generally if you install the vim-gtk package you can get the extra features.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thanks, again, you guys for the help.&lt;/p&gt;&#xA;" OwnerUserId="2062" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-07-22T18:32:27.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4016" PostTypeId="1" CreationDate="2015-07-22T18:43:15.113" Score="3" ViewCount="644" Body="&lt;p&gt;How, in vim, can I jump to the mixin that is &lt;code&gt;@include&lt;/code&gt;ed in a SCSS file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I'd like to put the cursor over &lt;code&gt;avatar&lt;/code&gt; below and hit some magic key in vim that'll take me to that mixin...but how?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#app/assets/stylesheets/application/_global.scss&#xA;&#xA;...&#xA;.avatar {&#xA;  @include avatar(50px);&#xA;  float: left;&#xA;  margin-right: 0.5em;&#xA;}&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ctags&lt;/strong&gt; doesn't pick it up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And typing &lt;code&gt;gf&lt;/code&gt; yields error: &lt;code&gt;Can't find file &quot;avatar.rb&quot; in path&lt;/code&gt;. Which makes me wonder if I might be able to add &lt;code&gt;.scss&lt;/code&gt; as a suffix that &lt;code&gt;gf&lt;/code&gt; will consider because the file I want to jump to is &lt;code&gt;avatar.scss&lt;/code&gt;?!?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried &lt;code&gt;:set suffixesadd+=.scss&lt;/code&gt; to no effect. thoughts?&lt;/p&gt;&#xA;" OwnerUserId="2918" LastEditorUserId="2918" LastEditDate="2015-07-22T19:14:25.653" LastActivityDate="2015-07-22T21:05:42.580" Title="Jump to the definition in a scss file" Tags="|key-bindings|filetype|ctags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4017" PostTypeId="2" ParentId="4016" CreationDate="2015-07-22T20:07:00.670" Score="5" Body="&lt;h2&gt;&lt;code&gt;gf&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The default &lt;code&gt;$VIMRUNTIME/ftplugin/scss.vim&lt;/code&gt; sources &lt;code&gt;$VIMRUNTIME/ftplugin/sass.vim&lt;/code&gt; which already sets everything for you to do &lt;code&gt;gf&lt;/code&gt; over &lt;code&gt;avatar&lt;/code&gt; and jump to &lt;code&gt;avatar.css&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal suffixesadd=.sass,.scss,.css&#xA;setlocal includeexpr=substitute(v:fname,'\\%(.*/\\\|^\\)\\zs','_','')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help gf&#xA;:help 'includeexpr'&#xA;:help 'suffixesadd'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;definition search&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It is also supposed to set everything for doing &lt;code&gt;[&amp;lt;C-d&amp;gt;&lt;/code&gt; over &lt;code&gt;avatar&lt;/code&gt; and jump to the definition of the mixin but there seems to be a problem with the default &lt;code&gt;includeexpr&lt;/code&gt; that prevents the otherwise correctly recognized includes to be correctly processed. Resetting that option fixes the issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal includeexpr=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adding the line above to &lt;code&gt;~/.vim/after/ftplugin/scss.vim&lt;/code&gt; should do the trick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant lines in &lt;code&gt;$VIMRUNTIME/ftplugin/sass.vim&lt;/code&gt; are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal define=^\\s*\\%(@mixin\\\|=\\)&#xA;setlocal includeexpr=substitute(v:fname,'\\%(.*/\\\|^\\)\\zs','_','')&#xA;setlocal suffixesadd=.sass,.scss,.css&#xA;let &amp;amp;l:include = '^\s*@import\s\+\%(url(\)\=[&quot;'']\='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'define'&#xA;:help 'includeexpr'&#xA;:help 'suffixesadd'&#xA;:help 'include'&#xA;:help :let-&amp;amp;&#xA;:help definition-search&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;ctags&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you use ctags, adding the lines below to &lt;code&gt;~/.ctags&lt;/code&gt; will give you a reasonably good sass support:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--langdef=scss&#xA;--langmap=scss:.scss&#xA;--regex-scss=/^[ \t]*@mixin ([A-Za-z0-9_-]+)/\1/m,mixin,mixins/&#xA;--regex-scss=/^[ \t]*\$([A-Za-z0-9_-]+)/\1/v,variable,variables/&#xA;--regex-scss=/^([A-Za-z0-9_-]*)*(\.[A-Za-z0-9_-]+) *[,{]/\2/c,class,classes/&#xA;--regex-scss=/^[ \t]+(\.[A-Za-z0-9_-]+) *[,{]/\1/c,class,classes/&#xA;--regex-scss=/^(.*)*\#([A-Za-z0-9_-]+) *[,{]/\2/i,id,ids/&#xA;--regex-scss=/^[ \t]*#([A-Za-z0-9_-]+)/\1/i,id,ids/&#xA;--regex-scss=/(^([A-Za-z0-9_-])*([A-Za-z0-9_-]+)) *[,|\{]/\1/t,tag,tags/&#xA;--regex-scss=/(^([^\/\/])*)[ \t]+([A-Za-z0-9_-]+)) *[,|\{]/\3/t,tag,tags/&#xA;--regex-scss=/(^(.*, *)([A-Za-z0-9_-]+)) *[,|\{]/\3/t,tag,tags/&#xA;--regex-scss=/(^[ \t]+([A-Za-z0-9_-]+)) *[,|\{]/\1/t,tag,tags/&#xA;--regex-scss=/^[ \t]*@media\s+([A-Za-z0-9_-]+)/\1/d,media,media/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help tags&#xA;:help ctags&#xA;$ man ctags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a demo of the three methods above, in the same order:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5FjZq.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5FjZq.gif&quot; alt=&quot;scss&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-07-22T21:05:42.580" LastActivityDate="2015-07-22T21:05:42.580" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4018" PostTypeId="1" AcceptedAnswerId="4020" CreationDate="2015-07-23T04:27:44.077" Score="4" ViewCount="191" Body="&lt;p&gt;I will frequently use visual mode and the &quot;norm&quot; command to quickly comment out several lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say this is my text (line numbers added for clarity):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.  #include &amp;lt;iostream&amp;gt;&#xA;2.  using namespace std;&#xA;3.   &#xA;4.  int main()&#xA;5.  {&#xA;6.     cout &amp;lt;&amp;lt; &quot;Hello world!\n&quot;;&#xA;7.     return 0;&#xA;8.  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And my cursor is on line 6. I hit 'v', 'j', and then &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;norm 0i//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;now my text is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.  #include &amp;lt;iostream&amp;gt;&#xA;2.  using namespace std;&#xA;3.   &#xA;4.  int main()&#xA;5.  {&#xA;6.  //   cout &amp;lt;&amp;lt; &quot;Hello world!\n&quot;;&#xA;7.  //   return 0;&#xA;8.  } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and my cursor is on the second '/' on line 7.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now, every new line I open starts with '//'. For example, if I hit 'o', and then enter twice, it will look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.  #include &amp;lt;iostream&amp;gt;&#xA;2.  using namespace std;&#xA;3.   &#xA;4.  int main()&#xA;5.  {&#xA;6.  //   cout &amp;lt;&amp;lt; &quot;Hello world!\n&quot;;&#xA;7.  //   return 0;&#xA;8.  //&#xA;9.  //&#xA;10. //&#xA;11. }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will also do this with &lt;code&gt;'A&amp;lt;cr&amp;gt;'&lt;/code&gt; and &lt;code&gt;'O'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What causes this? Is this a bug? Is there a way to get around it? It's not &lt;em&gt;super&lt;/em&gt; annoying, but it does throw me off a little bit. That and I'm really curious at what causes this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it matters at all, I am using Ubuntu 15.04 and vim 7.4.488.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2015-07-23T05:47:28.147" LastActivityDate="2015-07-23T12:32:25.517" Title="Why are new lines under commented lines automatically commented too?" Tags="|visual-mode|comments|" AnswerCount="2" CommentCount="1" ClosedDate="2015-07-23T12:33:03.123" ContentLicense="CC BY-SA 3.0" />
  <row Id="4019" PostTypeId="1" AcceptedAnswerId="4021" CreationDate="2015-07-23T04:33:57.240" Score="0" ViewCount="183" Body="&lt;p&gt;I'm attempting to open the recently released source files of the ancient &lt;a href=&quot;http://www.computerhistory.org/_static/atchm/electronic-arts-deluxepaint-early-source-code/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;DeluxePaint&lt;/em&gt;&lt;/a&gt; on MacVim, however, every file has an unexpected sequence of &lt;code&gt;^Z^Z^Z^Z^Z...&lt;/code&gt; characters at the end:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/t7ZX4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/t7ZX4.png&quot; alt=&quot;unexpected characters&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;What are those stray characters? Something related to a file encoding used back in the 80s by some editor?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How to I get rid of them? I would like to convert the files to utf-8 or ascii, so that they display properly on any modern text editor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1045" LastActivityDate="2015-07-23T05:49:43.900" Title="Old source code files display unexpected characters" Tags="|macvim|encoding|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4020" PostTypeId="2" ParentId="4018" CreationDate="2015-07-23T05:23:54.967" Score="8" Body="&lt;p&gt;This has nothing todo with the &lt;code&gt;normal&lt;/code&gt; command or the visual block. This is due to a setting &lt;code&gt;'formatoptions'&lt;/code&gt;, see &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27formatoptions%27&quot;&gt;&lt;code&gt;:help 'formatoptions'&lt;/code&gt;&lt;/a&gt;. In particular, the mentioned behaviour comes from the flags &lt;code&gt;r&lt;/code&gt; and &lt;code&gt;o&lt;/code&gt;. If you don't like the behaviour, you can turn it off with &lt;code&gt;:set fo-=ro&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#fo-table&quot;&gt;&lt;code&gt;:help fo-table&lt;/code&gt;&lt;/a&gt; for the available flags.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2015-07-23T06:44:10.897" LastActivityDate="2015-07-23T06:44:10.897" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4021" PostTypeId="2" ParentId="4019" CreationDate="2015-07-23T05:49:43.900" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;^Z&lt;/code&gt; is a control character more or less synonymous with EOF (end of file). Maybe they were mandatory for the compiler used by the author?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you have that line in every file in the project:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argadd **/*&#xA;:argdo g/&amp;lt;C-v&amp;gt;&amp;lt;C-z&amp;gt;/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;C-z&amp;gt;&lt;/code&gt; is &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; followed by &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Z&lt;/kbd&gt;, it should insert &lt;code&gt;^Z&lt;/code&gt; and make the command look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdo g/^Z/d&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-07-23T05:49:43.900" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4022" PostTypeId="1" AcceptedAnswerId="4025" CreationDate="2015-07-23T06:16:37.873" Score="1" ViewCount="1042" Body="&lt;p&gt;Size of one file is 200 Mb, while the size of another file is 20 Mb. &#xA;I need to press &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt; to stop loading the big file, when no vimdiff mode is enabled although I run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff &amp;lt;(hexdump -C r328.raw) &amp;lt;(hexdump -C r328_000.raw)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I am here now but I would like to have colours for differences:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YqH96.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YqH96.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can you start vimdiff of two files in vertical mode?&lt;/p&gt;&#xA;" OwnerUserId="2923" LastEditorUserId="2923" LastEditDate="2015-07-23T09:25:27.047" LastActivityDate="2019-12-28T19:35:50.280" Title="How to start vimdiff in Vertical mode?" Tags="|vimdiff|" AnswerCount="3" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4024" PostTypeId="2" ParentId="4018" CreationDate="2015-07-23T12:30:05.977" Score="0" Body="&lt;p&gt;It's because your block includes the start of the next line (because you pressed &lt;code&gt;j&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;V&lt;/code&gt; (upper case) to start your block, then you'll just have the line you want without pressing &lt;code&gt;j&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2933" LastEditorUserId="51" LastEditDate="2015-07-23T12:32:25.517" LastActivityDate="2015-07-23T12:32:25.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4025" PostTypeId="2" ParentId="4022" CreationDate="2015-07-23T18:11:12.000" Score="6" Body="&lt;p&gt;You could use use the &lt;code&gt;--length&lt;/code&gt; option of hexdump to only load 20Mb of the large file so you don't have to cancel what Vim is doing as @Carpetsmoker mentioned.  Ex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff &amp;lt;(hexdump -C --length=20000000 big) &amp;lt;(hexdump -C small)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="355" LastActivityDate="2015-07-23T18:11:12.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4026" PostTypeId="1" AcceptedAnswerId="4029" CreationDate="2015-07-23T21:17:49.247" Score="4" ViewCount="185" Body="&lt;p&gt;Let's assume I work on a C program file which has 10 functions. During one review, I changed their return types, return values and I added some checks/documentation. After some time I realize that while the checks and the documentation I added are fine, I shouldn't modify the return types. And this goes to the folowing, more general question?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to explore the undo tree and select the modifications that I want?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gundo seems very close to what I want. The interface is ideal, as I have a diff view and a browser view of the modifications I made. But is there a way to go to a certain state and select the updates that I want to keep?&lt;/p&gt;&#xA;" OwnerUserId="2938" LastActivityDate="2015-07-29T23:39:02.973" Title="Undo certain modifications" Tags="|undo-redo|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4027" PostTypeId="1" AcceptedAnswerId="4030" CreationDate="2015-07-24T07:15:52.453" Score="5" ViewCount="1374" Body="&lt;p&gt;I am trying to create a (git) repository for my vim files. Now, I am already struggling as to what directory I would store my files under. As far as I can see there is either &lt;code&gt;%HOME%&lt;/code&gt; or &lt;code&gt;%VIM%&lt;/code&gt;, right? Naturally, I feel more inclined to use &lt;code&gt;%VIM%&lt;/code&gt;. So I go&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set VIM=x:\path\to\repo&#xA;&#xA;cd %VIM%&#xA;&#xA;notepad vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to create a basic vimrc file in my repo. The &lt;code&gt;vimrc&lt;/code&gt; also contains &lt;code&gt;syntax enable&lt;/code&gt;. Now, when I start gvim and the startup process reaches the &lt;code&gt;syntax enable&lt;/code&gt; line, it gives an error message:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Error detected while processing x:\path\to\repo\vimrc&lt;br&gt;&#xA;  line 86&lt;br&gt;&#xA;  E484: Can't open file x:\path\to\repo\syntax\syntax.vim&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This seems to be because vim automatically sets &lt;code&gt;$VIMRUNTIME&lt;/code&gt; to the value of &lt;code&gt;$VIM&lt;/code&gt; if &lt;code&gt;$VIM&lt;/code&gt; is set. This is of course not what I want, since I was happy with vim's default determining of &lt;code&gt;$VIMRUNTIME&lt;/code&gt; at startup. Neither do I want to globally set &lt;code&gt;%VIMRUNTIME%&lt;/code&gt; as I don't want to change it if I install a newer vim version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what is the canonical way to keep my personal vim files in a repository?&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2016-02-19T17:44:46.580" Title="Keeping personal vimrc and syntax files etc in source control?" Tags="|vimrc|microsoft-windows|git|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4028" PostTypeId="2" ParentId="4027" CreationDate="2015-07-24T08:15:16.927" Score="2" Body="&lt;p&gt;I have a repository called &lt;code&gt;rc&lt;/code&gt; which contains a &lt;code&gt;install.sh&lt;/code&gt; script and all my runtime configurations. My workflow is like so:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;On a machine, hack &lt;code&gt;~/.vimrc&lt;/code&gt; till I am happy with it.&lt;/li&gt;&#xA;&lt;li&gt;Copy &lt;code&gt;~/.vimrc&lt;/code&gt; to &lt;code&gt;rc/vimrc&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Add, commit with a useful message, and push.&lt;/li&gt;&#xA;&lt;li&gt;On a different machine: fetch+merge rc.&lt;/li&gt;&#xA;&lt;li&gt;Run &lt;code&gt;install.sh&lt;/code&gt; which takes a backup of the current file and copies the repository one over the current one.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Clearly this works on *nix and not on Windows. However, the method could be easily adapted. How to do this is left as an exercise for the reader&lt;sup&gt;1&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&lt;sup&gt;1. Mostly because I have no idea how to it myself!&lt;/sup&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="622" LastEditorUserId="205" LastEditDate="2015-07-31T12:42:58.320" LastActivityDate="2015-07-31T12:42:58.320" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4029" PostTypeId="2" ParentId="4026" CreationDate="2015-07-24T08:19:50.113" Score="4" Body="&lt;p&gt;The &lt;code&gt;gundo&lt;/code&gt; plugin has a preview window, where it shows the diff between the selected version and the previous one.  You can locate the relevant changes in the change tree, then go to the preview window, save the buffer to a patch file, then edit the file to keep the relevant changes, then reverse the patch.  Something like &lt;a href=&quot;https://github.com/sgeb/vim-diff-fold&quot; rel=&quot;nofollow noreferrer&quot;&gt;diff-fold&lt;/a&gt; and / or &lt;a href=&quot;http://cyberelk.net/tim/software/patchutils/&quot; rel=&quot;nofollow noreferrer&quot;&gt;patchutils&lt;/a&gt; can make your life easier when editing the patch.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-07-24T08:19:50.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4030" PostTypeId="2" ParentId="4027" CreationDate="2015-07-24T08:59:02.753" Score="11" Body="&lt;p&gt;Since 7.4, all your configuration files (even your vimrc) are expected to be in this directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%userprofile%\vimfiles\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the name and location of that directory only matter to Vim. From Git's point of view, that directory could as well be &lt;code&gt;/etc/foo/bar/&lt;/code&gt; without any impact whatsoever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;put your &lt;code&gt;vimrc&lt;/code&gt; and all your third-party scripts in  &lt;code&gt;%userprofile%\vimfiles\&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;put that directory under version control.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;When you need to clone your repo on a unix-like system you do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ git clone &amp;lt;remote url&amp;gt; ~/.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or, in git bash on Windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ git clone &amp;lt;remote url&amp;gt; $HOME/vimfiles&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No need to mess with environment variables.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-07-29T10:10:34.350" LastActivityDate="2015-07-29T10:10:34.350" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4031" PostTypeId="1" AcceptedAnswerId="4032" CreationDate="2015-07-24T09:33:06.333" Score="11" ViewCount="472" Body="&lt;p&gt;Sometimes I use marks to navigate easily through different files using &lt;code&gt;mA&lt;/code&gt;, &lt;code&gt;mB&lt;/code&gt;... and &lt;code&gt;'A&lt;/code&gt;, &lt;code&gt;'B&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And sometime (more often than I'd like to admit) because of inattention or whatever the reason is, I use &lt;code&gt;m[LETTER]&lt;/code&gt; with an already existing mark which erase its previous value when I don't want to. Most of the time when I do that I don't have open the file originally pointed by the mark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case when I immedialy realized that I made a mistake, is it possible to get the previous value of my mark other than remembering where it was pointing to, navigating to this location and setting it again? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't found a command like that in the doc so if that doesn't exist is there a clever workaround that some of you use in this situation?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-07-24T12:45:20.987" Title="Set a mark to its previous value" Tags="|mark|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4032" PostTypeId="2" ParentId="4031" CreationDate="2015-07-24T11:45:25.883" Score="7" Body="&lt;p&gt;Here is some basic VimScript which roughly does what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We override the &lt;code&gt;ma&lt;/code&gt; through &lt;code&gt;mz&lt;/code&gt; mappings to store the current value in &lt;code&gt;g:previous_marks&lt;/code&gt; before calling the original &lt;code&gt;m&lt;/code&gt; to actually set the mark. We also define &lt;code&gt;&amp;lt;Leader&amp;gt;ma&lt;/code&gt; through &lt;code&gt;&amp;lt;Leader&amp;gt;mz&lt;/code&gt; to show the history for said mark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will probably want to store the info in &lt;code&gt;g:previous_marks&lt;/code&gt; in a more organized way, and add the ability to quickly restore a mark (rather than just  seeing the locations), but this example shows how it can be done, further tweaks are left as an exercise to the reader ;-)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:previous_marks = {}&#xA;fun! MyMark(mark)&#xA;    let l:marks = ''&#xA;    redir =&amp;gt; l:marks&#xA;        try&#xA;            silent! execute 'marks ' . a:mark&#xA;        catch&#xA;        endtry&#xA;    redir END&#xA;&#xA;    if l:marks != ''&#xA;        if !has_key(g:previous_marks, a:mark)&#xA;            let g:previous_marks[a:mark] = []&#xA;        endif&#xA;        call add(g:previous_marks[a:mark], split(l:marks, &quot;\n&quot;)[1])&#xA;    endif&#xA;&#xA;    execute 'normal! m' . a:mark&#xA;endfun&#xA;&#xA;fun! ShowHistory(mark)&#xA;    if !has_key(g:previous_marks, a:mark)&#xA;        echoerr 'No history for ' . a:mark&#xA;        return&#xA;    endif&#xA;&#xA;    for l:line in g:previous_marks[a:mark]&#xA;        echo l:line&#xA;    endfor&#xA;endfun&#xA;&#xA;fun! MakeMappings()&#xA;    for l:char in range(97, 122)&#xA;        let l:char = nr2char(l:char)&#xA;&#xA;        execute 'nnoremap &amp;lt;silent&amp;gt; m' . l:char . ' :call MyMark(&quot;' . l:char . '&quot;)&amp;lt;CR&amp;gt;'&#xA;        execute 'nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;m' . l:char . ' :call ShowHistory(&quot;' . l:char . '&quot;)&amp;lt;CR&amp;gt;'&#xA;    endfor&#xA;endfun&#xA;&#xA;call MakeMappings()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-07-24T11:45:25.883" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4033" PostTypeId="2" ParentId="4031" CreationDate="2015-07-24T11:52:45.503" Score="2" Body="&lt;p&gt;Since the actual problem seems to be navigation between multiple files/positions, I'd suggest this simple solution, which is based on the &lt;a href=&quot;https://github.com/Shougo/unite.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Unite&lt;/a&gt; plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Unite jump -auto-preview&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command (which can be mapped to something like &lt;code&gt;&amp;lt;leader&amp;gt;j&lt;/code&gt; for example) will show the jump list, &lt;em&gt;with&lt;/em&gt; a preview: each time you navigate the list with &lt;code&gt;j&lt;/code&gt;/&lt;code&gt;k&lt;/code&gt;, several lines around the cursor position in that file will be displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8KYbv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8KYbv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Alternative:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The default marks are so easy to be overwritten: perhaps &lt;em&gt;named&lt;/em&gt; bookmarks would better fit your use case, e.g. with the &lt;a href=&quot;https://github.com/AndrewRadev/simple_bookmarks.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;simple_bookmarks&lt;/a&gt; plugin.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-07-24T12:45:20.987" LastActivityDate="2015-07-24T12:45:20.987" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4034" PostTypeId="2" ParentId="4031" CreationDate="2015-07-24T11:53:24.463" Score="2" Body="&lt;p&gt;Not exactly what you want, but perhaps more useful: the &lt;a href=&quot;https://github.com/kshenoy/vim-signature&quot; rel=&quot;nofollow&quot;&gt;signature&lt;/a&gt; plugin.  It shows the current marks as signs in the gutter margin, and has simple shortcuts for editing them.  It can also put the list of signs in a location list for quick access.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-07-24T11:53:24.463" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4035" PostTypeId="1" CreationDate="2015-07-24T23:00:27.000" Score="7" ViewCount="1011" Body="&lt;p&gt;I found that it's really hard for me to hit &lt;kbd&gt;Control&lt;/kbd&gt; and other keys simultaneously, and I discovered that the &lt;kbd&gt;space&lt;/kbd&gt; key is rarely used, so I decided to map it to &lt;kbd&gt;Control&lt;/kbd&gt; . Thus, when I want to hit &lt;kbd&gt;Control&lt;/kbd&gt;+ &lt;kbd&gt;f&lt;/kbd&gt; for scrolling, I can instead hit &lt;kbd&gt;space&lt;/kbd&gt;+ &lt;kbd&gt;f&lt;/kbd&gt;, which would be a lot easier.&#xA;But with this line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Space&amp;gt; &amp;lt;C&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;nothing change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do that? Is it possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, is it a good practice to map &lt;kbd&gt;Space&lt;/kbd&gt;  to &lt;kbd&gt;Control &lt;/kbd&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="2206" LastEditorUserId="1841" LastEditDate="2015-07-25T11:33:46.550" LastActivityDate="2015-07-27T15:16:16.143" Title="why can't I map &lt;Space&gt; to &lt;C&gt;?" Tags="|key-bindings|vimrc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4036" PostTypeId="2" ParentId="688" CreationDate="2015-07-25T14:25:01.537" Score="2" Body="&lt;p&gt;A bit hackish solution might be the following (everything written between &amp;lt; and &gt; are to be inserted after pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%normal :redir @&quot;&amp;lt;Enter&amp;gt;:-=&amp;lt;Enter&amp;gt;:redir END&amp;lt;Enter&amp;gt;I&amp;lt;C-R&amp;gt;&quot;.&amp;lt;Tab&amp;gt;&amp;lt;Esc&amp;gt;kdd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Deconstruction&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%normal {commands}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;runs normal mode command on each line specified by the range, in this case every line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;redirects every output made by ex commands to the unnamed buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is an ex command that outputs the current line number (with a preceding newline unfortunately)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;stops redirecting to the unnamed buffer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I&amp;lt;C-R&amp;gt;&quot;.&amp;lt;Tab&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;inserts the content of the unnamed buffer with a . and a tab to to front of each line and exits from insert mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;kdd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;goes one line up and removes the newline which is the result of the :.= command.&lt;/p&gt;&#xA;" OwnerUserId="2726" LastActivityDate="2015-07-25T14:25:01.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4037" PostTypeId="1" AcceptedAnswerId="4039" CreationDate="2015-07-26T17:03:58.023" Score="2" ViewCount="108" Body="&lt;p&gt;When creating visual mode maps, you prefix ex commands with &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; to clear out the range if it's unused:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:xnoremap % :&amp;lt;C-u&amp;gt;execute 'normal! gv'&amp;lt;Bar&amp;gt;call Percent_nextline()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(example from &lt;a href=&quot;https://vi.stackexchange.com/questions/2820/how-to-make-a-movement-function-work-with-delete-yank-etc/2821#2821&quot;&gt;How to make a movement function work with delete, yank, etc&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But is there any point in doing so for normal maps? I can't imagine any scenario where a normal noremap ends up with text in the cmdline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In summary, do I ever need this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap % :&amp;lt;C-u&amp;gt;call Percent_nextline()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;over this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap % :call Percent_nextline()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2045" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-07-26T17:57:40.803" Title="Is there any point in using C-u in an nmap?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4038" PostTypeId="1" CreationDate="2015-07-26T17:44:09.937" Score="8" ViewCount="2250" Body="&lt;p&gt;I've narrowed down a bug in a program I'm working on to (surprisingly) some vim behavior!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program contains a file watcher.&#xA;When I write a file with &lt;code&gt;vim -u NONE&lt;/code&gt; and all the default settings, the behavior is as expected: some swap files are created and deleted, and the main file is saved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I add &lt;code&gt;:set nocompatible&lt;/code&gt;, I get the following additional inotify events:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wd=149, mask=IN_CREATE (0x100), cookie=0, length=16, name='4913'&#xA;wd=149, mask=IN_ATTRIB (0x4), cookie=0, length=16, name='4913'&#xA;wd=149, mask=IN_DELETE (0x200), cookie=0, length=16, name='4913'&#xA;&amp;lt;normal events appear after&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This indicates that vim is creating, modifying, and then deleting a file called &lt;code&gt;4913&lt;/code&gt; in the directory of the file I'm editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I create such a file myself (and &lt;code&gt;chmod 000&lt;/code&gt; it), vim will use &lt;code&gt;5036&lt;/code&gt; instead.&#xA;This leads me to believe that vim is looking for some arbitrary temporary file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The number is always &lt;code&gt;4913&lt;/code&gt; (across files, across reboots).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is quite alarming.&#xA;I obviously want to use &lt;code&gt;nocompatible&lt;/code&gt;, but this is a prohibitive bug.&#xA;What can I do?&lt;/p&gt;&#xA;" OwnerUserId="142" LastEditorUserId="142" LastEditDate="2015-07-26T18:17:10.070" LastActivityDate="2016-08-28T19:53:26.133" Title="Why does `set nocompatible` result in vim saving extra, all-numeric temporary files?" Tags="|save|linux|swap-file|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4039" PostTypeId="2" ParentId="4037" CreationDate="2015-07-26T17:57:40.803" Score="7" Body="&lt;p&gt;The point of &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; is to make the macro not bail out when used with a count.  If you press, say, &lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt; in normal mode you'll get &lt;code&gt;.,.+2&lt;/code&gt; inserted automatically on the command line.  This seldom makes sense for the map being defined.  Of course this is more useful if your macro cares about counts (see &lt;code&gt;:help v:count&lt;/code&gt; for an example), but even if it doesn't, adding &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; makes the macro tolerant to being called (perhaps inadvertently) with a count.  Pressing &lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;%&lt;/kbd&gt; is an error with your definition, but works just fine with the original definition.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-07-26T17:57:40.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4041" PostTypeId="1" AcceptedAnswerId="4042" CreationDate="2015-07-27T10:42:15.400" Score="4" ViewCount="1793" Body="&lt;p&gt;I am working on a CentOs machine. &lt;strong&gt;Vim works fine&lt;/strong&gt;. But when I &lt;code&gt;git commit -v&lt;/code&gt; It seems that something is wrong:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[vagrant@localhost dotfiles]$ git add .&#xA;[vagrant@localhost dotfiles]$ git commit -v&#xA;Error detected while processing /home/vagrant/.vimrc:&#xA;line    6:&#xA;E492: Not an editor command: Plugin 'gmarik/Vundle.vim'            &quot; vim bundle manager&#xA;line    7:&#xA;E492: Not an editor command: Plugin 'kien/ctrlp.vim'               &quot; finder ...&#xA;line    8:&#xA;E492: Not an editor command: Plugin 'fugitive.vim'                 &quot; git integration&#xA;line    9:&#xA;E492: Not an editor command: Plugin 'MarcWeber/vim-addon-mw-utils' &quot; add your local vimrc&#xA;line   10:&#xA;E492: Not an editor command: Plugin 'tomtom/tlib_vim'&#xA;line   11:&#xA;E492: Not an editor command: Plugin 'garbas/vim-snipmate'          &quot; add snippets to your vim&#xA;line   12:&#xA;E492: Not an editor command: Plugin 'scrooloose/nerdtree'          &quot; tree of files and folders&#xA;line   13:&#xA;E492: Not an editor command: Plugin 'tommcdo/vim-lion'             &quot; align equals&#xA;line   14:&#xA;E492: Not an editor command: Bundle 'vim-php/vim-composer'&#xA;line   29:&#xA;E518: Unknown option: foldlevel=1&#xA;line   30:&#xA;E518: Unknown option: foldlevelstart=42&#xA;line   31:&#xA;E518: Unknown option: foldmethod=indent&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2965" LastEditorUserId="2965" LastEditDate="2015-07-27T17:04:19.510" LastActivityDate="2015-10-08T14:57:20.700" Title="Error while processing .vimrc in vagrant when I run `git commit -v`" Tags="|plugin-vundle|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4042" PostTypeId="2" ParentId="4041" CreationDate="2015-07-27T11:20:46.697" Score="2" Body="&lt;p&gt;The error comes from the fact that Vundle isn't installed on your vagrant VM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should connect to your VM, issue the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And issue &lt;code&gt;:PluginInstall&lt;/code&gt; in vim on your VM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it is possible to use puppet to pre-configure your vagrant installation to include Vundle but I never tried it; I always do it manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you might be interested in a scrip like &lt;a href=&quot;https://gist.github.com/fideloper/7552992&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; to get inspiration on how to automatically add Vundle to a fresh install &lt;em&gt;(as said in the article linked on top of the page the script works only with an empty &lt;code&gt;.vimrc&lt;/code&gt;. I give you this link only as an inspiration)&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="205" LastEditDate="2015-07-27T11:52:31.627" LastActivityDate="2015-07-27T11:52:31.627" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4043" PostTypeId="2" ParentId="4035" CreationDate="2015-07-27T13:22:01.910" Score="5" Body="&lt;p&gt;Unfortunately I think that the comment of EvergreenTree is right: you can't map &lt;kbd&gt;ctrl&lt;/kbd&gt; as a single key into vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I tried to get what you want using the &lt;code&gt;langmap&lt;/code&gt; option which allows to substitute a key with another one in normal mode. I thought something like &lt;code&gt;set langmap +=\ ^&lt;/code&gt; could have worked but it doesn't (with that, &lt;kbd&gt;Space&lt;/kbd&gt; get your cursor at the beginning of the line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So  the best I could suggest to you is to add the following lines to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RemapSpaceToCtrl()&#xA;    for l:char in range(97, 122)&#xA;        let l:char = nr2char(l:char)&#xA;&#xA;        execute 'nnoremap &amp;lt;silent&amp;gt; &amp;lt;Space&amp;gt;' . l:char . ' &amp;lt;C-' . l:char . '&amp;gt;&amp;lt;CR&amp;gt;'&#xA;    endfor&#xA;endfunction&#xA;&#xA;call RemapSpaceToCtrl()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function maps &lt;code&gt;&amp;lt;Space&amp;gt;X&lt;/code&gt; to &lt;code&gt;&amp;lt;C-X&amp;gt;&lt;/code&gt; where &lt;code&gt;X&lt;/code&gt; is all the letters of the alphabet. This way &lt;kbd&gt;Space&lt;/kbd&gt; + &lt;kbd&gt;a&lt;/kbd&gt; increments a number, &lt;kbd&gt;Space&lt;/kbd&gt; + &lt;kbd&gt;f&lt;/kbd&gt; goes down one page etc...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's probably not the cleanest solution and you might want to improve it but that could be a workaround.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;To render unto Caesar the things which are Caesar's I get inspiration to map a prefix followed by different letters to another prefix followed by the letters from a function written by CarpetSmoker &lt;a href=&quot;https://vi.stackexchange.com/a/4032/1841&quot;&gt;here&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-07-27T15:16:16.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4044" PostTypeId="1" AcceptedAnswerId="4045" CreationDate="2015-07-27T19:16:32.523" Score="1" ViewCount="929" Body="&lt;p&gt;This one beats me after 30 years of vi/vim usage... Context: I'm on FreeBSD using the latest vim (7.4.796). A month or so ago, syntax highlighting in xterm(318) started acting up. In particular, the highlighting of comments is cyan, not the expected gray.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To track this down I have done the following.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strip down my &lt;code&gt;~/.vimrc&lt;/code&gt; to these few lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim .vimrc&#xA;  1 &quot; Normal must be set before colors &quot;fg&quot; and &quot;bg&quot; can be used.&#xA;  2 highlight Normal ctermfg=216 ctermbg=233&#xA;  3&#xA;  4 &quot; gray        This comment.&#xA;  5 highlight Comment   cterm=NONE      ctermfg=250     ctermbg=bg&#xA;  6&#xA;  7 &quot; Line numbers indicate this .vimrc was read.&#xA;  8 set number&#xA;  9 syntax enable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the line numbers appear; color 250 is gray in my &lt;code&gt;TERM=xterm-256color&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have moved away my &lt;code&gt;~/.vim&lt;/code&gt; directory to avoid any local plugin interference.&#xA;Interestingly, when I &lt;code&gt;:so .vimrc&lt;/code&gt; the correct color for the comments is used. It appears as if &lt;em&gt;only&lt;/em&gt; the highlighting stuff is ignored upon startup, but works when sourced explicitly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT #1&lt;/strong&gt;: I don't have any &lt;code&gt;VIM&lt;/code&gt; environment variable set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT #2&lt;/strong&gt;: &lt;code&gt;:verbose hi Comment&lt;/code&gt; says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Comment        xxx term=bold ctermfg=14 guifg=#80a0ff&#xA;Last set from /usr/local/share/vim/vim74/syntax/syncolor.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT #3&lt;/strong&gt;: &lt;code&gt;:scriptnames&lt;/code&gt; says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: ~/.vimrc&#xA;  2: /usr/local/share/vim/vim74/syntax/syntax.vim&#xA;  3: /usr/local/share/vim/vim74/syntax/synload.vim&#xA;  4: /usr/local/share/vim/vim74/syntax/syncolor.vim&#xA;  5: /usr/local/share/vim/vim74/filetype.vim&#xA;  6: /usr/local/share/vim/vim74/plugin/getscriptPlugin.vim&#xA;  7: /usr/local/share/vim/vim74/plugin/gzip.vim&#xA;  8: /usr/local/share/vim/vim74/plugin/logiPat.vim&#xA;  9: /usr/local/share/vim/vim74/plugin/matchparen.vim&#xA; 10: /usr/local/share/vim/vim74/plugin/netrwPlugin.vim&#xA; 11: /usr/local/share/vim/vim74/plugin/rrhelper.vim&#xA; 12: /usr/local/share/vim/vim74/plugin/spellfile.vim&#xA; 13: /usr/local/share/vim/vim74/plugin/tarPlugin.vim&#xA; 14: /usr/local/share/vim/vim74/plugin/tohtml.vim&#xA; 15: /usr/local/share/vim/vim74/plugin/vimballPlugin.vim&#xA; 16: /usr/local/share/vim/vim74/plugin/zipPlugin.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I ran out of ideas what is going on here and how to fix it. Someone hit me with the clue bat, please.&lt;/p&gt;&#xA;" OwnerUserId="2347" LastEditorUserId="2347" LastEditDate="2015-07-27T21:44:05.510" LastActivityDate="2015-07-27T22:28:05.753" Title="vimrc contents selectively (i.e. highlight) ignored" Tags="|vimrc|syntax-highlighting|terminal|highlight|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="4045" PostTypeId="2" ParentId="4044" CreationDate="2015-07-27T22:28:05.753" Score="5" Body="&lt;p&gt;Patches 7.4.757 on June 25, 7.4.766 on July 3, and 7.4.770 on July 10 added a feature to Vim in terminal mode that queries the terminal for its background color using the T_RGB escape sequence. When Vim receives the background color response from the terminal and the received background is different from the default (light), Vim changes the highlight colors to be compatible with the new background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A little testing verifies that Vim 7.4.729 running in xterm 318 starts with 'background' = light, but Vim 7.4.797 automatically sets 'background' = dark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A solution is to put&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=light&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your &lt;code&gt;~/.vimrc&lt;/code&gt;. I &lt;em&gt;think&lt;/em&gt; that setting this tells Vim not to query the terminal. It may just tell Vim to ignore the terminal's response to the background color query.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find out a little about the effect of setting 'background' from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'background'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I haven't found any documentation on this automatic setting feature.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-07-27T22:28:05.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4046" PostTypeId="1" AcceptedAnswerId="4047" CreationDate="2015-07-28T12:11:52.897" Score="3" ViewCount="255" Body="&lt;p&gt;I have two files open, say &lt;code&gt;File.h&lt;/code&gt; and &lt;code&gt;File.m&lt;/code&gt; in separate tabs. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-----------------------------------&#xA;| File.h         |  File.m        |&#xA;-----------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:ls&lt;/code&gt; reveals&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls&#xA;  1 %a   &quot;File.h&quot; line 1&#xA;  2  a   &quot;File.m&quot; line 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo set fo=croql&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suddenly have two tabs with the same content&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-----------------------------------&#xA;| File.m         |  File.m        |&#xA;-----------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but &lt;code&gt;:ls&lt;/code&gt; gives the output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls&#xA;  1 #    &quot;File1.h&quot; line 1&#xA;  2 %a   &quot;File2.m&quot; line 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't understand from the documentation what the &lt;code&gt;#&lt;/code&gt; char means here, except that I can &lt;code&gt;:e #&lt;/code&gt; to get back to the initial configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can somebody elucidate what is happening here?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastEditorUserId="1066" LastEditDate="2015-07-29T05:38:18.020" LastActivityDate="2015-07-29T05:38:18.020" Title="Why does ':bufdo set fo=*' change window contents?" Tags="|buffers|multiple-files|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4047" PostTypeId="2" ParentId="4046" CreationDate="2015-07-28T13:47:23.687" Score="1" Body="&lt;p&gt;&lt;code&gt;:help :bufdo&lt;/code&gt; explains very clearly how &lt;code&gt;:bufdo&lt;/code&gt; works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bfirst&#xA;:{cmd}&#xA;:bnext&#xA;:{cmd}&#xA;etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last buffer to be visited becomes the current buffer (&lt;code&gt;%&lt;/code&gt;), and the buffer visited just before becomes the alternate buffer (&lt;code&gt;#&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:tabdo&lt;/code&gt; doesn't care about buffers so it's most likely to be the right command for you.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="1841" LastEditDate="2015-07-28T16:21:58.247" LastActivityDate="2015-07-28T16:21:58.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4048" PostTypeId="1" AcceptedAnswerId="4052" CreationDate="2015-07-28T14:55:53.523" Score="4" ViewCount="531" Body="&lt;p&gt;I am trying to fix a compiler plugin for Gradle. Gradle generates error messages of the type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:compileJava/file/path/Main.java:52: error: cannot find symbol&#xA;    public static ABC abc;&#xA;                  ^&#xA;  symbol:   class ABC&#xA;  location: class Main&#xA;/file/path/Main2.java:291: error: incompatible types: com.whatever.N cannot be converted to com.another.N&#xA;... and so on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All error messages except for the first one are properly parsed with this error format string&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CompilerSet errorformat=&#xA;  \%E%f:%l:\ error:\ %m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that Gradle prepends a target name (in this case &lt;code&gt;:compileJava&lt;/code&gt;) to the first error message. My question is: how do I specify that :compileJava (and maybe some other :compileTarget) strings can be optionally included at the beginning of the error message?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I were to write a regexp in a more common format, this would look similar to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(:compileJava|:compileTarget]\)?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="2725" LastActivityDate="2015-07-28T20:14:20.833" Title="Vim ErrorFormat question for Gradle compiler plugin" Tags="|regular-expression|makeprg|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4050" PostTypeId="1" AcceptedAnswerId="4265" CreationDate="2015-07-28T16:59:44.520" Score="13" ViewCount="1576" Body="&lt;p&gt;I am using vim to edit latex documents. Often, I will want to change the name of a variable to something else. However, it's a little annoying to have to wade through irrelevant matches when I search for the variable name. I would like to search only in &quot;math zones&quot; as defined in the tex syntax file. Is there an easy way to limit a search to a specific syntax region?&lt;/p&gt;&#xA;" OwnerUserId="2976" LastActivityDate="2021-02-14T12:45:42.613" Title="How to search for pattern in certain syntax regions?" Tags="|search|" AnswerCount="7" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4051" PostTypeId="2" ParentId="4050" CreationDate="2015-07-28T18:16:22.397" Score="1" Body="&lt;p&gt;If you're searching for the string &lt;code&gt;foo&lt;/code&gt; inside &lt;code&gt;$...$&lt;/code&gt; or &lt;code&gt;$$...$$&lt;/code&gt;, this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\$.*\zsfoo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This anchors the match to a &lt;code&gt;$&lt;/code&gt; character but only selects the string &lt;code&gt;foo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not really an easy solution, but one could use a &lt;code&gt;:global&lt;/code&gt; + &lt;code&gt;:substitute&lt;/code&gt; to find &quot;math zones&quot; and search inside them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global /\v\\begin\{%(align|alignat|displaymath)\}/ +1,/\\end/-1 s/foo/&amp;amp;/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pretending that &lt;code&gt;:substitute&lt;/code&gt; is a search command, you can go to the next occurrence with &lt;code&gt;n&lt;/code&gt; and quit with &lt;code&gt;q&lt;/code&gt;. Should you confirm a substitution by mistake there shouldn't be any problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will have to set the list inside &lt;code&gt;%(&lt;/code&gt; ... &lt;code&gt;)&lt;/code&gt; to the names of the math environments you use (the full list is a bit hefty: &lt;code&gt;align|alignat|displaymath|eqnarray|equation|flalign|gather|math|multline|subequations|xalignat|xxalignat&lt;/code&gt;). Note that I'm using a very magic (&lt;code&gt;\v&lt;/code&gt;) pattern here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:global&lt;/code&gt; execute an Ex command (&lt;code&gt;:s&lt;/code&gt;) on each line where the pattern matches (&lt;code&gt;:help :global&lt;/code&gt;)&lt;br&gt;&#xA;&lt;code&gt;/\v&lt;/code&gt; start a very magic pattern (&lt;code&gt;:h /&lt;/code&gt;, &lt;code&gt;:h pattern&lt;/code&gt;, &lt;code&gt;:h magic&lt;/code&gt;)&lt;br&gt;&#xA;&lt;code&gt;\\begin\{&lt;/code&gt; match a literal &lt;code&gt;\begin{&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;%(align|alignat|displaymath)&lt;/code&gt; match any of these words (&lt;code&gt;:h /\%(&lt;/code&gt;, &lt;code&gt;:h /bar&lt;/code&gt;)&lt;br&gt;&#xA;&lt;code&gt;\}/&lt;/code&gt; match a literal &lt;code&gt;}&lt;/code&gt; and end the pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;+1,/\\end/-1&lt;/code&gt; a range consisting of the next line (counting from the one found by &lt;code&gt;:global&lt;/code&gt;) up to the line before the one found by the search pattern &lt;code&gt;/\\end&lt;/code&gt;. Within that range,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s/foo/&amp;amp;/gc&lt;/code&gt; search-and-replace every occurrence of the literal &lt;code&gt;foo&lt;/code&gt; with itself, after confirmation (&lt;code&gt;:h :substitute&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="2942" LastEditDate="2015-08-10T12:51:42.003" LastActivityDate="2015-08-10T12:51:42.003" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4052" PostTypeId="2" ParentId="4048" CreationDate="2015-07-28T20:14:20.833" Score="2" Body="&lt;p&gt;I suggest doing it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;errorformat =&#xA;    \ '%E%\m:%\%%(compileJava%\|compileTarget%\)%f:%l: error: %m,' .&#xA;    \ '%E%f:%l: error: %m,' .&#xA;    \ '%Z%p^,' .&#xA;    \ '%-G%.%#'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Proof:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cgetexpr [':compileJava/file/path/Main.java:52: error: cannot find symbol',&#xA;    \ '    public static ABC abc;',&#xA;    \ '                  ^',&#xA;    \ '  symbol:   class ABC',&#xA;    \ '  location: class Main',&#xA;    \ '/file/path/Main2.java:291: error: incompatible types: com.whatever.N cannot be converted to com.another.N' ]&#xA;echomsg string(getqflist())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[{'lnum': 52, 'bufnr': 3, 'col': 19, 'valid': 1, 'vcol': 1, 'nr': -1, 'type': 'E', 'pattern': '', 'text': 'cannot find symbol'},&#xA; {'lnum': 291, 'bufnr': 4, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': 'E', 'pattern': '', 'text': 'incompatible types: com.whatever.N cannot be converted to com.another.N'}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-07-28T20:14:20.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4053" PostTypeId="1" AcceptedAnswerId="4064" CreationDate="2015-07-28T22:02:38.763" Score="3" ViewCount="2338" Body="&lt;p&gt;There are already a lot of similar questions to this.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/16748161/jump-to-last-line-but-stay-in-the-same-column&quot;&gt;Jump to last line, but stay in the same column&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/16631436/how-to-go-to-the-end-of-the-file-in-vim-while-preserving-the-current-column-unde&quot;&gt;How to go to the end of the file in vim while preserving the current column under the cursor?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/3736678/how-do-you-select-a-whole-column-in-visual-block-mode&quot;&gt;How do you select a whole column in visual block mode?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;They all end with toggling the &lt;code&gt;startofline&lt;/code&gt; setting. Using &lt;code&gt;startofline&lt;/code&gt; it's possible to start a visual selection with &lt;code&gt;Ctrl-v&lt;/code&gt; and then use &lt;code&gt;gg&lt;/code&gt; or &lt;code&gt;G&lt;/code&gt; to select entire columns of text from the cursor to the beginning or to the end of the file. What if I want to select an entire column that doesn't go to the beginning or end of the file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;first line&#xA;&#xA;x b c&#xA;a m w&#xA;q y c&#xA;a e z&#xA;&#xA;last line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the cursor was on &lt;code&gt;b&lt;/code&gt; in the line reading &lt;code&gt;x b c&lt;/code&gt;, how can I select the column starting at that b and ending on the &lt;code&gt;e&lt;/code&gt; in &lt;code&gt;a e z&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For non-column oriented actions similar to this I would use the shift paren/bracket family but they seem unaffected by &lt;code&gt;nostartofline&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="268" LastEditorUserId="205" LastEditDate="2015-07-29T00:05:04.657" LastActivityDate="2015-07-29T09:31:42.117" Title="Visual select single column from cursor to last line with text in column" Tags="|visual-mode|cursor-motions|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4054" PostTypeId="1" AcceptedAnswerId="4055" CreationDate="2015-07-28T23:07:25.953" Score="10" ViewCount="898" Body="&lt;p&gt;I like the behavior of the &lt;code&gt;'smartcase'&lt;/code&gt; option, which lets searches I type in by hand be case-insensitive by default, case-sensitive when there are any capital letters. I also like the behavior of the &lt;code&gt;'noignorecase'&lt;/code&gt; option, which lets searches generated by the editor (as when hitting &lt;code&gt;*&lt;/code&gt; or &lt;code&gt;#&lt;/code&gt;) be case-sensitive by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, &lt;code&gt;'smartcase'&lt;/code&gt; only does its magic when &lt;code&gt;'ignorecase'&lt;/code&gt; is on, so now I have a conflict: I can either get the nice behavior for hand-generated searches or the nice behavior for machine-generated searches, but not both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How I can I get both nice behaviors?&lt;/p&gt;&#xA;" OwnerUserId="2982" LastActivityDate="2022-10-13T09:35:09.620" Title="case-sensitive * with ignorecase on" Tags="|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4055" PostTypeId="2" ParentId="4054" CreationDate="2015-07-29T00:00:38.313" Score="13" Body="&lt;p&gt;You can fix that for the &lt;code&gt;*&lt;/code&gt; command by putting the following mapping in your &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap * &amp;lt;silent&amp;gt; *N:let @/.='\C'&amp;lt;CR&amp;gt;n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you type &lt;code&gt;*&lt;/code&gt;, the mapping first executes the normal &lt;code&gt;*&lt;/code&gt; command, then jumps back to the original word (&lt;code&gt;N&lt;/code&gt;), then appends &lt;code&gt;\C&lt;/code&gt; to the search expression (&lt;code&gt;:let @/.='\C'&amp;lt;CR&amp;gt;&lt;/code&gt;), which makes it case-sensitive, and finally jumps forward again (&lt;code&gt;n&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A complete compendium of bindings which doesn't clobber jumps (using Vitor's trick from the comments) and supports both forward and backwards search looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;  * :let @/='\C\&amp;lt;' . expand('&amp;lt;cword&amp;gt;') . '\&amp;gt;'&amp;lt;CR&amp;gt;:let v:searchforward=1&amp;lt;CR&amp;gt;n&#xA;nnoremap &amp;lt;silent&amp;gt;  # :let @/='\C\&amp;lt;' . expand('&amp;lt;cword&amp;gt;') . '\&amp;gt;'&amp;lt;CR&amp;gt;:let v:searchforward=0&amp;lt;CR&amp;gt;n&#xA;nnoremap &amp;lt;silent&amp;gt; g* :let @/='\C'   . expand('&amp;lt;cword&amp;gt;')       &amp;lt;CR&amp;gt;:let v:searchforward=1&amp;lt;CR&amp;gt;n&#xA;nnoremap &amp;lt;silent&amp;gt; g# :let @/='\C'   . expand('&amp;lt;cword&amp;gt;')       &amp;lt;CR&amp;gt;:let v:searchforward=0&amp;lt;CR&amp;gt;n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="2982" LastEditDate="2015-07-29T22:58:33.823" LastActivityDate="2015-07-29T22:58:33.823" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4056" PostTypeId="1" AcceptedAnswerId="4057" CreationDate="2015-07-29T00:58:58.273" Score="92" ViewCount="49807" Body="&lt;p&gt;One of the plugins I have installed (probably Supertab) provides a nice view of documentation for the currently highlighted item in the completion menu:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fVILE.png&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fVILE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The (apparently) scratch buffer remains open even after I exit the completion (by pressing &lt;kbd&gt;Enter&lt;/kbd&gt; or &lt;kbd&gt;Space&lt;/kbd&gt;). Then, to quit it, I do &lt;code&gt;&amp;lt;c-w&amp;gt;↑:q&lt;/code&gt;, but I find having to press &lt;kbd&gt;Ctrl&lt;/kbd&gt; extremely annoying (one reason why I avoid splits).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's a quick way to close this scratch buffer? Is there a native way, or do I have to write a mapping?&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="51" LastEditDate="2015-07-30T13:39:13.617" LastActivityDate="2021-02-10T14:27:16.623" Title="Is there an easy way to close a scratch buffer/preview window?" Tags="|buffers|scratch-buffer|" AnswerCount="6" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4057" PostTypeId="2" ParentId="4056" CreationDate="2015-07-29T02:52:18.943" Score="99" Body="&lt;p&gt;The top window is called the preview window. So any of &lt;code&gt;&amp;lt;c-w&amp;gt;z&lt;/code&gt;, &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;c-z&amp;gt;&lt;/code&gt; or &lt;code&gt;:pc[lose][!]&lt;/code&gt; should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The below is the help for &lt;code&gt;:help :pclose&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;CTRL-W z        CTRL-W_z&#xA;CTRL-W CTRL-Z   CTRL-W_CTRL-Z&#xA;:pc :pclose&#xA;:pc[lose][!]    Close any &quot;Preview&quot; window currently open.  When the 'hidden'&#xA;                option is set, or when the buffer was changed and the [!] is&#xA;                used, the buffer becomes hidden (unless there is another&#xA;                window editing it).  The command fails if any &quot;Preview&quot; buffer&#xA;                cannot be closed.  See also :close.&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another relevant help page would be &lt;code&gt;:help preview-window&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="17068" LastEditDate="2018-04-06T19:05:57.287" LastActivityDate="2018-04-06T19:05:57.287" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4058" PostTypeId="1" AcceptedAnswerId="4065" CreationDate="2015-07-29T03:42:10.897" Score="1" ViewCount="435" Body="&lt;p&gt;I want to bring some magic to my configuration but it fails to work because it seems Vim refuses to imap to a key in main keyboard. For example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;imap a bcd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I know most of time that's insane, but I have use case for that. Is there any switch for that so that I can turn this off?&lt;/p&gt;&#xA;&lt;p&gt;Here is my Vim version:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 31 2015 23:36:07)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1097" LastEditorUserId="23502" LastEditDate="2022-11-05T07:28:57.053" LastActivityDate="2022-11-05T07:28:57.053" Title="How to map usual key in insert mode?" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4059" PostTypeId="1" AcceptedAnswerId="4076" CreationDate="2015-07-29T07:09:16.060" Score="2" ViewCount="230" Body="&lt;p&gt;I want to map an action that repeats the last make command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, such a mapping would work also in insert mode (i.e. it would automatically switch to command mode.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it would be nice, if such an action also automatically saved the buffers with unsaved changes in them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, this would automate steps like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ctrl+[&#xA;:w&#xA;:ma&#xA;Arrow-Up&#xA;Return&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Such steps could be mapped to &lt;kbd&gt;F9&lt;/kbd&gt;, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, saving all buffers with unsaved changes (e.g. when in split-window mode) probably complicates the action.&lt;/p&gt;&#xA;" OwnerUserId="2357" LastEditorUserId="1841" LastEditDate="2015-07-29T14:59:09.777" LastActivityDate="2015-07-30T05:15:14.690" Title="Mapping to get last make command and execute it again" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4060" PostTypeId="1" CreationDate="2015-07-29T07:32:11.237" Score="0" ViewCount="2294" Body="&lt;p&gt;How do I disable the &lt;kbd&gt;Ctrl&lt;/kbd&gt; key? I've tried options below, but they did not work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C&amp;gt; &amp;lt;NOP&amp;gt;&#xA;noremap &amp;lt;C-&amp;gt; &amp;lt;NOP&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="153" LastEditorUserId="23502" LastEditDate="2022-11-05T07:28:01.677" LastActivityDate="2022-11-05T07:28:01.677" Title="How to disable Ctrl key?" Tags="|key-bindings|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4061" PostTypeId="2" ParentId="4059" CreationDate="2015-07-29T07:55:34.853" Score="2" Body="&lt;p&gt;You could use Ingo Karkat's &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1661&quot; rel=&quot;nofollow&quot;&gt;Redocommand plugin&lt;/a&gt; which allows to call the last command matching a pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea would be to add the following function to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LastMake()&#xA;    bufdo w&#xA;    Redocommand :make&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this function &lt;code&gt;bufdo w&lt;/code&gt; saves all unsaved buffers and the second line use Redocommand to call the last &lt;code&gt;make&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you create the folowing mappings (add these two lines to your &lt;code&gt;.vimrc&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F9&amp;gt; :call LastMake()&#xA;inoremap &amp;lt;F9&amp;gt; &amp;lt;Esc&amp;gt;:call LastMake()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will allow you to use &lt;kbd&gt;F9&lt;/kbd&gt; in normal and insert mode to call the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; As @Jjaderberg  pointed it out in comments, &lt;code&gt;bufdo&lt;/code&gt; will change the current buffer which could be an issue if your &lt;code&gt;make&lt;/code&gt; command does use an absolute path. So a good solution is to replace it by &lt;code&gt;wall&lt;/code&gt; (for Write All) as @joeytwiddle suggested to get the same result without changing the current buffer. (Thanks to both of you for your comments) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LastMake()&#xA;    wall &#xA;    Redocommand :make&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-07-30T05:15:14.690" LastActivityDate="2015-07-30T05:15:14.690" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4062" PostTypeId="2" ParentId="4050" CreationDate="2015-07-29T07:56:07.893" Score="1" Body="&lt;p&gt;In case your &quot;math zones&quot; are qualified by some syntactical pattern, say, the string &quot;math&quot;, then you could at least use &lt;strong&gt;pattern sequences&lt;/strong&gt; to find a line with the matching pattern, as in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/math//your pattern/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note: the two patterns may be on different lines!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This may not restrict your matches to the zones - for that you'd need to identify the end of the zone -, but it will display only those matches after an initial pattern /math/. You can repeat the search for the next occurrence by using the ex-mode history (&lt;code&gt;:&lt;/code&gt; &lt;code&gt;up-arrow&lt;/code&gt; &lt;code&gt;enter&lt;/code&gt;).&#xA;&lt;hr&gt;&#xA;Note: ISTR that in earlier vim/vi versions I was also able to use that method directly as a search command (as opposed to an ex-mode command) &lt;code&gt;/math//your pattern/&lt;/code&gt; with the advantage of less typing and using of the &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; commands, but I cannot confirm that for my current vim version.&lt;/p&gt;&#xA;" OwnerUserId="2479" LastActivityDate="2015-07-29T07:56:07.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4064" PostTypeId="2" ParentId="4053" CreationDate="2015-07-29T09:31:42.117" Score="4" Body="&lt;p&gt;Probably the simplest way to solve this (apart from using something like &lt;code&gt;ctrl-v 4j&lt;/code&gt;) is to use the &lt;a href=&quot;https://github.com/coderifous/textobj-word-column.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;textojb-word-column&lt;/a&gt; plugin: if cursor is placed on the &quot;right&quot; column, a simple &lt;code&gt;vic&lt;/code&gt; will get the job done. This is the demo from the plugin page:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Phohw.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Phohw.gif&quot; alt=&quot;gif demo from the plugin page&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-07-29T09:31:42.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4065" PostTypeId="2" ParentId="4058" CreationDate="2015-07-29T12:22:01.027" Score="3" Body="&lt;p&gt;I found the reason. I have &lt;code&gt;set paste&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;, and according to the doc (&lt;code&gt;:h paste&lt;/code&gt;) this option disable mappings in insert mode:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the 'paste' option is switched on (also when it was already on):&#xA;  mapping in Insert mode and Command-line mode is disabled&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1097" LastEditorUserId="1841" LastEditDate="2015-07-29T12:39:35.900" LastActivityDate="2015-07-29T12:39:35.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4066" PostTypeId="1" AcceptedAnswerId="4115" CreationDate="2015-07-29T12:29:16.030" Score="0" ViewCount="835" Body="&lt;p&gt;I am using a Gradle compiler plugin for Vim. I run &lt;code&gt;:compiler gradle&lt;/code&gt; and then &lt;code&gt;:make build&lt;/code&gt;, and Gradle build is executed and error results properly parsed (many thanks to @lcd047 answering my &lt;a href=&quot;https://vi.stackexchange.com/questions/4048/vim-errorformat-question-for-gradle-compiler-plugin/4052?noredirect=1#comment5891_4052&quot;&gt;question&lt;/a&gt;). The problem is that after I fix some errors and re-run the build to check if they were properly fixed, &lt;code&gt;make&lt;/code&gt; tells me that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make: Nothing to be done for `build'.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If i restart Vim, i can re-run the build again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seems that it's looking for some timestamp that is not changed? How do I tell make to re-run the build anyway?&lt;/p&gt;&#xA;" OwnerUserId="2725" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-07-31T13:11:46.907" Title="Make: Nothing to be done for 'build'" Tags="|makeprg|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4067" PostTypeId="1" AcceptedAnswerId="4068" CreationDate="2015-07-29T16:31:15.187" Score="2" ViewCount="197" Body="&lt;p&gt;I am trying to copy the selected text from vim into system clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In visual mode, i pressed &lt;code&gt;:&lt;/code&gt;, and the command prompt string changed as, :'&amp;lt;,'&gt; Running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt; !tee &amp;gt;(xsel -b)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;added &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt; into the current buffer which is not the desired result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then i edited the command prompt string and ran it as, &#xA;&lt;code&gt;:'&amp;gt;,'&amp;gt; !tee &amp;gt;(xsel -b)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Selection area got copied into clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How is &lt;code&gt;:'&amp;gt;,'&amp;gt;&lt;/code&gt; different from &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Original &lt;a href=&quot;https://unix.stackexchange.com/questions/219052/copy-vim-selected-text-to-system-clipboard&quot;&gt;question&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2988" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2015-08-05T21:37:23.667" Title=":'&lt;,'&gt; Vs :'&gt;,'&gt;, what do these range arrows in vi visual mode mean?" Tags="|visual-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4068" PostTypeId="2" ParentId="4067" CreationDate="2015-07-29T16:52:42.133" Score="9" Body="&lt;p&gt;The &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; symbols mark the beginning and end of the last selected Visual area. For commands that take a range of lines or characters, &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; means that the range of the command is the selected area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;jjaderberg suggests that the &lt;code&gt;'&amp;gt;,'&amp;gt;&lt;/code&gt; range expression following a Visual selection would mean that the last line of the selection alone constitutes the range that the filter works on. AFAICT, this is the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for why the &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; range failed in that way, I'm sorry to say I have no idea. I haven't been able to reproduce it. If anyone knows, please edit this answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Documentation:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;'&amp;lt;&lt;/code&gt; / &lt;code&gt;'&amp;gt;&lt;/code&gt; symbols: &lt;code&gt;:h '&amp;lt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Using a range with a filter: &lt;code&gt;:h range!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Beginning a command-line with a Visual Line selection: &lt;code&gt;:h v_:&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="2942" LastEditDate="2015-08-05T21:37:23.667" LastActivityDate="2015-08-05T21:37:23.667" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4069" PostTypeId="1" CreationDate="2015-07-29T18:12:59.183" Score="2" ViewCount="1133" Body="&lt;p&gt;Every time I have a '0' character in a &lt;code&gt;#define&lt;/code&gt; preprocessor directive in C, I get a change of color. Neither the font nor color scheme have influence on it. It is starting to annoy me. Does anyone know how to solve it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hCzrC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hCzrC.png&quot; alt=&quot;Color change&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reproducible on Vim 7.4 with a &lt;code&gt;.vimrc&lt;/code&gt; containing only &lt;code&gt;syntax on&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2992" LastEditorUserId="51" LastEditDate="2015-07-29T21:39:14.117" LastActivityDate="2015-07-29T21:39:14.117" Title="Color change in the middle of #define" Tags="|syntax-highlighting|filetype-c|" AnswerCount="3" CommentCount="0" ClosedDate="2015-07-29T21:41:21.307" ContentLicense="CC BY-SA 3.0" />
  <row Id="4070" PostTypeId="2" ParentId="4069" CreationDate="2015-07-29T18:56:04.357" Score="1" Body="&lt;p&gt;I don't know why that happens but you can find out where it happens by moving the cursor to the culprit '0' and issuing the following command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;verbose highlight &quot;.synIDattr(synID(line(&quot;.&quot;),col(&quot;.&quot;),1),&quot;name&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;excecute&lt;/code&gt; allows you to build a string and execute it as a command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;verbose&lt;/code&gt; followed by some setting will let you know where that setting was last set&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;highlight&lt;/code&gt; is usually used to set highlighting for a syntax item but, like many other settings, if you execute it without any highlighting instructions for the item, it will instead tell you about what instructions are already set&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;synIDattr()&lt;/code&gt; will for some syntax item retrieve some attribute&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;synID()&lt;/code&gt; will get the ID of the syntax item at some line,column position in your buffer&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;line(&quot;.&quot;)&lt;/code&gt; will get the line which the cursor is on&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;col(&quot;.&quot;)&lt;/code&gt; will get the column which the cursor is on&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1&lt;/code&gt; this last argument to &lt;code&gt;synID()&lt;/code&gt; has to do with transparency when syntax items overlap-we want the effective syntax item (see &lt;code&gt;:help synID()&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;name&quot;&lt;/code&gt; this last argument to &lt;code&gt;synIDattr()&lt;/code&gt; is which attribute to get&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, the command will &quot;execute verbose info on highlight setting for the syntax item under the cursor,&quot; which will tell you from which file the syntax rule that annoys you is set. It won't fix it, but it'll tell you where to look.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at &lt;code&gt;:help {x}&lt;/code&gt; for any of these commands/functions (i.e., not the last two) for more information.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-07-29T18:56:04.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4071" PostTypeId="1" AcceptedAnswerId="4072" CreationDate="2015-07-29T19:14:02.900" Score="1" ViewCount="1241" Body="&lt;p&gt;While I was customizing my status line, I was wondering if I could make certain elements of the status line disappear if the window width is too small.  To do this, I would have to know how much space the status line is actually taking up.  Is there a way of doing this?  If not, is there some other way of hiding/showing certain elements of the status line if the window is squishing its contents?&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2020-05-21T07:36:49.873" Title="Get the length of the current status line" Tags="|vim-windows|statusline|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4072" PostTypeId="2" ParentId="4071" CreationDate="2015-07-29T19:20:36.443" Score="3" Body="&lt;p&gt;While I'm not a statusline connoisseur, I think the general idea is to do it &quot;the other way around&quot;: while computing the statusline, the evaluated code (functions etc.) &lt;em&gt;could&lt;/em&gt; check for Vim's windows width and decide if (or how) a certain information will be displayed. To put it in a silly way, something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set statusline=%{winwidth(0)&amp;gt;80?'looooooooooooooooooooooooong':'short'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Every time Vim's windows width changes, the status line will be re-evaluated and will display the adjusted information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, if you want to know the length of the statusline, you will kind of ...have to keep track of it while building the expression to be evaluated (since that's the place where you have the &quot;total&quot; control). Slightly less sillier example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set statusline=%{len(expand('%'))&amp;gt;winwidth(0)?expand('%:t'):expand('%')}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(show full filename path if shorter than the window width, or only the actual filename if not). In practice, functions should make such a build-statusline-while-checking-its-length easier.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After some digging - and if I understood it correctly - this seems to be the approach used in the &lt;a href=&quot;https://github.com/bling/vim-airline/blob/67de5f2257f8d5def7a31e3009d4298ce977cb80/autoload/airline/extensions/default.vim#L15&quot; rel=&quot;nofollow&quot;&gt;vim-airline&lt;/a&gt; plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:section_truncate_width = get(g:,&#xA;  'airline#extensions#default#section_truncate_width', {&#xA;  \ 'b': 79,&#xA;  \ 'x': 60,&#xA;  \ 'y': 88,&#xA;  \ 'z': 45,&#xA;  \ })&#xA;&#xA;function! s:get_section(winnr, key, ...)&#xA;  if has_key(s:section_truncate_width, a:key)&#xA;    if winwidth(a:winnr) &amp;lt; s:section_truncate_width[a:key]&#xA;      return ''&#xA;    endif&#xA;  endif&#xA;&#xA;  [...] &quot; other code, returns section text&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(if a section has 'truncate width' key in the dictionary, and window width is smaller than that width, the section isn't displayed)&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-07-29T22:43:15.080" LastActivityDate="2015-07-29T22:43:15.080" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4073" PostTypeId="2" ParentId="4069" CreationDate="2015-07-29T19:38:40.787" Score="1" Body="&lt;p&gt;In the file &lt;code&gt;/usr/share/vim/vim74/syntax/c.vim&lt;/code&gt;, I changed line 466:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi def link cCppOut        Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi def link cCppOut        Macro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and everything looks fine now. I got no idea why there are some c++ highlights in &lt;code&gt;c.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2993" LastEditorUserId="1841" LastEditDate="2015-07-29T20:58:42.840" LastActivityDate="2015-07-29T20:58:42.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4074" PostTypeId="2" ParentId="4069" CreationDate="2015-07-29T19:57:20.350" Score="2" Body="&lt;p&gt;That looks like &lt;a href=&quot;https://code.google.com/p/vim/issues/detail?id=281&quot; rel=&quot;nofollow&quot;&gt;issue 281&lt;/a&gt; and should be fixed with newer versions of Vim 7.4&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-07-29T19:57:20.350" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4075" PostTypeId="1" CreationDate="2015-07-29T20:02:01.107" Score="5" ViewCount="829" Body="&lt;p&gt;How can I add auto-complete for my Rails project? I want autocomplete for existing rails functions, including gems, and for functions I created. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope there is some plugin for smart auto-complete, to recognize which object method will be called, and to offer relevant methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;code&gt;vim-rails&lt;/code&gt; plugin, but can not get working auto-complete. I am using Ubuntu 12, and regular vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have successfully set up auto-complete for my &lt;code&gt;c++&lt;/code&gt; files, it recognizes which libraries I have included and offers relevant functions for object on which the method will be called.&lt;/p&gt;&#xA;" OwnerUserId="2846" LastEditorUserId="23502" LastEditDate="2022-11-05T07:27:34.323" LastActivityDate="2022-11-05T07:27:34.323" Title="How to enable autocomplete for my rails functions?" Tags="|autocompletion|filetype-ruby|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4076" PostTypeId="2" ParentId="4059" CreationDate="2015-07-29T22:13:42.787" Score="1" Body="&lt;p&gt;It's fairly easy to translate your keystrokes into a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F9&amp;gt; :wa&amp;lt;CR&amp;gt;:ma&amp;lt;Up&amp;gt;&amp;lt;CR&amp;gt;&#xA;imap &amp;lt;F9&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;F9&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; means carriage return.  You can also use &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; but that's longer to type!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;imap&lt;/code&gt; jumps out of insert mode with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, invokes the normal-mode F9 mapping, then goes back into insert mode with &lt;code&gt;i&lt;/code&gt;.  We can't make it a &quot;noremap&quot; because we want it to expand the other F9 mapping.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-07-29T22:13:42.787" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4077" PostTypeId="2" ParentId="3694" CreationDate="2015-07-29T23:16:25.700" Score="9" Body="&lt;p&gt;I wrote a little function to repeatedly hit CTRL-O for me, until the buffer changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find it &lt;a href=&quot;https://github.com/joeytwiddle/rc_files/blob/master/.vim/plugin/back_to_recent_buffer.vim&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.  I mapped it to CTRL-U but you could override CTRL-O if you wanted to.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GoBackToRecentBuffer()&#xA;  let startName = bufname('%')&#xA;  while 1&#xA;    exe &quot;normal! \&amp;lt;c-o&amp;gt;&quot;&#xA;    let nowName = bufname('%')&#xA;    if nowName != startName&#xA;      break&#xA;    endif&#xA;  endwhile&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-U&amp;gt; :call GoBackToRecentBuffer()&amp;lt;Enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could probably write something similar for &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Issues:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If there is no previous buffer, it will continue silently looping until you hit CTRL-C!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:jumps&lt;/code&gt; lists the historical locations that CTRL-O will step back through.&lt;/li&gt;&#xA;&lt;li&gt;Vim's default CTRL-T is a good alternative to mashing CTRL-O, because it is coarser grained: it moves back through tag jumps only.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2016-01-31T10:39:56.543" LastActivityDate="2016-01-31T10:39:56.543" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4079" PostTypeId="2" ParentId="4026" CreationDate="2015-07-29T23:39:02.973" Score="2" Body="&lt;p&gt;One way to approach this might be to diff the two versions of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before we can diff we first write a copy of the current state, and then undo to the initial state.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w over_developed.c&#xA;999u&#xA;:vert diffsplit over_developed.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(To diff in &quot;the other direction&quot; you could undo, write a copy, redo, then open the diff.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then navigate to those lines in over_developed.c that you want to retain, and hit &lt;code&gt;dp&lt;/code&gt; to push them into the real file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately &lt;code&gt;dp&lt;/code&gt; might not work in this precise case, because it groups lines together, and it sounds like you might have multiple changes on a single line.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-07-29T23:39:02.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4080" PostTypeId="2" ParentId="3978" CreationDate="2015-07-30T00:05:50.643" Score="3" Body="&lt;p&gt;There is another &lt;strong&gt;plugin called &lt;a href=&quot;https://github.com/joeytwiddle/repmo.vim/blob/master/plugin/repmo.vim&quot; rel=&quot;nofollow&quot;&gt;repmo.vim&lt;/a&gt;&lt;/strong&gt; (&quot;repeat motions&quot;) which can do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But &lt;strong&gt;you will need to specify which motions&lt;/strong&gt; (or actions in general) you want to repeat.  Mine is currently configured like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:repmo_mapmotions = &quot;j|k h|l zh|zl g;|g, &amp;lt;C-w&amp;gt;w|&amp;lt;C-w&amp;gt;W&quot;&#xA;let g:repmo_mapmotions .= &quot; &amp;lt;C-w&amp;gt;+|&amp;lt;C-w&amp;gt;- &amp;lt;C-w&amp;gt;&amp;gt;|&amp;lt;C-w&amp;gt;&amp;lt;&quot;&#xA;let g:repmo_key = &quot;;&quot; &#xA;let g:repmo_revkey = &quot;,&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So after doing &lt;kbd&gt;5 CTRL-W +&lt;/kbd&gt; I can hit &lt;kbd&gt;;&lt;/kbd&gt; to repeat it as many times as a like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin works by creating mappings for each of the keys specified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;f&lt;/code&gt; or &lt;code&gt;t&lt;/code&gt; are used, the &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt; mappings are cleared back to their default behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find the mapping for &lt;code&gt;g;&lt;/code&gt; especially useful, to get back to an earlier edit point.  &lt;kbd&gt;g;&lt;/kbd&gt; &lt;kbd&gt;;&lt;/kbd&gt; &lt;kbd&gt;;&lt;/kbd&gt; &lt;kbd&gt;;&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-11-29T05:43:34.077" LastActivityDate="2015-11-29T05:43:34.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4081" PostTypeId="1" CreationDate="2015-07-30T09:26:00.157" Score="2" ViewCount="168" Body="&lt;p&gt;In the last week my vim has started to exit insert mode when I type &lt;kbd&gt;alt&lt;/kbd&gt; + &lt;kbd&gt;3&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have changed my theme to tomorrow night, but other than that no updates or changes to &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas what could be causing this? I wouldn't have thought a colorscheme could do this.&lt;/p&gt;&#xA;" OwnerUserId="2997" LastEditorUserId="1841" LastEditDate="2015-07-30T09:34:23.523" LastActivityDate="2015-07-30T09:34:23.523" Title="Why typing `alt + 3` exits insert mode?" Tags="|key-bindings|insert-mode|" AnswerCount="0" CommentCount="5" ClosedDate="2015-07-30T10:56:56.127" ContentLicense="CC BY-SA 3.0" />
  <row Id="4082" PostTypeId="1" AcceptedAnswerId="4086" CreationDate="2015-07-30T11:03:57.830" Score="4" ViewCount="499" Body="&lt;p&gt;I am trying to enter a latin cross (&lt;code&gt;✝&lt;/code&gt;, Unicode &lt;code&gt;271d&lt;/code&gt;) into a document. I can't find a pre-defined digraph for this. I am able to enter such a character with &lt;code&gt;&amp;lt;ctrl-v&amp;gt;u271d&lt;/code&gt; or I can define a new digraph in my &lt;code&gt;.vimrc&lt;/code&gt; like so: &lt;code&gt;digraph \|- 10013&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But before I'd do that I'd like to know if there is really no pre-defined digraph for the latin cross. How can I verify this?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="985" LastEditDate="2015-07-30T13:49:00.550" LastActivityDate="2024-01-24T16:07:24.807" Title="How can I be sure a digraph is not defined by Vim?" Tags="|digraphs|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4083" PostTypeId="5" CreationDate="2015-07-30T11:58:18.863" Score="0" Body="&lt;p&gt;Although Vim was made to edit text files, it is possible to edit binary&#xA;files with the option &lt;code&gt;set binary&lt;/code&gt; or with the &lt;code&gt;-b&lt;/code&gt; parameter. This options implies the folowing:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;textwidth&lt;/code&gt; and &lt;code&gt;wrapmargin&lt;/code&gt; are set to 0&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;modeline&lt;/code&gt; and &lt;code&gt;expandtab&lt;/code&gt; are turned off&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;fileformat&lt;/code&gt; and &lt;code&gt;fileformats&lt;/code&gt; options won't be used&lt;/li&gt;&#xA;&lt;li&gt;Files will be written using single line endings&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more information see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#edit-binary&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h edit-binary&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-07-30T12:11:17.633" LastActivityDate="2015-07-30T12:11:17.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4084" PostTypeId="4" CreationDate="2015-07-30T11:58:18.863" Score="0" Body="Questions about editing non-text files." OwnerUserId="1841" LastEditorUserId="51" LastEditDate="2015-07-30T12:11:08.640" LastActivityDate="2015-07-30T12:11:08.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4085" PostTypeId="2" ParentId="4082" CreationDate="2015-07-30T11:58:26.327" Score="4" Body="&lt;p&gt;There is no such digraph defined by default. You can review available digraphs at &lt;code&gt;:help digraph-table&lt;/code&gt;. The listing includes hex and decimal values as well as the name of the character, so you can easily search for an entry, for instance with &lt;code&gt;:help digraph-table|/0x271d&lt;/code&gt; or &lt;code&gt;:help digraph-table|/CROSS&lt;/code&gt;. The closest ones I see by value are &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;✓   OK  2713    10003   CHECK MARK&#xA;✗   XX  2717    10007   BALLOT X&#xA;✠   -X  2720    10016   MALTESE CROSS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I suppose the closest one visually is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;†   /-  2020    8224    DAGGER&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-07-30T11:58:26.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4086" PostTypeId="2" ParentId="4082" CreationDate="2015-07-30T11:58:49.813" Score="5" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://vimhelp.appspot.com/digraph.txt.html#%3adigraphs&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:digraphs&lt;/code&gt;&lt;/a&gt; command to get a list of all defined digraphs. This isn't very easy to search, but we can use &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3aredir&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:redir&lt;/code&gt;&lt;/a&gt; to store it to a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir all_digraphs&#xA;:digraphs&#xA;:redir END&#xA;:e all_digraphs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And we can now search the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&amp;lt;C-v&amp;gt;u271d &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which gives us:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E385: search hit BOTTOM without match for: ✝&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which confirms that this characters isn't a pre-defined digraph.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-07-30T11:58:49.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4087" PostTypeId="5" CreationDate="2015-07-30T12:02:36.500" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow&quot;&gt;Vundle&lt;/a&gt; is a vim plugin which allows to easily manage installation, update, deletion and searches of other plugins directly from within vim.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-07-30T12:10:39.003" LastActivityDate="2015-07-30T12:10:39.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4088" PostTypeId="4" CreationDate="2015-07-30T12:02:36.500" Score="0" Body="Questions about the plugin manager Vundle." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-07-30T12:10:51.237" LastActivityDate="2015-07-30T12:10:51.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4089" PostTypeId="2" ParentId="184" CreationDate="2015-07-30T14:14:31.147" Score="1" Body="&lt;p&gt;If you'd like to not highlight after any search, you can use this (better):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nohls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or this (worse):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi Search NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2620" LastEditorUserId="2620" LastEditDate="2015-07-30T14:27:48.320" LastActivityDate="2015-07-30T14:27:48.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4091" PostTypeId="1" CreationDate="2015-07-30T15:29:01.177" Score="17" ViewCount="3724" Body="&lt;p&gt;When I need to work on different projects at the same time I have the folowing workflow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I create one tab for each project.&lt;/li&gt;&#xA;&lt;li&gt;In each tab I open the files that I want to edit, which makes several buffers.&lt;/li&gt;&#xA;&lt;li&gt;Optionnaly if I need to see two (or more) files at the same time I create split windows so I have a tab containing different windows which shows one buffer.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To navigate between my buffers I don't really use &lt;code&gt;:ls&lt;/code&gt; and &lt;code&gt;:b [name or number of buffer]&lt;/code&gt; instead I created some convenient mappings allowing me to switch between the buffers with &lt;code&gt;:bnext&lt;/code&gt; and &lt;code&gt;:bprevious&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way to work is pretty good but something bothers me: the buffers are shared between the tabs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I open &lt;code&gt;file1&lt;/code&gt; and &lt;code&gt;file2&lt;/code&gt; in &lt;code&gt;tab1&lt;/code&gt; and &lt;code&gt;file3&lt;/code&gt; in &lt;code&gt;tab2&lt;/code&gt;, if in &lt;code&gt;tab1&lt;/code&gt; I use several time &lt;code&gt;:bnext&lt;/code&gt; I'll see &lt;code&gt;file3&lt;/code&gt; in this tab which I don't want to. &lt;strong&gt;The workflow I'd want to get is the folowing&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Start vim (I have a first tab with a buffer in it): &lt;code&gt;$ vim foo&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Add a buffer to this tab: &lt;code&gt;:e bar&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Open a new tab and switch to it: &lt;code&gt;:tabnew&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Open a new buffer in this tab: &lt;code&gt;:e baz&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;If I stay in this buffer and do &lt;code&gt;:bnext&lt;/code&gt; or &lt;code&gt;:bprevious&lt;/code&gt; I'll stay on &lt;code&gt;baz&lt;/code&gt; buffer (since it is the only one in this tab)&lt;/li&gt;&#xA;&lt;li&gt;If I go in the previous tab &lt;code&gt;:tabprevious&lt;/code&gt; and execute several time &lt;code&gt;:bnext&lt;/code&gt; I'll switch only between &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;bar&lt;/code&gt; buffers but will not see &lt;code&gt;baz&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So here comes my question:&lt;/strong&gt; Is it possible to bind a set of buffers to a tab and make vim disallow the access to some buffers from another tab than the one they're meant to be in?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I'm aware that using &lt;code&gt;:b [myBuffer]&lt;/code&gt; would be a way to keep a buffer in a tab but when I have 3 or 4 files to edit I feel like I'm really faster using my mappings than typing the buffer name &lt;em&gt;(even if I can type only some characters to match the buffer name)&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2021-08-12T15:31:18.220" Title="How to bind a set of buffers to a tab?" Tags="|buffers|vim-windows|tabbed-user-interface|" AnswerCount="7" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4092" PostTypeId="2" ParentId="4091" CreationDate="2015-07-30T17:18:12.517" Score="9" Body="&lt;p&gt;Mhh, i did not find any plugin out there, but you could write it yourself. You need to learn vimscript for this. I just implemented the functionality that you can switch between buffers in a tab (no deletion yet). You can copy this into your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(&quot;g:WindowBufManager&quot;) &#xA;  let g:WindowBufManager= {}&#xA;endif&#xA;&#xA;function! StoreBufTab()&#xA;  if !has_key(g:WindowBufManager, tabpagenr())&#xA;    let  g:WindowBufManager[tabpagenr()] = []&#xA;  endif&#xA;&#xA;  &quot; add the new buffer to our explorer&#xA;  if index(g:WindowBufManager[tabpagenr()], bufname(&quot;%&quot;)) == -1 &amp;amp;&amp;amp; bufname(&quot;%&quot;) != &quot;&quot;&#xA;    call add (g:WindowBufManager[tabpagenr()],bufname(&quot;%&quot;))&#xA;  endif&#xA;endfunction&#xA;&#xA;function! WindowBufManagerNext() &#xA;  &quot; find the next index of the buffer&#xA;  let s = index(g:WindowBufManager[tabpagenr()], bufname(&quot;%&quot;))&#xA;  if (s!= -1)&#xA;    let s = (s +1) % len(g:WindowBufManager[tabpagenr()])&#xA;    execute 'b ' . g:WindowBufManager[tabpagenr()][s]&#xA;  endif&#xA;endfunction&#xA;&#xA;augroup WindowBufManagerGroup&#xA;  autocmd! BufEnter * call StoreBufTab()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Close your vimrc and open it again. To find the next buffer just use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call WindowBufManagerNext()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or define your own command or mapping. &#xA;This will work as long as you do not close or delete a tab or buffer. It will also not work for multiple buffers. It would require some more work to add those features, but its definetly doable. &lt;/p&gt;&#xA;" OwnerUserId="3003" LastActivityDate="2015-07-30T17:18:12.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4093" PostTypeId="1" AcceptedAnswerId="4095" CreationDate="2015-07-30T17:46:53.490" Score="1" ViewCount="391" Body="&lt;p&gt;I have a custom syntax plugin for a file format that can contain embedded HLSL or GLSL code. At the moment, I've manually included a bunch of &lt;code&gt;syntax keyword&lt;/code&gt; and &lt;code&gt;syntax match&lt;/code&gt; commands in my syntax file to cover the basics of HLSL or GLSL source. I'd &lt;em&gt;prefer&lt;/em&gt; to simply reference an existing HLSL syntax plugin via &lt;code&gt;syntax include&lt;/code&gt;, but there is no built-in HLSL or GLSL syntax support in vim, so I cannot expect that a &lt;code&gt;syntax include&lt;/code&gt; will succeed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to &lt;em&gt;attempt&lt;/em&gt; to execute &lt;code&gt;syntax include&lt;/code&gt;, and if it fails (or would fail), fall back to my half-hearted custom version. How can I accomplish this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked at &lt;code&gt;try&lt;/code&gt;/&lt;code&gt;endtry&lt;/code&gt;, but they didn't seem to allow me to avoid an error if the desired syntax file wasn't present, and in any case only work on vim 7.0 or greater, and &lt;em&gt;if possible&lt;/em&gt; I'd like to use a version-agnostic solution.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-07-30T18:06:56.280" Title="How can I conditionally include a syntax file from another syntax file?" Tags="|syntax-highlighting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4094" PostTypeId="2" ParentId="4093" CreationDate="2015-07-30T18:03:59.270" Score="0" Body="&lt;p&gt;Since &lt;code&gt;try&lt;/code&gt;/&lt;code&gt;endtry&lt;/code&gt; did not seem to work for me after a cursory attempt, I resorted to relying on the behavior of &lt;code&gt;syntax include&lt;/code&gt; which states that a relative path is searched for in the runtime path, and put this in my syntax file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:has_hlsl_support = 0&#xA;for directory in split(&amp;amp;runtimepath, &quot;,&quot;)&#xA;  if filereadable(simplify(directory . &quot;/syntax/hlsl.vim&quot;))&#xA;    let b:has_hlsl_support = 1&#xA;    break&#xA;  endif&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I can check &lt;code&gt;b:has_hlsl_support&lt;/code&gt; and branch accordingly. This works, but I find myself wondering if there's a superior method.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-07-30T18:03:59.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4095" PostTypeId="2" ParentId="4093" CreationDate="2015-07-30T18:06:56.280" Score="1" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%3aruntime&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help :runtime&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When &lt;code&gt;'verbose'&lt;/code&gt; is one or higher, there is a message when no file could be found.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This uses &lt;code&gt;:echomsg&lt;/code&gt; to print the error, which you can capture like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;redir =&amp;gt; error&#xA;    verbose silent runtime syntax/cx.vim&#xA;redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've found that using &lt;code&gt;:redir&lt;/code&gt; in startup scripts is sometimes problematic though, sometimes Vim mixes up which redir belongs to which variable, so alternatively you can just use a loop to scan each entry in the &lt;code&gt;runtimepath&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let found = 0&#xA;for path in split(&amp;amp;runtimepath, ',')&#xA;    if file_readable(path . '/fname.vim')&#xA;        execute 'source ' . path . '/fname.vim'&#xA;        let found = 1&#xA;        break&#xA;    endif&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-07-30T18:06:56.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4096" PostTypeId="1" CreationDate="2015-07-30T18:37:25.383" Score="6" ViewCount="852" Body="&lt;p&gt;I frequently use &lt;code&gt;:e.&lt;/code&gt; to navigate folders and open files in gVim.  But later, when I try to close the session with a &lt;code&gt;:qall&lt;/code&gt;, I am asked by vim whether or not I want to save changes to the folder(s) I was navigating with netrw.  I couldn't save such changes, even if checked yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I add to my vimrc to let Vim know that I never want to save changes to a directory?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I'm using gVim on Windows 7.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;I tried this, to no avail:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_dirhistmax=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2452" LastEditorUserId="2452" LastEditDate="2015-07-30T18:43:30.670" LastActivityDate="2017-05-05T18:15:42.620" Title="No Vim, I don't want to save changes to a directory" Tags="|save|netrw|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4097" PostTypeId="2" ParentId="4091" CreationDate="2015-07-30T18:41:15.837" Score="6" Body="&lt;p&gt;Buffers are global and there's nothing you can do about that except writing your own abstraction layer on top of tab pages, windows and buffers. philolo1's answer shows a reasonable approach to the problem but you'll quickly find the limits of such a &quot;solution&quot; and need to duplicate a lot of built-in features like &lt;code&gt;:bufdo&lt;/code&gt; or the alternate file…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Arguments&quot; on the other hand, can be local to a &lt;em&gt;window&lt;/em&gt; so they may be more useful in your workflow than &quot;buffers&quot; (in the strictest meaning of the word):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim file1 file2&#xA;:tabnew&#xA;:argl file3 file4 file5&#xA;:n&#xA;:n&#xA;gt&#xA;:n&#xA;gt&#xA;:N&#xA;and so on…&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arguments are not as flexible as buffers but they may provide a more dependable basis for your workflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But working on each project in its own Vim instance is in my opinion the only practical solution.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-07-30T18:41:15.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4098" PostTypeId="1" CreationDate="2015-07-30T18:43:21.873" Score="2" ViewCount="80" Body="&lt;p&gt;I'm running the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,.5s/^/!&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to block comment a section of code, however, after running the command the editor highlights the first character in every line of the file. I guess this doesn't surprise me since those characters match the regex, but I thought this would be suppressed if I add a range. &lt;/p&gt;&#xA;" OwnerUserId="3005" LastEditorUserId="23502" LastEditDate="2022-11-05T07:26:43.787" LastActivityDate="2022-11-05T07:26:43.787" Title="How to avoid highlighting when block commenting?" Tags="|search|regular-expression|substitute|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4099" PostTypeId="2" ParentId="4082" CreationDate="2015-07-30T19:06:54.727" Score="2" Body="&lt;p&gt;I made the &lt;a href=&quot;https://github.com/chrisbra/unicode.vim&quot; rel=&quot;nofollow&quot;&gt;unicode plugin&lt;/a&gt; that helps with finding digraphs. You can use the command &lt;code&gt;:Digraphs cross&lt;/code&gt; to search for a digraph whose name contains cross. Or when on the char, issue the command &lt;code&gt;:Unicodename&lt;/code&gt; and it will output the digraph for that char. There are other similar commands as well, so check the help.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-07-30T19:06:54.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4100" PostTypeId="2" ParentId="4098" CreationDate="2015-07-30T19:18:54.837" Score="3" Body="&lt;h3&gt;Standing on the shoulders of giants&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I would highly recommend commenting plugin like &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow&quot;&gt;commentary&lt;/a&gt; (which I use), &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow&quot;&gt;Nerd Commenter&lt;/a&gt;, &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=23&quot; rel=&quot;nofollow&quot;&gt;EnhCommentify&lt;/a&gt;, &lt;a href=&quot;https://github.com/tomtom/tcomment_vim&quot; rel=&quot;nofollow&quot;&gt;tComment&lt;/a&gt;, ..., &lt;a href=&quot;http://vimawesome.com/?q=comment&quot; rel=&quot;nofollow&quot;&gt;etc&lt;/a&gt;. There is no shame in using a plugin.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-07-30T19:18:54.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4101" PostTypeId="2" ParentId="12" CreationDate="2015-07-30T19:20:02.640" Score="8" Body="&lt;p&gt;Here is a different approach, that needs a newer Vim (something like 7.4.800)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This assumes an empty buffer and '1' in register a.&#xA;First enter 100 1 into your buffer, &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then visually select lines 2 till 100 &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;G&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now press &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;A&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the help at &lt;code&gt;:h v_g_CTRL-A&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-07-30T19:20:02.640" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4102" PostTypeId="1" AcceptedAnswerId="4210" CreationDate="2015-07-30T19:20:48.163" Score="6" ViewCount="2189" Body="&lt;p&gt;I've been using Gvim for a while, but lately stopped using GUI options and went to just commands. &lt;code&gt;:ls&lt;/code&gt; is used all the time, but I have a huge project and it is hard to see the file name quickly in the long path. I like how GVim displays buffers in the &quot;Buffers&quot; menu:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;file name&amp;gt;             &amp;lt;path from $HOME&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to either &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use built in functionality of vim to display just the filename in &lt;code&gt;:ls&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Write a function that will use &lt;code&gt;:ls&lt;/code&gt; and show just the filename. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have a preference for the second solution because I don't want to totally override &lt;code&gt;:ls&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some quick notes: I am pretty comfortable with Vim commands (over a year using it as the only editor). But I've just started VimScript and this function would be a great first personal tool. If someone knows how to write a command for this, I would really appreciate a hint rather than a solution on where to start to write this function that would display just a file names of open buffers. I will promise to post what I write pretty quickly. :)&lt;/p&gt;&#xA;" OwnerUserId="3006" LastEditorUserId="1841" LastEditDate="2015-08-07T13:19:39.987" LastActivityDate="2017-08-14T13:03:25.947" Title="How to shorten the result of `ls` to get only the file name and not the whole path?" Tags="|vimscript|buffers|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4103" PostTypeId="2" ParentId="4096" CreationDate="2015-07-30T19:23:54.017" Score="4" Body="&lt;p&gt;You could try setting the &lt;code&gt;buftype&lt;/code&gt; option. E.g. doing &lt;code&gt;:set buftype=nofile&lt;/code&gt; should make ignore that buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'am wondering how you could modify this buffer, since this should read-protected and not-modifiable.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-07-30T19:23:54.017" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4104" PostTypeId="1" CreationDate="2015-07-30T19:48:58.723" Score="3" ViewCount="114" Body="&lt;p&gt;I have a file with two columns, separated by a tab, and would like to match any part of the second column that begins with an asterisk. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  RAFP         rasp&#xA;  ET           *ratchet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then &lt;code&gt;*ratchet&lt;/code&gt; should be highlighted. (There are two spaces before the first column, and there are supposed to be – in some other rows, there are symbols placed in that space.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, I wrote the following match line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Keyword &quot;\t\*.*&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does not highlight anything. I have tried removing and adding escape characters, putting elements in square brackets, playing with the magic option (though I see in the help that syntax matches are always in magic mode no matter what) and just about everything else possible. If I take out the &lt;code&gt;\t&lt;/code&gt;, then it works as expected, but this has the potential for false positives, so it's important that the pattern start with the tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most baffling, if I do a simple search for &lt;code&gt;\t\*.*&lt;/code&gt; with &lt;code&gt;hlsearch&lt;/code&gt; on, it highlights exactly like it's supposed to. What is different about the pattern matching in a syntax highlight command from the normal search matching system?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim 7.4 (I can give more version output if it's relevant).&lt;/p&gt;&#xA;" OwnerUserId="2036" LastEditorUserId="2036" LastEditDate="2015-07-30T20:02:00.117" LastActivityDate="2015-07-30T20:02:00.117" Title="Can't seem to syntax-highlight a pattern beginning with a tab" Tags="|syntax-highlighting|regular-expression|" AnswerCount="0" CommentCount="4" ClosedDate="2016-03-02T12:58:31.973" ContentLicense="CC BY-SA 3.0" />
  <row Id="4106" PostTypeId="2" ParentId="4098" CreationDate="2015-07-31T07:41:13.930" Score="3" Body="&lt;p&gt;&lt;code&gt;:.,.5norm I!&lt;/code&gt; is an alternative that doesn't use substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, you can shorten your original command like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:,.5s/^/!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;,or like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:,+5s/^/!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, I don't know if you are aware of that but you can prepend your ex command with a count to automatically insert the right range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;6:s/^/!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,.+5s/^/!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is yet another way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/^/!/6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But yeah, use commentary.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-07-31T07:41:13.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4108" PostTypeId="1" CreationDate="2015-07-31T09:37:12.487" Score="-1" ViewCount="357" Body="&lt;p&gt;Is it possible in &lt;strong&gt;visual-block-mode&lt;/strong&gt; to use find next character?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1: select &lt;code&gt;&quot;&lt;/code&gt; in visual-block-mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;code(|&quot;|abcd&quot;).anotherCode()&#xA;code(|&quot;|abcde&quot;).anotherCode()&#xA;code(|&quot;|abcdef&quot;).anotherCode()&#xA;code(|&quot;|abcdefg&quot;).anotherCode()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2.a: go to (find) next &lt;code&gt;&quot;&lt;/code&gt; symbol (or any other) and &lt;em&gt;select this symbols&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;code(&quot;abcd|&quot;|).anotherCode()&#xA;code(&quot;abcde|&quot;|).anotherCode()&#xA;code(&quot;abcdef|&quot;|).anotherCode()&#xA;code(&quot;abcdefg|&quot;|).anotherCode()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2.b: go to (find) next &lt;code&gt;&quot;&lt;/code&gt; symbol (or any other) and &lt;em&gt;select all text inside this symbols&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;code(|&quot;abcd&quot;|).anotherCode()&#xA;code(|&quot;abcde&quot;|).anotherCode()&#xA;code(|&quot;abcdef&quot;|).anotherCode()&#xA;code(|&quot;abcdefg&quot;|).anotherCode()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2972" LastActivityDate="2015-08-01T09:55:08.367" Title="Visual block - actions like in normal mode (jump to/find character)" Tags="|visual-mode|" AnswerCount="1" CommentCount="2" ClosedDate="2015-08-01T11:18:08.990" ContentLicense="CC BY-SA 3.0" />
  <row Id="4109" PostTypeId="5" CreationDate="2015-07-31T11:44:34.127" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/python-rope/ropevim&quot; rel=&quot;nofollow&quot;&gt;Homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-07-31T11:44:34.127" LastActivityDate="2015-07-31T11:44:34.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4110" PostTypeId="4" CreationDate="2015-07-31T11:44:34.127" Score="0" Body="Uses the rope library to provide features like Python refactorings and code-assists." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-07-31T11:44:34.127" LastActivityDate="2015-07-31T11:44:34.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4111" PostTypeId="1" AcceptedAnswerId="4119" CreationDate="2015-07-31T12:45:59.050" Score="31" ViewCount="6322" Body="&lt;p&gt;What should the next steps to learning Vim be, after completing &lt;code&gt;vimtutor&lt;/code&gt;? I've watched videos on YouTube, read tutorials online and questions/answers on SE, and am busy reading &lt;a href=&quot;https://pragprog.com/book/dnvim/practical-vim&quot; rel=&quot;noreferrer&quot;&gt;Practical&lt;/a&gt; Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any other good resources available? Actually practicing and using Vim -- not just watching/reading about it -- is surely a good way to learn. Any suggestions on the best way to use the built-in help system to learn Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: Although &lt;a href=&quot;https://stackoverflow.com/questions/2567883/does-an-updated-vimtutor-exist&quot;&gt;this&lt;/a&gt; question on SO has been closed for being off-topic, several of the answers there look useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PPS: I used vim many years ago, moved to Emacs for Org-Mode, and am now returning to vim :)&lt;/p&gt;&#xA;" OwnerUserId="2932" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2018-05-31T18:39:58.453" Title="Learning Vim after vimtutor" Tags="|help-system|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4112" PostTypeId="2" ParentId="4098" CreationDate="2015-07-31T12:52:38.060" Score="0" Body="&lt;p&gt;After performing a search, you can hide the highlights by running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is short for &lt;code&gt;:nohlsearch&lt;/code&gt;.  After your next search, the highlights will re-appear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I actually have this mapped to &lt;kbd&gt;Ctrl-L&lt;/kbd&gt; so it's even easier to perform.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;C-L&amp;gt; &amp;lt;C-L&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;:match&amp;lt;CR&amp;gt;:diffupdate&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-07-31T12:52:38.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4113" PostTypeId="2" ParentId="4111" CreationDate="2015-07-31T13:01:08.560" Score="3" Body="&lt;p&gt;I heartily recommend this tutorial adaptation, for EX-tra Vim power: &lt;a href=&quot;http://dahu.github.io/vim_waz_ere/&quot; rel=&quot;nofollow&quot;&gt;http://dahu.github.io/vim_waz_ere/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-07-31T13:01:08.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4114" PostTypeId="2" ParentId="4102" CreationDate="2015-07-31T13:09:31.920" Score="4" Body="&lt;p&gt;Here is my suggestion to get you started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't tested or debugged it, so that's your task.  :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:MyBufList()&#xA;  set nomore&#xA;  let buf_count = bufnr(&quot;$&quot;)&#xA;  for i in range(1, buf_count)&#xA;    if getbufvar(l:i, '&amp;amp;buflisted') &amp;gt; 0&#xA;      let path = bufname(i)&#xA;      let filename = fnamemodify(path, &quot;:t&quot;)&#xA;      let folder = fnamemodify(path, &quot;:h&quot;)&#xA;      echo filename . &quot;\t(&quot; . folder . &quot;)&quot;&#xA;    endif&#xA;  endfor&#xA;  set more&#xA;endfunction&#xA;&#xA;command! MBL call s:MyBufList()&#xA;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;b :MBL&amp;lt;CR&amp;gt;:b&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-07-31T14:55:45.713" LastActivityDate="2015-07-31T14:55:45.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4115" PostTypeId="2" ParentId="4066" CreationDate="2015-07-31T13:11:46.907" Score="1" Body="&lt;p&gt;Solved by comment from @jjaderberg. The problem is related to the &lt;code&gt;compiler&lt;/code&gt; command. To quote Vim's help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;6. Selecting a compiler                                 compiler-select&#xA;&#xA;                                                :comp :compiler E666&#xA;:comp[iler][!] {name}           Set options to work with compiler {name}.&#xA;                                Without the &quot;!&quot; options are set for the&#xA;                                current buffer.  With &quot;!&quot; global options are set.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, i was using &lt;code&gt;:compiler gradle&lt;/code&gt; instead of &lt;code&gt;:compiler! gradle&lt;/code&gt;, hence had &lt;code&gt;makeprg&lt;/code&gt; properly set in one buffer only. Switching to a different buffer changed its value to the default, which is simply &lt;code&gt;make&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2725" LastActivityDate="2015-07-31T13:11:46.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4116" PostTypeId="1" AcceptedAnswerId="4117" CreationDate="2015-07-31T13:53:27.000" Score="24" ViewCount="6525" Body="&lt;p&gt;In Vim, the character class &lt;code&gt;\s&lt;/code&gt; matches any whitespace character. When I'm using those special characters in groups e.g. &lt;code&gt;[\s\w]&lt;/code&gt; it does not match any single whitespace or word character, it does match &lt;code&gt;s&lt;/code&gt; or &lt;code&gt;w&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does one use character classes inside groups?&lt;/p&gt;&#xA;" OwnerUserId="129" LastEditorUserId="129" LastEditDate="2015-08-02T05:17:12.917" LastActivityDate="2015-08-24T19:41:38.030" Title="Regex in Vi: How does one use character classes inside groups? (e.g. [\s\w])" Tags="|regular-expression|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4117" PostTypeId="2" ParentId="4116" CreationDate="2015-07-31T14:07:37.090" Score="16" Body="&lt;p&gt;That's not a group, it's a range, and in Vim you can't use character classes (although it's possible in other regex implementations, e.g. in &lt;a href=&quot;https://stackoverflow.com/questions/13142440/python-regex-including-whitespace-inside-character-range&quot;&gt;python&lt;/a&gt;). You'll have to use an &lt;a href=&quot;http://vimregex.com/#alternations&quot; rel=&quot;noreferrer&quot;&gt;alternation&lt;/a&gt; instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\(\w\|\s\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v(\s|\w)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(or, the &lt;a href=&quot;https://vi.stackexchange.com/a/4505/1111&quot;&gt;solution proposed&lt;/a&gt; by &lt;a href=&quot;https://vi.stackexchange.com/users/2942/peter-lewerin&quot;&gt;Peter Lewerin&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-24T19:32:02.467" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4118" PostTypeId="1" AcceptedAnswerId="4124" CreationDate="2015-07-31T14:43:23.433" Score="3" ViewCount="878" Body="&lt;p&gt;Currently I'm editing some SQLite scripts with my filetype set to &lt;code&gt;ft=sql&lt;/code&gt; and some types aren't being highlighted and :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;REAL&lt;/li&gt;&#xA;&lt;li&gt;TEXT&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There is some configuration that I'm missing ? I've searched for a syntax file specific for SQLite and didn't found any.&lt;/p&gt;&#xA;" OwnerUserId="1453" LastEditorUserId="23502" LastEditDate="2022-11-05T07:26:04.057" LastActivityDate="2022-11-05T07:26:04.057" Title="Aditional SQLite syntax highlighting in Vim" Tags="|syntax-highlighting|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4119" PostTypeId="2" ParentId="4111" CreationDate="2015-07-31T14:47:44.157" Score="33" Body="&lt;h3&gt;Sharpen the saw&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The best general advice is a simple one, &quot;&lt;a href=&quot;http://www.moolenaar.net/habits.html&quot; rel=&quot;noreferrer&quot;&gt;Sharpen the saw&lt;/a&gt;&quot; from Bram's Seven habits essay. I also suggest &lt;a href=&quot;http://vimcasts.org/&quot; rel=&quot;noreferrer&quot;&gt;Vimcasts blog&lt;/a&gt; post: &lt;a href=&quot;http://vimcasts.org/blog/2012/08/on-sharpening-the-saw/&quot; rel=&quot;noreferrer&quot;&gt;On sharpening the saw&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically &quot;sharpening the saw&quot; can be summarized as: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Don't learn everything all at once, but learn a few things at a time.&#xA;  When you find an inefficiency look for ways to improve it. Repeat&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h3&gt;Vimrc&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I also recommend you use &lt;a href=&quot;https://github.com/romainl/idiomatic-vimrc&quot; rel=&quot;noreferrer&quot;&gt;nearly blank vimrc&lt;/a&gt;. You should roughly understand each line in your &lt;code&gt;vimrc&lt;/code&gt;. Use &lt;code&gt;:help&lt;/code&gt; and google learn more.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Plugins&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;General plugin advice:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Slowly add a plugin or two when the need arises.&lt;/li&gt;&#xA;&lt;li&gt;Do not install a plugin without looking for a native solution first&lt;/li&gt;&#xA;&lt;li&gt;Must have good documentation&lt;/li&gt;&#xA;&lt;li&gt;Avoid plugins with many mappings&lt;/li&gt;&#xA;&lt;li&gt;If it doesn't feel Vim-like then avoid it&lt;/li&gt;&#xA;&lt;li&gt;Avoid if there are mappings that don't work with the &lt;code&gt;.&lt;/code&gt; command (may have to use &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;noreferrer&quot;&gt;repeat.vim&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;More good places to learn more about Vim&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/&quot; rel=&quot;noreferrer&quot;&gt;Vimcasts&lt;/a&gt; - Great articles and screencasts by Drew Neil, the author of &lt;em&gt;Practical Vim&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://derekwyatt.org/vim/tutorials/&quot; rel=&quot;noreferrer&quot;&gt;Derek Wyatt's Vim Videos&lt;/a&gt; - Good collection of Vim topics.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; - Steve Losh teaches how to customize Vim from the basics to the more advanced.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;TL;DR&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Read &lt;code&gt;:help&lt;/code&gt; and try to make small incremental changes to your workflow.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-05-31T18:39:58.453" LastActivityDate="2018-05-31T18:39:58.453" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4120" PostTypeId="1" AcceptedAnswerId="4123" CreationDate="2015-07-31T15:01:02.910" Score="24" ViewCount="3976" Body="&lt;p&gt;I created an &lt;code&gt;augroup&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; containing several &lt;code&gt;autocmd&lt;/code&gt; and I need to enable/disable these &lt;code&gt;autocommand&lt;/code&gt; on the fly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to create a mapping (let's say &lt;kbd&gt;F4&lt;/kbd&gt; for example) which would enable these autocommands when pressed once and disable them when pressed again without having to source a file or reload the &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-10-01T18:27:59.977" LastActivityDate="2021-01-02T20:27:16.000" Title="How to enable/disable an augroup on the fly?" Tags="|key-bindings|autocmd|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4121" PostTypeId="2" ParentId="4120" CreationDate="2015-07-31T15:01:02.910" Score="11" Body="&lt;p&gt;&lt;em&gt;(I actually figured it out by myself but as I didn't find an answer on this site I thought that could be usefull to create a &lt;a href=&quot;https://vi.meta.stackexchange.com/a/1282/1841&quot;&gt;self-answered question&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do so it is possible to create the following function and put it in the &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleTestAutoGroup()&#xA;    if !exists('g:TestAutoGroupMarker')&#xA;        let g:TestAutoGroupMarker = 1&#xA;    endif&#xA;&#xA;    &quot; Enable if the group was previously disabled&#xA;    if (g:TestAutoGroupMarker == 1)&#xA;        let g:TestAutoGroupMarker = 0&#xA;&#xA;        &quot; actual augroup&#xA;        augroup TestAutoGroup&#xA;            autocmd! BufEnter   * echom &quot;BufEnter &quot; . bufnr(&quot;%&quot;)&#xA;            autocmd! BufLeave   * echom &quot;BufLeave &quot; . bufnr(&quot;%&quot;)&#xA;            autocmd! TabEnter   * echom &quot;TabEnter &quot; . tabpagenr()&#xA;            autocmd! TabLeave   * echom &quot;TabLeave &quot; . tabpagenr()&#xA;        augroup END&#xA;    else    &quot; Clear the group if it was previously enabled&#xA;        let g:TestAutoGroupMarker = 1&#xA;&#xA;        &quot; resetting the augroup&#xA;        augroup TestAutoGroup&#xA;            autocmd!&#xA;        augroup END&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function creates a variable used to determine if the group was previously enabled or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it wasn't enabled, the group is populated with the wanted autocommands. If the group was previously enabled we use &lt;code&gt;autocmd!&lt;/code&gt; to &quot;reset&quot; it &lt;em&gt;i.e.&lt;/em&gt; deleting the command previously entered in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A relevant documentation is &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/14.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally it is possible to create the folowing mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F4&amp;gt; :call ToggleTestAutoGroup()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to use &lt;kbd&gt;F4&lt;/kbd&gt; to call the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: Karl Yngve Lervåg suggested an &lt;a href=&quot;https://vi.stackexchange.com/revisions/4121/2&quot;&gt;improved version&lt;/a&gt; of this function which reduced the number of lines of code, I felt it would be good to keep both versions the first one being still working maybe easier to understand by a vimscript debutant like me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is Karl's improved function, many thanks to him:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleTestAutoGroup()&#xA;    &quot; Switch the toggle variable&#xA;    let g:TestAutoGroupToggle = !get(g:, 'TestAutoGroupToggle', 1)&#xA;&#xA;    &quot; Reset group&#xA;    augroup TestAutoGroup&#xA;        autocmd!&#xA;    augroup END&#xA;&#xA;    &quot; Enable if toggled on&#xA;    if g:TestAutoGroupToggle&#xA;        augroup TestAutoGroup&#xA;            autocmd! BufEnter   * echom &quot;BufEnter &quot; . bufnr(&quot;%&quot;)&#xA;            autocmd! BufLeave   * echom &quot;BufLeave &quot; . bufnr(&quot;%&quot;)&#xA;            autocmd! TabEnter   * echom &quot;TabEnter &quot; . tabpagenr()&#xA;            autocmd! TabLeave   * echom &quot;TabLeave &quot; . tabpagenr()&#xA;        augroup END&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this version the group is always reset, and if it wasn't enabled, it is populated with the wanted autocommands&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-03-16T16:43:02.423" LastActivityDate="2015-08-02T11:16:09.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4122" PostTypeId="1" CreationDate="2015-07-31T16:56:03.747" Score="1" ViewCount="121" Body="&lt;p&gt;I've been using Vim 6.3 (specifically, gvim) for years (and plain old vi for decades before that). One nice feature was that autoread would detect if the file permissions changed. I made use of that feature with the following autocmd,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * if &amp;amp;readonly | !p4edit &amp;lt;afile&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where p4edit is a shell script that, among other things, runs &quot;p4 edit&quot; on the file to open it in my Perforce sandbox and make it writable. This script would be invoked if I &quot;w!&quot; wrote the readonly file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim 6.3, vim knew from then on that the file was writable, but now with Vim 7.4, this is no longer the case. Subsequent write attempts still require &quot;w!&quot;, and the p4edit script is reinvoked each time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Likewise, if I &quot;p4 submit&quot;ed any files I had open in gvim windows, the next time I went to one of those windows, gvim would notice that the file was once again readonly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get the old behaviour back?&lt;/p&gt;&#xA;" OwnerUserId="3016" LastActivityDate="2015-07-31T16:56:03.747" Title="Vim 7.4 autoread no longer detects change of file permissions" Tags="|autocmd|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4123" PostTypeId="2" ParentId="4120" CreationDate="2015-07-31T17:43:38.973" Score="27" Body="&lt;p&gt;Building on your answer: you don't need a variable to keep state of the &lt;code&gt;augroup&lt;/code&gt;, you can use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#exists%28%29&quot;&gt;&lt;code&gt;exists()&lt;/code&gt;&lt;/a&gt; for that, provided that you know at least one of the &lt;code&gt;autocmd&lt;/code&gt;s that are part of the group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleTestAutoGroup()&#xA;    if !exists('#TestAutoGroup#BufEnter')&#xA;        augroup TestAutoGroup&#xA;            autocmd!&#xA;            autocmd BufEnter   * echom &quot;BufEnter &quot; . bufnr(&quot;%&quot;)&#xA;            autocmd BufLeave   * echom &quot;BufLeave &quot; . bufnr(&quot;%&quot;)&#xA;            autocmd TabEnter   * echom &quot;TabEnter &quot; . tabpagenr()&#xA;            autocmd TabLeave   * echom &quot;TabLeave &quot; . tabpagenr()&#xA;        augroup END&#xA;    else&#xA;        augroup TestAutoGroup&#xA;            autocmd!&#xA;        augroup END&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;F4&amp;gt; :call ToggleTestAutoGroup()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-07-31T17:43:38.973" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4124" PostTypeId="2" ParentId="4118" CreationDate="2015-07-31T17:49:30.020" Score="5" Body="&lt;p&gt;As far as I know Vim doesn't have special support for SQLite, but &lt;code&gt;mysql&lt;/code&gt; should come pretty close for this purpose:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SQLSetType mysql&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information: &lt;code&gt;:help ft_sql.txt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-07-31T17:49:30.020" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4125" PostTypeId="2" ParentId="4120" CreationDate="2015-07-31T18:33:20.737" Score="9" Body="&lt;p&gt;I find the easy way is to use a global variable. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup TestAutoGroup&#xA;  autocmd!&#xA;  autocmd BufEnter * |&#xA;        \ if get(g:, 'toggle_autocmd', 1) |&#xA;        \   echom &quot;BufEnter &quot; . bufnr(&quot;%&quot;) |&#xA;        \ endif&#xA;augroup END&#xA;&#xA;nnoremap &amp;lt;f4&amp;gt; :&amp;lt;c-u&amp;gt;let g:toggle_autocmd = !get(g:, 'toggle_autocmd', 1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h g:&#xA;:h get()&#xA;:h :if&#xA;:h :bar&#xA;:h line-continuation&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="1841" LastEditDate="2015-07-31T19:24:39.267" LastActivityDate="2015-07-31T19:24:39.267" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4126" PostTypeId="1" CreationDate="2015-08-01T00:40:04.540" Score="1" ViewCount="361" Body="&lt;p&gt;When I compile and execute a c++ program in vim it outputs &quot;command terminated&quot; however when I compile it in geany (another ide) it outputs &quot;segmentation fault&quot;. Is there a way to get vim to output the same message as geany? &lt;/p&gt;&#xA;" OwnerUserId="3022" LastActivityDate="2015-08-01T02:10:12.083" Title="Compilation terminal output" Tags="|command-line|external-command|terminal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4127" PostTypeId="1" CreationDate="2015-08-01T01:01:51.830" Score="0" ViewCount="482" Body="&lt;p&gt;I have two mappings like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;s-c&amp;gt; zz&#xA;inoremap &amp;lt;s-c&amp;gt; &amp;lt;esc&amp;gt;zza&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, I just want to use &lt;code&gt;&amp;lt;s-c&amp;gt;&lt;/code&gt; to redraw the current line to the middle of the windows in both normal and insert mode. But, surprisingly, after that mapping, I cannot enter the uppercase &lt;code&gt;C&lt;/code&gt; in insert mode any more. Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it because that the uppercase &lt;code&gt;C&lt;/code&gt; by default mapped (recursively) to the &lt;code&gt;&amp;lt;s-c&amp;gt;&lt;/code&gt;? (I guess this because in many keyboard pressing &lt;code&gt;&amp;lt;s-c&amp;gt;&lt;/code&gt;has the same effect as pressing a uppercase C, that is, you get a &lt;code&gt;C&lt;/code&gt; in your buffer.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, how can I unmap it?&lt;/p&gt;&#xA;" OwnerUserId="2760" LastEditorUserId="7161" LastEditDate="2016-05-13T19:35:26.003" LastActivityDate="2016-05-13T19:35:26.003" Title="What happens when mapping &lt;s-c&gt;?" Tags="|key-bindings|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4128" PostTypeId="2" ParentId="4126" CreationDate="2015-08-01T02:10:12.083" Score="2" Body="&lt;p&gt;When you do &lt;code&gt;:!./a.out&lt;/code&gt;, the &lt;code&gt;Segmentation fault&lt;/code&gt; message is printed &lt;a href=&quot;https://unix.stackexchange.com/a/53385/70524&quot;&gt;by the shell that ran the command&lt;/a&gt;, &lt;em&gt;not&lt;/em&gt; the command itself. You could run something like&lt;sup&gt;1&lt;/sup&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!{ ./a.out; } 2&amp;gt;&amp;amp;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This redirects the stderr of the shell within the command group, so the message from the shell is also captured:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/bin/bash: line 1:  7153 Segmentation fault      (core dumped) ./a.out&#xA;&#xA;shell returned 139&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or run the command in a subshell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!( ./a.out; )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has similar output to the above option. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With more complex programs, you'll probably end up using some sort of build system, such as &lt;code&gt;make&lt;/code&gt;. In which case, the program won't be run directly by the shell, but by the makefile, so you'll get the error message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sup&gt;1&lt;/sup&gt;This depends on the shell. I'm assuming &lt;code&gt;bash&lt;/code&gt;, and couldn't get the same effect from &lt;code&gt;zsh&lt;/code&gt;.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2015-08-01T02:10:12.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4129" PostTypeId="2" ParentId="4127" CreationDate="2015-08-01T06:46:40.623" Score="4" Body="&lt;p&gt;By mapping a character in insert mode (or any mode) you overwrite the default behaviour. In your case, mapping &lt;code&gt;nnoremap &amp;lt;s-c&amp;gt; &amp;lt;esc&amp;gt;zza&lt;/code&gt; overwrites the default behaviour of inserting a capital C. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The *noremap commands (e.g. nnoremap,inoremap,etc) do not use recursive mapping, i.e. all keys in the mapping act as though they have the default behaviour. If you would like to insert a capital C as well as using the previously mentioned mapping simply by adding it to the mapping. &lt;code&gt;nnoremap &amp;lt;s-c&amp;gt; C&amp;lt;esc&amp;gt;zza&lt;/code&gt; should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, no, you can't unmap the default behaviour for keys, only override it with other actions (including doing nothing, with &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="2283" LastEditorUserId="2283" LastEditDate="2015-08-01T07:04:08.497" LastActivityDate="2015-08-01T07:04:08.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4130" PostTypeId="2" ParentId="4108" CreationDate="2015-08-01T09:55:08.367" Score="0" Body="&lt;p&gt;No, this is not possible. Visual-block mode only allows to select rectangular areas of text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To achieve something similar to what you want, you may be interested in &lt;a href=&quot;https://github.com/terryma/vim-multiple-cursors&quot; rel=&quot;nofollow&quot;&gt;vim-multiple-cursors&lt;/a&gt;. With this plugin you can create multiple cursors, where the commands you supply will affect each cursor. Thus you could create multiple cursors for the first row of &lt;code&gt;&quot;&lt;/code&gt;s, then apply the desired editing command, such as &lt;code&gt;df&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-08-01T09:55:08.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4132" PostTypeId="1" AcceptedAnswerId="4133" CreationDate="2015-08-01T12:28:58.347" Score="2" ViewCount="840" Body="&lt;p&gt;I want to create a function which would have the same behavior as for example &lt;code&gt;:tabs&lt;/code&gt; &lt;em&gt;(the screenshot is in french but I'm sure most of you will see what I mean)&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/D6nq8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/D6nq8.png&quot; alt=&quot;tabs command screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I for now I have the folowing command which works partially:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction()&#xA;    echo &quot;foo&quot;&#xA;    echo &quot;bar&quot;&#xA;&#xA;    let test = input(&quot;Press Enter or input a command&quot;, &quot;&quot;, &quot;command&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output is shown until the user input something but the behavior is not exactly the same as the one of the built-in functions: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;With my function the line &lt;code&gt;Press Enter or input a command&lt;/code&gt; will stay on screen whereas with the built-in functions when the user press a key the blue sentence on my screenshot disappears to let the command prompt appearing. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Also I'll have to create my own code to execute the command entered by the user if he enter one.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So my question is&lt;/strong&gt;: Is there a &quot;default&quot; way to keep the ouput of my vimscript function in the command line windows on the bottom of the screen until the user press &lt;kbd&gt;Enter&lt;/kbd&gt; or input a new command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be surprised if every function with an output had to redefine this behavior but I couldn't find how it is done.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-08-01T13:39:35.643" Title="How to create a function with persistent output in the bottom of window?" Tags="|vimscript|command-line|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4133" PostTypeId="2" ParentId="4132" CreationDate="2015-08-01T13:39:35.643" Score="3" Body="&lt;p&gt;Aren't you complicating things? The message &quot;Press ENTER or type command to continue&quot; is shown by Vim everytime the command line height (which can be set with &lt;code&gt;cmdheight&lt;/code&gt; option) isn't enough to display the entire command output. So, for example, for me it's sufficient to define and call this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ShowSomething()&#xA;    echo &quot;blah\nblah\nblah\nblah&quot;&#xA;endfunction&#xA;&#xA;:call ShowSomething()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... to have the behavior you want (of course, I could also issue the &lt;code&gt;echo&lt;/code&gt; command directly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ebV7v.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ebV7v.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-08-01T13:39:35.643" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4134" PostTypeId="1" AcceptedAnswerId="4136" CreationDate="2015-08-01T16:01:32.697" Score="5" ViewCount="866" Body="&lt;p&gt;I found &lt;a href=&quot;http://vim.wikia.com/wiki/VimTip1235&quot; rel=&quot;noreferrer&quot;&gt;this vim tip&lt;/a&gt; which allows you to evaluate a Python expression and displays the result in the command line. You just have to add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -nargs=+ Calc :py print &amp;lt;args&amp;gt;&#xA;:py from math import *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your &lt;code&gt;.vimrc&lt;/code&gt; and then you can do e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Calc sum([x^2 for x in range(100)])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which displays &lt;code&gt;4950&lt;/code&gt;in my command line, as if I had executed &lt;code&gt;:echo 4950&lt;/code&gt;.&#xA;This is convenient, but I would like to know how I can either append the result at the location of my cursor, or add it to a certain register.&lt;/p&gt;&#xA;" OwnerUserId="2804" LastEditorUserId="51" LastEditDate="2015-08-01T16:03:30.587" LastActivityDate="2017-06-02T00:22:08.360" Title="Calculating with python and appending result to file or register" Tags="|command-line|register|vimscript-python|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4135" PostTypeId="2" ParentId="4134" CreationDate="2015-08-01T18:22:32.300" Score="3" Body="&lt;p&gt;I do the following: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I create somewhere a calculator.py file containing this. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; import sys                                                                  &#xA; print eval(sys.argv[1]) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in vim i can do the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;read! python calculator.py &quot;[x^2 for x in range(100)]&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3003" LastActivityDate="2015-08-01T18:22:32.300" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4136" PostTypeId="2" ParentId="4134" CreationDate="2015-08-01T19:00:49.797" Score="3" Body="&lt;pre&gt;&lt;code&gt;function! CalcAndAppend(expr)&#xA;py &amp;lt;&amp;lt; EOF&#xA;import vim&#xA;evaluated = eval(vim.eval(&quot;a:expr&quot;))&#xA;&#xA;vim.current.buffer.append(str(evaluated), vim.current.window.cursor[0])&#xA;EOF&#xA;endfunction&#xA;&#xA;function! CalcAndAppendRegister(reg, expr)&#xA;py &amp;lt;&amp;lt; EOF&#xA;import vim&#xA;evaluated = eval(vim.eval(&quot;a:expr&quot;))&#xA;evalString = &quot;'&quot; + str(evaluated) + &quot;'&quot;&#xA;register = vim.eval(&quot;a:reg&quot;)&#xA;&#xA;vim.command(&quot;let @%s=%s&quot; % (register,evalString))&#xA;EOF&#xA;endfunction&#xA;&#xA;command! -nargs=+ Calc call CalcAndAppend(&amp;lt;q-args&amp;gt;) &#xA;&#xA;command! -register -nargs=+ CalcReg call CalcAndAppendRegister(&quot;&amp;lt;reg&amp;gt;&quot;,&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usage:&lt;br&gt;&#xA;&lt;code&gt;:Calc 2+2&lt;/code&gt;&lt;br&gt;&#xA;appends &lt;code&gt;4&lt;/code&gt; to the current buffer on one line below after cursor&lt;br&gt;&#xA;&lt;code&gt;:CalcReg a sum[x^2 for x in range(100)]&lt;/code&gt; put &lt;code&gt;4950&lt;/code&gt; to the register named &lt;code&gt;a&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1145" LastEditorUserId="2804" LastEditDate="2015-08-02T23:40:05.183" LastActivityDate="2015-08-02T23:40:05.183" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4137" PostTypeId="2" ParentId="4060" CreationDate="2015-08-02T04:32:02.710" Score="2" Body="&lt;p&gt;You cannot disable control without breaking (what most would consider) needed functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basis for not being able to map from the control key itself (this question) or to the control key (other similar question) is that Vim is, at its core, a terminal application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Terminal applications are different from GUI applications in that they send and receive a character stream, rather than receiving events and drawing pixels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The history of terminals and characters and mappings is long (and still developing, for example 8bit meta vs utf-8 encoding). I appologize for the length of this answer in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The short of it is that, assuming an ASCII baseline encoding and ignoring all extended encodings (latin1, utf-8, etc) there are 127 characters that a terminal program can send or receive. 96 of those are printable (alphabet, numbers, symbols, and space), and the other 32 are control characters (things like delete, bell, or end-of-transmission-block). It is up to the terminal or terminal emulator to map key presses to these characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of these characters represent the control key itself, or the alt key itself, etc. Further, none of these represent the key being pressed vs released.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of this, it is difficult to make a regular key act like a modifier, difficult to make a modifier act as a regular key, and difficult to make one modifier act like another. Vim's mapping system is based on the characters it receives and notation like  is just a nice way of specifying the code for the given character.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;More details&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The way this usually works are that the printing characters are sent like you'd expect. Numbers and symbols send the ASCII code for that number or symbol. Lower case letters go through as the lower case letter. Shift+letter goes through as the upper case letter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is considered to be happening under-the-hood is that holding shift &lt;em&gt;modifies&lt;/em&gt; the next key. In the case of letters, the modification is to remove the 5th bit (0x20), so 'a' being 0x61 becomes 'A' at 0x41, and 'z' being 0x7A becomes 'Z' at 0x5A. (this is a convenient way of thinking about it at anyrate. I think the actual progression was different).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The control key is another modifier, which instead of clearing bit 5 while held down, clears bits 5 and 6 (0x60), so 'a' goes from 0x61 to just 0x1 which is ASCII start of header. 'm' with the control key gets converted from 0x6D to 0xD which is carraige return, which is also what the Enter key sends. This is why ctrl+m and enter are mapped the same time in Vim; they are the same character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since there is no upper or lowercase with control (the shift clearing bit is included with control), and keyboard keys are usually shown in upper-case, and old systems didn't have lower case anyway, the convention is showing uppercase. To designate that it is a representation of a control key, a &lt;code&gt;^&lt;/code&gt; is placed before it. For example, a literal bel character in a file opened by Vim will be displayed as &lt;code&gt;^G&lt;/code&gt;. This allows a printable representation of an unprintable character. This doesn't cover all 31 control characters though. I don't know the reasoning behind the others, such as ^@ for null or ^^ for 0x1E (often typed as ctrl+6 regardless of where the &lt;code&gt;^&lt;/code&gt; key is on your keyboard). Another interesting one on my system is that ctrl+4 is equal to ^\, and control+\ is the code to terminate (vs ctrl+c to interrupt) the running program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alt/meta is another issue. There aren't other characters in ASCII left to reference. Many GUI terminal emulators have configuration options on how to handle this. Popular methods are to send an escape char followed by the key pressed with alt (complete with shift processing). Another is to treat it as a modifier that sets bit 8. The former can cause Vim to leave insert mode (because of the escape), the latter can break encoding (that is, collides with latin1 or whatever characters, or starts an utf-8 sequence)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Specifically on disabling control key&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Because you can map characters, one option is to map every character that results from modifying a typed character with a control key to a nop, as in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;c-a&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;c-b&amp;gt; &amp;lt;nop&amp;gt;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however, because several keys are equivalent, you would cause a removal of those functions as well. This includes aborting the current action (ctrl+c), the enter key (ctrl+m), backspace (ctrl+h or ctrl+?, another long story about those two that I won't get into now), tab (ctrl+i), and escape (ctrl+[).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might be willing to do this, of course. All of the functionality except ctrl+c and escape key can be done with normal commands, if you only disable these in insert mode (e.g. escape + o instead of just enter while in insert mode, or &lt;code&gt;escape&lt;/code&gt;, &lt;code&gt;x&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt; instead of backspace in insert mode. Tab could probably be inserted by writing a function that generates it, or by yanking an existing one into a register for subsequent paste). The action of escape could be mapped to something else, like &lt;code&gt;jj&lt;/code&gt; to get you our of insert mode. However, other keys that start with escape will also break if you map out the escape key itself. This includes the F1 through Fn keys, arrow keys, in some cases the number pad, sometime the delete key, page up/down, home/end, and depending on your setup, anything with the alt key pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course blanket disabling would cause problems. How can you execute an ex command if you don't have enter/ctrl+m? Maybe &lt;code&gt;jj&lt;/code&gt; escapes and &lt;code&gt;jk&lt;/code&gt; executes? But then you have to hope you never need &lt;code&gt;jk&lt;/code&gt; anywhere in your command. You wouldn't even be able do do something like j space backspace k to avoid the mapping, because you wouldn't have backspace either.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Additional thoughts&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In OP's comments, it is mentioned that the reason for disabling control is to train to do things that don't use control. Some comments mention modyfing the key mappings at the OS level, which would remove being able to send control characters with the control key without disabling the terminal receiving tab and enter from the OS and sending those as control characters itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I must recommend that if your fingers are getting sore with your current setup, the best thing you can do is probably to change your setup. Everyday typing should not make you sore. A few options are to take more breaks from typing, adjusting your typing position, and/or obtaining a more ergonomic keyboard (not generically, but suited to your needs). At any rate, let the soreness itself be the guide to reducing or removing the habit that induces the sorenes; rather than jumping to disable the functionality of the system, try to be more concious of what you are doing to notice when you do something you don't wish to do. (hopefully that's neither too zen nor too useless)&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-08-02T04:32:02.710" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4138" PostTypeId="2" ParentId="4134" CreationDate="2015-08-02T07:26:38.370" Score="5" Body="&lt;p&gt;That's what &lt;code&gt;pyeval()&lt;/code&gt; is good for.  The only (minor) inconvenience is that you have to quote the expression you want to evaluate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a = pyeval('sum([x^2 for x in range(100)])')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works for all data types, and you can do with it everything you can do with a Vim expression.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo pyeval('[x^2 for x in range(100)]')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-08-02T07:26:38.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4139" PostTypeId="1" CreationDate="2015-08-02T20:46:30.617" Score="5" ViewCount="2162" Body="&lt;p&gt;I've got a somewhat obfuscated javascript file with multiple variables named &lt;code&gt;a##########&lt;/code&gt;, where &lt;code&gt;#&lt;/code&gt; stands for a single &lt;code&gt;0-9&lt;/code&gt; digit. Each such identifier may or may not be unique.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was substituting these manually, using &lt;code&gt;:%s/&amp;lt;c-r&amp;gt;k/f#/g&lt;/code&gt;, where &lt;code&gt;k&lt;/code&gt; was the register I put one of these identifiers and &lt;code&gt;#&lt;/code&gt; was a number I was incrementing manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This soon proved quite slow and tedious, as well as error-prone, so I decided to do them all at once, automatically. I tried the help files and online and came up with this (after I'd named the first 30 occurrences manually):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let: counter = 31 | g/a\d\{10\}/s//\=&quot;f&quot;.counter/ | let counter = counter + 1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This worked, except instead of running each substitution globally, it ran it for each match individually, thus distorting the meaning of the identifiers (e.g. where there would be &lt;code&gt;a234789453&lt;/code&gt; 5 times, it would give me &lt;code&gt;f1&lt;/code&gt;, &lt;code&gt;f2&lt;/code&gt; etc. for each match, instead of replacing all instances of the same match with the same text).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I ran the same, placing the regex in &lt;code&gt;s&lt;/code&gt;'s call and using the &lt;code&gt;g&lt;/code&gt; flag for &lt;code&gt;s&lt;/code&gt; and got the same results, whether I made these modifications to the original command alone or separately. Then I tried:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let: counter = 31 | %s/a\d\{10\}/\=&quot;f&quot;.counter/ | let counter = counter + 1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which resulted in &lt;em&gt;all&lt;/em&gt; occurences of the pattern being replaced by &lt;code&gt;f31&lt;/code&gt;, regardless of the &lt;code&gt;g&lt;/code&gt; flag or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clearly, the issue is that I need to run &lt;code&gt;%s/__match__/\=&quot;f&quot;.counter/g&lt;/code&gt; for each match specifically, but I can't seem to find a way to explain this to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to run a global substitute for each unique match of a regex?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1275" LastActivityDate="2016-09-26T14:29:07.973" Title="Run global substitute for each match of a regex, with increment" Tags="|regular-expression|substitute|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4141" PostTypeId="1" AcceptedAnswerId="4142" CreationDate="2015-08-02T23:15:13.130" Score="77" ViewCount="94796" Body="&lt;p&gt;I am coding some html templates in JADE files.  I want to auto indent code with spaces instead of tab. I tried &lt;code&gt;shiftwidth=2&lt;/code&gt;, &lt;code&gt;tabstop=2&lt;/code&gt;, but no matter what, it's still indents using tabs instead of spacebar, which causes the JADE compile to throw errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I auto indent large sections of code using spaces instead of tabs?&lt;/p&gt;&#xA;" OwnerUserId="3030" LastEditorUserId="28" LastEditDate="2017-12-30T23:18:56.887" LastActivityDate="2020-04-18T01:50:30.880" Title="How to indent as spaces instead of tab?" Tags="|indentation|whitespace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4142" PostTypeId="2" ParentId="4141" CreationDate="2015-08-02T23:39:27.033" Score="70" Body="&lt;p&gt;You are looking for the &lt;code&gt;expandtab&lt;/code&gt; option.  When this option is set, spaces are &lt;em&gt;always&lt;/em&gt; used.  You can put &lt;code&gt;set expandtab&lt;/code&gt; in your vimrc to always have this option set when vim starts.  If you want to only enable this option for specific languages, see &lt;a href=&quot;https://vi.stackexchange.com/questions/4/how-can-i-change-the-default-indentation-based-on-filetype/&quot;&gt;this question&lt;/a&gt;.  For help on this option, see &lt;code&gt;:help 'expandtab'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-08-02T23:39:27.033" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4143" PostTypeId="2" ParentId="4111" CreationDate="2015-08-03T01:46:09.983" Score="3" Body="&lt;p&gt;You can learn a great deal by following the questions and answers on the &lt;code&gt;vim&lt;/code&gt; or &lt;code&gt;vim_use&lt;/code&gt; mailing list, &lt;a href=&quot;http://vim.sourceforge.net/maillist.php#vim&quot; rel=&quot;nofollow&quot;&gt;http://vim.sourceforge.net/maillist.php#vim&lt;/a&gt;. While this StackExchange site is great for simple questions and answers, the mailing list is better for questions that require some discussion.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-08-03T01:46:09.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4144" PostTypeId="1" CreationDate="2015-08-03T03:59:00.290" Score="2" ViewCount="779" Body="&lt;p&gt;Editing files containing Devanagari script (or other Indian scripts) in vim doesn't work out of the box. I have not found a satisfactory solution for it yet and would like to hear if anybody else has. &lt;/p&gt;&#xA;" OwnerUserId="2774" LastActivityDate="2015-08-03T03:59:00.290" Title="Editing files containing Devanagari script" Tags="|unicode|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4145" PostTypeId="2" ParentId="4139" CreationDate="2015-08-03T04:25:55.603" Score="3" Body="&lt;p&gt;I couldn't find a simple one-liner with the functionality you want, but I did cook up a script for it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Replacer(regexp, start)&#xA;    let elems = []&#xA;    &quot; Loop through all matches of regexp&#xA;    call cursor(1, 1)&#xA;    let [lnum,col] = searchpos(a:regexp, 'cW')&#xA;    while [lnum,col] != [0,0]&#xA;        &quot; if match isn't already in the list, add it&#xA;        if count(elems, expand(&quot;&amp;lt;cword&amp;gt;&quot;)) == 0&#xA;            call add(elems, expand(&quot;&amp;lt;cword&amp;gt;&quot;))&#xA;        endif&#xA;        let [lnum,col] = searchpos(a:regexp, 'W')&#xA;    endwhile&#xA;    &quot; Set initial counter&#xA;    let counter = a:start&#xA;    &quot; For each element, replace with new token&#xA;    for elem in elems&#xA;        exe '%s/'.elem.'/\=&quot;f&quot;.counter/g'&#xA;        let counter += 1&#xA;    endfor&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would then do &lt;code&gt;:call Replacer('a\d\{10\}', 31)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How it works&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As you saw with your two commands, a global command marks by line instead of by match, and the whole file replacement completes the full replace before doing any increments to your counter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What we need is to store a list of unique matches, and then iterate through the matches doing a whole file replacement of that match, incrementing the counter as we go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, we create a variable to track our matches. We want it to be a list. I called it elems: &lt;code&gt;let elems = []&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, we want to walk through the file searching for the regexp. First, we need to position the cursor at the top of the file, so we &lt;code&gt;call cursor(1, 1)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we start our loop. Each time we'll call &lt;code&gt;searchpos(&lt;/code&gt;. We use the &lt;code&gt;W&lt;/code&gt; flag to prevent wrap-around, so that our loop ends at the end of the file. On the very first invokation, we also add the &lt;code&gt;c&lt;/code&gt; flag to catch if the regexp matches the very beginning of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At each return of &lt;code&gt;searchpos&lt;/code&gt; the cursor has moved to the match. I made an assumption that the regexp is going to match the whole or beginning of a &lt;em&gt;word&lt;/em&gt; that we want to replace, instead of replacing just the match. So, we check if the &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; is already in our &lt;code&gt;elems&lt;/code&gt; list using the &lt;code&gt;count&lt;/code&gt; function. If it isn't, we add it using the &lt;code&gt;add&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that we have our list of unique matches, we set the counter to the desired start value &lt;code&gt;let counter = a:start&lt;/code&gt;, where the start was passed as an argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, we iterate over our list with a basic for loop &lt;code&gt;for elem in elems&lt;/code&gt; and build up a whole-file replacement command with &lt;code&gt;exe&lt;/code&gt;. I could have built up the replacement text directly, as in &lt;code&gt;/f' . counter . '/g'&lt;/code&gt; but I wanted to keep the replacement closer to your example, so I only inserted the value of &lt;code&gt;elem&lt;/code&gt; into the search, and let the replacement be the expression &lt;code&gt;&quot;f&quot;.counter&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Increment the counter after each full replacement &lt;code&gt;counter += 1&lt;/code&gt; and we are done.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Example run&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Given the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main() {&#xA;    int a1234567890;&#xA;    int a4820510384;&#xA;&#xA;    a1234567890 = 5;&#xA;    a4820510384 = 7;&#xA;&#xA;    a4820510384 += a1234567890;&#xA;&#xA;    return a1234567890*a4820510384 + a4820510384;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(sorry for the example being a c file isntead of javascript; the replacement should work just as well for javascript or any language where cword behaves appropriately)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call Replacer('a\d\{10\}',31)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;shows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4 substitutions on 4 lines&#xA;5 substitutions on 4 lines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main() {&#xA;    int f31;&#xA;    int f32;&#xA;&#xA;    f31 = 5;&#xA;    f32 = 7;&#xA;&#xA;    f32 += f31; &#xA;&#xA;    return f31*f32 + f32;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="227" LastActivityDate="2015-08-03T04:25:55.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4146" PostTypeId="2" ParentId="4139" CreationDate="2015-08-03T07:26:27.743" Score="5" Body="&lt;p&gt;Although I think John's answer is quite good, I thought of a different way to achieve this. It still requires a custom function, but it is a little bit simpler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to create an incrementer object that keeps track of the individual variable IDs. To do this, we define a dictionary with an incrementer function (you can add this for example to your vimrc):&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:incrementer = {&#xA;      \ 'n' : 31,&#xA;      \ 'ids' : {},&#xA;      \ }&#xA;&#xA;function! g:incrementer.increment(id)&#xA;  if !has_key(self.ids, a:id)&#xA;    let self.ids[a:id] = self.n&#xA;    let self.n += 1&#xA;  endif&#xA;&#xA;  return 'f' . self.ids[a:id]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the above code loaded, you can perform the substitution similar to how you tried it yourself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/a\d\{10\}/\=g:incrementer.increment(submatch(1))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-08-03T07:26:27.743" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4147" PostTypeId="2" ParentId="4139" CreationDate="2015-08-03T07:37:53.320" Score="10" Body="&lt;p&gt;While the other solutions involving VimL should work just fine, the simple (and to some extent straightforward) approach is to use a macro.  The trick is to make the macro recursive, to replace all variables automatically:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:let cnt = 31&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; - initialize &lt;code&gt;cnt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qqq&lt;/code&gt; - clear register &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; - start recording a macro named &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/\v&amp;lt;a\d{10}&amp;gt;&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; - search for variable names&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;*&lt;/code&gt; - set the search register &lt;code&gt;@/&lt;/code&gt; to match the current variable&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s//\='f'.cnt/g&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; - humanize the current variable&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:let cnt += 1&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; - update &lt;code&gt;cnt&lt;/code&gt; for the next variable&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@q&lt;/code&gt; - recursively invoke the current macro; the macro stops at the first error, namely when &lt;code&gt;/\v&amp;lt;a\d{10}&amp;gt;&lt;/code&gt; no longer matches anything&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; - finish recording the macro.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then you'd just run the macro: &lt;code&gt;@q&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1577" LastActivityDate="2015-08-03T07:37:53.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4148" PostTypeId="1" AcceptedAnswerId="4282" CreationDate="2015-08-03T08:21:13.643" Score="33" ViewCount="17481" Body="&lt;p&gt;I know I can join lines in Vim with &lt;code&gt;J&lt;/code&gt; and several variants thereof (&lt;code&gt;gJ&lt;/code&gt;, etc.); &lt;code&gt;J&lt;/code&gt; will &lt;em&gt;&quot;Remove the indent and insert up to two spaces&quot;&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But is there also a straightforward way to insert another character instead of the two spaces? For example a comma (&lt;code&gt;,&lt;/code&gt;) or comma &amp;amp; space (&lt;code&gt;,&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;8&#xA;9&#xA;10&#xA;32&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;8, 9, 10, 32&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;8,9,10,32&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2020-11-30T16:16:16.530" Title="Can I join lines with a comma (or another character)?" Tags="|line-breaks|" AnswerCount="7" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4149" PostTypeId="2" ParentId="4148" CreationDate="2015-08-03T08:27:12.227" Score="38" Body="&lt;p&gt;A simple way is this: simply select your lines (all but the last one)  - or use &lt;code&gt;%&lt;/code&gt; - and run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\n/,/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\n/, /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(where, of course, the &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; part was already inserted after &lt;code&gt;:&lt;/code&gt; by Vim, to target the selection)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;(2nd) Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Building on the above (and &lt;a href=&quot;https://vi.stackexchange.com/users/2313/sato-katsura&quot;&gt;Sato Katsura&lt;/a&gt;'s comment), here's a possible &quot;interactive join&quot; implementation, with count and optional repeat support:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ================ script ===============================================&#xA;&quot; interactive 'J', 'gJ' replacement with optional 'vim-repeat' support&#xA;&quot; The last used separator is automatically reused as:&#xA;&quot; a. default choice&#xA;&quot; b. when repeating (=&amp;gt; non-interactive repeats: same range, same separator)&#xA;let g:last_join_separator = &quot; &quot;&#xA;function! s:interactiveJoin(use_last_sep,...) range&#xA;    if (a:use_last_sep == 0) &quot;interactive, ask for separator to use&#xA;        call inputsave()&#xA;        echohl Question&#xA;        let l:sep = input(&quot;Separator:&quot;, g:last_join_separator)&#xA;        echohl None&#xA;        call inputrestore()&#xA;        redraw!&#xA;        let g:last_join_separator = l:sep &quot;update last separator value&#xA;    else &quot;non-interactive (when repeating with '.')&#xA;        let l:sep = g:last_join_separator&#xA;    endif&#xA;    if (a:0 == 0) &quot;with no argument, remove indentation *and trailing spaces*&#xA;        let l:subst = 's/\s*\n\+\s*/\=' . &quot;'&quot; . l:sep . &quot;'/&quot;&#xA;    else &quot; don't remove indentation or trailing spaces (act like 'gJ')&#xA;        let l:subst = 's/\n\+/\=' . &quot;'&quot; . l:sep . &quot;'/&quot;&#xA;    endif&#xA;    if a:firstline &amp;lt; a:lastline &quot;join given range&#xA;        execute a:firstline . ',' . (a:lastline - 1) . l:subst&#xA;        let l:count = a:lastline - a:firstline + 1 &quot;default count for repeat&#xA;    else &quot;or join only with next line&#xA;        execute l:subst&#xA;        let l:count = 1 &quot;default count for repeat&#xA;    endif&#xA;    &quot;make command repeatable&#xA;    &quot;(with the tpope/vim-repeat plugin: optional, recommended)&#xA;    if (a:0 == 0)&#xA;        silent! call repeat#set(&quot;\&amp;lt;Plug&amp;gt;(repeatJoin)&quot;, l:count)&#xA;    else&#xA;        silent! call repeat#set(&quot;\&amp;lt;Plug&amp;gt;(repeatGJoin)&quot;, l:count)&#xA;    endif&#xA;endfunction&#xA;&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(interactiveJoin)  :call &amp;lt;SID&amp;gt;interactiveJoin(0)&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(interactiveGJoin) :call &amp;lt;SID&amp;gt;interactiveJoin(0,'g')&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(repeatJoin)       :call &amp;lt;SID&amp;gt;interactiveJoin(1)&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(repeatGJoin)      :call &amp;lt;SID&amp;gt;interactiveJoin(1,'g')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And an actual mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;================= vimrc ================================================&#xA;nmap J &amp;lt;Plug&amp;gt;(interactiveJoin)&#xA;xmap J &amp;lt;Plug&amp;gt;(interactiveJoin)&#xA;nmap gJ &amp;lt;Plug&amp;gt;(interactiveGJoin)&#xA;xmap gJ &amp;lt;Plug&amp;gt;(interactiveGJoin)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is kinda(*) like &lt;code&gt;J&lt;/code&gt;, but interactive - it will prompt for the separator string. The default string is a space - so, for example, to join lines with no separator, hit &lt;code&gt;Backspace&lt;/code&gt; when prompted, to remove the default space character, and &lt;code&gt;Enter&lt;/code&gt; to accept the (now) empty separator. Count, e.g. &lt;code&gt;3J&lt;/code&gt;, also works. If &lt;code&gt;tpope/vim-repeat&lt;/code&gt; plugin is installed, repeating with '.' will also work, reusing the last separator and (if not changed - e.g. &lt;code&gt;10.&lt;/code&gt;) the last count or visual line range.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(*) It's not &lt;em&gt;exactly&lt;/em&gt; like &lt;code&gt;J&lt;/code&gt;,though: while it will remove indentation, it won't check for &lt;code&gt;.!?&lt;/code&gt; (end of phrase) to insert 2 spaces instead of one, or insert a space only if it's missing (it's hard to do something like this, since the separator string can be anything now). It will also remove trailing spaces (makes more sense).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this might be a nice way to overload the limited operators letter-space :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, technically &lt;code&gt;J&lt;/code&gt; is not quite an operator, but close to one - for example, you can't do &lt;code&gt;Jaw&lt;/code&gt;, to join &quot;a word&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(suggestions are welcome)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CYPGB.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CYPGB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-08-05T21:24:50.057" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4150" PostTypeId="1" CreationDate="2015-08-03T09:13:03.237" Score="3" ViewCount="243" Body="&lt;p&gt;I am trying to change a text file with data in 'document' form into unnormalized csv. The data are a list of hymn authors ('document header') and for each author a list of one or more hymns they have written ('document line'). The specific operation I am struggling with is taking each 'document header' and prepending it to the one or more 'document lines' that follow it.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Example data&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;For example, I want to turn this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Beskow Natanael&#xA;    140     Ack saliga dag&#xA;    399     Tränger i dolda djupen ner&#xA;    478     Ditt verk är stort&#xA;    479     Kärlek av höjden&#xA;Bexell Göran&#xA;    103     Herren lever våga tro det&#xA;Béze Théodore de&#xA;    283     Lovsjung nu alla länder Gud&#xA;    360     Såsom hjorten ivrigt längtar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Beskow Natanael,140,Ack saliga dag&#xA;Beskow Natanael,399,Tränger i dolda djupen ner&#xA;Beskow Natanael,478,Ditt verk är stort&#xA;Beskow Natanael,479,Kärlek av höjden&#xA;Bexell Göran,103,Herren lever våga tro det&#xA;Béze Théodore de,283,Lovsjung nu alla länder Gud&#xA;Béze Théodore de,360,Såsom hjorten ivrigt längtar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The specific change that I am struggling with is taking the 'document header' and prepending it to each 'document line' so I am leaving the other changes (removing the header, comma between hymn number and hymn title, etc.) to one side for the moment.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I could write a function to do this change, but I find that I am collecting quite a number of ad hoc functions for different editing operations, so I would prefer to learn how to do it with a &lt;code&gt;global&lt;/code&gt; command, or, if it is not a suitable operation to perform with &lt;code&gt;global&lt;/code&gt;, to understand why. &lt;strong&gt;How can I do this operation with &lt;code&gt;global&lt;/code&gt;; and, if I can't, why?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;What I have tried&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I have tried using the &lt;code&gt;:global&lt;/code&gt; command to execute different combinations of &lt;code&gt;normal&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;1) Yank, move, put&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g/^\S/normal! y$jPa,&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I take this to mean&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;for each line beginning with non-whitespace&lt;/li&gt;&#xA;&lt;li&gt;yank to end-of-line into unnamed register&lt;/li&gt;&#xA;&lt;li&gt;move down one line and put before from unnamed register&lt;/li&gt;&#xA;&lt;li&gt;append a comma&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This works, but only for each first 'document line'. The result is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Beskow Natanael&#xA;Beskow Natanael,    140     Ack saliga dag&#xA;    399     Tränger i dolda djupen ner&#xA;    478     Ditt verk är stort&#xA;    479     Kärlek av höjden&#xA;Bexell Göran&#xA;Bexell Göran,    103     Herren lever våga tro det&#xA;Béze Théodore de&#xA;Béze Théodore de,    283     Lovsjung nu alla länder Gud&#xA;    360     Såsom hjorten ivrigt längtar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To repeat the put operation on each 'document line' I think I would need to know how many there are and put in a loop, and I don't see an easy way to do that without writing a custom function.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;2) Yank, visually select, substitute&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To avoid having to count I thought I could instead visually select the 'document lines' and insert the 'document header' with a substitute over the visual selection.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^\S/normal! y$v/^\S^M:s/^\s/\=@&quot; . &quot;,&quot; . submatch(0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I intend this command to mean the following&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;for each line beginning with non-whitespace&lt;/li&gt;&#xA;&lt;li&gt;yank to the end of line&lt;/li&gt;&#xA;&lt;li&gt;visually select until the next line beginning with non-whitespace&lt;/li&gt;&#xA;&lt;li&gt;substitute over visual selection&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;match beginning-of-line + whitespace&lt;/li&gt;&#xA;&lt;li&gt;substitute contents of unnamed register + a comma + the entire match (i.e., the whitespace)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This command does not work at all.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It does not change the buffer at all.&lt;/li&gt;&#xA;&lt;li&gt;It leaves me in visual mode, with the last character on the first line selected.&lt;/li&gt;&#xA;&lt;li&gt;Hitting &lt;code&gt;/&amp;lt;Up&amp;gt;&lt;/code&gt; to look at the last search pattern shows &lt;code&gt;/^\S^M:s/^\s/\=@&quot; . &quot;,&quot; . submatch(0)&lt;/code&gt;. This tells me that the &lt;code&gt;^M&lt;/code&gt; does not execute the search as I had hoped, but rather everything following &lt;code&gt;/&lt;/code&gt; is interpreted as part of the pattern.&lt;/li&gt;&#xA;&lt;li&gt;Checking the unnamed register after running the command, it contains the last 'document header' in the buffer. This tells me that it goes through the buffer and performs the yank operation.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If, however, I type out the normal mode commands manually they work as expected.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-08-03T21:36:19.770" Title="How can I use the `global` command to prepend 'document headers' to 'document lines'?" Tags="|cut-copy-paste|repeated-commands|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4151" PostTypeId="2" ParentId="4091" CreationDate="2015-08-03T10:32:06.210" Score="2" Body="&lt;p&gt;So finally decided to create my own plugin to solve my problem, it is available on &lt;a href=&quot;https://github.com/statox/betterTabs.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used the idea of @philolo1 and tried to complete it, at the time I'm writting this answer it is still a work in progress.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; I no longer maintain the plugin as my workflow as evolved and I realized binding buffers to a tab adds more problem than it solves.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The plugin binds buffers to tabs: When the user open a buffer, it is automatically &quot;stored&quot; in the tab and can't be accessed from another tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The installation should be &quot;plugin manager friendly&quot; &lt;em&gt;(at least it works well with &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim-Plug&lt;/a&gt; and &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vundle&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the main features are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Automatically handle the binding of buffers (the user can open them as he did before)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:NextBuf&lt;/code&gt; and &lt;code&gt;:PrevBuf&lt;/code&gt; replace &lt;code&gt;:bn&lt;/code&gt; and &lt;code&gt;:bN&lt;/code&gt; to keep a consistent state of the tabs&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:ListBuf&lt;/code&gt; allows to list the buffers similarly to &lt;code&gt;:ls&lt;/code&gt; excepted that they are separated in tabs and a sign let the user see easily in which tab he currently is.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:ChangeBuf&lt;/code&gt; accept a buffer number or a buffer name to change of buffer and change of tab automatically&lt;/li&gt;&#xA;&lt;li&gt;Closing a buffer is done with &lt;code&gt;:CloseBuf&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Closing a tab is done with &lt;code&gt;:CloseTab&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For other operations the user should be able to use the built-in features (like &lt;code&gt;:tabopen&lt;/code&gt;, &lt;code&gt;:tabnext&lt;/code&gt;, etc...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For each commands some default mappings are provided and they can be easily disabled by adding &lt;code&gt;let g:betterTabsVim_map_keys = 0&lt;/code&gt; to your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried to make an explicit help file (&lt;code&gt;:h betterTabs.txt&lt;/code&gt;): it is not complete yet but users should find the minimum to use the plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still have a lot of testing to do to be sure that the plugin doesn't mess any native behavior. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally if anyone wants to help it is always possible de create issues on the &lt;a href=&quot;https://github.com/statox/betterTabs.vim/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;github page&lt;/a&gt; or to create pull requests.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-04-03T08:39:36.807" LastActivityDate="2018-04-03T08:39:36.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4152" PostTypeId="1" AcceptedAnswerId="4157" CreationDate="2015-08-03T10:38:29.770" Score="1" ViewCount="1550" Body="&lt;p&gt;One of the reasons i prefer to run Vim from a terminal instead of running gVim is that the output of external gets cluttered up by escape sequences each time I execute commands like &lt;code&gt;ls&lt;/code&gt; and &lt;code&gt;grep&lt;/code&gt; that I have aliased to colorize the output in my &lt;code&gt;.bashrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When executing &lt;code&gt;:!ls&lt;/code&gt; I get output that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[0m[01;34mDesktop[0m    [01;34mDocuments[0m    [01;34mDownloads[0m&#xA;[01;34mGit[0m    [01;34mMail[0m    [01;34mMusic[0m&#xA;[01;34mPictures[0m    [01;34mProgramming[0m&#xA;[01;34mPublic[0m    [01;34mSoftware[0m    [01;34mTemplates[0m    todo.txt    [01;34mVideos0m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Screenshot here:&lt;a href=&quot;https://i.stack.imgur.com/kbeDJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kbeDJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try executing &lt;code&gt;:!vi&lt;/code&gt; in gVim and your entire screen will explode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a solution to this problem? Is it possible to make gVim discard escape sequences when printing the output of an external command?&lt;/p&gt;&#xA;" OwnerUserId="3032" LastActivityDate="2015-08-03T12:22:09.510" Title="Escape sequences from external commands cluttering output in GVim" Tags="|external-command|gvim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4153" PostTypeId="2" ParentId="4150" CreationDate="2015-08-03T10:50:00.540" Score="2" Body="&lt;p&gt;This is one way to do it (I'm sure it's not perfect, but it gets the job done):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/./if getline('.')[0] =~ '\w' | delete | else | s/\s\+\(\w\+\)\s\+\(\w\+\)/\=@&quot; . ',' . submatch(1) . ',' . submatch(2)/ | -join! |endif&#xA;:g/^$/delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW, this would look much nicer if you would allow yourself to use functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is, you use &lt;code&gt;global&lt;/code&gt; to match both headers and non-headers (=&gt; non-empty lines), but act differently on them: if it's a header, delete it (=&gt; it's yanked to the default register), if not, replace first spaces with the current header (by yanking it back from the default register) followed by a comma, and the next spaces with a comma.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, instead, you only &lt;em&gt;search&lt;/em&gt; for headers, it's harder to then &lt;em&gt;act&lt;/em&gt; on non-header lines.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-08-03T13:21:41.833" LastActivityDate="2015-08-03T13:21:41.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4154" PostTypeId="2" ParentId="4152" CreationDate="2015-08-03T10:51:43.447" Score="2" Body="&lt;p&gt;The issue is that gVim doesn't emulate a full terminal, in this particular case, it doesn't recognize colour codes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is simply something you can't do in gVim, unless you spawn a new terminal with &lt;code&gt;:!xterm -e 'ls &amp;amp;&amp;amp; read'&lt;/code&gt;, use &lt;code&gt;:!/bin/ls&lt;/code&gt; to prevent loading your &lt;code&gt;ls&lt;/code&gt; alias which adds colours, or filter the colors with something like &lt;code&gt;:!ls | sed 's|\x1b\[[;0-9]*m||g'&lt;/code&gt; (I have that &lt;code&gt;sed&lt;/code&gt; command as a shell alias).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;a href=&quot;https://vi.stackexchange.com/a/2458/51&quot;&gt;What additional features do gVim and/or MacVim offer compared to Vim inside a terminal emulator?&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-08-03T10:51:43.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4155" PostTypeId="2" ParentId="4150" CreationDate="2015-08-03T11:07:51.227" Score="0" Body="&lt;p&gt;The second command is missing a final &lt;code&gt;^M&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to understand why the second command works if the normal mode commands are executed manually, but not from within the global command, I recorded the successful sequence of commands as a macro. In the register I find&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y$v/^\S^M:s/^\s/\=@&quot;.&quot;,&quot;.submatch(0)^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Lo and behold, if I use this sequence with &lt;code&gt;global&lt;/code&gt;, which gives an identical command to the second one in the question &lt;strong&gt;except for the additional &lt;code&gt;^M&lt;/code&gt; at the end&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^\S/normal! y$v/^\S^M:s/^\s/\=@&quot;.&quot;,&quot;.submatch(0)^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does not, however, finish the last 'document' in the buffer, since there is no start-of-line+non-whitespace to search forward to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a little disappointed about that being the solution and I'm not sure whether I should edit the question, close it, or leave it like it is. I'll leave it for a while and see if there are more answers, explanations or comments–I'm sure that, even if this global command now works (except for the last line), it could still be improved upon.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-08-03T11:07:51.227" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4156" PostTypeId="2" ParentId="4150" CreationDate="2015-08-03T11:44:30.407" Score="3" Body="&lt;p&gt;This just screams &quot;macro and normal&quot; for me. First, a comma after each name would be helpful as a name terminator, so execute &lt;code&gt;:g/^\S/normal A,&lt;/code&gt; first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start somewhere on line 2 and type&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; to start recording into buffer q&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0ma&lt;/code&gt; to go to the start of the line and save the position at mark a&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;?^\S&amp;lt;Enter&amp;gt;&lt;/code&gt; to search backward for the next line that does not start with a whitespace (you could also just go 1 line backwards, but add a &lt;code&gt;0&lt;/code&gt; in that case to go to the start of the line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yf,&lt;/code&gt; to yank to the first comma, including it, which should be the name by what we did in the first step&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'a0&lt;/code&gt; to return to the line of the mark a and go to the beginning (use `a instead, we saved at the beginning of the line, but I can't type that here with the grey background)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; to paste&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0x&lt;/code&gt; to delete the whitespace at the beginning&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; to stop recording&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That seems to do what you want, adjust accordingly (you could skip the first step in various circumstances, e.g. if all the lines that start with a whitespace have a numeral as the first non-whitespace character... but since you wanted to add commata anyways, I went that way). Now just use &lt;code&gt;:g/^\s/normal! @q&lt;/code&gt; to execute the macro we saved in buffer q (&lt;code&gt;@q&lt;/code&gt;) on each line that starts with a whitespace (&lt;code&gt;^\s&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works for your example. It has the additional advantage of being adjustable for the other changes you probably want to do, just by changing the macro when recording it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Macros&quot; rel=&quot;nofollow&quot;&gt;http://vim.wikia.com/wiki/Macros&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/390174/in-vim-how-do-i-apply-a-macro-to-a-set-of-lines&quot;&gt;https://stackoverflow.com/questions/390174/in-vim-how-do-i-apply-a-macro-to-a-set-of-lines&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;for more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed you might want to get right of the author-only lines, and that might be hard later on. Just insert a &lt;code&gt;:g/^\s/normal J&lt;/code&gt; after the first step, which produces 1 correct line and gets rid of the author-only line for each author, and then proceed with the macro as given.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="1306" LastEditDate="2015-08-03T21:36:19.770" LastActivityDate="2015-08-03T21:36:19.770" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4157" PostTypeId="2" ParentId="4152" CreationDate="2015-08-03T12:22:09.510" Score="2" Body="&lt;p&gt;You should take a look at the manual of those commands: they may allow you to define when to show colors or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ls&lt;/code&gt;, for example, has the &lt;code&gt;--color=auto&lt;/code&gt; option that makes it show colors only when possible.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-08-03T12:22:09.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4158" PostTypeId="1" AcceptedAnswerId="4162" CreationDate="2015-08-03T13:16:00.050" Score="8" ViewCount="145" Body="&lt;p&gt;I'm writing LaTeX code which has a lot of sections like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{definition}&#xA;blah blah blah ...&#xA;...&#xA;\end{definition}    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In normal text, I'm very fond of &lt;code&gt;gq]&lt;/code&gt; to rewrap everything nicely. Inside a block section like the above, that wraps the end command too, which I'd rather keep on a separate line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to tell vim that a line starting &lt;code&gt;\end&lt;/code&gt; ends a paragraph? Or is there another formatting command I can use (I have &lt;code&gt;&amp;lt;F8&amp;gt;&lt;/code&gt; mapped to &lt;code&gt;gq]&lt;/code&gt;, I don't mind redefnining it?&lt;/p&gt;&#xA;" OwnerDisplayName="user3034" LastEditorUserId="51" LastEditDate="2015-08-03T14:02:27.937" LastActivityDate="2015-08-03T14:27:22.697" Title="change meaning of &quot;paragraph&quot; for TeX input?" Tags="|cursor-motions|wrapping|filetype-tex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4159" PostTypeId="1" CreationDate="2015-08-03T13:33:23.617" Score="1" ViewCount="44" Body="&lt;p&gt;Is it possible to selecting text in more than one column without selecting both lines in VIM?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2015-08-03T13:35:43.440" Title="Selecting text in more than one column without selecting both lines?" Tags="|visual-mode|" AnswerCount="1" CommentCount="2" ClosedDate="2015-08-04T02:19:58.347" ContentLicense="CC BY-SA 3.0" />
  <row Id="4160" PostTypeId="2" ParentId="4159" CreationDate="2015-08-03T13:35:43.440" Score="1" Body="&lt;p&gt;&lt;code&gt;Ctrl-V&lt;/code&gt;, then arrows (or hjkl) starts block/column selection mode - is that the feature you are looking for?&lt;/p&gt;&#xA;" OwnerDisplayName="user3034" LastActivityDate="2015-08-03T13:35:43.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4161" PostTypeId="1" CreationDate="2015-08-03T13:40:40.913" Score="1" ViewCount="183" Body="&lt;p&gt;I've recently switched to the molokai color scheme and I've noticed that the colors look different than in gVim. I remember that I spent ages trying to get my terminal-vim to properly display the 256-color version of my previous theme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the terminal-version of monokai supposed to look like the following or is there something off here (terminal without tmux on the left, gVim on the right).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JMe8Y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JMe8Y.png&quot; alt=&quot;Terminal without tmux on the left, gvim on the right&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1842" LastActivityDate="2015-08-03T13:40:40.913" Title="Molokai colors off in terminal" Tags="|terminal|gvim|colorscheme|" AnswerCount="0" CommentCount="1" ClosedDate="2015-08-04T10:12:03.097" ContentLicense="CC BY-SA 3.0" />
  <row Id="4162" PostTypeId="2" ParentId="4158" CreationDate="2015-08-03T13:40:50.463" Score="5" Body="&lt;p&gt;One way to do it employs the &lt;code&gt;ie&lt;/code&gt; (&lt;em&gt;inside-environment&lt;/em&gt;) custom text object, available in a number of places: e.g. in the plugin &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;noreferrer&quot;&gt;vimtex&lt;/a&gt;, or with &lt;a href=&quot;https://github.com/rbonvall/vim-textobj-latex&quot; rel=&quot;noreferrer&quot;&gt;vim-textobj-latex&lt;/a&gt; (and there are others). With this functionality, then the rewrap command becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gqie&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gwie&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(to maintain cursor position).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only want to reformat text &lt;em&gt;from current text position&lt;/em&gt; (I see that this is your use case) to the paragraph end, you can probably make do with the following construct (no plugins required):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gq/\(^\s*$\|\\end\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will format to either an empty line, or a line containing the &lt;code&gt;\end&lt;/code&gt; keyword, whichever comes first. So you could use this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;F8&amp;gt; gq/\(\\end\\|^\s*$\)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-08-03T14:27:22.697" LastActivityDate="2015-08-03T14:27:22.697" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4163" PostTypeId="1" AcceptedAnswerId="4166" CreationDate="2015-08-03T18:00:34.057" Score="8" ViewCount="1559" Body="&lt;p&gt;I'm returning to Vim after using Emacs for a few years. I'm trying to &lt;a href=&quot;https://stackoverflow.com/a/1220118/580010&quot;&gt;grok&lt;/a&gt; Vim by reading and watching tutorials, as well as actually using it daily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When editing text, I find the Emacs commands of Alt-F, Alt-B, Ctrl-a, Ctrl-e, Alt-D and Alt-Backspace to be very useful and intuitive, allowing for quick and easy local edits while working with text (words/code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the Vim-way of implementing similar functionality? Returning to &lt;code&gt;NORMAL&lt;/code&gt; mode to issue a single motion, only to re-enter &lt;code&gt;INSERT&lt;/code&gt; mode is not optimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example 1: When in &lt;code&gt;INSERT&lt;/code&gt; mode to insert a &lt;code&gt;(&lt;/code&gt; at the start of an expression, how should I move to the end of the expression or the line to insert the corresponding &lt;code&gt;)&lt;/code&gt; in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example 2: When editing text, one may often want to delete a word forwards or backwards while writing or editing a sentence or code. It would be unusual to have a perfectly-formed sentence/code in one's mind, ready to type &quot;once-off&quot; ahead of time; often a sentence changes as one is working with the text. The restrictions of &lt;code&gt;INSERT&lt;/code&gt; mode are making this kind of editing difficult for me in Vim. I feel unable to effectively manipulate the text in insert mode, always finding myself having to switch back to &lt;code&gt;NORMAL&lt;/code&gt; mode for simple movements or deleting words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: Alt-F and -B move the cursor forward or backward one word. Ctrl-a and -e move the cursor to the start or end of line. Alt-F deletes the word under the cursor. Alt-Backspace deletes the word before the cursor.&lt;/p&gt;&#xA;" OwnerUserId="2932" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-08-04T23:28:00.010" Title="Grok Vim motions and simple edits" Tags="|insert-mode|cursor-motions|normal-mode|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4164" PostTypeId="2" ParentId="4163" CreationDate="2015-08-03T19:08:20.890" Score="9" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Alt-F, Alt-B, Ctrl-a, Ctrl-e, Alt-D and Alt-Backspace&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The equivalent commands in normal mode are &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;^&lt;/code&gt;, &lt;code&gt;$&lt;/code&gt;, &lt;code&gt;dw&lt;/code&gt;, &lt;code&gt;db&lt;/code&gt;. Note the logic: &lt;code&gt;dw&lt;/code&gt; deletes what is covered by &lt;code&gt;w&lt;/code&gt; and &lt;code&gt;db&lt;/code&gt; deletes what is covered by &lt;code&gt;b&lt;/code&gt;. What command would you use to delete what is covered by &lt;code&gt;^&lt;/code&gt;? Or to yank it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That language-like logic is the whole point of modal editing; it may take some time to adjust to it but there's no u-turn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The equivalent commands in insert mode are: &lt;code&gt;&amp;lt;C-Right&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-Left&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Home&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;End&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; and… nothing but you can create a simple mapping: &lt;code&gt;inoremap &amp;lt;C-something&amp;gt; &amp;lt;C-o&amp;gt;dw&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Returning to &lt;code&gt;NORMAL&lt;/code&gt; mode to issue a single motion, only to re-enter &lt;code&gt;INSERT&lt;/code&gt; mode is not optimal.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Indeed. The right approach is to enter insert mode to insert as little text as possible and return to normal mode as soon as possible.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Example 1: When in &lt;code&gt;INSERT&lt;/code&gt; mode to insert a &lt;code&gt;(&lt;/code&gt; at the start of an expression, how should I move to the end of the expression or the line to insert the corresponding &lt;code&gt;)&lt;/code&gt; in Vim?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Like in any text editor or IDE or text processor or &lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;End&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Example 2: When editing text, one may often want to delete a word forwards or backwards while writing or editing a sentence or code. It would be unusual to have a perfectly-formed sentence/code in one's mind, ready to type &quot;once-off&quot; ahead of time; often a sentence changes as one is working with the text. The restrictions of &lt;code&gt;INSERT&lt;/code&gt; mode are making this kind of editing difficult for me in Vim. I feel unable to effectively manipulate the text in insert mode, always finding myself having to switch back to &lt;code&gt;NORMAL&lt;/code&gt; mode for simple movements or deleting words.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Again, insert mode is for &lt;em&gt;inserting&lt;/em&gt; text. &quot;Manipulating text&quot; and moving around are supposed to happen in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please ask more precise questions.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="205" LastEditDate="2015-08-04T23:28:00.010" LastActivityDate="2015-08-04T23:28:00.010" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4165" PostTypeId="2" ParentId="4163" CreationDate="2015-08-03T19:25:32.013" Score="12" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;When editing text, I find the Emacs commands of Alt-F, Alt-B, Ctrl-a, Ctrl-e, Alt-D and Alt-Backspace to be very useful and intuitive, allowing for quick and easy local edits while working with text (words/code).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To answer your question about local edits: if you're in insert mode and press &lt;code&gt;ctrl-O&lt;/code&gt; you'll do the next command in insert mode. It can be handy if you decide to wipe the line. There are a few other commands in insert mode for small things, like pasting from the register and autocompleting words. You can read all of them with &lt;code&gt;:h ins-special-keys&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Example 1: When in INSERT mode to insert a ( at the start of an expression, how should I move to the end of the expression or the line to insert the corresponding ) in Vim?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Often there's a better way to do things in normal mode. For example, let's say you want to surround an expression with parenthesis. Some things you can do are &lt;code&gt;i(&amp;lt;end&amp;gt;)&lt;/code&gt;, &lt;code&gt;i(&amp;lt;esc&amp;gt;A)&lt;/code&gt;, &lt;code&gt;c$()&amp;lt;esc&amp;gt;P&lt;/code&gt;.* My favorite thing involves having one of the &quot;necessary&quot; vim plugins, &lt;a href=&quot;https://github.com/tpope/vim-surround&quot;&gt;vim-surround&lt;/a&gt;. With vim-surround, it's just &lt;code&gt;ys$)&lt;/code&gt;. What's great about all of these is that once you know how to do it in one situation, you can do it in all similar situations. What if instead of adding parenthesis to the end of the line, it's just three words? You can use &lt;code&gt;c3w()&amp;lt;esc&amp;gt;P&lt;/code&gt; or &lt;code&gt;ys3w)&lt;/code&gt;. What about the whole line? &lt;code&gt;cc()&amp;lt;esc&amp;gt;P&lt;/code&gt; or &lt;code&gt;yss)&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Example 2: When editing text, one may often want to delete a word forwards or backwards while writing or editing a sentence or code. It would be unusual to have a perfectly-formed sentence/code in one's mind, ready to type &quot;once-off&quot; ahead of time; often a sentence changes as one is working with the text. The restrictions of INSERT mode are making this kind of editing difficult for me in Vim. I feel unable to effectively manipulate the text in insert mode, always finding myself having to switch back to NORMAL mode for simple movements or deleting words.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;One thing that helps a lot is to add &lt;code&gt;inoremap jk &amp;lt;esc&amp;gt;&lt;/code&gt; to your vimrc. Then you can exit insert mode by pressing jk. This takes most of the overhead out of leaving insert mode so you can do &lt;code&gt;jk&amp;lt;sequenceofcommands&amp;gt;i&lt;/code&gt; to do commands without disrupting your typing.&lt;/p&gt;&#xA;" OwnerUserId="978" LastActivityDate="2015-08-03T19:25:32.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4166" PostTypeId="2" ParentId="4163" CreationDate="2015-08-03T20:18:17.010" Score="7" Body="&lt;p&gt;&lt;strong&gt;1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can achieve those or better (pinky) command mappings very quickly. I'm not recommending this solution, but as an example, if you want to move the cursor to the beginning of line with &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; you can execute the following line after hitting &lt;code&gt;:&lt;/code&gt; from normal mode (or add the line to your vimrc)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-a&amp;gt; &amp;lt;C-o&amp;gt;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or, if start of line means first non-blank character of line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-a&amp;gt; &amp;lt;C-o&amp;gt;^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Curious thing, I just tested these mappings in the buffer in which I'm writing this answer, and I was confused for a moment because they didn't work. Then I realized I had forgotten to enter insert mode. You seem to find it a pain to leave insert mode to execute normal mode commands. You may find after using Vim for a while that it's the reverse–that you linger in normal mode while you're thinking and only make excursions to insert mode for particular occasions. Vim is probably only (or mostly) worth learning if you find that you do more &lt;em&gt;editing&lt;/em&gt; than &lt;em&gt;writing&lt;/em&gt; text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So one part of an answer to your question about executing normal mode commands quickly from insert mode is &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;, which lets you leave insert mode temporarily to execute one normal mode command, then reenter. Read about it at &lt;code&gt;:help i_Ctrl-o&lt;/code&gt;. This is useful for one-off conveniences. A more sustainable route is probably to try to embrace normal mode as a default for navigation and editing, and only enter insert mode when you actually want to insert new characters by hand into the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your examples are very general so it's hard to give specific answers. I'm going to make up a specific example in hopes it fits or is translatable to something you encounter. For your number 1, it depends on &lt;em&gt;how you know&lt;/em&gt; where the closing parenthesis is supposed to go. let's say I have a line like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let cchar = s:cchar[&quot;atx&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is meant to be a line of VimL, vim's scripting language, and it (or something like it) occurs in a Vim syntax file I am currently disagreeing with. Let's say I want to change the right hand part of this expression to a function call, perhaps because the function provides defaults when the dictionary &lt;code&gt;s:cchar&lt;/code&gt; has not been assigned a value yet for the &lt;code&gt;&quot;atx&quot;&lt;/code&gt; key. With my cursor (in normal mode) on the first character, 'l', I might type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f=wcf[MyFunction(&amp;lt;Esc&amp;gt;$r)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Briefly, this says&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;f=&lt;/code&gt; - forward to '=' (I could have said &lt;code&gt;fs&lt;/code&gt;, but I probably wouldn't pause long enough to see that the 's' I want to reach is the first s on the line, so I'd go for the character that is obviously unique, and continue from there)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt; - next word, now my cursor is on the 's' of 's:cchar'&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cf[&lt;/code&gt; - change to forward to '['&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;at this point the line looks like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let cchar = |&quot;atx&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;|&lt;/code&gt; is the cursor, and I am in insert mode. I then type &lt;code&gt;MyFunction(&lt;/code&gt; and leave insert mode (&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt; - move cursor to end of line. I could have used &lt;code&gt;E&lt;/code&gt; for end-of-big-word or &lt;code&gt;f]&lt;/code&gt; for forward-to-']' or some other motion, but &lt;code&gt;$&lt;/code&gt; occurred to me first.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;r)&lt;/code&gt; - replace character under cursor with a ')'&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now I have changed the assignment expression from assigning from a script-local dictionary to using the return value of a function, and in doing so I introduced parentheses. I don't know how your particular need for parentheses looks, perhaps it's very different, in which case there will be a different string of commands to achieve it. If I paused to think longer about my made up example I might find more efficient ways to achieve that also, but who has time to pause and think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Try it, copy-paste (sorry, yank-put) the text and the command to a buffer, and with your cursor on the first character, 'f', of the command hit &lt;code&gt;y$&lt;/code&gt;. Now the command is in your unnamed register. Move to the beginning of the first line and hit &lt;code&gt;:normal &amp;lt;C-r&amp;gt;&quot;&lt;/code&gt; to a) enter command line mode, b) begin executing a normal mode command from the command line, and c) to paste (&lt;em&gt;atchoo&lt;/em&gt; put) the unnamed register into the command line as the normal mode command to be executed. The only thing you need to change in the command is to replace the phony &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; series of characters (because you copy-pasted &lt;em&gt;atchoo&lt;/em&gt; from your browser) with the actual Escape key code, so delete it and hit &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; and then your Esc key. It will look sort of like &lt;code&gt;^[&lt;/code&gt;. Now hit return to run the command. Or... just type the string of keys to test the commands, I just wanted to show you that you can interact with normal mode from cmdline mode as well, and &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt;, and all the other glories of Wonderland. Also, see &lt;code&gt;:help Cmdline-mode&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For deleting a word backwards you can use the standard mapping &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; (see &lt;code&gt;:help i_Ctrl-w&lt;/code&gt;). I don't know if there is a default mapping to delete a word forwards, but I suppose you could make one with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-S-w&amp;gt; &amp;lt;C-o&amp;gt;dw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; will take you out of insert mode for a one-off command and &lt;code&gt;dw&lt;/code&gt; will &quot;delete&quot; over the &quot;word&quot; motion. See &lt;code&gt;:help d&lt;/code&gt;, &lt;code&gt;:help w&lt;/code&gt;. If the forward words you delete are not actual words but class.function#names, you may want to use &lt;code&gt;W&lt;/code&gt; (see &lt;code&gt;:help W&lt;/code&gt;). If you're already mostly in normal mode you don't need these mappings, just do &lt;code&gt;dw&lt;/code&gt;, &lt;code&gt;db&lt;/code&gt; or friends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some help chapters to look closer at&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help &amp;lt;C-o&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help Insert&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help f&lt;/code&gt; and the following sections (&lt;code&gt;F&lt;/code&gt;,&lt;code&gt;t&lt;/code&gt;,&lt;code&gt;T&lt;/code&gt;,&lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help word-motions&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="1306" LastEditDate="2015-08-03T23:09:08.943" LastActivityDate="2015-08-03T23:09:08.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4167" PostTypeId="1" CreationDate="2015-08-04T07:09:12.307" Score="4" ViewCount="1991" Body="&lt;p&gt;In recent days I use a lot of vimscript and it would be helpful to have some autocompletion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like when I write &lt;code&gt;jo&lt;/code&gt; the autocompletion would recommend me to write &lt;code&gt;join&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have installed YouCompleteMe, but its hard to search in the internet for vimscript autocompletion because of the ambiguity.&lt;/p&gt;&#xA;" OwnerUserId="3003" LastEditorUserId="1821" LastEditDate="2015-08-04T10:16:18.570" LastActivityDate="2019-07-05T19:25:52.413" Title="Autocompletion Plugin for vimscript?" Tags="|vimscript|autocompletion|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4168" PostTypeId="1" AcceptedAnswerId="4179" CreationDate="2015-08-04T09:19:13.853" Score="1" ViewCount="498" Body="&lt;p&gt;In my vimrc I have this line :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call matchadd('ColorColumn', '\%81v', 100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It colors the 81th column in a subtle grey background so I can track my line length :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cPItS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cPItS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(see the &lt;code&gt;l&lt;/code&gt; and the &lt;code&gt;f&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found out that when editing a large file, this function causes Vim to be very slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the file I am currently working on is a &lt;code&gt;jsp&lt;/code&gt; file with a lot of mistakes in the indentation/syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried with a custom vimrc : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.vimrc-test&#xA;&#xA;call matchadd('ColorColumn', '\%81v', 100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And launching vim with &lt;code&gt;vim -u .vimrc-test -N my-file.jsp&lt;/code&gt; it reproduce the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am on MacVim 7.4.383 on Yosemity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know anything related to this issue ?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-08-04T09:32:11.877" LastActivityDate="2015-08-04T17:48:48.557" Title="matchadd makes vim slow with large files" Tags="|vimrc|performance|large-documents|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4169" PostTypeId="2" ParentId="4163" CreationDate="2015-08-04T09:34:46.430" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What is the Vim-way of implementing similar functionality? Returning to NORMAL mode to issue a single motion, only to re-enter INSERT mode is not optimal.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, one can say the Vim-way is to not stay in INSERT mode. The enlightening moment in Vim comes when you realize how you don't need to stay in INSERT mode. There are many ways to insert text, and all of them start from NORMAL mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, I am not a true one myself, and I remapped keys for doing the job (à la Windows):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-BACKSPACE&amp;gt; dbi&#xA;nmap &amp;lt;C-DEL&amp;gt; dei&#xA;imap &amp;lt;C-BACKSPACE&amp;gt; &amp;lt;ESC&amp;gt;ldbi&#xA;imap &amp;lt;C-DEL&amp;gt; &amp;lt;ESC&amp;gt;ldei&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3046" LastActivityDate="2015-08-04T09:34:46.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4170" PostTypeId="1" AcceptedAnswerId="4173" CreationDate="2015-08-04T11:24:47.233" Score="13" ViewCount="11720" Body="&lt;p&gt;Is there a command for deleting line (or n lines) above current one? Above = current not included.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I.e., is there an alternative to &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; which doesn't delete current line? Similar to how &lt;kbd&gt;o&lt;/kbd&gt;/&lt;kbd&gt;O&lt;/kbd&gt; and &lt;kbd&gt;p&lt;/kbd&gt;/&lt;kbd&gt;P&lt;/kbd&gt; work, but with deletion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I'm doing &lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;, which moves cursor one line up and deletes it. I could do &lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;d kdd&lt;/code&gt; and &lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;D jdd-&lt;/code&gt;, but having an alternative which doesn't move the cursor seems like a better option. Is there such?&lt;/p&gt;&#xA;" OwnerUserId="1733" LastActivityDate="2018-03-22T19:46:53.580" Title="How to delete line above/below cursor, but not current line?" Tags="|key-bindings|cursor-movement|normal-mode|" AnswerCount="6" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4171" PostTypeId="2" ParentId="4170" CreationDate="2015-08-04T12:20:55.407" Score="5" Body="&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; I didn't know the built-in features suggested by @Romainl in his answer: of course the &lt;code&gt;-d&lt;/code&gt; and &lt;code&gt;+d&lt;/code&gt; method should be prefered as it is way simpler than adding functions to your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe adding something like that to your &lt;code&gt;.vimrc&lt;/code&gt; could be what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DeleteOver()&#xA;   let save_cursor = getpos(&quot;.&quot;)&#xA;   normal k&#xA;   normal dd&#xA;   call setpos(&quot;.&quot;, save_cursor)&#xA;   normal k&#xA;endfunction&#xA;&#xA;function! DeleteUnder()&#xA;   let save_cursor = getpos(&quot;.&quot;)&#xA;   normal j&#xA;   normal dd&#xA;   call setpos(&quot;.&quot;, save_cursor)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These functions delete the line under or the line over the current one and go back to the position before the deletion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the function &lt;code&gt;DeleteOver()&lt;/code&gt; we need to go up one line with &lt;code&gt;normal k&lt;/code&gt; after the deletion because the deletion change the number of the original line which doesn't happend with &lt;code&gt;DeleteUnder()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also add this to your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;d :call DeleteOver()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;D :call DeleteUnder()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To create the mappings calling the functions.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-04T14:11:43.343" LastActivityDate="2015-08-04T14:11:43.343" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4172" PostTypeId="1" CreationDate="2015-08-04T13:51:00.803" Score="3" ViewCount="1527" Body="&lt;p&gt;I am pretty new to Vim and I need some help with work-flow developing in C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I am using Sublime Text as my primary editor for the following work-flow:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say I am working on RingBuffer class, for which I have &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ring_buffer.h&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ring_buffer.cpp&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;unittest\ring_buffer_mock.h&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;unittest\ring_buffer_test.cpp&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;and &lt;code&gt;unittest\ring_buffer.makefile&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Each makefile has its own set of dependencies.  Sublime Text allows you to add a build system, which runs a shell command defined by user in project file, and parses the output.  To test the Ring Buffer, I go to &lt;code&gt;menu&lt;/code&gt;-&gt;&lt;code&gt;tools&lt;/code&gt;-&gt;&lt;code&gt;BuildSystem&lt;/code&gt;-&gt;&lt;code&gt;RingBuffer&lt;/code&gt;.  So here is the question&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can you recommend a good work-flow in VIM?&lt;/li&gt;&#xA;&lt;li&gt;Is it possible in local &lt;code&gt;.vimrc&lt;/code&gt; to specify makefile, such as &lt;code&gt;ring_buffer.makefile&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;EDIT! First off, &lt;code&gt;set makeprg=make\ -f\ ring_buffer.makefile&lt;/code&gt; works well, but it does not offer any automation.  So I am going to ask a second question which can be found here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/4503/determining-makefile-based-on-source-file-name&quot;&gt;Determining makefile based on source file name&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-10-24T11:59:59.567" Title="Specify Makefile" Tags="|vimrc|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4173" PostTypeId="2" ParentId="4170" CreationDate="2015-08-04T14:05:39.520" Score="39" Body="&lt;pre&gt;&lt;code&gt;:-d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;cuts the line above the current line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:-5d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;cuts the 5th line above the current line (but moves the cursor).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:-5,-d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;cuts the 5 lines above the current line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:+,+5d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;cuts the 5 lines below the current line.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-08-04T14:05:39.520" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4174" PostTypeId="2" ParentId="4167" CreationDate="2015-08-04T14:17:35.057" Score="-1" Body="&lt;p&gt;I've tried &lt;a href=&quot;https://github.com/Shougo/neocomplete.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;neocomplete&lt;/a&gt; and &lt;a href=&quot;https://github.com/garbas/vim-snipmate&quot; rel=&quot;nofollow noreferrer&quot;&gt;snipmate&lt;/a&gt;. There are others that I haven't tried like &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;nofollow noreferrer&quot;&gt;youcompleteme&lt;/a&gt; and &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;ultisnips&lt;/a&gt; that may help. This last one (&lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;ultisnips&lt;/a&gt;) looks very nice. Check the image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/U7Y1c.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/U7Y1c.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last sugggestion, for &lt;a href=&quot;https://github.com/garbas/vim-snipmate&quot; rel=&quot;nofollow noreferrer&quot;&gt;snipmate&lt;/a&gt; and &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;ultisnips&lt;/a&gt; don't forget to install the '&lt;a href=&quot;https://github.com/honza/vim-snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;honza/vim-snippets&lt;/a&gt;' plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps. &lt;/p&gt;&#xA;" OwnerUserId="3049" LastActivityDate="2015-08-04T14:17:35.057" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4175" PostTypeId="2" ParentId="4141" CreationDate="2015-08-04T14:39:12.453" Score="80" Body="&lt;p&gt;You want expandtab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there are usually a couple of options you want to set at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you add the following to your ~/.vimrc file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; tabstop:          Width of tab character&#xA;&quot; softtabstop:      Fine tunes the amount of white space to be added&#xA;&quot; shiftwidth        Determines the amount of whitespace to add in normal mode&#xA;&quot; expandtab:        When this option is enabled, vi will use spaces instead of tabs&#xA;set tabstop     =4&#xA;set softtabstop =4&#xA;set shiftwidth  =4&#xA;set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can execute these manually from normal mode by proceeding them with ':'&lt;/p&gt;&#xA;" OwnerUserId="383" LastEditorUserId="18609" LastEditDate="2020-04-18T01:50:30.880" LastActivityDate="2020-04-18T01:50:30.880" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4176" PostTypeId="2" ParentId="4167" CreationDate="2015-08-04T16:06:31.887" Score="3" Body="&lt;p&gt;Vim actually has a native autocomplete engine. It's not as fully featured as neocomplete or YCM, but it's fast and usually gets the job done. You can find out more about it with &lt;code&gt;:h i_ctrl-x&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="978" LastActivityDate="2015-08-04T16:06:31.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4177" PostTypeId="1" AcceptedAnswerId="4178" CreationDate="2015-08-04T16:12:05.790" Score="4" ViewCount="143" Body="&lt;p&gt;Both &lt;code&gt;$&lt;/code&gt; and &lt;code&gt;\n&lt;/code&gt; represents the end of a line. To remove an empty line we can use either &lt;code&gt;:g/^$/d&lt;/code&gt; or &lt;code&gt;:%s/^\n//g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the difference between these two signs? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems the first command &lt;em&gt;removes&lt;/em&gt; a line while the latter one &lt;em&gt;replaces&lt;/em&gt; a line by nothing. Hence the first one should be more efficient than the second one. Is my analysis correct? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What about the comparison between &lt;code&gt;:g/^$/d&lt;/code&gt; and &lt;code&gt;:g/^\n/d&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1080" LastActivityDate="2015-08-04T17:33:45.830" Title="Difference between two end of line signs" Tags="|command-line|regular-expression|search|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4178" PostTypeId="2" ParentId="4177" CreationDate="2015-08-04T17:28:15.343" Score="6" Body="&lt;p&gt;To put it briefly, &lt;code&gt;$&lt;/code&gt; (and &lt;code&gt;^&lt;/code&gt;) are null-size, empty markers that, when replaced, actually remove nothing (so you basically append to the line), while &lt;code&gt;\n&lt;/code&gt; stands for the character (or characters) separating 2 lines: if  you replace &lt;code&gt;\n&lt;/code&gt;, you will also join those lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why if you replace your substitute example with &lt;code&gt;%s/^$//g&lt;/code&gt;, nothing happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:g/^$/d&lt;/code&gt; works because the pattern is only used to &lt;em&gt;find&lt;/em&gt; the line, and &lt;code&gt;d&lt;/code&gt; (delete) is the one actually removing the line, EOL included (since it is an Ex command).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-08-04T17:33:45.830" LastActivityDate="2015-08-04T17:33:45.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4179" PostTypeId="2" ParentId="4168" CreationDate="2015-08-04T17:48:48.557" Score="1" Body="&lt;p&gt;Try appending the &lt;code&gt;\%#=1&lt;/code&gt; to the pattern so the old regexp engine is used. If I remember correctly, there was a bug in the newer engine that makes matching column positions slower, which was fixed later in the 7.4. development.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-08-04T17:48:48.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4180" PostTypeId="2" ParentId="4170" CreationDate="2015-08-04T17:51:49.740" Score="3" Body="&lt;p&gt;Perhaps you'll improve your workflow if don't fear to ... jump :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is where cursor initially is: _.&#xA;&#xA;[Some other stuff you want to keep/skip ...]&#xA;&#xA;I want to delete these lines.&#xA;I want to delete these lines.&#xA;I want to delete these lines.&#xA;I want to delete these lines.&#xA;I want to delete these lines.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your actions (normal mode, cursor is on &lt;code&gt;_&lt;/code&gt;): &lt;code&gt;/I want&lt;/code&gt; &lt;code&gt;Enter&lt;/code&gt; &lt;code&gt;5dd&lt;/code&gt; &lt;code&gt;Ctrl-o&lt;/code&gt;. That's it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, &lt;a href=&quot;https://vi.stackexchange.com/users/54/romainl&quot;&gt;romainl&lt;/a&gt; answer is the best if all you want to delete whole lines, and you can count their offset easily (using relative linenumbers for example). The above is a more generic way to &quot;act&quot;: go there, using something that counts as a jump: this means you can always jump back, after you modify the text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you use absolute line numbers, you can replace the &lt;code&gt;/I want&lt;/code&gt; &lt;code&gt;Enter&lt;/code&gt; with something like &lt;code&gt;78gg&lt;/code&gt; or &lt;code&gt;78G&lt;/code&gt; to jump directly at that line number.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-08-04T17:57:24.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4181" PostTypeId="1" CreationDate="2015-08-05T08:30:46.380" Score="1" ViewCount="96" Body="&lt;p&gt;I have a laptop with latest OSX 10.10.4 and have tried to install latest MacVim via homebrew, cask and &quot;releases&quot; section in github page. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All works fine, but starting MacVim also opens Terminal.app, which I don't want to be started since I use iTerm. Is it possible to start MacVim without also starting Terminal? Or is there something broken with my clean OSX install?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Temporarily removing my &lt;code&gt;.vimrc&lt;/code&gt; and &lt;code&gt;.vim&lt;/code&gt; doesn't help.&lt;/p&gt;&#xA;" OwnerUserId="3064" LastEditorUserId="205" LastEditDate="2015-08-05T14:36:30.080" LastActivityDate="2015-08-05T14:36:30.080" Title="How do I prevent MacVim from automatically starting Terminal.app on OSX 10.10?" Tags="|macvim|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4182" PostTypeId="1" CreationDate="2015-08-05T17:57:37.563" Score="1" ViewCount="36" Body="&lt;p&gt;Sometimes I'll edit a file I'm working on in another editor (don't ask) but it will be open in vim or vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With vim I need to &lt;code&gt;:e&lt;/code&gt; to force a refresh of the file. However in my other editors the text updates automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to have vim keep files current with their saved state automatically?&lt;/p&gt;&#xA;" OwnerUserId="2918" LastActivityDate="2015-08-05T17:57:37.563" Title="Keep buffer current without manual refresh?" Tags="|buffers|save|persistent-state|" AnswerCount="0" CommentCount="2" ClosedDate="2015-08-06T14:59:24.763" ContentLicense="CC BY-SA 3.0" />
  <row Id="4183" PostTypeId="1" AcceptedAnswerId="4184" CreationDate="2015-08-05T18:26:43.103" Score="10" ViewCount="555" Body="&lt;p&gt;When we search a pattern in vim, the matches are usually highlighted. However, when we print it out, the highlights disappear. I tried both &lt;code&gt;:hardcopy &amp;gt; my_file.pdf&lt;/code&gt; and &lt;code&gt;:TOhtml&lt;/code&gt;. Neither retains the highlight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way that I can output the document with matched patterns highlighted to a pdf file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using GVim 7.4 on a Win 7 machine.&lt;/p&gt;&#xA;" OwnerUserId="1080" LastActivityDate="2015-08-06T08:48:41.887" Title="To print with search results highlighted" Tags="|search|highlight|printing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4184" PostTypeId="2" ParentId="4183" CreationDate="2015-08-05T19:22:40.557" Score="13" Body="&lt;p&gt;Try something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match Error &quot;yourterm&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or (to ignore case and match &quot;Yourterm&quot;, &quot;YOURTERM&quot;, &quot;yourTerm&quot; etc.):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match Error &quot;\cyourterm&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and print with &lt;code&gt;hardcopy&lt;/code&gt; - the term should be highlighted using the &lt;code&gt;Error&lt;/code&gt; highlight rules. (see also &lt;a href=&quot;https://vi.stackexchange.com/a/3540/1800&quot;&gt;this&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a pdf sample printed from my &lt;code&gt;vimrc&lt;/code&gt;, using &lt;code&gt;:syntax match Error &quot;Plug&quot;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/L4o9d.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/L4o9d.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the search term is already highlighted using current filetype syntax rules (so the previous command doesn't have any effect), and if you don't have a problem printing the text without those (in black-and-white, so to speak), then: &lt;code&gt;:set ft=&lt;/code&gt; and then &lt;code&gt;syntax match Error &quot;yourterm&quot;&lt;/code&gt;. You'll get black text on white background, with a touch of (probably) red - the highlighted matches.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-08-06T08:48:41.887" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4185" PostTypeId="1" CreationDate="2015-08-05T22:40:43.560" Score="6" ViewCount="1144" Body="&lt;p&gt;What is the correct way to change where UltiSnips searches for snippets? I tried the lines below with no success:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsSnippetsDir = &quot;/newfolder/snippets/&quot;&#xA;let g:UltiSnipsSnippetDirectories=[&quot;UltiSnipsNewDir&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3070" LastEditorUserId="23502" LastEditDate="2022-11-05T09:17:31.390" LastActivityDate="2022-11-05T09:17:31.390" Title="How do I change directory for UltiSnips snippets?" Tags="|vimrc|plugin-ultisnips|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4186" PostTypeId="1" CreationDate="2015-08-06T03:16:31.287" Score="6" ViewCount="1331" Body="&lt;p&gt;I love the relative numbers side-column in vim but when I have wrapped lines it becomes inaccurate (or less usable since I can't use that number directly in a &lt;code&gt;j/k&lt;/code&gt; command). I have &lt;code&gt;nnoremap j gj&lt;/code&gt; in my vimrc which is why I have that discrepancy but is there a way for the &lt;code&gt;:rnu&lt;/code&gt; command to reflect the lines a wrapped number takes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*If that made no sense, I'd like wrapped line 4 and 6 to have numbers all the way down not not skipping visible lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/11Px5.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/11Px5.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="217" LastActivityDate="2018-07-31T11:10:21.927" Title="Relative Numbers sidepanel with wrapped lines" Tags="|line-numbers|wrapping|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4187" PostTypeId="1" AcceptedAnswerId="4191" CreationDate="2015-08-06T12:41:55.603" Score="8" ViewCount="1517" Body="&lt;p&gt;I have multiple buffers open, some currently visible, some not. I know I can &lt;code&gt;write&lt;/code&gt; all of them with &lt;code&gt;:wa&lt;/code&gt;. However, I am curious, why &lt;code&gt;:bufdo w&lt;/code&gt; does not work. When I try it in a buffer with unsaved changes, vim tells me &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E37: No write since last change (add ! to override)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is this so?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2015-08-06T13:22:14.313" Title="Why can't I execute write command on all buffers with :bufdo?" Tags="|buffers|save|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4188" PostTypeId="5" CreationDate="2015-08-06T12:49:55.970" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/digraph.txt.html#digraph&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help digraph&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-06T12:49:55.970" LastActivityDate="2015-08-06T12:49:55.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4189" PostTypeId="4" CreationDate="2015-08-06T12:49:55.970" Score="0" Body="Digraphs is Vim's way to enter characters that cannot be entered by most keyboards." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-06T12:49:55.970" LastActivityDate="2015-08-06T12:49:55.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4190" PostTypeId="1" AcceptedAnswerId="4195" CreationDate="2015-08-06T13:06:01.013" Score="4" ViewCount="974" Body="&lt;p&gt;With the &lt;code&gt;textwidth&lt;/code&gt; option set the text written can be wrapped when we leave insert mode. If I type a line longer than my &lt;code&gt;textwidth&lt;/code&gt; value then it will go on a new line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. with &lt;code&gt;set textwidth=5&lt;/code&gt; and &lt;code&gt;set linebreak&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 2 3 [4]&#xA;&#xA;1 2 3&#xA;4[]&#xA;&#xA;&#xA;lorem ipsum dolor[Esc]&#xA;&#xA;lorem &#xA;ipsum &#xA;dolor[]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[X] means: I press X where [] is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when entering a line of number spearated by space, at the moment I enter the 6th character (in this case the number 4) the line break.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I enter a sentence the line doesn't break until I quit insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know what I can try/set ?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-08-20T13:51:01.257" Title="Breaks line without leaving insert mode" Tags="|insert-mode|line-breaks|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4191" PostTypeId="2" ParentId="4187" CreationDate="2015-08-06T13:13:46.880" Score="7" Body="&lt;p&gt;I'm feeling like you don't have the option &lt;code&gt;hidden&lt;/code&gt; set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, it means that you cannot switch from an unwritten buffer to another one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case you cannot save any buffer because it should change from an unwritten buffer. Adding the &lt;code&gt;hidden&lt;/code&gt; option will fix this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find more with : &lt;code&gt;:h hidden&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1841" LastEditDate="2015-08-06T13:22:14.313" LastActivityDate="2015-08-06T13:22:14.313" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4192" PostTypeId="1" AcceptedAnswerId="7168" CreationDate="2015-08-07T04:15:03.967" Score="3" ViewCount="796" Body="&lt;p&gt;I can grab the number of lines of a buffer with &lt;code&gt;line(&quot;$&quot;)&lt;/code&gt;, but this does not take into account if my terminal is small and I have &lt;code&gt;set wrap&lt;/code&gt; and some lines wrap. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if it is possible to query this (greater) line count value? Basically it would be the # of times that you could &lt;code&gt;gj&lt;/code&gt; from the top of the file (plus one). That's not a practical way to calculate it, neither is doing math based on the window dimension &lt;code&gt;winwidth()&lt;/code&gt; and the buffer contents themselves.&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2022-10-22T16:54:41.083" Title="Is it possible to get the height of the buffer *including* word wrap?" Tags="|vimscript|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4193" PostTypeId="2" ParentId="4192" CreationDate="2015-08-07T07:40:03.973" Score="3" Body="&lt;p&gt;The issue is that vim does not store the wrapped lines, it only displays those you have here. If you really want to do it you can do it a little bit more efficiently than using gj. The idea is to go to the beginning of the page, go to the end of the displayed window and use winline(), which gives you the displayed line number of the window and then scroll the page with z+.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CountLine()&#xA;  normal! gg&#xA;  let l:count = 0&#xA;  while 1&#xA;    normal! L$&#xA;    let l:count = l:count + winline()&#xA;    if line('.') == line('$')&#xA;      break&#xA;    else&#xA;      normal! z+&#xA;    endif&#xA;  endwhile&#xA;  return l:count&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3003" LastEditorUserId="3003" LastEditDate="2015-08-07T07:56:15.187" LastActivityDate="2015-08-07T07:56:15.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4194" PostTypeId="2" ParentId="4190" CreationDate="2015-08-07T08:17:59.417" Score="1" Body="&lt;p&gt;Check that your &lt;code&gt;formatoptions&lt;/code&gt; contain at least the letters 't' and 'c'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure paste mode is not set, otherwise all insert mode mappings and formatting is disabled. You can tell is paste mode is set if the &lt;code&gt;-- INSERT (paste) --&lt;/code&gt; prompt appears at the when in insert mode rather than just &lt;code&gt;-- INSERT --&lt;/code&gt;. Paste mode can be disabled with &lt;code&gt;:set nopaste&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise try running Vim with the command &lt;code&gt;vim -u NONE&lt;/code&gt; and see if the problem still occurs, this fixes the problem it is an issue with your vimrc file or a plugin. &lt;/p&gt;&#xA;" OwnerUserId="2283" LastEditorUserId="2283" LastEditDate="2015-08-07T08:39:17.760" LastActivityDate="2015-08-07T08:39:17.760" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4195" PostTypeId="2" ParentId="4190" CreationDate="2015-08-07T08:28:41.567" Score="4" Body="&lt;p&gt;So as we troubleshooted in the comments the problem came from the &lt;code&gt;formatoption&lt;/code&gt; value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;code&gt;:h formatoptions&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is a sequence of letters which describes how automatic&#xA;      formatting is to be done.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your settings contained the letter &lt;code&gt;l&lt;/code&gt; which according to &lt;code&gt;:h fo-table&lt;/code&gt; does the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Long lines are not broken in insert mode: When a line was longer than&#xA;      'textwidth' when the insert command started, Vim does not&#xA;      automatically format it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So the solution is to use the following command &lt;code&gt;set fo-=l&lt;/code&gt;. Still according to the doc it is better to use the &lt;code&gt;+=&lt;/code&gt; and &lt;code&gt;-=&lt;/code&gt; features options of &lt;code&gt;set&lt;/code&gt; to avoid conflicts with tags added later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another important point is how these tags are set: a lot of filetypes set those tags automatically. For example in &lt;code&gt;[path_to_vim_installation]/vim74/ftplugin/c.vim&lt;/code&gt; you can read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set 'formatoptions' to break comment lines but not other lines,&#xA;&quot; and insert the comment leader when hitting &amp;lt;CR&amp;gt; or using &quot;o&quot;.&#xA;setlocal fo-=t fo+=croql&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A solution is to override those behavior in your &lt;code&gt;.vimrc&lt;/code&gt; for the filetypes that you want.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-20T13:51:01.257" LastActivityDate="2015-08-20T13:51:01.257" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4196" PostTypeId="1" CreationDate="2015-08-07T10:24:30.573" Score="1" ViewCount="215" Body="&lt;p&gt;I have many python code examples in my markdown files, which should be prepended with &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; symbols.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I write a vim function to do this job:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function AddShellPrompt() range&#xA;    let lnum = a:firstline&#xA;    while lnum &amp;lt;= a:lastline&#xA;        let replaced_line = substitute(getline(lnum), '^\s\+', '&amp;amp;&amp;gt;&amp;gt;&amp;gt;', '')&#xA;        call setline(lnum, replaced_line)&#xA;        let lnum += 1&#xA;    endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is, for raw text like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pow(2, 3)&#xA;8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need only add &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; before &lt;code&gt;pow(2, 3)&lt;/code&gt;, but not before &lt;code&gt;8&lt;/code&gt;.&#xA;So I need to expand my regex.&lt;br&gt;&#xA;It comes to me that if I only add &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; for a line which contains any character of &lt;code&gt;+-*/%(=&lt;/code&gt;.&lt;br&gt;&#xA;I can get a pretty good result(though not perfect).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the problem is, how to write regex (especially in vim) which expresses &lt;em&gt;Some of the characters in the given set has appeared in the current line?&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A specific version of this question is:&lt;br&gt;&#xA;How to detect if a line contains any &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt;, &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;=&lt;/code&gt;, or even a word &lt;code&gt;import&lt;/code&gt; with a vim regex?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After the suggestion of the following answers, I got my improved function as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Massively add python prompt symbol in a markdown file&#xA;function AddShellPrompt() range&#xA;    let lnum = a:firstline&#xA;    let match_pattern = '^\s\+.*[-\+_*/%=]\|.*import\|.*print\|.*def\|.*class\|.*while\|.*for\|.*if\|.*elif\|.*else\|.*pass\|.*continue\|.*break\|.*return'&#xA;    while lnum &amp;lt;= a:lastline&#xA;        let current_line = getline(lnum)&#xA;        if match(current_line, match_pattern) == 0&#xA;            let replaced_line = substitute(current_line, '^\s\+', '&amp;amp;&amp;gt;&amp;gt;&amp;gt;', '')&#xA;            call setline(lnum, replaced_line)&#xA;        endif&#xA;        let lnum += 1&#xA;    endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3085" LastEditorUserId="3085" LastEditDate="2015-08-07T13:16:08.923" LastActivityDate="2015-10-06T14:27:34.533" Title="How to express &quot;There is a specified symbol in the following unknown numbers of characters&quot; in regex?" Tags="|regular-expression|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4197" PostTypeId="1" AcceptedAnswerId="4198" CreationDate="2015-08-07T10:37:00.223" Score="1" ViewCount="690" Body="&lt;p&gt;I've always thought about digraph mode as a way to quickly insert unicode special or unusual chars into the buffer without copy-pasting things around or changing keyboard layout system-wide. So to insert an em-dash, for example, I just type &lt;code&gt;&amp;lt;C-K&amp;gt;-M&lt;/code&gt;, to insert an &lt;code&gt;ä&lt;/code&gt;, I type &lt;code&gt;&amp;lt;C-K&amp;gt;a:&lt;/code&gt; and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Today I stumbled upon another interesting thing you can do in digraph mode, namely inserting special key codes literally into the buffer. From the docs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When {char1} is a special key, the code for that key is inserted in &amp;lt;&amp;gt; form.&#xA;For example, the string &quot;&amp;lt;S-Space&amp;gt;&quot; can be entered by typing &amp;lt;C-K&amp;gt;&amp;lt;S-Space&amp;gt;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm writing a post about Vim tips and tricks and this feature would help me a great deal to quickly enter literal commands. Unfortunately, it doesn't seem to work in my configuration. In insert mode, when I type &lt;code&gt;&amp;lt;C-K&amp;gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; I would expect a &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; to show up on the screen, instead nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I'm on OS X. My Vim build:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jul 10 2015 19:36:53)&#xA;MacOS X (unix) version&#xA;Included patches: 1-712&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         -gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;+clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   +perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python          +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            +ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            +mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        -mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.10 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: /usr/bin/clang   -L. -L/Users/haven/.sm/pkg/active/lib -fPIC -Bstatic -lz -fstack-protector -L/usr/local/lib -Wl,-headerpad_max_install_names -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python   -lruby-static -framework CoreFoundation -lobjc -L/Users/zool/.rvm/rubies/ruby-2.2.1/lib   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3079" LastEditorUserId="3079" LastEditDate="2015-08-07T11:18:38.733" LastActivityDate="2015-08-07T11:27:48.783" Title="Using digraph mode to insert special key codes" Tags="|insert-mode|unicode|digraphs|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4198" PostTypeId="2" ParentId="4197" CreationDate="2015-08-07T10:53:37.027" Score="2" Body="&lt;p&gt;It will work only for (some of) the Vim 'special keys', literally - see &lt;code&gt;:h ins-special-special&lt;/code&gt;. E.g. &lt;code&gt;&amp;lt;C-K&amp;gt;&amp;lt;Up&amp;gt;&lt;/code&gt;. &lt;code&gt;Tab&lt;/code&gt; is not in that list. In addition, your terminal may not pass all key combos to Vim. For example, &lt;code&gt;&amp;lt;S-Space&amp;gt;&lt;/code&gt; is there the same as &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;, so it won't work (unlike in GVim). Long story short, your options seems limited, using this method.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-08-07T11:27:48.783" LastActivityDate="2015-08-07T11:27:48.783" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4199" PostTypeId="2" ParentId="4196" CreationDate="2015-08-07T12:30:57.433" Score="0" Body="&lt;p&gt;It should be possible by including the &lt;code&gt;\|&lt;/code&gt; operator in your regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The text :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sit totam impedit+ .&#xA;adipisicing eos = nulla.&#xA;sit (veniam magnam.&#xA;elit %debitis porro!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the search regex : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/+\|=\|(\|%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the regex matches the 4 lines, though it's not some valid python statement, it answers you question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference : &lt;a href=&quot;https://stackoverflow.com/a/680031/2558252&quot;&gt;https://stackoverflow.com/a/680031/2558252&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-07T12:50:27.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4200" PostTypeId="2" ParentId="4196" CreationDate="2015-08-07T12:32:14.933" Score="2" Body="&lt;p&gt;The question seems easier when you word it differently. If you are happy with the logic of &lt;em&gt;Any of the characters &lt;code&gt;-+*/%(=&lt;/code&gt;or the word &lt;code&gt;import&lt;/code&gt;&lt;/em&gt;, the regex is simply&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[-+*/%()]\|import&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where&#xA;&lt;code&gt;[-+*/%()]&lt;/code&gt; is a set of characters that can match, &lt;code&gt;\|&lt;/code&gt; stands for &lt;em&gt;or&lt;/em&gt;, and &lt;code&gt;import&lt;/code&gt; is the word itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if you want to use that with substitute you want to match the beginning of line of the line containing the pattern, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^\ze.*[-+*/%()]\|import\@&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which adds the start-of-line, \ze to set the end of match directly after, then any characters followed by the match described before.&lt;/p&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2015-08-07T12:32:14.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4201" PostTypeId="5" CreationDate="2015-08-07T12:36:07.310" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://www.chiark.greenend.org.uk/~sgtatham/putty/&quot; rel=&quot;nofollow&quot;&gt;Homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-07T12:36:07.310" LastActivityDate="2015-08-07T12:36:07.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4202" PostTypeId="4" CreationDate="2015-08-07T12:36:07.310" Score="0" Body="SSH client for WIndows and Linux." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-07T12:36:07.310" LastActivityDate="2015-08-07T12:36:07.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4203" PostTypeId="5" CreationDate="2015-08-07T12:41:03.723" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/b4winckler/macvim&quot; rel=&quot;nofollow&quot;&gt;MacVim homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-07T12:41:03.723" LastActivityDate="2015-08-07T12:41:03.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4204" PostTypeId="4" CreationDate="2015-08-07T12:41:03.723" Score="0" Body="Vim modified to run as a native OSX (&quot;Cocoa&quot;) application. This is NOT the Vim that's included on OSX by default." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-07T12:41:03.723" LastActivityDate="2015-08-07T12:41:03.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4205" PostTypeId="5" CreationDate="2015-08-07T12:43:06.623" Score="0" Body="&lt;p&gt;See: &lt;a href=&quot;http://vimhelp.appspot.com/recover.txt.html#swap%2dfile&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help swap-file&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-07T12:43:06.623" LastActivityDate="2015-08-07T12:43:06.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4206" PostTypeId="4" CreationDate="2015-08-07T12:43:06.623" Score="0" Body="Vim stores changes made to a buffer on disk to a swap file, so that any unsaved changes can be recovered in case of a crash.&#xD;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-07T12:43:06.623" LastActivityDate="2015-08-07T12:43:06.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4207" PostTypeId="2" ParentId="4186" CreationDate="2015-08-07T13:02:10.477" Score="3" Body="&lt;p&gt;This is not possible without some serious hackery. In fact, I can't really think of a hack short of modifying the Vim source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also doubt that you &lt;em&gt;really&lt;/em&gt; want this. The definition of a &quot;line&quot; is 0 or more characters ended by a newline, if you change that definition, you change a lot in Vim. For example, what would you expect a command like &lt;code&gt;:s/A/B/&lt;/code&gt; to do? Change everything on the &quot;real&quot; line? Or only the &quot;virtual&quot; line? Or what about &lt;code&gt;:,3s/A/B/&lt;/code&gt;? Use the next 3 lines? Or the next 3 &quot;virtual&quot; lines?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand why you're asking this, but I think your proposed 'solution' will cause you more problems than you will solve.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-08-07T13:02:10.477" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4208" PostTypeId="5" CreationDate="2015-08-07T13:04:03.870" Score="0" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/sirver/UltiSnips&quot; rel=&quot;nofollow&quot;&gt;Homepage&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2715&quot; rel=&quot;nofollow&quot;&gt;Vim Script&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-07T13:04:03.870" LastActivityDate="2015-08-07T13:04:03.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4209" PostTypeId="4" CreationDate="2015-08-07T13:04:03.870" Score="0" Body="Adds &quot;Snippets&quot; to Vim, which allows you to quickly add pre-defined pieces of text with only a few keystrokes." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-07T13:04:03.870" LastActivityDate="2015-08-07T13:04:03.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4210" PostTypeId="2" ParentId="4102" CreationDate="2015-08-07T13:11:10.720" Score="6" Body="&lt;p&gt;I came up with a solution which I think does what you want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that you asked only for hints, so I'll write hints I would have given and then the final function. You'll be free to read it or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here are my tips:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Creating a function&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You said you were really new to vimscript, so here is a short reminder on functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They begins with &lt;code&gt;function! NameOfTheFunc()&lt;/code&gt; (note the first capital letter on the name and the parentheses) and end with &lt;code&gt;endfunction&lt;/code&gt;. You can put them in your &lt;code&gt;.vimrc&lt;/code&gt; file to let vim source them at each start.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Getting the output of a function&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you want to get the output of a function to manipulate it, you can put it in  a register thanks to the &lt;code&gt;redir&lt;/code&gt; function. A use case using &lt;code&gt;:ls&lt;/code&gt; &lt;em&gt;(hey that's also a hint ;-) )&lt;/em&gt; would be the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;redir @n exec 'ls' redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would put the result of &lt;code&gt;:ls&lt;/code&gt; in the register &lt;code&gt;@n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Doing substitutions on the content of a register&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I think you probably know the &lt;code&gt;:s&lt;/code&gt; command and maybe the &lt;code&gt;substitute()&lt;/code&gt; function. It is possible to use the latter to do substitution on the text of a register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(@n, {pattern}, {sub}, {flag})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will apply the substitution on the register &lt;code&gt;@n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;What about submatches?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I don't know how familiar you are with the &lt;code&gt;substitute&lt;/code&gt; command so I'll also remind you that it is possible to create submatches. I think &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Asubstitute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :substitute&lt;/code&gt;&lt;/a&gt; could interest you on this topic (I'll maybe edit this answer to put a link to a more relevant documentation). Basically it allows us to capture only a part of the pattern you're matching and reuse it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The important point is that to use submatches with the &lt;code&gt;substitute()&lt;/code&gt; function your call should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(@n, {pattern}, '\=submatch(X)', {tags})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;X&lt;/code&gt; is the number of the submatch you want to use. &lt;code&gt;\=&lt;/code&gt; allows us to evaluate the content of the &lt;code&gt;{sub}&lt;/code&gt; part instead of just using it literally.  &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;And finally some regex&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I will not make a complete explanation of regex here because it would be really long and I'm really not qualified to do that :-) This topic should be a start: &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#regexp&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h regexp&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the function &lt;code&gt;substitute()&lt;/code&gt; use magic parameter by default. So see &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2Fmagic&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h magic&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Creating a command to feel &quot;pro&quot;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;As we will create a function &lt;em&gt;(let's call it &lt;code&gt;ListBuffers()&lt;/code&gt;)&lt;/em&gt; that we will&#xA;potentially call (very) often, we could create a custom ex command which is way faster to call than a function. To do so, we simply have to add the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! LS call ListBuffers()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this line, typing &lt;code&gt;:LS&lt;/code&gt; will be equivalent to typing &lt;code&gt;call ListBuffers()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;For the next step, I'll shamelessly stole a hint that I got from &lt;a href=&quot;https://vi.stackexchange.com/a/4231/1841&quot;&gt;this VanLaser answer&lt;/a&gt;, many thanks to him. OP will probably not want to follow this step since you stated that you don't want to override &lt;code&gt;:ls&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Our command &lt;code&gt;:LS&lt;/code&gt; fills the same purpose as &lt;code&gt;:ls&lt;/code&gt;, it is possible thanks to &lt;a href=&quot;https://github.com/kana/vim-altercmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;the &lt;code&gt;alterCmd&lt;/code&gt; plugin&lt;/a&gt; to override the original &lt;code&gt;:ls&lt;/code&gt; to use it instead our command.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;alterCmd&lt;/code&gt; installed, we can use the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:AlterCommand ls LS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To replace the original &lt;code&gt;:ls&lt;/code&gt; command with our custom one. This way, typing &lt;code&gt;:ls&lt;/code&gt; will show the buffer list with the shortened names.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;And then we have a function&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Finally, with those different elements, I came up with a function which: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Gets the output of &lt;code&gt;:ls&lt;/code&gt; in a register&lt;/li&gt;&#xA;&lt;li&gt;Substitutes the full path to simply the name of the file&lt;/li&gt;&#xA;&lt;li&gt;Put this result in a variable&lt;/li&gt;&#xA;&lt;li&gt;Output this variable&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote class=&quot;spoiler&quot;&gt;&#xA;  &lt;p&gt;&lt;pre&gt;&lt;code&gt;function! ListBuffers()&#xA;    redir @n&#xA;    silent exec 'ls'&#xA;    redir END&#xA;&#xA;    let list = substitute(@n, '&quot;(\f*\)*(\f*)&quot;' , '\=submatch(2)', &quot;g&quot;)&#xA;    echo list&#xA; &#xA;endfunction&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;silent&lt;/code&gt; on line 3 which ensures that we execute &lt;code&gt;ls&lt;/code&gt; but don't output its result on the screen so you have the list only once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also the regex which can probably be improved. It creates 2 submatches. The first one contains &lt;code&gt;\f*\\&lt;/code&gt; which is as many file-name characters as possible followed by a literal &lt;code&gt;\&lt;/code&gt; and repeated as many time as possible. The second submatch only contains file-name characters and is the one used to replace the whole path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: I created this regex on Windows because I don't have access to a Linux box right now, you might need to replace the literal &lt;code&gt;\&lt;/code&gt; by a literal &lt;code&gt;/&lt;/code&gt; to make it work on Linux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the result of &lt;code&gt;:ls&lt;/code&gt; on my machine:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GUSDV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GUSDV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the result of my &lt;code&gt;ListBuffers()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hHLfO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hHLfO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt;: Sorry for the long answer, I hope it helped ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Carpetsmoker suggested using a variable instead of a register and I think he is particularly right. This way, using the function will not clobber the state of the register. So a better version of the function is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote class=&quot;spoiler&quot;&gt;&#xA;  &lt;p&gt;&lt;pre&gt;&lt;code&gt;function! ListBuffers()&#xA;    redir =&gt; ls_output&#xA;    silent exec 'ls'&#xA;    redir END&#xA;&#xA;    let list = substitute(ls_output, '&quot;(\f*\)*(\f*)&quot;' , '\=submatch(2)',    &quot;g&quot;)&#xA;&#xA;    echo list &#xA; &#xA;endfunction&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;An alternative was to use &lt;code&gt;getRegister()&lt;/code&gt; to save the state of &lt;code&gt;@n&lt;/code&gt; and &lt;code&gt;setRegister()&lt;/code&gt; to give it its previous state, but that's less effective than using a variable.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2015-08-11T12:09:30.243" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4211" PostTypeId="1" AcceptedAnswerId="4230" CreationDate="2015-08-08T09:59:08.930" Score="7" ViewCount="1495" Body="&lt;p&gt;I have a function that looks like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! MultiLineTest(u, v)&#xA;    if    a:u != 2 &amp;amp;&amp;amp;&#xA;       \  a:v != 2&#xA;&#xA;       return 'yes'&#xA;    else&#xA;       return 'no'&#xA;    end&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, the actual function is longer and more complicated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I'd like to add comments to the multi line expression, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if    a:u != 2 &amp;amp;&amp;amp;  &quot; Neither u nor&#xA;       \  a:v != 2     &quot; v must be 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the function is called now, I get an error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E15: Invalid expression: a:u != 2 &amp;amp;&amp;amp;  &quot; neither u nor  a:v != 2     &quot; v must be 2&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I understand why this error is thrown. But I'd still find it nice if I could somehow add comments to such a multi line expression. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="800" LastEditDate="2015-09-22T21:09:56.880" LastActivityDate="2015-09-22T21:09:56.880" Title="Is it possible to add inline comments in a multiline statement?" Tags="|vimscript|comments|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4212" PostTypeId="1" CreationDate="2015-08-08T10:04:27.523" Score="1" ViewCount="251" Body="&lt;p&gt;I've been using &lt;a href=&quot;https://vi.stackexchange.com/q/2260/267&quot;&gt;the pseudo keymap solution from my previous question&lt;/a&gt; to great effect for 6 months now. The short version is that it allows me to keep the computer keyboard map in my usual &lt;a href=&quot;http://www.kaufmann.no/roland/dvorak/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Programmer's Dvorak&lt;/a&gt; at almost all times but have an alternate insert mode in vim where I can type using a &lt;a href=&quot;https://en.wikipedia.org/wiki/Keyboard_layout#Turkish_.28F-keyboard.29&quot; rel=&quot;nofollow noreferrer&quot;&gt;Turkish-F layout&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is great for the alphabet and I've become pretty proficient in both languages, but it's an ongoing problem for symbols. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Turkish_alphabet&quot; rel=&quot;nofollow noreferrer&quot;&gt;Turkish alphabet&lt;/a&gt; has more characters than English and by necessity takes over more keys than the &lt;a href=&quot;https://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;Simplified Dvorak&lt;/a&gt; based layout I'm overlaying it on. The question becomes, &lt;strong&gt;“Where can I even put the displaced symbols?”&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far my solution has been to include a few extra mappings for that prefixes keys that were previously symbols with an Alt-code variant that restores the original symbol. If you're lost, and example would be what would be &lt;kbd&gt;Z&lt;/kbd&gt; on a QWERTY keyboard. In DVP this has &lt;code&gt;'&lt;/code&gt; and &lt;code&gt;&quot;&lt;/code&gt; (in Level 1/2 respectively). Now in my pseudo PTF mapping mode in vim &lt;code&gt;'&lt;/code&gt; is remapped to &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;&quot;&lt;/code&gt; to &lt;code&gt;J&lt;/code&gt; as that's where the Turkish-F layout has that letter. So far so good. But not where do I get my quotes from? By mapping &lt;code&gt;&amp;lt;A-'&amp;gt;&lt;/code&gt; to &lt;code&gt;'&lt;/code&gt; I can use &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;Z&lt;/kbd&gt; to get my quotes back in the position they would be in DVP even when my vim insert keymap is translating to PTF. Whew.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the &lt;kbd&gt;Alt&lt;/kbd&gt; is ① in a really bad place for this and ② conflicts with keybindings I would usually use for window management. I can, of course, move the key, but &lt;a href=&quot;http://goo.gl/7GfaHu&quot; rel=&quot;nofollow noreferrer&quot;&gt;I have it where it is&lt;/a&gt; for easy chording of keybindings. Using a different modifier would seem like a better solution. I have ISO Level3 (or Level5) Shift available in a great place for this. The only trouble is I can't figure out how to map them in Vim.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What can I put in &lt;a href=&quot;https://github.com/alerque/que-vim/blob/master/.vim/keymap/dvorak2turkishf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;my keymap file&lt;/a&gt; to catch chorded key combos using Level3 Shift the way that &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; catches &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;A&lt;/kbd&gt; or &lt;code&gt;&amp;lt;A-a&amp;gt;&lt;/code&gt; catches &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;A&lt;/kbd&gt;?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I suspect the answer to that is going to be, “You can't. Sucker.” In that event:&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;What &lt;em&gt;can&lt;/em&gt; I do? Can I setup a dead-key equivalent in a vim keymap such that a tap on the dead key (which could be anything, my keyboard is programmable) preceding any key will cause that one key to skip the custom map an emit the original non-mapped key?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="267" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-08-08T10:50:09.167" Title="Use ISO Level3/5 as modifier in vim keymap?" Tags="|key-bindings|keyboard-layout|input-methods|" AnswerCount="0" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4213" PostTypeId="5" CreationDate="2015-08-08T10:36:44.113" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:36:44.113" LastActivityDate="2015-08-08T10:36:44.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4214" PostTypeId="4" CreationDate="2015-08-08T10:36:44.113" Score="0" Body="Moving the cursor another place in the buffer." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:36:44.113" LastActivityDate="2015-08-08T10:36:44.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4215" PostTypeId="5" CreationDate="2015-08-08T10:38:26.730" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:38:26.730" LastActivityDate="2015-08-08T10:38:26.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4216" PostTypeId="4" CreationDate="2015-08-08T10:38:26.730" Score="0" Body="For questions about searching for text with / or search().&#xD;&#xA;&#xD;&#xA;For find/replace operations, use tag [substitute] instead." OwnerUserId="51" LastEditorUserId="25" LastEditDate="2022-01-28T03:23:24.807" LastActivityDate="2022-01-28T03:23:24.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4217" PostTypeId="5" CreationDate="2015-08-08T10:39:15.507" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:39:15.507" LastActivityDate="2015-08-08T10:39:15.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4218" PostTypeId="4" CreationDate="2015-08-08T10:39:15.507" Score="0" Body="For questions specific to Vim implementations on the Microsoft Windows operating system." OwnerUserId="51" LastEditorDisplayName="user579" LastEditDate="2018-09-13T11:28:34.840" LastActivityDate="2018-09-13T11:28:34.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4219" PostTypeId="5" CreationDate="2015-08-08T10:40:11.410" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:40:11.410" LastActivityDate="2015-08-08T10:40:11.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4220" PostTypeId="4" CreationDate="2015-08-08T10:40:11.410" Score="0" Body="Questions specific to the macOS operating system." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2022-09-23T11:18:13.777" LastActivityDate="2022-09-23T11:18:13.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4221" PostTypeId="5" CreationDate="2015-08-08T10:40:26.457" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:40:26.457" LastActivityDate="2015-08-08T10:40:26.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4222" PostTypeId="4" CreationDate="2015-08-08T10:40:26.457" Score="0" Body="For questions specific to the Linux operating system." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:40:26.457" LastActivityDate="2015-08-08T10:40:26.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4223" PostTypeId="5" CreationDate="2015-08-08T10:42:26.523" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:42:26.523" LastActivityDate="2015-08-08T10:42:26.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4224" PostTypeId="4" CreationDate="2015-08-08T10:42:26.523" Score="0" Body="Adding highlighting to the document other than syntax highlighting (such as hlsearch or :match)&#xD;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:42:26.523" LastActivityDate="2015-08-08T10:42:26.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4225" PostTypeId="5" CreationDate="2015-08-08T10:44:24.013" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:44:24.013" LastActivityDate="2015-08-08T10:44:24.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4226" PostTypeId="4" CreationDate="2015-08-08T10:44:24.013" Score="0" Body="The clientserver feature allows Vim to accept &amp; execute commands from another process.&#xD;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:44:24.013" LastActivityDate="2015-08-08T10:44:24.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4228" PostTypeId="5" CreationDate="2015-08-08T10:45:32.783" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/scrooloose/syntastic&quot; rel=&quot;nofollow&quot;&gt;Homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:45:32.783" LastActivityDate="2015-08-08T10:45:32.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4229" PostTypeId="4" CreationDate="2015-08-08T10:45:32.783" Score="0" Body="Automatically check for syntax or formatting errors.&#xD;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-08-08T10:45:32.783" LastActivityDate="2015-08-08T10:45:32.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4230" PostTypeId="2" ParentId="4211" CreationDate="2015-08-08T10:51:57.533" Score="9" Body="&lt;p&gt;Not directly. But: if the comment applies to the whole line, you better place it above the line. If the comment(s) are each to indicate something about a portion of the line, you could consider splitting the line into exactly those pieces, and use variables named such as that they can &lt;em&gt;replace&lt;/em&gt; your comments. It's better (IMHO) when the code &quot;speaks&quot; directly. E.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! MultiLineTest(u, v)&#xA;    let meaning_one = (a:u != 2) &quot;there can also be details (if needed)&#xA;    let meaning_two = (a:v != 2) &quot;other details&#xA;    return (meaning_one &amp;amp;&amp;amp; meaning_two) ? 'yes' : 'no'&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-08-08T11:02:59.380" LastActivityDate="2015-08-08T11:02:59.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4231" PostTypeId="2" ParentId="4091" CreationDate="2015-08-08T18:53:50.780" Score="2" Body="&lt;p&gt;So, with some delay, I think I may have found a &lt;em&gt;satisfactory&lt;/em&gt; (at least for me!) answer. You will need two of Shougo's plugins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Shougo/unite.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Shougo/Unite&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Shougo/tabpagebuffer.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Shougo/tabpagebuffer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and a quick access map to use instead of &lt;code&gt;:ls&lt;/code&gt;, to view (and select) only buffers from the &lt;em&gt;current&lt;/em&gt; tab. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :&amp;lt;C-u&amp;gt;Unite buffer_tab -no-split&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sVxJW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sVxJW.png&quot; alt=&quot;unite - per tab buffers&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can now move through the current's tab buffer list (&lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;), select one (&lt;code&gt;CR&lt;/code&gt;), cancel (&lt;code&gt;q&lt;/code&gt;), enter &quot;input&quot; (insert) mode to quickly filter the buffer selection by typing some letters, or even hit &lt;code&gt;Tab&lt;/code&gt; to open the action list for the current selected item (e.g. to open the buffer &lt;em&gt;above&lt;/em&gt; the current active one) - in short, you act in the generic &quot;Unite&quot; way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(see also &lt;code&gt;:h unite_default_key_mappings&lt;/code&gt; and Unite help in general). &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And now for the final (yet optional) trick. With &lt;a href=&quot;https://github.com/kana/vim-altercmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;altercmd&lt;/a&gt;, you can create your very own, tab-wise enabled, &lt;code&gt;ls&lt;/code&gt; command (based on the above Unite functionality):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! LS Unite buffer_tab -no-split&#xA;:AlterCommand ls LS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and everytime you hit &lt;code&gt;:ls&lt;/code&gt;, Vim will actually run &lt;em&gt;your&lt;/em&gt; command instead. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you also won't need &lt;code&gt;:bn&lt;/code&gt; or &lt;code&gt;:bp&lt;/code&gt;, since tab's buffers viewing and selection are now the same command.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-08-08T21:44:25.633" LastActivityDate="2015-08-08T21:44:25.633" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4232" PostTypeId="1" AcceptedAnswerId="4239" CreationDate="2015-08-08T20:21:49.880" Score="7" ViewCount="8345" Body="&lt;p&gt;I installed colorscheme &amp;quot;jellybeans&amp;quot; for Vim. Why does the colors look differently when I run Vim with and without sudo?&lt;/p&gt;&#xA;&lt;p&gt;Example on the screen below - the left one is without sudo, the right is with sudo. The one with sudo is working properly - how can I make Vim to have the same colors without using sudo?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/h9xSr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h9xSr.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I use&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Linux Mint 17.2 (x64)  &#xA;gnome-terminal 3.6.2  &#xA;bash 4.3.11  &#xA;tmux 1.8  &#xA;Vim 7.4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The value of my &lt;code&gt;$TERM&lt;/code&gt; variable is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$TERM=screen-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And the result is the same with &lt;code&gt;sudo $SHELL -c 'echo $TERM'&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here is my &lt;a href=&quot;https://github.com/tkossak/dotfiles/blob/master/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimrc file&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;EDIT - SOLUTION:&lt;/h2&gt;&#xA;&lt;p&gt;Colorscheme file was lacking read permission for &amp;quot;others&amp;quot;. Fixed with:&lt;br /&gt;&#xA;&lt;code&gt;sudo chmod +r /usr/share/vim/vim74/colors/jellybeans.vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1067" LastEditorUserId="23502" LastEditDate="2022-11-05T09:18:44.563" LastActivityDate="2022-11-05T09:18:44.563" Title="Why does my colorscheme look different when I run Vim with sudo?" Tags="|colorscheme|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4233" PostTypeId="1" CreationDate="2015-08-08T21:57:55.910" Score="4" ViewCount="659" Body="&lt;p&gt;I heard someone had set up their editor to highlight python raw strings as regular expressions, e.g. for Django:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;urls(r'^site1/(\d)*/new$'', ...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately my googleing doesn't get me anything. Is this possible in vim?&lt;/p&gt;&#xA;" OwnerUserId="3098" LastEditorUserId="865" LastEditDate="2016-04-08T22:51:00.413" LastActivityDate="2016-04-08T22:51:00.413" Title="Highlight python raw strings as regular expression" Tags="|syntax-highlighting|regular-expression|filetype-python|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4234" PostTypeId="2" ParentId="4232" CreationDate="2015-08-09T07:06:21.673" Score="10" Body="&lt;p&gt;When you run vim with sudo, you are running as user root, so you are using root's vimrc and .vim. Your colorscheme and other customizations set in your ~/.vimrc are not being used. You can see this by executing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:scriptnames&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-08-09T07:06:21.673" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4235" PostTypeId="1" AcceptedAnswerId="4237" CreationDate="2015-08-09T09:55:57.980" Score="13" ViewCount="3381" Body="&lt;p&gt;When editing source code using gvim (v.7.4.488), I want to commit some changes the vcs (I'm using git 2.1.4 from the command line in Ubuntu linux).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git --status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;shows which files I changed.  However, it also shows the vim &lt;code&gt;.*.swp&lt;/code&gt; of the currently visible buffer(s) (both if the file contain unsaved changes and when the edited file is the same as the &lt;code&gt;.*.swp&lt;/code&gt;-file).  Ofcourse, git can &lt;a href=&quot;https://help.github.com/articles/ignoring-files/&quot; rel=&quot;noreferrer&quot; title=&quot;Ignoring files - User Documentation&quot;&gt;ignore&lt;/a&gt; these files or vim can store the swap files in a different location (see &lt;a href=&quot;http://vim.wikia.com/wiki/Remove_swap_and_backup_files_from_your_working_directory&quot; rel=&quot;noreferrer&quot; title=&quot;Remove swap and backup files from your working directory - Vim Tips Wiki&quot;&gt;vim.wikia&lt;/a&gt; or &lt;a href=&quot;https://stackoverflow.com/q/1636297/814206&quot; title=&quot;swapfile - How to change the folder path for swp files in Vim - Stack Overflow&quot;&gt;this question at stackoverflow&lt;/a&gt;).  But I like the &lt;code&gt;.*.swp&lt;/code&gt;-files showing up in &lt;code&gt;git --status&lt;/code&gt; when they contain unsaved changes, since it signals me that I'm committing files in a different state than what I think they are in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I avoid the false positives of &lt;code&gt;.*.swp&lt;/code&gt;-files showing up in &lt;code&gt;git --status&lt;/code&gt; when the saved file is the same as the &lt;code&gt;.*.swp&lt;/code&gt;-file, while being able to see that file to commit are in a different state than the ones I'm editing with vim?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is it possible to only have &lt;code&gt;.*.swp&lt;/code&gt;-files, when file on disk and file in vim are different?&lt;/li&gt;&#xA;&lt;li&gt;Is there an other way to detect unsaved files?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Combining the comments of &lt;a href=&quot;https://vi.stackexchange.com/users/342/elyashiv&quot; title=&quot;User elyashiv - Vi and Vim Stack Exchange&quot;&gt;@elyashiv&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/users/1800/vanlaser&quot; title=&quot;User VanLaser - Vi and Vim Stack Exchange&quot;&gt;@VanLaser&lt;/a&gt; results in a simpler method than detecting whether swap files imply unsaved files:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;do not let git ignore the .*.sw[po] files;&lt;/li&gt;&#xA;&lt;li&gt;when committing, if &lt;code&gt;git --status&lt;/code&gt; reveals any &lt;code&gt;.*.sw[po]&lt;/code&gt;-files do a &lt;code&gt;:wa&lt;/code&gt; in vi; and,&lt;/li&gt;&#xA;&lt;li&gt;add and commit.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3101" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-10T18:51:15.060" Title="How to detect whether swp files contain unsaved changes?" Tags="|git|swap-file|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4236" PostTypeId="2" ParentId="4232" CreationDate="2015-08-09T15:01:17.400" Score="4" Body="&lt;p&gt;Instead of running &lt;code&gt;sudo vim&lt;/code&gt; to run &lt;code&gt;vim&lt;/code&gt; as root, run &lt;code&gt;sudoedit filename&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This creates a temporary copy of the file, edits that copy without root privileges, and copies the changes to the original file. You may need to set &lt;code&gt;VISUAL&lt;/code&gt; or &lt;code&gt;EDITOR&lt;/code&gt; to &lt;code&gt;vim&lt;/code&gt; (e.g. &lt;code&gt;export VISUAL=vim&lt;/code&gt;) to get &lt;code&gt;sudoedit&lt;/code&gt; to use the correct editor. This is safer and uses your Vim configuration instead of root’s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use &lt;code&gt;gvim&lt;/code&gt; instead, you’ll need to use the &lt;code&gt;--nofork&lt;/code&gt; option: &lt;code&gt;export VISUAL='gvim --nofork'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2680" LastActivityDate="2015-08-09T15:01:17.400" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4237" PostTypeId="2" ParentId="4235" CreationDate="2015-08-09T15:43:37.343" Score="11" Body="&lt;p&gt;&lt;code&gt;vim -r&lt;/code&gt; at the command line will list all swap files in the current directory and temporary directories, and whether they contain any unsaved changes. Look for the line that says &lt;code&gt;modified: no/YES&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don’t know how to tell Vim to look in a different directory, so you’ll need to change to each directory that contains a swap file and run &lt;code&gt;vim -r&lt;/code&gt;. You could come up with a script that parsed the output of &lt;code&gt;git status&lt;/code&gt;, or used &lt;code&gt;find -name '.*.sw[po]'&lt;/code&gt;, and then ran &lt;code&gt;vim -r&lt;/code&gt; in each directory, to show all swap files with unsaved changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I use &lt;code&gt;.*.sw[po]&lt;/code&gt; instead of &lt;code&gt;.*.swp&lt;/code&gt;, because sometimes &lt;code&gt;.swo&lt;/code&gt; files are created in addition to &lt;code&gt;.swp&lt;/code&gt; files, when you edit a file that already has a swap file. &lt;code&gt;.swn&lt;/code&gt; files can be created too if you edit a file with two existing swap files, but I don’t think I’ve ever seen one in the wild. If you’re really paranoid, you could use &lt;code&gt;.*.sw[a-p]&lt;/code&gt; or simply &lt;code&gt;.*.sw?&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/starting.html#-r&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help -r&lt;/code&gt;&lt;/a&gt; for (a little) more information on the &lt;code&gt;-r&lt;/code&gt; option, or &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/recover.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help recover.txt&lt;/code&gt;&lt;/a&gt; for more information on recovery and swap filenames.&lt;/p&gt;&#xA;" OwnerUserId="2680" LastEditorUserId="2680" LastEditDate="2015-08-10T18:51:15.060" LastActivityDate="2015-08-10T18:51:15.060" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4238" PostTypeId="2" ParentId="4235" CreationDate="2015-08-09T17:47:33.340" Score="8" Body="&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Is it possible to only have &lt;code&gt;.*.swp&lt;/code&gt;-files, when file on disk and file in vim are different?&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes.  The snippet below (adapted from &lt;a href=&quot;https://github.com/tpope/tpope/blob/338a4e89494bfe4928d3a0221c3ea1a7f09937cb/.vimrc#L328-L329&quot; rel=&quot;noreferrer&quot;&gt;tpope's vimrc&lt;/a&gt;) will disable the swap file for a buffer when it isn't modified, so swap files only exist for modified files.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorHold,BufWritePost,BufReadPost,BufLeave *&#xA;  \ if isdirectory(expand(&quot;&amp;lt;amatch&amp;gt;:h&quot;)) | let &amp;amp;swapfile = &amp;amp;modified | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;: Since the swap file only exists when the buffer is modified, you lose the use of the swap file as an advisory lock.  If the buffer is unmodified, then another Vim can start editing it without notice that it's already open.  If the second Vim saves before the first one makes more changes, then they won't be noticed until the user tries to save or something triggers Vim to check if the file is modified.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2015-08-10T13:32:24.370" LastActivityDate="2015-08-10T13:32:24.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4239" PostTypeId="2" ParentId="4232" CreationDate="2015-08-09T18:55:59.377" Score="4" Body="&lt;p&gt;The solution was: making sure users who run vim can actually read the colorscheme file. Giving everyone read permission is done with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo chmod +r /usr/share/vim/vim74/colors/jellybeans.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1067" LastEditorUserId="205" LastEditDate="2015-08-10T12:51:32.390" LastActivityDate="2015-08-10T12:51:32.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4240" PostTypeId="2" ParentId="4091" CreationDate="2015-08-09T19:10:10.917" Score="1" Body="&lt;p&gt;Check out this plugin. It seems to me it suits your needs perfectly.&#xA;    &lt;a href=&quot;https://github.com/szw/vim-ctrlspace&quot; rel=&quot;nofollow&quot;&gt;https://github.com/szw/vim-ctrlspace&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3105" LastActivityDate="2015-08-09T19:10:10.917" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4241" PostTypeId="1" AcceptedAnswerId="4242" CreationDate="2015-08-09T21:40:53.177" Score="2" ViewCount="463" Body="&lt;p&gt;Here's an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TestCursorPosWithCount() range&#xA;    echo virtcol('.')&#xA;endfunction&#xA;&#xA;nmap &amp;lt;leader&amp;gt;c :call TestCursorPosWithCount()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;code&gt;&amp;lt;leader&amp;gt;c&lt;/code&gt;, the column number will be shown correctly. But, if I do something like &lt;code&gt;2&amp;lt;leader&amp;gt;c&lt;/code&gt;, the cursor is moved and the column number will be that of the final cursor position. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the question: how can I get the original column number inside the function? I.e. the cursor position, as it was before pressing &lt;code&gt;2&lt;/code&gt; in the last example?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After receiving the answer, I add here my findings: a small function demo with normal &amp;amp; visual mappings, that can extract line &amp;amp; column information from the given situation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TestCursorPosWithCount(mode) range&#xA;    if (a:mode == 'n')&#xA;        echo 'normal mode'&#xA;        echo 'count: ' . v:count&#xA;        echo 'position: [' line('.') . ':' . col('.') ']'&#xA;    else &quot;visual mode&#xA;        echo 'visual mode: ' . visualmode()&#xA;        echo 'count: ' . v:count&#xA;        if visualmode() !=# 'V'&#xA;            echo 'range: [' a:firstline . ':' . col(&quot;'&amp;lt;&quot;) ' - '&#xA;                        \   a:lastline  . ':' . col(&quot;'&amp;gt;&quot;) ']'&#xA;        else&#xA;            echo 'range: ['  a:firstline ' - ' a:lastline ']'&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&#xA;nmap &amp;lt;leader&amp;gt;c :&amp;lt;C-u&amp;gt;call TestCursorPosWithCount('n')&amp;lt;CR&amp;gt;&#xA;xmap &amp;lt;leader&amp;gt;c :call TestCursorPosWithCount('v')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="343" LastEditDate="2017-12-06T11:35:46.143" LastActivityDate="2017-12-06T11:35:46.143" Title="Original column number in a mapped function called with a count" Tags="|vimscript|cursor-movement|count|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4242" PostTypeId="2" ParentId="4241" CreationDate="2015-08-09T22:39:34.657" Score="4" Body="&lt;p&gt;When you do :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:2call TestCursorPosWithCount()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... the cursor moves to the beginning of the line 2 and the function is being executed from there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;:&amp;lt;C-u&amp;gt;call TestCursorPosWithCount()&lt;/code&gt; instead, the original cursor position is available, and you can also still get the count number using &lt;code&gt;v:count&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1800" LastEditDate="2015-08-09T23:01:00.500" LastActivityDate="2015-08-09T23:01:00.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4243" PostTypeId="2" ParentId="3943" CreationDate="2015-08-09T23:32:02.010" Score="6" Body="&lt;p&gt;&lt;strong&gt;Yes&lt;/strong&gt;, but &lt;strong&gt;currently&lt;/strong&gt;(2015) not out-of-the-box, because the built-in file-manager of vim doesn't natively support remote browsing. .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update Q3@2016:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several work-arounds, with varying degrees of comfort/compatibility/effort. All together they add up to a nice solution, but they can all also be used individually:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Setup a user-level &lt;code&gt;afuse&lt;/code&gt;/&lt;code&gt;sshfs&lt;/code&gt; daemon in your shell init files&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a few lines of script sourced from e.g. &lt;code&gt;.profile&lt;/code&gt;, you can setup an on-demand auto-mounter under a directory e.g. &lt;code&gt;~/scp/&lt;/code&gt;. &lt;a href=&quot;https://unix.stackexchange.com/q/294965/127903&quot;&gt;Details of this integration in a post&lt;/a&gt; on &lt;a href=&quot;http://unix.stackexchange.com&quot;&gt;Unix &amp;amp; Linux SE&lt;/a&gt;. This is the most comfortable option, remote files &quot;appear&quot; local, but requires &lt;code&gt;afuse&lt;/code&gt; and &lt;code&gt;sshfs&lt;/code&gt; to be available to you.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Setup shell command line completion for remote file paths&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The completion function package for bash has a few functions designed for &lt;code&gt;ssh&lt;/code&gt; and &lt;code&gt;scp&lt;/code&gt; completion. &lt;a href=&quot;https://unix.stackexchange.com/a/294834/127903&quot;&gt;With a wrapper function &lt;code&gt;vim()&lt;/code&gt;, mangling remote paths into &lt;code&gt;vim&lt;/code&gt;'s expected form, they can be used to supply TAB-completed remote files to &lt;code&gt;vim&lt;/code&gt;&lt;/a&gt;. The minor shortcomings of this approach are also detailed there. For situations without afuse. Needs &lt;code&gt;bash-completion&lt;/code&gt; to be installed, or equivalent and adaptations for other shells. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you can't modify your environment or &lt;code&gt;.vimrc&lt;/code&gt;-only: In the vim file-manager you can use the &lt;kbd&gt;/&lt;/kbd&gt;/&lt;kbd&gt;?&lt;/kbd&gt; Keys to search forwards/backwards, and you could map &lt;kbd&gt;TAB&lt;/kbd&gt; to one of them. This is more powerful than it sounds for quickly navigating you around the file-system. Description below.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Basic Workaround (for standard vim with NetRW):&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Don't point vim to a remote file&lt;/li&gt;&#xA;&lt;li&gt;Point to a directory &quot;at the top&quot; e.g. &lt;code&gt;$HOME&lt;/code&gt;: &lt;code&gt;vim scp://files/&lt;/code&gt;, or &lt;code&gt;/&lt;/code&gt;: &lt;code&gt;vim scp://files///&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;NetRW plugin opens in wanted top-level-folder (&lt;code&gt;/&lt;/code&gt; or &lt;code&gt;$HOME&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;In NetRW, you can navigate with surprisingly few keystrokes:&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To edit remote &lt;code&gt;/etc/network/interfaces&lt;/code&gt; with NetRW on &lt;code&gt;/&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;et&lt;/kbd&gt;&lt;kbd&gt;ENTER&lt;/kbd&gt;&lt;kbd&gt;ENTER&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;netw&lt;/kbd&gt;&lt;kbd&gt;ENTER&lt;/kbd&gt;&lt;kbd&gt;ENTER&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;int&lt;/kbd&gt;&lt;kbd&gt;ENTER&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can always use &lt;code&gt;?&lt;/code&gt; to search back upwards, without wrapping from the top.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Even better&lt;/strong&gt;, for &lt;strong&gt;nearly mimicking&lt;/strong&gt; &lt;kbd&gt;TAB&lt;/kbd&gt;-Completion add in &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Map &lt;kbd&gt;TAB&lt;/kbd&gt; to &lt;kbd&gt;/&lt;/kbd&gt;  in NetRW: &lt;code&gt;autocmd filetype netrw noremap &amp;lt;buffer&amp;gt; &amp;lt;TAB&amp;gt; /&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Configure NetRW for TreeView: &lt;code&gt;let g:netrw_liststyle=3&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/5636941/5208540&quot;&gt;Add a toggle for a remote VExplore for &lt;code&gt;&amp;lt;C-E&amp;gt;&lt;/code&gt;&lt;/a&gt;, if you want (I use it).&lt;/li&gt;&#xA;&lt;li&gt;I also recommend &lt;code&gt;incsearch&lt;/code&gt;, &lt;code&gt;ignorecase&lt;/code&gt; and &lt;code&gt;smartcase&lt;/code&gt; for NetRW, or all buffers.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Compared to &quot;conventional&quot; tab-completion, the above is different, yet very comfortable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: All of the above assumes ssh certificate based password-less connections in &lt;a href=&quot;http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;~/.ssh/config&lt;/code&gt;&lt;/a&gt; with User, Port, Compression, JumpHost (ProxyCommand are setup up such that only hostname/aliases are needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;This has also been previously discussed offsite&#xA;&lt;a href=&quot;https://www.reddit.com/r/vim/comments/pikbl/is_there_a_way_to_get_tabcompletion_for_vim_over/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&#xA;and &lt;a href=&quot;http://thomer.com/howtos/netrw_completion.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="3102" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-07-17T11:10:36.953" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4244" PostTypeId="1" AcceptedAnswerId="4250" CreationDate="2015-08-10T06:44:07.930" Score="41" ViewCount="45050" Body="&lt;p&gt;I've been aware of these tab related settings in Vim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ts&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;expandtab&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;smarttab&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sts&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My normal setting is &lt;code&gt;set ts=4 sw=4 expandtab smarttab&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But according to &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27sts%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;sts&lt;/code&gt; documentation&lt;/a&gt;, if &lt;code&gt;expandtab&lt;/code&gt; is not set, it will try to use a combination of spaces and tabs to make up of the desired number of blanks for a tab size. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't really think of a useful scenario for this setting: Why would someone wants to have a fixed number of tabs and spaces that may just mess things up? The only advantage of doing this that I can think of is to reduce the number of characters and thus reduce the file size, which seems weird to me.&lt;/p&gt;&#xA;" OwnerUserId="3114" LastEditorUserId="2680" LastEditDate="2015-08-10T19:42:43.153" LastActivityDate="2020-11-13T14:08:21.657" Title="What is `softtabstop` used for?" Tags="|vimrc|tab-characters|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4245" PostTypeId="1" AcceptedAnswerId="5427" CreationDate="2015-08-10T10:22:28.693" Score="5" ViewCount="1804" Body="&lt;p&gt;I know that you can pass several flags to Vim at startup.&lt;/p&gt;&#xA;&lt;p&gt;For example: the &lt;code&gt;-w&lt;/code&gt; flags enables to records every keystrokes on the file output.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vi -w output &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I wonder if there is a way of doing this from the vimrc file, without having the &lt;code&gt;-w&lt;/code&gt; flag at vim startup.&lt;/p&gt;&#xA;&lt;p&gt;More generally: how can I specify a vim flag/option from within the vimrc ?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="23502" LastEditDate="2022-11-05T09:19:28.183" LastActivityDate="2022-11-05T09:19:28.183" Title="How to specify a Vim flag in the vimrc?" Tags="|vimrc|startup|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="4246" PostTypeId="1" AcceptedAnswerId="4249" CreationDate="2015-08-10T13:49:09.397" Score="19" ViewCount="14617" Body="&lt;p&gt;I saw somewhere on the web someone using &lt;code&gt;Ctrl-J&lt;/code&gt; and as I didn't know this mapping I looked up in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#j&quot;&gt;the relevant doc&lt;/a&gt; and found the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;j           or&#xA;&amp;lt;Down&amp;gt;      or&#xA;CTRL-J      or&#xA;&amp;lt;NL&amp;gt;        or&#xA;CTRL-N          [count] lines downward linewise.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which leads me to several questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;What is &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt;&lt;/strong&gt;: I would see it as an equivalent of &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; since pressing &lt;kbd&gt;Enter&lt;/kbd&gt; will go down one line in normal mode by default but why is it &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; here and not &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;What is the difference between these mappings&lt;/strong&gt;: Do all of these 5 options go one line down in the same way? According to my tests I would answer yes but that would lead to my next question.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Why are there 5 mappings to do the exact same thing&lt;/strong&gt;: I can understand that &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;&amp;lt;down&amp;gt;&lt;/code&gt; are kept for users who are not used to vim mappings, but why do the other mappings exist? &lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;When is it more interesting to use one more than the other&lt;/strong&gt;: That is a continuation of the previous question: if there is so many possibilities I guess that they have different advantages or are better to use in specific use cases. What are those use cases?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I find the redundancy of these commands even more strange when I look at &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#k&quot;&gt;&lt;code&gt;:h k&lt;/code&gt;&lt;/a&gt;: there are only 3 ways to go up: &lt;code&gt;k&lt;/code&gt;, &lt;code&gt;&amp;lt;UP&amp;gt;&lt;/code&gt; and &lt;code&gt;ctrl-p&lt;/code&gt;. So the bonus question is: &lt;strong&gt;Why are there 5 ways to go down and only 3 to go up?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="205" LastEditDate="2015-08-10T16:35:25.073" LastActivityDate="2015-08-10T21:14:40.080" Title="What is the difference between j, CTRL-J, &lt;NL&gt; and CTRL-N in normal mode?" Tags="|cursor-movement|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4248" PostTypeId="2" ParentId="4246" CreationDate="2015-08-10T16:28:37.410" Score="8" Body="&lt;p&gt;See &lt;code&gt;:help key-notation&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; means &quot;linefeed&quot; and &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; means &quot;carriage return&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those are two different ways to break the current line. They are historically bound to different control characters (&lt;code&gt;ctrl-j&lt;/code&gt; and &lt;code&gt;ctrl-m&lt;/code&gt;) but are usually inserted with the same key, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;. I agree that using &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; in this context seems counterintuitive.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;All those &quot;mappings&quot; (they are not actually mappings) behave exactly the same way.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;History, mostly, also cross-platform constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There were no dedicated motion keys Bill Joy's terminal but the arrows decals were on the &lt;code&gt;hjkl&lt;/code&gt; keys. Since modal editors were rare at the time, pressing those keys only inserted the associated character in whatever you were doing. You had to press &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; to move the cursor on the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, there's quite an overlap between &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Down&amp;gt;&lt;/code&gt;. &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; generally meaning &quot;next&quot; in Vim, it's easy to see how it got lumped together with its comrades.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Since they are all synonymous, you are free to use the one that works best for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, for example, is an interesting key to use for your own mappings.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-08-10T21:14:40.080" LastActivityDate="2015-08-10T21:14:40.080" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4249" PostTypeId="2" ParentId="4246" CreationDate="2015-08-10T16:30:35.500" Score="18" Body="&lt;p&gt;Interesting that you mentioned &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;. &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; or carriage return, technically used to mean &lt;em&gt;go to the start of the line&lt;/em&gt;. &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt;, or newline aka line feed (usually called &lt;code&gt;LF&lt;/code&gt;), was used to mean &lt;em&gt;go to the next line&lt;/em&gt;. Over time, the distinction was lost in most applications.&lt;sup&gt;1&lt;/sup&gt; Pressing &lt;kbd&gt;Enter&lt;/kbd&gt; actually yields a carriage return, usually (try pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; - you should see &lt;code&gt;^M&lt;/code&gt; in Unix terminals). &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt;'s control code is &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;N&lt;/kbd&gt; surprised me. According to &lt;a href=&quot;http://manpages.ubuntu.com/ascii.7&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;man ascii&lt;/code&gt;&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt;, it is a &lt;em&gt;shift out&lt;/em&gt; character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Oct   Dec   Hex   Char                        Oct   Dec   Hex   Char&#xA;────────────────────────────────────────────────────────────────────────&#xA;016   14    0E    SO  (shift out)             116   78    4E    N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;shift in&lt;/em&gt; and &lt;em&gt;shift out&lt;/em&gt; characters, according to &lt;a href=&quot;https://en.wikipedia.org/wiki/Shift_Out_and_Shift_In_characters&quot; rel=&quot;noreferrer&quot;&gt;Wikipedia&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... provided a way to shift, hence the nomenclature, a coloured ribbon, split longitudinally usually with red and black, up and down to the other  colour in an electro-mechanical typewriter or teleprinter ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How it ended up meaning &lt;em&gt;go down&lt;/em&gt; is a mystery to me.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why are there 5 ways to go down and only 3 to go up?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, the three ways to go up all have corresponding ways to go down. (&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt; presumably is the complement of &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;N&lt;/kbd&gt;, implying that the &lt;em&gt;shift in/out&lt;/em&gt; is not relevant here). The extra two ways down (&lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; or &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt;) are actually two representations of the same way. &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; is an inheritance from the typewriter days - and in those days, I don't think there was a key to go up - only to go down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/3091524/2072269&quot;&gt;What are carriage return, linefeed, and form feed?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sup&gt;1&lt;/sup&gt; It still matters in some cases (printing &lt;code&gt;\r&lt;/code&gt; (carriage return) and &lt;code&gt;\n&lt;/code&gt; (line feed) using most formatted printing functions/tools still retain the old meaning.).&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sup&gt;2&lt;/sup&gt; This table is arranged in such a manner that the alphabet corresponds to the control code of the character on the same line.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-10T17:27:08.647" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4250" PostTypeId="2" ParentId="4244" CreationDate="2015-08-10T18:02:42.497" Score="28" Body="&lt;p&gt;As the &lt;code&gt;softtabstop&lt;/code&gt; documention mentions, it's useful if you want to keep the default tab stop size of 8, but edit a file as if the tab stop size was some other value. For example, if you wanted an indentation level of 4 while editing code, but some comments had tab-indented text such as a table that depended on a tab stop of 8, you could set &lt;code&gt;sts&lt;/code&gt; to &lt;code&gt;4&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One difference I notice between your tab settings (&lt;code&gt;set ts=4 sw=4 expandtab smarttab&lt;/code&gt;) and the use of &lt;code&gt;sts&lt;/code&gt; (e.g. &lt;code&gt;set ts=8 sts=4&lt;/code&gt;) is when backspacing over spaces in the middle of a line of text. For example, consider the following line of text, where &lt;code&gt;·&lt;/code&gt; indicates a space:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some·text·······more·text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In insert mode, move the cursor just before the &lt;code&gt;m&lt;/code&gt; of &lt;code&gt;more text&lt;/code&gt;. With your settings, pressing Backspace deletes a single space. But while using &lt;code&gt;sts=4&lt;/code&gt;, Backspace deletes all the way to the previous tab stop, as it would behave if the spaces were a tab character instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can set &lt;code&gt;sts=4&lt;/code&gt; in addition to your settings and get the mid-line backspace behavior while not mixing tabs and spaces. Tabs will be expanded to four spaces, but you can backspace over a range of spaces in the middle of a line.&lt;/p&gt;&#xA;" OwnerUserId="2680" LastActivityDate="2015-08-10T18:02:42.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4251" PostTypeId="1" AcceptedAnswerId="4252" CreationDate="2015-08-10T18:51:37.703" Score="3" ViewCount="532" Body="&lt;p&gt;I have a Haskell file on VIM with a Haskell-style comment block:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5uKS2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5uKS2.png&quot; alt=&quot;https://i.stack.imgur.com/5uKS2.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I select that comment block on visual mode...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TFHWf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TFHWf.png&quot; alt=&quot;https://i.stack.imgur.com/TFHWf.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And press &lt;code&gt;gq&lt;/code&gt;, I expected VIM to format my comment to something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4nsgT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4nsgT.png&quot; alt=&quot;https://i.stack.imgur.com/4nsgT.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But instead, this is what VIM does:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qn2Dw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qn2Dw.png&quot; alt=&quot;https://i.stack.imgur.com/qn2Dw.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix it?&lt;/p&gt;&#xA;" OwnerUserId="3128" LastActivityDate="2015-08-10T19:12:21.333" Title="Vim &quot;gq&quot; command doesn't recognize Haskell-style comments" Tags="|visual-mode|formatting|comments|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4252" PostTypeId="2" ParentId="4251" CreationDate="2015-08-10T19:06:26.343" Score="6" Body="&lt;p&gt;&lt;code&gt;:set comments+=:--&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This appends &lt;code&gt;:--&lt;/code&gt; to the value of &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27comments%27&quot;&gt;&lt;code&gt;comments&lt;/code&gt;&lt;/a&gt;, which adds &lt;code&gt;--&lt;/code&gt; as a comment line indicator. The format of this option is described by &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#format-comments&quot;&gt;&lt;code&gt;:help format-comments&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2680" LastEditorUserId="2680" LastEditDate="2015-08-10T19:12:21.333" LastActivityDate="2015-08-10T19:12:21.333" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4254" PostTypeId="1" CreationDate="2015-08-10T21:46:23.107" Score="1" ViewCount="128" Body="&lt;p&gt;I have these mappings in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;s-j&amp;gt; &amp;lt;C-w&amp;gt;-&#xA;nnoremap &amp;lt;s-k&amp;gt; &amp;lt;C-w&amp;gt;+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a single buffer, &lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; results in resizing my (pic1) buffer. Im not sure about that, but i think the airline &quot;statusline&quot; is a seperate buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, how can i prevent that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Sorry, i forgot that i can edit my own questions.&#xA;In the link above (I can only post 2 links), the airline buffer is very similiar to mine before resizing - (pic2) &lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;, the location of the buffer has changed. I want just that the airline buffer is always as in the one before, that it's always at the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Nobe4 Thanks for the link, im not sure if that's what im searching for, but i'll try it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT2&lt;/strong&gt;: The Only difference between the two pictures is the positioning of the airline buffer. In &lt;a href=&quot;http://s30.postimg.org/q6c4wdj7l/2015_08_11_111422_800x881_scrot.png&quot; rel=&quot;nofollow&quot;&gt;1&lt;/a&gt; it's at the very bottom, like it should be. In &lt;a href=&quot;http://s29.postimg.org/wy3kp8lt3/2015_08_11_111651_800x881_scrot.png&quot; rel=&quot;nofollow&quot;&gt;2&lt;/a&gt; the airline buffer itself is shifted upwards. I.e. in (pic2), between the airline buffer and the very bottom is just nothing. My target is, that the airline buffer on the bottom (if horizontally splitted) can't be shifted upwards like in (pic2), because it's just useless.&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="2354" LastEditDate="2015-08-11T11:27:34.243" LastActivityDate="2015-08-11T11:27:34.243" Title="How do I prevent resizing of particular buffer?" Tags="|buffers|statusline|plugin-airline|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="4255" PostTypeId="1" CreationDate="2015-08-11T01:30:38.023" Score="6" ViewCount="145" Body="&lt;p&gt;I have a very customized vim configuration, but I don't think it has anything to do with this, because nothing has changed the key binding system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I press &lt;code&gt;g&lt;/code&gt; I can leave the window there and make a sandwich and come back and it's still shown in the part of my statusbar that shows pending keystrokes (I forget what that is called).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I press &lt;code&gt;\&lt;/code&gt; (&lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;) it times out and beeps after one second. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I check maps, I see that neither &lt;code&gt;g&lt;/code&gt; nor &lt;code&gt;\&lt;/code&gt; have primary mappings to just that key (which would indeed cause them to trigger their mapping upon timeout or receiving another non-matching key).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what then is the difference between these two cases? Why doesn't &lt;code&gt;\&lt;/code&gt; leave me more time, or, why does &lt;code&gt;g&lt;/code&gt; not time out?&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2015-12-23T22:21:17.607" Title="What determines if a key stroke is waited indefinitely or if it times out?" Tags="|key-bindings|" AnswerCount="1" CommentCount="8" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4256" PostTypeId="1" AcceptedAnswerId="4258" CreationDate="2015-08-11T01:48:27.333" Score="1" ViewCount="367" Body="&lt;p&gt;Suppose we have several files &lt;code&gt;f11.txt&lt;/code&gt; &lt;code&gt;f21.txt&lt;/code&gt; &lt;code&gt;f31.txt&lt;/code&gt; &lt;code&gt;f01.txt&lt;/code&gt; &lt;code&gt;f02.txt&lt;/code&gt; &lt;code&gt;f03.txt&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there any Vim option such that I can open all files except for &lt;code&gt;f0*.txt&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Something like &lt;code&gt;gvim -O * --exclude=*0*&lt;/code&gt;? (-O split files vertically, the first &lt;code&gt;*&lt;/code&gt; matches all files, the &lt;code&gt;exclude&lt;/code&gt; is supposed to exclude the &lt;code&gt;f0*.txt&lt;/code&gt; files)&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="23502" LastEditDate="2022-11-05T07:32:24.160" LastActivityDate="2022-11-05T07:32:24.160" Title="How to open multiple files except some files?" Tags="|multiple-files|invocation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4257" PostTypeId="1" AcceptedAnswerId="4277" CreationDate="2015-08-11T02:16:47.230" Score="3" ViewCount="1622" Body="&lt;p&gt;I have a couple of plugins that don't work correctly on some machines running earlier versions of Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to supress the &lt;code&gt;Error detected while processing...&lt;/code&gt; errors when I start up vim in these environments?&lt;/p&gt;&#xA;" OwnerUserId="1623" LastEditorUserId="1841" LastEditDate="2015-08-11T09:50:17.287" LastActivityDate="2015-08-12T05:42:02.997" Title="How do I prevent Vim from loading plugins on older configurations?" Tags="|vimrc|plugin-system|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4258" PostTypeId="2" ParentId="4256" CreationDate="2015-08-11T04:06:11.790" Score="3" Body="&lt;p&gt;Vim does not provide such an option, but if you are using bash, and have the &lt;code&gt;extglob&lt;/code&gt; option set (&lt;code&gt;shopt -s extglob&lt;/code&gt;), you can use the &lt;code&gt;!(pattern-list)&lt;/code&gt; sub-pattern to match all files except those matching one of the given patterns. (See &lt;code&gt;man bash&lt;/code&gt; and search for &lt;code&gt;!(&lt;/code&gt;.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that, you can open your files using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim -O !(*0*)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-08-11T04:06:11.790" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4259" PostTypeId="2" ParentId="4257" CreationDate="2015-08-11T04:25:34.813" Score="6" Body="&lt;p&gt;It depends on the plugin and on what is causing the error. Most plugins have a block of code near the top of the plugin that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('g:loaded_foo')&#xA;    finish&#xA;endif&#xA;let g:loaded_foo = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;foo&lt;/code&gt; is usually the name of the plugin. This prevents the plugin from being loaded more than once, but also allows the user to prevent it from being loaded at all by setting &lt;code&gt;g:loaded_foo&lt;/code&gt; in their &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your problematic plugin has such a block, then you can put code like the following in your &lt;code&gt;~/.vimrc&lt;/code&gt;. If the plugin fails because it is using a function such as &lt;code&gt;and()&lt;/code&gt; that exists only in recent versions of Vim, you can use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(&quot;*and&quot;)&#xA;    let g:loaded_foo = 1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help exists()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the plugin fails because of some patch that cannot be detected with &lt;code&gt;exists()&lt;/code&gt; or &lt;code&gt;has()&lt;/code&gt;, you can use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if version &amp;lt; 704 || (version == 704 &amp;amp;&amp;amp; !has(&quot;patch123&quot;))&#xA;    let g:loaded_foo = 1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-08-11T04:25:34.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4260" PostTypeId="2" ParentId="129" CreationDate="2015-08-11T06:50:43.573" Score="1" Body="&lt;p&gt;Like @superjer, I keep pressing &lt;kbd&gt;u&lt;/kbd&gt; until the red &lt;code&gt;[+]&lt;/code&gt; marker in my statusline disappears.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%f\ %#Error#%m%##&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-08-11T06:55:45.113" LastActivityDate="2015-08-11T06:55:45.113" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4261" PostTypeId="1" AcceptedAnswerId="4263" CreationDate="2015-08-11T07:07:00.060" Score="5" ViewCount="915" Body="&lt;p&gt;Every now and then when I try to quit vim, I incidentally open window with command cheat sheet as in attached picture. How do I do this and how is it called?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qk1Ka.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qk1Ka.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3131" LastActivityDate="2015-08-11T07:18:47.300" Title="Opening built-in cheat sheet" Tags="|help-system|" AnswerCount="2" CommentCount="2" ClosedDate="2015-08-15T21:07:56.400" ContentLicense="CC BY-SA 3.0" />
  <row Id="4262" PostTypeId="2" ParentId="4261" CreationDate="2015-08-11T07:18:37.680" Score="5" Body="&lt;p&gt;This is command history invoked by &lt;code&gt;q:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Using_command-line_history&quot;&gt;http://vim.wikia.com/wiki/Using_command-line_history&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3132" LastActivityDate="2015-08-11T07:18:37.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4263" PostTypeId="2" ParentId="4261" CreationDate="2015-08-11T07:18:47.300" Score="10" Body="&lt;p&gt;That's not a cheat sheet; it's a history of the commands you've executed. It allows you to find, edit and repeat commands you've previously executed. There are a couple of ways you can enter it. One is to type &lt;code&gt;Ctrl-F&lt;/code&gt; while on the ex command line. Another way is to type &lt;code&gt;q:&lt;/code&gt; while in normal mode. You can read more about it here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 20.4&#xA;:help 20.5&#xA;:help cmdwin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-08-11T07:18:47.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4264" PostTypeId="2" ParentId="4257" CreationDate="2015-08-11T09:43:07.010" Score="2" Body="&lt;p&gt;I'll base my answer on GaryJohn's one. The idea is the same: creating conditions on your Vim version or on features that you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using global varibales like &lt;code&gt;g:loaded_foo&lt;/code&gt; may be a problem on some plugin which do not provides this kind of variables. If you use a plugin manager you could instead use the following line in your &lt;code&gt;if&lt;/code&gt; condition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'XXX/myplug'` &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of having:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'XXX/myPlug`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if version &amp;lt; 704 || (version == 704 &amp;amp;&amp;amp; !has(&quot;patch123&quot;))&#xA;    Plug 'XXX/myPlug`&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Or whatever condition as GaryJohn stated)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This prevent vim from loading the plugin event if it is poorly designed and doesn't provides a global variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 1&lt;/strong&gt; Of course the plugin manager need to have these lines between its beginning and ending lines &lt;em&gt;(like &lt;code&gt;call plug#begin('~/.vim/plugged')&lt;/code&gt; and &lt;code&gt;call plug#end()&lt;/code&gt;for Vim-plug)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 2&lt;/strong&gt; My example use the &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow&quot;&gt;Vim-plug&lt;/a&gt; syntax because I tried it with this plugin manager but I see no reason why it wouldn't work with other plugin managers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 3&lt;/strong&gt; As I'm writing this answer I'm remembering that Vim-Plug as a &quot;on demand loading&quot; which might be tricked to load plugins depending on the Vim version. I'm not sure of this point btw.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-08-11T09:43:07.010" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4265" PostTypeId="2" ParentId="4050" CreationDate="2015-08-11T10:18:15.643" Score="4" Body="&lt;p&gt;Here is a function that you could try. I've only tested it a little bit but it seems to work ok.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! JJSyntaxSearch(pattern, syntaxitem)&#xA;  while search(a:pattern, 'W') &amp;gt; 0&#xA;    for id in synstack(line(&quot;.&quot;),col(&quot;.&quot;))&#xA;      if synIDattr(id,&quot;name&quot;) =~? a:syntaxitem&#xA;        return line(&quot;.&quot;)&#xA;      endif&#xA;    endfor&#xA;  endwhile&#xA;  return 0&#xA;endfunc&#xA;&#xA;command! -nargs=* JJSyntaxSearch call JJSyntaxSearch(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function calls Vim's search function in a loop until it finds an 'ordinary' match that is also a 'qualified' match to a particular syntax item, or until it reaches the end of the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It takes two arguments. The first is the search pattern and it is passed on unchanged to Vim's &lt;code&gt;search()&lt;/code&gt; function. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#search()&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help search()&lt;/code&gt;&lt;/a&gt; for how that function works. The second argument is the name of the syntax item on which you want to filter these matches. This can also be a pattern and is compared as a case-insensitive regular expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To find the pattern 'alpha' in math zones you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:JJSyntaxSearch alpha texMathZone.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;.&lt;/code&gt; at the end is the pattern atom for any single character, see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/.&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help /.&lt;/code&gt;&lt;/a&gt;. This is because there many math zone syntax items called &lt;code&gt;texMathZoneA&lt;/code&gt;, &lt;code&gt;texMathZoneB&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;search()&lt;/code&gt; function moves the cursor to the next 'ordinary' match. Then our function gets all the syntax item IDs for that new cursor position with &lt;code&gt;synstack()&lt;/code&gt;. Looping through them, it retrieves the name of each item in turn and tests it against the &lt;code&gt;syntaxitem&lt;/code&gt; argument. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#synstack()&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help synstack()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#synIDattr()&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help synIDattr()&lt;/code&gt;&lt;/a&gt;. If there is a 'qualified' match it returns the line number. If it reaches the end of the buffer without finding any 'qualified' match it returns &lt;code&gt;0&lt;/code&gt;. The point of the function is to get the cursor to the next 'qualified' match so you can do some operation there, but it is useful to return &quot;line number or 0&quot; to indicate whether it is meaningful to call the function again, for instance if you want to call the function repeatedly from another function or a macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I chose to use the &lt;code&gt;W&lt;/code&gt; flag for the &lt;code&gt;search()&lt;/code&gt; because it prevents 'wrapping around' the end of the buffer. Otherwise the function might get stuck as it keeps finding the same 'ordinary' matches but no 'qualified' matches.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-08-11T10:18:15.643" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4266" PostTypeId="2" ParentId="2772" CreationDate="2015-08-11T13:50:30.010" Score="4" Body="&lt;p&gt;Since this issue was found to be a bug in the combination of your Windows version and version 7.4 of gvim (the latest as of 08/2015), the only answers are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Wait until a newer version of vim for your Windows version. (7.3 came out 2010, 7.4 in 2013, so perhaps even this year)&lt;/li&gt;&#xA;&lt;li&gt;Don't use the Windows version of gvim on your Windows version. You did not mention , if you tried different variants (vim native/cygwin, a &quot;portable version&quot;). So you could try those, or the recent vim fork &lt;code&gt;neovim&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Use a different Windows Version. User mguiffrida found 8.1 to be unaffected. Perhaps the &quot;fix&quot; carried over into Windows 10 as well.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I realize, this is not the answer you wanted to hear, but -for now- this seems like the only answer.&lt;/p&gt;&#xA;" OwnerUserId="3102" LastEditorUserId="3102" LastEditDate="2015-08-11T16:34:49.530" LastActivityDate="2015-08-11T16:34:49.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4268" PostTypeId="2" ParentId="4245" CreationDate="2015-08-11T16:47:21.247" Score="0" Body="&lt;p&gt;(This solution only works if you want to save your keystrokes to a single file)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could alias it in your &lt;code&gt;bash_profile&lt;/code&gt;, &lt;code&gt;bash_rc&lt;/code&gt;, whichever one declares your path variables. This is one I did for &lt;code&gt;ls&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias ls=&quot;ls -pla&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So yours would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vi=&quot;vi -w [output]&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3138" LastActivityDate="2015-08-11T16:47:21.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4269" PostTypeId="1" CreationDate="2015-08-11T19:32:48.697" Score="3" ViewCount="790" Body="&lt;p&gt;Is there a way to expand a UltiSnips snippet while in vim command-line mode? I can only expand a snippet in insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using UltiSnips to help inserting unicode characters. And I need to write these characters in the command-line for searching. I do not want to insert them using &lt;code&gt;&amp;lt;C-v&amp;gt;u&lt;/code&gt;. I also prefer not to use digraphs.&lt;/p&gt;&#xA;" OwnerUserId="3140" LastEditorUserId="1841" LastEditDate="2015-08-11T19:38:00.433" LastActivityDate="2022-06-22T15:55:38.953" Title="Triggering UltiSnips in command-line mode" Tags="|plugin-ultisnips|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4270" PostTypeId="2" ParentId="2839" CreationDate="2015-08-11T20:37:32.293" Score="1" Body="&lt;p&gt;It's possibly your working path mode - check the ctrlp help for &lt;code&gt;g:ctrlp_working_path_mode&lt;/code&gt;. I'm not sure what the default is, but I seem to recall that when I didn't explicitly set it I also got weirdness. Since I am mostly working in source controlled projects I use &lt;code&gt;let g:ctrlp_working_path_mode = 'r'&lt;/code&gt; but otherwise using &lt;code&gt;let g:ctrlp_working_path_mode = 'c'&lt;/code&gt; might also help.&lt;/p&gt;&#xA;" OwnerUserId="248" LastActivityDate="2015-08-11T20:37:32.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4271" PostTypeId="1" AcceptedAnswerId="4276" CreationDate="2015-08-11T22:12:39.823" Score="5" ViewCount="4253" Body="&lt;p&gt;I have a function that is called via a mapping when I am in insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;buffer&amp;gt; &amp;lt;M-i&amp;gt; &amp;lt;ESC&amp;gt;:call TheFunc()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function is supposed to &quot;calculate&quot; a string (&lt;code&gt;l:text&lt;/code&gt;) and to insert it at the current cursor position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! TheFunc()&#xA;&#xA;   if g:FOO = 1&#xA;      let l:text = XYZ()&#xA;   elseif g:FOO = g:BAR&#xA;      let l:text = ABC()&#xA;   ... etc etc&#xA;   endif&#xA;&#xA;   execute 'normal a' . l:text&#xA;&#xA;   execute 'normal l'&#xA;   startinsert&#xA;&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;execute 'normal l'&lt;/code&gt; so that after calling the function, further typed text is inserted &lt;em&gt;after&lt;/em&gt; the text inserted by the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works fine, &lt;em&gt;except&lt;/em&gt; when the cursor is on the end of a line. In this case, the &lt;code&gt;normal l&lt;/code&gt; cannot move the cursor one to the right, and the subsequent &lt;code&gt;startinsert&lt;/code&gt; inserts one character to early.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can circumenvent this problem by replacing the &lt;code&gt;startinsert&lt;/code&gt; command with this construct&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if col('.') + 1 == col('$')&#xA;   startinsert!&#xA;else&#xA;  execute 'normal l'&#xA;  startinsert&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works as I need it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet, I &lt;em&gt;feel&lt;/em&gt; there should be a more elegant way to achieve what I want. Is there?&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2015-08-12T06:39:36.917" Title="Calling function to insert text with inoremap" Tags="|key-bindings|vimscript|insert-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4272" PostTypeId="1" AcceptedAnswerId="4274" CreationDate="2015-08-11T22:49:43.170" Score="2" ViewCount="444" Body="&lt;p&gt;I find there is one line &lt;code&gt;let g:netrw_bufsettings = 'noma nomod nu nobl nowrap ro'&lt;/code&gt; in my &lt;code&gt;_vimrc&lt;/code&gt; file. &lt;a href=&quot;http://rebbemalachi.blogspot.com/2013/04/re-making-netrw-buffers-buflisted.html&quot; rel=&quot;nofollow&quot;&gt;Google&lt;/a&gt; says it could make &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;netrw buffers buflisted&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What does it mean to make &quot;netrw buffers buflisted&quot;? Can anyone explain what the line in the &lt;code&gt;_vimrc&lt;/code&gt; file does?&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="51" LastEditDate="2015-08-12T08:22:43.070" LastActivityDate="2015-08-12T08:22:43.070" Title="What does it mean to buflist netrw buffer?" Tags="|buffers|netrw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4273" PostTypeId="1" AcceptedAnswerId="4275" CreationDate="2015-08-11T23:17:55.373" Score="4" ViewCount="530" Body="&lt;p&gt;I've sample file like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aa&#xA;bb&#xA;cc&#xA;dd&#xA;ee&#xA;ff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'd like to remove everything till the matched line &lt;code&gt;dd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally in Vim I type: &lt;code&gt;d/dd&lt;/code&gt; then &lt;kbd&gt;Enter&lt;/kbd&gt; and it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using in &lt;code&gt;ex&lt;/code&gt;, it doesn't work as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -s +&quot;norm ggd/dd&amp;lt;cr&amp;gt;&quot; +%p -cq! foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-11-28T22:38:02.550" Title="Delete text after match in Ex?" Tags="|normal-mode|ex-mode|ex-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4274" PostTypeId="2" ParentId="4272" CreationDate="2015-08-12T00:10:29.810" Score="3" Body="&lt;p&gt;The &lt;code&gt;g:netrw_bufsettings&lt;/code&gt; option is what allows you to set options that vim will only apply to netrw buffers.  A buffer is essentially a file that is loaded in vim, whether it actually exists on your hard drive or not.  You can get a list of all these buffers using the &lt;code&gt;:ls&lt;/code&gt; command.  When the &lt;code&gt;buflisted&lt;/code&gt; option is set &lt;em&gt;(which can be done manually like so: &lt;code&gt;:set buflisted&lt;/code&gt;)&lt;/em&gt;, it means that the buffer will be listed in the output of &lt;code&gt;:ls&lt;/code&gt; and will be included in the current buffer list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help on the commands used here, see these resources:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'buflisted'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :ls&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :set&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-08-12T00:10:29.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4275" PostTypeId="2" ParentId="4273" CreationDate="2015-08-12T00:20:54.363" Score="7" Body="&lt;p&gt;There is a better way of accomplishing the task you showed in ex mode, which is by using the &lt;code&gt;:delete&lt;/code&gt; command and a basic &lt;code&gt;cmdline-range&lt;/code&gt;.  To delete all lines between and including the beginning of the file and the search match, you can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1,/dd/delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't want to include the matched line in the deletion, you can do this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1,/dd/-1delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one works by selecting a range between the first line of the file and the first line that matches the pattern &lt;code&gt;dd&lt;/code&gt;, which is then used by the delete command.  The second one is essentially the same, except there is a &lt;code&gt;-1&lt;/code&gt; before &lt;code&gt;delete&lt;/code&gt; which selects the line directly above the pattern &lt;code&gt;dd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more on this, see &lt;code&gt;cmdline-ranges&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-11-28T22:38:02.550" LastActivityDate="2015-11-28T22:38:02.550" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4276" PostTypeId="2" ParentId="4271" CreationDate="2015-08-12T00:28:08.393" Score="9" Body="&lt;p&gt;There is a better way of using functions in mappings, and that is by using the &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; flag.  For example, say you wanted to insert the current line number at the cursor position by typing &lt;code&gt;ln&lt;/code&gt; in insert mode.  This is how you would accomplish that with an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; ln line(&quot;.&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of directly putting the keys you want to type in the mappping, you put a function whose return value is treated like normal keypresses.  In this case, it inserts the output of the &lt;code&gt;line()&lt;/code&gt; function.  A normal vimscript expression can be used as well.  For more on these kinds of mappings, see &lt;code&gt;:help :map-&amp;lt;expr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-08-12T00:28:08.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4277" PostTypeId="2" ParentId="4257" CreationDate="2015-08-12T04:57:45.403" Score="1" Body="&lt;p&gt;If you happen to have &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow&quot;&gt;pathogen&lt;/a&gt;, another solution here is to use its &lt;code&gt;g:pathogen_disabled&lt;/code&gt; array variable. In your .vimrc you can add bundle names to this array based on vim's reported environment. Upon calling call &lt;code&gt;pathogen#infect()&lt;/code&gt;, it will not enable the listed plugins.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Airline only works on Vim 7.2+&#xA;let g:pathogen_disabled = []&#xA;if v:version &amp;lt; 702&#xA;  call add(g:pathogen_disabled, 'vimproc')&#xA;endif&#xA;pathogen#infect()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1623" LastEditorUserId="1623" LastEditDate="2015-08-12T05:42:02.997" LastActivityDate="2015-08-12T05:42:02.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4278" PostTypeId="2" ParentId="4271" CreationDate="2015-08-12T06:39:36.917" Score="7" Body="&lt;p&gt;The following is an example where the &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; type mapping is used to obtain the same functionality. One of the main advantages is that you now stay in insert mode, which means the cursor position will be correct. It also means you don't have to worry about the &lt;code&gt;startinsert&lt;/code&gt; issue.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;buffer&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;m-i&amp;gt; TheFunc()&#xA;&#xA;function! TheFunc()&#xA;  if get(g:, 'foo', 1) == 1&#xA;    return &quot;foo&quot;&#xA;  else&#xA;    return &quot;bar&quot;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-08-12T06:39:36.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4279" PostTypeId="1" AcceptedAnswerId="4287" CreationDate="2015-08-12T07:47:08.163" Score="2" ViewCount="1713" Body="&lt;p&gt;I have to edit a bunch of *.txt files for which I want to define a specific filetype. So, in my &lt;code&gt;vimrc&lt;/code&gt;, I add a&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufReadPost bunchOfFiles/*.txt :set ft=bunchOfFilesFT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This reads &lt;code&gt;ftplugin/bunchOfFilesFT.vim&lt;/code&gt; as wanted. The problem is that it also reads &lt;code&gt;ftplugin/text.vim&lt;/code&gt; since there is an according autocmd that was defined in &lt;code&gt;filetype.vim&lt;/code&gt; that comes with a Vim installation.&lt;/p&gt;&#xA;&lt;p&gt;Since my &lt;em&gt;bunchOfFilesFT&lt;/em&gt; filetype should be completely independent of the &lt;em&gt;text&lt;/em&gt; filetype (despite its suffix), I'd rather have Vim not load &lt;code&gt;ftplugin/text.vim&lt;/code&gt;. Is this somehow possible?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="23502" LastEditDate="2022-11-05T07:31:53.483" LastActivityDate="2022-11-05T07:31:53.483" Title="How can I prevent the default loading of ftplugin/text.vim for certain *.txt files?" Tags="|vimrc|filetype|startup|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4280" PostTypeId="1" AcceptedAnswerId="4283" CreationDate="2015-08-12T08:15:44.867" Score="3" ViewCount="5754" Body="&lt;p&gt;I am writing a filetype plugin that will (among other things) &lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/autoload/vimtex/fold.vim&quot; rel=&quot;nofollow&quot;&gt;fold LaTeX documents&lt;/a&gt; by use of a custom foldlevel function. In order to make the folding efficient, I use &lt;code&gt;foldmethod=manual&lt;/code&gt; during editing and I define a function to refresh the folds, something like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RefreshFolds()&#xA;  setlocal foldmethod=expr&#xA;  normal! zx&#xA;  setlocal foldmethod=manual&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A small catch is that this requires me to refresh the folds manually after I open a buffer. In general, I want to refresh the folds manually, but I want them to be refreshed and defined when the buffer is opened. The first thought was that I could simply call &lt;code&gt;Refreshfolds()&lt;/code&gt; during initialization, but for some reason this didn't work. Instead I have found that I can refresh the folds by utilizing a self destructing autocommand as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup init_folds&#xA;  autocmd!&#xA;  autocmd CursorMoved &amp;lt;buffer&amp;gt; call InitFolds()&#xA;augroup END&#xA;&#xA;function! InitFolds()&#xA;  call RefreshFolds()&#xA;  autocmd! init_folds&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works as desired in most cases, but not if I open several buffers in separate tabs with &lt;code&gt;vim -p *.tex&lt;/code&gt;. In this case, it seems the buffers are opened simultaneously, which means the autocommand is only run for one of the buffers before it self destructs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want is to keep &lt;code&gt;foldmethod=manual&lt;/code&gt;, but at the same time I want to ensure that folds are refreshed through &lt;code&gt;RefreshFolds()&lt;/code&gt; after a buffer is opened. Does anyone know how to either fix the above approach so that it works when buffers are loaded simultaneously, or of a different approach that does not have the same problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: This problem comes from &lt;a href=&quot;https://github.com/lervag/vimtex/issues/52#issuecomment-130080829&quot; rel=&quot;nofollow&quot;&gt;this Github issue&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2015-08-12T21:00:28.460" LastActivityDate="2015-08-12T21:04:28.173" Title="How can I run a function once after the buffer has been completely loaded?" Tags="|autocmd|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="4281" PostTypeId="2" ParentId="4269" CreationDate="2015-08-12T09:52:33.287" Score="1" Body="&lt;p&gt;While I didn't achieve to trigger the completion from the command-line mode you can work this like this :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Prepare your command inside insert mode (or at least the part you cannot create from command-line mode). Yank it and insert it inside your command using &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; and the &lt;code&gt;&quot;&lt;/code&gt; register like so : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Insert Mode &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tec&amp;lt;Tab&amp;gt;yiw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Commande-line Mode &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/&amp;lt;C-r&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In command-line mode, there are only a set of word you can expand, for example : Command names, Tags, File names, ... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See : &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#cmdline-completion&quot; rel=&quot;nofollow&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#cmdline-completion&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-08-14T14:58:13.883" LastActivityDate="2015-08-14T14:58:13.883" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4282" PostTypeId="2" ParentId="4148" CreationDate="2015-08-12T10:41:16.333" Score="6" Body="&lt;p&gt;I wrote a Join plugin, can do what you want, and a lot more.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Except for all features provided by the build-in :join command, Join&#xA;  can:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Join lines with separator (string)&lt;/li&gt;&#xA;  &lt;li&gt;Join lines with or without trimming the leading/trailing whitespaces&lt;/li&gt;&#xA;  &lt;li&gt;Join lines with negative count (backwards join)&lt;/li&gt;&#xA;  &lt;li&gt;Join lines in reverse&lt;/li&gt;&#xA;  &lt;li&gt;Join lines and keep joined lines (without removing joined lines)&lt;/li&gt;&#xA;  &lt;li&gt;Join lines with any combinations of above options&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;more details and screenshots:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/sk1418/Join&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/sk1418/Join&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1569" LastActivityDate="2015-08-12T10:41:16.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4283" PostTypeId="2" ParentId="4280" CreationDate="2015-08-12T10:57:41.843" Score="2" Body="&lt;p&gt;The problem was that when the buffers are loaded simultaneously, then the autocommand group was deleted by one buffer before it was applied on the other buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve the issue, I modified the code so that each buffer has a unique autocommand group name. I did this with a script local counter and by saving the name to a buffer local variable. I delete the variable when it is no longer needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For completeness, here is a working example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:id = get(s:, 'id', 0) + 1&#xA;let b:my_augroup = 'init_folds_' . s:id&#xA;execute 'augroup' b:my_augroup&#xA;  autocmd!&#xA;  autocmd CursorMoved &amp;lt;buffer&amp;gt; call InitFolds()&#xA;augroup END&#xA;&#xA;function! InitFolds()&#xA;  call RefreshFolds()&#xA;  execute 'autocmd!' b:my_augroup&#xA;  execute 'augroup!' b:my_augroup&#xA;  unlet b:my_augroup&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2015-08-12T21:04:28.173" LastActivityDate="2015-08-12T21:04:28.173" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4284" PostTypeId="1" AcceptedAnswerId="4301" CreationDate="2015-08-12T11:27:33.297" Score="4" ViewCount="2797" Body="&lt;p&gt;I try to create a mapping for &lt;code&gt;Alt &amp;lt;&lt;/code&gt; and &lt;code&gt;Alt &amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;M-&amp;lt;&amp;gt; foo-bar-baz&#xA;inoremap &amp;lt;M-&amp;gt;&amp;gt; baz-bar-foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't work, most probably because &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; are themselves characters used to define the mapping. So, how can I create such a mapping?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="23502" LastEditDate="2022-11-05T09:20:03.533" LastActivityDate="2022-11-05T09:20:03.533" Title="How can I map Alt-&lt; or Alt-&gt;?" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4285" PostTypeId="1" AcceptedAnswerId="4289" CreationDate="2015-08-12T11:29:39.023" Score="2" ViewCount="1860" Body="&lt;p&gt;Given the following example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aa&#xA;aa&#xA;bb&#xA;bb&#xA;cc&#xA;dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to replace two-line match (&lt;code&gt;bb\nbb&lt;/code&gt;) with its first matching line (&lt;code&gt;bb&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;these two-lines can be matched by: &lt;code&gt;/bb\_.\{-}bb&lt;/code&gt; (as per: &lt;a href=&quot;http://vim.wikia.com/wiki/Search_across_multiple_lines&quot; rel=&quot;nofollow&quot;&gt;Search across multiple lines&lt;/a&gt;),&lt;/li&gt;&#xA;&lt;li&gt;I can replace two-line match with hardcoded one-line string: &lt;code&gt;%s/bb\_.\{-}bb/foo/g&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I can't use first backreference (&lt;code&gt;\1&lt;/code&gt;) instead of hardcoded string, so when using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/bb\ze\_.\{-}bb/\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as result of just adding &lt;code&gt;\ze&lt;/code&gt; and &lt;code&gt;\1&lt;/code&gt; to the previous example, I expect that this two-line pattern would be replaced by its backreference value (so &lt;code&gt;bb\nbb&lt;/code&gt; becomes &lt;code&gt;bb&lt;/code&gt;), but instead it removes the 1st line and not touching the 2nd. (so &lt;code&gt;bb\nbb&lt;/code&gt; becomes: &lt;code&gt;\nbb&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any idea why the following attempt doesn't work? I don't want to join and remove the second line, I'd like to understand what's the problem and what's the correct way of doing it.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-08-12T11:38:47.210" LastActivityDate="2015-08-12T12:39:16.370" Title="How to replace two-line match with its first backreference pattern?" Tags="|regular-expression|substitute|multiple-lines|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4286" PostTypeId="2" ParentId="4148" CreationDate="2015-08-12T11:42:04.733" Score="7" Body="&lt;p&gt;Here is example using external command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!paste -sd,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;%!&lt;/code&gt; replaces current buffer (content of the file) with the command: &lt;code&gt;paste -sd,&lt;/code&gt; (parameters &lt;code&gt;-s&lt;/code&gt; is used to join multiple lines and &lt;code&gt;-d&lt;/code&gt; sets the delimiter character to &lt;code&gt;,&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-08-12T16:04:19.440" LastActivityDate="2015-08-12T16:04:19.440" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4287" PostTypeId="2" ParentId="4279" CreationDate="2015-08-12T11:44:39.990" Score="3" Body="&lt;p&gt;It is a good idea to begin plugins, colorschemes, etc., by checking that it has not already been run for the current buffer. This prevents running the plugin again if it's not necessary and it gives the user the ability to easily disable it. For an ftplugin this usually looks like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;b:did_ftplugin&quot;)&#xA;  finish&#xA;endif&#xA;let b:did_ftplugin = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your &lt;code&gt;text.vim&lt;/code&gt; ftplugin does this, you can prevent it loading by setting the &lt;code&gt;b:did_ftplugin&lt;/code&gt; variable before &lt;code&gt;text.vim&lt;/code&gt; is loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, Vim's &lt;code&gt;ftplugin/vim.vim&lt;/code&gt; does a check like that. So I put the above snippet in &lt;code&gt;ftplugin/jjvim.vim&lt;/code&gt; and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufReadPost *.vim :set ft=jjvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my vimrc. Then I start a new vim session and edit &lt;code&gt;ftplugin/jjvim.vim&lt;/code&gt; again, and now only that ftplugin is loaded, not Vims &lt;code&gt;vim.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So make sure that your &lt;code&gt;text.vim&lt;/code&gt; contains a check like above, and make sure you set &lt;code&gt;b:did_ftplugin&lt;/code&gt; before &lt;code&gt;text.vim&lt;/code&gt; is loaded, for instance from your &lt;code&gt;bunchofFilesFT.vim&lt;/code&gt;, and you should be fine.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="15" LastEditDate="2015-08-12T12:22:44.310" LastActivityDate="2015-08-12T12:22:44.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4288" PostTypeId="1" AcceptedAnswerId="4299" CreationDate="2015-08-12T12:04:31.803" Score="5" ViewCount="646" Body="&lt;p&gt;Is it possible to show every n relative line numbers? So for example, I can see a a (+/-) 10, 20, 30... instead of a value on every line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there's no current way to do it, is it possible to create? i.e. can a plugin programmically change the line numbers shown?&lt;/p&gt;&#xA;" OwnerUserId="2512" LastActivityDate="2015-08-14T10:38:55.370" Title="Show only every n relative line number" Tags="|line-numbers|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4289" PostTypeId="2" ParentId="4285" CreationDate="2015-08-12T12:39:16.370" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I can't use first backreference (&lt;code&gt;\1&lt;/code&gt;) instead of hardcoded string&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, you haven't captured anything in the search so &lt;code&gt;\1&lt;/code&gt; has no value in the replacement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use a matched text later in the pattern, as a back-reference, as well as in the replacement.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(.*\)\n\1/\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows you to find a line (&lt;code&gt;\(.*\)&lt;/code&gt;) which has a duplicate line immediately following it (&lt;code&gt;\n\1&lt;/code&gt;) and remove that duplicate by replacing the search with just the grouped match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this can be simplified by simply starting the match after the initial line and removing all the matched content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(.*\)\zs\n\1//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-08-12T12:39:16.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4290" PostTypeId="1" AcceptedAnswerId="4291" CreationDate="2015-08-12T14:32:50.627" Score="27" ViewCount="7627" Body="&lt;p&gt;I am trying to figure out how to navigate windows little quicker, so I would like to map the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:nmap &amp;lt;silent&amp;gt; &amp;lt;C-F&amp;gt; :wincmd f&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is this remaps the &lt;code&gt;^f&lt;/code&gt; (lower-case &lt;code&gt;f&lt;/code&gt;) mapping, which is page down.  Is there any way to remap only &lt;code&gt;^F&lt;/code&gt; (upper-case &lt;code&gt;F&lt;/code&gt;) and leave the &lt;code&gt;^f&lt;/code&gt; as it was?&lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="51" LastEditDate="2015-08-12T15:09:19.170" LastActivityDate="2020-09-23T08:03:29.153" Title="Can I map a Ctrl + upper-case letter separately from Ctrl + lower-case letter?" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4291" PostTypeId="2" ParentId="4290" CreationDate="2015-08-12T14:55:33.163" Score="35" Body="&lt;p&gt;Mapping &lt;code&gt;&amp;lt;C-F&amp;gt;&lt;/code&gt; (&lt;code&gt;Ctrl+letter&lt;/code&gt;) is always the same as mapping &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; (&lt;code&gt;Ctrl+Shift+letter&lt;/code&gt;). You can't map one without the other.&lt;/p&gt;&#xA;&lt;p&gt;The root of the problem is that Vim reads characters from the terminal, which sends &lt;code&gt;^F&lt;/code&gt; (ASCII code &lt;code&gt;0x06&lt;/code&gt;) for both &lt;code&gt;Ctrl+f&lt;/code&gt; and &lt;code&gt;Ctrl+Shift+f&lt;/code&gt;; Vim has no way of knowing whether you pressed the Shift key. &lt;a href=&quot;https://bestasciitable.com/#context&quot; rel=&quot;noreferrer&quot;&gt;This site provides some more information about terminals and control characters&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In theory, this &lt;em&gt;could&lt;/em&gt; be done with gVim, since most (or all?) graphic environments send much more detailed key events. But unfortunately, gVim operates much like a terminal emulator, and can't distinguish between &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-F&amp;gt;&lt;/code&gt; either (this was perhaps a design decision for Vim-gVim compatibility).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Possible solutions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You could configure your terminal emulator to send a different code to Vim when you press &lt;code&gt;Ctrl+Shift+f&lt;/code&gt;. For example, for xterm you could do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;XTerm*VT100.translations: #override \n\&#xA;    Ctrl ~Meta Shift &amp;lt;Key&amp;gt;f: string(0x1b) string(&amp;quot;[24;6~&amp;quot;)\n\&#xA;    Ctrl ~Meta Shift &amp;lt;Key&amp;gt;r: string(0x1b) string(&amp;quot;[23;6~&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will send the code for &lt;code&gt;&amp;lt;C-S-F12&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-S-F11&amp;gt;&lt;/code&gt; to Vim, which you can pick up with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-S-F12&amp;gt; :echo 'ctrl+F pressed!'&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-S-F11&amp;gt; :echo 'ctrl+R pressed!'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Note that you &lt;em&gt;can&lt;/em&gt; map &lt;code&gt;Alt+Shift+letter&lt;/code&gt;, since the terminal sends a different code for those: &lt;code&gt;&amp;lt;Esc&amp;gt;f&lt;/code&gt; (&lt;code&gt;0x1b0x66&lt;/code&gt;) or &lt;code&gt;&amp;lt;Esc&amp;gt;F&lt;/code&gt; (&lt;code&gt;0x1b0x46&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;NeoVim has, as far as I can find, not fixed this problem except for a few cases such as &lt;code&gt;Ctrl+Shift+Enter&lt;/code&gt; and &lt;code&gt;Ctrl+Shift+Tab&lt;/code&gt;, but it's possible that this feature will be added in the future.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-09-23T08:03:29.153" LastActivityDate="2020-09-23T08:03:29.153" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4292" PostTypeId="1" AcceptedAnswerId="4377" CreationDate="2015-08-12T15:14:37.757" Score="5" ViewCount="1812" Body="&lt;p&gt;I am writing a vimscript function which should keep in a consistent state a &quot;home made buffer manager&quot;. The idea is that I want to keep a trace of my buffers in the tabs they were open in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &quot;buffer manager&quot; simply is a dictionary which has the numbers of the tabs as keys and lists of buffers numbers as values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To add the different buffers to this dictionary I created the following autocommand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufEnter * call AddBufferToTab()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then I have my function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddBufferToTab()&#xA;    let newBufNr = bufnr(&quot;%&quot;) &#xA;&#xA;    &quot; create an entry for the current tab if necessary&#xA;    if !has_key(g:BuffersManager, tabpagenr())&#xA;        let  g:BuffersManager[tabpagenr()] = []&#xA;    endif&#xA;&#xA;    &quot; Add the buffer to the tab&#xA;    if buflisted(newBufNr) &amp;amp;&amp;amp; index(g:BuffersManager[tabpagenr()], newBufNr) == -1&#xA;        call add (g:BuffersManager[tabpagenr()],newBufNr)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When vim enters a buffer the function is called, an empty list is created if the tab wasn't already managed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I test if the buffer is listed by &lt;code&gt;:ls&lt;/code&gt; with &lt;code&gt;buflisted(newBufNr)&lt;/code&gt; and if the buffer is already in the list of the tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is important to note that the first test seems to work: I don't want to add buffers which are not listed by &lt;code&gt;:ls&lt;/code&gt; and when I open an help buffer for example, the buffer is not added&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function seems to work properly excepted for one use case:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open NERDTree with &lt;code&gt;:NERDTree&lt;/code&gt; or &lt;code&gt;:NERDTreeToggle&lt;/code&gt; the function doesn't seems to be executed &lt;em&gt;(at least the debug &lt;code&gt;echom&lt;/code&gt; that I used never appeared)&lt;/em&gt; and the buffer still end added to the manager.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that when I add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echom &quot;ADD &quot; . bufnr(&quot;%&quot;) . &quot;  &quot; . bufname(&quot;%&quot;) . &quot;  &quot; . buflisted(bufnr(&quot;%&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To the function the informations seems to be the good ones (the ones of the currently entered buffer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also checked that NERDTree buffer have their property &lt;code&gt;buflisted&lt;/code&gt; to 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been working on this problem for several days now and I really can't figure out what's happening. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Why NERDTree buffers are added to the dictionary when the function is meant to ignore &lt;code&gt;nobuflisted&lt;/code&gt; buffers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; If ones wants a big picture of the problem the function is a part of a plug-in I'm developing and which is available on &lt;a href=&quot;https://github.com/statox/bettertabs.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 2&lt;/strong&gt; Of course if someone needs any additional information I'll gladly add them to this question, ask in the comments.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Additional information&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed the comment of @VanLaser and splitted the &lt;code&gt;if&lt;/code&gt; condition and based my test also on the name of the buffer. I also added some debugging message, here is the function in &quot;debugging state&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddBufferToTab()&#xA;    let newBufNr = bufnr(&quot;%&quot;) &#xA;&#xA;    &quot; create an entry for the current tab if necessary&#xA;    if !has_key(g:BuffersManager, tabpagenr())&#xA;        let  g:BuffersManager[tabpagenr()] = []&#xA;    endif&#xA;&#xA;    &quot; Get conditions to add the tab&#xA;    let isListed = buflisted(newBufNr)&#xA;&#xA;    let isAlreadyInManager = 1&#xA;    if (index(g:BuffersManager[tabpagenr()], newBufNr) == -1)&#xA;        let isAlreadyInManager = 0&#xA;    endif&#xA;&#xA;    let isNERDTreeBuffer = 0&#xA;    if (bufname(&quot;%&quot;) =~ &quot;NERD_Tree_&quot;)&#xA;        let isNERDTreeBuffer = 1&#xA;    endif&#xA;&#xA;    &quot; Debugging messages&#xA;    echom bufname(&quot;%&quot;)&#xA;    if (isListed)&#xA;        echom &quot;is Listed&quot;&#xA;    else &#xA;        echom &quot;is not Listed&quot;&#xA;    endif&#xA;&#xA;    if (isAlreadyInManager)&#xA;        echom &quot;is AlreadyInManager&quot;&#xA;    else &#xA;        echom &quot;is not AlreadyInManager&quot;&#xA;    endif&#xA;&#xA;    if (isNERDTreeBuffer)&#xA;        echom &quot;is NERDTreeBuffer&quot;&#xA;    else &#xA;        echom &quot;is not NERDTreeBuffer&quot;&#xA;    endif&#xA;    echom &quot;=========&quot;&#xA;&#xA;    &quot; Add the buffer to the tab&#xA;    if isListed &amp;amp;&amp;amp; !isAlreadyInManager &amp;amp;&amp;amp; !isNERDTreeBuffer&#xA;        call add (g:BuffersManager[tabpagenr()],newBufNr)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am sure that I don't have a call to the &lt;code&gt;add&lt;/code&gt; function anywhere else than in this function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then followed this workflow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;sourcing the file, the buffer manager is empty&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:e %&lt;/code&gt; (add the current file to the manager)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:e $MYVIMRC&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:NERDTree&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;select the first file &lt;code&gt;betterTabs.vim&lt;/code&gt; in NERDTree.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And here is the log I had:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bJQx5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bJQx5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see the opening of NerdTree doesn't seem to trigger the function (since I don't have any message about it in the log) BUT when I output the content of my dictionnary I get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4BOne.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4BOne.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I said I don't have any other call to &lt;code&gt;add&lt;/code&gt; in my whole file (I gave sooner in the post the link to the github repo if anyone wants to check).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand how the buffer can be added when it doesn't even trigger the function.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;More infos to follow the investigations of @VanLaser in the comments&lt;/strong&gt; (many thanks to him):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, to quote &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#:ls&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ls&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Each buffer has a unique number.  That number will not change,&#xA;  so you can always go to a specific buffer with &lt;code&gt;:buffer N&lt;/code&gt; or&#xA;  &lt;code&gt;N CTRL-^&lt;/code&gt;, where N is the buffer number.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So in theory if I get the number of the buffer I'm using it shouldn't change in the future. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I added the following lines at the very beginning of my function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echom bufnr('%')&#xA;echom expand('&amp;lt;abuf&amp;gt;')&#xA;&#xA;if bufnr('%') != expand('&amp;lt;abuf&amp;gt;')&#xA;    echom &quot;RETURN&quot;&#xA;    return&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and with the same workflow I get the same results, also I checked that the buffer numbers was the good ones:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the output of &lt;code&gt;messages&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KU0Tz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KU0Tz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;ls!&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UWUhH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UWUhH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally the content of my dictionary:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/o0dim.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/o0dim.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see it seems that the numbers are correctly returned, but once again NERDTree is launched but doesn't trigger the function.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;More infos to follow the comments of @lcd047&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I changed the autocommand to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufEnter * call AddBufferToTab(expand('&amp;lt;abuf&amp;gt;'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function prototype to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddBufferToTab(bufNumber)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I replaced &lt;code&gt;let newBufNr = bufnr(&quot;%&quot;)&lt;/code&gt; with &lt;code&gt;let newBufNr = a:bufNumber&lt;/code&gt; and the behavior gets even weirder:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added after the assignation of &lt;code&gt;newBufNr&lt;/code&gt; the following debugging echos:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echom newBufNr&#xA;echom bufnr('%')&#xA;echom expand('&amp;lt;abuf&amp;gt;')&#xA;echom a:bufNumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For every buffers they show the same number (so using &lt;code&gt;&amp;lt;abuf&amp;gt;&lt;/code&gt; in the autocommand doesn't make a difference in the cases I tried). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But&lt;/strong&gt; it get even weirder because then every buffers appears as not listed: for a reason that I don't understand &lt;code&gt;buflisted(expand('&amp;lt;abuf&amp;gt;'))&lt;/code&gt; returns 0 for every buffers.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt; I'm sorry for the length of this post I'm just trying to give as much informations as possible because I really absolutely don't understand what's happening there.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-16T19:53:45.533" LastActivityDate="2015-08-17T13:43:11.583" Title="Why `NERDTree` doesn't trigger the autocommand `BufEnter`?" Tags="|vimscript|plugin-nerdtree|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="4294" PostTypeId="1" CreationDate="2015-08-12T16:31:56.683" Score="3" ViewCount="287" Body="&lt;p&gt;I've recently delved into taking an existing colorscheme and customizing it to my liking. While doing this however, I found there was a highlight option for special comments and I'm not sure exactly what that refers to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the exact line if it helps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi SpecialComment ctermfg=66 gui=bold guifg=#5f8787&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25" LastActivityDate="2015-08-12T18:06:13.427" Title="What does Special Comment refer to in reference to a colorscheme?" Tags="|colorscheme|comments|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4295" PostTypeId="2" ParentId="4148" CreationDate="2015-08-12T16:58:41.303" Score="2" Body="&lt;p&gt;You can record a macro to join lines with a comma. This is useful if it's a rare or one-off task, and you can't remember how to write a substitute command and regular expression to perform the task, but you do remember how to record and run a macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To join lines with a comma, type &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; to record the macro in register &lt;code&gt;j&lt;/code&gt;. Then you can run the macro with &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;. You can re-run the macro with &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;, which saves on typing when running it multiple times in a row—you can even just hold down &lt;kbd&gt;@&lt;/kbd&gt; until you get near the end of the lines you want to join. You can also use a numeric prefix on &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; or &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt; to repeat it a set number of times. This leaves leading and trailing space intact, so there will be spaces before or after the comma if your original text had spaces there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To join with a comma and a space, insert &lt;kbd&gt;Space&lt;/kbd&gt; between the &lt;kbd&gt;,&lt;/kbd&gt; and &lt;kbd&gt;Esc&lt;/kbd&gt; when recording the macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;kbd&gt;J&lt;/kbd&gt; instead of &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt; when recording the macro, which will usually join lines with a comma and a space. However, if the current line has trailing whitespace, the comma will appear after the whitespace without a space following it. Also, it does not include the space if the next line starts with &lt;code&gt;)&lt;/code&gt;, and it puts two spaces after the comma if &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27joinspaces%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;joinspaces&lt;/code&gt;&lt;/a&gt; is set and the current line ends with &lt;code&gt;.&lt;/code&gt;, &lt;code&gt;!&lt;/code&gt;, or &lt;code&gt;?&lt;/code&gt;. These caveats are described under &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#J&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help J&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2680" LastEditorUserId="2680" LastEditDate="2015-08-12T17:07:45.727" LastActivityDate="2015-08-12T17:07:45.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4296" PostTypeId="2" ParentId="4294" CreationDate="2015-08-12T18:06:13.427" Score="3" Body="&lt;p&gt;&lt;code&gt;SpecialComment&lt;/code&gt; is not one of the default highlighting groups (see &lt;code&gt;:help highlighting-groups&lt;/code&gt;). It is a &lt;em&gt;suggested&lt;/em&gt; group name for &quot;special things inside a comment&quot; (see &lt;code&gt;:help group-name&lt;/code&gt;) (a minor group).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What constitutes &quot;special&quot; is left open to interpretation; scanning the default runtime files, it's generally used to identify things like Doxygen tags inside comments, header or similar notational structure items inside comments, and so on. The specific meaning varies for the individual syntax file, basically.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-08-12T18:06:13.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4297" PostTypeId="1" CreationDate="2015-08-12T19:29:06.163" Score="2" ViewCount="110" Body="&lt;p&gt;My leader is &lt;code&gt;,&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = ','&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now, I want to map &lt;code&gt;#&lt;/code&gt; to find previous match (when using &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt;, &lt;code&gt;T&lt;/code&gt;), I try this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap # ,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But nothing happens when I use &lt;code&gt;#&lt;/code&gt;, obviously something is wrong. What would be the correct way to create the mapping I want?&lt;/p&gt;&#xA;&lt;p&gt;UPDATE: with vim -u NONE it works fine for me too, so it must be some setting/plugin I use. Strange, cause&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;map #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;returns this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;n #       * ,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;the same thing that is returned in vim -u NONE, so it sounds like the map is ok...Strange&lt;/p&gt;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="590" LastEditorUserId="23502" LastEditDate="2022-11-05T07:31:08.293" LastActivityDate="2022-11-05T07:31:08.293" Title="How to map # to , when `,` is my leader?" Tags="|key-bindings|" AnswerCount="0" CommentCount="4" ClosedDate="2016-03-10T22:09:54.787" ContentLicense="CC BY-SA 4.0" />
  <row Id="4298" PostTypeId="1" CreationDate="2015-08-12T21:26:55.190" Score="11" ViewCount="3939" Body="&lt;p&gt;My vimtutor is in portuguese. I don't know why, because my Windows OS is in english, so as everything else. I don't remember to have chosen &quot;portuguese&quot; anywhere in the vim installing process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I change it to english?&lt;/p&gt;&#xA;" OwnerUserId="3160" LastEditorUserId="51" LastEditDate="2015-08-13T08:11:43.307" LastActivityDate="2019-04-04T22:50:49.397" Title="Change vimtutor language" Tags="|microsoft-windows|help-system|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4299" PostTypeId="2" ParentId="4288" CreationDate="2015-08-12T21:38:00.333" Score="4" Body="&lt;p&gt;I made a little script that does nearly what you do.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Explanations&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The core concept behind it comes directly from the &lt;a href=&quot;https://github.com/kshenoy/vim-signature&quot; rel=&quot;nofollow&quot;&gt;vim-signature&lt;/a&gt; plugin. Here is a step-by-step walkthrough : &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Remove all previous signs from the sign bar&lt;/li&gt;&#xA;&lt;li&gt;Build a list of the lines you want to show in the sign bar&lt;/li&gt;&#xA;&lt;li&gt;For each line, create a new sign with a unique id (based on current buffer and line number)&lt;/li&gt;&#xA;&lt;li&gt;For each line, display the sign (the text of the sign will be the current line) &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The code below works as a proof of concept, but I wouldn't use is. You will see if you try it that it gets all flickering when you move quickly. I think the reason behind it is that the sign bar is not intended to quickly change over time.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Improvements&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;There are also many optimisations I though of but didn't have the time to write : &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create the list from the beginning (as the file lenght will not change a lot very quickly) and reload the list only when needed.&lt;/li&gt;&#xA;&lt;li&gt;Create 10 lists with all signs created. The cursor move will only change the current list displayed.&lt;/li&gt;&#xA;&lt;li&gt;Call refresh only on row change (not on every cursor change)&lt;/li&gt;&#xA;&lt;li&gt;Obviously it display only numbers (not relative), but you cannot display more than two characters into the sign bar ...&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;Show me the code !&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;There you go : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; List of all displayed lines&#xA;let b:lines = []&#xA;&#xA;&quot; Add a line to the signbar&#xA;function! AddLine(lnum)&#xA;  &quot; create a unique id to the current sign&#xA;  let l:id = a:lnum * 1000 + bufnr('%')&#xA;&#xA;  &quot; Create a new sign and place it&#xA;  execute 'sign define Signature_' . l:id . ' text=' . a:lnum&#xA;  execute 'sign place ' . l:id . ' line=' . a:lnum . ' name=Signature_' . l:id . ' buffer=' . bufnr('%')&#xA;endfunction&#xA;&#xA;function! Remove(lnum)&#xA;  &quot; Find the sign based on it's id and remove it&#xA;  let l:id = a:lnum * 1000 + bufnr('%')&#xA;  silent! execute 'sign unplace ' . l:id&#xA;endfunction&#xA;&#xA;&quot; Create a list of all lines on the document to display&#xA;function! GetLines(currentLine) abort&#xA;  let l:c = a:currentLine % 10&#xA;&#xA;  while l:c &amp;lt;= line('$')&#xA;    call add(b:lines, l:c)&#xA;    let l:c += 10&#xA;  endwhile&#xA;endfunction&#xA;&#xA;&quot; Get called on every cursor move, reload the signs&#xA;function! Refresh()&#xA;  for j in b:lines&#xA;      call Remove (j)&#xA;  endfor&#xA;  let b:lines = []&#xA;&#xA;  call GetLines(line('.'))&#xA;  for j in b:lines&#xA;      call AddLine(j)&#xA;  endfor&#xA;endfunction&#xA;&#xA;&quot; Call the refresh method once on every cursor move&#xA;augroup CursorMove&#xA;  autocmd!&#xA;  autocmd CursorMoved * call Refresh()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I made a &lt;a href=&quot;https://github.com/nobe4/relative-n.vim&quot; rel=&quot;nofollow&quot;&gt;git repo&lt;/a&gt; for it if you want to contribute.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-08-12T21:38:00.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4300" PostTypeId="1" CreationDate="2015-08-13T00:29:36.523" Score="16" ViewCount="3658" Body="&lt;p&gt;I recorded a simple macro and replayed it on following lines, but it seems replay speed is very slow (handle a very few lines per second). Is this expected and is there a way to improve such speed?&lt;/p&gt;&#xA;" OwnerUserId="477" LastActivityDate="2021-07-23T08:49:10.260" Title="Improve macro replay speed?" Tags="|macro|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4301" PostTypeId="2" ParentId="4284" CreationDate="2015-08-13T04:25:58.170" Score="3" Body="&lt;p&gt;As said in my comment, the &lt;code&gt;&amp;lt;Alt-X&amp;gt;&lt;/code&gt; combination insert a special character. So instead of mapping to &lt;code&gt;&amp;lt;Alt-X&amp;gt;&lt;/code&gt;, you can map it to the special character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;M-&amp;lt;&amp;gt; foo-bar-baz&#xA;inoremap &amp;lt;M-&amp;gt;&amp;gt; baz-bar-foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap ¯ foo-bar-baz&#xA;inoremap ˘ baz-bar-foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note : This was working on a Mac, on iterm2, tmux and macvim. The behaviour may change depending the configuration ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit :  You can look at those posts :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/5379837/is-it-possible-to-mapping-alt-hjkl-in-insert-mode&quot;&gt;https://stackoverflow.com/questions/5379837/is-it-possible-to-mapping-alt-hjkl-in-insert-mode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/7501092/can-i-map-alt-key-in-vim&quot;&gt;https://stackoverflow.com/questions/7501092/can-i-map-alt-key-in-vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-13T04:25:58.170" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4302" PostTypeId="1" AcceptedAnswerId="4304" CreationDate="2015-08-13T06:14:18.293" Score="16" ViewCount="11729" Body="&lt;p&gt;I use &lt;code&gt;list&lt;/code&gt; and &lt;code&gt;listchars&lt;/code&gt; to show my whitespace, but the code style I adhere to uses tabs. Seeing &lt;code&gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;^I&lt;/code&gt; for all of my tabs is nauseating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I keep all of my existing list characters but with a blank tab character?&lt;/p&gt;&#xA;" OwnerUserId="3164" LastEditorUserId="10604" LastEditDate="2022-01-25T14:21:28.267" LastActivityDate="2022-01-25T14:21:28.267" Title="How can I show tabs as spaces instead of ^I or CTRL-I?" Tags="|tab-characters|list|listchars|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4303" PostTypeId="2" ParentId="4302" CreationDate="2015-08-13T06:22:42.200" Score="3" Body="&lt;p&gt;Turns out non-breaking spaces work just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per &lt;a href=&quot;https://stackoverflow.com/a/2228012/510036&quot;&gt;this answer&lt;/a&gt;, the utf-8 sequence is &lt;code&gt;&quot;\xc2\xa0&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I'm on a mac, I simply did &lt;code&gt;echo -en &quot;\xc2\xa0&quot; | pbcopy&lt;/code&gt; and then added them to my &lt;em&gt;.vimrc&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set listchars=tab:[2p],...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;[2p]&lt;/code&gt; pasted the clipboard twice. The result ended up being&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set listchars=tab:&amp;lt;nbsp&amp;gt;&amp;lt;nbsp&amp;gt;,...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which correctly caused tabs to show up as simple whitespace.&lt;/p&gt;&#xA;" OwnerUserId="3164" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-13T06:22:42.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4304" PostTypeId="2" ParentId="4302" CreationDate="2015-08-13T07:32:11.567" Score="29" Body="&lt;p&gt;&lt;code&gt;'listchars'&lt;/code&gt; takes two characters for &lt;code&gt;tab&lt;/code&gt; so you can simply use two regular spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set listchars=tab:\ \ ,trail:·,eol:¬,nbsp:_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="51" LastEditDate="2017-05-24T23:25:59.583" LastActivityDate="2017-05-24T23:25:59.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4305" PostTypeId="1" CreationDate="2015-08-13T11:47:08.523" Score="18" ViewCount="2502" Body="&lt;p&gt;In a vimscript-function, I need to assign a matched string to a variable &lt;code&gt;l:matched&lt;/code&gt; after calling &lt;code&gt;search()&lt;/code&gt; and I am wondering if there is a shorter way than what I am currently doing:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let l:pattern   = '\v^Foo: \zs.*'&#xA;let l:line      = search(l:pattern)&#xA;let l:line_text = getline(l:line)&#xA;let l:matched   = matchstr(l:line, l:pattern)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Ideally, I'd want something like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let l:matched = search_text(l:pattern)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;without resorting to &lt;code&gt;getline()&lt;/code&gt;. Is there such a vim function that I seem unable to find?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="23502" LastEditDate="2022-11-05T07:29:56.827" LastActivityDate="2022-11-05T07:29:56.827" Title="Is it possible to get the matched string after calling :search()?" Tags="|vimscript|search|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4306" PostTypeId="2" ParentId="4305" CreationDate="2015-08-13T13:21:32.523" Score="8" Body="&lt;p&gt;Since the cursor is placed on the 1st letter of the match, you could probably do a &lt;code&gt;:normal! y$&lt;/code&gt; after the search, and get the register content in your local variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach, which I think would work here very well, would be to use &lt;code&gt;:substitute&lt;/code&gt; with the &lt;code&gt;n&lt;/code&gt; flag (i.e. without an &lt;em&gt;actual&lt;/em&gt; substitution):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ActOn(match)&#xA;    &quot; do something with the match&#xA;    echo a:match&#xA;    &quot; [...]&#xA;endfunction&#xA;&#xA;function! FindAndCall(regex, func_name)&#xA;    execute ':keeppatterns %s/' . a:regex . '/\=' . a:func_name. '(submatch(0))/gn'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and which you call like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call FindAndCall('^Foo: \zs.*', 'ActOn')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This practically makes &lt;code&gt;ActOn&lt;/code&gt; a callback function - it will be evaluated for each match.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2017-08-08T09:20:18.750" LastActivityDate="2017-08-08T09:20:18.750" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4307" PostTypeId="1" AcceptedAnswerId="4312" CreationDate="2015-08-13T15:26:09.290" Score="29" ViewCount="25423" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/terryma/vim-multiple-cursors&quot; rel=&quot;noreferrer&quot;&gt;vim-multiple-cursors&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to put cursors exactly where I want. For example (&lt;code&gt;[x]&lt;/code&gt; are the cursor positions):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet[1], consectetur adipiscing elit, &#xA;sed do eiusmod tempor incididunt ut labore et dolore magna[2]&#xA;aliqua.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;em&gt;Sublime Text&lt;/em&gt; I would normally put the first cursor, then go to the next position with the arrows keys and put the second one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there something similar in VIM?&lt;/strong&gt; &#xA;With this plugin or another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following a comment, my interest in doing so appeared when trying to write&lt;br&gt;&#xA;&lt;code&gt;\section[My first section in this book]{My first section in this book}&lt;/code&gt;&lt;br&gt;&#xA;in a &lt;code&gt;.tex&lt;/code&gt; file. My first reaction was to write &lt;code&gt;\section[]{}&lt;/code&gt; and then put two cursors in order to write the same thing inside the &lt;code&gt;[]&lt;/code&gt; and &lt;code&gt;{}&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other example would be to add &lt;code&gt;_someStuff&lt;/code&gt; after several different variables names. For example, turn this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable1 = 2&#xA;my_variable2 = 12&#xA;var3 = 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable1_someStuff = 2&#xA;my_variable2_someStuff = 12&#xA;var3_someStuff = 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With multiple cursors I can do by selecting a column cursor and then going to the end of the word, then inserting, etc. But I guess I would be easy to choose exactly where I want the cursors to be.&lt;/p&gt;&#xA;" OwnerUserId="2977" LastEditorUserId="2977" LastEditDate="2015-08-13T19:26:43.407" LastActivityDate="2023-01-20T16:30:08.183" Title="Multiple cursors at desired location" Tags="|cursor-motions|cursor|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4308" PostTypeId="2" ParentId="4298" CreationDate="2015-08-13T18:49:12.410" Score="8" Body="&lt;h2&gt;1'st method&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Run &lt;code&gt;vimtutor&lt;/code&gt; (from command line) with 2 letter language code like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vimtutor en&lt;/code&gt; (for English)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vimtutor pt&lt;/code&gt; (for Portuguese)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;etc...&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;2'nd method&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Open tutor with different language with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim /usr/share/vim/vim74/tutor/tutor&lt;/code&gt; (for English)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim /usr/share/vim/vim74/tutor/tutor.pt&lt;/code&gt; (for Portuguese)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;etc...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The same default path applies to Cygwin on Windows. You may want to change &lt;code&gt;vim74&lt;/code&gt; part if you have different version)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this method you may actually want to copy the file somewhere else first and then open the copy, because you are going to modify it.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;3'rd method&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Vimtutor opens in Portuguese by default because you probably have some environmental variable set to Portugese like: &lt;code&gt;LC_ALL&lt;/code&gt;, &lt;code&gt;LANG&lt;/code&gt;, &lt;code&gt;LANGUAGE&lt;/code&gt; (check it with &lt;code&gt;env | grep -P 'LC_ALL|LANG'&lt;/code&gt;. You may want to change it like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;export LC_ALL=en_US.utf-8&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and then run &lt;code&gt;vimtutor&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1067" LastEditorUserId="1067" LastEditDate="2015-08-13T19:24:25.180" LastActivityDate="2015-08-13T19:24:25.180" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4309" PostTypeId="1" AcceptedAnswerId="4311" CreationDate="2015-08-13T19:32:19.113" Score="6" ViewCount="1791" Body="&lt;p&gt;I think it would be very nice if I can check whether current vim was compiled with python support, instead of having error message popping out every time vim is launched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this check be done in vimscript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that running shell wouldn't work if multiple vim's are installed and user launch one of them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version | grep -q '\+python\&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would be considered as a better approach if it could be checked within vimscript alone.&lt;/p&gt;&#xA;" OwnerUserId="1097" LastEditorUserId="1841" LastEditDate="2015-08-14T14:46:04.130" LastActivityDate="2015-08-14T14:46:04.130" Title="How to check with Vimscript whether python support is enabled?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4310" PostTypeId="2" ParentId="4307" CreationDate="2015-08-13T19:36:22.713" Score="6" Body="&lt;p&gt;Your given use-cases to me sound like to want to know the &lt;code&gt;.&lt;/code&gt; key command (repeat last Editing command)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Go to first place, press &lt;code&gt;i&lt;/code&gt;, insert your text, &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;move to location 2, press &lt;code&gt;.&lt;/code&gt; (Dot) ==&gt; Identical Text is inserted&lt;/li&gt;&#xA;&lt;li&gt;To move down one line here and insert again (when inserting into consecutive lines), press &lt;code&gt;&amp;lt;ALT&amp;gt;-j.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Your tex example for me is solved by:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;I\section[]{}&amp;lt;ESC&amp;gt;hhiMy first Sec...&amp;lt;ESC&amp;gt;lll.&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="3102" LastEditorUserId="3102" LastEditDate="2015-08-13T19:53:28.130" LastActivityDate="2015-08-13T19:53:28.130" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4311" PostTypeId="2" ParentId="4309" CreationDate="2015-08-13T19:59:56.217" Score="12" Body="&lt;p&gt;How about&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('python')&#xA;    ...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help has()&lt;/code&gt; and &lt;code&gt;:help feature-list&lt;/code&gt; at list item 1 and &lt;code&gt;/python&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-08-13T19:59:56.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4312" PostTypeId="2" ParentId="4307" CreationDate="2015-08-13T22:00:47.870" Score="47" Body="&lt;p&gt;&lt;strong&gt;Using multiple cursor isn't a Vimmer thing&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I said in the comments using multi cursors (even with a plugin) isn't really &quot;following the Vim way&quot;, I totally understand that it is attractive for someone coming from Sublime-Text but you can often find alternatives which are at least as efficient with Vim built-in features. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, finding these alternative solutions isn't always easy and sometimes it takes time but it will get easier with your Vim experience and you'll see that with time multiple cursors will seem totally useless to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;That's cool but how can I find an alternative way?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no universal answer since it depends a lot on what you're trying to do, I'll just try to give some hints about the first things to try:&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The dot command &lt;code&gt;.&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Dot command is probably one of the most powerful tools in Vim, it simply &#xA;allows us to repeat the last change.  I couldn't explain it better than Drew &#xA;Neil in his &lt;a href=&quot;https://pragprog.com/book/dnvim/practical-vim&quot; rel=&quot;noreferrer&quot;&gt;Practical Vim&lt;/a&gt;. I&#xA;think that every Vimmer should consider reading this book.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The strength of this command is that the last change can be an action working on&#xA;a character, a line or a whole file. For example, a change can be delimited by&#xA;the moment you enter insert mode and the moment you go back to normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that in mind it is easy to do what you wanted to do with multicursor:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First let's set up our environment: Let's write as you suggested&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\section[]{}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then make a &lt;strong&gt;repeatable change&lt;/strong&gt;&#xA;The cursor is now on &lt;code&gt;}&lt;/code&gt;,hit &lt;code&gt;F[&lt;/code&gt; to go back on the &lt;code&gt;[&lt;/code&gt; character.&#xA;Then enter insert mode with &lt;code&gt;i&lt;/code&gt; and type &lt;code&gt;My first section in this book&lt;/code&gt; and go&#xA;back to normal mode with &lt;code&gt;ESC&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\section[My first section in this book]{}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;And here comes the magic part: &#xA;Let's type &lt;code&gt;f{&lt;/code&gt; to put the cursor on the &lt;code&gt;{&lt;/code&gt; character and hit &lt;code&gt;.&lt;/code&gt; to repeat&#xA;the last change:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\section[My first section in this book]{My first section in this book}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All the challenge of the dot command is to learn how to make repeatable changes:&#xA;it will come with grokking Vim but the basic is to understand how to make your&#xA;change in a repeatable way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example to insert a semi colon at the end of a line you'll prefer using &#xA;&lt;code&gt;A;&lt;/code&gt; instead of &lt;code&gt;$a;&lt;/code&gt;. Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because &lt;code&gt;A;&lt;/code&gt; creates an atomic action so when you'll use &lt;code&gt;.&lt;/code&gt; on another line, no&#xA;matter where you are in the line you'll insert the semi colon at the end.&#xA;Whereas when using &lt;code&gt;$a;&lt;/code&gt; you split your change in two parts &lt;code&gt;$a&lt;/code&gt; and the&#xA;insertion of &lt;code&gt;;&lt;/code&gt; so if you use &lt;code&gt;.&lt;/code&gt; it will insert the semi colon on the current&#xA;position of the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; The magic formula in Vim is &lt;code&gt;n.&lt;/code&gt;. A really cool workflow is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;search for the place you want to make an edit with &lt;code&gt;/pattern&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;make your repeatable edit&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;n&lt;/code&gt; to go to the next place to edit&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;.&lt;/code&gt; to repeat the edit&lt;/li&gt;&#xA;&lt;li&gt;repeat the last two steps: You're the king of the world (or at least of&#xA;edits)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;macros&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Macros are another extremely important tool in Vim since it allows you to record&#xA;a sequence of keystrokes and repeat it as if you typed it again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll use, as an example, your second use case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable1 = 2&#xA;my_variable2 = 12&#xA;var3 = 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once again the important is to learn how to make your macros efficient (I'll&#xA;give a counter example just after):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Put your cursor on the word &lt;code&gt;variable1&lt;/code&gt; and begin to record your macro with&#xA;&lt;code&gt;qq&lt;/code&gt;. This means &quot;start recording all my future keystrokes in the register&#xA;named &lt;code&gt;q&lt;/code&gt;&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Start making your edit typing: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; to go at the beginning of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;e&lt;/code&gt; to go at the end of the first word&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&lt;/code&gt; to append after your cursor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.someStuff&lt;/code&gt; to append the wanted text&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to stop the insertion&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; to go on the next line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; to stop recording the macro&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You'll get:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable1.someStuff = 2&#xA;my_variable2 = 12&#xA;var3 = 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Now you can use the macro to repeat your edit. As you are on the right line to&#xA;edit you can simply execute the macro with &lt;code&gt;@q&lt;/code&gt;. As we want to execute it  twice you can use &lt;code&gt;2@q&lt;/code&gt; and you'll get the following result:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable1.someStuff = 2&#xA;my_variable2.someStuff = 12&#xA;var3.someStuff = 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 1&lt;/strong&gt; As you may have noticed, using &lt;code&gt;0ea&lt;/code&gt; at the beginning of the macro&#xA;was really important. Indeed, if you had put your cursor at the end of the first&#xA;word before recording the macro and executing it again your result would have&#xA;been:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable1.someStuff = 2&#xA;my_variable2 = 12.someStuff&#xA;var3 = 14.someStuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As your cursor the text would have been inserted at the position of the cursor&#xA;after changing of line (i.e. the end of the line in this case)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 2&lt;/strong&gt; Macros are extremely powerful and you can even create recursive&#xA;macros when you are comfortable with them. Here your macro could have been:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`0ea.someStuff&amp;lt;Esc&amp;gt;j@q`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The final &lt;code&gt;@q&lt;/code&gt; would have called the macro by itself instead of using &lt;code&gt;2@q&lt;/code&gt;; you'd&#xA;just have used &lt;code&gt;@q&lt;/code&gt; and all the work would have been done.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;visual block&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here comes another trick that doesn't directly apply to your use case but can&#xA;be really useful to edit a large number of line at the same time. Let's get this&#xA;extract of CSS code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;li.one   a{ background-image: url('/images/sprite.png'); }&#xA;li.two   a{ background-image: url('/images/sprite.png'); }&#xA;li.three a{ background-image: url('/images/sprite.png'); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What if you moved the sprites from &lt;code&gt;images&lt;/code&gt; to &lt;code&gt;components&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well you can put your cursor on the &lt;code&gt;i&lt;/code&gt; of &lt;code&gt;images&lt;/code&gt; and press &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;. This will&#xA;start the visual block mode which allows to select blocks. Now you can type &lt;code&gt;t/&lt;/code&gt;&#xA;to select the word you want to change and &lt;code&gt;2j&lt;/code&gt; to select all the occurrences of the&#xA;word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that you simply have to type &lt;code&gt;c&lt;/code&gt; to change the word and then &lt;code&gt;components&lt;/code&gt;.&#xA;When you'll go out of insert mode you'll see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;li.one   a{ background-image: url('/components/sprite.png'); }&#xA;li.two   a{ background-image: url('/components/sprite.png'); }&#xA;li.three a{ background-image: url('/components/sprite.png'); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The global command&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The global command is a tool which allows to apply an ex mode command on lines&#xA;matching a pattern, once again that's a good way to apply the same change on&#xA;different place without needing multiple cursors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The syntax is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range] g / pattern / command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more details on the &lt;code&gt;[range]&lt;/code&gt; parameter please see &lt;code&gt;:h :range&lt;/code&gt;. I won't detail&#xA;it here, I'll simply remind that &lt;code&gt;%&lt;/code&gt; represents the whole file, &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt;&#xA;represents the last selection, and &lt;code&gt;1,5&lt;/code&gt; represents the lines 1 to 5 of the&#xA;file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This parameter defines the lines which will be treated by the global command. If&#xA;no range is specified, then the global command will use &lt;code&gt;%&lt;/code&gt; by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The [pattern] argument is a search pattern as you are used to use with the search&#xA;engine. As it integrates the search history you can leave this field blank and&#xA;the global command will then use the last search pattern in the search history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally the [command] parameter is an ex command as you are probably used to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the behavior of the global command is pretty simple:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Iterate through all the lines defined in the [range] parameter&lt;/li&gt;&#xA;&lt;li&gt;If the current line matches the defined pattern, apply the command&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As the [command] parameter is an ex command, you can do a lot of things. Let's&#xA;take the following pseudo code which isn't pretty interesting and have a lot of&#xA;debugging messages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var myList  = null&#xA;var i       = 0&#xA;&#xA;myList = new List()&#xA;echo &quot;List instantiated&quot;&#xA;&#xA;for (i=0; i&amp;lt;10; i++)&#xA;    myList.Add(i)&#xA;    echo i . &quot; added to the list&quot;&#xA;&#xA;echo &quot;end of for loop&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now let's say that you're sure this code works and you want to delete these&#xA;useless &lt;code&gt;echo&lt;/code&gt; statements:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You can apply your global command on the whole file so you'll have to prepend&#xA;the command with &lt;code&gt;%&lt;/code&gt; (or with nothing since &lt;code&gt;%&lt;/code&gt; is the default range).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You know that the lines you want delete all matches the pattern &lt;code&gt;echo&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You want to delete these lines so you'll have to use the command &lt;code&gt;:delete&lt;/code&gt;&#xA;which can also be abbreviated as &lt;code&gt;d&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So you'll simply have to use the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%global/echo/delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can also be abbreviated as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/echo/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;%&lt;/code&gt; disappeared, &lt;code&gt;global&lt;/code&gt; is abbreviated as &lt;code&gt;g&lt;/code&gt; and &lt;code&gt;delete&lt;/code&gt; as &lt;code&gt;d&lt;/code&gt;.&#xA;As you might imagine the result is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var myList  = null&#xA;var i       = 0&#xA;&#xA;myList = new List()&#xA;&#xA;for (i=0; i&amp;lt;10; i++)&#xA;    myList.Add(i)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 1&lt;/strong&gt; An important point that took me some time to realize is that the&#xA;&lt;code&gt;normal&lt;/code&gt; command is an ex command which means that you can use it with the&#xA;global command. That can be really powerful: let's say that I want to duplicate&#xA;all the lines which contains echo, I don't need a macro or even the magic&#xA;formula &lt;code&gt;n.&lt;/code&gt;. I can simply use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/echo/normal YP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And voila:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var myList  = null&#xA;var i       = 0&#xA;&#xA;myList = new List()&#xA;echo &quot;List instantiated&quot;&#xA;echo &quot;List instantiated&quot;&#xA;&#xA;for (i=0; i&amp;lt;10; i++)&#xA;    myList.Add(i)&#xA;    echo i . &quot; added to the list&quot;&#xA;    echo i . &quot; added to the list&quot;&#xA;&#xA;echo &quot;end of for loop&quot;&#xA;echo &quot;end of for loop&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 2&lt;/strong&gt; &quot;Hey what if I want to use my command on lines which doesn't match a&#xA;specific pattern?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;global&lt;/code&gt; has an opposite command &lt;code&gt;vglobal&lt;/code&gt; abbreviated &lt;code&gt;v&lt;/code&gt; which works exactly&#xA;like &lt;code&gt;global&lt;/code&gt; except that the command will be applied on lines which don't&#xA;match the [pattern] parameter. This way if we apply&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:v/echo/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On our previous example we get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;List instantiated&quot;&#xA;    echo i . &quot; added to the list&quot;&#xA;echo &quot;end of for loop&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;delete&lt;/code&gt; command has been applied on lines which didn't contained &lt;code&gt;echo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here I hope that those few hints will give you ideas on how to get rid of your&#xA;multi cursor plugin and use Vim in the Vim way ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can imagine these examples are pretty simple and are just made to&#xA;demonstrate that when you follow the Vim way you really rarely need several&#xA;cursors. My advice would be when you encounter a situation where you think it&#xA;would be useful, write it down and take some time later to find a better&#xA;solution. 99% of the time you'll eventually find a faster/more efficient way to&#xA;do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I will repeat myself one more time but I really encourage you to read&#xA;&lt;a href=&quot;https://pragprog.com/book/dnvim/practical-vim&quot; rel=&quot;noreferrer&quot;&gt;Practical Vim&lt;/a&gt; by Drew Neil&#xA;because this book is not about &quot;How to do that or this in Vim&quot; it is about &quot;How&#xA;to learn to think in the Vim way&quot; which will allow you to built your own&#xA;solution to your future problems in a good way.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt; Special thanks to @Alex Stragies for his editing work and the corrections&#xA;he made to this long post.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="6698" LastEditDate="2019-06-03T23:37:31.063" LastActivityDate="2019-06-03T23:37:31.063" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="4313" PostTypeId="1" AcceptedAnswerId="4315" CreationDate="2015-08-13T22:46:56.467" Score="2" ViewCount="1978" Body="&lt;p&gt;I recently added &lt;code&gt;set hidden&lt;/code&gt; to my &lt;code&gt;vimrc&lt;/code&gt; script because I didn't always want to &lt;code&gt;:w&lt;/code&gt;rite a file before &lt;code&gt;:e&lt;/code&gt;diting another file. (With &lt;code&gt;set nohidden&lt;/code&gt;, which is the default, this resulted in a &lt;code&gt;E37: No write since last change (add ! to override)&lt;/code&gt; error).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;hidden&lt;/code&gt; solved this problem, but introduced a new one. Sometimes, I split the window (&lt;code&gt;ctrl-w n&lt;/code&gt;) before I &lt;code&gt;:e&lt;/code&gt;dit a file. This creates an empty buffer for each split that I have done. This is of course not what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there some setting or autocommand or anything that I am not aware of that gets rid of unused empty buffers automatically?&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2015-08-14T03:07:49.827" Title="&quot;set hidden&quot; leaves many *empty* buffers. Can I automatically get rid of them?" Tags="|buffers|split|hidden-buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4314" PostTypeId="1" AcceptedAnswerId="4342" CreationDate="2015-08-13T22:51:45.593" Score="0" ViewCount="548" Body="&lt;p&gt;I have &lt;code&gt;set wildmenu&lt;/code&gt; and &lt;code&gt;set wildmode=list,full&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I go to enter a command such as &lt;code&gt;buf&lt;/code&gt; or &lt;code&gt;tabe&lt;/code&gt;, follow it with a space, and then hit &lt;kbd&gt;tab&lt;/kbd&gt;, my wildmenu options take effect as I'd expect, but for some commands, such as &lt;code&gt;open&lt;/code&gt;, I can't tab complete afterwards. Instead &lt;code&gt;^I&lt;/code&gt; characters are added. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why can't I tab complete after &lt;code&gt;open&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1166" LastEditorUserId="1166" LastEditDate="2015-08-14T14:22:09.530" LastActivityDate="2015-08-14T17:00:28.097" Title="Why can't I tab complete after open?" Tags="|autocompletion|wildmenu|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4315" PostTypeId="2" ParentId="4313" CreationDate="2015-08-14T03:07:49.827" Score="7" Body="&lt;p&gt;Cut out the middle man. If you want to edit a file in a split, use &lt;code&gt;:split file.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is the very nature of using &lt;code&gt;&amp;lt;C-W&amp;gt;n&lt;/code&gt; that creates these new buffers. It's like using the &lt;code&gt;:new&lt;/code&gt; command, which is wasteful if you plan to immediately edit some other file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you like the visual confirmation of seeing the new window before editing the file, you could use &lt;code&gt;&amp;lt;C-W&amp;gt;s&lt;/code&gt; which opens a split with the current buffer (so you'll see two of the same file) and then proceed to use &lt;code&gt;:edit file.txt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2015-08-14T03:07:49.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4316" PostTypeId="2" ParentId="4300" CreationDate="2015-08-14T04:07:12.823" Score="17" Body="&lt;p&gt;Setting the &lt;code&gt;lazyredraw&lt;/code&gt; with &lt;code&gt;:set lazyredraw&lt;/code&gt; will greatly improve macro execution speed by not redrawing the screen while a macro is executing or a command is run other than those you type, see &lt;code&gt;:help 'lazyredraw'&lt;/code&gt; for more information. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to reduce make sure you don't have any time wasting autocmds or mappings. If your macros are still slow after running, check your vimrc file for slow or unnecessary mappings and remove unneeded plugins. In my case I had an autocmd that would run and external program to turn off CapsLock when exiting insert mode, this was convenient and normally unnoticeable but it slowed down insert macros a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your macro enters insert mode, where you have a lot of mappings, it may help to have a key to set paste mode and disable insert mappings temporarily, see &lt;code&gt;:help 'paste'&lt;/code&gt; and &lt;code&gt;:help 'pastetoggle'&lt;/code&gt;. Keep in mind this could make insertations more difficult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, keep the macro as simple as possible by minimizing movement, mode switching, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good Luck.&lt;/p&gt;&#xA;" OwnerUserId="2283" LastActivityDate="2015-08-14T04:07:12.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4317" PostTypeId="2" ParentId="4288" CreationDate="2015-08-14T10:38:55.370" Score="3" Body="&lt;p&gt;You can use my &lt;a href=&quot;https://github.com/chrisbra/DynamicSigns&quot; rel=&quot;nofollow&quot;&gt;DynamicSigns&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First Define a function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! CustomSignExpression(lnum, div)&#xA;    if a:lnum &amp;lt; line('w0') || a:lnum &amp;gt; line ('w$')&#xA;        return 0&#xA;    endif&#xA;    if !exists(&quot;#SignExpression#CursorMoved&quot;)&#xA;        augroup SignExpression&#xA;            au!&#xA;            au CursorMoved * :Signs&#xA;        augroup end&#xA;    endif&#xA;    let part=abs(a:lnum - line('.'))&#xA;    if part % a:div == 0&#xA;        return part &amp;gt; 99 ? 99 : part&#xA;    else&#xA;        return 0&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you simply call &lt;code&gt;:SignExpression CustomSignExpression(v:lnum, 5)&lt;/code&gt;&#xA;if you want to have every fifth line a relative number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The autocommand is there to make sure, the signs are redrawn on cursor&#xA;movement (which by default only happens on text changes to not impact performance negatively). This means, that it might affect redraw performance of your Vim especially for larger Files and screen sizes.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-08-14T10:38:55.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4318" PostTypeId="1" CreationDate="2015-08-14T10:54:34.493" Score="3" ViewCount="598" Body="&lt;p&gt;I have a file that uses 4-space indentation. By default, when I move horizontally, Vim moves over those spaces one by one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure Vim so that it moves 4 spaces horizontally when moving over indentation whitespace?&lt;/p&gt;&#xA;" OwnerUserId="1945" LastActivityDate="2015-08-15T14:09:52.167" Title="How to skip over indentation whitespace with horizontal motion?" Tags="|indentation|cursor-motions|whitespace|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4319" PostTypeId="2" ParentId="4318" CreationDate="2015-08-14T12:31:15.943" Score="4" Body="&lt;p&gt;Maybe you can add the following functions to your &lt;code&gt;.vimrc&lt;/code&gt;. They compare the current position of the cursor to the position of the first character and if necessary they skip the non printed characters before the first non blank one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyLMotion()&#xA;    let cursorPosition=getpos(&quot;.&quot;)&#xA;    normal ^&#xA;    let firstChar=getpos(&quot;.&quot;)&#xA;&#xA;    if cursorPosition[2] &amp;lt; firstChar[2]&#xA;        normal ^&#xA;    else&#xA;        call setpos('.', cursorPosition)&#xA;        normal! l&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This one goes on the right: if the cursor is before the first non blank character, then we use &lt;code&gt;normal ^&lt;/code&gt; to skip the whitespaces. If we are already on the line we use &lt;code&gt;normal! l&lt;/code&gt; to move on the right. Note the use of &lt;code&gt;!&lt;/code&gt;which allows to use the original &lt;code&gt;l&lt;/code&gt; motion even if we remap the key (this will be necessary otherwise we create a recursive function).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyHMotion()&#xA;    let cursorPosition=getpos(&quot;.&quot;)&#xA;    normal ^&#xA;    let firstChar=getpos(&quot;.&quot;)&#xA;&#xA;    if cursorPosition[2] &amp;lt;= firstChar[2]&#xA;        normal 0&#xA;    else&#xA;        call setpos('.', cursorPosition)&#xA;        normal! h&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This one goes on the left, this time if the cursor is on the first non blank character we use &lt;code&gt;normal 0&lt;/code&gt; to go on the beginning of the line and skip the white spaces. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then have to create these mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; h :call MyHMotion()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; l :call MyLMotion()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note the use of silent to prevent the messages &lt;code&gt;call MyXMotion&lt;/code&gt; to be output in the status line each time you press &lt;code&gt;h&lt;/code&gt; or &lt;code&gt;l&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you can use your &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt; keyslike before but they'll skip the unwanted space at the beginning of your line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the advantage of this solution is that the functions should work whatever your configuration is (tabs of whitespaces).&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-15T14:09:52.167" LastActivityDate="2015-08-15T14:09:52.167" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4320" PostTypeId="5" CreationDate="2015-08-14T12:56:31.090" Score="0" Body="&lt;p&gt;Vim can detect the type of file that is edited. This is done by checking the file name and sometimes by inspecting the contents of the file for specific text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To enable that, following command has to be added to the &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T13:06:48.663" LastActivityDate="2015-08-14T13:06:48.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4321" PostTypeId="4" CreationDate="2015-08-14T12:56:31.090" Score="0" Body="Questions about making Vim to have a defined behavior according the type of the edited file.&#xD;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T13:06:40.537" LastActivityDate="2015-08-14T13:06:40.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4322" PostTypeId="5" CreationDate="2015-08-14T12:59:48.837" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-08-14T12:59:48.837" LastActivityDate="2015-08-14T12:59:48.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4323" PostTypeId="4" CreationDate="2015-08-14T12:59:48.837" Score="0" Body="Questions about how to format a file with vim - this includes, but is not limited to, foldings, indents, wrappings, and so on." OwnerUserId="1841" LastEditorDisplayName="user579" LastEditDate="2018-09-20T17:39:13.000" LastActivityDate="2018-09-20T17:39:13.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4324" PostTypeId="5" CreationDate="2015-08-14T13:03:34.287" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-08-14T13:03:34.287" LastActivityDate="2015-08-14T13:03:34.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4325" PostTypeId="4" CreationDate="2015-08-14T13:03:34.287" Score="0" Body="A status line will be used to separate windows. Questions about how to format and change the content of this status line." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T13:06:46.293" LastActivityDate="2015-08-14T13:06:46.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4326" PostTypeId="5" CreationDate="2015-08-14T13:09:30.597" Score="0" Body="&lt;p&gt;&lt;em&gt;From &lt;code&gt;:h tab-page-intro&lt;/code&gt;:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can easily switch between tab pages, so that you have several collections of windows to work on different things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually you will see a list of labels at the top of the Vim window, one for&#xA;each tab page.  With the mouse you can click on the label to jump to that tab&#xA;page.  There are other ways to move between tab pages, see below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most commands work only in the current tab page.  That includes the &lt;code&gt;CTRL-W&lt;/code&gt;&#xA;commands, &lt;code&gt;:windo&lt;/code&gt;, &lt;code&gt;:all&lt;/code&gt; and &lt;code&gt;:ball&lt;/code&gt; (when not using the &lt;code&gt;:tab&lt;/code&gt; modifier).&#xA;The commands that are aware of other tab pages than the current one are&#xA;mentioned below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tabs are also a nice way to edit a buffer temporarily without changing the&#xA;current window layout.  Open a new tab page, do whatever you want to do and&#xA;close the tab page&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T13:20:07.997" LastActivityDate="2015-08-14T13:20:07.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4327" PostTypeId="4" CreationDate="2015-08-14T13:09:30.597" Score="0" Body="A tab page holds one or more windows. Questions about how to use and customize the behavior of Vim tabs." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T13:19:59.913" LastActivityDate="2015-08-14T13:19:59.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4328" PostTypeId="5" CreationDate="2015-08-14T13:15:52.673" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-08-14T13:15:52.673" LastActivityDate="2015-08-14T13:15:52.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4329" PostTypeId="4" CreationDate="2015-08-14T13:15:52.673" Score="0" Body="Vim is able to wrap lines when they are longer than the width of the window or than a user-defined width. Questions about how to customize this behavior." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T13:19:51.837" LastActivityDate="2015-08-14T13:19:51.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4330" PostTypeId="5" CreationDate="2015-08-14T13:33:19.683" Score="0" Body="&lt;p&gt;Related help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27tabstop%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 'tabstop'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27expandtab%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 'expandtab'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27shiftwidth%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 'shiftwidth'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T14:30:33.850" LastActivityDate="2015-08-14T14:30:33.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4331" PostTypeId="4" CreationDate="2015-08-14T13:33:19.683" Score="0" Body="Question about how to handle white spaces tab characters with vim, insert them, remove them, convert them to space characters, etc..." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T14:30:18.513" LastActivityDate="2015-08-14T14:30:18.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4332" PostTypeId="5" CreationDate="2015-08-14T13:39:09.143" Score="0" Body="&lt;p&gt;&lt;em&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/undo.html#%3CUndo%3E&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h undo&lt;/code&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last changes are remembered.  You can use the undo &lt;code&gt;u&lt;/code&gt; and redo &lt;code&gt;CTRL-R&lt;/code&gt; commands&#xA;to revert the text to how it was before each change.  You can also apply the&#xA;changes again, getting back the text before the undo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;U&quot; command is treated by undo/redo just like any other command.  Thus a&#xA;&quot;u&quot; command undoes a &quot;U&quot; command and a 'CTRL-R' command redoes it again.  When&#xA;mixing &quot;U&quot;, &quot;u&quot; and 'CTRL-R' you will notice that the &quot;U&quot; command will&#xA;restore the situation of a line to before the previous &quot;U&quot; command.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T14:29:51.110" LastActivityDate="2015-08-14T14:29:51.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4333" PostTypeId="4" CreationDate="2015-08-14T13:39:09.143" Score="0" Body="Question about navigation in the undo history, undoing, and redoing changes" OwnerUserId="1841" LastEditorUserId="51" LastEditDate="2015-08-14T14:30:02.707" LastActivityDate="2015-08-14T14:30:02.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4334" PostTypeId="5" CreationDate="2015-08-14T13:41:15.127" Score="0" Body="&lt;p&gt;Some well know plugin to wrap Git in Vim are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow&quot;&gt;Fugitive&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/airblade/vim-gitgutter&quot; rel=&quot;nofollow&quot;&gt;Git gutter&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T14:30:23.687" LastActivityDate="2015-08-14T14:30:23.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4335" PostTypeId="4" CreationDate="2015-08-14T13:41:15.127" Score="0" Body="Questions about the integration of the Git revision control system in Vim or about the synchronisation of Vim files via Git repositories." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T14:30:30.980" LastActivityDate="2015-08-14T14:30:30.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4336" PostTypeId="5" CreationDate="2015-08-14T13:49:43.780" Score="0" Body="&lt;p&gt;&lt;em&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/mbyte.html#Unicode&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h unicode&lt;/code&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Unicode character set was designed to include all characters from other&#xA;character sets.  Therefore it is possible to write text in any language using&#xA;Unicode (with a few rarely used languages excluded).  And it's mostly possible&#xA;to mix these languages in one file, which is impossible with other encodings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unicode can be encoded in several ways.  The most popular one is UTF-8, which&#xA;uses one or more bytes for each character and is backwards compatible with&#xA;ASCII.   On MS-Windows UTF-16 is also used (previously UCS-2), which uses&#xA;16-bit words.  Vim can support all of these encodings, but always uses UTF-8&#xA;internally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has comprehensive UTF-8 support.  It works well in:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;xterm with utf-8 support enabled&lt;/li&gt;&#xA;&lt;li&gt;Athena, Motif and GTK GUI&lt;/li&gt;&#xA;&lt;li&gt;MS-Windows GUI&lt;/li&gt;&#xA;&lt;li&gt;several other platforms&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Double-width characters are supported.  This works best with 'guifontwide' or&#xA;'guifontset'.  When using only 'guifont' the wide characters are drawn in the&#xA;normal width and a space to fill the gap.  Note that the 'guifontset' option&#xA;is no longer relevant in the GTK+ 2 GUI.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T14:29:24.743" LastActivityDate="2015-08-14T14:29:24.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4337" PostTypeId="4" CreationDate="2015-08-14T13:49:43.780" Score="0" Body="Question about using Unicode character set, how to insert them, how to display them and general use of the UTF8 encoding." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T14:30:10.487" LastActivityDate="2015-08-14T14:30:10.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4338" PostTypeId="5" CreationDate="2015-08-14T14:01:47.607" Score="0" Body="&lt;p&gt;Vim provides a quickfix mode to speedup the edit-compile-edit cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quickfix commands allows the user to navigate between different position in a file where some error was found by a compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h quickfix&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T14:30:27.280" LastActivityDate="2015-08-14T14:30:27.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4339" PostTypeId="4" CreationDate="2015-08-14T14:01:47.607" Score="0" Body="Questions about the usage of quickfix commands and quickfix windows." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-14T14:30:15.873" LastActivityDate="2015-08-14T14:30:15.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4340" PostTypeId="5" CreationDate="2015-08-14T14:03:04.000" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-08-14T14:03:04.000" LastActivityDate="2015-08-14T14:03:04.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4341" PostTypeId="4" CreationDate="2015-08-14T14:03:04.000" Score="0" Body="Questions about the use of a mouse with Vi or Vim." OwnerUserId="1841" LastEditorUserId="51" LastEditDate="2015-08-14T14:29:47.333" LastActivityDate="2015-08-14T14:29:47.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4342" PostTypeId="2" ParentId="4314" CreationDate="2015-08-14T17:00:28.097" Score="4" Body="&lt;p&gt;First of all you should understand &lt;a href=&quot;https://vi.stackexchange.com/q/2275/51&quot;&gt;What does :open do in vim?&lt;/a&gt; (thanks @Carpetsmoker for link)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;open&lt;/code&gt; has only one argument &lt;code&gt;:open /pattern/&lt;/code&gt; (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/vi_diff.html#:open&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help open&lt;/code&gt;&lt;/a&gt; and link above) and no complete options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For file names completion you should define your own command, something like this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command -complete=file -nargs=1 Open open &amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pay attention to &lt;code&gt;-complete=&lt;/code&gt; argument it may take some value listed in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:command-completion&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; and including &lt;code&gt;file&lt;/code&gt; , &lt;code&gt;file_in_path&lt;/code&gt;, &lt;code&gt;buffer&lt;/code&gt; etc. and finally &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:command-completion-custom&quot; rel=&quot;nofollow noreferrer&quot;&gt;custom function&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;-nargs=1&lt;/code&gt; indicate that you command can take only one arument&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:command&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help command&lt;/code&gt;&lt;/a&gt; for full explanation and examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can type &lt;code&gt;:Open&lt;/code&gt; and then press Tab&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or just use &lt;strong&gt;&lt;code&gt;:edit&lt;/code&gt;&lt;/strong&gt; command instead, it has completion option like as a &lt;code&gt;buffer&lt;/code&gt; and &lt;code&gt;tabe&lt;/code&gt; commands.&lt;/p&gt;&#xA;" OwnerUserId="1145" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-08-14T17:00:28.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4343" PostTypeId="1" AcceptedAnswerId="4344" CreationDate="2015-08-15T01:59:29.940" Score="7" ViewCount="359" Body="&lt;p&gt;My .vimrc does a lot of extra things I don't want to do if it's launched by git (for example, during commit), since the purpose of that Vim instance is very specific so it makes no sense to launch many windows I would launch in normal way.&lt;/p&gt;&#xA;&lt;p&gt;Is there any way I can detect whether this instance is launched by git?&lt;/p&gt;&#xA;" OwnerUserId="1097" LastEditorUserId="23502" LastEditDate="2022-11-05T09:16:45.127" LastActivityDate="2022-11-05T09:16:45.127" Title="Can I detect whether current Vim instance is launched by git?" Tags="|git|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4344" PostTypeId="2" ParentId="4343" CreationDate="2015-08-15T07:07:21.707" Score="7" Body="&lt;pre&gt;&lt;code&gt;$ git config --global core.editor &quot;vim -Nu NONE&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;tells Git to use Vim without sourcing your &lt;code&gt;vimrc&lt;/code&gt; (&lt;code&gt;-u NONE&lt;/code&gt;) and in &quot;nocompatible&quot; mode (&lt;code&gt;-N&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, well… you could even add something to start directly in insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ git config --global core.editor &quot;vim -Nu NONE -c startinsert&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-08-15T15:17:22.573" LastActivityDate="2015-08-15T15:17:22.573" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4346" PostTypeId="1" CreationDate="2015-08-15T14:04:44.093" Score="5" ViewCount="232" Body="&lt;p&gt;One thing I often do here is to add links to documentation when writing &lt;code&gt;:he foo&lt;/code&gt;, and I usually link to &lt;a href=&quot;http://vimhelp.appspot.com&quot; rel=&quot;noreferrer&quot;&gt;http://vimhelp.appspot.com&lt;/a&gt;. The problem is, that site's search is about slightly worse than the Stack Exchange sites' search. &lt;a href=&quot;http://vimdoc.sourceforge.net&quot; rel=&quot;noreferrer&quot;&gt;http://vimdoc.sourceforge.net&lt;/a&gt;, on the other hand, has excellent search functionality, searching the tags similar to the way Vim does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like is a function which can convert something like &lt;code&gt;:H magic&lt;/code&gt; to &lt;code&gt;http://vimhelp.appspot.com/pattern.txt.html#%2Fmagic&lt;/code&gt;, that is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;find the actual text of the help tag (&lt;code&gt;:he subst&lt;/code&gt; can go to the help for &lt;code&gt;:substitute&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;URL encode special characters in the tag (&lt;code&gt;:&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, etc.)&lt;/li&gt;&#xA;&lt;li&gt;copy the URL to the clipboard or some other register&lt;/li&gt;&#xA;&lt;li&gt;Bonus: if run without args, pick the argument I used for my last call to &lt;code&gt;:he&lt;/code&gt;, or the last tag I jumped to in the help.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've come close:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Help2url (word)&#xA;    python &amp;lt;&amp;lt;EOF&#xA;import vim&#xA;from urllib import quote_plus &#xA;topmatch = vim.eval ('taglist(a:word)[0]')&#xA;filename = topmatch['filename'].split ('/')[-1]&#xA;tag = quote_plus (topmatch['name'])&#xA;url = 'http://vimhelp.appspot.com/{:s}.html#{:s}'.format (filename, tag)&#xA;EOF&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This still needs to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use the help system's tags.&lt;/li&gt;&#xA;&lt;li&gt;copy to the clipboard&lt;/li&gt;&#xA;&lt;li&gt;work out the order that Vim uses.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The last point needs explaining. &lt;code&gt;taglist('magic')&lt;/code&gt; returns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[{'cmd': '/*''magic''*', 'static': 0, 'name': '''magic''', 'kind': '', 'filename&#xA;': '/usr/share/vim/vim74/doc/options.txt'}, {'cmd': '/*''nomagic''*', 'static':&#xA;0, 'name': '''nomagic''', 'kind': '', 'filename': '/usr/share/vim/vim74/doc/opti&#xA;ons.txt'}, {'cmd': '/*\/magic*', 'static': 0, 'name': '/magic', 'kind': '', 'fil&#xA;ename': '/usr/share/vim/vim74/doc/pattern.txt'}, {'cmd': '/*:smagic*', 'static':&#xA; 0, 'name': ':smagic', 'kind': '', 'filename': '/usr/share/vim/vim74/doc/change.&#xA;txt'}, {'cmd': '/*:snomagic*', 'static': 0, 'name': ':snomagic', 'kind': '', 'fi&#xA;lename': '/usr/share/vim/vim74/doc/change.txt'}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first match is &lt;code&gt;'magic'&lt;/code&gt;, whereas &lt;code&gt;:he magic&lt;/code&gt; goes to &lt;code&gt;/magic&lt;/code&gt;. So, simply taking the first element of the list returned from &lt;code&gt;taglist()&lt;/code&gt; doesn't seem to cut it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solutions not using Python are welcome. I'm just more comfortable with it.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-02-03T21:36:38.063" Title="How can I quickly convert a Vim help tag to a vimhelp.appspot.com link?" Tags="|help-system|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4347" PostTypeId="1" AcceptedAnswerId="8605" CreationDate="2015-08-15T16:33:44.590" Score="0" ViewCount="195" Body="&lt;p&gt;There is some strange behavior to observe in the current version of NetRW shipped with Debian Jessie (current as of Mid-2015) on my installation. Searching online doesn't immediately reveal other reports, or a known bug/existing patch. I'm currently not yet excluding my environments, or that this is documented behavior. Haven't found that yet though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I attempt to open 2 or more files with vim on different remote servers, only the first one gets opened successfully, concerning the other(s) I get a [New Directory] message. I switch command-line parameter sequence, the other one opens successfully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim scp://host1/filepath1 scp://host2/otherfilepath2&lt;/code&gt;&#xA;==&gt; First file opens, but second file is blank&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim scp://host2/otherfilepath2 scp://host1/filepath1&lt;/code&gt;&#xA;==&gt; Behavior consistent: Opening other files than first fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On top of it, &lt;strong&gt;both fail&lt;/strong&gt;, if I also specify a local file first:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim local/fi.le scp://host2/otherfilepath2 scp://host1/filepath1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following variant at least opens the first scp-file and the local file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim scp://host2/otherfilepath2 local/fi.le scp://host1/filepath1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/2004/3102&quot;&gt;Running with all local customizations disabled as described in detail here:&lt;/a&gt; &lt;code&gt;vim -u NONE -U NONE -N scp...&lt;/code&gt; creates buffers for all files, but all remote file buffers are empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I stumbled upon this, when I was testing some edge cases in a &lt;a href=&quot;https://vi.stackexchange.com/a/4243/3102&quot;&gt;solution/hack I was proposing as an answer&lt;/a&gt;&#xA;to a question about&#xA;&lt;a href=&quot;https://vi.stackexchange.com/q/3943/3102&quot;&gt;Filename Completion for Remote Files&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3102" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2016-07-06T15:50:31.817" Title="NetRW bug? : vim scp://host1/filepath scp://host2/otherfilepath only opens first file" Tags="|netrw|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4348" PostTypeId="1" CreationDate="2015-08-15T17:14:31.207" Score="3" ViewCount="569" Body="&lt;p&gt;Using the normal spell-check mechanism in vim one can jump from one misspelling to the next using &lt;code&gt;]s&lt;/code&gt;. Sadly vim's spell-check is completely useless for Turkish. Using the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2345&quot; rel=&quot;nofollow&quot;&gt;vimchant&lt;/a&gt; plugin that hooks into the Enchant spelling system (which in turn gets its Turkish from hunspell)* it is actually possible to get Turkish spell checking enabled in a vim buffer. However the fun and games seems to end with highlighting mismatches. The words are highlighted in the buffer but there seems to be no other smarts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can live without automatic suggestions, replacements etc. I can spell in Turkish when I stop to think about it. But navigating through a document fixing mistakes is painful. Even using paragraph, sentence and word motion commands it is still  tedious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can setup a binding to jump to the next item in the spelling mistake highlight group?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* Yes, this is turtles all the way down.&lt;/sub&gt; &lt;/p&gt;&#xA;" OwnerUserId="267" LastActivityDate="2015-08-15T22:22:37.767" Title="Motion key for next highlighted item?" Tags="|cursor-motions|highlight|spell-checking|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4349" PostTypeId="1" CreationDate="2015-08-15T18:49:35.193" Score="7" ViewCount="2381" Body="&lt;p&gt;What is the difference between the &lt;code&gt;clipboard&lt;/code&gt; and &lt;code&gt;xterm_clipboard&lt;/code&gt; features?  When do I need to enable one or the other at compilation time?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an aside, how do these features relate to the &lt;code&gt;mouse&lt;/code&gt; option?  Is it only through the mouse middle button?  I am using Vim from within the GNOME terminal.&lt;/p&gt;&#xA;" OwnerUserId="3192" LastEditorUserId="51" LastEditDate="2015-08-15T21:01:10.413" LastActivityDate="2015-08-18T20:06:14.183" Title="What's the difference between the &quot;clipboard&quot; and &quot;xterm_clipboard&quot; features?" Tags="|cut-copy-paste|terminal|os-clipboard|mouse|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4350" PostTypeId="2" ParentId="4348" CreationDate="2015-08-15T19:23:29.450" Score="3" Body="&lt;p&gt;I will only give a beginning of an answer. First, because the &lt;a href=&quot;https://github.com/vim-scripts/Vimchant&quot; rel=&quot;nofollow&quot;&gt;vimchant&lt;/a&gt; plugin uses &lt;a href=&quot;https://github.com/vim-scripts/Vimchant/blob/master/autoload/vimchant.vim#L127&quot; rel=&quot;nofollow&quot;&gt;matchadd&lt;/a&gt; to highlight items, you &lt;em&gt;can not&lt;/em&gt; (to my knowledge) search for &lt;code&gt;SpellBad&lt;/code&gt; highlighted items. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;One&lt;/strong&gt; way would be to change that line to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute 'syntax match SpellBad &quot;\C\V\&amp;lt;' . word . '\&amp;gt;&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead. Then, you can search for bad-spelling in your buffer with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo synIDattr(synID(line(&quot;.&quot;),col(&quot;.&quot;),1),&quot;name&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and moving the cursor from a word to the next one, until the result is &lt;code&gt;'SpellBad'&lt;/code&gt;. Automate that, and you have your answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Another&lt;/strong&gt; way (better, I think), would be again to slightly modify the plugin - simply save the local variable &lt;a href=&quot;https://github.com/vim-scripts/Vimchant/blob/master/autoload/vimchant.vim#L110&quot; rel=&quot;nofollow&quot;&gt;spelling_errors&lt;/a&gt; to a global one (e.g. &lt;code&gt;g:spelling_errors&lt;/code&gt;) on the following line. Then, create a function (can be in your vimrc) that searches forward, from the current cursor position, for &lt;em&gt;any&lt;/em&gt; of the words in that list (or, alternatively, move from word to word until it finds one that belongs to the list).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am now on Windows, and don't have an &lt;code&gt;enchant&lt;/code&gt; executable, so I can't help more.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-08-15T22:22:37.767" LastActivityDate="2015-08-15T22:22:37.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4351" PostTypeId="1" AcceptedAnswerId="4355" CreationDate="2015-08-15T20:33:52.210" Score="1" ViewCount="208" Body="&lt;p&gt;Many useful mappings need to temporarily save text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some practical examples are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Move line up/down&#xA;nnoremap &amp;lt;c-j&amp;gt; ddp&#xA;nnoremap &amp;lt;c-k&amp;gt; ddkP&#xA;&#xA;&quot; Substitute word under cursor (use `cc` instead of default `S`)&#xA;nnoremap SS yiw:s/&amp;lt;c-r&amp;gt;&quot;/&#xA;nnoremap S% yiw:%s/&amp;lt;c-r&amp;gt;&quot;/&#xA;&#xA;&quot; Substitute selection&#xA;vnoremap SS y:s/&amp;lt;c-r&amp;gt;&quot;/&#xA;vnoremap S% y:%s/&amp;lt;c-r&amp;gt;&quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These mappings has to yank a piece of text for later use. I have always used the default register for this but there is a problem with this approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By using the default register in the mapping I am overwriting it's previous content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the user has yanked some text and then executes one of the mappings the yanked text will be overwritten. This is something very minor but it has started to annoy me lately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There has to be a better way to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make mappings like these but do not affect the global Vim environment? If not then what is your solution to this problem?&lt;/p&gt;&#xA;" OwnerUserId="3032" LastActivityDate="2015-08-16T09:10:11.467" Title="How to make mappings that yank text without overwriting the global registers" Tags="|key-bindings|vimscript|register|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4353" PostTypeId="1" CreationDate="2015-08-16T03:46:24.370" Score="5" ViewCount="1734" Body="&lt;p&gt;As a way of organizing my codes, I like to include some titles as comments with specific patterns (I wish I can add ASCII art!). Consider for example, putting the following to mark a specific block of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//===================== Solving a big problem =============================//&#xA;&#xA;//--------------------The most important calculation-----------------------//&#xA;     ... some code ...&#xA;//------------------------End of the calculation---------------------------//&#xA;&#xA;//--------------------I/O operations are on their way ---------------------//&#xA;     ... some code ...&#xA;//------------------------End of I/O operations----------------------------//&#xA;//============================== End solution =============================//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I require:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The pattern should be 80-column wide (including identation space)&lt;/li&gt;&#xA;&lt;li&gt;The title should be centered&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can automate the generation of such patterns in vim?&lt;/p&gt;&#xA;" OwnerUserId="2199" LastActivityDate="2015-09-24T16:10:26.867" Title="How to generate patterns for comments?" Tags="|vimscript|comments|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4354" PostTypeId="1" AcceptedAnswerId="4378" CreationDate="2015-08-16T04:51:35.057" Score="2" ViewCount="461" Body="&lt;p&gt;In &lt;a href=&quot;https://github.com/vim-latex/vim-latex&quot; rel=&quot;nofollow&quot;&gt;vim-latexsuite&lt;/a&gt; how do I make vim completing references and equations labels with &lt;code&gt;.&lt;/code&gt; in them? For example, I call the equations by chapters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;label{eq:intro.x}&#xA;label{eq:physics.y}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then, when trying to reference these equations, by hitting &lt;code&gt;Ctrl+n&lt;/code&gt;, vim doesn't recognize the &lt;code&gt;.&lt;/code&gt; part and it just completes the first word. Any solution?&lt;/p&gt;&#xA;" OwnerUserId="2199" LastEditorUserId="1841" LastEditDate="2015-08-22T10:41:20.177" LastActivityDate="2015-08-22T10:41:20.177" Title="How to add '.' to autocomplete suggestions in vim-latexsuite?" Tags="|autocompletion|filetype-tex|plugin-vim-latex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4355" PostTypeId="2" ParentId="4351" CreationDate="2015-08-16T09:03:01.357" Score="3" Body="&lt;p&gt;&lt;strong&gt;Move line up/down&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :&amp;lt;C-u&amp;gt;silent! move+&amp;lt;CR&amp;gt;==&#xA;nnoremap &amp;lt;key&amp;gt; :&amp;lt;C-u&amp;gt;silent! move-2&amp;lt;CR&amp;gt;==&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; is used to get rid of any automatically added range (safer but not strictly necessary)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:silent!&lt;/code&gt; prevents useless output&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:move+&lt;/code&gt; moves the line below the line below&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:move-2&lt;/code&gt; moves the line below the second line above&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help c_ctrl-u&#xA;:help :silent&#xA;:help :move&#xA;:help range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Substitute word under cursor&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :s/\&amp;lt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;\&amp;gt;/&#xA;nnoremap &amp;lt;key&amp;gt; :%s/\&amp;lt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;\&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In the command-line, &lt;code&gt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; is used to insert the word under the cursor.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\&amp;lt;pattern\&amp;gt;&lt;/code&gt; restrict matches to whole words so you match &lt;code&gt;pattern&lt;/code&gt; but not &lt;code&gt;mypatterniscool&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help c_ctrl-r_ctrl-w&#xA;:help \&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Substitute selection&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This one is a little trickier: we &lt;em&gt;need&lt;/em&gt; to yank the visual selection because there's no equivalent of &lt;code&gt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; in that context but it's relatively easy to go around that limitation and avoid side effects with a bit of vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetVisualSelection()&#xA;    &quot; save the content of register v (it could be any alphabetic register)&#xA;    let old_reg = getreg(&quot;v&quot;)&#xA;&#xA;    &quot; reselect the visual selection and yank it in register v&#xA;    normal! gv&quot;vy&#xA;&#xA;    &quot; get the content of register v (what we just yanked)&#xA;    let raw_search = getreg(&quot;v&quot;)&#xA;&#xA;    &quot; restore register v&#xA;    call setreg(&quot;v&quot;, old_reg)&#xA;&#xA;    &quot; return a sanitize version of the yanked text&#xA;    &quot; useful if the text contains &quot;special&quot; characters or is multiline&#xA;    return substitute(escape(raw_search, '\/.*$^~[]'), &quot;\n&quot;, '\\n', &quot;g&quot;)&#xA;endfunction&#xA;&#xA;xnoremap &amp;lt;key&amp;gt; :&amp;lt;C-u&amp;gt;s/&amp;lt;C-r&amp;gt;=GetVisualSelection()&amp;lt;CR&amp;gt;/&#xA;xnoremap &amp;lt;key&amp;gt; :&amp;lt;C-u&amp;gt;%s/&amp;lt;C-r&amp;gt;=GetVisualSelection()&amp;lt;CR&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :function&#xA;:help :let&#xA;:help registers&#xA;:help :normal&#xA;:help gv&#xA;:help substitute()&#xA;:help escape()&#xA;:help c_ctrl-r_=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-08-16T09:10:11.467" LastActivityDate="2015-08-16T09:10:11.467" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4356" PostTypeId="1" AcceptedAnswerId="4357" CreationDate="2015-08-16T09:28:28.653" Score="2" ViewCount="570" Body="&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/23715908/3552975&quot;&gt;This answer&lt;/a&gt; teaches me how to yank matches of regex group into one register. But I want to yank two into two different registers. I've tried the following but failed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(regex1\)\(regex2\)/\=setreg('a', submatch(1))\=setreg('b', submatch(2))/n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An error thrown out says &lt;code&gt;invalid expression&lt;/code&gt;. Then I modified it to be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(regex1\)\(regex2\)/\=setreg('a', submatch(1)) | \=setreg('b', submatch(2))/n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I get the error &lt;code&gt;E493 backwards range given&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I do what I want? If so, how should I correct this snippet?&lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-17T07:31:31.227" Title="How can I yank two matches of regex group into two different registers?" Tags="|vimscript|regular-expression|substitute|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4357" PostTypeId="2" ParentId="4356" CreationDate="2015-08-16T09:46:16.947" Score="5" Body="&lt;p&gt;The idea is to give back a single (replace) result; so, concatenate works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(regex1\)\(regex2\)/\=setreg('a', submatch(1)) . setreg('b', submatch(2))/n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-08-16T13:44:20.780" LastActivityDate="2015-08-16T13:44:20.780" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4358" PostTypeId="2" ParentId="4353" CreationDate="2015-08-16T11:02:50.010" Score="8" Body="&lt;p&gt;&lt;strong&gt;Please don't do that&lt;/strong&gt;: This type of title comments is just too heavy and&#xA;doesn't improve the readability of your code. If you really need to create a&#xA;section use light multi lines comments like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&#xA;&quot; Solving a big problem&#xA;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's much easier to read. So now that I gave my totally subjective opinion,&#xA;which you don't have to agree with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here's a function to let you do what you want&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyComment(...)&#xA;&#xA;    &quot; get the arguments properly &#xA;    if (a:0 == 0) &#xA;        let argString = &quot;&quot; &#xA;        let argChar = &quot;-&quot; &#xA;    elseif (a:0 == 1) &#xA;        let argString = a:1 &#xA;        let argChar = &quot;-&quot;&#xA;    elseif (a:0 == 2) &#xA;        let argString = a:1 &#xA;        let argChar = strpart(a:2, 0, 1)&#xA;    else &#xA;        echom &quot;Too many arguments&quot; &#xA;        return&#xA;    endif&#xA;&#xA;    &quot; Get the characters to use at the beginning and the end of the title&#xA;    let result = substitute(&amp;amp;commentstring, &quot;commentstring=&quot;, &quot;&quot;, &quot;&quot;) &#xA;    let resultList = split(result, &quot;%s&quot;) &#xA;    let Comment = resultList[0] &#xA;    if (len(resultList)&amp;gt;1) &#xA;        let EndComment = resultList[1] &#xA;    else &#xA;        let EndComment = Comment&#xA;    endif&#xA;&#xA;    &quot; create the comment title &#xA;    let nb = (80 - strlen(argString) - len(Comment) - len(EndComment)) / 2 &#xA;    let i = 0 &#xA;    let commentString = argString&#xA;&#xA;    while i &amp;lt; nb &#xA;        let i = i + 1 &#xA;        let commentString = argChar . commentString . argChar&#xA;    endwhile&#xA;&#xA;    &quot; append one more char if necessary &#xA;    if strlen(argString) % 2 != 0 &#xA;        let commentString = commentString . argChar &#xA;    endif&#xA;&#xA;    let commentString = Comment . commentString . EndComment&#xA;&#xA;    &quot; Put the title in the buffer &#xA;    exe &quot;:normal o&quot; &#xA;    exe &quot;:normal i&quot; . commentString&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can call the function in 3 different ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:call MyComment()&lt;/code&gt; will insert an &quot;empty title&quot; of 80 characters like this:&#xA;&lt;code&gt;//-------------------------------------------------------------------//&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:call MyComment(&quot;Title section&quot;)&lt;/code&gt; will insert a title with the default &lt;code&gt;-&lt;/code&gt;&#xA;character like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;//--------------------------Title section----------------------------//&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:call MyComment(&quot;Another title&quot;, &quot;.&quot;)&lt;/code&gt; will let you choose the character to&#xA;repeate in your title &lt;em&gt;(If the second string contains more than one&#xA;character, only the first one will be used)&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;//...........................Another title............................//&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also with this function if you are editing a &lt;code&gt;C&lt;/code&gt; file, using &lt;code&gt;:call&#xA;MyComment(&quot;Hello world&quot;)&lt;/code&gt; will insert:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*--------------------------------Hello world---------------------------------*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a &lt;code&gt;java&lt;/code&gt; file you'll get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//--------------------------------Hello world---------------------------------//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And a &lt;code&gt;php&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*--------------------------------Hello world---------------------------------*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Improvements&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For now the function doesn't takes into consideration the indentation level,&#xA;if I get motivation I'll edit my answer otherwise I'll let it as an exercise&#xA;   for the reader ;-) &lt;em&gt;(remember that you can get the indent level of a&#xA;       line with &lt;code&gt;:foldlevel(x)&lt;/code&gt; &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/49.html&quot; rel=&quot;nofollow&quot;&gt;this&#xA;       page&lt;/a&gt;&#xA;       might help)&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It would also be possible the create a command to shorten the call of the&#xA;function, this tricky part might be to handle the optional number of&#xA;arguments. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; In the comments @Peter Rincker suggested &lt;a href=&quot;https://gist.github.com/PeterRincker/6e16e5a82065d7f9809f&quot; rel=&quot;nofollow&quot;&gt;a much more elegant solution&#xA;than mine&lt;/a&gt;. With his&#xA;authorization I'll present here a new version inspired by his function and the&#xA;explanation of the different tricks he used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyComment(...)&#xA;&#xA;    &quot; get the arguments properly&#xA;    let commentText = get(a:000, 0, '')&#xA;    let commentChar = get(a:000, 1, '-')[0]&#xA;&#xA;    &quot; Get the number of char to add on left&#xA;    let len   = (80 - len(commentText) - len(printf(&amp;amp;commentstring, '')))&#xA;    let left  = len / 2&#xA;    let right = len - left&#xA;&#xA;    &quot; force the title with repeat() function and insert it in the buffer&#xA;    put=printf(&amp;amp;commentstring, repeat(commentChar, left) . commentText . repeat(commentChar, right))&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First the part where he gets the arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let commentText = get(a:000, 0, '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#function-argument&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h function-argument&lt;/code&gt;&lt;/a&gt;&#xA;&lt;code&gt;a:000&lt;/code&gt; is a dictionary containing all the arguments, then &lt;code&gt;a:000[0]&lt;/code&gt; is&#xA;equivalent to &lt;code&gt;a:1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;get()&lt;/code&gt; third parameter is a default value.&#xA;This syntax allows to greatly reduce the ugly &lt;code&gt;if...else&lt;/code&gt; structure that I&#xA;originally used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another cool trick is to use &lt;code&gt;printf(&amp;amp;commentstring, '')&lt;/code&gt; to replace the &lt;code&gt;%s&lt;/code&gt; part&#xA;of the string. Once again much cleaner than my &lt;code&gt;substitute&lt;/code&gt; workaround&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally the reason I used his function: the use of &lt;code&gt;repeat()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf(&amp;amp;commentstring, repeat(commentChar, left) . commentText . repeat(commentChar, right))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function repeat the expression passed as first parameter, the number of time&#xA;passed as second parameter and return the concatenated result. This way in a&#xA;single line two loops are written in a very readible format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks to Peter for the improved version!&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-09-24T16:10:26.867" LastActivityDate="2015-09-24T16:10:26.867" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4359" PostTypeId="2" ParentId="4346" CreationDate="2015-08-16T16:09:39.083" Score="5" Body="&lt;p&gt;&lt;strong&gt;EDIT 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've improved the function, the encoding should be working on all of the help topics and it is now available as a &lt;a href=&quot;https://github.com/statox/GOD.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an updated version of the function allowing to call vimhelp.appspot.com. It has several advantages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can type a tag in the short form, the link created will be the full one (ex: &lt;code&gt;GOD @&amp;lt;!&lt;/code&gt; will generate a line &lt;code&gt;[:h /\@&amp;lt;!](link)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The function encodes the characters so that the url will work. These substitutions are based on a list which can easily evolve.&lt;/li&gt;&#xA;&lt;li&gt;It has no python dependency.&lt;/li&gt;&#xA;&lt;li&gt;It uses vimhelp.appspot.com instead of vimdoc.sourceforge as did the old version.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetOnlineDoc(string)&#xA;    &quot; Go to specified help tag locally&#xA;    execute &quot;h &quot; . a:string&#xA;&#xA;    &quot; Get the help filename&#xA;    let f = expand(&quot;%:t&quot;)&#xA;&#xA;    &quot; Get the tag&#xA;    let tag = expand('&amp;lt;cword&amp;gt;')&#xA;&#xA;    &quot; URL encoding (taken from https://github.com/idbrii/vim-textconv/blob/master/autoload/textconv/urlencode.vim)&#xA;    let dict = [&#xA;        \['%21','!'],&#xA;        \['%22',' '],&#xA;        \['%23','#'],&#xA;        \['%24','\$'],&#xA;        \['%26','&amp;amp;'],&#xA;        \['%27',&quot;'&quot;],&#xA;        \['%28','('],&#xA;        \['%29',')'],&#xA;        \['%2A','*'],&#xA;        \['%2B','+'],&#xA;        \['%2C',','],&#xA;        \['%2D','-'],&#xA;        \['%2F','/'],&#xA;        \['%3A',':'],&#xA;        \['%3B',';'],&#xA;        \['%3C','&amp;lt;'],&#xA;        \['%3D','='],&#xA;        \['%3E','&amp;gt;'],&#xA;        \['%3F','?'],&#xA;        \['%40','@'],&#xA;        \['%5B','['],&#xA;        \['%5C','\'],&#xA;        \['%5D',']'],&#xA;        \['%5E','\^'],&#xA;        \['%60','`'],&#xA;        \['%7B','{'],&#xA;        \['%7C','|'],&#xA;        \['%7D','}'],&#xA;        \['%7E','\~']&#xA;    \]&#xA;&#xA;    let s = tag&#xA;    for i in dict&#xA;        let s = substitute(s, i[1], i[0], 'g')&#xA;    endfor&#xA;&#xA;    &quot; Create the link&#xA;    let link = &quot;[`:h &quot; . tag . &quot;`](http://vimhelp.appspot.com/&quot; . f . &quot;.html#&quot; . s . &quot;)&quot;&#xA;&#xA;    &quot; Put it in the clipboard register&#xA;    if has('win32')&#xA;        let @* = link&#xA;    else&#xA;        let @+ = link&#xA;    endif&#xA;&#xA;    &quot; Optional, close the opened help file&#xA;    &quot;execute &quot;bd&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the same line is still in use to create the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=help GOD call GetOnlineDoc(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original answer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use a full vimscript solution which is a combination of a function and a &#xA;command. It use the site &#xA;&lt;a href=&quot;http://vimdoc.sourceforge.net&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net&lt;/a&gt; instead of the&#xA;one you requested but it doesn't work too bad:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetOnlineDoc(string)&#xA;&#xA;    &quot; Go to specified help tag locally&#xA;    execute &quot;h &quot; . a:string&#xA;&#xA;    &quot; Get the help filename without the &quot;.txt&quot; extension&#xA;    let filename = expand(&quot;%:t:r&quot;)&#xA;&#xA;    &quot; Create the link&#xA;    let link = &quot;http://vimdoc.sourceforge.net/htmldoc/&quot; . filename . &quot;.html#&quot; . a:string&#xA;&#xA;    &quot; Put it in the clipboard register&#xA;    let @* = link&#xA;&#xA;    &quot; Optional, close the opened help file&#xA;    &quot;execute &quot;bd&quot;&#xA;endfunction&#xA;&#xA;command! -nargs=1 -complete=help GOD call GetOnlineDoc(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 1&lt;/strong&gt; Depending on your system, you might need to replace the line &#xA;&lt;code&gt;let @* = link&lt;/code&gt; with &lt;code&gt;let @+ = link&lt;/code&gt; to get the link in the clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 2&lt;/strong&gt; It doesn't search for the last tag searched in history when no&#xA;argument is provided but I think it is possible to add this feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function simply opens the help topic of the tag taken as argument, get the&#xA;help file name and forge the corresponding url on the site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command has the parameter &lt;code&gt;-complete=help&lt;/code&gt; to avoid passing to the function a&#xA;tag which doesn't exists. For your example with &lt;code&gt;'magic'&lt;/code&gt; and &lt;code&gt;/magic&lt;/code&gt; the user&#xA;simply has to select the right tag to get the corresponding url.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It still has two main issues:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Some tags with special characters might not always be treated correctly&#xA;&lt;em&gt;(I haven't experienced this problem really often but it still might&#xA;happen)&lt;/em&gt;. But it still work for tags like &lt;code&gt;:ls&lt;/code&gt; or &lt;code&gt;/magic&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It doesn't check if the forged url actually exists.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-02-03T21:36:38.063" LastActivityDate="2017-02-03T21:36:38.063" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4360" PostTypeId="1" CreationDate="2015-08-16T16:49:15.913" Score="1" ViewCount="229" Body="&lt;p&gt;I have started using neocomplete and there's one thing that confuses me. What's actually the difference between&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;neocomplete#smart_close_popup()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;neocomplete#cancel_popup()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am definitely not an expert at vimscript, but to me this looks like they are exactly the same:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! neocomplete#smart_close_popup()&#xA;  return neocomplete#mappings#smart_close_popup()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! neocomplete#mappings#smart_close_popup() &quot;{{{&#xA;  return neocomplete#mappings#cancel_popup()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! neocomplete#mappings#cancel_popup() &quot;{{{&#xA;  let neocomplete = neocomplete#get_current_neocomplete()&#xA;  let neocomplete.complete_str = ''&#xA;  let neocomplete.skip_next_complete = 1&#xA;&#xA;  return pumvisible() ? &quot;\&amp;lt;C-e&amp;gt;&quot; : ''&#xA;endfunction&#xA;&quot;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tracked those down in the github repo. Anyway, does &lt;code&gt;smart_close_popup&lt;/code&gt; just call &lt;code&gt;cancel_popup&lt;/code&gt;? If yes, is there anything smart about that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, when I do &lt;code&gt;:map &amp;lt;C-e&amp;gt;&lt;/code&gt; or &lt;code&gt;:map &amp;lt;C-h&amp;gt;&lt;/code&gt; it says &lt;code&gt;No mapping found&lt;/code&gt; although I clearly see are bound to stuff (and they do stuff when I test them).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd love to get some clarification on this.&lt;/p&gt;&#xA;" OwnerUserId="3200" LastEditorUserId="51" LastEditDate="2016-03-02T16:06:44.287" LastActivityDate="2016-03-02T16:06:44.287" Title="Difference between smart_close_popup() and cancel_popup() in neocomplete?" Tags="|key-bindings|autocompletion|plugin-neocomplete|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="4361" PostTypeId="2" ParentId="4353" CreationDate="2015-08-16T16:55:47.070" Score="5" Body="&lt;p&gt;This is a perfect use case for &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow&quot;&gt;ultisnips&lt;/a&gt; with Python interpolation.  A sketch of a snippet for the first header might look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global !p&#xA;from math import floor, ceil&#xA;&#xA;def left(lng, fill, s):&#xA;    count = int(floor((lng - len(s) - 6) / 2.0))&#xA;    if count &amp;lt; 0: count = 0&#xA;    return fill * count&#xA;&#xA;def right(lng, fill, s):&#xA;    count = int(ceil((lng - len(s) - 6) / 2.0))&#xA;    if count &amp;lt; 0: count = 0&#xA;    return fill * count&#xA;endglobal&#xA;&#xA;snippet com &quot;Centered comments&quot; b&#xA;//`!p snip.rv = left(80, '=', t[1])` ${1:Solving a big problem} `!p snip.rv = right(80, '=', t[1])`//&#xA;$0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-08-16T16:55:47.070" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4362" PostTypeId="1" CreationDate="2015-08-16T17:10:03.613" Score="1" ViewCount="62" Body="&lt;p&gt;I am facing the following problem: a function, triggered by a &lt;code&gt;:nnoremap&lt;/code&gt; inserts a few lines into a buffer. Since I have folding enabled with &lt;code&gt;foldexpr=...&lt;/code&gt; and the inserted text contains this expression, the inserted text is folded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could stop this unwanted behaviour by setting &lt;code&gt;nofoldenable&lt;/code&gt;. Yet, if I do that, the already existing folds are opened. This is also not what I want. The existing folds should stay as the are, opened or closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is it possible to tell vim somehow that the inserted text is to be inserted without trying to fold it?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="1841" LastEditDate="2015-08-16T17:22:56.310" LastActivityDate="2015-08-23T21:34:13.233" Title="Is it possible for a :map to insert text without fold-closing the inserted text AND leaving the other folds as they are?" Tags="|key-bindings|insert-mode|folding|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4363" PostTypeId="1" AcceptedAnswerId="4365" CreationDate="2015-08-16T18:31:42.170" Score="2" ViewCount="109" Body="&lt;p&gt;I want to use visual block mode (ctl-v) to select all the comments but none of the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = 1             // short comment&#xA;b = 2             // this one is a longer comment&#xA;c = 3             // shortest&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My selection is marked with X characters here. Notice that if I start at the top-left my selection is unsatisfactory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = 1             XXXXXXXXXXXXXXXX&#xA;b = 2             XXXXXXXXXXXXXXXX longer comment&#xA;c = 3             XXXXXXXXXXX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I start middle-left I lose either the first or third line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = 1             // short comment&#xA;b = 2             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#xA;c = 3             XXXXXXXXXXX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And so on. I'm missing something here. What is the secret? I've tried :help and searched here and Google.&lt;/p&gt;&#xA;" OwnerUserId="2985" LastEditorUserId="7161" LastEditDate="2016-05-02T12:12:14.683" LastActivityDate="2016-05-02T12:12:14.683" Title="Visual block. Some right-end selections seem impossible" Tags="|visual-mode|visual-block|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4364" PostTypeId="2" ParentId="4363" CreationDate="2015-08-16T18:57:45.313" Score="6" Body="&lt;p&gt;One (*) secret is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set virtualedit=block&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... in your &lt;code&gt;vimrc&lt;/code&gt; :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;:h virtualedit&lt;/code&gt; will explain everything). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A disadvantage of this method: when yanking, you get trailing spaces on the shorter lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) The other is in the answer provided by @&lt;a href=&quot;https://vi.stackexchange.com/users/54/romainl&quot;&gt;romainl&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;BTW, for &lt;strong&gt;the secret of the golden rivet&lt;/strong&gt;, see &lt;a href=&quot;https://www.youtube.com/watch?v=vf6FRtmZewg&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-08-17T09:31:43.490" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4365" PostTypeId="2" ParentId="4363" CreationDate="2015-08-16T19:06:16.387" Score="9" Body="&lt;p&gt;The secret is to press &lt;code&gt;$&lt;/code&gt; after you have expanded your block vertically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;jj$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or to press &lt;code&gt;$&lt;/code&gt; before expanding your block vertically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;$jj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well, &lt;code&gt;$&lt;/code&gt; is the secret.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sup&gt;&lt;sup&gt;…which is not &lt;em&gt;that&lt;/em&gt; surprising, after all.&lt;/sup&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-08-16T19:06:16.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4366" PostTypeId="1" AcceptedAnswerId="4380" CreationDate="2015-08-16T19:11:34.040" Score="6" ViewCount="4077" Body="&lt;p&gt;I'm trying to create a function mapping that takes a count, in this case the number of lines to yank to the system clipboard.   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! Clipboard()&#xA;  echo 'Clipboard function called'&#xA;  if v:count is 0&#xA;    normal &quot;+yy&#xA;  else&#xA;    exec 'normal ' . v:count . '&quot;+yy'&#xA;  endif&#xA;endfunc&#xA;nmap YY :call Clipboard()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem is it's being called multiple times when a count is provided and even then the clipboard ends up with only one entry. Pretty bizarre.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. with this text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;first line&#xA;second line&#xA;third line&#xA;fourth line&#xA;fifth line&#xA;sixth line&#xA;seventh line&#xA;eighth line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I place the cursor at 'first line' and hit '4YY' and the clipboard ends up with these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fourth line&#xA;fifth line&#xA;sixth line&#xA;seventh line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How's this happening?&lt;br&gt;&#xA;The messages printed are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4 lines yanked&#xA;4 lines yanked&#xA;4 lines yanked&#xA;4 lines yanked&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the function is really being called 4 times like the message says, why do I have only one entry in the clipboard?&lt;/p&gt;&#xA;" OwnerUserId="3201" LastEditorUserId="343" LastEditDate="2017-12-06T11:24:42.677" LastActivityDate="2017-12-06T11:24:42.677" Title="Creating a Vim function mapping that takes a count" Tags="|key-bindings|range|count|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4367" PostTypeId="2" ParentId="464" CreationDate="2015-08-17T00:40:40.340" Score="8" Body="&lt;p&gt;You can use vim-airline. This plugin has a behavior that maybe fix you problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See line &lt;a href=&quot;https://github.com/bling/vim-airline/blob/master/doc/airline.txt#L470-479&quot; rel=&quot;noreferrer&quot;&gt;470-479 in airline.txt&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will not change the buffer numbers, but you can select a buffer from left to right by the row number in the tabline.&#xA;This is my setting for airline in &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;set airline &#xA;let g:airline#extensions#tabline#enabled = 1&#xA;let g:airline#extensions#tabline#tab_nr_type = 1 &quot; tab number&#xA;let g:airline#extensions#tabline#show_tab_nr = 1&#xA;let g:airline#extensions#tabline#formatter = 'default'&#xA;let g:airline#extensions#tabline#buffer_nr_show = 1&#xA;let g:airline#extensions#tabline#fnametruncate = 16&#xA;let g:airline#extensions#tabline#fnamecollapse = 2&#xA;&#xA;let mapleader=&quot;,&quot;&#xA;&#xA;let g:airline#extensions#tabline#buffer_idx_mode = 1&#xA;&#xA;nmap &amp;lt;leader&amp;gt;1 &amp;lt;Plug&amp;gt;AirlineSelectTab1&#xA;nmap &amp;lt;leader&amp;gt;2 &amp;lt;Plug&amp;gt;AirlineSelectTab2&#xA;nmap &amp;lt;leader&amp;gt;3 &amp;lt;Plug&amp;gt;AirlineSelectTab3&#xA;nmap &amp;lt;leader&amp;gt;4 &amp;lt;Plug&amp;gt;AirlineSelectTab4&#xA;nmap &amp;lt;leader&amp;gt;5 &amp;lt;Plug&amp;gt;AirlineSelectTab5&#xA;nmap &amp;lt;leader&amp;gt;6 &amp;lt;Plug&amp;gt;AirlineSelectTab6&#xA;nmap &amp;lt;leader&amp;gt;7 &amp;lt;Plug&amp;gt;AirlineSelectTab7&#xA;nmap &amp;lt;leader&amp;gt;8 &amp;lt;Plug&amp;gt;AirlineSelectTab8&#xA;nmap &amp;lt;leader&amp;gt;9 &amp;lt;Plug&amp;gt;AirlineSelectTab9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My tab line:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/TsoNI.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TsoNI.png&quot; alt=&quot;My tab line&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3203" LastEditorUserId="3203" LastEditDate="2015-08-19T07:44:17.797" LastActivityDate="2015-08-19T07:44:17.797" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4368" PostTypeId="1" AcceptedAnswerId="4388" CreationDate="2015-08-17T00:49:33.460" Score="2" ViewCount="212" Body="&lt;p&gt;When editing an Haskell file, I want to configure a comment format &lt;code&gt;{- -}&lt;/code&gt; such that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{- &amp;lt;cr&amp;gt;&#xA; - &amp;lt;cr&amp;gt;&#xA; - -}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work as expected (but almost there):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{- &amp;lt;cr&amp;gt;&#xA;- &amp;lt;cr&amp;gt;&#xA;- -}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;notice that after hitting &lt;kbd&gt;enter&lt;/kbd&gt;, the &lt;code&gt;-&lt;/code&gt; doesn't align. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What option should I use to make it aligned?&lt;/p&gt;&#xA;" OwnerUserId="1097" LastEditorUserId="1841" LastEditDate="2015-08-17T10:22:16.220" LastActivityDate="2015-08-18T00:56:37.270" Title="How can I configure a three-piece comment?" Tags="|comments|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4369" PostTypeId="2" ParentId="4353" CreationDate="2015-08-17T06:48:47.237" Score="4" Body="&lt;h3&gt;Just don't&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I agree with @statox, &quot;just don't do this&quot;. However if you do then @Sato Katsura is also correct that the best way is probably to use some snippets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you do not want to use snippets here are some native Vim methods.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;'virtualedit'&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can &lt;code&gt;:set virutaledit=all&lt;/code&gt; to make it so you can insert text anywhere without worrying about pesky line lengths and spaces. This is great for ASCII art or making comment boxes (use &lt;code&gt;r&lt;/code&gt;). Use &lt;code&gt;|&lt;/code&gt; to jump to a specific column, e.g. &lt;code&gt;80|&lt;/code&gt; to jump to column 80.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27virtualedit%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'virtualedit'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#r&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h r&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#bar&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h |&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Overwrite with &lt;code&gt;R&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;R&lt;/code&gt; command to replace/overwrite characters. This is a great way to put in your text without having to remove and tinker with your new comment line's length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#R&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h R&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Use &lt;code&gt;:center&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:center&lt;/code&gt; command will center text (by default to 80 chars). This isn't directly useful however you can use it to get your positioning without doing any hard work. Just create a line with your text then execute &lt;code&gt;:center&lt;/code&gt;. Now that you know the starting column you can use &lt;code&gt;R&lt;/code&gt; on your actual comment line. Bonus points for using &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt; to paste the text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:center&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :center&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-R&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Re-centering&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Re-centering can be accomplished using &lt;code&gt;:center&lt;/code&gt;, &lt;code&gt;r&lt;/code&gt;, &lt;code&gt;R&lt;/code&gt;, and &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt;. (All the &lt;code&gt;r&lt;/code&gt;'s!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting on the start of the word, do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v/-\+/b-&amp;lt;cr&amp;gt;ygvr-O&amp;lt;c-r&amp;gt;0&amp;lt;esc&amp;gt;:center&amp;lt;cr&amp;gt;jR&amp;lt;c-r&amp;gt;0&amp;lt;esc&amp;gt;kdd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Probably best to make this a command or mapping. Note it has quite a few side-effects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#r&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h r&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#R&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h R&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-R&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#O&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h O&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:center&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :center&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /&lt;/code&gt;&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#search-offset&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h search-offset&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#registers&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h registers&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#quote0&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h quote0&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#:noh&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :noh&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Re-centering with a substitution or &quot;how I learned to abuse regex backtracking&quot;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Another approach to re-centering is to use a substitution, &lt;code&gt;:s&lt;/code&gt;, with a sub-replace-expression.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v(-+)(.{-})(-+)/\=substitute(submatch(1).submatch(3),'\v(-*)(\1-=)','\1'.escape(submatch(2),'&amp;amp;~').'\2','')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Overview&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Capture the text and the leading and trailing characters, &lt;code&gt;-&lt;/code&gt; in this case. We use a sub-replace-expression to do another substitution to divide up the dashes in half. This balancing act is done via the regex engine's backtracking because math is hard (let's go shopping).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using very magic, &lt;code&gt;\v&lt;/code&gt;, to simplify regex. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27magic%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'magic'&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Using a sub-replace-expression, &lt;code&gt;\=&lt;/code&gt;. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h sub-replace-expression&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;{-}&lt;/code&gt; is a non-greedy version of &lt;code&gt;*&lt;/code&gt;. Similar to &lt;code&gt;*?&lt;/code&gt; in Perl-speak. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#E60&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\{-&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Learn more about this regex trick here: &lt;a href=&quot;https://stackoverflow.com/a/15844169/438329&quot;&gt;An easy way to center text between first and last non-white word in vim?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Possibly use &lt;code&gt;:keeppatterns&lt;/code&gt; to prevent side-effects.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Probably best to make this into a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -range -bar CenterComment execute &amp;lt;line1&amp;gt;.','.&amp;lt;line2&amp;gt;.'s/\V\^'.printf(escape(&amp;amp;commentstring, '\/'), '\zs\(\.\=\)\(\1\*\)\(\.\{-}\)\(\1\*\)\ze').&quot;\\$/\\=substitute(submatch(1).submatch(2).submatch(4),'\\v(.*)(\\1.=)','\\1'.escape(submatch(3),'&amp;amp;~').'\\2','')/&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can just use &lt;code&gt;:CenterComment&lt;/code&gt; on the comment line to recenter text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:s&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :s&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h sub-replace-expression&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#submatch()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h submatch()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#escape()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h escape()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27magic%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'magic'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#E60&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\{-&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5C=&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\=&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5Czs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\zs&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:command&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :command&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#printf()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h printf()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27commentstring%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'commentstring'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Thoughts&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Once again, just don't worry about this. There are plenty other things to worry about, e.g. your code and quality of documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally if I was going to use these kind of comments I would use some kind of snippet and &lt;code&gt;:CenterComment&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-17T11:22:59.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4370" PostTypeId="2" ParentId="4362" CreationDate="2015-08-17T07:02:20.007" Score="1" Body="&lt;p&gt;You can temporarily disable the &lt;code&gt;foldexpr&lt;/code&gt; by setting &lt;code&gt;foldmethod&lt;/code&gt; to &lt;code&gt;manual&lt;/code&gt; during the execution of the function. You could do this in your function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyMappedFunction(...)&#xA;  let l:foldmethod=&amp;amp;foldmethod &#xA;  setlocal foldmethod=manual&#xA;&#xA;  &quot; ... function content ...&#xA;&#xA;  let foldmethod=l:foldmethod&#xA;end function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the old &lt;code&gt;foldmethod&lt;/code&gt; is saved in order to restore it after the function is finished.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2015-08-23T21:34:13.233" LastActivityDate="2015-08-23T21:34:13.233" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4371" PostTypeId="2" ParentId="4368" CreationDate="2015-08-17T10:19:55.163" Score="2" Body="&lt;p&gt;The behavior of the comments is controled by the &lt;code&gt;comments&lt;/code&gt;options (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#format-comments&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h format-comments&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that your options are not properly configured, if you use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set comments=s1:{-,m:-,e:-}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your problem should be solved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets decompose the options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;s&lt;/code&gt; is for the start of three-piece comments&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1&lt;/code&gt; defines the offset to add to the middle and end part of the comment&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:{-&lt;/code&gt; defines the comment string of the first part of the three-piece comment.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;m&lt;/code&gt; is for the middle part of the three-piece comments&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;e&lt;/code&gt; is (surprisingly) for the end of the three-piece comments.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is a very minimal version of this option, please see the help topic linked at the beggining of the post to see all the magic you can do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Originally my &lt;code&gt;comments&lt;/code&gt; option was set to &lt;code&gt;s1fl:{-,mb:-,ex:-},:--&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-08-17T10:19:55.163" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4372" PostTypeId="1" AcceptedAnswerId="4376" CreationDate="2015-08-17T11:25:19.223" Score="5" ViewCount="1404" Body="&lt;p&gt;Is is possible to search for a regexp in &lt;strong&gt;only&lt;/strong&gt; the &lt;em&gt;current line&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is some text that I have written. Can you find this word?&#xA;                                                    ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line contains many &lt;code&gt;t&lt;/code&gt;'s. I would like to search forward for &lt;code&gt;this&lt;/code&gt; so the cursor ends up at the caret (the &lt;code&gt;^&lt;/code&gt; character).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with using &lt;code&gt;/&lt;/code&gt; is that if the pattern does not match in the line the cursor will jump to another part of the buffer. I do not want that behavior. I want the search to stop if there is no match in the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can of course search forward using &lt;code&gt;ft&lt;/code&gt; and press &lt;code&gt;;&lt;/code&gt; repeatedly but if I were to record macro that would make the macro inconsistent when executed at different locations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most obvious solution would be &lt;code&gt;:./this&lt;/code&gt; but that did not work for me (it finds matches at other lines in the buffer). So it appears to me that Vim is lacking this feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know of a way to do what I am describing?&lt;/p&gt;&#xA;" OwnerUserId="3032" LastEditorUserId="51" LastEditDate="2015-08-17T11:34:40.640" LastActivityDate="2022-07-21T14:26:24.830" Title="How to search forward for pattern in the current line? Like `/` and `?` but stop at end of line" Tags="|regular-expression|search|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4373" PostTypeId="2" ParentId="4372" CreationDate="2015-08-17T11:39:42.863" Score="2" Body="&lt;p&gt;How about using &lt;code&gt;:s/this//cI&lt;/code&gt;? Substitutes &lt;code&gt;this&lt;/code&gt; on the current line by it's own occurrence (an empty replacement string just uses the match), case sensitive (that's the &lt;code&gt;I&lt;/code&gt;). Using &lt;code&gt;c&lt;/code&gt; for confirmation, so the cursor actually jumps to the match, you'd have to press &lt;code&gt;q&lt;/code&gt; afterwards to stop the substitute-command. It has the additional advantage that if you have several matches on a line, you just press &lt;code&gt;y&lt;/code&gt; until you are where you want to be.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="1296" LastEditDate="2015-08-17T12:08:24.197" LastActivityDate="2015-08-17T12:08:24.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4374" PostTypeId="2" ParentId="4372" CreationDate="2015-08-17T11:41:07.213" Score="4" Body="&lt;p&gt;You can use &lt;code&gt;\%l&lt;/code&gt; to mach a specific line, but that means you would have to constantly change your pattern. e.g. &lt;code&gt;/\%42lfoo&lt;/code&gt;. With a quick mapping you can start your search with the line number injected into your search:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; /\%&amp;lt;c-r&amp;gt;=line('.')&amp;lt;cr&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As @Yegappan Lakshmanan noted, you can use &lt;code&gt;\%.l&lt;/code&gt; on newer version of Vim:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; /\%.l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:h /\%l &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2022-07-21T14:26:24.830" LastActivityDate="2022-07-21T14:26:24.830" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4375" PostTypeId="2" ParentId="4353" CreationDate="2015-08-17T12:02:36.197" Score="2" Body="&lt;p&gt;Here's a shorter implementation, interactive (will ask for the comment), inspired from the old-and-true &lt;a href=&quot;http://www.ibm.com/developerworks/library/l-vim-script-2/&quot; rel=&quot;nofollow&quot;&gt;IBM &quot;Vim Scripting&quot; guide&lt;/a&gt; (part 2, listings 13 &amp;amp; 14) and adapted for the OP request:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ========= fancy comments ====================================================&#xA;&quot; inspired from http://www.ibm.com/developerworks/library/l-vim-script-2/&#xA;&quot; (listings 13 &amp;amp; 14)&#xA;function! CommentBlock(comment, intro, end, box_char, ...)&#xA;    &quot; linewdith is 1ist computed from the 'textwidth' if set, 80 if not&#xA;    let linewidth = &amp;amp;textwidth&amp;gt; 0? &amp;amp;textwidth : 80&#xA;    &quot; but can be overwritten by the optional argument value:&#xA;    let linewidth = a:0 &amp;gt;= 1 ? a:1 : linewidth&#xA;&#xA;    let comwidth = strlen(a:comment) + 2&#xA;    let boxwidth1 = (linewidth - comwidth - len(a:intro) - len(a:end)) / 2&#xA;    let boxwidth1 = boxwidth1&amp;gt;0 ? boxwidth1 : 0&#xA;&#xA;    let boxwidth2 = (linewidth - len(a:intro) -len(a:end) - boxwidth1 - comwidth)&#xA;    return a:intro . repeat(a:box_char, boxwidth1) . ' ' . a:comment&#xA;                \ . ' ' .repeat(a:box_char, boxwidth2) . a:end&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No indentation support, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Mapping example&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; //* &amp;lt;C-R&amp;gt;=CommentBlock(input(&quot;Comment&amp;gt; &quot;), '//', '//', '*')&amp;lt;cr&amp;gt;&#xA;inoremap &amp;lt;silent&amp;gt; //= &amp;lt;C-R&amp;gt;=CommentBlock(input(&quot;Comment&amp;gt; &quot;), '//', '//', '=')&amp;lt;cr&amp;gt;&#xA;inoremap &amp;lt;silent&amp;gt; //- &amp;lt;C-R&amp;gt;=CommentBlock(input(&quot;Comment&amp;gt; &quot;), '//', '//', '-')&amp;lt;cr&amp;gt;&#xA;inoremap &amp;lt;silent&amp;gt; //x&#xA;            \ &amp;lt;C-R&amp;gt;=CommentBlock(input(&quot;Comment (40)&amp;gt; &quot;), '/*', '*/',  'x', 40)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Results&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//******************************* hello world ********************************//&#xA;//============================ this is a comment? ============================//&#xA;//------------------------------ minus for you -------------------------------//&#xA;/*xxxxxxxxxxx asdfasdfasdf xxxxxxxxxxx*/    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-08-17T12:10:36.343" LastActivityDate="2015-08-17T12:10:36.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4376" PostTypeId="2" ParentId="4372" CreationDate="2015-08-17T12:27:00.473" Score="6" Body="&lt;p&gt;You can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call search('find', '', line('.'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... where &lt;code&gt;'find'&lt;/code&gt;is the pattern. The cursor will be moved to the start of the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample interactive mapping (not perfect):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;/ :call search(input(&quot;Pattern: &quot;), '', line('.'))&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Also&lt;/strong&gt;: with several plugins that enhance Vim grammar (&lt;a href=&quot;https://github.com/osyo-manga/vim-operator-search&quot; rel=&quot;noreferrer&quot;&gt;operator-search&lt;/a&gt;, &lt;a href=&quot;https://github.com/kana/vim-textobj-line&quot; rel=&quot;noreferrer&quot;&gt;textobj-line&lt;/a&gt; (*)), you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map g/ &amp;lt;Plug&amp;gt;(operator-search)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/il&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... i.e. &quot;go search for pattern (&lt;code&gt;g/&lt;/code&gt;) in this line (&lt;code&gt;il&lt;/code&gt;)&quot;. But also:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/is&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(search in this sentence). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, visually select a range, move cursor to the end, hit &lt;code&gt;g/&lt;/code&gt; to search &lt;em&gt;inside the visual selection&lt;/em&gt;. Press &lt;code&gt;n&lt;/code&gt; for next match, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) Note that these plugins depend on their generic counterparts, Kana's &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;noreferrer&quot;&gt;textobj-user&lt;/a&gt; and &lt;a href=&quot;https://github.com/kana/vim-operator-user/&quot; rel=&quot;noreferrer&quot;&gt;operator-user&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-08-17T14:24:30.277" LastActivityDate="2015-08-17T14:24:30.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4377" PostTypeId="2" ParentId="4292" CreationDate="2015-08-17T13:36:57.897" Score="3" Body="&lt;h1&gt;tl;dr&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You cannot filter the buffer at its creation, you should wait until you have &#xA;more informations.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;First attempt&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I used the &lt;code&gt;:debug NERDTree&lt;/code&gt; command to see all the calls that this function&#xA;makes. When trying to stop it before the end I noticed something : A buffer was&#xA;created, without name, without filetype. And it had the position/size of the&#xA;nerdtree buffer (left split about 20 columns width).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It got me thinking that maybe you are trying to filter a buffer before it get's&#xA;enough informations. So the buffer doesn't &lt;em&gt;know&lt;/em&gt; that it will be a nerdtree&#xA;buffer yet.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Second attempt&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Instead of debugging manually I did a little log function that allows me to see&#xA;the flow of events when calling &lt;code&gt;:NERDTree&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup DebugGroup&#xA;  autocmd!&#xA;  autocmd BufAdd      * :call s:Debug('BufAdd')&#xA;  autocmd BufCreate   * :call s:Debug('BufCreate')&#xA;  &quot; idem for BufDelete BufWipeout BufFilePre BufFilePost BufEnter BufLeave BufWinEnter&#xA;  &quot;          BufWinLeave BufUnload BufHidden BufNew FileType Syntax&#xA;augroup END&#xA;&#xA;function! s:Debug(message) abort&#xA;  silent execute '!echo '.a:message.' '.bufnr(&quot;%&quot;).' &amp;gt;&amp;gt; debug'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sample result : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BufNew 1&#xA;BufAdd 1&#xA;BufCreate 1&#xA;BufLeave 1&#xA;BufEnter 5&#xA;BufWinEnter 5&#xA;BufDelete 5&#xA;BufWipeout 5&#xA;BufUnload 5&#xA;BufNew 5&#xA;BufAdd 5&#xA;BufCreate 5&#xA;BufEnter 5&#xA;BufWinEnter 5&#xA;BufDelete 5&#xA;Syntax 5&#xA;FileType 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see here that the buffer &lt;code&gt;1&lt;/code&gt; is the original buffer and the &lt;code&gt;5&lt;/code&gt; is the&#xA;nerdtree one. And to create the nerdtree buffer, there are : two times the&#xA;events &lt;code&gt;BufEnter&lt;/code&gt;, &lt;code&gt;BufDelete&lt;/code&gt; and &lt;code&gt;BufWinEnter&lt;/code&gt;. It's kind of strange why&#xA;nerdtree needs to open and delete two times the buffer to get working (but I'm&#xA;sure they have a good reason).&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Third attempt&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This time I used the methods that you provide in your script and in your&#xA;question to add details to the log : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:DebugBuffer(event)&#xA;    let newBufNr = bufnr(&quot;%&quot;)&#xA;    let isListed = buflisted(newBufNr)&#xA;    let isAlreadyInManager = (index(g:BuffersManager[tabpagenr()], newBufNr) == -1)?0:1&#xA;    let isNERDTreeBuffer = (bufname(&quot;%&quot;) =~ &quot;NERD_Tree_&quot;)?1:0&#xA;    let newBufSyntax = &amp;amp;ft&#xA;&#xA;    call s:Debug('&quot;'.a:event.' ['.newBufNr.'/'.bufname(&quot;%&quot;).' '.newBufSyntax.'] listed : '.isListed.' / managed : '.isAlreadyInManager.' / NERDTree '.isNERDTreeBuffer.'&quot;')&#xA;    call s:Debug('&quot;=&amp;gt; '.isListed.' &amp;amp; '.!isAlreadyInManager.' &amp;amp; '.!isNERDTreeBuffer.'&quot;')&#xA;endfunction&#xA;&#xA;augroup BuffersManagerGroup&#xA;  autocmd!&#xA;  autocmd BufAdd      * :call s:DebugBuffer('BufAdd')&#xA;  autocmd BufCreate   * :call s:DebugBuffer('BufCreate')&#xA;  &quot; idem for BufDelete BufWipeout BufFilePre BufFilePost BufEnter BufLeave BufWinEnter&#xA;  &quot;          BufWinLeave BufUnload BufHidden BufNew FileType Syntax&#xA;augroup END&#xA;&#xA;function! s:Debug(message) abort&#xA;  silent execute '!echo '.a:message.' &amp;gt;&amp;gt; debug'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The syntax is the following : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Event [BufferNumber/Filename FileType] listed : isListed / managed : isManaged / NERDTree : isNERDTree&#xA;=&amp;gt; litteral condition to be tested&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;isNERDTree&lt;/code&gt; is checked using the name, as you did in your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The log is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BufNew [4/betterTabs.vim vim] listed : 1 / managed : 0 / NERDTree 0&#xA;=&amp;gt; 1 &amp;amp; 1 &amp;amp; 1&#xA;BufAdd [4/betterTabs.vim vim] listed : 1 / managed : 1 / NERDTree 0&#xA;=&amp;gt; 1 &amp;amp; 0 &amp;amp; 1&#xA;BufCreate [4/betterTabs.vim vim] listed : 1 / managed : 1 / NERDTree 0&#xA;=&amp;gt; 1 &amp;amp; 0 &amp;amp; 1&#xA;BufLeave [4/betterTabs.vim vim] listed : 1 / managed : 1 / NERDTree 0&#xA;=&amp;gt; 1 &amp;amp; 0 &amp;amp; 1&#xA;BufEnter [5/ ] listed : 1 / managed : 0 / NERDTree 0&#xA;=&amp;gt; 1 &amp;amp; 1 &amp;amp; 1&#xA;BufWinEnter [5/ ] listed : 1 / managed : 1 / NERDTree 0&#xA;=&amp;gt; 1 &amp;amp; 0 &amp;amp; 1&#xA;BufDelete [5/ ] listed : 1 / managed : 1 / NERDTree 0&#xA;=&amp;gt; 1 &amp;amp; 0 &amp;amp; 1&#xA;BufWipeout [5/ ] listed : 1 / managed : 1 / NERDTree 0&#xA;=&amp;gt; 1 &amp;amp; 0 &amp;amp; 1&#xA;BufUnload [5/ ] listed : 1 / managed : 1 / NERDTree 0&#xA;=&amp;gt; 1 &amp;amp; 0 &amp;amp; 1&#xA;BufNew [5/NERD_tree_1 ] listed : 1 / managed : 1 / NERDTree 1&#xA;=&amp;gt; 1 &amp;amp; 0 &amp;amp; 0&#xA;BufAdd [5/NERD_tree_1 ] listed : 1 / managed : 1 / NERDTree 1&#xA;=&amp;gt; 1 &amp;amp; 0 &amp;amp; 0&#xA;BufCreate [5/NERD_tree_1 ] listed : 1 / managed : 1 / NERDTree 1&#xA;=&amp;gt; 1 &amp;amp; 0 &amp;amp; 0&#xA;BufEnter [5/NERD_tree_1 ] listed : 1 / managed : 1 / NERDTree 1&#xA;=&amp;gt; 1 &amp;amp; 0 &amp;amp; 0&#xA;BufWinEnter [5/NERD_tree_1 ] listed : 1 / managed : 1 / NERDTree 1&#xA;=&amp;gt; 1 &amp;amp; 0 &amp;amp; 0&#xA;BufDelete [5/NERD_tree_1 ] listed : 0 / managed : 1 / NERDTree 1&#xA;=&amp;gt; 0 &amp;amp; 0 &amp;amp; 0&#xA;Syntax [5/NERD_tree_1 nerdtree] listed : 0 / managed : 1 / NERDTree 1&#xA;=&amp;gt; 0 &amp;amp; 0 &amp;amp; 0&#xA;FileType [5/NERD_tree_1 nerdtree] listed : 0 / managed : 1 / NERDTree 1&#xA;=&amp;gt; 0 &amp;amp; 0 &amp;amp; 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here you can clearly see something : the new buffer (number 5) does not get&#xA;noticed by the &lt;code&gt;isNERDTree&lt;/code&gt; condition when triggering the &lt;code&gt;BufEnter&lt;/code&gt; event, in fact it is not a nerdtree buffer yet.&#xA;Later, on triggering the &lt;code&gt;BufNew&lt;/code&gt; event its name change (but not its filetype).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on your primary conditions : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if isListed &amp;amp;&amp;amp; !isAlreadyInManager &amp;amp;&amp;amp; !isNERDTreeBuffer&#xA;    call add (g:BuffersManager[tabpagenr()],newBufNr)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The add get called only one time : on the &lt;code&gt;BuffEnter&lt;/code&gt; (notice the &lt;code&gt;1 &amp;amp; 1 &amp;amp; 1&lt;/code&gt;).&#xA;When called on &lt;code&gt;BufEnter&lt;/code&gt;, the buffer is added to the list, but after, because&#xA;it already got considered, it doesn't change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you know this you can do multiple things :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;On events, you check if the buffer should be removed, like so :&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;new condition :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if isListed &amp;amp;&amp;amp; isAlreadyInManager &amp;amp;&amp;amp; isNERDTreeBuffer&#xA;  &quot; should be removed&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;You can use a different condition, instead of checking the name. As listed in&#xA;my log, you can recognize for the filetype and on the &lt;code&gt;FileType&lt;/code&gt; event delete&#xA;the buffer.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;For the nerdtree plugin, you should double check the &lt;em&gt;validity&lt;/em&gt; of the&#xA;buffer. As you cannot filter the buffer on it's creation, you should wait for&#xA;another event to remove the new buffer if needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Notes&lt;/strong&gt; :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Sorry for the long post, I wanted to be thorough.&lt;/li&gt;&#xA;&lt;li&gt;If you want more details, feel free to ask, I'll be happy to add them.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1841" LastEditDate="2015-08-17T13:43:11.583" LastActivityDate="2015-08-17T13:43:11.583" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4378" PostTypeId="2" ParentId="4354" CreationDate="2015-08-17T14:24:52.193" Score="2" Body="&lt;p&gt;I took time to install vim-latexsuite and I can confirm that my comment was right: you simply have to execute &lt;code&gt;:set iskeyword+=.&lt;/code&gt; to make completion work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid executing this function on each latex file you edit you can add the following line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal iskeyword+=.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To the syntax file &lt;code&gt;.vim/ftplugin/tex.vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-08-17T14:24:52.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4379" PostTypeId="1" AcceptedAnswerId="4381" CreationDate="2015-08-17T14:27:29.177" Score="-2" ViewCount="989" Body="&lt;p&gt;How commonly is Vim used in professional software development today, inside a company? By Vim, I mean the actual Vim editor, not a Vim/vi plugin/setting or usage within Eclipse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has Vim hindered your daily programming work when you had to interact with other tools or frameworks?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has Vim hindered your social interaction with other team members in some way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How did your colleagues and bosses respond in general, that you wanted to use an editor which forces you to configure it, instead of an ready-to-use IDE?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Sure, every IDE needs to be configured for the project. I just think Vim requires more configuration before being able to use it effectively. I assume this wouldn't create a good impression at work.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you pair-programmed with non-Vim users? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume that people are already familiar with Vim and don't start configuring Vim at work.&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="2932" LastEditDate="2015-08-17T17:54:42.600" LastActivityDate="2019-04-16T10:32:18.617" Title="Is vim suitable for professional development inside a company?" Tags="|vimrc|ide|" AnswerCount="1" CommentCount="6" ClosedDate="2015-08-17T15:06:58.847" ContentLicense="CC BY-SA 3.0" />
  <row Id="4380" PostTypeId="2" ParentId="4366" CreationDate="2015-08-17T14:29:18.863" Score="1" Body="&lt;p&gt;&lt;em&gt;(just to move the relevant comments in an answer)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;range&lt;/code&gt;, so that the function handles the range itself (&lt;code&gt;a:firstline&lt;/code&gt;, &lt;code&gt;a:lastline&lt;/code&gt;), so it's called only once. See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#E124&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; (&lt;code&gt;:h func-range&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach: use &lt;code&gt;:&amp;lt;C-u&amp;gt;call Clipboard()&amp;lt;CR&amp;gt;&lt;/code&gt; in your map. You clear the range prior to calling your function, so it's called only once, but you still have access to &lt;code&gt;v:count&lt;/code&gt; (also &lt;code&gt;v:count1&lt;/code&gt;) - so it's probably easier to use in your case.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-08-17T14:29:18.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4381" PostTypeId="2" ParentId="4379" CreationDate="2015-08-17T14:46:39.830" Score="8" Body="&lt;p&gt;This an odd question, and would be equally odd if asked of &lt;em&gt;any&lt;/em&gt; editor IMHO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No, vim (nor any other vi-variant) has ever hindered any of my work. I've only ever been hindered when &lt;em&gt;not&lt;/em&gt; using it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how vim would hinder my social interaction with other team members. It's not like vim gives you bad breath.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My colleagues and bosses couldn't care less what editor I use. About 70% of them use vim/vi too, a handful use emacs, most of the GUI developers use Eclipse, and one or two might use something else like jEdit or Notepad++. They don't care what brand of pen I take notes with either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I don't see how vim &lt;em&gt;forces&lt;/em&gt; you to configure it. Out of the box, it works pretty much like any version of vi ever has. Yeah, you end up tweaking it to your liking over time, but probably less than any IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't done any official pair programming, although two of us sometimes do work together to solve a particularly thorny problem. But then again, I don't see that the choice of editor matters much (everyone here except perhaps some of the GUI developers at least know how to use vim/vi, even if it's not their editor of choice).&lt;/p&gt;&#xA;" OwnerUserId="3016" LastEditorUserId="3016" LastEditDate="2019-04-16T10:32:18.617" LastActivityDate="2019-04-16T10:32:18.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4382" PostTypeId="1" CreationDate="2015-08-17T15:49:58.030" Score="1" ViewCount="3744" Body="&lt;p&gt;I have a fairly small Javascript project, and when I run &lt;code&gt;ctags -R&lt;/code&gt; it seems to generate at least some tags. I get a tags file (no extension?) in the root folder, and when I run &lt;code&gt;wc -l tags&lt;/code&gt; it says &lt;code&gt;8214 tags&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, Ctrl+] never finds any tags, even ones in the same file. Right now, I'm using the supergf plugin for similar functionality but I'm also using Tagbar and most of the functions are showing up empty or not at all. &#xA;(e.g. &lt;code&gt;void function(?,?,?,?)&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong? I also have tern-js installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="3210" LastActivityDate="2021-09-23T16:27:32.850" Title="Can't get Ctags working" Tags="|ctags|plugin-tagbar|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4383" PostTypeId="2" ParentId="4382" CreationDate="2015-08-17T16:15:47.693" Score="0" Body="&lt;p&gt;You may want to try the &lt;a href=&quot;http://vim-taglist.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;taglist&lt;/a&gt; plugin. It works perfectly for me.&lt;/p&gt;&#xA;" OwnerUserId="3205" LastActivityDate="2015-08-17T16:15:47.693" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4384" PostTypeId="2" ParentId="4366" CreationDate="2015-08-17T17:22:02.233" Score="4" Body="&lt;p&gt;When using counts and calling functions a range will be inserted automatically by Vim. You can see this by doing simply doing &lt;code&gt;3:&lt;/code&gt;. A common solution is to use &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; to remove the range. See &lt;code&gt;:h c_CTRL-U&lt;/code&gt; for more help.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap YY :&amp;lt;c-u&amp;gt;call Clipboard()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However there are a bunch of issues worth going over:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You should generally avoid recursive mappings. Use &lt;code&gt;noremap&lt;/code&gt; variants. e.g. &lt;code&gt;nnoremap &amp;lt;key&amp;gt; lhs&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;General rule of thumb: unless you are mapping to a &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mapping use &lt;code&gt;noremap&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Y&lt;/code&gt; is a Vim command and often remapped to &lt;code&gt;y$&lt;/code&gt;. Your key choice will cause a delay if you want to use &lt;code&gt;Y&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;v:count1&lt;/code&gt; instead of &lt;code&gt;v:count&lt;/code&gt; to simplify your code. See &lt;code&gt;:h v:count1&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Use full names. e.g. &lt;code&gt;function&lt;/code&gt; instead of &lt;code&gt;func&lt;/code&gt;. This will help aid with readability.&lt;/li&gt;&#xA;&lt;li&gt;Probably don't want this function in the global scope. Use &lt;code&gt;s:&lt;/code&gt; and &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt;. See &lt;code&gt;:h internal-variables&lt;/code&gt; and &lt;code&gt;:h &amp;lt;SID&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;This only method assumes that you only want to deal with yanking lines. Probably best to include a visual mode method as well.&lt;/li&gt;&#xA;&lt;li&gt;Should we be able to &lt;code&gt;d&lt;/code&gt; to clipboard?&lt;/li&gt;&#xA;&lt;li&gt;Possibly check out &lt;code&gt;'clipboard'&lt;/code&gt;. See &lt;code&gt;:h 'clipboard'&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Possibly make it easy to do &lt;code&gt;&quot;+&lt;/code&gt; instead of change a bunch of mappings. e.g. &lt;code&gt;nnoremap &quot;&quot; &quot;+&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-08-17T17:22:02.233" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4385" PostTypeId="1" AcceptedAnswerId="4386" CreationDate="2015-08-17T17:39:32.477" Score="1" ViewCount="111" Body="&lt;p&gt;Is there a way to tab through fields and values in a json file in Vim as you would form fields on a web form?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="23502" LastEditDate="2022-11-05T09:22:56.137" LastActivityDate="2022-11-05T09:22:56.137" Title="Is there a way to tab through fields and values in a JSON file in Vim?" Tags="|filetype-javascript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4386" PostTypeId="2" ParentId="4385" CreationDate="2015-08-17T18:34:03.203" Score="4" Body="&lt;p&gt;There is not native way to do this however a few mappings should do the trick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following to &lt;code&gt;~/.vim/after/ftplugin/javascript.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;tab&amp;gt; :&amp;lt;c-u&amp;gt;call search('\v(&quot;&amp;lt;bar&amp;gt;null&amp;lt;bar&amp;gt;\d+&amp;lt;bar&amp;gt;true&amp;lt;bar&amp;gt;false&amp;lt;bar&amp;gt;\[\]&amp;lt;bar&amp;gt;\{\})\ze\n=\s*[]:,}]')&amp;lt;bar&amp;gt;execute &quot;normal! vi&quot;. (getline('.')[col('.')-1] == '&quot;' ? '&quot;' : 'w')&amp;lt;cr&amp;gt;&#xA;xmap &amp;lt;buffer&amp;gt; &amp;lt;tab&amp;gt; &amp;lt;esc&amp;gt;`&amp;gt;l&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The basic idea is to search for items followed by &lt;code&gt;,&lt;/code&gt;, &lt;code&gt;}&lt;/code&gt;, &lt;code&gt;]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :search&#xA;:h &amp;lt;bar&amp;gt;&#xA;:h /\|&#xA;:h /\ze&#xA;:h :execute&#xA;:h :normal&#xA;:h getline()&#xA;:h col()&#xA;:h c_CTRL-U&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-08-17T18:34:03.203" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4387" PostTypeId="1" AcceptedAnswerId="4392" CreationDate="2015-08-18T00:33:06.573" Score="13" ViewCount="1182" Body="&lt;p&gt;I'm trying to have a highlighted undo in Vim, like spacemacs default config.&#xA;Sometimes when I want quick undo's, I can't realize what changed because it's instantaneous. So I am trying to have something like this when a press undo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FWWTU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FWWTU.png&quot; alt=&quot;highlighted undo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone have an idea how to do this in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I already have Gundo plugin, i just want to make the default undo more smooth)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: The &lt;a href=&quot;https://github.com/mbbill/undotree&quot; rel=&quot;nofollow noreferrer&quot;&gt;undotree&lt;/a&gt; plugin does the work (&lt;a href=&quot;https://github.com/sjl/gundo.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gundo&lt;/a&gt; doesn't highlight the changes), just use the &lt;code&gt;UndotreeToggle&lt;/code&gt; command and all future changes on the file will be highlighted.&lt;/p&gt;&#xA;" OwnerUserId="2131" LastEditorUserId="205" LastEditDate="2016-03-04T09:57:49.377" LastActivityDate="2017-01-02T05:43:56.560" Title="Highlighted undo in Vim" Tags="|highlight|undo-redo|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4388" PostTypeId="2" ParentId="4368" CreationDate="2015-08-18T00:49:12.127" Score="0" Body="&lt;p&gt;Ok. figured it out by looking into &lt;a href=&quot;https://github.com/neovimhaskell/haskell-vim&quot; rel=&quot;nofollow&quot;&gt;haskell.vim&lt;/a&gt;, I found ad slight modification of &lt;code&gt;indentexpr&lt;/code&gt; would work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;check it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;first,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd ~/.vim/bundle/haskell-vim/&#xA;$ vi indent/haskell.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then find the definition of &lt;code&gt;GetHaskellIndent&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I add following lines right after the handling of &lt;code&gt;--&lt;/code&gt; comment, therefore the function becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetHaskellIndent()&#xA;  let l:prevline = getline(v:lnum - 1)&#xA;&#xA;  if l:prevline =~ '^\s*--'&#xA;    return match(l:prevline, '\S')&#xA;  endif&#xA;&#xA;  if synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 1), &quot;name&quot;) == 'hsBlockComment'&#xA;      for l:c in range(v:lnum - 1, 0, -1)&#xA;          let l:bline = getline(l:c)&#xA;          if l:bline =~ '{-'&#xA;              return 1 + match(l:bline, '{-')&#xA;      endfor&#xA;      return 1&#xA;  endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;starting from &lt;code&gt;if synIDattr(synID(line(&quot;.&quot;), ...&lt;/code&gt; is my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;basically what it means is check whether the current position is in block comment syntax, if so, get in the for loop and find the first occurrence of &lt;code&gt;{-&lt;/code&gt;, then return the indent as deep as the &lt;code&gt;-&lt;/code&gt; in &lt;code&gt;{-&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;notice that, my haskell environment is heavily customized. you should config according to yours. though my indent is setup to use &lt;code&gt;haskell.vim&lt;/code&gt;, my syntax highlight is setup to use &lt;code&gt;vim2hs&lt;/code&gt;. so it's better to look into the syntax highlight file first to find out what syntax element you should look at(in &lt;code&gt;vim2hs&lt;/code&gt;'s case, it should be &lt;code&gt;'hsBlockComment'&lt;/code&gt;, in &lt;code&gt;haskell.vim&lt;/code&gt; it should be &lt;code&gt;'haskellBlockComment'&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;after having this code, I have following effect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{-&#xA; -&#xA; -&#xA; - -}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for comments in deep indent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      {-&#xA;       -&#xA;       -&#xA;       -&#xA;       -&#xA;       - -}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works like a charm.&lt;/p&gt;&#xA;" OwnerUserId="1097" LastEditorUserId="1097" LastEditDate="2015-08-18T00:56:37.270" LastActivityDate="2015-08-18T00:56:37.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4389" PostTypeId="1" AcceptedAnswerId="4390" CreationDate="2015-08-18T02:04:25.050" Score="0" ViewCount="197" Body="&lt;p&gt;I'm looking to map &lt;code&gt;Ctrl-N&lt;/code&gt; to &lt;code&gt;lbvhe&lt;/code&gt; in normal mode. This should visually select the word under the cursor, and works fine unless the word is at the beginning of a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having investigated, I've found that &amp;ndash; in a mapping &amp;ndash; firing &lt;code&gt;h&lt;/code&gt; when the cursor is in column 1 (which should simply do nothing) &quot;traps&quot; the cursor at the beginning of the line. Any following movement commands seem to be ignored; &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, &lt;code&gt;l&lt;/code&gt;, &lt;code&gt;e&lt;/code&gt;, and &lt;code&gt;w&lt;/code&gt; all do nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My mapping works perfectly on any word preceded by whitespace or punctuation, but not words preceded by the previous line's EOL.&lt;/p&gt;&#xA;" OwnerUserId="3212" LastEditorUserId="1841" LastEditDate="2015-08-18T06:09:06.583" LastActivityDate="2015-08-18T14:04:42.233" Title="Mapping to &quot;bh&quot; causes cursor to be trapped in first column" Tags="|key-bindings|cursor-movement|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4390" PostTypeId="2" ParentId="4389" CreationDate="2015-08-18T02:59:36.563" Score="7" Body="&lt;p&gt;Use &lt;code&gt;viw&lt;/code&gt; to visually select the current word. &lt;code&gt;iw&lt;/code&gt; is a text object for the &quot;inner&quot; word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you run &lt;code&gt;vimtutor&lt;/code&gt; from the command line as well as look at &lt;code&gt;:h quickref&lt;/code&gt; for more motions and text objects.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-08-18T14:04:42.233" LastActivityDate="2015-08-18T14:04:42.233" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4391" PostTypeId="2" ParentId="4389" CreationDate="2015-08-18T05:30:07.343" Score="2" Body="&lt;p&gt;From &lt;code&gt;:h map-error&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                            *map-error* &#xA;Note that when an error is encountered (that causes an error message or beep)  &#xA;the rest of the mapping is not executed.  This is Vi-compatible.  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so when you hit &lt;code&gt;h&lt;/code&gt; while on the first column (or &lt;code&gt;l&lt;/code&gt; on the last one) the mapping fails.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As @peterrincker said you could use &lt;code&gt;viw&lt;/code&gt;, which has &lt;em&gt;almost&lt;/em&gt; the same effect as your command (if you're not on a word &lt;code&gt;viw&lt;/code&gt; will not select anything while your command will select the previous word).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you still want to use your mapping you could use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-n&amp;gt; :silent! normal! lbvhe^M &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;^M&lt;/code&gt; being one character, use &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to enter it).&lt;/p&gt;&#xA;" OwnerUserId="683" LastActivityDate="2015-08-18T05:30:07.343" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4392" PostTypeId="2" ParentId="4387" CreationDate="2015-08-18T08:40:14.470" Score="6" Body="&lt;h1&gt;New solution&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You can view your last changes with the &lt;code&gt;:changes&lt;/code&gt; command. So you can fecth your most recent line change with a regex and then apply the line to &lt;code&gt;matchadd()&lt;/code&gt; as suggested by @joeytwiddle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DiffWithPrevious()&#xA;  call clearmatches()&#xA;  redir =&amp;gt; message&#xA;  silent changes&#xA;  redir END&#xA;  let line = matchstr(message, '\v\n\s{4}1[^0-9]*\zs\d+\ze')&#xA;  highlight TemporalDiff ctermbg=green guibg=green&#xA;  let m = matchadd('TemporalDiff', '\%'.line.'l')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; : &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;s&gt;This function only add a new highlight without removing the old one, so you'd have to remove the old one first.&lt;/s&gt; With the &lt;code&gt;clearmatches&lt;/code&gt; function you can remove the matches before adding a new one. Careful, it will remove &lt;strong&gt;ALL&lt;/strong&gt; matches. If you want more granularity, you can save your match and remove it manually : &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DiffWithPrevious()&#xA;  call matchdelete(m)&#xA;  ... &#xA;  let m = matchadd('TemporalDiff', '\%'.line.'l')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;After some tests, I found out it only works for one-line change.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;References :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/73438/2558252&quot;&gt;Why is \r a newline for Vim?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/3135448/2558252&quot;&gt;regex in vimscript&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Capture_ex_command_output&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Capture_ex_command_output&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Highlight_long_lines&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Highlight_long_lines&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Old solution&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Here is a possible solution, mainly inspired by &lt;a href=&quot;http://vim.wikia.com/wiki/Diff_current_buffer_and_the_original_file&quot; rel=&quot;nofollow noreferrer&quot;&gt;Diff current buffer and the original file&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DiffWithPrevious()&#xA;  undo&#xA;  write&#xA;  redo&#xA;  let filetype=&amp;amp;ft&#xA;  diffthis&#xA;  vnew | r # | normal! 1Gdd&#xA;  diffthis&#xA;  exe &quot;setlocal bt=nofile bh=wipe nobl noswf ro ft=&quot; . filetype&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to diff the file with the file on the system, so you undo your last change, write it, redo the las change and execute the diff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this should do the job for time-to-time temporal diff visualisations.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-01-02T05:43:56.560" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4393" PostTypeId="2" ParentId="4389" CreationDate="2015-08-18T08:45:20.180" Score="2" Body="&lt;p&gt;In addition to @Peter's answer I think you should read &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h text-objects&lt;/code&gt;&lt;/a&gt; because it is a really powerful Vim's feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Peter already mentionned &lt;code&gt;iw&lt;/code&gt; which selects a word and is pretty close to what you was trying to do. It is worth mentionning &lt;code&gt;aw&lt;/code&gt; which allows to select a word + a leading or trailing space (that can be useful to change the place of a word in a sentence without leaving two whitespaces instead of only one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also two other texts objects pretty similar: &lt;code&gt;iW&lt;/code&gt; and &lt;code&gt;aW&lt;/code&gt; which selects WORDS instead of words (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#WORD&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h WORD&lt;/code&gt;&lt;/a&gt; to clarify the difference). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally note that text-objects can be used with all the basics commands not only &lt;code&gt;v&lt;/code&gt;: &lt;code&gt;diw&lt;/code&gt; will delete your word, &lt;code&gt;caW&lt;/code&gt; will delete your WORD and a trailing space and switch to insert mode, &lt;code&gt;yaw&lt;/code&gt; will yank the word and a trailing space, etc...&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-08-18T08:45:20.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4394" PostTypeId="1" AcceptedAnswerId="4396" CreationDate="2015-08-18T09:31:24.050" Score="1" ViewCount="877" Body="&lt;p&gt;I have a graph data in a file with each line containing the source and destination node of an edge. I want to assign a random weight between [1, 10] for each edge to test my graph algorithm. How can I do that in Vim?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Graph data:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;1 2 &lt;br/&gt;2 3 &lt;br/&gt;1 5&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Data along with weights(Expected Output)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;1 2 5&lt;br/&gt;2 3 3&lt;br/&gt;1 5&#xA;9&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The last column is the weight of each edge.&lt;/p&gt;&#xA;" OwnerUserId="3213" LastEditorUserId="23502" LastEditDate="2022-11-05T09:22:29.177" LastActivityDate="2022-11-05T09:22:29.177" Title="How to append a random number between a range [1,10] at the end of each line in Vim?" Tags="|line-breaks|enumerate|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4395" PostTypeId="2" ParentId="4394" CreationDate="2015-08-18T10:02:10.960" Score="3" Body="&lt;p&gt;As long as you don't mind the quality of the random process generation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\s*$/\=' ' . (1 + str2nr(matchstr(reltimestr(reltime()), '\v\.@&amp;lt;=\d+')[1:]) % 10)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It basically replaces the end of each line, and all the trailing spaces, with a single space followed by &lt;code&gt;(current time microseconds % 10) + 1&lt;/code&gt;, where &lt;code&gt;%&lt;/code&gt; is the remainder/modulo operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/3832/1800&quot;&gt;random ... reference&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-08-18T16:20:44.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4396" PostTypeId="2" ParentId="4394" CreationDate="2015-08-18T10:03:52.833" Score="0" Body="&lt;p&gt;You can do it with a macro : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r!echo $RANDOM^Mld$kJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing the macro :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r!echo $RANDOM^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; : &lt;code&gt;^M&lt;/code&gt; is the litteral &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, so you should press &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; instead of &lt;code&gt;^M&lt;/code&gt; when you record your macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This insert in a new line a random number (you should look at &lt;a href=&quot;https://stackoverflow.com/a/20430735/2558252&quot;&gt;this post&lt;/a&gt; for more infos).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;l       &quot; go right&#xA; d      &quot; delete ... &#xA;  $     &quot; ... to the end of the line (leaving only the first digit)&#xA;   k    &quot; go up&#xA;    J   &quot; join the line below&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; :&#xA;As stated by @Doorknob : &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Bash's $RANDOM returns a random number from 0 to 32767&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So to keep the last digit instead of the first one, you can replace the &lt;code&gt;ld$&lt;/code&gt; part by : &lt;code&gt;vehx&lt;/code&gt;. I think that a random number generation should be put in a function and be carefully handled.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-08-20T11:35:15.137" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4397" PostTypeId="1" CreationDate="2015-08-18T14:47:37.460" Score="4" ViewCount="862" Body="&lt;p&gt;I'm using vim to write some long text documents in French and in English.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know how to enable spell check to check the words against a dictionary and verify than I don't misspell a word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question is:&lt;/strong&gt; Is it possible to use Vim to check grammar and syntax error as an editor like LibreOffice Writer or Microsoft Word would do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Verifications should include checks like conjugations or masculine/feminine singular/plural accords. And ideally some commands similar to spell check like &lt;code&gt;]s&lt;/code&gt; or &lt;code&gt;z=&lt;/code&gt; should be available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My searches often leads to programming language grammar check but not actual human languages. I have found &lt;a href=&quot;https://github.com/vim-scripts/LanguageTool&quot; rel=&quot;nofollow&quot;&gt;this plugin&lt;/a&gt; which integrates languageTool into vim but it use an external tool and requires to use Java which is something that I would really like to avoid. I was wondering if there would be a tool using more built-in features to do that.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-18T16:15:47.983" LastActivityDate="2015-08-23T09:11:30.767" Title="Using Vim to syntax check some text" Tags="|spell-checking|grammar-checking|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="4398" PostTypeId="2" ParentId="4394" CreationDate="2015-08-18T15:25:00.683" Score="0" Body="&lt;p&gt;This is the gist of it (assuming UNIX environment):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g//read! echo $RANDOM&#xA;:g//join&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want the number to be between 1 and 10:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g//read! echo $(( 1 + $RANDOM % 10 ))&#xA;:g//join&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to do this for a section of the file, just select the lines in visual line mode before typing the first command, and press &lt;code&gt;gv&lt;/code&gt; before typing the second.&lt;/p&gt;&#xA;" OwnerUserId="3215" LastActivityDate="2015-08-18T15:25:00.683" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4399" PostTypeId="1" AcceptedAnswerId="4400" CreationDate="2015-08-18T15:32:03.230" Score="2" ViewCount="999" Body="&lt;p&gt;I was wondering how it is that I would place VIMScript variable values in my regex range and also in the replacement portion of my regex?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GoogleFormsStep(startnum, endnum)&#xA;&#xA;    let x = startnum&#xA;    let line = 1&#xA;&#xA;    while x &amp;lt;= endnum&#xA;&#xA;      line, line s/$/x/g &quot; What do I do here?&#xA;&#xA;      let x = x + 1&#xA;      let line = line + 1&#xA;    endwhile&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="7161" LastEditDate="2016-05-13T17:35:15.950" LastActivityDate="2016-05-13T17:35:15.950" Title="Search and replace in vimscript using a range?" Tags="|vimscript|range|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4400" PostTypeId="2" ParentId="4399" CreationDate="2015-08-18T15:49:03.963" Score="3" Body="&lt;p&gt;Use &lt;code&gt;:execute&lt;/code&gt; and concatenation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let startline = 2&#xA;let endline = 56&#xA;let searchpattern = &quot;foo&quot;&#xA;let replacepattern = &quot;bar&quot;&#xA;&#xA;execute startline . &quot;,&quot; . endline . &quot;s/&quot; . searchpattern .&quot;/&quot; . replacepattern . &quot;/g&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternative:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let cmd = startline . &quot;,&quot; . endline . &quot;s/&quot; . searchpattern .&quot;/&quot; . replacepattern . &quot;/g&quot;&#xA;execute cmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-08-18T15:49:03.963" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4401" PostTypeId="2" ParentId="4372" CreationDate="2015-08-18T16:05:03.513" Score="0" Body="&lt;p&gt;Using the &lt;code&gt;search()&lt;/code&gt; tip from VanLaser I created these functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Repeat in the opposite direction if `reverse` is true&#xA;function! RepeatLineSearch(reverse)&#xA;    if a:reverse == s:search_backward&#xA;        call search(s:search_pattern, '', line('.'), '')&#xA;    else&#xA;        call search(s:search_pattern, 'b', line('.'), '')&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot; Search backward if `backward` is true&#xA;function! LineSearch(pattern, backward)&#xA;    let s:search_pattern = a:pattern&#xA;    let s:search_backward = a:backward&#xA;    call RepeatLineSearch(0)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then put these mappings in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Search forward/backward for a pattern in current line&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;f :call LineSearch(input('--&amp;gt; '), 0)&amp;lt;cr&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;F :call LineSearch(input('&amp;lt;-- '), 1)&amp;lt;cr&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;; :call RepeatLineSearch(0)&amp;lt;cr&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;, :call RepeatLineSearch(1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows me to search for a new pattern using &lt;code&gt;\f&lt;/code&gt; and &lt;code&gt;\F&lt;/code&gt; and repeat the last pattern using &lt;code&gt;\;&lt;/code&gt; and &lt;code&gt;\,&lt;/code&gt; where &lt;code&gt;\,&lt;/code&gt; repeats the pattern in the opposite direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Feel free to copy this code directly into your &lt;code&gt;.vimrc&lt;/code&gt; or modify it to fit your needs.&lt;/p&gt;&#xA;" OwnerUserId="3032" LastActivityDate="2015-08-18T16:05:03.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4402" PostTypeId="1" CreationDate="2015-08-18T16:30:48.443" Score="1" ViewCount="82" Body="&lt;p&gt;From the Vim documentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. Simulated command                    *simulated-command*&#xA;&#xA;This command is in Vi, but Vim only simulates it:&#xA;&#xA;                                               *:o* *:op* *:open*&#xA;:[range]o[pen]          Works like |:visual|: end Ex mode.&#xA;                        {Vi: start editing in open mode}&#xA;&#xA;:[range]o[pen] /pattern/    As above, additionally move the cursor to the&#xA;                            column where &quot;pattern&quot; matches in the cursor&#xA;                            line.&#xA;&#xA;Vim does not support open mode, since it's not really useful.  For those&#xA;situations where &quot;:open&quot; would start open mode Vim will leave Ex mode, which&#xA;allows executing the same commands, but updates the whole screen instead of&#xA;only one line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does bother not mention what &quot;open mode&quot; is and I have became interested in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it another editing mode like &lt;code&gt;-- REPLACE --&lt;/code&gt; and &lt;code&gt;-- VISUAL --&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you explain what &lt;code&gt;open mode&lt;/code&gt; is and tell me why it is useless and got scrapped from Vim?&lt;/p&gt;&#xA;" OwnerUserId="3032" LastActivityDate="2015-08-18T16:30:48.443" Title="What is &quot;open mode&quot; and why is it in Vi but not in Vim?" Tags="|command-line|ex-mode|original-vi|" AnswerCount="0" CommentCount="0" ClosedDate="2015-08-18T19:02:57.287" ContentLicense="CC BY-SA 3.0" />
  <row Id="4404" PostTypeId="2" ParentId="4349" CreationDate="2015-08-18T19:17:32.523" Score="5" Body="&lt;p&gt;I want to take a shot at answering my first question on this forum. If I understand your question right, you are referring to concepts of &quot;clipboard&quot; and &quot;primary&quot;. If not - sorry, I am wrong. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: After the comment by @jjaderberg below, I decided to clarify why I assumed that xterm_clipboard in vim is Primary. To be sure I looked up Clipboard definition in &lt;a href=&quot;http://invisible-island.net/xterm/manpage/xterm.html#h3-Clipboard&quot; rel=&quot;nofollow&quot;&gt;xterm manual page&lt;/a&gt;. I was basically looking for other definitions of the word 'clipboard' in xterm context besides those explained below. Since I did not find anything, I made an assumption that xterm_clipboard in vim is Primary in X, since Vim's &lt;code&gt;:help xterm_clipboard&lt;/code&gt; defines it as just:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;+xterm_clipboard    Unix only: xterm clipboard handling&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Every X.org application (X window system implementation, as you know) has a shared copy/paste buffer called Primary. That's where xterm, rxvt and other X applications copy selection, which is cleared once you make another selection. You can see what is in your 'primary' by running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xsel -p -o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will print contents of your Primary buffer (note, &lt;code&gt;xsel&lt;/code&gt; may not be installed by default). Another copy/paste buffer is called Clipboard, which is what you use when you do &lt;code&gt;ctrl+c/ctrl+v&lt;/code&gt;. You can see what's in it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xsel -b -o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In vim (on Linux at least), register &lt;code&gt;*&lt;/code&gt; stores Primary and register &lt;code&gt;+&lt;/code&gt; stores Clipboard. So if you make a selection in xterm and then in vim do &lt;code&gt;&quot;*p&lt;/code&gt; then you will insert what you selected in xterm. &lt;code&gt;&quot;+p&lt;/code&gt; will insert clipboard. (I think, if you copy something into clipboard you will clobber Primary, but I am not 100% sure, maybe someone can pitch in on this.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure, how this relates to mouse, but I did notice that the visual selection that's done by mouse (with &lt;code&gt;mouse=a&lt;/code&gt;) in vim in xterm also goes into &lt;code&gt;*&lt;/code&gt; register and hence in Primary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also, can't answer for sure about default availability of this functionality, but I want to assume (after rebuilding vim7.4 many times) that in the vast majority of cases they are compiled in by default. If anyone has more input on this, please edit this bit too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read more about this on &lt;a href=&quot;https://wiki.archlinux.org/index.php/Xterm#Copy_and_paste&quot; rel=&quot;nofollow&quot;&gt;Arch wiki&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for reading. Sorry, if I misunderstood. Hopefully, this helped a little. Cheers. :)&lt;/p&gt;&#xA;" OwnerUserId="3006" LastEditorUserId="3006" LastEditDate="2015-08-18T20:06:14.183" LastActivityDate="2015-08-18T20:06:14.183" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4405" PostTypeId="1" CreationDate="2015-08-18T20:00:59.343" Score="5" ViewCount="770" Body="&lt;p&gt;Is there a way to call vi/vim from the shell to format text?  It would be like running a vim-golf sequence from the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is so easy to compare effects of commands in vim that I can easily test a few options and identify a workable solution.  I would like to be able to incorporate those command sequences into command line options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried something simple like &lt;code&gt;vi -c &quot;:%s/./x/&quot;&lt;/code&gt; but it that doesn't seem to work at all in msysgit vim.  Really, I would only expect it to do that change and show me the open buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;vi -c ':%s/./x/'&lt;/code&gt; (with ' instead of &quot;) does run the command on the buffer, but it is still kept in the buffer and not pushed back to stdout.  Looks like Windows or msysgit was trying to magic my &lt;code&gt;%&lt;/code&gt; (fixed throughout the rest of the question).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to be able to do is use it like you would grep/sed/awk/tr.  The defaults are nice and not having to translate line break options from vim to the others would be helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I really want is a command line option for vim, say --doit='...' where I could specify what I would type, have it do that and spit out the resulting buffer.  Something like this would spit out and x for every character in the result of an &lt;code&gt;ls -l&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls -l | vi --doit=':%s/./x/g' -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would reformat text according to linebreaks (assuming textwidth and formatting options are set correctly):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi --doit='ggqG' sometextfile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is difficult to search for a solution to this because of the convolution between shell command line and the vim command mode line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone know if this is possible?&lt;/p&gt;&#xA;" OwnerUserId="3222" LastEditorUserId="8" LastEditDate="2015-08-18T21:45:40.850" LastActivityDate="2015-08-18T21:58:09.973" Title="Use vi/vim from shell to filter / format text" Tags="|vimscript|command-line|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4406" PostTypeId="2" ParentId="4405" CreationDate="2015-08-18T20:36:19.210" Score="2" Body="&lt;p&gt;You can use vim as a command server as described in here: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/remote.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/remote.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a similar question which describes hot to use it: &lt;a href=&quot;https://stackoverflow.com/questions/8507687/send-commands-to-vim-programmatically&quot;&gt;https://stackoverflow.com/questions/8507687/send-commands-to-vim-programmatically&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3003" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-18T20:36:19.210" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4407" PostTypeId="1" AcceptedAnswerId="4409" CreationDate="2015-08-18T21:16:34.240" Score="2" ViewCount="221" Body="&lt;p&gt;Why does this not work as expected?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyO()&#xA;     normal! o&#xA;endfunction&#xA;nnoremap TT :call MyO()&amp;lt;cr&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this is the situation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; |   an indented text&#xA; ^ (normal mode)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;typing &lt;code&gt;o&lt;/code&gt; gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    an indented text&#xA;    |&#xA;    ^ (insert mode)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but typing &lt;code&gt;TT&lt;/code&gt; gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    an indented text&#xA;|&#xA;^ (insert mode)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why can't I enjoy automatic indentation with &lt;code&gt;normal&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="2978" LastEditorUserId="2978" LastEditDate="2015-08-19T08:18:55.453" LastActivityDate="2015-08-19T08:18:55.453" Title="`normal` does not seem to allow automatic indentation" Tags="|vimscript|indentation|normal-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4408" PostTypeId="2" ParentId="4405" CreationDate="2015-08-18T21:58:09.973" Score="6" Body="&lt;p&gt;You can launch vim using two flags to accomplish this.  The two flags are &lt;code&gt;-e&lt;/code&gt; and &lt;code&gt;-s&lt;/code&gt;.  When vim is launched with the &lt;code&gt;-e&lt;/code&gt; flag, vim automatically enters ex mode, which is just vim's command line and nothing else.  The &lt;code&gt;-s&lt;/code&gt; flag means that vim is silent, which means that nothing is displayed.  This wouldn't be very useful if you couldn't pass commands via flags.  However, there are two options which can accomplish this.  They are &lt;code&gt;-c &quot;{ex command}&quot;&lt;/code&gt; and &lt;code&gt;+&quot;{ex command}&quot;&lt;/code&gt;.  You can add up to 10 of these to a single command.  For example, say I wanted to replace the word &quot;foo&quot; with &quot;bar&quot; in a file.  Here is what I would do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -es +&quot;%s/foo/bar/g&quot; +&quot;wq&quot; foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would launch vim in ex mode, run the command &lt;code&gt;%s/foo/bar/g&lt;/code&gt;, and then write to the file and quit using the &lt;code&gt;wq&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see more help on these command line flags by running &lt;code&gt;vim -h&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-08-18T21:58:09.973" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4409" PostTypeId="2" ParentId="4407" CreationDate="2015-08-18T22:37:25.360" Score="5" Body="&lt;p&gt;As explained in &lt;code&gt;help :normal&lt;/code&gt;, if an argument to &lt;code&gt;:normal&lt;/code&gt; is not a complete normal-mode command, it will be aborted as if &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; or &lt;code&gt;Ctrl-C&lt;/code&gt; was typed. &quot;This implies that an insert command [such as &lt;code&gt;o&lt;/code&gt;] must be completed (to start Insert mode, see &lt;code&gt;:startinsert&lt;/code&gt;).&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your &lt;code&gt;TT&lt;/code&gt; command is effectively executing &lt;code&gt;o&amp;lt;esc&amp;gt;i&lt;/code&gt;, which is not the same as just typing &lt;code&gt;o&lt;/code&gt;--it removes the indent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do what you want to do, try the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal o\&amp;lt;Space&amp;gt;\&amp;lt;BS&amp;gt;\&amp;lt;Esc&amp;gt;&quot;&#xA;startinsert!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That opens a new line with the cursor at the indented position, inserts a space and backspaces over the space to preserve the indent, then escapes back to normal mode. The &lt;code&gt;:startinsert!&lt;/code&gt; command then puts you in insert mode after the indent.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-08-18T22:37:25.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4410" PostTypeId="1" CreationDate="2015-08-18T23:50:39.960" Score="6" ViewCount="822" Body="&lt;p&gt;Can I do this in Vimscript?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let [a, b] = s:MyFunc()&#xA;&#xA;function! s:MyFunc()&#xA;  return [1, 2]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-08-18T23:50:39.960" Title="Can I do array destructuring in VimL?" Tags="|vimscript|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4411" PostTypeId="2" ParentId="4410" CreationDate="2015-08-18T23:50:39.960" Score="10" Body="&lt;p&gt;Yes you can, but Vim calls it &lt;em&gt;list unpacking&lt;/em&gt;.  It can be found in Vim's help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h let-unpack&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim allows you to create and populate two variables from a list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let [var1, var2] = mylist&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is equivalent to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let var1 = mylist[0]&#xA;let var2 = mylist[1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is also an (untagged) section on that help page titled &quot;List unpack&quot;.  It says you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let [var1, var2; rest] = mylist&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to collect an optional unknown number of items in a list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you can use a related trick to perform operations on multiple existing variables at once:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let [var1, var2] += 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is lots to like about this language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I don't believe any such magic is available for Dictionaries as of yet.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-08-18T23:50:39.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4412" PostTypeId="1" AcceptedAnswerId="4417" CreationDate="2015-08-19T01:40:23.577" Score="4" ViewCount="198" Body="&lt;p&gt;I know that if you press &lt;code&gt;n&lt;/code&gt; you can hop to the next occurrence of a matching pattern, and that if you want to go to the previous match, you press &lt;code&gt;N&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if my cursor is already in the middle of a match, how do I tell what number match that is from the top of the document?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2015-08-19T20:51:48.000" Title="Finding out what number occurance of a matching pattern is under your cursor?" Tags="|regular-expression|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4413" PostTypeId="2" ParentId="4412" CreationDate="2015-08-19T01:59:09.217" Score="2" Body="&lt;p&gt;This should just be a comment but as I don't have the reputation to comment here goes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This won't be accurate for multi occurrences on the one line but&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;First&#xA;yiw&#xA;Then&#xA;:1,.s/&amp;lt;C-R&amp;gt;&quot;//gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To discombobulate&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`yiw` will select the yank the word under the cursor  to register `&quot;` .&#xA;&#xA;`:1,.` does something from line 1 to the current line in command mode &#xA;&#xA;`&amp;lt;C-R&amp;gt;&quot;` means Ctrl-r&quot; which pastes the contents of register &quot; to the command line&#xA;&#xA;`s/&amp;lt;C-R&amp;gt;&quot;//gn` searches for the value in `&quot;` or `yes` and replaces nothing but counts matches. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;eg for the following with the cursor on a &lt;code&gt;yes&lt;/code&gt; in line 5 the above will say 10 matches on 5 lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1    yes no yes&#xA;2    yes no yes&#xA;3    yes no yes&#xA;4    yes no yes&#xA;5    yes no yes&#xA;6    yes no yes&#xA;7    yes no yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1313" LastEditorUserId="1313" LastEditDate="2015-08-19T02:57:27.103" LastActivityDate="2015-08-19T02:57:27.103" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4414" PostTypeId="2" ParentId="4412" CreationDate="2015-08-19T04:58:16.180" Score="4" Body="&lt;p&gt;You can do this with one command : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,.s/&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;//gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,.s/      &quot; start a substitute command from top of the document to current line&#xA;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;  &quot; paste the content of the word under the cursor&#xA;//          &quot; replace with noting&#xA;gn          &quot; don't actually replace&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in normal mode you can create a mapping for better use : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;n :1,.s/&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;//gn&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h c_&amp;lt;C-R&amp;gt;_&amp;lt;C-W&amp;gt;&lt;/code&gt; for further references.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&#xA;If you want to rely on your previously entered search pattern, you can replace &lt;code&gt;&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; by &lt;code&gt;&amp;lt;C-R&amp;gt;/&lt;/code&gt;. As the &lt;code&gt;/&lt;/code&gt; register is the search register, it contains the last search pattern.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-08-19T07:51:18.070" LastActivityDate="2015-08-19T07:51:18.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4415" PostTypeId="1" AcceptedAnswerId="4416" CreationDate="2015-08-19T08:46:35.437" Score="2" ViewCount="1976" Body="&lt;p&gt;I just successfully installed &lt;a href=&quot;https://github.com/bling/vim-airline&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-airline&lt;/a&gt;, and all the required stuff. I've downloaded the powerline-fonts, and successfully installed them. The only problem right now I'm having is: On right side of the bar from my angle, it shows some spacing between arrows and boxes like in the following picture:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oXWc3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oXWc3.png&quot; alt=&quot;Spacing between arrow and box on right side&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've applied a lot of techniques to make it look properly, but nothing makes it work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: No matter, how wide or short the screen is - the spacing remains consistent.&lt;/p&gt;&#xA;" OwnerUserId="3229" LastEditorUserId="1841" LastEditDate="2015-08-19T08:48:23.823" LastActivityDate="2015-08-19T09:29:47.610" Title="Spacing appears in Vim Airline on right side" Tags="|plugin-airline|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4416" PostTypeId="2" ParentId="4415" CreationDate="2015-08-19T09:29:47.610" Score="2" Body="&lt;p&gt;You should try adding the following line in your vimrc :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline#extensions#whitespace#mixed_indent_algo = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, some fonts may work better than others. e.g. :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://larsenwork.com/monoid/&quot; rel=&quot;nofollow&quot;&gt;http://larsenwork.com/monoid/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/powerline/fonts/tree/master/Inconsolata&quot; rel=&quot;nofollow&quot;&gt;https://github.com/powerline/fonts/tree/master/Inconsolata&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-08-19T09:29:47.610" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4417" PostTypeId="2" ParentId="4412" CreationDate="2015-08-19T11:24:48.910" Score="4" Body="&lt;p&gt;You can use the &lt;code&gt;n&lt;/code&gt; flag with the substitution command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/set//gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or use the current search pattern via &lt;code&gt;:%s///gn&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;:vimgrep&lt;/code&gt; and the quickfix list. Search for your pattern via:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep/set/ %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This searches the current file, &lt;code&gt;%&lt;/code&gt;, and adds the matches to the quickfix list. Then you can move through the quickfix list via &lt;code&gt;:cnext&lt;/code&gt; or &lt;code&gt;:cprevious&lt;/code&gt;. Upon moving through the quickfix list text will display at the bottom showing something like this &lt;code&gt;(4 of 10)&lt;/code&gt;. By using the &lt;code&gt;:copen&lt;/code&gt; command a window showing the quickfix results will open. Move to the pattern via pressing &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; on a quickfix item.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I prefer to use a plugin for this. &lt;a href=&quot;https://github.com/henrik/vim-indexed-search&quot; rel=&quot;nofollow&quot;&gt;vim-indexed-search&lt;/a&gt; gives you a message in the command line such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2 of 32 matches&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will tell what number match that is from the top of the document.&lt;/p&gt;&#xA;" OwnerUserId="1691" LastEditorUserId="1821" LastEditDate="2015-08-19T20:51:48.000" LastActivityDate="2015-08-19T20:51:48.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4418" PostTypeId="1" AcceptedAnswerId="4419" CreationDate="2015-08-19T12:25:48.340" Score="18" ViewCount="32187" Body="&lt;p&gt;For a file looking like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   2  AD,42.546245,1.601554,Andorra,376&#xA;   3  AE,23.424076,53.847818,United Arab Emirates,971&#xA;   4  AF,33.93911,67.709953,Afghanistan,93&#xA;   5  AG,17.060816,-61.796428,Antigua and Barbuda,1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to remove the leading spaces and numbers for the first 10 lines, so I'd end up with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AD,42.546245,1.601554,Andorra,376&#xA;AE,23.424076,53.847818,United Arab Emirates,971&#xA;AF,33.93911,67.709953,Afghanistan,93&#xA;AG,17.060816,-61.796428,Antigua and Barbuda,1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does &quot;remove two words&quot; &lt;code&gt;:d2w&lt;/code&gt; work for a single line, but not for a range &lt;code&gt;:1,10d2w&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem itself is solved due to the fixed format, using &lt;code&gt;:1,10s/.\{8\}//&lt;/code&gt;, so this is more about understanding how to use ranges with &lt;code&gt;:dNw&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="3232" LastEditorUserId="1821" LastEditDate="2015-08-19T14:49:52.900" LastActivityDate="2015-08-20T04:50:32.527" Title="Execute normal command over range" Tags="|command-line|normal-mode|repeated-commands|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4419" PostTypeId="2" ParentId="4418" CreationDate="2015-08-19T12:32:52.083" Score="32" Body="&lt;p&gt;You can do this with the normal command : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,10normal d2w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because the &lt;code&gt;d&lt;/code&gt; operator doesn't accept a range, but only a motion :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h d&#xA;&#xA;[&quot;x]d{motion}           Delete text that {motion} moves over [into register x].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can select your text in visual mode and you can do :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;normal d2w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-08-20T04:50:32.527" LastActivityDate="2015-08-20T04:50:32.527" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4420" PostTypeId="2" ParentId="439" CreationDate="2015-08-19T22:17:30.210" Score="12" Body="&lt;p&gt;Another trick you may try is to use replace. Sometimes this might be useful.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/$\n//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Scenario: Delete the last character and join with the next line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/=$\n\(.\)/\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xxxx=&#xA;123&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xxxx123&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3240" LastEditorUserId="927" LastEditDate="2017-06-22T22:01:28.093" LastActivityDate="2017-06-22T22:01:28.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4422" PostTypeId="2" ParentId="4387" CreationDate="2015-08-20T01:59:26.240" Score="2" Body="&lt;p&gt;For someone who is trying the same of me, that is closest that i reached thanks to the answers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DiffWithPrevious()&#xA;  call clearmatches()&#xA;  undo&#xA;  redir =&amp;gt; message&#xA;  silent changes&#xA;  redir END&#xA;  let line = matchstr(message, '\v\n\s{4}1[^0-9]*\zs\d+\ze')&#xA;  highlight TemporalDiff ctermbg=black guibg=black&#xA;  let m = matchadd('TemporalDiff', '\%'.line.'l')&#xA;  redraw&#xA;  let gchar = getchar()&#xA;  highlight TemporalDiff ctermbg=none guibg=none&#xA;  let m = matchadd('TemporalDiff', '\%'.line.'l')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2131" LastEditorUserId="2131" LastEditDate="2015-08-20T16:04:09.650" LastActivityDate="2015-08-20T16:04:09.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4423" PostTypeId="1" CreationDate="2015-08-20T12:07:03.947" Score="0" ViewCount="1500" Body="&lt;p&gt;I just installed tmux, iTerm2 and Vim. However, when i open Vim i have this bar with arrows on the left side. I don't know if it's there because of Vim or the terminal emulator. Is there a way to remove it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FvTtl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FvTtl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3242" LastEditorUserId="1306" LastEditDate="2015-08-21T03:45:49.260" LastActivityDate="2015-08-21T03:45:49.260" Title="Remove left bar in vim" Tags="|vimrc|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="4424" PostTypeId="2" ParentId="4423" CreationDate="2015-08-20T14:34:13.413" Score="2" Body="&lt;p&gt;I see you have found the culprit plugin already, but here's how you could go hunting for it if it happens again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before the &lt;code&gt;pathogen#infect()&lt;/code&gt; line in your vimrc, first add &lt;code&gt;let g:pathogen_disabled = []&lt;/code&gt;&#xA;and then for each plugin add a line like &lt;code&gt;call add(g:pathogen_disabled, {plugin-name})&lt;/code&gt;. Then remove them or comment them out one by one until the undesirable behavior reappears.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin name corresponds to the folder name in your pathogen bundle folder. To quickly add all the plugins to the disabled list you can do, with your cursor on the line above &lt;code&gt;pathogen#infect()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:read !ls ~/.vim/bundle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gives you the names of all the plugins that pathogen loads. If your plugins are not in &lt;code&gt;.vim/bundle&lt;/code&gt; then adjust the path. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V'[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to select the lines you just added. Then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/.*/call add(g:pathogen_disabled, '\0')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to change each line into a call to add the plugin to the disabled list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, to answer your actual question, if you have signs and you want to remove them, you can do (see &lt;code&gt;:help signs&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sign unplace *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-08-20T14:34:13.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4425" PostTypeId="1" AcceptedAnswerId="4428" CreationDate="2015-08-20T17:32:01.023" Score="1" ViewCount="62" Body="&lt;p&gt;Kaoryia's gVim &lt;a href=&quot;http://www.kaoriya.net/software/vim/&quot; rel=&quot;nofollow&quot;&gt;builds&lt;/a&gt; for Win32/64 come with a number of extra, non-official patches enabled. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of them are pretty clear: &lt;code&gt;:set charspace=-1&lt;/code&gt;, for example, will tighten the space between characters; &lt;code&gt;:set transparency=250&lt;/code&gt; will do what its name implies. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there is also this patch: &lt;a href=&quot;https://bitbucket.org/koron/vim-kaoriya-patches/src/32dc7fa41a91/X008-async_job.diff&quot; rel=&quot;nofollow&quot;&gt;async job&lt;/a&gt;, by Taro MURAOKA, briefly described in the source as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;job.c - Asynchronous job support&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone know what exactly it does, with perhaps an example about its usage?&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-08-20T21:59:46.397" Title="async_job patch in Kaoryia's gVim (windows)" Tags="|gvim|microsoft-windows|async|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4426" PostTypeId="1" AcceptedAnswerId="4431" CreationDate="2015-08-20T21:35:09.503" Score="3" ViewCount="1546" Body="&lt;p&gt;I would like to add to my vimrc a custom command (&lt;code&gt;:customFilter {pattern}&lt;/code&gt;) for filtering text and placing result in a new tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using &lt;code&gt;:global&lt;/code&gt; or &lt;code&gt;:vimgrep /{pattern}/ %&lt;/code&gt; but the problem is that I would like to redirect this result of &lt;code&gt;global&lt;/code&gt; or content of &lt;code&gt;Quickfix list&lt;/code&gt; (without name of file) to a new tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;my file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class TemperatureNode {&#xA;    + uint8_t getTemperatureValue()&#xA;    + void setTemperatureValue(uint8_t newVal)&#xA;    + uint8_t getHumidityValue()&#xA;    + void setHumidityValue(uint8_t newVal)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then I call &lt;code&gt;:customFilter void&lt;/code&gt; and get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+ void setTemperatureValue(uint8_t newVal)&#xA;+ void setHumidityValue(uint8_t newVal)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Having this with line numbers from the filtered file would be even better.&lt;/p&gt;&#xA;" OwnerUserId="3254" LastEditorUserId="205" LastEditDate="2015-09-20T18:53:55.260" LastActivityDate="2015-09-20T18:53:55.260" Title="Filtering text out to new tab with custom command" Tags="|buffers|user-commands|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4427" PostTypeId="2" ParentId="4426" CreationDate="2015-08-20T21:56:45.697" Score="5" Body="&lt;p&gt;First clear an register: &lt;code&gt;qaq&lt;/code&gt;&#xA;second, append all matching lines using the &lt;code&gt;:g&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/pattern/y A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Third, put all matches on a new page&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabnew +$put\ A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to be able to make changes on those filtered mached, have a look at my &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn&quot;&gt;NrrwRgn Plugin&lt;/a&gt;. The advantage is, once you save the narrowed buffer, the changes will be taken back into the original buffer.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-08-20T21:56:45.697" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4428" PostTypeId="2" ParentId="4425" CreationDate="2015-08-20T21:59:46.397" Score="1" Body="&lt;p&gt;That patch job, defines a new VimL function &lt;code&gt;jobrun()&lt;/code&gt;. But you better ask at that repository for a documentation.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-08-20T21:59:46.397" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4429" PostTypeId="2" ParentId="4387" CreationDate="2015-08-20T22:03:17.493" Score="3" Body="&lt;p&gt;Check my &lt;a href=&quot;https://github.com/chrisbra/changesPlugin&quot; rel=&quot;nofollow&quot;&gt;changes plugin&lt;/a&gt; and be sure to set the variable &lt;code&gt;g:changes_linehi_diff&lt;/code&gt; to 1&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-08-20T22:03:17.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4430" PostTypeId="1" AcceptedAnswerId="4471" CreationDate="2015-08-21T05:20:09.763" Score="2" ViewCount="1517" Body="&lt;p&gt;I'm trying to add a simple mapping to visually select recently pasted text. However, even though &lt;code&gt;`[v`]&lt;/code&gt; is working correctly in a vim session, when I try to use it in my .vimrc file, it doesn't work. Other mappings work correctly, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the mapping as described &lt;a href=&quot;https://vi.stackexchange.com/questions/31/how-do-i-visually-select-the-block-of-text-i-just-pasted-in-vim&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap  gV `[v`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What could be causing this issue? I tried to disable the plugins but the issue still occurs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, the keyboard I'm using was configured to include a dead tilde. I just changed it to type backtick &lt;code&gt;`&lt;/code&gt; instead of &lt;code&gt;`&amp;lt;space&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried to change the encoding using &lt;code&gt;set encoding=utf-8&lt;/code&gt; but didn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I can't escape backticks in the comments, I will be answering here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Nobe4 I'm just adding &lt;code&gt;nnoremap gV `[v`]&lt;/code&gt; at the end of my .vimrc file and then after pasting some text, I press gV. As I said, other mappings are working but this one doesn't do anything noticeable. I also tried to use gp as a replacement, but then vim listens to the p command and simply pastes again the same text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Christian Brabandt The thing that doesn't work is the mapping from gV to &lt;code&gt;`[v`]&lt;/code&gt;. If I type &lt;code&gt;`[v`]&lt;/code&gt; in some file, it does visually select the pasted text as intended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Nobe4 helped me to figure this out. The issue was that vim wasn't responding to mappings containing two (or more) characters. The issue was caused by the timeoutlen option. I'm using set timeoutlen=50 to remove a delay after pressing escape in order to change to normal mode. In the meanwhile, I change it to timeoutlen=300 but this has a noticeable delay in the status bar. Any suggestions are welcomed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE 3: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Okay. I'm using &lt;code&gt;set timeoutlen=1000 ttimeoutlen=10&lt;/code&gt; and now the delay is fixed and mappings are working correctly. Hopefully, this won't have unintended effects down the road.&lt;/p&gt;&#xA;" OwnerUserId="210" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-08-22T22:02:55.063" Title="nnoremap is not working with `[v`]" Tags="|key-bindings|" AnswerCount="1" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="4431" PostTypeId="2" ParentId="4426" CreationDate="2015-08-21T09:19:24.543" Score="7" Body="&lt;p&gt;You can create a new empty buffer in a new tab and then populate it with the result of a grep search on the previous file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabnew|0r!grep -n pattern #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :tabnew\|0r!grep -n  #&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which works like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bsoAY.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bsoAY.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--- edit ---&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an alternative command that works with the current buffer instead of the current file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%y z|tabnew|0put=@z|%!grep -n pattern&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%y z                 &quot; yank the whole buffer in register z&#xA;:tabnew               &quot; edit a new buffer in a new tab&#xA;:0put=@z              &quot; put the yanked text in that new buffer&#xA;:%!grep -n pattern    &quot; do your filtering&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -nargs=1 -range=% Filter &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;y z|tabnew|0put=@z|%!grep -n '&amp;lt;q-args&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Filter pattern        &quot; works on the whole buffer by default&#xA;:5,20Filter pattern    &quot; works on the supplied range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-08-21T19:56:16.217" LastActivityDate="2015-08-21T19:56:16.217" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4432" PostTypeId="1" AcceptedAnswerId="4433" CreationDate="2015-08-21T09:43:09.933" Score="2" ViewCount="2402" Body="&lt;p&gt;I have several lines, and each line has 2 quoted string, and I want to replace all space with &amp;quot;_&amp;quot; for the first quoted string.&lt;/p&gt;&#xA;&lt;p&gt;How to do that? Could I use macro?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;select 'a b c','a b c' union all&#xA;select 'a e1 c d','a e1 c d' union all&#xA;select 'a f11 c','a f11 c' union all&#xA;select 'a g1 c','a g1 c' union&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;result:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;select 'a_b_c','a b c' union all&#xA;select 'a_e1_c_d','a e1 c d' union all&#xA;select 'a_f11_c','a f11 c' union all&#xA;select 'a_g1_c','a g1 c' union&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3262" LastEditorUserId="23502" LastEditDate="2022-11-05T09:21:24.187" LastActivityDate="2022-11-05T09:21:24.187" Title="How to replace all space with &quot;_&quot; for the first quoted string?" Tags="|gvim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4433" PostTypeId="2" ParentId="4432" CreationDate="2015-08-21T09:52:02.503" Score="5" Body="&lt;p&gt;I think the macro is a good use here :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0vi':s/\%V /_/g^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing the macro : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0        &quot; go to the start of the line&#xA;vi'      &quot; visually select inside '&#xA;:s/       &quot; start a substitute command&#xA;\%V      &quot; tell the substitute to operate over the last visual selection&#xA; /_/g    &quot; there is a ' ' here : replace every ' ' with a '_'&#xA;^M       &quot; press &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reference for &lt;code&gt;\%V&lt;/code&gt; : &lt;a href=&quot;http://vim.wikia.com/wiki/Search_and_replace_in_a_visual_selection&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Search_and_replace_in_a_visual_selection&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then go line over line, or execute the macro over all lines at the same time (see &lt;a href=&quot;https://stackoverflow.com/a/3338480/2558252&quot;&gt;https://stackoverflow.com/a/3338480/2558252&lt;/a&gt;) &lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-21T13:47:41.147" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4434" PostTypeId="2" ParentId="4432" CreationDate="2015-08-21T10:22:16.000" Score="6" Body="&lt;p&gt;A macro like @Nobe4's may be the easiest, but you could also do a substitution. It can be tricky to express the substitution since you want it to be 'global' within the quoted string, but not really global for the line (i.e., replace &lt;em&gt;all&lt;/em&gt; whitespace, but only for the first quoted string on the line). One way is to do a non-global substitution to replace the whole first quoted string, and for replacement use an expression which makes a global substitution on that string from ' ' to '_'.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/'[^']*'/\=substitute(submatch(0), ' ', '_', 'g')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/'.\{-}'/\=substitute(submatch(0), ' ', '_', 'g')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe this feels a little clunky compared to a macro, but it can be a useful technique sometimes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Details&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:&lt;/code&gt; - enter cmdline mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt; - for all lines in buffer&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s&lt;/code&gt; - substitute (the three &lt;code&gt;/&lt;/code&gt; characters delimit the substitute command, see &lt;code&gt;:help :substitute&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'.\{-}'&lt;/code&gt; or &lt;code&gt;'[^']*'&lt;/code&gt; - regex that matches anything surrounded by single quotes&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\=&lt;/code&gt; - substitute with an expression (see &lt;code&gt;:help sub-replace-expression&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;substitute()&lt;/code&gt; - the expression is a call to &lt;code&gt;:help substitute()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;submatch(0)&lt;/code&gt; - the entire matched string is retrieved with &lt;code&gt;submatch(0)&lt;/code&gt; and is the first argument to &lt;code&gt;substitute()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;' ', '_'&lt;/code&gt; - the substitution on the string&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'g'&lt;/code&gt; - global flag, i.e., substitute all occurrences&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If we had ended the &lt;code&gt;:substitute&lt;/code&gt; command with a global flag (&lt;code&gt;/g&lt;/code&gt;) then it would have substituted all occurrences of quoted strings on the line. As it is, it only does the first. In the call to &lt;code&gt;substitute()&lt;/code&gt; however we do use the global flag (&lt;code&gt;'g'&lt;/code&gt;) in order to replace all occurrences of &lt;code&gt;' '&lt;/code&gt; in the quoted string.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="1306" LastEditDate="2015-08-21T10:40:56.430" LastActivityDate="2015-08-21T10:40:56.430" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4435" PostTypeId="1" AcceptedAnswerId="4441" CreationDate="2015-08-21T13:25:39.340" Score="5" ViewCount="637" Body="&lt;p&gt;Today I found myself struggling with Vim while being on the phone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had only one hand to move around, so the home row was fine but with small hands, every &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt; shortcuts (&lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt;, ...) is a pain to achieve. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I think that I should always use my two hands to use Vim, I found interesting the question : &lt;strong&gt;How can I use Vim with only one hand ?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-08-22T15:46:52.240" Title="One-handed Vim utilisation" Tags="|cursor-movement|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4436" PostTypeId="1" CreationDate="2015-08-21T15:05:43.990" Score="3" ViewCount="1206" Body="&lt;p&gt;I majorly use vim over an ssh session using putty. Sometimes I may have to copy code from ssh in a vim session but it's not very convenient. I do the following :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-w&amp;gt;o&#xA;:set nu!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This close all splits that I have. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way just for me to expand the current window to the whole screen temporarily and recover all closed splits afterward?&lt;/p&gt;&#xA;" OwnerUserId="1097" LastEditorUserId="1097" LastEditDate="2015-08-21T20:17:52.957" LastActivityDate="2018-07-22T08:30:34.927" Title="Reopen splits after closing them with &lt;C-w&gt;o" Tags="|vim-windows|split|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4437" PostTypeId="1" AcceptedAnswerId="4442" CreationDate="2015-08-21T15:21:05.060" Score="3" ViewCount="919" Body="&lt;p&gt;Is there a way to sort a list (single column, each item separated by &lt;code&gt;\r&lt;/code&gt;) in the buffer using just vim?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2015-08-22T14:37:15.877" Title="Sorting a list in the buffer?" Tags="|sort|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4438" PostTypeId="1" AcceptedAnswerId="4439" CreationDate="2015-08-21T15:24:57.410" Score="0" ViewCount="91" Body="&lt;p&gt;How can I link the vsplit views of two buffers so that the lines from both files are always in sync?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2015-08-21T15:29:17.283" Title="Linking the vsplit views of two different buffers?" Tags="|split|" AnswerCount="1" CommentCount="0" ClosedDate="2015-08-21T15:39:53.780" ContentLicense="CC BY-SA 3.0" />
  <row Id="4439" PostTypeId="2" ParentId="4438" CreationDate="2015-08-21T15:29:17.283" Score="2" Body="&lt;p&gt;You should check the &lt;code&gt;scrollbind&lt;/code&gt; option : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set scrollbind&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See : &lt;code&gt;:h scroll-binding&lt;/code&gt; for further reference.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-08-21T15:29:17.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4440" PostTypeId="1" AcceptedAnswerId="4444" CreationDate="2015-08-21T15:29:47.577" Score="3" ViewCount="227" Body="&lt;p&gt;If I'm running a complex macro on a large file that I expect to take a few minutes, is it OK to do other stuff on the system (e.g. opening another application, typing in a different text editor, etc?) or could my mouse movements and keyboard inputs cause the macro to go nuts?&lt;/p&gt;&#xA;" OwnerUserId="3264" LastActivityDate="2016-02-10T11:01:09.230" Title="Is it safe to do other stuff on a system while a macro runs?" Tags="|macro|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4441" PostTypeId="2" ParentId="4435" CreationDate="2015-08-21T16:27:06.370" Score="4" Body="&lt;p&gt;Any attempt to customize vim for one-handed use would almost certainly involve remapping a lot of the basic commands -- probably based on the preference and habits of the user in question (for example, which motions do you use most often, et cetera). Since that is highly subjective, I'll mostly gloss over it other than to note it as a likely step in the process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of that, though, one consideration would be specialized hardware that offers more keystroke possibilities to a single handle, perhaps something like a &lt;a href=&quot;https://en.wikipedia.org/wiki/Chorded_keyboard&quot; rel=&quot;nofollow&quot;&gt;chorded keyboard&lt;/a&gt; or even one of those crazy, gaming-oriented &quot;&lt;a href=&quot;http://gaming.logitech.com/en-us/product/g13-advanced-gameboard&quot; rel=&quot;nofollow&quot;&gt;gamerboards&lt;/a&gt;.&quot; Devices which either re-position keys to put more within easy reach of one hand, or which facilitate a greater number of actual keystrokes through chording, may be able to make up for the efficiency and ergonomics loss of having to use one hand on a traditional keyboard (and thus move it around a lot more to get to all the keys).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chorded devices are probably more likely, as at some point you're probably still going to enter insert mode and want to type actual text, and I'm not sure how viable that would be on something like that gamerboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mental investment would be high enough that I doubt it would be useful for dealing with the scenario you mentioned (vim'ing while on the phone), but might be more applicable for people with long-term injury or disability that prevents them from using two hands &quot;normally.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another interesting possibility to consider is that of using two hands, but not necessarily both at the same time. I briefly owned one of &lt;a href=&quot;http://gaming.logitech.com/en-us/product/g600-mmo-gaming-mouse&quot; rel=&quot;nofollow&quot;&gt;these mice&lt;/a&gt;, which I found overall to be rather horrid...  but its got 12 thumbable buttons on the side that can be shifted to another 12 via a ring-finger button, for a total of 24 distinct inputs. It made me think there might be a scenario where you could find some useful vim commands to map to those buttons, ones you found yourself using near when you also found yourself using the mouse for outside tasks, for example.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2015-08-21T16:27:06.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4442" PostTypeId="2" ParentId="4437" CreationDate="2015-08-21T16:29:10.560" Score="5" Body="&lt;p&gt;You can use the built-in sort utility:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or pipe the buffer to an external Unix command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!sort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more info and options see &lt;code&gt;:help :sort&lt;/code&gt; and &lt;code&gt;man sort&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3079" LastEditorUserId="3079" LastEditDate="2015-08-22T14:37:15.877" LastActivityDate="2015-08-22T14:37:15.877" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4443" PostTypeId="2" ParentId="4436" CreationDate="2015-08-21T16:51:15.567" Score="1" Body="&lt;p&gt;As guidelines, I would do something like :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let splits={}&#xA;&#xA;function! Clean()&#xA;  &quot; Populate splits with the current splits&#xA;endfunction&#xA;&#xA;function! Restore()&#xA;  &quot; Restore the splits from the variable splits&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can look at &lt;code&gt;:h usr_41.txt&lt;/code&gt; that contains a lot of function you can call to get all informations you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bufname()       get the name of a specific buffer&#xA;...&#xA;winheight()     get height of a specific window&#xA;winwidth()      get width of a specific window&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can look up for dictionnaries here &lt;code&gt;:h 'dictionary'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-08-21T16:51:15.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4444" PostTypeId="2" ParentId="4440" CreationDate="2015-08-21T17:29:29.327" Score="8" Body="&lt;p&gt;Indeed it is pretty safe to manipulate other programs while a macro is executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A macro simulates keystrokes within Vim which has no interaction with external GUI applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As macros don't depend on the movement of the mouse, no conflicts can appear &lt;em&gt;(Or at least I've never experienced them or heard of someone who has)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; As Sato observed in the comments, one element is shared between Vim and other applications: the clipboard. That means that if your Vim macro uses the system clipboard and you copy something new while it is executed, you might have unexpected results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best solution to this problem is to put the content of your system clipboard into a Vim register before recording the macro and to use this register in the macro.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="343" LastEditDate="2016-02-10T11:01:09.230" LastActivityDate="2016-02-10T11:01:09.230" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4445" PostTypeId="2" ParentId="4436" CreationDate="2015-08-21T17:56:57.283" Score="2" Body="&lt;p&gt;You could use sessions if you don't feel like creating a function (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/starting.html#views-sessions&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h view-sessions&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before closing your splits simple do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:mksession ~/tmp.session&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will save the current layout in the file &lt;code&gt;~/tmp.session&lt;/code&gt; (of course you can change the file path)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then expand your window as you usually do and then use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:source ~/tmp.session&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will restore the layout saved in the file.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also you can even simplify it, knowing that without argument &lt;code&gt;:mksession&lt;/code&gt; will create the file &lt;code&gt;~/Session.vim&lt;/code&gt; you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :mksession&amp;lt;CR&amp;gt; :only&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping will save your session and &quot;maximize&quot; the current window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then create this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :source ~/Session.vim&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to easily get your session back.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; In the comments HuStmpHrr mentionned an issue with &lt;code&gt;:mksession&lt;/code&gt; and &lt;code&gt;NERDTree&lt;/code&gt;. Actually the problem comes from the way &lt;code&gt;NERDTree&lt;/code&gt; creates its buffers: from what I have understood it actually creates a buffer, do some stuff, delete this buffer and create another one and do some stuff again (see &lt;a href=&quot;https://vi.stackexchange.com/a/4377/1841&quot;&gt;this nobe4 answer&lt;/a&gt; mentionning this).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion the wiser is to do more or less like in &lt;a href=&quot;https://stackoverflow.com/a/7590615/4194289&quot;&gt;this answer&lt;/a&gt;: closing NERDTree before making a session and opening it after restoring it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A workaround could then be to create these functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyMkSession(filePath)&#xA;    NERDTreeClose&#xA;    execute &quot;mksession! &quot; . a:filePath&#xA;endfunction&#xA;&#xA;function! MySoSession(filePath)&#xA;    execute &quot;source &quot; . a:filePath&#xA;    NERDTree&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And to use them instead of the built-in ones. That is neither clean or elegant but that could do the job.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-22T11:02:57.407" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4446" PostTypeId="2" ParentId="4436" CreationDate="2015-08-21T20:10:37.487" Score="6" Body="&lt;p&gt;Here is a safer way to do what you are currently doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabe %|set nonu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once you are done, close that tab page with &lt;code&gt;:q&lt;/code&gt; to go back to the previous tab page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--- edit ---&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A similar workflow for transient buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabnew|set nonu|b#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;--- endedit ---&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, you should probably try &quot;X forwarding&quot; which allows you to share clipboard over the wire:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ssh -X ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;$ man ssh&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-08-26T12:52:46.563" LastActivityDate="2015-08-26T12:52:46.563" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4447" PostTypeId="1" CreationDate="2015-08-22T05:21:41.963" Score="4" ViewCount="1097" Body="&lt;p&gt;When I'm writing over webdavfs vim temporary doesn't handle temporary files properly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ll -a&#xA;ls: cannot access .htaccess.swp: No such file or directory&#xA;ls: cannot access .htaccess.swx: No such file or directory&#xA;total 15196&#xA;drwxrwxr-x  2 sergio sergio     448 Ago 22 04:48 .&#xA;drwx------ 12 sergio sergio     528 Ago 22 04:47 ..&#xA;-rw-rw-r--  1 sergio sergio      21 Ago 22 04:48 .htaccess&#xA;-?????????  ? ?      ?            ?            ? .htaccess.swp&#xA;-?????????  ? ?      ?            ?            ? .htaccess.swx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How I can open a file with vim setting swap files in other directory ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note I just want this happens when I'm under webdav directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE : &#xA;yes, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim &quot;+set noswapfile&quot; .htaccess &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could be a solution but somehow the files .htaccess.swp .htaccess.swx still appears in webdav directory ... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update 2016-03-16:&#xA;still don't have an working solution , Editing like Remote Files may be a solution, anyone ?&#xA;other solution seems to be &lt;a href=&quot;https://github.com/kana/vim-metarw&quot; rel=&quot;nofollow&quot;&gt;https://github.com/kana/vim-metarw&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update 2016-09-11:&#xA;something like this could work , but seems works even better edit ~/.davfs2/davfs2.conf and set &quot;use_locks       0&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if expand(&quot;%:p:h&quot;) =~ '^/home/sergio/webdav'&#xA;     echo &quot;in webdav dir&quot;&#xA;     set directory=/tmp&#xA;     set backupdir=/tmp&#xA;     colorscheme desert&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3271" LastEditorUserId="3271" LastEditDate="2016-09-11T03:37:28.510" LastActivityDate="2016-09-11T03:37:28.510" Title="How to prevent vim from creating (and leaving) temporary files over webdav?" Tags="|swap-file|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4448" PostTypeId="2" ParentId="4447" CreationDate="2015-08-22T10:10:38.930" Score="5" Body="&lt;p&gt;The options you need are &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27directory%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;directory&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27backupdir%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;backupdir&lt;/code&gt;&lt;/a&gt; they allow you to set the directory where swap files and backup files are stored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second part of the problem is how to detect that you are editting files in a webdav directory to set these options. I would have tried an autocommand to do so but according to &lt;a href=&quot;http://vim.1045645.n5.nabble.com/Changing-location-of-swap-directory-for-selected-files-how-to-td5710693.html&quot; rel=&quot;nofollow&quot;&gt;this discussion&lt;/a&gt; it seems to be pretty hard: From what I have understood, they didn't managed to trigger an autocommand before the swap file is created (so changing the values of the swap directory is useless).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I could suggest to ease the process is either to definitely set the directory options for all your files or insert the following lines in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:directory_save  = &amp;amp;directory&#xA;let g:bdirectory_save = &amp;amp;backupdir&#xA;let g:currentDirState = 0&#xA;&#xA;function! ChangeSwapDir()&#xA;    if (g:currentDirState)&#xA;        let g:currentDirState = 0&#xA;        set directory=~/tmp&#xA;        set backupdir=~/tmp&#xA;    else&#xA;        let g:currentDirState = 1&#xA;        execute &quot;set directory=&quot; . g:directory_save &#xA;        execute &quot;set backupdir=&quot; . g:bdirectory_save&#xA;    endif&#xA;endfunction&#xA;&#xA;command CSD call ChangeSwapDir()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first 3 lines are used to save your default settings and initialize a variable which will tell us in what state the options are.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The function is used to switch the swap directory either to the default settings or to &lt;code&gt;~/tmp&lt;/code&gt; (of course you can change that to your prefered directory).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note that the function can be optimized and rewritten, I wrote it this way so that a newcomer to vimscript can understand it easily&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;And the last line allows you to call the function more easily with the command &lt;code&gt;:CSD&lt;/code&gt; (you can add a mapping if you want).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The idea is to call it each time you'll begin to edit files over webdav to set the directory to &lt;code&gt;~/tmp&lt;/code&gt; and call it again when you finished to come back to default. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is probably not as convenient as auto detecting that you are editing files in webdav directory but that seems to be a working workaround.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T21:26:42.897" LastActivityDate="2015-08-22T21:26:42.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4449" PostTypeId="5" CreationDate="2015-08-22T11:21:11.407" Score="0" Body="&lt;p&gt;Interesting related help topic:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27number%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h number&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27relativenumber%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h relativenumber&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="15" LastEditDate="2015-08-29T18:00:13.467" LastActivityDate="2015-08-29T18:00:13.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4450" PostTypeId="4" CreationDate="2015-08-22T11:21:11.407" Score="0" Body="Vim can output the number of each line on the left side of the screen. Questions about customizing this behavior." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T14:19:54.737" LastActivityDate="2015-08-22T14:19:54.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4451" PostTypeId="2" ParentId="4435" CreationDate="2015-08-22T15:46:52.240" Score="2" Body="&lt;p&gt;Many Linux desktop environments support 'sticky keys' among the assistive technologies for disabled persons. This allows a modifier key such as control to be pressed and released and then the second key pressed to complete the compound action.&lt;/p&gt;&#xA;" OwnerUserId="3276" LastActivityDate="2015-08-22T15:46:52.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4452" PostTypeId="1" CreationDate="2015-08-22T19:24:39.017" Score="28" ViewCount="7559" Body="&lt;p&gt;I usually work in a drop-down terminal, running about 25 characters high. Since I prefer tabs to windows&lt;sup&gt;1&lt;/sup&gt;, usually a lot of horizontal space is wasted - around half of the terminal width. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On top of that, Vim, with the default setting of &lt;code&gt;helpheight&lt;/code&gt;, leaves just about a couple of lines of the file content when I open a help window:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mdDwY.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mdDwY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make &lt;code&gt;:h&lt;/code&gt; use a vertical split?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;decrease &lt;code&gt;helpheight&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;&amp;lt;C-W&amp;gt;L&lt;/code&gt; to manually move the window&lt;/li&gt;&#xA;&lt;li&gt;make a map or a custom command which does the above for me.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is there a simpler way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sup&gt;1&lt;/sup&gt;I &lt;em&gt;do&lt;/em&gt; use windows when I need to look at multiple files together. But usually I prefer each file to be in its own (mental) context.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-08-22T21:41:31.047" LastActivityDate="2023-01-04T00:58:29.650" Title="How can I make Vim open help in a vertical split?" Tags="|vim-windows|help-system|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4453" PostTypeId="2" ParentId="4452" CreationDate="2015-08-22T19:28:37.903" Score="26" Body="&lt;p&gt;You can use &lt;code&gt;:vert h [your topic]&lt;/code&gt; to open help vertically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev H vert h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make vim replace &lt;code&gt;H&lt;/code&gt; by &lt;code&gt;vert h&lt;/code&gt; automatically in command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you can use this abbreviation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev HR vert bo h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To open the help window on the right side of the screen. (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#:botright&quot;&gt;&lt;code&gt;:h :botright&lt;/code&gt;&lt;/a&gt; for more details on &lt;code&gt;bo&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T19:46:20.043" LastActivityDate="2015-08-22T19:46:20.043" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4454" PostTypeId="2" ParentId="3830" CreationDate="2015-08-22T19:35:32.603" Score="1" Body="&lt;p&gt;As far as I can tell, there's nothing official in Vim about using such meta-tags in comments. As Carpetsmoker says, it's likely a habit carried over by people usually working in other environments. I don't often use such tags myself, but they remind me of the &lt;a href=&quot;http://download.java.net/jdk7u2/docs/technotes/tools/solaris/javadoc.html#javadoctags&quot; rel=&quot;nofollow&quot;&gt;Javadoc meta tags&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@author&#xA;{@code}&#xA;{@docRoot}&#xA;@deprecated&#xA;@exception&#xA;{@inheritDoc}&#xA;{@link}&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-08-22T19:35:32.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4455" PostTypeId="2" ParentId="4452" CreationDate="2015-08-22T19:49:32.433" Score="0" Body="&lt;p&gt;While this isn't a vertical split per-se, I find having help in its own tab to be very nice.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup HelpInTabs&#xA;autocmd!&#xA;   autocmd BufEnter *.txt call HelpInNewTab()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whoops. I thought I had pasted the whole answer. Here's the rest of the code.   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; only apply to help files...&#xA;function! HelpInNewTab ()&#xA;  if &amp;amp;buftype == 'help'&#xA;    &quot; convert help window to a tab&#xA;    execute &quot;normal \&amp;lt;C-W&amp;gt;T&quot;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2831" LastEditorUserId="2831" LastEditDate="2015-08-24T19:14:12.013" LastActivityDate="2015-08-24T19:14:12.013" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4456" PostTypeId="5" CreationDate="2015-08-22T20:17:52.997" Score="0" Body="&lt;p&gt;Whitespaces characters include tabs and spaces characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details on how to customize Vim representation of these characters ones can see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27listchars%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 'listchars'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27list%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 'list'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T22:12:15.300" LastActivityDate="2015-08-22T22:12:15.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4457" PostTypeId="4" CreationDate="2015-08-22T20:17:52.997" Score="0" Body="Question about how Vim handles non printable characters." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T22:13:07.137" LastActivityDate="2015-08-22T22:13:07.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4458" PostTypeId="5" CreationDate="2015-08-22T20:22:02.973" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#cmdline-history&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h cmdline-history&lt;/code&gt;&lt;/a&gt; for details on the different existing histories.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T22:13:01.457" LastActivityDate="2015-08-22T22:13:01.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4459" PostTypeId="4" CreationDate="2015-08-22T20:22:02.973" Score="0" Body="Questions about how Vim records the commands issues by the user and how to customize this behavior." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T22:11:58.627" LastActivityDate="2015-08-22T22:11:58.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4460" PostTypeId="5" CreationDate="2015-08-22T20:32:38.537" Score="0" Body="&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#abbreviations&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h abbreviations&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Abbreviations are used in Insert mode, Replace mode and Command-line mode.&#xA;If you enter a word that is an abbreviation, it is replaced with the word it&#xA;stands for.  This can be used to save typing for often used long words.  And&#xA;you can use it to automatically correct obvious spelling errors.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T22:12:48.147" LastActivityDate="2015-08-22T22:12:48.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4461" PostTypeId="4" CreationDate="2015-08-22T20:32:38.537" Score="0" Body="Vim can handle abbreviations to replace some text by some other text. Question about creating these abbreviations and how to make them work." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T22:12:40.110" LastActivityDate="2015-08-22T22:12:40.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4462" PostTypeId="5" CreationDate="2015-08-22T20:35:54.767" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;http://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-package-managers&quot;&gt;this question&lt;/a&gt; for a quick overview of plugin-managers.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T22:12:53.660" LastActivityDate="2015-08-22T22:12:53.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4463" PostTypeId="4" CreationDate="2015-08-22T20:35:54.767" Score="0" Body="Questions about general use of plugins managers." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T22:12:56.477" LastActivityDate="2015-08-22T22:12:56.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4464" PostTypeId="2" ParentId="4452" CreationDate="2015-08-22T20:47:58.847" Score="9" Body="&lt;p&gt;This is inspired from &lt;a href=&quot;https://github.com/junegunn/dotfiles/blob/master/vimrc#L1556&quot; rel=&quot;noreferrer&quot;&gt;junegunn 's &lt;em&gt;vimrc&lt;/em&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc_help&#xA;  autocmd!&#xA;  autocmd BufEnter *.txt if &amp;amp;buftype == 'help' | wincmd L | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-08-22T21:26:47.447" LastActivityDate="2015-08-22T21:26:47.447" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4465" PostTypeId="5" CreationDate="2015-08-22T20:49:43.517" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://tmux.github.io/&quot; rel=&quot;nofollow&quot;&gt;Tmux&lt;/a&gt; is a terminal multiplexer for unix systems which allows to split a terminal window into several panes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ones can find several plugin to improve the integration of vim in tmux like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator&quot; rel=&quot;nofollow&quot;&gt;vim-tmux-navigator&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/benmills/vimux&quot; rel=&quot;nofollow&quot;&gt;vimux&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/wellle/tmux-complete.vim&quot; rel=&quot;nofollow&quot;&gt;tmux-complete&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T22:13:13.153" LastActivityDate="2015-08-22T22:13:13.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4466" PostTypeId="4" CreationDate="2015-08-22T20:49:43.517" Score="0" Body="Questions about using vim into a tmux session and how to customize integration." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-22T22:12:51.343" LastActivityDate="2015-08-22T22:12:51.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4467" PostTypeId="5" CreationDate="2015-08-22T21:12:31.287" Score="0" Body="&lt;p&gt;Vim has a number of different ways to break or display long lines. This tag should be used for question that relate line-breaking questions on the display or changing the line breaks in the file.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-23T01:12:32.127" LastActivityDate="2015-08-23T01:12:32.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4468" PostTypeId="4" CreationDate="2015-08-22T21:12:31.287" Score="0" Body="Breaking of lines on the display or in the file." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-23T01:12:26.027" LastActivityDate="2015-08-23T01:12:26.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4469" PostTypeId="5" CreationDate="2015-08-22T21:19:01.257" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-08-22T21:19:01.257" LastActivityDate="2015-08-22T21:19:01.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4470" PostTypeId="4" CreationDate="2015-08-22T21:19:01.257" Score="0" Body="Questions about moving, deleting, or opening files; or about the difference between a buffer and its file. For topics such as saving files, use the buffers tag instead. " OwnerUserId="1841" LastEditorUserId="205" LastEditDate="2015-08-22T22:26:55.133" LastActivityDate="2015-08-22T22:26:55.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4471" PostTypeId="2" ParentId="4430" CreationDate="2015-08-22T21:50:51.973" Score="4" Body="&lt;p&gt;After some discussion with &lt;a href=&quot;https://vi.stackexchange.com/users/210/robert-smith&quot;&gt;Robert Smith&lt;/a&gt;, here is the conclusion:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem was not the mapping nor the command per se. The problem was the timeout that the vim configuration was using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timeout is configured by the options: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;timeoutlen   : mapping delay&#xA;ttimeoutlen  : key code delay &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, in MacVim 7.4 the default configuration is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;timeoutlen=1000&#xA;ttimeoutlen=-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It means that for both mappings and key codes, the time of 1000 ms is applied. Vim will wait 1 second before the mapping/key code completes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The set of values that solves the problem are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;timeoutlen=1000 &#xA;ttimeoutlen=10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It means that a mapping will wait 1 second to complete (as before) whereas a keycode will complete after only 10ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When checking for a non-firing mapping, it should be good advice to see those values.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-08-22T22:02:55.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4472" PostTypeId="2" ParentId="4452" CreationDate="2015-08-22T22:06:29.930" Score="7" Body="&lt;p&gt;You can use a custom command that does the vertical-or-not selection for you. This can be based on the current window width and height : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:ShowHelp(tag) abort&#xA;  if winheight('%') &amp;lt; winwidth('%')&#xA;    execute 'vertical help '.a:tag&#xA;  else&#xA;    execute 'help '.a:tag&#xA;  endif&#xA;endfunction&#xA;&#xA;command! -nargs=1 H call s:ShowHelp(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;References : &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h winheight&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h &amp;lt;f-args&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-08-22T22:06:29.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4473" PostTypeId="2" ParentId="4397" CreationDate="2015-08-23T09:11:30.767" Score="1" Body="&lt;h1&gt;TL;DR&lt;/h1&gt;&#xA;&lt;p&gt;You'll have to rely on some external tool. So either build a wrapper that support multi-language or use an existing one that may not support multi language.&lt;/p&gt;&#xA;&lt;h1&gt;The problem&lt;/h1&gt;&#xA;&lt;p&gt;I think the main problem around multi-language syntax and grammar (&lt;code&gt;iabbrev S/G syntax and grammar&lt;/code&gt;) correcting is that you always have to rely on some external tools that may not work for all languages. I'm thinking about &lt;a href=&quot;http://www.afterthedeadline.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;afterthedeadline&lt;/a&gt; that has a convenient vim plugin but (from what I found) only correct english. So if you want only english, you can settle with this one but, as you specified, you want to correct french too (and maybe one day spanish or german, ... ). So a common multi-language S/G checker should achieve this.&lt;/p&gt;&#xA;&lt;h1&gt;The Research&lt;/h1&gt;&#xA;&lt;p&gt;We're on internet ! So you can find anything that can help you. And there are a &lt;strong&gt;LOT&lt;/strong&gt; of S/G you can use freely. e.g.:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.spellchecker.net/german_spell_checker.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;german&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://bonpatron.com/en/&quot; rel=&quot;nofollow noreferrer&quot;&gt;french&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://spellcheckplus.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;english&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;And one in particular: &lt;a href=&quot;http://www.reverso.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;reverso&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I first used this website because as a non-english native I did a lot of translation from this site (where the quality of translation impressed me). And I just found out that they also so a syntax checker for English and French. So basically what you are searching for.&lt;/p&gt;&#xA;&lt;h1&gt;The Digging&lt;/h1&gt;&#xA;&lt;p&gt;To use this from Vim I wanted to have a curl-only interface with the website, so I started analysing the request to narrow my search to :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;curl -X &amp;quot;POST&amp;quot; &amp;quot;http://www.reverso.net/spell-checker/french-spelling-grammar/SpellerRequests.aspx&amp;quot; \&#xA;    --data-urlencode &amp;quot;language=fr&amp;quot; \&#xA;    --data-urlencode &amp;quot;interfLang=en&amp;quot; \&#xA;    --data-urlencode &amp;quot;passPhrase=a long passphrase&amp;quot; \&#xA;    --data-urlencode &amp;quot;dictionary=both&amp;quot; \&#xA;    --data-urlencode &amp;quot;lang=en &amp;quot; \&#xA;    --data-urlencode &amp;quot;inputstring=Bnjour tout le monde&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And the result was:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; &amp;lt;CheckSpellingResult&amp;gt;&#xA;    &amp;lt;document xmlns=&amp;quot;&amp;quot;&amp;gt;&#xA;      &amp;lt;sentences nb=&amp;quot;1&amp;quot;&amp;gt;&#xA;        &amp;lt;sentence id=&amp;quot;0&amp;quot; start=&amp;quot;0&amp;quot; length=&amp;quot;20&amp;quot; language=&amp;quot;Fr&amp;quot;&amp;gt;&#xA;          &amp;lt;inputText&amp;gt; Bnjour tout le monde&amp;lt;/inputText&amp;gt;&#xA;          &amp;lt;errors nb=&amp;quot;1&amp;quot;&amp;gt;&#xA;            &amp;lt;error id=&amp;quot;0&amp;quot; type=&amp;quot;spell&amp;quot; substitution=&amp;quot;&amp;quot; start=&amp;quot;0&amp;quot; end=&amp;quot;6&amp;quot; proba=&amp;quot;100&amp;quot;&amp;gt;&#xA;              &amp;lt;message&amp;gt; #!Bnjour#$ : mot inconnu de nos dictionnaires, il pourrait être remplacé par: #!Bonjour#$,#! BN jour#$.&amp;lt;/message&amp;gt;&#xA;              &amp;lt;alternatives nb=&amp;quot;3&amp;quot;&amp;gt;&#xA;                &amp;lt;alternative id=&amp;quot;0&amp;quot;&amp;gt; Bnjour&amp;lt;/alternative&amp;gt;&#xA;                &amp;lt;alternative id=&amp;quot;1&amp;quot;&amp;gt; Bonjour&amp;lt;/alternative&amp;gt;&#xA;                &amp;lt;alternative id=&amp;quot;2&amp;quot;&amp;gt; BN jour&amp;lt;/alternative&amp;gt;&#xA;              &amp;lt;/alternatives&amp;gt;&#xA;            &amp;lt;/error&amp;gt;&#xA;          &amp;lt;/errors&amp;gt;&#xA;        &amp;lt;/sentence&amp;gt;&#xA;      &amp;lt;/sentences&amp;gt;&#xA;    &amp;lt;/document&amp;gt;&#xA;    &amp;lt;newPassPhrase&amp;gt; WQ+MApSbF9X29BEr7nyIBn6iQQa3MnBKS9KYc6QkhXU=&amp;lt;/newPassPhrase&amp;gt;&#xA;    &amp;lt;textreplaced&amp;gt; Bnjour tout le monde&amp;lt;/textreplaced&amp;gt;&#xA;    &amp;lt;noreplace&amp;gt; 0&amp;lt;/noreplace&amp;gt;&#xA;  &amp;lt;/CheckSpellingResult&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;From this result you can parse the XML string and get the informations you want, building it in the quick fix list or trying to inject it in a plugin (&lt;a href=&quot;https://github.com/scrooloose/syntastic&quot; rel=&quot;nofollow noreferrer&quot;&gt;syntastic&lt;/a&gt; for example).&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Side Note&lt;/em&gt; :&#xA;For this solution, you'll have to ask for the website 2 times : one for fetching the passphrase and the second for correcting your text. It's kind of hacky but it'll work.&lt;/p&gt;&#xA;&lt;h1&gt;The Conclusion&lt;/h1&gt;&#xA;&lt;p&gt;(spoiler alert : no script, just a general conclusion)&lt;/p&gt;&#xA;&lt;p&gt;I think most of the tool you can use to check you grammar/syntax will work the same as reverso. The only thing that change will be the output that you'll have to parse each time. And having to handle all the cases can be a really consuming task when some tools already exists that works out-of-the-box.&lt;/p&gt;&#xA;&lt;p&gt;I think you can write some script that will do one of the following :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Prepare the texte to be verified in an external tool (Microsoft Word, Google Doc, ... ) and re-inserted inside Vim afterward. &lt;strong&gt;Easy&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Try to use an external tool directly from Vim with the requests and the parsing, ... &lt;strong&gt;Hard&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;But eventually you'll learn a lot on choosing the hard solution.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; :&lt;/p&gt;&#xA;&lt;p&gt;While trying to verify this text from reverso, I saw that the text should have a size of 600 characters max ... And I think this can be found on other online-free-to-use tools like this one.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-08-23T09:11:30.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4474" PostTypeId="1" AcceptedAnswerId="4478" CreationDate="2015-08-23T09:22:00.910" Score="2" ViewCount="1031" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/altercation/vim-colors-solarized&quot; rel=&quot;nofollow&quot;&gt;altercation's vim-solarized plugin&lt;/a&gt; to set my default colorscheme and have set my xterm to use solarized colors as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to run &lt;code&gt;:TOhtml&lt;/code&gt; on a buffer, say on $MYVIMRC, the resulting html file has different colors than it is supposed to have. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get the &quot;right&quot; colors/colorscheme for the html file?&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2016-07-27T07:36:12.797" Title="Using :TOhtml with solarized colorscheme" Tags="|colorscheme|plugin-solarized|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4475" PostTypeId="1" AcceptedAnswerId="4479" CreationDate="2015-08-23T10:43:21.010" Score="0" ViewCount="1272" Body="&lt;p&gt;I'm running Windows 7 with gvim 7.4 installed in the default location. I have created a file &lt;code&gt;C:\Users\MyUserNameHere\_vimrc&lt;/code&gt; with just a few lines as simple as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nowrap&#xA;set tabstop=2&#xA;set shiftwidth=2&#xA;set expandtab&#xA;set foldmethod=indent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There seems to be nothing wrong with my _vimrc. However, when I open a PHP file, the syntax higlighting is gone after I create this file. Of course I could just add the line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;syntax on&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to the _vimrc file in the directory corresponding to my username. But the fact that syntax highlighting is gone makes me think that some other useful default settings may be gone as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what I would like to know is, by creating &lt;code&gt;C:\Users\MyUserNameHere\_vimrc&lt;/code&gt;, have I overridden another &lt;code&gt;_vimrc&lt;/code&gt; file somewhere on the filesystem? I have tried searching from the windows search box next to the start button but found nothing.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-08-23T11:16:30.947" Title="Creating C:\Users\MyUserNameHere\_vimrc on Windows seems to override some other vimrc file" Tags="|vimrc|microsoft-windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4476" PostTypeId="1" AcceptedAnswerId="4477" CreationDate="2015-08-23T10:50:27.333" Score="0" ViewCount="251" Body="&lt;p&gt;I sometimes have multiple xterm windows open and run vim in both of them. Is there any way to copy text from one window to the other using registers if I don't have '+clipboard' enabled?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Steps to reproduce:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open a new xterm, run &lt;code&gt;vim -u NONE -N&lt;/code&gt; (vim with unsourced .vimrc to make sure that no plugin interferes)&lt;/li&gt;&#xA;&lt;li&gt;Yank a word with &lt;code&gt;yiw&lt;/code&gt;, yank another word with &lt;code&gt;&quot;ayiw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Run &lt;code&gt;:reg&lt;/code&gt; to check how the registers &quot;0 and &quot;a look like.&lt;/li&gt;&#xA;&lt;li&gt;Open a new xterm and start vim again with &lt;code&gt;vim -u NONE -N&lt;/code&gt;. I am now unable to paste either of the two words yanked before. Running &lt;code&gt;:reg&lt;/code&gt; show that indeed the registers &quot;0 and &quot;a look different than the ones in my first xterm window.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I understand that would I have vim with '+clipboard' enabled, I could use the &quot;+ register. But what can I do if I don't want have this option and don't want to open my two buffers in the same vim instance, but instead in two different xterms?&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2015-08-23T11:05:59.230" Title="Using registers in different terminals" Tags="|register|window-management|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4477" PostTypeId="2" ParentId="4476" CreationDate="2015-08-23T11:05:59.230" Score="1" Body="&lt;p&gt;Registers are not shared between different Vim sessions. If you want that, then you have to store and load the data from a file. I think, the Yankring plugin does something like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also it should be possible to write your viminfo using &lt;code&gt;:wv&lt;/code&gt; file after you put something into your desired register and load it from the other vim session using &lt;code&gt;:rv&lt;/code&gt;. See also the &lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-17.3&quot; rel=&quot;nofollow&quot;&gt;faq&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-08-23T11:05:59.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4478" PostTypeId="2" ParentId="4474" CreationDate="2015-08-23T11:07:34.900" Score="2" Body="&lt;p&gt;You can't get the &quot;right&quot; colors in a terminal emulator because the colors used for highlighting are defined as &quot;red&quot; or &quot;bright cyan&quot; which are then user-defined at the terminal emulator level and could mean &lt;em&gt;anything&lt;/em&gt;, especially in the case of Solarized where &quot;bright cyan&quot; is actually a freaking grey.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get the &quot;right&quot; colors in GVim, though, because syntax highlighting is done with fixed values.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-08-23T11:07:34.900" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4479" PostTypeId="2" ParentId="4475" CreationDate="2015-08-23T11:16:30.947" Score="1" Body="&lt;p&gt;Hit &lt;code&gt;:version&lt;/code&gt; inside Vim, you'll see the paths where Vim will search for a vimrc file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you run &lt;code&gt;:echo $VIM&lt;/code&gt;, &lt;code&gt;:echo $VIMRUNTIME&lt;/code&gt; and perhaps &lt;code&gt;:echo $HOME&lt;/code&gt;, you'll see the actual path components.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-08-23T11:16:30.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4480" PostTypeId="1" CreationDate="2015-08-23T16:43:35.310" Score="0" ViewCount="423" Body="&lt;p&gt;I have this mapping in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;cr&amp;gt; neocomplete#mappings#close_popup() .&#xA;\ &quot;&amp;lt;Plug&amp;gt;(neosnippet_jump_or_expand)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it's working great. When I press enter in a neocomplete popup it expands neosnippet but the problem is that &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; will now work only for that and will not do a return line in insert mode.&lt;/p&gt;&#xA;" OwnerUserId="3285" LastEditorUserId="54" LastEditDate="2015-08-23T18:44:48.000" LastActivityDate="2015-08-23T20:12:04.410" Title="a problem with a mapping ( map enter and tab key)" Tags="|vimscript|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4481" PostTypeId="2" ParentId="4480" CreationDate="2015-08-23T17:03:59.283" Score="1" Body="&lt;p&gt;Your question &lt;em&gt;could&lt;/em&gt; be more elaborate. Perhaps you need something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;cr&amp;gt; neosnippet#expandable_or_jumpable() ?&#xA;            \ &quot;&amp;lt;Plug&amp;gt;(neosnippet_expand_or_jump)&quot; :&#xA;            \ neocomplete#mappings#close_popup().&quot;\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-08-23T17:03:59.283" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4482" PostTypeId="1" AcceptedAnswerId="4494" CreationDate="2015-08-23T18:16:57.540" Score="13" ViewCount="11320" Body="&lt;p&gt;I've got the following line in my &lt;code&gt;_vimrc&lt;/code&gt; file which enables folding for my PHP (and other) files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=indent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, whenever I open a file it starts with every fold closed, but I would like the file to start with its folds open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I execute the command &lt;code&gt;zi&lt;/code&gt; to open up folds when vim 7.4 is launched?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried putting this in the &lt;code&gt;_vimrc&lt;/code&gt; but I get a pop up window with the error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E492: The following is not an editor command: zi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I fix this?&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="51" LastEditDate="2015-08-24T09:06:45.317" LastActivityDate="2020-06-23T09:21:12.020" Title="How to open a file with all folds opened?" Tags="|folding|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4483" PostTypeId="2" ParentId="4482" CreationDate="2015-08-23T18:35:50.133" Score="7" Body="&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/All_folds_open_when_opening_a_file&quot; rel=&quot;noreferrer&quot;&gt;Add the &lt;code&gt;foldlevel&lt;/code&gt; option to your _vimrc:&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldlevel=20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This opens 20 levels of folds automatically when you open a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not familiar with the &lt;code&gt;zi&lt;/code&gt; command, I just know &lt;code&gt;zR&lt;/code&gt; to open all folds from normal mode. In your _vimrc, you generally cannot use normal mode commands to my knowledge.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2015-08-23T18:35:50.133" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4485" PostTypeId="2" ParentId="4480" CreationDate="2015-08-23T20:06:39.657" Score="0" Body="&lt;p&gt;This is the how complex insert mode mappings that involve the popup menu are usually written:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iemap &amp;lt;expr&amp;gt; &amp;lt;key&amp;gt; pumvisible() ? &quot;\&amp;lt;another-key&amp;gt;&quot; : &quot;\&amp;lt;key&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The ternary operator is used to &quot;press&quot; &lt;code&gt;&amp;lt;another-key&amp;gt;&lt;/code&gt; if we are in a popup menu or &lt;code&gt;&amp;lt;key&amp;gt;&lt;/code&gt; if we are not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming the snippet in your question works (I don't use those plugins), the following mapping should expand the selected snippet if you are in a popup menu or just &quot;press&quot; a regular &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; otherwise.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;cr&amp;gt; pumvisible() ?&#xA;    \ neocomplete#mappings#close_popup() . &quot;&amp;lt;Plug&amp;gt;(neosnippet_jump_or_expand)&quot; :&#xA;    \ &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that the code above doesn't check if it is in a &lt;em&gt;neobundle + neosnippet&lt;/em&gt; popup menu so I'd suggest putting all that in a function so that you have some elbow room for all your checks (and get a chance to use an actual &lt;code&gt;if-elseif-else-endif&lt;/code&gt; conditional instead of a deep ternary operator.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-08-23T20:12:04.410" LastActivityDate="2015-08-23T20:12:04.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4486" PostTypeId="1" AcceptedAnswerId="4525" CreationDate="2015-08-23T20:42:02.057" Score="20" ViewCount="3198" Body="&lt;p&gt;Is there a way that &lt;code&gt;t{char}&lt;/code&gt; and &lt;code&gt;f{char}&lt;/code&gt; will continue to work in the next lines if &lt;code&gt;{char}&lt;/code&gt; is not present in a given line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to avoid using &lt;code&gt;/{char}&amp;lt;CR&amp;gt;&lt;/code&gt; to save 1 keystroke and to not have search highlighting, especially when I need this in combination with verbs (e.g. &lt;code&gt;dfa&lt;/code&gt;, &lt;code&gt;ct.&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="3282" LastEditorUserId="205" LastEditDate="2015-08-24T01:37:55.627" LastActivityDate="2022-01-12T00:47:41.480" Title="Expand f and t motion to next lines" Tags="|cursor-motions|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4487" PostTypeId="2" ParentId="3382" CreationDate="2015-08-23T22:14:01.583" Score="9" Body="&lt;p&gt;Besides deleting text, you can use the black hole register to delete other registers. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=@_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is one way of clearing register &lt;code&gt;&quot;a&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2015-08-23T22:14:01.583" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4488" PostTypeId="1" CreationDate="2015-08-24T01:51:24.823" Score="12" ViewCount="3721" Body="&lt;p&gt;For example, I have the following &lt;code&gt;autocommand&lt;/code&gt; definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup cursorline&#xA;    autocmd!&#xA;    autocmd WinLeave,BufLeave * set nocursorline&#xA;    autocmd WinEnter,BufEnter * set cursorline&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to define something that excludes &lt;code&gt;*.tex&lt;/code&gt; files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd WinEnter,BufEnter * &quot;except *.tex&quot; set cursorline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the syntax for that? I'm not sure what keywords to search the help docs.&lt;/p&gt;&#xA;" OwnerUserId="1539" LastEditorUserId="1841" LastEditDate="2015-08-24T13:01:10.177" LastActivityDate="2020-03-07T12:27:43.160" Title="How do I define an autocommand to work on all files excepted a certain filetype?" Tags="|autocmd|filetype|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4489" PostTypeId="1" CreationDate="2015-08-24T03:21:20.220" Score="24" ViewCount="55294" Body="&lt;p&gt;I tried visual block, but visual block only allow to highlight or delete characters on multiple lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any function that allows to add space before the first character of multiple lines when I press spacebar?&lt;/p&gt;&#xA;" OwnerUserId="3292" LastEditorUserId="1821" LastEditDate="2015-08-24T05:09:49.960" LastActivityDate="2021-07-29T13:23:11.903" Title="How to add space on multiple lines when pressing spacebar (without extra configuration)?" Tags="|insert-mode|visual-mode|replace|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4490" PostTypeId="2" ParentId="4489" CreationDate="2015-08-24T04:28:41.990" Score="32" Body="&lt;p&gt;You were right about visual mode, but you should have tried &lt;em&gt;blockwise visual mode&lt;/em&gt; by pressing &lt;code&gt;&amp;lt;C-V&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In blockwise visual mode you can select the lines and columns of your selection. When you selected the desired lines of the block you want, you can press &lt;code&gt;I&lt;/code&gt; (that is &lt;code&gt;Shift + i&lt;/code&gt;), you are now on insert mode, where you can add space in front of your line.&lt;/p&gt;&#xA;&lt;p&gt;When you press &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; the new spaces will be added to all lines of your selection.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="37216" LastEditDate="2021-07-29T13:23:11.903" LastActivityDate="2021-07-29T13:23:11.903" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4491" PostTypeId="2" ParentId="4488" CreationDate="2015-08-24T05:05:28.340" Score="1" Body="&lt;p&gt;I didn't find anything that seems to support what you want, but you can do quite the same with a little bit of scripting : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:ToggleCursorLine(open) abort&#xA;  let l:extension = expand('%:e')&#xA;  if l:extension !=? 'tex'&#xA;    if a:open&#xA;      set cursorline&#xA;    else&#xA;      set nocursorline&#xA;    endif&#xA;  endif&#xA;endfunction&#xA;&#xA;augroup cursorline&#xA;  autocmd!&#xA;  autocmd WinLeave,BufLeave * call s:ToggleCursorLine(1)&#xA;  autocmd WinEnter,BufEnter * call s:ToggleCursorLine(0)&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reference : &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#expand()&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h expand()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-08-24T05:41:33.553" LastActivityDate="2015-08-24T05:41:33.553" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4492" PostTypeId="2" ParentId="4488" CreationDate="2015-08-24T08:48:32.423" Score="5" Body="&lt;p&gt;How about: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd WinEnter,BufEnter * if &amp;amp;filetype != &quot;latex&quot; &amp;amp;&amp;amp; &amp;amp;filetype != &quot;plaintex&quot; | set cursorline | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;better formatted as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd WinEnter,BufEnter * if &amp;amp;filetype != &quot;latex&quot; &amp;amp;&amp;amp; &amp;amp;filetype != &quot;plaintex&quot; &#xA;                            \ | set cursorline &#xA;                            \ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This depends upon the &lt;code&gt;filetype&lt;/code&gt; as detected or set by Vim, and so doesn't have any case-sensitivity issues. (You might want to check what your tex files are being detected as, by running &lt;code&gt;set filetype?&lt;/code&gt; in Vim's commandline). &lt;/p&gt;&#xA;" OwnerUserId="2374" LastActivityDate="2015-08-24T08:48:32.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4493" PostTypeId="1" AcceptedAnswerId="4495" CreationDate="2015-08-24T09:10:33.187" Score="30" ViewCount="10756" Body="&lt;p&gt;I've gone through the &lt;code&gt;autocmd.txt&lt;/code&gt; help, but the information about this is scattered and not always present (eg. with &lt;code&gt;BufRead&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone who understands this well list the order of these events - with perhaps the conditions marked in parantheses, like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WinEnter   &#xA;BufEnter (if this window is for a different buffer than the current)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on, for easy reference?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note &lt;sup&gt;(copied from my own comment below)&lt;/sup&gt;:  I'm not talking about individual explanations of them, which are OK, but about how they interact with one another and in what order they happen. For eg., &lt;code&gt;WinEnter&lt;/code&gt; says &quot;Vim executes the BufEnter autocommands after the WinEnter autocommands&quot;, &lt;code&gt;TabEnter&lt;/code&gt; says &quot;After triggering the WinEnter and before triggering the BufEnter event&quot;, it's all scattered like this into many places. And sometimes it's not mentioned at all (for eg. &lt;code&gt;BufRead&lt;/code&gt; doesn't mention whether it runs after BufEnter or before - maybe an expert can infer it from some other piece of info there, but I can't.&lt;br&gt;&#xA;So, my intent here is to create a single, simple reference for the order of these events that can be looked up quickly by non-experts, in order to be more precise in our &lt;code&gt;autocmd&lt;/code&gt; event specifications.&lt;/p&gt;&#xA;" OwnerUserId="2374" LastEditorUserId="2374" LastEditDate="2015-08-24T09:25:26.400" LastActivityDate="2023-05-21T03:56:37.553" Title="What is the order of WinEnter, BufEnter, BufRead, Syntax, FileType events?" Tags="|buffers|vim-windows|autocmd|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4494" PostTypeId="2" ParentId="4482" CreationDate="2015-08-24T09:23:47.327" Score="10" Body="&lt;p&gt;&lt;code&gt;zi&lt;/code&gt; inverts the option &lt;code&gt;foldenable&lt;/code&gt;. But you don't want to invert it, you want to disable it. So put the following in your .vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set nofoldenable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3205" LastEditorUserId="3205" LastEditDate="2020-06-23T09:21:12.020" LastActivityDate="2020-06-23T09:21:12.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4495" PostTypeId="2" ParentId="4493" CreationDate="2015-08-24T10:01:44.777" Score="20" Body="&lt;p&gt;I tried googling for this with different sets of keywords, and struck gold on one such attempt with this result:&#xA;&lt;a href=&quot;https://web.archive.org/web/20220121051339/https://developer.ibm.com/tutorials/l-vim-script-5/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://web.archive.org/web/20220121051339/https://developer.ibm.com/tutorials/l-vim-script-5/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Specifically, this part is relevant to the current question:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;For example, if you start Vim, edit a file named demo.txt, swap into Insert mode, type in some text, save the file, and then exit, your Vim session receives a series of events like what is shown in Listing 1.&lt;/p&gt;&#xA;&lt;p&gt;Listing 1. Event sequence in a simple Vim editing session&lt;/p&gt;&#xA;&lt;p&gt;&amp;gt; vim&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;BufWinEnter     (create a default window)&lt;/li&gt;&#xA;&lt;li&gt;BufEnter        (create a default buffer)&lt;/li&gt;&#xA;&lt;li&gt;VimEnter        (start the Vim session)&lt;strong&gt;:edit demo.txt&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;BufNew          (create a new buffer to contain demo.txt)&lt;/li&gt;&#xA;&lt;li&gt;BufAdd          (add that new buffer to the session’s buffer list)&lt;/li&gt;&#xA;&lt;li&gt;BufLeave        (exit the default buffer)&lt;/li&gt;&#xA;&lt;li&gt;BufWinLeave     (exit the default window)&lt;/li&gt;&#xA;&lt;li&gt;BufUnload       (remove the default buffer from the buffer list)&lt;/li&gt;&#xA;&lt;li&gt;BufDelete       (deallocate the default buffer)&lt;/li&gt;&#xA;&lt;li&gt;BufReadCmd      (read the contexts of demo.txt into the new buffer)&lt;/li&gt;&#xA;&lt;li&gt;BufEnter        (activate the new buffer)&lt;/li&gt;&#xA;&lt;li&gt;BufWinEnter     (activate the new buffer's window)i&lt;/li&gt;&#xA;&lt;li&gt;InsertEnter     (swap into Insert mode)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It's still not entirely comprehensive (eg. no mention of &lt;code&gt;BufRead&lt;/code&gt; aka &lt;code&gt;BufReadPost&lt;/code&gt;, but I'm assuming it would come after &lt;code&gt;BufReadCmd&lt;/code&gt;), but it's an excellent start.&lt;/p&gt;&#xA;&lt;p&gt;One crucial missing piece of information though is how the &lt;code&gt;FileType&lt;/code&gt; and &lt;code&gt;Syntax&lt;/code&gt; autocmd events interact with this (assuming &lt;code&gt;filetype&lt;/code&gt; and &lt;code&gt;syntax&lt;/code&gt; are already on, and a new file is opened whose filetype and syntax are known to Vim).&lt;/p&gt;&#xA;" OwnerUserId="2374" LastEditorUserId="5803" LastEditDate="2023-05-21T03:56:37.553" LastActivityDate="2023-05-21T03:56:37.553" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4496" PostTypeId="2" ParentId="4493" CreationDate="2015-08-24T10:09:51.237" Score="17" Body="&lt;p&gt;To complete the @sundar answer:&lt;/p&gt;&#xA;&lt;p&gt;You can log the order of the events simply with a logging function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup EventLoggin&#xA;  autocmd!&#xA;  autocmd BufNewFile * call s:Log('BufNewFile')&#xA;  autocmd BufReadPre * call s:Log('BufReadPre')&#xA;  ...&#xA;  autocmd User * call s:Log('User')&#xA;augroup END&#xA;&#xA;function! s:Log(eventName) abort&#xA;  silent execute '!echo '.a:eventName.' &amp;gt;&amp;gt; log'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See the full file here: &lt;a href=&quot;https://github.com/lervag/dotvim/blob/3aa56d621423540bfa26b330182b3e97ed4ee5e8/personal/plugin/log-autocmds.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/lervag/dotvim/blob/3aa56d621423540bfa26b330182b3e97ed4ee5e8/personal/plugin/log-autocmds.vim&lt;/a&gt; (NB: As the previous gist has disappeared, I've replaced the URL to Karl's plugin --Luc)&lt;/p&gt;&#xA;&lt;p&gt;You can then &lt;code&gt;tail -f log&lt;/code&gt; and you get a real-time autocommand events activity.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="17372" LastEditDate="2022-01-27T13:43:10.820" LastActivityDate="2022-01-27T13:43:10.820" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4497" PostTypeId="1" CreationDate="2015-08-24T10:11:53.973" Score="5" ViewCount="342" Body="&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In MacVim I type &lt;code&gt;:tabe jäderberg.txt&lt;/code&gt; to open a buffer for that file. The file does not yet exist. My status line displays the file name &lt;code&gt;jäderberg.txt&lt;/code&gt;. I do &lt;code&gt;i&amp;lt;C-r&amp;gt;%&lt;/code&gt; to put the file name into the buffer and it puts &lt;code&gt;jäderberg.txt&lt;/code&gt;. I write and quit the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I run MacVim from Terminal by typing &lt;code&gt;mvim j&amp;lt;Tab&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;. The file opens, but the statusline displays &lt;code&gt;ja¨derberg.txt&lt;/code&gt;. I type &lt;code&gt;i&amp;lt;C-r&amp;gt;%&lt;/code&gt; and i get &lt;code&gt;ja¨derberg.txt&lt;/code&gt;. If in Terminal I type out the whole file name, &lt;code&gt;mvim jäderberg.txt&lt;/code&gt;, everything is fine. If I type &lt;code&gt;mvim jä&amp;lt;Tab&amp;gt;&lt;/code&gt; Terminal refuses to complete the file name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is my status line not displaying the file name correctly when I open MacVim from Terminal and tab-complete the filename?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;As far as I've gotten&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Accented characters&quot; can be stored as a single code point or as a series of code points. I don't know much about this, but I can tell there is a difference between how Terminal treats the character &lt;code&gt;ä&lt;/code&gt; that I type and the character &lt;code&gt;ä&lt;/code&gt; that is stored in a file name and completed with &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;jä&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ printf jä | xxd&#xA;0000000: 6ac3 a4                                  j..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Completing &lt;code&gt;jä&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ touch jä&#xA;$ printf jä | xxd&#xA;0000000: 6a61 cc88                                ja..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to correspond to a difference between composed and decomposed characters. I don't understand why Vim should fail to correctly display the decomposed &lt;code&gt;ä&lt;/code&gt; that is actually stored in the file name, and &lt;em&gt;only when I give the file name with a decomposed &lt;code&gt;ä&lt;/code&gt;&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Observations&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some further observations. I'm not sure what other info is relevant, so ask and I'll add.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If I move the cursor over the characters &lt;code&gt;ja¨derberg.txt&lt;/code&gt; in the buffer, they change. With the cursor on &lt;code&gt;j&lt;/code&gt; and pressing &lt;code&gt;l&lt;/code&gt; until end of line, here is how the line changes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ja¨derberg.txt&#xA;ja¨derberg.txt&#xA;jadderberg.txt&#xA;jadeerberg.txt&#xA;jaderrberg.txt&#xA;...&#xA;jaderberg.txtt&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I wrote a function to loop through all characters on the line and convert each to a number and back to a char, then write the results to the buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! JJDebugEncoding(lineno)&#xA;    let line = getline(a:lineno)&#xA;    let newline = &quot;&quot;&#xA;    for char in split(line, '\zs')&#xA;        let nr = char2nr(char)&#xA;        let newline = newline . nr2char(nr)&#xA;    endfor&#xA;    call append(a:lineno, newline)&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run it for a line with &lt;code&gt;ja¨derberg.txt&lt;/code&gt; I get &lt;code&gt;jaderberg.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no byte value &lt;code&gt;228 (ä)&lt;/code&gt; or &lt;code&gt;168 (¨)&lt;/code&gt; anywhere in the buffer.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Terminal Vim does not seem to have this problem.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;encoding&lt;/code&gt; is set to &lt;code&gt;utf-8&lt;/code&gt;. I'm not sure where this option is set since &lt;code&gt;latin1&lt;/code&gt; is the default, I'm not setting it in my vimrc and &lt;code&gt;:verbose set encoding&lt;/code&gt; doesn't tell me anything. But I have tested that it is already set by the time my vimrc is sourced (that's why I don't set it myself) so I figure that should be ok. &lt;code&gt;fileencoding&lt;/code&gt; defaults to &lt;code&gt;encoding&lt;/code&gt; if it is not set, but I have also tried setting it explicitly before writing the buffer to file with no difference. &lt;code&gt;fileencodings&lt;/code&gt; is set to &lt;code&gt;ucs-bom,utf-8,default,latin1&lt;/code&gt; and &lt;code&gt;fileformats&lt;/code&gt; to &lt;code&gt;unix,dos,mac&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a.) &lt;code&gt;NFS+&lt;/code&gt; requires file names to only contain characters in Unicode Normal Form D, that is, accented accented characters are decomposed. Other filesystems seem to favor but not enforce UNF-C, composed. Therefore this is likely a MacVim-specific problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b.) I was wrong to say this does not affect terminal Vim. It does, and &lt;code&gt;ga&lt;/code&gt; with cursor on &lt;code&gt;ä&lt;/code&gt; gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; typed&#xA;&amp;lt;a&amp;gt;  97,  Hex 61,  Octal 141 &amp;lt; ̈&amp;gt; 776, Hex 0308, Octal 1410&#xA;&quot; from % register or tab-completed&#xA;&amp;lt;ä&amp;gt; 228, Hex 00e4, Octal 344&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason I didn't notice this difference is that terminal Vim renders the characters the same way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;c.) Some relevant and helpful reading&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://groups.google.com/forum/#!searchin/vim_mac/filename/vim_mac/VoqFOpI2Yk8/vJSTxcWBeloJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim_mac 2007 related discussion&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://code.google.com/p/macfuse/issues/detail?id=139&quot; rel=&quot;nofollow noreferrer&quot;&gt;Comment #2 contains a good explanation of part of the problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://apple.stackexchange.com/questions/10476/how-to-enter-special-characters-so-that-bash-terminal-understands-them&quot;&gt;tab completing precomposed/decomposed characters&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://groups.google.com/forum/#!searchin/vim_mac/filename/vim_mac/dRM0cubZb1M/B5N9vf1tOgQJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim_mac distinguish between the encoding and rendering parts of the problem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="-1" LastEditDate="2017-04-13T12:45:30.893" LastActivityDate="2016-04-22T09:28:25.107" Title="Encoding issue with filename in MacVim" Tags="|macvim|macos|encoding|xxd|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4499" PostTypeId="2" ParentId="4489" CreationDate="2015-08-24T12:45:02.600" Score="8" Body="&lt;p&gt;To add a space at the beginning of mutliple lines you also can use the &lt;code&gt;normal&lt;/code&gt; command. Let's say you have the following file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; foo&#xA;&quot; bar&#xA;buzz&#xA;fizz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can select the lines you want to add a space on and use the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt; norm I &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note the space character after the &lt;code&gt;I&lt;/code&gt;&lt;/em&gt;&lt;/strong&gt;. The command means:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;      For the line I selected&#xA;norm        Execute the following sequence of keystrokes as if I was in normal mode&#xA;I           Insert at the beginning of the line the following characters&#xA;[space]     A space&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I you select the 3 first lines you'll get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &quot; foo&#xA; &quot; bar&#xA; buzz&#xA;fizz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For even more power you can combine the &lt;code&gt;normal&lt;/code&gt; command with the &lt;code&gt;global&lt;/code&gt; command to apply the transformation only on lines matching a pattern. If you want to add a space in front of the commented lines in our previous example you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/&quot;/norm I &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to apply &lt;code&gt;norm I&lt;/code&gt; on lines containing &lt;code&gt;&quot;&lt;/code&gt;. &lt;strong&gt;&lt;em&gt;Note the space character after the &lt;code&gt;I&lt;/code&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which will give you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &quot; foo&#xA; &quot; bar&#xA;buzz&#xA;fizz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-08-24T12:45:02.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4500" PostTypeId="2" ParentId="4488" CreationDate="2015-08-24T12:58:37.703" Score="8" Body="&lt;p&gt;In the same spirit as @Sundar answer but with a little more flexible syntax you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let ftToIgnore = ['latex', 'plaintex']&#xA;autocmd BufWritePre * if index(ftToIgnore, &amp;amp;ft) &amp;lt; 0 | set your options&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tend to prefer this syntax because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can easily add new filtetypes if you want.&lt;/li&gt;&#xA;&lt;li&gt;The condition length stay the same no matter how many filetypes you're checking.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-08-24T12:58:37.703" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4501" PostTypeId="1" CreationDate="2015-08-24T14:13:21.443" Score="6" ViewCount="1096" Body="&lt;p&gt;Is there an up-to-date community-driven&lt;sup&gt;1&lt;/sup&gt; website which lists best practices regarding settings in &lt;code&gt;.vimrc&lt;/code&gt;, plugins and/or tips to use vim? What is the best way to get to know up-to-date community-driven best practice regarding vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find that I spend too much time customizing my &lt;code&gt;.vimrc&lt;/code&gt; after having read something about vim in the internet, only to later find out my customization was suboptimal. The same is sometimes true for learning habits how to use vim or for plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course different people will judge different on what is suboptimal, but often enough I find myself agreeing to things &lt;em&gt;a community of active vim users recommends the most&lt;/em&gt;. For example, posts/answers here or on &lt;a href=&quot;https://www.reddit.com/r/vim/&quot;&gt;reddit&lt;/a&gt; &#xA; with a lot of votes usually contain quality information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, StackExchange does not want open-ended question about best practices for vim. And on Reddit a post usually only discusses one or two topics. Just counting how often something appears in &lt;code&gt;.vimrc&lt;/code&gt;s or how often a plugin is starred on Github also is no option, it leads to &lt;a href=&quot;http://vimawesome.com/?q=plugin%20manager&quot;&gt;suboptimal conclusions&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to use vim in a well-proven way with the input of a lot of users, and a good portion of that should ideally be a best practice site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example what I look for&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A constantly available list like the following one, possibly sortable and with additional comments from other users:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;99 votes&lt;/kbd&gt;&lt;a href=&quot;/questions/tagged/plugins&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;plugins&amp;#39;&quot; rel=&quot;tag&quot;&gt;plugins&lt;/a&gt;  If you use plugins, use &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot;&gt;vim-plug&lt;/a&gt; as a plugin manager&lt;br /&gt;&#xA;&lt;kbd&gt;90 votes&lt;/kbd&gt;&lt;a href=&quot;/questions/tagged/.vimrc&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;.vimrc&amp;#39;&quot; rel=&quot;tag&quot;&gt;.vimrc&lt;/a&gt;&lt;a href=&quot;/questions/tagged/plugin&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;plugin&amp;#39;&quot; rel=&quot;tag&quot;&gt;plugin&lt;/a&gt;  When building your &lt;code&gt;.vimrc&lt;/code&gt;, start with an empty one. Only add what you&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;understand. A good place to start are the settings in &lt;a href=&quot;https://github.com/tpope/vim-sensible&quot;&gt;vim-sensible&lt;/a&gt;.&lt;br /&gt;&#xA;&lt;kbd&gt;80 votes&lt;/kbd&gt;&lt;a href=&quot;/questions/tagged/plugins&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;plugins&amp;#39;&quot; rel=&quot;tag&quot;&gt;plugins&lt;/a&gt;  &lt;a href=&quot;https://github.com/scrooloose/syntastic&quot;&gt;Syntastic&lt;/a&gt; is a great syntax checker&lt;br /&gt;&#xA;&lt;kbd&gt;55 votes&lt;/kbd&gt;&lt;a href=&quot;/questions/tagged/.vimrc&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;.vimrc&amp;#39;&quot; rel=&quot;tag&quot;&gt;.vimrc&lt;/a&gt;  Set your &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; to space with &lt;code&gt;let mapleader = &quot;\&amp;lt;space&amp;gt;&quot;&lt;/code&gt;&lt;br /&gt;&#xA;&lt;kbd&gt;40 votes&lt;/kbd&gt;&lt;a href=&quot;/questions/tagged/general&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;general&amp;#39;&quot; rel=&quot;tag&quot;&gt;general&lt;/a&gt;  Remap Capslock to Control - to press &lt;code&gt;Esc&lt;/code&gt; train yourself to use &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt;&lt;br /&gt;&#xA;&lt;kbd&gt;30 votes&lt;/kbd&gt;&lt;a href=&quot;/questions/tagged/plugins&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;plugins&amp;#39;&quot; rel=&quot;tag&quot;&gt;plugins&lt;/a&gt;  If you use plugins, use Vundle as a plugin manager&lt;br /&gt;&#xA;&lt;kbd&gt;14 votes&lt;/kbd&gt;&lt;a href=&quot;/questions/tagged/general&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;general&amp;#39;&quot; rel=&quot;tag&quot;&gt;general&lt;/a&gt;  Instead of &lt;code&gt;di(&lt;/code&gt; use &lt;code&gt;dib&lt;/code&gt;, also for other verbs. For curly braces use &lt;code&gt;diB&lt;/code&gt;&lt;br /&gt;&#xA;&lt;kbd&gt;12 votes&lt;/kbd&gt;&lt;a href=&quot;/questions/tagged/general&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;general&amp;#39;&quot; rel=&quot;tag&quot;&gt;general&lt;/a&gt;  Remap Capslock to Esc&lt;br /&gt;&#xA;&lt;kbd&gt;10 votes&lt;/kbd&gt;&lt;a href=&quot;/questions/tagged/.vimrc&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;.vimrc&amp;#39;&quot; rel=&quot;tag&quot;&gt;.vimrc&lt;/a&gt;  It is a great idea to use &lt;code&gt;Thisfunction()&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt; if you want... &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&lt;strong&gt;Footnotes&lt;/strong&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1. With community driven I do not mean sites like &lt;a href=&quot;http://vim.wikia.com/wiki/Vim_Tips_Wiki&quot;&gt;vim.wikia.com&lt;/a&gt; where users collaborate, but rather websites where people can cast up- and downvotes&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2015-08-24T14:13:21.443" Title="Constantly updated community best practice website?" Tags="|vimrc|" AnswerCount="0" CommentCount="6" ClosedDate="2016-11-13T16:10:05.767" ContentLicense="CC BY-SA 3.0" />
  <row Id="4502" PostTypeId="1" AcceptedAnswerId="4517" CreationDate="2015-08-24T15:26:50.070" Score="2" ViewCount="969" Body="&lt;p&gt;I develop django templates, and I need to indent them with &lt;code&gt;gg=G&lt;/code&gt;, but jinja2 tags seem to be immune to it. Here is an example of poorly indented, hard to read &lt;i&gt;if-else&lt;/i&gt; tags:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{% extends &quot;base.html&quot; %}&#xA;{% block content %}&#xA;{% load my_tags %}&#xA;&amp;lt;center&amp;gt;&#xA;    &amp;lt;form action=&quot;#&quot; method=&quot;get&quot;&amp;gt;{% csrf_token %}&#xA;        &amp;lt;input type=&quot;text&quot; value=&quot;{{ ids }}&quot; name=&quot;search_items&quot; size=&quot;40&quot;&amp;gt; &#xA;        &amp;lt;input type=&quot;submit&quot; value=&quot;Search Items&quot;&amp;gt;&#xA;    &amp;lt;/form&amp;gt;&#xA;    {% if searching == True %}&#xA;    {% if insert_quantity &amp;gt; 0 %}&#xA;    &amp;lt;br&amp;gt;&amp;lt;i&amp;gt;{{ insert_quantity }} from {{ match_quantity }} matches selected:&amp;lt;/i&amp;gt;&amp;lt;br&amp;gt;&#xA;    {% item_list items %}&#xA;    {% else %}&#xA;    No such items in database.&#xA;    {% endif %}&#xA;    {% else %}&#xA;    &amp;lt;h2&amp;gt;Item List (10 randomly selected)&amp;lt;/h2&amp;gt;&#xA;    {% item_list items %}&#xA;    {% endif %}&#xA;&amp;lt;/center&amp;gt;&#xA;{% endblock %}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have installed &lt;code&gt;Glench/Vim-Jinja2-Syntax&lt;/code&gt;, but it does nothing. I also use &lt;code&gt;YouCompleteMe&lt;/code&gt;, which detects and highlights jinja2 syntax (what makes previous plugin redundant?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question:&#xA;Is it possible to indent those &lt;i&gt;if-else&lt;/i&gt; (and &lt;i&gt;for&lt;/i&gt; loops) tags with &lt;code&gt;gg=G&lt;/code&gt; with some plugin?&lt;/p&gt;&#xA;" OwnerUserId="2562" LastEditorUserId="51" LastEditDate="2015-08-25T15:52:18.970" LastActivityDate="2015-08-25T23:10:55.600" Title="jinja2 indentation with gg=G" Tags="|indentation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4503" PostTypeId="1" CreationDate="2015-08-24T15:33:04.667" Score="3" ViewCount="472" Body="&lt;p&gt;For current source file with the following name pattern: &lt;code&gt;xxx_test.cpp&lt;/code&gt; how do you execute make file with the following patter &lt;code&gt;xxx.makefile&lt;/code&gt;.  I tried using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set makeprg=make\ -f\ fnameescape(substitute(expand(&quot;%&quot;),&quot;_test.cpp$&quot;,&quot;.makefile&quot;,&quot;&quot;)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it gives me the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/bin/bash: -c: line 0: syntax error near unexpected token `('&#xA;/bin/bash: -c: line 0: `make -f fnameescape(substitute(expand(  2&amp;gt;&amp;amp;1| tee /tmp/user/1000/v98gzpR/261'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am new to VIM, I tried to parse the vim help files, but cannot find an answer on how to have VIM execute the substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:  The right answer is presented by Sato Katsura here:  &lt;a href=&quot;https://vi.stackexchange.com/questions/4841/why-is-make-running-against-a-wrong-file/4842#4842&quot;&gt;Why is make running against a wrong file?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks...&lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-09-24T17:18:17.283" Title="Determining makefile based on source file name" Tags="|makeprg|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4504" PostTypeId="2" ParentId="4503" CreationDate="2015-08-24T16:34:37.187" Score="4" Body="&lt;p&gt;The trick is to forget about wrapping your mind around &lt;code&gt;set&lt;/code&gt; syntax, and use &lt;code&gt;let&lt;/code&gt; instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;makeprg = 'make -f ' . fnameescape(substitute(expand('%'), '\m_test\.cpp$', '.makefile', ''))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :let-&amp;amp;&lt;/code&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-08-24T16:34:37.187" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4505" PostTypeId="2" ParentId="4116" CreationDate="2015-08-24T17:15:38.767" Score="15" Body="&lt;p&gt;Unlike some implementations of regular expression engines, Vim's doesn't seem to support that notation (&lt;code&gt;[\s\w]&lt;/code&gt;) in collections. One can use &lt;a href=&quot;https://en.wikipedia.org/wiki/Regular_expression#Character_classes&quot; rel=&quot;noreferrer&quot;&gt;POSIX character class expressions&lt;/a&gt;, though. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[:blank:]&lt;/code&gt; is the same as &lt;code&gt;\s&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[:space:]&lt;/code&gt; matches a greater number of whitespace characters than &lt;code&gt;\s&lt;/code&gt; does, and seems to be equivalent to &lt;code&gt;\_s&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[:alnum:]&lt;/code&gt; approximates  &lt;code&gt;\w&lt;/code&gt;, but does not match the underscore (&lt;code&gt;_&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So the collection you wanted could be written as &lt;code&gt;[[:blank:][:alnum:]_]&lt;/code&gt; or &lt;code&gt;[[:space:][:alnum:]_]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't verified this by testing, but it is documented in &lt;code&gt;:h regexp&lt;/code&gt;, &lt;code&gt;:h /character-classes&lt;/code&gt;, and &lt;code&gt;:h /collection&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Portability note: In other regex engines, &lt;code&gt;\s&lt;/code&gt; is typically the same as &lt;code&gt;[:space:]&lt;/code&gt; (or &lt;code&gt;\_s&lt;/code&gt;) is in Vim.&lt;/p&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="2942" LastEditDate="2015-08-24T19:41:38.030" LastActivityDate="2015-08-24T19:41:38.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4506" PostTypeId="1" AcceptedAnswerId="4509" CreationDate="2015-08-24T18:43:02.977" Score="6" ViewCount="1507" Body="&lt;p&gt;I program with Python and I installed &lt;a href=&quot;https://github.com/klen/python-mode#using-pathogen-recommended&quot; rel=&quot;noreferrer&quot;&gt;python-mode&lt;/a&gt; with pathogen. Everything was fine but then suddenly Vim started highlighting all the dots in the files. And it's kind of frustrating.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it was the plug-in so I deleted everything in my &lt;code&gt;~/.vimrc&lt;/code&gt;. The content on my &lt;code&gt;~/.vimrc&lt;/code&gt; was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Pathogen load&#xA;filetype off&#xA;&#xA;call pathogen#infect()&#xA;call pathogen#helptags()&#xA;&#xA;filetype plugin indent on&#xA;syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But nope, it wasn't the plugin: Vim still highlights all the dots. I'll attach an image. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you give me a hand with this? I'll appreciate it big time, promise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WO7ey.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WO7ey.png&quot; alt=&quot;vim highlights dots&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3181" LastEditorUserId="205" LastEditDate="2015-08-24T21:58:55.047" LastActivityDate="2015-08-24T21:58:55.047" Title="Why does Vim highlight every dot in my code?" Tags="|vimrc|highlight|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4507" PostTypeId="1" CreationDate="2015-08-24T18:57:54.140" Score="13" ViewCount="1280" Body="&lt;p&gt;I find myself dealing with this issue every time the &lt;code&gt;wrap&lt;/code&gt; option is active (in my particular case whenever I'm working with markdown files).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens is that, while scrolling up and down the buffer with &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt;, the wrapped lines of text (visually forming a paragraph) at the far top and far bottom don't scroll smoothly (i.e. one by one) out of screen. Instead, whole paragraphs disappear and reappear abruptly from and into view, making for a disorienting and annoying effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think a GIF will explain better what happens. Here, I'm just pressing &lt;code&gt;k&lt;/code&gt; repeatedly to scroll upwards. Keep an eye on the paragraph near the bottom!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/686Mn.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/686Mn.gif&quot; alt=&quot;ugh&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got used to this behaviour because I didn't think it was fixable, but then I realized that doesn't happen with physical lines and &lt;code&gt;wrap&lt;/code&gt; unset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to tell Vim to scroll out of screen by visual lines instead of physical ones?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ps: Yes, I've mapped my &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; to &lt;code&gt;gj&lt;/code&gt; and &lt;code&gt;gk&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3079" LastEditorUserId="3079" LastEditDate="2015-08-25T20:02:01.357" LastActivityDate="2023-05-10T13:56:20.650" Title="Scrolling issues when the `wrap` option is set" Tags="|cursor-movement|terminal|normal-mode|scrolling|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4508" PostTypeId="2" ParentId="4507" CreationDate="2015-08-24T19:15:20.187" Score="4" Body="&lt;p&gt;I think you are looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set display=lastline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'display'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-08-24T19:15:20.187" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4509" PostTypeId="2" ParentId="4506" CreationDate="2015-08-24T20:43:59.480" Score="7" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/users/1306/jjaderberg&quot;&gt;jjaderberg&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/users/1841/statox&quot;&gt;statox&lt;/a&gt; have mentioned it seems like you have set &lt;code&gt;hlsearch&lt;/code&gt;. All &lt;code&gt;.&lt;/code&gt; in your file will be highlighted when you search for them directly (&lt;code&gt;/.&lt;/code&gt;) or if your cursor is placed on a dot and you press &lt;code&gt;*&lt;/code&gt;. The highlighting stays enabled till you either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Perform a new search with &lt;code&gt;/{something}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Perform a new search for the word under your cursor with &lt;code&gt;*&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Disable the current highlighting with &lt;code&gt;:nohlsearch&lt;/code&gt;, or short &lt;code&gt;:noh&lt;/code&gt;. This leaves search highlighting on in general for your next search.&lt;/li&gt;&#xA;&lt;li&gt;Disable search highlighting completely with &lt;code&gt;:set nohlsearch&lt;/code&gt;, or short &lt;code&gt;:set nohl&lt;/code&gt;. This disables search highlighting for your next searches. If you want this to be a permanent state, add it to your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2015-08-24T20:43:59.480" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4510" PostTypeId="2" ParentId="4346" CreationDate="2015-08-24T22:52:26.150" Score="2" Body="&lt;p&gt;I managed to improve my original function to fulfil two of my objectives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Help2UrlPy (word)&#xA;    setlocal tags=$VIMRUNTIME/doc/tags&#xA;    python &amp;lt;&amp;lt;EOF&#xA;import vim&#xA;from urllib import quote_plus&#xA;topmatch = vim.eval ('taglist(a:word)[0]')&#xA;filename = topmatch['filename'].split ('/')[-1]&#xA;tag = quote_plus (topmatch['name'])&#xA;url = 'http://vimhelp.appspot.com/{:s}.html#{:s}'.format (filename, tag)&#xA;vim.command ('let @* = &quot;{:s}&quot;'.format (url))&#xA;print url&#xA;EOF&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;setlocal tags=$VIMRUNTIME/doc/tags&lt;/code&gt; lets me point to the &lt;code&gt;tags&lt;/code&gt; file for the Vim documentation, thus excluding any plugin-generated help and sticking to the official docs.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vim.command ('let @* = &quot;{:s}&quot;'.format (url))&lt;/code&gt; copies to the clipboard by assigning to the &lt;code&gt;*&lt;/code&gt; register.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, to get the correct tag I was forced to use another way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Help2Url (...)&#xA;    exec 'silent! help ' . ( a:0 ? a:1 : '' )&#xA;    if ! a:0&#xA;        exec &quot;normal \&amp;lt;c-T&amp;gt;&quot;&#xA;    endif&#xA;    let l:tagfile = expand ('%:t')&#xA;    let @* = expand ('&amp;lt;cword&amp;gt;')&#xA;    python import urllib&#xA;    let @* = pyeval ('urllib.quote_plus (&quot;' . @* . '&quot;)')&#xA;    let @* = printf ('http://vimhelp.appspot.com/%s.html#%s', l:tagfile, @*)&#xA;endfunction&#xA;&#xA;command! -nargs=? -complete=help H call Help2Url(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I just let Vim do the heavy lifting for me. When we open help using &lt;code&gt;:h foo&lt;/code&gt;, the cursor is placed at the tag that Vim picked, and I get the word using &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3A%3Ccword%3E&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;&lt;/a&gt;. And if I run it without any arguments, &lt;code&gt;:h&lt;/code&gt; opens the main help page, with the last search result in the tag stack. So, I jump back with &lt;code&gt;&amp;lt;c-t&amp;gt;&lt;/code&gt;, and again, get the &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;. All requirements fulfilled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An older version of this used the tag stack, but the tag is not actually loaded to the tag stack when you do &lt;code&gt;:he foo&lt;/code&gt;. And if I do search for the tag using &lt;code&gt;&amp;lt;c-]&amp;gt;&lt;/code&gt;, my position will remain unchanged, but the tag stack will now have the tag I wanted as the last entry. So, I run &lt;code&gt;help&lt;/code&gt; on the argument, search for the tag, and the manipulate the output of &lt;a href=&quot;http://vimhelp.appspot.com/tagsrch.txt.html#%3Atags&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;tags&lt;/code&gt;&lt;/a&gt; to get the last entry. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec &quot;normal \&amp;lt;c-]&amp;gt;&quot;&#xA;let l:tagfile = expand ('%:t')&#xA;redir @*&#xA;silent! tags&#xA;redir END&#xA;let @* = split (split (@*, '\n\+')[-2], '\v(\s|\@)+')[2] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-08-26T10:39:13.957" LastActivityDate="2015-08-26T10:39:13.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4511" PostTypeId="2" ParentId="4346" CreationDate="2015-08-25T08:12:05.353" Score="3" Body="&lt;p&gt;This is a copy of my post at the meta question &lt;a href=&quot;https://vi.meta.stackexchange.com/a/1250/51&quot;&gt;Is there a simpler way to link to the help?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 20150825&lt;/strong&gt;: an improved  of this now lives at &lt;a href=&quot;http://code.arp242.net/helplink.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://code.arp242.net/helplink.vim&lt;/a&gt;. It has a number of improvements, and you can install it as a plugin :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will leave the original since it's a lot simpler and might be more helpful to show how this can be done.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've been using this function; it will (backwards) look for the first tag, and return that in Markdown link. It also puts in the clipboard...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can just use &lt;code&gt;:help&lt;/code&gt; from Vim, and when you want to link something use &lt;code&gt;:echo Helplink()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Make help link (markdown format)&#xA;&quot; TODO: Find all tags, and let the user choose which one to use&#xA;fun! Helplink()&#xA;    &quot; Get the name of the tag, With help from:&#xA;    &quot; https://vi.stackexchange.com/questions/434/get-name-of-nearest-tag-to-the-cursor&#xA;    if !search('\*\zs[^*]\+\*$', 'bW')&#xA;        echoerr &quot;No tag found&quot;&#xA;    endif&#xA;    let l:line = getline('.')&#xA;    let l:start = col('.') - 1&#xA;    call search('\*', '', line('.'))&#xA;    let l:len =  col('.') - l:start - 1&#xA;    let l:tagname = strpart(l:line, l:start, l:len)&#xA;&#xA;    &quot; TODO: Also support Python 2 and maybe Ruby...&#xA;    let l:tagname_esc = system('python3 -c &quot;import sys, urllib.parse as p;  empty=' . &quot;''&quot; . '; print(p.quote(sys.argv[1], safe=empty), end=empty)&quot; ' . shellescape(b:tagname))&#xA;    let l:file = split(expand('%'), '/')[-1]&#xA;    let l:url = &quot;http://vimhelp.appspot.com/&quot; . l:file . &quot;.html#&quot; . l:tagname_esc&#xA;    let l:md = '[`:help ' . l:tagname . '`](' . l:url . ')'&#xA;&#xA;    &quot; Copy it to the clipboard&#xA;    let @+ = l:md&#xA;&#xA;    return l:md&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-03-16T16:43:02.423" LastActivityDate="2015-08-25T08:17:22.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4512" PostTypeId="2" ParentId="4172" CreationDate="2015-08-25T10:40:46.947" Score="1" Body="&lt;p&gt;I don't know much about C++ development, but in regard to your questions about good workflows and granular control with makefiles I'd tell you to look no further than tpope's &lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow&quot;&gt;vim-dispatch&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this plugin you can use &lt;code&gt;:Make&lt;/code&gt; to start an asynchronous build in the foreground (for longer build tasks you can append a &lt;code&gt;!&lt;/code&gt; to start it in the background instead). Just this command makes this plugin a must-have if you work with makefiles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there is more. Another cool command provided is &lt;code&gt;:Dispatch&lt;/code&gt;, which might address a couple of your requests. It's basically like &lt;code&gt;:Make&lt;/code&gt; but provides a bit more control:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Dispatch picks a compiler by looking for either&#xA;CompilerSet makeprg={program}\ [arguments] or&#xA;CompilerSet makeprg={program} in compiler plugins.&#xA;To force a given {program} to use a given {compiler},&#xA;create ~/.vim/after/compiler/{compiler}.vim and add to&#xA;it a line like the following:&#xA;&#xA;&quot; CompilerSet makeprg={program}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can have even more control by setting &lt;code&gt;g:dispatch_compilers&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt;. This option takes a dictionary where the keys are commands you can call after &lt;code&gt;:Dispatch&lt;/code&gt; and compiler plugins are the values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:dispatch_compilers = {&#xA;    \ 'latex': 'tex',&#xA;    \ 'bundle exec': ''}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure to read through the docs, there's definitely more to it.&lt;/p&gt;&#xA;" OwnerUserId="3079" LastActivityDate="2015-08-25T10:40:46.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4513" PostTypeId="2" ParentId="4507" CreationDate="2015-08-25T15:49:49.637" Score="8" Body="&lt;p&gt;That is an issue, that has been often requested but never been implemented. So no, there is no possibility for a better and smoother scrolling, once the lines wrap.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: This is no longer entirely true. See &lt;a href=&quot;https://vi.stackexchange.com/users/343/rich&quot;&gt;@Rich&lt;/a&gt;s &lt;a href=&quot;https://vi.stackexchange.com/a/42151/71&quot;&gt;answer&lt;/a&gt; for the status as of 2023&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2023-05-10T13:56:20.650" LastActivityDate="2023-05-10T13:56:20.650" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4514" PostTypeId="1" CreationDate="2015-08-25T16:48:28.247" Score="0" ViewCount="859" Body="&lt;p&gt;I want to to run run an autocmd for all but tex files, i figured out this solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre *.[^t][^e][^x] :Autoformat &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but is kind of ugly, because of this repeated [^..] pattern. Is there a nicer wy?&lt;/p&gt;&#xA;" OwnerUserId="3003" LastActivityDate="2015-08-25T17:11:18.143" Title="Nicer way to not mach a pattern in autocmd" Tags="|vimscript|autocmd|" AnswerCount="1" CommentCount="1" ClosedDate="2015-08-25T22:45:50.237" ContentLicense="CC BY-SA 3.0" />
  <row Id="4515" PostTypeId="2" ParentId="4486" CreationDate="2015-08-25T16:51:30.830" Score="2" Body="&lt;p&gt;there is a plugin that does what you seem to be wanting, as stated by VanLaser.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/dahu/vim-fanfingtastic&quot; rel=&quot;nofollow&quot;&gt;https://github.com/dahu/vim-fanfingtastic&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It now requires the repeat plugin to work properly, so you will need that too:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow&quot;&gt;https://github.com/tpope/vim-repeat&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3217" LastActivityDate="2015-08-25T16:51:30.830" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4516" PostTypeId="2" ParentId="4514" CreationDate="2015-08-25T17:11:18.143" Score="4" Body="&lt;p&gt;The usual way to do this is to call a function for each file and in the function check, return if the file extension is of a certain type. &#xA;I have explained similar alternatives&lt;a href=&quot;https://stackoverflow.com/a/28838030/789222&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The disadvantage of your example is, your pattern won't trigger for files like foobar.txt (first t will be excluded), files without extensions, foobar.diff (extension too long).&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-25T17:11:18.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4517" PostTypeId="2" ParentId="4502" CreationDate="2015-08-25T23:10:55.600" Score="3" Body="&lt;p&gt;The best thing is to indent them yourself with &lt;em&gt;tabs&lt;/em&gt; and &lt;em&gt;spaces&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is one project that is almost what you want, &lt;a href=&quot;https://github.com/Glench/Vim-Jinja2-Syntax/pull/10&quot; rel=&quot;nofollow&quot;&gt;here is a pull request&lt;/a&gt; that someone made with auto-indentation for jinja2 templates (I haven't tested, it can be buggy).&lt;/p&gt;&#xA;" OwnerUserId="3312" LastActivityDate="2015-08-25T23:10:55.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4518" PostTypeId="1" CreationDate="2015-08-26T02:20:47.483" Score="3" ViewCount="801" Body="&lt;p&gt;Following &lt;a href=&quot;https://vi.stackexchange.com/a/3633/1841&quot;&gt;this answer&lt;/a&gt; I've been using &lt;a href=&quot;https://github.com/kana/vim-submode&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-submode&lt;/a&gt; for some months on a windows gVim. Now that I'm trying to apply the same configuration on a terminal vim on linux I have some problems:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the folowing lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call submode#enter_with('test', 'n', '', '&amp;lt;leader&amp;gt;&amp;lt;UP&amp;gt;', '&amp;lt;C-w&amp;gt;-')&#xA;call submode#map('test', 'n', '', '&amp;lt;UP&amp;gt;', '&amp;lt;C-w&amp;gt;-')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Leader&lt;/kbd&gt;&lt;kbd&gt;Up&lt;/kbd&gt; let me enter in the submode &lt;code&gt;test&lt;/code&gt; without any issue but in this submode when I hit &lt;kbd&gt;Up&lt;/kbd&gt; I leave the submode and insert a &lt;code&gt;A&lt;/code&gt; character in my buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I replace the second line with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call submode#map('test', 'n', '', 'a', '&amp;lt;C-w&amp;gt;-')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything works properly i.e. hitting &lt;kbd&gt;a&lt;/kbd&gt; execute the submode command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue comes from the terminal which doesn't interpret correctly the arrow key because the commands works perfectly fine on a gVim on the same system. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that I don't understand why this happens because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The arrow key is correctly interpreted in the &lt;code&gt;enter_with&lt;/code&gt; mapping. Even if I replace the first line with &lt;code&gt;call submode#enter_with('test', 'n', '', '&amp;lt;UP&amp;gt;', '&amp;lt;C-w&amp;gt;-')&lt;/code&gt; hitting &lt;kbd&gt;Up&lt;/kbd&gt; will trigger the submode&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I can create a mapping like &lt;code&gt;nnoremap &amp;lt;Up&amp;gt; :echo &quot;FOO&quot;&amp;lt;CR&amp;gt;&lt;/code&gt; which will work properly.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've tried to replace &lt;code&gt;'&amp;lt;UP&amp;gt;'&lt;/code&gt; with the code of the arrow using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt; &lt;kbd&gt;Up&lt;/kbd&gt; to insert it which gave me &lt;code&gt;OA&lt;/code&gt; but that still doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My setup is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Debian Wheezy&lt;/li&gt;&#xA;  &lt;li&gt;rxvt Unicode&lt;/li&gt;&#xA;  &lt;li&gt;vim 7.4&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What can I do to solve my problem?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="343" LastEditDate="2018-03-06T17:29:07.407" LastActivityDate="2020-04-01T00:27:09.410" Title="How to use arrow keys mappings in vim-submode plugin on linux terminal?" Tags="|key-bindings|terminal|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4521" PostTypeId="1" AcceptedAnswerId="4526" CreationDate="2015-08-26T06:33:44.820" Score="7" ViewCount="1687" Body="&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3A%3Camatch%3E&quot; rel=&quot;noreferrer&quot;&gt;documentation&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;afile&amp;gt;    When executing autocommands, is replaced with the file name&#xA;           for a file read or write.&#xA;&amp;lt;abuf&amp;gt;     When executing autocommands, is replaced with the currently&#xA;           effective buffer number (for &quot;:r file&quot; and &quot;:so file&quot; it is&#xA;           the current buffer, the file being read/sourced is not in a&#xA;           buffer).&#xA;&amp;lt;amatch&amp;gt;   When executing autocommands, is replaced with the match for&#xA;           which this autocommand was executed.  It differs from&#xA;           &amp;lt;afile&amp;gt; only when the file name isn't used to match with&#xA;           (for FileType, Syntax and SpellFileMissing events).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet, if I had this &lt;code&gt;autocmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile * echo expand('&amp;lt;amatch&amp;gt;') expand('&amp;lt;afile&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And opened, say &lt;code&gt;.zshrc&lt;/code&gt; in &lt;code&gt;/tmp&lt;/code&gt; (&lt;code&gt;cd /tmp; vim .zshrc&lt;/code&gt;), I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/tmp/.zshrc .zshrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They are not the same. What's going on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%&lt;/code&gt; is faithful to what I actually typed. &lt;code&gt;vim ./.zshrc&lt;/code&gt; with &lt;code&gt;expand('%')&lt;/code&gt; added to the above &lt;code&gt;autocmd&lt;/code&gt; gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/tmp/.zshrc .zshrc ./.zshrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-08-26T06:42:18.697" LastActivityDate="2019-12-05T08:21:03.580" Title="When exactly does &lt;afile&gt; differ from &lt;amatch&gt;?" Tags="|autocmd|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4523" PostTypeId="1" CreationDate="2015-08-26T09:08:54.090" Score="12" ViewCount="1694" Body="&lt;p&gt;Is there a way to tell vim not to spell-check part of a latex document?&#xA;For instance, code block using the &lt;code&gt;minted&lt;/code&gt; environment or URLs in &lt;code&gt;\url{}&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I'm not sure it's relevant for spell checking but I'm using the &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;noreferrer&quot;&gt;vimtex&lt;/a&gt; plugin to edit latex files.)&lt;/p&gt;&#xA;" OwnerUserId="3320" LastEditorUserId="343" LastEditDate="2015-08-27T14:49:53.223" LastActivityDate="2021-07-20T12:26:00.233" Title="How to configure spell to ignore some environments in LaTeX" Tags="|spell-checking|plugin-vimtex|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4524" PostTypeId="2" ParentId="4523" CreationDate="2015-08-26T10:08:28.633" Score="11" Body="&lt;p&gt;You can disable spell checking for syntax items by adding them to a cluster together with &lt;code&gt;@NoSpell&lt;/code&gt;. You can read &lt;code&gt;:help spell-syntax&lt;/code&gt; for some information and look at your tex syntax file which most likely contains several examples already. If you type &lt;code&gt;:tabe $VIMRUNTIME/syntax/tex.vim&lt;/code&gt; you should get the tex syntax file in a new tab. If you then search &lt;code&gt;/\c@NoSpell&lt;/code&gt; you may see a line like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; syn cluster texMathZoneGroup add=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;texMathZoneGroup&lt;/code&gt; cluster has been defined earlier in the script to contain a number of syntax items and here &lt;code&gt;@NoSpell&lt;/code&gt; is added to the cluster to disable spell checking for these items. I'm afraid I can't say exactly where to best make the change for your particular syntax items as I don't know that syntax file very well. There may be an obvious cluster already where you can simply add &lt;code&gt;@NoSpell&lt;/code&gt;, or you may have to create a cluster that &lt;code&gt;contains=&lt;/code&gt; the items in question. It is also a good idea to make a copy of the syntax file in your user runtime directory and apply your changes there rather than change the distributed syntax file, or to apply your changes in a &lt;code&gt;after/syntax/tex.vim&lt;/code&gt; or other script that runs after the syntax file is loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you use a plugin, it may have options related to which items are spell checked. I don't use &lt;code&gt;vimtex&lt;/code&gt; but Karl Lervåg is pretty active here and if you get his attention could answer that for you.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-08-26T10:08:28.633" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4525" PostTypeId="2" ParentId="4486" CreationDate="2015-08-26T12:19:12.770" Score="9" Body="&lt;p&gt;I was also using &lt;a href=&quot;https://github.com/dahu/vim-fanfingtastic&quot; rel=&quot;noreferrer&quot;&gt;dahu/vim-fanfingtastic&lt;/a&gt; for some time and found it very helpful.  It supports semantic repeats with &lt;code&gt;.&lt;/code&gt; thanks to the library &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;noreferrer&quot;&gt;tpope/repeat.vim&lt;/a&gt; which you must also install.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative is &lt;a href=&quot;https://github.com/chrisbra/improvedft&quot; rel=&quot;noreferrer&quot;&gt;chrisbra/improvedft&lt;/a&gt; which does more or less the same thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/rhysd/clever-f.vim&quot; rel=&quot;noreferrer&quot;&gt;rhysd/clever-f.vim&lt;/a&gt; has an option to enable multi-line seeking, although its primary feature is to allow &lt;strong&gt;&lt;code&gt;f&lt;/code&gt; to repeat&lt;/strong&gt; the current seek, like &lt;code&gt;;&lt;/code&gt; does already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those all handle &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt; keys as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;disadvantage&lt;/strong&gt; with multi-line &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt; is that if you hit the wrong key, you will be taken off the current line to &lt;strong&gt;somewhere unexpected&lt;/strong&gt; in the file.  &lt;kbd&gt;Ctrl-O&lt;/kbd&gt; can help in those moments.  (This can be dangerous with a &lt;code&gt;c&lt;/code&gt; change if you don't realise that you just swallowed a few lines, but those were only teething troubles for me.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other related plugins, with slightly different approaches, such as &lt;a href=&quot;https://github.com/justinmk/vim-sneak&quot; rel=&quot;noreferrer&quot;&gt;justinmk/vim-sneak&lt;/a&gt; and &lt;a href=&quot;https://github.com/goldfeld/vim-seek&quot; rel=&quot;noreferrer&quot;&gt;goldfeld/vim-seek&lt;/a&gt; which prompt for &lt;strong&gt;two characters&lt;/strong&gt;, making it easier (but still not guaranteed) to hit your target location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then there is &lt;a href=&quot;https://github.com/easymotion/vim-easymotion&quot; rel=&quot;noreferrer&quot;&gt;easymotion/vim-easymotion&lt;/a&gt;.  This offers a lot of &lt;strong&gt;powerful motion keys&lt;/strong&gt;, some of which require an extra keypress or two to confirm the target character when there are many candidates.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But currently I'm using a home grown solution.  I &lt;a href=&quot;https://github.com/easymotion/vim-easymotion/issues/160&quot; rel=&quot;noreferrer&quot;&gt;worked with&lt;/a&gt; the author of EasyMotion to make &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt; &lt;strong&gt;flash count markers&lt;/strong&gt; over all the matching characters ahead of you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FzHba.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FzHba.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This acts as a natural &lt;strong&gt;count assistant&lt;/strong&gt; for vanilla vim motions.  When you try to move somewhere with &lt;code&gt;fx&lt;/code&gt; but then discover there are more &lt;code&gt;x&lt;/code&gt;s in the way than you thought, you can read the number that flashed over the character you were aiming for, and then do &lt;code&gt;[count];&lt;/code&gt; to jump there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find the &lt;a href=&quot;https://github.com/easymotion/vim-easymotion/tree/feature-flash-motions&quot; rel=&quot;noreferrer&quot;&gt;branch here&lt;/a&gt;.  Be sure to read the section &lt;em&gt;Add helpful hinting&lt;/em&gt; to set up the key mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However for &lt;code&gt;c&lt;/code&gt; change operations, it is still preferable to &lt;strong&gt;get it right the first time&lt;/strong&gt;.  In those cases I recommend spending an extra keystroke in &lt;code&gt;v&lt;/code&gt; Visual mode, or using one of EasyMotion's guaranteed jumps.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2016-03-10T10:00:29.160" LastActivityDate="2016-03-10T10:00:29.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4526" PostTypeId="2" ParentId="4521" CreationDate="2015-08-26T13:03:54.070" Score="8" Body="&lt;p&gt;&lt;code&gt;&amp;lt;amatch&amp;gt;&lt;/code&gt; is exactly what is matched against the &lt;code&gt;autocmd&lt;/code&gt; pattern.  For &lt;code&gt;autocmd&lt;/code&gt;s that match filenames, symlinks are resolved, the result is canonicalized, and the full path is returned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;afile&amp;gt;&lt;/code&gt; is the canonical full path as above, but the result is also shortened, which is essentially the same as &lt;code&gt;fnamemodify(file, ':.')&lt;/code&gt; (the exact details are more involved, but the preceding description is accurate for all &quot;normal&quot; cases).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, in general &lt;code&gt;expand('&amp;lt;afile&amp;gt;') == expand('&amp;lt;amatch&amp;gt;:.')&lt;/code&gt; (&lt;strong&gt;edit:&lt;/strong&gt; provided, of course, that they do refer to the same thing).&lt;/p&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="2313" LastEditDate="2015-08-26T17:50:56.380" LastActivityDate="2015-08-26T17:50:56.380" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4527" PostTypeId="1" AcceptedAnswerId="4537" CreationDate="2015-08-26T13:29:59.020" Score="0" ViewCount="380" Body="&lt;p&gt;Is there any proper autocomplete and/or syntax checker for &lt;code&gt;CoffeeScript&lt;/code&gt; in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not a very complex question but i cant seem to find anything.&#xA;I am currently using YCM.&lt;/p&gt;&#xA;" OwnerUserId="3322" LastEditorUserId="205" LastEditDate="2015-08-26T13:43:59.563" LastActivityDate="2015-08-27T05:29:28.347" Title="Is there any proper autocomplete and/or syntax checker for CoffeeScript in vim?" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4528" PostTypeId="1" AcceptedAnswerId="4542" CreationDate="2015-08-26T15:50:58.873" Score="2" ViewCount="644" Body="&lt;p&gt;I followed the link &lt;a href=&quot;https://superuser.com/questions/844004/creating-a-simple-vim-syntax-highlighting&quot;&gt;creating-a-simple-vim-syntax-highlighting&lt;/a&gt;, for doing the syntax highlighting for my purpose.&#xA;This is really nice., but it's static. So, keywords are to be predefined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a situation, where i see lot of pointers or addresses in my file, which i want to track individually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;example below, whatever follows &quot;&lt;code&gt;msm_vidc:  pkt: XXXXXXXX&lt;/code&gt; &quot; to be colored differently/individually. In below case, &lt;strong&gt;00211005,00211004,00221007,00211001&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[  615.738018] msm_vidc:  pkt: 0000002c 00211005 eac11e40 00000000 00000000 00021000 00000000 00000000&#xA;[  615.738078] msm_vidc:  pkt: 0000003c 00211004 eac11e40 00000000 00000000 00000000 00000000 00000000&#xA;[  615.753302] msm_vidc:  pkt: 00000028 00221007 eac11e40 0000100b 00000018 00000000 5dc00000 5dc00000&#xA;[  616.257331] msm_vidc:  pkt: 0000003c 00211004 eac11e40 00051da6 97658047 00000000 00000000 00000000&#xA;[  616.262023] msm_vidc:  pkt: 00000028 00221007 eac11e40 0000100b 00000018 00000000 5dc00000 5dc00000&#xA;[  616.336188] msm_vidc:  pkt: 0000003c 00211004 eac11e40 00051da6 97659fd2 00000000 00000000 00000000&#xA;[  616.336483] msm_vidc:  pkt: 0000003c 00211004 eac11e40 00051da6 9766a276 00000000 00000000 00000000&#xA;[  616.344627] msm_vidc:  pkt: 00000034 00021001 eac11e40 01000003 01000001 00000002 00001001 00000002&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, that, it can be viewed as below.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/c2IAn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/c2IAn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3323" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2015-08-28T09:33:37.430" Title="is there a way to define the syntax highlighting keyword programatically?" Tags="|vimscript|vimrc|syntax-highlighting|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4529" PostTypeId="2" ParentId="4528" CreationDate="2015-08-26T17:30:47.120" Score="1" Body="&lt;p&gt;Check out Ingo Karkat's &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2666&quot; rel=&quot;nofollow&quot;&gt;Mark&lt;/a&gt; plugin. You can highlight patterns by specifying them on the command line or by a couple of keystrokes over the word of interest. It rotates through a pallette of colors, or you can choose the color yourself.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-08-26T17:30:47.120" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4530" PostTypeId="1" AcceptedAnswerId="4531" CreationDate="2015-08-26T18:18:27.713" Score="4" ViewCount="369" Body="&lt;p&gt;Is there a setting that allows you to move over &lt;code&gt;conceal&lt;/code&gt;ed strings as if they were one (or even better: zero) characters? (&lt;a href=&quot;https://vi.stackexchange.com/a/2492/3316&quot;&gt;This answer&lt;/a&gt; seems to suggest there's not.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it is, any movement can land on the concealment character. For example, &lt;code&gt;fa&lt;/code&gt; will land on a following ceoncealment if it contains the character &lt;code&gt;a&lt;/code&gt;, rather than skipping it to the next &lt;code&gt;a&lt;/code&gt; on the line. This can be very annoying.&lt;/p&gt;&#xA;" OwnerUserId="3316" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-08-26T18:25:00.987" Title="Moving over conceal" Tags="|cursor-movement|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4531" PostTypeId="2" ParentId="4530" CreationDate="2015-08-26T18:25:00.987" Score="3" Body="&lt;p&gt;No, there is no such setting. Concealing only means to visually hide parts of your buffer, but that won't affect movements nor linebreaking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Fixing&quot; this is in the todo list, but I wouldn't bet it will be implemented within the foreseeable future, as it will likely introduce even more conceal bugs.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-08-26T18:25:00.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4532" PostTypeId="1" AcceptedAnswerId="4533" CreationDate="2015-08-26T22:29:15.197" Score="9" ViewCount="550" Body="&lt;p&gt;I am using gVim and it seems the deleted text within 1 line (except &lt;code&gt;d&lt;/code&gt; following some operations, like &lt;code&gt;(&lt;/code&gt;) doesn't go to &lt;code&gt;&quot;1&lt;/code&gt; then shift the &lt;code&gt;&quot;1-&quot;9&lt;/code&gt; registers, it only goes to &lt;code&gt;&quot;-&lt;/code&gt;, one example is &lt;code&gt;diw&lt;/code&gt; command. I didn't see this in the help (&lt;code&gt;:h registers&lt;/code&gt;), is this expected behavior?&lt;/p&gt;&#xA;" OwnerUserId="477" LastActivityDate="2021-03-03T15:25:33.297" Title="Numbered register doesn't record most deleted text within a line?" Tags="|register|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4533" PostTypeId="2" ParentId="4532" CreationDate="2015-08-26T23:34:32.750" Score="11" Body="&lt;p&gt;It is. To quote from &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#quote_number&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h quote_number&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Numbered register 1 contains the text deleted by the most recent delete or&#xA;change command, &lt;em&gt;unless&lt;/em&gt; the command specified another register or &lt;em&gt;the text is&#xA;less than one line (the small delete register is used then)&lt;/em&gt;. An exception is&#xA;made for the delete operator with these movement commands: |%|, |(|, |)|, |`|,&#xA;|/|, |?|, |n|, |N|, |{| and |}|. Register &amp;quot;1 is always used then (this is Vi&#xA;compatible).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;(emphasis mine)&lt;/p&gt;&#xA;&lt;p&gt;To briefly see the content of your registers after a &lt;code&gt;&amp;quot;&lt;/code&gt; (or &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; in insert mode), you can try &lt;a href=&quot;https://github.com/junegunn/vim-peekaboo&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-peekaboo&lt;/a&gt;—it makes selecting the desired register much easier.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="10604" LastEditDate="2021-03-03T15:25:33.297" LastActivityDate="2021-03-03T15:25:33.297" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4535" PostTypeId="1" AcceptedAnswerId="4536" CreationDate="2015-08-27T04:01:32.497" Score="1" ViewCount="1231" Body="&lt;p&gt;I have the following on my vimrc file to handle custom folding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ++ Folding                                                                    &#xA; set foldenable                      &quot; enable folding                            &#xA; set foldmethod=syntax               &quot; global folding method                &#xA; set foldlevelstart=1                &quot; folds with level 1 aren't closed &#xA;&#xA;augroup FileTypeVim                                                                                                                                                 &#xA;   autocmd!                                                                    &#xA;   autocmd FileType vim setlocal foldmethod=expr foldexpr=VimrcFold()          &#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open my vimrc it works perfectly fine. However, if I re-source my vimrc the foldmethod is set to &lt;em&gt;syntax&lt;/em&gt; (global) instead of &lt;em&gt;expr&lt;/em&gt; (specific for filetype vim). What do I have to specify in order to keep the vimrc with &lt;em&gt;expr&lt;/em&gt; foldmethod? I suspect it has to be with BufType rather than FileType but I am not sure how to deal with that. &lt;/p&gt;&#xA;" OwnerUserId="977" LastEditorUserId="1821" LastEditDate="2015-08-27T04:17:10.730" LastActivityDate="2015-08-27T08:52:30.167" Title="Setting foldmethod=expr when re-sourcing vimrc?" Tags="|vimscript|vimrc|autocmd|folding|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4536" PostTypeId="2" ParentId="4535" CreationDate="2015-08-27T04:16:54.327" Score="1" Body="&lt;p&gt;You can do that with a modeline and an autocommand. E.g. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The modeline :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=marker spell:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this modeline I can fold my vimrc based on &lt;code&gt;{}&lt;/code&gt; pairs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The autocommands : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup FileTypeVim&#xA;   autocmd!&#xA;   &quot; Source your vimrc on save&#xA;   autocmd! BufWritePost .vimrc source %&#xA;   &quot; Apply modeline option after re-openning the vimrc file (that is after sourcing it)&#xA;   autocmd! BufWritePost .vimrc set modeline | doautocmd BufRead&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;References : &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/24221294/vim-read-modeline-after-opening-the-file&quot;&gt;https://stackoverflow.com/questions/24221294/vim-read-modeline-after-opening-the-file&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Modeline_magic&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Modeline_magic&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-27T07:08:20.990" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4537" PostTypeId="2" ParentId="4527" CreationDate="2015-08-27T05:29:28.347" Score="1" Body="&lt;p&gt;I don't code in CoffeeScript myself, but I've used &lt;a href=&quot;https://github.com/kchmck/vim-coffee-script&quot; rel=&quot;nofollow&quot;&gt;vim-coffee-script&lt;/a&gt; for viewing files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't support autocomplete, but it kind of provides syntax checking by compiling (showing the errors) and running &lt;a href=&quot;http://www.coffeelint.org/&quot; rel=&quot;nofollow&quot;&gt;coffeelint&lt;/a&gt;. I know it's kind of a stretch though.. maybe better than nothing?&lt;/p&gt;&#xA;" OwnerUserId="3329" LastActivityDate="2015-08-27T05:29:28.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4538" PostTypeId="2" ParentId="4535" CreationDate="2015-08-27T06:20:38.770" Score="2" Body="&lt;p&gt;When resourcing your .vimrc you will overwrite your current foldmethod setting and reset it to &quot;syntax&quot;. The autocommand won't trigger, since by that time, the filetype has already been set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way around it, would be to check your current foldmethod and only set it, if it set to manual, e.g. like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;l:fdm is# 'manual'&#xA;    let &amp;amp;fdm='syntax'&#xA; endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This checks the local foldmethod setting for the current buffer and only&#xA;sets the global option, if the local value is at the default value of 'manual' (assuming it had not been set).&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-08-27T08:52:30.167" LastActivityDate="2015-08-27T08:52:30.167" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4539" PostTypeId="1" CreationDate="2015-08-27T07:01:07.503" Score="4" ViewCount="190" Body="&lt;p&gt;While searching for autocommands event I noticed that there are no &lt;code&gt;SourcePost&lt;/code&gt; event. This is strange, because nearly all of other event have a &lt;code&gt;Post&lt;/code&gt; version of it (e.g. &lt;code&gt;FileAppendPost&lt;/code&gt;, &lt;code&gt;BufWritePost&lt;/code&gt;, ... ).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know the reason behind this ?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-08-27T07:14:25.787" LastActivityDate="2022-12-30T18:11:53.623" Title="Event SourcePost doesn't exist" Tags="|vimrc|autocmd|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4540" PostTypeId="2" ParentId="4382" CreationDate="2015-08-27T08:12:23.840" Score="1" Body="&lt;p&gt;You should check your current directory to see if its the same as your &lt;strong&gt;tags&lt;/strong&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:pwd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If not just&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cd /to/dir/which/contains/yourtagfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and try again using tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please check &lt;a href=&quot;https://stackoverflow.com/questions/11975316/vim-ctags-tag-not-found&quot;&gt;this response&lt;/a&gt; for ways to set searching directories for tag files&lt;/p&gt;&#xA;" OwnerUserId="2710" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-27T12:02:50.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4541" PostTypeId="1" AcceptedAnswerId="4546" CreationDate="2015-08-27T08:49:10.630" Score="10" ViewCount="6876" Body="&lt;p&gt;I installed vundle yesterday and since I did, the tabwidth I configured in my vimrc is ignored and set back to 4 instead of 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found out that the following line after the vundle paragraph is causing it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My indentation is set up like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noexpandtab &quot; Make sure that every file uses real tabs, not spaces&#xA;set shiftround  &quot; Round indent to multiple of 'shiftwidth'&#xA;set smartindent &quot; Do smart indenting when starting a new line&#xA;set autoindent  &quot; Copy indent from current line, over to the new line&#xA;&#xA;&quot; Set the tab width&#xA;let s:tabwidth=2&#xA;exec 'set tabstop='    .s:tabwidth&#xA;exec 'set shiftwidth=' .s:tabwidth&#xA;exec 'set softtabstop='.s:tabwidth&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can check my full vimrc &lt;a href=&quot;https://github.com/wullxz/configfiles/blob/68332089f8747435e9a658e850e51cf11214697a/vimrc&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested the indentation problem using a python script (where indentation really matters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already tried changing &lt;code&gt;filetype plugin indent on&lt;/code&gt; to &lt;code&gt;filetype plugin on&lt;/code&gt; but that doesn't change anything. Only commenting out that line helps.&lt;br&gt;&#xA;Now, the vundle install guide says, this line is required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I fix this indent issue? Can I just ommit the filetype line or is it really mandatory to keep it in the vimrc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to @ChristianBrabandt and @romainl I now found a solution that can also reside in a single vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[...]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noexpandtab &quot; Make sure that every file uses real tabs, not spaces&#xA;set shiftround  &quot; Round indent to multiple of 'shiftwidth'&#xA;set autoindent  &quot; Copy indent from current line, over to the new line&#xA;&#xA;&quot; Set the tab width&#xA;let s:tabwidth=2&#xA;au Filetype * let &amp;amp;l:tabstop = s:tabwidth&#xA;au Filetype * let &amp;amp;l:shiftwidth = s:tabwidth&#xA;au Filetype * let &amp;amp;l:softtabstop = s:tabwidth&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3331" LastEditorUserId="3331" LastEditDate="2015-08-27T12:14:41.810" LastActivityDate="2017-01-27T23:32:38.537" Title="vundle &quot;filetype plugin indent on&quot; messes with tabwidth" Tags="|vimrc|indentation|plugin-vundle|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4542" PostTypeId="2" ParentId="4528" CreationDate="2015-08-27T09:19:52.437" Score="1" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; : To share the script more easily, I made a github repo &lt;a href=&quot;https://github.com/nobe4/syntaxreload.vim&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; where you can go and try it for yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how I did it. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get the matching strings : &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The workflow is the following : you do a search and then you call the &lt;code&gt;Reload&lt;/code&gt; command. It will build a list of all matched strings with a function and the following substitution command : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s//\=&amp;lt;SID&amp;gt;AddToList(l:list, submatch(0))/n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Sort and remove duplicates over the list with the functions &lt;code&gt;uniq()&lt;/code&gt; and &lt;code&gt;sort()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Build a dictionary that has for keys the matched strings and for values a random color (see the &lt;code&gt;s:GetColor()&lt;/code&gt; function for details)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create a new empty buffer &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For each entry in the dictionary :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create two new syntax and highlight strings &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;e.g. for the entry &lt;code&gt;'foo1' : 'red'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match foo1 &quot;foo1&quot;&#xA;highlight foo1 ctermbg=red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Add the created lines into the buffer&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Move vim to the location of the syntax file (&lt;strong&gt;This part is currently not dynamic, you might want to change it&lt;/strong&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Override the current syntax file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Reload the syntax&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note :&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For this to work (as specified in the &lt;a href=&quot;https://github.com/nobe4/syntaxreload.vim/blob/master/ftdetect/syntaxreload.vim&quot; rel=&quot;nofollow&quot;&gt;ftdetect&lt;/a&gt; file) you should use &lt;code&gt;.foo&lt;/code&gt; as filetype. (this could be dynamic as well)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is a demo : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://asciinema.org/a/25644&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;https://asciinema.org/a/25644.png&quot; alt=&quot;asciicast&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a question , please leave a comment, I'll be happy to answer it.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-08-28T09:33:37.430" LastActivityDate="2015-08-28T09:33:37.430" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4543" PostTypeId="5" CreationDate="2015-08-27T09:37:17.690" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow&quot;&gt;Homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3320" LastEditorUserId="3320" LastEditDate="2015-08-27T15:57:50.390" LastActivityDate="2015-08-27T15:57:50.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4544" PostTypeId="4" CreationDate="2015-08-27T09:37:17.690" Score="0" Body="A modern vim plugin for editing LaTeX files." OwnerUserId="3320" LastEditorUserId="3320" LastEditDate="2015-08-27T15:57:41.980" LastActivityDate="2015-08-27T15:57:41.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4545" PostTypeId="1" AcceptedAnswerId="4547" CreationDate="2015-08-27T09:37:34.547" Score="7" ViewCount="742" Body="&lt;p&gt;I've been using vim for more than 5 years now, and I was surprised when I didn't know what an abandoned buffer was. The closest answer I found was in this &lt;a href=&quot;https://stackoverflow.com/a/15950622/1864317&quot;&gt;SO answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is an abandoned buffer one that was loaded but is not displayed any more? What about if there are multiple tabs - are any of the buffers loaded in these tabs abandoned or not?&lt;/p&gt;&#xA;" OwnerUserId="3332" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2024-02-11T18:33:53.037" Title="What is an abandoned buffer in vim?" Tags="|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4546" PostTypeId="2" ParentId="4541" CreationDate="2015-08-27T09:49:16.817" Score="11" Body="&lt;p&gt;First things first; the line below has absolutely &lt;em&gt;nothing&lt;/em&gt; to do with Vundle or plugin management:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That command does three things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;enables filetype detection,&lt;/li&gt;&#xA;&lt;li&gt;enables filetype-specific scripts (ftplugins),&lt;/li&gt;&#xA;&lt;li&gt;enables filetype-specific indent scripts.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That line is there because some plugin managers have to make sure filetype detection is disabled before doing their magic and using Vim for programming would suck a lot harder without ftplugins and proper indentation. It is my opinion that they should simply deal with filetype detection internally but well…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, your problem is caused by over-possessive ftplugins that override your indentation settings with theirs. The python ftplugin is the most common culprit because it was decided not long ago that it should enforce PEP8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easy way out would be to avoid sourcing ftplugins altogether:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but they usually come with useful stuff so that method is not really recommended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The cleanest solution is to leave the &lt;code&gt;filetype&lt;/code&gt; line in its &quot;optimal&quot; state:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and override their overrides with your own &lt;code&gt;after/ftplugin/python.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal noexpandtab&#xA;setlocal shiftround&#xA;setlocal autoindent&#xA;&#xA;let s:tabwidth=2&#xA;let &amp;amp;l:tabstop = s:tabwidth&#xA;let &amp;amp;l:shiftwidth = s:tabwidth&#xA;let &amp;amp;l:softtabstop = s:tabwidth&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I removed &lt;code&gt;smartindent&lt;/code&gt; because it is not that smart to begin with and deprecated by filetype-specific indent scripts anyway.&lt;/li&gt;&#xA;&lt;li&gt;I replaced your &lt;code&gt;:execute&lt;/code&gt; commands with cleaner &lt;code&gt;:let&lt;/code&gt; commands to avoid unnecessary concatenation.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-08-27T09:49:16.817" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4547" PostTypeId="2" ParentId="4545" CreationDate="2015-08-27T10:14:15.600" Score="8" Body="&lt;p&gt;An &amp;quot;abandoned&amp;quot; buffer is a buffer you left without saving changes.&lt;/p&gt;&#xA;&lt;p&gt;If you have &lt;code&gt;set nohidden&lt;/code&gt; (the default value), Vim generally warns you about unsaved changes when you try to leave a modified buffer. When you force your way with a bang, the previous buffer becomes &amp;quot;abandoned&amp;quot; and you loose all your unsaved changes.&lt;/p&gt;&#xA;&lt;p&gt;If you have &lt;code&gt;set hidden&lt;/code&gt;, modified buffers are kept in their current state when you leave them so they are — technically — never &amp;quot;abandoned&amp;quot;. You will still get a warning if you try to quit Vim with unsaved changes.&lt;/p&gt;&#xA;&lt;p&gt;As long as it's still displayed in a window, a buffer can't be thought of as &amp;quot;hidden&amp;quot; or &amp;quot;abandoned&amp;quot; so your buffers currently displayed in another window in another tab page are neither &amp;quot;hidden&amp;quot; nor &amp;quot;abandoned&amp;quot;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2024-02-11T18:33:53.037" LastActivityDate="2024-02-11T18:33:53.037" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4548" PostTypeId="1" CreationDate="2015-08-27T10:32:57.520" Score="1" ViewCount="139" Body="&lt;p&gt;We can start elvis in input mode using &lt;strong&gt;-i&lt;/strong&gt; option.&#xA;Also we can start input mode with various commands that specified in help &lt;code&gt;:help&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But users call &lt;strong&gt;insert mode&lt;/strong&gt; too which can also determined from &lt;strong&gt;h&lt;/strong&gt; command &lt;code&gt;:h&lt;/code&gt;.&#xA;Is there any difference between insert mode and input mode in elvis?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also consider that &lt;strong&gt;-i&lt;/strong&gt; option is for startup command line: &lt;code&gt;elvis -i&lt;/code&gt; which is specified in help: &lt;code&gt;elvis --help&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;elvis version: 2.2.0&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="3327" LastEditorUserId="51" LastEditDate="2020-12-11T04:52:13.137" LastActivityDate="2020-12-11T04:52:13.137" Title="Elvis 2.2.0 : Input vs Insert mode" Tags="|insert-mode|startup|elvis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4549" PostTypeId="2" ParentId="4548" CreationDate="2015-08-27T10:45:49.793" Score="3" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: from comments below, the answer was originally posted for the elvis version of vi.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I think the &lt;code&gt;insert&lt;/code&gt; and &lt;code&gt;input&lt;/code&gt; modes are the same thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the documentation you can see all the vim modes : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h vim-modes&#xA;&#xA;Vim has six BASIC modes:&#xA;Normal mode&#xA;Visual mode&#xA;Select mode&#xA;Insert mode&#xA;Command-line mode&#xA;Ex mode&#xA;&#xA;There are six ADDITIONAL modes.  These are variants of the BASIC modes:&#xA;Operator-pending mode&#xA;Replace mode&#xA;Virtual Replace mode&#xA;Insert Normal mode&#xA;Insert Visual mode&#xA;Insert Select mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no input mode here, it should be a second name for the &lt;code&gt;insert&lt;/code&gt; mode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the &lt;code&gt;-i&lt;/code&gt; flags doesn't seems to do what you say. The documentation says that the &lt;code&gt;-i&lt;/code&gt; flag start vim another &lt;code&gt;viminfo&lt;/code&gt; file. (see &lt;code&gt;:h -i&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The flag you might want to see is the &lt;code&gt;-y&lt;/code&gt; : it start vim in &quot;easy&quot; mode. (see &lt;code&gt;:h -y&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-08-27T13:00:09.270" LastActivityDate="2015-08-27T13:00:09.270" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4550" PostTypeId="1" CreationDate="2015-08-27T12:00:16.887" Score="1" ViewCount="652" Body="&lt;p&gt;I have created a &lt;code&gt;ftplugin/html.vim&lt;/code&gt; file with a custom fold expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my &lt;code&gt;.vimrc&lt;/code&gt; file I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=syntax &quot;all files use syntax fold method&#xA;autocmd Syntax html set foldmethod=expr foldexpr=HTMLFolds() &quot;html files use custom fold method&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However when opening an &lt;code&gt;index.html&lt;/code&gt; and then another file, let's say &lt;code&gt;app.js&lt;/code&gt; and then toggling between the files with &lt;code&gt;bp&lt;/code&gt; and &lt;code&gt;bn&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fold method is never kept and somehow reset to &lt;code&gt;manual&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to keep the foldmethod for each buffer when navigating files in vim so the &lt;code&gt;foldmethod&lt;/code&gt; is kept always the one it should be?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;behaviour example&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://asciinema.org/a/bmax4jemuq9toi2fnkf3q66yv&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;https://asciinema.org/a/bmax4jemuq9toi2fnkf3q66yv.png&quot; alt=&quot;asciicast&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3334" LastEditorUserId="3334" LastEditDate="2015-08-27T21:23:07.860" LastActivityDate="2015-08-27T21:23:07.860" Title="Vim reseting to foldmethod=manual once navigating buffers" Tags="|vimrc|folding|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4551" PostTypeId="2" ParentId="4550" CreationDate="2015-08-27T12:35:29.483" Score="2" Body="&lt;p&gt;Since you already have &lt;code&gt;ftplugin/html.vim&lt;/code&gt; you should simply add these lines to it and keep your &lt;code&gt;vimrc&lt;/code&gt; clean:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal foldmethod=expr&#xA;setlocal foldexpr=HTMLFolds()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, you should probably make &lt;code&gt;HTMLFolds()&lt;/code&gt; local to your script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:HTMLFolds()&#xA;    ...&#xA;function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and call it like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal foldexpr=s:HTMLFolds()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-08-27T12:35:29.483" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4552" PostTypeId="1" AcceptedAnswerId="4563" CreationDate="2015-08-27T16:19:31.320" Score="6" ViewCount="2541" Body="&lt;p&gt;Let's say I'm a terrible person and I'm thinking about remapping &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to do what &lt;code&gt;:&lt;/code&gt; normally does (start command-line mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's built-in &lt;code&gt;netrw&lt;/code&gt; plugin also remaps &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to open the selected directory or file. Specifically, it appears to map it to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call netrw#LocalBrowseCheck(&amp;lt;SID&amp;gt;NetrwBrowseChgDir(1, &amp;lt;SID&amp;gt;NetrwGetWord()))`)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The use of &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; makes it impractical for me to simply reproduce this map in my &lt;code&gt;.vimrc&lt;/code&gt;, which I would like to do, because I would like to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType netrw nnoremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in order to access command-line mode consistently. What might be an effective way to move &lt;code&gt;netrw&lt;/code&gt;'s default &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; functionality to another keystroke so I can still open files with it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My experiments thus far have led to my trying to use &lt;code&gt;maparg&lt;/code&gt; to do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:ConfigureNetrw()&#xA;  execute &quot;nnoremap &amp;lt;buffer&amp;gt; o &quot; . maparg(&quot;&amp;lt;CR&amp;gt;&quot;, &quot;n&quot;)&#xA;  nnoremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; :&#xA;endfunction&#xA;&#xA;augroup configure_netrw&#xA;  autocmd!&#xA;  autocmd FileType netrw call s:ConfigureNetrw()&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However this seems to result in both &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; and &lt;code&gt;o&lt;/code&gt; doing the same thing when I check the output of &lt;code&gt;nmap&lt;/code&gt; (they both get mapped to &lt;code&gt;:&lt;/code&gt;). I could understand how this might happen if I used &lt;code&gt;nmap&lt;/code&gt;, since the &lt;code&gt;maparg&lt;/code&gt; result has a &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in it. But it confuses me how it doesn't seem to matter if I use &lt;code&gt;nmap&lt;/code&gt; or &lt;code&gt;nnoremap&lt;/code&gt;; the same thing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;After a lot of frustrated poking around I have narrowed my apparent problem to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:prior = maparg(&quot;&amp;lt;CR&amp;gt;&quot;, &quot;n&quot;)&#xA;nmap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I put this in &lt;code&gt;~/.vim/after/ftplugin/netrw.vim&lt;/code&gt;. I would expect that getting into a Netrw buffer and doing &lt;code&gt;:echo g:prior&lt;/code&gt; would print the &lt;code&gt;LocalBrowseCheck&lt;/code&gt; text that netrw maps &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to. Instead it prints &lt;code&gt;-&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This happens if I put the same two lines in a function called from an &lt;code&gt;autocmd&lt;/code&gt;, as I was originally doing. It happens if use &lt;code&gt;nnoremap&lt;/code&gt; instead of &lt;code&gt;nmap&lt;/code&gt;. It does &lt;em&gt;not&lt;/em&gt; happen if I change the filename or autocmd so it associates with a different filetype (say, text); in that it prints what &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is originally bound to (&lt;code&gt;:&lt;/code&gt;). I am now completely confused.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorDisplayName="user72" LastEditDate="2015-08-28T20:00:23.287" LastActivityDate="2021-06-08T14:47:25.230" Title="How can I move netrw's default keybindings to other keys?" Tags="|netrw|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4553" PostTypeId="2" ParentId="4552" CreationDate="2015-08-27T17:10:10.567" Score="6" Body="&lt;p&gt;Netrw's documentation recommends putting your custom mappings in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/after/ftplugin/netrw.vim                    on unix-like systems&#xA;%userprofile%\vimfiles\after\ftplugin\netrw.vim    on Windows&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will need to use &lt;code&gt;nmap&lt;/code&gt; because you are remapping existing mappings (that's what is blocking you), and &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; to restrict your mappings to netrw buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-08-27T17:10:10.567" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4554" PostTypeId="1" CreationDate="2015-08-27T17:19:09.523" Score="1" ViewCount="2023" Body="&lt;p&gt;I've write myself a function, which receive a motion and perform it in other window. However, a problem raises when I need to map a real motion to a key sequence:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-p&amp;gt; :call Motion('\&amp;lt;C-F&amp;gt;')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unexpectedly, &lt;code&gt;vim&lt;/code&gt; executes &lt;code&gt;&amp;lt;C-F&amp;gt;&lt;/code&gt; for me when I just want &lt;code&gt;vim&lt;/code&gt; to put &lt;code&gt;&amp;lt;C-F&amp;gt;&lt;/code&gt; there as string literal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any solution to this?&lt;/p&gt;&#xA;" OwnerUserId="1097" LastEditorUserId="1821" LastEditDate="2016-04-14T17:36:13.357" LastActivityDate="2020-12-06T06:06:18.777" Title="how can I keep `&lt;C-f&gt;` literal in map definition?" Tags="|key-bindings|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4555" PostTypeId="1" CreationDate="2015-08-27T17:20:22.043" Score="4" ViewCount="1191" Body="&lt;p&gt;The &lt;code&gt;/&lt;/code&gt; command moves to the next occurrence of a pattern.  But how do I move to the next line in which a pattern does &lt;em&gt;not&lt;/em&gt; appear?&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2015-08-27T19:08:10.723" Title="Search for the next line that does not match a pattern" Tags="|search|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4556" PostTypeId="1" AcceptedAnswerId="4558" CreationDate="2015-08-27T18:10:11.290" Score="32" ViewCount="14163" Body="&lt;p&gt;Is there a command to undo the last operation performed while in insert mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just pasted text from the wrong register using &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt;, and I have two options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Delete by hand what I just pasted and start over.&lt;/li&gt;&#xA;&lt;li&gt;Switch to normal mode, hit &lt;code&gt;u&lt;/code&gt; and lose the text I typed before hitting &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is there a better way?&lt;/p&gt;&#xA;" OwnerUserId="3079" LastActivityDate="2015-08-27T18:57:21.217" Title="Undo in insert mode" Tags="|insert-mode|undo-redo|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4557" PostTypeId="2" ParentId="4556" CreationDate="2015-08-27T18:32:18.447" Score="8" Body="&lt;p&gt;From insert mode:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If your pasted text is smaller than one line (which is what your 2nd point implies), simply hit &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; to remove all characters before cursor in the current line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If pasted text is more than one line, your 2nd solution would work better, adapted as follows: &lt;code&gt;&amp;lt;C-o&amp;gt;u&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Both points above will start and stay - or finish - in insert mode; they are actually the same with your proposed solutions, just made shorter :)&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-08-27T18:32:18.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4558" PostTypeId="2" ParentId="4556" CreationDate="2015-08-27T18:36:12.250" Score="19" Body="&lt;p&gt;Vim offers a limited ability to specify the scope of an undoable change with the &lt;code&gt;Ctrl-G u&lt;/code&gt; command, which breaks the undo sequence. See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help i_CTRL-G_u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your case, the solution would be to remap &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;C-R&amp;gt; &amp;lt;C-G&amp;gt;u&amp;lt;C-R&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then typing &lt;code&gt;&amp;lt;C-O&amp;gt;u&lt;/code&gt; will undo just the changes made since you typed &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;. See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help i_CTRL-O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="2055" LastEditDate="2015-08-27T18:57:21.217" LastActivityDate="2015-08-27T18:57:21.217" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4559" PostTypeId="2" ParentId="4556" CreationDate="2015-08-27T18:36:48.887" Score="9" Body="&lt;p&gt;You could try &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; (deletes a word to the left) or &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; (clear characters before cursor when pressed once, deletes linebreak when pressed a second time). See &lt;code&gt;:help i_CTRL-W&lt;/code&gt; and &lt;code&gt;:help i_CTRL-U&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you paste a lot from a register it is of course faster to undo your changes, you can use insert-normal-mode with &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; for that (execute one normal mode command then go back to insert mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general it is helpful to chunk your edits into small pieces by often going back to normal mode, so that you have fine-grained undo possibilities.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastEditorUserId="3282" LastEditDate="2015-08-27T18:46:51.437" LastActivityDate="2015-08-27T18:46:51.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4560" PostTypeId="2" ParentId="4555" CreationDate="2015-08-27T18:51:12.157" Score="6" Body="&lt;p&gt;Recent Vims come with the &lt;a href=&quot;http://vim.sourceforge.net/scripts/script.php?script_id=1290&quot; rel=&quot;nofollow&quot;&gt;LogiPat plugin&lt;/a&gt;. With that, you can simply do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:LogiPat !&quot;foo&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it will jump to the next line, not containting your pattern. To see the pattern, you can type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo @/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which should show something like &lt;code&gt;^\%(\%(foo\)\@!.\)*$&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-08-27T19:08:10.723" LastActivityDate="2015-08-27T19:08:10.723" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4561" PostTypeId="1" AcceptedAnswerId="4562" CreationDate="2015-08-27T22:04:57.030" Score="5" ViewCount="3424" Body="&lt;p&gt;I am breaking apart some files, and I'd like to paste what I cut into a brand new file, which I specify the name of. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:c file-that-doesnt-exist.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;c&lt;/code&gt; is a key command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; I've found &lt;code&gt;:e&lt;/code&gt;, but that just takes me to a new buffer with the same clipboard. I would just like to magically dump the clipboard into a new file and continue editing the original file, without seeing a new buffer.&lt;/p&gt;&#xA;" OwnerUserId="3344" LastEditorUserId="3344" LastEditDate="2015-08-27T22:17:29.130" LastActivityDate="2015-08-28T21:13:47.517" Title="Paste buffer/clipboard into brand new file?" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4562" PostTypeId="2" ParentId="4561" CreationDate="2015-08-28T00:08:12.650" Score="7" Body="&lt;p&gt;A fast way, working on entire lines, is to visually select the lines to move (&lt;code&gt;V&lt;/code&gt; ...), then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;write! &amp;gt;&amp;gt; the_other_file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... where &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; is automatically appended by Vim after you press &lt;code&gt;:&lt;/code&gt;. This will append the range to that file, creating it if it doesn't exist. Then, a &lt;code&gt;gv&lt;/code&gt; in normal mode will reselect the range, so you can easily delete it (&lt;code&gt;d&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, it's even easier - select another range (&lt;code&gt;V&lt;/code&gt; ...), hit &lt;code&gt;:&lt;/code&gt; to open command-line, &lt;code&gt;Ctrl-P&lt;/code&gt; to bring back the last command, &lt;code&gt;Enter&lt;/code&gt; to copy the lines &lt;sup&gt;1&lt;/sup&gt;. Then &lt;code&gt;gvd&lt;/code&gt; to delete them locally; rinse and repeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Alternatively&lt;/strong&gt;, you could &quot;cut&quot; to a named register by &lt;em&gt;appending&lt;/em&gt; to it (using the capital letter), e.g. on first text selection to cut: &lt;code&gt;&quot;ad&lt;/code&gt;, then (repeatedly): &lt;code&gt;&quot;Ad&lt;/code&gt; (on other selected text). At the end, edit the new file and paste from that register (&lt;code&gt;&quot;ap&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sup&gt;1&lt;/sup&gt;Even better, use &lt;code&gt;@:&lt;/code&gt; to repeat the last command (as &lt;a href=&quot;https://vi.stackexchange.com/users/21/karl-yngve-lerv%c3%a5g&quot;&gt;Karl Yngve Lervåg&lt;/a&gt; suggests in the 1st comment below).&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-08-28T21:13:47.517" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4563" PostTypeId="2" ParentId="4552" CreationDate="2015-08-28T04:05:44.083" Score="3" Body="&lt;p&gt;This is what I ended up doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:ConfigureNetrw()&#xA;  let prior = maparg(&quot;&amp;lt;CR&amp;gt;&quot;, &quot;n&quot;)&#xA;  if prior != &quot;:&quot;&#xA;    execute &quot;nnoremap &amp;lt;buffer&amp;gt; o &quot; . prior&#xA;    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; :&#xA;  endif&#xA;endfunction&#xA;&#xA;augroup netrw_configuration&#xA;  autocmd!&#xA;  autocmd FileType netrw call s:ConfigureNetrw()&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It turns out that for one reason or another (I'm not quite sure yet, as netrw's code is a bit tricky to delve through), the filetype for a netrw buffer is set or reset multiple times, or something, because the code for the filetype autocommand or in an &lt;code&gt;after/ftplugin&lt;/code&gt; script executes more than once. You can observe this with a snippet like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(&quot;g:counter&quot;)&#xA;  g:counter = 1&#xA;else&#xA;  g:counter = g:counter + 1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;:echo g:counter&lt;/code&gt; after invoking netrw. &lt;code&gt;g:counter&lt;/code&gt; will be 3 or 5 (or at least was for me) depending on where that code was. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the unusual behavior I was seeing where both commands ended up mapped to the same thing was because after the first invocation of the code, &lt;code&gt;maparg()&lt;/code&gt; would return the mapping I'd set for &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in the prior invocations, stomping over my original mapping. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Netrw will also re-apply buffer local mappings as you navigate the tree, it seems (or perhaps simply reset the filetype, but in any case the mappings are reset), which necessitates the check to see if the mapping for &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is what I expect it to be.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorDisplayName="user72" LastEditDate="2015-08-29T14:47:21.767" LastActivityDate="2015-08-29T14:47:21.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4564" PostTypeId="2" ParentId="3362" CreationDate="2015-08-28T07:18:09.340" Score="0" Body="&lt;p&gt;Not sure if I understand the question but if you only want to close all the files then this is the way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or just:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2710" LastEditorUserId="2710" LastEditDate="2015-08-28T07:39:50.640" LastActivityDate="2015-08-28T07:39:50.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4565" PostTypeId="2" ParentId="4561" CreationDate="2015-08-28T07:26:43.657" Score="5" Body="&lt;p&gt;An alternative is, assuming you want to store register a:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sp +0put\ a c:\temp\split.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can use &lt;code&gt;:e&lt;/code&gt; or &lt;code&gt;:tabedit&lt;/code&gt; or even &lt;code&gt;:new&lt;/code&gt; if you want a new unnamed buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the help&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :put&#xA;:h +cmd&#xA;:h :new&#xA;:h :split_f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-08-28T07:26:43.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4566" PostTypeId="1" AcceptedAnswerId="4568" CreationDate="2015-08-28T08:05:44.977" Score="4" ViewCount="4460" Body="&lt;p&gt;Is there a way to search files with netrw similar to find command in linux?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in command line I can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -name &quot;pattern&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there something similar in netrw?&lt;/p&gt;&#xA;" OwnerUserId="2710" LastActivityDate="2015-11-20T22:28:06.060" Title="Is there a way to search files with netrw similar to find command in linux?" Tags="|netrw|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4568" PostTypeId="2" ParentId="4566" CreationDate="2015-08-28T08:20:28.353" Score="3" Body="&lt;p&gt;You have plugins to do so :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://kien.github.io/ctrlp.vim/&quot; rel=&quot;nofollow&quot;&gt;Ctrl-P&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3025&quot; rel=&quot;nofollow&quot;&gt;Command-T&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Or you can do by hand :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a unix command from vim :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!find . -name &quot;pattern&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the &lt;code&gt;Explore&lt;/code&gt; command :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Explore pattern&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Based on &lt;a href=&quot;http://vim.wikia.com/wiki/Find_files_in_subdirectories&quot; rel=&quot;nofollow&quot;&gt;this post&lt;/a&gt; this function is available through the &lt;code&gt;netrw.vim&lt;/code&gt; file. &lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-08-28T08:20:28.353" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4569" PostTypeId="2" ParentId="4554" CreationDate="2015-08-28T10:12:31.523" Score="2" Body="&lt;p&gt;You can pass a literal &lt;code&gt;Ctrl+f&lt;/code&gt; by pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; in insert mode, but I'm not sure this will work for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other method which I find more correct (or easier and more widely used) is to pass the key/motion as a string and use &lt;code&gt;:execute&lt;/code&gt; to create the maps inside your function. Here is an example from the &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim/blob/master/plugin/ctrlp.vim#L38-L40&quot; rel=&quot;nofollow&quot;&gt;CtrlP&lt;/a&gt; plugin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The part in the plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if g:ctrlp_map != '' &amp;amp;&amp;amp; !hasmapto('&amp;lt;plug&amp;gt;(ctrlp)')&#xA;        exe 'map' g:ctrlp_map '&amp;lt;plug&amp;gt;(ctrlp)'&#xA;en&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can set the motion in .vimrc as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_map = '&amp;lt;C-f&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then &lt;code&gt;&amp;lt;plug&amp;gt;(ctrlp)&lt;/code&gt; would be mapped to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case you would have a simple call in .vimrc like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-p&amp;gt; :call Motion('&amp;lt;C-F&amp;gt;')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in &lt;code&gt;Motion&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Motion(sequence)&#xA;    &quot; other stuff&#xA;    execute 'map' a:sequence '&amp;lt;Plug&amp;gt;(action)'&#xA;    &quot; more stuff&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20" LastEditorUserId="20" LastEditDate="2015-08-28T14:38:55.360" LastActivityDate="2015-08-28T14:38:55.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4570" PostTypeId="1" AcceptedAnswerId="4571" CreationDate="2015-08-28T11:03:54.510" Score="2" ViewCount="576" Body="&lt;p&gt;Completion seems to work ok overall (so &lt;code&gt;&amp;lt;C-X&amp;gt;&lt;/code&gt; + &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; complete for tags and &lt;code&gt;&amp;lt;C-X&amp;gt;&lt;/code&gt; + &lt;code&gt;&amp;lt;C-N&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;C-P&amp;gt;&lt;/code&gt; complete in context), but the line completion (&lt;code&gt;&amp;lt;C-X&amp;gt;&lt;/code&gt; + &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt;) always tells me &quot;Pattern not found&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does not work even when at the beginning of a new line (when &lt;code&gt;&amp;lt;C-X&amp;gt;&lt;/code&gt; + &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; should just copy the previous line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&#xA;Even when starting vim without anything (&lt;code&gt;vim -u NONE&lt;/code&gt;) line completion still does not work. huh?&lt;/p&gt;&#xA;" OwnerUserId="2792" LastEditorUserId="2792" LastEditDate="2015-08-28T12:14:37.347" LastActivityDate="2015-08-28T14:24:40.190" Title="Trouble with vim line completion?" Tags="|autocompletion|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="4571" PostTypeId="2" ParentId="4570" CreationDate="2015-08-28T14:24:40.190" Score="5" Body="&lt;p&gt;The &lt;code&gt;'complete'&lt;/code&gt; option tells Vim where to look for building the popup menu when you do &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-l&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your value, &lt;code&gt;],i,d&lt;/code&gt; means that Vim will look in tags files (&lt;code&gt;]&lt;/code&gt;) and includes (&lt;code&gt;i&lt;/code&gt; and &lt;code&gt;d&lt;/code&gt;) for completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sorry to say that the explanation of what &lt;code&gt;i&lt;/code&gt; does is misleading and has been for a long time: it doesn't scan the current file &lt;em&gt;at all&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If Vim doesn't see a &lt;code&gt;tags&lt;/code&gt; file and doesn't find any include declaration in your buffer (or they point to files that can't be found) it has nothing to draw completions from and… simply doesn't do completion at all.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-08-28T14:24:40.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4572" PostTypeId="1" CreationDate="2015-08-29T00:42:54.417" Score="18" ViewCount="2040" Body="&lt;p&gt;I am trying to make vim auto indent with tabs, and align with whitespaces, but actually, vim indent with tabs and fill the alignment with tabs + white spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim does it :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RLVtl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RLVtl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(each block is a tab)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;&amp;gt;--long a = 1,&#xA;&amp;gt;--&amp;gt;--..b = 2,&#xA;&amp;gt;--&amp;gt;--..c = 3;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;May do it :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;&amp;gt;--long a = 1,&#xA;&amp;gt;--.....b = 2,&#xA;&amp;gt;--.....c = 3;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, I think there is a lot of questions about the subject of tabs and spaces, but none of them provide some Just Works solution:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/8493705/vim-use-tabs-for-indentation-spaces-for-alignment-with-c-source-files&quot;&gt;https://stackoverflow.com/questions/8493705/vim-use-tabs-for-indentation-spaces-for-alignment-with-c-source-files&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/29208431/vim-indent-with-tabs-align-with-spaces&quot;&gt;https://stackoverflow.com/questions/29208431/vim-indent-with-tabs-align-with-spaces&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/6504507/vim-indenting-and-alignment-combining-spaces-and-tabs&quot;&gt;https://stackoverflow.com/questions/6504507/vim-indenting-and-alignment-combining-spaces-and-tabs&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Actually I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ai&#xA;set cindent&#xA;set cinoptions=(0,:0,u0,U0,g0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=231&quot; rel=&quot;nofollow noreferrer&quot;&gt;Smart Tab&lt;/a&gt; plugin, which seems to work well, but when I try &lt;code&gt;gg=G&lt;/code&gt; I get some weird errors :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function CtabRedoIndent..&amp;lt;SNR&amp;gt;12_CheckAlign:&#xA;line   11:&#xA;E108: No such variable: &quot;b:ctab_lastalign&quot;&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function CtabRedoIndent:&#xA;line   10:&#xA;E170: Missing :endwhile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This discussion seems to be prety old, so now, 2015, there is a official solution to deal with it ?&lt;/p&gt;&#xA;" OwnerUserId="2131" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-08-11T09:48:56.393" Title="Tabs for indentation, spaces for alignment" Tags="|tab-characters|whitespace|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4575" PostTypeId="1" AcceptedAnswerId="4576" CreationDate="2015-08-29T16:34:25.077" Score="22" ViewCount="2163" Body="&lt;p&gt;Is there a dedicated way to merge two blocks of text by interleaving lines, like passing from this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a1&#xA;a2&#xA;a3&#xA;a4&#xA;  b1&#xA;  b2&#xA;  b3&#xA;  b4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a1&#xA;  b1&#xA;a2&#xA;  b2&#xA;a3&#xA;  b3&#xA;a4&#xA;  b4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in a few commands?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: I really like &lt;a href=&quot;https://vi.stackexchange.com/a/4576/1841&quot;&gt;Sato Katsura's solution&lt;/a&gt;, here is how I have implemented it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Interleave()&#xA;    &quot; retrieve last selected area position and size&#xA;    let start = line(&quot;.&quot;)&#xA;    execute &quot;normal! gvo\&amp;lt;esc&amp;gt;&quot;&#xA;    let end = line(&quot;.&quot;)&#xA;    let [start, end] = sort([start, end], &quot;n&quot;)&#xA;    let size = (end - start + 1) / 2&#xA;    &quot; and interleave!&#xA;    for i in range(size - 1)&#xA;        execute (start + size + i). 'm' .(start + 2 * i)&#xA;    endfor&#xA;endfunction&#xA;&#xA;&quot; Select your two contiguous, same-sized blocks, and use it to Interleave ;)&#xA;vnoremap &amp;lt;pickYourMap&amp;gt; &amp;lt;esc&amp;gt;:call Interleave()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2978" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2022-12-31T14:52:45.017" Title="Merge blocks by interleaving lines" Tags="|vimscript|formatting|merge|" AnswerCount="5" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4576" PostTypeId="2" ParentId="4575" CreationDate="2015-08-29T17:36:37.793" Score="10" Body="&lt;p&gt;There is no dedicated way to do that (as far as I know), but yeah, it can be done with a few commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Interleave(start, end, where)&#xA;    if a:start &amp;lt; a:where&#xA;        for i in range(0, a:end - a:start)&#xA;            execute a:start . 'm' . (a:where + i)&#xA;        endfor&#xA;    else&#xA;        for i in range(a:end - a:start, 0, -1)&#xA;            execute a:end . 'm' . (a:where + i)&#xA;        endfor&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can run it with &lt;code&gt;:call Interleave(5, 8, 1)&lt;/code&gt;.  The first parameter is the first line to move, the second one the last line, and the third one where to move them.  You probably want to turn on line numbers to see what you're doing (&lt;code&gt;:set number&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This assumes the blocks don't overlap.  See &lt;code&gt;:help :move&lt;/code&gt; and &lt;code&gt;:help range()&lt;/code&gt; to understand how the function works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are probably better ways to pick up the two blocks.  There is a plugin floating around that is supposed to let you swap two blocks.  I can't remember the name of the plugin, but the author (perhaps the famous Dr. Chip?) has put more thought into finding an interface than I did. :)&lt;/p&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="2313" LastEditDate="2015-08-30T02:17:53.000" LastActivityDate="2015-08-30T02:17:53.000" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4577" PostTypeId="1" AcceptedAnswerId="4579" CreationDate="2015-08-29T17:53:46.967" Score="22" ViewCount="12347" Body="&lt;p&gt;If I want to go to the next &lt;code&gt;,&lt;/code&gt; on the line then I type &lt;code&gt;t,&lt;/code&gt;. If I wanted to go to the previous &lt;code&gt;,&lt;/code&gt; I could use &lt;code&gt;/n&lt;/code&gt;, enter, &lt;code&gt;N&lt;/code&gt; but this is a bit of a fiddle. What is the best way to go to reverse the &lt;code&gt;t&lt;/code&gt; command and go to the previous &lt;code&gt;,&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3155" LastActivityDate="2015-08-29T18:06:41.980" Title="What is the reverse of the 'go to next' command" Tags="|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4578" PostTypeId="2" ParentId="4577" CreationDate="2015-08-29T17:58:01.460" Score="10" Body="&lt;p&gt;Just scroll down one paragraph in the help from &lt;code&gt;:help t&lt;/code&gt; to find &lt;code&gt;T&lt;/code&gt;, which moves &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Till after [count]'th occurrence of {char} to the left.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also &lt;code&gt;:help F&lt;/code&gt; which is to &lt;code&gt;f&lt;/code&gt; what &lt;code&gt;T&lt;/code&gt; is to &lt;code&gt;t&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can repeat the &lt;code&gt;fFtT&lt;/code&gt; motions with &lt;code&gt;;&lt;/code&gt; and also repeat in reverse direction with &lt;code&gt;,&lt;/code&gt;, so if you are already moving forward through the &lt;code&gt;,&lt;/code&gt;s on the line with &lt;code&gt;t,&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt; to repeat, then want to move back, just hit &lt;code&gt;,&lt;/code&gt; to repeat the &lt;code&gt;t&lt;/code&gt; motion as if it was a &lt;code&gt;T&lt;/code&gt; motion.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="1306" LastEditDate="2015-08-29T18:04:14.503" LastActivityDate="2015-08-29T18:04:14.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4579" PostTypeId="2" ParentId="4577" CreationDate="2015-08-29T17:59:21.353" Score="36" Body="&lt;p&gt;You can just use &lt;code&gt;T,&lt;/code&gt; and &lt;code&gt;F,&lt;/code&gt; instead of &lt;code&gt;t,&lt;/code&gt; and &lt;code&gt;f,&lt;/code&gt;. The lowercase commands go forward; the uppercase ones go backwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo, b|ar, baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the cursor on the first &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;t,&lt;/code&gt; would move forward to &lt;code&gt;r&lt;/code&gt; (the character before the next comma). Now if you use &lt;code&gt;T,&lt;/code&gt; you will go backwards to the character after the previous comma (i.e. the space after &lt;code&gt;foo,&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;f&lt;/code&gt; and &lt;code&gt;F&lt;/code&gt; do the same except they go to the specified character and not the character before/after it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note you can use the &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt; commands to repeat the last &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt; or &lt;code&gt;T&lt;/code&gt; command either in a forward of backwards direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more on this read &lt;code&gt;:help f&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="356" LastEditDate="2015-08-29T18:06:41.980" LastActivityDate="2015-08-29T18:06:41.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4580" PostTypeId="1" AcceptedAnswerId="4581" CreationDate="2015-08-29T19:38:43.227" Score="7" ViewCount="1057" Body="&lt;p&gt;Is there a way to call Vim in such a way that it opens a buffer with some content specified on the terminal, i.e. not saved in a file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I would like to run &lt;code&gt;vim&lt;/code&gt; and have it open a buffer with &lt;code&gt;foo, bar, baz and qux&lt;/code&gt; written on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an option that does this?&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="1841" LastEditDate="2015-08-30T20:12:31.753" LastActivityDate="2017-01-20T06:40:41.577" Title="How to specify the content of a new buffer from command line?" Tags="|terminal|invocation|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4581" PostTypeId="2" ParentId="4580" CreationDate="2015-08-29T19:51:15.057" Score="12" Body="&lt;p&gt;Did you try something like this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo &quot;foo, bar, baz, and qux&quot; | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or like that?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -c &quot;put='foo, bar, baz, and qux'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-08-29T19:51:15.057" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4582" PostTypeId="2" ParentId="4575" CreationDate="2015-08-29T20:52:21.923" Score="4" Body="&lt;p&gt;If you want to have a little bit of fun with macros and marks you could try something like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First put a mark (here &lt;code&gt;a&lt;/code&gt;) on the line containing &lt;code&gt;a1&lt;/code&gt; with &lt;code&gt;ma&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to the line containing &lt;code&gt;b1&lt;/code&gt; and mark it with &lt;code&gt;mb&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Start recording a macro in the register you want (here the register &lt;code&gt;q&lt;/code&gt;) with &lt;code&gt;qq&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Insert the folowing in your macro: &lt;code&gt;ddmb'apjma'b&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Stop recording the macro with &lt;code&gt;q&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Play it as many times as needed with &lt;code&gt;X@q&lt;/code&gt; where &lt;code&gt;X&lt;/code&gt; is the number of time to play it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To detail the macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dd mb 'a p j ma 'b&#xA; |  |  | | |    |&#xA; |  |  | | |    go back to line marked `b`&#xA; |  |  | | |&#xA; |  |  | | move of one line and replace the mark `a`&#xA; |  |  | insert the deleted line under the line marked `a`&#xA; |  |  go to line marked `a`&#xA; |  mark the future line to move with `b`&#xA; delete the line to move&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; As lago-lito mentionned it in the comments this method will overwrite the marks and the buffers.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For the marks I don't think that's a real problem: I rarely use all 26 marks in a buffer and I think one will most of the time find 2 free marks.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For the buffer it is possible to save it in a temporary variable: Before recording the macro use &lt;code&gt;:let saveReg=getreg('&quot;')&lt;/code&gt; to save the register and once the action is done use &lt;code&gt;:call setreg('&quot;', saveReg)&lt;/code&gt; to get the register back to its previous state.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Anyway I must admit that this solution is just a quick workaround and isn't optimal: In my opinion &lt;a href=&quot;https://vi.stackexchange.com/a/4583/1841&quot;&gt;Christan's answer&lt;/a&gt; is the best one and should be accepted because it doesn't mess with buffers and marks, doesn't force the user to create a function and shows the power of the global command.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2015-08-30T20:59:57.073" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4583" PostTypeId="2" ParentId="4575" CreationDate="2015-08-29T21:19:22.037" Score="17" Body="&lt;p&gt;Here is another alternative:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^a/+4t .&#xA;:+,+5d &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First copy the lines which are 4 lines below to the after the current line (&lt;code&gt;:h :t&lt;/code&gt;) then delete the consecutive b lines (&lt;code&gt;:h :d&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even better is this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :g/^a//^\s*b/m .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means, for each line starting with a find the next line starting with 'b' and move it to below the current line.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-08-30T07:17:08.770" LastActivityDate="2015-08-30T07:17:08.770" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4584" PostTypeId="1" CreationDate="2015-08-30T00:35:41.780" Score="31" ViewCount="9326" Body="&lt;p&gt;How do I create my own list of auto-completion for certain filetypes? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I would like css and html to autocomplete from the list of css classes in &lt;a href=&quot;https://fortawesome.github.io/Font-Awesome/&quot;&gt;FontAwesome&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="1841" LastEditDate="2015-08-30T05:12:35.400" LastActivityDate="2016-08-13T22:33:07.103" Title="How to create my own autocomplete function?" Tags="|autocompletion|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4585" PostTypeId="2" ParentId="4584" CreationDate="2015-08-30T05:10:18.987" Score="20" Body="&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Thanks to romainl's comment I've edited my answer to show how to create a user-defined completion function. In the previous version I was overriding the buil-in omni-completion which wasn't good because the user would have loose the default completion which is pretty powerful.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A vimscript solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution is to use vimscript and the fact that vim let's you create a customized completion function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage of this solution is that you don't need an additional plugin you can simply create a user-defined completion function and use the built-in completion feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll use your example of the fontAwesome classes in &lt;code&gt;css&lt;/code&gt; files:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create the file &lt;code&gt;~/.vim/autoload/csscomplete.vim&lt;/code&gt; and put the following lines in it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:matches=&quot;.fa-lg .fa-2x .fa-3x .fa-4x .fa-5x .fa-fw .fa-ul .fa-ul .fa-li .fa-li.fa-lg .fa-border .fa-pull-left .fa-pull-right .fa.fa-pull-left&quot;&#xA;&#xA;function! csscomplete#CompleteFA(findstart, base)&#xA;    if a:findstart&#xA;        &quot; locate the start of the word&#xA;        let line = getline('.')&#xA;        let start = col('.') - 1&#xA;        while start &amp;gt; 0 &amp;amp;&amp;amp; (line[start - 1] =~ '\a' || line[start - 1] =~ '.' || line[start - 1] =~ '-')&#xA;            let start -= 1&#xA;        endwhile&#xA;        return start&#xA;    else&#xA;        &quot; find classes matching &quot;a:base&quot;&#xA;        let res = []&#xA;        for m in split(s:matches)&#xA;            if m =~ '^' . a:base&#xA;                call add(res, m)&#xA;            endif&#xA;        endfor&#xA;        return res&#xA;    endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then create the file &lt;code&gt;~/.vim/after/ftplugin/css.vim&lt;/code&gt; and put in it the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal completefunc=csscomplete#CompleteFA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can trigger your user-defined completion function with &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-u&amp;gt;&lt;/code&gt;. It will try to find a match to the last typed word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the screenshot I typed &lt;code&gt;.fa-l&lt;/code&gt; and then triggered the function with &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-u&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EkJNw.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EkJNw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How does it work?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First here are some relevant documentation topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#complete-functions&quot; rel=&quot;noreferrer&quot;&gt;:h complete-functions&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27completefunc%27&quot; rel=&quot;noreferrer&quot;&gt;:h 'completefunc'&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-X_CTRL-U&quot; rel=&quot;noreferrer&quot;&gt;:h i_CTRL-X_CTRL-U&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A &lt;a href=&quot;https://stackoverflow.com/a/2890444/4194289&quot;&gt;great answer&lt;/a&gt; about the organization of files.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want to create a custom completion for a particular filetype you have to put it in the file &lt;code&gt;$HOME/.vim/autoload/{FILETYPE}complete.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then in this file you have to create your completion function which is called twice:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;On first call its first argument is the current position of the cursor and the function will determine the word to complete. In my function I used 3 comparisons to get the word to complete because the class can be composed of letters, &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt; &lt;em&gt;(I think it is possible to improve this matching but I'm really bad with regex)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On second call the second argument is the word to match and then the function compares it to the list of possible classes to match &lt;sup&gt;1&lt;/sup&gt;. Here you see that I return a dictionary which will populate the completion menu &lt;strong&gt;but&lt;/strong&gt; when you'll read the documentation you'll see that you can create a much more complex dictionary to customize even more the behavior of your function.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You also have to tell to Vim &quot;for this kind of file, use this complete function I created&quot;. To do so you have to set &lt;code&gt;completefunc&lt;/code&gt; to the name of the function you created (here &lt;code&gt;csscomplete#CompleteFA&lt;/code&gt;) and this setting must be done in the file &lt;code&gt;$HOME/.vim/after/ftplugin/{FILETYPE}.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; In my function the variable &lt;code&gt;s:matches&lt;/code&gt; contains all the possible matches. Here I only put some suggestions for readability but you can put all the classes offered by FontAwesome (You can find the complete list in &lt;a href=&quot;https://gist.github.com/romainl/8bfc2ab1b565c19cb6b9&quot; rel=&quot;noreferrer&quot;&gt;this file&lt;/a&gt; created by romainl).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What if I don't like Vimscript?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possibility is to use the plugin &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;noreferrer&quot;&gt;YoucompleteMe&lt;/a&gt; which offers an API to play with the completion menu. You can create python function which will do the matching job and will use the API to populate Vim interface. More details &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe#writing-new-semantic-completers&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-08-30T23:54:24.583" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4586" PostTypeId="2" ParentId="4584" CreationDate="2015-08-30T08:44:38.797" Score="25" Body="&lt;p&gt;Dictionary completion would be a cheap and non-intrusive solution:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;save &lt;a href=&quot;https://gist.github.com/romainl/8bfc2ab1b565c19cb6b9&quot; rel=&quot;noreferrer&quot;&gt;fontawesome.txt&lt;/a&gt; somewhere on your machine,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;put this in &lt;code&gt;after/ftplugin/css.vim&lt;/code&gt; (create the file if it doesn't exist):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal complete+=k&#xA;setlocal dictionary+=/path/to/fontawesome.txt&#xA;setlocal iskeyword+=-&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;start a new session or do &lt;code&gt;:e&lt;/code&gt; in a CSS buffer to forcefully source the file above,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;press &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; in insert mode,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;enjoy!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/x9B6U.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/x9B6U.gif&quot; alt=&quot;dictionary completion&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Reference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help ins-completion&#xA;:help 'complete'&#xA;:help 'dictionary'&#xA;:help 'iskeyword'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-08-30T10:07:45.323" LastActivityDate="2015-08-30T10:07:45.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4587" PostTypeId="2" ParentId="4580" CreationDate="2015-08-30T20:09:48.293" Score="3" Body="&lt;p&gt;This solution is totally inspired from romainl's one &lt;em&gt;(many thanks to him)&lt;/em&gt; but it allows to open multiple buffers with multiple strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following lines to your &lt;code&gt;.zshrc&lt;/code&gt; (or &lt;code&gt;.bashrc&lt;/code&gt; or any relevant file where you define your bash functions)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function mvim {&#xA;    CMD=&quot;vim &quot;&#xA;    for string in &quot;$@&quot;&#xA;    do&#xA;        CMD=$CMD&quot;-c \&quot;enew | put='&quot;$string&quot;'\&quot; &quot;&#xA;    done&#xA;    CMD=$CMD&quot;-c \&quot;bufdo 1d\&quot;&quot;&#xA;&#xA;    eval $CMD&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After sourcing your &lt;code&gt;.zshrc&lt;/code&gt; file you'll be able to call the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mvim &quot;foo bar&quot; &quot;baz&quot; &quot;and quz&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will open a vim instance with 3 buffers, each one containing one string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If no argument is provided a regular vim instance will be started. If one argument is an empty string, an empty buffer will be created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; I realized that for a reason that I don't understand an empty line is created at the beginning of each buffer so I added the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CMD=$CMD&quot;-c \&quot;bufdo 1d\&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get rid of this empty line in all buffers.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-08-30T21:33:54.400" LastActivityDate="2015-08-30T21:33:54.400" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4588" PostTypeId="2" ParentId="3730" CreationDate="2015-08-30T20:14:32.677" Score="2" Body="&lt;p&gt;First mistake I see time and again in relation to Windows is always attempting to solve the problem by using &lt;code&gt;$HOME&lt;/code&gt;, don't. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;$HOME&lt;/code&gt; will eventually cause problems, especially if you use any Unix-like environments (Cygwin, git bash, etc.). Don't use it in scripts, don't set it as an environment variable. In fact, setting &lt;code&gt;$HOME&lt;/code&gt; will cause Cygwin to stop working correctly, and git bash to do similar. The more you play with &lt;code&gt;$HOME&lt;/code&gt; the worse the bugs get, and tracing them down gets harder. Just don't use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Windows builds the &lt;code&gt;$HOME&lt;/code&gt; on the fly and behind the scenes with &lt;code&gt;%HOMEDRIVE%%HOMEPATH%&lt;/code&gt;. Simply use this inside your &lt;code&gt;_vimrc&lt;/code&gt; or &lt;code&gt;vimrc&lt;/code&gt; (without dot):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viminfo+=n%HOMEDRIVE%/%HOMEPATH%/vimfiles/viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should solve the problem. If you changed &lt;code&gt;vimfiles&lt;/code&gt; to &lt;code&gt;.vim&lt;/code&gt; adjust accordingly.&lt;/p&gt;&#xA;" OwnerUserId="3360" LastEditorUserId="3360" LastEditDate="2015-09-01T16:35:16.773" LastActivityDate="2015-09-01T16:35:16.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4590" PostTypeId="1" AcceptedAnswerId="4592" CreationDate="2015-08-31T01:04:20.523" Score="10" ViewCount="1754" Body="&lt;p&gt;I'd like to insert a word in multiple lines, is there any command like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[2,3,5,7,11]s/^/word\ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which would insert &lt;code&gt;word&lt;/code&gt; at the beginning of line 2, line 3, line 5, line 7 and line 11?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, multiple lines are not contiguous.&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="1841" LastEditDate="2015-08-31T03:12:37.160" LastActivityDate="2015-08-31T23:39:10.463" Title="How to substitute in multiple lines?" Tags="|command-line|search|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4592" PostTypeId="2" ParentId="4590" CreationDate="2015-08-31T05:46:17.690" Score="16" Body="&lt;p&gt;Performing a substitution on several consecutive lines is pretty easy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:2,11s/^/word /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but a range can't cover non-consecutive lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a bit of creativity, though, it is entirely possible to work around that &quot;limitation&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, you can repeat the last substitution with &lt;code&gt;:&amp;amp;&lt;/code&gt; or &lt;code&gt;:&amp;amp;&amp;amp;&lt;/code&gt; (the former will not preserve the original flags, the latter will) so you can chain substitutions pretty easily:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2s/^/word /|3&amp;amp;|5&amp;amp;|7&amp;amp;|11&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :&amp;amp;&lt;/code&gt; and scroll around for &lt;code&gt;:&amp;amp;&amp;amp;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-08-31T19:09:29.167" LastActivityDate="2015-08-31T19:09:29.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4593" PostTypeId="1" CreationDate="2015-08-31T14:46:53.997" Score="4" ViewCount="452" Body="&lt;p&gt;When scrolling with the mouse wheel, characters will often duplicate themselves on subsequent lines. For instance, if I'm scrolling down, I can sometimes see an open brace on its line and on the following line. I can clean this up each time with Ctrl+L, but how can I prevent it from occurring at all?&lt;/p&gt;&#xA;" OwnerUserId="3369" LastEditorUserId="21062" LastEditDate="2019-08-08T15:38:35.927" LastActivityDate="2019-08-08T15:38:35.927" Title="Stray characters when scrolling in gvim" Tags="|gvim|scrolling|mouse|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4595" PostTypeId="1" AcceptedAnswerId="4596" CreationDate="2015-09-01T00:20:34.673" Score="4" ViewCount="310" Body="&lt;p&gt;Not sure I said it right, it's kinda hard to explain with words, so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2yPrx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2yPrx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if syntax highlighting trying to be helpful here or what, it's definitely annoying and distracting. I simply don't want the rest of the code to be highlighting in the string color while I'm typing a string in a certain line. Some other editors/IDEs only let the current line be affected as opposed to everything that's after the first &lt;code&gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been staring at the syntax file for a while now trying to figure out what match/region/hi is responsible for this, disabling things here and there but no luck, here's the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Vim syntax file&#xA;&quot; Language: C&#xA;&quot; Maintainer:   Bram Moolenaar &amp;lt;Bram@vim.org&amp;gt;&#xA;&quot; Last Change:  2013 Jul 05&#xA;&#xA;&quot; Quit when a (custom) syntax file was already loaded&#xA;if exists(&quot;b:current_syntax&quot;)&#xA;  finish&#xA;endif&#xA;&#xA;let s:cpo_save = &amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;&#xA;let s:ft = matchstr(&amp;amp;ft, '^\([^.]\)\+')&#xA;&#xA;&quot; A bunch of useful C keywords&#xA;syn keyword cStatement  goto break return continue asm&#xA;syn keyword cLabel      case default&#xA;syn keyword cConditional    if else switch&#xA;syn keyword cRepeat     while for do&#xA;&#xA;syn keyword cTodo       contained TODO FIXME XXX&#xA;&#xA;&quot; It's easy to accidentally add a space after a backslash that was intended&#xA;&quot; for line continuation.  Some compilers allow it, which makes it&#xA;&quot; unpredictable and should be avoided.&#xA;syn match   cBadContinuation contained &quot;\\\s\+$&quot;&#xA;&#xA;&quot; cCommentGroup allows adding matches for special things in comments&#xA;syn cluster cCommentGroup   contains=cTodo,cBadContinuation&#xA;&#xA;&quot; String and Character constants&#xA;&quot; Highlight special characters (those which have a backslash) differently&#xA;syn match   cSpecial    display contained &quot;\\\(x\x\+\|\o\{1,3}\|.\|$\)&quot;&#xA;if !exists(&quot;c_no_utf&quot;)&#xA;  syn match cSpecial    display contained &quot;\\\(u\x\{4}\|U\x\{8}\)&quot;&#xA;endif&#xA;if exists(&quot;c_no_cformat&quot;)&#xA;  syn region    cString     start=+L\=&quot;+ skip=+\\\\\|\\&quot;+ end=+&quot;+ contains=cSpecial,@Spell extend&#xA;  &quot; cCppString: same as cString, but ends at end of line&#xA;  if !exists(&quot;cpp_no_cpp11&quot;) &quot; ISO C++11&#xA;    syn region cCppString   start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\=&quot;+ skip=+\\\\\|\\&quot;\|\\$+ excludenl end=+&quot;+ end='$' contains=cSpecial,@Spell&#xA;  else&#xA;    syn region cCppString   start=+L\=&quot;+ skip=+\\\\\|\\&quot;\|\\$+ excludenl end=+&quot;+ end='$' contains=cSpecial,@Spell&#xA;  endif&#xA;  syn region    cCppOut2    contained start=&quot;0&quot; end=&quot;^\s*\(%:\|#\)\s*\(endif\&amp;gt;\|else\&amp;gt;\|elif\&amp;gt;\)&quot; contains=cSpaceError,cCppSkip&#xA;  syn region    cCppSkip    contained start=&quot;^\s*\(%:\|#\)\s*\(if\&amp;gt;\|ifdef\&amp;gt;\|ifndef\&amp;gt;\)&quot; skip=&quot;\\$&quot; end=&quot;^\s*\(%:\|#\)\s*endif\&amp;gt;&quot; contains=cSpaceError,cCppSkip&#xA;else&#xA;  if !exists(&quot;c_no_c99&quot;) &quot; ISO C99&#xA;    &quot;syn match  cFormat     display &quot;%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)&quot; contained&#xA;  else&#xA;    &quot;syn match  cFormat     display &quot;%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)&quot; contained&#xA;  endif&#xA;  &quot;syn match    cFormat     display &quot;%%&quot; contained&#xA;  syn region    cString     start=+L\=&quot;+ skip=+\\\\\|\\&quot;+ end=+&quot;+ contains=cSpecial,cFormat,@Spell extend&#xA;  &quot; cCppString: same as cString, but ends at end of line&#xA;  syn region    cCppString  start=+L\=&quot;+ skip=+\\\\\|\\&quot;\|\\$+ excludenl end=+&quot;+ end='$' contains=cSpecial,@Spell&#xA;endif&#xA;&#xA;syn match   cCharacter  &quot;L\='[^\\]'&quot;&#xA;syn match   cCharacter  &quot;L'[^']*'&quot; contains=cSpecial&#xA;if exists(&quot;c_gnu&quot;)&#xA;  syn match cSpecialError   &quot;L\='\\[^'\&quot;?\\abefnrtv]'&quot;&#xA;  syn match cSpecialCharacter &quot;L\='\\['\&quot;?\\abefnrtv]'&quot;&#xA;else&#xA;  syn match cSpecialError   &quot;L\='\\[^'\&quot;?\\abfnrtv]'&quot;&#xA;  syn match cSpecialCharacter &quot;L\='\\['\&quot;?\\abfnrtv]'&quot;&#xA;endif&#xA;syn match   cSpecialCharacter display &quot;L\='\\\o\{1,3}'&quot;&#xA;syn match   cSpecialCharacter display &quot;'\\x\x\{1,2}'&quot;&#xA;syn match   cSpecialCharacter display &quot;L'\\x\x\+'&quot;&#xA;&#xA;if !exists(&quot;c_no_c11&quot;) &quot; ISO C11&#xA;  if exists(&quot;c_no_cformat&quot;)&#xA;    syn region  cString     start=+\%(U\|u8\=\)&quot;+ skip=+\\\\\|\\&quot;+ end=+&quot;+ contains=cSpecial,@Spell extend&#xA;  else&#xA;    syn region  cString     start=+\%(U\|u8\=\)&quot;+ skip=+\\\\\|\\&quot;+ end=+&quot;+ contains=cSpecial,@Spell extend&#xA;  endif&#xA;  syn match cCharacter  &quot;[Uu]'[^\\]'&quot;&#xA;  syn match cCharacter  &quot;[Uu]'[^']*'&quot; contains=cSpecial&#xA;  if exists(&quot;c_gnu&quot;)&#xA;    syn match   cSpecialError   &quot;[Uu]'\\[^'\&quot;?\\abefnrtv]'&quot;&#xA;    syn match   cSpecialCharacter &quot;[Uu]'\\['\&quot;?\\abefnrtv]'&quot;&#xA;  else&#xA;    syn match   cSpecialError   &quot;[Uu]'\\[^'\&quot;?\\abfnrtv]'&quot;&#xA;    syn match   cSpecialCharacter &quot;[Uu]'\\['\&quot;?\\abfnrtv]'&quot;&#xA;  endif&#xA;  syn match cSpecialCharacter display &quot;[Uu]'\\\o\{1,3}'&quot;&#xA;  syn match cSpecialCharacter display &quot;[Uu]'\\x\x\+'&quot;&#xA;endif&#xA;&#xA;&quot;when wanted, highlight trailing white space&#xA;if exists(&quot;c_space_errors&quot;)&#xA;  if !exists(&quot;c_no_trail_space_error&quot;)&#xA;    syn match   cSpaceError display excludenl &quot;\s\+$&quot;&#xA;  endif&#xA;  if !exists(&quot;c_no_tab_space_error&quot;)&#xA;    syn match   cSpaceError display &quot; \+\t&quot;me=e-1&#xA;  endif&#xA;endif&#xA;&#xA;&quot; This should be before cErrInParen to avoid problems with #define ({ xxx })&#xA;if exists(&quot;c_curly_error&quot;)&#xA;  syn match cCurlyError &quot;}&quot;&#xA;  syn region    cBlock      start=&quot;{&quot; end=&quot;}&quot; contains=ALLBUT,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString,@Spell fold&#xA;else&#xA;  syn region    cBlock      start=&quot;{&quot; end=&quot;}&quot; transparent fold&#xA;endif&#xA;&#xA;&quot;catch errors caused by wrong parenthesis and brackets&#xA;&quot; also accept &amp;lt;% for {, %&amp;gt; for }, &amp;lt;: for [ and :&amp;gt; for ] (C99)&#xA;&quot; But avoid matching &amp;lt;::.&#xA;syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cNumber,cFloat,cOctal,cOctalError,cNumbersCom&#xA;if exists(&quot;c_no_curly_error&quot;)&#xA;  if s:ft ==# 'cpp' &amp;amp;&amp;amp; !exists(&quot;cpp_no_cpp11&quot;)&#xA;    syn region  cParen      transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell&#xA;    &quot; cCppParen: same as cParen but ends at end-of-line; used in cDefine&#xA;    syn region  cCppParen   transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell&#xA;    syn match   cParenError display &quot;)&quot;&#xA;    syn match   cErrInParen display contained &quot;^^&amp;lt;%\|^%&amp;gt;&quot;&#xA;  else&#xA;    syn region  cParen      transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppString,@Spell&#xA;    &quot; cCppParen: same as cParen but ends at end-of-line; used in cDefine&#xA;    syn region  cCppParen   transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell&#xA;    syn match   cParenError display &quot;)&quot;&#xA;    syn match   cErrInParen display contained &quot;^[{}]\|^&amp;lt;%\|^%&amp;gt;&quot;&#xA;  endif&#xA;elseif exists(&quot;c_no_bracket_error&quot;)&#xA;  if s:ft ==# 'cpp' &amp;amp;&amp;amp; !exists(&quot;cpp_no_cpp11&quot;)&#xA;    syn region  cParen      transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell&#xA;    &quot; cCppParen: same as cParen but ends at end-of-line; used in cDefine&#xA;    syn region  cCppParen   transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell&#xA;    syn match   cParenError display &quot;)&quot;&#xA;    syn match   cErrInParen display contained &quot;&amp;lt;%\|%&amp;gt;&quot;&#xA;  else&#xA;    syn region  cParen      transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppString,@Spell&#xA;    &quot; cCppParen: same as cParen but ends at end-of-line; used in cDefine&#xA;    syn region  cCppParen   transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell&#xA;    syn match   cParenError display &quot;)&quot;&#xA;    syn match   cErrInParen display contained &quot;[{}]\|&amp;lt;%\|%&amp;gt;&quot;&#xA;  endif&#xA;else&#xA;  if s:ft ==# 'cpp' &amp;amp;&amp;amp; !exists(&quot;cpp_no_cpp11&quot;)&#xA;    syn region  cParen      transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppBracket,cCppString,@Spell&#xA;    &quot; cCppParen: same as cParen but ends at end-of-line; used in cDefine&#xA;    syn region  cCppParen   transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cBracket,cString,@Spell&#xA;    syn match   cParenError display &quot;[\])]&quot;&#xA;    syn match   cErrInParen display contained &quot;&amp;lt;%\|%&amp;gt;&quot;&#xA;    syn region  cBracket    transparent start='\[\|&amp;lt;::\@!' end=']\|:&amp;gt;' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString,@Spell&#xA;  else&#xA;    syn region  cParen      transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppBracket,cCppString,@Spell&#xA;    &quot; cCppParen: same as cParen but ends at end-of-line; used in cDefine&#xA;    syn region  cCppParen   transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cBracket,cString,@Spell&#xA;    syn match   cParenError display &quot;[\])]&quot;&#xA;    syn match   cErrInParen display contained &quot;[\]{}]\|&amp;lt;%\|%&amp;gt;&quot;&#xA;    syn region  cBracket    transparent start='\[\|&amp;lt;::\@!' end=']\|:&amp;gt;' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString,@Spell&#xA;  endif&#xA;  &quot; cCppBracket: same as cParen but ends at end-of-line; used in cDefine&#xA;  syn region    cCppBracket transparent start='\[\|&amp;lt;::\@!' skip='\\$' excludenl end=']\|:&amp;gt;' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell&#xA;endif&#xA;&#xA;&quot;integer number, or floating point number without a dot and with &quot;f&quot;.&#xA;syn case ignore&#xA;syn match   cNumbers    display transparent &quot;\&amp;lt;\d\|\.\d&quot; contains=cNumber,cFloat,cOctalError,cOctal&#xA;&quot; Same, but without octal error (for comments)&#xA;syn match   cNumbersCom display contained transparent &quot;\&amp;lt;\d\|\.\d&quot; contains=cNumber,cFloat,cOctal&#xA;syn match   cNumber     display contained &quot;\d\+\(u\=l\{0,2}\|ll\=u\)\&amp;gt;&quot;&#xA;&quot;hex number&#xA;syn match   cNumber     display contained &quot;0x\x\+\(u\=l\{0,2}\|ll\=u\)\&amp;gt;&quot;&#xA;&quot; Flag the first zero of an octal number as something special&#xA;syn match   cOctal      display contained &quot;0\o\+\(u\=l\{0,2}\|ll\=u\)\&amp;gt;&quot; contains=cOctalZero&#xA;syn match   cOctalZero  display contained &quot;\&amp;lt;0&quot;&#xA;syn match   cFloat      display contained &quot;\d\+f&quot;&#xA;&quot;floating point number, with dot, optional exponent&#xA;syn match   cFloat      display contained &quot;\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=&quot;&#xA;&quot;floating point number, starting with a dot, optional exponent&#xA;syn match   cFloat      display contained &quot;\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\&amp;gt;&quot;&#xA;&quot;floating point number, without dot, with exponent&#xA;syn match   cFloat      display contained &quot;\d\+e[-+]\=\d\+[fl]\=\&amp;gt;&quot;&#xA;if !exists(&quot;c_no_c99&quot;)&#xA;  &quot;hexadecimal floating point number, optional leading digits, with dot, with exponent&#xA;  syn match cFloat      display contained &quot;0x\x*\.\x\+p[-+]\=\d\+[fl]\=\&amp;gt;&quot;&#xA;  &quot;hexadecimal floating point number, with leading digits, optional dot, with exponent&#xA;  syn match cFloat      display contained &quot;0x\x\+\.\=p[-+]\=\d\+[fl]\=\&amp;gt;&quot;&#xA;endif&#xA;&#xA;&quot; flag an octal number with wrong digits&#xA;syn match   cOctalError display contained &quot;0\o*[89]\d*&quot;&#xA;syn case match&#xA;&#xA;if exists(&quot;c_comment_strings&quot;)&#xA;  &quot; A comment can contain cString, cCharacter and cNumber.&#xA;  &quot; But a &quot;*/&quot; inside a cString in a cComment DOES end the comment!  So we&#xA;  &quot; need to use a special type of cString: cCommentString, which also ends on&#xA;  &quot; &quot;*/&quot;, and sees a &quot;*&quot; at the start of the line as comment again.&#xA;  &quot; Unfortunately this doesn't very well work for // type of comments :-(&#xA;  syn match cCommentSkip    contained &quot;^\s*\*\($\|\s\+\)&quot;&#xA;  syn region cCommentString contained start=+L\=\\\@&amp;lt;!&quot;+ skip=+\\\\\|\\&quot;+ end=+&quot;+ end=+\*/+me=s-1 contains=cSpecial,cCommentSkip&#xA;  syn region cComment2String    contained start=+L\=\\\@&amp;lt;!&quot;+ skip=+\\\\\|\\&quot;+ end=+&quot;+ end=&quot;$&quot; contains=cSpecial&#xA;  syn region  cCommentL start=&quot;//&quot; skip=&quot;\\$&quot; end=&quot;$&quot; keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError,@Spell&#xA;  if exists(&quot;c_no_comment_fold&quot;)&#xA;    &quot; Use &quot;extend&quot; here to have preprocessor lines not terminate halfway a&#xA;    &quot; comment.&#xA;    syn region cComment matchgroup=cCommentStart start=&quot;/\*&quot; end=&quot;\*/&quot; contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell extend&#xA;  else&#xA;    syn region cComment matchgroup=cCommentStart start=&quot;/\*&quot; end=&quot;\*/&quot; contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell fold extend&#xA;  endif&#xA;else&#xA;  syn region    cCommentL   start=&quot;//&quot; skip=&quot;\\$&quot; end=&quot;$&quot; keepend contains=@cCommentGroup,cSpaceError,@Spell&#xA;  if exists(&quot;c_no_comment_fold&quot;)&#xA;    syn region  cComment    matchgroup=cCommentStart start=&quot;/\*&quot; end=&quot;\*/&quot; contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell extend&#xA;  else&#xA;    syn region  cComment    matchgroup=cCommentStart start=&quot;/\*&quot; end=&quot;\*/&quot; contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell fold extend&#xA;  endif&#xA;endif&#xA;&quot; keep a // comment separately, it terminates a preproc. conditional&#xA;syn match   cCommentError   display &quot;\*/&quot;&#xA;syn match   cCommentStartError display &quot;/\*&quot;me=e-1 contained&#xA;&#xA;syn keyword cOperator   sizeof&#xA;if exists(&quot;c_gnu&quot;)&#xA;  syn keyword   cStatement  __asm__&#xA;  syn keyword   cOperator   typeof __real__ __imag__&#xA;endif&#xA;syn keyword cType       int long short char void&#xA;syn keyword cType       signed unsigned float double&#xA;if !exists(&quot;c_no_ansi&quot;) || exists(&quot;c_ansi_typedefs&quot;)&#xA;  syn keyword   cType       size_t ssize_t off_t wchar_t ptrdiff_t sig_atomic_t fpos_t&#xA;  syn keyword   cType       clock_t time_t va_list jmp_buf FILE DIR div_t ldiv_t&#xA;  syn keyword   cType       mbstate_t wctrans_t wint_t wctype_t&#xA;endif&#xA;if !exists(&quot;c_no_c99&quot;) &quot; ISO C99&#xA;  syn keyword   cType       _Bool bool _Complex complex _Imaginary imaginary&#xA;  syn keyword   cType       int8_t int16_t int32_t int64_t&#xA;  syn keyword   cType       uint8_t uint16_t uint32_t uint64_t&#xA;  syn keyword   cType       int_least8_t int_least16_t int_least32_t int_least64_t&#xA;  syn keyword   cType       uint_least8_t uint_least16_t uint_least32_t uint_least64_t&#xA;  syn keyword   cType       int_fast8_t int_fast16_t int_fast32_t int_fast64_t&#xA;  syn keyword   cType       uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t&#xA;  syn keyword   cType       intptr_t uintptr_t&#xA;  syn keyword   cType       intmax_t uintmax_t&#xA;endif&#xA;if exists(&quot;c_gnu&quot;)&#xA;  syn keyword   cType       __label__ __complex__ __volatile__&#xA;endif&#xA;&#xA;syn keyword cStructure  struct union enum typedef&#xA;syn keyword cStorageClass   static register auto volatile extern const&#xA;if exists(&quot;c_gnu&quot;)&#xA;  syn keyword   cStorageClass   inline __attribute__&#xA;endif&#xA;if !exists(&quot;c_no_c99&quot;)&#xA;  syn keyword   cStorageClass   inline restrict&#xA;endif&#xA;if !exists(&quot;c_no_c11&quot;)&#xA;  syn keyword   cStorageClass   _Alignas alignas&#xA;  syn keyword   cOperator   _Alignof alignof&#xA;  syn keyword   cStorageClass   _Atomic&#xA;  syn keyword   cOperator   _Generic&#xA;  syn keyword   cStorageClass   _Noreturn noreturn&#xA;  syn keyword   cOperator   _Static_assert static_assert&#xA;  syn keyword   cStorageClass   _Thread_local thread_local&#xA;  syn keyword   cType       char16_t char32_t&#xA;endif&#xA;&#xA;if !exists(&quot;c_no_ansi&quot;) || exists(&quot;c_ansi_constants&quot;) || exists(&quot;c_gnu&quot;)&#xA;  if exists(&quot;c_gnu&quot;)&#xA;    syn keyword cConstant __GNUC__ __FUNCTION__ __PRETTY_FUNCTION__ __func__&#xA;  endif&#xA;  syn keyword cConstant __LINE__ __FILE__ __DATE__ __TIME__ __STDC__&#xA;  syn keyword cConstant __STDC_VERSION__&#xA;  syn keyword cConstant CHAR_BIT MB_LEN_MAX MB_CUR_MAX&#xA;  syn keyword cConstant UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX&#xA;  syn keyword cConstant CHAR_MIN INT_MIN LONG_MIN SHRT_MIN&#xA;  syn keyword cConstant CHAR_MAX INT_MAX LONG_MAX SHRT_MAX&#xA;  syn keyword cConstant SCHAR_MIN SINT_MIN SLONG_MIN SSHRT_MIN&#xA;  syn keyword cConstant SCHAR_MAX SINT_MAX SLONG_MAX SSHRT_MAX&#xA;  if !exists(&quot;c_no_c99&quot;)&#xA;    syn keyword cConstant __func__&#xA;    syn keyword cConstant LLONG_MIN LLONG_MAX ULLONG_MAX&#xA;    syn keyword cConstant INT8_MIN INT16_MIN INT32_MIN INT64_MIN&#xA;    syn keyword cConstant INT8_MAX INT16_MAX INT32_MAX INT64_MAX&#xA;    syn keyword cConstant UINT8_MAX UINT16_MAX UINT32_MAX UINT64_MAX&#xA;    syn keyword cConstant INT_LEAST8_MIN INT_LEAST16_MIN INT_LEAST32_MIN INT_LEAST64_MIN&#xA;    syn keyword cConstant INT_LEAST8_MAX INT_LEAST16_MAX INT_LEAST32_MAX INT_LEAST64_MAX&#xA;    syn keyword cConstant UINT_LEAST8_MAX UINT_LEAST16_MAX UINT_LEAST32_MAX UINT_LEAST64_MAX&#xA;    syn keyword cConstant INT_FAST8_MIN INT_FAST16_MIN INT_FAST32_MIN INT_FAST64_MIN&#xA;    syn keyword cConstant INT_FAST8_MAX INT_FAST16_MAX INT_FAST32_MAX INT_FAST64_MAX&#xA;    syn keyword cConstant UINT_FAST8_MAX UINT_FAST16_MAX UINT_FAST32_MAX UINT_FAST64_MAX&#xA;    syn keyword cConstant INTPTR_MIN INTPTR_MAX UINTPTR_MAX&#xA;    syn keyword cConstant INTMAX_MIN INTMAX_MAX UINTMAX_MAX&#xA;    syn keyword cConstant PTRDIFF_MIN PTRDIFF_MAX SIG_ATOMIC_MIN SIG_ATOMIC_MAX&#xA;    syn keyword cConstant SIZE_MAX WCHAR_MIN WCHAR_MAX WINT_MIN WINT_MAX&#xA;  endif&#xA;  syn keyword cConstant FLT_RADIX FLT_ROUNDS&#xA;  syn keyword cConstant FLT_DIG FLT_MANT_DIG FLT_EPSILON&#xA;  syn keyword cConstant DBL_DIG DBL_MANT_DIG DBL_EPSILON&#xA;  syn keyword cConstant LDBL_DIG LDBL_MANT_DIG LDBL_EPSILON&#xA;  syn keyword cConstant FLT_MIN FLT_MAX FLT_MIN_EXP FLT_MAX_EXP&#xA;  syn keyword cConstant FLT_MIN_10_EXP FLT_MAX_10_EXP&#xA;  syn keyword cConstant DBL_MIN DBL_MAX DBL_MIN_EXP DBL_MAX_EXP&#xA;  syn keyword cConstant DBL_MIN_10_EXP DBL_MAX_10_EXP&#xA;  syn keyword cConstant LDBL_MIN LDBL_MAX LDBL_MIN_EXP LDBL_MAX_EXP&#xA;  syn keyword cConstant LDBL_MIN_10_EXP LDBL_MAX_10_EXP&#xA;  syn keyword cConstant HUGE_VAL CLOCKS_PER_SEC NULL&#xA;  syn keyword cConstant LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY&#xA;  syn keyword cConstant LC_NUMERIC LC_TIME&#xA;  syn keyword cConstant SIG_DFL SIG_ERR SIG_IGN&#xA;  syn keyword cConstant SIGABRT SIGFPE SIGILL SIGHUP SIGINT SIGSEGV SIGTERM&#xA;  &quot; Add POSIX signals as well...&#xA;  syn keyword cConstant SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP&#xA;  syn keyword cConstant SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV&#xA;  syn keyword cConstant SIGSTOP SIGTERM SIGTRAP SIGTSTP SIGTTIN SIGTTOU&#xA;  syn keyword cConstant SIGUSR1 SIGUSR2&#xA;  syn keyword cConstant _IOFBF _IOLBF _IONBF BUFSIZ EOF WEOF&#xA;  syn keyword cConstant FOPEN_MAX FILENAME_MAX L_tmpnam&#xA;  syn keyword cConstant SEEK_CUR SEEK_END SEEK_SET&#xA;  syn keyword cConstant TMP_MAX stderr stdin stdout&#xA;  syn keyword cConstant EXIT_FAILURE EXIT_SUCCESS RAND_MAX&#xA;  &quot; Add POSIX errors as well&#xA;  syn keyword cConstant E2BIG EACCES EAGAIN EBADF EBADMSG EBUSY&#xA;  syn keyword cConstant ECANCELED ECHILD EDEADLK EDOM EEXIST EFAULT&#xA;  syn keyword cConstant EFBIG EILSEQ EINPROGRESS EINTR EINVAL EIO EISDIR&#xA;  syn keyword cConstant EMFILE EMLINK EMSGSIZE ENAMETOOLONG ENFILE ENODEV&#xA;  syn keyword cConstant ENOENT ENOEXEC ENOLCK ENOMEM ENOSPC ENOSYS&#xA;  syn keyword cConstant ENOTDIR ENOTEMPTY ENOTSUP ENOTTY ENXIO EPERM&#xA;  syn keyword cConstant EPIPE ERANGE EROFS ESPIPE ESRCH ETIMEDOUT EXDEV&#xA;  &quot; math.h&#xA;  syn keyword cConstant M_E M_LOG2E M_LOG10E M_LN2 M_LN10 M_PI M_PI_2 M_PI_4&#xA;  syn keyword cConstant M_1_PI M_2_PI M_2_SQRTPI M_SQRT2 M_SQRT1_2&#xA;endif&#xA;if !exists(&quot;c_no_c99&quot;) &quot; ISO C99&#xA;  syn keyword cConstant true false&#xA;endif&#xA;&#xA;&quot; Accept %: for # (C99)&#xA;syn region  cPreCondit  start=&quot;^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\&amp;gt;&quot; skip=&quot;\\$&quot; end=&quot;$&quot; keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError&#xA;syn match   cPreConditMatch display &quot;^\s*\(%:\|#\)\s*\(else\|endif\)\&amp;gt;&quot;&#xA;if !exists(&quot;c_no_if0&quot;)&#xA;  syn cluster   cCppOutInGroup  contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip&#xA;  syn region    cCppOutWrapper  start=&quot;^\s*\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&amp;amp;\)&quot; end=&quot;.\@=\|$&quot; contains=cCppOutIf,cCppOutElse,@NoSpell fold&#xA;  syn region    cCppOutIf   contained start=&quot;0\+&quot; matchgroup=cCppOutWrapper end=&quot;^\s*\(%:\|#\)\s*endif\&amp;gt;&quot; contains=cCppOutIf2,cCppOutElse&#xA;  if !exists(&quot;c_no_if0_fold&quot;)&#xA;    syn region  cCppOutIf2  contained matchgroup=cCppOutWrapper start=&quot;0\+&quot; end=&quot;^\s*\(%:\|#\)\s*\(else\&amp;gt;\|elif\s\+\(0\+\s*\($\|//\|/\*\|&amp;amp;\)\)\@!\|endif\&amp;gt;\)&quot;me=s-1 contains=cSpaceError,cCppOutSkip,@Spell fold&#xA;  else&#xA;    syn region  cCppOutIf2  contained matchgroup=cCppOutWrapper start=&quot;0\+&quot; end=&quot;^\s*\(%:\|#\)\s*\(else\&amp;gt;\|elif\s\+\(0\+\s*\($\|//\|/\*\|&amp;amp;\)\)\@!\|endif\&amp;gt;\)&quot;me=s-1 contains=cSpaceError,cCppOutSkip,@Spell&#xA;  endif&#xA;  syn region    cCppOutElse contained matchgroup=cCppOutWrapper start=&quot;^\s*\(%:\|#\)\s*\(else\|elif\)&quot; end=&quot;^\s*\(%:\|#\)\s*endif\&amp;gt;&quot;me=s-1 contains=TOP,cPreCondit&#xA;  syn region    cCppInWrapper   start=&quot;^\s*\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)&quot; end=&quot;.\@=\|$&quot; contains=cCppInIf,cCppInElse fold&#xA;  syn region    cCppInIf    contained matchgroup=cCppInWrapper start=&quot;\d\+&quot; end=&quot;^\s*\(%:\|#\)\s*endif\&amp;gt;&quot; contains=TOP,cPreCondit&#xA;  if !exists(&quot;c_no_if0_fold&quot;)&#xA;    syn region  cCppInElse  contained start=&quot;^\s*\(%:\|#\)\s*\(else\&amp;gt;\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)&quot; end=&quot;.\@=\|$&quot; containedin=cCppInIf contains=cCppInElse2 fold&#xA;  else&#xA;    syn region  cCppInElse  contained start=&quot;^\s*\(%:\|#\)\s*\(else\&amp;gt;\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)&quot; end=&quot;.\@=\|$&quot; containedin=cCppInIf contains=cCppInElse2&#xA;  endif&#xA;  syn region    cCppInElse2 contained matchgroup=cCppInWrapper start=&quot;^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*&quot; end=&quot;^\s*\(%:\|#\)\s*endif\&amp;gt;&quot;me=s-1 contains=cSpaceError,cCppOutSkip,@Spell&#xA;  syn region    cCppOutSkip contained start=&quot;^\s*\(%:\|#\)\s*\(if\&amp;gt;\|ifdef\&amp;gt;\|ifndef\&amp;gt;\)&quot; skip=&quot;\\$&quot; end=&quot;^\s*\(%:\|#\)\s*endif\&amp;gt;&quot; contains=cSpaceError,cCppOutSkip&#xA;  syn region    cCppInSkip  contained matchgroup=cCppInWrapper start=&quot;^\s*\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&amp;amp;\)\)\@!\|ifdef\&amp;gt;\|ifndef\&amp;gt;\)&quot; skip=&quot;\\$&quot; end=&quot;^\s*\(%:\|#\)\s*endif\&amp;gt;&quot; containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc&#xA;endif&#xA;&quot;syn region cIncluded   display contained start=+&quot;+ skip=+\\\\\|\\&quot;+ end=+&quot;+&#xA;&quot;syn match  cIncluded   display contained &quot;&amp;lt;[^&amp;gt;]*&amp;gt;&quot;&#xA;syn match   cInclude    display &quot;^\s*\(%:\|#\)\s*include\&amp;gt;\s*[&quot;&amp;lt;]&quot; contains=cIncluded&#xA;&quot;syn match cLineSkip    &quot;\\$&quot;&#xA;syn cluster cPreProcGroup   contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cUserLabel,cSpecial,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti&#xA;syn region  cDefine     start=&quot;^\s*\(%:\|#\)\s*\(define\|undef\)\&amp;gt;&quot; skip=&quot;\\$&quot; end=&quot;$&quot; keepend contains=ALLBUT,@cPreProcGroup,@Spell&#xA;syn region  cPreProc    start=&quot;^\s*\(%:\|#\)\s*\(pragma\&amp;gt;\|line\&amp;gt;\|warning\&amp;gt;\|warn\&amp;gt;\|error\&amp;gt;\)&quot; skip=&quot;\\$&quot; end=&quot;$&quot; keepend contains=ALLBUT,@cPreProcGroup,@Spell&#xA;&#xA;&quot; Highlight User Labels&#xA;syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString&#xA;if s:ft ==# 'c' || exists(&quot;cpp_no_cpp11&quot;)&#xA;  syn region    cMulti      transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell&#xA;endif&#xA;&quot; Avoid matching foo::bar() in C++ by requiring that the next char is not ':'&#xA;syn cluster cLabelGroup contains=cUserLabel&#xA;syn match   cUserCont   display &quot;^\s*\I\i*\s*:$&quot; contains=@cLabelGroup&#xA;syn match   cUserCont   display &quot;;\s*\I\i*\s*:$&quot; contains=@cLabelGroup&#xA;syn match   cUserCont   display &quot;^\s*\I\i*\s*:[^:]&quot;me=e-1 contains=@cLabelGroup&#xA;syn match   cUserCont   display &quot;;\s*\I\i*\s*:[^:]&quot;me=e-1 contains=@cLabelGroup&#xA;&#xA;syn match   cUserLabel  display &quot;\I\i*&quot; contained&#xA;&#xA;&quot; Avoid recognizing most bitfields as labels&#xA;syn match   cBitField   display &quot;^\s*\I\i*\s*:\s*[1-9]&quot;me=e-1 contains=cType&#xA;syn match   cBitField   display &quot;;\s*\I\i*\s*:\s*[1-9]&quot;me=e-1 contains=cType&#xA;&#xA;if exists(&quot;c_minlines&quot;)&#xA;  let b:c_minlines = c_minlines&#xA;else&#xA;  if !exists(&quot;c_no_if0&quot;)&#xA;    let b:c_minlines = 50   &quot; #if 0 constructs can be long&#xA;  else&#xA;    let b:c_minlines = 15   &quot; mostly for () constructs&#xA;  endif&#xA;endif&#xA;if exists(&quot;c_curly_error&quot;)&#xA;  syn sync fromstart&#xA;else&#xA;  exec &quot;syn sync ccomment cComment minlines=&quot; . b:c_minlines&#xA;endif&#xA;&#xA;&quot; Define the default highlighting.&#xA;&quot; Only used when an item doesn't have highlighting yet&#xA;&quot;hi def link cFormat        cSpecial&#xA;hi def link cCppString      cString&#xA;hi def link cCommentL       cComment&#xA;hi def link cCommentStart   cComment&#xA;hi def link cLabel      Label&#xA;hi def link cUserLabel      Label&#xA;hi def link cConditional    Conditional&#xA;hi def link cRepeat     Repeat&#xA;hi def link cCharacter      Character&#xA;hi def link cSpecialCharacter   cSpecial&#xA;hi def link cNumber     Number&#xA;hi def link cOctal      Number&#xA;hi def link cOctalZero      PreProc  &quot; link this to Error if you want&#xA;hi def link cFloat      Float&#xA;&quot;hi def link cOctalError        cError&#xA;&quot;hi def link cParenError        cError&#xA;&quot;hi def link cErrInParen        cError&#xA;&quot;hi def link cCommentError  cError&#xA;&quot;hi def link cCommentStartError cError&#xA;&quot;hi def link cSpaceError        cError&#xA;&quot;hi def link cSpecialError  cError&#xA;&quot;hi def link cCurlyError        cError&#xA;hi def link cOperator       Operator&#xA;hi def link cStructure      Structure&#xA;hi def link cStorageClass   StorageClass&#xA;hi def link cInclude        Include&#xA;hi def link cPreProc        PreProc&#xA;hi def link cDefine     Macro&#xA;&quot;hi def link cIncluded      cString&#xA;&quot;hi def link cError     Error&#xA;hi def link cStatement      Statement&#xA;hi def link cCppInWrapper   cCppOutWrapper&#xA;hi def link cCppOutWrapper  cPreCondit&#xA;hi def link cPreConditMatch cPreCondit&#xA;hi def link cPreCondit      PreCondit&#xA;hi def link cType       Type&#xA;hi def link cConstant       Constant&#xA;hi def link cCommentString  cString&#xA;hi def link cComment2String cString&#xA;hi def link cCommentSkip    cComment&#xA;hi def link cString     String&#xA;hi def link cComment        Comment&#xA;hi def link cSpecial        SpecialChar&#xA;hi def link cTodo       Todo&#xA;&quot;hi def link cBadContinuation   Error&#xA;hi def link cCppOutSkip     cCppOutIf2&#xA;hi def link cCppInElse2     cCppOutIf2&#xA;hi def link cCppOutIf2      cCppOut2  &quot; Old syntax group for #if 0 body&#xA;hi def link cCppOut2        cCppOut  &quot; Old syntax group for #if of #if 0&#xA;hi def link cCppOut     Comment&#xA;&#xA;let b:current_syntax = &quot;c&quot;&#xA;&#xA;unlet s:ft&#xA;&#xA;let &amp;amp;cpo = s:cpo_save&#xA;unlet s:cpo_save&#xA;&quot; vim: ts=8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would appreciate any help, thanks!&lt;/p&gt;&#xA;" OwnerUserId="3023" LastActivityDate="2015-09-01T12:22:30.193" Title="Prevent C incomplete string matching from highlighting the rest of the code with the string color?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4596" PostTypeId="2" ParentId="4595" CreationDate="2015-09-01T12:22:30.193" Score="2" Body="&lt;p&gt;I used the string match in &lt;code&gt;cs.vim&lt;/code&gt; (C# syntax) file, couldn't be simpler!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;start=+&quot;+  end=+&quot;+ end=+$+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replaced all the &lt;code&gt;cString&lt;/code&gt; matches in my &lt;code&gt;c.vim&lt;/code&gt; with it.&lt;/p&gt;&#xA;" OwnerUserId="3023" LastActivityDate="2015-09-01T12:22:30.193" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4597" PostTypeId="1" AcceptedAnswerId="4598" CreationDate="2015-09-01T19:01:39.957" Score="5" ViewCount="402" Body="&lt;p&gt;There is an emacs plugin called &lt;a href=&quot;https://github.com/dimitri/switch-window&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;switch-window&lt;/code&gt;&lt;/a&gt; which indexes all open windows and allows the user to switch a window based on it's number. This is really convenient when you have a large number of windows open. Does anyone know if there's something similar for vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5SEzw.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5SEzw.png&quot; alt=&quot;screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2897" LastActivityDate="2015-09-01T19:34:13.483" Title="Emacs switch-window for vim" Tags="|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4598" PostTypeId="2" ParentId="4597" CreationDate="2015-09-01T19:34:13.483" Score="9" Body="&lt;p&gt;Oh yes, there sure is: &lt;a href=&quot;https://github.com/t9md/vim-choosewin&quot; rel=&quot;noreferrer&quot;&gt;vim-choosewin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The animated demo from plugin's page:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hGMVy.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hGMVy.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-09-01T19:34:13.483" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4600" PostTypeId="1" AcceptedAnswerId="4605" CreationDate="2015-09-02T00:44:37.213" Score="17" ViewCount="30907" Body="&lt;p&gt;I'm using Linux system. Two vims are opened in two terminals. Now I'd like to copy text from A to B. One way to do so is to select text in A, use mouse to copy, then switch to B, in the insert mode, command &lt;code&gt;&amp;lt;c-r&amp;gt;+&lt;/code&gt; will paste the text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway to perform it without using mouse? like &lt;code&gt;&quot;+yy&lt;/code&gt; in A, when switch to B, &lt;code&gt;o&amp;lt;c-r&amp;gt;+&lt;/code&gt;? I explored couple of combinations in vain. And I searched for &quot;copy across terminals&quot;, but find nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;user @statox suggests one solution using visual mode, i.e. &lt;code&gt;v$&quot;+y&lt;/code&gt; in A, when switch to B, &lt;code&gt;o&amp;lt;c-r&amp;gt;+&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any simple way that can copy the text in A without entering into v mode? Admittedly entering into v-mode does not involve too many key strikes, just wonder if there is better way. Eg. if the cursor is at the middle of a line, &lt;code&gt;yy&lt;/code&gt; copies the whole line (to register &lt;code&gt;&quot;&lt;/code&gt;), while &lt;code&gt;0v$y&lt;/code&gt; does the same thing with extra key stroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, my question can be reduced to if there is any way with fewer key strokes than &lt;code&gt;0v$&quot;+y&lt;/code&gt; for &lt;strong&gt;copy&lt;/strong&gt; such that I can use &lt;code&gt;&amp;lt;alt-tab&amp;gt;o&amp;lt;c-r&amp;gt;+&lt;/code&gt; to paste.&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="1080" LastEditDate="2015-09-02T01:49:29.430" LastActivityDate="2023-03-04T08:14:48.007" Title="How to copy across terminals?" Tags="|cut-copy-paste|register|linux|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4602" PostTypeId="1" AcceptedAnswerId="4603" CreationDate="2015-09-02T06:09:24.957" Score="1" ViewCount="821" Body="&lt;p&gt;I'm writing a function to automate a repetitive task. Copied from a macro so still not elegant while I get it to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I want to fold a xml file my way to make visual comparison easier for files that may differ in size by 10,0000 plus lines due to differences in what the xml production program  is querying&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two types of file &lt;code&gt;M&lt;/code&gt; and &lt;code&gt;U&lt;/code&gt;. All works as expected except for the put command &lt;code&gt;:put =foldbegin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FoldXml(mcr)&#xA;&#xA;   echom a:mcr&#xA;   if ( a:mcr == 'M' )&#xA;     let taglist = ['getContractDetailsResponse', 'contractDetailsResponse', 'contractInfo']&#xA;     set wrapscan&#xA;   else&#xA;     let taglist=['product', 'status', 'company', 'region']&#xA;     set wrapscan&#xA;   endif&#xA;     &quot;Tags to process&#xA; &quot;    let tot=len(taglist) &#xA;     let tot=1&#xA;     &quot;Where we start&#xA;     let start=0&#xA;     &quot;Fold stuff&#xA;     let BeginStart='&quot;=== BEGIN '&#xA;     let BeginEnd=' ==={{{'&#xA;     let EndStart='&quot;=== END '&#xA;     let EndEnd=' ===}}}'&#xA;     norm! gg&#xA;     while start &amp;lt; tot &#xA;       &quot;beginning. Not needed but hey :)&#xA;         norm! gg&#xA;         &quot;WHat number we up to&#xA;         let s1=expand(start)&#xA;         &quot;Set up some stuff&#xA;         &quot;Begin search&#xA;         &quot;let findStart='&amp;lt;'.taglist[expand(start)].'&amp;gt;'&#xA;         let findStart='&amp;lt;'.taglist[s1].'&amp;gt;'&#xA;         &quot;End search&#xA;         let findEnd='&amp;lt;\/'.taglist[s1].'&amp;gt;'&#xA;         &quot;Fold stuff&#xA;         let foldbegin=BeginStart.taglist[s1].BeginEnd&#xA;         let foldend=EndStart.taglist[s1].EndEnd&#xA;         &quot;find first match for current value of taglist[start]. Will try a&#xA;         &quot;better regex solution later&#xA;         call search(findStart)&#xA;         &quot;Why need : but norm! gg doesn't ?&#xA;         :norm! k&#xA;         &quot;paste the beginning fold&#xA;         :put =foldbegin&#xA;         call search(findEnd)&#xA;         :put =foldend&#xA;         let start = start + 1&#xA;     endwhile&#xA;  endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The file looks like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;getContractDetailsResponse&amp;gt;   &#xA;  &amp;lt;contractDetailsResponse&amp;gt;&#xA;&#xA;....&#xA;&#xA;  &amp;lt;/contractDetailsResponse&amp;gt;&#xA;&amp;lt;/getContractDetailsResponse&amp;gt;&#xA;&#xA;vim:foldmethod=marker:foldclose=all:tw=88:ts=8:shiftwidth=2:noexpandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I get the &lt;code&gt;:put =foldbegin&lt;/code&gt; to open a line above rather than below as happens with &lt;code&gt;:put =foldend&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1313" LastActivityDate="2015-09-02T07:00:31.787" Title="Put variable to line above current line VIm" Tags="|vimscript|gvim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4603" PostTypeId="2" ParentId="4602" CreationDate="2015-09-02T07:00:31.787" Score="5" Body="&lt;p&gt;To &lt;code&gt;:put&lt;/code&gt; a line above the current line, add an exclamation point: &lt;code&gt;:put!&lt;/code&gt;. See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :put&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and scroll down a bit.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-09-02T07:00:31.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4604" PostTypeId="2" ParentId="4600" CreationDate="2015-09-02T07:02:42.383" Score="4" Body="&lt;p&gt;I think the solution you already mention in your question is the correct one. If you want to reduce the number of keystrokes, you can simply create a map, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;leader&amp;gt;y &quot;+y&#xA;vmap &amp;lt;leader&amp;gt;d &quot;+d&#xA;nmap &amp;lt;leader&amp;gt;p &quot;+p&#xA;nmap &amp;lt;leader&amp;gt;P &quot;+P&#xA;vmap &amp;lt;leader&amp;gt;p &quot;+p&#xA;vmap &amp;lt;leader&amp;gt;P &quot;+P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See the second entry &lt;a href=&quot;http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-09-02T07:02:42.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4605" PostTypeId="2" ParentId="4600" CreationDate="2015-09-02T07:31:37.937" Score="18" Body="&lt;p&gt;You can check if Vim is built with clipboard support with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo has('clipboard')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the output is &lt;code&gt;1&lt;/code&gt;, the following should be enough to achieve your goal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;*y    in source Vim&#xA;&quot;*p    in destination Vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can make it all a lot more seamless by synchronizing the clipboard register and the default register with this setting in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard^=unnamed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the output of &lt;code&gt;:echo has('clipboard')&lt;/code&gt; is &lt;code&gt;0&lt;/code&gt;, consider installing a proper Vim like &lt;code&gt;vim-gtk&lt;/code&gt; or &lt;code&gt;vim-gnome&lt;/code&gt; (the name of the package may differ from distro to distro).&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-02T07:31:37.937" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4606" PostTypeId="1" AcceptedAnswerId="4607" CreationDate="2015-09-02T07:42:36.990" Score="2" ViewCount="1933" Body="&lt;p&gt;I try to do a substitution from a vim script and to operate over a captured group like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let string = &quot;{b1} {b2} ({b3})&quot;&#xA;echo substitute(string, &quot;{\([^}]*\)}&quot;, &quot;a&quot;, &quot;g&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't match anything and the result doesn't change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remove the &lt;code&gt;\( \)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo substitute(string, &quot;{[^}]*}&quot;, &quot;a&quot;, &quot;g&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the whole &lt;code&gt;{b1}&lt;/code&gt; is replaced with &lt;code&gt;a&lt;/code&gt;, when I only want to replace the content of it: &lt;code&gt;{a}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have read that the pattern in the substitute command always work in &lt;code&gt;magic&lt;/code&gt; mode. And that in the magic mode, the capture group is: &lt;code&gt;\( \)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know the trick to make this work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;Thanks to Christian Brabandt I was able to make it work (see his answer below). I had to change the &lt;code&gt;\( \)&lt;/code&gt; to &lt;code&gt;\zs \ze&lt;/code&gt; also.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-09-02T07:55:14.963" LastActivityDate="2015-09-02T07:55:14.963" Title="Capture group in substitute function" Tags="|vimscript|regular-expression|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4607" PostTypeId="2" ParentId="4606" CreationDate="2015-09-02T07:52:00.847" Score="3" Body="&lt;p&gt;In double-quote strings, the backslash has a special meaning. And will probably be skipped when parsing the quoted string. The details can be seen at &lt;code&gt;:h expr-quote&lt;/code&gt;. You would have to double the slashes to make that work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, it is usually easier to read and maintain using single quoted strings. See &lt;code&gt;:h literal-string&lt;/code&gt; as there the backslash won't be skipped.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-02T07:52:00.847" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4608" PostTypeId="1" AcceptedAnswerId="4609" CreationDate="2015-09-02T08:53:34.080" Score="2" ViewCount="929" Body="&lt;p&gt;When inside a session, I often end up with multiple tabs containing multiple split buffers and multiple &quot;instances&quot; of NerdTree buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command to close all NerdTree buffers in the session ?&lt;/p&gt;&#xA;" OwnerUserId="3385" LastEditorUserId="1841" LastEditDate="2015-09-02T13:39:33.117" LastActivityDate="2015-09-02T13:39:33.117" Title="How can I close all NERTree buffers" Tags="|buffers|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4609" PostTypeId="2" ParentId="4608" CreationDate="2015-09-02T09:05:22.217" Score="3" Body="&lt;p&gt;You can do this with the &lt;code&gt;tabdo&lt;/code&gt; command: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabdo NERDTreeClose&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will execute the &lt;code&gt;NERDTreeClose&lt;/code&gt; on every tab.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-09-02T09:05:22.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4610" PostTypeId="1" AcceptedAnswerId="4611" CreationDate="2015-09-02T09:05:38.840" Score="8" ViewCount="1974" Body="&lt;p&gt;I am making a complex mapping that requires me to insert angle brackets (&lt;code&gt;&amp;lt;&lt;/code&gt;and &lt;code&gt;&amp;gt;&lt;/code&gt;) but I do not know how to escape them so Vim does not interpret them as special key-codes.&lt;/p&gt;&#xA;&lt;p&gt;It seems like escaping them are not required if you do a simple mapping like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;x yi&amp;lt;pppp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But my mapping looks more like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;x a&amp;lt;?&amp;lt;&amp;lt;cr&amp;gt;lyi&amp;lt;/&amp;lt;&amp;lt;cr&amp;gt;a/&amp;lt;c-r&amp;gt;&amp;quot;&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And I become really confused about all angle brackets. I also think that Vim might become confused.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to escape angle brackets when making mappings in Vim?&lt;/p&gt;&#xA;" OwnerUserId="3032" LastEditorUserId="23502" LastEditDate="2022-11-05T09:26:31.403" LastActivityDate="2022-11-05T09:26:31.403" Title="How to escape angle brackets in mappings (the ones that appear in &lt;esc&gt; and &lt;cr&gt;)?" Tags="|key-bindings|escape|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4611" PostTypeId="2" ParentId="4610" CreationDate="2015-09-02T09:10:38.667" Score="11" Body="&lt;p&gt;You can do so with &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt; (see &lt;code&gt;:h &amp;lt;lt&amp;gt;&lt;/code&gt;) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;x a&amp;lt;lt&amp;gt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will enter &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; literaly, whereas :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;x a&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will execute &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-09-02T09:10:38.667" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4612" PostTypeId="1" AcceptedAnswerId="4930" CreationDate="2015-09-02T13:44:10.443" Score="2" ViewCount="1135" Body="&lt;p&gt;Is there a vimscript function that wraps text in a similar manner like &lt;code&gt;gqgq&lt;/code&gt; does?&lt;/p&gt;&#xA;&lt;p&gt;For example, if I have the following string variable:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let txt = 'One foo, two bars and three bazes went up the hill'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'd like to call something like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let indent   = 4&#xA;let textwith = 12&#xA;let wrapped = wrap(txt, indent, textwidth)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After the call, the value of &lt;code&gt;wrapped&lt;/code&gt; should be&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    One foo, two&#xA;    bars and&#xA;    three bazes&#xA;    went up the&#xA;    hill&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is there something that does that?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="23502" LastEditDate="2022-11-05T09:25:55.830" LastActivityDate="2022-11-05T09:25:55.830" Title="Is there a vimscript function to wrap text?" Tags="|vimscript|wrapping|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4613" PostTypeId="1" AcceptedAnswerId="4632" CreationDate="2015-09-02T14:02:18.707" Score="17" ViewCount="2117" Body="&lt;p&gt;I just discovered that vim obviously allows division by zero:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let a=42/0&#xA;:echo a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;prints &lt;code&gt;2147483647&lt;/code&gt; (which is the value of &lt;code&gt;a&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this documented somewhere and why does vim allow division by zero?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="205" LastEditDate="2015-09-04T10:46:52.673" LastActivityDate="2015-09-06T18:32:44.140" Title="Why does vim allow integer division by zero?" Tags="|vimscript|arithmetic|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4614" PostTypeId="2" ParentId="4613" CreationDate="2015-09-02T14:07:35.807" Score="15" Body="&lt;p&gt;Here is why :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;42 / 0 tends to +infinity&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And how does Vim represent the largest number available ?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2147483647&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h limits&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, the &lt;code&gt;float2nr&lt;/code&gt; function documentation states : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When the value of {expr} is out of range for a |Number| the&#xA;result is truncated to 0x7fffffff or -0x7fffffff.  NaN results&#xA;in -0x80000000.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you have here your 2 numbers : &lt;code&gt;+ 2147483647&lt;/code&gt; and &lt;code&gt;- 2147483647&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last number &lt;code&gt;-2147483648&lt;/code&gt; is used for representing the &lt;code&gt;NaN&lt;/code&gt; value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is confirmed by the &lt;code&gt;eval&lt;/code&gt; section on it (mea culpa: &lt;a href=&quot;https://vi.stackexchange.com/a/4632/1892&quot;&gt;@cuonglm posted&lt;/a&gt; it just before me) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When dividing a Number by zero the result depends on the value:&#xA;    0 / 0  = -0x80000000    (like NaN for Float)&#xA;   &amp;gt;0 / 0  =  0x7fffffff    (like positive infinity)&#xA;   &amp;lt;0 / 0  = -0x7fffffff    (like negative infinity)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As @VanLaser stated, this only work for integer, for floating point number you have more consistency :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1/0.0     =  inf&#xA; 1/0.0 + 1 =  inf&#xA; 1/0.0 - 1 =  inf&#xA;&#xA;-1/0.0     = -inf&#xA;-1/0.0 - 1 = -inf&#xA;-1/0.0 + 1 = -inf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-09-03T10:55:46.500" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4615" PostTypeId="2" ParentId="2135" CreationDate="2015-09-02T15:25:39.173" Score="3" Body="&lt;p&gt;You can use a custom format expression/program to achieve what you want. Check out &lt;code&gt;:help 'formatexpr'&lt;/code&gt; and &lt;code&gt;:help 'formatprg'&lt;/code&gt; for info on exactly how to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that as mentioned in the comments above, there was a bug in vim where the format expression was being called on every key inserted rather than only when the text is supposed to wrap. This has been fixed in Vim 7.4.658.&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-09-02T15:25:39.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4616" PostTypeId="1" AcceptedAnswerId="4617" CreationDate="2015-09-02T16:58:32.890" Score="3" ViewCount="1030" Body="&lt;p&gt;I currently run a series of commands on any file I am working on to compress the lines. That series is -&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;G:a&#xA;PRESS ENTER KEY&#xA;.&#xA;:g/^./ .,/^$/-1 join&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I press &lt;code&gt;S-g&lt;/code&gt;, &lt;code&gt;S-:&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;enter&lt;/code&gt;, &lt;code&gt;.&lt;/code&gt;, then run that regular expression. This joins my lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CrunchLines()&#xA;exec G&#xA;exec :&#xA;exec  a&#xA;exec return&#xA;.&#xA;:g/^./ .,/^$/-1 join&#xA;endfu&#xA;com! CRUNCH call CrunchLines()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do you just run vim commands inside of a function?&lt;/p&gt;&#xA;" OwnerUserId="1417" LastEditorUserId="54" LastEditDate="2015-09-02T19:44:41.293" LastActivityDate="2015-09-02T20:29:05.797" Title="How to convert series of commands into a Vim Function?" Tags="|vimscript|vimrc|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4617" PostTypeId="2" ParentId="4616" CreationDate="2015-09-02T17:34:13.050" Score="2" Body="&lt;p&gt;If you want to run a command from a vim function you can do so with the normal command : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! dd &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This act as &lt;code&gt;dd&lt;/code&gt; in normal mode.&#xA;The &lt;code&gt;!&lt;/code&gt; prevent using user mapping, to you get the basic vim functionalities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to compress your file you can go to the last line with &lt;code&gt;G&lt;/code&gt; and then joins every lines with your expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the function could be :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Crunch() abort&#xA;  normal! G&#xA;  g/^./ .,/^$/-1 join&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use the &lt;code&gt;J&lt;/code&gt; key that joins the lines like so : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Crunch() abort&#xA;  normal! ggVGJ&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg  : go to first line&#xA;V   : start a visual line selection&#xA;G   : go to last line&#xA;J   : join the selection&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-09-02T17:42:51.717" LastActivityDate="2015-09-02T17:42:51.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4618" PostTypeId="1" AcceptedAnswerId="4620" CreationDate="2015-09-02T17:40:39.860" Score="0" ViewCount="356" Body="&lt;p&gt;I searched a little for a &lt;code&gt;global&lt;/code&gt; function that would act as the &lt;code&gt;:g&lt;/code&gt; command but in a more Function-style.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like the substitute command which has a function associated :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h substitute()&#xA;:h :substitute&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you know if such exists ?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-09-02T18:59:51.013" Title="Is there any global() function?" Tags="|vimscript|command-line|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4619" PostTypeId="2" ParentId="4612" CreationDate="2015-09-02T18:58:49.327" Score="0" Body="&lt;p&gt;No there is no such function and it wouldn't make much sense.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-02T18:58:49.327" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4620" PostTypeId="2" ParentId="4618" CreationDate="2015-09-02T18:59:51.013" Score="2" Body="&lt;p&gt;No there is no such function and it would not make much sense. If you need to do something for each item in a list, you can loop around it.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-02T18:59:51.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4621" PostTypeId="2" ParentId="4616" CreationDate="2015-09-02T20:29:05.797" Score="1" Body="&lt;p&gt;My exact method was - &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Crunch multi line text into single line&#xA;&quot; Useful for moving text from .tex to web services&#xA;function! Crunch() abort&#xA;    normal! G&#xA;    normal! o&#xA;    g/^./ .,/^$/-1 join&#xA;endfunction&#xA;com! CRUNCH call Crunch()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows me to crunch multi line files correctly.&lt;/p&gt;&#xA;" OwnerUserId="1417" LastActivityDate="2015-09-02T20:29:05.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4622" PostTypeId="1" CreationDate="2015-09-02T21:32:35.383" Score="7" ViewCount="1471" Body="&lt;p&gt;From time to time I want to search on the list of my currents mappings. I search either for mapped keys &lt;em&gt;(what &lt;code&gt;/&amp;lt;Space&amp;gt;a&lt;/code&gt; does?)&lt;/em&gt; or for a command &lt;em&gt;(What keys are mapped on &lt;code&gt;/MyFunction()&amp;lt;CR&amp;gt;&lt;/code&gt;?)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can output these mappings with &lt;code&gt;:map&lt;/code&gt; (or &lt;code&gt;:nmap&lt;/code&gt;, &lt;code&gt;:vmap&lt;/code&gt;, etc...) but this open a window where I can only scroll and not use search mode &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when I want to search in this list I have to use &lt;code&gt;redir&lt;/code&gt; to put the result of the command in a new file, which I then open in vim and use search mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir &amp;gt; foo&#xA;:map&#xA;:redir END&#xA;:e foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I feel like this workflow is not natural:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It uses a lots of commands compared to what I want to do.&lt;/li&gt;&#xA;&lt;li&gt;It creates a new file that I have to delete.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So my question is &lt;strong&gt;is there a more natural way to do a search in the currently mapped keys?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I could create a function which would executes these commands and a custom command to easily call the function, but I was wondering if there wouldn't be a more straight forward way to do it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-09-02T22:19:49.570" Title="How to easily search in the list of existing mappings?" Tags="|key-bindings|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4623" PostTypeId="1" CreationDate="2015-09-02T21:51:18.537" Score="0" ViewCount="154" Body="&lt;p&gt;Related to &lt;a href=&quot;https://vi.stackexchange.com/questions/4613/why-does-vim-allow-to-divide-by-zero&quot;&gt;Why does vim allow to divide by zero&lt;/a&gt;, what's going on here?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let a=-42/0&#xA;:echo a&#xA;-2147483647&#xA;&#xA;:let b=a - 1&#xA;:echo b&#xA;-2147483648&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="945" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-09-03T15:20:45.860" Title="Why is division of a negative number by 0 not the minimum number?" Tags="|vimscript|arithmetic|" AnswerCount="1" CommentCount="1" ClosedDate="2015-09-03T20:25:19.350" ContentLicense="CC BY-SA 3.0" />
  <row Id="4624" PostTypeId="2" ParentId="4623" CreationDate="2015-09-02T22:08:54.547" Score="2" Body="&lt;p&gt;It is because vim represents the signed integers on 32 bits which makes that &lt;code&gt;-2147483648&lt;/code&gt; actually is the smallest number in Vim and not &lt;code&gt;-2147483647&lt;/code&gt; as you could think.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let foo = -2147483647&#xA;echo foo - 1&#xA;=&amp;gt; -2147483648&#xA;&#xA;let foo = -2147483648&#xA;echo foo - 1&#xA;=&amp;gt; 2147483647&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On 32 bits the max value of an integer is &lt;code&gt;2^31-1&lt;/code&gt; when the min value is &lt;code&gt;-2^31&lt;/code&gt;. For an explanation of this different values see &lt;a href=&quot;https://en.wikipedia.org/wiki/Signed_number_representations#Two.27s_complement&quot; rel=&quot;nofollow&quot;&gt;this wiki page&lt;/a&gt; about the two complement in the representation of signed integers.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-09-02T22:54:45.673" LastActivityDate="2015-09-02T22:54:45.673" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4625" PostTypeId="2" ParentId="4622" CreationDate="2015-09-02T22:12:04.327" Score="2" Body="&lt;p&gt;A very easy way to search for a mapping uses a &lt;a href=&quot;https://github.com/Shougo/unite.vim&quot; rel=&quot;nofollow&quot;&gt;plugin&lt;/a&gt;. But the good news is, you probably have it already. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Unite mapping -start-insert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... then you basically directly type your search term and narrow down the list.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Without&lt;/em&gt; a plugin, you can still narrow your map results by providing the prefix of the map, and its type. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose xmap &amp;lt;leader&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... will show the defined mappings only for visual mode, and which start with the leader key. You are not limited to one character there (e.g. you can use &lt;code&gt;xmap &amp;lt;leader&amp;gt;a&lt;/code&gt; and so on).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-09-02T22:19:12.393" LastActivityDate="2015-09-02T22:19:12.393" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4626" PostTypeId="2" ParentId="4622" CreationDate="2015-09-02T22:19:49.570" Score="2" Body="&lt;p&gt;&lt;code&gt;:map&lt;/code&gt;, &lt;code&gt;:imap&lt;/code&gt; and friends take an argument so, instead of issuing a generic command and then filtering it you could simply issue a specific command from the get go:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-02T22:19:49.570" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4627" PostTypeId="1" AcceptedAnswerId="4650" CreationDate="2015-09-02T22:55:14.257" Score="6" ViewCount="2603" Body="&lt;p&gt;When I create a fold with &lt;code&gt;zfap&lt;/code&gt;, vim displays something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+--  15 lines: myFunctionPrototype :: Test -&amp;gt; Test -&amp;gt; Bool &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I would like vim not to display this number of lines.&#xA;I find this distracting, and not adding sufficient information in my case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd prefer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+-- : myFunctionPrototype :: Test -&amp;gt; Test -&amp;gt; Bool&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or even better:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+-- myFunctionPrototype :: Test -&amp;gt; Test -&amp;gt; Bool&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to suppress the line count, or a way to modify what vim displays when there's a fold that I could put in my vimrc ?&lt;/p&gt;&#xA;" OwnerUserId="1682" LastActivityDate="2019-04-28T15:43:30.230" Title="Change what vim displays when there is a fold" Tags="|vimrc|folding|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4628" PostTypeId="2" ParentId="4627" CreationDate="2015-09-03T00:18:07.620" Score="2" Body="&lt;p&gt;The text that is displayed for a closed fold is determined by the &lt;code&gt;'foldtext'&lt;/code&gt; option. See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'foldtext'&#xA;:help fold-foldtext&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The latter topic has a few examples of ways to get different text. As another, simple example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set foldtext=v:folddashes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will result in a line of only dashes (actually hyphens) across the full width of the window.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-09-03T00:18:07.620" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4629" PostTypeId="1" CreationDate="2015-09-03T04:04:16.950" Score="2" ViewCount="975" Body="&lt;p&gt;I'm running Gvim 704 on Windows 7 Ultimate x64. Sometimes for some unapparent reason I get these blue dot artifacts:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/thJ3B.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/thJ3B.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm very minimalist when it comes to plugins, I only use pathogen, ctrlp, nerdcommenter, tabular, vim-scroll-smooth and vim-surround. I also have a dll that enables me to go fullscreen via F11.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do any activity like changing windows (give focus to another window and refocus on vim again), close/reopen the vim buffer/window, toggle fullscreen etc the artifacts go away. It updates its position in the screen as I scroll up/down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;behave mswin&#xA;source $VIMRUNTIME/mswin.vim&#xA;let $PATH .= ';C:\Windows\SysWOW64'&#xA;&#xA;&quot;&quot;{{{ -- AutoCommands --&#xA;&#xA;augroup FormatOptions&#xA;    autocmd!&#xA;    autocmd BufEnter * setlocal formatoptions-=cro&#xA;augroup END&#xA;    &quot;Start maximized&#xA;    augroup OnEnter&#xA;        autocmd!&#xA;        autocmd VimEnter * call libcallnr(&quot;gvimfullscreen.dll&quot;, &quot;ToggleFullScreen&quot;, 0)&#xA;        autocmd GUIEnter * simalt ~x&#xA;    augroup END&#xA;    &quot; Auto set working directory&#xA;    augroup UpdateCWD&#xA;        autocmd!&#xA;        autocmd BufEnter * silent! lcd %:p:h&#xA;    augroup END&#xA;&quot;&quot;}}}&#xA;&#xA;&quot;&quot;{{{ -- Misc Settings --&#xA;&#xA;    &quot; split chars&#xA;    set fillchars=stl:-&#xA;    set fillchars+=vert:\|&#xA;&#xA;    &quot; fixes some scrolling/rendering issues&#xA;    set ttyscroll=0&#xA;    set nocursorline&#xA;    set nocursorcolumn&#xA;&#xA;    &quot; switch cases indentation&#xA;    set cinoptions==0&#xA;&#xA;    &quot; global search/replace by default&#xA;    set gdefault&#xA;&#xA;    &quot; cursor shape&#xA;    set guicursor+=i:ver11&#xA;    set guicursor+=v:ver11&#xA;    set guicursor+=n:block&#xA;&#xA;    &quot; disable blinking&#xA;    set guicursor=a:blinkon0&#xA;&#xA;    &quot; these four speed things up when syn high is enabled and browsing huge amount of text&#xA;    syntax sync minlines=256&#xA;&#xA;    set norelativenumber&#xA;    set expandtab&#xA;    set nocompatible&#xA;    set shellslash&#xA;    set backspace=2&#xA;    set guifont=Courier_New:h12:cANSI&#xA;    &quot;set guifont=Consolas:b:h12:cANSI &quot;use _ for spaces&#xA;    color black&#xA;    syntax on&#xA;    set wrap&#xA;    set autoindent&#xA;    set smartindent&#xA;    set tabstop=4&#xA;    set shiftwidth=4&#xA;    set textwidth=65&#xA;    set laststatus=0                &quot; status line&#xA;    filetype plugin indent on&#xA;    set noswapfile&#xA;    set nobackup&#xA;    set nohlsearch&#xA;    &quot;set hlsearch                   &quot; highlights all the found instances in a search&#xA;    set ignorecase                  &quot; Ignore case when searching&#xA;    set smartcase                   &quot; Ignore case if search is all lowercase, case-sensitive otherwise.&#xA;    set incsearch                   &quot; Show search matches as you type.&#xA;    scriptencoding utf-8            &quot; UTF-8 encoding&#xA;    set guioptions=                 &quot; no gui, whatsoever&#xA;    set autoread                    &quot; auto read files after they're modified without displaying a prompt&#xA;    set mouse=a&#xA;&#xA;&quot;&quot;}}}&#xA;&#xA;&quot;&quot;{{{ -- Plugins --&#xA;&#xA;    &quot; Fullscreen&#xA;    map &amp;lt;F11&amp;gt; &amp;lt;Esc&amp;gt;:call libcallnr(&quot;gvimfullscreen.dll&quot;, &quot;ToggleFullScreen&quot;, 0)&amp;lt;CR&amp;gt;&#xA;&#xA;    &quot;Tabularize&#xA;    nnoremap &amp;lt;leader&amp;gt;t= :Tabularize /=&amp;lt;cr&amp;gt;&#xA;    nnoremap &amp;lt;leader&amp;gt;t{ :Tabularize /{&amp;lt;cr&amp;gt;&#xA;    nnoremap &amp;lt;leader&amp;gt;t: :Tabularize /:&amp;lt;cr&amp;gt;&#xA;    vnoremap &amp;lt;leader&amp;gt;t= :Tabularize /=&amp;lt;cr&amp;gt;&#xA;    vnoremap &amp;lt;leader&amp;gt;t{ :Tabularize /{&amp;lt;cr&amp;gt;&#xA;    vnoremap &amp;lt;leader&amp;gt;t: :Tabularize /:&amp;lt;cr&amp;gt;&#xA;&#xA;    &quot;CtrlP&quot;&#xA;        let g:ctrlp_root_markers = ['Source', 'src']&#xA;&#xA;        set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe,*.meta,*.mat,*.suo,*.csproj,*.sln,*.dwlt,&#xA;                        \*.asset,*.unity,*.db,*.xml,*.cache,*.prefab,*.fbx,*.max,*.lxo,*.blend,&#xA;                        \*.obj,*.3DS,*.smd,*.mp3,*.ogg,*.wav,*.png,*.jpg,*.prefs,*.anim,*.unityproj,&#xA;                        \*.config,*.log,*.rsp,&#xA;                        \*UnityTempFile*,*.pdb,*.dll,*.ilk,*.lnk,*.ini&#xA;&#xA;        nnoremap &amp;lt;C-m&amp;gt;&amp;lt;c-p&amp;gt; :CtrlPMRU&amp;lt;cr&amp;gt;&#xA;&#xA;        let g:ctrlp_custom_ignore = {&#xA;          \ 'dir':  '\v[\/]\.(git|hg|svn)$',&#xA;          \ 'file': '\v\.(exe|so|dll|meta)$',&#xA;          \ 'link': 'some_bad_symbolic_links',&#xA;          \ }&#xA;&#xA;    &quot;UltiSnips&quot;&#xA;        &quot; Trigger configuration. Do not use &amp;lt;tab&amp;gt; if you use https://github.com/Valloric/YouCompleteMe.&#xA;        let g:UltiSnipsExpandTrigger=&quot;&amp;lt;s-tab&amp;gt;&quot;&#xA;        let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;c-k&amp;gt;&quot;&#xA;        let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-i&amp;gt;&quot;&#xA;&#xA;        &quot; If you want :UltiSnipsEdit to split your window.&#xA;        let g:UltiSnipsEditSplit=&quot;vertical&quot;&#xA;&#xA;    &quot;Smooth scroll&quot;&#xA;        noremap &amp;lt;silent&amp;gt; &amp;lt;c-f&amp;gt; m':call smooth_scroll#down(&amp;amp;scroll * 1, 1, 2)&amp;lt;CR&amp;gt;&#xA;        noremap &amp;lt;silent&amp;gt; &amp;lt;c-a&amp;gt; m':call smooth_scroll#up(&amp;amp;scroll * 1, 1, 2)&amp;lt;CR&amp;gt;&#xA;&#xA;    &quot;Pathogen&quot;&#xA;        let g:pathogen_disabled = []&#xA;        execute pathogen#infect()&#xA;&quot;&quot;}}}&#xA;&#xA;&quot;&quot;{{{ -- Mappings&#xA;&#xA;    &quot;collapse blocks of empty lines into a single one&#xA;    nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;re ma:%s/^\_s\+\n/\r&amp;lt;CR&amp;gt;'azz&#xA;&#xA;    &quot;unicode insertion&#xA;    inoremap &amp;lt;C-k&amp;gt; &amp;lt;C-v&amp;gt;&#xA;    cnoremap &amp;lt;C-k&amp;gt; &amp;lt;C-v&amp;gt;&#xA;&#xA;    &quot;member search (works only when lines start with member names)&#xA;    nnoremap &amp;lt;A-/&amp;gt; /^&#xA;&#xA;    &quot;indent block&#xA;    nnoremap + =}&#xA;    nnoremap =i =i{&#xA;&#xA;    &quot;find variable/function declaration (works when their name is the start of the line)&#xA;    nnoremap &amp;lt;A-d&amp;gt; yiw/^\&amp;lt;&amp;lt;C-R&amp;gt;&quot;\&amp;gt;&amp;lt;CR&amp;gt;zz&#xA;    &quot;find struct/class/enum&#xA;    nnoremap &amp;lt;A-f&amp;gt;&amp;lt;A-s&amp;gt; yiw/^\&amp;lt;struct &amp;lt;C-R&amp;gt;&quot;\&amp;gt;&amp;lt;CR&amp;gt;zz&#xA;    nnoremap &amp;lt;A-f&amp;gt;&amp;lt;A-c&amp;gt; yiw/^\&amp;lt;class &amp;lt;C-R&amp;gt;&quot;\&amp;gt;&amp;lt;CR&amp;gt;zz&#xA;    nnoremap &amp;lt;A-f&amp;gt;&amp;lt;A-e&amp;gt; yiw/^\&amp;lt;enum &amp;lt;C-R&amp;gt;&quot;\&amp;gt;&amp;lt;CR&amp;gt;zz&#xA;&#xA;    &quot;simple for loop template&#xA;    &quot;inoremap ,for &amp;lt;C-O&amp;gt;m'for(; ;)&amp;lt;CR&amp;gt;{&amp;lt;CR&amp;gt;}&amp;lt;C-O&amp;gt;''&amp;lt;Esc&amp;gt;m'=i{''f(a&#xA;&#xA;    &quot;double toggle fullscreen&#xA;    nmap &amp;lt;leader&amp;gt;ff &amp;lt;F11&amp;gt;&amp;lt;F11&amp;gt;&#xA;&#xA;    &quot;jump to end of file&#xA;    nnoremap &amp;lt;Space&amp;gt; G&#xA;    vnoremap &amp;lt;Space&amp;gt; G&#xA;&#xA;    &quot;serach for visually selected text&#xA;    vnoremap * y/&amp;lt;C-R&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;    vnoremap # y?&amp;lt;C-R&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&#xA;    &quot;Jump list&#xA;    &quot;forward&#xA;    nnoremap &amp;lt;S-o&amp;gt; &amp;lt;C-I&amp;gt;&#xA;&#xA;    &quot;Rename&quot; (whole word)&#xA;    &quot;current line&#xA;    nnoremap &amp;lt;A-r&amp;gt;&amp;lt;A-r&amp;gt; :s/\&amp;lt;&amp;lt;c-r&amp;gt;=expand(&quot;&amp;lt;cword&amp;gt;&quot;)&amp;lt;cr&amp;gt;\&amp;gt;//I&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;    &quot;current function scope&#xA;    nmap &amp;lt;A-r&amp;gt;&amp;lt;A-l&amp;gt; Y[mV%:s/\&amp;lt;&amp;lt;C-R&amp;gt;&quot;\&amp;gt;//cI&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;    &quot;global&#xA;    nnoremap &amp;lt;A-r&amp;gt;&amp;lt;A-g&amp;gt; :%s/\&amp;lt;&amp;lt;c-r&amp;gt;=expand(&quot;&amp;lt;cword&amp;gt;&quot;)&amp;lt;cr&amp;gt;\&amp;gt;//cI&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&#xA;    nnoremap gr gd[{V%::s/&amp;lt;C-R&amp;gt;///cI&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;    nnoremap gR gD:%s/&amp;lt;C-R&amp;gt;///cI&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&#xA;    &quot;Essential&quot;&#xA;        &quot; Leader&#xA;        let mapleader = &quot;,&quot;&#xA;        &quot; Quick vimrc edit&#xA;        nnoremap &amp;lt;leader&amp;gt;ev :vsplit $MYVIMRC &amp;lt;cr&amp;gt;&#xA;        &quot; Quick vimrc reload (sourcing)&#xA;        nnoremap &amp;lt;leader&amp;gt;so :source $MYVIMRC &amp;lt;Bar&amp;gt;nohlsearch&amp;lt;cr&amp;gt;&#xA;        &quot; Clear search&#xA;        nnoremap &amp;lt;silent&amp;gt;&amp;lt;A-c&amp;gt; :nohlsearch&amp;lt;Return&amp;gt;&#xA;        inoremap &amp;lt;silent&amp;gt;&amp;lt;A-c&amp;gt; &amp;lt;esc&amp;gt;:nohlsearch&amp;lt;Return&amp;gt;a&#xA;        &quot; Quick insert/normal modes toggle (Caps is mapped to F2 via ahk)&#xA;        nnoremap &amp;lt;F2&amp;gt; i&#xA;        inoremap &amp;lt;silent&amp;gt;&amp;lt;F2&amp;gt; &amp;lt;Esc&amp;gt;:call GoRightIfNotBOL()&amp;lt;CR&amp;gt;&#xA;        vnoremap &amp;lt;F2&amp;gt; &amp;lt;Esc&amp;gt;&#xA;&#xA;    &quot;Misc Nops&#xA;        nnoremap &amp;lt;A-f&amp;gt; &amp;lt;Nop&amp;gt;&#xA;        &quot; mouse nops&#xA;        map &amp;lt;MiddleMouse&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&#xA;    &quot;Movement&quot;   &#xA;        noremap k gj&#xA;        noremap i gk&#xA;        noremap j h&#xA;        &quot; Next/prev word (insert mode)&#xA;        inoremap &amp;lt;C-l&amp;gt; &amp;lt;esc&amp;gt;ea&#xA;        inoremap &amp;lt;C-j&amp;gt; &amp;lt;esc&amp;gt;bi&#xA;        &quot; Jump to last cursor position&#xA;        nnoremap &amp;lt;A--&amp;gt; ``&#xA;        &quot; Navigation&#xA;        &quot;next/prev word/block&#xA;        nnoremap J b&#xA;        nnoremap L w&#xA;        &quot;nnoremap I {&#xA;        &quot;nnoremap K }&#xA;        vnoremap J b&#xA;        vnoremap L w&#xA;        &quot;vnoremap I {&#xA;        &quot;vnoremap K }   &#xA;&#xA;        nnoremap / :set hlsearch&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;/&#xA;        nnoremap ? :set hlsearch&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;?&#xA;&#xA;        nnoremap &amp;lt;silent&amp;gt; I :set nohlsearch&amp;lt;CR&amp;gt;?^\s*$&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;&#xA;        nnoremap &amp;lt;silent&amp;gt; K :set nohlsearch&amp;lt;CR&amp;gt;/^\s*$&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;&#xA;        vnoremap &amp;lt;silent&amp;gt; I ?^\s*$&amp;lt;CR&amp;gt;&#xA;        vnoremap &amp;lt;silent&amp;gt; K /^\s*$&amp;lt;CR&amp;gt;&#xA;&#xA;        &quot;next/prev method/function'&#xA;        nnoremap &amp;lt;silent&amp;gt;} /^{&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;&#xA;        nnoremap &amp;lt;silent&amp;gt;{ ?^{&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;&#xA;&#xA;        &quot;beginning/end of line&#xA;        nnoremap m ox&amp;lt;BS&amp;gt;&#xA;        nnoremap o Ox&amp;lt;BS&amp;gt;&#xA;        &quot;nnoremap m o&#xA;        &quot;nnoremap o O&#xA;        nnoremap h ^i&#xA;        nnoremap ' $a&#xA;        vnoremap h ^&#xA;        vnoremap ' $&#xA;&#xA;        &quot;jump to top/middle/bottom of the screen&#xA;        nnoremap &amp;lt;S-h&amp;gt; M&#xA;        nnoremap &amp;lt;S-t&amp;gt; H&#xA;        nnoremap &amp;lt;S-b&amp;gt; L&#xA;        vnoremap &amp;lt;S-h&amp;gt; M&#xA;        vnoremap &amp;lt;S-t&amp;gt; H&#xA;        vnoremap &amp;lt;S-b&amp;gt; L&#xA;&#xA;        &quot; jump to match&#xA;        nnoremap &amp;lt;S-m&amp;gt; %&#xA;        vnoremap &amp;lt;S-m&amp;gt; %&#xA;&#xA;        &quot;Scroll screen 'without' moving cursor&#xA;        &quot;one char&#xA;        nnoremap &amp;lt;C-i&amp;gt; &amp;lt;C-y&amp;gt;&#xA;        nnoremap &amp;lt;C-k&amp;gt; &amp;lt;C-e&amp;gt;&#xA;        nnoremap &amp;lt;C-j&amp;gt; zh&#xA;        nnoremap &amp;lt;C-l&amp;gt; zl&#xA;        vnoremap &amp;lt;C-i&amp;gt; &amp;lt;C-y&amp;gt;&#xA;        vnoremap &amp;lt;C-k&amp;gt; &amp;lt;C-e&amp;gt;&#xA;        vnoremap &amp;lt;C-j&amp;gt; zh&#xA;        vnoremap &amp;lt;C-l&amp;gt; zl&#xA;&#xA;        &quot;screen&#xA;        nnoremap &amp;lt;C-h&amp;gt; zz&#xA;        nnoremap &amp;lt;C-t&amp;gt; zt&#xA;        nnoremap &amp;lt;C-b&amp;gt; zb&#xA;        vnoremap &amp;lt;C-h&amp;gt; zz&#xA;        vnoremap &amp;lt;C-t&amp;gt; zt&#xA;        vnoremap &amp;lt;C-b&amp;gt; zb&#xA;&#xA;    &quot;Clipboard&quot;&#xA;        &quot; Undoing&#xA;        nnoremap &amp;lt;C-z&amp;gt; u&#xA;        inoremap &amp;lt;C-z&amp;gt; &amp;lt;C-[&amp;gt;ui&#xA;        &quot; This is due to the fact that in VS, Ctrl-V is reserved for paste&#xA;        nnoremap &amp;lt;A-v&amp;gt; &amp;lt;C-v&amp;gt;&#xA;&#xA;    &quot;Other&quot;&#xA;        &quot; yank current word&#xA;        nnoremap Y yiw&#xA;&#xA;        &quot; For recording purposes, fast repeating.&#xA;        nnoremap &amp;lt;A-2&amp;gt; @a&#xA;&#xA;        &quot; Change inside&#xA;        nnoremap &amp;lt;A-i&amp;gt; ci&#xA;        nnoremap &amp;lt;A-i&amp;gt;&amp;lt;A-'&amp;gt; ci&quot;&#xA;        nnoremap &amp;lt;A-i&amp;gt;&amp;lt;A-9&amp;gt; ci(&#xA;&#xA;        &quot; Join&#xA;        nnoremap &amp;lt;A-j&amp;gt; J&#xA;        vnoremap &amp;lt;A-j&amp;gt; J&#xA;&#xA;        &quot; Visual-&amp;gt;insert&#xA;        vnoremap &amp;lt;A-i&amp;gt; I&#xA;        vnoremap &amp;lt;A-a&amp;gt; A&#xA;&#xA;        &quot; Jumps cursor inside braces http://stackoverflow.com/questions/9621173/vim-and-indentation-with-brackets-braces&#xA;        inoremap {&amp;lt;CR&amp;gt; {&amp;lt;CR&amp;gt;}&amp;lt;C-o&amp;gt;O&#xA;&#xA;    &quot;Visual/Select&quot;&#xA;        &quot; Visually select the current word&#xA;        nnoremap v&amp;lt;space&amp;gt; viw&#xA;&#xA;    &quot;Numerics&quot;&#xA;        &quot; [de-in]crement&#xA;        nnoremap &amp;lt;A-a&amp;gt; &amp;lt;C-a&amp;gt;&#xA;        nnoremap &amp;lt;A-x&amp;gt; &amp;lt;C-x&amp;gt;&#xA;&#xA;    &quot;Deletion&quot;&#xA;        &quot; Delete word under cursor&#xA;        nnoremap d&amp;lt;space&amp;gt; diw&#xA;        nnoremap c&amp;lt;space&amp;gt; ciw&#xA;        &quot; delete word to the left of cursor.&#xA;        inoremap &amp;lt;C-BS&amp;gt; &amp;lt;C-W&amp;gt;&#xA;        &quot; Enhanced change line&#xA;        nnoremap &amp;lt;silent&amp;gt;cc :call ChangeCurrentLine()&amp;lt;cr&amp;gt;a&#xA;&#xA;    &quot;GUI&quot;&#xA;        &quot; Toggle menu bar&#xA;        nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;tm :call ToggleMenuBar()&amp;lt;cr&amp;gt;&#xA;&#xA;    &quot;Buffers&quot;&#xA;        &quot; previous buffer&#xA;        nnoremap &amp;lt;leader&amp;gt;3 :buf #&amp;lt;CR&amp;gt;&#xA;&#xA;        &quot; Show a menu to complete buffer and file names&#xA;        set wildchar=&amp;lt;Tab&amp;gt; wildmenu wildmode=full&quot;&#xA;&#xA;        &quot; Writing/saving&#xA;        inoremap &amp;lt;C-s&amp;gt; &amp;lt;C-[&amp;gt;:w &amp;lt;Enter&amp;gt;a&#xA;        nnoremap &amp;lt;C-s&amp;gt; :w &amp;lt;Enter&amp;gt;&#xA;&#xA;        &quot; To open a new empty buffer&#xA;        nnoremap &amp;lt;leader&amp;gt;T :enew&amp;lt;cr&amp;gt;&#xA;&#xA;        &quot; Move to the next buffer&#xA;        nnoremap &amp;lt;leader&amp;gt;l :bnext&amp;lt;CR&amp;gt;&#xA;&#xA;        &quot; Move to the previous buffer&#xA;        nnoremap &amp;lt;leader&amp;gt;j :bprevious&amp;lt;CR&amp;gt;&#xA;&#xA;        &quot; Close the current buffer and move to the previous one&#xA;        &quot; This replicates the idea of closing a tab&#xA;        nnoremap &amp;lt;leader&amp;gt;bq :bp &amp;lt;BAR&amp;gt; bd #&amp;lt;CR&amp;gt;&#xA;&#xA;        &quot; Show all open buffers and their status&#xA;        nnoremap &amp;lt;leader&amp;gt;bl :ls&amp;lt;CR&amp;gt;&#xA;&#xA;    &quot;Windows&quot;&#xA;        &quot; Switching windows&#xA;        nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;wi :wincmd k&amp;lt;CR&amp;gt;&#xA;        nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;wk :wincmd j&amp;lt;CR&amp;gt;&#xA;        nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;wj :wincmd h&amp;lt;CR&amp;gt;&#xA;        nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;wl :wincmd l&amp;lt;CR&amp;gt;&#xA;        &quot; Resizing&#xA;        nnoremap &amp;lt;silent&amp;gt;&amp;lt;A-S-l&amp;gt; :15winc &amp;gt;&amp;lt;CR&amp;gt;&#xA;        nnoremap &amp;lt;silent&amp;gt;&amp;lt;A-S-j&amp;gt; :15winc &amp;lt;&amp;lt;CR&amp;gt;&#xA;        nnoremap &amp;lt;silent&amp;gt;&amp;lt;A-S-i&amp;gt; &amp;lt;C-w&amp;gt;5+&#xA;        nnoremap &amp;lt;silent&amp;gt;&amp;lt;A-S-k&amp;gt; &amp;lt;C-w&amp;gt;5-&#xA;        &quot; Veritcal Split&#xA;        nnoremap &amp;lt;leader&amp;gt;sv &amp;lt;C-w&amp;gt;v&#xA;&quot;&quot;}}}&#xA;&#xA;&quot;&quot;{{{ -- Functions --&#xA;    function! ToggleMenuBar()&#xA;        let &amp;amp;g:guioptions = ToggleStringValue(&amp;amp;g:guioptions, &quot;m&quot;)&#xA;    endfu&#xA;&#xA;    function! IsLineEmpty(line)&#xA;        return match(a:line, '^\s*$') == -1 ? 0 : 1&#xA;    endfu&#xA;&#xA;    function! IsCurrentLineEmpty()&#xA;        return IsLineEmpty(getline('.'))&#xA;    endfu&#xA;&#xA;    function! ChangeCurrentLine()&#xA;        execute &quot;normal! &quot; . (IsCurrentLineEmpty() ? &quot;0&quot; : &quot;^&quot;) . &quot;C&quot;&#xA;    endfu&#xA;&#xA;    &quot; Returns 1 if the cursor is at the beginning of a line &quot;&#xA;    function! IsBOL()&#xA;        return col('.') == 1&#xA;    endfu&#xA;&#xA;  function! GoRightIfNotBOL()&#xA;        if !IsBOL()&#xA;            execute &quot;normal l&quot;&#xA;        endif&#xA;    endfu&#xA;&#xA;    function! ToggleStringValue(input, value)&#xA;        let l:result = a:input&#xA;        if l:result =~ a:value&#xA;            let l:result = substitute(l:result, a:value, &quot;&quot;, &quot;&quot;)&#xA;        else&#xA;            let l:result .= a:value&#xA;        endif&#xA;        return l:result&#xA;    endfu&#xA;&#xA;    function! s:JumpMethod(char, flags, mode)&#xA;        let original_cursor = getpos('.')&#xA;&#xA;        if a:mode == 'v'&#xA;            normal! gv&#xA;        elseif a:mode == 'o'&#xA;            normal! v&#xA;        endif&#xA;&#xA;        while search(a:char, a:flags) &amp;gt; 0&#xA;            if a:char == '}'&#xA;                &quot; jump to the opening one to analyze the definition&#xA;                normal! %&#xA;            endif&#xA;&#xA;            let current_line = line('.')&#xA;&#xA;            if getline(current_line) =~ '^\s*{'&#xA;                &quot; it's alone on the line, check the above one&#xA;                let method_line = current_line - 1&#xA;            else&#xA;                let method_line = current_line&#xA;            endif&#xA;&#xA;            let method_line_body = getline(method_line)&#xA;&#xA;            if method_line_body =~ '\k\+\s*(.*)' &amp;amp;&amp;amp; method_line_body !~ '\&amp;lt;\(for\|foreach\|if\|while\|switch\|using\|catch\|get\|set\)\&amp;gt;'&#xA;                &quot; it's probably a function call&#xA;&#xA;                if a:char == '}'&#xA;                    &quot; we need to go back to the closing bracket&#xA;                    normal! %&#xA;                endif&#xA;&#xA;                echo&#xA;                return&#xA;            else&#xA;                if a:char == '}'&#xA;                    &quot; we still need to go back to the closing bracket&#xA;                    normal! %&#xA;                endif&#xA;            endif&#xA;        endwhile&#xA;&#xA;        &quot; if we're here, the search has failed, restore cursor position&#xA;        echo&#xA;        call setpos('.', original_cursor)&#xA;    endfunction&#xA;&quot;&quot;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I never had these issues before but I vaguely remember starting to have them around the time I added the ilnes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ttyscroll=0&#xA;set nocursorline&#xA;set nocursorcolumn&#xA;&#xA;syntax sync minlines=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not exactly sure they're related but I do remember adding them was an attempt to solve the rendering/artifacts problems. The artifacts don't happen in a replicate-able manner so even if I were to disable those options I might not see any immediately but eventually do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any idea what could be causing this and how to get rid of it?&lt;/p&gt;&#xA;" OwnerUserId="3023" LastEditorUserId="24" LastEditDate="2015-09-11T04:56:51.973" LastActivityDate="2015-09-11T04:56:51.973" Title="Gvim rendering artifacts?" Tags="|gvim|microsoft-windows|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="4630" PostTypeId="2" ParentId="4613" CreationDate="2015-09-03T04:31:54.400" Score="2" Body="&lt;p&gt;This behavior is useful in Calculus when using something called a Limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lim n -&gt; 0^+ of 1/n = +inf&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can also be written as:&#xA;As n -&gt; 0^+, 1/n -&gt; +inf&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is read like so..&#xA;As n approaches zero from the right, the function 1/n approaches positive infinity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To see a visual explanation of this reasoning, pop over to&#xA;&lt;a href=&quot;http://www.wolframalpha.com/input/?i=limit+n-%3E0+of+1%2Fn&quot; rel=&quot;nofollow&quot;&gt;http://www.wolframalpha.com/input/?i=limit+n-%3E0+of+1%2Fn&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for Vim-script specifically, AFAIK not many people do much more than logic and integer arithmetic with it.  It could be the case that this behavior seemed like a good idea at the time, and is merely a legacy artifact at this point.&lt;/p&gt;&#xA;" OwnerUserId="3396" LastEditorUserId="3396" LastEditDate="2015-09-06T18:32:44.140" LastActivityDate="2015-09-06T18:32:44.140" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4631" PostTypeId="1" AcceptedAnswerId="4633" CreationDate="2015-09-03T06:25:38.123" Score="3" ViewCount="670" Body="&lt;p&gt;I have shortcut map in gVim like &lt;code&gt;nmap &amp;lt;a-k&amp;gt; SomeKeySequence:SomeCommand&lt;/code&gt;, it seems the last command will not be run if the previous key sequence aborted (like no valid operating target then bell rings), is there a way to let the last command to run even if failure happens in previous operations?&lt;/p&gt;&#xA;" OwnerUserId="477" LastEditorUserId="71" LastEditDate="2015-09-03T19:27:00.243" LastActivityDate="2015-09-03T19:27:00.243" Title="Run following command even if previous command fails to run?" Tags="|vimscript|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4632" PostTypeId="2" ParentId="4613" CreationDate="2015-09-03T07:44:06.823" Score="9" Body="&lt;p&gt;This behavior is documented under &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html&quot;&gt;eval section&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When dividing a Number by zero the result depends on the value:&#xA;      0 / 0  = -0x80000000  (like NaN for Float)&#xA;     &amp;gt;0 / 0  =  0x7fffffff  (like positive infinity)&#xA;     &amp;lt;0 / 0  = -0x7fffffff  (like negative infinity)&#xA;    (before Vim 7.2 it was always 0x7fffffff)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1892" LastActivityDate="2015-09-03T07:44:06.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4633" PostTypeId="2" ParentId="4631" CreationDate="2015-09-03T10:34:13.353" Score="8" Body="&lt;p&gt;It depends a little on what exactly you want to do. You can always call a function and handle errors in the function gracefully (e.g. try/catch clauses).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can wrap your normal mode command into a :exe &quot;:norm&quot; clause, which will not make the mapping abort on erros, e.g. you could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;f5&amp;gt; :exe &quot;:norm! h&quot;&amp;lt;cr&amp;gt;:echo &quot;done&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(That is a silly example, but shows, that the echo will also shown, if the cursor is at the start of a line and a left movement is not possible).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-03T10:34:13.353" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4634" PostTypeId="1" AcceptedAnswerId="4635" CreationDate="2015-09-03T12:54:15.787" Score="13" ViewCount="1639" Body="&lt;p&gt;I would like to find out what are the most common patterns I'm using during coding. So I'm looking for a way to record all my keyboard input while I'm in Vim, preferably with timestamps. Then I could do some analysis on the most recent used patterns/motions what time does an action take, and find out things to optimize.&lt;/p&gt;&#xA;&lt;p&gt;Is there an idiomatic way to do this in Vim?&#xA;Shall I try and write a plugin for this?&#xA;What would be the performance implications of doing something like this?&lt;/p&gt;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="3405" LastEditorUserId="23502" LastEditDate="2022-11-05T09:24:15.933" LastActivityDate="2022-11-05T09:24:15.933" Title="How to record my keyboard input to do statistics on it?" Tags="|vimrc|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4635" PostTypeId="2" ParentId="4634" CreationDate="2015-09-03T14:30:19.973" Score="4" Body="&lt;p&gt;Vim allows logging all input when the &lt;code&gt;-w&lt;/code&gt; command line option is passed with a file:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;-w {scriptout}&#xA;                    All the characters that you type are recorded in the file   {scriptout}, until you exit Vim.  This is useful if you want to create a script file to be used with &quot;vim -s&quot; or &quot;:source!&quot;.  If the {scriptout} file exists, characters are appended.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now that we have access to the input we can redirect it where we want. The following way for instance (&lt;strong&gt;*nix systems only&lt;/strong&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -w &amp;gt;(./timestamper.py &amp;gt; log)&#xA;vim -w &amp;gt;(tee raw-log | ./timestamper.py &amp;gt; log) # If we want the raw log, too&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;timestamper.py&lt;/code&gt; is the following short python script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python&#xA;&#xA;import sys&#xA;import datetime&#xA;&#xA;while True:&#xA;    if (sys.stdin.closed):&#xA;        sys.stdout.write(&quot;Input closed\n&quot;)&#xA;        break&#xA;&#xA;    a = sys.stdin.read(1)&#xA;    if (not a):&#xA;        break&#xA;    sys.stdout.write(&quot;[{}]: {}\n&quot;.format(datetime.datetime.now(), a))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The script can be replaced with any other programme that takes input if you want to do something more sophisticated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;NOTE: After some short testing I found out that vim seems to keep a buffer of the inputs that it flushes at some point and on exit. This makes the timestamps fairly unreliable.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="20" LastActivityDate="2015-09-03T14:30:19.973" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4636" PostTypeId="2" ParentId="4600" CreationDate="2015-09-03T22:11:56.690" Score="0" Body="&lt;p&gt;If you are using a Mac(OSX), you can install &lt;em&gt;pbcopy&lt;/em&gt; (using &lt;em&gt;brew install pbcopy&lt;/em&gt; --see &lt;a href=&quot;http://brew.sh/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://brew.sh/&lt;/a&gt; for more details).   Then run the following (straight from commandline) &lt;em&gt;without&lt;/em&gt; touching the mouse:&lt;/p&gt;&#xA;&lt;p&gt;EXAMPLE:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;In TERMINAL# &lt;strong&gt;001&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;cat /tmp/stuff.txt | pbcopy&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can switch to terminal #002 (without using the mouse) by using the built-in hot keys in OSX's terminal application: &lt;kbd&gt;command&lt;/kbd&gt; + &lt;kbd&gt;i&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In TERMINAL# &lt;strong&gt;002&lt;/strong&gt;:  Open the new file in vim&lt;/p&gt;&#xA;&lt;p&gt;vi newfile&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Put vim in  &lt;em&gt;insert mode&lt;/em&gt; with &lt;kbd&gt;i&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Insert the text from the clipboard with &lt;kbd&gt;command&lt;/kbd&gt; + &lt;kbd&gt;V&lt;/kbd&gt; (to paste from the clipboard on a Mac)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Enjoy the rest of your day!&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3408" LastEditorUserId="-1" LastEditDate="2023-03-04T08:14:48.007" LastActivityDate="2023-03-04T08:14:48.007" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4637" PostTypeId="1" AcceptedAnswerId="4660" CreationDate="2015-09-04T08:01:40.070" Score="36" ViewCount="80320" Body="&lt;p&gt;When I am recording a macro with &lt;code&gt;q&lt;/code&gt; and I am done, I can type:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; to stop recording if I am in normal or visual mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-o&amp;gt;q&lt;/code&gt; to stop recording if I am in insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I stop recording if my macro ends in command mode? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2978" LastActivityDate="2015-09-07T13:25:13.800" Title="How do I stop recording while in command line?" Tags="|command-line|register|macro|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4638" PostTypeId="2" ParentId="4637" CreationDate="2015-09-04T08:55:02.570" Score="20" Body="&lt;p&gt;One way to do it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;start your macro as usual (e.g. &lt;code&gt;qq&lt;/code&gt; ... other chars)&lt;/li&gt;&#xA;&lt;li&gt;when you reach the cmdline-mode, write all the characters you want&lt;/li&gt;&#xA;&lt;li&gt;you want to end the macro here. Hit &lt;code&gt;ESC&lt;/code&gt; to get out of cmdline-mode, &lt;code&gt;q&lt;/code&gt; to end your macro.&lt;/li&gt;&#xA;&lt;li&gt;remove the &lt;code&gt;ESC&lt;/code&gt; from your &lt;code&gt;q&lt;/code&gt; register (*): you can paste it in a buffer, remove the &lt;code&gt;^[&lt;/code&gt; character, select the whole stuff again (character-wise) and yank it back to register &lt;code&gt;q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;that's it: run your macro: &lt;code&gt;@q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Basically, you &quot;post-process&quot; your macro a little, since it is stored in a register :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) A quick way to remove the last character from a macro stored in register &lt;code&gt;q&lt;/code&gt; would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @q = @q[:-2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-09-04T11:36:46.390" LastActivityDate="2015-09-04T11:36:46.390" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4640" PostTypeId="1" AcceptedAnswerId="4641" CreationDate="2015-09-04T11:47:18.617" Score="4" ViewCount="135" Body="&lt;p&gt;I often &quot;pre-compose&quot; and save my longer questions for StackExchange usign Vim / GVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does a syntax highlighting file for the &lt;strong&gt;StackExchange markdown&lt;/strong&gt; already exist? If yes, where can I obtain it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Googling for &lt;code&gt;vim syntax file stackexchange&lt;/code&gt; leads to general questions / answers on various SE-sites about &quot;vimish&quot; syntax highlighting in general.&lt;/p&gt;&#xA;" OwnerUserId="3325" LastActivityDate="2021-03-31T18:46:45.653" Title="Syntax highlighting for StackExchange markdown" Tags="|syntax-highlighting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4641" PostTypeId="2" ParentId="4640" CreationDate="2015-09-04T14:29:55.023" Score="4" Body="&lt;p&gt;AFAIK no.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But Vim already supports Markdown out of the box and there are probably a few alternative syntax scripts &lt;a href=&quot;http://www.vim.org/scripts/script_search_results.php?keywords=markdown&amp;amp;script_type=syntax&amp;amp;order_by=creation_date&amp;amp;direction=descending&amp;amp;search=search&quot; rel=&quot;nofollow&quot;&gt;available&lt;/a&gt; if the default doesn't satisfy you.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-04T14:29:55.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4642" PostTypeId="2" ParentId="4637" CreationDate="2015-09-04T14:41:54.180" Score="3" Body="&lt;p&gt;Having read your comment about the use case, it looks like you could use a key mapping instead of a macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this line in my .vimrc (don't remember where I found it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;s :%s/\&amp;lt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;\&amp;gt;//g&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It has a similar effect to the use case you described, putting you on the command line so the only thing you have to do is type the replacement and press enter, but in this case, replacing all occurrences of the word that was under your cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To just replace within the current block, I think something like the following should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;s m'va{&amp;lt;ESC&amp;gt;``:'&amp;lt;,'&amp;gt;s/\&amp;lt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;\&amp;gt;//g&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, you can map it to whatever key you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What the above does: mark the current position using the unnamed marker, visually select the current block, leave visual mode and return the cursor to the saved position (the visual selection markers are still set), enter command mode and type out the substitute command, inserting the word that was under the cursor with &lt;code&gt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;&lt;/code&gt;, and positioning your cursor to type out the replacement.&lt;/p&gt;&#xA;" OwnerUserId="2659" LastActivityDate="2015-09-04T14:41:54.180" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4643" PostTypeId="1" AcceptedAnswerId="4684" CreationDate="2015-09-04T15:00:42.163" Score="10" ViewCount="5143" Body="&lt;p&gt;One big difference of neovim and Vim is that neovim includes a &lt;a href=&quot;http://neovim.io/doc/user/nvim_terminal_emulator.html&quot;&gt;terminal emulator&lt;/a&gt; that works asynchronously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I fail to see how can I profit from this feature. For what can I use it? Can you give some use cases for neovim's terminal feature so that I understand how I can use it to its best extent?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal Vim I normally use &lt;code&gt;:read !{command}&lt;/code&gt;, &lt;code&gt;:write !{command}&lt;/code&gt;, &lt;code&gt;Ctrl+Z&lt;/code&gt; and &lt;code&gt;fg&lt;/code&gt; as well as tmux split windows. &lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2022-01-01T19:11:56.033" Title="Use case for neovim terminal emulator?" Tags="|terminal|neovim|" AnswerCount="5" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4646" PostTypeId="2" ParentId="4643" CreationDate="2015-09-05T10:52:50.760" Score="3" Body="&lt;p&gt;The best use case I can think of is the original one-an ADM-3a on a 110 bps line!  Sometimes there's really no substitute for looking at things side-by-side, and &lt;code&gt;:!r&lt;/code&gt; doesn't cut it.&lt;/p&gt;&#xA;" OwnerUserId="1430" LastActivityDate="2015-09-05T10:52:50.760" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4647" PostTypeId="2" ParentId="4643" CreationDate="2015-09-05T17:07:18.690" Score="6" Body="&lt;p&gt;I think the option to create terminal-only mappings is valuable, and extends the options you've got in other terminal emulators, e.g. mapping t to run unittests with specific configuration, which you can only achieve through complex aliases or bash functions.&lt;/p&gt;&#xA;" OwnerUserId="3188" LastActivityDate="2015-09-05T17:07:18.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4648" PostTypeId="1" CreationDate="2015-09-05T17:39:27.100" Score="3" ViewCount="1464" Body="&lt;p&gt;I know in Unix we can use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;z&lt;/kbd&gt; and &lt;code&gt;fg&lt;/code&gt; to switch between shell and Vim. But how to do that in powershell?&lt;/p&gt;&#xA;&lt;p&gt;There is a question about &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;z&lt;/kbd&gt; and &lt;code&gt;fg&lt;/code&gt; in Powershell &lt;a href=&quot;https://superuser.com/questions/465238/is-there-an-analog-of-bashs-ctrlz-fg-in-powershell&quot;&gt;is there an analog bash ctrl-z in powershell&lt;/a&gt;.&#xA;But the answer &lt;code&gt;psjob&lt;/code&gt; doesn't work as desired in this case.&lt;/p&gt;&#xA;&lt;p&gt;When I type &lt;code&gt;!psjob&lt;/code&gt;, it does return to the command line, but any key strokes will bring it back to Vim. So I can't really execute any command.&lt;/p&gt;&#xA;&lt;p&gt;Does any one know if there is a solution for this?&lt;/p&gt;&#xA;" OwnerUserId="3179" LastEditorUserId="23502" LastEditDate="2023-07-24T16:07:54.190" LastActivityDate="2023-07-24T16:07:54.190" Title="How to return to command line of Powershell from Vim?" Tags="|key-bindings|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4649" PostTypeId="2" ParentId="4648" CreationDate="2015-09-05T19:01:34.333" Score="3" Body="&lt;p&gt;I think you are asking the wrong thing here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The feature you mention is a feature of the shell and unixoid systems. &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;z&lt;/kbd&gt; advises the shell to stop the currently executed process (vim in your case). As there is no other process executed in the shell, you are back at your prompt and can work normally. The &lt;code&gt;fg&lt;/code&gt; command tells the shell to bring back the interrupted process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is by no means a feature of vim, but only of the shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, I doubt that the power shell has this feature. So you can only workaround by executing a command through vim with the exclamation mark. But that will probably be executed on windows &lt;code&gt;cmd.exe&lt;/code&gt; and not on powershell.&lt;/p&gt;&#xA;" OwnerUserId="826" LastEditorUserId="205" LastEditDate="2015-10-06T09:27:32.643" LastActivityDate="2015-10-06T09:27:32.643" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4650" PostTypeId="2" ParentId="4627" CreationDate="2015-09-05T19:19:56.197" Score="3" Body="&lt;p&gt;to put in &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldtext=MyFoldText()&#xA;function MyFoldText()&#xA;  let line = getline(v:foldstart)&#xA;  let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')&#xA;  return v:folddashes . sub&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;MyFoldText&lt;/code&gt; is now the function that is responsible for displaying some text, when some lines have been folded.&lt;/p&gt;&#xA;" OwnerUserId="1682" LastEditorUserId="1682" LastEditDate="2015-09-05T22:16:08.667" LastActivityDate="2015-09-05T22:16:08.667" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4651" PostTypeId="1" AcceptedAnswerId="4657" CreationDate="2015-09-05T20:05:52.023" Score="2" ViewCount="774" Body="&lt;p&gt;I want to use &lt;kbd&gt;F1&lt;/kbd&gt; in vim-gnome* on Ubuntu 14.04.2.  But when I press &lt;kbd&gt;F1&lt;/kbd&gt; I get Gnome &quot;help&quot;. It's stopping me from remapping &lt;kbd&gt;F1&lt;/kbd&gt; to something useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Searching reveals that the trick is to use dconf to map &lt;kbd&gt;F1&lt;/kbd&gt; to something else, but this doesn't work for me; it stops the help window from appearing but Gnome still seems to be stealing the key before Vim sees it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*: I've installed &lt;code&gt;vim-gnome&lt;/code&gt; because that's what you have to do if you want support for clipboard but can't be bothered building Vim from source. &lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastEditorUserId="4472" LastEditDate="2017-06-23T22:07:01.233" LastActivityDate="2017-06-23T22:07:01.233" Title="Remapping F1 on vim-gnome" Tags="|key-bindings|linux|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4653" PostTypeId="1" AcceptedAnswerId="4655" CreationDate="2015-09-06T02:12:58.693" Score="3" ViewCount="4297" Body="&lt;p&gt;I have the following lines in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; No annoying sound on errors&#xA;set noerrorbells&#xA;set novisualbell&#xA;set t_vb=&#xA;set tm=500&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which I believe should disable all visual/audio bells and flashes. However, vim still flashes when I'm on the first line and try to move up (&lt;code&gt;k&lt;/code&gt;) or on the last line and try to move down (&lt;code&gt;j&lt;/code&gt;). If I turn off visual flashes in my terminal profile preferences the behavior stops so this is not a redraw issue or something else. Why is this still happening?&lt;/p&gt;&#xA;" OwnerUserId="3354" LastActivityDate="2015-09-06T10:41:09.920" Title="Vim Still Flashing When It Shouldn't Be" Tags="|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4654" PostTypeId="1" CreationDate="2015-09-06T10:22:14.970" Score="2" ViewCount="999" Body="&lt;p&gt;I'd like to &lt;code&gt;diff&lt;/code&gt; large files in vim using the scrollback limit set in my terminal (which is available memory), so I can, if necessary, find and review previously applied changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use OS X's Terminal set to &lt;code&gt;xterm-256color&lt;/code&gt; (modified, &lt;code&gt;alternate screen&lt;/code&gt; is disabled).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't find any settings to make the initial windows the same size as the opened files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A workaround for single files is using &lt;a href=&quot;https://bitheap.org/mouseterm/&quot; rel=&quot;nofollow&quot;&gt;MouseTerm&lt;/a&gt; to enable mouse reporting, then add to your &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;mouse&quot;)&#xA;    set mouse=a&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;vimdiff&lt;/code&gt; this allows to easily scroll long files, but the text is not kept in the scrollback, although it does for single files.&lt;/p&gt;&#xA;" OwnerUserId="4432" LastEditorUserId="4432" LastEditDate="2015-10-24T19:49:48.077" LastActivityDate="2015-10-24T19:49:48.077" Title="Can vimdiff show large files beyond screenful limits at once?" Tags="|terminal|vimdiff|large-documents|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4655" PostTypeId="2" ParentId="4653" CreationDate="2015-09-06T10:31:11.970" Score="7" Body="&lt;p&gt;Recent Vims have the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27belloff%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'belloff'&lt;/code&gt;&lt;/a&gt; setting. Simply set it to all to disable all bells:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set belloff=all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should fix the flashing issue for you. This needs a &lt;a href=&quot;http://ftp.vim.org/vim/patches/7.4/7.4.793&quot; rel=&quot;noreferrer&quot;&gt;Vim 7.4 &gt; 793 patchlevel&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the help at &lt;code&gt;:h 'belloff'&lt;/code&gt; for all the possible values.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="205" LastEditDate="2015-09-06T10:41:09.920" LastActivityDate="2015-09-06T10:41:09.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4656" PostTypeId="2" ParentId="4653" CreationDate="2015-09-06T10:32:25.847" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27visualbell%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h visualbell&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Use visual bell instead of beeping.  The terminal code to display the&#xA;visual bell is given with 't_vb'.  When no beep or flash is wanted,&#xA;use &quot;:set vb t_vb=&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the last sentence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should, instead, do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noerrorbells&#xA;set visualbell&#xA;set t_vb=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Disabling &lt;code&gt;visualbell&lt;/code&gt; enabled audio beeps, and the terminal emulator probably converted that to flashing.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-09-06T10:32:25.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4657" PostTypeId="2" ParentId="4651" CreationDate="2015-09-06T11:05:40.703" Score="2" Body="&lt;p&gt;I think gnome and the gnome-terminal intercept the keypresses, so that those keys never get through to Vim. &lt;a href=&quot;https://askubuntu.com/a/244786&quot;&gt;This answer on Ask Ubuntu&lt;/a&gt; shows how to disable this specifically for gnome and the gnome-terminal.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.647" LastActivityDate="2015-09-06T11:05:40.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4658" PostTypeId="2" ParentId="4654" CreationDate="2015-09-06T13:46:24.490" Score="1" Body="&lt;p&gt;it might work using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set lines=1000 columns=100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where your line number is your scrollback limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you can &quot;cheat&quot; using screen, setting it to a way higher height than vim's default. I'm sure that there is a config option to set LINES and COLUMNS (as it does not use the env variables), but using a terminal to set it with a very small font, and opening it in another terminal using &lt;code&gt;screen -x&lt;/code&gt; should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;though, I do not really see why you'd want to abuse the scrollback, when vim can properly manage the mouse within the terminal. Just do &lt;code&gt;:set mouse=a&lt;/code&gt; to have it take over full mouse control.&lt;/p&gt;&#xA;" OwnerUserId="4434" LastEditorUserId="4434" LastEditDate="2015-09-10T06:40:36.243" LastActivityDate="2015-09-10T06:40:36.243" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4659" PostTypeId="1" CreationDate="2015-09-06T14:19:55.957" Score="4" ViewCount="613" Body="&lt;p&gt;I am using Vim to edit Fortran 90 code. The code is structured in the following manner:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;./srcs&lt;/code&gt; - contains main code file &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;./libs&lt;/code&gt; - contains some module file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I open the main file in Vim and then find some interesting function and press &lt;code&gt;gD&lt;/code&gt; Vim cannot find this function since it does not know where to search. If I copy all the source files to one folder this option does work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How do I tell Vim where my code is?&lt;/li&gt;&#xA;&lt;li&gt;Can you suggest for a quick manner on how to work with this kind of folder without repeating the use of solution (1)?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Other tips and or suggestions of working with Vim to edit Fortran projects will be very much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks Rami&lt;/p&gt;&#xA;" OwnerUserId="4435" LastEditorUserId="4472" LastEditDate="2017-09-26T07:42:16.977" LastActivityDate="2017-09-26T07:42:16.977" Title="Using Vim gD on project with multiple folders" Tags="|multiple-files|filetype-fortran|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4660" PostTypeId="2" ParentId="4637" CreationDate="2015-09-06T14:58:46.753" Score="25" Body="&lt;p&gt;Another solution is when in command line mode, use &lt;code&gt;Ctrl-f&lt;/code&gt;, and press &lt;code&gt;q&lt;/code&gt; to stop recording. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Ctrl-f&lt;/code&gt; allows you to open the command line window, in which you can edit the command in normal mode. To validate the command, simply use enter.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Therefore, after having added something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;c-q&amp;gt; &amp;lt;c-f&amp;gt;i&amp;lt;c-o&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your &lt;code&gt;.vimrc&lt;/code&gt;, you can use &lt;code&gt;&amp;lt;c-q&amp;gt;&lt;/code&gt; to stop recording a macro while in command mode.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Florent&lt;/p&gt;&#xA;" OwnerUserId="4437" LastEditorUserId="2978" LastEditDate="2015-09-07T13:25:13.800" LastActivityDate="2015-09-07T13:25:13.800" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4661" PostTypeId="2" ParentId="4659" CreationDate="2015-09-06T15:23:40.433" Score="3" Body="&lt;p&gt;According to &lt;code&gt;:h 29.5&lt;/code&gt;, &lt;code&gt;gd&lt;/code&gt; and &lt;code&gt;gD&lt;/code&gt; should work only in the current file, while &lt;code&gt;[I&lt;/code&gt; will look in included files. Yet, it seem to work for you (if you copy all files in a single folder).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, put this in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path-=./libs&#xA;set path+=./libs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This adds your &lt;code&gt;./libs&lt;/code&gt; folder to the &lt;code&gt;path&lt;/code&gt; variable.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-09-06T15:23:40.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4662" PostTypeId="1" AcceptedAnswerId="4663" CreationDate="2015-09-06T20:36:32.243" Score="3" ViewCount="2376" Body="&lt;p&gt;I used &lt;code&gt;set colorcolumn=80&lt;/code&gt; and set the color to red in the python.vim file. Works like a champ - even for all other files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd also like to &lt;code&gt;set colorcolumn=110&lt;/code&gt; for C files though; this one has been set to darkgray for color separation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems the &lt;a href=&quot;https://github.com/todd-dsm/vimSimple/blob/master/vim/after/loadlangs.vim&quot; rel=&quot;nofollow&quot;&gt;order of loading&lt;/a&gt; is the problem; if &lt;a href=&quot;https://github.com/todd-dsm/vimSimple/blob/master/vim/after/langs/python.vim&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;python.vim&lt;/code&gt;&lt;/a&gt; loads last, its column and color are used; if &lt;code&gt;clang.vim&lt;/code&gt; is loaded last, then it stomps the &lt;code&gt;python.vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turning the dial back, I've been diddling with my own tailored vim setup for quite a while now. I clearly got a little carried away with the modularity; that notwithstanding:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Within the existing context, how would one make this change so it's language specific?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4442" LastEditorUserId="205" LastEditDate="2015-09-07T06:11:48.683" LastActivityDate="2015-09-08T04:25:36.053" Title="Language-Specific Configuration: ColorColumn" Tags="|vimrc|autocmd|" AnswerCount="1" CommentCount="0" ClosedDate="2015-09-07T06:10:55.947" ContentLicense="CC BY-SA 3.0" />
  <row Id="4663" PostTypeId="2" ParentId="4662" CreationDate="2015-09-06T20:50:46.200" Score="7" Body="&lt;p&gt;the standard way to do this is to create &lt;code&gt;autocommands&lt;/code&gt; groups:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup python&#xA;    au! &quot; clear augroup when reloading vimrc&#xA;    autocmd FileType python set colorcolumn=80&#xA;augroup END&#xA;&#xA;augroup cc&#xA;    au! &quot; clear augroup when reloading vimrc&#xA;    autocmd FileType c,cpp set colorcolumn=110&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is a way to execute specific commands for a given filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But as you want to source specific files given a filetype, then you should use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/ftplugin/python.vim&#xA;~/.vim/ftplugin/clang.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to load your personal commands.&lt;/p&gt;&#xA;" OwnerUserId="4434" LastEditorUserId="4442" LastEditDate="2015-09-08T04:25:36.053" LastActivityDate="2015-09-08T04:25:36.053" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4664" PostTypeId="1" AcceptedAnswerId="4665" CreationDate="2015-09-06T21:02:20.953" Score="4" ViewCount="412" Body="&lt;p&gt;A very common use case I'm having is to copy something (let's say a word) and I want to paste it in another context (let's say a word with quotes). The way I do it is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char *foobar(void) {&#xA;    return &quot;barfoo&quot;;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;there, as my cursor is on foobar:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char *foo|bar(void) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yiw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to copy content. Then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to move within the returned string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    return &quot;bar|foo&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then I should do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi&quot;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to paste &lt;code&gt;foobar&lt;/code&gt; within the quotes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    return &quot;foobar|&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is whether there's a way to use a motion to &lt;code&gt;put&lt;/code&gt;, the same way it is possible to &lt;code&gt;yank&lt;/code&gt;, what I'd love to do is something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pi&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which obviously wouldn't work. I find it feels weird to have to use a visual to apply a paste within a motion, but everybody I asked told me it's not possible. If it is indeed not, what would be the rationale of having the action &lt;code&gt;put&lt;/code&gt; not accepting a motion‽&lt;/p&gt;&#xA;" OwnerUserId="4434" LastActivityDate="2015-09-06T22:44:59.950" Title="Use motion when putting" Tags="|cut-copy-paste|cursor-motions|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4665" PostTypeId="2" ParentId="4664" CreationDate="2015-09-06T22:44:59.950" Score="3" Body="&lt;p&gt;Well, assuming &lt;code&gt;pi&quot;&lt;/code&gt; would work, it would then mean that you will need at least 2 chars to simply put at cursor position - you can't simply use &lt;code&gt;p&lt;/code&gt; by itself! (which is, after all, the most often used paste operation). With yank, it's clear you have to copy &quot;something&quot;, so there is an asymmetry between the two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, with Kana's &lt;a href=&quot;https://github.com/kana/vim-operator-replace&quot; rel=&quot;nofollow&quot;&gt;operator replace&lt;/a&gt;, you can simply do something like &lt;code&gt;_i&quot;&lt;/code&gt; to replace text with previous yanked text from default register. Or &lt;code&gt;__&lt;/code&gt; to replace a line&#xA;(assuming you mapped &lt;code&gt;_&lt;/code&gt; as the docs suggest).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-09-06T22:44:59.950" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4666" PostTypeId="1" CreationDate="2015-09-07T00:31:46.147" Score="4" ViewCount="3121" Body="&lt;p&gt;I am using Vim on Arch Linux. One thing I like to do is using my transparent terminal I can be editing a latex file and have it automatically compiling and showing behind what I am writing. Is there a way to get the same transparency in gVim? What option should I add to my &lt;code&gt;.gvimrc&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to ensure proper transparency in terminal all I set is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:solarized_termtrans=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3354" LastEditorUserId="24" LastEditDate="2015-09-11T04:54:46.777" LastActivityDate="2015-09-11T04:54:46.777" Title="How to Make gVim Transparent" Tags="|gvim|colorscheme|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4667" PostTypeId="1" AcceptedAnswerId="4671" CreationDate="2015-09-07T05:25:06.090" Score="0" ViewCount="1452" Body="&lt;p&gt;Basically I'm transposing my one record with many columns to many records in one column. A non-whitespace character begins a Word. I'm using gVim on Win7 so I need to use &lt;code&gt;CTRL-Q&amp;lt;CR&amp;gt;&lt;/code&gt; as my new line character. The number of spaces between words is not constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My attempt: &lt;code&gt;:%s/\S/&amp;lt;CTRL-Q&amp;gt;&amp;lt;CR&amp;gt;\S/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Questions&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why does my attempt not work?&lt;/li&gt;&#xA;&lt;li&gt;How can I do this in gVim?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Convert&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo  1true   0false +pos -neg ++dblpos    (lefp        }rcurl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; foo &#xA; 1true &#xA; 0false &#xA; +pos &#xA; -neg &#xA; ++dblpos &#xA; (lefp &#xA; }rcurl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1132" LastActivityDate="2015-09-07T22:21:12.657" Title="How to put each Word in a varying space delimited file on a new line?" Tags="|gvim|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4668" PostTypeId="1" AcceptedAnswerId="4677" CreationDate="2015-09-07T08:11:03.070" Score="1" ViewCount="398" Body="&lt;p&gt;How to let the cursor push the screen instead of the the screen drag the cursor when scrolling with the mouse?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I switched to iterm 2 on osx, but in the regular osx terminal when i scroll the scrolling moves the cursor not the window. In iterm 2 it only scrolls the window. I can't find the setting to set this back again. I found &lt;code&gt;set mouse=a&lt;/code&gt; but this doesn't do the trick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify I do not want a scroll offset. I want the physical scroll action to move the cursor not the screen.&lt;/p&gt;&#xA;" OwnerUserId="3322" LastEditorUserId="205" LastEditDate="2015-09-08T11:32:54.270" LastActivityDate="2015-09-08T11:32:54.270" Title="How to let the cursor push the screen instead of the the screen drag the cursor when scrolling with the mouse?" Tags="|scrolling|mouse|iterm2|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4669" PostTypeId="1" CreationDate="2015-09-07T08:56:28.843" Score="10" ViewCount="7703" Body="&lt;p&gt;Text marked as&lt;code&gt;__bold__&lt;/code&gt; or &lt;code&gt;_italic_&lt;/code&gt; appears in the same color as normal text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Headings and code do show up in different colors, so vim correctly recognizes the file as markdown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is no matter what colorscheme I use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to make text marked as bold or italic in Markdown, highlighted in their own colors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I'm using a full vim install (not vim-tiny) version 7.4 on Xubuntu Linux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what it looks like. While the previous lines show that headings etc. work, line 22-26 contain text that should have been highlighted differently than the default - this is in &lt;code&gt;:colorscheme default&lt;/code&gt; but it doesn't work in others either&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ldPDu.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ldPDu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4446" LastEditorUserId="4446" LastEditDate="2015-09-07T23:05:13.843" LastActivityDate="2016-03-01T07:16:58.190" Title="Markdown: how to syntax-highlight Bold and Italic in different color than normal text?" Tags="|syntax-highlighting|filetype-markdown|" AnswerCount="2" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4671" PostTypeId="2" ParentId="4667" CreationDate="2015-09-07T22:21:12.657" Score="3" Body="&lt;p&gt;It would be simpler if:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You set the &lt;code&gt;fileformat&lt;/code&gt; to &lt;code&gt;unix&lt;/code&gt;, so that Vim takes care of line endings;&lt;/li&gt;&#xA;&lt;li&gt;You replace the whitespace instead of the non-whitespace characters.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set fileformat=unix&#xA;:%s/\s\+/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;\r&lt;/code&gt; is in the replacement of a substitute command, Vim will pick the appropriate line ending for the file format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your attempt would not have worked, since &lt;code&gt;\S&lt;/code&gt; in the replacement is just &lt;code&gt;S&lt;/code&gt;, not the character that matched.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-09-07T22:21:12.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4672" PostTypeId="1" AcceptedAnswerId="4692" CreationDate="2015-09-08T04:22:36.600" Score="5" ViewCount="2413" Body="&lt;p&gt;Consider the following vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DecideWhetherToStrip()&#xA;    let l:search = @/&#xA;    &quot; Check if a file being opened has trailing spaces in the first place.&#xA;    let b:dostrip = !search('\s\+$', 'npw')&#xA;    let @/ = l:search&#xA;endfunction&#xA;&#xA;function! StripTrailingWhitespace()&#xA;    if b:dostrip&#xA;        let l:search = @/&#xA;        let l:winview = winsaveview()&#xA;        %s/\s\+$//e            &quot; Kill spaces at EOL&#xA;        %s/\($\n\s*\)\+\%$//e  &quot; Kill lines at EOF&#xA;        let @/ = l:search&#xA;        call winrestview(l:winview)&#xA;    endif&#xA;endfunction&#xA;&#xA;augroup whitespace&#xA;    autocmd!&#xA;    autocmd BufReadPost * call DecideWhetherToStrip()&#xA;    autocmd BufWritePre * call StripTrailingWhitespace()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;StripTrailingWhitespace&lt;/code&gt; function is probably familiar to many people as I've mostly stolen it from the internet, but the &lt;code&gt;DecideWhetherToStrip&lt;/code&gt; and the &lt;code&gt;b:dostrip&lt;/code&gt; variable were put together by me, just now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The intention of this code is that I want to detect whether a newly opened file contains trailing whitespace, and then only strip trailing whitespace if the file didn't have any to begin with. This is because I need to edit certain files that actually require trailing whitespace, but for the most part I want files to start clean and stay clean. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: does this code work the way I think it does? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems to work in my preliminary testing but I'm worried that there will be unexpected surprises down the line, in certain corner cases. Like what if I have two files open, one with &lt;code&gt;b:dostrip&lt;/code&gt; set to &lt;code&gt;1&lt;/code&gt;, and one &lt;code&gt;0&lt;/code&gt;. How does &lt;code&gt;StripTrailingWhitespace&lt;/code&gt; know which buffer it's operating on? What if two files are modified and I call &lt;code&gt;:wall!&lt;/code&gt;, is &lt;code&gt;autocmd&lt;/code&gt; smart enough to call &lt;code&gt;StripTrailingWhitespace&lt;/code&gt; once each with each buffer active? Or will I run into issues where &lt;code&gt;StripTrailingWhitespace&lt;/code&gt; will only be called once with the setting from one buffer but will actually modify both buffers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any other failure modes to this code I should be wary of?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="4458" LastActivityDate="2016-03-04T00:00:08.547" Title="How does vimscript know which buffer these buffer-local variables use?" Tags="|vimscript|buffers|whitespace|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4673" PostTypeId="1" AcceptedAnswerId="4681" CreationDate="2015-09-08T05:23:34.143" Score="1" ViewCount="986" Body="&lt;p&gt;I am using the &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow&quot;&gt;vim-fugitive&lt;/a&gt; plugin and I encounter a strange behaviour. I don't know if it's really related to the plugin or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to open the &lt;code&gt;Gstatus&lt;/code&gt; page in a new tab. So I am creating a new tab and call Gstatus on the new tab : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabnew | Gstatus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I get the following error :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E492: Not an editor command: Gstatus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you know what might cause the issue and how to fix it ? &#xA;I can create a function to achieve this behavior, but I wanted to keep a mapping like the one I currently use : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;gs tabnew | Gstatus&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When starting vim inside a git directory without a file, the &lt;code&gt;Gstatus&lt;/code&gt; works.&lt;/li&gt;&#xA;&lt;li&gt;When creating a new tab and running &lt;code&gt;Gstatus&lt;/code&gt; by hand, the command failed, even if the &lt;code&gt;pwd&lt;/code&gt; command shows the good directory.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-09-08T11:18:06.620" LastActivityDate="2022-10-02T21:54:02.357" Title="Open Gstatus in new tab" Tags="|command-line|plugin-fugitive|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4674" PostTypeId="1" AcceptedAnswerId="4691" CreationDate="2015-09-08T05:23:55.407" Score="0" ViewCount="1339" Body="&lt;p&gt;I have been using the plugin called Ultisnips and it is great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I am looking for the following feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I have two files &lt;code&gt;history.tex&lt;/code&gt; and &lt;code&gt;geography.tex&lt;/code&gt; which I edit regularly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to have snippets for each of them but I want them to be independent of each other. What I mean by this is that if I am working on &lt;code&gt;history.tex&lt;/code&gt;, a snippet named &lt;code&gt;samplesnip&lt;/code&gt; serves some purpose while when I am working on &lt;code&gt;geography.tex&lt;/code&gt; the snippet named &lt;code&gt;samplesnip&lt;/code&gt; serves a completely different purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now what I have is a file named &lt;code&gt;tex.snippets&lt;/code&gt; where all my snippets for tex files go. So I do not have the kind of flexibility that I want.&lt;/p&gt;&#xA;" OwnerUserId="2369" LastActivityDate="2015-09-09T16:52:58.850" Title="How to Write File Name Specific Snippets Using UltiSnips or Otherwise" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4675" PostTypeId="1" AcceptedAnswerId="4676" CreationDate="2015-09-08T08:27:39.073" Score="4" ViewCount="1625" Body="&lt;p&gt;Yesterday I'm trying to make a doc command abbreviation for python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The original command is &lt;code&gt;normal 0i&quot;&quot;&quot;^M&quot;&quot;&quot;&lt;/code&gt;, which works in command-line mode.&lt;br&gt;&#xA;But failed when using alias &lt;code&gt;doc&lt;/code&gt; defined by &lt;code&gt;ca doc normal 0i&quot;&quot;&quot;^M&quot;&quot;&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And later, I find I need to quit insert mode, do some movement, and then enter insert mode again.&lt;br&gt;&#xA;The command &lt;code&gt;normal 0i&quot;&quot;&quot;^[$a^M&quot;&quot;&quot;&lt;/code&gt; failed both in command-line mode and with alias.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I deal with &lt;code&gt;^M&lt;/code&gt; and &lt;code&gt;^[&lt;/code&gt; in normal command alias,&lt;br&gt;&#xA;and how should I manipulate insert mode quit and enter again action with normal command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: The &lt;code&gt;^M&lt;/code&gt; and &lt;code&gt;^[&lt;/code&gt; character was made by combining &lt;code&gt;CTRL-V&lt;/code&gt; + &lt;code&gt;Enter&lt;/code&gt;/&lt;code&gt;Esc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3085" LastEditorUserId="3085" LastEditDate="2015-09-08T12:23:05.170" LastActivityDate="2015-09-08T12:23:05.170" Title="How to abbreviate(ca) normal command with &quot;Esc&quot; and &quot;Enter&quot; key?" Tags="|command-line|normal-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4676" PostTypeId="2" ParentId="4675" CreationDate="2015-09-08T09:27:28.750" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;And later, I find I need to quit insert mode, do some movement, and then  ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not sure where you found that from, but it's the other way around - you should quit insert mode before ending a &lt;code&gt;:normal&lt;/code&gt; command, otherwise &lt;code&gt;:normal&lt;/code&gt; will cancel the last operation. From &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3Anormal&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :normal&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{commands} should be a complete command.  If&#xA;{commands} does not finish a command, the last one&#xA;will be aborted as if &amp;lt;Esc&amp;gt; or &amp;lt;C-C&amp;gt; was typed.&#xA;This implies that an insert command must be completed&#xA;(to start Insert mode, see :startinsert).  A &quot;:&quot;&#xA;command must be completed as well.  And you can't use&#xA;&quot;Q&quot; or &quot;gQ&quot; to start Ex mode.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, your original command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ca doc normal 0i&quot;&quot;&quot;^M&quot;&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;using an abbreviation instead of a proper command, &lt;code&gt;^M&lt;/code&gt; will be taken assumed to end the &lt;code&gt;normal&lt;/code&gt; command (the way it would be if you'd actually typed it), and not be a part of it. Then you'd have to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ca doc normal 0i&quot;&quot;&quot;&amp;lt;cr&amp;gt;&quot;&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#map_return&quot; rel=&quot;nofollow&quot;&gt;the &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; code&lt;/a&gt; available for maps and abbreviations.&#xA;Though I think you'd be better off using a normal-mode map instead of using a command-mode one. Or use a proper command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Doc normal 0i&quot;&quot;&quot;&amp;lt;cr&amp;gt;&quot;&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can use the &lt;code&gt;:Doc&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-09-08T09:27:28.750" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4677" PostTypeId="2" ParentId="4668" CreationDate="2015-09-08T10:23:20.243" Score="1" Body="&lt;p&gt;How about&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;ScrollWheelUp&amp;gt; k&#xA;nnoremap &amp;lt;ScrollWheelDown&amp;gt; j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;? I can't test on osx though, but it works on my linux installation.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastActivityDate="2015-09-08T10:23:20.243" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4678" PostTypeId="2" ParentId="1887" CreationDate="2015-09-08T11:56:59.310" Score="1" Body="&lt;p&gt;See &lt;a href=&quot;http://vim.wikia.com/wiki/Changing_case_with_regular_expressions&quot; rel=&quot;nofollow&quot;&gt;http://vim.wikia.com/wiki/Changing_case_with_regular_expressions&lt;/a&gt;&#xA;It explains the \U, \L, \u, \l modifiers quite clearly and succinctly!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its essence is the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are times that you might like to go through a file and change the case of characters that match some arbitrary criteria. If you understand regular expressions well, you can actually do this fairly easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's as simple as placing \U or \L in front of backreferences which you want to change the case of, and \E at the end. Vim will make the text in the backreference uppercase or lowercase (respectively). Use \u and \l (without the \E at the end) to just change the case of the very first character in the backreference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(A &quot;backreference&quot; is a part of a regular expression that refers to a previous part of a regular expression. The most common backreferences are &amp;amp;, \1, \2, \3, ... , \9).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some examples that demonstrate the power of this technique:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lowercase the entire file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;:%s/.*/\L&amp;/g&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&amp;amp; is a handy backreference that refers to the complete text of the match.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Uppercase all words that are preceded by a &amp;lt; (i.e. opening HTML tag names):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;lt;\(\w*\)/&amp;lt;\U\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note also the gu and gU commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, ggguG will lowercase the entire file.&#xA;(gg = go to top, gu = lowercase, G = go to EOF).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By using the \0 general backref instead of the name ones (\1, \2 etc) you can save some typing for on replace stanza of the regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This regex upper cases an explicit set of words to uppercase in a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(select\)\|\(order)\|\(by\)\|\(from\)\|\(where\)/\U\0/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not rocket science, but otherwise you'd have to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(select\)\|\(order)\|\(by\)\|\(from\)\|\(where\)/\U\1\U\2\U\3\U\4\U\5/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4462" LastEditorUserId="28" LastEditDate="2015-09-09T02:21:19.660" LastActivityDate="2015-09-09T02:21:19.660" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4679" PostTypeId="1" AcceptedAnswerId="4685" CreationDate="2015-09-08T11:59:05.537" Score="4" ViewCount="360" Body="&lt;p&gt;I have openend a zip archive with vim (zip.vim v27) and now want to replace a string in all files contained in the archive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware that I could manually open all files in buffers and then do &lt;code&gt;bufdo %s/foo/bar/g | update&lt;/code&gt;, or that I could unpack the archive, execute &lt;code&gt;vim `find . -type f`&lt;/code&gt;, execute the above &lt;code&gt;bufdo&lt;/code&gt;, and repack the files. Is there anything simpler than that?&lt;/p&gt;&#xA;" OwnerUserId="117" LastEditorUserId="1841" LastEditDate="2016-10-14T15:21:04.437" LastActivityDate="2016-10-14T15:21:04.437" Title="How do I perform a replacement on all files in a zip archive?" Tags="|binary-file|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4680" PostTypeId="2" ParentId="4673" CreationDate="2015-09-08T14:50:27.580" Score="5" Body="&lt;p&gt;I'll just quote from the official plugin FAQ:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;FAQ&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Q: I installed the plugin and started Vim. Why don't any of the commands&#xA;  exist?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A: Fugitive cares about the current file, not the current working&#xA;  directory. Edit a file from the repository.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Q: I opened a new tab. Why don't any of the commands exist? &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A: Fugitive&#xA;  cares about the current file, not the current working directory. Edit&#xA;  a file from the repository.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It doesn't matter if you are, or not, in a Git controlled folder. &lt;code&gt;:Gstatus&lt;/code&gt; is a buffer-local command, it will only be available if the currently loaded buffer deals with a file which is under git revision control. Therefore, when you open a new tab, the current buffer is an empty one, and &lt;code&gt;:Gstatus&lt;/code&gt; is not defined.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-09-08T14:50:27.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4681" PostTypeId="2" ParentId="4673" CreationDate="2015-09-08T15:23:17.543" Score="7" Body="&lt;p&gt;Using &lt;code&gt;&amp;lt;c-w&amp;gt;T&lt;/code&gt; to promote a window to a new tab.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;gs :Gstatus&amp;lt;cr&amp;gt;&amp;lt;c-w&amp;gt;T&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see &lt;code&gt;:h CTRL-W_T&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-09-08T16:00:35.900" LastActivityDate="2015-09-08T16:00:35.900" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4682" PostTypeId="1" AcceptedAnswerId="11722" CreationDate="2015-09-08T18:18:43.897" Score="20" ViewCount="4069" Body="&lt;p&gt;When using Vim to read from stdin, it prints a informative message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo foo | vim -&#xA;Vim: Reading from stdin...&#xA;&#xA;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This is just an example. The actual use doesn't allow shell constructs.&lt;/strong&gt; &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_dev/MATXOzr2AdM&quot;&gt;&lt;code&gt;vim &amp;lt;(echo foo)&lt;/code&gt;&lt;/a&gt; is not an option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I suppress that using &lt;em&gt;only&lt;/em&gt; Vim options and/or vimrc settings?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In case you do need to know what this is for, I'm trying to use &lt;a href=&quot;http://murukesh.me/2015/08/28/vim-for-man.html&quot;&gt;Vim for reading manpages&lt;/a&gt; (shameless plug). GNU man doesn't allow shell constructs in &lt;code&gt;MANPAGER&lt;/code&gt;, and by using &lt;code&gt;ftplugin/man.vim&lt;/code&gt; and other things, I have successfully managed to have a comfortable experience using just &lt;code&gt;MANPAGER=&quot;vim -&quot;&lt;/code&gt;. The last remaining annoyance is the unsightly message printed after every manpage that I viewed.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="4472" LastEditDate="2022-07-21T20:55:29.830" LastActivityDate="2022-07-21T20:55:29.830" Title="How can I suppress the &quot;reading from STDIN&quot; message from within Vim?" Tags="|vimrc|options|manpages|" AnswerCount="4" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4683" PostTypeId="1" AcceptedAnswerId="4686" CreationDate="2015-09-08T23:19:10.770" Score="3" ViewCount="2189" Body="&lt;p&gt;Following on from &lt;a href=&quot;https://vi.stackexchange.com/questions/4602/put-variable-to-line-above-current-line-vim/4603#4603&quot;&gt;Put variable to line above current line VIm&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added some logic to only run if the begin and end tags in the list are present, snippet&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;....&#xA;let findStart='&amp;lt;'.taglist[s1].'&amp;gt;'&#xA;let findEnd='&amp;lt;'.'\/'.ns.taglist[s1].'&amp;gt;'&#xA;&#xA;let fs=0&#xA;let fe=0&#xA;&#xA;&#xA;while something&#xA;  let fs=search(expand(findStart))&#xA;  let fe=search(expand(findEnd))&#xA;  if ( &amp;amp;fs&amp;gt;0 &amp;amp;&amp;amp; &amp;amp;fe&amp;gt;0 )&#xA;      call search(findStart,'b')&#xA;      &quot;paste the beginning fold&#xA;      :-1put =foldbegin&#xA;      .....&#xA;      :let fs=0&#xA;      :let fe=0&#xA;  endif &#xA;let something=something +1&#xA;endwhile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In modeline this &lt;code&gt;:let fs=0|:call search('&amp;lt;')|echo fs&lt;/code&gt; returns the position of the search. In Vimscript the only way I can use the variable in an if statement is &lt;code&gt;if ( &amp;amp;fs&amp;gt;0 ... )&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find anything to explain why the statements work differently so I can make sense of it. Any suggestions of where to look for answers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also  &lt;code&gt;:let fs=0&lt;/code&gt; within the if doesn't reset the variable. Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: It's something to do with using 2 letter variables but I don't know what the issue is despite googling it.&lt;/p&gt;&#xA;" OwnerUserId="1313" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-09-09T18:17:06.650" Title="How do I access variables in if statements?" Tags="|vimscript|gvim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4684" PostTypeId="2" ParentId="4643" CreationDate="2015-09-08T23:39:38.440" Score="10" Body="&lt;p&gt;Running a terminal inside Vim allows you to use Vim commands on the input and output to the programs that you run in that terminal. You get search, copy-paste, macros, syntax coloring, etc. Using &lt;code&gt;:read !{command}&lt;/code&gt; and &lt;code&gt;:write !{command}&lt;/code&gt; gives you that for one-shot commands, but asynchronous input/output becomes useful when you want to submit input to an external program piece by piece.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The typical use case is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop&quot;&gt;read-eval-print loop&lt;/a&gt; (REPL), which is provided by many high-level programming languages. You type a stanza in your source code, then feed it to the REPL for immediate feedback. Since the REPL keeps running from one submission to the next, the submitted code snippet are executed in context.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2015-09-08T23:39:38.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4685" PostTypeId="2" ParentId="4679" CreationDate="2015-09-08T23:48:33.813" Score="7" Body="&lt;p&gt;One approach is to let your operating system mount the zip file as a directory. Then the problem reduces to applying the transformation to all the files in that directory (and its subdirectories).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most modern Unix systems (including Linux and OS X) support &lt;a href=&quot;https://en.wikipedia.org/wiki/Filesystem_in_Userspace&quot; rel=&quot;nofollow noreferrer&quot;&gt;FUSE&lt;/a&gt;, which allows user code to implement filesystems. For example, you can use [fuse-zip]:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Create an empty directory where the zip file will be mounted.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir mnt&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Mount the zip file to that directory.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fuse-zip foo.zip mnt&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Read and modify files in &lt;code&gt;mnt&lt;/code&gt; as desired.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When you're done, unmount the zip file from the directory.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fusermount -u mnt&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;An alternative to fuse-zip is &lt;a href=&quot;http://www.cybernoia.de/software/archivemount/&quot; rel=&quot;nofollow noreferrer&quot;&gt;archivemount&lt;/a&gt;. Windows has a &lt;a href=&quot;https://superuser.com/questions/367540/tool-to-mount-a-zip-rar-archive-as-a-win-drive-and-be-able-to-read-write-as-a&quot;&gt;somewhat similar feature&lt;/a&gt; that allows mounting a zip file as a drive with third-party software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To act on all the files in a directory tree, you can use &lt;a href=&quot;http://vim.wikia.com/wiki/Search_and_replace_in_multiple_buffers#All_files_in_a_tree&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:args&lt;/code&gt; and &lt;code&gt;:argdo&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args mnt/**/*&#xA;:argdo %s/foo/bar/g | update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2015-09-08T23:48:33.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4686" PostTypeId="2" ParentId="4683" CreationDate="2015-09-09T06:16:17.877" Score="3" Body="&lt;p&gt;It would help, if you could include the error message in your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using '&amp;amp;variables' you are effectively accessing option values. See the help at &lt;code&gt;:h expr-option&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in your if statement you should &lt;strong&gt;not&lt;/strong&gt; use &lt;code&gt;if &amp;amp;fs&lt;/code&gt; if you want to check a variable and not the option value 'fsync', but using &amp;amp;fe will cause an error, because there exists no option with that (short-)name.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-09T06:16:17.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4687" PostTypeId="2" ParentId="4682" CreationDate="2015-09-09T08:09:23.670" Score="12" Body="&lt;p&gt;The answer to your &lt;em&gt;exact&lt;/em&gt; question:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I suppress that using only Vim options and/or vimrc settings?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;is: no, it's &lt;em&gt;not&lt;/em&gt; possible because of the following part of the &lt;a href=&quot;https://github.com/vim/vim/blob/fc53ec1e9aac682a8524698240ed2bb6f7b0e300/src/fileio.c#L800&quot;&gt;code&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if (read_stdin)&#xA;    {&#xA;#ifndef ALWAYS_USE_GUI&#xA;        mch_msg(_(&quot;Vim: Reading from stdin...\n&quot;));&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which means that if you give &lt;code&gt;-&lt;/code&gt; as argument to vim, then it'll mechanically show that message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;though, as a work around, if you use a file redirection instead of the &lt;code&gt;-&lt;/code&gt; argument you'll get rid of the message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;foo&quot; | vim &amp;lt; /dev/tty&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and here's an example of &lt;code&gt;MANPAGE&lt;/code&gt; setting that just works™ (taken from the intertubes):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export MANPAGER='bash -c &quot;vim -MRn -c \&quot;set ft=man nomod nolist nospell nonu\&quot; -c \&quot;nm q :qa!&amp;lt;CR&amp;gt;\&quot; -c \&quot;nm &amp;lt;end&amp;gt; G\&quot; -c \&quot;nm &amp;lt;home&amp;gt; gg\&quot;&amp;lt;/dev/tty &amp;lt;(col -b)&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4434" LastActivityDate="2015-09-09T08:09:23.670" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4689" PostTypeId="1" AcceptedAnswerId="4690" CreationDate="2015-09-09T15:08:24.733" Score="25" ViewCount="29061" Body="&lt;p&gt;I have a &lt;code&gt;~/.vimrc&lt;/code&gt; that contains just this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NewFile()&#xA;        let filename = input(&quot;Filename:&quot;)&#xA;endfunction&#xA;command NewFile :call NewFile()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(of course my real &lt;code&gt;.vimrc&lt;/code&gt; is more complex, but I've recreated this small test case with no plugins etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My intent is to write a function that supports creating a new file according to a template. Some input items will be asked from the vi user, such as the name of the file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function isn't that sophisticated yet (understatement!) - all it does is ask for the filename. When I use the command &lt;code&gt;NewFile&lt;/code&gt; from the vi command line, it starts, but then once I enter the filename and hit Enter, I get the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E488: Trailing characters&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is that? What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="51" LastEditDate="2015-09-09T23:30:56.383" LastActivityDate="2015-09-09T23:30:56.383" Title="Why am I getting a &quot;E488: Trailing characters&quot; error on this custom command?" Tags="|vimscript|error|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4690" PostTypeId="2" ParentId="4689" CreationDate="2015-09-09T15:27:42.013" Score="32" Body="&lt;p&gt;Remove the trailing &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;&#xA;That is only needed for mappings, but not for commands.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-09T15:27:42.013" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4691" PostTypeId="2" ParentId="4674" CreationDate="2015-09-09T16:47:15.887" Score="3" Body="&lt;p&gt;You want to use &lt;code&gt;UltiSnipsAddFiletypes&lt;/code&gt;. As the &lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt#L218&quot; rel=&quot;nofollow&quot;&gt;docs&lt;/a&gt; say:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The UltiSnipsAddFiletypes command allows for explicit merging of other&#xA;  snippet filetypes for the current buffer. For example, if you edit a&#xA;  .rst file but also want the Lua snippets to be available you can issue&#xA;  the command &gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;:UltiSnipsAddFiletypes rst.lua&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To automatically set the filetype when you edit a file, add the following to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead history.tex UltiSnipsAddFiletypes history.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that as stated in &lt;code&gt;:help 'filetype'&lt;/code&gt;, vim natively supports the idea of dotted filetypes, so you could change the filetype to history.tex to do custom filetype plugins, syntax, and more.&lt;/p&gt;&#xA;" OwnerUserId="680" LastEditorUserId="680" LastEditDate="2015-09-09T16:52:58.850" LastActivityDate="2015-09-09T16:52:58.850" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4692" PostTypeId="2" ParentId="4672" CreationDate="2015-09-09T23:59:09.240" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;if I have two files open, one with b:dostrip set to 1, and one 0. How does StripTrailingWhitespace know which buffer it's operating on?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;b:&lt;/code&gt; always relates to the currently active buffer. It's exactly the same as function-local (&lt;code&gt;foo&lt;/code&gt;) or class-local (&lt;code&gt;self.foo&lt;/code&gt;) variables that exist is most programming languages: it's &lt;em&gt;always&lt;/em&gt; local to the current function, never local to another function (you &lt;em&gt;can&lt;/em&gt; still access buffer-local variables from other buffers by the way, but not with the &lt;code&gt;b:&lt;/code&gt; syntax; you need the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getbufvar%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;getbufvar()&lt;/code&gt;&lt;/a&gt; function for that).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#b%3a&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help b:&lt;/code&gt;&lt;/a&gt; for the documentation by the way.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What if two files are modified and I call :wall!, is autocmd smart enough to call StripTrailingWhitespace once each with each buffer active?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. The &lt;code&gt;Buf*&lt;/code&gt; events are run for every bufffer.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;will I run into issues where StripTrailingWhitespace will only be called once with the setting from one buffer but will actually modify both buffers?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. Vim commands always operate on the current buffer except for a few commands that work on multiple buffers (like &lt;code&gt;:bufdo&lt;/code&gt;).&#xA;Remember that Vim commands are &lt;em&gt;exactly&lt;/em&gt; the same as what you're doing in Vim whenever you're editing some file. There's little &quot;magic&quot; here.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-03-04T00:00:08.547" LastActivityDate="2016-03-04T00:00:08.547" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4693" PostTypeId="1" CreationDate="2015-09-10T06:40:59.167" Score="1" ViewCount="630" Body="&lt;p&gt;How can I search for queries including &lt;code&gt;%&lt;/code&gt;, &lt;code&gt;$&lt;/code&gt; and the likes? I tried to prefix then with '\', enclosing in quotes, but it only makes it worse:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Ag &quot;$r&quot;&#xA;|| ERR: Error: No query. What do you want to search for?&#xA;&#xA;:Ag &quot;\$r&quot;&#xA;No matches for &quot;&quot;\$r&quot;&quot;&#xA;&#xA;:Ag \\$r&#xA;|| ERR: Bad regex! pcre_compile() failed at position 1: \ at end of pattern&#xA;|| If you meant to search for a literal string, run ag with -Q&#xA;&#xA;:Ag -Q &quot;\\$r&quot;&#xA;:Ag -Q \\$r&#xA;No Error, but finds god knows what&#xA;&#xA;:Ag &quot;\%whatever&quot;&#xA;|| ERR: Error: No query. What do you want to search for?&#xA;&#xA;:Ag &quot;%whatever&quot;&#xA;E499: Empty file name for '%' or '#', only works with &quot;:p:h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="237" LastEditorUserId="237" LastEditDate="2015-09-10T07:26:24.863" LastActivityDate="2015-09-10T07:26:24.863" Title="Search for %, $ using :Ag" Tags="|command-line|the-silver-searcher|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4694" PostTypeId="2" ParentId="4693" CreationDate="2015-09-10T07:22:59.907" Score="1" Body="&lt;p&gt;Did you try the following?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Ag \\$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-10T07:22:59.907" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4695" PostTypeId="1" AcceptedAnswerId="4696" CreationDate="2015-09-10T08:47:46.650" Score="28" ViewCount="17897" Body="&lt;p&gt;I'm writing down a markdown table which looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;| 13/05/15 | 09:30-16:00 |  6.5 |&#xA;| 14/05/15 | 10:00-16:30 |  6.5 |&#xA;| 16/05/15 | 15:30-01:00 |  9.5 |&#xA;| 21/05/15 | 09:00-16:30 |  7.5 |&#xA;| 22/05/15 | 08:30-17:00 |  8.5 |&#xA;| 28/05/15 | 09:30-15:30 |  6   |&#xA;| 02/06/15 | 09:00-20:00 | 11   |&#xA;| 03/06/15 | 08:30-22:30 | 14   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm looking for a way to quickly calculate the total of the third column and insert it in the buffer. The solution I have in mind would make use of visual-block mode (to select all the numbers) and maybe of the expression register (to do the math).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would this be possible using native Vim commands? If not, is there a plugin that can help me?&lt;/p&gt;&#xA;" OwnerUserId="3079" LastEditorUserId="3079" LastEditDate="2015-09-11T08:36:07.380" LastActivityDate="2023-05-31T18:58:15.563" Title="Quickly calculate the total of a column of numbers" Tags="|visual-mode|arithmetic|" AnswerCount="11" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4696" PostTypeId="2" ParentId="4695" CreationDate="2015-09-10T08:55:33.740" Score="20" Body="&lt;p&gt;I wrote a plugin: &lt;a href=&quot;https://github.com/sk1418/HowMuch&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/sk1418/HowMuch&lt;/a&gt;  which supports visual selection and does math calculations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default the plugin supports three math-expression evaluation engines: Gnu bc, python, and vimscript. You can do the calculations on a certain one or let the plugin automatically choose one for you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works with your example like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ndHHm.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ndHHm.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For details please read the README on github.&lt;/p&gt;&#xA;" OwnerUserId="1569" LastEditorUserId="4472" LastEditDate="2017-09-11T09:43:43.643" LastActivityDate="2017-09-11T09:43:43.643" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4697" PostTypeId="2" ParentId="4695" CreationDate="2015-09-10T10:16:56.320" Score="8" Body="&lt;p&gt;My &lt;a href=&quot;https://github.com/chrisbra/csv.vim&quot; rel=&quot;noreferrer&quot;&gt;csv plugin&lt;/a&gt; allows this. Use the &lt;code&gt;:SumCol&lt;/code&gt; command and be sure to read the documentation.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-10T10:16:56.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4699" PostTypeId="2" ParentId="4695" CreationDate="2015-09-10T18:43:18.853" Score="24" Body="&lt;p&gt;If you don't want to use plugins or drop to a bash script, you can do something like the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;c-V {motions} &quot;ay&lt;/code&gt; copy column into &lt;code&gt;&quot;a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:let @a = substitute(@a, 'c-V c-J', '+', 'g')&lt;/code&gt; replace the column newlines with &lt;code&gt;+&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ic-R=c-Ra&lt;/code&gt; run the replaced &lt;code&gt;&quot;a&lt;/code&gt; through the expression register&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Alternatively: make the expression history entry re-usable for further sums of columns&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ctrl-V {motions} y&lt;/code&gt; put column into yank register &lt;code&gt;&quot;&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ictrl-R=eval(substitute(@&quot;, '\n', '+', 'g'))&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Repeating for another column:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ctrl-V {motion} y&lt;/code&gt; (unchanged)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ictrl-R=&amp;lt;CR&amp;gt;&lt;/code&gt; or if you did something else with the expression register, cycle through the history with the up arrow key (or with &lt;code&gt;ctrl-P&lt;/code&gt; if you remapped it):&lt;br&gt;&#xA;&lt;code&gt;ictrl-R=&amp;lt;up&amp;gt;...&amp;lt;up&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="978" LastEditorUserId="1292" LastEditDate="2019-09-29T09:41:21.663" LastActivityDate="2019-09-29T09:41:21.663" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4700" PostTypeId="1" AcceptedAnswerId="4701" CreationDate="2015-09-10T20:12:55.980" Score="2" ViewCount="113" Body="&lt;p&gt;Indexing a Latex document, I added a lot of &lt;code&gt;\index[]{}&lt;/code&gt; commands in \footcite prenotes. It's stupid! Anyway, in my code I have a lot of :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\footcite[blabla blabla\index[n]{something} blabla.][postnote]{Reference}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or sometimes :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\footcite[blabla blabla\index[n]{something} blabla\index[n]{otherthing} blabla.][postnote]{Reference}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to find some trick to suppress all the &lt;code&gt;\index[n]{something}&lt;/code&gt; or &lt;code&gt;\index[n]{otherthing}&lt;/code&gt; stuffs only if they are between the square brackets of a footcite prenote. Is there an easy trick to do that ?&lt;/p&gt;&#xA;" OwnerUserId="4492" LastEditorUserId="4492" LastEditDate="2015-09-10T22:00:26.417" LastActivityDate="2015-09-11T07:48:29.140" Title="Deleting a Latex command multiple times" Tags="|filetype-tex|repeated-commands|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4701" PostTypeId="2" ParentId="4700" CreationDate="2015-09-10T20:23:02.820" Score="2" Body="&lt;p&gt;If the &lt;code&gt;\footcite&lt;/code&gt; is always one line, you could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%g/\footcite[/s/\index.\{-}[}]//cg&lt;/code&gt; Select every line with &quot;footcite&quot; on it, and &lt;em&gt;only&lt;/em&gt; on those lines take every string of the form &quot;\index any characters ]&quot; and remove it. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;c&lt;/code&gt; ensures that if some of the &lt;code&gt;index&lt;/code&gt;s are outside of the cite and you want to keep those, you can just skip replacing those.&lt;/p&gt;&#xA;" OwnerUserId="978" LastActivityDate="2015-09-10T20:23:02.820" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4702" PostTypeId="1" AcceptedAnswerId="4705" CreationDate="2015-09-10T20:36:55.863" Score="4" ViewCount="193" Body="&lt;p&gt;I currently use Vim for Java development. I use maven and for a small project I typically begin by running&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim .&lt;/code&gt; or &lt;code&gt;vim pom.xml&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;from terminal at project root and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argadd **/*.java&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to add all the java files to the arguments list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I edit away. It works very well, but there is some headache, like my statusline not being composed well for showing deeply nested filepaths, etc., but my question is specifically about editing a file in the same directory as the file I'm editing in the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, say I am editing a Java interface &lt;code&gt;src/main/java/com/fancy/restclient/Client.java&lt;/code&gt;. I am happy with the interface and want to create an implementation in the same folder. I type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:spl %:p:h/ClientImpl.java&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to edit &lt;code&gt;ClientImpl.java&lt;/code&gt;, in the same folder, in a horizontal split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a faster way to do this?&lt;/strong&gt; I type this very slowly and it breaks my train of thought (&lt;em&gt;choo choo!&lt;/em&gt;) Should I just suck it up and get used to it, or am I missing out on a more glorious editing experience? How would you edit a different file in the same directory as the current file?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When I want to edit a file in the same directory which already exists I usually have it in my args list and &lt;code&gt;:spl | b Cli&amp;lt;Tab&amp;gt;&lt;/code&gt; is convenient. If it exists but is not in my args list I can use &lt;code&gt;:find&lt;/code&gt; and friends to get at it quickly. So my question is &lt;em&gt;primarily&lt;/em&gt; about editing new files.&lt;/li&gt;&#xA;&lt;li&gt;I don't want to use &lt;code&gt;autochdir&lt;/code&gt; because I have a compiler set up that expects the working directory to be the project root (and it also would make it more complicated to edit files in a different directory branch of the project).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-09-11T06:47:18.687" Title="Workflow for editing file in same (deeply nested) directory" Tags="|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4703" PostTypeId="2" ParentId="4700" CreationDate="2015-09-10T22:20:44.903" Score="1" Body="&lt;h3&gt;Substitute and nested substitute&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Another way, which handles the command being split over multiple lines, is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\\footcite\[\_.\{-}\zs\\index\[\_.\{-}]{\(\_.\{-}\)}/\1/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would have to run this more than once if you want to remove more than one &lt;code&gt;\index&lt;/code&gt; command within the same &lt;code&gt;\footcite[]&lt;/code&gt;. I'm actually not sure in this case how match one thing (&lt;code&gt;\footcite[]&lt;/code&gt;) but make many substitutions. Normally you can use use a replacement expression and call a 'nested substitute' (&lt;code&gt;s/pattern/\=substitute()&lt;/code&gt;/, see &lt;code&gt;:help sub-replace-expression&lt;/code&gt;), but I couldn't figure out how to match the whole &lt;code&gt;\footcite[]&lt;/code&gt; string properly. So, that is left as a lesson for the reader (and the writer, for another day), or for knowledgeable vimmers to answer in the comments.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Global/normal/visual/substitute&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Instead you can do it with a global/normal/visual/substitute command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/\\footcite/normal /[^Mvi]:s/\\index\[[^\]]*\]{\([^}]*\)}/\1/g^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;nb&lt;/em&gt; the &lt;code&gt;^M&lt;/code&gt; is &lt;code&gt;Ctrl-V&lt;/code&gt;+&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This command&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;finds the right lines with &lt;code&gt;global&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;issues a normal command to&lt;/li&gt;&#xA;&lt;li&gt;searches forward to &lt;code&gt;[&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;visually selects inside &lt;code&gt;[]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;substitutes over visual selection&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This looks more complicated than it is because (as I learned &lt;a href=&quot;https://vi.stackexchange.com/questions/4150/how-can-i-use-the-global-command-to-prepend-document-headers-to-document-li/4156#4156&quot;&gt;here&lt;/a&gt;) you can execute a recorded macro from a global command. So: move cursor to a &lt;code&gt;\footcite&lt;/code&gt; command and record while you make a manual substitution&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;qqf[vi]:s/\\index\[[^\]]*\]{\([^}]*\)}/\1/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; record macro to q register&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f[&lt;/code&gt; forward to &lt;code&gt;[&lt;/code&gt; -- or use &lt;code&gt;/[&amp;lt;CR&amp;gt;&lt;/code&gt; if &lt;code&gt;[&lt;/code&gt; can be on the next line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vi]&lt;/code&gt; visually select inside &lt;code&gt;[]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:s/...&lt;/code&gt; do the substitution&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With the macro recorded you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\\footcite/normal! @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-09-11T07:48:29.140" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4704" PostTypeId="2" ParentId="3362" CreationDate="2015-09-11T05:21:10.540" Score="3" Body="&lt;p&gt;The way I understood your question, you have a script which opens several tabs in a vim instance, you do stuff and end with 2 tabs opened in vim, and one of these tabs is empty. When you close the non empty tab, vim should close too since the remaining tab is useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case you could use the following function + autocommand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! WinEnter * call CloseVimOnLastWindow()&#xA;&#xA;function! CloseVimOnLastWindow()&#xA;    &quot; If we are on the last tab, if it contains only one window&#xA;    &quot; and this window doesn't contains a buffer representing a file&#xA;    if (tabpagenr('$') == 1 &amp;amp;&amp;amp; winnr() == 1 &amp;amp;&amp;amp; len(expand('%'))==0)&#xA;            q!&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;WinEnter&lt;/code&gt; you'll trigger the function each time you enter a new window, which includes the situation where you close your tab and enter in the last one which is useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the function is called it checks 3 things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The number of remaining tabpages, verifying if we only have one last remaining tab.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The number of windows in this pages: If your last tab contains more than one window you're not in the situation you described so no action is triggered.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The length of the buffer name to see if the buffer in this last window doesn't represent an actual file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If these 3 conditions are filled up, then the function closes Vim.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-09-11T05:21:10.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4705" PostTypeId="2" ParentId="4702" CreationDate="2015-09-11T06:47:18.687" Score="3" Body="&lt;p&gt;&lt;code&gt;:split file&lt;/code&gt; is a shortcut for &lt;code&gt;:new&lt;/code&gt; followed by &lt;code&gt;:edit file&lt;/code&gt;. Since &lt;code&gt;file&lt;/code&gt; is already in your argument list, using a &lt;em&gt;file&lt;/em&gt;-related command like &lt;code&gt;:edit&lt;/code&gt; doesn't make much sense; an &lt;em&gt;argument&lt;/em&gt;-related command or a &lt;em&gt;buffer&lt;/em&gt;-related command like &lt;code&gt;:sbuffer&lt;/code&gt; is a more logical command, here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sb %:p:h/ClientImpl.java&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this doesn't solve the &quot;same directory&quot; aspect of your problem. What you need is a way to insert the path to the directory of the current file in your command-line. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap :: &amp;lt;C-r&amp;gt;=expand('%:p:h')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which allows you to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sb ::&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and have it expanded like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sb src/main/java/com/fancy/restclient&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… leaving the rest up to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also do all of the above in a single mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :sbuffer &amp;lt;C-r&amp;gt;=expand('%:p:h').'/*'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if you want that for files that don't belong to your arglist:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :split &amp;lt;C-r&amp;gt;=expand('%:p:h').'/*'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, what exactly is your rationale for filling up the argument list with all the files in your project? Given the depth and breadth of all the Java project I've seen that means you end up with a potentially huge argument list and just as much navigation issues as with a mostly empty argument list.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;FWIW, here are a few relevant snippets from my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot; JUGGLING WITH FILES &quot;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;nnoremap ,f :find *&#xA;nnoremap ,F :find &amp;lt;C-R&amp;gt;=expand('%:p:h').'/**/*'&amp;lt;CR&amp;gt;&#xA;nnoremap ,s :sfind *&#xA;nnoremap ,S :sfind &amp;lt;C-R&amp;gt;=expand('%:p:h').'/**/*'&amp;lt;CR&amp;gt;&#xA;nnoremap ,v :vert sfind *&#xA;nnoremap ,V :vert sfind &amp;lt;C-R&amp;gt;=expand('%:p:h').'/**/*'&amp;lt;CR&amp;gt;&#xA;nnoremap ,t :tabfind *&#xA;nnoremap ,T :tabfind &amp;lt;C-R&amp;gt;=expand('%:p:h').'/**/*'&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot; JUGGLING WITH BUFFERS &quot;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;nnoremap ,b :buffer *&#xA;nnoremap ,B :sbuffer *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, I'm a big fan of &lt;code&gt;:find&lt;/code&gt; ;-)&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-11T06:47:18.687" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4706" PostTypeId="1" CreationDate="2015-09-11T09:05:27.850" Score="2" ViewCount="179" Body="&lt;p&gt;Python group regexp has this syntax &lt;code&gt;(?P&amp;lt;idGroup&amp;gt; ... )&lt;/code&gt;, where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;(?P&amp;lt;idGroup&amp;gt;&lt;/code&gt; is the beginning of a region.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;...&lt;/code&gt; is the content of the region.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;)&lt;/code&gt; is the end of region.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I highlight start region with matchgroup parameter of region. But I want to highlight separately &lt;code&gt;idGroup&lt;/code&gt; in this start region. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it posible?&lt;/p&gt;&#xA;" OwnerUserId="4500" LastEditorUserId="51" LastEditDate="2015-09-11T15:26:16.787" LastActivityDate="2015-09-11T15:26:16.787" Title="How to match patern inside a syntax region start pattern?" Tags="|syntax-highlighting|regular-expression|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4707" PostTypeId="1" CreationDate="2015-09-11T12:25:25.903" Score="3" ViewCount="385" Body="&lt;p&gt;How can one move vertically, staying in the same column (implicitly adding spaces), regardless of line lengths? (If the next line is shorter than the current, &lt;kbd&gt;j&lt;/kbd&gt; will move the cursor to the last character of the next line.) This would be useful when adding comments.&lt;/p&gt;&#xA;" OwnerUserId="4504" LastEditorUserId="1841" LastEditDate="2015-09-11T12:51:43.137" LastActivityDate="2015-09-13T09:24:34.460" Title="Vertical motion within one column" Tags="|cursor-movement|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4708" PostTypeId="2" ParentId="4707" CreationDate="2015-09-11T12:42:32.010" Score="5" Body="&lt;p&gt;You can consider &lt;code&gt;set ve=insert&lt;/code&gt; if you just want to do virtual edit in insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set ve=all&lt;/code&gt; if you want to do virtual editing in all modes. This may break some macro or plugin (if the plugin doesn't check the &lt;code&gt;ve&lt;/code&gt; option).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27ve%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 've'&lt;/code&gt;&lt;/a&gt; to know more about &lt;code&gt;virtualedit&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add a mapping, easily setting the &lt;code&gt;ve&lt;/code&gt; option to &lt;code&gt;all&lt;/code&gt; and back for your requirements, just like toggling line numbers.&lt;/p&gt;&#xA;" OwnerUserId="1569" LastEditorUserId="205" LastEditDate="2015-09-13T09:24:34.460" LastActivityDate="2015-09-13T09:24:34.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4709" PostTypeId="1" AcceptedAnswerId="4939" CreationDate="2015-09-11T13:39:15.377" Score="2" ViewCount="1535" Body="&lt;p&gt;I have to use a very specific software with its own syntax and file format: &lt;code&gt;.htc&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been supplied a &lt;code&gt;.xml&lt;/code&gt; and &lt;code&gt;.lang&lt;/code&gt; that can be used for Notepad++ and gedit to support syntax highlighting but no such file for Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can convert/import this to VIM? &lt;/p&gt;&#xA;" OwnerUserId="4507" LastEditorUserId="1841" LastEditDate="2015-09-11T13:45:03.400" LastActivityDate="2016-01-29T00:15:13.880" Title="How to generate a syntax highlighting file for vim from a syntax file for notepad++?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4710" PostTypeId="1" CreationDate="2015-09-11T17:29:09.893" Score="3" ViewCount="1322" Body="&lt;p&gt;I was trying to revamp the vim editor so I installed NeoBundle but I didn't like it. How can I uninstall it completely?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed the installation instructions given in the &lt;a href=&quot;https://github.com/Shougo/neobundle.vim#quick-start&quot; rel=&quot;nofollow&quot;&gt;readme&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ curl https://raw.githubusercontent.com/Shougo/neobundle.vim/master/bin/install.sh &amp;gt; install.sh`&#xA;$ sh ./install.sh`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should I just erase the lines in the &lt;code&gt;.vimrc&lt;/code&gt; file?&lt;/p&gt;&#xA;" OwnerUserId="3291" LastEditorUserId="24" LastEditDate="2015-11-13T05:39:40.127" LastActivityDate="2015-12-13T06:28:24.280" Title="How to uninstall NeoBundle in OS X?" Tags="|vimrc|macos|installing|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4711" PostTypeId="1" AcceptedAnswerId="4712" CreationDate="2015-09-11T18:39:36.933" Score="2" ViewCount="848" Body="&lt;p&gt;I am using Ubuntu 14.04. Recently I installed the solarized colorscheme for vim and the gnome terminal. After the installation I have noticed when I try to launch vim from the terminal, instead of opening immediately, it says:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim new.c&#xA;Already only one window&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press enter then vim opens. Is this normal? And how do I make vim open with a single command?&lt;br&gt;&#xA;My ~/.vimrc file:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; An example for a vimrc file.&#xA;&quot;&#xA;&quot; Maintainer:   Bram Moolenaar &amp;lt;Bram@vim.org&amp;gt;&#xA;&quot; Last change:  2011 Apr 15&#xA;&quot;&#xA;&quot; To use it, copy it to&#xA;&quot;     for Unix and OS/2:  ~/.vimrc&#xA;&quot;         for Amiga:  s:.vimrc&#xA;&quot;  for MS-DOS and Win32:  $VIM\_vimrc&#xA;&quot;       for OpenVMS:  sys$login:.vimrc&#xA;&#xA;&quot; When started as &quot;evim&quot;, evim.vim will already have done these settings.&#xA;if v:progname =~? &quot;evim&quot;&#xA;  finish&#xA;endif&#xA;&#xA;&quot; Use Vim settings, rather than Vi settings (much better!).&#xA;&quot; This must be first, because it changes other options as a side effect.&#xA;set nocompatible&#xA;&#xA;&quot; allow backspacing over everything in insert mode&#xA;set backspace=indent,eol,start&#xA;&#xA;if has(&quot;vms&quot;)&#xA;  set nobackup      &quot; do not keep a backup file, use versions instead&#xA;else&#xA;  set backup        &quot; keep a backup file&#xA;endif&#xA;set history=50      &quot; keep 50 lines of command line history&#xA;set ruler       &quot; show the cursor position all the time&#xA;set showcmd     &quot; display incomplete commands&#xA;set incsearch       &quot; do incremental searching&#xA;&#xA;&quot; For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries&#xA;&quot; let &amp;amp;guioptions = substitute(&amp;amp;guioptions, &quot;t&quot;, &quot;&quot;, &quot;g&quot;)&#xA;&#xA;&quot; Don't use Ex mode, use Q for formatting&#xA;map Q gq&#xA;&#xA;&quot; CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,&#xA;&quot; so that you can undo CTRL-U after inserting a line break.&#xA;inoremap &amp;lt;C-U&amp;gt; &amp;lt;C-G&amp;gt;u&amp;lt;C-U&amp;gt;&#xA;&#xA;&quot; In many terminal emulators the mouse works just fine, thus enable it.&#xA;if has('mouse')&#xA;  set mouse=a&#xA;endif&#xA;&#xA;&quot; Switch  highlighting on, when the terminal has colors&#xA;&quot; Also switch on highlighting the last used search pattern.&#xA;if &amp;amp;t_Co &amp;gt; 2 || has(&quot;gui_running&quot;)&#xA;   on&#xA;  set hlsearch&#xA;endif&#xA;&#xA;&quot; Only do this part when compiled with support for autocommands.&#xA;if has(&quot;autocmd&quot;)&#xA;&#xA;  &quot; Enable file type detection.&#xA;  &quot; Use the default filetype settings, so that mail gets 'tw' set to 72,&#xA;  &quot; 'cindent' is on in C files, etc.&#xA;  &quot; Also load indent files, to automatically do language-dependent indenting.&#xA;  filetype plugin indent on&#xA;&#xA;  &quot; Put these in an autocmd group, so that we can delete them easily.&#xA;  augroup vimrcEx&#xA;  au!&#xA;&#xA;  &quot; For all text files set 'textwidth' to 78 characters.&#xA;  autocmd FileType text setlocal textwidth=78&#xA;&#xA;  &quot; When editing a file, always jump to the last known cursor position.&#xA;  &quot; Don't do it when the position is invalid or when inside an event handler&#xA;  &quot; (happens when dropping a file on gvim).&#xA;  &quot; Also don't do it when the mark is in the first line, that is the default&#xA;  &quot; position when opening a file.&#xA;  autocmd BufReadPost *&#xA;    \ if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) |&#xA;    \   exe &quot;normal! g`\&quot;&quot; |&#xA;    \ endif&#xA;&#xA;  augroup END&#xA;&#xA;else&#xA;&#xA;  set autoindent        &quot; always set autoindenting on&#xA;&#xA;endif &quot; has(&quot;autocmd&quot;)&#xA;&#xA;&quot; Convenient command to see the difference between the current buffer and the&#xA;&quot; file it was loaded from, thus the changes you made.&#xA;&quot; Only define it when not defined already.&#xA;if !exists(&quot;:DiffOrig&quot;)&#xA;  command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis&#xA;          \ | wincmd p | diffthis&#xA;endif&#xA;&#xA;&quot;Additional changes&#xA;set nu &quot; Line numbering&#xA;set shiftwidth=4 &quot; Indents will have a width of 4&#xA;set tabstop=4    &quot; The width of a TAB is set to 4.&#xA;                 &quot; Still it is a \t. It is just that Vim will interpret it&#xA;                 &quot; to be having a width of 4&#xA;&quot; Pathogen&#xA;execute pathogen#infect()&#xA;&#xA;&quot; Solarized&#xA;syntax enable&#xA;set background=dark&#xA;colorscheme solarized&#xA;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4513" LastEditorUserId="4513" LastEditDate="2015-09-11T19:42:01.687" LastActivityDate="2015-09-11T21:29:30.187" Title="Why is Vim echoing &quot;Already only one window&quot; when starting from terminal?" Tags="|vimrc|terminal|colorscheme|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4712" PostTypeId="2" ParentId="4711" CreationDate="2015-09-11T21:29:30.187" Score="4" Body="&lt;p&gt;Remove the &lt;code&gt;on&lt;/code&gt;. I don't know, why you have this in your .vimrc, because it only makes sense to use interactively. This is the short form of &lt;code&gt;:only&lt;/code&gt; and means, if you have several windows open, close all other windows and use make the current window the only open window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now this will fail, if you have only one window open, e.g. when call vim with a single filename argument. &#xA;Vim will try to execute the &lt;code&gt;:only&lt;/code&gt; command on your single existing window, and since there are no other windows open, you will see this warning.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-11T21:29:30.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4713" PostTypeId="2" ParentId="4710" CreationDate="2015-09-12T02:30:09.770" Score="2" Body="&lt;p&gt;Remove the lines in .vimrc and delete the folder ~/.vim/bundle/neobundle.vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The installation is just cloning a github repo and then loading with the lines you added to .vimrc&lt;/p&gt;&#xA;" OwnerUserId="4518" LastActivityDate="2015-09-12T02:30:09.770" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4714" PostTypeId="1" CreationDate="2015-09-12T06:19:10.883" Score="2" ViewCount="3129" Body="&lt;p&gt;I just started using Zathura to view pdfs while editing tex files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to have forward searching capability in Zathura.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the LaTeX-Box plugin in Vim, I have added the following in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:LatexBox_viewer= '/usr/bin/zathura --fork --synctex-editor-command &quot;vim --servername VIM --remote +\%{line} \%{input}&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gives me backward searching capability when I open a tex file with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --servername VIM filename.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and open the corresponding PDF file by typing &lt;code&gt;&amp;lt;LocalLeader&amp;gt;lv&lt;/code&gt; (this automatically opens the corresponding PDF file in Zathura).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I do not know how to have forward searching.&lt;/p&gt;&#xA;" OwnerUserId="2369" LastEditorUserId="205" LastEditDate="2015-09-14T19:56:48.243" LastActivityDate="2024-03-12T17:01:15.137" Title="How to have forward search using Zathura PDF viewer and LaTeX-Box plugin?" Tags="|search|plugin-latex-box|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4715" PostTypeId="1" AcceptedAnswerId="4716" CreationDate="2015-09-12T09:37:59.607" Score="1" ViewCount="569" Body="&lt;p&gt;I often start new projects in the same way. I guess it exists a way to be fast a starting a project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: I am trying to start new composer project with the following function. I perfectly see the string &lt;code&gt;'New Project name: '&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I press enter, my cursor just goes on top of current file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CreateProject()&#xA;    let new_name = input('New Project name: ')&#xA;    exec '!composer create-project foo/bar ' + l:new_name + ' 1.0.0'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2965" LastEditorUserId="205" LastEditDate="2015-09-13T08:54:37.520" LastActivityDate="2015-09-13T08:54:37.520" Title="How do I use input() to get the name of a new composer project from the user?" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4716" PostTypeId="2" ParentId="4715" CreationDate="2015-09-12T09:47:05.377" Score="1" Body="&lt;p&gt;For concatenating string, you should use &lt;code&gt;.&lt;/code&gt; instead of &lt;code&gt;+&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have composer installed, so instead of calling composer, I simply called the unix &lt;code&gt;echo&lt;/code&gt; function like so :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec '!echo ' . l:new_name . ' 1.0.0'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it prints the entered name with the &lt;code&gt;1.0.0&lt;/code&gt; after.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ref :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/26.html&quot; rel=&quot;nofollow&quot;&gt;http://learnvimscriptthehardway.stevelosh.com/chapters/26.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#expr-.&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h expr-.&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-09-12T09:47:05.377" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4717" PostTypeId="1" AcceptedAnswerId="4718" CreationDate="2015-09-12T11:52:19.177" Score="5" ViewCount="1349" Body="&lt;p&gt;I am trying to achieve the following : &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Having a set of predefined functions in my script&lt;/li&gt;&#xA;&lt;li&gt;Having a map of relation between the functions and their argument&lt;/li&gt;&#xA;&lt;li&gt;Calling the functions with their argument dynamically &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here is the code that I have :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:A(a) abort&#xA;  return 'A'.a:a&#xA;endfunction&#xA;&#xA;function! s:B(b) abort&#xA;  return 'B'.a:b&#xA;endfunction&#xA;&#xA;let s:functions_map ={&#xA;      \ 'A': 'aa',&#xA;      \ 'B': 'bb'&#xA;      \ }&#xA;&#xA;function! s:CallMap() abort&#xA;  for [l:key, l:value] in items(s:functions_map)&#xA;    let l:Current_function = function(l:key)&#xA;    echo l:Current_function(l:value)&#xA;  endfor&#xA;endfunction&#xA;&#xA;command! Call call &amp;lt;SID&amp;gt;CallMap()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;Call&lt;/code&gt; I get the following message : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E700: Unknown function: A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you know where the issue could be coming from ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; : &#xA;I replace &lt;code&gt;l:current_function&lt;/code&gt; by &lt;code&gt;l:Current_function&lt;/code&gt; to solve another error that was not directly related to the problem.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2015-09-12T12:09:24.067" LastActivityDate="2020-12-28T11:13:57.183" Title="Call function from string name" Tags="|vimscript|functions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4718" PostTypeId="2" ParentId="4717" CreationDate="2015-09-12T12:03:56.767" Score="5" Body="&lt;p&gt;You defined the function &lt;code&gt;s:A&lt;/code&gt;, but tried to call &lt;code&gt;function('A')&lt;/code&gt; - they are not the same: function &lt;code&gt;A()&lt;/code&gt; doesn't exist. (&lt;code&gt;:h E700&lt;/code&gt; points directly to the &lt;code&gt;function()&lt;/code&gt; call)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll probably have to use &lt;code&gt;'&amp;lt;SID&amp;gt;A'&lt;/code&gt; in place of &lt;code&gt;'A'&lt;/code&gt; as key (same for B, of course).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;code&gt;:h call()&lt;/code&gt; (with braces; not &lt;code&gt;call&lt;/code&gt;) might help with the handling of the function arguments.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-09-12T12:07:16.750" LastActivityDate="2015-09-12T12:07:16.750" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4719" PostTypeId="1" AcceptedAnswerId="4720" CreationDate="2015-09-12T17:15:05.443" Score="4" ViewCount="223" Body="&lt;p&gt;Do you know how to jump to a defined Vimscript breakpoint ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I define a breakpoint with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:breakadd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I can see it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:breaklist&#xA;&amp;gt; 1  func &amp;lt;SNR&amp;gt;114_MyFunctionName  line 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I didn't found any way to jump to the breakpoint defined.&#xA;Do you know if there is such option?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-01-10T22:00:37.533" Title="Jump to Vimscript breakpoint" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4720" PostTypeId="2" ParentId="4719" CreationDate="2015-09-12T19:36:19.360" Score="3" Body="&lt;p&gt;AFAIK, there isn't. Sometimes jumping to a breapoint can make no sense - e.g. when you add a breakpoint for a function which is not yet defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the normal  jumping mechanisms instead - for example, based on ctags.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-09-12T19:36:19.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4721" PostTypeId="1" AcceptedAnswerId="4722" CreationDate="2015-09-12T22:48:35.503" Score="4" ViewCount="2369" Body="&lt;p&gt;I have my dotfiles synchronized on github which is a current practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I use several machines I want to be able to have some part of my configuration not synched on my github repo. To do so I added these lines in my synched &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $MYLOCALVIMRC = $HOME . &quot;/.local.vim&quot;&#xA;if filereadable($MYLOCALVIMRC)&#xA;    source $MYLOCALVIMRC&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which allows me to add some configuration to &lt;code&gt;~/.local.vim&lt;/code&gt; which isn't synched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works well but now I'd like to extend that to the plugins: I'd like to have some plugins only loaded on some machines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow&quot;&gt;vim-plug&lt;/a&gt; as my plugin manager and it is not possible to call &lt;code&gt;plug#begin('~/.vim/plugged')&lt;/code&gt; and &lt;code&gt;plug#end()&lt;/code&gt; several times. Even when changing the directory of &lt;code&gt;plug#begin()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only solution I could imagine was to use a second plugin manager for the local vimrc but it is pretty ugly and I think that it might create some conflicts on the runtime path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Is it possible, using a plugin manager, to load some plugins in a &lt;code&gt;.vimrc&lt;/code&gt; file and some other plugins in a local configuration file sourced by the first &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="205" LastEditDate="2015-09-14T09:39:57.153" LastActivityDate="2015-09-14T09:39:57.153" Title="How to load plugins from my vimrc and from another file?" Tags="|vimrc|plugin-system|plugin-vim-plug|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4722" PostTypeId="2" ParentId="4721" CreationDate="2015-09-12T23:22:01.610" Score="4" Body="&lt;p&gt;(I &lt;strong&gt;haven't&lt;/strong&gt; tested this)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use another local file, that contains exclusively &lt;code&gt;Plug ...&lt;/code&gt; commands. The main &lt;em&gt;vimrc&lt;/em&gt; would load this, &lt;em&gt;inside&lt;/em&gt; the &lt;code&gt;plug#begin&lt;/code&gt; - &lt;code&gt;plug#end&lt;/code&gt; section. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $MYLOCALPLUGINS = $HOME . &quot;/.local.plugins.vim&quot;&#xA;&#xA;plug#begin('~/.vim/plugged')&#xA;Plug '...'&#xA;&#xA;&quot; load local plugins&#xA;if filereadable($MYLOCALPLUGINS)&#xA;    source $MYLOCALPLUGINS&#xA;endif&#xA;&#xA;Plug '...'&#xA;plug#end()&#xA;&#xA;let $MYLOCALVIMRC = $HOME . &quot;/.local.vim&quot;&#xA;if filereadable($MYLOCALVIMRC)&#xA;    source $MYLOCALVIMRC&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively (and simpler), just move the &lt;code&gt;$MYLOCALVIMRC&lt;/code&gt; creation above &lt;code&gt;plug#begin&lt;/code&gt;, and load the extra (locally-used) plugins directly in the main vimrc, on condition that this local vimrc exists:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $MYLOCALVIMRC = $HOME . &quot;/.local.vim&quot;&#xA;&#xA;plug#begin('~/.vim/plugged')&#xA;Plug '...'&#xA;&#xA;&quot; load local plugins HERE&#xA;if filereadable($MYLOCALVIMRC)&#xA;    Plug '...'&#xA;    Plug '...'&#xA;endif&#xA;&#xA;Plug '...'&#xA;plug#end()&#xA;&#xA;if filereadable($MYLOCALVIMRC)&#xA;    source $MYLOCALVIMRC&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-09-12T23:37:11.800" LastActivityDate="2015-09-12T23:37:11.800" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4723" PostTypeId="1" CreationDate="2015-09-13T00:24:43.627" Score="1" ViewCount="231" Body="&lt;p&gt;I've compiled Python 2.7.10 and Vim 7.4 with Python support (HP-UX 11.31 ia64).&#xA;Everything seems to be working well except for threads. Here's simple example.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from threading import Thread&#xA;from time import sleep&#xA;&#xA;def threaded_function(arg):&#xA;    for i in range(arg):&#xA;        print i&#xA;        sleep(1)&#xA;&#xA;def start_thread():&#xA;    thread = Thread(target = threaded_function, args=(5, ))&#xA;    thread.start()&#xA;&#xA;if __name__ == '__main__':&#xA;    start_thread()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Python interpreter executes it perfectly well.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% python thread.py&#xA;0&#xA;1&#xA;2&#xA;3&#xA;4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But Vim produces an error when I'm trying to source it (enclosed in python &amp;lt;&amp;lt; EOF / EOF brackets):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 14, in &amp;lt;module&amp;gt;&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 11, in start_thread&#xA;  File &quot;/home/users/zemtsoe/local/lib/python2.7/threading.py&quot;, line 745, in start&#xA;    _start_new_thread(self.__bootstrap, ())&#xA;thread.error: can't start new thread&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;AFAIK Python threads are available (despite Vim thread-unsafety).&#xA;Also I'm unable to use YCM plugin because of this error.&#xA;What can I do?&lt;/p&gt;&#xA;" OwnerUserId="4525" LastEditorUserId="4525" LastEditDate="2015-09-13T11:14:37.393" LastActivityDate="2015-09-13T22:21:10.563" Title="Is it possible to start python thread from inside Vim under HP-UX?" Tags="|vimscript-python|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4724" PostTypeId="1" CreationDate="2015-09-13T13:54:23.590" Score="4" ViewCount="1160" Body="&lt;p&gt;What is the color scheme property for the mode indicator (that says &lt;code&gt;--INSERT--&lt;/code&gt;, &lt;code&gt;--REPLACE--&lt;/code&gt;, &lt;code&gt;--VISUAL--&lt;/code&gt;, etc) that appears at the bottom of the screen? &lt;br /&gt;&#xA;I would like to change this because the color scheme I am using has set the defaults to be too low contrast to be useful for an at-a-glance reference for the current mode.&lt;br /&gt;&#xA;Here's an image for reference of what I am talking about (circled with an arrow pointing to it):&lt;br /&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/v33wU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/v33wU.png&quot; alt=&quot;An image of the bottom left corner of a VIM session in which the mode indicator that says &amp;lt;code&amp;gt;--INSERT--&amp;lt;/code&amp;gt; is too low contrast to be useful.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3071" LastEditorUserId="1841" LastEditDate="2015-09-13T16:11:30.400" LastActivityDate="2015-09-13T16:11:30.400" Title="How to change the color of the modes names (--INSERT--, --REPLACE--, --VISUAL--, etc)" Tags="|colorscheme|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4725" PostTypeId="1" AcceptedAnswerId="4727" CreationDate="2015-09-13T14:01:59.227" Score="2" ViewCount="228" Body="&lt;p&gt;Not sure how to explain this but basically I'm using an external plugin/dll to enable fullscreen in gvim (which is very lame since this should be a built-in feature...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem in when I open a window in a horizontal split, vim's cmd line gets offset up a little bit, I'd have to exit/enter fullscreen mode again to get it back to the bottom of the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a video demonstrating the problem: &lt;a href=&quot;https://youtu.be/Ad__lRMoCc8&quot; rel=&quot;nofollow&quot;&gt;https://youtu.be/Ad__lRMoCc8&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my entire setup: &lt;a href=&quot;https://github.com/vexe/vim&quot; rel=&quot;nofollow&quot;&gt;https://github.com/vexe/vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I truly appreciate any help as this has been frustrating me a lot...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[Edit]&lt;/strong&gt; Just tested it without fullscreen, it's still the same issue. i.e. open a normal gvim window (not in fullscreen) and then open something in a horizontal split, the cmd line will get offseted as well... I would have to move the window around, maximize/unmaximize it etc to get the line back to the bottom of the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[Edit]&lt;/strong&gt; Running gvim.exe without my _vimrc/_gvimrc, the issue is not there...&lt;/p&gt;&#xA;" OwnerUserId="3023" LastEditorUserId="3023" LastEditDate="2015-09-13T14:08:32.937" LastActivityDate="2015-09-13T16:04:45.627" Title="gvim cmd line offset issue when doing horizontal splits?" Tags="|gvim|split|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4726" PostTypeId="2" ParentId="4724" CreationDate="2015-09-13T14:40:44.933" Score="4" Body="&lt;p&gt;With a half hour of experimentation, I was able to figure out the answer to my own problem. The properly that I wanted to change the value of in my &lt;code&gt;.vim&lt;/code&gt; color scheme was the &lt;code&gt;&quot;ModeMsg&quot;&lt;/code&gt; property. I also edited the &lt;code&gt;&quot;MoreMsg&quot;&lt;/code&gt; property because it had the same value and would have caused similar problems later.&lt;br /&gt;&#xA;My mode message and more message now are high enough contrast that they can be viewed easily.&lt;br /&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/CrIqc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CrIqc.png&quot; alt=&quot;The bottom left corner of a VIM session showing the newly modified mode message which is now higher contrast and more functional.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3071" LastActivityDate="2015-09-13T14:40:44.933" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4727" PostTypeId="2" ParentId="4725" CreationDate="2015-09-13T15:34:09.867" Score="1" Body="&lt;p&gt;I have found the culprit!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set laststatus=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason hiding that statusline and doing a horizontal split will cause the issue. Setting it to 1 (default value: show status line when there's more than one window) will not cause any offsetting of the cmd line!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;BUT I do NOT want a status line at all!&lt;/strong&gt; Does anybody know a way around this? This sounds ridiculous but is there anyway to not have the statusline and not suffer from this issue? how about an empty statusline? I tried &lt;code&gt;set statuesline=&lt;/code&gt; but it didn't do anything, I still see &quot;filename-------&quot; in the statusline (&lt;code&gt;noruler&lt;/code&gt; is also set)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I set the horizontal split chars to whitespace (after walking into this &lt;a href=&quot;https://stackoverflow.com/questions/7223309/vim-statusline-uses-carret-symbols-for-spaces-how-to-switch-to-spaces&quot;&gt;caveat&lt;/a&gt;) via &lt;code&gt;set fillchars=stl:\&lt;/code&gt; notice the escaped space via &lt;code&gt;\&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now I'm still stuck with the filename at the beginning of the status line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Used space for statusline &lt;code&gt;set statusline=\&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there's still an annoying empty line above the cmd line, not as annoying as the initial situation but still... if anyone has a better solution please let me know.&lt;/p&gt;&#xA;" OwnerUserId="3023" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-09-13T16:04:45.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4728" PostTypeId="1" CreationDate="2015-09-13T15:54:05.297" Score="13" ViewCount="2294" Body="&lt;p&gt;I want to record a macro within a macro, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa&#xA;    [ first macro ... ]&#xA;    qb&#xA;        [ second macro ... ]&#xA;    q&#xA;    [ some more stuff, involving @b ... ]&#xA;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the second &lt;code&gt;q&lt;/code&gt; is interpreted as a request to stop the first macro, and the rest is interpreted as commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to begin recording a second macro within a macro?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, is there any other way to achieve the desired effect of repeating a certain sequence of keystrokes, while already inside a macro?&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2017-09-29T22:40:55.627" Title="How can I record a nested macro?" Tags="|macro|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4729" PostTypeId="2" ParentId="4728" CreationDate="2015-09-13T16:25:02.947" Score="12" Body="&lt;p&gt;AFAIK, you cannot record two macros by &lt;code&gt;qx...q&lt;/code&gt; in one shot. For your requirement, you have to create macro &lt;code&gt;b&lt;/code&gt; by &lt;code&gt;qb....q&lt;/code&gt;, then &lt;code&gt;qa...@bq&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to &quot;record&quot; &lt;code&gt;b&lt;/code&gt; you can do &lt;code&gt;let @b='whatever'&lt;/code&gt; then &lt;code&gt;@b&lt;/code&gt; will replay the macro. E.g. &lt;code&gt;let @b='ggdG'&lt;/code&gt; define a macro &lt;code&gt;b&lt;/code&gt; to remove all content of your current buffer without &quot;recording&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a macro definition trick, which may not relevant to your question. It is recursive macro, not nested macro. That is, you can do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;qa..whatever..@aq&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this will recursively replay the macro &lt;code&gt;a&lt;/code&gt;. It is sometimes useful, when we don't know how many times we want to replay the macro. Because when error occurs, the macro replay will automatically stop. It saves &lt;code&gt;999@a&lt;/code&gt; for example.&lt;/p&gt;&#xA;" OwnerUserId="1569" LastActivityDate="2015-09-13T16:25:02.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4730" PostTypeId="1" AcceptedAnswerId="4731" CreationDate="2015-09-13T21:30:58.677" Score="0" ViewCount="1833" Body="&lt;p&gt;First and foremost, I'm using Arch Linux. I have a file &lt;code&gt;dir/data.tex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I execute this command in terminal (when in the &lt;code&gt;dir&lt;/code&gt; directory)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim data.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;indent&quot; [New File]&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Upon pressing &lt;kbd&gt;enter&lt;/kbd&gt;, Vim opens up an empty file!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what my &lt;code&gt;.vimrc&lt;/code&gt; looks like in my home directory &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n indent on&#xA;set grepprg=grep\ -nH\ $*&#xA;let g:tex_flavor = &quot;latex&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4526" LastEditorUserId="1841" LastEditDate="2015-09-13T21:36:13.447" LastActivityDate="2015-09-14T08:47:32.040" Title="Why does vim create a new file when opening an existing file?" Tags="|vimrc|terminal|linux|linux-arch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4731" PostTypeId="2" ParentId="4730" CreationDate="2015-09-13T21:39:08.943" Score="8" Body="&lt;p&gt;That line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;means &quot;open the file called &lt;code&gt;indent&lt;/code&gt; that is at the root of the working directory&quot;. Basically, you tell Vim to do something silly and… it does just that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Be more careful about what you copy and paste.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-09-14T08:47:32.040" LastActivityDate="2015-09-14T08:47:32.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4733" PostTypeId="1" AcceptedAnswerId="4740" CreationDate="2015-09-14T11:06:45.330" Score="3" ViewCount="2292" Body="&lt;p&gt;Say I have a merge conflict in Git, and try to resolve it with &lt;strong&gt;vimdiff&lt;/strong&gt; using &lt;code&gt;diff3&lt;/code&gt; view. Here is a screenshot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ggg8g.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ggg8g.png&quot; alt=&quot;Initial State&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now while resolving, I want to &lt;code&gt;diffget&lt;/code&gt; once from &lt;code&gt;LO&lt;/code&gt; see how it looks like, undo, and then &lt;code&gt;diffget&lt;/code&gt; from &lt;code&gt;RE&lt;/code&gt;. Another situation is that I have &lt;code&gt;diffget&lt;/code&gt;ed from the wrong place, say &lt;code&gt;LO&lt;/code&gt;, so I want to undo and &lt;code&gt;diffget&lt;/code&gt; the correct one, say &lt;code&gt;RE&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So first of all I do &lt;code&gt;:diffget LO&lt;/code&gt; and get what is expected:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hG3Me.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hG3Me.png&quot; alt=&quot;After &amp;lt;code&amp;gt;:diffget LO&amp;lt;/code&amp;gt;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far everything is ok, but now I want to undo the last &lt;code&gt;diffget&lt;/code&gt;, to &lt;code&gt;diffget&lt;/code&gt; from &lt;code&gt;RE&lt;/code&gt;. So I undo with &lt;code&gt;u&lt;/code&gt; and get to what I had before (though, note the highlighting difference):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nALvv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nALvv.png&quot; alt=&quot;After undo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And now simply &lt;code&gt;diffget&lt;/code&gt; from &lt;code&gt;RE&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/npERK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/npERK.png&quot; alt=&quot;After &amp;lt;code&amp;gt;diffget RE&amp;lt;/code&amp;gt;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I got one additional redundant &lt;code&gt;octocat&lt;/code&gt; line &lt;code&gt;diffget&lt;/code&gt;ed from &lt;code&gt;RE&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is what I was expecting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        +----------+------------+&#xA;        |  actual  |  expected  |&#xA;        +----------+------------+&#xA;        |    cat   |    cat     |&#xA;        |    dog   |    dog     |&#xA;   ??   |  octodog |   octodog  |&#xA;  ----&amp;gt; |  octocat |   octocat  |&#xA;        |  octocat |            |&#xA;        +----------+------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So my question is, why is this happening? And how can I achieve the behaviour I expected?&lt;/p&gt;&#xA;" OwnerUserId="2141" LastActivityDate="2015-09-15T07:08:56.123" Title="Undo diffget in vimdiff" Tags="|vimdiff|undo-redo|git|merge|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4734" PostTypeId="2" ParentId="4669" CreationDate="2015-09-14T16:02:41.770" Score="0" Body="&lt;p&gt;Looks like Vim default color schemes don't have the best support for markdown and use the HTML syntax file instead. That's probably causing your issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try installing a maintained and popular color scheme instead. &lt;a href=&quot;https://github.com/altercation/vim-colors-solarized&quot; rel=&quot;nofollow&quot;&gt;Solarized&lt;/a&gt;, &lt;a href=&quot;https://github.com/sickill/vim-monokai&quot; rel=&quot;nofollow&quot;&gt;Monokai&lt;/a&gt; and &lt;a href=&quot;https://github.com/chriskempson/base16-vim&quot; rel=&quot;nofollow&quot;&gt;base16&lt;/a&gt; are common choices.&lt;/p&gt;&#xA;" OwnerUserId="3079" LastActivityDate="2015-09-14T16:02:41.770" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="4735" PostTypeId="1" AcceptedAnswerId="4738" CreationDate="2015-09-14T21:03:57.163" Score="8" ViewCount="633" Body="&lt;p&gt;This is a noob question, so basically in vim I want to run &lt;code&gt;ctags -R&lt;/code&gt; when I am writing to my source or header files (&lt;code&gt;*.h&lt;/code&gt; or &lt;code&gt;*.cpp&lt;/code&gt;) so I tried the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.cpp :!ctags -R&#xA;autocmd BufWritePost *.h :!ctags -R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to work, but every time I save, it wants a confirmation, so I have to press enter, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;coap/coap_pdu_ll.h&quot; 30L, 793C written&#xA;:!ctags R&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get rid of the confirmation?&lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="205" LastEditDate="2015-09-14T22:44:59.353" LastActivityDate="2015-09-14T22:57:45.000" Title="How do I execute &quot;ctags -R&quot; on saving *.h and *.cpp files without a confirmation prompt?" Tags="|external-command|autocmd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4736" PostTypeId="1" AcceptedAnswerId="4737" CreationDate="2015-09-14T21:13:55.647" Score="3" ViewCount="193" Body="&lt;p&gt;&lt;em&gt;I'm using gvim version 7.4.205 for Windows, if that matters.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I type &lt;code&gt;:help :bp&lt;/code&gt;, it shows the help for &lt;code&gt;:bN&lt;/code&gt; and &lt;code&gt;:bp&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[N]bN[ext][!] [N]          *:bN* *:bNext* *:bp* *:bprevious* *E88*&#xA;:[N]bp[revious][!] [N]&#xA;        Go to [N]th previous buffer in buffer list.  [N] defaults to&#xA;        one.  Wraps around the start of the buffer list.&#xA;        See |:buffer-!| for [!] and 'switchbuf'.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's that &lt;code&gt;*E88*&lt;/code&gt; in the top right of the entry?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screenshot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pFfGY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pFfGY.png&quot; alt=&quot;E88 is circled in a screenshot of the help for &amp;lt;code&amp;gt;:bp&amp;lt;/code&amp;gt;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="945" LastActivityDate="2015-09-14T21:50:26.700" Title="What are these `E88` shortcuts in the manual?" Tags="|gvim|help-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4737" PostTypeId="2" ParentId="4736" CreationDate="2015-09-14T21:50:26.700" Score="6" Body="&lt;p&gt;They are error codes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do something wrong and Vim gives you an error code you can search the documentation for its meaning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some common ones are listed and explained under &lt;code&gt;:help error-messages&lt;/code&gt; but most are scattered around the documentation, generally close to the commands that would cause that error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some errors like this one are pretty cryptic, though. I have no idea how anything would go wrong with this particular command which wraps around the buffer list and doesn't care at all about the arguments it receives.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-14T21:50:26.700" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4738" PostTypeId="2" ParentId="4735" CreationDate="2015-09-14T21:57:50.130" Score="10" Body="&lt;p&gt;When you execute an external command with &lt;code&gt;:!&lt;/code&gt;, Vim doesn't know what the external command might have written to the terminal, so it waits for you to confirm that you are ready to continue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid that, you can use the &lt;code&gt;system()&lt;/code&gt; function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.cpp call system(&quot;ctags -R&quot;)&#xA;autocmd BufWritePost *.h   call system(&quot;ctags -R&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also simplify that to one command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.cpp,*.h call system(&quot;ctags -R&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A problem with calling &lt;code&gt;system()&lt;/code&gt; is that you lose any error messages it might produce. That can be solved by using &lt;code&gt;echo&lt;/code&gt; instead of &lt;code&gt;call&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.cpp,*.h echo system(&quot;ctags -R&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, that echoes an empty line to the display when the command succeeds, causing another &quot;Press ENTER or type command to continue&quot; prompt. The simplest solution for that is to increase the height of the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cmdheight=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another, more complicated solution would be to echo a message only if there is one. Then you avoid the prompt without losing any screen space.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.cpp,*.h let msg=system('ctags -R') | if msg!=&quot;&quot; | echo msg | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-09-14T21:57:50.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4739" PostTypeId="2" ParentId="4735" CreationDate="2015-09-14T22:57:45.000" Score="2" Body="&lt;p&gt;Since it looks like you are using C++ why not just rebuild your tags when you compile? Just add a rule to your makefile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Plugins: &lt;a href=&quot;https://github.com/ludovicchabant/vim-gutentags&quot; rel=&quot;nofollow&quot;&gt;Gutentags&lt;/a&gt; or &lt;a href=&quot;https://github.com/xolox/vim-easytags&quot; rel=&quot;nofollow&quot;&gt;vim-easytags&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Using Git? Check out Tim Pope's git hooks method: &lt;a href=&quot;http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html&quot; rel=&quot;nofollow&quot;&gt;Effortless Ctags with Git&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-09-14T22:57:45.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4740" PostTypeId="2" ParentId="4733" CreationDate="2015-09-15T07:08:56.123" Score="1" Body="&lt;p&gt;(cf &lt;a href=&quot;http://chat.stackexchange.com/rooms/29120/discussion-between-nobe4-and-n9code&quot;&gt;discussion&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that at some point, running the &lt;code&gt;diffupdate&lt;/code&gt; command solves the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:diffupdate&lt;/code&gt; updates the current diff view. It changes the diff colors to match the new state between files. It also update the folds, that are displayed to keep the diff buffer relatively small.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-09-15T07:08:56.123" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4741" PostTypeId="1" AcceptedAnswerId="4742" CreationDate="2015-09-15T17:06:06.307" Score="5" ViewCount="258" Body="&lt;p&gt;According to &lt;code&gt;:h spell&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim only checks words for spelling, there is no grammar check.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It does however alert with a green wobbly line if a sentence begins with a small letter. Is there a way to have vim alert in a similar way if a word is repeated? This is a mistake I make quite often.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be fairly easy to find with a regular expression, e.g. with &lt;code&gt;\v( \w{2,})\1\W&lt;/code&gt;. But how to apply this to vim's spellchecking?&lt;/p&gt;&#xA;" OwnerUserId="3316" LastEditorUserId="3316" LastEditDate="2015-09-15T20:46:08.850" LastActivityDate="2015-09-15T20:46:08.850" Title="Alert for repeated word in spell checking" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4742" PostTypeId="2" ParentId="4741" CreationDate="2015-09-15T17:30:36.170" Score="5" Body="&lt;p&gt;I don't know how to use a regex to spell checking, but you can highlight repeated words the way &lt;code&gt;spell&lt;/code&gt; would:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match SpellBad /\&amp;lt;\(\w\+\)\s\+\1\&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Yes, I like &lt;code&gt;\&lt;/code&gt; a lot. :P)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mvcff.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mvcff.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/IEBG8.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IEBG8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This won't bring up &lt;code&gt;foo  foo&lt;/code&gt; when you look for badly spelled words (via &lt;code&gt;[s&lt;/code&gt; or &lt;code&gt;]s&lt;/code&gt;, for example), but hopefully the quick visual feedback you get from the highlighting should be helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;The the&lt;/code&gt; is a special case, added to Vim's default rules, from what I can make of &lt;a href=&quot;http://vimhelp.appspot.com/spell.txt.html#spell-BAD&quot; rel=&quot;noreferrer&quot;&gt;the help&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-09-15T17:30:36.170" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4743" PostTypeId="1" AcceptedAnswerId="4752" CreationDate="2015-09-15T19:02:59.980" Score="3" ViewCount="202" Body="&lt;p&gt;Thanks to @BobHyam's question and to @BenjiFischer's answer on the list vim_use@googlegroups.com, I found out how to print to hardcopy while integrating form feeds:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;in ~/.vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;   ^L&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;by analogy, in foo.sh&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#   ^L&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;followed by something like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set popt+=formfeed;y,left:15mm,right:15mm&#xA;:[range]hardcopy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With that in mind, and knowing that converting vim generated text into an html file is also possible with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]TOhtml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... I could not find a solution on how to insert arbitrarily placed html page breaks in the yet to be converted vim file (the code) so it would mess up neither the code nor the document converted to html.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anybody ideas on whether it can be done (with a reasonable effort) prior or upon conversion to html, from the vim buffer ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: I am not asking about html syntax. I do know how to insert a page break in html &lt;em&gt;while writing html&lt;/em&gt;. That bit is off topic here. What I am after is a way to code using vim and prior to converting all or part of a buffer to an html document, to introduce from vim the necessary html page breaks, without disrupting the code.&lt;/p&gt;&#xA;" OwnerUserId="4547" LastEditorUserId="4547" LastEditDate="2015-09-16T12:51:43.787" LastActivityDate="2015-09-17T17:41:19.503" Title="How to convert code to html **with** arbitrary html page breaks?" Tags="|formatting|filetype-html|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4744" PostTypeId="1" CreationDate="2015-09-16T04:06:48.597" Score="7" ViewCount="1136" Body="&lt;p&gt;I want to hide the statusline, I don't ever use nor care about what is written in it. The problem is vim doesn't offer a way to achieve that in a convenient manner. If I just do &lt;code&gt;set laststatus=0&lt;/code&gt; I will suffer from the artifact mentioned in &lt;a href=&quot;https://vi.stackexchange.com/questions/4725/gvim-cmd-line-offset-issue-when-doing-horizontal-splits&quot;&gt;this question&lt;/a&gt;. If I do &lt;code&gt;set laststatus=1&lt;/code&gt; and     set &lt;code&gt;fillchars=stl:\&lt;/code&gt; the status line will be invisible but well, still take a line of space, which is annoying...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how it looks right now, slight darker background just to show you that it's blocking the text behind it and is still taking one line of space &lt;a href=&quot;https://i.stack.imgur.com/HvcAx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HvcAx.png&quot; alt=&quot;https://i.stack.imgur.com/HvcAx.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to hide the status line for good (both in single and multiple windows mode) without suffering from the artifacts mentioned in the previous question?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd appreciate any help, tired of fighting my tools to get them to do what I want.&lt;/p&gt;&#xA;" OwnerUserId="3023" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-02-13T15:31:09.407" Title="Hide statusline when more than two windows open without suffering the extra hidden empty line artifact?" Tags="|gvim|split|statusline|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4745" PostTypeId="2" ParentId="4744" CreationDate="2015-09-16T06:19:28.353" Score="3" Body="&lt;p&gt;It is not posssible, to completly hide the statusline, if there are multiple windows. You can tweak the StatusLine and StatusLineNC highlighting groups (Note, even if you clear those groups completly, Vim will fall back and use '=' and '^' to dispaly something sane.), but basically that line will always be shown, and can't be used to display the buffer content.&#xA;If you think about it, this makes sense, since for vertical splits, you couldn't tell where one buffer ends and the next one starts. &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-16T06:19:28.353" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4746" PostTypeId="1" AcceptedAnswerId="4747" CreationDate="2015-09-16T06:38:51.397" Score="2" ViewCount="95" Body="&lt;p&gt;I am currently using gvim in an MS-Windows environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As part of a vim script function, I need to open a pdf file. So I call &lt;code&gt;system&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call system(l:pdf_file)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This opens and displays the pdf_file. Yet, the problem is, that the script hangs until I close the pdf viewer application. I'd rather have the script to continue with its execution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I tried changing the function call to, in order to open and display my pdf file asynchronously:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call system('start ' . l:pdf_file)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I get an &lt;code&gt;E371: Command not found&lt;/code&gt; error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure why this is and more importantly, how I can achieve what I want.&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="51" LastEditDate="2015-09-16T14:19:36.467" LastActivityDate="2015-09-16T14:19:36.467" Title="How do I combine system() and &quot;start&quot; in a Windows environment" Tags="|external-command|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4747" PostTypeId="2" ParentId="4746" CreationDate="2015-09-16T09:01:51.633" Score="5" Body="&lt;p&gt;Not sure why this happens. What works is to use &lt;code&gt;:call system('start /b '.l:pdf_file)&lt;/code&gt; I guess you want the '/b' parameter anyhow, since this will prevent popping up a cmd windows. Also you probably want to use :sil! to prevent an error message, because vim tries to read back the result of this call. Perhaps it is easier to use &lt;code&gt;:! start /b foobar.pdf&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-16T09:01:51.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4748" PostTypeId="1" CreationDate="2015-09-16T13:19:59.950" Score="5" ViewCount="1544" Body="&lt;p&gt;I was wondering if anyone know a good (modern) plugin, similar to &lt;a href=&quot;https://github.com/joonty/vdebug&quot; rel=&quot;nofollow&quot;&gt;vdebug&lt;/a&gt;, that gives a debugging interface for C/C++/Fortran in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know about clewn and pyclewn, however, I find these are too bulky and I would much prefer a more simple solution. My thought was that in light of the recent increase in plugin development for Vim, there might be something new that I was not aware of and that provides a more modern interface with fewer dependencies.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="51" LastEditDate="2016-07-21T17:33:23.067" LastActivityDate="2016-07-21T17:33:23.067" Title="Plugin for debugging c/c++/fortran in Vim" Tags="|ide|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4749" PostTypeId="1" CreationDate="2015-09-16T14:14:38.463" Score="1" ViewCount="35" Body="&lt;p&gt;My current VIMRC contains the below. I am using the correct colorscheme but it is not accepting my changes for the terminal search highlighting. If I input the :hi command by hand it works. Do I need to use some kind of precursor to hi? set does not work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Syntax highlight&#xA;if &amp;amp;t_Co &amp;gt;= 256 || has(&quot;gui_running&quot;)&#xA;    colorscheme vividchalk&#xA;    hi Search cterm=NONE ctermfg=grey ctermbg=blue&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1417" LastActivityDate="2015-09-16T14:14:38.463" Title="VIMRC changing Search Highlighting" Tags="|vimrc|highlight|" AnswerCount="0" CommentCount="3" ClosedDate="2015-09-16T14:25:03.550" ContentLicense="CC BY-SA 3.0" />
  <row Id="4750" PostTypeId="1" AcceptedAnswerId="4751" CreationDate="2015-09-17T11:30:07.177" Score="4" ViewCount="409" Body="&lt;p&gt;I want to insert subsequent numbers whenever there a regex matches. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do this in terminal using &lt;code&gt;for&lt;/code&gt; command and either &lt;code&gt;perl&lt;/code&gt; or &lt;code&gt;sed&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I want this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; This is a command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To turn to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; This is a1 comma2nd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where I am using the regex &lt;code&gt;a&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="17" LastActivityDate="2015-09-17T13:48:25.250" Title="Insert subsequent numbers in a substitution pattern" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4751" PostTypeId="2" ParentId="4750" CreationDate="2015-09-17T13:48:25.250" Score="4" Body="&lt;p&gt;One way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:i = 0&#xA;function! Increment()&#xA;    let g:i = g:i + 1&#xA;    return g:i&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/pattern/\=submatch(0) . Increment()/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW, &lt;a href=&quot;https://stackoverflow.com/questions/4951533/search-and-replace-with-incremented-values-in-vim&quot;&gt;this question&lt;/a&gt; is pretty similar.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-09-17T13:48:25.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4752" PostTypeId="2" ParentId="4743" CreationDate="2015-09-17T17:41:19.503" Score="1" Body="&lt;p&gt;&lt;code&gt;$VIMSCRIPT/syntax/2html.vim&lt;/code&gt; is the file responsible with html generation. Apparently, the &lt;code&gt;\x0c&lt;/code&gt; character (inserted in Vim with &lt;code&gt;Ctrl-V Ctrl-L&lt;/code&gt;) will never be found and replaced by Vim, since the &lt;code&gt;strtrans()&lt;/code&gt; function already replaced its occurences with the literal 2-letter sequence &lt;code&gt;^L&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way IMHO would be to simply place special comment lines in Vim (you could keep &lt;code&gt;&quot;   ^L&lt;/code&gt; for compatibility with &lt;code&gt;hardcopy&lt;/code&gt;), run &lt;code&gt;:TOhtml&lt;/code&gt; and then, in the html output buffer, run a substitute command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^.*&amp;amp;quot;\s*^L.*/&amp;lt;p=&quot;page-break-before: always&quot;&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... then save your html output buffer. This changes the &lt;em&gt;whole line&lt;/em&gt; that contains a start-Vim-comment char followed by any number of whitespaces and a &lt;code&gt;^L&lt;/code&gt; sequence or char. The replacement part can be anything you want - I have no idea about which html tags are used to break pages - but you say you have no problems with that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If/when all works well, you can make a command that calls both of the above in sequence, and map it to a key combo.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-09-17T17:41:19.503" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4753" PostTypeId="1" AcceptedAnswerId="4757" CreationDate="2015-09-17T22:37:45.303" Score="15" ViewCount="5149" Body="&lt;p&gt;I have created a few mappings like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;buffer&amp;gt; &amp;lt;leader&amp;gt;xyzABC   :call SomeFunc('ABC')&amp;lt;CR&amp;gt;&#xA;:nnoremap &amp;lt;buffer&amp;gt; &amp;lt;leader&amp;gt;xyzDE    :call SomeFunc('DE')&amp;lt;CR&amp;gt;&#xA;:nnoremap &amp;lt;buffer&amp;gt; &amp;lt;leader&amp;gt;xyzFoo18 :call SomeFunc('Foo18')&amp;lt;CR&amp;gt;&#xA;:nnoremap &amp;lt;buffer&amp;gt; &amp;lt;leader&amp;gt;xyzBar22 :call SomeFunc('Bar22')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works as desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am now looking for a possibility to create a map-template that would allow me to remove the obvious redundant parts of my mappings, something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;buffer&amp;gt; &amp;lt;leader&amp;gt; xyz? :call SomeFunc(?)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so that I could pass &lt;em&gt;any&lt;/em&gt; value as parameter to &lt;code&gt;SomeFunc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there such a possibility?&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2015-09-18T15:26:11.103" Title="Is it possible to create mappings with parameters?" Tags="|key-bindings|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4754" PostTypeId="2" ParentId="4753" CreationDate="2015-09-17T23:06:11.617" Score="8" Body="&lt;p&gt;Thanks to Peter Rincker's comment, I have found the answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;buffer&amp;gt; &amp;lt;leader&amp;gt; xyz :call SomeFunc(input('Param: '))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="985" LastActivityDate="2015-09-17T23:06:11.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4755" PostTypeId="2" ParentId="3673" CreationDate="2015-09-18T05:22:28.940" Score="2" Body="&lt;p&gt;I came across a partial solution, using &lt;code&gt;formatoptions=tcqaw&lt;/code&gt;. Basically, you still auto-wrap paragraphs, but a paragraph ends when the line has no trailing whitespace, which is suitable for many cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using your example (with a slight modification, no undo and using &quot;&lt;code&gt;&amp;lt;SPACE&amp;gt;&lt;/code&gt;This...&quot;) I get this result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is still a long  &#xA;This is pasted and &#xA;not wrapped&#xA;line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3188" LastEditorUserId="3188" LastEditDate="2015-09-18T10:14:17.957" LastActivityDate="2015-09-18T10:14:17.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4756" PostTypeId="2" ParentId="4753" CreationDate="2015-09-18T09:16:27.960" Score="1" Body="&lt;p&gt;You might want to take a look at &lt;a href=&quot;http://www.vim.org/scripts/script.php%3Fscript_id%3D2540&quot; rel=&quot;nofollow&quot;&gt;SnipMate&lt;/a&gt;, which aims at giving TextMate-like snippets to vim. It proved very helpful to me, anyway.&lt;/p&gt;&#xA;" OwnerUserId="4581" LastEditorUserId="15" LastEditDate="2015-09-18T15:26:11.103" LastActivityDate="2015-09-18T15:26:11.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4757" PostTypeId="2" ParentId="4753" CreationDate="2015-09-18T10:25:39.283" Score="9" Body="&lt;p&gt;As @peter-rinckler said, it is probably easier to do it with a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* Xyz :call SomeFunc(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Makes it possible to do (in normal mode)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Xyz ABC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't really like the &lt;code&gt;input()&lt;/code&gt; because you can't repeat those kinds of things easily.&lt;/p&gt;&#xA;" OwnerUserId="1543" LastActivityDate="2015-09-18T10:25:39.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4758" PostTypeId="1" AcceptedAnswerId="4772" CreationDate="2015-09-18T11:57:18.157" Score="22" ViewCount="5330" Body="&lt;p&gt;I sometimes need to write Greek words, but when I am using the Greek keyboard, hitting, say, &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; will be understood as &lt;code&gt;&amp;lt;C-π&amp;gt;&lt;/code&gt; and not as the command I intend. This can be fixed with &lt;code&gt;:map &amp;lt;C-p&amp;gt; &amp;lt;C-π&amp;gt;&lt;/code&gt;. Can I do this for all letters without making a list of all?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. Making a list of all does not produce a perfect result. E.g., &lt;code&gt;q&lt;/code&gt; is &lt;code&gt;;&lt;/code&gt; on the Gr. keyboard, but we don’t want to map ; to q. Also, for some reason, ΖΖ (zeta zeta) does not work after &lt;code&gt;:map Ζ Z&lt;/code&gt;. And a command I defined, &lt;code&gt;\lw&lt;/code&gt;, does not work as &lt;code&gt;\λς&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="1841" LastEditDate="2015-09-19T03:08:03.920" LastActivityDate="2018-11-29T08:50:06.147" Title="What is the most convenient way to work with different keyboards in vim?" Tags="|key-bindings|keyboard-layout|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4759" PostTypeId="2" ParentId="4758" CreationDate="2015-09-18T17:57:58.410" Score="1" Body="&lt;p&gt;I type in two languages too: Russian and English. And now I use this plugin &lt;a href=&quot;https://github.com/lyokha/vim-xkbswitch&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/lyokha/vim-xkbswitch&lt;/a&gt;. This plugin has a dependency on the native keyboard layout switcher, for Mac OS X you can use mine one &lt;a href=&quot;https://github.com/myshov/xkbswitch-macosx&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/myshov/xkbswitch-macosx&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="500" LastEditDate="2018-01-29T12:05:40.690" LastActivityDate="2018-01-29T12:05:40.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4760" PostTypeId="1" CreationDate="2015-09-18T21:29:58.317" Score="1" ViewCount="96" Body="&lt;p&gt;After updating vim, it behaves very irrationally when I try to edit a &lt;code&gt;c&lt;/code&gt; or &lt;code&gt;cpp&lt;/code&gt; file. Here is a picture:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TjhX0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TjhX0.png&quot; alt=&quot;screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to debug a bit, and both&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NORC -N --cmd 'call pathogen#infect()' file.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --noplugin file.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;eliminates the problem, which is strange, as the first one uses plugins but no vimrc, and the second one vimrc but no plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am indeed using pathogen and if relevant (or actually, regardless of that), here are the plugins I'm using: &lt;code&gt;nerdcommenter&lt;/code&gt;, &lt;code&gt;vim-airline&lt;/code&gt;, &lt;code&gt;vim-glsl&lt;/code&gt;, &lt;code&gt;vim-session&lt;/code&gt;, &lt;code&gt;nerdtree&lt;/code&gt;, &lt;code&gt;vim-airlineish&lt;/code&gt;, &lt;code&gt;vim-gradle&lt;/code&gt;, &lt;code&gt;YouCompleteMe&lt;/code&gt;, &lt;code&gt;TagHighlight&lt;/code&gt;, &lt;code&gt;vim-autoclose&lt;/code&gt;, &lt;code&gt;vim-misc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my &lt;code&gt;.vimrc&lt;/code&gt;: &lt;a href=&quot;https://bpaste.net/show/9910268a2e20&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://bpaste.net/show/9910268a2e20&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to debug using &lt;code&gt;:finish&lt;/code&gt;, and found out that the error is caused by line 69:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Same thing if I replace it by: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that's maybe obvious as the problem seems to only happen (as far as I have tried) on c and cpp files.&lt;/p&gt;&#xA;" OwnerUserId="4589" LastEditorUserId="51" LastEditDate="2016-07-21T17:33:06.877" LastActivityDate="2016-07-21T17:33:06.877" Title="Strange behaviour when editing c and cpp files after update" Tags="|vimrc|filetype|" AnswerCount="0" CommentCount="7" ClosedDate="2016-03-02T15:43:32.837" ContentLicense="CC BY-SA 3.0" />
  <row Id="4761" PostTypeId="2" ParentId="4758" CreationDate="2015-09-19T03:05:13.347" Score="12" Body="&lt;p&gt;As I said in the comments, mappings in are not designed to do what you want to do. An interesting option for this use case is &lt;code&gt;langmap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This option allows to keep the behavior or your keyboard in insert mode and change its behavior in the other modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use it Vim has to be compiled with &lt;code&gt;+langmap&lt;/code&gt;, you can check that this option is enabled with &lt;code&gt;echo has('langmap')&lt;/code&gt;: if the command returns &lt;code&gt;1&lt;/code&gt; the option is enabled else you'll have to get a setup with this option enabled (to know how to do that, it is another question).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it is enabled, the option takes pairs of characters for example &lt;code&gt;set langmap += à@&lt;/code&gt; will allow you to add a &lt;code&gt;à&lt;/code&gt; in your buffer when you're in insert mode and you type a &lt;code&gt;à&lt;/code&gt; but typing &lt;code&gt;à&lt;/code&gt; in normal mode will actually trigger a &lt;code&gt;@&lt;/code&gt; (this example can be useful on azerty keyboards to ease work with macros).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use langmap in greek you can follow the example given in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27langmap%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'langmap'&lt;/code&gt;&lt;/a&gt; adding this line to your &lt;code&gt;vimrc&lt;/code&gt; &lt;em&gt;(Copying this line from here may not be a good idea since I'm &lt;strong&gt;really&lt;/strong&gt; not sure of the encoding, yanking the line directly from the help file is probably safer)&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set langmap=ΑA,ΒB,ΨC,ΔD,ΕE,ΦF,ΓG,ΗH,ΙI,ΞJ,ΚK,ΛL,ΜM,ΝN,ΟO,ΠP,QQ,ΡR,ΣS,ΤT,ΘU,ΩV,WW,ΧX,ΥY,ΖZ,αa,βb,ψc,δd,εe,φf,γg,ηh,ιi,ξj,κk,λl,μm,νn,οo,πp,qq,ρr,σs,τt,θu,ωv,ςw,χx,υy,ζz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now from what I understand in your comments it remains an issue when you try to use predefined commands: when you type a command, the insert mode behavior will be triggered instead of the langmap defined behavior. Unfortunately I'm not sure I have a good solution for that. One idea could be to redefine commands for example like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command λς lw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way when you'll type the command &lt;code&gt;λς&lt;/code&gt; Vim will execute &lt;code&gt;lw&lt;/code&gt; but I see several drawbacks to this method:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It might be a huge pain in the butt to redefine all the commands you want to use.&lt;/li&gt;&#xA;&lt;li&gt;User-defined commands have to start with a capital letter, and I have now idea how convenient it is to do that in greek.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So maybe a plugin suggested by @Alexander Myshov in his answer to this question could be useful (as I never tried any of these I don't know if they solve the problem but it seems like they do).&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="20001" LastEditDate="2018-11-29T08:50:06.147" LastActivityDate="2018-11-29T08:50:06.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4762" PostTypeId="1" AcceptedAnswerId="4763" CreationDate="2015-09-19T06:02:30.633" Score="9" ViewCount="5524" Body="&lt;p&gt;I am new to Vim. My code file has 300 lines. Suppose currently the cursor is on line 254, and I used &lt;code&gt;gg&lt;/code&gt; command the cursor turn to line 1. I want to go back to line 254 but I forget that line number. Is there a command the can do this?&lt;/p&gt;&#xA;" OwnerUserId="4582" LastEditorUserId="205" LastEditDate="2015-09-19T14:18:06.810" LastActivityDate="2015-09-19T14:19:01.790" Title="How do I get back to the previous line after moving?" Tags="|cursor-movement|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4763" PostTypeId="2" ParentId="4762" CreationDate="2015-09-19T09:06:16.720" Score="17" Body="&lt;p&gt;Use &lt;code&gt;``&lt;/code&gt; to jump back to the exact position you were in before you searched/jumped, or &lt;code&gt;''&lt;/code&gt; to jump back to the start of the line you were on before you searched/jumped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;kbd&gt;CTRL+O&lt;/kbd&gt; and &lt;kbd&gt;CTRL+I&lt;/kbd&gt; for jumping back and forward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/53911/123527&quot;&gt;In vim, how do I go back to where I was before a search?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/5052079/123527&quot;&gt;Move cursor to its last position&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1558" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-09-19T14:19:01.790" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4764" PostTypeId="2" ParentId="4758" CreationDate="2015-09-19T09:43:41.350" Score="1" Body="&lt;p&gt;I type regularly in English and Swedish. Swedish is a smaller problem to solve than Greek because it only expands the English alphabet with a few characters, but I think my solution is transferable to Greek.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to switch using my OS's system keyboard switch. The problem with this is, as the OP noted, that it breaks a whole bunch of commands, since in normal mode, each key sends another signal to Vim with the non-English keyboard. In the Swedish keyboard layout, moreover, a whole bunch of non-alphabetical characters are moved to make way for the new characters &lt;code&gt;å&lt;/code&gt;, &lt;code&gt;ä&lt;/code&gt;, and &lt;code&gt;ö&lt;/code&gt;. For example, &lt;code&gt;}&lt;/code&gt; is typed with Alt-Shift-9 (matching the &lt;em&gt;opening&lt;/em&gt; parenthesis on the English keyboard), and backslash is typed with Alt-Shift-7. Switching to a vanilla Swedish keyboard layout for insertmode thus causes a whole bunch of headaches. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My solution was to remap the relevant keys in insertmode only and wrap these mappings in a function so that I can switch easily back and forth. The code below is how I did this in my &lt;code&gt;.vimrc&lt;/code&gt;. This only adds the characters I need to the position they have in the Swedish keyboard layout, leaving everything else. To type the characters that are masked by them (&lt;code&gt;;&lt;/code&gt;, &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;[&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt;, &lt;code&gt;&quot;&lt;/code&gt;, and &lt;code&gt;'&lt;/code&gt;), I simply hit the key twice. Luckily, only silly people even need to type two &lt;code&gt;ä&lt;/code&gt;s in a row. (If this double hitting is not suitable, you could map them to Ctrl or something like that. The basic principle is that characters that are masked remain in their place on the keyboard but are one keystroke removed from being realized. I find this much easier than moving them around.) What means is that when I want to type in Swedish, I hit &lt;code&gt;&amp;lt;Leader&amp;gt;s&lt;/code&gt;, which switches to these mappings and apply Swedish spellchecking. To switch back I do &lt;code&gt;&amp;lt;Leader&amp;gt;e&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, for Greek, this would involve doing mappings for the whole alphabet, which is actually less of a hassle than it sounds like once you got the principle down. The tricky part then would be to unmap all those changes when switching to English. Perhaps someone can come up with a nifty way to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am planning on doing a insert function like those below for Arabic, the other language I often type in. I might come back here to report on the process.   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Switch to Swedish&#xA;function! SweType()&#xA;  set spelllang=sv&#xA;  inoremap ; ö&#xA;  inoremap ;; ;&#xA;  inoremap : Ö&#xA;  inoremap :: :&#xA;  inoremap [ å&#xA;  inoremap { Å&#xA;  inoremap ' ä&#xA;  inoremap '' '&#xA;  inoremap &quot; Ä&#xA;  inoremap &quot;&quot; &quot;&#xA;  inoremap [[ [&#xA;  inoremap {{ {&#xA;endfunction&#xA;nmap &amp;lt;Leader&amp;gt;s :&amp;lt;C-U&amp;gt;call SweType()&amp;lt;CR&amp;gt;&#xA;&#xA;&#xA;&quot; Switch to English&#xA;function! EngType()&#xA;  set spelllang=en_us&#xA;  inoremap ; ;&#xA;  iunmap ;;&#xA;  inoremap : :&#xA;  iunmap ::&#xA;  inoremap [ [&#xA;  iunmap [[&#xA;  inoremap { {&#xA;  iunmap {{&#xA;  inoremap ' '&#xA;  iunmap ''&#xA;  inoremap &quot; &quot;&#xA;  iunmap &quot;&quot;&#xA;endfunction&#xA;nmap &amp;lt;Leader&amp;gt;e :&amp;lt;C-U&amp;gt;call EngType()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3316" LastActivityDate="2015-09-19T09:43:41.350" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4765" PostTypeId="1" AcceptedAnswerId="4766" CreationDate="2015-09-19T11:46:07.773" Score="2" ViewCount="2547" Body="&lt;p&gt;I have a problem with indentation using vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say I have a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class My&#xA;end // &amp;lt;-- cursor is here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press O vim will create new line in between &lt;strong&gt;class&lt;/strong&gt; and &lt;strong&gt;end&lt;/strong&gt; and it will be indented. When I add a method def to it so the file looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class My&#xA;  def my&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim inserts tab for the automatic indentation not spaces so in git diff it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class My&#xA;    def my&#xA;    def&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My .vimrc is very basic:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;filetype off&#xA;let mapleader = &quot;\&amp;lt;space&amp;gt;&quot;&#xA;set tabstop=2 shiftwidth=2 expandtab &quot; setting up tab behaviour&#xA;set number &quot; show line numbers&#xA;set relativenumber &quot; make the line numbers relative&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'ctrlpvim/ctrlp.vim'&#xA;Plugin 'thoughtbot/vim-rspec'&#xA;Plugin 'tpope/vim-surround'&#xA;Plugin 'vim-ruby/vim-ruby'&#xA;&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&#xA;map &amp;lt;Leader&amp;gt;t :call RunCurrentSpecFile()&amp;lt;CR&amp;gt;&#xA;map &amp;lt;Leader&amp;gt;s :call RunNearestSpec()&amp;lt;CR&amp;gt;&#xA;map &amp;lt;Leader&amp;gt;l :call RunLastSpec()&amp;lt;CR&amp;gt;&#xA;map &amp;lt;Leader&amp;gt;a :call RunAllSpecs()&amp;lt;CR&amp;gt;&#xA;nmap 0 ^&#xA;nmap &amp;lt;leader&amp;gt;vr :tabe $MYVIMRC&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;so :source $MYVIMRC&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;cs :tabe db/schema.rb&amp;lt;cr&amp;gt;&#xA;imap jk &amp;lt;esc&amp;gt;&#xA;imap kj &amp;lt;esc&amp;gt;&#xA;&#xA;syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea on how to fix this so the automatic indention is two spaces? &#xA;It drives my &lt;strong&gt;nuts!&lt;/strong&gt; I have to spend so much time fixing indentation after every commit....&lt;/p&gt;&#xA;" OwnerUserId="4594" LastActivityDate="2015-09-19T12:01:52.240" Title="vim indentation setup - Ruby" Tags="|vimrc|indentation|" AnswerCount="1" CommentCount="0" ClosedDate="2015-09-19T14:20:24.230" ContentLicense="CC BY-SA 3.0" />
  <row Id="4766" PostTypeId="2" ParentId="4765" CreationDate="2015-09-19T11:53:42.113" Score="4" Body="&lt;p&gt;If you need to use two spaces instead of tab, try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shiftwidth=2&#xA;set tabstop=2&#xA;set expandtab &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More on this here on &lt;a href=&quot;http://vim.wikia.com/wiki/Converting_tabs_to_spaces&quot; rel=&quot;nofollow&quot;&gt;wiki&lt;/a&gt; or in help&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h shiftwidth&#xA;:h tabstop&#xA;:h expandtab &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2961" LastEditorUserId="2961" LastEditDate="2015-09-19T12:01:52.240" LastActivityDate="2015-09-19T12:01:52.240" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4767" PostTypeId="1" AcceptedAnswerId="4770" CreationDate="2015-09-19T15:33:33.713" Score="1" ViewCount="131" Body="&lt;p&gt;I'd like to quickly replace all non word characters up to first word &lt;code&gt;\w&lt;/code&gt; character with a space.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----So that this line becomes&#xA;    So that this line becomes&#xA;&#xA;----------------And this line looks like this&#xA;                And this line looks like this&#xA;&#xA;--=======--^^---Likewise this becomes&#xA;                Likewise this becomes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command: &lt;code&gt;0v\wr&lt;/code&gt; (space after the r) works in normal mode, but when I place it in my &lt;code&gt;_vimrc&lt;/code&gt; file, with &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;! 0v\wr&lt;/code&gt; (with space being the last character), I get stuck in visual mode without character replacement.&lt;/p&gt;&#xA;" OwnerUserId="1132" LastEditorUserId="51" LastEditDate="2015-09-19T21:35:06.400" LastActivityDate="2015-09-19T22:08:25.480" Title="How to create a mapping to replace all non word characters at the beginning of a line?" Tags="|key-bindings|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4769" PostTypeId="2" ParentId="4767" CreationDate="2015-09-19T21:05:47.197" Score="2" Body="&lt;p&gt;Here is a possible solution which correct all the lines of your file in one command. &lt;em&gt;(Warning: might cause eye bleeding to regex masters)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add these lines to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test()&#xA;    let match = search('^\s*[^a-zA-Z0-9 ]\+\w')&#xA;    while match&#xA;        s/^\(\s*\)\(\W\)\(\w*\)/\1 \3/&#xA;        let match = search('^\s*[^a-zA-Z0-9 ]\+\w')&#xA;    endwhile&#xA;endfunction&#xA;&#xA;nmap &amp;lt;Leader&amp;gt;! :call Test()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function has a &lt;code&gt;while&lt;/code&gt; loop which is true while a line begins by 0 or more whitespaces followed by a non word and non whitespace character followed by a word character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each time such a line is found the first non word character following a beginning whitespace is replaced by a whitespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the mapping is here to call the function with &lt;kbd&gt;leabder&lt;/kbd&gt;+&lt;kbd&gt;!&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the following file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ---So that this line becomes&#xA;----------------And this line looks like this&#xA;    =====--^^---Likewise this becomes&#xA; -=======--^^---Likewise^^^^^ this becomes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    So that this line becomes&#xA;                And this line looks like this&#xA;                Likewise this becomes&#xA;                Likewise^^^^^ this becomes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That might not be the most elegant solution but you get the result :-)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-09-19T21:21:37.847" LastActivityDate="2015-09-19T21:21:37.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4770" PostTypeId="2" ParentId="4767" CreationDate="2015-09-19T21:10:00.857" Score="3" Body="&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;! 0v&amp;lt;S-Right&amp;gt;hr&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This possible solution may be also useful&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^.\{-}\&amp;lt;/\=repeat(' ',strlen(submatch(0)))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read more&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h functions&#xA;:h function-list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2961" LastEditorUserId="2961" LastEditDate="2015-09-19T22:08:25.480" LastActivityDate="2015-09-19T22:08:25.480" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4772" PostTypeId="2" ParentId="4758" CreationDate="2015-09-20T05:05:47.730" Score="7" Body="&lt;p&gt;I would recommend &lt;code&gt;keymap&lt;/code&gt;, which can solve your trouble. Put these in your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; set keymap=greek_utf-8&#xA;set iminsert=0&#xA;set imsearch=-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to disable Greek as a default.You can toggle the option on (Greek) and off (English) using &lt;code&gt;&amp;lt;ctrl&amp;gt;+^&lt;/code&gt; (you can also use &lt;code&gt;&amp;lt;ctrl&amp;gt;+6&lt;/code&gt;, it is mapped on key, not on symbol) in insert mode and Replace mode (doesn't work in Normal mode). To automatically disable  when leaving insert mode you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;ESC&amp;gt; &amp;lt;ESC&amp;gt;:set iminsert=0&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More on these&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27iminsert%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h iminsert&lt;/code&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27keymap%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h keymap&lt;/code&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27imsearch%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h imsearch&lt;/code&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-%5E&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-^&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;EDIT to second comment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try this to switch Greek on automatically, if entering insert mode (and replace mode), and to switch off automatically, if leaving (then you don't need mapping mentioned before).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup Greek&#xA;    au InsertEnter * set iminsert=1&#xA;    au InsertLeave * set iminsert=0&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2961" LastEditorUserId="2961" LastEditDate="2015-09-20T13:07:58.507" LastActivityDate="2015-09-20T13:07:58.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4773" PostTypeId="1" AcceptedAnswerId="4775" CreationDate="2015-09-20T10:29:43.503" Score="9" ViewCount="1552" Body="&lt;p&gt;What is  the fastest sequence to delete to the end of line &lt;strong&gt;after&lt;/strong&gt; the cursor position?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I want to delete this line in a faster way&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sequence: &lt;code&gt;5eD&lt;/code&gt; will delete the last character of the word &lt;code&gt;line&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I want to delete this lin&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Moving around with vim often put me on the first or last character of a word, forcing me to move by one more keystroke each time I want to delete to the end of line (in the example above, by adding one motion to the right: &lt;code&gt;5elD&lt;/code&gt;). Is there a more efficient way (by moving after the end of word or by deleting after the cursor)?&lt;/p&gt;&#xA;" OwnerUserId="4599" LastEditorUserId="4599" LastEditDate="2015-09-20T10:35:36.553" LastActivityDate="2021-01-28T13:56:50.637" Title="Move after end of word or Delete after cusor" Tags="|cursor-motions|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4774" PostTypeId="1" AcceptedAnswerId="4776" CreationDate="2015-09-20T13:16:48.847" Score="6" ViewCount="1374" Body="&lt;p&gt;Consider the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long foobar=(test);&#xA;int  barbar=(something);&#xA;char foofoo=();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Suppose I have yanked some chunk of code which I want to place before each opening parenthesis, e.g. &lt;code&gt;funcName&lt;/code&gt;. What I currently have to do is just manually enter the addition after selecting e.g. all the &lt;code&gt;(&lt;/code&gt; via &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;, and then after pressing &lt;kbd&gt;I&lt;/kbd&gt;, enter &lt;code&gt;funcName&lt;/code&gt; (thus disregarding contents of yank register).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to instead &lt;em&gt;insert&lt;/em&gt; the text before selection, like I'd do using &lt;kbd&gt;P&lt;/kbd&gt; for a single line?&lt;/p&gt;&#xA;" OwnerUserId="1081" LastActivityDate="2015-09-21T11:06:06.313" Title="How to paste a line in a vertical selection block?" Tags="|cut-copy-paste|visual-mode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4775" PostTypeId="2" ParentId="4773" CreationDate="2015-09-20T13:40:31.783" Score="5" Body="&lt;p&gt;&lt;code&gt;D&lt;/code&gt; is an &lt;em&gt;inclusive&lt;/em&gt; command that works over a motion that includes the cursor at one end and the last printable character on the line at the other end. There is AFAIK no built-in way to turn an &lt;em&gt;inclusive&lt;/em&gt; command into an &lt;em&gt;exclusive&lt;/em&gt; command and vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The heaviest solution would be to define your own operators and motions/text-objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A somewhat lighter solution would be to define mappings for those corner cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An even lighter — but boring — solution would be to spend a few more keystrokes in visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, you could simply &lt;em&gt;move&lt;/em&gt; in a slightly more &quot;agile&quot; manner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5f D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-20T13:40:31.783" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4776" PostTypeId="2" ParentId="4774" CreationDate="2015-09-20T13:43:50.130" Score="7" Body="&lt;p&gt;In insert mode, you can use &lt;code&gt;&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt; to insert the content of the unnamed register (replace &lt;code&gt;&quot;&lt;/code&gt; with &lt;code&gt;b&lt;/code&gt; if what you want to insert is stored in register &lt;code&gt;b&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;jjI&amp;lt;C-r&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-20T13:43:50.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4777" PostTypeId="1" AcceptedAnswerId="4778" CreationDate="2015-09-20T14:36:10.397" Score="7" ViewCount="208" Body="&lt;p&gt;Sometimes I want to try a pattern with &lt;code&gt;/&lt;/code&gt; before doing &lt;code&gt;:%s/ …&lt;/code&gt;; can I reuse it without having to type it all over? (or use the mouse.)&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2015-09-20T15:45:10.097" Title="Reusing search pattern in ex mode" Tags="|ex-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4778" PostTypeId="2" ParentId="4777" CreationDate="2015-09-20T15:07:45.550" Score="9" Body="&lt;p&gt;Sure, just leave the pattern in the substitution empty:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s//replacement/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-09-20T15:07:45.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4779" PostTypeId="2" ParentId="4777" CreationDate="2015-09-20T15:34:51.143" Score="0" Body="&lt;p&gt;Another possible solution&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe '%s/' . @/ . '/replacement/g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2961" LastEditorUserId="2961" LastEditDate="2015-09-20T15:41:41.040" LastActivityDate="2015-09-20T15:41:41.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4780" PostTypeId="2" ParentId="4777" CreationDate="2015-09-20T15:39:28.177" Score="4" Body="&lt;p&gt;In addition to &lt;a href=&quot;https://vi.stackexchange.com/a/4778/46&quot;&gt;@garyjohn's answer&lt;/a&gt;, you can use &lt;code&gt;&amp;lt;c-r&amp;gt;/&lt;/code&gt; to insert the search register into a command if you want to edit it or leaving out the search pattern isn't sufficient.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;lt;c-r&amp;gt;//replacement&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="46" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-09-20T15:45:10.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4781" PostTypeId="1" CreationDate="2015-09-20T19:03:47.837" Score="5" ViewCount="226" Body="&lt;p&gt;I used Cygwin perl and cpan to download, compile and test a working &lt;code&gt;ack&lt;/code&gt;, struggling with a clean working model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Primarily using win32 Vim, it seems like I can only utilize the Cygwin &lt;code&gt;ack&lt;/code&gt; if I change from &lt;code&gt;$COMSPEC&lt;/code&gt; to &lt;code&gt;c:/cygwin/bin/bash.&lt;/code&gt;&#xA;Unfortunately, this breaks other useful tools within Vim.  I have loaded the plugin &lt;a href=&quot;https://github.com/mileszs/ack.vim&quot; rel=&quot;nofollow&quot;&gt;ack.vim&lt;/a&gt; which seems promising, but it encounters an error after search execution and fails to render in quickfix. I have read many posts but haven't found a palatable implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What is the best mechanism for executing an external &lt;code&gt;ack&lt;/code&gt; in Cygwin from win32 Vim?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps I should look further at the Ack.vim implementation?  Maybe just something as simple as quickly switching between shell implementations without Vim restart?&lt;/p&gt;&#xA;" OwnerUserId="2498" LastEditorUserId="2498" LastEditDate="2015-09-25T01:00:37.993" LastActivityDate="2015-09-25T01:00:37.993" Title="How to utilize the Cygwin ack tool from Vim 7.4?" Tags="|external-command|cygwin|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4782" PostTypeId="5" CreationDate="2015-09-20T19:43:05.600" Score="0" Body="&lt;p&gt;Vim allows users to define their own commands with the following format:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:com[mand][!] [{attr}...] {cmd} {rep}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;{cmd}&lt;/code&gt; part has to begin with a capital letter to differentiate built-in commands from user-defined commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;{attr}&lt;/code&gt; can be used to define a number of arguments taken by the command or the source to use to autocomplete these arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some related commands are &lt;code&gt;:delc[ommand]&lt;/code&gt; and &lt;code&gt;:comc[lear]&lt;/code&gt; which respectively allows to delete a user defined command and to clear all the user defined commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more informations see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:command&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :command&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:delcommand&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h delc&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:comclear&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h comc&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="51" LastEditDate="2015-09-20T20:50:12.507" LastActivityDate="2015-09-20T20:50:12.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4783" PostTypeId="4" CreationDate="2015-09-20T19:43:05.600" Score="0" Body="Questions about :command and how the user can define custom commands." OwnerUserId="1841" LastEditorUserId="51" LastEditDate="2015-09-20T20:49:59.320" LastActivityDate="2015-09-20T20:49:59.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4784" PostTypeId="1" AcceptedAnswerId="4785" CreationDate="2015-09-20T23:27:10.937" Score="5" ViewCount="1224" Body="&lt;p&gt;I am wanting to wrap the &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; and the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; blocks below and surround them both with another &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;body&amp;gt;&#xA;&#xA;    &amp;lt;h2&amp;gt;Im a heading&amp;lt;/h2&amp;gt;&#xA;    &amp;lt;div class=&quot;row&quot;&amp;gt;&#xA;        im some content&#xA;    &amp;lt;/div&amp;gt;&#xA;&#xA;&amp;lt;/body&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From normal mode, I am entering &lt;code&gt;-- VISUAL LINE --&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;V&lt;/kbd&gt;, select block, &lt;kbd&gt;S&lt;/kbd&gt; (enter surround mode), then type &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;vim-surround successfully wraps the block, but loses all indenting, e.g:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;body&amp;gt;    &#xA;&#xA;&amp;lt;div&amp;gt;&#xA;&amp;lt;h2&amp;gt;Im a heading&amp;lt;/h2&amp;gt;&#xA;&amp;lt;div class=&quot;row&quot;&amp;gt;&#xA;im some content&#xA;&amp;lt;/div&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&#xA;&amp;lt;/body&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I notice elsewhere, people are saying capital &lt;code&gt;S&lt;/code&gt; tells vim-surround &quot;surround AND indent&quot;, but for me capital &lt;code&gt;S&lt;/code&gt; only enables vim-surround and lowercase &lt;code&gt;s&lt;/code&gt; doesnt work at all.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/13349701/4668401&quot;&gt;This SO answer&lt;/a&gt; suggests there is some possible setup required to enable the indenting behaviour for &lt;kbd&gt;S&lt;/kbd&gt;.&lt;br&gt;&#xA;Or is it an operating system specific issue? (My OS is Ubuntu 14.04)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get vim-surround's automatic indenting to work?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-09-21T14:46:14.877" Title="How can I get vim-surround to automatically indent surrounded HTML code?" Tags="|plugin-vim-surround|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4785" PostTypeId="2" ParentId="4784" CreationDate="2015-09-21T00:18:09.943" Score="4" Body="&lt;p&gt;I found a workable solution by changing the following vim core settings.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype indent on&#xA;:set smartindent  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my case I was editing an HTML file - which vim had no trouble detecting as the correct filetype, but if you were editing any other HTML-containing file that vim didn't recognise correctly, you may need to add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set filetype=html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Those changes enabled visually selecting a block of text and hitting &lt;kbd&gt;=&lt;/kbd&gt; to automatically indent HTML tags correctly.&lt;br&gt;&#xA;After that vim-surround also automatically indented when surrounding code - similar to pressing &lt;kbd&gt;=&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;More background&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Reading &lt;a href=&quot;http://vimhelp.appspot.com/filetype.txt.html#%3Afiletype&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help filetype&lt;/code&gt;&lt;/a&gt; gave an excellent overview/introduction to what was going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to see what your current &lt;code&gt;filetype&lt;/code&gt; setting is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;To see the current status, type: &#xA;        :filetype&#xA;The output looks something like this: &#xA;        filetype detection:ON  plugin:ON  indent:OFF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="205" LastEditDate="2015-09-21T14:46:14.877" LastActivityDate="2015-09-21T14:46:14.877" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4786" PostTypeId="1" AcceptedAnswerId="4794" CreationDate="2015-09-21T10:42:43.233" Score="4" ViewCount="1904" Body="&lt;p&gt;Is the meta key supposed to do anything in vim? It would be nice if the things that can be done on the command line could also be done in insert mode (such as &lt;code&gt;&amp;lt;M-t&amp;gt;&lt;/code&gt; for transposing words). As it is (on my mac with iterm configured to use the command key as meta), it serves only as a quicker alternative to the escape key, because &lt;code&gt;&amp;lt;meta+b&amp;gt;&lt;/code&gt; = &lt;code&gt;&amp;lt;esc&amp;gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a post saying one could put&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; fix meta-keys which generate &amp;lt;Esc&amp;gt;a .. &amp;lt;Esc&amp;gt;z&#xA;let c='a'&#xA;while c &amp;lt;= 'z'&#xA;  exec &quot;set &amp;lt;M-&quot;.toupper(c).&quot;&amp;gt;=\e&quot;.c&#xA;  exec &quot;imap \e&quot;.c.&quot; &amp;lt;M-&quot;.toupper(c).&quot;&amp;gt;&quot;&#xA;  let c = nr2char(1+char2nr(c))&#xA;endw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into .vimrc; but that only made my meta produce some useless symbols.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. I think the answer to this quæstion is simply no. Though it is useful for escaping to normal mode with the first command, &lt;code&gt;&amp;lt;M-d&amp;gt;d&lt;/code&gt; for &lt;code&gt;&amp;lt;esc&amp;gt;dd&lt;/code&gt; &amp;amp;c.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2015-09-21T15:06:12.130" LastActivityDate="2016-01-07T18:41:45.747" Title="Can vim make use of the meta key?" Tags="|key-bindings|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4788" PostTypeId="2" ParentId="4774" CreationDate="2015-09-21T11:06:06.313" Score="3" Body="&lt;p&gt;You could also use the &quot;normal&quot; command so that it would work even if the &lt;code&gt;(&lt;/code&gt; are not aligned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Vjj&lt;/code&gt; To select the three lines&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:normal f(P&lt;/code&gt; To execute &lt;code&gt;f(&lt;/code&gt; (find first &lt;code&gt;(&lt;/code&gt;) and &lt;code&gt;P&lt;/code&gt; to paste on all three lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This makes it also easier to repeat (by selecting other lines, hitting &lt;code&gt;:&lt;/code&gt; and &lt;kbd&gt;Up&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="1543" LastActivityDate="2015-09-21T11:06:06.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4789" PostTypeId="1" CreationDate="2015-09-21T12:02:54.430" Score="2" ViewCount="50" Body="&lt;p&gt;Sometimes there are several second long slowdowns when browsing Clojure source code in a Git repo via Vim's netrw. My Vim version is 7.4.865.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do have a couple of plugins that must have caused this. How do i most efficiently identify the culprit without resorting to disabling plugins one-by-one (or binary-tree wise)? Is there some sort of logging/verbose mode/etc. i could turn on to see what function takes so much time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="2725" LastActivityDate="2015-09-21T12:02:54.430" Title="Vim slowdown when browsing with netrw" Tags="|netrw|performance|" AnswerCount="0" CommentCount="1" ClosedDate="2016-03-02T15:40:33.570" ContentLicense="CC BY-SA 3.0" />
  <row Id="4790" PostTypeId="1" AcceptedAnswerId="4795" CreationDate="2015-09-21T14:49:34.223" Score="0" ViewCount="90" Body="&lt;p&gt;As the title. Basically I want to apply &lt;code&gt;set linebreak&lt;/code&gt; to the &lt;code&gt;gundo&lt;/code&gt; window.&lt;/p&gt;&#xA;" OwnerUserId="3316" LastActivityDate="2015-09-21T17:28:14.617" Title="How can I soft wrap the gundo preview?" Tags="|wrapping|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4791" PostTypeId="2" ParentId="4790" CreationDate="2015-09-21T16:26:08.907" Score="1" Body="&lt;p&gt;Before you get better answer, you can go to &lt;code&gt;/autoload/gundo.vim&lt;/code&gt; (or wherever it is), there should be two functions &lt;code&gt;GundoSettingsGraph()&lt;/code&gt; and &lt;code&gt;GundoSettingsPreview()&lt;/code&gt; (depends on which you desire to change), and there you can change &lt;code&gt;setlocal nowrap&lt;/code&gt; to &lt;code&gt;setlocal wrap&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2961" LastActivityDate="2015-09-21T16:26:08.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4792" PostTypeId="1" AcceptedAnswerId="4793" CreationDate="2015-09-21T16:44:56.497" Score="0" ViewCount="761" Body="&lt;p&gt;I have a problem with UltiSnips. It keeps jump backwards even tough I didn't&#xA;map it in my &lt;code&gt;.vimrc&lt;/code&gt; file. My &lt;code&gt;.vimrc&lt;/code&gt; look like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;C-l&amp;gt;&quot;                                             &#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;C-k&amp;gt;&quot;                                        &#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;C-i&amp;gt;&quot;&#xA;&#xA;let g:ycm_key_list_select_completion = ['&amp;lt;Tab&amp;gt;', '&amp;lt;Down&amp;gt;']                       &#xA;let g:ycm_key_list_previous_completion = ['&amp;lt;S-Tab&amp;gt;', '&amp;lt;Up&amp;gt;']                     &#xA;&#xA;let g:SuperTabDefaultCompletionType = '&amp;lt;Tab&amp;gt;' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No there saying anything about &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; executing &lt;code&gt;JumpBackwardTrigger&lt;/code&gt;. But,&#xA;when type this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fpri                             \\ Then hit &amp;lt;tab&amp;gt;, it expands to:&#xA;fprintf(stderr, &quot;%s\n&quot;, str__);  \\ My cursor at __. YCM need to do the job&#xA;                                 \\ when I start typing. Then I hit &amp;lt;tab&amp;gt;&#xA;fprintf(stderr, &quot;__\n&quot;, str);    \\ But it bring back!!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have no mapping that involves &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; key. So, what is causing this?&lt;/p&gt;&#xA;" OwnerUserId="1526" LastActivityDate="2015-09-21T17:00:08.923" Title="Tab keep triggering jump backward in ultisnips" Tags="|plugin-ultisnips|plugin-you-complete-me|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4793" PostTypeId="2" ParentId="4792" CreationDate="2015-09-21T17:00:08.923" Score="2" Body="&lt;p&gt;Unfortunately &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; are parsed as the exact same key by most terminals. You can follow a discussion about this on this neovim issue: &lt;a href=&quot;https://github.com/neovim/neovim/issues/176&quot; rel=&quot;nofollow&quot;&gt;https://github.com/neovim/neovim/issues/176&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest solution is to pick a different mapping for jumping backwards, like &lt;code&gt;&amp;lt;leader&amp;gt;i&lt;/code&gt;. If you really want this fixed, I suggest following the linked issue and looking into leonerd's work.&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-09-21T17:00:08.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4794" PostTypeId="2" ParentId="4786" CreationDate="2015-09-21T17:05:55.730" Score="8" Body="&lt;p&gt;If you are able/willing to switch to Neovim, that has full support for meta key combinations, as documented here: &lt;a href=&quot;https://github.com/neovim/neovim/blob/master/runtime/doc/vim_diff.txt#L86&quot;&gt;https://github.com/neovim/neovim/blob/master/runtime/doc/vim_diff.txt#L86&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="680" LastActivityDate="2015-09-21T17:05:55.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4795" PostTypeId="2" ParentId="4790" CreationDate="2015-09-21T17:28:14.617" Score="3" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyGundo&#xA;    au!&#xA;    au BufWinEnter __Gundo_Preview__ :setl linebreak wrap&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-21T17:28:14.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4796" PostTypeId="1" AcceptedAnswerId="4797" CreationDate="2015-09-21T19:19:52.037" Score="8" ViewCount="853" Body="&lt;p&gt;Vim has the excellent command &lt;code&gt;set tw=79&lt;/code&gt; which will automatically break your lines at 79 characters, however I like (just) my comments broken at 72 characters automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any good way to do this in Vim?&lt;/p&gt;&#xA;" OwnerUserId="2425" LastActivityDate="2015-09-21T20:49:44.753" Title="Automatically breaking lines in comments?" Tags="|line-breaks|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4797" PostTypeId="2" ParentId="4796" CreationDate="2015-09-21T20:49:44.753" Score="9" Body="&lt;p&gt;I like this one&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup comment_textwidth&#xA;    autocmd!&#xA;    autocmd TextChanged,TextChangedI * :call AdjustTextWidth()&#xA;augroup END&#xA;&#xA;function! AdjustTextWidth()&#xA;    let syn_element = synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;) - 1, 1), &quot;name&quot;)&#xA;    let &amp;amp;textwidth = syn_element =~? 'comment' ? 72 : 79&#xA;    echo &quot;tw = &quot; . &amp;amp;textwidth&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.reddit.com/r/vim/comments/3kk4ml/settings_a_different_textwidth_for_comments/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Source&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more inspiration look &lt;a href=&quot;https://stackoverflow.com/questions/4027222/vim-use-shorter-textwidth-in-comments-and-docstrings&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2961" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-09-21T20:49:44.753" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4798" PostTypeId="1" AcceptedAnswerId="4799" CreationDate="2015-09-21T22:05:15.403" Score="16" ViewCount="10825" Body="&lt;p&gt;For example when editing a big &lt;code&gt;.gitignore&lt;/code&gt; file and pasting in a block for a newly added toolset's suggested ignore patterns,&#xA;I manually looked at each line and typed &lt;code&gt;/\.filetype&lt;/code&gt; where filetype is what's on that line, to confirm that this wasn't already represented elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't plan to use &lt;code&gt;sort -u&lt;/code&gt; or &lt;code&gt;uniq&lt;/code&gt; because I wish to retain the blocks of ignores organized by toolchain involved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It occurs to me that there must be an even shorter method of basically highlighting other lines that match this line, or searching for the word at the cursor. Would someone be able to tell me how, or if it is not a feature?&lt;/p&gt;&#xA;" OwnerUserId="3303" LastActivityDate="2018-05-15T11:08:17.443" Title="find next occurrence of word or line at cursor" Tags="|key-bindings|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4799" PostTypeId="2" ParentId="4798" CreationDate="2015-09-21T22:18:56.743" Score="23" Body="&lt;p&gt;You can use &lt;code&gt;*&lt;/code&gt; in normal mode which will go to the next occurrence of the word under your cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @Sato pointed it out in the comments &lt;code&gt;*&lt;/code&gt; allows to search forward and &lt;code&gt;#&lt;/code&gt; is the equivalent to search backward. Once you've pressed &lt;code&gt;*&lt;/code&gt; or &lt;code&gt;#&lt;/code&gt; you can use the keys &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; to navigate between the matches just like you do after searching with &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also if you want to search more terms, an option is to yank what you are looking for and then put it in the search register:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt; to start the search&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt; to insert the search terms you just yanked&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to begin the search&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that this method will affect the content of the unnamed register.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-05-15T11:08:17.443" LastActivityDate="2018-05-15T11:08:17.443" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4800" PostTypeId="1" AcceptedAnswerId="4802" CreationDate="2015-09-21T23:38:44.030" Score="1" ViewCount="132" Body="&lt;p&gt;When Im writing shell scripts I often want to run/check a block of code, by &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;V&lt;/kbd&gt; highlight block&lt;/li&gt;&#xA;&lt;li&gt;then &lt;code&gt;:'&amp;lt;,'&amp;gt;w !bash&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;vim will then execute highlighted block and display output at the bottom of vim's display - displacing the current buffer with the shell output.&lt;br&gt;&#xA;The problem is sometimes the output goes beyond the top of the screen and when in that state, no key commands to navigate the text seem available - i.e. any key just returns back to the buffer.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ive tried piping into less, e.g. &lt;code&gt;:'&amp;lt;,'&amp;gt;w !bash | less&lt;/code&gt;, this actually  crashed my vim instance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I display the output in a useful way, e.g.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;move around the existing output, kind of like less (ideal)&lt;/li&gt;&#xA;&lt;li&gt;sending large output to a new buffer (good)&lt;/li&gt;&#xA;&lt;li&gt;sending output into a new file (ok, if no better options)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="51" LastEditDate="2015-09-22T12:57:12.740" LastActivityDate="2015-09-22T12:57:12.740" Title="Output of shell commands is going beyond available screen space" Tags="|external-command|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="4801" PostTypeId="1" AcceptedAnswerId="4808" CreationDate="2015-09-22T00:55:19.993" Score="4" ViewCount="991" Body="&lt;p&gt;While testing out the &lt;a href=&quot;https://github.com/fatih/vim-go&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-go&lt;/a&gt; plugin I encountered &lt;a href=&quot;https://github.com/fatih/vim-go/issues/287&quot; rel=&quot;nofollow noreferrer&quot;&gt;an issue&lt;/a&gt; that I wanted to look into more closely. In a comment on the issue, the owner of the plugin writes:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The text &lt;code&gt;read 0 byte, err read tcp 127.0.0.1:8800: i/o timeout: []&lt;/code&gt;&#xA;  is seen as an error line, so &lt;code&gt;makeprg&lt;/code&gt; automatically parses it and&#xA;  puts into the quickfix list.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not familiar with Vim plugin development but with a bit of digging I found &lt;a href=&quot;https://github.com/fatih/vim-go/blob/73710fe6964c2f366682dba3550e2dcec7831949/compiler/go.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;the file where the parsing patterns are defined&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;CompilerSet errorformat=&#xA;      \%-G#\ %.%#,&#xA;      \%-G%.%#panic:\ %m,&#xA;      \%Ecan\'t\ load\ package:\ %m,&#xA;      \%A%f:%l:%c:\ %m,&#xA;      \%A%f:%l:\ %m,&#xA;      \%C%*\\s%m,&#xA;      \%-G%.%#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I read &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#error-file-format&quot; rel=&quot;nofollow noreferrer&quot;&gt;the QuickFix error format documentation&lt;/a&gt; to understand these patterns, and I figured while doing so that I would add comments to the repository for the next reader to come along who isn't familiar with these patterns and tokens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got into the habit of using inline comments in this type of situation when &lt;a href=&quot;https://docs.python.org/2/library/re.html#re.X&quot; rel=&quot;nofollow noreferrer&quot;&gt;documenting complicated regex patterns in Python&lt;/a&gt;. It's really useful. I wanted to do the same here, so I tried using &lt;code&gt;&quot;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Define the patterns that will be recognized by QuickFix when parsing the output of GoRun.&#xA;&quot; More information at http://vimdoc.sourceforge.net/htmldoc/quickfix.html#errorformat&#xA;CompilerSet errorformat=&#xA;      \%-G#\ %.%#,                   &quot; Ignore lines beginning with &quot;#&quot; (&quot;# command-line-arguments&quot; line sometimes appears?)&#xA;      \%-G%.%#panic:\ %m,            &quot; Ignore lines containing &quot;panic: message&quot;&#xA;      \%Ecan\'t\ load\ package:\ %m, &quot; Start of multiline error string is &quot;can't load package: message&quot;&#xA;      \%A%f:%l:%c:\ %m,              &quot; Start of multiline unspecified string is &quot;filename:linenumber:columnnumber: message&quot;&#xA;      \%A%f:%l:\ %m,                 &quot; Start of multiline unspecified string is &quot;filename:linenumber: message&quot;&#xA;      \%C%*\\s%m,                    &quot; Continuation of multiline error message is indented&#xA;      \%-G%.%#                       &quot; All lines not matching any of the above patterns are ignored&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this worked correctly, it wouldn't change the behavior of the plugin at all; but I found that QuickFix stopped working entirely after this change. If the syntax highlighting on GitHub is to be believed, most of these aren't actually being parsed as comments. I searched around and found &lt;a href=&quot;http://vim.wikia.com/wiki/Backing_up_and_commenting_vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Commenting is simple: put a double quote to the left of the text you want to comment&quot; on the Vim Tips Wiki&lt;/a&gt; but apparently it's not so simple as that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/24716804/inline-comments-in-vimrc-mappings&quot;&gt;A question on SO points to a similar issue,&lt;/a&gt; but I'm not defining mappings here and the different lines are actually part of the same command, so I can't just separate them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to an existing question here on Vi.SE, &lt;a href=&quot;https://vi.stackexchange.com/q/4211/800&quot;&gt;it's not possible to use inline comments with multi-line statements.&lt;/a&gt; So, how can I add a brief explanation for each pattern in the source, corresponding directly to the pattern where it appears in the code? I'd rather not throw it all into an overly-verbose multi-line comment in front of the &lt;code&gt;CompilerSet&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="800" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-09-22T20:28:42.983" Title="How can I clearly document errorformat patterns in a plugin compiler file?" Tags="|vimscript|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4802" PostTypeId="2" ParentId="4800" CreationDate="2015-09-22T05:17:11.960" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/sjl/clam.vim&quot; rel=&quot;nofollow&quot;&gt;Clam&lt;/a&gt; is very useful for that kind of scenario:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;select a bunch of lines,&lt;/li&gt;&#xA;&lt;li&gt;do &lt;code&gt;:'&amp;lt;,'&amp;gt;Clam bash&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;get the result in a vertical Vim window,&lt;/li&gt;&#xA;&lt;li&gt;go back to your script, edit it, run it again in the same vertical window.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-22T05:17:11.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4803" PostTypeId="1" AcceptedAnswerId="4804" CreationDate="2015-09-22T08:30:43.443" Score="1" ViewCount="745" Body="&lt;p&gt;I have a file with 30000 lines (3MB), when I use &lt;code&gt;:w&lt;/code&gt; vim editor hangs for several seconds, but when I use pure vim/vi it takes only a moment to save the changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do I get this effect? What could be causing this lag?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Changed original question &lt;em&gt;What is the difference between :w and :up?&lt;/em&gt; to &lt;em&gt;Why :w command is so slow for relatively small file?&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="147" LastEditorUserId="205" LastEditDate="2015-09-22T18:10:10.963" LastActivityDate="2015-09-22T18:10:10.963" Title="Why is :w command so slow for a relatively small file?" Tags="|vimrc|save|" AnswerCount="1" CommentCount="9" ClosedDate="2015-09-28T14:19:41.887" ContentLicense="CC BY-SA 3.0" />
  <row Id="4804" PostTypeId="2" ParentId="4803" CreationDate="2015-09-22T08:35:46.117" Score="6" Body="&lt;p&gt;I would just comment, but not enough reputation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at &lt;code&gt;:help up&lt;/code&gt; it says &quot;Like &lt;code&gt;:write&lt;/code&gt;, but only write when the buffer has been modified.&quot;&lt;/p&gt;&#xA;" OwnerUserId="4622" LastActivityDate="2015-09-22T08:35:46.117" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4805" PostTypeId="1" AcceptedAnswerId="4806" CreationDate="2015-09-22T14:37:11.057" Score="2" ViewCount="153" Body="&lt;p&gt;When writing shell scripts, it is frequently necessary to call external commands in &lt;code&gt;$PATH&lt;/code&gt;. Some of these have long names (e.g. &lt;code&gt;system-config-printer-applet&lt;/code&gt; or &lt;code&gt;xfwm4-workspace-settings&lt;/code&gt;), and it would be useful to be able to complete them while in insert mode. Shells like &lt;code&gt;bash&lt;/code&gt; and &lt;code&gt;zsh&lt;/code&gt; have this capability built in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this isn't built into any of Vim's &lt;code&gt;ins-completion&lt;/code&gt; defaults.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#ins-completion&quot; rel=&quot;nofollow&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/insert.html#ins-completion&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The feature was requested in 2004, but does not seem to have been implemented since then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://comments.gmane.org/gmane.editors.vim/26022&quot; rel=&quot;nofollow&quot;&gt;http://comments.gmane.org/gmane.editors.vim/26022&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a setting or plugin to enable this?&lt;/p&gt;&#xA;" OwnerUserId="4498" LastEditorUserId="4498" LastEditDate="2015-09-22T14:45:49.510" LastActivityDate="2015-09-23T05:17:29.753" Title="Insert mode completion of executables in `$PATH` (like `compgen -c`)" Tags="|autocompletion|external-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4806" PostTypeId="2" ParentId="4805" CreationDate="2015-09-22T15:29:24.650" Score="4" Body="&lt;p&gt;This recipe enables dictionary completion for shell scripts via regular keyword completion and omni completion:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Add the following lines to &lt;code&gt;~/.vimrc&lt;/code&gt; to enable dictionary completion in shell scripts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup shellscripts&#xA;    &quot; prevent duplicates if .vimrc is sourced twice.&#xA;    autocmd!&#xA;&#xA;    &quot; tell Vim where the dictionary is&#xA;    autocmd FileType sh setlocal complete+=k~/shellcmds.txt dictionary=~/shellcmds.txt&#xA;&#xA;    &quot; completions for hyphenated commands&#xA;    autocmd FileType sh setlocal iskeyword+=-&#xA;&#xA;    &quot; generate the dictionary&#xA;    autocmd FileType sh call system(&quot;compgen -c &amp;gt; ~/shellcmds.txt&quot;)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Open a shell script in a new Vim instance.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; (keyword completion) or &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; (omni completion) in insert mode to perform completion.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to keep your &lt;code&gt;vimrc&lt;/code&gt; lean and clean, you can move the important bits of the snippet above in a proper ftplugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/after/ftplugin/sh.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Its content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal complete+=k~/shellcmds.txt&#xA;setlocal dictionary=~/shellcmds.txt&#xA;setlocal iskeyword+=-&#xA;silent call system(&quot;compgen -c &amp;gt; ~/shellcmds.txt&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Dictionary completion is a cheap and easy way to get completion for unsupported languages and frameworks.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-09-23T05:17:29.753" LastActivityDate="2015-09-23T05:17:29.753" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4807" PostTypeId="2" ParentId="3" CreationDate="2015-09-22T18:39:56.770" Score="25" Body="&lt;p&gt;You can toggle relative numbering on and off using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set rnu    &quot; toggle relative numbering on&#xA;:set rnu!   &quot; toggle relative numbering off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4624" LastEditorUserId="1841" LastEditDate="2015-09-22T22:25:48.670" LastActivityDate="2015-09-22T22:25:48.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4808" PostTypeId="2" ParentId="4801" CreationDate="2015-09-22T19:08:09.657" Score="5" Body="&lt;p&gt;Settings like &lt;code&gt;errorformat&lt;/code&gt; can be modified using the &lt;code&gt;+=&lt;/code&gt; and &lt;code&gt;-=&lt;/code&gt; operators. You can take advantage of this by setting an initial value and adding to it, with a comment accompanying each addition. You could do, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Define the patterns that will be recognized by QuickFix when parsing the output of GoRun.&#xA;&quot; More information at http://vimdoc.sourceforge.net/htmldoc/quickfix.html#errorformat&#xA;CompilerSet  errorformat=%-G#\ %.%#                   &quot; Ignore lines beginning with &quot;#&quot; (&quot;# command-line-arguments&quot; line sometimes appears?)&#xA;CompilerSet errorformat+=%-G%.%#panic:\ %m            &quot; Ignore lines containing &quot;panic: message&quot;&#xA;CompilerSet errorformat+=%Ecan\'t\ load\ package:\ %m &quot; Start of multiline error string is &quot;can't load package: message&quot;&#xA;CompilerSet errorformat+=%A%f:%l:%c:\ %m              &quot; Start of multiline unspecified string is &quot;filename:linenumber:columnnumber: message&quot;&#xA;CompilerSet errorformat+=%A%f:%l:\ %m                 &quot; Start of multiline unspecified string is &quot;filename:linenumber: message&quot;&#xA;CompilerSet errorformat+=%C%*\\s%m                    &quot; Continuation of multiline error message is indented&#xA;CompilerSet errorformat+=%-G%.%#                      &quot; All lines not matching any of the above patterns are ignored&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe a bit verbose, but it should work (assuming &lt;code&gt;CompilerSet errorformat&lt;/code&gt; behaves the way &lt;code&gt;set errorformat&lt;/code&gt; does).&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-09-22T20:28:42.983" LastActivityDate="2015-09-22T20:28:42.983" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4809" PostTypeId="1" AcceptedAnswerId="4810" CreationDate="2015-09-22T22:10:53.697" Score="4" ViewCount="504" Body="&lt;p&gt;Say I entered &lt;code&gt;:e bla/bla/bla.txt&lt;/code&gt; and I realize I want to put a &lt;code&gt;!&lt;/code&gt; after the &lt;code&gt;e&lt;/code&gt;. Can I get there without using the arrow keys?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2015-09-22T22:23:05.720" Title="Can one jump in ex mode?" Tags="|ex-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4810" PostTypeId="2" ParentId="4809" CreationDate="2015-09-22T22:17:31.600" Score="5" Body="&lt;h3&gt;Command Line Window&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;cmdline-window&lt;/code&gt; to edit the command line the same way as you would any other window. Enter into this window by pressing &lt;code&gt;&amp;lt;c-f&amp;gt;&lt;/code&gt; while on the command line or use &lt;code&gt;q:&lt;/code&gt; in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a similar &lt;a href=&quot;http://vimcasts.org/&quot; rel=&quot;nofollow&quot;&gt;Vimcasts&lt;/a&gt; episode on the subject: &lt;a href=&quot;http://vimcasts.org/episodes/refining-search-patterns-with-the-command-line-window/&quot; rel=&quot;nofollow&quot;&gt;Refining search patterns with the command-line window&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Command line mappings&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The command line also has many of its own mappings to help navigate/modify:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-b&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;home&amp;gt;&lt;/code&gt; to go to the beginning (&lt;a href=&quot;https://github.com/tpope/vim-rsi&quot; rel=&quot;nofollow&quot;&gt;Some people&lt;/a&gt; remap this to &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; to match emacs/bash/readline)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;s-left&amp;gt;&lt;/code&gt; or shift + left arrow moves to the left one &lt;code&gt;WORD&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; clears the command line completely&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-r&amp;gt;{reg}&lt;/code&gt; will put the value of register, &lt;code&gt;{reg}&lt;/code&gt; into the line&lt;/li&gt;&#xA;&lt;li&gt;Many more. See &lt;code&gt;Q_ce&lt;/code&gt; for a quick review.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h cmdwin&#xA;:h cmdline-editing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-09-22T22:23:05.720" LastActivityDate="2015-09-22T22:23:05.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4812" PostTypeId="2" ParentId="4809" CreationDate="2015-09-22T22:21:44.010" Score="1" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-B&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h cmdline&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-B or &amp;lt;Home&amp;gt;                                c_CTRL-B c_&amp;lt;Home&amp;gt; c_Home&#xA;            cursor to beginning of command-line&#xA;CTRL-E or &amp;lt;End&amp;gt;                                 c_CTRL-E c_&amp;lt;End&amp;gt; c_End&#xA;            cursor to end of command-line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I didn't see any other commands that &quot;jumped&quot; around and didn't use arrow keys. You could do: &lt;kbd&gt;Home&lt;/kbd&gt;&lt;kbd&gt;Del&lt;/kbd&gt;, then type &lt;code&gt;e!&lt;/code&gt; (a bit convoluted, I agree).&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-09-22T22:21:44.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4813" PostTypeId="1" AcceptedAnswerId="4814" CreationDate="2015-09-22T23:11:28.883" Score="5" ViewCount="126" Body="&lt;p&gt;Is there a way to edit comments so that they will all be aligned without having to align them manually with &lt;kbd&gt;tab&lt;/kbd&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e., How can I get something like that?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some text          %comment&#xA;some more text     %another comment&#xA;&amp;amp;c.                %=etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;without manually adjusting each comment?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="1841" LastEditDate="2015-09-22T23:22:18.403" LastActivityDate="2015-09-23T00:21:23.947" Title="Edit comments as if separate lines?" Tags="|formatting|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4814" PostTypeId="2" ParentId="4813" CreationDate="2015-09-22T23:19:22.897" Score="5" Body="&lt;p&gt;You might be interested by the &lt;a href=&quot;https://github.com/godlygeek/tabular&quot; rel=&quot;nofollow&quot;&gt;tabular plugin&lt;/a&gt; it allows to align text based on patterns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case if you have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some text  %comment&#xA;some more text %another comment&#xA;&amp;amp;c.  %=etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with your cursor on the first line you can use &lt;code&gt;3V&lt;/code&gt; to select the lines you want to treat and then &lt;code&gt;:Tabular /%&lt;/code&gt; and tabular will automatically indent the text like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some text          %comment&#xA;some more text     %another comment&#xA;&amp;amp;c.                %=etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The plugin is pretty powerful and can be used to do much more complex operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; As jjaderberg pointed it out in this case you don't need to select the text: Tabular is pretty clever and can &quot;guess&quot; how to format the text. For example you can use &lt;code&gt;:Tabularize&lt;/code&gt; (without selection neither pattern) and the plugin will still align the comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also an interesting mapping to add to your &lt;code&gt;.vimrc&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap T :Tabular /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you can visually select a part of text and use &lt;kbd&gt;T&lt;/kbd&gt; to easily start tabular.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2&lt;/strong&gt; I was looking around to find fun stuff to do with tabular and I just found out a &lt;a href=&quot;https://gist.github.com/tpope/287147&quot; rel=&quot;nofollow&quot;&gt;nice Tim Pope's gist&lt;/a&gt; which could be interesting here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; %   %&amp;lt;Esc&amp;gt;:call &amp;lt;SID&amp;gt;align('%')&amp;lt;CR&amp;gt;a&#xA;&#xA;function! s:align(aa)&#xA;  let p = '^.*\s'.a:aa.'\s.*$'&#xA;  if exists(':Tabularize') &amp;amp;&amp;amp; (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)&#xA;    let column = strlen(substitute(getline('.')[0:col('.')],'[^'.a:aa.']','','g'))&#xA;    let position = strlen(matchstr(getline('.')[0:col('.')],'.*'.a:aa.':\s*\zs.*'))&#xA;    exec 'Tabularize/'.a:aa.'/l1'&#xA;    normal! 0&#xA;    call search(repeat('[^'.a:aa.']*'.a:aa,column).'\s\{-\}'.repeat('.',position),'ce',line('.'))&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It maps &lt;code&gt;%&lt;/code&gt; so that when you write several consecutive lines containing a &lt;code&gt;%&lt;/code&gt;, the comments will be automatically aligned on the fly. And when you write a single line with &lt;code&gt;%&lt;/code&gt; it will only be added without more indent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that a possible improvement would be to define the mapping according to the file time so that the correct comment character is mapped for each language.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-09-23T00:21:23.947" LastActivityDate="2015-09-23T00:21:23.947" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4815" PostTypeId="1" AcceptedAnswerId="4816" CreationDate="2015-09-23T00:32:34.780" Score="2" ViewCount="457" Body="&lt;p&gt;For some reason I get, what I call an &quot;uneven&quot; output from Ack/Ag in the quickfix list window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My project directory structure is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/user/projects/myproject&#xA; |&#xA; ---- llvm-or1k&#xA; |&#xA; ---- clang-or1k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did a search with Ag using the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ag --nogroup --nocolor --column -S -U BuildSchedGraph /home/user/projects/myproject&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And got the following output (snippet)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;&#xA;/home/user/projects/myproject/llvm-or1k/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.h|176 col 63| /// BuildSchedUnits, AddSchedEdges - Helper functions for BuildSchedGraph.&#xA;&#xA;llvm-or1k/lib/CodeGen/SelectionDAG/ScheduleDAGVLIW.cpp|100 col 3| BuildSchedGraph(AA);&#xA;&#xA;/home/user/projects/myproject/llvm-or1k/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp|336 col 3| BuildSchedGraph(NULL);&#xA;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't understand why the first and the last &quot;finds&quot; have &lt;code&gt;/home/user/projects/myproject&lt;/code&gt; prepended to the path while the second one doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is becoming quite annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2865" LastEditorUserId="2055" LastEditDate="2015-09-23T04:00:12.837" LastActivityDate="2021-07-29T22:51:08.480" Title="uneven quickfix window output from Ack/Ag" Tags="|quickfix|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4816" PostTypeId="2" ParentId="4815" CreationDate="2015-09-23T02:44:51.450" Score="6" Body="&lt;p&gt;Yes, it is annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When Vim creates a quickfix list from the output of a program such as Ack, it creates a buffer for each file in the quickfix list using the name provided by the other program. This is often a full path name. Vim simplifies or resolves those names to relative path names upon certain events. The problem is that those names are not resolved when the quickfix list is displayed, so you see a mixture of full path names and relative path names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no good solution available to users.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a workaround that is very much a hack, but it works for me because of the way I use Vim. That is, when I'm working on a project for which I use quickfix lists generated from programs such as cscope, I always start Vim in the top-level directory of the project and never use &lt;code&gt;:cd&lt;/code&gt; or &lt;code&gt;:lcd&lt;/code&gt;. It turns out that executing &lt;code&gt;:cd&lt;/code&gt; is one of the events that causes Vim to resolve its buffer names, so I have the following in my &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufAdd * exe &quot;cd&quot; fnameescape(getcwd())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As Vim creates the quickfix list, it adds a buffer for each file. That autocommand executes &lt;code&gt;:cd&lt;/code&gt; to the current working directory for each file added and causes the file names to be resolved. Executing &lt;code&gt;:cd&lt;/code&gt; like that is a no-op in my case. Again, this is a hack and it has side effects depending on what you're doing, but it works for me in my situation and makes my quickfix lists more appealing. It may work for you, too.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-09-23T02:44:51.450" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="4817" PostTypeId="1" AcceptedAnswerId="4826" CreationDate="2015-09-23T07:00:30.607" Score="7" ViewCount="2028" Body="&lt;p&gt;Is there a way to run vim from command line to edit the last edited file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let say I first edit file &lt;code&gt;giorgio.sh&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vi giorgio.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Afterwards, I exit back to terminal&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ do something...&#xA;$ do something else...&#xA;$ do something else again...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to edit again the file in vim, maybe using some vim command line parameter/option ?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vi {option to edit last edited/saved file}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I mean without using:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;an internal vim command like &lt;code&gt;:browse oldfiles&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;the beautiful MRU plugin&lt;/li&gt;&#xA;&lt;li&gt;the  bash history (requiring to scroll, if, after your edit, you ran some other commands)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It is strange that it doesn't seem possible to do a so common task in a super quick Vim way.&lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="1841" LastEditDate="2015-09-23T15:57:19.177" LastActivityDate="2017-12-19T17:28:10.327" Title="Is there a vim command line option to edit last edited file?" Tags="|invocation|options|" AnswerCount="7" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4818" PostTypeId="2" ParentId="4817" CreationDate="2015-09-23T07:46:37.210" Score="8" Body="&lt;p&gt;For this purpose, I have definde the following alias in my shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias lvim=&quot;vim -c \&quot;normal '0\&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(l meaning last)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-23T07:46:37.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4819" PostTypeId="2" ParentId="4817" CreationDate="2015-09-23T08:25:03.380" Score="3" Body="&lt;p&gt;Another possible alias:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias lvim=&quot;vim -c':e#&amp;lt;1'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-23T08:25:03.380" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4820" PostTypeId="1" AcceptedAnswerId="4821" CreationDate="2015-09-23T11:04:33.527" Score="4" ViewCount="277" Body="&lt;p&gt;For example I've the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is my first line, but longer.&#xA;This is my first line&#xA;This is my second line, but longer.&#xA;This is my second line&#xA;This is my third line, but longer.&#xA;This is my third line&#xA;This&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I expect to remove the shorter lines which share the same (from beginning of the line) content with either previous or next line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm expect from above example to have only 3 main unique sentences (longer one), as the shorter once are already contained in longer lines. This method has several real usages such as finding the leaf items (such as directories).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming the content is sorted (could be in reverse if that helps), I think we can compare next line with the previous one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe I need to match each line and create some back reference to the previous one, similar as for &lt;a href=&quot;http://vim.wikia.com/wiki/Uniq_-_Removing_duplicate_lines&quot; rel=&quot;nofollow&quot;&gt;removing duplicate lines&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\(.*\)\n\1$/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but with additional &lt;code&gt;.*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\(.*\).*\n\1$/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it removes the shorter line instead of leaving the longer one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how this can be achieved?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-09-23T12:07:40.790" LastActivityDate="2015-09-23T12:14:55.067" Title="How do I remove lines where its content already occured in the previous line?" Tags="|regular-expression|substitute|multiple-lines|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4821" PostTypeId="2" ParentId="4820" CreationDate="2015-09-23T11:50:44.610" Score="3" Body="&lt;p&gt;Probably not exactly the solution you expect, but I'd rather use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/ if search('^' . getline('.'), 'wn') != line('.') | delete | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will also remove duplicates (since you do mention &lt;em&gt;unique sentences&lt;/em&gt;), e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This&#xA;This is my first line, but longer.&#xA;This is my first line, but longer.&#xA;This is my first line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is my first line, but longer.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For every line, its content is searched forward in the whole file, starting from current position and wrapping until it finds something. If it doesn't, the search will &quot;land&quot; (find) the same original line used as pattern. In the first case, the line is deleted (its content exists elsewhere).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-09-23T11:50:44.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4822" PostTypeId="2" ParentId="4820" CreationDate="2015-09-23T12:14:55.067" Score="2" Body="&lt;p&gt;You are close.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can live with an error &quot;E16: invalid range&quot; make the delete command delete the next line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\(.*\).*\n\1$/+d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:g&lt;/code&gt; with patterns matching several lines is tricky and this works for your special case, but it does not always work as one expect it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another alternative is to simply use the &lt;code&gt;:s&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(\(.*\).*\)\n\2$/\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which replaces the match (the two consecutive lines) with the longer line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Funnily it looks like this pattern matches here only with the old 'regular expression engine' so you might have to set your &lt;code&gt;'re'&lt;/code&gt; setting accordingly.&#xA;But I might be missing some patch here.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-23T12:14:55.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4823" PostTypeId="1" AcceptedAnswerId="4834" CreationDate="2015-09-23T13:08:30.513" Score="1" ViewCount="211" Body="&lt;p&gt;I need to set on my Linux box &lt;code&gt;VIM&lt;/code&gt;  as default mime application for editing text file. On &lt;code&gt;zsh&lt;/code&gt; I managed to wrap a function from vim --remote. But I would like to use it for default xdg-mime application (in the same way &lt;code&gt;emacsclient&lt;/code&gt; is doing for emacs).&lt;/p&gt;&#xA;" OwnerUserId="4632" LastActivityDate="2015-09-23T21:24:09.790" Title="Wrapper script for vim --remote" Tags="|vimscript|linux|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4824" PostTypeId="1" AcceptedAnswerId="4825" CreationDate="2015-09-23T14:07:54.767" Score="9" ViewCount="523" Body="&lt;p&gt;I've been a long time fan of the &lt;code&gt;t&lt;/code&gt; and &lt;code&gt;f&lt;/code&gt; motions to modify text up to or including some character.  For more complicated criteria, I've started using &lt;code&gt;/&lt;/code&gt; followed by a search string to modify text up to a certain phrase.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I had:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delete this text, but not this.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;on a line I could do &lt;code&gt;0d/not this&lt;/code&gt; to delete everything except &lt;code&gt;not this.&lt;/code&gt;.  This is usually exactly how I want it to work, but every now and then I'd like the pattern to be included in the edit.  So, in my previous example, it would have deleted everything except the period.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible using a similar construct?  I'd prefer it to be without the use of additional plugins, but such answer are also welcome.&lt;/p&gt;&#xA;" OwnerUserId="1115" LastEditorUserId="205" LastEditDate="2015-09-23T23:55:57.763" LastActivityDate="2015-09-23T23:55:57.763" Title="Is it possible to use '/' search as an inclusive motion (similar to what 'f' is to 't')?" Tags="|cursor-motions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4825" PostTypeId="2" ParentId="4824" CreationDate="2015-09-23T14:07:54.767" Score="9" Body="&lt;p&gt;Right as I was about to post the question, I remembered that you can do a search and leave the cursor at the end of the pattern with &lt;code&gt;/e&lt;/code&gt; appended to the end of the pattern.  Doing &lt;code&gt;0d/not this/e&lt;/code&gt; will delete the line including &quot;not this&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help search-offset&lt;/code&gt; has more information about this and actually has an example similar to what I was trying to achieve (don't I now feel foolish...).&lt;/p&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2015-09-23T14:07:54.767" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4826" PostTypeId="2" ParentId="4817" CreationDate="2015-09-23T14:11:15.480" Score="5" Body="&lt;p&gt;&lt;strong&gt;An heavy solution: the sessions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possible option is to use the sessions mechanism:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First your vim version has to be compiled with the &lt;code&gt;+mksession&lt;/code&gt; option. &lt;em&gt;(Use &lt;code&gt;:echo has('mksession')&lt;/code&gt; to check that).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when you are about to leave vim, use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:mksession!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will create &lt;em&gt;(or overwrite thanks to &lt;code&gt;!&lt;/code&gt;)&lt;/em&gt; a file named Session.vim in the current directory which will save your current open files, windows layout and cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you can also give a path as parameter to &lt;code&gt;mksession&lt;/code&gt; to choose where to save and how to name you session file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can go back to your shell and do whatever you want. When you want to reopen vim with your last edited file you have to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$vim -S /path/to/Session.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will reopen the files you where editing with the cursor at the same position&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How to shorten it?&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this workflow is good for you you'll probably be able to create the bash alias the most convenient for your use case. Here is an example, maybe you'll want to bend it to your way to use sessions: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Q mksession! ~/Session.vim | qall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this will allow you to use &lt;code&gt;:Q&lt;/code&gt; to save your session in &lt;code&gt;~/Session.vim&lt;/code&gt; and quit vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a bash alias you can create :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias lvim='vim -S ~/Session.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will reload the session created when you used &lt;code&gt;:Q&lt;/code&gt; in vim.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A much lighter solution: suspend vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;This solution is not suitable if you need to close your shell.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In unix shell you can suspend Vim using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;z&lt;/kbd&gt;. This will put Vim in background and you'll get acces to your shell again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your shell when you need to get Vim back you simply have to use the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ fg &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; That zsh provides convenient mappings to use also &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;z&lt;/kbd&gt; on the shell to get Vim back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note2&lt;/strong&gt; If you tend to forget that you put vim in back ground you can add these lines to your &lt;code&gt;.bashrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PROMPT_COMMAND='hasjobs=$(jobs -p)'&#xA;PS1=$PS1 + '${hasjobs:+\j }'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you don't have any background job your prompt will stay the same and when you have some background jobs, a count will appear at the end of your prompt (It's up to you to bend it to your preferences). For this trick, credits &lt;a href=&quot;https://unix.stackexchange.com/a/35731/90314&quot;&gt;goes to jw013&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2015-09-24T15:02:18.390" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4827" PostTypeId="1" AcceptedAnswerId="4828" CreationDate="2015-09-23T15:16:33.343" Score="4" ViewCount="1960" Body="&lt;p&gt;In my vimscripts I sometimes have to use the &lt;code&gt;windo&lt;/code&gt; command to execute an action on each open split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with this command is that it cycles through all the open splits and ends on a different split than the one I was on when I started the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand the causes of this behavior, but I need to find a workaround to get back on my original split after using &lt;code&gt;windo&lt;/code&gt;. A solution I found is to do that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:currentWindow=winnr()&#xA;windo [whatever I want to apply to all the splits]&#xA;exe l:currentWindow . &quot;wincmd w&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically before using &lt;code&gt;windo&lt;/code&gt; I get the number of my current window in the variable &lt;code&gt;l:currentWindow&lt;/code&gt;. After using window I use &lt;code&gt;exe&lt;/code&gt; to execute &lt;code&gt;wincmd w&lt;/code&gt; which is the equivalent to &lt;kbd&gt;Ctrl-w&lt;/kbd&gt;+&lt;kbd&gt;w&lt;/kbd&gt; which allows to go to a window according to its number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I haven't had a problem with this solution but I was wondering if there is another way to execute an action on each split without changing the cursor position?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure I'm not the first one to encounter this problem and other vimmers probably found different/better workaround.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-09-24T17:56:43.803" Title="What is a better way to use `windo` without changing of window?" Tags="|vimscript|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4828" PostTypeId="2" ParentId="4827" CreationDate="2015-09-23T16:14:31.580" Score="6" Body="&lt;p&gt;Create a new &lt;code&gt;:windo&lt;/code&gt; command witch restores the window.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ -complete=command Windo &#xA;      \ let s:currentWindow = winnr() |&#xA;      \ execute &quot;windo &amp;lt;args&amp;gt;&quot; |&#xA;      \ exe s:currentWindow . &quot;wincmd w&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This just wraps up your manual method into command &lt;code&gt;:Windo&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="1841" LastEditDate="2015-09-24T17:56:43.803" LastActivityDate="2015-09-24T17:56:43.803" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4829" PostTypeId="1" AcceptedAnswerId="4832" CreationDate="2015-09-23T19:05:25.840" Score="4" ViewCount="947" Body="&lt;p&gt;I have a giant html file which is a mess (not my fault). I want to add to some nodes (about 400) a unique id. They all have are of the same class, so I can add the id like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:% s/class=&quot;some-class&quot;/&amp;amp; id=&amp;lt;some id&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is generating the id - its has to be unique for each match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="342" LastEditorUserId="1841" LastEditDate="2015-09-23T20:21:30.117" LastActivityDate="2015-09-23T21:07:50.187" Title="How to add a uid to html nodes?" Tags="|text-generation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4830" PostTypeId="1" CreationDate="2015-09-23T19:19:49.987" Score="2" ViewCount="1024" Body="&lt;p&gt;Upon opening a new file in an active buffer in the current window, the message line at the very bottom of the screen shows &lt;code&gt;&quot;%f&quot; [New File]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does Vim know that the buffer contains a new file, rather than an existing file? I want to detect this in order to test whether quickfix has correctly parsed a file name from an error message. Since &lt;code&gt;getqflist()&lt;/code&gt; gives &lt;code&gt;'bufno'&lt;/code&gt; instead of &lt;code&gt;'filename'&lt;/code&gt;, I can't use &lt;code&gt;filereadable()&lt;/code&gt; for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also tried checking &lt;code&gt;getbufvar()&lt;/code&gt; but until you actually try to &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix&quot; rel=&quot;nofollow&quot;&gt;jump to the error with &lt;code&gt;:cc&lt;/code&gt;&lt;/a&gt;, any buffers created by quickfix after parsing an error message for a file name are unlisted and &lt;code&gt;getbufvar()&lt;/code&gt; returns an empty dictionary. I want to determine whether the buffer will contain a new or existing file and intervene &lt;em&gt;before&lt;/em&gt; jumping to the error and opening the file. &lt;/p&gt;&#xA;" OwnerUserId="800" LastActivityDate="2015-12-22T20:49:45.207" Title="How can I detect whether an unlisted buffer contains a new file or an existing file?" Tags="|vimscript|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4831" PostTypeId="2" ParentId="4830" CreationDate="2015-09-23T19:19:49.987" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#functions&quot; rel=&quot;nofollow&quot;&gt;list of built-in functions&lt;/a&gt; includes &lt;code&gt;bufname&lt;/code&gt;, which can retrieve the filename displayed in the output of &lt;code&gt;ls!&lt;/code&gt; from an unlisted buffer, before/without listing it:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;bufname( {expr})      String  Name of the buffer {expr}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, if you know the number of the buffer, you can use &lt;code&gt;filereadable()&lt;/code&gt; as in the following example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let qflist = getqflist()&#xA;for item in qflist&#xA;    let readable = filereadable(bufname(item.bufnr))&#xA;    echo bufname(item.bufnr) . &quot; is &quot; . (readable ? &quot;&quot; : &quot;not &quot;) . &quot;a readable file.&quot;&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="800" LastActivityDate="2015-09-23T19:19:49.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4832" PostTypeId="2" ParentId="4829" CreationDate="2015-09-23T20:17:24.623" Score="3" Body="&lt;p&gt;Could you use the expression replacement (&lt;code&gt;:help sub-replace-expression&lt;/code&gt;) and a simple counter function? Something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyCount()&#xA;    if exists('w:count')&#xA;        let w:count = w:counter + 1&#xA;    else &#xA;        let w:count = 1&#xA;    endif&#xA;    return w:count&#xA;endfunc&#xA;&#xA;:%s/class=&quot;some-class&quot;/\=submatch(0) . ' &quot;id&quot;=&quot;' . MyCount() . '&quot;'/&#xA;:unlet w:counter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming the id attribute and value should both be enclosed in quotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;submatch()&lt;/code&gt; is similar to &lt;code&gt;\0&lt;/code&gt; in the replacement, but plays well with in an expression replacement (see &lt;code&gt;:help submatch()&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2015-09-23T20:17:24.623" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4833" PostTypeId="2" ParentId="4829" CreationDate="2015-09-23T20:42:51.617" Score="2" Body="&lt;p&gt;Based on the solution given by @jjaderberg, on Linux systems you can get a uuid with the command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uuidgen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A solution could be to use the following one liner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/class=&quot;some-class&quot;/\=submatch(0) . ' id=' . system('uuidgen')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get this kind of result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class=&quot;some-class&quot; id=db2c6d1c-4646-4998-bec8-c697e5bc668c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This clearly isn't the best solution (I think jjaderbeg's one is far better), but I think the idea to add the result of an external command in a substitution can &lt;em&gt;(sometimes)&lt;/em&gt; be interesting .&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-09-23T21:07:50.187" LastActivityDate="2015-09-23T21:07:50.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4834" PostTypeId="2" ParentId="4823" CreationDate="2015-09-23T21:24:09.790" Score="2" Body="&lt;p&gt;&lt;code&gt;xdg-open&lt;/code&gt; relies on &lt;code&gt;.desktop&lt;/code&gt; files, so you'll have to create on and then associate it with the right mimetypes. If you can't/won't use GVim, you can still piggy-back on its &lt;code&gt;.desktop&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ grep -v Comment /usr/share/applications/gvim.desktop &#xA;[Desktop Entry]&#xA;Name=GVim&#xA;GenericName=Text Editor&#xA;GenericName[de]=Texteditor&#xA;TryExec=gvim&#xA;Exec=gvim -f %F&#xA;Terminal=false&#xA;Type=Application&#xA;Icon=vim&#xA;Categories=Utility;TextEditor;&#xA;StartupNotify=true&#xA;MimeType=text/plain;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Copy the contents to a &lt;code&gt;vim.desktop&lt;/code&gt;, while:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;replacing &lt;code&gt;gvim&lt;/code&gt; with &lt;code&gt;vim&lt;/code&gt; for &lt;code&gt;TryExec&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;using your &lt;code&gt;vim --remote&lt;/code&gt; command for &lt;code&gt;Exec&lt;/code&gt;. &lt;code&gt;%F&lt;/code&gt;, as you might have deduced, will be replaced with the filenames.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then, copy this to &lt;code&gt;~/.local/share/applications&lt;/code&gt; and mark it as executable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cp vim.desktop ~/.local/share/applications&#xA;chmod +x ~/.local/share/applications/vim.desktop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In whatever method you use to access launchers for your installed apps (Unity's Dash, GNOME Shell's Overview, MATE/XFCE/Clementine's menu, etc.), you should see a new Vim entry, indicating that the &lt;code&gt;.desktop&lt;/code&gt; file was correctly created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, to associate it with text files, you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xdg-mime default vim.desktop text/plain&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-09-23T21:24:09.790" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4835" PostTypeId="1" CreationDate="2015-09-23T22:51:44.953" Score="9" ViewCount="4950" Body="&lt;p&gt;Has anyone used GNU global with vim? I'm navigating through a large C++ code base and have some trouble figuring out how to use it. I want to use its gtags-cscope functionality but I can't figure out how to generate a cross reference database which later I can connect to vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help in finding the solution is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2865" LastActivityDate="2017-04-19T07:33:55.537" Title="GNU global and vim" Tags="|tags|cscope|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4836" PostTypeId="1" AcceptedAnswerId="4837" CreationDate="2015-09-24T01:40:11.683" Score="3" ViewCount="18185" Body="&lt;p&gt;I'd like to replace the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ThisIsALoooongNameOfATwoDArray[100-rowIndex][j-2]-ThisIsALoooongNameOfATwoDArray[100+rowIndex][j+2];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ptr[j-2]-Ptr[j+2];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried the command &lt;code&gt;:%s/This.*ex\]/Ptr/g&lt;/code&gt; (and &lt;code&gt;/gc&lt;/code&gt; variation), It turns out the regular expression performs the longest matching and the result becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ptr[j+2];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any simple way to achieve my goal? (I know I can delete it one by one and/or use &lt;code&gt;q&lt;/code&gt; macro. Just wonder if we can do something using the &quot;restricted&quot; regular expression.)&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="205" LastEditDate="2015-09-24T02:29:31.733" LastActivityDate="2015-09-24T02:38:48.717" Title="How to match the first occurence of a repeating pattern on the same line?" Tags="|regular-expression|search|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4837" PostTypeId="2" ParentId="4836" CreationDate="2015-09-24T01:55:35.850" Score="1" Body="&lt;p&gt;You can use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\mThis.\{-}]/Ptr/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\{-}&lt;/code&gt; will match as few as possible characters before the following character in the regex. This allows to match only the first pair of brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be more detailled:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\m&lt;/code&gt; use magic flavor of regex&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;This&lt;/code&gt; match literally the string &lt;code&gt;This&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.\{-}]&lt;/code&gt; match as few as possible character before the following &lt;code&gt;]&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-09-24T02:14:43.147" LastActivityDate="2015-09-24T02:14:43.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4838" PostTypeId="2" ParentId="4836" CreationDate="2015-09-24T02:38:48.717" Score="1" Body="&lt;p&gt;A greedy alternative:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/This[^]]*ex\]/Ptr/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[^]]*&lt;/code&gt; matches anything but &lt;code&gt;]&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ex\]&lt;/code&gt; matches literally &lt;code&gt;ex]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-09-24T02:38:48.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4839" PostTypeId="1" CreationDate="2015-09-24T09:08:15.223" Score="4" ViewCount="1628" Body="&lt;p&gt;In general, is there a way to UNDO the last &quot;meta&quot; command (I mean a command entered in command line to manage a window ), or some equivalent keystroke sequence ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Btw, I know the &lt;code&gt;u&lt;/code&gt; (= undo) and &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;R&lt;/kbd&gt; (= redo) works for commands that edits/changes a file content. Ok, but:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let consider the scenario in screenshot here attached, where I'm editing multiple files in a multiwindow/multitab:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nVi6H.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nVi6H.png&quot; alt=&quot;multiple window in vim screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, let say for example that I enter for typo or error a &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;O&lt;/kbd&gt; to exlicitly edit &lt;code&gt;:only&lt;/code&gt; and afterward I would UNDO, to go back to last window layout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command/keystroke to go back o the previous window layout ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can use &lt;code&gt;:ball&lt;/code&gt; (reshow all buffers each in a window horizontally splitted) or &lt;code&gt;:vert ball&lt;/code&gt; (same with vertical split), but in this way I loss all windows layout setting (window resized/personalized, visual window sequence, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More in general, how can I undo commands entered in command line or using some keystroke sequence alias ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware of course that some commands are pretty &quot;irreversible&quot;; like &lt;code&gt;:w&lt;/code&gt; for example, but I'd love a UNDO for many commands that just manage layout/buffers/&quot;in-memory&quot; work.&lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="25223" LastEditDate="2019-10-26T18:04:49.983" LastActivityDate="2019-10-26T18:04:49.983" Title="How can I undo last command in command line?" Tags="|command-line|vim-windows|tabbed-user-interface|undo-redo|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4840" PostTypeId="2" ParentId="4817" CreationDate="2015-09-24T13:28:58.147" Score="1" Body="&lt;p&gt;@romainl answers doesn't work well if you use NerdTree (I don't want to go to the latest Nerdtree buffer), so here is my solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put this in your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Buflisted()&#xA;  return filter(range(1, bufnr('$')), 'buflisted(v:val)')&#xA;endfunction&#xA;&#xA;function! g:Go_to_last_file()&#xA;  let b = extend(&#xA;  \ filter(copy(v:oldfiles),&#xA;  \        &quot;v:val !~ 'fugitive:\\|NERD_tree\\|^/tmp/\\|.git/'&quot;),&#xA;  \ filter(map(s:Buflisted(), 'bufname(v:val)'), '!empty(v:val)'))&#xA;  execute(&quot;e &quot; . b[0])&#xA;  return b[0]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in your bashrc : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias lvim=&quot;vim -c 'silent call g:Go_to_last_file()'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1543" LastEditorUserId="1543" LastEditDate="2015-10-16T14:09:34.300" LastActivityDate="2015-10-16T14:09:34.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4841" PostTypeId="1" AcceptedAnswerId="4842" CreationDate="2015-09-24T16:03:59.080" Score="2" ViewCount="486" Body="&lt;p&gt;I am trying to get VIM to run the right makefile for a specific source file.  For example, if the current file is &lt;code&gt;ui8_c_buff_test.cpp&lt;/code&gt; and if I use the &lt;code&gt;makeprg&lt;/code&gt; configuration below and run &lt;code&gt;make&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;makeprg = 'make -f '.fnameescape(substitute(expand('%'), '\m_test\.cpp$', '.makefile', '')) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the system should run against the &lt;code&gt;ui8_c_buff_test.cpp&lt;/code&gt; and execute &lt;code&gt;make -f dispatcher/unittest/ui8_c_buff.makefile&lt;/code&gt;, but it is running against the &lt;code&gt;.vimrc&lt;/code&gt; file where the &lt;code&gt;makeprg&lt;/code&gt; is set, and I get the following result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/sporty/.vimrc:1: *** missing separator (did you mean TAB instead of 8 spaces?).  Stop.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I run the following command,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo 'make -f '.fnameescape(substitute(expand('%'), '\m_test\.cpp$', '.makefile', ''))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get a correct result, which is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make -f dispatcher/unittest/ui8_c_buff.makefile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So how can I get the makeprg to run against the current file instead of .vimrc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I asked a question here: &lt;a href=&quot;https://vi.stackexchange.com/questions/4503/determining-makefile-based-on-source-file-name&quot;&gt;Determining makefile based on source file name&lt;/a&gt;, and got an answer, but  most of the time it does not work.  &lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-09-25T05:44:12.717" Title="Why is make running against a wrong file?" Tags="|vimrc|makeprg|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4842" PostTypeId="2" ParentId="4841" CreationDate="2015-09-24T16:45:35.770" Score="5" Body="&lt;p&gt;The right-hand side of &lt;code&gt;let &amp;amp;makeprg = ...&lt;/code&gt; is evaluated only once.  If you put that command in your &lt;code&gt;.vimrc&lt;/code&gt; as it is, &lt;code&gt;%&lt;/code&gt;expands to &lt;code&gt;/home/sporty/.vimrc&lt;/code&gt; and you get the interesting effect you describe.  You need to put it in an &lt;code&gt;autocmd&lt;/code&gt;, so that it gets re-evaluated every time you open a file of the relevant type.  Also, you probably want to use the local version of &lt;code&gt;makeprg&lt;/code&gt; rather than the global one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd  BufRead,BufNewFile  *.cpp&#xA;    \ let &amp;amp;l:makeprg = 'make -f '.fnameescape(substitute(expand('%:t'), '\m_test\.cpp$', '.makefile', ''))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll probably still have to solve the problem of running &lt;code&gt;make&lt;/code&gt; in the correct directory.  One way to get around that is to always open your files starting from the base directory of your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; As @Ben points out in comments, you can deal with changing directories automatically with another &lt;code&gt;autocmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd QuickfixCmdPre *.makefile&#xA;    \ let s:makefile = substitute(expand('%:t'), '\m_test\.cpp$', '.makefile', '') |&#xA;    \ let s:base = findfile(s:makefile, escape(expand('%:p:h'), ' ') . ';') |&#xA;    \ if s:base !=# '' |&#xA;    \     execute 'lcd ' . fnameescape(expand(s:base, '%:p:h')) |&#xA;    \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="2313" LastEditDate="2015-09-25T05:44:12.717" LastActivityDate="2015-09-25T05:44:12.717" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4843" PostTypeId="2" ParentId="562" CreationDate="2015-09-24T19:33:34.990" Score="3" Body="&lt;p&gt;Long lost and almost forgotten.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meant to re-factor the code etc. but post is as is. This code is used on a 32-bit system. Not sure how it would behave on 64-bit (or other).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a hack in C-code somewhere as well, (extracting PID).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Leave it as a post for anyone to hack and tweak. My current script as a whole (using &lt;code&gt;pid&lt;/code&gt; as option it should work on any GUI given it's &lt;em&gt;“GUI-PID/Program”&lt;/em&gt; and the use of &lt;code&gt;wmctrl -l -p&lt;/code&gt; and so on):&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;# Please leave in place:&#xA;# http://vi.stackexchange.com/q/562/220&#xA;&#xA;declare -i debug=1&#xA;declare -i pid=0&#xA;opt=j&#xA;&#xA;# Usage&#xA;usage()&#xA;{&#xA;    printf &quot;Usage: %s [[opt] &amp;lt;PID&amp;gt;] | [[opt] &amp;lt;SWP&amp;gt;]\n&quot; &quot;${0/*\//}&quot;&#xA;    printf &quot;\nopt:\n&quot;&#xA;    printf &quot;   j   : Jump to window. (Default)\n&quot;&#xA;    printf &quot;   g   : Get window. (E.g. from other workspace.)\n&quot;&#xA;    printf &quot;   l   : List windows.\n&quot;&#xA;    printf &quot;   p   : Only print. (With some extra info.)\n&quot;&#xA;    printf &quot;   s   : Alias for j. (switch)\n&quot;&#xA;    printf &quot;   i   : Alias for p. (information)\n&quot;&#xA;    printf &quot;   h   : This help.\n&quot;&#xA;    printf &quot;\n&quot;&#xA;    printf &quot;  &amp;lt;PID&amp;gt;: Process ID.\n&quot;&#xA;    printf &quot;  &amp;lt;SWP&amp;gt;: Read PID from Vim swap file.\n&quot;&#xA;    if (($#)); then&#xA;        printf &quot;\nERR: Unknown option %s\n&quot; &quot;$1&quot;&#xA;    fi&#xA;}&#xA;&#xA;# Check if PID is a (G)Vim process&#xA;check_vim_pid()&#xA;{&#xA;    local comm=&#xA;    if ! [[ &quot;$1&quot; =~ ^[0-9]+$ ]];then&#xA;        printf &quot;ERR: Some weird thing has happened (P: $1).\n&quot; &amp;gt;&amp;amp;2&#xA;        exit 1&#xA;    fi&#xA;    comm=&quot;$(ps -p $1 -o comm=)&quot;&#xA;    [[ &quot;$comm&quot; =~ ^g?vim$ ]] &amp;amp;&amp;amp; return 0 || return 1&#xA;}&#xA;&#xA;# First two bytes should be b0, bc or bC&#xA;# Or in hex 0x6230, 0x6263 or 0x6243&#xA;check_b0()&#xA;{&#xA;    local b01=&quot;${1:0:2}&quot;&#xA;    local b02=&quot;${1:2:2}&quot;&#xA;&#xA;    if [[ $b01 != '62' ]] ||&#xA;        ([[ &quot;$b02&quot; != '30' &amp;amp;&amp;amp; &quot;$b02&quot; != '63' &amp;amp;&amp;amp; &quot;$b02&quot; != '43' ]]); then&#xA;        return 1&#xA;    fi&#xA;    return 0&#xA;}&#xA;&#xA;# Read PID from swap file.&#xA;# Se notes below for information.&#xA;vim_file=&quot;&quot;&#xA;vim_swp_pid()&#xA;{&#xA;    local swp=&quot;$1&quot;&#xA;&#xA;    if ! [[ -r &quot;$swp&quot; ]]; then&#xA;        printf &quot;ERR: Not able to read $swp.\n&quot; &amp;gt;&amp;amp;2&#xA;        exit 2&#xA;    fi&#xA;&#xA;    # Read b0 ID&#xA;    local b0_id=&quot;$(xxd -l 2 -p &quot;$swp&quot;)&quot;&#xA;    if ! check_b0 &quot;$b0_id&quot;; then&#xA;        printf &quot;ERR: Bad b0 ID in file (Not Vim-swap?): %s\n&quot; &quot;$b0_id&quot; &amp;gt;&amp;amp;2&#xA;        exit 3&#xA;    fi&#xA;    # Read PID from .swp file&#xA;    local -a opid=($(xxd -s 24 -l 4 -p -c 1 &quot;$swp&quot;))&#xA;    # Read int magic from .swp file&#xA;    local magic=$(xxd -s 1008 -l 8 -p &quot;$swp&quot;)&#xA;&#xA;    if [[ &quot;${magic:0:8}&quot; == &quot;33323130&quot; ]]; then&#xA;        # Intel (LittleEndian)&#xA;        pid=$(printf &quot;%d&quot; &quot;0x${opid[3]}${opid[2]}${opid[1]}${opid[0]}&quot;)&#xA;    elif [[ &quot;${magic:0:8}&quot; == &quot;30313233&quot; ]] ||&#xA;        [[ &quot;${magic:8:8}&quot; == &quot;30313233&quot; ]]; then&#xA;        # Motorola (BigEndian)&#xA;        pid=$(printf &quot;%d&quot; &quot;0x${opid[0]}${opid[1]}${opid[2]}${opid[3]}&quot;)&#xA;    else&#xA;        printf &quot;ERR: Unknown byteroder: %s\n&quot; &quot;$magic&quot; &amp;gt;&amp;amp;2&#xA;        exit 4&#xA;    fi&#xA;    if ! check_vim_pid $pid; then&#xA;        printf &quot;N010: PID %d is not a Vim process.\n&quot; &quot;$pid&quot; &amp;gt;&amp;amp;2&#xA;        exit 10&#xA;    fi&#xA;    # Read file name&#xA;    vim_file=&quot;$(xxd -s 108 -l 800 -ps &quot;$1&quot; | xxd -r -p)&quot;&#xA;}&#xA;&#xA;list_windows()&#xA;{&#xA;    local winid desk pid host title comm&#xA;    printf &quot;%-10s %-3s %-6s %-16s %s\n&quot; &quot;WINID&quot; &quot;DSK&quot; &quot;PID&quot; &quot;COMM&quot; &quot;TITLE&quot;&#xA;    while IFS=$' \n' read -r winid desk pid host title; do&#xA;        cf=&quot;/proc/$pid/comm&quot;&#xA;        [[ -r &quot;$cf&quot; ]] &amp;amp;&amp;amp; read -r comm &amp;lt; &quot;$cf&quot;&#xA;        printf &quot;%10s %3d %6d %-16s %s\n&quot; &quot;$winid&quot; &quot;$desk&quot; &quot;$pid&quot; &quot;$comm&quot; &quot;$title&quot;&#xA;    done &amp;lt;&amp;lt;&amp;lt; &quot;$(wmctrl -lp)&quot;&#xA;}&#xA;# ------------------------- RUN -------------------------------------------- #&#xA;&#xA;# Check if any arguments (a bit redundant, but OK)&#xA;if [[ -z &quot;$1&quot; ]]; then&#xA;    usage &amp;gt;&amp;amp;2&#xA;    exit 1&#xA;fi&#xA;&#xA;# Loop arguments&#xA;while [[ &quot;$1&quot; ]]; do&#xA;    if [[ &quot;$1&quot; =~ ^[0-9]+$ ]]; then&#xA;        pid=$1&#xA;    else&#xA;        [[ &quot;${1:0:1}&quot; == &quot;-&quot; ]] &amp;amp;&amp;amp; op=${1:1} || op=$1&#xA;        case &quot;$op&quot; in&#xA;        l) list_windows; exit 0;;&#xA;        d) debug=1;;&#xA;        h|-help) usage; exit 0;;&#xA;        j|s|g|p|i) opt=$op;;&#xA;        *)&#xA;            if ! [[ -e &quot;$1&quot; ]]; then&#xA;                usage &amp;gt;&amp;amp;2;&#xA;                printf &quot;\nE006: Can't stat \`%s'\n&quot; &quot;$1&quot; &amp;gt;&amp;amp;2&#xA;                exit 2&#xA;            fi&#xA;            vim_swp_pid &quot;$1&quot;&#xA;            ;;&#xA;        esac&#xA;    fi&#xA;    shift&#xA;done&#xA;&#xA;# Check if PID is set&#xA;if !(($pid)); then&#xA;    usage &amp;gt;&amp;amp;2&#xA;    printf &quot;E011: PID required / Not found.\n&quot; &amp;gt;&amp;amp;2&#xA;    exit 11&#xA;fi&#xA;&#xA;# Read WindowID, Workspace, PID of all-windows then filter by PID&#xA;read -r wid ws &amp;lt;&amp;lt;&amp;lt;$(wmctrl -l -p | awk -v p=&quot;$pid&quot; '$3 == p {print $1,&quot;\t&quot;,$2}')&#xA;&#xA;pikoli()&#xA;{&#xA;    local pp=$1&#xA;    while :; do&#xA;        awk '/^PPid:/{print $2;next}/^Name:/{print $2;next}' /proc/$pp/status 2&amp;gt;/dev/null || return&#xA;        pp=$(awk '/^PPid:/{print $2;next}' /proc/$pp/status)&#xA;    done&#xA;}&#xA;&#xA;if ! [[ &quot;$wid&quot; ]]; then&#xA;    pikoli $pid&#xA;    printf &quot;ERR: Window not fround from PID %d.\n&quot; &quot;$pid&quot; &amp;gt;&amp;amp;2&#xA;    exit 12&#xA;fi&#xA;&#xA;# As most DM's names desktops from 1 and not 0, a more user-friendly number.&#xA;((dmws=ws + 1))&#xA;&#xA;# Do the action!&#xA;((debug)) &amp;amp;&amp;amp; printf &quot;PID=%d, WID=%s, WS=%d\n&quot; &quot;$pid&quot; &quot;$wid&quot; &quot;$ws&quot;&#xA;case &quot;$opt&quot; in&#xA;j|s)    printf &quot;Swithching to workspace %d raising window %s by PID %d.\n&quot; \&#xA;        &quot;$dmws&quot; &quot;$wid&quot; &quot;$pid&quot;;&#xA;    wmctrl -ia &quot;$wid&quot;&#xA;    ;;&#xA;g)    printf &quot;Getting window %s by PID %d from workspace %d.\n&quot; \&#xA;        &quot;$wid&quot; &quot;$pid&quot; &quot;$dmws&quot;;&#xA;    wmctrl -iR &quot;$wid&quot;&#xA;    ;;&#xA;i|p)    printf &quot;Window is on workspace %d having window ID %s by PID %d.\n&quot; \&#xA;        &quot;$dmws&quot; &quot;$wid&quot; &quot;$pid&quot;;&#xA;    xwininfo -id $wid&#xA;    ;;&#xA;esac&#xA;&#xA;exit 0&#xA;&#xA;#############################################################################&#xA;# ----------------- Vim swap file block zero format ----------------------- #&#xA;#############################################################################&#xA;#&#xA;# No script / bash code beyond here&#xA;#&#xA;&#xA;NOTES 'memline.c:139':&#xA;&#xA;:62&#xA;#define BLOCK0_ID0     'b'          /* block 0 id 0 */&#xA;#define BLOCK0_ID1     '0'          /* block 0 id 1 */&#xA;#define BLOCK0_ID1_C0  'c'          /* block 0 id 1 'cm' 0 */&#xA;#define BLOCK0_ID1_C1  'C'          /* block 0 id 1 'cm' 1 */&#xA;&#xA;:124&#xA;#define B0_FNAME_SIZE_ORG   900 /* what it was in older versions */&#xA;#define B0_FNAME_SIZE_NOCRYPT   898 /* 2 bytes used for other things */&#xA;#define B0_FNAME_SIZE_CRYPT 890 /* 10 bytes used for other things */&#xA;#define B0_UNAME_SIZE       40&#xA;#define B0_HNAME_SIZE       40&#xA;/*&#xA; * Restrict the numbers to 32 bits, otherwise most compilers will complain.&#xA; * This won\'t detect a 64 bit machine that only swaps a byte in the top 32&#xA; * bits, but that is crazy anyway.&#xA; */&#xA;#define B0_MAGIC_LONG   0x30313233L&#xA;#define B0_MAGIC_INT    0x20212223L&#xA;#define B0_MAGIC_SHORT  0x10111213L&#xA;#define B0_MAGIC_CHAR   0x55&#xA;&#xA;:139&#xA;/*&#xA; * Block zero holds all info about the swap file.&#xA; *&#xA; * NOTE: DEFINITION OF BLOCK 0 SHOULD NOT CHANGE! It would make all existing&#xA; * swap files unusable!&#xA; *&#xA; * If size of block0 changes anyway, adjust MIN_SWAP_PAGE_SIZE in vim.h!!&#xA; *&#xA; * This block is built up of single bytes, to make it portable across&#xA; * different machines. b0_magic_* is used to check the byte order and size of&#xA; * variables, because the rest of the swap file is not portable.&#xA; */&#xA;struct block0&#xA;{&#xA;    char_u  b0_id[2];   /* id for block 0: BLOCK0_ID0 and BLOCK0_ID1,&#xA;                 * BLOCK0_ID1_C0, BLOCK0_ID1_C1 */&#xA;    char_u  b0_version[10]; /* Vim version string */&#xA;    char_u  b0_page_size[4];/* number of bytes per page */&#xA;    char_u  b0_mtime[4];    /* last modification time of file */&#xA;    char_u  b0_ino[4];  /* inode of b0_fname */&#xA;    char_u  b0_pid[4];  /* process id of creator (or 0) */&#xA;    char_u  b0_uname[B0_UNAME_SIZE]; /* name of user (uid if no name) */&#xA;    char_u  b0_hname[B0_HNAME_SIZE]; /* host name (if it has a name) */&#xA;    char_u  b0_fname[B0_FNAME_SIZE_ORG]; /* name of file being edited */&#xA;    long    b0_magic_long;  /* check for byte order of long */&#xA;    int     b0_magic_int;   /* check for byte order of int */&#xA;    short   b0_magic_short; /* check for byte order of short */&#xA;    char_u  b0_magic_char;  /* check for last char */&#xA;};&#xA;&#xA;offs    len     what&#xA;0       2       id&#xA;2       10      version&#xA;12      4       bytes per page&#xA;16      4       mtime&#xA;20      4       inode&#xA;24      4       PID or 0&#xA;28      40      name of user or uid&#xA;68      40      host name&#xA;108     900     fname&#xA;1008    4/8/    magic long*&#xA;1012    4/8/    magic int*&#xA;1016    2/      magic short*&#xA;1018    1/      magic char*&#xA;&#xA;Length of magics is arch dependant.&#xA;Offset for magic, in example above, is by standard 32 bit.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2015-09-24T19:40:04.653" LastActivityDate="2015-09-24T19:40:04.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4844" PostTypeId="1" CreationDate="2015-09-24T20:19:31.690" Score="3" ViewCount="296" Body="&lt;p&gt;I find &lt;code&gt;:set hlsearch&lt;/code&gt; useful while I am entering the pattern; but I want the effect of &lt;code&gt;:noh&lt;/code&gt; as soon as I press enter. Is that possible?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-01-02T22:35:10.320" Title="Turn off highlights when pattern is entered" Tags="|highlight|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4845" PostTypeId="1" AcceptedAnswerId="4846" CreationDate="2015-09-24T20:31:53.603" Score="2" ViewCount="193" Body="&lt;p&gt;Some command sequences consisting of &lt;code&gt;\&lt;/code&gt; and a non-letter (&lt;code&gt;,&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt;) are not coloured (&lt;code&gt;\&amp;amp;&lt;/code&gt; is). How to fix?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2015-09-24T22:57:27.613" LastActivityDate="2015-09-24T22:57:27.613" Title="vim-latex/latex-suite: command sequences not coloured" Tags="|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4846" PostTypeId="2" ParentId="4845" CreationDate="2015-09-24T20:40:16.327" Score="2" Body="&lt;p&gt;Maybe to signal that your macro/command would be &lt;a href=&quot;http://www.tex.ac.uk/FAQ-linmacnames.html&quot; rel=&quot;nofollow&quot;&gt;invalid&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not saying it's the right way, just what's the idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim TeX statements (part of the &lt;code&gt;texCmdGroup&lt;/code&gt;), from &lt;code&gt;$VIMRUNTIME/syntax/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; TeX/LaTeX keywords: {{{1&#xA;&quot; Instead of trying to be All Knowing, I just match \..alphameric..&#xA;&quot; Note that *.tex files may not have &quot;@&quot; in their \commands&#xA;if exists(&quot;g:tex_tex&quot;) || b:tex_stylish&#xA;  syn match texStatement    &quot;\\[a-zA-Z@]\+&quot;&#xA;else&#xA;  syn match texStatement    &quot;\\\a\+&quot;&#xA;  if !exists(&quot;s:tex_no_error&quot;) || !s:tex_no_error&#xA;   syn match texError       &quot;\\\a*@[a-zA-Z@]*&quot;&#xA;  endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In addition, recognized special chars are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match texSpecialChar    &quot;\\[$&amp;amp;%#{}_]&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add a syntax rule for the &lt;code&gt;texStatement&lt;/code&gt; in &lt;code&gt;~/.vim/after/syntax/tex.vim&lt;/code&gt;: e.g. &lt;code&gt;syn match texStatement &quot;\\[0-9 ,;\\]&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-09-24T22:54:28.350" LastActivityDate="2015-09-24T22:54:28.350" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4847" PostTypeId="1" AcceptedAnswerId="6248" CreationDate="2015-09-24T20:54:18.390" Score="11" ViewCount="2524" Body="&lt;p&gt;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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally I'd do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat &amp;gt;&amp;gt; ~/.bashrc &amp;lt;&amp;lt;EOF&#xA;export PATH=~/.composer/vendor/bin:\$PATH&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is also possible to do it via ansible (&lt;code&gt;line&lt;/code&gt;+&lt;code&gt;insertafter=EOF&lt;/code&gt;+&lt;code&gt;regexp&lt;/code&gt;), but it's another story.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vi/ex I could do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex +'$s@$@\rexport PATH=\~/.composer/vendor/bin:$PATH@' -cwq ~/.bashrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but then how do I check if the line is already there (and thus do nothing) ideally without repeating the same line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or maybe there is some easier way to do it in Ex editor?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="1841" LastEditDate="2015-10-01T17:48:23.487" LastActivityDate="2016-04-12T00:38:16.237" Title="How to append some line at the end of the file only if it's not there yet?" Tags="|substitute|ex-command|" AnswerCount="6" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4848" PostTypeId="1" CreationDate="2015-09-24T21:55:32.237" Score="2" ViewCount="909" Body="&lt;p&gt;I have the following mapping in my project:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F7&amp;gt; :execute '!gtags'&amp;lt;cr&amp;gt; :cscope kill -1&amp;lt;cr&amp;gt; :cscope add CTAGS&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Under certain conditions I want to be able to execute this mapping from a script, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (mycondition)&#xA;  execute 'normal &amp;lt;F7&amp;gt;'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code above didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody know if it is possible to do something like that?&lt;/p&gt;&#xA;" OwnerUserId="2865" LastEditorUserId="1841" LastEditDate="2015-09-24T22:07:24.460" LastActivityDate="2016-05-18T05:20:51.313" Title="How to execute a mapping on &lt;F7&gt; key from a script?" Tags="|vimscript|key-bindings|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4849" PostTypeId="2" ParentId="4848" CreationDate="2015-09-24T22:05:07.300" Score="2" Body="&lt;p&gt;You have to insert the escape code corresponding to &lt;kbd&gt;F7&lt;/kbd&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do so in insert mode on my system, I used &lt;kbd&gt;Ctrl-v&lt;/kbd&gt;&lt;kbd&gt;F7&lt;/kbd&gt;. It inserted &lt;code&gt;^[[18~&lt;/code&gt; and the script worked.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="4676" LastEditDate="2016-05-18T05:20:51.313" LastActivityDate="2016-05-18T05:20:51.313" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="4850" PostTypeId="1" AcceptedAnswerId="4851" CreationDate="2015-09-25T02:33:37.677" Score="5" ViewCount="4982" Body="&lt;p&gt;I'm not sure if I should ask this problem on vim or on Linux/Ubuntu forum. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is, I opened multiple terminals on my desktop, and several of them opened various of &lt;code&gt;*.txt&lt;/code&gt; files. Not all of them are saved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then my desktop partially broke down. I can ssh it from my laptop. Is there any way to know which files are opened in vim? And is there any way I can save the unsaved files?&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="467" LastEditDate="2017-11-16T12:20:15.103" LastActivityDate="2019-04-29T20:15:56.257" Title="How to show all unsaved files opened in vim?" Tags="|save|linux|crash-recovery|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4851" PostTypeId="2" ParentId="4850" CreationDate="2015-09-25T03:05:18.390" Score="3" Body="&lt;p&gt;If you can modify those files, it's likely that Vim created swap files for them. Swap files have extensions &lt;code&gt;.swp&lt;/code&gt;, &lt;code&gt;.swo&lt;/code&gt;, ..., etc. You can search for these files using &lt;code&gt;find&lt;/code&gt;. Looking in your home directory, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find ~ -type f -name '.*.sw?'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the Vim programs are still running, you could expedite the search by looking at which files are opened by the Vim processes. This can be done by examining the process' &lt;code&gt;/proc&lt;/code&gt; entry and finding where the &lt;code&gt;fd&lt;/code&gt;s point to (&lt;code&gt;ls -l /proc/&amp;lt;pid&amp;gt;/fd/&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ pgrep vim | xargs -i ls /proc/{}/fd -l&#xA;total 0&#xA;lrwx------ 1 muru muru 64 Sep 25 08:31 0 -&amp;gt; /dev/pts/2&#xA;lrwx------ 1 muru muru 64 Sep 25 08:31 1 -&amp;gt; /dev/pts/2&#xA;lrwx------ 1 muru muru 64 Sep 25 08:31 2 -&amp;gt; /dev/pts/2&#xA;lrwx------ 1 muru muru 64 Sep 25 08:31 3 -&amp;gt; socket:[23224440]&#xA;lrwx------ 1 muru muru 64 Sep 25 08:31 5 -&amp;gt; socket:[23220671]&#xA;lrwx------ 1 muru muru 64 Sep 25 08:31 7 -&amp;gt; /tmp/.gameoverlayui.log.swp&#xA;total 0&#xA;lrwx------ 1 muru muru 64 Sep 25 08:31 0 -&amp;gt; /dev/pts/5&#xA;lrwx------ 1 muru muru 64 Sep 25 08:31 1 -&amp;gt; /dev/pts/5&#xA;lrwx------ 1 muru muru 64 Sep 25 08:31 2 -&amp;gt; /dev/pts/5&#xA;lrwx------ 1 muru muru 64 Sep 25 08:31 3 -&amp;gt; socket:[23222572]&#xA;lrwx------ 1 muru muru 64 Sep 25 08:31 5 -&amp;gt; socket:[23223590]&#xA;lrwx------ 1 muru muru 64 Sep 25 08:31 7 -&amp;gt; /home/muru/.vimhelp.vim.swp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, I have two Vim windows, each having one file opened.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I don't think you can control those processes, not easily&lt;sup&gt;1&lt;/sup&gt;, anyway. You &lt;em&gt;can&lt;/em&gt; kill them, and then open those files again. Vim will detect the swap files and offer to recover:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ pkill vim&#xA;$ vim /tmp/gameoverlayui.log&#xA;E325: ATTENTION&#xA;Found a swap file by the name &quot;.gameoverlayui.log.swp&quot;&#xA;          owned by: muru   dated: Fri Sep 25 08:37:49 2015&#xA;         file name: /tmp/gameoverlayui.log&#xA;          modified: YES&#xA;         user name: muru   host name: muru-laptop&#xA;        process ID: 11066&#xA;While opening file &quot;gameoverlayui.log&quot;&#xA;             dated: Fri Sep 25 08:37:43 2015&#xA;&#xA;(1) Another program may be editing the same file.  If this is the case,&#xA;    be careful not to end up with two different instances of the same&#xA;    file when making changes.  Quit, or continue with caution.&#xA;(2) An edit session for this file crashed.&#xA;    If this is the case, use &quot;:recover&quot; or &quot;vim -r gameoverlayui.log&quot;&#xA;    to recover the changes (see &quot;:help recovery&quot;).&#xA;    If you did this already, delete the swap file &quot;.gameoverlayui.log.swp&quot;&#xA;    to avoid this message.&#xA;&#xA;Swap file &quot;.gameoverlayui.log.swp&quot; already exists!&#xA;[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort: &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; You could use reptyr or one of the other solutions described in &lt;a href=&quot;https://unix.stackexchange.com/q/4034/70524&quot;&gt;this Unix &amp;amp; Linux post&lt;/a&gt; to reattach the Vim process to your SSH session. I have no idea how that will work.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2015-09-25T03:10:19.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4852" PostTypeId="1" CreationDate="2015-09-25T06:32:11.077" Score="1" ViewCount="51" Body="&lt;p&gt;I have a pretty huge &lt;code&gt;.vimrc&lt;/code&gt; by now which use to edit &lt;code&gt;tex&lt;/code&gt; documents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also ask questions on MathStackExchange frequently and there I do not have any of the keybindings which I have when I am working using vim. So my typing becomes really slow, especially because I unwittingly use the the same key strokes on MSE text area which I use in vim, giving weird output. Then I end up cleaning up the mess.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to use the same keybindings on MSE which I have in my &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using chromium web browser in Ubuntu 14.04.&lt;/p&gt;&#xA;" OwnerUserId="2369" LastActivityDate="2015-09-25T13:53:02.020" Title="How to use vim editing abilities while asking question on MSE" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4854" PostTypeId="1" CreationDate="2015-09-25T07:46:27.853" Score="2" ViewCount="82" Body="&lt;p&gt;By default, vim will not split long paragraphs (or any paragraphs (= long lines)) across pages. Instead of showing the first part of a paragraph that does not fit into the page entirely, it leaves out all of it, even if this leaves half the screen empty. Can this be changed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, see how line 1 is followed by a blank area as line 2 is too big to fit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Grt1S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Grt1S.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Qt56g.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qt56g.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. I answered this quæstion myself below, but the result is still not quite as I want it. The remaining problem is that, when one scrolls with &lt;code&gt;&amp;lt;ctrl-e&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;ctrl-y&amp;gt;&lt;/code&gt;, vim will only allow the first display line of a paragraph to be at the top of the screen. I want it to be possible to put any display line on top of the screen with &lt;code&gt;&amp;lt;ctrl-e&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;ctrl-y&amp;gt;&lt;/code&gt;. This would be parallel to &lt;code&gt;gj&lt;/code&gt; and &lt;code&gt;gk&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="205" LastEditDate="2015-09-28T07:30:48.617" LastActivityDate="2015-09-28T07:30:48.617" Title="Dividing long paragraphs across pages" Tags="|wrapping|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4855" PostTypeId="1" CreationDate="2015-09-25T07:46:42.893" Score="10" ViewCount="17572" Body="&lt;p&gt;I usually use Vim with an Italian keyboard (I'm from Italy), &#xA;(mainly in an Ubuntu Linux Virtualbox guest from a Windows host). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have problems when I have to enter some frequently used characters (in Unix) not present in Italian keyboard layout, I'm referring especially to these chars:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;tilde: &lt;kbd&gt;~&lt;/kbd&gt; (home directory alias)&lt;/li&gt;&#xA;&lt;li&gt;back quote / back tick: &lt;code&gt;`&lt;/code&gt; (mainly in ruby programs)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Ok, I can use &lt;code&gt;$HOME&lt;/code&gt; instead of &lt;code&gt;~&lt;/code&gt;, but there is any Vim specific way (maybe some keystroke sequence) to enter these (and other) &quot;special&quot; chars non present in keyboard available?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution could be a key-binding in &lt;code&gt;.vimrc&lt;/code&gt;?&#xA;By example I have in my &lt;code&gt;.vimrc&lt;/code&gt; this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map ' `&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but as you can imagine I'm unhappy with this specific key remap...( and I have &lt;code&gt;&amp;lt;Fx&amp;gt;&lt;/code&gt; already occupied) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, Maybe the question is a bit off-topic because it is not related to Vim directly, but to the keyboard hw/ language setting; maybe ask in Stack Overflow is better? &lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="205" LastEditDate="2015-09-25T08:40:43.113" LastActivityDate="2024-02-07T16:06:10.437" Title="How to enter tilde (~), back tick (`) and special chars with a non-US keyboard?" Tags="|key-bindings|vimrc|keyboard-layout|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4856" PostTypeId="1" AcceptedAnswerId="4857" CreationDate="2015-09-25T09:36:15.207" Score="3" ViewCount="717" Body="&lt;p&gt;I am developing a syntax file and I am struggling with a &lt;code&gt;concealends&lt;/code&gt; property :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region Reference start=&quot;{reference}&quot; end=&quot;{/reference}&quot; conceal&#xA;syntax region Name start=&quot;{name}&quot; end=&quot;{/name}&quot; concealends&#xA;&#xA;{name}name1{/name}&#xA;{reference}ref{/reference}{name}name2{/name}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I source the file and the syntax is applied. I run &lt;code&gt;set conceallevel=2&lt;/code&gt; and I have the following &lt;em&gt;display&lt;/em&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region Reference start=&quot;&quot; conceal&#xA;syntax region Name start=&quot;{name}&quot; end=&quot;{/name}&quot; concealends&#xA;&#xA;{name}name1{/name}&#xA;{name}name2{/name}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the conceal property is applied to the &lt;code&gt;reference&lt;/code&gt; block but the concealends is not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this with and  without my &lt;code&gt;vimrc&lt;/code&gt; and the results doesn't change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have an idea of what I am doing wrong ?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2015-09-25T09:54:28.337" Title="Syntax concealends not applied" Tags="|vimrc|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4857" PostTypeId="2" ParentId="4856" CreationDate="2015-09-25T09:54:28.337" Score="2" Body="&lt;p&gt;The help (&lt;code&gt;:syn-concealends&lt;/code&gt;) states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The ends of a region can only be concealed separately&#xA;  in this way when they have their own highlighting via &quot;matchgroup&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I did a little test by using an existing highlight group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region Reference start=&quot;{reference}&quot; end=&quot;{/reference}&quot; conceal&#xA;syntax region Name matchgroup=texStatement start=&quot;{name}&quot; end=&quot;{/name}&quot; concealends&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This hides the &lt;code&gt;{reference}ref{/reference}&lt;/code&gt; completely, and hides the &lt;code&gt;{name}&lt;/code&gt; and &lt;code&gt;{/name}&lt;/code&gt; region markers/ends, leaving &lt;code&gt;name1&lt;/code&gt; and &lt;code&gt;name2&lt;/code&gt; only - I suppose this is what you aim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This isn't a complete answer. Hope the above are a good pointer to further reading - I am an absolute beginner in the syntax area.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-09-25T09:54:28.337" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4858" PostTypeId="2" ParentId="4852" CreationDate="2015-09-25T13:53:02.020" Score="2" Body="&lt;p&gt;There are plugins available to edit text areas with an external editor.&#xA;After a brief google search I found the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://superuser.com/questions/261689/its-all-text-for-chrome&quot;&gt;https://superuser.com/questions/261689/its-all-text-for-chrome&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2015-09-25T13:53:02.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4859" PostTypeId="1" AcceptedAnswerId="4863" CreationDate="2015-09-25T14:03:16.443" Score="1" ViewCount="369" Body="&lt;p&gt;I need to pass a paramter (&lt;code&gt;-extract&lt;/code&gt;) to the jshint syntax checker such that it extracts JavaScript from HTML before checking. Unfortunatly I have no idea how to do that for syntastic. &lt;/p&gt;&#xA;" OwnerUserId="4413" LastActivityDate="2015-09-25T15:20:21.277" Title="How to pass a parameter to JSHint with Syntastic" Tags="|syntax-highlighting|filetype-javascript|plugin-syntastic|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4861" PostTypeId="1" CreationDate="2015-09-25T14:57:19.427" Score="2" ViewCount="289" Body="&lt;p&gt;How does one get uniform tabs/spaces to display properly in other programs (like Less)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, say I am modifying my .vimrc in Vim and I've created two columns on the same line (one for rule and one for comment).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim the comments all line up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=80        &quot; set line length&#xA;set tabstop=4           &quot; how many cols a tab counts for&#xA;set expandtab           &quot; insert spaces for &amp;lt;tab&amp;gt;&#xA;set softtabstop=4       &quot; tabs are 4 spaces&#xA;set shiftwidth=4        &quot; indent/outdent by 4 cols&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now for the sake of example, say I open it again in Less. The output would be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=80        &quot; set line length&#xA;set tabstop=4             &quot; how many cols a tab counts for&#xA;set expandtab             &quot; insert spaces for &amp;lt;tab&amp;gt;&#xA;set softtabstop=4          &quot; tabs are 4 spaces&#xA;set shiftwidth=4        &quot; indent/outdent by 4 cols&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I unknowingly mixing a combination of tabs and spaces? Or does it have to do with my tab settings?&lt;/p&gt;&#xA;" OwnerUserId="4648" LastActivityDate="2015-09-25T15:13:18.587" Title="How to get uniform tabs/spaces in other programs (like Less)" Tags="|vim-windows|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4862" PostTypeId="2" ParentId="4861" CreationDate="2015-09-25T15:13:18.587" Score="3" Body="&lt;p&gt;You always want to use spaces for alignments. Vim's &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; will insert spaces or real tabs depending on the setting of &lt;code&gt;'expandtab'&lt;/code&gt;. You can see the value of &lt;code&gt;'expandtab'&lt;/code&gt; via &lt;code&gt;:set expandtab?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I would suggest you use an some type of aligning plugin to avoid doing this manually. Both &lt;a href=&quot;https://github.com/godlygeek/tabular&quot; rel=&quot;nofollow&quot;&gt;tabular&lt;/a&gt; and &lt;a href=&quot;http://vim-easy-align&quot; rel=&quot;nofollow&quot;&gt;vim-easy-align&lt;/a&gt; are good choices. Example of using tabular:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Tabularize/&quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-09-25T15:13:18.587" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4863" PostTypeId="2" ParentId="4859" CreationDate="2015-09-25T15:20:21.277" Score="4" Body="&lt;p&gt;Syntastic allows passing arguments directly to the checkers using the &lt;code&gt;syntastic_&amp;lt;filetype&amp;gt;_&amp;lt;checker&amp;gt;_&amp;lt;option&amp;gt;&lt;/code&gt; variable name format. It supports global (&lt;code&gt;g:&lt;/code&gt;) and buffer (&lt;code&gt;b:&lt;/code&gt;) variants with the buffer having preference over the global one. &lt;code&gt;filetype&lt;/code&gt; and &lt;code&gt;checker&lt;/code&gt; are obvious so I won't get in detail. &lt;code&gt;option&lt;/code&gt; is what interests you. It can be &lt;code&gt;exe&lt;/code&gt;, &lt;code&gt;args&lt;/code&gt;, &lt;code&gt;fname&lt;/code&gt;, &lt;code&gt;post_args&lt;/code&gt; or &lt;code&gt;tail&lt;/code&gt;. Put one after another they build the command that syntastic will execute. &lt;em&gt;See the help &quot;link&quot; below for more details.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case you probably want to modify &lt;code&gt;args&lt;/code&gt; for (I assume) the &lt;code&gt;html&lt;/code&gt; filetype. You can put this global variable in your vimrc file to pass the command line parameter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_html_jshint_args=&quot;-extract&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or using an auto command set it for a specific buffer. Examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType html let b:syntastic_html_jshint_args=&quot;-extract&quot;&#xA;autocmd BufNewFile,BufRead file.html,another_file.html let b:syntastic_html_jshint_args=&quot;-extract&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can check more details with &lt;code&gt;:help syntastic-config-makeprg&lt;/code&gt; or online at the &lt;a href=&quot;https://github.com/scrooloose/syntastic/blob/36ead6d75ce511a34d01f36051aa4c6d688f73bf/doc/syntastic.txt#L687&quot; rel=&quot;nofollow&quot; title=&quot;version 3.6.0&quot;&gt;github repo&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20" LastActivityDate="2015-09-25T15:20:21.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4864" PostTypeId="2" ParentId="4855" CreationDate="2015-09-25T17:16:56.857" Score="11" Body="&lt;p&gt;From &lt;a href=&quot;https://vimhelp.org/digraph.txt.html#digraph&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help digraph&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Digraphs are used to enter characters that normally cannot be entered by&#xA;an ordinary keyboard.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Running &lt;a href=&quot;https://vimhelp.org/digraph.txt.html#%3Adigraphs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:digraphs&lt;/code&gt;&lt;/a&gt; will show you the currently defined digraphs. &lt;code&gt;`&lt;/code&gt; is defined as &lt;code&gt;'!&lt;/code&gt; and &lt;code&gt;~&lt;/code&gt; is defined as &lt;code&gt;'?&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There are two ways of entering digraphs:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-k&amp;gt; {char1} {char2}&#xA;{char1} &amp;lt;BS&amp;gt; {char2}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The second method requires &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27digraph%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:set digraph&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;That said, &lt;code&gt;inoremap '' ` &lt;/code&gt; might be quicker, assuming you don't often need two &lt;code&gt;'&lt;/code&gt;s in a row. Note that globally remapping &lt;code&gt;''&lt;/code&gt; will mask &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%27%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ''&lt;/code&gt;&lt;/a&gt;, but mapping it in insert and command modes is safe to my knowledge. Off the top of my head, I can't think a similar memorable and convenient alternative for &lt;code&gt;~&lt;/code&gt;. &lt;code&gt;--&lt;/code&gt; and &lt;code&gt;==&lt;/code&gt; seem likely to be used as themselves frequently. Muru's suggestion of &lt;code&gt;+-&lt;/code&gt; could a good option.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastEditorUserId="2736" LastEditDate="2024-02-07T16:06:10.437" LastActivityDate="2024-02-07T16:06:10.437" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4865" PostTypeId="1" AcceptedAnswerId="4868" CreationDate="2015-09-25T21:15:27.683" Score="2" ViewCount="274" Body="&lt;p&gt;I'm looking how I might use &quot;Operator-Pending&quot; mode to make a custom motion that allows change, delete or visual selection of a pattern match under the current cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, after searching for a pattern I would like to place the cursor on any match and type &quot;dim&quot; to delete the whole match (or &quot;cim&quot; to change).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came up with this, which doesn't quite work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MoveOverMatch()&#xA;    &quot; Save last search pattern&#xA;    let reset = @/&#xA;    &quot; Move to start of match&#xA;    call search(@/,&quot;b&quot;)&#xA;    &quot; Move to end of match&#xA;    call search(@/,&quot;e&quot;)&#xA;    &quot; Advance one more character&#xA;    normal! l&#xA;    &quot; Restore search pattern&#xA;    let @/ = reset&#xA;endfunction&#xA;&#xA;omap im :call MoveOverMatch()&amp;lt;CR&amp;gt;&#xA;xmap im :call MoveOverMatch()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The omap will work if the cursor is at the start of the match, but place the cursor anywhere in the middle of the match and it will delete from that position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought the search backwards might take care of that, but apparently not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The xmap in visual mode doesn't work at all. I was hoping that typing &quot;vim&quot; would visually select the match. In fact the cursor jumps to the previous match and cancels visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers very much welcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found part of the puzzle. The following fixes for &quot;cim&quot; and &quot;dim&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MoveOverMatch()&#xA;    &quot; Save last search pattern&#xA;    let reset = @/&#xA;    &quot; Move to start of match&#xA;    call search(@/,&quot;b&quot;)&#xA;    normal! v&#xA;    &quot; Move to end of match&#xA;    call search(@/,&quot;e&quot;)&#xA;    &quot; Advance one more character&#xA;    normal! l&#xA;    &quot; Restore search pattern&#xA;    let @/ = reset&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Entering visual mode after the backwards search seems to do the trick for &quot;change&quot; and &quot;delete&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Visual mode still doesn't work, so help is still appreciated.&lt;/p&gt;&#xA;" OwnerUserId="1493" LastEditorUserId="1493" LastEditDate="2015-09-25T21:25:54.280" LastActivityDate="2015-09-25T21:50:22.890" Title="Custom motion to change, delete or select matching pattern" Tags="|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4866" PostTypeId="2" ParentId="4844" CreationDate="2015-09-25T21:18:44.097" Score="3" Body="&lt;p&gt;I think you can achieve what you want through the mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;silent&amp;gt; &amp;lt;cr&amp;gt; &amp;lt;cr&amp;gt;:nohl&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above mapping should turn of highlighted searches after you have pressed enter to accept the search pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, though, that the highlighting is turned back on with for instance &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt;, i.e. when repeating the search. You can turn this off with maps, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap n n:nohl&amp;lt;cr&amp;gt;&#xA;nnoremap N N:nohl&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I found that the above &lt;code&gt;cnoremap&lt;/code&gt; does not work as expected if you use the &lt;a href=&quot;https://github.com/haya14busa/incsearch.vim&quot; rel=&quot;nofollow&quot;&gt;incsearch&lt;/a&gt; plugin, and I could not find why.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2016-01-02T22:35:10.320" LastActivityDate="2016-01-02T22:35:10.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4867" PostTypeId="1" CreationDate="2015-09-25T21:20:25.030" Score="3" ViewCount="170" Body="&lt;p&gt;Is anyone using the polytonic Greek spell file successfully? I get &lt;code&gt;Error detected while processing /Users/lawrence/.vim/spell/polytonic.utf-8.spl:&#xA;E763: Word characters differ between spell files&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. Sorry, I was impræcise before: I get this error only when combining Greek with English, after &lt;code&gt;set spell&lt;/code&gt; and &lt;code&gt;set spelllang=polytonic,en_gb&lt;/code&gt; (regardless of whether in .vimrc or session). It works fine, though; but the error message is a bit annoying.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2015-10-05T12:28:30.927" LastActivityDate="2016-02-02T14:53:50.920" Title="Error, polytonic Greek spell file" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4868" PostTypeId="2" ParentId="4865" CreationDate="2015-09-25T21:27:28.863" Score="5" Body="&lt;p&gt;If I understood your description, the built-in &lt;code&gt;gn&lt;/code&gt; and &lt;code&gt;gN&lt;/code&gt; already do what you are trying to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/foo&amp;lt;CR&amp;gt;&#xA;dgn&#xA;cgn&#xA;vgn&#xA;ygn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help gn&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Bonus mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt;      *``cgn&#xA;nnoremap &amp;lt;otherkey&amp;gt; #``cgN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-09-25T21:50:22.890" LastActivityDate="2015-09-25T21:50:22.890" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4870" PostTypeId="1" AcceptedAnswerId="4871" CreationDate="2015-09-26T12:32:41.270" Score="0" ViewCount="517" Body="&lt;p&gt;I use vim with ruby. I have a habit of opening and closing brackets when I define new function or a block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I would type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;array.map {}_ # _ - cursor position after finishing typing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I am still in &lt;strong&gt;Insert&lt;/strong&gt; mode I have a mapping &lt;code&gt;imap jk &amp;lt;esc&amp;gt;&lt;/code&gt; to get me out to normal mode. Cursor is going back under the closing bracket and I can press &lt;strong&gt;i&lt;/strong&gt; to start typing inside the brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how would I go around creating the mapping &lt;code&gt;&amp;lt;leader&amp;gt;i&lt;/code&gt; that would insert spaces automatically on both sides of the cursor?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;array.map {}_ # jk&amp;lt;leader&amp;gt;i&#xA;array.map { _ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4594" LastActivityDate="2015-09-26T13:06:05.487" Title="Adding leading and trailing space when entering insert mode" Tags="|key-bindings|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4871" PostTypeId="2" ParentId="4870" CreationDate="2015-09-26T13:05:57.417" Score="1" Body="&lt;p&gt;I think, instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;array.map { _ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would be better to have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;array.map { _}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, the cursor is on the second space. Then, whatever you'd type would have a space after it. And a mapping for that would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;i i  &amp;lt;esc&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;i&lt;/code&gt;, followed by two spaces&lt;/li&gt;&#xA;&lt;li&gt;an &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; to go back to normal, at which point the cursor would be on the second space,&lt;/li&gt;&#xA;&lt;li&gt;another &lt;code&gt;i&lt;/code&gt; to go back to insert mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you have arrow keys working in insert mode, you could use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;i i  &amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-09-26T13:05:57.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4872" PostTypeId="2" ParentId="4870" CreationDate="2015-09-26T13:06:05.487" Score="1" Body="&lt;p&gt;You could simply do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;leader&amp;gt;i i&amp;lt;space&amp;gt;&amp;lt;space&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-26T13:06:05.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4873" PostTypeId="1" CreationDate="2015-09-26T21:49:53.107" Score="12" ViewCount="14667" Body="&lt;p&gt;I'd like to install VIM via apt-get, but I'm not sure if I get all of its features. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a difference between this, and compiling it from source?&lt;/p&gt;&#xA;" OwnerUserId="4663" LastEditorUserId="205" LastEditDate="2015-09-27T08:33:35.237" LastActivityDate="2018-05-31T05:24:21.267" Title="Is there a difference between &quot;sudo apt-get vim&quot; and &quot;./configure --with-features=huge&quot;?" Tags="|installing|linux-debian|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4874" PostTypeId="1" AcceptedAnswerId="4876" CreationDate="2015-09-26T22:20:56.843" Score="0" ViewCount="1341" Body="&lt;p&gt;I'm trying to add a good Tab autocompletion plugin for VIM and I've found &lt;a href=&quot;https://github.com/davidhalter/jedi-vim&quot; rel=&quot;nofollow&quot;&gt;Jedi&lt;/a&gt;, but on its docs it says to use &lt;a href=&quot;https://github.com/ervandew/supertab&quot; rel=&quot;nofollow&quot;&gt;Supertab&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand the difference between the two. I'm writing Python and I would like tab completion. Why should I use one or the other?&lt;/p&gt;&#xA;" OwnerUserId="4656" LastEditorUserId="51" LastEditDate="2016-02-05T21:01:49.693" LastActivityDate="2016-02-05T21:01:49.693" Title="Supertab or Jedi for Python Autocompletion" Tags="|plugin-jedi-vim|plugin-supertab|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4875" PostTypeId="2" ParentId="4873" CreationDate="2015-09-26T22:42:38.253" Score="6" Body="&lt;p&gt;Indeed the version you get with &lt;code&gt;apt-get install vim&lt;/code&gt; doesn't have all the features of a version compiled with  &lt;code&gt;--with-features=huge&lt;/code&gt;. For example you don't always have options like &lt;code&gt;+python&lt;/code&gt; or &lt;code&gt;+lua&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good alternative is to use &lt;code&gt;apt-get install vim-nox&lt;/code&gt; which is much more complete.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-09-26T22:42:38.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4876" PostTypeId="2" ParentId="4874" CreationDate="2015-09-26T22:55:09.280" Score="0" Body="&lt;p&gt;I do not use Vim-Jedi but from what the doc says, the plugin allows completion using &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Supertab is another plugin which remaps &lt;kbd&gt;Tab&lt;/kbd&gt; to a sensible autocomplete behavior. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The author only suggests to use supertab if you want to use the &lt;kbd&gt;Tab&lt;/kbd&gt; key to trigger Vim-Jedi completion &lt;em&gt;(This is easier than remapping the key by&#xA;yourself in your &lt;code&gt;.vimrc&lt;/code&gt;)&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that you can use Vim-Jedi without supertab if you like its original completion with &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;. IMO you should just give Vim-Jedi a try without supertab and when you're comfortable with it, you'll see if you want to use supertab and make your choice.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="205" LastEditDate="2015-09-27T04:39:39.083" LastActivityDate="2015-09-27T04:39:39.083" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4877" PostTypeId="1" AcceptedAnswerId="4887" CreationDate="2015-09-27T02:18:42.037" Score="1" ViewCount="355" Body="&lt;p&gt;Unfortunately, I have to convert code created by mathtype into real latex code.     My converted creates hideous expressions like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\textstyleMTConvertedEquation{{\textbackslash}[\{X\_k\} {\textbackslash}equiv {\textbackslash}left(&#xA;\{\{X\_\{1,k\}\},...,\{X\_\{n,k\}\}\} {\textbackslash}right){\textbackslash}]}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to globally convert expressions like these to latex code, by replacing the matched curly braces with &lt;code&gt;$&lt;/code&gt;'s.    Obviously, the &lt;code&gt;%&lt;/code&gt; character will match up the braces but I don't know how to incorporate this fact into a global command, i.e., I'd like to construct a command of this form, but don't know how to identify the matched brace.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\\textstyleMTConvertedEquation{.*&amp;lt;matched brace&amp;gt;/s//\$\1\$/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks for any suggestions!&lt;/p&gt;&#xA;" OwnerUserId="4667" LastEditorUserId="205" LastEditDate="2015-09-27T04:44:55.207" LastActivityDate="2015-09-27T12:14:14.203" Title="Globally replace text contained in curly braces" Tags="|command-line|delimiter-matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4878" PostTypeId="1" AcceptedAnswerId="4886" CreationDate="2015-09-27T06:24:33.347" Score="4" ViewCount="1161" Body="&lt;p&gt;I use 2 spaces as indentation. So I set &lt;code&gt;shiftwidth&lt;/code&gt; using &lt;code&gt;:set sw=2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when I do the shift operator(&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;) on a line twice, the indentation converts the 4 spaces automatically to a tab. So to avoid this, I set &lt;code&gt;tabstop&lt;/code&gt; to a high value say 60 using &lt;code&gt;:set ts=60&lt;/code&gt; and the shift operator works (does NOT convert space to tab).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, Is this the right way to do? Am I missing a simpler solution?&lt;/p&gt;&#xA;" OwnerUserId="4668" LastActivityDate="2015-09-30T17:30:29.660" Title="Avoid spaces getting converted to tabs automatically during shift(&gt;&gt;)" Tags="|tab-characters|whitespace|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4879" PostTypeId="2" ParentId="4873" CreationDate="2015-09-27T07:16:17.137" Score="15" Body="&lt;p&gt;If you look at the options used to build the various packages (in &lt;a href=&quot;https://salsa.debian.org/vim-team/vim/blob/debian/sid/debian/rules&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;debian/rules&lt;/code&gt;&lt;/a&gt;), you'll see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OPTFLAGS+=--with-features=huge&#xA;&#xA;...&#xA;&#xA;NOINTERPFLAGS:=--disable-luainterp&#xA;NOINTERPFLAGS+=--disable-mzschemeinterp&#xA;NOINTERPFLAGS+=--disable-perlinterp&#xA;ifeq ($(DEB_VENDOR),Ubuntu)&#xA;    NOINTERPFLAGS+=--enable-pythoninterp --with-python-config-dir=$(shell python-config --configdir)&#xA;else&#xA;    NOINTERPFLAGS+=--disable-pythoninterp&#xA;endif&#xA;NOINTERPFLAGS+=--disable-python3interp&#xA;NOINTERPFLAGS+=--disable-rubyinterp&#xA;NOINTERPFLAGS+=--disable-tclinterp&#xA;&#xA;ALLINTERPFLAGS:=--enable-luainterp&#xA;ALLINTERPFLAGS+=--disable-mzschemeinterp&#xA;ALLINTERPFLAGS+=--enable-perlinterp&#xA;ALLINTERPFLAGS+=--enable-pythoninterp --with-python-config-dir=$(shell python-config --configdir)&#xA;ALLINTERPFLAGS+=--disable-python3interp&#xA;ALLINTERPFLAGS+=--enable-rubyinterp&#xA;ALLINTERPFLAGS+=--enable-tclinterp&#xA;ALLINTERPFLAGS+=--with-tclsh=/usr/bin/tclsh&#xA;&#xA;...&#xA;&#xA;CFLAGS_vim-basic:=$(CFLAGS)&#xA;CFGFLAGS_vim-basic:=$(CFGFLAGS) $(OPTFLAGS) $(NOXFLAGS) $(NOINTERPFLAGS)&#xA;&#xA;CFLAGS_vim-tiny:=$(CFLAGS) -DTINY_VIMRC&#xA;CFGFLAGS_vim-tiny:=$(CFGFLAGS) $(TINYFLAGS)&#xA;&#xA;CFLAGS_vim-gtk:=$(CFLAGS)&#xA;CFGFLAGS_vim-gtk:=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(GTKFLAGS) $(ALLINTERPFLAGS)&#xA;&#xA;CFLAGS_vim-gnome:=$(CFLAGS)&#xA;CFGFLAGS_vim-gnome:=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(GNOMEFLAGS) $(ALLINTERPFLAGS)&#xA;&#xA;CFLAGS_vim-athena:=$(CFLAGS)&#xA;CFGFLAGS_vim-athena:=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(ATHENAFLAGS) $(ALLINTERPFLAGS)&#xA;&#xA;CFLAGS_vim-nox:=$(CFLAGS)&#xA;CFGFLAGS_vim-nox:=$(CFGFLAGS) $(OPTFLAGS) $(NOXFLAGS) $(ALLINTERPFLAGS)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;all packages except &lt;code&gt;vim-tiny&lt;/code&gt; gets built with &lt;code&gt;--with-features=huge&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vim-basic&lt;/code&gt; (aka &lt;code&gt;vim&lt;/code&gt;) has interpreters turned &lt;em&gt;off&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;the others have options based on frontend, with interpreters turned on.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To pick one:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you'd like a barebones Vim, pick &lt;code&gt;vim-tiny&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If you'd like a more full-featured Vim, pick &lt;code&gt;vim&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If you'd like all the features that the packaging allows, but &lt;em&gt;don't&lt;/em&gt; want GUI (and the dependencies of a GUI), pick &lt;code&gt;vim-nox&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If you'd like a GUI, and but don't want anything to do with GTK, pick &lt;code&gt;vim-athena&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If you'd like a GUI, &lt;strike&gt;and use a GNOME-based desktop environment (GNOME, Unity, Cinnamon, etc.), pick &lt;code&gt;vim-gnome&lt;/code&gt;&lt;/strike&gt; and use a GTK3-based environment (GNOME, Unity, Cinnamon, MATE, etc.), pick &lt;code&gt;vim-gtk3&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If you'd like a GUI, and use a GTK2-based or non-GTK desktop environment (XFCE, LXDE, etc.), pick &lt;code&gt;vim-gtk&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2018-05-31T05:24:21.267" LastActivityDate="2018-05-31T05:24:21.267" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4880" PostTypeId="2" ParentId="4873" CreationDate="2015-09-27T07:34:05.620" Score="5" Body="&lt;p&gt;&lt;code&gt;$ sudo apt-get install vim-gtk&lt;/code&gt; (or &lt;code&gt;vim-gnome&lt;/code&gt; if you are on Ubuntu) will get you the most complete Vim with the least effort.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Official packages usually lag a bit so, if you &lt;em&gt;really&lt;/em&gt; want the latest version, you will have to apply the latest patches and build it yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be aware, though, that new patches come up every couple of days, so keeping up with upstream needs dedication.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-27T07:34:05.620" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4881" PostTypeId="1" AcceptedAnswerId="4882" CreationDate="2015-09-27T09:53:02.420" Score="15" ViewCount="1260" Body="&lt;p&gt;Is it possible for vim to treat underscores like spaces or hypens, so when I use the sequence &lt;code&gt;dw&lt;/code&gt;, it doesn't delete whole sentence &lt;code&gt;some_long_text_with_underscores&lt;/code&gt;, when the cursor is at the beginning?&lt;/p&gt;&#xA;" OwnerUserId="2562" LastEditorUserId="28" LastEditDate="2017-12-30T23:19:04.873" LastActivityDate="2017-12-30T23:19:04.873" Title="How to treat underscores like space?" Tags="|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4882" PostTypeId="2" ParentId="4881" CreationDate="2015-09-27T10:20:50.997" Score="23" Body="&lt;p&gt;&lt;code&gt;dw&lt;/code&gt; deletes a word, and what constitutes a word is defined by the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27iskeyword%27&quot;&gt;&lt;code&gt;iskeyword&lt;/code&gt;&lt;/a&gt; setting. From &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#word&quot;&gt;&lt;code&gt;:h word&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        word&#xA;A word consists of a sequence of letters, digits and underscores, or a&#xA;sequence of other non-blank characters, separated with white space (spaces,&#xA;tabs, &amp;lt;EOL&amp;gt;).  This can be changed with the 'iskeyword' option.  An empty line&#xA;is also considered to be a word.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To remove &lt;code&gt;_&lt;/code&gt; from &lt;code&gt;iskeyword&lt;/code&gt;, do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword-=_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-09-27T10:20:50.997" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4883" PostTypeId="1" AcceptedAnswerId="4884" CreationDate="2015-09-27T10:59:22.517" Score="6" ViewCount="2968" Body="&lt;p&gt;&lt;em&gt;/* This is coming directly from Molokai's &lt;a href=&quot;https://github.com/tomasr/molokai/issues/36&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue #36&lt;/a&gt;. */&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The problem&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tomasr/molokai&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Molokai&lt;/em&gt;&lt;/a&gt; is a very nice theme for &lt;em&gt;Vim&lt;/em&gt; but it has a terrible &lt;em&gt;vimdiff&lt;/em&gt; highlighting (see left split, last 5 lines). &lt;code&gt;+&lt;/code&gt; are not &lt;em&gt;green&lt;/em&gt; and &lt;code&gt;-&lt;/code&gt; are not &lt;em&gt;red&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LunqU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LunqU.png&quot; alt=&quot;Bad syntax highlighting&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been suggested by &lt;strong&gt;justinmk&lt;/strong&gt;@GitHub to use the following &lt;code&gt;~/.vimrc&lt;/code&gt; (&lt;a href=&quot;https://gist.github.com/Atcold/f3b75884c6b2ba18ff26&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;'s the &lt;em&gt;gist&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax enable&#xA;let s:color_override_dark = '&#xA;    \ if &amp;amp;background == &quot;dark&quot;&#xA;    \ | hi StatusLine    guifg=#000000 guibg=#ffffff gui=NONE  ctermfg=16 ctermbg=15     cterm=NONE&#xA;    \ | hi CursorLine    guibg=#293739 ctermbg=236&#xA;    \ | hi PmenuSel      guibg=#0a9dff guifg=white   gui=NONE  ctermbg=39 ctermfg=white  cterm=NONE&#xA;    \ | hi PmenuSbar     guibg=#857f78&#xA;    \ | hi PmenuThumb    guifg=#242321&#xA;    \ | hi WildMenu      gui=NONE cterm=NONE guifg=#f8f6f2 guibg=#0a9dff ctermfg=255 ctermbg=39&#xA;    \ | hi DiffAdd       guifg=#ffffff guibg=#006600 gui=NONE  ctermfg=231  ctermbg=22   cterm=NONE &#xA;    \ | hi DiffChange    guifg=#ffffff guibg=#007878 gui=NONE  ctermfg=231  ctermbg=30   cterm=NONE &#xA;    \ | hi DiffDelete    guifg=#ff0101 guibg=#9a0000 gui=NONE  ctermfg=196  ctermbg=88   cterm=NONE &#xA;    \ | hi DiffText      guifg=#000000 guibg=#ffb733 gui=NONE  ctermfg=000  ctermbg=214  cterm=NONE &#xA;    \ | hi MatchParen    guifg=NONE   guibg=NONE gui=underline ctermfg=NONE ctermbg=NONE cterm=underline&#xA;    \ | endif&#xA;    \'&#xA;&#xA;if has('vim_starting') &quot;only on startup&#xA;  exe 'autocmd ColorScheme * '.s:color_override_dark&#xA;  &quot; expects &amp;amp;runtimepath/colors/{name}.vim.&#xA;  silent! colorscheme molokai&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which unfortunately does not work for some reasons.&#xA;Can someone point out what has been done wrongly?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;The solution&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Inserting the following code into &lt;code&gt;~/.vimrc&lt;/code&gt; fixes the problem stated above.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme molokai&#xA;&quot; Better gitcommit messages&#xA;hi diffAdded   ctermbg=NONE ctermfg=46  cterm=NONE guibg=NONE guifg=#00FF00 gui=NONE&#xA;hi diffRemoved ctermbg=NONE ctermfg=196 cterm=NONE guibg=NONE guifg=#FF0000 gui=NONE&#xA;hi link diffLine String&#xA;hi link diffSubname Normal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here we have a before / after :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ys04s.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ys04s.png&quot; alt=&quot;Before / after&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Further information&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It is possible to &lt;a href=&quot;http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor&quot; rel=&quot;nofollow noreferrer&quot;&gt;remap &lt;code&gt;F10&lt;/code&gt; to *show me what syntax is this*&lt;/a&gt;. Then, one can modify what s/he feels needs some adjustments, as I've done for the 'strong' &lt;code&gt;diffLine&lt;/code&gt; and to the 'green' &lt;code&gt;diffSubname&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4670" LastEditorUserId="4670" LastEditDate="2015-09-27T19:20:47.633" LastActivityDate="2015-09-27T19:20:47.633" Title="Overwrite colorscheme syntax highlighting" Tags="|colorscheme|vimdiff|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4884" PostTypeId="2" ParentId="4883" CreationDate="2015-09-27T11:42:34.023" Score="7" Body="&lt;p&gt;&lt;code&gt;DiffAdd&lt;/code&gt; and &lt;code&gt;DiffDelete&lt;/code&gt; are only used when actually &lt;em&gt;performing&lt;/em&gt; a diff (&lt;code&gt;$ vim -d foo.txt bar.txt&lt;/code&gt;, &lt;code&gt;$ vimdiff foo.txt bar.txt&lt;/code&gt;, &lt;code&gt;$ git mergetool&lt;/code&gt;, etc.); those highlight groups are totally irrelevant, here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The highlight groups used for added and deleted lines when &lt;em&gt;reading&lt;/em&gt; a diff file are &lt;code&gt;diffAdded&lt;/code&gt; and &lt;code&gt;diffRemoved&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding the lines below between line 272 and line 274 of &lt;code&gt;molokai.vim&lt;/code&gt; should fix your problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi diffAdded   ctermbg=NONE ctermfg=108 cterm=NONE guibg=NONE guifg=#87af87 gui=NONE&#xA;hi diffRemoved ctermbg=NONE ctermfg=131 cterm=NONE guibg=NONE guifg=#af5f5f gui=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Those are the colors used in &lt;a href=&quot;https://github.com/romainl/Apprentice&quot;&gt;my own colorscheme&lt;/a&gt;, use the ones you want.)&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-27T11:42:34.023" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4885" PostTypeId="2" ParentId="4817" CreationDate="2015-09-27T11:45:58.207" Score="4" Body="&lt;p&gt;The last file should be at the top of the &lt;a href=&quot;http://vim.wikia.com/wiki/Jumping_to_previously_visited_locations&quot; rel=&quot;nofollow&quot;&gt;jumplist&lt;/a&gt;, which you can visit with &lt;code&gt;CTRL-O&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way around your bash issue, related to muru's comment, is with the &lt;a href=&quot;http://www.gnu.org/software/bash/manual/html_node/Commands-For-History.html&quot; rel=&quot;nofollow&quot;&gt;reverse-search-history&lt;/a&gt; &lt;code&gt;CTRL-R&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4655" LastActivityDate="2015-09-27T11:45:58.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4886" PostTypeId="2" ParentId="4878" CreationDate="2015-09-27T12:03:18.760" Score="2" Body="&lt;p&gt;Set the &lt;code&gt;'expandtab'&lt;/code&gt; option setting. This will prevent shifting from replacing indent by using TABs.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-27T12:03:18.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4887" PostTypeId="2" ParentId="4877" CreationDate="2015-09-27T12:14:14.203" Score="2" Body="&lt;p&gt;I am not sure if I understand you correctly and you didn't provide an example, how it is supposed to look afterwards. So here is how I would do, what I think you want to be done:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\\textstyleMTConvertedEquation{/:exe &quot;:norm! 0dt{c%$\&amp;lt;C-R&amp;gt;\&quot;$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might need to remove the extra brace before/after the '$', which could be done in a single step like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\\textstyleMTConvertedEquation{/:exe &quot;:norm! 0dt{c%$\&amp;lt;C-R&amp;gt;=getreg('\&quot;')[1:-2]\&amp;lt;CR&amp;gt;$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-27T12:14:14.203" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4888" PostTypeId="1" AcceptedAnswerId="4889" CreationDate="2015-09-27T20:15:11.457" Score="13" ViewCount="3166" Body="&lt;p&gt;I recently discovered the option &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27switchbuf%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;switchbuf&lt;/code&gt;&lt;/a&gt; and tried to use it but I can't say if I don't understand how it should work or if it actually doesn't work on my Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About the different possible values, the doc says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;useopen&lt;/em&gt; If included, jump to the first open window that &lt;br/&gt;&#xA;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;contains the specified buffer (if there is one).&lt;br/&gt;&#xA;  &lt;em&gt;usetab&lt;/em&gt;  Like &quot;useopen&quot;, but also consider windows in other tab  pages.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have then used &lt;code&gt;set switchbuf=useopen,usetab&lt;/code&gt; and the following commands in a new vim instance:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open a first buffer &lt;code&gt;:e file1&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;Split the screen &lt;code&gt;:split&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Open a second buffer &lt;code&gt;:e file2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Go back to the first buffer &lt;code&gt;:e file1&lt;/code&gt; (I have also used &lt;code&gt;:bN&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The last commands to go to the first buffer open it in the second split. From what I understand from the doc the commands should place the cursor to the first split where the buffer is already open thanks to &lt;code&gt;useopen&lt;/code&gt;. Also the behavior is the same when I try the same commands with tabs instead of splits.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is this behavior the expected one? &lt;/li&gt;&#xA;&lt;li&gt;If so could you explain what this option should do?&lt;/li&gt;&#xA;&lt;li&gt;If not I know that I'll have to debug my &lt;code&gt;.vimrc&lt;/code&gt; but maybe is there a common setting known to interfere with &lt;code&gt;switchbuf&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-09-27T20:22:25.317" LastActivityDate="2015-09-27T20:29:20.493" Title="How should the option 'switchbuf' work?" Tags="|vimrc|buffers|split|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4889" PostTypeId="2" ParentId="4888" CreationDate="2015-09-27T20:29:20.493" Score="15" Body="&lt;p&gt;&lt;code&gt;'switchbuf'&lt;/code&gt; is only honored by quickfix commands (like &lt;code&gt;:cc&lt;/code&gt;) and buffer-splitting commands (like &lt;code&gt;:sb&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't affect &lt;code&gt;:buffer&lt;/code&gt; and other &quot;regular&quot; buffer-related commands.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-27T20:29:20.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4891" PostTypeId="1" AcceptedAnswerId="4892" CreationDate="2015-09-28T02:12:57.017" Score="83" ViewCount="29226" Body="&lt;p&gt;I accidentally pressed &lt;code&gt;gh&lt;/code&gt; in normal mode and started a selection, so I looked up the doc and found &lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#Select%2Dmode&quot;&gt;&lt;code&gt;:h Select-mode&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I understand the select mode is close to the visual mode excepted that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Typing a printable character, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; will delete the selection, start insert mode and replace the selection with the input.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;hjkl&lt;/code&gt; and other normal or visual mode movement won't extend the selection unless they're prefixed with &lt;code&gt;&amp;lt;Shift&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CTRL-O&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;CTRL-G&amp;gt;&lt;/code&gt; will switch to visual mode.&lt;/li&gt;&#xA;&lt;li&gt;The doc also says the following, which if I understand correctly means that it is possible to do linewise selection which are then treated characterwise:&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When using an operator in Select mode, and the selection is linewise, the&#xA;  selected lines are operated upon, but like in characterwise selection.  For&#xA;  example, when a whole line is deleted, it can later be pasted halfway a line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am a little confused because I don't understand why this mode was created: all I can see is that it is less convenient than visual mode and doesn't provide more features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the searches that I have made all give results about doing selection in visual mode but do not treat select mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my questions are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Why was the select mode created?&lt;/li&gt;&#xA;&lt;li&gt;What are its advantage compared to visual mode?&lt;/li&gt;&#xA;&lt;li&gt;What is a use case where it is more interesting to use select mode?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;MetaNote&lt;/strong&gt; I have no idea which tag is relevant to this question, feel free to retag if needed.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-11-22T09:53:17.017" LastActivityDate="2016-11-22T09:53:17.017" Title="What is the select mode and when is it relevant to use it?" Tags="|visual-mode|history-of|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4892" PostTypeId="2" ParentId="4891" CreationDate="2015-09-28T05:16:24.743" Score="42" Body="&lt;p&gt;The whole point of select mode is to provide a selection behavior similar to the one used in conventional editors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the same note, there's &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/mswin.vim&quot; rel=&quot;noreferrer&quot;&gt;mswin.vim&lt;/a&gt; which changes a bunch of options and mappings to make Vim feel like a conventional editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can only assume those were added to please a subset of Vim users, probably at the time Vim was ported to Windows (I can feel some disdain for Windows in the doc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, select mode is essential to snippet expansion plugins and can be abused for fun and profit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap § *``gn&amp;lt;C-g&amp;gt;&#xA;inoremap § &amp;lt;C-o&amp;gt;gn&amp;lt;C-g&amp;gt;&#xA;snoremap &amp;lt;expr&amp;gt; . @.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-09-28T07:28:54.710" LastActivityDate="2015-09-28T07:28:54.710" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="4893" PostTypeId="1" AcceptedAnswerId="4897" CreationDate="2015-09-28T09:32:18.457" Score="7" ViewCount="1738" Body="&lt;p&gt;While working &lt;a href=&quot;https://github.com/plasticboy/vim-markdown&quot; rel=&quot;noreferrer&quot;&gt;a Markdown plugin&lt;/a&gt;, we've wanted to change the filetype from &lt;code&gt;mkd&lt;/code&gt; to &lt;code&gt;markdown&lt;/code&gt; to increase compatibility with other plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid breaking users &lt;code&gt;.vimrc&lt;/code&gt; that had autocommands like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType mkd echo 'a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;we've tried using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set filetype=mkd.markdown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from &lt;code&gt;ftdetect/markdown.vim&lt;/code&gt;, since &lt;code&gt;help 'ft'&lt;/code&gt; says both types would be tried.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the syntax works fine, but the autocmd does not run. The only way to make it run is to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType mkd.markdown echo 'a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is obviously bad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to avoid breaking user autocommands in this case?&lt;/p&gt;&#xA;" OwnerUserId="2038" LastEditorUserId="2038" LastEditDate="2015-09-28T09:40:13.557" LastActivityDate="2019-08-05T17:31:30.653" Title="How to make autocmd FileType work when a file has multiple / compound dot separated types?" Tags="|autocmd|filetype|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4894" PostTypeId="1" AcceptedAnswerId="4896" CreationDate="2015-09-28T09:44:40.953" Score="5" ViewCount="668" Body="&lt;p&gt;&lt;code&gt;ignorecase&lt;/code&gt; is a global option, so it's not possible to locally set ic&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setlocal ic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there a trick to set &lt;code&gt;ic&lt;/code&gt; locally in a buffer.&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2015-10-02T23:57:16.883" Title="Is there a trick to set 'ignorecase' locally" Tags="|buffers|options|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4895" PostTypeId="2" ParentId="4894" CreationDate="2015-09-28T10:51:02.760" Score="9" Body="&lt;p&gt;You can always prefix your search expression with &lt;code&gt;\c&lt;/code&gt; to enforce case insensitivity (and &lt;code&gt;\C&lt;/code&gt; for case sensitivity). From &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2Fignorecase&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h ignorecase&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        /\c /\C&#xA;When &quot;\c&quot; appears anywhere in the pattern, the whole pattern is handled like&#xA;'ignorecase' is on.  The actual value of 'ignorecase' and 'smartcase' is&#xA;ignored.  &quot;\C&quot; does the opposite: Force matching case for the whole pattern.&#xA;{only Vim supports \c and \C}&#xA;Note that 'ignorecase', &quot;\c&quot; and &quot;\C&quot; are not used for the character classes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, for example, to have case-sensitive search for &lt;code&gt;name&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\Cname&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And for case-insensitive:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\cname&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could perhaps map these to some shortcut, say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;c/ /\c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-10-02T18:40:09.117" LastActivityDate="2015-10-02T18:40:09.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4896" PostTypeId="2" ParentId="4894" CreationDate="2015-09-28T14:34:03.120" Score="6" Body="&lt;p&gt;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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other alternative is to use the '\c' and '\C' atoms when searching (see the help at &lt;code&gt;:h /\c&lt;/code&gt; and &lt;code&gt;:h /\C&lt;/code&gt; but this is usually a hassle to remember.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-09-28T14:54:51.613" LastActivityDate="2015-09-28T14:54:51.613" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4897" PostTypeId="2" ParentId="4893" CreationDate="2015-09-28T14:52:18.880" Score="7" Body="&lt;p&gt;Use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd FileType *markdown* :echom &quot;a&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;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 implictly anchored to the start and end and can be seen by using &lt;code&gt;:echo glob2regpat('markdown')&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="10084" LastEditDate="2019-08-05T17:31:30.653" LastActivityDate="2019-08-05T17:31:30.653" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4898" PostTypeId="1" AcceptedAnswerId="4899" CreationDate="2015-09-28T15:41:11.587" Score="0" ViewCount="449" Body="&lt;p&gt;I'm trying to match a pattern &lt;em&gt;only&lt;/em&gt; when it occurs between matching delimiters&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in the lines below, I'd like to match the a in the first line, but not the a in the second, which is &lt;em&gt;not&lt;/em&gt; inside matching parens&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;( a )&#xA;( b ) a ( b )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:&lt;code&gt;g/(.*a.*)/s/a/A/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;obviously doesn't work because it's too greedy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would have thought the non-greedy alternative&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/(\{-}a\{-})/s/a/A/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would work, but for some reason it returns&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;( A )&#xA;( b ) A ( b )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, I don't really understand how the non-greedy syntax works.&#xA;Any suggestions would be most appreciated!   Thanks&lt;/p&gt;&#xA;" OwnerUserId="4667" LastActivityDate="2015-09-28T16:04:03.040" Title="Match a pattern within matching delimiters" Tags="|delimiter-matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4899" PostTypeId="2" ParentId="4898" CreationDate="2015-09-28T15:58:23.960" Score="0" Body="&lt;p&gt;You could try something like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/(\s*\(a\)\s*)/\U\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(\s*\(a\)\s*)&lt;/code&gt; can be decomposed:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first pair of &lt;code&gt;()&lt;/code&gt; are the litteral characters&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s*&lt;/code&gt; match any number of whitespace between the brackets and your pattern&lt;/li&gt;&#xA;&lt;li&gt;The pair of &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; captures a subgroup&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&lt;/code&gt; is the subgroup captured (but you could change it to any pattern)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\U\1&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\U&lt;/code&gt; convert to upper case.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\1&lt;/code&gt; the first subgroup you capted (with &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-09-28T16:04:03.040" LastActivityDate="2015-09-28T16:04:03.040" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4900" PostTypeId="2" ParentId="4835" CreationDate="2015-09-28T16:24:30.367" Score="1" Body="&lt;p&gt;In the source code directory use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -name '*.cpp' -o -name '*.h' &amp;gt; gtags.files&#xA;gtags --accept-dotfiles -c -f gtags.files&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will build the cross reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vim, you can issue the following command to invoke gtags-cscope&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:GtagsCscope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4688" LastEditorUserId="205" LastEditDate="2015-09-29T04:51:21.557" LastActivityDate="2015-09-29T04:51:21.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4901" PostTypeId="1" AcceptedAnswerId="6256" CreationDate="2015-09-28T16:32:05.603" Score="4" ViewCount="188" Body="&lt;p&gt;Via &lt;a href=&quot;https://code.google.com/p/conque/&quot; rel=&quot;nofollow&quot; title=&quot;Conque&quot;&gt;Conque&lt;/a&gt; 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 &lt;code&gt;%cpaste&lt;/code&gt; and &lt;code&gt;--&lt;/code&gt;. That is, if I am interactively editing and testing the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def wait_job(layer2, vault_name, job_id, sleepsec=60, timeout=86400):&#xA;    &quot;&quot;&quot; Wait for a job to terminate. &quot;&quot;&quot;&#xA;    t0 = datetime.now()&#xA;    vault = fetch_vault(layer2, vault_name)&#xA;    while 1:&#xA;        job = vault.get_job(job_id)&#xA;        if not job.completed:&#xA;            tf = datetime.now()&#xA;            delta = tf - t0&#xA;            if (delta.seconds &amp;gt; timeout):&#xA;                # 2FIX: should this just return false?&#xA;                raise Exception('timed out')&#xA;            time.sleep(sleepsec)&#xA;        else:&#xA;            break&#xA;    wasok = job.completed&#xA;    return wasok&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And grab the code block starting from &lt;code&gt;if not job.completed&lt;/code&gt;, and send it to an ipython process in a Conque window, I have to send:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%cpaste&#xA;        if not job.completed:&#xA;            tf = datetime.now()&#xA;            delta = tf - t0&#xA;            if (delta.seconds &amp;gt; timeout):&#xA;                # 2FIX: should this just return false?&#xA;                raise Exception('timed out')&#xA;            time.sleep(sleepsec)&#xA;        else:&#xA;            break&#xA;--&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I believe I have to modify the following line in the definition of &lt;code&gt;ConqueTerm_SendVisKey&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if maparg(g:ConqueTerm_SendVisKey, 'v') == ''&#xA;  sil exe 'v' . map_modifier . 'map &amp;lt;silent&amp;gt; ' . g:ConqueTerm_SendVisKey . ' :&amp;lt;C-u&amp;gt;call conque_term#send_selected(visualmode())&amp;lt;CR&amp;gt;'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But am not sure where to start. Probably it would be better to define variables for gate start and gate end, but can I just do a string concat around &lt;code&gt;visualmode()&lt;/code&gt;? Or must I send call the send three times?&lt;/p&gt;&#xA;" OwnerUserId="4686" LastEditorUserId="4686" LastEditDate="2015-09-29T16:13:11.900" LastActivityDate="2016-01-27T10:04:08.770" Title="modify conque to gate selected text" Tags="|vimscript|plugin-conque|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4902" PostTypeId="1" AcceptedAnswerId="25364" CreationDate="2015-09-28T20:12:43.730" Score="19" ViewCount="16654" Body="&lt;p&gt;I need to search for lines which contain some word but do &lt;em&gt;not&lt;/em&gt; contain a second word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, find lines that contain the word &quot;This&quot; but not the word &quot;red&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so that for a file containing these lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a blue coat&#xA;This is a red  coat&#xA;This is a purple coat&#xA;That is a coat&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The search would locate the first and third lines only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any advice!&lt;/p&gt;&#xA;" OwnerUserId="4667" LastEditorUserId="205" LastEditDate="2015-09-29T04:50:06.677" LastActivityDate="2020-05-19T06:46:18.053" Title="search for lines which contain a pattern but do not contain a second pattern" Tags="|search|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4903" PostTypeId="2" ParentId="4902" CreationDate="2015-09-28T21:30:00.167" Score="30" Body="&lt;p&gt;You can use this command to print lines containing &lt;code&gt;This&lt;/code&gt; and not &lt;code&gt;red&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\(.*This\)\&amp;amp;\(.*red\)\@!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\&amp;amp;&lt;/code&gt; separates the branches like a logical &lt;code&gt;AND&lt;/code&gt; because we want the lines that satisfy the two conditions (branches),&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(.*This\)&lt;/code&gt; is the first branch, it could simply be &lt;code&gt;This&lt;/code&gt; but it is more generic that way,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(.*red\)\@!&lt;/code&gt; is the second branch, &lt;code&gt;\@!&lt;/code&gt; means &quot;zero width match if the preceding atom doesn't match&quot;, like a logical &lt;code&gt;NOT&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In other words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(.*This\)  \&amp;amp;  \(.*red\)\@!&#xA;°°°°°°°°°°  °°  °°°°°°°°°°°°&#xA;'This'      AND NOT 'red'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-28T21:30:00.167" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4904" PostTypeId="1" CreationDate="2015-09-28T21:59:11.873" Score="2" ViewCount="514" Body="&lt;p&gt;I would like to change the visual highlight color in xoria256 colorscheme to the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;make the background brighter but keep the color of the letters the same. I've seen people do it and I really like it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I played with &lt;code&gt;Visual&lt;/code&gt; and &lt;code&gt;VisualNOS&lt;/code&gt; highlight groups but I was not able to figure out how to do it. I'd really appreciate any advice on the matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2865" LastActivityDate="2015-10-29T02:56:09.687" Title="how to change visual selector color with xoria256 colorscheme" Tags="|syntax-highlighting|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4905" PostTypeId="2" ParentId="4904" CreationDate="2015-09-29T02:50:12.613" Score="1" Body="&lt;p&gt;These are the current lines 75 and 77 of &lt;a href=&quot;https://github.com/vim-scripts/xoria256.vim/blob/master/colors/xoria256.vim#L75-L77&quot; rel=&quot;nofollow&quot;&gt;xoria256.vim&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Visual       ctermfg=255 guifg=#eeeeee ctermbg=96  guibg=#875f87&#xA;hi VisualNOS    ctermfg=255 guifg=#eeeeee ctermbg=60  guibg=#5f5f87&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will have to change the values according to &lt;a href=&quot;https://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg&quot; rel=&quot;nofollow&quot;&gt;the xterm palette&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Choose a color swatch,&lt;/li&gt;&#xA;&lt;li&gt;use the number in the bottom left corner for &lt;code&gt;ctermfg&lt;/code&gt; and &lt;code&gt;ctermbg&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;use the corresponding hexadecimal color for &lt;code&gt;guifg&lt;/code&gt; and &lt;code&gt;guibg&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;do &lt;code&gt;:colorscheme xoria256&lt;/code&gt; to reload your colorscheme and preview your changes.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-29T02:50:12.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4906" PostTypeId="1" CreationDate="2015-09-29T04:54:31.350" Score="4" ViewCount="207" Body="&lt;p&gt;When I am writting a Latex document I generally like to keep an 80 column &#xA;line width to keep things easy to read. However I don't like to use text&#xA;wrapping because it can get in the way of typing equations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally I will type a paragraph without caring how long the lines are, and eventually they gradually get longer, and longer, to the point where if I &lt;code&gt;vsplit&lt;/code&gt; two documents the lines run off the end.  So I will &lt;code&gt;set textwitdth=80&lt;/code&gt; and highlight an offending section in visual mode, and then use &lt;code&gt;gq&lt;/code&gt; to format the selected text.  However this is a bit more of a process than I have come accustomed to using vim I prefer to do things with only a few key strokes, or have it automatically done based on the file type. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for a way to either: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;script the application of a particular format (predetermined) to a selection of text &lt;/li&gt;&#xA;&lt;li&gt;Apply conditional formatting to a file-type based on some of the same identifiers used  to conditionally highlight syntax  &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For those unfamiliar with latex: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A regular text section is by and large free of any syntax. When you&#xA;begin an equation  like this, &#xA;\begin{equation}&#xA;\hat{H}\Psi = E\Psi&#xA;\end{equation}&#xA;I wouldn't want the lines inside to be wrapped automatically.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So there is a clear way of identifying math environments ie&lt;code&gt;\begin..\end&lt;/code&gt; and Vim's ft plugin recognizes this for syntax highlighting. Can you apply conditional formatting in a similar way? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This (latex) is an example I am working with right now, but for example in general programming I would really like it if multi line comments could be wrapped without automatically wrapping regular code. &lt;/p&gt;&#xA;" OwnerUserId="4692" LastEditorUserId="51" LastEditDate="2015-11-09T07:25:07.727" LastActivityDate="2015-12-09T15:54:24.043" Title="Apply formating with a script, or have ftplugin format particular text based on syntax" Tags="|vimscript|filetype-tex|wrapping|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4907" PostTypeId="1" AcceptedAnswerId="4908" CreationDate="2015-09-29T08:18:32.677" Score="10" ViewCount="2430" Body="&lt;p&gt;I'm using macvim inside tmux inside iTerm2. Basically I just want to be able to scroll the buffer using the mousewheel. I've set&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set -g moude-mouse on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;.tmux.conf&lt;/code&gt;, and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=a&#xA;set ttymouse=xterm2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;.vimrc&lt;/code&gt;. Additionally I enabled 'xterm mouse reporting' in iTerm2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever I use the mouse wheel, vim will switch to insert mode and insert seemingly random characters. I'm guessing vim can't correctly interpret the mouse escape-codes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem also appears outside of tmux and in the default Terminal.app which leads me to believe that it's a vim issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've expiremented with all possible values of &lt;code&gt;ttymouse&lt;/code&gt;, none had the desired effect.&lt;/p&gt;&#xA;" OwnerUserId="1842" LastActivityDate="2015-09-29T09:00:04.140" Title="Mouse wheel scrolling inserts characters" Tags="|macvim|tmux|iterm2|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4908" PostTypeId="2" ParentId="4907" CreationDate="2015-09-29T09:00:04.140" Score="12" Body="&lt;p&gt;Ah, I found the culprit by bisecting my &lt;code&gt;.vimrc&lt;/code&gt; file. I had mapped &lt;kbd&gt;Escape&lt;/kbd&gt; in normal mode to clear search highlighting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Clear highlighting on escape in normal mode&#xA;nnoremap &amp;lt;esc&amp;gt; :noh&amp;lt;return&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, that will confuse vim as it tries to parse the mouse's escape codes. So what I ended up doing is taking the solution from &lt;a href=&quot;https://stackoverflow.com/a/1037182/337591&quot;&gt;this answer&lt;/a&gt;, and also mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; needed so that vim still understands escape sequences&#xA;nnoremap &amp;lt;esc&amp;gt;^[ &amp;lt;esc&amp;gt;^[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will fix that issue.&lt;/p&gt;&#xA;" OwnerUserId="1842" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-09-29T09:00:04.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4909" PostTypeId="1" AcceptedAnswerId="4910" CreationDate="2015-09-29T11:20:44.623" Score="6" ViewCount="121" Body="&lt;p&gt;What is the appropriate way to make shortcuts for phrases like ‘on the other hand’? I tried &lt;code&gt;imap otoh on the other hand&lt;/code&gt;, but that produces an undesireable lag after all &lt;code&gt;o&lt;/code&gt;s.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2015-10-02T17:36:22.580" LastActivityDate="2015-10-02T17:36:22.580" Title="Shortcuts for phrases" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4910" PostTypeId="2" ParentId="4909" CreationDate="2015-09-29T11:36:42.370" Score="8" Body="&lt;p&gt;Take a look at &lt;code&gt;:help abbreviations&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev otoh on the other hand&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-29T11:36:42.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4911" PostTypeId="1" CreationDate="2015-09-29T12:34:26.277" Score="4" ViewCount="1946" Body="&lt;p&gt;When I use &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt; to autocomplete, a list of possible completions appears, which can be annoying. Can this be disabled?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2017-03-14T10:18:57.157" LastActivityDate="2017-03-14T10:18:57.157" Title="How to disable the autocomplete menu but still get words completed?" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4912" PostTypeId="1" AcceptedAnswerId="5270" CreationDate="2015-09-29T13:26:19.963" Score="0" ViewCount="318" Body="&lt;p&gt;I have finally got vim with airline plugin to work on windows with conemu thanks to &lt;a href=&quot;https://github.com/bling/vim-airline/issues/513&quot; rel=&quot;nofollow noreferrer&quot;&gt;this topic&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Almost everything is good right now except some problems with colors in airline when screen is scrolled. Check below gif:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/R8V6V.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/R8V6V.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking forward to find the culprit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the beginning result was worse, but I commented everything that was reduntant. In spare time I will check each and every single setting in the vimrc file. But still can't get the airline to hold its colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find my vimrc &lt;a href=&quot;https://gist.github.com/lkurylo/aa947a1ae6d7185aa064&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3349" LastEditorUserId="1841" LastEditDate="2015-09-29T17:27:07.853" LastActivityDate="2015-10-26T07:41:52.187" Title="airline in conemu - changing colors on page scroll" Tags="|microsoft-windows|plugin-airline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4913" PostTypeId="2" ParentId="4139" CreationDate="2015-09-29T14:00:18.707" Score="1" Body="&lt;p&gt;Many linux distributions offer a Vim with Perl support. If this is the case we can use &lt;code&gt;:perl perl-command&lt;/code&gt; and &lt;code&gt;:perldo perl-command&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:perldo $c=31&#xA;:perldo s/a(\d{10})/$m{$1} ||= $c++; &quot;f$m{$1}&quot; /ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(untested)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution presented is in fact very similar to the question...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:perldo perl-command&lt;/code&gt; executes perl-command for the range (def: all lines)&lt;/li&gt;&#xA;&lt;li&gt;if &quot;perl-command&quot; modifies the default string, the line gets modified. Perl's  &lt;code&gt;s/regExp/str/&lt;/code&gt; is very similar to vim's s///...&lt;/li&gt;&#xA;&lt;li&gt;but &quot;eval&quot; option: &lt;code&gt;s/RegExp/perl-exp/e&lt;/code&gt; is nice and powerful: it substitutes by &lt;code&gt;eval-in-perl(perl-exp)&lt;/code&gt;, in our case:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;for all occurences of &lt;code&gt;a\d{10}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;define a new number if we have a new case: &lt;code&gt;$m{number} = $n{number} || $c++&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;replace by &lt;code&gt;fNUMBER&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;RegExp (following the question) is &quot;a&quot; followed by 10 digits (&lt;code&gt;\d{10}&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3002" LastEditorUserId="3002" LastEditDate="2016-09-26T14:29:07.973" LastActivityDate="2016-09-26T14:29:07.973" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4914" PostTypeId="1" AcceptedAnswerId="4917" CreationDate="2015-09-29T14:45:53.343" Score="2" ViewCount="116" Body="&lt;p&gt;This is more of a specific deeper dive into vanilla Vim then the question &lt;a href=&quot;https://vi.stackexchange.com/questions/2493/can-i-make-vim-also-save-small-deletions-into-register-1&quot;&gt;Can I make Vim also save “small deletions” into register &quot;1?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A common text editing situation I run into is to yank a text string and then attempt to replace another string with the one previously yanked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do this on a line Vim generously rotates the registries for me (&lt;code&gt;&quot;1&lt;/code&gt;, &lt;code&gt;&quot;2&lt;/code&gt;, &lt;code&gt;&quot;…&lt;/code&gt;) but with inner text movement you usually get one register and it gets swallowed with the last movement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the following example becomes problematic:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foobar = &quot;this is a test&quot;&#xA;bazfoo = &quot;this is another test&quot;&#xA;                  ^- Cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;yi&quot;kci&quot;&amp;lt;C-R&amp;gt;-&lt;/code&gt;. Now I could preempt this with &lt;code&gt;&quot;ayi&quot;kci&quot;&amp;lt;C-R&amp;gt;a&lt;/code&gt;. However, this is slightly problematic because more times than not the later is executed like this instead: &lt;code&gt;yi&quot;kci&quot;crap!&amp;lt;Esc&amp;gt;uj&quot;ayi&quot;kci&quot;&amp;lt;C-R&amp;gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously this isn't ideal. So I am curious, how do I conveniently manage small change registers or is there a better way to replace a text object with a previously yanked one?&lt;/p&gt;&#xA;" OwnerUserId="544" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-10-02T13:40:46.410" Title="How can I conveniently yank then change small text?" Tags="|cut-copy-paste|cursor-motions|register|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4915" PostTypeId="2" ParentId="4909" CreationDate="2015-09-29T14:54:08.273" Score="2" Body="&lt;p&gt;You can use &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow&quot;&gt;UltiSnips&lt;/a&gt; generic snippet plugin. In this you can do something like.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet otoh &quot;Some description&quot; b&#xA;on the other hand&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4696" LastEditorUserId="1841" LastEditDate="2015-09-29T15:42:57.030" LastActivityDate="2015-09-29T15:42:57.030" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4916" PostTypeId="2" ParentId="4911" CreationDate="2015-09-29T17:13:53.247" Score="4" Body="&lt;p&gt;You can use &lt;code&gt;set completeopt=longest&lt;/code&gt; which will insert the longest common text of the matches. (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27completeopt%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 'completeopt'&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be sure not to have &lt;code&gt;menu&lt;/code&gt; nor &lt;code&gt;menuone&lt;/code&gt; in &lt;code&gt;'completeopt'&lt;/code&gt; to disable the autocompletion menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way when you'll trigger autocomplete with &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; you will not have the menu open but the word will be complete with as many letters as possible.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-09-29T17:22:00.323" LastActivityDate="2015-09-29T17:22:00.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4917" PostTypeId="2" ParentId="4914" CreationDate="2015-09-29T19:30:13.497" Score="6" Body="&lt;p&gt;If you don't use a specific register, the text you yank systematically goes into register &lt;code&gt;0&lt;/code&gt; where it will stay until you yank something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that you can still use what you yanked, even if you cut stuff in the mean time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Paste from register &lt;code&gt;0&lt;/code&gt; in normal mode: &lt;code&gt;&quot;0p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Insert content of register &lt;code&gt;0&lt;/code&gt; in insert mode: &lt;code&gt;&amp;lt;C-r&amp;gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help registers&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-09-29T19:30:13.497" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4919" PostTypeId="1" AcceptedAnswerId="4922" CreationDate="2015-09-29T22:44:18.333" Score="146" ViewCount="140492" Body="&lt;p&gt;I can't figure out how to go back to &lt;code&gt;Normal&lt;/code&gt; mode after entering &lt;code&gt;Terminal&lt;/code&gt; in &lt;code&gt;Insert&lt;/code&gt; mode...&lt;/p&gt;&#xA;&lt;p&gt;Escape just doesn't seem to work.&lt;/p&gt;&#xA;&lt;p&gt;Any idea?&lt;/p&gt;&#xA;" OwnerUserId="1682" LastEditorUserId="8558" LastEditDate="2020-07-05T14:48:15.303" LastActivityDate="2022-12-27T11:47:45.610" Title="Exit from Terminal mode in Neovim/Vim 8" Tags="|neovim|terminal-buffer|" AnswerCount="13" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="4920" PostTypeId="1" AcceptedAnswerId="4923" CreationDate="2015-09-30T00:51:10.243" Score="3" ViewCount="723" Body="&lt;p&gt;I really want to know why doesn't Vim's &lt;code&gt;v:lnum&lt;/code&gt; return 1 for very first line. I tried googling and searching in Vim's docs, but I can't find an answer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that &lt;code&gt;v:lnum&lt;/code&gt; returns &lt;em&gt;line number&lt;/em&gt;, but I don't understand which line &lt;code&gt;v:lnum&lt;/code&gt; is referring to..? A little aside; from &lt;code&gt;help v:lnum&lt;/code&gt; I understand that you can only use &lt;code&gt;v:lnum&lt;/code&gt; with some expressions including &lt;code&gt;indentexpr&lt;/code&gt; (the one I'm interested in the most for my indentation script). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;workflow test 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;make a &lt;code&gt;.vim&lt;/code&gt; file. e.g &lt;code&gt;check.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;append &lt;code&gt;echo v:lnum&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;open new vim window and &lt;code&gt;:source check.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;append some text to the file and &lt;code&gt;:source check.vim&lt;/code&gt; again&lt;/li&gt;&#xA;&lt;li&gt;no matter how many lines I add to the file I always get &lt;code&gt;0&lt;/code&gt; back&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I think I understand this, since Vim docs say that &lt;code&gt;v:lnum&lt;/code&gt; only works in conjunction with some specific expressions then you would expect &lt;code&gt;0&lt;/code&gt; when I'm trying to use &lt;code&gt;v:lnum&lt;/code&gt; by itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;workflow test 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;make &lt;code&gt;check.vim&lt;/code&gt; file&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;append&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal indentexpr=Check()&#xA;function! Check()&#xA;  let line = getline(v:lnum)&#xA;  echo v:lnum line&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;open new vim window and &lt;code&gt;:source check.vim&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;append some text to the file and &lt;code&gt;:call Check()&lt;/code&gt; function&lt;/li&gt;&#xA;&lt;li&gt;I DON'T get &lt;em&gt;first line&lt;/em&gt; no matter what I do.. I can get any other lines.. e.g &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if I only type in one line into the file and &lt;code&gt;:call Check()&lt;/code&gt; I get &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;''&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;if I type in second line into the file and &lt;code&gt;:call Check()&lt;/code&gt; I get &lt;code&gt;2&lt;/code&gt; and &lt;code&gt;check line two&lt;/code&gt; back&lt;/li&gt;&#xA;&lt;li&gt;if I keep adding lines to the file and run &lt;code&gt;:call Check()&lt;/code&gt; on lets say the fifths line I get &lt;code&gt;5&lt;/code&gt; and &lt;code&gt;check line five&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I think I understand that &lt;code&gt;v:lnum&lt;/code&gt; returns index of the last line typed into the file. But why doesn't it return the index of the very first line type?&lt;/p&gt;&#xA;" OwnerUserId="4700" LastEditorUserId="205" LastEditDate="2015-09-30T05:09:18.287" LastActivityDate="2015-09-30T06:15:45.513" Title="Why `v:lnum` doesn't return 1 for the first line?" Tags="|vimscript|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4921" PostTypeId="2" ParentId="4914" CreationDate="2015-09-30T01:51:30.753" Score="0" Body="&lt;p&gt;You can also use visual mode. Your example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foobar = &quot;this is a test&quot;&#xA;bazfoo = &quot;this is another test&quot;&#xA;                  ^- Cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can be changed with &lt;code&gt;yi&quot;kvi&quot;p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foobar = &quot;this is another test&quot;&#xA;bazfoo = &quot;this is another test&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h v_p&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2154" LastActivityDate="2015-09-30T01:51:30.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4922" PostTypeId="2" ParentId="4919" CreationDate="2015-09-30T05:09:54.863" Score="159" Body="&lt;p&gt;You are supposed to press &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;n&lt;/kbd&gt;.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;code&gt;:help terminal-emulator&lt;/code&gt; for a mapping suggestion.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="37975" LastEditDate="2021-09-17T11:53:21.260" LastActivityDate="2021-09-17T11:53:21.260" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="4923" PostTypeId="2" ParentId="4920" CreationDate="2015-09-30T06:15:45.513" Score="4" Body="&lt;p&gt;&lt;code&gt;v:lnum&lt;/code&gt; is a Vim internal variable, that is only &lt;strong&gt;valid&lt;/strong&gt; while evaluating the &lt;code&gt;indentexpr&lt;/code&gt;, &lt;code&gt;foldexpr&lt;/code&gt;, &lt;code&gt;formatexpr&lt;/code&gt; options. In other contexts this does nothing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means, that in you indentexpr or formatexpr you can find out, what line is currently being evaluated and react accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For indentexpr this means, it will get filled, once you start indenting your file, e.g. using &lt;code&gt;gg=G&lt;/code&gt;, for formatexpr this will be evaluated when defining your foldmethod and folding is enabled and formatexpr will be evaluated using the gq command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other context, this is really invalid. It should actually be always 0 so there might be a (minor) bug there.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-09-30T06:15:45.513" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4924" PostTypeId="1" AcceptedAnswerId="4927" CreationDate="2015-09-30T12:34:45.237" Score="0" ViewCount="46" Body="&lt;p&gt;When I am coding in c++, I want vim to expand &lt;code&gt;(&lt;/code&gt; into &lt;code&gt;()&amp;lt;++&amp;gt;&lt;/code&gt; and place the cursor in the parenthesis. I do this by putting the following line in one of the files loaded at startup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap (      ()&amp;lt;++&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I would like this binding to be disabled in comments, like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Inline comment where ( shouldn't become ()&amp;lt;++&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Comment block where ( shouldn't become ()&amp;lt;++&amp;gt;&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do it?&lt;/p&gt;&#xA;" OwnerUserId="4708" LastActivityDate="2015-09-30T13:31:46.260" Title="Define new command that works only outside c++ comments" Tags="|comments|filetype-c++|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4926" PostTypeId="2" ParentId="4924" CreationDate="2015-09-30T13:06:37.883" Score="0" Body="&lt;p&gt;[copy paste of the answer given on SO...]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets/&quot; rel=&quot;nofollow&quot;&gt;lh-brackets&lt;/a&gt; it already detects the context to not expand anywhere. It also adds a placeholder after the closing brackets. If you directly install &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp&quot; rel=&quot;nofollow&quot;&gt;lh-cpp&lt;/a&gt;, the control statements will also be context aware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I must admit your request is quite surprising as nobody seems to use placeholders any more. And yet lh-brackets is the plugin that (re-)introduced this concept (idea stolen from Stephen Riehm's original bracketing macros). Then &lt;a href=&quot;https://github.com/LucHermitte/mu-template/&quot; rel=&quot;nofollow&quot;&gt;mu-template&lt;/a&gt; used a similar bracketing philosophy, and finally latex-suite did as well. BTW, lh-brackets should be compatible with an installed version of latex-suite)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: for the ones that absolutely want to define the mappings themselves, look at the &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets/blob/master/plugin/misc_map.vim#L200&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Map*Context()&lt;/code&gt; functions&lt;/a&gt; from lh-brackets. The first version recognized comments and string contexts to not expand the &lt;em&gt;key&lt;/em&gt;. The last version (&lt;code&gt;Map4TheseContext()&lt;/code&gt;) permits to specify how the key should be expanded for a list of possible contexts.&lt;br&gt;&#xA;The idea is to test the context with &lt;code&gt;synIDattr(synID(line('.'),col('.')-1,1),'name')&lt;/code&gt;, then to interpret possible special character sequences like &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2015-09-30T13:06:37.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4927" PostTypeId="2" ParentId="4924" CreationDate="2015-09-30T13:24:50.760" Score="1" Body="&lt;p&gt;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:&#xA;&lt;code&gt;&#xA;:inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; ( synIDattr(synIDtrans(synID(line('.'), col('.')-1, 'name')),'name')=~?&quot;comment&quot;?&quot;(&quot;:&quot;()&amp;lt;++&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which means, check that the current syntax item is not of type comment and in that case replace by your ()&amp;lt;++&gt; item or else replace by themselves. Note, it is probably more easier to hide that functionality behind a function that does the necessary checks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: to make undo and redo work properly, instead of using &quot;&amp;lt;Left&gt;&quot; you should use &quot;&amp;lt;C-G&gt;U&amp;lt;Left&gt;&quot;, which is a relative recent addition to Vim. Read the help at &lt;code&gt;:h i_CTRL-G_U&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-09-30T13:31:46.260" LastActivityDate="2015-09-30T13:31:46.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4928" PostTypeId="2" ParentId="3809" CreationDate="2015-09-30T13:59:07.170" Score="1" Body="&lt;p&gt;I solved the problem by writing a small python script that creates a tag file. The script searches for CSS classes and prints a tag line for every class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment I run the script by hand with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;css_tags $file &amp;gt;&amp;gt; tags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which adds the files to the tags file.&#xA;This works since tag completion isn't limited by the &lt;code&gt;iskeyword&lt;/code&gt; setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the contents of the script which is also available on &lt;a href=&quot;https://github.com/tantSinnister/CSSTags&quot; rel=&quot;nofollow&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python3&#xA;&#xA;import argparse&#xA;import re&#xA;&#xA;parser = argparse.ArgumentParser(description='CSStags.')&#xA;parser.add_argument('css_file', type=argparse.FileType('r'))&#xA;&#xA;&#xA;def create_tag(tag_name, filename, line):&#xA;    &quot;&quot;&quot;&#xA;    Create a ctag line for the CSS class&#xA;    &quot;&quot;&quot;&#xA;    print('%s\t%s\t/^%s$/;&quot;\tc' % (tag_name, filename, line))&#xA;&#xA;&#xA;def main():&#xA;    args = parser.parse_args()&#xA;&#xA;    class_regex = re.compile('^\.([\w-]+)\s*{')&#xA;&#xA;    for line in args.css_file:&#xA;        class_match = class_regex.match(line)&#xA;        if class_match:&#xA;            create_tag(class_match.group(1), args.css_file.name, class_match.group(0))&#xA;&#xA;&#xA;if __name__ == '__main__':&#xA;    main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="350" LastActivityDate="2015-09-30T13:59:07.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4929" PostTypeId="1" CreationDate="2015-09-30T14:19:17.713" Score="1" ViewCount="264" Body="&lt;p&gt;The GVim window is having screen refresh issues in my vmware virtual machine. The problem is very evident when I scroll pages or go to a line or search for words. Pressing Ctrl-k repaints the screen and if I navigate the document up/down line by line, it clears up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The VM itself has sufficient resources and nothing is running in the background. OS: Linux Mint 17.2. This is an irritating problem, and affects particularly while doing find/replace as the screen will only show the words are found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, I tried to get a screen shot of the GVim window, but the very act of Alt-PrtScn refreshes the window and the buffer appears. This problem is absent when opening vim on a bash terminal.&lt;/p&gt;&#xA;" OwnerUserId="4709" LastEditorUserId="205" LastEditDate="2015-09-30T14:33:20.283" LastActivityDate="2015-09-30T14:33:20.283" Title="VIM behavior in Linux VM" Tags="|gvim|linux-debian|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4930" PostTypeId="2" ParentId="4612" CreationDate="2015-09-30T14:24:17.407" Score="2" Body="&lt;p&gt;This function does what I need&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! TextWrap(text, width, indent)&#xA;&#xA;  let l:line = ''&#xA;  let l:ret  = ''&#xA;&#xA;  for word in split(a:text)&#xA;&#xA;    if len(l:line) + len(word) + 1 &amp;gt; a:width&#xA;&#xA;       if len(l:ret)&#xA;          let l:ret .= &quot;\n&quot;&#xA;       endif&#xA;       let l:ret .=  repeat(' ', a:indent) . l:line&#xA;&#xA;       let l:line = ''&#xA;&#xA;    endif&#xA;&#xA;    if len (l:line)&#xA;       let l:line .= ' '&#xA;    endif&#xA;&#xA;    let l:line .= word&#xA;&#xA;  endfor&#xA;&#xA;  let l:ret .= &quot;\n&quot; . repeat(' ', a:indent) . l:line&#xA;&#xA;  return l:ret&#xA;&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function is then called, for example, like so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo TextWrap(&quot;one two three four five six seven eight nine ten&quot;, 8, 2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which results in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  one two&#xA;  three&#xA;  four&#xA;  five six&#xA;  seven&#xA;  eight&#xA;  nine ten&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The parameter &lt;code&gt;indent&lt;/code&gt; specifies how many empty (space) characters there are in front of the first word. &lt;code&gt;width&lt;/code&gt; specifies the maximum number of characters &lt;em&gt;after&lt;/em&gt; &lt;code&gt;indent&lt;/code&gt; characters. (for example &lt;code&gt;five six&lt;/code&gt; or &lt;code&gt;nine ten&lt;/code&gt; each constists of 8 characters).&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="985" LastEditDate="2016-08-27T07:19:33.153" LastActivityDate="2016-08-27T07:19:33.153" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4931" PostTypeId="1" AcceptedAnswerId="4932" CreationDate="2015-09-30T14:52:05.267" Score="2" ViewCount="846" Body="&lt;p&gt;How can I get git's &lt;code&gt;difftool&lt;/code&gt;, when using &lt;code&gt;vimdiff&lt;/code&gt;, to use my &lt;code&gt;~/.vimrc&lt;/code&gt; file?&lt;/p&gt;&#xA;" OwnerUserId="756" LastEditorUserId="1841" LastEditDate="2015-09-30T15:30:40.963" LastActivityDate="2015-09-30T15:51:19.537" Title="How to use ~/.vimrc for vimdiff" Tags="|vimdiff|git|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4932" PostTypeId="2" ParentId="4931" CreationDate="2015-09-30T15:51:19.537" Score="2" Body="&lt;p&gt;In my &lt;code&gt;git&lt;/code&gt; config, I have alias:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[alias]&#xA;   vimdiff=difftol -y -t vimdiff -R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &lt;em&gt;does&lt;/em&gt; use my .vimrc to display all colorscheme, statusline, etc.&lt;/p&gt;&#xA;" OwnerUserId="2303" LastActivityDate="2015-09-30T15:51:19.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4933" PostTypeId="2" ParentId="4847" CreationDate="2015-09-30T15:56:48.430" Score="1" Body="&lt;p&gt;I normally use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;perl -i -p0e '$_.=&quot;export PATH=~/bin:\$PATH\n&quot; unless m!~/bin:!' ~/.bashrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3002" LastActivityDate="2015-09-30T15:56:48.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4934" PostTypeId="2" ParentId="4878" CreationDate="2015-09-30T16:24:29.320" Score="0" Body="&lt;p&gt;I have two functions that swap back and forth between tabs and spaces, as well, if interested.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Tabstyle_tabs()&#xA;  &quot; Default to using 8 column tabs&#xA;  set softtabstop=8&#xA;  set shiftwidth=8&#xA;  set tabstop=8&#xA;  set noexpandtab&#xA;endfunction&#xA;&#xA;function! Tabstyle_spaces()&#xA;  &quot; Default to using 4 column indents&#xA;  set softtabstop=4&#xA;  set shiftwidth=4&#xA;  set tabstop=4&#xA;  set expandtab&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can set the &lt;code&gt;8&lt;/code&gt; and &lt;code&gt;4&lt;/code&gt; to whatever sizes you like of course.&lt;br&gt;&#xA;I'd started to work on a function that takes variable size tabstop, but haven't bothered, as I use &lt;code&gt;autocmds&lt;/code&gt; for different file types and this use these functions only when necessary otherwise.&lt;/p&gt;&#xA;" OwnerUserId="2303" LastActivityDate="2015-09-30T16:24:29.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4935" PostTypeId="2" ParentId="3944" CreationDate="2015-09-30T16:50:30.137" Score="4" Body="&lt;p&gt;This is a very bad answer (down-votes deserved)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) &lt;strong&gt;netrw&lt;/strong&gt; has to do with history of remote files editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(from: &lt;a href=&quot;https://stackoverflow.com/a/9850662/2991627&quot;&gt;https://stackoverflow.com/a/9850662/2991627&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;netrw&lt;/strong&gt; is a kind of vim plugin/script which supports reading and writing files across networks. .netrwhist is a history file which maintains all the directories that were modified. So whenever you modify the contents of ~/.vim it adds one entry in .netrwhist  )&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;2) Somewhere (.vimrc, .netrwhist or similar) you may have some operation that&#xA;changes register &lt;code&gt;&quot;+&lt;/code&gt; or &lt;code&gt;&quot;*&lt;/code&gt;  (look for &lt;code&gt;/[*+]&lt;/code&gt; in those files...) and see if there is something strange...&lt;/p&gt;&#xA;" OwnerUserId="3002" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-09-30T16:50:30.137" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4936" PostTypeId="2" ParentId="4878" CreationDate="2015-09-30T17:30:29.660" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/Raimondi/YAIFA&quot; rel=&quot;nofollow&quot;&gt;YAIFA plugin&lt;/a&gt; may be of interest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It tries to auto-detect the indentation method used in the current file, and set your &lt;code&gt;expandtab&lt;/code&gt; &lt;code&gt;tabstop&lt;/code&gt; and &lt;code&gt;shiftwidth&lt;/code&gt; options appropriately.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-09-30T17:30:29.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4937" PostTypeId="2" ParentId="4894" CreationDate="2015-09-30T17:58:18.650" Score="2" Body="&lt;p&gt;You could modify &lt;code&gt;ignorecase&lt;/code&gt; when you move in or out of a window or buffer, so it will always have the desired value.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Automatically by file type&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd WinEnter * let &amp;amp;ignorecase = match( bufname(&quot;%&quot;), '\.php$' ) != -1&#xA;autocmd BufEnter * let &amp;amp;ignorecase = match( bufname(&quot;%&quot;), '\.php$' ) != -1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would set &lt;code&gt;ignorecase&lt;/code&gt; on &lt;code&gt;*.php&lt;/code&gt; files, and unset it otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to write the same command for both WinEnter and BufEnter, but they could call out to a function if you want to avoid repetition.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Manually set for each buffer (like setlocal)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Since you asked how to set &lt;code&gt;ignorecase&lt;/code&gt; locally, this solution might give you something close to what you wanted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command SetLocalIgnoreCase    set ignorecase   | let b:ignorecase = 1&#xA;command SetLocalNoIgnoreCase  set noignorecase | let b:ignorecase = 0&#xA;&#xA;autocmd WinEnter * let &amp;amp;ignorecase = get(b:, 'ignorecase', 0)&#xA;autocmd BufEnter * let &amp;amp;ignorecase = get(b:, 'ignorecase', 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above, &lt;code&gt;b:ignorecase&lt;/code&gt; is a buffer-local variable, which the autocmds can pick up when switching focus.  If you wanted window-local, use &lt;code&gt;w:&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We use &lt;code&gt;get()&lt;/code&gt; to avoid errors in buffers where the variable does not exist, and default to &lt;code&gt;0&lt;/code&gt; in that case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(With liberal use of &lt;code&gt;eval&lt;/code&gt; this approach could even be generalised to other global options that you want to act as locals.)&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-10-02T23:57:16.883" LastActivityDate="2015-10-02T23:57:16.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4938" PostTypeId="1" AcceptedAnswerId="4948" CreationDate="2015-09-30T21:52:16.880" Score="2" ViewCount="60" Body="&lt;p&gt;I'm not sure of the right language here, but I need to modify all occurrences of a pattern (specifically &amp;amp;) that occur inside a pair of delimiters while leaving unmodified the pattern if it is 'outside all open delimiters'.      With apologies, here's a complicated real world example (I'm concerned that an answer to a simplified example might exploit special features of the example that won't hold in general.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the following line, the first &amp;amp; is outside all delimiters, but the second one is located to the right of a { and to the left of the matching }.   I need to modify the second one but not the first.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; \begin{array}{l l}E\left( {\tau |k} \right) &amp;amp; =  E\left[ {\left. {\left( {\frac{1}{{n - 2d}}\sum\nolimits_{i  =  1}^n {{Z_i}} } \right)\tau } \right|k} \right]  = \frac{1}{{n - 2d}}\sum\nolimits_{i  &amp;amp; =  1}^n {E\left( {{Z_i}\tau |k} \right)} \\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's an even nastier example.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\left| {E\left( {X|A} \right)} \right| &amp;amp; =  \left| {E\left( {{q_2}|{q_1} &amp;lt; {q_2}  &amp;lt;  {q_3}  &amp;lt;  {q_4}} \right)} \right| &amp;amp; =  \frac{{\left| {E\left( {{q_2}{I_{{q_1} &amp;amp; &amp;lt;  {q_2} &amp;amp; &amp;lt;  {q_3} &amp;amp; &amp;lt;  {q_4}}}} \right)} \right|}}{{P\left( A \right)}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, the first and second &amp;amp;'s are outside of any matching delimiters, but the third, fourth and fifth are enclosed in matching delimiters, and need to be modified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks very much for any advice, and apologies for the persnickety nature of this horrible problem.&lt;/p&gt;&#xA;" OwnerUserId="4667" LastActivityDate="2015-10-01T15:39:53.613" Title="Distinguish between patterns that are inside open delimters and those that are not" Tags="|delimiter-matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4939" PostTypeId="2" ParentId="4709" CreationDate="2015-09-30T22:33:08.597" Score="2" Body="&lt;p&gt;&lt;strong&gt;Note 1&lt;/strong&gt;: In the comments OP requested examples of syntax files in both formats, so this is not a complete answer but maybe some elements which could be useful to have in mind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 2&lt;/strong&gt;: My knowledge of Notepad++ is pretty limited so as said in the Note1 let's hope that someone with a deeper knowledge will see this post and make a better answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First to answer the question, as said &lt;a href=&quot;https://superuser.com/a/575529/386795&quot;&gt;here&lt;/a&gt; it seems that there is no existing tool able to automatically convert a Notepad++ language file to Vim syntax file. The main reason is that the vim syntax files use some very specific mechanisms which don't have equivalents in Notepad++. Hence translating a file might be much longer than writing one from scratch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some resources which might be useful:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://docs.notepad-plus-plus.org/index.php/User_Defined_Languages&quot; rel=&quot;nofollow noreferrer&quot;&gt;A documentation&lt;/a&gt; about user-defined Notepad++ language files.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://docs.notepad-plus-plus.org/index.php?title=User_Defined_Language_Files&quot; rel=&quot;nofollow noreferrer&quot;&gt;A list&lt;/a&gt; of Notepad++ language files.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Creating_your_own_syntax_files&quot; rel=&quot;nofollow noreferrer&quot;&gt;A wikia tip&lt;/a&gt; and &lt;a href=&quot;http://docs.notepad-plus-plus.org/index.php?title=User_Defined_Language_Files&quot; rel=&quot;nofollow noreferrer&quot;&gt;a really good tutorial&lt;/a&gt; about Vim syntax files.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think it is possible to get the keywords on the Notepad++ file to create a basic Vim file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once again this answer is not complete at all and really doesn't solve the problem.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2015-09-30T22:33:08.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4940" PostTypeId="1" AcceptedAnswerId="4941" CreationDate="2015-09-30T23:53:04.643" Score="6" ViewCount="654" Body="&lt;p&gt;Vim has some kind of support for dot-separated compound filetypes like &quot;ruby.rspec&quot; where settings/definitions for both will be loaded. I see mentions of it around the internet but I can't find any mention of it in the docs. Is there a canonical doc on it or an official name for this feature?&lt;/p&gt;&#xA;" OwnerUserId="824" LastActivityDate="2015-10-01T14:34:22.520" Title="Where are vim compound (dotted) filetypes documented" Tags="|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4941" PostTypeId="2" ParentId="4940" CreationDate="2015-10-01T05:57:22.557" Score="4" Body="&lt;p&gt;This is described briefly at &lt;code&gt;:h 'filetype'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When a dot appears in the value then this separates two filetype&#xA;names.  Example:&#xA;    /* vim: set filetype=c.doxygen : */ ~&#xA;This will use the &quot;c&quot; filetype first, then the &quot;doxygen&quot; filetype.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="824" LastEditDate="2015-10-01T14:34:22.520" LastActivityDate="2015-10-01T14:34:22.520" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4942" PostTypeId="2" ParentId="4817" CreationDate="2015-10-01T06:43:24.817" Score="3" Body="&lt;p&gt;I know this is the vi/vim stackexchange, but the best solution to this is actually the bash history.  I see it mentioned in a few answers, but I thought I would expand on it a little bit, because bash history expansion has a lot more useful features than I've seen commonly used:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can use &lt;code&gt;!vi&lt;/code&gt; to immediately run the last command that started with &lt;code&gt;vi&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You can use &lt;code&gt;!vi:p&lt;/code&gt; to print that command (and add it to the history list) without running it.  If it is indeed the command you want to run, you just press the up arrow and &lt;kbd&gt;Enter&lt;/kbd&gt;, or just type &lt;code&gt;!!&lt;/code&gt; and press &lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Let's say you run &lt;code&gt;!vi:p&lt;/code&gt; and find the file you want, but the command was run the last time with a bunch of extra arguments, such as &lt;code&gt;vim -s ./dostuff.vimscript -N mydir/subdir/myfile.txt&lt;/code&gt; and you want to edit &lt;code&gt;myfile.txt&lt;/code&gt; without using any of the other options.  Simply type &lt;code&gt;vim !$&lt;/code&gt; and voila!  &lt;code&gt;!$&lt;/code&gt; is expanded to the last argument of the immediately preceding command, and you've got the file open as you wanted.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For further reading I recommend the bash man page.  Type &lt;code&gt;/^HISTORY EXPANSION&lt;/code&gt; and you will go straight to the applicable section.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2015-10-01T06:43:24.817" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4943" PostTypeId="2" ParentId="4612" CreationDate="2015-10-01T11:34:47.553" Score="0" Body="&lt;p&gt;I have wrote something a bit alike for indenting with options my mail texts (with a justify option). It's called &lt;code&gt;yaposting&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/guyzmo/vim-yaposting&quot; rel=&quot;nofollow&quot;&gt;https://github.com/guyzmo/vim-yaposting&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;whithin it there's a mail format tool with enough parameters to do that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/guyzmo/vim-yaposting/blob/master/pylibs/mail_format.py&quot; rel=&quot;nofollow&quot;&gt;https://github.com/guyzmo/vim-yaposting/blob/master/pylibs/mail_format.py&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and it is exposed as a function within the vimscript file to do so:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/guyzmo/vim-yaposting/blob/master/plugin/yaposting.vim#L113&quot; rel=&quot;nofollow&quot;&gt;https://github.com/guyzmo/vim-yaposting/blob/master/plugin/yaposting.vim#L113&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Though I did that plugin a long time ago, before I actually understood vim. If I was to rewrite this plugin, I'd change it to have the python function work within &lt;code&gt;:set formatprg&lt;/code&gt; with the parameters of how you want to setup your indentation given as either arguments to &lt;code&gt;set formatprg&lt;/code&gt; or another global vim setting. And then use the traditional &lt;code&gt;gqap&lt;/code&gt; (and eventually enable other &lt;code&gt;gq-&lt;/code&gt; like shortcut to make it available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the right thing is to use the &quot;standard&quot; vi thing, which is &lt;code&gt;gqap&lt;/code&gt;, and the right tool that formats things how you want it!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="4434" LastActivityDate="2015-10-01T11:34:47.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4944" PostTypeId="1" AcceptedAnswerId="4949" CreationDate="2015-10-01T13:15:34.723" Score="15" ViewCount="6428" Body="&lt;p&gt;I am trying to reverse a string, so that &lt;code&gt;'abc defg hij'&lt;/code&gt; becomes &lt;code&gt;'jih gfed cba'&lt;/code&gt;. The solution I came up with is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;join(reverse(split(l:text, '.\zs')), '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a more elegant solution or should I stick with what I have come up with?&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2019-09-09T12:58:20.243" Title="How do I reverse a string with Vim script" Tags="|vimscript|string-manipulation|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="4945" PostTypeId="1" AcceptedAnswerId="5978" CreationDate="2015-10-01T14:47:33.680" Score="10" ViewCount="433" Body="&lt;p&gt;I'm interested in learning how the term &lt;em&gt;yank&lt;/em&gt; got its name.  I'm also interested in why Vi/Vim &quot;yank&quot; differs from Emacs &quot;yank&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;a href=&quot;https://unix.stackexchange.com/questions/209660/why-is-the-vi-editors-copy-command-called-yank&quot;&gt;same question on Unix &amp;amp; Linux&lt;/a&gt;; &lt;a href=&quot;https://emacs.stackexchange.com/questions/17056/what-is-the-origin-of-the-term-yank&quot;&gt;dual question about Emacs&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4718" LastEditorUserId="-1" LastEditDate="2017-04-13T12:52:45.943" LastActivityDate="2015-12-28T20:01:05.450" Title="What is the origin of the term &quot;yank&quot;?" Tags="|cut-copy-paste|history-of|original-vi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4946" PostTypeId="2" ParentId="4847" CreationDate="2015-10-01T14:48:42.827" Score="2" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex ~/.bashrc -c &quot;if search('export PATH=\~\/.composer\/vendor\/bin:\$PATH')&amp;gt;0 | norm quit | endif | norm Aexport PATH=~/.composer/vendor/bin:$PATH&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;:append&lt;/code&gt; won't work inside &lt;code&gt;if endif&lt;/code&gt;-block with Ex mode (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#:append&quot; rel=&quot;nofollow&quot;&gt;VimDoc&lt;/a&gt;) so I have to put &lt;code&gt;norm A...&lt;/code&gt; outside.&lt;/p&gt;&#xA;" OwnerUserId="1145" LastEditorUserId="467" LastEditDate="2015-10-06T19:44:43.710" LastActivityDate="2015-10-06T19:44:43.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4947" PostTypeId="1" AcceptedAnswerId="4950" CreationDate="2015-10-01T15:31:07.580" Score="5" ViewCount="760" Body="&lt;p&gt;According to &lt;code&gt;:help strpart()&lt;/code&gt;, the parameters &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;len&lt;/code&gt; are bytes, not characters, so that &lt;a href=&quot;https://i.stack.imgur.com/zCKWh.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zCKWh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;returns a string of 2 characters, starting with the letter &lt;em&gt;Beth&lt;/em&gt;. What I'd like to have is a function, that I can pass a hebrew (or any other multibyte character string) and not have byte semantics but character semantics, so that with the parameters &lt;code&gt;2&lt;/code&gt; and &lt;code&gt;4&lt;/code&gt; I am returned a four character string starting with the letter &lt;em&gt;Gimmel&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please excuse that I am posting a picture, but when I tried to copy paste my example, the left to right/right to left handling of the stackexchange-editor got into my way.&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="985" LastEditDate="2015-10-01T15:45:56.970" LastActivityDate="2016-12-29T11:40:54.670" Title="Is there a version of &quot;strpart&quot; that is aware of characters, rather than bytes" Tags="|vimscript|unicode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4948" PostTypeId="2" ParentId="4938" CreationDate="2015-10-01T15:39:53.613" Score="1" Body="&lt;p&gt;Many Vims provide support for some scripting languages (Perl, Ruby, Python). if your vim has Perl support (some distributions don't provide it) you can use&#xA;&lt;code&gt;:perl perl-command&lt;/code&gt; and &lt;code&gt;:perldo perl-command&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the following we are going to count the curly brackets level (&lt;code&gt;c&lt;/code&gt;) and add it to each &lt;code&gt;&amp;amp;&lt;/code&gt; (&lt;code&gt;&amp;amp;-c&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:perl $a{'{'}=1; $a{'}'}=-1; $c=0&#xA;:perldo s/([{}&amp;amp;])/if($1 eq '&amp;amp;'){&quot;$1-$c&quot;}else{$c += $a{$1}; &quot;$1&quot;}/ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;1) initialization of &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;a&lt;/code&gt; ( curly brackets delta)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) (using perl &lt;code&gt;s/regexp/perl-exp/eval&lt;/code&gt;),&lt;br&gt; &#xA;...for each occurence of &lt;code&gt;{&lt;/code&gt; &lt;code&gt;}&lt;/code&gt; recalculate &lt;code&gt;c&lt;/code&gt;; for each &lt;code&gt;&amp;amp;&lt;/code&gt;, show &lt;code&gt;c&lt;/code&gt;.&#xA;We get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\left| {E\left( {X|A} \right)} \right| &amp;amp;-0 =  \left| {E\left( {{q_2}|{q_1} &amp;lt;&#xA;{q_2}  &amp;lt;  {q_3}  &amp;lt;  {q_4}} \right)} \right| &amp;amp;-0 =  \frac{{\left| {E\left(&#xA;{{q_2}{I_{{q_1} &amp;amp;-6 &amp;lt;  {q_2} &amp;amp;-6 &amp;lt;  {q_3} &amp;amp;-6 &amp;lt;  {q_4}}}} \right)} &#xA;\right|}}{{P\left( A \right)}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now it is easy to see what are the &quot;bad &lt;code&gt;&amp;amp;&lt;/code&gt;&quot; (&lt;code&gt;s/&amp;amp;-[^0]/BAD_ones/g&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="3002" LastActivityDate="2015-10-01T15:39:53.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4949" PostTypeId="2" ParentId="4944" CreationDate="2015-10-01T15:44:17.907" Score="12" Body="&lt;p&gt;Your solution is very elegant! An alternative if you are in Unix based env:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!!rev&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3002" LastActivityDate="2015-10-01T15:44:17.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4950" PostTypeId="2" ParentId="4947" CreationDate="2015-10-01T15:53:07.087" Score="5" Body="&lt;p&gt;Something like this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Strpartw(src, start, ...)&#xA;    return a:0 ?&#xA;        \ join(split(a:src, '.\zs')[a:start : (a:start + a:1 - 1)], '') :&#xA;        \ join(split(a:src, '.\zs')[a:start :], '')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-10-01T15:53:07.087" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4951" PostTypeId="1" AcceptedAnswerId="5107" CreationDate="2015-10-01T16:14:45.613" Score="5" ViewCount="603" Body="&lt;h1&gt;Update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I've now also tried this on my Arch setup and everything works fine there.&lt;br&gt;&#xA;&lt;code&gt;vim --version&lt;/code&gt; on that machine says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep 28 2015 08:49:36)&#xA;Included patches: 1-884&#xA;Compiled by Arch Linux&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;-clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   +perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python          +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      +lua             +rightleft       +windows&#xA;+diff            +menu            +ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            +mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;   system vimrc file: &quot;/etc/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim        -lm -lncurses -lelf -lnsl   -lacl -lattr -lgpm -ldl  -L/usr/lib -llua -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic   -lruby -lpthread -lgmp -ldl -lcrypt -lm  -L/usr/lib&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Original Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I'm having problems with both NERDTree and CtrlP after upgrading to Vim 7.4. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;CtrlP can't find any entries in some folders and NERDTree doesn't display all content of all folders. I've had none of these problems before upgrading. I have the same problem when testing &lt;a href=&quot;https://github.com/szw/vim-ctrlspace&quot; rel=&quot;nofollow&quot;&gt;ctrlspace&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that the problem is that the path have Swedish characters (å, ä, ö) in it. Though this weren't a problem before upgrading from the built-in Vim in OS X (El Capitan). If I rename the folders in the path so that there are no such characters, then I don't have the problem anymore.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Try the following path while standing in &lt;code&gt;åäö&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;åäö/foo/bar:&#xA;&#xA;baz.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;vim.rc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; -------- Vundle -------&#xA;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'kien/ctrlp.vim'&#xA;Plugin 'scrooloose/nerdtree'&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I upgraded using &lt;code&gt;brew install vim&lt;/code&gt; and this is what &lt;code&gt;vim --version&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct  1 2015 17:36:26)&#xA;MacOS X (unix) version&#xA;Included patches: 1-884&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         -gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;+clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   +perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python          +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            +ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            +mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        -mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -F/usr/local/Frameworks -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.11 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: /usr/bin/clang   -L. -L/usr/local/lib -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -F/private/tmp/vim20151001-44506-3ot6hp/vim-7.4.884/Frameworks -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python   -lruby.2.0.0 -lobjc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4722" LastEditorUserId="4722" LastEditDate="2015-10-09T21:53:51.793" LastActivityDate="2015-10-14T15:23:47.373" Title="Problems with paths that includes swedish characters" Tags="|plugin-nerdtree|macos|plugin-ctrlp|version|" AnswerCount="1" CommentCount="10" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4952" PostTypeId="2" ParentId="4847" CreationDate="2015-10-01T17:23:10.690" Score="3" Body="&lt;p&gt;A possible solution is to create a function to do that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddLine()&#xA;&#xA;    let l:res = 0&#xA;    g/export PATH=\~\/.composer\/vendor\/bin:\\\$PATH/let l:res = l:res+1&#xA;&#xA;    if (l:res == 0)&#xA;        normal G&#xA;        normal oexport PATH=~/.composer/vendor/bin:\$PATH&#xA;    endif&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First we create a local variable &lt;code&gt;l:res&lt;/code&gt; which will be used to count the number of occurrences of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We use the &lt;code&gt;global&lt;/code&gt; command: each time the line is matched, &lt;code&gt;l:res&lt;/code&gt; is incremented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally if &lt;code&gt;l:res&lt;/code&gt; is still 0 it means that the line doesn't appear in the file so we go to the last line thanks to &lt;code&gt;G&lt;/code&gt;, and we create a new line with &lt;code&gt;o&lt;/code&gt; on which we write the line to add.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 1&lt;/strong&gt; The method I used to set the value of &lt;code&gt;l:res&lt;/code&gt; is a little bit heavy and could be replaced by the one suggested by @Alex in &lt;a href=&quot;https://vi.stackexchange.com/a/4946/1841&quot;&gt;his answer&lt;/a&gt; with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:res = search('export PATH=\~\/.composer\/vendor\/bin:\\\$PATH')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 2&lt;/strong&gt; Also to make the function more flexible you can use arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddLine(line)&#xA;&#xA;    let l:line =  escape(a:line, &quot;/~$&quot; )&#xA;&#xA;    let l:res = 0&#xA;    exe &quot;g/&quot; . l:line . &quot;/let l:res = l:res+1&quot;&#xA;&#xA;    if (l:res == 0)&#xA;        normal G&#xA;        exe &quot;normal o&quot; . a:line&#xA;    endif&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Note the trick with &lt;code&gt;escape()&lt;/code&gt; to add a &lt;code&gt;\&lt;/code&gt; in front of the characters which might cause a problem in the search.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Note also that you'll still have to escape the &lt;code&gt;\&lt;/code&gt; by yourself when calling the function (I didn't manage to escape &lt;code&gt;\&lt;/code&gt; automatically):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call AddLine(&quot;export PATH=~/.composer/vendor/bin:\\$PATH&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-10-01T18:04:29.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4953" PostTypeId="2" ParentId="4947" CreationDate="2015-10-01T22:52:37.073" Score="3" Body="&lt;p&gt;In &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-vim-lib&lt;/a&gt;, I'm doing it this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('*strcharpart')&#xA;  function! lh#encoding#strpart(mb_string, p, l)&#xA;    &quot; If we want a narrow contract&#xA;    &quot; call lh#assert#value(lh#encoding#strlen(a:mb_string)).is_ge(a:p+a:l)&#xA;    return strcharpart(a:mb_string, a:p, a:l)&#xA;  endfunction&#xA;else&#xA;  function! lh#encoding#strpart(mb_string, p, l)&#xA;    &quot; If we want a narrow contract&#xA;    &quot; call lh#assert#value(lh#encoding#strlen(a:mb_string)).is_ge(a:p+a:l)&#xA;    return matchstr(a:mb_string, '.\{,'.a:l.'}', 0, a:p+1)&#xA;  endfunction&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is that regex functions treat &lt;code&gt;.&lt;/code&gt; as a character and not as a byte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll also find a &lt;code&gt;strlen()&lt;/code&gt; implementation and a &lt;code&gt;at()&lt;/code&gt; function, but you should be able to do everything you wish with &lt;code&gt;matchstr()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that since recent Vim versions, we can use &lt;code&gt;strcharpart()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-12-29T11:40:54.670" LastActivityDate="2016-12-29T11:40:54.670" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4954" PostTypeId="1" CreationDate="2015-10-01T23:41:37.727" Score="1" ViewCount="70" Body="&lt;p&gt;I've just learnt how to run perl commands within vi, but I had to install vim.gtk in order to have perl support.     But I want to incorporate these perl commands into bash scripts that call ex.  Is there a version of ex that has perl support?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="4667" LastActivityDate="2015-10-01T23:41:37.727" Title="using ex with perl support" Tags="|ex-command|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4955" PostTypeId="1" CreationDate="2015-10-02T01:38:06.103" Score="24" ViewCount="27889" Body="&lt;p&gt;After generating a tags file with &lt;code&gt;exuberant-ctags&lt;/code&gt; I can jump from a function call to its declaration with &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; which is pretty convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how to do it in the other way? When my cursor is on the definition of a function, how can I go to the lines where the function is called?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I look to the file generated by ctags I only see informations related to the location of the definition and not of the calls, does it means that I can't do that, that Vim as a clever workaround or that I need to use something else than &lt;code&gt;exuberant-ctags&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2021-09-22T09:46:00.140" Title="How to jump to function call?" Tags="|ctags|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4956" PostTypeId="2" ParentId="4955" CreationDate="2015-10-02T05:14:13.697" Score="9" Body="&lt;p&gt;You can't do that with ctags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try a beefier alternative like &lt;a href=&quot;http://cscope.sourceforge.net/&quot;&gt;cscope&lt;/a&gt; (which even has its own help section: &lt;code&gt;:help cscope&lt;/code&gt;) or &lt;a href=&quot;http://www.gnu.org/software/global/&quot;&gt;global&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-10-02T05:14:13.697" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4957" PostTypeId="2" ParentId="4955" CreationDate="2015-10-02T05:22:22.190" Score="15" Body="&lt;p&gt;You can't jump to function calls with &lt;code&gt;ctags&lt;/code&gt;.  For C/C++ and Java there is &lt;a href=&quot;http://cscope.sourceforge.net/&quot;&gt;&lt;code&gt;cscope&lt;/code&gt;&lt;/a&gt;, and it integrates nicely with Vim (see &lt;a href=&quot;http://vimhelp.appspot.com/if_cscop.txt.html&quot;&gt;&lt;code&gt;:help cscope&lt;/code&gt;&lt;/a&gt;).  For other languages you might be able to find a tool that generates / exports &lt;code&gt;cscope&lt;/code&gt;-compatible databases (f.i. &lt;a href=&quot;https://github.com/bosu/hscope&quot;&gt;&lt;code&gt;hscope&lt;/code&gt;&lt;/a&gt; for Haskell, and &lt;a href=&quot;https://github.com/eapache/starscope/&quot;&gt;&lt;code&gt;starscope&lt;/code&gt;&lt;/a&gt; for Ruby, Go, and JavaScript).  You can also use &lt;code&gt;cscope&lt;/code&gt; with &lt;a href=&quot;http://www.gnu.org/software/global/&quot;&gt;GNU global&lt;/a&gt; databases, by pointing &lt;code&gt;cscopeprg&lt;/code&gt; to &lt;code&gt;gtags-cscope&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a side note: if you aren't put off by occasionally puzzling use of &lt;a href=&quot;https://en.wikipedia.org/wiki/Engrish&quot;&gt;Engrish&lt;/a&gt;, ;) you probably also want to use &lt;a href=&quot;https://github.com/universal-ctags/ctags&quot;&gt;universal-ctags&lt;/a&gt; instead of &lt;code&gt;exuberant-ctags&lt;/code&gt;.  The latter hasn't been updated in years.  The former is an actively maintained fork.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="2313" LastEditDate="2015-10-02T16:50:27.590" LastActivityDate="2015-10-02T16:50:27.590" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4958" PostTypeId="2" ParentId="4847" CreationDate="2015-10-02T10:53:06.417" Score="1" Body="&lt;p&gt;In order to simplify and avoid the presence of many &lt;code&gt;\&lt;/code&gt;, the line to be added will be &lt;code&gt;export PATH=mybin:PATH&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Main strategy: substitute the &quot;non-&lt;code&gt;mybin&lt;/code&gt;&quot; text (all  file) with text+mybin-path-definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; vim  +'s#\v%^((.|\n)(mybin:)@!)*%$#&amp;amp;\rexport PATH=mybin:PATH#e' -cx bashrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or with &lt;em&gt;more didactic indentation&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s#                                    substitute&#xA;   \v                                  very magical to redude \&#xA;&#xA;   %^                                  file begin&#xA;   ((.|\n)(mybin:)@!)*                 multi-line str without &quot;mybin:&quot;&#xA;                                         (any char not followed by &quot;mybin&quot;)*&#xA;   %$                                  end of file&#xA; #                                    by&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If we have a match:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;&lt;/code&gt; has the full text of &lt;code&gt;bashrc&lt;/code&gt; and &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;&lt;/code&gt; does not contain &lt;code&gt;/mybin:/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #                                    by ...&#xA;   &amp;amp;                                   all file&#xA;   export PATH=mybin:PATH              and the new path&#xA; #e                                   don't complain if patt not found&#xA;&#xA;-cx                                   save and leave &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: Finally, we can make a vim script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat bashrcfix&#xA;&#xA;#!/usr/bin/vim -s&#xA;:e ~/fakebashrc&#xA;:s#\v%^((.|\n)(mybin:)@!)*%$#&amp;amp;\rexport PATH=mybin:PATH#e&#xA;:x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;chmod 755 and install it. Usage: &lt;code&gt;bashrcfix&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;be careful: in &lt;code&gt;\v&lt;/code&gt; mode, &lt;code&gt;=&lt;/code&gt; means optional &lt;/p&gt;&#xA;" OwnerUserId="3002" LastEditorUserId="3002" LastEditDate="2015-10-05T11:01:16.413" LastActivityDate="2015-10-05T11:01:16.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4959" PostTypeId="1" CreationDate="2015-10-02T10:54:46.717" Score="2" ViewCount="305" Body="&lt;p&gt;Just installed vim and vimified plugin set under cygwin. Everything works like a charm except one annoying issue - i can see some special symbols (like new line) and it seems that some characters are shown in wrong way, for example the automatically inserted by VIM newline symbol is replaced with a box.&#xA;I am using mintty, the locale is en_US.UTF8, the same is listed under mintty configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any suggestions?&#xA;Thanks.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Ol5lg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ol5lg.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4730" LastActivityDate="2015-10-02T10:54:46.717" Title="VIM under Cygwin some characters missing" Tags="|encoding|cygwin|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4961" PostTypeId="2" ParentId="4847" CreationDate="2015-10-02T13:48:22.480" Score="2" Body="&lt;p&gt;Most of these answers seem complicated how about good old shell commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;grep composer/vender ~/.bashrc || cat &amp;gt;&amp;gt; ~/.bashrc &amp;lt;&amp;lt;EOF&#xA;export PATH=~/.composer/vendor/bin:\$PATH&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This could easily be a Bash function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;addBashrcPath() {&#xA;  if ! grep &quot;$1&quot; ~/.bashrc &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&#xA;    printf 'export PATH=%s:$PATH' &quot;$1&quot; &amp;gt;&amp;gt; ~/.bashrc&#xA;  fi&#xA;}&#xA;&#xA;addBashrcPath &quot;~/.composer/vendor/bin&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: The exit code of grep is important and in this case it needs to be reversed use &lt;code&gt;! grep&lt;/code&gt;; &lt;code&gt;grep -v&lt;/code&gt; will not exit as expected in this situation. Thanks you @joeytwiddle for the tip.&lt;/p&gt;&#xA;" OwnerUserId="544" LastEditorUserId="544" LastEditDate="2015-10-05T13:38:28.493" LastActivityDate="2015-10-05T13:38:28.493" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4962" PostTypeId="1" AcceptedAnswerId="4967" CreationDate="2015-10-02T15:48:45.547" Score="4" ViewCount="454" Body="&lt;p&gt;Say I do a regex search for a class of characters, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/[clsktb]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;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?&lt;/p&gt;&#xA;" OwnerUserId="411" LastActivityDate="2015-10-05T13:22:52.377" Title="Find number of regex matches per line" Tags="|regular-expression|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4964" PostTypeId="2" ParentId="4962" CreationDate="2015-10-02T17:13:07.553" Score="1" Body="&lt;p&gt;Many Vims provide support for some scripting languages (Perl, Ruby, Python). If your vim has Perl support (some distributions don't provide it) you can use &lt;code&gt;:perl perl-command&lt;/code&gt; and &lt;code&gt;:perldo perl-command&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:perldo   $_ = y/clsktb// . &quot; :: $_&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Perl's &lt;code&gt;y///&lt;/code&gt; returns the number of occurrences of the chars in the default string (&lt;code&gt;$_&lt;/code&gt;). The new $_ is concatenation of that number followed by &quot; :: &quot; and the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;\thanks{EvergreenTree}&lt;/p&gt;&#xA;" OwnerUserId="3002" LastEditorUserId="3002" LastEditDate="2015-10-05T13:22:52.377" LastActivityDate="2015-10-05T13:22:52.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4965" PostTypeId="2" ParentId="4962" CreationDate="2015-10-02T17:26:27.733" Score="2" Body="&lt;p&gt;&lt;strong&gt;If&lt;/strong&gt; you must (using a  Vim &lt;em&gt;linked sausage&lt;/em&gt; command):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sign unplace *&#xA;:g/^/ let n = 0 | let c = -1 | while c != 0 | let c = search('[-]', '', line('.')) | let n = n + 1 | endwhile | if n &amp;gt; 1 | exe 'sign define ' . n . ' text=' . (n-1) | exe 'sign place ' . n . ' line=' . line('.') . ' name=' . n . ' file=' . expand('%:p') | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-10-02T17:37:00.517" LastActivityDate="2015-10-02T17:37:00.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4966" PostTypeId="1" CreationDate="2015-10-02T17:40:02.443" Score="1" ViewCount="94" Body="&lt;p&gt;After &lt;code&gt;:Abolish tits that is to say&lt;/code&gt;, and &lt;code&gt;tits&lt;/code&gt;, I get &lt;code&gt;* that is to say&lt;/code&gt; with a star in front of it. This happens only when vim-latex is loaded and in .tex files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. The problem seems to lie somewhere in &lt;code&gt;vim-latex/plugin/imaps.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2015-10-02T20:28:45.073" LastActivityDate="2015-10-02T20:28:45.073" Title="Plugin conflict: vim-latex and abolish" Tags="|plugin-vim-latex|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4967" PostTypeId="2" ParentId="4962" CreationDate="2015-10-02T17:41:05.920" Score="8" Body="&lt;p&gt;Here is a variation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^/\=len(split(getline('.'), '[clsktb]\zs')).' '/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;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.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-10-02T17:56:47.107" LastActivityDate="2015-10-02T17:56:47.107" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4968" PostTypeId="1" AcceptedAnswerId="5106" CreationDate="2015-10-02T20:51:54.880" Score="5" ViewCount="1327" Body="&lt;p&gt;I am new to vim, and I use netrw as a file explorer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Frequently hit shift-P to open a file in a buffer.  Sometimes I accidentally hit &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#netrw-O&quot; rel=&quot;nofollow noreferrer&quot;&gt;shift-O&lt;/a&gt;, and netrw will start obtaining the file.  How do I cancel cancel that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two changes I see happen are a new split opens with the below message&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;warning&lt;/strong&gt; (netrw) cannot determine method (format: protocol://[user@]hostname[:port]/[path])&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which I can close.&#xA;But also I see a message in the status/message bar.  What I really want to do is get rid of that message: &lt;strong&gt;Obtaining index.html&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2tP6q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2tP6q.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above documentation, suggests that the message will end when the transfer completes.  So maybe I need to cancel the transfer.  I scanned/searched the above documentation for the words cancel and transfer and found nothing to suggest a fix.&lt;/p&gt;&#xA;" OwnerUserId="3241" LastEditorUserId="3241" LastEditDate="2015-10-12T13:48:25.420" LastActivityDate="2015-11-20T22:15:00.040" Title="How can I stop 'Obtaining &lt;filename&gt;'?" Tags="|netrw|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4969" PostTypeId="1" AcceptedAnswerId="4971" CreationDate="2015-10-03T00:58:42.743" Score="7" ViewCount="1830" Body="&lt;p&gt;What is the &lt;code&gt;~/.vim&lt;/code&gt; file used for, if anything, other than plugins? Is it part of Vim, or was it &amp;quot;invented&amp;quot; by plugin managers like Vundle?&lt;/p&gt;&#xA;" OwnerUserId="4674" LastEditorUserId="5864" LastEditDate="2021-01-26T17:24:58.433" LastActivityDate="2021-01-26T17:24:58.433" Title="Is the ~/.vim directory used for anything other than plugins?" Tags="|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4970" PostTypeId="2" ParentId="4969" CreationDate="2015-10-03T07:11:41.743" Score="5" Body="&lt;p&gt;It's an optional part of Vim proper and predated the plugin managers. It can be used for plugins you write yourself, for plugins you get from others, and to augment or replace Vim's standard plugins. I didn't find a primary place in the documentation where its use is discussed, but you can find a number of examples by executing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helpgrep /\.vim\&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It can also be used for your own &lt;code&gt;filetype.vim&lt;/code&gt; file to add the recognition of filetypes or filename suffixes not recognized by Vim's &lt;code&gt;$VIMRUNTIME/filetype.vim&lt;/code&gt;. Recent versions of Vim also look there for a file named &lt;code&gt;vimrc&lt;/code&gt; if &lt;code&gt;~/.vimrc&lt;/code&gt; does not exist, allowing you to keep all your Vim configuration files in that directory.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-10-03T07:11:41.743" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4971" PostTypeId="2" ParentId="4969" CreationDate="2015-10-03T07:18:24.730" Score="7" Body="&lt;p&gt;I don't have conclusive evidence, but:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;.vim&lt;/code&gt; is one of the default values of &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27runtimepath%27&quot;&gt;&lt;code&gt;'runtimepath'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                'runtimepath' 'rtp' vimfiles&#xA;'runtimepath' 'rtp'     string  (default:&#xA;                                        Unix: &quot;$HOME/.vim,&#xA;                                                $VIM/vimfiles,&#xA;                                                $VIMRUNTIME,&#xA;                                                $VIM/vimfiles/after,&#xA;                                                $HOME/.vim/after&quot;&#xA;...&#xA;    This is a list of directories which will be searched for runtime&#xA;    files:&#xA;      filetype.vim  filetypes by file name new-filetype&#xA;      scripts.vim   filetypes by file contents new-filetype-scripts&#xA;      autoload/     automatically loaded scripts autoload-functions&#xA;      colors/       color scheme files :colorscheme&#xA;      compiler/     compiler files :compiler&#xA;      doc/          documentation write-local-help&#xA;      ftplugin/     filetype plugins write-filetype-plugin&#xA;      indent/       indent scripts indent-expression&#xA;      keymap/       key mapping files mbyte-keymap&#xA;      lang/         menu translations :menutrans&#xA;      menu.vim      GUI menus menu.vim&#xA;      plugin/       plugin scripts write-plugin&#xA;      print/        files for printing postscript-print-encoding&#xA;      spell/        spell checking files spell&#xA;      syntax/       syntax files mysyntaxfile&#xA;      tutor/        files for vimtutor tutor&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I think &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2332&quot;&gt;Pathogen&lt;/a&gt; was one of the first plugins to allow you to easily install plugins in other directories&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Even its &lt;a href=&quot;http://www.vim.org/scripts/download_script.php?src_id=9085&quot;&gt;first release&lt;/a&gt; used &lt;code&gt;~/.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; pathogen.vim - path option manipulation&#xA;&quot; Maintainer:   Tim Pope&#xA;&quot; Last Change:  Apr 26, 2008&#xA;&#xA;&quot; Install in ~/.vim/autoload (or ~\vimfiles\autoload).&#xA;&quot;&#xA;&quot; API is documented below.&#xA;&#xA;if exists(&quot;g:loaded_pathogen&quot;) || &amp;amp;cp&#xA;  finish&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;runtimepath&lt;/code&gt; support was introduced in, or before, 2008. From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/version6.html&quot;&gt;&lt;code&gt;version6.txt&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*version6.txt*  For Vim version 7.3.  Last change: 2008 Aug 06&#xA;&#xA;...&#xA;&#xA;Plugin support                  *new-plugins*&#xA;&#xA;To make it really easy to load a Vim script when starting Vim, the &quot;plugin&quot;&#xA;runtime directory can be used.  All &quot;*.vim&quot; files in it will be automatically&#xA;loaded.  For Unix, the directory &quot;~/.vim/plugin&quot; is used by default.  The&#xA;'runtimepath' option can be set to look in other directories for plugins.&#xA;|load-plugins| |add-plugin|&#xA;&#xA;The |:runtime| command has been added to load one or more files in&#xA;'runtimepath'.&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Vim 6.2 makes use of &lt;code&gt;runtimepath&lt;/code&gt;, adding support for the &lt;code&gt;ftplugin&lt;/code&gt; directory. See &lt;a href=&quot;http://ftp.vim.org/pub/vim/patches/6.2.073&quot;&gt;patch 6.2.073&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*** ../vim-6.2.072/runtime/doc/filetype.txt Sun Jun  1 12:20:32 2003&#xA;--- runtime/doc/filetype.txt    Thu Aug 14 11:22:30 2003&#xA;***************&#xA;*** 1,4 ****&#xA;! *filetype.txt*  For Vim version 6.2.  Last change: 2003 Apr 25&#xA;&#xA;&#xA;          VIM REFERENCE MANUAL    by Bram Moolenaar&#xA;--- 1,4 ----&#xA;! *filetype.txt*  For Vim version 6.2.  Last change: 2003 Aug 14&#xA;&#xA;&#xA;          VIM REFERENCE MANUAL    by Bram Moolenaar&#xA;***************&#xA;*** 147,157 ****&#xA;  This means that the contents of compressed files are not inspected.&#xA;&#xA;                            *new-filetype*&#xA;! If a file type that you want to use is not detected yet, there are two ways to&#xA;! add it.  In any way, it's better not modify the $VIMRUNTIME/filetype.vim file.&#xA;! It will be overwritten when installing a new version of Vim.&#xA;&#xA;! A. If your file type can be detected by the file name.&#xA;     1. Create your user runtime directory.  You would normally use the first&#xA;        item of the 'runtimepath' option.  Example for Unix: &amp;gt;&#xA;    :!mkdir ~/.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;runtimepath&lt;/code&gt; has been in use since at least 2003, well before Pathogen was released. We can safely conclude its invention predated Vundle and similar plugins. (Though it could have been invented by someone who wanted to make using plugins easier.) And its use was definitely making user-level extensions to functionality easier, by allowing one to drop files in various directories to easily affect Vim behaviour.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-10-03T07:49:42.930" LastActivityDate="2015-10-03T07:49:42.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4972" PostTypeId="1" AcceptedAnswerId="4973" CreationDate="2015-10-03T12:52:08.167" Score="3" ViewCount="534" Body="&lt;p&gt;I am struggling combining a negative lookahead assertion &lt;code&gt;@!&lt;/code&gt; with the very magic specifier &lt;code&gt;\v&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a buffer with this content&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div class='vvv'&amp;gt;abc&amp;lt;/div&amp;gt;&#xA;&amp;lt;div class='ttt'&amp;gt;abc&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to search for all classes except vvv. I can do this like so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/class=.\(vvv\)\@!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This finds the second line (&lt;code&gt;class='ttt'&lt;/code&gt;), as expected. Yet, when I try to search with the &lt;em&gt;very magic&lt;/em&gt; modifier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\vclass=.(vvv)@!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the search finds both classes. I had wrongly assumed these searches to be equivalent. Why are they different?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="985" LastEditDate="2015-10-03T13:06:14.313" LastActivityDate="2015-10-04T10:51:59.527" Title="negative lookahead (@!) together with very magic \v" Tags="|regular-expression|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4973" PostTypeId="2" ParentId="4972" CreationDate="2015-10-04T09:45:33.127" Score="4" Body="&lt;p&gt;The code you wrote is perfect but in &lt;code&gt;\v&lt;/code&gt; mode &lt;code&gt;=&lt;/code&gt; needs protection.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\vclass\='(ttt)@!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In normal mode &lt;code&gt;\=&lt;/code&gt; means &lt;em&gt;optional&lt;/em&gt; (the same as &lt;code&gt;\?&lt;/code&gt;). In &#xA;&lt;code&gt;\v&lt;/code&gt; mode, &lt;code&gt;=&lt;/code&gt; means optional: &lt;code&gt;class=&lt;/code&gt; ends up meaning &lt;code&gt;class|clas&lt;/code&gt; (I would prefer &lt;code&gt;=&lt;/code&gt; were just a normal char).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to mark the classes different form &lt;code&gt;ttt&lt;/code&gt; we can:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\vclass\='(ttt)@!.{-}'/MARKED&amp;amp;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When we have more complex &quot;different-from&quot; patterns it may be easier the long way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\vclass\='(tt1|...)'/classAUX=\1/          rename exceptions&#xA;:%s/\vclass\='.{-}'/MARKED&amp;amp;/                   treat normal cases&#xA;:%s/\vclassAUX/class/                          unrename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;\thanks{Peter Lewerin}&lt;/p&gt;&#xA;" OwnerUserId="3002" LastEditorUserId="3002" LastEditDate="2015-10-04T10:51:59.527" LastActivityDate="2015-10-04T10:51:59.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4974" PostTypeId="1" CreationDate="2015-10-04T11:55:03.707" Score="6" ViewCount="108" Body="&lt;p&gt;If I copy text into the xterm clipboard (&lt;code&gt;&quot;+y&lt;/code&gt;) from gvim, it is cleared when I exit gvim.&lt;br&gt;&#xA;How do I prevent this?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found the solution for vim, but it doesn't work for &lt;strong&gt;Gvim&lt;/strong&gt;:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimLeave * call system(&quot;echo -n $'&quot; . escape(getreg(), &quot;'&quot;) . &quot;' | xsel -ib&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://superuser.com/questions/299419/prevent-vim-from-clearing-the-clipboard-on-exit&quot;&gt;https://superuser.com/questions/299419/prevent-vim-from-clearing-the-clipboard-on-exit&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4753" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2015-12-17T14:40:13.780" Title="Prevent gvim from clearing the clipboard on exit" Tags="|cut-copy-paste|gvim|os-clipboard|x11|" AnswerCount="0" CommentCount="2" ClosedDate="2015-12-17T14:42:04.213" ContentLicense="CC BY-SA 3.0" />
  <row Id="4975" PostTypeId="1" AcceptedAnswerId="10815" CreationDate="2015-10-04T13:23:51.433" Score="22" ViewCount="14723" Body="&lt;p&gt;I installed gvim on both Fedora and Win7. I found that both vim and gvim on Fedora didn't highlight the function name in c code while gvim on win7 did highlight it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that on win7, &lt;code&gt;vim73/syntax/c.vim&lt;/code&gt; has the additional lines at the end:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match cFunction &quot;\&amp;lt;[a-zA-Z_][a-zA-Z_0-9]*\&amp;gt;[^()]*)(&quot;me=e-2 &#xA;syn match cFunction &quot;\&amp;lt;[a-zA-Z_][a-zA-Z_0-9]*\&amp;gt;\s*(&quot;me=e-1 &#xA;hi cFunction gui=NONE guifg=#B5A1FF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I add these lines into the &lt;code&gt;c.vim&lt;/code&gt; on Fedora, gvim can highlight the function name, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To maintain the portability, I want to just modify the &lt;code&gt;.vimrc&lt;/code&gt; to highlight the function name. However after adding these lines into the &lt;code&gt;.vimrc&lt;/code&gt;, it didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, can anyone help me? I did a search and there are many solutions to highlight the function names in vim. But I am just curious about how to make these lines work in &lt;code&gt;.vimrc&lt;/code&gt;. Thanks very much!&lt;/p&gt;&#xA;" OwnerUserId="4754" LastEditorUserId="51" LastEditDate="2017-01-02T05:03:15.863" LastActivityDate="2018-08-22T10:47:54.917" Title="How can I add additional syntax highlighting rules in my local vimrc?" Tags="|vimrc|syntax-highlighting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4976" PostTypeId="2" ParentId="4955" CreationDate="2015-10-04T21:25:05.820" Score="9" Body="&lt;p&gt;You could use Vim's &lt;strong&gt;grep&lt;/strong&gt; command to search all the files in your project:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:grep! &amp;quot;\&amp;lt;&amp;lt;cword&amp;gt;\&amp;gt;&amp;quot; . -r&#xA;:copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Let's put that in a keybind:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F4&amp;gt; :grep! &amp;quot;\&amp;lt;&amp;lt;cword&amp;gt;\&amp;gt;&amp;quot; . -r&amp;lt;CR&amp;gt;:copen&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I find this one-key project-wide search invaluable when I am exploring a large unfamiliar codebase.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; are regexp sequences which indicate the start and end of a word, so you won't get partial matches.  (The &lt;code&gt;-w&lt;/code&gt; option to grep might be another way to achieve this.)&lt;/p&gt;&#xA;&lt;p&gt;However, this is an &lt;strong&gt;unintelligent search&lt;/strong&gt;, so it can produce false-positives if the same word appears in unrelated contexts.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Truthfully, I use my own &lt;a href=&quot;https://github.com/joeytwiddle/grep.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;modified version of the grep.vim plugin&lt;/a&gt; instead. This is slightly friendlier to use:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It lets you edit the search pattern, and also the grep commandline (so you can target specific folders like &lt;code&gt;src/ lib/&lt;/code&gt; instead of &lt;code&gt;.&lt;/code&gt;) and remembers the changes.&lt;/li&gt;&#xA;&lt;li&gt;I added support for Google's &lt;a href=&quot;https://github.com/google/codesearch&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;csearch&lt;/strong&gt;&lt;/a&gt;.  This can be much faster than grep (on HDDs) because it builds an index of words rather than scanning each file every time.  Notably, csearch uses a slightly different regexp standard, so &lt;code&gt;\b&lt;/code&gt; must be used instead of &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I configure it and exclude some standard files &lt;a href=&quot;https://github.com/joeytwiddle/rc_files/blob/5e67249194407360d12f38e7f5b2f085937fd286/.vimrc#L147-L170&quot; rel=&quot;nofollow noreferrer&quot;&gt;like this&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For fast access, I create &lt;a href=&quot;https://github.com/joeytwiddle/rc_files/blob/5e67249194407360d12f38e7f5b2f085937fd286/.vim/plugin/joeykeymap.vim#L557-L592&quot; rel=&quot;nofollow noreferrer&quot;&gt;two keybinds&lt;/a&gt;.  &lt;kbd&gt;F3&lt;/kbd&gt; lets me edit the commandline, &lt;kbd&gt;F4&lt;/kbd&gt; uses the previously configured commandline without any extra keystrokes.  The mechanism is pretty ugly, and could use some cleanup, but it has served me well.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2021-09-22T09:46:00.140" LastActivityDate="2021-09-22T09:46:00.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4977" PostTypeId="1" AcceptedAnswerId="4978" CreationDate="2015-10-04T21:37:10.850" Score="3" ViewCount="250" Body="&lt;p&gt;I understand that when in insert mode the cursor is described as between characters, and when in normal mode the cursor is supposed to be on a valid character. I have been having a lot of trouble with this behavior recently. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I enter insert mode I will use &lt;code&gt;_&lt;/code&gt; to represent the cursor&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;and append some text to the end of a line_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I exit insert mode the cursor is dropped to the beginning of the line below it so I would end up here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;and append some text to the end of a line&#xA;_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This really breaks up my flow when I am typing and I would like to modify the behavior so that the cursor is instead left at the end of the line. Since there is no character there ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I know it wont just stay here_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I would prefer it if the cursor just moved to the character before when I exit insert mode &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;So I would end up her_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pretending there is an e at the end of that line and I have the cursor on it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know a way to achieve this? All of the documentation I have read suggests that this is the normal behavior anyway. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have remapped &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; to &lt;code&gt;jk&lt;/code&gt; but if I remove that from my &lt;code&gt;.vimrc&lt;/code&gt; I still en up at the beginning of the next line &lt;/p&gt;&#xA;" OwnerUserId="4692" LastActivityDate="2015-10-05T00:47:48.377" Title="cursor behavior when exiting &lt;insert&gt; mode" Tags="|insert-mode|cursor|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4978" PostTypeId="2" ParentId="4977" CreationDate="2015-10-05T00:47:48.377" Score="4" Body="&lt;p&gt;Thanks to the comment by @muru I was able to figure this out. I turns out in my &lt;code&gt;.vimrc&lt;/code&gt; I had this line to remap &lt;code&gt;jk&lt;/code&gt; to &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap jk &amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but there was a &lt;code&gt;space&lt;/code&gt; inserted at the end of the line. If I remove the space the problem is fixed. I did not realize that white space characters were important when making these customization. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;a href=&quot;http://www.badassvim.com/how-to-remap-keys-in-vim/&quot; rel=&quot;nofollow&quot;&gt;blog&lt;/a&gt; pointed out that any characters used (even white-space) when remapping commands were interpreted.  &lt;/p&gt;&#xA;" OwnerUserId="4692" LastActivityDate="2015-10-05T00:47:48.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4979" PostTypeId="2" ParentId="4867" CreationDate="2015-10-05T01:35:25.243" Score="1" Body="&lt;p&gt;I followed instructions as described at &lt;a href=&quot;https://github.com/vim-scripts/polytonic.utf-8.spl&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;. This is the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BFDFg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BFDFg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only way I could reproduce the behaviour mentioned previously was when I haven't &lt;code&gt;set spell&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;  but tried to enable spelling in open Vim through command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So maybe that is what is missing. Another possible explanation may be that there is an error in your file, so try to download it from github, and set it again.&lt;/p&gt;&#xA;" OwnerUserId="2961" LastActivityDate="2015-10-05T01:35:25.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4981" PostTypeId="1" AcceptedAnswerId="4982" CreationDate="2015-10-05T18:45:20.623" Score="3" ViewCount="125" Body="&lt;p&gt;I'd like to be able to create the commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap oo o&#xA;nmap oi o&amp;lt;Esc&amp;gt;&#xA;nmap OO O&#xA;nmap OI O&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the problem is that &lt;code&gt;o&lt;/code&gt; triggers immediately and the second character ends up in Insert mode. &lt;code&gt;nnoremap o &amp;lt;nop&amp;gt;&lt;/code&gt; doesn't fix things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I &quot;disable&quot; the &lt;code&gt;o&lt;/code&gt; command while still allowing it to be mapped?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously I could just use a leader mapping, but I figure I might as well try and go ham with it.&lt;/p&gt;&#xA;" OwnerUserId="4674" LastActivityDate="2015-10-05T20:35:01.013" Title="Can I disable a command while still allowing things to be mapped to it?" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4982" PostTypeId="2" ParentId="4981" CreationDate="2015-10-05T19:12:27.273" Score="3" Body="&lt;p&gt;You can run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap o &amp;lt;nop&amp;gt;&#xA;nnoremap oo o&#xA;nnoremap oi o&amp;lt;Esc&amp;gt;&#xA;nnoremap OO O&#xA;nnoremap OI O&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="350" LastActivityDate="2015-10-05T19:12:27.273" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4983" PostTypeId="1" CreationDate="2015-10-05T20:33:04.110" Score="5" ViewCount="113" Body="&lt;p&gt;I have a multiple file/folder project that looks like the following. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;├── 0_Preamble&#xA;│   ├── 01_TitlePage.tex&#xA;│   ├── 02_TitleBack.tex&#xA;│   ├── 03_Dedication.tex&#xA;│   ├── 0_Preamble.tex&#xA;├── 1_Theory&#xA;│   ├── 11_Problem.tex&#xA;│   ├── 12_RelatedWork.tex&#xA;│   ├── 1_Theory.tex&#xA;│   └── img&#xA;├── 2_Experimental&#xA;│   ├── 21_CodeStructure.tex&#xA;│   ├── 22_Data.tex&#xA;│   ├── 2_Experimental.tex&#xA;│   └── img&#xA;├── 3_Conclusion&#xA;│   ├── 31_PrincipalResults.tex&#xA;│   ├── 3_Conclusion.tex&#xA;│   └── img&#xA;├── _master.tex&#xA;├── _master.toc&#xA;├── _references.bib&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each folder has a main file with the same name where all the other files from that folder are included. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;code&gt;1_Theory.tex&lt;/code&gt; has the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\chapter{Theory Aspects}&#xA;\input{11_Problem.tex}&#xA;\input{12_RelatedWork.tex}&#xA;\input{13_OurApproach.tex}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The master file &lt;code&gt;_master.tex&lt;/code&gt; (which is the main file that is compilated) includes all the main folder files, this means:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{document}&#xA;\subimport{0_Preamble/}{0_Preamble.tex}&#xA;\cleardoublepage&#xA;\subimport{1_Theory/}{1_Theory.tex}&#xA;\cleardoublepage&#xA;\subimport{2_Experimental/}{2_Experimental.tex}&#xA;\cleardoublepage&#xA;\subimport{3_Conclusion/}{3_Conclusion.tex}&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've been trying to use the &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow&quot;&gt;vimtex&lt;/a&gt; plugin, which normally support multifiles project, as long as these are all included from the same main file (if I understood correcly from the docs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Anybody knows how to use it with a project like mine?&lt;/strong&gt; Another more suitable plugin is also an option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of all, I would like the auto-completion function to work (with labels, references, etc.).&lt;/p&gt;&#xA;" OwnerUserId="2977" LastEditorUserId="2977" LastEditDate="2015-10-06T13:46:28.970" LastActivityDate="2015-10-06T13:46:28.970" Title="Latex plugin for Vim that supports files organized in multiple directories" Tags="|filetype-tex|plugin-vim-latex|plugin-vimtex|plugin-latex-box|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4984" PostTypeId="2" ParentId="4981" CreationDate="2015-10-05T20:35:01.013" Score="3" Body="&lt;p&gt;I feel like you mappings are designed to create black lines.  This is &lt;a href=&quot;https://stackoverflow.com/q/2565531/438329&quot;&gt;a&lt;/a&gt; &lt;a href=&quot;https://stackoverflow.com/q/6765211/438329&quot;&gt;common&lt;/a&gt; &lt;a href=&quot;https://stackoverflow.com/q/16359878/438329&quot;&gt;task&lt;/a&gt; here are some quick mappings to put in your &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; [&amp;lt;space&amp;gt; :pu! _&amp;lt;cr&amp;gt;:']+1&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; ]&amp;lt;space&amp;gt; :pu _&amp;lt;cr&amp;gt;:'[-1&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you prefer a plugin then I suggest Tim Pope's &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1590&quot; rel=&quot;nofollow noreferrer&quot;&gt;unimpaired.vim&lt;/a&gt;. Which supplies these mappings, but will also take a count. The plugin also has many other nice mappings.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-10-05T20:35:01.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4985" PostTypeId="1" AcceptedAnswerId="4986" CreationDate="2015-10-05T21:17:09.407" Score="4" ViewCount="138" Body="&lt;p&gt;I can use &lt;code&gt;f&lt;/code&gt; or &lt;code&gt;F&lt;/code&gt; to highlight/change or jump to the next occurrence of say, a comma.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is way useful, but is there a way to highlight/change to the character just before?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Say I have some code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this.remove (object, index + 1, name)&#xA;                     ^ cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and want to replace the &lt;code&gt;index + 1&lt;/code&gt; with &lt;code&gt;location&lt;/code&gt;?  &lt;code&gt;cf,&lt;/code&gt; will require me to retype the comma &lt;code&gt;location,&lt;/code&gt; in my replacement text.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Is there a command already to do this, or how would I go about adding this to my Vim?&lt;/p&gt;&#xA;" OwnerUserId="2221" LastEditorUserId="2221" LastEditDate="2015-10-12T21:12:43.740" LastActivityDate="2015-10-12T21:12:43.740" Title="Jumping to *just before* the nth occurence?" Tags="|key-bindings|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4986" PostTypeId="2" ParentId="4985" CreationDate="2015-10-05T21:27:41.313" Score="9" Body="&lt;p&gt;You should have scrolled a bit when you read &lt;code&gt;:help f&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ct,&#xA;cT,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help t&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-10-05T21:37:11.127" LastActivityDate="2015-10-05T21:37:11.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4989" PostTypeId="1" CreationDate="2015-10-06T12:15:43.370" Score="2" ViewCount="496" Body="&lt;p&gt;I have setup my Vim Help to appear as a listed buffer for my ease of quick access and return to same page. The problem I face is that every time I jump around in Vim Help page using &lt;code&gt;Ctrl-]&lt;/code&gt; a new Vim-Help-page-buffer is created, which is not what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to disable Vim from creating a new buffer every time I jump to a hyperlinked page within Vim Help pages?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or else perhaps, is it possible to have the opening of a Vim-Help-hyperlinked-page to automatically trigger the deletion of the previous Vim-Help buffer? How could this be scripted?&lt;/p&gt;&#xA;" OwnerUserId="4617" LastEditorUserId="51" LastEditDate="2015-10-07T15:16:43.337" LastActivityDate="2015-10-07T15:16:43.337" Title="Is there a way to disable Vim from creating a new buffer every time I jump to a hyperlinked page within Vim Help pages?" Tags="|vimscript|buffers|help-system|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4990" PostTypeId="1" AcceptedAnswerId="4992" CreationDate="2015-10-06T13:12:31.610" Score="4" ViewCount="2519" Body="&lt;p&gt;I'm using vim a lot and I'm trying to optimize few movements I do with too much key pressed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For exemple I have this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;module SanitizeIdsParams&#xA;  def self.my_method ids&#xA;    ...code&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;module SanitizeIdsParams&#xA;  def self.my_method ids&#xA;    ...code&#xA;  end&#xA;&#xA;  def self.my_method ids&#xA;    ...code&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the moment I'm doing something like &lt;code&gt;j&amp;lt;CR&amp;gt;v3jy&amp;lt;ESC&amp;gt;4Go&amp;lt;ESC&amp;gt;p&lt;/code&gt; I'm not a huge fan of &lt;code&gt;:2,4t.4Go&amp;lt;ESC&amp;gt;&lt;/code&gt;, any other ideas without specifying exact line number ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know also if when I yank I can stay where I yank and not going at the beginning of my visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open to classic vim motions and plugins.&lt;/p&gt;&#xA;" OwnerUserId="3357" LastEditorUserId="3357" LastEditDate="2015-10-06T13:17:36.183" LastActivityDate="2015-10-08T11:54:04.293" Title="Duplicate block of code" Tags="|cut-copy-paste|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4991" PostTypeId="1" CreationDate="2015-10-06T14:02:07.590" Score="6" ViewCount="4205" Body="&lt;p&gt;Now I am learning how to use GNU GLOBAL in vim. I have installed &lt;code&gt;gtags.vim&lt;/code&gt;. I have &lt;code&gt;gtags&lt;/code&gt; the kernel source directory. The &lt;code&gt;.vimrc&lt;/code&gt; includes the following lines:&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cscopetag&#xA;set csprg=gtags-cscope                                             &#xA;cs add GTAGS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assume that I am editing the file &lt;code&gt;arch/x86/kvm/x86.c&lt;/code&gt; and the cursor is on the function call &lt;code&gt;kvm_lapic_enabled()&lt;/code&gt;. Now I press &lt;code&gt;^]&lt;/code&gt;, the vim complains like this:&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E429: File &quot;arch/x86/kvm/lapic.h&quot; does not exist&#xA;E257: cstag: tag not found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I remove the &lt;code&gt;set cscopetag&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt;, the vim will complains like this:&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E433: No tags file&#xA;E426: tag not found: kvm_lapic_enabled&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I guess that in the first case, vim used the tag file generated by gtags to locate the function and learned that it is defined in &lt;code&gt;arch/x86/kvm/lapic.h&lt;/code&gt;. However, vim seems to lookup this file under current directory, that is &lt;code&gt;arch/x86/kvm/arch/x86/kvm/lapic.h&lt;/code&gt;, when using cscope by default.&#xA;So how to configure vim to let &lt;code&gt;^]&lt;/code&gt; can utilize the GTAGS correctly? Exactly, how to configure the &lt;code&gt;cscope find&lt;/code&gt; command to use the GTAGS correctly?&lt;br/&gt;&#xA;Thanks very much!&lt;/p&gt;&#xA;" OwnerUserId="4754" LastActivityDate="2015-10-06T14:02:07.590" Title="Using GNU GLOBAL and gtags-cscope in vim" Tags="|vimrc|ctags|cscope|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4992" PostTypeId="2" ParentId="4990" CreationDate="2015-10-06T14:19:28.887" Score="4" Body="&lt;p&gt;Once you have your visual selection you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;t'&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(it's actually &lt;code&gt;:t'&amp;gt;&lt;/code&gt; because Vim adds the visual range automatically)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to copy it after the visual selection and do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'[O&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to add an empty line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to use visual selection, something like this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:,/end/t//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will still need to add the empty line manually.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-10-06T14:19:28.887" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4993" PostTypeId="2" ParentId="4990" CreationDate="2015-10-06T14:21:37.663" Score="3" Body="&lt;p&gt;For most languages you probably would be able to jump between the start and the end of a block of code with &lt;code&gt;%&lt;/code&gt; (check &lt;code&gt;:help %&lt;/code&gt;), because the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=39&quot; rel=&quot;nofollow&quot;&gt;matchit plugin&lt;/a&gt; comes installed by default with vim. So on your example you could only navigate to 'begin' or 'end' and use &lt;code&gt;y%&lt;/code&gt; to copy the entire block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't need to duplicate all the code, but just want to use as a template, you should check some kind of snippet plugin, such as &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2715&quot; rel=&quot;nofollow&quot;&gt;Ultisnips&lt;/a&gt; and &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2540&quot; rel=&quot;nofollow&quot;&gt;snipmate&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2015-10-07T11:21:47.267" LastActivityDate="2015-10-07T11:21:47.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4994" PostTypeId="1" AcceptedAnswerId="4997" CreationDate="2015-10-06T14:44:49.653" Score="4" ViewCount="1085" Body="&lt;p&gt;I'd like to automatically format html and js code when I exit insert mode. Currently I have &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; mapped to format the current file in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;c-f&amp;gt; :call JSBeautify()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can trigger this command each time I exit insert mode?&lt;/p&gt;&#xA;" OwnerUserId="4771" LastEditorUserId="1841" LastEditDate="2015-10-06T19:26:51.807" LastActivityDate="2015-10-07T15:00:57.433" Title="Automatically call HTMLBeaufity when exiting Insert mode in Vim" Tags="|autocmd|plugin-vim-jsbeautify|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4995" PostTypeId="1" AcceptedAnswerId="4996" CreationDate="2015-10-06T16:24:49.013" Score="3" ViewCount="568" Body="&lt;p&gt;When I open a large number of files in vim with tabs only the first &lt;code&gt;tabpagemax&lt;/code&gt; files are in tabs and any more than that are available by doing &lt;code&gt;:n&lt;/code&gt;.  After I close several of the open tabs how do I 'refresh' the tabs with the untabbed files?&lt;/p&gt;&#xA;" OwnerUserId="4761" LastActivityDate="2017-03-08T13:54:13.900" Title="How does one put currently open files into tabs?" Tags="|tabbed-user-interface|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4996" PostTypeId="2" ParentId="4995" CreationDate="2015-10-06T17:47:09.297" Score="5" Body="&lt;p&gt;You can use &lt;code&gt;:tab ball&lt;/code&gt; 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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps this works better:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set tabpagemax=99&#xA;:tab ball&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or even &lt;code&gt;:exe &quot;tab ball&quot; &amp;amp;tabpagemax&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="205" LastEditDate="2015-10-07T00:07:18.217" LastActivityDate="2015-10-07T00:07:18.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4997" PostTypeId="2" ParentId="4994" CreationDate="2015-10-06T19:20:32.577" Score="5" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#InsertLeave&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;InsertLeave&lt;/code&gt;&lt;/a&gt; autocommand event to do what you want. You can add something like that in your &lt;code&gt;.vimrc&lt;/code&gt; to create commands for html and js files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! InsertLeave *.html,*.js call JSBeautify&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;InsertLeave&lt;/code&gt; will trigger the event each time you exit insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;*.html,*.js&lt;/code&gt; to do that only on html and js files.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;call JSBeautify&lt;/code&gt; is the call you want to do.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also you could be interested in the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#BufWritePre&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;BufWritePre&lt;/code&gt;&lt;/a&gt; event which will trigger the command just before writing the buffer to the file. Using the command each time you leave insert mode may be not that comfortable I think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relevant help topic:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocmd-events&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h autocmd-events&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; In the comments OP asks how to use different function for different filetypes. The easiest solution I see is using an &lt;code&gt;augroup&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup&#xA;    autocmd!&#xA;    autocmd! InsertLeave *.js   call JSBeautify&#xA;    autocmd! InsertLeave *.html call HTMLBeautify&#xA;    autocmd! InsertLeave *.css  call CSSBeautify&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;augroup&lt;/code&gt; allows to group autocommands.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;autocmd!&lt;/code&gt; purges the group when you need to re-source your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;the 3 autocommands are pretty similar to the first one excepted they are triggered for only one filetype.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;More related topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#:augroup&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :augroup&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/14.html&quot; rel=&quot;nofollow&quot;&gt;LearnVimscriptTheHardWay chapter on &lt;code&gt;augroup&lt;/code&gt;&lt;/a&gt; &lt;em&gt;(Also all of this book is pretty good to learn vimscript so don't hesitate to read all of it ;-) )&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-10-07T15:00:57.433" LastActivityDate="2015-10-07T15:00:57.433" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4998" PostTypeId="2" ParentId="4989" CreationDate="2015-10-06T22:08:27.513" Score="4" Body="&lt;p&gt;Well, I decided to answer my own question: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter,BufWinEnter * if &amp;amp;filetype=='help' &#xA;        \| let w:bufnuc = bufnr(&quot;%&quot;)&#xA;        \| let w:bufnua = bufnr(&quot;#&quot;)&#xA;        \| if w:bufnua &amp;gt; 0&#xA;            \| execute &quot;buffer &quot; . w:bufnua&#xA;                \| if &amp;amp;filetype=='help' &#xA;                    \| if w:bufnua != w:bufnuc&#xA;                        \| set nobuflisted&#xA;                    \| endif&#xA;                \| endif &#xA;            \| execute &quot;buffer &quot; . w:bufnuc&#xA;        \| endif&#xA;    \| endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works as per spec's above.&lt;/p&gt;&#xA;" OwnerUserId="4617" LastEditorUserId="205" LastEditDate="2015-10-06T23:01:13.473" LastActivityDate="2015-10-06T23:01:13.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4999" PostTypeId="2" ParentId="4995" CreationDate="2015-10-06T23:45:16.473" Score="4" Body="&lt;h3&gt;And now for something completely different...&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;It seems like you are using Vim's tabs as file proxies (aka 1 file == 1 tab). This is how most editors work. Vim on the other hand uses the same familiar name &quot;tab&quot; to be a view into window (splits) layout. This unfortunate naming has lead many a new vimmer to try and force tabs to behave as file proxies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's uses buffers. Buffers can be associated with files or simply scratch buffer not associated file. Each file has its own buffer. Buffers are Vim's file proxies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now windows/splits are views into a buffer. You can have many windows looking into the same or different buffers. You can move these windows around, create them, close them, or whatever you need to create a layout of buffers that meet your workflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tabs are a collection of windows or a view into a layout of windows. It's just another layer above windows. You can of course use these tabs however you want, but trying to force Vim to use tabs like other editors is going to be pure folly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But don't just take my word for it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/103590/438329&quot;&gt;Using Vim's tabs like buffers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/26708822/438329&quot;&gt;Why do Vim experts prefer buffers over tabs?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/21338192/438329&quot;&gt;Use buffers effectively&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Oh yeah? What about Buftabline, Airline, BufTabs, MiniBufExpl, ...?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;All these plugins do is show you your currently listed buffers. Maybe with some kind of positioning information so that you feel comfortable cycling via &lt;code&gt;:bnext&lt;/code&gt; and &lt;code&gt;:bprevious&lt;/code&gt; (or whatever mappings you might be using) through your buffer list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that is great and all, these plugins have recreated other editor's version of tabs, but Vim already let you cycle through buffers without these plugins. The only thing missing was a menu which &lt;code&gt;:ls&lt;/code&gt; will gladly do for you without wasting any screen real-estate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine having 10, 25, 50, or 100+ buffers open. How is your Buftabline going to handle that? My bet is not well. You need to stop reaching for simple tools like &lt;code&gt;:bnext&lt;/code&gt; / &lt;code&gt;:bprev&lt;/code&gt; and start reaching for a power tool like &lt;code&gt;:b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Behold the power of &lt;code&gt;:b&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:b&lt;/code&gt; command can take a buffer number to switch directly to a buffer. Far more interesting, &lt;code&gt;:b&lt;/code&gt; can take a partial filename.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:b partial-name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Need more power in your &lt;code&gt;:b&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Uses tab completion&lt;/li&gt;&#xA;&lt;li&gt;Uses &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; to list out completions&lt;/li&gt;&#xA;&lt;li&gt;Accepts globs. e.g. &lt;code&gt;:b *foo&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;**&lt;/code&gt; to descend into directories. e.g. &lt;code&gt;:b foo/**/bar&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Don't forget to add &lt;code&gt;set hidden&lt;/code&gt; to your &lt;code&gt;vimrc&lt;/code&gt;. See &lt;code&gt;:h 'hidden'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why ride a bike when you can fly?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9CCOq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9CCOq.png&quot; alt=&quot;Flying vs cycling&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://of-vim-and-vigor.blogspot.ro/p/vim-vigor-comic.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;taken from Bairui's collection of Vim infographics&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use a simple mapping to leverage both &lt;code&gt;:ls&lt;/code&gt; and &lt;code&gt;:b&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :ls&amp;lt;cr&amp;gt;:b&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can travel directly to you buffer you want. No more cycling.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;But I like plugins&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Who doesn't like a good plugin. As a matter a fact if you are looking for a nice buffer switching plugin then I would recommend you look into a nice fuzzy finder like &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;CtrlP&lt;/a&gt; to aid you in switching between buffers. A fuzzy finder actually adds value to switching between buffers by getting you there faster with less typing.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Conclusion&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Eventually you workflow will require you to use more than 3 buffers at a time. At that moment I would suggest you take another look at the &lt;code&gt;:b&lt;/code&gt; command or at the very least get a nice fuzzy finder. It will save you time and effort.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So stop riding your bike when you can &lt;em&gt;fly&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-03-08T13:54:13.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5000" PostTypeId="1" AcceptedAnswerId="5002" CreationDate="2015-10-07T03:50:21.050" Score="5" ViewCount="95" Body="&lt;p&gt;I noticed that if I have a quoted string which contains one new line character I can't use the text objects &lt;code&gt;i&quot;&lt;/code&gt; and &lt;code&gt;a&quot;&lt;/code&gt; anymore. For example if I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is some text which is less than 80 character and &quot;this is a quoted string&#xA;which contains a line break&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When my cursor is on the word &lt;code&gt;string&lt;/code&gt; using &lt;code&gt;va&quot;&lt;/code&gt; will not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This behavior is consistent with what &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#aquote&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h aquote&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Only works within one line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My questions are:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there a built-in text object which would have the same behavior as &lt;code&gt;a&quot;&lt;/code&gt; but accepting breakline?&lt;/li&gt;&#xA;&lt;li&gt;If not is there a plugin which implement it? (I didn't find a relevant one)&lt;/li&gt;&#xA;&lt;li&gt;If not is there a good reason which makes that is hasn't been implemented?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-10-07T14:41:57.590" Title="How to keep a text object a&quot; when it contains a breakline?" Tags="|cursor-motions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5002" PostTypeId="2" ParentId="5000" CreationDate="2015-10-07T09:27:52.970" Score="2" Body="&lt;p&gt;Thinking of a reason why Vim doesn't have this by default ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At least in VimL and C/C++, to have a string span multiple lines, you can't really have an opening delimiter on a line, and just the ending one on another. &lt;code&gt;&quot;this is a quoted string&lt;/code&gt; is an end-of-line comment in vimscript, not an unfinished string. For example, with C, you have to use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf(&quot;first very long line &quot;&#xA;       &quot;second line, in code &quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, briefly put, a multiline string (quote, text lines, quote) is not necessarily a &lt;em&gt;valid&lt;/em&gt; multiline string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I agree it can be useful for other filetypes (text, markdown). Even though, for &lt;em&gt;text&lt;/em&gt;, perhaps you'd want to use a &lt;a href=&quot;https://github.com/reedes/vim-textobj-quote&quot; rel=&quot;nofollow noreferrer&quot;&gt;typographic quotes&lt;/a&gt; solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To complement &lt;a href=&quot;https://vi.stackexchange.com/questions/5000/how-to-keep-a-text-object-a-when-it-contains-a-breakline#comment7627_5000&quot;&gt;FDinoff's comment/solution&lt;/a&gt; of using &lt;a href=&quot;https://github.com/beloglazov/vim-textobj-quotes&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-quotes&lt;/a&gt;: if your filetype has syntax support, and the multiline quoted string appears as a separate syntax item, you  can select the whole block using &lt;a href=&quot;https://github.com/kana/vim-textobj-syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kana's syntax&lt;/a&gt; text object. In the above example, both strings will be selected at once, when using something like &lt;code&gt;viy&lt;/code&gt; or &lt;code&gt;vay&lt;/code&gt; with cursor inside any of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like the syntax-based approach because it's not limited to multiline &lt;em&gt;strings&lt;/em&gt;: I can very well select an entire multiline comment in exactly the same way. And I'm also pretty sure the selection is a valid one.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-10-07T14:41:57.590" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5004" PostTypeId="1" CreationDate="2015-10-07T11:24:49.367" Score="0" ViewCount="86" Body="&lt;p&gt;I am using tern_for_vim to provide javascript support on autocompletion, jump to definitions and it also generates hints about parameter type based on any JSDocs I write for my functions. &#xA;The problem is if I update those JSDocs, tern doesnt seem to update its defintions.&lt;br&gt;&#xA;Is it possible to tell tern to reload / reparse my code?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2015-10-07T11:59:48.300" Title="How can I rebuild tern_for_vim's index of my code?" Tags="|plugin-ternjs|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5006" PostTypeId="1" AcceptedAnswerId="5008" CreationDate="2015-10-07T11:41:41.453" Score="3" ViewCount="357" Body="&lt;p&gt;When performing autocompletion on PHP or javascript, vim opens a scratch buffer which contains info about the function being autocompleted.&lt;br&gt;&#xA;Unfortunately, I increased the height of this scratch buffer by 8 lines with&#xA;&lt;kbd&gt;C-w&lt;/kbd&gt;, &lt;kbd&gt;8&lt;/kbd&gt;, &lt;kbd&gt;+&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the scratch buffer always opens really large (about 10 lines high).&lt;br&gt;&#xA;Even closing and restarting vim makes no difference.&lt;br&gt;&#xA;How can I reset the behaviour for this scratch buffer?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2015-10-07T11:46:36.690" Title="How can I reset the scratch / preview buffer height?" Tags="|scratch-buffer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5007" PostTypeId="2" ParentId="5004" CreationDate="2015-10-07T11:44:34.960" Score="1" Body="&lt;p&gt;According &lt;a href=&quot;https://github.com/marijnh/tern_for_vim&quot; rel=&quot;nofollow&quot;&gt;&quot;Tern for Vim&quot; plugin&lt;/a&gt;  homepage, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is a Vim plugin that provides Tern-based JavaScript editing support.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So it is an easier interface for the &lt;a href=&quot;http://ternjs.net/&quot; rel=&quot;nofollow&quot;&gt;Tern&lt;/a&gt; tool. Therefore, if you don't find the information on how to update the index on the &lt;a href=&quot;https://github.com/marijnh/tern_for_vim/blob/master/doc/tern.txt&quot; rel=&quot;nofollow&quot;&gt;plugin documentation&lt;/a&gt;, you should check the &lt;a href=&quot;http://ternjs.net/doc/manual.html&quot; rel=&quot;nofollow&quot;&gt;Tern documentation&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't point the direct command/configuration, as I don't use JavaScript nor Tern; but you probably executed it to generate a first version of the definition list, otherwise it wouldn't have worked at all. If it is a configuration, maybe it just became outdated (for instance, if you moved the project directory). If it is a command you can create a mapping to make it easier to trigger the update.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-10-07T11:44:34.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5008" PostTypeId="2" ParentId="5006" CreationDate="2015-10-07T11:46:36.690" Score="4" Body="&lt;p&gt;It's called &quot;preview window&quot; and you can read all about it in &lt;code&gt;:help preview-window&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;'previewheight'&lt;/code&gt; option should be what you are looking for.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-10-07T11:46:36.690" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5009" PostTypeId="2" ParentId="5004" CreationDate="2015-10-07T11:59:48.300" Score="0" Body="&lt;p&gt;this is embarrasing, but it seems the failure to update was because my JSDoc code wasnt syntactically correct.&lt;br&gt;&#xA;Once I fixed my doc comments - the autocomplete hints updated automatically.&lt;br&gt;&#xA;It seems the tern server doesnt need to be manually reloaded as you would with a ctags file for example.  I think the interaction between vim and tern occurs regularly - perhaps everytime you invoke a tern command or autocompletion...?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2015-10-07T11:59:48.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5011" PostTypeId="1" CreationDate="2015-10-07T14:54:06.847" Score="5" ViewCount="281" Body="&lt;p&gt;For example, I want to write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$HOME/.vim/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and complete the path with &lt;code&gt;i_CTRL-X_CTRL-F&lt;/code&gt; so that it becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$HOME/.vim/syntax/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what I get is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/username/.vim/syntax/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One workaround I've tried is using &lt;code&gt;~&lt;/code&gt; instead of &lt;code&gt;$HOME&lt;/code&gt;, but they aren't equivalent, e.g. &lt;code&gt;&quot;echo &quot;$HOME&quot;&lt;/code&gt; is not the same as &lt;code&gt;echo &quot;~&quot;&lt;/code&gt;, and &lt;code&gt;~&lt;/code&gt; doesn't help with other environment variables.&lt;/p&gt;&#xA;" OwnerUserId="4498" LastEditorUserId="4498" LastEditDate="2015-12-05T02:52:42.770" LastActivityDate="2015-12-05T02:52:42.770" Title="Prevent ^X^F from expanding $HOME" Tags="|autocompletion|insert-mode|path|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5012" PostTypeId="2" ParentId="5011" CreationDate="2015-10-07T20:08:40.420" Score="2" Body="&lt;p&gt;This is probably impossible without any plugins, as mentioned on the comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you wouldn't have to start from the scratch if you want to implement such functionality using VimL, you could use the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4313&quot; rel=&quot;nofollow&quot;&gt;BufNameComplete plugin&lt;/a&gt; as a starting point (note that it uses the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3914&quot; rel=&quot;nofollow&quot;&gt;CompleteHelper : Generic functions to support custom insert mode completions&lt;/a&gt; plugin, which probably isn't necessary for your problem).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use a regex to identify any environment variables before the expansion and then apply &lt;code&gt;substitute(result, expanded_env_var, original_env_var, '')&lt;/code&gt; in order to restore the environment variables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(actually this works if you want to check only for the first environment variable on the input; if you want to preserve all of them,you would need to build a dictionary with all the variables and the respective expansions, and then iterate on it to replace each expansion with the original variable)&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-10-07T20:08:40.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5013" PostTypeId="1" CreationDate="2015-10-07T22:59:05.650" Score="1" ViewCount="390" Body="&lt;p&gt;I am going to write a program which can be run from the command line, at least on *nix systems.  I considered using Python or Perl, but why not Vimscript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Has anybody done this?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What is the best practice for writing this kind of application?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a bootstrap or library?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;User interaction will be minimal in my case. The input will be provided as arguments to the executable, and Vim will display text output and do some processing.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;My initial attempt&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Outputs this when run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ./my_new_app arg1 &quot;broken word&quot; arg3&#xA;&#xA;Retrieved arguments: arg1 broken word arg3&#xA;Press ENTER or type command to continue&#xA;Argument 0 is: arg1&#xA;Press ENTER or type command to continue&#xA;Argument 1 is: broken&#xA;Press ENTER or type command to continue&#xA;Argument 2 is: word&#xA;Press ENTER or type command to continue&#xA;Argument 3 is: arg3&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are three issues:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It breaks the second argument into &lt;strong&gt;two arguments&lt;/strong&gt; due to the space.&lt;/li&gt;&#xA;&lt;li&gt;Every time I print something, I must &lt;strong&gt;Press ENTER&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If I pipe the result as in &lt;code&gt;./myapp 1 2 3 &amp;gt; output.file&lt;/code&gt; then I get &lt;strong&gt;&quot;Warning: Output is not to a terminal&quot;&lt;/strong&gt;, and I can't see the Press ENTER prompts, although I still need to fulfil them.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;&lt;em&gt;my_new_app&lt;/em&gt; (executable file)&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;# Pass the arguments to Vim in a variable, and exec my_new_app.vim&#xA;vim -c &quot;:let g:arguments_string='$*'&quot; -c &quot;:so $0.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;&lt;em&gt;my_new_app.vim&lt;/em&gt;&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Print(str)&#xA;  exec '!echo &quot;' . a:str . '&quot;'&#xA;  &quot; This doesn't work so well: I only see the first line.&#xA;  &quot;call system('echo &quot;' . a:str . '&quot;')&#xA;endfunction&#xA;&#xA;call s:Print(&quot;Retrieved arguments: &quot; . g:arguments_string)&#xA;&#xA;let s:args = split(g:arguments_string, ' ')&#xA;&#xA;for i in range(0, len(s:args))&#xA;  call s:Print(&quot;Argument &quot; . i . &quot; is: &quot; . s:args[i])&#xA;endfor&#xA;&#xA;exit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-10-07T22:59:05.650" Title="Writing a command-line tool in VimScript" Tags="|vimscript|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5014" PostTypeId="1" AcceptedAnswerId="5024" CreationDate="2015-10-08T02:07:05.040" Score="0" ViewCount="354" Body="&lt;p&gt;If I am coding in PHP and I type out a PHP built-in function (e.g. &lt;code&gt;explode()&lt;/code&gt;)  vims standard omni-complete would normally provide a function signature in a preview window.&lt;br&gt;&#xA;I recently installed a couple of plugins and now the function signature preview doesnt seem to work, is there any way to manually invoke this preview window with function signature? &lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2015-10-08T02:23:26.087" LastActivityDate="2015-10-08T14:22:50.467" Title="How can I manually invoke the function signature preview?" Tags="|autocompletion|previewing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5015" PostTypeId="1" CreationDate="2015-10-08T05:31:15.153" Score="41" ViewCount="6036" Body="&lt;p&gt;I was extremely impressed with the power of vi from the first half hour that I used it. I then found out that in some work environments, there are many people (technicians, and even system administrators!) who avoid it as &quot;too complicated&quot; without ever having run the vimtutor, and still other people who use vi only in insert mode and miss the whole point of modal editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I demonstrate the power of vi/Vim to others in such a way as to inspire them to learn it and use it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am especially interested in any actual histories of what has been successful in getting others (or yourself) to learn and use Vim.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="11357" LastEditDate="2022-09-26T04:00:29.540" LastActivityDate="2022-09-26T04:00:29.540" Title="How can I inspire others to use vi/Vim?" Tags="|untagged|" AnswerCount="14" CommentCount="7" ClosedDate="2021-01-27T16:13:29.570" ContentLicense="CC BY-SA 3.0" />
  <row Id="5016" PostTypeId="2" ParentId="5015" CreationDate="2015-10-08T06:18:46.657" Score="3" Body="&lt;p&gt;Although &lt;code&gt;vi&lt;/code&gt; has a respected pedigree in computing history, I would recommend focusing on &lt;code&gt;vim&lt;/code&gt;. It is a full featured editor with incredible capabilities, matching any of its competitors. Its only drawback is the learning curve; it does take time to get the &quot;Vim mindset&quot; and muscle memory. I think it is well worth the effort. There is a lot of power at your disposal when you become proficient at &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Demonstrate the power of vimscript to automate boring text processing tasks.&lt;/li&gt;&#xA;&lt;li&gt;Install cool plugins like &lt;code&gt;vim-airline&lt;/code&gt;, because everybody likes a good UI.&lt;/li&gt;&#xA;&lt;li&gt;There are loads of free tutorials around, like &lt;a href=&quot;http://www.openvim.com/tutorial.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vi&lt;/code&gt;/&lt;code&gt;vim&lt;/code&gt; is installed on all Unix-based systems; so any professional sysdamin should have a working knowledge of it. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="398" LastEditorUserId="3168" LastEditDate="2018-10-03T14:44:41.157" LastActivityDate="2018-10-03T14:44:41.157" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5017" PostTypeId="2" ParentId="5015" CreationDate="2015-10-08T08:24:30.137" Score="61" Body="&lt;p&gt;Although I've invested some effort in Vim and its ecosystem I don't actively try to convert others. Most of the people I've worked with don't invest much time at all into improving their workflow and toolset because they are satisfied with what they have. I find that perfectly fine… and I would &lt;em&gt;hate&lt;/em&gt; to be the target of constant editor-related proselytizing so I don't impose that to others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes, though, a coworker might be intrigued by my vimming and ask me a couple of questions. When that rare event happens, I'm more than happy to discuss the subject, demo cool tricks, and point him/her at useful resources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At my last job, a coworker was very interested by Vim and knew the basics quite well (&lt;code&gt;vimtutor&lt;/code&gt;). It was enough for him to be able to perform quick edits but he lacked the confidence and the know-how to actually switch to Vim (something he actually wanted). At one point, he had to do a series of repetitive edits on a large JSON file manually. He was distressed by the idea of wasting an hour doing that and came to me looking for a faster/smarter solution. Of course, a simple macro did the job in less than a minute (including recording) which allowed me to explain a few key concepts…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One problem faced by newcomers is that &quot;Now what?&quot; moment that comes just after &lt;code&gt;vimtutor&lt;/code&gt;. Vim hides its beauty very well and not many people have the will to crack that shell without help. I can provide that help if needed… but I will never force Vim unto others.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-10-09T15:03:56.313" LastActivityDate="2015-10-09T15:03:56.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5018" PostTypeId="1" AcceptedAnswerId="5019" CreationDate="2015-10-08T09:18:07.073" Score="6" ViewCount="138" Body="&lt;p&gt;I'm analyzing a lot of logs using VIM version 7.3 (2010 Aug 15, compiled Sep 24 2013 13:45:11). &lt;br&gt;&#xA;Recently I obtained logs that look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     3521:2015-09-28T09:18:36.922557+00:00 192 [info]  »   ERR:  00 LINUX-0-&amp;lt;2015-09-28T09:18:36.922555Z&amp;gt; 22E ERR/APP/Error, (pid:558) name : SomeApplication#015¶&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but after inserting any word at the end of a line it changes to 3 lines like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3521:2015-09-28T09:18:36.922557+00:00 192 [info]  »   ERR:  00¶&#xA;LINUX-0-&amp;lt;2015-09-28T09:18:36.922555Z&amp;gt; 22E ERR/APP/Error, (pid:558) name :¶&#xA;SomeApplication#015 %%%¶&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cindent¶&#xA;set nowrap¶&#xA;set hidden¶&#xA;set number¶&#xA;set ignorecase¶&#xA;set tabstop=6 shiftwidth=4 softtabstop=4 expandtab¶&#xA;set listchars=tab:»\ ,eol:¶,trail:·,   &quot; show invisible characters as in eclipse IDE¶&#xA;nmap &amp;lt;CR&amp;gt; o&amp;lt;Esc&amp;gt;¶&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Space&amp;gt; :silent noh&amp;lt;Bar&amp;gt;echo&amp;lt;CR&amp;gt;¶&#xA;&#xA;&quot; user defined commands¶&#xA;command DBGPrint ! cat % &amp;lt;Bar&amp;gt; grep \%\%\% &amp;lt;Bar&amp;gt; less¶&#xA;command! -nargs=1 Filter %y z &amp;lt;Bar&amp;gt; tabnew &amp;lt;Bar&amp;gt; 0put=@z &amp;lt;Bar&amp;gt; %!grep -in &quot;&amp;lt;args&amp;gt;&quot;¶&#xA;command! -nargs=1 FilterSens %y z &amp;lt;Bar&amp;gt; tabnew &amp;lt;Bar&amp;gt; 0put=@z &amp;lt;Bar&amp;gt; %!grep -n &quot;&amp;lt;args&amp;gt;&quot;¶&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;br&gt;&#xA;I added&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=0&#xA;set wrapmargin=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;at the end of my .vimrc file but when opening log file I have it set to &lt;em&gt;textwidth=78&lt;/em&gt;.&lt;br&gt;&#xA;When I execute &lt;em&gt;set textwidth=0&lt;/em&gt; in open file - it works.&lt;/p&gt;&#xA;" OwnerUserId="3254" LastEditorUserId="3254" LastEditDate="2015-10-09T10:33:41.320" LastActivityDate="2015-10-09T10:33:41.320" Title="Adding new characters cause splitting line into many lines" Tags="|indentation|line-breaks|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5019" PostTypeId="2" ParentId="5018" CreationDate="2015-10-08T09:31:10.670" Score="5" Body="&lt;p&gt;Try &lt;code&gt;set textwidth=0&lt;/code&gt; to not break up long lines. See &lt;code&gt;:h tw&lt;/code&gt;. Note that if you set the textwidth to 0, then wrapmargin might take effect, see &lt;code&gt;:h wm&lt;/code&gt;, so consider also using &lt;code&gt;set wrapmargin=0&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastActivityDate="2015-10-08T09:31:10.670" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5020" PostTypeId="1" AcceptedAnswerId="5025" CreationDate="2015-10-08T11:27:57.267" Score="0" ViewCount="456" Body="&lt;p&gt;I have added the following line some days ago to enable NERDTree and Tagbar fancy arrows.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;scriptencoding utf-8&#xA;set encoding=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything works fine. It displays äüöÄÜÖ without problems in text files of any kind. But just today I have seen the following line not showing this character correctly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bereits bei der &amp;lt;e4&amp;gt;ltsten &amp;lt;c4&amp;gt;nderung&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... which is the information message that undo it at it's last change. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to keep fancy arrows and correctly display messages?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Removing &lt;code&gt;set encoding=utf-8&lt;/code&gt; brings back Umlaute but also fancy arrows are gone. &lt;/p&gt;&#xA;" OwnerUserId="4413" LastEditorUserId="4413" LastEditDate="2015-10-08T14:32:02.547" LastActivityDate="2015-10-08T14:53:04.380" Title="gVim not showing german Umlaute, but only in error/warning and other messages" Tags="|gvim|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5021" PostTypeId="2" ParentId="4990" CreationDate="2015-10-08T11:31:33.767" Score="3" Body="&lt;p&gt;If you have to copy a known number of lines you can do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;yanks 3 lines from the cursor position&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And use &lt;kbd&gt;p&lt;/kbd&gt; to paste where do you want them.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It may come as help to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set relativenumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it will show line numbers relative to cursor position. Show you can see how many lines you need to yank(as far as the display permits).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To turn line numbering off do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set norelativenumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2710" LastEditorUserId="2710" LastEditDate="2015-10-08T11:54:04.293" LastActivityDate="2015-10-08T11:54:04.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5023" PostTypeId="2" ParentId="5015" CreationDate="2015-10-08T13:34:02.930" Score="25" Body="&lt;p&gt;I use Vim for everything. I mean everything. Programming, word processing, writing novels, etc. Everything. I have been sitting at an auto dealership using a &lt;a href=&quot;https://en.wikipedia.org/wiki/Surface_Pro_3#Hardware&quot;&gt;Surface Pro 3&lt;/a&gt; running a Linux &lt;a href=&quot;https://en.wikipedia.org/wiki/VirtualBox&quot;&gt;Virtual Box&lt;/a&gt; with Vim and had people strike up conversations with me about what I am doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just use Vim. People will flock to you to find out what it is you are doing and why. I usually explain it this way -&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Vim because it has a very small footprint. Microsoft Word is several gigabytes and my Surface only has 128&amp;nbsp;GB of space. I need to maximize my space and Vim helps me do that. It is also extensible and helps me stay focused. Here, look. &lt;em&gt;Demo some of my plugins and show how Vim in full screen essentially covers everything up so I can think&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often demonstrate &lt;a href=&quot;http://en.wikipedia.org/wiki/LaTeX&quot;&gt;LaTeX&lt;/a&gt; in combination with Vim. I will build a LaTeX file and then compile it into a beautiful PDF using a template I have. I also demo my letter and resume templates. I stress how important it is to break up style from content. By this point people are no longer interested in what I have to say and regret speaking to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They look for a way out of the conversation, and I go back to writing. Vim is a religious experience more than a word processor.&lt;/p&gt;&#xA;" OwnerUserId="1417" LastEditorUserId="4676" LastEditDate="2015-10-17T18:04:38.023" LastActivityDate="2015-10-17T18:04:38.023" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="5024" PostTypeId="2" ParentId="5014" CreationDate="2015-10-08T14:22:50.467" Score="1" Body="&lt;p&gt;In theory you could go to the end of the function and and press &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; if  &lt;code&gt;'completeopt'&lt;/code&gt; has &lt;code&gt;menuone&lt;/code&gt; set. However this will add an extra paren at the end of the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the following snippet in my &lt;code&gt;~/.vim/after/ftplugin/php.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:PHPQuickMan(word)&#xA;  if !exists('g:php_builtin_functions')&#xA;    call phpcomplete#LoadData()&#xA;  endif&#xA;  let word = a:word . '('&#xA;  if !get(b:, 'php_quick_man_color', get(g:, 'php_quick_man_color', 1))&#xA;    echo word . get(g:php_builtin_functions, word, ' can not be found')&#xA;  else&#xA;    let sig = get(g:php_builtin_functions, word, '')&#xA;    if sig == ''&#xA;      echohl WarningMsg&#xA;      echo word . ' can not be found'&#xA;      echohl None&#xA;    else&#xA;      echon word&#xA;      for part in split(matchstr(sig, '.*\ze|\s\+\w\+$'), '\&amp;lt;')&#xA;        echohl Directory&#xA;        let w = matchstr(part, '\v^(int|array|mixed|callable|object|string|bool|void|resource)')&#xA;        echon w&#xA;        echohl None&#xA;        echon strpart(part, len(w))&#xA;      endfor&#xA;      echon &quot;) | &quot;&#xA;      echohl WarningMsg&#xA;      echon matchstr(sig, '|\s\+\zs\w\+$')&#xA;      echohl None&#xA;    endif&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;buffer&amp;gt; K :call &amp;lt;SID&amp;gt;PHPQuickMan(expand('&amp;lt;cword&amp;gt;'))&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This leverages the php's omni-complete database to print out at the bottom of the screen the function signature when you press &lt;code&gt;K&lt;/code&gt; on a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'completeopt'&#xA;:h compl-omni&#xA;:h i_CTRL-X_CTRL-O&#xA;:h K&#xA;:h 'keywordprg'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-10-08T14:22:50.467" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5025" PostTypeId="2" ParentId="5020" CreationDate="2015-10-08T14:53:04.380" Score="0" Body="&lt;p&gt;To let you guys know -- the solution from  Christian Brabandt posted in the comments worked for me. Thank you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the link again: &lt;a href=&quot;https://superuser.com/q/207264/85228&quot;&gt;https://superuser.com/q/207264/85228&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4413" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2015-10-08T14:53:04.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5026" PostTypeId="2" ParentId="5015" CreationDate="2015-10-08T14:56:53.597" Score="14" Body="&lt;p&gt;As someone that had to learn Vim at my last job, I would say that the biggest hurdle was being put in front of a &lt;em&gt;&quot;default&quot;&lt;/em&gt; install that had no options set.  I spent most of the time saying, &lt;em&gt;&quot;Why does it act this way when everyone would expect it to do the opposite?&quot;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out that every one else already set some &lt;em&gt;&quot;sanity&quot;&lt;/em&gt; defaults.  Once I figured that out, I was much happier, and &lt;em&gt;&quot;gave it a chance&quot;&lt;/em&gt; to learn more.  After a few days of the number pad not working, tabs being wrong, searches not working well, etc. I was ready to throw in the towel and never look back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want someone to like it enough to &lt;strong&gt;try&lt;/strong&gt; and learn more advanced features, start them off on the right foot with a settings file that is optimized for the type of work they need to do.&lt;/p&gt;&#xA;" OwnerUserId="4798" LastEditorUserId="3168" LastEditDate="2018-09-26T09:06:28.483" LastActivityDate="2018-09-26T09:06:28.483" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5028" PostTypeId="1" AcceptedAnswerId="5040" CreationDate="2015-10-08T17:00:24.573" Score="4" ViewCount="106" Body="&lt;p&gt;When editing html in Vim, I'll write the class name of the section that I am working on like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mid-med&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It is untagged plain text.&lt;/p&gt;&#xA;&lt;p&gt;I'll call tcomment to comment that out. What I expect to have happen is this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!-- mid-med --&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Instead I get this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!-- mid&amp;amp;#45;med --&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;tcomment is converting the plain-text hyphen into html character code.&lt;/p&gt;&#xA;&lt;p&gt;Is there anyway to prevent tcomment from doing this?&lt;/p&gt;&#xA;&lt;p&gt;I searched &amp;quot;help:tcomment&amp;quot; but I couldn't find or make sense of anything.&lt;/p&gt;&#xA;&lt;p&gt;I could just create the comment code first then type in the text but that's counter-intuitive and messing up my workflow.&lt;/p&gt;&#xA;&lt;p&gt;Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="4803" LastEditorUserId="23502" LastEditDate="2022-11-05T10:55:24.697" LastActivityDate="2022-11-05T10:55:24.697" Title="Vim tcomment plugin changes the hyphens in untagged text (html) to html code (&amp; #45;)" Tags="|comments|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5029" PostTypeId="1" AcceptedAnswerId="5030" CreationDate="2015-10-08T18:56:44.757" Score="3" ViewCount="1082" Body="&lt;p&gt;I'm trying to create a key mapping that makes switching buffers quicker and easier - something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmenu&#xA;nnoremap &amp;lt;Tab&amp;gt; :buffer&amp;lt;space&amp;gt;&amp;lt;Tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is, this mapping leaves me at the end of a command line that looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:buffer ^I&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I want it to start tabbing through the list of buffers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've searched the help files and Google, and tried many different combinations of &lt;code&gt;:execute&lt;/code&gt; and &lt;code&gt;:normal&lt;/code&gt;, all to no avail. Is there a way to do what I'm asking, or am I stuck with the following, two-keypress solution?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmenu&#xA;nnoremap &amp;lt;Tab&amp;gt; :buffer&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, pressing &lt;code&gt;&amp;lt;Tab&amp;gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; will do what I want.&lt;/p&gt;&#xA;" OwnerUserId="4808" LastEditorUserId="1841" LastEditDate="2015-10-08T19:26:12.030" LastActivityDate="2015-10-08T19:26:12.030" Title="Key mapping that will invoke the wildmenu" Tags="|key-bindings|vimrc|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5030" PostTypeId="2" ParentId="5029" CreationDate="2015-10-08T19:16:35.317" Score="3" Body="&lt;p&gt;You need to &lt;code&gt;set wildcharm=&amp;lt;Tab&amp;gt;&lt;/code&gt; and the following mapping will do what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Tab&amp;gt; :buffer &amp;lt;Tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27wildcharm%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 'wildcharm'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27wildchar%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 'wildchar'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;wildchar&lt;/code&gt; defines the key which triggers the wildmenu&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;wildcharm&lt;/code&gt; is like &lt;code&gt;wildchar&lt;/code&gt; but it works in macros and mappings.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2015-10-08T19:16:35.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5031" PostTypeId="2" ParentId="5029" CreationDate="2015-10-08T19:17:27.780" Score="3" Body="&lt;p&gt;You need the &lt;code&gt;wildcharm&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildcharm=&amp;lt;C-z&amp;gt;&#xA;nnoremap &amp;lt;key&amp;gt; :buffer&amp;lt;Space&amp;gt;&amp;lt;C-z&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'wildcharm&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-10-08T19:17:27.780" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5032" PostTypeId="1" AcceptedAnswerId="5034" CreationDate="2015-10-08T20:01:31.607" Score="9" ViewCount="1367" Body="&lt;p&gt;I use vim in the terminal as well as gvim. My issue is that in the terminal &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt; opens urls without a problem but in gVim nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone else experienced this issue and found a fix?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using gvim 7.4 with patches 1-52.&lt;/p&gt;&#xA;" OwnerUserId="4807" LastEditorUserId="1841" LastEditDate="2015-10-08T20:13:05.840" LastActivityDate="2018-03-27T20:39:04.970" Title="`gx` not opening url in gvim but works in terminal" Tags="|gvim|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5033" PostTypeId="1" CreationDate="2015-10-08T20:53:06.310" Score="2" ViewCount="62" Body="&lt;p&gt;Typing &lt;kbd&gt;`&lt;/kbd&gt; with delimitMate gives &lt;code&gt;``&lt;/code&gt;. But in tex files, it should produce `' . Can it be told to do so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. I found that this is easy with AutoPairs:&#xA;&lt;code&gt;let g:AutoPairs={'`': &quot;'&quot;, '&quot;': '&quot;', '{': '}', '''': '''', '(': ')', '[': ']'}&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="51" LastEditDate="2016-03-02T15:14:28.260" LastActivityDate="2016-03-02T15:14:28.260" Title="Getting delimitMate to yield tex-quotes" Tags="|delimiter-matching|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5034" PostTypeId="2" ParentId="5032" CreationDate="2015-10-08T21:06:56.960" Score="9" Body="&lt;p&gt;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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I could fix this, by using &lt;code&gt;setsid xdg-open&lt;/code&gt; which you need to set for the g:netrw&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:netrw_browsex_viewer=&quot;setsid xdg-open&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Bug opened with &lt;a href=&quot;https://bugzilla.xfce.org/show_bug.cgi?id=12251&quot; rel=&quot;nofollow&quot;&gt;XFCE&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2016-09-23T06:50:28.107" LastActivityDate="2016-09-23T06:50:28.107" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5035" PostTypeId="2" ParentId="5015" CreationDate="2015-10-08T23:22:44.433" Score="12" Body="&lt;p&gt;The best way to inspire an old dog to use a new trick is to take something they are doing and show how it can be easily done faster/easier/better in another way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is definitely a learning curve involved though which just turns some people off. One joke goes &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How do you truly generate a random string? Ask a newcomer to close vim. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4812" LastActivityDate="2015-10-08T23:22:44.433" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5036" PostTypeId="2" ParentId="5015" CreationDate="2015-10-08T23:30:25.553" Score="22" Body="&lt;p&gt;Demonstrate the power of dot ('.') in command mode.  Easily repeating a complicated edit with one key press generally looks like magic.&lt;/p&gt;&#xA;" OwnerUserId="4813" LastEditorUserId="4813" LastEditDate="2016-02-09T01:34:23.103" LastActivityDate="2016-02-09T01:34:23.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5037" PostTypeId="1" AcceptedAnswerId="5042" CreationDate="2015-10-09T00:30:49.027" Score="1" ViewCount="57" Body="&lt;p&gt;I have created a new command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Tags execute '!GTAGSFORCECPP=1 gtags' | cscope kill -1 | cscope add GTAGS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, for some reason &lt;code&gt;cscope add GTAGS&lt;/code&gt; doesn't execute when I execute &lt;code&gt;:Tags&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone explain what is the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2865" LastActivityDate="2015-10-09T09:11:38.010" Title="Why only part of a command is executed" Tags="|user-commands|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5038" PostTypeId="1" AcceptedAnswerId="5049" CreationDate="2015-10-09T04:11:50.397" Score="2" ViewCount="420" Body="&lt;p&gt;For example, this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2:26&#xA;3:04&#xA;3:14&#xA;5:38&#xA;4:12&#xA;10:30&#xA;6:29&#xA;6:53&#xA;11:49&#xA;9:33&#xA;4:17&#xA;7:49&#xA;6:10&#xA;6:04&#xA;6:28&#xA;6:40&#xA;4:21&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(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.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there are ways to do this in &lt;code&gt;bash&lt;/code&gt;, e.g. with &lt;code&gt;awk&lt;/code&gt;.  Running an external shell command is okay, but it has to work &lt;em&gt;from within&lt;/em&gt; vi—and a vim-native approach would be preferred.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="51" LastEditDate="2015-10-22T07:18:23.207" LastActivityDate="2016-03-18T00:10:20.890" Title="How to replace a list of numbers (or times/timestamps) with their sum?" Tags="|search|replace|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5039" PostTypeId="2" ParentId="5038" CreationDate="2015-10-09T04:46:31.587" Score="1" Body="&lt;p&gt;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 numbers are zeros, e.g., 5:00 or 0:30.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nrformats-=octal&#xA;&#xA;# TYPE the following in insert mode, don't execute in normal mode:&#xA;0&quot;hdwx&quot;mdwj0:let @a='^Rh^A$^Rm^A'^M@a&#xA;&#xA;# (you can't record playing another macro.)&#xA;# To type the ^R etc. sequences, prefix them with ^V&#xA;&#xA;# Then yank the line into register q with &amp;lt;Esc&amp;gt;0&quot;qy$&#xA;&#xA;# Type the following in insert mode on a new line:&#xA;$60^X0^A&#xA;&#xA;# Then yank into register c with &amp;lt;Esc&amp;gt;0&quot;cy$&#xA;&#xA;# Next, run the following in normal mode:&#xA;16@q7@c&#xA;# The counts here are of course specific to the times I was adding.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Like I said, a little bit hacky, but easier than pulling out a calculator or doing it in your head (for a large list).&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2015-10-09T04:46:31.587" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5040" PostTypeId="2" ParentId="5028" CreationDate="2015-10-09T05:54:39.750" Score="3" Body="&lt;p&gt;Add this to a file &lt;code&gt;~/.vim/ftplugin/html.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tcomment#replacements_xml = {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-10-09T05:54:39.750" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5041" PostTypeId="2" ParentId="5038" CreationDate="2015-10-09T06:20:21.730" Score="2" Body="&lt;p&gt;The following are a function and a command that can be used with a range to achieve your goal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range Sum call s:sum()&#xA;&#xA;function! s:sum() range&#xA;  &quot; Get range boundaries&#xA;  let l1 = getpos(&quot;'&amp;lt;&quot;)[1]&#xA;  let l2 = getpos(&quot;'&amp;gt;&quot;)[1]&#xA;  if l2 &amp;lt;= l1 | return | endif&#xA;&#xA;  &quot; Calculate sum of seconds in provided range of lines&#xA;  let sum = 0&#xA;  for time in map(getline(l1,l2), 'split(v:val, '':'')')&#xA;    let sum += time[0]*60 + time[1]&#xA;  endfor&#xA;&#xA;  &quot; Delete lines and calculate time in format hh:mm:ss&#xA;  normal! gvd&#xA;  call setline(l1, printf('%02d:%02d:%02d',&#xA;        \ sum/3600,&#xA;        \ (sum % 3600)/60,&#xA;        \ sum % 60))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use this in your given example, you would simply do something like this: &lt;code&gt;ggV}:Sum&amp;lt;cr&amp;gt;&lt;/code&gt;. You may also map the command, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;leader&amp;gt;s :Sum&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;s gv:Sum&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-10-09T06:20:21.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5042" PostTypeId="2" ParentId="5037" CreationDate="2015-10-09T06:34:18.363" Score="3" Body="&lt;p&gt;Your problem is that &lt;code&gt;:command&lt;/code&gt; does not (by default) accept the use of bars, as explaind in &lt;code&gt;:h :bar&lt;/code&gt;. You may circumvent this by using the &lt;code&gt;-bar&lt;/code&gt; option, see &lt;code&gt;:h :command-bar&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar Tags execute '!GTAGSFORCECPP=1 gtags'&#xA;    \ | cscope kill -1&#xA;    \ | cscope add GTAGS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also wrap the functionality in a function, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Tags :call s:tags()&#xA;&#xA;function! s:tags()&#xA;  execute '!GTAGSFORCECPP=1 gtags' &#xA;  cscope kill -1&#xA;  cscope add GTAGS&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks to Christian Brabandt for mentioning the &lt;code&gt;-bar&lt;/code&gt; in the comments.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2015-10-09T09:11:38.010" LastActivityDate="2015-10-09T09:11:38.010" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5043" PostTypeId="2" ParentId="5038" CreationDate="2015-10-09T06:47:32.077" Score="2" Body="&lt;p&gt;Here's what I came up with, Karl was faster to post something more elegant but as I spend some time on it I think it couldn't hurt to share it :-)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Takes a string formatted H:M:S and convert it to seconds&#xA;function! ConvertToSecond(time)&#xA;    let l:cmp = split(a:time, &quot;:&quot;)&#xA;    let l:seconds = 0&#xA;&#xA;    if (len(l:cmp) == 1)&#xA;        let l:seconds = l:cmp[0]&#xA;    elseif (len(l:cmp) == 2)&#xA;        let l:seconds = l:cmp[1] + 60*l:cmp[0]&#xA;    elseif (len(l:cmp) == 3)&#xA;        let l:seconds = l:cmp[2] + 60*l:cmp[1] + 3600*l:cmp[0]&#xA;    endif&#xA;&#xA;    return l:seconds&#xA;endfunction&#xA;&#xA;&quot; Takes a number of seconds and convert it to h:m:s&#xA;function! ConvertFromSeconds(time)&#xA;    let l:time     = a:time&#xA;    let l:hours    = l:time / 3600&#xA;    let l:time     = l:time % 3600&#xA;    let l:minutes  = l:time / 60&#xA;    let l:time     = l:time % 60&#xA;    let l:seconds  = l:time&#xA;&#xA;    return l:hours . &quot;h&quot; . l:minutes . &quot;m&quot; . l:seconds . &quot;s&quot;&#xA;endfunction&#xA;&#xA;&quot; Iterate through line and append the sum on the next line&#xA;function! SumAndConvert() range&#xA;    let l:total = 0&#xA;&#xA;    if (a:firstline &amp;gt; a:lastline)&#xA;        echo &quot;Wrong range&quot;&#xA;        return&#xA;    endif&#xA;&#xA;    let l:line = a:firstline&#xA;    &quot; Read lines from current one to last one&#xA;    while (l:line &amp;lt;= a:lastline)&#xA;        let l:total  = l:total + ConvertToSecond(getline(l:line))&#xA;        let l:line   += 1&#xA;    endwhile&#xA;&#xA;    normal '&amp;gt; &#xA;    put = ConvertFromSeconds(l:total)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It can be called with a range like this for all the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,$call SumAndConvert()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or this for the last visual selection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;call SumAndConvert()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And of course it is possible to create user-defined commands to shorten the call.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2015-10-09T06:59:16.183" LastActivityDate="2015-10-09T06:59:16.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5044" PostTypeId="2" ParentId="5038" CreationDate="2015-10-09T07:23:11.610" Score="2" Body="&lt;p&gt;With &lt;a href=&quot;http://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow&quot;&gt;lh-vim-lib&lt;/a&gt; function &lt;code&gt;lh#list#accumulate()&lt;/code&gt;, and the following definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToSeconds(ms)&#xA;  let l = split(a:ms, ':')&#xA;  return l[0] * 60 + l[1]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it can be done with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo strftime('%H:%M:%S', eval(lh#list#accumulate(getline(1,'$'), 'ToSeconds', 'join(v:1_, &quot;+&quot;)')))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to make it a command, it could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToSeconds(ms)&#xA;  let l = split(a:ms, ':')&#xA;  return l[0] * 60 + l[1]&#xA;endfunction&#xA;&#xA;command! -range=% -narg=0 SumMinSec&#xA;      \ echo strftime('%H:%M:%S', eval(lh#list#accumulate(getline(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;), 'ToSeconds', 'join(v:1_, &quot;+&quot;)')))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NB: As you see, no need for modulo operation, we already have &lt;code&gt;strftime&lt;/code&gt;. However we lack &lt;code&gt;strptime&lt;/code&gt;, hence my &lt;code&gt;ToSeconds()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Or, a more &lt;em&gt;simple&lt;/em&gt; solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% -narg=0 SumMinSec&#xA;  \ echo strftime('%H:%M:%S',&#xA;  \     lh#list#accumulate2(&#xA;  \        lh#list#chain_transform(&#xA;  \           getline(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;),&#xA;  \           ['split(v:1_, &quot;:&quot;)', 'v:1_[0]*60 + v:1_[1]']),&#xA;  \        0))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2015-10-09T13:13:53.167" LastActivityDate="2015-10-09T13:13:53.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5045" PostTypeId="2" ParentId="5015" CreationDate="2015-10-09T09:07:55.967" Score="9" Body="&lt;p&gt;The best way is to learn &lt;em&gt;Vim&lt;/em&gt; your-self and demonstrate the power of it to others. Even you don't have to (demonstrate it) - it's self-promoting. Once you're using it with some fancy syntax colors on some hackish-like terminal background, people gets curious and often ask - &lt;em&gt;what the heck are you doing&lt;/em&gt;. Then show to them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you do pair programming and you see that another developer started doing some repeatable work which feels like a Sisyphean task (like hitting the &lt;em&gt;Backspace&lt;/em&gt; or arrows hundreds of time), tell him how much this annoys you as in &lt;em&gt;Vim&lt;/em&gt; it takes only few keystrokes in less than a second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also check the following pages for some useful Vim tricks:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/726894/55075&quot;&gt;What are the dark corners of Vim your mom never told you about?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/1276403/55075&quot;&gt;Simple VIM commands you wish you'd known earlier&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/74625/55075&quot;&gt;What is the best way to force yourself to master vi?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-10-10T18:14:43.353" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5046" PostTypeId="1" AcceptedAnswerId="5057" CreationDate="2015-10-09T09:57:10.057" Score="1" ViewCount="141" Body="&lt;p&gt;Suppose a source code interpreter outputs the error messages in the following format:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;M123 Warning path/to/file 123 Description message&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error_code error_type file line_number message&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I set &lt;code&gt;errorformat&lt;/code&gt; such that I get both the error_code and message in the quickfix window?&#xA;Please note that error_type can be any string, with and without numbers.&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="23502" LastEditDate="2022-11-05T10:54:45.310" LastActivityDate="2022-11-05T10:54:45.310" Title="How to merge multiple strings in errorformat?" Tags="|errorformat|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5048" PostTypeId="1" AcceptedAnswerId="5053" CreationDate="2015-10-09T10:18:55.653" Score="12" ViewCount="4382" Body="&lt;p&gt;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:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:w | make | cw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In that way:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;code&gt;:w&lt;/code&gt; vim command save editing&lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;:make&lt;/code&gt; INTERNAL vim command invoke the external make program using&#xA;makefile.&lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;:cw&lt;/code&gt; vim command the quickfix window showing list of errors and letting me to go directly to line where errors are.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;That's great! but (in case of compiler error) I have to press key &lt;kbd&gt;ENTER&lt;/kbd&gt; TWICE:&lt;/p&gt;&#xA;&lt;p&gt;a first time (in the shell):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;press ENTER or type command to continue&amp;quot; &lt;kbd&gt;ENTER&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;second time (inside the editor):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;press ENTER or type command to continue&amp;quot; &lt;kbd&gt;ENTER&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;BTW, I read about the &lt;code&gt;shortmess&lt;/code&gt; setting but didn't help this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set shortmess=aoOtI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Any idea to avoid to press enter and go directly to the quickfix windows ?&lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="23502" LastEditDate="2022-11-05T10:54:18.763" LastActivityDate="2022-11-05T10:54:18.763" Title="How to avoid to press ENTER twice, when compiling with :make inside Vim?" Tags="|command-line|external-command|ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5049" PostTypeId="2" ParentId="5038" CreationDate="2015-10-09T11:47:30.513" Score="2" Body="&lt;p&gt;One powerful function of vim is piping an area thru an external command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I think this is not what you are looking for, but, just for the record):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!awk -F: '{a=$2*60+$1} END {printf(&quot;\%d:\%02d&quot;,a/60,a\%60)}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;\thanks{Wildcard} for pointing out the &quot;&lt;code&gt;10:09&lt;/code&gt;&quot; problem and solution&lt;/p&gt;&#xA;" OwnerUserId="3002" LastEditorUserId="3002" LastEditDate="2016-03-18T00:10:20.890" LastActivityDate="2016-03-18T00:10:20.890" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5050" PostTypeId="1" AcceptedAnswerId="5052" CreationDate="2015-10-09T12:08:45.990" Score="14" ViewCount="1548" Body="&lt;p&gt;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 &lt;code&gt;~/.vim/spell/en.utf-8.add&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;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 machines, and I don't need to add it once on each machine. I tried versioning &lt;code&gt;~/.vim/spell/en.utf-8.add&lt;/code&gt; in git, but this does not seem to work: vim does not pick up the new terms. I suspect that Vim also needs the file &lt;code&gt;en.utf-8.add.spl&lt;/code&gt; to be edited somehow, but as this file is binary, versioning it will probably lead to conflicts.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone here have a satisfactory solution to have vim spellcheck dictionary additions as part of their config, and synchronizing them between all of their machines?&lt;/p&gt;&#xA;" OwnerUserId="4819" LastEditorUserId="23502" LastEditDate="2022-11-05T10:53:10.673" LastActivityDate="2022-11-05T10:53:10.673" Title="How to share Vim spellchecking additions between multiple machines?" Tags="|spell-checking|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5051" PostTypeId="2" ParentId="5050" CreationDate="2015-10-09T13:38:30.317" Score="0" Body="&lt;p&gt;I sync my .vim folder to my machines using Dropbox. Whenever I've made a change to my configuration, I'll throw it back onto Dropbox and pull it down on my other machines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the commands set in my .bashrc file so I can save some typing. My Vim install isn't too complex, so it's pretty quick to sync when I make a change. Not sure how it'd handle an exceptionally large .vim folder.&lt;/p&gt;&#xA;" OwnerUserId="4823" LastActivityDate="2015-10-09T13:38:30.317" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5052" PostTypeId="2" ParentId="5050" CreationDate="2015-10-09T13:44:18.387" Score="19" Body="&lt;p&gt;Vim uses the &lt;code&gt;spl&lt;/code&gt; file to do the checks, and the &lt;code&gt;spl&lt;/code&gt; file is generated from the &lt;code&gt;add&lt;/code&gt; file.  We can speculate on whether the &lt;code&gt;spl&lt;/code&gt; file is portable across different machines and Vim versions, but it's easier (and safer) to re-generate it as needed.  Now, the &lt;code&gt;spl&lt;/code&gt; file is re-generated automatically when you add words to your local dictionary from within Vim, but you must run &lt;code&gt;mkspell&lt;/code&gt; to re-generate it if you edit the &lt;code&gt;add&lt;/code&gt; file directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that in mind, you can do something like this: synchronize the &lt;code&gt;add&lt;/code&gt; file by whatever means (with &lt;code&gt;git&lt;/code&gt;, &lt;code&gt;rsync&lt;/code&gt;, NFS, or whatever), and add these commands to your &lt;code&gt;vimrc&lt;/code&gt; on all machines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for d in glob('~/.vim/spell/*.add', 1, 1)&#xA;    if filereadable(d) &amp;amp;&amp;amp; (!filereadable(d . '.spl') || getftime(d) &amp;gt; getftime(d . '.spl'))&#xA;        exec 'mkspell! ' . fnameescape(d)&#xA;    endif&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will re-generate the &lt;code&gt;spl&lt;/code&gt; file at Vim startup whenever the corresponding &lt;code&gt;add&lt;/code&gt; file is newer than it.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="2313" LastEditDate="2015-10-09T14:04:45.423" LastActivityDate="2015-10-09T14:04:45.423" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5053" PostTypeId="2" ParentId="5048" CreationDate="2015-10-09T14:30:48.313" Score="12" Body="&lt;p&gt;Vim displays the &quot;Press ENTER&quot; 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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue has been &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/message.html#press-enter&quot;&gt;documented in Vim's help&lt;/a&gt; (&lt;code&gt;:h press-enter&lt;/code&gt;) and also &lt;a href=&quot;http://vim.wikia.com/wiki/Avoiding_the_%22Hit_ENTER_to_continue%22_prompts&quot;&gt;addressed on the VimTips wiki&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Make more space for messages&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;An easy and reliable fix is to increase the size of the command-line area.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cmdheight=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this has the disadvantage of using up extra screen space.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Reduce number/size of messages&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Reducing the number of lines printed by &lt;code&gt;:w&lt;/code&gt; and &lt;code&gt;:make&lt;/code&gt; could also help:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:silent w&lt;/code&gt; or &lt;code&gt;:silent make&lt;/code&gt; so they don't display anything.&lt;/li&gt;&#xA;&lt;li&gt;Make messages shorter with &lt;code&gt;:set shortmess=a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Handle the prompt with a keymap&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you know you will always get a prompt when you run a particular mapping, then you can add &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to the mapping to answer the prompt for you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a &lt;strong&gt;dirty solution&lt;/strong&gt;, because if later the prompt is not displayed (e.g. you increase &lt;code&gt;cmdheight&lt;/code&gt; or decrease the number of messages) then the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; will still be sent!  That's not a big problem if Normal mode interprets it as &quot;go to beginning of next line&quot;, but it could be more disruptive if focus was on the quickfix list, or an explorer window, where &lt;kbd&gt;Enter&lt;/kbd&gt; performs a more significant action.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-10-12T14:13:09.200" LastActivityDate="2015-10-12T14:13:09.200" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5054" PostTypeId="2" ParentId="5038" CreationDate="2015-10-09T14:38:55.503" Score="1" Body="&lt;p&gt;In this specific case, I'd use plain substitution with the &lt;code&gt;sub-replace-\=&lt;/code&gt;, where you can enter an expression that is evaluated before doing the substitution. Things to keep in mind when using &lt;code&gt;\=&lt;/code&gt; in the substitution are that special meaning for characters (in &lt;code&gt;:h sub-replace special&lt;/code&gt;) does not apply and that text matched with &lt;code&gt;\( \)&lt;/code&gt; need to be accessed with &lt;code&gt;submatch(1)&lt;/code&gt; etc. &lt;code&gt;submatch(0)&lt;/code&gt; contains the whole matched text. For full details, you can see &lt;code&gt;:h sub-replace-\=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Going from format &lt;code&gt;HH:MM:SS&lt;/code&gt; to sum in seconds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;01:02:26&#xA;03:04&#xA;03:14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can be done with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(\(\d\+\):\)\?\(\d\+\):\(\d\+\)/\=submatch(2)*3600+submatch(3)*60+submatch(4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the hours are optional. Now we have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3746&#xA;184&#xA;194&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which we can yank (clearing the register first) using the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=&quot;&quot; | %y A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To calculate the sum to the last line, we can use &lt;code&gt;:put&lt;/code&gt; in combination with the expression register &lt;code&gt;@=&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$put =eval('0' . substitute(@a, '\n', '+', 'g') . '0')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where we substitute newlines in the register with &lt;code&gt;+&lt;/code&gt; signs using the function &lt;code&gt;substitute()&lt;/code&gt;. The register also contains newlines in the beginning and at the end, so we need to pad it with zeroes on both ends. This results in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3746&#xA;184&#xA;194&#xA;4124&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To go in the other direction (from seconds to &lt;code&gt;HH:MM:SS&lt;/code&gt;), you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s@\d\+@\=printf(&quot;%02d:%02d:%02d&quot;, submatch(0)/3600, submatch(0)%3600/60, submatch(0)%60)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where you need to use some other character than &lt;code&gt;/&lt;/code&gt; as a delimiter, since it is used in the expression. I chose to use &lt;code&gt;@&lt;/code&gt;. In the end, we get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;01:02:26&#xA;00:03:04&#xA;00:03:14&#xA;01:08:44&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1672" LastEditorUserId="1672" LastEditDate="2015-10-11T16:34:35.790" LastActivityDate="2015-10-11T16:34:35.790" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5055" PostTypeId="1" AcceptedAnswerId="5059" CreationDate="2015-10-09T15:34:03.800" Score="13" ViewCount="7645" Body="&lt;p&gt;I've seen &lt;code&gt;set exrc&lt;/code&gt; mentioned in various places for using per-directory &lt;code&gt;.vimrc&lt;/code&gt; files, but every time it's been mentioned it's been with strong admonition not to actually use it because it's dangerous. I've also come across &lt;code&gt;set secure&lt;/code&gt; which is supposed to fix some of the inherit danger of &lt;code&gt;set exrc&lt;/code&gt;, but even with that the consensus seems to be not to use &lt;code&gt;set exrc&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've heard bits and pieces of why, but what exactly are the dangers of using &lt;code&gt;set exrc&lt;/code&gt;, with or without &lt;code&gt;set secure&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1166" LastActivityDate="2015-10-09T17:09:02.270" Title="Why is set exrc dangerous?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5056" PostTypeId="1" AcceptedAnswerId="5429" CreationDate="2015-10-09T15:45:44.203" Score="4" ViewCount="264" Body="&lt;p&gt;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?&lt;/p&gt;&#xA;" OwnerUserId="1166" LastActivityDate="2015-11-10T00:36:31.990" Title="Save functions in a session" Tags="|sessions|functions|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5057" PostTypeId="2" ParentId="5046" CreationDate="2015-10-09T16:15:42.990" Score="0" Body="&lt;p&gt;You can't do this with &lt;code&gt;errorformat&lt;/code&gt; alone, but there are a couple of ways to do it. One is to filter the output of your interpreter with another program like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set mp=make\ \\\|&amp;amp;\ error_filter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as explained in an un-indexed paragraph in the reference manual. To find it, execute &lt;code&gt;:help quickfix-directory-stack&lt;/code&gt; and scroll up to the previous section titled &quot;Filtering messages&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way is to post-process the contents of the quickfix list as described under &lt;code&gt;:help QuickFixCmdPost-example&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using either method, edit the error message to put &lt;code&gt;error_code&lt;/code&gt; next to &lt;code&gt;message&lt;/code&gt; and use an &lt;code&gt;errorformat&lt;/code&gt; that sees them together as just a message (&lt;code&gt;%m&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-10-09T16:15:42.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5058" PostTypeId="1" AcceptedAnswerId="5060" CreationDate="2015-10-09T16:55:28.843" Score="2" ViewCount="256" Body="&lt;p&gt;Cannot figure out how to use the output of :pwd as argument to :helptags. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helptags . exec ':pwd'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tried many combinations of |, :exec, :call and ! . &lt;/p&gt;&#xA;" OwnerUserId="1378" LastActivityDate="2015-10-09T17:23:17.260" Title="Using command output as argument to another command" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5059" PostTypeId="2" ParentId="5055" CreationDate="2015-10-09T17:09:02.270" Score="17" Body="&lt;p&gt;Because you're telling vim to perform some commands from a file you may not have control over or someone else could have written. Say you grab something from github, and deep in the tree there's a .vimrc. If you vim something in that directory and have &lt;code&gt;set exrc&lt;/code&gt;, you're telling vim to run the commands in the .vimrc you got from github. Do you completely trust whoever created that file? Because you're letting vim run whatever commands they put in that file. Or say you're on a machine regularly used by multiple people (they still exist :-) ), and someone asks you to look at something in their home directory (or /tmp, or any place they can write to). You cd there, it's a text file, so you do a &lt;code&gt;vim file&lt;/code&gt;. With &lt;code&gt;set exrc&lt;/code&gt;, you're also telling vim to run the commands in .vimrc in that directory. Do you completely trust that user, or in a world writable directory like /tmp, every user who can log in to that machine?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set secure&lt;/code&gt; mitigates the problem somewhat by limiting some things that can be done in a .vimrc, but if the per-directory .vimrc can made to be owned by you (such as in the github example, or on a multi-user machine where some users can chown files to you), &lt;code&gt;set secure&lt;/code&gt; is ignored, so you still have the same problems.&lt;/p&gt;&#xA;" OwnerUserId="4620" LastActivityDate="2015-10-09T17:09:02.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5060" PostTypeId="2" ParentId="5058" CreationDate="2015-10-09T17:23:17.260" Score="5" Body="&lt;p&gt;Backticks can be used many places, so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helptags `pwd`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will do what you want, although so will:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helptags .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other uses would be things like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e `date +\%Y-\%m-\%d`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which edits a file whose name is the current date in the format YYYY-MM-DD (the backslashes are because % is a special character there).&lt;/p&gt;&#xA;" OwnerUserId="4620" LastActivityDate="2015-10-09T17:23:17.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5061" PostTypeId="1" AcceptedAnswerId="5062" CreationDate="2015-10-09T18:08:48.573" Score="0" ViewCount="225" Body="&lt;p&gt;I have readonly &lt;code&gt;/usr&lt;/code&gt; partition and &lt;code&gt;:helptags&lt;/code&gt; returns an error about not being able to write to &lt;code&gt;/usr/share/vim/vim74/doc&lt;/code&gt;. Is it possible to specify additional/another directory for help tags?&lt;/p&gt;&#xA;" OwnerUserId="1378" LastActivityDate="2015-10-09T18:48:12.573" Title="Is it possible to generate help tags with readonly '/usr'?" Tags="|help-system|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5062" PostTypeId="2" ParentId="5061" CreationDate="2015-10-09T18:48:12.573" Score="1" Body="&lt;p&gt;You normally shouldn't be trying to put help tags into &lt;code&gt;/usr/share/vim/vim74/doc&lt;/code&gt;. That directory already contains a &lt;code&gt;tags&lt;/code&gt; file. Any plugins that you install should go into your &lt;code&gt;~/.vim&lt;/code&gt; directory and the resulting help tags into &lt;code&gt;~/.vim/doc&lt;/code&gt;. Do that by executing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helptags ~/.vim/doc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help add-local-help&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just to round out the answer, if you're adding plugins for use by all users and not just you, you could put them in &lt;code&gt;/usr/share/vim/vimfiles&lt;/code&gt; and build a help tags file there with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helptags /usr/share/vimfiles/doc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That wouldn't work in your particular case, though, because you wouldn't be able to write to that directory, either.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-10-09T18:48:12.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5063" PostTypeId="1" AcceptedAnswerId="5064" CreationDate="2015-10-09T19:38:30.193" Score="6" ViewCount="325" Body="&lt;p&gt;Sometimes I copy text from the buffer in VM and I want to use it in an editor command.  Is there some way to paste it from a register into the command text using only the keyboard?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2015-10-09T20:01:45.493" Title="Is there a way to paste text from a buffer into your command using just the keyboard?" Tags="|command-line|register|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5064" PostTypeId="2" ParentId="5063" CreationDate="2015-10-09T19:55:41.760" Score="11" Body="&lt;p&gt;Yep, just like in insert mode: &lt;code&gt;Ctrl-R&lt;/code&gt; followed by the register name, or &lt;code&gt;&quot;&lt;/code&gt; for the default one (i.e. &lt;code&gt;Ctrl-R &quot;&lt;/code&gt;). See &lt;code&gt;:h c_CTRL-R&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-10-09T20:01:45.493" LastActivityDate="2015-10-09T20:01:45.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5066" PostTypeId="1" AcceptedAnswerId="5071" CreationDate="2015-10-09T21:41:40.083" Score="4" ViewCount="585" Body="&lt;p&gt;Most of the time I'd like &lt;code&gt;noexpandtab&lt;/code&gt; on because our corporate formatting uses tabs instead of spaces, so in my &lt;code&gt;.vimrc&lt;/code&gt; I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set tab width stuff&#xA;set tabstop=4 softtabstop=0 noexpandtab shiftwidth=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is annoying though is when I am writing my git commit messages and tabs come in, I'd like those to be spaces. I know I could just do &lt;code&gt;:set expandtab&lt;/code&gt; when I'm writing a commit message but it seems annoying to do every time. Surely there is a better way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For what it's worth I'm running vim through git bash in Git for Windows.&lt;/p&gt;&#xA;" OwnerUserId="4833" LastEditorUserId="4833" LastEditDate="2015-10-12T13:43:06.330" LastActivityDate="2015-10-12T13:43:06.330" Title="How can I set expandtab but only for git commit messages?" Tags="|vimrc|tab-characters|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5067" PostTypeId="1" AcceptedAnswerId="5070" CreationDate="2015-10-10T00:03:02.757" Score="5" ViewCount="424" Body="&lt;p&gt;Is it possible to make the surround plugin work on &lt;code&gt;`TeX-style quotes'&lt;/code&gt; and &lt;code&gt;``TeX-style double quotes''&lt;/code&gt;? (Normally, if &lt;code&gt;`this is quoted'&lt;/code&gt;| and &lt;code&gt;`this'&lt;/code&gt;, &lt;code&gt;va'&lt;/code&gt; will select from the first closing mark to the second (if the cursor is at |).)&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="1292" LastEditDate="2017-08-10T07:00:50.587" LastActivityDate="2017-08-14T13:43:52.853" Title="surround plugin and TeX quotes `'" Tags="|cursor-motions|plugin-vim-surround|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5069" PostTypeId="1" CreationDate="2015-10-10T03:12:32.263" Score="3" ViewCount="3784" Body="&lt;p&gt;When editing with vi or Vim &amp;quot;insert&amp;quot; or replace popup text does not appear when in insert or replace mode.&lt;/p&gt;&#xA;&lt;p&gt;This problem occurs both with Windows 7 and Putty interface and with Mac and Iterm2 interface.  Also, the problem is strange since it does not appear for one Windows 7 PC I use.&lt;/p&gt;&#xA;" OwnerUserId="4835" LastEditorUserId="23502" LastEditDate="2022-11-05T10:52:13.813" LastActivityDate="2022-11-05T10:52:13.813" Title="vi and Vim does not show &quot;insert&quot; or &quot;replace&quot; popup" Tags="|insert-mode|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5070" PostTypeId="2" ParentId="5067" CreationDate="2015-10-10T03:21:08.687" Score="7" Body="&lt;p&gt;You can create a customize surround by defining a variable &lt;code&gt;g:surround_{key code}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for example you could do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:surround_96 = &quot;`\r'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where 96 is the key code for &lt;code&gt;`&lt;/code&gt;. You can make this more readable by putting by letting vim determine the key code by using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:surround_{char2nr(&quot;`&quot;)} = &quot;`\r'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\r&lt;/code&gt; will be replaced by the relevant text. If you only want this to work in tex files you can put it in an autocmd&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType tex let b:surround_{char2nr(&quot;`&quot;)} = &quot;`\r'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usage would be &lt;code&gt;ysiw`&lt;/code&gt;. Read &lt;code&gt;:help surround-customizing&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2015-10-10T03:21:08.687" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5071" PostTypeId="2" ParentId="5066" CreationDate="2015-10-10T08:30:27.060" Score="8" Body="&lt;p&gt;&lt;strong&gt;First possibility&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following line to your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType gitcommit setlocal expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Second possibility&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a file &lt;code&gt;~/.vim/after/ftplugin/gitcommit.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and in there put:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setlocal expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See the faq:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-14.11&quot;&gt;How do I configure Vim to automatically set the 'textwidth' option to a particular value when I edit mails&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-26.3&quot;&gt;How do I extend an existing filetype plugin?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-26.1&quot;&gt;How do I set different options for different types of files?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="71" LastEditorUserId="205" LastEditDate="2015-10-10T12:05:23.183" LastActivityDate="2015-10-10T12:05:23.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5072" PostTypeId="1" CreationDate="2015-10-10T09:29:48.820" Score="2" ViewCount="321" Body="&lt;p&gt;I am looking for a way to enhance vim gf command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Myclass&#xA;  include Mymodules::HardToFind&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have started with installing &lt;a href=&quot;https://github.com/tpope/vim-rails&quot; rel=&quot;nofollow&quot;&gt;tpope/rails-vim&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Easy navigation of the Rails directory structure. gf considers context&#xA;  and knows about partials, fixtures, and much more.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But I think I have a problem with path variable in my vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When my cursor is a the beginning of the &lt;strong&gt;include&lt;/strong&gt; and I hit gf I am getting: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E345: Can't find file &quot;include&quot; in path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I move it at the beginning of &lt;strong&gt;Mymodules::HardToFind&lt;/strong&gt; I am getting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E345: Can't find file &quot;mymodules/hard_to_find.rb&quot; in path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;So the first problem is the path - How should I configure it?&lt;/li&gt;&#xA;&lt;li&gt;Second one is it possible to have the file loaded regardless of the cursor position in a given line?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4594" LastActivityDate="2015-10-10T09:29:48.820" Title="Enhancing Vim gf command for ruby: include module syntax" Tags="|vimrc|filetype-ruby|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5073" PostTypeId="1" CreationDate="2015-10-10T13:00:45.210" Score="0" ViewCount="753" Body="&lt;p&gt;When editing with Vim on Macbook Pro with Iterm2 interface I can copy text by:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;highlighting text with left-button double click on mouse,&lt;/li&gt;&#xA;&lt;li&gt;paste text by pressing center wheel on mouse.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Instead of (2) I would much prefer pasting the text by right-clicking the mouse button.&lt;/p&gt;&#xA;&lt;p&gt;A related problem is that when highlighting the text in one window and pasting into another, the active window does not switch from window 1 to window 2; the active window remains window 1 but I would much prefer a switch to window 2.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to fix these two problems?&lt;/p&gt;&#xA;" OwnerUserId="4835" LastEditorUserId="23502" LastEditDate="2022-11-05T10:51:29.330" LastActivityDate="2022-11-05T10:51:29.330" Title="vi or Vim: Mac/Iterm 2 highlight-paste" Tags="|cut-copy-paste|macos|iterm2|" AnswerCount="1" CommentCount="2" ClosedDate="2017-11-18T01:39:21.980" ContentLicense="CC BY-SA 4.0" />
  <row Id="5075" PostTypeId="2" ParentId="5015" CreationDate="2015-10-10T20:06:15.330" Score="11" Body="&lt;p&gt;Most importantly: don't push, don't evangelize. Be absolutely sure about your motivation. If there is even a hint of missionary work, don't start. The overwhelming majority of people react either annoyed or aggressive, because the mere suggestion to check out another workflow carries an undercurrent of criticism. That your workflow may be better than theirs. Which closes many people off. Actually, this is a general principle that works regardless of setting (think Vegetarians/Meat eaters, Democrats/Republicans, car brands, recipes, …) They all do what they do because they believe what they do is the right way to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It may very well be that no criticism from your side is intended in the first place, but this happens on the other side and there's nothing you can do about it. That's humans for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest bringing the subject up when there is no deadline, in a relaxed setting. Talk from &lt;strong&gt;your&lt;/strong&gt; experience, in a way how impressed &lt;strong&gt;you&lt;/strong&gt; were and how much more efficient &lt;strong&gt;you&lt;/strong&gt; feel now. Never compare. Never say &quot;it's better&quot;, as that would be an absolute statement, just asking to be challenged. Always go with &quot;I'm more productive this way&quot;. This way the other person cannot dismiss that &lt;strong&gt;you&lt;/strong&gt; may indeed be more productive and you don't apply any pressure. If the other picks the topic up, be gentle and maybe offer to share a link or two, Vimcasts is a great resource for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Learning Vim is a hell of a task, especially considering the insane amount of time you invest to get your very first setup right. I had so many question marks in my head during that time and about every second setting seemed nonsensical or even hostile. It's the opposite of intuitive. Either someone sticks with it and gets progressively more &quot;aha!&quot; moments or will just drop it for a more Word-like editor. Whatever works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end it's really not worth any debate: everybody just uses what gets the job done. That's the beauty of source code: it's universal.&lt;/p&gt;&#xA;" OwnerUserId="4845" LastEditorUserId="4845" LastEditDate="2015-10-10T20:14:39.407" LastActivityDate="2015-10-10T20:14:39.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5076" PostTypeId="1" CreationDate="2015-10-10T23:48:53.993" Score="6" ViewCount="331" Body="&lt;p&gt;Is it possible to apply an ex command to something smaller than a line? For instance, I tried to define a mapping that would remove an \emph{} from the enclosed word. The best I could do was:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap dsi vaW:s/\\emph{//\|s/}//&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out that this does not operate on the selection but rather on the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. I am satisfied with the comments to the effect that &lt;code&gt;:s&lt;/code&gt; can operate on selections if &lt;code&gt;\%V&lt;/code&gt; is placed at the beginning of the pattern.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2015-10-11T14:25:38.787" LastActivityDate="2016-02-06T18:32:53.810" Title="Applying an ex command to a visual selection or text object" Tags="|visual-mode|cursor-motions|ex-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5077" PostTypeId="2" ParentId="5069" CreationDate="2015-10-11T11:45:58.347" Score="2" Body="&lt;p&gt;The &lt;code&gt;showmode&lt;/code&gt; option is automatically enabled when you run Vim in &quot;nocompatible mode&quot; and automatically disabled if you run Vim in &quot;compatible mode&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;compatible mode&quot; is the default, it means Vim tries its best to behave like the original Vi, which is extremely annoying and impractical, therefore it is recommended to run Vim in &quot;nocompatible mode&quot;. This can be achieved…&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;by using the &lt;code&gt;-N&lt;/code&gt; flag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -N foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;or by executing that command in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nocompatible&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;or by having a custom &lt;code&gt;vimrc&lt;/code&gt; (empty or not) at any one of these default locations:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;on unix-like systems&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$HOME/.vimrc&#xA;$HOME/.vim/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;on windows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%userprofile%\_vimrc&#xA;%userprofile%\vimfiles\vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-10-11T11:45:58.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5078" PostTypeId="2" ParentId="5073" CreationDate="2015-10-11T11:53:40.270" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Get yourself &lt;a href=&quot;https://github.com/macvim-dev/macvim/releases&quot; rel=&quot;nofollow&quot;&gt;a proper Vim&lt;/a&gt; with clipboard support.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Place the bundled &lt;code&gt;mvim&lt;/code&gt; script somewhere in your &lt;code&gt;$PATH&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add an alias to your &lt;code&gt;~/.bashrc&lt;/code&gt; or whatever init file is used by your shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vim='/path/to/mvim -v'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;&quot;+y&lt;/code&gt; and &lt;code&gt;&quot;+p&lt;/code&gt; to yank to and put from the system clipboard.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-10-11T11:53:40.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5079" PostTypeId="2" ParentId="5015" CreationDate="2015-10-11T14:25:05.013" Score="10" Body="&lt;p&gt;The first time I used vi was in an &quot;intro to Unix&quot; class.  The teacher didn't know it very well, and he introduced it in a very clunky way.  We had to memorize enough to get around if we ever got stuck in a system that didn't have anything else installed.  I didn't take a second look after that semester.  That's how you &lt;em&gt;don't&lt;/em&gt; evangelize vi, and I think is how a lot of people had their first experience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few years later, I was in a corporate continuing education class about Perl.  The instructor used vim in his demonstrations and offered to help people with it on the side, even though it wasn't the primary purpose of the class.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An unofficial motto of Perl is TMTOWTDI (there's more than one way to do it).  As the class would ask questions, the instructor would make edits to show alternatives, &lt;strong&gt;faster than he could describe the edits in words&lt;/strong&gt;.  I was accustomed to being able to read code as it was being edited, but for him, editing happened in a flurry of keys, then the explanation followed, at glacial speed in comparison.  If he didn't have to stop to explain the edit to us, he would have already moved on to the next task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a fair few similar opportunities to demonstrate vim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Scrum meetings&lt;/li&gt;&#xA;&lt;li&gt;Pair programming&lt;/li&gt;&#xA;&lt;li&gt;Tech talks&lt;/li&gt;&#xA;&lt;li&gt;Software demonstrations&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think just showing people its potential after you learn it will inspire them to push past the initial clunkiness.&lt;/p&gt;&#xA;" OwnerUserId="780" LastActivityDate="2015-10-11T14:25:05.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5080" PostTypeId="1" AcceptedAnswerId="5081" CreationDate="2015-10-11T14:29:34.807" Score="16" ViewCount="464" Body="&lt;p&gt;&lt;code&gt;:s/pattern/replacement&lt;/code&gt; operates on the first match and&#xA;&lt;code&gt;:s/pattern/replacement/g&lt;/code&gt; on all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to operate only on the last one?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2016-03-24T19:58:30.377" LastActivityDate="2017-07-01T06:00:02.587" Title="Can I make :s operate only on the last match of the line?" Tags="|substitute|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5081" PostTypeId="2" ParentId="5080" CreationDate="2015-10-11T14:39:20.870" Score="18" Body="&lt;p&gt;I would use &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5Czs&quot;&gt;&lt;code&gt;\zs&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.*\zspattern/replacement/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A little bit of explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt; represents any single character&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;*&lt;/code&gt; represents greedy matching (as many as possible)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In Vim you can use zero-width anchors &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; to define the start and the end of the searched pattern, which you wish to match. Anything before &lt;code&gt;\zs&lt;/code&gt; and after &lt;code&gt;\ze&lt;/code&gt; in your pattern will remain unaffected by replacement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it easy to understand, I would like to use this example from &lt;a href=&quot;http://vim.wikia.com&quot;&gt;wikia&lt;/a&gt;'s &lt;a href=&quot;http://vim.wikia.com/wiki/Search_and_replace&quot;&gt;Search and replace&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Save typing by using &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; to set the start and end of a&#xA;  pattern. For example, instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/Copyright 2007 All Rights Reserved/Copyright 2008 All Rights Reserved/ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/Copyright \zs2007\ze All Rights Reserved/2008/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For more information, look at&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5Czs&quot;&gt;&lt;code&gt;:h \zs&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#pattern-overview&quot;&gt;&lt;code&gt;:h pattern-overview&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2961" LastEditorUserId="2961" LastEditDate="2015-10-13T20:53:44.217" LastActivityDate="2015-10-13T20:53:44.217" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5082" PostTypeId="1" CreationDate="2015-10-11T16:08:08.273" Score="10" ViewCount="437" Body="&lt;p&gt;Caveat: I'm not a web developer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, there are rare occasions where I have to edit HTML. When I do, I've noticed a behavior in Vim that I don't like, and hope that I can change via configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I code, I tend to wrap lines at 80 characters. This often means that I have to split HTML tags across lines. What I'd like is some sensible indentation when this happens. So, for example, I might have the following code and would like it indented similarly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;a href=&quot;http://someverylongurl.com/foo/bar/blaz/SinwzvO.jpg&quot;&amp;gt;&amp;lt;img&#xA;   src=&quot;http://someverylongurl.com/foo/bar/blaz/Sinwzv0.jpg&quot;&#xA;   class=&quot;ri&quot; alt=&quot;This is an image&quot;&amp;gt;&amp;lt;/a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, by default, Vim's autoindentation will indent the split HTML tags to the same level as the HTML tag start on the previous line. In other words, I get something like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;a href=&quot;http://someverylongurl.com/foo/bar/blaz/SinwzvO.jpg&quot;&amp;gt;&amp;lt;img&#xA;                                                              src=&quot;http://someverylongurl.com/foo/bar/blaz/Sinwzv0.jpg&quot;&#xA;                                                              class=&quot;ri&quot; alt=&quot;This is an image&quot;&amp;gt;&amp;lt;/a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is, exactly, what I don't want. As I'm typing, I find I'm &lt;em&gt;constantly&lt;/em&gt; having to go back and fix indentations like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like Vim's autoindent generally, and don't want to simply disable it universally. I'd rather just disable or change the split HTML tag indentation, but I can't figure out how.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to change this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I've tried searching Stackoverflow for this question, but couldn't find it. If it's a duplicate, please point me to the original.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Solution was found here &lt;a href=&quot;https://www.reddit.com/r/vim/comments/3ogbna/disabling_partial_html_indentation_in_vim/cvy8p3u&quot; rel=&quot;noreferrer&quot;&gt;https://www.reddit.com/r/vim/comments/3ogbna/disabling_partial_html_indentation_in_vim/cvy8p3u&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT #2: Okay, the above solution didn't solve the problem. It's still there.&lt;/p&gt;&#xA;" OwnerUserId="4854" LastEditorUserId="4854" LastEditDate="2015-10-16T18:28:31.933" LastActivityDate="2021-07-13T18:35:54.250" Title="Disabling partial HTML indentation in Vim" Tags="|indentation|filetype-html|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5084" PostTypeId="1" CreationDate="2015-10-12T21:21:36.797" Score="14" ViewCount="2162" Body="&lt;p&gt;Contracts etc formal things need numbered lists.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. Some text&#xA;&#xA;2. More text&#xA;&#xA; 2.1. Sub-section text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key is to eliminate the manual re-numbering when inserting or deleting a list item. Is this possible with &lt;code&gt;vim&lt;/code&gt;? List numbering consistency is really difficult to keep track of manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the associated goals with this is to have proper revision control made possible by a non-obfuscated storage format, such as clear text.&lt;/p&gt;&#xA;" OwnerUserId="2301" LastEditorUserId="2301" LastEditDate="2015-10-12T21:44:46.150" LastActivityDate="2015-10-14T07:42:35.203" Title="How to achieve automatic list numbering in vim?" Tags="|insert-mode|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5087" PostTypeId="1" AcceptedAnswerId="5090" CreationDate="2015-10-13T15:23:26.363" Score="8" ViewCount="196" Body="&lt;p&gt;For example, let's say I want to put a number before every line that starts with the word &quot;Do&quot;.  The command would look something like &lt;code&gt;:%s/^(Do )/1. \1/&lt;/code&gt;, but what can I do so it will apply numbers consecutively instead of the same number each time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I'm well aware of the numerous ways to do this using macros and Ctrl-A, but for use in more complicated Ex-mode commands I would like to know the answer to exactly the title question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For another example where a macro approach wouldn't be so easy, let's say I want to append a number to all instances of the word &quot;Section&quot;, and have them consecutively numbered but restarting the count after each line that starts &quot;Chapter&quot;.  An Ex-mode command that can &lt;em&gt;almost&lt;/em&gt; do this, save for actually incrementing the number to be added, is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:g/^Chapter/;/^Chapter/-s/Section\zs/ 1/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see that an easy method of incrementing numbers in the Ex-mode substitute command could be very useful.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2015-10-14T08:12:32.703" Title="How can I use consecutive numbers in an Ex-style substitute command?" Tags="|ex-mode|replace|variables|global-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5088" PostTypeId="1" CreationDate="2015-10-13T15:39:34.820" Score="3" ViewCount="1465" Body="&lt;p&gt;I have remapped &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; to easily cycle through my open buffers. I don't understand why when I use this shortcut there is a delay of almost a second before the buffer is switched. This doesn't happen when I use &lt;code&gt;gn&lt;/code&gt; or &lt;code&gt;:bnext&lt;/code&gt;. &#xA;This is how do mapping: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; ] :bnext&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; [ :bprevious&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you help me? &lt;/p&gt;&#xA;" OwnerUserId="1620" LastActivityDate="2015-10-14T23:53:46.497" Title="Remapping [ and ] is really slow" Tags="|key-bindings|normal-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5089" PostTypeId="1" AcceptedAnswerId="5988" CreationDate="2015-10-13T16:05:42.713" Score="1" ViewCount="395" Body="&lt;p&gt;Texas Instruments has a custom assembly language for its &lt;a href=&quot;http://processors.wiki.ti.com/index.php/Programmable_Realtime_Unit_Subsystem&quot; rel=&quot;nofollow&quot;&gt;programmable real-time unit subsystems (PRUSS)&lt;/a&gt;. &lt;a href=&quot;http://processors.wiki.ti.com/index.php/PASM_Syntax_Highlighting&quot; rel=&quot;nofollow&quot;&gt;TI provides syntax files&lt;/a&gt; for Notepad++ and Textpad, but I cannot find any syntax files for Vim. I'd be a bit surprised if no one had made on yet, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now, I'm using &lt;code&gt;ft=c&lt;/code&gt;, which is okay but not ideal.&lt;/p&gt;&#xA;" OwnerUserId="1060" LastActivityDate="2018-05-23T08:58:30.053" Title="Is there a syntax file for TI's PRUSS assembly language?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5090" PostTypeId="2" ParentId="5087" CreationDate="2015-10-13T16:25:29.517" Score="8" Body="&lt;p&gt;This command does what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i = 1|g/^Do/s/^/\=i/|let i = i + 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation…&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;let i = 1&lt;/code&gt; initializes counter &lt;code&gt;i&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g/^Do/s/^/\=i/&lt;/code&gt; prepends &lt;code&gt;i&lt;/code&gt; to each line starting with &lt;code&gt;Do&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;let i = i + 1&lt;/code&gt; increments &lt;code&gt;i&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The trick is that the incrementation happens before the next substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--- edit ---&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we used a single substitution, the counter would only be incremented once, after everything is done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since we are performing multiple substitutions — one for each matching line — instead of a single one, the counter is correctly incremented before the next substitution.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-10-14T08:12:32.703" LastActivityDate="2015-10-14T08:12:32.703" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5091" PostTypeId="1" AcceptedAnswerId="5093" CreationDate="2015-10-13T17:18:08.040" Score="15" ViewCount="1222" Body="&lt;p&gt;If I want to delete every word, that is easy, because I would do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s%/WORD//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what if I want to do &lt;code&gt;xyz&lt;/code&gt; to every occurrence of &quot;WORD&quot;? For example, let's say I want to delete every line that contains &quot;WORD&quot;. I can think of a couple ways to do this, but none of them seem ideal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/WORD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then manually press &lt;code&gt;ddnddnddnddn...&lt;/code&gt; until there are no more occurrences. But this is time consuming if there are many lines to do this on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qd/WORD&amp;lt;enter&amp;gt;ddq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then guess how many times WORD occurs, and then, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;500@d &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this will either A) miss a bunch of lines or B) delete of bunch of extra lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to do this?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2015-10-13T22:09:35.373" Title="How do I apply a set of keystrokes to every occurrence of a word?" Tags="|search|macro|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5092" PostTypeId="2" ParentId="5091" CreationDate="2015-10-13T17:21:36.163" Score="2" Body="&lt;p&gt;It seems you are looking for &lt;code&gt;:global&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/WORD/d_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2015-10-13T17:21:36.163" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5093" PostTypeId="2" ParentId="5091" CreationDate="2015-10-13T17:53:31.803" Score="21" Body="&lt;p&gt;You can use the &lt;code&gt;:global&lt;/code&gt; and &lt;code&gt;:normal&lt;/code&gt; commands for this.  The &lt;code&gt;:global&lt;/code&gt; command has the following syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/{pattern}/{command}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will run &quot;command&quot; on every occurrence of &quot;pattern&quot;.  You can then use the &lt;code&gt;:normal&lt;/code&gt; command to run a series of keystrokes on each occurrence of a word using &lt;code&gt;:global&lt;/code&gt;.  Like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/WORD/normal {keystrokes}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If those keystrokes involve special keys like &lt;code&gt;&amp;lt;Ctrl&amp;gt;&lt;/code&gt;, you can combine it with the &lt;code&gt;:execute&lt;/code&gt; command like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/WORD/exe &quot;normal {keystrokes}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do note that you must put a backslash before each occurrence of a special key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more on these commands, see &lt;code&gt;:help :normal&lt;/code&gt; and &lt;code&gt;:help :global&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-10-13T17:53:31.803" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5094" PostTypeId="1" CreationDate="2015-10-13T21:59:17.270" Score="0" ViewCount="231" Body="&lt;p&gt;I have the following script variable and a mapping defined as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:tblgen_files = '-G \&quot;\\.td$\&quot;'&#xA;nnoremap &amp;lt;leader&amp;gt;st :call &amp;lt;SID&amp;gt;PrjAck(expand('&amp;lt;cword&amp;gt;'), s:tblgen_files, &quot;-w -Q&quot;, proj_root)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the mapping is execute I get a following error:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/F2L5M.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/F2L5M.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="2865" LastEditorUserId="23502" LastEditDate="2022-11-05T10:50:37.833" LastActivityDate="2022-11-05T10:50:37.833" Title="Why can't I use a script variable as a function parameter in a mapping?" Tags="|key-bindings|variables|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="5095" PostTypeId="2" ParentId="5091" CreationDate="2015-10-13T22:09:35.373" Score="3" Body="&lt;p&gt;Just for completeness, you &lt;em&gt;can&lt;/em&gt;  use &lt;code&gt;:substitute&lt;/code&gt;, if you match - in your example (delete the whole line that has WORD) - &lt;em&gt;the entire line&lt;/em&gt; containing WORD, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^.*\&amp;lt;WORD\&amp;gt;.*\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has an implicit &quot;replace match with nothing&quot;, i.e. it's the shorter form of: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^.*\&amp;lt;WORD\&amp;gt;.*\n//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Combined with &lt;code&gt;\zs&lt;/code&gt;, &lt;code&gt;\ze&lt;/code&gt;, &lt;code&gt;\(&lt;/code&gt;-&lt;code&gt;\)&lt;/code&gt; (grouping), and &lt;code&gt;\=&lt;/code&gt; (in the replacement part) with &lt;code&gt;submatch()&lt;/code&gt;, &lt;code&gt;:substitute&lt;/code&gt; can be very powerful.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-10-13T22:09:35.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5096" PostTypeId="2" ParentId="5094" CreationDate="2015-10-13T22:51:08.490" Score="2" Body="&lt;h2&gt;Short answer&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is (probably) the wrong way to go about this.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Long answer&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Without knowing exactly scenario it is hard to suggest better alternatives. In general script local variables are more of a way to protect and encapsulate variables. Having them in your mapping just seems wrong as your mappings do not change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below are some general solutions:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Hard coding&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If your script local variable never changes and &lt;code&gt;s:ProjectAck&lt;/code&gt; is always being called with &lt;code&gt;s:tblgen_files&lt;/code&gt; then equivalent to a hard coded value so remove it from the function call.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Global variable&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you script local variable changes and &lt;code&gt;s:ProjectAck&lt;/code&gt; is always being called with &lt;code&gt;s:tblgen_files&lt;/code&gt; then this is equivalent to a global variable. Still probably best to put it in the function.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Default parameter&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s:ProjectAck&lt;/code&gt; is being called from many places and not always using &lt;code&gt;s:tblgen_files&lt;/code&gt;. This is a sign of a default value so use a different mechanism. See &lt;code&gt;:h a:0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:example(...)&#xA;  let param = a:0 ? a:1 : 'default value'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Buffer local variable&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This is the odd case out because this is not possible with a script local variable, however it is worth mentioning as buffer local variables are often used a way of mimicking a &quot;project local variables&quot;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;You have made it this far: How to use script local variables in mappings&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Simple, don't. Use another script local function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:files()&#xA;  return s:tblgen_files&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;st :call &amp;lt;SID&amp;gt;PrjAck(expand('&amp;lt;cword&amp;gt;'), &amp;lt;SID&amp;gt;files(), &quot;-w -Q&quot;, proj_root)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Conclusion&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I would suggest you figure out your needs and choose an alternative to using a script local variable inside your mapping.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-10-13T22:59:30.817" LastActivityDate="2015-10-13T22:59:30.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5097" PostTypeId="1" CreationDate="2015-10-13T23:48:04.750" Score="1" ViewCount="77" Body="&lt;p&gt;I've turned on filetype indent and plugins on with the following in my vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;filetype indent plugin on  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Everything is fine when I open a file from terminal, but if I open another buffer through the :edit command, it doesn't seem to load the any of the indent settings (doesn't expand tabs, different shiftwidth, etc). The first buffer has all the correct settings. All subsequent files opened with edit do not.&#xA;Any idea why and how I might fix this?&lt;/p&gt;&#xA;" OwnerUserId="4897" LastActivityDate="2015-10-13T23:48:04.750" Title="filetype plugin not loaded on files opened with edit command" Tags="|buffers|indentation|filetype|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5098" PostTypeId="1" CreationDate="2015-10-14T05:23:46.930" Score="1" ViewCount="532" Body="&lt;p&gt;&lt;strong&gt;How to troubleshoot pathogen?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using Mac OSX El Capitan. Vim 7.4 MacOS X version, not MacVim. Running from terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can run nerdtree as a plugin, but won't work with pathogen. Same case with other plugins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have followed the install directions closely at &lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot; rel=&quot;nofollow&quot;&gt;https://github.com/scrooloose/nerdtree&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;From the &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;filetype off &quot; Pathogen needs to run before plugin indent on&#xA;call pathogen#infect()&#xA;call pathogen#helptags()&#xA;syntax on&#xA;filetype plugin indent on&#xA;colorscheme murphy&#xA;inoremap ii &amp;lt;Esc&amp;gt;`^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;From &lt;code&gt;:scriptnames&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1: ~/.vimrc&#xA; 2: ~/.vim/autoload/pathogen.vim&#xA; 3: /opt/local/share/vim/vim74/syntax/syntax.vim&#xA; 4: /opt/local/share/vim/vim74/syntax/synload.vim&#xA; 5: /opt/local/share/vim/vim74/syntax/syncolor.vim&#xA; 6: /opt/local/share/vim/vim74/filetype.vim&#xA; 7: ~/.vim/bundle/todo.txt-vim/ftdetect/todo.vim&#xA; 8: /opt/local/share/vim/vim74/ftplugin.vim&#xA; 9: /opt/local/share/vim/vim74/indent.vim&#xA;10: /opt/local/share/vim/vim74/colors/murphy.vim&#xA;11: ~/.vim/bundle/nerdtree/plugin/NERD_tree.vim&#xA;12: ~/.vim/bundle/nerdtree/autoload/nerdtree.vim&#xA;13: ~/.vim/bundle/nerdtree/lib/nerdtree/path.vim&#xA;14: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_controller.vim&#xA;15: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_item.vim&#xA;16: ~/.vim/bundle/nerdtree/lib/nerdtree/key_map.vim&#xA;17: ~/.vim/bundle/nerdtree/lib/nerdtree/bookmark.vim&#xA;18: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim&#xA;19: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_dir_node.vim&#xA;20: ~/.vim/bundle/nerdtree/lib/nerdtree/opener.vim&#xA;21: ~/.vim/bundle/nerdtree/lib/nerdtree/creator.vim&#xA;22: ~/.vim/bundle/nerdtree/lib/nerdtree/flag_set.vim&#xA;23: ~/.vim/bundle/nerdtree/lib/nerdtree/nerdtree.vim&#xA;24: ~/.vim/bundle/nerdtree/lib/nerdtree/ui.vim&#xA;25: ~/.vim/bundle/nerdtree/lib/nerdtree/event.vim&#xA;26: ~/.vim/bundle/nerdtree/lib/nerdtree/notifier.vim&#xA;27: ~/.vim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim&#xA;28: ~/.vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim&#xA;29: ~/.vim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim&#xA;30: ~/.vim/bundle/vim-easymotion/plugin/EasyMotion.vim&#xA;31: ~/.vim/bundle/vim-markdown-preview/plugin/vim-markdown-preview.vim&#xA;32: /opt/local/share/vim/vim74/syntax/modula2.vim`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Directory structure is&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim&#xA;~/.vim/autoload&#xA;~/.vim/bundle&#xA;~/.vim/plugin&#xA;~/.vim/lib&#xA;etc, etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/.vim/bundle&lt;/code&gt; has &lt;code&gt;/nerdtree&lt;/code&gt; from cloned from github.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;File loads in Vim but no nerdtree or other plugins are active.&lt;/p&gt;&#xA;" OwnerUserId="4898" LastEditorUserId="54" LastEditDate="2015-10-14T11:57:52.933" LastActivityDate="2015-10-14T15:07:03.637" Title="Pathogen won't load nerdtree or other bundles" Tags="|plugin-managers|" AnswerCount="1" CommentCount="2" ClosedDate="2015-10-15T21:43:25.633" ContentLicense="CC BY-SA 3.0" />
  <row Id="5099" PostTypeId="1" AcceptedAnswerId="5102" CreationDate="2015-10-14T06:31:40.077" Score="4" ViewCount="687" Body="&lt;p&gt;My projects are in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/user/projectA&#xA;/home/user/projectB&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, at times I hit CtrlP and I haven't opened a file in a particular project, so my working directory is &lt;code&gt;/home/user&lt;/code&gt;. CtrlP starts indexing this whole directory, which is huge and takes a whole lot of time every time I accidentally hit CtrlP. How can I avoid this? I have seen that I can exclude files and directories using Vim's wildignore and CtrlP's own g:ctrlp_custom_ignore, but that doesn't work as I can't ignore a parent directory and still search in a child directory. Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, I would also be happy with Vim automatically making &lt;code&gt;/home/user/projectA&lt;/code&gt; the default working directory, just to avoid ever having &lt;code&gt;/home/user&lt;/code&gt; as the working directory.&lt;/p&gt;&#xA;" OwnerUserId="4902" LastActivityDate="2015-10-14T08:33:34.060" Title="CtrlP should never index particular directories" Tags="|plugin-ctrlp|working-directory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5100" PostTypeId="2" ParentId="5084" CreationDate="2015-10-14T07:42:35.203" Score="1" Body="&lt;p&gt;I have a plugin that can (Partially?) helps you: &lt;a href=&quot;https://github.com/KabbAmine/lazyList.vim&quot; rel=&quot;nofollow&quot;&gt;lazyList&lt;/a&gt; (No automatic list numbering).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the following example (&lt;code&gt;_&lt;/code&gt; is the cursor position) ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. Some text&#xA;2. More text   &#xA; Sub-secti_on text&#xA; Sub-section text   &#xA; Sub-section text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... simply execute the command &lt;code&gt;:LazyList '2.%1%. '&lt;/code&gt; to get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. Some text&#xA;2. More text   &#xA; 2.1. Sub-secti_on text&#xA; 2.2. Sub-section text   &#xA; 2.3. Sub-section text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To remove the indices, execute the same command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, the indices are added to the current paragraph (Same indentation or when surrounded by empty lines), but you can add them to a visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good way of doing in your case:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Add indices&lt;/li&gt;&#xA;&lt;li&gt;Remove the indices before adding a new element(s).&lt;/li&gt;&#xA;&lt;li&gt;Add indices after adding the new element(s).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=C4P09AmLiGA&amp;amp;feature=youtu.be&quot; rel=&quot;nofollow&quot;&gt;This video&lt;/a&gt; should be more explicit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bad thing with the plugin, is that it doesn't take in account a visual selection with empty lines, I should reconsider this behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;P.S&lt;/strong&gt; English is not my native language, so please excuse the mistakes.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="4903" LastActivityDate="2015-10-14T07:42:35.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5101" PostTypeId="2" ParentId="5088" CreationDate="2015-10-14T07:59:40.530" Score="4" Body="&lt;p&gt;This is because you probably have other mappings that start with &lt;code&gt;[&lt;/code&gt; or &lt;code&gt;]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get a list of all your active mappings by running &lt;code&gt;:map&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then have to get rid of the maps you don't want that start with &lt;code&gt;[&lt;/code&gt; (either in your vimrc or by finding out how to change the mappings for the plugin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you prefer, you can also remap to something more specific, for example &lt;code&gt;[[&lt;/code&gt; or &lt;code&gt;]]&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1543" LastEditorUserId="205" LastEditDate="2015-10-14T23:53:46.497" LastActivityDate="2015-10-14T23:53:46.497" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5102" PostTypeId="2" ParentId="5099" CreationDate="2015-10-14T08:04:13.190" Score="4" Body="&lt;p&gt;2 ways of doing that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;On your terminal, move to your project directory then execute vim.&lt;/li&gt;&#xA;&lt;li&gt;Manually specify the working directory into vim using &lt;code&gt;:cd&lt;/code&gt; command (You can check the current working directory with &lt;code&gt;:pwd&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Extra&lt;/h2&gt;&#xA;&#xA;&lt;h3&gt;CtrlP&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you're using &lt;a href=&quot;https://stackoverflow.com/questions/18285751/use-ag-in-ctrlp-vim&quot;&gt;&lt;code&gt;ag&lt;/code&gt; with ctrlp&lt;/a&gt;, you can create a &lt;code&gt;.agignore&lt;/code&gt; file into your working directory, and specify there what ctrlp should ignore and not index.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;A little but useful vim command&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In my vimrc I have the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Dir :cd %:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So with &lt;code&gt;Dir&lt;/code&gt; I can set the current vim working directory to the current file's path, its useful sometimes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use vim autocommands (&lt;code&gt;h autocmd&lt;/code&gt;) to automate the process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example if you want to make &lt;code&gt;/path/project&lt;/code&gt; be your cwd in each vim start, add then to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * :cd /path/project&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The event &lt;code&gt;VimEnter&lt;/code&gt; is quite understandable (&lt;code&gt;h autocmd-events&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="4903" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-10-14T08:33:34.060" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5103" PostTypeId="1" AcceptedAnswerId="5112" CreationDate="2015-10-14T08:07:05.987" Score="2" ViewCount="588" Body="&lt;p&gt;When I used vim for programming I used cntrl+n/cntrl+p a lot for keyword completion. I switched from programming to reporting with vim and now I have some new needs, one of which is amazing LaTeX support (huzzah vim has this).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I would like to keep using completion of cntrl+n and cntrl+p but past semi-colons. As I create sections and chapters with labels so I can make references to these. But a chapter label is c:name and a section is s:name where a subsection is ss:name. If I could do c: to get the previous chapter that would be great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does stock Vim offer this, or should I create a plug-in for this?&lt;/p&gt;&#xA;" OwnerUserId="583" LastActivityDate="2015-10-15T11:25:11.323" Title="Completion past special characters" Tags="|autocompletion|filetype-tex|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5104" PostTypeId="2" ParentId="3334" CreationDate="2015-10-14T13:18:37.723" Score="2" Body="&lt;p&gt;I would recommend the &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow&quot;&gt;vim-unimpaired&lt;/a&gt; plugin, which has convenient mappings for quickfix motions (and then some). It's not the most minimal solution, but check the source code if you want to roll your own mappings. &lt;/p&gt;&#xA;" OwnerUserId="4909" LastActivityDate="2015-10-14T13:18:37.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5105" PostTypeId="2" ParentId="5098" CreationDate="2015-10-14T15:07:03.637" Score="1" Body="&lt;p&gt;Ugh, I was calling &lt;code&gt;:NERD_Tree&lt;/code&gt;, not &lt;code&gt;:NERDTree&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also added to my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd vimenter * NERDTree&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Problem&quot; solved.&lt;/p&gt;&#xA;" OwnerUserId="4899" LastActivityDate="2015-10-14T15:07:03.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5106" PostTypeId="2" ParentId="4968" CreationDate="2015-10-14T15:13:10.700" Score="5" Body="&lt;p&gt;Just call&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set statusline&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3241" LastActivityDate="2015-10-14T15:13:10.700" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5107" PostTypeId="2" ParentId="4951" CreationDate="2015-10-14T15:23:47.373" Score="1" Body="&lt;p&gt;This is solved by removing &lt;code&gt;mac_precompose_path&lt;/code&gt; from the Vim source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A fork where this is fixed can be found here: &lt;a href=&quot;https://github.com/OskarPersson/vim&quot; rel=&quot;nofollow&quot;&gt;https://github.com/OskarPersson/vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested this by creating a Homebrew formula of the repository above.&lt;/p&gt;&#xA;" OwnerUserId="4722" LastActivityDate="2015-10-14T15:23:47.373" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5108" PostTypeId="1" AcceptedAnswerId="5111" CreationDate="2015-10-14T16:26:30.960" Score="1" ViewCount="1259" Body="&lt;p&gt;I have this in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set directory=~/.vim/tmp-backup-swapfiles&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This directory is read- and writable by me, sensibly enough.  It is part of the local filesystem and never inaccessible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, vim seems to often ignore this and instead use &lt;code&gt;~/tmp&lt;/code&gt;.  I've sometimes thought it does this with files from a remote mounted filesystem, but since I do that much of the time it is hard to tell.  Also, there are inconsistencies -- for example, right now I have gvim (7.4.475) open with a local file who's swap turns out to be in &lt;code&gt;~/tmp&lt;/code&gt; and a remote file whose swap is in &lt;code&gt;~/.vim/tmp-backup-swapfiles&lt;/code&gt;.  It is easy to see they are both still in play by making a change to the buffer and checking the timestamp.  I also have a source and header file from the same location open, but the &lt;code&gt;.hpp.swp&lt;/code&gt; is in &lt;code&gt;~/tmp&lt;/code&gt; and the &lt;code&gt;.cpp.swp&lt;/code&gt; is in &lt;code&gt;~/.vim/tmp-backup-swapfiles&lt;/code&gt; :\&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This gets irritating when I have to clean up for whatever reason, or fail to, and get told there's suddenly a swapfile from last week in play on something I've been editing since.  What can I do to force it to just use the one directory specified to ensure there's no confusion?&lt;/p&gt;&#xA;" OwnerUserId="4913" LastActivityDate="2021-03-20T13:50:03.847" Title="Swap file directory often ignored" Tags="|swap-file|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5110" PostTypeId="1" AcceptedAnswerId="10147" CreationDate="2015-10-14T16:51:02.313" Score="24" ViewCount="6009" Body="&lt;p&gt;Say I have a python script with a runtime error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat example.py  &#xA;#! /usr/bin/env python3&#xA;&#xA;a = 1/0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ python3 example.py &#xA;Traceback (most recent call last):&#xA;  File &quot;example.py&quot;, line 3, in &amp;lt;module&amp;gt;&#xA;    a = 1/0&#xA;ZeroDivisionError: division by zero&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want Vim to jump to the problematic line of that file (line 3 in this case). I know Vim can do this because it works just fine for catching errors at compile time in C with &lt;code&gt;gcc&lt;/code&gt; using &lt;code&gt;:make&lt;/code&gt; and the &lt;code&gt;quickfix&lt;/code&gt; window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n3SXg.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n3SXg.png&quot; alt=&quot;quickfix output from gcc&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sure, I can populate Vim's quickfix window with &lt;code&gt;:set makeprg=python3\ %&lt;/code&gt; and then &lt;code&gt;:make&lt;/code&gt;, but it does not jump to the line number where the traceback points to. When I look in &lt;code&gt;:copen&lt;/code&gt; it just highlights the first line of the trace, and I can't jump to the relevant line number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BRZdQ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BRZdQ.png&quot; alt=&quot;quickfix output from python3&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I'm using Vim 7.4  on Debian &lt;code&gt;jessie&lt;/code&gt; in case that matters.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Can I configure Vim so that it knows how to get the relevant line number from a Python traceback?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can I modify the Python interpreter to spit out an error format that Vim already knows how to parse and get the relevant line number?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4498" LastEditorUserId="4498" LastEditDate="2016-11-01T16:30:14.197" LastActivityDate="2022-11-11T08:44:03.907" Title="Quickfix support for Python tracebacks" Tags="|quickfix|filetype-python|makeprg|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5111" PostTypeId="2" ParentId="5108" CreationDate="2015-10-14T21:46:24.903" Score="1" Body="&lt;p&gt;Use&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set dir?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to see which directories are used to store your swap files. If you insist on having just one directory, you could use&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set directory=~/.vim/tmp-backup-swapfiles//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Using double trailing slashes in the path tells Vim to create swap files using the whole path of the files being edited to avoid collisions.&lt;/p&gt;&#xA;" OwnerUserId="2961" LastEditorUserId="34082" LastEditDate="2021-03-20T13:50:03.847" LastActivityDate="2021-03-20T13:50:03.847" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5112" PostTypeId="2" ParentId="5103" CreationDate="2015-10-14T21:54:35.637" Score="5" Body="&lt;p&gt;If the chapter, section etc. labels are in the same file, or in any other open buffers, you can still use &lt;code&gt;Ctrl-n&lt;/code&gt;/&lt;code&gt;Ctrl-p&lt;/code&gt;. You just have to add &lt;code&gt;:&lt;/code&gt; to the keyword characters, with: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set iskeyword+=:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This enables (no more than) the following: if you write &lt;code&gt;c:blah&lt;/code&gt; somewhere, &lt;code&gt;c:&lt;/code&gt; followed by &lt;code&gt;Ctrl-p&lt;/code&gt; (or &lt;code&gt;Ctrl-n&lt;/code&gt;) is able to later offer it for autocompletion.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-10-15T11:25:11.323" LastActivityDate="2015-10-15T11:25:11.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5114" PostTypeId="1" CreationDate="2015-10-14T23:16:11.117" Score="2" ViewCount="132" Body="&lt;p&gt;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 &lt;code&gt;.vimrc&lt;/code&gt; and press &lt;code&gt;Ctrl-]&lt;/code&gt; to open the relevant section in the help files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I e.g. write &lt;code&gt;:help nocompatible&lt;/code&gt;, it brings up the relevant help section. However, if I move my cursor over the word &lt;code&gt;nocompatible&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;         ^&#xA;         |&#xA;     my cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I press &lt;code&gt;ctrl-]&lt;/code&gt; then I get the error messages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E433: No tags file&#xA;E426: tag not found: nocompatible&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="4882" LastActivityDate="2015-10-15T06:26:34.800" Title="Ctrl-] to open relevant help straight from .vimrc" Tags="|vimrc|help-system|tags|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5115" PostTypeId="2" ParentId="5114" CreationDate="2015-10-14T23:52:39.840" Score="2" Body="&lt;p&gt;The help system's tag files are probably present, but loaded only for the &lt;code&gt;help&lt;/code&gt; system. You could probably define a mapping, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-]&amp;gt; :exec &quot;h &quot; . expand(&quot;&amp;lt;cword&amp;gt;&quot;)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; contains the word currently under the cursor, so we use &lt;code&gt;expand?(&quot;&amp;lt;cword&amp;gt;&quot;)&lt;/code&gt; to get its value and run the &lt;code&gt;:h[elp]&lt;/code&gt; command on it.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-10-14T23:52:39.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5117" PostTypeId="1" CreationDate="2015-10-15T06:06:55.307" Score="1" ViewCount="27" Body="&lt;p&gt;I am using a recorded macro to manually wrap an extremely long string in a python script, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;blah = ('blahblah ... blah blah')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;blah = ('blahblah...'&#xA;        'blahblah...'&#xA;        ...&#xA;        'blahblah...')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the macro is &lt;code&gt;4f,a''^[i^M^[&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works fine, preserving my indentation right up to the point that the first line &lt;code&gt;blah =...&lt;/code&gt; reaches the top of the page, then suddenly it starts dedenting to the first character of the line.  How can I prevent this?  i.e., how can I make vim recognize that the opening paren is above the top of the page?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: OK, it's not the top of the page, but 50 lines above, and my window (at present) is 52 lines.&lt;/p&gt;&#xA;" OwnerUserId="1112" LastActivityDate="2015-10-15T06:06:55.307" Title="Parentheses off the page stop being recognized" Tags="|indentation|macvim|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5118" PostTypeId="2" ParentId="5114" CreationDate="2015-10-15T06:15:52.413" Score="4" Body="&lt;p&gt;I think the functionality you want is very useful, but it is already provided with the &lt;code&gt;K&lt;/code&gt; mapping. This runs a program to lookup the keyword under the cursor. By default, it uses &lt;code&gt;man&lt;/code&gt;. You can set it to &lt;code&gt;':help'&lt;/code&gt; (or to &lt;code&gt;''&lt;/code&gt;) to open vim help files with &lt;code&gt;K&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this is very useful, as it can be used to set a different lookup program for different file types. Thus, if you set it up, you can use &lt;code&gt;K&lt;/code&gt; to consistently lookup the desired manual or help files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;br&gt;&#xA;- &lt;code&gt;:h K&lt;/code&gt;&lt;br&gt;&#xA;- &lt;code&gt;:h 'keywordprg'&lt;/code&gt;&lt;br&gt;&#xA;- &lt;a href=&quot;https://www.reddit.com/r/vim/comments/3oo1e0/has_anyone_found_a_way_to_make_k_useful/&quot; rel=&quot;nofollow&quot;&gt;Discussion on reddit&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2015-10-15T06:26:34.800" LastActivityDate="2015-10-15T06:26:34.800" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5119" PostTypeId="2" ParentId="5056" CreationDate="2015-10-15T09:11:29.553" Score="0" Body="&lt;p&gt;Assuming that “certain session” means “certain project” and “certain directory” I would try to use the per-project &lt;code&gt;.vimrc&lt;/code&gt; file. To get vim to additionally read the &lt;code&gt;.vimrc&lt;/code&gt; in the current directory, I have &lt;code&gt;set exrc&lt;/code&gt; in my &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4922" LastActivityDate="2015-10-15T09:11:29.553" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5120" PostTypeId="1" AcceptedAnswerId="5124" CreationDate="2015-10-15T10:24:30.897" Score="7" ViewCount="4830" Body="&lt;p&gt;I'm working with python code. After some modifications, I want to update the identation but obviously, select everything and press '=' doesn't work, python being python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there any other way to add (and/or remove) some character (here, tabs) at the beggining of each line ?&lt;/p&gt;&#xA;" OwnerUserId="4717" LastActivityDate="2021-11-03T11:53:00.850" Title="Add tab in front of each line" Tags="|normal-mode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5121" PostTypeId="1" CreationDate="2015-10-15T12:10:43.697" Score="2" ViewCount="84" Body="&lt;p&gt;I'm aware of the jumps list, and that you can navigate forwards and backwards through locations I've previously jumped between.  But I'd like to duplicate the behaviour of many other editors (such as Visual Studio) where essentially they include movements such as page up/down as jumps so that they too can be navigated forwards and backwards.  That is, having pressed page down 10 times you can go back ten times.  In this example you might just as well press page up, but obviously when you're performing a mixture of jumps, go to declarations, changes etc it's great to be able to go back one step at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would appear this is not possible in vim, but perhaps I'm missing something.  Is it something that can be achieved with a remapping or plugin?  &lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastEditorDisplayName="user859" LastEditDate="2015-10-15T16:17:55.680" LastActivityDate="2015-11-14T16:18:56.927" Title="Navigate previous locations" Tags="|jumplist|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5122" PostTypeId="2" ParentId="5121" CreationDate="2015-10-15T12:53:53.447" Score="1" Body="&lt;p&gt;The best solution/workaround I can see is to remap Control-D/U/B/F (and any other operations you want to end up in the jumps list) to additionally goto the current line, which I do by setting a mark and jumping to it. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-d&amp;gt; &amp;lt;c-d&amp;gt;mp`p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user859" LastActivityDate="2015-10-15T12:53:53.447" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5123" PostTypeId="1" CreationDate="2015-10-15T15:16:47.347" Score="17" ViewCount="6127" Body="&lt;p&gt;I know that in vim I can add &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;.vimrc&lt;/code&gt; to avoid that arrow keys display A, B, C, D in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'm using vi &lt;em&gt;Version 4.0 (gritter) 12/25/06&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I obtain the same behavior? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;== EDIT == (1)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the &lt;a href=&quot;https://www.archlinux.org/packages/core/x86_64/vi/&quot;&gt;vi version from Arch Linux&lt;/a&gt; which is built from this &lt;a href=&quot;http://ex-vi.cvs.sourceforge.net/viewvc/ex-vi/ex-vi/&quot;&gt;CVS repository&lt;/a&gt; (last commit 24 February 2007) with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make PREFIX=/usr LIBEXECDIR=/usr/lib/ex PRESERVEDIR=/var/lib/ex \&#xA;TERMLIB=ncurses FEATURES=&quot;-DCHDIR -DFASTTAG -DUCVISUAL -DMB -DBIT8&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and with theses three patches: &lt;a href=&quot;https://projects.archlinux.org/svntogit/packages.git/tree/trunk/fix-tubesize-short-overflow.patch?h=packages/vi&quot;&gt;fix-tubesize-short-overflow.patch&lt;/a&gt;, &lt;a href=&quot;https://projects.archlinux.org/svntogit/packages.git/tree/trunk/navkeys.patch?h=packages/vi&quot;&gt;navkeys.patch&lt;/a&gt; and &lt;a href=&quot;https://projects.archlinux.org/svntogit/packages.git/tree/trunk/preserve-dir.patch?h=packages/vi&quot;&gt;preserve-dir.patch&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;== EDIT (2)==&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problems happens in &lt;a href=&quot;https://www.archlinux.org/packages/community/x86_64/lxterminal/&quot;&gt;LXTerminal 0.2.0&lt;/a&gt;, &lt;a href=&quot;https://wiki.archlinux.org/index.php/Termite&quot;&gt;Termite 10-1&lt;/a&gt;, &lt;a href=&quot;https://wiki.archlinux.org/index.php/Tilda&quot;&gt;Tilda 1.2.4-1&lt;/a&gt;, &lt;a href=&quot;https://wiki.archlinux.org/index.php/Terminator&quot;&gt;Terminator 0.98-1&lt;/a&gt; and &lt;a href=&quot;https://wiki.archlinux.org/index.php/Xterm&quot;&gt;xterm 320-2&lt;/a&gt; but not in &lt;a href=&quot;https://wiki.archlinux.org/index.php/Rxvt-unicode&quot;&gt;urxvt v9.21 &lt;/a&gt; nor in the Linux virtual consoles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;== EDIT (3)==&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/7908799/xcurses/terminfo.html&quot;&gt;Single Unix Specification&lt;/a&gt; left-arrow, down-arrow, right-arrow, up-arrow correspond to respectively the following capname : &lt;code&gt;kcub1&lt;/code&gt;, &lt;code&gt;kcud1&lt;/code&gt;, &lt;code&gt;kcuf1&lt;/code&gt; and &lt;code&gt;kcuu1&lt;/code&gt;. Comparing terminfo entries from &lt;code&gt;xterm&lt;/code&gt; and &lt;code&gt;rxvt-unicode-256color&lt;/code&gt; for these capterms gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ infocmp xterm rxvt-unicode-256color | grep -E 'kcuf1|kcub1|kcud1|kcuu1'&#xA;&#xA;kcub1: '\EOD', '\E[D'.&#xA;kcud1: '\EOB', '\E[B'.&#xA;kcuf1: '\EOC', '\E[C'.&#xA;kcuu1: '\EOA', '\E[A'.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Modifying the xterm terminfo entry by substituing &lt;code&gt;'\EOD'&lt;/code&gt;, &lt;code&gt;'\EOB'&lt;/code&gt;, &lt;code&gt;'\EOC'&lt;/code&gt;, &lt;code&gt;'\EOA'&lt;/code&gt;  by &lt;code&gt;'\E[D'&lt;/code&gt;, &lt;code&gt;'\E[B'&lt;/code&gt;, &lt;code&gt;'\E[C'&lt;/code&gt;, &lt;code&gt;'\E[A'&lt;/code&gt; should solve the problem but is it a good idea? Maybe it will break other programs arrow keys usage?&lt;/p&gt;&#xA;" OwnerUserId="4926" LastEditorUserId="4926" LastEditDate="2015-10-17T09:58:57.957" LastActivityDate="2021-03-24T12:46:46.803" Title="Fix arrow keys displaying A, B, C, D in vi (not in vim)" Tags="|key-bindings|original-vi|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5124" PostTypeId="2" ParentId="5120" CreationDate="2015-10-15T19:56:31.103" Score="8" Body="&lt;p&gt;As Sato mentioned in comments, &lt;code&gt;:help v_&amp;gt;&lt;/code&gt; will show you help for the best tool you can use for this.  &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; in normal mode will indent the current line; &lt;code&gt;&amp;gt;3&amp;gt;&lt;/code&gt; will indent the current line and the following two lines; &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; will decrease indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another feature that works will in combination with &lt;code&gt;&amp;gt;&lt;/code&gt; can be found at &lt;code&gt;:help text-objects&lt;/code&gt;.  (&lt;code&gt;aB&lt;/code&gt;, &lt;code&gt;a[&lt;/code&gt;, and so on.)  For example in C-style code that uses curly braces, &lt;code&gt;&amp;gt;aB&lt;/code&gt; or &lt;code&gt;&amp;gt;iB&lt;/code&gt; to indent the current block &lt;em&gt;including&lt;/em&gt; curly braces, or only indent the lines &lt;em&gt;between&lt;/em&gt; the curly braces, respectively.  For Python code, &lt;code&gt;&amp;gt;ap&lt;/code&gt; (indent a paragraph) may be more useful, but using visual mode to select the lines as described in &lt;code&gt;:help v_&amp;gt;&lt;/code&gt; is even more adjustable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the general answer to &quot;How to add a character/some text at the beginning of each line?&quot; i.e., when you want to insert something other than tabs or spaces, there are a couple ways:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%normal Itext to insert&lt;/code&gt; will prepend &lt;code&gt;text to insert&lt;/code&gt; to every line in the file.  &lt;code&gt;%&lt;/code&gt; can be replaced with any range you like.  (See &lt;code&gt;:help range&lt;/code&gt; and also &lt;code&gt;:help :normal&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can use &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;to enter blockwise-visual mode, use &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; to select a column of characters, then &lt;code&gt;I&lt;/code&gt; (capital) to insert text at that point in &lt;em&gt;all&lt;/em&gt; selected lines.  (It will only be visible in all the lines after you &lt;kbd&gt;Esc&lt;/kbd&gt; and then make another motion of any sort.)  This has the advantage that you can enter text at ANY point in the line, not only at the beginning.  (See &lt;code&gt;:help v_b_I&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2015-10-15T19:56:31.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5125" PostTypeId="2" ParentId="5056" CreationDate="2015-10-15T20:11:05.017" Score="2" Body="&lt;p&gt;Assuming the functions are something you don't want &lt;em&gt;all&lt;/em&gt; the time, so you don't want them in your &lt;code&gt;.vimrc&lt;/code&gt; file, you can define them in a separate file and use &lt;code&gt;:source filename&lt;/code&gt; to load in the definitions.  This avoids the security issues of &lt;code&gt;set exrc&lt;/code&gt; and loading untrusted files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the pathname to your functions file is irritatingly long, you could even define a function in your &lt;code&gt;.vimrc&lt;/code&gt; just to call &lt;code&gt;:source /home/me/annoyingly/long/path/name/functionsfile&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2015-10-15T20:11:05.017" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5126" PostTypeId="1" AcceptedAnswerId="5127" CreationDate="2015-10-15T20:27:05.337" Score="3" ViewCount="695" Body="&lt;p&gt;I would like to create a new scratch buffer in vim script. I would like to use this buffer to output the result of the execution of a scala script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am creating the buffer with this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ScratchBuffer()&#xA;  vnew&#xA;  setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile&#xA;endfunction &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then I call it as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let outputBuf = ScratchBuffer()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;outputbuf should contain the buffer number. However, this doesn't seem to work. I need the buffer number in order to then use the buffer in a python script.&lt;/p&gt;&#xA;" OwnerUserId="1620" LastEditorUserId="23502" LastEditDate="2022-11-05T10:49:47.410" LastActivityDate="2022-11-05T10:49:47.410" Title="How to detect the buffer number of new buffer?" Tags="|vimscript|buffers|vimscript-python|scratch-buffer|hidden-buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5127" PostTypeId="2" ParentId="5126" CreationDate="2015-10-15T20:49:00.707" Score="7" Body="&lt;p&gt;Your function returns nothing, but you call it expecting the buffer number. This should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ScratchBuffer()&#xA;  vnew&#xA;  setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile&#xA;  return bufnr('%')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-10-15T20:49:00.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5128" PostTypeId="1" AcceptedAnswerId="5318" CreationDate="2015-10-15T23:20:20.303" Score="8" ViewCount="3109" Body="&lt;p&gt;I use &lt;code&gt;set matchpairs+=&amp;lt;:&amp;gt;&lt;/code&gt; in my config (to help when editing HTML, for instance), but I just noticed it made vim very slow when editing emails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;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 numerous &lt;code&gt;&amp;gt;&lt;/code&gt; as delimiters)&lt;/p&gt;&#xA;" OwnerUserId="4819" LastActivityDate="2015-11-08T15:23:42.863" Title="matchpairs makes vim slow" Tags="|performance|delimiter-matching|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5129" PostTypeId="2" ParentId="5080" CreationDate="2015-10-15T23:44:22.630" Score="7" Body="&lt;p&gt;You can search for the last match by grouping all, &lt;code&gt;\(.*\)&lt;/code&gt;, but last ocurrence of &lt;code&gt;pattern&lt;/code&gt;. Then exiting with the captured group, &lt;code&gt;\1&lt;/code&gt;, and adding the &lt;code&gt;replacement&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(.*\)pattern/\1replacement/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4930" LastActivityDate="2015-10-15T23:44:22.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5130" PostTypeId="1" CreationDate="2015-10-16T01:43:18.157" Score="24" ViewCount="8775" Body="&lt;p&gt;&lt;code&gt;winheight()&lt;/code&gt; and &lt;code&gt;winwidth()&lt;/code&gt; return the number of columns/lines in the current window. What I'm looking for is something closer to the actual height and width of the editing area, or displayed area if run in a terminal. The problem with &lt;code&gt;winheight()&lt;/code&gt; and &lt;code&gt;winwidth()&lt;/code&gt; is that aspect ratio calculated from these values is out of touch with the actual aspect ratio.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo winwidth('%') winheight('%') winwidth('%') * 1.0 / winheight('%')&#xA;104 51 2.039216&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A screenshot of the buffer area is sized 936x918 pixels, giving a displayed aspect ratio of &lt;code&gt;1.019608&lt;/code&gt;. I think I can get the actual value by using the size of the font, but how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a follow-up to &lt;a href=&quot;https://vi.stackexchange.com/questions/4452/how-can-i-make-vim-open-help-in-a-vertical-split&quot;&gt;How can I make Vim open help in a vertical split?&lt;/a&gt;. I'm trying to adapt &lt;a href=&quot;https://vi.stackexchange.com/a/4472/205&quot;&gt;Nobe4's solution&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-09-22T21:11:32.763" Title="How do I get the actual height and width of Vim?" Tags="|vim-windows|window-management|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5131" PostTypeId="2" ParentId="5128" CreationDate="2015-10-16T03:08:41.207" Score="6" Body="&lt;p&gt;If your emails have a particular file type, you could use &lt;code&gt;BufRead&lt;/code&gt; or &lt;code&gt;BufNewFile&lt;/code&gt; or &lt;code&gt;FileType&lt;/code&gt; to turn off some matchpairs automatically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.email set mps-=&amp;lt;:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4932" LastEditorUserId="205" LastEditDate="2015-10-16T06:08:59.860" LastActivityDate="2015-10-16T06:08:59.860" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5132" PostTypeId="1" AcceptedAnswerId="21684" CreationDate="2015-10-16T10:50:54.937" Score="3" ViewCount="1307" Body="&lt;p&gt;I have no idea how swap files are formatted, but I'm wondering if the information in them can be directly examined somehow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to EvergreenTree's comment below, it also contains meta information such as current process ID, modification timestamps, etc.&lt;/p&gt;&#xA;" OwnerUserId="4913" LastEditorUserId="4913" LastEditDate="2015-10-16T12:59:09.087" LastActivityDate="2021-10-02T09:06:14.307" Title="Examine swap file" Tags="|swap-file|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5133" PostTypeId="1" AcceptedAnswerId="5134" CreationDate="2015-10-16T12:32:33.750" Score="1" ViewCount="219" Body="&lt;p&gt;I wrote this line into my .vimrc today:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;rtp :below new \| execute append(0, &amp;amp;runtimepath) \| s/,/\r/ &amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to display my runtimepath in a new buffer with one path per line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works fine, but prompts me with 'No write since last change' when I've finished with it and want to close it. Is there any way to mark that buffer as temporary and not intended to be saved? Or is there a better way of doing this (eg. something other than &lt;code&gt;below new&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="2374" LastActivityDate="2015-10-16T12:41:03.940" Title="How to mark a buffer as intentionally temporary (i.e. not to be saved)?" Tags="|save|error|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5134" PostTypeId="2" ParentId="5133" CreationDate="2015-10-16T12:41:03.940" Score="2" Body="&lt;p&gt;Found the answer in the very last &lt;a href=&quot;https://vi.stackexchange.com/questions/4096/no-vim-i-dont-want-to-save-changes-to-a-directory?rq=1&quot;&gt;&quot;related question&quot;&lt;/a&gt;. Changing the mapping to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;rtp :below new \| execute append(0, &amp;amp;runtimepath) \| s/,/\r/ \| setlocal buftype=nofile&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;fixes the error. &lt;/p&gt;&#xA;" OwnerUserId="2374" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-10-16T12:41:03.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5135" PostTypeId="2" ParentId="5128" CreationDate="2015-10-16T13:27:47.283" Score="1" Body="&lt;p&gt;I guess it has something to do with your &lt;code&gt;.vimrc&lt;/code&gt; somewhere else, I can still edit emails as long as 10000 lines without having any slowdown with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set matchpairs+=&amp;lt;:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you try with an empty vimrc and start finding out by commenting out other things ?&lt;/p&gt;&#xA;" OwnerUserId="1543" LastActivityDate="2015-10-16T13:27:47.283" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5137" PostTypeId="1" AcceptedAnswerId="5139" CreationDate="2015-10-16T14:06:41.263" Score="1" ViewCount="128" Body="&lt;p&gt;I've the following dummy file created via:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo -e &quot;a a\tb b\tc c&quot; &amp;gt; file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any literal for space which I can use for motion argument?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example this works (which removes the 1st &lt;code&gt;a a&lt;/code&gt; column):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex +'%norm df ' -sc'%p|q!' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but only when the whitespace was typed manually by &lt;kbd&gt;Ctrl+V&lt;/kbd&gt;-&lt;kbd&gt;Ctrl+Tab&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried already: &lt;code&gt;\t&lt;/code&gt;, &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;c-v&amp;gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;, etc., but without success.&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-10-16T14:43:21.123" Title="How to write literal for Tab key to use for motion?" Tags="|cursor-motions|normal-mode|ex-mode|tab-characters|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5139" PostTypeId="2" ParentId="5137" CreationDate="2015-10-16T14:43:21.123" Score="2" Body="&lt;p&gt;This should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c':exe &quot;:%norm df\&amp;lt;Tab&amp;gt;&quot;' -c ':wq' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(not sure, why you are using -sc '%p' thing)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:exe &quot;norm &amp;lt;key&amp;gt;&quot;&lt;/code&gt; is documented at &lt;code&gt;:h expr-quote&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-10-16T14:43:21.123" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5140" PostTypeId="1" AcceptedAnswerId="5153" CreationDate="2015-10-16T15:03:45.020" Score="4" ViewCount="1266" Body="&lt;p&gt;To print the whole buffer, you can use &lt;code&gt;%p&lt;/code&gt;, how do I print value of register to the standard output?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is example how I would print the whole buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +'norm dw' +'%p' -scq! &amp;lt;(echo foo bar)&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I'm looking for &lt;code&gt;%p&lt;/code&gt; equivalent printing way for registers, for example to print the last deletion (&lt;code&gt;&quot;&quot;&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-10-17T19:01:20.487" LastActivityDate="2015-10-25T20:01:48.490" Title="How to print value of register to the standard output?" Tags="|command-line|register|ex-mode|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5141" PostTypeId="5" CreationDate="2015-10-16T22:08:00.630" Score="0" Body="&lt;p&gt;In Vim, the &lt;code&gt;:hardcopy&lt;/code&gt; command generates a Postscript file. On most Unix-like systems, this can be sent to a printer with &lt;code&gt;lp&lt;/code&gt; or &lt;code&gt;lpr&lt;/code&gt;. On Windows, &lt;code&gt;:hardcopy&lt;/code&gt; sends its output to an installed printer.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;External links&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Printing in Vim: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/print.html&quot; rel=&quot;nofollow&quot;&gt;7.3 reference manual&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/print.txt.html&quot; rel=&quot;nofollow&quot;&gt;7.4 reference manual&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2015-10-17T14:14:33.947" LastActivityDate="2015-10-17T14:14:33.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5142" PostTypeId="4" CreationDate="2015-10-16T22:08:00.630" Score="0" Body="Printing to Postscript, PDF and other formats" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2015-10-17T14:14:42.370" LastActivityDate="2015-10-17T14:14:42.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5144" PostTypeId="1" AcceptedAnswerId="5148" CreationDate="2015-10-17T01:17:41.503" Score="2" ViewCount="861" Body="&lt;p&gt;I've a file where I would like to extract a multiline pattern in non-greedy way (similar to this &lt;a href=&quot;https://stackoverflow.com/q/152708/55075&quot;&gt;scenario&lt;/a&gt;) by using &lt;code&gt;ex&lt;/code&gt; editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This example works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +'/aa/,/cc/p' -scq! &amp;lt;(echo -e &quot;start\naa\nbb\ncc\nend&quot;)&#xA;aa&#xA;bb&#xA;cc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by extracting me pattern between &lt;code&gt;aa&lt;/code&gt; and &lt;code&gt;cc&lt;/code&gt;, but it's uses ranges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I would like to extend that example by introducing &lt;a href=&quot;http://vim.wikia.com/wiki/Search_across_multiple_lines#Searching_for_multiline_HTML_comments&quot; rel=&quot;nofollow noreferrer&quot;&gt;a multiline non-greedy pattern&lt;/a&gt; (&lt;code&gt;\_.\{-}&lt;/code&gt;), but it doesn't print for me the whole multi-line match for some reason:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +'/aa\_.\{-}cc/p' -scq! &amp;lt;(echo -e &quot;start\naa\nbb\ncc\nend&quot;)&#xA;aa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any reason for that or I'm missing anything? How do I correct that?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-10-17T20:27:41.837" Title="How to print a multi-line match?" Tags="|command-line|search|linux|ex-mode|multiple-lines|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5145" PostTypeId="1" AcceptedAnswerId="5147" CreationDate="2015-10-17T10:54:52.053" Score="3" ViewCount="1306" Body="&lt;p&gt;say for example, I have this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;test1&quot;&amp;gt;&amp;lt;/div&amp;gt;&#xA;&amp;lt;span class=&quot;highlight&quot;&amp;gt;&amp;lt;/span&amp;gt;&#xA;&amp;lt;nav class=&quot;tester&quot;&amp;gt;&amp;lt;/nav&amp;gt;&#xA;&amp;lt;aside class=&quot;wrapper&quot;&amp;gt;&amp;lt;/aside&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want use visual block mode to add a new class to each line - in one action - so the result is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;test1 new_class&quot;&amp;gt;&amp;lt;/div&amp;gt;&#xA;&amp;lt;span class=&quot;highlight new_class&quot;&amp;gt;&amp;lt;/span&amp;gt;&#xA;&amp;lt;nav class=&quot;tester new_class&quot;&amp;gt;&amp;lt;/nav&amp;gt;&#xA;&amp;lt;aside class=&quot;wrapper new_class&quot;&amp;gt;&amp;lt;/aside&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried enter visual block mode &lt;kbd&gt;Ctrl + v&lt;/kbd&gt;, select all 4 lines, but I cant move the cursor position to the 2nd &lt;code&gt;&quot;&lt;/code&gt; in each line, I have tried &lt;code&gt;2f&quot;&lt;/code&gt; , which does find  the 2nd &lt;code&gt;&quot;&lt;/code&gt; - for one particular line, but then the cursor position of that line dictates the position for all  the other lines. I cant get the cursor position to find  the 2nd &lt;code&gt;&quot;&lt;/code&gt; for each individual line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know another solution to this problem is to simply visually select the lines with regular &lt;code&gt;visual&lt;/code&gt; and then use command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/&quot;&amp;gt;/ new_class&quot;&amp;gt;/g &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this works, but is it possible to use &lt;code&gt;-- VISUAL BLOCK --&lt;/code&gt; to do this?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="7161" LastEditDate="2016-05-02T12:12:10.307" LastActivityDate="2016-05-02T12:12:10.307" Title="Can I select and edit specific positions in lines while in visual block mode?" Tags="|visual-mode|visual-block|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5146" PostTypeId="1" AcceptedAnswerId="5149" CreationDate="2015-10-17T12:40:44.253" Score="1" ViewCount="85" Body="&lt;p&gt;I'd like to append a custom string at the end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example using &lt;code&gt;:read&lt;/code&gt; command this works: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$r !echo my string&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however is there any more portable way of doing that (without executing external program)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$r &quot;my string&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it's just duplicating content of my file (the same as: &lt;code&gt;:$r %&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to I specify literal string in this context?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-10-17T21:50:07.283" LastActivityDate="2022-11-17T15:46:38.253" Title="How to append a custom string at the end of the file?" Tags="|command-line|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5147" PostTypeId="2" ParentId="5145" CreationDate="2015-10-17T12:41:00.713" Score="5" Body="&lt;p&gt;No, you can only do rectangular selections with visual-block mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beside substitution, there are basically two ways to do what you want without third party plugins: direct repetition of normal mode commands and macros.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Repeating normal mode commands&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do your edit in one place and repeat it in the other places:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&quot;&amp;lt;&amp;lt;CR&amp;gt;              search for &quot;&amp;gt;&#xA;s new_class&quot;&amp;lt;Esc&amp;gt;    replace it with your text followed by a double quote&#xA;n.                   jump to next occurrence and repeat the change&#xA;n.                   and again&#xA;n.                   and again&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help single-repeat&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Replaying a recorded macro&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Record your macro and play it back as many times as necessary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq                  start recording in register q&#xA;02f&quot;                go to first column then jump to second &quot;&#xA;i new_class&amp;lt;Esc&amp;gt;    insert your text&#xA;j                   go down one line&#xA;q                   stop recording&#xA;@q                  replay your recording&#xA;@q                  and again&#xA;@q                  and again&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you can use &lt;code&gt;@@&lt;/code&gt; to repeat the last played macro: &lt;code&gt;@q@@@@&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;you can use a count before &lt;code&gt;@q&lt;/code&gt;: &lt;code&gt;3@q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help recording&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Using a &quot;manual&quot; macro&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;:{range}normal&lt;/code&gt; to execute a macro on lines covered by &lt;code&gt;{range}&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;normal 2f&quot;i new_class&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :normal&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-10-17T12:49:28.527" LastActivityDate="2015-10-17T12:49:28.527" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5148" PostTypeId="2" ParentId="5144" CreationDate="2015-10-17T12:46:10.460" Score="3" Body="&lt;p&gt;There's something almost perverse in doing this with &lt;code&gt;ex&lt;/code&gt;, akin to chopping a tree with a razor blade, or drinking a bucket of water through a straw.  But if you stop and think for a few minutes about what you're doing, it's relatively straightforward:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex +'/aa\_.\{-}cc/' +'normal gny' +new +'normal P' +'%p' -scqa! file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Translation, for the less masochistic among us:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;+&lt;/code&gt; introduce command line statements that apply to &lt;code&gt;file&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/aa\_.\{-}cc/&lt;/code&gt; searches for the pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal gn&lt;/code&gt; marks the text just found&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt; yanks said text&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;new&lt;/code&gt; opens a new buffer&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal P&lt;/code&gt; pastes the text&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%p&lt;/code&gt; prints the buffer (i.e. &lt;code&gt;:p&lt;/code&gt; applied to the entire buffer, a.k.a. &lt;code&gt;%&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-scqa!&lt;/code&gt; runs &lt;code&gt;:qa!&lt;/code&gt;, i.e. bails out.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The same tricks, using &lt;code&gt;normal &amp;lt;mumble&amp;gt;&lt;/code&gt; to get to normal mode commands from within &lt;code&gt;ex&lt;/code&gt;, and pasting stuff to a scratch buffer, can be used to solve other similar quizzes, such as printing the contents of a register, and &lt;code&gt;echo&lt;/code&gt;-ing things (hint: use &lt;code&gt;redir&lt;/code&gt; for that one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Alternative approach, by OP:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex +'sil /aa\_.\{-}cc/norm gny' +'redi&amp;gt;&amp;gt;/dev/stdout|echon @&quot;' -scq! file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note that &lt;code&gt;/dev/stdout&lt;/code&gt; is not available on all systems.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="2313" LastEditDate="2015-10-17T20:27:41.837" LastActivityDate="2015-10-17T20:27:41.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5149" PostTypeId="2" ParentId="5146" CreationDate="2015-10-17T12:51:02.923" Score="6" Body="&lt;p&gt;Yes, you can use &lt;code&gt;:put&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$put='my string'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :put&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-10-17T12:51:02.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5150" PostTypeId="1" CreationDate="2015-10-17T14:18:48.443" Score="1" ViewCount="48" Body="&lt;p&gt;How might Ι automatically fold all paragraphs where every line begins with &lt;code&gt;%%&lt;/code&gt;? Would be good for comments in TeX.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2015-10-17T18:08:27.793" Title="Automatic folding based on bol" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5151" PostTypeId="2" ParentId="5150" CreationDate="2015-10-17T18:08:27.793" Score="2" Body="&lt;p&gt;Try this setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :set foldenable foldmethod=expr foldexpr=getline(v:lnum)=~'^\s*%%'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-10-17T18:08:27.793" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5153" PostTypeId="2" ParentId="5140" CreationDate="2015-10-17T18:58:06.230" Score="3" Body="&lt;p&gt;Echo command can print the value of any register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echon @&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This output can be redirected to the file (or standard output in this case) by using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir &amp;gt; file&#xA;:echon @&quot;&#xA;:redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the working example is as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +'norm dw' +'redir&amp;gt;&amp;gt;/dev/stdout|echon @-' -scq! &amp;lt;(echo foo bar)&#xA;foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;@-&lt;/code&gt; register stores the last text that you deleted or changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: The &lt;a href=&quot;https://en.wikipedia.org/wiki/Standard_streams#Standard_output_.28stdout.29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;/dev/stdout&lt;/code&gt;&lt;/a&gt; could not exist on some non-Unix systems. &lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or workaround would be to replace the entire buffer with register and print it, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex +'norm dw' +'%d|put-|%p' -scq! &amp;lt;(echo foo bar)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-10-25T20:01:48.490" LastActivityDate="2015-10-25T20:01:48.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5154" PostTypeId="1" CreationDate="2015-10-18T00:10:35.430" Score="1" ViewCount="595" Body="&lt;p&gt;I dislike the default way vim open the help window. I just want to open the help window vertically.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I want to remap the &lt;code&gt;help&lt;/code&gt; command to &lt;code&gt;vert help&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I put in vimrc is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap h vert h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="1276" LastActivityDate="2015-10-18T02:28:05.130" Title="how to remap help command to vert help?" Tags="|vimrc|" AnswerCount="2" CommentCount="2" ClosedDate="2016-09-08T01:04:52.893" ContentLicense="CC BY-SA 3.0" />
  <row Id="5155" PostTypeId="2" ParentId="5154" CreationDate="2015-10-18T02:15:01.570" Score="4" Body="&lt;p&gt;The mapping you defined works in normal, visual and operator-pending modes and does not automatically change modes. That is, when you type &lt;code&gt;h&lt;/code&gt;, you effectively send to Vim the key sequence &lt;code&gt;vert h&lt;/code&gt;, which enters visual mode (&lt;code&gt;v&lt;/code&gt;), selects to the end of the current word (&lt;code&gt;e&lt;/code&gt;), and replaces the visually-selected region (&lt;code&gt;r&lt;/code&gt;) with the character &lt;code&gt;t&lt;/code&gt;. Then, back in normal mode, the cursor is moved one position to the right (&lt;code&gt;&lt;/code&gt;) and one position to the left (&lt;code&gt;h&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mapping you want is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap h :vert h&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The colon (&lt;code&gt;:&lt;/code&gt;) is a necessary part of the &lt;code&gt;:vert&lt;/code&gt; command, putting Vim into ex mode before accepting the command. The &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; terminates the command as you would if you had typed it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used &lt;code&gt;:nnoremap&lt;/code&gt; rather than &lt;code&gt;:noremap&lt;/code&gt; because it didn't seem useful to have this mapping work in any but the normal mode.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-10-18T02:15:01.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5156" PostTypeId="2" ParentId="5154" CreationDate="2015-10-18T02:28:05.130" Score="2" Body="&lt;p&gt;simply use &lt;code&gt;cabbrev&lt;/code&gt;:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cabbrev h vert h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when type &lt;code&gt;:h&lt;/code&gt;, it will automatically expand to &lt;code&gt;:vert h&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1276" LastActivityDate="2015-10-18T02:28:05.130" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5157" PostTypeId="1" CreationDate="2015-10-18T04:29:49.897" Score="3" ViewCount="1803" Body="&lt;p&gt;I have a few questions about vi and its current relationship with Vim. First of all, is Vim minimal (i.e. the default vi on Cygwin) basically a POSIX compliant implementation of vi? I believe POSIX sets &lt;em&gt;minimum&lt;/em&gt; standards and so allows additional features not specified in the standard. Does this common minimal vi implementation have any features not found in the standard? What other common 'minimal' vi's exist?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, I am aware that there are a lot of differences between vi and Vim. Is there a comprehensive list of how Vim enhances on vi?&lt;/p&gt;&#xA;" OwnerUserId="4951" LastEditorUserId="51" LastEditDate="2016-03-02T23:11:41.577" LastActivityDate="2016-12-20T12:43:33.530" Title="What are differences between POSIX vi and minimal vi implementations, if any?" Tags="|original-vi|posix|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5158" PostTypeId="1" AcceptedAnswerId="5166" CreationDate="2015-10-18T05:01:19.347" Score="3" ViewCount="2093" Body="&lt;p&gt;I want to organize my vimrc better, so I want to put all the custom functions at bottom:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;different setting between different os&#xA;if MyDetectOS() ==? &quot;windows&quot;&#xA;    set rtp+=~/vimfiles/bundle/Vundle.vim/&#xA;    let path='~/vimfiles/bundle'&#xA;else &#xA;    set rtp+=~/.vim/bundle/Vundle.vim&#xA;endif&#xA;if MyDetectOS() ==? &quot;linux&quot; &#xA;    set clipboard=unnamedplus&#xA;else&#xA;    set clipboard=unnamed&#xA;endif&#xA;&#xA;&#xA;&#xA;function! MyDetectOS()&#xA;    if has(&quot;win32&quot;) || has(&quot;win16&quot;) || has(&quot;win64&quot;)&#xA;        return &quot;windows&quot;&#xA;    elseif has(&quot;mac&quot;) || has(&quot;macunix&quot;)&#xA;        return &quot;mac&quot;&#xA;    elseif has(&quot;win32unix&quot;)&#xA;        return &quot;cygwin&quot;&#xA;    elseif has(&quot;unix&quot;)&#xA;        let l:uname = substitute(system(&quot;uname&quot;), '\n', '', '')&#xA;        if l:uname ==? &quot;linux&quot;&#xA;            return &quot;linux&quot;&#xA;        else&#xA;            return &quot;unix&quot;&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I put the &lt;code&gt;MyDetectOS&lt;/code&gt; function at bottom like above. Then I'll get errors like below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E117: Unknown function: MyDetectOS&#xA;E15: Invalid expression: MyDetectOS() ==? &quot;linux&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why it doesn't work?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="51" LastEditDate="2015-10-18T10:06:20.553" LastActivityDate="2015-12-17T15:14:14.150" Title="How to put custom functions at bottom?" Tags="|vimscript|vimrc|functions|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5159" PostTypeId="1" CreationDate="2015-10-18T06:35:48.063" Score="2" ViewCount="1565" Body="&lt;p&gt;&lt;code&gt;:q!&lt;/code&gt; and &lt;code&gt;ZQ&lt;/code&gt; both fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a file opened; I made a new tab with &lt;code&gt;:tabnew&lt;/code&gt; (just for some register swapping); I switched back to my main file and wrote my changes to a new filename; I tried &lt;code&gt;ZQ&lt;/code&gt; to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then successfully closed the file (I don't recall how), leaving the extra [No name] tab open.  I tried to quit again; no success.  I get an error: &lt;code&gt;No write since last change (add ! to override)&lt;/code&gt; but I am &lt;em&gt;using&lt;/em&gt; ! already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is on Ubuntu 14.04 in a virtualbox.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get vim to exit???&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I got it to close—no idea which step worked, so I'm leaving this question open for the &quot;why&quot; part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Funny behavior on the no name tab—I deleted the contents and tried to exit; got the same error message &lt;em&gt;and&lt;/em&gt; the contents I had deleted reappeared!  Used &lt;code&gt;u&lt;/code&gt; to undo back to the oldest change (empty buffer) and tried to exit again; same error and content reappeared.  Made a new tab and closed it with &lt;code&gt;:q!&lt;/code&gt; successfully, then tried &lt;code&gt;ZQ&lt;/code&gt; on original no-name-and-mysteriously-not-empty tab, and it somehow worked.  :/&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="51" LastEditDate="2016-07-21T17:33:11.190" LastActivityDate="2016-07-21T18:24:49.307" Title="Why is ZQ not exiting vim?" Tags="|tabbed-user-interface|error|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5160" PostTypeId="2" ParentId="5132" CreationDate="2015-10-18T06:46:15.097" Score="1" Body="&lt;p&gt;You can directly examine the actual bit-level file contents of any file using &lt;code&gt;hexdump -C&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-C&lt;/code&gt; flag isn't strictly necessary, but it will display an ASCII view of the file side by side with the hexdump, which makes it nice and easy to spot text strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know of any better way to examine a non-text file than that.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2015-10-18T06:46:15.097" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5161" PostTypeId="1" AcceptedAnswerId="5163" CreationDate="2015-10-18T07:20:35.853" Score="1" ViewCount="65" Body="&lt;p&gt;This would be particularly useful for macros, i.e., select visually the exact lines I want to perform the macro on, and then run the macro.  But currently when it finishes the first action, the visual selection turns off, so the next action only works on the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example macro:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:&lt;/code&gt; &lt;code&gt;auto-inserted '&amp;lt;,'&amp;gt;&lt;/code&gt; &lt;code&gt;w ^R0.extension | d^M&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Where the 0 register is known to have a legal filename in it with no spaces.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to extract visually selected lines to a different file, and a macro along with Ex-mode commands would do nicely, IF I could get the Ex-mode commands to work more than once on the same selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="51" LastEditDate="2015-10-22T07:17:41.637" LastActivityDate="2015-10-22T07:17:41.637" Title="Is there a way to perform more than one Ex-mode action on the current visual selection?" Tags="|visual-mode|ex-mode|macro|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5162" PostTypeId="2" ParentId="5158" CreationDate="2015-10-18T07:27:51.043" Score="1" Body="&lt;p&gt;The error says it all:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;E117: Unknown function: MyDetectOS&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't call a function that has not been defined yet. Move the definition of the function above the point where it is first used.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="2313" LastEditDate="2015-10-18T16:34:19.367" LastActivityDate="2015-10-18T16:34:19.367" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5163" PostTypeId="2" ParentId="5161" CreationDate="2015-10-18T07:31:21.777" Score="2" Body="&lt;p&gt;Although visual mode finishes after you call your command, the marks &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; remain valid. So if you need to call additional commands you can simply use those marks again. They won't be added automatically, so you need to add them manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could reselect the last visual area using &lt;code&gt;gv&lt;/code&gt; and call your next Ex command and those marks will be added automatically again.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="4676" LastEditDate="2015-10-18T10:09:21.507" LastActivityDate="2015-10-18T10:09:21.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5164" PostTypeId="1" AcceptedAnswerId="5170" CreationDate="2015-10-18T09:44:18.617" Score="6" ViewCount="314" Body="&lt;p&gt;When I type some mathematical expressions in Tex files using Vim, e.g. &lt;code&gt;a_{2} = a_{1} + a_{0}&lt;/code&gt;, it is displayed in a human readable way like &lt;code&gt;a2 = a1 + a0&lt;/code&gt;. (Actually the numbers are of a smaller font, but I don't know how to format mathematical expressions in Vi and Vim beta.) What I would like to know is what plugin is causing this effect. I just want to disable this feature since it's really annoying when moving cursor because it looks as if each of the numbers is consisted of one character but actually I have to type arrow keys several times to move from the number to the neighboring characters since the numbers correspond to something like &lt;code&gt;_{2}&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;a href=&quot;https://github.com/Shougo/neobundle.vim&quot; rel=&quot;nofollow&quot;&gt;Neobundle&lt;/a&gt; for managing plugins and I use the following plugins,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NeoBundle 'Shougo/neocomplete'&#xA;NeoBundle 'Shougo/neosnippet'&#xA;NeoBundle 'Shougo/neosnippet-snippets'&#xA;NeoBundle 'tpope/vim-fugitive'&#xA;NeoBundle 'ctrlpvim/ctrlp.vim'&#xA;NeoBundle 'flazz/vim-colorschemes'&#xA;NeoBundle 'Shougo/unite.vim'&#xA;NeoBundle 'thinca/vim-quickrun'&#xA;NeoBundle 'davidoc/taskpaper.vim'&#xA;NeoBundle 'itchyny/lightline.vim'&#xA;NeoBundle 'altercation/vim-colors-solarized'&#xA;NeoBundle 'git://git.wincent.com/command-t.git'&#xA;NeoBundle 'vim-latex/vim-latex'&#xA;NeoBundle 'surround.vim'&#xA;NeoBundle 'mattn/emmet-vim'&#xA;NeoBundle 'kchmck/vim-coffee-script'&#xA;NeoBundle 'vim-scripts/sudo.vim'&#xA;NeoBundle 'Shougo/neomru.vim'&#xA;NeoBundle 'tomtom/tcomment_vim'&#xA;NeoBundle 'vim-scripts/AnsiEsc.vim'&#xA;NeoBundle 'hallison/vim-markdown'&#xA;NeoBundle 'elzr/vim-json'&#xA;NeoBundle 'xolox/vim-session'&#xA;NeoBundle 'xolox/vim-misc'&#xA;NeoBundle 'tmhedberg/SimpylFold'&#xA;NeoBundle 'vim-ruby/vim-ruby'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought &lt;code&gt;vim-latex&lt;/code&gt; has something to do with this but it turned out that it doesn't. &lt;/p&gt;&#xA;" OwnerUserId="3290" LastEditorUserId="1292" LastEditDate="2020-01-02T23:03:24.020" LastActivityDate="2020-01-02T23:03:24.020" Title="Mathematical expressions in TeX files are displayed in a human-readable way" Tags="|filetype-tex|plugin-vim-latex|conceal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5165" PostTypeId="1" AcceptedAnswerId="5167" CreationDate="2015-10-18T10:01:29.490" Score="7" ViewCount="1783" Body="&lt;p&gt;I'm looking for something like &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;@@&lt;/code&gt; that will work in normal mode for repeating the last Ex-mode command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per the rule of the XY problem, I'll also state the broader goal:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a fancy regex search and replace command in Ex-mode that I want to apply to &lt;em&gt;almost&lt;/em&gt; all matches in the file.  But I need to review each one before I change it.  If I could use &lt;code&gt;.&lt;/code&gt; to repeat an Ex-mode command, I could just use &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt; to do what I need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So any way to apply my search and replace to all lines &lt;strong&gt;interactively&lt;/strong&gt; would help me—but I'd still be interested in an answer to the title question.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="51" LastEditDate="2015-10-22T07:17:26.287" LastActivityDate="2015-10-22T07:17:26.287" Title="How can I repeat last Ex-mode command in normal mode?" Tags="|search|normal-mode|ex-mode|repeated-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5166" PostTypeId="2" ParentId="5158" CreationDate="2015-10-18T10:06:11.240" Score="3" Body="&lt;p&gt;The way to understand this is that a function decleration is just an assignment, similar to &lt;code&gt;x = 2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when you do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyDetectOS()&#xA;    [...]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You're really just doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyDetectOS = function!&#xA;    [...]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it doesn't work for the same reason that something like this doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = 40 + b&#xA;b = 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason that it does work in &lt;em&gt;some&lt;/em&gt; languages, is that those languages use a more advanced parser; they will first look for all functions and assign references to them, and then do a second pass where the code is actually executed with those references in place. Note that neither method can be considered &quot;better&quot; than the other; the simpler method is more flexible in some ways and suited for functional programming, the more complex allows you to not worry so much about the order of code and is somewhat less surprising for some.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One technique that you can use to &quot;get around&quot; this is put most code in a function, and kick that off at the end:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Main()&#xA;    if MyDetectOS() ==? &quot;windows&quot;&#xA;        [...]&#xA;    endif&#xA;endfunction&#xA;&#xA;function! MyDetectOS()&#xA;    [...]&#xA;endfunction&#xA;&#xA;Main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way the entire file is read, before the actual code is being executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative method putting your functions in a seperate file, and then use &lt;code&gt;source&lt;/code&gt; to include that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source ~/.vim/functions.vim&#xA;&#xA;if MyDetectOS() ==? &quot;windows&quot;&#xA;    [...]&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-12-17T15:14:14.150" LastActivityDate="2015-12-17T15:14:14.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5167" PostTypeId="2" ParentId="5165" CreationDate="2015-10-18T10:07:57.047" Score="8" Body="&lt;p&gt;Use the &lt;code&gt;/c&lt;/code&gt; flag at the end of your substitution in order to confirm each substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/foo/bar/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help s_flags&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;&amp;amp;&lt;/code&gt; to repeat the last substitution &lt;em&gt;without the flags&lt;/em&gt;. See &lt;code&gt;:help &amp;amp;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;@:&lt;/code&gt; to repeat the last ex command.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-10-18T10:07:57.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5168" PostTypeId="2" ParentId="5158" CreationDate="2015-10-18T10:54:27.023" Score="4" Body="&lt;p&gt;Vim has a neat mechanism that allows you to put all your custom functions in an &lt;code&gt;autoload&lt;/code&gt; directory somewhere in your &lt;code&gt;$RUNTIMEPATH&lt;/code&gt; and source them &lt;em&gt;only&lt;/em&gt; when needed.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Move all your custom functions to &lt;code&gt;~/.vim/autoload/myfunctions.vim&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Rename them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyDetectOS()    ===&amp;gt;    function myfunctions#MyDetectOS()&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Change all your calls to use the new name:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if myfunctions#MyDetectOS() ==? &quot;linux&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;One benefit is that functions are not sourced before their first call so that's less work for Vim on startup. Of course, your example is called in your &lt;code&gt;vimrc&lt;/code&gt; so that's a moot point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another — more obvious — one is that you have less stuff in your &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help autoload&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-10-18T10:54:27.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5169" PostTypeId="2" ParentId="5159" CreationDate="2015-10-18T15:21:05.420" Score="2" Body="&lt;p&gt;From &lt;code&gt;:help abandon&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim remembers whether you have changed the buffer.  You are protected from&#xA;  losing the changes you made.  If you try to quit without writing, or want to&#xA;  start editing another file, Vim will refuse this.  In order to overrule this&#xA;  protection, add a '!' to the command.  The changes will then be lost.  For&#xA;  example: &quot;:q&quot; will not work if the buffer was changed, but &quot;:q!&quot; will.  To see&#xA;  whether the buffer was changed use the &quot;CTRL-G&quot; command.  The message includes&#xA;  the string &quot;[Modified]&quot; if the buffer has been changed.  &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If you want to automatically save the changes without asking, switch on the&#xA;  'autowriteall' option.  'autowrite' is the associated Vi-compatible option&#xA;  that does not work for all commands.                     &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If you want to keep the changed buffer without saving it, switch on the&#xA;  'hidden' option.  See hidden-buffer.  Some commands work like this even when&#xA;  'hidden' is not set, check the help for the command.     &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-10-18T15:21:05.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5170" PostTypeId="2" ParentId="5164" CreationDate="2015-10-18T15:54:39.447" Score="5" Body="&lt;p&gt;This functionality comes from the internal LaTeX plugin. See &lt;code&gt;:h tex-conceal&lt;/code&gt; and &lt;code&gt;:h g:tex_conceal&lt;/code&gt;. You can turn it off either by setting &lt;code&gt;conceallevel=0&lt;/code&gt; or by letting &lt;code&gt;g:tex_conceal=''&lt;/code&gt;. To be more precise, you can use either of the following lines in your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tex_conceal = ''&#xA;set conceallevel = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I propose that you read &lt;code&gt;:h conceallevel&lt;/code&gt; before you set it to 0, since this will have an effect also for other file types.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-10-18T15:54:39.447" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5171" PostTypeId="1" CreationDate="2015-10-18T17:00:32.883" Score="5" ViewCount="608" Body="&lt;p&gt;How should I ideally modify an already existing syntax file without touching the file itself (since it's normally not world writeable)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to add the keyword &lt;code&gt;\autoref&lt;/code&gt; to TeX's syntax highlighting, so that it is recognized by vim as &lt;code&gt;RefZone&lt;/code&gt;. Basically I need to extend the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region texRefZone         matchgroup=texStatement start=&quot;\\\(page\|eq\)ref{&quot;      end=&quot;}\|%stopzone\&amp;gt;&quot;    contains=@texRefGroup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4955" LastActivityDate="2015-10-18T18:16:34.977" Title="Add keyword to existing syntax file without changing the original syntax file" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5172" PostTypeId="2" ParentId="5171" CreationDate="2015-10-18T18:16:34.977" Score="3" Body="&lt;p&gt;Create a file named &lt;code&gt;*.vim&lt;/code&gt; in &lt;code&gt;~/.vim/after/syntax/&lt;/code&gt; and add the desired modified line.&lt;/p&gt;&#xA;" OwnerUserId="4955" LastActivityDate="2015-10-18T18:16:34.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5173" PostTypeId="1" AcceptedAnswerId="5179" CreationDate="2015-10-18T21:09:12.897" Score="3" ViewCount="1090" Body="&lt;p&gt;If I set syntax highlighting rules manually (not in a file), is there a way to save them out to a file? Specifically, the goal is to source this file to restore the syntax highlighting rules later on.&lt;/p&gt;&#xA;" OwnerUserId="3164" LastEditorUserId="21" LastEditDate="2015-10-19T07:10:00.473" LastActivityDate="2018-05-01T22:41:33.040" Title="Is there a way to dump syntax highlighting to a .vim file?" Tags="|syntax-highlighting|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5174" PostTypeId="2" ParentId="5173" CreationDate="2015-10-18T22:05:55.427" Score="12" Body="&lt;p&gt;You can use &lt;code&gt;:redir&lt;/code&gt; for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Dump highlight definitions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir &amp;gt; file&#xA;:hi&#xA;:redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Dump syntax definitions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir &amp;gt; file&#xA;:syntax&#xA;:redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you will probably need to press &lt;code&gt;G&lt;/code&gt; and &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to get to the end of the listing if you don't want to go through everything.&lt;/li&gt;&#xA;&lt;li&gt;neither method will produce a working syntax script or a working colorscheme, you will need to edit the result anyway.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :redir&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-10-19T06:23:15.577" LastActivityDate="2015-10-19T06:23:15.577" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="5175" PostTypeId="1" CreationDate="2015-10-19T00:31:28.510" Score="10" ViewCount="1427" Body="&lt;p&gt;Here is my use case:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have lots of code which because of style enforcement we write newlines after and before each open and close brace (respectively). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function func(args) {&#xA;&#xA;    statement 1;&#xA;    statement 2;&#xA;&#xA;    if (condition) {&#xA;&#xA;        statement 3; &#xA;&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While this is nice and easy to read, I do consider this to be a expletive-worthy waste of space, but my teammates do not agree with me. Basically this is how we're checking in our code and that's that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking that maybe I can use Vim features to help me save screen real-estate, while still allowing me to write the code in the verbose way. I don't mind typing it out, I just want more efficient use of space. I figured maybe I can have Vim auto-collapse the gratuitous empty lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am finding it somewhat challenging to set this up using syntax rules because whatever I write seems to conflict with existing syntax rules, but what I decided to do as a first attempt was to write these rules which will not collide: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match aaaaaaaaa &quot;\vabcd&quot; conceal cchar=A&#xA;syntax match bbbbbbbbb &quot;\vef\ngh&quot; conceal cchar=B&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second rule here is close to what I want, which for the open bracket case is something like &lt;code&gt;/\v\{(\n\s*){2,}&lt;/code&gt;: match an open-bracket with any number greater than or equal to 2 of a newline followed by only whitespace. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens inside of vim however is the following: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If I type &lt;code&gt;abcd&lt;/code&gt; in a line, it gets concealed to &lt;code&gt;A&lt;/code&gt; as expected.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I type &lt;code&gt;ef&lt;/code&gt; on one line and &lt;code&gt;gh&lt;/code&gt; on the next, BOTH lines become concealed with &lt;code&gt;B&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I was really really hoping the two lines &lt;code&gt;ef\ngh&lt;/code&gt; would have been concealed into a single line so that I can save some vertical buffer space this way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I see now that it's probably a Vim implementation detail problem. Collapsing lines is a problem for code folding to solve, probably just out of scope as far as conceal is concerned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I wonder if there is still some way to do what I want to do. Maybe using fold markers somehow? The problem is that I need to fold only the empty whitespace.&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="51" LastEditDate="2015-10-22T07:17:12.430" LastActivityDate="2017-10-11T11:43:07.110" Title="Is there a way to conceal across lines?" Tags="|folding|conceal|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="5176" PostTypeId="1" AcceptedAnswerId="5177" CreationDate="2015-10-19T04:11:15.950" Score="14" ViewCount="7457" Body="&lt;p&gt;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 &lt;code&gt;.&lt;/code&gt; doesn't help much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything similar to &lt;code&gt;r&lt;/code&gt; that returns to normal mode after a single character—but uses insert mode instead of replace mode?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="51" LastEditDate="2015-10-22T07:16:53.913" LastActivityDate="2020-01-12T17:24:14.100" Title="Is there a way to insert a single character and then exit insert mode?" Tags="|insert-mode|normal-mode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5177" PostTypeId="2" ParentId="5176" CreationDate="2015-10-19T04:17:09.940" Score="14" Body="&lt;p&gt;If there isn't (I haven't looked), you can use this mapping in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-I&amp;gt; i &amp;lt;ESC&amp;gt;r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It &lt;code&gt;i&lt;/code&gt;nserts, places a space, &lt;code&gt;ESC&lt;/code&gt;apes, and starts a single letter &lt;code&gt;r&lt;/code&gt;eplace. This gets mapped to &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;I&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a hack, and will leave a hanging space if you hit escape before you type a letter - but it's better than nothing!&lt;/p&gt;&#xA;" OwnerUserId="3164" LastEditorUserId="3164" LastEditDate="2015-10-19T05:56:34.853" LastActivityDate="2015-10-19T05:56:34.853" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5178" PostTypeId="1" CreationDate="2015-10-19T06:23:32.940" Score="10" ViewCount="1168" Body="&lt;p&gt;So many choices!  So confusing!&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;When should one be used in preference to another?  &lt;/li&gt;&#xA;&lt;li&gt;How do these relate to each other?  &lt;/li&gt;&#xA;&lt;li&gt;What are the differences between them, anyway?&lt;/li&gt;&#xA;&lt;li&gt;How do they affect commands you type in?  &lt;/li&gt;&#xA;&lt;li&gt;How do they relate to registers, macros, marks, options, and command history?  &lt;/li&gt;&#xA;&lt;li&gt;Which nest inside which others, for example is a tab a subdivision of a window like in typical GUI programs, or is a window a subdivision of a tab?  &lt;/li&gt;&#xA;&lt;li&gt;How does this relate to multiple command line arguments (the arglist) accessible through &lt;code&gt;:next&lt;/code&gt; and &lt;code&gt;:prev&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;And lastly, which of these (if any) are &lt;code&gt;vi&lt;/code&gt; compatible?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="11986" LastEditDate="2017-03-30T12:49:23.133" LastActivityDate="2018-05-26T17:04:24.200" Title="Buffers vs tabs vs arglist vs windows" Tags="|buffers|vim-windows|tabbed-user-interface|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="5179" PostTypeId="2" ParentId="5173" CreationDate="2015-10-19T07:08:31.740" Score="4" Body="&lt;p&gt;No, there is no command that will save the syntax/highlight definitions to a file that can be parsed to restore the same definitions at a later stage. Or, to be more specific, I do not think that any such command exists. I also do not know of any plugins or addons that will do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the command history is stored in &lt;code&gt;~/.viminfo&lt;/code&gt;. Thus, if you want to copy manually typed highlight/syntax commands into a file for later sourcing, you may copy the relevant commands from the command history. Of course, this requires some manual parsing and tweaking, but I think this is the simplest solution to your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details, see:&lt;br&gt;&#xA;- &lt;code&gt;:h viminfo&lt;/code&gt;&lt;br&gt;&#xA;- &lt;code&gt;:h 'viminfo'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-10-19T07:08:31.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5180" PostTypeId="1" AcceptedAnswerId="5182" CreationDate="2015-10-19T10:44:23.883" Score="1" ViewCount="916" Body="&lt;p&gt;I'm trying to insert a filename into text as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put=expand(&quot;%&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I've the following errors:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E116: Invalid arguments for function expand(&lt;br&gt;&#xA;  E15: Invalid expression: expand(&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Why this doesn't work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's most surprising thing is that it works when using single-quote instead, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put=expand('%')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I'm trying to understand:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there any differences between using double-quotes or single-quotes? If so, what kind?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim v7.4.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-10-19T13:43:29.470" LastActivityDate="2015-10-19T13:43:29.470" Title="Why I'm getting Invalid arguments for the function when using double-quotes?" Tags="|command-line|error|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5181" PostTypeId="1" AcceptedAnswerId="5183" CreationDate="2015-10-19T11:05:03.930" Score="1" ViewCount="83" Body="&lt;p&gt;I'm trying to automatically delete useless headers when calling &lt;code&gt;vim&lt;/code&gt; from &lt;code&gt;mutt&lt;/code&gt;. I've tried running &lt;code&gt;vim&lt;/code&gt; with the following command.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim +'0,/^$/g/^\(Cc\|Bcc\|Reply-To\): $/d' /tmp/test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, I get the following feedback when it starts.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;/tmp/test&amp;quot; 11L, 60C&#xA;3 fewer lines&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For testing purposes, if I remove the range and g (i.e. &lt;code&gt;0,/^$/g&lt;/code&gt;), the command is as follows, and I do not get the additional prompt.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim +'g/^\(Cc\|Bcc\|Reply-To\): $/d' /tmp/test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Why do I get the prompt for the first command? How can I suppress it?&lt;/p&gt;&#xA;&lt;h2&gt;Edit&lt;/h2&gt;&#xA;&lt;p&gt;I seem to only get the prompt when the command deletes three lines, e.g. when &lt;code&gt;/tmp/test&lt;/code&gt; consists of the following.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;To: Foo&#xA;Cc: &#xA;Bcc: &#xA;Reply-To: &#xA;&#xA;foo&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, when there are only two lines deleted, I get no prompt, e.g. when &lt;code&gt;/tmp/test&lt;/code&gt; consists of the following.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;To: Foo&#xA;Cc: Bar&#xA;Bcc: &#xA;Reply-To: &#xA;&#xA;foo&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-10-19T12:40:48.777" Title="How can I suppress feedback when calling vim with certain commands?" Tags="|command-line|invocation|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5182" PostTypeId="2" ParentId="5180" CreationDate="2015-10-19T11:15:46.550" Score="5" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;From &lt;code&gt;:help :put&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The register can also be &lt;code&gt;=&lt;/code&gt; followed by an optional expression. The expression continues until the end of the command. You need to escape the &lt;code&gt;|&lt;/code&gt; and &lt;code&gt;&amp;quot;&lt;/code&gt; characters to prevent them from terminating the command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For the difference between &lt;code&gt;&amp;quot;&lt;/code&gt; and &lt;code&gt;'&lt;/code&gt; in the context of an expression, see &lt;code&gt;:help expr-quote&lt;/code&gt; and &lt;code&gt;:help expr-'&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="54" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-10-19T11:23:07.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5183" PostTypeId="2" ParentId="5181" CreationDate="2015-10-19T12:40:48.777" Score="4" Body="&lt;p&gt;Use &lt;code&gt;:silent&lt;/code&gt; to suppress the output of the command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +'silent 0,/^$/g/^\(Cc\|Bcc\|Reply-To\): $/d' /tmp/test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-10-19T12:40:48.777" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5184" PostTypeId="1" AcceptedAnswerId="5187" CreationDate="2015-10-19T12:45:01.013" Score="5" ViewCount="113" Body="&lt;p&gt;I did recently some &lt;a href=&quot;https://unix.stackexchange.com/a/236525/21471&quot;&gt;performance test&lt;/a&gt; where I've created artificially 1GB of random text file by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ hexdump -C /dev/urandom | rev | head -c1G | pv &amp;gt; file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which has around 13mln of lines starting from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|.....!m;}._dTO4x|  bd 9c aa 08 70 12 d6 b3  d7 3b f5 46 45 f4 43 87  00000000&#xA;|...DH...e..DN'..|  5e 8d 58 44 84 7f 5a 0d  56 1f dc 44 e4 72 6a de  01000000&#xA;|.B.~.^WE.g=...Y.|  1a 24 29 e7 ed e5 75 54  6d 76 d3 fe ec 00 95 ca  02000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and basically I would like to print the last column, in other words remove everything else exempt the last column and print the result/buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my goal is match parsing times towards &lt;code&gt;awk&lt;/code&gt;, &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;curl&lt;/code&gt; or &lt;code&gt;cut&lt;/code&gt; within reasonable limits. I understand that other tools could be more suitable for this task (e.g. regex in &lt;code&gt;grep&lt;/code&gt; is 4x faster) and it's difficult to compare these times, however as part of the learning process I'd like to see what it can be done in order to boost file processing by Ex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To focus just on parsing times, I'm ignoring saving the file as well as printing the buffer to the standard output (&lt;code&gt;%print&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my progress how the times are dropping down (on MBR OS X):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;initial version (with regex operating without silent mode):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ time ex +'%s/^.*\s//g' -cq! file &#xA;real    4m36.202s&#xA;user    3m53.264s&#xA;sys     0m41.960s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which seems it was using too much of system time&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;with silent mode (which ignores invoking the screen):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ time ex +'%s/^.*\s//g' -scq! file&#xA;real    3m39.654s&#xA;user    3m37.176s&#xA;sys     0m2.126s&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;converting RegEx into normal keystrokes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ time ex +'%norm $Bd0' -scq! file&#xA;real    3m12.051s&#xA;user    3m9.797s&#xA;sys     0m1.957s&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;now, I've tried to use &lt;a href=&quot;https://vi.stackexchange.com/q/3382/467&quot;&gt;a black hole register&lt;/a&gt;, but it didn't speed up anything, just opposite:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ time ex +'%norm $B&quot;_d0' -scq! file&#xA;real    3m21.275s&#xA;user    3m18.800s&#xA;sys     0m2.107s&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;adding &lt;code&gt;-u NONE&lt;/code&gt; makes - no difference&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;added &lt;code&gt;-n&lt;/code&gt; (for no swap file) - no difference&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;adding &lt;code&gt;--startuptime timing.out&lt;/code&gt; gives the following highest times (in msec):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;000.008  000.008: --- VIM STARTING ---&#xA;004.124  003.007: shell init&#xA;3372.778  3365.165: opening buffers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which covers only &amp;lt;3.5 seconds of a starting time in total&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;what else can I try?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Are there any other methods of speeding up Ex processing for larger files or some ways which are quicker than the others? Or basically this is how it is?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-10-19T14:44:08.237" Title="What are the methods of speeding up parsing of a big file using Ex?" Tags="|command-line|ex-mode|linux|performance|large-documents|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5185" PostTypeId="1" CreationDate="2015-10-19T13:01:38.397" Score="1" ViewCount="37" Body="&lt;p&gt;I am trying to enter the i_CTRL-X Sub-Mode by pressing &lt;code&gt;c-x&lt;/code&gt; in insert mode.  But &lt;code&gt;c-x&lt;/code&gt; does nothing.  Is there any way to know what &lt;code&gt;c-x&lt;/code&gt; in the insert mode is mapped to, so I can troubleshoot it?  I am using YouCompleteMe, which may cause the conflict, i am Just trying to figure out how to get line completion to work.&lt;/p&gt;&#xA;" OwnerUserId="3050" LastActivityDate="2015-10-19T13:40:28.633" Title="Tracking Key Combinations" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5186" PostTypeId="2" ParentId="5185" CreationDate="2015-10-19T13:40:28.633" Score="2" Body="&lt;p&gt;Yes, you can check what &lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; is mapped to in insert mode with &lt;code&gt;:imap &amp;lt;c-x&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A useful debugging workflow is to start from scratch. First open Vim with no vimrc, e.g. from a shell type &lt;code&gt;vim -u NONE&lt;/code&gt;. Verify that things work as expected. Then start with an empty vimrc file and copy parts of your original vimrc file one after another until you reproduce the problem.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-10-19T13:40:28.633" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5187" PostTypeId="2" ParentId="5184" CreationDate="2015-10-19T14:44:08.237" Score="3" Body="&lt;p&gt;Switch to the old regexp engine, it's much faster than the new one for the particular regexp you're using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set regexpengine=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also turn off stuff you definitely won't be using (cf. &lt;a href=&quot;http://vim.wikia.com/wiki/Faster_loading_of_large_files&quot; rel=&quot;nofollow&quot;&gt;wiki&lt;/a&gt;), but that will have a much smaller effect that the regexp engine.  To sum it up, run &lt;code&gt;ex&lt;/code&gt; with the following &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set regexpengine=1&#xA;set eventignore+=FileType&#xA;set bufhidden=unload&#xA;set buftype=nowrite&#xA;set undolevels=-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-10-19T14:44:08.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5188" PostTypeId="1" AcceptedAnswerId="5189" CreationDate="2015-10-19T15:15:53.917" Score="15" ViewCount="13723" Body="&lt;p&gt;I want all of my files ending in &lt;code&gt;.tex&lt;/code&gt; to have line length 80. So whenever I open a &lt;code&gt;.tex&lt;/code&gt; file in vim I type &lt;code&gt;:set tw=79&lt;/code&gt;. What would I put in my .vimrc to automate this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if I wanted it to work with a specific list of filetypes, say, &lt;code&gt;.md&lt;/code&gt;, &lt;code&gt;.txt&lt;/code&gt;, and &lt;code&gt;.tex&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="4960" LastActivityDate="2019-02-04T12:28:09.510" Title="How do I run a specific vim command when opening a file with a given extension?" Tags="|vimrc|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5189" PostTypeId="2" ParentId="5188" CreationDate="2015-10-19T15:47:54.667" Score="14" Body="&lt;p&gt;Instead of checking the extension and setting the textwidth accordingly you could simply create a &lt;code&gt;tex.vim&lt;/code&gt; (the name must match the filetype) file in &lt;code&gt;.vim/ftplugin/&lt;/code&gt; or for Windows &lt;code&gt;$HOME/vimfiles/ftplugin/&lt;/code&gt; and set textwidth there. This will help you to keep your .vimrc clean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your &lt;code&gt;.vim/ftplugin/tex.vim&lt;/code&gt; file would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal textwidth=79&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As 8bittree said in the comments you also have to enable &lt;code&gt;filetype plugins&lt;/code&gt; in your vimrc (I woudln't know why anybody would not enable it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read this for more information: &lt;a href=&quot;http://vim.wikia.com/wiki/Keep_your_vimrc_file_clean&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Keep_your_vimrc_file_clean&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4413" LastEditorUserId="51" LastEditDate="2019-02-04T12:28:09.510" LastActivityDate="2019-02-04T12:28:09.510" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5190" PostTypeId="2" ParentId="3024" CreationDate="2015-10-19T15:57:07.607" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://vim-latex.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;vim-latexsuite&lt;/a&gt; is a very good addition for writing LaTeX documents and will handle spell checking as you want it to. Meaning, ignore equasions in spell checking and it also does a lot of other great stuff.&lt;/p&gt;&#xA;" OwnerUserId="4413" LastActivityDate="2015-10-19T15:57:07.607" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5191" PostTypeId="1" AcceptedAnswerId="5192" CreationDate="2015-10-19T16:36:12.337" Score="3" ViewCount="1629" Body="&lt;p&gt;Is there a command to display a count of the number of lines you have selected in Visual Mode in VIM?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2015-10-19T16:43:41.997" Title="Displaying the number of lines you have selected in Visual Mode?" Tags="|visual-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5192" PostTypeId="2" ParentId="5191" CreationDate="2015-10-19T16:43:41.997" Score="9" Body="&lt;p&gt;&lt;kbd&gt;g&lt;/kbd&gt; then &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt; will spit out something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Selected 10 of 4123 Lines; 67 of 11111 Words; 400 of 40000 Bytes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4913" LastActivityDate="2015-10-19T16:43:41.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5193" PostTypeId="2" ParentId="5188" CreationDate="2015-10-19T18:38:51.137" Score="12" Body="&lt;p&gt;In &lt;code&gt;~/.vimrc&lt;/code&gt; you can add the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufReadPost,BufNewFile *.md,*.txt,*.tex setlocal tw=79&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;For extra commands, separate them by &lt;code&gt;|&lt;/code&gt;.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will set your settings right after reading the file, or opening a new file into the buffer for specific extensions.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="51" LastEditDate="2019-02-04T12:27:26.547" LastActivityDate="2019-02-04T12:27:26.547" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5195" PostTypeId="1" AcceptedAnswerId="5197" CreationDate="2015-10-20T07:02:08.373" Score="31" ViewCount="7601" Body="&lt;p&gt;I know &quot;expose one more line&quot; for Ctrl-E, but why use Ctrl-Y to expose one more line at the top?  Is there an easy mnemonic for this that I'm missing?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="51" LastEditDate="2022-09-23T11:06:38.500" LastActivityDate="2022-10-26T14:30:10.760" Title="What is the mnemonic for Ctrl-Y (in normal mode)?" Tags="|normal-mode|scrolling|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5196" PostTypeId="1" CreationDate="2015-10-20T09:19:20.993" Score="7" ViewCount="3107" Body="&lt;p&gt;I am relatively new to using &lt;code&gt;vim&lt;/code&gt;. I have to admit it is a powerful tool, however it can be very frustrating if one doesn't learn how to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whatever, there is one or two things that annoy me terribly:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;How can I get to the end of the previous line/start of the next one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume I have this text file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abcdef&#xA;| &amp;lt;- cursor, not character&#xA;ghijkl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In all the text editor I have seen, pressing &lt;code&gt;left-arrow&lt;/code&gt; would bring me to the &lt;code&gt;f&lt;/code&gt; letter, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abcdef| &amp;lt;- cursor, not character&#xA;&#xA;ghijkl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Idem est, pressing &lt;code&gt;right-arrow&lt;/code&gt; would bring me to the beginning of the next line (before the &lt;code&gt;g&lt;/code&gt; character).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;vim&lt;/code&gt; doesn't do that, the cursor is stuck if I don't press &lt;code&gt;up/down-arrow&lt;/code&gt;. Can I change that? It is &lt;em&gt;very&lt;/em&gt; annoying.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How can I go directly to the end of the last line by pressing &lt;code&gt;down-arrow&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume I have this text file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; a&#xA; b&#xA;|c   &amp;lt;- '|' is the cursor&#xA; def&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By pressing &lt;code&gt;down-arrow&lt;/code&gt;, I will go before the letter &lt;code&gt;d&lt;/code&gt;, okay, but if I click again, nothing will happen. However, I would like the cursor to go to the end of that line (since it is the last one of the text file). How? The only solution I found was to put several new empty line...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Why does the cursor can't go to the last character in command mode? It keeps being stuck like this: &lt;code&gt;abcde|f&lt;/code&gt;, without being able to go after the &lt;code&gt;f&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4972" LastEditorUserId="205" LastEditDate="2015-10-22T03:04:01.920" LastActivityDate="2015-10-22T03:04:01.920" Title="How to change the behavior of cursor motions? (ex: go from one line to the end of the previous one)" Tags="|cursor-movement|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5197" PostTypeId="2" ParentId="5195" CreationDate="2015-10-20T09:53:51.720" Score="39" Body="&lt;p&gt;Bill Joy and Mark Horton wrote in &lt;a href=&quot;http://docs.freebsd.org/44doc/usd/12.vi/paper-2.html#section10&quot; rel=&quot;noreferrer&quot;&gt;their original vi manual&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If you want to see more of the file below where you are, you can hit &lt;code&gt;^E&lt;/code&gt; to expose one more line at the bottom of the screen, leaving the cursor where it is. The command &lt;code&gt;^Y&lt;/code&gt; (which is hopelessly non-mnemonic, but next to &lt;code&gt;^U&lt;/code&gt; on the keyboard) exposes one more line at the top of the screen.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So, &amp;quot;next to u&amp;quot; was the motivation, and can serve as a mnemonic, I guess.&lt;/p&gt;&#xA;&lt;p&gt;The Y also sort of represents an arrow pointing up (↑) if you squint a little bit (it has the head of the arrow inverted).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2022-10-26T14:30:10.760" LastActivityDate="2022-10-26T14:30:10.760" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5198" PostTypeId="2" ParentId="5196" CreationDate="2015-10-20T09:57:08.467" Score="2" Body="&lt;p&gt;Simple solution (by simple I mean no fancy mappings or similar). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For &lt;code&gt;1&lt;/code&gt;&lt;/strong&gt; are the combinations:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;kA&lt;/code&gt;: &lt;code&gt;k&lt;/code&gt; go one line up, &lt;code&gt;A&lt;/code&gt; append text to the end of the line (your &quot;left-arrow&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;jI&lt;/code&gt;: &lt;code&gt;j&lt;/code&gt; go one line down, &lt;code&gt;I&lt;/code&gt; insert text before the first non-blank in the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These commands are even faster typed then moving to the arrow keys. Generally speaking I think Vim is designed to never have to use arrow keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For &lt;code&gt;2&lt;/code&gt;&lt;/strong&gt; &lt;code&gt;jI&lt;/code&gt; does also do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For &lt;code&gt;3&lt;/code&gt;&lt;/strong&gt; this is the expected behaviour for the cursor.  It would be very irritating if &lt;code&gt;j&lt;/code&gt; would jump to the end of the line. Or am I understanding you wrong?&lt;/p&gt;&#xA;" OwnerUserId="4413" LastEditorUserId="4413" LastEditDate="2015-10-20T10:25:03.957" LastActivityDate="2015-10-20T10:25:03.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5199" PostTypeId="2" ParentId="5196" CreationDate="2015-10-20T12:31:45.430" Score="9" Body="&lt;p&gt;You can use the &lt;code&gt;whichwrap&lt;/code&gt; setting to change this behaviour. Try &lt;code&gt;:set whichwrap+=&amp;lt;,&amp;gt;,h,l&lt;/code&gt; to allow the left and right arrow keys and &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt; to wrap. See &lt;code&gt;:help whichwrap&lt;/code&gt; for more options.&lt;/p&gt;&#xA;" OwnerUserId="454" LastActivityDate="2015-10-20T12:31:45.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5200" PostTypeId="2" ParentId="5196" CreationDate="2015-10-20T14:50:57.167" Score="5" Body="&lt;p&gt;All of these are normal mode commands and leave you in normal mode:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt; will move the cursor to the end of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; will move the cursor to the beginning of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; will move the cursor to the first &lt;em&gt;non-blank&lt;/em&gt; character in the line. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;3&quot;&gt;&#xA;  &lt;li&gt;Why does the cursor can't go to the last character in command mode? It keeps being stuck like this: &lt;code&gt;abcde|f&lt;/code&gt;, without being able to go after the f.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Vim &lt;em&gt;is&lt;/em&gt; on the last character in the line (newlines don't count), so it makes sense that the cursor can't move after it, because there's nothing there. To help visualize it, you may want to set the cursor to a block cursor or horizontal line, rather than the misleading vertical line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vgtlT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vgtlT.png&quot; alt=&quot;vertical cursor&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/8FK8H.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8FK8H.png&quot; alt=&quot;block cursor&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/EyLK7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EyLK7.png&quot; alt=&quot;horizontal cursor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In all three of those images, the cursor was in the same location, simply the shape was changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In insert mode, the cursor &lt;em&gt;can&lt;/em&gt; move beyond the last character in a line, because it indicates where the &lt;em&gt;new&lt;/em&gt; character will be placed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:he 'guicursor'&lt;/code&gt; for information on how to change the cursor shape. Here's a simple setup that sets the cursor to a block in all modes except insert mode, in which it's a 10%-wide vertical line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set guicursor=a:block-Cursor,i:ver10-Cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is tested in GVim, console based version may need additional configuration.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2015-10-20T14:50:57.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5201" PostTypeId="1" AcceptedAnswerId="5203" CreationDate="2015-10-20T15:45:36.493" Score="39" ViewCount="19360" Body="&lt;p&gt;I edit C++ code in &lt;code&gt;.cpp&lt;/code&gt; files, while template code goes into &lt;code&gt;.tcc&lt;/code&gt; files. When I open such a file, no syntax highlighting is available. I tried &lt;code&gt;set syntax=cpp&lt;/code&gt; in a a &lt;code&gt;tpp.vim&lt;/code&gt; file in &lt;code&gt;~/.vim/ftplugin/&lt;/code&gt;, but it does not do anything, while in the editor it works. Is there some way to have vim treat specific extensions as synonymous with others?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastEditorUserId="1066" LastEditDate="2016-12-31T14:15:24.753" LastActivityDate="2018-09-05T10:09:21.413" Title="How do I tell vim that some file extensions are synonymous?" Tags="|syntax-highlighting|filetype|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5202" PostTypeId="2" ParentId="5201" CreationDate="2015-10-20T15:57:10.660" Score="26" Body="&lt;p&gt;You could do (in your global &lt;code&gt;.vimrc&lt;/code&gt;): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter *.tpp :setlocal filetype=cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1543" LastActivityDate="2015-10-20T15:57:10.660" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5203" PostTypeId="2" ParentId="5201" CreationDate="2015-10-20T17:42:00.780" Score="32" Body="&lt;p&gt;The preferred approach is to create a &lt;code&gt;~/.vim/filetype.vim&lt;/code&gt;, as mentioned in &lt;code&gt;:help 43.2&lt;/code&gt; and explained in &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-26.8&quot;&gt;Vim FAQ 26.8&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A better alternative to the above approach is to create a filetype.vim&#xA;  file in the ~/.vim directory (or in one of the directories specified&#xA;  in the 'runtimepath' option) and add the following lines: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; my filetype file&#xA;if exists(&quot;did_load_filetypes&quot;)&#xA;    finish&#xA;endif&#xA;augroup filetypedetect&#xA;    au! BufRead,BufNewFile *.x       setfiletype c&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;did_load_filetypes&lt;/code&gt; shouldn't cause you any problems; it would only require a Vim restart after it is changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is necessary in order to avoid multiple and unnecessary loading of this file, and it is inherited from the base file ($VIMRUNTIME/filetype.vim):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Vim support file to detect file types&#xA;&quot;&#xA;&quot; Maintainer:   Bram Moolenaar &amp;lt;Bram@vim.org&amp;gt;&#xA;&quot; Last Change:  2014 Jun 12&#xA;&#xA;&quot; Listen very carefully, I will say this only once&#xA;if exists(&quot;did_load_filetypes&quot;)&#xA;  finish&#xA;endif&#xA;let did_load_filetypes = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information check &lt;code&gt;:help new-filetype&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2015-11-10T15:12:18.997" LastActivityDate="2015-11-10T15:12:18.997" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5205" PostTypeId="1" AcceptedAnswerId="5210" CreationDate="2015-10-20T23:48:53.773" Score="15" ViewCount="2461" Body="&lt;p&gt;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 &lt;code&gt;:scriptnames&lt;/code&gt; command? In the help for all flavours of &lt;code&gt;grep&lt;/code&gt; and &lt;code&gt;vimgrep&lt;/code&gt; there is only &lt;code&gt;{file}&lt;/code&gt; as a place where to perform search.&lt;/p&gt;&#xA;" OwnerUserId="1378" LastActivityDate="2020-09-22T20:01:21.467" Title="How to grep in ex command output?" Tags="|vimscript|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5206" PostTypeId="1" AcceptedAnswerId="5208" CreationDate="2015-10-21T01:38:46.490" Score="0" ViewCount="886" Body="&lt;p&gt;I have added CSS tags to my project &lt;code&gt;tags&lt;/code&gt; file by adding this to &lt;code&gt;~/.ctags&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--langdef=css&#xA;--langmap=css:.css&#xA;--langmap=css:+.scss&#xA;--langmap=css:+.sass&#xA;--langmap=css:+.styl&#xA;--langmap=css:+.less&#xA;--regex-css=/^[ \t]*(([A-Za-z0-9_-]+[ \t\n,]+)+)\{/\1/t,tag,tags/&#xA;--regex-css=/^[ \t]*#([A-Za-z0-9_-]+)/#\1/i,id,ids/&#xA;--regex-css=/^[ \t]*\.([A-Za-z0-9_-]+)/.\1/c,class,classes/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then, after project tags file is updated, it now has entries like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.bg-danger  public/CSS/framework/components/utilities.css   /^.bg-danger {$/;&quot;  c&#xA;.bg-faded   public/CSS/framework/components/utilities.css   /^.bg-faded {$/;&quot;   c&#xA;.bg-info    public/CSS/framework/components/utilities.css   /^.bg-info {$/;&quot;    c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like completion to work when writing html in html or PHP files, e.g. if I am in &lt;code&gt;-- INSERT --&lt;/code&gt; mode and have a partial like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    &amp;lt;div class=&quot;bg-d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Im trying to get completion assistance with &lt;kbd&gt;Ctrl - x&lt;/kbd&gt;, &lt;kbd&gt;Ctrl - ]&lt;/kbd&gt; but vim simply returns&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;-- Tag completion (^]^N^P) Pattern not found&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Im not fussed whether completion is invoked via the &lt;kbd&gt;Ctrl - ]&lt;/kbd&gt; command specifically (but I dont really want to install a plugin for this), I just want completion assistance for CSS classes (and ids) as I type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relevant info&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;terminal vim - version 7.4.52&lt;/li&gt;&#xA;&lt;li&gt;Plugins - ctrlp&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2015-10-21T08:05:52.413" LastActivityDate="2015-10-21T08:51:13.227" Title="Enable completion for CSS using ctags" Tags="|autocompletion|ctags|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5207" PostTypeId="2" ParentId="5205" CreationDate="2015-10-21T08:08:53.410" Score="5" Body="&lt;p&gt;First, you need to grab the output of &lt;code&gt;scriptnames&lt;/code&gt; and put it into a buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:redir&lt;/code&gt; for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @a       &quot; redirect output of following ex commands to register a&#xA;:scriptnames    &quot; press G to get to the end of the output if it's too long&#xA;:redir END      &quot; end the redirection&#xA;:vnew           &quot; new buffer in vertical window&#xA;:put a          &quot; put content of register&#xA;/pattern        &quot; search for 'pattern'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That said, a &lt;code&gt;:scriptname&lt;/code&gt; output that's too long to be scanned with your own eyes may be a symptom of deeper problems.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-10-21T08:08:53.410" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5208" PostTypeId="2" ParentId="5206" CreationDate="2015-10-21T08:43:17.107" Score="2" Body="&lt;p&gt;The problem comes from the leading dot before class names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your search pattern leaves it out but you add it afterwards and, because tag search honors your &lt;code&gt;iskeyword&lt;/code&gt; setting which doesn't contain &lt;code&gt;.&lt;/code&gt;, Vim looks for &lt;code&gt;^foo&lt;/code&gt; instead of &lt;code&gt;^.foo&lt;/code&gt; in your tag files and, logically, doesn't find it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You basically have two ways to fix that issue…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In ctags&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remove &lt;code&gt;.&lt;/code&gt; from the second part of your pattern. This will index &lt;code&gt;.foo&lt;/code&gt; as &lt;code&gt;foo&lt;/code&gt; and allow Vim to find it when doing tag-based completion.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--regex-css=/^[ \t]*\.([A-Za-z0-9_-]+)/.\1/c,class,classes/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--regex-css=/^[ \t]*\.([A-Za-z0-9_-]+)/\1/c,class,classes/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In Vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add &lt;code&gt;.&lt;/code&gt; to the &lt;code&gt;iskeyword&lt;/code&gt; option to allow Vim to search for &lt;code&gt;^.foo&lt;/code&gt; instead of &lt;code&gt;^foo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword+=.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that both methods probably have shortcomings so it may be a good idea to do some real world testing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might find my &lt;a href=&quot;https://gist.github.com/romainl/085b4db4a26a06ec7e16&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;.ctags&lt;/code&gt;&lt;/a&gt; interesting.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-10-21T08:51:13.227" LastActivityDate="2015-10-21T08:51:13.227" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5209" PostTypeId="2" ParentId="5196" CreationDate="2015-10-21T10:08:57.867" Score="3" Body="&lt;p&gt;For 1: Use &lt;code&gt;Space&lt;/code&gt; and &lt;code&gt;Backspace&lt;/code&gt; to do what you are used to arrow keys doing.  &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt; will never move you off the current line, but &lt;code&gt;Space&lt;/code&gt; and &lt;code&gt;Backspace&lt;/code&gt; will.  (This is default in &lt;code&gt;vim&lt;/code&gt; but not in &lt;code&gt;vi&lt;/code&gt;; it's adjustable with the &lt;code&gt;whichwrap&lt;/code&gt; option as others have mentioned.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;code&gt;+&lt;/code&gt; (or &lt;code&gt;Return&lt;/code&gt;) and &lt;code&gt;-&lt;/code&gt; will take you to the &lt;em&gt;non-whitespace&lt;/em&gt; start of the next line or previous line, respectively.  Can be very handy in tab-structured documents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For 2: Use &lt;code&gt;G$&lt;/code&gt; to go to the end of the last line.  It's two keystrokes, yes, but does exactly what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you may want to learn about &lt;code&gt;gi&lt;/code&gt;, which begins inserting text at the same place you were inserting text last time you left insert mode.  This would probably handle some use cases for going to the end of the document.  (Not all of them.  If you've done some other insertion edits such that &lt;code&gt;gi&lt;/code&gt; wouldn't go to the end of the document, and now want to start adding text at the end of the last line, just use &lt;code&gt;GA&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For 3: The only reason I can think of why you would want this behavior, is if you always use &lt;code&gt;i&lt;/code&gt; to insert.  &lt;strong&gt;Use &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;A&lt;/code&gt; to append text&lt;/strong&gt;.  &lt;code&gt;A&lt;/code&gt; will enter insert mode and append text to the end of the current line.  &lt;code&gt;a&lt;/code&gt; will append text after the current character position.  There, now you don't need to move your cursor off of the text of the line.  :)&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="4676" LastEditDate="2015-10-21T10:27:50.670" LastActivityDate="2015-10-21T10:27:50.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5210" PostTypeId="2" ParentId="5205" CreationDate="2015-10-21T10:23:45.767" Score="7" Body="&lt;p&gt;You could do: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:redir =&amp;gt; scriptn | sil exe 'scriptnames' | redir end | echo(system('grep pattern',scriptn))&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What it does: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir =&amp;gt; scriptn                      &quot;redirect following output to variable scriptn&#xA;:sil exe 'scriptnames'                 &quot;silently execute scriptnames&#xA;:redir end                             &quot;end the redirection&#xA;:echo(system('grep pattern',scriptn))  &quot;echo the call of grep witht that input with the pattern `pattern`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1543" LastEditorUserId="1452" LastEditDate="2020-04-27T06:17:03.807" LastActivityDate="2020-04-27T06:17:03.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5211" PostTypeId="1" AcceptedAnswerId="5212" CreationDate="2015-10-21T13:55:56.570" Score="1" ViewCount="213" Body="&lt;p&gt;For instance, let's say I want to change all instances of &lt;code&gt;Ctrl-m&lt;/code&gt;, &lt;code&gt;Ctrl-p&lt;/code&gt;, etc., in a document to the more conventional &lt;code&gt;^M&lt;/code&gt;, &lt;code&gt;^P&lt;/code&gt;, etc.  I can use &lt;code&gt;:s/Ctrl-\(.\)/^\1&lt;/code&gt;to &lt;em&gt;almost&lt;/em&gt; accomplish this, but it leaves the letters in lowercase where they should be in uppercase.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I change the case of a backreferenced regex match in a Ex-mode substitute command?  (&lt;code&gt;:s&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="51" LastEditDate="2015-10-22T07:15:55.863" LastActivityDate="2015-10-22T07:15:55.863" Title="How can you change the case of a backreference in Ex-mode substitute command?" Tags="|regular-expression|substitute|ex-mode|letter-case|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5212" PostTypeId="2" ParentId="5211" CreationDate="2015-10-21T14:01:13.967" Score="2" Body="&lt;p&gt;Perhaps like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/Ctrl-\(.\)/^\u\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information: &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#s%2F%5Cu&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help s/\u&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-10-21T14:01:13.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5213" PostTypeId="1" AcceptedAnswerId="5217" CreationDate="2015-10-21T14:14:41.820" Score="16" ViewCount="6918" Body="&lt;p&gt;I think it would be useful to have possibility to swap &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; values in the code rapidly, with combination &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt; or &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt;. Is there some plugin for that or something else?&lt;/p&gt;&#xA;" OwnerUserId="500" LastEditorUserId="51" LastEditDate="2015-10-22T07:14:53.893" LastActivityDate="2020-02-20T17:06:18.227" Title="Swap values &quot;true&quot; and &quot;false&quot; via ctrl+a, ctrl+x" Tags="|key-bindings|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5214" PostTypeId="2" ParentId="5213" CreationDate="2015-10-21T14:18:47.087" Score="13" Body="&lt;p&gt;There is &lt;a href=&quot;https://github.com/AndrewRadev/switch.vim&quot; rel=&quot;noreferrer&quot;&gt;switch.vim&lt;/a&gt;, and it's customizable.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The main entry point of the plugin is a single command, &lt;code&gt;:Switch&lt;/code&gt;. When the command is executed, the plugin looks for one of a few specific patterns under the cursor and performs a substition depending on the pattern.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For example if the cursor is on the &lt;code&gt;true&lt;/code&gt; in the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;flag = true&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then upon executing &lt;code&gt;:Switch&lt;/code&gt;, the &lt;code&gt;true&lt;/code&gt; will turn into &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="467" LastEditDate="2015-10-26T10:37:37.763" LastActivityDate="2015-10-26T10:37:37.763" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5215" PostTypeId="2" ParentId="5015" CreationDate="2015-10-21T16:25:26.773" Score="8" Body="&lt;p&gt;It was the &lt;em&gt;inner&lt;/em&gt; motions that made my eyes turn into floating hearts for Vim. In addition to &lt;code&gt;.&lt;/code&gt; repeats and prefixing stuff with counts, showing inner motions is usually one of the first things I show/share when someone asks me about vim. &lt;code&gt;ci(&lt;/code&gt; or &lt;code&gt;gUi&amp;gt;&lt;/code&gt; or &lt;code&gt;diw&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g;&lt;/code&gt; and &lt;code&gt;g,&lt;/code&gt; to jump around to the places you've edited is usually good for an eye widening or two.&lt;/p&gt;&#xA;" OwnerUserId="4993" LastActivityDate="2015-10-21T16:25:26.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5217" PostTypeId="2" ParentId="5213" CreationDate="2015-10-21T17:11:53.347" Score="8" Body="&lt;p&gt;I wrote a plugin (&lt;a href=&quot;https://github.com/sagarrakshe/toggle-bool&quot; rel=&quot;nofollow noreferrer&quot;&gt;toggle-bool&lt;/a&gt;) to toggle the boolean values you can try it. It supports the following boolean values:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;true&lt;/code&gt; &amp;lt;-&gt; &lt;code&gt;false&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yes&lt;/code&gt; &amp;lt;-&gt; &lt;code&gt;no&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;on&lt;/code&gt; &amp;lt;-&gt; &lt;code&gt;off&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; &amp;lt;-&gt; &lt;code&gt;1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4996" LastEditorUserId="4996" LastEditDate="2018-11-27T07:57:57.543" LastActivityDate="2018-11-27T07:57:57.543" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5218" PostTypeId="1" AcceptedAnswerId="5221" CreationDate="2015-10-21T20:05:43.080" Score="3" ViewCount="630" Body="&lt;p&gt;For the following switch block:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/kM628.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kM628.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If I select the switch block and apply the &lt;code&gt;auto format&lt;/code&gt; command, the &lt;code&gt;=&lt;/code&gt; key, I get the following:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OANnG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OANnG.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The block is formatted correctly in the first image, but it gets messed up by &lt;code&gt;auto format&lt;/code&gt;.  It works fine on &lt;code&gt;if&lt;/code&gt; blocks, but really messes up the case blocks.  What controls the auto-format?  Is there any way I can adjust the configuration to apply camel style brackets?&lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-10-22T16:33:27.503" Title="Auto Indent (the = key) of C switch block" Tags="|indentation|formatting|filetype-c|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5219" PostTypeId="1" AcceptedAnswerId="5220" CreationDate="2015-10-21T20:20:49.353" Score="9" ViewCount="522" Body="&lt;p&gt;Occasionally, I will press &lt;code&gt;Ctrl-x&lt;/code&gt; and &lt;code&gt;Ctrl-a&lt;/code&gt; to increment/decrement the highlighted number, and the opposite operation will happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This usually happens when I'm working with with registers (&lt;code&gt;q&lt;/code&gt;).  Could I possibly be setting up some sort of alias between the two commands?  How do I fix it besides opening/closing vim?&lt;/p&gt;&#xA;" OwnerUserId="3209" LastEditorUserId="51" LastEditDate="2015-10-22T07:14:35.463" LastActivityDate="2015-10-22T07:14:35.463" Title="Ctrl-A and Ctrl-X seemed to be switched sometimes!" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5220" PostTypeId="2" ParentId="5219" CreationDate="2015-10-21T20:25:01.993" Score="11" Body="&lt;p&gt;Nevermind, the number I was incrementing was in a date time (like &lt;code&gt;2015-08-07&lt;/code&gt;) and I think vim was interpreting it as a negative integer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D'oh.&lt;/p&gt;&#xA;" OwnerUserId="3209" LastActivityDate="2015-10-21T20:25:01.993" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5221" PostTypeId="2" ParentId="5218" CreationDate="2015-10-22T00:34:24.127" Score="6" Body="&lt;p&gt;The configuration of C indenting in Vim is controlled by the &lt;code&gt;cinoptions&lt;/code&gt; option. That particular aspect of indenting is controlled by the &lt;code&gt;l&lt;/code&gt; (lower-case L) flag. When set to any value other than 1, it will &quot;align with a case label instead of the statement after it in the same line.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you can get the indenting style you want by putting this in your &lt;code&gt;~/.vimrc&lt;/code&gt; on Unix or &lt;code&gt;~/_vimrc&lt;/code&gt; on Windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cinoptions+=l1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help cino-l&#xA;:help cinoptions-values&#xA;:help 'cinoption'&#xA;:help C-indenting&#xA;:help 30.2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Those topics are ordered roughly from particular to general aspects of C indenting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find out more about auto-format here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help auto-format&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;although I don't think that's what you mean by &quot;auto format&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, those &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; are called braces. Brackets are the more squarish &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-10-22T00:34:24.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5222" PostTypeId="1" CreationDate="2015-10-22T09:06:39.113" Score="2" ViewCount="708" Body="&lt;p&gt;Somehow every line in my Vim is bold. I'm using Consolas, which has a Bold typeface. Also, after leaving Vim, terminal is shown in Regular. The screenshot shows a small document that should have both Regular and Bold. It only seems to change in color a bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BIJ8m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BIJ8m.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've had it working before, but even then, the difference between Regular and Bold was an absolute minimum. Using Vim with SPF13 and iTerm2. &lt;/p&gt;&#xA;" OwnerUserId="5003" LastEditorUserId="23502" LastEditDate="2022-10-24T06:20:24.740" LastActivityDate="2022-10-24T06:20:24.740" Title="Every line shows bold" Tags="|font|iterm2|plugin-spf13|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5223" PostTypeId="2" ParentId="4773" CreationDate="2015-10-22T11:10:44.860" Score="1" Body="&lt;p&gt;There are multiple ways to achieve what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5elD&#xA;6f D&#xA;6wDx&#xA;6whD&#xA;# ... probably others too&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All these cost you just +1 keystroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If deleting starting from current position +1 was possible, then it will make sense to ask for deleting from current position -1 too. It would raise the question about other commands too, for example deleting until the end of the file from the current line +1, -1, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can this possibly work? I see only two possible ways:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pass a parameter to the existing commands to modify their behavior with the desired nuance. This will inevitably cost you +1 keystroke, so you won't be better off than what exists already&lt;/li&gt;&#xA;&lt;li&gt;Have a new keystroke for this behavior. Most keys on the keyboard already have something else more important and powerful to do, it would be a very tough choice to assign one of the unused keys for such a small functionality&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, I don't see a way to have something better than the current features :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I agree that it's a bit unfortunate that there is no &quot;atomic&quot; command to delete from the next character. I see the practical use of what you're asking: when cutting short a text, I often want to delete starting from a space character, because I don't want to leave trailing whitespace at the end of lines (Git complains about it, for example). And the &lt;code&gt;w&lt;/code&gt; and &lt;code&gt;e&lt;/code&gt; word jumping commands are not very suitable for this, as &lt;code&gt;w&lt;/code&gt; jumps to first letters and &lt;code&gt;e&lt;/code&gt; jumps to last letters, and there's no shortcut to jump on the space after a word, except explicit searches like &lt;code&gt;f&lt;/code&gt;. So I understand and even share your need. I just don't see where this can be squeezed in the existing functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best alternative I can think of is to record the action in a macro, let's say &lt;code&gt;d&lt;/code&gt;. At the end of a word (on the last letter), record like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qdlDq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, you can redo this action at the end of another word with &lt;code&gt;@d&lt;/code&gt;.&#xA;To do it repeatedly, you can do &lt;code&gt;@@&lt;/code&gt;.&#xA;When doing it repeatedly this is faster to type than &lt;code&gt;lD&lt;/code&gt;,&#xA;but this might depend on your taste.&#xA;If you don't do it repeatedly then the macro doesn't really help, as it's the same number of keystrokes anyway (+ the creation of the macro).&lt;/p&gt;&#xA;" OwnerUserId="135" LastEditorUserId="135" LastEditDate="2015-10-22T12:53:05.513" LastActivityDate="2015-10-22T12:53:05.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5224" PostTypeId="1" AcceptedAnswerId="6754" CreationDate="2015-10-22T11:49:11.977" Score="1" ViewCount="143" Body="&lt;p&gt;I have multiple indent rules for same file type. I'd like to try them separately. How do I see which one is active? :set filetype is correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did manage to change the rules by disabling all other indent files manually, but there probably is a better way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case I have &gt;5 different Javascript indent versions I'd like to test. (Mac default, Pangloss, web-indent, etc.)&lt;/p&gt;&#xA;" OwnerUserId="4751" LastEditorUserId="4751" LastEditDate="2015-10-22T19:44:49.890" LastActivityDate="2016-03-03T09:52:32.077" Title="How do I choose which indent format to use for same file type?" Tags="|indentation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5225" PostTypeId="1" AcceptedAnswerId="5226" CreationDate="2015-10-22T12:06:56.603" Score="12" ViewCount="1864" Body="&lt;p&gt;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&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo :e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, after this syntax highlighting is lost in all the buffers. Typing &lt;code&gt;:e&lt;/code&gt; in a buffer then restores it again. This seems strange, as I'd suppose that &lt;code&gt;:e&lt;/code&gt; behaves the same when given directly and when inside &lt;code&gt;:bufdo&lt;/code&gt;. Is there a way how to get around that, to have syntax highlighted buffers after &lt;code&gt;:bufdo :e&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5005" LastActivityDate="2023-05-02T14:21:55.813" Title="Syntax highlighting is gone after :bufdo :e" Tags="|syntax-highlighting|buffers|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5226" PostTypeId="2" ParentId="5225" CreationDate="2015-10-22T12:41:25.403" Score="7" Body="&lt;p&gt;What you are experiencing seems to be a feature. From &lt;code&gt;:help bufdo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Note: While this command is executing, the Syntax&#xA;    autocommand event is disabled by adding it to&#xA;    'eventignore'.  This considerably speeds up editing&#xA;    each buffer.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nevertheless, you probably should focus on which settings you are using on gVim that you are missing on console Vim, as they should be able to behave in the exact same way. If you really need to reload all the buffers, you should try the &lt;code&gt;:checktime&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="7933" LastEditDate="2020-04-02T15:26:16.073" LastActivityDate="2020-04-02T15:26:16.073" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5228" PostTypeId="1" AcceptedAnswerId="5235" CreationDate="2015-10-22T13:55:47.980" Score="11" ViewCount="201" Body="&lt;p&gt;I edit quite a few BibTeX files, and I regularly forget the trailing commas: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@Book{cooke2015british,&#xA; author = {Cooke, Lez},&#xA; title = {British Television Drama},&#xA; publisher = {Palgrave on behalf of the British Film Institute},&#xA; year = {2015},&#xA; keywords = {about}&#xA; address = {London},&#xA; isbn = {978-1844576234}&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll see that I forgot to add the comma after &lt;code&gt;keywords = {about}&lt;/code&gt;, which will mean that I have to spend time debugging. Is there a way Vim can make me remember? By the way, I have the &lt;a href=&quot;https://github.com/vim-scripts/bib_autocomp.vim/tree/master/ftplugin&quot;&gt;bib_autocomp.vim&lt;/a&gt; plugin ... &lt;/p&gt;&#xA;" OwnerUserId="5007" LastActivityDate="2015-10-28T10:55:38.917" Title="How can Vim help me remember the trailing commas in BibTeX files?" Tags="|autocompletion|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5229" PostTypeId="1" AcceptedAnswerId="5231" CreationDate="2015-10-22T13:56:46.490" Score="3" ViewCount="1117" Body="&lt;p&gt;I'm following the page where there is an example how to set-up &lt;a href=&quot;http://vim.wikia.com/wiki/Vim_as_a_system_interpreter_for_vimscript&quot; rel=&quot;nofollow&quot;&gt;Vim as a system interpreter for vimscript&lt;/a&gt; by setting the following shebang line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/vim -nNesc:let&amp;amp;verbose=1|let&amp;amp;viminfo=&quot;&quot;|source%|echo&quot;&quot;|qall!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I did the test by adding &lt;code&gt;%print&lt;/code&gt;, but it prints the current script file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I obviously don't want to parse my current file which consist commands for Vim, but I want to parse the file from the argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What shebang line should I use, so I can use the script as a parser for the file which I will specify in the argument?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example to execute commands from &lt;code&gt;parser.vim&lt;/code&gt; on file &lt;code&gt;my_file.txt&lt;/code&gt; I would run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./parser.vim my_file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-10-23T05:51:56.490" Title="The right shebang for Vim to parse the file from the argument?" Tags="|command-line|external-command|linux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5231" PostTypeId="2" ParentId="5229" CreationDate="2015-10-22T14:55:46.927" Score="3" Body="&lt;p&gt;&lt;code&gt;source%&lt;/code&gt; should give you a hint what's going on: the first argument &lt;em&gt;is&lt;/em&gt; the current script, while &lt;code&gt;my_file.txt&lt;/code&gt; is the second argument.  Adding &lt;code&gt;args&lt;/code&gt; or &lt;code&gt;ls&lt;/code&gt; to the script confirms that.  This means you have to add &lt;code&gt;bnext&lt;/code&gt; to the top of your script to edit the text file rather than the script itself.  It also means you'll have to manage arguments in your script.  The wiki page is misleadingly optimistic about that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; One way to overcome the problem of the current buffer pointing to the script itself is to add &lt;code&gt;bnext&lt;/code&gt; to the shebang line.  However, running &lt;code&gt;bnext&lt;/code&gt; before &lt;code&gt;source %&lt;/code&gt; is too early (after &lt;code&gt;bnext&lt;/code&gt; the script can no longer be sourced), and running it after &lt;code&gt;source %&lt;/code&gt; is too late (the script has already run).  A workaround is to add it to a &lt;code&gt;SourcePre&lt;/code&gt; autocommand.  But since an autocommand would consume the rest of the command line, it has to be wrapped in an &lt;code&gt;exec&lt;/code&gt;.  And you probably also want to limit &lt;code&gt;SourcePre&lt;/code&gt; to the script itself.  This leads to something like this, which mostly works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#! /usr/bin/vim -nNesc:let&amp;amp;verbose=1|let&amp;amp;viminfo=&quot;&quot;|exec &quot;autocmd SourcePre &quot;.fnameescape(expand(&quot;%:p&quot;,1)).&quot; bnext&quot;|source%|qall!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'd still need to do something about &lt;code&gt;args&lt;/code&gt; if your script uses &lt;code&gt;argdo&lt;/code&gt; and friends.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="2313" LastEditDate="2015-10-23T05:51:56.490" LastActivityDate="2015-10-23T05:51:56.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5232" PostTypeId="1" AcceptedAnswerId="5280" CreationDate="2015-10-22T16:02:34.813" Score="4" ViewCount="179" Body="&lt;p&gt;Also asking how to apply an ex range to a normal command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a file of some 125k lines with a preamble followed by 8 columns of 10 character wide text, the contents of the column are 8 characters of numbers followed by spaces, except that the last column has no trailing space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I wanted to wrap it such that each column becomes a row in order,&#xA;I would &lt;code&gt;set tw=9&lt;/code&gt; (or 8 or 10?) and then use &lt;code&gt;gq&lt;/code&gt; to wrap it.&#xA;I hoped the easiest thing to do would be to go to the first line after the preamble and type something like:&#xA;  &lt;code&gt;:.,$gq&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you know, &lt;code&gt;gq&lt;/code&gt; is not an ex mode command.&#xA;I couldn't find in the help where the ex mode version of a formatting command is, I'd love both an answer to if that does exist what it is, or if it doesn't, and what you'd do to apply the gq normal mode command to everything to the end of the file. Is there something better than type:&lt;br&gt;&#xA;  &lt;code&gt;200000gq&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EG file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;These are very nice data points from our experiment.&#xA;This was carried out at our big data point lab by e@mail.tld&#xA;If you positioned your cursor on the fifth line, what would you&#xA;type in vim to turn all of these points into their own line?&#xA;       1        10       100      1000     10000    100000   1000000  10000000&#xA;10000001  10000010  10000100  10001000  10010000  10100000  11000000  20000000&#xA;... 125k lines later&#xA;88888881  18888818  18888188  18881888  18818888  18188888  11888888  28888888&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where the desired format would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;These are very nice data points from our experiment.&#xA;This was carried out at our big data point lab by e@mail.tld&#xA;If you positioned your cursor on the fifth line, what would you&#xA;type in vim to turn all of these points back into columns? [BONUS]&#xA;1&#xA;10&#xA;100&#xA;1000&#xA;10000&#xA;100000&#xA;1000000&#xA;10000000&#xA;1.25M lines of data points; Padding or alignment aren't important now.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3303" LastActivityDate="2015-10-26T23:30:05.177" Title="Hard wrapping a range to textwidth with an ex command" Tags="|cursor-motions|ex-mode|wrapping|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5233" PostTypeId="1" CreationDate="2015-10-22T18:13:19.270" Score="6" ViewCount="3253" Body="&lt;p&gt;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 &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-j&amp;gt; &amp;lt;Down&amp;gt;   &#xA;inoremap &amp;lt;C-k&amp;gt; &amp;lt;Up&amp;gt;&#xA;inoremap &amp;lt;C-h&amp;gt; &amp;lt;Left&amp;gt;&#xA;inoremap &amp;lt;C-l&amp;gt; &amp;lt;Right&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, everything works fine except for ctrl-j. When I press ctrl-j, it will add in a tab right after my cursor position. I thought this might be caused by some of my other setting (like smarttab, shiftwidth, etc.), so I removed every line other than &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-j&amp;gt; &amp;lt;Down&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is still adding the tab. What makes this strange behavior even weirder is that if I open vim with no settings or mappings, and call &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;C-j&amp;gt; &amp;lt;Down&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it works perfectly fine. But when I call &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:source ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it goes back to adding tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's causing this? It doesn't make any sense to me that it behaves differently if called from within vim vs sourced from my vimrc. If it makes any difference, I', using gvim on windows 7.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2022-01-10T04:58:27.207" Title="Strange behavior of &lt;ctrl-j&gt; remapping" Tags="|key-bindings|vimrc|gvim|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5234" PostTypeId="1" AcceptedAnswerId="5237" CreationDate="2015-10-22T20:20:56.903" Score="1" ViewCount="135" Body="&lt;p&gt;Why are the commands on my &lt;code&gt;.bash_profile&lt;/code&gt; not recognized? I tried using both &lt;code&gt;set shell=/bin/bash\&lt;/code&gt; and &lt;code&gt;set shell=/bin/bash\ -i&lt;/code&gt; - none worked.&lt;/p&gt;&#xA;" OwnerUserId="3128" LastActivityDate="2015-10-22T21:22:58.427" Title="Commands on my .bash_profile aren't recognized when using `:!cmd` on OSX 10.11 using mvim" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5235" PostTypeId="2" ParentId="5228" CreationDate="2015-10-22T20:40:15.717" Score="6" Body="&lt;p&gt;Quick and dirty solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:match Error /^\s\+.*,\@&amp;lt;!\ze\n\s\+\w/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also create a special syntax for BibTeX files using the same pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some explanations on the used regular expression:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;^\s\+&lt;/code&gt; searches for indented keywords.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\ze&lt;/code&gt; stops the pattern matching such that the next line is not marked.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;,\@&amp;lt;!\n&lt;/code&gt; searches for lines not ending with a comma.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\n\s\+\w&lt;/code&gt; guarantees that there is a new entry after the currently being scanned.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The same pattern can be used to jump between erroneous lines using &lt;code&gt;vimgrep&lt;/code&gt; as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /^\s\+.*,\@&amp;lt;!\ze\n\s\+\w/ %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the quickfix window does not open automatically, it can be opened using &lt;code&gt;:copen&lt;/code&gt;. And &lt;code&gt;:cnext&lt;/code&gt; and &lt;code&gt;:cprevious&lt;/code&gt; can be used to jump between errors.&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="599" LastEditDate="2015-10-28T10:55:38.917" LastActivityDate="2015-10-28T10:55:38.917" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5236" PostTypeId="1" CreationDate="2015-10-22T21:01:18.713" Score="2" ViewCount="131" Body="&lt;p&gt;When folding is toggled so that 800 line buffer is folded to 80 lines (with the window height being 50 lines), the scrollbar slider dosn't change its length and remains of the same size as when the buffer is unfolded. Is this behaviour correct? Shouldn't scrollbar slider size depend only on visible lines and change its size when the number of visible lines changes (e.g. after folding)?&lt;/p&gt;&#xA;" OwnerUserId="1378" LastEditorUserId="51" LastEditDate="2015-12-17T13:47:43.857" LastActivityDate="2016-03-03T09:43:59.717" Title="Strange behaviour of scrollbar" Tags="|gvim|folding|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5237" PostTypeId="2" ParentId="5234" CreationDate="2015-10-22T21:18:41.047" Score="2" Body="&lt;p&gt;The shell which executes your command isn't a login shell, so it doesn't load .bash_profile. One hack for getting it to work (even though most people I've seen recommend against it) is: &lt;code&gt;:set shellcmdflag=-i&lt;/code&gt; in your .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't recall why it was recommended against, but when I've done it, Vim tends to randomly get put in the background like &lt;code&gt;CTRL+z&lt;/code&gt; was pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a previous StackOverflow answer to the same question: &lt;a href=&quot;https://stackoverflow.com/questions/4642822/commands-executed-from-vim-are-not-recognizing-bash-command-aliases&quot;&gt;https://stackoverflow.com/questions/4642822/commands-executed-from-vim-are-not-recognizing-bash-command-aliases&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="306" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-10-22T21:22:58.427" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5238" PostTypeId="2" ParentId="5228" CreationDate="2015-10-22T22:33:54.257" Score="0" Body="&lt;p&gt;One possibility is defining a &lt;code&gt;.vimrc&lt;/code&gt; shortcut to add the missing &lt;code&gt;,&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map \q  :%s/\v([}&quot;])(\s*\n\s*\S+\s*\=)/\1,\2/&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and use &lt;code&gt;\q&lt;/code&gt; before leaving or when debugging. &lt;/p&gt;&#xA;" OwnerUserId="3002" LastActivityDate="2015-10-22T22:33:54.257" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5239" PostTypeId="1" AcceptedAnswerId="5240" CreationDate="2015-10-22T22:40:41.880" Score="15" ViewCount="2027" Body="&lt;p&gt;I know that I can delete from the cursor till and including the first occurence of a character &lt;i&gt;x&lt;/i&gt; with &lt;code&gt;dfx&lt;/code&gt;. This only works on one line. How can I delete from the current cursor position till the first occurence of &lt;i&gt;x&lt;/i&gt; when &lt;i&gt;x&lt;/i&gt; is not in the same line?&lt;/p&gt;&#xA;&lt;p&gt;E.g., if the cursor is after the first space in&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;yada yada yada&lt;br&gt;&#xA;yada yada yada x&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;and I type &lt;code&gt;dfx&lt;/code&gt; the result needs to be:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;yada&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5011" LastEditorUserId="5011" LastEditDate="2022-05-09T12:22:47.597" LastActivityDate="2022-05-09T12:22:47.597" Title="Delete from cursor till first character x (spanning multiple lines)" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5240" PostTypeId="2" ParentId="5239" CreationDate="2015-10-22T22:59:51.800" Score="25" Body="&lt;p&gt;Use &lt;code&gt;/&lt;/code&gt; for forward search:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d/x&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;?&lt;/code&gt; for backward search:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d?x&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-10-23T17:29:11.367" LastActivityDate="2015-10-23T17:29:11.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5241" PostTypeId="2" ParentId="5239" CreationDate="2015-10-23T04:20:07.370" Score="12" Body="&lt;p&gt;I wanted to comment on romainl's answer, but I don't have enough reputation to do so yet!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although it needs one more keystroke, I find it useful to do &lt;code&gt;v/x&amp;lt;CR&amp;gt;d&lt;/code&gt; to see the portion that is being removed.&lt;/p&gt;&#xA;" OwnerUserId="947" LastActivityDate="2015-10-23T04:20:07.370" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5242" PostTypeId="2" ParentId="5233" CreationDate="2015-10-23T04:27:54.060" Score="1" Body="&lt;p&gt;Look at this: &lt;a href=&quot;https://stackoverflow.com/questions/9092982/mapping-c-j-to-something-in-vim&quot;&gt;https://stackoverflow.com/questions/9092982/mapping-c-j-to-something-in-vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;According to the document of bash-support.vim:&#xA;  The original meaning of Ctrl-j is 'move [n] lines downward' (see |CTRL-j|). If you are accustomed to use the default and don't like these jump targets you can switch them off. Put the following line in the file '.vimrc' :&#xA;  let g:BASH_Ctrl_j = 'off'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use that mapping &lt;code&gt;let g:BASH_Ctrl_j = 'off'&lt;/code&gt; before your mapping and I guess it should resolve the issue.&lt;/p&gt;&#xA;" OwnerUserId="947" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-10-23T04:27:54.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5243" PostTypeId="1" AcceptedAnswerId="5246" CreationDate="2015-10-23T09:03:59.970" Score="33" ViewCount="11128" Body="&lt;p&gt;I know that I can delete from the cursor till and including the first occurence of a character &lt;i&gt;x&lt;/i&gt; with &lt;a href=&quot;https://vi.stackexchange.com/questions/5239/delete-from-cursor-till-first-character-x-spanning-multiple-lines#5240&quot;&gt;&lt;code&gt;d/x&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/a&gt; or with &lt;a href=&quot;https://vi.stackexchange.com/questions/5239/delete-from-cursor-till-first-character-x-spanning-multiple-lines#5241&quot;&gt;&lt;code&gt;v/x&amp;lt;CR&amp;gt;d&lt;/code&gt;&lt;/a&gt; if I want to see the selection first and then delete. How can I delete from the current cursor position till the &lt;i&gt;n&lt;/i&gt;th occurence of &lt;i&gt;x&lt;/i&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g., if the cursor is after the first space in&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;i&gt;yada yada yada&lt;br&gt;&#xA;  yada yada yada x&lt;br&gt;&#xA;  yada yada yada x&lt;br&gt;&#xA;  yada yada yada x&lt;/i&gt;&lt;br&gt;&#xA;  xx&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and I type a command to remove up to the third &lt;i&gt;x&lt;/i&gt; the result needs to be:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;i&gt;yada&lt;br&gt;&#xA;  xx&lt;/i&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5011" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-07-27T23:35:42.287" Title="Delete from cursor till nth occurence of character x" Tags="|search|cut-copy-paste|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5244" PostTypeId="1" AcceptedAnswerId="5245" CreationDate="2015-10-23T09:15:53.073" Score="6" ViewCount="4311" Body="&lt;p&gt;I want to select text from multiple lines up till and including the pattern &lt;i&gt;pattern&lt;/i&gt;. When I use &lt;code&gt;v/pattern&lt;/code&gt; the text till &lt;i&gt;attern&lt;/i&gt; is selected (not including attern). How can I select text including &lt;i&gt;attern&lt;/i&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g., when I have the text&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;yada yada&lt;br&gt;&#xA;  yada n pattern&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and my cursor is at the first y, I am looking for a command to highlight everything.&lt;/p&gt;&#xA;" OwnerUserId="5011" LastEditorUserId="5011" LastEditDate="2015-10-23T09:21:20.743" LastActivityDate="2015-10-23T10:06:36.610" Title="Select text till and including pattern" Tags="|search|regular-expression|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5245" PostTypeId="2" ParentId="5244" CreationDate="2015-10-23T10:06:36.610" Score="14" Body="&lt;p&gt;Just append &lt;code&gt;/e&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to your search pattern.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;v/pattern/e&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5016" LastActivityDate="2015-10-23T10:06:36.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5246" PostTypeId="2" ParentId="5243" CreationDate="2015-10-23T10:28:26.197" Score="30" Body="&lt;p&gt;You can do :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;wd4/x&amp;lt;Enter&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you start on the top left of your text&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt; : move to beginning of next word&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d&lt;/code&gt; : delete&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;4/x&amp;lt;Enter&amp;gt;&lt;/code&gt; : until the 4th occurence of x&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you don't know the number of times you would like to do it beforehand, you can also do : &lt;code&gt;d/x&amp;lt;Enter&amp;gt;&lt;/code&gt; and then hit &lt;code&gt;.&lt;/code&gt; to repeat&lt;/p&gt;&#xA;" OwnerUserId="1543" LastActivityDate="2015-10-23T10:28:26.197" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5247" PostTypeId="2" ParentId="3512" CreationDate="2015-10-23T16:14:15.750" Score="3" Body="&lt;p&gt;I like folding with indent but including the comments in the fold (I mean each comment get the same level of fold as the previous line). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, foldignore keyword just works for one line comments. So I fold with expr in vimrc: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=expr&#xA;set foldexpr=FoldMethod(v:lnum)&#xA;&#xA;function! FoldMethod(lnum)&#xA;  &quot;get string of current line&#xA;  let crLine=getline(a:lnum)&#xA;&#xA;  &quot; check if empty line &#xA;  if empty(crLine) &quot;Empty line or end comment &#xA;    return -1 &quot; so same indent level as line before &#xA;  endif &#xA;&#xA;  &quot; check if comment &#xA;  let a:data=join( map(synstack(a:lnum, 1), 'synIDattr(v:val, &quot;name&quot;)') )&#xA;  if a:data =~ &quot;.*omment.*&quot;&#xA;    return '='&#xA;  endif&#xA;&#xA;  &quot;Otherwise return foldlevel equal to indent /shiftwidth (like if&#xA;  &quot;foldmethod=indent)&#xA;  else  &quot;return indent base fold&#xA;    return indent(a:lnum)/&amp;amp;shiftwidth&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last block : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;indent(a:lnum)/&amp;amp;shiftwidth&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Returns a foldlevel base on indent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the other one :  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;join( map(synstack(a:lnum, 1), 'synIDattr(v:val, &quot;name&quot;)') )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Checks if the first character of the line is consider as a comment with the syntax. So it is a good way to merge indent and syntax folding with expression, the most advanced folding. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you can also &quot;set foldtext&quot; depending on how you want the result to look like.&lt;/p&gt;&#xA;" OwnerUserId="5026" LastActivityDate="2015-10-23T16:14:15.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5248" PostTypeId="2" ParentId="2261" CreationDate="2015-10-23T16:25:15.947" Score="1" Body="&lt;p&gt;Unfortunately, foldignore keyword just works for one line comments. So I fold with expr : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=expr&#xA;set foldexpr=FoldMethod(v:lnum)&#xA;&#xA;function! FoldMethod(lnum)&#xA;  &quot;get string of current line&#xA;  let crLine=getline(a:lnum)&#xA;&#xA;  &quot; check if empty line &#xA;  if empty(crLine) &quot;Empty line or end comment &#xA;    return -1 &quot; so same indent level as line before &#xA;  endif &#xA;&#xA;  &quot; check if comment &#xA;  let a:data=join( map(synstack(a:lnum, 1), 'synIDattr(v:val, &quot;name&quot;)') )&#xA;  if a:data =~ &quot;.*omment.*&quot;&#xA;    return '='&#xA;  endif&#xA;&#xA;  &quot;Otherwise return foldlevel equal to indent /shiftwidth (like if&#xA;  &quot;foldmethod=indent)&#xA;  else  &quot;return indent base fold&#xA;    return indent(a:lnum)/&amp;amp;shiftwidth&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last block : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;indent(a:lnum)/&amp;amp;shiftwidth&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Returns a foldlevel base on indent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the other one :  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;join( map(synstack(a:lnum, 1), 'synIDattr(v:val, &quot;name&quot;)') )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Checks if the first character of the line is consider as a comment with the syntax. So it is a good way to merge indent and syntax folding with expression, the most advanced folding. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you can also &quot;set foldtext&quot; depending on how you want the result to look like.&lt;/p&gt;&#xA;" OwnerUserId="5026" LastActivityDate="2015-10-23T16:25:15.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5249" PostTypeId="1" CreationDate="2015-10-23T17:06:41.093" Score="1" ViewCount="119" Body="&lt;p&gt;Preface: I enjoy using vim, but am by no means a vim power user.  My .vimrc file is largely the result of googling other's solutions and adapting them to my needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that in mind, I'm curious if it's possible to have the .vimrc file set the values for &lt;em&gt;g:Tex_SmartQuoteOpen&lt;/em&gt; and &lt;em&gt;g:Tex_SmartQuoteClose&lt;/em&gt; based on the presence or absence of a specific keyword or pattern in the file that is being opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Context: Most of my .vimrc edits are related to making vim and the vim-latex plugin behave in a way that makes my life easier.  The default setting for SmartQuotes within vim-latex is to set the open quote to `` and the close quote to ''.  However, when I'm writing .tex files in languages other than english (particular when writing multi-lingual documents) I need to use the csquotes package so that each language gets the correct style of quotes (high vs low vs guillemets, etc.)  Thus, my .vimrc currently defines &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Tex_SmartQuoteOpen=&quot;\\enquote\{&quot;&#xA;let g:Tex_SmartQuoteClose=&quot;\}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, this is a bit heavy handed as I don't always use the csquotes package.  I'm sure there must be a way to have vim do a quick search of the document being opened to look for the existence of &lt;em&gt;csquotes&lt;/em&gt; (or, more accurately, a regex-like expression along the lines of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\\usepackage.\{-}{csquotes}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then assign the SmartQuote variables if the search is successful.  Is this possible or is it too complex for a simple .vimrc customization?&lt;/p&gt;&#xA;" OwnerUserId="4999" LastActivityDate="2015-10-23T19:50:35.963" Title="Is it possible to set SmartQuote depending on the content of a file?" Tags="|vimrc|plugin-vim-latex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5250" PostTypeId="2" ParentId="5249" CreationDate="2015-10-23T19:50:35.963" Score="1" Body="&lt;p&gt;It's possible and not very complex, but it needs to be done at the right time and doing it in your &lt;code&gt;~/.vimrc&lt;/code&gt; is too early--the .tex file has not been loaded yet so it can't be searched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the place for this sort of customization is in your &lt;code&gt;~/.vim/ftplugin/tex.vim&lt;/code&gt; file, as described in &lt;code&gt;~/.vim/ftplugin/latex-suite/texrc&lt;/code&gt;. You might be able to do it from your &lt;code&gt;~/.vimrc&lt;/code&gt; by employing autocommands, but I'm not sure how to do that so that your customization is done after the .tex file is loaded but before the &lt;em&gt;g:Tex_SmartQuoteOpen&lt;/em&gt; and &lt;em&gt;g:Tex_SmartQuoteClose&lt;/em&gt; variables are read by the latex-suite files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think also that it would be better to set the buffer-local versions of those variables, &lt;em&gt;b:Tex_SmartQuoteOpen&lt;/em&gt; and &lt;em&gt;b:Tex_SmartQuoteClose&lt;/em&gt;, so that you can apply different quotes in different buffers, should the situation ever arise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code that should go into &lt;code&gt;~/.vim/ftplugin/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if search('\\usepackage.\{-}{csquotes}', 'wn')&#xA;    let b:Tex_SmartQuoteOpen=&quot;\\enquote\{&quot;&#xA;    let b:Tex_SmartQuoteClose=&quot;\}&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-10-23T19:50:35.963" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5251" PostTypeId="1" CreationDate="2015-10-23T22:32:24.603" Score="2" ViewCount="100" Body="&lt;p&gt;I like to use tabs for indentation (hey, don't bully me!). But &lt;a href=&quot;https://stackoverflow.com/research/developer-survey-2015#tech-tabsspaces&quot;&gt;33% of other programmers prefer spaces&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces&quot; rel=&quot;nofollow noreferrer&quot;&gt;The norm with Python is to use spaces&lt;/a&gt; for indetation. Even so, I configured Vim to use tabs with Python since I recently worked on Python code that was indented with tabs. But right now I'm working on some other Python project which has spaces for indentation...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now I want to make Vim figure out which kind of indentation the file uses and indent accordingly. So my question is how can I accomplish that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I discovered the &lt;code&gt;copyindent&lt;/code&gt; option, which seems to solve the problem. But I am unsure whether this is the correct way to solve the problem. Does it have any pitfall? Is there a better way to do this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For the sake of completeness, these are the contents of my &lt;code&gt;.vim/after/ftplugin/python.vim&lt;/code&gt; file, which is the one ensuring tabs are used for Python right now. I also have &lt;code&gt;filetype plugin indent on&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal tabstop=4&#xA;setlocal softtabstop=4&#xA;setlocal shiftwidth=4&#xA;setlocal textwidth=80&#xA;setlocal smarttab&#xA;setlocal noexpandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="356" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-10-23T22:32:24.603" Title="Automatically determine whether to use spaces or tabs" Tags="|vimrc|indentation|filetype-python|" AnswerCount="0" CommentCount="5" ClosedDate="2015-12-17T13:43:20.403" ContentLicense="CC BY-SA 3.0" />
  <row Id="5252" PostTypeId="1" AcceptedAnswerId="5253" CreationDate="2015-10-24T19:07:24.210" Score="8" ViewCount="912" Body="&lt;p&gt;I know about &lt;code&gt;%&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt;, which reference the filenames of the current and previous buffers in command-line mode. Is there any way to similarly reference other buffers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's say that &lt;code&gt;:ls&lt;/code&gt; gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 #h   foo.txt&#xA;2  h   bar.txt&#xA;3 %a   baz.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and I want to use a command to the effect of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!pandoc foo.txt bar.txt baz.txt -o out.pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Only with a bit less typing. I would imagine something along the lines of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!pandoc b1 b2 b3 -o out.pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So. Is there anything like this? Is there an addon somewhere, or some handy bit of vimscript I could use?&lt;/p&gt;&#xA;" OwnerUserId="514" LastActivityDate="2015-10-25T07:13:28.307" Title="Can you reference buffers in command mode?" Tags="|command-line|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5253" PostTypeId="2" ParentId="5252" CreationDate="2015-10-24T20:07:38.967" Score="8" Body="&lt;p&gt;You can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!pandoc #1 #2 #3 -o out.pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is mentioned briefly in the help at &lt;code&gt;:h :_#n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need the full path to the file (say, because some of the files are in different directories), you can append &lt;code&gt;:p&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!pandoc #1:p #2:p #3:p -o out.pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="514" LastEditDate="2015-10-25T07:13:28.307" LastActivityDate="2015-10-25T07:13:28.307" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5254" PostTypeId="1" AcceptedAnswerId="36910" CreationDate="2015-10-24T20:15:12.920" Score="0" ViewCount="488" Body="&lt;p&gt;For my vim plugin I try to catch an event when quickfix window is closed. I did it with BufWinLeave event. But it does not work when I have quickfix open on multiple tabs, because of 'Not when it's still visible in another window.' from BufWinLeave documentations. But I did not find any other event, that can tell me that some random window is closed. Do you such event or how to do that?&lt;/p&gt;&#xA;" OwnerUserId="5038" LastActivityDate="2022-02-28T21:03:04.593" Title="Window close event" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5255" PostTypeId="2" ParentId="5233" CreationDate="2015-10-24T22:15:53.073" Score="8" Body="&lt;p&gt;Due to legacy reasons, vim generally treats key events as a terminal emulator would treat them, even in &quot;GUI&quot; versions (e.g.  gvim).  A terminal emulator would produce e.g. the byte 0x08 for &lt;kbd&gt;Ctrl-H&lt;/kbd&gt;, which is why the byte is sometimes printed as &lt;code&gt;^H&lt;/code&gt;.  The characters &lt;code&gt;@&lt;/code&gt; to &lt;code&gt;_&lt;/code&gt; in the ASCII table (covering the uppercase letters and some symbols) are mapped down to bytes 0x00 to 0x1F when combined with control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, unfortunately some of these low bytes, or control characters, have special meaning: 0x09 turns out to be &lt;kbd&gt;Tab&lt;/kbd&gt;, 0x0A turns out to be &lt;kbd&gt;Enter&lt;/kbd&gt;, etc.  This has the unfortunate consequence that pressing &lt;kbd&gt;Enter&lt;/kbd&gt;  and pressing &lt;kbd&gt;Ctrl-J&lt;/kbd&gt; is the same thing in vim—if you change the meaning of one, the meaning of the other changes as well.  Even if it &lt;strong&gt;would&lt;/strong&gt; work, I don't think you would want to remap enter in insert mode, so the answer to your question is basically &lt;em&gt;“don't map &lt;kbd&gt;Ctrl-J&lt;/kbd&gt; in insert-mode”&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now, in vim it is a bit more complicated than that.  When I saw the question I decided to see what gvim in particular does for the different keystrokes... so I pulled up gvim and typed in insert-mode &lt;kbd&gt;Ctrl-v&lt;/kbd&gt;&lt;kbd&gt;Ctrl-h&lt;/kbd&gt; and so on for the different keys.  This gave me &lt;code&gt;^H^@^K^L&lt;/code&gt;.  Huh, that's weird, why does &lt;kbd&gt;Ctrl-j&lt;/kbd&gt; get interpreted as a null byte (&lt;code&gt;^@&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out (see &lt;code&gt;:h NL-used-for-Nul&lt;/code&gt;) that internally vim stores null bytes as line feed characters, and this is what causes the various gotchas with &lt;code&gt;\n&lt;/code&gt; and &lt;code&gt;\r&lt;/code&gt; in regex patterns.  But anyway, not to digress from the topic too much... the main takeaway here I guess is that &lt;kbd&gt;Ctrl-J&lt;/kbd&gt; is really special in vim, and trying to map it in insert-mode will probably cause more headache than the benefit it provides.&lt;/p&gt;&#xA;" OwnerUserId="5039" LastEditorUserId="51" LastEditDate="2018-09-12T23:58:19.133" LastActivityDate="2018-09-12T23:58:19.133" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5256" PostTypeId="1" AcceptedAnswerId="5263" CreationDate="2015-10-25T12:28:29.603" Score="1" ViewCount="1244" Body="&lt;p&gt;I recently found out about vim-pathogen, and installing vim plugins on my Mac and on remote shared Linux machines has been working great. However, I can't get vim-pathogen working on one remote shared Linux machine I use. I tried using vim-pathogen on an external Linux cluster, but if I have the recommended &lt;code&gt;execute pathogen#infect()&lt;/code&gt; line in my &lt;code&gt;.vimrc&lt;/code&gt; file, Vim suddenly won't even open if I clone a plugin repository in my &lt;code&gt;.vim/bundle&lt;/code&gt; directory. Below is a copy of one of my sessions where I tried to get vim-pathogen working. I had the same problem with other plugins, so it's not just vim-autoclose. How do I go about getting vim-pathogen working? I have Vim 7.0 on this machine.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lindsb@rrlogin:~$ ls .vim&#xA;lindsb@rrlogin:~$ cat .vimrc&#xA;lindsb@rrlogin:~$ mkdir -p ~/.vim/autoload ~/.vim/bundle &amp;amp;&amp;amp; \&#xA;&amp;gt; curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim&#xA;lindsb@rrlogin:~$ ls .vim/*&#xA;.vim/autoload:&#xA;pathogen.vim&#xA;&#xA;.vim/bundle:&#xA;lindsb@rrlogin:~$ echo -e &quot;execute pathogen#infect()\nsyntax on\nfiletype plugin indent on&quot; &amp;gt; .vimrc&#xA;lindsb@rrlogin:~$ cat .vimrc&#xA;execute pathogen#infect()&#xA;syntax on&#xA;filetype plugin indent on&#xA;lindsb@rrlogin:~$ vi&#xA;lindsb@rrlogin:~$ git clone https://github.com/Townk/vim-autoclose .vim/bundle/vim-autoclose&#xA;Cloning into '.vim/bundle/vim-autoclose'...&#xA;remote: Counting objects: 326, done.&#xA;remote: Total 326 (delta 0), reused 0 (delta 0), pack-reused 326 &#xA;Receiving objects: 100% (326/326), 97.85 KiB | 0 bytes/s, done.&#xA;Resolving deltas: 100% (132/132), done.&#xA;Checking connectivity... done.&#xA;lindsb@rrlogin:~$ ls .vim/*&#xA;.vim/autoload:&#xA;pathogen.vim&#xA;&#xA;.vim/bundle:&#xA;vim-autoclose&#xA;lindsb@rrlogin:~$ vi&#xA;*** glibc detected *** vim: double free or corruption (fasttop): 0x00000000197ee800 ***&#xA;======= Backtrace: =========&#xA;/lib64/libc.so.6[0x326da714af]&#xA;/lib64/libc.so.6(cfree+0x4b)[0x326da757ab]&#xA;vim(clear_tv+0x4e)[0x453c7e]&#xA;|      |      |&#xA;|      |      |&#xA;V      V      V&#xA;[ a bunch more lines of similar error output ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5043" LastActivityDate="2015-10-25T19:13:47.230" Title="Vim won't open if &quot;execute pathogen#infect()&quot; in .vimrc" Tags="|plugin-system|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5257" PostTypeId="1" AcceptedAnswerId="5258" CreationDate="2015-10-25T13:27:14.787" Score="0" ViewCount="81" Body="&lt;p&gt;I have the following dysfunctional mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Capitalise each word in selection&#xA;vmap gw :'&amp;lt;,'&amp;gt;s/\&amp;lt;./\u&amp;amp;/g&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which should do what the comment says. But when I use it, vim reports &lt;code&gt;E488: Trailing characters&lt;/code&gt;. It works when I leave out the selection marks &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt;, but then it applies to the whole line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect I need to escape something here, but &lt;a href=&quot;http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_2)&quot; rel=&quot;nofollow&quot;&gt;the help page&lt;/a&gt; only lists some other characters which must be escaped.&lt;/p&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2015-10-25T18:07:30.423" Title="Visual mode mapping not working. Do I have to escape characters?" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5258" PostTypeId="2" ParentId="5257" CreationDate="2015-10-25T13:39:16.617" Score="2" Body="&lt;p&gt;When you enter command-line mode from visual mode Vim automatically populates the command-line with &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt;. Your mapping adds another &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; after the automatic one which makes your command invalid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap gw :s/\&amp;lt;./\u&amp;amp;/g&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does exactly what you'd expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--- edit ---&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Substitutions are line-wise by default. If you want to restrict your substitution to the current visual selection you need to add the &lt;code&gt;\%V&lt;/code&gt; atom to your search pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap gw :s/\%V\&amp;lt;./\u&amp;amp;/g&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help \%V&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-10-25T18:07:30.423" LastActivityDate="2015-10-25T18:07:30.423" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5259" PostTypeId="1" AcceptedAnswerId="5260" CreationDate="2015-10-25T16:02:07.637" Score="1" ViewCount="680" Body="&lt;p&gt;Given the following files with two trailing spaces at the end:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo &quot;test1  &quot; &amp;gt; test1.txt; echo &quot;test2  &quot; &amp;gt; test2.txt; echo &quot;test3  &quot; &amp;gt; test3.txt&#xA;$ hexdump -C *.txt&#xA;00000000  74 65 73 74 31 20 20 0a  74 65 73 74 32 20 20 0a  |test1  .test2  .|&#xA;00000010  74 65 73 74 33 20 20 0a                           |test3  .|&#xA;00000018&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to use &lt;code&gt;argdo&lt;/code&gt; to remove trailing spaces, but it seems it applies the changes only to the last file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim *.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in Vim I'm checking:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args&#xA;[test1.txt] test2.txt test3.txt&#xA;:argdo! %s/\s\+$//e&#xA;&quot;test2.txt&quot; 1 line, 8 characters&#xA;&quot;test3.txt&quot; 1 line, 8 characters&#xA;:args&#xA;test1.txt test2.txt [test3.txt]&#xA;:xa &quot; To save all changed buffers and exit.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However only the last file has been modified:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ hexdump -C *.txt&#xA;00000000  74 65 73 74 31 20 20 0a  74 65 73 74 32 20 20 0a  |test1  .test2  .|&#xA;00000010  74 65 73 74 33 0a                                 |test3.|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as I can read in the help (&lt;code&gt;:help :argdo&lt;/code&gt;), it:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Execute {cmd} for each file in the argument list&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I believe it works with &lt;code&gt;bufdo&lt;/code&gt;, but why it doesn't work with &lt;code&gt;argdo&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any reason why it doesn't work as expected and how to fix it?&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2023-01-19T14:20:06.180" Title="Why argdo applies changes only to the last file?" Tags="|multiple-files|argument-list|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5260" PostTypeId="2" ParentId="5259" CreationDate="2015-10-25T17:05:51.077" Score="4" Body="&lt;p&gt;When using &lt;code&gt;:argdo&lt;/code&gt; 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). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that after your :argdo command, only the third buffer will be marked as modified and this is the only buffer that will be written to disk (simply because the changes for the other buffers have been aborted). You can confirm this, by using &lt;code&gt;:ls&lt;/code&gt; and see that only the last argument buffer is marked as modified with &quot;+&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you should either expliticly write your changes as part of the &lt;code&gt;:argdo&lt;/code&gt; command or set the 'hidden' option or possibly set any of the &lt;code&gt;autowrite&lt;/code&gt; and &lt;code&gt;autowriteall&lt;/code&gt; option to prevent this from happening.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-10-25T17:05:51.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5261" PostTypeId="2" ParentId="501" CreationDate="2015-10-25T17:40:16.083" Score="2" Body="&lt;p&gt;There are few useful shortcuts for navigating multiple files:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;CTRL-^&lt;/code&gt; (where &lt;code&gt;N&lt;/code&gt; is the buffer number) to jump to the previously edited file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;N CTRL-^&lt;/code&gt; (where &lt;code&gt;N&lt;/code&gt; is the buffer number) to jump to specific buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;Control+^&lt;/kbd&gt; - go to 1st buffer&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;Control+^&lt;/kbd&gt; - go to 2nd buffer&lt;/li&gt;&#xA;&lt;li&gt;etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is equivalent to &lt;code&gt;:buffer N&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;:Ex&lt;/code&gt;/&lt;code&gt;:Sex&lt;/code&gt;/&lt;code&gt;:Vex&lt;/code&gt; to navigate the current directory.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;:tabs&lt;/code&gt; instead (&lt;code&gt;vim -p&lt;/code&gt;) with some custom shortcuts in your &lt;code&gt;.vimrc&lt;/code&gt; such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; TABS&#xA;&quot; To create a new tab (Control-T)&#xA;nnoremap &amp;lt;C-t&amp;gt; :tabnew&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;C-t&amp;gt; &amp;lt;Esc&amp;gt;:tabnew&amp;lt;CR&amp;gt;&#xA;&quot; Tab Navigation (Control+Left &amp;lt;-&amp;gt; Control-Right, Shift+H &amp;lt;-&amp;gt; Shift+L).&#xA;nnoremap &amp;lt;S-h&amp;gt; gT&#xA;nnoremap &amp;lt;S-l&amp;gt; gt&#xA;nnoremap &amp;lt;A-Left&amp;gt; gT&#xA;nnoremap &amp;lt;A-Right&amp;gt; gt&#xA;nnoremap &amp;lt;C-S-Tab&amp;gt; gT&#xA;nnoremap &amp;lt;C-Tab&amp;gt; gt&#xA;&quot; Tab Close (Control-W)&#xA;nnoremap &amp;lt;C-BS&amp;gt; :tabclose&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;C-BS&amp;gt; &amp;lt;Esc&amp;gt;:tabclose&amp;lt;CR&amp;gt;&#xA;&quot; Close All (Control-Q)&#xA;nnoremap &amp;lt;C-q&amp;gt; :qa&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;C-q&amp;gt; &amp;lt;Esc&amp;gt;:qa&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;:ba&lt;/code&gt;/&lt;code&gt;:vert ba&lt;/code&gt; to split, jump into selected buffer via &lt;kbd&gt;Control+w&lt;/kbd&gt;,&lt;kbd&gt;w&lt;/kbd&gt;/&lt;kbd&gt;W&lt;/kbd&gt;, then make it the current window (&lt;code&gt;:on&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-10-25T17:40:16.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5262" PostTypeId="2" ParentId="1981" CreationDate="2015-10-25T18:24:56.637" Score="0" Body="&lt;p&gt;One way to replace the whole buffer with your clipboard can be via external command, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!pbpaste&#xA;:%!echo my_text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;See also: &lt;a href=&quot;http://vim.wikia.com/wiki/Mac_OS_X_clipboard_sharing&quot; rel=&quot;nofollow&quot;&gt;Mac OS X clipboard sharing&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or by using substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\_.*/\=@+/&#xA;:%s/\_.*/my text/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively use &lt;code&gt;:%d|put+&lt;/code&gt; (as already suggested in the comments).&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2015-10-25T18:24:56.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5263" PostTypeId="2" ParentId="5256" CreationDate="2015-10-25T19:13:47.230" Score="2" Body="&lt;p&gt;As Christian Brabandt suggested, my issue was caused by an old version of vim. I installed locally by cloning the &lt;a href=&quot;https://github.com/vim/vim.git&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim git repo&lt;/a&gt; then executing &lt;code&gt;./configure --prefix=$HOME/usr/vim &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install&lt;/code&gt; within the top directory of the vim repo. (&lt;code&gt;$HOME/usr/vim&lt;/code&gt; is where I wanted vim installed) The new vim worked great with the pathogen plugin installation method, but it opened really slowly. By analyzing the startup time with &lt;code&gt;vim --startuptime out.log&lt;/code&gt; I found that setting up the clipboard was taking up most of the startup time. Following the instructions in &lt;a href=&quot;https://stackoverflow.com/questions/14635295/vim-takes-a-very-long-time-to-start-up&quot;&gt;this post&lt;/a&gt; I found that &lt;code&gt;vim -X&lt;/code&gt; opened much faster, so I added &lt;code&gt;set clipboard=exclude:.*&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt; file. Now everything works great.&lt;/p&gt;&#xA;" OwnerUserId="5043" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-10-25T19:13:47.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5264" PostTypeId="1" CreationDate="2015-10-25T20:05:49.263" Score="1" ViewCount="286" Body="&lt;p&gt;I currently want to write my own vim colorscheme for the vim in cmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason all my xterm256 colors are messed up. Every 10-15 colors the pattern of colors repeat themself... which is quite funky in an negative sense-.-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I generated all 256 colors with a little function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let num = 255 &#xA;while num &amp;gt;= 0&#xA;exec 'hi col_'.num.' ctermbg='.num.' ctermfg=white'&#xA;exec 'syn match col_'.num.' &quot;ctermbg='.num.':....&quot; containedIn=ALL'&#xA;call append(0, 'ctermbg='.num.':....')&#xA;let num = num - 1&#xA;endwhile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here the result:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/JDJPO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JDJPO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is why it behaves like this and how to fix it, if possible -.-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appreciate any help that one can provide.&lt;/p&gt;&#xA;" OwnerUserId="5046" LastActivityDate="2015-10-25T20:05:49.263" Title="vim in cmd, xterm colors completely messed up" Tags="|colorscheme|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5265" PostTypeId="1" AcceptedAnswerId="5266" CreationDate="2015-10-25T20:42:02.247" Score="8" ViewCount="9490" Body="&lt;p&gt;For testing purposes I've opened the following file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim http://example.com/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I'm using the following command to delete a highlighted multi-line pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/&amp;lt;body\_.\{-}body&amp;gt;/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which matches multiple lines, but only removes for the first line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for workaround (for this particular case) it works however when I delete the inner tag block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/&amp;lt;body\_.\{-}body&amp;gt;/norm dit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work when working on non-tag blocks, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/body {\_.\{-}}/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but again, this particular case can be solved by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/body {\_.\{-}}/norm d%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the question is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I remove a multi-line match at one go in more universal way (which would work in all cases)?&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2022-09-23T11:50:21.100" Title="How to delete a multi-line match?" Tags="|command-line|regular-expression|ex-mode|multiple-lines|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5266" PostTypeId="2" ParentId="5265" CreationDate="2015-10-25T21:55:44.677" Score="16" Body="&lt;p&gt;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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it's quite possible to delete groups of rows that match a beginning pattern and an ending pattern. The most obvious way, I think, is to combine the &lt;code&gt;:global&lt;/code&gt; and &lt;code&gt;:delete&lt;/code&gt; commands like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/&amp;lt;body/ .,/body&amp;gt;/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which searches every line in the buffer for the pattern &lt;code&gt;&amp;lt;body&lt;/code&gt;. When it finds a match, it constructs the range &lt;code&gt;.,/body&amp;gt;/&lt;/code&gt;, i.e. from the line that matched to the next line that matches &lt;code&gt;body&amp;gt;&lt;/code&gt; and invokes the &lt;code&gt;:delete&lt;/code&gt; command on that range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/&amp;lt;body/,/body&amp;gt;/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's the same command, omitting the current-line &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, there's of course the &lt;code&gt;dat&lt;/code&gt; operation, but since you didn't use that, I assume it's somehow inadequate. Now, there's usually only one &quot;body&quot; element in a html-like document, but if one were to delete all &quot;foo&quot; elements, one could use this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/&amp;lt;foo/ norm! dvatx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, &lt;code&gt;g&lt;/code&gt;lobally search for the pattern &lt;code&gt;&amp;lt;foo&lt;/code&gt;, at every occurrence invoke the &lt;code&gt;norm&lt;/code&gt;al mode command (&lt;code&gt;!&lt;/code&gt; disallow mappings here) &lt;code&gt;d&lt;/code&gt;elete &lt;code&gt;v&lt;/code&gt; (force character-wise, omit or replace with &lt;code&gt;V&lt;/code&gt; if line-wise is preferred) &lt;code&gt;a&lt;/code&gt;round &lt;code&gt;t&lt;/code&gt;ag, and &lt;code&gt;x&lt;/code&gt; remove leftover &quot;&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As they say, anyone processing sgml/html/xml using regular expressions is of course in a state of sin. Oversimplified schemes like this will blow up from time to time. The only way to be sure is to invoke a filter that runs a dom processor.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:g&lt;/code&gt;: Search-and-apply &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html#:g&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :g&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:d&lt;/code&gt;: Delete &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:d&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :d&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[range]&lt;/code&gt;: Range specification &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#[range]&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help [range]&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:norm&lt;/code&gt;: Apply normal-mode &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/various.html#:norm&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :norm&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d&lt;/code&gt;: Delete &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#d&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help d&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v&lt;/code&gt;: Force character-wise &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#o_v&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help o_v&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt;: Force line-wise &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#o_v&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help o_v&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&lt;/code&gt;: Around selection &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help text-objects&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;t&lt;/code&gt;: tag selection &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help text-objects&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2942" LastEditorUserId="2942" LastEditDate="2015-10-26T18:01:30.127" LastActivityDate="2015-10-26T18:01:30.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5267" PostTypeId="2" ParentId="5265" CreationDate="2015-10-26T01:46:43.983" Score="2" Body="&lt;p&gt;You can use a filter.  I would probably use &lt;code&gt;sed&lt;/code&gt; for arbitrary multi-line matching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a drawback in that there is no way in &lt;code&gt;sed&lt;/code&gt; to do non-greedy matching, but in certain cases you can work around that.  (For example, add only one line at a time until you get a match, then do the substitute, as below.)  Your examples aren't using non-greedy matching in the first place, so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:.,$!sed '/&amp;lt;body/{;:loop;s@&amp;lt;body.*/body&amp;gt;@@;t;$b;N;bloop;}'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example command.  This will filter lines from the current line through the end of the file.  Until it finds the match &lt;code&gt;&amp;lt;body&lt;/code&gt; it will output each line exactly as it inputs.  When it hits &lt;code&gt;&amp;lt;body&lt;/code&gt; it enters a loop (conveniently labeled with &lt;code&gt;:loop&lt;/code&gt;.  The label itself does nothing but can be branched to later.)  &lt;code&gt;sed&lt;/code&gt; runs a substitute command, greedily matching &lt;code&gt;&amp;lt;body.*/body&amp;gt;&lt;/code&gt; and deleting it if found (using @ as delimiter to avoid needing to escape the &lt;code&gt;/&lt;/code&gt;.)  &lt;em&gt;If&lt;/em&gt; the substitute command actually did something, &lt;code&gt;t&lt;/code&gt; exits the loop and &lt;code&gt;sed&lt;/code&gt; outputs the text as it was changed by the substitute command, and then proceeds to the next line.  Otherwise, &lt;code&gt;sed&lt;/code&gt; continues: the &lt;code&gt;$b&lt;/code&gt; command is ignored unless &lt;code&gt;sed&lt;/code&gt; is on the last line to be filtered.  &lt;code&gt;N&lt;/code&gt; adds in the next line to what is being considered, with a newline in between, and the &lt;code&gt;b&lt;/code&gt;ranch command branches to the label &lt;code&gt;loop&lt;/code&gt;.  Then the substitute command is run again, now on &lt;em&gt;two&lt;/em&gt; lines, and if no match then it is run on &lt;em&gt;three&lt;/em&gt; lines, until it either finds a match (at which point the &lt;code&gt;t&lt;/code&gt; command breaks the loop) or until the end of the lines to be filtered, at which point &lt;code&gt;$b&lt;/code&gt; causes a &lt;code&gt;b&lt;/code&gt;ranch and exits the loop, outputting the lines without filtering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;sed&lt;/code&gt; is a whole language in itself.  It's not very complicated—actually if you're familiar with Ex commands you will recognize a lot of &lt;code&gt;vim&lt;/code&gt;'s heritage in &lt;code&gt;sed&lt;/code&gt;'s syntax—but it is very concise.  I've heard it called the &quot;assembly language of text editing&quot; and it is a very apt description.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this is helpful.  I'm happy to clarify anything more you'd like on this, or tailor the example better for your needs.  :)&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2015-10-26T01:46:43.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5268" PostTypeId="1" AcceptedAnswerId="5269" CreationDate="2015-10-26T04:10:21.830" Score="0" ViewCount="1846" Body="&lt;p&gt;I have searched both Stack Overflow and the Vi and Vim Stack Exchange sites and the few questions regarding font size in vim are regarding gvim and the guifont. However, I am using vim from command line. Some of the posts are regarding setting font size on the fly, which also does not apply to my situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a two part question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First part:&lt;/strong&gt; How do I permanently enlarge the display font size? (Poor vision necessitates this.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Second part:&lt;/strong&gt; How do I set the font to be displayed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am separating these points, because I may choose to just enlarge the default font (whatever that is.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have compiled vim from source and am using version 7.4.899. When configuring the source code, I used&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--with-features=huge --enable-multibyte&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am hoping for a simple solution in the .vimrc file, but would rebuild from source if necessary.&lt;/p&gt;&#xA;" OwnerUserId="5049" LastActivityDate="2015-10-26T07:15:52.013" Title="Permanently set Font size and font selection in vim (compiled from source)" Tags="|vimrc|font|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5269" PostTypeId="2" ParentId="5268" CreationDate="2015-10-26T07:15:52.013" Score="2" Body="&lt;p&gt;You can only change the font face and the font size in GVim/MacVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use Vim in a terminal emulator you will have to do that in your terminal emulator.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-10-26T07:15:52.013" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5270" PostTypeId="2" ParentId="4912" CreationDate="2015-10-26T07:41:52.187" Score="1" Body="&lt;p&gt;It's been fixed in ConEmu 151025&lt;/p&gt;&#xA;" OwnerUserId="3349" LastActivityDate="2015-10-26T07:41:52.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5271" PostTypeId="1" AcceptedAnswerId="5282" CreationDate="2015-10-26T15:00:36.453" Score="14" ViewCount="2338" Body="&lt;p&gt;An example (The &lt;code&gt;^&lt;/code&gt; is the cursor position):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a bc def ghi&#xA;j k l mn o p q rs&#xA;      ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a bc def ghimn o p q rs&#xA;            ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;or at least:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a bc def ghimn o p q rs&#xA;           ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know I can use &lt;code&gt;d0i&amp;lt;BS&amp;gt;&lt;/code&gt;, but I want a faster way to do this and I want to remain in the command mode. I am a beginner in vim and I think that maybe the answer is a modification of &lt;code&gt;kA&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much! &lt;code&gt;:-)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5010" LastEditorUserId="41706" LastEditDate="2023-06-14T14:57:52.137" LastActivityDate="2023-06-14T20:09:03.913" Title="How to delete till the end of the previous line (i.e. to end of line above)?" Tags="|cursor-movement|cursor-motions|normal-mode|linux|multiple-lines|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5272" PostTypeId="1" CreationDate="2015-10-26T15:10:12.053" Score="0" ViewCount="834" Body="&lt;p&gt;Outside of tmux they work well. These key combinations should move the cursor to the beginning of the document and, respectively, to the end of the document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I make them work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much! &lt;code&gt;:-)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5010" LastActivityDate="2017-09-14T20:40:18.050" Title="On Ubuntu and in tmux, vim does not react to Ctrl+Home and Ctrl+End" Tags="|key-bindings|cursor-movement|linux|tmux|cursor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5273" PostTypeId="1" AcceptedAnswerId="5275" CreationDate="2015-10-26T15:39:52.477" Score="5" ViewCount="4081" Body="&lt;p&gt;Fully realizing the heritage of &lt;code&gt;vi&lt;/code&gt;, I know that its predecessor (&lt;code&gt;ex&lt;/code&gt;) could be, and was, used for command line processing of files (&quot;sed-style&quot;, if you like).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The manpage says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;-c&lt;/code&gt; {command}&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;{command} will be executed after the first file has been read.  {command} is interpreted as an Ex command.  If the {command} contains spaces it must be enclosed in double  quotes  (this depends on the shell that is used).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;-e&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Start Vim in Ex mode, just like the executable was called &quot;ex&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But I was unable to find &quot;real-life&quot; examples, or get something like a simple search-and-replace to work myself. I like examples...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So let's assume a &lt;code&gt;file.txt&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abcdef&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and I would like to open that file, remove all occurrences of &lt;code&gt;e&lt;/code&gt; in it (&lt;code&gt;:%s/e//g&lt;/code&gt; if I were in full &lt;code&gt;vim&lt;/code&gt; mode), save, and close.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I go about it?&lt;/p&gt;&#xA;" OwnerUserId="1726" LastEditorUserId="467" LastEditDate="2015-10-29T13:13:52.373" LastActivityDate="2016-06-23T05:06:54.253" Title="How to use &quot;-c&quot; command line option?" Tags="|ex-command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5274" PostTypeId="2" ParentId="5271" CreationDate="2015-10-26T16:26:05.683" Score="13" Body="&lt;p&gt;Well, you can combine the &quot;backward search&quot; motion and the &lt;code&gt;delete&lt;/code&gt; operator:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d?$&amp;lt;Enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-10-26T16:26:05.683" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5275" PostTypeId="2" ParentId="5273" CreationDate="2015-10-26T16:35:49.313" Score="6" Body="&lt;p&gt;An &quot;ex command&quot; means anything that you type in the commandline after the &lt;code&gt;:&lt;/code&gt;, such as &lt;code&gt;:write&lt;/code&gt;, it doesn't really have anything to do with &quot;ex mode&quot;, as such. ex mode is a &quot;mode&quot; where you only have the commandline, and not the graphical editor (&quot;vi&quot; stands for &quot;visual ex mode&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it's really as simple as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c ':%s/e//g' -c ':wq' file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's no need to use &quot;ex mode&quot;. You can if you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -e -c ':%s/e//g' -c ':wq' file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It has the advantage of not messing with your terminal so much, but other than that there's little difference.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-10-28T14:33:31.500" LastActivityDate="2015-10-28T14:33:31.500" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5276" PostTypeId="1" AcceptedAnswerId="5278" CreationDate="2015-10-03T20:47:57.007" Score="2" ViewCount="517" Body="&lt;p&gt;I would like to find multiple files and open them all in tabs within the same vim instance.&lt;/p&gt;&#xA;" OwnerUserId="4761" OwnerDisplayName="andorov" LastEditorUserId="205" LastEditDate="2016-04-24T17:59:08.447" LastActivityDate="2016-04-24T17:59:39.437" Title="How do I open multiple files from find each in a separate tab in vim?" Tags="|invocation|tabbed-user-interface|load|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5277" PostTypeId="2" ParentId="5276" CreationDate="2015-10-03T20:47:57.007" Score="5" Body="&lt;pre&gt;&lt;code&gt;find &quot;$PWD&quot; -name '*.txt' -exec vim -p {} +&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4761" OwnerDisplayName="andorov" LastEditorUserId="205" LastEditDate="2016-04-24T17:59:39.437" LastActivityDate="2016-04-24T17:59:39.437" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5278" PostTypeId="2" ParentId="5276" CreationDate="2015-10-08T15:10:27.000" Score="6" Body="&lt;pre&gt;&lt;code&gt;vim -p `find . -name '*.txt'` &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Putting the &lt;code&gt;find&lt;/code&gt; command between backticks executes &lt;code&gt;find&lt;/code&gt; 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 &lt;code&gt;vim -p result1 result2 ... resultN&lt;/code&gt; .&lt;/p&gt;&#xA;" OwnerUserId="2710" OwnerDisplayName="Neaţu Ovidiu Gabriel" LastActivityDate="2015-10-08T15:10:27.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5279" PostTypeId="1" AcceptedAnswerId="5292" CreationDate="2015-10-26T19:48:25.890" Score="5" ViewCount="2263" Body="&lt;p&gt;There are various &lt;a href=&quot;https://vi.stackexchange.com/questions/2954/how-do-i-disable-syntastic-for-python-files&quot;&gt;questions&lt;/a&gt; &lt;a href=&quot;https://stackoverflow.com/questions/20030603/vim-syntastic-how-to-disable-the-checker&quot;&gt;and&lt;/a&gt; &lt;a href=&quot;https://stackoverflow.com/questions/31818109/how-to-selectively-disable-checkers-for-certain-file-types-when-using-syntastic&quot;&gt;answers&lt;/a&gt; about disabling/blacklisting certain file types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I disable syntastic &lt;strong&gt;for all but one&lt;/strong&gt; filetype? (Let's say Python.)&lt;/p&gt;&#xA;" OwnerUserId="5057" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-05-26T19:24:37.107" Title="How to enable syntastic only for Python?" Tags="|filetype|plugin-syntastic|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5280" PostTypeId="2" ParentId="5232" CreationDate="2015-10-26T21:10:26.887" Score="2" Body="&lt;p&gt;I set tw=9 as you mentioned. Then I removed the spaces before de &quot;1&quot; in the first row and also left a blank line between the paragraph and the numbers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;These are very nice data points from our experiment.&#xA;This was carried out at our big data point lab by e@mail.tld&#xA;If you positioned your cursor on the fifth line, what would you&#xA;type in vim to turn all of these points into their own line?&#xA;&#xA;1        10       100      1000     10000    100000   1000000  10000000&#xA;10000001  10000010  10000100  10001000  10010000  10100000  11000000  20000000&#xA;88888881  18888818  18888188  18881888  18818888  18188888  11888888  28888888&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I put the cursor anywhere on the numbers and typed &lt;code&gt;gqip&lt;/code&gt;. This is the result I obtained:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;These are very nice data points from our experiment.&#xA;This was carried out at our big data point lab by e@mail.tld&#xA;If you positioned your cursor on the fifth line, what would you&#xA;type in vim to turn all of these points into their own line?&#xA;&#xA;1&#xA;10&#xA;100&#xA;1000&#xA;10000&#xA;100000&#xA;1000000&#xA;10000000&#xA;10000001&#xA;10000010&#xA;10000100&#xA;10001000&#xA;10010000&#xA;10100000&#xA;11000000&#xA;20000000&#xA;88888881&#xA;18888818&#xA;18888188&#xA;18881888&#xA;18818888&#xA;18188888&#xA;11888888&#xA;28888888&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1735" LastEditorUserId="1735" LastEditDate="2015-10-26T23:30:05.177" LastActivityDate="2015-10-26T23:30:05.177" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5281" PostTypeId="2" ParentId="5271" CreationDate="2015-10-26T22:07:24.727" Score="4" Body="&lt;p&gt;With visual mode: &lt;code&gt;hvk$d&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br&gt;&#xA;&lt;code&gt;h&lt;/code&gt; - Move one to the left&lt;br&gt;&#xA;&lt;code&gt;v&lt;/code&gt; - Start visual mode&lt;br&gt;&#xA;&lt;code&gt;k$&lt;/code&gt; - Move to the end of the previous line&lt;br&gt;&#xA;&lt;code&gt;d&lt;/code&gt; - Delete selection&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2015-10-27T06:57:55.260" LastActivityDate="2015-10-27T06:57:55.260" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5282" PostTypeId="2" ParentId="5271" CreationDate="2015-10-26T22:14:52.827" Score="15" Body="&lt;p&gt;Try &lt;code&gt;d0kJx&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't have to leave normal mode with this.&lt;/p&gt;&#xA;" OwnerUserId="5062" LastActivityDate="2015-10-26T22:14:52.827" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5283" PostTypeId="1" AcceptedAnswerId="5288" CreationDate="2015-10-27T05:59:47.583" Score="2" ViewCount="604" Body="&lt;p&gt;I recently had an 'rm -rf' related mishap in my home directory ( Ubuntu 14.04 installation ). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim ( v 7.4.52 ) and the add-on package 'vim-youcompleteme' had been installed prior to the mishap and worked perfectly .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After recovering from my goof-up, I noticed that the completion features from 'vim-youcompleteme' no longer seemed to be working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried complete removal of the package ( apt-get purge vim-youcompleteme ) and subsequent re-installation, hoping that this would reinstate the aforementioned add-on package and its capabilities. This didn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect something in the resource / settings data must have gotten corrupted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am hoping for suggestions that would lead to the resurrection of the completion feature for Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="5066" LastEditorUserId="15" LastEditDate="2015-10-28T13:07:43.227" LastActivityDate="2015-10-28T13:07:43.227" Title="Re-activation of vim-youcompleteme" Tags="|plugin-you-complete-me|linux-debian|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5284" PostTypeId="2" ParentId="5279" CreationDate="2015-10-27T07:05:33.293" Score="1" Body="&lt;p&gt;You could disable syntax checking for a specific filetype by overriding the default checker and tell him to use none.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_filetype_checkers['python'] = ['python'] &quot; will use python as checker&#xA;let g:syntastic_filetype_checkers['python'] = []         &quot; won't use any checker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could set this option to be empty for every filetype you don't want to be checked. &lt;/p&gt;&#xA;" OwnerUserId="4413" LastEditorUserId="4413" LastEditDate="2015-10-27T07:11:53.647" LastActivityDate="2015-10-27T07:11:53.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5285" PostTypeId="1" AcceptedAnswerId="5287" CreationDate="2015-10-27T09:38:24.723" Score="7" ViewCount="204" Body="&lt;p&gt;I want to keep in the undo history just one change for a long command such as: &lt;code&gt;d0kJx&lt;/code&gt;. (I took the command from &lt;a href=&quot;https://vi.stackexchange.com/a/5282/5010&quot;&gt;this answer&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command (&lt;code&gt;d0kJx&lt;/code&gt;) does this (The &lt;code&gt;^&lt;/code&gt; is the cursor position):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a bc def ghi&#xA;j k l mn o p q rs&#xA;      ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a bc def ghimn o p q rs&#xA;            ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this is possible, how can I do this? I think that maybe the answer is to extend the command in some way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much! &lt;code&gt;:-)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5010" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-10-27T12:04:32.157" Title="How to keep in the undo history just one change for this command?" Tags="|key-bindings|cursor-movement|cursor-motions|normal-mode|undo-redo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5286" PostTypeId="1" AcceptedAnswerId="5301" CreationDate="2015-10-27T10:24:38.693" Score="5" ViewCount="831" Body="&lt;p&gt;I want to make block commenting easy. To comment out a range of lines, what I can do is something like: &lt;code&gt;:17,21s/^/#&lt;/code&gt; 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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially I thought of making a parameterized mapping for this, where I could pass the line numbers as parameters to string search and replacement map but then realised that mappings cannot have parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I got this function which will comment a range and the comment character can be passed to it as well (like # in Python and // in JavaScript):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range -nargs=? Co call CommentThis(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;, &amp;lt;q-args&amp;gt;)&#xA;function! CommentThis(l1, l2, lead)&#xA;    let l:lead = a:lead == '' ? '#' : a:lead&#xA;    exe printf('%i,%is+^+%s', a:l1, a:l2, l:lead)&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now doing something like &lt;code&gt;:17,21Co&lt;/code&gt; will achieve the task and I can do &lt;code&gt;:17,21Co//&lt;/code&gt; (for adding &lt;code&gt;//&lt;/code&gt; instead of default &lt;code&gt;#&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: How can I modify this function so as to make it work as a comment toggle? Or add a different command line to it so that I can use command 'Co' for commenting and 'Cu' to uncomment? A search and replace pattern to uncomment a python comment would be &lt;code&gt;:17,21s/^#/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS:&lt;/strong&gt;&#xA;The reason I don't want to use &lt;a href=&quot;http://vimawesome.com/plugin/the-nerd-commenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERD Commentor&lt;/a&gt; is that it doesn't support ranges, it just supports count, where I have to either take the cursor to the line I want to comment or select it.&#xA;Another plugin I found is &lt;a href=&quot;https://github.com/tpope/vim-commentary/blob/master/README.markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;Commentary VIM&lt;/a&gt; but its command &lt;code&gt;:17,21Commentary&lt;/code&gt; is too long for me.&lt;/p&gt;&#xA;" OwnerUserId="5019" LastEditorUserId="11357" LastEditDate="2019-05-01T22:45:41.440" LastActivityDate="2019-05-01T22:45:41.440" Title="Making a custom function to comment out a range of lines" Tags="|vimrc|comments|functions|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="5287" PostTypeId="2" ParentId="5285" CreationDate="2015-10-27T12:04:32.157" Score="11" Body="&lt;p&gt;I think you are interested in &lt;code&gt;:h undo-blocks&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make the long command, e.g. &lt;code&gt;d0kJx&lt;/code&gt;, undoable as a single change, you can run it from the command line through &lt;code&gt;normal&lt;/code&gt;, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:normal! d0kJx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the &lt;code&gt;!&lt;/code&gt; ensures that we do not use custom mappings.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-10-27T12:04:32.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5288" PostTypeId="2" ParentId="5283" CreationDate="2015-10-27T14:31:33.917" Score="3" Body="&lt;p&gt;The addon packages in Debian/Ubuntu are typically managed using the &lt;a href=&quot;https://packages.debian.org/stable/vim-addon-manager&quot; rel=&quot;nofollow&quot;&gt;vim-addon-manager&lt;/a&gt; package.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once an addon package is installed, you run &lt;code&gt;vam install &amp;lt;addon&amp;gt;&lt;/code&gt; to enable it in your user's config.  In this case, you likely want to run &lt;code&gt;vam install youcompleteme&lt;/code&gt; but &lt;code&gt;vam list&lt;/code&gt; can confirm the addon name.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-10-27T14:31:33.917" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5289" PostTypeId="2" ParentId="410" CreationDate="2015-10-27T16:57:07.063" Score="9" Body="&lt;p&gt;Besides &lt;code&gt;reset&lt;/code&gt;, you can try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stty sane&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which should also make your terminal usable again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://superuser.com/a/336020/56124&quot;&gt;here&lt;/a&gt; for explanations. &#xA;And somehow this can be considered a vim misbehavior, at least &lt;a href=&quot;https://github.com/neovim/neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neovim&lt;/a&gt; doesn't have this issue at the moment.&lt;/p&gt;&#xA;" OwnerUserId="5076" LastEditorUserId="5076" LastEditDate="2019-06-21T05:24:49.437" LastActivityDate="2019-06-21T05:24:49.437" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5290" PostTypeId="1" CreationDate="2015-10-27T17:34:33.783" Score="5" ViewCount="1291" Body="&lt;p&gt;I had &lt;code&gt;vim&lt;/code&gt; open in a terminal; I needed to check some other things so I typed Ctrl-Z.  When I later type &lt;code&gt;fg&lt;/code&gt;, it just stopped again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myprompt$ fg&#xA;vim newfile path/to/existingfile&#xA;&#xA;[1]+  Stopped                 vim newfile path/to/existingfile&#xA;&#xA;[1]+  Stopped                 vim newfile path/to/existingfile&#xA;myprompt$ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sometimes, as shown above, it even stops twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like the shell is attempting to resume &lt;code&gt;vim&lt;/code&gt; but that it just halts again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have quite a bit of work typed into &lt;code&gt;newfile&lt;/code&gt;; how can I either resume successfully or kill the job and retain the work I did?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2022-08-28T21:07:45.687" Title="Vim won't return to foreground" Tags="|bash|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5291" PostTypeId="2" ParentId="5290" CreationDate="2015-10-27T18:51:48.047" Score="3" Body="&lt;p&gt;Okay, I handled it via &lt;code&gt;kill %1&lt;/code&gt;, then &lt;code&gt;vim&lt;/code&gt; and then within vim, &lt;code&gt;:recover newfile&lt;/code&gt;.  Still don't know why it happened but I'm very happy there was a way to recover the file!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;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 properly.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2015-10-27T18:51:48.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5292" PostTypeId="2" ParentId="5279" CreationDate="2015-10-27T19:10:04.410" Score="6" Body="&lt;p&gt;From the &lt;a href=&quot;https://github.com/scrooloose/syntastic/blob/1926693d1bcf786a526ff0980bc120ab4bad0dee/doc/syntastic.txt#L480-L513&quot; rel=&quot;nofollow&quot;&gt;syntastic docs&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;                                                       'syntastic_mode_map'&#xA;Default: { &quot;mode&quot;: &quot;active&quot;,&#xA;           &quot;active_filetypes&quot;: [],&#xA;           &quot;passive_filetypes&quot;: [] }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Use this option to fine tune when automatic syntax checking is done (or not&#xA;  done).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The option should be set to something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_mode_map = {&#xA;    \ &quot;mode&quot;: &quot;active&quot;,&#xA;    \ &quot;active_filetypes&quot;: [&quot;ruby&quot;, &quot;php&quot;],&#xA;    \ &quot;passive_filetypes&quot;: [&quot;puppet&quot;] }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;&quot;mode&quot; can be mapped to one of two values - &quot;active&quot; or &quot;passive&quot;. When set&#xA;  to &quot;active&quot;, syntastic does automatic checking whenever a buffer is saved or&#xA;  initially opened.  When set to &quot;passive&quot; syntastic only checks when the user&#xA;  calls :SyntasticCheck.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The exceptions to these rules are defined with &quot;active_filetypes&quot; and&#xA;  &quot;passive_filetypes&quot;. In passive mode, automatic checks are still done for&#xA;  filetypes in the &quot;active_filetypes&quot; array (and &quot;passive_filetypes&quot; is&#xA;  ignored). In active mode, automatic checks are not done for any filetypes in&#xA;  the &quot;passive_filetypes&quot; array (&quot;active_filetypes&quot; is ignored).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If any of &quot;mode&quot;, &quot;active_filetypes&quot;, or &quot;passive_filetypes&quot; are left&#xA;  unspecified, they default to values above.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If local variable 'b:syntastic_mode' is defined its value takes precedence&#xA;  over all calculations involving 'syntastic_mode_map' for the corresponding&#xA;  buffer.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;At runtime, the :SyntasticToggleMode command can be used to switch between&#xA;  active and passive modes.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You probably want something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_mode_map = {&#xA;    \ &quot;mode&quot;: &quot;passive&quot;,&#xA;    \ &quot;active_filetypes&quot;: [&quot;python&quot;],&#xA;    \ &quot;passive_filetypes&quot;: [] }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="559" LastEditorUserId="559" LastEditDate="2016-05-26T19:24:37.107" LastActivityDate="2016-05-26T19:24:37.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5293" PostTypeId="1" AcceptedAnswerId="5304" CreationDate="2015-10-28T09:25:16.647" Score="3" ViewCount="534" Body="&lt;p&gt;I am a big fan of text objects, and I like their composability. For example, if I have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\label{sec:this-is-a-section}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can easily copy the &lt;code&gt;sec:this-is-a-section&lt;/code&gt; part by navigating inside, and pressing &lt;code&gt;yi}&lt;/code&gt; and use this, for example, to paste it after a &lt;code&gt;\ref{&lt;/code&gt; somewhere else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am missing is a good way to jump between these two. Intuitively, I want a command that takes a text object (&lt;code&gt;i}&lt;/code&gt;) selects this and searches for it. Does that exist, or is there a succinct way to achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is such a thing for the specific case of the &lt;code&gt;iw&lt;/code&gt; text object, namely the &lt;code&gt;*&lt;/code&gt; command. So in a way I wonder if there is a generalization of this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;I am not looking for ways to jump between &lt;code&gt;\label&lt;/code&gt; and &lt;code&gt;\ref&lt;/code&gt;, e.g. with a tag file; these are just example for the purpose of the question.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="1937" LastActivityDate="2015-10-29T11:13:17.970" Title="Find based on text objects" Tags="|search|cursor-motions|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5294" PostTypeId="2" ParentId="5293" CreationDate="2015-10-28T10:10:03.733" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/nelstrom/vim-visual-star-search&quot; rel=&quot;nofollow&quot;&gt;visual-star-search&lt;/a&gt; plugin can be used to search for a visual block.  It solves your problem: select an object the usual way, then press &lt;code&gt;*&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-10-28T10:10:03.733" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5296" PostTypeId="2" ParentId="5265" CreationDate="2015-10-28T14:47:24.767" Score="4" Body="&lt;p&gt;A possible approach to delete the multi-line pattern is replace it  by nothing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;lt;body&amp;gt;\(.|\n\)*&amp;lt;\/body&amp;gt;//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or in a more vim-ish, not greedy way: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;lt;body\_.\{-}body&amp;gt;//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;\thanks{@kenorb}&lt;/p&gt;&#xA;" OwnerUserId="3002" LastEditorUserId="3002" LastEditDate="2015-10-28T20:11:24.300" LastActivityDate="2015-10-28T20:11:24.300" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5297" PostTypeId="1" CreationDate="2015-10-28T17:03:53.293" Score="2" ViewCount="47" Body="&lt;p&gt;I've been working in an omni-completion script for Vim that is becoming more and more complex. At this point I'm interested in implementing some kind of check-in regression test for the script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to implement such a test?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: github + travis-ci solution is preferred.&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="51" LastEditDate="2015-10-29T14:19:29.870" LastActivityDate="2015-10-29T14:19:29.870" Title="How to implement a check-in test for omni completion script?" Tags="|vimscript|plugin-system|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5298" PostTypeId="1" AcceptedAnswerId="5303" CreationDate="2015-10-28T17:28:41.797" Score="1" ViewCount="282" Body="&lt;p&gt;I’m exploring Vim’s capabilities and somehow stumbled upon this task. It’s constructed, but I’m curious:&#xA;Is there a one-liner colon command that can &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;find the first line that matches a pattern p (say, begins with „bla“)&lt;/li&gt;&#xA;&lt;li&gt;find the first line after this line that doesn’t match p and&lt;/li&gt;&#xA;&lt;li&gt;move lines 4-5 after the line found in 2.?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The order of 1.-3. doesn’t matter for purposes of execution, that’s just to explain what I’m thinking of achieving.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks guys! Vim is so great.&lt;/p&gt;&#xA;" OwnerUserId="5089" LastEditorUserId="7161" LastEditDate="2016-05-16T10:24:44.570" LastActivityDate="2016-05-16T10:24:44.570" Title="One-liner? Move lines after 1st line not matching pattern after one that does" Tags="|command-line|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5299" PostTypeId="1" AcceptedAnswerId="5306" CreationDate="2015-10-28T19:44:32.173" Score="18" ViewCount="6897" Body="&lt;p&gt;I'm having some trouble reading vim's documentation on the terminal because I can't follow the links that are given.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I quote:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Jump to a subject:  Position the cursor on a tag (e.g. |bars|) and&#xA;  hit CTRL-].&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The problem is that i'm using a spanish keyboard where the &quot;+&quot; and the &quot;]&quot; are on the same button so when I hit CTRL-], I make a zoom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I map the CTRL-] to any other keys somehow or is there any other option? &lt;/p&gt;&#xA;" OwnerUserId="5081" LastActivityDate="2019-06-16T21:16:32.387" Title="Problem following links of vim's doc (:help) on the terminal" Tags="|key-bindings|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5300" PostTypeId="2" ParentId="5299" CreationDate="2015-10-28T22:35:16.420" Score="8" Body="&lt;p&gt;Another option is using clicking on the tag, if &lt;code&gt;set mouse=a&lt;/code&gt; is on.&lt;/p&gt;&#xA;" OwnerUserId="4932" LastActivityDate="2015-10-28T22:35:16.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5301" PostTypeId="2" ParentId="5286" CreationDate="2015-10-28T22:44:46.410" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Now doing something like :17,21Co will achieve the task and I can do :17,21Co// (for adding // instead of default #)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;tpope's commentary does this, just tab-expand the command into &lt;code&gt;:17,21Commentary&lt;/code&gt;. It'll autodetect filetypes so you don't have to worry about passing &lt;code&gt;#&lt;/code&gt; or &lt;code&gt;//&lt;/code&gt;. It wont comment blank lines, although I'm not sure why that's necessary?&lt;/p&gt;&#xA;" OwnerUserId="4932" LastActivityDate="2015-10-28T22:44:46.410" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5302" PostTypeId="2" ParentId="5298" CreationDate="2015-10-29T05:34:22.110" Score="2" Body="&lt;p&gt;You can do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/^bla/,/^\(bla\)\@!/;4,5 m .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;:/^bla/,/^\(bla\)\@!/;&lt;/code&gt; searches for the first line that begins with &lt;code&gt;bla&lt;/code&gt;, then finds the next line that does not begin with &lt;code&gt;bla&lt;/code&gt; and puts the cursor there (with &lt;code&gt;;&lt;/code&gt;). The next part, &lt;code&gt;4,5 m .&lt;/code&gt; then moves lines 4 and 5 to the cursor position &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this requires well thought out regexps, and I was not able to find a way to reuse the first regexp in the second.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-10-29T05:34:22.110" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5303" PostTypeId="2" ParentId="5298" CreationDate="2015-10-29T10:48:53.817" Score="3" Body="&lt;p&gt;Use the following syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/\(bla[^\n]*\)\+\zs/;4,5m.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which finds multiple (&lt;code&gt;+&lt;/code&gt;) occurrences of &lt;code&gt;bla&lt;/code&gt; followed by new line characters (&lt;code&gt;[^\n]&lt;/code&gt;), then place the cursor (&lt;code&gt;;&lt;/code&gt;) where we set our start of match (&lt;code&gt;\zs&lt;/code&gt;) and move our range of lines (&lt;code&gt;4,5&lt;/code&gt;) at the current cursor position. See: &lt;code&gt;:help :/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To insert lines at the end of the whole pattern (not after first line of match), change &lt;code&gt;bla[^\n]&lt;/code&gt; into &lt;code&gt;\nbla&lt;/code&gt;, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/\(\nbla\)\+\zs/;4,5m.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of current cursor position (&lt;code&gt;.&lt;/code&gt;), you can also use variety of different addresses to move the lines into, like &lt;code&gt;\/&lt;/code&gt; (the next line where the previously used search pattern matches or other addresses; see &lt;code&gt;:help {address}&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-10-29T13:08:28.563" LastActivityDate="2015-10-29T13:08:28.563" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5304" PostTypeId="2" ParentId="5293" CreationDate="2015-10-29T11:13:17.970" Score="1" Body="&lt;p&gt;Pasting in commandline-mode from a register is done via &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt;(see &lt;code&gt;:h &amp;lt;C-r&amp;gt;&lt;/code&gt;, this also works in insert mode). So you could simply yank your text object, be it via &lt;code&gt;yi}&lt;/code&gt; or visual selection, and then type &lt;code&gt;/&amp;lt;C-r&amp;gt;&quot;&amp;lt;Enter&amp;gt;&lt;/code&gt; to search for it.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastActivityDate="2015-10-29T11:13:17.970" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5305" PostTypeId="1" AcceptedAnswerId="5307" CreationDate="2015-10-29T12:49:16.453" Score="5" ViewCount="2534" Body="&lt;p&gt;I'm trying to learn a bit of vimscript and currently reading &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/12.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;the 12th chapter&lt;/a&gt; of Learn Vimscript the Hard Way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this page, the author says :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A common idiom in Vim scripting is to pair the BufRead and BufNewFile&#xA;  events together to run a command whenever you open a certain kind of&#xA;  file, regardless of whether it happens to exist already or not.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I thought I would try this for a problem I have.&#xA;I've got a folder in which I would like to be sure all files have the filetype markdown.&#xA;The folder contains existing files, which have the filetype text and don't have any extension.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added the following line to my vimrc :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead /path/to/my/folder/* set filetype=markdown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, when I create a new file inside my folder, the filetype is automatically set to markdown.&#xA;So the BufNewFile event is triggered as expected.&#xA;However, when I open an existing file, the filetype remains text, as if the BufRead event was not triggered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found two solutions :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;delete the content of &lt;code&gt;~/.vim/view&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;change the event to watch from &lt;code&gt;BufNewFile&lt;/code&gt;,&lt;code&gt;BufRead&lt;/code&gt; to &lt;code&gt;BufEnter&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But out of curiosity I would like to understand a few things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why is the &lt;code&gt;BufRead&lt;/code&gt; event not working ?&lt;/li&gt;&#xA;&lt;li&gt;What's the difference between &lt;code&gt;BufRead&lt;/code&gt; and &lt;code&gt;BufEnter&lt;/code&gt; ?&lt;/li&gt;&#xA;&lt;li&gt;For each file previously edited in vim, the &lt;code&gt;~/.vim/view&lt;/code&gt; folder seems to have a corresponding file which stores its settings (filetype, indentation...). The settings stored in that file seem to have priority over an autocmd triggered by the &lt;code&gt;BufRead&lt;/code&gt; event.&#xA;So, what's the purpose of this event if it's unable to bypass what's inside the &lt;code&gt;view/&lt;/code&gt; folder ?&lt;/li&gt;&#xA;&lt;li&gt;If I want to be sure to automatically change any setting for a file with an autocommand, is the &lt;code&gt;BufEnter&lt;/code&gt; event the right one to choose ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="10604" LastEditDate="2019-12-28T18:46:16.440" LastActivityDate="2019-12-28T18:46:16.440" Title="In an autocmd what's the use of the BufRead event?" Tags="|vimscript|vimrc|buffers|autocmd|filetype|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5306" PostTypeId="2" ParentId="5299" CreationDate="2015-10-29T13:01:42.940" Score="9" Body="&lt;p&gt;One option (if you don't mind a bit of typing) is to type &lt;code&gt;:tag tagname&lt;/code&gt; and press enter.  This is exactly equivalent to Ctrl-] according to &lt;code&gt;:help CTRL-]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use this, please note that you can use tab completion just as when typing &lt;code&gt;:help topic&lt;/code&gt; commands, and you can use Ctrl-D to list the possible autocompletions of what you've typed so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I admit this isn't much of an alternative, but it's worth knowing.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2015-10-29T13:01:42.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5307" PostTypeId="2" ParentId="5305" CreationDate="2015-10-29T14:35:04.500" Score="3" Body="&lt;p&gt;As far as I know, there is no precedence for views using &lt;code&gt;mkview&lt;/code&gt; and &lt;code&gt;loadview&lt;/code&gt; over buffer triggers such as &lt;code&gt;BufRead&lt;/code&gt;. Whatever is executed last, will define which configuration is to be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Per discussed in the comments, there are two possible solutions to this question:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Remove the &lt;code&gt;BufWinLeave&lt;/code&gt; and &lt;code&gt;BufWinEnter&lt;/code&gt; autocommands which make and load views.&lt;/li&gt;&#xA;&lt;li&gt;Or place the &lt;code&gt;BufRead&lt;/code&gt; etc. commands after the view commands. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5070" LastActivityDate="2015-10-29T14:35:04.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5309" PostTypeId="1" AcceptedAnswerId="7794" CreationDate="2015-10-30T00:21:00.233" Score="6" ViewCount="1287" Body="&lt;p&gt;How to inspect the cursor position in Vim command line (Cmdline mode) from Vim script?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to configure my Command-line mode key bindings in Vim to behave &lt;a href=&quot;http://linuxcommand.org/man_pages/tcsh1.html&quot; rel=&quot;noreferrer&quot;&gt;like in &lt;em&gt;tcsh&lt;/em&gt;&lt;/a&gt;.  In particular, i would like &lt;kbd&gt;Ctrl-d&lt;/kbd&gt; to delete one character after the cursor except at the end of the command line, and to list all possible completions otherwise (what &lt;kbd&gt;Ctrl-d&lt;/kbd&gt; does in Cmdline mode by default).  The first thing that comes to mind is to make some mapping similar to the following one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;C-d&amp;gt; (col('.')==col('$')?'&amp;lt;C-d&amp;gt;':'&amp;lt;Del&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, this one does not do what i want because it is the cursor position in the text that is being inspected, not the cursor position in the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what Vim functions can inspect the cursor position in Vim command line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also be interested to know how to move the cursor in the command line and how to modify the command line from Vim script.&lt;/p&gt;&#xA;" OwnerUserId="1248" LastActivityDate="2016-05-13T21:43:51.973" Title="How to inspect the cursor position in Vim command line (Cmdline mode)?" Tags="|vimscript|key-bindings|command-line|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5310" PostTypeId="1" CreationDate="2015-10-30T03:38:56.450" Score="13" ViewCount="21111" Body="&lt;p&gt;When I am in a CSS file with a blank line, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pZ6pk.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pZ6pk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I want to simply make a new line and move down to it, by hitting &lt;kbd&gt;Enter&lt;/kbd&gt; , vim is auto inserting a tab character, e.g. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6egUL.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6egUL.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:set fo?&lt;/code&gt; inside the CSS file =&gt; &lt;code&gt;formatoptions=croql&lt;/code&gt;.&lt;br&gt;&#xA;If I disable all formatoptions with &lt;code&gt;:set fo=&lt;/code&gt; - it still happens.&lt;br&gt;&#xA;however if format options are disabled using &lt;code&gt;:set paste&lt;/code&gt; vim does stop inserting the tab - but I dont want to have to work in paste mode all the time!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;settings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;noautoindent&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nosmartindent&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nocindent&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I turn off filetype specific indenting with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It still happens, what am I missing - do I need to restart vim or something for the settings to take effect?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I stop vim autoinserting these tab characters?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2015-10-30T03:50:58.877" LastActivityDate="2021-10-17T07:58:22.897" Title="How can I stop vim automatically inserting a tab in CSS files?" Tags="|indentation|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5311" PostTypeId="2" ParentId="5310" CreationDate="2015-10-30T04:41:32.920" Score="13" Body="&lt;p&gt;I found a couple of ways to solve the problem.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;1. reload the buffer after running &lt;code&gt;:filetype indent off&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim's docs (&lt;code&gt;:help :filetype-indent-off&lt;/code&gt;)  provided an explanation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can disable &lt;code&gt;:filetype indent on&lt;/code&gt; with: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype indent off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This actually loads the file &quot;indoff.vim&quot; in 'runtimepath'.&#xA;  This disables auto-indenting for files you will open.  It will keep working in&#xA;  already opened files.  Reset 'autoindent', 'cindent', 'smartindent' and/or&#xA;  'indentexpr' to disable indenting in an opened file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;&quot;It will keep working in already opened files.&quot;&lt;/em&gt; - explained that I simply had to kill and reload the buffer after I ran the command &lt;code&gt;:filetype indent off&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;2. Reset indentexpr&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;per docs&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Reset 'autoindent', 'cindent', 'smartindent' and/or&#xA;  'indentexpr' to disable indenting in an opened file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;it turned out the issue was caused by &lt;code&gt;indentexpr&lt;/code&gt; which had the value of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;indentexpr=GetCSSIndent()&#xA;Last set from /usr/share/vim/vim74/indent/css.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was able to reset it with: &lt;code&gt;:set indentexpr=&quot;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which also fixed the problem.&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2015-10-30T05:18:59.477" LastActivityDate="2015-10-30T05:18:59.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5312" PostTypeId="2" ParentId="1942" CreationDate="2015-10-30T06:11:03.483" Score="9" Body="&lt;h2&gt;Running a command in the background&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I was running a command that blocked for a bit, and I didn't really care about the output. This can be taken care of by starting the process attached not to the terminal/emulator but rather to the system and redirecting all output to /dev/null. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent exec &quot;!(espeak 'speaking in background'&amp;amp;) &amp;gt; /dev/null&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;(...&amp;amp;)&lt;/code&gt; runs it in the background and &lt;code&gt;&amp;gt; /dev/null&lt;/code&gt; redirects all output to &lt;code&gt;/dev/null&lt;/code&gt; (nothing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The parenthesis trap the output into a subshell (or something like that), but it does have the side-effect of not being attached to the current shell (not a big deal).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Running a command silently in the background with mapping&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I just realized that if you &lt;em&gt;are&lt;/em&gt;, in fact, mapping it, you can do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;e :!$(espeak 'speaking in the background'&amp;amp;) &amp;gt; /dev/null&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above will display nothing in the command bar and will, additionally, not display anything in the terminal outside of vim. It will be mapped to &lt;kbd&gt;&lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;&lt;/kbd&gt; &lt;kbd&gt;e&lt;/kbd&gt;, which is &lt;kbd&gt;\&lt;/kbd&gt; &lt;kbd&gt;e&lt;/kbd&gt; by default.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Running a command, capturing its output, displaying its contents&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;(Another edit - and maybe the neatest one). This one will &lt;em&gt;display&lt;/em&gt; the &lt;em&gt;output&lt;/em&gt; of a command if you so choose:&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;INSIDE A NEW TAB:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent exec &quot;!(echo 'hello. I'm a process! :)') &amp;gt; /tmp/vim_process&quot; | :tabedit /tmp/vim_process&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;INSIDE A VERTICAL SPLIT:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent exec &quot;!(echo 'hello. I'm a process :)') &amp;gt; /tmp/vim_process&quot; | :vs /tmp/vim_process&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;INSIDE A HORIZONTAL SPLIT:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent exec &quot;!(echo 'hello. I'm a process :)') &amp;gt; /tmp/vim_process&quot; | :sp /tmp/vim_process&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... do whatever you want&lt;/p&gt;&#xA;" OwnerUserId="5108" LastEditorUserId="5108" LastEditDate="2015-10-30T14:13:58.293" LastActivityDate="2015-10-30T14:13:58.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5313" PostTypeId="1" AcceptedAnswerId="5314" CreationDate="2015-10-30T09:28:42.670" Score="1" ViewCount="91" Body="&lt;p&gt;I want to essentially be able to use a command similar to &lt;code&gt;dt#&lt;/code&gt;, where the &lt;code&gt;#&lt;/code&gt; represents any numerical character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My use case is modifying a script where I have a few server instances with long names that I wanted to abbreviate, from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;instance0&#xA;instance1&#xA;instance2&#xA;instance3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i0&#xA;i1&#xA;i2&#xA;i3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is that possible without a regex? It would be useful to have something similar that includes a way to represent any alpha or symbol too.&lt;/p&gt;&#xA;" OwnerUserId="180" LastActivityDate="2015-10-30T09:55:39.977" Title="How can I execute a command with a motion to the next/previous number?" Tags="|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5314" PostTypeId="2" ParentId="5313" CreationDate="2015-10-30T09:55:39.977" Score="2" Body="&lt;p&gt;Placing your cursor on the second character in your string (&lt;code&gt;n&lt;/code&gt;), you could use &lt;code&gt;d/\d&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose this does count as regex still, but looking at the documentation of &lt;code&gt;t&lt;/code&gt; and &lt;code&gt;f&lt;/code&gt;, they both use &lt;code&gt;{char}&lt;/code&gt; which does not seem to include character groups or types such as &lt;code&gt;\d&lt;/code&gt; represents digits in a regex pattern.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i[n]stance0&#xA;instance1&#xA;instance2&#xA;instance3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;d/\d&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i0&#xA;instance1&#xA;instance2&#xA;instance3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5070" LastActivityDate="2015-10-30T09:55:39.977" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5315" PostTypeId="1" CreationDate="2015-10-30T11:05:25.383" Score="4" ViewCount="145" Body="&lt;p&gt;I would like to be able to edit and format blocks of comments (in different markup and programming languages) as if the commenting characters (generally in the beginning of the lines) are ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, when i indent or unindent a block of &quot;commented out&quot; text, i would like only the &quot;commented out&quot; text to be moved right or left, not the whole comment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; NOTE:&#xA;&quot; this is a bug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;~&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; NOTE:&#xA;&quot;   this is a bug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;not like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; NOTE:&#xA;  &quot; this is a bug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there some plugin for making Vim behave like this?  If not, what would be a simple solution to indent and unindent text in comments?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other examples of operations i would like to have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;go to first nonblank in the line (like &lt;code&gt;^&lt;/code&gt;), but ignoring the commenting character,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;delete to the beginning of line in Insert mode (like &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt;), but ignoring the commenting character.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1248" LastEditorUserId="1248" LastEditDate="2015-10-31T16:12:03.287" LastActivityDate="2015-10-31T16:12:03.287" Title="Formatting blocks of &quot;commented out&quot; text" Tags="|indentation|formatting|comments|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5316" PostTypeId="1" AcceptedAnswerId="5334" CreationDate="2015-10-30T13:33:55.590" Score="6" ViewCount="451" Body="&lt;p&gt;I've recently installed a plugin called &lt;a href=&quot;https://github.com/vim-utils/vim-troll-stopper&quot;&gt;vim-troll-stopper&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some unicode characters are drawn exactly the same but have different meanings.&#xA;I think they are called &lt;a href=&quot;https://en.wikipedia.org/wiki/Homoglyph&quot;&gt;homoglyphs&lt;/a&gt;.&lt;br&gt;&#xA;Some programmers may use this to troll people using their code, by replacing for example the semicolon (; unicode 003b) with a greek question mark (; unicode 037e).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The purpose of the plugin is to warn you by highlighting all suspicious characters in red, and by replacing them with their legitimate counterparts if you type the command &lt;code&gt;:TrollStop&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I've noticed that the more I switch between buffers, the more the plugin causes lag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how to reproduce the lag :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Install the plugin ; if you use Vundle as a plugin manager, it simply means adding the line &lt;code&gt;Plugin 'vim-utils/vim-troll-stopper'&lt;/code&gt; inside your vimrc, writing and sourcing it, then typing the command &lt;code&gt;:PluginInstall&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;open 2 files foo and bar : &lt;code&gt;vim foo bar&lt;/code&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;write some text inside foo : &lt;code&gt;here's some text&lt;/code&gt;&lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;copy and paste the line a lot : &lt;code&gt;yy99p&lt;/code&gt;&lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;switch to buffer bar : &lt;code&gt;:b2&lt;/code&gt;&lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;write some text inside bar : &lt;code&gt;more text&lt;/code&gt;&lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;copy and paste the line a lot : &lt;code&gt;yy99p&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Now, switch back and forth a lot between the two buffers with the default mapping &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;, and look at the cpu load.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;When I do this on my system, vim usually doesn't use more than 2% of the cpu and the movements inside the files (hjkl) remain quick.&lt;br&gt;&#xA;However, with the plugin enabled, switching a lot between buffers causes vim to use between 25% and 30% of the cpu, and then the movements inside the files are very slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know a lot about vimscript, but I noticed that the problem is not binary : vim is not quick then suddenly completely slow.&lt;br&gt;&#xA;The more I switch buffers, the more it is slow.&lt;br&gt;&#xA;So I supposed that something was happening every time I entered a buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked at the code, and noticed this line :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufEnter * call &amp;lt;SID&amp;gt;HighlighTrolling()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command causes vim to call the &lt;code&gt;HighlighTrolling()&lt;/code&gt; function whenever you enter a buffer.&#xA;I suppose the function highlights the suspicious characters in red.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/14.html&quot;&gt;14th chapter&lt;/a&gt; of Learn Vimscript the Hard Way, the author says that if you create an autocommand and define it twice, even though the autocommand is the same, it will be executed twice :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When you create an autocommand like this Vim has no way of knowing if&#xA;  you want it to replace an existing one. In our case, Vim created two&#xA;  separate autocommands that each happen to do the same thing.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;He also says that the solution is to wrap the autocommand inside an autocommand group and clear the group :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim has a solution to the problem. The first step is to group related&#xA;  autocommands into named groups.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;[...]&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you want to clear a group you can use autocmd! inside the group.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now, going back to the plugin lag, I thought this could explain it.&#xA;I tried fixing the code like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup highlight&#xA;    autocmd!&#xA;    autocmd BufEnter * call &amp;lt;SID&amp;gt;HighlighTrolling()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, it didn't solve the lag issue.&#xA;So I tried to simply change the event that triggers the autocommand from &lt;code&gt;BufEnter&lt;/code&gt; to &lt;code&gt;BufRead,BufNewFile&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufRead,BufNewFile * call &amp;lt;SID&amp;gt;HighlighTrolling()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It worked, the lag is now gone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, out of curiosity, I would like to know 3 things :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why is the plugin causing lag ? Is it because it duplicates an autocommand every time I enter a buffer ?&#xA;If so, is there a way to see those duplicates autocommands ?&#xA;I typed &lt;code&gt;:com&lt;/code&gt; and didn't see them.&lt;/li&gt;&#xA;&lt;li&gt;In the context of this plugin, what do you think would be the best event to trigger the autocommand that highlights the suspicious characters ?&lt;/li&gt;&#xA;&lt;li&gt;More generally, how would you modify the plugin so that it doesn't cause lag anymore ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-10-30T14:06:48.697" LastActivityDate="2015-11-02T23:05:40.713" Title="Fixing lag due to vim-troll-stopper plugin" Tags="|vimscript|buffers|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5318" PostTypeId="2" ParentId="5128" CreationDate="2015-10-31T10:40:47.163" Score="8" Body="&lt;p&gt;The slowness of delimiter matching is not caused by vim itself but by the &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/plugin/matchparen.vim&quot; rel=&quot;noreferrer&quot;&gt;matchparen plugin&lt;/a&gt;, which is part of the vim distribution and loaded by default in &lt;code&gt;/etc/vim/vimrc&lt;/code&gt; in Debian. (This is why I still had the problem without a vimrc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately the matchparen plugin supports a timeout when looking for matches, so the slowness can be avoided by setting those timeout to lower values. I added the following to my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:matchparen_timeout = 2&#xA;let g:matchparen_insert_timeout = 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2 milliseconds is plenty of time on modern machines to find a relevant delimiter, and when scrolling down in &lt;a href=&quot;http://paste.fulltxt.net/7BxA&quot; rel=&quot;noreferrer&quot;&gt;this file&lt;/a&gt; on my machine, display is no longer slugging and CPU usage for vim stays at 15% or so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; actually I increased it to 20, otherwise I sometimes see it fail. This means there is still some sluggishness, but it's better than without the setting.&lt;/p&gt;&#xA;" OwnerUserId="4819" LastEditorUserId="4819" LastEditDate="2015-11-08T15:23:42.863" LastActivityDate="2015-11-08T15:23:42.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5319" PostTypeId="1" AcceptedAnswerId="5320" CreationDate="2015-10-31T14:03:09.360" Score="3" ViewCount="251" Body="&lt;p&gt;Running &lt;code&gt;:h ctrl-\&lt;/code&gt; in Vim opens the subsection about the mapping of &lt;kbd&gt;Ctrl-\&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt; in Cmdline mode to evaluate an expression and to replace the command line with the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is &lt;kbd&gt;Ctrl-\&lt;/kbd&gt; used for something in other modes too? (I couldn't find anything about this) Even if it is, why is key sequence to evaluate an expression in Cmdline mode not simply &lt;kbd&gt;Ctrl-\&lt;/kbd&gt;?  Are there other key mappings starting with &lt;kbd&gt;Ctrl-\&lt;/kbd&gt; in Cmdline mode?  Will there be problems if I do &lt;code&gt;cnoremap &amp;lt;C-\&amp;gt; &amp;lt;C-\&amp;gt;e&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1248" LastEditorUserId="865" LastEditDate="2015-10-31T14:35:10.147" LastActivityDate="2015-10-31T14:35:10.147" Title="Strange key combination: &lt;CTRL-\&gt;&lt;e&gt; (in Cmdline mode)" Tags="|key-bindings|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5320" PostTypeId="2" ParentId="5319" CreationDate="2015-10-31T14:33:27.257" Score="5" Body="&lt;p&gt;&lt;code&gt;:help CTRL-\&lt;/code&gt;&lt;kbd&gt;Ctrl+D&lt;/kbd&gt; will show you all the help topics that contain &lt;code&gt;CTRL-\&lt;/code&gt;.  As you can see, there are a number of default keybindings that use &lt;code&gt;CTRL-\&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to whether that will cause problems, well that depends on your definition of problem. :) Do you want to be able to use any of those other commands?  If not, then it shouldn't cause a problem.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-10-31T14:33:27.257" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5321" PostTypeId="1" CreationDate="2015-10-31T18:31:50.127" Score="1" ViewCount="706" Body="&lt;p&gt;Is there a way to hide all text that is being entered, just as passwords are hidden? so that the cursor moves but the output is æquivalent to spaces, until the function is turned off? Variants of this function might leave the letter or word under the cursor visible.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2015-11-01T23:11:26.583" Title="Hiding text as entered" Tags="|formatting|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5322" PostTypeId="2" ParentId="5321" CreationDate="2015-10-31T19:58:56.993" Score="2" Body="&lt;p&gt;In Insert mode, we can intercept each inserted character, and replace it with a &lt;code&gt;*&lt;/code&gt;.  Here is a quick proof of concept:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertCharPre * let v:char='*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that one-liner is undesirable, because now it's difficult to turn off that autocommand.  You need to restart your Vim to get back to normal!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tidy way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyPassListener&#xA;  autocmd!&#xA;  autocmd InsertCharPre * if s:RecordCharacter(v:char) | let v:char='*' | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will need to implement your own RecordCharacter function, and perhaps build up a secret string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:pass = &quot;&quot;&#xA;&#xA;function! s:RecordCharacter(c)&#xA;  let s:pass .= c&#xA;  &quot; Maybe do something special here if the character is a carriage return&#xA;  return 1&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you are finished, and want to go back to normal, clear the event listener group you defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyPassListener&#xA;  autocmd!&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Notably the technique above won't store the typed characters in the buffer.  A load of &lt;code&gt;*&lt;/code&gt;s will be added to the buffer instead.  The secret characters will be available only in the &lt;code&gt;s:pass&lt;/code&gt; variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the characters that were typed to exist in the buffer, you will need to hide them, rather than replace them.  Two possible options are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Set the foreground and background highlighting to the same colour.  This should make the text invisible (provided the characters are not highlighted in bold, which can render differently in terminals).  (There might also be issues when the cursor is hovering over a character.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the &lt;code&gt;conceal&lt;/code&gt; feature to hide or overlay the characters in the buffer.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-11-01T23:11:26.583" LastActivityDate="2015-11-01T23:11:26.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5323" PostTypeId="1" CreationDate="2015-10-31T23:09:25.293" Score="2" ViewCount="86" Body="&lt;p&gt;How might one write a command that toggles between the settings &lt;code&gt;hi Normal ctermfg=8&lt;/code&gt; and &lt;code&gt;hi Normal ctermfg=12&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2015-11-01T01:59:05.933" Title="A command for toggling between text colours" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5324" PostTypeId="2" ParentId="5323" CreationDate="2015-11-01T01:20:48.357" Score="1" Body="&lt;p&gt;I think you could add this code to your &lt;code&gt;$MYVIMRC&lt;/code&gt; file :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;t :call ToggleForegroundColor()&amp;lt;CR&amp;gt;&#xA;&#xA;function! ToggleForegroundColor()&#xA;&#xA;let fgcolor=synIDattr(hlID('Normal'), 'fg#')&#xA;&#xA;if fgcolor == 8&#xA;    hi Normal ctermfg=12&#xA;else&#xA;    hi Normal ctermfg=8&#xA;endif&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After saving and sourcing it, you should be able to toggle between the two values by pressing &lt;code&gt;&amp;lt;leader&amp;gt;t&lt;/code&gt;.&lt;br&gt;&#xA;If your &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; is the comma key, it would be &lt;code&gt;,t&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can define your &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; key in your &lt;code&gt;$MYVIMRC&lt;/code&gt; file with something like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;,&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To explain the code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;t :call ToggleForegroundColor()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line maps &lt;code&gt;&amp;lt;leader&amp;gt;t&lt;/code&gt; to a function called &lt;code&gt;ToggleForegroundColor&lt;/code&gt;.&#xA;The function is defined just afterwards and is responsible for toggling the value of the &lt;code&gt;ctermfg&lt;/code&gt; argument.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let fgcolor=synIDattr(hlID('Normal'), 'fg#')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line assigns to the variable &lt;code&gt;fgcolor&lt;/code&gt; the value of the foreground color number of the Normal highlight group (&lt;code&gt;ctermfg&lt;/code&gt; if you're inside a terminal, &lt;code&gt;guifg&lt;/code&gt; if you're inside gvim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information about the built-in functions used here, you can have a look inside the help : &lt;code&gt;:h synIDattr&lt;/code&gt; and &lt;code&gt;:h hlID&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rest of the code is a simple &lt;code&gt;if else endif&lt;/code&gt; structure which tests the value of &lt;code&gt;fgcolor&lt;/code&gt; to change the value of &lt;code&gt;ctermfg&lt;/code&gt; accordingly.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-01T01:59:05.933" LastActivityDate="2015-11-01T01:59:05.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5325" PostTypeId="1" CreationDate="2015-11-01T03:30:15.183" Score="3" ViewCount="2211" Body="&lt;p&gt;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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On some slides there are also real pictures displayed. Check 7:25 and 25:20 of the video.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=MquaityA1SM&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=MquaityA1SM&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone knows how this is done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="5123" LastActivityDate="2021-04-10T04:42:20.780" Title="Using Vim/GVim for slideshow presentation" Tags="|gvim|macvim|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5327" PostTypeId="2" ParentId="5325" CreationDate="2015-11-01T10:06:38.527" Score="2" Body="&lt;p&gt;I was watching that video yesterday and had basically the same question.&lt;br&gt;&#xA;As &lt;code&gt;Wildcard&lt;/code&gt; already pointed out, I am pretty sure that the images are not directly displayed in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;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 changes my vimrc to one with a light background. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u ~/.vimrc-light -p *.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;a href=&quot;https://github.com/gelisam/git-slides&quot; rel=&quot;nofollow&quot;&gt;git-slides&lt;/a&gt; or &lt;a href=&quot;https://github.com/tybenz/vimdeck&quot; rel=&quot;nofollow&quot;&gt;vimdeck&lt;/a&gt; that both look very promising, but did not work for me particularly well.&lt;/p&gt;&#xA;" OwnerUserId="5016" LastActivityDate="2015-11-01T10:06:38.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5328" PostTypeId="2" ParentId="5325" CreationDate="2015-11-01T10:26:11.393" Score="2" Body="&lt;p&gt;That presentation is just a &lt;a href=&quot;http://unnovative.net/Erik_Falor_Vim_Wizard.pdf&quot; rel=&quot;nofollow&quot;&gt;pdf&lt;/a&gt;. You can find the link at the bottom of most slides.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-11-01T10:26:11.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5330" PostTypeId="2" ParentId="2403" CreationDate="2015-11-01T18:01:32.870" Score="4" Body="&lt;p&gt;Writing this more as a note to myself than anything, but maybe this will be useful to some: on Arch Linux, you can install a version of vim compiled with python3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# pacman -S vim-python3&#xA;resolving dependencies...&#xA;looking for conflicting packages...&#xA;:: vim-python3 and vim are in conflict. Remove vim? [y/N] y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Type y and this will replace your existing vim with the python3 enabled vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# pacman -S vim-jedi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will install the autocompletion, for python3.&lt;/p&gt;&#xA;" OwnerUserId="5129" LastActivityDate="2015-11-01T18:01:32.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5333" PostTypeId="1" CreationDate="2015-11-02T18:21:18.260" Score="4" ViewCount="365" Body="&lt;p&gt;Is there a shortcut to move the Visual area as a whole?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, after entering Visual mode linewise to make the next line selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now this is achieved by:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;V&lt;/kbd&gt; Start Visual mode linewise&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;j&lt;/kbd&gt; move one line down -&gt; now 2 lines are selected&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;o&lt;/kbd&gt; select the other end&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;j&lt;/kbd&gt; move that end one line down -&gt; finally only next line selected&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is there a shortcut that achieves the same effect as the &lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know how to create a mapping, I am asking if there is a default shortcut.&lt;/p&gt;&#xA;" OwnerUserId="1881" LastEditorUserId="1402" LastEditDate="2015-11-12T07:19:51.430" LastActivityDate="2018-04-26T09:26:03.120" Title="Moving the Visual Area at once" Tags="|key-bindings|visual-mode|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5334" PostTypeId="2" ParentId="5316" CreationDate="2015-11-02T23:05:40.713" Score="3" Body="&lt;p&gt;&lt;code&gt;vim-troll-stopper&lt;/code&gt; author here. First of all thank you for identifying the problem and contributing a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After further investigating and testing the approach with &lt;code&gt;BufRead,BufNewFile&lt;/code&gt; proposed by @Sato above I must say that's unfortunately not the solution. There are 2 scenarios where this doesn't work (this comes down to situations where the above auto commands are not triggered):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;start vim with no arguments (eg &lt;code&gt;$ vim&lt;/code&gt; in the command line). At this moment neither &lt;code&gt;BufRead&lt;/code&gt; nor &lt;code&gt;BufNewFile&lt;/code&gt; auto commands are triggered.&lt;br/&gt; If you now enter insert mode and copy-paste these troll characters &lt;code&gt;!！ǃ︕﹗&lt;/code&gt; they will not be highlighted by the plugin.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;open an existing file with vim (eg &lt;code&gt;$ vim foo.txt&lt;/code&gt;) and copy-paste these troll characters in the buffer: &lt;code&gt;!！ǃ︕﹗&lt;/code&gt;. The chars will be properly highlighted.&lt;br/&gt;&#xA;Now invoke &lt;code&gt;:split&lt;/code&gt; command (&lt;code&gt;BufRead,BufNewFile&lt;/code&gt; will not trigger!). Troll characters in new vim window will &lt;strong&gt;not&lt;/strong&gt; be highlighted.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also, even though we try to prevent unnecessary &lt;code&gt;matchadd()&lt;/code&gt;s with &lt;code&gt;BufRead,BufNewFile&lt;/code&gt; &lt;strong&gt;they will still pile up&lt;/strong&gt;. This can be checked with &lt;code&gt;:echo getmatches()&lt;/code&gt; after opening a couple files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The core to figuring this out is to understand that &lt;code&gt;matchadd()&lt;/code&gt; works &lt;strong&gt;with vim's windows not buffers&lt;/strong&gt;. As &lt;code&gt;:h matchadd()&lt;/code&gt; at the beginning states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Defines a pattern to be highlighted in the &lt;strong&gt;current window&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is really counter intuitive and what made this hard to get right. I see another popular plugin author had a lot of issues because of this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a lot of experimenting, I found this to be working:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use &lt;code&gt;BufEnter,WinEnter&lt;/code&gt; auto-commands&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;limit invoking &lt;code&gt;matchadd()&lt;/code&gt; command to only once per vim window by using guard variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('w:guard_var')&#xA;  call matchadd(...)&#xA;  let w:guard_var = 1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&quot;Troll&quot; characters are now highlighted in all scenarios. Also, if you check window matches with &lt;code&gt;:echo getmatches()&lt;/code&gt; at any point while using vim, there will be only one &lt;code&gt;TrollStopper&lt;/code&gt; group.&lt;/p&gt;&#xA;" OwnerDisplayName="user345" LastActivityDate="2015-11-02T23:05:40.713" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5335" PostTypeId="1" AcceptedAnswerId="5336" CreationDate="2015-11-03T01:49:08.717" Score="27" ViewCount="33694" Body="&lt;p&gt;I'm starting to use Vim and I chose Vundle instead of Pathogen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know if I can install the NERDTree using Vundle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm starting Vim and searching for NERDTree like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:BundleSearch NERDTree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it is not finding the plugin, only:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Keymap: i - Install plugin; c - Cleanup; s - Se|&#xA;arch; R - Reload list                           |~                                               &#xA;&quot;Search results for: NERDTree                   |~                                               &#xA;Plugin 'nerdtree-ack'                           |~                                               &#xA;Plugin 'FindInNERDTree'  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5144" LastEditorUserId="6196" LastEditDate="2016-07-20T20:21:51.920" LastActivityDate="2019-07-25T01:12:03.047" Title="How to install NERDTree with Vundle?" Tags="|plugin-nerdtree|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5336" PostTypeId="2" ParentId="5335" CreationDate="2015-11-03T02:12:07.727" Score="33" Body="&lt;p&gt;Below is the empty Vundle config.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible &#xA;filetype off&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'gmarik/Vundle.vim'&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if you want to add a new plugin example &#xA;&lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot;&gt;nerdtree&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you just add the line &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;code&gt;Plugin 'scrooloose/nerdtree'&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;now the vimrc will look like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible &#xA;filetype off&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'gmarik/Vundle.vim'&#xA;&quot; added nerdtree&#xA;Plugin 'scrooloose/nerdtree'&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, just save the vimrc and restart vim so it can source the new vimrc then issue the &lt;strong&gt;:PluginInstall command:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PluginInstall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;more information on using can be found &lt;a href=&quot;https://www.digitalocean.com/community/tutorials/how-to-use-vundle-to-manage-vim-plugins-on-a-linux-vps&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1691" LastActivityDate="2015-11-03T02:12:07.727" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5337" PostTypeId="2" ParentId="2969" CreationDate="2015-11-03T07:51:40.050" Score="0" Body="&lt;p&gt;FWIW, I use this (in my .vimrc):&#xA;&lt;code&gt;autocmd vimenter * silent! lcd %:p:h&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sets the pwd to be the current folder (or, the folder/file given when launching vim).&lt;/p&gt;&#xA;" OwnerUserId="5148" LastActivityDate="2015-11-03T07:51:40.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5338" PostTypeId="1" AcceptedAnswerId="5373" CreationDate="2015-11-04T00:06:06.253" Score="3" ViewCount="173" Body="&lt;p&gt;Vim users, tell me how many times you remember looking down at your status bar and unexpectedly seeing &lt;code&gt;recording&lt;/code&gt; in bold green. It's been recording your keystrokes since you-dont-know-when.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has happened to me no less than twenty times by now. I don't know how it is even possible for me to press q so often, and it's somewhat a possibility that some errant plugin bind is resulting in an unterminated macro recording.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It occurs to me that the best thing would be if there was somehow a way to bind an escape keystroke that aborts the recording and restores the content of whatever register I happen to be accidentally recording over. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that's really going above and beyond. I'd simply like to know which register it is that I happen to be currently recording over. Maybe I'll go take a peek at it to see how long its been recording for. Or I'll go and clear it out to keep everything nice and tidy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this even possible?&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="15" LastEditDate="2015-11-04T13:50:04.820" LastActivityDate="2015-11-06T10:36:26.093" Title="Is there any possibility of making Vim UI show which register a macro is currently being recorded to?" Tags="|macro|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5339" PostTypeId="1" AcceptedAnswerId="5341" CreationDate="2015-11-04T01:45:04.507" Score="16" ViewCount="8091" Body="&lt;p&gt;I have the following command in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;set path+=&quot;.getcwd().&quot;/**&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works well if current working directory is like &lt;code&gt;/home/tamlok/my_work/&lt;/code&gt;. However, if the directory contains spaces, such as &lt;code&gt;D:\Program Files\vim\&lt;/code&gt;, vim will complain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose that I can fix this using &lt;code&gt;substitute()&lt;/code&gt; function to replace all the spaces with escaped spaces. What would an experienced vimmer do here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another issue is the &lt;code&gt;\&lt;/code&gt; in Windows. If &lt;code&gt;getcwd()&lt;/code&gt; gets &lt;code&gt;D:\Program Files\vim\&lt;/code&gt;, do I need to escape the &lt;code&gt;\&lt;/code&gt; with &lt;code&gt;\\&lt;/code&gt; or replace it with &lt;code&gt;/&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now I handle it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mycwd=substitute(getcwd(), '\\', '/', 'g')&#xA;let mycwd=substitute(mycwd, ' ', '\\ ', 'g')&#xA;execute &quot;set path+=&quot;.mycwd.&quot;/**&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is that OK? Any help is appreciated! Thanks very much!&lt;/p&gt;&#xA;" OwnerUserId="4754" LastEditorUserId="2920" LastEditDate="2016-07-01T17:40:23.577" LastActivityDate="2016-07-01T17:40:23.577" Title="How to deal with string containing spaces in Vim script?" Tags="|vimscript|vimrc|microsoft-windows|string-manipulation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5340" PostTypeId="2" ParentId="2969" CreationDate="2015-11-04T02:11:32.210" Score="3" Body="&lt;p&gt;Here is what I did in the end. Thanks to &lt;a href=&quot;https://github.com/scrooloose/nerdtree/issues/480&quot; rel=&quot;nofollow&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NERDTreeToggleInCurDir()&#xA;  &quot; If NERDTree is open in the current buffer&#xA;  if (exists(&quot;t:NERDTreeBufName&quot;) &amp;amp;&amp;amp; bufwinnr(t:NERDTreeBufName) != -1)&#xA;    exe &quot;:NERDTreeClose&quot;&#xA;  else&#xA;    if (expand(&quot;%:t&quot;) != '')&#xA;      exe &quot;:NERDTreeFind&quot;&#xA;    else&#xA;      exe &quot;:NERDTreeToggle&quot;&#xA;    endif&#xA;  endif&#xA;endfunction&#xA;&#xA;&quot; nnoremap &amp;lt;leader&amp;gt;nf :NERDTreeFind&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;nf :call NERDTreeToggleInCurDir()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="237" LastActivityDate="2015-11-04T02:11:32.210" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5341" PostTypeId="2" ParentId="5339" CreationDate="2015-11-04T03:20:17.490" Score="18" Body="&lt;p&gt;The function you are looking for is &lt;code&gt;fnameescape()&lt;/code&gt;.  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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more on this see &lt;code&gt;:help fnameescape()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-11-04T03:20:17.490" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5342" PostTypeId="1" CreationDate="2015-11-04T10:29:36.530" Score="1" ViewCount="145" Body="&lt;p&gt;On a new Linux system (RedHat7), gvim has strange behavior. Pressing &lt;code&gt;Enter&lt;/code&gt; gives me &lt;code&gt;~M&lt;/code&gt;, pressing &lt;code&gt;Esc&lt;/code&gt; gives me &lt;code&gt;~[&lt;/code&gt;, &lt;code&gt;C-V&lt;/code&gt; gives me &lt;code&gt;~V&lt;/code&gt;. Curiously, &lt;code&gt;Enter&lt;/code&gt; on the numpad works. I tried mapping the &lt;code&gt;~M&lt;/code&gt; (which is 0x8d) in &lt;code&gt;Enter&lt;/code&gt;, without success. What is wrong with my configuration? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To complete the information, it was a package added by my computer engineer. There are also another vim on &lt;code&gt;/usr/bin/vim&lt;/code&gt; (without graphic interface) working normally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help.&lt;/p&gt;&#xA;" OwnerUserId="5162" LastEditorUserId="51" LastEditDate="2015-11-08T14:33:18.537" LastActivityDate="2015-11-08T14:33:18.537" Title="Special keys such as Enter and Ctrl+key combinations don't work with gVim" Tags="|key-bindings|gvim|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5343" PostTypeId="1" CreationDate="2015-11-04T11:41:01.253" Score="1" ViewCount="1212" Body="&lt;p&gt;I have a problem since the last Vim update that is driving me crazy. I don't know if it's actually related to the update, but since I didn't change anything in my config that's my best guess.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've mapped &lt;code&gt;leader&lt;/code&gt; to &lt;code&gt;-&lt;/code&gt; and &lt;code&gt;:q&lt;/code&gt; to &lt;code&gt;&amp;lt;leader&amp;gt;q&lt;/code&gt;. It always worked without any problem and it's one of those combinations that I perform without thinking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, I've found out today, that &lt;code&gt;-&lt;/code&gt; is mapped in &lt;code&gt;netrw&lt;/code&gt; to go up one level in the directory tree. Since a couple of days, when I load &lt;code&gt;netrw&lt;/code&gt;, Vim started to perform the default action instead of considering &lt;code&gt;-&lt;/code&gt; as my leader, so every time I try to close a window with &lt;code&gt;netrw&lt;/code&gt; in it, Vim goes up one level and starts recording a macro instead of doing &lt;code&gt;:q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is this: how can I unmap the default &lt;code&gt;-&lt;/code&gt; behavior in &lt;code&gt;netrw&lt;/code&gt; and restore my &lt;code&gt;leader&lt;/code&gt; mapping?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if anyone happens to know why this started happening in the last couple of days, I'd be very happy to know.&lt;/p&gt;&#xA;" OwnerUserId="3079" LastEditorUserId="3079" LastEditDate="2015-11-04T11:47:29.513" LastActivityDate="2015-11-04T11:47:29.513" Title="Remap netrw keys" Tags="|key-bindings|netrw|" AnswerCount="0" CommentCount="5" ClosedDate="2015-11-08T14:32:21.720" ContentLicense="CC BY-SA 3.0" />
  <row Id="5344" PostTypeId="1" CreationDate="2015-11-04T13:05:04.803" Score="3" ViewCount="635" Body="&lt;p&gt;I am new to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a HTML code with lots of &lt;code&gt;&amp;lt;li&amp;gt;&amp;lt;/li&amp;gt;&lt;/code&gt; with its content that could span multiply lines like below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;ol&amp;gt;&#xA;    &amp;lt;li&amp;gt;&#xA;        text&#xA;        text&#xA;    &amp;lt;/li&amp;gt;&#xA;    &amp;lt;li&amp;gt;&#xA;        text&#xA;        text&#xA;    &amp;lt;/li&amp;gt;&#xA;&amp;lt;/ol&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I apply &lt;code&gt;:set foldmethod=syntax&lt;/code&gt;, vim does nothing on folding that tags.&#xA;When I apply &lt;code&gt;:set foldmethod=indent&lt;/code&gt;, vim apply code folding like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;ol&amp;gt;&#xA;    &amp;lt;li&amp;gt;&#xA;+---- 2 lines: text------&#xA;    &amp;lt;/li&amp;gt;&#xA;    &amp;lt;li&amp;gt;&#xA;+---- 2 lines: text------&#xA;    &amp;lt;/li&amp;gt;&#xA;&amp;lt;/ol&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I intend to fold the code like when I use manual folding &lt;code&gt;zfat&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;ol&amp;gt;&#xA;+---- 4 lines: &amp;lt;li&amp;gt;------&#xA;+---- 4 lines: &amp;lt;li&amp;gt;------&#xA;&amp;lt;/ol&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that it is more condensed and, at the same time, I know it is a listed items.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is: how do I achieve this with auto folding?&lt;/p&gt;&#xA;" OwnerUserId="5164" LastActivityDate="2015-11-04T14:39:38.923" Title="How to auto fold html tags?" Tags="|filetype-html|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5345" PostTypeId="2" ParentId="5344" CreationDate="2015-11-04T14:39:38.923" Score="2" Body="&lt;p&gt;You can achieve this using foldexpression. The best would be to create a function, that analyzes each line and returns an actual foldlevel. Here is a short example, that should get you started:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fen fdm=expr fde=getline(v:lnum)=~#'&amp;lt;[^&amp;gt;]*&amp;gt;'?'a1':getline(v:lnum)=~#'&amp;lt;/[^&amp;gt;]*&amp;gt;'?'s1':'='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read the details at &lt;code&gt;:h fold-expr&lt;/code&gt; (especially the special meaning of the return values for the evaluation of the expression.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-11-04T14:39:38.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5346" PostTypeId="1" AcceptedAnswerId="5410" CreationDate="2015-11-04T14:57:25.880" Score="2" ViewCount="881" Body="&lt;p&gt;I'm enforcing some strange behaviour of Vundle plugin. Basically, from time to time, i'm not able to install new plugins using &lt;code&gt;:PluginInstall&lt;/code&gt; because Vundle can't see the new &lt;code&gt;Plugin&lt;/code&gt; entries in my &lt;code&gt;.vimrc&lt;/code&gt; file. The results displayed by &lt;code&gt;:PluginInstall&lt;/code&gt; contains few plugins from .vimrc but not the recently added ones. I was able to fix that temporary by closing MacVim, opening a terminal vim and running &lt;code&gt;PluginInstall&lt;/code&gt; there but it stopped working and now i'm completely not able to install new plugins anywhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It behaves like the &lt;code&gt;.vimrc&lt;/code&gt; file has been cached somewhere but i can't find such cached one and there is no any &lt;code&gt;.vimrc.swp&lt;/code&gt; file present so i feel quite lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5165" LastActivityDate="2015-11-08T21:47:02.713" Title="Vundle/vim can't see changes in .vimrc" Tags="|vimrc|macvim|plugin-vundle|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5347" PostTypeId="1" CreationDate="2015-11-04T17:06:51.487" Score="4" ViewCount="1330" Body="&lt;p&gt;I'd like to be able to see which lines in my file have been edited relative to the current git head, is there any way I can do this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, I'd like to be able to tell if a line was added or modified as I would by looking at the git diff. &lt;/p&gt;&#xA;" OwnerUserId="5167" LastActivityDate="2015-11-04T17:57:18.623" Title="Can I show the git diff status on a per-line basis?" Tags="|git|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5348" PostTypeId="1" AcceptedAnswerId="9972" CreationDate="2015-11-04T17:49:10.287" Score="25" ViewCount="13851" Body="&lt;p&gt;in vim I can do &lt;code&gt;vim --servername foo&lt;/code&gt; and &lt;code&gt;vim --servername foo --remote-silent bar.txt&lt;/code&gt; to open files in one instance of vim from several terminal windows (via tmux or whatever). How is the same thing achieved in NeoVim?&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2022-11-28T07:10:08.107" Title="How can I use --servername and --remote in neovim?" Tags="|neovim|clientserver|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5349" PostTypeId="2" ParentId="5347" CreationDate="2015-11-04T17:57:18.623" Score="4" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/airblade/vim-gitgutter&quot; rel=&quot;nofollow&quot;&gt;gitgutter&lt;/a&gt; and &lt;a href=&quot;https://github.com/mhinz/vim-signify&quot; rel=&quot;nofollow&quot;&gt;signify&lt;/a&gt; are two plugins I know of which provide this sort of functionality.  When a buffer is saved, the sign column is updated to show where lines have been added/modified/deleted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;gitgutter is Git specific, while signify supports multiple version control systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sub&gt;N.B., I'm a collaborator on signify.&lt;/sub&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-11-04T17:57:18.623" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5350" PostTypeId="2" ParentId="3066" CreationDate="2015-11-04T19:36:59.260" Score="48" Body="&lt;p&gt;You can completely wipe out a buffer using the :bwipeout (or :bw) command.  This completely removes the buffer from memory, including any marks, option settings, etc. that you have added to it.  Similarly, :bdelete (or :bd) removes the buffer, but leaves it in memory and keeps marks and option settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per the comment by Tom Hale, the Vim documentation recommends using :bd over :bw unless you know what you are doing. I tend to use :bw because like the idea of completely removing the buffer from memory, and I don't make much use of marks, buffer-specific option settings, etc, to the point of needing them to remain after closing my buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like the :quit (:q) command, Vim will give an error if the buffer has changed.  To address this, you can append an exclamation point after the command to suppress the prompt.  Another option, instead of adding exclamation points to everything, is to add &quot;set confirm&quot; to your vimrc.  With this set, vim will prompt you to save file changes on close.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:bufdo is a useful command that performs another command on all active buffers.  Combining the :bufdo command with the :bw/:bd command lets you remove all active buffers at once.  You can still use the exclamation point to suppress errors, but whether you place it after :bufdo, after :bw, or after both causes different results for each:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bd          - deletes the current buffer, error if there are unwritten changes&#xA;:bd!         - deletes the current buffer, no error if unwritten changes&#xA;:bufdo bd    - deletes all buffers, stops at first error (unwritten changes)&#xA;:bufdo! bd   - deletes all buffers except those with unwritten changes&#xA;:bufdo! bd!  - deletes all buffers, no error on any unwritten changes&#xA;&#xA;:bw          - completely deletes the current buffer, error if there are unwritten changes&#xA;:bw!         - completely deletes the current buffer, no error if unwritten changes&#xA;:bufdo bw    - completely deletes all buffers, stops at first error (unwritten changes)&#xA;:bufdo! bw   - completely deletes all buffers except those with unwritten changes&#xA;:bufdo! bw!  - completely deletes all buffers, no error on any unwritten changes&#xA;&#xA;:set confirm - confirm changes (Yes, No, Cancel) instead of error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are a few other useful buffer commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls          - list open buffers&#xA;:b N         - open buffer number N (as shown in ls)&#xA;:tabe +Nbuf  - open buffer number N in new tab&#xA;:bnext       - go to the next buffer (:bn also)&#xA;:bprevious   - go to the previous buffer (:bp also)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a lot more to buffer handling that is out of the scope of this question.  Have a look at:&lt;br&gt;&#xA;&lt;a href=&quot;http://vim.wikia.com/wiki/Vim_buffer_FAQ&quot; rel=&quot;noreferrer&quot;&gt;http://vim.wikia.com/wiki/Vim_buffer_FAQ&lt;/a&gt;&#xA;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#buffers&quot; rel=&quot;noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/windows.html#buffers&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5172" LastEditorUserId="5172" LastEditDate="2017-08-18T19:19:59.967" LastActivityDate="2017-08-18T19:19:59.967" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5351" PostTypeId="1" CreationDate="2015-11-04T20:52:00.587" Score="1" ViewCount="143" Body="&lt;p&gt;I have been using NVIM on Ubuntu machine for about 3 month now, and like most noobs started with gnome terminal, I would like to graduate to plain xterm, but having trouble with the color in xterm.  Below, on the left is the gnome terminal and on the right is the xterm:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RHRHR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RHRHR.png&quot; alt=&quot;gnome-terminal vs xterm&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is my xterm configuration:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;File &lt;code&gt;~/.xinitrc&lt;/code&gt; contents&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[[ -f ~/.Xresources ]] &amp;amp;&amp;amp; xrdb -merge -I$HOME ~/.Xresources&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;File &lt;code&gt;~/.Xresources&lt;/code&gt; contents&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xterm*faceName: Ubuntu Mono for Powerline&#xA;xterm*faceSize: 11&#xA;&#xA;xterm*loginshell: true&#xA;&#xA;xterm*savelines: 16384&#xA;&#xA;! double-click to select whole URLs :D&#xA;xterm*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:48,126:48&#xA;&#xA;*customization: -color&#xA;XTerm*termName:  xterm-256color&#xA;&#xA;xterm*rightScrollBar: false&#xA;xterm*ScrollBar: false&#xA;&#xA;XTerm*selectToClipboard: true&#xA;&#xA;! hard contrast: *background: #1d2021&#xA;*background: #282828&#xA;! soft contrast: *background: #32302f&#xA;*foreground: #ebdbb2&#xA;! Black + DarkGrey&#xA;*color0:  #282828&#xA;*color8:  #928374&#xA;! DarkRed + Red&#xA;*color1:  #cc241d&#xA;*color9:  #fb4934&#xA;! DarkGreen + Green&#xA;*color2:  #98971a&#xA;*color10: #b8bb26&#xA;! DarkYellow + Yellow&#xA;*color3:  #d79921&#xA;*color11: #fabd2f&#xA;! DarkBlue + Blue&#xA;*color4:  #458588&#xA;*color12: #83a598&#xA;! DarkMagenta + Magenta&#xA;*color5:  #b16286&#xA;*color13: #d3869b&#xA;! DarkCyan + Cyan&#xA;*color6:  #689d6a&#xA;*color14: #8ec07c&#xA;! LightGrey + White&#xA;*color7:  #a89984&#xA;*color15: #ebdbb2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the xterm running the 256color.pl script show following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ytQa8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ytQa8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like this is all that I need.  Am I missing something?  Also my configs can be found at:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/sittim/configs&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/sittim/configs&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE:  I use nvim, so for configuration look at the .nvimrc, but doing some testing the colours are the same for NVIM and VIM.&lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="3050" LastEditDate="2015-11-04T21:21:36.103" LastActivityDate="2015-11-04T21:21:36.103" Title="Color Configuration in xterm" Tags="|colorscheme|" AnswerCount="0" CommentCount="3" ClosedDate="2015-11-09T06:35:16.220" ContentLicense="CC BY-SA 3.0" />
  <row Id="5352" PostTypeId="1" AcceptedAnswerId="5353" CreationDate="2015-11-05T08:09:23.743" Score="2" ViewCount="1471" Body="&lt;p&gt;(This question pertains to &lt;code&gt;nvi&lt;/code&gt; instead of &lt;code&gt;vim&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To facilitate editing, I created the following mappings&#xA;&lt;code&gt;map! ( (?)@^[F?xi&#xA;map! [ [?]@^[F?xi&#xA;map! { {?}@^[F?xi&#xA;&lt;/code&gt;&#xA;so that entering &lt;code&gt;(&lt;/code&gt; will insert &lt;code&gt;(|)@&lt;/code&gt;, where &lt;code&gt;|&lt;/code&gt; denote the cursor position (in insert mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, what I want is that when I press &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt;, the cursor will jump to the &lt;code&gt;@&lt;/code&gt;, delete it, and go into insert mode. For this, I created the mapping&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map! ^V^I ^[f@xi&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this works &lt;em&gt;only when @ is &lt;strong&gt;not&lt;/strong&gt; the last character in the line&lt;/em&gt;. &#xA;Likewise, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map! ^V^I ^[f@xa&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;only works &lt;em&gt;when @ &lt;strong&gt;is&lt;/strong&gt; the last character in the line&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The problem is that the position of the cursor after &lt;code&gt;x&lt;/code&gt; is different depending on whether the last character was removed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would solve this problem is if there is another command &lt;code&gt;α&lt;/code&gt; (say) such that &lt;code&gt;α&lt;/code&gt; acts as &lt;code&gt;i&lt;/code&gt; or &lt;code&gt;a&lt;/code&gt; depending the cursor is at the end of the line; as far as I know, no such &lt;code&gt;α&lt;/code&gt; exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do?&lt;/p&gt;&#xA;" OwnerUserId="5179" LastActivityDate="2015-11-05T08:33:33.797" Title="Position cursor at end of line in insert mode" Tags="|cursor-movement|cursor-motions|original-vi|nvi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5353" PostTypeId="2" ParentId="5352" CreationDate="2015-11-05T08:27:48.273" Score="2" Body="&lt;p&gt;Once the cursor is on the &lt;code&gt;@&lt;/code&gt; you can press &lt;code&gt;s&lt;/code&gt; to &quot;substitute&quot; the current character. This will delete the current character and leave you in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, you could replace all your &lt;code&gt;xi&lt;/code&gt; and &lt;code&gt;xa&lt;/code&gt; with &lt;code&gt;s&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map! [ [?]@^[F?s&#xA;map! { {?}@^[F?s&#xA;&#xA;map! ^V^I ^[f@s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-11-05T08:33:33.797" LastActivityDate="2015-11-05T08:33:33.797" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5354" PostTypeId="1" AcceptedAnswerId="5500" CreationDate="2015-11-05T08:41:36.213" Score="30" ViewCount="15336" Body="&lt;p&gt;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.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way that I could (from a different terminal) tell the running Vim process to &quot;save all &amp;amp; exit&quot; from the command line? By sending a signal, or through some other means?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know about Vim swap files, and that I could just kill Vim and recover from the swap. I am asking if there is a &quot;cleaner&quot; way.&lt;/p&gt;&#xA;" OwnerUserId="1726" LastEditorUserId="205" LastEditDate="2016-05-27T15:16:05.377" LastActivityDate="2020-06-11T06:24:19.057" Title="How do I close Vim externally?" Tags="|quit|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5355" PostTypeId="1" CreationDate="2015-11-05T12:39:02.513" Score="1" ViewCount="129" Body="&lt;p&gt;I'm trying to use &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow&quot;&gt;surround.vim&lt;/a&gt; plugin and make a basic surround with a &lt;code&gt;&quot;&lt;/code&gt; sign. Documents states that i need to for example select a word with &lt;code&gt;v&lt;/code&gt; and press &lt;code&gt;s&quot;&lt;/code&gt;. However, i'm not able to use that nor any other surround command because &lt;code&gt;s&lt;/code&gt; char removes my selection and enters interactive mode. So basically using &lt;code&gt;Vs&quot;&lt;/code&gt; on &lt;code&gt;example_string&lt;/code&gt; string gives me &lt;code&gt;&quot;&lt;/code&gt; instead of &lt;code&gt;&quot;example_string&quot;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any clues!&lt;/p&gt;&#xA;" OwnerUserId="5165" LastActivityDate="2015-11-05T18:49:31.540" Title="Surround.vim deletes selection" Tags="|plugin-vim-surround|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5356" PostTypeId="1" AcceptedAnswerId="5357" CreationDate="2015-11-05T13:16:56.720" Score="19" ViewCount="2423" Body="&lt;p&gt;How to make the two windows  equal width when comparing files with command &#xA;&lt;code&gt;vim -d file1 file2&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NXXWn.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NXXWn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to make the two windows be equal width?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="51" LastEditDate="2015-11-08T12:35:45.117" LastActivityDate="2015-11-08T12:35:45.117" Title="How to make the two windows equal width when comparing files?" Tags="|vim-windows|vimdiff|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5357" PostTypeId="2" ParentId="5356" CreationDate="2015-11-05T13:21:02.010" Score="23" Body="&lt;p&gt;You can equalize the size of windows with &lt;code&gt;&amp;lt;c-w&amp;gt;=&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4573" LastEditorUserId="21" LastEditDate="2015-11-05T18:28:30.473" LastActivityDate="2015-11-05T18:28:30.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5358" PostTypeId="2" ParentId="5356" CreationDate="2015-11-05T16:08:16.000" Score="8" Body="&lt;p&gt;If you want the window widths to remain equal as you change the size of the Vim window, try this in your ~/.vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;##VimResized&quot;)&#xA;    if &amp;amp;diff&#xA;        au VimResized * wincmd =&#xA;    endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-11-05T16:08:16.000" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5359" PostTypeId="1" CreationDate="2015-11-05T18:16:03.180" Score="0" ViewCount="35" Body="&lt;p&gt;In Vim, i can cycle through edit locations with &lt;code&gt;g,&lt;/code&gt; and &lt;code&gt;g;&lt;/code&gt;, and jump  to locations with &lt;code&gt;Ctrl-I&lt;/code&gt; and &lt;code&gt;Ctrl-O&lt;/code&gt;. Is there any way to similarly cycle through edit commands? This would be something similar to &lt;code&gt;Ctrl-R&lt;/code&gt; command available in the shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words - a period command &lt;code&gt;.&lt;/code&gt; lets me execute the last edit repeatedly, but what if I wanted to execute the one before last, or second before last? Is this functionality available?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="2725" LastActivityDate="2015-11-05T18:50:55.813" Title="Cycle through edit command history" Tags="|command-history|repeated-commands|" AnswerCount="0" CommentCount="3" ClosedDate="2015-11-08T14:20:26.767" ContentLicense="CC BY-SA 3.0" />
  <row Id="5361" PostTypeId="2" ParentId="5355" CreationDate="2015-11-05T18:49:31.540" Score="1" Body="&lt;p&gt;I have this in my &lt;code&gt;.vimrc&lt;/code&gt;:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map S ysiw  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Mnemonic: &quot;you surround in word&quot;.&#xA;Since this is by far my most used scenario for surround capitol S seemed like a good shortcut.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help surround  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does definitly help you with more examples.&lt;/p&gt;&#xA;" OwnerUserId="5016" LastActivityDate="2015-11-05T18:49:31.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5362" PostTypeId="1" AcceptedAnswerId="5366" CreationDate="2015-11-05T18:56:17.880" Score="15" ViewCount="4974" Body="&lt;p&gt;I have a file that looks like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Move to 230.00&#xA;Hold&#xA;Hold&#xA;Hold&#xA;Hold&#xA;Hold&#xA;Hold&#xA;Move to 00.00&#xA;Hold &#xA;Hold &#xA;Hold &#xA;Hold &#xA;Hold &#xA;FooBar&#xA;Hold &#xA;Spam&#xA;Hold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like it to look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Move to 230.00&#xA;Hold&#xA;Move to 00.00&#xA;Hold &#xA;FooBar&#xA;Hold&#xA;Spam&#xA;Hold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm sure there must be a way that vim could quickly do this, but I can't quite wrap my head around how. Is this beyond the power of macros, and needs vimscript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it's OK if I have to apply the same macro to each block of &quot;Holds&quot;. It doesn't have to be a single one macro that gets the whole file, although that would be awesome.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="51" LastEditDate="2015-11-08T12:36:18.650" LastActivityDate="2015-12-03T02:40:24.037" Title="Delete all consecutive duplicates" Tags="|substitute|macro|global-command|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5363" PostTypeId="2" ParentId="5362" CreationDate="2015-11-05T19:27:31.127" Score="8" Body="&lt;p&gt;If you want to remove ALL adjacent identical lines, not just &lt;code&gt;Hold&lt;/code&gt;, you can do it extremely easily with an external filter from within &lt;code&gt;vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%!uniq&lt;/code&gt; (in a Unix environment).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to do it directly in &lt;code&gt;vim&lt;/code&gt;, it's actually very tricky.  I think there is a way, but for the general case it is very tricky to make it 100% functional and I haven't worked out all the bugs yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, for &lt;em&gt;this specific&lt;/em&gt; case, since you can visually see that the next line that is non-duplicate doesn't start with the same character, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:+,./^[^H]/-d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;+&lt;/code&gt; means the line after the current line.  The . refers to the current line.  The &lt;code&gt;/^[^H]/-&lt;/code&gt; means the line before (&lt;code&gt;-&lt;/code&gt;) the next line that doesn't start with H.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then d is delete.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2015-11-05T19:27:31.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5364" PostTypeId="2" ParentId="5362" CreationDate="2015-11-05T19:38:09.397" Score="2" Body="&lt;p&gt;A Vim-based answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(^.*\n\)\1\{1,}/\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;= Replace &lt;em&gt;every line followed by itself at least once&lt;/em&gt;, with that same line.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-11-05T19:38:09.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5365" PostTypeId="2" ParentId="4102" CreationDate="2015-11-05T19:41:18.263" Score="2" Body="&lt;p&gt;To add on to the awesome answer from @statox above, here's what I had to do to get it to work on Linux.  In addition to changing the appropriate &lt;code&gt;\&lt;/code&gt; to &lt;code&gt;/&lt;/code&gt;, I had to escape the parentheses, resulting in this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let list = substitute(ls_output, '&quot;\(\f*/\)*\(\f*\)&quot;', '\=submatch(2)', &quot;g&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5158" LastActivityDate="2015-11-05T19:41:18.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5366" PostTypeId="2" ParentId="5362" CreationDate="2015-11-05T19:57:29.263" Score="16" Body="&lt;p&gt;I think the following command should work :   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :%s/^\(.*\)\(\n\1\)\+$/\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We use the substitution command on the whole file to change &lt;code&gt;pattern&lt;/code&gt; into &lt;code&gt;string&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/pattern/string/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;pattern&lt;/code&gt; is &lt;code&gt;^\(.*\)\(\n\1\)\+$&lt;/code&gt; and &lt;code&gt;string&lt;/code&gt; is &lt;code&gt;\1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;pattern&lt;/code&gt; can be broken down like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^\(subpattern1\)\(subpattern2\)\+$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt; match respectively a beginning of line and an end of line.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; are used to enclose &lt;code&gt;subpattern1&lt;/code&gt; so that we can refer to it later by the special number &lt;code&gt;\1&lt;/code&gt;.&lt;br&gt;&#xA;They are also used to enclose &lt;code&gt;subpattern2&lt;/code&gt; so that we can repeat it 1 or more times with the quantifier &lt;code&gt;\+&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;subpattern1&lt;/code&gt; is &lt;code&gt;.*&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;.&lt;/code&gt; is a metacharacter matching any character except new line and &lt;code&gt;*&lt;/code&gt; is a quantifier that matches the last character 0, 1 or more times.&lt;br&gt;&#xA;So &lt;code&gt;.*&lt;/code&gt; matches any text containing no new line.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;subpattern2&lt;/code&gt; is &lt;code&gt;\n\1&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;\n&lt;/code&gt; matches a new line and &lt;code&gt;\1&lt;/code&gt; matches the same text that was matched inside the first &lt;code&gt;\(&lt;/code&gt;, &lt;code&gt;\)&lt;/code&gt; which here is &lt;code&gt;subpattern1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;pattern&lt;/code&gt; can be read like this :&lt;br&gt;&#xA;&lt;em&gt;a beginning of line (&lt;code&gt;^&lt;/code&gt;) followed by any text containing no new line (&lt;code&gt;.*&lt;/code&gt;) followed by a new line (&lt;code&gt;\n&lt;/code&gt;) then the same text (&lt;code&gt;\1&lt;/code&gt;), the latter two being repeated one or more times (&lt;code&gt;\+&lt;/code&gt;), and finally an end of line (&lt;code&gt;$&lt;/code&gt;)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wherever &lt;code&gt;pattern&lt;/code&gt; is matched (a block of identical lines), the substitution command replaces it with &lt;code&gt;string&lt;/code&gt; which here is &lt;code&gt;\1&lt;/code&gt; (the first line of the block).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to see which blocks of lines will be affected without changing anything in your file, you can enable the &lt;code&gt;hlsearch&lt;/code&gt; option and add the &lt;code&gt;n&lt;/code&gt; substitution flag at the end of the command :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(.*\)\(\n\1\)\+$/\1/n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more granular control, you can also ask for a confirmation before changing each block of lines by adding the &lt;code&gt;c&lt;/code&gt; substitution flag instead :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(.*\)\(\n\1\)\+$/\1/c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information on the substitution command read &lt;code&gt;:help :s&lt;/code&gt;,&lt;br&gt;&#xA;for the substitution flags &lt;code&gt;:help s_flags&lt;/code&gt;,&lt;br&gt;&#xA;for the various metacharacters and quantifiers read &lt;code&gt;:help pattern-atoms&lt;/code&gt;,&lt;br&gt;&#xA;and for regular expressions in vim read &lt;a href=&quot;http://vimregex.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: &lt;a href=&quot;https://vi.stackexchange.com/questions/5362/delete-all-consecutive-duplicates#comment8232_5366&quot;&gt;Wildcard&lt;/a&gt; fixed a problem in the command by adding a &lt;code&gt;$&lt;/code&gt; at the end of &lt;code&gt;pattern&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also &lt;a href=&quot;https://vi.stackexchange.com/a/5370/4939&quot;&gt;BloodGain&lt;/a&gt; has a shorter and more readable version of the same command.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-11-06T02:02:17.623" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5367" PostTypeId="1" AcceptedAnswerId="5380" CreationDate="2015-11-05T23:39:07.943" Score="1" ViewCount="573" Body="&lt;p&gt;For some reason when I execute a &lt;code&gt;hardcopy&lt;/code&gt; command &lt;code&gt;vim&lt;/code&gt; doesn't print the header, only text. Here are my setting for &lt;code&gt;printoptions&lt;/code&gt; as well as &lt;code&gt;printheader&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printoptions=left:3pc,number:y,syntax:n,header:2&#xA;printheader=%&amp;lt;%f%h%m%=Page %N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anybody know why it doesn't print the header?&lt;/p&gt;&#xA;" OwnerUserId="2865" LastActivityDate="2015-11-06T13:55:14.223" Title="vim doesn't print the header in hardcopy" Tags="|printing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5368" PostTypeId="2" ParentId="5362" CreationDate="2015-11-05T23:40:27.950" Score="2" Body="&lt;p&gt;Here is a solution based on an &lt;a href=&quot;https://groups.yahoo.com/neo/groups/vim/conversations/topics/36621&quot; rel=&quot;nofollow&quot;&gt;old (2003) vim(golf)&lt;/a&gt; by Preben Gulberg and Piet Delport.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It's roots lies in &lt;code&gt;%g/^\v(.*)\n\1$/d&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Unlike the other solutions, it has been &lt;a href=&quot;https://github.com/LucHermitte/vim-system-tools/blob/master/plugin/system_utils.vim#L195&quot; rel=&quot;nofollow&quot;&gt;encapsulated&lt;/a&gt; into a function so, it doesn't modify the search register, nor the unnamed register. &lt;/li&gt;&#xA;&lt;li&gt;And it also has been encapsulated into a command in order to simplify its usage: &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:Uniq&lt;/code&gt; (equivalent to &lt;code&gt;:%Uniq&lt;/code&gt;), &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:1,Uniq&lt;/code&gt; (from the start of the buffer to the current line), &lt;/li&gt;&#xA;&lt;li&gt;visually select lines + hit &lt;code&gt;:Uniq&amp;lt;cr&amp;gt;&lt;/code&gt; (expanded by vim into &lt;code&gt;:'&amp;lt;,'&amp;gt;Uniq&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;etc (&lt;code&gt;:h range&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% -nargs=0 Uniq &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call s:EmuleUniq()&#xA;&#xA;function! s:EmuleUniq() range&#xA;  let l1 = a:firstline&#xA;  let l2 = a:lastline&#xA;  if l1 &amp;lt; l2&#xA;    &quot; Note the &quot;-&quot; to avoid spilling over the end of the range&#xA;    &quot; Note also the use of &quot;:delete&quot;, along with the black hole register &quot;_&quot;&#xA;    silent exe l1.','l2.'-g/^\(.*\)\n\1$/d _'&#xA;&#xA;    call histdel('search', -1)          &quot; necessary&#xA;    &quot; let @/ = histget('search', -1)    &quot; useless within a function&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: their firsts attempts were:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Version1 from: Preben 'Peppe' Guldberg &amp;lt;peppe {at} xs4all {dot} nl&amp;gt;&#xA;&quot; silent exe l1 . ',' . (l2 - 1) . 's/^\(.*\)\%(\n\%&amp;lt;' . (l2 + 1)&#xA;      &quot; \ . 'l\1$\)\+/\1/e'&#xA;&#xA;&quot; Version from: Piet Delport &amp;lt;pjd {at} 303.za {dot} net&amp;gt;&#xA;&quot; silent exe l1.','l2.'g/^\%&amp;lt;'.l2.'l\(.*\)\n\1$/d'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2015-11-06T10:40:42.667" LastActivityDate="2015-11-06T10:40:42.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5369" PostTypeId="2" ParentId="4102" CreationDate="2015-11-06T00:04:07.743" Score="3" Body="&lt;p&gt;You can also emulate &lt;code&gt;:ls&lt;/code&gt; quite easily in VimL (and thus avoid &lt;code&gt;:redir&lt;/code&gt;, the need to cut the line and analyse the filenames, ...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the way, you can filter and choose which filenames you wish to keep and also which part you want to display. However more work is required if you which to keep the attributes echoed by &lt;code&gt;:ls&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Answers were given to a similar question (just filtering), on SO: &lt;a href=&quot;https://stackoverflow.com/questions/2974192/how-can-i-pare-down-vims-buffer-list-to-only-include-active-buffers&quot;&gt;https://stackoverflow.com/questions/2974192/how-can-i-pare-down-vims-buffer-list-to-only-include-active-buffers&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like the functional approach, other prefer plain loops:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo join(sort(map(filter(range(0, bufnr('$')), 'bufwinnr(v:val)&amp;gt;=0'), 'fnamemodify(bufname(v:val), &quot;:t&quot;)'), 'u'), &quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-08-14T13:03:25.947" LastActivityDate="2017-08-14T13:03:25.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5370" PostTypeId="2" ParentId="5362" CreationDate="2015-11-06T00:17:08.463" Score="12" Body="&lt;p&gt;Try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s;\v^(.*)(\n\1)+$;\1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As with &lt;a href=&quot;https://vi.stackexchange.com/a/5366/5190&quot;&gt;saginaw's answer&lt;/a&gt;, this uses Vim's :substitute command. However, it takes advantage of a couple of extra features to improve readability:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Vim lets us use any non-alphanumeric ASCII character except backslash (&lt;strong&gt;\&lt;/strong&gt;), double-quote (&lt;strong&gt;&quot;&lt;/strong&gt;), or pipe (&lt;strong&gt;|&lt;/strong&gt;) to divide our match/replace/flags text. Here, I selected semicolon (&lt;strong&gt;;&lt;/strong&gt;), but you can choose another.&lt;/li&gt;&#xA;&lt;li&gt;Vim provides &quot;magic&quot; settings for regular expressions, so that characters are interpreted for their special meanings instead of requiring a backslash escape. This is helpful to reduce verbosity, and because it is more consistent than the &quot;nomagic&quot; default. Starting with &lt;strong&gt;&lt;code&gt;\v&lt;/code&gt;&lt;/strong&gt; means &quot;very magic,&quot; or all characters except alphanumeric (&lt;strong&gt;A-z0-9&lt;/strong&gt;) and underscore (&lt;strong&gt;_&lt;/strong&gt;) have special meaning.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The meaning of the components are:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;%&lt;/strong&gt; &lt;em&gt;for the whole file&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;s&lt;/strong&gt; &lt;em&gt;substitute&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;;&lt;/strong&gt; &lt;em&gt;begin substitute string&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;\v&lt;/strong&gt; &lt;em&gt;&quot;very magic&quot;&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;^&lt;/strong&gt; &lt;em&gt;beginning of line&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;(.*)&lt;/strong&gt; &lt;em&gt;0 or more of &lt;strong&gt;any&lt;/strong&gt; character (group 1)&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;(\n\1)+&lt;/strong&gt; &lt;em&gt;newline followed by (group 1 match text), 1 or more times (group 2)&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;$&lt;/strong&gt; &lt;em&gt;end of line&lt;/em&gt; (or in this case, think &lt;em&gt;next character must be a newline&lt;/em&gt;)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;;&lt;/strong&gt; &lt;em&gt;begin replace string&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;\1&lt;/strong&gt; &lt;em&gt;group 1 match text&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;;&lt;/strong&gt; &lt;em&gt;end of command&lt;/em&gt; or &lt;em&gt;begin flags&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5190" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-12-03T02:40:24.037" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5371" PostTypeId="1" AcceptedAnswerId="5395" CreationDate="2015-11-06T02:24:31.197" Score="6" ViewCount="1960" Body="&lt;p&gt;I defined some highlights in the vimrc file and it works well in gvim. However after I &lt;code&gt;mksession&lt;/code&gt; 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.&lt;br&gt;&#xA;The &lt;code&gt;sessionoptions&lt;/code&gt; is &lt;code&gt;blank,buffers,curdir,folds,help,options,tabpages,winsize&lt;/code&gt;.&lt;br&gt;&#xA;Snippet from my vimrc file:&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let current_color = &quot;&quot;&#xA;&#xA;if has(&quot;gui_running&quot;)&#xA;    colorscheme desert&#xA;    let current_color = &quot;desert&quot;&#xA;else&#xA;    colorscheme torte&#xA;    let current_color = &quot;torte&quot;&#xA;endif&#xA;&#xA;&quot; Section about changing color&#xA;if current_color == &quot;desert&quot;&#xA;    hi LineNr guifg=DarkKhaki&#xA;    &quot; Or guibg=NavajoWhite1&#xA;    hi StatusLine guifg=black guibg=LightGoldenrod3&#xA;    hi PmenuSel guifg=black guibg=LightGoldenrod3&#xA;    &quot; Or guibg=Plum3&#xA;    hi Pmenu guifg=black guibg=RosyBrown&#xA;    hi CursorLine guibg=Grey27&#xA;elseif current_color == &quot;torte&quot;&#xA;    hi CursorLine term=NONE cterm=NONE ctermbg=238&#xA;    hi Search term=reverse ctermfg=229 ctermbg=136&#xA;    hi StatusLine ctermfg=16 ctermbg=179 cterm=NONE&#xA;    hi StatusLineNC ctermfg=244 ctermbg=144 cterm=NONE&#xA;    hi Comment term=bold ctermfg=74&#xA;    hi Constant term=underline ctermfg=217&#xA;    hi LineNr term=underline ctermfg=143&#xA;    hi Folded ctermfg=220&#xA;    hi FoldColumn ctermfg=220&#xA;    hi Special ctermfg=214&#xA;    hi NonText ctermfg=152 ctermbg=239&#xA;    hi Visual ctermfg=186 ctermbg=64 cterm=NONE&#xA;    hi PmenuSel ctermfg=16 ctermbg=179 cterm=NONE&#xA;    hi Pmenu ctermfg=16 ctermbg=138&#xA;    hi ColorColumn ctermbg=88&#xA;    hi WarningMsg ctermfg=202&#xA;    hi ErrorMsg ctermfg=15 ctermbg=160&#xA;    hi Error ctermfg=15 ctermbg=160&#xA;endif&#xA;hi Modifier cterm=inverse ctermfg=118 gui=inverse guifg=#87ff00&#xA;hi StatuslineWarning cterm=inverse ctermfg=210 gui=inverse guifg=#ff8787&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help? Thanks very much!&lt;/p&gt;&#xA;" OwnerUserId="4754" LastActivityDate="2018-08-06T01:45:40.937" Title="Vim lost custom highlight settings after recovering from sessions" Tags="|vimrc|gvim|colorscheme|highlight|sessions|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5372" PostTypeId="2" ParentId="5362" CreationDate="2015-11-06T05:25:52.547" Score="2" Body="&lt;p&gt;One more, assuming Vim 7.4.218 or later:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Uniq(line1, line2)&#xA;    let cursor = getcurpos()&#xA;    let lines = uniq(getline(a:line1, a:line2))&#xA;    if setline(a:line1, lines) == 0 &amp;amp;&amp;amp; len(lines) &amp;lt;= a:line2 - a:line1&#xA;        silent execute (a:line1 + len(lines)) . ',' . a:line2 . 'd _'&#xA;    endif&#xA;    call setpos('.', cursor)&#xA;endfunction&#xA;&#xA;command! -range=% Uniq call &amp;lt;SID&amp;gt;Uniq(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This isn't necessarily better than the other solutions, though.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-11-06T05:25:52.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5373" PostTypeId="2" ParentId="5338" CreationDate="2015-11-06T10:36:26.093" Score="2" Body="&lt;p&gt;You can display the current register in your statusline (vim-airline) with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%{v:register}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5016" LastActivityDate="2015-11-06T10:36:26.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5374" PostTypeId="1" CreationDate="2015-11-06T11:28:37.157" Score="2" ViewCount="338" Body="&lt;p&gt;I am very new to Vim and this problem has stumped me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;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 file? Bear in mind, my file is very large and will take a long time to move to the bottom.&lt;/p&gt;&#xA;" OwnerUserId="5199" LastEditorUserId="205" LastEditDate="2015-11-08T18:49:13.960" LastActivityDate="2015-11-08T18:49:13.960" Title="How to save text after deleting lines to a new file in Vim?" Tags="|command-line|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5375" PostTypeId="2" ParentId="5374" CreationDate="2015-11-06T11:39:29.197" Score="0" Body="&lt;p&gt;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 the result to a new file called bar. To do this you can type &lt;code&gt;:saveas bar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a file called bar already exists, you will have to tell vim to overwrite it by adding an exclamation mark &lt;code&gt;:saveas! bar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To navigate between the two files foo and bar, you can type &lt;code&gt;:b#&lt;/code&gt; or&lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; (the Control modifier key and the &lt;code&gt;^&lt;/code&gt; key pressed at the same time).&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-06T12:31:04.507" LastActivityDate="2015-11-06T12:31:04.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5376" PostTypeId="1" AcceptedAnswerId="5378" CreationDate="2015-11-06T12:41:50.027" Score="3" ViewCount="480" Body="&lt;p&gt;I want to check if a string consists of n or more words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the following regex to check for 3 words, but the match returns true?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo '  hello world  ' =~ '^\(\s\{-}\w\+\)\{-3,}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to make regex matching &quot;n&quot; or more words?&lt;/p&gt;&#xA;" OwnerUserId="5201" LastActivityDate="2015-11-06T15:41:31.213" Title="Match &quot;n&quot; or more words" Tags="|vimscript|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5377" PostTypeId="1" AcceptedAnswerId="5379" CreationDate="2015-11-06T13:20:16.640" Score="1" ViewCount="506" Body="&lt;p&gt;I have &lt;code&gt;set autoindent&lt;/code&gt; and &lt;code&gt;set tw=90&lt;/code&gt; and &lt;code&gt;set fo=t&lt;/code&gt;. Additionally I have working autocompletion that means when I type one character a popup menu come in. Because of popup menu in some situations, where all these 3 things happen to work together, it gives some very unpleasant random effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a line like this that is less than &lt;code&gt;tw&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;some indentation&amp;gt;sdjfl ... sdkf Some&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I add some text and have a cursor in the specified position in insert mode&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;some indentation&amp;gt;sdjfl ... sdkfslfj &amp;lt;cursor&amp;gt; Some&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I type a character like here&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;some indentation&amp;gt;sdjfl ... sdkfslfj I Some&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And vim wraps should wrap and indent me text like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;some indentation&amp;gt;sdjfl ... sdkfslfj &#xA;&amp;lt;some indentation&amp;gt;I&amp;lt;cursor&amp;gt; Some&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I have this result&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;some indentation&amp;gt;sdjfl ... sdkfslfj &#xA;&amp;lt;some indentation&amp;gt;I&amp;lt;cursor&amp;gt;Some&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or very often and more unfortunately I have this result&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;some indentation&amp;gt;sdjfl ... sdkfslfj &#xA;&amp;lt;some indentation&amp;gt;SI&amp;lt;cursor&amp;gt;ome&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I figured out that when I turn off autocompletion, than&#xA;I have many correct result, and sometime this results where it cuts the space before cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Help me to solve this, please?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The options and version of my vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Options ---&#xA;  autoindent          guioptions=agit     laststatus=0        showbreak=↪       textwidth=90&#xA;  background=dark     helplang=en         linebreak           showcmd             timeoutlen=700&#xA;  backup              hidden            nomore              noshowmode            ttimeoutlen=900&#xA;  comments=b:#,fb:-   history=1000        mouse=a             smartcase           ttyfast&#xA;  confirm             hlsearch            number              smartindent         updatetime=800&#xA;  copyindent          ignorecase          previewheight=30    softtabstop=2       wildignore=*.pyc&#xA;  cursorcolumn        iminsert=0          ruler               splitbelow          wildmenu&#xA;  cursorline          incsearch           scroll=26           splitright          window=55&#xA;  expandtab         nojoinspaces          scrolloff=3         suffixesadd=.py&#xA;  filetype=python     keywordprg=pydoc    shiftwidth=2        syntax=python&#xA;  backspace=indent,eol,start&#xA;  backupdir=~/Vim/Trash/backup&#xA;  cinkeys=0{,0},0),:,!^F,o,O,e&#xA;  commentstring=# %s&#xA;  directory=~/Vim/Trash/swap&#xA;  fileencoding=utf-8&#xA;  fileencodings=utf-8,ucs-bom,latin1,iso-8859-5&#xA;  formatoptions=tqcrow&#xA;  grepprg=grep -nH --color&#xA;  guicursor=n-c-v:block-Cursor-blinkwait1000-blinkon0-blinkoff250,i-ci:ver30-iCursor-blinkwait30000-blinkon200-blinkoff150&#xA;  guifont=Powerline Consolas 13&#xA;  include=^\s*\(from\|import\)&#xA;  includeexpr=substitute(v:fname,'\.','/','g')&#xA;  indentexpr=GetPythonIndent(v:lnum)&#xA;  indentkeys=0{,0},:,!^F,o,O,e,&amp;lt;:&amp;gt;,=elif,=except&#xA;  makeprg=make -f ~/Documents/Tests/Makefile&#xA;  omnifunc=pythoncomplete#Complete&#xA;  printoptions=paper:a4&#xA;  termencoding=utf-8&#xA;&#xA;&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec  9 2014 17:36:41)&#xA;Included patches: 1-488&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by buildd@&#xA;Huge version with GTK2-GNOME GUI.  Features included (+) or not (-):&#xA;+acl             +dialog_con_gui  +insert_expand   +mouse_sgr       +ruby            +vertsplit&#xA;+arabic          +diff            +jumplist        -mouse_sysmouse  +scrollbind      +virtualedit&#xA;+autocmd         +digraphs        +keymap          +mouse_urxvt     +signs           +visual&#xA;+balloon_eval    +dnd             +langmap         +mouse_xterm     +smartindent     +visualextra&#xA;+browse          -ebcdic          +libcall         +multi_byte      -sniff           +viminfo&#xA;++builtin_terms  +emacs_tags      +linebreak       +multi_lang      +startuptime     +vreplace&#xA;+byte_offset     +eval            +lispindent      -mzscheme        +statusline      +wildignore&#xA;+cindent         +ex_extra        +listcmds        +netbeans_intg   -sun_workshop    +wildmenu&#xA;+clientserver    +extra_search    +localmap        +path_extra      +syntax          +windows&#xA;+clipboard       +farsi           +lua             +perl            +tag_binary      +writebackup&#xA;+cmdline_compl   +file_in_path    +menu            +persistent_undo +tag_old_static  +X11&#xA;+cmdline_hist    +find_in_path    +mksession       +postscript      -tag_any_white   -xfontset&#xA;+cmdline_info    +float           +modify_fname    +printer         +tcl             +xim&#xA;+comments        +folding         +mouse           +profile         +terminfo        +xsmp_interact&#xA;+conceal         -footer          +mouseshape      +python          +termresponse    +xterm_clipboard&#xA;+cryptv          +fork()          +mouse_dec       -python3         +textobjects     -xterm_save&#xA;+cscope          +gettext         +mouse_gpm       +quickfix        +title           +xpm&#xA;+cursorbind      -hangul_input    -mouse_jsbterm   +reltime         +toolbar         &#xA;+cursorshape     +iconv           +mouse_netterm   +rightleft       +user_commands   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5038" LastEditorUserId="51" LastEditDate="2015-11-09T06:33:11.537" LastActivityDate="2015-11-09T06:33:11.537" Title="Autocomplete popup menu with autoindent and hard wrap in insert mode" Tags="|autocompletion|indentation|wrapping|plugin-you-complete-me|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5378" PostTypeId="2" ParentId="5376" CreationDate="2015-11-06T13:31:01.793" Score="3" Body="&lt;p&gt;I don't know if it's correct, but to check if a string contains 3 words or more I would type this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo 'some random string' =~ '\v\s*(\w+\s+){2,}\w+\s*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For 4 words or more :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo 'some random string' =~ '\v\s*(\w+\s+){3,}\w+\s*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: &lt;a href=&quot;https://vi.stackexchange.com/questions/5376/match-n-or-more-words#comment8247_5378&quot;&gt;Peter Rincker&lt;/a&gt;'s answer seems much better and shorter :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v(\w+(\s+|$)){3,}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not sure but I suppose it can be read as :&lt;br&gt;&#xA;&lt;em&gt;very magic mode enabled (&lt;code&gt;\v&lt;/code&gt;), a word (&lt;code&gt;\w+&lt;/code&gt;) followed by either a whitespace (&lt;code&gt;\s+&lt;/code&gt;) or (&lt;code&gt;|&lt;/code&gt;) the end of the string (&lt;code&gt;$&lt;/code&gt;), everything being repeated 3 or more times (&lt;code&gt;{3,}&lt;/code&gt;)&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-06T15:41:31.213" LastActivityDate="2015-11-06T15:41:31.213" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5379" PostTypeId="2" ParentId="5377" CreationDate="2015-11-06T13:47:30.763" Score="0" Body="&lt;p&gt;As the problem just happens when you are using the Ycm plugin, it is certainly something related to that plugin. You should check &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/blob/master/doc/youcompleteme.txt&quot; rel=&quot;nofollow&quot;&gt;plugin documentation&lt;/a&gt;. In special, the FAQ section reports that some plugins that may cause interference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    9. FAQ |youcompleteme-faq|&#xA;   1. I used to be able to 'import vim' in '.ycm_extra_conf.py', but now can't |import-vim|&#xA;      :&#xA;      :&#xA;   18. YCM conflicts with UltiSnips TAB key usage |youcompleteme-ycm-conflicts-with-ultisnips-tab-key-usage|&#xA;   19. Why isn't YCM just written in plain VimScript, FFS? |youcompleteme-why-isnt-ycm-just-written-in-plain-vimscript-ffs|&#xA;   20. Why does YCM demand such a recent version of Vim? |youcompleteme-why-does-ycm-demand-such-recent-version-of-vim|&#xA;   21. I get annoying messages in Vim's status area when I type |youcompleteme-i-get-annoying-messages-in-vims-status-area-when-i-type|&#xA;   22. Nasty bugs happen if I have the 'vim-autoclose' plugin installed |vim-sub-autoclose|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also search the current and closed issues on &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/issues&quot; rel=&quot;nofollow&quot;&gt;the bug tracker&lt;/a&gt;. If any of these solves your problem, you should open a new issue there.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-11-06T13:47:30.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5380" PostTypeId="2" ParentId="5367" CreationDate="2015-11-06T13:55:14.223" Score="2" Body="&lt;p&gt;I tried with your very own settings and I encountered no issue. If I understand the help correctly, by default Vim will use A4 as the medium size; maybe your output gets on a smaller medium size than A4? Could you try to add something like:  &lt;code&gt;paper:letter&lt;/code&gt; in your &lt;code&gt;printoptions&lt;/code&gt;. Does it change something? What exact size of medium are you using?&lt;/p&gt;&#xA;" OwnerUserId="5139" LastActivityDate="2015-11-06T13:55:14.223" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5381" PostTypeId="2" ParentId="5374" CreationDate="2015-11-06T14:02:18.823" Score="2" Body="&lt;p&gt;I'm not sure to understand your need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only want to save lines filtered into a new file, you can play with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; equivalent to &quot;grep the_word &amp;gt; the-filename&quot;&#xA;:let @a =''&#xA;:v/the_word/y A&#xA;:call writefile(@a, 'the-filename')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However a more likely scenario is: if you do multiple edits, &lt;code&gt;:saveas&lt;/code&gt; will permit to save the current buffer under in another file. But the current filename won't be changed. If you do some more edits, and hit &lt;code&gt;:save&lt;/code&gt;/&lt;code&gt;:update&lt;/code&gt;, the old file will get overwritten. You need to call &lt;code&gt;:file&lt;/code&gt; in order to change the filename of the current buffer. After that, all following saves will be done to the new file, leaving the old one unchanged.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2015-11-06T14:02:18.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5382" PostTypeId="1" AcceptedAnswerId="5790" CreationDate="2015-11-06T15:16:04.590" Score="10" ViewCount="193" Body="&lt;p&gt;I have tried this in a JavaScript file after disabling &lt;code&gt;smartindent&lt;/code&gt; and &lt;code&gt;autoindent&lt;/code&gt; options, with &lt;code&gt;textwidth = 80&lt;/code&gt;, but it is still the same.&#xA;It also happens automatically because of the &lt;code&gt;textwidth&lt;/code&gt; option when inserting words which together have a length of over 80 characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What happens:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA; * - a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l&#xA; *   m n o p q r s t u v w x y z&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I want:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA; * - a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l&#xA; * m n o p q r s t u v w x y z&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you very much! &lt;code&gt;:-)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5010" LastEditorUserId="51" LastEditDate="2015-11-08T12:35:22.707" LastActivityDate="2015-12-10T12:55:22.823" Title="How to temporarily make gq consider hyphen (-) a normal word, to not indent the following lines in the same paragraph" Tags="|indentation|formatting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5383" PostTypeId="1" AcceptedAnswerId="5385" CreationDate="2015-11-06T16:01:14.063" Score="3" ViewCount="191" Body="&lt;p&gt;I am a heavy user of the argument list and I always have the files which are important for my current task in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I started to use netrw more often to search through the files system.&#xA;But I can't find a way to add the files and to add it to the argument list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is it possible to &lt;code&gt;:arge&lt;/code&gt; a file from within netrw? &lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2015-11-20T21:28:29.120" Title="Is it possible to add a file to the argument list with in netrw?" Tags="|netrw|argument-list|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5385" PostTypeId="2" ParentId="5383" CreationDate="2015-11-06T16:23:29.853" Score="2" Body="&lt;p&gt;You can do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;c                       make the current netrw directory the current vim directory&#xA;:arge &amp;lt;C-r&amp;gt;&amp;lt;C-f&amp;gt;&amp;lt;CR&amp;gt;    edit the file under the cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adding this line to your &lt;code&gt;vimrc&lt;/code&gt; should allow you to avoid the &lt;code&gt;c&lt;/code&gt; step:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_keepdir = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-11-06T16:23:29.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5387" PostTypeId="2" ParentId="1922" CreationDate="2015-11-06T17:10:14.283" Score="4" Body="&lt;p&gt;If you want to substitute within a visual &lt;em&gt;block&lt;/em&gt;, you can use the &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#VIS&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;vis.vim&lt;/code&gt; plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Applying_substitutes_to_a_visual_block&quot; rel=&quot;nofollow&quot;&gt;http://vim.wikia.com/wiki/Applying_substitutes_to_a_visual_block&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To install:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Download vis.vba.gz from &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#VIS&quot; rel=&quot;nofollow&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#VIS&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Open vis.vba.gz in Vim 7.1 or later.&#xA;vim vis.vba.gz&#xA;&#xA;# Source the open file.&#xA;:so %&#xA;&#xA;# Quit Vim&#xA;:q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctrl-v to enter visual-block mode&#xA;Move to select the block you want&#xA;:B s/pattern/newtext/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you type &lt;code&gt;:B&lt;/code&gt;, you will see this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;B &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's fine, it's just vim saying that the command will apply to the currently selected visual block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even better, you can perform any Ex command on the visual block, not just substitutions. For example &lt;code&gt;:B !sort&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2244" LastEditorUserId="2244" LastEditDate="2015-11-06T18:41:59.373" LastActivityDate="2015-11-06T18:41:59.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5388" PostTypeId="1" AcceptedAnswerId="5404" CreationDate="2015-11-06T18:00:03.057" Score="9" ViewCount="883" Body="&lt;p&gt;When I write a German text containing something like &lt;code&gt;abücd&lt;/code&gt; for instance and to a &lt;code&gt;dw&lt;/code&gt; in front, it will only delete the &lt;code&gt;ab&lt;/code&gt; since it does not interpret &lt;code&gt;ü&lt;/code&gt; as a word character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I edit reStructuredText, I have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iskeyword=38,42,43,45,47-58,60-62,64-90,97-122,_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That explains why the umlauts are not marked, but I do not understand where this comes from. When I just open gVim this is set to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iskeyword=@,48-57,_,192-255&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where could this be coming from?&lt;/p&gt;&#xA;" OwnerUserId="5210" OwnerDisplayName="Martin Ueding" LastEditorUserId="5210" LastEditDate="2015-11-08T08:25:43.857" LastActivityDate="2016-10-25T20:07:47.120" Title="Vim does not take umlauts as word characters" Tags="|unicode|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5390" PostTypeId="1" AcceptedAnswerId="5394" CreationDate="2015-11-06T18:37:47.650" Score="12" ViewCount="1460" Body="&lt;p&gt;I want to modify files with &lt;code&gt;vim&lt;/code&gt; without changing the creation time stamps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The docs doesn't seem to mention anything about such possibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to achieve this without turning off the swap/recover feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One alternative would be to store the time somewhere and then overwrite it when exiting, I guess.&lt;/p&gt;&#xA;" OwnerUserId="4432" LastActivityDate="2019-05-09T00:15:42.393" Title="Preserve creation time stamp after modification" Tags="|buffers|save|" AnswerCount="3" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5391" PostTypeId="2" ParentId="5390" CreationDate="2015-11-07T04:53:45.350" Score="1" Body="&lt;p&gt;What you want is not possible to implement in UNIX using standard userspace functions.  The &lt;code&gt;ctime&lt;/code&gt; of a file is updated automatically by the kernel &lt;a href=&quot;https://unix.stackexchange.com/questions/31255/on-what-occasion-will-inode-change/31261&quot;&gt;when the file's &lt;code&gt;inode&lt;/code&gt; changes&lt;/a&gt;.  Unlike &lt;code&gt;atime&lt;/code&gt; and &lt;code&gt;mtime&lt;/code&gt;, there is no user-accessible function to set &lt;code&gt;ctime&lt;/code&gt; to an arbitrary value.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2015-11-07T04:53:45.350" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5392" PostTypeId="2" ParentId="184" CreationDate="2015-11-07T07:25:58.887" Score="39" Body="&#xA;&#xA;&lt;h2&gt;Disable search highlighting permanently&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Matches won't be highlighted whenever you do a search using &lt;kbd&gt;/&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nohlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Clear highlight until next search&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;code&gt;:nohlsearch&lt;/code&gt; (clears until &lt;kbd&gt;n&lt;/kbd&gt; or &lt;kbd&gt;N&lt;/kbd&gt; is pressed or a fresh search is performed)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Clear highlight on pressing &lt;kbd&gt;ESC&lt;/kbd&gt;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;esc&amp;gt; :noh&amp;lt;return&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Clear highlight on pressing another key or custom map&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Clear highlights on pressing &lt;kbd&gt;\&lt;/kbd&gt; (backslash)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap \ :noh&amp;lt;return&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Clear highlights on hitting &lt;kbd&gt;ESC&lt;/kbd&gt; twice&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;esc&amp;gt;&amp;lt;esc&amp;gt; :noh&amp;lt;return&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="969" LastActivityDate="2015-11-07T07:25:58.887" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5393" PostTypeId="1" AcceptedAnswerId="5413" CreationDate="2015-11-07T09:43:06.753" Score="22" ViewCount="22396" Body="&lt;p&gt;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.&lt;/p&gt;&#xA;" OwnerUserId="5214" LastActivityDate="2016-08-14T15:31:24.983" Title="What's the correct way to install YouComplete using vim-plug in vim/nvim?" Tags="|plugin-you-complete-me|plugin-vim-plug|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5394" PostTypeId="2" ParentId="5390" CreationDate="2015-11-07T18:22:39.120" Score="2" Body="&lt;p&gt;Sato's answer would be correct on a standard Unix-derivative, where &lt;code&gt;ctime&lt;/code&gt; is often mistaken for creation time but is actually inode change time, and &quot;preserving&quot; 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 and time, and isn't updated by modifying the file in place or changing the file's mode or anything like that, all of which do update &lt;code&gt;ctime&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see the creation time by doing a Get Info on a file in the Finder or &lt;code&gt;GetFileInfo &amp;lt;file&amp;gt;&lt;/code&gt; from a command line (&lt;code&gt;GetFileInfo&lt;/code&gt; requires the developer tools to be installed). The time can be modified using &lt;code&gt;SetFile -d &amp;lt;datetime&amp;gt; &amp;lt;file&amp;gt;&lt;/code&gt; (also requiring developer tools).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it seems reasonable (to me, don't know about Bram :-) ) to ask for vim to maintain the create time on Mac OS X, by copying the create time from the original file to the new file, but it clearly doesn't, and glancing through the vim sources, I don't see anywhere where it does so. So, unfortunately, it appears the answer to the poster's question is &quot;It's not currently possible.&quot; Because Mac OS X (with developer tools) does allow getting and setting the create time from the command line, it may be possible to put together a vim script that does that, although that's (currently) beyond my vim scripting abilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I decided to play around with scripting something and actually got it to work!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following to your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPre * call SaveFileCreateTime()&#xA;autocmd BufWritePost * call RestoreFileCreateTime()&#xA;&#xA;function! SaveFileCreateTime()&#xA;    let l:path = expand('%:p')&#xA;&#xA;    if l:path != ''&#xA;        let b:created = system(&quot;GetFileInfo -d &quot; . shellescape(bufname(&quot;%&quot;)))&#xA;    endif&#xA;endfunction&#xA;&#xA;function! RestoreFileCreateTime()&#xA;    if exists('b:created')&#xA;        execute system(&#xA;          \ 'SetFile -d ' .&#xA;          \ shellescape(b:created) .&#xA;          \ ' ' .&#xA;          \ shellescape(bufname(&quot;%&quot;)))&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That sets auto commands to run before a file is read (for editing in a buffer, not for things like &lt;code&gt;:read&lt;/code&gt;) and after it's written. The first calls &lt;code&gt;SaveFileCreateTime&lt;/code&gt; which uses &lt;code&gt;GetFileInfo -d&lt;/code&gt; to get the file's create time and store it in the buffer local variable &lt;code&gt;b:created&lt;/code&gt;. After a file is written, &lt;code&gt;RestoreFileCreateTime&lt;/code&gt; is called. If &lt;code&gt;b:created&lt;/code&gt; exists, it's used in a &lt;code&gt;system&lt;/code&gt; command to use &lt;code&gt;SetFile -d&lt;/code&gt; to set the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo hello &amp;gt;file.txt&#xA;$ stat -c%z file.txt;GetFileInfo -d file.txt&#xA;2015-11-07 11:44:04.000000000 -0800&#xA;11/07/2015 11:44:04&#xA;$ vim file.txt&#xA;a earth&amp;lt;esc&amp;gt;:wq&#xA;$ cat file.txt&#xA;hello earth&#xA;$ stat -c%z file.txt;GetFileInfo -d file.txt&#xA;2015-11-07 11:44:24.000000000 -0800&#xA;11/07/2015 11:44:04&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see the inode change time (as displayed by &lt;code&gt;stat&lt;/code&gt;) has changed, but the file create time (as displayed by &lt;code&gt;GetFileInfo&lt;/code&gt;) hasn't. Success!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As noted above, this requires the developer tools to be installed to get GetFileInfo and SetFile. Also, this is my first real script, so feel free to point out all the hideous errors I've made!&lt;/p&gt;&#xA;" OwnerUserId="4620" LastEditorUserId="4620" LastEditDate="2015-11-07T19:49:40.033" LastActivityDate="2015-11-07T19:49:40.033" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="5395" PostTypeId="2" ParentId="5371" CreationDate="2015-11-07T20:54:05.967" Score="6" Body="&lt;p&gt;Your last &lt;a href=&quot;https://vi.stackexchange.com/questions/5371/vim-lost-custom-highlight-settings-after-recovering-from-sessions#comment8261_5371&quot;&gt;comment&lt;/a&gt; says that your default colorscheme is sourced twice : once before your custom highlight groups, and once after.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second time it's loaded, your custom highlight groups must be overwritten.&#xA;I think the reason why your default theme is loaded a second time when you source your &lt;a href=&quot;https://gist.github.com/tamlok/89d124e70839c333f729&quot; rel=&quot;noreferrer&quot;&gt;Session.vim&lt;/a&gt;, is because the latter includes this line (83) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=dark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h 'background'&lt;/code&gt; says :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When a color scheme is loaded (the &quot;g:colors_name&quot; variable is set)&#xA;  setting 'background' will cause the color scheme to be reloaded.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I suppose that when the &lt;code&gt;set background=dark&lt;/code&gt; from your Session.vim is executed, your default theme is reloaded but not your custom colors because they are defined in a different place (your vimrc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if it will work, but here are a few suggestions you could try :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Delete this line from your Session.vim. This should solve the issue&#xA;now, but you will have to do it again every time you create a new&#xA;session with the &lt;code&gt;:mksession&lt;/code&gt; command.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Change the value of the &lt;code&gt;sessionoptions&lt;/code&gt; option.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment you say&#xA;it's &lt;code&gt;blank,buffers,curdir,folds,help,options,tabpages,winsize&lt;/code&gt;.&lt;br&gt;&#xA;The &lt;code&gt;options&lt;/code&gt; part is responsible for saving options (including the&#xA;&lt;code&gt;background&lt;/code&gt; one) and mappings.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use the following command before&#xA;saving the session or include it inside your vimrc : &lt;code&gt;set sessionoptions-=options&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a result, your &lt;code&gt;sessionsoptions&lt;/code&gt; value will be&#xA;&lt;code&gt;blank,buffers,curdir,folds,help,tabpages,winsize&lt;/code&gt; and your options&#xA;will not be saved anymore.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Write your custom highlight groups into a dedicated file (let's say custom_colors.vim) and then, inside your vimrc, add an autocmd that automatically source this file at the end of the startup. For example, something like this :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd VimEnter * source /path/to/custom_colors.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this file should be sourced after Session.vim, its settings should not be overwritten.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here I used the &lt;code&gt;VimEnter&lt;/code&gt; event but you could also try the &lt;code&gt;SessionLoadPost&lt;/code&gt; event :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd SessionLoadPost * source /path/to/custom_colors.vim&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-08T01:30:57.213" LastActivityDate="2015-11-08T01:30:57.213" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5396" PostTypeId="2" ParentId="5393" CreationDate="2015-11-07T21:16:53.187" Score="4" Body="&lt;p&gt;I managed to install it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I did was install python for neovim using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pip install neovim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The next thing I did was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PlugInstall YouCompleteMe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from within neovim and it started installing as it normally does (if you have all the usual YCM dependencies installed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .nvimrc still had the section for YCM in it and I guess vim-plug still uses those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;I don't understand why YCM gets installed to the old vim plugins folder (/.vim) instead of neovim's folder (well I do, because I specified it, but shouldn't neovim install plugins to it's own folder structure? I thought it would be smart enough..) Is it even a good idea to be sharing folder hierarchies like that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I had in my .nvimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;&#xA;&quot; Make sure you use single quotes&#xA;Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }&#xA;&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5214" LastEditorUserId="5214" LastEditDate="2015-11-07T21:49:06.080" LastActivityDate="2015-11-07T21:49:06.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5397" PostTypeId="1" CreationDate="2015-11-07T21:19:36.740" Score="4" ViewCount="1100" Body="&lt;p&gt;Makefiles can have commands such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BAR = $(subst ', '\'', $(FOO))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the first argument to &lt;code&gt;subst&lt;/code&gt; is a &lt;strong&gt;single&lt;/strong&gt; &lt;em&gt;single quote&lt;/em&gt; resulting in for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FOO = some ' single ' quotes&#xA;BAR = $(subst ', '\'', $(FOO))&#xA;@echo &quot;$(BAR)&quot;&#xA;&#xA;some '\'' single '\'' quotes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Same goes for &lt;strong&gt;single&lt;/strong&gt; &lt;em&gt;double quotes&lt;/em&gt; as well as things like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BAR = $(subst &quot;, \&quot;, $(FOO))&#xA;BAR = &quot;$(subst &quot;, \&quot;, $(FOO))&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;make.vim&lt;/code&gt; syntax file matches single quoted strings by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region  makeSString start=+\(\\\)\@&amp;lt;!'+  skip=+\\.+  end=+'+  contains=makeIdent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/usr/share/vim/vim74/syntax/make.vim&lt;/code&gt; or the like.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But this does not match single standalone quotes, and the syntax comes out of sync and one get a mess on the lines following.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I am not fluent in syn commands. As a quick hack I have added the file &lt;code&gt;.vim/after/syntax/make.vim&lt;/code&gt; with the contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region makeQarg start=#&quot;\?\$(subst\s\+\(['&quot;]\)\@=#hs=e+1 end=+['&quot;]+&#xA;hi def link makeQarg Exception&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Use &lt;code&gt;Error&lt;/code&gt; or the like for &lt;em&gt;hi def link&lt;/em&gt; if you want to twiddle.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is not a fix. One issue is that the &lt;em&gt;keyword&lt;/em&gt; &lt;code&gt;subst&lt;/code&gt; and the leading &lt;code&gt;$(&lt;/code&gt; also becomes a part of the match and thus one loose the syntax for that. Not a huge deal, but still.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on a fix?&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2015-11-09T16:00:19.713" LastActivityDate="2015-11-09T16:00:19.713" Title="Syntax highlight single - quote parameter" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5398" PostTypeId="1" AcceptedAnswerId="5408" CreationDate="2015-11-07T21:31:59.397" Score="8" ViewCount="1543" Body="&lt;p&gt;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 &quot;clean&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! foo()&#xA;    (...)&#xA;    let v:errmsg = 'ok'&#xA;    execute &quot;silent! normal! :/&quot; . l:pattern . &quot;\r&quot;&#xA;    if v:errmsg == 'ok'&#xA;        (... do stuff ...)&#xA;    else&#xA;        (... do other stuff ...)&#xA;    endif&#xA; endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The question is: can the same result be achieved somewhow without the clunky use of &lt;strong&gt;v:errmsg&lt;/strong&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have in mind is something of the form&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! foo()&#xA;   (...)&#xA;   if GrepInCurrentBuffer(l:pattern)&#xA;      (... do stuff ...)&#xA;   (...etc...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2058" LastActivityDate="2015-11-08T21:52:31.470" Title="vimscript conditional based on grep on current buffer" Tags="|vimscript|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5399" PostTypeId="1" AcceptedAnswerId="5400" CreationDate="2015-11-08T03:27:57.843" Score="1" ViewCount="359" Body="&lt;p&gt;I've read that blowfish2 encryption is available on VIM 7.4.399. For some reason, my version—7.4.52—does not have blowfish2 capabilities (it has blowfish capabilities, though). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used &lt;code&gt;sudo apt install vim-gnome&lt;/code&gt; to install VIM. Is there a vimball or something of the sort I can use to enable blowfish2?&lt;/p&gt;&#xA;" OwnerUserId="4675" LastEditorUserId="51" LastEditDate="2015-11-08T07:07:55.360" LastActivityDate="2015-11-08T07:07:55.360" Title="Enabling or installing blowfish2 capabilities on VIM 7.4.52" Tags="|installing|security|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5400" PostTypeId="2" ParentId="5399" CreationDate="2015-11-08T04:18:24.893" Score="1" Body="&lt;p&gt;Since the command you mention includes &lt;code&gt;apt&lt;/code&gt; I suppose you're on debian or a linux distribution based on it (ubuntu, mint).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked on ubuntu's website and found a &lt;a href=&quot;http://packages.ubuntu.com/trusty/vim-gnome&quot; rel=&quot;nofollow&quot;&gt;vim-gnome&lt;/a&gt; package for the latest LTS (14.04).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its version is 7.4.052 which is not enough if blowfish2 support was added in version 7.4.399.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're on ubuntu 14.04, to install a more recent version of vim-gnome, you could add &lt;a href=&quot;https://launchpad.net/~pi-rho/+archive/ubuntu/dev&quot; rel=&quot;nofollow&quot;&gt;this ppa&lt;/a&gt; to the list of your repositories :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo add-apt-repository ppa:pi-rho/dev&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then update and upgrade.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The latest version of vim-gnome from this ppa is 7.4.899, which should be enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since there are different versions of vim, with different features (vim-tiny, vim-gnome ...), you could also check that you're calling the desired version by typing :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo update-alternatives --config vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-08T04:38:14.370" LastActivityDate="2015-11-08T04:38:14.370" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5401" PostTypeId="1" AcceptedAnswerId="5405" CreationDate="2015-11-08T05:31:05.460" Score="4" ViewCount="7934" Body="&lt;p&gt;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:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaaaaaaa&#xA;aaaaaaaa&#xA;aaaaaaaa&#xA;aaaaaaaa&#xA;aaaaaaaa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the following block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bbbbbbbb&#xA;bbbbbbbb&#xA;bbbbbbbb&#xA;bbbbbbbb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to merge them thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaaaaaaabbbbbbbb&#xA;aaaaaaaabbbbbbbb&#xA;aaaaaaaabbbbbbbb&#xA;aaaaaaaabbbbbbbb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't copy line by line because there are many lines in both files and they could be different. &lt;/p&gt;&#xA;" OwnerUserId="5222" LastActivityDate="2015-11-09T03:32:42.383" Title="Copy and pasting blocks of text anywhere" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5403" PostTypeId="2" ParentId="2877" CreationDate="2015-11-08T07:11:12.503" Score="0" Body="&lt;h3&gt;2021 Update&lt;/h3&gt;&#xA;&lt;p&gt;Later versions of Vim and NeoVim now have terminal support built-in. Use the &lt;code&gt;:term(inal)&lt;/code&gt; command to open a new terminal.&lt;/p&gt;&#xA;&lt;h3&gt;Original Answer&lt;/h3&gt;&#xA;&lt;p&gt;I highly recommend &lt;a href=&quot;https://github.com/Shougo/vimshell.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Shougo/vimshell.vim&lt;/a&gt; for this purpose.&lt;/p&gt;&#xA;&lt;p&gt;Its a vim plugin that allows you to run a terminal within vim. You can open the terminal in a new tab with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:VimShellTab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or quickfix window with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:VimShellPop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then you can run commands as usual, i.e.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;node&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5223" LastEditorUserId="28" LastEditDate="2021-03-01T16:24:20.287" LastActivityDate="2021-03-01T16:24:20.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5404" PostTypeId="2" ParentId="5388" CreationDate="2015-11-08T12:26:03.043" Score="5" Body="&lt;p&gt;The &lt;code&gt;@&lt;/code&gt; character in &lt;code&gt;iskeyword&lt;/code&gt; includes all characters for which &lt;code&gt;isalpha()&lt;/code&gt; (C function) is TRUE; in modern (last 20 years) libc implementations this also looks for unicode characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your second &lt;code&gt;iskeyword&lt;/code&gt; uses &lt;code&gt;97-122&lt;/code&gt; (a-z) and &lt;code&gt;64-90&lt;/code&gt; (A-Z), which doesn't include all the variants with the various diacritics (such as the umlaut/diaeresis/trema).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the solution is to replace &lt;code&gt;97-122&lt;/code&gt; and &lt;code&gt;64-90&lt;/code&gt; with &lt;code&gt;@&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This funky &lt;code&gt;iskeyword&lt;/code&gt; comes from the LISP syntax file; the &lt;code&gt;rst&lt;/code&gt; syntax file includes a bunch of other syntax files for highlighting the code blocks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Luckily you can set which languages to include with the &lt;code&gt;g:rst_syntax_code_list&lt;/code&gt; variable. The default is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:rst_syntax_code_list = ['vim', 'java', 'cpp', 'lisp', 'php', 'python', 'perl']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since it's unlikely that you need LISP syntax highlighting in your reStructuredText file, you can probably just remove it. Just add it anywhere in your vimrc file, if it's defined, the syntax file will use that value instead of defining its own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion, you probably want to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:rst_syntax_code_list = []&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because who knows what funky side-effects the other syntax files cause...&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-11-08T12:26:03.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5405" PostTypeId="2" ParentId="5401" CreationDate="2015-11-08T16:20:40.700" Score="5" Body="&lt;p&gt;Select all 'bbbb..' text using &lt;code&gt;Ctrl-V&lt;/code&gt; (visual block selection mode), yank; then go to the last char of the first &lt;code&gt;aaaa...&lt;/code&gt; string, hit &lt;code&gt;Ctrl-V&lt;/code&gt; again; go down to the last &lt;code&gt;aaaa ...&lt;/code&gt; string, while staying in the same column (so cursor is still on the last &lt;code&gt;a&lt;/code&gt; character). You are still in block selection mode. Hit 'p' to paste.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-11-08T20:24:44.413" LastActivityDate="2015-11-08T20:24:44.413" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5406" PostTypeId="1" AcceptedAnswerId="5407" CreationDate="2015-11-08T17:08:44.930" Score="4" ViewCount="337" Body="&lt;p&gt;When I open a file with &lt;code&gt;.md&lt;/code&gt; extension, the filetype is set to &lt;code&gt;markdown&lt;/code&gt;, as expected. But the &lt;code&gt;ftplugin&lt;/code&gt; 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 &lt;code&gt;ftplugin/markdown.vim&lt;/code&gt; and found this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim&#xA;&#xA;setlocal comments=fb:*,fb:-,fb:+,n:&amp;gt; commentstring=&amp;gt;\ %s&#xA;setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o&#xA;setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+&#xA;&#xA;if exists('b:undo_ftplugin')&#xA;  let b:undo_ftplugin .= &quot;|setl cms&amp;lt; com&amp;lt; fo&amp;lt; flp&amp;lt;&quot;&#xA;else&#xA;  let b:undo_ftplugin = &quot;setl cms&amp;lt; com&amp;lt; fo&amp;lt; flp&amp;lt;&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, I already commented out the first line. But vim still loads the html plugin. How can I influence this behaviour?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastEditorUserId="1066" LastEditDate="2015-11-08T17:16:59.940" LastActivityDate="2016-06-21T06:47:02.287" Title="Why does Vim load unrelated ftplugins?" Tags="|filetype|plugin-system|filetype-html|filetype-markdown|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="5407" PostTypeId="2" ParentId="5406" CreationDate="2015-11-08T18:40:03.707" Score="6" Body="&lt;p&gt;Vim already comes with Markdown support so what happens is that you have two Markdown ftplugins doing the same thing. Since you &quot;fixed&quot; one (&lt;code&gt;~/.vim/ftplugin/markdown.vim&lt;/code&gt;) without &quot;fixing&quot; the other (&lt;code&gt;$VIMRUNTIME/ftplugin/markdown.vim&lt;/code&gt;), your fix is simply overridden by the built-in ftplugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you insist on disabling HTML support in markdown buffers you can simply &quot;fix&quot; the built-in ftplugin (and probably get rid of the extraneous one) but I'd suggest you reconsider your strategy. HTML is valid Markdown so yeah, HTML has its place in Markdown.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-11-08T18:40:03.707" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5408" PostTypeId="2" ParentId="5398" CreationDate="2015-11-08T18:47:50.383" Score="8" Body="&lt;p&gt;The function you are looking for is &lt;code&gt;search()&lt;/code&gt;.  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 &lt;code&gt;'ignorecase'&lt;/code&gt;, &lt;code&gt;'smartcase'&lt;/code&gt;, and &lt;code&gt;'magic'&lt;/code&gt; options are used on the search pattern.  Note that if you want to choose where the search starts at, you can use the &lt;code&gt;cursor()&lt;/code&gt; or the &lt;code&gt;setpos()&lt;/code&gt; function to set the cursor position, and the &lt;code&gt;getcurpos()&lt;/code&gt; function to save the cursor location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example of it in action:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SearchInRange(pattern, start_line, end_line)&#xA;    &quot; Save cursor position.&#xA;    let save_cursor = getcurpos()&#xA;&#xA;    &quot; Set cursor position to beginning of file.&#xA;    call cursor(a:start_line, 0)&#xA;&#xA;    &quot; Search for the string 'hello' with a flag c.  The c flag means that a&#xA;    &quot; match at the cursor position will be accepted.&#xA;    let search_result = search(pattern, &quot;c&quot;, a:end_line)&#xA;&#xA;    &quot; Set the cursor back at the saved position.  The setpos function was&#xA;    &quot; used here because the return value of getcurpos can be used directly&#xA;    &quot; with it, unlike the cursor function.&#xA;    call setpos('.', save_cursor)&#xA;&#xA;    &quot; If the search function didn't find the pattern, it will have&#xA;    &quot; returned 0, thus it wasn't found.  Any other number means that an instance&#xA;    &quot; has been found.&#xA;    return search_result ? 1 : 0&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more on the things mentioned in this answer, see the following help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help search()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'ignorecase'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'smartcase'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'magic'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help cursor()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help setpos()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getcurpos()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-11-08T21:25:42.253" LastActivityDate="2015-11-08T21:25:42.253" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5409" PostTypeId="1" AcceptedAnswerId="5419" CreationDate="2015-11-08T21:03:42.930" Score="3" ViewCount="848" Body="&lt;p&gt;I'm writing a helpfile for a plugin, i.e. a &lt;code&gt;foo.txt&lt;/code&gt;  file that goes in the plugin's &lt;code&gt;doc/&lt;/code&gt; directory. At the bottom of that file I placed the following modeline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim: tw=70 ft=help fdm=marker fmr={{{,}}} fdl=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now here's the problem:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When opened directly with &lt;code&gt;vim foo.txt&lt;/code&gt;, the file is displayed with the correct foldlevel of 0 (folds delimited by markers are closed), which means the modeline was correctly interpreted.&lt;/li&gt;&#xA;&lt;li&gt;When opened as a help file within vim as &lt;code&gt;:help foo&lt;/code&gt;, the file is displayed with folds opened, which means the modeline was &lt;em&gt;not&lt;/em&gt; correctly interpreted.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So the question is: how do I get the folds to appear initialy closed when the helpfile is opened with &lt;code&gt;:help&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it even possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the problem can be tested (and hopefully reproduced) by copying&#xA;the following code to e.g. &lt;code&gt;~/.vim/doc/foo.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*foo*&#xA;{{{&#xA;This line should appear initially folded&#xA;}}}&#xA;vim: tw=70 ft=help fdm=marker fmr={{{,}}} fdl=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then comparing what happens with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; vim ~/.vim/doc/foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; vim&#xA;:helptags ~/.vim/doc/&#xA;:help foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2058" LastEditorUserId="2058" LastEditDate="2015-11-08T23:14:41.997" LastActivityDate="2015-11-09T14:25:53.463" Title="Modeline folding not working on help file" Tags="|folding|help-system|modeline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5410" PostTypeId="2" ParentId="5346" CreationDate="2015-11-08T21:47:02.713" Score="4" Body="&lt;p&gt;Vim parses your &lt;code&gt;.vimrc&lt;/code&gt; once when it is started. Whenever you change something in it (in your case add a new plugin), vim needs to be told manually that something changed so that the &lt;code&gt;.vimrc&lt;/code&gt; gets parsed again. You do that by running &lt;code&gt;:source $MYVIMRC&lt;/code&gt;. I often shorten that to &lt;code&gt;:so %&lt;/code&gt; when my &lt;code&gt;.vimrc&lt;/code&gt; is opened (&lt;code&gt;%&lt;/code&gt; gets expanded to current file name).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After sourcing your &lt;code&gt;.vimrc&lt;/code&gt;, all saved changes are processed and should take effect, so you can run your &lt;code&gt;:PluginInstall&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, your &lt;code&gt;:PluginInstall&lt;/code&gt; command will only work if the &lt;code&gt;.vimrc&lt;/code&gt; was sourced. What you can do to save you doing this small step manually over and over again is to &lt;a href=&quot;http://www.bestofvim.com/tip/auto-reload-your-vimrc/&quot; rel=&quot;nofollow&quot;&gt;automate it&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup reload_vimrc &quot; {&#xA;    autocmd!&#xA;    autocmd BufWritePost $MYVIMRC source $MYVIMRC&#xA;augroup END &quot; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way, whenever you save changes to your &lt;code&gt;.vimrc&lt;/code&gt;, it gets sourced automatically.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2015-11-08T21:47:02.713" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5411" PostTypeId="2" ParentId="5398" CreationDate="2015-11-08T21:52:31.470" Score="4" Body="&lt;p&gt;For reference to anyone looking at this question in the future, here's a working solution following the same pattern as the pseudo-code in the question. It is completely based on &lt;strong&gt;VanLaser&lt;/strong&gt;'s comments to both the original question and EvergreenTree's answer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! foo()&#xA;    (... do stuff that defines l:pattern ...)&#xA;    if search(l:pattern,'nw')&#xA;        (... do stuff ...)&#xA;    else&#xA;        (... do other stuff ...)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the particular case of the actual function that originated this question, the solution did not really require the 'nw' flags. These flags should however make the solution safer in general, based on their description in vim's help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'n'     do Not move the cursor&#xA;'w'     wrap around the end of the file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(from &lt;code&gt;:help search&lt;/code&gt; in Vim 7.4)&lt;/p&gt;&#xA;" OwnerUserId="2058" LastActivityDate="2015-11-08T21:52:31.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5412" PostTypeId="2" ParentId="5401" CreationDate="2015-11-09T03:32:42.383" Score="3" Body="&lt;p&gt;Visual-block select (C-V) the text you want to prepend, then either yank/delete the text.  Go to the first line and character of the text you want to prepend to, then press P (upper case P).&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2015-11-09T03:32:42.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5413" PostTypeId="2" ParentId="5393" CreationDate="2015-11-09T06:51:48.313" Score="12" Body="&lt;p&gt;neovim version 0.1 has breaking changes.   It uses directory &lt;code&gt;~/.config/nvim&lt;/code&gt;&#xA;(On Mac OS X. Linux or Windows may use slightly different paths.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want your neovim configuration independent of vim configuration, &#xA;you can rename &lt;code&gt;.nvimrc&lt;/code&gt; to &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt; (See the docs &lt;a href=&quot;https://neovim.io/doc/user/vim_diff.html#nvim-configuration&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://neovim.io/doc/user/nvim_from_vim.html&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install vim-plug to &lt;code&gt;~/.config/nvim/autoload/plug.vim&lt;/code&gt;&lt;br&gt;&#xA;The directory tree looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.config&#xA;├── nvim&#xA;    ├── autoload&#xA;    │   └── plug.vim&#xA;    ├── init.vim&#xA;    └── plugged&#xA;        ├── YouCompleteMe&#xA;        ├── ctrlp.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In neovim when you run &lt;code&gt;:PlugInstall&lt;/code&gt;, vim-plug will install your plugins to the path you specified in &lt;code&gt;init.vim&lt;/code&gt;&lt;br&gt;&#xA;Use &lt;code&gt;.config/nvim/plugged&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; for vim&#xA;&quot; call plug#begin('~/.vim/plugged')&#xA;&quot; for neovim&#xA;call plug#begin('~/.config/nvim/plugged')&#xA;&quot; Keep Plug commands between plug#begin/end.&#xA;Plug 'https://github.com/Valloric/YouCompleteMe'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want neovim to use vim's plugin location, replace directory &lt;code&gt;.config/nvim&lt;/code&gt; with a symlink named &lt;code&gt;.config/nvim&lt;/code&gt; that points to &lt;code&gt;.vim&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ln -s ~/.vim ~/.config/nvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In .vim either add &lt;code&gt;init.vim&lt;/code&gt; similar to &lt;code&gt;.vimrc&lt;/code&gt;, or add symlink named &lt;code&gt;init.vim&lt;/code&gt; to point to &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ln -s ~/.vimrc ~/.vim/init.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use Homebrew to install neovim, at the end of the install it provides some helpful info about setting the symlinks: &lt;a href=&quot;https://github.com/neovim/homebrew-neovim&quot;&gt;https://github.com/neovim/homebrew-neovim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also many people create a git repo in a directory named &quot;dotfiles&quot; or similar to version control configuration files like &lt;code&gt;init.vim&lt;/code&gt; and &lt;code&gt;.vimrc&lt;/code&gt;. In other directories add symlinks to your dotfiles&lt;br&gt;&#xA;(e.g. &lt;code&gt;~/.config/neovim/init.vim&lt;/code&gt; could be symlinked to &lt;code&gt;~/dotfiles/init.vim&lt;/code&gt;)&lt;br&gt;&#xA;This is handy when setting up a new machine.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;YouCompleteMe&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As warsong mentioned&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pip install neovim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For C family language completion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.config/nvim/plugged/YouCompleteMe&#xA;./install.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot;&gt;https://github.com/Valloric/YouCompleteMe&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ran &lt;code&gt;install.py&lt;/code&gt; separately, hadn't seen nifty one-liner method  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5230" LastEditorUserId="51" LastEditDate="2015-11-09T10:32:18.293" LastActivityDate="2015-11-09T10:32:18.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5414" PostTypeId="2" ParentId="4906" CreationDate="2015-11-09T07:22:31.423" Score="2" Body="&lt;p&gt;This is pretty much the same question as &lt;a href=&quot;https://vi.stackexchange.com/q/564/51&quot;&gt;Prevent Vim from breaking up links mid-tag in markdown&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For TeX equations it's slightly more involved, but not too much. &#xA;We assume we're inside an equation if a line in the last 10 lines begins with &lt;code&gt;\begin{equation}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au CursorMovedI,CursorMoved *.tex let b:tex_textwidth = 80 | let b:tex_last_line = 0 | call ModifyTextWidth()&#xA;&#xA;fun! ModifyTextWidth()&#xA;        &quot; Only run if the cursor is on another line&#xA;        if line('.') == b:tex_last_line | return | endif&#xA;        let b:tex_last_line = line('.')&#xA;&#xA;        &quot; Try to find the start of an equation&#xA;        let l:eq = 0&#xA;        for i in range(1, 10)&#xA;                if getline(line('.') - i) =~ '^\\end{equation}' | break | endif&#xA;&#xA;                &quot; We're in an equation&#xA;                if getline(line('.') - i) =~ '^\\begin{equation}'&#xA;                        set textwidth=0&#xA;                        return&#xA;                endif&#xA;        endfor&#xA;&#xA;        &quot; Reset to original&#xA;        let &amp;amp;textwidth = b:tex_textwidth&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't extensively tested this, but it seems to work well with some samples I've found on the internet...&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-11-09T07:22:31.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5415" PostTypeId="1" CreationDate="2015-11-09T10:57:37.457" Score="1" ViewCount="410" Body="&lt;p&gt;I'm using &lt;code&gt;filetype indent on&lt;/code&gt; in my vimrc, generally this works very well, when pressing return it sets the indentation properly (in most cases).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However it has a very strange/annoying behavior, of re-indenting a line, when editing some text to that line.&#xA;eg, editing a &lt;code&gt;CMakeLists.txt&lt;/code&gt;, typing &lt;code&gt;endif(&lt;/code&gt; will re-indent the the line based on vims indentation logic (in other cases too, this is just an example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to enable &lt;code&gt;filetype indent&lt;/code&gt; when adding in new-lines, but not have it attempt to re-indent existing text while typing?&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2015-11-09T17:18:25.527" Title="How to use 'filetype indent on', without it indenting while entering text in insert mode" Tags="|vimrc|indentation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5416" PostTypeId="1" AcceptedAnswerId="5450" CreationDate="2015-11-09T11:23:34.830" Score="5" ViewCount="2507" Body="&lt;p&gt;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).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In theory, if both plugins are installed SuperTab should handle Jedi seamlessly, but that's not my case. I found &lt;a href=&quot;https://github.com/davidhalter/jedi-vim/issues/165&quot; rel=&quot;nofollow&quot;&gt;this report&lt;/a&gt; of some people experiencing the same behavior, while others saying it works for them. There is no solution provided though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugins I'm using don't override each other:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls ~/.vim/bundle/&#xA;auto-pairs  nerdtree  syntastic    vim-trailing-whitespace&#xA;jedi-vim    supertab  vim-airline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So what else may be causing this behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nu&#xA;set ts=4&#xA;set sw=4&#xA;set mouse=a&#xA;set showmatch&#xA;set expandtab&#xA;set background=dark&#xA;syntax on&#xA;filetype plugin indent on&#xA;&#xA;execute pathogen#infect()&#xA;&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user5235" LastEditorUserId="51" LastEditDate="2016-02-05T21:01:22.267" LastActivityDate="2016-02-05T21:01:22.267" Title="Can't get Jedi's autocompletion on SuperTab" Tags="|autocompletion|plugin-jedi-vim|plugin-supertab|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5417" PostTypeId="2" ParentId="5416" CreationDate="2015-11-09T11:38:30.293" Score="0" Body="&lt;p&gt;The default for SuperTab is to use &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; completion, vim-jedi, however, starts with &lt;code&gt;&amp;lt;C-Space&amp;gt;&lt;/code&gt;. You need to tell SuperTab that you want to use that ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can configure this with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:SuperTabDefaultCompletionType = '&amp;lt;C-@&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;@&lt;/code&gt; refers to the space. You may also want to set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:SuperTabMappingForward = '&amp;lt;C-@&amp;gt;'&#xA;let g:SuperTabMappingBackward = '&amp;lt;S-C-@&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is documented in &lt;code&gt;:help g:SuperTabDefaultCompletionType&lt;/code&gt;, &lt;code&gt;:help g:SuperTabMappingForward&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-11-09T11:38:30.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5418" PostTypeId="1" CreationDate="2015-11-09T13:43:52.183" Score="6" ViewCount="521" Body="&lt;p&gt;I have a language which uses statement like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WHILE ... DO&#xA;..&#xA;END_WHILE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can do the following in the corresponding synthax file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword LangKeys WHILE DO END_WHILE&#xA;syn region  LangBlock start=&quot;WHILE&quot; end=&quot;END_WHILE&quot; fold transparent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which allows me to highlight correctly the different keywords as well as defining a given region.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now, I would like to be sure that the DO is only highlighted &lt;strong&gt;in the context of the loop&lt;/strong&gt;. But I don't want to affect anything else. I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword LangKeys WHILE END_WHILE&#xA;syn keyword InsideKeys DO contained&#xA;syn region LangBlock start=&quot;WHILE&quot; end=&quot;END_WHILE&quot; fold transparent contained=InsideKeys&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;also without the &lt;code&gt;transparent&lt;/code&gt; option. I tried a few variations of that. But it does not produce the expected result. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I get the highlight to be applied only when the keywords are within a given context?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, is there a better way to handle that?&lt;/p&gt;&#xA;" OwnerUserId="2170" LastEditorUserId="15685" LastEditDate="2018-10-09T12:07:16.023" LastActivityDate="2018-10-09T12:07:16.023" Title="Syntax file: keywords within context" Tags="|syntax-highlighting|folding|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5419" PostTypeId="2" ParentId="5409" CreationDate="2015-11-09T14:25:53.463" Score="3" Body="&lt;p&gt;Vim treats help files special and resets some options beofre opening them. After trying your example, what seems to work is to add an explicit &lt;code&gt;:set foldenable&lt;/code&gt; to your modeline, e.g. this seems to work for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim: tw=70 ft=help fdm=marker fmr={{{,}}} fdl=0 fen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-11-09T14:25:53.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5420" PostTypeId="2" ParentId="4906" CreationDate="2015-11-09T14:31:02.093" Score="2" Body="&lt;p&gt;I have a similar &lt;a href=&quot;https://www.256bit.org/~chrisbra/cms/Z-files/format.vim.html&quot; rel=&quot;nofollow&quot;&gt;setup with respect for writing mails&lt;/a&gt;. The idea is, to check the cursor position and depending on the current position set some formatting options.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Dynamically set format options, depending on where you are in a&#xA;&quot; mail, idea from Teemu Likonen:&#xA;&quot; http://groups.google.com/group/vim_use/msg/f59e5c1adc6be2b3&#xA;&#xA;let d_fo = &amp;amp;fo&#xA;let s:defaults = 'setlocal tw=72 ts=8 sts=4 sw=4 fo='.d_fo&#xA;execute s:defaults&#xA;let b:MailAreaDetect=1&#xA;&#xA;&quot;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;LocalLeader&amp;gt;ma1 :call &amp;lt;SID&amp;gt;MailAreaDetect_On()&#xA;&quot;    \ &amp;lt;bar&amp;gt; echo 'MailAreaDetect On'&amp;lt;CR&amp;gt;&#xA;&quot;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;LocalLeader&amp;gt;ma0 :call &amp;lt;SID&amp;gt;MailAreaDetect_Off()&#xA;&quot;    \ &amp;lt;bar&amp;gt; echo 'MailAreaDetect Off'&amp;lt;CR&amp;gt;&#xA;&#xA;nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt; &amp;lt;F9&amp;gt; :call &amp;lt;SID&amp;gt;MailAreaDetect_Switch(0)&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt; &amp;lt;F9&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt;:call &amp;lt;SID&amp;gt;MailAreaDetect_Switch(1)&amp;lt;CR&amp;gt;&#xA;&#xA;function! s:MailAreaDetect_Switch(vmode)&#xA;    if b:MailAreaDetect&#xA;        silent call &amp;lt;SID&amp;gt;MailAreaDetect_Off()&#xA;        let b:MailAreaDetect=0&#xA;        echo 'MailAreaDetect Off'&#xA;        if a:vmode&#xA;            sleep 1&#xA;        endif&#xA;    else&#xA;        silent call &amp;lt;SID&amp;gt;MailAreaDetect_On()&#xA;        let b:MailAreaDetect=1&#xA;        echo 'MailAreaDetect On'&#xA;        if a:vmode&#xA;            sleep 1&#xA;        endif&#xA;    endif&#xA;endfu&#xA;&#xA;&#xA;function! s:MailAreaDetect_On()&#xA;    silent autocmd! MailAreaDetect CursorMoved,CursorMovedI&#xA;        \ &amp;lt;buffer&amp;gt; call &amp;lt;SID&amp;gt;AreaOptions()&#xA;    let b:MailAreaDetect=1&#xA;endfunction&#xA;&#xA;function! s:MailAreaDetect_Off()&#xA;    silent autocmd! MailAreaDetect&#xA;    execute s:defaults&#xA;    let b:MailAreaDetect=0&#xA;endfunction&#xA;&#xA;augroup MailAreaDetect&#xA;    autocmd!&#xA;    call &amp;lt;SID&amp;gt;MailAreaDetect_On()&#xA;augroup END&#xA;&#xA;function! s:AreaOptions()&#xA;    execute s:defaults&#xA;    if &amp;lt;SID&amp;gt;CheckArea('\v^From( |: ).*\n','\v^$')&#xA;        &quot;echo 'Header'&#xA;        setlocal fo-=a fo-=w fo-=t sts=0 sw=8 noet&#xA;    elseif getline('.') =~ '\m^\s*&amp;gt;'&#xA;        &quot;echo 'Quotation'&#xA;        setlocal fo-=a fo-=w&#xA;    elseif &amp;lt;SID&amp;gt;CheckArea('\m^--- .*\n^+++ ','\v(^$|\n^-- $)')&#xA;        &quot;echo 'Patch'&#xA;        setlocal fo-=a fo-=w fo-=t sts=0 sw=8 noet&#xA;    elseif &amp;lt;SID&amp;gt;CheckArea('^-- $','^$')&#xA;        &quot;echo 'Signature'&#xA;        setlocal fo-=a fo-=w fo-=t sts=0 sw=8 noet&#xA;    else&#xA;        &quot;echo 'My text'&#xA;        setlocal fo+=aw et&#xA;    endif&#xA;endfunction&#xA;&#xA;function! s:CheckArea(start, end)&#xA;    return (search(a:start,'bcnW')-line('.')) &amp;gt;&#xA;        \ (search(a:end,'bnW')-line('.'))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="51" LastEditDate="2015-11-09T15:18:42.447" LastActivityDate="2015-11-09T15:18:42.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5421" PostTypeId="1" AcceptedAnswerId="5422" CreationDate="2015-11-09T14:40:02.223" Score="7" ViewCount="795" Body="&lt;p&gt;VIM spell files seem to be in some binary format. Is it possible (and easy) to convert one back to a plain text word list?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="51" LastEditDate="2015-11-09T15:17:20.090" LastActivityDate="2015-11-09T15:17:20.090" Title="Converting .spl spell files" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5422" PostTypeId="2" ParentId="5421" CreationDate="2015-11-09T15:16:01.347" Score="8" Body="&lt;p&gt;Yes, you can use &lt;a href=&quot;http://vimhelp.appspot.com/spell.txt.html#%3aspelldump&quot;&gt;&lt;code&gt;:spelldump&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:spelld[ump]            Open a new window and fill it with all currently valid&#xA;                        words.  Compound words are not included.&#xA;                        Note: For some languages the result may be enormous,&#xA;                        causing Vim to run out of memory.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will use the language file that you set with the &lt;code&gt;'spelllang'&lt;/code&gt; option.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-11-09T15:16:01.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5423" PostTypeId="2" ParentId="5415" CreationDate="2015-11-09T17:18:25.527" Score="2" Body="&lt;p&gt;You can modify the indent behaviour through the option &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;indentkeys&amp;#39;&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;indentkeys&lt;/code&gt;&lt;/a&gt;. The docs explain things relatively well:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A list of keys that, when typed in Insert mode, cause reindenting of&#xA;      the current line.  Only happens if 'indentexpr' isn't empty.&#xA;      The format is identical to 'cinkeys', see |indentkeys-format|.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you do: &lt;code&gt;:echo &amp;amp;indentkeys&lt;/code&gt;, you will see that the filetype plugin for &lt;code&gt;cmake&lt;/code&gt; adds for instance &lt;code&gt;ENDIF(&lt;/code&gt;. Thus you might want to do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set indentkeys&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To reset the option to its default value. Note that this should come in &lt;code&gt;$VIM/after/ftplugin/cmake.vim&lt;/code&gt; (or similar) so that it is sourced after the regular filetype plugin.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-11-09T17:18:25.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5424" PostTypeId="2" ParentId="3001" CreationDate="2015-11-09T18:43:32.250" Score="4" Body="&lt;p&gt;You could simply &lt;code&gt;:set noro&lt;/code&gt; before doing the modification. This should prevent the warning.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-11-09T18:43:32.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5425" PostTypeId="1" AcceptedAnswerId="5428" CreationDate="2015-11-09T19:33:36.840" Score="11" ViewCount="623" Body="&lt;p&gt;Is it possible to pipe an unsaved buffer to an external command and then replace the buffer by the command’s output? &lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2015-11-10T07:44:16.733" Title="External command on unsaved buffer" Tags="|external-command|" AnswerCount="2" CommentCount="0" ClosedDate="2015-12-17T13:54:27.023" ContentLicense="CC BY-SA 3.0" />
  <row Id="5426" PostTypeId="2" ParentId="5425" CreationDate="2015-11-09T19:42:31.330" Score="1" Body="&lt;p&gt;Yes that should be possible. One possibility: the &lt;code&gt;system()&lt;/code&gt; function takes as optional argument the input to be used for the external command. &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-11-09T19:42:31.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5427" PostTypeId="2" ParentId="4245" CreationDate="2015-11-09T19:44:27.013" Score="3" Body="&lt;p&gt;This is not possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the &lt;code&gt;-w&lt;/code&gt; or &lt;code&gt;-W&lt;/code&gt; flags are given, Vim will set the &lt;code&gt;scriptout&lt;/code&gt; variable to a filehandle (&lt;code&gt;main.c&lt;/code&gt;, &lt;code&gt;command_line_scan()&lt;/code&gt;, around line 2374). This variable is referenced in only 2 other places; &lt;code&gt;getchar.c&lt;/code&gt; for writing to the file, and &lt;code&gt;message.c&lt;/code&gt;, to work around a problem which causes a character to be recorded twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only viable options I see are either a shell alias, or a wrapper script which calls Vim with the &lt;code&gt;-w&lt;/code&gt; flags.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="1821" LastEditDate="2016-06-03T17:32:42.320" LastActivityDate="2016-06-03T17:32:42.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5428" PostTypeId="2" ParentId="5425" CreationDate="2015-11-09T19:52:11.927" Score="11" Body="&lt;p&gt;You can use the &quot;filter&quot; command,&lt;code&gt;:!&lt;/code&gt;, which like most commands can be prefixed with a range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:{range}!cmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;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 &lt;code&gt;%&lt;/code&gt; as the range, which means the entire buffer. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!sort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find the Vim documentation with &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3arange%21&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :range!&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2015-11-10T07:44:16.733" LastActivityDate="2015-11-10T07:44:16.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5429" PostTypeId="2" ParentId="5056" CreationDate="2015-11-10T00:36:31.990" Score="2" Body="&lt;p&gt;Put the function in a file with the same name as your session file but ending in &lt;code&gt;x.vim&lt;/code&gt; as described in item 10 under&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help mks&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-11-10T00:36:31.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5431" PostTypeId="1" CreationDate="2015-11-10T13:51:19.837" Score="1" ViewCount="641" Body="&lt;p&gt;Hello I blew my MacOSX PC away and started fresh.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did a &lt;code&gt;git init&lt;/code&gt; on my laptop's vim directory and installed all the appropriate plugins/bundle using pathogen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now my issue is, when I &lt;code&gt;git add -A&lt;/code&gt; every under .vim and then committed everything and pushed it to &lt;strong&gt;github&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is NOT everything under &lt;strong&gt;.vim/&lt;/strong&gt; directory got commit and pushed up into github. In particular the stuff under the &lt;strong&gt;bundle/&lt;/strong&gt; directory (which are the most important things).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The directory themselves under bundle are push to github but they are &lt;strong&gt;all empty&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I add all of them into github without having to go and resort to doing it one by one in each folder? (some of these are already under source control from their original authors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I move around machines a lot sometimes, so it would be handy to know. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2129" LastEditorUserId="2129" LastEditDate="2015-11-10T14:02:53.110" LastActivityDate="2015-11-10T14:02:53.110" Title="How can I add everything under .vim directory into github?" Tags="|git|" AnswerCount="0" CommentCount="5" ClosedDate="2015-11-10T14:14:56.837" ContentLicense="CC BY-SA 3.0" />
  <row Id="5433" PostTypeId="2" ParentId="5418" CreationDate="2015-11-10T14:32:54.127" Score="1" Body="&lt;p&gt;The difference isn't so large, but the following seems to be working&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword LangKeys   contained WHILE END_WHILE&#xA;syn keyword InsideKeys contained DO&#xA;syn region  LangBlock  fold transparent &#xA;        \ matchgroup=LangKeys &#xA;        \ start=&quot;\&amp;lt;WHILE\_s&quot; end=&quot;\&amp;lt;END_WHILE\&amp;gt;&quot; &#xA;        \ contains=InsideKeys&#xA;hi def link LangKeys   Statement&#xA;hi def link InsideKeys Statement&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way, a &lt;code&gt;DO&lt;/code&gt; inside the &lt;code&gt;WHILE&lt;/code&gt; group will be highlighted but not separated.&lt;/p&gt;&#xA;" OwnerUserId="2170" LastActivityDate="2015-11-10T14:32:54.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5434" PostTypeId="1" CreationDate="2015-11-10T21:18:26.213" Score="5" ViewCount="1427" Body="&lt;p&gt;Some languages have flow control or loop structures that require a few words, for example, shell has&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [...]&#xA;then&#xA;  ...&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use the syntax highlighting features of vim to indicate that there is an error, if, for example a &lt;code&gt;fi&lt;/code&gt; is detected before a &lt;code&gt;then&lt;/code&gt;? And if it is, how to do it for that example?&lt;/p&gt;&#xA;" OwnerUserId="2170" LastActivityDate="2015-11-10T22:06:46.977" Title="Code syntax checking using highlighting" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5435" PostTypeId="2" ParentId="5434" CreationDate="2015-11-10T22:06:46.977" Score="5" Body="&lt;p&gt;With some languages, the syntax highlighting can show an error, if the syntax rules define them. For example, the C syntax definition in my system includes an error for invalid octal numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match   cOctalError display contained &quot;0\o*[89]\d*&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kVji2.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kVji2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or in shell scripts, an unmatched &lt;code&gt;fi&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qC89L.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qC89L.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More commonly, this is achieved via syntax checking plugins which show messages. For example, &lt;a href=&quot;https://github.com/scrooloose/syntastic&quot; rel=&quot;noreferrer&quot;&gt;the syntastic plugin&lt;/a&gt; can indicate lines with errors, and the error message given by the program used to check the syntax:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qCjHj.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qCjHj.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Admittedly, the error is a bit cryptic, and in some cases, can be quite long-winded. But with a bit of practice, this will help you spot errors quickly enough.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-11-10T22:06:46.977" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5436" PostTypeId="1" AcceptedAnswerId="5437" CreationDate="2015-11-10T23:30:23.943" Score="17" ViewCount="5917" Body="&lt;p&gt;I am editing a .sql file in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;INSERT INTO apps_forms (app_id, form_id) VALUES&#xA;(1, 1),&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'm looking to do is yank the &lt;code&gt;(1, 1),&lt;/code&gt; line and paste it 137 times; however, I want the &lt;em&gt;second&lt;/em&gt; number in parenthesis to be incremented each time. The output would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;INSERT INTO apps_forms (app_id, form_id) VALUES&#xA;(1, 1),&#xA;(1, 2),&#xA;(1, 3),&#xA;...&#xA;(1, 137),&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do that in Vim and, if so, what command would I use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="5251" LastActivityDate="2019-12-08T18:17:14.450" Title="Yanking and pasting while incrementing" Tags="|cut-copy-paste|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5437" PostTypeId="2" ParentId="5436" CreationDate="2015-11-10T23:42:06.390" Score="15" Body="&lt;p&gt;Put your cursor on the &lt;code&gt;(1, 1),&lt;/code&gt; line then type :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qaVypt)&amp;lt;C-a&amp;gt;q135@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;qa&lt;/code&gt; begins the recording of a macro inside the register &lt;strong&gt;a&lt;/strong&gt; (you could choose another letter).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Vyp&lt;/code&gt; duplicates the current line, by selecting the whole line (V), copying it (y) and then pasting it below (p).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;t)&lt;/code&gt; move the cursor just before the next closed parenthesis, so that it's on the second number.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; (&lt;kbd&gt;Ctrl&lt;/kbd&gt; and &lt;kbd&gt;a&lt;/kbd&gt;) increments the number.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;q&lt;/code&gt; ends the recording of the macro.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;135@a&lt;/code&gt; replays the macro stored in the register &lt;strong&gt;a&lt;/strong&gt; 135 times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit : &lt;a href=&quot;https://vi.stackexchange.com/questions/5436/yanking-and-pasting-while-incrementing/5437#comment8342_5437&quot;&gt;Peter Rincker&lt;/a&gt; has a shorter command :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqYpW&amp;lt;c-a&amp;gt;q135@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The differences are :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it uses the register &lt;strong&gt;q&lt;/strong&gt; to store the macro (faster to type &lt;code&gt;qq&lt;/code&gt; than &lt;code&gt;qa&lt;/code&gt; because it's the same key),&lt;br&gt;&#xA;it copies the line with only one keystroke &lt;code&gt;Y&lt;/code&gt; (instead of two &lt;code&gt;Vy&lt;/code&gt;),&lt;br&gt;&#xA;and it moves the cursor to the second number with only one keystroke &lt;code&gt;W&lt;/code&gt; (instead of &lt;code&gt;t)&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-11T00:43:55.560" LastActivityDate="2015-11-11T00:43:55.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5438" PostTypeId="2" ParentId="5436" CreationDate="2015-11-11T05:58:19.997" Score="2" Body="&lt;p&gt;The easy to understand / easy to remember / easy to adapt to other situations way to do it: use the &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#VISINCR&quot; rel=&quot;nofollow&quot;&gt;VisIncr&lt;/a&gt; plugin (if you'd rather use a version that actually plays nice with the package managers from this century as opposed to dealing with &lt;code&gt;vimball&lt;/code&gt;s, you can get it from &lt;a href=&quot;https://github.com/vim-scripts/VisIncr&quot; rel=&quot;nofollow&quot;&gt;GitHub&lt;/a&gt;).  With it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;go to the &lt;code&gt;(1, 1),&lt;/code&gt; line and yank it: &lt;code&gt;Vy&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;paste it 136 times: &lt;code&gt;136p&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;go to the second column of &lt;code&gt;1&lt;/code&gt; and mark it vertically: &lt;code&gt;C-vGf)h&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;run the increment: &lt;code&gt;:II&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;read the manual to find out about the other goodies: &lt;code&gt;:help visincr&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="2313" LastEditDate="2015-11-11T06:10:25.517" LastActivityDate="2015-11-11T06:10:25.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5439" PostTypeId="1" AcceptedAnswerId="5556" CreationDate="2015-11-11T06:05:17.433" Score="5" ViewCount="690" Body="&lt;p&gt;When my cursor is on a URL that ends with a trailing slash, for example : &lt;code&gt;http://www.google.com/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... if I type &lt;code&gt;gx&lt;/code&gt; 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 (&quot;&lt;a href=&quot;http://www.google.com&quot; rel=&quot;nofollow&quot;&gt;http://www.google.com&lt;/a&gt;&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to tell vim to only send the URL to the browser and not download the webpage ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if it's related but I've set up the values of 2 global variables in my vimrc :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_gx=&quot;&amp;lt;cWORD&amp;gt;&quot;&#xA;let g:netrw_browsex_viewer=&quot;xdg-open&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one is to prevent vim from sending only a part of the URL when it contains a &lt;code&gt;?&lt;/code&gt; or &lt;code&gt;#&lt;/code&gt;.&lt;br&gt;&#xA;The second one is to call a default program on my linux system when the cursor is on the path to a local file (instead of a web URL).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vim 7.4.899 and here's the &lt;a href=&quot;https://paste.debian.net/331185/&quot; rel=&quot;nofollow&quot;&gt;output&lt;/a&gt; of &lt;code&gt;vim --version&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-11T07:53:47.820" LastActivityDate="2017-12-13T17:41:45.037" Title="Why does gx call curl when the cursor is on a URL with trailing slash?" Tags="|buffers|external-command|netrw|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5440" PostTypeId="2" ParentId="5436" CreationDate="2015-11-11T07:17:58.457" Score="12" Body="&lt;p&gt;Recent Vims have learned about incrementing visual selected regions as well as creating a sequence. So you can do this after pasting your line 137 times:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) visually block-select (&lt;kbd&gt;Ctrl-V&lt;/kbd&gt;) the second 1 starting from line 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) press &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;Ctrl-A&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have recorded a screen cast &lt;a href=&quot;https://www.256bit.org/~chrisbra/Vim_Recording_20151109.mkv&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclaimer: This needs a Vim 7.4.900 or so.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="16706" LastEditDate="2019-12-08T18:17:14.450" LastActivityDate="2019-12-08T18:17:14.450" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5441" PostTypeId="1" AcceptedAnswerId="5443" CreationDate="2015-11-11T08:46:02.360" Score="39" ViewCount="14109" Body="&lt;p&gt;As per the title, is it possible to split the &lt;code&gt;vimrc&lt;/code&gt; file in several sub-files?  Keep separate files for groups of settings that concern one &lt;strong&gt;&lt;em&gt;thing&lt;/em&gt;&lt;/strong&gt;?  This &lt;em&gt;thing&lt;/em&gt; might be anything, any kind of user-defined group of settings. For example,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[updated]&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;keep all &lt;em&gt;Python(-mode)&lt;/em&gt; related settings in &lt;code&gt;vimrc.python-mode&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;keep settings for the Calendar utility for vim in &lt;code&gt;vimrc.calendar&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;keep color setting in a separate file?&lt;/li&gt;&#xA;&lt;li&gt;keep &lt;em&gt;mappings&lt;/em&gt; (aka shortcuts?) in a separate file?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1963" LastEditorUserId="51" LastEditDate="2017-04-24T12:34:32.553" LastActivityDate="2020-11-16T19:11:55.800" Title="Is it possible and useful to split vimrc?" Tags="|vimrc|filetype|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5442" PostTypeId="1" CreationDate="2015-11-11T08:53:04.747" Score="2" ViewCount="145" Body="&lt;p&gt;I just installed haskell-vim-now from this site ( &lt;a href=&quot;https://github.com/begriffs/haskell-vim-now&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; ) but when I launch vim and I enter text, such as an hello world haskell example, no code colors are displayed, nor completion : I wonder if something has really been installed (althought the haskell-vim-now seems to have been installed without errors)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe I forgot something, but I can't see what.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks.&lt;/p&gt;&#xA;" OwnerUserId="5255" LastActivityDate="2015-12-12T15:08:55.223" Title="ubuntu &amp; haskell : problem with haskell-vim-now" Tags="|linux|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5443" PostTypeId="2" ParentId="5441" CreationDate="2015-11-11T09:13:27.307" Score="35" Body="&lt;p&gt;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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to enable this in your &lt;code&gt;.vimrc&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then put your specific filetype settings into a file (creating non-existing directories) called &lt;code&gt;~/.vim/ftplugin/python.vim&lt;/code&gt; for python settings. This is also covered in the &lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-26.1&quot;&gt;FAQ&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update (13.11.2015)&lt;/strong&gt;&#xA;There is also another possibility (if you don't want to use filetype specific options):&#xA;If you want to group some options to a specific file, you can make use of the &lt;code&gt;source&lt;/code&gt; or &lt;code&gt;runtime&lt;/code&gt; command. For example my &lt;code&gt;.vimrc&lt;/code&gt; contains this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This script contains plugin specific settings&#xA;source ~/.vim/plugins.vim&#xA;&quot; This script contains mappings&#xA;source ~/.vim/mapping.vim&#xA;&quot; additional helper functions:&#xA;source ~/.vim/functions.vim&#xA;&quot; For abbreviations read in the following file:&#xA;source ~/.vim/abbrev.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-11-13T08:08:12.753" LastActivityDate="2015-11-13T08:08:12.753" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5444" PostTypeId="1" CreationDate="2015-11-11T12:46:38.077" Score="2" ViewCount="145" Body="&lt;p&gt;How can I disable default behaviour in emmet or sparkup?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to disable this expansion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;form --&amp;gt; &amp;lt;form action=&quot;&quot;&amp;gt;&amp;lt;/form&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to set it to (without &lt;code&gt;action=&quot;&quot;&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;form --&amp;gt; &amp;lt;form&amp;gt;&amp;lt;/form&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1526" LastActivityDate="2015-11-11T12:46:38.077" Title="How to disable default emmet or sparkup behaviour" Tags="|plugin-emmet-vim|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5446" PostTypeId="1" AcceptedAnswerId="5447" CreationDate="2015-11-11T15:03:25.787" Score="6" ViewCount="1095" Body="&lt;p&gt;Folks, I'm writing a syntax highlighting script for vim, but I'm struggling on how to highlight only a submatch of a pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, suppose that I want to highlight any number within &lt;code&gt;#&lt;/code&gt;, like &lt;code&gt;#42#&lt;/code&gt; to highlight &lt;strong&gt;only&lt;/strong&gt; the 42 and not the &lt;code&gt;#&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't fully understand what the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5C@=&quot; rel=&quot;nofollow&quot;&gt;\@=&lt;/a&gt; operator does, but I'm trying to use it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match Number &quot;\(#\)\@=\d\+\(#\)\@=&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;Just complementing Kent's answer, from the man page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            */\zs*&#xA;\zs Matches at any position, and sets the start of the match there: The&#xA;    next char is the first char of the whole match. |/zero-width|&#xA;    Example: &amp;gt;&#xA;        /^\s*\zsif&#xA;&amp;lt;   matches an &quot;if&quot; at the start of a line, ignoring white space.&#xA;    Can be used multiple times, the last one encountered in a matching&#xA;    branch is used.  Example: &amp;gt;&#xA;        /\(.\{-}\zsFab\)\{3}&#xA;&amp;lt;   Finds the third occurrence of &quot;Fab&quot;.&#xA;    {not in Vi} {not available when compiled without the |+syntax| feature}&#xA;                            */\ze*&#xA;\ze Matches at any position, and sets the end of the match there: The&#xA;    previous char is the last char of the whole match. |/zero-width|&#xA;    Can be used multiple times, the last one encountered in a matching&#xA;    branch is used.&#xA;    Example: &quot;end\ze\(if\|for\)&quot; matches the &quot;end&quot; in &quot;endif&quot; and&#xA;    &quot;endfor&quot;.&#xA;    {not in Vi} {not available when compiled without the |+syntax| feature}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4963" LastEditorUserId="4963" LastEditDate="2015-11-11T15:56:50.880" LastActivityDate="2015-11-11T15:56:50.880" Title="Vim to highlight only a submatch" Tags="|syntax-highlighting|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5447" PostTypeId="2" ParentId="5446" CreationDate="2015-11-11T15:15:10.793" Score="9" Body="&lt;p&gt;You can use &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match Number &quot;#\zs\d\+\ze#&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1569" LastActivityDate="2015-11-11T15:15:10.793" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5448" PostTypeId="1" CreationDate="2015-11-11T16:19:35.760" Score="2" ViewCount="990" Body="&lt;p&gt;I would like to know how to highlight multiple tokens in the same line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I want to highlight the value of 'a', I can write something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match num  'a=\zs\d\+\ze,b=\d\+.*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would highlight the number 42 in &lt;code&gt;a=42,b=5&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now what if I want to highlight both numbers? I know that something like &lt;code&gt;'a=\zs\d\+\ze,b=\zs\d\+\ze.*'&lt;/code&gt; won't work because it only highlights the last number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that I &lt;strong&gt;don't&lt;/strong&gt; want to highlight all the numbers in the line, so if I have a string like &lt;code&gt;(a=1,b=2,c=3)&lt;/code&gt;, I only want to highlight &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;2&lt;/code&gt; (i.e. the values of &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Also note that &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; should be adjacent, with &lt;code&gt;b&lt;/code&gt; following &lt;code&gt;a&lt;/code&gt;. So &lt;code&gt;(a=1,b=2,b=3)&lt;/code&gt; should highlight only &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;2&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4963" LastEditorUserId="4963" LastEditDate="2015-11-11T16:32:09.247" LastActivityDate="2015-11-11T16:35:11.203" Title="Syntax highlight multiple matches in the same line" Tags="|syntax-highlighting|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5449" PostTypeId="2" ParentId="5448" CreationDate="2015-11-11T16:31:07.147" Score="2" Body="&lt;p&gt;Given that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;so if I have a string like z=5,a=1,b=2,c=3, I only want to highlight 1&#xA;  and 2 (i.e. the values of a and b).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match Number &quot;[ab]=\zs\d\+&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match Number &quot;\(^\|[\s,]\)[ab]=\zs\d\+&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The below one won't match variables like &lt;code&gt;faaa=..&lt;/code&gt; or &lt;code&gt;xxxb=&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1569" LastEditorUserId="1569" LastEditDate="2015-11-11T16:35:11.203" LastActivityDate="2015-11-11T16:35:11.203" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5450" PostTypeId="2" ParentId="5416" CreationDate="2015-11-11T16:52:59.990" Score="2" Body="&lt;p&gt;As a simple solution, try adding this line to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:SuperTabDefaultCompletionType = &quot;context&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will result in the following behavior, which should be what you need in most cases:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/l&amp;lt;tab&amp;gt;  # will use filename completion&#xA;myvar.t&amp;lt;tab&amp;gt; # will use user completion if completefunc set, or&#xA;             # omni completion if omnifunc set.&#xA;myvar-&amp;gt;&amp;lt;tab&amp;gt; # same as above&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can always check &lt;code&gt;:help supertab-completioncontexts&lt;/code&gt; if you need a more personalized behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What jedi-vim does is set &lt;code&gt;omnifunc&lt;/code&gt; option to use the function it provides. This means that jedi-vim is only used when performing omni-completion. If you want to force SuperTab to &lt;strong&gt;always&lt;/strong&gt; use omni-completion then you can also use the following option &lt;strong&gt;instead&lt;/strong&gt; of the above one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:SuperTabContextDefaultCompletionType = &quot;&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="599" LastActivityDate="2015-11-11T16:52:59.990" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5451" PostTypeId="1" CreationDate="2015-11-11T17:10:21.473" Score="5" ViewCount="321" Body="&lt;p&gt;I am seeing this in Vim 7.3. I have autoindent on. Sometimes, when I move some code to the next line, the indentation of the line it was originally on changes, and then the newly created line is set to match that indentation. I don't mind that the new line indentation matches the previous one, since that is what autoindent is for, but why is the line I was on randomly changing its indentation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example. This is how the text is formatted before I make changes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    $sql= &quot;  &#xA;        SELECT *&#xA;        FROM temp_events                                                                                                                                                             &#xA;        ORDER BY&#xA;            Reader, Date, Time&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want  each ORDER BY column to be on its own line, so I move the cursor to the space in between &quot;Reader, &quot; and &quot;Date&quot;, and press &lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; to replace the space with a new line character. This is the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    $sql= &quot;        &#xA;        SELECT *   &#xA;        FROM temp_events&#xA;        ORDER BY   &#xA;        Reader,&#xA;        Date, Time&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, instead of just making the new line match the indentation of the one above, it first changed the indentation of the line with &quot;Reader&quot; and then made the new line match this now incorrect indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I was hoping would happen:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    $sql= &quot;        &#xA;        SELECT *   &#xA;        FROM temp_events&#xA;        ORDER BY&#xA;            Reader,&#xA;            Date, Time&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, I would also move Time to its line.&lt;/p&gt;&#xA;" OwnerUserId="1410" LastEditorUserId="1410" LastEditDate="2015-11-11T17:24:53.430" LastActivityDate="2015-11-12T05:46:22.267" Title="When moving text to new line, changes indentation for both lines" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5452" PostTypeId="1" CreationDate="2015-11-11T19:45:42.217" Score="5" ViewCount="242" Body="&lt;p&gt;I can set the text width and can manually line break imported paragraphs with the following as an example.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=72&#xA;gqq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can also navigate English text files with the standard 'w' 'b' 'e' '*' commands, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works well for English, however Thai and other Brahmic scripts of South and South-east Asia space at the phrasal level. Libreoffice, Word, Indesign, TeX, etc. &quot;know&quot; where line breaks should occur. And except for TeX, I can navigate by Thai word in these programs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question:&lt;/strong&gt; How can vim be &quot;taught&quot; to recognize Thai words (or any Indic language for that matter) for the purpose of navigation, word wrapping, and line breaking.&lt;/p&gt;&#xA;" OwnerUserId="5049" LastActivityDate="2015-11-11T19:45:42.217" Title="Set line breaks, word wraps and word searching for Thai and other non-latin languages" Tags="|vimscript|vimrc|wrapping|line-breaks|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5453" PostTypeId="2" ParentId="5451" CreationDate="2015-11-12T03:54:57.513" Score="5" Body="&lt;p&gt;I would start by checking if you have &lt;code&gt;filetype indent ON&lt;/code&gt;, you can check with command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you get &lt;code&gt;filetype indent ON&lt;/code&gt; in the response, then it means vim has loaded scripts which define indent behaviour.&lt;br&gt;&#xA;e.g. When I run &lt;code&gt;:scriptnames&lt;/code&gt; from inside a &lt;code&gt;mysql&lt;/code&gt; file,Vim tells me it has run these scripts: (amongst alot of other results, including the plugin and syntax files for SQL).  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; /usr/share/vim/vim74/indent/sql.vim                                                                                                               &#xA; /usr/share/vim/vim74/indent/sqlanywhere.vim &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sqlanywhere.vim&lt;/code&gt; is the default fallback file for sql indenting and is likely responsible for setting your SQL indent behaviour.&lt;br&gt;&#xA;You could try unsetting the SQL indent script completely with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype indent off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(note: to apply the updated config you must reload the buffer afterwards with &lt;code&gt;:e&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, if you don't want to lose the entire config you could try  looking in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/vim/vim74/indent/sqlanywhere.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for example it sets &lt;code&gt;indentexpr=GetSQLIndent()&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;from &lt;code&gt;:h indentexpr&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Expression which is evaluated to obtain the proper indent for a line.&lt;br&gt;&#xA;          It is used when a new line is created, for the = operator and&lt;br&gt;&#xA;          in Insert mode as specified with the 'indentkeys' option.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would try &lt;code&gt;:set indentexpr=&quot;&quot;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this doesn't solve your problem exactly, but it might give you a start&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2015-11-12T05:46:22.267" LastActivityDate="2015-11-12T05:46:22.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5454" PostTypeId="1" CreationDate="2015-11-12T11:13:03.673" Score="3" ViewCount="1702" Body="&lt;p&gt;~/.vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimLeave * :!touch /home/odiszapc/vimleave&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After exiting by typing &lt;code&gt;:q&amp;lt;CR&amp;gt;&lt;/code&gt; the file is not created. What I'm doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Version of ViM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 20 2015 10:38:14)&#xA;Included patches: 1-207, 209-801, 803-808, 810-827&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5275" LastEditorUserId="51" LastEditDate="2015-11-12T16:34:25.363" LastActivityDate="2015-11-12T16:34:25.363" Title="VimLeave event not triggered?" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5455" PostTypeId="2" ParentId="5454" CreationDate="2015-11-12T11:21:02.443" Score="8" Body="&lt;p&gt;What I was doing wrong is adding &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; at the end of the line. That's work pretty well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimLeave * :!touch /home/odiszapc/vimleave&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5275" LastEditorUserId="5275" LastEditDate="2015-11-12T14:24:57.040" LastActivityDate="2015-11-12T14:24:57.040" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5456" PostTypeId="2" ParentId="5418" CreationDate="2015-11-12T12:33:06.807" Score="1" Body="&lt;pre&gt;&lt;code&gt;syn region LangBlock matchgroup=LangKeys start=&quot;\&amp;lt;WHILE\&amp;gt;&quot; end=&quot;\&amp;lt;END_WHILE\&amp;gt;&quot; fold transparent contains=InsideKeys&#xA;syn keyword InsideKeys DO contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Things that I changed in the syntax code you provided:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The &lt;code&gt;\&amp;lt; \&amp;gt;&lt;/code&gt; are required to only match words, such that WHILE is not found inside END_WHILE.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;matchgroup&lt;/code&gt; argument sets the syntax group name to be used in the match start/end words.&lt;/li&gt;&#xA;&lt;li&gt;Remove the keywords for WHILE and END_WHILE, because the highlight is done by the respective syn-match command.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Obviously, both &lt;code&gt;LangKeys&lt;/code&gt; and &lt;code&gt;InsideKeys&lt;/code&gt; syntax groups need to be defined using the &lt;code&gt;highlight&lt;/code&gt; command with something like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight link LangKeys   Statement&#xA;highlight link InsideKeys Statement&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information please check:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help syn-match&#xA;:help hi-link&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="599" LastEditorUserId="599" LastEditDate="2015-11-12T14:07:25.803" LastActivityDate="2015-11-12T14:07:25.803" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="5457" PostTypeId="2" ParentId="5442" CreationDate="2015-11-12T14:19:30.430" Score="2" Body="&lt;p&gt;Have you enabled syntax highlighting and filetype plugins/indentation in your vimrc?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-11-12T14:19:30.430" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5458" PostTypeId="1" AcceptedAnswerId="5459" CreationDate="2015-11-12T14:24:17.567" Score="9" ViewCount="436" Body="&lt;p&gt;Is it possible to add a sign to be displayed in the signs column whenever the line has a ToDo group (ToDo,FIXME...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;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.&lt;/p&gt;&#xA;" OwnerDisplayName="user5235" LastActivityDate="2015-11-13T08:04:54.643" Title="Is it possible to assign a sign to &quot;Todo&quot; group?" Tags="|syntax-highlighting|colorscheme|signs|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5459" PostTypeId="2" ParentId="5458" CreationDate="2015-11-12T16:28:00.710" Score="9" Body="&lt;p&gt;Try this function :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SignKeyword()&#xA;&#xA;    silent! sign undefine todo&#xA;&#xA;    sign define todo text=&amp;gt;&amp;gt; texthl=Search&#xA;&#xA;    g/\v\C(&amp;lt;TODO&amp;gt;|&amp;lt;FIXME&amp;gt;)/execute &quot;sign place 9999 line=&quot; . line('.')&#xA;    \ . &quot; name=todo buffer=&quot; . bufnr('')&#xA;&#xA;    nohlsearch&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now call the function on the command line :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call SignKeyword()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or add a mapping in your &lt;code&gt;~/.vimrc&lt;/code&gt; to call it :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;your mapping&amp;gt; :call SignKeyword()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or add an autocmd. For example if you want the function to be called automatically when opening a file whose filetype is markdown  :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown call SignKeyword()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The first line of the function &lt;code&gt;silent! sign undefine todo&lt;/code&gt; deletes the sign todo if it already exists, so that if your signs are misplaced after deleting or adding a line, you can recall the function to fix them immediately.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The second line defines a sign whose name is todo, whose text is &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; (you can change it to suit your preferences) and which uses the Search highlighting group (same thing).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The third line uses the global command :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/pattern/command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The global command executes a command on every line that matches a pattern.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the pattern is &lt;code&gt;\v\C(&amp;lt;TODO&amp;gt;|&amp;lt;FIXME&amp;gt;)&lt;/code&gt;, which means any line containing either the word &lt;strong&gt;TODO&lt;/strong&gt; or &lt;strong&gt;FIXME&lt;/strong&gt;.&lt;br&gt;&#xA;The regex includes the atom &lt;code&gt;\C&lt;/code&gt; so that the search respects the case (no matter what your 'ignorecase' option is). If you want the search to not respect the case, change it to &lt;code&gt;\c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever such a line is found the following line is executed by the function :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;sign place 9999 line=&quot; . line('.')&#xA;    \ . &quot; name=todo buffer=&quot; . bufnr('')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It executes (with the &lt;code&gt;:execute&lt;/code&gt; command) the content of the following string :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;sign place 9999 line=&quot; . line('.') . &quot; name=todo buffer=&quot; . bufnr('')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The string includes two vim built-in functions : &lt;code&gt;line()&lt;/code&gt; and &lt;code&gt;bufnr()&lt;/code&gt;.&lt;br&gt;&#xA;&lt;code&gt;line('.')&lt;/code&gt; returns the number of the current line when a match is found by the global command, and &lt;code&gt;bufnr('.')&lt;/code&gt; returns the number of the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for example, if the global command finds a match on line 10 in the buffer  5, it will give :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;sign place 9999 line=&quot; . 10 . &quot; name=todo buffer=&quot; . 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The dots concatenate the strings, and so it will finally evaluate to :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;sign place 9999 line=10 name=todo buffer=5&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is the &lt;code&gt;:sign&lt;/code&gt; command placing a sign on line 10 in buffer 5.&lt;br&gt;&#xA;9999 is a random id chosen for the sign (you can choose another one).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The fourth line of the function &lt;code&gt;:nohlsearch&lt;/code&gt; disables the highlighting of the matched patterns.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit : I fixed the regex, the original was wrong.&#xA;I wrote &lt;code&gt;^[TODO|FIXME]&lt;/code&gt; but instead I think it should be &lt;code&gt;\v\C(&amp;lt;TODO&amp;gt;|&amp;lt;FIXME&amp;gt;)&lt;/code&gt;.&#xA;Sorry for the inconvenience, I'm still learning vimscript.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-13T03:41:07.780" LastActivityDate="2015-11-13T03:41:07.780" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5460" PostTypeId="2" ParentId="5458" CreationDate="2015-11-12T17:22:48.950" Score="6" Body="&lt;p&gt;You can use my &lt;a href=&quot;https://github.com/chrisbra/DynamicSigns&quot; rel=&quot;nofollow&quot;&gt;DynamicSigns&lt;/a&gt; plugin. This allows for so called &quot;SignExpression&quot; which are similar to the fold expression. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can simply do &lt;code&gt;:SignExpression getline(v:lnum)=~'TODO'?'Warning':0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the help for more exmples of what is possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage of using my plugin is, that it tracks changes of the buffer and adjusts the signs accordingly.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-11-13T08:04:54.643" LastActivityDate="2015-11-13T08:04:54.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5461" PostTypeId="1" AcceptedAnswerId="5482" CreationDate="2015-11-13T07:37:38.720" Score="1" ViewCount="479" Body="&lt;p&gt;&lt;strong&gt;What I want&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want create a mapping which comments a line into a box, for example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;textline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;shall be transformed to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ##############################################################################&#xA;&quot; textline&#xA;&quot; ############################################################################## &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on the buffer filetype, the appropriate comment string shall be used. The solution should work too if the line is empty. Furthermore, the same mapping or and additional mapping should be able to transform a box back to the normal text from anywhere within the box. Ideally, I could give a count too so that will work for more than one line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My current solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use tpope's vim-commentary plugin which recognizes the appropriate comment string and lets me toogle line comments with &lt;code&gt;gcc&lt;/code&gt;. I created the following mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;b O&amp;lt;Esc&amp;gt;78i#&amp;lt;Esc&amp;gt;gccjgcco&amp;lt;Esc&amp;gt;a  &amp;lt;Esc&amp;gt;78i#&amp;lt;Esc&amp;gt;k$&#xA;map &amp;lt;leader&amp;gt;u _ddgccj_ddk$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The shortcomings of my solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If I create a box from an empty line, the second line in the box is not commented (as &lt;code&gt;gcc&lt;/code&gt; doesn't change an empty line)&lt;/li&gt;&#xA;&lt;li&gt;The mapping for unboxing just works from the first line of a given box. Of course I can change that by adding a &lt;code&gt;k&lt;/code&gt; or a &lt;code&gt;kk&lt;/code&gt; in the beginning of the mapping to work from the second or third line, but it will only work then from a specific line&lt;/li&gt;&#xA;&lt;li&gt;I need a second mapping for unboxing, I would prefer to use only one mapping for both boxing and unboxing&lt;/li&gt;&#xA;&lt;li&gt;The mapping does not accept a count (to example box two lines instead of just one)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I improve these mappings and get rid of as many shortcomings as possible?&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2015-11-15T20:18:31.180" Title="Comment line into a box and undo" Tags="|key-bindings|comments|plugin-vim-commentary|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5462" PostTypeId="1" AcceptedAnswerId="5463" CreationDate="2015-11-13T10:58:33.567" Score="27" ViewCount="4611" Body="&lt;p&gt;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?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;make visual selection &lt;kbd&gt;v&lt;/kbd&gt;, then motions to make selection etc, then&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;so&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But vim gives an error &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;no range allowed&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;also&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;w | so&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use ! to write partial buffer&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How can I source visually selected vimscript?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="205" LastEditDate="2016-02-23T01:19:11.793" LastActivityDate="2023-06-22T03:44:41.370" Title="How can I source a visual selection of vimscript?" Tags="|vimscript|visual-mode|" AnswerCount="8" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5463" PostTypeId="2" ParentId="5462" CreationDate="2015-11-13T11:06:38.853" Score="22" Body="&lt;p&gt;On the command line hit &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; then type &lt;code&gt;@*&lt;/code&gt; and enter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; will delete the visual range &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; that has been automatically inserted if some text is visually selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:@*&lt;/code&gt; will execute the content of the &lt;code&gt;*&lt;/code&gt; register which contains whatever is visually selected at the moment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if the text that is selected / highlighted is in your web browser (firefox, chrome, ...), it will work, the &lt;code&gt;*&lt;/code&gt; register will allow you to access it directly in vim.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If your text is selected in a vim buffer, another solution is to copy it in a named register, for example the &lt;strong&gt;a&lt;/strong&gt; register by typing &lt;code&gt;&quot;ay&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, on the command line, type : &lt;code&gt;&amp;lt;C-r&amp;gt;a&lt;/code&gt; and enter.&lt;br&gt;&#xA;&lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;r&lt;/kbd&gt; will give you a sort of prompt represented by the character &lt;code&gt;&quot;&lt;/code&gt; (for more information read &lt;code&gt;:h c_Ctrl-r&lt;/code&gt;).&lt;br&gt;&#xA;At this new prompt, if you give the name of a register, its content will be inserted on the command line, where you'll be able to edit it before execution. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Besides if you copy some text without specifying a register, it will be accessible from the unnamed register &lt;strong&gt;&quot;&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So suppose you've got a line of vimscript in a file and want to source it quickly, you can copy it with &lt;code&gt;Y&lt;/code&gt;, then source it on the command line with : &lt;code&gt;:&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt; and enter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, if you use this last solution, there's just a problem you must be aware of.&lt;br&gt;&#xA;If you see a strange character on the command line like this &lt;code&gt;^M&lt;/code&gt;, it's the &lt;a href=&quot;https://en.wikipedia.org/wiki/Caret_notation&quot;&gt;caret notation&lt;/a&gt; of the carriage return. You should delete it, otherwise you'll probably get an error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In summary, you :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;copy your line of vimscript with &lt;code&gt;Y&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;switch to command mode with &lt;code&gt;:&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; to enter the registers prompt&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;&quot;&lt;/code&gt; to call the unnamed register&lt;/li&gt;&#xA;&lt;li&gt;hit backspace to delete the &lt;code&gt;^M&lt;/code&gt; character&lt;/li&gt;&#xA;&lt;li&gt;and hit enter.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-13T11:48:09.480" LastActivityDate="2015-11-13T11:48:09.480" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5464" PostTypeId="1" AcceptedAnswerId="5474" CreationDate="2015-11-13T13:43:39.107" Score="4" ViewCount="225" Body="&lt;p&gt;I’m using the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=953&quot; rel=&quot;nofollow&quot;&gt;multiselect&lt;/a&gt; plugin. I have selected multiple contiguous blocks of code and want to yank all of them into one register. For example, from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- selected A --&#xA;—— unselected ——&#xA;-- selected B --&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- selected A --&#xA;-- selected B --&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in one register. Executing &lt;code&gt;MSExecCmd yank&lt;/code&gt; yanks the contiguous blocks into separate registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I yank them into one?&lt;/p&gt;&#xA;" OwnerUserId="5045" LastActivityDate="2015-11-14T12:16:00.170" Title="Yanking lines from a multiple selection" Tags="|cut-copy-paste|multiple-lines|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5468" PostTypeId="2" ParentId="5461" CreationDate="2015-11-13T15:52:45.403" Score="2" Body="&lt;p&gt;This should work :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CommentBox()&#xA;&#xA;    &quot; PREPARATIONS&#xA;&#xA;    &quot; prefix is the number we hit before &amp;lt;leader&amp;gt;b&#xA;        let prefix=v:count1&#xA;&#xA;    &quot; We define the Firstchar() function that returns the first character&#xA;    &quot; of the current line.&#xA;        function! Firstchar()&#xA;            execute &quot;normal! _&quot;&#xA;            return matchstr(getline('.'), '\%' . col('.') . 'c.')&#xA;        endfunction&#xA;&#xA;    &quot; We define the Gcc() function that comments an uncommented line.&#xA;        function! Gcc()&#xA;            if Firstchar() !=# s:commentchar&#xA;            execute &quot;normal gcc&quot;&#xA;            endif&#xA;        endfunction&#xA;&#xA;    &quot; We define the InsertCommentChar() function that inserts a&#xA;    &quot; comment character manually, because the gcc mapping is unable to&#xA;    &quot; comment an empty line.&#xA;        function! InsertCommentChar()&#xA;            if getline('.') =~ '\v(\s*|^$)'&#xA;                execute &quot;normal! i\&amp;lt;c-r&amp;gt;a\e&quot;&#xA;            endif&#xA;        endfunction&#xA;&#xA;    &quot; We store the character under the cursor inside the s:firstchar variable.&#xA;        let s:firstchar = Firstchar()&#xA;&#xA;    &quot; We open a new line.&#xA;        execute &quot;normal! o&quot;&#xA;&#xA;    &quot; We check whether this new line is empty and add the character 'a' in&#xA;    &quot; this case.&#xA;        if getline('.') =~ '\v(\s*|^$)'&#xA;            execute &quot;normal! ia\e&quot;&#xA;        endif&#xA;&#xA;    &quot; We comment this new line.&#xA;        execute &quot;normal gcc&quot;&#xA;&#xA;    &quot; We store the comment character inside the s:commentchar variable.&#xA;    &quot; For example, if we are in a python file, then s:commentchar = #&#xA;        let s:commentchar = Firstchar()&#xA;&#xA;    &quot; We delete this new line and go back where we were.&#xA;        execute &quot;normal! ddk&quot;&#xA;&#xA;    &quot; CREATION OF A BOX&#xA;&#xA;    &quot; If firstchar and commentchar are different, it means that we were not on&#xA;    &quot; a commented line when we invoked the function. So we create a box.&#xA;        if s:firstchar !=# s:commentchar&#xA;&#xA;        &quot; We call the gcc mapping to comment the lines.&#xA;            execute &quot;normal &quot;.prefix.&quot;gcc&quot;&#xA;&#xA;        &quot; We create the upper border and put the mark a on the line.&#xA;            execute &quot;normal! O\ea  \e78i#\ema&quot;&#xA;&#xA;        &quot; We create the lower border and put the mark b on the line.&#xA;            execute &quot;normal! &quot;.prefix.&quot;jo\ea  \e78i#\emb&quot;&#xA;&#xA;        &quot; We put the comment character inside the register a.&#xA;            call setreg(&quot;a&quot;, s:commentchar)&#xA;&#xA;        &quot; We ask the global command to insert the comment character on every&#xA;        &quot; empty line inside the box.&#xA;            'a,'b g/^$/call InsertCommentChar()&#xA;&#xA;        &quot; We go on the upper border and comment it if it's not.&#xA;            execute &quot;normal! 'a&quot;&#xA;            call Gcc()&#xA;&#xA;        &quot; Same thing for lower border.&#xA;            execute &quot;normal! 'b&quot;&#xA;            call Gcc()&#xA;&#xA;    else&#xA;&#xA;    &quot; DESTRUCTION OF A BOX&#xA;&#xA;    &quot; If firstchar and commentchar are different, it means we were not on a&#xA;    &quot; commented line when we invoked the function, thus we want to undo&#xA;    &quot; a box, not create one.&#xA;&#xA;    &quot; First, we delete the borders and put the marks a and b around it.&#xA;        execute &quot;silent! normal! ?###\rddma/###\rddkmb&quot;&#xA;&#xA;    &quot; Then, we uncomment every line that was inside the box.&#xA;        'a,'b g/^/execute &quot;normal gcc&quot;&#xA;&#xA;    endif&#xA;&#xA;endfunction&#xA;&#xA;&quot; We define &amp;lt;leader&amp;gt;b as a shortcut to create/delete a box.&#xA;    nnoremap &amp;lt;leader&amp;gt;b :&amp;lt;c-u&amp;gt;call CommentBox()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There may be rough edges. If someone knows how to improve the code, let me know, I'm interested.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Preparations&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The first instruction of the &lt;code&gt;CommentBox()&lt;/code&gt; function is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let prefix=v:count1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;prefix&lt;/code&gt; variable stores the number that precedes the mapping that will be assigned to this function, which will be &lt;code&gt;&amp;lt;leader&amp;gt;b&lt;/code&gt;.&lt;br&gt;&#xA;So if you hit &lt;code&gt;6&amp;lt;leader&amp;gt;b&lt;/code&gt;, &lt;code&gt;prefix&lt;/code&gt; will store 6 and if you hit directly &lt;code&gt;&amp;lt;leader&amp;gt;b&lt;/code&gt; without prefixing it with a count, &lt;code&gt;prefix&lt;/code&gt; will store 1.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Subfunctions&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Next we define 3 functions (inside the main one) :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;code&gt;Firstchar()&lt;/code&gt; function that returns the first character of the&#xA;current line.&lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;Gcc()&lt;/code&gt; function that comments a line by calling the &lt;code&gt;gcc&lt;/code&gt; mapping but only if the line is empty or contains only whitespace (with this regex &lt;code&gt;\v(\s*|^$)&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;InsertCommentChar()&lt;/code&gt; function that inserts a comment character manually at the beginning of a line, because the &lt;code&gt;gcc&lt;/code&gt; mapping is unable to comment an empty line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These functions use 2 special commands : &lt;code&gt;execute&lt;/code&gt; and &lt;code&gt;normal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;execute&lt;/code&gt; command can take a string or a concatenation of strings (with the dot operator &lt;code&gt;.&lt;/code&gt;), inside the string it interprets the &lt;code&gt;\e&lt;/code&gt; as the escape key, the &lt;code&gt;\r&lt;/code&gt; as the enter key, the &lt;code&gt;\&amp;lt;c-r&amp;gt;&lt;/code&gt; as the &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;r&lt;/kbd&gt; key combination, evaluates the &lt;code&gt;prefix&lt;/code&gt; variable and sends the result to the &lt;code&gt;normal&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;normal&lt;/code&gt; command types every key it reads (in this case it receives the key from the &lt;code&gt;execute&lt;/code&gt; command) as if we were in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, whenever inside the script there's something written after &lt;code&gt;normal&lt;/code&gt;, it will be as if we typed a sequence of keystrokes while in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the &lt;code&gt;InsertCommentChar()&lt;/code&gt; function will type : &lt;code&gt;i\&amp;lt;c-r&amp;gt;a\e&lt;/code&gt;.&lt;br&gt;&#xA;This will cause the switch to insert mode (&lt;code&gt;i&lt;/code&gt;), then the insertion of the &lt;code&gt;a&lt;/code&gt; register, then go back to normal mode by escaping (&lt;code&gt;\e&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, to insert the content of a register in insert mode you can hit &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;r&lt;/kbd&gt; followed by the name of the register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What will be in the &lt;code&gt;a&lt;/code&gt; register ? The comment character.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Variables&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Now that we have defined those functions, we need to set two variables &lt;code&gt;s:firstchar&lt;/code&gt; and &lt;code&gt;s:commentchar&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do we prefix them with &lt;code&gt;s:&lt;/code&gt; ?&lt;br&gt;&#xA;It's a scope (if you know Python, I think it's a sort of namespace).&lt;br&gt;&#xA;The &lt;code&gt;s:&lt;/code&gt; scope is local to the script, without it, the variables would be accessible in the main function but not in the subfunctions that we've just defined.&lt;br&gt;&#xA;Indeed when a subfunction calls a variable defined in the main one, vim must know where to look for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To define &lt;code&gt;s:firstchar&lt;/code&gt;, we simply call the function Firstchar() :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:firstchar = Firstchar()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To define &lt;code&gt;s:commentchar&lt;/code&gt;, it's a bit more tricky.&lt;br&gt;&#xA;Inspired by &lt;a href=&quot;https://vi.stackexchange.com/questions/5461/comment-line-into-a-box-and-undo#comment8438_5468&quot;&gt;your comment&lt;/a&gt; (thanks a lot by the way), we're going to open a new line, insert a character in it, comment the line with the &lt;code&gt;gcc&lt;/code&gt; mapping and then grab the first character of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The implementation is the following :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal! o&quot;&#xA;&#xA;if getline('.') =~ '\v(\s*|^$)'&#xA;    execute &quot;normal! ia\e&quot;&#xA;endif&#xA;&#xA;execute &quot;normal gcc&quot;&#xA;let s:commentchar = Firstchar()&#xA;execute &quot;normal! ddk&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that we must ensure that this new line is empty (hence the regex &lt;code&gt;\v(\s*|^$)&lt;/code&gt;) before inserting the &lt;code&gt;a&lt;/code&gt; character.&lt;br&gt;&#xA;Besides at the end, once we've stored the comment character inside &lt;code&gt;s:commentchar&lt;/code&gt;, we delete our new line (&lt;code&gt;dd&lt;/code&gt;) and go back where we were (&lt;code&gt;k&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Decision making&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Now we need to decide if we want to create or destroy a box.&#xA;To do so, we're going to compare the first character of the line we're on when invoking the function with the comment character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If they are different, it means we weren't on a commented line and want to create a box.&lt;br&gt;&#xA;If they are the same, it means we were on a commented line (probably inside a box) and want to undo a box instead of creating one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's what the main &lt;code&gt;if&lt;/code&gt; condition inside the main function checks :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if s:firstchar !=# s:commentchar&#xA;[...]&#xA;else &#xA;[...]&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Creation of a box&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;We create a box with these 9 instructions :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    execute &quot;normal &quot;.prefix.&quot;gcc&quot;&#xA;    execute &quot;normal! O\ea  \e78i#\ema&quot;&#xA;    execute &quot;normal! &quot;.prefix.&quot;jo\ea  \e78i#\emb&quot;&#xA;&#xA;    call setreg(&quot;a&quot;, charb)&#xA;    'a,'b g/^$/execute &quot;normal! i\&amp;lt;c-r&amp;gt;a\e&quot;&#xA;&#xA;    execute &quot;normal! 'a&quot;&#xA;    call Gcc()&#xA;    execute &quot;normal! 'b&quot;&#xA;    call Gcc()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Suppose we hit &lt;code&gt;6&amp;lt;leader&amp;gt;b&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this scenario, the &lt;code&gt;normal&lt;/code&gt; command will first receive 3 sequences of keystrokes consecutively :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;6gcc&#xA;&#xA;O\ea  \e78i#\ema&#xA;&#xA;6jo\ea  \e78i#\emb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;normal&lt;/code&gt; command will type them as if we were in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;6gcc&lt;/code&gt; = we comment the 6 next lines (because we prefix our mapping with 6 in our example)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;O\ea  \e78i#\e&lt;/code&gt; = we open a line above us (&lt;code&gt;O&lt;/code&gt;), escape (&lt;code&gt;\e&lt;/code&gt;), go into insert mode and type 2 spaces (&lt;code&gt;a&lt;/code&gt;), escape again, insert 78 # characters (&lt;code&gt;78i#&lt;/code&gt;), escape again and put the mark &lt;strong&gt;a&lt;/strong&gt; (&lt;code&gt;ma&lt;/code&gt;) on the line.&lt;br&gt;&#xA;At this point, we have inserted a line above the original one, that is commented and contains 78 &lt;code&gt;#&lt;/code&gt; characters.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;6jo\ea  \e78i#\emb&lt;/code&gt; = we go 6 lines downward and do the exact same thing. &#xA;Insert 78 &lt;code&gt;#&lt;/code&gt; characters and put the mark &lt;strong&gt;b&lt;/strong&gt; on the line (&lt;code&gt;mb&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The box is almost done, but there's still one problem that you mentioned in your initial post.&lt;br&gt;&#xA;The &lt;code&gt;gcc&lt;/code&gt; mapping doesn't comment an empty line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve this problem, we're going to insert ourselves the comment character on every empty line, and that's what the fourth and fifth instructions do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fourth instruction uses the &lt;code&gt;setreg()&lt;/code&gt; built-in function to put the content of the &lt;code&gt;s:commentchar&lt;/code&gt; variable inside the register &lt;code&gt;a&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    call setreg(&quot;a&quot;, s:commentchar)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the fifth instruction uses the global command. The syntax of the global command is the following :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;range g/pattern/command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On every line inside &lt;code&gt;range&lt;/code&gt; (for example &lt;code&gt;10,20&lt;/code&gt; means every line between 10 and 20) that matches &lt;code&gt;pattern&lt;/code&gt;, the global command will execute &lt;code&gt;command&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The range we're going to use is &lt;code&gt;'a,'b&lt;/code&gt; (which means every line between mark &lt;strong&gt;a&lt;/strong&gt; and mark &lt;strong&gt;b&lt;/strong&gt;), the pattern will be &lt;code&gt;^$&lt;/code&gt; (empty line) and the command will be &lt;code&gt;call InsertCommentChar()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the fifth instruction we need is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    'a,'b g/^$/call InsertCommentChar()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last 4 instructions are there to comment the borders if they aren't already (in some cases it happen).&#xA;To navigate between the two borders, again we use the &lt;strong&gt;a&lt;/strong&gt; and &lt;strong&gt;b&lt;/strong&gt; marks that we set previously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's it, the box should be created.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Destruction of a box&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If we hit the mapping &lt;code&gt;&amp;lt;leader&amp;gt;b&lt;/code&gt; on a line that is commented (&lt;code&gt;s:firstchar&lt;/code&gt; = &lt;code&gt;s:commentchar&lt;/code&gt;), we execute these 2 instructions :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    execute &quot;silent! normal! ?###\rddma/###\rddkmb&quot;&#xA;    'a,'b g/^/execute &quot;normal gcc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's say we're still in our example and we've got a box containing 8 lines (6 for the comments and 2 for the borders).&#xA;In this case, the first instruction will send to the &lt;code&gt;normal&lt;/code&gt; command the following keystrokes :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?###\rddma/###\rddkmb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;?###\r&lt;/code&gt; = we search for the string &lt;strong&gt;###&lt;/strong&gt; backward&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dd&lt;/code&gt; = we delete the first line of the box (the upper border).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ma&lt;/code&gt; = we're now on the first line commented inside the box, we put the mark &lt;strong&gt;a&lt;/strong&gt; on it&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/###\r&lt;/code&gt; = we search for the string &lt;strong&gt;###&lt;/strong&gt; forward.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dd&lt;/code&gt; = we delete the last line of the box (the lower border).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;kmb&lt;/code&gt; = we go one line upward (&lt;code&gt;k&lt;/code&gt;) and then we put the mark &lt;strong&gt;b&lt;/strong&gt; on the line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Once we've put our marks around our block of text, we want to run the &lt;code&gt;gcc&lt;/code&gt; mapping on each of its line to uncomment it.&#xA;To do so, we use the global command again :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'a,'b g/^/execute &quot;normal gcc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line can be read like this :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;for each line between mark a and b, whenever the global command finds a line matching the pattern &lt;code&gt;^&lt;/code&gt; (which is every line, since every line has a beginning), it must run the command &lt;code&gt;execute &quot;normal gcc&quot;&lt;/code&gt; on it.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The last line of the code maps the &lt;code&gt;CommentBox()&lt;/code&gt; function to &lt;code&gt;&amp;lt;leader&amp;gt;b&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :&amp;lt;c-u&amp;gt;call CommentBox()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Finally, the &lt;code&gt;silent!&lt;/code&gt; commands are used whenever a search is performed, in case there are errors, they won't show up on screen.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the difference between the &lt;code&gt;normal&lt;/code&gt; commands and the &lt;code&gt;normal!&lt;/code&gt; commands is the recursiveness. Usually I prefer no recursiveness so I use &lt;code&gt;normal!&lt;/code&gt;, because recursiveness means trouble. But sometimes it's necessary.&lt;br&gt;&#xA;Here it's necessary when we call the &lt;code&gt;gcc&lt;/code&gt; mapping, because we want vim to interpret it recursively, otherwise it would probably be interpreted as &lt;code&gt;g&lt;/code&gt; and &lt;code&gt;cc&lt;/code&gt; separately or something like that.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-15T08:28:43.223" LastActivityDate="2015-11-15T08:28:43.223" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5469" PostTypeId="1" CreationDate="2015-11-13T17:52:45.533" Score="4" ViewCount="192" Body="&lt;p&gt;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?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2015-11-13T18:19:39.517" LastActivityDate="2021-06-15T05:14:52.790" Title="Autocorrecting final sigma" Tags="|abbreviations|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5470" PostTypeId="1" CreationDate="2015-11-13T17:55:16.840" Score="1" ViewCount="83" Body="&lt;p&gt;I copied the code from &lt;a href=&quot;https://github.com/chakrit/vim-thai-keys/blob/master/plugin/vim-thai-keys.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-thai-keys&lt;/a&gt; to my &lt;code&gt;.vimrc&lt;/code&gt; file and made a few adjustments.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;My problem:&lt;/strong&gt; Typing the '2' key while using the Thai keyboard in Normal mode either sends me to &lt;code&gt;/search&lt;/code&gt; mode or moves the cursor two spaces to the right and I am thus unable to use 2 in a keystroke navigation or editing combination.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The symbol on the Thai keyboard corresponding to the English key '2' is '/'.&lt;/p&gt;&#xA;&lt;p&gt;Changes made to .vimrc file and the results of typing '2' from the Thai keyboard while in Normal mode.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:map / 2&lt;/code&gt; — &lt;em&gt;Result: Cursor moves 2 spaces to the right&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:map \/ 2&lt;/code&gt; — &lt;em&gt;Result: Sent into &lt;code&gt;/search&lt;/code&gt; mode&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;nnoremap / 2&lt;/code&gt; — &lt;em&gt;Result: Cursor moves 2 spaces to the right&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;nnoremap \/ /&lt;/code&gt; — &lt;em&gt;Result: Sent into &lt;code&gt;/search&lt;/code&gt; mode&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;All of the other numbers and key stroke mappings seem to work wonderfully.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;em&gt;(Yes, I restarted vim after editing the .vimrc file) :) :)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Is there a way to map the '2' key so that while in the Thai keyboard in Normal mode I am able to use it as a normal 2 in navigation and editing keystroke combinations?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Bonus points:&lt;/strong&gt; Should I use &lt;code&gt;:map&lt;/code&gt; or &lt;code&gt;nnoremap&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; file for these key stroke mappings and why.&lt;/p&gt;&#xA;" OwnerUserId="5049" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-12-15T19:07:09.970" Title="mapping '2' key in Thai resulting in '/'" Tags="|key-bindings|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5471" PostTypeId="1" CreationDate="2015-11-13T18:13:55.200" Score="3" ViewCount="451" Body="&lt;p&gt;Suppose I want to make a syntax highlighting script to work with files with the following hypothetical format:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;blah # blahA1B2 bla&#xA;asdf A11B453 # qwert&#xA;aaa A0B0 bbb @&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, lines with arbitrary text, but somewhere in the line I have a string with the format &lt;code&gt;A\d\+B\d\+&lt;/code&gt; (&lt;code&gt;A&lt;/code&gt; immediately followed by a number, immediately followed by &lt;code&gt;B&lt;/code&gt;, and then another number).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, suppose that I highlight the whole line based on another pattern (in the example I'll make it clear).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I want&lt;/strong&gt; is to highlight &lt;strong&gt;only&lt;/strong&gt; the numbers within the pattern &lt;code&gt;A[0-9]\+B[0-9]\+&lt;/code&gt;, &lt;strong&gt;without&lt;/strong&gt; removing the current highlight from the &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;B&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following script almost solves my problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match Type '.*#.*'&#xA;syn match Macro '.*@.*'&#xA;syn match Number '[AB]\zs\d\+\ze'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What it does:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Highlight with green lines that have a &lt;code&gt;#&lt;/code&gt; (this part is ok).&lt;/li&gt;&#xA;&lt;li&gt;Highlight with purple lines that have a &lt;code&gt;@&lt;/code&gt; (this part also is ok).&lt;/li&gt;&#xA;&lt;li&gt;Highlight the number following A or B (this need improvement).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The problem with my script is that it also highlights &lt;code&gt;A2&lt;/code&gt; and &lt;code&gt;B3&lt;/code&gt;, but they should be together to be highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also worked a bit with the &lt;code&gt;contains&lt;/code&gt; and &lt;code&gt;containedin&lt;/code&gt;, but with no success.&lt;/p&gt;&#xA;" OwnerUserId="4963" LastActivityDate="2015-11-13T20:17:41.527" Title="Highlight multiple matches without removing previous context" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5472" PostTypeId="2" ParentId="5471" CreationDate="2015-11-13T19:56:13.347" Score="3" Body="&lt;p&gt;Apparently &lt;code&gt;transparent&lt;/code&gt; was the missing piece of the puzzle, as @Sato points out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The final script would be something of this sort:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match Type '.*#.*'&#xA;syn match Macro '.*@.*'&#xA;syn match pattern 'A\d\+B\d\+' transparent contains=num&#xA;syn match num '[AB]\zs\d\+\ze' contained&#xA;hi def link num Number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without the &lt;code&gt;transparent&lt;/code&gt;, A and B would lack highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason adding a &lt;code&gt;containedin=pattern&lt;/code&gt; in num's line won't work, but I didn't bother finding out why.&lt;/p&gt;&#xA;" OwnerUserId="4963" LastEditorUserId="4963" LastEditDate="2015-11-13T20:17:41.527" LastActivityDate="2015-11-13T20:17:41.527" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5474" PostTypeId="2" ParentId="5464" CreationDate="2015-11-14T12:10:59.507" Score="4" Body="&lt;p&gt;What happens if you run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=&quot;&quot;&#xA;:MSExecNormalCmd &quot;Ay&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after you have your blocks visually selected?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... the idea (even if the above doesn't work) is still to yank-append each visually selected block to the same register. But, since you use a specific plugin, &lt;em&gt;you&lt;/em&gt; are the one who should know how to do it (i.e. reading the plugin's &lt;a href=&quot;https://github.com/vim-scripts/multiselect/blob/master/doc/multiselect.txt&quot; rel=&quot;nofollow&quot;&gt;help&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-11-14T12:10:59.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5475" PostTypeId="1" AcceptedAnswerId="5476" CreationDate="2015-11-14T17:09:10.333" Score="5" ViewCount="2356" Body="&lt;p&gt;Could this be done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I'm imagining that I would type &lt;code&gt;vim .&lt;/code&gt; then navigate to a different directory within netrw, exit netrw, and find that bash has done a &lt;code&gt;cd&lt;/code&gt; to that same directory.&lt;/p&gt;&#xA;" OwnerUserId="2985" LastActivityDate="2018-12-11T04:33:47.993" Title="Use netrw to change my bash working directory?" Tags="|netrw|bash|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5476" PostTypeId="2" ParentId="5475" CreationDate="2015-11-14T18:17:59.737" Score="4" Body="&lt;p&gt;No it isn't possible. Vim will be the child of your bash process. A child can't change the current directory of its parent (except by doing tricky and very discouraged things: &lt;a href=&quot;https://stackoverflow.com/questions/2375003/how-do-i-set-the-working-directory-of-the-parent-process&quot;&gt;https://stackoverflow.com/questions/2375003/how-do-i-set-the-working-directory-of-the-parent-process&lt;/a&gt;). You may also want to read: &lt;a href=&quot;https://unix.stackexchange.com/questions/141313/chdirdirectory-doesnt-change-directory-after-exiting-to-shell&quot;&gt;https://unix.stackexchange.com/questions/141313/chdirdirectory-doesnt-change-directory-after-exiting-to-shell&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Maybe&lt;/strong&gt; you could achieve writing a tiny vimscript launched at startup and printing the current directory (of the child process being vim) when exiting, and write some bash alias for something like &lt;code&gt;cd `vim -c ...`&lt;/code&gt;. But why on earth would you do such a tricky thing?&lt;/p&gt;&#xA;" OwnerUserId="5139" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-11-14T18:27:12.243" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5477" PostTypeId="2" ParentId="5475" CreationDate="2015-11-14T18:43:00.060" Score="2" Body="&lt;p&gt;You could, but it would take a little scripting: adding to netrw and writing a bash function wrapper for vim. &lt;a href=&quot;http://ranger.nongnu.org/&quot; rel=&quot;nofollow&quot;&gt;Ranger&lt;/a&gt;, a file manager with vi key bindings, and &lt;a href=&quot;http://linux.die.net/man/1/wcd&quot; rel=&quot;nofollow&quot;&gt;wcd&lt;/a&gt;, Wherever Change Directory, do this. Take a look at their documentation for examples. The idea is that you add a shell function, named &lt;code&gt;ranger&lt;/code&gt; or &lt;code&gt;wcd&lt;/code&gt;, respectively, to your &lt;code&gt;~/.bashrc&lt;/code&gt;, which calls the actual program. The user uses the features of the program to select the new directory which the program then writes to a temporary file, then exits. The function reads the new directory name from that temporary file and cd's to it. In your case, you would have to add a command to Vim to write the current directory (selected by netrw) to a temporary file, then exit Vim. Your &lt;code&gt;vim&lt;/code&gt; wrapper function would then read that file and cd to the directory it names.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-11-14T18:43:00.060" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5478" PostTypeId="2" ParentId="5333" CreationDate="2015-11-14T19:42:05.227" Score="-1" Body="&lt;p&gt;If you're amenable to a plugin, perhaps this is an option:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/matze/vim-move&quot; rel=&quot;nofollow&quot;&gt;vim-move&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2498" LastActivityDate="2015-11-14T19:42:05.227" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5479" PostTypeId="2" ParentId="5348" CreationDate="2015-11-14T21:49:49.987" Score="11" Body="&lt;p&gt;As far as I know vim has this feature because the GUI vim (gvim) uses the graphical X server. I am aware that non GUI Vim can also use the &lt;code&gt;--servername&lt;/code&gt; argument but &lt;em&gt;only when X11 is running and also by accessing to it&lt;/em&gt;. On the other hand, neovim has no graphical support; for that reason, I don't think that the &lt;code&gt;--servername&lt;/code&gt; option can work (unless the option would have been fully rewritten in another way) since I would find strange to have a console program accessing the X11 server only for that purpose.&lt;/p&gt;&#xA;" OwnerUserId="5139" LastActivityDate="2015-11-14T21:49:49.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5480" PostTypeId="2" ParentId="5441" CreationDate="2015-11-14T22:00:52.193" Score="6" Body="&lt;p&gt;It is completely possible to do what you want. Some of the others have said about filetype plugins which work well for that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you can source and .vim file in your vimrc so you can split the .vimrc into as many files as you would like. Just source the file and it will work. As a example here is my (probably not very useful) dotfiles. &lt;a href=&quot;https://github.com/dspecht/dotfiles/&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/dspecht/dotfiles/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5306" LastActivityDate="2015-11-14T22:00:52.193" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5481" PostTypeId="1" CreationDate="2015-11-14T23:47:13.503" Score="1" ViewCount="254" Body="&lt;p&gt;I'm writing a remote neovim plugin that automatically inserts parens into the buffer based on &lt;a href=&quot;http://shaunlebron.github.io/parinfer/&quot; rel=&quot;nofollow&quot;&gt;http://shaunlebron.github.io/parinfer/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm struggling to figure out is how can I get &lt;code&gt;:undojoin&lt;/code&gt; like behavior when I modify the buffer through the plugin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance given this line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(let [foo bar] foo)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I hit &lt;code&gt;D&lt;/code&gt; while at the &lt;code&gt;let&lt;/code&gt; the plugin will modify the buffer by adding back the trailing paren to be the desired line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(let)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the undo history now contains two entries in the stack, at the top is the plugin's modification adding the &lt;code&gt;)&lt;/code&gt; followed by the deletion. If I undo here, the buffer changes to &lt;code&gt;(let&lt;/code&gt; and the plugin reads the paren and I'm stuck in a loop unable to undo the original deletion.&lt;/p&gt;&#xA;" OwnerUserId="5307" LastEditorUserId="51" LastEditDate="2016-03-02T21:07:30.623" LastActivityDate="2016-03-02T21:07:30.623" Title="How to undojoin changes made from neovim remote plugin on TextChanged" Tags="|vimscript|neovim|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5482" PostTypeId="2" ParentId="5461" CreationDate="2015-11-15T02:36:00.943" Score="1" Body="&lt;p&gt;I created a &lt;a href=&quot;https://github.com/cbaumhardt/vim-commentary-boxed&quot; rel=&quot;nofollow&quot;&gt;plugin&lt;/a&gt; which does exactly that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just plug it in into your &lt;code&gt;.vimrc&lt;/code&gt;, e.g. using &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow&quot;&gt;vim-plug&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'cbaumhardt/vim-commentary-boxed'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After installing, define a custom mapping in your &lt;code&gt;.virmc&lt;/code&gt;, e.g. &lt;code&gt;&amp;lt;leader&amp;gt;b&lt;/code&gt;, and you are all set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :&amp;lt;C-u&amp;gt;call ToggleBox()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Calling &lt;code&gt;&amp;lt;leader&amp;gt;b&lt;/code&gt; will toggle a boxed comment for a line. It accepts counts too, e.g. &lt;code&gt;4&amp;lt;leader&amp;gt;b&lt;/code&gt;.&#xA;Please &lt;a href=&quot;https://github.com/cbaumhardt/vim-commentary-boxed#examples&quot; rel=&quot;nofollow&quot;&gt;see the examples&lt;/a&gt; for further explanation.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastEditorUserId="3282" LastEditDate="2015-11-15T20:18:31.180" LastActivityDate="2015-11-15T20:18:31.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5483" PostTypeId="2" ParentId="5469" CreationDate="2015-11-15T10:24:38.150" Score="1" Body="&lt;p&gt;Since a final sigma is quickly followed with a space &lt;em&gt;even if a punctuation marks immediately followf it&lt;/em&gt; (except for the end-of-line case), you could do this: define the folowwing function (in your &lt;code&gt;~/.vimrc&lt;/code&gt; file) and remap the &lt;em&gt;space&lt;/em&gt; key in insert mode to this function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; The function checks whether a final greek sigma to be fixed can be found&#xA;&quot; on the same line at the left of the cursor; the function should be accessed&#xA;&quot; through a mapping of the space key in insert mode (since even punctuation&#xA;&quot; marks are flollowed with a space.&#xA;function! FixPreviousSigma()&#xA;    let l:l = line(&quot;.&quot;)&#xA;    let l:c = col(&quot;.&quot;)&#xA;    let l:s = search('σ\&amp;gt;', 'bcW', l:l)&#xA;    if l:s == l:l&#xA;        silent execute &quot;normal rς&quot;&#xA;    endif&#xA;    call cursor(l:l, l:c)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then use the tricky mapping whenever you need to use this feature:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;Space&amp;gt; &amp;lt;ESC&amp;gt;:call FixPreviousSigma()&amp;lt;CR&amp;gt;a&amp;lt;C-v&amp;gt;&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you also want to take into account the end-of-line case, maybe you could also try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;Enter&amp;gt; &amp;lt;ESC&amp;gt;:callFixPreviousSigma()&amp;lt;CR&amp;gt;o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5139" LastEditorUserId="5139" LastEditDate="2015-11-15T13:46:49.437" LastActivityDate="2015-11-15T13:46:49.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5484" PostTypeId="1" AcceptedAnswerId="5485" CreationDate="2015-11-15T15:09:45.510" Score="20" ViewCount="9682" Body="&lt;p&gt;In python, when using the vim module, it is incredibly simple to get the current window/buffer/tabpage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;current_win = vim.current.window&#xA;current_buff = vim.current.buffer&#xA;current_tabpage = vim.current.tabpage&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is, how do you do this in pure VimL / Vimscript and what type of object is returned? I really can't seem to find this anywhere in &lt;code&gt;windows.txt&lt;/code&gt; (&lt;code&gt;:h windows&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="5022" LastEditorUserId="205" LastEditDate="2015-11-15T21:06:36.173" LastActivityDate="2015-11-16T06:02:56.083" Title="Get the current window/buffer/tabpage in Vimscript" Tags="|vimscript|vim-windows|macvim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5485" PostTypeId="2" ParentId="5484" CreationDate="2015-11-15T16:41:54.263" Score="28" Body="&lt;p&gt;Well… it's just as simple in vimscript.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Current window&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;current_win = vim.current.window&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let current_win = winnr()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Current buffer&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;current_buff = vim.current.buffer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let current_buff = bufnr(&quot;%&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Current tabpage&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;current_tabpage = vim.current.tabpage&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let current_tabpage = tabpagenr()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help functions&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-11-16T06:02:56.083" LastActivityDate="2015-11-16T06:02:56.083" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5486" PostTypeId="2" ParentId="5470" CreationDate="2015-11-15T18:47:07.343" Score="1" Body="&lt;p&gt;A simple solution is to use the &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; key which I have chosen to map to &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;space&amp;gt; &amp;lt;Leader&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;/ 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure there are no spaces after the 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another useful mapping for Thai is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;ไ W&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This resolves the conflict on the Thai keyboard with the &lt;code&gt;&quot;&lt;/code&gt; key while removing the need to include the &lt;code&gt;&amp;lt;shift&amp;gt;&lt;/code&gt; key.&lt;/p&gt;&#xA;" OwnerUserId="5049" LastActivityDate="2015-11-15T18:47:07.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5487" PostTypeId="1" CreationDate="2015-11-16T05:33:00.893" Score="2" ViewCount="98" Body="&lt;p&gt;When horizontally splitting windows in vim, the content which is being edited will float up or down based on the position of the newly created window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, when editing a C file in vim, and I want to autocomplete functions via YCM, hitting &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Space&lt;/kbd&gt; causes a new preview window to appear either at the top or bottom. The line which I am editing will float down or up, and that makes my eyes out of focus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I disable such a float?&lt;/p&gt;&#xA;" OwnerUserId="5315" LastEditorUserId="6489" LastEditDate="2016-07-20T00:03:04.920" LastActivityDate="2016-07-20T00:03:04.920" Title="Prevent the float of current line from the horizontal window splitting in vim" Tags="|vim-windows|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5488" PostTypeId="1" CreationDate="2015-11-16T07:34:28.017" Score="18" ViewCount="5393" Body="&lt;p&gt;Today I learned how to fold/unfold in Vim; it's quite handy.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unexpectedly, when I exit a file and reenter it, the folds I created are gone (unfolded).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In our company's large project there are quite a lot of sticky (legacy) code blocks which are kind of obsolete but indispensable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really need to fold them nearly permanently.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a brief way to tell Vim to save my folding preferences for a file? &lt;/p&gt;&#xA;" OwnerUserId="3085" LastEditorUserId="2920" LastEditDate="2018-12-04T22:24:05.610" LastActivityDate="2023-06-26T01:45:06.183" Title="Can I save folds?" Tags="|folding|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5489" PostTypeId="1" AcceptedAnswerId="5490" CreationDate="2015-11-16T07:39:30.840" Score="9" ViewCount="6252" Body="&lt;p&gt;I'm reworking a section of logic in some C code to avoid a memory leak that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (result) {&#xA;case CASE_1:&#xA;     return report(...);&#xA;case CASE_2:&#xA;     return report(...);&#xA;/*&#xA; * More cases follow with the same pattern.&#xA; */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've used &lt;code&gt;%s/return report/report/&lt;/code&gt; to remove the &lt;code&gt;return&lt;/code&gt; statements, but now I need to add a line with &lt;code&gt;break;&lt;/code&gt; after that, so the final result resembles something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (result) {&#xA;case CASE_1:&#xA;     report(...);&#xA;     break;&#xA;case CASE_2:&#xA;     report(...);&#xA;     break;&#xA;/*&#xA; * More cases follow with the same pattern.&#xA; */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried using the &lt;code&gt;global&lt;/code&gt; command to execute the &lt;code&gt;append&lt;/code&gt; command with no success:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Error &quot;E448: Trailing characters&quot; (potential bug in Vim?)&#xA;:g/report(&quot;/a\&#xA;     break;&#xA;&#xA;# Appends nothing and does not wait for text to be input.&#xA;:g/report(&quot;/a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Trying the above in ex mode with Vim fails, and visual mode doesn't seem to work well with the insertion commands in general, regardless of the variant of vi. If I omit the &lt;code&gt;global&lt;/code&gt; command, it will work: I can enter text and type a single &quot;.&quot; character on a line by itself to return to command mode (or visual mode, depending on which mode I was in). However, this cannot be repeated using the &lt;kbd&gt;.&lt;/kbd&gt; key in visual mode because it's an ex command, not a motion command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In an unusual twist, the first attempt works in ex mode with the port of &lt;a href=&quot;http://ex-vi.sourceforge.net/&quot;&gt;&quot;The Traditional Vi&quot;&lt;/a&gt; and even &lt;code&gt;ed&lt;/code&gt; of all things, though nothing is auto-indented due to the usage of to the &lt;code&gt;global&lt;/code&gt; command. That's fine anyway since the structure is predictable enough to manually insert indentation characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also attempted the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/report(&quot;.*$/&amp;amp;\&#xA;    break;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the result of one line as displayed by Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    report(&quot;No match&quot;);^@&#xA;break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anybody explain how to use the &lt;code&gt;global&lt;/code&gt; command with the &lt;code&gt;append&lt;/code&gt; command to append one or even more than one line of text in Vim, even if I have to leave visual mode to do it?&lt;/p&gt;&#xA;" OwnerDisplayName="user5316" LastActivityDate="2015-11-16T09:38:28.160" Title="Append lines of text after pattern using global command" Tags="|ex-mode|global-command|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5490" PostTypeId="2" ParentId="5489" CreationDate="2015-11-16T08:23:47.413" Score="10" Body="&lt;p&gt;If I understand your post correctly, you had this snippet of C code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (result) {&#xA;case CASE_1:&#xA;     return report(&quot;...&quot;);&#xA;case CASE_2:&#xA;     return report(&quot;...&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you wanted to transform it to :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (result) {&#xA;case CASE_1:&#xA;     report(&quot;...&quot;);&#xA;     break;&#xA;case CASE_2:&#xA;     report(&quot;...&quot;);&#xA;     break;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know all the details of the global command, but here's how I would do it :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/return report/normal! _dawobreak;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The global command searches the pattern &lt;code&gt;return report&lt;/code&gt;, then on each line that matches this pattern, it executes the following command :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! _dawobreak;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;normal&lt;/code&gt; command types every character that follows as if we were in normal mode. Here it reads &lt;code&gt;_dawobreak;&lt;/code&gt; as a sequence of keystrokes that can be broken down like this :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;_&lt;/code&gt; = go to first non whitespace character&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;daw&lt;/code&gt; = delete a word (including the space after it)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&lt;/code&gt; = open a new line under the current one&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;break;&lt;/code&gt; = insert &lt;code&gt;break;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The exclamation mark after the &lt;code&gt;normal&lt;/code&gt; command, is to prevent recursiveness.&lt;br&gt;&#xA;It means : &lt;em&gt;if inside the sequence of keystrokes you detect a subsequence corresponding to a mapping, don't interpret it.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-16T09:21:13.020" LastActivityDate="2015-11-16T09:21:13.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5491" PostTypeId="2" ParentId="5489" CreationDate="2015-11-16T09:38:28.160" Score="6" Body="&lt;p&gt;One way to do it is to use the widely underappreciated &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5Czs&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\zs&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/report.*\zs/\r     break;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this does is, look at lines containing &lt;code&gt;report&lt;/code&gt;, find end of line, and add a new line with &lt;code&gt;break&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also achieve the same thing with &lt;code&gt;global&lt;/code&gt;, but that would just complicate the command for no reason.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2015-11-16T09:38:28.160" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5492" PostTypeId="1" AcceptedAnswerId="5493" CreationDate="2015-11-16T10:57:29.733" Score="10" ViewCount="1142" Body="&lt;pre&gt;&lt;code&gt;Old text             Command         New text&#xA;Hello *world         ysiw(           Hello ( world )&#xA;Hello *world         ysiwb           Hello (world)&#xA;Hello *world          ysiw)           Hello (world)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does vim-surround add spaces to the first example, and is there a way to disable this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where the asterisk denotes cursor position&lt;/p&gt;&#xA;" OwnerUserId="5319" LastActivityDate="2015-11-16T11:23:53.057" Title="Why does vim surround add spaces in this example?" Tags="|plugin-vim-surround|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5493" PostTypeId="2" ParentId="5492" CreationDate="2015-11-16T11:23:53.057" Score="14" Body="&lt;p&gt;The plugin vim surround allows you to &lt;em&gt;choose&lt;/em&gt; whether you want spaces and parenthesis or just parenthesis. You can disable it by using other mappings; &lt;em&gt;actually you pasted them in your question, as the second and third examples&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is actually a pattern in the mappings of this plugin: if you use the opening character - e.g.: &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;[&lt;/code&gt; - them it will include spaces. If you use the closing character - e.g.: &lt;code&gt;)&lt;/code&gt;, &lt;code&gt;}&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; - them it won't include spaces. The aliases for these blocks (&lt;code&gt;b&lt;/code&gt;, &lt;code&gt;B&lt;/code&gt; and &lt;code&gt;r&lt;/code&gt;) also doesn't includes the spaces, probably because most of time the people (like you) doesn't want the spaces.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-11-16T11:23:53.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5494" PostTypeId="1" CreationDate="2015-11-16T11:26:07.480" Score="1" ViewCount="370" Body="&lt;p&gt;I've installed the Ultisnips plugin with Pathogen. All in all it seems to be working fine.&#xA;My problem is that it doesn't seem to work for the first python file I load, but it works for all the rest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's a list of the plugins I currently have installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctrlp.vim  nose.vim  syntastic  ultisnips       vim-easymotion  vim-snippets&#xA;jedi-vim   supertab  vim-commentary   vim-fugitive    vim-surround&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Part of my .vimrc related to Ultisnips and SuperTab:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:SuperTabDefaultCompletionType = &quot;context&quot;&#xA;let g:UltiSnipsUsePythonVersion = 2&#xA;&quot; Set ultisnips triggers&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;tab&amp;gt;&quot;                                            &#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;tab&amp;gt;&quot;                                       &#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;s-tab&amp;gt;&quot;&#xA;let g:ultisnips_python_style = &quot;sphinx&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Has any one else encountered something similar?&lt;/p&gt;&#xA;" OwnerUserId="5320" LastActivityDate="2015-11-16T11:26:07.480" Title="Ultisnips not working on first load of python file" Tags="|filetype-python|plugin-ultisnips|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5495" PostTypeId="1" AcceptedAnswerId="5497" CreationDate="2015-11-16T13:00:49.193" Score="18" ViewCount="3164" Body="&lt;p&gt;I'm trying to understand how can I use operator with subsequent motion inside a mapping. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap /c c{here we pending for a motion}/&amp;lt;C-r&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The map should do the following: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Activate &lt;code&gt;c&lt;/code&gt; operator and listen for the next motion;&lt;/li&gt;&#xA;&lt;li&gt;Eg, I can type here &lt;code&gt;t,&lt;/code&gt; to change everything before the next comma;&lt;/li&gt;&#xA;&lt;li&gt;Go to insert mode deleting everything between cursor and the comma;&lt;/li&gt;&#xA;&lt;li&gt;Deleted text is automatically searched as a pattern &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So to put it simple, after motion text is removed, I'm leaved in insert mode with highlighted occurrences of the deleted text. I would be very grateful if somebody help me to puzzle out this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answers are almost what I want. But!  When I press &lt;code&gt;/cw&lt;/code&gt;, type something instead of the word, then press &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. After I expect to do the same with the next occurrences. But after presing &lt;code&gt;n&lt;/code&gt; (go to next occurrence) and &lt;code&gt;.&lt;/code&gt; (repeat last command) it just prepend last typed text instead of replacing it. The main goal of the mapping is using it with &lt;code&gt;n/N&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt; to repeat. Have I missed something?&lt;/p&gt;&#xA;" OwnerUserId="5321" LastEditorUserId="5321" LastEditDate="2015-11-16T15:16:37.243" LastActivityDate="2016-07-11T01:53:30.633" Title="Mapping with motion" Tags="|key-bindings|cursor-movement|search|cursor-motions|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5496" PostTypeId="2" ParentId="5495" CreationDate="2015-11-16T13:29:15.803" Score="4" Body="&lt;p&gt;It is easier to implement (and to document) complex mappings by using functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DoMagic()&#xA;   execute &quot;normal! d&quot;.input(&quot;enter motion: &quot;)&#xA;   let @/=@&quot;&#xA;   startinsert&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then make your mapping call that function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap /c :call DoMagic()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your intention is to perform search &amp;amp; replace in a large number of places you should try the substitute command: &lt;code&gt;:s&lt;/code&gt;. You could change your mapping to copy the visual selection to the search pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DoMagic2()&#xA;   normal! gv&quot;ay&#xA;   return @a&#xA;endfunction&#xA;&#xA;vmap /c :&amp;lt;c-w&amp;gt;%s/&amp;lt;C-r&amp;gt;=DoMagic2()&amp;lt;CR&amp;gt;//gc&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2015-11-16T15:41:55.497" LastActivityDate="2015-11-16T15:41:55.497" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5497" PostTypeId="2" ParentId="5495" CreationDate="2015-11-16T14:53:13.603" Score="12" Body="&lt;p&gt;vim supports operator-mapping  &lt;code&gt;:h map-operator&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need is an &lt;code&gt;operatorfunc&lt;/code&gt;, and a mapping. for your needs, the followings codes work. Well it is just an example, you refine further.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap  &amp;lt;silent&amp;gt; /c :set opfunc=SpecialChange&amp;lt;CR&amp;gt;g@&#xA;function! SpecialChange(type)&#xA;    silent exec 'normal! `[v`]d'    &#xA;    silent exec 'let @/=@&quot;' &#xA;    startinsert&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &#xA;    &lt;code&gt;exec 'let @/=@&quot;'&lt;/code&gt; just for highlighting the codes in buffer. If you don't want to see the highlighting immediately, you can just &lt;code&gt;let @/=@&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1569" LastEditorUserId="1569" LastEditDate="2015-11-16T15:33:14.867" LastActivityDate="2015-11-16T15:33:14.867" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5499" PostTypeId="1" CreationDate="2015-11-16T18:27:50.783" Score="1" ViewCount="338" Body="&lt;p&gt;How can I make linker errors jumpable in quickfix?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int foo(void);&#xA;&#xA;int main(int argc, char* argv[]) {&#xA;    foo();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Start up vim and run &lt;code&gt;:set makeprg=gcc\ %&lt;/code&gt; and try &lt;code&gt;:make&lt;/code&gt;. This produces a linker error and gives a press enter prompt. If I then check &lt;code&gt;:copen&lt;/code&gt; the linker error is there but prefixed with &lt;code&gt;||&lt;/code&gt; and can't be jumped to. I want to be able to jump to the file, or even the reference itself if possible, when linker errors like this occur.&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2016-02-24T22:49:32.587" Title="Jump to linker errors in quickfix" Tags="|quickfix|errorformat|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="5500" PostTypeId="2" ParentId="5354" CreationDate="2015-11-16T20:42:53.810" Score="30" Body="&lt;p&gt;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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;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:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;$ ls -l /proc/$(pgrep -n vim)/fd/&#xA;total 0&#xA;lrwx------ 1 muru muru 64 Nov 17 01:25 0 -&amp;gt; /dev/pts/14&#xA;lrwx------ 1 muru muru 64 Nov 17 01:25 1 -&amp;gt; /dev/pts/14&#xA;lrwx------ 1 muru muru 64 Nov 17 01:25 2 -&amp;gt; /dev/pts/14&#xA;lrwx------ 1 muru muru 64 Nov 17 01:25 3 -&amp;gt; socket:[99564312]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, my initial few attempts failed:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;echo '^[:wq^M' &amp;gt; /proc/$(pgrep -n vim)/fd/0&#xA;echo ':wq^M' &amp;gt; /proc/$(pgrep -n vim)/fd/0&#xA;echo ':wq^M' &amp;gt; /proc/$(pgrep -n vim)/fd/0&#xA;echo '^C' &amp;gt; /proc/$(pgrep -n vim)/fd/0&#xA;printf &quot;%s&quot; '^[:wqa!^M' &amp;gt; /proc/$(pgrep -n vim)/fd/0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sub&gt;The &lt;code&gt;^[&lt;/code&gt; and &lt;code&gt;^M&lt;/code&gt; were obtained by &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;, respectively.&lt;/sub&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They all resulted in the characters showing up on the terminal (I was testing this out locally, before applying it to the remote session). Googling around, I found &lt;a href=&quot;https://stackoverflow.com/a/20386980/2072269&quot;&gt;this SO post&lt;/a&gt;, using Python to write to the pseudoterminal device:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;#!/usr/bin/python&#xA;&#xA;import sys,os,fcntl,termios&#xA;if len(sys.argv) != 3:&#xA;   sys.stderr.write(&quot;usage: ttyexec.py tty command\n&quot;)&#xA;   sys.exit(1)&#xA;fd = os.open(&quot;/dev/&quot; + sys.argv[1], os.O_RDWR)&#xA;cmd=sys.argv[2]&#xA;for i in range(len(cmd)):&#xA;   fcntl.ioctl(fd, termios.TIOCSTI, cmd[i])&#xA;fcntl.ioctl(fd, termios.TIOCSTI, '\n')&#xA;os.close(fd)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And trying it out on an interactive python shell worked:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;$ sudo python3&#xA;Python 3.5.0 (default, Sep 20 2015, 11:28:25) &#xA;[GCC 5.2.0] on linux&#xA;Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.&#xA;&amp;gt;&amp;gt;&amp;gt; import os, fcntl, termios&#xA;&amp;gt;&amp;gt;&amp;gt; fd = os.open('/dev/pts/14', os.O_RDWR)&#xA;&amp;gt;&amp;gt;&amp;gt; a = '\033:wqa!\n'&#xA;&amp;gt;&amp;gt;&amp;gt; for i in a: fcntl.ioctl(fd, termios.TIOCSTI, i);&#xA;... &#xA;b'\x1b'&#xA;b':'&#xA;b'w'&#xA;b'q'&#xA;b'a'&#xA;b'!'&#xA;b'\n'&#xA;&amp;gt;&amp;gt;&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Done!&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-05-26T10:34:14.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5501" PostTypeId="1" AcceptedAnswerId="5503" CreationDate="2015-11-16T20:43:14.187" Score="8" ViewCount="1718" Body="&lt;p&gt;Is it possible to programmatically let a function knows its own name?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am looking for is something which would allow me to write this code (or something similar):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! myUtils#TestMe() abort&#xA;    let l:_self = &quot; a way to get the current function name&#xA;    echom l:_self&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which, once called with &lt;code&gt;:call myUtils#TestMe()&lt;/code&gt; would print:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myUtils#TestMe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="1841" LastEditDate="2016-04-03T10:28:36.660" LastActivityDate="2021-12-22T06:05:24.227" Title="Is there a way to get the name of the current function in vim-script?" Tags="|vimscript|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5502" PostTypeId="1" CreationDate="2015-11-16T21:41:33.677" Score="4" ViewCount="1131" Body="&lt;p&gt;I want to write c++ code in vim using &lt;a href=&quot;https://en.wikipedia.org/wiki/Indent_style#Lisp_style&quot; rel=&quot;nofollow&quot;&gt;lisp indentation style&lt;/a&gt; (closing curly braces on the same line as last statement) but I can't figure out how to configure indentation to use that style. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any workaround to use and indent end curly braces at the end of block (rather than at the next line)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int func() {&#xA;    print(&quot;Hello\n&quot;);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like vim to recognise this formatting and indent next line properly.&#xA;Normally, Vim doesn't recognise the curly brace at the end of line as end of block and use the same indent as previous line.&lt;/p&gt;&#xA;" OwnerUserId="5329" LastEditorUserId="5329" LastEditDate="2015-11-17T20:51:17.677" LastActivityDate="2016-02-16T20:41:58.467" Title="Indenting c/c++ using lisp indentation style" Tags="|indentation|filetype-c++|filetype-c|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5503" PostTypeId="2" ParentId="5501" CreationDate="2015-11-16T22:00:03.593" Score="13" Body="&lt;p&gt;Yes, there is :) Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Testing()&#xA;    &quot; this is the droid you're looking for&#xA;    echo substitute(expand('&amp;lt;sfile&amp;gt;'), '.*\(\.\.\|\s\)', '', '')&#xA;    &quot; compare with this (not what you want, just for reference)&#xA;    echo expand('&amp;lt;sfile&amp;gt;')&#xA;endfunction&#xA;&#xA;function! OutsideTesting()&#xA;    call Testing()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the test:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call Testing()&#xA;:call OutsideTesting()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Surprisingly perhaps, the solution is based on &lt;code&gt;&amp;lt;sfile&amp;gt;&lt;/code&gt;, which returns something like &lt;code&gt;function Testing&lt;/code&gt; (if called directly from &lt;code&gt;Testing&lt;/code&gt;) or &lt;code&gt;function OutsideTesting..Testing&lt;/code&gt;, if called from the &quot;outer&quot; function. See &lt;code&gt;:h &amp;lt;sfile&amp;gt;&lt;/code&gt;. The &lt;code&gt;substitute()&lt;/code&gt; call removes the first part of the expansion and leaves only the inner function name (you can also change the substitution pattern to leave only the outer function name instead - depends on what you want).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-11-16T22:39:29.767" LastActivityDate="2015-11-16T22:39:29.767" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5504" PostTypeId="1" CreationDate="2015-11-17T03:12:09.307" Score="1" ViewCount="392" Body="&lt;p&gt;I'm running into a weird behaviour where I'm editing a file and saving it with the :w command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is it leaves behind the 'w' character after my line of edit. It doesn't do it all the time but its often enough to become a problem. The actual 'w' character isn't there because if I close and reopen the file, character disappear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure whats causing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    activate() {&#xA;        return this.productService&#xA;            .getAll()&#xA;            .then(products = this.products = products);**w**&#xA;    }&#xA;&#xA;NOTE: the 'w' after the semi-colon.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;:verb au BufWrite&lt;/strong&gt; produced:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Auto Command ---&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;:verb au BufWritePost&lt;/strong&gt; produced:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Auto-Commands ---&#xA;airline  BufWritePost&#xA;    */autoload/airline/themes/*.vim&#xA;              exec 'source '.split(globpath(&amp;amp;rtp, 'autoload/airline/themes/'.g:airline_theme.'.vim', 1), &quot;\n&quot;)[0] | call airline#load_theme()&#xA;        Last set from ~/.vim/bundle/airline/plugin/airline.vim&#xA;CtrlPMRUF  BufWritePost&#xA;    *         cal s:record(expand('&amp;lt;abuf&amp;gt;', 1))&#xA;        Last set from ~/.vim/bundle/ctrlp/autoload/ctrlp/mrufiles.vim&#xA;gitgutter  BufWritePost&#xA;    *         if gettabvar(tabpagenr(), 'gitgutter_didtabenter') |   call settabvar(tabpagenr(), 'gitgutter_didtabenter', 0) | else |   call gitgutter#process_buffer(bufnr(''), 0) | endif&#xA;        Last set from ~/.vim/bundle/gitgutter/plugin/gitgutter.vim&#xA;syntastic  BufWritePost&#xA;    *         call s:BufWritePostHook()&#xA;        Last set from ~/.vim/bundle/syntastic/plugin/syntastic.vim&#xA;gzip  BufWritePost&#xA;    *.gz      call gzip#write(&quot;gzip&quot;)&#xA;        Last set from /usr/local/Cellar/vim/7.4.712_1/share/vim/vim74/plugin/gzip.vim&#xA;    *.bz2     call gzip#write(&quot;bzip2&quot;)&#xA;        Last set from /usr/local/Cellar/vim/7.4.712_1/share/vim/vim74/plugin/gzip.vim&#xA;    *.Z       call gzip#write(&quot;compress -f&quot;)&#xA;        Last set from /usr/local/Cellar/vim/7.4.712_1/share/vim/vim74/plugin/gzip.vim&#xA;    *.lzma    call gzip#write(&quot;lzma -z&quot;)&#xA;        Last set from /usr/local/Cellar/vim/7.4.712_1/share/vim/vim74/plugin/gzip.vim&#xA;    *.xz      call gzip#write(&quot;xz -z&quot;)&#xA;        Last set from /usr/local/Cellar/vim/7.4.712_1/share/vim/vim74/plugin/gzip.vim&#xA;BufWritePost&#xA;    &amp;lt;buffer=1&amp;gt;&#xA;              call s:JSHint()&#xA;        Last set from ~/.vim/bundle/jshint/ftplugin/javascript/jshint.vim&#xA;airline_whitespace  BufWritePost&#xA;    *         unlet! b:airline_whitespace_check&#xA;        Last set from ~/.vim/bundle/airline/autoload/airline/extensions/whitespace.vim&#xA;TagbarAutoCmds  BufWritePost&#xA;    *         call s:AutoUpdate(fnamemodify(expand('&amp;lt;afile&amp;gt;'), ':p'), 1)&#xA;        Last set from ~/.vim/bundle/tagbar/autoload/tagbar.vim&#xA;BufWritePost&#xA;    &amp;lt;buffer=7&amp;gt;&#xA;              call s:JSHint()&#xA;        Last set from ~/.vim/bundle/jshint/ftplugin/javascript/jshint.vim&#xA;    &amp;lt;buffer=15&amp;gt;&#xA;              call s:JSHint()&#xA;        Last set from ~/.vim/bundle/jshint/ftplugin/javascript/jshint.vim&#xA;    &amp;lt;buffer=34&amp;gt;&#xA;              call s:JSHint()&#xA;        Last set from ~/.vim/bundle/jshint/ftplugin/javascript/jshint.vim&#xA;    &amp;lt;buffer=54&amp;gt;&#xA;              call s:JSHint()&#xA;        Last set from ~/.vim/bundle/jshint/ftplugin/javascript/jshint.vim&#xA;    &amp;lt;buffer=55&amp;gt;&#xA;              call s:JSHint()&#xA;        Last set from ~/.vim/bundle/jshint/ftplugin/javascript/jshint.vim&#xA;    &amp;lt;buffer=56&amp;gt;&#xA;              call s:JSHint()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2129" LastEditorUserId="2129" LastEditDate="2015-11-17T04:59:48.223" LastActivityDate="2015-11-17T04:59:48.223" Title="Vim leaving behind character after saving with :w not sure why" Tags="|terminal|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5505" PostTypeId="1" AcceptedAnswerId="5509" CreationDate="2015-11-17T11:47:21.327" Score="1" ViewCount="67" Body="&lt;p&gt;I have this keymap: &lt;code&gt;map &amp;lt;F3&amp;gt; :hi Tab gui=underline guifg=8 ctermbg=8&amp;lt;CR&amp;gt;&lt;/code&gt; and I know that, I can clear group by &lt;code&gt;:hi clear Tab&lt;/code&gt;, but how to map only F3 to do this? I want one key to turn on/off this higlight group, like: &lt;code&gt;map &amp;lt;F3&amp;gt; :set number!&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards.&lt;/p&gt;&#xA;" OwnerUserId="5335" LastActivityDate="2015-11-17T18:16:15.203" Title="Keybindings to turn on/off higlight group" Tags="|key-bindings|highlight|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5506" PostTypeId="2" ParentId="5505" CreationDate="2015-11-17T12:58:33.053" Score="1" Body="&lt;p&gt;I may be wrong but I don't think you can give a decimal number as a value for the &lt;code&gt;guifg&lt;/code&gt; attribute (&lt;code&gt;guifg=8&lt;/code&gt;).&lt;br&gt;&#xA;When I type &lt;code&gt;:hi Tab gui=underline guifg=8 ctermbg=8&lt;/code&gt; inside a terminal it works, but inside a gui, gvim returns the error message &lt;code&gt;E254: Cannot allocate color8&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what the help says about this error (&lt;code&gt;:help e254&lt;/code&gt;) :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The color name {name} is unknown.  See |gui-colors| for a list of&#xA;  colors that are available on most systems.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And the help about gui-colors (&lt;code&gt;:help gui-colors&lt;/code&gt;) talks about color names, or hexadecimal values in the form of &lt;code&gt;#rrggbb&lt;/code&gt; (&lt;code&gt;#rr&lt;/code&gt;= red, &lt;code&gt;#gg&lt;/code&gt;=green, &lt;code&gt;#bb&lt;/code&gt;=blue).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But maybe I misunderstood something. Anyway, concerning your problem, here's what I would do.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Find a way to get the value of one of the attributes that I want to set.&lt;br&gt;&#xA;For example, you want to give to the &lt;code&gt;guifg&lt;/code&gt; attribute of the Tab highlight group the value of 8. To get this value from a vim script you can use this expression :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;synIDattr(hlID('Tab'), 'fg#')&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Assign this value to a variable :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let guifgcolor=synIDattr(hlID('Tab'), 'fg#')&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Write a function that tests the value of the variable. If it's not the one that I want (8 in this example), then execute the command &lt;code&gt;hi Tab gui=underline guifg=8 ctermbg=8&lt;/code&gt; and if it is then execute &lt;code&gt;hi clear Tab&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Write a mapping that calls the function.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It could give something like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleHighlightGroup()&#xA;&#xA;    let guifgcolor=synIDattr(hlID('Tab'), 'fg#')&#xA;&#xA;    if guifgcolor == 8&#xA;        highlight clear Tab&#xA;    else&#xA;        highlight Tab gui=underline guifg=8 ctermbg=8&#xA;    endif&#xA;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;F3&amp;gt; :&amp;lt;c-u&amp;gt;call ToggleHighlightGroup()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit : &lt;a href=&quot;https://vi.stackexchange.com/questions/5505/keybindings-to-turn-on-off-higlight-group#comment8502_5506&quot;&gt;VanLaser&lt;/a&gt; suggests a good &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/38.html&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt; that explains how to toggle an option in more details.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-17T14:20:16.887" LastActivityDate="2015-11-17T14:20:16.887" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5507" PostTypeId="2" ParentId="2387" CreationDate="2015-11-17T13:46:48.483" Score="1" Body="&lt;p&gt;Noticed this error when I had forgot to start the line with &lt;code&gt;:&lt;/code&gt; in &lt;code&gt;.viminfo&lt;/code&gt; file for example &lt;code&gt;set tabstop=4&lt;/code&gt;. To get rid of this error had to add &lt;code&gt;:&lt;/code&gt; at the beginning of the line as below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set tabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5337" LastEditorUserId="205" LastEditDate="2015-11-17T15:40:01.693" LastActivityDate="2015-11-17T15:40:01.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5508" PostTypeId="1" AcceptedAnswerId="5584" CreationDate="2015-11-17T16:19:17.053" Score="3" ViewCount="3276" Body="&lt;p&gt;I'm trying to navigate to next dot in a file using windows version of vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it doesn't do anything as well as all other similar commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;F.&#xA;d.&#xA;D.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is correct way to do it?&lt;/p&gt;&#xA;" OwnerUserId="5341" LastEditorUserId="5341" LastEditDate="2015-11-19T17:24:36.673" LastActivityDate="2015-11-23T19:49:58.710" Title="Vim navigate to next dot symbol in text" Tags="|cursor-movement|search|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5509" PostTypeId="2" ParentId="5505" CreationDate="2015-11-17T18:16:15.203" Score="3" Body="&lt;p&gt;Here is a different approach, doing it in a single line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt;&amp;lt;silent&amp;gt; &amp;lt;f3&amp;gt;  synIDattr(hlID('Tab'),'underline')?':hi clear Tab&amp;lt;cr&amp;gt;':':hi Tab gui=underline guifg=8 ctermbg=8&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses expression mappings to check the underline attribute of the Tab highlighting. If there exists one, it will clear the highlighting and if there does not exist one, it will recreate it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is explained in the help at &lt;code&gt;:h :map-expression&lt;/code&gt; and the if-then-else expression (condition?then:else) at &lt;code&gt;:h expr1&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-11-17T18:16:15.203" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5510" PostTypeId="1" AcceptedAnswerId="5512" CreationDate="2015-11-17T19:55:16.417" Score="1" ViewCount="249" Body="&lt;p&gt;I'm trying to make a custom Vim command to compile code without having to do &lt;code&gt;:!gcc -Wall %:p -o %:p:r&lt;/code&gt; every time. So far, I've been using this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command Com w&amp;lt;CR&amp;gt;! gcc -Wall %:p -o %:p:r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the problem with that is that if I want to compile multiple files, I have to go back to &lt;code&gt;:!&lt;/code&gt;. I was thinking of something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command -nargs=+ Com w | ! gcc -Wall &amp;lt;args&amp;gt; -o compiled&#xA;:command -nargs=0 Com w | ! gcc -Wall %:p -o %:p:r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, that doesn't work, because it throws an error for trying to define the command twice. It does show what I want to do, though, I think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get different behavior for different numbers of arguments?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;I'm new here. Please don't be too angry if I misread or misunderstood &lt;a href=&quot;https://vi.stackexchange.com/help/dont-ask&quot;&gt;Don't Ask&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/help/on-topic&quot;&gt;On Topic&lt;/a&gt;, or left out some information that's necessary.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="anon" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-11-18T17:50:45.217" Title="Getting different behavior for different numbers of arguments in a custom command" Tags="|vimscript|vimrc|command-line|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="5511" PostTypeId="1" AcceptedAnswerId="6744" CreationDate="2015-11-18T05:09:57.120" Score="3" ViewCount="1780" Body="&lt;p&gt;I've looked at &lt;a href=&quot;https://stackoverflow.com/questions/235439/vim-80-column-layout-concerns&quot;&gt;Vim 80 column layout concerns&lt;/a&gt; and &lt;a href=&quot;https://stackoverflow.com/questions/2447109/showing-a-different-background-colour-in-vim-past-80-characters?lq=1&quot;&gt;Showing a different background colour in Vim past 80 characters&lt;/a&gt; and tried the solutions provided there. They seem to work, however, only for some simple ordinary &lt;code&gt;.vimrc&lt;/code&gt;'s, not for spf13.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I add, say,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=80&#xA;set colorcolumn=+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to a simple &lt;code&gt;.vimrc&lt;/code&gt;, I get&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5uwgE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5uwgE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I try to add these two lines to &lt;code&gt;~/.vimrc.local&lt;/code&gt; (as mentioned in spf13) for customization, I get nothing. Do I need to set something else like &lt;code&gt;~/.vimrc.before&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if my way of customization is too naive, or if there is already some instruction on this that I've missed. Has anyone succeeded in setting a different background color or layout for columns beyond 80 when using spf13? Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW I'm using VIM 7.3 on UBUNTU 12.04.&lt;/p&gt;&#xA;" OwnerUserId="2788" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-03-02T20:32:48.173" Title="Showing a different background color or layout beyond 80 column using spf13" Tags="|vimrc|plugin-spf13|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5512" PostTypeId="2" ParentId="5510" CreationDate="2015-11-18T08:43:53.403" Score="2" Body="&lt;p&gt;I know nothing about compiling but if I understand you correctly, you want a vim command that can be used without argument to execute a shell command.&lt;br&gt;&#xA;And if the same vim command is used with arguments, it should execute a different shell command on them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've come up with a template that maybe you could adapt to your specific needs and that seems to do what you want :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CompileFiles(...)&#xA;&#xA;    if a:0 == 0&#xA;        !echo &quot;Compile without argument&quot;&#xA;    else&#xA;        execute &quot;!cat &quot; . join(a:000)&#xA;    endif&#xA;&#xA;endfunction&#xA;&#xA;command! -nargs=* Com call CompileFiles(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this template, the &lt;code&gt;Com&lt;/code&gt; command is defined at the end and calls the &lt;code&gt;CompileFiles()&lt;/code&gt; function that is defined just above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command passes the arguments it receives to the function.&lt;br&gt;&#xA;Inside the latter you can test the number of arguments with &lt;code&gt;a:0&lt;/code&gt; and access the list of arguments with &lt;code&gt;a:000&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function tests the number of arguments it has received :  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if it's 0 it executes the shell command &lt;code&gt;echo &quot;Compile without&#xA;argument&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;if it's more, all the arguments are concatenated (with the built-in &lt;code&gt;join()&lt;/code&gt; function) into a string which in turn is concatenated at the end of &lt;code&gt;&quot;!cat &quot;&lt;/code&gt;.&lt;br&gt;&#xA;The content of the resulting string is then executed.&lt;br&gt;&#xA;For example, if you type &lt;code&gt;:Com foo bar&lt;/code&gt;, the function should execute &lt;code&gt;!cat foo bar&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What you want is different.&lt;br&gt;&#xA;You want to write the current file (&lt;code&gt;w&lt;/code&gt;) and then (&lt;code&gt;|&lt;/code&gt;) execute the shell (&lt;code&gt;!&lt;/code&gt;) command &lt;code&gt;gcc -Wall %:p -o %:p:r&lt;/code&gt; if no argument follows the command, or execute &lt;code&gt;gcc -Wall &amp;lt;args&amp;gt; -o compiled&lt;/code&gt; if there are arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the previous code could be modified like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CompileFiles(...)&#xA;&#xA;    if a:0 == 0&#xA;        write&#xA;        !gcc -Wall %:p -o %:p:r&#xA;    else&#xA;        write&#xA;        execute &quot;!gcc -Wall &quot; . join(a:000) . &quot; -o compiled&quot;&#xA;    endif&#xA;&#xA;endfunction&#xA;&#xA;command! -nargs=* Com call CompileFiles(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not sure it will work though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last thing, before passing some arguments to the shell it's often recommended to escape them. There's a built-in function that does it : &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#shellescape%28%29&quot; rel=&quot;nofollow&quot;&gt;shellescape()&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know how to use it on a specific argument :  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;shellescape(a:foo)&lt;/code&gt; will escape the argument whose name is foo,&lt;br&gt;&#xA; &lt;code&gt;shellescape(a:1)&lt;/code&gt; will escape the first argument of the optional group (the one that is symbolized by &lt;code&gt;...&lt;/code&gt; in the previous code), etc.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;but I don't know how to escape a list of arguments whose size is unknown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; : I've tried to modify the code a little bit to escape the arguments in case they contain special characters :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CompileFiles(...)&#xA;&#xA;    let mylist=[]&#xA;    let c = 0&#xA;    while c &amp;lt; a:0&#xA;        let myarg = shellescape(a:000[c])&#xA;        call add(mylist, myarg)&#xA;        let c += 1&#xA;    endwhile&#xA;&#xA;    if a:0 == 0&#xA;        write&#xA;        !gcc -Wall %:p -o %:p:r&#xA;    else&#xA;        write&#xA;        execute &quot;!gcc -Wall &quot; . join(mylist) . &quot; -o compiled&quot;&#xA;    endif&#xA;&#xA;endfunction&#xA;&#xA;command! -nargs=* Com call CompileFiles(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only thing that changes is the creation of a &lt;code&gt;mylist&lt;/code&gt; variable and a &lt;code&gt;while&lt;/code&gt; loop that executes the &lt;code&gt;shellescape()&lt;/code&gt; function on each argument received by the main function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't test it as I don't have anything to compile.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-18T17:50:45.217" LastActivityDate="2015-11-18T17:50:45.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5513" PostTypeId="2" ParentId="5508" CreationDate="2015-11-18T12:04:00.983" Score="4" Body="&lt;p&gt;The &lt;code&gt;f&lt;/code&gt; command only works within the current line. But you can use the sentence motions &lt;code&gt;(&lt;/code&gt; &quot;one sentence back&quot; and &lt;code&gt;)&lt;/code&gt; &quot;next sentence&quot; to navigate across multiple lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although this only works if the dot is followed by a space, tab or linebreak as mentioned in the help &lt;code&gt;:h (&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A sentence is defined as ending at a '.', '!' or '?' followed by&#xA;  either the end of a line, or by a space or tab.  Any number of closing&#xA;  ')', ']', '&quot;' and ''' characters may appear after the '.', '!' or '?'&#xA;  before the spaces, tabs or end of line.  A paragraph and section&#xA;  boundary is also a sentence boundary.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you can't hit your dot this way you should use the search function &lt;code&gt;/\.&lt;/code&gt; Remember to escape the dot character because it has a special meaning in the search function. Otherwise you would search for every character.&lt;/p&gt;&#xA;" OwnerUserId="5331" LastEditorUserId="5331" LastEditDate="2015-11-18T12:26:39.513" LastActivityDate="2015-11-18T12:26:39.513" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5514" PostTypeId="1" AcceptedAnswerId="5515" CreationDate="2015-11-18T12:25:55.513" Score="33" ViewCount="25437" Body="&lt;p&gt;Today, I decided to try vi instead of Vim; I wanted to see how different it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't notice much differences at all. The biggest thing I noticed was how vi didn't say &lt;code&gt;-- INSERT --&lt;/code&gt; when I went into insertion mode, and there were some minor interface differences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This made me wonder, what are the biggest differences between vi and Vim?&lt;/p&gt;&#xA;" OwnerUserId="5285" LastEditorUserId="927" LastEditDate="2020-01-02T10:49:21.110" LastActivityDate="2020-01-05T00:22:15.830" Title="Biggest differences between Vim and vi" Tags="|original-vi|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5515" PostTypeId="2" ParentId="5514" CreationDate="2015-11-18T12:32:28.470" Score="32" Body="&lt;p&gt;There actually is a help command in Vim to tell you about the differences: &lt;a href=&quot;http://vimhelp.appspot.com/vi_diff.txt.html#vi-differences&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help vi_diff&lt;/code&gt;&lt;/a&gt; (note the underscore: &lt;code&gt;:help vi_diff&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.vim.org/viusers.php&quot; rel=&quot;noreferrer&quot;&gt;From Vim's site&lt;/a&gt;, the biggest are:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;unlimited undo&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can do xxxx and undo each of the four deletes. When was the last&#xA;time you typed &amp;quot;jjjj&amp;quot; and then found out the caps lock key was on? You&#xA;accidentally joined five lines together, and Vi can undo only the last&#xA;command. In Vim you can undo all four &amp;quot;J&amp;quot; commands and get your&#xA;original text back.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;portability&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Vi is only available on Unix. Vim works on MS-Windows, Macintosh,&#xA;Amiga, OS/2, VMS, QNX and other systems. And also on every Unix&#xA;system.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;syntax highlighting&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Vim can be programmed to highlight portions of the buffer in different&#xA;colors or styles, based on the type of file being edited. There are&#xA;hundreds of syntax highlighting rulesets bundled with Vim.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;GUI&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Vim works well at a console, but it can run natively in many GUIs,&#xA;including X Windows, Mac OS, and Microsoft Windows. It uses native GUI&#xA;widgets for scrolling, dividing buffers, and menuing. It can also talk&#xA;to the clipboard.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5331" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-01-05T00:22:15.830" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5516" PostTypeId="2" ParentId="5502" CreationDate="2015-11-18T13:37:55.453" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I'd like vim to recognise this formatting and indent next line&#xA;  properly. Normally, Vim doesn't recognise the curly brace at the end&#xA;  of line as end of block and use the same indent as previous line&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Vim &lt;em&gt;does&lt;/em&gt; recognize the curly brace at the end of the line if it is configured to do so. The most relevant option on this regard is the &lt;code&gt;'autoindent'&lt;/code&gt; (see &lt;code&gt;:help autoindent&lt;/code&gt;). I tried your example in a .cpp file and Vim adjusts the indent of the next line correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-14.10&quot; rel=&quot;nofollow&quot;&gt;Vim FAQ 14.10&lt;/a&gt; explain how to &lt;strong&gt;disable&lt;/strong&gt; it, but you can use it to understand how to configure it:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;14.10. How do I turn off the automatic indentation of text?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;By default, the automatic indentation of text is not turned on. Check&#xA;  the configuration files (.vimrc, .gvimrc) for settings related to&#xA;  indentation. Make sure the &quot;:filetype indent on&quot; command is not&#xA;  present. If it is present, remove it. Also, depending on your&#xA;  preference, you may also want to check the value of the 'autoindent',&#xA;  'smartindent', 'cindent' and 'indentexpr' options and turn them off as&#xA;  needed.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;For more information, read &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype-indent-off&#xA;'autoindent'&#xA;'smartindent'&#xA;'cindent'&#xA;'indentexpr'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first my understanding was that you were unable to get &lt;em&gt;any&lt;/em&gt; automatic indentation; from your comment I get that you want to &lt;em&gt;change&lt;/em&gt; the default behavior of &lt;code&gt;'cindent'&lt;/code&gt;. You can do that by changing a number of options:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;27.2. How do I configure the indentation used for C/C++ files?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You can configure the Vim C indentation by modifying the value of the&#xA;  'cinoptions', 'cinkeys' and 'cinwords' options.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;For more information, read &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'cindent'&#xA;'cinoptions'&#xA;'cinkeys'&#xA;'cinwords'&#xA;C-indenting&#xA;cinoptions-values&#xA;'smartindent'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The documentation on each entry is quite extensive, as it allows for very flexible configuration. After a quick search and tests I think it is &lt;em&gt;not&lt;/em&gt; possible to achieve what do you want by using &lt;code&gt;'autoindent'&lt;/code&gt;, &lt;code&gt;'cindent'&lt;/code&gt;, or &lt;code&gt;'smartindent'&lt;/code&gt;, thus you will have to use &lt;code&gt;'indentexpr'&lt;/code&gt;. From &lt;code&gt;:help C-indenting&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;There are in fact four main methods available for indentation, each one&#xA;overrides the previous if it is enabled, or non-empty for 'indentexpr':&#xA;'autoindent'    uses the indent from the previous line.&#xA;'smartindent'   is like 'autoindent' but also recognizes some C syntax to&#xA;                increase/reduce the indent where appropriate.&#xA;'cindent'       Works more cleverly than the other two and is configurable to&#xA;                different indenting styles.&#xA;'indentexpr'    The most flexible of all: Evaluates an expression to compute&#xA;                the indent of a line.  When non-empty this method overrides&#xA;                the other ones.  See indent-expression.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Besides giving many details, the &lt;code&gt;:help 'indentexpr'&lt;/code&gt; also suggests using the files on $VIMRUNTIME/indent directory as a starting point. The file $VIMRUNTIME/indent/ada.vim shows that you can set &lt;code&gt;'indentexpr'&lt;/code&gt; to call a function, and inside that function you can parse the current and surrounding lines before returning the correct indentation number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use some existing C/C++ indentation plugin in vim.org as a base, such as &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2636&quot; rel=&quot;nofollow&quot;&gt;Indent file for Google C++ Coding Style&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2015-11-18T18:55:10.343" LastActivityDate="2015-11-18T18:55:10.343" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5517" PostTypeId="1" AcceptedAnswerId="5518" CreationDate="2015-11-18T15:24:28.633" Score="1" ViewCount="223" Body="&lt;p&gt;I write in English and Swedish in vim and have the lines below in my &lt;code&gt;.vimrc&lt;/code&gt; to switch to and from a pseudo-Swedish keyboard layout. Basically some keys are remapped with &lt;code&gt;inoremmap&lt;/code&gt; when doing &lt;code&gt;&amp;lt;Leader&amp;gt;s&lt;/code&gt; to output Swedish characters, and characters that are masked by this are reached by hitting the key twice. &lt;code&gt;&amp;lt;Leader&amp;gt;e&lt;/code&gt; undoes these mappings to return to English typing. This all works fine except for with the &lt;code&gt;r&lt;/code&gt; operation. For example, when the Swedish mappings are in effect, &lt;code&gt;r[&lt;/code&gt; does not change the letter to &lt;code&gt;å&lt;/code&gt;, but to &lt;code&gt;[&lt;/code&gt;. How can I make these mappings also affect the &lt;code&gt;r&lt;/code&gt; operation?    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I do not want to use the OS's keyboard switch since this would effect operations in normal mode.   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Switch to Swedish&#xA;function! SweType()&#xA;  set spelllang=sv&#xA;  inoremap ; ö&#xA;  inoremap ;; ;&#xA;  inoremap : Ö&#xA;  inoremap :: :&#xA;  inoremap [ å&#xA;  inoremap { Å&#xA;  inoremap ' ä&#xA;  inoremap '' '&#xA;  inoremap &quot; Ä&#xA;  inoremap &quot;&quot; &quot;&#xA;  inoremap [[ [&#xA;  inoremap {{ {&#xA;endfunction&#xA;nmap &amp;lt;Leader&amp;gt;s :&amp;lt;C-U&amp;gt;call SweType()&amp;lt;CR&amp;gt;&#xA;&#xA;&#xA;&quot; Switch to English&#xA;function! EngType()&#xA;  set spelllang=en_us&#xA;  inoremap ; ;&#xA;  iunmap ;;&#xA;  inoremap : :&#xA;  iunmap ::&#xA;  inoremap [ [&#xA;  iunmap [[&#xA;  inoremap { {&#xA;  iunmap {{&#xA;  inoremap ' '&#xA;  iunmap ''&#xA;  inoremap &quot; &quot;&#xA;  iunmap &quot;&quot;&#xA;endfunction&#xA;nmap &amp;lt;Leader&amp;gt;e :&amp;lt;C-U&amp;gt;call EngType()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3316" LastActivityDate="2015-11-18T16:30:25.907" Title="imap and the r operation" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5518" PostTypeId="2" ParentId="5517" CreationDate="2015-11-18T15:37:18.843" Score="1" Body="&lt;p&gt;You should be able to remap the whole sequence of keys in normal mode :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap r[ rå&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edited the answer, as I'm not sure in which mode we are when we hit &lt;code&gt;r&lt;/code&gt;. Maybe a sub mode of insert mode that is left as soon as another key is pressed.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-18T16:30:25.907" LastActivityDate="2015-11-18T16:30:25.907" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5520" PostTypeId="1" AcceptedAnswerId="5521" CreationDate="2015-11-18T16:25:52.967" Score="3" ViewCount="1078" Body="&lt;p&gt;I use two languages to check my spelling: English and Russian, so I have the following options in &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set spell spelllang=ru_yo,en_us&#xA;set spellsuggest=10&#xA;set keymap=russian-jcukenwin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sometimes I run &lt;code&gt;zG&lt;/code&gt; on &quot;incorrect&quot; words to mark them as the &quot;good&quot; ones and make the exception globally. After pressing &lt;code&gt;zG&lt;/code&gt; I see the following in the status line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Word 'Timur' added to /tmp/vsqMS8V/10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems Vim adds my dictionary preferences/exceptions into temporary directory. Is it possible to specify concrete path where to store such files? There is &lt;code&gt;spellfile&lt;/code&gt; option, but I didn't get the idea how to use it with multiple langs..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The are mistake, I should use &lt;code&gt;zg&lt;/code&gt; instead &lt;code&gt;zG&lt;/code&gt; to store exceptions under &lt;code&gt;~/.vim/spell&lt;/code&gt; permanently and between all vim sessions. But still question is open: how to specify a concrete path/file to store the words?&lt;/p&gt;&#xA;" OwnerUserId="5321" LastEditorUserId="5321" LastEditDate="2015-11-18T19:19:10.643" LastActivityDate="2015-11-18T20:00:11.373" Title="How to force vim save excluded (good) words into specific file?" Tags="|vimrc|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5521" PostTypeId="2" ParentId="5520" CreationDate="2015-11-18T17:24:22.073" Score="5" Body="&lt;p&gt;If you want to mark a word as good and that vim remembers it, I think you should hit &lt;code&gt;zg&lt;/code&gt; and not &lt;code&gt;zG&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what the help says about &lt;code&gt;zG&lt;/code&gt; (&lt;code&gt;:help zG&lt;/code&gt;) :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;zG            Like &quot;zg&quot; but add the word to the internal word list&#xA;            internal-wordlist.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And here's what the help says about the internal-wordlist (&lt;code&gt;:help internal-wordlist&lt;/code&gt;) :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The internal word list is used for all buffers where 'spell' is set. &#xA;  It is not stored, it is lost when you exit Vim.  It is also cleared&#xA;  when 'encoding' is set.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On my system, when I hit &lt;code&gt;zg&lt;/code&gt; the word is added in &lt;code&gt;~/.vim/spell/{language}.{encoding}.add&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want another location for the file, here's what the help says about the &lt;code&gt;spellfile&lt;/code&gt; option :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Name of the word list file where words are added for the |zg| and&#xA;  |zw|  commands.  It must end in &quot;.{encoding}.add&quot;.  You need to&#xA;  include the   path, otherwise the file is placed in the current&#xA;  directory.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So to choose another location for the file, type :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set spellfile=/path/to/your/file.{encoding}.add&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, you said that you didn't get how to use the &lt;code&gt;spellfile&lt;/code&gt; option to use multiple languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The help also says :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For the file name the first language name that appears in&#xA;  'spelllang' is used,  ignoring the region.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you switch regularly between English and Russian, maybe you should try the following mappings :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;se :setlocal spell! spelllang=en&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;sr :setlocal spell! spelllang=ru&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They will toggle spell check and they will change the value of the &lt;code&gt;spelllang&lt;/code&gt; option, which is used for the name of the file storing your exceptions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should allow you to have two separate files for two different languages.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-18T20:00:11.373" LastActivityDate="2015-11-18T20:00:11.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5523" PostTypeId="2" ParentId="5514" CreationDate="2015-11-18T18:37:59.367" Score="15" Body="&lt;p&gt;Vim has many features that Vi does not, even features that are not obviously &quot;advanced&quot; features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In practice, this means that if you are used to Vi, you will likely encounter very few differences if you start using Vim (or some other Vi clone), but if you are used to Vim &lt;em&gt;and&lt;/em&gt; if your &quot;reflexes&quot; include features such as visual mode highlighting, any key action that starts with &quot;g&quot; or &quot;z&quot;, any text action with &quot;i&quot; or &quot;a&quot; [e.g. &quot;daw&quot; to delete a word under the cursor], navigating with arrow keys in insert mode, etc, you will find that those don't work in Vi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also the question of what exactly you were using when you say you &quot;tried Vi&quot;. On many systems, &quot;vi&quot; actually runs Vim, in a mode where some of these differences apply (default showmode as you observed, arrow keys don't work in insert mode) and others do not (visual mode and g/z keys work), and some features depend on a compile-time option that is sometimes disabled in the &quot;tiny Vim&quot; that is used for this (text objects, such as &quot;aw&quot; a word, are one of these). You won't get these if you run the &lt;em&gt;real&lt;/em&gt; Vi, or if &quot;vi&quot; is some other clone with fewer or different features than Vim, such as nvi or VILE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, on the obscure side, while &quot;tiny Vim in Vi mode&quot; obviously doesn't have any features that a full Vim does not, there are a few features of the genuine original Vi that vim lacks. These are documented in &lt;code&gt;:help vi-differences&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="880" LastEditorUserId="880" LastEditDate="2015-11-18T18:44:34.143" LastActivityDate="2015-11-18T18:44:34.143" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5524" PostTypeId="1" CreationDate="2015-11-18T20:52:38.733" Score="3" ViewCount="163" Body="&lt;p&gt;Vim can often show you text differing from the actual input, such as with non-printing characters, concealed text, etc. There are plugins which prettify text (for example, using a proper lambda character instead of &lt;code&gt;\&lt;/code&gt; in Haskell). How can I copy the text so displayed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the mouse&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;screen&lt;/code&gt;/&lt;code&gt;tmux&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But I would prefer a within-Vim solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify, I only care about the text, not colours or highlighting. For example, if it shows &lt;code&gt;^@&lt;/code&gt; for NUL, or &lt;code&gt;^H&lt;/code&gt; for backspace, or &lt;code&gt;λ&lt;/code&gt; for &lt;code&gt;\&lt;/code&gt;, then I want my copied text to use &lt;code&gt;^@&lt;/code&gt;, &lt;code&gt;^H&lt;/code&gt; and &lt;code&gt;λ&lt;/code&gt; respectively.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-11-18T21:10:03.703" LastActivityDate="2015-11-19T06:54:45.560" Title="How can I copy the displayed text, instead of the actual text?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5525" PostTypeId="2" ParentId="5524" CreationDate="2015-11-18T21:05:24.980" Score="9" Body="&lt;p&gt;For the terminal, I think, the simplest solution is to let the terminal handle the mouse selection by pressing shift when visually selecting with the mouse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution would be to script something using the &lt;code&gt;screenchar()&lt;/code&gt; function. But I don't know of a ready plugin for that.&#xA;&lt;strong&gt;Update&lt;/strong&gt; But you can script something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! ScreenCapture()&#xA;    let array=[]&#xA;    for i in range(1,&amp;amp;lines)&#xA;        let row=''&#xA;        for j in range(1,&amp;amp;columns)&#xA;            let row.=nr2char(screenchar(i,j))&#xA;        endfor&#xA;        call add(array, row)&#xA;    endfor&#xA;    tabnew&#xA;    call setline(1,array)&#xA;endfu&#xA;com! ScreenCapture :call ScreenCapture()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both solutions won't handle syntax highlighting. An alternative that can handle even syntax highlighting and signs would be to use the distributed 2html vim plugin. This converts the current buffer to a html page including syntax highlighting (or diff mode) that you can open with the browser. For me, this is the prefered solution to pretty print something from within Vim.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-11-19T06:54:45.560" LastActivityDate="2015-11-19T06:54:45.560" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5526" PostTypeId="2" ParentId="5487" CreationDate="2015-11-18T22:27:21.350" Score="2" Body="&lt;p&gt;There is no direct feature for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Workarounds could be&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;keeping the preview open&lt;/li&gt;&#xA;&lt;li&gt;setting &lt;code&gt;cursorline&lt;/code&gt; and &lt;code&gt;cursorcolumn&lt;/code&gt; (&lt;code&gt;:se cuc! cul!&lt;/code&gt; to toggle, or &lt;code&gt;[ox&lt;/code&gt; and &lt;code&gt;]ox&lt;/code&gt; if you use &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow&quot;&gt;https://github.com/tpope/vim-unimpaired&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;using &lt;code&gt;scrolloffset&lt;/code&gt; smartly. This would really only achieve the desired effect if you edit near the opposite end of your window to where the preview opens, I guess, but it could be enough to significantly reduce the movement in a percentage of the cases&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5359" LastActivityDate="2015-11-18T22:27:21.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5527" PostTypeId="1" AcceptedAnswerId="5529" CreationDate="2015-11-19T00:09:19.850" Score="2" ViewCount="757" Body="&lt;p&gt;To structure my &lt;code&gt;.vimrc&lt;/code&gt; a bit better I decided to create a custom fold expression in the file &lt;code&gt;.vim/after/ftplugin/vim/folding.vim&lt;/code&gt; which gets loaded automatically for my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; The purpose of this script is to fold my .vimrc automatically.&#xA;&quot; This file will be sourced automatically, each time a vim file is opened or&#xA;&quot; created, see http://vimcasts.org/episodes/writing-a-custom-fold-expression/&#xA;&#xA;&quot; The function is called for each line of code, numbers represent fold level&#xA;function! VimFolds()&#xA;  &quot; get line contents&#xA;  let thisline = getline(v:lnum)&#xA;  if match(thisline, '^&quot;&quot;&quot;') &amp;gt;= 0&#xA;    &quot; tell Vim this line starts a level 2 fold, so Vim close all level 2 folds&#xA;    &quot; that came before it&#xA;    return '&amp;gt;2'&#xA;  else if match(thisline, '^&quot;&quot;') &amp;gt;= 0&#xA;    return '&amp;gt;1'&#xA;  else&#xA;    &quot; tell Vim this line should have the same fold level as its predecessor&#xA;    return '='&#xA;  endif&#xA;endfunction&#xA;setlocal foldmethod=expr&#xA;setlocal foldexpr=VimFolds()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this code somehow does not really work for the first fold level (lines don't get folded), and the second fold level behaves weird as well (lines seem to be folded twice). I do not understand where the error is. I tried changing it to &lt;code&gt;&quot;##&lt;/code&gt; and &lt;code&gt;&quot;#&lt;/code&gt;, but this did not work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tested on this &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot; plugins (managed via vim-plug)&#xA;&quot; :PlugInstall/PlugUpdate [name], :PlugStatus, :PlugUpgrade to upgrade vim-plug&#xA;call plug#begin('~/.vim/plugged')&#xA;Plug 'altercation/vim-colors-solarized'&#xA;Plug 'tpope/vim-sensible'&#xA;Plug 'tpope/vim-commentary'&#xA;Plug 'tpope/vim-surround'&#xA;Plug 'tpope/vim-repeat'&#xA;Plug 'tpope/vim-unimpaired'&#xA;Plug 'scrooloose/syntastic'&#xA;&quot; some more plugins here, not listed&#xA;call plug#end()&#xA;&#xA;&quot;&quot; colorscheme settings&#xA;set background=dark&#xA;colorscheme solarized&#xA;&#xA;&quot;&quot;&quot; testing a subfold&#xA;set relativenumber&#xA;set number &quot; hybrid setting when both combined&#xA;&#xA;&quot; better line wrap&#xA;let &amp;amp;showbreak='↪ '&#xA;&#xA;&quot;&quot;&quot; testing some more subfold&#xA;&quot; enable spell checking for git commits&#xA;autocmd FileType gitcommit setlocal spell&#xA;&#xA;&quot; more code, not relevant&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where is my mistake?&lt;/p&gt;&#xA;" OwnerUserId="3282" LastEditorUserId="3282" LastEditDate="2015-11-19T00:26:20.967" LastActivityDate="2015-11-19T07:13:15.020" Title="Folding my .vimrc doesn't work as expected" Tags="|vimrc|folding|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5528" PostTypeId="1" AcceptedAnswerId="5530" CreationDate="2015-11-19T07:05:02.260" Score="5" ViewCount="1297" Body="&lt;p&gt;I have some code in my &lt;code&gt;~/.vimrc&lt;/code&gt; that (simplified) looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SomeAppendFunction()&#xA;    let failed = append(0, [&quot;Some header text&quot;])&#xA;endfunction&#xA;command SomeAppendFunction :call SomeAppendFunction()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The intent is to provide a command that prepends some fixed text to any file I wish. I don't really care too much about handling errors from the &lt;code&gt;append()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;a href=&quot;https://github.com/scrooloose/syntastic&quot; rel=&quot;nofollow&quot;&gt;Syntastic&lt;/a&gt; over this, which uses &lt;a href=&quot;https://github.com/scrooloose/syntastic/wiki/VimL%3A---vimlint&quot; rel=&quot;nofollow&quot;&gt;vimlint&lt;/a&gt; to check it, it quite rightly warns that I'm not using the return variable &lt;code&gt;failed&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/xyz/.vimrc|255 col 9 warning| [EVL102] unused variable `l:failed`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I remove the &lt;code&gt;let failed =&lt;/code&gt; from the line inside the function, so it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SomeAppendFunction()&#xA;    append(0, [&quot;Some header text&quot;])&#xA;endfunction&#xA;command SomeAppendFunction :call SomeAppendFunction()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... I instead now see: ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line  301:&#xA;E126: Missing :endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... when I start vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I avoid the warning about the unused variable, but also have a syntactically correct function?&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="51" LastEditDate="2015-11-20T13:06:45.270" LastActivityDate="2015-11-20T13:06:45.270" Title="How can I avoid warnings about unused variables?" Tags="|vimscript|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5529" PostTypeId="2" ParentId="5527" CreationDate="2015-11-19T07:06:35.713" Score="4" Body="&lt;p&gt;Make the &lt;code&gt;else if&lt;/code&gt; an &lt;code&gt;elseif&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I find it usually simpler to give the variable &lt;code&gt;v:lnum&lt;/code&gt; as parameter to the foldfunction. This makes it easier to debug the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some hints:&#xA;You can use &lt;code&gt;:set debug=msg&lt;/code&gt; to see error messages and you can use &lt;code&gt;:breakadd func VimFolds&lt;/code&gt; to start the debugger when the function is executed. &#xA;Setting &lt;code&gt;:set foldcolumn=5&lt;/code&gt; gives a visual indication of the result of the folding expression. This is also often useful.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-11-19T07:13:15.020" LastActivityDate="2015-11-19T07:13:15.020" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="5530" PostTypeId="2" ParentId="5528" CreationDate="2015-11-19T07:11:09.077" Score="6" Body="&lt;p&gt;&lt;code&gt;append()&lt;/code&gt; is a function and no command. As such, it must be called using the &lt;code&gt;:call&lt;/code&gt; command. So use &lt;code&gt;:call append()&lt;/code&gt;. Second, if you want to ignore errors, you can wrap the whole command into a &lt;code&gt;try...catch...endtry&lt;/code&gt; statement like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;try&#xA;   call append()   &quot; could fail for whatever reason&#xA;catch&#xA;   &quot; no-op&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-11-19T07:11:09.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5531" PostTypeId="1" AcceptedAnswerId="5532" CreationDate="2015-11-19T08:06:06.643" Score="8" ViewCount="4450" Body="&lt;p&gt;I remapped my hjkl keys to ijkl, but in netrw, &quot;i&quot; switches view styles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to change this? Is it possible to change this?&lt;/p&gt;&#xA;" OwnerUserId="5365" LastActivityDate="2020-12-03T20:02:39.007" Title="How to remap &quot;i&quot; in netrw?" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5532" PostTypeId="2" ParentId="5531" CreationDate="2015-11-19T09:03:07.490" Score="12" Body="&lt;p&gt;If you want your cursor to move left when pressing &lt;code&gt;i&lt;/code&gt; in the built-in file browser netrw, then try adding the following code in your &lt;code&gt;$MYVIMRC&lt;/code&gt; file :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup netrw_mapping&#xA;    autocmd!&#xA;    autocmd filetype netrw call NetrwMapping()&#xA;augroup END&#xA;&#xA;function! NetrwMapping()&#xA;    noremap &amp;lt;buffer&amp;gt; i h&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason why your custom mapping didn't have the expected result, is probably because netrw set up mappings that are local to the buffer (using the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; option), which means they override your global mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The previous code adds an autocommand that automatically calls a function whenever you enter a buffer whose filetype is netrw. The function then sets up your mapping using the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; option, which means it should be able to override the local mapping previously done by netrw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the workaround from &lt;a href=&quot;https://unix.stackexchange.com/a/42939/125618&quot;&gt;this post&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2015-11-19T09:38:55.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5533" PostTypeId="1" CreationDate="2015-11-19T15:10:07.847" Score="14" ViewCount="7225" Body="&lt;p&gt;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 &lt;a href=&quot;https://vi.stackexchange.com/questions/2280/show-only-matching-lines&quot;&gt;similar questions&lt;/a&gt;, but they don't solve my problem. I don't want to use folds for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What do I want exactly?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open a document, I want Vim to not read in commented lines. It should behave as if these lines do not exist at all in the document, with only one exception: I need a visual indicator ( e.g. in an additional column at the side) that tells me here is a comment which is not displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Upon pressing a certain key combination, I want all comments to show up (i.e. normal Vim behaviour).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to modify the document with comments not displayed. Upon save, the whole document is saved &lt;em&gt;with&lt;/em&gt; comments (they are always saved 1 line above the text which was under them in the beginning).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem/66378#66378&quot;&gt;Why&lt;/a&gt; do I want this?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It destracts less and looks visually more pleasing. Take the &lt;code&gt;.vimrc&lt;/code&gt; for example - you can have all settings nicely below each other. If you want to change something, or are unsure why you set it this way, just toggle your comments.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastEditorUserId="51" LastEditDate="2015-11-28T04:27:30.070" LastActivityDate="2018-06-10T20:07:38.490" Title="Hide certain lines completely (not folding)" Tags="|folding|comments|conceal|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5534" PostTypeId="1" AcceptedAnswerId="5538" CreationDate="2015-11-19T15:12:42.683" Score="3" ViewCount="157" Body="&lt;p&gt;I use &lt;a href=&quot;https://github.com/haya14busa/incsearch.vim&quot; rel=&quot;nofollow&quot;&gt;this plugin&lt;/a&gt; (incsearch.vim) which changes the search function in vim by highlighting the text dynamically while typing the regex after &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the plugin to work I had to add these lines in my &lt;code&gt;~/.vimrc&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map /  &amp;lt;Plug&amp;gt;(incsearch-forward)&#xA;map ?  &amp;lt;Plug&amp;gt;(incsearch-backward)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suppose the result is that whenever I hit &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;, some functions (&lt;code&gt;incsearch-forward()&lt;/code&gt; and &lt;code&gt;insearch-backward()&lt;/code&gt;) provided by the plugin are called to take care of the search.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to modify those mappings, so that the plugin's functions are still called but the search begins automatically with &lt;code&gt;\v&lt;/code&gt;, the &lt;em&gt;very magic&lt;/em&gt; mode is enabled and I don't have to escape &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;)&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt;, &lt;code&gt;+&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without calling the plugin's functions it would give something like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map /  /\v&#xA;map ?  ?\v&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I don't know how to call the plugin at the same time.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-19T15:26:10.953" LastActivityDate="2015-11-19T17:30:42.427" Title="How to modify a mapping involving the special key name &lt;Plug&gt;?" Tags="|key-bindings|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5535" PostTypeId="2" ParentId="5534" CreationDate="2015-11-19T15:27:47.700" Score="0" Body="&lt;p&gt;I think I found. I tried the other way around the first time, sorry.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map /  &amp;lt;Plug&amp;gt;(incsearch-forward)\v&#xA;map ?  &amp;lt;Plug&amp;gt;(incsearch-backward)\v&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastActivityDate="2015-11-19T15:27:47.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5536" PostTypeId="1" AcceptedAnswerId="5537" CreationDate="2015-11-19T17:00:39.880" Score="4" ViewCount="2902" Body="&lt;p&gt;I am looking for a complete list of the key descriptions commonly used for remapping keys.&lt;/p&gt;&#xA;" OwnerDisplayName="user5370" LastActivityDate="2016-11-25T21:52:18.373" Title="List of key descriptions such as &lt;esc&gt; or &lt;cr&gt;" Tags="|key-bindings|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5537" PostTypeId="2" ParentId="5536" CreationDate="2015-11-19T17:09:30.130" Score="8" Body="&lt;pre&gt;&lt;code&gt;:help key-notation&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They are described in the &lt;a href=&quot;https://vimhelp.appspot.com/intro.txt.html#key-notation&quot; rel=&quot;noreferrer&quot;&gt;help&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;notation    meaning         equivalent  decimal value(s)    ~&#xA;-----------------------------------------------------------------------&#xA;&amp;lt;Nul&amp;gt;       zero            CTRL-@    0 (stored as 10) *&amp;lt;Nul&amp;gt;*&#xA;&amp;lt;BS&amp;gt;        backspace       CTRL-H    8 *backspace*&#xA;&amp;lt;Tab&amp;gt;       tab         CTRL-I    9 *tab* *Tab*&#xA;                            *linefeed*&#xA;&amp;lt;NL&amp;gt;        linefeed        CTRL-J   10 (used for &amp;lt;Nul&amp;gt;)&#xA;&amp;lt;FF&amp;gt;        formfeed        CTRL-L   12 *formfeed*&#xA;&amp;lt;CR&amp;gt;        carriage return     CTRL-M   13 *carriage-return*&#xA;&amp;lt;Return&amp;gt;    same as &amp;lt;CR&amp;gt;                *&amp;lt;Return&amp;gt;*&#xA;&amp;lt;Enter&amp;gt;     same as &amp;lt;CR&amp;gt;                *&amp;lt;Enter&amp;gt;*&#xA;&amp;lt;Esc&amp;gt;       escape          CTRL-[   27 *escape* *&amp;lt;Esc&amp;gt;*&#xA;&amp;lt;Space&amp;gt;     space                32 *space*&#xA;&amp;lt;lt&amp;gt;        less-than       &amp;lt;    60 *&amp;lt;lt&amp;gt;*&#xA;&amp;lt;Bslash&amp;gt;    backslash       \    92 *backslash* *&amp;lt;Bslash&amp;gt;*&#xA;&amp;lt;Bar&amp;gt;       vertical bar        |   124 *&amp;lt;Bar&amp;gt;*&#xA;&amp;lt;Del&amp;gt;       delete              127&#xA;&amp;lt;CSI&amp;gt;       command sequence intro  ALT-Esc 155 *&amp;lt;CSI&amp;gt;*&#xA;&amp;lt;xCSI&amp;gt;      CSI when typed in the GUI       *&amp;lt;xCSI&amp;gt;*&#xA;&#xA;&amp;lt;EOL&amp;gt;       end-of-line (can be &amp;lt;CR&amp;gt;, &amp;lt;LF&amp;gt; or &amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;,&#xA;        depends on system and 'fileformat') *&amp;lt;EOL&amp;gt;*&#xA;&#xA;&amp;lt;Up&amp;gt;        cursor-up           *cursor-up* *cursor_up*&#xA;&amp;lt;Down&amp;gt;      cursor-down         *cursor-down* *cursor_down*&#xA;&amp;lt;Left&amp;gt;      cursor-left         *cursor-left* *cursor_left*&#xA;&amp;lt;Right&amp;gt;     cursor-right            *cursor-right* *cursor_right*&#xA;&amp;lt;S-Up&amp;gt;      shift-cursor-up&#xA;&amp;lt;S-Down&amp;gt;    shift-cursor-down&#xA;&amp;lt;S-Left&amp;gt;    shift-cursor-left&#xA;&amp;lt;S-Right&amp;gt;   shift-cursor-right&#xA;&amp;lt;C-Left&amp;gt;    control-cursor-left&#xA;&amp;lt;C-Right&amp;gt;   control-cursor-right&#xA;&amp;lt;F1&amp;gt; - &amp;lt;F12&amp;gt;    function keys 1 to 12       *function_key* *function-key*&#xA;&amp;lt;S-F1&amp;gt; - &amp;lt;S-F12&amp;gt; shift-function keys 1 to 12    *&amp;lt;S-F1&amp;gt;*&#xA;&amp;lt;Help&amp;gt;      help key&#xA;&amp;lt;Undo&amp;gt;      undo key&#xA;&amp;lt;Insert&amp;gt;    insert key&#xA;&amp;lt;Home&amp;gt;      home                *home*&#xA;&amp;lt;End&amp;gt;       end             *end*&#xA;&amp;lt;PageUp&amp;gt;    page-up             *page_up* *page-up*&#xA;&amp;lt;PageDown&amp;gt;  page-down           *page_down* *page-down*&#xA;&amp;lt;kHome&amp;gt;     keypad home (upper left)    *keypad-home*&#xA;&amp;lt;kEnd&amp;gt;      keypad end (lower left)     *keypad-end*&#xA;&amp;lt;kPageUp&amp;gt;   keypad page-up (upper right)    *keypad-page-up*&#xA;&amp;lt;kPageDown&amp;gt; keypad page-down (lower right)  *keypad-page-down*&#xA;&amp;lt;kPlus&amp;gt;     keypad +            *keypad-plus*&#xA;&amp;lt;kMinus&amp;gt;    keypad -            *keypad-minus*&#xA;&amp;lt;kMultiply&amp;gt; keypad *            *keypad-multiply*&#xA;&amp;lt;kDivide&amp;gt;   keypad /            *keypad-divide*&#xA;&amp;lt;kEnter&amp;gt;    keypad Enter            *keypad-enter*&#xA;&amp;lt;kPoint&amp;gt;    keypad Decimal point        *keypad-point*&#xA;&amp;lt;k0&amp;gt; - &amp;lt;k9&amp;gt; keypad 0 to 9           *keypad-0* *keypad-9*&#xA;&amp;lt;S-...&amp;gt;     shift-key           *shift* *&amp;lt;S-*&#xA;&amp;lt;C-...&amp;gt;     control-key         *control* *ctrl* *&amp;lt;C-*&#xA;&amp;lt;M-...&amp;gt;     alt-key or meta-key     *meta* *alt* *&amp;lt;M-*&#xA;&amp;lt;A-...&amp;gt;     same as &amp;lt;M-...&amp;gt;         *&amp;lt;A-*&#xA;&amp;lt;D-...&amp;gt;     command-key (Macintosh only)    *&amp;lt;D-*&#xA;&amp;lt;t_xx&amp;gt;      key with &quot;xx&quot; entry in termcap&#xA;-----------------------------------------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastActivityDate="2015-11-19T17:09:30.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5538" PostTypeId="2" ParentId="5534" CreationDate="2015-11-19T17:30:42.427" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I would like to modify those mappings, so that the plugin's functions&#xA;  are still called but the search begins automatically with \v, the very&#xA;  magic mode is enabled and I don't have to escape (, ), {, + etc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can achieve that by using your previous mappings, by changing some plugin options. This approach avoids cluttering the search line with the &lt;code&gt;\v&lt;/code&gt;. From the &lt;a href=&quot;https://github.com/haya14busa/incsearch.vim/blob/master/doc/incsearch.txt#L161&quot; rel=&quot;noreferrer&quot;&gt;documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;By default 'magic' option, all you can set is 'magic' or 'nomagic',&#xA;and in addition, default option has porability problem. see: 'magic'&#xA;In contrast to default 'magic' option, |g:incsearch#magic| enable&#xA;you to set 'very magic' |\v| and 'very nomagic' |\V| in adition to&#xA;'magic' |\m| and 'nomagic' |\M|.&#xA;This option doesn't cause porability problems, so you need not worry&#xA;about this problem. No other pattern related programs are affected by&#xA;this option.&#xA;Usage: &amp;gt;&#xA;let g:incsearch#magic = '\v' &quot; very magic&#xA;let g:incsearch#magic = '\V' &quot; very nomagic&#xA;let g:incsearch#magic = '\m' &quot; magic&#xA;let g:incsearch#magic = '\M' &quot; nomagic&#xA;&amp;lt;&#xA;default: ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-11-19T17:30:42.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5539" PostTypeId="2" ParentId="5533" CreationDate="2015-11-19T17:55:13.487" Score="10" Body="&lt;p&gt;I don't know how to achieve exactly what you want, only a part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want to hide some text inside &lt;code&gt;~/.vimrc&lt;/code&gt; (for example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First we need to know which highlight group handles the text you want to hide.&#xA;Add this mapping to your &lt;code&gt;~/.vimrc&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F10&amp;gt; :echo &quot;hi&amp;lt;&quot; . synIDattr(synID(line(&quot;.&quot;),col(&quot;.&quot;),1),&quot;name&quot;) . '&amp;gt; trans&amp;lt;'&#xA;\ . synIDattr(synID(line(&quot;.&quot;),col(&quot;.&quot;),0),&quot;name&quot;) . &quot;&amp;gt; lo&amp;lt;&quot;&#xA;\ . synIDattr(synIDtrans(synID(line(&quot;.&quot;),col(&quot;.&quot;),1)),&quot;name&quot;) . &quot;&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've taken it from &lt;a href=&quot;http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next put your cursor on some text you want to hide, for example a comment. Then hit &lt;code&gt;F10&lt;/code&gt;.&lt;br&gt;&#xA;The name of the highlight group should appear on the command line.&lt;br&gt;&#xA;On my system the output is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi&amp;lt;vimLineComment&amp;gt; trans&amp;lt;vimLineComment&amp;gt; lo&amp;lt;Comment&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think it means that the highlight group for vim comments is &lt;code&gt;vimLineComment&lt;/code&gt; and that it's linked to &lt;code&gt;Comment&lt;/code&gt;.&#xA;So we want to hide the text that is handled by the highlight group &lt;code&gt;vimLineComment&lt;/code&gt; (or &lt;code&gt;Comment&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To achieve this, we could use the conceal feature added in vim 7.3 (&lt;code&gt;:help conceal&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match vimLineComment &quot;^\&quot;.*&quot; conceal containedin=ALL cchar=&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line tells vim to search text whose highlight group is &lt;code&gt;vimLineComment&lt;/code&gt; and which matches the regex &lt;code&gt;^\&quot;.*&lt;/code&gt; (a beginning of a line (&lt;code&gt;^&lt;/code&gt;) followed by a double quote (&lt;code&gt;\&quot;&lt;/code&gt;) followed by any text (&lt;code&gt;.*&lt;/code&gt;)), and to hide and replace it everywhere it's found (&lt;code&gt;containedin=ALL&lt;/code&gt;) with the character &lt;code&gt;&amp;gt;&lt;/code&gt; (&lt;code&gt;cchar=&amp;gt;&lt;/code&gt;).&lt;br&gt;&#xA;The &lt;code&gt;conceal&lt;/code&gt; syntax attribute will hide the text we want, unless the cursor is on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, we tell vim to completely hide the text unless it has a custom replacement character defined :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set conceallevel=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are 4 possible values for this option with 4 different effects (see &lt;code&gt;:help conceallevel&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As we don't want to type those commands every time, we add an autocommand in our &lt;code&gt;~/.vimrc&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup hide_text&#xA;    autocmd!&#xA;    autocmd FileType vim :set conceallevel=2 | :syntax match vimLineComment &quot;^\&quot;.*&quot; conceal containedin=ALL cchar=&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, we add a mapping to toggle the value of the &lt;code&gt;conceallevel&lt;/code&gt; option (between 2 and 0 ; 2 = hidden, 0 = shown ) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;h :&amp;lt;c-u&amp;gt;if (&amp;amp;conceallevel==2) \| set conceallevel=0 \| else \| set conceallevel=2 \| endif&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result is that the text should be shown / hidden when we hit &lt;code&gt;&amp;lt;leader&amp;gt;h&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also change the color of the replacement character :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight Conceal ctermfg=&amp;lt;code color&amp;gt; guifg=#&amp;lt;code color&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can choose in which mode a comment will be displayed. For example, if you want it to be shown only when you're on its line in insert mode :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal concealcursor=ncv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I don't know how to collapse all those hidden lines like the folding feature does, sorry.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; : another possible solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You keep your folding settings to collapse the lines you don't want to see, and you hide the titles of the folds, so that they don't distract you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FoldingTitle()&#xA;    if (v:foldlevel&amp;gt;1)&#xA;        let line = repeat(' ', &amp;amp;sw * (v:foldlevel-1)).'&amp;gt;'&#xA;    else&#xA;        let line = '|'&#xA;    endif&#xA;    return line&#xA;endfunction&#xA;&#xA;set foldtext=FoldingTitle()&#xA;set fillchars+=fold:\ &#xA;set foldcolumn=3 &quot; optional&#xA;&#xA;highlight FoldColumn ctermfg=&amp;lt;code color&amp;gt; guifg=#&amp;lt;code color&amp;gt; ctermbg=&amp;lt;code color&amp;gt; guibg=#&amp;lt;code color&amp;gt; &quot;optional&#xA;highlight Folded ctermfg=&amp;lt;code color&amp;gt; guifg=#&amp;lt;code color&amp;gt; ctermbg=&amp;lt;code color&amp;gt; guibg=#&amp;lt;code color&amp;gt; &quot;optional&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this code we customize the title of the folds by giving the value &lt;code&gt;FoldingTitle()&lt;/code&gt; to the &lt;code&gt;foldtext&lt;/code&gt; option.&#xA;It means that we can change how a fold will look through this function.&#xA;&lt;code&gt;FoldingTitle()&lt;/code&gt; just returns a symbol so that you know there's a fold (&lt;code&gt;&amp;gt;&lt;/code&gt; preceded by some repeated spaces, or &lt;code&gt;|&lt;/code&gt; depending on the foldlevel).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we define the space character as the character to use to fill the empty space on the lines :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fillchars+=fold:\ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Don't forget the space after the backslash.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally we define a column (whose width is 3) which will be shown at the side of the window and which will indicate open and closed folds. We also customize the color of the foldcolumn as well as the color of the titles of the folds. Each of these 3 lines is optional.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldcolumn=3 &quot; optional&#xA;highlight FoldColumn ctermfg=&amp;lt;code color&amp;gt; guifg=#&amp;lt;code color&amp;gt; ctermbg=&amp;lt;code color&amp;gt; guibg=#&amp;lt;code color&amp;gt;&#xA;highlight Folded ctermfg=&amp;lt;code color&amp;gt; guifg=#&amp;lt;code color&amp;gt; ctermbg=&amp;lt;code color&amp;gt; guibg=#&amp;lt;code color&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-19T20:39:47.887" LastActivityDate="2015-11-19T20:39:47.887" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5540" PostTypeId="1" AcceptedAnswerId="5542" CreationDate="2015-11-19T21:03:04.930" Score="1" ViewCount="202" Body="&lt;p&gt;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.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could achieve this result with the syn match &lt;code&gt;'^ .*.[a-zA-Z].*'&lt;/code&gt;, but I want the highlight to be working only if the previous line does not end with a &quot;=&quot;.&#xA;Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="5372" LastActivityDate="2015-11-19T21:50:44.710" Title="Syntax highlighting for not empty line starting with a space, but only if the previous line did not end with &quot;=&quot;" Tags="|syntax-highlighting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5541" PostTypeId="2" ParentId="5540" CreationDate="2015-11-19T21:32:57.440" Score="0" Body="&lt;p&gt;Yes, it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;O.k., now seriously. This is only for the starting space.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match WhiteSpaceWithoutPrecedingEqualSign /=\@&amp;lt;!\n^ \S/hs=s+1,he=e-1&#xA;hi WhiteSpaceWithoutPrecedingEqualSign guibg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is for the line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match WhiteSpaceWithoutPrecedingEqualSign /=\@&amp;lt;!\n^ \S.*/hs=s+1&#xA;hi WhiteSpaceWithoutPrecedingEqualSign guibg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h pattern&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h syntax&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2961" LastEditorUserId="2961" LastEditDate="2015-11-19T21:38:05.303" LastActivityDate="2015-11-19T21:38:05.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5542" PostTypeId="2" ParentId="5540" CreationDate="2015-11-19T21:35:44.350" Score="0" Body="&lt;p&gt;Here is a sample text to test the regex you want to build :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this line doesn't begin with a space&#xA; this line begins with a space and the previous line doesn't end with =&#xA; this line begins with a space and the previous line ends with =&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The set of characters &lt;code&gt;[a-zA-Z]&lt;/code&gt; can be expressed with the atom &lt;code&gt;\a&lt;/code&gt;.&#xA;So your regex can be rewritten like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^ .*.\a.*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now your regex uses the &lt;code&gt;^&lt;/code&gt; character, which stands for a beginning of a line. The problem is it can only be used at the beginning of the regex. To describe a beginning of line anywhere inside the regex, you have to use &lt;code&gt;\_^&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you don't want the previous line to begin with the character &lt;code&gt;=&lt;/code&gt;.&#xA;This can be expressed with the following regex (in very magic mode) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(\=\n)@&amp;lt;!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The end result is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(\=\n)@&amp;lt;!\_^ .*.\a.*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you want to be sure the very magic mode is enabled :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v(\=\n)@&amp;lt;!\_^ .*.\a.*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-19T21:50:44.710" LastActivityDate="2015-11-19T21:50:44.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5543" PostTypeId="1" AcceptedAnswerId="5544" CreationDate="2015-11-19T22:40:04.900" Score="1" ViewCount="508" Body="&lt;p&gt;I have trouble with one specific folding expression, &lt;code&gt;s1&lt;/code&gt;. The documentation (&lt;code&gt;:h fold-expr&lt;/code&gt;) says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;s1&quot;, &quot;s2&quot;, ..  subtract one, two, .. from the fold level of the&#xA;            previous line&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However this is not true for me. Create a file &lt;code&gt;.vim/after/ftplugin/vim/test.vim/&lt;/code&gt; with the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot; This is a demo, the fold starts here. This line has foldlevel 1&#xA;&quot; This line is folded wrong, it should have foldlevel 0, but has foldlevel 1&#xA;function! VimFolds(lnum)&#xA;  let thisline = getline(a:lnum)&#xA;  if match(thisline, '^&quot;&quot;') &amp;gt;= 0&#xA;    return '&amp;gt;1'&#xA;  elseif match(thisline, '^&quot; ') &amp;gt;= 0&#xA;    return 's1'&#xA;  else&#xA;    return '='&#xA;  endif&#xA;endfunction&#xA;setlocal foldmethod=expr&#xA;setlocal foldexpr=VimFolds(v:lnum)&#xA;set foldcolumn=3&#xA;set foldminlines=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Open the file with Vim, it should be folded according to its own rules. The second line should be on foldlevel 0 according to documentation, but is on foldlevel 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I understanding something wrong here on how to use this?&lt;/p&gt;&#xA;" OwnerUserId="3282" LastEditorUserId="3282" LastEditDate="2015-11-19T23:35:07.657" LastActivityDate="2015-11-19T23:45:20.107" Title="fold-expr not working as expected" Tags="|folding|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5544" PostTypeId="2" ParentId="5543" CreationDate="2015-11-19T23:45:20.107" Score="1" Body="&lt;pre&gt;&lt;code&gt;&quot;&quot; This is a demo, the fold starts here. This line has foldlevel 1&#xA;&quot; This line is folded wrong, it should have foldlevel 0, but has foldlevel 1&#xA;function! VimFolds(lnum)&#xA;  let thisline = getline(a:lnum)&#xA;  if thisline =~ '^&quot;&quot;'&#xA;    return '&amp;gt;1'&#xA;  elseif thisline =~ '^&quot; '&#xA;    return foldlevel(a:lnum-1)-1&#xA;  else&#xA;    return foldlevel(a:lnum-1)&#xA;  endif&#xA;endfunction&#xA;set foldmethod=expr&#xA;set foldexpr=VimFolds(v:lnum)&#xA;set foldcolumn=3&#xA;set foldminlines=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know how to make the &lt;code&gt;'s1'&lt;/code&gt; value work as intended either.&lt;br&gt;&#xA;However the code above seems to do what you want.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastActivityDate="2015-11-19T23:45:20.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5545" PostTypeId="1" AcceptedAnswerId="5548" CreationDate="2015-11-20T02:07:33.847" Score="3" ViewCount="1960" Body="&lt;p&gt;While editing buffer A, I would like to append some text to buffer B without leaving buffer A. How can I achieve that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ultimate goal is to form a collection of words that I cherry-pick from the buffer I am currently editing without having to switch buffers or windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My plan was to write a mapping to yank &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; and append it to another buffer in its own line, but I can't figure out how to write to a different buffer.&lt;/p&gt;&#xA;" OwnerUserId="5374" LastActivityDate="2015-11-20T20:20:44.320" Title="How can I append text to another buffer?" Tags="|key-bindings|buffers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5546" PostTypeId="1" AcceptedAnswerId="5731" CreationDate="2015-11-20T04:07:59.960" Score="4" ViewCount="909" Body="&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#%7Bevent%7D&quot; rel=&quot;nofollow&quot;&gt;the Vim event documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim recognizes the following events.  Vim ignores the case of event&#xA;  names (e.g., you can use &quot;BUFread&quot; or &quot;bufread&quot; instead of &quot;BufRead&quot;).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So in &lt;a href=&quot;https://github.com/Gnouc/dot_config_file/blob/master/.vim/custom_filetype.vim#L93&quot; rel=&quot;nofollow&quot;&gt;my custom_filetype.vim&lt;/a&gt;, I use &lt;code&gt;au filetype&lt;/code&gt; to run a command when &lt;code&gt;FileType&lt;/code&gt; events occur. It worked fine for me until I updated my &lt;code&gt;vim&lt;/code&gt; to a newer patch level:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 19 2015 14:09:11)&#xA;Included patches: 1-922&#xA;Compiled by cuonglm@debian&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;vim&lt;/code&gt; will raise an error with &lt;code&gt;au filetype&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim&#xA;line   93:&#xA;E216: No such event: jinja :call Jinja_config()&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Changing any letter in &lt;code&gt;filetype&lt;/code&gt; to uppercase, like &lt;code&gt;Filetype&lt;/code&gt;, &lt;code&gt;fileType&lt;/code&gt; or even &lt;code&gt;fIletype&lt;/code&gt; worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I went through git log but can not find any issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this change intentional or do I have any mis-configuration?&lt;/p&gt;&#xA;" OwnerUserId="1892" LastEditorUserId="205" LastEditDate="2015-12-23T07:47:43.630" LastActivityDate="2015-12-23T07:47:43.630" Title="Why doesn't Vim work with lowercase event names?" Tags="|autocmd|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="5548" PostTypeId="2" ParentId="5545" CreationDate="2015-11-20T07:59:16.683" Score="4" Body="&lt;p&gt;As you said in your post, you can grab the word under the cursor with the special keyword &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; (or &lt;code&gt;&amp;lt;cWORD&amp;gt;&lt;/code&gt; if you want a big word), but before writing it inside a buffer you need to expand it :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expand(&quot;&amp;lt;cword&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, you need a function to write into a buffer.&lt;br&gt;&#xA;When you are looking for a function, type &lt;code&gt;:help function-list&lt;/code&gt;.&lt;br&gt;&#xA;It will give you a list of all the functions available sorted by category.&lt;br&gt;&#xA;In this buffer of the help, if you search for the word &lt;em&gt;file&lt;/em&gt;, you will find a category of functions that allow you to manipulate files :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help file-functions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the bottom of this category, there's a function that seems to do what you want (write into another buffer) : &lt;code&gt;writefile()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details on how to use it, read &lt;code&gt;:h writefile(&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To write a word inside a buffer and append it to its existing content here is the syntax given by the help :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call writefile([&quot;foo&quot;], &quot;event.log&quot;, &quot;a&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You just need to replace &quot;foo&quot; with the word under the cursor and &quot;event.log&quot; with the name of the buffer in which you want to append some text (let's say for example &quot;file&quot;).&lt;br&gt;&#xA;It gives something like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call writefile([expand(&quot;&amp;lt;cword&amp;gt;&quot;)], &quot;file&quot;, &quot;a&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, you need a mapping to do it automatically :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;a :&amp;lt;c-u&amp;gt;call writefile([expand(&quot;&amp;lt;cword&amp;gt;&quot;)], &quot;file&quot;, &quot;a&quot;)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here I've chosen &lt;code&gt;&amp;lt;leader&amp;gt;a&lt;/code&gt; as a mapping, but you can choose another one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you could have the following message error :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Warning: File &quot;{filename}&quot; has changed since editing started&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The solution given by the help is to set an option in your &lt;code&gt;$MYVIMRC&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoread&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Two possible improvements :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To write in the alternate file (the file that was last edited in the current window) instead of &lt;code&gt;file&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;a :&amp;lt;c-u&amp;gt;call writefile([expand(&quot;&amp;lt;cword&amp;gt;&quot;)], expand(&quot;#&quot;), &quot;a&quot;)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In case you use a split window, to update all the splits, you can use the following command :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;windo e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the previous mappings become :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;a :&amp;lt;c-u&amp;gt;call writefile([expand(&quot;&amp;lt;cword&amp;gt;&quot;)], &quot;file&quot;, &quot;a&quot;) \| windo e&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;a :&amp;lt;c-u&amp;gt;call writefile([expand(&quot;&amp;lt;cword&amp;gt;&quot;)], expand(&quot;#&quot;), &quot;a&quot;) \| windo e&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-20T20:20:44.320" LastActivityDate="2015-11-20T20:20:44.320" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5549" PostTypeId="1" AcceptedAnswerId="5554" CreationDate="2015-11-20T09:30:04.283" Score="4" ViewCount="1800" Body="&lt;p&gt;I am looking for a transformation that would change this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    text&#xA;        indented&#xA;        text&#xA;            double&#xA;            indented&#xA;            text&#xA;        indented&#xA;        again&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text&#xA;    indented&#xA;    text&#xA;        double&#xA;        indented&#xA;        text&#xA;    indented&#xA;    again&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then wouldn't change anything if applied again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I a nutshell, I need to keep the minimal indentation level without loosing the relative indentations of the lines. So just drop the indentations that run all along the selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a clever way to do so ?&lt;/p&gt;&#xA;" OwnerUserId="2978" LastEditorUserId="2978" LastEditDate="2015-11-20T10:00:10.407" LastActivityDate="2015-11-20T16:14:34.743" Title="Remove unecessary indents while keeping the relative indentation" Tags="|indentation|formatting|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5551" PostTypeId="2" ParentId="5549" CreationDate="2015-11-20T11:10:51.983" Score="1" Body="&lt;p&gt;The following code add a mapping &lt;code&gt;&amp;lt;leader&amp;gt;s&lt;/code&gt; that should do what you want on the specific file you provided, if you use spaces to indent.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;s :&amp;lt;c-u&amp;gt;call UnindentSpaces()&amp;lt;cr&amp;gt;&#xA;&#xA;function! UnindentSpaces()&#xA;&#xA;    function! GlobalUnindent()&#xA;&#xA;        let line = getline('.')&#xA;        let p = match(line, '\S') - s:n&#xA;        s;^\s*;\=repeat(' ', p);&#xA;&#xA;    endfunction&#xA;&#xA;    let line = getline(1)&#xA;    let s:n = match(line, '\S')&#xA;    if s:n &amp;gt; 0&#xA;        g/^/call GlobalUnindent()&#xA;    endif&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Conditions in which I tested this code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set expandtab&#xA;set tabstop=4 softtabstop=4 shiftwidth=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use a tab character to indent, then the following code should be used instead (&lt;code&gt;&amp;lt;leader&amp;gt;t&lt;/code&gt;) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;t :&amp;lt;c-u&amp;gt;call UnindentTabs()&amp;lt;cr&amp;gt;&#xA;&#xA;function! UnindentTabs()&#xA;&#xA;    function! GlobalUnindent()&#xA;&#xA;        let line = getline('.')&#xA;        let p = match(line, '\S') - s:n&#xA;        s;^\s*;\=repeat(&quot;\t&quot;, p);&#xA;&#xA;    endfunction&#xA;&#xA;    let line = getline(1)&#xA;    let s:n = match(line, '\S')&#xA;    if s:n &amp;gt; 0&#xA;        g/^/call GlobalUnindent()&#xA;    endif&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Conditions in which I tested this code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noexpandtab&#xA;set tabstop=4 softtabstop=4 shiftwidth=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tell me if it works for you, otherwise I'll try to modify it if I can.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; : if you can rely on the first character of the first line to detect whether the file use spaces or tabs for indentation, then I think you can do it with only one mapping (&lt;code&gt;&amp;lt;leader&amp;gt;u&lt;/code&gt;) and one function which will cover both cases (tabs vs spaces) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;u :&amp;lt;c-u&amp;gt;call Unindent()&amp;lt;cr&amp;gt;&#xA;&#xA;function! Unindent()&#xA;&#xA;    function! GlobalUnindent()&#xA;&#xA;        let line = getline('.')&#xA;        let p = match(line, '\S') - s:n&#xA;        s;^\s*;\=repeat(s:indentchar, p);&#xA;&#xA;    endfunction&#xA;&#xA;    let line = getline(1)&#xA;    let s:indentchar = matchstr(line, '\%1c.')&#xA;    let s:n = match(line, '\S')&#xA;&#xA;    if s:n &amp;gt; 0&#xA;        g/^/call GlobalUnindent()&#xA;    endif&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-20T12:37:50.633" LastActivityDate="2015-11-20T12:37:50.633" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5552" PostTypeId="1" AcceptedAnswerId="5553" CreationDate="2015-11-20T14:52:56.540" Score="1" ViewCount="304" Body="&lt;p&gt;i have the following Text in my vim ('|' is my cursor.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;|--------------[ LatexBox ]-------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When i press &lt;code&gt;ci[&lt;/code&gt;, nothing happens. I would expect that it doesn't matter where exactly in the line my cursor is. at least when a pair of brackets in the line is.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;--------------[| LatexBox ]-------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, when i press &lt;code&gt;ci[&lt;/code&gt; nvim delets the content of the Brackets and puts me in insert mode, as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;=&gt; How can i fix that?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I know &lt;a href=&quot;https://vi.stackexchange.com/q/19/2354&quot;&gt;this&lt;/a&gt; question, but in this example i don't have multiple brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Btw. that example doesn't work also in a single buffer without any other content (suggested also in &lt;a href=&quot;https://vi.stackexchange.com/q/19/2354&quot;&gt;1&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-11-20T15:31:14.170" Title="ci[ ; bracket recognition fails" Tags="|cursor-motions|neovim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5553" PostTypeId="2" ParentId="5552" CreationDate="2015-11-20T15:31:14.170" Score="4" Body="&lt;p&gt;What you see is the expected behavior of &lt;code&gt;ci[&lt;/code&gt; (and &lt;code&gt;ci(&lt;/code&gt;, and &lt;code&gt;ci{&lt;/code&gt;). There is &lt;em&gt;nothing&lt;/em&gt; to &quot;fix&quot;, here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you can use &lt;a href=&quot;https://gist.github.com/sjl/1171642&quot; rel=&quot;nofollow&quot;&gt;this script&lt;/a&gt; to add your desired behavior to Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Motion for &quot;next/last object&quot;. For example, &quot;din(&quot; would go to the next &quot;()&quot; pair&#xA;&quot; and delete its contents.&#xA;&#xA;onoremap an :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;NextTextObject('a', 'f')&amp;lt;cr&amp;gt;&#xA;xnoremap an :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;NextTextObject('a', 'f')&amp;lt;cr&amp;gt;&#xA;onoremap in :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;NextTextObject('i', 'f')&amp;lt;cr&amp;gt;&#xA;xnoremap in :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;NextTextObject('i', 'f')&amp;lt;cr&amp;gt;&#xA;&#xA;onoremap al :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;NextTextObject('a', 'F')&amp;lt;cr&amp;gt;&#xA;xnoremap al :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;NextTextObject('a', 'F')&amp;lt;cr&amp;gt;&#xA;onoremap il :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;NextTextObject('i', 'F')&amp;lt;cr&amp;gt;&#xA;xnoremap il :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;NextTextObject('i', 'F')&amp;lt;cr&amp;gt;&#xA;&#xA;function! s:NextTextObject(motion, dir)&#xA;  let c = nr2char(getchar())&#xA;&#xA;  if c ==# &quot;b&quot;&#xA;      let c = &quot;(&quot;&#xA;  elseif c ==# &quot;B&quot;&#xA;      let c = &quot;{&quot;&#xA;  elseif c ==# &quot;d&quot;&#xA;      let c = &quot;[&quot;&#xA;  endif&#xA;&#xA;  exe &quot;normal! &quot;.a:dir.c.&quot;v&quot;.a:motion.c&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-11-20T15:31:14.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5554" PostTypeId="2" ParentId="5549" CreationDate="2015-11-20T16:14:34.743" Score="3" Body="&lt;p&gt;Delete the text linewise and then paste with &lt;code&gt;]p&lt;/code&gt; with your cursor from an empty line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dG]p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;]p&lt;/code&gt; is doing all the hard work. &lt;code&gt;]p&lt;/code&gt; will paste the text, but will adjust the indent to the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h ]p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-11-20T16:14:34.743" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5555" PostTypeId="2" ParentId="5383" CreationDate="2015-11-20T21:28:29.120" Score="0" Body="&lt;p&gt;Try netrw v155c -- it provides two maps for argument list handling.  Essentially, ma moves marked file names to the argument list and mA will go the other direction.  You can get v155c from &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#NETRW&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-11-20T21:28:29.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5556" PostTypeId="2" ParentId="5439" CreationDate="2015-11-20T21:55:58.173" Score="2" Body="&lt;p&gt;Try netrw v155d ; it won't treat the url ending with a &quot;/&quot; as a file to be obtained.  You can get it from &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#NETRW&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-11-20T21:55:58.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5557" PostTypeId="2" ParentId="4968" CreationDate="2015-11-20T22:15:00.040" Score="0" Body="&lt;p&gt;I'm using netrw v155d; I don't see the split taking place (just the error message, which a :q handles just fine).  Perhaps you should try updating your netrw: &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#NETRW&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-11-20T22:15:00.040" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5558" PostTypeId="2" ParentId="3944" CreationDate="2015-11-20T22:22:28.793" Score="0" Body="&lt;p&gt;That looks like the contents of .netrwhist, a file typically placed in ~/.vim/.netrwhist.  I suggest upgrading your netrw and see if that fixes the problem, because I'm not seeing it: &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#NETRW&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-11-20T22:22:28.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5559" PostTypeId="2" ParentId="4566" CreationDate="2015-11-20T22:28:06.060" Score="1" Body="&lt;p&gt;Yes -- seems you have a number of people answering who don't use gvim because such search support is easily seen under the netrw menu.  So, look at :help netrw-star . In particular,  :Explore */pattern .&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-11-20T22:28:06.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5561" PostTypeId="2" ParentId="3771" CreationDate="2015-11-20T22:47:35.297" Score="3" Body="&lt;p&gt;There are a lot of commands in netrw for directory navigation.  Some that come to mind:  &lt;code&gt;:Rexplore&lt;/code&gt; (to return from a file to netrw); &lt;code&gt;:help netrw-qb&lt;/code&gt; will inform you of netrw's history mechanism (u, U), &lt;code&gt;:help g:netrw_keepdir&lt;/code&gt;, etc.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastEditorUserId="19908" LastEditDate="2018-11-21T23:06:07.667" LastActivityDate="2018-11-21T23:06:07.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5562" PostTypeId="1" CreationDate="2015-11-21T02:38:54.870" Score="0" ViewCount="103" Body="&lt;p&gt;I quite often open linux system configuration files with vim and sometimes  have a session with lots of tabs, splits, quicklists etc that I want to save to a session and restore again later.&lt;br&gt;&#xA;The problem is I usually only open as a non-root user with read-only access and therefore my vim process doesn't have privileges to save the &lt;code&gt;Session.vim&lt;/code&gt; file in the current directory (I guess it may be able to save to home - but My preference is to save the session file to the site where I'm working).&lt;br&gt;&#xA;Is it possible to elevate to &lt;code&gt;sudo&lt;/code&gt; privileges inside vim simply for the &lt;code&gt;:mksession&lt;/code&gt; command? &lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2015-11-21T02:58:19.823" LastActivityDate="2015-11-21T03:46:35.930" Title="How can I save a session in a directory owned by root?" Tags="|sessions|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="5563" PostTypeId="2" ParentId="5562" CreationDate="2015-11-21T02:55:21.013" Score="1" Body="&lt;p&gt;Its a bit hacky, so I'd be interested if anyone else has a better answer, but I was able to achieve this inside vim with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:! sudo touch Session.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:! sudo chown user:user Session.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:mksession Session.vim&lt;/code&gt; or &lt;code&gt;:Obsess&lt;/code&gt; (because I'm using tim popes &lt;code&gt;vim-obsession&lt;/code&gt; plugin)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2015-11-21T02:55:21.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5565" PostTypeId="1" AcceptedAnswerId="5566" CreationDate="2015-11-21T06:23:43.720" Score="5" ViewCount="4763" Body="&lt;p&gt;I know that there is already a method to move the cursor to a particular line in vim like &lt;code&gt;:25&lt;/code&gt; and it moves to line number 25. But can I configure vim to move to 15th column in 25th line say something like this &lt;code&gt;:25:15&lt;/code&gt; ?  &lt;/p&gt;&#xA;" OwnerUserId="2758" LastEditorUserId="4676" LastEditDate="2015-11-25T08:32:39.497" LastActivityDate="2015-11-25T08:32:39.497" Title="How to move cursor in a specific column" Tags="|vimrc|cursor-movement|macvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5566" PostTypeId="2" ParentId="5565" CreationDate="2015-11-21T07:20:30.020" Score="12" Body="&lt;p&gt;If you want to do it from the normal mode, just type: &lt;code&gt;15|&lt;/code&gt;. If you want to move to 15th column in 25th, type &lt;code&gt;25G15|&lt;/code&gt;. If you want to do it as a command you can type: &lt;code&gt;:call cursor(25,15)&lt;/code&gt; but I think it is easier to type &lt;code&gt;25G15|&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5139" LastActivityDate="2015-11-21T07:20:30.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5567" PostTypeId="1" AcceptedAnswerId="5665" CreationDate="2015-11-21T14:05:59.960" Score="4" ViewCount="2646" Body="&lt;p&gt;Currently, I use &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow&quot;&gt;vim-plug&lt;/a&gt; for managing plugins and &lt;a href=&quot;https://github.com/flazz/vim-colorschemes&quot; rel=&quot;nofollow&quot;&gt;vim-colorschemes&lt;/a&gt; for my  colorschemes - which doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Approach 1:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in my init.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'flazz/vim-colorschemes'&#xA;[...]&#xA;syntax on&#xA;colorscheme babymate256&#xA;set background=dark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Putting those colorscheme settings at the end of my init.vim(=after my mappings), works. Putting those before my mappings (but after &lt;code&gt;filetype plugin&lt;/code&gt;&#xA;and that) doesn't. That doesn't make much sense to me, but as neovim supports asynchron execution, that may be the cause.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting &lt;code&gt;set runtimepath+=~/.dotfiles/nvim/plugged/vim-colorschemes/colors&lt;/code&gt; before those colorscheme settings doesn't work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Approach 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting all colorschemes from &lt;code&gt;nvim/plugged/vim-colorschemes/colors&lt;/code&gt; into &lt;code&gt;nvim/colors/&lt;/code&gt; doesn't change anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, i can set my colorscheme manually after nvim has started.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I thought of using just an if structure for setting the colorscheme, but i don't know what i could test, as the colorscheme set doesn't provide any variables.&lt;/li&gt;&#xA;&lt;li&gt;why does the manual configuration using nvim/color doesn't work?&lt;/li&gt;&#xA;&lt;li&gt;Do you have suggestions on how to manage colorschemes?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I don't like setting it at the end of my file, as it destroys my file structure.&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="2354" LastEditDate="2015-11-21T14:17:30.687" LastActivityDate="2019-09-20T07:37:24.110" Title="non-default colorschemes can't be loaded; setting them manually after startup works" Tags="|colorscheme|neovim|startup|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5568" PostTypeId="1" AcceptedAnswerId="5569" CreationDate="2015-11-21T20:19:47.293" Score="0" ViewCount="385" Body="&lt;p&gt;I'm trying to join a list within a function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mylist=split(globpath(&amp;amp;rtp, 'custompath/*'))&#xA;mylist=join(mylist,&quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'm getting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E492: Not an editor command:     mylist=join(mylist,&quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm sure I'm missing something fundamental...&lt;/p&gt;&#xA;" OwnerUserId="2312" LastActivityDate="2015-11-21T20:27:30.620" Title="split/join lists -&gt; E492" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5569" PostTypeId="2" ParentId="5568" CreationDate="2015-11-21T20:27:30.620" Score="3" Body="&lt;p&gt;&lt;code&gt;mylist=..&lt;/code&gt; is not a command. You want to &lt;strong&gt;let&lt;/strong&gt; the variable, e.g. &lt;code&gt;let mylist=...&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-11-21T20:27:30.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5570" PostTypeId="1" CreationDate="2015-11-22T10:54:11.297" Score="1" ViewCount="67" Body="&lt;p&gt;I often find navigation of :help files to be cumbersome. Given that they are mostly structured information, is there an existing way of using this structure for initially folded display? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. after installing a new plugin, I'd like to browse the :help [plugin] by looking at the folded TOC. In a perfect world, after opening help I can see all of the top level help topics and I can descend into any one using zo/zO/similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know of a plugin that provides syntax folding for help files, or is there some other easy way to get this working?&lt;/p&gt;&#xA;" OwnerUserId="5089" LastActivityDate="2015-11-22T17:12:00.303" Title="Folded display of help files?" Tags="|help-system|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5571" PostTypeId="1" AcceptedAnswerId="5572" CreationDate="2015-11-22T12:39:45.993" Score="5" ViewCount="2418" Body="&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Toggle_auto-indenting_for_code_paste&quot; rel=&quot;noreferrer&quot;&gt;This&lt;/a&gt; wikia page explains how to paste text from a different application into vim when in insert mode. Simply apply the command &lt;code&gt;set paste&lt;/code&gt; and things will work as expected. After you are done, just enter command &lt;code&gt;set nopaste&lt;/code&gt; to go back to the original state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some unwanted behavior of staying in the &lt;code&gt;set paste&lt;/code&gt; state? If I put that command in my .vimrc, will it affect any other command? &lt;/p&gt;&#xA;" OwnerUserId="4562" LastActivityDate="2015-11-22T13:23:53.590" Title="Effects of set paste" Tags="|cut-copy-paste|insert-mode|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5572" PostTypeId="2" ParentId="5571" CreationDate="2015-11-22T13:06:26.643" Score="3" Body="&lt;p&gt;As the &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27paste%27&quot; rel=&quot;nofollow&quot;&gt;documentation states&lt;/a&gt; setting the &lt;code&gt;paste&lt;/code&gt; option disables many features:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; When the 'paste' option is switched on (also when it was already on):&#xA;                - mapping in Insert mode and Command-line mode is disabled&#xA;                - abbreviations are disabled&#xA;                - 'autoindent' is reset&#xA;                - 'expandtab' is reset&#xA;                - 'formatoptions' is used like it is empty&#xA;                - 'revins' is reset&#xA;                - 'ruler' is reset&#xA;                - 'showmatch' is reset&#xA;                - 'smartindent' is reset&#xA;                - 'smarttab' is reset&#xA;                - 'softtabstop' is set to 0&#xA;                - 'textwidth' is set to 0&#xA;                - 'wrapmargin' is set to 0&#xA;        These options keep their value, but their effect is disabled:&#xA;                - 'cindent'&#xA;                - 'indentexpr'&#xA;                - 'lisp'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can of course stay in paste mode, but one usually doesn't, because it disables too many features.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-11-22T13:06:26.643" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5573" PostTypeId="2" ParentId="5571" CreationDate="2015-11-22T13:09:32.023" Score="2" Body="&lt;p&gt;The &lt;em&gt;many&lt;/em&gt; undesirable side effects of &lt;code&gt;'paste'&lt;/code&gt; are explained in &lt;code&gt;:help 'paste'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When the 'paste' option is switched on (also when it was already on):&#xA;    - mapping in Insert mode and Command-line mode is disabled&#xA;    - abbreviations are disabled&#xA;    - 'textwidth' is set to 0&#xA;    - 'wrapmargin' is set to 0&#xA;    - 'autoindent' is reset&#xA;    - 'smartindent' is reset&#xA;    - 'softtabstop' is set to 0&#xA;    - 'revins' is reset&#xA;    - 'ruler' is reset&#xA;    - 'showmatch' is reset&#xA;    - 'formatoptions' is used like it is empty&#xA;These options keep their value, but their effect is disabled:&#xA;    - 'lisp'&#xA;    - 'indentexpr'&#xA;    - 'cindent'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In short, &lt;code&gt;:set paste&lt;/code&gt; is an abomination that should be used &lt;em&gt;only&lt;/em&gt; when you can't avoid it and, even then, disabled as soon as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use Vim's built-in clipboard support as much as you can.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-11-22T13:09:32.023" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5574" PostTypeId="2" ParentId="5571" CreationDate="2015-11-22T13:16:46.170" Score="1" Body="&lt;p&gt;The &lt;code&gt;paste&lt;/code&gt; option is useful so that vim doesn't indent every pasted line by inserting a tab character (or spaces) in front of them which messes the formatting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've noticed two side effects that are a little annoying and are the reason why I don't put &lt;code&gt;set paste&lt;/code&gt; inside my &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, it disables auto-indentation when you're in insert mode even if you type your text normally (no pasting) because vim seems to not make the difference between pasted text and typed text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, at one time I had mapped the &lt;code&gt;jk&lt;/code&gt; sequence as escape (I don't have it anymore), and the mapping doesn't work when &lt;code&gt;paste&lt;/code&gt; is set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I want to copy some text from another program inside vim in a terminal, in insert mode, I usually have the choice between &lt;code&gt;&amp;lt;C-S-v&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-r&amp;gt;*&lt;/code&gt; or &lt;code&gt;&amp;lt;C-r&amp;gt;+&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a vim plugin called &lt;a href=&quot;https://github.com/ConradIrwin/vim-bracketed-paste&quot; rel=&quot;nofollow&quot;&gt;vim-bracketed-paste&lt;/a&gt; that allows a recent terminal to tell vim that the text is being pasted from an external program. It solves the problem of extra indentation when pasting with &lt;code&gt;&amp;lt;C-S-v&amp;gt;&lt;/code&gt; but not with &lt;code&gt;&amp;lt;C-r&amp;gt;*&lt;/code&gt; or &lt;code&gt;&amp;lt;C-r&amp;gt;+&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note you can also paste while in normal mode with &lt;code&gt;&quot;+p&lt;/code&gt; or &lt;code&gt;&quot;*p&lt;/code&gt;.&#xA;The first one allows you to paste what's inside the system clipboard, the second one what's selected in an external program.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-22T13:23:53.590" LastActivityDate="2015-11-22T13:23:53.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5575" PostTypeId="1" CreationDate="2015-11-22T17:02:36.983" Score="4" ViewCount="416" Body="&lt;p&gt;I found the following command, which saves the current file with &lt;code&gt;sudo&lt;/code&gt;, meaning you can open a file you don't have write access to (as long as you &lt;em&gt;do&lt;/em&gt; have read access), in the amazing &lt;a href=&quot;https://github.com/amix/vimrc&quot; rel=&quot;nofollow&quot;&gt;Ultimate vimrc&lt;/a&gt; by &lt;code&gt;amix&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command W w !sudo tee % &amp;gt; /dev/null&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you stick this in your &lt;code&gt;vimrc&lt;/code&gt;, then type &lt;code&gt;:W&lt;/code&gt; in any open file, &lt;code&gt;vim&lt;/code&gt;gives you 2 options: &lt;code&gt;Load&lt;/code&gt;, which reloads the file with the new changes, and &lt;code&gt;OK&lt;/code&gt;, which does not reload the file, but keeps the changes to the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there an equivalent command for saving and quitting at the same time?&lt;/strong&gt; It would be to &lt;code&gt;:x&lt;/code&gt; what this &lt;code&gt;:W&lt;/code&gt; command is to &lt;code&gt;:w&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5399" LastActivityDate="2015-11-24T16:27:02.623" Title="Save/Quit Unprivileged File With Sudo" Tags="|save|quit|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5576" PostTypeId="2" ParentId="5570" CreationDate="2015-11-22T17:12:00.303" Score="1" Body="&lt;p&gt;Forget the folding. Use something like this in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType vim,help setlocal keywordprg=:help&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and then you can hit &lt;code&gt;K&lt;/code&gt; every time your mouse is on a help keyword/tag, to jump directly to that help topic. To jump back, you can use &lt;code&gt;Ctrl-o&lt;/code&gt;. This also works for the right part of each line from the TOC (hence its usefulness), and it's more powerful than folding - you can jump between files, and back to were you started.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-11-22T17:12:00.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5577" PostTypeId="1" AcceptedAnswerId="5578" CreationDate="2015-11-22T17:40:08.943" Score="3" ViewCount="243" Body="&lt;p&gt;In vim I currently have this window arrangement&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+----------------------------+&#xA;|                            |&#xA;|             1              |&#xA;+----------------------------+&#xA;|                            |&#xA;|             2              |&#xA;+----------------------------+&#xA;|                            |&#xA;|             3              |&#xA;+----------------------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is what I want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+-------------+--------------+&#xA;|             |              |&#xA;|             |              |&#xA;|    1        |      2       |&#xA;|             |              |&#xA;|             |              +&#xA;+-------------+--------------+&#xA;|                            |&#xA;|             3              |&#xA;+----------------------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I focus on 1 - then try to convert the &lt;code&gt;1 &amp;amp; 2&lt;/code&gt; horizontal split to vertical  with &lt;code&gt;&amp;lt;C-w&amp;gt;H&lt;/code&gt; I end up with this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+------+------+&#xA;|      |      |&#xA;|      |   2  |&#xA;|  1   +------+&#xA;|      |      |&#xA;|      |   3  |&#xA;+------+------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2015-11-22T17:54:26.653" Title="How can I reorient this window arrangement?" Tags="|vim-windows|window-management|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5578" PostTypeId="2" ParentId="5577" CreationDate="2015-11-22T17:54:26.653" Score="4" Body="&lt;p&gt;With the windows arranged as in you last illustration, move the cursor to window 3 and type &lt;code&gt;&amp;lt;C-W&amp;gt;J&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-11-22T17:54:26.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5579" PostTypeId="1" CreationDate="2015-11-22T23:21:10.220" Score="1" ViewCount="87" Body="&lt;p&gt;I cannot seem to make the pdfviewer work in the vim-r-plugin in windows 10. &#xA;I use acrobat, and have added the reader to the path. It works with latexsuite, as I use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Tex_ViewRule_pdf = 'AcroRd32'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in vimrc with no problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I try to add &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let vimrplugin_pdfviewer = 'AcroRd32'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to vimrc, I get an error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function ROpenPDF:&#xA;line 41:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried installing sumatrapdf (and add it to the path) and keep vimrc clean and also using sumatra as an option in vimrc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also looked through the windows.vim and common_global.vim and as far as I can see my vimrc-options should be caught by the plugin. But to be sure I tried manually adding let g:rplugin_sumatra_path and let g:rplugin_pdfviewer = 'Sumatra' to my vimrc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions as to where I should look next?&lt;/p&gt;&#xA;" OwnerUserId="5403" LastActivityDate="2015-11-22T23:21:10.220" Title="Pdfviewer not working in vim-r-plugin (windows 10)" Tags="|gvim|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5580" PostTypeId="1" AcceptedAnswerId="5581" CreationDate="2015-11-22T23:23:21.357" Score="4" ViewCount="979" Body="&lt;p&gt;For each &lt;code&gt;autocmd&lt;/code&gt; (or set of related autocommands) in my &lt;code&gt;.vimrc&lt;/code&gt; I currently define an &lt;code&gt;augroup&lt;/code&gt; to &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/14.html&quot; rel=&quot;nofollow&quot;&gt;prevent having multiple autocommands when I re-source my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/a&gt;. I do &lt;em&gt;not&lt;/em&gt; need the &lt;code&gt;augroup&lt;/code&gt; for anything else (e.g. toggling them on or off via settings).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I just remove all the &lt;code&gt;augroup&lt;/code&gt; and &lt;code&gt;autocmd!&lt;/code&gt; clutter surrounding my actual &lt;code&gt;autocmd&lt;/code&gt; and tell Vim to remove all autocommands upon re-sourcing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps adding something similar to the following line on top of my &lt;code&gt;.vimrc&lt;/code&gt; (to unset all previous autocommands)?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! * *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Putting all autocommands in one &lt;code&gt;augroup&lt;/code&gt; is no viable option for me, as I lose my structure then)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2015-11-23T00:54:25.903" Title="Remove augroups around autocmds in .vimrc" Tags="|vimrc|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5581" PostTypeId="2" ParentId="5580" CreationDate="2015-11-22T23:51:41.487" Score="3" Body="&lt;p&gt;Just adding &lt;code&gt;autocmd!&lt;/code&gt; before defining your autocommands, and without any augroup, should be enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an excerpt from &lt;code&gt;:h :autocmd&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When your .vimrc file is sourced twice, the autocommands will appear&#xA;  twice. To avoid this, put this command in your .vimrc file, before&#xA;  defining autocommands:  &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;:autocmd!   &quot; Remove ALL autocommands for the current group.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think that if you don't have any group, and you put &lt;code&gt;autocmd!&lt;/code&gt; inside your vimrc, vim considers that it's inside a default group, and so will delete all the autocommands for the latter which is all autocommands globally, because of this (&lt;code&gt;:h autocmd-groups&lt;/code&gt;) :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When no specific group is selected, Vim uses the default group.  The&#xA;  default group does not have a name.  You cannot execute the&#xA;  autocommands from the default group separately; you can execute them&#xA;  only by executing autocommands for all groups.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But if you want to be sure, there's a way to check.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add this code in a file that is sourced by vim, for example your &lt;code&gt;~/.vimrc&lt;/code&gt; (it will create the &lt;code&gt;:RedirInTab&lt;/code&gt; command) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RedirInTab(command)&#xA;    redir =&amp;gt; s:output&#xA;    silent! execute a:command&#xA;    redir END&#xA;    if empty(s:output)&#xA;        echoerr &quot;No output&quot;&#xA;    else&#xA;        tabnew&#xA;        setlocal ft=help buftype=nofile noswapfile nobuflisted bufhidden=wipe nomodified&#xA;        silent! put=s:output&#xA;    endif&#xA;endfunction&#xA;command! -nargs=+ -complete=command RedirInTab call RedirInTab(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To see all the autocommands installed in your session, you can type &lt;code&gt;:autocmd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But to navigate more easily in the output with the same commands you have in a normal buffer, and to see the number of lines contained in it, type this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:RedirInTab autocmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll see all your currently installed autocommands in a normal buffer displayed in a new tab (it works for any other command that gives an output, like &lt;code&gt;:command&lt;/code&gt;, &lt;code&gt;:function&lt;/code&gt;, &lt;code&gt;:highlight&lt;/code&gt;, etc.). Go at the bottom of the buffer to see how many lines there are (hit &lt;code&gt;&amp;lt;C-g&amp;gt;&lt;/code&gt; or &lt;code&gt;set number&lt;/code&gt; if necessary).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next source your &lt;code&gt;~/.vimrc&lt;/code&gt; a few times (let's say 10). You can source it manually with &lt;code&gt;:so%&lt;/code&gt; and you can repeat this command 10 times by typing &lt;code&gt;10@:&lt;/code&gt;.&#xA;Now reexecute &lt;code&gt;:RedirInTab autocmd&lt;/code&gt; and see how many lines there are this time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't put &lt;code&gt;autocmd!&lt;/code&gt; in your &lt;code&gt;~/.vimrc&lt;/code&gt;, you should probably see a few hundred more lines.&#xA;If you put &lt;code&gt;autocmd!&lt;/code&gt;, the number of lines should be approximately the same.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-23T00:54:25.903" LastActivityDate="2015-11-23T00:54:25.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5582" PostTypeId="2" ParentId="3683" CreationDate="2015-11-23T18:52:16.240" Score="1" Body="&lt;p&gt;As others have mentioned, &lt;a href=&quot;https://github.com/vim-scripts/dbext.vim&quot; rel=&quot;nofollow&quot;&gt;dbext&lt;/a&gt; is probably what you are looking for.  I've been using it for a while now to run queries against a (an?) SQL Server database.  I've only used it for simple querying of stuff, but I believe it can insert, update, delete, etc.&lt;/p&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2015-11-23T18:52:16.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5583" PostTypeId="2" ParentId="3031" CreationDate="2015-11-23T19:46:35.833" Score="4" Body="&lt;p&gt;For your case,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_list_hide='.*\.un\~$'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will do the trick.  See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help /~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for why the extra backslash preceding the tilde is needed.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-11-23T19:46:35.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5584" PostTypeId="2" ParentId="5508" CreationDate="2015-11-23T19:49:58.710" Score="2" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://github.com/rhysd/clever-f.vim&quot; rel=&quot;nofollow&quot;&gt;Clever-F&lt;/a&gt; or &lt;a href=&quot;https://github.com/justinmk/vim-sneak&quot; rel=&quot;nofollow&quot;&gt;Vim-Sneak&lt;/a&gt; plugins to make the &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt; motions automatically search over multiple lines, because usually they will only search within the current line.&lt;/p&gt;&#xA;" OwnerUserId="2919" LastActivityDate="2015-11-23T19:49:58.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5585" PostTypeId="2" ParentId="2845" CreationDate="2015-11-23T20:35:37.613" Score="4" Body="&lt;p&gt;You could try netrw v155e with its size-styling parameter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_sizestyle= &quot;h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Get it from &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#NETRW&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-11-23T20:35:37.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5586" PostTypeId="1" AcceptedAnswerId="5592" CreationDate="2015-11-24T13:04:04.420" Score="7" ViewCount="1633" Body="&lt;p&gt;I want to have the command which is stated in the title. I looked for it in intrinsic Vim command but did not find it. I ran some tutorial online about functions in vim, The idea would be to have something like that in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;command&amp;gt; &amp;lt;argument&amp;gt;: call nextWordWithLetter(argument)&#xA;&#xA;function nextWordWithLetter(letter)&#xA;    &quot; for word i in line&#xA;    &quot; if word i's first letter = letter&#xA;        &quot; col = column of word i&#xA;        &quot; break&#xA;    col | &quot;The command to jump to column number 'col'&#xA;end function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4562" LastActivityDate="2015-12-01T01:29:07.630" Title="Go to the next word starting with specific letter on current line" Tags="|key-bindings|cursor-movement|functions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5587" PostTypeId="2" ParentId="5586" CreationDate="2015-11-24T13:55:52.500" Score="8" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; : &lt;a href=&quot;https://vi.stackexchange.com/a/5592/4939&quot;&gt;Peter Rincker&lt;/a&gt;'s answer is shorter, easier to explain, and can be repeated as many times as you want. My solution is too long, and can't be repeated for several words. I should delete the answer but maybe someone will be interested in it, so I let it here.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'm not sure this is what you want, but try the following code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NextWordWithLetter(type)&#xA;&#xA;    normal! `]vy&#xA;&#xA;    let letter = @0&#xA;    let line = getline('.')&#xA;    let list = split(line)&#xA;&#xA;    for word in list&#xA;        if matchstr(word, '\%1c.') ==# letter&#xA;            let col = match(line, word) + 1&#xA;            execute &quot;normal! &quot; . col . &quot;|&quot;&#xA;            break&#xA;        endif&#xA;    endfor&#xA;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;g :set operatorfunc=NextWordWithLetter&amp;lt;cr&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mapping to call the function is &lt;code&gt;&amp;lt;leader&amp;gt;g&amp;lt;motion&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to move your cursor to the next word beginning with the letter &lt;code&gt;p&lt;/code&gt;, and &lt;code&gt;,&lt;/code&gt; is your leader key, then you could type &lt;code&gt;,gfp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Goal&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want to go to the next word beginning with a specific letter. I don't know if vim already has such a motion built-in, but let's assume it doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We need to define a new motion (like &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;e&lt;/code&gt; etc.).&#xA;Usually, to define a new motion or object, you use the &lt;code&gt;onoremap&lt;/code&gt; command. It's explained in detail &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/15.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how to achieve your goal this way, but I know how to define a new operator that indirectly will do what you want.&lt;br&gt;&#xA;I say &lt;em&gt;indirectly&lt;/em&gt; because the purpose of a new operator, usually, is not &lt;strong&gt;to move&lt;/strong&gt; somewhere, but &lt;strong&gt;to do&lt;/strong&gt; something on a piece of text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim explains how to create a new operator in the help : &lt;code&gt;:h map-operator&lt;/code&gt;. It's also explained &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/32.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/33.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/34.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The syntax may seem weird to you, but here's how it seems to work in vimscript :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g@&lt;/code&gt; is a special operator (like &lt;code&gt;c&lt;/code&gt; to change, &lt;code&gt;d&lt;/code&gt; to delete, &lt;code&gt;y&lt;/code&gt; to copy etc.) that allows you to build your own operator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you type &lt;code&gt;g@{motion}&lt;/code&gt; vim will look for the &lt;code&gt;opfunc&lt;/code&gt; option whose value is supposed to be the name of a function, set the marks &lt;code&gt;`[&lt;/code&gt; and &lt;code&gt;`]&lt;/code&gt; around the text you would have moved over if you had just typed &lt;code&gt;{motion}&lt;/code&gt; (more on this later) and execute the function which can do anything you want on this piece of text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create different operators by writing different functions and setting the &lt;code&gt;opfunc&lt;/code&gt; option to the name of the function you want to use.&lt;br&gt;&#xA;But before delving into what our function does, let's take a look at the mapping we need to trigger it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Mapping&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the end of the piece of code, there's this line :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;g :set operatorfunc=NextWordWithLetter&amp;lt;cr&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It tells vim that whenever you hit &lt;code&gt;&amp;lt;leader&amp;gt;g&lt;/code&gt;, it must silently (&lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt;) set the value of the &lt;code&gt;operatorfunc&lt;/code&gt; option to &lt;code&gt;NextWordWithLetter&lt;/code&gt; and then hit in normal mode &lt;code&gt;g@&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The operator &lt;code&gt;g@&lt;/code&gt; waits for a motion to set the marks &lt;code&gt;`[&lt;/code&gt; and &lt;code&gt;`]&lt;/code&gt; around the text you would have moved over with &lt;code&gt;{motion}&lt;/code&gt; before executing the function stored in &lt;code&gt;opfunc&lt;/code&gt;. Here the function is &lt;code&gt;NextWordWithLetter()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could do the same by typing in command mode :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set operatorfunc=NextWordWithLetter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in normal mode : &lt;code&gt;g@&lt;/code&gt;&lt;br&gt;&#xA;Then always in normal mode : &lt;code&gt;{motion}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But of course it would be tedious, so we create the mapping &lt;code&gt;&amp;lt;leader&amp;gt;g&lt;/code&gt; that automatically sets the &lt;code&gt;operatorfunc&lt;/code&gt; option to the desired function name and hit &lt;code&gt;g@&lt;/code&gt; for us.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's assume your leader key is &lt;code&gt;,&lt;/code&gt; and you are looking for the next word beginning with the letter &lt;code&gt;p&lt;/code&gt;.&#xA;Using our mapping, you could type &lt;code&gt;,gfp&lt;/code&gt;.&lt;br&gt;&#xA;As a result vim will set the marks &lt;code&gt;`[&lt;/code&gt; and &lt;code&gt;`]&lt;/code&gt; around the text between your cursor and the next character &lt;code&gt;p&lt;/code&gt;, set &lt;code&gt;opfunc&lt;/code&gt; to &lt;code&gt;NextWordWithLetter&lt;/code&gt;, and because of the value of this option it will execute the function &lt;code&gt;NextWordWithLetter()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, let's take a look at what the function does.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Setting variables&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First we need to tell the function which character we're looking for :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! `]vy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;normal&lt;/code&gt; command types any sequence of characters you pass to it as if you were in normal mode.&#xA;Here the sequence of characters is &lt;code&gt;`]vy&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you're in a buffer you can set a mark anywhere with the normal command &lt;code&gt;m{letter}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to put the mark &lt;code&gt;a&lt;/code&gt; where your cursor is, you would type &lt;code&gt;ma&lt;/code&gt;. Then, you could move around and go back to the same line as the mark &lt;code&gt;a&lt;/code&gt; with the command &lt;code&gt;'a&lt;/code&gt; or to the exact character where you set the mark &lt;code&gt;a&lt;/code&gt; with the command &lt;code&gt;`a&lt;/code&gt;.&lt;br&gt;&#xA;You can see all your marks with the command &lt;code&gt;:marks&lt;/code&gt;. The uppercase marks are global and can be used to jump across buffers, the lowercase ones are local to a buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two special marks that vim automatically sets for us : &lt;code&gt;`[&lt;/code&gt; and &lt;code&gt;`]&lt;/code&gt;. Whenever you change or yank some text, vim puts those marks around it (&lt;code&gt;:h '[&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's get back to our example : you wanted to go to the next word beginning with the letter &lt;code&gt;p&lt;/code&gt;, so you hit &lt;code&gt;,gfp&lt;/code&gt;. &lt;code&gt;fp&lt;/code&gt; is a command that moves the cursor to the next character &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point, vim is going to automatically set the marks &lt;code&gt;`[&lt;/code&gt; and &lt;code&gt;`]&lt;/code&gt; around the text that we would have moved over if we had just typed &lt;code&gt;{motion}&lt;/code&gt; (&lt;code&gt;fp&lt;/code&gt; in our example).&lt;br&gt;&#xA;It's written in the help (&lt;code&gt;:h g@&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;g@{motion}        Call the function set by the 'operatorfunc' option.             The&#xA;  '[ mark is positioned at the start of the text            moved over by&#xA;  {motion}, the '] mark on the last             character of the text.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;We haven't changed or yanked anything yet, so why does vim already put those marks ? Because it thinks that the function wants to do something on the text, and the function will need those marks to identify the text to operate on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when the &lt;code&gt;normal&lt;/code&gt; command types &lt;code&gt;`]vy&lt;/code&gt;, it can be read as :&lt;br&gt;&#xA;&lt;em&gt;go to the mark &lt;code&gt;`]&lt;/code&gt; (last character of the text moved over), go into visual mode (&lt;code&gt;v&lt;/code&gt;) and copy the visual selection (&lt;code&gt;y&lt;/code&gt;)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now we've copied your searched character (character &lt;code&gt;p&lt;/code&gt;). Everything you copy is in a register. There are different registers in vim, each of them being used for a different purpose . To take a look at them, type &lt;code&gt;:reg&lt;/code&gt;, and to know which register stores what &lt;code&gt;:h registers&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last text you copied is stored in the register &lt;code&gt;0&lt;/code&gt;.&#xA;You can access it with &lt;code&gt;@0&lt;/code&gt; : &lt;code&gt;echo @0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your searched character &lt;code&gt;p&lt;/code&gt; is in this register. We assign it to the variable &lt;code&gt;letter&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let letter = @0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next we assign the current line to the variable &lt;code&gt;line&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let line = getline('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;getline()&lt;/code&gt; is a built-in function which returns the line whose number has been passed as an argument, and &lt;code&gt;'.'&lt;/code&gt; is expanded as the number of the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next we assign to the variable &lt;code&gt;list&lt;/code&gt; a list containing each word of the line :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let list = split(line)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;split()&lt;/code&gt; is a built-in function that splits a string whenever it finds a whitespace (space, tab character...). You can tell it to split at other locations by giving a second argument. For example, if you wanted to split whenever there's a colon character, you would use &lt;code&gt;split(line, ':')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For loop&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;for&lt;/code&gt; loop iterates over the variable &lt;code&gt;list&lt;/code&gt;, and stores each of its item inside the variable &lt;code&gt;word&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for word in list&#xA;...&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, it checks whether the first letter of &lt;code&gt;word&lt;/code&gt; is the letter you're looking for :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if matchstr(word, '\%1c.') ==# letter&#xA;...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;matchstr()&lt;/code&gt; is a built-in function which returns a pattern if it's found inside a string.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here we're looking for the pattern &lt;code&gt;'\%1c.'&lt;/code&gt; inside &lt;code&gt;word&lt;/code&gt;.&#xA;In a vim regex, &lt;code&gt;\%1c&lt;/code&gt; is a zero-width atom. It doesn't add anything to the pattern, it just tells the regex engine which parses the regex that our pattern begins on the first column of the text (for more info &lt;code&gt;:h /\%c&lt;/code&gt;). The dot at the end of the regex means any character.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;'\%1c.'&lt;/code&gt; means : any character on the first column of the text, and &lt;code&gt;matchstr(word, '\%1c.')&lt;/code&gt; will return the first character of &lt;code&gt;word&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To compare the first letter of &lt;code&gt;word&lt;/code&gt; with &lt;code&gt;letter&lt;/code&gt; we use the &lt;code&gt;==#&lt;/code&gt; operator. It's an operator that is case sensitive (no matter what the value of the &lt;code&gt;ignorecase&lt;/code&gt; option is). You could also use &lt;code&gt;==?&lt;/code&gt; which is case insensitive, or a bare &lt;code&gt;==&lt;/code&gt; (which is case sensitive or not depending on &lt;code&gt;ignorecase&lt;/code&gt; ; not recommended to use this one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, if the first character of &lt;code&gt;word&lt;/code&gt; is &lt;code&gt;letter&lt;/code&gt;, here's what the function does :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let col = match(line, word) + 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It stores the index of the first character of &lt;code&gt;word&lt;/code&gt; plus one inside the variable &lt;code&gt;col&lt;/code&gt;. &lt;code&gt;match()&lt;/code&gt; is a built-in function, whose base syntax is &lt;code&gt;match(string, pattern)&lt;/code&gt; and which returns the index in &lt;code&gt;string&lt;/code&gt; where &lt;code&gt;pattern&lt;/code&gt; matches. We add one because vim begins indexing with 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally it executes this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal! &quot; . col . &quot;|&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;execute&lt;/code&gt; is a command that executes the content of any string you pass to it. Here the string is : &lt;code&gt;&quot;normal! &quot; . col . &quot;|&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The dot operator concatenates the 3 strings &lt;code&gt;&quot;normal !&quot;&lt;/code&gt;, &lt;code&gt;col&lt;/code&gt; (it's a number but vim's coercion turns it into a string automatically), and &lt;code&gt;&quot;|&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say your searched character is on the 10th column of the line.&#xA;In this case, the previous string would be evaluated to : &lt;code&gt;&quot;normal! 10|&quot;&lt;/code&gt;.&#xA;So &lt;code&gt;execute&lt;/code&gt; executes &lt;code&gt;&quot;normal! 10|&quot;&lt;/code&gt;, which results in the &lt;code&gt;normal&lt;/code&gt; command typing &lt;code&gt;10|&lt;/code&gt; for us.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2015-11-24T21:24:29.303" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5588" PostTypeId="1" AcceptedAnswerId="5655" CreationDate="2015-11-24T14:13:48.053" Score="1" ViewCount="1363" Body="&lt;p&gt;I have a couple of functions chained together to verbose messages in my status line in MacVim. I have noticed that in one particular occasion a line is blank and is not delivering the message it is supposed to deliver:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[24_NOV_2015 13:59:03.544470] &amp;lt;devLogger.LogStreamOut&amp;gt; (DEBUG) Cycle: [0], Retry state for current cycle: [FALSE]&#xA;(Blank line)&#xA;[24_NOV_2015 13:59:03.554405] &amp;lt;devLogger.LogStreamOut&amp;gt; (DEBUG) Reached last cycle of [0] cycle(s).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I type &lt;code&gt;:messages&lt;/code&gt; I can clearly see the missing line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[24_NOV_2015 13:59:03.544470] &amp;lt;devLogger.LogStreamOut&amp;gt; (DEBUG) Cycle: [0], Retry state for current cycle: [FALSE]&#xA;[24_NOV_2015 13:59:03.552491] &amp;lt;devLogger.LogStreamOut&amp;gt; (DEBUG) Success, stream sent to file.&#xA;[24_NOV_2015 13:59:03.554405] &amp;lt;devLogger.LogStreamOut&amp;gt; (DEBUG) Reached last cycle of [0] cycle(s).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I use a blank &lt;code&gt;echom ''&lt;/code&gt; at the end of my message functions, all 3 lines come through fine, but I get a blank line at the end of the message stream.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a more elegant way to make sure that every message appears in the status line in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My core &lt;code&gt;echom&lt;/code&gt; wrapper looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'echohl' error&#xA;for l:line in split('My message.', '\\n')&#xA;  echomsg l:line&#xA;endfor&#xA;echohl NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;--- CORRECTION ---&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After further investigation, I now know that the &lt;code&gt;echomsg&lt;/code&gt; wrapper that I use to send messages to the messaging facility of vim is not the problem. The problem was a function wrapper that sends the &lt;code&gt;echomsg&lt;/code&gt; to a file in parallel. So this is where something goes wrong and my &lt;code&gt;echomsg&lt;/code&gt; on the status line is messed up (sometimes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;try&#xA;    echon &quot;\r&quot;&#xA;    execute 'redir &amp;gt;&amp;gt; ' . l:file&#xA;    silent echomsg l:msgString&#xA;    silent echo &quot;\n&quot;&#xA;    silent! redir END&#xA;catch /E190:/&#xA;    throw s:myException('Cannot write to file: %s', l:file)&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the right question would probably be: What would be the best way of handling &lt;code&gt;echomsg&lt;/code&gt; both on the &lt;code&gt;file out&lt;/code&gt; and the &lt;code&gt;message&lt;/code&gt; sides.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="5328" LastEditDate="2015-11-29T15:52:52.893" LastActivityDate="2015-11-29T16:58:59.573" Title="How to make sure every 'echo[msg]' command is visible?" Tags="|vimscript|macvim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5589" PostTypeId="1" AcceptedAnswerId="5591" CreationDate="2015-11-24T16:14:46.767" Score="13" ViewCount="1578" Body="&lt;p&gt;I insert this text in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t tttt ttttttttt tt tttt tt ttt tttttt-tttt-ttttttt&#xA;tttttttttttttttttttttttttttttttttttttttttttttttttttttt ttttt ttt ttt tttttt&#xA;ttttttt tttt ttttttt: ttttttt tt ttttttt, ttttttt tt tttttt, tttttt tt ttttttt,&#xA;tttttt tt tttttt ttt. t tttttt tt ttt (tttt) ttttttt-tttttt-tt-ttttttt tttttt&#xA;for the &quot;tttttt in ttttttt&quot; part of the issue (in the previous week I have&#xA;worked on the &quot;objects in objects&quot; part). This part is about making it&#xA;possible for the end user to add arrays in objects. First of all I checked&#xA;that the current implementation allows putting arrays in objects at least&#xA;from the schema passed to the plugin constructor.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then I visually select all these lines and press &lt;code&gt;gq&lt;/code&gt;. The contents become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t tttt ttttttttt tt tttt tt ttt tttttt-tttt-ttttttt&#xA;tttttttttttttttttttttttttttttttttttttttttttttttttttttt ttttt ttt ttt tttttt&#xA;ttttttt tttt ttttttt: ttttttt tt ttttttt, ttttttt tt tttttt, tttttt tt ttttttt,&#xA;tttttt tt tttttt ttt. t tttttt tt ttt (tttt) ttttttt-tttttt-tt-ttttttt tttttt&#xA;for the &quot;tttttt in ttttttt&quot; part of the issue (in the previous week I have&#xA;    worked on the &quot;objects in objects&quot; part). This part is about making it&#xA;    possible for the end user to add arrays in objects. First of all I checked&#xA;    that the current implementation allows putting arrays in objects at least&#xA;    from the schema passed to the plugin constructor.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please explain to me why there is that whitespace at the beginning of the last four lines. Is it possible that the first word (&lt;code&gt;for&lt;/code&gt;) on the fifth line, which in some programming languages starts a &lt;code&gt;for&lt;/code&gt; loop, makes Vim think it should start a new indented block of code, even if these lines are in an unsaved file or in a Markdown file? How can I avoid this behavior and make &lt;code&gt;gq&lt;/code&gt; stop inserting that whitespace?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;comments&lt;/code&gt; setting has the default value: &lt;code&gt;s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:&amp;gt;,fb:-&lt;/code&gt;. You can see my &lt;code&gt;.vimrc&lt;/code&gt; file &lt;a href=&quot;https://github.com/silviubogan/dotfiles/blob/master/.vimrc&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; My &lt;code&gt;fo&lt;/code&gt; (&lt;code&gt;formatoptions&lt;/code&gt;) option has the value &lt;code&gt;tcq&lt;/code&gt;, the &lt;code&gt;formatexpr&lt;/code&gt; and &lt;code&gt;formatprg&lt;/code&gt; options are empty.&lt;/p&gt;&#xA;" OwnerUserId="5010" LastEditorUserId="51" LastEditDate="2015-11-26T23:39:16.943" LastActivityDate="2015-11-26T23:39:16.943" Title="Unexplained gq indentation issue" Tags="|indentation|formatting|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5590" PostTypeId="2" ParentId="5575" CreationDate="2015-11-24T16:27:02.623" Score="4" Body="&lt;p&gt;I don't think there is a save/quit automated, but as a reference to several nix-oriented tasks, there is a plugin that covers much of it (e.g. SudoWrite).   (plugin: &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4300&quot; rel=&quot;nofollow&quot;&gt;eunuch&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To combine the two tasks without using sudo you can use &lt;code&gt;:wq&lt;/code&gt; of course.&lt;br&gt;&#xA;I attempted using &lt;code&gt;:w !sudo tee % | q&lt;/code&gt; which failed.&lt;br&gt;&#xA;Using the &lt;code&gt;eunuch&lt;/code&gt; plugin instead allows: &lt;code&gt;SudoWrite | q&lt;/code&gt; which successfully writes and then quits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, installing that plugin and then using &lt;code&gt;:command! W SudoWrite | q&lt;/code&gt; does the intended sudo-write and then quit.&lt;/p&gt;&#xA;" OwnerUserId="2303" LastActivityDate="2015-11-24T16:27:02.623" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5591" PostTypeId="2" ParentId="5589" CreationDate="2015-11-24T18:09:56.330" Score="19" Body="&lt;p&gt;The problem is that you have set &lt;code&gt;smartindent&lt;/code&gt; in your &lt;code&gt;~/.vimrc&lt;/code&gt;. The &lt;code&gt;smartindent&lt;/code&gt; options causes Vim to assume that your text is some C-like programming language when indenting. Among other things, it treats &lt;code&gt;for&lt;/code&gt; like a keyword and gives an extra level of indentation to the line following. See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'smartindent'&#xA;:help 'cinwords'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-11-24T18:09:56.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5592" PostTypeId="2" ParentId="5586" CreationDate="2015-11-24T19:09:40.430" Score="11" Body="&lt;p&gt;You can use &lt;code&gt;getchar()&lt;/code&gt; and &lt;code&gt;search()&lt;/code&gt; to accomplish your goal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :call search('\&amp;lt;' . nr2char(getchar()), 'W', line('.'))&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is we use &lt;code&gt;nr2char(getchar())&lt;/code&gt; to wait for a character to be typed and use &lt;code&gt;search()&lt;/code&gt; to search for the next instance of the character at the beginning of a word via &lt;code&gt;\&amp;lt;&lt;/code&gt;. We limit this to the current line by supplying the current line, &lt;code&gt;line('.')&lt;/code&gt;, as the third parameter to &lt;code&gt;search()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I think I would rather just use &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;f&lt;/code&gt;, however there are other plugins that provide similar functionality:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/easymotion/vim-easymotion&quot; rel=&quot;nofollow&quot;&gt;EasyMotion&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/goldfeld/vim-seek&quot; rel=&quot;nofollow&quot;&gt;vim-seek&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/justinmk/vim-sneak&quot; rel=&quot;nofollow&quot;&gt;vim-sneak&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/rhysd/clever-f.vim&quot; rel=&quot;nofollow&quot;&gt;clever-f.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/unblevable/quick-scope&quot; rel=&quot;nofollow&quot;&gt;quick-scope&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h search(&#xA;:h getchar(&#xA;:h /\&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-12-01T01:29:07.630" LastActivityDate="2015-12-01T01:29:07.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5593" PostTypeId="2" ParentId="2432" CreationDate="2015-11-24T19:30:53.037" Score="0" Body="&lt;p&gt;If&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You're using gvim&lt;/li&gt;&#xA;&lt;li&gt;Your vim supports +clientserver (see vim --version)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then the following will allow you to simply type  gvim  (by itself) and get a browser display showing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup VimStartup&#xA;au!&#xA;au VimEnter * if expand(&quot;%&quot;) == &quot;&quot; &amp;amp;&amp;amp; argc() == 0 &amp;amp;&amp;amp; (v:servername =~ 'GVIM\d*' || v:servername == &quot;&quot;) | e . | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(put this into your .vimrc)&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-11-24T19:30:53.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5594" PostTypeId="1" AcceptedAnswerId="5615" CreationDate="2015-11-25T01:32:26.997" Score="2" ViewCount="2432" Body="&lt;p&gt;I am looking for an easy way to reflow blocks of comments (in GO).  According to &lt;a href=&quot;https://stackoverflow.com/questions/8435808/reflowing-comment-blocks-with-vim&quot;&gt;this post&lt;/a&gt; I should be able to just run &lt;code&gt;gq&lt;/code&gt; on a block and it will reflow automatically, but this doesn't seem to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some sample text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// PrintStarredRepos tries to print tags of repo's that have been starred&#xA;// adaf da df a da fs daf e according to the &quot;user&quot; configuration setting that is read in from the&#xA;// config file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is what the text looks like after I run &lt;code&gt;gq&lt;/code&gt; on it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// PrintStarredRepos tries to print tags of repo's that have been starred //&#xA;adaf da df a da fs daf e according to the &quot;user&quot; configuration setting that is&#xA;read in from the // config file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are relevant settings in my vimrc based on details I found in &lt;a href=&quot;https://vi.stackexchange.com/questions/4251/vim-gq-command-doesnt-recognize-haskell-style-comments#&quot;&gt;another post&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;textwidth=80&lt;/li&gt;&#xA;&lt;li&gt;filetype plugin indent on&lt;/li&gt;&#xA;&lt;li&gt;set ft?  (filetype=go)&lt;/li&gt;&#xA;&lt;li&gt;set comments? (comments=s1:/&lt;em&gt;,mb:&lt;/em&gt;,ex:*/,://)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I can't figure out why comments aren't wrapping?&lt;/p&gt;&#xA;" OwnerUserId="5423" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-11-26T18:15:31.337" Title="visual mode gq not reflowing comment block" Tags="|visual-mode|formatting|comments|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5595" PostTypeId="1" AcceptedAnswerId="5597" CreationDate="2015-11-25T05:54:45.677" Score="1" ViewCount="379" Body="&lt;p&gt;There comes a time where I'm in a situation of downloading multiple files. And the name of files are in series. Something like.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://www.example.com/files/images/img01.jpg&#xA;http://www.example.com/files/images/img02.jpg&#xA;http://www.example.com/files/images/img03.jpg&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose there are files from &lt;code&gt;img01.jpg&lt;/code&gt; to &lt;code&gt;img49.jpg&lt;/code&gt;. What is the best way to write the full URL of the image on each line &lt;em&gt;(as done above)&lt;/em&gt; without repetition? So that I can pass &lt;code&gt;wget&lt;/code&gt; the list with &lt;code&gt;-i&lt;/code&gt; parameter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;P.S.&lt;/strong&gt;: Don't tell me I can do &lt;code&gt;curl http://www.example.com/files/images/img{01,49}.jpg&lt;/code&gt; in bash to accomplish my work.&lt;/p&gt;&#xA;" OwnerUserId="5425" LastActivityDate="2018-05-23T07:35:48.507" Title="How to write incremental lines in Vim?" Tags="|vimscript|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5596" PostTypeId="2" ParentId="5595" CreationDate="2015-11-25T06:20:49.647" Score="13" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Assuming you have this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://www.example.com/files/images/img01.jpg&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Start recording in some alphabetic register, say &lt;code&gt;q&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Yank the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yy&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Put it below the current line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Increment the number:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Stop the recording:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Play it back 47 times:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;47@q&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In short:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqyyp&amp;lt;C-a&amp;gt;q47@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you will almost certainly need to tell Vim to stop considering numbers starting with &lt;code&gt;0&lt;/code&gt; as octal numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nrformats-=octal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-11-25T06:20:49.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5597" PostTypeId="2" ParentId="5595" CreationDate="2015-11-25T07:43:26.623" Score="13" Body="&lt;p&gt;Here is a different version, that assumes you have Vim &lt;a href=&quot;https://github.com/vim/vim/commit/3a304b23823b089e499063e8211c5695d049f3ba&quot; rel=&quot;nofollow noreferrer&quot;&gt;7.4.754&lt;/a&gt; (25 Jun 2015) or newer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://www.example.com/files/images/img01.jpg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now copy and paste it 48 times &lt;code&gt;yy48p&lt;/code&gt;. Then go to the &lt;em&gt;second line&lt;/em&gt;, visually block select the 01 down to the bottom and press &lt;code&gt;g&amp;lt;C-A&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might need to adjust your &lt;code&gt;'nrformat'&lt;/code&gt; settings as romainl said in his answer.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="1292" LastEditDate="2018-05-23T07:35:48.507" LastActivityDate="2018-05-23T07:35:48.507" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5598" PostTypeId="1" AcceptedAnswerId="5600" CreationDate="2015-11-25T08:42:42.470" Score="0" ViewCount="1972" Body="&lt;p&gt;I want to record a macro, which generates a formatted text that includes a number. I want the number to be counted up whenever the macro is invoked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc 1 def&#xA;abc 2 def&#xA;abc 3 def&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Vim&lt;/code&gt;'s version is &lt;code&gt;7.0&lt;/code&gt;. OS is &lt;code&gt;CentOS 6&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2951" LastActivityDate="2015-11-25T15:18:51.170" Title="auto number counting with macro" Tags="|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5599" PostTypeId="2" ParentId="5598" CreationDate="2015-11-25T09:53:10.787" Score="1" Body="&lt;p&gt;I do something similar in a function to number a list but taking note that the register may change between sessions something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=`number you want eg 10`&#xA;&#xA;qp &quot;Record macro&#xA;:let @a=@a+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Either&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.put a &quot;puts it current line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i   &quot;insert mode&#xA;Ctrl-R a  &quot;Control R a will paste register a&#xA;&#xA;q &quot; finish macro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1313" LastActivityDate="2015-11-25T09:53:10.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5600" PostTypeId="2" ParentId="5598" CreationDate="2015-11-25T15:18:51.170" Score="5" Body="&lt;p&gt;Use &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; mapping will increment a number in your macro.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqyyp&amp;lt;c-a&amp;gt;q@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to duplicate the current line (&lt;code&gt;yy&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt;) and then increment the newly duplicated line (&lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h q&#xA;:h CTRL-A&#xA;:h @&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-11-25T15:18:51.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5601" PostTypeId="1" AcceptedAnswerId="12468" CreationDate="2015-11-25T15:29:35.250" Score="14" ViewCount="2973" Body="&lt;p&gt;I have two windows open on the same buffer and I want to edit two parts of the same file at the same time.  I can't because the windows are scrolling together.  I have &lt;code&gt;noscrollbind&lt;/code&gt; set so I am confused by this.  What else could be causing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I start a new session then the problem goes away.  I'd prefer not to have to close my session because I have memorized all the buffer numbers.  &lt;/p&gt;&#xA;" OwnerUserId="2399" LastEditorUserId="6838" LastEditDate="2017-05-23T21:08:08.097" LastActivityDate="2017-05-24T08:38:09.683" Title="Why are my windows scrolling together?" Tags="|gvim|scrolling|plugin-fugitive|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5602" PostTypeId="2" ParentId="5594" CreationDate="2015-11-25T15:42:15.480" Score="4" Body="&lt;p&gt;You need to check your &lt;code&gt;formatoptions&lt;/code&gt; setting. According to the &lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#fo-table&quot; rel=&quot;nofollow&quot;&gt;manual&lt;/a&gt; you need the &quot;q&quot; flag to be present:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        *fo-table*&#xA;You can use the 'formatoptions' option  to influence how Vim formats text.&#xA;'formatoptions' is a string that can contain any of the letters below.  The&#xA;default setting is &quot;tcq&quot;.  You can separate the option letters with commas for&#xA;readability.&#xA;&#xA;letter   meaning when present in 'formatoptions'&#xA;[...]&#xA;q   Allow formatting of comments with &quot;gq&quot;.&#xA;    Note that formatting will not change blank lines or lines containing&#xA;    only the comment leader.  A new paragraph starts after such a line,&#xA;    or when the comment leader changes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-11-25T15:42:15.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5603" PostTypeId="1" CreationDate="2015-11-25T17:06:38.003" Score="5" ViewCount="2563" Body="&lt;p&gt;When editing markdown (&lt;code&gt;*.md&lt;/code&gt;) formatted files, and making bullet points, upon pressing return I want the new bullet point to be automatically created in the same level under the previous one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately, &lt;code&gt;:set autoindent&lt;/code&gt; does exactly this. However, I shouldn't have to specify it manually according to my &lt;a href=&quot;http://vi.kpaste.net/231abd6cb?raw&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/a&gt; (note the &lt;code&gt;filetype plugin indent on&lt;/code&gt; line and please excuse my horrible config).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tested it also with HTML and JavaScript formatted files, and found that &lt;code&gt;autoindent&lt;/code&gt; &lt;em&gt;is&lt;/em&gt; being applied there.&lt;/p&gt;&#xA;" OwnerUserId="4773" LastActivityDate="2016-01-17T17:57:44.247" Title="Why is autoindent not applied to my markdown files?" Tags="|indentation|filetype-markdown|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5604" PostTypeId="2" ParentId="5603" CreationDate="2015-11-26T00:19:40.460" Score="-1" Body="&lt;p&gt;It seems that there is no default vim plugin for md file type. Using vundle I add this plugin and it seems to work well:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gabrielelana/vim-markdown&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which is the found at github:&#xA;&lt;a href=&quot;https://github.com/gabrielelana/vim-markdown&quot; rel=&quot;nofollow&quot;&gt;https://github.com/gabrielelana/vim-markdown&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To install using vundle add this line in the vundle config section of your .vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Plugin 'gabrielelana/vim-markdown'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To install using pathogen:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim/bundle &amp;amp;&amp;amp; \&#xA;git clone git://github.com/gabrielelana/vim-markdown.git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1181" LastEditorUserId="1181" LastEditDate="2015-11-26T15:18:25.900" LastActivityDate="2015-11-26T15:18:25.900" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5605" PostTypeId="1" CreationDate="2015-11-26T07:13:04.070" Score="0" ViewCount="57" Body="&lt;p&gt;I have a few :cabbrev mappings that I use frequently, like &lt;code&gt;:qq&lt;/code&gt; as a shortcut for &lt;code&gt;:q!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently I installed a &lt;a href=&quot;https://github.com/inside/vim-search-pulse&quot; rel=&quot;nofollow&quot;&gt;nifty plugin&lt;/a&gt; and these abbreviations no longer triggered with &lt;kbd&gt;Enter&lt;/kbd&gt;, although &lt;kbd&gt;Space&lt;/kbd&gt; would still activate them.  It turns out that the plugin rebinds &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in command mode to a function that does some work then returns a string &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, which is presumably interpreted as a keystroke, although I do not know why.  However, the &quot;keystroke&quot; is not triggering abbreviations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a Vim bug, or does the extra &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; need to be triggered some other way?  I would like to keep the plugin if possible, but I really like my abbreviations.&lt;/p&gt;&#xA;" OwnerUserId="2817" LastActivityDate="2015-11-26T08:59:18.367" Title="How to fix :cmap breaking :cabbrev" Tags="|abbreviations|" AnswerCount="1" CommentCount="2" ClosedDate="2015-12-17T12:57:40.493" ContentLicense="CC BY-SA 3.0" />
  <row Id="5606" PostTypeId="1" AcceptedAnswerId="5608" CreationDate="2015-11-26T08:22:29.973" Score="12" ViewCount="2186" Body="&lt;p&gt;So my question is simple. Is it a good idea to learn vim scripting just to create vim or we should adopt some other more accepted languages to that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example &lt;a href=&quot;https://www.google.co.in/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=4&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0ahUKEwjg_uiq063JAhWGj44KHey0ADIQtwIIMDAD&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DvMAeYp8mX_M&amp;amp;usg=AFQjCNHIrZLmVe5tlbtZ6inZrY1vqAonRw&amp;amp;sig2=dZiwP7LG0oxpsIduwW6OBw&quot;&gt;This&lt;/a&gt; link opens a YouTube videos which shows How to use Python to create vim plugins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim scripts are not entirely useful unless one intends to create some vim plugins. So is there any particular thing that can not be done unless vim scripts are used only ?&lt;/p&gt;&#xA;" OwnerUserId="2758" LastActivityDate="2015-11-26T10:20:24.777" Title="What to follow to create a vim plugin?" Tags="|vimscript|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5607" PostTypeId="2" ParentId="5605" CreationDate="2015-11-26T08:59:18.367" Score="1" Body="&lt;p&gt;You can trigger expansion of abbreviations by pressing &lt;code&gt;Ctrl-]&lt;/code&gt;. So perhaps you can add the CTRL-] in front of the mapping of the &lt;code&gt;Enter&lt;/code&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the help at &lt;code&gt;:h i_CTRL-]&lt;/code&gt; and &lt;code&gt;:h c_CTRL-]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you should probably create an issue for that on the plugins repository.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-11-26T08:59:18.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5608" PostTypeId="2" ParentId="5606" CreationDate="2015-11-26T09:28:06.197" Score="13" Body="&lt;p&gt;My plugins are 99% in VimL. The reason is that VimL is available where vim is installed. It's much more complicated with other languages -- for instance, it's rare I have Python installed on the windows boxes where I use Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course VimL is cumbersome, it's missing many cool features, but at least, it's easier to have something portable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 1% not in VimL is when I need to interact with external API which offer python bindings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, almost everything you learn regarding VimL can be used interactively when you play with commands like &lt;code&gt;:substitute&lt;/code&gt;. Most mappings or macros don't need python either.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2015-11-26T09:28:06.197" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5609" PostTypeId="2" ParentId="5606" CreationDate="2015-11-26T10:20:24.777" Score="12" Body="&lt;p&gt;If you intend to write plugins you definitively should read the nice article &lt;a href=&quot;http://stevelosh.com/blog/2011/09/writing-vim-plugins/&quot;&gt;&quot;Writing Vim Plugins&quot;, by Steve Losh&lt;/a&gt;; not only for deciding if you will stick with VimL or not, but for the best practice advices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also contains a small discussion about &lt;a href=&quot;http://stevelosh.com/blog/2011/09/writing-vim-plugins/#scripting-vim-with-other-languages&quot;&gt;Scripting Vim with Other Languages&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;First, using another language will requires your plugin’s users to use&#xA;  a version of Vim compiled with support for that version. In this day&#xA;  and age it’s usually not a problem, but if you want your plugin to run&#xA;  everywhere then it’s not an option.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Using another language adds overhead. You need to not only learn&#xA;  Vimscript but also the interface between Vim and the language. For&#xA;  small plugins this can add more complexity to the project than it&#xA;  saves, but for larger plugins it can pay for itself. It’s up to you to&#xA;  decide whether it’s worth it.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Finally, using another language does not entirely insulate you from&#xA;  the eccentricities of Vimscript. You still need to learn how to do&#xA;  most things in Vimscript — using another language simply lets you wrap&#xA;  most of this up more neatly than you otherwise could.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My experience is that even when a non-VimL plugin is better, I end up switching to a pure VimL alternative later, mainly because of portability. Vim runs on virtually any system (even ugly and old legacy systems), and the overhead of setting up the dependencies or temporary disabling that plugin is not worth (especially if you keep forgetting that you disabled it and trying to use its mappings/commands). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even when it is easier to setup the dependencies you can hit some problems (e.g.: some python-based plugins doesn't works 100% when they are sourced from shared folders on Virtual Machines). That is why the few plugins I wrote use VimL only.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-11-26T10:20:24.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5610" PostTypeId="1" AcceptedAnswerId="5642" CreationDate="2015-11-26T13:19:27.333" Score="1" ViewCount="301" Body="&lt;p&gt;I am using the &lt;a href=&quot;https://github.com/the-lambda-church/merlin&quot; rel=&quot;nofollow&quot;&gt;merlin&lt;/a&gt; plugin for Ocaml and right now I set the runtimepath by hand, as per their installation instructions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugins')&#xA;  &quot;other plugins go here...&#xA;call plug#end()&#xA;&#xA;set rtp+=/home/hugo/.opam/4.02.3/share/merlin/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to change this so that merlin is managed by vim-plug for consistency and because of vim-plug's lazy-loading feature. I tried doing the following but now my ocaml keybindings are broken:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugins')&#xA;  &quot;other plugins go here...&#xA;&#xA;  Plug '/home/hugo/.opam/4.02.3/share/merlin/vim'&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Apparently, there is an &lt;code&gt;/usr/share/vim/vim74/ftplugin/ocaml.vim&lt;/code&gt; file in my system that overrides some of the keybindings that are automatically defined by merlin. When I was setting the runtimepath by hand the merlin directory appeared last in the runtimepath list (as seen via &lt;code&gt;:echo &amp;amp;rtp&lt;/code&gt;), which seemingly causes merlin to load last but when I use vim-plug the merlin dir shows up before &lt;code&gt;/usr/share/vim/vim74&lt;/code&gt; and the keybinds from the system file have priority.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to solve this conflict? Should I look for a way to disable the unwanted ftplugin file that comes installed in my system? Should I redefine all the broken keybindings by hand? Or is there something else I can do?&lt;/p&gt;&#xA;" OwnerUserId="5439" LastActivityDate="2015-11-28T15:41:09.130" Title="How can I stop a system ftplugin file from overriding the keybindings from a plugin I manage via vim-plug?" Tags="|key-bindings|plugin-vim-plug|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5611" PostTypeId="1" AcceptedAnswerId="5616" CreationDate="2015-11-26T14:03:13.133" Score="3" ViewCount="1157" Body="&lt;p&gt;I've made changes to my &lt;code&gt;_vimrc&lt;/code&gt; (windows) file since creating a session.  I'm finding it impossible (using &lt;code&gt;:source&lt;/code&gt;) to apply these changes to the session; it sticks stubbornly to the values as they were when the session was created.  If I load a new instance of vim without loading the session I can see that my new settings are fine, but it seems the values I used previously are &quot;burned in&quot; to the session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a solution, or do I have to delete this session and recreate it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the following plugins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'ctrlpvim/ctrlp.vim'&#xA;Plug 'easymotion/vim-easymotion'&#xA;Plug 'altercation/vim-colors-solarized'&#xA;Plug 'justinmk/vim-syntax-extra'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Previously I had a mapping for &lt;kbd&gt;/&lt;/kbd&gt; and &lt;kbd&gt;?&lt;/kbd&gt; to use &lt;code&gt;easymotion&lt;/code&gt; to search, but I've since changed the &lt;code&gt;vimrc&lt;/code&gt; file to leave those using the default vim search. &lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastEditorUserId="4472" LastEditDate="2015-11-30T14:31:46.630" LastActivityDate="2015-11-30T14:31:46.630" Title="Make vim sessions adopt changes to vimrc file" Tags="|vimrc|sessions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5612" PostTypeId="1" AcceptedAnswerId="5618" CreationDate="2015-11-26T14:11:07.717" Score="6" ViewCount="4987" Body="&lt;p&gt;When I click on a link in thunderbird and firefox is already running, it doesn't open a new window, just a new tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want the same thing for vim: no matter where I am and how I send a bunch of files to it, I want them opened in a single session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this, I've added the following code in my &lt;code&gt;~/.bashrc&lt;/code&gt; and &lt;code&gt;~/.zshrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function nv {&#xA;&#xA;vim --serverlist | grep -q VIM&#xA;&#xA;if [ $? -eq 0 ]; then&#xA;&#xA;    if [ $# -eq 0 ]; then&#xA;        vim&#xA;    else&#xA;        vim --remote &quot;$@&quot;&#xA;    fi&#xA;&#xA;else&#xA;    vim --servername vim &quot;$@&quot;&#xA;fi&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It defines the function &lt;code&gt;nv&lt;/code&gt; which can do 3 things :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if no VIM server is running, &lt;code&gt;nv&lt;/code&gt; launches one&lt;/li&gt;&#xA;&lt;li&gt;if a VIM server is&#xA;running and one or more arguments were passed to &lt;code&gt;nv&lt;/code&gt;, it sends them&#xA;to the server&lt;/li&gt;&#xA;&lt;li&gt;if a VIM server is running but no argument was passed&#xA;to &lt;code&gt;nv&lt;/code&gt;, it launches a simple vim session (so that I can still launch a separate vim session by using the same function / alias)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've recently &lt;a href=&quot;https://www.reddit.com/r/vim/comments/3u23ro/vim_q_ftw/&quot; rel=&quot;noreferrer&quot;&gt;read&lt;/a&gt; that you could redirect the output of a shell command as the quickfix list to vim. For example :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -q &amp;lt;(grep -Rn foo *)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works with vim but not with my function &lt;code&gt;nv&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to use the same syntax so that the output of &lt;code&gt;grep&lt;/code&gt; is not opened by a new vim session, but by the VIM server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use &lt;code&gt;nv -q &amp;lt;(grep -Rn foo *)&lt;/code&gt;, the VIM server doesn't receive the output of &lt;code&gt;grep&lt;/code&gt; but a file called &lt;code&gt;-q&lt;/code&gt; and another one : &lt;code&gt;/proc/&amp;lt;pid&amp;gt;/fd/11&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know why it doesn't work, the function was not written with that case in mind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then, I tried something simpler : &lt;code&gt;vim --remote -q &amp;lt;(grep -Rn foo *)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the result is the same, it doesn't work, the server still receives two files : &lt;code&gt;-q&lt;/code&gt; and &lt;code&gt;/proc/&amp;lt;pid&amp;gt;/fd/11&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know if it's possible to edit the code of my &lt;code&gt;nv&lt;/code&gt; function so that it works when I use it with the &lt;code&gt;-q&lt;/code&gt; switch to remotely populate the quickfix list of an already running vim server, and if so receive some advice on how to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's not, at least, I would like to know how to use the &lt;code&gt;-q&lt;/code&gt; and &lt;code&gt;--remote&lt;/code&gt; switch simultaneously.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; : I may be wrong but I don't think &lt;code&gt;-q&lt;/code&gt; and &lt;code&gt;--remote&lt;/code&gt; can be used simultaneously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the moment, I've come up with the following command :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --remote-send &quot;:grep -Rn foo *&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I need to edit the &lt;code&gt;nv&lt;/code&gt; function to integrate it, but I don't know how to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit bis: I don't think it's worth the trouble, I'll stick with &lt;code&gt;nv&lt;/code&gt; and the last command when needed.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-26T16:26:12.420" LastActivityDate="2015-11-27T07:17:14.727" Title="How to redirect the output of a command as the quickfix list to a vim server / function?" Tags="|linux|invocation|quickfix|clientserver|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5613" PostTypeId="1" AcceptedAnswerId="5614" CreationDate="2015-11-26T14:31:11.033" Score="7" ViewCount="2354" Body="&lt;p&gt;I have a situation with typesetting a book in which the quotation marks are all screwed up. The author used a variety of marks¹ and apparently didn't believe in discriminating between them. I've managed to sort out a lot of them such as fixing all the uses as apostrophe and most of the opening and closing quotes, but there are a few lingering problems. I have ten more open curly quotes (&lt;code&gt;“&lt;/code&gt;) that closing curly quotes (&lt;code&gt;”&lt;/code&gt;). This means that somewhere either quotations aren't closed at all or the wrong mark is used. Searching for one at a time (or even both at once with a regex) helps a little, but still visually scanning hundreds of pages of text for miss-matches is a lot of work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way that I can search for two expressions at once and highlight each in a different color?&lt;/strong&gt; This way I could skim for pairs without having to look closely at each one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;¹ &lt;sub&gt;I kid you not there was a random distribution of single and double straight quotes, single and double curly quotes in assorted directions, back-ticks, and various combinations including &lt;code&gt;''&lt;/code&gt;, &lt;code&gt;'‘&lt;/code&gt;, &lt;code&gt;‘'&lt;/code&gt;, &lt;code&gt;’‘&lt;/code&gt;, etc.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="267" LastActivityDate="2015-11-26T15:48:03.657" Title="Search and highlight two different strings in different colors" Tags="|search|highlight|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5614" PostTypeId="2" ParentId="5613" CreationDate="2015-11-26T14:47:29.823" Score="7" Body="&lt;p&gt;I don't know if it's what you're looking for, but let's say you've got two patterns &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;bar&lt;/code&gt;, that you want to highlight in different colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you need to define two highlight groups to set up the colors you want. Let's say, one with green background and the other one with blue background :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight MyGroup1 ctermbg=green guibg=green&#xA;:highlight MyGroup2 ctermbg=blue guibg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next you need to define your two matches with the &lt;code&gt;matchadd()&lt;/code&gt; function.&lt;br&gt;&#xA;For example, you could apply the green background defined in the highlight group &lt;code&gt;MyGroup1&lt;/code&gt; to the pattern &lt;code&gt;foo&lt;/code&gt; and the blue background defined in &lt;code&gt;MyGroup2&lt;/code&gt; to the pattern &lt;code&gt;bar&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd(&quot;MyGroup1&quot;, &quot;foo&quot;)&#xA;:call matchadd(&quot;MyGroup2&quot;, &quot;bar&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can access all the information (highlight group, pattern, priority, id) about your matches with the &lt;code&gt;getmatches()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo getmatches()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;id&lt;/code&gt; key is useful because its value allows you to delete a specific match with the &lt;code&gt;matchdelete()&lt;/code&gt; function :&#xA;&lt;code&gt;:call matchdelete({id})&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides, if you store the output of &lt;code&gt;getmatches()&lt;/code&gt; inside a variable (let's say &lt;code&gt;m&lt;/code&gt;) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let m = getmatches()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... then you can clear your matches with the &lt;code&gt;clearmatches()&lt;/code&gt; function :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call clearmatches()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and restore them with the &lt;code&gt;setmatches()&lt;/code&gt; function afterwards :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setmatches(m)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, if you have to define those matches regularly, you can gain some time by storing the commands that define them in a separate file and source it when needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you could store the following code in &lt;code&gt;mymatches.vim&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight MyGroup1 ctermbg=green guibg=green&#xA;highlight MyGroup2 ctermbg=blue guibg=blue&#xA;&#xA;call matchadd(&quot;MyGroup1&quot;, &quot;foo&quot;)&#xA;call matchadd(&quot;MyGroup2&quot;, &quot;bar&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And source it with : &lt;code&gt;:so mymatches.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if one of your pattern is a double quote &lt;code&gt;&quot;&lt;/code&gt;, you should escape it &lt;code&gt;&quot;\&quot;&quot;&lt;/code&gt; or put single quotes around &lt;code&gt;'&quot;'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-11-26T15:48:03.657" LastActivityDate="2015-11-26T15:48:03.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5615" PostTypeId="2" ParentId="5594" CreationDate="2015-11-26T18:15:31.337" Score="8" Body="&lt;p&gt;In my vimrc file I had &lt;code&gt;set paste&lt;/code&gt; turned on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I removed this configuration I was able to get comments to flow correctly.&lt;/p&gt;&#xA;" OwnerUserId="5423" LastActivityDate="2015-11-26T18:15:31.337" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5616" PostTypeId="2" ParentId="5611" CreationDate="2015-11-26T19:00:00.087" Score="5" Body="&lt;p&gt;The &lt;code&gt;:map&lt;/code&gt; command defines a new mapping, while the &lt;code&gt;:unmap&lt;/code&gt; removes them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you define a new mapping, it will remain there until you explicitly removes it. Your session file is probably saving it, so when you reload your session it is back. You can inspect the contents of your session file to confirm it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus you probably can continue using your session if you execute the &lt;code&gt;:unmap&lt;/code&gt; to remove the mappings for / and ? (on the command line, it is not necessary on the vimrc). Check &lt;code&gt;:help :unmap&lt;/code&gt; and &lt;code&gt;:help 40.1&lt;/code&gt; for details.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But it's still me manually changing one thing that my vimrc file&#xA;  contains; it can contain other things: autocommands, for example. I&#xA;  was hoping there'd be some way of saying &quot;forgot the settings as they&#xA;  were at the point the session was created and use these new settings;&#xA;  burn these into the session&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I understood you, you want to restore the settings after changing too many options/mappings/autocmds, thus it would be cumbersome to restore them manually. The &lt;code&gt;'sessionoptions'&lt;/code&gt; could be useful in this case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Changes the effect of the |:mksession| command.  It is a comma&#xA;separated list of words.  Each word enables saving and restoring&#xA;something:&#xA;   word     save and restore ~&#xA;   blank    empty windows&#xA;   buffers  hidden and unloaded buffers, not just those in windows&#xA;   curdir   the current directory&#xA;   folds    manually created folds, opened/closed folds and local&#xA;        fold options&#xA;   globals  global variables that start with an uppercase letter&#xA;        and contain at least one lowercase letter.  Only&#xA;        String and Number types are stored.&#xA;   help     the help window&#xA;   localoptions options and mappings local to a window or buffer (not&#xA;        global values for local options)&#xA;   options  all options and mappings (also global values for local&#xA;        options)&#xA;   ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try &lt;code&gt;':set sessionoptions-=options'&lt;/code&gt;, reload your session and then restore it with &lt;code&gt;':set sessionoptions+=options'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to do this often you should try some session plugin, such as &lt;a href=&quot;http://peterodding.com/code/vim/session/&quot; rel=&quot;nofollow&quot;&gt;session.vim&lt;/a&gt;, which provides the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The *:RestartVim* command&#xA;&#xA;This command saves your current editing session, restarts Vim and restores your&#xA;editing session. This can come in handy when you're debugging Vim scripts which&#xA;can't be easily/safely reloaded using a more lightweight approach [10]. It&#xA;should work fine on Windows and UNIX alike but because of technical limitations&#xA;it only works in graphical Vim.&#xA;&#xA;Any commands following the |:RestartVim| command are intercepted and executed&#xA;after Vim is restarted and your session has been restored. This makes it easy&#xA;to perform manual tests which involve restarting Vim, e.g. ':RestartVim | edit&#xA;/path/to/file | call MyTest()'.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using this plugin you could create a simple mapping that changes &lt;code&gt;'sessionoptions'&lt;/code&gt;, restarts your session, and restore that option.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2015-11-27T17:23:53.337" LastActivityDate="2015-11-27T17:23:53.337" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5617" PostTypeId="2" ParentId="5603" CreationDate="2015-11-26T19:26:39.890" Score="1" Body="&lt;p&gt;If I understand you correctly, the behavior you want is controlled by the &lt;code&gt;comments&lt;/code&gt; and &lt;code&gt;formatoptions&lt;/code&gt; options, which are set to &lt;code&gt;comments=fb:*,fb:-,fb:+,n:&amp;gt;&lt;/code&gt; and &lt;code&gt;formatoptions=tcqln&lt;/code&gt; by $VIMRUNTIME/ftplugin/markdown.vim. Those options are described here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'comments'&#xA;:help format-comments&#xA;:help 'formatoptions'&#xA;:help fo-table&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To have the next line &lt;em&gt;not&lt;/em&gt; automatically indented when you press &lt;code&gt;&amp;lt;Return&amp;gt;&lt;/code&gt; while entering a bullet, you need to remove the &lt;code&gt;f&lt;/code&gt; flag from the &lt;code&gt;*&lt;/code&gt; comment definition. The commands to do that without disturbing the other comment definitions are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set comments-=fb:*&#xA;:set comments+=b:*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To have a bullet inserted automatically when you press Return, &lt;code&gt;formatoptions&lt;/code&gt; needs to include the &lt;code&gt;r&lt;/code&gt; flag. The command to do that is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatoptions+=r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll need to do those commands &lt;em&gt;after&lt;/em&gt; those options have been set by the plugin file, so put those commands, without the leading colons, in a file named `~/.vim/after/ftplugin/markdown.vim.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-11-26T19:26:39.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5618" PostTypeId="2" ParentId="5612" CreationDate="2015-11-27T07:17:14.727" Score="2" Body="&lt;p&gt;You cannot use &lt;code&gt;--remote&lt;/code&gt; with &lt;code&gt;-q&lt;/code&gt;, any arguments after &lt;code&gt;--remote&lt;/code&gt; are treated as filenames:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--remote    Connect to a Vim server and make it edit the files given in&#xA;            the rest of the arguments.  If no server is found a warning&#xA;            is given and the files are edited in the current Vim.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That said, you cannot use the result of process substitution (&lt;code&gt;&amp;lt;(cmd)&lt;/code&gt;) with a program running elsewhere. If you notice, the file name from process substitution uses &lt;code&gt;/proc/self&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo &amp;lt;(date)&#xA;/proc/self/fd/11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The shell sets up the file descriptors of the executed command so that one of them points the substituted process. Naturally, this &lt;code&gt;fd&lt;/code&gt; cannot be easily used by a separate process - you'll at least need to translate &lt;code&gt;/proc/self&lt;/code&gt; to &lt;code&gt;/proc/&amp;lt;PID&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, it would be easier if we could run the command in Vim itself. The &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3Acexpr&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;cexpr&lt;/code&gt;&lt;/a&gt; command should help us there:&#xA;quickfix.txt  For Vim version 7.4.  Last change: 2015 Sep 08&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        :cex :cexpr E777&#xA;:cex[pr][!] {expr}      Create a quickfix list using the result of {expr} and&#xA;                        jump to the first error.&#xA;                        If {expr} is a String, then each new-line terminated&#xA;                        line in the String is processed using the global value&#xA;                        of 'errorformat' and the result is added to the&#xA;                        quickfix list.&#xA;                        If {expr} is a List, then each String item in the list&#xA;                        is processed and added to the quickfix list.  Non&#xA;                        String items in the List are ignored.&#xA;                        See :cc for [!].&#xA;                        Examples: &#xA;                                :cexpr system('grep -n xyz *')&#xA;                                :cexpr getline(1, '$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Huh, one of the examples uses &lt;code&gt;grep&lt;/code&gt; much the same way you do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;cexpr&lt;/code&gt;, the following function could work:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function nv (&#xA;    if vim --serverlist | grep -q VIM; then&#xA;        if [ $# -eq 0 ]; then&#xA;            vim&#xA;        elif [[ $1 == -q ]]; then&#xA;            shift&#xA;            IFS=' '&#xA;            vim --remote-send &quot;:cexpr system('$*')&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&quot;&#xA;        else&#xA;            vim --remote &quot;$@&quot;&#xA;        fi&#xA;    else&#xA;        vim --servername VIM &quot;$@&quot;&#xA;    fi&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use it thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nv -q grep -Rn foo *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's to say, you pass the command as you would write it to &lt;code&gt;nv -q&lt;/code&gt;. The function checks if the first argument is &lt;code&gt;-q&lt;/code&gt;, and then uses &lt;code&gt;vim --remote-send&lt;/code&gt; to call &lt;code&gt;cexpr&lt;/code&gt; and &lt;code&gt;system()&lt;/code&gt; on the rest of the arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This bit might need explaining:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;shift&#xA;IFS=' '&#xA;... system('$*') ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the first argument is &lt;code&gt;-q&lt;/code&gt; and it's no longer needed, and using &lt;code&gt;$*&lt;/code&gt; is more convenient, I simply discard &lt;code&gt;-q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, there are two quick ways of combining the arguments: &lt;code&gt;$@&lt;/code&gt; and &lt;code&gt;$*&lt;/code&gt;. A quoted &lt;code&gt;$@&lt;/code&gt; is usually preferred, if you want separate words (we don't). So, we use &lt;code&gt;$*&lt;/code&gt;, which combines the arguments using the first character of &lt;code&gt;IFS&lt;/code&gt;. What the value of IFS is depends on the shell, so I set it to a space to get the needed effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best effect is if you send a quoted command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nv -q 'grep -Rn foo *'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;*&lt;/code&gt; won't be expanded by the shell you called it from, thus preventing problems when called by &lt;code&gt;system()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Note&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;My &lt;a href=&quot;http://paste.ubuntu.com/13516374/&quot; rel=&quot;nofollow&quot;&gt;earlier version&lt;/a&gt; of the function used &lt;code&gt;{}&lt;/code&gt; to group the command. This version uses &lt;code&gt;()&lt;/code&gt;, to create a subshell. This makes it easier to set variables like &lt;code&gt;IFS&lt;/code&gt; locally without disturbing the shell.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-11-27T07:17:14.727" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5619" PostTypeId="1" AcceptedAnswerId="5817" CreationDate="2015-11-27T07:21:22.553" Score="8" ViewCount="1518" Body="&lt;p&gt;When I run ctags for a project written in bash, tags for functions are generated, but not for variables.&lt;br&gt;&#xA;e.g. if I run &lt;code&gt;ctags --list-kinds=sh&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;f  functions&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As compared to if I run the list for the &quot;c&quot; language alot more tag types get included.&lt;br&gt;&#xA;Is it possible to generate tags for bash variables? or does anyone know of a custom regex that can added to &lt;code&gt;~/.ctags&lt;/code&gt; to enable this?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2015-12-13T23:31:11.737" LastActivityDate="2021-07-21T04:57:31.273" Title="Generate ctags for bash variables?" Tags="|ctags|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5620" PostTypeId="2" ParentId="5595" CreationDate="2015-11-27T08:23:05.120" Score="2" Body="&lt;p&gt;Another option is to use &lt;code&gt;:substitute&lt;/code&gt; command together with &lt;code&gt;sub-replace-\=&lt;/code&gt;, and using the line numbers to get the increments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can start with the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://www.example.com/files/images/img01.jpg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and duplicate it enough times with the &lt;code&gt;yy48p&lt;/code&gt;. After that, the substitute command would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/01/\=printf('%02d', line('.'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A more general form to perform the same action is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/img\zs\d\{2}/\=printf('%02d', line('.'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where you use &lt;code&gt;\zs&lt;/code&gt;to anchor the number reference to certain location in the pattern (if there were multiple numbers) and don't need to necessarily have the same number on each line when you start the substitution. You can also include an offset if needed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/img\zs\d\{2}/\=printf('%02d', line('.')+4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2015-11-27T08:23:05.120" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5621" PostTypeId="1" AcceptedAnswerId="5627" CreationDate="2015-11-27T11:54:35.057" Score="4" ViewCount="3055" Body="&lt;p&gt;I wanted to take a look into neovim coming from vim and my question is about the &lt;code&gt;.vimrc&lt;/code&gt;/&lt;code&gt;.viminfo&lt;/code&gt; as well as the &lt;code&gt;.vim&lt;/code&gt; folder. Preferably I would like to use fresh instances of these. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have to create them by myself or will neovim create them? I don't want to link them together and like the idea of a &lt;strong&gt;&lt;em&gt;reset&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5454" LastActivityDate="2015-11-27T17:47:08.913" Title="neovim: use new .vimrc and .vim" Tags="|vimrc|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5622" PostTypeId="1" AcceptedAnswerId="5623" CreationDate="2015-11-27T14:40:04.490" Score="27" ViewCount="70649" Body="&lt;p&gt;I am trying to get the &lt;a href=&quot;http://vimawesome.com/plugin/vim-airline-sad-beautiful-tragic&quot; rel=&quot;noreferrer&quot;&gt;vim-airline&lt;/a&gt; up and running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have required it via vundle in my &lt;code&gt;~./vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'bling/vim-airline'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have installed it and expected my Vim to look like the screenshot on its project page:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fr5SC.png&quot; alt=&quot;Expected Vim theme&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/iZPE1.png&quot; alt=&quot;Actual look of my Vim instance&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Concerning the fonts, I tried adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_powerline_fonts = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet the icons then are just gibberish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I just found that for the colors, as described in &lt;a href=&quot;https://github.com/bling/vim-airline/wiki/FAQ&quot; rel=&quot;noreferrer&quot;&gt;the FAQ&lt;/a&gt;, I can add in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet this still leads to line looks distorted:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2mlbT.png&quot; alt=&quot;Vim with t_Co=256&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Especially the Git integration about (branch name with the icon). Or the the way the &gt;-&quot;arrow&quot; is displayed. I want that eye-candy, too. Can I even achieve that in Bash? Or would I need a different shell?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I want Vim to look like the example screenshot on the plugin page, as I expected it to be the default of the plugin. How can I achieve that?&lt;/p&gt;&#xA;" OwnerUserId="5449" LastEditorUserId="5449" LastEditDate="2019-01-22T10:33:33.670" LastActivityDate="2021-09-22T09:29:15.560" Title="How do I configure the Vim airline plugin to look like its own project screenshot?" Tags="|vimrc|plugin-vundle|plugin-airline|bash|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="5623" PostTypeId="2" ParentId="5622" CreationDate="2015-11-27T14:58:21.707" Score="30" Body="&lt;p&gt;One has to realize that the feature implemented by airline are inspired by the &lt;a href=&quot;https://powerline.readthedocs.org/en/latest/&quot;&gt;powerline&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, I was relying on the docs too much, not realizing that there is well-written airline help document shipped with itself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h airline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reading its documentation helps understanding the functionality of this plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Font&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned in the powerline docs:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Powerline uses several special glyphs to get the arrow effect and some&#xA;  custom symbols for developers. This requires having either a symbol&#xA;  font or a patched font installed in the system. Used application (e.g.&#xA;  terminal emulator) must also either be configured to use patched fonts&#xA;  (in some cases even support it because custom glyphs live in private&#xA;  use area which some applications reserve for themselves) or support&#xA;  fontconfig for powerline to work properly with powerline-specific&#xA;  glyphs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So one can patch existing fonts (&lt;a href=&quot;https://powerline.readthedocs.org/en/latest/installation.html#fonts-installation&quot;&gt;see the powerline font section&lt;/a&gt; docs or you may install a collection or already prepared fonts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can install a powerline font collection via:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone git@github.com:powerline/fonts.git&#xA;cd fontd&#xA;./install.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have chosen &lt;code&gt;Meslo LG L DZ for Powerline&lt;/code&gt; in my terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One has to add to &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_powerline_fonts = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Colors&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the colors, you have to set in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as desribed in the &lt;a href=&quot;https://github.com/bling/vim-airline/wiki/FAQ&quot;&gt;FAQ&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Theme&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to see your current theme, run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :AirlineTheme&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for me the default was &lt;code&gt;dark&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change them for the current session by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :AirlineTheme THEME_NAME&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/bling/vim-airline/wiki/Screenshots&quot;&gt;You can find a list of themes here.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;@todo&lt;/em&gt;: Find out theme used in the screenshot. I actually like &lt;code&gt;luna&lt;/code&gt; more, yet that is an entirely different matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My changes currently let vim look like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DzrlM.png&quot; alt=&quot;current state of vim look&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="5449" LastEditorUserId="5449" LastEditDate="2015-11-27T21:15:30.213" LastActivityDate="2015-11-27T21:15:30.213" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5624" PostTypeId="1" CreationDate="2015-11-27T15:49:51.160" Score="14" ViewCount="6998" Body="&lt;p&gt;I just learned about tabs, meaning I can open them via&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabe some/file&#xA;:tabe yet/another/file&#xA;:tabe foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and circle them via gt (activate right one) and gT (activate left one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet when I close my vim instance via quit-all &lt;code&gt;:qa&lt;/code&gt;, all my tabs are gone. How can I restore them all when entering vim again?&lt;/p&gt;&#xA;" OwnerUserId="5449" LastActivityDate="2015-11-27T17:26:31.973" Title="How do I restore a group of tabs?" Tags="|sessions|" AnswerCount="2" CommentCount="0" ClosedDate="2015-11-28T04:23:03.163" ContentLicense="CC BY-SA 3.0" />
  <row Id="5625" PostTypeId="2" ParentId="5624" CreationDate="2015-11-27T17:02:17.760" Score="11" Body="&lt;p&gt;You can save a session of vim with all its settings including your open tabs with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:mksession ~/session.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and load it with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:source ~/session.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you don't want to store options like your colorscheme and font size you can disable storing them with this entry in your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set sessionoptions-=options&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5331" LastActivityDate="2015-11-27T17:02:17.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5626" PostTypeId="2" ParentId="5624" CreationDate="2015-11-27T17:18:34.853" Score="16" Body="&lt;p&gt;In vim, there is a feature which allows you to save your current session to a vimscript file.  This can be done using the &lt;code&gt;:mksession&lt;/code&gt; command.  Here is a synopsis of the command given in the vim documentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:mks[ession][!] [file]&#xA;Write a Vim script that restores the current editing session.&#xA;When [!] is included an existing file is overwritten.&#xA;When [file] is omitted &quot;Session.vim&quot; is used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then load a saved session by running &lt;code&gt;vim -S Session.vim&lt;/code&gt;.  The &lt;code&gt;-S&lt;/code&gt; option will take the file given to it and source it before vim starts.  &lt;em&gt;(see &lt;code&gt;:h :source&lt;/code&gt;)&lt;/em&gt;  Also, if you omit the file name from the &lt;code&gt;-S&lt;/code&gt; option, it will try to source a file in the current directory called &lt;code&gt;Session.vim&lt;/code&gt;.  &lt;em&gt;(only if &lt;code&gt;-S&lt;/code&gt; is given as the last argument and the file exists)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an option which allows you to specify what is saved in a session file as well, called &lt;code&gt;'sessionoptions'&lt;/code&gt;.  This option is a comma separated list of words, with each word enabling the saving or restoring of something via the &lt;code&gt;:mksession&lt;/code&gt; command.  Here is a list of the possible words in this option and what is saved for each one:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;blank&lt;/code&gt; - empty windows&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;buffers&lt;/code&gt; - hidden and unloaded buffers, not just those in windows&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;curdir&lt;/code&gt; - the current directory&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;folds&lt;/code&gt; - manually created folds, opened/closed folds and local fold options&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;globals&lt;/code&gt; - global variables that start with an uppercase letter and contain at least one lowercase letter.  Only String and Number types are stored.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;help&lt;/code&gt; - the help window&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;localoptions&lt;/code&gt; - options and mappings local to a window or buffer (not global values for local options)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;options&lt;/code&gt; - all options and mappings (also global values for local options)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;resize&lt;/code&gt; - size of the Vim window: 'lines' and 'columns'&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sesdir&lt;/code&gt; - the directory in which the session file is located will become the current directory (useful with projects accessed over a network from different systems)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;slash&lt;/code&gt; - backslashes in file names replaced with forward slashes&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;tabpages&lt;/code&gt; - all tab pages; without this only the current tab page is restored, so that you can make a session for each tab page separately&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;unix&lt;/code&gt; - with Unix end-of-line format (single ), even when on Windows or DOS&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;winpos&lt;/code&gt; - position of the whole Vim window&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;winsize&lt;/code&gt; - window sizes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As an example, the default value for this option would be the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sessionoptions=blank,buffers,curdir,folds,help,options,tabpages,winsize&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more on these topics, see &lt;code&gt;:help :mksession&lt;/code&gt; and &lt;code&gt;:help 'sessionoptions'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-11-27T17:26:31.973" LastActivityDate="2015-11-27T17:26:31.973" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5627" PostTypeId="2" ParentId="5621" CreationDate="2015-11-27T17:47:08.913" Score="6" Body="&lt;p&gt;Neovim dosn't use .vimrc/.viminfo as well as the .vim folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Neovim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use &lt;code&gt;$XDG_CONFIG_HOME/nvim/init.vim&lt;/code&gt; instead of &lt;code&gt;.vimrc&lt;/code&gt; for storing&#xA;configuration.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;$XDG_CONFIG_HOME/nvim&lt;/code&gt; instead of &lt;code&gt;.vim&lt;/code&gt; to store configuration&#xA;files.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;$XDG_DATA_HOME/shada/main.shada&lt;/code&gt; instead of &lt;code&gt;.viminfo&lt;/code&gt; for&lt;br&gt;&#xA;persistent session information.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1691" LastActivityDate="2015-11-27T17:47:08.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5629" PostTypeId="2" ParentId="5595" CreationDate="2015-11-27T22:06:11.737" Score="2" Body="&lt;p&gt;Like Cajanus, start with one line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://www.example.com/files/images/img01.jpg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and duplicate it 48 times:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yy48p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using visincr.vim, use ctrl-v to visual-block select the 01s.  Then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:II 1 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can get visincr.vim from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://www.drchip.org/astronaut/vim/index.html#VISINCR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-11-27T22:06:11.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5630" PostTypeId="1" AcceptedAnswerId="5633" CreationDate="2015-11-27T22:35:55.770" Score="13" ViewCount="19806" Body="&lt;p&gt;I often have to add stuff at the end of a file, hence I go to the last line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;yet this is at the beginning of the line. Often I discover myself doing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;Arrow Right&lt;/kbd&gt; to jump by word until I am at the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I enter insert mode us via &lt;code&gt;a&lt;/code&gt;, and hit Enter and do whatever I need there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This feels overcomplicated. How to add content at the end of the file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus point if I can do it by just one command.&lt;/p&gt;&#xA;" OwnerUserId="5449" LastActivityDate="2017-01-13T16:58:09.647" Title="How to quickly add content in a new line at end of file?" Tags="|cursor-movement|cursor-motions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5631" PostTypeId="2" ParentId="5630" CreationDate="2015-11-27T22:35:55.770" Score="4" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:$&lt;/code&gt; jumps to the end of the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Shift&lt;/kbd&gt; + &lt;kbd&gt;A&lt;/kbd&gt; # enters insert mode at end of&#xA;current line&lt;/li&gt;&#xA;&lt;li&gt;Enter # inserts new line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This gets rids of the word by word navigation.&lt;/p&gt;&#xA;" OwnerUserId="5449" LastActivityDate="2015-11-27T22:35:55.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5632" PostTypeId="1" CreationDate="2015-11-27T22:59:35.787" Score="4" ViewCount="768" Body="&lt;p&gt;I recently saw &lt;a href=&quot;https://www.youtube.com/watch?v=5r6yzFEXajQ&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;this&lt;/strong&gt;&lt;/a&gt; video about &lt;code&gt;tmux and vim&lt;/code&gt; and instantly fell in love with the color theme used in the video. Luckily the presenter (&lt;em&gt;Nick Nisi&lt;/em&gt;) provides a link in the video-description to his &lt;code&gt;.vimrc&lt;/code&gt; an more resources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked through his GitHub repository and saw that he used a theme called &lt;em&gt;delek&lt;/em&gt;. It seems like delek is preinstalled with vim, but I also found another download for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, my &lt;code&gt;vim&lt;/code&gt;doesn't even look close to the &lt;code&gt;vim&lt;/code&gt; as shown in the video. I't not sure whether I used a wrong theme or if I somehow screw up my colors. I'm using the Terminal-App under Mac, which supports 256 colors and I'm pretty sure that iTerm (that's what Nick uses in the video) &lt;em&gt;only&lt;/em&gt; supports 256 colors as well. So this shouldn't be the problem...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm actually using &lt;code&gt;neoVim&lt;/code&gt;, but this should't play a role neither. &#xA;Here is my &lt;code&gt;.config/init.vim&lt;/code&gt; (&lt;code&gt;neoVim&lt;/code&gt;'s equivalent to &lt;code&gt;.vimrc&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Setup NeoBundle {{{&#xA;&quot; If vundle is not installed, do it first&#xA;&#xA;  &quot; Install NeoBundle if not already installed&#xA;  let bundleExists = 1&#xA;  if (!isdirectory(expand(&quot;$HOME/.config/nvim/bundle/neobundle.vim&quot;)))&#xA;    call system(expand(&quot;mkdir -p $HOME/.nvim/bundle&quot;))&#xA;    call system(expand(&quot;git clone https://github.com/Shougo/neobundle.vim ~/.config/nvim/bundle/neobundle.vim&quot;))&#xA;    let bundleExists = 0&#xA;  endif&#xA;&#xA;&#xA;  if 0 | endif&#xA;&#xA;  if has('vim_starting')&#xA;    if &amp;amp;compatible&#xA;      &quot; Be iMproved&#xA;      set nocompatible&#xA;  endif&#xA;&#xA;&quot; Required:&#xA;    set runtimepath+=~/.config/nvim//bundle/neobundle.vim/ &#xA;  endif&#xA;&#xA;&quot; Required:&#xA;  call neobundle#begin(expand('~/.config/nvim/bundle/'))&#xA;&#xA;&quot; Let NeoBundle manage NeoBundle&#xA;&quot; Required:&#xA;  NeoBundleFetch 'Shougo/neobundle.vim'&#xA;&#xA;&quot; colorscheme &amp;amp; syntax highlighting&#xA;  NeoBundle 'https://github.com/vim-scripts/delek.vim'&#xA;&#xA;  call neobundle#end()&#xA;&#xA;&quot; Required:&#xA;  filetype plugin indent on&#xA;  NeoBundleCheck&#xA;  if bundleExists == 0&#xA;    echo &quot;Installing Bundles, ignore errors&quot;&#xA;  endif&#xA;&#xA;&quot;}}}&#xA;&#xA;&quot; Themes {{{&#xA;  syntax on&#xA;&#xA;  set encoding=utf8&#xA;  let base16colorspace=256&#xA;  set t_Co=256&#xA;  set background=dark&#xA;  colorscheme delek&#xA;&quot;}}}&#xA;&#xA;&quot; Miscellaneous {{{&#xA;  set clipboard=unnamed&#xA;  set foldmethod=marker&#xA;&quot;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would be awesome if anyone of you guys would know whether it's a problem with the terminal, the (probably) wrong theme or my config?&lt;/p&gt;&#xA;" OwnerUserId="5454" LastEditorUserId="51" LastEditDate="2015-11-28T04:24:19.137" LastActivityDate="2015-11-28T04:24:19.137" Title="Wrong color-theme displayed" Tags="|terminal|colorscheme|neovim|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5633" PostTypeId="2" ParentId="5630" CreationDate="2015-11-27T23:03:53.250" Score="24" Body="&lt;h2&gt;If file is already opened in normal mode&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Go&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;G&lt;/code&gt; goes to the end of the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&lt;/code&gt; enters insert mode on a line below the current one&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;If you are opening the file from the command line&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can open vim on the last line of a file from the command line using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim + filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;+&lt;/code&gt; lets to specify the line number. Leaving it blank defaults to the last line of the file as explained in the man page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;       +[num]      For the first file the cursor will be  positioned  on  line&#xA;                   &quot;num&quot;.   If &quot;num&quot; is missing, the cursor will be positioned&#xA;                   on the last line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can use &lt;code&gt;o&lt;/code&gt; as above to enter insert mode on the line below.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What about inserting at the top of the file (or an arbitrary line number)?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In normal mode &lt;code&gt;gg&lt;/code&gt; can be used to jump to any line in the file by number. So &lt;code&gt;5gg&lt;/code&gt; jumps to line 5. gg without a number is a shortcut for the first line of the file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to insert a line above the first line, you could do that with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ggO&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1402" LastEditorUserId="5449" LastEditDate="2017-01-13T16:58:09.647" LastActivityDate="2017-01-13T16:58:09.647" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5634" PostTypeId="1" AcceptedAnswerId="5635" CreationDate="2015-11-27T23:16:05.250" Score="20" ViewCount="21292" Body="&lt;p&gt;I used to enter insert mode by &lt;code&gt;a&lt;/code&gt; never realizing that there is a system as to &lt;em&gt;where&lt;/em&gt; the insert mode starts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was sometimes annoyed that &lt;code&gt;a&lt;/code&gt; would put the cursor after the first character of a line, yet the thing is: It enters the insert mode &lt;em&gt;after&lt;/em&gt; the current cursor position. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I realized I could enter insert mode at the end of the line using &lt;code&gt;A&lt;/code&gt;, or below the current line using &lt;code&gt;o&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the ways in normal mode to enter insert mode and what is their difference?&lt;/p&gt;&#xA;" OwnerUserId="5449" LastEditorUserId="5449" LastEditDate="2019-05-27T14:53:00.400" LastActivityDate="2019-05-27T14:53:00.400" Title="What options are there to enter insert mode?" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5635" PostTypeId="2" ParentId="5634" CreationDate="2015-11-27T23:26:38.300" Score="37" Body="&lt;h2&gt;Entering insert mode at different locations&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The vim help documents have a great section on this: &lt;code&gt;:help inserting&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick summary is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;i&lt;/code&gt;: Insert before the cursor.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;I&lt;/code&gt;: Insert before the first non-blank character of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&lt;/code&gt;: Insert after the cursor. &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A&lt;/code&gt;: Insert at the end of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&lt;/code&gt;: Begin a new line below the current line and insert.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;O&lt;/code&gt;: Begin a new line above the current and insert.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gI&lt;/code&gt;: Insert at column 1 of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gi&lt;/code&gt;: Insert where insert mode was last stopped.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Insert commands take a count as well, so you can type &lt;code&gt;3itest&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;&lt;/code&gt; to get: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;test test test &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Insert commands can be repeated with &lt;code&gt;.&lt;/code&gt; as well, so &lt;code&gt;itest&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;..&lt;/code&gt; will yield (because the &lt;code&gt;i&lt;/code&gt; inserts before the cursor, which is on the space):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;testtesttest &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, I'll add&#xA;&lt;a href=&quot;https://vi.stackexchange.com/users/865/evergreentree&quot;&gt;EvergreenTree's&lt;/a&gt; answer&#xA;from the comments: You can enter insert mode with &lt;code&gt;:star[tinsert][!]&lt;/code&gt; which&#xA;works like &lt;code&gt;i&lt;/code&gt; unless you give it the option &lt;code&gt;!&lt;/code&gt;, in which case it works like&#xA;&lt;code&gt;A&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Modifying text and then entering insert mode&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It is also possible to modify the text in normal mode and enter insert mode at&#xA;the end. See &lt;code&gt;:help replacing&lt;/code&gt;. A summary of the commands are as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;c&lt;/code&gt;: Delete text (and yank to the buffer) and enter insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cc&lt;/code&gt;: Delete the line and enter insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C&lt;/code&gt;: Delete until the end of the line and enter insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s&lt;/code&gt;: Delete a number of characters and enter insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;S&lt;/code&gt;: Delete a number of line and enter insert mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Many of these also work on visually selected text.&lt;/p&gt;&#xA;" OwnerUserId="1402" LastEditorUserId="1402" LastEditDate="2015-12-26T17:08:07.397" LastActivityDate="2015-12-26T17:08:07.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5636" PostTypeId="1" AcceptedAnswerId="5637" CreationDate="2015-11-28T01:10:50.317" Score="2" ViewCount="338" Body="&lt;p&gt;I have a line of vimscript in my buffer like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call MyFooFunction(1,2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'm trying to execute it quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I yank it (&lt;code&gt;yy&lt;/code&gt;), invoke the command line (&lt;code&gt;:&lt;/code&gt;), and paste it in with &lt;code&gt;&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, after I paste, I see an extra &lt;em&gt;^M&lt;/em&gt; at the end:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call MyFooFunction(1,2)^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is this extra &lt;em&gt;^M&lt;/em&gt; character and how do I not have it included when I paste?&lt;/p&gt;&#xA;" OwnerUserId="2312" LastActivityDate="2015-11-28T01:43:18.533" Title="Extra character after pasting yank text into command line" Tags="|vimscript|cut-copy-paste|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5637" PostTypeId="2" ParentId="5636" CreationDate="2015-11-28T01:43:18.533" Score="5" Body="&lt;p&gt;That extra character is a newline.  &lt;code&gt;yy&lt;/code&gt; copies both the contents of the line and the line break.  To copy a line without the line break, you can do &lt;code&gt;0y$&lt;/code&gt;.  &lt;code&gt;0&lt;/code&gt; moves to the beginning of the line, and &lt;code&gt;y$&lt;/code&gt; yanks until the last character of the line.  If you want to, you could map it to make it faster:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap Y 0y$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Y&lt;/code&gt; is a synonym for &lt;code&gt;yy&lt;/code&gt; by default, so it is okay to map over it.  You can map it to whatever key you prefer though.&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-11-28T01:43:18.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5638" PostTypeId="1" AcceptedAnswerId="5646" CreationDate="2015-11-28T08:40:48.943" Score="6" ViewCount="716" Body="&lt;p&gt;I have a parenthesis in my LaTeX document that is intentionally unmatched. This breaks syntax highlighting for all of the following text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to reset syntax highlighting after this point?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;%stopzone&lt;/code&gt; trick that works for other LaTeX syntax breakages doesn't work here. Neither does inserting a matching paren in a comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a small example that exhibits the problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;\documentclass{article}&#xA;&#xA;\begin{document}&#xA;&#xA;\begin{itemize}&#xA;\item \textit{properly} highlighted&#xA;\end{itemize}&#xA;&#xA;(&#xA;&#xA;\begin{itemize}&#xA;\item \textit{improperly} highlighted&#xA;\end{itemize}&#xA;&#xA;\end{document}&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="5459" LastActivityDate="2015-12-07T22:13:20.247" Title="Fix syntax highlighting after unmatched parentheses" Tags="|filetype-tex|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5639" PostTypeId="1" AcceptedAnswerId="5640" CreationDate="2015-11-28T11:22:59.137" Score="1" ViewCount="1633" Body="&lt;p&gt;I run into a problem while practicing the Ex mode by running &lt;code&gt;sh&lt;/code&gt; command, following this &lt;a href=&quot;https://kb.iu.edu/d/afdc&quot; rel=&quot;nofollow noreferrer&quot;&gt;tutorial&lt;/a&gt;. I cannot go back to the editing file[s]. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I can see the .swp dot file by running &lt;code&gt;ls -a&lt;/code&gt;.   &lt;/li&gt;&#xA;&lt;li&gt;None listed by running &lt;code&gt;jobs&lt;/code&gt;   &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;fg&lt;/code&gt; can neither call it back.   &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I cannot find a relavant question here, except this &lt;a href=&quot;https://vi.stackexchange.com/questions/4817/is-there-a-vim-command-line-option-to-edit-last-edited-file&quot;&gt;one&lt;/a&gt;, but absolutely it cannot tackle this problem. Please point me in the right direction. &lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-07-12T17:17:05.943" Title="How can I go back to the editing file after invoking shell in Ex mode?" Tags="|ex-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5640" PostTypeId="2" ParentId="5639" CreationDate="2015-11-28T12:25:36.603" Score="6" Body="&lt;p&gt;Type &lt;code&gt;exit&lt;/code&gt; at the prompt and press &lt;kbd&gt;Enter&lt;/kbd&gt; to terminate the current shell session and come back to Vim and your previous session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$ jobs&lt;/code&gt; and &lt;code&gt;$ fg&lt;/code&gt; don't work because you don't have background jobs &lt;em&gt;in the current shell session&lt;/em&gt;. Those commands would work if you used &lt;code&gt;&amp;lt;C-z&amp;gt;&lt;/code&gt; instead of &lt;code&gt;:sh&lt;/code&gt;, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:sh&lt;/code&gt; suspends the current shell session and starts a new one in which you can't access processes running or suspended in the previous one. The only way to get back the previous session is to terminate the current one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-z&amp;gt;&lt;/code&gt; only suspends Vim. This puts you back in the shell where you started Vim and where you can see Vim with &lt;code&gt;$ jobs&lt;/code&gt; and switch back to it with &lt;code&gt;$ fg&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-11-28T12:25:36.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5642" PostTypeId="2" ParentId="5610" CreationDate="2015-11-28T15:41:09.130" Score="2" Body="&lt;p&gt;Look at the top of $VIMRUNTIME/ftplugin/ocaml.vim -- you'll see some lines that say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;b:did_ftplugin&quot;)&#xA;  finish&#xA;endif    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, put in your personal&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$HOME/.vim/ftplugin/ocaml.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:did_ftplugin= 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will effectively prevent the system ocaml plugin from loading.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-11-28T15:41:09.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5643" PostTypeId="1" AcceptedAnswerId="5648" CreationDate="2015-11-28T18:30:17.207" Score="8" ViewCount="160" Body="&lt;p&gt;Let's say I have a vertical split, and four buffers open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to have one buffer open on the left, and cycle through just the other three on the right. Something like &lt;code&gt;:bnext&lt;/code&gt; but skipping open/visible buffers.&lt;/p&gt;&#xA;" OwnerUserId="5462" LastActivityDate="2020-10-23T08:03:09.023" Title="Can I cycle through buffers while skipping ones I've opened?" Tags="|buffers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5645" PostTypeId="2" ParentId="5643" CreationDate="2015-11-28T19:24:15.367" Score="5" Body="&lt;p&gt;This is barely tested, but should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    fu! CycleBuffer()&#xA;        let i=get(s:, 'cycle_bufnr', 0)%bufnr('$')+1&#xA;        while bufwinnr(i) &amp;gt; 0&#xA;            let i+=1&#xA;        endw&#xA;        if i &amp;gt; bufnr('$')&#xA;            echomsg 'There is no buffer to cycle to!'&#xA;        else&#xA;            exe i.'b'&#xA;            let s:cycle_bufnr=i&#xA;        endif&#xA;    endfu&#xA;    com! CycleBuffer :call CycleBuffer()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Call &lt;code&gt;:CycleBuffer&lt;/code&gt; to advance to the next buffer, that is not visible.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-11-28T19:24:15.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5646" PostTypeId="2" ParentId="5638" CreationDate="2015-11-28T19:38:34.547" Score="4" Body="&lt;p&gt;This is a very difficult problem. It is such a corner case of what people need, that I would not personally want to support it directly. Thus I also won't try to come with a direct answer to your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, I want to propose two indirect solutions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Put the unmatched paranthesis inside a verbatim command, e.g. &lt;code&gt;\verb+(+&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Create a new command for the unmatched paranthesis, e.g. &lt;code&gt;\newcommand{\unMatchedParen}{(}&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Which of these to choose depends on the reason you need the unmatched paranthesis, but both of them will work in that they will not break syntax highlighting.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-11-28T19:38:34.547" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5647" PostTypeId="1" AcceptedAnswerId="7797" CreationDate="2015-11-29T04:25:31.400" Score="4" ViewCount="918" Body="&lt;p&gt;As far as I know, all &quot;good&quot; scripts/programs start off with a shebang line as the first line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;#!/usr/bin/env python&#xA;#!/usr/bin/perl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc.  Is it possible to pass that line to Vim in &lt;code&gt;command&lt;/code&gt;-mode to generically determine the program to use when executing the current file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, perl file needs&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! perl%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Python, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! python%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the shebang is already there in the file, is it possible to replace the specific program &lt;strong&gt;before&lt;/strong&gt; the &lt;strong&gt;%&lt;/strong&gt; character (current file) with the shebang line/argument?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if the file is executable already &lt;code&gt;:! ./%&lt;/code&gt; works&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The idea is to map a key so that, as you write code, simply hitting a shortcut key the file is executed; mimicking an IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Once again, assuming the file is not (yet) executable, since you just started writing it in Vim.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5465" LastEditorUserId="5465" LastEditDate="2016-05-14T03:30:38.113" LastActivityDate="2016-05-14T08:10:24.853" Title="How to pass generic shebang line to shell" Tags="|command-line|external-command|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5648" PostTypeId="2" ParentId="5643" CreationDate="2015-11-29T08:33:53.327" Score="6" Body="&lt;p&gt;This is a good new feature idea&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is another implementation. This one will ignore unlisted buffers, and also it won't rely on a global to decide which is next. Instead the &lt;em&gt;next&lt;/em&gt; definition is relative to the current buffer number.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;CycleToNextBuffer :call &amp;lt;sid&amp;gt;CycleToNext('after')&amp;lt;cr&amp;gt;&#xA;if !hasmapto('&amp;lt;Plug&amp;gt;CycleToNextBuffer', 'n')&#xA;  nmap &amp;lt;silent&amp;gt; &amp;lt;unique&amp;gt; &amp;lt;F12&amp;gt; &amp;lt;Plug&amp;gt;CycleToNextBuffer&#xA;endif&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;CycleToPreviousBuffer :call &amp;lt;sid&amp;gt;CycleToNext('before')&amp;lt;cr&amp;gt;&#xA;if !hasmapto('&amp;lt;Plug&amp;gt;CycleToPreviousBuffer', 'n')&#xA;  nmap &amp;lt;silent&amp;gt; &amp;lt;unique&amp;gt; &amp;lt;F11&amp;gt; &amp;lt;Plug&amp;gt;CycleToPreviousBuffer&#xA;endif&#xA;&#xA;function! s:CycleToNext(direction) abort&#xA;  let undisplayed_buffers = filter(range(1, bufnr('$')), 'buflisted(v:val) &amp;amp;&amp;amp; bufwinnr(v:val) == -1')&#xA;  if empty(undisplayed_buffers)&#xA;    echomsg &quot;No hidden (listed) buffer to jump to&quot;&#xA;    return&#xA;  endif&#xA;  if a:direction == 'next'&#xA;    let after = filter(copy(undisplayed_buffers), 'v:val &amp;gt; bufnr(&quot;%&quot;)')&#xA;    let buf = empty(after) ? undisplayed_buffers[0] : after[0]&#xA;  else&#xA;    let before = filter(copy(undisplayed_buffers), 'v:val &amp;lt; bufnr(&quot;%&quot;)')&#xA;    let buf = empty(before) ? undisplayed_buffers[-1] : before[-1]&#xA;  endif&#xA;  silent exe 'b '.buf&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="4939" LastEditDate="2016-01-02T12:25:16.873" LastActivityDate="2016-01-02T12:25:16.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5649" PostTypeId="1" AcceptedAnswerId="5650" CreationDate="2015-11-29T10:00:45.343" Score="3" ViewCount="2920" Body="&lt;p&gt;I'm using MacVim on OSX 10.11 El Capitan, which still has some issues with El Captain's new Split Screen feature – namely, MacVim automatically resizes to 191 columns, taking up most of the screen real estate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this, I have to manually &lt;code&gt;set columns=95&lt;/code&gt;, which works perfectly except that then, the entire vim window goes black. The easiest way to fix that is &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; to redraw the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I have the following mapping set up in my &lt;code&gt;.vimrc&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;ss :set columns=95&amp;lt;CR&amp;gt;&amp;lt;C-l&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem is, the &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; command seems to come too soon after the screen is resized, so it remains black and I still have to manually redraw the screen myself. Is there any way to delay the execution of the final &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; command by a few ms or so (or, even fancier, to wait until the screen has been fully resized) so that I can do this all in one fell swoop?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="2593" LastActivityDate="2015-11-29T10:46:00.837" Title="Can I add a delay/wait to a key mapping?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5650" PostTypeId="2" ParentId="5649" CreationDate="2015-11-29T10:46:00.837" Score="10" Body="&lt;p&gt;You could use the the builtin sleep function (see &lt;code&gt;:h sleep&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:sleep 2&amp;lt;CR&amp;gt;&lt;/code&gt; lets Vim sleep for 2 seconds, &lt;code&gt;:sleep 200m&amp;lt;CR&amp;gt;&lt;/code&gt; for 200 milliseconds. There is also the &quot;gosleep&quot; command in normal mode, e.g. &lt;code&gt;2gs&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2015-11-29T10:46:00.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5651" PostTypeId="1" AcceptedAnswerId="5654" CreationDate="2015-11-29T12:30:54.490" Score="20" ViewCount="13375" Body="&lt;p&gt;When setting &lt;code&gt;spelllang&lt;/code&gt; for the first time, I was prompted to auto-download the appropriate spell file. Somehow I aborted the process due to unclear instructions, when it asked me, into which directory it should go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when I &lt;code&gt;:set spelllang&lt;/code&gt; it just says &lt;code&gt;Warning: Cannot find word list&lt;/code&gt;… but does not offer to download it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I restart the process?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastEditorUserId="1111" LastEditDate="2018-11-19T04:24:43.730" LastActivityDate="2020-02-08T19:47:20.050" Title="How can I make vim download spell files?" Tags="|spell-checking|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5652" PostTypeId="2" ParentId="5647" CreationDate="2015-11-29T12:40:24.157" Score="5" Body="&lt;p&gt;You could use the fact that your shell understands the Shebang:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!./%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please be sure to make your file executable (&lt;code&gt;chmod +x filename&lt;/code&gt;). You can easily create a mapping for this, so that you can execute your current file with one keypress.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2015-11-29T12:40:24.157" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5653" PostTypeId="2" ParentId="5647" CreationDate="2015-11-29T13:05:12.603" Score="2" Body="&lt;p&gt;If for some reason @cbaumhardt's answer doesn't work for you, you can actually just use &lt;code&gt;perl&lt;/code&gt;.  As a handy helper for systems that don't handle shebang lines correctly, perl will actually honor the shebang line itself.  See &lt;a href=&quot;https://stackoverflow.com/questions/29563832/why-dont-i-get-any-syntax-errors-when-i-execute-my-python-script-with-perl&quot;&gt;this question on SO&lt;/a&gt; for more info about that.&lt;/p&gt;&#xA;" OwnerUserId="1828" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-11-29T13:05:12.603" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5654" PostTypeId="2" ParentId="5651" CreationDate="2015-11-29T13:42:24.213" Score="16" Body="&lt;p&gt;The &lt;a href=&quot;https://vimhelp.appspot.com/spell.txt.html#spellfile.vim&quot; rel=&quot;noreferrer&quot;&gt;help&lt;/a&gt; states this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The plugin has a default place where to look for spell files, on the Vim ftp&#xA;server.  If you want to use another location or another protocol, set the&#xA;g:spellfile_URL variable to the directory that holds the spell files.  The&#xA;netrw plugin is used for getting the file, look there for the specific&#xA;syntax of the URL.  Example: &#xA;    let g:spellfile_URL = 'http://ftp.vim.org/vim/runtime/spell'&#xA;You may need to escape special characters.&#xA;&#xA;The plugin will only ask about downloading a language once.  If you want to&#xA;try again anyway restart Vim, or set g:spellfile_URL to another value (e.g.,&#xA;prepend a space).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please, note that the default choice at each interaction is negative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, the following happens if you enter &lt;code&gt;:set spelllang=fr&lt;/code&gt; and the French language is not yet installed).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Cannot find spell file for &quot;fr&quot; in utf-8&#xA;Do you want me to try downloading it?&#xA;(Y)es, [N]o:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hit &lt;kbd&gt;Y&lt;/kbd&gt; to download the spell language&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Downloading fr.utf-8.spl...&#xA;:!curl 'http://ftp.vim.org/pub/vim/runtime/spell/fr.utf-8.spl' -o '/tmp/vu98ZTF/2.spl'&#xA;  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current&#xA;                                 Dload  Upload   Total   Spent    Left  Speed&#xA;&quot;/tmp/vu98ZTF/2.spl&quot; [noeol] 1122L, 571626C&#xA;In which directory do you want to write the file:&#xA;1. /home/youruser/.vim/spell&#xA;[C]ancel, (1):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hit &lt;kbd&gt;1&lt;/kbd&gt; (hitting &lt;kbd&gt;Enter&lt;/kbd&gt; choses the default &lt;code&gt;Cancel&lt;/code&gt; action)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This will improve making suggestions for spelling mistakes,&#xA;but it uses quite a bit of memory.&#xA;[N]o, (Y)es:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hit &lt;kbd&gt;Y&lt;/kbd&gt; (or &lt;kbd&gt;N&lt;/kbd&gt;/&lt;kbd&gt;Enter&lt;/kbd&gt;, it's your choice) &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Downloading fr.utf-8.sug...&#xA;:!curl 'http://ftp.vim.org/pub/vim/runtime/spell/fr.utf-8.sug' -o '/tmp/vu9&#xA;8ZTF/2.sug'&#xA;  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current&#xA;                                 Dload  Upload   Total   Spent    Left  Speed&#xA;  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--    26 2269k   26  596k    0     0   651k      0  0:00:03 --:--:--  0:00:03  6 64 2269k   64 1469k    0     0   767k      0  0:00:02  0:00:01  0:00:01  7&quot;~/.vim/spell/fr.utf-8.sug&quot; [New] 15706L, 2324315C written&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="6498" LastEditDate="2019-05-18T11:43:33.913" LastActivityDate="2019-05-18T11:43:33.913" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="5655" PostTypeId="2" ParentId="5588" CreationDate="2015-11-29T16:58:59.573" Score="0" Body="&lt;p&gt;I have asked this question in a wrong way. The problem was not related to the &lt;code&gt;echomsg&lt;/code&gt; command alone but more about writing the messages to a file. I will be posting a more specific question regarding this issue of: &lt;em&gt;How to append a string to a file in vim script?&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="5328" LastActivityDate="2015-11-29T16:58:59.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5656" PostTypeId="1" CreationDate="2015-11-29T17:19:03.083" Score="3" ViewCount="985" Body="&lt;p&gt;In a file containing tags like these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;myclass&quot;&amp;gt;&#xA;Something irrelevant.&#xA;&amp;lt;/div&amp;gt;&#xA;&amp;lt;div class=&quot;myclass&quot;&amp;gt;&#xA;MATCH ME&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to delete all tags &lt;em&gt;not&lt;/em&gt; containing a specific pattern, here &quot;MATCH ME&quot; as an example. I can search for the opening of the tag, then do &lt;code&gt;vat&lt;/code&gt;, inspect the selection, if it doesn't contain my pattern I hit &lt;code&gt;d&lt;/code&gt; to delete it and move on to the next candidate with &lt;code&gt;n&lt;/code&gt;, else I will hit &lt;code&gt;n&lt;/code&gt; straight, continuing to the end of the file. Now I'd like to automate that, as I have a few files like that. How?&lt;/p&gt;&#xA;" OwnerUserId="2774" LastActivityDate="2015-12-17T12:55:56.403" Title="Conditionally delete xml tags" Tags="|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5657" PostTypeId="1" AcceptedAnswerId="5664" CreationDate="2015-11-29T17:26:28.340" Score="4" ViewCount="2326" Body="&lt;p&gt;I would like to create two functions, one for sending a message string to Vim's own messaging system and one to dump the message string to a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I have already progressed in figuring this out with different approaches however, my solution is not elegant enough and sometimes the messages sent to &lt;code&gt;:messages&lt;/code&gt; are getting lost on the status line at the moment of printing them out. However once I run &lt;code&gt;:messages&lt;/code&gt; I can see those &lt;em&gt;skipped&lt;/em&gt; messages in there. So this must be related to the way I deal with new lines etc. Here are bits of my script that should illustrate what approaches I have tried so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Lets assume this is a part of the SendToStatus() function&#xA;&quot; and it is a bit like a pseudo-code.&#xA;execute 'echohl' error&#xA;for l:line in split('My message.', '\\n')&#xA;  echomsg l:line&#xA;endfor&#xA;echohl NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The traditional way of sending the messages to &lt;code&gt;:messages&lt;/code&gt; works fine on it's own. The problems start when I use the following to write the same message to a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Lets assume this is a part of the SendToFile() function&#xA;&quot; and this is also a bit like a pseudo-code.&#xA;try&#xA;    echon &quot;\r&quot;&#xA;    execute 'redir &amp;gt;&amp;gt; ' . l:file&#xA;    silent echomsg l:msgString&#xA;    silent echo &quot;\n&quot;&#xA;    silent! redir END&#xA;catch /E190:/&#xA;    throw s:myException('Cannot write to file: %s', l:file)&#xA;end-try&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when I execute these commands one after another like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SomeMoreComplexWrapper() abort&#xA;    ...&#xA;    SendToStatus('some message')&#xA;    SendToFile('some message')&#xA;    ....&#xA;    SendToStatus('some more messages')&#xA;    ....&#xA;    SendToStatus('some more messages')&#xA;    SendToFile('even more messages')&#xA;    ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The strings are written to the file with no issues what so ever, however, the status messages are getting lost on some occasions. It must be the way the echoing order is managed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried the &lt;code&gt;readfile()&lt;/code&gt; and &lt;code&gt;writefile()&lt;/code&gt; approaches, which worked just fine. This helped me to take the process of echoing to a file out of the equation, thus removed the need of dealing with &lt;code&gt;echo&lt;/code&gt; and &lt;code&gt;echomsg&lt;/code&gt; on both sides and only keep &lt;code&gt;echomsg&lt;/code&gt; to send the strings to the &lt;code&gt;:message&lt;/code&gt; facility. However I need to store the contents of my log file into a list and append the new string to that every time I need to send something to the file, which I find a bit scary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you please help me with this issue?&lt;/p&gt;&#xA;" OwnerUserId="5328" LastActivityDate="2015-11-30T16:00:29.567" Title="How to write message strings to a file using vim script?" Tags="|vimscript|macvim|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5658" PostTypeId="1" CreationDate="2015-11-29T18:20:02.493" Score="6" ViewCount="785" Body="&lt;p&gt;Currently my &lt;code&gt;init.vim&lt;/code&gt; (&lt;code&gt;neovim&lt;/code&gt;'s equivalent to the &lt;code&gt;.vimrc&lt;/code&gt;) sets the &lt;code&gt;foldmethod&lt;/code&gt; to &lt;code&gt;marker&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=marker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open a file all sections are folded and if the curser is placed in the according line and moved to the left it will open automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be awesome if there was a way to have a similar experience when moving to the left (ergo: When I move to the left up against the start of the line. I want the section to be folded).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How is this possible?&lt;/p&gt;&#xA;" OwnerUserId="5454" LastActivityDate="2018-04-23T21:40:42.893" Title="Fold/Unfold on moving vertically" Tags="|cursor-movement|cursor-motions|folding|neovim|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5660" PostTypeId="1" AcceptedAnswerId="5662" CreationDate="2015-11-29T20:29:52.227" Score="3" ViewCount="154" Body="&lt;p&gt;I have text in my buffer like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar&#xA;baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and my cursor is on the &quot;f&quot; of foo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say I want to delete up-to-and-including the &quot;a&quot; in bar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in normal mode I try: &lt;code&gt;d/ba&amp;lt;enter&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this is invoking the delete command, then doing a forward search for &quot;ba&quot; and pressing enter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would expect this to delete &lt;em&gt;up to&lt;/em&gt; the &quot;r&quot; in bar, basically including the search match in the deletion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, it just deletes the &quot;foo&quot; line, leaving &quot;bar&quot; in-tact, with the cursor at the start of the &quot;bar&quot; line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand there are many other ways to accomplish this particular situation, but I am trying to understand this fundamental behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this occurring, and how can I use the / command so that it deletes/yanks/etc &lt;em&gt;including&lt;/em&gt; the match?&lt;/p&gt;&#xA;" OwnerUserId="2312" LastEditorUserId="51" LastEditDate="2016-04-03T00:30:35.357" LastActivityDate="2016-04-03T00:30:35.357" Title="normal mode delete with search pattern - not deleting whole match" Tags="|regular-expression|search|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5662" PostTypeId="2" ParentId="5660" CreationDate="2015-11-29T20:48:39.353" Score="5" Body="&lt;p&gt;Add &lt;code&gt;\zs&lt;/code&gt; to the end of the search pattern.  This will make it so that everything before &lt;code&gt;\zs&lt;/code&gt; will be excluded from the actual match, but it is required to be there.  The counterpart of &lt;code&gt;\zs&lt;/code&gt; is &lt;code&gt;\ze&lt;/code&gt;, which excludes everything after it from the match but requires it to be there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help on &lt;code&gt;\zs&lt;/code&gt;, see &lt;code&gt;:help \zs&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned in VanLaser's comment, you can also use a &lt;code&gt;search-offset&lt;/code&gt; to accomplish this.  In you example, the command would be &lt;code&gt;/ba/e&amp;lt;enter&amp;gt;&lt;/code&gt;, since the &lt;code&gt;e&lt;/code&gt; offset has the effect of making the search an inclusive motion, thus deleting the match with the rest of the characters between it and the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more on search offsets, see &lt;code&gt;:help search-offset&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-11-29T21:05:13.157" LastActivityDate="2015-11-29T21:05:13.157" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5664" PostTypeId="2" ParentId="5657" CreationDate="2015-11-30T16:00:29.567" Score="1" Body="&lt;p&gt;The problem was related to that bit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echon &quot;\r&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... in the file dumper function, used to reset the cursor position. Stack multiple &lt;code&gt;SendToFile()&lt;/code&gt; and you get the cursor aligned too many time causing the next &lt;code&gt;echom&lt;/code&gt; commands to be not visible in the status line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution (for now) is to use a variable &lt;code&gt;s:isFileStreamActive&lt;/code&gt; that is set to 1 inside &lt;code&gt;SendToFile()&lt;/code&gt; and to 0 inside &lt;code&gt;SendToStatus()&lt;/code&gt;. In that way, consecutive &lt;code&gt;echon &quot;\r&quot;&lt;/code&gt; commands can be skipped with an &lt;code&gt;if&lt;/code&gt; statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !s:isFileStreamActive&#xA;    echon &quot;\r&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5328" LastActivityDate="2015-11-30T16:00:29.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5665" PostTypeId="2" ParentId="5567" CreationDate="2015-11-30T16:51:53.017" Score="6" Body="&lt;p&gt;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) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;=&gt;&lt;/strong&gt; i now use just &lt;code&gt;autocmd VimEnter * colorscheme babymate256&lt;/code&gt;&#xA;(which is not as fine as without an autocmd, but it doesn't disorganize up my config structure.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Btw: Additionally, i just haven't found the exact name of my default colorscheme, &quot;:colorscheme &quot; had just printed &quot;default&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;hr&gt;&#xA;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;Afterwards, i solved a very similar problem by putting &quot;set background=dark&quot; &lt;em&gt;before&lt;/em&gt; the colorscheme setting.&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="2354" LastEditDate="2015-12-12T15:03:05.930" LastActivityDate="2015-12-12T15:03:05.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5666" PostTypeId="1" CreationDate="2015-11-30T22:17:18.893" Score="4" ViewCount="760" Body="&lt;p&gt;I have the &lt;a href=&quot;https://github.com/rhysd/vim-clang-format&quot; rel=&quot;nofollow&quot;&gt;VIM Clang Format Plugin&lt;/a&gt; and I would like to format my code every time I save it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;This is in my current .vimrc:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; map to &amp;lt;Leader&amp;gt;cf in C++ code&#xA;  autocmd FileType c,cpp,objc nnoremap &amp;lt;buffer&amp;gt;&amp;lt;Leader&amp;gt;cf :&amp;lt;C-u&amp;gt;ClangFormat&amp;lt;CR&amp;gt;&#xA;  autocmd FileType c,cpp,objc vnoremap &amp;lt;buffer&amp;gt;&amp;lt;Leader&amp;gt;cf :ClangFormat&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Format on save&#xA;  autocmd BufWritePost *&#xA;      \ autocmd FileType c,cpp,objc ClangFormat&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first two lines work &lt;strong&gt;great&lt;/strong&gt;. I can hit &lt;em&gt;leader + cf&lt;/em&gt; in &lt;code&gt;normal mode&lt;/code&gt; and the code gets formatted. My problems are the last two lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;My Intention:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I hit save (&lt;strong&gt;&lt;em&gt;:wc&lt;/em&gt;&lt;/strong&gt;) and BufWritePost * is triggered.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;ClangFormat&lt;/em&gt;&lt;/strong&gt; is only executed if the filetype is c, cpp, or objc (just as in the first two lines). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Well, it doesn't work and I can't find my mistake.  Any help is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5454" LastActivityDate="2015-11-30T22:17:18.893" Title="Can't get autocmd with two events to work" Tags="|vimrc|autocmd|formatting|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5667" PostTypeId="1" AcceptedAnswerId="5669" CreationDate="2015-11-30T22:20:32.760" Score="3" ViewCount="417" Body="&lt;p&gt;I want to create a function for a mapping. The key for the mapping is configured through a variable. How can I escape the key in the return statement so it works?&#xA;This works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:some_key = &quot;&amp;lt;Up&amp;gt;&quot;&#xA;function! &amp;lt;SID&amp;gt;TestFun()&#xA;  &quot; doing something&#xA;  return &quot;\&amp;lt;Up&amp;gt;&quot;&#xA;endfunction&#xA;noremap &amp;lt;expr&amp;gt; g:some_key &amp;lt;SID&amp;gt;TestFun()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I want something likes this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:some_key = &quot;&amp;lt;Up&amp;gt;&quot;&#xA;function! &amp;lt;SID&amp;gt;TestFun()&#xA;  &quot; doing something&#xA;  return &quot;\&quot;.g:some_key&#xA;endfunction&#xA;noremap &amp;lt;expr&amp;gt; g:some_key &amp;lt;SID&amp;gt;TestFun()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Right now my solution was creating a new variable holding the escaped key like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec 'let s:escaped_key = &quot;\'.g:some_key.'&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I'm there's a better way to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: The method I'm looking for should also work for a function called using &lt;code&gt;&amp;lt;C-R&amp;gt;=&amp;lt;SID&amp;gt;SomeFunction()&amp;lt;CR&amp;gt;&lt;/code&gt; in a &lt;code&gt;imap&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5479" LastEditorUserId="5479" LastEditDate="2015-11-30T23:10:22.297" LastActivityDate="2015-12-01T03:17:33.633" Title="Escape return value key in mapping function" Tags="|vimscript|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5668" PostTypeId="1" CreationDate="2015-12-01T00:48:54.197" Score="4" ViewCount="3304" Body="&lt;p&gt;Sometimes, when I send a shell command from vim, I receive an error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, when I type the following command &lt;code&gt;:!chmod +x shellescape(&quot;%&quot;)&lt;/code&gt;, zsh complains with :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;zsh:1: unknown sort specifier&#xA;&#xA;shell returned 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know a way to fix this specific problem :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;!chmod +x &quot; . shellescape(&quot;%&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I don't know is how to read the exact command that the shell tried to execute when I make a mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last commands are not sent directly to the shell, vim evaluates a few things before doing so. I would like to see the result of this evaluation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried looking at the output of the &lt;code&gt;history&lt;/code&gt; command in zsh but it seems that the commands typed in vim are not logged there.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-01T01:25:47.740" LastActivityDate="2015-12-02T06:04:53.797" Title="How to read the exact command executed by the shell when sent from vim?" Tags="|command-line|terminal|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5669" PostTypeId="2" ParentId="5667" CreationDate="2015-12-01T03:17:33.633" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;All problems in computer science can be solved by another level of&#xA;  indirection except for the problem of too many layers of indirection.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;-Kevlin Henney&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Use a &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; (or &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt;) mapping to &lt;code&gt;g:some_key&lt;/code&gt;. Use this new mapping in your function instead of &lt;code&gt;g:some_key&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:some_key = '&amp;lt;Up&amp;gt;'&#xA;execute 'nnoremap &amp;lt;Plug&amp;gt;(some-key) ' . g:some_key&#xA;&#xA;function! s:TestFun()&#xA;  &quot; doing something&#xA;  return &quot;\&amp;lt;Plug&amp;gt;(some-key)&quot;&#xA;endfunction&#xA;execute 'nmap &amp;lt;expr&amp;gt; ' . g:some_key . ' &amp;lt;SID&amp;gt;TestFun()'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are a few things worth noting:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using &lt;code&gt;nmap&lt;/code&gt; instead of &lt;code&gt;nnoremap&lt;/code&gt; so that we can map &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Using double quoted string and escaping the key notation. e.g. &lt;code&gt;&quot;\&amp;lt;Plug&amp;gt;..&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;You can use &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; mapping instead and use &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; if you want to emulate &lt;code&gt;nnoremap&lt;/code&gt;. See &lt;code&gt;:h &amp;lt;SID&amp;gt;&lt;/code&gt; and &lt;code&gt;:h :map-script&lt;/code&gt; for more information.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :execute&#xA;:h &amp;lt;Plug&amp;gt;&#xA;:h &amp;lt;SID&amp;gt;&#xA;:h :map-script&#xA;:h key-notation&#xA;:h expr-string&#xA;:h literal-string&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-12-01T03:17:33.633" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5670" PostTypeId="1" AcceptedAnswerId="5671" CreationDate="2015-12-01T04:03:11.570" Score="6" ViewCount="93" Body="&lt;p&gt;Let's say I've got the following function :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SomeFunction()&#xA;&#xA;    return &quot;/tmp/foo&quot;&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If I type : &lt;code&gt;:echo SomeFunction()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The function is evaluated and the output in vim is the string &lt;code&gt;&quot;/tmp/foo&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If I type : &lt;code&gt;:edit SomeFunction()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The function is not evaluated, instead of opening the file &lt;code&gt;/tmp/foo&lt;/code&gt; a buffer called &lt;code&gt;SomeFunction()&lt;/code&gt; is opened.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If I type &lt;code&gt;!cat SomeFunction()&lt;/code&gt;, the function is not evaluated, the shell complains with the error :  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;zsh: parse error near `()'&#xA;shell returned 1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If I type &lt;code&gt;execute &quot;!cat &quot; . SomeFunction()&lt;/code&gt;, the function is evaluated and the content of &lt;code&gt;/tmp/foo&lt;/code&gt; is displayed in the shell.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I'm editing the file &lt;code&gt;foo&lt;/code&gt; which contains the text &lt;code&gt;hello world&lt;/code&gt; and I type &lt;code&gt;!cat %&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt; is evaluated (or expanded ?) and the shell displays &lt;code&gt;hello world&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm a little confused by all those differences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In which context is a function or a special character like &lt;code&gt;%&lt;/code&gt; (current file) and &lt;code&gt;#&lt;/code&gt; (alternate file) automatically evaluated / expanded and why ?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-01T04:17:17.717" LastActivityDate="2015-12-01T05:29:36.660" Title="When is a function or special character automatically evaluated / expanded and why?" Tags="|vimscript|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5671" PostTypeId="2" ParentId="5670" CreationDate="2015-12-01T05:29:36.660" Score="4" Body="&lt;p&gt;It depends on the Ex command you're trying to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Vim documentation on &lt;code&gt;echo&lt;/code&gt; and &lt;code&gt;edit&lt;/code&gt; comes in useful here as it tells you what each Ex command it expects. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:echo&lt;/code&gt; according to Vim's &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Aecho&quot; rel=&quot;nofollow&quot;&gt;documentation&lt;/a&gt; takes an expression, and expressions can be function calls in Vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:edit&lt;/code&gt; on the other hand expects an &lt;code&gt;+opt&lt;/code&gt;, followed by a &lt;code&gt;+cmd&lt;/code&gt;. Conveniently, the &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Aedit&quot; rel=&quot;nofollow&quot;&gt;Vim documentation&lt;/a&gt; also explains what the &lt;code&gt;+opt&lt;/code&gt; and &lt;code&gt;+cmd&lt;/code&gt; can be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve your problem, you can use the &lt;code&gt;:execute&lt;/code&gt; Ex command instead to evaluate a function like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute(&quot;edit &quot; . SomeFunction())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you ever become confused if an Ex command takes an expression, option, command or something else, remember to always check the Vim documentation as it will let you know what the Ex command is expecting. A trick is to prepend the Ex command with a &lt;code&gt;:&lt;/code&gt; (i.e. &lt;code&gt;:help :echo&lt;/code&gt; for the help page on &lt;code&gt;:echo&lt;/code&gt;) so that you will find the correct match.&lt;/p&gt;&#xA;" OwnerUserId="246" LastActivityDate="2015-12-01T05:29:36.660" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5672" PostTypeId="1" AcceptedAnswerId="5673" CreationDate="2015-12-01T11:24:41.850" Score="3" ViewCount="216" Body="&lt;p&gt;When I have multiple files in the argument list, can I rearrange the order of the list?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args&#xA; [A.md] B.md C.md D.md E.md F.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is there a command/series of commands that gives me&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args&#xA; [A.md] F.md C.md D.md E.md B.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is ask I have a key binding for &lt;code&gt;:next&lt;/code&gt; and &lt;code&gt;:prev&lt;/code&gt; and it would be used full to move the files next to each other so I don't have to press the keybinding mutiple times.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2015-12-01T12:23:07.903" Title="Is is possible to change the order of the argument list?" Tags="|argument-list|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5673" PostTypeId="2" ParentId="5672" CreationDate="2015-12-01T12:11:14.293" Score="3" Body="&lt;pre&gt;&lt;code&gt;$ touch {A,B,C,D,E,F}.md&#xA;$ vim *.md&#xA;:redir =&amp;gt; current_args&#xA;:silent args&#xA;:redir END&#xA;:let current_args =  substitute(current_args, 'F', 'B', '')&#xA;:let current_args =  substitute(current_args, 'B', 'F', '')&#xA;:exe &quot;args &quot;.substitute(current_args, '[\n\r[\]]', '', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First you can use &lt;code&gt;:args&lt;/code&gt; to retrieve the current list of arguments, and &lt;code&gt;:redir&lt;/code&gt; to capture it to a variable. After you manipulate the variable contents, use &lt;code&gt;:args {arglist}&lt;/code&gt; to set the modified arglist. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the output of &lt;code&gt;:args&lt;/code&gt; contains square brackets and newlines, which must be removed before it is used set the new arglist.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2015-12-01T12:23:07.903" LastActivityDate="2015-12-01T12:23:07.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5674" PostTypeId="1" CreationDate="2015-12-01T13:27:50.620" Score="1" ViewCount="141" Body="&lt;p&gt;I'm currently running raspbian (a 7 version, &lt;code&gt;cat /etc/debian_version&lt;/code&gt; says &lt;code&gt;7.8&lt;/code&gt;) on a Raspberry Pi 2 Model B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because I have to edit some of my python files directly on the running system, I copied my &lt;code&gt;.vimrc&lt;/code&gt; file in order to get the vim environment I'm used to work with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing I noticed is that my self defined keys are not working:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-Right&amp;gt; :tabnext&amp;lt;CR&amp;gt;&#xA;map &amp;lt;C-Left&amp;gt; :tabprevious&amp;lt;CR&amp;gt;&#xA;map &amp;lt;C-n&amp;gt; :tabnew&amp;lt;SPACE&amp;gt;&#xA;map &amp;lt;F9&amp;gt; :set number!&amp;lt;CR&amp;gt;&#xA;imap &amp;lt;F9&amp;gt; &amp;lt;ESC&amp;gt;:set number!&amp;lt;CR&amp;gt;a&#xA;set pastetoggle=&amp;lt;F10&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;None of these key combinations work, neither Ctrl+n nor F9, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this question &lt;a href=&quot;https://vi.stackexchange.com/questions/2419/mapping-ctrls-does-not-work&quot;&gt;Mapping Ctrl+s does not work&lt;/a&gt; and I decided to check whether the &lt;code&gt;stty&lt;/code&gt; settings were the same or not.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# on my local debian 7 machine&#xA;$ stty &#xA;speed 38400 baud; line = 0;&#xA;eol = M-^?; eol2 = M-^?; swtch = M-^?;&#xA;iutf8&#xA;&#xA;# on raspbian&#xA;$ stty&#xA;speed 38400 baud; line = 0;&#xA;eol = M-^?; eol2 = M-^?;&#xA;-brkint&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;they are clearly different, so I tried syncing the settings&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; # on my local debian 7 machine&#xA; $ stty --save&#xA; 6506:5:4bf:8a3....&#xA;&#xA; # on raspbian&#xA; $ stty 6506:5:4bf:8a3....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that didn't help either, adding &lt;code&gt;silent !stty -ixon&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt; also didn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of my keymaps seem to be working, I don't understand why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also had a strange error with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; autocmd BufReadPost *&#xA;       \ if ! exists(&quot;g:leave_my_cursor_position_alone&quot;) |&#xA;       \     if line(&quot;'\&quot;&quot;) &amp;gt; 0 &amp;amp;&amp;amp; line (&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) |&#xA;       \         exe &quot;normal g'\&quot;&quot; |&#xA;       \     endif |&#xA;       \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've had these lines in my &lt;code&gt;.vimrc&lt;/code&gt; for ages and now I'm getting this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/teststand/.vimrc-yanez:&#xA;line   95: &#xA;E10: \ should be followed by /, ? or &amp;amp;&#xA;line   96: &#xA;E10: \ should be followed by /, ? or &amp;amp;&#xA;line   97: &#xA;E10: \ should be followed by /, ? or &amp;amp;&#xA;line   98: &#xA;E10: \ should be followed by /, ? or &amp;amp;&#xA;line   99: &#xA;E10: \ should be followed by /, ? or &amp;amp;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know how to solve these problems. Is the vim build buggy or do I have to change something else in my &lt;code&gt;stty&lt;/code&gt; settings?&lt;/p&gt;&#xA;" OwnerUserId="5486" OwnerDisplayName="Pablo" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-12-01T14:22:25.163" Title="Ctrl-Key in vim keymaps running on raspbian are not responsive" Tags="|key-bindings|linux-debian|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="5675" PostTypeId="1" CreationDate="2015-12-01T15:19:26.160" Score="0" ViewCount="103" Body="&lt;p&gt;I wanted to install some plugins in Vim.&lt;br&gt;&#xA;While reading on this topic, I came across plugin manager.  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Why do I need it ?  &lt;/li&gt;&#xA;&lt;li&gt;Which plugin manager - &lt;code&gt;pathogen&lt;/code&gt; and &lt;code&gt;Vundle&lt;/code&gt; should I use ?  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, I want to know more about reasons for choosing one over the other or not choosing one.&lt;/p&gt;&#xA;" OwnerUserId="5087" LastEditorUserId="5087" LastEditDate="2015-12-01T18:56:36.617" LastActivityDate="2015-12-01T18:56:36.617" Title="What is the ideal way of installing a vim plugin?" Tags="|plugin-system|" AnswerCount="0" CommentCount="4" ClosedDate="2015-12-01T21:43:17.587" ContentLicense="CC BY-SA 3.0" />
  <row Id="5676" PostTypeId="1" CreationDate="2015-12-01T19:36:13.923" Score="2" ViewCount="320" Body="&lt;p&gt;I want to work with a C code with a lot of #ifdef directives. I wonder if there is a program, that will show me, which of these #ifdef's will be left in the code, and which will be cut out by preprocessor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, maybe, a tool, showing a list of defined preprocessor variables for this exact position in the source.&lt;/p&gt;&#xA;" OwnerUserId="5365" LastEditorUserId="51" LastEditDate="2015-12-02T05:57:12.870" LastActivityDate="2015-12-02T05:57:12.870" Title="Tools for working with C #ifdef preprocessor directives?" Tags="|ide|filetype-c|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5677" PostTypeId="1" AcceptedAnswerId="5678" CreationDate="2015-12-02T03:26:52.983" Score="1" ViewCount="1757" Body="&lt;p&gt;I would like to have a mapping that opens a buffer with all the lines containing the word under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know such a mapping already exists in vanilla vim in normal mode &lt;code&gt;[I&lt;/code&gt;.&lt;br&gt;&#xA;But I don't like the output, the controls to move seem limited and I don't know how to edit it like a normal buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've come up with the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LinesWithWordUnderCursor()&#xA;&#xA;    &quot; Clear register a&#xA;    let @a=&quot;&quot;&#xA;    &quot; Save cursor position&#xA;    let save_cursor = getcurpos()&#xA;&#xA;    &quot; Copy all the lines containing the word under cursor with format :&#xA;    &quot; line number &amp;lt;space&amp;gt; line &amp;lt;CR&amp;gt;&#xA;    &quot;&#xA;    &quot; Resulting command :&#xA;    &quot; g/{cword}/let @a = @a . line('.') . ' ' . getline('.') . '\r'&#xA;&#xA;    execute &quot;g/&quot; . expand(&quot;&amp;lt;cword&amp;gt;&quot;) . &quot;/let @a = @a . line('.') . ' ' . getline('.') . '\r'&quot;&#xA;&#xA;    &quot; Put the cursor back where it was&#xA;    call setpos('.', save_cursor)&#xA;    &quot; Open a new tab&#xA;    tabnew&#xA;    &quot; Set buffer as temporary&#xA;    setlocal buftype=nofile noswapfile nobuflisted bufhidden=wipe nomodified&#xA;    &quot; Paste register a&#xA;    put =@a&#xA;&#xA;endfunction&#xA;&#xA;nnoremap [I :&amp;lt;c-u&amp;gt;call LinesWithWordUnderCursor()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function appends all the lines inside the register &lt;code&gt;a&lt;/code&gt;.&#xA;I would like the following formatting :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;{the line number} {a tab character} {the line} {a newline character}&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function works, but I don't know how to insert a control character like a tab or a newline on each copied line.&lt;br&gt;&#xA;The command responsible for copying and formatting a line is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;g/&quot; . expand(&quot;&amp;lt;cword&amp;gt;&quot;) . &quot;/let @a = @a . line('.') . ' ' . getline('.') . '\r'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried adding &lt;code&gt;\t&lt;/code&gt; and &lt;code&gt;\n&lt;/code&gt; in different ways (escaping the double quotes, using single quotes, using the &lt;code&gt;string()&lt;/code&gt; function ...), but it always ends with an error or with undesirable single quote characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to build a global command by concatenating a few strings and then execute it with &lt;code&gt;execute&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the end of the concatenation, &lt;code&gt;execute&lt;/code&gt; should execute something like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/{word under cursor}/let @a = @a . line('.') . &quot;\t&quot; . getline('.') . &quot;\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the moment I use a litteral space instead of a tab character, and a carriage return (&lt;code&gt;\r&lt;/code&gt;) instead of a newline (which produces a weird output with the caret notation &lt;code&gt;^M&lt;/code&gt; at the end of every line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I modify the concatenation of strings executed by the &lt;code&gt;execute&lt;/code&gt; command so that it integrates a tab character instead of a space and a newline character instead of a carriage return ?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-02T05:11:14.993" LastActivityDate="2015-12-04T17:19:07.187" Title="How to add a control character inside a string executed by the execute command?" Tags="|vimscript|register|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5678" PostTypeId="2" ParentId="5677" CreationDate="2015-12-02T05:14:16.530" Score="4" Body="&lt;p&gt;You command looks like follow without the &lt;code&gt;:execute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/pat/let @a.= line('.') . &quot;\t&quot; . getline('.') . &quot;\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adding in the &lt;code&gt;:execute&lt;/code&gt; means you need to quote things correctly. The real trick is to use single quote. Also properly escape your single quotes or switching to double quotes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :execute 'g/' . expand('&amp;lt;cword&amp;gt;') . '/let @a.= line(&quot;.&quot;) . &quot;\t&quot; . getline(&quot;.&quot;) . &quot;\n&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h expr-string&#xA;:h literal-string&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-12-02T15:24:24.903" LastActivityDate="2015-12-02T15:24:24.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5679" PostTypeId="2" ParentId="5668" CreationDate="2015-12-02T06:04:53.797" Score="2" Body="&lt;p&gt;A bigger problem here is that your command is wrong.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:!chmod +x shellescape(&quot;%&quot;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What makes you think you can run Vim functions like this? Use &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%25%3aS&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;%:S&lt;/code&gt;&lt;/a&gt; to escape special shell characters, eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!chmod +x %:S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I realize this doesn't answer your question directly, but for all practical purposes all you need to know &quot;If error, use &lt;code&gt;%:S&lt;/code&gt;, if still error, read what you typed&quot;, as there aren't any other substitutions done in the &lt;code&gt;:!&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-12-02T06:04:53.797" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5680" PostTypeId="1" CreationDate="2015-12-02T09:45:09.240" Score="10" ViewCount="3868" Body="&lt;p&gt;I find both &lt;em&gt;number&lt;/em&gt; and &lt;em&gt;relativenumber&lt;/em&gt; useful.  Is there any way to display them both at the same time?&lt;/p&gt;&#xA;" OwnerUserId="650" LastActivityDate="2022-07-23T10:13:11.773" Title="How can I set number and relativenumber at the same time?" Tags="|line-numbers|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5681" PostTypeId="1" AcceptedAnswerId="5682" CreationDate="2015-12-02T10:36:53.327" Score="19" ViewCount="2358" Body="&lt;p&gt;Due to a quirk in the domain-specific language I am working with, I frequently face the task of (selectively, not globally) replacing &lt;code&gt;term&lt;/code&gt; or &lt;code&gt;TERM&lt;/code&gt; with &lt;code&gt;word&lt;/code&gt; or &lt;code&gt;WORD&lt;/code&gt;, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means, I search case-insensitively for &lt;code&gt;term&lt;/code&gt;, and want to replace that with &lt;code&gt;word&lt;/code&gt; &lt;em&gt;while keeping the uppercase / lowercase of the original &lt;code&gt;term&lt;/code&gt; intact&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since checking the whole of &lt;code&gt;term&lt;/code&gt; for &lt;em&gt;consistent&lt;/em&gt; upper-/lowercase would be difficult and is not really necessary, I would settle for uppercase / lowercase of &lt;code&gt;word&lt;/code&gt; / &lt;code&gt;WORD&lt;/code&gt; being decided on the first letter of &lt;code&gt;term&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I achieve this?&lt;/p&gt;&#xA;" OwnerUserId="1726" LastActivityDate="2021-02-06T14:04:40.077" Title="Replace a string without changing case?" Tags="|substitute|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5682" PostTypeId="2" ParentId="5681" CreationDate="2015-12-02T10:54:55.617" Score="18" Body="&lt;p&gt;Michaels Geddes' plugin &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=6&quot; rel=&quot;nofollow noreferrer&quot;&gt;keepcase&lt;/a&gt; (&lt;a href=&quot;https://github.com/vim-scripts/keepcase.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub&lt;/a&gt;) has all you need:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%SubstituteCase/\cterm/word/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Other syntax elements from &lt;code&gt;:substitute&lt;/code&gt; are also supported.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="51" LastEditDate="2021-02-06T14:04:40.077" LastActivityDate="2021-02-06T14:04:40.077" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5683" PostTypeId="2" ParentId="5681" CreationDate="2015-12-02T11:04:29.573" Score="21" Body="&lt;p&gt;This can be handled by the &lt;code&gt;:Subvert&lt;/code&gt; from the &lt;a href=&quot;https://github.com/tpope/vim-abolish/#substitution&quot;&gt;abolish plugin&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;One time I had an application with a domain model called &quot;facility&quot;&#xA;  that needed to be renamed to &quot;building&quot;. So, a simple search and&#xA;  replace, right?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/facility/building/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Oh, but the case variants!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/Facility/Building/g&#xA;:%s/FACILITY/BUILDING/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Wait, the plural is more than &quot;s&quot; so we need to get that too!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/facilities/buildings/g&#xA;:%s/Facilities/Buildings/g&#xA;:%s/FACILITIES/BUILDINGS/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Abolish.vim has your back. One command to do all six, and you can&#xA;  repeat it with &amp;amp; too!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%Subvert/facilit{y,ies}/building{,s}/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-12-02T11:04:29.573" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5684" PostTypeId="2" ParentId="5680" CreationDate="2015-12-02T13:55:13.747" Score="8" Body="&lt;p&gt;Showing all the line numbers and relative numbers at the same time isn't possible. But you can get the current line number and the relative number for all the others. From &lt;code&gt;:help number_relativenumber&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The 'relativenumber' option changes the displayed number to be&#xA;relative to the cursor.  Together with 'number' there are these&#xA;four combinations (cursor in line 3):&#xA;&#xA;    'nonu'          'nu'            'nonu'          'nu'&#xA;    'nornu'         'nornu'         'rnu'           'rnu'&#xA;&#xA;    |apple          |  1 apple      |  2 apple      |  2 apple&#xA;    |pear           |  2 pear       |  1 pear       |  1 pear&#xA;    |nobody         |  3 nobody     |  0 nobody     |3   nobody&#xA;    |there          |  4 there      |  1 there      |  1 there&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reasoning about this can be found at this &lt;a href=&quot;https://groups.google.com/forum/#!searchin/vim_dev/relativenumber/vim_dev/tOmXNHXsAKE/PtnprbOqfO8J&quot; rel=&quot;noreferrer&quot;&gt;discussion on vim-dev mailing group&lt;/a&gt;, which contains a link to a &lt;a href=&quot;https://www.reddit.com/r/vim/comments/17gg56/&quot; rel=&quot;noreferrer&quot;&gt;similar  reddit question: Relative numbering with absolute number on the current line&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-12-02T13:55:13.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5685" PostTypeId="1" AcceptedAnswerId="5690" CreationDate="2015-12-02T15:31:39.447" Score="8" ViewCount="3567" Body="&lt;p&gt;I don't use any &lt;code&gt;g combinations&lt;/code&gt; except of &lt;code&gt;gg&lt;/code&gt;, in normal mode. How can I make it so that pressing &lt;code&gt;g&lt;/code&gt; once will be enough?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap g gg&lt;/code&gt; makes it wait for 3 seconds or so for a continuation of the command. Unmapping &lt;code&gt;g&lt;/code&gt; beforehand doesn't work either, because I can't map to &lt;code&gt;gg&lt;/code&gt; if I unmap &lt;code&gt;g&lt;/code&gt;. Should I unmap every single combination that isn't &lt;code&gt;gg&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5365" LastActivityDate="2015-12-02T22:23:11.000" Title="How to remap gg to g?" Tags="|key-bindings|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="5686" PostTypeId="1" AcceptedAnswerId="5688" CreationDate="2015-12-02T15:57:02.407" Score="1" ViewCount="109" Body="&lt;p&gt;Given&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&#xA;b&#xA;c&#xA;d&#xA;e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to &lt;code&gt;5yy&lt;/code&gt; and then separately paste 5 lines in arbitrary locations in order of &lt;code&gt;a&lt;/code&gt; &lt;code&gt;b&lt;/code&gt; &lt;code&gt;c&lt;/code&gt; &lt;code&gt;d&lt;/code&gt; &lt;code&gt;e&lt;/code&gt; instead of a separate &lt;code&gt;yy&lt;/code&gt; &lt;code&gt;p&lt;/code&gt; for each line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any plugins or Vim script that would service this type of workflow?&#xA;Or is there a basic set of macros that would help me achieve this?&lt;/p&gt;&#xA;" OwnerUserId="5487" LastActivityDate="2015-12-02T17:07:10.400" Title="Yank with Separate Line Pasting" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5687" PostTypeId="1" AcceptedAnswerId="5694" CreationDate="2015-12-02T16:31:21.807" Score="25" ViewCount="17892" Body="&lt;p&gt;I've started using diff mode in vim at work, and the one thing I noticed is that the colors are really bright, which doesn't help when you're trying to look for differences in huge files for long periods of time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any color schemes out there that people have customized to make diff mode easier on the eyes?&lt;/p&gt;&#xA;" OwnerUserId="5492" LastActivityDate="2019-07-09T05:51:34.183" Title="Better diff color scheme" Tags="|vimdiff|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5688" PostTypeId="2" ParentId="5686" CreationDate="2015-12-02T16:32:55.247" Score="3" Body="&lt;p&gt;If you paste into order, we could imagine something that consumes one line in the unnamed register (or any other) each time it's used.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap £ :call append('.', matchstr(getreg(v:register),&quot;\\v.{-}\\ze\n&quot;))&amp;lt;cr&amp;gt;:call setreg(v:register, substitute(getreg(v:register) , &quot;\\v.{-}(\n\|$)&quot;, '', ''))&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Of course, a function (and using &lt;code&gt;:put=&lt;/code&gt; instead of &lt;code&gt;append()&lt;/code&gt;) would be better. This is just a quick and dirty solution. From a function we could have used &lt;code&gt;matchlist()&lt;/code&gt; instead of &lt;code&gt;matchstr()&lt;/code&gt; + &lt;code&gt;substitute()&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2015-12-02T17:07:10.400" LastActivityDate="2015-12-02T17:07:10.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5689" PostTypeId="2" ParentId="5687" CreationDate="2015-12-02T17:06:27.187" Score="13" Body="&lt;p&gt;I have a syntax/diff.vim (that I source manually) with the following contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi DiffText   cterm=none ctermfg=Black ctermbg=Red gui=none guifg=Black guibg=Red&#xA;hi DiffChange cterm=none ctermfg=Black ctermbg=LightMagenta gui=none guifg=Black guibg=LightMagenta&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="9165" LastEditDate="2019-03-21T13:25:39.300" LastActivityDate="2019-03-21T13:25:39.300" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5690" PostTypeId="2" ParentId="5685" CreationDate="2015-12-02T17:19:11.063" Score="22" Body="&lt;p&gt;Assuming you have a newer version of Vim (7.3.1261+) you can use &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;nowait&amp;gt; g gg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although, I can not stress the usefulness of some of the &lt;code&gt;g&lt;/code&gt; mappings. Here is a short list of useful &lt;code&gt;g&lt;/code&gt; mappings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;gE&lt;/code&gt; - backwards end of word motion&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g_&lt;/code&gt; - to the last non-blank character of a line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gt&lt;/code&gt; &amp;amp; &lt;code&gt;gT&lt;/code&gt; - tab navigation&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g,&lt;/code&gt; &amp;amp; &lt;code&gt;g;&lt;/code&gt; - back and forth through the change list&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gu&lt;/code&gt; &amp;amp; &lt;code&gt;gU&lt;/code&gt; - case changing&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gn&lt;/code&gt; - visually select current pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gv&lt;/code&gt; - reselect previous visual selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gi&lt;/code&gt; - start insert mode in the same position Insert mode was last stopped&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gf&lt;/code&gt; - go to file under cursor (My personal favorite)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h g&lt;/code&gt; for a list of all &lt;code&gt;g&lt;/code&gt; mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I would just learn to use &lt;code&gt;gg&lt;/code&gt; as it is a good habit and less is not known to be a good Vi/Vim emulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h g&#xA;:h :map-nowait&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-12-02T22:23:11.000" LastActivityDate="2015-12-02T22:23:11.000" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="5691" PostTypeId="2" ParentId="5680" CreationDate="2015-12-02T19:25:44.657" Score="6" Body="&lt;p&gt;It is not really possible to have both number and relativenumber displayed at the same time, besides what is mentioned at &lt;code&gt;:h number_relativenumber&lt;/code&gt; (see different answer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can misuse the gutter column to display extra numbers. For example, you can use my &lt;a href=&quot;https://github.com/chrisbra/DynamicSigns&quot; rel=&quot;noreferrer&quot;&gt;DynamicSigns&lt;/a&gt; plugin and let it draw the relativenumber column besides the number column. For that to work, you do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :SignExpression CustomSignExpression(v:lnum, 1)&#xA; :let &amp;amp;nuw=&amp;amp;nuw+1&#xA; :set nu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See the help &lt;code&gt;:h SignExpression&lt;/code&gt; for the definition of the CustomSignExpression function (The 1 means, to draw the relativenumber at every line, use 5 to draw it only every fifth line). Increasing the &lt;code&gt;'numberwidth'&lt;/code&gt; setting (the &lt;code&gt;:let &amp;amp;nuw=&amp;amp;nuw+1&lt;/code&gt; part) just makes sure, there will be an extra space between the gutter column and the number column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note however, this will considerable slow down vim when scrolling, as the signs need to be recreated on every move.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this example. &lt;a href=&quot;https://i.stack.imgur.com/FaASy.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FaASy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2015-12-02T19:47:25.680" LastActivityDate="2015-12-02T19:47:25.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5692" PostTypeId="1" CreationDate="2015-12-02T19:55:32.937" Score="1" ViewCount="359" Body="&lt;p&gt;Is is possible to get the original working directory of vim after changing the local working directory?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say I open vim with parent directory:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/projects/myproject&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and then I open a file and change the working directory:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/projects/myproject/tasks/mytask.js&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter * silent! lcd %:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;GOAL:&lt;/strong&gt; I want to get the directory name:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/projects/myproject&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/projects/myproject/tasks&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="5498" LastActivityDate="2015-12-03T16:23:54.347" Title="After changing lcd get parent directory of original file" Tags="|working-directory|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5693" PostTypeId="2" ParentId="5692" CreationDate="2015-12-02T20:08:32.367" Score="0" Body="&lt;pre&gt;&lt;code&gt;:echo system(&quot;pwd&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should give you the information you want.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-02T20:08:32.367" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5694" PostTypeId="2" ParentId="5687" CreationDate="2015-12-02T20:13:10.410" Score="16" Body="&lt;p&gt;I quite like the diff colors in &lt;a href=&quot;https://github.com/romainl/Apprentice&quot; rel=&quot;noreferrer&quot;&gt;my colorscheme&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sgNwU.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sgNwU.png&quot; alt=&quot;diff&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-02T20:13:10.410" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5695" PostTypeId="2" ParentId="5685" CreationDate="2015-12-02T20:25:03.360" Score="7" Body="&lt;p&gt;Just to chime in, if you really really want a single key - you can still use ... &lt;em&gt;another&lt;/em&gt; one (i.e. a key that you don't need that much)! In this way you can leave the useful &lt;code&gt;g&lt;/code&gt; prefix alone. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you can &quot;overload&quot; &lt;code&gt;0&lt;/code&gt; to toggle between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;^&lt;/code&gt; functionality, when repeatedly pressed, and free &lt;code&gt;^&lt;/code&gt; instead for your usage (since it's an intuitive &lt;em&gt;go up&lt;/em&gt; character). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure this is not perfect, but here's a possible quick-n-dirty proof of concept:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToStartOrNonBlankToggle(mode)&#xA;    if (a:mode == 'x')&#xA;        normal! gv&#xA;    endif&#xA;    let sp = col('.')&#xA;    normal! ^&#xA;    let ep = col('.')&#xA;    if (sp == ep)&#xA;        normal! 0&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; 0 :&amp;lt;c-u&amp;gt;call ToStartOrNonBlankToggle('n')&amp;lt;cr&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; 0 :&amp;lt;c-u&amp;gt;call ToStartOrNonBlankToggle('o')&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; 0 :&amp;lt;c-u&amp;gt;call ToStartOrNonBlankToggle('x')&amp;lt;cr&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; ^ gg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above still allows using 0 as motion, and also from visual mode. On an indented line, &lt;code&gt;y0&lt;/code&gt; would now copy from cursor position to the first non-blank character. If you want to copy to the start column instead, you'll have to go visual: &lt;code&gt;v00y&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can now also use &lt;code&gt;13^&lt;/code&gt; to go to line 13.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-12-02T20:30:22.287" LastActivityDate="2015-12-02T20:30:22.287" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5696" PostTypeId="1" AcceptedAnswerId="5698" CreationDate="2015-12-03T00:30:14.470" Score="5" ViewCount="3141" Body="&lt;p&gt;I'm using Vim with the Vaxe plugin for syntax highlighting, the plugin's highlighting file is &lt;a href=&quot;https://github.com/jdonaldson/vaxe/blob/master/syntax/haxe.vim&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; for reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to add some conceals to tidy up the code visually, but I can't seem to get anything to apply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest thing I'm trying to achieve as to conceal the word &quot;package&quot; as just the letter &quot;p&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using various plugins like SyntaxAttr.vim, I determined the syntax attributes for the word package are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi&amp;lt;haxeTypeDecl&amp;gt; trans&amp;lt;haxeTypeDecl&amp;gt; lo&amp;lt;Statement&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I try to add it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn match haxeTypeDecl /package/ conceal cchar=p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The entry seems to be added as I can see it with &quot;:syn&quot; as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;haxeTypeDecl   xxx abstract interface from import to using enum class package&#xA;               match /^class\&amp;gt;/&#xA;               match /[^.]\s*\&amp;lt;class\&amp;gt;/ms=s+1&#xA;               match /package/  conceal&#xA;               links to Keyword&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I set conceal level to 2, but the text is not concealed. It works when I test it in an empty stand alone document, but doesn't in a real document. I'm guessing I'm not properly overriding the highlighting, but I'm not sure what I'm meant to do. Do I make my own group and linked it with &quot;:hl! link&quot;?, add a match higher priority match with matchadd()? Do I have to also override the Statement group or the Keywords group? Vim's syntax highlighting seems unbelievably dense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank's in advance!&lt;/p&gt;&#xA;" OwnerUserId="5502" LastActivityDate="2023-07-28T07:04:55.880" Title="Adding conceal to already existing syntax highlighting?" Tags="|syntax-highlighting|conceal|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5697" PostTypeId="2" ParentId="5687" CreationDate="2015-12-03T03:46:25.243" Score="6" Body="&lt;p&gt;My own scheme &quot;&lt;a href=&quot;https://github.com/joeytwiddle/vim-diff-traffic-lights-colors&quot; rel=&quot;noreferrer&quot;&gt;Traffic light colors&lt;/a&gt;&quot; featuring red, yellow, green and blue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are a bit gentler in GVim than on the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But they were really designed to be intuitive (for westerners) rather than gentle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/P8U2v.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/P8U2v.png&quot; alt=&quot;gvim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hwlN7.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hwlN7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-12-03T03:46:25.243" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5698" PostTypeId="2" ParentId="5696" CreationDate="2015-12-03T08:53:45.117" Score="5" Body="&lt;p&gt;The problem in your case is that the syntax highlighting script for your &lt;a href=&quot;https://github.com/jdonaldson/vaxe/blob/master/syntax/haxe.vim#L23&quot; rel=&quot;nofollow noreferrer&quot;&gt;package&lt;/a&gt; defines a &lt;strong&gt;keyword&lt;/strong&gt; (enter &lt;code&gt;:h syn-keyword&lt;/code&gt; for more details) and that always has priority before any of the syn-match or syn-region rules.&lt;/p&gt;&#xA;&lt;p&gt;In your case, I would therefore simply use a &lt;code&gt;matchadd()&lt;/code&gt; call like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; :call matchadd('Conceal', 'package', 10, 99, {'conceal': 'p'})&#xA; :set conceallevel=2 concealcursor=nv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This requires a relatively new Vim version (I don't remember the exact patch level, but a 7.4.700 should work)&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="48407" LastEditDate="2023-07-28T07:04:55.880" LastActivityDate="2023-07-28T07:04:55.880" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="5699" PostTypeId="1" AcceptedAnswerId="5701" CreationDate="2015-12-03T08:54:02.263" Score="3" ViewCount="369" Body="&lt;p&gt;I want to write a function that will remove blank lines given a set of visually selected lines by the user. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After removing the blank lines, I want the input lines still be visually selected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this? Here is the code that removes blank lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RemoveBlankLines() range&#xA;    exe a:firstline.&quot;,&quot;.a:lastline.&quot;g/^\s*$/d&quot;&#xA;endfunction&#xA;command! -range=% RemoveBlankLines &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call RemoveBlankLines()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5506" LastActivityDate="2015-12-03T10:02:50.433" Title="Visually select a few lines given start and end positions in vimscript" Tags="|vimscript|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5701" PostTypeId="2" ParentId="5699" CreationDate="2015-12-03T10:02:50.433" Score="4" Body="&lt;p&gt;I would have said to use &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt; marks, but alas each command executed by &lt;code&gt;:global&lt;/code&gt; is messing with them.&#xA;However, you only need to know the new last line, as the first line won't change. &lt;code&gt;']&lt;/code&gt; won't be enough as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see several solution:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Mark the last line. Cons: it'll modify a mark -&gt; this may mess the marks the end user is using -&gt; not good&lt;/li&gt;&#xA;&lt;li&gt;have &lt;code&gt;:g&lt;/code&gt; count how many lines you have removed. Cons: more verbose code&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't reselect at the end of the command (which will be odd if it wasn't called from the visual mode), but at the end of a visual mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;xnoremap µ :RemoveBlankLine&amp;lt;cr&amp;gt;gv&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And let the user manually reselect  after the call to the command -- I'm not sure you'll be able to use &lt;code&gt;mode()&lt;/code&gt; to check whether you are in visual mode to conditionally reselect.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Anyway, back to your exact question, I'll do it this way (2.):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:RemoveBlankLines() range&#xA;    let cpt = 0&#xA;    silent exe a:firstline.','.a:lastline.'g/^\s*$/d_|let cpt+=1'&#xA;    exe a:firstline&#xA;    normal! V&#xA;    exe (a:lastline-cpt)&#xA;endfunction&#xA;&#xA;command! -range=% RemoveBlankLines &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call s:RemoveBlankLines()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2015-12-03T10:02:50.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5703" PostTypeId="1" CreationDate="2015-12-03T15:19:41.597" Score="5" ViewCount="1128" Body="&lt;p&gt;When I type &lt;code&gt;:ls&lt;/code&gt;, I get a list of buffers with non-sequential, high numbers (I didn't open 800 files):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls!&#xA;  1      &quot;b(...)&quot; line 67&#xA;  2 #    &quot;b(...)&quot; line 90&#xA;  3      &quot;b(...)&quot; line 50&#xA;  4      &quot;b(...)&quot; line 90&#xA; 27u  -  &quot;ControlP&quot; line 8&#xA; 77      &quot;b(...)&quot; line 16&#xA; 93      &quot;b(...)&quot; line 1&#xA; 94      &quot;b(...)&quot; line 209&#xA; 99      &quot;b(...)&quot; line 135&#xA;104      &quot;b(...)&quot; line 52&#xA;109      &quot;b(...)&quot; line 65&#xA;110      &quot;b(...)&quot; line 44&#xA;112      &quot;b(...)&quot; line 39&#xA;113      &quot;b(...)&quot; line 339&#xA;114      &quot;b(...)&quot; line 58&#xA;130  a   &quot;b(...)&quot; line 186&#xA;144      &quot;s(...)&quot; line 51&#xA;146      &quot;b(...)&quot; line 6&#xA;147      &quot;b(...)&quot; line 359&#xA;150      &quot;t(...)&quot; line 1&#xA;151      &quot;b(...)&quot; line 123&#xA;152      &quot;b(...)&quot; line 178&#xA;187      &quot;b(...)&quot; line 581&#xA;204      &quot;s(...)&quot; line 1&#xA;239u     &quot;2&quot; line 1&#xA;244      &quot;b(...)&quot; line 42&#xA;258      &quot;b(...)&quot; line 73&#xA;278      &quot;t(...)&quot; line 1&#xA;281      &quot;t(...)&quot; line 153&#xA;308      &quot;t(...)&quot; line 1&#xA;313      &quot;t(...)&quot; line 15&#xA;314      &quot;v(...)&quot; line 1&#xA;315      &quot;s(...)&quot; line 217&#xA;318      &quot;b(...)&quot; line 34&#xA;325u h-  &quot;NERD_tree_1&quot; line 32&#xA;326      &quot;t(...)&quot; line 1&#xA;327      &quot;t(...)&quot; line 34&#xA;347      &quot;b(...)&quot; line 49&#xA;350      &quot;b(...)&quot; line 5&#xA;481      &quot;b(...)&quot; line 38&#xA;566      &quot;b(...)&quot; line 30&#xA;583      &quot;t(...)&quot; line 55&#xA;680      &quot;t(...)&quot; line 33&#xA;685      &quot;b(...)&quot; line 216&#xA;784      &quot;t(...)&quot; line 1&#xA;815      &quot;b(...)&quot; line 1&#xA;816  a   &quot;b(...)&quot; line 0&#xA;878      &quot;f(...)&quot; line 1&#xA;879      &quot;b(...)&quot; line 1&#xA;880      &quot;f(...)&quot; line 1&#xA;881 %a + &quot;[No Name]&quot; line 1&#xA;Press ENTER or type command to continue   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why did this happen?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't use &lt;code&gt;:grep&lt;/code&gt;. I have the following plugins installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Plugin 'VundleVim/Vundle.vim'&#xA;  Plugin 'kien/ctrlp.vim'&#xA;  Plugin 'morhetz/gruvbox'&#xA;  Plugin 'scrooloose/nerdtree'&#xA;  Plugin 'majutsushi/tagbar'&#xA;  Plugin 'tomtom/tcomment_vim'&#xA;  Plugin 'Shougo/unite.vim'&#xA;  Plugin 'tpope/vim-fugitive'&#xA;  Plugin 'airblade/vim-gitgutter'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5512" LastEditorUserId="205" LastEditDate="2015-12-16T23:02:13.003" LastActivityDate="2015-12-16T23:02:13.003" Title="Why are my buffer numbers so high?" Tags="|buffers|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="5704" PostTypeId="1" AcceptedAnswerId="5705" CreationDate="2015-12-03T15:53:34.517" Score="1" ViewCount="1810" Body="&lt;p&gt;I have the following directory structure&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current Directory&lt;/p&gt;&#xA;&#xA;&lt;p&gt;|--components&lt;/p&gt;&#xA;&#xA;&lt;p&gt;|--|--Artist&lt;/p&gt;&#xA;&#xA;&lt;p&gt;|--|--|--index.js&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so i want to display &quot;Artist/index.js&quot; or &quot;C/c/Artist/index.js&quot; in my tabline in vim-airline&lt;/p&gt;&#xA;" OwnerUserId="5513" LastActivityDate="2021-02-07T12:25:29.290" Title="Show current file name and parent directory in tabline of vim-airline" Tags="|plugin-airline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5705" PostTypeId="2" ParentId="5704" CreationDate="2015-12-03T16:03:50.613" Score="1" Body="&lt;p&gt;I figured it out. These are the lines I added to the configuration file.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline#extensions#tabline#fnamemod = ':.'&#xA;let g:airline#extensions#tabline#fnamecollapse = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5513" LastEditorUserId="5864" LastEditDate="2021-02-07T12:25:29.290" LastActivityDate="2021-02-07T12:25:29.290" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5706" PostTypeId="2" ParentId="5692" CreationDate="2015-12-03T16:23:54.347" Score="3" Body="&lt;h3&gt;Fugitive&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If your project is under git's control then you use &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow&quot;&gt;Fugitive.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo fugitive#repo().tree()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To edit a file relative to the git root you an use &lt;code&gt;:Gedit&lt;/code&gt; and a &lt;code&gt;/&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Gedit /tasks/mytask.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h fugitive&#xA;:h :Gedit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Projectionist&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you are using &lt;a href=&quot;https://github.com/tpope/vim-projectionist&quot; rel=&quot;nofollow&quot;&gt;Projectionist.vim&lt;/a&gt; then you can get the inner most directory by doing the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo projectionist#path()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Projectionist also provides &lt;code&gt;:Cd&lt;/code&gt; to change the directory from the project root. &lt;code&gt;:ProjectDo {cmd}&lt;/code&gt; will run command, &lt;code&gt;{cmd}&lt;/code&gt;, from the project root.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h projectionist&#xA;:h :Cd&#xA;:h :ProjectDo&#xA;:h projectionist#path()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Low-tech solution&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Forget &quot;auto-cd-ing&quot; to the current file's directory. Just set your current path to your project's root. Use a nice fuzzyfinder like &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;nofollow&quot;&gt;CtrlP&lt;/a&gt; to navigate your files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;%:h&lt;/code&gt; to get the current file's directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e %:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'autochdir'&#xA;:h c_%&#xA;:h filename-modifiers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Thoughts&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Personally I use projectionist for my project needs, however I also keep the current working directory at my project root and never change it. This keeps things simple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do insist on &quot;auto-cd-ing&quot; then I would recommend you look into &lt;code&gt;'autochdir&lt;/code&gt;. See &lt;code&gt;:h 'autochdir'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-12-03T16:23:54.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5707" PostTypeId="1" AcceptedAnswerId="5710" CreationDate="2015-12-03T16:46:42.747" Score="1" ViewCount="403" Body="&lt;p&gt;If I open multiple files in vi, and then when issuing the &lt;code&gt;:bnext&lt;/code&gt; or &lt;code&gt;:bprev&lt;/code&gt; or &lt;code&gt;:buffer&lt;/code&gt; command I'm presented with &lt;code&gt;Feature not implemented&lt;/code&gt;, how do I edit one of the other files that I have open?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="51" LastEditDate="2015-12-03T22:26:14.160" LastActivityDate="2015-12-03T22:26:14.160" Title="How to edit the next file when VI doesn't have buffer support?" Tags="|multiple-files|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5708" PostTypeId="5" CreationDate="2015-12-03T16:47:23.097" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-12-03T16:47:23.097" LastActivityDate="2015-12-03T16:47:23.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5709" PostTypeId="4" CreationDate="2015-12-03T16:47:23.097" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-12-03T16:47:23.097" LastActivityDate="2015-12-03T16:47:23.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5710" PostTypeId="2" ParentId="5707" CreationDate="2015-12-03T16:48:27.287" Score="3" Body="&lt;p&gt;&lt;code&gt;:n&lt;/code&gt; will go to the next file when you open multiple ones&lt;/p&gt;&#xA;" OwnerUserId="1828" LastActivityDate="2015-12-03T16:48:27.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5711" PostTypeId="1" AcceptedAnswerId="5712" CreationDate="2015-12-03T16:51:11.713" Score="1" ViewCount="720" Body="&lt;p&gt;I was recently &lt;a href=&quot;https://github.com/kenorb/dotfiles/blob/master/.vimrc&quot; rel=&quot;nofollow&quot;&gt;looking at a another users &lt;code&gt;.vimrc&lt;/code&gt;&lt;/a&gt; and noticed that they had settings which we commented as &lt;code&gt;secure, private editing&lt;/code&gt;; how does one accomplish this, and what do the settings in question mean?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed one of them was &lt;code&gt;nobackup&lt;/code&gt; which seems to me to mean that you don't create that &lt;code&gt;~&lt;/code&gt; file that always hangs around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: you may want to port this over to the security stackexchange as well, they could probably use it over there.&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2015-12-03T17:03:17.887" Title="How to ensure private secure editing in vim?" Tags="|vimrc|security|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5712" PostTypeId="2" ParentId="5711" CreationDate="2015-12-03T17:03:17.887" Score="2" Body="&lt;p&gt;For each of those options, do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'option'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'nobackup'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-03T17:03:17.887" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5713" PostTypeId="2" ParentId="5546" CreationDate="2015-12-04T06:28:17.330" Score="1" Body="&lt;p&gt;After checking all the plugins, I found the issue due to the &lt;a href=&quot;https://sourceware.org/git/gitweb.cgi?p=systemtap.git;a=tree;f=vim;hb=HEAD&quot; rel=&quot;nofollow&quot;&gt;vim-systemtap&lt;/a&gt; plugin, which &lt;a href=&quot;https://sourceware.org/git/gitweb.cgi?p=systemtap.git;a=blob;f=vim/ftdetect/stp.vim;h=3be1ca0e3d25283ed3d06beba956eee043b2bffc;hb=HEAD&quot; rel=&quot;nofollow&quot;&gt;define an &lt;code&gt;augroup&lt;/code&gt; named &lt;code&gt;filetype&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetype&#xA;  au BufNewFile,BufRead *.stp   set filetype=stp&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that group name would override the event name.&lt;/p&gt;&#xA;" OwnerUserId="1892" LastActivityDate="2015-12-04T06:28:17.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5714" PostTypeId="1" AcceptedAnswerId="5719" CreationDate="2015-12-04T07:44:14.937" Score="1" ViewCount="948" Body="&lt;p&gt;I want to join multiple consecutive blank lines into single blank line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this, I use the following global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^\s*$/,/./-j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this doesn't work in some exceptional cases. For example in the following scenario, 3 blank lines between &quot;c&quot; and &quot;d&quot; are reduced to 2 blank lines instead of 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/S2dKf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S2dKf.png&quot; alt=&quot;Figure 1&quot;&gt;&lt;/a&gt;  &lt;a href=&quot;https://i.stack.imgur.com/m8pNy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/m8pNy.png&quot; alt=&quot;Figure 2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In first figure, line 6 has no space. Line 7 has one space. Line 8 has no space. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does the above command not work in this case?&lt;/p&gt;&#xA;" OwnerUserId="5506" LastEditorUserId="205" LastEditDate="2017-03-08T13:53:31.060" LastActivityDate="2017-03-08T13:53:31.060" Title="Reducing multiple blank lines into single blank line. Exceptional case" Tags="|regular-expression|ex-mode|global-command|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5715" PostTypeId="2" ParentId="5714" CreationDate="2015-12-04T08:05:36.457" Score="0" Body="&lt;p&gt;Your global command is explained in details &lt;a href=&quot;https://vi.stackexchange.com/a/1921/4939&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;g/^\s*$/,/./-j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If I understood the post correctly, I think your problem comes from this part:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;,/./-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It defines the range of lines on which the &lt;code&gt;join&lt;/code&gt; command has to operate.&lt;/p&gt;&#xA;&lt;p&gt;The range begins with the current line (an empty line which can contain whitespace as described by the pattern &lt;code&gt;^\s*$&lt;/code&gt;) and ends one line above the next line containing &lt;strong&gt;any&lt;/strong&gt; character (including a space).&lt;/p&gt;&#xA;&lt;p&gt;So I think that in your example, when the global command &lt;code&gt;g&lt;/code&gt; finds the empty line number 6, the join command &lt;code&gt;j&lt;/code&gt; looks for a line containing any character (&lt;code&gt;/./&lt;/code&gt;) and finds a space on line 7, then goes back one line above (&lt;code&gt;-&lt;/code&gt; ; line 6 again) to determine the final line to collapse. Therefore &lt;code&gt;j&lt;/code&gt; joins the lines between current line 6 and final line 6, which means it doesn't join anything.&lt;/p&gt;&#xA;&lt;p&gt;After that it joins line 7 and 8.&lt;/p&gt;&#xA;&lt;p&gt;If you want the &lt;code&gt;join&lt;/code&gt; command to ignore the space when searching for the last line to collapse, you could replace &lt;code&gt;.&lt;/code&gt; (any character) with &lt;code&gt;\S&lt;/code&gt; (any non whitespace character).&lt;/p&gt;&#xA;&lt;p&gt;It would give:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;g/^\s*$/,/\S/-j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A more readable version of the same command could be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;global/^\s*$/ .,/\S/-1 join&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The dot &lt;code&gt;.&lt;/code&gt; in this last command is used in the range &lt;code&gt;.,/\S/-1&lt;/code&gt; and not in a search pattern, so this time it doesn't stand for any character but for the current line.&lt;br /&gt;&#xA;And &lt;code&gt;.,/\S/-1&lt;/code&gt; is a range like &lt;code&gt;a,b&lt;/code&gt; where &lt;code&gt;a&lt;/code&gt; = &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;=&lt;code&gt;/\S/-1&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It could be read like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;global command (&lt;code&gt;global&lt;/code&gt;), whenever you find an empty line (&lt;code&gt;/^\s*$/&lt;/code&gt;) execute the &lt;code&gt;join&lt;/code&gt; command between the current line (&lt;code&gt;.&lt;/code&gt;) and one line above (&lt;code&gt;-1&lt;/code&gt;) the next line containing no whitespace (&lt;code&gt;/\S/&lt;/code&gt;).&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2015-12-04T13:47:14.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5717" PostTypeId="1" AcceptedAnswerId="5722" CreationDate="2015-12-04T16:39:20.820" Score="1" ViewCount="161" Body="&lt;p&gt;i use neovim and pathogen for managing plugins&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When i just put these settings in my &lt;code&gt;init.vim&lt;/code&gt;, the plugin won't load.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:indentLine_loaded = 1&#xA;let g:indentLine_fileType = ['vim','c', 'cpp']&#xA;let g:indentLine_fileTypeExclude = ['help']&#xA;let g:indentLine_bufNameExclude = ['NERDTree*']&#xA;let g:indentLine_leadingSpaceChar='.'&#xA;let g:indentLine_char = '.'&#xA;let g:indentLine_color_term = 239&#xA;let g:indentLine_showFirstIndentLevel=1&#xA;let g:indentLine_color_tty_dark=1&#xA;let g:indentLine_color_dark = 1&#xA;let g:indentLine_faster = 1&#xA;let g:indentLine_concealcursor=''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when i put those settings with an autocmd in my &lt;code&gt;init.vim&lt;/code&gt;, the plugin works, but only the default settings are loaded. However, when i type after the startup e.g. &lt;code&gt;:h help&lt;/code&gt; the appearance of the indentations do change to the desired result.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * let g:indentLine_loaded = 1&#xA;autocmd VimEnter * let g:indentLine_fileType = ['vim','c', 'cpp']&#xA;autocmd VimEnter * let g:indentLine_fileTypeExclude = ['help']&#xA;autocmd VimEnter * let g:indentLine_bufNameExclude = ['NERDTree*']&#xA;autocmd VimEnter * let g:indentLine_leadingSpaceChar='.'&#xA;autocmd VimEnter * let g:indentLine_char = '.'&#xA;autocmd VimEnter * let g:indentLine_color_term = 239&#xA;autocmd VimEnter * let g:indentLine_showFirstIndentLevel=1&#xA;autocmd VimEnter * let g:indentLine_color_tty_dark=1&#xA;autocmd VimEnter * let g:indentLine_color_dark = 1&#xA;autocmd VimEnter * let g:indentLine_faster = 1&#xA;autocmd VimEnter * let g:indentLine_concealcursor=''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can i make neovim load the indentationLine settings immediately?&lt;/p&gt;&#xA;" OwnerUserId="2354" LastActivityDate="2015-12-04T18:22:45.700" Title="IndentationLine Plugin doesn't get loaded without autocmd; appearance changes from default to desired when opening another window" Tags="|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5718" PostTypeId="1" AcceptedAnswerId="5749" CreationDate="2015-12-04T16:39:58.487" Score="3" ViewCount="637" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/junegunn/vim-easy-align&quot; rel=&quot;nofollow&quot; title=&quot;vim-easy-align&quot;&gt;vim-easy-align&lt;/a&gt; plugin and when in &lt;code&gt;bash&lt;/code&gt; scripts I try to align &lt;code&gt;$&lt;/code&gt; at the beginning of variable names, the aligning adds spaces around the delimiter, i.e. &lt;code&gt;&amp;lt;space&amp;gt;$&amp;lt;space&amp;gt;&lt;/code&gt; which of course makes those variables meaningless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there options or tips to temporarily or permanently disable this? for specific delimiters? That is, to allow spaces around &lt;code&gt;=&lt;/code&gt; and other delimiters, but not the variable leaders such as &lt;code&gt;$&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I make a &lt;code&gt;\$\w&lt;/code&gt; regex instead of just using the &lt;code&gt;$&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2303" LastEditorUserId="24" LastEditDate="2016-10-21T20:50:06.567" LastActivityDate="2016-10-21T20:50:06.567" Title="easy-align spaces around delimiters" Tags="|alignment|plugin-easy-align|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5719" PostTypeId="2" ParentId="5714" CreationDate="2015-12-04T17:03:05.090" Score="7" Body="&lt;h2&gt;Why your command doesn't work&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The simple answer is the &lt;code&gt;.&lt;/code&gt; as the end range for your &lt;code&gt;:j&lt;/code&gt; command will match the space in your offending line. This means that your nearly empty line will not be removed/compressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be solved by searching for &lt;code&gt;\S&lt;/code&gt; (non-whitespace character) instead of &lt;code&gt;.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\s*$/,/\S/-j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;We can do better&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The following command will work with your inconsistent whitespace issues and is much shorter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:v/\S/,//-j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The fully expanded command is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vglobal/\S/ .,/\S/-1join&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Overview&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;For every blank line, &lt;code&gt;:join&lt;/code&gt; the current line with the line above the next non-empty line, &lt;code&gt;\S&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Glory of details&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:v&lt;/code&gt; is short for &lt;code&gt;:vglobal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:v/{pat}/{cmd}&lt;/code&gt; will run &lt;code&gt;{cmd}&lt;/code&gt; on every line &lt;em&gt;not&lt;/em&gt; matching &lt;code&gt;{pat}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\S&lt;/code&gt; will match a non-whitespace character&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:join&lt;/code&gt; (&lt;code&gt;:j&lt;/code&gt; for short) command will join lines together. For this example you can think of it as compressing a block of blank lines into 1 blank line.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;:j&lt;/code&gt; command takes a range. e.g. &lt;code&gt;.,//-&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The range is &lt;code&gt;.,/\S/-1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The start range is the current line, &lt;code&gt;.&lt;/code&gt;. However &lt;code&gt;.&lt;/code&gt; can be assumed so leave it blank.&lt;/li&gt;&#xA;&lt;li&gt;The end of the range is &lt;code&gt;/\S/-1&lt;/code&gt;. Which means find the next line with a non-whitespace character and then use the line right above it (&lt;code&gt;-1&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Since the pattern is the same pattern used in the &lt;code&gt;:v&lt;/code&gt; command we can reuse the pattern. &lt;code&gt;//&lt;/code&gt; is shorthand to reuse the last search pattern.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-1&lt;/code&gt; can be shorted to just &lt;code&gt;-&lt;/code&gt; as the 1 can be assumed&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.,/\S/-1&lt;/code&gt; becomes &lt;code&gt;,//-&lt;/code&gt; after we shorten it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :j&#xA;:h :v&#xA;:h :g&#xA;:h /\S&#xA;:h :range&#xA;:h /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2015-12-04T17:17:32.327" LastActivityDate="2015-12-04T17:17:32.327" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5720" PostTypeId="2" ParentId="509" CreationDate="2015-12-04T17:10:11.830" Score="5" Body="&lt;p&gt;Here are two easy options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;with a block of text selected, type &lt;code&gt;!fmt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;with your cursor at the start of a block, type &lt;code&gt;!}fmt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Both of these send a block of text to unix &lt;code&gt;fmt&lt;/code&gt;, see &lt;code&gt;man fmt&lt;/code&gt; for options. You can pass option arguments from vim. For example, to format a block a 50 characters wide, type &lt;code&gt;!}fmt -w 50&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5526" LastEditorUserId="5526" LastEditDate="2015-12-06T02:22:49.860" LastActivityDate="2015-12-06T02:22:49.860" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5721" PostTypeId="2" ParentId="5677" CreationDate="2015-12-04T17:19:07.187" Score="1" Body="&lt;p&gt;Instead of &lt;code&gt;\t&lt;/code&gt;, you can capture a control character by first typing &lt;code&gt;CTRL-v&lt;/code&gt; followed by the character you want. For sake of this example, let's say that &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; means &quot;press the tab key&quot;, and &lt;code&gt;&amp;lt;RETURN&amp;gt;&lt;/code&gt; means &quot;press the return key&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To capture a tab character in your function definition: &lt;code&gt;CTRL-v&amp;lt;TAB&amp;gt;&lt;/code&gt;. To capture a newline: &lt;code&gt;CTRL-v&amp;lt;RETURN&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5526" LastActivityDate="2015-12-04T17:19:07.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5722" PostTypeId="2" ParentId="5717" CreationDate="2015-12-04T18:22:45.700" Score="3" Body="&lt;p&gt;The problem lies in &lt;code&gt;let g:indentLine_loaded = 1&lt;/code&gt;, which is a pattern used for &lt;em&gt;preventing&lt;/em&gt; loading a given plugin (see  &lt;code&gt;:help write-plugin&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you include it with on your init file it prevents the plugin from loading. On the autocmd it is completely ignored (along your settings), because when the VimEnter event fires after the plugin is already loaded:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VimEnter        After doing all the startup stuff, including&#xA;                loading .vimrc files, executing the &quot;-c cmd&quot;&#xA;                arguments, creating all windows and loading&#xA;                the buffers in them.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-12-04T18:22:45.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5723" PostTypeId="1" AcceptedAnswerId="5726" CreationDate="2015-12-04T23:14:15.723" Score="68" ViewCount="57405" Body="&lt;p&gt;Vi and Vim, as all of you know, have many synonyms. There are three ways I know of to save the file and exit Vim and Vi. These are &lt;em&gt;:wq&lt;/em&gt; &lt;strong&gt;&amp;lt;cr&amp;gt;&lt;/strong&gt;, &lt;em&gt;:x&lt;/em&gt; &lt;strong&gt;&amp;lt;cr&amp;gt;&lt;/strong&gt; and &lt;em&gt;ZZ&lt;/em&gt;. I have heard that these are different in some way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any practical differences between using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;&amp;lt;cr&amp;gt;&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;&amp;lt;cr&amp;gt;&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Z&lt;/kbd&gt;&lt;kbd&gt;Z&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to save file and exit Vim and Vi?&lt;/p&gt;&#xA;" OwnerUserId="3032" LastEditorUserId="2920" LastEditDate="2016-07-11T06:46:08.353" LastActivityDate="2022-12-22T03:11:43.563" Title="What are the differences between :wq&lt;cr&gt; :x&lt;cr&gt; and ZZ when exiting vim?" Tags="|save|filesystem|quit|original-vi|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5724" PostTypeId="1" CreationDate="2015-12-05T00:29:11.477" Score="0" ViewCount="71" Body="&lt;p&gt;Is there a way to search for method definition with some Vim plugin? Suppose there's a method with rather generic name, something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;User user;&#xA;cout &amp;lt;&amp;lt; user.get_name() &amp;lt;&amp;lt; endl;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to jump immediately to &lt;code&gt;User&lt;/code&gt; class without browsing through multiple files that define &lt;code&gt;get_name&lt;/code&gt; method for other classes?&lt;/p&gt;&#xA;" OwnerUserId="5528" LastActivityDate="2015-12-05T00:29:11.477" Title="Searching for method definitions with cscope and ctags (or anything else)" Tags="|ctags|cscope|" AnswerCount="0" CommentCount="2" ClosedDate="2015-12-05T07:10:52.300" ContentLicense="CC BY-SA 3.0" />
  <row Id="5725" PostTypeId="2" ParentId="5714" CreationDate="2015-12-05T00:40:52.183" Score="1" Body="&lt;p&gt;Using substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(\n\s*){2,}/\r\r/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;substitute 2 or more newlines &lt;code&gt;(\n){2,}&lt;/code&gt; with a empty line (&lt;code&gt;\n\n&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; (very magical) was used to simplify the necessity of protections (&lt;code&gt;\{2,\}&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3002" LastActivityDate="2015-12-05T00:40:52.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5726" PostTypeId="2" ParentId="5723" CreationDate="2015-12-05T02:33:26.643" Score="55" Body="&lt;p&gt;From Vim's documentation, &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Ax&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:x&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#ZZ&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;ZZ&lt;/code&gt;&lt;/a&gt; are equivalent; they only save the file if it has been modified, then quit Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Write current file, if modified, and quit (same as &quot;:x&quot;).  &#xA;(Note: If there are several windows for the&#xA;current file, the file is written if it was modified and the window is closed).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Awq&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:wq&lt;/code&gt;&lt;/a&gt; on the other hand writes the file and quits Vim (assuming proper permissions). &lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="11680" LastEditDate="2018-08-11T02:08:13.167" LastActivityDate="2018-08-11T02:08:13.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5727" PostTypeId="1" AcceptedAnswerId="5728" CreationDate="2015-12-05T06:56:24.797" Score="5" ViewCount="1866" Body="&lt;p&gt;Sometimes (I can't reproduce it reliably), after opening a tab, the height of my command line becomes excessively big.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it begins, the buffer displayed in the first newly created tab has only 10 lines. The buffers displayed in the subsequently created tabs have only 3 lines. All the rest is taken by the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found 4 ways to make the command line take only one line again.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Switching to another tab and coming back (&lt;code&gt;gt&lt;/code&gt;, &lt;code&gt;gT&lt;/code&gt;)  &lt;/li&gt;&#xA;&lt;li&gt;Creating a split and closing it (&lt;code&gt;:sp&lt;/code&gt;, &lt;code&gt;:q&lt;/code&gt;)  &lt;/li&gt;&#xA;&lt;li&gt;Maximizing the window (&lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; + &lt;code&gt;_&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Dragging the status line to the bottom of the screen with the mouse&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After that, cycling between the tabs doesn't change the command line height.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as soon as I close one, the command line of the tab which gains the focus becomes high again. I usually hit &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; + &lt;code&gt;_&lt;/code&gt;, which fixes the height until I open or close a tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It only concerns a new tab, or the first tab which gains the focus after closing another one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The value of my &lt;code&gt;'cmdheight'&lt;/code&gt; option is 1, &lt;code&gt;'cmdwinheight'&lt;/code&gt; is 7 and &lt;code&gt;'winheight'&lt;/code&gt; is 999.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I can't find the cause, maybe I will add an autocmd (something like &lt;code&gt;au TabEnter * wincmd _&lt;/code&gt;), but before doing that, is there a way to find what is causing the command line height to be changed when I sometimes open or close a tab ?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-05T07:15:06.873" LastActivityDate="2015-12-05T07:33:44.383" Title="How to find what is causing the command line height to be changed after opening / closing a tab?" Tags="|command-line|vim-windows|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5728" PostTypeId="2" ParentId="5727" CreationDate="2015-12-05T07:33:44.383" Score="4" Body="&lt;p&gt;To find where an option was last set, use &lt;code&gt;:verbose set &amp;lt;option&amp;gt;?&lt;/code&gt;. In this case,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set cmdheight?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :verbose-cmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-12-05T07:33:44.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5729" PostTypeId="1" AcceptedAnswerId="5730" CreationDate="2015-12-05T08:24:06.547" Score="31" ViewCount="3082" Body="&lt;p&gt;I want to see the value of a variable, so I run the command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim displays the results of this command using the &lt;code&gt;--more--&lt;/code&gt; pager.&lt;br&gt;&#xA;How can I search this for a phrase, e.g. &lt;code&gt;html&lt;/code&gt;?&lt;br&gt;&#xA;I've looked the man page for the more pager which says &lt;code&gt;+/&lt;/code&gt; is used for search but it doesn't seem to work, neither does &lt;code&gt;/&lt;/code&gt; as per the less pager.&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2024-03-19T18:43:32.907" Title="How can I perform a search when vim displays content using &quot;more&quot; pager?" Tags="|search|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5730" PostTypeId="2" ParentId="5729" CreationDate="2015-12-05T08:44:32.693" Score="22" Body="&lt;p&gt;This is not the &lt;code&gt;more&lt;/code&gt; pager, this is Vim's internal and minimalistic pager which doesn't have search capabilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you can use the &lt;code&gt;:redir&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @a    redirect output of following commands to register a&#xA;:let         list every current option and its value&#xA;G&amp;lt;CR&amp;gt;        go straight to the end of the listing and make it disappear&#xA;:redir END   stop redirection&#xA;:tabnew      open a new buffer in a new window in a new tab page&#xA;&quot;ap          put from register a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… then use regular Vim commands.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-05T08:44:32.693" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5731" PostTypeId="2" ParentId="5546" CreationDate="2015-12-05T12:33:56.243" Score="7" Body="&lt;p&gt;I looked into the source and I think I found the problem. If you look in the &lt;a href=&quot;https://vimhelp.appspot.com/autocmd.txt.html#:au&quot;&gt;help&lt;/a&gt; (&lt;code&gt;:h :au&lt;/code&gt;) you will see this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au[tocmd] [group] {event} {pat} [nested] {cmd}&#xA;        Add {cmd} to the list of commands that Vim will&#xA;        execute automatically on {event} for a file matching&#xA;        {pat} autocmd-patterns.&#xA;        Vim always adds the {cmd} after existing autocommands,&#xA;        so that the autocommands execute in the order in which&#xA;        they were given.  See autocmd-nested for [nested].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is the &lt;code&gt;[group]&lt;/code&gt; part. Your autocommand from your config was this: &lt;code&gt;au filetype jinja :call Jinja_config()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means your &lt;code&gt;autocmd filetype jinja&lt;/code&gt; will be parsed as an autocommand, belonging to the &lt;strong&gt;filetype&lt;/strong&gt; group, using the &lt;strong&gt;jinja&lt;/strong&gt; event, which does not exist. Therefore you get that error &lt;code&gt;E216: No such event: jinja&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even when using the &lt;code&gt;*&lt;/code&gt; as pattern, this would not work as expected, because the &lt;code&gt;*&lt;/code&gt; would be parsed as meaning &lt;strong&gt;all available events&lt;/strong&gt; and the pattern would then be parsed as the first part of your command, which is obviously wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest opening an issue at the plugins page, that defines that &lt;code&gt;augroup filetype&lt;/code&gt; as this will cause trouble.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-12-05T12:33:56.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5732" PostTypeId="1" AcceptedAnswerId="5736" CreationDate="2015-12-05T22:20:46.837" Score="8" ViewCount="6192" Body="&lt;p&gt;When using &lt;em&gt;gVim&lt;/em&gt; on &lt;em&gt;Windows 7&lt;/em&gt; I cannot use &lt;strong&gt;^]&lt;/strong&gt; (&lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;]&lt;/kbd&gt;) to jump to tags as described in the &lt;em&gt;Vim&lt;/em&gt; documentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-LeftMouse&amp;gt;                   *&amp;lt;C-LeftMouse&amp;gt;* *CTRL-]*&#xA;CTRL-]      Jump to the definition of the keyword under the&#xA;            cursor.  Same as &quot;:tag {ident}&quot;, where {ident} is the&#xA;            keyword under or after cursor.&#xA;            When there are several matching tags for {ident}, jump&#xA;            to the [count] one.  When no [count] is given the&#xA;            first one is jumped to. See |tag-matchlist| for&#xA;            jumping to other matching tags.&#xA;            {Vi: identifier after the cursor}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This used to bother me a lot when learning &lt;em&gt;Vim&lt;/em&gt;. In the end I managed to solve it by using this hacky mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;t :tag &amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which allowed me to jump to tags using &lt;code&gt;\t&lt;/code&gt; (I used the default setting of &lt;code&gt;\&lt;/code&gt; as&lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not a problem for me anymore as I now only use &lt;em&gt;gnu/linux&lt;/em&gt; for programming and I have already read pretty much all help there is to read. But considering that this contributed to making my experience learning &lt;em&gt;Vim&lt;/em&gt; so much worse I ask here to get this solved for people who are in the same situation I was in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why doesn't &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;]&lt;/kbd&gt; work for me on &lt;em&gt;Windows 7&lt;/em&gt; and how can it be fixed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: The title has been edited with the information that this problem is caused by the keyboard layout I used.&lt;/p&gt;&#xA;" OwnerUserId="3032" LastEditorUserId="3032" LastEditDate="2015-12-06T10:14:13.020" LastActivityDate="2015-12-06T20:36:23.737" Title="Tag navigation using CTRL+] does not work with Non English keyboard on Windows" Tags="|cursor-movement|microsoft-windows|tags|jumplist|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5733" PostTypeId="2" ParentId="5732" CreationDate="2015-12-05T22:53:07.660" Score="2" Body="&lt;p&gt;I just found out why I had this problem.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The cause of the problem&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The problem is that I used a Non-English keyboard layout on my Windows 7 computer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The backslash character is entered using &lt;kbd&gt;Alt Gr&lt;/kbd&gt;+&lt;kbd&gt;9&lt;/kbd&gt; on my Non-English keyboard layout. This leads to that &lt;strong&gt;^]&lt;/strong&gt; would be entered using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Alt Gr&lt;/kbd&gt;+&lt;kbd&gt;9&lt;/kbd&gt;. This simply does not work within &lt;em&gt;Vim&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not know why that is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The problem could be in hardware. Maybe the problem is caused by limited keyboard ghosting (but I have the same problem with a keyboard that is supposed to be able to register 6 keys at once).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The problem could be in software. Vim maybe was not programmed with this in mind.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would appreciate if someone else who uses a Non-English keyboard could comment on if &lt;strong&gt;^]&lt;/strong&gt; works as it should on their machine.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The solution&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The problem is fixed by simply changing to an English keyboard layout. Unfortunately I have found no other solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you have to use an English layout instead. &lt;em&gt;Vim&lt;/em&gt;'s user interface is also designed with an English keyboard layout in mind. Using an English keyboard layout is also advantageous in programming because characters like &lt;code&gt;[&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt; that are frequently used in programming become easier to reach (no &lt;kbd&gt;Alt Gr&lt;/kbd&gt; stretch). So switching can even make your life more comfortable!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem will be about entering characters in your main language. Then you have to resort to using &lt;strong&gt;digraphs&lt;/strong&gt; (see &lt;code&gt;:help digraphs&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to solve it this problem would be to use this hacky mapping that was mentioned in the question:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;t :tag &amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which allows the user to jump to a tag with &lt;code&gt;\t&lt;/code&gt; (if &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; is set to &lt;code&gt;\&lt;/code&gt; as it is by default).&lt;/p&gt;&#xA;" OwnerUserId="3032" LastEditorUserId="3032" LastEditDate="2015-12-06T14:07:47.233" LastActivityDate="2015-12-06T14:07:47.233" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5734" PostTypeId="1" CreationDate="2015-12-06T02:49:42.377" Score="11" ViewCount="8164" Body="&lt;p&gt;I'd like to use YouCompleteMe with C++ semantic completion, but after hours of trying, I can't find why it doesn't work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything seems to be working but I can't complete function parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running Vim on Archlinux (Gnome Terminal on Openbox):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Linux Arch-PC 4.2.5-1-ARCH #1 SMP PREEMPT Tue Oct 27 08:13:28 CET 2015 x86_64 GNU/Linux&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I installed YCM following the instructions (with the &lt;code&gt;install.py&lt;/code&gt; script and clang support). I also tried with AUR YCM package and got the same issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;YcmDebugInfo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Printing YouCompleteMe debug information...&#xA;-- Server has Clang support compiled in: True&#xA;-- Clang version: clang version 3.7.0 (tags/RELEASE_370/final)&#xA;-- Flags for /home/arthur/vimtest/main.cpp loaded from /home/arthur/vimtest/.ycm&#xA;_extra_conf.py:&#xA;-- ['-x', 'c++', '-Wall', '-isystem', '/home/arthur/.vim/bundle/YouCompleteMe/th&#xA;ird_party/ycmd/ycmd/../clang_includes']&#xA;-- Server running at: http://127.0.0.1:54555&#xA;-- Server process ID: 11520&#xA;-- Server logfiles:&#xA;--   /tmp/ycm_temp/server_54555_stdout.log&#xA;--   /tmp/ycm_temp/server_54555_stderr.log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's what appears on screen when trying to complete: &lt;a href=&quot;https://i.stack.imgur.com/W3D8A.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/W3D8A.jpg&quot; alt=&quot;YCM issue&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used YCM-Generator for the &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I just missing something stupid due to my lack of Vim knowledge? Seems to be something like bad keyboard shortcuts mapping... but can't figure out what's wrong exactly. This is my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;    &quot; let Vundle manage Vundle, required&#xA;    Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;    Plugin 'scrooloose/nerdtree'&#xA;    Plugin 'mbbill/undotree'&#xA;    Plugin 'majutsushi/tagbar'&#xA;    Plugin 'bling/vim-airline'&#xA;    Plugin 'tpope/vim-fugitive'&#xA;    Plugin 'vim-scripts/c.vim'&#xA;    Plugin 'Valloric/YouCompleteMe'&#xA;    Plugin 'sjl/badwolf'        &#xA;    Plugin 'rdnetto/YCM-Generator'&#xA;&#xA;call vundle#end()            &quot; required&#xA;filetype plugin on    &quot; required&#xA;&#xA;&quot;Settings&#xA;set tabstop=4&#xA;set softtabstop=4&#xA;set shiftwidth=4&#xA;set expandtab&#xA;set smartindent&#xA;set autoindent&#xA;set backspace=indent,eol,start&#xA;set background=dark &#xA;set shiftround&#xA;set ignorecase&#xA;set showmode&#xA;set ruler&#xA;set showcmd&#xA;set mouse=a&#xA;au BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) | exe &quot;normal! g'\&quot;&quot; | endif&#xA;&#xA;&quot;Plugins Settings :&#xA;    &quot;badwolf&#xA;        colorscheme badwolf&#xA;    &quot;YCM :&#xA;        let g:ycm_collect_identifiers_from_tags_files = 1&#xA;    &quot;airline :&#xA;        set laststatus=2&#xA;        let g:airline_powerline_fonts = 1&#xA;&#xA;&#xA;&#xA;&#xA;&quot;Shortcuts&#xA;    nnoremap &amp;lt;F3&amp;gt;  :UndotreeToggle&amp;lt;cr&amp;gt; &#xA;    nnoremap &amp;lt;F4&amp;gt;  :TagbarToggle&amp;lt;cr&amp;gt; &#xA;    nnoremap &amp;lt;F2&amp;gt;  :NERDTreeToggle&amp;lt;cr&amp;gt; &#xA;&#xA;&#xA;syn on&#xA;set nu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help!&lt;/p&gt;&#xA;" OwnerUserId="5546" LastEditorUserId="5546" LastEditDate="2016-01-26T04:10:53.653" LastActivityDate="2016-01-26T04:10:53.653" Title="Why doesn't YouCompleteMe complete function paramters?" Tags="|vimrc|autocompletion|filetype-c++|plugin-you-complete-me|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5735" PostTypeId="1" AcceptedAnswerId="5799" CreationDate="2015-12-06T06:36:31.937" Score="3" ViewCount="465" Body="&lt;p&gt;I'm just starting to learn Vim-LaTeX, and there are a couple things that bug me. First, I would like to suppress all standard output to the command line when I compile using &lt;code&gt;\ll&lt;/code&gt;, but I would still like errors to show up in the quick-fix window. Also, Vim prompts me to press Enter after compilation with &lt;code&gt;\ll&lt;/code&gt; and after viewing with &lt;code&gt;\lv&lt;/code&gt;, both of which I would like to skip and always go immediately back to Vim as soon as compilation is done or the pdf is opened. I can suppress all output using a line like this in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Tex_CompileRule_pdf = 'pdflatex -interaction=nonstopmode $* &amp;gt;/dev/null'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but then if there's an error it doens't tell me. Any thoughts or advice would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5043" LastEditorUserId="21" LastEditDate="2015-12-06T16:51:25.217" LastActivityDate="2015-12-11T03:47:18.317" Title="Suppressing standard output during compilation in vim-latex" Tags="|plugin-vim-latex|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="5736" PostTypeId="2" ParentId="5732" CreationDate="2015-12-06T12:28:15.600" Score="12" Body="&lt;p&gt;Say hello to knowledge fragmentation: &lt;a href=&quot;https://stackoverflow.com/q/6932702/520162&quot;&gt;https://stackoverflow.com/q/6932702/520162&lt;/a&gt; This question was already asked and answered on StackOverflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The key is to  press &lt;kbd&gt;CTRL&lt;/kbd&gt; and the key that is located where the &lt;kbd&gt;]&lt;/kbd&gt; lives on the US keyboard&lt;/strong&gt;. I had the issue with a QUERTZ German keyboard and have to press &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;+&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Compare: US keyboard:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/53fZv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/53fZv.png&quot; alt=&quot;US keyboard&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;German keyboard:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/hhRpq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hhRpq.png&quot; alt=&quot;German keyboard&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another obvious way would be to simply remap the functionality to a different keystroke. Since you want to g&lt;strong&gt;o&lt;/strong&gt; t&lt;strong&gt;o&lt;/strong&gt; the tag under the cursor, you could use &lt;kbd&gt;o&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt; for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map oo &amp;lt;C-]&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1041" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-12-06T20:36:23.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5737" PostTypeId="1" AcceptedAnswerId="5738" CreationDate="2015-12-06T15:35:13.237" Score="7" ViewCount="2506" Body="&lt;p&gt;basically i want to test within my vimrc, if &lt;code&gt;/home/$USER/.dotfiles/nvim/bundle/vim-snippets/snippets&lt;/code&gt; was symlinked to &lt;code&gt;/home/$USER/.dotfiles/nvim/snippets&lt;/code&gt;&#xA;If not, it should create the symlink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;the code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au VimEnter * :!bash -c &quot;! [  -L /home/$USER/.dotfiles/nvim/snippets  ] &amp;amp;&amp;amp; ln -sb /home/$USER/.dotfiles/nvim/bundle/vim-snippets/snippets /home/$USER/.dotfiles/nvim/snippets&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&quot;:&quot;&lt;/code&gt; before &lt;code&gt;!bash&lt;/code&gt; doesn't change anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;the error message:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing VimEnter Auto commands for &quot;*&quot;:                                                                                              &#xA;E34: No previous command  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is, i don't know what is wrong with my code and google/help pages also aren't very helpful.&lt;/p&gt;&#xA;" OwnerUserId="2354" LastActivityDate="2020-06-24T21:16:23.243" Title="Trouble to call a bash command from vimrc with autocommands | &quot;Error: no previous command&quot; (neovim)" Tags="|autocmd|neovim|bash|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5738" PostTypeId="2" ParentId="5737" CreationDate="2015-12-06T15:49:44.233" Score="7" Body="&lt;p&gt;&lt;code&gt;!&lt;/code&gt; has to be escaped which can be done with a backslash &lt;code&gt;\!&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I think the problem comes from the second bang in your command which has a special meaning for vim. It is automatically replaced with the previous external command.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Any '!' in {cmd} is replaced with the previous          external command&#xA;(see also 'cpoptions').  But not when             there is a backslash before&#xA;the '!', then that            backslash is removed.  Example: &amp;quot;:!ls&amp;quot; followed&#xA;by            &amp;quot;:!echo ! ! \!&amp;quot; executes &amp;quot;echo ls ! !&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;And since the autocommand is triggered by the &lt;code&gt;VimEnter&lt;/code&gt; event, which means as soon as vim is launched, there can't be any previous external command.&lt;/p&gt;&#xA;&lt;p&gt;You should probably escape the second bang to protect it from being interpreted by vim before the command is sent to the shell :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;au VimEnter * :!bash -c &amp;quot;\! [  -L /home/$USER/.dotfiles/nvim/snippets  ] &amp;amp;&amp;amp; ln -sb /home/$USER/.dotfiles/nvim/bundle/vim-snippets/snippets /home/$USER/.dotfiles/nvim/snippets&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For more information, see &lt;code&gt;:help :!&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="13656" LastEditDate="2020-06-24T21:16:23.243" LastActivityDate="2020-06-24T21:16:23.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5739" PostTypeId="1" AcceptedAnswerId="5740" CreationDate="2015-12-06T18:03:55.250" Score="4" ViewCount="2068" Body="&lt;p&gt;I would like to know how to generate ctags and find them with auto-complete plugins for new libraries that I install in order to 1) auto-complete for 3rd party library namespaces, classes, etc. and 2) not have my syntax checking plugin think I have undefined references. In order to generate tags for my own new projects, I use this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-F12&amp;gt; :!ctags -R --sort=yes --c++-kinds=+pl --fields=+iaSl --extra=+q .&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how do I adapt this to new libraries in my system? I have tried going to a library's include directory, run the above command, and then set the ctag path to find the tags file, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set tags+=/usr/include/pcl-1.7/pcl/tags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then it seems that the tags are not found. I use the YouCompleteMe and I have the collect_identifiers parameter set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_collect_identifiers_from_tags_files = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I enable ctags to find them? I can using Exuberant Ctags 5.9 and VIM 7.4.&lt;/p&gt;&#xA;" OwnerUserId="5552" LastActivityDate="2015-12-06T20:49:47.623" Title="Adding ctags for a 3rd party library" Tags="|autocompletion|tags|ctags|plugin-you-complete-me|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5740" PostTypeId="2" ParentId="5739" CreationDate="2015-12-06T20:49:47.623" Score="5" Body="&lt;p&gt;You could use this to tell Vim to look recursively for &lt;code&gt;tags&lt;/code&gt; files under &lt;code&gt;/usr/include/&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tags+=/usr/include/**/tags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the generation part, I'm afraid you will still have to generate &lt;code&gt;tags&lt;/code&gt; files manually for each new library… or write a shell script.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;By the way, Vim comes with what it calls &quot;include-search&quot;; you will probably find the following help sections interesting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help include-search&#xA;:help definition-search&#xA;:help 'include'&#xA;:help 'define'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-06T20:49:47.623" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5741" PostTypeId="1" AcceptedAnswerId="5742" CreationDate="2015-12-07T00:17:51.443" Score="9" ViewCount="404" Body="&lt;p&gt;I want to open a terminal buffer in a vertical split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If i try &lt;code&gt;:vertical split terminal&lt;/code&gt; I get a buffer named 'terminal', not a terminal buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently learned I could do &lt;code&gt;:vertical split +terminal&lt;/code&gt; to open a terminal buffer, but I have not been able to find the help docs explaining what the + is doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does the '+' mean, is it specific to terminal buffers or is it a more generic thing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also just realized I can do &lt;code&gt;:vertical split | terminal&lt;/code&gt; to get the same behavior (at least I think its the same).&lt;/p&gt;&#xA;" OwnerUserId="1472" LastActivityDate="2015-12-07T00:25:57.207" Title="What does the '+' symbol mean when opening a buffer?" Tags="|buffers|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5742" PostTypeId="2" ParentId="5741" CreationDate="2015-12-07T00:25:57.207" Score="10" Body="&lt;p&gt;Should have looked a bit harder before asking, I found my answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help +cmd&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *+cmd* *[+cmd]*&#xA;The [+cmd] argument can be used to position the cursor in the newly opened&#xA;file, or execute any other command:&#xA;    +       Start at the last line.&#xA;    +{num}      Start at line {num}.&#xA;    +/{pat}     Start at first line containing {pat}.&#xA;    +{command}  Execute {command} after opening the new file.&#xA;                {command} is any Ex command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1472" LastActivityDate="2015-12-07T00:25:57.207" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5743" PostTypeId="1" CreationDate="2015-12-07T02:21:26.843" Score="2" ViewCount="68" Body="&lt;p&gt;I use solarized for my terminal color. When I first create a new tex file and begin writing, I get the plaintex colorscheme, which I like. But once I save and reopen, I get the tex colorscheme, which seems lacking. I can use &quot;set filetype=tex&quot; to get the color back, but I cannot get it to run from the tex.vim file. I'm sure there's a better way to get the coloring I want.&lt;/p&gt;&#xA;" OwnerUserId="5554" LastActivityDate="2015-12-07T02:21:26.843" Title="How can I set tex filetypes to use plaintex solarized coloring" Tags="|terminal|filetype-tex|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5744" PostTypeId="1" AcceptedAnswerId="5745" CreationDate="2015-12-07T03:34:02.007" Score="7" ViewCount="687" Body="&lt;p&gt;Is there an easy way to add text to the left margin of a vim document (to the left of the line numbers)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that it is possible to do because plugins such as vim-signature do it, but I am curious how this is done, and what the easiest way to do it would be.&lt;/p&gt;&#xA;" OwnerUserId="3217" LastActivityDate="2015-12-07T08:17:23.327" Title="Adding text to the left margin" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5745" PostTypeId="2" ParentId="5744" CreationDate="2015-12-07T04:40:33.420" Score="10" Body="&lt;p&gt;I think what you are referring to is called a sign by vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding a sign seems to be a two-step process. First you define what it looks like, then you place it where you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic syntax to define a sign is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sign define {name} {argument}...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;{argument}...&lt;/code&gt; is a series of arguments that you can choose :  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;icon=&lt;/code&gt; full path to an icon&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;linehl=&lt;/code&gt; highlighting group for the whole line on which you will place the sign   &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;text=&lt;/code&gt; text to display if there's no icon or you run vim in a terminal  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;texthl=&lt;/code&gt; highlighting group for &lt;code&gt;text&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To place your sign, once you've defined it :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sign place {id} line={lnum} name={name} file={fname}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;{id}&lt;/code&gt; is an arbitrary number which will allow you to manipulate the sign later&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;{lnum}&lt;/code&gt; and &lt;code&gt;{fname}&lt;/code&gt; are respectively the line number and the file in which you want to place your sign&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;{name}&lt;/code&gt; is the name of your sign&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To list your signs and see their attributes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sign list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To remove a sign :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sign unplace {id} file={fname}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Usage example&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sign define mysign text=&amp;gt;&amp;gt; texthl=Search&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... defines the sign &lt;code&gt;mysign&lt;/code&gt;, which will display the text &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; with the colors from the highlighting group &lt;code&gt;Search&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, assuming you're editing the file &lt;code&gt;/tmp/foo&lt;/code&gt;, you can place your sign on its 10th line with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sign place 9999 line=10 name=mysign file=/tmp/foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the id 9999 was chosen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, to remove the sign you just placed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sign unplace 9999 file=/tmp/foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are many other ways to define, place and unplace a sign.&lt;br&gt;&#xA;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help sign-commands&#xA;:help :sign-define&#xA;:help :sign-undefine&#xA;:help :sign-list&#xA;:help :sign-place&#xA;:help :sign-unplace&#xA;:help :sign-place-list&#xA;:help :sign-jump&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-07T08:17:23.327" LastActivityDate="2015-12-07T08:17:23.327" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5746" PostTypeId="1" CreationDate="2015-12-07T05:49:00.443" Score="4" ViewCount="473" Body="&lt;p&gt;I want all trailing whitespace in the buffers I'm editing to be highlighted in red.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the autocommand I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter,WinEnter * call matchadd('Error', '\v\s+$', -1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;matchadd()&lt;/code&gt; function looks for the pattern &lt;code&gt;'\v\s+$'&lt;/code&gt; which describes trailing whitespace, and changes its color with the highlighting group &lt;code&gt;Error&lt;/code&gt; and a &lt;code&gt;-1&lt;/code&gt; priority (so that &lt;code&gt;'hlsearch'&lt;/code&gt; whose priority is 0 can override it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to modify it so that the command is not executed in a help file. I've come up with this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter,WinEnter * if &amp;amp;filetype !=? &quot;help&quot;&#xA;            \ | call matchadd('Error', '\v\s+$', -1)&#xA;            \ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, trailing whitespace is still colored in red even in a help file. For example, in &lt;code&gt;:help 'relativenumber'&lt;/code&gt; below the line :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;See hl-LineNr  and hl-CursorLineNr for the highlighting used for&#xA;    the number.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;... I see a red tab character on an empty line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've commented the autocommand, and tested the following command in various buffers (help and non help) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;filetype !=? &quot;help&quot; | call matchadd('Error', '\v\s+$', -1) | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works as expected :&lt;br&gt;&#xA;trailing whitespace in red in a non help file, trailing whitespace uncolored in a help file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to modify the autocommand so that the &lt;code&gt;matchadd()&lt;/code&gt; function is not called in a help file ?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-07T06:59:14.413" LastActivityDate="2016-01-23T09:09:04.800" Title="How to test filetype in an autocommand without using the FileType event?" Tags="|autocmd|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5747" PostTypeId="2" ParentId="2047" CreationDate="2015-12-07T07:14:15.680" Score="41" Body="&lt;p&gt;I will not provide an in-depth comparison, as I only have limited experience with the different plugins. I know a couple of plugins well (&lt;a href=&quot;https://github.com/LaTeX-Box-Team/LaTeX-Box/&quot; rel=&quot;noreferrer&quot;&gt;LaTeX-Box&lt;/a&gt; and &lt;a href=&quot;http://vim-latex.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;LaTeX-Suite&lt;/a&gt;), and I know one plugin very well, since I am developing it myself: &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;noreferrer&quot;&gt;vimtex&lt;/a&gt;. Thus, I will mostly write about vimtex. However, I will first point out some references that might be of interest to others.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Some overview and references&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;There are &lt;em&gt;alot&lt;/em&gt; of plugins for Vim. These are the ones I've recognized as being at least semi popular:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim-latex.sourceforge.net&quot; rel=&quot;noreferrer&quot;&gt;LaTeX-Suite&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/LaTeX-Box-Team/LaTeX-Box&quot; rel=&quot;noreferrer&quot;&gt;LaTeX-Box&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;noreferrer&quot;&gt;vimtex&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://atp-vim.sourceforge.net&quot; rel=&quot;noreferrer&quot;&gt;AutomaticTexPlugin&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/xuhdev/vim-latex-live-preview&quot; rel=&quot;noreferrer&quot;&gt;vim-latex-live-preview&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On &lt;a href=&quot;https://tex.stackexchange.com&quot;&gt;tex.stackexchange.com&lt;/a&gt;, there is a &lt;a href=&quot;https://tex.stackexchange.com/questions/339/latex-editors-ides&quot;&gt;huge list&lt;/a&gt; of LaTeX editors and IDEs. It gives a nice overview in general, but it also provides some overview of plugins for Vim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://tex.stackexchange.com/a/148473&quot;&gt;Vim with LaTeX-Box&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://tex.stackexchange.com/a/394&quot;&gt;Vim with LaTeX-Suite&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://tex.stackexchange.com/a/5370&quot;&gt;Vim with Snipmate and rubber&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://tex.stackexchange.com/a/252555&quot;&gt;Vim with vimtex&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;vimtex&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;vimtex is based on LaTeX-Box. It started out after I had contributed bug fixes and updates to LaTeX-Box for some time. I realized that the plugin could be written in a much more modern way if I wrote it from scratch. I first stripped most features and built a more robust and modular &quot;engine&quot;. I then added features, and I think today it has most of the features of LaTeX-Box and then some.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of giving a full list of features (see &lt;a href=&quot;https://github.com/lervag/vimtex#features&quot; rel=&quot;noreferrer&quot;&gt;instead here for that&lt;/a&gt;), I will rather try to point out some of the differences between vimtex and other plugins. However, I want to provide some bold claims:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vimtex is the &lt;em&gt;most modern&lt;/em&gt; Vim plugin for LaTeX available today&lt;/li&gt;&#xA;&lt;li&gt;The code is &lt;em&gt;high quality&lt;/em&gt; and it is currently being &lt;a href=&quot;https://github.com/lervag/vimtex/issues&quot; rel=&quot;noreferrer&quot;&gt;actively maintained&lt;/a&gt; by myself&lt;/li&gt;&#xA;&lt;li&gt;The plugin is mostly stable, even though some features are still being developed (and as such may be subject to change and updates)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;vimtex vs LaTeX-Box&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Since vimtex is based on LaTeX-Box, it obviously has similar principles. The idea is to keep things simple and to solve problems thare are not already solved by other, better plugins. It utilizes &lt;a href=&quot;https://www.ctan.org/pkg/latexmk/&quot; rel=&quot;noreferrer&quot;&gt;latexmk&lt;/a&gt; to compile the LaTeX documents, and it builds upon the internal Vim plugin for syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is currently one important feature in LaTeX-Box that is missing in vimtex: Single-shot compilation &lt;em&gt;with callback&lt;/em&gt;. The reason that this feature is not in vimtex is simply because it is complicated, and that I never found a way to implement it that is simple enough for my own preference (suggestions are welcome, please don't hesitate to open issues or pull requests).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;vimtex vs LaTeX-Suite&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The main difference between vimtex and LaTeX-Suite is probably that vimtex does not try to implement a full fledged IDE for LaTeX inside Vim. E.g.:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vimtex does not provide a full snippet feature, because this is better handled by &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;noreferrer&quot;&gt;UltiSnips&lt;/a&gt; or &lt;a href=&quot;https://github.com/Shougo/neosnippet.vim&quot; rel=&quot;noreferrer&quot;&gt;neosnippet&lt;/a&gt; or similar snippet engines.&lt;/li&gt;&#xA;&lt;li&gt;vimtex builds upon Vim principles: It provides text objects for environments, inline math, it provides motions for sections and paragraphs&lt;/li&gt;&#xA;&lt;li&gt;vimtex uses &lt;code&gt;latexmk&lt;/code&gt; for compilation with a callback feature to get instant feedback on compilation errors&lt;/li&gt;&#xA;&lt;li&gt;vimtex is very modular: if you don't like a feature, you can turn it off.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21" LastEditorUserId="-1" LastEditDate="2017-04-13T12:34:32.317" LastActivityDate="2015-12-07T07:14:15.680" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5749" PostTypeId="2" ParentId="5718" CreationDate="2015-12-07T17:15:35.430" Score="2" Body="&lt;p&gt;FileType solution, just for reference to whoever can use it....&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;---- Easy Align ---- {{{&#xA;xmap ga &amp;lt;Plug&amp;gt;(EasyAlign)&#xA;nmap ga &amp;lt;Plug&amp;gt;(EasyAlign)&#xA;&#xA;augroup FileType sh,perl&#xA;  let g:easy_align_delimiters = {&#xA;      \ 's': {&#xA;      \     'pattern':       '\$',&#xA;      \     'ignore_groups': ['Comment'],&#xA;      \     'left_margin':   0,&#xA;      \     'right_margin':  0,&#xA;      \     'indentation':   'shallow',&#xA;      \     'stick_to_left': 0&#xA;      \     },&#xA;      \ '=': {&#xA;      \     'pattern':       '=',&#xA;      \     'ignore_groups': ['Comment'],&#xA;      \     'left_margin':   0,&#xA;      \     'right_margin':  0,&#xA;      \     'indentation':   'deep',&#xA;      \     'stick_to_left': 0&#xA;      \     }&#xA;  \}&#xA;  augroup END&#xA;&quot;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2303" LastActivityDate="2015-12-07T17:15:35.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5750" PostTypeId="1" AcceptedAnswerId="5751" CreationDate="2015-12-07T19:06:46.687" Score="11" ViewCount="3811" Body="&lt;p&gt;I know that gv reselects the last visual selection. This is great and I use it frequently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But sometimes I want to do something related but different: from the current cursor position, select a block in the same shape as the prior visual selection, but &lt;em&gt;positioned&lt;/em&gt; where the cursor is now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, I often have this desire when pasting a chunk of text and then wanting to do some sort of substitution or transformation to it. So this command would let me reselect what I just pasted. (For that reason, also useful would be a command to &quot;visually select last paste,&quot; but there are nonetheless other instances where what I literally want is &quot;reselect last visual shape irrespective of whether that reselects the last paste.&quot; &lt;strong&gt;EDIT: Please see &lt;a href=&quot;https://vi.stackexchange.com/questions/5770/is-there-a-way-to-reselect-the-last-pasted-text-rather-than-the-last-actual-sel&quot;&gt;Is there a way to reselect the last pasted text, rather than the last actual selection, starting at the current cursor position?&lt;/a&gt; for this question&lt;/strong&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note: if there is not a built-in way to do this, I'm comfortable editing ~/.vim to add a vimscript example [and possibly modify it] and bind this to an easy key combination, but writing one from scratch to do this is beyond my present ability.)&lt;/p&gt;&#xA;" OwnerUserId="4985" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-12-08T18:31:04.107" Title="Is there a way to reselect the last visual shape, rather than the last actual selection, starting at the current cursor position?" Tags="|visual-mode|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5751" PostTypeId="2" ParentId="5750" CreationDate="2015-12-07T19:39:59.283" Score="7" Body="&lt;p&gt;This is a simple remap that allows you to re-select last pasted (or changed) text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap gV `[v`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From comments in original post, perhaps you want to save the coordinates of the last change/paste &lt;em&gt;before&lt;/em&gt; other/further changes, and restore &lt;em&gt;that&lt;/em&gt; visual selection?&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-12-07T19:55:29.317" LastActivityDate="2015-12-07T19:55:29.317" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5752" PostTypeId="2" ParentId="5638" CreationDate="2015-12-07T22:13:20.247" Score="1" Body="&lt;p&gt;Upon seeing your comment that the parentheses were actually matched but there was a lot of intervening macros, it is possible that there is a synchronization issue -- does&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn sync fromstart&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;alleviate your problem?&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-12-07T22:13:20.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5753" PostTypeId="1" AcceptedAnswerId="11895" CreationDate="2015-12-08T02:19:22.910" Score="5" ViewCount="3653" Body="&lt;p&gt;I often find myself accidentally pressing &lt;code&gt;&amp;lt;c-e&amp;gt;&lt;/code&gt;/&lt;code&gt;^E&lt;/code&gt; while in normal mode inside a terminal buffer. This causes the terminal buffer to scroll down and a line with a &lt;code&gt;~&lt;/code&gt; is displayed, like when your file doesn't reach the bottom of the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've created a mapping that stops &lt;code&gt;^E&lt;/code&gt; from being called if the current buffer is a terminal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ^E :call ScrollStop()&amp;lt;cr&amp;gt;&#xA;function! ScrollStop()&#xA;  if &amp;amp;buftype !=# &quot;terminal&quot;&#xA;    normal! ^E&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would now like to do the same thing for &lt;code&gt;^Y&lt;/code&gt; by extending the function to allow me to pass in either &lt;code&gt;^E&lt;/code&gt; or &lt;code&gt;^Y&lt;/code&gt; but all my attempts so far have caused various errors, mainly &lt;code&gt;E119: Not enough arguments for function: ScrollStop&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Thanks to the comments by @GaryJohn we've narrowed the problem down.  If we have the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyScroll(key)&#xA;   exe 'normal' a:key&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and we call it via &lt;code&gt;:call MyScroll('^E')&lt;/code&gt; where &lt;code&gt;^E&lt;/code&gt; is entered via ctrl-v + crtl-e then we get the expected result, the buffer scrolls down one line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If however we create a mapping &lt;code&gt;:nnoremap ^E :call MyScroll('^E')&amp;lt;cr&amp;gt;&lt;/code&gt; then press &lt;code&gt;^E&lt;/code&gt;, we get an error &lt;code&gt;E471: Argument required: normal&lt;/code&gt;. This happens for both Vim and Neovim.  &lt;/p&gt;&#xA;" OwnerUserId="1472" LastEditorUserId="1472" LastEditDate="2017-03-28T03:38:31.920" LastActivityDate="2017-11-21T11:40:57.543" Title="How to pass control characters, e.g. &lt;c-e&gt; to a function in a mapping?" Tags="|vimscript|functions|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5754" PostTypeId="2" ParentId="5750" CreationDate="2015-12-08T05:20:28.563" Score="6" Body="&lt;p&gt;To reselect the old shape, you can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1v&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5568" LastActivityDate="2015-12-08T05:20:28.563" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5755" PostTypeId="1" AcceptedAnswerId="5756" CreationDate="2015-12-08T08:09:07.170" Score="4" ViewCount="351" Body="&lt;p&gt;I want to indent lines in each paragraph except the first one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By paragraph, I mean a group of lines that are separated from other groups of lines by at least one blank line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, here we have three paragraphs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;paragraph1&#xA;line1.1&#xA;&#xA;paragraph2&#xA;line2.1&#xA;line2.2&#xA;&#xA;paragraph3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to indent all the lines except the first one in each paragraph. To do this, I use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^\w\+/+1,/^\s*$/&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that this command indents every line progressively. The result is as here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;paragraph1&#xA;    line1.1&#xA;&#xA;paragraph2&#xA;    line2.1&#xA;        line2.2&#xA;&#xA;paragraph3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;line2.2&lt;/code&gt; is indented twice. I guess this occurs because global command matches all lines first with the regex &lt;code&gt;^\w\+&lt;/code&gt;, then it applies the command &lt;code&gt;+1,/^\s*$/&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I produce the following output?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;paragraph1&#xA;    line1.1&#xA;&#xA;paragraph2&#xA;    line2.1&#xA;    line2.2&#xA;&#xA;paragraph3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5506" LastActivityDate="2015-12-08T08:26:00.273" Title="Indenting lines in each paragraph except the first one using global command" Tags="|regular-expression|global-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5756" PostTypeId="2" ParentId="5755" CreationDate="2015-12-08T08:26:00.273" Score="2" Body="&lt;p&gt;If you don't mind the error message (of the the &lt;code&gt;+1&lt;/code&gt; going past the last line), just doing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\w/ +&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works. Since the pattern for &lt;code&gt;:global&lt;/code&gt; matches all the lines below &lt;code&gt;paragraph2&lt;/code&gt; anyway, there is no need to give range to &lt;code&gt;:&amp;gt;&lt;/code&gt; at all (besides the &lt;code&gt;+1&lt;/code&gt; to skip the first).&lt;/p&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2015-12-08T08:26:00.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5757" PostTypeId="1" AcceptedAnswerId="5758" CreationDate="2015-12-08T11:37:06.683" Score="0" ViewCount="59" Body="&lt;p&gt;I've added the following to my &lt;em&gt;.vimrc&lt;/em&gt; in order to test how &lt;code&gt;&amp;lt;count&amp;gt;&lt;/code&gt; works in a user defined command because I was noticing odd behaviour:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -count=1 CountTest :exe &quot;echo &quot; . &amp;lt;count&amp;gt; . &quot;'&quot; &#xA;noremap &amp;lt;space&amp;gt; :CountTest&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, when I type &lt;code&gt;:3CountTest&lt;/code&gt; I get what I would expect, i.e., the number 3 is echoed into the prompt. However, when I try using my custom mapping to &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; (i.e. typing &lt;code&gt;3&amp;lt;space&amp;gt;&lt;/code&gt;) I get 3 + &lt;em&gt;the current line number&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure it's just a problem with the way I've assigned my custom mapping. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="5572" LastEditorUserId="343" LastEditDate="2017-12-06T11:35:22.373" LastActivityDate="2017-12-06T11:35:22.373" Title="Why does the &lt;count&gt; escape sequence insert the current line number in my user command?" Tags="|vimscript|count|user-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5758" PostTypeId="2" ParentId="5757" CreationDate="2015-12-08T12:35:28.663" Score="0" Body="&lt;p&gt;In &lt;code&gt;:h map-examples&lt;/code&gt;, it is mentioned that &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When you type a count before triggering a mapping, it's like the count&#xA;  was typed before the {lhs}.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For your mapping, this means that the count is added before &lt;code&gt;:&lt;/code&gt;. This means the actual command that is getting executed is, for count of 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,.+1CountTest&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and for count of 5:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.,.+4CountTest&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the result of what you see is just how range given to a command which should take a count is handled. To handle the count correctly in the mapping, you can use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;space&amp;gt; :&amp;lt;C-u&amp;gt;exec v:count1 &quot;CountTest&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2015-12-08T12:35:28.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5759" PostTypeId="1" AcceptedAnswerId="5778" CreationDate="2015-12-08T15:32:17.387" Score="8" ViewCount="328" Body="&lt;p&gt;I was looking at &lt;a href=&quot;http://vimgolf.com/challenges/5666943bac55c907fd02066f&quot;&gt;this vimgolf challenge&lt;/a&gt;, and I thought it would be nice to delete specific lines by address. I know I can do this with &lt;code&gt;:&amp;lt;line_number&amp;gt;d&lt;/code&gt;, but is there a way to list multiple line numbers for &lt;code&gt;d&lt;/code&gt; to be run on? I imagine something like this: &lt;code&gt;:1,4,32d&lt;/code&gt;, but of course it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would this be done?&lt;/p&gt;&#xA;" OwnerUserId="4748" LastActivityDate="2015-12-09T09:15:07.327" Title="Delete multiple lines by address" Tags="|repeated-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5760" PostTypeId="1" AcceptedAnswerId="5763" CreationDate="2015-12-08T15:38:14.760" Score="17" ViewCount="1716" Body="&lt;p&gt;For example I have this JavaScript code. The &lt;code&gt;|&lt;/code&gt; character represents the cursor position and it is on an empty line.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function a() {&#xA;    console.log(&amp;quot;a&amp;quot;);&#xA;&#xA;    function b() {&#xA;        console.log(&amp;quot;b&amp;quot;);&#xA;&#xA;        function c() {&#xA;            console.log(&amp;quot;c&amp;quot;);&#xA;        }&#xA;|&#xA;        c();&#xA;    }&#xA;&#xA;    b();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After the requested operation, the contents would look like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function a() {&#xA;    console.log(&amp;quot;a&amp;quot;);&#xA;&#xA;    function b() {&#xA;        console.log(&amp;quot;b&amp;quot;);&#xA;&#xA;        function c() {&#xA;            console.log(&amp;quot;c&amp;quot;);&#xA;        }&#xA;        |&#xA;        c();&#xA;    }&#xA;&#xA;    b();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What I am asking for is a mapping command.&lt;/p&gt;&#xA;" OwnerUserId="5010" LastEditorUserId="32861" LastEditDate="2021-01-01T17:27:57.387" LastActivityDate="2021-01-01T17:27:57.387" Title="How to move the cursor to the correct indentation level without quiting insert mode?" Tags="|key-bindings|indentation|insert-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5761" PostTypeId="1" AcceptedAnswerId="5764" CreationDate="2015-12-08T16:00:44.613" Score="12" ViewCount="523" Body="&lt;p&gt;By searching, I've highlighted the string that I want to change.  Now I want to replace only the highlighted text. I'm using &lt;code&gt;n&lt;/code&gt; to advance to the next instance of the search string. I was thinking I could do something like &lt;code&gt;ciw&lt;/code&gt; but that changes the whole word not just the highlighted text. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm familiar with &lt;code&gt;:%s/old/new/g&lt;/code&gt; but I don't want to change all instances. Instead, I want to advance my cursor to each instance and then decide whether to change it.&lt;/p&gt;&#xA;" OwnerUserId="1132" LastEditorUserId="865" LastEditDate="2015-12-08T16:37:03.570" LastActivityDate="2015-12-12T07:16:07.683" Title="How to selectively change a hightlighted string?" Tags="|search|replace|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5762" PostTypeId="2" ParentId="5761" CreationDate="2015-12-08T16:17:55.113" Score="7" Body="&lt;p&gt;If you have already searched for a word with &lt;code&gt;/word&lt;/code&gt; or &lt;code&gt;?word&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:%s//newword/gc&lt;/code&gt; to replace the word you previously searched for with &lt;code&gt;newword&lt;/code&gt;, by leaving the search term (&lt;code&gt;s//..&lt;/code&gt;) empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;c&lt;/code&gt; flag says that every change should be confirmed, by pressing &lt;code&gt;y&lt;/code&gt; for yes or &lt;code&gt;n&lt;/code&gt; for no.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at &lt;code&gt;:help :s_flags&lt;/code&gt; for more information about the confirm flag.&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="350" LastEditDate="2015-12-12T07:16:07.683" LastActivityDate="2015-12-12T07:16:07.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5763" PostTypeId="2" ParentId="5760" CreationDate="2015-12-08T16:23:23.897" Score="21" Body="&lt;p&gt;As @jamessan mentioned, &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; will indent to the correct place from insert mode. You can also use &lt;code&gt;&amp;lt;C-t&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; to increase or decrease the indention level from insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you may be able to avoid getting into that situation completely by using one of the following techniques:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use &lt;code&gt;o&lt;/code&gt;/&lt;code&gt;O&lt;/code&gt; to start a new line from a previous line&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;cc&lt;/code&gt;/&lt;code&gt;S&lt;/code&gt; to edit the line (takes indention into consideration)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h cc&#xA;:h S&#xA;:h o&#xA;:h i_CTRL-T&#xA;:h i_CTRL-F&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="67" LastEditDate="2015-12-10T22:03:07.820" LastActivityDate="2015-12-10T22:03:07.820" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5764" PostTypeId="2" ParentId="5761" CreationDate="2015-12-08T16:44:15.453" Score="16" Body="&lt;p&gt;Use the &lt;code&gt;gn&lt;/code&gt; motion to edit the current search match. The following example will change the current match to &quot;FooBar&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cgnFooBar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The great part about this technique is that you can repeat the change via &lt;code&gt;.&lt;/code&gt;. Assuming the next match will be changed the same way you can just use &lt;code&gt;.&lt;/code&gt; to repeat. Or skip a few matches via &lt;code&gt;n&lt;/code&gt; and then use &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimcasts.org/&quot;&gt;Vimcasts&lt;/a&gt; has a nice episode on this matter: &lt;a href=&quot;http://vimcasts.org/episodes/operating-on-search-matches-using-gn/&quot;&gt;Operating on search matches using gn&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-12-08T16:44:15.453" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5765" PostTypeId="2" ParentId="5761" CreationDate="2015-12-08T16:47:04.860" Score="2" Body="&lt;p&gt;&lt;strong&gt;Method #1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can take advantage of the &lt;code&gt;gn&lt;/code&gt; and &lt;code&gt;gN&lt;/code&gt; mappings to accomplish what you want.  &lt;code&gt;gn&lt;/code&gt; will search forward for the last used search term and visually select the match.  &lt;code&gt;gN&lt;/code&gt; does exactly the same thing, except it searches backwards.  When combined with an operator such as &lt;code&gt;c&lt;/code&gt;, the operator will be applied to the match,  For example, if your last search string is &quot;foo&quot; and you type &lt;code&gt;cgn&lt;/code&gt;, it will search forwards for the next instance of &quot;foo&quot;, delete it, and put you in insert mode to enter the replacement text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more on these, see &lt;code&gt;:help gn&lt;/code&gt; and &lt;code&gt;:help gN&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Method #2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;code&gt;:substitute&lt;/code&gt; command with the &lt;code&gt;c&lt;/code&gt; flag.  This will ask you to confirm each substitution.  For instance, say you wanted to replace foo with bar in the entire file, but wanted to confirm each replacement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/foo/bar/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more on this, see these help topics: &lt;code&gt;:help :s_flags&lt;/code&gt;, &lt;code&gt;:help cmdline-ranges&lt;/code&gt;, and &lt;code&gt;:help :substitute&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-12-08T16:47:04.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5766" PostTypeId="1" CreationDate="2015-12-08T16:55:56.703" Score="21" ViewCount="6462" Body="&lt;p&gt;If I want to indent all lines in a document, I can type &lt;code&gt;&amp;gt;G&lt;/code&gt; to apply it to the current line and below, followed by and &lt;code&gt;&amp;gt;gg&lt;/code&gt; to apply it to the lines above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a combination I can use to just apply &lt;code&gt;&amp;gt;&lt;/code&gt; to all lines at once?&lt;/p&gt;&#xA;" OwnerUserId="69" LastActivityDate="2015-12-08T22:08:10.543" Title="How I apply a command to all lines?" Tags="|key-bindings|normal-mode|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5767" PostTypeId="2" ParentId="5766" CreationDate="2015-12-08T17:05:38.963" Score="7" Body="&lt;p&gt;One way to indent all lines in a document:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-12-08T17:05:38.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5768" PostTypeId="2" ParentId="5766" CreationDate="2015-12-08T17:06:17.067" Score="19" Body="&lt;p&gt;You are looking for the &lt;code&gt;:&amp;gt;&lt;/code&gt; command and a range of &lt;code&gt;1,$&lt;/code&gt; (&lt;code&gt;%&lt;/code&gt; for short) for the whole file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :&amp;gt;&#xA;:h :range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2015-12-08T17:06:17.067" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5769" PostTypeId="2" ParentId="5076" CreationDate="2015-12-08T17:36:33.340" Score="1" Body="&lt;p&gt;Perhaps &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#VIS&quot; rel=&quot;nofollow&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#VIS&lt;/a&gt; 's :B command  will do what you want -- it applies the command to the visual block selection.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2015-12-08T17:36:33.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5770" PostTypeId="1" CreationDate="2015-12-08T18:30:36.910" Score="1" ViewCount="38" Body="&lt;p&gt;I know that gv reselects the last visual selection. This is great and I use it frequently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But sometimes I want to select the block of text that I just pasted. This is useful e.g. for sending example code from Stackexchange from vim to a REPL or generally selecting text that I just pasted from one tab to another or from outside vim to inside, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: I am asking this question just to provide the right place to put the answer to a related question to &lt;a href=&quot;https://vi.stackexchange.com/questions/5750/is-there-a-way-to-reselect-the-last-visual-shape-rather-than-the-last-actual-se&quot;&gt;Is there a way to reselect the last visual shape, rather than the last actual selection, starting at the current cursor position?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4985" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-12-09T01:49:18.163" Title="Is there a way to reselect the last pasted text, rather than the last actual selection, starting at the current cursor position?" Tags="|cut-copy-paste|visual-mode|" AnswerCount="0" CommentCount="0" ClosedDate="2015-12-08T20:20:18.307" ContentLicense="CC BY-SA 3.0" />
  <row Id="5771" PostTypeId="1" AcceptedAnswerId="5775" CreationDate="2015-12-08T19:16:00.893" Score="4" ViewCount="257" Body="&lt;p&gt;Is it possible to change that somehow? Either to make Vim go one symbol further in normal mode, or one symbol less in visual mode?&lt;/p&gt;&#xA;" OwnerUserId="5365" LastActivityDate="2015-12-08T23:21:59.620" Title="Why after pressing $ in normal mode Vim goes to the last symbol in line, but in visual mode it goes on the /n newline symbol?" Tags="|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5772" PostTypeId="2" ParentId="5771" CreationDate="2015-12-08T20:36:10.477" Score="4" Body="&lt;p&gt;As far as I know, there's no built-in way to stop visual mode from being &lt;em&gt;inclusive&lt;/em&gt; and normal mode from being &lt;em&gt;exclusive&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One could probably remap everything to work like that but that sounds like a bad idea to me.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-08T20:36:10.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5773" PostTypeId="2" ParentId="5766" CreationDate="2015-12-08T20:37:42.477" Score="4" Body="&lt;p&gt;Without leaving normal mode you can simply do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg&amp;gt;G&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-08T20:37:42.477" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="5774" PostTypeId="2" ParentId="5766" CreationDate="2015-12-08T20:53:18.427" Score="4" Body="&lt;p&gt;Another option that has not been mentioned yet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will run the command &lt;code&gt;&amp;gt;&lt;/code&gt; on all lines that match the pattern &lt;code&gt;^&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Downside is that this will overwrite your search history.&lt;/p&gt;&#xA;" OwnerUserId="1472" LastEditorUserId="1472" LastEditDate="2015-12-08T22:08:10.543" LastActivityDate="2015-12-08T22:08:10.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5775" PostTypeId="2" ParentId="5771" CreationDate="2015-12-08T21:01:51.883" Score="10" Body="&lt;p&gt;You can make &lt;code&gt;$&lt;/code&gt; go one symbol further in normal mode by enabling setting &lt;code&gt;virtualedit=onemore&lt;/code&gt; and remapping &lt;code&gt;$&lt;/code&gt; to &lt;code&gt;g$&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set virtualedit=onemore&#xA;:nnoremap $ g$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As @statox mentions in the comments&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also make $ go one symbol less in visual mode with the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnoremap $ $h &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1472" LastEditorUserId="1472" LastEditDate="2015-12-08T23:21:59.620" LastActivityDate="2015-12-08T23:21:59.620" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5776" PostTypeId="2" ParentId="5753" CreationDate="2015-12-08T22:11:03.620" Score="2" Body="&lt;p&gt;The following function and calls to that function work in Vim. It seems like they should work in Neovim but I don't have a Neovim to test.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyScroll(key)&#xA;    exe 'normal' a:key&#xA;endfunction&#xA;&#xA;call MyScroll('^E')&#xA;call MyScroll('^Y')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the &lt;code&gt;^E&lt;/code&gt; and &lt;code&gt;^Y&lt;/code&gt; in the calls to MyScroll() above are literal &lt;code&gt;Ctrl-E&lt;/code&gt; and &lt;code&gt;Ctrl-Y&lt;/code&gt; characters entered by typing the two-character sequences &lt;code&gt;Ctrl-V Ctrl-E&lt;/code&gt; and &lt;code&gt;Ctrl-V Ctrl-Y&lt;/code&gt;, respectively.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-12-08T22:11:03.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5778" PostTypeId="2" ParentId="5759" CreationDate="2015-12-09T09:15:07.327" Score="6" Body="&lt;p&gt;The bar &lt;code&gt;|&lt;/code&gt; command can be used to separate multiple commands in a single command statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your example could be written as &lt;code&gt;:1d|4d|32d&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#:%5Cbar&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#:\bar&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="593" LastActivityDate="2015-12-09T09:15:07.327" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5779" PostTypeId="1" CreationDate="2015-12-09T18:44:34.260" Score="6" ViewCount="695" Body="&lt;p&gt;I'm using Vim 7.3 on OS X Terminal version 2.6.1 (OS X version 10.11.2). If it's relevant, my version is compiled &lt;em&gt;without&lt;/em&gt; X11.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open a file in Vim, the terminal title bar changes to show the file name, as expected. Quitting the file with &lt;code&gt;:q&lt;/code&gt; clears the title bar, also expected. The problem comes when using &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Z&lt;/kbd&gt; to stop Vim temporarily. After doing so, the title bar reads &quot;Thanks for flying Vim&quot;. Restarting the stopped Vim instance with &lt;code&gt;%%&lt;/code&gt; causes the title bar to once again display the file name. Finally, quitting Vim with &lt;code&gt;:q&lt;/code&gt; leaves the title bar showing the file name, instead of blank as it should be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example to clarify. Each step lists the action, the title bar that is expected, and the title bar that actually results.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;New terminal window – &quot;&quot; – &quot;&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vim foo.txt&lt;/code&gt; – &quot;foo.txt&quot; – &quot;foo.txt&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:q&lt;/code&gt; – &quot;&quot; – &quot;&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vim foo.txt&lt;/code&gt; – &quot;foo.txt&quot; – &quot;foo.txt&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Z&lt;/kbd&gt; – &quot;&quot; – &quot;Thanks for flying Vim&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%%&lt;/code&gt; – &quot;foo.txt&quot; – &quot;foo.txt&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:q&lt;/code&gt; – &quot;&quot; – &quot;foo.txt&quot;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As you can see, there are discrepancies between what I expect and what actually happens at steps 5 and 7. 5 can be fixed, I've found, with &lt;code&gt;:set titleold=&lt;/code&gt;, to clear the old title variable. However, step 7 continues to vex me, and is clearly related to stopping Vim using bash job control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get the title bar properly restored even after stopping and restarting Vim using bash job control?&lt;/p&gt;&#xA;" OwnerUserId="5598" LastEditorUserId="23502" LastEditDate="2023-12-05T07:53:14.897" LastActivityDate="2024-01-04T08:00:40.080" Title="Properly restore terminal title after suspending Vim" Tags="|terminal|macos|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5780" PostTypeId="1" AcceptedAnswerId="5782" CreationDate="2015-12-09T20:10:58.093" Score="102" ViewCount="39014" Body="&lt;p&gt;How can I get a list of the names of filetypes that vim currently knows about?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to do this so that when vim doesn't automatically detect a filetype I can try some of the filetypes vim knows about that may be similar and see if they provide reasonable syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that vimscript files dealing with filetypes are put in the &lt;code&gt;ftplugin&lt;/code&gt; directory by convention but they don't need to be (I'm not sure, but I don't think the vimscript files in the &lt;code&gt;ftplugin&lt;/code&gt; directory are special) so I want to just ask vim what filetypes it knows about, regardless of how it learned about them.&lt;/p&gt;&#xA;" OwnerUserId="268" LastEditorUserId="268" LastEditDate="2015-12-10T18:25:40.363" LastActivityDate="2022-10-19T13:23:43.637" Title="List known filetypes" Tags="|syntax-highlighting|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5781" PostTypeId="1" AcceptedAnswerId="5783" CreationDate="2015-12-09T21:42:30.820" Score="3" ViewCount="385" Body="&lt;p&gt;I often use &lt;code&gt;vim&lt;/code&gt; via terminal wrapper (e.g. &lt;code&gt;gnome-terminal --disable-factory --command='vim /tmp/firefox12345.txt'&lt;/code&gt;) to edit a textarea on websites, e.g. when writing this question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever I put in a block of code I wonder if I can somehow:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;visually select whole indented part of text in the current buffer&lt;/li&gt;&#xA;&lt;li&gt;open it in a new one&lt;/li&gt;&#xA;&lt;li&gt;change the filetype to match the syntax (e.g. javascript)&lt;/li&gt;&#xA;&lt;li&gt;edit, write and close it&lt;/li&gt;&#xA;&lt;li&gt;have vim &quot;update&quot; all my changes in the original buffer&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2719" LastEditorUserId="1238" LastEditDate="2015-12-16T17:06:44.657" LastActivityDate="2015-12-16T17:06:44.657" Title="Can I edit visually selected text in a different buffer?" Tags="|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5782" PostTypeId="2" ParentId="5780" CreationDate="2015-12-09T21:52:47.217" Score="116" Body="&lt;p&gt;&lt;strong&gt;Simple Solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Type &lt;code&gt;:setfiletype&lt;/code&gt; &lt;em&gt;(with a space afterwards)&lt;/em&gt;, then press &lt;code&gt;Ctrl-d&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help cmdline-completion&lt;/code&gt; for more on autocompletion in vim's command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Complicated Solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution uses the &lt;code&gt;'runtimepath'&lt;/code&gt; option to get all available syntax directories, and then fetches a list of the vimscript files in those directories with their extensions removed.  This may not be the safest way to do it, so improvements are welcome:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetFiletypes()&#xA;    &quot; Get a list of all the runtime directories by taking the value of that&#xA;    &quot; option and splitting it using a comma as the separator.&#xA;    let rtps = split(&amp;amp;runtimepath, &quot;,&quot;)&#xA;    &quot; This will be the list of filetypes that the function returns&#xA;    let filetypes = []&#xA;&#xA;    &quot; Loop through each individual item in the list of runtime paths&#xA;    for rtp in rtps&#xA;        let syntax_dir = rtp . &quot;/syntax&quot;&#xA;        &quot; Check to see if there is a syntax directory in this runtimepath.&#xA;        if (isdirectory(syntax_dir))&#xA;            &quot; Loop through each vimscript file in the syntax directory&#xA;            for syntax_file in split(glob(syntax_dir . &quot;/*.vim&quot;), &quot;\n&quot;)&#xA;                &quot; Add this file to the filetypes list with its everything&#xA;                &quot; except its name removed.&#xA;                call add(filetypes, fnamemodify(syntax_file, &quot;:t:r&quot;))&#xA;            endfor&#xA;        endif&#xA;    endfor&#xA;&#xA;    &quot; This removes any duplicates and returns the resulting list.&#xA;    &quot; NOTE: This might not be the best way to do this, suggestions are welcome.&#xA;    return uniq(sort(filetypes))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use this function in whatever way you want, such as printing all of the values in the list.  You could accomplish that like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for f in GetFiletypes() | echo f | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this probably can be compacted quite a bit, it is just like this for readability.  I won't explain every function and command used here, but here are all the help pages for them:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'runtimepath'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :let&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :let-&amp;amp;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help split()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :for&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help expr-.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :if&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help isdirectory()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help glob()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help fnamemodify()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help add()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help uniq()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help sort()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2016-09-10T18:53:12.360" LastActivityDate="2016-09-10T18:53:12.360" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5783" PostTypeId="2" ParentId="5781" CreationDate="2015-12-09T22:03:01.353" Score="6" Body="&lt;p&gt;You may want to try the Emacs-inspired &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn&quot;&gt;NrrwRgn&lt;/a&gt; (&quot;narrow region&quot;) plugin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should allow you to do exactly what you ask - but you'll probably have to &lt;code&gt;set filetype=javascript&lt;/code&gt; (as an example) yourself (or perhaps run &lt;code&gt;filetype detect&lt;/code&gt;) in the narrowed region.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-12-09T22:03:01.353" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5785" PostTypeId="1" AcceptedAnswerId="5839" CreationDate="2015-12-10T02:09:45.830" Score="2" ViewCount="455" Body="&lt;p&gt;While I was answering another question, I noticed an odd behaviour in the functions &lt;code&gt;finddir()&lt;/code&gt; and &lt;code&gt;findfile()&lt;/code&gt;.  According to the help page, both of these functions will return the full path to the first match &lt;em&gt;unless&lt;/em&gt; the match is found in a directory beneath the specified directory.  Is there some way of forcing both of them to return a full path?&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2016-05-08T20:20:09.480" Title="Make findfile() always return full path" Tags="|filesystem|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5786" PostTypeId="1" AcceptedAnswerId="5789" CreationDate="2015-12-10T10:38:11.427" Score="3" ViewCount="119" Body="&lt;p&gt;I have the markdown file that uses &lt;code&gt;#&lt;/code&gt; for headlines, like this one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#H1&#xA;Text one one&#xA;##h2&#xA;more Text&#xA;#more H1s&#xA;Even more text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No I have the problem that some interpreters of markdown don't accept a headline when it isn't surrounded by empty lines.&#xA;So the upper file needs to look like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#H1&#xA;&#xA;Text one one&#xA;&#xA;##h2&#xA;&#xA;more Text&#xA;&#xA;#more H1s&#xA;&#xA;Even more text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought I could write a function that gets executed when I write my changes to the file and I came up with this two functions&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! &amp;lt;SID&amp;gt;SurroundingNewLines()&#xA;    execute &quot;normal! O\&amp;lt;esc&amp;gt;jo\&amp;lt;esc&amp;gt;&quot;&#xA;endfunc&#xA;&#xA;function! &amp;lt;SID&amp;gt;AddEmptyLines()&#xA;    1global/^#/execute &quot;normal! o\&amp;lt;esc&amp;gt;&quot;&#xA;    2,$global/^#/call &amp;lt;SID&amp;gt;SurroundingNewLines()&#xA;    %substitute/\n\{3,}/\r\r/e&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note that this is my first experience with VimScript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;AddEmptyLines&lt;/code&gt; searches for lines that start with a &lt;code&gt;#&lt;/code&gt; and surrounds those with new lines and then the &lt;code&gt;substitute&lt;/code&gt; command removes all duplicate empty lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works but it is rather inefficient since it always adds the lines and then removes all unnecessarily added lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there a better way of doing this, for example find all headers that are not surrounded by empty lines?&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2015-12-11T13:18:32.887" Title="How to surround all headlines with empty new lines in a markdown file?" Tags="|vimscript|regular-expression|global-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5787" PostTypeId="1" AcceptedAnswerId="5788" CreationDate="2015-12-10T11:39:27.910" Score="1" ViewCount="1674" Body="&lt;p&gt;I have the following problem. Consider this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t status = 0x00;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I want to search for the occurence for the status, I will get LOADS of references (nearly every module uses some sort of status).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cs find s status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I thought that the best idea would be to search for: &lt;code&gt;extern uint8_t status&lt;/code&gt; which will narrow down my search results (a little...)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cs find e extern uint8_t status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunatelly &lt;code&gt;cscope&lt;/code&gt; with &lt;code&gt;egrep&lt;/code&gt; doesn't allow that. How should my call to &lt;code&gt;cs find e&lt;/code&gt; look like, so that I will the occurence of &lt;code&gt;extern uint8_t status&lt;/code&gt;?&#xA;I have tried the following (omitting the obvious &lt;code&gt;extern uint8_t&lt;/code&gt;...)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cs find e status =&#xA;:cs find e status\s=&#xA;:cs find e status[:space:]=&#xA;:cs find e status[[:space:]]=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="245" LastActivityDate="2015-12-10T11:39:59.333" Title="Using cscope to search for patterns with spaces" Tags="|cscope|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5788" PostTypeId="2" ParentId="5787" CreationDate="2015-12-10T11:39:59.333" Score="1" Body="&lt;p&gt;It seems, that the following works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cs find e status[ ]=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="245" LastActivityDate="2015-12-10T11:39:59.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5789" PostTypeId="2" ParentId="5786" CreationDate="2015-12-10T12:23:42.937" Score="7" Body="&lt;p&gt;Well, you can have perhaps more cases than you account for in your description: a header line can be preceded by 0, 1 or many empty lines, and can be followed by 0, 1 or many empty lines. In all these cases, you want to achieve a header line preceded &lt;em&gt;and&lt;/em&gt; followed by exactly 1 line (if I got that right). With this description, the problem can be solved with something like (I'm sure it can be improved):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(^\s*\n\)*\(^#.*\)\(\n\s*\)*/\r\2\r\r/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or (similar, with more symmetry and slightly simpler):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v^(\s*\n)*(#.*\n)(\s*\n)*/\r\2\r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that two headers following one right after the other will have 2 lines between them, but in a way this is a feature: in this way you can see that you still have to add some text there ...&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-12-11T13:18:32.887" LastActivityDate="2015-12-11T13:18:32.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5790" PostTypeId="2" ParentId="5382" CreationDate="2015-12-10T12:55:22.823" Score="3" Body="&lt;p&gt;Vim's default Javascript configuration contains a setting to &lt;a href=&quot;https://github.com/vim/vim/blob/1c57fe8b9450eb29c3e42a94527d4b7514f853e2/runtime/ftplugin/javascript.vim#L25&quot; rel=&quot;nofollow&quot;&gt;format dashed lists in comments&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get the behaviour you want, simply override the setting (for javascript filetypes) to leave out the dashed list part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal comments=s1:/*,mb:*,ex:*/,://&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2015-12-10T12:55:22.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5791" PostTypeId="1" AcceptedAnswerId="5798" CreationDate="2015-12-10T13:01:24.317" Score="13" ViewCount="1002" Body="&lt;p&gt;Hot exit is one of killer features of Sublime Text editor. It allows to close editor at any point of time without worrying about modifications in opened files - it just closes without any question. When launch ST again all opened and edited files will be at the same state as they were before close&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder is there a way doing the same in vim?&lt;/p&gt;&#xA;" OwnerUserId="5608" LastActivityDate="2015-12-10T20:45:29.023" Title="Is there any vim plugin that implement hot exit feature from sublime text" Tags="|save|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5792" PostTypeId="1" AcceptedAnswerId="5796" CreationDate="2015-12-10T13:35:19.600" Score="4" ViewCount="772" Body="&lt;p&gt;I would like to apply macro &lt;code&gt;a&lt;/code&gt; to a set of lines. For consecutive lines, this can be done by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5,10norm! @a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;a href=&quot;https://stackoverflow.com/questions/390174/in-vim-how-do-i-apply-a-macro-to-a-set-of-lines&quot;&gt;https://stackoverflow.com/questions/390174/in-vim-how-do-i-apply-a-macro-to-a-set-of-lines&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to do it for every &lt;code&gt;n&lt;/code&gt;-th line from my current cursor position?&lt;/p&gt;&#xA;" OwnerDisplayName="user5370" LastActivityDate="2015-12-10T14:31:57.063" Title="Apply macro to every `n`-th line" Tags="|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5794" PostTypeId="2" ParentId="5791" CreationDate="2015-12-10T13:48:22.233" Score="1" Body="&lt;p&gt;Yes. It's called &quot;session&quot; and you can read all about it in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help session&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-10T13:48:22.233" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5795" PostTypeId="1" CreationDate="2015-12-10T13:49:17.010" Score="1" ViewCount="743" Body="&lt;p&gt;I have a server with vim installed and an empty &lt;code&gt;.vimrc&lt;/code&gt;.  I open a python file and run &lt;code&gt;:set filetype=python&lt;/code&gt;. I then try to indent a line with &lt;code&gt;==&lt;/code&gt; and vim complains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.!indent&#xA;shell returned 2&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the line is replaced with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;indent: Standard input:2: Error:Unexpected end of file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try &lt;code&gt;:help =&lt;/code&gt;, the buffer says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E433: No tags file&#xA;E149: Sorry, no help for =&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a minimum configuration needed in order for &lt;code&gt;=&lt;/code&gt; to work?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="69" LastEditDate="2015-12-10T20:56:21.150" LastActivityDate="2016-07-03T05:13:55.857" Title="&quot;shell returned 2&quot; when I try to indent" Tags="|indentation|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5796" PostTypeId="2" ParentId="5792" CreationDate="2015-12-10T14:10:08.533" Score="9" Body="&lt;p&gt;How about writing a 2nd macro that moves down n lines and then executes @a? Using a mark you can easily jump back to your original position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g., having defined your macro in register a, press &lt;code&gt;qb&lt;/code&gt; to record in register b, press &lt;code&gt;5j&lt;/code&gt; to go to line 6, press &lt;code&gt;@a&lt;/code&gt; to execute a and then &lt;code&gt;q&lt;/code&gt; to quit recording. Using &lt;code&gt;9@b&lt;/code&gt; will then execute macro a on every 5th line, i.e. lines 11, 16, 21,..., up to line 51. Since &lt;code&gt;j&lt;/code&gt; will fail at the end of the file, simpy use &lt;code&gt;1000@b&lt;/code&gt; for the whole file... adjust numbers as needed.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="1296" LastEditDate="2015-12-10T14:31:57.063" LastActivityDate="2015-12-10T14:31:57.063" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5797" PostTypeId="2" ParentId="5792" CreationDate="2015-12-10T14:11:13.447" Score="3" Body="&lt;p&gt;Something like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;record current line number and &lt;code&gt;n&lt;/code&gt; in some variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let c=line('.')&#xA;:let n=2&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;conditionally run the macro from your &lt;code&gt;a&lt;/code&gt; register on every &lt;code&gt;n&lt;/code&gt;-th line &lt;em&gt;after&lt;/em&gt; the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/if line('.') &amp;gt; c &amp;amp;&amp;amp;  (line('.') - c) % n == 0 | norm! @a&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I also believe that it would be easier to alter the macro instead (to jump &lt;code&gt;n&lt;/code&gt; lines below as its first or last operation).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-12-10T14:19:10.523" LastActivityDate="2015-12-10T14:19:10.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5798" PostTypeId="2" ParentId="5791" CreationDate="2015-12-10T20:45:29.023" Score="7" Body="&lt;p&gt;Vim can do this, though it may be a bit clunky and take some setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/5794/2736&quot;&gt;romainl&lt;/a&gt; gets you partway with &lt;code&gt;session&lt;/code&gt;. The missing bits are swap files, &lt;code&gt;:preserve&lt;/code&gt;, and the &lt;code&gt;&amp;amp;&lt;/code&gt; flag for &lt;code&gt;cpoptions&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Swap files are intended for recovery if Vim or your system crashes. They enable you to recover any unsaved changes (with some limitations, see &lt;code&gt;:he swap-file&lt;/code&gt;). However, when Vim exits normally, it deletes any swap files it was using, even if the buffer had unsaved changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's where &lt;code&gt;:preserve&lt;/code&gt; and &lt;code&gt;cpoptions&lt;/code&gt;'s &lt;code&gt;&amp;amp;&lt;/code&gt; come in. &lt;code&gt;:preserve&lt;/code&gt; forces Vim to write all buffers to their swap files immediately (as opposed to the standard after 4 seconds or 200 characters, or whatever your options have set it to). Doing &lt;code&gt;:set cpoptions+=&amp;amp;&lt;/code&gt; tells Vim &lt;em&gt;not&lt;/em&gt; to delete swap files saved with &lt;code&gt;:preserve&lt;/code&gt; when exiting normally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, Vim does not automatically clean up swap files when recovering from them, so you can soon end up with a directory looking like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.foo.txt.swn&#xA;.foo.txt.swo&#xA;.foo.txt.swp&#xA;foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can delete the older ones manually, but Vim will only automatically offer to recover if there is a &lt;code&gt;*.swp&lt;/code&gt; file where it would put its new swap file. The &lt;code&gt;:recover&lt;/code&gt; command will force Vim to look for swap files to recover from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By using autocommands, you can automate preserving (probably with the &lt;code&gt;QuitPre&lt;/code&gt; event) and recovering (probably with &lt;code&gt;BufRead&lt;/code&gt; or &lt;code&gt;BufReadPost&lt;/code&gt;). &lt;a href=&quot;https://github.com/chrisbra/Recover.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Recover.vim&lt;/a&gt; is a plugin that might work as a friendlier alternative for managing recovering. It appears to also handle cleaning up swap files. I'm not sure how it would handle a directory with a &lt;code&gt;.swo&lt;/code&gt; but no &lt;code&gt;.swp&lt;/code&gt; file. You may still need to use &lt;code&gt;:recover&lt;/code&gt; for that case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-obsession&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-obsession&lt;/a&gt; is another plugin that claims to make handling sessions much easier.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-12-10T20:45:29.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5799" PostTypeId="2" ParentId="5735" CreationDate="2015-12-11T03:47:18.317" Score="0" Body="&lt;p&gt;My solution to both my problems was, as &lt;a href=&quot;https://vi.stackexchange.com/users/21/karl-yngve-lerv%C3%A5g&quot;&gt;Karl Yngve Lervåg&lt;/a&gt; suggested, to ditch Vim-LaTeX in favor of a better plugin. I'm currently trying out LaTeX-Box, which solves both of my problems nicely. Maybe I'll try out vimtex next to see which one I like better.&lt;/p&gt;&#xA;" OwnerUserId="5043" LastActivityDate="2015-12-11T03:47:18.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5800" PostTypeId="1" AcceptedAnswerId="5802" CreationDate="2015-12-11T07:15:10.880" Score="6" ViewCount="1461" Body="&lt;p&gt;Hi I am having some issue trying to unmap this key in my .&lt;strong&gt;vimrc&lt;/strong&gt;. I've tried a lot of suggestions and remapping but it seems to be resetting itself every time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unamp &amp;lt;Esc&amp;gt; &#xA;unmap! &amp;lt;Esc&amp;gt;&#xA;map &amp;lt;Esc&amp;gt;^[ &amp;lt;Esc&amp;gt;^[&#xA;map &amp;lt;Esc&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everytime I open a file in vim and type the following in command mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following shows up and I want to get rid of the &lt;code&gt;n &amp;lt;Esc&amp;gt; *:bprevious&amp;lt;CR&amp;gt;&lt;/code&gt; mapping completely, that is not in my .&lt;code&gt;vimrc&lt;/code&gt; file but it keeps resetting.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n &amp;lt;Esc&amp;gt;     * :bprevious&amp;lt;CR&amp;gt;&#xA;  &amp;lt;Esc&amp;gt;^[     &amp;lt;Esc&amp;gt;^[&#xA;ov &amp;lt;Esc&amp;gt;      &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The out from the command suggested in the comment: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose :map &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n  &amp;lt;Esc&amp;gt;     * :bprevious&amp;lt;CR&amp;gt;&#xA;       Last set from ~/.vimrc&#xA;   &amp;lt;Esc&amp;gt;^[   [Esc]^[&#xA;       Last set from ~/.vimrc&#xA;ov &amp;lt;Esc&amp;gt;     &amp;lt;Nop&amp;gt;&#xA;   Last set from ~/.vimrc &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've checked my .&lt;code&gt;vimrc&lt;/code&gt; and I definitely don't have it set.&lt;/p&gt;&#xA;" OwnerUserId="2129" LastEditorUserId="2129" LastEditDate="2015-12-11T09:33:40.507" LastActivityDate="2015-12-11T10:13:06.220" Title="How can I unmap &lt;esc&gt; key in vim, it keeps reverting despite setting it in .vimrc?" Tags="|key-bindings|vimrc|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5801" PostTypeId="2" ParentId="5800" CreationDate="2015-12-11T09:43:00.293" Score="1" Body="&lt;p&gt;I think I found the 'potentially' culprit. I would love an explanation if anyone can explain it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These two lines when I comment them out the first entry gets erased.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-]&amp;gt; :bnext&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-[&amp;gt; :bprevious&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure why that would affect the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; key but it seems to have 'fixed' the issue.&lt;/p&gt;&#xA;" OwnerUserId="2129" LastActivityDate="2015-12-11T09:43:00.293" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5802" PostTypeId="2" ParentId="5800" CreationDate="2015-12-11T10:13:06.220" Score="6" Body="&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;[&lt;/kbd&gt; &lt;a href=&quot;http://vim.wikia.com/wiki/Avoid_the_escape_key&quot;&gt;is the the same as ESC&lt;/a&gt;, as mentioned in &lt;code&gt;:help &amp;lt;Esc&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;notation    meaning         equivalent  decimal value(s)    ~&#xA;-----------------------------------------------------------------------&#xA;&amp;lt;Nul&amp;gt;       zero            CTRL-@    0 (stored as 10) *&amp;lt;Nul&amp;gt;*&#xA;&amp;lt;BS&amp;gt;        backspace       CTRL-H    8 *backspace*&#xA;&amp;lt;Tab&amp;gt;       tab         CTRL-I    9 *tab* *Tab*&#xA;                            *linefeed*&#xA;&amp;lt;NL&amp;gt;        linefeed        CTRL-J   10 (used for &amp;lt;Nul&amp;gt;)&#xA;&amp;lt;FF&amp;gt;        formfeed        CTRL-L   12 *formfeed*&#xA;&amp;lt;CR&amp;gt;        carriage return     CTRL-M   13 *carriage-return*&#xA;&amp;lt;Return&amp;gt;    same as &amp;lt;CR&amp;gt;                *&amp;lt;Return&amp;gt;*&#xA;&amp;lt;Enter&amp;gt;     same as &amp;lt;CR&amp;gt;                *&amp;lt;Enter&amp;gt;*&#xA;&amp;lt;Esc&amp;gt;       escape          CTRL-[   27 *escape* *&amp;lt;Esc&amp;gt;*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-12-11T10:13:06.220" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5803" PostTypeId="1" CreationDate="2015-12-12T03:41:04.337" Score="5" ViewCount="591" Body="&lt;p&gt;While in INSERT mode, I'd like to make &lt;code&gt;&amp;lt;c-r&amp;gt;*&lt;/code&gt; behave as &lt;code&gt;&amp;lt;c-r&amp;gt;+&lt;/code&gt;. Is that possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried both of the following, but no luck:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-r&amp;gt;* &amp;lt;c-r&amp;gt;+&#xA;onoremap * +&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT, Dec 11th: The solution I tried (&lt;code&gt;inoremap &amp;lt;c-r&amp;gt;* &amp;lt;c-r&amp;gt;+&lt;/code&gt;) is the answer, but sometimes that doesn't always work, and I'm not entirely sure why (it might have to do with timeouts as mentioned in the comments, and sometimes the timeout behavior changes on me at some random point into my NeoVim session).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT, Dec 12th: This is what I'm trying to achieve, as per a comment I wrote in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    &quot; COPY/PASTE&#xA;        &quot; Make &quot;* behave the same on all OSes. In linux, &quot;* uses the&#xA;        &quot; SECONDARY register for pasting with a mouse middle click, but I&#xA;        &quot; never use that. In OS X, &quot;* uses the same register as &quot;+, which&#xA;        &quot; is the behavior I like.&#xA;            noremap &quot;* &quot;+&#xA;            inoremap &amp;lt;c-r&amp;gt;* &amp;lt;c-r&amp;gt;+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5626" LastEditorUserId="51" LastEditDate="2015-12-17T14:04:15.727" LastActivityDate="2015-12-17T14:04:15.727" Title="Is it possible to remap the character following CTRL+R in INSERT mode?" Tags="|key-bindings|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="5804" PostTypeId="1" AcceptedAnswerId="5805" CreationDate="2015-12-12T14:12:04.093" Score="13" ViewCount="18855" Body="&lt;p&gt;I want to zoom in VIM, like Sublime text or Atom, using &lt;code&gt;CTRL +&lt;/code&gt; &amp;amp; &lt;code&gt;CTRL -&lt;/code&gt; and &lt;code&gt;CTRL 0&lt;/code&gt; for reset to default font-size.&lt;/p&gt;&#xA;" OwnerUserId="5631" LastEditorUserId="205" LastEditDate="2016-02-18T00:31:09.233" LastActivityDate="2016-02-18T00:31:09.233" Title="How to zoom to text in VIM via shortcut?" Tags="|key-bindings|font|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5805" PostTypeId="2" ParentId="5804" CreationDate="2015-12-12T16:25:05.660" Score="14" Body="&lt;p&gt;If you are using vim in a terminal you can simply use its zoom shortcuts. For Gnome-Terminal this is &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;+&lt;/kbd&gt;. In others it may be &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;+&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also there are several plugins out there for this purpose. e.x: &lt;a href=&quot;https://github.com/drmikehenry/vim-fontsize&quot;&gt;https://github.com/drmikehenry/vim-fontsize&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an alternative you can define your own functions like this one from &lt;a href=&quot;http://vim.wikia.com/wiki/Change_font_size_quickly&quot;&gt;vim.wika.com&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:pattern = '^\(.* \)\([1-9][0-9]*\)$'&#xA;let s:minfontsize = 6&#xA;let s:maxfontsize = 16&#xA;function! AdjustFontSize(amount)&#xA;  if has(&quot;gui_gtk2&quot;) &amp;amp;&amp;amp; has(&quot;gui_running&quot;)&#xA;    let fontname = substitute(&amp;amp;guifont, s:pattern, '\1', '')&#xA;    let cursize = substitute(&amp;amp;guifont, s:pattern, '\2', '')&#xA;    let newsize = cursize + a:amount&#xA;    if (newsize &amp;gt;= s:minfontsize) &amp;amp;&amp;amp; (newsize &amp;lt;= s:maxfontsize)&#xA;      let newfont = fontname . newsize&#xA;      let &amp;amp;guifont = newfont&#xA;    endif&#xA;  else&#xA;    echoerr &quot;You need to run the GTK2 version of Vim to use this function.&quot;&#xA;  endif&#xA;endfunction&#xA;&#xA;function! LargerFont()&#xA;  call AdjustFontSize(1)&#xA;endfunction&#xA;command! LargerFont call LargerFont()&#xA;&#xA;function! SmallerFont()&#xA;  call AdjustFontSize(-1)&#xA;endfunction&#xA;command! SmallerFont call SmallerFont()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An then map two keys to &lt;code&gt;:LargerFont&lt;/code&gt; and &lt;code&gt;:SmallerFont&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5331" LastEditorUserId="5331" LastEditDate="2015-12-12T19:00:51.263" LastActivityDate="2015-12-12T19:00:51.263" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5806" PostTypeId="1" AcceptedAnswerId="5811" CreationDate="2015-12-12T22:21:27.230" Score="103" ViewCount="55183" Body="&lt;p&gt;I know many ways to copy things:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;yiw&lt;/code&gt; = yank in current word&lt;br&gt;&#xA;&lt;code&gt;yaw&lt;/code&gt; = yank all word (includes a trailing space)&lt;br&gt;&#xA;&lt;code&gt;yy&lt;/code&gt;  = yank the current line&lt;br&gt;&#xA;&lt;code&gt;3yy&lt;/code&gt; = yank three lines starting at the current one&lt;br&gt;&#xA;&lt;code&gt;yap&lt;/code&gt; = yank all paragraph (includes trailing newline)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can also delete or change a single character:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;x&lt;/code&gt; = delete the character under the cursor&lt;br&gt;&#xA;&lt;code&gt;r&lt;/code&gt; = replace the character under the cursor  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how in the world do you simply copy a single character under the cursor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My motivation is that I'm programming in Perl 6 and some of the operators are Unicode characters. Right now I'm using &lt;a href=&quot;https://github.com/tadzik/perl6-Config-INI/blob/master/lib/Config/INI.pm&quot; rel=&quot;noreferrer&quot;&gt;tadzik's Perl 6 Config::INI code&lt;/a&gt; as a starting point for a custom parser, for example, and I would have liked to have copied just that one &lt;a href=&quot;https://doc.perl6.org/language/operators#postfix_%C2%BB._%2F_postfix_%3E%3E.&quot; rel=&quot;noreferrer&quot;&gt;French quote character (a hyper operator)&lt;/a&gt; from &lt;a href=&quot;https://github.com/tadzik/perl6-Config-INI/blob/master/lib/Config/INI.pm#L26&quot; rel=&quot;noreferrer&quot;&gt;this line&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my %hash = $&amp;lt;sections&amp;gt;».ast;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could use the two character &quot;Texas&quot; version of the hyper operator &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;, but I thought that &lt;code&gt;&amp;gt;»&lt;/code&gt; looked better and less ambiguous than &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my %hash = $&amp;lt;sections&amp;gt;&amp;gt;&amp;gt;.ast;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4MoZx.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4MoZx.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/eK1EC.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eK1EC.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1111" LastEditorUserId="1111" LastEditDate="2017-03-29T19:38:33.023" LastActivityDate="2020-03-28T11:46:07.573" Title="How can I yank (copy) the single character on which the cursor rests?" Tags="|cut-copy-paste|" AnswerCount="4" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="5807" PostTypeId="1" CreationDate="2015-12-13T02:54:13.973" Score="4" ViewCount="60" Body="&lt;p&gt;When I first open vim, the Powerline plugin works as expected:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/YQa7B.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YQa7B.png&quot; alt=&quot;Normal Powerline&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I then switch to another buffer, the coloring of powerline's status bar is gone and it remains that way even if switching back to the original buffer:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Ha1fG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ha1fG.png&quot; alt=&quot;AfterBufferSwitch&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea why this is happening? How do I fix it?&lt;/p&gt;&#xA;" OwnerUserId="5636" LastEditorUserId="10604" LastEditDate="2019-10-27T16:16:16.703" LastActivityDate="2019-10-27T16:16:16.703" Title="Why do Powerline colors dim and stay dimmed when switching buffers?" Tags="|buffers|plugin-powerline|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="5810" PostTypeId="1" AcceptedAnswerId="5812" CreationDate="2015-12-13T12:03:45.173" Score="4" ViewCount="945" Body="&lt;p&gt;I'm looking for a command to delete a range of buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I launch vim which opens a new unnamed buffer.&lt;br&gt;&#xA;I then switch to a file on which I previously put the mark &lt;code&gt;N&lt;/code&gt; (&lt;code&gt;~/Dropbox/notes&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this file I've written:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e /tmp/foo&#xA;:e /tmp/bar&#xA;:e /tmp/baz&#xA;:e /tmp/qux&#xA;:e /tmp/norf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I visually select those five lines, and source them (&lt;code&gt;:&amp;lt;c-u&amp;gt;@*&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I've got 5 new buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I switch back to the &lt;code&gt;N&lt;/code&gt; file and do a listing (&lt;code&gt;ls&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1  h   &quot;[No Name]&quot;                    line 1&#xA;  2 %a   &quot;Dropbox/notes&quot;                line 139&#xA;  3  h   &quot;/tmp/foo&quot;                     line 1&#xA;  4  h   &quot;/tmp/bar&quot;                     line 1&#xA;  5  h   &quot;/tmp/baz&quot;                     line 1&#xA;  6  h   &quot;/tmp/qux&quot;                     line 1&#xA;  7 #h   &quot;/tmp/norf&quot;                    line 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to delete the 5 temporary buffers from 3 to 7.&lt;br&gt;&#xA;Most Ex commands accept a range, and I suppose &lt;code&gt;:bd&lt;/code&gt; is probably one of them. I may have misunderstood the help but it seems to confirm you can prefix &lt;code&gt;:bd&lt;/code&gt; with a range :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:N,Mbdelete[!]    Do &quot;:bdelete[!]&quot; for all buffers in the range N to M&#xA;        inclusive.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, I type &lt;code&gt;:3,7bd&lt;/code&gt; but the result is not what I expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the buffers from 2 to 7 were deleted, including my &lt;code&gt;N&lt;/code&gt; file and I'm automatically sent back to the unnamed buffer n° 1.&#xA;Here's the final output of &lt;code&gt;:ls&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1 %a   &quot;[No Name]&quot;                    line 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried other ranges like &lt;code&gt;5,6&lt;/code&gt; but the result is always the same, everything is unloaded except the first buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to pass a range to the &lt;code&gt;:bd&lt;/code&gt; command, and if so how ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I've found the cause of the problem, but I don't understand it.&#xA;It seems to happen only inside a buffer in which a fold has been created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how to reproduce it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;create a file &lt;code&gt;/tmp/test&lt;/code&gt; in which you put :&#xA;&lt;code&gt;&#xA;:e /tmp/foo&#xA;:e /tmp/bar&#xA;:e /tmp/baz&#xA;:e /tmp/qux&#xA;:e /tmp/norf&#xA;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;launch vim with an empty vimrc and edit the file &lt;code&gt;/tmp/test&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim -u NONE /tmp/test&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;source it to open 5 new buffers: &lt;code&gt;:so%&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;go back to first buffer (&lt;code&gt;/tmp/test&lt;/code&gt;): &lt;code&gt;:b1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;fold the whole buffer: &lt;code&gt;ggzfG&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;type &lt;code&gt;:ls&lt;/code&gt;:&#xA;&lt;code&gt;&#xA;  1 %a   &quot;/tmp/test&quot;                    line 1&#xA;  2      &quot;/tmp/foo&quot;                     line 1&#xA;  3      &quot;/tmp/bar&quot;                     line 1&#xA;  4      &quot;/tmp/baz&quot;                     line 1&#xA;  5      &quot;/tmp/qux&quot;                     line 1&#xA;  6 #    &quot;/tmp/norf&quot;                    line 1&#xA;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;type &lt;code&gt;:3,4bd&lt;/code&gt; to delete buffers from 3 to 4 (bar and baz).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On my system, vim deletes 5 buffers (1 to 5) instead of 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that the output of &lt;code&gt;:ls&lt;/code&gt; is:&#xA;&lt;code&gt;&#xA;  6 %a   &quot;/tmp/norf&quot;                    line 1&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I don't fold the buffer, the &lt;code&gt;:bd&lt;/code&gt; command interprets the range as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vim &lt;a href=&quot;https://paste.debian.net/plain/343732&quot; rel=&quot;nofollow&quot;&gt;version 7.4.942&lt;/a&gt; installed from this &lt;a href=&quot;https://launchpad.net/~pi-rho/+archive/ubuntu/dev&quot; rel=&quot;nofollow&quot;&gt;ppa&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is the behavior of the &lt;code&gt;:bd&lt;/code&gt; command modified when executed inside a buffer in which a fold has been created ?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-13T16:34:14.647" LastActivityDate="2015-12-13T18:06:54.993" Title="How to pass a range to the :bd command in a buffer in which a fold has been created?" Tags="|command-line|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5811" PostTypeId="2" ParentId="5806" CreationDate="2015-12-13T12:39:49.883" Score="101" Body="&lt;p&gt;Composing the yank operation with the so often used &quot;one character to the right&quot; motion should work: &lt;code&gt;yl&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW (to comment on a OP comment), for me &lt;code&gt;»&lt;/code&gt; can be yanked in this manner, in gVim or terminal Vim. Perhaps a (file)encoding issue?&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-12-13T19:16:07.460" LastActivityDate="2015-12-13T19:16:07.460" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5812" PostTypeId="2" ParentId="5810" CreationDate="2015-12-13T18:06:54.993" Score="4" Body="&lt;p&gt;This is mentioned briefly at &lt;code&gt;:h fold-behaviour&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;For Ex commands the range is adjusted to always start at the first line of a&#xA;closed fold and end at the last line of a closed fold.  Thus this command:&#xA;    :s/foo/bar/g&#xA;when used with the cursor on a closed fold, will replace &quot;foo&quot; with &quot;bar&quot; in&#xA;all lines of the fold.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can see, how this is confusing, but I am not sure, if this qualifies as a bug.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-12-13T18:06:54.993" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5813" PostTypeId="1" AcceptedAnswerId="5814" CreationDate="2015-12-13T20:03:19.890" Score="4" ViewCount="837" Body="&lt;p&gt;I want to run a function with a condition that checks for ANSI color escape codes when I open files but I don't know how to write the condition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I expect it to look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ? '^[[0;32m'&#xA;    &quot; stuff to do...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;^[[0;32m&lt;/code&gt; contains a control character instead a literal '^[')&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I write this?&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2015-12-13T20:43:37.337" Title="if/else condition for matching a regex in a file" Tags="|search|regular-expression|functions|" AnswerCount="1" CommentCount="0" ClosedDate="2015-12-13T23:35:32.273" ContentLicense="CC BY-SA 3.0" />
  <row Id="5814" PostTypeId="2" ParentId="5813" CreationDate="2015-12-13T20:43:37.337" Score="6" Body="&lt;p&gt;You can use the &lt;code&gt;search()&lt;/code&gt; function. Something like this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if search('\e\[\d\+;\d\+m', 'nW')&amp;gt;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-12-13T20:43:37.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5816" PostTypeId="2" ParentId="5619" CreationDate="2015-12-13T21:12:41.077" Score="3" Body="&lt;p&gt;A regex can be built to find variable declarations like &lt;code&gt;[A-z]…=[A-z0-9]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another for variable usage to include a &lt;code&gt;\$&lt;/code&gt; in the front&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My own yaml-specific .ctags example is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--regex-c=/^( YAML langdef config )/\1/k,t/&#xA;--langdef=yaml&#xA;--langmap=yaml:.yml.yaml&#xA;--regex-yaml=/^[ \t]*-[ \t]*.*:[ \t]*(.+)/\1/k,tasks/&#xA;--languages=+yaml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Modified for bash-isms of course. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--regex-sh=/^.*[ \t]*([A-Za-z][A-Za-z0-9_]*)=[&quot;.]*/\1/k,tasks/&#xA;--languages=+sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2303" LastEditorUserId="2303" LastEditDate="2015-12-13T23:00:21.630" LastActivityDate="2015-12-13T23:00:21.630" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5817" PostTypeId="2" ParentId="5619" CreationDate="2015-12-13T22:42:12.697" Score="4" Body="&lt;p&gt;based on the prompt from @Cometsong I added wrote the regex expression below and added to my &lt;code&gt;~/.ctags&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--regex-sh=/^[ \t]*(local)?[ \t]*([A-Za-z0-9_-]+)=/\2/v,variable,variables/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far it seems to be working quite nicely&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2015-12-13T22:42:12.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5818" PostTypeId="1" AcceptedAnswerId="5844" CreationDate="2015-12-14T08:26:03.530" Score="57" ViewCount="52333" Body="&lt;p&gt;I read the wiki entry on &lt;a href=&quot;http://vim.wikia.com/wiki/Indenting_source_code&quot; rel=&quot;noreferrer&quot;&gt;vim source code indentation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still can't understand the difference between &lt;code&gt;autoindent&lt;/code&gt; and &lt;code&gt;smartindent&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems they do the same thing, copy the indentation level to next line when you press &lt;code&gt;enter&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="6590" LastEditDate="2016-09-30T03:30:39.607" LastActivityDate="2021-09-08T21:29:35.333" Title="What is the difference between autoindent and smartindent in vimrc?" Tags="|indentation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5819" PostTypeId="1" AcceptedAnswerId="5821" CreationDate="2015-12-14T10:52:46.453" Score="9" ViewCount="849" Body="&lt;p&gt;I have words like &lt;code&gt;lblSERINOd&lt;/code&gt; in sentences. Words are separated by white space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to replace the &lt;code&gt;d&lt;/code&gt; at the end of all such words with &lt;code&gt;u&lt;/code&gt;. So for example &lt;code&gt;lblSERINOd&lt;/code&gt; will look like &lt;code&gt;lblSERINOu&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried &lt;code&gt;s/.*\ud /u /g&lt;/code&gt; but Vim says it cannot find &lt;code&gt;.*\ud&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the problem here?&lt;/p&gt;&#xA;" OwnerUserId="4840" LastActivityDate="2015-12-14T16:31:24.407" Title="How to match a word ending with uppercase letter and a specific letter?" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5820" PostTypeId="1" CreationDate="2015-12-14T11:28:53.533" Score="13" ViewCount="697" Body="&lt;p&gt;I'm trying to enhance an old completion function. I'd like it to update the choices displayed in the popup menu as I type new characters&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My completion function is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! lh#icomplete#ecm(findstart, base) abort&#xA;  if a:findstart&#xA;    let l = getline('.')&#xA;    let startcol = match(l[0:col('.')-1], '\v\S+$')&#xA;    if startcol == -1&#xA;      let startcol = col('.')-1&#xA;    endif&#xA;    &quot; let g:debug+= [&quot;findstart(&quot;.a:base.&quot;) -&amp;gt; &quot;.(startcol)]&#xA;    return startcol&#xA;  else&#xA;    &quot; let g:debug += [&quot;matching(&quot;.a:base.&quot;)&quot;]&#xA;    let words = ['un', 'deux', 'trois', 'trente-deux', 'unité']&#xA;    call filter(words, 'v:val =~ a:base')&#xA;    &quot; return { 'words' : words}&#xA;    return { 'words' : words, 'refresh' : 'always'}&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That I use with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set completefunc=lh#icomplete#ecm&#xA;:inoremap µ &amp;lt;c-x&amp;gt;&amp;lt;c-u&amp;gt;&amp;lt;c-p&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From my understanding of the documentation, the fact I use &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt;, I go into the &lt;em&gt;third state&lt;/em&gt; (according to |ins-completion-menu|), and when I type &lt;em&gt;&quot;any printable, non-white character&quot;&lt;/em&gt; I should be able to &lt;em&gt;&quot;Add this character and reduce the number of matches.&quot;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I type in insert mode &lt;code&gt;uµ&lt;/code&gt;, the completion menu pops-up as expected.&#xA;Alas when I type &lt;code&gt;x&lt;/code&gt; (just after the &lt;code&gt;µ&lt;/code&gt;), I'm out of completion mode and &lt;code&gt;ux&lt;/code&gt; is what I get in my buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What did I do wrong or missed in the documentation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: I've seen that without &lt;code&gt;refresh=always&lt;/code&gt;, results are filtered, except I'd like to call the function again in order to apply a custom filter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Just in case, I'm using gvim 7.4-908)&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2015-12-14T16:18:14.253" LastActivityDate="2017-01-30T22:00:56.967" Title="Dynamic completion" Tags="|autocompletion|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5821" PostTypeId="2" ParentId="5819" CreationDate="2015-12-14T11:56:48.813" Score="10" Body="&lt;p&gt;One way to do it would be this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\u\zsd\&amp;gt;/u/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Initially I assumed that the new Vim regex engine (being advertised as &quot;faster, but limited&quot;) can't understand &lt;code&gt;\u&lt;/code&gt; in &lt;code&gt;:substitute&lt;/code&gt;, but this isn't the case. I &lt;em&gt;rather&lt;/em&gt; think now that the OP forgot to use &lt;code&gt;%&lt;/code&gt; and simply searched on the wrong line; this would explain the error message, but of course still needs to be confirmed as &quot;the&quot; cause.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2015-12-14T16:31:24.407" LastActivityDate="2015-12-14T16:31:24.407" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5822" PostTypeId="2" ParentId="5819" CreationDate="2015-12-14T14:38:21.747" Score="5" Body="&lt;p&gt;It looks like you may have changed Vim's &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27magic%27&quot;&gt;&lt;code&gt;'magic'&lt;/code&gt;&lt;/a&gt; option from its default to &lt;code&gt;'nomagic'&lt;/code&gt;.  You can check this with the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set magic?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As documented at &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2Fmagic&quot;&gt;:help /magic&lt;/a&gt;, &lt;code&gt;'nomagic'&lt;/code&gt; causes the &lt;code&gt;.&lt;/code&gt; in a regexp to be treated as a literal dot instead of the metacharacter meaning &quot;match any character&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would &lt;strong&gt;highly&lt;/strong&gt; recommend leaving this option at its default value.  This is one of a few options that really shouldn't exist and can cause subtle problems in plugins.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2015-12-14T14:38:21.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5823" PostTypeId="1" AcceptedAnswerId="5824" CreationDate="2015-12-12T20:56:14.913" Score="8" ViewCount="268" Body="&lt;p&gt;My Vim config includes &lt;a href=&quot;http://goo.gl/dQVhzo&quot; rel=&quot;nofollow&quot;&gt;plugins that try to handle current project, build tags, etc&lt;/a&gt;. This is quite useful for my daily programming in Vim, but it's just annoying when I use Vim for some quick edits, like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;edit a git commit message;&lt;/li&gt;&#xA;&lt;li&gt;edit a shell command when I type &lt;kbd&gt;Ctrl+x&lt;/kbd&gt;&lt;kbd&gt;Ctrl+e&lt;/kbd&gt; in zsh or bash;&lt;/li&gt;&#xA;&lt;li&gt;etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I don't like the &lt;code&gt;--noplugins&lt;/code&gt; either, since I still want to take advantage of some plugins in quick-edit mode, such as surround, easy-motion, and lots of others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I want to have some &quot;light mode&quot; (or &quot;quick mode&quot;), in which some of the plugins will be bypassed, but not all of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first idea was to have some special command-line argument, which I'd parse in vimscript, but quick googling shows that it's currently impossible in vimscript (awful sad, by the way).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My second idea is to set some environment variable when running vim, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ VIM_LIGHT_MODE=1 vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works in git:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ git config --global core.editor 'VIM_LIGHT_MODE=1 vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I do &lt;code&gt;EDITOR='VIM_LIGHT_MODE=1 vim'&lt;/code&gt;, and type &lt;kbd&gt;Ctrl+x&lt;/kbd&gt;&lt;kbd&gt;Ctrl+e&lt;/kbd&gt; in the shell, it doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;edit-command-line:13: command not found: VIM_LIGHT_MODE=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I tried this: &lt;code&gt;EDITOR=&quot;bash -c 'VIM_LIGHT_MODE=1 vim'&quot;&lt;/code&gt;, but it fails as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim': -c: line 1: syntax error: unexpected end of file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(To be honest, this one looks particularly weird, it seems I misunderstand how exactly &lt;code&gt;$EDITOR&lt;/code&gt; is used, and I'll be glad if someone explains what's going on here)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All other experiments failed as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only hack I can think of is to set some &lt;code&gt;servername&lt;/code&gt;, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --servername VIM_LIGHTWEIGHT_MODE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then check &lt;code&gt;v:servername&lt;/code&gt; in vimscript, but this is a &lt;em&gt;total&lt;/em&gt; hack: this is not what servername is for, at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there a cleaner way to achieve what I want?&lt;/p&gt;&#xA;" OwnerUserId="2913" OwnerDisplayName="Dmitry Frank" LastEditorUserId="1238" LastEditDate="2015-12-16T17:06:54.980" LastActivityDate="2016-04-15T21:17:09.807" Title="How do I introduce a &quot;light mode&quot;, in which not all plugins are loaded?" Tags="|invocation|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5824" PostTypeId="2" ParentId="5823" CreationDate="2015-12-12T22:16:04.960" Score="10" Body="&lt;p&gt;There are (at least) two possibilities:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;use &lt;code&gt;env&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EDITOR='/usr/bin/env VIM_LIGHT_MODE=1 vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;use &lt;code&gt;vim&lt;/code&gt; with another initialization file, say &lt;code&gt;.vimrc-light&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EDITOR='/usr/bin/vim -u ~/.vimrc-light'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="963" OwnerDisplayName="gniourf_gniourf" LastActivityDate="2015-12-12T22:16:04.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5825" PostTypeId="2" ParentId="5806" CreationDate="2015-12-14T19:44:12.050" Score="23" Body="&lt;p&gt;Usually I press &lt;code&gt;vy&lt;/code&gt; (&lt;em&gt;visual yank&lt;/em&gt;), sometimes &lt;code&gt;xu&lt;/code&gt; (&lt;em&gt;delete undo&lt;/em&gt;) too. Also , if you want to yank the char before your cursor, instead of &lt;code&gt;lvy&lt;/code&gt;, you can press &lt;code&gt;Xu&lt;/code&gt;, I think that's the reason why I press &lt;code&gt;xu&lt;/code&gt; for the current. :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that, &lt;code&gt;Xu&lt;/code&gt; will make your cursor move to that char.&lt;/p&gt;&#xA;" OwnerUserId="1569" LastEditorUserId="1111" LastEditDate="2015-12-14T21:22:53.010" LastActivityDate="2015-12-14T21:22:53.010" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5826" PostTypeId="1" AcceptedAnswerId="5827" CreationDate="2015-12-14T20:47:28.367" Score="3" ViewCount="1037" Body="&lt;p&gt;In some keyboard, &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; are painful to hit. This is why I've remapped these 2 characters respectively to &lt;code&gt;aa&lt;/code&gt; and &lt;code&gt;pp&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap aa &amp;lt;&#xA;cnoremap aa &amp;lt;&#xA;inoremap pp &amp;gt;&#xA;cnoremap pp &amp;gt;&#xA;onoremap aa &amp;lt;&#xA;onoremap pp &amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is this binding doesn't work in the operator pending mode. Consider this example where _ is my cursor: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;tag&amp;gt; _foobar &amp;lt;/tag&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want my cursor to go to the &lt;code&gt;&amp;lt;&lt;/code&gt;, so I hit &lt;code&gt;faa&lt;/code&gt; but vim understands my command as : &lt;code&gt;fa&lt;/code&gt; + &lt;code&gt;a&lt;/code&gt; (go to the next &lt;code&gt;a&lt;/code&gt;, and append).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I change this behavior ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second question : I want it to be very fast, for example, if I type &lt;code&gt;fa&lt;/code&gt;, I don't want vim to wait for a second &lt;code&gt;a&lt;/code&gt;. So I've set a timeout:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ttimeout&#xA;set ttimeoutlen=10 &quot;ms&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These commands don't seem working, because if I press &lt;code&gt;a&lt;/code&gt; in insert mode and another &lt;code&gt;a&lt;/code&gt; 500 ms after (no chrono), a &lt;code&gt;&amp;lt;&lt;/code&gt; appear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for reading&lt;/p&gt;&#xA;" OwnerUserId="2513" LastActivityDate="2015-12-15T02:03:41.030" Title="vim, map character everywhere" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5827" PostTypeId="2" ParentId="5826" CreationDate="2015-12-14T21:57:12.480" Score="3" Body="&lt;p&gt;What is the purpose of the &lt;code&gt;:onoremap&lt;/code&gt; mappings ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to operate on tags without typing &lt;code&gt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;it&lt;/code&gt; and &lt;code&gt;at&lt;/code&gt; can help you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are two usage examples:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;cit&lt;/code&gt; = cut the text inside the tags (&lt;strong&gt;c&lt;/strong&gt;hange &lt;strong&gt;i&lt;/strong&gt;nside &lt;strong&gt;t&lt;/strong&gt;ags)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;yat&lt;/code&gt; = copy the tags and the text between them (&lt;strong&gt;y&lt;/strong&gt;ank &lt;strong&gt;a&lt;/strong&gt;round&#xA;&lt;strong&gt;t&lt;/strong&gt;ags)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If for some reasons, you can't or don't want to use the &lt;code&gt;it&lt;/code&gt; and &lt;code&gt;at&lt;/code&gt; objects and prefer &lt;code&gt;aa&lt;/code&gt; and &lt;code&gt;pp&lt;/code&gt; instead, here's a way to do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnoremap aa :&amp;lt;c-u&amp;gt;normal! T&amp;gt;vt&amp;lt;&amp;lt;cr&amp;gt;&#xA;:omap aa :&amp;lt;c-u&amp;gt;normal vaa&amp;lt;cr&amp;gt;&#xA;&#xA;:vnoremap pp :&amp;lt;c-u&amp;gt;normal! F&amp;lt;v2f&amp;gt;&amp;lt;cr&amp;gt;&#xA;:omap pp :&amp;lt;c-u&amp;gt;normal vpp&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the mappings in other modes (insert mode, command-line mode, argument of the &lt;code&gt;f&lt;/code&gt; command), there may be other ways, but you could try adding the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:lnoremap aa &amp;lt;&#xA;:lnoremap pp &amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I understood the help correctly, when you're in insert mode or command-line mode you will have to hit &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; to enable / disable those mappings (it will change the value of the &lt;code&gt;'iminsert'&lt;/code&gt; option):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In Insert mode and in Command-line mode the mappings can be disabled with&#xA;the CTRL-^ command i_CTRL-^ c_CTRL-^. These commands change the value of&#xA;the 'iminsert' option.  When starting to enter a normal command line (not a&#xA;search pattern) the mappings are disabled until a CTRL-^ is typed.  The state&#xA;last used is remembered for Insert mode and Search patterns separately.  The&#xA;state for Insert mode is also used when typing a character as an argument to&#xA;command like &quot;f&quot; or &quot;t&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help language-mapping&#xA;:help 'iminsert'&#xA;:help i_CTRL-^&#xA;:help c_CTRL-^&#xA;:help v_it&#xA;:help v_at&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-15T02:03:41.030" LastActivityDate="2015-12-15T02:03:41.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5828" PostTypeId="1" CreationDate="2015-12-14T22:52:46.473" Score="1" ViewCount="381" Body="&lt;pre&gt;&lt;code&gt;function! NERDTreeHighlightFile(extension, fg, bg)&#xA;    exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'&#xA;    exec 'autocmd filetype nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:bg .' guifg='. a:fg&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ripped this from a thread on the NERDTree file highlighting stufff. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So real quick, this function is working for all filetypes except for .c files, funnily enough the ones I use the most. I'm new to vim plugins and such though so have mercy lol. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm no pro at regex but it looks to me like there aren't any problems in that department. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone could figure this out that'd be dope. Thanks. &lt;/p&gt;&#xA;" OwnerUserId="5652" LastActivityDate="2015-12-14T22:52:46.473" Title="NERDTree file extension highlighting issue: c files not highlighted" Tags="|vimscript|vimrc|plugin-nerdtree|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5829" PostTypeId="1" CreationDate="2015-12-15T09:07:11.777" Score="2" ViewCount="1309" Body="&lt;p&gt;When starting vim in a mingw64 terminal emulator on windows, the command &lt;code&gt;:py print(1)&lt;/code&gt; fails, saying&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Could not load library msys-python2.7.dll&#xA;Sorry, this command is disabled, the Python library could not be loaded.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My vim installation DOES have python support, as &lt;code&gt;vim --version&lt;/code&gt; shows both &#xA;&lt;code&gt;python/dyn&lt;/code&gt; as &lt;code&gt;python3/dyn&lt;/code&gt;. Also, when executing the same command in gvim, no problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Needless to say, I have python installed, both 2 and 3)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be the cause of this problem?&lt;/p&gt;&#xA;" OwnerUserId="2455" LastActivityDate="2016-06-23T03:47:01.133" Title="Vimscript-python support not working in terminal" Tags="|terminal|microsoft-windows|vimscript-python|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5830" PostTypeId="2" ParentId="5823" CreationDate="2015-12-15T09:16:15.343" Score="3" Body="&lt;p&gt;While the accepted answer is certainly better, I'd like to discuss &lt;code&gt;EDITOR=&quot;bash -c 'VIM_LIGHT_MODE=1 vim'&quot;&lt;/code&gt;. The problem here is that &lt;code&gt;EDITOR&lt;/code&gt; is invoked with arguments, and the arguments passed to &lt;code&gt;bash -c&lt;/code&gt; do not get forwarded automatically to &lt;code&gt;vim&lt;/code&gt;. You need to use &lt;code&gt;&quot;$@&quot;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EDITOR=&quot;bash -c 'VIM_LIGHT_MODE=1 vim \&quot;\$@\&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the first argument after the command in &lt;code&gt;bash -c&lt;/code&gt; is &lt;code&gt;$0&lt;/code&gt;, which is not part of &lt;code&gt;$@&lt;/code&gt;, so you need to use a placeholder argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EDITOR=&quot;bash -c 'VIM_LIGHT_MODE=1 vim \&quot;\$@\&quot; lightvim' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With these pitfalls, it's not a good option, but workable nonetheless.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-12-15T09:16:15.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5831" PostTypeId="2" ParentId="5829" CreationDate="2015-12-15T10:49:53.793" Score="2" Body="&lt;p&gt;The &lt;code&gt;:help python-dynamic&lt;/code&gt; mentions the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To use the Python interface the Python DLL must be in your search&#xA;  path.  In a console window type &quot;path&quot; to see what directories are&#xA;  used.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The name of the DLL must match the Python version Vim was compiled&#xA;  with. Currently the name is &quot;python24.dll&quot;.  That is for Python 2.4. &#xA;  To know for sure edit &quot;gvim.exe&quot; and search for &quot;python\d*.dll\c&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Perhaps the python versions you installed doesn't matches the versions that Vim expects. It is also possible that there is a mismatch on the dll name.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-12-15T10:49:53.793" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5832" PostTypeId="1" CreationDate="2015-12-15T12:12:26.493" Score="1" ViewCount="278" Body="&lt;p&gt;I want to enable omnifunc in my MacVim whenever I start to type in a few of leading words, such that whenever I type &lt;code&gt;np.&lt;/code&gt;, the completion list pops up to show me the candidates (e.g. &lt;code&gt;np.random&lt;/code&gt;, &lt;code&gt;np.trunc&lt;/code&gt;, etc...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In default, you are bothered to type in &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; to make the list pop up. &lt;a href=&quot;https://stackoverflow.com/questions/3160744/show-vim-omnicomplete-on-certain-characters-instead-of-ctrl-x-ctrl-o&quot;&gt;In the post over Stack Overflow&lt;/a&gt;, some users assign the combination to different keymaps (e.g. just type in &lt;code&gt;:&lt;/code&gt; to make the list shown up).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I want to call the list without typing in any keys, much like you can do in Xcode. I also want to get out of the suggestion if I don't need it, much like in Xcode, which I think is not feasible in standard settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make it in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Vim 7.4 and neocomplete. &lt;/p&gt;&#xA;" OwnerUserId="1072" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2015-12-15T12:25:00.293" Title="How can I enable onmifunc completion automatically?" Tags="|key-bindings|autocompletion|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5833" PostTypeId="1" AcceptedAnswerId="5834" CreationDate="2015-12-15T13:26:32.663" Score="13" ViewCount="3171" Body="&lt;p&gt;I am using spell checker in vim, and I find one feature very annoying: errors are being highlighted with some weird color, which is nowhere to be found in gnome terminal settings:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u8gXn.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u8gXn.png&quot; alt=&quot;highlighted error&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I would like to change the highlight color to something else, so it doesn't obscure the &lt;code&gt;wordd&lt;/code&gt;, without changing my global font color. How can I configure this?&lt;/p&gt;&#xA;" OwnerUserId="2562" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-11-12T04:54:12.273" Title="Spell mistakes have weird coloring" Tags="|linux|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5834" PostTypeId="2" ParentId="5833" CreationDate="2015-12-15T16:04:09.900" Score="13" Body="&lt;p&gt;The &lt;code&gt;SpellBad&lt;/code&gt; highlighting group should allow you to configure the appearance of misspelled words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say you want them to be red on yellow background. Then you could add the following code somewhere in your vimrc file or in your colorscheme file (but in any case after the colorscheme has set up the &lt;code&gt;SpellBad&lt;/code&gt; group, otherwise it would override your settings):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight clear SpellBad&#xA;:highlight SpellBad ctermfg=009 ctermbg=011 guifg=#ff0000 guibg=#ffff00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;ctermfg&lt;/code&gt;, &lt;code&gt;ctermbg&lt;/code&gt; arguments control the colors of the foreground and background colors in a terminal while &lt;code&gt;guifg&lt;/code&gt;, &lt;code&gt;guibg&lt;/code&gt; do the same for vim inside a gui.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the terminal, the colors can be expressed with a name (red, yellow...) or a decimal code between 000 and 007 / 015 / 255 when it supports 8 / 16 / 256 colors.&#xA;You can check how many colors it supports from vim with: &lt;code&gt;echo &amp;amp;t_Co&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a gui, the colors can be expressed with a name or a code in hexadecimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a &lt;a href=&quot;https://commons.wikimedia.org/wiki/File:Xterm_256color_chart.svg&quot; rel=&quot;nofollow noreferrer&quot;&gt;chart&lt;/a&gt; which shows codes for some colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other highlighting groups (&lt;code&gt;SpellCap&lt;/code&gt;, &lt;code&gt;SpellLocal&lt;/code&gt; and &lt;code&gt;SpellRare&lt;/code&gt;) which control the appearance of other kinds of words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that setting the &lt;code&gt;'background'&lt;/code&gt; option causes your colorscheme to be reloaded.&#xA;So if you have &lt;code&gt;set background=dark&lt;/code&gt; somewhere in your vimrc, put the previous code which changes the &lt;code&gt;SpellBad&lt;/code&gt; group after that line, otherwise the colorscheme will again override your settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help hl-SpellBad&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="9942" LastEditDate="2019-11-12T04:54:12.273" LastActivityDate="2019-11-12T04:54:12.273" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="5835" PostTypeId="1" AcceptedAnswerId="5837" CreationDate="2015-12-15T17:03:15.237" Score="64" ViewCount="23830" Body="&lt;p&gt;I currently deal with lots of json files and am quite fond of the bash comand &lt;code&gt;jq&lt;/code&gt;, e.g. if I want to format the file I do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;jq . ugly.json &amp;gt; formated.json&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I don't want to leave vim, but run it directly within my current open file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!jq . %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;!&lt;/code&gt; runs a bash command&#xA;&lt;code&gt;%&lt;/code&gt; means the current file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet this only displays the result, yet does not update the content of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;hr&gt;&#xA;While writing this question I stumbled upon a solution yet don't know why it works. It would be great if someone could point out why &lt;code&gt;:%!jq .&lt;/code&gt; works.&lt;/p&gt;&#xA;" OwnerUserId="5449" LastEditorUserId="5449" LastEditDate="2015-12-15T17:08:22.897" LastActivityDate="2015-12-15T21:06:47.013" Title="How to run bash command over current file and replace buffer with result?" Tags="|external-command|bash|" AnswerCount="2" CommentCount="0" ClosedDate="2015-12-17T13:53:50.083" ContentLicense="CC BY-SA 3.0" />
  <row Id="5836" PostTypeId="2" ParentId="5835" CreationDate="2015-12-15T17:03:15.237" Score="21" Body="&lt;p&gt;By sheer luck I found out that both:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!jq . %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or shorter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!jq .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;work, yet I don't understand &lt;em&gt;why&lt;/em&gt; this updates the buffer.&lt;/p&gt;&#xA;" OwnerUserId="5449" LastActivityDate="2015-12-15T17:03:15.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5837" PostTypeId="2" ParentId="5835" CreationDate="2015-12-15T17:37:41.653" Score="66" Body="&lt;p&gt;&lt;code&gt;:!{cmd}&lt;/code&gt; sends &lt;code&gt;{cmd}&lt;/code&gt; to the shell which executes it and shows its output on the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:{range}!{filter}&lt;/code&gt; sends the lines from the current buffer inside &lt;code&gt;{range}&lt;/code&gt; as the input of the &lt;code&gt;{filter}&lt;/code&gt; program and replaces them with its output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your example, &lt;code&gt;:%!jq&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt; is the range, which means: &lt;em&gt;all the lines of the current buffer&lt;/em&gt;&lt;br&gt;&#xA;It could also be written &lt;code&gt;1,$&lt;/code&gt; (from the first line to the last one)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;jq&lt;/code&gt; is the filter program&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here's a &lt;a href=&quot;https://2.bp.blogspot.com/-TKrpj9ZOb_8/Ty8Z6uGef1I/AAAAAAAAASQ/5pEwFwtONkU/s1600/vim_ranges_p0.png&quot;&gt;page&lt;/a&gt; describing the various ways of writing a range.&lt;br&gt;&#xA;And on &lt;a href=&quot;https://4.bp.blogspot.com/-MhHrs8Q-S_A/UJpAuI_mOZI/AAAAAAAAAZ0/aJrXwjlvoYs/s1600/vim_pipes.png&quot;&gt;this page&lt;/a&gt;, you can find other usage examples of a filter program :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%! xxd [-r]&#xA;:%! column -t&#xA;:%! sort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one replaces a binary file with a hex dump (or the reverse with the &lt;code&gt;-r&lt;/code&gt; flag).&lt;br&gt;&#xA;The second one formats data from the file into a table.&lt;br&gt;&#xA;The third one sorts lines according to the first characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can test the third one, with this simple file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3 !&#xA;2 world&#xA;1 hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After typing &lt;code&gt;:%! sort&lt;/code&gt;, the buffer is replaced with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 hello&#xA;2 world&#xA;3 !&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you had typed &lt;code&gt;:!sort %&lt;/code&gt;, the output would have been displayed on the screen but would not have replaced the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the &lt;code&gt;%&lt;/code&gt; sign doesn't mean the same thing depending on where it is placed:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Before&lt;/strong&gt; the bang (and more generally before most Ex commands), it's&#xA;interpreted as a range (same as &lt;code&gt;1,$&lt;/code&gt;) which tells vim which lines&#xA;must be filtered.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;After&lt;/strong&gt; the bang (and more generally after most Ex commands), it's expanded as the name of the current file before the full command is sent to the shell.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help filter&#xA;:help range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-15T21:06:47.013" LastActivityDate="2015-12-15T21:06:47.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5838" PostTypeId="1" CreationDate="2015-12-15T18:42:03.193" Score="1" ViewCount="72" Body="&lt;p&gt;I was looking for a way to color stderr so when I ran &lt;code&gt;:!make target&lt;/code&gt;, I'd see the stderr lines pop up in red so I could more easily see what stopped my build.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inspired by this answer: &lt;a href=&quot;https://serverfault.com/a/59279&quot;&gt;https://serverfault.com/a/59279&lt;/a&gt;, I made the following file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;~/.vim/vim_bash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec 2&amp;gt; &amp;gt;(while read line; do echo -e &quot;\e[01;31m$line\e[0m&quot; &amp;gt;&amp;amp;2; done)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I'd run vim via:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BASH_ENV=~/.vim/vim_bash vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I'd do &lt;code&gt;:!make target-with-error&lt;/code&gt;, the stderr text now shows up as red.  Everything looks right to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if there's a better way to color stderr.  I'm mostly interested in avoiding some &quot;gotchas&quot; that I haven't thought of with using the exec command in this manner.  Thanks.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For those who tried this and like the effect, add &lt;code&gt;let $BASH_ENV=~/.vim/vim_bash&lt;/code&gt; to your .vimrc or .vim/vimrc file.&lt;/p&gt;&#xA;" OwnerUserId="5659" LastEditorUserId="-1" LastEditDate="2017-04-13T12:14:55.810" LastActivityDate="2015-12-15T19:21:51.347" Title="colored stderr when performing :!make" Tags="|vimrc|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5839" PostTypeId="2" ParentId="5785" CreationDate="2015-12-15T23:51:01.650" Score="3" Body="&lt;p&gt;As far as I know it is impossible to force &lt;code&gt;findfile()&lt;/code&gt;/&lt;code&gt;finddir()&lt;/code&gt; to return full paths, but it is possible to convert them to full paths using the &lt;code&gt;fnamemodify()&lt;/code&gt; function.  It takes two arguments: the path you want to modify, and the modifiers.  In this case, the modifier we are interested in is the &lt;code&gt;:p&lt;/code&gt; modifier.  This will take the given path and convert it to a full path.  This can then be used on the outputs of the &lt;code&gt;findfile()&lt;/code&gt; and &lt;code&gt;finddir()&lt;/code&gt; functions, though it is a little trickier since we must account for the fact that they may return a list instead of just a string.  Here is the solution I have come up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use ... to capture any and all arguments passed to this function&#xA;function! FindFileFP(...)&#xA;    &quot; Use the call function to call a function with all of the captured arguments&#xA;    &quot; as arguments to the specified function.&#xA;    let result = call(findfile, a:000)&#xA;    &quot; Check to see if the result is a list&#xA;    if type(result) == type([])&#xA;        &quot; Apply the fnamemodify function to every item in the list&#xA;        map(result, 'fnamemodify(v:val, &quot;:%p&quot;)')&#xA;    else&#xA;        &quot; Otherwise, just set the variable to the result of fnamemodify&#xA;        result = fnamemodify(result, ':%p')&#xA;    endif&#xA;    return result&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you can create a counterpart for the &lt;code&gt;finddir()&lt;/code&gt; function by simply changing all references to &lt;code&gt;findfile()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help, see &lt;code&gt;:help fnamemodify()&lt;/code&gt; and &lt;code&gt;:help filename-modifiers&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There may be a shorter way of doing this, improvements welcome.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2016-05-08T20:20:09.480" LastActivityDate="2016-05-08T20:20:09.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5841" PostTypeId="1" CreationDate="2015-12-16T11:54:22.403" Score="2" ViewCount="193" Body="&lt;p&gt;When I try to use a file name in a variable for the &lt;code&gt;cs add&lt;/code&gt; command, I cannot understand what happens. I'm using a bash script &lt;code&gt;myscript.sh&lt;/code&gt; which returns the path name of cscope database (&lt;code&gt;/mydir/cscope.out&lt;/code&gt;) based on the current file name (&lt;code&gt;/mydir/myfile.py&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let db = system(&quot;myscript.sh &quot; . expand(&quot;%:p&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After that, when I call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cs add db&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;E563: stat(/mydir/db) error 2&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;cs add &quot; . db&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;E563: stat(/mydir/cscope.out^@) error 2&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/mydir/cscope.out&lt;/code&gt; is the right file name which returned by &lt;code&gt;myscript.sh&lt;/code&gt;, but where the &lt;code&gt;^@&lt;/code&gt; thing comes from? How do I correctly use the variable with a parameter in this case?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. When &lt;code&gt;cs add&lt;/code&gt; is called with plain file name:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cs add /mydir/cscope.out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Connection is created OK and no errors is reported.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo db&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Displays:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/mydir/cscope.out&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1378" LastEditorUserId="205" LastEditDate="2015-12-16T12:31:57.067" LastActivityDate="2015-12-16T13:05:15.033" Title="Strange behaviour when using variables" Tags="|variables|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5842" PostTypeId="1" AcceptedAnswerId="5993" CreationDate="2015-12-16T12:34:11.077" Score="5" ViewCount="2410" Body="&lt;p&gt;When I hit &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; or type &lt;code&gt;:tag {indent}&lt;/code&gt;, vim does not jump to the first tag that matches the keyword under the cursor. Instead, it prompts me to select from multiple matches for the word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim mistakes &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; for &lt;code&gt;g&amp;lt;C-]&amp;gt;&lt;/code&gt; and &lt;code&gt;:tag {indent}&lt;/code&gt; for &lt;code&gt;tjump {indent}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When I launch vim without sourcing my &lt;code&gt;.vimrc&lt;/code&gt; file, &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; or &lt;code&gt;:tag {indent}&lt;/code&gt; is ok, whether all initializations are skipped with the argument &lt;code&gt;-u NONE&lt;/code&gt;, or just the plugins are sourced with the argument &lt;code&gt;-u NORC&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When I launch vim sourcing my &lt;code&gt;.vimrc&lt;/code&gt; file, &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; or &lt;code&gt;:tag {indent}&lt;/code&gt; goes wrong, whether I skip loading plugins with the argument &lt;code&gt;--noplugin&lt;/code&gt; or not.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5510" LastEditorUserId="5510" LastEditDate="2015-12-30T01:14:41.040" LastActivityDate="2015-12-30T01:14:41.040" Title="Exuberant Ctags: CTRL-] and &quot;:tag&quot; went wrong" Tags="|ctags|" AnswerCount="1" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5843" PostTypeId="2" ParentId="5841" CreationDate="2015-12-16T13:05:15.033" Score="2" Body="&lt;p&gt;If you're using GNU &lt;code&gt;find&lt;/code&gt; for this, then perhaps you can use the &lt;code&gt;-printf&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find /some/path -name cscope.out -printf '%p' -quit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will just print the path of the matched file without any additional characters. &lt;code&gt;-quit&lt;/code&gt; instructs it to exit after the first match. This should avoid the extra NUL and let you use the &lt;code&gt;:exe&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-12-16T13:05:15.033" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5844" PostTypeId="2" ParentId="5818" CreationDate="2015-12-16T15:55:51.493" Score="47" Body="&lt;p&gt;&lt;code&gt;autoindent&lt;/code&gt; essentially tells vim to apply the indentation of the current line to the next (created by pressing &lt;kbd&gt;enter&lt;/kbd&gt; in &lt;em&gt;insert&lt;/em&gt; mode or with &lt;kbd&gt;O&lt;/kbd&gt; or &lt;kbd&gt;o&lt;/kbd&gt; in &lt;em&gt;normal&lt;/em&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;smartindent&lt;/code&gt; reacts to the syntax/style of the code you are editing (especially for C). When having it &lt;em&gt;on&lt;/em&gt; you also should have &lt;code&gt;autoindent&lt;/code&gt; &lt;em&gt;on&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help autoindent&lt;/code&gt; also mentions two alternative settings: &lt;code&gt;cindent&lt;/code&gt; and &lt;code&gt;indentexpr&lt;/code&gt;, both of which make vim ignore the value of &lt;code&gt;smartindent&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1238" LastActivityDate="2015-12-16T15:55:51.493" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5845" PostTypeId="1" AcceptedAnswerId="6165" CreationDate="2015-12-16T17:17:44.270" Score="4" ViewCount="907" Body="&lt;p&gt;I am using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;esc&amp;gt; :noh&amp;lt;return&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to remove the highlighting after a search with &lt;code&gt;hlsearch&lt;/code&gt; on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, this shows &lt;code&gt;:noh&lt;/code&gt; in the command line. I would like to turn this off (preferably without any side effects).&lt;/p&gt;&#xA;" OwnerDisplayName="user5370" LastActivityDate="2016-01-19T10:09:39.690" Title="Do not show mapped command in command line" Tags="|command-line|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5846" PostTypeId="2" ParentId="5703" CreationDate="2015-12-16T19:22:58.480" Score="7" Body="&lt;p&gt;It's because of &lt;a href=&quot;https://github.com/airblade/vim-gitgutter&quot; rel=&quot;noreferrer&quot;&gt;vim-gitgutter&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to work correctly with git repos which mess around with line endings, e.g. via &lt;code&gt;core.crlf&lt;/code&gt;, I had to change how vim-gitgutter ran its diffs.  Previously it passed the contents of the buffer directly to &lt;code&gt;git-diff&lt;/code&gt; on stdin, via the second argument to vim's &lt;code&gt;system()&lt;/code&gt; call.  Now it has to create a temporary file for the buffer's contents and hand the file to &lt;code&gt;git-diff&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although the temporary file is never read into vim, and is deleted immediately after use, vim still increments the next available buffer number.  I find this inelegant but there it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a result, after you have been editing files for a while you end up with high buffer numbers.  I agree it's a bit surprising but it doesn't do any harm.&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2015-12-16T19:22:58.480" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5847" PostTypeId="1" AcceptedAnswerId="5848" CreationDate="2015-12-16T20:26:45.593" Score="3" ViewCount="477" Body="&lt;p&gt;My vimrc already has the very useful mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt; &amp;lt;gv&#xA;vnoremap &amp;gt; &amp;gt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using the TComment plugin, and I'd like to also do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap gc gcgv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to re-highlight a visual selection after toggling &lt;code&gt;gc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, as written, it just seems to prevent &lt;code&gt;gc&lt;/code&gt; from working. &lt;code&gt;vnoremap&lt;/code&gt; gives the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this with a simple mapping? Or should I write a function for it?&lt;/p&gt;&#xA;" OwnerUserId="4674" LastActivityDate="2015-12-16T20:38:26.383" Title="Why can't I remap `gc` to `gc` and then `gv`?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5848" PostTypeId="2" ParentId="5847" CreationDate="2015-12-16T20:38:26.383" Score="6" Body="&lt;p&gt;Indeed, you either defined a recursive mapping (&lt;code&gt;vmap&lt;/code&gt;), or one that doesn't know that &lt;code&gt;gc&lt;/code&gt; is supposed to comment something (&lt;code&gt;vnoremap&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution: do what &lt;code&gt;gc&lt;/code&gt; does (if you look at it with &lt;code&gt;:verbose vmap gc&lt;/code&gt;), and add &lt;code&gt;gv&lt;/code&gt; to it as you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:xmap gc &amp;lt;Plug&amp;gt;TComment_gcgv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does look strange. Maybe that's why other plugins use a format like &lt;code&gt;&amp;lt;Plug&amp;gt;(some_code)&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that (un)commenting may change the text &quot;bounding box&quot; and it won't necessarily correspond to the visual selection &lt;em&gt;before&lt;/em&gt; the operation.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2015-12-16T20:38:26.383" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5849" PostTypeId="1" CreationDate="2015-12-16T20:47:15.403" Score="5" ViewCount="198" Body="&lt;p&gt;I want to align a Latex table the way it appears in the final document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/r5dwr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/r5dwr.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are various Vim plugins for aligning tables (&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=294&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;, &lt;a href=&quot;https://github.com/junegunn/vim-easy-align&quot; rel=&quot;nofollow noreferrer&quot;&gt;3&lt;/a&gt;, &lt;a href=&quot;https://github.com/godlygeek/tabular&quot; rel=&quot;nofollow noreferrer&quot;&gt;4&lt;/a&gt;), but none of them handle the spanning cell correctly. The code should be aligned like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{tabular}{|c|c|c|}&#xA;    \multicolumn{2}{|c|}{spanning cell} &amp;amp; cell3 \\&#xA;    cell1 &amp;amp; cell2                       &amp;amp; cell3 \\&#xA;\end{tabular}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but ends up looking like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{tabular}{|c|c|c|}&#xA;    \multicolumn{2}{|c|}{spanning cell} &amp;amp; cell3 \\&#xA;    cell1                               &amp;amp; cell2 &amp;amp; cell3 \\&#xA;\end{tabular}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5682" LastEditorUserId="5682" LastEditDate="2015-12-17T00:05:17.813" LastActivityDate="2015-12-17T00:05:17.813" Title="How to align a Latex table that uses \multicolumn?" Tags="|formatting|filetype-tex|alignment|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5850" PostTypeId="1" CreationDate="2015-12-17T00:30:59.800" Score="2" ViewCount="151" Body="&lt;p&gt;I'm playing with conceal in help files to highlight / colour specific text strings which was working fine until I added the :print: example below. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QbIFA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QbIFA.png&quot; alt=&quot;conceal example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this concealed all the &lt;code&gt;:&lt;/code&gt; as expected so I tried to escape the &lt;code&gt;:&lt;/code&gt; around the word print&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :%s/[^[:print:]]//g : &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The original conceal statement was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match myIgnoreHc /[:#]|[#:]/ contained conceal -Oopswrong original&#xA;syn match myhelpCommentHc       &quot;[:#]\s.\{-}\s[:#]\s&quot; contains=myIgnoreHc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I changed the match to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match myIgnoreHc /[:#]\s\S\|\S\s[#:]/ contained conceal &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which worked if I wrote the &lt;code&gt;:print:&lt;/code&gt; as &lt;code&gt;: :print :&lt;/code&gt; however I'd prefer to escape or tell the parser to ignore the match in certain situations eg &lt;code&gt;::&lt;/code&gt; or &lt;code&gt;##&lt;/code&gt; as the &lt;code&gt;:print :&lt;/code&gt; isn't what I was after :).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="1313" LastEditorUserId="1313" LastEditDate="2015-12-17T05:17:46.030" LastActivityDate="2015-12-17T05:17:46.030" Title="escaping a character included in a conceal command vimscript" Tags="|vimscript|gvim|help-system|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5851" PostTypeId="1" AcceptedAnswerId="5852" CreationDate="2015-12-17T02:00:05.370" Score="43" ViewCount="33406" Body="&lt;p&gt;I want to teach myself to prefer hjkl more over the arrow keys in order to stay on the home row. (I am very aware that &lt;a href=&quot;http://vimcasts.org/blog/2013/02/habit-breaking-habit-making/&quot; rel=&quot;noreferrer&quot;&gt;one should not use hjkl as the main navigation keys&lt;/a&gt; as there are more powerful movement commands available yet this is more about breaking my habits in regards to the arrow keys.)&lt;/p&gt;&#xA;&lt;p&gt;In order to break that habit: How can I disable the arrow keys so that I am forced to use the hjkl or some other navigation method?&lt;/p&gt;&#xA;&lt;p&gt;As a bonus, it would be helpful if there was a message shown &lt;code&gt;Dont't use this!&lt;/code&gt; yet that it's not mandatory. If they don't work, it will be confusing enough for me to rethink my habits.&lt;/p&gt;&#xA;" OwnerUserId="5449" LastEditorUserId="5449" LastEditDate="2021-02-08T14:50:07.740" LastActivityDate="2023-01-26T17:32:34.993" Title="How to disable arrow keys in vim?" Tags="|key-bindings|cursor-movement|cursor-motions|" AnswerCount="8" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="5852" PostTypeId="2" ParentId="5851" CreationDate="2015-12-17T02:31:41.790" Score="32" Body="&lt;p&gt;You can install the &lt;a href=&quot;https://github.com/wikitopian/hardmode&quot; rel=&quot;noreferrer&quot;&gt;hardmode plugin&lt;/a&gt; and in your &lt;code&gt;.vimrc&lt;/code&gt; put in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:HardMode_level = 'wannabe'&#xA;let g:HardMode_hardmodeMsg = 'Don''t use this!'&#xA;autocmd VimEnter,BufNewFile,BufReadPost * silent! call HardMode()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't want to use a plugin (which may be a better choice, as you get to customise everything yourself!), use &lt;code&gt;nnoremap&lt;/code&gt;, &lt;code&gt;vnoremap&lt;/code&gt; and &lt;code&gt;inoremap&lt;/code&gt; on &lt;code&gt;&amp;lt;Left&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Right&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Down&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;PageUp&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;PageDown&amp;gt;&lt;/code&gt;, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Left&amp;gt; :echo &quot;No left for you!&quot;&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;Left&amp;gt; :&amp;lt;C-u&amp;gt;echo &quot;No left for you!&quot;&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;Left&amp;gt; &amp;lt;C-o&amp;gt;:echo &quot;No left for you!&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4729" LastEditorUserId="21947" LastEditDate="2019-04-25T07:20:32.813" LastActivityDate="2019-04-25T07:20:32.813" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5853" PostTypeId="1" AcceptedAnswerId="25204" CreationDate="2015-12-17T08:19:19.710" Score="8" ViewCount="920" Body="&lt;p&gt;I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;namespace&#xA;{&#xA;&#xA;template&amp;lt;typename T&amp;gt; &#xA;    struct One // This is the odd line&#xA;{&#xA;     // impl details&#xA;}&#xA;&#xA;template&amp;lt;typename T&amp;gt; &#xA;struct Two &#xA;{&#xA;     // impl details&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would want to change the indent rules to make it look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;namespace&#xA;{&#xA;&#xA;template&amp;lt;typename T&amp;gt; &#xA;struct One &#xA;{&#xA;     // impl details&#xA;}&#xA;&#xA;template&amp;lt;typename T&amp;gt; &#xA;struct Two &#xA;{&#xA;     // impl details&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Primary question&lt;/strong&gt; But I can't find what rule is causing the strange indentation. Is there a way to query vim for this information? (I know there is something like that in emacs)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Secondary question&lt;/strong&gt; If there is no such option, does someone know how I can make it look right? Note that it only happens immediately after a namespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current cinoptions is &lt;code&gt;cinoptions=:0,g0,=1s,(1s,N-s&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5693" LastEditorUserId="18609" LastEditDate="2020-05-08T17:00:51.360" LastActivityDate="2020-05-15T00:18:53.597" Title="Is it possible to get the rule (cinoptions) that govern the indentation for a specific line in vim" Tags="|vimrc|indentation|filetype-c++|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5854" PostTypeId="2" ParentId="5851" CreationDate="2015-12-17T09:18:25.120" Score="51" Body="&lt;p&gt;In case you, or someone else reading this topic, just wants to disable the key movements without the text warning enter the following lines in .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The commands will disable the key movement in normal, visual, select, and operator-pending modes. If you use &lt;code&gt;inoremap&lt;/code&gt; the arrow movement will be removed from only insert mode; &lt;code&gt;nnoremap&lt;/code&gt; will remove them from only normal mode, etc. See &lt;code&gt;:help :map-modes&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This massively popular topic deals with the differences between noremap, nnoremap, inoremap etc: &lt;a href=&quot;https://stackoverflow.com/questions/3776117/what-is-the-difference-between-the-remap-noremap-nnoremap-and-vnoremap-mapping&quot; title=&quot;Remapping in Vim.&quot;&gt;Remapping in Vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The general idea with remapping goes like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Choice-of-mode-to-remap &amp;lt;remap this command&amp;gt; &amp;lt;to this action/command instead&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in the other examples given you remap your left command to a text prompt which incidentally removes the action of actually moving the cursor. The example I gave above simply remaps the actions do to nothing, rather than something else. Consider it removing, rather than replacing, vim functionality.&lt;/p&gt;&#xA;" OwnerUserId="5695" LastEditorUserId="10604" LastEditDate="2020-06-11T12:46:24.667" LastActivityDate="2020-06-11T12:46:24.667" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5855" PostTypeId="1" CreationDate="2015-12-17T11:24:38.753" Score="5" ViewCount="583" Body="&lt;p&gt;It seems that spell-checking in vim is normally enabled at a buffer level (&lt;code&gt;set spell&lt;/code&gt; vs. &lt;code&gt;set nospell&lt;/code&gt;). However, sometimes it would be useful to ignore certain parts of a buffer (for example, URLs in text files often contain &quot;nonsense&quot; from a dictionary perspective, but are nevertheless valid and correct).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use the spell-checking support in vim only for parts of a buffer? For example, can one define regexes to ignore? Alternatively, are there any third-party spellcheckers for vim which can do this?&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="205" LastEditDate="2016-04-24T18:05:36.010" LastActivityDate="2016-04-24T18:05:36.010" Title="Is it possible to turn on spell-checking for only parts of buffers?" Tags="|regular-expression|spell-checking|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5856" PostTypeId="2" ParentId="5855" CreationDate="2015-12-17T12:25:10.260" Score="7" Body="&lt;p&gt;You can define syntax rule with the &lt;code&gt;@NoSpell&lt;/code&gt; keyword. From &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3asyn%2dspell&quot;&gt;&lt;code&gt;:help :syn-spell&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sy[ntax] spell [toplevel | notoplevel | default]&#xA;        This defines where spell checking is to be done for text that is not&#xA;        in a syntax item:&#xA;&#xA;        toplevel:       Text is spell checked.&#xA;        notoplevel:     Text is not spell checked.&#xA;        default:        When there is a @Spell cluster no spell checking.&#xA;&#xA;        For text in syntax items use the @Spell and @NoSpell clusters&#xA;        spell-syntax.  When there is no @Spell and no @NoSpell cluster then&#xA;        spell checking is done for &quot;default&quot; and &quot;toplevel&quot;.&#xA;&#xA;        To activate spell checking the 'spell' option must be set.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, to not spell URLs, you could use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn match url /\(\s\|^\s*\*\?\)\@&amp;lt;=\(http\|https\|ftp\):\/\/[-0-9a-zA-Z_?&amp;amp;=+#%/.!':;@~]\+/ contains=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Many syntax files use this. To the best of my knowledge this is the only way to tell the Vim spell checker to ignore certain parts.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-12-17T12:25:10.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5857" PostTypeId="2" ParentId="5656" CreationDate="2015-12-17T12:55:56.403" Score="2" Body="&lt;p&gt;Assuming that &lt;code&gt;MATCH ME&lt;/code&gt; is always a single line, you can use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^MATCH ME/-1,+1d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First, &lt;code&gt;:g/^MATCH ME/&lt;/code&gt; will search for all instances of &lt;code&gt;MATCH ME&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;We then run the &lt;code&gt;:d&lt;/code&gt; (&lt;code&gt;:delete&lt;/code&gt;) command on everything that matches with &lt;code&gt;:g&lt;/code&gt;, but we also add a range of &lt;code&gt;-1,+1&lt;/code&gt;, meaning one line before and one line after the matched line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If your &lt;code&gt;MATCH ME&lt;/code&gt; pattern may consist of multiple lines, we need a slightly more advanced version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^MATCH ME/call DeleteBetween('&amp;lt;div class=&quot;myclass&quot;&amp;gt;', '&amp;lt;\/div&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of adding a whole bunch on the command-line (which quickly becomes unreadable), I created a little helper function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! DeleteBetween(start, end)&#xA;    &quot; Reverse search for where we should start deleting&#xA;    execute '?' . a:start&#xA;&#xA;    &quot; Remember the line number&#xA;    let l:start = line('.')&#xA;&#xA;    &quot; Forward search for when we should stop deleting&#xA;    execute '/' . a:end&#xA;&#xA;    &quot; And delete the line range (:4,8d)&#xA;    execute ':' . l:start . ',' . line('.') . 'd'&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-12-17T12:55:56.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5858" PostTypeId="2" ParentId="5603" CreationDate="2015-12-17T13:06:43.177" Score="2" Body="&lt;p&gt;I'm not entirely sure what you mean, but I believe that &lt;code&gt;:set autoindent&lt;/code&gt; should do what you expect. From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27autoindent%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help 'autoindent'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Copy indent from current line when starting a new line (typing  in Insert mode or when using the &quot;o&quot; or &quot;O&quot; command). If you do not type anything on the new line except  or CTRL-D and then type , CTRL-O or , the indent is deleted again.  Moving the cursor to another line has the same effect, unless the 'I' flag is included in 'cpoptions'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-12-17T13:06:43.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5859" PostTypeId="2" ParentId="5333" CreationDate="2015-12-17T13:38:04.093" Score="1" Body="&lt;p&gt;You can create a mapping for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnoremap &amp;lt;C-j&amp;gt; jojo&#xA;:vnoremap &amp;lt;C-k&amp;gt; koko&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case I mapped it in visual mode to &lt;kbd&gt;Ctrl+j&lt;/kbd&gt; and &lt;kbd&gt;Ctrl+k&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-12-17T13:38:04.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5860" PostTypeId="2" ParentId="5804" CreationDate="2015-12-17T14:03:47.063" Score="2" Body="&lt;p&gt;Apparat's answer works for gVim; if you're using Vim from within a Terminal, you will need to configure the terminal to change the font size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Xterm, I like to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;XTerm*VT100.translations: #override \n\&#xA;    Ctrl &amp;lt;KeyPress&amp;gt; =:larger-vt-font() \n\&#xA;    Ctrl &amp;lt;KeyPress&amp;gt; -:smaller-vt-font()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my &lt;code&gt;~/.Xdefaults&lt;/code&gt; to change the font size with &lt;code&gt;CTRL +&lt;/code&gt; and &lt;code&gt;CTRL -&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some terminals also respond to escape codes to set the font; for Xterm I've never been able to get that to work correctly, though...&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-12-17T14:03:47.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5862" PostTypeId="2" ParentId="4572" CreationDate="2015-12-17T14:36:41.720" Score="3" Body="&lt;p&gt;Doing this truly automatically is difficult. Vim doesn't know what is &quot;indentation&quot; and what is &quot;alignment&quot;; and some people may disagree on what exactly constitutes indentation and alignment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=231&quot; rel=&quot;nofollow&quot;&gt;Smart Tabs plugin&lt;/a&gt; is designed to do what you want; I found that it works reasonably well for C files, but has a number of caveats; it &lt;strong&gt;breaks&lt;/strong&gt; Python files, for example, and does some unexpected (for me, anyway) things for C files at times.&lt;br&gt;&#xA;Looking at the source, I can't really figure out how it works in 5 minutes, and combined with the fact that it breaks some stuff, should tell you to proceed carefully...&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-12-17T14:36:41.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5863" PostTypeId="1" CreationDate="2015-12-17T15:15:13.667" Score="4" ViewCount="472" Body="&lt;p&gt;If I start vim in Ex-mode, I can have it print the entire file with &lt;code&gt;%print&lt;/code&gt;, but it just prints the raw text. Is there a command I can use to get it to print the file with syntax highlighting?&lt;/p&gt;&#xA;" OwnerUserId="361" LastActivityDate="2015-12-19T18:04:29.763" Title="Printing syntax highlighting in ex-mode" Tags="|syntax-highlighting|ex-mode|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5864" PostTypeId="1" CreationDate="2015-12-17T16:40:01.683" Score="6" ViewCount="1232" Body="&lt;p&gt;In my vimrc I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap Q gw&#xA;nmap Q gwap&#xA;set formatoptions+=cj&#xA;set formatoptions-=t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This disables automatic text wrapping, and allows me to correctly wrap the paragraph my cursor is on right now by pressing &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;Q&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, formatting a paragraph is exactly what I want to do, but here's an example of where it's wrong:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# This is a long comment in a Python file. It is longer than 80 characters, and should get wrapped.&#xA;def a_function():&#xA;    &quot;&quot;&quot;This is still in the same paragraph.&quot;&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, when I put my cursor on the comment and press &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;Q&lt;/kbd&gt;, this happens:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# This is a long comment in a Python file. It is longer than 80 characters, and&#xA;# should get wrapped.&#xA;def a_function(): &quot;&quot;&quot;This is still in the same paragraph.&quot;&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want the following to happen:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# This is a long comment in a Python file. It is longer than 80 characters, and&#xA;# should get wrapped.&#xA;def a_function():&#xA;    &quot;&quot;&quot;This is still in the same paragraph.&quot;&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a combination of commands or a plugin that does this? I want to use the same key to wrap regular text and comments, and use paragraphs for text, but when my cursor is on a comment I want the wrapping to be limited to the comment.&lt;/p&gt;&#xA;" OwnerUserId="260" LastActivityDate="2017-04-26T09:35:19.673" Title="Reformat within comment" Tags="|formatting|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5865" PostTypeId="1" CreationDate="2015-12-17T20:06:40.713" Score="1" ViewCount="34" Body="&lt;p&gt;I made a few folds in my file, but they were gone after I closed it. I'd like to save them somehow somewhere, and teach vim to automatically load them when I open this file.&lt;/p&gt;&#xA;" OwnerUserId="5365" LastActivityDate="2015-12-17T20:06:40.713" Title="How to save folds?" Tags="|folding|" AnswerCount="0" CommentCount="1" ClosedDate="2015-12-17T23:01:10.103" ContentLicense="CC BY-SA 3.0" />
  <row Id="5867" PostTypeId="1" AcceptedAnswerId="10327" CreationDate="2015-12-17T21:33:25.083" Score="4" ViewCount="1137" Body="&lt;p&gt;&lt;strong&gt;Notice&lt;/strong&gt;:&#xA;I hope this question fits our site, I'm open to any comments.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've been a Vim user for 15 years now, always as an editor on its own, with some IDE functionalities such as autocompletion among others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now at work I've had to use NetBeans, and I installed &lt;a href=&quot;http://jvi.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;jVi&lt;/a&gt;. It works pretty well, provided you've enabled some settings&lt;sup&gt;[1]&lt;/sup&gt;, with only a few missing features like plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any review or experience regarding the integration of Vim with NetBeans in comparison with the integration of Vim with Eclipse (whose only plugin I know of is &lt;a href=&quot;https://marketplace.eclipse.org/content/vrapper-vim&quot; rel=&quot;nofollow&quot;&gt;Vrapper&lt;/a&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to know is: should I consider Eclipse as an alternative to NetBeans regarding only its integration with respect to Vim?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;[1]: The most important setting is enabling (both on Linux [what I use] or Mac): &quot;Mac Retina Cursor Xor Bug&quot;.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="1957" LastEditorUserId="23502" LastEditDate="2022-09-08T18:37:49.443" LastActivityDate="2022-09-08T18:37:49.443" Title="Integration (or emulation) of Vim with NetBeans or Eclipse" Tags="|ide|plugin-eclim|vrapper|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5868" PostTypeId="2" ParentId="5806" CreationDate="2015-12-17T22:26:11.270" Score="10" Body="&lt;p&gt;The simplest way I know to do this is to use &lt;code&gt;x&lt;/code&gt; to delete the character, which also puts it in the buffer, and then &lt;code&gt;P&lt;/code&gt; to put it back.  You can then move the cursor around and paste the character back wherever you want it with &lt;code&gt;p&lt;/code&gt; (after cursor) or &lt;code&gt;P&lt;/code&gt; (before cursor), as long as you do not change the buffer.&lt;/p&gt;&#xA;" OwnerUserId="5705" LastEditorUserId="21" LastEditDate="2015-12-18T07:28:31.720" LastActivityDate="2015-12-18T07:28:31.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5869" PostTypeId="1" AcceptedAnswerId="5871" CreationDate="2015-12-17T22:32:14.180" Score="5" ViewCount="2263" Body="&lt;p&gt;In bash one can edit the current commandline in &lt;code&gt;$EDITOR&lt;/code&gt; by pressing &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-e&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running bash inside a terminal buffer within Neovim. I would like to be able to press &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-e&amp;gt;&lt;/code&gt; and have Neovim open a new buffer (&lt;code&gt;:new&lt;/code&gt;), in the same Neovim instance, with the current contents of the commandline. When I close that buffer (&lt;code&gt;:bdelete&lt;/code&gt;) I would like to have the contents of the buffer replace what was on the commandline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="1472" LastActivityDate="2017-05-03T21:08:09.600" Title="Edit Neovim terminal commandline within the same Neovim instance" Tags="|terminal|external-command|neovim|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5870" PostTypeId="1" AcceptedAnswerId="5879" CreationDate="2015-12-18T00:20:02.123" Score="7" ViewCount="2132" Body="&lt;p&gt;If I have changed a bunch of files but without saving and maybe I have another pile of noname buffers which are changed and without a file name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want vim to prompt confirmation for each one of the above files. if it's a changed file without saving then ask me whether to save it. if it's a noname buffer asking me whether to save it, if yes then provide a file name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's just like in some other modeless editor, when you edit a lot of files and click the close button to close the editor, it'll prompt confirmations.&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="1276" LastEditDate="2015-12-18T01:43:52.780" LastActivityDate="2015-12-18T10:50:25.727" Title="How to safely quit vim if there's some unsaved changes?" Tags="|quit|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5871" PostTypeId="2" ParentId="5869" CreationDate="2015-12-18T00:54:05.097" Score="3" Body="&lt;p&gt;I've now turned the script below into a plugin: &lt;a href=&quot;https://github.com/brettanomyces/nvim-editcommand&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvim-editcommand&lt;/a&gt;, or if you don't mind starting you terminals with a plugin command &lt;a href=&quot;https://github.com/brettanomyces/nvim-terminus&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvim-terminus&lt;/a&gt; provides a few more features&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Finally got it working in pure (ugly) vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    &quot; set the name of the current buffer, useful for setting the name of terminal buffers&#xA;function! SetFileName()&#xA;  execute 'file ' . input('Enter name: ')&#xA;endfunction&#xA;&#xA;&quot; - yank from last line with prompt ('&amp;gt; ') to last line into register c&#xA;&quot; - clear commandline&#xA;&quot; - call function&#xA;tnoremap &amp;lt;c-x&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;:execute ':?&amp;gt; ?,$y c'&amp;lt;cr&amp;gt;A&amp;lt;c-c&amp;gt;&amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;:call EditCommandline()&amp;lt;cr&amp;gt;&#xA;&#xA;function! EditCommandline()&#xA;  &quot; clear search highlighting&#xA;  let @/ = &quot;&quot;&#xA;&#xA;  &quot; - set an autocmd on the current (terminal) buffer that will run when the buffer is next entered&#xA;  &quot; - put from register c (where the new command will be)&#xA;  &quot; - remove the autocmd&#xA;  &quot; - go to insert mode&#xA;  autocmd BufEnter &amp;lt;buffer&amp;gt; put c | autocmd! BufEnter &amp;lt;buffer&amp;gt; | call feedkeys('A')&#xA;&#xA;  &quot; get all text after prompt '&amp;gt; '&#xA;  let s:command = strpart(@c, strridx(@c, &quot;&amp;gt; &quot;) + 2)&#xA;&#xA;  &quot; open new empty buffer&#xA;  new &#xA;&#xA;  &quot; make buffer a scratch buffer&#xA;  setlocal buftype=nofile&#xA;  setlocal bufhidden=hide&#xA;  setlocal noswapfile&#xA;&#xA;  &quot; put command into buffer&#xA;  put! =s:command&#xA;&#xA;  &quot; remove extra lines&#xA;  %join!&#xA;&#xA;  &quot; copy buffer to register when it is closed&#xA;  autocmd BufLeave &amp;lt;buffer&amp;gt; :%yank c&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1472" LastEditorUserId="1472" LastEditDate="2017-05-03T21:08:09.600" LastActivityDate="2017-05-03T21:08:09.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5872" PostTypeId="1" AcceptedAnswerId="5876" CreationDate="2015-12-18T03:37:07.520" Score="3" ViewCount="3071" Body="&lt;p&gt;I'm new to vi/vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I learned that I can close a file I'm editing and open the another file at once by typing &lt;code&gt;:vi filename&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I sometimes want to open other files without closing the file I'm editing and interchange these buffers with commands like &lt;code&gt;:next&lt;/code&gt; or &lt;code&gt;:prev&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I haven't understand the difference among &lt;code&gt;buffer&lt;/code&gt;, &lt;code&gt;window&lt;/code&gt; and &lt;code&gt;file&lt;/code&gt; exactly yet. So some words could be wrong I used avobe.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my vim's version is 7.2, Small version without GUI and be used on CentOS6.7&lt;/p&gt;&#xA;" OwnerUserId="2951" LastEditorUserId="2951" LastEditDate="2015-12-18T04:03:46.413" LastActivityDate="2015-12-23T12:13:20.093" Title="Can I open other files without closing the file I'm editing?" Tags="|buffers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5873" PostTypeId="1" AcceptedAnswerId="5875" CreationDate="2015-12-18T05:02:33.063" Score="4" ViewCount="944" Body="&lt;p&gt;When I define key mappings, I prefer using a modifier key with another key, because modifier key can make you so much fast if you need to press some key mapping multiple times, you only need to hold down the modifier key once and keep pressing the other key. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;br&gt;&#xA;say if I map &lt;code&gt;ctrl j&lt;/code&gt; to cycle through opening windows. I just need to hold down &lt;code&gt;ctrl&lt;/code&gt; once and press several time &lt;code&gt;j&lt;/code&gt; to get to the window I want. that's just &lt;code&gt;1 * ctrl + n * j&lt;/code&gt; key strokes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; key is different. &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; key is not modifier key. So if map &lt;code&gt;&amp;lt;leader&amp;gt; j&lt;/code&gt; to cycle through windows. I need to repeat: press &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;, press &lt;code&gt;j&lt;/code&gt; several times. that's &lt;code&gt;n * &amp;lt;leader&amp;gt; + n * j&lt;/code&gt; key strokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there any chance I can make the &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; key modifier? or if you know some other way I can define my own modifier key?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="1821" LastEditDate="2016-06-20T07:52:09.967" LastActivityDate="2016-06-20T07:52:09.967" Title="Can I make &lt;leader&gt; key modifier, or is there anyway I can get more custom modifier key?" Tags="|key-bindings|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5874" PostTypeId="2" ParentId="5873" CreationDate="2015-12-18T06:58:41.670" Score="4" Body="&lt;p&gt;You can't turn the &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; key into a modifier key and you can't create your own modifier keys.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-18T06:58:41.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5875" PostTypeId="2" ParentId="5873" CreationDate="2015-12-18T07:35:22.943" Score="6" Body="&lt;p&gt;As has been said, this is not directly possible. There exists however plugins that create clever maps to achieve something similar: &lt;a href=&quot;https://github.com/tomtom/tinykeymap_vim/&quot;&gt;tinykeymap&lt;/a&gt;, &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2223&quot;&gt;tinymode&lt;/a&gt; or &lt;a href=&quot;https://github.com/kana/vim-submode&quot;&gt;vim-submode&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-12-18T07:35:22.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5876" PostTypeId="2" ParentId="5872" CreationDate="2015-12-18T07:44:48.880" Score="7" Body="&lt;p&gt;First, I want to recommend that you go through the vimtutor (&lt;code&gt;:h tutor&lt;/code&gt;). That will explain a lot of the different concepts in Vim. To learn about the difference between the buffers, windows and a file, you can read for instance: &lt;code&gt;:h windows.txt&lt;/code&gt; and &lt;code&gt;:h editing.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;:vi&lt;/code&gt; or &lt;code&gt;:visual&lt;/code&gt; is used to get out of ex mode and back to normal mode. If you don't know what ex mode is, then I suggest you instead use the command &lt;code&gt;:e ...&lt;/code&gt; to edit new files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to close a file, but leave the buffer open, I suggest that you use the option &lt;code&gt;:set hidden&lt;/code&gt;. See &lt;code&gt;:h 'hidden'&lt;/code&gt; for a detailed explanation. In short, this will set closed buffers to hidden instead of wiping them. Thus you can reopen closed files with &lt;code&gt;:bnext&lt;/code&gt; and &lt;code&gt;:bprev&lt;/code&gt; and similar.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-12-18T07:44:48.880" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5877" PostTypeId="2" ParentId="5864" CreationDate="2015-12-18T07:48:09.617" Score="5" Body="&lt;p&gt;The problem is, your motion &quot;&lt;a href=&quot;https://vimhelp.appspot.com/motion.txt.html#ap&quot; rel=&quot;noreferrer&quot;&gt;ap&lt;/a&gt;&quot; moves to the end of a paragraph. And a &lt;a href=&quot;https://vimhelp.appspot.com/motion.txt.html#paragraph&quot; rel=&quot;noreferrer&quot;&gt;paragraph&lt;/a&gt; is defined as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A paragraph begins after each empty line, and also at each of a set of&#xA;paragraph macros, specified by the pairs of characters in the 'paragraphs'&#xA;option.  The default is &quot;IPLPPPQPP TPHPLIPpLpItpplpipbp&quot;, which corresponds to&#xA;the macros &quot;.IP&quot;, &quot;.LP&quot;, etc.  (These are nroff macros, so the dot must be in&#xA;the first column).  A section boundary is also a paragraph boundary.&#xA;Note that a blank line (only containing white space) is NOT a paragraph&#xA;boundary.&#xA;Also note that this does not include a '{' or '}' in the first column.  When&#xA;the '{' flag is in 'cpoptions' then '{' in the first column is used as a&#xA;paragraph boundary posix.&#xA;&#xA;                                                        section&#xA;A section begins after a form-feed (&amp;lt;C-L&amp;gt;) in the first column and at each of&#xA;a set of section macros, specified by the pairs of characters in the&#xA;'sections' option.  The default is &quot;SHNHH HUnhsh&quot;, which defines a section to&#xA;start at the nroff macros &quot;.SH&quot;, &quot;.NH&quot;, &quot;.H&quot;, &quot;.HU&quot;, &quot;.nh&quot; and &quot;.sh&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means, Vim does as you told and formats the paragraph. You could either add an empty line before your function definition or use a different motion, (since essentialy, this is what they are for ;)) like e.g. the suggested &lt;code&gt;gqj&lt;/code&gt; or alternatively use visual mode like this &lt;code&gt;Vq&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-12-18T07:48:09.617" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="5878" PostTypeId="1" AcceptedAnswerId="5883" CreationDate="2015-12-18T09:57:28.030" Score="9" ViewCount="3932" Body="&lt;p&gt;Today, I found my &lt;code&gt;.vimrc&lt;/code&gt; didn't take effect. It was ok just hours ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I launched vim with &lt;code&gt;$vim --plugin&lt;/code&gt;, &lt;code&gt;:scriptnames&lt;/code&gt; echoed nothing: &lt;code&gt;.vimrc&lt;/code&gt; file was not sourced. (Note: &lt;code&gt;/etc/vimrc&lt;/code&gt; was removed to debug this problem.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I tried to google and found &lt;code&gt;$VIMINIT&lt;/code&gt; variable suspicious. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the value of &lt;code&gt;$VIMINIT&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo $VIMINIT&#xA;set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim documentation about &lt;code&gt;VIMINIT&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; c. Four places are searched for initializations.  The first that exists&#xA;    is used, the others are ignored.  The $MYVIMRC environment variable is&#xA;    set to the file that was first found, unless $MYVIMRC was already set.&#xA;    -  The environment variable VIMINIT (see also |compatible-default|) (*)&#xA;       The value of $VIMINIT is used as an Ex command line.&#xA;    -  The user vimrc file(s):&#xA;                &quot;$HOME/.vimrc&quot;      (for Unix and OS/2) (*)&#xA;                &quot;s:.vimrc&quot;          (for Amiga) (*)&#xA;                &quot;home:.vimrc&quot;       (for Amiga) (*)&#xA;                &quot;$VIM/.vimrc&quot;       (for OS/2 and Amiga) (*)&#xA;                &quot;$HOME/_vimrc&quot;      (for MS-DOS and Win32) (*)&#xA;                &quot;$VIM/_vimrc&quot;       (for MS-DOS and Win32) (*)&#xA;            Note: For Unix, OS/2 and Amiga, when &quot;.vimrc&quot; does not exist,&#xA;            &quot;_vimrc&quot; is also tried, in case an MS-DOS compatible file&#xA;            system is used.  For MS-DOS and Win32 &quot;.vimrc&quot; is checked&#xA;            after &quot;_vimrc&quot;, in case long file names are used.&#xA;            Note: For MS-DOS and Win32, &quot;$HOME&quot; is checked first.  If no&#xA;            &quot;_vimrc&quot; or &quot;.vimrc&quot; is found there, &quot;$VIM&quot; is tried.&#xA;            See |$VIM| for when $VIM is not set.&#xA;    -  The environment variable EXINIT.&#xA;       The value of $EXINIT is used as an Ex command line.&#xA;    -  The user exrc file(s).  Same as for the user vimrc file, but with&#xA;       &quot;vimrc&quot; replaced by &quot;exrc&quot;.  But only one of &quot;.exrc&quot; and &quot;_exrc&quot; is&#xA;       used, depending on the system.  And without the (*)!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could not understand the vim documentation fully. It seems that &lt;code&gt;$VIMINIT&lt;/code&gt; may mess the startup of vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clear &lt;code&gt;$VIMINIT&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ VIMINIT=&#xA;$ echo $VIMINIT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem still exist.&lt;/p&gt;&#xA;" OwnerUserId="5510" LastEditorUserId="5510" LastEditDate="2015-12-19T01:58:38.310" LastActivityDate="2015-12-19T01:58:38.310" Title="Why won't vim source my .vimrc file" Tags="|vimrc|invocation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5879" PostTypeId="2" ParentId="5870" CreationDate="2015-12-18T10:38:11.667" Score="12" Body="&lt;p&gt;The option &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27confirm%27&quot;&gt;&lt;code&gt;confirm&lt;/code&gt;&lt;/a&gt; does what you describe for modified files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set confirm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my vimrc, it gives the following prompt when I &lt;code&gt;:quit&lt;/code&gt; a modified NoName buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Save changes to &quot;Untitled&quot;?&#xA;[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For me, if it's an unnamed buffer and you answer &lt;code&gt;(Y)es&lt;/code&gt; to the prompt, it opens it. You could then &lt;code&gt;:write filename&lt;/code&gt;, and &lt;code&gt;:qall&lt;/code&gt; again (seems like any buffers you've already said &lt;code&gt;(N)o&lt;/code&gt; to the prompt are cleared).&lt;/p&gt;&#xA;" OwnerUserId="4655" LastEditorUserId="4655" LastEditDate="2015-12-18T10:50:25.727" LastActivityDate="2015-12-18T10:50:25.727" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5880" PostTypeId="1" CreationDate="2015-12-18T10:43:23.453" Score="8" ViewCount="1393" Body="&lt;p&gt;According to &lt;code&gt;h: help&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use the 'history' option to set the number of lines that are remembered&#xA;  (default: 20)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I know I can set the number of lines higher, yet is there an &quot;endless&quot; option that always adds the command to the history unless disk space runs out?&lt;/p&gt;&#xA;" OwnerUserId="5449" LastEditorUserId="51" LastEditDate="2015-12-22T23:42:40.210" LastActivityDate="2015-12-22T23:42:40.210" Title="How to have endless vim history?" Tags="|vimrc|command-history|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5881" PostTypeId="2" ParentId="5880" CreationDate="2015-12-18T11:15:21.557" Score="10" Body="&lt;p&gt;No, it is not possible. According to &lt;code&gt;:help 'history'&lt;/code&gt; you can have 10 thousand entries:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'history' 'hi'      number  (Vim default: 50, Vi default: 0)&#xA;            global&#xA;            {not in Vi}&#xA;    A history of &quot;:&quot; commands, and a history of previous search patterns&#xA;    is remembered.  This option decides how many entries may be stored in&#xA;    each of these histories (see |cmdline-editing|).&#xA;    The maximum value is 10000.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this number should be more than enough. If you have complex commands which are hard to remember you should create commands on your vimrc (which you should include in your backups), instead of relaying in the command history, which usually you don't save in backups and can be corrupted/erased by some plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With good (and short) commands/abbreviations/mappings you could easily type what you need, instead of keep searching the command history.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-12-18T11:15:21.557" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5882" PostTypeId="2" ParentId="5878" CreationDate="2015-12-18T13:28:16.483" Score="8" Body="&lt;p&gt;You probably misunderstood the documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt; c. Four places are searched for initializations.  The first that exists&#xA;    is used, the others are ignored.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus if you are using the VIMINIT, the vimrc won't be loaded.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;-  The environment variable VIMINIT (see also |compatible-default|) (*)&#xA;   The value of $VIMINIT is used as an Ex command line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You are setting $VIMINIT to an Ex command, &lt;code&gt;set number&lt;/code&gt;, which is OK according to the docs. But if prefer a vimrc, you should include &lt;code&gt;set number&lt;/code&gt; on that file &lt;em&gt;instead&lt;/em&gt; of using $VIMINIT. You mentioned that you set it to empty and your vimrc was still not loaded, but you actually should &lt;em&gt;unset&lt;/em&gt; the variable.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-12-18T13:28:16.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5883" PostTypeId="2" ParentId="5878" CreationDate="2015-12-18T13:33:41.853" Score="10" Body="&lt;p&gt;Expanding on @mMontu's answer; Vim hunts for initialization in order of that list till it finds one. Since the &lt;code&gt;$VIMINIT&lt;/code&gt; variable take precedent to the &lt;code&gt;.vimrc&lt;/code&gt; file, it satisfies the search and any other option after that is &lt;strong&gt;ignored&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason it still didn't work after:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ VIMINIT=&#xA;$ echo $VIMINIT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is (1) you're setting a local variable not an environment variable. That needs to be exported:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ export VIMINIT=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(2) this still won't work because &lt;code&gt;VIMINIT&lt;/code&gt; is still defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ printenv | grep VIMINIT&#xA;VIMINIT=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What needs to happen is removal from the environment all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ unset VIMINIT&#xA;$ printenv | grep VIMINIT || echo &quot;Gone&quot;&#xA;Gone&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(These commands are Bash specific. Change them to suit your preferred shell if needed.)&lt;/p&gt;&#xA;" OwnerUserId="544" LastEditorUserId="1586" LastEditDate="2015-12-18T17:53:37.070" LastActivityDate="2015-12-18T17:53:37.070" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5884" PostTypeId="2" ParentId="5488" CreationDate="2015-12-18T13:45:51.213" Score="10" Body="&lt;p&gt;I do exactly this for one file I refer to a lot &lt;code&gt;NOTES.otl&lt;/code&gt; I performed the following in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Useful for my Quick Notes feature in my tmuxrc&#xA;augroup QuickNotes&#xA;  au BufWrite,VimLeave NOTES.otl mkview&#xA;  au BufRead           NOTES.otl silent loadview&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this means is that in your case you can handle manual folds using the &lt;code&gt;:mkview&lt;/code&gt; and &lt;code&gt;:loadview&lt;/code&gt; commands.&lt;/p&gt;&#xA;" OwnerUserId="544" LastActivityDate="2015-12-18T13:45:51.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5885" PostTypeId="1" CreationDate="2015-12-18T14:36:27.137" Score="5" ViewCount="792" Body="&lt;p&gt;I am using Vim with Pathogen, vim-jsx, and vim-javascript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have trouble getting the correct indentation. When I am breaking one line that is too long into several pieces (without adding new blocks), the next line loses its correct indentation (and the next one after that, etc). This is really annoying and blocks me from using &lt;code&gt;gg=G&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me illustrate:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QYEE6.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QYEE6.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the gif, I am breaking the &lt;code&gt;conversationPage&lt;/code&gt; line, and then reindenting the next two lines with &lt;code&gt;==&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no such problems with my other &lt;code&gt;vim-js-indent&lt;/code&gt; plugin, thoguh, but it doesn't support JSX. Any help would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5713" LastEditorUserId="205" LastEditDate="2015-12-20T23:14:33.563" LastActivityDate="2015-12-28T20:23:02.920" Title="Vim auto indentation" Tags="|indentation|filetype-javascript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5886" PostTypeId="1" AcceptedAnswerId="5891" CreationDate="2015-12-18T14:50:03.830" Score="2" ViewCount="96" Body="&lt;p&gt;I have a rather long chat transcript that I copied out of a window, and when I pasted it into vim, it put two line breaks after every username, and then what the user typing said.  I'd like to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Search for the &lt;code&gt;&amp;gt;&lt;/code&gt; character&lt;/li&gt;&#xA;&lt;li&gt;Go to the top of the file.&lt;/li&gt;&#xA;&lt;li&gt;Start recording the macro&lt;/li&gt;&#xA;&lt;li&gt;Move to the next match.&lt;/li&gt;&#xA;&lt;li&gt;Press the delete key twice to move to move the text up to the same line as the user's name&lt;/li&gt;&#xA;&lt;li&gt;Finish recording the macro.&lt;/li&gt;&#xA;&lt;li&gt;Run the previously recorded macro for every match in the file.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How would one go about this in VIM?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2015-12-22T15:29:10.523" Title="How to move to the next matching string and then hit delete twice in a macro?" Tags="|macro|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5887" PostTypeId="2" ParentId="5886" CreationDate="2015-12-18T15:03:30.480" Score="7" Body="&lt;p&gt;One way of deleting two new lines after every &lt;code&gt;&amp;gt;&lt;/code&gt; is as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;gt;\n\n/&amp;gt; /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To explain, this is a global search and replace (&lt;code&gt;:%s&lt;/code&gt;) finding &gt; followed by two newline characters (&lt;code&gt;&amp;gt;\n\n&lt;/code&gt;) replacing with &lt;code&gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or for recording the macro you asked for&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Search for the &gt; character&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;2&quot;&gt;&#xA;  &lt;li&gt;Go to the top of the file.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;3&quot;&gt;&#xA;  &lt;li&gt;Start recording the macro&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;4&quot;&gt;&#xA;  &lt;li&gt;Move to the next match.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;5&quot;&gt;&#xA;  &lt;li&gt;Press the delete key twice to move to move the text up to the same line as the user's name&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A&amp;lt;del&amp;gt;&amp;lt;del&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;6&quot;&gt;&#xA;  &lt;li&gt;Finish recording the macro.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;7&quot;&gt;&#xA;  &lt;li&gt;Run the previously recorded macro for every match in the file.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This last line would run it once. Could run it a number of times, say 5, with &lt;code&gt;5@@&lt;/code&gt;. To run the macro until the end of the file (from saginaw in comments), you would need to &lt;code&gt;:set nowrapscan&lt;/code&gt; (to stop at the end of the file when searching with &lt;code&gt;n&lt;/code&gt;), define &lt;code&gt;a&lt;/code&gt; as a recursive macro with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qA@aq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then &lt;code&gt;:set wrapscan&lt;/code&gt; to return to the default search behaviour.&lt;/p&gt;&#xA;" OwnerUserId="4655" LastEditorUserId="4655" LastEditDate="2015-12-22T15:29:10.523" LastActivityDate="2015-12-22T15:29:10.523" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5888" PostTypeId="2" ParentId="2010" CreationDate="2015-12-18T16:20:03.080" Score="3" Body="&lt;p&gt;Seems like you found your answer. I had this same problem and nothing above worked. What worked for me was using &lt;a href=&quot;https://github.com/altercation/solarized/blob/master/xfce4-terminal/dark/terminalrc&quot; rel=&quot;nofollow&quot;&gt;altercation's &lt;code&gt;terminalrc&lt;/code&gt;&lt;/a&gt;, as opposed to &lt;a href=&quot;https://github.com/sgerrand/xfce4-terminal-colors-solarized/blob/master/dark/terminalrc&quot; rel=&quot;nofollow&quot;&gt;sgerrand's&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My relevant &lt;code&gt;vimrc&lt;/code&gt; is simply:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax enable&#xA;set background=dark&#xA;colorscheme solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope that helps someone!&lt;/p&gt;&#xA;" OwnerUserId="5719" LastEditorUserId="205" LastEditDate="2015-12-18T17:30:41.160" LastActivityDate="2015-12-18T17:30:41.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5889" PostTypeId="1" CreationDate="2015-12-18T17:00:47.313" Score="5" ViewCount="591" Body="&lt;p&gt;I often edit code where I have a general comment for a block of code and specific comment for each line. For instance, this a sample of my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;indentation&#xA;set autoindent                 &quot;automatically indent&#xA;set shiftwidth=2               &quot;auto-ident two blanks&#xA;set tabstop=2                  &quot;tabs are two blanks&#xA;set expandtab                  &quot;tabs are spaces&#xA;set backspace=indent,eol,start &quot;backspaces delete auto-inserted indents&#xA;&#xA;&quot;:cmdline&#xA;set showcmd        &quot;show incomplete cmds&#xA;set wildmenu       &quot;cmdline completion&#xA;set history=1000   &quot;store 1000 cmd from cmdline&#xA;set laststatus=2   &quot;always show the current file status&#xA;set noruler        &quot;off by default, but had to reset it&#xA;set shell=/bin/zsh &quot;use zsh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For now, I am able to render that kind of formatting by using &lt;a href=&quot;https://github.com/junegunn/vim-easy-align&quot;&gt;easy align&lt;/a&gt;. However this is quite limited because it natively only considers few delimiters. For vim (whose comments start by &lt;code&gt;&quot;&lt;/code&gt;) and LaTeX (whose comments start by &lt;code&gt;%&lt;/code&gt;) I need to tweak the &lt;code&gt;g:easy_align_delimiters&lt;/code&gt; variable. Which in my opinion is not right, since it is syntax dependent it should arise in a locale variable with a &lt;code&gt;filetype&lt;/code&gt; detection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot use it globally either, since some comments are aligned too far from the corresponding line of code and it takes quite a bit of time to go through each block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/godlygeek/tabular&quot;&gt;Tabular&lt;/a&gt; isn't a solution either, since it aligns everything (including those &quot;general&quot; block comments).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a script or a plugin that, given that syntax recognition is enabled, automatically indents comments in the same fashion as in the sample &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5720" LastEditorUserId="205" LastEditDate="2015-12-18T17:26:40.040" LastActivityDate="2015-12-21T18:41:34.977" Title="A plugin to align comments" Tags="|comments|alignment|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5890" PostTypeId="1" CreationDate="2015-12-18T18:58:36.997" Score="1" ViewCount="1461" Body="&lt;p&gt;I'm looking for a plugin that will autocomplete closing brackets for me. Furthermore, I'd like it to space and tab the inner block automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried a number of them where if I'm typing python for example, I'll get into situations like this (* represents my cursor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def myFunc(){&#xA;*}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I get the autocomplete on the &lt;code&gt;}&lt;/code&gt;, but it 1) doesnt indent for me and 2) leaves the closing bracket on the same line. Instead, I'd like to be able to do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def myFunc(){&#xA;    *&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where as soon as I hit enter within the &lt;code&gt;{}&lt;/code&gt; it will correctly indent for me and shift the closing bracket 2 lines down. This is the case in most languages I use (javascript, CSS etc)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any plugins that can do this?&lt;/p&gt;&#xA;" OwnerUserId="5716" LastActivityDate="2015-12-18T19:12:21.513" Title="Bracket completion with correct tab and insert placement" Tags="|autocompletion|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5891" PostTypeId="2" ParentId="5886" CreationDate="2015-12-18T19:03:44.177" Score="5" Body="&lt;p&gt;As steve pointed out, &lt;code&gt;:%s/&amp;gt;\n\n/&amp;gt; /&lt;/code&gt; is useful here (although the &lt;code&gt;g&lt;/code&gt; flag he used is superfluous.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to mention another command that is applicable here: the &quot;join&quot; command, which is &lt;code&gt;J&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for a macro you could use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ggqq/&amp;gt;$&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;code&gt;JJq999@q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg                  # Move to start of file&#xA;  qq                # Start recording macro into register q&#xA;    /&amp;gt;$^M           # Search for the &quot;&amp;gt;&quot; character at the end of a line&#xA;         JJ         # Join the next two lines onto the current line&#xA;           q        # Stop recording macro&#xA;            999@q   # Play macro back 999 times.&#xA;                    # (It will stop when &quot;&amp;gt;&quot; is no longer found at the end of any line.)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="4676" LastEditDate="2015-12-18T19:18:40.153" LastActivityDate="2015-12-18T19:18:40.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5892" PostTypeId="2" ParentId="5890" CreationDate="2015-12-18T19:12:21.513" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/LucHermitte/lh-brackets/&quot; rel=&quot;nofollow&quot;&gt;lh-brackets&lt;/a&gt; does it indirectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it detects you hit &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; within a pair of &lt;code&gt;{}&lt;/code&gt;, it will insert everything that is required. By default, it'll just insert &lt;code&gt;{}&lt;/code&gt;. You'll have to use &lt;code&gt;-nl&lt;/code&gt; option of &lt;code&gt;:Brackets&lt;/code&gt; to force the newline every time (I went back from this configuration)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's currently defined only for curly brackets, if you want it for other kind of bracket-pairs, you'll have to adapt this snippet of viml:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if lh#option#get('cb_newline_within_empty_brackets', 1)&#xA;  call lh#brackets#enrich_imap('&amp;lt;cr&amp;gt;',&#xA;        \ {'condition': 'getline(&quot;.&quot;)[col(&quot;.&quot;)-2:col(&quot;.&quot;)-1]==&quot;{}&quot;',&#xA;        \   'action': 'lh#brackets#_add_newline_between_brackets()'},&#xA;        \ 0,&#xA;        \ '\&amp;lt;cr\&amp;gt;'&#xA;        \ )&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(i.e. change the condition, or use instead &lt;code&gt;lh#brackets#define_imap()&lt;/code&gt; that takes a list of condition+action)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, brackets in Python? Really? BTW, this language may incur side effects regarding automatic indentation.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2015-12-18T19:12:21.513" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5893" PostTypeId="2" ParentId="5886" CreationDate="2015-12-18T23:42:48.423" Score="2" Body="&lt;p&gt;Macros are good for quick-and-dirty solutions in the moment, but command-line commands are more efficient (though this is only normally noticeable on really large files). One possible method:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/&amp;gt;$/j3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h :g&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]g[lobal]/{pattern}/[cmd]&#xA;        Execute the Ex command [cmd] (default &quot;:p&quot;) on the&#xA;        lines within [range] where {pattern} matches.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;[cmd]&lt;/code&gt; in this case is &lt;code&gt;:j&lt;/code&gt;. From &lt;code&gt;:h :j&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]j[oin][!] {count} [flags]&#xA;        Join {count} lines, starting with [range] (default:&#xA;        current line |cmdline-ranges|).  Same as &quot;J&quot;, except&#xA;        with [!] the join does not insert or delete any&#xA;        spaces.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to join the current line with the next two lines, you actually have to use a &lt;code&gt;{count}&lt;/code&gt; of 3, as I've put here.&lt;/p&gt;&#xA;" OwnerUserId="514" LastActivityDate="2015-12-18T23:42:48.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5896" PostTypeId="2" ParentId="5863" CreationDate="2015-12-19T18:04:29.763" Score="4" Body="&lt;p&gt;You can do this by combining two tools:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:TOhtml&lt;/code&gt; &lt;strong&gt;generates an HTML file&lt;/strong&gt; that contains syntax highlight.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;elinks&lt;/code&gt; &lt;strong&gt;prints the HTML file into the terminal&lt;/strong&gt; with colors. See  &lt;a href=&quot;https://stackoverflow.com/a/5459537/17916&quot;&gt;this post&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I created &lt;code&gt;~/test_vimrc.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SgyYe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SgyYe.png&quot; alt=&quot;The file in Vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I typed &lt;code&gt;:TOhtml&lt;/code&gt;, so Vim created &lt;code&gt;~/test_vimrc.vim.html&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I go to the terminal and type this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;elinks -dump -dump-color-mode 3 ~/test_vimrc.vim.html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I see this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cQb2g.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cQb2g.png&quot; alt=&quot;The file in the terminal with syntax highlight&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You need to test which color mode works in your terminal. For me 2 and 3 work, but the background is gray if I use 1 or 4. Also, within tmux, it it always gray:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/I31uj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/I31uj.png&quot; alt=&quot;The file in the terminal inside tmux&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5729" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-12-19T18:04:29.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5898" PostTypeId="1" AcceptedAnswerId="5904" CreationDate="2015-12-20T03:03:33.387" Score="5" ViewCount="1900" Body="&lt;p&gt;There is a file with name &lt;code&gt;./folderA/folderB/file.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And there is text: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./folderA/folderB/file.:abcdefg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I move the cursor on letter &lt;code&gt;B&lt;/code&gt; and type &lt;code&gt;&amp;lt;c-w&amp;gt;f&lt;/code&gt;, it says &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E447: Can't find file &quot;./folderA/folderB/file&quot; in path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the file name is &lt;code&gt;file.&lt;/code&gt;. There is a dot at the end of the file name but no extension name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I open such a file? I have many files with similar names, so I hope to minimize keystrokes. I'm using Ubuntu.&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="51" LastEditDate="2015-12-22T22:12:01.237" LastActivityDate="2016-06-16T15:22:43.560" Title="How do I open file under cursor, when the filename has a trailing dot?" Tags="|linux|filesystem|error|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5900" PostTypeId="2" ParentId="5898" CreationDate="2015-12-20T03:27:11.983" Score="7" Body="&lt;p&gt;From &lt;code&gt;:help gf&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Trailing punctuation characters &quot;.,:;!&quot; are ignored.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I suppose the dot at the end is not considered as part of the filename but as punctuation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if it can be done with fewer keystrokes, but to open this file while the cursor is on B, I would type:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;viWF.&amp;lt;c-w&amp;gt;f&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;viW&lt;/code&gt; = visually select characters inside big word  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;F.&lt;/code&gt; = move the end of the selection to the previous dot  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;f&lt;/code&gt; = open file whose path is visually selected in a split&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To save some keystrokes you could also define a mapping :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;wf viWF.&amp;lt;c-w&amp;gt;f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then type &lt;code&gt;&amp;lt;leader&amp;gt;wf&lt;/code&gt; while the cursor is on the file path you described.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-20T03:52:41.093" LastActivityDate="2015-12-20T03:52:41.093" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5901" PostTypeId="1" CreationDate="2015-12-20T05:10:07.707" Score="11" ViewCount="2784" Body="&lt;p&gt;I am using neovim with qt-neovim (linux arch).&#xA;On gvim I could launch a maximized window with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if has(&amp;quot;gui_running&amp;quot;)&#xA;    set lines 999 columns 999&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;That is not working now though. I tried removing the &lt;code&gt;if&lt;/code&gt; without success.&#xA;Is there any way I can achieve that?&lt;/p&gt;&#xA;" OwnerUserId="5732" LastEditorUserId="11054" LastEditDate="2021-03-21T00:35:14.527" LastActivityDate="2021-03-21T00:35:14.527" Title="How to start maximized gui with qt-neovim?" Tags="|neovim|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5902" PostTypeId="1" AcceptedAnswerId="5903" CreationDate="2015-12-20T20:29:11.100" Score="5" ViewCount="442" Body="&lt;p&gt;I would like to use the normal commands &lt;code&gt;g,&lt;/code&gt; and &lt;code&gt;g;&lt;/code&gt; more often to navigate through the change list.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is I usually don't know how far I am in the change list from the edit I'm interested in and I have to repeat the commands many times to reach it.&lt;br&gt;&#xA;Usually, what I do is :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use the Ex command &lt;code&gt;:changes&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;G&lt;/code&gt; to go to the bottom of the change list and see the latest edits&lt;/li&gt;&#xA;&lt;li&gt;look for the edit where I want to go and prepend the normal commands &lt;code&gt;g,&lt;/code&gt; or &lt;code&gt;g;&lt;/code&gt; with a count&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To automate this process a little bit, I've come up with the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;g, :changes&amp;lt;cr&amp;gt;G&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the &lt;code&gt;G&lt;/code&gt; part of the mapping doesn't seem to work, the beginning of the change list is displayed (with the oldest entries), while I want to see the newest entries from the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I move inside vim's internal pager from a mapping ?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-20T20:42:01.573" LastActivityDate="2015-12-24T11:40:56.240" Title="How to move inside vim's internal pager from a mapping?" Tags="|key-bindings|cursor-movement|" AnswerCount="4" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5903" PostTypeId="2" ParentId="5902" CreationDate="2015-12-20T20:56:29.160" Score="3" Body="&lt;p&gt;There is no way of accomplishing this by default.  However, you can capture the output of the &lt;code&gt;:changes&lt;/code&gt; command with the &lt;code&gt;:redir&lt;/code&gt; command and paste it into a new split buffer.  Here is my implementation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! ChangeList call &amp;lt;SID&amp;gt;ChangeList()&#xA;&#xA;function! s:ChangeList() abort&#xA;    &quot; Save z register&#xA;    let l:oldz = @z&#xA;    &quot; Redirect any output on the command line to register z&#xA;    redir @z&#xA;    &quot; Make the output of changes silent, though redir still captures it&#xA;    silent! changes&#xA;    redir END&#xA;    &quot; Open scratch buffer in new split&#xA;    new&#xA;    &quot; Insert the contents of z into current buffer silently&#xA;    silent! put z&#xA;    &quot; Restore register z to previous value&#xA;    let @z = l:oldz&#xA;    &quot; Remove blank lines and superfluous greater-than symbol (silently)&#xA;    silent! %g/^[\s&amp;gt;]*$/d&#xA;    &quot; Go to end of file&#xA;    $&#xA;    &quot; Make the buffer not related to any sort of file, and will never be written&#xA;    set buftype=nofile&#xA;&#xA;    &quot; Define the function MoveCursor() which will move the cursor&#xA;    &quot; when we hit Enter on a line in the scratch buffer&#xA;    function! s:MoveCursor() abort&#xA;        &quot; Get line number of the entry in the change list&#xA;        let l:lnum = split(getline('.'))[1]&#xA;        &quot; Get column number of the entry in the change list&#xA;        let l:col = split(getline('.'))[2]&#xA;        &quot; Store new cursor position inside variable l:pos&#xA;        let l:pos = [0, l:lnum, l:col, 0]&#xA;        &quot; Close scratch buffer&#xA;        wincmd q&#xA;        &quot; Set cursor position&#xA;        silent! call setpos('.', l:pos)&#xA;    endfunction&#xA;&#xA;    &quot; Define local mapping to call the function MoveCursor() when we hit Enter&#xA;    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;return&amp;gt; :call &amp;lt;SID&amp;gt;MoveCursor()&amp;lt;cr&amp;gt;&#xA;&#xA;    endfunction&#xA;&#xA;&quot; Define mapping &amp;lt;leader&amp;gt;g, to call the ChangeList() function&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;g, :call &amp;lt;SID&amp;gt;ChangeList()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To move your cursor to a position stored in the change list:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;hit &lt;code&gt;&amp;lt;leader&amp;gt;g,&lt;/code&gt; to open a new window displaying the change list&lt;/li&gt;&#xA;&lt;li&gt;move your cursor on the line showing the edit you are interested in&lt;/li&gt;&#xA;&lt;li&gt;hit Enter&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The window should close and your cursor should move to the line and column which were stored in the change list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can put whatever options you want after &lt;code&gt;set buftype=nofile&lt;/code&gt;, such as &lt;code&gt;set nobuflisted&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="4939" LastEditDate="2015-12-21T05:22:27.847" LastActivityDate="2015-12-21T05:22:27.847" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5904" PostTypeId="2" ParentId="5898" CreationDate="2015-12-20T22:00:50.983" Score="4" Body="&lt;p&gt;Another option is to set &lt;code&gt;includeexpr&lt;/code&gt;. From &lt;code&gt;:help includeexpr&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                *'includeexpr'* *'inex'*&#xA;'includeexpr' 'inex'    string  (default &quot;&quot;)&#xA;                    local to buffer&#xA;                    {not in Vi}&#xA;                    {not available when compiled without the&#xA;                    |+find_in_path| or |+eval| features}&#xA;    Expression to be used to transform the string found with the 'include'&#xA;    option to a file name.  Mostly useful to change &quot;.&quot; to &quot;/&quot; for Java:&#xA;            :set includeexpr=substitute(v:fname,'\\.','/','g')&#xA;    The &quot;v:fname&quot; variable will be set to the file name that was detected.&#xA;&#xA;    Also used for the |gf| command if an unmodified file name can't be&#xA;    found.  Allows doing &quot;gf&quot; on the name after an 'include' statement.&#xA;    Also used for |&amp;lt;cfile&amp;gt;|.&#xA;&#xA;    The expression will be evaluated in the |sandbox| when set from a&#xA;    modeline, see |sandbox-option|.&#xA;&#xA;    It is not allowed to change text or jump to another window while&#xA;    evaluating 'includeexpr' |textlock|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &quot;Also used&quot; paragraph is what will be useful here. When you do a &lt;code&gt;gf&lt;/code&gt; and vim can't find the file, it places the name it tried to read in &lt;code&gt;v:fname&lt;/code&gt; and evaluates the expression in &lt;code&gt;includeexpr&lt;/code&gt;. it then tries to read a file with the resulting name. So if you do a:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set includeexpr=v:fname.'.'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then do a &lt;code&gt;gf&lt;/code&gt; when on &lt;code&gt;file.&lt;/code&gt;, vim tries to read &lt;code&gt;file&lt;/code&gt;, which fails. It then evaluates &lt;code&gt;v:fname.'.'&lt;/code&gt;, with &lt;code&gt;v:fname&lt;/code&gt; set to &lt;code&gt;file&lt;/code&gt;, which just appends a period to the contents of &lt;code&gt;v:fname&lt;/code&gt; and returns &lt;code&gt;file.&lt;/code&gt;. vim then tries to read that, which succeeds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that vim will still try to read &lt;code&gt;file&lt;/code&gt;, so if you have both &lt;code&gt;file&lt;/code&gt; and &lt;code&gt;file.&lt;/code&gt;, vim will read &lt;code&gt;file&lt;/code&gt;, but I'd argue having both &lt;code&gt;file&lt;/code&gt; and &lt;code&gt;file.&lt;/code&gt; is just asking for trouble. :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only need to do this for certain file types, you could place it in an &lt;code&gt;autocmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.dots set includeexpr=v:fname.'.'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where you only want to have vim look for &lt;code&gt;file.&lt;/code&gt; in files ending in &lt;code&gt;.dots&lt;/code&gt; (for example).&lt;/p&gt;&#xA;" OwnerUserId="4620" LastEditorUserId="4620" LastEditDate="2015-12-20T22:05:54.573" LastActivityDate="2015-12-20T22:05:54.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5905" PostTypeId="1" AcceptedAnswerId="5919" CreationDate="2015-12-21T03:15:10.693" Score="13" ViewCount="1229" Body="&lt;p&gt;I don't know if there's some function to check a window's position, I mean is it currently sitting at bottom or top, left or right??&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;__________________________&#xA;|           |            |&#xA;|           |            |&#xA;|  left     |   right    |&#xA;|           |            |&#xA;|           |            |&#xA;|___________|____________|&#xA;&#xA;__________________________&#xA;|                        |&#xA;|          top           |&#xA;|________________________|&#xA;|                        |&#xA;|         bottom         |&#xA;|_______________________ |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1276" LastActivityDate="2015-12-22T10:05:08.620" Title="Is it possible to tell if a window is at bottom or top, left or right?" Tags="|vim-windows|split|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5906" PostTypeId="2" ParentId="5905" CreationDate="2015-12-21T07:11:09.633" Score="6" Body="&lt;p&gt;I don't think there is any way to check this, unfortunately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There might be a way to make a custom function that checks this: The window numbers are always numbered from 1 on the top left to &lt;em&gt;n&lt;/em&gt; on the bottom right. Perhaps one can use this combined with the geometry data from &lt;code&gt;winwidth()&lt;/code&gt;, &lt;code&gt;winheight()&lt;/code&gt; and the values of &lt;code&gt;&amp;amp;lines&lt;/code&gt; and &lt;code&gt;&amp;amp;columns&lt;/code&gt; to create the desired map?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, in order to be general, this should support more complex layouts. What should the output be if for instance the left side is split into two? Perhaps this is the reason why the function does not exist in the first place...&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2015-12-21T07:11:09.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5907" PostTypeId="1" CreationDate="2015-12-21T16:39:09.800" Score="7" ViewCount="461" Body="&lt;p&gt;Several of the commands for &lt;a href=&quot;http://vim.wikia.com/wiki/Browsing_programs_with_tags&quot; rel=&quot;nofollow&quot;&gt;browsing programs with tags&lt;/a&gt; use &lt;kbd&gt;]&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there a mnemonic for this?&lt;/li&gt;&#xA;&lt;li&gt;Why was it selected?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5746" LastEditorUserId="51" LastEditDate="2022-09-23T11:08:33.240" LastActivityDate="2022-09-23T11:08:33.240" Title="Why is ] used for tag navigation?" Tags="|key-bindings|tags|history-of|original-vi|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5908" PostTypeId="2" ParentId="5889" CreationDate="2015-12-21T18:41:34.977" Score="2" Body="&lt;p&gt;I'm not familiar with easy align, but by reading the documentation my understanding is that you shouldn't tweak &lt;code&gt;g:easy_align_delimiters&lt;/code&gt;. As the plugin allows specifying the character along the command or operator, you could define a new command/operator that calls the easy align specifying the correct characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually the comment characters are set by the ftplugin on the &lt;code&gt;'commentstring'&lt;/code&gt; option, which is local to the buffer. Thus the new command/operator would need to parse the contents of &lt;code&gt;&amp;amp;commentstring&lt;/code&gt; and include it dynamically, possible using &lt;code&gt;:execute&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-12-21T18:41:34.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5909" PostTypeId="1" CreationDate="2015-12-16T22:44:35.770" Score="3" ViewCount="739" Body="&lt;p&gt;A recent upgrade appears to have broken the ability of Windows-native &lt;code&gt;gvim&lt;/code&gt; (7.4) to run &lt;code&gt;:!&lt;/code&gt;-like commands using Cygwin's &lt;code&gt;bash&lt;/code&gt; as the shell. (No doubt it's something that's been configured for my convenience that I'll have to find and deconfigure.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can tell me how I might fix it, work around it, or help things along, thank you, etc., etc.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The minimal example&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;First, enter this list into the buffer of a new &lt;code&gt;gvim&lt;/code&gt; window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;2&#xA;3&#xA;4&#xA;5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, configure the shell settings to Cygwin bash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let &amp;amp;shell=&quot;C:\\cygwin64\\bin\\bash.exe&quot;&#xA;:let &amp;amp;shellcmdflag=&quot;-c&quot;&#xA;:let &amp;amp;shellxquote=&quot;\&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, run &lt;code&gt;wc&lt;/code&gt; using the shell, replacing the current buffer contents.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!/usr/bin/wc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the Windows 10 machine, I get a few seconds of hang followed by an E485 at the bottom of the window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;shell returned 254&#xA;&#xA;E485: Can't read file C:/Users/psmay/AppData/Local/Temp/VIo4283.tmp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Windows 8.1 machine I have on remote, which is otherwise similarly configured, behaves appropriately, replacing the buffer with &lt;code&gt;wc&lt;/code&gt;'s output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 5  5 15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="psmay" LastActivityDate="2015-12-21T19:40:07.013" Title="Windows gvim with &amp;shell set to Cygwin bash broken by Windows 10" Tags="|cygwin|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5910" PostTypeId="2" ParentId="5909" CreationDate="2015-12-17T15:50:15.703" Score="1" Body="&lt;p&gt;Short version: Switch to an x64 build of Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After tracking down &lt;a href=&quot;https://tuxproject.de/projects/vim/&quot; rel=&quot;nofollow&quot;&gt;some more recent Vim builds&lt;/a&gt;, I found out that the latest 32-bit (x86) build fails the above test in the same way, but the 64-bit (x64) build succeeds. Incidentally, the &lt;code&gt;gvim&lt;/code&gt; already on my machine is from the installer on &lt;a href=&quot;http://www.vim.org/download.php&quot; rel=&quot;nofollow&quot;&gt;Vim's own download page&lt;/a&gt;, which is evidently also a 32-bit build.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Still no idea, though, why running 64-bit Cygwin from 32-bit Vim is suddenly illegal.)&lt;/p&gt;&#xA;" OwnerDisplayName="psmay" LastActivityDate="2015-12-17T15:50:15.703" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5911" PostTypeId="2" ParentId="5902" CreationDate="2015-12-21T19:55:47.657" Score="1" Body="&lt;p&gt;You could also try the &lt;a href=&quot;https://github.com/sjl/gundo.vim&quot; rel=&quot;nofollow&quot;&gt;Gundo.vim&lt;/a&gt; plugin for a visual representation of the undo tree.&lt;/p&gt;&#xA;" OwnerUserId="2919" LastActivityDate="2015-12-21T19:55:47.657" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5912" PostTypeId="1" AcceptedAnswerId="5915" CreationDate="2015-12-21T22:43:32.553" Score="7" ViewCount="618" Body="&lt;p&gt;When defining a function, is it always recommended to use the scope &lt;code&gt;s:&lt;/code&gt; to make it local to the script and avoid overwriting a function with the same name in the global namespace ?&lt;br&gt;&#xA;And is it always recommended to use the argument &lt;code&gt;abort&lt;/code&gt; in case the function detects an error ?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:SomeFunction() abort&#xA;    echo &quot;hello world!&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The scope &lt;code&gt;s:&lt;/code&gt; seems a good thing, but it makes the code a little more verbose, because each time I want to call &lt;code&gt;SomeFunction()&lt;/code&gt; from a mapping I have to prefix it with &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap {lhs} :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;SomeFunction()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even to store its output inside a variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let myvar = &amp;lt;SID&amp;gt;SomeFunction()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are there some specific cases in which you don't want to use &lt;code&gt;s:&lt;/code&gt; and / or &lt;code&gt;abort&lt;/code&gt; ?&lt;br&gt;&#xA;If so, for what reasons ?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-21T22:48:44.570" LastActivityDate="2015-12-22T03:35:48.840" Title="When is it recommended to use the scope s: and the argument abort to define a function?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5913" PostTypeId="1" AcceptedAnswerId="5914" CreationDate="2015-12-21T23:29:58.150" Score="8" ViewCount="262" Body="&lt;p&gt;From help &lt;code&gt;:help i_ctrl-a&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-A      Insert previously inserted text.  {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's say I have an empty buffer and I'm in normal mode.&lt;br&gt;&#xA;I type &lt;code&gt;i&lt;/code&gt; to go in insert mode.&lt;br&gt;&#xA;I type &lt;code&gt;()&lt;/code&gt;, then move the cursor one character to the left by hitting &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; (which I mapped to &lt;code&gt;&amp;lt;left&amp;gt;&lt;/code&gt; in insert mode), type &lt;code&gt;foo&lt;/code&gt;,  and go back in normal mode by hitting escape.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The buffer contains: &lt;code&gt;(foo)&lt;/code&gt;&lt;br&gt;&#xA;I thought, wrongly, that the previously inserted text would be &lt;code&gt;(foo)&lt;/code&gt; but it's not.&lt;br&gt;&#xA;The previously inserted text is only &lt;code&gt;foo&lt;/code&gt; which can be checked by typing &lt;code&gt;:registers .&lt;/code&gt; or hitting &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; in insert mode again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does hitting an arrow key reset the previously inserted text ?&lt;br&gt;&#xA;Is there a way to make the dot register store all the text that was inserted the last time I went in insert mode even though I hit an arrow key ?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-22T01:12:39.660" LastActivityDate="2015-12-22T01:20:07.670" Title="Why is the previously inserted text reset after using an arrow key?" Tags="|key-bindings|cursor-movement|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5914" PostTypeId="2" ParentId="5913" CreationDate="2015-12-22T01:08:09.033" Score="7" Body="&lt;p&gt;In insert mode, the left arrow key actually exits insert mode, moves the cursor, then re-enters insert mode. That breaks your change into two changes: inserting &lt;code&gt;()&lt;/code&gt; and inserting &lt;code&gt;foo&lt;/code&gt;. This behavior is discussed under&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help ins-special-special&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The solution is to remap the left arrow key to include &lt;code&gt;CTRL-G U&lt;/code&gt;. The example in the Vim Reference Manual is hard to find because it's not directly tagged. First go to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help i_CTRL-G_U&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then scroll down 42 lines to &quot;An example for using &lt;code&gt;CTRL-G U&lt;/code&gt;:&quot; For the left arrow key, use this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Left&amp;gt; &amp;lt;C-G&amp;gt;U&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to work, but the display of the &lt;code&gt;.&lt;/code&gt; register by the &lt;code&gt;:registers&lt;/code&gt; command looks weird after executing your &lt;code&gt;(foo)&lt;/code&gt; example. On my Windows machine, it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;.  ()^GU&amp;lt;80&amp;gt;klfoo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="4939" LastEditDate="2015-12-22T01:20:07.670" LastActivityDate="2015-12-22T01:20:07.670" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5915" PostTypeId="2" ParentId="5912" CreationDate="2015-12-22T03:35:48.840" Score="6" Body="&lt;p&gt;The &lt;code&gt;s:&lt;/code&gt; simply means you are not polluting the global namespace.  Usually you would do this if it is a function that doesn't need to be called by the user.  As for the &lt;code&gt;abort&lt;/code&gt; flag, here is what the docs &lt;code&gt;:help :func-abort&lt;/code&gt; say:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the [abort] argument is added, the function will&#xA;  abort as soon as an error is detected.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If your function doesn't do any set up and won't break anything if it can't tear itself down when an error is encountered, then it probably would be okay to use it.  &lt;em&gt;(that is, if you want to silently abort if an error occurs)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2015-12-22T03:35:48.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5916" PostTypeId="1" CreationDate="2015-12-22T04:59:40.113" Score="15" ViewCount="1821" Body="&lt;p&gt;From help &lt;code&gt;:help backtick-expansion&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;On Unix and a few other systems you can also use backticks for the file name&#xA;argument, for example:&#xA;    :next `find . -name ver\\*.c -print`&#xA;    :view `ls -t *.patch  \| head -n1`&#xA;The backslashes before the star are required to prevent the shell from&#xA;expanding &quot;ver*.c&quot; prior to execution of the find program.  The backslash&#xA;before the shell pipe symbol &quot;|&quot; prevents Vim from parsing it as command&#xA;termination.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I type the command taken from the help, I get an error: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:next `find . -name ver\\*.c -print&#xA;E79: Cannot expand wildcards  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does the example from the help use two backslashes instead of one, and why does it not work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following work:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If I remove one of the two backslashes which protect the star from being expanded by the shell before the &lt;code&gt;find&lt;/code&gt; program: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:next `find . -name ver\*.c -print`&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I remove both of backslashes and put single quotes around the pattern &lt;code&gt;ver*.c&lt;/code&gt;:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:next `find . -name 'ver*.c' -print`&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Up to this point, the rule seems to be:&lt;br&gt;&#xA;&lt;em&gt;if your shell command contains a star and you don't want the shell to expand it before the command, put one backslash in front of it or put single quotes around the pattern&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the help gives another example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:view `ls -t *.patch  \| head -n1`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command works without any modification, no need of single quotes, no need of backslash.&lt;br&gt;&#xA;I suppose the reason why it works is because the &lt;code&gt;ls&lt;/code&gt; command (contrary to the &lt;code&gt;-name&lt;/code&gt; argument of the &lt;code&gt;find&lt;/code&gt; command) accept multiple file arguments and sees no problem with the shell expanding &lt;code&gt;*.patch&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, let's say I want to look for all the files with the extension &lt;code&gt;.conf&lt;/code&gt; inside the &lt;code&gt;/etc&lt;/code&gt; folder and pipes the output of &lt;code&gt;find&lt;/code&gt; to &lt;code&gt;grep&lt;/code&gt; to get only the matches containing the string &lt;code&gt;input&lt;/code&gt;.&lt;br&gt;&#xA;In the shell, from any working directory, I would type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find /etc -name '*.conf' | grep input&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it would work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vim, I will type the same command putting backticks around it, and a backslash in front of the pipe symbol to prevent vim from interpreting it as a command termination :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:next `find /etc -name '*.conf' \| grep input`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if I type the same command without the pipe and the &lt;code&gt;grep input&lt;/code&gt;, I get an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:next `find /etc -name '*.conf'`&#xA;E79: Cannot expand wildcards&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is there an error in this case even though I protected the star with single quotes?&lt;br&gt;&#xA;And why is there an error now, but not just before with the pipe and the &lt;code&gt;grep input&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To try understanding, I've come up with a simpler command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -name '*.conf'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks for all the files with the extension &lt;code&gt;.conf&lt;/code&gt; in the working directory. The command works in the shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test it in vim, I typed: &lt;code&gt;:next `find . -name '*.conf'`&lt;/code&gt;&lt;br&gt;&#xA;And it works.&#xA;In this case the dot stands for my current working directory as displayed by the Ex command &lt;code&gt;:pwd&lt;/code&gt; which is my home directory &lt;code&gt;/home/username&lt;/code&gt; since I launched the vim session from it.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does it work when I ask to search in the current working directory whereas it doesn't work when I ask to search in an arbitrary folder such as &lt;code&gt;/etc&lt;/code&gt;?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if I change my working directory from &lt;code&gt;/home/username&lt;/code&gt; to &lt;code&gt;/etc&lt;/code&gt; with the vim Ex command &lt;code&gt;:cd /etc&lt;/code&gt; and retry the same command as before, again it errors out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:next `find . -name '*.conf'`&#xA;E79: Cannot expand wildcards&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does the same command work when I'm in my home folder but not when I'm in &lt;code&gt;/etc&lt;/code&gt; ?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure there's some logic, but I can't find one.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the general and correct syntax to populate the arglist with an arbitrary shell command (containing a star, a pipe, searching in any directory from any working directory) ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vim version &lt;a href=&quot;https://paste.debian.net/plain/343732&quot;&gt;7.4.942&lt;/a&gt; and zsh is my default shell.&#xA;I tested these commands with a minimum of initializations (&lt;code&gt;vim -u NORC -N&lt;/code&gt;) from bash as well as from zsh.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need to configure vim to call bash and not zsh ?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="205" LastEditDate="2015-12-22T05:36:35.087" LastActivityDate="2015-12-25T07:47:16.647" Title="How to use backtick-expansion to populate the arglist?" Tags="|command-line|external-command|linux|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5917" PostTypeId="1" CreationDate="2015-12-22T08:45:26.717" Score="7" ViewCount="794" Body="&lt;p&gt;Many terminal emulators allow you to define colors:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KTdZu.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KTdZu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than trying to approximate (and duplicate!) the same theme in a Vim colorscheme, is there a way to tell terminal Vim to output ANSI escape codes for the colors I've already defined (&quot;red&quot;, &quot;green&quot;, &quot;yellow&quot;, &quot;magenta&quot;, etc)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, why not?&lt;/p&gt;&#xA;" OwnerUserId="5752" LastActivityDate="2015-12-22T09:59:13.480" Title="Is it possible for Vim to output ANSI colors from the terminal, without a colorscheme?" Tags="|terminal|colorscheme|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5918" PostTypeId="2" ParentId="5917" CreationDate="2015-12-22T09:59:13.480" Score="7" Body="&lt;p&gt;Assuming your terminal emulator doesn't claim to support 256 colors (&lt;code&gt;$ echo $TERM&lt;/code&gt; should output a string that doesn't contain &lt;code&gt;256color&lt;/code&gt;) and you didn't lie to Vim about that (&lt;code&gt;:echo &amp;amp;t_Co&lt;/code&gt; should output &lt;code&gt;8&lt;/code&gt; or &lt;code&gt;16&lt;/code&gt;), Vim should honor the &quot;ANSI&quot; colors you defined in your terminal emulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The built-in colorschemes all use those &quot;ANSI&quot; colors — either by name or by number — by default but many third party colorschemes are specifically designed for the GUI and/or for 256 colors terminal emulators. Those colorschemes generally don't work at all (or very poorly) in 8/16 colors setups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you will need to experiment with built-in and third party colorschemes to find the &quot;perfect&quot; combination.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can look for the clues below to tell if a colorscheme will work in your setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctermfg=red    use of names means it works in 8/16 color terminals&#xA;ctermfg=7      use of numbers below 16 means it works in 8/16 color terminals&#xA;ctermfg=123    use of numbers between 16 and 255 means it works in 256 color terminals&#xA;guifg=...      means it works in GUI Vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-22T09:59:13.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5919" PostTypeId="2" ParentId="5905" CreationDate="2015-12-22T10:05:08.620" Score="4" Body="&lt;p&gt;Summing up the comments of the question:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;-- I'm trying to write a function to rotate window splits to vertical if&#xA;  current layout it's horizontal and vice versa when there're just two&#xA;  windows.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;-- Why not simply use ctrl-W_L? (or ctrl-W_R)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;-- I want it to be convenient toggle function, it will automatically&#xA;  detect the current layout and do the correct rotation for me instead&#xA;  that I need to think it in my brain and choose the right command to&#xA;  use. All I need to do is always hit the same key mapping.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For the layouts containing just two windows the following function should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Rotate()&#xA;   &quot; save the original position, jump to the first window&#xA;   let initial = winnr()&#xA;   exe 1 . &quot;wincmd w&quot;&#xA;&#xA;   wincmd l&#xA;   if winnr() != 1&#xA;      &quot; succeeded moving to the right window&#xA;      wincmd J &quot; make it the bot window&#xA;   else&#xA;      &quot; cannot move to the right, so we are at the top&#xA;      wincmd H &quot; make it the left window&#xA;   endif&#xA;&#xA;   &quot; restore cursor to the initial window&#xA;   exe initial . &quot;wincmd w&quot;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;F3&amp;gt; :call Rotate()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2015-12-22T10:05:08.620" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5920" PostTypeId="1" AcceptedAnswerId="6776" CreationDate="2015-12-22T15:48:30.223" Score="5" ViewCount="1045" Body="&lt;p&gt;I make a &lt;code&gt;.vim&lt;/code&gt; directory in my home directory. I then made an &lt;code&gt;autoload&lt;/code&gt; directory and a &lt;code&gt;bundle&lt;/code&gt; directory. I added the &lt;code&gt;pathogen.vim&lt;/code&gt; file to the autoload directory. I then added &lt;code&gt;execute pathogen#infect()&lt;/code&gt; to my vimrc but there is a point I might have gone wrong. I have 3 different vimrc files, one in &lt;code&gt;/etc/vim&lt;/code&gt;, one in &lt;code&gt;/usr/share/vim&lt;/code&gt; and one in my home directory. Which one should I have edited? I have tried all 3 but it still doesn't work, and I'm getting errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /usr/share/vim/vimrc:&#xA;line 1:&#xA;E117: Unknown function: pathogen#infect&#xA;E15: Invalid expression: pathogen#infect()&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More generally, when I want to edit my vimrc, where should I do this? in &lt;code&gt;/etc/vim/vimrc&lt;/code&gt;? in &lt;code&gt;/usr/share/vim/vimrc&lt;/code&gt;? in &lt;code&gt;~/vim/vimrc&lt;/code&gt;? or just &lt;code&gt;~/vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5758" LastEditorUserId="8" LastEditDate="2015-12-24T23:32:19.453" LastActivityDate="2016-03-05T13:52:16.450" Title="Trying to install pathogen, but where?" Tags="|error|installing|plugin-pathogen|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5921" PostTypeId="1" AcceptedAnswerId="5934" CreationDate="2015-12-22T18:24:27.127" Score="30" ViewCount="15336" Body="&lt;p&gt;Right now I'm using fugitive to manage almost everything git related, but I can't find a good workflow to quickly visualize and switch between available branches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can do &lt;code&gt;:Git checkout &amp;lt;branch-name&amp;gt;&lt;/code&gt;, the problem is that it autocompletes both file names and branches, and I'd prefer a branch list.&lt;/p&gt;&#xA;" OwnerUserId="3216" LastEditorUserId="205" LastEditDate="2015-12-23T06:43:33.000" LastActivityDate="2022-01-31T15:26:29.067" Title="Easiest way to switch git branches" Tags="|command-line|autocompletion|git|plugin-fugitive|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5922" PostTypeId="1" CreationDate="2015-12-23T01:11:17.017" Score="4" ViewCount="2269" Body="&lt;p&gt;I am currently try to break inefficient habits, and one bad habit is to keep a button pressed, e.g. keep pressing &lt;kbd&gt;j&lt;/kbd&gt; to move down approximately 10 lines instead of moving exactly 10 lines down with &lt;code&gt;10j&lt;/code&gt;, or moving across words with &lt;kbd&gt;h&lt;/kbd&gt; and &lt;kbd&gt;l&lt;/kbd&gt; instead of doing wordwide movements with &lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;kbd&gt;b&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to make me realize that I am doing something inefficient, I have currently disabled key repeat on my Ubuntu, yet this affects all key-presses in all application. And while this is a smell in most application, it has its uses for some of them; so I am wondering:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to disable key repeat in vimrc?&lt;/p&gt;&#xA;" OwnerUserId="5449" LastActivityDate="2018-08-03T17:01:13.227" Title="How to disable key repeat in vim?" Tags="|key-bindings|vimrc|normal-mode|repeated-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5923" PostTypeId="2" ParentId="5922" CreationDate="2015-12-23T05:11:45.940" Score="6" Body="&lt;p&gt;This would be not a smart solution, because the &lt;code&gt;hjkl&lt;/code&gt; are particularly useful if you are moving 1-2 characters up and down. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nevertheless, if you want to disable repetition of &lt;code&gt;j&lt;/code&gt; for example use this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap jj &amp;lt;nop&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You also may have to set &lt;code&gt;timeoutlen&lt;/code&gt; to a low value (&lt;code&gt;set timeoutlen=50&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="5763" LastEditorUserId="205" LastEditDate="2015-12-23T05:12:52.020" LastActivityDate="2015-12-23T05:12:52.020" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5925" PostTypeId="2" ParentId="5921" CreationDate="2015-12-23T05:24:12.013" Score="8" Body="&lt;p&gt;You should embrace your terminal. If you use &lt;kbd&gt;CTRL-Z&lt;/kbd&gt;, it will background Vim (or whichever process you are currently running), then you can run any commands you want, the &lt;code&gt;fg&lt;/code&gt; to bring the process back to the foreground:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;CTRL-Z&amp;gt;&#xA;git checkout &amp;lt;tab&amp;gt;&#xA;fg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5763" LastEditorDisplayName="user579" LastEditDate="2018-09-14T01:42:30.243" LastActivityDate="2018-09-14T01:42:30.243" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5926" PostTypeId="1" CreationDate="2015-12-23T10:35:03.463" Score="3" ViewCount="1782" Body="&lt;p&gt;I currently have the following &lt;strong&gt;auto-command&lt;/strong&gt; (in my vimrc) -&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter *.c nmap &amp;lt;F5&amp;gt; :Makexec&amp;lt;CR&amp;gt; &#xA;  \:if findfile( expand(&quot;%:p:r&quot;).&quot;.exe&quot; ,expand(&quot;%:p:h&quot;) ) != &quot;&quot;&amp;lt;CR&amp;gt;&#xA;  \    :!%:p:r.exe&amp;lt;CR&amp;gt;&#xA;  \:else&amp;lt;CR&amp;gt;&#xA;  \    :vert topleft cwin&amp;lt;CR&amp;gt;&#xA;  \    :vert resize 50&amp;lt;CR&amp;gt;&#xA;  \:endif&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;What is Makexec?&lt;br&gt;&#xA;  Not relevant in my opinion, however if necessary see below *&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to convert this auto-command such that it executes a single string where the string contains the above commands chained together.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Attempt 1  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:c_exe_str=&quot;Makexec | if findfile(expand(\&quot;%:p:r\&quot;).\&quot;.exe\&quot;, expand(\&quot;%:p:h\&quot;)) != \&quot;\&quot; | !%:p:r.exe | else | vert topleft cwin | vert resize 50 | endif&quot;&#xA;&#xA;autocmd BufEnter *.c nmap &amp;lt;F5&amp;gt; :execute g:c_exe_str&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This didn't work as I had expected, I get the following error at the shell -&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;C:\windows\system32\cmd.exe /c D:\NewFolder\c_experiments.exe | else |&#xA;  vert topleft cwin | vert resize 50 | endif&lt;br&gt;&#xA;  'else' is not recognized as an internal or external command, operable program or batch file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Attempt 2&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:c_exe_str=&quot;Makexec | if findfile(expand(\&quot;%:p:r\&quot;).\&quot;.exe\&quot;, expand(\&quot;%:p:h\&quot;)) != \&quot;\&quot; | echo system(expand(\&quot;%:p:r\&quot;).\&quot;.exe\&quot;) | else | vert topleft cwin | vert resize 50 | endif&quot;&#xA;&#xA;autocmd BufEnter *.c nmap &amp;lt;F5&amp;gt; :execute g:c_exe_str&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This kinda (sic) works but without displaying the executable's output in a shell window; basically it doesn't work the same way as the original auto-command.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How do I go about exactly mimicking the original auto-command's steps using execute()?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;* &lt;code&gt;command -nargs=? Makexec :w | :silent exe &quot;!rm -f %:p:r.exe&quot; | :let &amp;amp;makeprg='gcc -Wall -Werror -o %&amp;lt; % &amp;lt;args&amp;gt;' | :make!&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5768" LastEditorUserId="5768" LastEditDate="2015-12-23T10:44:43.433" LastActivityDate="2016-01-13T16:39:42.660" Title="How to execute a string of conditional commands which includes a shell command?" Tags="|vimscript|vimrc|" AnswerCount="1" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5927" PostTypeId="2" ParentId="5872" CreationDate="2015-12-23T12:13:20.093" Score="0" Body="&lt;p&gt;I use &lt;code&gt;:ls&lt;/code&gt; to list the buffers open and &lt;code&gt;:b  &amp;lt;filename_from_list_of_open_buffers&amp;gt;&lt;/code&gt; to edit it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;n.b. &lt;code&gt;:b&lt;/code&gt; auto completes so I just start typing and bash the tab key until the file displayed is correct. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I want to open a new buffer, I use &lt;code&gt;e: &amp;lt;filename&amp;gt;&lt;/code&gt;. I am by no means a vim expert so the terminology might be wrong. &lt;/p&gt;&#xA;" OwnerUserId="5653" LastActivityDate="2015-12-23T12:13:20.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5928" PostTypeId="1" AcceptedAnswerId="6225" CreationDate="2015-12-23T12:40:25.993" Score="3" ViewCount="142" Body="&lt;p&gt;&lt;a href=&quot;https://camo.githubusercontent.com/296aecf30e1607233814196db6bd3f5f47e70c73/68747470733a2f2f7261772e6769746875622e636f6d2f5369725665722f756c7469736e6970732f6d61737465722f646f632f64656d6f2e676966&quot; rel=&quot;nofollow&quot;&gt;In this example&lt;/a&gt;, when &lt;code&gt;class&lt;/code&gt; is typed, a list of potential expansions is shown. The snippet itself works in my nvim, but the list is not shown. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Commenting out my whole init.vim (the vimrc of neovim), just leaving the Ultisnip installation hasn't changed anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;=&gt; What is the vim name for that &quot;list&quot; ? How do i fix this? What could i look for to debug it?&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="205" LastEditDate="2015-12-23T15:01:16.047" LastActivityDate="2016-01-23T10:12:43.933" Title="neovim doesn't show expansion &quot;list&quot; of completions" Tags="|autocompletion|neovim|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5929" PostTypeId="1" AcceptedAnswerId="5932" CreationDate="2015-12-23T12:51:14.237" Score="5" ViewCount="721" Body="&lt;p&gt;I'm using &lt;code&gt;r&lt;/code&gt; a lot (e.g. for replacing &lt;code&gt;&quot;&lt;/code&gt; with &lt;code&gt;'&lt;/code&gt; when refactoring code). Is there an easy way to do something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For text: &lt;code&gt;values = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]&lt;/code&gt;.&lt;br&gt;&#xA;Place cursor on first &lt;code&gt;&quot;&lt;/code&gt;, press &lt;code&gt;r'&lt;/code&gt; to change to &lt;code&gt;values = ['a&quot;, &quot;b&quot;, &quot;c&quot;]&lt;/code&gt;.&lt;br&gt;&#xA;Now we want to repeat that five times.&lt;br&gt;&#xA;For example by pressing &lt;code&gt;5&amp;lt;Ctrl&amp;gt;r&lt;/code&gt;.&lt;br&gt;&#xA;To repeat previous &lt;code&gt;r&lt;/code&gt; command five times for next occurences of &lt;code&gt;'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would this be possible? And if so, how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can do &lt;code&gt;&amp;lt;Shift&amp;gt;v:s/&quot;/'/&amp;lt;Enter&amp;gt;&lt;/code&gt;. But this seems inefficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help making my life easier. ;)&lt;/p&gt;&#xA;" OwnerUserId="483" LastActivityDate="2015-12-25T13:43:23.010" Title="Repeat replace one character (r) for next occurence" Tags="|replace|repeated-commands|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5930" PostTypeId="2" ParentId="1905" CreationDate="2015-12-23T12:53:13.977" Score="4" Body="&lt;p&gt;It's not necessary to edit the default syntax file. The &lt;a href=&quot;https://github.com/vim-jp/vim-java&quot; rel=&quot;nofollow&quot;&gt;vim-java&lt;/a&gt; plugin has support for this. Just install like any other plugin and the lambda operator will be highlighted correctly.&lt;/p&gt;&#xA;" OwnerUserId="177" LastActivityDate="2015-12-23T12:53:13.977" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5931" PostTypeId="1" CreationDate="2015-12-23T15:04:10.360" Score="5" ViewCount="77" Body="&lt;p&gt;I have decided to use Vim for editing prose, as I find it to be a much more work-conducive, clutter-free environment than most so-called text processors expressly built for that purpose. To that end, and on the advice of some internet stranger with a blog, I added this function to my vimrc to quickly enable (and disable, I suppose? I don't really know how to tell whether the function has been turned off again) a prose-editing mode which sets a text width and text-wrapping options that make sense for natural languages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! WordProcessorMode()&#xA;    setlocal formatoptions=ant&#xA;    setlocal textwidth=72&#xA;    setlocal wrapmargin=0&#xA;endfu&#xA;&#xA;com! WP call WordProcessorMode()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However - as has already been adressed in this post: &lt;a href=&quot;https://stackoverflow.com/questions/11039544/unwrap-text-in-vim&quot;&gt;https://stackoverflow.com/questions/11039544/unwrap-text-in-vim&lt;/a&gt; - sometimes I would like to unwrap that text in order to paste it into a forum post (as I'm doing right now) or an e-mail editor, or whatever. When I try to &lt;code&gt;vipJ&lt;/code&gt; under this custom word-wrapping mode, though, nothing happens. Why is that? &lt;/p&gt;&#xA;" OwnerUserId="5772" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-12-23T16:08:58.187" Title="vipJ unwrapping fails when using custom function" Tags="|word-processing|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5932" PostTypeId="2" ParentId="5929" CreationDate="2015-12-23T15:38:43.480" Score="8" Body="&lt;p&gt;Well, &lt;code&gt;&amp;lt;Shift&amp;gt;v:s/&quot;/'/&amp;lt;Enter&amp;gt;&lt;/code&gt; is certainly less efficient than &lt;code&gt;:s/&quot;/'&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are various ways to perform the same task:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f&quot;           jump to next &quot;&#xA;r'           replace it with a '&#xA;;.           repeat jump then repeat replace&#xA;;.           repeat jump then repeat replace&#xA;;.           repeat jump then repeat replace&#xA;;.           repeat jump then repeat replace&#xA;;.           repeat jump then repeat replace&#xA;&#xA;/&quot;&amp;lt;CR&amp;gt;       search for next &quot;&#xA;cgn'&amp;lt;Esc&amp;gt;    change it to ' (Note: the gn command was introduced in Vim 7.3.610)&#xA;.....        repeat change 5 times&#xA;&#xA;qq           start recording in register q&#xA;f&quot;           jump to next &quot;&#xA;r'           replace it with '&#xA;q            stop recording&#xA;5@q          replay recording 5 times&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;None of which being as efficient as &lt;code&gt;:s/&quot;/'&amp;lt;CR&amp;gt;&lt;/code&gt; which can be made even better with a small mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt;      :s/&#xA;nnoremap &amp;lt;otherkey&amp;gt; :%s/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cBLT7.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cBLT7.gif&quot; alt=&quot;demo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-12-25T13:43:23.010" LastActivityDate="2015-12-25T13:43:23.010" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5933" PostTypeId="2" ParentId="5921" CreationDate="2015-12-23T18:48:03.917" Score="13" Body="&lt;p&gt;Use the &lt;a href=&quot;https://github.com/idanarye/vim-merginal&quot; rel=&quot;noreferrer&quot;&gt;vim-merginal&lt;/a&gt; plugin (&lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;noreferrer&quot;&gt;fugitive&lt;/a&gt; extension). It offers interactive TUI for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Viewing the list of branches&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Checking out branches from that list&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Creating new branches&lt;/li&gt;&#xA;&lt;li&gt;Deleting branches&lt;/li&gt;&#xA;&lt;li&gt;Merging branches&lt;/li&gt;&#xA;&lt;li&gt;Rebasing branches&lt;/li&gt;&#xA;&lt;li&gt;Solving merge conflicts&lt;/li&gt;&#xA;&lt;li&gt;Interacting with remotes(pulling, pushing, fetching, tracking)&lt;/li&gt;&#xA;&lt;li&gt;Diffing against other branches&lt;/li&gt;&#xA;&lt;li&gt;Renaming branches&lt;/li&gt;&#xA;&lt;li&gt;Viewing git history for branches&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Urfly.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Urfly.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="177" LastEditorUserId="177" LastEditDate="2015-12-23T19:25:59.447" LastActivityDate="2015-12-23T19:25:59.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5934" PostTypeId="2" ParentId="5921" CreationDate="2015-12-23T19:23:03.613" Score="20" Body="&lt;p&gt;To summarize the answers, here are the ways to accomplish this:&lt;/p&gt;&#xA;&lt;h2&gt;Vanilla Terminal Vim in a shell with job control&lt;/h2&gt;&#xA;&lt;p&gt;Press &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;Z&lt;/kbd&gt; in normal mode will drop you back in to the shell and suspend Vim. After executing your &lt;code&gt;git checkout [branchname]&lt;/code&gt;, run the &lt;code&gt;fg&lt;/code&gt; builtin to return to the suspended Vim which will also force Vim to refresh (&lt;code&gt;:help timestamp&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;It is also noteworthy that the &lt;code&gt;:checktime&lt;/code&gt; command in Vim will perform a buffer scan to see what filesystem changes there have been. See &lt;code&gt;:help :checktime&lt;/code&gt; for more info.&lt;/p&gt;&#xA;&lt;p&gt;In vim 8, you can use &lt;code&gt;:terminal&lt;/code&gt; to start a shell, or &lt;code&gt;:terminal git checkout [branchname]&lt;/code&gt; to run one command. Neither will automatically &lt;code&gt;:checktime&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Vanilla GUI Vim&lt;/h2&gt;&#xA;&lt;p&gt;Some gvim implementations will have &lt;code&gt;:shell&lt;/code&gt; support which will open a shell inside of Vim using a dumb terminal. However it may be easier to just type:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:!git checkout [branchname]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will execute the command without having to open a new shell prompt. (This option is also usable in the terminal Vim).&lt;/p&gt;&#xA;&lt;h2&gt;vim-fugitive&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&quot;/questions/tagged/plugin-fugitive&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;plugin-fugitive&amp;#39;&quot; rel=&quot;tag&quot;&gt;plugin-fugitive&lt;/a&gt; is a plugin that allows you to use Git from within Vim. The command would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Git checkout [branchname]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;vim-merginal&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/idanarye/vim-merginal&quot; rel=&quot;noreferrer&quot;&gt;vim-merginal&lt;/a&gt; is a plugin that uses &lt;a href=&quot;/questions/tagged/plugin-fugitive&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;plugin-fugitive&amp;#39;&quot; rel=&quot;tag&quot;&gt;plugin-fugitive&lt;/a&gt; and provides a user friendly-ish interface.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Type &lt;code&gt;:Merginal&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Move cursor to the branch you want.&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;cc&lt;/code&gt; to check out that branch.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="544" LastEditorUserId="10604" LastEditDate="2021-05-25T19:34:14.203" LastActivityDate="2021-05-25T19:34:14.203" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="5935" PostTypeId="2" ParentId="5820" CreationDate="2015-12-23T20:19:53.250" Score="3" Body="&lt;p&gt;After further investigations (and some reverse engineering).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot explain why completion doesn't strictly follow the documentation. I'll have to ask on vim_dev I guess.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, it seems the way to do it consists in registering a listener on &lt;code&gt;CursorMovedI&lt;/code&gt; that'll trigger completion again every time a character is inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difficulty is then to know when to stop.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;CompletionDone&lt;/code&gt; is of no use as it'll be triggered after every key hit.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;InsertLeave&lt;/code&gt; is a good start, but it doesn't cover all cases, i.e.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When a character for which there is no more match is typed, we have to stop&lt;/li&gt;&#xA;&lt;li&gt;When the end-user selects one menu-item, we have to stop as well.&lt;br&gt;&#xA;I've found no way other than overriding &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;c-y&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Other difficulties consist in detecting when nothing has changed in order to avoid kind of infinite loops and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way, here is my current code (that'll be used in other plugins). The &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/icomplete.vim#L138&quot; rel=&quot;nofollow noreferrer&quot;&gt;last version will be maintained here&lt;/a&gt;. It's quite long, but here it is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ## Smart completion {{{2&#xA;&quot; Function: lh#icomplete#new(startcol, matches, hook) {{{3&#xA;function! lh#icomplete#new(startcol, matches, hook) abort&#xA;  silent! unlet b:complete_data&#xA;  let augroup = 'IComplete'.bufnr('%').'Done'&#xA;  let b:complete_data = lh#on#exit()&#xA;        \.restore('&amp;amp;completefunc')&#xA;        \.restore('&amp;amp;complete')&#xA;        \.restore('&amp;amp;omnifunc')&#xA;        \.register('au! '.augroup)&#xA;        \.register('call self.logger.log(&quot;finalized! (&quot;.getline(&quot;.&quot;).&quot;)&quot;)')&#xA;  set complete=&#xA;  let b:complete_data.startcol        = a:startcol&#xA;  let b:complete_data.all_matches     = map(copy(a:matches), 'type(v:val)==type({}) ? v:val : {&quot;word&quot;: v:val}')&#xA;  let b:complete_data.matches         = {'words': [], 'refresh': 'always'}&#xA;  let b:complete_data.hook            = a:hook&#xA;  let b:complete_data.cursor_pos      = []&#xA;  let b:complete_data.last_content    = [line('.'), getline('.')]&#xA;  let b:complete_data.no_more_matches = 0&#xA;  let b:complete_data.logger          = s:logger.reset()&#xA;&#xA;  &quot; keybindings {{{4&#xA;  call b:complete_data&#xA;        \.restore_buffer_mapping('&amp;lt;cr&amp;gt;', 'i')&#xA;        \.restore_buffer_mapping('&amp;lt;c-y&amp;gt;', 'i')&#xA;        \.restore_buffer_mapping('&amp;lt;esc&amp;gt;', 'i')&#xA;        \.restore_buffer_mapping('&amp;lt;tab&amp;gt;', 'i')&#xA;  inoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;cr&amp;gt;  &amp;lt;c-y&amp;gt;&amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;:call b:complete_data.conclude()&amp;lt;cr&amp;gt;&#xA;  inoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;c-y&amp;gt; &amp;lt;c-y&amp;gt;&amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;:call b:complete_data.conclude()&amp;lt;cr&amp;gt;&#xA;  &quot; Unlike usual &amp;lt;tab&amp;gt; behaviour, this time, &amp;lt;tab&amp;gt; inserts the next match&#xA;  inoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;tab&amp;gt; &amp;lt;down&amp;gt;&amp;lt;c-y&amp;gt;&amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;:call b:complete_data.conclude()&amp;lt;cr&amp;gt;&#xA;  &quot; &amp;lt;c-o&amp;gt;&amp;lt;Nop&amp;gt; doesn't work as expected...&#xA;  &quot; To stay in INSERT-mode:&#xA;  &quot; inoremap &amp;lt;silent&amp;gt; &amp;lt;esc&amp;gt; &amp;lt;c-e&amp;gt;&amp;lt;c-o&amp;gt;:&amp;lt;cr&amp;gt;&#xA;  &quot; To return into NORMAL-mode:&#xA;  inoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;esc&amp;gt; &amp;lt;c-e&amp;gt;&amp;lt;esc&amp;gt;&#xA;  &quot; TODO: see to have &amp;lt;Left&amp;gt;, &amp;lt;Right&amp;gt;, &amp;lt;Home&amp;gt;, &amp;lt;End&amp;gt; abort&#xA;&#xA;  &quot; Group {{{4&#xA;  exe 'augroup '.augroup&#xA;    au!&#xA;    &quot; Emulate InsertCharPost&#xA;    &quot; au CompleteDone &amp;lt;buffer&amp;gt; call b:complete_data.logger.log(&quot;Completion done&quot;)&#xA;    au InsertLeave  &amp;lt;buffer&amp;gt; call b:complete_data.finalize()&#xA;    au CursorMovedI &amp;lt;buffer&amp;gt; call b:complete_data.cursor_moved()&#xA;  augroup END&#xA;&#xA;  function! s:cursor_moved() abort dict &quot;{{{4&#xA;    if self.no_more_matches&#xA;      call self.finalize()&#xA;      return&#xA;    endif&#xA;    if !self.has_text_changed_since_last_move()&#xA;      call s:logger.log(lh#fmt#printf(&quot;cursor %1 just moved (text hasn't changed)&quot;, string(getpos('.'))))&#xA;      return&#xA;    endif&#xA;    call s:logger.log(lh#fmt#printf('cursor moved %1 and text has changed -&amp;gt; relaunch completion', string(getpos('.'))))&#xA;    call feedkeys( &quot;\&amp;lt;C-X&amp;gt;\&amp;lt;C-O&amp;gt;\&amp;lt;C-P&amp;gt;\&amp;lt;Down&amp;gt;&quot;, 'n' )&#xA;  endfunction&#xA;  let b:complete_data.cursor_moved = function('s:cursor_moved')&#xA;&#xA;  function! s:has_text_changed_since_last_move() abort dict &quot;{{{4&#xA;    let l = line('.')&#xA;    let line = getline('.')&#xA;    try&#xA;      if l != self.last_content[0]  &quot; moved vertically&#xA;        let self.no_more_matches = 1&#xA;        call s:logger.log(&quot;Vertical move =&amp;gt; stop&quot;)&#xA;        return 0&#xA;        &quot; We shall leave complete mode now!&#xA;      endif&#xA;      call s:logger.log(lh#fmt#printf(&quot;line was: %1, and becomes: %2; has_changed?%3&quot;, self.last_content[1], line, line != self.last_content[1]))&#xA;      return line != self.last_content[1] &quot; text changed&#xA;    finally&#xA;      let self.last_content = [l, line]&#xA;    endtry&#xA;  endfunction&#xA;  let b:complete_data.has_text_changed_since_last_move = function('s:has_text_changed_since_last_move')&#xA;&#xA;  function! s:complete(findstart, base) abort dict &quot;{{{4&#xA;    call s:logger.log(lh#fmt#printf('findstart?%1 -&amp;gt; %2', a:findstart, a:base))&#xA;    if a:findstart&#xA;      if self.no_more_matches&#xA;        call s:logger.log(&quot;no more matches -&amp;gt; -3&quot;)&#xA;        return -3&#xA;        call self.finalize()&#xA;      endif&#xA;      if self.cursor_pos == getcurpos()&#xA;        call s:logger.log(&quot;cursor hasn't moved -&amp;gt; -2&quot;)&#xA;        return -2&#xA;      endif&#xA;      let self.cursor_pos = getcurpos()&#xA;      return self.startcol&#xA;    else&#xA;      return self.get_completions(a:base)&#xA;    endif&#xA;  endfunction&#xA;  let b:complete_data.complete = function('s:complete')&#xA;&#xA;  function! s:get_completions(base) abort dict &quot;{{{4&#xA;    let matching = filter(copy(self.all_matches), 'v:val.word =~ join(split(a:base, &quot;.\\zs&quot;), &quot;.*&quot;)')&#xA;    let self.matches.words = matching&#xA;    call s:logger.log(lh#fmt#printf(&quot;'%1' matches: %2&quot;, a:base, string(self.matches)))&#xA;    if empty(self.matches.words)&#xA;      call s:logger.log(&quot;No more matches...&quot;)&#xA;      let self.no_more_matches = 1&#xA;    endif&#xA;    return self.matches&#xA;  endfunction&#xA;  let b:complete_data.get_completions = function('s:get_completions')&#xA;&#xA;  function! s:conclude() abort dict &quot; {{{4&#xA;    let selection = getline('.')[self.startcol : col('.')-1]&#xA;    call s:logger.log(&quot;Successful selection of &amp;lt;&quot;.selection.&quot;&amp;gt;&quot;)&#xA;    if !empty(self.hook)&#xA;      call lh#function#execute(self.hook, selection)&#xA;    endif&#xA;    &quot; call self.hook()&#xA;    call self.finalize()&#xA;  endfunction&#xA;  let b:complete_data.conclude = function('s:conclude')&#xA;&#xA;  &quot; Register {{{4&#xA;  &quot; call b:complete_data&#xA;        &quot; \.restore('b:complete_data')&#xA;  &quot; set completefunc=lh#icomplete#func&#xA;  set omnifunc=lh#icomplete#func&#xA;endfunction&#xA;&#xA;&quot; Function: lh#icomplete#new_on(pattern, matches, hook) {{{3&#xA;function! lh#icomplete#new_on(pattern, matches, hook) abort&#xA;  let l = getline('.')&#xA;  let startcol = match(l[0:col('.')-1], '\v'.a:pattern.'+$')&#xA;  if startcol == -1&#xA;    let startcol = col('.')-1&#xA;  endif&#xA;  call lh#icomplete#new(startcol, a:matches, a:hook)&#xA;endfunction&#xA;&#xA;&quot; Function: lh#icomplete#func(startcol, base) {{{3&#xA;function! lh#icomplete#func(findstart, base) abort&#xA;  return b:complete_data.complete(a:findstart, a:base)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be used with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let entries = [&#xA;  \ {'word': 'un', 'menu': 1},&#xA;  \ {'word': 'deux', 'menu': 2},&#xA;  \ {'word': 'trois', 'menu': 3},&#xA;  \ {'word': 'trentre-deux', 'menu': 32},&#xA;  \ 'unité'&#xA;  \ ]&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; µ &amp;lt;c-o&amp;gt;:call lh#icomplete#new_on('\w', entries, 'lh#common#warning_msg(&quot;nominal: &quot;.v:val)')&amp;lt;cr&amp;gt;&amp;lt;c-x&amp;gt;&amp;lt;c-O&amp;gt;&amp;lt;c-p&amp;gt;&amp;lt;down&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should be able to observe (indirectly) the result applied to C++ snippets selection for my template expander plugin on this &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp/blob/master/doc/screencast-snippet-baseNV-class.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;screencast&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-01-30T22:00:56.967" LastActivityDate="2017-01-30T22:00:56.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5936" PostTypeId="2" ParentId="4255" CreationDate="2015-12-23T21:39:17.987" Score="9" Body="&lt;p&gt;Certain commands such as &lt;code&gt;g&lt;/code&gt;, &lt;code&gt;z&lt;/code&gt;, &lt;code&gt;f&lt;/code&gt; or &lt;code&gt;Ctrl-W&lt;/code&gt; expect another key afterwards. Those commands will call &lt;code&gt;plain_vgetch()&lt;/code&gt; internally, which is a function that loops and waits until it receives a key (and ignores certain internal key events such as Scrollbar or Ignore events).&#xA;By setting some additional global variables, it will be made sure, that those keys won't be mapped and the plain keycode will be returned. But depending on the command, the languange maps might apply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What will be done, depends on the flags for the normal mode commands (see the definition of &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/normal.c#L217&quot;&gt;the &lt;code&gt;nv_cmd&lt;/code&gt; struct in &lt;code&gt;normal.c&lt;/code&gt;&lt;/a&gt;). The &lt;code&gt;NV_NCH*&lt;/code&gt; flags mean that another char needs to be obtained.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="205" LastEditDate="2015-12-23T22:21:17.607" LastActivityDate="2015-12-23T22:21:17.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5937" PostTypeId="1" AcceptedAnswerId="5939" CreationDate="2015-12-23T23:33:09.133" Score="3" ViewCount="174" Body="&lt;p&gt;When I open a PHP file in Vim I want Vim to provide SQL assistance as well as all the PHP assistance.&lt;br&gt;&#xA;From &lt;a href=&quot;http://vimhelp.appspot.com/ft_sql.txt.html#sql-completion-filetypes&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h sql-completion-filetypes&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This can be enabled easily with the following steps (assuming a Perl&#xA;  file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.  :e test.pl  &#xA;2.  :set filetype=sql  &#xA;3.  :set ft=perl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would like to automate this:&#xA;So far I have tried&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Appending the following commands to &lt;code&gt;~/.vim/after/ftplugins/php.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set filetype=sql  &#xA;:set ft=php&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This throws errors like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing FileType Auto commands for &quot;*&quot;:       &#xA;E218: autocommand nesting too deep&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which I'm assuming is happening because when whenever the &lt;code&gt;set ft=php&lt;/code&gt; command is run - it then re-triggers the &lt;code&gt;~/.vim/after/ftplugins/php.vim&lt;/code&gt; script which then re-triggers the &lt;code&gt;set ft=php&lt;/code&gt; statement.&lt;br&gt;&#xA;Is it possible to automate running these commands &lt;code&gt;:set filetype=sql&lt;/code&gt;, &lt;code&gt;:set ft=php&lt;/code&gt; when opening a php file?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="205" LastEditDate="2015-12-24T04:45:15.713" LastActivityDate="2015-12-24T04:52:20.447" Title="Automate running SQL filetype scripts when opening a PHP file" Tags="|autocmd|filetype|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5938" PostTypeId="1" AcceptedAnswerId="5940" CreationDate="2015-12-24T03:38:26.037" Score="3" ViewCount="1200" Body="&lt;p&gt;If I define the variable &lt;code&gt;foo&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let foo = '~/Desktop'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to check the length of the string it contains, then I can type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo strlen(foo)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output is 9, which is right.&lt;br&gt;&#xA;If I had typed &lt;code&gt;:echo strlen('foo')&lt;/code&gt;, the output would have been 3, because Vim would have calculated the length of the string &lt;code&gt;'foo'&lt;/code&gt; instead of the evaluation of the variable &lt;code&gt;foo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I want to expand the filepath contained in &lt;code&gt;foo&lt;/code&gt;.&lt;br&gt;&#xA;The following command doesn't echo any message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo glob('foo')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the following does output something (&lt;code&gt;/home/username/Desktop&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo glob(foo)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, these 2 examples seem to show that if I want to pass the evaluation of a variable name as an argument to a function, I must not put quotes around it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if I want to check whether the variable &lt;code&gt;foo&lt;/code&gt; exists and has been defined, and I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:if exists(foo) | echo &quot;success!&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's no output. However, the following works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:if exists('foo') | echo &quot;success!&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This time, it was different, as I needed to put quotes around &lt;code&gt;foo&lt;/code&gt; for it to be evaluated by &lt;code&gt;exists()&lt;/code&gt;.&#xA;Why do I need to use quotes with &lt;code&gt;exists()&lt;/code&gt; but neither with &lt;code&gt;strlen()&lt;/code&gt; nor with &lt;code&gt;glob()&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When do you need to put quotes around a variable name which is passed as an argument to a function?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="205" LastEditDate="2015-12-24T05:03:28.880" LastActivityDate="2015-12-24T05:03:28.880" Title="As an argument of a function, when does a variable name need to be quoted?" Tags="|vimscript|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5939" PostTypeId="2" ParentId="5937" CreationDate="2015-12-24T04:52:20.447" Score="3" Body="&lt;p&gt;On my Vim (7.4.944), the SQL filetype plugin performs &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/ftplugin/sql.vim#L101&quot; rel=&quot;nofollow&quot;&gt;the following check&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(&quot;*SQL_SetType&quot;)&#xA;    &quot; NOTE: You cannot use function! since this file can be&#xA;    &quot; sourced from within this function.  That will result in&#xA;    &quot; an error reported by Vim.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That seems to be a good way to load &lt;code&gt;sql.vim&lt;/code&gt; once. So, in my &lt;code&gt;~/.vim/ftplugin/php.vim&lt;/code&gt;, I added:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(&quot;*SQL_SetType&quot;)&#xA;    set ft=sql&#xA;    set ft=php&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't use SQL in PHP, but AFAICT, the SQL settings were loaded.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-12-24T04:52:20.447" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5940" PostTypeId="2" ParentId="5938" CreationDate="2015-12-24T05:02:05.760" Score="4" Body="&lt;p&gt;It has to do with the nature of &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#exists%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;exists()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Note that the argument must be a string, not the name of the&#xA; variable itself.  For example: &#xA;         exists(bufcount)&#xA;This doesn't check for existence of the &quot;bufcount&quot; variable,&#xA; but gets the value of &quot;bufcount&quot;, and checks if that exists.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;exists()&lt;/code&gt; examines the contents of the argument, if you want to check if a variable named &lt;code&gt;foo&lt;/code&gt; exists, you must pass it a string containing &lt;code&gt;foo&lt;/code&gt;. You could have done the following just as well (after defining &lt;code&gt;foo&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let bar = 'foo'&#xA;:if exists(bar) | echo &quot;success!&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, you need to quote the variable and make it a string, when you're interested in dealing with the variable itself, not its contents.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-12-24T05:02:05.760" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5941" PostTypeId="1" AcceptedAnswerId="5943" CreationDate="2015-12-24T05:56:36.473" Score="9" ViewCount="6886" Body="&lt;p&gt;While working in various source files, (C, Ruby, etc.) I find that I'm often hunting around for functions. Is there a way to have an auto-generated HUD that lists the structure of the current file? It would be fantastic if it linked to different &lt;em&gt;parts&lt;/em&gt; of the file, similar to how NERDTree links to different files. Or, similar to the side-navs in the screenshots here: &lt;a href=&quot;https://stackoverflow.com/questions/16895610/gen-file-missing-incomplete-in-eclipse&quot;&gt;https://stackoverflow.com/questions/16895610/gen-file-missing-incomplete-in-eclipse&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming that this doesn't exist as a plugin or something, how do people usually navigate around files like this?&lt;/p&gt;&#xA;" OwnerUserId="4748" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2021-02-18T23:52:59.947" Title="Summary of functions in current file?" Tags="|plugin-system|plugin-nerdtree|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5942" PostTypeId="2" ParentId="5902" CreationDate="2015-12-24T08:40:01.657" Score="0" Body="&lt;p&gt;As I noticed that there were other similar lists of files for which I wanted a navigation similar to a normal buffer (arglist, buffer list, changelist, jumplist, tag stack), I tried to adapt the answer proposed by EvergreenTree to them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Redir() redirects the output of an Ex command into a scratch buffer&#xA;&quot; displayed in a new horizontal split, vertical split or tab.&#xA;&quot; The Ex command is passed to the function with the argument a:command,&#xA;&quot; and the destination of the output is chosen with a:where&#xA;&#xA;function! s:Redir(command, where) abort&#xA;&#xA;    &quot; Begin capture inside variable l:output&#xA;    redir =&amp;gt; l:output&#xA;    &quot; Execute a:command (silently)&#xA;    silent! execute a:command&#xA;    &quot; End redirection&#xA;    redir END&#xA;&#xA;    if empty(l:output)&#xA;        &quot; If nothing was captured, display a message and exit&#xA;        echom &quot;No output&quot;&#xA;        return&#xA;    else&#xA;        &quot; If we open a new tab to display the capture, when we will close it,&#xA;        &quot; we want to go back to the exact tab where we were.&#xA;        &quot; To do so, we need to memorize the number of the current tab&#xA;        let s:lasttab = tabpagenr()&#xA;&#xA;        &quot; Execute the 2nd argument a:where silently to open a new horizontal&#xA;        &quot; split, vertical split or tab.&#xA;        &quot; a:where should be equal to &quot;new&quot;, &quot;vert new&quot;, or &quot;tabnew&quot;&#xA;        silent! execute a:where&#xA;&#xA;        &quot; Define a special buffer type ; it must not:&#xA;        &quot;     - be related to a file&#xA;        &quot;     - create a swap file&#xA;        &quot;     - pollute the buffer list&#xA;        &quot;     - leave any trace after being abandoned&#xA;        setlocal buftype=nofile noswapfile nobuflisted bufhidden=wipe&#xA;&#xA;        &quot; Paste the capture&#xA;        silent! put =l:output&#xA;&#xA;        &quot; If some lines of the output are too long for the screen,&#xA;        &quot; don't wrap them because it can make them difficult to read&#xA;        setlocal nowrap&#xA;&#xA;        &quot; Remove empty lines, or a line with the single character '&amp;gt;'&#xA;        silent! g/^\s*$/d&#xA;        silent! g/^&amp;gt;$/d&#xA;&#xA;        if a:command ==# &quot;args&quot;&#xA;            &quot; All args are packed on a single line.&#xA;            &quot; Format the output, so that each arg is on a separate line&#xA;            silent! keeppatterns s; ;\r;g&#xA;&#xA;            &quot; The current argument is surrounded with []&#xA;            &quot; Because of the square brackets, when we hit Enter on its line,&#xA;            &quot; nothing happens.&#xA;            &quot;&#xA;            &quot; Remove them, and put 4 spaces in front of its name, so that&#xA;            &quot; we still have a way to distinguish it from the other arguments&#xA;            silent! keeppatterns %s;\v^\[(.*)\]$;    \1;g&#xA;&#xA;            &quot; Delete last line, because it's empty&#xA;            $delete&#xA;        endif&#xA;&#xA;        &quot; Prevent buffer to be modified, then go on last line&#xA;        setlocal nomodifiable | $&#xA;    endif&#xA;&#xA;    &quot; Check whether a:command is somewhere in s:mapping_dict ; if it's not&#xA;    &quot; MoveCursor() can't send us anywhere when we hit Enter on a line, and&#xA;    &quot; there's no need to create a mapping to call it&#xA;    if has_key(s:mapping_dict, a:command)&#xA;&#xA;    &quot; In the output, when we hit Enter on an entry, we want the scratch buffer&#xA;    &quot; to be closed, and the cursor to move to the exact location of the entry.&#xA;    &quot;&#xA;    &quot; We will delegate this task to the MoveCursor() function.&#xA;    &quot; For now, we just define a mapping to call it.&#xA;    &quot;&#xA;    &quot; MoveCursor() must know from which command is the output we are reading&#xA;    &quot; when we hit Enter, so we must pass a:command as an argument.&#xA;    &quot;&#xA;    &quot; Since the mapping contains a variable (a:command) we must build the&#xA;    &quot; mapping with a concatenation of strings and execute the result with&#xA;    &quot; :execute&#xA;    &quot;&#xA;    &quot; Also we use &amp;lt;buffer&amp;gt; to make the mapping local to the scratch buffer&#xA;        execute 'nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;return&amp;gt;&#xA;                    \ :call &amp;lt;SID&amp;gt;MoveCursor(&quot;' . a:command . '&quot;)&amp;lt;cr&amp;gt;'&#xA;&#xA;    endif&#xA;&#xA;endfunction&#xA;&#xA;&quot; We want global mappings to call Redir(), passing automatically various&#xA;&quot; Ex commands as an argument. The Ex command can be :&#xA;&quot; :args, :buffers, :changes, :jumps, :tags&#xA;&quot;&#xA;&quot; The following dictionary maps a letter to each of them.&#xA;&quot; The letter is going to be used to define a mapping of the form:&#xA;&quot; &amp;lt;leader&amp;gt;g{letter}&#xA;let s:mapping_dict = {'args':'a', 'buffers':'b', 'changes':'c', 'jumps':'j',&#xA;            \ 'tags':'t',}&#xA;&#xA;for i in range(len(s:mapping_dict))&#xA;    &quot; Store every command and every letter from the dictionary respectively&#xA;    &quot; in s:command and s:letter&#xA;    let [s:command, s:letter] = items(s:mapping_dict)[i]&#xA;&#xA;    &quot; For each command in the dictionary, define a mapping such as:&#xA;    &quot; nnoremap &amp;lt;silent&amp;gt; ,gj :call &amp;lt;SID&amp;gt;Redir(&quot;jumps&quot;, &quot;tabnew&quot;)&amp;lt;cr&amp;gt;&#xA;    execute 'nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;g' . s:letter .&#xA;                \ ' :call &amp;lt;SID&amp;gt;Redir(&quot;' . s:command . '&quot;, &quot;tabnew&quot;)&amp;lt;cr&amp;gt;'&#xA;endfor&#xA;&#xA;&quot; Define the Ex command :Redir which calls the function Redir()&#xA;&quot; Give it the attribute '-complete' with the value 'command' so that vim&#xA;&quot; auto-completes a word typed after :Redir and suggests a command name&#xA;&quot;&#xA;&quot; :Redir can be useful to read the output of other system commands, from the&#xA;&quot; command line. For example:&#xA;&quot; :augroup, :autocmd, :command, :function&#xA;command! -nargs=1 -complete=command Redir call &amp;lt;SID&amp;gt;Redir(&amp;lt;q-args&amp;gt;, &quot;tabnew&quot;)&#xA;&#xA;&quot; Definition of MoveCursor()&#xA;&quot; Whenever Redir() calls MoveCursor(), it sends it the name of an Ex&#xA;&quot; command (:args, :buffers, :changes, :jumps, :tags) as an argument.&#xA;&#xA;function! s:MoveCursor(command) abort&#xA;&#xA;    &quot; Field() is a function who takes an index number as an argument (idx), and&#xA;    &quot; returns the idx-th field of the current line&#xA;    function! s:Field(idx) abort&#xA;        return split(getline('.'))[a:idx]&#xA;    endfunction&#xA;&#xA;    &quot; The entries in every output display a buffer name in a field.&#xA;    &quot; The index of this field varies from one command to another.&#xA;    &quot; Same thing for the line number and the column number.&#xA;    &quot;&#xA;    &quot; The following dictionaries map the name of a command to the field index&#xA;    &quot; in which a buffer name, a line number and a column number can be found.&#xA;    &quot;&#xA;    &quot; -1 means the command doesn't output any buffer name / line number /&#xA;    &quot;  colomn number&#xA;    let [l:buffer_idx_dict, l:line_idx_dict, l:col_idx_dict] =&#xA;                \ [{&quot;args&quot;:0, &quot;buffers&quot;:0, &quot;changes&quot;:-1, &quot;jumps&quot;:3, &quot;tags&quot;:4,},&#xA;                \ {&quot;args&quot;:-1, &quot;buffers&quot;:-1, &quot;changes&quot;:1, &quot;jumps&quot;:1, &quot;tags&quot;:3,},&#xA;                \ {&quot;args&quot;:-1, &quot;buffers&quot;:-1, &quot;changes&quot;:2, &quot;jumps&quot;:2, &quot;tags&quot;:-1,}]&#xA;&#xA;    &quot; In those 3 dictionaries, look up the field index for a:command&#xA;    &quot; and store them in 3 variables:&#xA;    &quot; l:buffer_field, l:line_field and l:col_field&#xA;    let [l:buffer_idx, l:line_idx, l:col_idx] =&#xA;                \ [l:buffer_idx_dict[a:command],&#xA;                \ l:line_idx_dict[a:command],&#xA;                \ l:col_idx_dict[a:command]]&#xA;&#xA;    &quot; If the index is different from -1, we can call Field() to retrieve the&#xA;    &quot; content of a specific field:&#xA;    &quot; a buffer name, a line number, a column number&#xA;    &quot;&#xA;    &quot; We store those informations in 3 variables:&#xA;    &quot; l:bname, l:lnum, l:cnum&#xA;    if l:buffer_idx != -1 | let l:bname = &amp;lt;SID&amp;gt;Field(l:buffer_idx) | endif&#xA;    if l:line_idx != -1 | let l:lnum = &amp;lt;SID&amp;gt;Field(l:line_idx) | endif&#xA;    if l:col_idx != -1 | let l:cnum = &amp;lt;SID&amp;gt;Field(l:col_idx) | endif&#xA;&#xA;    &quot; In the output of :tags, the file name is displayed with a relative path;&#xA;    &quot; example: intro.txt&#xA;    &quot; We need an absolute path; example: /usr/share/vim/vim74/doc/intro.txt&#xA;    if a:command ==# 'tags' |&#xA;                \ let l:bname = glob('$VIMRUNTIME') . '/doc/' . l:bname | endif&#xA;&#xA;    &quot; Store new cursor position inside variable l:pos&#xA;    if exists('l:lnum') &amp;amp;&amp;amp; exists('l:cnum') |&#xA;                \ let l:pos = [0, l:lnum, l:cnum, 0] |&#xA;                \ elseif exists('l:lnum') |&#xA;                \ let l:pos = [0, l:lnum, 0, 0] |&#xA;                \ endif&#xA;&#xA;    &quot; Close scratch buffer&#xA;    wincmd q&#xA;&#xA;    &quot; Go back to the last tab we were before opening scratch buffer&#xA;    execute 'tabnext ' . s:lasttab&#xA;&#xA;    &quot; If l:bname exists and:&#xA;    &quot; it matches an existing file, or a:command is 'buffers',&#xA;    &quot; then load it in the current window.&#xA;    &quot;&#xA;    &quot; Need to check if bname exists because there could be no buffer name,&#xA;    &quot; e.g.: entries in the jumplist whose motion stays in the current buffer.&#xA;    &quot; Need to check if bname matches a file because sometimes it's just&#xA;    &quot; a random string of text (e.g. some entries in the jumplist and in the&#xA;    &quot; tag stack).&#xA;    &quot; If a:command = 'buffers', then bname is a number not a filename, so&#xA;    &quot; the previous check will fail but we do want the buffer to be loaded&#xA;    &quot; anyway.&#xA;&#xA;    if exists('l:bname') &amp;amp;&amp;amp; ( !empty(glob(l:bname)) || a:command ==# 'buffers' )&#xA;&#xA;        &quot; We could use :sbuffer instead of :buffer because&#xA;        &quot;     if &amp;amp;switchbuf = useopen,usetab&#xA;        &quot; and if l:bname is already displayed in another window or tab,&#xA;        &quot; then instead of loading the buffer in the current window, the focus&#xA;        &quot; would be switched to wherever the buffer is currently displayed.&#xA;        &quot;&#xA;        &quot; Problem: if the buffer is not displayed, :sbuffer opens a new split&#xA;        &quot; instead of loading the buffer in the current window&#xA;        &quot; Do we want that ?&#xA;&#xA;        execute 'buffer ' . l:bname&#xA;    endif&#xA;&#xA;    &quot; Set cursor position&#xA;    if exists('l:pos') | silent! call setpos('.', l:pos) | endif&#xA;&#xA;    &quot; Fold everything except where we are&#xA;    normal zMzv&#xA;    &quot; Set current line as the middle of the screen&#xA;    normal zz&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I didn't test it much but so far it seems to work.&lt;br&gt;&#xA;It defines 5 mappings (&lt;code&gt;&amp;lt;leader&amp;gt;ga&lt;/code&gt;, &lt;code&gt;&amp;lt;leader&amp;gt;gb&lt;/code&gt;, &lt;code&gt;&amp;lt;leader&amp;gt;gc&lt;/code&gt;, &lt;code&gt;&amp;lt;leader&amp;gt;gj&lt;/code&gt;, &lt;code&gt;&amp;lt;leader&amp;gt;gt&lt;/code&gt;) to navigate through the arglist, buffer list, changelist, jumplist and tagstack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current behavior is to display the buffer described in the entry of a list in the current window, but I wonder if it wouldn't be better to first check whether the buffer is already displayed in another one. If it is, the focus should then be given to it instead of displaying the buffer in a 2nd window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't know how to do that.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-24T10:06:50.927" LastActivityDate="2015-12-24T10:06:50.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5943" PostTypeId="2" ParentId="5941" CreationDate="2015-12-24T09:15:53.493" Score="12" Body="&lt;p&gt;You could try either &lt;a href=&quot;http://vim-taglist.sourceforge.net/&quot;&gt;TagList&lt;/a&gt; or &lt;a href=&quot;http://majutsushi.github.io/tagbar/&quot;&gt;TagBar&lt;/a&gt; but such a list could be generated as needed (no third party tool or configuration needed) with a simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/func/#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :global&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't mind a little bit of per-filetype configuration, the &lt;code&gt;:dlist&lt;/code&gt; command could be used to list every function in the current file &lt;em&gt;and&lt;/em&gt; included files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:dlist /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help definition-search&lt;/code&gt;, &lt;code&gt;:help 'include'&lt;/code&gt;, &lt;code&gt;:help 'define'&lt;/code&gt;, &lt;code&gt;:help 'suffixesadd'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-24T09:15:53.493" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5944" PostTypeId="2" ParentId="5902" CreationDate="2015-12-24T11:40:56.240" Score="1" Body="&lt;p&gt;You can use a plugin for this, like &lt;a href=&quot;https://github.com/sjl/gundo.vim.git&quot; rel=&quot;nofollow&quot;&gt;gundo.vim&lt;/a&gt; (DerW answer) or &lt;a href=&quot;https://github.com/mbbill/undotree&quot; rel=&quot;nofollow&quot;&gt;undotree&lt;/a&gt;. Actually undotree is better since has more customizations and realtime update.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, my vimrc has the following configurations for the undotree:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;tu :UndotreeToggle&amp;lt;CR&amp;gt;&#xA;let g:undotree_WindowLayout=3&#xA;let g:undotree_SetFocusWhenToggle=0&#xA;let g:undotree_TreeNodeShape='▶'&#xA;let g:undotree_DiffpanelHeight=30&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="177" LastActivityDate="2015-12-24T11:40:56.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5945" PostTypeId="1" CreationDate="2015-12-24T12:15:23.720" Score="5" ViewCount="1679" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/3434/dont-add-new-line-at-the-end-of-a-file&quot;&gt;Some people prefer not to&lt;/a&gt; end a file with a new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not one of them. In fact, I want to &lt;em&gt;see&lt;/em&gt; that it's there!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I keep this 'force new line at end' behaviour, but show it in the editor? I often leave a double new line accidentally, because I've added one myself too.&lt;/p&gt;&#xA;" OwnerUserId="5778" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2015-12-24T12:56:25.280" Title="Still force new line at end, but show it too?" Tags="|vimrc|line-breaks|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5946" PostTypeId="1" AcceptedAnswerId="5947" CreationDate="2015-12-24T12:20:24.103" Score="4" ViewCount="943" Body="&lt;p&gt;Is it possible to swap the order of the command line and status line, such that the status line is flush with the bottom?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or better yet, completely disable the command line - but I understand that not to be possible.&lt;/p&gt;&#xA;" OwnerUserId="5778" LastEditorUserId="5778" LastEditDate="2015-12-24T13:36:50.313" LastActivityDate="2022-08-10T10:52:59.957" Title="Swap command line and status-line?" Tags="|command-line|statusline|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5947" PostTypeId="2" ParentId="5946" CreationDate="2015-12-24T12:27:55.693" Score="5" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;What you call the &quot;mode line&quot; is actually called &quot;command line&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can't move it around.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can't disable it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-24T12:27:55.693" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5948" PostTypeId="2" ParentId="5945" CreationDate="2015-12-24T12:56:25.280" Score="4" Body="&lt;p&gt;Like &lt;em&gt;so many people&lt;/em&gt;, you seem to mix up &quot;new line&quot; and &quot;newline&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When editing a file where the last line doesn't end with a &quot;newline&quot; character, Vim will add that &quot;newline&quot; character on write unless the &lt;code&gt;'noeol'&lt;/code&gt; and &lt;code&gt;'binary'&lt;/code&gt; option are set. So, basically, you probably &lt;em&gt;always&lt;/em&gt; have that &quot;newline&quot; character at the end of your files, whether you see it or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;newline&quot; character can be interpreted in two ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;as a &quot;line terminator&quot;, the editor considers anything that comes after a &quot;newline&quot; character to be on another line;&lt;/li&gt;&#xA;&lt;li&gt;as a &quot;line separator&quot;, the editor considers that the &quot;newline&quot; character must be &lt;em&gt;between&lt;/em&gt; two lines.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the first interpretation, that &quot;newline&quot; character at the end of the last line can't really be displayed in any useful way because it is the same as any other &quot;newline&quot; character at the end of any other line in the file. If you think about it, there's no real &lt;em&gt;need&lt;/em&gt; to even display it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the second interpretation, that &quot;newline&quot; character at the end of the last line is not displayed either but, because the interpretation mandates the presence of another line after the &quot;newline&quot; character, the editor adds a &quot;new line&quot; at the end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding such a &quot;new line&quot; at the end of the file just as misleading as it is unnecessary and wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Vim way is simply to assume the &quot;newline&quot; character is there and thus to not add an unnecessary &quot;new line&quot; at the end of the file.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-24T12:56:25.280" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="5949" PostTypeId="1" CreationDate="2015-12-24T13:36:33.033" Score="18" ViewCount="12522" Body="&lt;p&gt;I have the following in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! AddSpaceBeforeEqual()&#xA;  s/\([a-z)_0-9&quot;'\[\]]\)=/\1 =/ge&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/Kuniwak/vint&quot;&gt;vint&lt;/a&gt; to lint my vimrc, and got the following warning : &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;ProhibitCommandWithUnintendedSideEffect&lt;/strong&gt;   Avoid commands with unintended side effects. Avoid using :s[ubstitute] as it moves the cursor and prints error messages. Prefer functions (such as search()) better suited to scripts. For many vim commands, functions exist that do the same thing with fewer side effects. See :help functions() for a list of built-in functions.   Google Vimscript Style Guide&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, I do not think that they is a way to do the substitution without using the &lt;code&gt;:s&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the &lt;code&gt;search()&lt;/code&gt; function gives the lines matching a pattern, but there is no way to do substitution.&#xA;The &lt;code&gt;substitute()&lt;/code&gt; function operates on a string, and doesn't substitute on a whole file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I implement a substitute method myself, or is they a smarter way to rewrite my function ?&lt;/p&gt;&#xA;" OwnerUserId="1543" LastEditorUserId="865" LastEditDate="2015-12-24T15:59:41.427" LastActivityDate="2015-12-25T17:03:02.350" Title="Substitute with pure vimscript (without `:s`)" Tags="|vimscript|substitute|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5950" PostTypeId="1" CreationDate="2015-12-24T13:45:39.580" Score="4" ViewCount="478" Body="&lt;p&gt;I use Vim v7.4 on a Windows laptop.  Recently, I copied my &lt;code&gt;.vimrc&lt;/code&gt; from a Mac, only to find that every time I leave insert mode, a sequence of strange characters will appear:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pGfrC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pGfrC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These characters (right after the cursor) don't actually exist, and they always follow the current position of cursor whenever I switch back to normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this with a blank &lt;code&gt;.vimrc&lt;/code&gt;, and the issue didn't occur.  However, my current &lt;code&gt;.vimrc&lt;/code&gt; is pretty big, and I have no idea how to debug this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to solve this issue?&lt;/p&gt;&#xA;" OwnerUserId="902" LastEditorUserId="1292" LastEditDate="2018-08-30T10:36:52.457" LastActivityDate="2018-08-30T10:36:52.457" Title="Strange characters appear after leaving insert mode on Windows" Tags="|microsoft-windows|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5951" PostTypeId="2" ParentId="4848" CreationDate="2015-12-24T14:28:28.237" Score="2" Body="&lt;p&gt;A workaround may be put the code in a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CallF7()&#xA;    execute '!gtags'&amp;lt;cr&amp;gt; :cscope kill -1&amp;lt;cr&amp;gt; :cscope add CTAGS&amp;lt;cr&amp;gt;&#xA;endfunction&#xA;nnoremap &amp;lt;F7&amp;gt; :call CallF7()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (mycondition)&#xA;  call CallF7()&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="177" LastActivityDate="2015-12-24T14:28:28.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5952" PostTypeId="2" ParentId="5949" CreationDate="2015-12-24T15:56:02.473" Score="13" Body="&lt;p&gt;The reason it is warning you about unintended side effects is because &lt;code&gt;:substitute&lt;/code&gt; does move the cursor and overwrite the previous search &lt;em&gt;(if used outside of a function)&lt;/em&gt;.  However, this does not mean you shouldn't use it, as you can reverse the side effects of &lt;code&gt;:substitute&lt;/code&gt;.  For example, here is a function I made that uses the substitute command to strip trailing whitespace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! StripTrailingWhitespace()&#xA;    &quot; Save cursor position&#xA;    let l:save = winsaveview()&#xA;    &quot; Remove trailing whitespace&#xA;    %s/\s\+$//e&#xA;    &quot; Move cursor to original position&#xA;    call winrestview(l:save)&#xA;    echo &quot;Stripped trailing whitespace&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you could also use the &lt;code&gt;:mark&lt;/code&gt; command to save the cursor position, but that also means you will be overwriting the mark you decide to use.  I haven't used vint before, but one tip on linters is that you can take their warnings with a grain of salt.  In this case, it is true that &lt;code&gt;:substitute&lt;/code&gt; does have side effects, but they are side effects that can be prevented.  Plus, there really is no better way of doing a search and replace in a file anyway.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2015-12-25T17:03:02.350" LastActivityDate="2015-12-25T17:03:02.350" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5953" PostTypeId="1" AcceptedAnswerId="5957" CreationDate="2015-12-24T18:51:42.063" Score="6" ViewCount="187" Body="&lt;p&gt;For new files, Sublime Text changes the file name to the first line of the file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tSScV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tSScV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to achieve this on Vim?&lt;/p&gt;&#xA;" OwnerUserId="177" LastEditorUserId="865" LastEditDate="2015-12-24T18:53:43.580" LastActivityDate="2015-12-25T02:09:21.337" Title="Automatic name for new files" Tags="|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5954" PostTypeId="1" CreationDate="2015-12-24T21:11:31.427" Score="2" ViewCount="795" Body="&lt;p&gt;Ok so I have setup my .vimrc as followed but I'm still experiencing a few problems with it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $VIM=/usr/share/vim/vim74&#xA;let $VIMRUNTIME=/usr/share/vim/vim74&#xA;execute pathogen#infect()&#xA;&#xA;&quot; air-line&quot;&#xA;let g:airline_powerline_fonts = 1&#xA;&#xA;&#xA;if !exists('g:airline_symbols')&#xA;  let g:airline_symbols = {}&#xA;endif&#xA;&#xA;&quot; unicode symbols&#xA;let g:airline_left_sep = '»'&#xA;let g:airline_left_sep = '▶'&#xA;let g:airline_right_sep = '«'&#xA;let g:airline_right_sep = '◀'&#xA;let g:airline_symbols.linenr = '␊'&#xA;let g:airline_symbols.linenr = '␤'&#xA;let g:airline_symbols.linenr = '¶'&#xA;let g:airline_symbols.branch = '⎇'&#xA;let g:airline_symbols.paste = 'ρ'&#xA;let g:airline_symbols.paste = 'Þ'&#xA;let g:airline_symbols.paste = '∥'&#xA;let g:airline_symbols.whitespace = 'Ξ'&#xA;&#xA;&quot; airline symbols&#xA;let g:airline_left_sep = ''&#xA;let g:airline_left_alt_sep = ''&#xA;let g:airline_right_sep = ''&#xA;let g:airline_right_alt_sep = ''&#xA;let g:airline_symbols.branch = ''&#xA;let g:airline_symbols.readonly = ''&#xA;let g:airline_symbols.linenr = ''&#xA;&#xA;let g:airline_theme='luna'&#xA;&#xA;set nocompatible&#xA;set mouse=a&#xA;&#xA;inoremap &amp;lt;Esc&amp;gt;[62~ &amp;lt;C-X&amp;gt;&amp;lt;C-E&amp;gt;&#xA;inoremap &amp;lt;Esc&amp;gt;[63~ &amp;lt;C-X&amp;gt;&amp;lt;C-Y&amp;gt;&#xA;nnoremap &amp;lt;Esc&amp;gt;[62~ &amp;lt;C-E&amp;gt;&#xA;nnoremap &amp;lt;Esc&amp;gt;[63~ &amp;lt;C-Y&amp;gt;&#xA;&#xA;set tabstop=4&#xA;set autoindent&#xA;set shiftwidth=4&#xA;set shiftround&#xA;set showmatch&#xA;set ignorecase&#xA;set smartcase&#xA;set smarttab&#xA;set hlsearch&#xA;set incsearch&#xA;set history=1000&#xA;set undolevels=1000&#xA;set visualbell&#xA;set noerrorbells&#xA;set backspace=indent,eol,start&#xA;set background=dark&#xA;&#xA;autocmd InsertEnter * set cul&#xA;autocmd InsertLeave * set nocul&#xA;&#xA;syntax on&#xA;filetype plugin indent on&#xA;set number&#xA;silent! nmap &amp;lt;C-p&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;silent! map &amp;lt;F3&amp;gt; :NERDTreeFind&amp;lt;CR&amp;gt;&#xA;let g:NERDTreeMapActivateNode=&quot;&amp;lt;F3&amp;gt;&quot;&#xA;let g:NERDTreeMapPreview=&quot;&amp;lt;F4&amp;gt;&quot;&#xA;let g:NERDTreeShowHidden=1&#xA;autocmd GUIEnter * set vb t_vb=&#xA;autocmd VimEnter * set vb t_vb=&#xA;set termencoding=utf8&#xA;set term=xterm&#xA;set t_Co=256&#xA;let &amp;amp;t_AB=&quot;\e[48;5;%dm&quot;&#xA;let &amp;amp;t_AF=&quot;\e[38;5;%dm&quot;&#xA;colorscheme base16-eighties&#xA;highlight Search ctermbg=green ctermfg=0&#xA;highlight IncSearch ctermbg=green ctermfg=0&#xA;highlight CursorLine ctermbg=8 ctermfg=0&#xA;highlight LineNr ctermfg=blue ctermbg=black&#xA;highlight CursorLineNr ctermfg=blue ctermbg=black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My first and main problem is that I've changed my codepage with chcp to 65001. This displays very odd characters instead of the powerline font arrows that I need for my airline in vim. Does anyone know what codepage I would have to use to get it to work properly? Or perhaps there is a different problem altogether?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Hack font patched, I've also tried inconsolata patched. The arrows are correctly displayed for my agnoster theme with zsh so I don't know why it's not working with vim :/&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My second problem is that I'm missing my cursor in vim with this configuration.&#xA;I'm using cygwin with conemu to emulate 256 colors in vim and this started to happen right after I tried to configure it for 256 colors.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set termencoding=utf8&#xA;set term=xterm&#xA;set t_Co=256&#xA;let &amp;amp;t_AB=&quot;\e[48;5;%dm&quot;&#xA;let &amp;amp;t_AF=&quot;\e[38;5;%dm&quot;&#xA;colorscheme base16-eighties&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This part is responsible for removing my cursor in vim, but it's also responsible for showing the correct colors for both my airline and my colorscheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've gotten all this info from the following two pages:&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/20034851/vim-encoding-unicode-in-terminal-under-windows/25073399#25073399&quot;&gt;https://stackoverflow.com/questions/20034851/vim-encoding-unicode-in-terminal-under-windows/25073399#25073399&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/3359/how-to-fix-status-bar-symbols-in-airline-plugin?lq=1&quot;&gt;How to fix status bar symbols in Airline plugin?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a screenshot of my config in vim. As you can see it displays odd characters instead of the powerline font ones:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/hwoNa.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hwoNa.jpg&quot; alt=&quot;vim-airline no propper display&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: For my main problem I forgot to set the encoding in my .vimrc using: set encoding=utf-8 fixed the powerline arrows.&#xA;Now all I'm left with is trying to fix the cursor which I'm clueless about.&lt;/p&gt;&#xA;" OwnerUserId="5780" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-12-24T23:49:18.273" Title="what is the correct codepage to use with vim airline?" Tags="|vimrc|plugin-airline|cygwin|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5955" PostTypeId="1" CreationDate="2015-12-24T22:37:29.180" Score="2" ViewCount="51" Body="&lt;p&gt;Instead of pressing backspace multiple times to move lines up one, is there a vim shortcut/command that can do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know you can move a single line up or down with &lt;code&gt;:m -&lt;/code&gt; or &lt;code&gt;+&lt;/code&gt;, so I figure it there should be a command for this aswell but can't find the documentation for it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just figured out you can press &lt;code&gt;dd&lt;/code&gt; on the blank line to move everything up.&lt;/p&gt;&#xA;" OwnerUserId="5782" LastEditorUserId="51" LastEditDate="2015-12-24T23:35:00.397" LastActivityDate="2015-12-24T23:35:00.397" Title="How do i move all lines from curser and below up one" Tags="|normal-mode|" AnswerCount="0" CommentCount="3" ClosedDate="2016-01-19T13:10:03.930" ContentLicense="CC BY-SA 3.0" />
  <row Id="5956" PostTypeId="1" AcceptedAnswerId="5975" CreationDate="2015-12-24T22:39:47.453" Score="3" ViewCount="534" Body="&lt;p&gt;I'm thinking of migrating from Vim to NeoVim. I decided to begin with a bit of Python code in my &lt;code&gt;.vimrc&lt;/code&gt; that sets the backup directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;a href=&quot;https://neovim.io/doc/user/if_pyth.html#Python&quot; rel=&quot;nofollow&quot;&gt;documentation&lt;/a&gt;, I wrote the following script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;------------------------------------------------------------&#xA;&quot; Set swap file directory with Python&#xA;python &amp;lt;&amp;lt; endpython&#xA;import neovim, os.path&#xA;from os import getcwd, environ&#xA;from hashlib import md5&#xA;cwd = getcwd()&#xA;m = md5()&#xA;m.update(cwd)&#xA;swd = m.hexdigest()&#xA;full_swd = os.path.join(environ['HOME'], '.config', 'nvim', '.swap', swd)&#xA;if not os.path.exists(full_swd):&#xA;    os.makedirs(full_swd)&#xA;nvim = neovim.attach('socket', path=environ['NVIM_LISTEN_ADDRESS'])&#xA;nvim.command('set backupdir=' + full_swd)&#xA;nvim.command('set directory=' + full_swd)&#xA;endpython&#xA;&#xA;&quot;------------------------------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem I encountered is that this script hangs, even though I'm capable of repeating it via the command line. I tried to insert &lt;code&gt;print&lt;/code&gt; statements in various places of the script, and it looks like this is the blocking line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim.command('set backupdir=' + full_swd)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong? Thank you very much.&lt;/p&gt;&#xA;" OwnerUserId="5753" LastEditorUserId="5753" LastEditDate="2015-12-24T22:53:00.303" LastActivityDate="2015-12-27T05:11:21.590" Title="Neovim Python script hangs" Tags="|vimrc|neovim|vimscript-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5957" PostTypeId="2" ParentId="5953" CreationDate="2015-12-25T02:09:21.337" Score="5" Body="&lt;p&gt;I don't use Sublime Text, but something like this sounds like what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SetFileNameToFirstLine()&#xA;  silent execute &quot;file &quot;.fnameescape(getline(1))&#xA;endfunction&#xA;&#xA;let s:set_file_name_to_first_line_active = 0&#xA;function! ToggleSetFileNameToFirstLine()&#xA;  if s:set_file_name_to_first_line_active&#xA;    silent! augroup! SFNTFL&#xA;    echo &quot;SetFileNameToFirstLine disabled&quot;&#xA;  else&#xA;    augroup SFNTFL&#xA;      au! InsertLeave,CursorHold,CursorHoldI &amp;lt;buffer&amp;gt; call SetFileNameToFirstLine()&#xA;    augroup END&#xA;    call SetFileNameToFirstLine()&#xA;    echo &quot;SetFileNameToFirstLine enabled&quot;&#xA;  endif&#xA;  let s:set_file_name_to_first_line_active = !s:set_file_name_to_first_line_active&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;F9&amp;gt; :call ToggleSetFileNameToFirstLine()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;F9&lt;/kbd&gt; will start changing your filename to the first line. Hit it again to disable this behaviour. (You can make it default, but I really recommend against it...)&lt;/p&gt;&#xA;" OwnerUserId="4729" LastActivityDate="2015-12-25T02:09:21.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5958" PostTypeId="2" ParentId="5916" CreationDate="2015-12-25T04:07:24.827" Score="9" Body="&lt;p&gt;I still don't know how to use backtick-expansion to populate the arglist with an arbitrary shell command, however I've found a workaround.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help `=&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;You can have the backticks expanded as a Vim expression, instead of as an&#xA;external command, by putting an equal sign right after the first backtick,&#xA;e.g.:&#xA;    :e `=tempname()`&#xA;The expression can contain just about anything, thus this can also be used to&#xA;avoid the special meaning of '&quot;', '|', '%' and '#'.  However, 'wildignore'&#xA;does apply like to other wildcards.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, instead of expanding directly a shell command like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args `shell command`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We can send the shell command to the Vim function &lt;code&gt;systemlist()&lt;/code&gt; and use the expression register &lt;code&gt;=&lt;/code&gt; to expand the resulting expression like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args `=systemlist(&quot;shell command&quot;)`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To save some keystrokes, I've defined the following Ex command in my vimrc (&lt;code&gt;:PA&lt;/code&gt; for Populate Arglist):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 PA args `=systemlist(&amp;lt;q-args&amp;gt;)`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And tested it with various shell commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PA find . -name ver\*.c -print 2&amp;gt;/dev/null&#xA;:PA find . -name 'ver*.c' -print 2&amp;gt;/dev/null&#xA;:PA ls -t *.patch  | head -n1&#xA;:PA find /etc -name '*.conf' 2&amp;gt;/dev/null | grep input&#xA;:PA find /etc -name '*.conf' 2&amp;gt;/dev/null&#xA;:PA find . -name '*.conf' 2&amp;gt;/dev/null&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far it works like expected and the command can be typed as it would be in the shell (no need to escape the pipe for example).&lt;br&gt;&#xA;It seems more consistent and reliable than direct backtick-expansion.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="205" LastEditDate="2015-12-25T07:47:16.647" LastActivityDate="2015-12-25T07:47:16.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5959" PostTypeId="1" AcceptedAnswerId="5960" CreationDate="2015-12-25T06:34:12.373" Score="7" ViewCount="1572" Body="&lt;p&gt;I'm trying to set up normal mode mappings to make it easy to add white space around the cursor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; will add one space to the right of the cursor;&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; will add a newline below;&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; will add a newline above;&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; will add one space to the right of the cursor; and&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;C-Enter&amp;gt;&lt;/code&gt; will add a newline at the current cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also want the cursor position not to move during the command. For left, right, and newline, this is simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-h&amp;gt; i &amp;lt;Esc&amp;gt;l&#xA;nnoremap &amp;lt;C-l&amp;gt; a &amp;lt;Esc&amp;gt;h&#xA;nnoremap &amp;lt;C-^M&amp;gt; i&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;&amp;lt;Backspace&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but for above and below, the corresponding commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-j&amp;gt; o &amp;lt;Esc&amp;gt;k&#xA;nnoremap &amp;lt;C-k&amp;gt; O &amp;lt;Esc&amp;gt;j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will get me back on the right line, but not back to the same column that I was on before. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to return to the cursor position I was at just before entering insert mode? My best Google-fu only brought up references to &lt;code&gt;''&lt;/code&gt; &amp;amp; double-backtick (can't figure out how to format the markdown there) and &lt;code&gt;:jumps&lt;/code&gt; / &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; &amp;amp; &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt;, neither of which seem to work quite the way I'd like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this be solved without Vimscript? Can it even be solved &lt;em&gt;with&lt;/em&gt; Vimscript?&lt;/p&gt;&#xA;" OwnerUserId="2593" LastActivityDate="2015-12-26T06:14:38.327" Title="How to jump back to the cursor position before I entered insert mode?" Tags="|key-bindings|vimrc|cursor-motions|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5960" PostTypeId="2" ParentId="5959" CreationDate="2015-12-25T07:21:51.980" Score="8" Body="&lt;p&gt;You can set a local mark to where you're before opening a new line, and go back to this mark afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can choose any letter for the mark, let's say for example &lt;code&gt;x&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-k&amp;gt; mxO&amp;lt;esc&amp;gt;`x&#xA;nnoremap &amp;lt;C-j&amp;gt; mxo&amp;lt;esc&amp;gt;`x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;mx&lt;/code&gt; sets the mark &lt;code&gt;x&lt;/code&gt; where the cursor is&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`x&lt;/code&gt; moves the cursor back to the position of mark &lt;code&gt;x&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could also look at what tpope wrote in his &lt;a href=&quot;https://github.com/tpope/vim-unimpaired/blob/master/plugin/unimpaired.vim&quot; rel=&quot;noreferrer&quot;&gt;unimpaired plugin&lt;/a&gt; and put the following code inside your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nostartofline&#xA;&#xA;function! s:BlankUp(count) abort&#xA;  put!=repeat(nr2char(10), a:count)&#xA;  ']+1&#xA;endfunction&#xA;&#xA;function! s:BlankDown(count) abort&#xA;  put =repeat(nr2char(10), a:count)&#xA;  '[-1&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;c-k&amp;gt; :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;BlankUp(v:count1)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;c-j&amp;gt; :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;BlankDown(v:count1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The advantage of this solution over the previous one is that it accepts a count and doesn't change any of your marks.&lt;br&gt;&#xA;For example to insert 2 lines above the current one, hit &lt;code&gt;2&amp;lt;C-k&amp;gt;&lt;/code&gt;, 3 lines below &lt;code&gt;3&amp;lt;C-j&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: to write a double backtick in your post, use triple backticks before and after (and put spaces before and after the double backtick):&#xA;&lt;code&gt;``&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;br&gt;&#xA;I just noticed that in the case of the 2nd solution, if you want the cursor to come back to the same column where it was before pasting a new line, you have to disable the option &lt;code&gt;'startofline'&lt;/code&gt;: &lt;code&gt;set nostartofline&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When this option is disabled, the column number of your cursor stays the same after using various commands such as &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt;, &lt;code&gt;gg&lt;/code&gt;, &lt;code&gt;dd&lt;/code&gt;, &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;:bnext&lt;/code&gt;, &lt;code&gt;:25&lt;/code&gt;.&lt;br&gt;&#xA;See &lt;code&gt;:help 'startofline'&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-26T06:14:38.327" LastActivityDate="2015-12-26T06:14:38.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5961" PostTypeId="2" ParentId="5959" CreationDate="2015-12-25T11:18:37.927" Score="7" Body="&lt;p&gt;No need for vimscript here, the mappings below do exactly what you ask:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-j&amp;gt; m`o&amp;lt;Esc&amp;gt;``&#xA;nnoremap &amp;lt;C-k&amp;gt; m`O&amp;lt;Esc&amp;gt;``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;m`&lt;/code&gt; is used to set the &quot;previous context mark&quot;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&amp;lt;Esc&amp;gt;&lt;/code&gt; does what you expect,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;``&lt;/code&gt; jumps back to the previous context mark.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-25T11:18:37.927" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5962" PostTypeId="2" ParentId="5949" CreationDate="2015-12-25T13:52:07.610" Score="15" Body="&lt;p&gt;Here is a simplistic implementation of your function, written with &lt;code&gt;substitute()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddSpaceBeforeEqualInWholeBuffer()&#xA;    let l = 1&#xA;    for line in getline(1,&quot;$&quot;)&#xA;        call setline(l, substitute(line, '\([^= ]\)=', '\1 =', &quot;g&quot;))&#xA;        let l = l + 1&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adjust the search pattern to taste.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-25T13:52:07.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5963" PostTypeId="1" AcceptedAnswerId="6001" CreationDate="2015-12-25T14:05:42.893" Score="10" ViewCount="1873" Body="&lt;p&gt;Here is a file -- &lt;code&gt;ChipBooter.cpp&lt;/code&gt; -- in my project(Omit some details that are not related to this question):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class ChipBooter {&#xA;public:   &#xA;    void Boot() {&#xA;        this-&amp;gt;DpDetect();&#xA;    }&#xA;    void DpDetect() {}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I hit &lt;code&gt;g&amp;lt;C-]&amp;gt;&lt;/code&gt; to jump to the definition of &lt;code&gt;DpDetect&lt;/code&gt;, Vim displayed a list with duplicate matching tags:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# pri kind tag               file&#xA;1 F C f    DpDetect          OMU/src/boot/src/ChipBooter.cpp&#xA;             class:ChipBooter&#xA;             void ChipBooter::DpDetect()&#xA;2 F C f    DpDetect          OMU/src/boot/src/ChipBooter.cpp&#xA;             class:ChipBooter&#xA;             void ChipBooter::DpDetect()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the same definition! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem happens every time I hit &lt;code&gt;g&amp;lt;C-]&amp;gt;&lt;/code&gt; and always doubles the length of the list. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;More Details&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Exuberant Ctags version: &lt;code&gt;5.8&lt;/code&gt;. Vim version is &lt;code&gt;7.3&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a visual representation of my directory hierarchy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Source&#xA;  `---tags&#xA;  |       &#xA;  `---OMU&#xA;       `---src&#xA;            `---boot&#xA;                 `---src&#xA;                      `---ChipBooter.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I ran &lt;code&gt;ctags -R&lt;/code&gt; in &lt;code&gt;Source&lt;/code&gt; which contains the &lt;code&gt;OMU&lt;/code&gt; directory to generate the &lt;code&gt;tags&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I launch vim using &lt;code&gt;vim -u NONE -N&lt;/code&gt;; &lt;code&gt;.vimrc&lt;/code&gt; and plugins is disabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is only one entry about &lt;code&gt;DpDetect&lt;/code&gt; in the &lt;code&gt;tags&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DpDetect    OMU/src/boot/src/ChipBooter.cpp /^void ChipBooter::DpDetect()$/;&quot;   f   class:ChipBooter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;tags&lt;/code&gt; is default value, because &lt;code&gt;.vimrc&lt;/code&gt; is disabled.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set tags?&#xA;tags=./tags,./TAGS,tags,TAGS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@romainl said Vim seems to be using both two &lt;em&gt;tags&lt;/em&gt; files: &lt;code&gt;tags&lt;/code&gt; and &lt;code&gt;TAGS&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo tagfiles()&#xA;['tags', 'TAGS']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I change &lt;code&gt;tags&lt;/code&gt; option to exclude &lt;em&gt;TAGS&lt;/em&gt; file(&lt;code&gt;:set tags=./tags,tags&lt;/code&gt;), duplicate tags problem does not exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where is the &lt;code&gt;TAGS&lt;/code&gt; file? There is only a &lt;code&gt;tags&lt;/code&gt; file in my project directory.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ find {My project root directory} -iname tags&#xA;./tags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5510" LastEditorUserId="5510" LastEditDate="2015-12-30T00:52:24.057" LastActivityDate="2015-12-30T14:06:19.823" Title="Exuberant Ctags - Duplicate tags problem" Tags="|ctags|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5964" PostTypeId="2" ParentId="5949" CreationDate="2015-12-25T15:22:52.380" Score="1" Body="&lt;p&gt;The &lt;code&gt;:s&lt;/code&gt; command is a pure Vimscript approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess is the warning only means, that the cursor will most likely be mispositioned after its useage (which you can circumvent by using the &lt;code&gt;winsaveview()&lt;/code&gt; function before and the &lt;code&gt;winrestview()&lt;/code&gt; commmand after its usage). Also you need to take care of possible errors that might occur. This is usually handled by using the &lt;code&gt;e&lt;/code&gt; flag. Also one needs to take care of some settings like the &lt;code&gt;gdefault&lt;/code&gt; setting, which inverts the meaning of the &lt;code&gt;g&lt;/code&gt; flag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One needs to take care of those specifics and that is probably the root cause of those warnings. But that does not mean to avoid the use of the &lt;code&gt;:s&lt;/code&gt; command. It is perfectly okay to use &lt;code&gt;:s&lt;/code&gt; command, if you want to replace something in the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note, one could of course loop through all lines and use an search()/getline()/setline() approach. But that is usually slower.)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-12-25T15:22:52.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5965" PostTypeId="1" AcceptedAnswerId="5968" CreationDate="2015-12-25T18:08:13.377" Score="0" ViewCount="70" Body="&lt;p&gt;i can't find any syntax highlighting for offlineimaprc files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of vim has normally for everything syntax highlighting (even for esoteric programming languages!), this makes me wondering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did i just failed to notice sth obvious or has vim really no syntax highlighting for offlineimaprc files?&lt;/p&gt;&#xA;" OwnerUserId="2354" LastActivityDate="2015-12-25T21:03:04.483" Title="can't find syntax highlighting for offlineimaprc" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5966" PostTypeId="1" AcceptedAnswerId="5967" CreationDate="2015-12-25T18:35:41.600" Score="9" ViewCount="395" Body="&lt;p&gt;I came accross this line in a syntax file.. it does not work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax keyword Type Transparent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess this has something to see with the fact that &lt;code&gt;transparent&lt;/code&gt; is a significant keyword for Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do to escape it, and to get the actual word &lt;code&gt;Transparent&lt;/code&gt; colored in my files like all other &lt;code&gt;Type&lt;/code&gt; words? What if I stumble one day accross other touchy keywords like &lt;code&gt;keyword&lt;/code&gt;, &lt;code&gt;syn&lt;/code&gt;, &lt;code&gt;match&lt;/code&gt; etc?&lt;/p&gt;&#xA;" OwnerUserId="2978" LastActivityDate="2015-12-25T20:56:02.700" Title="How to escape significant keywords from syntax files?" Tags="|vimscript|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5967" PostTypeId="2" ParentId="5966" CreationDate="2015-12-25T20:56:02.700" Score="13" Body="&lt;p&gt;This is an interesting question and it looks like the documentation does not say anything about escaping those special words. First, special arguments that can appear anywhere depend on which syntax command you use. The documentation mentiones those specials arguments at &lt;a href=&quot;https://vimhelp.appspot.com/syntax.txt.html#:syn-arguments&quot;&gt;:h :syn-arguments&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The :syntax commands that define syntax items take a number of arguments.&#xA;The common ones are explained here.  The arguments may be given in any&#xA;order and may be mixed with patterns.&#xA;&#xA;Not all commands accept all arguments.  This table shows which arguments&#xA;can not be used for all commands:&#xA;                                                        E395&#xA;                    contains  oneline   fold  display  extend concealends&#xA;:syntax keyword          -       -       -       -       -      -&#xA;:syntax match           yes      -      yes     yes     yes     -&#xA;:syntax region          yes     yes     yes     yes     yes    yes&#xA;&#xA;These arguments can be used for all three commands:&#xA;    conceal&#xA;    cchar&#xA;    contained&#xA;    containedin&#xA;    nextgroup&#xA;    transparent&#xA;    skipwhite&#xA;    skipnl&#xA;    skipempty&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for the first question, on how to escape those special arguments, I tried using the syntax-keyword special syntax element &lt;code&gt;[]&lt;/code&gt; and this does work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax keyword Type Eins Transparent[] contained[]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;[]&lt;/code&gt; is used to denote an optional part of a keyword, so that e.g. &lt;code&gt;Trans[parent]&lt;/code&gt; would define the separate keywords &lt;code&gt;Trans&lt;/code&gt;, &lt;code&gt;Transp&lt;/code&gt;, &lt;code&gt;Transpa&lt;/code&gt;, etc and by (ab-)using this, I made the syntax script work as you wanted.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-12-25T20:56:02.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5968" PostTypeId="2" ParentId="5965" CreationDate="2015-12-25T21:03:04.483" Score="2" Body="&lt;p&gt;Here's a &lt;a href=&quot;https://github.com/hrother/offlineimaprc.vim&quot; rel=&quot;nofollow&quot;&gt;github project&lt;/a&gt; called offlineimaprc.vim that provides &quot;Syntax highlighting offlineimap configuration file&quot;. I haven't tried it, but @toogley reported in a comment above that it works.&lt;/p&gt;&#xA;" OwnerUserId="4620" LastActivityDate="2015-12-25T21:03:04.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5971" PostTypeId="1" CreationDate="2015-12-26T10:42:12.587" Score="1" ViewCount="165" Body="&lt;p&gt;While looking through Vim's source code, I notice that it contained a folder named &lt;a href=&quot;https://github.com/vim/vim/tree/master/farsi&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;farsi&lt;/code&gt;&lt;/a&gt; in the top directory, created 9 years ago. The &lt;a href=&quot;https://github.com/vim/vim/commits/master/farsi&quot; rel=&quot;nofollow&quot;&gt;commit message&lt;/a&gt; seems to be just &lt;code&gt;updated for version 7.1a&lt;/code&gt;. Why Farsi, and not any other language? And the location seems weird from a code organization perspective.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2015-12-26T10:59:35.627" LastActivityDate="2015-12-26T15:55:22.083" Title="Why does the source code of Vim have a folder named farsi in the root directory?" Tags="|history-of|vim-development|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5973" PostTypeId="2" ParentId="5971" CreationDate="2015-12-26T15:55:22.083" Score="2" Body="&lt;p&gt;It's just Farsi fonts, not code. The actual code lives in &lt;code&gt;src/farsi.c&lt;/code&gt;, and is similar to &lt;code&gt;src/arabic.c&lt;/code&gt;. Vim has shipped Farsi fonts since at least 1996 (&lt;a href=&quot;ftp://ftp.vim.org/pub/vim/farsi/&quot; rel=&quot;nofollow&quot;&gt;as separate download&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does Vim ship with Farsi fonts but not Arabic fonts? Perhaps in 1996 Farsi fonts were not commonly shipped with OS's (and Arabic was), or perhaps it's a random inconsistent decision at the whim of Bram or another programmer ;-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2015-12-26T15:55:22.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5974" PostTypeId="1" AcceptedAnswerId="6249" CreationDate="2015-12-26T16:36:17.107" Score="11" ViewCount="9111" Body="&lt;p&gt;I am working on a ChromeOS computer with both Vi and Vim.  When I open up the editor to an existing document, I type A to begin editing.  When I try to move around with my arrow keys, the following happens:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yMz1N.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yMz1N.png&quot; alt=&quot;vim and vi arrow keys&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried both Vim and Vi, and both of the have this problem. How do I move around in my document while editing it?&lt;/p&gt;&#xA;" OwnerUserId="5795" LastEditorUserId="205" LastEditDate="2017-03-08T14:20:32.273" LastActivityDate="2022-10-05T07:38:31.570" Title="I can't move around the document while editing" Tags="|key-bindings|terminal|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5975" PostTypeId="2" ParentId="5956" CreationDate="2015-12-27T05:06:12.077" Score="2" Body="&lt;p&gt;Don't use the neovim interface for this, its designed to be used asynchronously and you are using it synchronously. (You are deadlocking neovim which is waiting for the nvim socket to respond but it will never respond because it is already in a blocking python call). You should probably use the old vim interface if you need to do stuff synchronously. (AFAIK it still works and isn't being removed)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python &amp;lt;&amp;lt; endpython&#xA;import vim&#xA;import os&#xA;from hashlib import md5&#xA;cwd = os.getcwd()&#xA;m = md5()&#xA;m.update(cwd)&#xA;swd = m.hexdigest()&#xA;full_swd = os.path.join(os.environ['HOME'], '.config', 'nvim', '.swap', swd)&#xA;if not os.path.exists(full_swd):&#xA;    os.makedirs(full_swd)&#xA;&#xA;# This should be preferred to manually constructing the string.&#xA;vim.options['backupdir'] = full_swd &#xA;vim.options['directory'] = full_swd&#xA;endpython&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2015-12-27T05:11:21.590" LastActivityDate="2015-12-27T05:11:21.590" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5976" PostTypeId="1" CreationDate="2015-12-28T01:14:39.047" Score="4" ViewCount="367" Body="&lt;p&gt;In order to keep my tags file up to date I wrote this function which runs &lt;code&gt;ctags -R .&lt;/code&gt; whenever I save a file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! UpdateCtags()&#xA;    &quot; assume if a tags file exists - then current dir is ok&#xA;    if filereadable(&quot;tags&quot;)&#xA;        echo &quot;updating tags file&quot;&#xA;        call system('ctags -R .')&#xA;    else&#xA;        echo &quot;unable to update tags file - probably wrong current dir&quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;au BufWritePost * silent! call UpdateCtags()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function seems to work ok, but it triggers a prompts &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;&quot;somefile&quot; 508L, 16090C written  &#xA;updating tags file  &#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Its not a major problem, but considering I save a file probably every 15 seconds, I want a message confirming the function ran to be printed, but I don't want to be interupted by a prompt.&lt;br&gt;&#xA;.&lt;br&gt;&#xA;Is it possible to make this prompt go away? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ive tried adding &lt;code&gt;silent!&lt;/code&gt; to the autocmd&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWritePost * silent! call UpdateCtags()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it seems to have no effect&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2015-12-28T01:22:12.587" LastActivityDate="2015-12-28T04:20:53.250" Title="How to run a function without getting prompted to continue?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5977" PostTypeId="2" ParentId="5976" CreationDate="2015-12-28T01:30:37.317" Score="4" Body="&lt;p&gt;After reading this &lt;a href=&quot;http://vim.wikia.com/wiki/Avoiding_the_%22Hit_ENTER_to_continue%22_prompts&quot; rel=&quot;nofollow&quot;&gt;vim.wikia.com&lt;/a&gt; article, I learnt that the cause of the prompt is content in the command line exceeding the available commandline height&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so I added &lt;code&gt;set cmdheight=2&lt;/code&gt; to the function to this and it now seems to work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if filereadable(&quot;tags&quot;)&#xA;    set cmdheight=2&#xA;    &quot;^^^^^^^^^^^^^^^^&#xA;    echo &quot;updating tags file&quot;&#xA;    call system('ctags -R .')&#xA;    set cmdheight=1&#xA;    &quot;^^^^^^^^^^^^^^^&#xA;else&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2015-12-28T04:20:53.250" LastActivityDate="2015-12-28T04:20:53.250" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5978" PostTypeId="2" ParentId="4945" CreationDate="2015-12-28T20:01:05.450" Score="2" Body="&lt;p&gt;The text is &lt;strong&gt;d&lt;/strong&gt;ragged/&lt;strong&gt;m&lt;/strong&gt;oved/&lt;strong&gt;p&lt;/strong&gt;ulled/&lt;strong&gt;y&lt;/strong&gt;anked into to clipboard. It's just a synonymous found to be easy to remember the &lt;strong&gt;y&lt;/strong&gt; key, since all other keys are used.&lt;/p&gt;&#xA;" OwnerUserId="177" LastActivityDate="2015-12-28T20:01:05.450" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5979" PostTypeId="2" ParentId="5885" CreationDate="2015-12-28T20:23:02.920" Score="3" Body="&lt;p&gt;Ok, I've figured out a way to do this in my environment. I had to shrink and cut pangloss vim-javascript a little bit. Here's my fork:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/seavan/vim-javascript-plus&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/seavan/vim-javascript-plus&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should install it along with vim-jsx in your bundle directory. It will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I removed some of the latest pangloss updates to make it work. Hopefully I will merge them back after a while.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/CQB79.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CQB79.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5713" LastActivityDate="2015-12-28T20:23:02.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5980" PostTypeId="2" ParentId="4844" CreationDate="2015-12-29T00:42:35.360" Score="1" Body="&lt;p&gt;I have in my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap &amp;lt;leader&amp;gt;q :nohlsearch&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which maps my leader (\ by default, but I remapped to ,) then q to remove the search highlighting.  Not exactly what you're looking for, but it might be worthwhile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That, and several other nice bits came from &lt;a href=&quot;http://dougblack.io/words/a-good-vimrc.html#search&quot; rel=&quot;nofollow&quot;&gt;http://dougblack.io/words/a-good-vimrc.html#search&lt;/a&gt;, though he uses space to disable the highlight.&lt;/p&gt;&#xA;" OwnerUserId="5819" LastActivityDate="2015-12-29T00:42:35.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5981" PostTypeId="2" ParentId="4844" CreationDate="2015-12-29T02:46:57.823" Score="4" Body="&lt;p&gt;From a excellent book -- &quot;Practical Vim&quot;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Typing &lt;code&gt;:noh&amp;lt;CR&amp;gt;&lt;/code&gt; to mute search highlighting is laborious. You can&#xA;  speed things up by creating a mapping such as this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-l&amp;gt; :&amp;lt;C-u&amp;gt;nohlsearch&amp;lt;CR&amp;gt;&amp;lt;C-l&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Normally,  clears and redraws the screen (see &lt;code&gt;:h CTRL-L&lt;/code&gt;). This&#xA;  mapping builds on top of the usual behavior by muting search&#xA;  highlighting.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can add this line to you &lt;em&gt;vimrc&lt;/em&gt; file. If you hit &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;l&lt;/kbd&gt;, Vim will mute search highlighting and redraw the screen at the same time.&lt;/p&gt;&#xA;" OwnerUserId="5510" LastEditorUserId="5510" LastEditDate="2015-12-29T03:18:03.667" LastActivityDate="2015-12-29T03:18:03.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5982" PostTypeId="1" AcceptedAnswerId="5983" CreationDate="2015-12-29T04:01:37.817" Score="7" ViewCount="178" Body="&lt;p&gt;Have been reading vim scripting posts for an hour, but I'm afraid I don't have the skills to apply these posts to my problem.    Editing math in latex documents, I'm frequently wanting to replace math symbols such as +, -, = with \Pad{+}, \Pad{-}, \Pad{=}, where \Pad is a latex macro I've defined to put space around the symbol.   I'd like be able to put my cursor on such a symbol, type a couple of letters, say &lt;code&gt;;P&lt;/code&gt; and have this action replace the symbol with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\Pad{whatever the symbol under the cursor is}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help would be most appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;` &lt;/p&gt;&#xA;" OwnerUserId="4667" LastActivityDate="2015-12-29T08:42:45.793" Title="mapping to enclose symbol under cursor with an expression that contains the symbol" Tags="|macro|replace|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5983" PostTypeId="2" ParentId="5982" CreationDate="2015-12-29T04:44:15.843" Score="5" Body="&lt;pre&gt;&lt;code&gt;function! s:PadMacro(type) abort&#xA;    if a:type ==# 'char'&#xA;        normal! `[v`]d&#xA;    elseif a:type ==# 'line'&#xA;        normal! '[V']d&#xA;    elseif a:type ==# 'v'&#xA;        normal! `&amp;lt;v`&amp;gt;d&#xA;    else&#xA;        return&#xA;    endif&#xA;    let string = '\Pad{' . @&quot; . '}'&#xA;    silent execute &quot;normal! i\&amp;lt;c-r&amp;gt;=string\r&quot;&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; ;P :set operatorfunc=&amp;lt;sid&amp;gt;PadMacro&amp;lt;cr&amp;gt;g@&#xA;vnoremap &amp;lt;silent&amp;gt; ;P :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;PadMacro(visualmode())&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you put the previous code in your vimrc, it should do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use it, hit &lt;code&gt;;P{motion}&lt;/code&gt; and the &lt;code&gt;PadMacro()&lt;/code&gt; function should enclose the characters covered by &lt;code&gt;{motion}&lt;/code&gt; with &lt;code&gt;\Pad{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usage examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;;Pl&lt;/code&gt; to enclose the character under the cursor (because &lt;code&gt;l&lt;/code&gt; is a motion which covers the character under the cursor)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;Piw&lt;/code&gt; to enclose the word under the cursor (because &lt;code&gt;iw&lt;/code&gt; is a text object which covers all the characters inside the word under the cursor )  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;Pis&lt;/code&gt; to enclose the sentence in which the cursor is (because &lt;code&gt;is&lt;/code&gt; is a text object which covers all the characters inside a sentence)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;P$&lt;/code&gt; to enclose the characters between your cursor and the end of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;P&lt;/code&gt; to enclose the characters visually selected&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Everything done by the &lt;code&gt;PadMacro()&lt;/code&gt; function is considered as a single edition which means it's dot repeatable.&lt;br&gt;&#xA;In other words, if you have several similar portions of text to enclose with &lt;code&gt;\Pad{}&lt;/code&gt; there's no need to hit the mapping every time, only the first time (after that you can hit &lt;code&gt;.&lt;/code&gt; to repeat your last edition).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a complete list of text-objects on which you can apply your enclosure, see:&lt;br&gt;&#xA;&lt;code&gt;:help text-objects&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-29T08:42:45.793" LastActivityDate="2015-12-29T08:42:45.793" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5984" PostTypeId="2" ParentId="5982" CreationDate="2015-12-29T06:37:40.977" Score="6" Body="&lt;p&gt;The idea is simple:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;you cut the text you want to surround and enter insert mode,&lt;/li&gt;&#xA;&lt;li&gt;you insert the first part,&lt;/li&gt;&#xA;&lt;li&gt;you insert the content of the unnamed register,&lt;/li&gt;&#xA;&lt;li&gt;you insert the last part,&lt;/li&gt;&#xA;&lt;li&gt;you get out of insert mode.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For your example you would do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s\Pad{&amp;lt;C-r&amp;gt;&quot;}&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be mapped for your convenience:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; normal mode, for single characters&#xA;nnoremap ;P s\Pad{&amp;lt;C-r&amp;gt;&quot;}&amp;lt;Esc&amp;gt;&#xA;&#xA;&quot; visual mode, for multiple characters&#xA;xnoremap ;P s\Pad{&amp;lt;C-r&amp;gt;&quot;}&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that it's possible to use a different register if you don't want to clutter the unnamed register. Here I use the &lt;code&gt;z&lt;/code&gt; register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;zs\Pad{&amp;lt;C-r&amp;gt;z}&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-12-29T08:31:29.513" LastActivityDate="2015-12-29T08:31:29.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5985" PostTypeId="2" ParentId="5982" CreationDate="2015-12-29T08:07:54.400" Score="3" Body="&lt;p&gt;Just one more solution for case when surround not only one symbol (sample from my config for surround with &quot;[&quot; &amp;amp; &quot;]&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap Q[ O&amp;lt;Esc&amp;gt;i[&amp;lt;Esc&amp;gt;gvo&amp;lt;Esc&amp;gt;la]&amp;lt;Esc&amp;gt;&#xA;nnoremap Q[ veO&amp;lt;Esc&amp;gt;i[&amp;lt;Esc&amp;gt;gvo&amp;lt;Esc&amp;gt;la]&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Key is to use &quot;o&quot; &amp;amp; &quot;O&quot; to move to start/end of selection&lt;/p&gt;&#xA;" OwnerUserId="5823" LastActivityDate="2015-12-29T08:07:54.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5986" PostTypeId="1" AcceptedAnswerId="5987" CreationDate="2015-12-29T16:00:30.137" Score="4" ViewCount="160" Body="&lt;p&gt;I have been trying to map &lt;code&gt;{&lt;/code&gt; in insert mode to the following if the line contains any character other than blank or tabs: &lt;strong&gt;&lt;code&gt;&amp;lt;CR&amp;gt;{&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/strong&gt; and to &lt;strong&gt;&lt;code&gt;{&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/strong&gt; if the line is blank (contains at most spaces or tabs), how would you do this? I am assuming vimscript is needed ?&lt;/p&gt;&#xA;" OwnerUserId="1305" LastActivityDate="2015-12-29T17:15:51.177" Title="Mapping { with Vimscript" Tags="|vimscript|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5987" PostTypeId="2" ParentId="5986" CreationDate="2015-12-29T16:19:50.543" Score="3" Body="&lt;p&gt;I'm not sure this is what you want, but you could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:InsertBrace() abort&#xA;    if getline('.') =~ '\S'&#xA;        return &quot;\n{\n&quot;&#xA;    else&#xA;        return &quot;{\n&quot;&#xA;    endif&#xA;endfunction&#xA;inoremap &amp;lt;expr&amp;gt; { &amp;lt;sid&amp;gt;InsertBrace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your vim version doesn't support vimscript functions, you could try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; { getline('.') =~ '\S' ? &quot;^M{^M&quot; : &quot;{^M&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, do not type &lt;code&gt;^M&lt;/code&gt; literally, instead type &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;) and then &lt;kbd&gt;Enter&lt;/kbd&gt;. It will insert a carriage return character literally which vim displays with its caret notation &lt;code&gt;^M&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-29T17:15:51.177" LastActivityDate="2015-12-29T17:15:51.177" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5988" PostTypeId="2" ParentId="5089" CreationDate="2015-12-29T18:15:33.113" Score="2" Body="&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; There is now a plugin made by copying the syntax file below: &lt;a href=&quot;https://github.com/laubzega/pruss-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/laubzega/pruss-vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my own PRU vim syntax highlighter with instructions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir ~/.vim/syntax&#xA;mkdir ~/.vim/ftdetect&#xA;&#xA;cd ~/.vim/ftdetect&#xA;vi pruft.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Insert and save the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.p       set filetype=pru&#xA;au BufRead,BufNewFile *.hp      set filetype=pru&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Return back to your terminal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim/syntax&#xA;vi pru.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Insert and save the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Vim syntax file for PRU&#xA;&quot; Created by Bryan Wilcutt&#xA;&#xA;if exists (&quot;b:current_syntax&quot;)&#xA;    finish&#xA;endif&#xA;&#xA;&quot; Define keywords from PRU&#xA;syn keyword syntaxElementKeyword add adc sub suc rsb rsc lsl lsr and or xor not min max &#xA;syn keyword syntaxElementKeyword clr set scan lmbd mov ldi mvib mviw mvid lbbo sbbo lbco sbco&#xA;syn keyword syntaxElementKeyword zero jmp jal call ret qbgt qbge qblt qble qbeq qbne qba &#xA;syn keyword syntaxElementKeyword qbbs qbbc wbs wbc halt slp &#xA;&#xA;syn keyword syntaxElementKeyword ADD ADC SUB SUC RSB RSC LSL LSR AND OR XOR NOT MIN MAX &#xA;syn keyword syntaxElementKeyword CLR SET SCAN LMBD MOV LDI MVIB MVIW MVID LBBO SBBO LBCO SBCO&#xA;syn keyword syntaxElementKeyword ZERO JMP JAL CALL RET QBGT QBGE QBLT QBLE QBEQ QBNE QBA &#xA;syn keyword syntaxElementKeyword QBBS QBBC WBS WBC HALT SLP &#xA;hi def link syntaxElementKeyword Statement&#xA;&#xA;&quot; Define registers from PRU&#xA;&#xA;syn keyword registerKeyword r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 &#xA;syn keyword registerKeyword r16 r17 r18 r19 r20 r21 r22 r23 r24 r25 r26 r27 r28 r29 r30 r31 &#xA;&#xA;syn keyword registerKeyword R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 &#xA;syn keyword registerKeyword R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 R30 R31 &#xA;&#xA;syn match regPartBit '.t\d\+' contains=registerKeyword&#xA;syn match regPartWord '.w\d\+' contains=registerKeyword&#xA;&#xA;hi def link registerKeyword PreProc&#xA;hi def link regPartBit PreProc&#xA;hi def link regPartWord PreProc&#xA;&#xA;&quot; Preprocessor commands&#xA;&#xA;syn keyword preprocWord setcallreg entrypoint origin assign enter leave using macro mparam endm struct ends&#xA;syn keyword preprocType u32 u16 u8&#xA;hi def link preprocWord PreProc&#xA;hi def link preprocType Type&#xA;&#xA;&#xA;&quot; Define constant registers from PRU&#xA;&#xA;syn keyword constantKeyword c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 &#xA;syn keyword constantKeyword c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 &#xA;&#xA;syn keyword constantKeyword C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 &#xA;syn keyword constantKeyword C16 C17 C18 C19 C20 C21 C22 C23 C24 C25 C26 C27 C28 C29 C30 C31 &#xA;&#xA;hi def link constantKeyword PreProc&#xA;&#xA;&quot; Define comments&#xA;&#xA;syn match synComment &quot;//.*$&quot;&#xA;hi def link synComment Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Restart your vim session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The syntax highlighter isn't perfect but good enough for my own use while writing PRU assembler code.&lt;/p&gt;&#xA;" OwnerUserId="5828" LastEditorUserId="1060" LastEditDate="2018-05-23T08:58:30.053" LastActivityDate="2018-05-23T08:58:30.053" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5989" PostTypeId="1" AcceptedAnswerId="5990" CreationDate="2015-12-29T18:16:36.953" Score="24" ViewCount="17091" Body="&lt;p&gt;I want to run the following shell.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wea-this is the end of the second word | vim j&#xA;exit 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which I had hoped would pipe the key strokes &lt;code&gt;w&lt;/code&gt; (move forward a word) then &lt;code&gt;e&lt;/code&gt; (end of the word) then &lt;code&gt;a&lt;/code&gt; (append) then &lt;code&gt;-this is the end of the second word&lt;/code&gt; (text) to the Vim document named &lt;code&gt;j&lt;/code&gt; which already has words in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following error occurred when I ran the shell script.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/root/bin/tt.sh: line 1: wea-this: command not found&#xA;Vim: Warning: Input is not from a terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am running Ubuntu 14.04.&#xA;Two types of answers will be appreciated:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to use piping to achieve this desired result.&lt;/li&gt;&#xA;&lt;li&gt;Another method by which I can use &quot;Vim commands&quot; (not ed or sed commands) to edit a text document from a shell script. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="2695" LastEditDate="2019-09-16T15:15:13.880" LastActivityDate="2019-09-16T15:15:13.880" Title="Is it possible to pipe vim commands to vim?" Tags="|invocation|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5990" PostTypeId="2" ParentId="5989" CreationDate="2015-12-29T18:29:42.533" Score="18" Body="&lt;p&gt;To insert the string &lt;code&gt;&quot;hello&quot;&lt;/code&gt; on the first line of the file &lt;code&gt;j&lt;/code&gt;, you could type in your shell the following command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim +&quot;1 | put! ='hello'&quot; j&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:1&lt;/code&gt; moves the cursor to the first line of the buffer&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:put! ='hello'&lt;/code&gt; pastes the string &quot;hello&quot; above the current line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To insert the string &lt;code&gt;&quot;hello&quot;&lt;/code&gt; and then save and quit the file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim +&quot;1 | put! ='hello' | x&quot; j&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same thing as before, we've just added the Ex command &lt;code&gt;:x&lt;/code&gt; which saves and quit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More generally you can execute any sequence of Ex commands on a file, from an interactive shell or from a bash script, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim +'Ex command1 | Ex command2 | ...' file&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a lot of Ex commands, you could write them all inside a dedicated file (called for example &lt;code&gt;myExCommands.vim&lt;/code&gt;), one command per line, and then from the shell or a script you could source it (with the Ex command &lt;code&gt;:source&lt;/code&gt; or the short version&lt;code&gt;:so&lt;/code&gt;) like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +'so myExCommands.vim' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see you've edited your question.&lt;br&gt;&#xA;I think the previous answer still applies, because you can execute any normal command from Ex mode with the Ex commands &lt;code&gt;:normal&lt;/code&gt; and &lt;code&gt;:execute&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's say you want to :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;move your cursor on the first line of the buffer (&lt;code&gt;1G&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;move your cursor to the first non whitespace character on the line (&lt;code&gt;_&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;move your cursor one word forward (&lt;code&gt;w&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;move your cursor to the end of the new word (&lt;code&gt;e&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;go into insert mode after the character under the cursor (&lt;code&gt;a&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;insert the string &lt;code&gt;hello&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;save and quit (&lt;code&gt;:x&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To do this on the file &lt;code&gt;j&lt;/code&gt;, type from the shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +&quot;execute 'normal! 1G_weahello' | x&quot; j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help +cmd&#xA;:help :normal&#xA;:help :execute&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-29T20:35:18.603" LastActivityDate="2015-12-29T20:35:18.603" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5991" PostTypeId="2" ParentId="2764" CreationDate="2015-12-29T21:34:08.093" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/kassio/neoterm&quot; rel=&quot;nofollow&quot;&gt;Neoterm&lt;/a&gt; is a plugin for neovim that is developed for this purpose. It implements a new command &lt;code&gt;:TREPLSend&lt;/code&gt; which will take the current line and send it to a terminal window. Works fine for basic bash and any language that has a REPL mode.&lt;/p&gt;&#xA;" OwnerUserId="5831" LastActivityDate="2015-12-29T21:34:08.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5992" PostTypeId="1" AcceptedAnswerId="6003" CreationDate="2015-12-29T23:58:12.010" Score="6" ViewCount="812" Body="&lt;h1&gt;Questions&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;In the following example:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why in the first line, a &lt;code&gt;\t&lt;/code&gt; is inserted but only 4-col blank is displayed? Shouldn't it be &lt;code&gt;8&lt;/code&gt; according to &lt;code&gt;tabstop&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Why the two &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; hits in the first line and fifth lines have different results? (one is &lt;code&gt;09&lt;/code&gt; and the other is &lt;code&gt;20202020&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;.vimrc&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noexpandtab&#xA;set tabstop=8                             &#xA;set shiftwidth=4                                    &#xA;set softtabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Text&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I created the following text by first inserting 8 empty lines and then typing at the beginning of each line, so that there is no &lt;code&gt;shiftwidth&lt;/code&gt; generated. (each 4-col blank below is inserted by hitting &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1tab    done&#xA;2tabs        done&#xA;3tabs            done&#xA;4tabs                done&#xA;    1tab&#xA;        2tabs&#xA;            3tabs&#xA;                4tabs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;hex representation&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Then I did &lt;code&gt;:%!xxd&lt;/code&gt;, this is what I got (with some trailing newlines):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0000000: 3174 6162 0964 6f6e 650a 3274 6162 7309  1tab.done.2tabs.                                                                                                        &#xA;0000010: 2020 2020 646f 6e65 0a33 7461 6273 0909      done.3tabs..                                                                                                        &#xA;0000020: 646f 6e65 0a34 7461 6273 0909 2020 2020  done.4tabs..                                                                                                            &#xA;0000030: 646f 6e65 0a20 2020 2031 7461 620a 0932  done.    1tab..2                                                                                                        &#xA;0000040: 7461 6273 0a09 2020 2020 3374 6162 730a  tabs..    3tabs.                                                                                                        &#xA;0000050: 0909 3474 6162 730a 0a0a 0a0a 0a0a 0a0a  ..4tabs.........&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Related discussion&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are some pretty good answers &lt;a href=&quot;https://stackoverflow.com/q/1878974/2160440&quot;&gt;here&lt;/a&gt; but I still don't understand what is going on in this particular case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(PS: this thread was posted &lt;a href=&quot;https://stackoverflow.com/q/34276561/2160440&quot;&gt;here&lt;/a&gt; but no comprehensive solution is found so I'm reposting it now.)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vimcasts.org/episodes/tabs-and-spaces/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt; from @EvergreenTree below is very helpful and almost solved my problem, however it seems not to answer my second question.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Solution (adapted from &lt;a href=&quot;https://vi.stackexchange.com/a/6003/5833&quot;&gt;Christ's answer&lt;/a&gt; below)&lt;/h1&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;tabstop=8&lt;/code&gt; does not necessarily mean each &lt;code&gt;\t&lt;/code&gt; is displayed as 8 columns, instead it means each &lt;code&gt;\t&lt;/code&gt; is displayed as &lt;strong&gt;ALIGNED&lt;/strong&gt; to 8 columns.&lt;/li&gt;&#xA;&lt;li&gt;Similarly, &lt;code&gt;softtabstop=4&lt;/code&gt; means each &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; hit (in contrast to &lt;code&gt;\t&lt;/code&gt; for &lt;code&gt;tabstop&lt;/code&gt; above) is displayed as aligned to 4 columns.&lt;/li&gt;&#xA;&lt;li&gt;When &lt;code&gt;noexpandtab&lt;/code&gt; is set, &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; hit may generate &lt;code&gt;\t&lt;/code&gt;, spaces, or a mixture of them, depending on the current position of cursor. More precisely, it will advance to next position aligned with &lt;code&gt;softtabstop&lt;/code&gt;. If this position is not aligned with &lt;code&gt;tabstop&lt;/code&gt;, spaces will be inserted. If it is, &lt;code&gt;\t&lt;/code&gt; will be inserted and redundant former spaces will be removed if needed. (see the video provided by @EvergreenTree below for an example of removing previously existed spaces). &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5833" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2015-12-30T16:40:43.713" Title="vimrc tab behavior when noexpandtab and softtabstop is less than tabstop" Tags="|indentation|tab-characters|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5993" PostTypeId="2" ParentId="5842" CreationDate="2015-12-30T01:11:49.587" Score="4" Body="&lt;p&gt;To see all the files that Vim sourced during launch, I typed &lt;code&gt;:scriptnames&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;When launching vim with the command &lt;code&gt;$vim --noplugin&lt;/code&gt; or &lt;code&gt;$vim&lt;/code&gt;, there is a &lt;code&gt;/etc/vimrc&lt;/code&gt; file which is sourced;&lt;/li&gt;&#xA;&lt;li&gt;When launching vim with &lt;code&gt;$vim -u NONE&lt;/code&gt; or &lt;code&gt;$vim -u NORC&lt;/code&gt;, this &lt;code&gt;/etc/vimrc&lt;/code&gt; file is gone.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There are other differences in the list of sourced files, but only &lt;code&gt;/etc/vimrc&lt;/code&gt; caught my eye because &lt;code&gt;vimrc&lt;/code&gt; is included in this path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I experimented with &lt;code&gt;/etc/vimrc&lt;/code&gt; and I found that one statement in it was modifying the behavior &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; and &lt;code&gt;:tag {indent}&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cscopetag&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I comment out this line, the problem no longer exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the vim help (&lt;code&gt;:help cscopetag&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If 'cscopetag' is set, the commands &quot;:tag&quot; and CTRL-] as well as &quot;vim&#xA;  -t&quot; will always use :cstag instead of the default :tag behavior.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help :cstag&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you use cscope as well as ctags, |:cstag| allows you to search one&#xA;  or the other before making a jump.  For example, you can choose to&#xA;  first search your cscope database(s) for a match, and if one is not&#xA;  found, then your tags file(s) will be searched.  The order in which&#xA;  this happens is determined by the value of |csto|.  See&#xA;  |cscope-options| for more details.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;|:cstag| performs the equivalent of &quot;:cs find g&quot; on the identifier&#xA;  when searching through the cscope database(s).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;|:cstag| performs the equivalent of |:tjump| on the identifier when&#xA;  searching through your tags file(s).&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5510" LastActivityDate="2015-12-30T01:11:49.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5994" PostTypeId="2" ParentId="5989" CreationDate="2015-12-30T07:25:33.193" Score="11" Body="&lt;p&gt;Here is a way you can use normal-mode commands, rather than just ex commands, to edit a stream presented to Vim from stdin. This isn't a very useful example, but it illustrates the techniques involved. It assumes that your shell is bash.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;The brown fox jumped.&quot; | vim -s &amp;lt;(printf 'wcwred\e:wq! foo\n') -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-&lt;/code&gt; at the end tells Vim to read text (not commands) from stdin. The &lt;code&gt;-s&lt;/code&gt; tells Vim to execute keystrokes from the specified file. In this case, the file is the output of a bash process substitution. The &lt;code&gt;&amp;lt;(...)&lt;/code&gt; is replaced by the name of a named pipe. The output of the pipe is the output of the command within the parentheses. The &lt;code&gt;wcwred\e&lt;/code&gt; moves the cursor by one word and changes that next word to &lt;code&gt;red&lt;/code&gt;. The &lt;code&gt;:wq! foo\n&lt;/code&gt; saves the result to the file &lt;code&gt;foo&lt;/code&gt; even if that file already exists. The end result is a file named &lt;code&gt;foo&lt;/code&gt; containing the text &lt;code&gt;The red fox jumped.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more on some of those topics, see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help -file&#xA;:help -s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also the &lt;code&gt;Process Substitution&lt;/code&gt; section of the &lt;code&gt;bash(1)&lt;/code&gt; man page.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2015-12-30T07:25:33.193" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5995" PostTypeId="1" AcceptedAnswerId="5997" CreationDate="2015-12-30T08:57:11.680" Score="7" ViewCount="301" Body="&lt;p&gt;I'm used to set marks with &lt;code&gt;m&amp;lt;char&amp;gt;&lt;/code&gt; where &lt;code&gt;&amp;lt;char&amp;gt;&lt;/code&gt; is any character I choose and then reaching the marks with &lt;code&gt;]`&lt;/code&gt; or &lt;code&gt;[`&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if it is possible to use a command to set a mark with an &lt;strong&gt;incremental index&lt;/strong&gt; instead of a character, avoiding to override marks previously set.&lt;/p&gt;&#xA;" OwnerUserId="5707" LastActivityDate="2015-12-30T10:18:02.873" Title="How to set incremental marks?" Tags="|cursor-movement|mark|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5996" PostTypeId="2" ParentId="5995" CreationDate="2015-12-30T09:54:03.710" Score="3" Body="&lt;p&gt;I'm not sure I understood what you wanted. But if you want to cycle through all the available local marks from &lt;code&gt;a&lt;/code&gt; to &lt;code&gt;z&lt;/code&gt;, then the following mapping should allow you to do so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;m&#xA;            \ :&amp;lt;c-u&amp;gt;if !exists('marklist') \|\| marklist == [] &amp;lt;bar&amp;gt;&#xA;            \     let marklist = map(range(98, 122), &quot;nr2char(v:val)&quot;) &amp;lt;bar&amp;gt;&#xA;            \     execute 'normal! ma' &amp;lt;bar&amp;gt;&#xA;            \ else &amp;lt;bar&amp;gt;&#xA;            \     execute 'normal! m' . marklist[0] &amp;lt;bar&amp;gt;&#xA;            \     let marklist = marklist[1:] &amp;lt;bar&amp;gt;&#xA;            \ endif&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you hit &lt;code&gt;&amp;lt;leader&amp;gt;m&lt;/code&gt;, the first time it should set the mark &lt;code&gt;a&lt;/code&gt; where the cursor is, the second time the mark &lt;code&gt;b&lt;/code&gt;, etc.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-30T10:18:02.873" LastActivityDate="2015-12-30T10:18:02.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5997" PostTypeId="2" ParentId="5995" CreationDate="2015-12-30T10:16:38.577" Score="6" Body="&lt;p&gt;There is nothing built in to vim, but you can script something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:IncrementalMark() abort&#xA;    let b:index_mark=get(b:, 'index_mark', -1)+1&#xA;    &quot; configure, which marks to use&#xA;    let marks='abcdefghijklmnopqrstuvwxyz'&#xA;    return 'm'.marks[b:index_mark%strlen(marks)]&#xA;endfu&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;m &amp;lt;sid&amp;gt;IncrementalMark()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;marks&lt;/code&gt; variable, to configure which marks are actually allowed to be overwritten by this function. If you e.g. want to set the mark a yourself, then remove the a from this variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, that since marks are buffer-local, so will this function start with the first mark again, once you switch buffers, so you can have the same (lowercase) mark in several buffers.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-12-30T10:16:38.577" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5998" PostTypeId="1" AcceptedAnswerId="5999" CreationDate="2015-12-30T11:52:45.277" Score="12" ViewCount="3613" Body="&lt;p&gt;From Vim's help document (see: &lt;code&gt;:help 'path'&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'path' String(default on Unix: &quot;&lt;code&gt;.,/usr/include,,&lt;/code&gt;&quot;)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;-To search relative to the directory of the current file, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set path=.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;-To search in the current directory use an empty string between two commas:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set path=,,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It seems that &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;,,&lt;/code&gt; have no difference in  'path' option. They both mean the current directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot understand why we need to put both &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;,,&lt;/code&gt; to the path option.  What is the difference between &lt;code&gt;:set path=.&lt;/code&gt; and &lt;code&gt;:set path=,,&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5510" LastActivityDate="2015-12-30T12:57:43.963" Title="Is Vim's default 'path' option redundant?" Tags="|path|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5999" PostTypeId="2" ParentId="5998" CreationDate="2015-12-30T12:57:37.310" Score="16" Body="&lt;p&gt;&quot;Current directory&quot; and &quot;directory of the current file&quot; are two different things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;current directory&quot; is by default the directory in which you started Vim. You ask Vim what it is with &lt;code&gt;:pwd&lt;/code&gt; and change it with &lt;code&gt;:cd&lt;/code&gt; or &lt;code&gt;:lcd&lt;/code&gt; or by setting the &lt;code&gt;autochdir&lt;/code&gt; option. If you never change it, it will stay the same until you close the current session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;directory of the current file&quot; is exactly what it claims to be. If the current file is in the &quot;current directory&quot;, both have the same value. If the current file is in another directory, they have different values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;path&lt;/code&gt; to be useful, it is necessary to address those two scenarios with &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;,,&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd /foo/bar/baz&#xA;$ vim filename&#xA;:pwd                   --&amp;gt;  /foo/bar/baz&#xA;:echo expand(&quot;%:p:h&quot;)  --&amp;gt;  /foo/bar/baz&#xA;:e ../file&#xA;:pwd                   --&amp;gt;  /foo/bar/baz&#xA;:echo expand(&quot;%:p:h&quot;)  --&amp;gt;  /foo/bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2015-12-30T12:57:37.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6000" PostTypeId="2" ParentId="5998" CreationDate="2015-12-30T12:57:43.963" Score="7" Body="&lt;p&gt;The &lt;em&gt;directory of the current file&lt;/em&gt; and &lt;em&gt;current directory&lt;/em&gt; are two &#xA;entirely different things (that may, on occasion, have the same value).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /tmp; vim /etc/bash.bashrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unless I have &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27autochdir%27&quot;&gt;&lt;code&gt;autochdir&lt;/code&gt;&lt;/a&gt; (or something similar) set, the current directory is &lt;code&gt;/tmp&lt;/code&gt;, yet the directory of the current file is &lt;code&gt;/etc&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2015-12-30T12:57:43.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6001" PostTypeId="2" ParentId="5963" CreationDate="2015-12-30T13:54:10.293" Score="6" Body="&lt;p&gt;As @romainl said, It is indeed an FS(file system) case-sensitivity issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My project file is mounted from Window 7 to my Fedora using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mount {Windows 7 Dir} {Fedora Dir} /local_folder -t cifs -o username=xxxx,password=xxxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;http://linux.die.net/man/8/mount.cifs&quot; rel=&quot;noreferrer&quot;&gt;mount.cifs&lt;/a&gt; man page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;case sensitive is the default if the server supports it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It means that the Mount will preserve the case-sensitivity of the server FS. If the server's FS is case-sensitive, these mounted files will be case-sensitive; If the server's FS is case-insensitive, they will be case-insensitive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Windows 7 is case-insensitive, which makes these project files case-insensitive.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd {My project root directory}&#xA;$ ls tags&#xA;tags&#xA;$ ls TAGS&#xA;TAGS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If 'tags' option includes both &lt;em&gt;tags&lt;/em&gt; and &lt;em&gt;TAGS&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set tags=tags,TAGS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will search the tags file twice: one for &lt;em&gt;tags&lt;/em&gt;, another for &lt;em&gt;TAGS&lt;/em&gt;. In both times, Vim finds that there is one fits. This makes Vim mistake one same &lt;em&gt;tags&lt;/em&gt; file for two different files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consequently, Vim will use two tags files:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo tagfiles()&#xA;['tags', 'TAGS']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus, duplicate tags problem happened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If 'tags' option includes only &lt;em&gt;tags&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set tags=tags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem will not exist.&lt;/p&gt;&#xA;" OwnerUserId="5510" LastEditorUserId="5510" LastEditDate="2015-12-30T14:06:19.823" LastActivityDate="2015-12-30T14:06:19.823" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6002" PostTypeId="1" CreationDate="2015-12-30T14:06:13.280" Score="1" ViewCount="559" Body="&lt;p&gt;I have the following problem. If the location list is open (e.g., by Syntastic) and some other plugin opens a preview window (e.g., YCM or jedi-vim), the cursor goes in the location list. Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Vxhuc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Vxhuc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After selecting &quot;abort&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E609k.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E609k.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It happens in vim, neovim and gvim.&#xA;Any ideas?&#xA;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: it seems the problem was caused by MiniBufExpl.&lt;/p&gt;&#xA;" OwnerUserId="5842" LastEditorUserId="1577" LastEditDate="2016-06-22T15:25:14.013" LastActivityDate="2016-06-22T15:25:14.013" Title="Location list, preview window, autocompletion" Tags="|autocompletion|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6003" PostTypeId="2" ParentId="5992" CreationDate="2015-12-30T15:55:59.670" Score="2" Body="&lt;p&gt;By setting &lt;code&gt;softtabstop&lt;/code&gt; to a value smaller than the &lt;code&gt;tabstop&lt;/code&gt; value, Vim must insert spaces, as the tab when entered in insert mode may only be 4 chars wide. In contrast to line 1, the tab will move to column eight, even if there is some text in front of it.&#xA;This can be seen, by entering &lt;code&gt;o&amp;lt;C-U&amp;gt;&amp;lt;C-V&amp;gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; and then moving back to the first column and starting to insert some chars. Until you move over column 7, the tab after it will always stay.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-12-30T15:55:59.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6004" PostTypeId="1" CreationDate="2015-12-30T16:56:32.493" Score="5" ViewCount="213" Body="&lt;p&gt;I have seen this very interesting article: &lt;a href=&quot;http://dustycloud.org/blog/vcs-friendly-patchable-document-line-wrapping/&quot; rel=&quot;nofollow&quot;&gt;http://dustycloud.org/blog/vcs-friendly-patchable-document-line-wrapping/&lt;/a&gt; --- basically it is a suggestion for hard-breaking lines of text (for example, in markdown or LaTeX sources) to achieve both easy readability and easy &quot;diff&quot;-ability. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, when I write in LaTeX normally I follow the classical way of &quot;one line per phrase&quot; (hard new line at full stop), and the mandatory blank line for paragraph. This is unfortunately almost unreadable in a &lt;code&gt;diff&lt;/code&gt; of a very long phrase, especially if the change is near the end. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The suggested format is to have a line format (a la &lt;code&gt;gqip&lt;/code&gt;) for every phrase, but keeping the phrases on their own. For example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a short phrase. This, instead, is a very long, probably too long for English, phrase, but in other languages very long phrases are quite common, really --- and so on and so on.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be formatted as (this has &lt;code&gt;setl tw=60&lt;/code&gt; to be more dramatic) &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a short phrase. &#xA;This, instead, is a very long, probably too long for&#xA;English, phrase, but in other languages very long phrases&#xA;are quite common, really --- and so on and so on.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can go from the first form to the final one by hand:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;format the paragraph with &lt;code&gt;gqip&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;go to the first full stop (or question mark, or a symbol meaning the end of the sentence); &lt;/li&gt;&#xA;&lt;li&gt;if it is the end of the paragraph, stop;&lt;/li&gt;&#xA;&lt;li&gt;otherwise, insert a linebreak; &lt;/li&gt;&#xA;&lt;li&gt;then go to the next line, format again the &lt;em&gt;rest&lt;/em&gt; of the paragraph as in point 1 above (still searching how to do this effectively --- clearly &lt;code&gt;gqip&lt;/code&gt; do not work here unless I temporarily add a blank line above); &lt;/li&gt;&#xA;&lt;li&gt;repeat until the end of the paragraph. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is there a way to apply such a type of formatting &lt;em&gt;automatically&lt;/em&gt; to a paragraph?&lt;/p&gt;&#xA;" OwnerUserId="854" LastEditorUserId="854" LastEditDate="2016-01-12T18:17:08.917" LastActivityDate="2016-01-15T11:39:30.870" Title="Text formatting CVS-friendly" Tags="|cursor-motions|formatting|filetype-tex|plugin-vimtex|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6005" PostTypeId="1" AcceptedAnswerId="6007" CreationDate="2015-12-30T18:08:08.583" Score="3" ViewCount="617" Body="&lt;p&gt;Frequently when using vim I will hit a case where I am looking at a function that is half off the bottom of the screen, and I would like to see the whole thing. &lt;code&gt;ctrl-D&lt;/code&gt; will generally solve the problem visually, but it also moves my cursor. If I was already at the top of the function, I'd like to stay there, just see the whole thing. Is there a version of &lt;code&gt;ctrl-D&lt;/code&gt; that acts more like &lt;code&gt;ctrl-e&lt;/code&gt;, or even better, a command sequence that would center whatever function my cursor is currently in?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vim in at least three places: native GNOME Terminal on Fedora, native Terminal on OS X, and in both places occasionally over ssh.&lt;/p&gt;&#xA;" OwnerUserId="423" LastActivityDate="2015-12-30T19:53:09.107" Title="Scroll without changing the cursor position" Tags="|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6007" PostTypeId="2" ParentId="6005" CreationDate="2015-12-30T19:53:09.107" Score="3" Body="&lt;p&gt;You can use zt for keeping cursor at the top, zb for bottom and zz for middle; furthermore, you can find out more about these by using :h command&lt;/p&gt;&#xA;" OwnerUserId="1305" LastActivityDate="2015-12-30T19:53:09.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6008" PostTypeId="1" AcceptedAnswerId="6009" CreationDate="2015-12-31T00:23:19.993" Score="15" ViewCount="11914" Body="&lt;p&gt;I would like to join lines together only for lines which have certain pattern (such as &lt;code&gt;;&lt;/code&gt;), however when using &lt;code&gt;g/;/j&lt;/code&gt; it doesn't work as expected unless called couple of times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&#xA;1;&#xA;2;&#xA;3;&#xA;4;&#xA;5;&#xA;b&#xA;6;&#xA;7;&#xA;8;&#xA;9;&#xA;c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when using: &lt;code&gt;:g/;/j&lt;/code&gt; the output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&#xA;1; 2;&#xA;3; 4;&#xA;5; b&#xA;6; 7;&#xA;8; 9;&#xA;c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;code&gt;:g/;/-j&lt;/code&gt; gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a 1; 2; 3; 4; 5;&#xA;b 6; 7; 8; 9;&#xA;c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;similar with: &lt;code&gt;:g/;\_.\{-};/j&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My expected output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a &#xA;1; 2; 3; 4; 5;&#xA;b&#xA;6; 7; 8; 9;&#xA;c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or something similar, so all lines containing the pattern are joined together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How this can be achieved?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2015-12-31T01:50:09.773" LastActivityDate="2020-06-19T16:19:17.300" Title="How to join all lines together which matching pattern?" Tags="|global-command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6009" PostTypeId="2" ParentId="6008" CreationDate="2015-12-31T05:14:45.837" Score="19" Body="&lt;p&gt;&lt;strong&gt;Possible explanation of the problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the reason why &lt;code&gt;:g/;/j&lt;/code&gt; doesn't work is because the &lt;code&gt;:g&lt;/code&gt; command operates with a 2-pass algorithm:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;during the first pass it marks the lines containing the pattern &lt;code&gt;;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;during the second pass it operates on the marked lines&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;During the second pass, &lt;code&gt;:g&lt;/code&gt; joins the line &lt;code&gt;1;&lt;/code&gt; with line &lt;code&gt;2;&lt;/code&gt; because &lt;code&gt;1;&lt;/code&gt; was marked during the first pass.&#xA;However I suspect (not sure) that it doesn't join &lt;code&gt;1; 2;&lt;/code&gt; with &lt;code&gt;3;&lt;/code&gt; because the line &lt;code&gt;2;&lt;/code&gt; doesn't exist anymore, its content has been merged with the line &lt;code&gt;1;&lt;/code&gt; which has already been processed.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;:g&lt;/code&gt; looks for the next line which was marked during first pass (&lt;code&gt;3;&lt;/code&gt;) and joins it with the following one (&lt;code&gt;4;&lt;/code&gt;). After that the problem repeats, it can't join &lt;code&gt;3; 4;&lt;/code&gt; with &lt;code&gt;5;&lt;/code&gt; because the line &lt;code&gt;4;&lt;/code&gt; doesn't exist anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution 1 (with vimscript)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe you could call a function whenever a line containing &lt;code&gt;;&lt;/code&gt; is found to check whether the previous line also contains a semicolon:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! JoinLines()&#xA;    if getline(line('.')-1) =~ ';'&#xA;        .-1join&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then use the following global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/;/call JoinLines()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or without a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/;/if getline(line('.')-1) =~ ';' | -j | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution 2 (without vimscript)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/;/.,/^[^;]*$/-1j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whenever the global command &lt;code&gt;:g&lt;/code&gt; finds the pattern &lt;code&gt;;&lt;/code&gt; it executes the command:  &lt;code&gt;.,/^[^;]*$/-1j&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be broken down like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/pattern/a,bj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pattern = ;&#xA;a       = .           = number of current line&#xA;b       = /^[^;]*$/-1 = number of next line without any semicolon minus one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;b&lt;/code&gt; can be broken down further like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/    = look for the number of the next line matching the following pattern&#xA;^    = a beginning of line&#xA;[^;] = then any character except a semicolon&#xA; *   = the last character can be repeated 0 or more times&#xA; $   = an end of line&#xA; /   = end of pattern&#xA; -1  = removes one to the number you just got&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;j&lt;/code&gt; is the abbreviated form of the Ex command &lt;code&gt;:join&lt;/code&gt; which like most other Ex commands can be preceded by a range.&lt;br&gt;&#xA;Here it's preceded by the range: &lt;code&gt;.,/^[^;]*$/-1&lt;/code&gt; (&lt;code&gt;a,b&lt;/code&gt;)&lt;br&gt;&#xA;A range follows the form &lt;code&gt;a,b&lt;/code&gt; where &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; are generally 2 line numbers, and allows you to operate on a group of lines whose number is between &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;, instead of just one.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the &lt;code&gt;j&lt;/code&gt; command joins all the lines between the current one (&lt;code&gt;a&lt;/code&gt;) and the next one which doesn't contain any semicolon minus one (&lt;code&gt;b&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :global&#xA;:help :join&#xA;:help :range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2015-12-31T08:07:09.663" LastActivityDate="2015-12-31T08:07:09.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6010" PostTypeId="1" CreationDate="2015-12-31T06:04:15.757" Score="2" ViewCount="608" Body="&lt;p&gt;My research hints that there is no way to have a JS file properly formatted without going through installations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder whether there is a minimal effort way of doing it in vim.&#xA;What are your opinions on that one? What do you recommend? Can't this be achieved by an appropriate configuration of a &lt;code&gt;.vimrc&lt;/code&gt; file?&lt;/p&gt;&#xA;" OwnerUserId="2053" LastActivityDate="2015-12-31T10:12:41.570" Title="Minimal to effort to have a JS beautifier on vim" Tags="|vimrc|filetype-javascript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6011" PostTypeId="1" AcceptedAnswerId="6012" CreationDate="2015-12-31T07:25:15.410" Score="2" ViewCount="1600" Body="&lt;p&gt;I need in vim input the following Numbers:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;23²,66²,38³&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How to insert this number?&lt;/p&gt;&#xA;" OwnerUserId="5841" LastEditorUserId="1543" LastEditDate="2015-12-31T13:22:42.733" LastActivityDate="2015-12-31T13:22:42.733" Title="How to insert the square number symbol (small 2) in vim?" Tags="|insert-mode|" AnswerCount="1" CommentCount="0" ClosedDate="2015-12-31T12:44:30.637" ContentLicense="CC BY-SA 3.0" />
  <row Id="6012" PostTypeId="2" ParentId="6011" CreationDate="2015-12-31T08:21:49.600" Score="4" Body="&lt;p&gt;The simplest way is probably to copy and paste those numbers into Vim. That should just work. Alternatively, if you want to write down those, you can use the digraph feature like this: &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;K&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;S&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the help at &lt;code&gt;:h digraphs&lt;/code&gt; and &lt;code&gt;:h 24.9&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-12-31T08:21:49.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6013" PostTypeId="2" ParentId="6010" CreationDate="2015-12-31T09:01:14.177" Score="8" Body="&lt;p&gt;I recommend filtering your buffer/file through a node module called &lt;a href=&quot;https://www.npmjs.com/package/js-beautify&quot;&gt;js-beautify&lt;/a&gt; (also available as a python module):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!js-beautify -f -        &quot; whole buffer&#xA;:'&amp;lt;,'&amp;gt;!js-beautify -f -    &quot; selected lines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the custom command I have in &lt;code&gt;after/ftplugin/javascript.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -buffer -range=% Format let b:winview = winsaveview() |&#xA;    \ execute &amp;lt;line1&amp;gt; . &quot;,&quot; . &amp;lt;line2&amp;gt; . &quot;!js-beautify -f - -j -t -s &quot; . &amp;amp;shiftwidth |&#xA;    \ call winrestview(b:winview)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That command works on the whole buffer by default or on any range, while keeping the cursor position and, &lt;em&gt;more or less&lt;/em&gt;, respecting indentation settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read &lt;code&gt;$ js-beautify --help&lt;/code&gt; for the available options.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2015-12-31T10:12:41.570" LastActivityDate="2015-12-31T10:12:41.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6014" PostTypeId="1" AcceptedAnswerId="6015" CreationDate="2015-12-31T11:28:04.223" Score="4" ViewCount="121" Body="&lt;p&gt;I have a key mapped to a command which runs a function, and I would like to detect whether it has been passed a range (prefixed with a count) or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difficultly is that I need to be able to differentiate between &lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;CTRL E&lt;/kbd&gt; and plain &lt;kbd&gt;CTRL E&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;kbd&gt;CTRL E&lt;/kbd&gt; is actually my interactive buffer selector.  But when a range is passed I would like it to act like &lt;kbd&gt;CTRL ^&lt;/kbd&gt;.  That is because I like the functionality of &lt;kbd&gt;CTRL ^&lt;/kbd&gt;, but it is too much of a stretch for my left hand!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-E&amp;gt; :JoeysBufferSwitch&amp;lt;Enter&amp;gt;&#xA;command! -range JoeysBufferSwitch &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call JoeysBufferSwitch()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I can tell if &lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;CTRL E&lt;/kbd&gt; was pressed, because &lt;code&gt;a:lastline - a:firstline&lt;/code&gt; will be &lt;code&gt;4&lt;/code&gt; inside the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I &lt;strong&gt;cannot detect&lt;/strong&gt; whether &lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;CTRL E&lt;/kbd&gt; was pressed or &lt;kbd&gt;CTRL E&lt;/kbd&gt; was pressed, because in both cases &lt;code&gt;a:lastline == a.firstline&lt;/code&gt; inside the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can detect the difference between these two situations, or otherwise behave differently when a count is passed and when a count is not passed?&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="343" LastEditDate="2017-12-06T11:26:11.417" LastActivityDate="2017-12-06T11:26:11.417" Title="Can my mapping/function detect when count/range 1 is given instead of none?" Tags="|key-bindings|functions|range|count|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6015" PostTypeId="2" ParentId="6014" CreationDate="2015-12-31T11:55:59.373" Score="5" Body="&lt;p&gt;To get the count given to &lt;code&gt;&amp;lt;C-E&amp;gt;&lt;/code&gt;, you don't need to use the range to do it. There are two pre-defined variables you can use, &lt;code&gt;v:count&lt;/code&gt; and &lt;code&gt;v:count1&lt;/code&gt;, which contain the count given to the last normal mode command. The former should work for you, as it will be zero when no count has been given. The latter defaults to 1 in same situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a minimal working example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EchoCount()&#xA;    echo v:count&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;C-E&amp;gt; :&amp;lt;C-u&amp;gt;call EchoCount()&amp;lt;Enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; is used to clear the range before issuing &lt;code&gt;:call&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the range, I don't think there is a way to distinguish between &lt;code&gt;:.Command&lt;/code&gt; (which is what happens when you press &lt;code&gt;1&lt;/code&gt; before &lt;code&gt;:&lt;/code&gt;) and &lt;code&gt;:Command&lt;/code&gt;, when no count is given.&lt;/p&gt;&#xA;" OwnerUserId="1672" LastEditorUserId="1672" LastEditDate="2016-01-25T10:36:10.917" LastActivityDate="2016-01-25T10:36:10.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6016" PostTypeId="1" AcceptedAnswerId="6018" CreationDate="2015-12-31T19:14:39.753" Score="7" ViewCount="5005" Body="&lt;p&gt;When I do a &lt;code&gt;/someStringtoFind&lt;/code&gt; in vim it immediately jumps to the closest matched string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Almost always this is what I want it to do. Sometimes though, I want to be able to enter a string to find and not have my cursor move while I am typing the string. Then, after I have finished typing the string, I could hit enter for vim to jump to the string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="5601" LastEditorUserId="54" LastEditDate="2015-12-31T19:21:31.987" LastActivityDate="2015-12-31T22:20:05.310" Title="Do a forward slash search but don't have vim immediately jump to the string?" Tags="|search|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6017" PostTypeId="2" ParentId="6016" CreationDate="2015-12-31T21:57:49.057" Score="4" Body="&lt;p&gt;You can make use of the fact, that you can set the search register &lt;code&gt;@/&lt;/code&gt; directly, which does not move the cursor. So simply do &lt;code&gt;:let @/='foobar'&lt;/code&gt;&#xA;and the cursor position won't change. If you want to move to the match, you press &lt;kbd&gt;n&lt;/kbd&gt; as usual.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2015-12-31T21:57:49.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6018" PostTypeId="2" ParentId="6016" CreationDate="2015-12-31T22:20:05.310" Score="9" Body="&lt;p&gt;Type &lt;code&gt;:&lt;/code&gt; before searching: &lt;strong&gt;&lt;code&gt;:/someStringtoFind&lt;/code&gt; &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/strong&gt;. If the match isn't at the beginning of the line, press &lt;code&gt;n&lt;/code&gt; to go to the beginning of the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/someStringtoFind/&lt;/code&gt; is an empty ex command with the range of lines &lt;code&gt;/someStringtoFind/&lt;/code&gt; (a 1-line range). The empty ex command means “jump to the end of the range”, so the command jumps to the next line containing a match for &lt;code&gt;someStringtoFind&lt;/code&gt;. You can drop the final &lt;code&gt;/&lt;/code&gt; if you have nothing to put afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:/someStringtoFind&lt;/code&gt; drops you to the beginning of the target line. The search is stored in the search history, so &lt;code&gt;n&lt;/code&gt; brings you to the beginning of the next match, which is on the current line. There's an exception: if the match starts at the beginning of the line, then you're already at the beginning of the match, and &lt;code&gt;n&lt;/code&gt; would bring you to the next match. As long as the match doesn't span lines, &lt;code&gt;$N&lt;/code&gt; brings you to the beginning of the match reliably, if you don't mind the extra typing (or are writing a macro).&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2015-12-31T22:20:05.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6019" PostTypeId="1" AcceptedAnswerId="6024" CreationDate="2016-01-01T09:56:49.930" Score="7" ViewCount="2229" Body="&lt;p&gt;I often write functions in my &lt;code&gt;~/.vimrc&lt;/code&gt; or in &lt;code&gt;~/.vim/autoload/myfunctions.vim&lt;/code&gt;, which when executed result in an error such as:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function SomeFunction:&#xA;line   xx:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Those errors can be read in the output of the Ex command &lt;code&gt;:messages&lt;/code&gt;.&lt;br&gt;&#xA;Is there a way to populate the quickfix list with them, so that I can type &lt;code&gt;:copen&lt;/code&gt;, navigate through them, hit &lt;code&gt;Enter&lt;/code&gt; on one, and be automatically redirected to the file and line where an error has been raised?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-01-01T10:16:37.827" LastActivityDate="2020-02-10T03:22:18.443" Title="Is it possible to populate the quickfix list with the errors of vimscript functions?" Tags="|vimscript|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6020" PostTypeId="1" AcceptedAnswerId="6021" CreationDate="2016-01-01T09:58:31.283" Score="5" ViewCount="868" Body="&lt;p&gt;I would like to define some mappings involving key combinations like &lt;code&gt;&amp;lt;S-F1&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;A-d&amp;gt;&lt;/code&gt;.&lt;br&gt;&#xA;For example something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;A-d&amp;gt; :echo &quot;hello world!&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, on my system, it doesn't work. I'm using guake as a terminal emulator and tmux as a terminal multiplexer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a solution &lt;a href=&quot;https://stackoverflow.com/a/27206531&quot;&gt;here&lt;/a&gt;. Basically the person says that you must do the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;launch the utility &lt;code&gt;cat&lt;/code&gt; inside your shell&lt;/li&gt;&#xA;&lt;li&gt;hit your key combination (e.g. &lt;code&gt;&amp;lt;A-d&amp;gt;&lt;/code&gt;), and read the output (e.g. &lt;code&gt;^[d&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;add in your vimrc &lt;code&gt;set {key combination}={cat output}&lt;/code&gt; (e.g. &lt;code&gt;set &amp;lt;A-d&amp;gt;=^[d&lt;/code&gt;)&lt;br&gt;&#xA;The trick being not to type &lt;code&gt;^[&lt;/code&gt; litteraly, but &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;escape&amp;gt;&lt;/code&gt; to insert a litteral escape character (whose caret notation is &lt;code&gt;^[&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;finally define your mapping as usual&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It works but I'm not sure why the first three steps are required on my system and what they do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my understanding of what happens when I hit a key on a keyboard.&lt;br&gt;&#xA;A keycode is sent to the kernel (which can be read with the &lt;code&gt;xev&lt;/code&gt; utility).&lt;br&gt;&#xA;The kernel sends this keycode to the X server which uses a table to translate it into a keysym (a key symbol like &lt;code&gt;A&lt;/code&gt;, &lt;code&gt;aacute&lt;/code&gt;, &lt;code&gt;F1&lt;/code&gt;...).&lt;br&gt;&#xA;The keysym is sent to the gui program which has the focus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, when I hit &lt;code&gt;&amp;lt;A-d&amp;gt;&lt;/code&gt;, the kernel receives 2 keycodes (&lt;code&gt;64&lt;/code&gt; for &lt;code&gt;Alt_L&lt;/code&gt; and &lt;code&gt;40&lt;/code&gt; for &lt;code&gt;d&lt;/code&gt;) which are translated into 2 keysyms by the X server (&lt;code&gt;0xffe9, Alt_L&lt;/code&gt; and &lt;code&gt;0x64, d&lt;/code&gt;).&#xA;The combination of keysyms &lt;code&gt;Alt_L&lt;/code&gt; and &lt;code&gt;d&lt;/code&gt; is sent to guake, which sends it to tmux, which sends it to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside the tmux configuration file I could map &lt;code&gt;&amp;lt;A-d&amp;gt;&lt;/code&gt; to make it perform some action. So tmux understands this combination of keysyms. Why does vim not understand it like tmux ?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do I need to put &lt;code&gt;set &amp;lt;A-d&amp;gt;=^[d&lt;/code&gt; in my vimrc ?&#xA;And what's &lt;code&gt;^[d&lt;/code&gt; ? An escape sequence ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found 2 paragraphs in the help &lt;code&gt;:help :set-termcap&lt;/code&gt; which treat this question, but I still don't understand. They talk about something called &lt;a href=&quot;https://en.wikipedia.org/wiki/Termcap&quot; rel=&quot;nofollow noreferrer&quot;&gt;termcap&lt;/a&gt;. I read the wikipedia page, and basically what I understood is that termcap is a library as well as a database containing information for hundreds of terminals. It allows programs (like the shell or vim) to know how to use a terminal to display some text.&#xA;Like for example:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;how many screen columns are available&lt;/li&gt;&#xA;&lt;li&gt;which string to send to move the cursor to an arbitrary position&lt;/li&gt;&#xA;&lt;li&gt;how to scroll the screen&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;According to the help an instruction like &lt;code&gt;set &amp;lt;A-d&amp;gt;=^[d&lt;/code&gt; allows you to override some value stored in the termcap database. Which value was stored in termcap, and why is it necessary to override it specifically for vim ?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-01-01T11:57:30.647" Title="Understanding :help set-termcap" Tags="|key-bindings|terminal|linux|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6021" PostTypeId="2" ParentId="6020" CreationDate="2016-01-01T11:57:30.647" Score="2" Body="&lt;p&gt;Vim doesn't receive &lt;code&gt;Alt_L+d&lt;/code&gt;. It receives exactly what you obtained in &lt;code&gt;cat&lt;/code&gt; when you typed &lt;code&gt;&amp;lt;A-d&amp;gt;&lt;/code&gt;: &lt;code&gt;^]d&lt;/code&gt;, where &lt;code&gt;^]&lt;/code&gt; is a literal &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. Yes, Vim sees &lt;code&gt;&amp;lt;Esc&amp;gt;d&lt;/code&gt; when you press &lt;code&gt;&amp;lt;A-d&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, Vim is unable to recognize the Alt key as such, so you have to teach it.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-01-01T11:57:30.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6022" PostTypeId="2" ParentId="6019" CreationDate="2016-01-01T13:01:49.743" Score="5" Body="&lt;p&gt;I don't have a complete solution for you but most complex plugins have some kind of logging function for handling errors in a generic way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good approach would be to wrap some or all of your code in a &lt;code&gt;try-catch&lt;/code&gt; block, parse the exception and populate the quickfix list with useful information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a very simplistic implementation of the idea:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Foo()&#xA;    try&#xA;        bar&#xA;    catch&#xA;        call setqflist([{&quot;bufnr&quot;:1,&quot;lnum&quot;:1,&quot;text&quot;:v:exception}])&#xA;    endtry&#xA; endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pointing to the right file doesn't sound as easy, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help setqflist()&lt;/code&gt;, &lt;code&gt;:help :try&lt;/code&gt;, &lt;code&gt;:help v:exception&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-01-01T13:52:00.453" LastActivityDate="2016-01-01T13:52:00.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6023" PostTypeId="2" ParentId="6008" CreationDate="2016-01-01T19:47:41.187" Score="3" Body="&lt;p&gt;I do similar joining all the time with a global search and replace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;s/;\n/;/&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\n&lt;/code&gt; matches newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To find and delete blank lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;s/^$\n//&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not sure why, but if want to insert a new line you have to use &lt;code&gt;\r&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5868" LastActivityDate="2016-01-01T19:47:41.187" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6024" PostTypeId="2" ParentId="6019" CreationDate="2016-01-01T22:37:47.380" Score="8" Body="&lt;p&gt;A &lt;a href=&quot;https://stackoverflow.com/a/34078655/15934&quot;&gt;recent question on SO&lt;/a&gt; inspired me to develop a &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/exception.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;function that decodes &lt;code&gt;v:throwpoint&lt;/code&gt;&lt;/a&gt; that I use in a new &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/commit/268a18a5c9af7e5f411934a67f29e15ce0bbed8f&quot; rel=&quot;nofollow noreferrer&quot;&gt;logger&lt;/a&gt; that fills the quickfix list, and &lt;a href=&quot;https://github.com/LucHermitte/vim-UT&quot; rel=&quot;nofollow noreferrer&quot;&gt;my unit testing framework for vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be used to enhance romainl's answer in order to decode file+line from error messages.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Bar() abort&#xA;    bar&#xA;endfunction&#xA;&#xA;function! Foo()&#xA;  try&#xA;    call Bar()&#xA;  catch /.*/&#xA;    let bt = lh#exception#callstack(v:throwpoint)&#xA;    let data = map(copy(bt), '{&quot;filename&quot;: v:val.script, &quot;text&quot;: &quot;called from here&quot;, &quot;lnum&quot;: v:val.pos}')&#xA;    let data[0].text = v:exception&#xA;    call setqflist(data)&#xA;  endtry&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since my initial answer, I've &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/Callstack.md#lhexceptionsay_what&quot; rel=&quot;nofollow noreferrer&quot;&gt;improved the workflow&lt;/a&gt; to be able to decode the last error(s) sent as messages. A typical way to use it would be through a command like the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=? WTF call lh#exception#say_what(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: my implementation tries to adapt automatically to the current locale (see &lt;code&gt;:h :lang&lt;/code&gt;...) as error messages are localized, and to support some other minor issue (like &lt;code&gt;'#'&lt;/code&gt; character not &lt;code&gt;'isk'&lt;/code&gt; list option).&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2020-02-09T19:02:04.663" LastActivityDate="2020-02-09T19:02:04.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6025" PostTypeId="1" CreationDate="2016-01-02T04:28:55.237" Score="6" ViewCount="1087" Body="&lt;p&gt;When I want to recursively search files for a text pattern I use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:grep -R 'color:' .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim then lists the results in a quicklist window for easy access.&lt;br&gt;&#xA;But now I need to perform another grep pass to exclude some results.&lt;br&gt;&#xA;So far I have tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:grep -R 'color:' . \| grep -v '@'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;result: empty list, also tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:grep -R 'color:' . &amp;lt;bar&amp;gt; grep -v '@'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;result: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;/bin/bash: bar: No such file or directory&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How can I get shell piping to work, when the command is generated from Vim?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2016-01-13T11:14:17.203" Title="how to perform multiple grep passes by using piping in external shell?" Tags="|external-command|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="6026" PostTypeId="1" AcceptedAnswerId="6028" CreationDate="2016-01-02T05:44:13.840" Score="12" ViewCount="1295" Body="&lt;p&gt;Occasionally I want to override the default syntax highlighting colours and styles with my own preferences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I imagine the most appropriate way to do this would be to create my own colorscheme.  However I have a couple of questions.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If I want to set a highlight for a specific syntax group in a specific language, does this belong in my colorscheme, or would it be better to place it in &lt;code&gt;after/syntax/[filetype].vim&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight jsAssignExpIdent cterm=bold gui=bold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems a little odd to place obscure language-specific rules in the colorscheme, as they will be loaded whatever language I am working on, but it seems even worse to place highlight rules in the syntax file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sometimes I create new syntax rules for a specific language, in &lt;code&gt;after/syntax/[filetype].vim&lt;/code&gt;. In case other users want to employ these extensions, would it be appropriate for me to provide default highlight rules there which link to common default highlight groups? If another user wants to override that highlight colour, how should they do that?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;::::: after/syntax/asm.vim :::::&#xA;&#xA;syn match asmHexNumber /\(0x\|\$\)[0-9A-Fa-f]\+/&#xA;highlight default link asmHexNumber Number&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2017-01-13T04:37:24.650" LastActivityDate="2017-01-13T04:37:24.650" Title="Where do custom highlighting rules belong?" Tags="|syntax-highlighting|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6027" PostTypeId="2" ParentId="6025" CreationDate="2016-01-02T06:31:21.083" Score="6" Body="&lt;p&gt;The reason the pipe isn't functioning like you'd expect is because you're not grepping through the shell, you're grepping through Vim (see digression). For instance, this would be using your shell from Vim to perform your search:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!grep -R 'color:' . | grep -v '@'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;!&lt;/code&gt; at the beginning, which means &quot;execute this command from the shell&quot; (see &lt;code&gt;:h :!&lt;/code&gt;). This doesn't help your underlying problem, however, because your shell's end result won't go the quickfix list. This simply executes the whole command at the shell, lets you see it, and returns you to Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your fastest solution might be to employ grep's &lt;code&gt;--exclude&lt;/code&gt; (note: see EDIT below):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:grep -R --exclude='*@*' 'color:' .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Digression: &lt;code&gt;:grep&lt;/code&gt; is different from &lt;code&gt;:!grep&lt;/code&gt; in that Vim is using a file pattern searcher of your choice as an Ex command within Vim, not the shell. The &lt;code&gt;grepprg&lt;/code&gt; option indicates which file pattern searcher to use (use &lt;code&gt;:set grepprg?&lt;/code&gt; to see what's currently set). If you have &lt;code&gt;set grepprg=grep\ -nH&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt;, for instance, then &lt;code&gt;:grep&lt;/code&gt; will indeed use &lt;code&gt;grep&lt;/code&gt;. If &lt;code&gt;grepprg&lt;/code&gt; is set to &lt;code&gt;internal&lt;/code&gt;, however, then &lt;code&gt;:grep&lt;/code&gt; will use &lt;code&gt;:vimgrep&lt;/code&gt; instead, which will require a Vim search pattern. (You might be familiar with the Vim search pattern from using &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;?&lt;/code&gt;.) See &lt;code&gt;:h :grep&lt;/code&gt; and &lt;code&gt;:h :vimgrep&lt;/code&gt; for details. Also, if you like &lt;a href=&quot;http://beyondgrep.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ack&lt;/a&gt; or &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;nofollow noreferrer&quot;&gt;ag&lt;/a&gt;, you can set &lt;code&gt;grepprg&lt;/code&gt; to tell &lt;code&gt;:grep&lt;/code&gt; to use them instead of regular grep or vimgrep.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;EDIT&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;@the_velour_fog Thanks for correcting me by pointing out that grep's &lt;code&gt;--exclude&lt;/code&gt; is excluding files to grep, rather than omitting lines that otherwise match grep's search pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution is to use Vim script's &lt;code&gt;getqflist()&lt;/code&gt; and &lt;code&gt;setqflist()&lt;/code&gt; to pass searches to the existing quickfix list and populate a new one. See Kent's &lt;a href=&quot;https://stackoverflow.com/a/15409149/1052412&quot;&gt;Stack Overflow answer&lt;/a&gt; and resulting &lt;a href=&quot;https://github.com/sk1418/QFGrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;QFGrep on GitHub&lt;/a&gt;. With this script, you can perform your first grep/ack like normal, then use the following actions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;g&lt;/code&gt; input pattern to do further filtering&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;v&lt;/code&gt; input pattern to do further inverted filtering (like grep -v)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;r&lt;/code&gt; restore the Quickfix/location-list with original entries&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5871" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-01-04T23:19:55.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6028" PostTypeId="2" ParentId="6026" CreationDate="2016-01-02T10:04:02.800" Score="9" Body="&lt;p&gt;&lt;strong&gt;First question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Highlight definitions belong to your colorscheme. The fact that they are loaded for every buffer, no matter what their language, shouldn't be a problem at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to edit your colorscheme, you can put those highlight definitions in &lt;code&gt;plugin/myhighlights.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyHighlights()&#xA;    highlight ...&#xA;    highlight ...&#xA;endfunction&#xA;&#xA;augroup MyHighlights&#xA;    autocmd!&#xA;    autocmd ColorScheme * call MyHighlights()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Second question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your sample is exactly how you should do and how every syntax script does. This method lets the plugin developer define sane default without forcing specific colors down their user's throat.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-01-02T10:51:26.063" LastActivityDate="2016-01-02T10:51:26.063" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6029" PostTypeId="1" AcceptedAnswerId="6030" CreationDate="2016-01-02T16:09:32.697" Score="8" ViewCount="4733" Body="&lt;p&gt;I want to make a mapping that does the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F1&amp;gt; oHello, (user inputs their name. Ex. Jason). You have a very nice name.&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping should make a non-recursive map to F1 that starts a new line in insert mode. Next it types &quot;Hello, &quot; then waits for the user to type their name and then enter or some other signal command to say they are done. After that input the map moves forward and completes the statement with &quot;You have a very nice name.&quot; then exits insert mode with ESC.&lt;/p&gt;&#xA;" OwnerUserId="2695" LastActivityDate="2017-07-21T21:53:57.273" Title="How to wait for user input in the middle of a mapping?" Tags="|key-bindings|functions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6030" PostTypeId="2" ParentId="6029" CreationDate="2016-01-02T16:53:10.517" Score="10" Body="&lt;p&gt;You can use a mapping with the &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; flag to achieve this.  Mappings with the &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; flag will evaluate the right hand side of the mapping as an expression and then apply the result as key strokes.  This can be combined with the &lt;code&gt;input()&lt;/code&gt; function to achieve what you want.  Here is your mapping implemented with these features:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;F1&amp;gt; &quot;oHello, &quot; . input(&quot;Please give your name: &quot;) . &quot;. You have a very nice name.\&amp;lt;ESC&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a break down of what happens:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt;&lt;/code&gt; - create a non-recursive expr mapping&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;F1&amp;gt;&lt;/code&gt; - the key you press to activate the mapping&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;oHello, &quot; . input(&quot;Please give you name: &quot;) . &quot;. You have a very nice name.\&amp;lt;ESC&amp;gt;&quot;&lt;/code&gt; - concatenates the result of the input function with the rest of the mapping.  It is necessary to escape &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; because if you don't, it won't be interpreted as the escape key.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help input()&lt;/code&gt; and &lt;code&gt;:help :map-&amp;lt;expr&amp;gt;&lt;/code&gt; for more.&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2016-01-02T16:53:10.517" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6032" PostTypeId="1" AcceptedAnswerId="6034" CreationDate="2016-01-02T21:05:02.167" Score="6" ViewCount="1020" Body="&lt;p&gt;I want to use the combination &lt;code&gt;gggqG&lt;/code&gt; to go to the top of the file and format the whole file from there, so that it fits into my 80 col textwidth border.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I do, vim ignores my markdown headers. So I want basically to ignore all markdown headers for formatting. How can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;before&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#this is a h1&#xA;this is the text of the file i want &#xA;to reformat&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;after&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#this is a h1 this&#xA;is the text of the file&#xA;i want to reformat&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The word &lt;code&gt;this&lt;/code&gt; was moved to the header.&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="205" LastEditDate="2016-01-02T22:59:24.147" LastActivityDate="2016-01-06T15:35:53.720" Title="How do I make Vim respect Markdown headers when formating text?" Tags="|formatting|wrapping|filetype-markdown|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6033" PostTypeId="1" AcceptedAnswerId="6043" CreationDate="2016-01-02T21:31:32.990" Score="3" ViewCount="155" Body="&lt;p&gt;Let's say I have that text in my file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;At vero eos et accusamus et iusto odio&#xA;dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et &#xA;quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deser&#xA;unt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, &#xA;cum soluta nobis est eligendi optio cumque nihil impe&#xA;dit quo minus id quod maxime placeat (*|*)&#xA;facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to reformat the whole paragraph with &lt;code&gt;gq&lt;/code&gt; or sth similiar.&#xA;But I want to have a defined paragraph at &lt;code&gt;(*|*)&lt;/code&gt; . so Idon't want vim to reformat that line. How can I achieve that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; With a &quot;defined paragraph&quot; I mean sth like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;At vero eos et accusamus et iusto odi dignissimos ducimus qui blanditiis&#xA;praesentium voluptatum deleniti atque corrupti quos dolores et quas&#xA;molestias excepturi sint occaecati cupiditate non provident, similique sunt&#xA;in culpa qui officia deser unt mollitia animi, id est laborum et dolorum&#xA;fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero&#xA;tempore, cum soluta nobis est eligendi optio cumque nihil impe dit quo minus&#xA;id quod maxime placeat. (*|*)&#xA;facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. EDIT&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;formatoptions=a,t&lt;/code&gt;&#xA;I've read also &lt;code&gt;:h fo-table&lt;/code&gt;, but I couldn't find sth helpful yet.&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="2354" LastEditDate="2016-01-02T22:01:25.053" LastActivityDate="2016-01-05T23:27:15.340" Title="Make vim respect custom, defined paragraph when formatting text?" Tags="|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6034" PostTypeId="2" ParentId="6032" CreationDate="2016-01-02T23:31:22.203" Score="9" Body="&lt;p&gt;Since you don't have wrapping for comments enabled, the workaround in &lt;a href=&quot;https://stackoverflow.com/a/2686502/2072269&quot;&gt;this Stack Overflow post&lt;/a&gt; can be used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set comments+=n:#&#xA;set fo+=q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This adds &lt;code&gt;#&lt;/code&gt; as a comment marker (allowing &lt;code&gt;n&lt;/code&gt;esting, so that &lt;code&gt;##&lt;/code&gt;, &lt;code&gt;###&lt;/code&gt;, etc. also count).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suggest leaving a space after &lt;code&gt;#&lt;/code&gt; and using &lt;code&gt;nb:#&lt;/code&gt; - some Markdown parsers require a space after &lt;code&gt;#&lt;/code&gt;. The &lt;a href=&quot;http://spec.commonmark.org/0.22/#atx-headers&quot; rel=&quot;nofollow noreferrer&quot;&gt;CommonMark spec&lt;/a&gt; also supports this.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-01-02T23:31:22.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6035" PostTypeId="1" AcceptedAnswerId="6163" CreationDate="2016-01-03T17:55:25.703" Score="7" ViewCount="4229" Body="&lt;p&gt;I am trying to convert a String &lt;code&gt;'1'&lt;/code&gt; to a Number (int) &lt;code&gt;1&lt;/code&gt; in a vimL script. I have used the built-in command &lt;code&gt;str2nr()&lt;/code&gt; so far, however I was not able to write this in an elegant and effective way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I would like to catch invalid strings before attempting to convert them to an integer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&#xA;&lt;code&gt;'abc1'&lt;/code&gt; will return &lt;code&gt;0&lt;/code&gt; when run through the &lt;code&gt;str2nr()&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I probably need the right regex pattern to catch anything such as:&#xA;&lt;code&gt;'a'&lt;/code&gt;, &lt;code&gt;'a1b'&lt;/code&gt; &lt;code&gt;'7xy'&lt;/code&gt; as an illegal value and anything like: &lt;code&gt;'1'&lt;/code&gt; or &lt;code&gt;'7'&lt;/code&gt; as a legal value, thus filtering out all non-integer values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried something in the lines of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:value = 'abcX1'&#xA;let l:debug = l:value =~ '\[0-9]^\[A-Z]\^[a-z]\' ? &quot;YES&quot; : &quot;NO&quot;&#xA;echom l:debug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is expected to return a &lt;code&gt;NO&lt;/code&gt;, while this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:value = '7'&#xA;let l:debug = l:value =~ '\[0-9]^\[A-Z]\^[a-z]\' ? &quot;YES&quot; : &quot;NO&quot;&#xA;echom l:debug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is expected to return a &lt;code&gt;YES&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as I said, I am not good with regular expressions and probably building the wrong pattern up in those examples above as they are not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="205" LastEditDate="2016-01-03T19:39:48.293" LastActivityDate="2016-01-19T03:22:46.403" Title="How do I convert a String to a Number, catching invalid strings?" Tags="|vimscript|macvim|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6036" PostTypeId="1" AcceptedAnswerId="6037" CreationDate="2016-01-04T13:16:58.880" Score="4" ViewCount="1340" Body="&lt;p&gt;I have the following code in a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:TrimWhitespace() abort range&#xA;&#xA;    &quot; Save cursor position, because the following substitution will move it&#xA;    let save_cursor = getpos('.')&#xA;    &quot; Check whether a range was passed to the function   &#xA;    if exists('a:firstline')&#xA;        execute 'keepjumps keeppatterns ' .&#xA;                    \ a:firstline . ',' . a:lastline . 's/\v\s+$//e'&#xA;    else&#xA;        keepjumps keeppatterns %s/\v\s+$//e&#xA;    endif&#xA;    &quot; Put the cursor back where it was before the function was called&#xA;    call setpos('.', save_cursor)&#xA;&#xA;endfunction&#xA;command! -range=% TrimWhitespace &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call &amp;lt;SID&amp;gt;TrimWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It defines the command &lt;code&gt;:TrimWhitespace&lt;/code&gt; which calls a function with the same name, and removes trailing whitespace from the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command accepts a range, which by default is &lt;code&gt;1,$&lt;/code&gt; because it's defined with the argument &lt;code&gt;-range=%&lt;/code&gt;, so that it can be called like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:TrimWhitespace           removes all trailing whitespace&#xA;:'&amp;lt;,'&amp;gt;TrimWhitespace      only in visual selection&#xA;:10,20TrimWhitespace      only between lines 10 and 20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works as expected except for one thing: the cursor position is not saved and restored properly. No matter where the cursor is before the command is executed, it ends on the first line of the range.&lt;br&gt;&#xA;I think the reason why it doesn't work is because when the cursor position is saved, it's already too late, the function has already moved the cursor to the first line of the range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought maybe putting &lt;code&gt;normal ``&lt;/code&gt; before and after the save like this:&#xA;&lt;code&gt;&#xA;normal ``&#xA;let save_cursor = getpos('.')&#xA;normal ``&#xA;&lt;/code&gt;&#xA;... would work, but it doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution would be to save the position outside the function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% TrimWhitespace let g:save_cursor = getpos('.') |&#xA;            \ &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call &amp;lt;SID&amp;gt;TrimWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I don't like polluting the global namespace with a variable.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From inside the function, is there a way to save the position which the cursor had just before the function was called?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: following &lt;a href=&quot;https://vi.stackexchange.com/a/6037/4939&quot;&gt;romainl&lt;/a&gt;'s answer, I've changed the code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:TrimWhitespace() abort range&#xA;&#xA;    &quot; Check whether a range was passed to the function   &#xA;    if exists('a:firstline')&#xA;        execute 'keepjumps keeppatterns ' .&#xA;                    \ a:firstline . ',' . a:lastline . 's/\v\s+$//e'&#xA;    else&#xA;        keepjumps keeppatterns %s/\v\s+$//e&#xA;    endif&#xA;    &quot; Restore the state of the window (useful for not losing cursor position)&#xA;    call winrestview(b:winview)&#xA;&#xA;endfunction&#xA;command! -range=% TrimWhitespace let b:winview = winsaveview() |&#xA;            \ &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call &amp;lt;SID&amp;gt;TrimWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I completely forgot you could use a variable local to a buffer, plus &lt;code&gt;winsaveview()&lt;/code&gt; seems to save more than just the cursor position (first line of the window for example, that's nice).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2&lt;/strong&gt;: No need of a function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% TrimWhitespace let b:winview = winsaveview() |&#xA;            \ execute 'keepjumps keeppatterns ' .&#xA;            \ &amp;lt;line1&amp;gt; . ',' . &amp;lt;line2&amp;gt; . 's/\s\+$//e' |&#xA;            \ call winrestview(b:winview) |&#xA;            \ unlet b:winview&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-01-09T00:28:42.827" Title="How to save previous cursor position inside a function which has received a range?" Tags="|vimscript|cursor-movement|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6037" PostTypeId="2" ParentId="6036" CreationDate="2016-01-04T13:27:03.103" Score="5" Body="&lt;p&gt;This is how I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; reformat selection&#xA;command! -buffer -range=% Format let b:winview = winsaveview() |&#xA;  \ execute &amp;lt;line1&amp;gt; . &quot;,&quot; . &amp;lt;line2&amp;gt; . &quot;!js-beautify -f - -j -t -s &quot; . &amp;amp;shiftwidth |&#xA;  \ call winrestview(b:winview)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could probably &lt;code&gt;unlet b:winview&lt;/code&gt; afterwards.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-01-08T20:23:36.647" LastActivityDate="2016-01-08T20:23:36.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6038" PostTypeId="1" AcceptedAnswerId="6039" CreationDate="2016-01-04T22:24:30.160" Score="5" ViewCount="1354" Body="&lt;p&gt;When using the args list, Vim adds those arglist files to the buffer list.&lt;br&gt;&#xA;Once I'm finished with the argslist, I then have many unwanted argslist files in the bufferlist.&lt;br&gt;&#xA;They don't have a contiguous number sequence, so I cant just say, &lt;code&gt;:11,24 bd&lt;/code&gt;.&lt;br&gt;&#xA;Is it possible to remove these files from the bufferlist?, possibly using the same pattern I used to create the arglist? e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bd tests/unit/**/*.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2016-01-05T00:12:04.613" Title="How can I remove the argslist files from the buffer list?" Tags="|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6039" PostTypeId="2" ParentId="6038" CreationDate="2016-01-04T23:17:52.837" Score="7" Body="&lt;p&gt;Use &lt;code&gt;:argdo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdo bd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:argdo {cmd}&lt;/code&gt; will run command, &lt;code&gt;{cmd}&lt;/code&gt;, on every item in the argslist. In this case you use &lt;code&gt;:bdelete&lt;/code&gt; as the command to unload the buffer and delete it from the buffer list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see: &lt;code&gt;:h :argdo&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2016-01-05T00:12:04.613" LastActivityDate="2016-01-05T00:12:04.613" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6040" PostTypeId="1" AcceptedAnswerId="6041" CreationDate="2016-01-05T15:06:13.660" Score="20" ViewCount="3551" Body="&lt;p&gt;When I'm editing a Vim command, I would like to use &lt;a href=&quot;http://www.bigsmoke.us/readline/shortcuts&quot;&gt;the same shortcuts&lt;/a&gt; as in Bash and every other REPL: &lt;kbd&gt;M-b&lt;/kbd&gt; to go back a word, &lt;kbd&gt;M-Backspace&lt;/kbd&gt; to delete a previous word, &lt;kbd&gt;M-u&lt;/kbd&gt; to convert the word to uppercase, &lt;kbd&gt;C-k&lt;/kbd&gt; to cut until the end of the line, etc. I have been able to configure some of the commands, using &lt;code&gt;:cmap&lt;/code&gt;, but not all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin or setting which provides this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know about &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27cedit%27&quot;&gt;&lt;code&gt;cedit&lt;/code&gt;&lt;/a&gt;, but I find it cumbersome when all I need is to enter a quick command.&lt;/p&gt;&#xA;" OwnerUserId="5899" LastActivityDate="2022-05-22T17:20:57.990" Title="How can I use Readline shortcuts in the vim command line?" Tags="|key-bindings|command-line|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6041" PostTypeId="2" ParentId="6040" CreationDate="2016-01-05T16:01:41.140" Score="15" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a plugin or setting which provides this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, &lt;a href=&quot;https://github.com/tpope/vim-rsi&quot;&gt;rsi.vim plugin&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Readline mappings are provided in insert mode and command line mode. Normal mode is deliberately omitted.&lt;/li&gt;&#xA;  &lt;li&gt;Important Vim key bindings (like insert mode's C-n and C-p completion) are not overridden.&lt;/li&gt;&#xA;  &lt;li&gt;Meta key bindings are provided in a way that works in the terminal without the perils of remapping escape.&lt;/li&gt;&#xA;  &lt;li&gt;C-d, C-e, and C-f are mapped such that they perform the Readline behavior in the middle of the line and the Vim behavior at the end.&#xA;  (Think about it.)&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-01-05T16:01:41.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6042" PostTypeId="2" ParentId="6025" CreationDate="2016-01-05T17:47:16.710" Score="2" Body="&lt;p&gt;In similar situations I usually do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r! grep -R  'color:' . | grep -v '@'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, it reads the command's standard output to your buffer; we can edit, delete it etc. (and undoing if you are not happy)&lt;/p&gt;&#xA;" OwnerUserId="3002" LastEditorUserId="3002" LastEditDate="2016-01-13T11:14:17.203" LastActivityDate="2016-01-13T11:14:17.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6043" PostTypeId="2" ParentId="6033" CreationDate="2016-01-05T23:27:15.340" Score="3" Body="&lt;p&gt;Quick, easy way: Use visual select to select all lines in the paragraph, then press gq.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could create a custom mapping that does something similar:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;k {mz/\(\*\|\*\)&amp;lt;cr&amp;gt; Ea&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;'zgw}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use this at any point in your paragraph, this mapping will:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Go to start of the current paragraph (Assuming new lines demarcate paragraphs)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Mark current position&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\(\*\|\*\)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Search for your paragraph marker&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ea&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;insert a new line at your paragraph marker&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Return to mark&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gw}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Format to end of paragraph&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;At vero eos et accusamus et iusto odio&#xA;dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et &#xA;quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deser&#xA;unt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, &#xA;cum soluta nobis est eligendi optio cumque nihil impe&#xA;dit quo minus id quod maxime placeat (*|*)&#xA;facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis&#xA;praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias&#xA;excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui&#xA;officia deser unt mollitia animi, id est laborum et dolorum fuga. Et harum&#xA;quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta&#xA;nobis est eligendi optio cumque nihil impe dit quo minus id quod maxime placeat&#xA;(*|*)&#xA;&#xA;facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4932" LastActivityDate="2016-01-05T23:27:15.340" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6044" PostTypeId="2" ParentId="6032" CreationDate="2016-01-06T15:35:53.720" Score="5" Body="&lt;p&gt;If you're willing to change the way you write your Markdown slightly, you could fix this simply by introducing an extra blank line between your headings and the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# this is a h1&#xA;&#xA;this is the text of the file i want&#xA;to reformat&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is how I personally format my atx-style Markdown headers, anyway: I think it looks better and is easier to read.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2016-01-06T15:35:53.720" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6045" PostTypeId="1" AcceptedAnswerId="6046" CreationDate="2016-01-06T20:37:37.543" Score="3" ViewCount="1556" Body="&lt;p&gt;I would like to make some modification to the code of &lt;a href=&quot;https://github.com/tpope/vim-rsi&quot; rel=&quot;nofollow noreferrer&quot;&gt;this plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It adds / changes some default keybindings. Among them are &lt;code&gt;&amp;lt;C-b&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; which move the cursor one character to the left / right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is they &lt;a href=&quot;https://vi.stackexchange.com/questions/5913/why-is-the-previously-inserted-text-reset-after-using-an-arrow-key&quot;&gt;break the undo sequence&lt;/a&gt;, because they are mapped to &lt;code&gt;&amp;lt;Left&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Right&amp;gt;&lt;/code&gt;. The &lt;a href=&quot;https://vi.stackexchange.com/a/5914/4939&quot;&gt;solution&lt;/a&gt; is to prefix them with &lt;code&gt;&amp;lt;C-g&amp;gt;U&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I don't know in which version and which patch &lt;code&gt;&amp;lt;C-g&amp;gt;U&lt;/code&gt; appeared in Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;:helpgrep CTRL-G.*U&lt;/code&gt; which gave me 5 results in the quickfix list, but none of them gave me the info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have 2 questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I find precisely when &lt;code&gt;&amp;lt;C-g&amp;gt;U&lt;/code&gt; appeared in Vim?&lt;/li&gt;&#xA;&lt;li&gt;How can I reliably test in a script if vim supports it?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Let's say I find out that &lt;code&gt;&amp;lt;C-g&amp;gt;U&lt;/code&gt; appeared in Vim 7.4.567, would the following line be the proper way to test?:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if v:version &amp;gt; 704 || v:version == 704 &amp;amp;&amp;amp; has(&quot;patch567&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-01-06T21:33:25.540" Title="How to test if Vim supports &lt;C-g&gt;U?" Tags="|vimscript|key-bindings|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6046" PostTypeId="2" ParentId="6045" CreationDate="2016-01-06T21:00:27.867" Score="3" Body="&lt;p&gt;You can find all the patches &lt;a href=&quot;http://ftp.vim.org/pub/vim/patches/&quot; rel=&quot;nofollow&quot;&gt;on Vim's FTP server&lt;/a&gt;. &lt;code&gt;&amp;lt;C-g&amp;gt;U&lt;/code&gt; was added in &lt;a href=&quot;http://ftp.vim.org/pub/vim/patches/7.4/7.4.849&quot; rel=&quot;nofollow&quot;&gt;patch 7.4.849&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-01-06T21:00:27.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6047" PostTypeId="2" ParentId="6045" CreationDate="2016-01-06T21:33:25.540" Score="4" Body="&lt;p&gt;I simply use &lt;code&gt;has('patch-7.4.849')&lt;/code&gt; in lh-brackets. This is enough.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-01-06T21:33:25.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6048" PostTypeId="1" CreationDate="2016-01-07T05:57:19.677" Score="3" ViewCount="793" Body="&lt;p&gt;I wonder how one can add characters such as &lt;code&gt;&lt;/code&gt;(yes, space!), &lt;code&gt;'&lt;/code&gt; (single quote), &lt;code&gt;&quot;&lt;/code&gt; (double quote), etc., to &lt;code&gt;iskeyword&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not a theoretical exercise. The purpose is &lt;code&gt;iabbrev&lt;/code&gt; for these. I noticed that if you add a character to &lt;code&gt;iskeyword&lt;/code&gt;, then use it for &lt;code&gt;iabbrev&lt;/code&gt;, and then remove it from &lt;code&gt;iskeyword&lt;/code&gt;, the abbreviation still works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding space, would make it possible to e.g., to define two word abbreviations.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; I double checked. This works. Take the following as an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword+=^&#xA;set iskeyword&#xA;iabbrev ^0 ⁰&#xA;set iskeyword-=^&#xA;set iskeyword&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="205" LastEditDate="2016-01-08T10:38:26.757" LastActivityDate="2016-01-08T10:38:26.757" Title="Special characters in iskeywords" Tags="|abbreviations|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6049" PostTypeId="1" CreationDate="2016-01-07T07:10:34.133" Score="6" ViewCount="39" Body="&lt;p&gt;This is a feature in Eclipse that I would love to find a solution for in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have Vim set up with tw=80 so that the lines wrap at 80 columns. When I'm in the middle of a string, and the line breaks, I have to change some stuff around so that the once single-lined string is formatted to be a multiline string. I'd like that when the line wraps and I'm in the middle of the string, this &quot;conversion&quot; is done automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example in Python:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(^ represents the cursor)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_string = &quot;Hello my name is John Smith and...^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I press return:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_string = &quot;&quot;&quot;Hello my name is John Smith and...&#xA;            ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Or in C:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_string = &quot;Hello my name is John Smith and...^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I press return:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_string = &quot;Hello my name is John Smith and ...&quot; + &#xA;            &quot;^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Please let me know if there is anything I can clarify. If anyone can point me in the right direction that would be great!&lt;/p&gt;&#xA;" OwnerUserId="5932" LastActivityDate="2016-01-07T07:10:34.133" Title="Expand strings into multiline strings on line wrap" Tags="|wrapping|string-manipulation|" AnswerCount="0" CommentCount="4" ClosedDate="2016-01-13T14:52:47.463" ContentLicense="CC BY-SA 3.0" />
  <row Id="6050" PostTypeId="1" AcceptedAnswerId="6054" CreationDate="2016-01-07T12:00:56.380" Score="2" ViewCount="107" Body="&lt;p&gt;I've the following file (which is a simplification of the &lt;code&gt;hosts&lt;/code&gt; file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;126.0.0.1&#xA;127.0.0.1&#xA;128.0.0.1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'm trying to invoke the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex +g/127/d -cwq file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is supposed to remove lines consisting &lt;code&gt;127&lt;/code&gt;, then write and quit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works when using &lt;code&gt;vim -e&lt;/code&gt;, however it doesn't work using &lt;code&gt;ex&lt;/code&gt;/&lt;code&gt;vi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although when printing buffer after the change, it seems the change has been made:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex +&quot;g/127/d|%p&quot; file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it also displays the following warning:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Badly formed address&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm using original Ex v4.0 (gritter) 3/25/05. On OS X can be installed via &lt;code&gt;brew install ex-vi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why doesn't the above command work in &lt;code&gt;ex&lt;/code&gt; editor? And how do I make it work?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="51" LastEditDate="2016-01-11T19:50:29.393" LastActivityDate="2016-01-25T09:56:31.233" Title="Why aren't :g/X/d changes saved in Ex?" Tags="|global-command|ex-command|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6051" PostTypeId="1" AcceptedAnswerId="6052" CreationDate="2016-01-07T12:29:49.373" Score="3" ViewCount="1150" Body="&lt;p&gt;I'm using &lt;code&gt;cindent&lt;/code&gt; with C++ sources, and when I put some macro, which already ends with a semicolon, like Qt's &lt;code&gt;Q_OBJECT&lt;/code&gt;, &lt;code&gt;cindent&lt;/code&gt; doesn't understand it and makes an extra indentation on the next line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For emacs there &lt;a href=&quot;https://stackoverflow.com/a/19995905/673852&quot;&gt;seems to be an option&lt;/a&gt; to use/edit &lt;code&gt;c-macro-names-with-semicolon&lt;/code&gt; variable, which apparently would make the indenter understand these particular macros correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any similar option in Vim?&lt;/p&gt;&#xA;" OwnerUserId="1081" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-01-07T15:44:29.993" Title="How to make auto-indentation work correctly after macros ending with semicolons" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6052" PostTypeId="2" ParentId="6051" CreationDate="2016-01-07T15:38:16.900" Score="3" Body="&lt;p&gt;The &lt;code&gt;:help 'cindent'&lt;/code&gt; mentions &lt;code&gt;:help C-indenting&lt;/code&gt;, which contains the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Note that 'cindent' indenting does not work for every code scenario.  Vim&#xA;is not a C compiler: it does not recognize all syntax.  One requirement is&#xA;that toplevel functions have a '{' in the first column.  Otherwise they are&#xA;easily confused with declarations.&#xA;&#xA;These four options control C program indenting:&#xA;'cindent'       Enables Vim to perform C program indenting automatically.&#xA;'cinkeys'       Specifies which keys trigger reindenting in insert mode.&#xA;'cinoptions'    Sets your preferred indent style.&#xA;'cinwords'      Defines keywords that start an extra indent in the next line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to achieve the what you described it would be necessary to know how the macro would expanded; but this would require that Vim behaving as a &lt;em&gt;compiler&lt;/em&gt;, which, as noticed above, it does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there would be an option equivalent to &lt;code&gt;c-macro-names-with-semicolon&lt;/code&gt; it would be part of the &lt;code&gt;'cinoptions'&lt;/code&gt;. But if you check &lt;code&gt;:help cinoptions-values&lt;/code&gt; you will notice that despite it is possible to make a number of customizations, there is nothing similar to what you are looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you could try using &lt;code&gt;'indentexpr'&lt;/code&gt; along&lt;code&gt;'cindent'&lt;/code&gt;. Also from &lt;code&gt;:help C-indenting&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;There are in fact four main methods available for indentation, each one&#xA;overrides the previous if it is enabled, or non-empty for 'indentexpr':&#xA;'autoindent'    uses the indent from the previous line.&#xA;'smartindent'   is like 'autoindent' but also recognizes some C syntax to&#xA;        increase/reduce the indent where appropriate.&#xA;'cindent'   Works more cleverly than the other two and is configurable to&#xA;        different indenting styles.&#xA;'indentexpr'    The most flexible of all: Evaluates an expression to compute&#xA;        the indent of a line.  When non-empty this method overrides&#xA;        the other ones.  See |indent-expression|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By using &lt;code&gt;'indentexpr'&lt;/code&gt; you could use a custom function to analyze the contents of the macro (possibly using ctags) and them return the correct amount of indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are concerned with a few known macros you could try using the &quot;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=678&quot; rel=&quot;nofollow&quot;&gt;genindent.vim plugin: Generic function for indentexpr&lt;/a&gt;&quot; to make &lt;code&gt;'cindent'&lt;/code&gt; ignore lines referencing those macros.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-01-07T15:44:29.993" LastActivityDate="2016-01-07T15:44:29.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6053" PostTypeId="2" ParentId="6050" CreationDate="2016-01-07T17:22:44.850" Score="1" Body="&lt;p&gt;If it works with the Vim Ex mode but fails with &lt;a href=&quot;http://sourceforge.net/projects/ex-vi/&quot; rel=&quot;nofollow&quot;&gt;Ex v4.0 (gritter)&lt;/a&gt; them it is probably an issue with the latter application. I would suggest reporting on the project bug tracker, but it seems that it isn't supported anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the command works with &lt;code&gt;vim -e&lt;/code&gt;, wouldn't it be better to just stick with it?&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-01-07T17:22:44.850" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6054" PostTypeId="2" ParentId="6050" CreationDate="2016-01-07T17:52:18.063" Score="3" Body="&lt;p&gt;There are some problems here. First ex is made for interactive use. You can't use several -c commands. Second, and this is a specialty of the :g command, you can't separate several commands using the '|'. A &lt;code&gt;:g/127/d|wq&lt;/code&gt; command would write and quit after the first match)&#xA;This makes it effectively useless to add another command after the -c command. What works however is this traditional approach&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat &amp;lt;&amp;lt;EOF|ex /foobar&#xA;g/127/d&#xA;x&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also works with nvi. Though, I could make nvi also use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvi -e +'g/127/d|&#xA;wq' foobar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that is also not portable. (I don't know, why this works, however).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-01-07T17:52:18.063" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6056" PostTypeId="1" CreationDate="2016-01-07T18:43:43.083" Score="5" ViewCount="1873" Body="&lt;p&gt;I am in vim in the &lt;code&gt;.gitignore&lt;/code&gt; file. I now want to add a file path that already exists on the current dir, e.g.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;./app/poit/narf/auth.json&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to type it though, I want to navigate to that file somehow with tabcompletion in vim and then insert its filename in the &lt;code&gt;.gitignore&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I know I can do is open the editor command&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:e app/poit/narf/auth.json&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I can have tabcompletion here. Yet this only gets me the text in the command window, and now I have to yank it somehow inside the buffer. I am also looking more for a more fit solution.&lt;/p&gt;&#xA;" OwnerUserId="5449" LastActivityDate="2016-01-07T18:52:15.247" Title="How to insert a file path with tab- or autocompletion relative to the current file's dir?" Tags="|autocompletion|filesystem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6057" PostTypeId="2" ParentId="6056" CreationDate="2016-01-07T18:52:15.247" Score="9" Body="&lt;p&gt;You can use vim's file name completion feature for this.  To use it, press &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;f&lt;/kbd&gt; in insert mode.  For more on this, see &lt;code&gt;:help compl-filename&lt;/code&gt;.  Do note that it isn't recursive, so you must complete the path level by level.  &lt;em&gt;(first &lt;code&gt;app/&lt;/code&gt;, then &lt;code&gt;poit/&lt;/code&gt;, etc.)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2016-01-07T18:52:15.247" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6059" PostTypeId="1" CreationDate="2016-01-08T01:49:20.547" Score="2" ViewCount="1040" Body="&lt;p&gt;Has anyone successfully configured a postgres database in vim's dbext ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see only configurations for mysql or sqllite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I included the following code in .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; let g:dbext_default_profile_mydb='type=pgsql:user=mydb:mydb=localhost:dsnname=mydb:dbname=mydb'&#xA; let g:dbext_default_profile='mydb'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;mydb is the database, role, username and password for my database.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when I list connections I got this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dbext:Unknown parameter: POSTGRESQL_bin&#xA;dbext:Unknown parameter: POSTGRESQL_cmd_header&#xA;dbext:Unknown parameter: POSTGRESQL_cmd_terminator&#xA;dbext:Unknown parameter: POSTGRESQL_cmd_options&#xA;dbext:Unknown parameter: POSTGRESQL_on_error&#xA;dbext:Unknown parameter: utilities&#xA;dbext:Unknown parameter: POSTGRESQL_cmd_terminator&#xA;dbext:A valid database type must be chosen    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can anyone show me the correct line to put in .vimrc for accessing a postgresql database with dbext please ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if I use DBPromptForBufferParameters command it works ok.&lt;/p&gt;&#xA;" OwnerUserId="5944" LastActivityDate="2016-01-08T02:01:58.537" Title="Vim's dbext with postgres" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6060" PostTypeId="2" ParentId="6059" CreationDate="2016-01-08T02:01:58.537" Score="2" Body="&lt;p&gt;This is the correct configuration for using postgres with dbext. Put these lines in your .vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; let g:dbext_default_profile_myDB='type=pgsql:host=localhost:user=myUser:dsnname=myDB:dbname=myDB:passwd=myPassword'&#xA; let g:dbext_default_profile='myDB'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5944" LastActivityDate="2016-01-08T02:01:58.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6061" PostTypeId="1" AcceptedAnswerId="6135" CreationDate="2016-01-08T05:29:14.297" Score="42" ViewCount="8746" Body="&lt;p&gt;Is there a specific historical reason for this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt; — (you can skip this part if you already understand the question.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As intermediate/advanced &lt;code&gt;vi&lt;/code&gt; users will know, &lt;code&gt;y&lt;/code&gt; is the &quot;yank&quot; command—it yanks (copies) the text specified by the following movement command.*  Thus &lt;code&gt;ye&lt;/code&gt; yanks to the end of the word, &lt;code&gt;y0&lt;/code&gt; yanks from cursor position to the beginning of the line, &lt;code&gt;y_&lt;/code&gt; yanks the entire current line, &lt;code&gt;y$&lt;/code&gt; yanks from cursor position to the end of the current line, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;d&lt;/code&gt; (delete) command and the &lt;code&gt;c&lt;/code&gt; (change) command can both be used with all of these motions as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;dd&lt;/code&gt; is a synonym for &lt;code&gt;d_&lt;/code&gt; and deletes the entire current line.  Likewise, &lt;code&gt;cc&lt;/code&gt; is a synonym for &lt;code&gt;c_&lt;/code&gt; and will &lt;em&gt;change&lt;/em&gt; the current line (i.e. it will delete all the text and put you in insert mode at the beginning of the line).**&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;yank&quot; command follows this convention; &lt;code&gt;yy&lt;/code&gt; will yank the entire current line just like &lt;code&gt;y_&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is another set of synonyms: &lt;code&gt;D&lt;/code&gt; is a synonym for &lt;code&gt;d$&lt;/code&gt; and will delete from the cursor position to the end of the line.  &lt;code&gt;C&lt;/code&gt; is a synonym for &lt;code&gt;c$&lt;/code&gt; and will change the text from the cursor position to the end of the line, placing you in insert mode to type the new text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, &lt;strong&gt;&lt;code&gt;Y&lt;/code&gt; is &lt;em&gt;another&lt;/em&gt; synonym for &lt;code&gt;yy&lt;/code&gt; or &lt;code&gt;y_&lt;/code&gt; and will yank the &lt;em&gt;entire&lt;/em&gt; line&lt;/strong&gt;, not just from the cursor to the end of the line as you would expect from the &lt;code&gt;C&lt;/code&gt; and &lt;code&gt;D&lt;/code&gt; patterns.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I understand that in Vim it was kept this way to preserve backward compatibility with &lt;code&gt;vi&lt;/code&gt;, as is mentioned in the Vim help under &lt;code&gt;:help Y&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you like &quot;Y&quot; to work from the cursor to the end of line (which is more logical, but not Vi-compatible) use &quot;:map Y y$&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So this is a holdover from &lt;code&gt;vi&lt;/code&gt;.  Fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, &lt;strong&gt;why was the command designed that way in the first place?  Was there any logic to it ever?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;*Specifically it places the text in register 0 and points the unnamed register at register 0.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;**Although it's not relevant to my question, &lt;code&gt;S&lt;/code&gt; is another synonym for &lt;code&gt;cc&lt;/code&gt; or &lt;code&gt;c_&lt;/code&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2016-06-20T20:58:30.023" Title="Why is Y a synonym for yy instead of y$?" Tags="|key-bindings|cut-copy-paste|history-of|original-vi|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6063" PostTypeId="1" AcceptedAnswerId="6064" CreationDate="2016-01-08T08:45:23.070" Score="10" ViewCount="362" Body="&lt;p&gt;Is there any alternative in vim search and replace for strings, than having to escape every special character in string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, If I want to match following string and replace with something&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ERROR] Login unsucessful&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I have to do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\[ERROR\]\ Login\ unsucessful/something/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it becomes lot more uglier and painful for complex strings containing lot of special characters&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&quot;[ERROR] Login unsucessful&quot;/something/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which would avoid all escaping.&#xA;Is there any feature like this?&lt;/p&gt;&#xA;" OwnerUserId="5019" LastEditorUserId="5019" LastEditDate="2016-01-08T12:45:28.880" LastActivityDate="2016-01-22T15:01:31.950" Title="Alternative to escape slashes in search and replace for long strings" Tags="|search|regular-expression|replace|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6064" PostTypeId="2" ParentId="6063" CreationDate="2016-01-08T09:11:18.450" Score="16" Body="&lt;p&gt;You can use the &lt;code&gt;very-nomagic&lt;/code&gt; switch. See &lt;code&gt;:h \V&lt;/code&gt; for details. This would give you &lt;code&gt;%s/\V[ERROR] Login unsuccessful/something/g&lt;/code&gt;. There is also the &lt;code&gt;nomagic&lt;/code&gt; switch &lt;code&gt;\M&lt;/code&gt;, which is a lighter version of &lt;code&gt;\V&lt;/code&gt; and does not seem to be widely used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that you don't have to escape spaces as you do in your example, even when not using &lt;code&gt;\V&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastActivityDate="2016-01-08T09:11:18.450" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6065" PostTypeId="2" ParentId="6063" CreationDate="2016-01-08T09:11:42.240" Score="7" Body="&lt;p&gt;You don't need to escape spaces. So this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\[ERROR\]\ Login\ unsucessful/something/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should actually be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\[ERROR\] Login unsucessful/something/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And, of course, you can enable &lt;em&gt;very nomagic&lt;/em&gt; &quot;mode&quot; to make those special characters less special:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\V[ERROR] Login unsucessful/something/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help /magic&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-01-22T15:01:31.950" LastActivityDate="2016-01-22T15:01:31.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6066" PostTypeId="1" AcceptedAnswerId="6067" CreationDate="2016-01-08T09:42:28.293" Score="4" ViewCount="187" Body="&lt;p&gt;Is it possible to put vim comments in lines that include &lt;code&gt;iabbrev&lt;/code&gt;, as in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev hte the &quot; common typo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="205" LastEditDate="2016-01-08T10:09:41.027" LastActivityDate="2016-01-08T10:41:44.903" Title="Is it possible to put vim comments in lines that include `iabbrev`" Tags="|comments|abbreviations|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6067" PostTypeId="2" ParentId="6066" CreationDate="2016-01-08T10:08:22.233" Score="6" Body="&lt;p&gt;As explained in &lt;a href=&quot;http://vimhelp.appspot.com/usr_40.txt.html#40.1&quot;&gt;&lt;code&gt;:help 40.1&lt;/code&gt;&lt;/a&gt; (&lt;code&gt;SPECIAL CHARACTERS&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;It is not possible to put a comment directly after a mapping, because the &quot;&#xA;character is considered to be part of the mapping.  You can use |&quot;, this&#xA;starts a new, empty command with a comment.  Example: &#xA;&#xA;        :map &amp;lt;Space&amp;gt; W|     &quot; Use spacebar to move forward a word&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, you can use &lt;code&gt;|&lt;/code&gt; in order to indicate the end of the abbreviation/mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev hte the| &quot; common typo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="205" LastEditDate="2016-01-08T10:41:44.903" LastActivityDate="2016-01-08T10:41:44.903" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6069" PostTypeId="2" ParentId="6048" CreationDate="2016-01-08T10:25:40.000" Score="3" Body="&lt;p&gt;Your example already works, without messing with the &lt;code&gt;'iskeyword'&lt;/code&gt; setting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, because your example is an abbreviation of type end-id as can be read at &lt;code&gt;:h abbreviations&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example, that would only work, if you change your &lt;code&gt;'iskeyword'&lt;/code&gt; setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set isk+=,&#xA;:iabbrev abc,def ABCDEF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now enter insert mode and type &quot;abc,def&quot; and see how this is changed to ABCDEF. Now reset your iskeyword setting: &lt;code&gt;:set isk&amp;amp;vim&lt;/code&gt; and enter again &quot;abc,def&quot; and note that the abbreviation does not work and if you enter the &lt;code&gt;:iabbrev&lt;/code&gt; command again, you will see an error E474 invalid argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: In general it is not recommended to change the &lt;code&gt;'iskeyword'&lt;/code&gt; setting, because it messes with too many different things (motions, syntax highlighting, regular expressions).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-01-08T10:25:40.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6070" PostTypeId="1" CreationDate="2016-01-08T17:45:01.120" Score="11" ViewCount="3429" Body="&lt;p&gt;I'm trying to make Vim wait after the leader key indefinitely without messing with the &lt;code&gt;timeoutlen&lt;/code&gt; of other keys.&#xA;Currently I have this lines in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader=&quot; &quot;&#xA;set timeoutlen=2000 ttimeoutlen=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;ttimeoutlen&lt;/code&gt; make commands such as &lt;code&gt;ciw&lt;/code&gt; last permanently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Spacemacs plugin for Emacs which has a nice set of default configurations, one of these is that the leader key waits indefinitely. Can I do this on Vim by any other way than changing the &lt;code&gt;timeoutlen&lt;/code&gt; values?&lt;/p&gt;&#xA;" OwnerUserId="2131" LastEditorUserId="205" LastEditDate="2016-01-08T20:39:28.323" LastActivityDate="2016-01-10T08:25:01.490" Title="How do I make Vim wait indefinitely after leader key has been pressed?" Tags="|vimrc|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6071" PostTypeId="1" AcceptedAnswerId="6074" CreationDate="2016-01-08T18:31:31.377" Score="7" ViewCount="312" Body="&lt;p&gt;&lt;code&gt;:help section&lt;/code&gt; states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The &quot;]&quot; and &quot;[&quot; commands stop at the '{' or '}' in the first column.  This is&#xA;  useful to find the start or end of a function in a C program.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is it possible to change the &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; commands to jump to a different character or pattern. For example in Markdown, I would like sections defined as titles, lines beginning with &lt;code&gt;#&lt;/code&gt; aka the pattern &lt;code&gt;^#&lt;/code&gt;. Similarly in Haskell, I would like it to jump to the next/previous type definition (line containing &lt;code&gt;::&lt;/code&gt;). Both would be set in their respective &lt;code&gt;ftplugin&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried using &lt;code&gt;map ]] /^#&amp;lt;CR&amp;gt;w&lt;/code&gt; but this does not seem to work as expected and leaves text highlighted. It seems like there would be a better way to achieve this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible and if so, how would I achieve this?&lt;/p&gt;&#xA;" OwnerUserId="5952" LastActivityDate="2016-01-08T20:27:06.143" Title="Changing how the jump section `[` and `]` command works" Tags="|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6072" PostTypeId="1" AcceptedAnswerId="6073" CreationDate="2016-01-08T18:41:09.150" Score="4" ViewCount="430" Body="&lt;p&gt;Let's say I've got the word &lt;code&gt;foo&lt;/code&gt; in a file, I copy it in register &lt;code&gt;a&lt;/code&gt; (&lt;code&gt;&quot;ayiw&lt;/code&gt;) and I define the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;F3&amp;gt; &quot;&amp;lt;C-r&amp;gt;a&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I hit &lt;code&gt;F3&lt;/code&gt; while in insert mode it will paste the content of register &lt;code&gt;a&lt;/code&gt; (&lt;code&gt;foo&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, let's say I define the following function, and the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SomeFunction()&#xA;      return &quot;&amp;lt;C-R&amp;gt;a&quot;&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;F3&amp;gt; SomeFunction()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I hit &lt;code&gt;F3&lt;/code&gt;, instead of inserting the &lt;code&gt;a&lt;/code&gt; register (&lt;code&gt;foo&lt;/code&gt;), it inserts literally &lt;code&gt;&amp;lt;C-R&amp;gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a solution, which involves changing the function and using the unicode for &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;.&lt;br&gt;&#xA;I think &lt;code&gt;u12&lt;/code&gt; is the unicode for the control character &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;, because when you insert it literally (&lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;) and you hit &lt;code&gt;ga&lt;/code&gt; on it, the output is &lt;code&gt;&amp;lt;^R&amp;gt;  18,  Hex 12,  Octal 022&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the following function and mapping works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SomeFunction()&#xA;      return &quot;\u12&quot; . 'a'&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;F3&amp;gt; SomeFunction()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I hit &lt;code&gt;F3&lt;/code&gt; it inserts the content of the &lt;code&gt;a&lt;/code&gt; register as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But why do I have to use unicode when the control character is returned by a function instead of being directly passed as an argument to &lt;code&gt;:inoremap&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: After reading &lt;a href=&quot;https://vi.stackexchange.com/a/6073/4939&quot;&gt;Christian Brabandt&lt;/a&gt;'s answer, I've realised that my solution was too complex.&lt;br&gt;&#xA;As he has well explained, no need of unicode, a control character must simply be escaped in a string, so the proper way to write the function would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SomeFunction()&#xA;      return &quot;\&amp;lt;C-R&amp;gt;a&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And yet I'm still confused, if I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;F3&amp;gt; &quot;&amp;lt;C-r&amp;gt;a&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works as expected. So why do I need to escape &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; inside the function but not when it's directly passed as an argument to &lt;code&gt;:inoremap&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that, I think I have an explanation. The Ex commands which define a mapping like &lt;code&gt;:inoremap&lt;/code&gt;, &lt;code&gt;:nnoremap&lt;/code&gt;... don't need the control characters to be escaped. For example, you don't write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap \&amp;lt;F3&amp;gt; :call SomeFunction\&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F3&amp;gt; :call SomeFunction&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why? Probably because these commands are special, they already interpret correctly &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; as a carriage return and not as 4 literal characters (same thing for &lt;code&gt;&amp;lt;F3&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, going back to my previous function, why do I need to escape &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt;?&lt;br&gt;&#xA;Because, when I hit &lt;code&gt;&amp;lt;F3&amp;gt;&lt;/code&gt;, &lt;code&gt;:inoremap&lt;/code&gt; evaluates the right-hand-side of the mapping as a call to the function &lt;code&gt;SomeFunction()&lt;/code&gt;... and that's it. It doesn't interpret anything after that, it just types the output literally.&lt;br&gt;&#xA;The output of &lt;code&gt;SomeFunction()&lt;/code&gt; is not interpreted by &lt;code&gt;:inoremap&lt;/code&gt;, so this time you have to escape the control character so that Vim (not &lt;code&gt;:inoremap&lt;/code&gt;) interprets &lt;code&gt;\&amp;lt;C-r&amp;gt;&lt;/code&gt; as &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;r&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-01-08T21:18:21.183" Title="Why do I need to use unicode for a control character in a mapping using &lt;expr&gt; and a function?" Tags="|vimscript|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6073" PostTypeId="2" ParentId="6072" CreationDate="2016-01-08T18:48:13.413" Score="4" Body="&lt;p&gt;If you want to have Keys returned by mapping expressions, you have to escape them as mentioned in the help &lt;code&gt;:h expr-quote&lt;/code&gt;. So your Function needs to return &lt;code&gt;&quot;\&amp;lt;c-r&amp;gt;a&quot;&lt;/code&gt; (note the backslash), else you couldn't let the function return the string &lt;code&gt;&quot;&amp;lt;c-r&amp;gt;a&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-01-08T18:48:13.413" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6074" PostTypeId="2" ParentId="6071" CreationDate="2016-01-08T19:57:52.407" Score="8" Body="&lt;p&gt;I stole and renamed the function below from &lt;code&gt;$VIMRUNTIME/ftplugin/python.vim&lt;/code&gt;&#xA;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomJump(motion) range&#xA;    let cnt = v:count1&#xA;    let save = @/&#xA;    mark '&#xA;    while cnt &amp;gt; 0&#xA;        silent! execute a:motion&#xA;        let cnt = cnt - 1&#xA;    endwhile&#xA;    call histdel('/', -1)&#xA;    let @/ = save&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I use it like this in &lt;code&gt;after/ftplugin/javascript.vim&lt;/code&gt; to jump from function definition to function definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; ]] :call CustomJump('/function')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;buffer&amp;gt; [[ :call CustomJump('?function')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could use it like this for markdown:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; ]] :call CustomJump('/^#')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;buffer&amp;gt; [[ :call CustomJump('?^#')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or like that for haskell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; ]] :call CustomJump('/::')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;buffer&amp;gt; [[ :call CustomJump('?::')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But don't forget the awesome &lt;code&gt;:global&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/func/#&#xA;:g/^#/#&#xA;:g/::/#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-01-08T19:57:52.407" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6075" PostTypeId="2" ParentId="6071" CreationDate="2016-01-08T20:27:06.143" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/gabrielelana/vim-markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-markdown&lt;/code&gt; plugin&lt;/a&gt; has &lt;a href=&quot;https://github.com/gabrielelana/vim-markdown/blob/master/ftplugin/markdown.vim#L95&quot; rel=&quot;nofollow noreferrer&quot;&gt;a function&lt;/a&gt; for this in Markdown files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:JumpToHeader(forward, visual)&#xA;  let pattern = '\v^#{1,6}.*$|^.+\n%(\-+|\=+)$'&#xA;  if a:visual&#xA;    normal! gv&#xA;  endif&#xA;  if a:forward&#xA;    let direction = '/'&#xA;  else&#xA;    let direction = '?'&#xA;  endif&#xA;  execute 'silent normal! ' . direction . pattern . &quot;\n&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It matches both &lt;a href=&quot;http://spec.commonmark.org/0.22/#atx-headers&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATX&lt;/a&gt; and &lt;a href=&quot;http://spec.commonmark.org/0.22/#setext-header&quot; rel=&quot;nofollow noreferrer&quot;&gt;setext&lt;/a&gt; headers (&lt;code&gt;# foo&lt;/code&gt; as well as &lt;code&gt;foo&lt;/code&gt; with &lt;code&gt;---&lt;/code&gt; below it). The function is &lt;a href=&quot;https://github.com/gabrielelana/vim-markdown/blob/master/ftplugin/markdown.vim#L144&quot; rel=&quot;nofollow noreferrer&quot;&gt;mapped by default&lt;/a&gt; to &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt; by the plugin. However, it could benefit from a call to &lt;code&gt;histdel()&lt;/code&gt; (as seen in &lt;a href=&quot;https://vi.stackexchange.com/a/6074/205&quot;&gt;romainl's answer&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-01-08T20:27:06.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6076" PostTypeId="2" ParentId="6070" CreationDate="2016-01-08T20:54:46.780" Score="4" Body="&lt;p&gt;Here is a dirty workaround you could consider:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Increase timeoutlen when &amp;lt;Leader&amp;gt; is pressed&#xA;&quot; Only one of these lines is needed.  I am not sure which is most recommended.&#xA;&quot;nmap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt; :&amp;lt;C-U&amp;gt;set timeoutlen=99999 ttimeoutlen=99999&amp;lt;CR&amp;gt;&amp;lt;Leader&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt; :&amp;lt;C-U&amp;gt;set timeoutlen=99999 ttimeoutlen=99999&amp;lt;CR&amp;gt;:call feedkeys('&amp;lt;Leader&amp;gt;')&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Reset timeoutline to normal soon afterwards&#xA;autocmd CursorMoved * set timeoutlen=2000 ttimeoutlen=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The CursorMoved event is not ideal but it usually gets triggered sooner or later.  You may be able to find other events or mappings to reset the values in those cases when you get stuck on the long timeout.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2016-01-10T08:25:01.490" LastActivityDate="2016-01-10T08:25:01.490" CommentCount="0" CommunityOwnedDate="2016-01-08T20:54:46.780" ContentLicense="CC BY-SA 3.0" />
  <row Id="6077" PostTypeId="2" ParentId="6070" CreationDate="2016-01-08T21:36:57.480" Score="3" Body="&lt;p&gt;If you do &lt;code&gt;:set notimeout nottimeout&lt;/code&gt; mappings won't time out. This is all explained very well at &lt;code&gt;:h 'timeout'&lt;/code&gt;&#xA;You might try other combinations of those two mappings. &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-01-08T21:36:57.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6078" PostTypeId="1" AcceptedAnswerId="6080" CreationDate="2016-01-08T22:13:08.817" Score="4" ViewCount="505" Body="&lt;p&gt;When I do a visual block insert with &lt;code&gt;virtualedit=all&lt;/code&gt; I want to insert into all selected lines regardless of what text is already in those lines. Instead the behavior I get is that the line where I begin the visual block is always inserted into and the other highlighted lines are inserted into only if they already contain text in the selected column or the immediately preceding column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, with &lt;code&gt;_&lt;/code&gt; as the cursor, and the following text that contains no trailing spaces (the cursor is outside the text):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc  _&#xA;abcd&#xA;abcde&#xA;ab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if I begin a visual block where the cursor is and continue down to the last column, then block insert foo, and then press escape I end up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc _foo&#xA;abcd&#xA;abcdefoo&#xA;ab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead, I want this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc _foo&#xA;abcd foo&#xA;abcdefoo&#xA;ab   foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="268" LastActivityDate="2016-01-10T15:02:40.347" Title="Visual block insert into multiple areas with no text with virtualedit=all" Tags="|visual-mode|virtualedit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6079" PostTypeId="2" ParentId="6063" CreationDate="2016-01-08T22:24:10.330" Score="2" Body="&lt;p&gt;In addition to the &lt;em&gt;nomagic&lt;/em&gt; flags mention in other answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is often the case that you don't need to be precise in your search string&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to match &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ERROR] Login unsucessful&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could use the expression&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.ERROR. Login unsucessful&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, you have to know that your data won't contain other strings, differing from your intended target but matching the expression.&lt;/p&gt;&#xA;" OwnerUserId="5955" LastActivityDate="2016-01-08T22:24:10.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6080" PostTypeId="2" ParentId="6078" CreationDate="2016-01-08T22:53:00.910" Score="6" Body="&lt;p&gt;This is due to the behaviour of blockwise operators. In this particular example, you need to append the text. That is, with the visual block selection, here marked with &lt;code&gt;_&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc  _&#xA;abcd _&#xA;abcde_&#xA;ab   _&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can type &lt;code&gt;Afoo&amp;lt;esc&amp;gt;&lt;/code&gt; to get the desired output, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc _foo&#xA;abcd foo&#xA;abcdefoo&#xA;ab   foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With visual block insert, see &lt;code&gt;:h v_b_I&lt;/code&gt;, you will only insert text if the line extends into the block. However, with visual block append, see &lt;code&gt;:h v_b_A&lt;/code&gt;, you will append to every line, even if the lines do not extend into the block. In the latter case, whitespace will be added as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see &lt;code&gt;:h blockwise-operators&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2016-01-10T15:02:40.347" LastActivityDate="2016-01-10T15:02:40.347" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6081" PostTypeId="1" CreationDate="2016-01-10T08:17:37.927" Score="4" ViewCount="170" Body="&lt;p&gt;Sadly over time a few of my mappings have ended up overlapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I toggle wrapping with &lt;kbd&gt;\w&lt;/kbd&gt; but I later introduced &lt;a href=&quot;https://github.com/joeytwiddle/rc_files/blob/master/.vim/plugin/change_with.vim&quot; rel=&quot;nofollow&quot;&gt;a mapping&lt;/a&gt; on &lt;kbd&gt;\wi&lt;/kbd&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a result, when I press &lt;kbd&gt;\w&lt;/kbd&gt;, Vim waits for some time to see if I will follow it with &lt;kbd&gt;i&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I usually don't want to wait, I will often hit &lt;kbd&gt;Space&lt;/kbd&gt; to force Vim to recognise that no &lt;kbd&gt;i&lt;/kbd&gt; is forthcoming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But of course hitting &lt;kbd&gt;Space&lt;/kbd&gt; has the minor side effect of pushing me forwards one character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;strong&gt;is there a better keystroke&lt;/strong&gt; I could use than &lt;kbd&gt;Space&lt;/kbd&gt; which would result in no action being taken?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I accept that this might be a two-keystroke operation.  An example could be &lt;kbd&gt;y Escape&lt;/kbd&gt;, which I assume does nothing.  But a better choice would be easier to hit (&lt;kbd&gt;Escape&lt;/kbd&gt; is a long way to reach) and possibly use a meta combination (&lt;kbd&gt;Ctrl-C&lt;/kbd&gt; is faster/easier to perform than &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt;, isn't it?).&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2016-01-10T08:26:37.050" LastActivityDate="2016-01-10T19:18:53.070" Title="Is there a no-op normal mode keystroke that I can use to positively terminate a timeout?" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6082" PostTypeId="2" ParentId="6081" CreationDate="2016-01-10T08:54:10.080" Score="6" Body="&lt;p&gt;It seems any key you map to &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt; correctly terminates the mapping, without doing anything else. With&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set notimeout&#xA;inoremap w foo&#xA;inoremap ww bar&#xA;inoremap &amp;lt;space&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;w&amp;lt;space&amp;gt;&lt;/code&gt; to insert foo, and &lt;code&gt;ww&lt;/code&gt; to insert bar. Of course, this would be the same as mapping &lt;code&gt;w&amp;lt;space&amp;gt;&lt;/code&gt; in the first place, expect for the fact the &quot;mapping-completion-key&quot; is generic.&lt;/p&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2016-01-10T08:54:10.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6083" PostTypeId="1" AcceptedAnswerId="6085" CreationDate="2016-01-10T09:47:15.250" Score="5" ViewCount="8873" Body="&lt;p&gt;I want to find all the characters upto the first occurence of the character &quot;/&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;/.\{-}\/ &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;but this included every character upto the last occurrence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for example, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;test/path/to/something&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;matched &quot;test/path/to/&quot; but I want it to only match &quot;test/&quot;&lt;/p&gt;&#xA;" OwnerUserId="5964" LastEditorUserId="5964" LastEditDate="2016-01-10T10:41:53.887" LastActivityDate="2020-11-07T01:24:25.880" Title="Match everything before first occurrence of a character" Tags="|search|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6084" PostTypeId="2" ParentId="6083" CreationDate="2016-01-10T11:15:21.927" Score="4" Body="&lt;p&gt;Vim has start and end anchors (&lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; respectively) that you can use. In this case, the &lt;code&gt;\ze&lt;/code&gt; anchor will help match what you're looking for:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;foo\ze\/&lt;/code&gt; matches the &quot;foo&quot; in &quot;foo/bar/baz&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this example, it stops the search the match after it finds &quot;foo&quot; followed by a &quot;/&quot; but does not include the &quot;/&quot; since we put the anchor before it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read the &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5Cze&quot; rel=&quot;nofollow&quot;&gt;help&lt;/a&gt; on the &lt;code&gt;\ze&lt;/code&gt; anchor for more information:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\ze        Matches at any position, and sets the end of the match there: The&#xA;           previous char is the last char of the whole match. |/zero-width|&#xA;           Can be used multiple times, the last one encountered in a matching&#xA;           branch is used.&#xA;&#xA;           Example: &quot;end\ze\(if\|for\)&quot; matches the &quot;end&quot; in &quot;endif&quot; and &quot;endfor&quot;.&#xA;           This cannot be followed by a multi. |E888|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="246" LastActivityDate="2016-01-10T11:15:21.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6085" PostTypeId="2" ParentId="6083" CreationDate="2016-01-10T11:34:08.417" Score="6" Body="&lt;p&gt;It doesn't actually match &lt;code&gt;test/path/to/&lt;/code&gt; -- it matches three times: &lt;code&gt;test/&lt;/code&gt;, &lt;code&gt;path/&lt;/code&gt; and &lt;code&gt;to/&lt;/code&gt;. If you want to match only match the first one, the easiest way is to anchor the pattern to something, for example, beginning of line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^.\{-}\/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works if you really want to match everything before. In practice, you might want to only match what is e.g. separated by whitespace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\s\zs\S\{-}\/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2016-01-10T11:34:08.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6086" PostTypeId="1" AcceptedAnswerId="6087" CreationDate="2016-01-10T11:38:44.423" Score="6" ViewCount="147" Body="&lt;p&gt;I am looking for a way to convert one word to another while &quot;capturing&quot; the case of the match that is substituted. An example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the text:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Begin the beginning&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now I want to convert this to&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;End the ending&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To do so I need a command like the one below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/([Bb]egin/ [CASE OF CAPTURE][Ee]nd/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then with a correctly working &lt;code&gt;[CASE OF CAPTURE][Ee]&lt;/code&gt; part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do we get the case of the capture (being upper or lowercase begin) and substitute with same (upper or lowercase end)?&lt;/p&gt;&#xA;" OwnerUserId="5011" LastActivityDate="2016-01-10T12:50:25.000" Title="Convert word to another substituting case (upper or lower) with same case" Tags="|regular-expression|substitute|letter-case|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6087" PostTypeId="2" ParentId="6086" CreationDate="2016-01-10T12:50:25.000" Score="5" Body="&lt;p&gt;You can do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\([Bb]\)egin/\=printf(&quot;%snd&quot;, submatch(1)==#'B'?'E':'e')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This checks in the replacement part of the &lt;code&gt;:s&lt;/code&gt; command, what the case of the first subgroup was and either returns an upper 'e' or a lower 'e'.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-01-10T12:50:25.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6088" PostTypeId="1" CreationDate="2016-01-10T15:48:01.570" Score="15" ViewCount="385" Body="&lt;p&gt;I've mapped &lt;code&gt;&amp;lt;C-,&amp;gt;&lt;/code&gt; as well as some other special keys (&lt;code&gt;&amp;lt;C-Enter&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-S-Space&amp;gt;&lt;/code&gt;, ...) in my vimrc like,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set  &amp;lt;F13&amp;gt;=^[[44;5u&#xA;:map  &amp;lt;F13&amp;gt; &amp;lt;C-,&amp;gt;&#xA;:map! &amp;lt;F13&amp;gt; &amp;lt;C-,&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and configured iTerm to send &lt;code&gt;^[[44;5u&lt;/code&gt; when &lt;code&gt;&amp;lt;C-,&amp;gt;&lt;/code&gt; is typed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note that &lt;code&gt;^[&lt;/code&gt; is the ascii Escape character.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works great, but Vim flashes &lt;code&gt;&amp;lt;80&amp;gt;ü^D,&lt;/code&gt; in the showcmd area whenever I use &lt;code&gt;&amp;lt;C-,&amp;gt;&lt;/code&gt;. Here's a screenshot (see the bottom-right corner):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7ex30.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7ex30.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't inhibit the mapping or seem to cause any problems, I'm just curious what it indicates. None of my other special mappings (&lt;code&gt;&amp;lt;C-Enter&amp;gt;&lt;/code&gt; and the like) do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastEditorUserId="51" LastEditDate="2016-11-17T05:51:28.347" LastActivityDate="2023-03-16T09:22:51.670" Title="Using &lt;C-,&gt; causes &quot;&lt;80&gt;ü^D,&quot; to flash in the showcmd area?" Tags="|key-bindings|vimrc|terminal|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6089" PostTypeId="2" ParentId="846" CreationDate="2016-01-10T16:47:44.147" Score="3" Body="&lt;p&gt;If your goal is to use mapleader and you have it redefined in your .vimrc &lt;/p&gt;&#xA;&#xA;&lt;p&gt;let mapleader = ','&lt;/p&gt;&#xA;&#xA;&lt;p&gt;that wouldn't work. You can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -c 'execute &quot;normal &quot;.get(g:,&quot;mapleader&quot;,&quot;\\&quot;).&quot;t&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but if you plan to use that functionality from command line, is better to encapsulate functionality on a function and call it directly.&lt;/p&gt;&#xA;" OwnerUserId="2779" LastActivityDate="2016-01-10T16:47:44.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6090" PostTypeId="1" AcceptedAnswerId="6092" CreationDate="2016-01-10T18:54:52.957" Score="4" ViewCount="5716" Body="&lt;p&gt;I am trying to install &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow&quot;&gt;vimtex&lt;/a&gt;, and I am not how to do that. What plugin manager should I use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I combine it with &quot;vim-surround&quot;? &quot;snipmate&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I went through the &lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/README.md&quot; rel=&quot;nofollow&quot;&gt;readme&lt;/a&gt; file, but could not really understand how vimtex could be used with other plugin managers. I could not install &lt;code&gt;vim-plug&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="5919" LastActivityDate="2020-09-04T15:19:06.383" Title="installing vimtex?" Tags="|plugin-system|plugin-vimtex|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6091" PostTypeId="2" ParentId="6081" CreationDate="2016-01-10T19:18:53.070" Score="1" Body="&lt;p&gt;I am considering using &lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; to end the timeout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are pretty easy to hit, and usually leave me back where I started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The one exception is if I was sitting on the last line of a file, then &lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; will ring the bell, and leave me on the line before last.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(For my most common use case, they are also conveniently on the opposite hand from &lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;).&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2016-01-10T19:18:53.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6092" PostTypeId="2" ParentId="6090" CreationDate="2016-01-10T22:00:29.833" Score="6" Body="&lt;p&gt;To install with &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;noreferrer&quot;&gt;vim-pathogen&lt;/a&gt;, this should work (taken directly from the readme, I just swapped vim-sensible with vimtex):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Now any plugins you wish to install can be extracted to a subdirectory under ~/.vim/bundle, and they will be added to the 'runtimepath'. Observe:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim/bundle&#xA;git clone https://github.com/lervag/vimtex.git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Now vimtex is installed. If you really want to get crazy, you could set it up as a submodule in whatever repository you keep your dot files in. I don't like to get crazy.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I further suggest you read the full readme of vim-pathogen, as well as other plugin managers that might be of interested, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;noreferrer&quot;&gt;vim-plug&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/gmarik/vundle&quot; rel=&quot;noreferrer&quot;&gt;vundle&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Shougo/neobundle.vim&quot; rel=&quot;noreferrer&quot;&gt;neobundle&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Regarding how to combine vimtex with other plugins: I don't understand the question. In principle, it should just work.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-01-10T22:00:29.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6093" PostTypeId="1" CreationDate="2016-01-11T05:06:47.497" Score="5" ViewCount="365" Body="&lt;p&gt;Say I've got a URL in the clipboard, I enter vim, I hit &lt;code&gt;&amp;lt;C-Q&amp;gt;&lt;/code&gt; and highlight a word. Then I hit &lt;code&gt;I&amp;lt;C-R&amp;gt;+&lt;/code&gt; to insert the clipboard at the start of the selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What actually happens is the word that I had highlighted gets inserted, instead of the URL I was expecting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got &lt;code&gt;clipboard=&lt;/code&gt;, &lt;code&gt;selectmode=key&lt;/code&gt;, &lt;code&gt;virtualedit=block&lt;/code&gt;. I can't find any other setting I might have enabled to do this. I've confirmed that &lt;code&gt;:reg +&lt;/code&gt; shows the URL and then changes after I highlight the word.&lt;/p&gt;&#xA;" OwnerUserId="488" LastEditorUserId="488" LastEditDate="2016-01-11T05:12:03.233" LastActivityDate="2016-01-11T05:15:31.883" Title="How to disable the clipboard being overwritten when highlighting text in visual block mode?" Tags="|visual-mode|os-clipboard|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6094" PostTypeId="2" ParentId="6093" CreationDate="2016-01-11T05:15:31.883" Score="4" Body="&lt;p&gt;Removing &lt;code&gt;a&lt;/code&gt; from the list of &lt;code&gt;guioptions&lt;/code&gt; was the answer. Change it from &lt;code&gt;set guioptions=ac&lt;/code&gt; to only &lt;code&gt;set guioptions=c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Credit to carpetsmoker in the comments here &lt;a href=&quot;https://vi.stackexchange.com/questions/769/can-visual-select-mode-be-integrated-with-the-unix-selection-clipboard?rq=1&quot;&gt;Can visual select mode be integrated with the Unix selection clipboard?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="488" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-01-11T05:15:31.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6095" PostTypeId="1" AcceptedAnswerId="6096" CreationDate="2016-01-11T07:04:21.673" Score="7" ViewCount="1155" Body="&lt;p&gt;I'm trying to convert hex values to binary.&#xA;For example, I have got some text file containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0.0 010111010  B4&#xA;0.1 001001011  A3&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I'm trying to convert &lt;code&gt;B4&lt;/code&gt; to &lt;code&gt;10110100&lt;/code&gt;, and &lt;code&gt;A3&lt;/code&gt; too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I can't find any method. So does anyone know how to do that?&lt;/p&gt;&#xA;" OwnerUserId="5973" LastEditorUserId="205" LastEditDate="2016-01-11T10:42:10.480" LastActivityDate="2016-01-11T11:00:22.180" Title="How to convert hex to binary in Text mode?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6096" PostTypeId="2" ParentId="6095" CreationDate="2016-01-11T09:00:27.163" Score="8" Body="&lt;p&gt;The helpfile &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#eval-examples&quot;&gt;&lt;code&gt;:h eval-examples&lt;/code&gt;&lt;/a&gt; contains an example of a &lt;code&gt;number2binary&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; The function Nr2Bin() returns the binary string representation of a number.&#xA;func Nr2Bin(nr)&#xA;  let n = a:nr&#xA;  let r = &quot;&quot;&#xA;  while n&#xA;    let r = '01'[n % 2] . r&#xA;    let n = n / 2&#xA;  endwhile&#xA;  return r&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Copy that example to your .vimrc and after restarting your vim, you can do &lt;code&gt;:echo Nr2Bin(0xB4)&lt;/code&gt; and it will output 10110100.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When writing (e.g. in insert mode) you can then, press &lt;code&gt;&amp;lt;C-R&amp;gt;=Nr2Bin(0xA3)&lt;/code&gt; and the result will be inserted into your buffer.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="205" LastEditDate="2016-01-11T11:00:22.180" LastActivityDate="2016-01-11T11:00:22.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6097" PostTypeId="1" AcceptedAnswerId="6098" CreationDate="2016-01-11T11:53:18.823" Score="25" ViewCount="25453" Body="&lt;p&gt;Vim's &lt;a href=&quot;http://www.vim.org/download.php#pc&quot;&gt;Downloads page&lt;/a&gt; says the 64-bit version is discontinued:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h3&gt;Win64&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;The 32-bit version of Vim runs fine on 64-bit windows. There was a&#xA;  64-bit binary, but it wasn't used much and maintenance stopped.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which is fine, I suppose, except that 32-bit Vim doesn't pick up 64-bit Python. &lt;code&gt;has('python')&lt;/code&gt;? &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are my options for installing 64-bit Vim specifically (including GVim) on Windows, with as much plugin support as possible?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The binary from Cream is also apparently 32-bit (see the &lt;a href=&quot;http://sourceforge.net/projects/cream/files/Vim/7.4.1063/gvim-7-4-1063_version.txt/download&quot;&gt;&lt;code&gt;version.txt&lt;/code&gt;&lt;/a&gt;). As for Cygwin, I'm not sure about getting GVim running in it (&lt;a href=&quot;http://cs.nyu.edu/~yap/prog/cygwin/FAQs.html#gvim&quot;&gt;it apparently needs &lt;code&gt;DISPLAY&lt;/code&gt; set&lt;/a&gt;, which would indicate the need for X server, which is yet another complication over the complexity of Cygwin itself).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;a href=&quot;http://www.mingw.org/&quot;&gt;MinGW&lt;/a&gt; installed (and it is rather outdated, admittedly), so I could make some attempt at compiling it myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Vim Wikia suggests &lt;a href=&quot;https://tuxproject.de/projects/vim/x64/&quot;&gt;https://tuxproject.de/projects/vim/x64/&lt;/a&gt;, which has a rather ominous instruction:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You'll need to copy the appropriate DLL files to your Vim directory to make them work. They're not included.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To my Vim directory? Will &lt;a href=&quot;https://tuxproject.de&quot;&gt;https://tuxproject.de&lt;/a&gt;'s build not pick up Python installed elsewhere?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So, I'd like to install 64-bit Vim so that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it works out-of-the-box with Python installed using the official Python binaries (preferably both 2 and 3, if that's possible, and the latest versions)&lt;/li&gt;&#xA;&lt;li&gt;it is easy to keep updated&lt;/li&gt;&#xA;&lt;li&gt;the requirements for having it installed are a minimum (... so a Cygwin installation, if workable, should be minimal)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="51" LastEditDate="2017-03-20T18:12:03.317" LastActivityDate="2017-03-20T18:51:45.233" Title="How can I install 64-bit Vim on Windows?" Tags="|microsoft-windows|installing|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6098" PostTypeId="2" ParentId="6097" CreationDate="2016-01-11T12:50:59.347" Score="16" Body="&lt;p&gt;I think tuxproject.de is the way to go and I think, it will pick up Python dll, if they are in your path and are also 64bit. The easy way is to copy them to your .vim directory, to make sure vim will find them when trying to load them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is another alternative (and I really hope this will become official). We are trying to build binary Vims as part of the CI testing with appveyor, so that eventually for every patch there will be a corresponding Windows Vim version 32bit and 64bit available. Current snapshots are available &lt;a href=&quot;https://ci.appveyor.com/project/k-takata/vim/history&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://github.com/chrisbra/vim/releases&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. Note they are unofficial and not regularly maintained. But I really hope, something like this will be available with the not too far away release of Vim 7.5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;05.02.2016&lt;/strong&gt; We have now un-official (or almost official) binaries in the new repository &lt;a href=&quot;https://github.com/vim/vim-win32-installer&quot; rel=&quot;noreferrer&quot;&gt;vim-win32-installer&lt;/a&gt;. Feedback is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2016-02-05T14:53:17.710" LastActivityDate="2016-02-05T14:53:17.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6099" PostTypeId="1" AcceptedAnswerId="6881" CreationDate="2016-01-11T15:29:13.137" Score="5" ViewCount="448" Body="&lt;p&gt;Sometimes when I do something like saving, opening another file or another tab, the screen isn't changing states properly. At first I thought it was just my computer being slow, but then I noticed that after any keypress the screen updates and everything is okay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like this: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6vZhA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6vZhA.png&quot; alt=&quot;Screen update bug&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but after a keypress everything updates and the file opens properly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BwQkC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BwQkC.png&quot; alt=&quot;Proper view&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do to prevent this from happening? It's &lt;em&gt;really&lt;/em&gt; annoying!&lt;/p&gt;&#xA;" OwnerUserId="5965" LastEditorUserId="1708" LastEditDate="2016-03-11T18:53:35.627" LastActivityDate="2016-03-14T10:30:54.697" Title="MacVim doesn't redraw screen properly" Tags="|save|macvim|" AnswerCount="1" CommentCount="3" ClosedDate="2016-03-15T07:08:01.197" ContentLicense="CC BY-SA 3.0" />
  <row Id="6100" PostTypeId="1" CreationDate="2016-01-11T23:14:31.647" Score="2" ViewCount="2811" Body="&lt;p&gt;How can I remove the horrible color of my vim status bar has? I'd like it to be the same color as the background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wrvUg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wrvUg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current settings in my &lt;code&gt;~./.vimrc&lt;/code&gt; file (or &lt;code&gt;~/.vimrc.after&lt;/code&gt; file as I use) which relate to the status bar are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set laststatus=2                            &quot; Show the last status&#xA;hi statusline guibg=#263238&#xA;&#xA;set statusline=%f                           &quot; Filename&#xA;&#xA;function! InsertStatuslineColor(mode)&#xA;  if a:mode == 'i'&#xA;    hi statusline guibg=#573E81 guifg=#263238&#xA;  elseif a:mode == 'r'&#xA;    hi statusline guibg=blue guifg=#263238&#xA;  else&#xA;    hi statusline guibg=red guifg=#263238&#xA;  endif&#xA;endfunction&#xA;&#xA;au InsertEnter * call InsertStatuslineColor(v:insertmode)&#xA;au InsertChange * call InsertStatuslineColor(v:insertmode)&#xA;au InsertLeave * hi statusline guibg=#c5c8c6 guifg=#263238&#xA;&#xA;&quot; default the statusline to green when entering Vim&#xA;hi statusline guibg=#c5c8c6 guifg=#263238&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using MacVim v7.4 (88).&lt;/p&gt;&#xA;" OwnerUserId="5981" LastActivityDate="2021-03-25T19:11:05.150" Title="Remove vim status bar background color?" Tags="|gvim|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6101" PostTypeId="1" AcceptedAnswerId="6102" CreationDate="2016-01-12T16:13:02.497" Score="17" ViewCount="3403" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a text object for current line?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a text object for &lt;code&gt;^$&lt;/code&gt;?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2082" LastEditorUserId="1292" LastEditDate="2019-01-24T12:50:03.307" LastActivityDate="2023-09-19T15:19:56.500" Title="Is there a text object for current line?" Tags="|cursor-motions|custom-text-object|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6102" PostTypeId="2" ParentId="6101" CreationDate="2016-01-12T16:42:49.777" Score="19" Body="&lt;p&gt;Here are crude &amp;quot;line&amp;quot; text objects:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap il g_o0&#xA;onoremap il :normal vil&amp;lt;CR&amp;gt;&#xA;xnoremap al $o0&#xA;onoremap al :normal val&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And a crude &amp;quot;buffer&amp;quot; text object:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap i% GoggV&#xA;onoremap i% :normal vi%&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;---EDIT---&lt;/p&gt;&#xA;&lt;p&gt;An &amp;quot;operator&amp;quot; is a command that doesn't do anything by itself: &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&lt;p&gt;Pressing those keys put you in &amp;quot;operator-pending mode&amp;quot;, where Vim waits for you to tell it what you want it to operate on… with an &amp;quot;operator-pending motion&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;You can use &lt;code&gt;:omap&lt;/code&gt; or &lt;code&gt;:onoremap&lt;/code&gt; to define custom operator-pending motions. The technique used here is inspired by &lt;code&gt;:help omap-info&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;you define a visual mode mapping that covers the desired area,&lt;/li&gt;&#xA;&lt;li&gt;you use that mapping in an operator-pending mapping.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Note that I used &lt;code&gt;:onoremap&lt;/code&gt; because &lt;code&gt;il&lt;/code&gt;, &lt;code&gt;al&lt;/code&gt; and &lt;code&gt;i%&lt;/code&gt; don't already exist. If you are overriding an existing motion or text-object — say &lt;code&gt;ip&lt;/code&gt; — you must use a recursive mapping: &lt;code&gt;:omap&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:help :map-operator&lt;/code&gt; describes a slightly more advanced method.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;code&gt;:help v_o&lt;/code&gt; for &lt;code&gt;o&lt;/code&gt; in visual mode.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2023-09-19T15:19:56.500" LastActivityDate="2023-09-19T15:19:56.500" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6103" PostTypeId="1" CreationDate="2016-01-12T20:37:03.180" Score="4" ViewCount="1462" Body="&lt;p&gt;I often complete file paths in Vim using &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;x&lt;/kbd&gt;&#xA;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;f&lt;/kbd&gt; in insert mode, but there is one annoyance: the tilde character does not expand. This is fine for things like bash, but for Python (which does not understand &lt;code&gt;~/Data/data.xml&lt;/code&gt;) it is suboptimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/Dat&lt;/code&gt; completes to &lt;code&gt;~/Data/&lt;/code&gt; whereas I would prefer the full path&#xA;&lt;code&gt;/home/user/Data/&lt;/code&gt;. (As a side note: Vim already expands shell variables correctly, so that &lt;code&gt;$HOME/Dat&lt;/code&gt; completes to &lt;code&gt;/home/user/Data&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get file path completion to expand the tilde? If not&#xA;natively, is there a plugin that does so?&lt;/p&gt;&#xA;" OwnerUserId="1402" LastEditorUserId="205" LastEditDate="2016-01-13T03:26:02.263" LastActivityDate="2016-01-13T13:49:10.597" Title="How do I get &quot;~&quot; (tilde) to expand when using File Name Completion in Insert Mode?" Tags="|autocompletion|insert-mode|path|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6104" PostTypeId="2" ParentId="6103" CreationDate="2016-01-12T20:48:13.040" Score="5" Body="&lt;p&gt;If you press &lt;kbd&gt;Ctrl+x&lt;/kbd&gt;&lt;kbd&gt;Ctrl+f&lt;/kbd&gt; immediately after typing the &lt;code&gt;~&lt;/code&gt;, i.e. before typing the trailing slash, it is expanded to &lt;code&gt;/home/user/&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1672" LastEditorUserId="205" LastEditDate="2016-01-13T03:26:18.757" LastActivityDate="2016-01-13T03:26:18.757" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6105" PostTypeId="1" CreationDate="2016-01-13T07:05:11.010" Score="8" ViewCount="351" Body="&lt;p&gt;Following up my earlier question (&lt;a href=&quot;https://vi.stackexchange.com/q/6097/205&quot;&gt;How can I install 64-bit Vim on Windows?&lt;/a&gt;), I'd like to automate updating Vim. On Linux, I let the package manager and its frontends take care of checking for updates to Vim and notifying me of them (or even automatically installing them). On Windows, this is not so easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I were using Cygwin, I'd probably use Cygwin's package manager in a similar fashion as I do on Linux. Though I am curious how this would be done. Via the Task Scheduler, perhaps?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I automate checks for new versions of Vim? Preferably, I'd like to automate updates as well.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There could be a builtin function I am not aware of that does this.&lt;/li&gt;&#xA;&lt;li&gt;A custom function called on startup that &lt;em&gt;asynchronously&lt;/em&gt; checks &lt;a href=&quot;https://github.com/vim/vim/commits/master.atom&quot; rel=&quot;nofollow noreferrer&quot;&gt;the commit feed&lt;/a&gt; for new patches, or a download source for new downloads.&lt;/li&gt;&#xA;&lt;li&gt;A scheduled task that does the above outside of Vim.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;em&gt;asynchronous&lt;/em&gt; part - I don't want to wait around while Vim uses &lt;code&gt;wget&lt;/code&gt; or something to download a page and parse it and so on... I want to get started with whatever I was doing, and be notified whenever the update check process finishes. Consider how Notepad++ notifies you of available updates, without stopping startup for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to see a general method - if parsing HTML is needed (say, for example, looking at a specific download page like &lt;a href=&quot;https://tuxproject.de/projects/vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://tuxproject.de/projects/vim/&lt;/a&gt;), I can manage that - but how do I accomplish the rest?&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2021-08-07T21:40:06.043" Title="How can I automate checking for new Vim releases on Windows?" Tags="|microsoft-windows|installing|version|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6106" PostTypeId="1" AcceptedAnswerId="6107" CreationDate="2016-01-13T08:27:37.843" Score="1" ViewCount="416" Body="&lt;p&gt;I have the following code in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:WordPos(dir) abort&#xA;    return a:dir ==# 'right'&#xA;    \ ? searchpos('\&amp;lt;', 'nz', line('.'))[1]&#xA;    \ : searchpos('\&amp;lt;', 'bn', line('.'))[1]&#xA;endfunction&#xA;&#xA;silent! execute &quot;set &amp;lt;M-b&amp;gt;=\eb&quot;&#xA;silent! execute &quot;set &amp;lt;M-f&amp;gt;=\ef&quot;&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;M-b&amp;gt; &amp;lt;SID&amp;gt;WordPos('left') == 0&#xA;\ ? '&amp;lt;S-Left&amp;gt;'&#xA;\ : repeat('&amp;lt;C-G&amp;gt;U&amp;lt;Left&amp;gt;', col('.') - &amp;lt;SID&amp;gt;WordPos('left'))&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;M-f&amp;gt; &amp;lt;SID&amp;gt;WordPos('right') == 0&#xA;\ ? '&amp;lt;S-Right&amp;gt;'&#xA;\ : repeat('&amp;lt;C-G&amp;gt;U&amp;lt;Right&amp;gt;', &amp;lt;SID&amp;gt;WordPos('right') - col('.'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The goal is to move by words in insert mode with &lt;code&gt;Alt-b&lt;/code&gt;, &lt;code&gt;Alt-f&lt;/code&gt; without breaking the undo sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works more or less but if I try to type the character &lt;code&gt;â&lt;/code&gt;, instead of inserting it, Vim triggers the mapping for &lt;code&gt;Alt-b&lt;/code&gt;, which makes the cursor move one word backward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As soon as I comment the mapping for &lt;code&gt;Alt-b&lt;/code&gt;, the problem disappears.&#xA;It happens in Vim as well as in gVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output of the shell command &lt;code&gt;xxd -p&lt;/code&gt; when I hit &lt;code&gt;Alt-b&lt;/code&gt; is &lt;code&gt;1b62&lt;/code&gt;, and for &lt;code&gt;â&lt;/code&gt; it's &lt;code&gt;c3a2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does Vim interpret &lt;code&gt;â&lt;/code&gt; as &lt;code&gt;Alt-b&lt;/code&gt; even though the keycodes seem different?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-01-13T11:04:17.993" LastActivityDate="2016-01-13T11:04:17.993" Title="Why does Vim interpret â as Alt-b in a mapping?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6107" PostTypeId="2" ParentId="6106" CreationDate="2016-01-13T08:48:07.767" Score="3" Body="&lt;p&gt;I think, traditionally (in the old times), pressing the &lt;kbd&gt;Alt&lt;/kbd&gt; key meant setting the high-bit of the corresponding ascii char. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, &amp;lt;A-b&gt; is the same as â in the terminal at least.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Terminal input handling is rather complicated and there exist many little knobs one can set, but IIRC until recently, there was no reliable way, to distinguish the Alt key presses from the highbit ascii chars. That might be different on Windows or in the Gui, I don't really know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Neovim project did change it and used the libtermkey library which can detect those difference and therefore fixed this annoyance. For Vim, however, as far as I know, there is no way around it and therefore, it is advised to not use the  key for mapping, since this is not portable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in general, I tend to avoid using the Alt key in mappings.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2016-01-13T08:57:24.977" LastActivityDate="2016-01-13T08:57:24.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6108" PostTypeId="1" AcceptedAnswerId="6109" CreationDate="2016-01-13T09:33:36.417" Score="2" ViewCount="75" Body="&lt;p&gt;I'm trying to understand how to move in the undo tree with the following default mappings:&lt;br&gt;&#xA;&lt;code&gt;u&lt;/code&gt;, &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;, &lt;code&gt;g-&lt;/code&gt; and &lt;code&gt;g+&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my understanding of things, which is probably wrong or incomplete. Each time we make a new edit, a new leaf is created in the undo tree.&#xA;The more we make edits, the more leafs are added along a branch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To move along the branch, we can use &lt;code&gt;u&lt;/code&gt; to go back to the original version of the buffer, and &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; to go forward to the newest version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be confirmed with the simple following test:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;create an empty buffer,&lt;/li&gt;&#xA;&lt;li&gt;insert the number &lt;code&gt;1&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;&amp;lt;C-A&amp;gt;&lt;/code&gt; to increment it to &lt;code&gt;2&lt;/code&gt;, again to &lt;code&gt;3&lt;/code&gt; and again to &lt;code&gt;4&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;u&lt;/code&gt; and &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;, we can go back to each state of the buffer: empty, &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt;, &lt;code&gt;3&lt;/code&gt; and &lt;code&gt;4&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If at one point, we go backward and make a new edit from a past leaf, we create a new branch. The leafs which are not between the root of the tree (the original buffer) and the beginning of the new branch (the last edit we just made) can't be accessed with &lt;code&gt;u&lt;/code&gt; and &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;.&lt;br&gt;&#xA;Going back to the example, this can be confirmed:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;from the buffer's version &lt;code&gt;4&lt;/code&gt;, hit &lt;code&gt;u&lt;/code&gt; to go back to &lt;code&gt;3&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;r5&lt;/code&gt; to replace &lt;code&gt;3&lt;/code&gt; with &lt;code&gt;5&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;u&lt;/code&gt; to undo the last edit&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The last &lt;code&gt;u&lt;/code&gt; doesn't bring us back to &lt;code&gt;4&lt;/code&gt; but to &lt;code&gt;3&lt;/code&gt;.&lt;br&gt;&#xA;We can't go back anymore to &lt;code&gt;4&lt;/code&gt; with &lt;code&gt;u&lt;/code&gt; and &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; because they only move along the shortest path between the root of the tree and the most recent version of the buffer which we've visited.&lt;br&gt;&#xA;&lt;code&gt;4&lt;/code&gt; is not on the shortest path between the original empty buffer and &lt;code&gt;5&lt;/code&gt;, because &lt;code&gt;5&lt;/code&gt; was created from &lt;code&gt;3&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To go back to any leaf of the undo tree, we can use &lt;code&gt;g-&lt;/code&gt; and &lt;code&gt;g+&lt;/code&gt;.&#xA;Contrary to &lt;code&gt;u&lt;/code&gt; and &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;, they move along a time axis on which every leaf is placed in the order it was created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To confirm this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;undo with &lt;code&gt;u&lt;/code&gt; up to the original empty buffer&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;g+&lt;/code&gt; 5 times to reach &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt;, &lt;code&gt;3&lt;/code&gt;, &lt;code&gt;4&lt;/code&gt; and &lt;code&gt;5&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;g-&lt;/code&gt; 5 times to get back to &lt;code&gt;4&lt;/code&gt;, &lt;code&gt;3&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt; and the empty buffer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, there's one case I don't understand.&#xA;If from &lt;code&gt;5&lt;/code&gt;, we hit &lt;code&gt;u&lt;/code&gt; to get back to &lt;code&gt;3&lt;/code&gt;, then &lt;code&gt;g+&lt;/code&gt;, we get &lt;code&gt;5&lt;/code&gt;.&#xA;But on the time axis, the nearest leaf from &lt;code&gt;3&lt;/code&gt; is not &lt;code&gt;5&lt;/code&gt;, it's &lt;code&gt;4&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So why does Vim bring us to &lt;code&gt;5&lt;/code&gt; instead of &lt;code&gt;4&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-01-13T10:22:04.413" LastActivityDate="2023-01-03T19:09:41.553" Title="Why does g+ sometimes skip a leaf of the undo tree?" Tags="|key-bindings|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6109" PostTypeId="2" ParentId="6108" CreationDate="2016-01-13T10:12:14.387" Score="2" Body="&lt;p&gt;I find the default mappings/commands for navigating through the undo tree very complex and hard to memorize. If your intention is to use it on regular editing (instead of writing some custom command for a specific task), I'd recommend using a plugin, such as the &lt;a href=&quot;https://github.com/mbbill/undotree/&quot; rel=&quot;nofollow noreferrer&quot;&gt;undo tree plugin&lt;/a&gt;, which provides a great visual representation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ohfbn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ohfbn.png&quot; alt=&quot;undo tree screenshot&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It makes it very easy to find a previous point on the undo tree; among several options, it allows for toggling the relative time to absolute time.&#xA;There are several alternative plugins; for instance, on the link above there is a feature comparison  of the undo tree plugin against the &lt;a href=&quot;https://web.archive.org/web/20170115153627/http://sjl.bitbucket.org/gundo.vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gundo plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Obviously the navigation through plugins will be slower than through the built-in plugins. But I believe that navigating the undo tree should be an exception, so for me it isn't worth spending time and effort learning/memorizing commands to gain a few seconds per week/month. If it does make sense for your workflow, then you can use the representation provided by plugins to aid your learning, to understand how the default commands moved you through the undo tree.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="11357" LastEditDate="2023-01-03T19:09:41.553" LastActivityDate="2023-01-03T19:09:41.553" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6111" PostTypeId="2" ParentId="6103" CreationDate="2016-01-13T12:21:51.790" Score="2" Body="&lt;p&gt;How about using an input abbreviation? E.g. using &lt;code&gt;iabbrevv ~~ /home/duck&lt;/code&gt;, when you type &lt;code&gt;~~/&lt;/code&gt; it will be expanded to &lt;code&gt;/home/duck/&lt;/code&gt; immediately and you can continue as normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or maybe just a mapping:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;C-x&amp;gt;&amp;lt;C-f&amp;gt; &amp;lt;C-[&amp;gt;viW:s/\~/\/home\/duck/&amp;lt;CR&amp;gt;Ea&amp;lt;C-x&amp;gt;&amp;lt;C-f&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will simply substitute the tilde of the WORD you're typing on by your homedir. It might be improved by using a mark to save your cursor position, but I kinda guess you're fine with just continuing to type at the end of the WORD.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="1296" LastEditDate="2016-01-13T13:49:10.597" LastActivityDate="2016-01-13T13:49:10.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6112" PostTypeId="1" AcceptedAnswerId="16981" CreationDate="2016-01-13T15:54:51.980" Score="64" ViewCount="28264" Body="&lt;p&gt;In order to ensure that behaviour is not affected by my personal config, I want to start Vim in a way that ignores &lt;em&gt;all&lt;/em&gt; my user-installed config files, as if Vim had just been freshly installed for the first time and the user had run it immediately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is addressed &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-2.5&quot; rel=&quot;noreferrer&quot;&gt;in the FAQ&lt;/a&gt; which suggests that the answer is to start Vim with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gets &lt;em&gt;most&lt;/em&gt; of the way there, but the &lt;code&gt;runtimepath&lt;/code&gt; option still contains &lt;code&gt;~/.vim&lt;/code&gt; and, notably, &lt;code&gt;~/.vim/after&lt;/code&gt;, (so e.g. if I subsequently turn on file type detection and change filetype, code in &lt;code&gt;~/.vim/after/syntax/the_relevant_filetype.vim&lt;/code&gt; will be executed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can workaround this specific problem by invoking the following commands on startup*:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set runtimepath-=~/.vim&#xA;:set runtimepath-=~/.vim/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...but I'm not sure if:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;This is a robust solution: Are those the only paths that can cause user-configuration to take effect? Is there anything else I haven't thought of?&lt;/li&gt;&#xA;&lt;li&gt;There is a better way of achieving the desired result.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* By using &lt;code&gt;--cmd&lt;/code&gt; or &lt;code&gt;-u vimrc&lt;/code&gt; shell arguments, or simply by typing them manually.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: Here's one specific example of the sort of problem I'm trying to fix. (Although I'd like the solution to fix any other possible issues I might not yet have encounted.):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Create a file ~/.vim/after/ftplugin/c.vim, containing the content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap i :echom &quot;This is not default behaviour&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now we have some user-installed configuration that we want to ignore. Let's test the solution suggested by the FAQ.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run Vim with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Enter the commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype plugin on&#xA;:set ft=c&#xA;i&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Desired behaviour&lt;/strong&gt;: Vim should enter Insert mode. This is what it would do if no user configuration existed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Observed behaviour&lt;/strong&gt;: Vim prints out &quot;This is not default behaviour&quot;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-01-14T12:57:01.250" LastActivityDate="2021-03-03T15:26:06.323" Title="How can I get Vim to ignore all user configuration, as if it were freshly installed?" Tags="|startup|" AnswerCount="4" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6113" PostTypeId="2" ParentId="5926" CreationDate="2016-01-13T16:39:42.660" Score="1" Body="&lt;p&gt;It looks like the end goal is simply to have your &lt;kbd&gt;F5&lt;/kbd&gt; be mapped to certain functionality when you are in a C source file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Presuming you already have file type detection switched on (&lt;code&gt;:help filetype&lt;/code&gt;), the way I would achieve this is to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create a function to run the code,&lt;/li&gt;&#xA;&lt;li&gt;Create a mapping to call the function when &lt;kbd&gt;F5&lt;/kbd&gt; is pressed,&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Place the code for both of these in the file &lt;code&gt;~/.vim/after/ftplugin/c.vim&lt;/code&gt;, which will cause the mapping to be created whenever a file of type &lt;code&gt;C&lt;/code&gt; is edited. (See &lt;code&gt;:help ftplugin-overrule&lt;/code&gt; for more details.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:f5()&#xA;  Makexec &#xA;  if findfile( expand(&quot;%:p:r&quot;).&quot;.exe&quot; ,expand(&quot;%:p:h&quot;) ) != &quot;&quot;&#xA;    !%:p:r.exe&#xA;  else&#xA;    vert topleft cwin&#xA;    vert resize 50&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;F5&amp;gt; :call &amp;lt;SID&amp;gt;f5()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;N.B.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The &lt;code&gt;s:&lt;/code&gt; and &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; prefixes to the function name mean that the function is only defined within that script, preventing it from clashing with similarly named functions elsewhere, (&lt;code&gt;:help &amp;lt;SID&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; causes the mapping only to apply to the individual buffer, so if you switch to a file with a different filetype, the F5 key won't erroneously call the function,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; just means that the mapping contents (&lt;code&gt;:call...&lt;/code&gt;) won't be echoed to the screen when the mapping is invoked,&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you &lt;em&gt;don't&lt;/em&gt; have file type detection switched on, and for some reason you don't want to switch it on, you could of course use an autocommand to create the mapping, similar to what you had before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter *.c nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;F5&amp;gt; :call &amp;lt;SID&amp;gt;f5()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastActivityDate="2016-01-13T16:39:42.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6114" PostTypeId="2" ParentId="6112" CreationDate="2016-01-13T17:11:43.753" Score="15" Body="&lt;p&gt;One way to eliminate user-specific files would be to use a different value of &lt;code&gt;$HOME&lt;/code&gt;. To allow nothing to be read, or written to (such as viminfo), you could use &lt;code&gt;/dev/null&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HOME=/dev/null vim -u NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will cause errors about &lt;code&gt;viminfo&lt;/code&gt;, so, instead you could create a temporary folder, or use an existing one (like &lt;code&gt;/tmp&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HOME=$(mktemp -d) vim -u NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With such a &lt;code&gt;$HOME&lt;/code&gt;, &lt;code&gt;-u NONE&lt;/code&gt; may not be needed, depending on what your administrator has added to the system-wide &lt;code&gt;vimrc&lt;/code&gt;. For example, on all lab systems I administer, I added a &lt;code&gt;/etc/vim/vimrc.local&lt;/code&gt; (sourced by the packaged Vim's default &lt;code&gt;/etc/vim/vimrc&lt;/code&gt;) that has &lt;code&gt;nocompatible&lt;/code&gt;, &lt;code&gt;syntax&lt;/code&gt;, etc., set, and &lt;code&gt;filetype on&lt;/code&gt; as well.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-01-13T17:11:43.753" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6115" PostTypeId="1" AcceptedAnswerId="6118" CreationDate="2016-01-13T17:19:08.347" Score="6" ViewCount="1269" Body="&lt;p&gt;How to map &lt;code&gt;i&lt;/code&gt; to start editing on visual block mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want the same behavior for &lt;code&gt;&amp;lt;shift&amp;gt;-i&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="177" LastEditorUserId="7161" LastEditDate="2016-05-02T10:05:43.907" LastActivityDate="2016-05-02T10:05:43.907" Title="Visual block editing: map i" Tags="|key-bindings|visual-mode|visual-block|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6116" PostTypeId="2" ParentId="6100" CreationDate="2016-01-13T17:50:06.720" Score="3" Body="&lt;p&gt;There are several places in the code where you specifically set the statusline background to a sort of grayish colour with commands like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi statusline guibg=#c5c8c6 ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to replace these with lines like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi statusline guibg=NONE ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...to remove the colour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your statusline background still isn't correct you might have also have &lt;code&gt;reverse&lt;/code&gt; set. Check if the output of &lt;code&gt;:hilight statusline&lt;/code&gt; contains &lt;code&gt;gui=reverse&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, you will also need to clear this setting, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi statusline guibg=NONE gui=NONE ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :highlight&lt;/code&gt; for further details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2016-01-13T17:50:06.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6117" PostTypeId="2" ParentId="6112" CreationDate="2016-01-13T17:52:09.580" Score="0" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-2.5&quot; rel=&quot;nofollow&quot;&gt;Vim-FAQ  2.5&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2.5. I have a &quot;xyz&quot; (some) problem with Vim. How do I determine it is a&#xA;       problem with my setup or with Vim?  / Have I found a bug in Vim?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;First, you need to find out, whether the error is in the actual&#xA;  runtime files or any plugin that is distributed with Vim or whether it&#xA;  is a simple side effect of any configuration option from your .vimrc&#xA;  or .gvimrc. So first, start vim like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;this starts Vim in nocompatible mode (-N), without reading your&#xA;  viminfo file (-i NONE), without reading any configuration file (-u&#xA;  NONE for not reading .vimrc file and -U NONE for not reading a .gvimrc&#xA;  file) or even plugin.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-01-13T17:52:09.580" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="6118" PostTypeId="2" ParentId="6115" CreationDate="2016-01-13T18:00:24.123" Score="8" Body="&lt;p&gt;You can use &lt;code&gt;:h map-expression&lt;/code&gt; to determine which version of visual mode you are in, and change the behaviour accordingly. Visual mode mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;expr&amp;gt; i mode()=~'\cv' ? 'i' : 'I'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will make &lt;kbd&gt;i&lt;/kbd&gt; act as &lt;code&gt;i&lt;/code&gt; in visual and linewise-visual modes, and as &lt;code&gt;I&lt;/code&gt; otherwise, i.e. in blockwise visual mode.&lt;/p&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2016-01-13T18:00:24.123" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6119" PostTypeId="2" ParentId="778" CreationDate="2016-01-14T05:25:48.107" Score="1" Body="&lt;p&gt;There's a lightweight solution for that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Set up &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=5309&quot; rel=&quot;nofollow&quot;&gt;vimdiffext&lt;/a&gt; plugin.&lt;/li&gt;&#xA;&lt;li&gt;Do &lt;code&gt;diff dir1 dir2 | vim -R -&lt;/code&gt; at shell.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It will add folds and side-by-side comparison for changed files.&lt;/p&gt;&#xA;" OwnerUserId="5999" LastEditorUserId="467" LastEditDate="2016-01-14T10:48:06.897" LastActivityDate="2016-01-14T10:48:06.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6120" PostTypeId="1" AcceptedAnswerId="6122" CreationDate="2016-01-14T06:50:07.770" Score="1" ViewCount="203" Body="&lt;p&gt;I attempt to highlight CamelCase word in java file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match myClassName '\v(&amp;lt;\u\i*&amp;gt;)+'&#xA;highlight link myClassName Type&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;String&lt;/code&gt; in &lt;code&gt;(String []args)&lt;/code&gt; or &lt;code&gt;new String(&quot;...&quot;)&lt;/code&gt;does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I include brackets &lt;code&gt;{}[]()&lt;/code&gt; in the match, I solve the issue, but why?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;UPD&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/btLUF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/btLUF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The left one is a java file, the right one is &lt;code&gt;~/.vim/after/syntax/java.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It only highlight &lt;code&gt;Main&lt;/code&gt; and &lt;code&gt;System&lt;/code&gt;, but not highlight &lt;code&gt;String&lt;/code&gt; and &lt;code&gt;Date&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6000" LastEditorUserId="6000" LastEditDate="2016-01-14T14:27:37.383" LastActivityDate="2016-01-14T15:19:00.557" Title="highlight CamelCase word" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6121" PostTypeId="1" CreationDate="2016-01-14T14:32:35.463" Score="4" ViewCount="368" Body="&lt;p&gt;I have the following &lt;code&gt;.inputrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set editing-mode vi&#xA;set keymap vi-command&#xA;&#xA;set show-all-if-ambiguous on&#xA;set completion-ignore-case on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In bash when I type following (in insert mode!) as an example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# cat ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then press the &lt;code&gt;Home/Pos1&lt;/code&gt; key and then the &lt;code&gt;Del&lt;/code&gt; key the result is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# at ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far so expected. Now, for &lt;code&gt;ipython&lt;/code&gt;. I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In [1]: from bla import blub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then press the &lt;code&gt;Home/Pos1&lt;/code&gt; key and then the &lt;code&gt;Del&lt;/code&gt; key the result is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In [1]: From bla import blub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the cursor is at the position of the &lt;code&gt;r&lt;/code&gt; and it is not in insert mode anymore which is not what vim would do, right (not even in &lt;code&gt;compatible mode&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand my workflow is not exactly vim-style but I am just very used to it sshing to non-vi keys environments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Migrated from &lt;a href=&quot;https://stackoverflow.com/questions/34764730/inputrc-vi-keys-ipython-and-the-del-key&quot;&gt;Stackoverflow&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6006" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-01-14T14:32:35.463" Title="readline: inputrc vi keys, ipython and the del key" Tags="|bash|input-methods|" AnswerCount="0" CommentCount="4" ClosedDate="2016-01-14T18:09:25.300" ContentLicense="CC BY-SA 3.0" />
  <row Id="6122" PostTypeId="2" ParentId="6120" CreationDate="2016-01-14T15:19:00.557" Score="3" Body="&lt;p&gt;The problem is, your new syntax highlighting interferes with the java syntax highlighting. There are two different possibilities around it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Instead of the rather complex syntax rules, use matchadd() family of functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) add the containedin=ALL to your syntax definition, to make sure, it can be included in other syntax groups.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-01-14T15:19:00.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6123" PostTypeId="1" CreationDate="2016-01-14T15:48:37.287" Score="7" ViewCount="2145" Body="&lt;p&gt;Both &lt;em&gt;background&lt;/em&gt; and &lt;em&gt;colorscheme&lt;/em&gt; in &lt;code&gt;~/.vimrc&lt;/code&gt; are badly misbehaving!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have setup &lt;em&gt;solarized&lt;/em&gt; to work on &lt;em&gt;vim&lt;/em&gt; and it can manually toggle between &lt;em&gt;background&lt;/em&gt; &lt;em&gt;light&lt;/em&gt;/&lt;em&gt;dark&lt;/em&gt;. My general settings in &lt;code&gt;~/.vimrc&lt;/code&gt; are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'altercation/vim-colors-solarized' &quot;I use plug.vim&#xA;syntax enable&#xA;set background=light&#xA;set t_Co=256&#xA;let g:solarized_termcolors=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Operating system: &lt;em&gt;Ubuntu 14.04.&lt;/em&gt;; &lt;em&gt;xterm&lt;/em&gt; and works well with 256 colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to map in &lt;code&gt;~/.vimrc&lt;/code&gt; background toggling. For this purpose :help solarized (in vim) suggests to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call togglebg#map(&quot;&amp;lt;F9&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this doesn't work because it changes the &lt;em&gt;colorscheme&lt;/em&gt; from &lt;em&gt;solarized&lt;/em&gt; to default (my intention was to toggle only in &lt;em&gt;solarized&lt;/em&gt; between &lt;em&gt;dark&lt;/em&gt; and &lt;em&gt;light&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I remove from &lt;code&gt;~/.vimrc call togglebg#map(&quot;&amp;lt;F9&amp;gt;&quot;)&lt;/code&gt; and replaced it with what most google/superuser/vim.wikia commentators, in various flavors, have suggested with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BgToggleSol()&#xA;    if (&amp;amp;background == &quot;light&quot;)&#xA;      set background=dark &#xA;    else&#xA;       set background=light &#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;sz :call BgToggleSol()&amp;lt;cr&amp;gt;&#xA;&#xA;colorscheme solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this has the same problem (that toggling resets &lt;em&gt;colorscheme&lt;/em&gt; to &lt;em&gt;default&lt;/em&gt;). While if &lt;em&gt;colorscheme solarized&lt;/em&gt; is executed directly after &lt;code&gt;set background=...&lt;/code&gt; in the &lt;code&gt;if else endif&lt;/code&gt; clause then the &lt;em&gt;background&lt;/em&gt; stops toggling between &lt;em&gt;dark&lt;/em&gt;/&lt;em&gt;light&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I must have exhausted nearly all possibilities, but the problem is still not going away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestion is very welcome. Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="4617" LastEditorUserId="51" LastEditDate="2016-01-14T22:33:23.777" LastActivityDate="2022-08-28T02:54:45.410" Title="How to setup in `~/.vimrc` a mapping for `colorscheme` to toggle `solarized` between `dark` and `light`?" Tags="|vimscript|colorscheme|plugin-solarized|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6124" PostTypeId="1" AcceptedAnswerId="6128" CreationDate="2016-01-14T17:02:34.757" Score="1" ViewCount="300" Body="&lt;p&gt;Wordpress has an annoying &lt;a href=&quot;https://wordpress.stackexchange.com/questions/214456/why-does-wordpress-have-a-noop-php-file&quot;&gt;noop file&lt;/a&gt; which &lt;code&gt;ctags&lt;/code&gt; thinks defines all Wordpress functions.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA; * @ignore&#xA; */&#xA;function add_action() {}&#xA;&#xA;/**&#xA; * @ignore&#xA; */&#xA;function did_action() {}&#xA;&#xA;/**&#xA; * @ignore&#xA; */&#xA;function do_action_ref_array() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I tell &lt;code&gt;ctags&lt;/code&gt; to ignore this file when it creates the tag list?&lt;/strong&gt; I cannot simply delete the file.&lt;/p&gt;&#xA;" OwnerUserId="989" LastEditorUserId="-1" LastEditDate="2017-04-13T12:38:00.157" LastActivityDate="2016-01-14T19:49:06.783" Title="Configure tags to ignore noop file" Tags="|ctags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6125" PostTypeId="1" AcceptedAnswerId="6126" CreationDate="2016-01-14T17:05:19.670" Score="1" ViewCount="82" Body="&lt;p&gt;I'm getting undefined shiftwidth function error when I try to run &lt;code&gt;Autoformat html&lt;/code&gt; in vim-autoformat plugin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIU shiftwidth is a variable, not a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Checking plugin's source I see that it invokes it by a certain &quot;s&quot; object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:formatdef_astyle_cs = '&quot;astyle --mode=cs --style=ansi --indent-namespaces -pcH&quot;.(&amp;amp;expandtab ? &quot;s&quot;.shiftwidth() : &quot;t&quot;)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which I couln't find. Anyone knows how I solve this ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My VIM version: 7.3.429&lt;/p&gt;&#xA;" OwnerUserId="5944" LastEditorUserId="51" LastEditDate="2016-01-14T18:12:47.507" LastActivityDate="2016-01-14T18:12:47.507" Title="vim-autoformat plugin - undefined shiftwidth function" Tags="|error|plugin-vim-autoformat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6126" PostTypeId="2" ParentId="6125" CreationDate="2016-01-14T17:48:45.407" Score="3" Body="&lt;p&gt;shiftwidth() is a function that has been added I think late in the 7.3 circle. Can you update your Vim version?&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-01-14T17:48:45.407" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="6128" PostTypeId="2" ParentId="6124" CreationDate="2016-01-14T19:49:06.783" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Open a terminal emulator.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;At the prompt, type this command and press &lt;kbd&gt;Enter&lt;/kbd&gt; to open ctag's documentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ man ctags&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Type this command and press &lt;kbd&gt;Enter&lt;/kbd&gt; to jump to the first occurrence of the word &lt;code&gt;ignore&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/ignore&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;kbd&gt;n&lt;/kbd&gt; a few times until you find a relevant section.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you don't, try again with a synonym. Maybe… &lt;code&gt;exclude&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/exclude&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-01-14T19:49:06.783" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6129" PostTypeId="2" ParentId="6123" CreationDate="2016-01-14T20:44:54.783" Score="3" Body="&lt;p&gt;Something is definitely not right.&#xA;I have in my .vimrc something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=dark&#xA;colorscheme solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I do &lt;code&gt;:set bg?&lt;/code&gt; after that, it shows &quot;light&quot;.&#xA;I think that's the reason the if/else/endif in you function doesn't work after 'colorsheme solarized'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only workaround I can think of is to maintain the state in a separate variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Initially set it to &quot;dark&quot; or &quot;light&quot; according to your default&#xA;let s:mybg = &quot;dark&quot;&#xA;function! BgToggleSol()&#xA;    if (s:mybg ==? &quot;light&quot;)&#xA;       set background=dark&#xA;       let s:mybg = &quot;dark&quot;&#xA;    else&#xA;       set background=light&#xA;       let s:mybg = &quot;light&quot;&#xA;    endif&#xA;    &quot; set background=light&#xA;    colorscheme solarized&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;sz :call BgToggleSol()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6013" LastActivityDate="2016-01-14T20:44:54.783" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="6130" PostTypeId="2" ParentId="6004" CreationDate="2016-01-15T11:39:30.870" Score="3" Body="&lt;p&gt;Rather than changing the way text is actually stored by writing a custom &lt;code&gt;'formatexpr'&lt;/code&gt;, I'd be tempted to just to use Vim's existing features to solve the stated goals of easy readability and easy &quot;diff&quot;-ability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long lines are easily readable in Vim with the following set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set wrap&#xA;:set linebreak&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And changes towards the end of a line are also perfectly readable when using Vim for diffing (&lt;code&gt;:help diff&lt;/code&gt;), so long as you ensure 'wrap' is switched on while you view the diff. (It's off by default).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's at least one plugin (&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1245&quot; rel=&quot;nofollow&quot;&gt;cvsmenu&lt;/a&gt;) that allows you to use Vim for viewing CVS diffs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to diff &lt;em&gt;outside&lt;/em&gt; of Vim, there are tools that can help with this too: e.g. &lt;a href=&quot;https://www.gnu.org/software/wdiff/&quot; rel=&quot;nofollow&quot;&gt;wdiff&lt;/a&gt;, or &lt;a href=&quot;https://git-scm.com/docs/git-diff&quot; rel=&quot;nofollow&quot;&gt;git diff&lt;/a&gt;'s  &lt;code&gt;--word-diff&lt;/code&gt; option.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2016-01-15T11:39:30.870" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6131" PostTypeId="1" AcceptedAnswerId="6144" CreationDate="2016-01-15T13:35:49.517" Score="10" ViewCount="947" Body="&lt;p&gt;I have a string like &lt;code&gt;'foobar'&lt;/code&gt;, and I want to surround it with parentheses: &lt;code&gt;('foobar')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With vim-surround, I can do &lt;code&gt;ysi')&lt;/code&gt;, which produces &lt;code&gt;'(foobar)'&lt;/code&gt;... Not what I want&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can also &lt;code&gt;ysa')&lt;/code&gt;, but that will include whitespace: &lt;code&gt;(     'foobar')&lt;/code&gt;... Meh, close.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vim, I can &lt;code&gt;2yi'&lt;/code&gt;, which yanks exactly what I need &lt;code&gt;'foobar'&lt;/code&gt;, but I cannot seem to make it work with vim-surround&lt;/p&gt;&#xA;" OwnerUserId="6018" LastEditorUserId="205" LastEditDate="2016-01-17T17:47:02.040" LastActivityDate="2016-01-18T14:56:53.537" Title="How do I surround a quoted string without including leading whitespace?" Tags="|cursor-motions|plugin-vim-surround|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6132" PostTypeId="1" AcceptedAnswerId="6133" CreationDate="2016-01-15T16:11:53.033" Score="1" ViewCount="563" Body="&lt;p&gt;I have something like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;neckbeard: &quot;https://appa.com/emoji/neckbeard/c8ec7bf188.png&quot;,&#xA;metal: &quot;https://appa.com/emoji/metal/9f936a4278.png&quot;,&#xA;fu: &quot;https://appa.com/emoji/fu/2f615de37f.png&quot;,&#xA;feelsgood: &quot;https://appa.com/emoji/feelsgood/7bcbaa15fa.png&quot;,&#xA;finnadie: &quot;https://appa.com/emoji/finnadie/08e66eb46d.png&quot;,&#xA;goberserk: &quot;https://appa.com/emoji/goberserk/d8b892d59b.png&quot;,&#xA;godmode: &quot;https://appa.com/emoji/godmode/1bd6476fbb.png&quot;,&#xA;hurtrealbad: &quot;https://appa.com/emoji/hurtrealbad/b9c3d648e6.png&quot;,&#xA;rage1: &quot;https://appa.com/emoji/rage1/0c3685290c.png&quot;,&#xA;rage2: &quot;https://appa.com/emoji/rage2/feaf8897c6.png&quot;,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:neckbeard:&#xA;:metal:&#xA;:fu:&#xA;:feelsgood:&#xA;:finnadie:&#xA;:goberserk:&#xA;:godmode:&#xA;:hurtrealbad:&#xA;:rage1:&#xA;:rage2:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried a macro &lt;code&gt;@ai:&amp;lt;esc&amp;gt;f&quot;D0&lt;/code&gt; did a visual select to all the line and then &lt;code&gt;:'&amp;lt;,'&amp;gt; @a&lt;/code&gt; but I get &lt;code&gt;E488: Trailing characters: i:&lt;/code&gt;. I've tried with a default vimrc without plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why? &lt;/p&gt;&#xA;" OwnerUserId="3357" LastActivityDate="2016-01-15T16:29:35.223" Title="Macro fail with E488: Trailing characters: i:" Tags="|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6133" PostTypeId="2" ParentId="6132" CreationDate="2016-01-15T16:29:35.223" Score="0" Body="&lt;p&gt;I have to user &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/various.html#%3anormal&quot; rel=&quot;nofollow&quot;&gt;normal&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it's &lt;code&gt;:'&amp;lt;,'&amp;gt; norm @a&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And it's work&lt;/p&gt;&#xA;" OwnerUserId="3357" LastActivityDate="2016-01-15T16:29:35.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6134" PostTypeId="1" AcceptedAnswerId="6137" CreationDate="2016-01-15T16:52:08.523" Score="7" ViewCount="1943" Body="&lt;p&gt;I often &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;Z&lt;/kbd&gt; to the command line. Is there a way to do that in response to hitting &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;Z&lt;/kbd&gt; in insert mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;iabbrev&lt;/code&gt; command does not seem to work.&lt;/p&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="4472" LastEditDate="2017-07-06T18:40:08.950" LastActivityDate="2017-07-06T18:40:08.950" Title="Mapping Ctrl-Z in insert mode?" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6135" PostTypeId="2" ParentId="6061" CreationDate="2016-01-15T19:22:40.110" Score="21" Body="&lt;p&gt;I found a paper &lt;a href=&quot;https://docs.freebsd.org/44doc/usd/12.vi/paper.html&quot;&gt;&quot;An Introduction to Display Editing with Vi&quot;&lt;/a&gt; by William Joy (vi creator) and Mark Horton (vi maintainer since 1979).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the paper it is clear that the default Y behavior is not a mistake, but a desired feature.&#xA;In the &lt;a href=&quot;https://docs.freebsd.org/44doc/usd/12.vi/paper-4.html#section26&quot;&gt;&quot;Rearranging and duplicating text&quot; section&lt;/a&gt; they mention this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Try the command YP. This makes a copy of the current line &#xA;and leaves you on this copy, which is placed before the current line. &#xA;The command Y is a convenient abbreviation for yy. &#xA;The command Yp will also make a copy of the current line, &#xA;and place it after the current line. &#xA;You can give Y a count of lines to yank, and thus duplicate &#xA;several lines try 3YP.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Later in the list of commands (see the &lt;a href=&quot;https://docs.freebsd.org/44doc/usd/12.vi/paper.pdf&quot;&gt;appendix in the pdf version&lt;/a&gt;), the description for Y is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Y  Yanks a copy of the current line into the unnamed buffer, &#xA;   to be put back by a later p or P; a very useful synonym for yy.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way I am sure that Y was a feature and not a bug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for inconsistency with &lt;code&gt;D&lt;/code&gt; and &lt;code&gt;C&lt;/code&gt; - I also have a logical explanation.&#xA;If you try to think as a text editor author than your main desire would be to create new text and not delete it. &#xA;They (text editor authors) want their users to write more text and more and more...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for the syntactic sugar commands (and &lt;code&gt;Y&lt;/code&gt;, &lt;code&gt;D&lt;/code&gt; and &lt;code&gt;C&lt;/code&gt; are kind of syntactic sugar because they duplicate already existing features) they choose the operations which add as much text as possible (&lt;code&gt;Y&lt;/code&gt; duplicates the whole line) or delete as less text as possible (&lt;code&gt;D&lt;/code&gt; and &lt;code&gt;C&lt;/code&gt; delete until the end of line and not the whole line).&lt;/p&gt;&#xA;" OwnerUserId="6013" LastEditorUserId="6013" LastEditDate="2016-01-15T23:14:57.913" LastActivityDate="2016-01-15T23:14:57.913" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6136" PostTypeId="1" AcceptedAnswerId="6140" CreationDate="2016-01-15T19:22:55.247" Score="10" ViewCount="5846" Body="&lt;p&gt;I like to have &lt;code&gt;:set list&lt;/code&gt; on so that I can tell if things are spaces or tabs. My tabs show as &lt;code&gt;&amp;gt;---&lt;/code&gt; which is nice, but they are the same color are the text, is there a way to dim them so they're less distracting?&lt;/p&gt;&#xA;" OwnerUserId="4833" LastActivityDate="2016-01-16T15:13:32.677" Title="How to dim characters from :set list" Tags="|highlight|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6137" PostTypeId="2" ParentId="6134" CreationDate="2016-01-15T22:17:35.950" Score="6" Body="&lt;p&gt;Using &lt;code&gt;:h CTRL-Z&lt;/code&gt; as inspiration, the following solutions can be cooked:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;c-z&amp;gt; &amp;lt;esc&amp;gt;:stop&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or (shorter &amp;amp; literally closer):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;c-z&amp;gt; &amp;lt;esc&amp;gt;&amp;lt;c-z&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-01-15T22:17:35.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6138" PostTypeId="1" CreationDate="2016-01-16T08:57:09.593" Score="2" ViewCount="66" Body="&lt;p&gt;This is for an indent function that should maintain the indentation should the cursor happen to be in a string region. It maintains the indentation when I hit &lt;code&gt;==&lt;/code&gt; in normal mode but changes when I open a new line in the same string.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if synIDattr(synID(line('.'), line('.'), 0), 'name') =~ 'string'&#xA;  return -1&#xA;else&#xA;  return correct_indentation&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running the function in insert mode returns an empty string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-R&amp;gt;=synIDattr(synID(line('.'), line('.'), 0), 'name')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The docs don't mention anything about editing modes, just that it'll give different result when in &lt;strong&gt;gui&lt;/strong&gt; mode from when in &lt;strong&gt;term&lt;/strong&gt; mode&lt;/p&gt;&#xA;" OwnerUserId="6036" LastActivityDate="2016-01-17T18:09:51.087" Title="Can't seem to get syntax information when in insert mode" Tags="|vimscript|syntax-highlighting|indentation|functions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6139" PostTypeId="2" ParentId="6138" CreationDate="2016-01-16T11:53:21.547" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#synID%28%29&quot; rel=&quot;nofollow&quot;&gt;function &lt;code&gt;synID&lt;/code&gt;&lt;/a&gt; has to be called with the line and column position of where you want to get the syntax information from. Therefore, you need to replace the second &lt;code&gt;line('.')&lt;/code&gt; call by a &lt;code&gt;col('.')&lt;/code&gt; call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you get a zero, this means, that there is no syntax information available for that position. This could be the case, because in insert mode, your cursor is usually one column behind the last inserted text. &lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="205" LastEditDate="2016-01-17T18:09:51.087" LastActivityDate="2016-01-17T18:09:51.087" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6140" PostTypeId="2" ParentId="6136" CreationDate="2016-01-16T15:13:32.677" Score="15" Body="&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27listchars%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'listchars'&lt;/code&gt;&lt;/a&gt; mentions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    The &quot;NonText&quot; highlighting will be used for &quot;eol&quot;, &quot;extends&quot; and&#xA;    &quot;precedes&quot;.  &quot;SpecialKey&quot; for &quot;nbsp&quot;, &quot;space&quot;, &quot;tab&quot; and &quot;trail&quot;.&#xA;    hl-NonText hl-SpecialKey&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if we go to &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#hl%2dSpecialKey&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help hl-SpecialKey&lt;/code&gt;&lt;/a&gt; we read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SpecialKey      Meta and special keys listed with &quot;:map&quot;, also for text used&#xA;                to show unprintable characters in the text, 'listchars'.&#xA;                Generally: text that is displayed differently from what it&#xA;                really is.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can change this with the &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3ahighlight&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:highlight&lt;/code&gt;&lt;/a&gt; command, or &lt;code&gt;:hi&lt;/code&gt; for short:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi SpecialKey ctermfg=grey guifg=grey70&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this &lt;em&gt;also&lt;/em&gt; change the colours of non-printable characters; for example the &lt;code&gt;^M&lt;/code&gt; when you're dealing with a file that mixes Unix and DOS line endings.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-01-16T15:13:32.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6141" PostTypeId="1" CreationDate="2016-01-16T17:43:35.920" Score="1" ViewCount="1288" Body="&lt;p&gt;I am a new user to &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow&quot;&gt;vimtex&lt;/a&gt;. Here are some requests for tips.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I hear that it has &quot;make on write&quot; feature. How do I enable it to use my flags to &lt;code&gt;makelatex&lt;/code&gt;, so that it uses e.g., &lt;code&gt;lualatex&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Which keybindings do you have for useful features, e.g., find next error/warning?&lt;/li&gt;&#xA;&lt;li&gt;How do you enable/use the F7 key mentioned in the documentation?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5919" LastActivityDate="2016-01-16T17:43:35.920" Title="Tips for using vimtex?" Tags="|plugin-vimtex|" AnswerCount="0" CommentCount="2" ClosedDate="2016-01-17T17:38:16.027" ContentLicense="CC BY-SA 3.0" />
  <row Id="6142" PostTypeId="1" CreationDate="2016-01-16T19:54:40.537" Score="8" ViewCount="1157" Body="&lt;pre&gt;&lt;code&gt;# vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 31 2015 23:36:07)&#xA;# cat /root/.vimrc &#xA;map &amp;lt;F2&amp;gt; :w\|!sh % &amp;lt;cr&amp;gt;&#xA;map &amp;lt;F3&amp;gt; :w\|!bash % &amp;lt;cr&amp;gt;&#xA;map &amp;lt;F4&amp;gt; :w\|!python % &amp;lt;cr&amp;gt;&#xA;map &amp;lt;F5&amp;gt; :w\|!python % &amp;amp;&amp;lt;cr&amp;gt;&#xA;&#xA;highlight RedundantWhitespace ctermbg=DarkBlue guibg=red&#xA;match RedundantWhitespace /\s\+$\|\t/&#xA;&#xA;syntax on&#xA;highlight Comment ctermfg=green&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm starting edit highcharts example htm:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vi /var/www/js/highcharts/examples/dynamic-master-detail/index.htm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UKwaP.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UKwaP.gif&quot; alt=&quot;animation of problem&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm navigating through code and I'm using only the arrow keys and the  &lt;kbd&gt;Home&lt;/kbd&gt;, &lt;kbd&gt;Page Up&lt;/kbd&gt;, &lt;kbd&gt;Page Down&lt;/kbd&gt;, and &lt;kbd&gt;End&lt;/kbd&gt; keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After 2 minutes this visual glitch occurs; half of the screen under my cursor loses its syntax highlighting and becomes one color. If I hit &lt;kbd&gt;Page Down&lt;/kbd&gt; or &lt;kbd&gt;Page Up&lt;/kbd&gt;, syntax highlighting is restored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any html code with javascript inside is affected.&lt;/p&gt;&#xA;" OwnerUserId="6039" LastEditorUserId="865" LastEditDate="2016-01-16T23:28:05.540" LastActivityDate="2016-12-18T23:39:01.807" Title="Why does vim blink randomly when I'm navigating through code?" Tags="|highlight|error|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6143" PostTypeId="1" CreationDate="2016-01-16T21:42:40.523" Score="6" ViewCount="1280" Body="&lt;p&gt;I really enjoy the workflow in &lt;a href=&quot;http://www.literatureandlatte.com/scrivener.php&quot; rel=&quot;noreferrer&quot;&gt;Scrivener&lt;/a&gt;, but I don't like the non-vim nature of it. Is there a good alternative plugin for vim that let's you manage documents in a similar way? I'm most interested in the ability to sort and compile documents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal would be to have the ability to edit a document in multiple parts. I'm imagining something like NerdTree, but with the ability to vertically rearrange files in an arbitrary way. It is important that the files are ultimately compiled down into a single document. I imagine that this could be done with Pandoc, but I don't know how well integrated that may be. It would be really slick if there was a way to simply append certain documents together and have that save as a new file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple people have thought about this sort of thing before: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.linuxforums.org/forum/programming-scripting/179648-vim-writers-scrivener-replacement.html&quot; rel=&quot;noreferrer&quot;&gt;http://www.linuxforums.org/forum/programming-scripting/179648-vim-writers-scrivener-replacement.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://parezcoydigo.wordpress.com/2012/12/05/vim-scrivener/&quot; rel=&quot;noreferrer&quot;&gt;https://parezcoydigo.wordpress.com/2012/12/05/vim-scrivener/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4748" LastEditorUserId="4748" LastEditDate="2016-01-18T01:37:08.957" LastActivityDate="2016-01-18T01:37:08.957" Title="Scrivener for Vim?" Tags="|large-documents|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6144" PostTypeId="2" ParentId="6131" CreationDate="2016-01-17T17:45:40.077" Score="11" Body="&lt;p&gt;It's not specific to vim-surround - &lt;code&gt;va'&lt;/code&gt; also selects the leading whitespace. From &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#a%27&quot;&gt;&lt;code&gt;:h a'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&quot;                                                      v_aquote aquote&#xA;a'                                                      v_a' a'&#xA;a`                                                      v_a` a`&#xA;                        &quot;a quoted string&quot;.  Selects the text from the previous&#xA;                        quote until the next quote.  The 'quoteescape' option&#xA;                        is used to skip escaped quotes.&#xA;                        Only works within one line.&#xA;                        When the cursor starts on a quote, Vim will figure out&#xA;                        which quote pairs form a string by searching from the&#xA;                        start of the line.&#xA;                        &lt;strong&gt;Any trailing white space is included, unless there is&#xA;                        none, then leading white space is included.&lt;/strong&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reading on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;i&quot;                                                      v_iquote iquote&#xA;i'                                                      v_i' i'&#xA;i`                                                      v_i` i`&#xA;                        Like a&quot;, a' and a`, but exclude the quotes and&#xA;                        repeating won't extend the Visual selection.&#xA;                        Special case: &lt;strong&gt;With a count of 2 the quotes are&#xA;                        included, but no extra white space as with a&quot;/a'/a`.&lt;/strong&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ys2i')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And with my tests, this worked as desired:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a   'aaa'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Changes to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a   ('aaa')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-01-17T17:45:40.077" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6145" PostTypeId="2" ParentId="5603" CreationDate="2016-01-17T17:57:44.247" Score="1" Body="&lt;p&gt;&lt;code&gt;filetype indent on&lt;/code&gt;, as &lt;a href=&quot;http://vimhelp.appspot.com/filetype.txt.html#%3Afiletype-indent-on&quot; rel=&quot;nofollow&quot;&gt;the documentation&lt;/a&gt; says, loads the corresponding indent file for that filetype. That is, it loads &lt;code&gt;$VIMRUNTIME/indent/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; (and similarly for other directories in &lt;code&gt;runtimepath&lt;/code&gt;). And there is &lt;a href=&quot;https://github.com/vim/vim/tree/master/runtime/indent&quot; rel=&quot;nofollow&quot;&gt;none for &lt;code&gt;markdown&lt;/code&gt;&lt;/a&gt;. Compare (well, even though there's nothing to compare) with &lt;code&gt;indent/go.vim&lt;/code&gt;, which does &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/indent/go.vim#L18&quot; rel=&quot;nofollow&quot;&gt;set &lt;code&gt;autoindent&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; C indentation is too far off useful, mainly due to Go's := operator.&#xA;&quot; Let's just define our own.&#xA;setlocal nolisp&#xA;setlocal autoindent&#xA;setlocal indentexpr=GoIndent(v:lnum)&#xA;setlocal indentkeys+=&amp;lt;:&amp;gt;,0=},0=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, just using &lt;code&gt;filetype indent on&lt;/code&gt; isn't enough, you have to have &lt;code&gt;indent/markdown.vim&lt;/code&gt; somewhere in your &lt;code&gt;runtimepath&lt;/code&gt; set &lt;code&gt;autoindent&lt;/code&gt;. Therefore, create &lt;code&gt;~/.vim/indent/markdown.vim&lt;/code&gt;, containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal autoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or just add &lt;code&gt;set autoindent&lt;/code&gt; to your &lt;code&gt;vimrc&lt;/code&gt;, if it's useful enough across filetypes.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-01-17T17:57:44.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6146" PostTypeId="1" AcceptedAnswerId="6154" CreationDate="2016-01-18T04:48:19.657" Score="2" ViewCount="132" Body="&lt;p&gt;I am taking notes in an outline format that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* Micro topic 1&#xA;** Microbes are small&#xA;** You can't see them!&#xA;*** Isn't that something?&#xA;* Micro topic 2&#xA;** I hope I like the teacher&#xA;*** She will be great!&#xA;** Micro is cool!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where one star is a top level heading, and more stars indicate subheadings as in a typical bullet point outline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to automatically convert them into a .csv file like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;* Micro topic 1&quot;,&quot; &quot;** Microbes are small&quot;, &quot;** You can't see them!&quot;, &quot;*** Isn't that something?&quot;,&#xA;&quot;* Micro topic 2&quot;, &quot;** I hope I like the teacher&quot;, &quot;*** She will be great!&quot;, &quot;** Micro is cool!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where the first column contains only top level headings (lines beginning with one star), and the following columns are subheadings belonging to their parent top level heading.  My challenge is that I don't know how to get vim macros to be aware of when the encounter a new top level heading, and should therefore not join it to the previous line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I've got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i&quot;&#xA;$&quot;,&#xA;J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to surround a line in quotes, add a comma, join with the following line and repeat.  But how to skip joining lines if the next line starts with &lt;code&gt;*&lt;/code&gt;, or regular expression &lt;code&gt;^\*\s&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="6053" LastActivityDate="2016-01-19T11:45:37.597" Title="Convert outline to .csv macro" Tags="|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6147" PostTypeId="2" ParentId="6146" CreationDate="2016-01-18T08:01:17.560" Score="1" Body="&lt;p&gt;You can find the line before the next top level heading with the regexp &lt;code&gt;\n\*[^*]&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\n&lt;/code&gt; newline&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\*&lt;/code&gt; followed by a star&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^*]&lt;/code&gt; not followed by another star (brackets are only for grouping)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This fails at the end of the file. We can use &lt;code&gt;\%$&lt;/code&gt; to find the end of the file in that case, together with the &lt;code&gt;\|&lt;/code&gt; OR operator for vim regeps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you can visually select lines and press &lt;code&gt;J&lt;/code&gt; to join them. Also, reselecting a visual selection is done via &lt;code&gt;gv&lt;/code&gt;. So this works out the following way&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start at a top level heading line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Shift&amp;gt;V&lt;/code&gt; to start linewise visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/\n\*[^*]\|\%$&lt;/code&gt; to go to the line before the next top level heading, or if that fails, to the last line of the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:s/^/&quot;/&lt;/code&gt; to insert at the beginning of each line (the range before &lt;code&gt;s&lt;/code&gt; is inserted automatically for you)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gv&lt;/code&gt; to reselect&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:s/$/&quot;,/&lt;/code&gt; to insert at the end of each line (again, range inserted automatically&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gv&lt;/code&gt; to reselect&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;J&lt;/code&gt; to join all the lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:s/,$//&lt;/code&gt; to delete the last comma (no range neccessary since we operate on the current line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; to go to the next line, a top level heading (fails at the end of the file, which is good)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Put that into a macro, and it will do what you want, as I understand it. Of course, steps 4 to 7 could be done globally prior to the macro, but that way it is suitable for a custom command.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="1296" LastEditDate="2016-01-19T11:45:37.597" LastActivityDate="2016-01-19T11:45:37.597" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6148" PostTypeId="1" AcceptedAnswerId="10942" CreationDate="2016-01-18T11:57:22.193" Score="3" ViewCount="1158" Body="&lt;p&gt;Vim's popup menu is a very cool and modern feature. However, if the list is very long (such as completion) and I keep pressing &lt;code&gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; to navigate through the menu quickly, the popup menu will flash to refresh the content, which is sometimes a little dizzy.&lt;br/&gt;&#xA;So what may be the cause? Is this a limit of the terminal or is there any plugin which make Vim inefficient?&lt;br/&gt;&#xA;Thanks very much!&lt;/p&gt;&#xA;" OwnerUserId="4754" LastActivityDate="2017-01-12T12:49:58.270" Title="How to avoid obvious flash of the popup menu when navigating quickly?" Tags="|vimrc|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6149" PostTypeId="2" ParentId="6148" CreationDate="2016-01-18T12:23:04.007" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;So what may be the cause? Is this a limit of the terminal or is there&#xA;  any plugin which make Vim inefficient?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In order to understand if it is a terminal limitation you could try to reproduce the problem in different terminals and using gVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are suspicious that it could be a plugin that may be causing the problem then you could follow the procedure described on &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-2.5&quot; rel=&quot;nofollow&quot;&gt;Vim-FAQ  2.5&lt;/a&gt;. Some relevant parts follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2.5. I have a &quot;xyz&quot; (some) problem with Vim. How do I determine it is a&#xA;       problem with my setup or with Vim?  / Have I found a bug in Vim?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;First, you need to find out, whether the error is in the actual&#xA;  runtime files or any plugin that is distributed with Vim or whether it&#xA;  is a simple side effect of any configuration option from your .vimrc&#xA;  or .gvimrc. So first, start vim like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;this starts Vim in nocompatible mode (-N), without reading your&#xA;  viminfo file (-i NONE), without reading any configuration file (-u&#xA;  NONE for not reading .vimrc file and -U NONE for not reading a .gvimrc&#xA;  file) or even plugin.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If the error does not occur when starting Vim this way, then the&#xA;  problem is either related to some plugin of yours or some setting in&#xA;  one of your local setup files. You need to find out, what triggers the&#xA;  error, you try starting Vim this way: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;If the error occurs, the problem is your .viminfo file. Simply delete&#xA;  the viminfo file then. If the error does not occur, try: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u ~/.vimrc --noplugin -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This will simply use your .vimrc as configuration file, but not load&#xA;  any plugins. If the error occurs this time, the error is possibly&#xA;  caused by some configuration option inside your .vimrc file. Depending&#xA;  on the length of your vimrc file, it can be quite hard to trace the&#xA;  origin within that file.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The best way is to add :finish command in the middle of your .vimrc.&#xA;  Then restart again using the same command line. If the error still&#xA;  occurs, the bug must be caused because of a setting in the first half&#xA;  of your .vimrc. If it doesn't happen, the problematic setting must be&#xA;  in the second half of your .vimrc. So move the :finish command to the&#xA;  middle of that half, of which you know that triggers the error and&#xA;  move your way along, until you find the problematic option. If your&#xA;  .vimrc is 350 lines long, you need at a maximum 9 tries to find the&#xA;  offending line (in practise, this can often be further reduced, since&#xA;  often lines depend on each other).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If the problem does not occur, when only loading your .vimrc file, the&#xA;  error must be caused by a plugin or another runtime file (indent&#xA;  autoload or syntax script). Check the output of the :scriptnames&#xA;  command to see what files have been loaded and for each one try to&#xA;  disable each one by one and see which one triggers the bug. Often&#xA;  files that are loaded by vim, have a simple configuration variable to&#xA;  disable them, but you need to check inside each file separately.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-01-18T12:23:04.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6150" PostTypeId="1" AcceptedAnswerId="6151" CreationDate="2016-01-18T12:53:44.030" Score="7" ViewCount="199" Body="&lt;p&gt;I'm trying to tune the highlighting in my vim and I'm trying to set some syntax groups via the &lt;code&gt;match&lt;/code&gt; command and highlight them in my &lt;code&gt;vimrc&lt;/code&gt; file, because those groups are generic and do not belong to any particular language syntax file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But my approach works only for a single highlighting, as soon as I add another instance of a &lt;code&gt;highlight/match&lt;/code&gt; pair the previously declared ones do not work, only the last one works until I add another &lt;code&gt;highlight/match&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code (the relevant part) of my vimrc.&#xA;This example works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi NewLineWin ctermfg=248 guifg=#999999&#xA;match NewLineWin /\r\n/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this doesn't (only the last pair of &lt;code&gt;hi/match&lt;/code&gt; does):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi NewLineWin ctermfg=248 guifg=#999999&#xA;match NewLineWin /\r\n/&#xA;hi WhiteSpaceChar ctermfg=252 guifg=#999999&#xA;match WhiteSpaceChar / /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me with this, how to make it work?&lt;/p&gt;&#xA;" OwnerUserId="2798" LastActivityDate="2016-02-16T09:49:20.793" Title="a highlight command resets previously declared highlights" Tags="|vimrc|syntax-highlighting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6151" PostTypeId="2" ParentId="6150" CreationDate="2016-01-18T12:58:42.710" Score="8" Body="&lt;p&gt;From &lt;code&gt;:help :match&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Highlighting matches using :match are limited to three&lt;br&gt;&#xA;  matches (aside from :match, :2match and :3match are&lt;br&gt;&#xA;  available). matchadd() does not have this limitation and in&lt;br&gt;&#xA;  addition makes it possible to prioritize matches.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi NewLineWin ctermfg=248 guifg=#999999&#xA;match NewLineWin /\r\n/&#xA;hi WhiteSpaceChar ctermfg=252 guifg=#999999&#xA;2match WhiteSpaceChar / /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi NewLineWin ctermfg=248 guifg=#999999&#xA;match NewLineWin /\r\n/&#xA;hi WhiteSpaceChar ctermfg=252 guifg=#999999&#xA;call matchadd(&quot;WhiteSpaceChar&quot;, &quot; &quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;matchadd()&lt;/code&gt; also allows further flexibility, such as deleting or prioritising matches. See &lt;code&gt;:help matchadd()&lt;/code&gt; for more details. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, look into syntax highlighting: &lt;code&gt;:help syntax&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-01-18T13:13:08.307" LastActivityDate="2016-01-18T13:13:08.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6152" PostTypeId="2" ParentId="3603" CreationDate="2016-01-18T14:26:54.980" Score="1" Body="&lt;p&gt;There is no mechanism in vim to change built-in commands.&#xA;This is actually a good thing, because you can be sure that default behavior is not changed by plugins.&#xA;Also plugins itself can rely on the default behavior, so such a feature (to change builtin commands) would potentially create a lot of headache. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there any similar mechanism for builtin commands, and in particular for :make? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. If you check vim docs (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_40.html#40.2&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#user-commands&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;), you'll find that &lt;code&gt;:command&lt;/code&gt; only works with custom commands, which should start with capital letter (except Next which is also reserved).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Or should I just define a custom command wrapper that calls the built in one but also adds tab completion?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, this is the way to go.&lt;/p&gt;&#xA;" OwnerUserId="6013" LastActivityDate="2016-01-18T14:26:54.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6153" PostTypeId="2" ParentId="6131" CreationDate="2016-01-18T14:56:53.537" Score="2" Body="&lt;p&gt;I always visually select string before using surround plus I have a mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xmap s S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It saves me a key stroke while surrounding selected string so for me the sequence is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;va's)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[obvious explanation: &quot;select visually everything within and with single quotes and surround selection with parentheses without adding white space&quot;]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternative version: &lt;code&gt;va'sb&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6059" LastActivityDate="2016-01-18T14:56:53.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6154" PostTypeId="2" ParentId="6146" CreationDate="2016-01-18T15:50:50.603" Score="1" Body="&lt;p&gt;Using &lt;code&gt;:global&lt;/code&gt;, I would do this in two parts:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, convert all the lines to strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.*/&quot;&amp;amp;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second, replace newlines on all the lines except the last before each top level heading with commas:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/&quot;\*\{2,}/-1s/\n/,/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pattern for global &lt;code&gt;/&quot;\*\{2,}/&lt;/code&gt; matches all the lines where quote is followed by two or more stars. The command executed for each of these lines is &lt;code&gt;:-1s/\n/,&lt;/code&gt;, i.e. for the line &lt;strong&gt;before&lt;/strong&gt; (&lt;code&gt;-1&lt;/code&gt; as range), substitute newline with a comma.&lt;/p&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2016-01-18T15:50:50.603" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6155" PostTypeId="1" CreationDate="2016-01-18T16:27:47.040" Score="3" ViewCount="1175" Body="&lt;p&gt;I would like to set a different highlighting for windows EOL characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried several approaches and some of them worked when I did &lt;code&gt;: so $MYVIMRC&lt;/code&gt;, which is pretty strange, because after I closed and reopened a file these effects were gone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call matchadd(&quot;NewLineWin&quot;, &quot;\r\n&quot;)&#xA;&#xA;call matchadd(&quot;NewLineWin&quot;, &quot;\r\(\n\)\@=&quot;)&#xA;&#xA;call matchadd(&quot;NewLineWin&quot;, &quot;\r(?=\n)&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And none of these worked after reopening the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no error in the highlight setting, because, if I change the matchadd call to this &lt;code&gt;call matchadd(&quot;NewLineWin&quot;, &quot;\r&quot;)&lt;/code&gt; everything works normally. But I doubt that this is an acceptable approach, since Windows EOL are &lt;code&gt;\r\n&lt;/code&gt; and not simply &lt;code&gt;\r&lt;/code&gt;. Besides, I'm wondering what is wrong with my regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anyone help me with this, please?&lt;/p&gt;&#xA;" OwnerUserId="2798" LastEditorUserId="2798" LastEditDate="2016-01-18T16:33:42.437" LastActivityDate="2016-07-26T13:40:36.727" Title="How to highlight windows end of line characters aka ^M, \r\n?" Tags="|vimrc|syntax-highlighting|regular-expression|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6156" PostTypeId="2" ParentId="6155" CreationDate="2016-01-18T16:47:00.000" Score="1" Body="&lt;p&gt;One must use the dollar &lt;code&gt;$&lt;/code&gt; sign which marks eol in regex expressions which are not in the multiline mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is the substitution of &lt;code&gt;\n&lt;/code&gt; to &lt;code&gt;$&lt;/code&gt; in the first example &lt;code&gt;call matchadd(&quot;NewLineWin&quot;, &quot;\r$&quot;)&lt;/code&gt; did the work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This solution for some yet unknown reason does not work when one opens a file in a new tab, that is when vim is already running&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="2798" LastEditorUserId="2798" LastEditDate="2016-07-26T13:40:36.727" LastActivityDate="2016-07-26T13:40:36.727" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6157" PostTypeId="2" ParentId="3854" CreationDate="2016-01-18T20:06:48.950" Score="6" Body="&lt;p&gt;I think the problem is not &lt;code&gt;:lazyredraw&lt;/code&gt; which, as I understand from docs, should work for functions (see &lt;code&gt;:help :redraw&lt;/code&gt;, it says &quot;Useful to update the screen halfway executing a script or function&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that you use &lt;code&gt;normal&lt;/code&gt; to update buffer and it works like if you actually type something and here &lt;code&gt;:lazyredraw&lt;/code&gt; doesn't have an effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of &lt;code&gt;normal&lt;/code&gt; you need to use text manipulation functions (like &lt;code&gt;setline()&lt;/code&gt;) and ex commands (like &lt;code&gt;:delete&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Compare these two functions, first one, &lt;code&gt;MakeChangesNorm()&lt;/code&gt; will do some crazy screen updates, while the second one, &lt;code&gt;MakeChangesFunctions()&lt;/code&gt; will do the update instantly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MakeChangesNorm()&#xA;    let lastline = line('$')&#xA;    norm gg&#xA;    let linenum = line('.')&#xA;    let lastline = line('$')&#xA;    while linenum &amp;lt; lastline&#xA;        norm ^&#xA;        norm s/choice/test/&#xA;        norm j&#xA;        normal &quot;_3dd&#xA;        let linenum = line('.')&#xA;        let lastline = line('$')&#xA;    endwhile&#xA;endfunction&#xA;&#xA;&#xA;function! MakeChangesFunctions()&#xA;    norm gg&#xA;    let linenum = line('.')&#xA;    let lastline = line('$')&#xA;    while linenum &amp;lt; lastline&#xA;        let line = getline(linenum)&#xA;        &quot; Substitute using substitute() and setline()&#xA;        let line = substitute(line, 'choice', 'test', '')&#xA;        call setline(linenum, line)&#xA;        &quot; Delete lines using :delete&#xA;        execute '.,.+2delete _'&#xA;        let linenum = line('.')&#xA;        let lastline = line('$')&#xA;    endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The file I tested it on looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*choice test2 test3 super&#xA;*choice test2 test3 super&#xA;*choice test2 test3 super&#xA;*choice test2 test3 super&#xA;*choice test2 test3 super&#xA;*choice test2 test3 super&#xA;*choice test2 test3 super&#xA;*choice test2 test3 super&#xA;*choice test2 test3 super&#xA;*choice test2 test3 super&#xA;... 60 lines like this ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6013" LastEditorUserId="6013" LastEditDate="2016-01-19T13:21:22.550" LastActivityDate="2016-01-19T13:21:22.550" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6158" PostTypeId="1" AcceptedAnswerId="6159" CreationDate="2016-01-18T21:39:32.537" Score="2" ViewCount="2553" Body="&lt;p&gt;I record this macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ia^[sb^[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should open insert mode, write a, exit, replace with b, then exit insert mode again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you can bind it to @w with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @w='ia^[sb^['&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For whatever reason instead of a line with &lt;code&gt;b&lt;/code&gt; I get the following &lt;code&gt;a^[sb^[&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something I can do to get the esc key working in my macros? I've tried using &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; instead of &lt;code&gt;^[&lt;/code&gt; as well to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="2541" LastActivityDate="2016-01-18T23:08:08.777" Title="Macro won't exit insert mode with Esc" Tags="|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6159" PostTypeId="2" ParentId="6158" CreationDate="2016-01-18T22:04:48.187" Score="7" Body="&lt;p&gt;It looks like your &lt;code&gt;^[&lt;/code&gt; is not a literal &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. More likely a &lt;code&gt;^&lt;/code&gt; followed by a &lt;code&gt;[&lt;/code&gt; (two characters); &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are supposed to insert a &lt;em&gt;literal&lt;/em&gt; escape character (a single character displayed as &lt;code&gt;^[&lt;/code&gt;). This is done with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; followed by &lt;kbd&gt;Esc&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="51" LastEditDate="2016-01-18T23:08:08.777" LastActivityDate="2016-01-18T23:08:08.777" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6160" PostTypeId="1" AcceptedAnswerId="6161" CreationDate="2016-01-18T23:44:53.697" Score="4" ViewCount="230" Body="&lt;p&gt;Consider this string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 1 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I mark the first two 1s in visual mode and then &lt;code&gt;:'&amp;lt;,'&amp;gt;s/1/2/g&lt;/code&gt;, all 1s on the line are replaced by 2s, not just those in the selected region.  Why is this the case and how can I restrict the operation to the selected text?&lt;/p&gt;&#xA;" OwnerUserId="6066" LastEditorUserId="6066" LastEditDate="2016-01-19T00:54:17.447" LastActivityDate="2016-01-19T01:52:11.833" Title="Why is substitution applied outside the selected region?" Tags="|visual-mode|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6161" PostTypeId="2" ParentId="6160" CreationDate="2016-01-19T01:50:31.823" Score="7" Body="&lt;p&gt;The &lt;code&gt;:s[ubstitue]&lt;/code&gt; command operates on whole lines and the &lt;code&gt;[range]&lt;/code&gt; prefix is a range of lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To restrict the operation to just the visually-selected region, you can use the &lt;code&gt;\%V&lt;/code&gt; atom in your search pattern. That is, visually-select the first two 1s in your example, then use this command to replace just those 1s:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;s/\%V1/2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help /\%V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:help&lt;/code&gt; entry says to put &lt;code&gt;\%V&lt;/code&gt; at the start and end of the pattern, but I didn't read that before trying it and it worked in the example here with &lt;code&gt;\%V&lt;/code&gt; at just the start of the pattern.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2016-01-19T01:50:31.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6162" PostTypeId="2" ParentId="6160" CreationDate="2016-01-19T01:52:11.833" Score="3" Body="&lt;p&gt;That is, because you have provided only a line-based range for the &lt;code&gt;:s&lt;/code&gt; command. There is no way to have an ex command apply to only a column-based selection. Specifically for the &lt;code&gt;:s&lt;/code&gt; command there exists the &lt;code&gt;\%V&lt;/code&gt; regex atom, that allows to substitute within a selection only.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-01-19T01:52:11.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6163" PostTypeId="2" ParentId="6035" CreationDate="2016-01-19T03:17:13.677" Score="3" Body="&lt;p&gt;You can represent the set of non-digit characters with the atom &lt;code&gt;\D&lt;/code&gt; or with the expression &lt;code&gt;[^0-9]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if your definition of an invalid string is any string containing a non-digit character, you could probably detect it like this:&lt;br&gt;&#xA;&lt;code&gt;let debug = value =~ '\D' ? &quot;NO&quot; : &quot;YES&quot;&lt;/code&gt;&lt;br&gt;&#xA;or like this:&lt;br&gt;&#xA;&lt;code&gt;let debug = value =~ '[^0-9]' ? &quot;NO&quot; : &quot;YES&quot;&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can describe a set of characters with a pair of brackets &lt;code&gt;[]&lt;/code&gt;, and then put inside all the characters you want. You could imagine they're separated by the logical operator OR.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[012]  = 0 or 1 or 2&#xA;[0-9]  = 0 or 1 or 2 or ... 9&#xA;[^0-9] = anything except 0 or 1 or ... 9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A caret sign (&lt;code&gt;^&lt;/code&gt;) positioned inside the pair of brackets just after the opening one allows you to invert the set of characters. It could be read as: &lt;em&gt;anything except what follows&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regex engine of Vim provides another kind of notation to describe some sets of characters which are then called atoms. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\d&lt;/code&gt; for digit, same as &lt;code&gt;[0-9]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s&lt;/code&gt; for whitespace, a space or a tab&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\w&lt;/code&gt; for word character, same as &lt;code&gt;[0-9A-Za-z_]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Usually you can &quot;invert&quot; an atom by using an uppercase character (there are some exceptions though):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\D&lt;/code&gt; for non-digit, same as &lt;code&gt;[^0-9]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\S&lt;/code&gt; for non-whitespace, anything except a space or a tab&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\W&lt;/code&gt; for non-word character, same as &lt;code&gt;[^0-9A-Za-z_]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want to know more about the various sets of characters or atoms you can use to build your regexes, see:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help /character-classes&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-01-19T03:22:46.403" LastActivityDate="2016-01-19T03:22:46.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6164" PostTypeId="1" AcceptedAnswerId="6174" CreationDate="2016-01-19T03:58:58.690" Score="8" ViewCount="4968" Body="&lt;p&gt;I'm on Arch, and recently the &lt;code&gt;vim-python3&lt;/code&gt; and &lt;code&gt;gvim-python3&lt;/code&gt; packages were removed, so I'm working on building vim from source such that the &lt;code&gt;:python&lt;/code&gt; command will act as &lt;code&gt;python3&lt;/code&gt;. Specifically, I'm doing this so that the &lt;code&gt;vim-jedi&lt;/code&gt; package will work properly. I tried changing the &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--enable-pythoninterp=dynamic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;flag in my &lt;code&gt;PKGBUILD&lt;/code&gt; to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--disable-pythoninterp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when I did &lt;code&gt;vim --version&lt;/code&gt; after building and installing, it still showed&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+python/dyn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:python import sys;print(sys.version)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;showed python 2 still. What do I need to change to have only python 3?&lt;/p&gt;&#xA;" OwnerUserId="6067" LastEditorUserId="51" LastEditDate="2016-01-19T13:07:32.540" LastActivityDate="2016-01-30T23:34:12.973" Title="How can I build vim with just python 3 support?" Tags="|linux|installing|vimscript-python|linux-arch|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6165" PostTypeId="2" ParentId="5845" CreationDate="2016-01-19T09:20:27.550" Score="6" Body="&lt;p&gt;As @VanLaser &lt;a href=&quot;https://vi.stackexchange.com/questions/5845/do-not-show-mapped-command-in-command-line#comment9550_5845&quot;&gt;mentions in a comment&lt;/a&gt;, you can do this by adding &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; to your map command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;esc&amp;gt; :noh&amp;lt;return&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap-silent&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :map-silent&lt;/code&gt;&lt;/a&gt; explains:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To define a mapping which will not be echoed on the command line, add &quot;&lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt;&quot; as the first argument.  Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;silent&amp;gt; ,h /Header&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;The search string will not be echoed when using this mapping.  Messages from the executed command are still given though.  To shut them up too, add a &quot;:silent&quot; in the executed command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;silent&amp;gt; ,h :exe &quot;:silent normal /Header\r&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Prompts will still be given, e.g., for inputdialog().  &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Using &quot;&lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt;&quot; for an abbreviation is possible, but will cause redrawing of the command line to fail.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="343" LastEditorUserId="205" LastEditDate="2016-01-19T10:09:39.690" LastActivityDate="2016-01-19T10:09:39.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6166" PostTypeId="1" CreationDate="2016-01-19T11:21:30.117" Score="1" ViewCount="787" Body="&lt;p&gt;Currently i'm working on Node.js and I wanted some additional plugins which can help me learning this new technology. I installed tern_for_js and YouCompleteMe from Vundle. I also compiled YCM, but I don't see any auto-completion or any javascript support. Here is my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;&#xA;set number&#xA;set laststatus=2&#xA;set nocompatible&#xA;set expandtab&#xA;set shiftwidth=2&#xA;set smartindent&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'bling/vim-airline'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'ternjs/tern_for_vim'&#xA;Plugin 'Valloric/YouCompleteMe'&#xA;call vundle#end()&#xA;&#xA;:map &amp;lt;F2&amp;gt; :echo 'Current time is ' . strftime('%c')&amp;lt;CR&amp;gt;&#xA;&#xA;set guifont=ProggyCleanTT:h18&#xA;colorscheme torte&#xA;NERDTree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anybody tell me what I'm doing wrong. Or did I miss something? Is there some extra configuration that have to be made?&lt;/p&gt;&#xA;" OwnerUserId="6068" LastEditorUserId="51" LastEditDate="2016-01-19T13:05:18.733" LastActivityDate="2016-01-19T13:05:18.733" Title="vim youcompleteme not working" Tags="|macvim|plugin-you-complete-me|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6167" PostTypeId="1" AcceptedAnswerId="6169" CreationDate="2016-01-19T12:53:29.807" Score="8" ViewCount="576" Body="&lt;p&gt;I would like the first line of some documents I have to be highlighted as a comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match myTypeComment /{apply only to first line}^.*$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I don't know how this regex should work for only one line (e.g. the first line) in syntax matching. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much!&lt;/p&gt;&#xA;" OwnerUserId="6072" LastEditorUserId="51" LastEditDate="2016-01-19T13:18:55.557" LastActivityDate="2016-01-20T17:48:47.163" Title="Define syntax in only one line" Tags="|syntax-highlighting|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6168" PostTypeId="2" ParentId="6167" CreationDate="2016-01-19T13:17:08.540" Score="4" Body="&lt;p&gt;You can use the &lt;code&gt;\%l&lt;/code&gt; regex atom to make sure to match at a particular line. &#xA;So you would likely want something along the lines of this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match myTypeComment /^\%1l#.*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also the help at &lt;code&gt;:h /\%l&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="51" LastEditDate="2016-01-19T17:56:57.580" LastActivityDate="2016-01-19T17:56:57.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6169" PostTypeId="2" ParentId="6167" CreationDate="2016-01-19T13:17:38.190" Score="7" Body="&lt;p&gt;You can use the &lt;code&gt;\%1l&lt;/code&gt;; this will match a specific line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to highlight the first line if it starts with &lt;code&gt;# Hello&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match myTypeComment /\%1l# Hello.*/&#xA;:hi myTypeComment ctermfg=red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also works for other lines (e.g. &lt;code&gt;\%42l&lt;/code&gt; for the 42nd line) and you can use &lt;code&gt;\%42&amp;lt;l&lt;/code&gt; and &lt;code&gt;\%42&amp;gt;l&lt;/code&gt; for lines before or after the 42nd line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5c%25l&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help /\%l&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-01-20T17:48:47.163" LastActivityDate="2016-01-20T17:48:47.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6170" PostTypeId="1" CreationDate="2016-01-19T15:33:36.430" Score="4" ViewCount="175" Body="&lt;p&gt;This might be more of a bash question than vim, but I thought I should start here. Frequently when editing code, it would be &quot;nice&quot; to copy and paste the directory structure into a text editor. For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following directory structure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;img/foo.jpg&#xA;img/foo2.jpg&#xA;img/Another_foo.jpg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm editing a file with the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;img src=&quot;img/foo.jpg&quot;&amp;gt;&#xA;&amp;lt;img src=&quot;img/foo2.jpg&quot;&amp;gt;&#xA;&amp;lt;img src=&quot;img/Another_foo.jpg&quot;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I add more files to the img directory so that it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;img/foo.jpg&#xA;img/foo2.jpg&#xA;img/Another_foo.jpg&#xA;img/bar.gif&#xA;img/bar2.jpg&#xA;img/Another_bar.png&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In graphical editing environments, I would just copy and paste the filenames into the file and quickly get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;img src=&quot;img/foo.jpg&quot;&amp;gt;&#xA;&amp;lt;img src=&quot;img/foo2.jpg&quot;&amp;gt;&#xA;&amp;lt;img src=&quot;img/Another_foo.jpg&quot;&amp;gt;&#xA;&amp;lt;img src=&quot;img/bar.gif&quot;&amp;gt;&#xA;&amp;lt;img src=&quot;img/bar2.jpg&quot;&amp;gt;&#xA;&amp;lt;img src=&quot;img/Another_bar.png&quot;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(For larger filesets, I hack my way through by pasting the directory structure into Excel and then concatenating the code for each line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an easily-reproducible way to do something similar with vim?&lt;/p&gt;&#xA;" OwnerUserId="6075" LastActivityDate="2016-01-21T07:55:07.960" Title="How do I copy the directory structure into the text of a file?" Tags="|cut-copy-paste|substitute|filesystem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6171" PostTypeId="1" AcceptedAnswerId="6173" CreationDate="2016-01-19T15:39:26.553" Score="5" ViewCount="589" Body="&lt;p&gt;I'm trying to set up a plugin to enable indentation guides, following an answer to &lt;a href=&quot;https://vi.stackexchange.com/questions/666/how-to-add-indentation-guides-lines&quot;&gt;this question&lt;/a&gt;. The plugin is &lt;a href=&quot;https://github.com/Yggdroot/indentLine&quot; rel=&quot;nofollow noreferrer&quot;&gt;Yggdroot/indentLine&lt;/a&gt;. It has instructions to set up a custom glyph to be shown instead of the default one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Download and install FontForge.&lt;/li&gt;&#xA;  &lt;li&gt;Locate and open your terminal/gVim font.&lt;/li&gt;&#xA;  &lt;li&gt;Open the font in FontForge, choose Goto from the View menu and select Private Use Area from the drop down box.&lt;/li&gt;&#xA;  &lt;li&gt;In the private use area, locate a blank spot for the glyph. Make a note of the code, e.g. U+E0A3.&lt;/li&gt;&#xA;  &lt;li&gt;Double-click the selected code point to open the font drawing tool.&lt;/li&gt;&#xA;  &lt;li&gt;From the File menu, select Import... and locate the indentLine-dotted-guide.eps file.&lt;/li&gt;&#xA;  &lt;li&gt;Once imported, choose File -&gt; Generate Fonts and choose a location and file type for the new font.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;  &#xA;  &lt;p&gt;Once completed, your new font will contain the more subtle dotted guide and all you have to do is set that glyph to g:indentLine_char in your .vimrc file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I decided to check first if I could to substitute any glyph at all. And I could, I changed the glyph for the &lt;code&gt;A&lt;/code&gt; character to a square and set it as the value of the indentLine_char variable. I got this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mp1Gg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mp1Gg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I tried to define the glyph for a Unicode character from &quot;the Private Use Area&quot;, namely U+DE90, I could not insert it into my vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Copy/paste does not work from FontForge, so directly insert the char into vimrc is impossible, while it was possible to do this with other chars which were not defined by me, like &quot;┆&quot; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I wonder, &lt;strong&gt;may be there is some way to write Unicode characters by their numeric value in a vim script?&lt;/strong&gt; E.g. &lt;code&gt;let foo = \U+12323&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried instructions from &lt;a href=&quot;http://vim.wikia.com/wiki/Entering_special_characters&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim.wikia.com&lt;/a&gt;, but reproduction a described approach&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;By hex value for any Unicode codepoint: ^VUnnnnnnnn (with 00000000 &amp;lt;= nnnnnnnn &amp;lt;= 7FFFFFFF) &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(the keystrokes in order: &lt;code&gt;Ctrl+V&lt;/code&gt;; &lt;code&gt;Shift+U&lt;/code&gt;; &lt;code&gt;d&lt;/code&gt;; &lt;code&gt;e&lt;/code&gt;; &lt;code&gt;9&lt;/code&gt;; &lt;code&gt;0&lt;/code&gt;;) gave me a value in the angle brackets &lt;code&gt;let g:indentLine_char = &amp;lt;de90&amp;gt;&lt;/code&gt; and an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing ~/.vimrc:&#xA;line   16:&#xA;E15: Invalid expression: &amp;lt;de90&amp;gt;&#xA;E15: Invalid expression: &amp;lt;de90&amp;gt;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I tried to enclose it inside brackets, I got another error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;20_Setup..&amp;lt;SNR&amp;gt;20_IndentLinesEnable:&#xA;line   21:&#xA;E844: invalid cchar value&#xA;E475: Invalid argument: IndentLine /\%(^\s\+\)\@&amp;lt;=\%3v / containedin=ALL conceal cchar=&amp;lt;de90&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could anyone suggest something about this, please?&lt;/p&gt;&#xA;" OwnerUserId="2798" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-06-08T17:55:04.790" Title="How can a character be inserted during an edit session by its Unicode numeric value?" Tags="|vimrc|indentation|unicode|string-manipulation|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6172" PostTypeId="2" ParentId="6170" CreationDate="2016-01-19T15:49:31.550" Score="5" Body="&lt;p&gt;First step, insert the file listing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r!ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second step, turn each line into an HTML tag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'[,s/.*/&amp;lt;img src=&quot;&amp;amp;&quot;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :r&lt;/code&gt;, &lt;code&gt;:help range&lt;/code&gt;, &lt;code&gt;:help mark-motions&lt;/code&gt;, and &lt;code&gt;:help :s&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-01-19T15:49:31.550" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6173" PostTypeId="2" ParentId="6171" CreationDate="2016-01-19T16:31:55.197" Score="4" Body="&lt;p&gt;You are close. You need to use this form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let foobar=&quot;\u1234&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &quot;\u&quot; allows to use up to 4 hex digits. Until recently, it was not possible to use more, but with newer Vims you can now use &quot;\U&quot; plus up to 8 hex numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The details are explained at &lt;code&gt;:h expr-quote&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-01-19T16:31:55.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6174" PostTypeId="2" ParentId="6164" CreationDate="2016-01-19T16:43:55.833" Score="7" Body="&lt;p&gt;Thanks to x33a on the Arch forums, I was able to solve my problem. (&lt;a href=&quot;https://bbs.archlinux.org/viewtopic.php?pid=1596987#p1596987&quot; rel=&quot;noreferrer&quot;&gt;https://bbs.archlinux.org/viewtopic.php?pid=1596987#p1596987&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I changed the python 3 flag from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--enable-python3interp=dyanmic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--enable-python3interp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This resulted in only python 3 being available.&lt;/p&gt;&#xA;" OwnerUserId="6067" LastActivityDate="2016-01-19T16:43:55.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6175" PostTypeId="2" ParentId="6171" CreationDate="2016-01-19T17:55:48.017" Score="4" Body="&lt;p&gt;Pressing &lt;code&gt;&amp;lt;C-v&amp;gt;ude90&lt;/code&gt; in insert mode should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is probably:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:indentLine_char = &amp;lt;de90&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is missing quotes; it should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:indentLine_char = &quot;&amp;lt;de90&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(where &lt;code&gt;&amp;lt;de90&amp;gt;&lt;/code&gt; is entered with &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;, and not 6 separate characters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &#xA;&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL%2dV&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help i_CTRL-V&lt;/code&gt;&lt;/a&gt; and &#xA;&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL%2dV_digit&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help i_CTRL-V_digit&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-01-19T17:55:48.017" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6176" PostTypeId="1" CreationDate="2016-01-19T21:58:17.653" Score="2" ViewCount="692" Body="&lt;p&gt;I just discovered eclim, I am trying to run Java in my first project with &lt;code&gt;:Java&lt;/code&gt; but it could not find the main class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I create the project with &lt;code&gt;:ProjectCreate test -n java&lt;/code&gt;, open a file test/src/test.java and put the following in it &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Test {&#xA;    public static void main(String[] args) {&#xA;        System.out.println(&quot;Hello, this is a test.&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;save it, and then run &lt;code&gt;:Java&lt;/code&gt; and get the error &lt;code&gt;Could not find or load main class main&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The .classpath looks like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&#xA;&amp;lt;classpath&amp;gt;&#xA;    &amp;lt;classpathentry kind=&quot;src&quot; path=&quot;src&quot;/&amp;gt;&#xA;    &amp;lt;classpathentry kind=&quot;con&quot; path=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot;/&amp;gt;&#xA;    &amp;lt;classpathentry kind=&quot;output&quot; path=&quot;bin&quot;/&amp;gt;&#xA;&amp;lt;/classpath&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6078" LastEditorUserId="51" LastEditDate="2016-01-20T03:12:12.987" LastActivityDate="2016-01-20T03:12:12.987" Title="Eclim Could not find or load main class main" Tags="|plugin-eclim|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6177" PostTypeId="1" CreationDate="2016-01-19T23:21:18.950" Score="22" ViewCount="2210" Body="&lt;p&gt;I want to be able to easily start Vim in a private mode. Let's define a private mode as one that utilizes this set of commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set history=0&#xA;set nobackup&#xA;set nomodeline&#xA;set noshelltemp&#xA;set noswapfile&#xA;set noundofile&#xA;set nowritebackup&#xA;set secure&#xA;set viminfo=&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Let me know if you can think of any additional commands suitable for the private mode.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point is I cannot think of any short and easy way to start Vim with this setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some ideas I've come up with:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;h3&gt;Load .vimrcprivate instead of .vimrc&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can simply put all the necessary commands into .vimrcprivate and start Vim like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u .vimrcprivate&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h3&gt;Define and call a &lt;code&gt;Private()&lt;/code&gt; function&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Another idea add a code like this to your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Private()&#xA;    &quot; set of commands here&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then you are able to start Vim in a private mode like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; vim -c 'call Private()'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h3&gt;Use a variable to trigger the setting up of your commands&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;It is quite similar to the second solution.&#xA;Just add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('privatemode')&#xA;    &quot; set of commands here&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your .vimrc and then start Vim using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c 'let privatemode=1'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is neither smart nor short.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h3&gt;Add an alias to your .bashrc (or to any other .*rc file your shell is using)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vimprivate=&quot;vim +\&quot;set history=0\&quot; +\&quot;set nobackup\&quot; +\&quot;set nomodeline\&quot;\&#xA;    +\&quot;set noshelltemp\&quot; +\&quot;set noswapfile\&quot; +\&quot;set noundofile\&quot;\ &#xA;    +\&quot;set nowritebackup\&quot; +\&quot;set secure\&quot; +\&quot;set viminfo=\&quot;\&quot;\&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is awful. I don't like it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h3&gt;Use an environmental variable&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Just run &lt;code&gt;VIM_PRIVATE=1 vim&lt;/code&gt; and add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if $VIM_PRIVATE&#xA;    &quot; set of commands here&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your .vimrc.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h3&gt;Some &lt;em&gt;magic&lt;/em&gt; (from a comment by &lt;a href=&quot;https://vi.stackexchange.com/users/51/carpetsmoker&quot;&gt;Carpetsmoker&lt;/a&gt; in &lt;a href=&quot;https://vi.stackexchange.com/questions/834/prevent-vim-from-recording-events-for-certain-filetypes/1940#1940&quot;&gt;this thread&lt;/a&gt;)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Carpetsmoker says in &lt;a href=&quot;https://vi.stackexchange.com/questions/834/prevent-vim-from-recording-events-for-certain-filetypes/1940#comment1861_1940&quot;&gt;this comment&lt;/a&gt; that&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I would not recommend using a separate vimrc file, for the simple reason &gt; that it's so easy to forget. Something like this autocmd: &lt;code&gt;au BufRead * if &amp;amp;cryptmethod != &quot;&quot; | setlocal nobackup noundofile ... | endif&lt;/code&gt; should do the magic for you, and it's impossible to forget.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However I've got no idea how this magic works &lt;em&gt;yet&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Have you got any idea? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The perfect solution would be &lt;code&gt;vim -private&lt;/code&gt; or &lt;code&gt;vim +Private&lt;/code&gt; however:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I am quite sure you cannot add you own custom command line options like &lt;code&gt;-private&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;li&gt;when it comes to &lt;code&gt;+Private&lt;/code&gt; I was unable to find it online.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6043" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2021-03-22T11:02:17.433" Title="The simplest way to start Vim in private mode" Tags="|vimscript|vimrc|options|startup|security|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6178" PostTypeId="1" AcceptedAnswerId="6179" CreationDate="2016-01-20T01:35:08.350" Score="13" ViewCount="1752" Body="&lt;p&gt;Does neovim set any environment variables that would let me detect from bash that the terminal is neovim? I want to change the behavior of my &lt;code&gt;.bashrc&lt;/code&gt; if neovim is the terminal.&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2016-01-20T03:19:29.623" Title="Detect neovim terminal from bash in bashrc" Tags="|terminal|neovim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6179" PostTypeId="2" ParentId="6178" CreationDate="2016-01-20T02:26:17.867" Score="16" Body="&lt;p&gt;I compared the output of running &lt;code&gt;env&lt;/code&gt; in a standard terminal to the output when running it within Neovim, and it looks like these variables are new:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIMRUNTIME=/usr/local/Cellar/neovim/HEAD/share/nvim/runtime&#xA;VIM=/usr/local/Cellar/neovim/HEAD/share/nvim&#xA;NVIM_LISTEN_ADDRESS=/var/folders/_8/sy7jjpw55mbgn2prml0fbsgc0000gn/T/nvimaLHjPR/0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The &lt;code&gt;vim&lt;/code&gt; I have also has &lt;code&gt;$VIM&lt;/code&gt; and &lt;code&gt;$VIMRUNTIME&lt;/code&gt; so their mere presence doesn't indicate Neovim vs Vim...)&lt;/p&gt;&#xA;" OwnerUserId="67" LastEditorUserId="67" LastEditDate="2016-01-20T02:34:36.677" LastActivityDate="2016-01-20T02:34:36.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6180" PostTypeId="2" ParentId="2634" CreationDate="2016-01-20T02:52:37.830" Score="1" Body="&lt;p&gt;Not quite the solution to your shell-within-vim issue, but if you ever find yourself in a shell (outside vim) wishing you could use vim-style navigation or edits on the shell command you just typed out (or pulled up via the history), you might be interested in the shell's &quot;vi mode&quot;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;When you enter a line in vi mode, you are already placed in 'insertion' mode, as if you had typed an 'i'. Pressing ESC switches you into 'command' mode, where you can edit the text of the line with the standard vi movement keys, move to previous history lines with 'k' and subsequent lines with 'j', and so forth.&quot; [&lt;a href=&quot;http://www.gnu.org/software/bash/manual/html_node/Readline-vi-Mode.html&quot; rel=&quot;nofollow&quot;&gt;GNU's bash reference&lt;/a&gt;]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Enable this mode by typing &lt;code&gt;set -o vi&lt;/code&gt; in Bash, or sticking that line into &lt;code&gt;.bashrc&lt;/code&gt;. It starts you off in Insert mode, but &lt;code&gt;Esc&lt;/code&gt; and you can navigate and edit like you're in vi.&lt;/p&gt;&#xA;" OwnerUserId="67" LastActivityDate="2016-01-20T02:52:37.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6181" PostTypeId="2" ParentId="6178" CreationDate="2016-01-20T03:19:29.623" Score="11" Body="&lt;p&gt;Aside from alxndr's example, you can set one yourself with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let $IN_NEOVIM = &quot;yes&quot;&#xA;:terminal&#xA;$ env | grep NEOVIM&#xA;IN_NEOVIM=yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is especially useful as a simple way to pass information to the shell; for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let $NEOVIM_FILETYPE = &amp;amp;filetype&#xA;:terminal&#xA;$ env | grep NEOVIM&#xA;NEOVIM_FILETYPE=python    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-01-20T03:19:29.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6182" PostTypeId="1" AcceptedAnswerId="6193" CreationDate="2016-01-20T06:40:03.553" Score="9" ViewCount="4828" Body="&lt;p&gt;Lately I've found myself working more and more with remote servers over SSH.  Most of those severs don't have Vim, but just Vi.  Using it hasn't been too rough with just a few problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One is this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/3328/how-to-replace-a-word-with-a-yanked-word-in-normal-mode&quot;&gt;How to replace a word with a yanked word in normal mode&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The accepted answer (and the way I've always done things) uses visual mode which often isn't compiled into what I need to use (yank text, visual over text to be replace, put).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;How  can I do this in Vi?&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="2221" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-01-21T08:48:09.073" Title="How can I replace a word with a yanked word in Vi?" Tags="|cut-copy-paste|replace|original-vi|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6184" PostTypeId="1" CreationDate="2016-01-20T13:02:27.157" Score="6" ViewCount="2269" Body="&lt;p&gt;I have just created a file &lt;code&gt;.html&lt;/code&gt;. When I run &lt;code&gt;set filetype?&lt;/code&gt; I get &lt;code&gt;filetype=html&lt;/code&gt;. Then I select this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;&amp;lt;span&amp;gt;&#xA;&amp;lt;/span&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and press &lt;code&gt;=&lt;/code&gt; but the code is not indented... I don't have problems to indent &lt;code&gt;php&lt;/code&gt; files for example using the same procedure.&lt;/p&gt;&#xA;" OwnerUserId="6086" LastActivityDate="2018-06-21T23:35:52.443" Title="HTML is not being indented" Tags="|indentation|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6185" PostTypeId="2" ParentId="6184" CreationDate="2016-01-20T13:22:16.267" Score="2" Body="&lt;p&gt;Try checking the options mentioned in &lt;code&gt;:help =&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;={motion}   Filter {motion} lines through the external program&#xA;            given with the 'equalprg' option.  When the 'equalprg'&#xA;            option is empty (this is the default), use the&#xA;            internal formatting function |C-indenting| and&#xA;            |'lisp'|.  But when 'indentexpr' is not empty, it will&#xA;            be used instead |indent-expression|.  When Vim was&#xA;            compiled without internal formatting then the &quot;indent&quot;&#xA;            program is used as a last resort.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it is working in php files, try comparing the values of the relevant options in each of them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your example works fine here, and the command &lt;code&gt;:4verbose setlocal equalprg indentexpr&lt;/code&gt; prints the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  equalprg=&#xA;  indentexpr=HtmlIndent()&#xA;    Last set from /usr/local/share/vim/vim74/indent/html.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-01-20T13:22:16.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6187" PostTypeId="1" CreationDate="2016-01-20T15:01:09.173" Score="8" ViewCount="514" Body="&lt;p&gt;Assume I have the text &lt;code&gt;Fnord&lt;/code&gt; yanked before and that my cursor resides on the &lt;code&gt;B&lt;/code&gt; of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;M:mock(Baz)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I change the text inside () with the previously yanked text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I often make the mistake by doing:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;di(&lt;/code&gt; aka &quot;delete inside ()&quot; &lt;/li&gt;&#xA;&lt;li&gt;SHIFT+P&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;yet which leaves me with the exact text again, as the deleted text will be moved to the register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;M:mock(Fnord)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5449" LastEditorUserId="5449" LastEditDate="2016-01-21T09:35:25.007" LastActivityDate="2016-01-21T09:35:25.007" Title="How to replace text inside () with previously yanked text?" Tags="|cut-copy-paste|normal-mode|register|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6188" PostTypeId="2" ParentId="6187" CreationDate="2016-01-20T15:17:27.057" Score="1" Body="&lt;p&gt;Assuming &quot;Fnord&quot; is in register a you can do (with the cursor at the beginning of the line)&#xA;&lt;code&gt;f(ci(&amp;lt;c-r&amp;gt;a&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-01-20T15:17:27.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6189" PostTypeId="2" ParentId="6187" CreationDate="2016-01-20T15:17:30.113" Score="10" Body="&lt;p&gt;Unless you specify a register, &lt;code&gt;p&lt;/code&gt; (or &lt;code&gt;P&lt;/code&gt;) will use the last register that was filled. The unnamed register &lt;code&gt;&quot;&quot;&lt;/code&gt; contains the most recently yanked or deleted text (unless another register was specified, e.g. with &lt;code&gt;&quot;ay&lt;/code&gt;), but these also go into &lt;code&gt;&quot;0&lt;/code&gt; for yanks or &lt;code&gt;&quot;1&lt;/code&gt; for deletes/changes. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#registers&quot;&gt;registers&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the last text was yanked with &lt;code&gt;y&lt;/code&gt; you can paste it from the &lt;code&gt;0&lt;/code&gt; register with &lt;code&gt;&quot;0P&lt;/code&gt;. If it was deleted, you could access it with the &lt;code&gt;2&lt;/code&gt; register  with &lt;code&gt;&quot;2P&lt;/code&gt; (&lt;code&gt;&quot;1&lt;/code&gt; is now &lt;code&gt;Baz&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you could avoid messing with your registers and delete to the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#quote_&quot;&gt;blackhole register &lt;code&gt;&quot;_&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;_di(P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4655" LastEditorUserId="4655" LastEditDate="2016-01-20T15:53:34.177" LastActivityDate="2016-01-20T15:53:34.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6190" PostTypeId="2" ParentId="6187" CreationDate="2016-01-20T16:17:48.140" Score="14" Body="&lt;p&gt;You can use visual selection to select the text to replace, and then paste over it as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vi(p&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vi(&lt;/code&gt; selects Baz (because it is enclosed in parenthesis), &lt;code&gt;p&lt;/code&gt; pastes Fnord over it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this will yank Baz to the register after the paste, which might not be what you want.&lt;/p&gt;&#xA;" OwnerUserId="1402" LastActivityDate="2016-01-20T16:17:48.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6191" PostTypeId="2" ParentId="6187" CreationDate="2016-01-20T16:33:16.880" Score="3" Body="&lt;p&gt;If installing plugins is an option, you could use &lt;a href=&quot;https://github.com/maxbrunsfeld/vim-yankstack&quot; rel=&quot;nofollow&quot;&gt;yankstack.vim&lt;/a&gt;. Then you could retain you current workflow:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Currently, I often make the mistake by doing:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;di( aka &quot;delete inside ()&quot;&lt;/li&gt;&#xA;  &lt;li&gt;SHIFT+P&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Alt+p  - cycle to the previous yank&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-01-20T16:33:16.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6192" PostTypeId="2" ParentId="2634" CreationDate="2016-01-20T18:42:29.953" Score="5" Body="&lt;p&gt;Actually &lt;code&gt;VimShell&lt;/code&gt; does what you want and allows to edit both command line and the text generated by previous commands.&#xA;Other vim shells I tried do not allow this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nvim's terminal also doesn't allow terminal buffer editing, you can't even edit the current command line in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also works in emacs &lt;code&gt;shell&lt;/code&gt; (checked in spacemacs), &lt;code&gt;term&lt;/code&gt; and &lt;code&gt;eshell&lt;/code&gt; both allow edit only the command line, but in &lt;code&gt;shell&lt;/code&gt; you can also edit the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bmmon.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bmmon.png&quot; alt=&quot;Vim with VimShell on the left, spacemacs with shell on the right&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6013" LastActivityDate="2016-01-20T18:42:29.953" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6193" PostTypeId="2" ParentId="6182" CreationDate="2016-01-20T20:46:19.770" Score="9" Body="&lt;p&gt;This is answered to some degree in &lt;a href=&quot;https://vi.stackexchange.com/a/3376/4676&quot;&gt;statox's answer&lt;/a&gt; to the question you linked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key to your question is an understanding of &lt;a href=&quot;http://3.bp.blogspot.com/-Mp8uW2YRtsQ/TyVC1_JDanI/AAAAAAAAASI/hDfS9m7E3iY/s1600/vim_regs_p1.png&quot; rel=&quot;noreferrer&quot;&gt;vi's &lt;em&gt;registers&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you yank text, it gets placed in register 0, and the &lt;em&gt;unnamed register&lt;/em&gt; gets &lt;em&gt;pointed&lt;/em&gt; to register 0.  When you delete text, it gets placed in register 1, and the unnamed register gets pointed to register 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you &quot;put&quot; text, it gets pasted from the unnamed register by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can specify what register you want to paste from or copy into.  That's what the double-quote (&lt;code&gt;&quot;&lt;/code&gt;) key does: specify a register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there are several simple approaches, any of which will work.  The two basic approaches are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Yank the text you are going to paste just as you usually would (perhaps with &lt;code&gt;yw&lt;/code&gt;, delete the text you want to overwrite just as you usually would (with &lt;code&gt;dw&lt;/code&gt;), then paste &lt;em&gt;from register 0&lt;/em&gt; by typing &lt;code&gt;&quot;0P&lt;/code&gt; or &lt;code&gt;&quot;0p&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Yank the text as usual with &lt;code&gt;yw&lt;/code&gt;, then delete the text you want to overwrite &lt;em&gt;into the black hole register&lt;/em&gt; by typing &lt;code&gt;&quot;_dw&lt;/code&gt;, then paste with &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;P&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You could also yank into a named register (&lt;code&gt;&quot;kye&lt;/code&gt; to yank into register &lt;code&gt;k&lt;/code&gt;, for example) and then paste from that register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the operation to be repeatable with the &lt;code&gt;.&lt;/code&gt; command and perform it in one step, you could also use &lt;code&gt;&quot;_ce&lt;/code&gt; to &quot;change to the end of the word&quot;, dumping the word being changed into the black hole register, and then type &lt;code&gt;&amp;lt;C-r&amp;gt;0&amp;lt;Esc&amp;gt;&lt;/code&gt; while in insert mode to paste from register 0 and exit insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: As pointed out in the comments, some of the above approaches may use Vim extensions.  An approach that strictly uses &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html&quot; rel=&quot;noreferrer&quot;&gt;POSIX &lt;code&gt;vi&lt;/code&gt; features&lt;/a&gt; but is perhaps not as handy is, yank the word you want into a named register (I'll say register k) by using &lt;code&gt;&quot;kye&lt;/code&gt;, then delete the word you don't want with &lt;code&gt;de&lt;/code&gt;, and paste in the word you yanked with &lt;code&gt;&quot;kP&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-01-21T08:48:09.073" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6194" PostTypeId="1" AcceptedAnswerId="6197" CreationDate="2016-01-20T21:45:26.273" Score="25" ViewCount="8101" Body="&lt;p&gt;This has always bugged me about the &lt;code&gt;w&lt;/code&gt; and &lt;code&gt;W&lt;/code&gt; motion commands—they seem to work differently when used with the &lt;code&gt;c&lt;/code&gt;hange command than they do when used alone, or with the &lt;code&gt;d&lt;/code&gt;elete command.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For example, with the cursor on the &quot;q&quot; of this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The quick brown fox jumps over the lazy dog.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;typing &lt;code&gt;dw&lt;/code&gt; results in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The brown fox jumps over the lazy dog.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and typing &lt;code&gt;de&lt;/code&gt; results in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The  brown fox jumps over the lazy dog.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Notice the two spaces between &quot;The&quot; and &quot;brown&quot;.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;y&lt;/code&gt;ank command also treats &lt;code&gt;w&lt;/code&gt; and &lt;code&gt;e&lt;/code&gt; differently, as can be shown by comparing &lt;code&gt;yeP&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The quickquick brown fox jumps over the lazy dog.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;ywP&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The quick quick brown fox jumps over the lazy dog.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However, typing either &lt;code&gt;ceslow&amp;lt;Esc&amp;gt;&lt;/code&gt; or &lt;code&gt;cwslow&amp;lt;Esc&amp;gt;&lt;/code&gt; results in the same thing&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The slow brown fox jumps over the lazy dog.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this documented somewhere?  What is the logic behind it and how can I predict the results of a command that uses &lt;code&gt;w&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2022-03-22T02:13:29.083" Title="Why do `cw` and `ce` do the same thing?" Tags="|cursor-motions|vi-words|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6195" PostTypeId="1" AcceptedAnswerId="6205" CreationDate="2016-01-20T22:49:35.273" Score="0" ViewCount="124" Body="&lt;p&gt;There is &lt;a href=&quot;https://vi.stackexchange.com/questions/834/prevent-vim-from-recording-events-for-certain-filetypes/1940#comment1861_1940&quot;&gt;a comment&lt;/a&gt; by &lt;a href=&quot;https://vi.stackexchange.com/users/51/&quot;&gt;Carpetsmoker&lt;/a&gt; which suggests a way to &lt;a href=&quot;https://vi.stackexchange.com/questions/834/prevent-vim-from-recording-events-for-certain-filetypes/&quot;&gt;prevent Vim from recording events for certain filetypes&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I would not recommend using a separate vimrc file, for the simple reason that it's so easy to forget. Something like this autocmd: &lt;code&gt;au BufRead * if &amp;amp;cryptmethod != &quot;&quot; | setlocal nobackup noundofile ... | endif&lt;/code&gt; should do the magic for you, and it's impossible to forget. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I am not sure if I understand how it is suppose to work. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Questions:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Do I have to basically start Vim with an option like this: &lt;code&gt;vim +&quot;set cryptmethod=blowfish&quot;&lt;/code&gt; to trigger the &lt;code&gt;setlocal nobackup noundofile ...&lt;/code&gt; section of the autocommand from the comment?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does Carpetsmoker say that the crytpmethod way is superior to the separate vimrc way?&lt;br&gt;&#xA;As I think of it, both &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u ~/.vimrc-incognito&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +&quot;set cryptmethod=blowfish&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;are equally easy to forget. &lt;/p&gt;&#xA;" OwnerUserId="6043" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-01-21T13:15:06.250" Title="Why is an autocmd using cryptmethod a better way to prevent Vim from recording events than a separate vimrc?" Tags="|vimrc|autocmd|security|encryption|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6196" PostTypeId="1" AcceptedAnswerId="6198" CreationDate="2016-01-20T23:36:12.407" Score="12" ViewCount="1585" Body="&lt;p&gt;On bash's readline in emacs mode, I recently discovered the &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_node/emacs/Transpose.html&quot; rel=&quot;noreferrer&quot;&gt;transpose&lt;/a&gt; functionality, giving me the opportunity to quickly fix a typo like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dc dir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd dir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by pressing &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;T&lt;/kbd&gt; on the &lt;code&gt;c&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something similar in Vi/Vim that lets me swap characters and words around?&lt;/p&gt;&#xA;" OwnerUserId="5449" LastEditorUserId="205" LastEditDate="2016-01-24T02:27:11.503" LastActivityDate="2018-11-13T13:17:16.060" Title="How do I flip characters or words like emacs' transpose?" Tags="|normal-mode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6197" PostTypeId="2" ParentId="6194" CreationDate="2016-01-20T23:44:41.597" Score="27" Body="&lt;p&gt;It's a special case. Check &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#WORD&quot;&gt;the documentation for WORD&lt;/a&gt;, under &quot;Special case&quot;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Special case: &quot;cw&quot; and &quot;cW&quot; are treated like &quot;ce&quot; and &quot;cE&quot; if the cursor is on a non-blank.  This is because &quot;cw&quot; is interpreted as&#xA;  change-word, and a word does not include the following white space. &#xA;  {Vi: &quot;cw&quot; when on a blank followed by other blanks changes only the&#xA;  first blank; this is probably a bug, because &quot;dw&quot; deletes all the&#xA;  blanks}&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Another special case: When using the &quot;w&quot; motion in combination with an&#xA;  operator and the last word moved over is at the end of a line, the end&#xA;  of that word becomes the end of the operated text, not the first word&#xA;  in the next line.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The original Vi implementation of &quot;e&quot; is buggy.  For example, the &quot;e&quot;&#xA;  command will stop on the first character of a line if the previous&#xA;  line was empty. But when you use &quot;2e&quot; this does not happen.  In Vim&#xA;  &quot;ee&quot; and &quot;2e&quot; are the same, which is more logical.  However, this&#xA;  causes a small incompatibility between Vi and Vim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4932" LastEditorUserId="205" LastEditDate="2016-01-21T13:17:51.350" LastActivityDate="2016-01-21T13:17:51.350" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6198" PostTypeId="2" ParentId="6196" CreationDate="2016-01-21T00:48:14.240" Score="15" Body="&lt;p&gt;For characters, it's fairly simple: &lt;code&gt;xp&lt;/code&gt; to swap the letter under the cursor with the following letter, and &lt;code&gt;Xp&lt;/code&gt; to swap the letter under the cursor with the previous letter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;x&lt;/code&gt; command deletes the character under the cursor, leaving the cursor on the next character.  The &lt;code&gt;X&lt;/code&gt; command deletes the character just before the cursor, leaving the cursor on the same character it was on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;p&lt;/code&gt; puts (pastes) the last deleted or last yanked text just after the current cursor position.  (&lt;code&gt;P&lt;/code&gt; puts it just before the current cursor position, so &lt;code&gt;xP&lt;/code&gt; and &lt;code&gt;XP&lt;/code&gt; both leave the text the way it was before you started.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For swapping words, I'm not sure; perhaps someone else can answer that.  You can come close with &lt;code&gt;dawwP&lt;/code&gt; (or remap it to be shorter) but that will break on several edge cases, for example near the end of a line.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="4676" LastEditDate="2016-01-21T01:08:20.960" LastActivityDate="2016-01-21T01:08:20.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6199" PostTypeId="1" AcceptedAnswerId="6200" CreationDate="2016-01-21T02:02:04.623" Score="5" ViewCount="606" Body="&lt;p&gt;Is there a way that I can use the &lt;code&gt;'mouse'&lt;/code&gt; option to disable all mouse functions in MacVim?&lt;/p&gt;&#xA;" OwnerUserId="6098" LastEditorUserId="865" LastEditDate="2016-01-21T02:14:00.950" LastActivityDate="2019-03-15T14:29:43.447" Title="How can I disable all mouse functions in MacVim?" Tags="|vimrc|macvim|mouse|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6200" PostTypeId="2" ParentId="6199" CreationDate="2016-01-21T02:18:23.487" Score="9" Body="&lt;p&gt;To disable all mouse functions, you can simply put this in your &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more, see &lt;code&gt;:help 'mouse'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2016-01-21T02:18:23.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6203" PostTypeId="1" AcceptedAnswerId="6204" CreationDate="2016-01-21T09:43:18.600" Score="3" ViewCount="246" Body="&lt;p&gt;I a have PHP syntax highlighting file in &lt;code&gt;~/.vim/syntax/php.vim&lt;/code&gt;. Thus, PHP functions are highlighted differently than my own custom functions and Wordpress functions. Therefore, VIM does have a way to determine if a function is a PHP built-in or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;a href=&quot;https://stackoverflow.com/a/16328217/343302&quot;&gt;this script&lt;/a&gt; slightly modified to open PHP and Wordpress documentation from within VIM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BrowseDoc()&#xA;    if b:current_syntax == &quot;php&quot;&#xA;        ! firefox &quot;http://php.net/manual-lookup.php?pattern=&amp;lt;cword&amp;gt;&quot;&#xA;        ! firefox &quot;https://codex.wordpress.org/Function_Reference/&amp;lt;cword&amp;gt;&quot;&#xA;    elseif b:current_syntax == &quot;perl&quot;&#xA;        ! firefox &quot;http://perldoc.perl.org/search.html?q=&amp;lt;cword&amp;gt;&quot;&#xA;    elseif b:current_syntax == &quot;python&quot;&#xA;        ! firefox &quot;https://docs.python.org/3.5/search.html?q=&amp;lt;cword&amp;gt;&quot;&#xA;    else&#xA;        return&#xA;    endif&#xA;endfunction&#xA;map &amp;lt;leader&amp;gt;ff :call BrowseDoc()&amp;lt;Return&amp;gt;&amp;lt;Return&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How might I use the VIM feature that determines if a function is to be highlighted as PHP or not to determine if php.net or wordpress.org documentation should be opened?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the &lt;code&gt;phpFunctions&lt;/code&gt; syn keyword in the syntax file, but I've been unable to figure out how to query if the word under the cursor is a member of that family or not.&lt;/p&gt;&#xA;" OwnerUserId="989" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-01-21T16:00:19.080" Title="Vimscript `if` on based on highlighting file" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6204" PostTypeId="2" ParentId="6203" CreationDate="2016-01-21T10:53:19.090" Score="6" Body="&lt;p&gt;You can determine the current syntax group with this expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;count(map(synstack(line('.'), col('.')), 'synIDattr(v:val, &quot;name&quot;)'), &quot;phpFunction&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which should return &lt;code&gt;1&lt;/code&gt; if the word under the cursor belongs to the &lt;code&gt;phpFunction&lt;/code&gt; group and &lt;code&gt;0&lt;/code&gt; if it doesn't.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-01-21T14:04:41.883" LastActivityDate="2016-01-21T14:04:41.883" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6205" PostTypeId="2" ParentId="6195" CreationDate="2016-01-21T11:49:50.920" Score="3" Body="&lt;p&gt;Note that the original question was asking about how to prevent leakage of sensitive information &lt;em&gt;every time&lt;/em&gt; certain filetypes are edited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The essential point that @Carpetsmoker was trying to make is that this feature should be automatic, because anything manual is easy to forget.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that he wrote: &quot;&lt;strong&gt;&lt;em&gt;Something like&lt;/em&gt;&lt;/strong&gt; this autocmd&quot; (emphasis mine), so this code isn't necessarily supposed to be a full answer. I &lt;em&gt;think&lt;/em&gt; he may have misremembered the encryption options slightly, and meant to check &lt;code&gt;'key'&lt;/code&gt;, which is set if and only if encryption is being used, rather than &lt;code&gt;'cryptmethod'&lt;/code&gt;, which is set by default to &lt;code&gt;'zip'&lt;/code&gt;*. Seeing as the original question was about filetypes though, the following might have been a simpler illustration of his concept:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead *.[sensitive filetype] setlocal nobackup noundofile ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use your examples, he's &lt;em&gt;not&lt;/em&gt; suggesting you should use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +&quot;set cryptmethod=blowfish&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u ~/.vimrc-incognito&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;He's suggesting you should configure Vim is such a way that you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# automatic, impossible to forget&#xA;vim filename.[sensitive filetype]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# manual, easy to forget&#xA;vim -u ~/.vimrc-incognito filename.[sensitive filetype]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...which is an obvious improvement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of this is really relevant to what you are trying to do, however, which is specifically to create a feature that is &lt;em&gt;not&lt;/em&gt; limited to certain filetypes and which &lt;em&gt;does&lt;/em&gt; need to be turned on manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* and I suspect even this wouldn't actually work well, as I don't &lt;em&gt;think&lt;/em&gt; this autocmd would fire when setting the key with &lt;code&gt;:X&lt;/code&gt;&amp;thinsp;&amp;mdash;&amp;thinsp;I haven't tested this, though.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2016-01-21T11:49:50.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6206" PostTypeId="1" AcceptedAnswerId="6212" CreationDate="2016-01-21T13:21:44.867" Score="6" ViewCount="636" Body="&lt;p&gt;I use the shift keys a lot and it is an unnecessary strain on the pinky. The &lt;code&gt;enter&lt;/code&gt; and &lt;code&gt;backspace&lt;/code&gt; functionalities are conveniently located under a dominant finger (ctrl-m and ctrl-h). Similarly:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a way to map the shift function to a dominant finger? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But in the vim spirit I want to get this functionality with a key combination rather than finger acrobatics; e.g., lets use the extremely rare key combination &lt;code&gt;fd&lt;/code&gt; (in insert mode!). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the alphanumerical keys one could dump an entire list of imaps: &lt;code&gt;fd1 !&lt;/code&gt;, &lt;code&gt;fd2 @&lt;/code&gt;, ..., &lt;code&gt;fda A&lt;/code&gt; etc. into vimrc. I'm hoping there is a better way. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Ideally, &lt;code&gt;fd&lt;/code&gt; would be mapped to a &quot;sticky shift&quot; that waits for a one letter input, shifts it, then turns off the sticky shift. Is this possible?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Many thanks!&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Post mortem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Rich has a function down below which can be modified to have the complete effect. Last night someone wrote a neat solution and then erased it so I will include it here:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;imap &amp;lt;expr&amp;gt; fd nr2char(getchar()-32)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This does the trick if all you want to capitalize letters. Otherwise it seems like a good way to do function calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another good suggestion in the comments below is modifying the keyboard at the firmware level using &lt;a href=&quot;https://github.com/tmk/tmk_keyboard&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help everyone!&lt;/p&gt;&#xA;" OwnerUserId="2882" LastEditorUserId="4939" LastEditDate="2016-01-23T05:18:38.217" LastActivityDate="2016-01-23T05:18:38.217" Title="Sticky shift - or getting &lt;shift&gt; with letter combinations" Tags="|key-bindings|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6207" PostTypeId="2" ParentId="6203" CreationDate="2016-01-21T14:27:26.203" Score="3" Body="&lt;p&gt;Based on &lt;a href=&quot;https://vi.stackexchange.com/a/6204/989&quot;&gt;romainl's terrific answer&lt;/a&gt; I concocted this function to support all the PHP highlighting types:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BrowseDoc()&#xA;    if b:current_syntax == &quot;php&quot;&#xA;&#xA;        &quot; phpRegion&#xA;        let keywords_php = ['phpFCKeyword', 'phpKeyword', 'phpBoolean', 'phpClasses', 'phpConstants', 'phpFunctions', 'phpInclude', 'phpMagicConstants', 'phpServerVars', 'phpStatement', 'phpSuperglobals', 'phpType']&#xA;        let is_php = 0&#xA;&#xA;        for kw in keywords_php&#xA;            if count(map(synstack(line('.'), col('.')), 'synIDattr(v:val, &quot;name&quot;)'), kw)&#xA;                let is_php = 1&#xA;            endif&#xA;        endfor&#xA;&#xA;        if is_php&#xA;            !firefox &quot;http://php.net/manual-lookup.php?pattern=&amp;lt;cword&amp;gt;&quot;&#xA;        else&#xA;            !firefox &quot;https://codex.wordpress.org/Function_Reference/&amp;lt;cword&amp;gt;&quot;&#xA;        endif&#xA;&#xA;    elseif b:current_syntax == &quot;perl&quot;&#xA;        !firefox &quot;http://perldoc.perl.org/search.html?q=&amp;lt;cword&amp;gt;&quot;&#xA;&#xA;    elseif b:current_syntax == &quot;python&quot;&#xA;        !firefox &quot;https://docs.python.org/3.5/search.html?q=&amp;lt;cword&amp;gt;&quot;&#xA;&#xA;    else&#xA;        execute &quot;!firefox -new-tab 'https://google.com/?q=&quot; . &amp;amp;ft . &quot;\\%20&amp;lt;cword&amp;gt;'&quot;&#xA;&#xA;    endif&#xA;&#xA;endfunction&#xA;map &amp;lt;leader&amp;gt;f :call BrowseDoc()&amp;lt;Return&amp;gt;&amp;lt;Return&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Thank you romainl!&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="989" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-01-21T16:00:19.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6208" PostTypeId="1" AcceptedAnswerId="6210" CreationDate="2016-01-21T16:46:01.443" Score="13" ViewCount="9253" Body="&lt;p&gt;I usually search for words by &lt;code&gt;:/string&lt;/code&gt;, but if I have to search entire current line, how to do that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;event: 1  beacon: 0x02              //line 1&#xA;event: 19 beacon: 0x02              //line 2&#xA;event: 1  beacon: 0x03              //line 3&#xA;event: 1  beacon: 0x02              //line 4&#xA;event: 8  beacon: 0x01              //line 5&#xA;event: 19 beacon: 0x02              //line 6&#xA;event: 1  beacon: 0x02              //line 7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, if &lt;code&gt;cursor&lt;/code&gt; is presently at &lt;code&gt;line 1&lt;/code&gt; how to search similarly as &lt;code&gt;:/&lt;/code&gt; for text containing entire current line. The cursor should jump then to matching &lt;code&gt;line 4&lt;/code&gt;, and again to &lt;code&gt;line 7&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2706" LastActivityDate="2018-07-25T08:59:06.167" Title="How to search for lines matching current line in vim" Tags="|command-line|search|highlight|delimiter-matching|mark|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6209" PostTypeId="2" ParentId="6208" CreationDate="2016-01-21T17:05:25.893" Score="4" Body="&lt;p&gt;Personally I would get a &lt;a href=&quot;https://github.com/nelstrom/vim-visual-star-search&quot; rel=&quot;nofollow&quot;&gt;visual star&lt;/a&gt; plugin (&lt;a href=&quot;http://vimawesome.com/?q=star&quot; rel=&quot;nofollow&quot;&gt;there are few out there&lt;/a&gt;). There is a nice Vimcast about this: &lt;a href=&quot;http://vimcasts.org/episodes/search-for-the-selected-text/&quot; rel=&quot;nofollow&quot;&gt;Search for the selected text&lt;/a&gt;. This means you can select the line visually and then press &lt;code&gt;*&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a plugin isn't your thing you can add the following mapping to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap * :&amp;lt;c-u&amp;gt;let @/=@&quot;&amp;lt;cr&amp;gt;gvy:let [@/,@&quot;]=[@&quot;,@/]&amp;lt;cr&amp;gt;/\V&amp;lt;c-r&amp;gt;=substitute(escape(@/,'/\'),'\n','\\n','g')&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: Visual-block (&lt;code&gt;&amp;lt;c-v&amp;gt;&lt;/code&gt;) is not supported for this mapping.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2016-02-26T19:07:14.603" LastActivityDate="2016-02-26T19:07:14.603" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6210" PostTypeId="2" ParentId="6208" CreationDate="2016-01-21T17:08:48.327" Score="7" Body="&lt;p&gt;Here's how I'd do it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Yank the line (into the unnamed register), without including the newline at the end: &lt;code&gt;0y$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Initiate a &lt;em&gt;very nomagic&lt;/em&gt; search: &lt;code&gt;/\V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Add the yanked line: &lt;code&gt;&amp;lt;c-r&amp;gt;&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Fire off the search: &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/6208/how-to-search-for-lines-matching-current-line-in-vim/6210?noredirect=1#comment9636_6210&quot;&gt;@EvergreenTree points out in a comment&lt;/a&gt;, you can of course create a mapping to perform all the steps in one go:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;* 0y$/\V&amp;lt;c-r&amp;gt;&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Relevant help topics:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help registers&#xA;:help /magic&#xA;:help c_CTRL-R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. If the line you're searching for contains backslashes, you'll still need to go through and escape them (by adding another backslash), even with a &lt;em&gt;very nomagic&lt;/em&gt; search.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-01-22T08:26:28.560" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6212" PostTypeId="2" ParentId="6206" CreationDate="2016-01-21T18:01:03.743" Score="5" Body="&lt;p&gt;I'm not sure if a clean implementation of this feature is possible in Vimscript. (I suspect it's not, and I fully agree with the commenters who suggest it's better to implement this outside of Vim.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nevertheless, here's a proof-of-concept of a hacky function that maps insert-mode &lt;code&gt;fd&lt;/code&gt; to a function which waits for a single character of input, and capitalises it if it's a-z before re-entering insert mode and writing it back out. This is marginally nicer than your &quot;create all the mappings individually&quot; idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would need a bit more logic to handle all the other keyboard keys, but this should be sufficient to demonstrate the general concept. Note that &lt;code&gt;getchar()&lt;/code&gt; returns an ASCII value, so all the &lt;code&gt;if&lt;/code&gt; block is doing is converting the ASCII values for lowercase letters into uppercase ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me know if you decide to go down this path and need any more help filling the rest of it in.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap fd &amp;lt;Esc&amp;gt;:call StickyShift()&amp;lt;CR&amp;gt;&#xA;&#xA;function! StickyShift()&#xA;  let l:key_pressed = getchar()&#xA;  &quot; Capitalise a-z&#xA;  if l:key_pressed &amp;gt;= 97 &amp;amp;&amp;amp; l:key_pressed &amp;lt;= 122&#xA;    let l:key_pressed -= 32&#xA;  endif&#xA;  call feedkeys(&quot;a&quot;. nr2char(l:key_pressed))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-01-22T14:33:14.563" LastActivityDate="2016-01-22T14:33:14.563" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6213" PostTypeId="2" ParentId="6206" CreationDate="2016-01-21T19:37:55.250" Score="2" Body="&lt;p&gt;&lt;code&gt;inoremap fd &amp;lt;C-o&amp;gt;gUl&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would allow you to type afd and get A etc. if you are open to reverse the order of your bind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does not work for the 1 to ! etc unfortunately.&lt;/p&gt;&#xA;" OwnerUserId="5693" LastActivityDate="2016-01-21T19:37:55.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6214" PostTypeId="1" AcceptedAnswerId="6217" CreationDate="2016-01-22T06:40:22.343" Score="5" ViewCount="1196" Body="&lt;p&gt;Consider I work on a file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'90008000','90008005'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I insert the following text after &lt;code&gt;'90008000',&lt;/code&gt; in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'90008001','90008002','90008003','90008004',&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have read &lt;a href=&quot;https://vi.stackexchange.com/questions/12/how-can-i-generate-a-list-of-sequential-numbers-one-per-line&quot;&gt;this post&lt;/a&gt;, but I do not know how to insert these numbers in the same line.&lt;/p&gt;&#xA;" OwnerUserId="5510" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-01-22T14:39:27.120" Title="Insert a string of sequential numbers in one line" Tags="|command-line|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6215" PostTypeId="2" ParentId="6208" CreationDate="2016-01-22T10:06:08.140" Score="12" Body="&lt;p&gt;Especially for mapping purposes, I find using &lt;code&gt;getline()&lt;/code&gt; more elegant than doing the yanking yourself. Calling &lt;code&gt;getline()&lt;/code&gt; with a string &lt;code&gt;'.'&lt;/code&gt; returns the line under the cursor. There are two good options for using this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec '/' . getline('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which parses the strings &lt;code&gt;'/'&lt;/code&gt; and what is returned from &lt;code&gt;getline()&lt;/code&gt; together and executes that as a vim command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&amp;lt;C-r&amp;gt;=getline('.')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which uses the expression register &lt;code&gt;@=&lt;/code&gt;. The expression following &lt;code&gt;=&lt;/code&gt; is evaluated after the first &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; and placed in the command line.&lt;/p&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2016-01-22T10:06:08.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6216" PostTypeId="2" ParentId="6214" CreationDate="2016-01-22T10:20:30.463" Score="5" Body="&lt;p&gt;Personally, I'd probably just do this manually using regular insert/motion operations, &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;p&lt;/code&gt;, and &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt;, but you &lt;em&gt;could&lt;/em&gt; do this by recording and replaying a macro with the following keystrokes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0qqt,ya';a,&amp;lt;c-r&amp;gt;&quot;&amp;lt;esc&amp;gt;h&amp;lt;c-a&amp;gt;q3@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Broken down:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt;: Move to the start of the line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt;: Start recording a macro,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;t,&lt;/code&gt;: Jump &quot;till&quot; the first comma,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ya'&lt;/code&gt;: Yank the number and the surrounding quotes,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;&lt;/code&gt;: Jump &quot;till&quot; the comma again,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a,&amp;lt;c-r&amp;gt;&quot;&amp;lt;esc&amp;gt;&lt;/code&gt;: Insert a new comma, and the text you yanked previously,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;h&amp;lt;c-a&amp;gt;&lt;/code&gt;: Increment the number,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: Stop recording the macro,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;3@q&lt;/code&gt;: Replay the macro 3 times to add the next three numbers.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There are certainly other ways to achieve this with a macro: this is just the first that sprung to mind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Macros are an incredibly powerful tool once you've got your head around how to order operations in a way such that repeating them will produce the desired results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you first start using them it might take you a couple of tries or more to figure out a working macro (&lt;code&gt;u&lt;/code&gt; is your friend!), but after a while you can pretty much get it right on the first go every time, without having to think too much about how to do it. Remember that &lt;em&gt;everything&lt;/em&gt; you type is recorded, so minor editing mistakes in recording can easily be corrected just as you would do so normally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relevant help topics:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help complex-repeat&#xA;:help CTRL-A&#xA;:help registers&#xA;:help i_CTRL-R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-01-22T14:39:27.120" LastActivityDate="2016-01-22T14:39:27.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6217" PostTypeId="2" ParentId="6214" CreationDate="2016-01-22T10:21:46.830" Score="6" Body="&lt;p&gt;You could use a macro. Starting with the cursor on the first character of the line, type &lt;code&gt;qqyf,P&amp;lt;C-a&amp;gt;F'q3@q&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq      &quot;start the macro recording to register `q`&#xA;yf,     &quot;yank the part you are looking to duplicate,&#xA;P       &quot;paste it *before* the cursor.&#xA;&amp;lt;C-a&amp;gt;   &quot;increment the next number by one&#xA;F'      &quot;move backwards until '&#xA;q       &quot;stop recording the macro,&#xA;3@q     &quot;execute previously recorded macro 3 times.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In practice, it is often easier to do this kind of things linewise and join the lines afterward. &lt;code&gt;:join!&lt;/code&gt; can be used to avoid spaces while joining the lines.&lt;/p&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2016-01-22T10:21:46.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6218" PostTypeId="2" ParentId="6214" CreationDate="2016-01-22T10:36:11.037" Score="3" Body="&lt;p&gt;If you have a lot of similar lines, here is a mapping that could help you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; ,x :let [a, b] = map(split(getline('.'), ','), 'eval(v:val)') &amp;lt;bar&amp;gt; execute &quot;s/^.*$/'&quot; . join(range(a,b), &quot;','&quot;) . &quot;'&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hit &lt;code&gt;,x&lt;/code&gt; on a line following the form &lt;code&gt;'a','b'&lt;/code&gt; (with a &amp;lt; b), and it should be converted into:&lt;br&gt;&#xA; &lt;code&gt;'a','a+1','a+2',...,'b'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The mapping executes 2 Ex commands separated by a pipe symbol (&lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 1st command stores the 2 numbers on the line in the variables &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let [a, b] = map(split(getline('.'), ','), 'eval(v:val)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It can be broken down like this:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getline('.')    returns the current line&#xA;&#xA;split(g, ',')   splits the string g where a comma is found&#xA;                example: split('1,2,3', ',') returns [1, 2, 3]&#xA;&#xA;                here g stands for: getline('.')&#xA;&#xA;map(s, 'eval(v:val)')&#xA;                s being a list, map() takes each of its item and transforms it with&#xA;                the operation: eval(v:val)&#xA;                where v:val is an item of s&#xA;                example: map(['1', '2', '3'], 'eval(v:val)') returns [1, 2, 3]&#xA;&#xA;                eval() evaluates a string; useful to get a number inside quotes&#xA;                example: eval('123') returns 123&#xA;&#xA;                here s stands for: split(getline('.'), ',')&#xA;&#xA;let [a, b] = map(s, 'eval(v:val)')&#xA;                stores in the variables a and b the 2 items inside the list returned&#xA;                by the map() function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The 2nd command substitutes the current line with a new one, containing the missing numbers between &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;s/^.*$/'&quot; . join(range(a,b), &quot;','&quot;) . &quot;'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It can be broken down like this:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;range(a,b)      returns the list of numbers between a and b&#xA;                example: range(1,3) returns [1, 2, 3]&#xA;&#xA;join(r, &quot;','&quot;)  returns a string which concatenates all the items from the list r&#xA;                separated by the 3 characters ','&#xA;                example: join([1, 2, 3], &quot;','&quot;) returns &quot;1','2','3&quot;&#xA;&#xA;                here r stands for: range(a,b)&#xA;&#xA;execute &quot;s/^.*$/'&quot; . j . &quot;'&quot;&#xA;&#xA;                executes the Ex command resulting from the concatenation of 3 strings:&#xA;                &quot;s/^.*$/'&quot;&#xA;                j &#xA;                &quot;'&quot;&#xA;&#xA;                The resulting Ex command is a substitution command (:s/^.*$/'j')&#xA;                which substitutes the whole line (^.*$) with the string &quot;'j'&quot;&#xA;&#xA;                here j stands for: join(range(a,b), &quot;','&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-01-22T13:55:39.940" LastActivityDate="2016-01-22T13:55:39.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6219" PostTypeId="2" ParentId="6208" CreationDate="2016-01-22T11:42:08.417" Score="2" Body="&lt;p&gt;With &lt;a href=&quot;https://github.com/haya14busa/vim-asterisk&quot; rel=&quot;nofollow&quot;&gt;vim-asterisk&lt;/a&gt; installed just use &lt;code&gt;V$*&lt;/code&gt; (or &lt;code&gt;0v$*&lt;/code&gt;) to select the current line and search for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the second command &lt;code&gt;0&lt;/code&gt; is not necessary if the cursor is already on the start of the line.&lt;/p&gt;&#xA;" OwnerUserId="177" LastEditorUserId="177" LastEditDate="2016-01-22T16:21:01.783" LastActivityDate="2016-01-22T16:21:01.783" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6220" PostTypeId="1" CreationDate="2016-01-22T18:26:40.280" Score="7" ViewCount="1582" Body="&lt;p&gt;is there any chance to format code to satisfy rubocop?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default my neovim is indenting code like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Test&#xA;  attr_accessor :a, :b, :c,&#xA;    :d, :e, :f&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it would be nicer to have it like that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Test&#xA;  attr_accessor :a, :b, :c,&#xA;                :d, :e, :f&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6121" LastEditorUserId="7161" LastEditDate="2016-06-06T14:06:01.873" LastActivityDate="2016-06-06T14:06:01.873" Title="Neovim format ruby code like rubocop" Tags="|neovim|formatting|alignment|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6221" PostTypeId="2" ParentId="6208" CreationDate="2016-01-22T21:43:27.737" Score="2" Body="&lt;p&gt;One more way to do this is using the command-line window: &lt;code&gt;yy/&amp;lt;Ctrl-F&amp;gt;p&amp;lt;Enter&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Yank the whole line you need with &lt;code&gt;yy&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;/&lt;/code&gt; and then Ctrl-F to open command-line window&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;p&lt;/code&gt; to paste the line&lt;/li&gt;&#xA;&lt;li&gt;Press Enter to start the search&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6013" LastActivityDate="2016-01-22T21:43:27.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6222" PostTypeId="1" CreationDate="2016-01-23T01:15:51.603" Score="4" ViewCount="1001" Body="&lt;p&gt;Stating gnome-vim from the terminal on Linux Mint 17.3 I am getting the following error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An error occurred while loading or saving configuration information for gvim. Some of your configuration settings may not work properly.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;No D-BUS daemon running&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/B3fP1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/B3fP1.png&quot; alt=&quot;gvim dialog error No D-BUS daemon running&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This error recently started on my system. I believe the issue is external to Vim, possibly dbus is not functional correctly anymore, or another program is impacting it.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Current Workaround&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I determined that if you relaunch dbus in the terminal it can resolve the issue.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export $(dbus-launch)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone have a more permanent solution?&lt;/p&gt;&#xA;" OwnerUserId="6103" LastActivityDate="2016-01-23T01:15:51.603" Title="How to resolve gVim startup error &quot;No D-BUS daemon running&quot;" Tags="|gvim|error|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6223" PostTypeId="2" ParentId="5746" CreationDate="2016-01-23T06:58:21.037" Score="2" Body="&lt;p&gt;I didn't realise that &lt;code&gt;matchadd()&lt;/code&gt; was piling up the same highlight pattern (just with a different, incremented id), the more I was opening new buffers or simply switching between windows. Here was the output of &lt;code&gt;echo getmatches()&lt;/code&gt; after just a few opened buffers and switching between windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[{'group': 'Error', 'pattern': '\v\s+$', 'priority': -1, 'id': 4}, {'group': 'Error', 'pattern': '\v\s+$', 'priority': -1, 'id': 5}, {'group': 'Error', 'pattern': '\v\s+$', 'priority': -1, 'id': 6}, ..., {'group': 'Error', 'pattern': '\v\s+$', 'priority': -1, 'id': 24}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suspect the only thing that my modified autocmd was doing is preventing a new match to be added when entering a help buffer. But it didn't remove all the previous ones, so maybe that's why a trailing whitespace was still colored in red even in a help buffer. Or maybe not. Maybe the highlighting is local to the window, so the previous ones were not affecting a help buffer displayed in a new window. I don't know. (*)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides, I wonder if the piling of the same matches would have an effect performance-wise in the long run...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I've found a workaround using the Ex command &lt;code&gt;:2match&lt;/code&gt; instead of the function &lt;code&gt;matchadd()&lt;/code&gt;. Here's the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup trailing_whitespace&#xA;    autocmd!&#xA;    autocmd BufEnter,WinEnter * 2match Error /\s\+$/ |&#xA;                              \ if &amp;amp;filetype ==# 'help' |&#xA;                              \ call matchdelete(2) |&#xA;                              \ endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The advantage of &lt;code&gt;:2match&lt;/code&gt; compared to &lt;code&gt;matchadd()&lt;/code&gt; is that it doesn't pile up new matches, it just recreates the same one with the same id, &lt;code&gt;2&lt;/code&gt;, every time a buffer/window is entered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prevent the match to be created in a help buffer, the autocmd also executes &lt;code&gt;call matchdelete(2)&lt;/code&gt; to delete the match whose id is 2 when the filetype is &lt;code&gt;'help'&lt;/code&gt; (thank you &lt;a href=&quot;https://vi.stackexchange.com/questions/5746/how-to-test-filetype-in-an-autocommand-without-using-the-filetype-event#comment8865_5746&quot;&gt;VanLaser&lt;/a&gt; for giving me the idea).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far it seems to work as intended. Trailing whitespace in red everywhere except in a help buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, there are actually 3 similar commands: &lt;code&gt;:match&lt;/code&gt;, &lt;code&gt;:2match&lt;/code&gt;, &lt;code&gt;:3match&lt;/code&gt; which create a match whose id is respectively 1, 2 and 3.&lt;br&gt;&#xA;I didn't use &lt;code&gt;:match&lt;/code&gt; because it's more convenient to keep it untouched in case you want to create a quick match temporarily.&lt;br&gt;&#xA;And I couldn't use &lt;code&gt;:3match&lt;/code&gt; because it was already used by the script-local function &lt;code&gt;Highlight_Matching_Pair()&lt;/code&gt; defined in &lt;code&gt;/usr/share/vim/vim74/plugin/matchparen.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(*) I'm not sure, but I think the matches created by &lt;code&gt;matchadd()&lt;/code&gt; in previous windows did have an effect on a help buffer even when displayed in a new window. Otherwise the following code would work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup trailing_whitespace&#xA;    autocmd!&#xA;    autocmd BufEnter,WinEnter * let m = matchadd('Error', '\v\s+$', -1) |&#xA;                              \ if &amp;amp;filetype ==# 'help' |&#xA;                              \ call matchdelete(m) |&#xA;                              \ endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work. A trailing whitespace is still colored in red even in a help buffer displayed in a new window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I've just realised I could pass a fourth optional argument to &lt;code&gt;matchadd()&lt;/code&gt; to specify the id I want, which would prevent the piling up of identical matches. So I could write something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup trailing_whitespace&#xA;    autocmd!&#xA;    autocmd BufEnter,WinEnter * call matchadd('Error', '\v\s+$', -1, 9999) |&#xA;                              \ if &amp;amp;filetype ==# 'help' |&#xA;                              \ call matchdelete(9999) |&#xA;                              \ endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work as intended. Besides, every time I would open a buffer or switch to another window, I would have the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing BufEnter Auto commands for &quot;*&quot;:&#xA;E801: ID already taken: 9999&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;matchadd()&lt;/code&gt; doesn't want to create a match whose id is already used while &lt;code&gt;:2match&lt;/code&gt; doesn't care. So all in all, it seems &lt;code&gt;:2match&lt;/code&gt; is a better solution for this particular autocmd.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-01-23T09:09:04.800" LastActivityDate="2016-01-23T09:09:04.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6224" PostTypeId="1" CreationDate="2016-01-23T08:03:26.720" Score="2" ViewCount="155" Body="&lt;p&gt;My working vim appearance looks like that:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/csKJm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/csKJm.png&quot; alt=&quot;working vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes I accidentally open file when I am focused on nerd tree buffer and I end up like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/IFSkJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IFSkJ.png&quot; alt=&quot;vim working mess&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I would like to ask you if there is any way to set vim to block opening files in certain buffers?&lt;/p&gt;&#xA;" OwnerUserId="2993" LastActivityDate="2016-01-23T08:03:26.720" Title="How to block opening files in specified buffers" Tags="|buffers|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6225" PostTypeId="2" ParentId="5928" CreationDate="2016-01-23T10:12:43.933" Score="1" Body="&lt;p&gt;I just overlooked the part of the &lt;a href=&quot;https://github.com/sirver/UltiSnips#ultisnips&quot; rel=&quot;nofollow&quot;&gt;description&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[...] In this demo I am editing a python file. I first expand the #!&#xA;  snippet, then the class snippet. The completion menu comes from&#xA;  YouCompleteMe,[...]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2354" LastActivityDate="2016-01-23T10:12:43.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6226" PostTypeId="2" ParentId="6220" CreationDate="2016-01-23T16:37:01.733" Score="2" Body="&lt;p&gt;Maybe the &lt;a href=&quot;https://github.com/godlygeek/tabular/&quot; rel=&quot;nofollow&quot;&gt;tabular plugin&lt;/a&gt; suits your needs?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Test&#xA;  attr_accessor :a, :b, :c,&#xA;    :d, :e, :f&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;typing &lt;code&gt;:Tabularize /:\a\S\s/l0&lt;/code&gt; will result in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Test&#xA;  attr_accessor:a, :b, :c,&#xA;               :d, :e, :f&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:Tabularize /:&lt;/code&gt; aligns all colons. The colon must be followed by a letter (&lt;code&gt;\a&lt;/code&gt;), a non whitespace character (&lt;code&gt;\S&lt;/code&gt;) and a whitespace (&lt;code&gt;\s&lt;/code&gt;). That complete match is then left-adjusted (&lt;code&gt;/l0&lt;/code&gt;). The zero afterwards prevents Tabular to add whitespace after each alignment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;note&lt;/strong&gt; that this is not permanent. I.e. when you reformat your code, the aligning is destroyed and it will look like the first example again. To make this aligning persistent, you could maybe define a custom formatting function which runs the above tabular command after the vim formatting. But I don't know much about that.&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="2354" LastEditDate="2016-01-23T17:12:41.513" LastActivityDate="2016-01-23T17:12:41.513" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6228" PostTypeId="1" CreationDate="2016-01-23T18:14:44.997" Score="30" ViewCount="31582" Body="&lt;p&gt;Most editors have a feature like when you press some keys by placing caret over a function, it pops the documentation of that function along with number and type of arguments that function takes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering whether Vim offers such support. For example, while coding in C, I use a built in function &lt;code&gt;qsort()&lt;/code&gt;. Since I am not sure about type and number of arguments it takes, I would like to know it without escaping Vim. Is it possible? &lt;/p&gt;&#xA;" OwnerUserId="6134" LastEditorUserId="205" LastEditDate="2016-01-23T20:15:00.470" LastActivityDate="2021-04-22T12:15:12.360" Title="How can I get Vim to show documentation of a C/C++ function?" Tags="|autocompletion|" AnswerCount="7" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6229" PostTypeId="2" ParentId="6228" CreationDate="2016-01-23T19:25:13.997" Score="7" Body="&lt;p&gt;If you want proper &lt;em&gt;documentation&lt;/em&gt;, the plugin in saginaw's comment seems to cover your C++ needs. I don't know of a generic one but you can probably find alternatives for other languages on vim.org.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If…&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;your code is already indexed with ctags,&lt;/li&gt;&#xA;&lt;li&gt;your index also includes the standard library,&lt;/li&gt;&#xA;&lt;li&gt;and all you want is a &lt;em&gt;hint&lt;/em&gt;,&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;you can use &lt;code&gt;&amp;lt;C-w&amp;gt;}&lt;/code&gt; to open the definition of the keyword under your cursor in a preview window. YMMV, of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help preview-window&lt;/code&gt;, &lt;code&gt;:help tags&lt;/code&gt; and &lt;code&gt;:help ctags&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also use Vim's built-in &quot;include-search&quot; functionality: press &lt;code&gt;[i&lt;/code&gt; to print the &quot;signature&quot; of the word under the cursor in the command-line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pdDIl.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pdDIl.png&quot; alt=&quot;[i&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help include-search&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-01-23T19:25:13.997" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6230" PostTypeId="2" ParentId="6228" CreationDate="2016-01-23T20:28:46.850" Score="14" Body="&lt;p&gt;If you can set up &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;noreferrer&quot;&gt;YouCompleteMe&lt;/a&gt;, it supports C, C++, JavaScript, Go and some other languages. Here's it in action:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0Ew0i.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0Ew0i.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/7Ro6Z.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7Ro6Z.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a bit annoying to &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe#installation&quot; rel=&quot;noreferrer&quot;&gt;install&lt;/a&gt;, and once it's installed you need to &lt;a href=&quot;https://valloric.github.io/YouCompleteMe/#c-family-semantic-completion-engine-usage&quot; rel=&quot;noreferrer&quot;&gt;configure it for C and C++&lt;/a&gt; by creating a &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt;. I lifted one from &lt;a href=&quot;https://github.com/rasendubi/dotfiles/blob/master/.vim/.ycm_extra_conf.py&quot; rel=&quot;noreferrer&quot;&gt;this repo&lt;/a&gt;, and got this effect.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-01-23T20:28:46.850" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6231" PostTypeId="1" CreationDate="2016-01-23T20:58:36.443" Score="1" ViewCount="38" Body="&lt;p&gt;I don't know why it is happening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I've got a code like this (let x be our cursor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main() {x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main() {&#xA;}x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I would like to enter the normal mode and type &lt;kbd&gt;shift&lt;/kbd&gt; + &lt;kbd&gt;o&lt;/kbd&gt; to insert a new line above &lt;code&gt;}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However this is what happens:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main() {&#xA;}Ox&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and after a while it changes to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main() {&#xA;    x&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a video where I was able to reproduce this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=vz170eR6aT0&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;https://img.youtube.com/vi/vz170eR6aT0/mqdefault.jpg&quot; alt=&quot;Video thumbnail&quot;&gt;&lt;br&gt;&#xA;&lt;strong&gt;Vim hangs for a second when typing shift-o after inserting curly brackets&lt;/strong&gt; on YouTube&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Side note: could you please suggest me better tagging for this question? I've got no idea how to tag it.&lt;/em&gt;&#xA;" OwnerUserId="6043" LastActivityDate="2016-01-23T20:58:36.443" Title="Delay after typing shift-o to insert a new line between brackets" Tags="|insert-mode|normal-mode|" AnswerCount="0" CommentCount="1" ClosedDate="2016-01-23T21:26:22.537" ContentLicense="CC BY-SA 3.0" />
  <row Id="6232" PostTypeId="2" ParentId="6228" CreationDate="2016-01-24T08:33:28.060" Score="21" Body="&lt;p&gt;For C, pressing &lt;code&gt;K&lt;/code&gt; on the keyword will pull up the built-in manpage directly. For instance, place the cursor on the &lt;code&gt;printf&lt;/code&gt; keyword:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf(&quot;Hello, %s!&quot;, foo);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now press &lt;code&gt;K&lt;/code&gt; (upper case K) and the manpage for &lt;code&gt;printf&lt;/code&gt; should appear in VIM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NAME&#xA;   printf - format and print data&#xA;&#xA;SYNOPSIS&#xA;   printf FORMAT [ARGUMENT]...&#xA;   printf OPTION&#xA;&#xA;DESCRIPTION&#xA;   Print ARGUMENT(s) according to FORMAT, or execute according to OPTION:&#xA;&#xA;   --help display this help and exit&#xA;&#xA;   --version&#xA;          output version information and exit&#xA;&#xA;   FORMAT controls the output as in C printf.  Interpreted sequences are:&#xA;&#xA;   \&quot;     double quote&#xA;   \\     backslash&#xA;&#xA;   ... It continues for quite a few scrollable pages&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to work out of the box in all Debian-derived distros that I've tried it on, no specific configuration required.&lt;/p&gt;&#xA;" OwnerUserId="989" LastActivityDate="2016-01-24T08:33:28.060" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6233" PostTypeId="1" AcceptedAnswerId="6234" CreationDate="2016-01-24T09:47:41.110" Score="2" ViewCount="162" Body="&lt;p&gt;In my codes, I often have to do this kind of text editing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;u(:,:,:) = 0._dp&#xA;v(:,:,:) = 0._dp&#xA;temp(:,:,:) = 0._dp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;grid%u(0:nx,0:ny,0:nz) = 0._dp&#xA;grid%v(0:nx,0:ny,0:nz) = 0._dp&#xA;grid%temp(0:nx,0:ny,0:nz) = 0._dp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using the record option, which is something that I recently learned how to use and therefore not excel at. Here is how I do it (cursor is placed on &quot;u&quot;).&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; / &lt;code&gt;i grid%&lt;/code&gt; / &lt;code&gt;ESC&lt;/code&gt;  (start recording and store in buffer &quot;q&quot;, go to insert mode and enter &quot;grid%&quot;, escape insert mode)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f:&lt;/code&gt; / &lt;code&gt;i 0&lt;/code&gt; / &lt;code&gt;ESC&lt;/code&gt; / &lt;code&gt;;;&lt;/code&gt; / &lt;code&gt;.&lt;/code&gt; / &lt;code&gt;;;&lt;/code&gt; / &lt;code&gt;.&lt;/code&gt; (go to next &quot;:&quot;, insert 0, escape insert mode, go to 2nd next &quot;:&quot;, repeat last command, go to 2nd next &quot;:&quot;, repeat last command)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;&lt;/code&gt; / &lt;code&gt;a nz&lt;/code&gt; / &lt;code&gt;ESC&lt;/code&gt; / &lt;code&gt;,,&lt;/code&gt; / &lt;code&gt;a ny&lt;/code&gt; / &lt;code&gt;ESC&lt;/code&gt; / &lt;code&gt;,,&lt;/code&gt; / &lt;code&gt;a nx&lt;/code&gt; / &lt;code&gt;ESC&lt;/code&gt; (go to next &quot;:&quot;, insert after cursor &quot;nz&quot;, escape insert mode, go to 2nd previous &quot;:&quot;, insert after cursor &quot;ny&quot;, escape insert mode, go to 2nd previous &quot;:&quot;, insert after cursor &quot;nz&quot;, escape insert mode)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; / &lt;code&gt;SHIFT-^&lt;/code&gt; / &lt;code&gt;@q&lt;/code&gt; (go down one line, go to first non-blank character, apply macro &quot;q&quot;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; / &lt;code&gt;SHIFT-^&lt;/code&gt; / &lt;code&gt;@q&lt;/code&gt; (go down one line, go to first non-blank character, apply macro &quot;q&quot;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The only thing I can think of which can make this code editing more efficient is to use the macro on the two lines in one command. Intuitively, I tried &lt;code&gt;2@q&lt;/code&gt; but that did not work.&lt;/p&gt;&#xA;" OwnerUserId="4562" LastActivityDate="2016-01-24T10:07:00.643" Title="What is the fastest way to perform this change?" Tags="|macro|repeated-commands|performance|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6234" PostTypeId="2" ParentId="6233" CreationDate="2016-01-24T10:07:00.643" Score="4" Body="&lt;p&gt;As far as I can tell, your recording doesn't include any vertical motion. This means that &lt;code&gt;2@q&lt;/code&gt; will play your recording twice on the same line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could add a &lt;code&gt;j&lt;/code&gt; at the end of your macro to move down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could use &lt;code&gt;2:norm @q&lt;/code&gt; to play your recording on the current line and the following one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;count&quot; you give to Vim before running an ex command is transformed into a range. Here, your &lt;code&gt;2&lt;/code&gt; is transformed into &lt;code&gt;.,.+1&lt;/code&gt; which covers the current line (&lt;code&gt;.&lt;/code&gt;) and the one below (&lt;code&gt;.+1&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-01-24T10:07:00.643" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6235" PostTypeId="1" CreationDate="2016-01-24T11:27:53.167" Score="2" ViewCount="738" Body="&lt;p&gt;I'm trying to configure the &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow&quot;&gt;NERDCommenter plugin&lt;/a&gt; to handle multiline ruby comments (i.e., nested inside &lt;code&gt;=begin&lt;/code&gt; and &lt;code&gt;=end&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant setting is something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:NERDCustomDelimiters = {&#xA;    \ 'ruby': {'left': '# ', 'leftAlt': &quot;=begin\n&quot;, 'rightAlt': &quot;\n=end&quot; }&#xA;    \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;except this gives me the &lt;code&gt;^@&lt;/code&gt; control character instead of an actual newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Found this in &lt;a href=&quot;http://www.softpanorama.org/Editors/Vimorama/vim_scripting.shtml&quot; rel=&quot;nofollow&quot;&gt;a primer on vimscript&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that strings can be specified with either double-quotes or single-quotes as delimiters. Double-quoted strings honor special &quot;escape sequences&quot; such as &quot;\n&quot; (for newline), &quot;\t&quot; (for tab), &quot;\u263A&quot; (for Unicode smiley face), or &quot;\&quot; (for the escape character).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and made sure to place the strings inside double quotes. Still no dice. What gives?&lt;/p&gt;&#xA;" OwnerUserId="2593" LastEditorUserId="205" LastEditDate="2016-01-24T15:50:04.153" LastActivityDate="2016-01-24T15:50:04.153" Title="Plugin config settings: Newline &quot;\n&quot; returns ^@ control character?" Tags="|vimscript|plugin-nerdcommenter|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6236" PostTypeId="2" ParentId="6235" CreationDate="2016-01-24T15:49:24.747" Score="3" Body="&lt;p&gt;&lt;code&gt;^@&lt;/code&gt;, if you look at &lt;a href=&quot;http://manpages.ubuntu.com/ascii.7&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;man ascii&lt;/code&gt;&lt;/a&gt;, is the ASCII NUL character. That makes me think this has to do with how newlines are inserted in the replacement string of a &lt;code&gt;:substitute&lt;/code&gt; command. From &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3As%25&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :s%&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &amp;lt;CR&amp;gt;        split line in two at this point&#xA;              (Type the &amp;lt;CR&amp;gt; as CTRL-V &amp;lt;Enter&amp;gt;)                  s&amp;lt;CR&amp;gt;&#xA;  \r          idem                                               s/\r&#xA;  \&amp;lt;CR&amp;gt;       insert a carriage-return (CTRL-M)&#xA;              (Type the &amp;lt;CR&amp;gt; as CTRL-V &amp;lt;Enter&amp;gt;)                  s/\&amp;lt;CR&amp;gt;&#xA;  \n          insert a &amp;lt;NL&amp;gt; (&amp;lt;NUL&amp;gt; in the file)&#xA;              (does NOT break the line)     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;\n&lt;/code&gt; inserts a &lt;code&gt;&amp;lt;NUL&amp;gt;&lt;/code&gt;, perhaps you should try &lt;code&gt;\r=end&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-01-24T15:49:24.747" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="6237" PostTypeId="1" CreationDate="2016-01-24T17:04:03.230" Score="1" ViewCount="33" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mCx1g.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mCx1g.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I type &lt;code&gt;o&lt;/code&gt;,  it will insert a new line, and it is exactly new line without any indentation. The cursor will go to the beginning.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I insert a new line with the indentation of the line above?&lt;/p&gt;&#xA;" OwnerUserId="6020" LastEditorUserId="205" LastEditDate="2016-01-25T03:40:37.207" LastActivityDate="2016-01-25T03:40:37.207" Title="How can I insert a new line with the indentation of the line above?" Tags="|indentation|" AnswerCount="0" CommentCount="1" ClosedDate="2016-01-25T19:39:48.503" ContentLicense="CC BY-SA 3.0" />
  <row Id="6238" PostTypeId="1" CreationDate="2016-01-24T17:04:19.787" Score="4" ViewCount="620" Body="&lt;p&gt;I wrote a quick snippet of VimL to display, in my statusline, the type of the currently focused Haskell expression&#xA;It looks like this (&lt;a href=&quot;https://gfycat.com/EnlightenedShimmeringHoiho&quot; rel=&quot;nofollow noreferrer&quot;&gt;click for better quality (as gfy)&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://gfycat.com/EnlightenedShimmeringHoiho&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XrKbM.gif&quot; alt=&quot;Screen-capture of a cursor moving around a vim buffer, with the statusline constantly updating to show the type of the selected expression&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've included the code below,&#xA;but the only important part is the &lt;code&gt;system&lt;/code&gt; call.&#xA;The call takes about 0.04&amp;thinsp;s to execute,&#xA;which is fine with me;&#xA;there's really no noticeable delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, what does bother me greatly&#xA;is that if I send a key event while the system call is running,&#xA;the key is echoed to the display&#xA;and overwrites a character.&#xA;Of course, it doesn't actually modify the buffer,&#xA;and hitting &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; is sufficient to fix it,&#xA;but this happens whenever I'm pressing keys rapidly in sequence&#xA;or holding down a key,&#xA;so writing &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; all the time is very frustrating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Worse, it means that I can't trust my own eyes!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I solve this problem?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To reproduce this, create a file with ten or so lines&#xA;(like &lt;code&gt;10Ohello&amp;lt;Esc&amp;gt;&lt;/code&gt;) and save it as &lt;code&gt;sample.txt&lt;/code&gt;.&#xA;Save the below text block as &lt;code&gt;sample.vimrc&lt;/code&gt;.&#xA;Then run &lt;code&gt;vim sample.txt -u sample.vimrc&lt;/code&gt; and hold down &lt;code&gt;j&lt;/code&gt;;&#xA;you should see a bunch of &lt;code&gt;j&lt;/code&gt;s appear.&#xA;Hit &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; to clear them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's &lt;code&gt;sample.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&#xA;set statusline=%{SlowOutput()}&#xA;function! SlowOutput()&#xA;    silent call system(&quot;sleep 0.1&quot;)&#xA;    return &quot;I'm awake; I'm awake!&quot;&#xA;endfunction&#xA;&#xA;set laststatus=2&#xA;&#xA;&quot; tried with and without this (I would *very* much prefer to keep it on):&#xA;&quot; set lazyredraw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The actual code I'm using,&#xA;in case I'm missing something important&#xA;or you just want the code for yourself, follows&#xA;(it depends on &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;nofollow noreferrer&quot;&gt;bling/vim-airline&lt;/a&gt; and &lt;a href=&quot;https://github.com/bitc/vim-hdevtools&quot; rel=&quot;nofollow noreferrer&quot;&gt;bitc/vim-hdevtools&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_section_gutter = &quot;%{HaskellCursorType()}%=&quot;&#xA;function! HaskellCursorType()&#xA;    if &amp;amp;l:ft != &quot;haskell&quot;&#xA;        return &quot;&quot;&#xA;    else&#xA;        let l:file = expand(&quot;%&quot;)&#xA;        if l:file == ''&#xA;            return &quot;&quot;&#xA;        endif&#xA;        if !filereadable(l:file)&#xA;            return &quot;&quot;&#xA;        endif&#xA;        let l:line = line('.')&#xA;        let l:col = col('.')&#xA;        let l:cmd = hdevtools#build_command('type', shellescape(l:file) . ' ' . l:line . ' ' . l:col)&#xA;        silent let l:output = system(l:cmd)&#xA;        let l:lines = split(l:output, '\n')&#xA;        if len(l:lines) == 0&#xA;            return &quot;(no type)&quot;&#xA;        endif&#xA;        return matchstr(l:lines[0], '&quot;\zs[^&quot;]\+\ze&quot;')&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="142" LastEditorUserId="205" LastEditDate="2016-01-24T19:41:58.613" LastActivityDate="2016-02-27T18:15:04.007" Title="How can I make a slow-ish `system` call in a statusline without corrupting the display?" Tags="|external-command|statusline|performance|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="6239" PostTypeId="1" AcceptedAnswerId="6250" CreationDate="2016-01-24T19:10:51.663" Score="4" ViewCount="482" Body="&lt;p&gt;My &lt;code&gt;formatoptions&lt;/code&gt; include &lt;code&gt;cro&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a filetype (Stata .do files) in which the comment character is &lt;code&gt;*&lt;/code&gt;. Anything after this character is considered a comment line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In insert mode &lt;code&gt;*&amp;lt;CR&amp;gt;*&lt;/code&gt; leads to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*&#xA;* &amp;lt;cursor&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However &lt;code&gt;**&amp;lt;CR&amp;gt;&lt;/code&gt; leads to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;**&#xA;&amp;lt;cursor&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My desired behavior, which seems to work in most other filetypes in my configuration, is that &lt;code&gt;**&amp;lt;CR&amp;gt;&lt;/code&gt; leads to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;**&#xA;*&amp;lt;cursor&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's wrong with this filetype and how can I fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another filetype example I found with similar behavior is Python. There if I do &lt;code&gt;#&amp;lt;CR&amp;gt;#&lt;/code&gt; I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#&#xA;#&amp;lt;cursor&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I do &lt;code&gt;##&amp;lt;CR&amp;gt;&lt;/code&gt; I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;##&#xA;&amp;lt;cursor&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of what I would expect, which is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;##&#xA;#&amp;lt;cursor&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to be the same behavior as with the Stata files except that in the Stata files vim also inserts a space after the &lt;code&gt;*&lt;/code&gt;. In Python it doesn't add the space but still doesn't recognize &lt;code&gt;##&lt;/code&gt; as being a comment line.&lt;/p&gt;&#xA;" OwnerUserId="5464" LastEditorUserId="205" LastEditDate="2016-01-25T13:56:24.097" LastActivityDate="2016-01-25T14:26:38.813" Title="Automatic comment leader not inserted on some file types" Tags="|comments|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6240" PostTypeId="2" ParentId="5734" CreationDate="2016-01-24T19:20:23.153" Score="9" Body="&lt;p&gt;Finally found it! Completing parameters is not a part of the YCM behaviour. See &lt;a href=&quot;https://github.com/Valloric/ycmd/issues/170&quot;&gt;this YCM issue&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's &lt;a href=&quot;https://github.com/oblitum/YouCompleteMe/tree/clang_complete-params&quot;&gt;an old fork from oblitum&lt;/a&gt; which could grant this feature. That's what misled me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this part of the fork seems unmaintained and after a few tries I couldn't make it work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I tried out &lt;code&gt;clang_completer&lt;/code&gt; which has the parameter completion feature I was looking for.&lt;/p&gt;&#xA;" OwnerUserId="5546" LastEditorUserId="205" LastEditDate="2016-01-24T19:38:15.253" LastActivityDate="2016-01-24T19:38:15.253" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6241" PostTypeId="2" ParentId="2403" CreationDate="2016-01-24T22:41:07.230" Score="1" Body="&lt;p&gt;I'm in a position where I have to constantly switch between two python projects, one using python 2 the other python 3.&#xA;As you noted youcompleteme does not work with python 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First I compiled an additional version of vim with python 3 (which I start with vim3) and I use vundle as plugin manager.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my .vimrc I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'davidhalter/jedi-vim' &quot; for python3&#xA;Plugin 'Valloric/YouCompleteMe' &quot; for python2&#xA;&#xA;&#xA;if has('python3')&#xA;    let g:loaded_youcompleteme = 1 &quot; disables loading it! doesnt support python3&#xA;    let g:jedi#force_py_version = 3&#xA;    let g:pymode_python = 'python3'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It disables youcompleteme when I run vim3, but I have the jedi-vim autocomplete instead. I only just started using it, and this &lt;a href=&quot;https://blog.dbrgn.ch/2013/5/27/using-jedi-with-ymc/&quot; rel=&quot;nofollow&quot;&gt;blog post&lt;/a&gt; says they are not compatible together but for me autocomplete works in both, jedi's go-to-definition works, python-mode's pylint works and no plugin complains on startup. All good so far :)&lt;/p&gt;&#xA;" OwnerUserId="6146" LastActivityDate="2016-01-24T22:41:07.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6242" PostTypeId="1" AcceptedAnswerId="6243" CreationDate="2016-01-25T05:56:35.383" Score="0" ViewCount="464" Body="&lt;p&gt;VIMTEX How do you enable/use the F7 key mentioned in the documentation? &lt;code&gt;:map &amp;lt;F7&amp;gt;&lt;/code&gt; is empty and provides no clue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: In response to the comments below. I cannot figure out what F7 is designed to do, and how to invoke it.  &lt;/p&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="5919" LastEditDate="2016-01-28T09:41:30.400" LastActivityDate="2016-01-28T09:41:30.400" Title="What's the purpose of F7 in vimtex? How is it used/" Tags="|plugin-vimtex|" AnswerCount="1" CommentCount="3" ClosedDate="2016-01-25T21:03:42.783" ContentLicense="CC BY-SA 3.0" />
  <row Id="6243" PostTypeId="2" ParentId="6242" CreationDate="2016-01-25T09:03:33.683" Score="3" Body="&lt;p&gt;The &lt;code&gt;&amp;lt;F7&amp;gt;&lt;/code&gt; key is enabled by default, unless you have other mappings either in your &lt;code&gt;vimrc&lt;/code&gt; file or in another plugin that conflicts with the vimtex mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the mapping in both insert mode and in normal mode. In insert mode, you can use it to make the word in front of the cursor into a command, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;test&amp;lt;f7&amp;gt;  =&amp;gt;  \test{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;FYI: If you find the documentation for vimtex lacking or confusing, please open an issue or a pull request.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-01-25T09:03:33.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6244" PostTypeId="1" AcceptedAnswerId="6246" CreationDate="2016-01-25T09:40:59.537" Score="3" ViewCount="158" Body="&lt;p&gt;I want vim to automatically set the filetype to PKGBUILD when I am editing files that are named &quot;PKGBUILD&quot;.  How can I accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="5663" LastEditorUserId="865" LastEditDate="2016-01-25T17:17:24.247" LastActivityDate="2016-01-25T17:17:24.247" Title="How to set filetype to PKGBUILD when the filename is PKGBUILD?" Tags="|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6245" PostTypeId="2" ParentId="6050" CreationDate="2016-01-25T09:56:31.233" Score="1" Body="&lt;p&gt;For full &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html&quot; rel=&quot;nofollow&quot;&gt;POSIX compatibility&lt;/a&gt; (i.e. portability), try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc 'g/^127/d&#xA;x' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I improved your regex slightly because it appeared to me that your intent was to only delete lines &lt;em&gt;beginning&lt;/em&gt; with &quot;127&quot;; if that was incorrect, remove the &lt;code&gt;^&lt;/code&gt; carat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-s&lt;/code&gt; command causes &lt;code&gt;ex&lt;/code&gt; to run silently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;g&lt;/code&gt;lobal command must be terminated by a newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;+cmd&lt;/code&gt; is not guaranteed by POSIX; only &lt;code&gt;-c cmd&lt;/code&gt; is guaranteed, and multiple &lt;code&gt;-c&lt;/code&gt; flags are not necessarily supported.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;x&lt;/code&gt; is the &quot;exit&quot; command; it saves changes and exits, but only writes to the file if changes were actually made.  (So if no changes were made, the timestamp on the file will be unaffected—which is preferable in many situations.)&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2016-01-25T09:56:31.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6246" PostTypeId="2" ParentId="6244" CreationDate="2016-01-25T09:59:49.413" Score="2" Body="&lt;p&gt;You could define the following autocmd in your vimrc :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    autocmd BufRead,BufNewFile PKGBUILD set filetype=PKGBUILD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And to make sure the autocmd is not duplicated every time your vimrc is sourced, you could wrap it into an augroup and empty the latter at the beginning (&lt;code&gt;autocmd!&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup pkgbuild&#xA;    autocmd!&#xA;    autocmd BufRead,BufNewFile PKGBUILD set filetype=PKGBUILD&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;BufRead&lt;/code&gt; and &lt;code&gt;BufNewFile&lt;/code&gt; are 2 possible events which will trigger, for a buffer whose name is &lt;code&gt;PKGBUILD&lt;/code&gt;, the command: &lt;code&gt;set filetype=PKGBUILD&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help autocmd&#xA;:help autocmd-events&#xA;:help augroup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-01-25T15:34:16.047" LastActivityDate="2016-01-25T15:34:16.047" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6247" PostTypeId="2" ParentId="5273" CreationDate="2016-01-25T10:31:25.087" Score="5" Body="&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest portable way to do this is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf '%s\n' %s/e//g x | ex file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This avoids error conditions discussed below.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original Answer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the advantages of &lt;code&gt;ex&lt;/code&gt; as opposed to Vim is that &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;ex&lt;/code&gt; is guaranteed by POSIX&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're in the sysadmin world and you need to script automated edits to text files (e.g. configuration files to be edited across thousands of different remote servers), you want to use something &lt;em&gt;portable&lt;/em&gt;.  Perl is great but not portable—and it's overkill for very simple file edits.  &lt;code&gt;sed&lt;/code&gt; and &lt;code&gt;awk&lt;/code&gt; are both guaranteed by POSIX, but they're not designed for in-place file editing.  (&lt;code&gt;sed&lt;/code&gt; has a &lt;code&gt;-i&lt;/code&gt; switch in some implementations such as GNU &lt;code&gt;sed&lt;/code&gt; to allow for in-place file editing, but for portable scripting that option shouldn't be relied upon as it is not in the &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;POSIX standard for &lt;code&gt;sed&lt;/code&gt;&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The correct tool for the job is &lt;code&gt;ex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your example, removing all instances of the letter &quot;e&quot; from the file, the &lt;code&gt;ex&lt;/code&gt; command is simple (and portable):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '%s/e//g | x' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-s&lt;/code&gt; switch starts &lt;code&gt;ex&lt;/code&gt; silently, for batch processing (as opposed to interactive use where messages are printed out to the terminal).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-c&lt;/code&gt; switch precedes the command to be run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The substitute command is as you wrote it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The vertical bar separates commands to be run sequentially (unless you're &lt;a href=&quot;https://vi.stackexchange.com/a/6245/4676&quot;&gt;using it with the &lt;code&gt;g&lt;/code&gt;lobal command&lt;/a&gt;, but we're not.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;x&lt;/code&gt; command exits after writing any changes to the file.  (It only writes to the file if edits were made, thus preserving the file's timestamp if no edits were necessary.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;There is one &lt;em&gt;major&lt;/em&gt; caveat to the above command:&lt;/strong&gt; If the letter &quot;e&quot; doesn't exist anywhere in the file, the substitute command will fail and the &lt;code&gt;x&lt;/code&gt; command won't be executed.  This will leave you staring at a silently running &lt;code&gt;ex&lt;/code&gt; process with no error output, or output of any kind.  It's not at all obvious in this case what's happening, but it's actually waiting for you to type in &lt;code&gt;ex&lt;/code&gt; commands.  (It's more obvious if you omit the &lt;code&gt;-s&lt;/code&gt; flag, so that you are actually prompted for input with a colon.)  Just type &lt;code&gt;q!&lt;/code&gt; to exit in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I were to actually use this to edit files on remote servers, of course, I would want the command to exit correctly even if there weren't any instances of the letter &quot;e&quot; in the files being edited.  Vim has an &lt;code&gt;e&lt;/code&gt; flag for the substitute command which would handle this by suppressing &lt;code&gt;e&lt;/code&gt;rrors if the regex weren't matched:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '%s/e//ge | x' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the POSIX way would be to use the &lt;code&gt;g&lt;/code&gt;lobal command to run the &lt;code&gt;s&lt;/code&gt;ubstitute command on all lines matching the given regex—and to not run substitute at all if the regex weren't found:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc 'g/e/s///g&#xA;x' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-06-23T05:06:54.253" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6248" PostTypeId="2" ParentId="4847" CreationDate="2016-01-25T11:22:33.347" Score="7" Body="&lt;p&gt;If you want &lt;em&gt;bulletproof&lt;/em&gt;, you probably want something a little more portable than the complicated options above.  I would stick to &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html&quot; rel=&quot;nofollow&quot;&gt;POSIX features of &lt;code&gt;ex&lt;/code&gt;&lt;/a&gt; and make it stupid-simple: Just remove the line if it's there (regardless of how many times it's there), add it to the end of the file, then save and exit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc 'g/^export PATH=\~\/\.composer\/vendor\/bin:\$PATH$/d&#xA;$a&#xA;export PATH=~/.composer/vendor/bin:$PATH&#xA;.&#xA;x' ~/.bashrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I anchored the regex for added robustness, though I think it's almost impossible to &lt;em&gt;accidentally&lt;/em&gt; match this regex.  (Anchored means using &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt; so the regex will only match if it matches an &lt;em&gt;entire&lt;/em&gt; line.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the &lt;code&gt;+cmd&lt;/code&gt; syntax is not required by POSIX, nor is the common feature of allowing multiple &lt;code&gt;-c&lt;/code&gt; arguments.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There are a multitude of other &lt;strong&gt;simple&lt;/strong&gt; ways to do this.  For instance, add the line to the end of the file, then run the last two lines of the file through the external UNIX filter &lt;code&gt;uniq&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '$a&#xA;export PATH=~/.composer/vendor/bin:$PATH&#xA;.&#xA;$-,$!uniq&#xA;x' input&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is very very clean and simple, and is also fully POSIX-compliant.  It uses the &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html#tag_20_40_13_52&quot; rel=&quot;nofollow&quot;&gt;Escape feature of &lt;code&gt;ex&lt;/code&gt;&lt;/a&gt; for external text filtering, and the &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/uniq.html&quot; rel=&quot;nofollow&quot;&gt;POSIX-specified shell utility &lt;code&gt;uniq&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bottom line is, &lt;code&gt;ex&lt;/code&gt; is &lt;em&gt;designed&lt;/em&gt; for in-place file editing and it is by far the most portable way to accomplish that in a non-interactive fashion.  It predates even the original &lt;code&gt;vi&lt;/code&gt;, actually—the name &lt;code&gt;vi&lt;/code&gt; is for &quot;visual editor&quot;, and the non-visual editor it was built upon &lt;em&gt;was&lt;/em&gt; &lt;code&gt;ex&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For even greater simplicity (and to reduce it to a single line), use &lt;code&gt;printf&lt;/code&gt; to send the commands to &lt;code&gt;ex&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf %s\\n '$a' 'export PATH=~/.composer/vendor/bin:$PATH' . '$-,$!uniq' x | ex input&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="4676" LastEditDate="2016-04-12T00:38:16.237" LastActivityDate="2016-04-12T00:38:16.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6249" PostTypeId="2" ParentId="5974" CreationDate="2016-01-25T12:05:48.317" Score="8" Body="&lt;p&gt;I do need to point out the elephant in the room: &lt;strong&gt;You shouldn't be navigating in insert mode.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Insert mode is for &lt;em&gt;inserting&lt;/em&gt; text.  While many implementations of &lt;code&gt;vi&lt;/code&gt; &lt;em&gt;allow&lt;/em&gt; you to navigate (using the arrow keys) while in insert mode, the recommended, &lt;em&gt;normal&lt;/em&gt; method of navigation is to &lt;strong&gt;navigate in normal mode.&lt;/strong&gt;  Normal mode should be the mode you are normally in, hence the name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The topic of modal editing vs. arrow keys is well described (at a beginner level) under &quot;Misconception #1&quot; in &lt;a href=&quot;http://www.viemu.com/a-why-vi-vim.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this excellent article&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an additional point of background, the terminals upon which &lt;code&gt;vi&lt;/code&gt; was originally designed didn't even &lt;em&gt;have&lt;/em&gt; arrow keys.  On some old keyboards the HJKL keys are additionally labelled with arrows; I don't actually know if this came before or after &lt;code&gt;vi&lt;/code&gt; but I suspect the former.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I highly recommend working your way through the &lt;code&gt;vimtutor&lt;/code&gt; (on the command line) and reading through the above linked article to start getting a handle on the power of modal editing.  I suspect that the problem of non-functioning arrow keys will drop into total insignificance once you get a feel for the powerful motion commands available in normal mode.  I know I personally &lt;em&gt;never&lt;/em&gt; use arrow keys while editing text in Vim, and I feel handicapped when using other editors where I must use the arrow keys to navigate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This site itself will also be of great assistance; for instance, here are a couple posts you may find helpful:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/2367/4676&quot;&gt;How can I jump to the next &amp;quot;paragraph&amp;quot;?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/5851/4676&quot;&gt;How to disable arrow keys in vim?&lt;/a&gt;  (Ironic, isn't it?)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As to the nitty-gritty of Chrome OS and how it interprets arrow key presses in your terminal, I suspect that debugging it will go beyond the scope of this site.  If you are truly determined to use arrow keys in &lt;code&gt;vi&lt;/code&gt;, perhaps you will have better luck with the keyboard-to-terminal debugging issue amongst the knowledgeable people over at superuser.com.  Best of luck to you whatever you decide, and I hope you may come to appreciate the power of Vim even with non-arrow-key only usage patterns.  :)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;P.S.: The most basic motion commands there are, are &lt;code&gt;h&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, &lt;code&gt;l&lt;/code&gt;.  To these you can add &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Backspace&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Return&amp;gt;&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt;, and of course the great favorites &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;e&lt;/code&gt; and their whitespace-separated-word counterparts &lt;code&gt;W&lt;/code&gt;, &lt;code&gt;B&lt;/code&gt;, &lt;code&gt;E&lt;/code&gt;.  If you add in sentence motions &lt;code&gt;(&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt;, paragraph motions &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;, searching the word under the cursor forward or backward with &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; respectively, and same-line character search with &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;T&lt;/code&gt;, &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt;, and if you actually learn all of those well, or even most of those (which won't take you very long, actually)...I can promise you with total confidence that you will &lt;em&gt;never&lt;/em&gt; go back to using arrow keys to navigate text within Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This isn't even a complete list of motion commands; far from it.  To see a more complete list along with documentation for each, start Vim, type &lt;code&gt;:help motion.txt&lt;/code&gt;, and use &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; as your &quot;down&quot; and &quot;up&quot; keys to scroll through the document.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-01-25T12:05:48.317" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6250" PostTypeId="2" ParentId="6239" CreationDate="2016-01-25T14:26:38.813" Score="6" Body="&lt;p&gt;You might have to set a custom &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27comments%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;comments&lt;/code&gt;&lt;/a&gt;. For me, &lt;code&gt;comments&lt;/code&gt; in a Python file is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;comments=b:#,fb:-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With some experimenting, I found that, for Vim to insert &lt;code&gt;#&lt;/code&gt; after lines with &lt;code&gt;##&lt;/code&gt;, I needed to use a three-piece comment (or part of one, anyway):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- Three-piece comments that have a start string, an end string, and optional&#xA;  lines in between.  The strings for the start, middle and end are different.&#xA;  An example is the C style comment:&#xA;        /*&#xA;         * this is a C comment&#xA;         */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The start would be &lt;code&gt;#&lt;/code&gt;, with nesting allowed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  n     Nested comment.  Nesting with mixed parts is allowed.  If 'comments'&#xA;        is &quot;n:),n:&amp;gt;&quot; a line starting with &quot;&amp;gt; ) &amp;gt;&quot; is a comment.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But not requiring a blank space after (so &lt;code&gt;##&lt;/code&gt; would work), so omitting &lt;code&gt;b&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  b     Blank (&amp;lt;Space&amp;gt;, &amp;lt;Tab&amp;gt; or &amp;lt;EOL&amp;gt;) required after {string}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The middle would be &lt;code&gt;#&lt;/code&gt;, without nesting, but inserting a space:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  {digits}&#xA;        When together with 's' or 'e': add {digit} amount of offset to an&#xA;        automatically inserted middle or end comment leader. The offset begins&#xA;        from a left alignment. See below for more details.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set comments+=sn:#,mb1:#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now &lt;code&gt;##&amp;lt;CR&amp;gt;&lt;/code&gt; gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;##&#xA;# _&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly, for your Stata file, you can set &lt;code&gt;comments&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set comments+=ns:*,mb1:*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check what it is first, and modify it appropriately.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-01-25T14:26:38.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6251" PostTypeId="1" AcceptedAnswerId="6711" CreationDate="2016-01-25T16:35:30.443" Score="3" ViewCount="587" Body="&lt;p&gt;I am working on a project that could really benefit if I can open vim by specifying a line number/ match so that the file would open with the cursor positioned on that line. Is there a way to do that with a command line argument? (because i am opening a file as &lt;code&gt;vim file_name&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, is there a way to specify the tab sequence as well? So, after typing some stuff on line 2, Hit tab and go to line 7 , something to that effect.&#xA;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I am sorry if this is already asked before. I searched a lot but i could not find anything. &lt;/p&gt;&#xA;" OwnerUserId="5481" LastActivityDate="2016-02-27T17:44:34.880" Title="Specifying the line on which the cursor should start at" Tags="|gvim|vim-windows|macvim|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="6252" PostTypeId="2" ParentId="4901" CreationDate="2016-01-25T18:20:09.890" Score="1" Body="&lt;p&gt;Unfortunately, I'm not sure I fully understand the problem you are having or what you are trying to achieve.  From what I can gather, you're trying to interactively execute python code from vim.  If you're willing to entertain non-Conque related solutions, then I'd highly recommend the vim-ipython plugin.  It allows you to select arbitrary lines of python code and execute them in an existing ipython session.  I believe it is fairly forgiving about the indentation as long as the selected block is correctly indented within itself.  This should allow you to select just the &lt;code&gt;if&lt;/code&gt; block within a function and execute it even though it may be indented a few levels relative to the rest of the file (hopefully that made sense).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin can be found here: &lt;a href=&quot;https://github.com/ivanov/vim-ipython&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ivanov/vim-ipython&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2016-01-25T18:20:09.890" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6253" PostTypeId="1" AcceptedAnswerId="6257" CreationDate="2016-01-25T19:29:21.440" Score="4" ViewCount="108" Body="&lt;p&gt;For 4-5 years I've had the following in my &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap jj &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which I understand is pretty conventional, and I've never had problems until recently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every so often, typically when load is higher than usual, this remapping doesn't work and I end up with something like &lt;code&gt;jj;wq&lt;/code&gt; in my document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the best way to go about increasing the reliability of this remapping? Is this uncommon, maybe indicating a system or keyboard problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vim version 7.4 on Ubuntu 14.04, with &lt;a href=&quot;https://github.com/jrumbut/MyVimRC/blob/master/.vimrc&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; .vimrc&lt;/p&gt;&#xA;" OwnerUserId="5575" LastEditorUserId="24" LastEditDate="2016-01-25T20:47:15.453" LastActivityDate="2016-01-26T15:30:06.170" Title="Two character remap sometimes failing in INSERT mode" Tags="|key-bindings|insert-mode|escape|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6254" PostTypeId="1" AcceptedAnswerId="6264" CreationDate="2016-01-26T00:36:08.710" Score="20" ViewCount="22564" Body="&lt;p&gt;The current working directory is &lt;code&gt;./A/B/&lt;/code&gt;. An empty document is opened when I type &lt;code&gt;vim&lt;/code&gt;, and the netrw is opened with command &lt;code&gt;:e.&lt;/code&gt; The window is split by &lt;code&gt;vs.&lt;/code&gt;, and I can navigate to the upper level directory, i.e., &lt;code&gt;./A/&lt;/code&gt;. Now I'd like to copy a file &lt;code&gt;a_file.jpg&lt;/code&gt; from &lt;code&gt;./A/B/&lt;/code&gt; to &lt;code&gt;./A/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;yy&lt;/code&gt; on the target file and &lt;code&gt;p&lt;/code&gt; in the target window (directory), but it did not achieve my goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way that can achieve the goal without installing extra plugins?&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="205" LastEditDate="2016-01-26T20:04:58.720" LastActivityDate="2020-05-11T12:26:03.043" Title="How do I copy a file in netrw?" Tags="|cut-copy-paste|netrw|filesystem|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6255" PostTypeId="1" CreationDate="2016-01-26T01:49:15.343" Score="2" ViewCount="426" Body="&lt;p&gt;I have turned on &lt;code&gt;cursorline&lt;/code&gt; and &lt;code&gt;cursorcolumn&lt;/code&gt; options to highlight cursor line and cursor column, but there is some inconsistency in the behavior. The &lt;code&gt;CursorLine&lt;/code&gt; highlighting seems to have a lower priority than other syntax highlighting, so the usual syntax highlighting works in the cursor line, but &lt;code&gt;CursorColumn&lt;/code&gt; seems to have a higher priority, as it cancels the usual syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can i change this behavior so that &lt;code&gt;CursorColumn&lt;/code&gt; highlighting be applied only if there is no corresponding syntax highlighting (like with &lt;code&gt;CursorLine&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="1248" LastActivityDate="2016-01-26T01:49:15.343" Title="Cursor line and cursor column highlighting &quot;priorities&quot; are inconsistent" Tags="|highlight|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6256" PostTypeId="2" ParentId="4901" CreationDate="2016-01-26T12:39:08.810" Score="3" Body="&lt;p&gt;It's possible to get this behaviour &lt;em&gt;without&lt;/em&gt; changing ConqueTerm's code itself. The code below applies your desired behaviour to linewise visual mode selections*.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;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 then removing the gates again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add the code to your .vimrc, or if you want it only to apply to Python files, you could add &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; to the &lt;code&gt;vnoremap&lt;/code&gt; mapping to make it buffer-specific and put it in &lt;code&gt;.vim/after/ftplugin/markdown.vim&lt;/code&gt; so it applies to all Python files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;silent&amp;gt; &amp;lt;f9&amp;gt; :&amp;lt;c-u&amp;gt;call ConqueWrapper(&quot;%cpaste&quot;, &quot;--&quot;)&amp;lt;CR&amp;gt;&#xA;&#xA;function! ConqueWrapper(start_gate, end_gate)&#xA;  let m = visualmode()&#xA;&#xA;  &quot; Only apply this wrapper to linewise selections&#xA;  if m ==# 'V'&#xA;    let start_line = line(&quot;'&amp;lt;&quot;)&#xA;    let end_line = line(&quot;'&amp;gt;&quot;)&#xA;&#xA;    &quot; Add in the code gates&#xA;    call append(end_line, a:end_gate)&#xA;    call append(start_line - 1, a:start_gate)&#xA;&#xA;    &quot; Reset the visual marks&#xA;    call setpos(&quot;'&amp;lt;&quot;, [0, start_line, 0, 0])&#xA;    call setpos(&quot;'&amp;gt;&quot;, [0, end_line + 2, 0, 0])&#xA;&#xA;    &quot; Send to ConqueTerm&#xA;    call conque_term#send_selected(&quot;V&quot;)&#xA;&#xA;    &quot; Switch back to original buffer&#xA;    wincmd p&#xA;&#xA;    &quot; Remove the code gates&#xA;    execute end_line + 2 . &quot;delete _&quot;&#xA;    execute start_line . &quot;delete _&quot;&#xA;&#xA;    &quot; Switch back to ConqueTerm&#xA;    wincmd p&#xA;  else&#xA;    &quot; Not linewise: just pass it on directly to ConqueTerm&#xA;    execute &quot;call conque_term#send_selected(\&quot;&quot; . m . &quot;\&quot;)&quot;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My personal preference is not to make changes to the source code of plugins if I can avoid it, because then you have to either:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Make a fork of plugin project, and keep this updated by merging in future changes from the original project,&lt;/li&gt;&#xA;&lt;li&gt;Or reapply your changes every time you update the plugin.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;...neither of which is a very appealing prospect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* Because I don't think it makes much sense for characterwise or blockwise selections, and the code to implement it would be more complicated, and therefore harder for you to understand.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-01-27T10:04:08.770" LastActivityDate="2016-01-27T10:04:08.770" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6257" PostTypeId="2" ParentId="6253" CreationDate="2016-01-26T15:18:46.460" Score="5" Body="&lt;p&gt;The options &lt;code&gt;'timeout'&lt;/code&gt; and &lt;code&gt;'timeoutlen'&lt;/code&gt; control how Vim will treat typed characters when they are part of a mapping. By default &lt;code&gt;'timeout'&lt;/code&gt; is enabled and &lt;code&gt;'timeoutlen'&lt;/code&gt;'s value is 1000 (ms).&lt;br&gt;&#xA;It means that by default when you hit a character that is part of a mapping, Vim will wait 1s before deciding whether you are typing the &lt;code&gt;{lhs}&lt;/code&gt; of your mapping or if it's just a single character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you hit the first &lt;code&gt;j&lt;/code&gt; in your mapping, you could imagine that Vim has triggered a timer, and you have 1s to type the second &lt;code&gt;j&lt;/code&gt; if you want to escape. After 1s, your first &lt;code&gt;j&lt;/code&gt; is not considered as part of a mapping anymore, it's just a character. So in the end Vim will just insert &lt;code&gt;jj&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually Vim receives your &lt;code&gt;j&lt;/code&gt; almost immediately after you typed it. However, if your system is under a heavy load maybe it adds some lag between the moment where you hit &lt;code&gt;j&lt;/code&gt; and the moment Vim receives it. When it happens it's as if you typed &lt;code&gt;jj&lt;/code&gt; with more than one second between the 2 characters. If that's the case, then you could increase the value of the &lt;code&gt;'timeoutlen'&lt;/code&gt; option so that your second &lt;code&gt;j&lt;/code&gt; has enough time to reach Vim before the timeout occurs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to increase the length of the timeout to 2s, you could add in your vimrc:&lt;br&gt;&#xA;&lt;code&gt;set timeoutlen=2000&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help timeout&#xA;:help timeoutlen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-01-26T15:30:06.170" LastActivityDate="2016-01-26T15:30:06.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6258" PostTypeId="1" AcceptedAnswerId="6261" CreationDate="2016-01-26T15:53:29.437" Score="17" ViewCount="13579" Body="&lt;p&gt;If I open the file explorer with &lt;code&gt;:Explore&lt;/code&gt; and choose a file, it replaces the buffer I had open before and I have to open it again. How do I avoid this?&lt;/p&gt;&#xA;" OwnerUserId="6164" LastActivityDate="2019-08-29T16:41:09.517" Title="Using :Explore without closing current buffer" Tags="|buffers|netrw|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6259" PostTypeId="2" ParentId="6258" CreationDate="2016-01-26T16:24:41.867" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How do I avoid this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You don't. The previous buffer is still there, you only need to pull it from the buffer list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:b &amp;lt;Tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-01-26T16:24:41.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6260" PostTypeId="1" CreationDate="2016-01-26T16:43:43.457" Score="4" ViewCount="204" Body="&lt;p&gt;I have the following in my &lt;code&gt;.vimrc&lt;/code&gt; on both machines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And yet, for some reason I only see the &lt;a href=&quot;https://stackoverflow.com/a/234578/5419599&quot;&gt;expected behavior&lt;/a&gt; on my Mac, and not on the other computer (which is a Windows 7 box running MobaXterm).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The auto-unindenting after I type &lt;code&gt;}&lt;/code&gt; is really quite nice, and I'd like it to work in both places.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this an issue with a missing &quot;filetype plugin?&quot;  I can't find any directory where &quot;filetype plugins&quot; are stored and I never installed any myself; how does that work, anyway?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The language I was using at the time I noticed the discrepancy was &lt;code&gt;awk&lt;/code&gt;, and Vim chose the correct syntax highlighting on both machines (based on the &lt;code&gt;.awk&lt;/code&gt; file extension), but failed to handle the autoindent the way I expected on Windows.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have installed no plugins at all on either machine.  The &lt;code&gt;.vimrc&lt;/code&gt; is practically empty in each case.  MobaXterm has Vim 7.3.646; the Mac just says 7.3.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-01-26T18:18:07.653" Title="Why does Vim smartindent on one computer and not another?" Tags="|indentation|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6261" PostTypeId="2" ParentId="6258" CreationDate="2016-01-26T19:22:31.107" Score="10" Body="&lt;p&gt;I usually use a following flow when I want to open the file (while keeping the current file):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make a new vertical / horizontal split&lt;/li&gt;&#xA;&lt;li&gt;Open netrw from in the new split&lt;/li&gt;&#xA;&lt;li&gt;Select another file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As mentioned in comments there are also :Sexplore and :Vexplore which do the split and open netrw at once, but I don't use them. I don't use :Explore too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead I use &lt;a href=&quot;https://github.com/tpope/vim-vinegar&quot; rel=&quot;noreferrer&quot;&gt;vim-vinegar&lt;/a&gt; which is a slim, but very useful improvement on top of netrw. You just press &lt;code&gt;-&lt;/code&gt; any time you need the file explorer.&#xA;Also I highly recommend to check Drew Neil's &lt;a href=&quot;http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/&quot; rel=&quot;noreferrer&quot;&gt;Oil and Vinegar post&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my flow above is to pre-split the screen as I want it to be and then select the new file.&lt;/p&gt;&#xA;" OwnerUserId="6013" LastActivityDate="2016-01-26T19:22:31.107" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6262" PostTypeId="2" ParentId="6254" CreationDate="2016-01-26T19:34:16.220" Score="11" Body="&lt;p&gt;I would do this from the command line mode:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Select the file you need in netrw&lt;/li&gt;&#xA;&lt;li&gt;Open command the line and type - &lt;code&gt;:!mv &amp;lt;C-R&amp;gt;&amp;lt;C-F&amp;gt; ../&amp;lt;C-R&amp;gt;&amp;lt;C-F&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;&amp;lt;C-R&amp;gt;&amp;lt;C-F&amp;gt;&lt;/code&gt; inserts file name under cursor, so you don't have to type the file name.&lt;/p&gt;&#xA;" OwnerUserId="6013" LastEditorUserId="6013" LastEditDate="2017-09-29T15:38:17.267" LastActivityDate="2017-09-29T15:38:17.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6263" PostTypeId="1" CreationDate="2016-01-26T20:06:59.190" Score="4" ViewCount="305" Body="&lt;p&gt;Here's a sample macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;2Ea,^[j^&lt;/code&gt;&#xA;(Jump to the end of the second word, append a &quot;,&quot; escape visual mode, and go to the next line.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of &lt;code&gt;99 The,&lt;/code&gt; I get &lt;code&gt;99  The,ê^&lt;/code&gt; and it stays stuck in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried manually rewriting the macro like:&#xA;&lt;code&gt;2Ea,&amp;lt;Esc&amp;gt;j^&lt;/code&gt;&#xA;&lt;code&gt;2Ea,&amp;lt;Escape&amp;gt;j^&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And neither work, I just end up with something like this: &lt;code&gt;99  The,&amp;lt;Esc&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2541" LastActivityDate="2016-01-26T20:06:59.190" Title="Esc from insert in macro prints ê^ instead of running Esc" Tags="|insert-mode|macro|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="6264" PostTypeId="2" ParentId="6254" CreationDate="2016-01-26T20:20:20.423" Score="27" Body="&lt;p&gt;You cannot use &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;p&lt;/code&gt; etc., to copy files in netrw - it comes with its own commands. See &lt;a href=&quot;http://vimhelp.appspot.com/pi_netrw.txt.html#netrw-mc&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h netrw-mc&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MARKED FILES: COPYING                                           netrw-mc {{{2&#xA;            (See netrw-mf and netrw-mr for how to mark files)&#xA;                      (Uses the global marked file list)&#xA;&#xA;Select a target directory with mt (netrw-mt).  Then change directory,&#xA;select file(s) (see netrw-mf), and press &quot;mc&quot;.  The copy is done&#xA;from the current window (where one does the mf) to the target.&#xA;&#xA;If one does not have a target directory set with netrw-mt, then netrw&#xA;will query you for a directory to copy to.&#xA;&#xA;One may also copy directories and their contents (local only) to a target&#xA;directory.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your case is simplified since &lt;code&gt;./A&lt;/code&gt; is the parent of &lt;code&gt;./A/B&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open &lt;code&gt;./A/B&lt;/code&gt;, move to the line having &lt;code&gt;../&lt;/code&gt;, &lt;/li&gt;&#xA;&lt;li&gt;Mark it with &lt;code&gt;mt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move to the line with the file you want to copy.&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;mf&lt;/code&gt;, and then &lt;code&gt;mc&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ tree foo&#xA;foo&#xA;└── bar&#xA;    └── test&#xA;&#xA;1 directory, 1 file&#xA;$ vim foo/bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Move to &lt;code&gt;..&lt;/code&gt; and press &lt;code&gt;mt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Hmele.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Hmele.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The header will change to show the current target:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WtPeX.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WtPeX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Move to the file (here &lt;code&gt;test&lt;/code&gt;) and press &lt;code&gt;mf&lt;/code&gt;. It gets highlighted for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5wGU2.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5wGU2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;code&gt;mc&lt;/code&gt; - the highlighting goes away. Now navigate to the parent folder - the file should be present:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jG41q.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jG41q.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-01-26T20:20:20.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6265" PostTypeId="1" AcceptedAnswerId="6267" CreationDate="2016-01-26T20:34:49.470" Score="12" ViewCount="4278" Body="&lt;p&gt;I'm a little confused on VimScript's regex comparison operators.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I look through &lt;code&gt;:h =~?&lt;/code&gt; my understanding is that &lt;code&gt;=~&lt;/code&gt; can be used to do a regex match (with the &lt;code&gt;?&lt;/code&gt; making it case-insensitive).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this code prints &quot;no&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:myVar = &quot;S123&quot;&#xA;if s:myVar =~? &quot;^S\d+&quot;&#xA;  echo &quot;yes&quot;&#xA;else&#xA;  echo &quot;no&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I using the &lt;code&gt;=~&lt;/code&gt; operator incorrectly?&lt;/p&gt;&#xA;" OwnerUserId="2312" LastActivityDate="2016-01-26T20:48:11.977" Title="Usage of the =~ operator" Tags="|vimscript|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6266" PostTypeId="2" ParentId="6258" CreationDate="2016-01-26T20:46:07.927" Score="16" Body="&lt;p&gt;In &lt;a href=&quot;http://vimhelp.appspot.com/pi_netrw.txt.html#netrw-explore&quot;&gt;&lt;code&gt;:help netrw-explore&lt;/code&gt;&lt;/a&gt; they mention several other commands to explore your files.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Among them are &lt;code&gt;:Texplore&lt;/code&gt; which opens the file explorer window in a new tab instead of using your current window.&lt;br&gt;&#xA;There are other variants you could try, like &lt;code&gt;:Sexplore&lt;/code&gt; (horizontal split) or &lt;code&gt;:Vexplore&lt;/code&gt; (vertical split).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When your cursor is on a file, you can also hit &lt;code&gt;o&lt;/code&gt;, &lt;code&gt;v&lt;/code&gt;, or &lt;code&gt;t&lt;/code&gt; to open it in a horizontal split, vertical split or tab.&lt;br&gt;&#xA;Also &lt;code&gt;p&lt;/code&gt; will open a window in which you can preview the file under the cursor, but the focus will stay in your netrw buffer meaning you can go on exploring your filesystem without needing to do a &lt;code&gt;&amp;lt;C-w&amp;gt;w&lt;/code&gt; or &lt;code&gt;&amp;lt;C-w&amp;gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="205" LastEditDate="2016-01-26T20:50:13.107" LastActivityDate="2016-01-26T20:50:13.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6267" PostTypeId="2" ParentId="6265" CreationDate="2016-01-26T20:48:11.977" Score="14" Body="&lt;p&gt;There are two problems: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You need &lt;code&gt;\+&lt;/code&gt; since you're not using magic.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You're using &lt;code&gt;&quot;&lt;/code&gt; instead of &lt;code&gt;'&lt;/code&gt;. You need to double escape &lt;code&gt;\&lt;/code&gt;: &lt;code&gt;\\d&lt;/code&gt;, or use single quotes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#literal-string&quot;&gt;&lt;code&gt;:h literal-string&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;literal-string                                          literal-string E115&#xA;---------------&#xA;'string'                string constant                 expr-'&#xA;&#xA;Note that single quotes are used.&#xA;&#xA;This string is taken as it is.  No backslashes are removed or have a special&#xA;meaning.  The only exception is that two quotes stand for one quote.&#xA;&#xA;Single quoted strings are useful for patterns, so that backslashes do not need&#xA;to be doubled.  These two commands are equivalent: &#xA;        if a =~ &quot;\\s*&quot;&#xA;        if a =~ '\s*'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:myVar = &quot;S123&quot;&#xA;if s:myVar =~? '^S\d\+'&#xA;  echo &quot;yes&quot;&#xA;else&#xA;  echo &quot;no&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works as expected.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-01-26T20:48:11.977" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6269" PostTypeId="1" CreationDate="2016-01-27T04:46:59.020" Score="9" ViewCount="586" Body="&lt;p&gt;I was looking at &lt;a href=&quot;https://unix.stackexchange.com/q/257819/135943&quot;&gt;this&#xA;question&lt;/a&gt; and then&#xA;wondered how I might implement &lt;a href=&quot;https://unix.stackexchange.com/a/257913/135943&quot;&gt;my answer which uses&#xA;&lt;code&gt;sed&lt;/code&gt;&lt;/a&gt; using purely&#xA;&lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;POSIX&#xA;&lt;code&gt;ex&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trick is that while in &lt;code&gt;sed&lt;/code&gt; I can compare the hold space with&#xA;the pattern space to see if they are exactly equivalent (with&#xA;&lt;code&gt;G;/^\(.*\)\n\1$/{do something}&lt;/code&gt;), I know of no way to do such a&#xA;test in &lt;code&gt;ex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that in Vim I could &lt;code&gt;Y&lt;/code&gt;ank the first line and then type&#xA;&lt;code&gt;:2,$g/&amp;lt;C-r&amp;gt;0/d&lt;/code&gt; to &lt;em&gt;almost&lt;/em&gt; do what I'm specifying—but if the first&#xA;line contains anything but very straightforward alphanumeric text&#xA;this becomes chancy indeed, since the line is being dumped in as a&#xA;&lt;em&gt;regex&lt;/em&gt;, not just a string for comparison.  (And if the first line&#xA;contains a forward slash, the rest of the line will be interpreted&#xA;as a command!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if I want to delete all the lines in &lt;code&gt;myfile&lt;/code&gt; that are identical&#xA;to the first line—but not delete the first line—how could I do that&#xA;using &lt;code&gt;ex&lt;/code&gt;?  For that matter, how could I do it using &lt;code&gt;vi&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a POSIX way to delete a line if it exactly matches another&#xA;line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps something like this imaginary syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:2,$g/**lines equal to &quot;0**/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2016-06-21T16:40:26.027" Title="Use ex-command to check whether two lines are identical?" Tags="|ex-mode|original-vi|ex-command|posix|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6270" PostTypeId="5" CreationDate="2016-01-27T04:49:33.540" Score="0" Body="&lt;p&gt;The &lt;code&gt;POSIX&lt;/code&gt; tag is for questions about the &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;POSIX-standardized&#xA;features for&#xA;&lt;code&gt;ex&lt;/code&gt;&lt;/a&gt;&#xA;and &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;POSIX-standardized features for&#xA;&lt;code&gt;vi&lt;/code&gt;&lt;/a&gt;,&#xA;which differ occasionally from the &quot;original-vi&quot; implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you wish a solution to be portable to a wide variety of Unix&#xA;or Unix-like systems (RHEL/CentOS, Ubuntu, macOS, Solaris, et.&#xA;al.), the closest thing to a universal guideline for portability&#xA;is the collection of &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/&quot; rel=&quot;nofollow noreferrer&quot;&gt;POSIX (Portable Operating System Interface)&#xA;standards&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance when scripting in-place file edits with &lt;code&gt;ex&lt;/code&gt; which may&#xA;be run on a wide variety of systems, or when intending to edit files&#xA;with &lt;code&gt;vi&lt;/code&gt; on servers or embedded devices which may or may not have&#xA;Vim, your questions about such should be tagged &lt;code&gt;POSIX&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When your question is specifically about the original &lt;code&gt;vi&lt;/code&gt; program&#xA;and its features/design, even when its features differ from the&#xA;modern POSIX standards, use the &lt;code&gt;original-vi&lt;/code&gt; tag instead.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="11357" LastEditDate="2018-12-19T15:49:01.223" LastActivityDate="2018-12-19T15:49:01.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6271" PostTypeId="4" CreationDate="2016-01-27T04:49:33.540" Score="0" Body="The POSIX tag is for questions about the POSIX-standardized features for `ex` and `vi`, which differ occasionally from the &quot;original-vi&quot; implementation." OwnerUserId="4676" LastEditorUserId="4676" LastEditDate="2016-01-28T14:54:33.813" LastActivityDate="2016-01-28T14:54:33.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6272" PostTypeId="1" AcceptedAnswerId="6709" CreationDate="2016-01-27T07:32:44.740" Score="4" ViewCount="967" Body="&lt;p&gt;How do I get the width in columns of the area available for text in the current split. If &lt;code&gt;columns&lt;/code&gt; is 110, but 5 of that is gutter, signs and numbers, I want 105.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: This is a duplicate of &lt;a href=&quot;https://stackoverflow.com/questions/26315925/get-usable-window-width-in-vim-script/26318602#26318602&quot;&gt;https://stackoverflow.com/questions/26315925/get-usable-window-width-in-vim-script/26318602#26318602&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(but I can't flag it as a duplicate because it's not in Vi and Vim)&lt;/p&gt;&#xA;" OwnerUserId="6174" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-02-27T16:46:08.440" Title="Get column width of available text area" Tags="|vimscript|split|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6273" PostTypeId="5" CreationDate="2016-01-27T10:08:17.810" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-01-27T10:08:17.810" LastActivityDate="2016-01-27T10:08:17.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6274" PostTypeId="4" CreationDate="2016-01-27T10:08:17.810" Score="0" Body="Conque is a Vim plugin which allows you to run interactive programs, such as bash on linux or powershell.exe on Windows, inside a Vim buffer. In other words it is a terminal emulator which uses a Vim buffer to display the program output. &#xD;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-01-28T14:33:18.110" LastActivityDate="2016-01-28T14:33:18.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6276" PostTypeId="2" ParentId="6269" CreationDate="2016-01-27T21:35:52.227" Score="2" Body="&lt;p&gt;It would appear that the only POSIX way to do this is to use an external filter, such as &lt;code&gt;sed&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to delete the 17th line of your file only if it is exactly identical to the 5th line, and otherwise leave it unchanged, you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,17!sed '5h;17{G;/^\(.*\)\n\1$/d;s/\n.*$//;}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(You could run &lt;code&gt;sed&lt;/code&gt; on the entire buffer here, or you could run it only on the lines 5-17, but in the first case you're doing unnecessary filtering—no big deal—and in the latter case you would have to use the numbers 1 and 13 in your &lt;code&gt;sed&lt;/code&gt; command instead of 5 and 17.  Confusing.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;sed&lt;/code&gt; only does a single forward pass, there's no easy way to do the reverse and delete the 5th line only if it is identical to the 17th line.  I tried for a while as a point of curiosity...it's &lt;em&gt;tricky&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Breakthrough&lt;/strong&gt; - You can do it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:17t 5&#xA;:5,5+!sed '1N;/^\(.*\)\n\1$/d;s/\n.*$//'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is actually the more general method.  It can likewise be used to give the same result as the first command (and delete the 17th line only if it's identical to the 5th line) like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5t 17&#xA;:17,17+!sed '1N;/^\(.*\)\n\1$/d;s/\n.*$//'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For broader uses such as deleting &lt;em&gt;all&lt;/em&gt; the lines of the file that are identical to line 37, while leaving line 37 intact, you could do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:37,$!sed '1{h;n;};G;/^\(.*\)\n\1$/d;s/\n.*$//'&#xA;:37t 0&#xA;:1,37!sed '1{h;d;};G;/^\(.*\)\n\1$/d;s/\n.*$//'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The conclusion here is, for checking if two lines are identical, the best tool &lt;em&gt;is&lt;/em&gt; &lt;code&gt;sed&lt;/code&gt;, not &lt;code&gt;ex&lt;/code&gt;.  But as &lt;a href=&quot;https://vi.stackexchange.com/questions/5362/delete-all-consecutive-duplicates/5363#comment8790_5363&quot;&gt;DevSolar alluded to in a comment&lt;/a&gt;, this isn't a failure of &lt;code&gt;vi&lt;/code&gt; or &lt;code&gt;ex&lt;/code&gt;—they are &lt;em&gt;designed&lt;/em&gt; to work with Unix tools; that is a major strength.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-01-27T22:00:02.667" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6277" PostTypeId="2" ParentId="6164" CreationDate="2016-01-28T02:20:19.880" Score="5" Body="&lt;p&gt;The problem was not in Vim's default Python interpreter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The real root of the problem is that the last version of &lt;code&gt;jedi-vim&lt;/code&gt; (0.7.0) was released in 2013 and did not work well with Python 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since then Python 3 support in &lt;code&gt;jedi-vim&lt;/code&gt; has been improved a lot.&#xA;We (Arch users) asked &lt;code&gt;jedi-vim&lt;/code&gt; to make a new release. &lt;code&gt;0.8.0&lt;/code&gt; has been released and now it is in the Arch repo. Please remove the hacked Vim and update Arch. &lt;code&gt;jedi-vim&lt;/code&gt; is supposed to work well now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moral of this story: do not try to add workarounds over workarounds. Try to find the &lt;em&gt;real&lt;/em&gt; root of the issue and fix that. Work with upstream more actively. Do not be afraid to ask.&lt;/p&gt;&#xA;" OwnerUserId="6182" LastEditorUserId="205" LastEditDate="2016-01-30T23:34:12.973" LastActivityDate="2016-01-30T23:34:12.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6278" PostTypeId="2" ParentId="6228" CreationDate="2016-01-28T04:30:57.313" Score="1" Body="&lt;p&gt;Vim's C/C++ file type comes with a decent omnicompletion function, which supports &quot;preview&quot; functionality.  So add &quot;preview&quot; to your completeopt option and see a function signature when you do insert mode completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal mode, you could CTRL+W } to open the function declaration in the preview window manually.&lt;/p&gt;&#xA;" OwnerUserId="1094" LastActivityDate="2016-01-28T04:30:57.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6279" PostTypeId="1" CreationDate="2016-01-28T10:25:00.027" Score="3" ViewCount="1449" Body="&lt;p&gt;The command &lt;code&gt;map localleader&lt;/code&gt; are explained very nicely &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/06.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. How do I read the current value of the &lt;code&gt;&amp;lt;localleader&amp;gt;&lt;/code&gt; thingy? Is this a variable or what?&lt;/p&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="205" LastEditDate="2016-01-28T13:35:42.863" LastActivityDate="2016-01-28T17:29:17.520" Title="How to read the value of Maplocalleader?" Tags="|key-bindings|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="6280" PostTypeId="2" ParentId="6279" CreationDate="2016-01-28T13:46:44.243" Score="3" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#maplocalleader&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h maplocalleader&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                        &amp;lt;LocalLeader&amp;gt; maplocalleader&#xA;&amp;lt;LocalLeader&amp;gt; is just like &amp;lt;Leader&amp;gt;, except that it uses &quot;maplocalleader&quot;&#xA;instead of &quot;mapleader&quot;.  &amp;lt;LocalLeader&amp;gt; is to be used for mappings which are&#xA;local to a buffer.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Recursing on to &lt;code&gt;:h &amp;lt;Leader&amp;gt;&lt;/code&gt; (which is just above this paragraph):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                        &amp;lt;Leader&amp;gt; mapleader&#xA;To define a mapping which uses the &quot;mapleader&quot; variable, the special string&#xA;&quot;&amp;lt;Leader&amp;gt;&quot; can be used.  It is replaced with the string value of &quot;mapleader&quot;.&#xA;If &quot;mapleader&quot; is not set or empty, a backslash is used instead.  Example: &#xA;        :map &amp;lt;Leader&amp;gt;A  oanother line&amp;lt;Esc&amp;gt;&#xA;Works like: &#xA;        :map \A  oanother line&amp;lt;Esc&amp;gt;&#xA;But after: &#xA;        :let mapleader = &quot;,&quot;&#xA;It works like: &#xA;        :map ,A  oanother line&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;mapleader&lt;/code&gt; &lt;em&gt;is&lt;/em&gt; a variable, and therefore &lt;code&gt;maplocalleader&lt;/code&gt; is too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tricky part, of course, is that neither is set by default - and so Vim uses &lt;code&gt;\&lt;/code&gt; as the leader. If you try to examine the value of these two variables, by e.g., &lt;code&gt;let maplocalleader&lt;/code&gt; or &lt;code&gt;echo mapleader&lt;/code&gt;, Vim will just throw an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E121: Undefined variable: mapleader&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do you set it? The &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; help quoted above has an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;,&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let maplocalleader = &quot;_&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="5919" LastEditDate="2016-01-28T17:29:17.520" LastActivityDate="2016-01-28T17:29:17.520" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6281" PostTypeId="2" ParentId="6258" CreationDate="2016-01-28T19:33:11.723" Score="6" Body="&lt;p&gt;If you have netrw v153 or later, you'll have &lt;a href=&quot;http://vimhelp.appspot.com/pi_netrw.txt.html#%3ALexplore&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:Lexplore&lt;/code&gt;&lt;/a&gt; available.  This command opens a window on the side of the display, and &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; will cause editing to occur in window#2 (by default).  You can change the default window to be used for editing by using the &lt;code&gt;C&lt;/code&gt; map or by changing the variable &lt;code&gt;g:netrw_chgwin&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastEditorUserId="205" LastEditDate="2016-01-29T04:49:51.503" LastActivityDate="2016-01-29T04:49:51.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6282" PostTypeId="1" AcceptedAnswerId="6285" CreationDate="2016-01-28T23:10:03.540" Score="4" ViewCount="103" Body="&lt;p&gt;I'm using VIM7.4.488 on ubuntu 15.04 system. I use command &lt;code&gt;:setlocal spell spelllang=en_us&lt;/code&gt; for spell checking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can capture some spelling error as well as words like &lt;code&gt;htb&lt;/code&gt;, &lt;code&gt;Cref&lt;/code&gt;, &lt;code&gt;iffalse&lt;/code&gt;. However, it did not detect the error spelling &lt;code&gt;tehrmal&lt;/code&gt; (thermal). Then I tried &lt;code&gt;ge agw obr tbg.&lt;/code&gt;, and type the command again, the obvious incorrect words are undetected either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way to fix this problem?&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="1080" LastEditDate="2016-01-29T02:13:09.957" LastActivityDate="2016-01-29T02:27:42.600" Title="Why does spell-check work poorly on my system?" Tags="|linux|spell-checking|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6283" PostTypeId="1" AcceptedAnswerId="6284" CreationDate="2016-01-29T01:43:33.990" Score="7" ViewCount="1772" Body="&lt;p&gt;The HTML that's being returned by this PHP function doesn't have any syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I delete the &lt;code&gt;'&lt;/code&gt; on line 13 the HTML highlighting works (but the PHP function breaks), with it the HTML highlighting does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get the HTML to have its proper syntax highlighting inside of this function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/79vQL.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/79vQL.png&quot; alt=&quot;html loses syntax highlighting inside php return function&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I want to be doing &lt;a href=&quot;http://vim.wikia.com/wiki/Different_syntax_highlighting_within_regions_of_a_file&quot; rel=&quot;noreferrer&quot;&gt;something like this&lt;/a&gt;?  I'm having a hard time figuring out what to make of that and how I would adapt it for my situation, let alone whether or not that's the right approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be great if Vim could automatically recognize HTML inside a PHP file without having to type any hard-to-remember commands.&lt;/p&gt;&#xA;" OwnerUserId="6189" LastEditorUserId="205" LastEditDate="2016-01-29T04:48:01.987" LastActivityDate="2016-01-29T04:48:01.987" Title="Why doesn't Vim recognize HTML inside PHP?" Tags="|syntax-highlighting|filetype-php|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6284" PostTypeId="2" ParentId="6283" CreationDate="2016-01-29T01:58:38.310" Score="6" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#ft%2dphp%2dsyntax&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help ft-php-syntax&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;There are the following options for the php syntax highlighting.&#xA;&#xA;[..]&#xA;&#xA;Enable HTML syntax highlighting inside strings:&#xA;&#xA;  let php_htmlInStrings = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add that your vimrc.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-01-29T01:58:38.310" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6285" PostTypeId="2" ParentId="6282" CreationDate="2016-01-29T02:27:42.600" Score="5" Body="&lt;p&gt;Most likely you've got some conflict with file syntax, which can be confirmed by turning that off:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, by default in vim files (Such as your .vimrc) spell checking is only performed in comments.&lt;/p&gt;&#xA;" OwnerUserId="4932" LastActivityDate="2016-01-29T02:27:42.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6286" PostTypeId="1" CreationDate="2016-01-29T02:52:30.817" Score="7" ViewCount="370" Body="&lt;p&gt;The text inside of &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tags is the same color as the html attributes, so it's hard to distinguish between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/G0iNZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/G0iNZ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The html inside this .php file is colored (line one of this image) almost identically to the html inside an .html file (second line of this image), except for this subtle yet major difference.  The words &quot;This is also red&quot; should be black instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I customize/override the color that one of these (either the p text or the attributes) is displayed in in php files?  Or how can I make it automatically match the colors exactly how they are in an html file?&lt;/p&gt;&#xA;" OwnerUserId="6189" LastEditorUserId="6189" LastEditDate="2016-01-29T14:57:40.563" LastActivityDate="2016-01-29T14:57:40.563" Title=".php file makes html text same color as html attributes - how to fix?" Tags="|syntax-highlighting|filetype-php|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6287" PostTypeId="1" AcceptedAnswerId="6288" CreationDate="2016-01-29T10:46:11.960" Score="13" ViewCount="1749" Body="&lt;p&gt;First of all, with this being my first post here, I'd just like to say that I've found VIM to be a great tool and the forum here to be very helpful in finding answers to questions, with lots of helpful people providing invaluable assistance. I'm still very new to VIM, so pretty much everything I've learned about it has come from here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: I know how to reverse ALL the lines in a file (:g/^/m0 among other ways), but is there a way to reverse every 4 lines in a file, so that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1&#xA;line2&#xA;line3&#xA;line4&#xA;line5&#xA;line6&#xA;line7&#xA;line8&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line4&#xA;line3&#xA;line2&#xA;line1&#xA;line8&#xA;line7&#xA;line6&#xA;line5&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can assume that there will always be an exact multiple of 4 lines in such files.&lt;/p&gt;&#xA;" OwnerUserId="6195" LastEditorUserId="51" LastEditDate="2016-01-29T13:38:03.150" LastActivityDate="2016-02-01T11:29:17.890" Title="How to reverse every 4 lines?" Tags="|vimscript|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6288" PostTypeId="2" ParentId="6287" CreationDate="2016-01-29T11:08:49.963" Score="14" Body="&lt;p&gt;The command &lt;code&gt;:Reverse&lt;/code&gt; explained at &lt;a href=&quot;http://vim.wikia.com/wiki/Reverse_all_lines&quot; rel=&quot;noreferrer&quot;&gt;Vim Wiki&lt;/a&gt; can be used for this (you may include it in your &lt;code&gt;.vimrc&lt;/code&gt; to make it permanent):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar -range=% Reverse &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;g/^/m&amp;lt;line1&amp;gt;-1|nohl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can record a macro to run the command on every four lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qmV3j:Reverse&amp;lt;cr&amp;gt;4jq&#xA;1000@m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qm&lt;/code&gt;: 'q' in normal mode starts (and stops) recording a macro in a given register (register 'm', in this case, but it could be any other letter)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt;: enter visual mode and select the current line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;3j&lt;/code&gt;: expand the visual selection to the next 3 lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:Reverse&amp;lt;cr&amp;gt;&lt;/code&gt;: run the Reverse command on the selected lines (&lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; here stands for the &lt;kbd&gt;enter&lt;/kbd&gt; key)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;4j&lt;/code&gt;: go to the next unchanged lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: stops recording the macro&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1000@m&lt;/code&gt;: run the macro recorded at register 'm' 1000 times (you may increase this number if your file is larger than 4000 lines)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned in the comments, you could use a recursive macro instead of using a count:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qmV3j:Reverse&amp;lt;cr&amp;gt;4jq&#xA;qM@mq&#xA;@m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qM&lt;/code&gt;: if the register specified for &lt;code&gt;q&lt;/code&gt; is uppercase the macro is &lt;em&gt;appended&lt;/em&gt; to the register (which is also useful when you realize when you missed the last steps on a complex macro)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@m&lt;/code&gt;: run the macro on register &lt;code&gt;m&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: stop appending the macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Despite it is created as a macro, you can create a command for this if it is a common task on your workflow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Reverse4()&#xA;   let reg_m = @m&#xA;   let @m = '&amp;lt;c-r&amp;gt;&amp;lt;c-r&amp;gt;m'&#xA;   normal! @m&#xA;   let @m = reg_m&#xA;endfunction&#xA;command! Reverse4 call Reverse4()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;function! Reverse4()&lt;/code&gt;/&lt;code&gt;endfunction&lt;/code&gt;: defines a new function&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;let reg_m = @m&lt;/code&gt;: saves the current contents of register &lt;code&gt;m&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;let @m = &quot;&amp;lt;c-r&amp;gt;&amp;lt;c-r&amp;gt;m&quot;&lt;/code&gt;: insert the macro in the register &lt;code&gt;m&lt;/code&gt; -- note that &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt; is the vim notation for &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt; and that you should &lt;strong&gt;type&lt;/strong&gt; this, not copy/paste, so your line will be similar to &lt;code&gt;let @m = 'V3j:Reverse^M4j@m'&lt;/code&gt; and it will contain a &lt;em&gt;special character&lt;/em&gt; (^M)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal! @m&lt;/code&gt;: the normal command run its argument as it has been typed in normal mode, so it will run the recursive macro&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;let @m = reg_m&lt;/code&gt;: restores the contents of the register &lt;code&gt;m&lt;/code&gt;, so you don't have to remember that this register is being used on this function and avoid using it&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;command! Reverse4 call Reverse4()&lt;/code&gt;: create a new command for this function&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Depending on your needs you could enhance it, e.g.: pass an argument to the command and function so it would work for any number of lines instead of being fixed in groups of 4 lines.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-02-01T11:29:17.890" LastActivityDate="2016-02-01T11:29:17.890" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6289" PostTypeId="2" ParentId="6287" CreationDate="2016-01-29T11:42:35.820" Score="7" Body="&lt;p&gt;You can also do this with an &lt;code&gt;Ex&lt;/code&gt; command using &lt;code&gt;sed&lt;/code&gt; as an external filter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!sed -n 'h;n;G;h;n;G;h;n;G;p'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This version will ignore (delete) any extra lines beyond a multiple of 4.  To keep in the last set of less than 4 lines (reversed), use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!sed -n '$p;h;n;G;$p;h;n;G;$p;h;n;G;p'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;%&lt;/code&gt; here means &quot;Every line in the buffer.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;!&lt;/code&gt; command means &quot;Run the following command with the specified lines as input, and &lt;em&gt;replace&lt;/em&gt; the specified lines with the output of the command.&quot;  (It's called a filter; very handy for such things as sorting, e.g., &lt;code&gt;:%!sort&lt;/code&gt; will sort all the lines in your file; &lt;code&gt;:2,8!sort&lt;/code&gt; will sort lines 2-8, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sed&lt;/code&gt; is the &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;stream editor&lt;/a&gt; tool and is found on all Unix-like systems.  The key concepts of &lt;code&gt;sed&lt;/code&gt; used here are the &quot;pattern space&quot; (which by default just contains each line of the input in turn), and the &quot;hold space&quot; (which is where you can stick extra text while using &lt;code&gt;sed&lt;/code&gt; to save it while processing other lines of input).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;-n&lt;/code&gt; is an option to the &lt;code&gt;sed&lt;/code&gt; command to suppress its default actions of printing the pattern space (because in this case we only want to print when we explicitly say so.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$p&lt;/code&gt; in the &lt;code&gt;sed&lt;/code&gt; command means &quot;If you are on the last line of &lt;code&gt;sed&lt;/code&gt;'s input, print (the pattern space).&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;h&lt;/code&gt; means &quot;stick the current contents of the 'pattern space' in the 'hold space', overwriting whatever's there.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;n&lt;/code&gt; means &quot;replace the contents of the 'pattern space' with the next line from the input.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;G&lt;/code&gt; means &quot;append to the 'pattern space': a newline followed by the contents of the 'hold space'.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taken all together, the &lt;code&gt;sed&lt;/code&gt; command stores up four lines of output, reversing them as it stores them, and then prints them.  The &lt;code&gt;$p&lt;/code&gt; commands added in the second version ensure that if the last line of the file is reached other than on a multiple of 4 lines, the lines are still printed.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For an alternate, interactive approach still without using any Vim-specific features and also without using an external filter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to go to the fourth line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.m -4 | +3m . | +2m . | +5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to reverse the previous four lines (1-4) and leave your cursor on line 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.m -4&lt;/code&gt; moves the current line to just &lt;em&gt;after&lt;/em&gt; the line four lines back (leaving the cursor on the moved line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;+3m .&lt;/code&gt; moves the line that is 3 lines &lt;em&gt;after&lt;/em&gt; the current line, to &lt;em&gt;just&lt;/em&gt; after the current line, leaving the cursor on the moved line.  &lt;code&gt;+2m .&lt;/code&gt; of course works the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;+5&lt;/code&gt; places the cursor five lines down from where it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Repeat as desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim you can repeat this whole command with &lt;code&gt;@:&lt;/code&gt;, then repeat again with &lt;code&gt;@@&lt;/code&gt;.  In POSIX &lt;code&gt;vi&lt;/code&gt; or &lt;code&gt;ex&lt;/code&gt; you would need to &lt;em&gt;insert&lt;/em&gt; &lt;code&gt;:.m -4 | +3m . | +2m . | +5&lt;/code&gt; as a line of text, delete it to a named buffer (register), and then execute that named buffer (register).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in &lt;code&gt;ex&lt;/code&gt; mode, reversing lines interactively using POSIX-specified features only, and starting with 17 lines of text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Entering Ex mode.  Type &quot;visual&quot; to go to Normal mode.&#xA;:0a     # Append following text after &quot;line 0&quot; (i.e. insert at start of file).&#xA;.m -4 | +3m . | +2m . | +5&#xA;.       # End text insertion&#xA;:d k    # Delete that line to register k&#xA;line1   # This is a printout of the current line&#xA;:4      # Move to line 4&#xA;line4&#xA;:@k     # Execute register k to reverse lines 1-4&#xA;line8&#xA;:@@     # Execute register k again&#xA;line12&#xA;:@@     # Execute register k again&#xA;line16&#xA;:@@     # Execute register k again&#xA;line17&#xA;:%p     # Print the whole buffer (just to see what was done)&#xA;line4&#xA;line3&#xA;line2&#xA;line1&#xA;line8&#xA;line7&#xA;line6&#xA;line5&#xA;line12&#xA;line11&#xA;line10&#xA;line9&#xA;line16&#xA;line15&#xA;line14&#xA;line13&#xA;line17&#xA;:wq     # Save and quit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Further reading:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;POSIX specifications for &lt;code&gt;ex&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;POSIX specifications for &lt;code&gt;vi&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/457/4676&quot;&gt;Does Ex mode have any practical use?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-01-29T12:34:35.213" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6290" PostTypeId="2" ParentId="6287" CreationDate="2016-01-29T14:11:15.317" Score="9" Body="&lt;p&gt;As with &lt;a href=&quot;https://vi.stackexchange.com/a/4156/343&quot;&gt;all&lt;/a&gt; &lt;a href=&quot;https://vi.stackexchange.com/a/3110/343&quot;&gt;repetitive&lt;/a&gt; &lt;a href=&quot;https://vi.stackexchange.com/a/5600/343&quot;&gt;actions&lt;/a&gt;, if you can do something once with basic edit operations, then you can easily do it lots of times by recording a macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In this case I shall use a recursive macro, but you could just record a non-recursive one and play it back multiple times by hammering &lt;code&gt;@@&lt;/code&gt; or by using a count.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ggqqqqqddjjpkddkkPjddpjj@qq@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Broken down&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;gg&lt;/code&gt;: Move to the start of the file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qqq&lt;/code&gt;: Clear out register &lt;code&gt;q&lt;/code&gt;. We'll see why this is necessary in step 5.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt;: Start recording a macro to register q&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ddjjpkddkkPjddpjj&lt;/code&gt;: A series of operations that reorders the first four lines simply by deleting and pasting them manually. (This might look complicated at first glance, but don't be deceived. This is very basic stuff that you'd have learned in the first 5 mins or so of &lt;code&gt;vimtutor&lt;/code&gt;: &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, &lt;code&gt;dd&lt;/code&gt;, &lt;code&gt;p&lt;/code&gt;, &lt;code&gt;P&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@q&lt;/code&gt;: Call the macro! At this point, register &lt;code&gt;q&lt;/code&gt; contains nothing (because we cleared it in step 2), so nothing will happen.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: Stop recording the macro.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@q&lt;/code&gt;: Replay the recursive macro as many times as necessary.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;N.B. The above won't produce the desired results if the file contains a number of lines that is not exactly divisible by four. In order to stop the macro early if there aren't four lines left, we need to carry out a Vim normal-mode command that will fail, &lt;em&gt;before&lt;/em&gt; we start applying the edits in step 4. We can do this by attempting to move down a line three times (and then back up) before we start moving lines around: &lt;code&gt;jjj3k&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ggqqqqqjjj3kddjjpkddkkPjddpjj@qq@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-01-29T15:49:39.407" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="6291" PostTypeId="1" AcceptedAnswerId="6707" CreationDate="2016-01-29T15:41:03.270" Score="4" ViewCount="3754" Body="&lt;p&gt;I don't want to &lt;a href=&quot;https://stackoverflow.com/questions/1527784/what-is-vim-recording-and-how-can-it-be-disabled&quot;&gt;disable recording entirely&lt;/a&gt;, but I'm not happy with vim keeping my recordings between sessions, and occasionally I fat finger the &lt;kbd&gt;@&lt;/kbd&gt; key and end up with a bunch of garbage in the active buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I ensure that &lt;em&gt;all&lt;/em&gt; recordings are deleted (e.g. when I restart vim)?&lt;/p&gt;&#xA;" OwnerUserId="5339" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-02-27T16:23:44.100" Title="Delete all recordings?" Tags="|macro|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6293" PostTypeId="1" CreationDate="2016-01-29T20:09:00.810" Score="4" ViewCount="663" Body="&lt;p&gt;How can I substitute all except the last asterisk in groups of two or more asterisks with two spaces?  E.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* Micro topic 1&#xA;** Microbes are small&#xA;** You can't see them!&#xA;*** Isn't that something?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* Micro topic 1&#xA;  * Microbes are small&#xA;  * You can't see them!&#xA;    * Isn't that something?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to modify of &lt;code&gt;/^\*\{2,}&lt;/code&gt; to match all but the last asterisk in the group and then perform the substitution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or &lt;code&gt;:g/^\*\{2,}/s/\*/&lt;/code&gt; with a range, so that it will subsitute each asterisk with two spaces, while leaving the last asterisk?  E.g. &lt;code&gt;***&lt;/code&gt; becomes &lt;code&gt;*&lt;/code&gt;  (four spaces and an asterisk)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;:g/^\*\{2,}/s/\*\+/&lt;/code&gt; to replace the asterisks with spaces, but it doesn't replace the asterisks individually.&lt;/p&gt;&#xA;" OwnerUserId="6053" LastEditorUserId="6053" LastEditDate="2016-01-29T20:27:40.547" LastActivityDate="2016-01-29T20:45:05.953" Title="Substitute all except the last asterisk in groups of two or more asterisks" Tags="|regular-expression|substitute|global-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6294" PostTypeId="1" AcceptedAnswerId="6348" CreationDate="2016-01-29T20:14:14.187" Score="9" ViewCount="4310" Body="&lt;p&gt;I have Windows 7 64-bit, with python 2.7.11 and python 3.5.1 (both 32-bit) installed, and I have compiled vim with python/dyn and python3/dyn, but I keep getting the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py print &quot;hello&quot;&#xA;E887: Sorry, this command is disabled, the Python's site module could not be loaded&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the following all work just fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\python27\python -c &quot;import site;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py3 print(&quot;hello&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my vim version info:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 29 2016 11:58:41)&#xA;MS-Windows 32-bit console version&#xA;Included patches: 1-1194&#xA;Compiled by afontaine@PHOENIX&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl                +eval               -mouseshape         +tag_old_static&#xA;+arabic             +ex_extra           +multi_byte_ime/dyn -tag_any_white&#xA;+autocmd            +extra_search       +multi_lang         -tcl&#xA;-balloon_eval       +farsi              -mzscheme           -tgetent&#xA;-browse             +file_in_path       -netbeans_intg      -termresponse&#xA;++builtin_terms     +find_in_path       +path_extra         +textobjects&#xA;+byte_offset        +float              -perl               +title&#xA;-channel            +folding            +persistent_undo    -toolbar&#xA;+cindent            -footer             -postscript         +user_commands&#xA;+clientserver       +gettext/dyn        +printer            +vertsplit&#xA;+clipboard          -hangul_input       +profile            +virtualedit&#xA;+cmdline_compl      +iconv/dyn          +python/dyn         +visual&#xA;+cmdline_hist       +insert_expand      +python3/dyn        +visualextra&#xA;+cmdline_info       +jumplist           +quickfix           +viminfo&#xA;+comments           +keymap             +reltime            +vreplace&#xA;+conceal            +langmap            +rightleft          +wildignore&#xA;+cryptv             +libcall            -ruby               +wildmenu&#xA;+cscope             +linebreak          +scrollbind         +windows&#xA;+cursorbind         +lispindent         +signs              +writebackup&#xA;+cursorshape        +listcmds           +smartindent        -xfontset&#xA;+dialog_con         +localmap           -sniff              -xim&#xA;+diff               -lua                +startuptime        -xterm_save&#xA;+digraphs           +menu               +statusline         -xpm_w32&#xA;-dnd                +mksession          -sun_workshop       &#xA;-ebcdic             +modify_fname       +syntax             &#xA;+emacs_tags         +mouse              +tag_binary&#xA;Compilation: gcc -Iproto -DWIN32 -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -DHAVE_PATHDEF -DFEAT_HUGE -DHAVE_GETTEXT -DHAVE_LOCALE_H -DDYNAMIC_GETTEXT -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG -DFEAT_CHANNEL -DFEAT_GUI_W32 -DFEAT_CLIPBOARD -DFEAT_MBYTE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DDYNAMIC_ICONV -pipe -w -march=i386 -Wall -DFEAT_PYTHON  -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=&quot;python27.dll&quot; -DFEAT_PYTHON3  -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=&quot;python35.dll&quot; -DFEAT_XPM_W32 -I xpm/x86/include -I xpm/x86/../include -O3 -fomit-frame-pointer -freg-struct-return -s&#xA;Linking: gcc -Iproto -DWIN32 -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -DHAVE_PATHDEF -DFEAT_HUGE -DHAVE_GETTEXT -DHAVE_LOCALE_H -DDYNAMIC_GETTEXT -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG -DFEAT_CHANNEL -DFEAT_GUI_W32 -DFEAT_CLIPBOARD -DFEAT_MBYTE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DDYNAMIC_ICONV -pipe -w -march=i386 -Wall -DFEAT_PYTHON  -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=&quot;python27.dll&quot; -DFEAT_PYTHON3  -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=&quot;python35.dll&quot; -DFEAT_XPM_W32 -I xpm/x86/include -I xpm/x86/../include -O3 -fomit-frame-pointer -freg-struct-return -s -mwindows -o gvim.exe -lkernel32 -luser32 -lgdi32 -ladvapi32 -lcomdlg32 -lcomctl32 -lversion -lwsock32 -Lxpm/x86/lib -lXpm -lole32 -luuid      &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;where python27.dll&lt;/code&gt; outputs &lt;code&gt;C:\Windows\System32&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried the advice from &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_dev/gsggIcWJKuM&quot; rel=&quot;noreferrer&quot;&gt;this google group post&lt;/a&gt;, but to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want to have YouCompleteMe running successfully.&lt;/p&gt;&#xA;" OwnerUserId="2010" LastEditorUserId="2010" LastEditDate="2016-02-02T20:07:00.270" LastActivityDate="2017-03-19T14:29:05.197" Title="How do I use Python plugins on Windows?" Tags="|microsoft-windows|vimscript-python|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6295" PostTypeId="1" CreationDate="2016-01-29T20:14:45.833" Score="1" ViewCount="92" Body="&lt;p&gt;Is there a way to make a substitution only at the beginning and end of a pattern and NOT line by line?  E.g., searching for the pattern &lt;code&gt;/^\*\{2,}.*&lt;/code&gt; in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* Micro topic 1&#xA;** Microbes are small&#xA;** You can't see them!&#xA;*** Isn't that something?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and surrounding the entire pattern in quotes would yield:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* Micro topic 1&#xA;&quot;** Microbes are small&#xA;** You can't see them!&#xA;*** Isn't that something?&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6053" LastActivityDate="2019-10-22T12:56:47.283" Title="Substitute at begining and end of a pattern (not line by line)" Tags="|regular-expression|substitute|global-command|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6296" PostTypeId="1" AcceptedAnswerId="6302" CreationDate="2016-01-29T20:23:57.437" Score="2" ViewCount="1148" Body="&lt;p&gt;I am a new vim user, and I don't know why but my first buffer (the [No Name] buffer) is not empty each time I open it, still after rebooting my computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It begins with &lt;code&gt;:q!&lt;/code&gt; then the end of my .vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And when I open a file with vim from the command line it says before :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;client.c&quot; &quot;client.c&quot; 58L, 1558C &#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then a buffer with the file content preceded by the same text as when I open vim without opening a file, like described before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I may have done something wrong but I don't know what and I haven't found any information about how to change the default buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; The text begins by :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:q!¬                                                                        &#xA; ¬&#xA; &quot; Add plugins to &amp;amp;runtimepath¬&#xA; call plug#end()¬&#xA; ¬&#xA; &quot; Syntastic¬&#xA; set statusline+=%#warningmsg#¬&#xA; set statusline+=%{SyntasticStatuslineFlag()}¬&#xA; set statusline+=%*¬&#xA; ¬&#xA; let g:syntastic_always_populate_loc_list = 1¬&#xA; let g:syntastic_auto_loc_list = 1¬&#xA; let g:syntastic_check_on_open = 1¬&#xA; let g:syntastic_check_on_wq = 0¬&#xA; ¬&#xA; ¬&#xA; &quot; Window navigation with Control¬&#xA; nnoremap &amp;lt;C-h&amp;gt; &amp;lt;C-w&amp;gt;h¬&#xA; nnoremap &amp;lt;C-j&amp;gt; &amp;lt;C-w&amp;gt;j¬&#xA; nnoremap &amp;lt;C-k&amp;gt; &amp;lt;C-w&amp;gt;k¬&#xA; nnoremap &amp;lt;C-l&amp;gt; &amp;lt;C-w&amp;gt;l¬&#xA; &quot; Tab navigation¬&#xA;nnoremap th  :tabfirst&amp;lt;CR&amp;gt;¬  &#xA;nnoremap tj  :tabnext&amp;lt;CR&amp;gt;¬&#xA;nnoremap tk  :tabprev&amp;lt;CR&amp;gt;¬&#xA;nnoremap tl  :tablast&amp;lt;CR&amp;gt;¬&#xA;nnoremap tt  :tabedit&amp;lt;Space&amp;gt;¬&#xA;nnoremap tm  :tabm&amp;lt;Space&amp;gt;¬&#xA;nnoremap td  :tabclose&amp;lt;CR&amp;gt;¬&#xA;nnoremap tn :tabnew&amp;lt;CR&amp;gt;¬&#xA;nnoremap to :tabonly&amp;lt;CR&amp;gt;¬&#xA;nnoremap ts :tab split&amp;lt;CR&amp;gt;¬&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6078" LastEditorUserId="51" LastEditDate="2016-01-30T00:45:21.690" LastActivityDate="2016-01-30T18:03:48.437" Title="First buffer (the [No Name] buffer) is not empty when I start Vim" Tags="|buffers|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6297" PostTypeId="2" ParentId="6293" CreationDate="2016-01-29T20:45:05.953" Score="3" Body="&lt;p&gt;You can match &quot;each asterisk that is followed by an asterisk&quot;. This is true for all asterisks but the last one. You can then substitute this for two spaces. One way to express that pattern is by ending the match after a single asterisk, but including a trailing asterisk in the pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\*\ze\*/  /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help /\ze&lt;/code&gt; for information about the end-of-match pattern atom.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2016-01-29T20:45:05.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6298" PostTypeId="1" AcceptedAnswerId="6300" CreationDate="2016-01-29T21:12:20.050" Score="3" ViewCount="402" Body="&lt;p&gt;When I open vim (or gvim) on MacOS X, the window opens immediately, but there is a pause of about a second before the cursor appears.  I've profiled my plugins, but their startup times don't account for the length of the pause:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ExecTime&quot;   &quot;PluginName&quot;&#xA;42.126  &quot;syntastic&quot;&#xA;15.896  &quot;unite.vim&quot;&#xA;7.116   &quot;vim-textobj-rubyblock&quot;&#xA;6.77    &quot;vim-fugitive&quot;&#xA;6.653   &quot;vim-easymotion&quot;&#xA;4.707   &quot;tabular&quot;&#xA;1.787   &quot;neomru.vim&quot;&#xA;1.585   &quot;vim-table-mode&quot;&#xA;1.376   &quot;tagbar&quot;&#xA;1.106   &quot;L9&quot;&#xA;1.053   &quot;vim-textobj-user&quot;&#xA;1.042   &quot;neoyank.vim&quot;&#xA;1.027   &quot;vim-surround&quot;&#xA;0.679   &quot;vim-exchange&quot;&#xA;0.667   &quot;Vundle.vim&quot;&#xA;0.645   &quot;neocomplete.vim&quot;&#xA;0.512   &quot;neosnippet.vim&quot;&#xA;0.355   &quot;vim-commentary&quot;&#xA;0.321   &quot;restore_view.vim&quot;&#xA;0.187   &quot;ag.vim&quot;&#xA;0.167   &quot;vimproc.vim&quot;&#xA;0.15    &quot;tern_for_vim&quot;&#xA;0.115   &quot;vim-javascript-syntax&quot;&#xA;0.114   &quot;scss-syntax.vim&quot;&#xA;0.113   &quot;vim-slim&quot;&#xA;0.099   &quot;vim-snippets&quot;&#xA;0.077   &quot;Rename&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I use the &lt;code&gt;--startuptime&lt;/code&gt; flag it produces a file 2 million lines long, and I don't know how to extract the relevant info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be causing the problem?  How else can I debug it?&lt;/p&gt;&#xA;" OwnerUserId="5373" LastActivityDate="2016-01-29T22:26:01.410" Title="Slow startup time unrelated to plugins" Tags="|vimscript|vimrc|performance|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6299" PostTypeId="2" ParentId="6287" CreationDate="2016-01-29T22:25:17.797" Score="7" Body="&lt;pre&gt;&lt;code&gt;:g/^/exe 'm .-' . substitute(line('.') % 4, '^0$', '4', '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Plain English: For every line, move the current line up &lt;code&gt;lnum % 4&lt;/code&gt;, unless &lt;code&gt;lnum % 4 == 0&lt;/code&gt;, in which case move the current line up &lt;code&gt;4&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, to reverse every &lt;code&gt;n&lt;/code&gt; lines, replace the &lt;code&gt;4&lt;/code&gt;'s in the above command with &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6206" LastEditorUserId="6206" LastEditDate="2016-01-29T22:41:18.267" LastActivityDate="2016-01-29T22:41:18.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6300" PostTypeId="2" ParentId="6298" CreationDate="2016-01-29T22:26:01.410" Score="4" Body="&lt;p&gt;If you are debugging plugins, then do the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disable half of your plugins.&#xA;If it fixes the problem, re-enable half of the disabled ones.&#xA;If it doesn't, disable half of the ones not yet disabled.&#xA;Repeat until you have proven which plugin is the cause, or that none is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your happy case is found by running &lt;code&gt;vim -u NONE.&lt;/code&gt;&#xA;If that does not suffer from the problem then there is something in your startup sequence that is causing it.&#xA;If you find that no plugin was the cause, extend the bisection to the rest of your &lt;em&gt;vimrc&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disable half of the rest of your &lt;em&gt;vimrc&lt;/em&gt;.&#xA;If it fixes the problem, re-enable half of the disable part.&#xA;If it doesn't, disable half of the not yet disabled part.&#xA;Repeat until you have proven which part of your &lt;em&gt;vimrc&lt;/em&gt; is the cause, or that none is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this happens when you open Vim o edit a particular file, then details of that file may be important.&#xA;You should also investigate the output of &lt;code&gt;:scriptnames&lt;/code&gt; to see what scripts have been run since you started Vim.&#xA;If &lt;code&gt;vim -u NONE&lt;/code&gt; is OK, the culprit will be in there somewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;How do I debug my vimrc file?&lt;/a&gt; and &lt;a href=&quot;http://vim.wikia.com/wiki/Bisecting&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Bisecting&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2016-01-29T22:26:01.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6301" PostTypeId="2" ParentId="6296" CreationDate="2016-01-29T22:31:04.393" Score="2" Body="&lt;p&gt;If the &lt;code&gt;vimrc&lt;/code&gt; contains errors like literal&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:a!&#xA;:q!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it will print the rest of the file in the first buffer, and also at the beginning of files opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So be sure to check your &lt;code&gt;vimrc&lt;/code&gt; from errors.&lt;/p&gt;&#xA;" OwnerUserId="6078" LastEditorUserId="205" LastEditDate="2016-01-30T18:03:48.437" LastActivityDate="2016-01-30T18:03:48.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6302" PostTypeId="2" ParentId="6296" CreationDate="2016-01-29T22:31:46.890" Score="2" Body="&lt;p&gt;Some of the lines of your &lt;em&gt;vimrc&lt;/em&gt; are input as text into whatever buffer you are loading.&#xA;It looks like there is something happening in your &lt;em&gt;vimrc&lt;/em&gt; which stops the lines being processed as ex commands and instead are input as text into the buffer.&#xA;Look at the lines in your &lt;em&gt;vimrc&lt;/em&gt; just at that break point and you may find the culprit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you by any chance have a literal &lt;code&gt;:q!&lt;/code&gt; in there?&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2016-01-29T22:31:46.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6303" PostTypeId="1" CreationDate="2016-01-29T22:46:13.450" Score="5" ViewCount="63" Body="&lt;p&gt;Is there a way to use &lt;code&gt;:help&lt;/code&gt; to find commands  that take arguments vs. no arguments?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: &lt;code&gt;:map&lt;/code&gt; (w/o arguments) can list the key mappings for various modes. However, &lt;code&gt;:help :map&lt;/code&gt; leads me to &lt;code&gt;:map {lhs} {rhs}&lt;/code&gt; (around line 48) instead of line 114 which explains &lt;code&gt;:map&lt;/code&gt; w/o arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I have to type &lt;code&gt;/:map&lt;/code&gt; then &lt;code&gt;n&lt;/code&gt; over and over again to find it the section  (around line 114) that contains &lt;code&gt;:map&lt;/code&gt; w/o arguments. &lt;/p&gt;&#xA;" OwnerUserId="6207" LastActivityDate="2016-01-29T22:46:13.450" Title="Is it possible to look up a command that takes no arguments?" Tags="|help-system|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6304" PostTypeId="1" AcceptedAnswerId="6317" CreationDate="2016-01-30T01:02:33.567" Score="3" ViewCount="1115" Body="&lt;p&gt;This question might be a little bit out of the ordinary for this site, but I want to better understand how vim works under the hood. I know that if I enter the hex value &lt;code&gt;0x01&lt;/code&gt; vim will display it as &lt;code&gt;^A&lt;/code&gt;. Does that mean when I hit &lt;code&gt;&amp;lt;ctrl-a&amp;gt;&lt;/code&gt; on my keyboard, vim will receive my keystroke as &lt;code&gt;0x01&lt;/code&gt;? Or does it receive it as something totally unrelated, like two separate keys?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, this question is somewhat related, but are there any characters (including the extended ascii codes 128-255) that vim does not accept as a valid normal mode keystroke? Which ones, or could you point me to a list of all of them somewhere?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="51" LastEditDate="2016-01-30T01:10:06.377" LastActivityDate="2016-02-02T10:08:46.110" Title="How does vim map keystrokes to hex values?" Tags="|key-bindings|terminal|encoding|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6305" PostTypeId="1" AcceptedAnswerId="6309" CreationDate="2016-01-30T13:51:38.460" Score="6" ViewCount="964" Body="&lt;p&gt;Many sections of stuff we right is such that it could be automatically formatted by user defined rules. Here are a couple of examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;List of include files in languages such as C. It is customary to sort these alphabetically, and this sorting is also part of style guides such as those of Google.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Ditto for &lt;code&gt;usepackage&lt;/code&gt; in &lt;code&gt;LaTeX&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Comments in languages such as BASH&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Tables, which could be processed by &lt;code&gt;column -t&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The entire file, from which I would like to automatically remove spaces at eoln, and repeated empty lines.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Doing these in vi is not tough. Just do something like &lt;code&gt;!}sort -u&lt;/code&gt;. What's annoying is the need to do this repeatedly. Ideally, I would write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// AUTO: `!}sort -u | column -t`&#xA;#include &quot;z.h&quot;&#xA;#include &quot;a.h&quot;&#xA;#include &quot;b.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and each time I save my file, these specially marked commands will execute.  Is this possible to do? Are there any plugins that do something similar?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inspiration may be drawn from this question: &lt;a href=&quot;https://vi.stackexchange.com/questions/4906/apply-formating-with-a-script-or-have-ftplugin-format-particular-text-based-on&quot;&gt;Apply formating with a script, or have ftplugin format particular text based on syntax&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Here is another concrete example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# To sort: +2,/)/-1!column -t | sort&#xA;JUNKFILES = $(wildcard \&#xA;*~             \&#xA;*.aux          \&#xA;*.out          \&#xA;*.bbl          \&#xA;*.bcf          \&#xA;*.blg          \&#xA;*blx.bib       \&#xA;[dD]elme*      \&#xA;DELME*         \&#xA;*.dvi          \&#xA;*.fdb_latexmk  \&#xA;*.fls          \&#xA;*.listing      \&#xA;*.log          \&#xA;$(MAIN).pdf    \&#xA;*.o            \&#xA;*.out          \&#xA;*.run.xml      \&#xA;*.synctex.gz   \&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-02-24T22:58:52.557" Title="Auto sorting of lists of include files" Tags="|vimscript|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6306" PostTypeId="2" ParentId="4572" CreationDate="2016-01-30T18:13:39.630" Score="0" Body="&lt;p&gt;Indentation in vim is performed simply using the following script&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Script to perform Indentation of a single file&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash &#xA;#Author: Ankit shah&#xA;#Enter file name to indent as argument&#xA;file=$1&#xA;vim $file -c &quot;normal gg=G&quot; -c &quot;wq&quot;&#xA;#Use expand command to turn tabs into spaces. Code uniform across different vim environment&#xA;expand -t 4 $file $file &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3007" LastActivityDate="2016-01-30T18:13:39.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6307" PostTypeId="1" AcceptedAnswerId="6323" CreationDate="2016-01-31T09:37:39.420" Score="20" ViewCount="18412" Body="&lt;p&gt;I was reading &lt;strong&gt;vimtutor&lt;/strong&gt; and in lesson 2.1 there was this note about typing commands like &lt;strong&gt;dw&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NOTE: The letter  d  will appear on the last line of the screen as you type&#xA;    it.  Vim is waiting for you to type  w .  If you see another character&#xA;    than  d  you typed something wrong; press  &amp;lt;ESC&amp;gt;  and start over.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I can't see the commands that I am typing in command line neither in vim or gvim. How can I fix that?&lt;/p&gt;&#xA;" OwnerUserId="6219" LastActivityDate="2016-08-09T07:00:07.443" Title="vim doesn't show the command that is being typed" Tags="|command-line|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6308" PostTypeId="2" ParentId="6307" CreationDate="2016-01-31T10:26:37.393" Score="17" Body="&lt;p&gt;This behaviour is controlled by the &lt;code&gt;showcmd&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set showcmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and see if that brings it back.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2016-01-31T10:26:37.393" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6309" PostTypeId="2" ParentId="6305" CreationDate="2016-01-31T14:32:38.170" Score="4" Body="&lt;p&gt;You want to automatically run a command when you write your buffer, and the n save your buffer after the command.. This means you're looking for an &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocmd-intro&quot;&gt;autocmd&lt;/a&gt; that runs during a &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#BufWrite&quot;&gt;BufWrite&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Place something like this into your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWrite *.c call Libsort()&#xA;function Libsort()&#xA;    normal mfgg}&#xA;    let lineNumber = line('.') - 1&#xA;    execute '1,' . lineNumber . '!sort -u'&#xA;    normal 'f&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should do something similar to what you want. When you write your current buffer, if it is a .c file, it marks your current position, goes to the start of the document and sorts the first paragraph, and then returns to the mark. I wrote that function quite quickly, so it's not error checked or anything but should give you an idea for a starting point.&lt;/p&gt;&#xA;" OwnerUserId="4932" LastActivityDate="2016-01-31T14:32:38.170" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6310" PostTypeId="1" CreationDate="2016-01-31T17:00:20.437" Score="2" ViewCount="673" Body="&lt;p&gt;I'm trying to get SuperTab to work a particular way with &lt;code&gt;.tex&lt;/code&gt; files. I am also using the vimtex plugin as well as snipMate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior I want is the following.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;In most text, I want the main priority to be completing snipMate snippets. If none are found, then I want a real tab.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;However if I have started to write a &lt;code&gt;\ref&lt;/code&gt;, &lt;code&gt;\cite&lt;/code&gt;, &lt;code&gt;\eqref&lt;/code&gt;, &lt;code&gt;\include&lt;/code&gt; or &lt;code&gt;\includegraphics&lt;/code&gt; (did I miss any?) command, I want omnicomplete first. If omnicomplete can't find anything then I want nothing to happen (i.e. no real tab).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In general, I never want tab to initiate a &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; keyword completion ever for any reason!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have been through the SuperTab documentation several times and I just don't get it. I can't see how the plugin works well enough to determine what settings I need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I am using the default settings. The behavior I am seeing is that snipMate snippets are being completed first (that's what I want) except they are always taking precedence even after a &lt;code&gt;\ref{&lt;/code&gt; for example. If no snippet is found I am always getting keyword completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I decided to overhaul my whole setup to address this. It took some effort, but seems to work the way I want it now and is probably better in the long run.&#xA;The new approach is to use YouCompleteMe for completion, UltiSnips for snippets, and SuperTab to hack the previous two via this clever configuration: &lt;a href=&quot;https://stackoverflow.com/a/22253548/509489&quot;&gt;https://stackoverflow.com/a/22253548/509489&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the problem is now resolved (although not solved)&lt;/p&gt;&#xA;" OwnerUserId="5464" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-02-04T22:59:26.500" Title="Trying to get a particular SuperTab behavior with snippets and omnicomplete" Tags="|autocompletion|filetype-tex|plugin-vimtex|plugin-supertab|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6311" PostTypeId="1" CreationDate="2016-02-01T02:44:10.370" Score="2" ViewCount="85" Body="&lt;p&gt;I read this description of a different example, &lt;a href=&quot;https://vi.stackexchange.com/questions/1920/how-does-g-j-reduce-multiple-blank-lines-to-a-single-blank-work-in-vi&quot;&gt;substitute command&lt;/a&gt; and it was very helpful, but I'm still not fully certain how to interpret the commands in &lt;code&gt;:g /start1/.,/start2/-1 move /end/-1&lt;/code&gt;.  It is supposed to be something that has the text &lt;code&gt;start1&lt;/code&gt; on some line, followed by text, followed by a line that contains &lt;code&gt;start2&lt;/code&gt;, followed by a line that has &lt;code&gt;end&lt;/code&gt;.  In outline, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;texttexttext &#xA;.Rh start1 &#xA;.Rf some text &#xA;some more &#xA;... &#xA;.Rh start2 &#xA;more text &#xA;... &#xA;.Rh end &#xA;textytextytext&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The search-and-replace command is supposed to take everything from &lt;code&gt;.Rh start1&lt;/code&gt; to just before &lt;code&gt;.Rh start2&lt;/code&gt; and move it between &lt;code&gt;.Rh end&lt;/code&gt; and &lt;code&gt;textytextytext&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I read it so far, &lt;code&gt;:g /start1/...&lt;/code&gt; says to globally search for &lt;code&gt;start1&lt;/code&gt; and do &lt;code&gt;...&lt;/code&gt;.  Now since the &lt;code&gt;...&lt;/code&gt; is &lt;code&gt;.,/start2/-1 move /end/-1&lt;/code&gt; what does this mean?  I take the &lt;code&gt;.&lt;/code&gt; to be a regex for &quot;any character&quot;, which is just followed by a comma.  Is Vim searching for that character-comma combination?  Or is it replacing the start1 line with it?  &lt;/p&gt;&#xA;" OwnerUserId="6225" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-02-01T05:20:44.170" Title="How does this search-and-replace command work? `:g /start1/.,/start2/-1 move /end/-1`" Tags="|search|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6312" PostTypeId="2" ParentId="6311" CreationDate="2016-02-01T03:23:02.720" Score="2" Body="&lt;p&gt;After reading some websites I think I may have answered my own question.  I believe the behavior goes like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:g/start1/...&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;indeed means, throughout the document, search for &quot;start1&quot; and do &quot;...&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;...&quot; is &lt;code&gt;.,/start2/-1 ...&lt;/code&gt; where the &lt;code&gt;.&lt;/code&gt; is actually not a regex but a Vim symbol that effectively refers to the line on which the search string was found, and the comma means &quot;select everything from the first part to the next part&quot;.  The first part was, as we've seen, the line on which &quot;start1&quot; appears.  The next part is the &lt;code&gt;start2/-1&lt;/code&gt; which is the next line on which &quot;start2&quot; appears, and then back-stepped by 1.  So this effectively selects everything from start1 to start2, not including the line containing start2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;move&lt;/code&gt; is then given and blah blah blah the rest is obvious.&lt;/p&gt;&#xA;" OwnerUserId="6225" LastActivityDate="2016-02-01T03:23:02.720" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6313" PostTypeId="1" AcceptedAnswerId="6316" CreationDate="2016-02-01T10:07:50.247" Score="1" ViewCount="812" Body="&lt;p&gt;I would like to fix only spacing in badly formatted C/C++ source code.&#xA;The Vim command &lt;code&gt;=&lt;/code&gt; fixes only indentation. Utility &lt;code&gt;indent&lt;/code&gt; is not suitable, because it reformats totally all source code, but want to minimize changes (for example avoid to break lines, minimize noise for diff and SCM).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, fix&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; for( i=1; i&amp;lt;10; i++ ){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (i = 1; i &amp;lt; 10; i++) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6229" LastEditorUserId="6229" LastEditDate="2016-02-01T11:59:28.187" LastActivityDate="2016-02-01T12:16:30.643" Title="Fix spacing with vim" Tags="|indentation|whitespace|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6314" PostTypeId="1" CreationDate="2016-02-01T11:01:35.223" Score="2" ViewCount="358" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/thoughtbot/vim-rspec&quot; rel=&quot;nofollow&quot;&gt;vim-rspec&lt;/a&gt; on a mac with macvim and iterm. I'm using &lt;a href=&quot;https://github.com/thoughtbot/vim-rspec/blob/2cf8c5002cb89eb8e9aabe59d25b89dc5afec88a/plugin/rspec.vim#L44&quot; rel=&quot;nofollow&quot;&gt;this command&lt;/a&gt; to clear the iTerm screen and run the test in iTerm.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:rspec_command = &quot;clear &amp;amp;&amp;amp; rspec {spec}&quot;&#xA;let g:rspec_runner = &quot;os_x_iterm&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wanted to know what will be the command to interrupt the current process like with &lt;code&gt;Ctrl+c&lt;/code&gt;. I've try &lt;code&gt;^\Quit &amp;amp;&amp;amp; clear &amp;amp;&amp;amp; rspec {spec}&lt;/code&gt; but I get &lt;code&gt;zsh: substitution failed&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="3357" LastEditorUserId="3357" LastEditDate="2016-02-01T11:25:01.503" LastActivityDate="2016-02-01T11:25:01.503" Title="Send SIGINT to iTerm from vim" Tags="|terminal|macvim|iterm2|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6315" PostTypeId="2" ParentId="495" CreationDate="2016-02-01T11:25:09.603" Score="3" Body="&lt;p&gt;Try using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expand -t 4 input_filename output_filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;expand&lt;/code&gt; is a command-line tool to convert tabs to spaces, which you can run from a shell or with &lt;code&gt;:!expand&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/expand.html&quot; rel=&quot;nofollow&quot;&gt;in POSIX&lt;/a&gt; so it should be available on most systems. &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/unexpand.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;unexpand&lt;/code&gt;&lt;/a&gt; will do the reverse, by the way.&lt;/p&gt;&#xA;" OwnerUserId="3007" LastEditorUserId="51" LastEditDate="2016-02-01T14:11:27.437" LastActivityDate="2016-02-01T14:11:27.437" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6316" PostTypeId="2" ParentId="6313" CreationDate="2016-02-01T11:50:54.077" Score="2" Body="&lt;p&gt;This function almost does the job.&#xA;Comment on the right side shows result&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Fix_spacing()&#xA;    %s/\&amp;lt;\(if\|for\|while\|switch\)(\s*/\1 (/ge     &quot; if (&#xA;    %s/\&amp;lt;\(else\){/\1 {/ge                          &quot; else {&#xA;    %s/}\(else\)/} \1/ge                            &quot; } else&#xA;    %s/ *){ */) {/ge                                &quot; ) {&#xA;    %s/\((\) \(\S\)/\1\2/ge                         &quot; no space after (&#xA;    %s/\n\n\n\+/\r\r/ge                             &quot; single empty line&#xA;    %s/\([,;]\)\(\S\)/\1 \2/ge                      &quot; space after ,;&#xA;    %s/\(\S\) \([,;)]\)/\1\2/ge                     &quot; no space before ,;)&#xA;    %s/\s*$//ge                                     &quot; no terminal space&#xA;    %s/^\([^ ^\t].*\){/\1\r{/ge                     &quot; { on new line for functions&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code inserts and deletes spaces around some keywords, brackets, comma, semicolon, terminal space and some line fixes.&lt;/p&gt;&#xA;" OwnerUserId="6229" LastEditorUserId="6229" LastEditDate="2016-02-01T12:16:30.643" LastActivityDate="2016-02-01T12:16:30.643" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6317" PostTypeId="2" ParentId="6304" CreationDate="2016-02-01T16:53:27.063" Score="4" Body="&lt;p&gt;The question &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-20.5&quot; rel=&quot;nofollow&quot;&gt;20.5 of the Vim FAQ&lt;/a&gt; seems to indicate that vim will receive a single character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;20.5. Why does mapping the &amp;lt;C-...&amp;gt; key not work?&#xA;&#xA;The only Ctrl-printable-key chords which Vim can reliably detect (because they&#xA;are defined in the ASCII standard) are the following: &amp;gt;&#xA;&#xA;        Ctrl-@                 0x00            NUL&#xA;        Ctrl-A to Ctrl-Z       0x01 to 0x1A&#xA;        Ctrl-a to Ctrl-z       0x01 to 0x1A&#xA;        Ctrl-[                 0x1B            ESC&#xA;        Ctrl-\                 0x1C&#xA;        Ctrl-]                 0x1D&#xA;        Ctrl-^                 0x1E&#xA;        Ctrl-_                 0x1F&#xA;        Ctrl-?                 0x7F            DEL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the keyboard input system was subject to several discussion on the &lt;a href=&quot;https://groups.google.com/forum/#!forum/vim_dev&quot; rel=&quot;nofollow&quot;&gt;vim-dev mailing list&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://groups.google.com/forum/#!searchin/vim_dev/paul$20evans/vim_dev/s2ymEzKff1g/mUuxu4Sb8eUJ&quot; rel=&quot;nofollow&quot;&gt;Improve vim's keyboard input subsystem&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_dev/2bp9UdfZ63M%5B1-25%5D&quot; rel=&quot;nofollow&quot;&gt;Dear Bram - Please fix vim's input queue mechanism with (...)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So you will probably need to read the source code to have a better understanding of this mechanism.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your second question you could check &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-20.5&quot; rel=&quot;nofollow&quot;&gt;question 20.4&lt;/a&gt;, as any valid normal mode keystroke can be used for mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;20.4. I am not able to create a mapping for the &amp;lt;xxx&amp;gt; key. What is wrong?&#xA;&#xA;1) First make sure, the key is passed correctly to Vim. To determine if&#xA;   this is the case, put Vim in Insert mode and then hit Ctrl-V (or&#xA;   Ctrl-Q if your Ctrl-V is remapped to the paste operation (e.g. on&#xA;   Windows if you are using the mswin.vim script file) followed by your&#xA;   key.&#xA;&#xA;   If nothing appears in the buffer (and assuming that you have&#xA;   'showcmd' on, ^V remains displayed near the bottom right of the Vim&#xA;   screen), then Vim doesn't get your key correctly and there is nothing&#xA;   to be done, other than selecting a different key for your mapping or&#xA;   using GVim, which should recognise the key correctly.&#xA;&#xA;(...)&#xA;&#xA;For more information, read &#xA;&#xA;    |map-keys-fails|&#xA;    |:map-special-keys|&#xA;    |key-codes|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your purpose is to pass commands to vim from external tools, you might consider avoid understanding the details on &lt;em&gt;how&lt;/em&gt; &lt;code&gt;&amp;lt;ctrl-a&amp;gt;&lt;/code&gt; is received by vim, providing the alternative format explained in &lt;code&gt;:help key-codes&lt;/code&gt; (e.g.: &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; standing for &lt;code&gt;&amp;lt;ctrl-a&amp;gt;&lt;/code&gt;), and then using &lt;code&gt;:execute&lt;/code&gt; + &lt;code&gt;normal&lt;/code&gt; commands, as explained in &lt;code&gt;:help :execute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    :execute &quot;normal ixxx\&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(possibly by inserting such strings on the clipboard and executing it from vim with &lt;code&gt;:@+&lt;/code&gt; or writing to a file and then using &lt;code&gt;:source&lt;/code&gt; on it)&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-02-02T10:08:46.110" LastActivityDate="2016-02-02T10:08:46.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6318" PostTypeId="1" AcceptedAnswerId="6328" CreationDate="2016-02-01T23:44:45.217" Score="11" ViewCount="4694" Body="&lt;p&gt;I've the following format of the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;common&amp;gt;&#xA;fitnes=0&#xA;genetic=1&#xA;method=0&#xA;&amp;lt;/common&amp;gt;&#xA;&amp;lt;inputs&amp;gt;&#xA;foo=bar&#xA;bar=foo&#xA;&amp;lt;/inputs&amp;gt;&#xA;&amp;lt;limits&amp;gt;&#xA;balance=200.00&#xA;&amp;lt;/limits&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I would like to delete everything what is between &lt;code&gt;&amp;lt;inputs&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;/inputs&amp;gt;&lt;/code&gt; (excluding pattern it-self) and replace it with the content from another file (e.g. &lt;code&gt;foo.txt&lt;/code&gt;). In other words lines with &lt;code&gt;foo=bar&lt;/code&gt; and &lt;code&gt;bar=foo&lt;/code&gt; would be replaced with another content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably it can be similar to how you &lt;a href=&quot;https://vi.stackexchange.com/q/5265/467&quot;&gt;delete a multi-line match&lt;/a&gt;, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/&amp;lt;inputs/,/inputs&amp;gt;/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I'm not sure with &lt;em&gt;what&lt;/em&gt; I should replace the &lt;code&gt;d&lt;/code&gt; in order to insert the content of another file, but I want to keep the matching pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar approach would be to &lt;a href=&quot;https://vi.stackexchange.com/q/3299/467&quot;&gt;remove inner content of html tag&lt;/a&gt;, like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/&amp;lt;inputs&amp;gt;/norm vitd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but then I don't know how would you add into it the content from the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I'm trying to find one liner, since it'll be part of another script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve that?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-02-02T13:50:01.703" Title="How to replace content between two patterns from the file?" Tags="|regular-expression|global-command|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6319" PostTypeId="1" AcceptedAnswerId="6320" CreationDate="2016-02-02T00:13:18.790" Score="3" ViewCount="795" Body="&lt;p&gt;Given that I have a table of text in columns, how can I reverse the order of the 3rd column? That is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;111a 2a   333a&#xA;11b  222b 33b&#xA;1c   22c  3c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I convert that into this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;111a 2a   3c&#xA;11b  222b 33b&#xA;1c   22c  333a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Actual data considerably longer.)&lt;/p&gt;&#xA;" OwnerUserId="6216" LastActivityDate="2016-02-02T06:14:20.343" Title="How do I reverse the order of a single column" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6320" PostTypeId="2" ParentId="6319" CreationDate="2016-02-02T01:56:38.163" Score="6" Body="&lt;p&gt;To reverse the third column, you could use blockwise Visual mode to select and delete the first two columns, use the command &lt;code&gt;:sort!&lt;/code&gt; to reverse the remaining text (third column), and then paste the first two columns back where they were. Here are the keystrokes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg&amp;lt;C-v&amp;gt;Gwwhx:sort!&amp;lt;CR&amp;gt;P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the command &lt;code&gt;:sort!&lt;/code&gt; is not actually reversing the text - it's putting the text in reverse sorted order. To actually reverse the text you could use the command &lt;code&gt;:g/^/exe 'm .-' . line('.')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an alternative, the following mapping will reverse the visually selected column - you can use &lt;code&gt;&amp;lt;C-v&amp;gt;${up/down motion(s)}&lt;/code&gt; or &lt;code&gt;:set virtualedit=all&lt;/code&gt; to select the last column.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;silent&amp;gt; \r y:&amp;lt;C-u&amp;gt;call setreg('&quot;', reverse(getreg('&quot;', 1, 1)), getregtype('&quot;'))&amp;lt;CR&amp;gt;gvp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping yanks the selected text into the default register, reverses the contents of the default register, reselects the previously selected region, and then pastes the contents of the default register over the selected region.&lt;/p&gt;&#xA;" OwnerUserId="6206" LastEditorUserId="6206" LastEditDate="2016-02-02T06:14:20.343" LastActivityDate="2016-02-02T06:14:20.343" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6321" PostTypeId="1" CreationDate="2016-02-02T02:02:29.283" Score="2" ViewCount="226" Body="&lt;p&gt;I want to map Ctrl + curly brace to some keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;c-}&amp;gt; xxxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work. Why?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="205" LastEditDate="2016-02-02T02:16:12.143" LastActivityDate="2016-02-02T02:16:12.143" Title="How do I map curly braces with Ctrl?" Tags="|key-bindings|vimrc|" AnswerCount="0" CommentCount="5" ClosedDate="2016-02-27T16:07:30.817" ContentLicense="CC BY-SA 3.0" />
  <row Id="6322" PostTypeId="2" ParentId="6318" CreationDate="2016-02-02T02:36:46.640" Score="6" Body="&lt;p&gt;This seems to work, at least on a Unix system:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/&amp;lt;inputs&amp;gt;/+1,/&amp;lt;\/inputs&amp;gt;/-1!cat foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses the &lt;code&gt;{range}!{filter}&lt;/code&gt; command to filter the lines from one after &lt;code&gt;&amp;lt;inputs&amp;gt;&lt;/code&gt; to one before &lt;code&gt;&amp;lt;/inputs&amp;gt;&lt;/code&gt; through the external program &lt;code&gt;cat foo.txt&lt;/code&gt;. In this case, &lt;code&gt;cat&lt;/code&gt; ignores its standard input, so the original lines are deleted and replaced by the contents of the file &lt;code&gt;foo.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :range!&#xA;:help cmdline-ranges&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2016-02-02T02:36:46.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6323" PostTypeId="2" ParentId="6307" CreationDate="2016-02-02T04:23:56.010" Score="10" Body="&lt;p&gt;Add this line into you .vimrc , either source it or restart vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set showcmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And yes If you are experimenting with your vimrc and tired of sourcing it after every change, add this line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost .vimrc source %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6242" LastActivityDate="2016-02-02T04:23:56.010" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6324" PostTypeId="1" AcceptedAnswerId="6325" CreationDate="2016-02-02T04:53:11.927" Score="6" ViewCount="151" Body="&lt;p&gt;(I put the tl;dr bit at the top)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can i bind &lt;kbd&gt;F10&lt;/kbd&gt; for Vim so that when I hit &lt;kbd&gt;F10&lt;/kbd&gt; while inside command (Ex) mode that the command in the command buffer is not actually executed?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already tried the one thing that I know to do for the situation which is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;F10&amp;gt; &amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Background information follows...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a binding which for historical (arbitrary) reasons I have been using the &lt;kbd&gt;F10&lt;/kbd&gt; key to conditionally control my unix systems. So basically what I needed to tell Vim to do is when I hit &lt;kbd&gt;F10&lt;/kbd&gt; either have this function the same as the &lt;kbd&gt;Esc&lt;/kbd&gt; key (to exit insert mode for example) or do some other action if already in normal mode (such as move to next pane in &lt;code&gt;tmux&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that is the background that you didn't ask for about why I am binding &lt;kbd&gt;Esc&lt;/kbd&gt; rather than mapping my &lt;kbd&gt;Esc&lt;/kbd&gt; key at the OS level. It's a &quot;smart&quot; unintuitive crazy thing but it's intuitive for yours truly now :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has worked fantastically well through a small number of hundreds of thousands of lines of code over many years since I started doing this but one quirk remains.&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="4472" LastEditDate="2017-06-28T20:04:35.347" LastActivityDate="2017-06-28T20:04:35.347" Title="Is there a way to bind a key to properly leave command mode?" Tags="|key-bindings|ex-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6325" PostTypeId="2" ParentId="6324" CreationDate="2016-02-02T06:44:23.567" Score="6" Body="&lt;p&gt;&lt;kbd&gt;esc&lt;/kbd&gt; in command line mode traditionally meant the same as &lt;kbd&gt;Enter&lt;/kbd&gt;. That means, it executes your entered command and Vim behaves still the same, when  is mapped to another key. Several years ago, I even made a &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/C3wh_Z_VXEo/4XUARHm5EA0J&quot; rel=&quot;noreferrer&quot;&gt;patch&lt;/a&gt;, to fix this, but it seems nobody cared too much about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Back to your question, simply map &lt;kbd&gt;F10&lt;/kbd&gt; to &lt;kbd&gt;Control&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt; should do what you want, e.g. abort the entered command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cnoremap &amp;lt;f10&amp;gt; &amp;lt;c-c&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-02-02T06:44:23.567" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6326" PostTypeId="2" ParentId="6318" CreationDate="2016-02-02T07:27:56.167" Score="5" Body="&lt;p&gt;An alternative approach to that from Gary is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^&amp;lt;inputs&amp;gt;/+,/^&amp;lt;\/inputs&amp;gt;/-d|-r dummy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which first deletes everything in the given pattern, than uses the &lt;code&gt;:r&lt;/code&gt; command to read the data from file dummy.&#xA;Now if you need to extract the filename from the lines between the &lt;code&gt;&amp;lt;input&amp;gt;/&amp;lt;/input&amp;gt;&lt;/code&gt; pattern, it gets a litte bit more complicated.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-02-02T07:27:56.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6327" PostTypeId="1" CreationDate="2016-02-02T07:47:13.670" Score="3" ViewCount="49" Body="&lt;p&gt;After vim has been open for a while (on Ubuntu in a console), I notice that commands start behaving differently. Mostly, they'll change or delete an extra character. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;123456&#xA;  ^ cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;dl&lt;/code&gt; should delete the &lt;code&gt;3&lt;/code&gt;, but instead deletes &lt;code&gt;34&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, typing &lt;code&gt;s&lt;/code&gt; should delete the &lt;code&gt;3&lt;/code&gt; and take me into insert mode with the cursor over the &lt;code&gt;4&lt;/code&gt;, but instead deletes &lt;code&gt;34&lt;/code&gt; and takes me into insert mode with the cursor over the &lt;code&gt;5&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also notice sometimes that deleting a word will delete an extra character as well. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello world&#xA;^ cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;de&lt;/code&gt; should delete &lt;code&gt;hello&lt;/code&gt; and place the cursor over the space, but instead would delete the space as well, with the cursor over the &lt;code&gt;w&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would cause this? Is there anything I can check, next time this happens, to debug it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my .vimrc, although it's long and references a bunch of plugins so I can't expect anyone to go through it for me: &lt;a href=&quot;http://pastebin.com/z33b33E2&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/z33b33E2&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2560" LastEditorUserId="2560" LastEditDate="2016-02-02T08:04:43.387" LastActivityDate="2016-02-02T08:04:43.387" Title="After a while in a session, commands to change one character change two. Why?" Tags="|cursor-movement|normal-mode|" AnswerCount="0" CommentCount="6" ClosedDate="2018-12-13T13:11:04.630" ContentLicense="CC BY-SA 3.0" />
  <row Id="6328" PostTypeId="2" ParentId="6318" CreationDate="2016-02-02T08:31:37.897" Score="12" Body="&lt;p&gt;A substitution can be used to replace a pattern with the result of an expression like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:keeppatterns %s;&amp;lt;inputs&amp;gt;\zs\_.\{-}\ze&amp;lt;/inputs&amp;gt;;\=insert(readfile('test.txt'), '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help sub-replace-expression&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;keeppatterns&lt;/code&gt; prevents the &lt;code&gt;substitute&lt;/code&gt; command from adding anything to the search history and preserves the &quot;last search pattern register&quot; - see &lt;code&gt;:help &quot;/&lt;/code&gt;. It's good practice to prevent scripts from unnecessarily modifying Vim's global state with the command modifiers &lt;code&gt;keepalt&lt;/code&gt;, &lt;code&gt;keepjumps&lt;/code&gt;, &lt;code&gt;lockmarks&lt;/code&gt;, &lt;code&gt;keepmarks&lt;/code&gt;, and &lt;code&gt;keeppatterns&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6206" LastEditorUserId="6206" LastEditDate="2016-02-02T13:50:01.703" LastActivityDate="2016-02-02T13:50:01.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6329" PostTypeId="1" AcceptedAnswerId="6336" CreationDate="2016-02-02T10:32:13.013" Score="12" ViewCount="922" Body="&lt;p&gt;When using &lt;code&gt;:vsplit&lt;/code&gt; my gvim window jumps to a specific screen location. How do I stop this from happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same thing happens when the second to last split is closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using gvim on Windows.&lt;/p&gt;&#xA;" OwnerUserId="6246" LastEditorUserId="51" LastEditDate="2016-02-02T13:22:53.570" LastActivityDate="2018-10-24T16:04:25.910" Title="How do I stop my window from moving when using vsplit?" Tags="|gvim|vim-windows|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6330" PostTypeId="1" AcceptedAnswerId="6758" CreationDate="2016-02-02T10:52:53.070" Score="4" ViewCount="147" Body="&lt;p&gt;One can use &lt;code&gt;col('$')&lt;/code&gt; to get the length of the current cursor line. Further, one can use &lt;code&gt;virtcol('$')&lt;/code&gt; to get the same length, but this returns the actual screen column. However, it ignores the conceal feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to get the column number similar to &lt;code&gt;col()&lt;/code&gt; and &lt;code&gt;virtcol()&lt;/code&gt; that takes the conceal into account?&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-03-03T18:59:10.690" Title="Get visual column number with conceal feature" Tags="|functions|conceal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6331" PostTypeId="1" AcceptedAnswerId="6335" CreationDate="2016-02-02T11:46:39.210" Score="8" ViewCount="9358" Body="&lt;p&gt;Hi I want to search text inside gvim with the following criteria &#xA;&lt;code&gt;a&amp;amp;b&amp;amp;(c|d)&lt;/code&gt;.&#xA;I know for &lt;code&gt;a&amp;amp;b&lt;/code&gt; it is &lt;code&gt;/.*a\&amp;amp;.*b&lt;/code&gt; and for &lt;code&gt;c|d&lt;/code&gt; it is &lt;code&gt;/c\|d&lt;/code&gt; but combining these two doesnt work.&#xA;what can be the exact command ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: I tried &lt;code&gt;.*a\&amp;amp;.*b\&amp;amp;.*(c\|d)&lt;/code&gt;, but it is taking it as &lt;code&gt;.*a\&amp;amp;.*b\&amp;amp;.*(c&lt;/code&gt; ORed with &lt;code&gt;d)&lt;/code&gt; , inc brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit2: breaking the expression to &lt;code&gt;a&amp;amp;b&amp;amp;c&lt;/code&gt;|&lt;code&gt;a&amp;amp;b&amp;amp;d&lt;/code&gt; is working,&lt;code&gt;.*a\&amp;amp;.*b\&amp;amp;.*c\|.*a\&amp;amp;.*b\&amp;amp;.*d&lt;/code&gt; , but thats not something I am looking for.&lt;/p&gt;&#xA;" OwnerUserId="6247" LastEditorUserId="1405" LastEditDate="2016-02-02T12:08:37.020" LastActivityDate="2016-02-04T18:21:05.657" Title="gvim search query for mixed AND &amp; OR conditions" Tags="|search|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6332" PostTypeId="2" ParentId="6318" CreationDate="2016-02-02T11:54:20.603" Score="1" Body="&lt;p&gt;If this is another attempt to parse XML with non-XML Tools, don't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solutions here are valid, but the intention might not be. If the XML is not from a well tamed source, you might get escapes, CDATA, or white spaces in the tag!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So xsltproc from command in vi can deal with that. &lt;/p&gt;&#xA;" OwnerUserId="6248" LastActivityDate="2016-02-02T11:54:20.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6334" PostTypeId="2" ParentId="6318" CreationDate="2016-02-02T12:33:00.837" Score="2" Body="&lt;p&gt;I feel a macro will be a easier approach.&#xA;Especially, if you have various places to do the same.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Keep only those 2 files open.&lt;/li&gt;&#xA;&lt;li&gt;Now in the first file start recording by &lt;code&gt;qa,&lt;/code&gt; (&lt;code&gt;a&lt;/code&gt; is the record name).&lt;/li&gt;&#xA;&lt;li&gt;Search for the start pattern, press &lt;em&gt;down&lt;/em&gt;, then press &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;v&lt;/kbd&gt;, search for the end pattern, press &lt;em&gt;up&lt;/em&gt;. Now the part which you want to delete is selected. Delete it.&lt;/li&gt;&#xA;&lt;li&gt;Mark the position using &lt;code&gt;ma&lt;/code&gt; (&lt;code&gt;a&lt;/code&gt; is the mark name) and save the file.&lt;/li&gt;&#xA;&lt;li&gt;Go to the 2nd file, by &lt;code&gt;:b2&lt;/code&gt; command and similarly select the part as per your start/end criteria.&lt;/li&gt;&#xA;&lt;li&gt;Come back to this file press &lt;code&gt;a&lt;/code&gt; to go to that point. Paste there by &lt;code&gt;p&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;li&gt;Search for end criteria again, and cross the section to not hit it again.&lt;/li&gt;&#xA;&lt;li&gt;Quit recoding by pressing &lt;code&gt;q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Repeat the number of times by &lt;code&gt;40@a&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6247" LastEditorUserId="467" LastEditDate="2016-02-02T13:47:30.360" LastActivityDate="2016-02-02T13:47:30.360" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6335" PostTypeId="2" ParentId="6331" CreationDate="2016-02-02T12:43:46.900" Score="8" Body="&lt;p&gt;From &lt;code&gt;:help \&amp;amp;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2. A branch is one or more concats, separated by &quot;\&amp;amp;&quot;.  It matches the last&#xA;   concat, but only if all the preceding concats also match at the same&#xA;   position.  Examples:&#xA;    &quot;foobeep\&amp;amp;...&quot; matches &quot;foo&quot; in &quot;foobeep&quot;.&#xA;    &quot;.*Peter\&amp;amp;.*Bob&quot; matches in a line containing both &quot;Peter&quot; and &quot;Bob&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I want to search lines with following criteria, USB &amp;amp; LENGTH should&#xA;  definitly be there along with either RX or TX.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So it seems impossible that any text would match &quot;USB&quot; AND &quot;LENGTH&quot;. You would probably use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(USB.*LENGTH\).*\(RX\|TX\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or, using &lt;code&gt;\v&lt;/code&gt; to reduce the escaping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v(USB.*LENGTH).*(RX|TX)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you meant USB and LENGTH but in any order:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v(.*USB&amp;amp;.*LEN).*(RX|TX)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-02-02T13:08:42.200" LastActivityDate="2016-02-02T13:08:42.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6336" PostTypeId="2" ParentId="6329" CreationDate="2016-02-02T13:44:07.933" Score="13" Body="&lt;p&gt;This happens because when vertical splitting the window, vim needs to add a vertical scrollbar, which causes vim to recalculate the visual size and eventually makes vim jump to a different screen location. The current workaround is to &lt;code&gt;:set guioptions-=r guioptions-=L&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As of patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.0.1278&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.0.1278&lt;/a&gt;, you can also use &lt;code&gt;:set guioptions+=k&lt;/code&gt; to prevent Vim from resizing, see also the documentation at &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27go-k%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'go-k'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-10-24T16:04:25.910" LastActivityDate="2018-10-24T16:04:25.910" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6338" PostTypeId="1" CreationDate="2016-02-02T17:18:25.783" Score="18" ViewCount="16403" Body="&lt;p&gt;I am stuck on windows 10 and would like to give Neovim a shot. Is it ready, or should I just set up my vim configuration for the moment? I haven't really seen any videos or articles on Neovim under windows, but when googling, I found a few that lead me to believe there may have been issues that have not yet been adequately resolved.&lt;/p&gt;&#xA;" OwnerUserId="6254" LastEditorUserId="1072" LastEditDate="2018-02-12T07:34:32.083" LastActivityDate="2018-02-12T07:34:32.083" Title="Neovim on windows 10 - is it ready and how to set it up?" Tags="|microsoft-windows|neovim|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6339" PostTypeId="2" ParentId="6338" CreationDate="2016-02-02T18:12:50.877" Score="11" Body="&lt;p&gt;As stated on &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Installing-Neovim#windows&quot;&gt;neovim wiki&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Windows support is &lt;strong&gt;(currently) experimental&lt;/strong&gt;. To try it out, you need nvim.exe and a front-end such as Neovim-Qt.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However there isn't a list of all features that are missing or unstable. The best way to discover is actually installing and trying.&lt;/p&gt;&#xA;" OwnerUserId="1453" LastActivityDate="2016-02-02T18:12:50.877" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6340" PostTypeId="1" AcceptedAnswerId="6342" CreationDate="2016-02-02T20:40:38.020" Score="6" ViewCount="2963" Body="&lt;p&gt;I'm trying to change between the active buffer and the alternate buffer with the command &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;^&lt;/kbd&gt; as this &lt;a href=&quot;http://vimcasts.org/episodes/working-with-buffers/&quot; rel=&quot;nofollow noreferrer&quot;&gt;video&lt;/a&gt; explains. However, nothing happens. I'm using a Spanish keyboard and to press the &lt;kbd&gt;^&lt;/kbd&gt; accent, I have to hit &lt;kbd&gt;Shift&lt;/kbd&gt; therefore I have to type &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;Shift&lt;/kbd&gt; + &lt;kbd&gt;^&lt;/kbd&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I said nothing happens so is there any other way to do this or could I just map other keys?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Here you can see the keyboard &lt;a href=&quot;https://i.stack.imgur.com/Gafpb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Gafpb.png&quot; alt=&quot;keyboard&quot;&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="5081" LastEditorUserId="205" LastEditDate="2016-02-03T13:48:44.920" LastActivityDate="2016-02-03T13:48:44.920" Title="Changing between the active buffer and the alternate buffer" Tags="|key-bindings|buffers|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6341" PostTypeId="1" AcceptedAnswerId="6344" CreationDate="2016-02-02T21:56:52.630" Score="9" ViewCount="824" Body="&lt;p&gt;You can reflow a paragraph with &lt;code&gt;gqip&lt;/code&gt; (or &lt;code&gt;gqap&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the fastest way to sort a paragraph &lt;code&gt;vip:sort&amp;lt;cr&amp;gt;&lt;/code&gt;? Or is there some shorter keystroke for sorting?&lt;/p&gt;&#xA;" OwnerUserId="5574" LastActivityDate="2016-02-03T01:56:40.200" Title="What is the fastest way to sort a paragraph?" Tags="|sort|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6342" PostTypeId="2" ParentId="6340" CreationDate="2016-02-02T22:49:41.083" Score="12" Body="&lt;p&gt;&lt;code&gt;CTRL-6&lt;/code&gt; can be used to edit the alternate file - tested on OS X by changing the input source from U.S. to Spanish ISO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find yourself wanting to edit the alternate file often, you could consider mapping backspace to edit the alternate file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; 'edit alternate file' convenience mapping&#xA;nnoremap &amp;lt;BS&amp;gt; &amp;lt;C-^&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6206" LastActivityDate="2016-02-02T22:49:41.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6343" PostTypeId="2" ParentId="6341" CreationDate="2016-02-03T00:24:37.550" Score="5" Body="&lt;p&gt;You can create a simple normal mode mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :'{,'}sort&amp;lt;CR&amp;gt;&#xA;&#xA;usage from normal mode: &amp;lt;key&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or a more flexible visual mode mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;key&amp;gt; :sort&amp;lt;CR&amp;gt;&#xA;&#xA;usage from normal mode: vip&amp;lt;key&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-02-03T00:24:37.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6344" PostTypeId="2" ParentId="6341" CreationDate="2016-02-03T01:56:40.200" Score="12" Body="&lt;p&gt;You could define a &quot;sort lines&quot; operator like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:SortLinesOpFunc(...)&#xA;    '[,']sort&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; \s :&amp;lt;C-u&amp;gt;set operatorfunc=&amp;lt;SID&amp;gt;SortLinesOpFunc&amp;lt;CR&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\sip&lt;/code&gt; will sort the paragraph under the cursor and, in general, &lt;code&gt;\s{motion}&lt;/code&gt; will sort the lines moved over by &lt;code&gt;{motion}&lt;/code&gt;, inclusively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :map-operator&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6206" LastActivityDate="2016-02-03T01:56:40.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6345" PostTypeId="1" CreationDate="2016-02-03T02:36:42.550" Score="9" ViewCount="261" Body="&lt;p&gt;I want to open &lt;code&gt;Test.txt&lt;/code&gt; file when I put the cursor on the word &lt;code&gt;test.txt&lt;/code&gt; and type &lt;code&gt;gf&lt;/code&gt;. Is it possible?&lt;/p&gt;&#xA;" OwnerUserId="6261" LastEditorUserId="205" LastEditDate="2016-02-03T05:40:05.630" LastActivityDate="2016-02-03T05:40:05.630" Title="How do I open a file using `gf` in case-insensitive manner?" Tags="|filesystem|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6346" PostTypeId="2" ParentId="6345" CreationDate="2016-02-03T03:47:56.763" Score="6" Body="&lt;p&gt;&lt;code&gt;:set fileignorecase&lt;/code&gt; will treat file names and directories as case insensitive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's on by default for some systems like OS X which comes built in with a case insensitive (but case preserving) file system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also read the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27fileignorecase%27&quot;&gt;help&lt;/a&gt; on it for more:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'fileignorecase' 'fic'  boolean (default on for systems where case in file&#xA;                 names is normally ignored)&#xA;                 global&#xA;                 {not in Vi}&#xA;&#xA;    When set case is ignored when using file names and directories.&#xA;    See 'wildignorecase' for only ignoring case when doing completion.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="246" LastActivityDate="2016-02-03T03:47:56.763" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6347" PostTypeId="2" ParentId="6340" CreationDate="2016-02-03T12:42:46.390" Score="9" Body="&lt;p&gt;Another method to access the alternate file (usually the previous buffer) is the command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:b#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which should be usable regardless of keyboard/terminal inputs.&lt;/p&gt;&#xA;" OwnerUserId="4932" LastActivityDate="2016-02-03T12:42:46.390" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6348" PostTypeId="2" ParentId="6294" CreationDate="2016-02-03T15:34:57.503" Score="7" Body="&lt;p&gt;All right, apparently the state is this: VIM on Windows supports python &lt;code&gt;2.7.9&lt;/code&gt;, not &lt;code&gt;2.7.11&lt;/code&gt;. It might work with &lt;code&gt;2.7.10&lt;/code&gt;, I did not test it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though I compiled VIM on Windows with a reference to the &lt;code&gt;2.7.11&lt;/code&gt; DLL, it suddenly worked when I tried swapping out &lt;code&gt;2.7.11&lt;/code&gt; for &lt;code&gt;2.7.9&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if I did something wrong with &lt;code&gt;2.7.11&lt;/code&gt;, and it actually does work, but I don't have the time to figure it out.&lt;/p&gt;&#xA;" OwnerUserId="2010" LastActivityDate="2016-02-03T15:34:57.503" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6349" PostTypeId="1" AcceptedAnswerId="6352" CreationDate="2016-02-03T15:43:46.477" Score="7" ViewCount="827" Body="&lt;p&gt;I have a large body of LaTeX text (a whole book) which has &lt;code&gt;\textit{}&lt;/code&gt; and &lt;code&gt;\textbf{}&lt;/code&gt; commands interchanged in some places. In other places they are completely missing. How do I create quick shortcuts in Vim so that I can do the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Switch between &lt;code&gt;\textit{}&lt;/code&gt; to &lt;code&gt;\textbf{}&lt;/code&gt; and vice versa without affecting what is inside &lt;code&gt;{}&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Wrap word or phrase under cursor into either of the &lt;code&gt;\textit{}&lt;/code&gt; or &lt;code&gt;\textbf{}&lt;/code&gt; commands.&lt;/li&gt;&#xA;&lt;li&gt;Remove either the &lt;code&gt;\textit{}&lt;/code&gt; or &lt;code&gt;\textbf{}&lt;/code&gt; commands where they are not needed but put in by mistake.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6272" LastEditorUserId="205" LastEditDate="2016-02-03T17:57:12.037" LastActivityDate="2016-02-03T17:57:12.037" Title="How can I make quick environment or command changes in LaTeX" Tags="|filetype-tex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6350" PostTypeId="1" AcceptedAnswerId="6351" CreationDate="2016-02-03T16:33:39.167" Score="18" ViewCount="913" Body="&lt;p&gt;When using &lt;code&gt;u&lt;/code&gt; or &lt;code&gt;CTL-R&lt;/code&gt; to undo or re-do an edit in vim, I seem to alter chunks of text, not just the most recent keystroke.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What determines the size of the chunk that is considered to be a single edit?&lt;/p&gt;&#xA;" OwnerUserId="1969" LastEditorUserId="51" LastEditDate="2016-02-03T21:17:56.343" LastActivityDate="2016-02-03T22:40:20.047" Title="How does vim determine the size of a single &quot;edit&quot; when using &quot;u&quot; and &quot;CTL-R&quot;?" Tags="|command-history|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6351" PostTypeId="2" ParentId="6350" CreationDate="2016-02-03T17:01:52.847" Score="20" Body="&lt;p&gt;You are looking for the definition of &lt;code&gt;undo-blocks&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/undo.txt.html#undo-blocks&quot;&gt;&lt;code&gt;:h undo-blocks&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;One undo command normally undoes a typed command, no matter how many changes&#xA;  that command makes.  This sequence of undo-able changes forms an undo block.&#xA;  Thus if the typed key(s) call a function, all the commands in the function are&#xA;  undone together.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The same block is used for &lt;code&gt;redo&lt;/code&gt;. From &lt;a href=&quot;http://vimhelp.appspot.com/undo.txt.html#redo&quot;&gt;&lt;code&gt;:h redo&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The last changes are remembered.  You can use the undo and redo commands above&#xA;  to revert the text to how it was before each change.  You can also apply the&#xA;  changes again, getting back the text before the undo.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1453" LastEditorUserId="205" LastEditDate="2016-02-03T17:59:45.527" LastActivityDate="2016-02-03T17:59:45.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6352" PostTypeId="2" ParentId="6349" CreationDate="2016-02-03T17:54:16.097" Score="7" Body="&lt;p&gt;If you use &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;noreferrer&quot;&gt;the vimtex plugin&lt;/a&gt;, you can:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Change an enclosing command using &lt;code&gt;csc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UQgul.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UQgul.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;According to the help, a &lt;code&gt;ysc&lt;/code&gt; corresponding to the commands offered by &lt;code&gt;surround.vim&lt;/code&gt; isn't available, but can be added. See &lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L1725&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h vimtex-faq-surround&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                          *vimtex-faq-surround*&#xA;Q: |vimtex| provides `dse`, `dsc`, `cse`, and `csc`.  These seem to be inspired by&#xA;   |surround.vim|.  Does |vimtex| also provide the corresponding `yse` and `ysc`?&#xA;A: The mentioned mappings are indeed inspired by |surround.vim|.  However,&#xA;   |vimtex| does not provide `yse` and `ysc`.  If you use |surround.vim|, then&#xA;   the asked for mappings may be easily added if one adds the following lines&#xA;   to ones `vimrc` file: &amp;gt;&#xA;&#xA;  augroup latexSurround&#xA;     autocmd!&#xA;     autocmd FileType tex call s:latexSurround()&#xA;  augroup END&#xA;&#xA;  function! s:latexSurround()&#xA;     let b:surround_{char2nr(&quot;e&quot;)}&#xA;       \ = &quot;\\begin{\1environment: \1}\n\t\r\n\\end{\1\1}&quot;&#xA;     let b:surround_{char2nr(&quot;c&quot;)} = &quot;\\\1command: \1{\r}&quot;&#xA;  endfunction&#xA;&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Delete an enclosing command using &lt;code&gt;dsc&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-02-03T17:54:16.097" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6353" PostTypeId="2" ParentId="6350" CreationDate="2016-02-03T21:48:57.800" Score="6" Body="&lt;p&gt;You can think of it this way too: every time you go to insert mode to edit text and you hit &lt;kbd&gt;Esc&lt;/kbd&gt;, that will form a block. If you try to undo that block, you will go to the same position before you entered insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore you can &quot;save&quot; your changes just by exiting insert mode from time to time: let's say you go to insert mode and write a function. You could continue coding and go to the next function however sometimes it's preferable to go back to normal mode and switch to insert mode again. In that way, you can have your code structured in a simple way and if you need to go back you can know in what position you will end up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: if you use arrows for moving, it's like if you pressed &lt;kbd&gt;Esc&lt;/kbd&gt; +[&lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt;]&lt;/p&gt;&#xA;" OwnerUserId="5081" LastEditorUserId="5081" LastEditDate="2016-02-03T22:00:06.453" LastActivityDate="2016-02-03T22:00:06.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6354" PostTypeId="2" ParentId="6350" CreationDate="2016-02-03T22:40:20.047" Score="8" Body="&lt;p&gt;Vim's modal editing is often viewed as an &lt;em&gt;operator&lt;/em&gt; (e.g. &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt;, ...) applied over a &lt;em&gt;motion&lt;/em&gt; (e.g. &lt;code&gt;iw&lt;/code&gt;, &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;}&lt;/code&gt;, ...). As a wonderful by product Vim gets chunky undo's. Where as other editors have to do some guessing to make many small undo's into undo blocks, Vim does this naturally. Another side affect is this gives you a repeat operator, &lt;code&gt;.&lt;/code&gt; (aka the dot command).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your question specifically mention keystrokes so I assume you want to know how to undo small changes while in insert mode. The answer is this is not &quot;the Vim way&quot;. &quot;The Vim Way&quot; means you will be in insert mode for short burst at a time. This means when mistakes are made in insert mode you often just exit to normal mode and correct the text or just do an undo, &lt;code&gt;u&lt;/code&gt;, and rewrite the text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes there is need to split an undo block while in insert mode. This can be accomplished via &lt;code&gt;&amp;lt;c-g&amp;gt;u&lt;/code&gt; while in insert mode. See &lt;code&gt;:h :undoj&lt;/code&gt; and &lt;code&gt;:h undo-blocks&lt;/code&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help I suggest the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h undo-blocks&#xA;:h :undoj&#xA;:h undo-tree&#xA;:h persistent-undo&#xA;:h undo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are also some screencasts on this subject:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/episodes/modal-editing-undo-redo-and-repeat/&quot;&gt;Modal editing: undo, redo and repeat&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/episodes/undo-branching-and-gundo-vim/&quot;&gt;Undo branching and Gundo.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-02-03T22:40:20.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6355" PostTypeId="2" ParentId="2560" CreationDate="2016-02-03T23:17:24.093" Score="1" Body="&lt;p&gt;I've developed a set of CTAGS regex rules for JavaScript and CoffeeScript. My rules include unit tests so I think they are more reliable than most.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my git repo which should be most up to date:&#xA;    &lt;a href=&quot;https://github.com/winstonwolff/ctags-javascript-coffeescript&quot; rel=&quot;nofollow&quot;&gt;https://github.com/winstonwolff/ctags-javascript-coffeescript&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here are the rules I use as of writing this post:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--languages=-JavaScript&#xA;--langdef=js&#xA;--langmap=js:.js&#xA;--regex-js=/^var[ \t]+([a-zA-Z0-9._$]+) = \[/\1/a,array/&#xA;--regex-js=/^var[ \t]+([a-zA-Z0-9._$]+) = \{/\1/o,object/&#xA;--regex-js=/^var[ \t]+([a-zA-Z0-9._$]+)[ \t]*=[^{\[]*$/\1/r,var/&#xA;&#xA;--regex-js=/^var[ \t]+([A-Za-z0-9._$]+)[ \t]*=[ \t]*[A-Za-z0-9_$]+.extend/\1/f,function/&#xA;--regex-js=/^[ \t]*([A-Za-z0-9_$]*\.)*([A-Za-z0-9_$]+)[ \t]*[:=][ \t]*function/\2/f,function/&#xA;--regex-js=/^[ \t]*function[ \t]*([A-Za-z0-9_$]+)[ \t]*\(/\1/f,function/&#xA;--regex-js=/^[ \t]*var[ \t]+([A-Za-z0-9_$]*\.)*([A-Za-z0-9_$]+)[ \t]*=[ \t]function/\2/f,function/&#xA;&#xA;--regex-js=/(jQuery|\$)\([ \t]*([^ \t]*)[ \t]*\)\.bind\([ \t]*['&quot;](.*)['&quot;]/\2.\3/f,function/&#xA;&#xA;--regex-js=/^[ \t]*describe[ \t]*\([ \t]*[&quot;'](.*)[&quot;']/\1/f,function/&#xA;--regex-js=/^([ \t]*)(describe|context|it)[ \t]*\([ \t]*[&quot;'](.*)[&quot;']/.\1\3/f,function/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6278" LastActivityDate="2016-02-03T23:17:24.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6356" PostTypeId="1" AcceptedAnswerId="6357" CreationDate="2016-02-03T23:35:32.037" Score="7" ViewCount="2552" Body="&lt;p&gt;I have powerline statusline plugin and &lt;code&gt;set laststatus=2&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt;, so I have two places it tells me my mode in. What is the bottom one called and can I disable it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/FOaWO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4833" LastActivityDate="2016-02-03T23:48:38.290" Title="How to disable '-- INSERT --' text beneath statusline?" Tags="|statusline|plugin-powerline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6357" PostTypeId="2" ParentId="6356" CreationDate="2016-02-03T23:48:38.290" Score="8" Body="&lt;p&gt;From the &lt;a href=&quot;https://github.com/vim-airline/vim-airline/wiki/FAQ&quot;&gt;airline-FAQ&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How do i get rid of the default mode indicator?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Add &lt;code&gt;set noshowmode&lt;/code&gt; to your vimrc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4932" LastActivityDate="2016-02-03T23:48:38.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6358" PostTypeId="1" CreationDate="2016-02-04T00:39:30.543" Score="11" ViewCount="3932" Body="&lt;p&gt;I use Vim for writing C++, and I have quite a few &lt;code&gt;#include&amp;lt;&amp;gt;&lt;/code&gt; statements, comments, etc. that I must include in each new file I create.  I've added &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile *.cpp r C:\(full file path of skeleton text file) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to my vimrc, because I heard this creates a buffer with the text I need in it.  How do I go about adding this text to a new file?  Is there an easy way to do this from the buffer, or is there another easy way to go about doing this?  I've also heard a little about template plugins. Is there a very simple one that could do this for me?&lt;/p&gt;&#xA;" OwnerUserId="6280" LastEditorUserId="205" LastEditDate="2016-02-04T00:58:44.537" LastActivityDate="2019-06-07T08:39:30.533" Title="How do I add skeleton text to new vim files?" Tags="|vimrc|buffers|autocmd|filetype-c++|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="6359" PostTypeId="1" CreationDate="2016-02-04T01:53:31.780" Score="6" ViewCount="160" Body="&lt;p&gt;Sometimes I work with a vertically split window and I was thinking it would be cool if when I enter the command line with &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, etc., the command I type would appear below the current window instead of at the far left of the whole vim layout. Is there a way to do that?&lt;/p&gt;&#xA;" OwnerUserId="6149" LastEditorUserId="205" LastEditDate="2016-02-04T02:04:34.500" LastActivityDate="2022-10-26T19:56:22.940" Title="Position command line under current window?" Tags="|command-line|split|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6360" PostTypeId="2" ParentId="6358" CreationDate="2016-02-04T02:51:14.833" Score="7" Body="&lt;p&gt;Skeleton text from an existing file can be added to a new file by inserting the line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile *.cpp r C:\(full file path of skeleton text file)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into the vimrc. The &lt;code&gt;BufNewFile&lt;/code&gt; event does not work if the new file is created in two steps using &lt;code&gt;:enew&lt;/code&gt; then &lt;code&gt;:sav filename&lt;/code&gt;. Instead, creating a new file using &lt;code&gt;:e filename&lt;/code&gt; triggers the &lt;code&gt;BufNewFile&lt;/code&gt; event's autocommand in the vimrc, adding the contents of the skeleton text file to the newly created file.&lt;/p&gt;&#xA;" OwnerUserId="6280" LastEditorUserId="205" LastEditDate="2016-02-04T03:01:23.070" LastActivityDate="2016-02-04T03:01:23.070" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6361" PostTypeId="2" ParentId="6359" CreationDate="2016-02-04T06:14:13.357" Score="5" Body="&lt;p&gt;No. The position of the command-line can't be changed.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-02-04T06:14:13.357" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6362" PostTypeId="2" ParentId="6358" CreationDate="2016-02-04T07:24:55.750" Score="5" Body="&lt;p&gt;Indeed, template expander plugins will help you in this task. &lt;code&gt;:read&lt;/code&gt; is the step 0 of template expander plugins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, &lt;a href=&quot;https://github.com/LucHermitte/mu-template&quot; rel=&quot;nofollow&quot;&gt;mu-template&lt;/a&gt; will try to include foo.h from foo.cpp if foo.h is detected. It'll also permit to expand headers with dynamic data within them (date, author, license/copyright, etc).&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-02-04T08:30:50.140" LastActivityDate="2016-02-04T08:30:50.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6364" PostTypeId="1" CreationDate="2016-02-04T10:23:11.940" Score="4" ViewCount="1369" Body="&lt;p&gt;Using UltiSnips, I'd like to add a set of snippets just for one file or for a set of files in the same directory, maybe using a &lt;code&gt;:vim&lt;/code&gt; modeline. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to put &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; let g:UltiSnipsSnippetDirectories=[&quot;UltiSnips&quot;, &quot;.&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;.vimrc&lt;/code&gt; and then adding a &lt;code&gt;all.snippets&lt;/code&gt; file in the same directory of the file (by the way, it is a LaTeX file — I tried also with &lt;code&gt;tex_local.snippets&lt;/code&gt; file) but it doesn't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rational is the following: I am writing a &lt;code&gt;beamer&lt;/code&gt; presentation and I have a repeating pattern for several frames --- one that is two diagrams side by side for example, another a figure and a plot, and so on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have defined snippets that create the 3 or 4 patterns I like for this presentation, and happily added them to my &lt;code&gt;.vimtex/UltiSnips/tex_local.snippets&lt;/code&gt; file --- and all is fine. But these snippets are really only useful for &lt;em&gt;this&lt;/em&gt; file, and at the end of the day I do not want to keep adding very local things to the generic snippets definitions...&lt;/p&gt;&#xA;" OwnerUserId="854" LastEditorUserId="854" LastEditDate="2016-02-04T12:36:12.723" LastActivityDate="2020-01-03T18:25:41.703" Title="Adding a snippet file locally (for this file only)" Tags="|plugin-ultisnips|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6365" PostTypeId="2" ParentId="6364" CreationDate="2016-02-04T15:20:08.373" Score="4" Body="&lt;p&gt;If your template expander plugin doesn't support snippets local to the current buffer, i.e. if &lt;code&gt;b:UltiSnipsSnippetDirectories&lt;/code&gt; is not understood in your case, you can&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ask the maintainers to use this variable if defined, or the global one otherwise -- this is the best course of action&lt;/li&gt;&#xA;&lt;li&gt;or you can use another snippet engine that supports local snippets&lt;/li&gt;&#xA;&lt;li&gt;or you can register an autocommand so that when you enter the window/buffer where your file is, &lt;code&gt;g:UltiSnipsSnippetDirectories&lt;/code&gt; is set accordingly, and it's reset when you leave this buffer.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;i.e. something like (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:AddSnippets()&#xA;   let b:restore = get(g:, 'UltiSnipsSnippetDirectories', [])&#xA;   let g:UltiSnipsSnippetDirectories = b:restore + ['yourNewPath']&#xA;endfunction&#xA;&#xA;function s:RestoreSnippets()&#xA;   let g:UltiSnipsSnippetDirectories = b:restore&#xA;endfunction&#xA;&#xA;augroup DedicatedSnippets&#xA;  au !&#xA;  au BufEnter /path/to/your/file call s:AddSnippets()&#xA;  au BufLeave /path/to/your/file call s:RestoreSnippets()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-02-04T15:20:08.373" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6366" PostTypeId="1" AcceptedAnswerId="9539" CreationDate="2016-02-04T15:20:19.093" Score="14" ViewCount="16860" Body="&lt;p&gt;Rather than choosing one character to be displayed as the EOL character, I'd like one to display for both CR and LF separately and regardless of if the file is unix or dos. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="4833" LastActivityDate="2018-06-05T08:09:50.933" Title="Display CR and LF rather than &quot;EOL&quot; in ':set list'" Tags="|vimrc|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6367" PostTypeId="2" ParentId="780" CreationDate="2016-02-04T16:37:57.727" Score="4" Body="&lt;p&gt;The &lt;code&gt;xmledit&lt;/code&gt; (&lt;a href=&quot;http://vimawesome.com/plugin/xmledit&quot; rel=&quot;nofollow&quot;&gt;http://vimawesome.com/plugin/xmledit&lt;/a&gt;) plugin allows to jump between open and close tags using&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;lt;localleader&gt;&lt;kbd&gt;%&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Often &amp;lt;localleader&gt; will be &lt;kbd&gt;\&lt;/kbd&gt;, so you can jump with&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;%&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;NOTE:&lt;/em&gt; Unlike &lt;code&gt;matchit&lt;/code&gt;, you don't have to put your cursor inside the tag. Placing it right on the &lt;code&gt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;gt;&lt;/code&gt; is perfectly fine for the &lt;code&gt;xmledit&lt;/code&gt; plugin. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;NOTE 2:&lt;/em&gt; A drawback here is, that you can't use it in the visual mode. But this isn't a big deal, since you can always select the entire tag with &lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3230" LastEditorUserId="3230" LastEditDate="2016-02-04T17:28:37.067" LastActivityDate="2016-02-04T17:28:37.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6368" PostTypeId="2" ParentId="3694" CreationDate="2016-02-04T18:17:15.977" Score="2" Body="&lt;p&gt;You can also use &lt;code&gt;:oldfiles&lt;/code&gt; to get a list of files you edited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The list will have numbers associated with filenames. Pick a file, note the number (say 14) and open it with &lt;code&gt;:edit #&amp;lt;14&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also run other commands on that file or pass multiple files to a command at once. More about this &lt;a href=&quot;https://stackoverflow.com/a/29692602/1953718&quot;&gt;HERE&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="307" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-02-04T18:17:15.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6369" PostTypeId="2" ParentId="6331" CreationDate="2016-02-04T18:21:05.657" Score="4" Body="&lt;p&gt;You may want to use &lt;code&gt;:logiPat&lt;/code&gt;. It ships with newer versions of Vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:LogiPat &quot;a&quot;&amp;amp;&quot;b&quot;&amp;amp;(&quot;c&quot;|&quot;d&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see: &lt;code&gt;:h logipat&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-02-04T18:21:05.657" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6370" PostTypeId="1" AcceptedAnswerId="6371" CreationDate="2016-02-04T22:03:27.013" Score="6" ViewCount="452" Body="&lt;p&gt;I want to remap &lt;code&gt;&amp;lt;C-i&amp;gt;*character*&lt;/code&gt; to &lt;code&gt;i*character*&amp;lt;Esc&amp;gt;&lt;/code&gt; for easy inserting of single characters. This is what I've written:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let printable_characters = [ '!', '&quot;', '#', '$', '%', '&amp;amp;', '''', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '&amp;lt;', '=', '&amp;gt;', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~']&#xA;for val in printable_characters&#xA;    silent! execute &quot;nnoremap &amp;lt;C-i&amp;gt;&quot; . val . &quot; i&quot; . val . &quot;&amp;lt;Esc&amp;gt;&quot;&#xA;    silent! execute &quot;nnoremap &amp;lt;C-a&amp;gt;&quot; . val . &quot; a&quot; . val . &quot;&amp;lt;Esc&amp;gt;&quot;&#xA;    unlet val&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try to source it by executing &lt;code&gt;:source %&lt;/code&gt;, the following happens:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It will complain about how I forgot the &lt;code&gt;endfor&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Once I press return, the file will look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let printable_characters = [ '!', '&quot;', '#', '$', '%', '&amp;amp;', '''', '(',          ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '&amp;lt;', '=', '&amp;gt;', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~']&#xA;for val in printable_characters&#xA;    silent! execute &quot;nnoremap &amp;lt;C-i&amp;gt;&quot; . val . &quot; i&quot; . val . &quot;&amp;lt;Esc&amp;gt;&quot;&#xA;    silent! execute &quot;nnoremap &amp;lt;C-a&amp;gt;&quot; . val . &quot; a&quot; . val . &quot;&amp;lt;Esc&amp;gt;&quot;&#xA;    unlet val&#xA;    silent! execute &quot;nnoremap &amp;lt;C-a&amp;gt;&quot; . val . &quot; a&quot; . val . &quot;&amp;lt;Esc&amp;gt;&quot;&#xA;    unlet val&#xA;    endfor&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="24" LastEditDate="2016-02-04T23:53:03.470" LastActivityDate="2016-02-05T18:12:23.470" Title="Vimscript file rewrites itself and complains of a mismatched endfor" Tags="|key-bindings|vimscript|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6371" PostTypeId="2" ParentId="6370" CreationDate="2016-02-04T22:26:45.483" Score="8" Body="&lt;p&gt;There is a much better way of accomplishing this than brute forcing it.  You can use these simple expr mappings instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-i&amp;gt; &quot;i&quot; . nr2char(getchar()) . &quot;&amp;lt;Esc&amp;gt;&quot;&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-a&amp;gt; &quot;a&quot; . nr2char(getchar()) . &quot;&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is how they work:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-i&amp;gt;&lt;/code&gt; - Create a mapping for &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt; with the &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; flag.  This flag tells vim to interpret all of the characters after &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; as an expression when the mapping is triggered, which means you can use functions, variables, operators and the like.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;i&quot; . nr2char(getchar()) . &quot;&amp;lt;Esc&amp;gt;&quot;&lt;/code&gt; - A simple expression which concatenates &lt;code&gt;&quot;i&quot;&lt;/code&gt;, a single character given by the user, and &lt;code&gt;&quot;&amp;lt;Esc&amp;gt;&quot;&lt;/code&gt;.  &lt;code&gt;getchar&lt;/code&gt; returns a number representing the pressed key, so &lt;code&gt;nr2char&lt;/code&gt; is used to convert it to a string.  The result of this concatenation is what is used as the final mapping when the user presses &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;.  For example, if the user presses &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt; then this expression evaluates to &lt;code&gt;&quot;it&amp;lt;Esc&amp;gt;&quot;&lt;/code&gt;, which then results in those keys being pressed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more, see &lt;code&gt;:help :map-&amp;lt;expr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, look at the other answers for why your current solution doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2016-02-04T22:33:30.487" LastActivityDate="2016-02-04T22:33:30.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6372" PostTypeId="2" ParentId="6370" CreationDate="2016-02-04T22:30:33.107" Score="7" Body="&lt;p&gt;One of your &quot;printable&quot; characters is a vertical bar, &lt;code&gt;|&lt;/code&gt;. When that value comes up in your loop, you effectively execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-i&amp;gt;|i|&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The bar denotes the end of the map command (see &lt;code&gt;:help map_bar&lt;/code&gt;). You probably want to escape it in the array, like &lt;code&gt;'\|'&lt;/code&gt; (or choose another method of generating these mappings).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(You can observe this by reducing, temporarily, your printable characters array to just &lt;code&gt;[ '|' ]&lt;/code&gt; or alternatively by removing &lt;code&gt;'|'&lt;/code&gt; from your set and seeing the behavior change.)&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2016-02-04T22:30:33.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6373" PostTypeId="2" ParentId="6370" CreationDate="2016-02-04T22:32:25.817" Score="6" Body="&lt;p&gt;To include a pipe or bar (&lt;kbd&gt;|&lt;/kbd&gt;) in a map, use &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt;. A literal &lt;code&gt;|&lt;/code&gt; will end the &lt;code&gt;map&lt;/code&gt; command and take what follows as a new command. That means that the &lt;code&gt;execute&lt;/code&gt; command does something very different from what you intend when &lt;code&gt;val == '|'&lt;/code&gt;. The &lt;em&gt;different&lt;/em&gt; involves all the characters trailing the pipe, although I'm not sure at a glance exactly why you get this particular effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you comment out the loop and variable assignment, replace the concatenation with a literal &lt;code&gt;|&lt;/code&gt;, and source the file you will see a similar effect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; let printable_characters = [ '!', '&quot;', '#', '$', '%', '&amp;amp;', '''', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '&amp;lt;', '=', '&amp;gt;', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~']&#xA;&quot; for val in printable_characters&#xA;    silent! execute &quot;nnoremap &amp;lt;C-i&amp;gt;|i|&amp;lt;Esc&amp;gt;&quot;&#xA;    silent! execute &quot;nnoremap &amp;lt;C-a&amp;gt;|a|&amp;lt;Esc&amp;gt;&quot;&#xA;    &quot; unlet val&#xA;&quot; endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; let printable_characters = [ '!', '&quot;', '#', '$', '%', '&amp;amp;', '''', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '&amp;lt;', '=', '&amp;gt;', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~']&#xA;&quot; for val in printable_characters&#xA;    silent! execute &quot;nnoremap &amp;lt;C-i&amp;gt;|i|&amp;lt;Esc&amp;gt;&quot;&#xA;    silent! execute &quot;nnoremap &amp;lt;C-a&amp;gt;|a|&amp;lt;Esc&amp;gt;&quot;&#xA;    &quot; unlet val&#xA;    silent! execute &quot;nnoremap &amp;lt;C-a&amp;gt;|a|&amp;lt;Esc&amp;gt;&quot;&#xA;    &quot; unlet val&#xA;&quot; endfor&#xA;&quot; endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help map_bar&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2016-02-04T22:32:25.817" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6374" PostTypeId="1" CreationDate="2016-02-05T15:31:55.490" Score="5" ViewCount="65" Body="&lt;p&gt;I sometimes have plugs stop working — in my case, mostly using async lookups with Unite.  When this happens, I would like to see what is happening and look into how to configure around it, or make a patch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command that shows a 'log' of running errors?  I'm hoping for any place to get status.  Similarly, can I ping or probe plugins or a register they interact with, in order to watch a 'live stream' of events?&lt;/p&gt;&#xA;" OwnerUserId="915" LastEditorUserId="51" LastEditDate="2016-07-21T17:33:27.160" LastActivityDate="2016-07-21T17:33:27.160" Title="Is there an ideal / idiomatic way to debug running plugins?" Tags="|plugin-system|plugin-unite.vim|async|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6375" PostTypeId="1" CreationDate="2016-02-05T16:10:28.843" Score="1" ViewCount="642" Body="&lt;p&gt;I'm trying to use my MobaXTerm vim to access a remote file using netrw as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim scp://my_username@my_server//path/file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have password-less login set up (through .ssh / rsa_id, etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works fine from my OS X machine running vim 7.3, but not from MobaXTerm vim (also 7.3).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does MobaXTerm's vim support netrw?&lt;/p&gt;&#xA;" OwnerUserId="4890" LastActivityDate="2016-02-11T02:38:33.377" Title="Does MobaXTerm's vim support netrw?" Tags="|netrw|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6377" PostTypeId="1" CreationDate="2016-02-05T18:48:52.997" Score="2" ViewCount="207" Body="&lt;p&gt;Whenever I do &lt;code&gt;source! %MYVIMRC&lt;/code&gt; it gets reloaded, but it is copied inside the file I am editing at the cursor location and comments are inserted all over the place and multiple times (.vimrc is about 200 lines, but I get over 600 lines inserted into whatever file I am editing) and it's all indented in  a strange way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't pinpoint the location of the error in vimrc. I've been experimenting with some fancy plugins lately like neocomplete and nerdcommenter, but removing them did not help. Commented out everything from vimrc and sourcing it did the same thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is vim works perfectly as expected. I understand more or less everything I have in my vimrc (exceptions are some plugin configs), but it behaves 100% when I start it and just work in it. However, when I source it while working all hell breaks loose. I am on a slightly older version of vim on Debian stable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my vimrc just in case: &lt;a href=&quot;https://github.com/sergenikov/vim-tmux-config/blob/master/.vimrc&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sergenikov/vim-tmux-config/blob/master/.vimrc&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="3006" LastEditorUserId="205" LastEditDate="2016-02-06T04:53:37.477" LastActivityDate="2016-02-06T04:53:37.477" Title="Why does sourcing vimrc copy it into the current file?" Tags="|vimrc|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6378" PostTypeId="1" AcceptedAnswerId="6380" CreationDate="2016-02-05T19:47:47.057" Score="17" ViewCount="1700" Body="&lt;p&gt;Imagine I have the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some random stuff&#xA;* asdf&#xA;* foo&#xA;* bar&#xA;some other random stuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to replace the asterisk bullets with numbers, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some random stuff&#xA;1. asdf&#xA;2. foo&#xA;3. bar&#xA;some other random stuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can this be done in vim ?&lt;/p&gt;&#xA;" OwnerUserId="6310" LastEditorUserId="343" LastEditDate="2017-12-06T11:10:05.997" LastActivityDate="2017-12-06T11:10:05.997" Title="Replace a series of asterisk bullet points with a numbered list" Tags="|substitute|filetype-markdown|range|markup|counting|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6379" PostTypeId="1" CreationDate="2016-02-05T19:48:16.917" Score="5" ViewCount="1719" Body="&lt;p&gt;I used Suptertab for a while and I really like it. Recently I tried to add a snippet management plugin but I wasn't successful in getting them to work with Supertab. I tried SnipMate and Ultisnips. Does anyone have a suggestion on which plugin to use? I really don't want to change the shortcut for any one of them and I hope it works for both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="6311" LastEditorUserId="51" LastEditDate="2016-03-14T05:15:47.123" LastActivityDate="2017-03-15T18:03:30.980" Title="Is there a snippet plugin compatible with Supertab?" Tags="|plugin-ultisnips|plugin-supertab|plugin-snipmate|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6380" PostTypeId="2" ParentId="6378" CreationDate="2016-02-05T20:01:56.163" Score="15" Body="&lt;p&gt;You could try the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let c=0 | g/^* /let c+=1 | s//\=c.'. '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;First it initializes the variable &lt;code&gt;c&lt;/code&gt; (&lt;code&gt;let c=0&lt;/code&gt;), then it executes the global command &lt;code&gt;g&lt;/code&gt; which looks for the pattern &lt;code&gt;^*&lt;/code&gt; (a beginning of line, followed by an asterisk and a space).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever a line containing this pattern is found, the global command executes the command:&lt;br&gt;&#xA;&lt;code&gt;let c+=1 | s//\=c.'. '&lt;/code&gt;&lt;br&gt;&#xA;It increments the variable &lt;code&gt;c&lt;/code&gt; (&lt;code&gt;let c+=1&lt;/code&gt;), then (&lt;code&gt;|&lt;/code&gt;) it substitutes (&lt;code&gt;s&lt;/code&gt;) the previous searched pattern (&lt;code&gt;//&lt;/code&gt;) with the evaluation of an expression (&lt;code&gt;\=&lt;/code&gt;):&lt;br&gt;&#xA;the contents of variable &lt;code&gt;c&lt;/code&gt; concatenated (&lt;code&gt;.&lt;/code&gt;) with the string &lt;code&gt;'. '&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you don't want to modify all the lines from your buffer, but only a specific paragraph, you can pass a range to the global command.&#xA;For example, to modify only the lines whose number is between 5 and 10:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let c=0 | 5,10g/^* /let c+=1 | s//\=c.'. '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you have a file containing several similar lists which you want to convert, for example something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some random stuff                 some random stuff                      &#xA;* foo                             1. foo                                 &#xA;* bar                             2. bar                                 &#xA;* baz                             3. baz                                 &#xA;some other random stuff           some other random stuff                &#xA;                           ==&amp;gt;                                                &#xA;some random stuff                 some random stuff                      &#xA;* foo                             1. foo                                 &#xA;* bar                             2. bar                                 &#xA;* baz                             3. baz                                 &#xA;* qux                             4. qux                                 &#xA;some other random stuff           some other random stuff                &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can do it with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let [c,d]=[0,0] | g/^* /let [c,d]=[line('.')==d+1 ? c+1 : 1, line('.')] | s//\=c.'. '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's just a variant of the previous command, which resets the variable &lt;code&gt;c&lt;/code&gt; when you switch to another list. To detect whether you are in another list, the variable &lt;code&gt;d&lt;/code&gt; is used to store the number of the last line where a substitution was made.&lt;br&gt;&#xA;The global command compares the current line number (&lt;code&gt;line('.')&lt;/code&gt;) with &lt;code&gt;d+1&lt;/code&gt;. If they are the same, it means we are in the same list as before so &lt;code&gt;c&lt;/code&gt; is incremented (&lt;code&gt;c+1&lt;/code&gt;), otherwise it means we are in a different list, so &lt;code&gt;c&lt;/code&gt; is reset (&lt;code&gt;1&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside a function, the command &lt;code&gt;let [c,d]=[line('.')==d+1 ? c+1 : 1, line('.')]&lt;/code&gt; could be rewritten like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let c = line('.') == d+1 ? c+1 : 1&#xA;let d = line('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if line('.') == d+1&#xA;    let c = c+1&#xA;else&#xA;    let c = 1&#xA;endif&#xA;let d = line('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To save some keystrokes, you could also define the custom command &lt;code&gt;:NumberedLists&lt;/code&gt;, which accepts a range whose default value is &lt;code&gt;1,$&lt;/code&gt; (&lt;code&gt;-range=%&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% NumberedLists let [c,d]=[0,0] | &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;g/^* /let [c,d]=[line('.')==d+1 ? c+1 : 1, line('.')] | s//\=c.'. '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;:NumberedLists&lt;/code&gt; will be executed, &lt;code&gt;&amp;lt;line1&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;line2&amp;gt;&lt;/code&gt; will be automatically replaced with the range you used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to convert all the lists in the buffer, you would type: &lt;code&gt;:NumberedLists&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only the lists between line 10 and 20: &lt;code&gt;:10,20NumberedLists&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only the visual selection: &lt;code&gt;:'&amp;lt;,'&amp;gt;NumberedLists&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :range&#xA;:help :global&#xA;:help :substitute&#xA;:help sub-replace-expression&#xA;:help list-identity    (section list unpack)&#xA;:help expr1&#xA;:help :command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-02-06T05:53:02.673" LastActivityDate="2016-02-06T05:53:02.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6381" PostTypeId="2" ParentId="6378" CreationDate="2016-02-05T20:18:33.557" Score="9" Body="&lt;p&gt;Visually select the lines and execute this substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/*/\=line('.') - line(&quot;'&amp;lt;&quot;) + 1 . '.'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help sub-replace-expression&lt;/code&gt;, &lt;code&gt;:help line()&lt;/code&gt;, and &lt;code&gt;:help '&amp;lt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid having to select the lines, backward and forward searches with offsets can be used to specify the substitution range like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:?^[^*]?+1,/^[^*]/-1s/*/\=line('.') - search('^[^[:digit:]]', 'bn') . '.'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help cmdline-ranges&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6206" LastEditorUserId="6206" LastEditDate="2016-02-06T05:50:30.713" LastActivityDate="2016-02-06T05:50:30.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6382" PostTypeId="1" AcceptedAnswerId="6384" CreationDate="2016-02-05T21:42:48.437" Score="4" ViewCount="2215" Body="&lt;p&gt;I'm on Windows 7 with Vim 7.4, and Unicode symbols with the &lt;a href=&quot;https://github.com/chrissimpkins/Hack&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hack&lt;/a&gt; font look awful. Am I missing a setting somewhere? Is there a way to improve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, this is gvim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/WVSET.png&quot; alt=&quot;gvim&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and this is atom:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XawWp.png&quot; alt=&quot;atom&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also done the same with the Consolas font, and it's still bad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This issue also exists in terminal vim, but it is slightly better.&lt;/p&gt;&#xA;" OwnerUserId="2010" LastActivityDate="2016-02-05T22:09:53.060" Title="Why do symbols look ugly in gvim?" Tags="|gvim|microsoft-windows|unicode|font|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6383" PostTypeId="2" ParentId="6377" CreationDate="2016-02-05T21:44:16.503" Score="4" Body="&lt;p&gt;This is for the sake of completeness, in case someone else runs into this issue. And thanks to @saginaw for the answer above in comments and a pointer to where to look.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like @saginaw said I was doing &lt;code&gt;source!&lt;/code&gt;, which was not reading Ex commands causing issues. Here it is form the comment:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;if you add a bang :source! $MYVIMRC, it doesn't read Ex commands anymore but Vim commands (executed from normal mode, like dd for example). So when you type :source! $MYVIMRC, Vim probably searches for anything which looks like a normal command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Following @saginaw advice I looked up the doc on &lt;code&gt;source&lt;/code&gt; function and then on &lt;code&gt;function&lt;/code&gt; and &lt;code&gt;command&lt;/code&gt;. They all have bang attribute &lt;code&gt;!&lt;/code&gt;, which means every function declaration I have I can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Foo()&#xA;   ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Foo ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I source vimrc with &lt;code&gt;source&lt;/code&gt;, it will redefine these again. My mistake was that I was using &lt;code&gt;source!&lt;/code&gt; thinking that &lt;strong&gt;it&lt;/strong&gt; will redefine those functions. So the lesson is that when you write function in vimrc remember that they have a bang attribute.&lt;/p&gt;&#xA;" OwnerUserId="3006" LastActivityDate="2016-02-05T21:44:16.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6384" PostTypeId="2" ParentId="6382" CreationDate="2016-02-05T22:04:13.893" Score="6" Body="&lt;p&gt;If you have a recent Vim, you may try to enable DirectX rendering. It should improve &quot;wide&quot; font rendering, among other things. Here's an example &lt;code&gt;vimrc&lt;/code&gt; snip:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;gui_running&quot;)&#xA;    set guioptions=icpM&#xA;    if has('win32') || has('win64')&#xA;        if (v:version == 704 &amp;amp;&amp;amp; has(&quot;patch393&quot;)) || v:version &amp;gt; 704&#xA;            set renderoptions=type:directx,level:0.75,gamma:1.25,contrast:0.25,&#xA;                        \geom:1,renmode:5,taamode:1&#xA;        endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Reference&lt;/em&gt; &lt;code&gt;:h rop&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some other remarks, more generic, which may or may not be useful in your case:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Font spacing (horizontal, vertical) sometimes is not the same between Linux, Mac and Windows (in Vim, but also happens with other apps, e.g. Emacs). You can tweak those using &lt;code&gt;set linespace=...&lt;/code&gt; (vertical) and, (only) if you use &lt;a href=&quot;http://www.kaoriya.net/software/vim/&quot; rel=&quot;noreferrer&quot;&gt;Kaoriya's gVim build&lt;/a&gt;, &lt;code&gt;set charspace=...&lt;/code&gt; (horizontal). This may indirectly improve font appearance.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-02-05T22:09:53.060" LastActivityDate="2016-02-05T22:09:53.060" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6385" PostTypeId="2" ParentId="6378" CreationDate="2016-02-05T22:51:58.060" Score="9" Body="&lt;p&gt;This only works with a recent Vim version (that has &lt;code&gt;:h v_g_CTRL-A&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Block-select the list bullets (&lt;code&gt;*&lt;/code&gt;) and replace them with &lt;code&gt;0&lt;/code&gt; (cursor is on first &lt;code&gt;*&lt;/code&gt;):  &lt;code&gt;Ctrl-v&lt;/code&gt; &lt;code&gt;j&lt;/code&gt; &lt;code&gt;j&lt;/code&gt; &lt;code&gt;r&lt;/code&gt; &lt;code&gt;0&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Reselect previous block and &lt;em&gt;increment with counter&lt;/em&gt;: &lt;code&gt;gv&lt;/code&gt; &lt;code&gt;g&lt;/code&gt; &lt;code&gt;Ctrl-a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;... and that's it :)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(If you want to have a dot after each number, change 1st step to: &lt;code&gt;Ctrl-v&lt;/code&gt; &lt;code&gt;j&lt;/code&gt; &lt;code&gt;j&lt;/code&gt; &lt;code&gt;s&lt;/code&gt; &lt;code&gt;0&lt;/code&gt; &lt;code&gt;.&lt;/code&gt; &lt;code&gt;Esc&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-02-06T00:00:28.793" LastActivityDate="2016-02-06T00:00:28.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6386" PostTypeId="1" AcceptedAnswerId="6405" CreationDate="2016-02-06T06:45:49.133" Score="5" ViewCount="809" Body="&lt;p&gt;I know that I can use &lt;code&gt;:set list&lt;/code&gt; to show invisible characters. However, I am interested in a thing I've seen in many other editors, which is not to show or not show invisibles outright but show them only while typing&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, when I press &lt;kbd&gt;Tab&lt;/kbd&gt; it shows me the char I've assigned, but as soon as I start typing again, the character disappears. Same with space, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any known way to do this in Vim?&lt;/p&gt;&#xA;" OwnerUserId="5022" LastEditorUserId="5022" LastEditDate="2016-11-04T10:18:44.317" LastActivityDate="2016-11-04T10:18:44.317" Title="How do I show invisible characters only as I type them?" Tags="|insert-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6388" PostTypeId="1" AcceptedAnswerId="6389" CreationDate="2016-02-06T08:54:38.870" Score="3" ViewCount="237" Body="&lt;p&gt;I do have a bunch of XHTML files and I need to put an &lt;code&gt;@id&lt;/code&gt; for all the &lt;code&gt;p&lt;/code&gt; elements inside all those files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried the following &lt;code&gt;argdo&lt;/code&gt; approach in the following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cd d:\testfiles\&#xA;:args *.xhtml&#xA;:argdo let i = 1 | g/&amp;lt;p/s/&amp;lt;p/\=printf(&quot;&amp;lt;p id=\&quot;para%02d\&quot;&quot;, i)/ | let i = i + 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, this works fine. Doing it by this way value of &lt;code&gt;i&lt;/code&gt; is getting incremented all the time. But, I want it to use &lt;code&gt;unlet i&lt;/code&gt;, whenever &lt;code&gt;argdo&lt;/code&gt; executes to a new buffer. In short, variable &lt;code&gt;i&lt;/code&gt; must be set to &lt;code&gt;1&lt;/code&gt; for each item in the &lt;code&gt;arg-list&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have tried to use &lt;code&gt;|unlet i&lt;/code&gt; at the end of the &lt;code&gt;argdo statements&lt;/code&gt; or at the beginning of the &lt;code&gt;argdo statements&lt;/code&gt;. But both ways have failed.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Is there any workaround? I am very new to &lt;code&gt;vim&lt;/code&gt;. Using it only a few months and loving it day by day. Pointing out my error to get job done, is greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5912" LastEditorUserId="5912" LastEditDate="2016-02-06T10:47:24.033" LastActivityDate="2016-02-06T10:47:24.033" Title="How to `unlet` a variable using from a `argdo` statement in VIM" Tags="|buffers|variables|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6389" PostTypeId="2" ParentId="6388" CreationDate="2016-02-06T10:28:33.717" Score="4" Body="&lt;p&gt;When you use a variable without a scope (&lt;code&gt;i&lt;/code&gt; instead of &lt;code&gt;b:i&lt;/code&gt; or &lt;code&gt;w:i&lt;/code&gt;, etc.) outside of a function, you're using a global variable. From &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#internal-variables&quot;&gt;&lt;code&gt;:h internal-variables&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;There are several name spaces for variables.  Which one is to be used is&#xA;specified by what is prepended:&#xA;&#xA;                (nothing) In a function: local to a function; otherwise: global&#xA;buffer-variable    b:   Local to the current buffer.&#xA;window-variable    w:   Local to the current window.&#xA;tabpage-variable   t:   Local to the current tab page.&#xA;global-variable    g:   Global.&#xA;local-variable     l:   Local to a function.&#xA;script-variable    s:   Local to a :source'ed Vim script.&#xA;function-argument  a:   Function argument (only inside a function).&#xA;vim-variable       v:   Global, predefined by Vim.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A plain &lt;code&gt;i&lt;/code&gt; is a variable common to all buffers. Since you need to reset the variable for each file, and each file will be in a separate buffer, you can use buffer-local variables (&lt;code&gt;b:i&lt;/code&gt; instead of &lt;code&gt;i&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-02-06T10:35:52.153" LastActivityDate="2016-02-06T10:35:52.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6390" PostTypeId="1" AcceptedAnswerId="6422" CreationDate="2016-02-06T14:04:54.597" Score="4" ViewCount="437" Body="&lt;p&gt;If I define a function in my vimrc (or in a plugin), Vim will load it and I can use it. But what's happening under the hood after my vimscript is parsed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it transcoded down to C and compiled?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it put on the heap at runtime and referenced through a function pointer?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2016-02-09T17:36:14.533" Title="Does Vim compile user-defined functions?" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6391" PostTypeId="1" AcceptedAnswerId="6392" CreationDate="2016-02-06T17:36:59.000" Score="9" ViewCount="1137" Body="&lt;p&gt;To work, abbreviations need to be separated by whitespace.  E.g., if I have an &lt;code&gt;iab fo FOOBAR&lt;/code&gt; then typing &lt;code&gt;whatfo&lt;/code&gt; will not trigger the abbreviation.  There are some obvious sensible reasons for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'd like an abbreviation that could be used as a suffix without me having to trigger the iab then go back and remove the space.  Is this possible? E.g., &lt;code&gt;iab fo &amp;lt;backspace&amp;gt;FOOBAR&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4913" LastActivityDate="2016-02-08T12:17:05.617" Title="Backspace in insert abbreviation" Tags="|abbreviations|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6392" PostTypeId="2" ParentId="6391" CreationDate="2016-02-06T18:56:23.520" Score="9" Body="&lt;p&gt;You could write inside your vimrc: &lt;code&gt;iab fo &amp;lt;BS&amp;gt;FOOBAR&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; is the notation to use for the backspace key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information about special key names, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help key-notation&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-02-08T04:18:23.417" LastActivityDate="2016-02-08T04:18:23.417" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6393" PostTypeId="1" AcceptedAnswerId="6394" CreationDate="2016-02-06T20:10:23.723" Score="2" ViewCount="151" Body="&lt;p&gt;i want to substitute the text &lt;code&gt;'which apt'&lt;/code&gt; to &lt;code&gt;$(which apt)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/'\&amp;amp;.*'/$(\0) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does substitute to &lt;code&gt;$('which apt')&lt;/code&gt;. How can i leave those single quotes out on the substitution, so that just $(..) appears?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/'\zs\&amp;amp;.*\ze'/$(\0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;results in &lt;code&gt;$('which apt)'&lt;/code&gt;. Although the regex should match any character between the two ', as i marked them as outside of the selection. i don't know if i did sth wrong?&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="2354" LastEditDate="2016-02-06T21:04:05.047" LastActivityDate="2016-02-06T21:05:12.967" Title="substitute 'which apt' to $(which apt)" Tags="|substitute|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6394" PostTypeId="2" ParentId="6393" CreationDate="2016-02-06T21:05:12.967" Score="8" Body="&lt;pre&gt;&lt;code&gt;:s/'\(.\{-}\)'/$(\1)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Search part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'            single quote&#xA; \(.\{-}\)   any character — . —, as few as possible — \{-} —,&#xA;             captured for reuse in the replacement — \(...\) —&#xA;          '  single quote&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replacement part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$(           replace the first quote&#xA;  \1         reuse the capture group&#xA;    )        replace the second quote&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-02-06T21:05:12.967" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6395" PostTypeId="1" AcceptedAnswerId="6398" CreationDate="2016-02-06T23:34:32.247" Score="8" ViewCount="2932" Body="&lt;p&gt;I have problems getting python3 support working in neovim. &#xA;I have followed the instructions in &lt;code&gt;:help nvim-python&lt;/code&gt;, but &lt;code&gt;:echo has('python3')&lt;/code&gt; returns 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried installing the neovim python modules both from git and pip, and also the AUR on arch linux, but &lt;code&gt;:echo has('python3')&lt;/code&gt; still returns 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried setting the path to python manually in neovim, and I also tried rebuilding neovim from source from github after installing python modules, but still nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I found out clipboardprovider didn't work either.&lt;/p&gt;&#xA;" OwnerUserId="6326" LastEditorUserId="6326" LastEditDate="2016-02-07T11:49:09.533" LastActivityDate="2017-11-29T11:39:43.507" Title="Neovim python3 support not working" Tags="|neovim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6397" PostTypeId="2" ParentId="6391" CreationDate="2016-02-07T08:33:10.613" Score="4" Body="&lt;p&gt;Simply press in insert mode &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;. This will trigger abbreviations to be expanded, without entering a space&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-02-07T08:33:10.613" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6398" PostTypeId="2" ParentId="6395" CreationDate="2016-02-07T11:48:15.353" Score="7" Body="&lt;p&gt;Okay, I found out there was an error in my init.vim. I was overwriting the runtimepath instead of appending to it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath+=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then it works.&lt;/p&gt;&#xA;" OwnerUserId="6326" LastEditorUserId="205" LastEditDate="2016-02-07T12:16:57.173" LastActivityDate="2016-02-07T12:16:57.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6399" PostTypeId="1" AcceptedAnswerId="6401" CreationDate="2016-02-07T13:18:08.823" Score="2" ViewCount="408" Body="&lt;p&gt;I tried following &lt;a href=&quot;http://vim.wikia.com/wiki/Insert_current_filename&quot; rel=&quot;nofollow&quot;&gt;this tip from vim wikia&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap \fn &amp;lt;C-R&amp;gt;=expand(&quot;%:t:r&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For me this doesn't make any difference to the functionality of &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;%&lt;/kbd&gt; in insert mode (it still just gives the full path and file extension), so I was looking at that and some linked tips and vim help sections, to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why doesn't this work?  Should it? If so could there be something in my config or an extension that ruins it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Somewhat tangentially, what is the &lt;code&gt;\fn&lt;/code&gt; about?  I've seen variations on this in other map commands but can't find any explanation of it.  If someone could break this line down completely and explain the meaning that would be great.&lt;/p&gt;&#xA;" OwnerUserId="4913" LastEditorUserId="4913" LastEditDate="2016-02-07T16:58:56.017" LastActivityDate="2016-02-07T16:58:56.017" Title="Remap of C-R registers and &quot;\xx&quot; syntax" Tags="|key-bindings|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6400" PostTypeId="2" ParentId="6391" CreationDate="2016-02-07T15:28:12.383" Score="4" Body="&lt;p&gt;As an alternative, here's a way to define and expand abbreviations that expand anywhere:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:anywhere_abbreviations = {&#xA;    \ 'fo': 'FOOBAR',&#xA;    \ 'ab': 'ABBREVIATION',&#xA;\ }&#xA;&#xA;function! s:MaybeExpandAbbreviation(trigger)&#xA;    for key in keys(s:anywhere_abbreviations)&#xA;        if matchstr(getline('.'), repeat('.', strchars(key)) . '\%' . col('.') . 'c') ==# key&#xA;            return repeat(&quot;\&amp;lt;BS&amp;gt;&quot;, strchars(key)) . s:anywhere_abbreviations[key] . a:trigger&#xA;        endif&#xA;    endfor&#xA;    return &quot;\&amp;lt;C-]&amp;gt;&quot; . a:trigger&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Space&amp;gt; &amp;lt;SID&amp;gt;MaybeExpandAbbreviation(&quot;\&amp;lt;Space&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just add the abbreviations that should expand anywhere to the &lt;code&gt;s:anywhere_abbreviations&lt;/code&gt; dictionary. The &lt;code&gt;s:MaybeExpandAbbreviation()&lt;/code&gt; function searches for and expands abbreviation matches when the trigger key is pressed - &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; is mapped to trigger the expansion of the &quot;anywhere abbreviations&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the above &lt;code&gt;s:anywhere_abbreviations&lt;/code&gt; dictionary, typing &lt;code&gt;whatfo&amp;lt;Space&amp;gt;&lt;/code&gt; will expand to &lt;code&gt;whatFOOBAR&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6206" LastEditorUserId="6206" LastEditDate="2016-02-07T15:42:07.680" LastActivityDate="2016-02-07T15:42:07.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6401" PostTypeId="2" ParentId="6399" CreationDate="2016-02-07T16:04:37.110" Score="3" Body="&lt;p&gt;Ah, you misread the mapping. It doesn't map &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt;, it maps &lt;code&gt;\fn&lt;/code&gt;. Typing &lt;code&gt;\fn&lt;/code&gt; while in insert mode &lt;em&gt;is&lt;/em&gt; what gets you the filename.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wrote it this way, perhaps it might be clearer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;leader&amp;gt;fn &amp;lt;c-r&amp;gt;=expand(&quot;%:t:r&quot;)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The default leader is &lt;code&gt;\&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-02-07T16:04:37.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6402" PostTypeId="1" AcceptedAnswerId="6403" CreationDate="2016-02-08T03:40:18.610" Score="6" ViewCount="444" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/2350/how-to-map-alt-key&quot;&gt;I know about this thread.&lt;/a&gt;&#xA;Using &lt;code&gt;sed -n l&lt;/code&gt;, I get the following output&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for pageUp : &lt;code&gt;^[[5~&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for alt+pageUp : &lt;code&gt;^[[5;3~&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The alt+pageUp seems to be sending new char altogether and not combination of Pageup char &lt;code&gt;^[[5~&lt;/code&gt; and some other char.&lt;/p&gt;&#xA;" OwnerUserId="6338" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-02-08T04:02:06.637" Title="How to map Alt-PageUp in Vim?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6403" PostTypeId="2" ParentId="6402" CreationDate="2016-02-08T04:02:06.637" Score="6" Body="&lt;p&gt;Found it. It was straight forward!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;A-PageUp&amp;gt; {rhs}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6338" LastActivityDate="2016-02-08T04:02:06.637" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6404" PostTypeId="2" ParentId="6391" CreationDate="2016-02-08T10:20:11.510" Score="3" Body="&lt;p&gt;To summarize the two simplest answers that came out of this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;You can use a backspace directly in an abbreviation&lt;/strong&gt; -- various special characters are documented under &lt;code&gt;:help keycodes&lt;/code&gt;.  So, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:iab cdt &amp;lt;BS&amp;gt;cedental&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will allow you to type &lt;code&gt;trans cdt&lt;/code&gt; and get &lt;code&gt;transcendental&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;One I'm particularly ashamed of since I've been using it for years: The common &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2540&quot; rel=&quot;nofollow&quot;&gt;snipMate plugin&lt;/a&gt; allows for parameters to go in front, so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; snippet cdt&#xA;     ${1}cendental ${2}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Allows for typing &lt;code&gt;cdt&lt;/code&gt;, which &lt;kbd&gt;Tab&lt;/kbd&gt; will expand to &lt;code&gt;cendental&lt;/code&gt; and put the cursor in front so you can type &lt;code&gt;trans&lt;/code&gt;, then hit &lt;kbd&gt;Tab&lt;/kbd&gt; again to move to the beginning of the next word.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4913" LastEditorUserId="4913" LastEditDate="2016-02-08T12:17:05.617" LastActivityDate="2016-02-08T12:17:05.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6405" PostTypeId="2" ParentId="6386" CreationDate="2016-02-08T17:44:26.820" Score="1" Body="&lt;p&gt;You can achieve an effect similar to this by changing the colour of tabs so you can't see them, and then making them visible again when&#xA;they are at the end of a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the colorscheme I'm currently using, the background is set to colour &lt;code&gt;8&lt;/code&gt;. You&#xA;will need to tweak the colours in the first &lt;code&gt;highlight&lt;/code&gt; command to match those in your colorscheme (and add &lt;code&gt;gui&lt;/code&gt; options to&#xA;the highlight commands if you're working in GUI Vim).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; First, turn on list&#xA;set list&#xA;&#xA;&quot; Now change the colours so that tabs blend in with the background&#xA;highlight SpecialKey ctermfg=8 ctermbg=8&#xA;&#xA;&quot; Now add a highlight group for tabs we do want to be visible.&#xA;&quot; The command below is likely to work in all colorschemes, but feel free to&#xA;&quot; edit to your taste.&#xA;highlight link VisibleTab Error&#xA;&#xA;&quot; Set up a match to use the new highlight for tabs at the end of the line&#xA;match VisibleTab /\t$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use the same technique for some of the other invisible characters mentioned in &lt;code&gt;:help 'listchars'&lt;/code&gt; by changing the regular expression in the &lt;code&gt;:match&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-02-09T09:09:45.160" LastActivityDate="2016-02-09T09:09:45.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6406" PostTypeId="1" AcceptedAnswerId="7725" CreationDate="2016-02-08T17:50:45.383" Score="7" ViewCount="289" Body="&lt;p&gt;Say I am mixing English and German in my documents and have my spelllang variable set accordingly. How do I indicate, when I want to mark a word as good, to which spellfile it is to be added? &lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-05-10T15:31:48.330" Title="Adding words to one of many spellfiles" Tags="|spell-checking|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6407" PostTypeId="2" ParentId="3228" CreationDate="2016-02-08T18:45:24.010" Score="2" Body="&lt;p&gt;According to &lt;a href=&quot;https://github.com/mxw/vim-jsx/issues/63&quot; rel=&quot;nofollow&quot;&gt;mxw/vim-jsx#63&lt;/a&gt; there may have been a bug in pangloss' vim-javascript that triggered this issue.  It doesn't reproduce on the current (circa 2016 Feb 8) master branches for vim-jsx and its required dependency &lt;a href=&quot;https://github.com/pangloss/vim-javascript&quot; rel=&quot;nofollow&quot;&gt;vim-javascript&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1377" LastActivityDate="2016-02-08T18:45:24.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6408" PostTypeId="1" CreationDate="2016-02-08T19:24:49.447" Score="5" ViewCount="221" Body="&lt;p&gt;With at least these settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expandtab&#xA;textwidth=79&#xA;sw=4&#xA;ts=4&#xA;fo=tcq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I have a long line of text that starts with a &lt;code&gt;*&lt;/code&gt; (like a C/javadoc comment) it will honor the current indent level when I &lt;code&gt;gqq&lt;/code&gt;, albeit formatting it like a code comment, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* I'm convinced of this: Good done anywhere is good done everywhere...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;=&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* I'm convinced of this: Good done anywhere is good done&#xA;* everywhere. For a change, start by speaking to people&#xA;* rather than walking by them like they're stones that&#xA;* don't matter. As long as you're breathing, it's never too&#xA;* late to do some good.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I remove the leading &lt;code&gt;*&lt;/code&gt;, it just wraps flush with the left:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    I'm convinced of this: Good done anywhere is good done&#xA;everywhere. For a change, start by speaking to people rather than walking by&#xA;them like they're stones that don't matter. As long as you're breathing, it's&#xA;never too late to do some good.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm just doing plain text prose in a .txt.  How can I make it look like the following, ideally without any fancy leading char?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I'm convinced of this: Good done anywhere is good done&#xA;everywhere. For a change, start by speaking to people rather&#xA;than walking by them like they're stones that don't matter.&#xA;As long as you're breathing, it's never too late to do some&#xA;good.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was able to do this by manually deleting all leading whitespace, passing the line through &lt;code&gt;:!fmt -w60&lt;/code&gt;, and then block inserting 20 spaces; but that involves a lot of math and typing, a cumbersome external command, and is not platform independent (wouldn't work in windows, for instance).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample Text is a quote from Maya Angelou.  &lt;/p&gt;&#xA;" OwnerUserId="6344" LastEditorUserId="51" LastEditDate="2016-02-08T20:00:39.037" LastActivityDate="2016-02-11T11:08:06.847" Title="How to wrap plain text honoring existing text indent?" Tags="|indentation|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6409" PostTypeId="1" AcceptedAnswerId="6412" CreationDate="2016-02-08T20:36:15.803" Score="1" ViewCount="1634" Body="&lt;p&gt;I use VIM for writing in LaTeX and I would like to have a single key to compile the text and open a PDF of it.  I have the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F10&amp;gt; :!pdflatex % &amp;amp;&amp;amp; start %.pdf &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my vimrc.  It seems to compile fine, but &lt;code&gt;%&lt;/code&gt; represents the filename including the file extension, so the second command will not run (it is attempting to start &lt;code&gt;filename.tex.pdf&lt;/code&gt;).  Is there a way to call the filename without the file extension?  For example, &lt;code&gt;%&lt;/code&gt; returns &lt;code&gt;filename.tex&lt;/code&gt;.  Is there something that would return just &lt;code&gt;filename&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks so much for the help!&lt;/p&gt;&#xA;" OwnerUserId="6280" LastEditorUserId="51" LastEditDate="2016-02-08T20:49:33.127" LastActivityDate="2016-02-08T23:09:46.273" Title="Map single key to compile and open LaTeX PDF" Tags="|vimrc|filetype-tex|" AnswerCount="1" CommentCount="4" ClosedDate="2016-02-09T04:54:32.897" ContentLicense="CC BY-SA 3.0" />
  <row Id="6410" PostTypeId="1" AcceptedAnswerId="6413" CreationDate="2016-02-08T21:20:51.463" Score="2" ViewCount="282" Body="&lt;p&gt;I'm trying to deploy some static content upon &lt;code&gt;write&lt;/code&gt;ing a buffer with an autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup dep&#xA;  autocmd!&#xA;  autocmd BufWritePost myProject/frontEnd/** :call s:deploy()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;s:deploy&lt;/code&gt; function basically does the copy operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;frontEnd&lt;/code&gt; project has a bunch of directories with subdirectories for various JavaScript, CSS, and other files I want to be deployed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found that my autocmd works great when saving files after starting Vim like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim myProject/frontEnd/index.html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The autocmd also works when saving files after starting Vim like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim myProject/frontEnd/js/file.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, when the autocmd does not execute when I start out at the above &lt;code&gt;index.html&lt;/code&gt; and then use netrw to navigate to &lt;code&gt;file.js&lt;/code&gt;. It's like the navigating kills the autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on what is happening here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT for future Googlers:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution I was looking for (that @user21497's answer helped me realize) was to use a pre-pending wildcard in my autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost */myProject/frontEnd/** :call s:deploy()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2312" LastEditorUserId="2312" LastEditDate="2016-02-09T13:21:55.483" LastActivityDate="2016-02-09T13:21:55.483" Title="BufWritePost not working after navigating using netrw" Tags="|vimscript|autocmd|netrw|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6411" PostTypeId="1" CreationDate="2016-02-08T21:47:48.440" Score="2" ViewCount="32" Body="&lt;p&gt;I wanted to fold my LaTeX document and found this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://tex.stackexchange.com/questions/130586/vim-nice-folding-function&quot;&gt;https://tex.stackexchange.com/questions/130586/vim-nice-folding-function&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Which seems to indicate that folding has been removed from Latex-Box?) That takes care of environments. But I am still missing two functions, which I was hoping might be added to the code referred to, namely:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;folding from every occurrence of &lt;code&gt;\somecommand&lt;/code&gt; to one line above the next; &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;folding two or more subsequent commented out lines.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="-1" LastEditDate="2017-04-13T12:34:32.317" LastActivityDate="2016-02-09T05:39:26.377" Title="Folding from occurrence to next; two or more comments" Tags="|folding|filetype-tex|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6412" PostTypeId="2" ParentId="6409" CreationDate="2016-02-08T22:25:14.740" Score="2" Body="&lt;p&gt;You could try using a filename-modifier like &lt;code&gt;:r&lt;/code&gt; or a combination of several like &lt;code&gt;:t:r&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:t&lt;/code&gt; should allow you to get the tail of the path, that is just the last element in the path (&lt;code&gt;baz&lt;/code&gt; in &lt;code&gt;/foo/bar/baz&lt;/code&gt;). And &lt;code&gt;:r&lt;/code&gt; the root of the path, the path without the extension of the last item (&lt;code&gt;/foo/bar/baz&lt;/code&gt; in &lt;code&gt;/foo/bar/baz.c&lt;/code&gt;). So you could try one of the 2 following commands:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F10&amp;gt; :!pdflatex % &amp;amp;&amp;amp; start %:r.pdf&amp;lt;CR&amp;gt; &#xA;map &amp;lt;F10&amp;gt; :!pdflatex % &amp;amp;&amp;amp; start %:t:r.pdf&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your filenames may contain special characters which you want to protect from the shell, you can use the function &lt;code&gt;shellescape()&lt;/code&gt;. But in this case you would also probably have to:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;use the function &lt;code&gt;expand()&lt;/code&gt; to force the expansion of &lt;code&gt;%&lt;/code&gt; and &lt;code&gt;%:r&lt;/code&gt;&#xA;before the call to &lt;code&gt;shellescape()&lt;/code&gt;,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;build the mapping with a concatenation of strings to force the evaluation of the functions before sending the command to the shell,  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;execute the result with the command &lt;code&gt;:execute&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Maybe something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F10&amp;gt; :execute '!pdflatex ' . shellescape(expand('%')) . ' &amp;amp;&amp;amp; start ' . shellescape(expand('%:r') . '.pdf')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if your filenames may contain special characters which you want to protect from Vim (like &lt;code&gt;!&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt;, because they have a special meaning on Vim's command-line), you can pass a 2nd non-zero argument to the &lt;code&gt;shellescape()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F10&amp;gt; :execute '!pdflatex ' . shellescape(expand('%'), 1) . ' &amp;amp;&amp;amp; start ' . shellescape(expand('%:r') . '.pdf', 1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help filename-modifiers&#xA;:help :execute&#xA;:help expand()&#xA;:help shellescape()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-02-08T23:09:46.273" LastActivityDate="2016-02-08T23:09:46.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6413" PostTypeId="2" ParentId="6410" CreationDate="2016-02-09T03:24:57.523" Score="3" Body="&lt;p&gt;Your autocmd depends on vim being in the directory holding myProject; there are several options that could affect that. What does &lt;code&gt;:echo g:netrw_keepdir&lt;/code&gt; show and what does &lt;code&gt;:echo &amp;amp;acd&lt;/code&gt; show, for example. After navigating, what does &lt;code&gt;:echo getcwd()&lt;/code&gt; show?&lt;/p&gt;&#xA;" OwnerUserId="2377" LastEditorUserId="4939" LastEditDate="2016-02-09T03:28:25.777" LastActivityDate="2016-02-09T03:28:25.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6414" PostTypeId="1" AcceptedAnswerId="6416" CreationDate="2016-02-09T07:54:11.653" Score="3" ViewCount="665" Body="&lt;p&gt;I have a question regarding a plugin called &lt;a href=&quot;https://github.com/Shougo/vimfiler.vim&quot; rel=&quot;nofollow&quot;&gt;Vimfiler&lt;/a&gt;. What I want is to open a .doc/.docx file using MS Word from &lt;strong&gt;Vimfiler&lt;/strong&gt;. For this, I added the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call vimfiler#set_execute_file('doc,docx', '/Applications/Microsoft Word.app')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;code&gt;.vimrc&lt;/code&gt;. Even if I pressed &lt;code&gt;Return&lt;/code&gt; after choosing a &lt;code&gt;.doc&lt;/code&gt; file on Vimfiler, MS Word did not start. I also attempted to select the &lt;code&gt;open&lt;/code&gt; action by pressing &lt;code&gt;a&lt;/code&gt; after choosing a &lt;code&gt;.doc&lt;/code&gt; file, but the same result as before. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me how to proceed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MacVim on El Capitan&lt;/p&gt;&#xA;" OwnerUserId="6349" LastEditorUserId="6349" LastEditDate="2016-02-09T10:35:51.623" LastActivityDate="2016-02-09T10:35:51.623" Title="Vimfiler (a plugin): how to open .doc file using MS Word" Tags="|external-command|macvim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6415" PostTypeId="2" ParentId="6414" CreationDate="2016-02-09T08:25:35.600" Score="3" Body="&lt;p&gt;I don't have Word or Windows so I tried solving your issue with Libreoffice and &lt;code&gt;.odt&lt;/code&gt; files. The following code seems to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call vimfiler#set_execute_file('odt', 'libreoffice')&#xA;augroup vimfiler_mapping&#xA;    autocmd!&#xA;    autocmd FileType vimfiler nmap &amp;lt;buffer&amp;gt; x &amp;lt;Plug&amp;gt;(vimfiler_execute_vimfiler_associated)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe you could tweak the code for your needs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call vimfiler#set_execute_file('doc', 'path/to/MS Word')&#xA;augroup vimfiler_mapping&#xA;    autocmd!&#xA;    autocmd FileType vimfiler nmap &amp;lt;buffer&amp;gt; x &amp;lt;Plug&amp;gt;(vimfiler_execute_vimfiler_associated)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The autocmd installs a buffer-local mapping on the &lt;code&gt;x&lt;/code&gt; key whenever you open a buffer whose filetype is &lt;code&gt;vimfiler&lt;/code&gt;.&lt;br&gt;&#xA;And as &lt;a href=&quot;https://vi.stackexchange.com/questions/6414/vimfiler-a-plugin-how-to-open-doc-file-using-ms-word#comment10112_6415&quot;&gt;muru&lt;/a&gt; explained in the comment, the call to the function &lt;code&gt;vimfiler#set_execute_file()&lt;/code&gt; appends a new item in the dictionary &lt;code&gt;g:vimfiler_execute_file_list&lt;/code&gt; whose values are command names designated to open the files with the extension stored inside the associated keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help vimfiler#set_execute_file()&#xA;:help &amp;lt;Plug&amp;gt;(vimfiler_execute_vimfiler_associated)&#xA;:help g:vimfiler_execute_file_list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-02-09T08:49:56.240" LastActivityDate="2016-02-09T08:49:56.240" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6416" PostTypeId="2" ParentId="6414" CreationDate="2016-02-09T08:39:07.790" Score="2" Body="&lt;p&gt;In your specific case, it is likely OSX already associates &lt;code&gt;.doc&lt;/code&gt; and &lt;code&gt;.docx&lt;/code&gt; files with MS Word. So you can use that to your advantage, using &lt;code&gt;vimfiler_execute_system_associated&lt;/code&gt;, which is mapped to &lt;code&gt;x&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x                       &amp;lt;Plug&amp;gt;(vimfiler_execute_system_associated)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just pressing &lt;code&gt;x&lt;/code&gt; on the filename should be enough.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-02-09T08:39:07.790" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6417" PostTypeId="1" AcceptedAnswerId="6419" CreationDate="2016-02-09T11:27:57.493" Score="7" ViewCount="538" Body="&lt;p&gt;My spellchecker wants me to begin every sentence with a capital letter, i.e., it underlines lowercase characters after full stop. Can I make it stop?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="205" LastEditDate="2016-02-09T17:03:10.303" LastActivityDate="2016-02-09T17:03:10.303" Title="How do I allow sentences to begin with lowercase letters?" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6418" PostTypeId="1" AcceptedAnswerId="6424" CreationDate="2016-02-09T11:48:15.223" Score="5" ViewCount="1904" Body="&lt;p&gt;Automatic folding with the vimtex plugin is unbearably slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything I can do to speed this up? I tried installing the &lt;a href=&quot;https://github.com/vim-scripts/FastFold&quot; rel=&quot;nofollow noreferrer&quot;&gt;fastfold&lt;/a&gt; plugin but that did nothing I could notice.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2020-04-27T11:50:21.150" LastActivityDate="2020-04-27T11:50:21.150" Title="Folding slow with vimtex" Tags="|folding|filetype-tex|performance|plugin-vimtex|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6419" PostTypeId="2" ParentId="6417" CreationDate="2016-02-09T12:28:29.433" Score="6" Body="&lt;p&gt;There's the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27spellcapcheck%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;'spellcapcheck'&lt;/code&gt;&lt;/a&gt; option; from the help:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Pattern to locate the end of a sentence.  The following word will be checked to start with a capital letter.  If not then it is highlighted with SpellCap &lt;code&gt;hl-SpellCap&lt;/code&gt; (unless the word is also badly spelled).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The default value is &lt;code&gt;[.?!]\_[\])'&quot; \t]\+&lt;/code&gt;, but it may be set when loading a spell file (to accommodate the language's specific rules).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to disable it, you should therefore use &lt;code&gt;:set spellcapcheck=&lt;/code&gt; &lt;em&gt;after&lt;/em&gt; using &lt;code&gt;:set spell&lt;/code&gt; and &lt;code&gt;:set spelllang&lt;/code&gt;. Unfortunately, there doesn't seem to be an autocmd to help you here, but you can use a mapping, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;ss :set spell!&amp;lt;CR&amp;gt;:set spellcapcheck=&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;sn :set spelllang=nl&amp;lt;CR&amp;gt;:set spellcapcheck=&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;se :set spelllang=en_gb&amp;lt;CR&amp;gt;:set spellcapcheck=&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;su :set spelllang=en_us&amp;lt;CR&amp;gt;:set spellcapcheck=&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;sd :set spelllang=de_de&amp;lt;CR&amp;gt;:set spellcapcheck=&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-02-09T16:49:59.247" LastActivityDate="2016-02-09T16:49:59.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6420" PostTypeId="2" ParentId="2674" CreationDate="2016-02-09T15:36:06.487" Score="31" Body="&lt;p&gt;If I want to swap one line with the line above I usually do the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ddkP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;dd will delete the line and add it to the default register.&lt;/li&gt;&#xA;&lt;li&gt;k will move up a line (j would move down a line)&lt;/li&gt;&#xA;&lt;li&gt;P will paste above the current line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6353" LastActivityDate="2016-02-09T15:36:06.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6421" PostTypeId="1" CreationDate="2016-02-09T16:52:43.287" Score="3" ViewCount="55" Body="&lt;p&gt;I enjoy spelling Latin and Greek loan words according to their original spelling, e.g. præcise and œconomy. Might there be a convenient way to add these to the spellfile (manually) and at the same time mark their modern counterparts as bad (i.e. the words that in each case have e for æ and œ)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps the very best solution would be a script that looked up all words containing æ or œ, and, if the same word with e were considered correct, would accept the variant and mark the original as bad (and otherwise do nothing).&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2016-02-09T17:04:01.480" LastActivityDate="2016-03-03T12:35:03.267" Title="Private spellings, adding and marking standard as bad in one operation" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6422" PostTypeId="2" ParentId="6390" CreationDate="2016-02-09T17:17:16.723" Score="7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it transcoded down to C and compiled?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Vimscript is interpreted, and in fact you can do basically the same things in vimscript as you could at the &lt;code&gt;:&lt;/code&gt; command (and the other way around), plus or minus some bar and escape characters to make things sane.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The evaluation code is mainly located in &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/eval.c&quot;&gt;&lt;code&gt;eval.c&lt;/code&gt;&lt;/a&gt;, which you can browse if you are brave.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it put on the heap at runtime and referenced through a function&#xA;  pointer?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;While a built-in function &lt;em&gt;is&lt;/em&gt; ultimately a function pointer to the C implementation, a user function is represented by a &lt;code&gt;ufunc_T&lt;/code&gt; structure (trimmed of some stuff for brevity):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct ufunc&#xA;{&#xA;    int      uf_varargs;&#xA;    int      uf_flags;&#xA;    int      uf_calls;&#xA;    garray_T uf_args;&#xA;    garray_T uf_lines;&#xA;    scid_T   uf_script_ID;&#xA;    int      uf_refcount;&#xA;    char_u   uf_name[1];&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;call_user_func&lt;/code&gt; is used to actually make the call to a user function. After doing a ton of setup to initialize arguments, variables, profiling information and state management, &lt;code&gt;call_user_func&lt;/code&gt; does&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;do_cmdline(NULL, get_func_line, (void *)fc, DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to execute each line of the function as a &lt;code&gt;:&lt;/code&gt; command line (the implementation of &lt;code&gt;do_cmdline&lt;/code&gt; in in &lt;a href=&quot;https://github.com/vim/vim/blob/fb1f62691eae7c79a28b3b17a60e72ce198c71a2/src/ex_docmd.c#L745&quot;&gt;ex_docmd.c&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorDisplayName="user72" LastEditDate="2016-02-09T17:36:14.533" LastActivityDate="2016-02-09T17:36:14.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6423" PostTypeId="1" CreationDate="2016-02-09T17:38:32.973" Score="3" ViewCount="95" Body="&lt;p&gt;I am an average user of vim and LaTeX. I hate using anything but the keyboard while working on the computer. Following popular recommendations I have been using vim-LaTeX for few years now and have not used anything else. I love it. But sometimes when I am writing something (heavy technical writing) then few things seem difficult such as tables. I know tables are not the most intuitive part of LaTeX, but I was wondering if I am missing anything using vim-LaTeX. Are there any better options that you can suggest? Kindly also mention (if possible) what are advantages and disadvantages of switching. Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="6356" LastActivityDate="2016-02-09T17:38:32.973" Title="Am I missing something using vim-LaTeX?" Tags="|plugin-vim-latex|" AnswerCount="0" CommentCount="2" ClosedDate="2016-02-12T14:16:28.300" ContentLicense="CC BY-SA 3.0" />
  <row Id="6424" PostTypeId="2" ParentId="6418" CreationDate="2016-02-09T20:20:09.093" Score="9" Body="&lt;p&gt;First: Did you bother to read the vimtex documentation, i.e. &lt;code&gt;:h vimtex-folding&lt;/code&gt;? The docs clearly point out that the &lt;code&gt;fold-expr&lt;/code&gt; method of folding is slow, and so therefore provides an option &lt;code&gt;g:vimtex_fold_manual&lt;/code&gt; which if enabled (set to nonzero value) will set &lt;code&gt;foldmethod=manual&lt;/code&gt;, and instead will remap &lt;code&gt;zx&lt;/code&gt; and &lt;code&gt;zX&lt;/code&gt; to recalculate the folds when necessary (typically not very often).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fastfold plugin is a very good alternative, as it will automatically ensure that the foldmethod is set to manual. This will also work for other file types, and the plugin provides a set of possibilities for when the folds should be refreshed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Disclaimer: I am the developer of vimtex.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-02-09T20:20:09.093" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6425" PostTypeId="1" CreationDate="2016-02-09T21:42:25.540" Score="4" ViewCount="348" Body="&lt;p&gt;I am on Windows 10. I just installed &lt;strong&gt;Vundle&lt;/strong&gt; and now I am trying to run the &lt;code&gt;PluginInstall&lt;/code&gt; command. However, I am getting errors saying it can't open a file in &lt;code&gt;AppData/Local/Temp&lt;/code&gt;. This does occur on all plugins (at least it seems so).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using gvim, which I ran as an admin to make sure it wasn't permissions related. I have tried restarting my machine, as I was doing updates anyway. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why am I having this issue? Please advise. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I have looked in AppData, the file it is looking for doesn't exist.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;[&lt;img src=&quot;https://i.stack.imgur.com/BfUGG.png&quot; alt=&quot;screensnippet of gvim and error[1]&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the comments suggested, I tried set shell=git and the errors changed to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/B5BT3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/B5BT3.png&quot; alt=&quot;Error processing - screensnippet&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will try out the links. &lt;/p&gt;&#xA;" OwnerUserId="6360" LastEditorUserId="-1" LastEditDate="2016-02-11T07:07:15.513" LastActivityDate="2019-10-27T22:01:05.143" Title="Vundle won't install plugins due to an error about AppData/Local/Temp" Tags="|gvim|microsoft-windows|plugin-vundle|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6426" PostTypeId="1" AcceptedAnswerId="6427" CreationDate="2016-02-10T04:30:03.027" Score="17" ViewCount="2938" Body="&lt;p&gt;How can I create a recursive macro so that it only runs until the end of the line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or how to run a recursive macro until the end of the line only?&lt;/p&gt;&#xA;" OwnerUserId="6362" LastEditorUserId="205" LastEditDate="2016-02-10T08:03:14.247" LastActivityDate="2022-07-21T14:23:36.217" Title="How do I stop a recursive macro at the end of the line?" Tags="|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6427" PostTypeId="2" ParentId="6426" CreationDate="2016-02-10T05:15:34.760" Score="13" Body="&lt;p&gt;There is probably a simpler method but maybe you could try the following.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say you will use register &lt;code&gt;q&lt;/code&gt; to record your recursive macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the very beginning of the recording, type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let a = line('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, at the very end of the recording, instead of hitting &lt;code&gt;@q&lt;/code&gt; to make the macro recursive, type the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:if line('.') == a | exe 'norm @q' | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally end the recording of the macro with &lt;code&gt;q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last command you typed will replay the macro &lt;code&gt;q&lt;/code&gt; (&lt;code&gt;exe 'norm @q'&lt;/code&gt;) but only if the current line number (&lt;code&gt;line('.')&lt;/code&gt;) is the same as the one initially stored in variable &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:normal&lt;/code&gt; command allows you to type normal commands (like &lt;code&gt;@q&lt;/code&gt;) from Ex mode.&lt;br&gt;&#xA;And the reason why the command is wrapped into a string and executed by the command &lt;code&gt;:execute&lt;/code&gt; is to prevent &lt;code&gt;:normal&lt;/code&gt; from consuming (typing) the rest of the command (&lt;code&gt;|endif&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Usage example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say you have the following buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 2 3 4&#xA;1 2 3 4&#xA;1 2 3 4&#xA;1 2 3 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you want to increment all the numbers from an arbitrary line with a recursive macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could type &lt;code&gt;0&lt;/code&gt; to move your cursor to the beginning of a line then start the recording of the macro :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqq&#xA;qq&#xA;:let a=line('.')&#xA;&amp;lt;C-a&amp;gt;&#xA;w&#xA;:if line('.')==a|exe 'norm @q'|endif&#xA;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;qqq&lt;/code&gt; clears the contents of register &lt;code&gt;q&lt;/code&gt; so that when you initially call it during the definition of the macro, it will not interfere&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; starts the recording&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:let a=line('.')&lt;/code&gt; stores current line number inside variable &lt;code&gt;a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt; increments the number under the cursor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt; moves the cursor to the next number&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:if line('.')==a|exe 'norm @q'|endif&lt;/code&gt; recalls the macro but only if&#xA;the line number didn't change&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; stops the recording&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Once you have defined your macro, if you position your cursor on the third line, hit &lt;code&gt;0&lt;/code&gt; to move it to the beginning of the line, then hit &lt;code&gt;@q&lt;/code&gt; to replay the macro &lt;code&gt;q&lt;/code&gt;, it should only affect the current line and not the others:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 2 3 4&#xA;1 2 3 4&#xA;2 3 4 5&#xA;1 2 3 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Make a macro recursive after the recording&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want, you can make your macro recursive after its recording using the fact that it's stored in a string inside a register and that you can concatenate two strings with the dot &lt;code&gt;.&lt;/code&gt; operator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would give you several benefits:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;no need of clearing the register before the recording, because the characters &lt;code&gt;@q&lt;/code&gt; will be added in the macro after it has been defined, and after you have overwritten whatever old contents was there&lt;/li&gt;&#xA;&lt;li&gt;no need of typing anything unusual during the recording, you could focus on making a simple, working macro&lt;/li&gt;&#xA;&lt;li&gt;possibility of testing it before making it recursive to see how it behaves&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you record your macro as usual (non-recursively), you can make it recursive afterwards with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @q = @q . &quot;@q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even shorter: &lt;code&gt;let @q .= &quot;@q&quot;&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;.=&lt;/code&gt; is an operator which allows to append a string to another one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should add the 2 characters &lt;code&gt;@q&lt;/code&gt; at the very end of the sequence of keystrokes stored inside register &lt;code&gt;q&lt;/code&gt;.&#xA;You could also define a custom command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -register RecursiveMacro let @&amp;lt;reg&amp;gt; .= &quot;@&amp;lt;reg&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It defines the command &lt;code&gt;:RecursiveMacro&lt;/code&gt; which waits for the name of a register as an argument (because of the &lt;code&gt;-register&lt;/code&gt; attribute passed to &lt;code&gt;:command&lt;/code&gt;).&lt;br&gt;&#xA;It's the same command as before, the only difference is you replace every occurrence of &lt;code&gt;q&lt;/code&gt; with &lt;code&gt;&amp;lt;reg&amp;gt;&lt;/code&gt;. When the command will be executed, Vim will automatically expand every occurrence of &lt;code&gt;&amp;lt;reg&amp;gt;&lt;/code&gt; with the register name you provided.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, all you have to do is record your macro as usual (non-recursively), then type &lt;code&gt;:RecursiveMacro q&lt;/code&gt; to make the macro stored inside register &lt;code&gt;q&lt;/code&gt; recursive.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could do the same thing to make a macro recursive on the condition it stays on the current line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @q = &quot;:let a=line('.')\r&quot; . @q . &quot;:if line('.')==a|exe 'norm @q'|endif\r&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's the exact same thing described at the beginning of the post, except this time you do it after the recording. You just concatenate two strings, one before and one after whatever keystrokes the &lt;code&gt;q&lt;/code&gt; register currently contains:  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;let @q =&lt;/code&gt; redefines the contents of register &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;:let a=line('.')\r&quot;&lt;/code&gt; stores the current line number inside the variable &lt;code&gt;a&lt;/code&gt; before the macro does its work&lt;br&gt;&#xA;&lt;code&gt;\r&lt;/code&gt; is necessary to tell Vim to press Enter and execute the command, see &lt;code&gt;:help expr-quote&lt;/code&gt; for a list of similar special characters,  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;. @q .&lt;/code&gt; concatenates the current contents of the &lt;code&gt;q&lt;/code&gt; register with the previous string and the next one,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;:if line('.')==a|exe 'norm @q'|endif\r&quot;&lt;/code&gt; recalls the macro &lt;code&gt;q&lt;/code&gt; on the condition that the line didn't change&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Again, to save some keystrokes, you can automate the process by defining the following custom command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -register RecursiveMacroOnLine let @&amp;lt;reg&amp;gt; = &quot;:let a=line('.')\r&quot; . @&amp;lt;reg&amp;gt; . &quot;:if line('.')==a|exe 'norm @&amp;lt;reg&amp;gt;'|endif\r&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And again, all you have to do is record your macro as usual (non-recursively), then type &lt;code&gt;:RecursiveMacroOnLine q&lt;/code&gt; to make the macro stored inside register &lt;code&gt;q&lt;/code&gt; recursive on the condition it stays on the current line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Merge the 2 commands&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also tweak &lt;code&gt;:RecursiveMacro&lt;/code&gt; so that it covers the 2 cases:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;make a macro recursive unconditionally,   &lt;/li&gt;&#xA;&lt;li&gt;make a macro recursive on the condition it stays on the current line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To do this, you could pass a second argument to &lt;code&gt;:RecursiveMacro&lt;/code&gt;. The latter would simply test its value and, depending on the value, would execute one of the 2 previous commands. It would give something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -register -nargs=1 RecursiveMacro if &amp;lt;args&amp;gt; | let @&amp;lt;reg&amp;gt; .= &quot;@&amp;lt;reg&amp;gt;&quot; | else | let @&amp;lt;reg&amp;gt; = &quot;:let a=line('.')\r&quot; . @&amp;lt;reg&amp;gt; . &quot;:if line('.')==a|exe 'norm @&amp;lt;reg&amp;gt;'|endif\r&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or (using line continuations/backslashes to make it a little more readable):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -register -nargs=1 RecursiveMacro&#xA;           \ if &amp;lt;args&amp;gt; |&#xA;           \     let @&amp;lt;reg&amp;gt; .= &quot;@&amp;lt;reg&amp;gt;&quot; |&#xA;           \ else |&#xA;           \     let @&amp;lt;reg&amp;gt; = &quot;:let a = line('.')\r&quot; .&#xA;           \                  @&amp;lt;reg&amp;gt; .&#xA;           \                  &quot;:if line('.')==a | exe 'norm @&amp;lt;reg&amp;gt;' | endif\r&quot; |&#xA;           \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's the same as before, except this time you have to provide a 2nd argument to &lt;code&gt;:RecursiveMacro&lt;/code&gt; (because of the &lt;code&gt;-nargs=1&lt;/code&gt; attribute).&lt;br&gt;&#xA;When this new command will be executed, Vim will automatically expand &lt;code&gt;&amp;lt;args&amp;gt;&lt;/code&gt; with the value you provided.&lt;br&gt;&#xA;If this 2nd argument is non-zero/true (&lt;code&gt;if &amp;lt;args&amp;gt;&lt;/code&gt;) the first version of the command will be executed (the one which makes a macro recursive unconditionally), otherwise if it's zero/false then the second version will be executed (the one which makes a macro recursive on the condition it stays on the current line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So going back to the previous example, it would give the following thing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq&#xA;&amp;lt;C-a&amp;gt;&#xA;w&#xA;q&#xA;:RecursiveMacro q 0&#xA;3G&#xA;0@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; begins the recording of a macro inside register &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; increments the number under the cursor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt; moves the cursor to the next number&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; ends the recording&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:RecursiveMacro q 0&lt;/code&gt; makes the macro stored inside register &lt;code&gt;q&lt;/code&gt;&#xA;recursive but only until the end of the line (because of the second argument &lt;code&gt;0&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;3G&lt;/code&gt; moves your cursor to an arbitrary line (3 for example)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0@q&lt;/code&gt; replays the recursive macro from the beginning of the line&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It should give the same result as before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 2 3 4&#xA;1 2 3 4&#xA;2 3 4 5&#xA;1 2 3 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this time you didn't have to type the distracting commands during the recording of your macro, you could simply focus on making a working one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And during step 5, if you had passed a non-zero argument to the command, that is if you had typed &lt;code&gt;:RecursiveMacro q 1&lt;/code&gt; instead of &lt;code&gt;:RecursiveMacro q 0&lt;/code&gt;, the macro &lt;code&gt;q&lt;/code&gt; would have become recursive unconditionally, which would have given the following buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 2 3 4&#xA;1 2 3 4&#xA;2 3 4 5&#xA;2 3 4 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This time the macro wouldn't have stopped at the end of the 3rd line but at the end of the buffer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help line()&#xA;:help :normal&#xA;:help :execute&#xA;:help :command-nargs&#xA;:help :command-register&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-02-11T05:49:58.457" LastActivityDate="2016-02-11T05:49:58.457" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6428" PostTypeId="2" ParentId="6426" CreationDate="2016-02-10T10:31:53.350" Score="12" Body="&lt;h2&gt;Use &lt;code&gt;l&lt;/code&gt;&lt;/h2&gt;&#xA;&lt;p&gt;A recursive macro will stop as soon as it encounters a command that fails. Therefore, to stop at the end of a line, you need a command that will fail at the end of the line.&lt;/p&gt;&#xA;&lt;p&gt;By default*, the &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#l&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;l&lt;/code&gt;&lt;/a&gt; command is such a command, so you can use it to stop a recursive macro. If the cursor is &lt;em&gt;not&lt;/em&gt; at the end of the line, then you just need to move it back afterwards with the command &lt;code&gt;h&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Example&lt;/h2&gt;&#xA;&lt;p&gt;So, using the &lt;a href=&quot;https://vi.stackexchange.com/a/6427/343&quot;&gt;same example macro as saginaw&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;qqqqq&amp;lt;c-a&amp;gt;lhw@qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Broken down:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;qqq&lt;/code&gt;: Clear out the q register,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt;: Start recording a macro in the &lt;code&gt;q&lt;/code&gt; register,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt;: Increment the number under the cursor,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;lh&lt;/code&gt;: If we are at the end of the line, abort the macro. Otherwise, do nothing.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt;: Advance to the next word on the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@q&lt;/code&gt;: Recurse&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: Stop recording.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;You can then run the macro with the same &lt;code&gt;0@q&lt;/code&gt; command as described by saginaw.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;* The &lt;code&gt;'whichwrap'&lt;/code&gt; option allows you to define which movement keys will wrap around to the next line when you are at the beginning or end of a line (See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27whichwrap%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'whichwrap'&lt;/code&gt;&lt;/a&gt;). If you have &lt;code&gt;l&lt;/code&gt; set in this option, then it will break the solution described above.&lt;/p&gt;&#xA;&lt;p&gt;However, it is likely that you only use one of the three default normal-mode commands for advancing a single character (&lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;, &lt;code&gt;l&lt;/code&gt;, and &lt;code&gt;&amp;lt;Right&amp;gt;&lt;/code&gt;), so if you have &lt;code&gt;l&lt;/code&gt; included in your &lt;code&gt;'whichwrap'&lt;/code&gt; setting, you can remove one that you &lt;em&gt;don't&lt;/em&gt; use from the &lt;code&gt;'whichwrap'&lt;/code&gt; option, e.g. for &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set whichwrap-=s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then you can replace the &lt;code&gt;l&lt;/code&gt; command in step 4 of the macro with a &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2022-07-21T14:23:36.217" LastActivityDate="2022-07-21T14:23:36.217" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6430" PostTypeId="1" CreationDate="2016-02-10T12:06:40.527" Score="3" ViewCount="84" Body="&lt;p&gt;I realize that this is probably too much to ask, but: sometimes one wants certain lines in a document to remain identical; might there be a way to link two lines such that changes to one are immediately also applied to the other?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-02-12T18:04:46.970" Title="Keeping lines identical" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6431" PostTypeId="2" ParentId="6375" CreationDate="2016-02-11T02:38:33.377" Score="1" Body="&lt;p&gt;A couple of things to consider:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;what is your &lt;code&gt;g:netrw_scp_cmd&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;you may need to give a full path to your system's scp&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2016-02-11T02:38:33.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6432" PostTypeId="1" AcceptedAnswerId="6439" CreationDate="2016-02-11T08:20:28.297" Score="13" ViewCount="7605" Body="&lt;p&gt;I know I can complete filenames/paths from the current directory using &lt;kbd&gt;Ctrl+X&lt;/kbd&gt;, &lt;kbd&gt;Ctrl+F&lt;/kbd&gt; (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#compl-filename&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;compl-filename&lt;/code&gt;&lt;/a&gt;). That works great in combination with &lt;code&gt;set autochdir&lt;/code&gt;, which changes the current directory to the directory of the active buffer.&lt;/p&gt;&#xA;&lt;p&gt;However, I started using &lt;a href=&quot;https://github.com/airblade/vim-rooter&quot; rel=&quot;nofollow noreferrer&quot;&gt;airblade/vim-rooter&lt;/a&gt; to make the current directory the &amp;quot;project&amp;quot; folder. Now filename completion always starts from the project folder.&lt;/p&gt;&#xA;&lt;p&gt;The question: Is there a way to make the filename completion use the directory of the active buffer instead of the current directory? Or some other workaround?&lt;/p&gt;&#xA;" OwnerUserId="6375" LastEditorUserId="4866" LastEditDate="2023-09-19T12:42:50.740" LastActivityDate="2023-09-19T12:42:50.740" Title="Vim filename/path completion" Tags="|autocompletion|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6433" PostTypeId="2" ParentId="6408" CreationDate="2016-02-11T11:08:06.847" Score="3" Body="&lt;p&gt;It looks like if you have &lt;code&gt;autoindent&lt;/code&gt; set, then &lt;code&gt;gqq&lt;/code&gt; honors the indentation of the line you’re on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    ~ ω  vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 10 2016 14:15:10)&#xA;MacOS X (unix) version&#xA;Included patches: 1-1257&#xA;Compiled by Homebrew&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Start Vim without any initialization files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;paste in a long line and giving it any indent&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set autoindent&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gqq&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Give it a try! 8-)&lt;/p&gt;&#xA;" OwnerUserId="4922" LastActivityDate="2016-02-11T11:08:06.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6434" PostTypeId="1" CreationDate="2016-02-11T11:40:55.253" Score="4" ViewCount="453" Body="&lt;p&gt;I am using terminal vim 7.4 and standard completion, i.e. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-x&amp;gt;,&amp;lt;C-p&amp;gt;&lt;/code&gt; for word completion&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; omnicompletion&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-x&amp;gt;,&amp;lt;C-f&amp;gt;&lt;/code&gt; for file completion etc, &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;~/.vimrc completion config&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;set omnifunc=syntaxcomplete#Complete&#xA;set completeopt=longest,menuone,preview&#xA;set iskeyword+=-&#xA;set dictionary=/usr/share/dict/words&#xA;set infercase&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So say I'm writing some PHP and I &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;type &lt;code&gt;var_d&lt;/code&gt;  (beginning of &lt;code&gt;var_dump()&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;then use omnicompletion &lt;kbd&gt;Ctrl - x&lt;/kbd&gt;,&lt;kbd&gt;Ctrl - o&lt;/kbd&gt;&lt;br&gt;&#xA;Vim is quick at summoning the completion list and incrementally narrowing the results.  &lt;/li&gt;&#xA;&lt;li&gt;Then I navigate up the completion menu to &lt;code&gt;var_dump&lt;/code&gt; and select with &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;At this point vim has a delay of about 1 to 1.5 seconds before inserting the text into the line itself.&lt;br&gt;&#xA;Its not a &quot;visual&quot; delay either, if I type anything during the delay period vim discards the completion selection - and I need to start the completion again.&lt;br&gt;&#xA;The delay seems strange and unnecessary because all the hard work of searching and sorting results has been done at this point, all vim needs to do is just put the item into the line.&lt;br&gt;&#xA;Is it possible to &quot;fix&quot; this delay so vim just instantly puts the selection in the line?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2016-02-11T11:48:53.703" LastActivityDate="2016-02-28T00:15:52.140" Title="Delay after selecting item from completion list" Tags="|autocompletion|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6435" PostTypeId="1" CreationDate="2016-02-11T12:17:52.193" Score="4" ViewCount="161" Body="&lt;p&gt;I set up this nifty custom function to help me use Vim for word processing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! WordProcessorMode()&#xA;    setlocal formatoptions=ant&#xA;    setlocal textwidth=60&#xA;    setlocal wrapmargin=0&#xA;endfu&#xA;com! WP call WordProcessorMode()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I use this mode, I find that unless I leave an empty line between two paragraphs, the two adjacent lines are automatically joined together, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;New Hampshire Spanks the Elites&#xA;Panic Sets In On Clinton Campaign&#xA;Some Sage Advice for Hillary Clinton&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;New Hampshire Spanks the Elites Panic Sets in on Clinton Campaign Some Sage Advice for Hillary Clinton&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, most of the time it's good practice to format your prose tidily, but sometimes (with numbered lists and whatnot) I would like to have the freedom to insert adjacent non-collapsed lines. Is it possible to alter my function to prevent this sort of behavior, or alternatively suspend it temporarily somehow so I can insert a numbered list?&lt;/p&gt;&#xA;" OwnerUserId="5772" LastEditorUserId="205" LastEditDate="2016-02-11T13:21:51.350" LastActivityDate="2016-02-11T23:51:11.453" Title="Format options setting collapses lines" Tags="|formatting|word-processing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6436" PostTypeId="1" CreationDate="2016-02-11T13:32:17.650" Score="7" ViewCount="1666" Body="&lt;p&gt;Is there any way to show line numbers by default, for all windows, buffers, and tabs opened inside Vim (including man pages, &lt;code&gt;netrw&lt;/code&gt; buffers, etc.)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have already tried to edit &lt;code&gt;_vimrc&lt;/code&gt; by putting &lt;code&gt;set number&lt;/code&gt;. This changes the behavior of the all new file buffers. But while I am opening a man page or navigating a directory listing using &lt;code&gt;netrw&lt;/code&gt; or &lt;code&gt;NERDTree&lt;/code&gt;, the line numbers are not showing up. And for each kind of those windows, buffers and tabs, I have to run &lt;code&gt;:se nu&lt;/code&gt;. Are there any way to enable Vim to show up line numbers for all its buffers?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Why do I need this?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am very new to Vim and try to adopt its culture. Previously, I was using &lt;a href=&quot;http://www.lugaru.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Epsilon — a EMACS-style text editor&lt;/a&gt; editor for a long time. But, some time ago, I found &lt;a href=&quot;https://stackoverflow.com/q/1218390/797393&quot;&gt;this question at Stack Overflow&lt;/a&gt; and was very astonished to see &lt;a href=&quot;https://stackoverflow.com/a/1220118/797393&quot;&gt;its answer&lt;/a&gt; and started to learn Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, in my previous editor these are easy settings for me, what my eyes are very familiar with. And I believe there must some way to do this in Vim too.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Can anybody help me or at least give me some hint to get this setting done? &lt;/p&gt;&#xA;" OwnerUserId="5912" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-02-11T19:12:01.810" Title="How to show line numbers for all buffers, windows &amp; tabs" Tags="|vimrc|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6437" PostTypeId="1" AcceptedAnswerId="6443" CreationDate="2016-02-11T13:58:12.167" Score="6" ViewCount="472" Body="&lt;p&gt;I use the &lt;a href=&quot;https://github.com/lervag/vimtex&quot;&gt;vimtex&lt;/a&gt; plugin for TeX editing and &lt;a href=&quot;https://github.com/reedes/vim-lexical&quot;&gt;vim-lexical&lt;/a&gt; for spell-checking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works generally fine, but there are several commands vim-lexical tries to spellcheck. For example, in &lt;code&gt;\includepdf{pathToPdfFile}&lt;/code&gt; it marks the path to the file as spelling mistake. How can I tell vim-lexical that it should ignore everything in some commands (such as &lt;code&gt;\includepdf&lt;/code&gt;) but consider in some others (everything in &lt;code&gt;\bf&lt;/code&gt; should be checked)?&lt;/p&gt;&#xA;" OwnerUserId="6379" LastEditorUserId="205" LastEditDate="2016-02-11T14:33:56.423" LastActivityDate="2016-02-11T21:59:12.480" Title="How do I spellcheck TeX files using vim-lexical, skipping some command arguments but not others?" Tags="|filetype-tex|spell-checking|plugin-vimtex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6438" PostTypeId="1" AcceptedAnswerId="6440" CreationDate="2016-02-11T14:26:15.690" Score="6" ViewCount="1912" Body="&lt;p&gt;Is there any way to show non-printable characters by default, for all windows, buffers, tabs, opened inside Vim (including man pages, &lt;code&gt;netrw&lt;/code&gt; buffers, etc.)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally I also like to see the non-printable characters for all the buffers. And here goes my &lt;code&gt;_vimrc&lt;/code&gt; lines for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    scriptencoding utf-8&#xA;    set listchars+=space:·&#xA;    set listchars=eol:¶,tab:» ,trail:~,extends:&amp;gt;,precedes:&amp;lt;,space:·&#xA;    set list &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And again, this is working for all the file buffers. As soon as I open up a manual page or &lt;code&gt;netrw&lt;/code&gt; directory listing or &lt;code&gt;NERDTree&lt;/code&gt; buffer, I have to run &lt;code&gt;:se list&lt;/code&gt; for each buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody help me or at least give me some hint to get this setting done? &lt;/p&gt;&#xA;" OwnerUserId="5912" LastEditorUserId="205" LastEditDate="2016-02-11T14:30:52.897" LastActivityDate="2016-02-11T16:05:08.980" Title="How to show non-printable characters for all buffers, windows &amp; tabs" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6439" PostTypeId="2" ParentId="6432" CreationDate="2016-02-11T14:46:26.677" Score="7" Body="&lt;p&gt;As @muru mentioned, there are no options to configure the directory from which to complete path and file names.  It always uses the working directory of the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've written a couple of functions and mappings to help with this. Behind the scenes, they change the local working directory (using &lt;code&gt;:lcd&lt;/code&gt;) temporarily, then restore the previous working directory when done.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Elephant&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For reasons unknown to even me, I've called this micro-plugin &lt;em&gt;Elephant&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code (copied from my &lt;a href=&quot;https://github.com/tommcdo/vimfiles/blob/acbfebde2fb468dbad05d8acf7d395727dfa0202/config/elephant.vim&quot;&gt;Vim config on GitHub&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:elephant_map = {&#xA;    \ 'f': function('elephant#current_file'),&#xA;    \ 'p': function('elephant#vcs_project')&#xA;\ }&#xA;&#xA;function! elephant#prompt(base)&#xA;    let l:Fcn = get(g:elephant_map, a:base, function('elephant#identity'))&#xA;    let l:basedir = l:Fcn()&#xA;    execute 'lcd' l:basedir&#xA;    let l:file = fnamemodify(input(l:basedir.'/', '', 'file'), ':p')&#xA;    lcd -&#xA;    return fnamemodify(l:file, ':.')&#xA;endfunction&#xA;&#xA;function! s:elephant_init()&#xA;    let l:base = getchar()&#xA;    return elephant#prompt(nr2char(l:base))&#xA;endfunction&#xA;&#xA;function! elephant#identity()&#xA;    return '.'&#xA;endfunction&#xA;&#xA;function! elephant#vcs_project()&#xA;    return fnamemodify(finddir('.git', '.;'), ':h')&#xA;endfunction&#xA;&#xA;function! elephant#current_file()&#xA;    return expand('%:h')&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;C-R&amp;gt;&amp;lt;C-E&amp;gt; &amp;lt;SID&amp;gt;elephant_init()&#xA;cnoremap &amp;lt;silent&amp;gt; &amp;lt;C-R&amp;gt;&amp;lt;C-E&amp;gt; &amp;lt;C-R&amp;gt;=&amp;lt;SID&amp;gt;elephant_init()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;How to use it&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Using these mappings happens in 3 steps.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;1. Invoke the mapping&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In Insert mode or Command-line mode, invoke the mapping using &lt;code&gt;&amp;lt;C-R&amp;gt;&amp;lt;C-E&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;2. Choose a directory&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Type a single character to choose which root directory you want completion from. The code above provides two types of roots:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;f&lt;/code&gt; - The directory that the current file (buffer) resides in&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; - The base directory of the Git project the current file belongs to&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;3. Enter the path or file name&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You will be prompted to enter the path or file name relative to the directory specified, with completion available. Press &lt;code&gt;Enter&lt;/code&gt; when finished.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Some notes&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This doesn't provide inline completion in Insert mode the way &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-F&amp;gt;&lt;/code&gt; does; instead, you will be typing the path or file name on the Command-line prompt (where &lt;code&gt;:&lt;/code&gt; commands go). Upon pressing &lt;code&gt;Enter&lt;/code&gt;, the path will be inserted into the buffer.&lt;/li&gt;&#xA;&lt;li&gt;The same is true in Command-line mode, which can sometimes be confusing when you hit &lt;code&gt;Enter&lt;/code&gt; and forget that you still have to hit &lt;code&gt;Enter&lt;/code&gt; to issue whatever command you were just typing.&lt;/li&gt;&#xA;&lt;li&gt;Other directory functions can be registered by adding them into &lt;code&gt;g:elephant_map&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The path inserted will be the full, absolute path. The script can be tweaked to change that behaviour, but I haven't got around to it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="64" LastActivityDate="2016-02-11T14:46:26.677" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6440" PostTypeId="2" ParentId="6438" CreationDate="2016-02-11T16:05:08.980" Score="4" Body="&lt;p&gt;You can get &lt;code&gt;'list'&lt;/code&gt; on all the windows by using the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup setList&#xA;   au!&#xA;   au BufWinEnter *  set list&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The (long) explanation of why it doesn't work only by setting it on the vimrc can be found at &lt;code&gt;:help local-options&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-02-11T16:05:08.980" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6441" PostTypeId="2" ParentId="6436" CreationDate="2016-02-11T19:12:01.810" Score="6" Body="&lt;p&gt;From  &lt;a href=&quot;https://vi.stackexchange.com/a/6440/5912&quot;&gt;mMontu's answer&lt;/a&gt;, to my another similar question.... that this can easily be solved by adding below line in &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWinEnter * set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5912" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-02-11T19:12:01.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6442" PostTypeId="1" AcceptedAnswerId="6444" CreationDate="2016-02-11T20:28:08.940" Score="10" ViewCount="2021" Body="&lt;p&gt;Any way to get Vim to format my comments to comply with Google cpplint?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ylpkg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ylpkg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Top section is not compliant, to comply 5 changes are required.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;keep this comment at the same level&lt;/li&gt;&#xA;&lt;li&gt;Add a space after &lt;code&gt;//&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;add minimum of two spaces between code and comment&lt;/li&gt;&#xA;&lt;li&gt;align comments&lt;/li&gt;&#xA;&lt;li&gt;add space after &lt;code&gt;//&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;(Note I am also asking this question here, it may be possible to do with Tabular &lt;a href=&quot;https://github.com/godlygeek/tabular/issues/44&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/godlygeek/tabular/issues/44&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: As per recommendation below, this works:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plugin =&gt; &lt;a href=&quot;https://github.com/rhysd/vim-clang-format&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/rhysd/vim-clang-format&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;.nvimrc or .vimrc Configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:clang_format#code_style='google'&#xA;&#xA;let g:clang_format#style_options = {&#xA;            \ &quot;AccessModifierOffset&quot; : -3,&#xA;            \ &quot;Standard&quot; : &quot;C++03&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="7161" LastEditDate="2016-06-06T14:05:55.767" LastActivityDate="2016-06-06T14:05:55.767" Title="How do I align C++ comments to be compliant with Google styling?" Tags="|filetype-c++|alignment|plugin-tabular|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6443" PostTypeId="2" ParentId="6437" CreationDate="2016-02-11T21:59:12.480" Score="5" Body="&lt;p&gt;First: This is not related to &lt;code&gt;vim-lexical&lt;/code&gt;. Syntax rules define where spell checking should be done, and so the current behaviour is defined by the internal syntax plugin for LaTeX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default syntax rule for tex command arguments allows spell checking. Some commands, e.g. &lt;code&gt;\include{...}&lt;/code&gt;, are not spell checked. This is controlled by the &lt;code&gt;@Spell&lt;/code&gt; and &lt;code&gt;@NoSpell&lt;/code&gt; syntax clusters, see &lt;code&gt;:h spell-syntax&lt;/code&gt; and &lt;code&gt;:h syn-spell&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to add your own rules, you can create the file &lt;code&gt;.vim/after/syntax/tex.vim&lt;/code&gt;. An example rule that will match &lt;code&gt;\includepdf&lt;/code&gt; and prevent spelling is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match texInputFile /\\includepdf\%(\[.\{-}\]\)\=\s*{.\{-}}/&#xA;      \ contains=texStatement,texInputCurlies,texInputFileOpt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this rule makes the syntax matching of &lt;code&gt;\includepdf&lt;/code&gt; correspond to &lt;code&gt;\include&lt;/code&gt; and similar commands. To prevent spelling of other commands where such a correspondence does not make sense, you could also use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match texStatement '\\includepdf' nextgroup=texMyNoSpell&#xA;syntax region texMyNoSpell matchgroup=Delimiter start='{' end='}' contained&#xA;      \ contains=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note: Please don't hesitate to &lt;a href=&quot;https://github.com/lervag/vimtex/issues&quot;&gt;open issues with vimtex&lt;/a&gt; for things like this. vimtex provides some updates to the syntax rules on top of the internal syntax plugin, and the &lt;code&gt;\includepdf&lt;/code&gt; command is a good example of commands I personally think should be matched.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-02-11T21:59:12.480" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6444" PostTypeId="2" ParentId="6442" CreationDate="2016-02-11T22:25:54.433" Score="11" Body="&lt;p&gt;&lt;a href=&quot;http://clang.llvm.org/docs/ClangFormat.html&quot;&gt;clang-format&lt;/a&gt; is a command line tool that formats c++ code. One of the default formatters is google.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;clang-format -style=google&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are plugins that would allow you to run clang-format in vim. One such plugin is &lt;a href=&quot;https://github.com/rhysd/vim-clang-format&quot;&gt;https://github.com/rhysd/vim-clang-format&lt;/a&gt; (I have not used it, it was the first I found)&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2016-02-11T22:25:54.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6445" PostTypeId="2" ParentId="6435" CreationDate="2016-02-11T23:51:11.453" Score="3" Body="&lt;p&gt;I also use vim for a lot of word processing/prose, and I format as I go, rather than having a catch-all command that formats all your text at once. By manually formatting as I go, I implicitly solve the problem you describe. I'm not sure if this fits your workflow, but I'll describe it below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Easy line wrapping/formatting&#xA;imap gq &amp;lt;C-G&amp;gt;u&amp;lt;ESC&amp;gt;gw}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which I invoke whenever I want to leave insert mode after typing out text that I wish to format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This mapping performs the following actions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-G&amp;gt;u&lt;/code&gt; Manually create an undo-block, so we can unformat the text if we don't like it;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; Leave insert mode;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gw}&lt;/code&gt; Format to the end of the paragraph. You can change &lt;code&gt;}&lt;/code&gt; to whatever motion you prefer. (I format as I go along, so I only format from my current position to the end of the paragraph, which works well if I assume the previous text in the paragraph is formatted correctly.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So as you're typing out &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;New Hampshire Spanks the Elites&#xA;Panic Sets In On Clinton Campaign&#xA;Some Sage Advice for Hillary Clinton&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You simply don't use the mapping to leave insert mode. If you're typing out something that you DO want to format however; use the mapping to leave insert mode, and everything's done for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EG a long series of text input:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Streaming video is becoming a larger and more important proportion of internet traffic with each passing year. Video data is projected to take up 80\% of consumer internet traffic in 2019, with over 70\% of that being delivered via commercial Content Delivery Networks&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gets formatted into the following when I leave insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Streaming video is becoming a larger and more important proportion of&#xA;internet traffic with each passing year. Video data is projected to take up&#xA;80\% of consumer internet traffic in 2019, with over 70\% of that being&#xA;delivered via commercial Content Delivery Networks&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if I want to make an edit to some point of the paragraph:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Streaming video is REALLY COOL AND I LIKE IT SO MUCH AND SO DOES EVERYONE ELSE AND THAT'S WHY IT'S becoming a larger and more important proportion of&#xA;internet traffic with each passing year. Video data is projected to take up&#xA;80\% of consumer internet traffic in 2019, with over 70\% of that being&#xA;delivered via commercial Content Delivery Networks&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gets nicely formatted into the following as well, when I leave insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Streaming video is REALLY COOL AND I LIKE IT SO MUCH AND SO DOES EVERYONE&#xA;ELSE AND THAT'S WHY IT'S becoming a larger and more important proportion of&#xA;internet traffic with each passing year. Video data is projected to take up&#xA;80\% of consumer internet traffic in 2019, with over 70\% of that being&#xA;delivered via commercial Content Delivery Networks&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4932" LastActivityDate="2016-02-11T23:51:11.453" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6446" PostTypeId="1" AcceptedAnswerId="6470" CreationDate="2016-02-12T02:13:12.833" Score="1" ViewCount="3634" Body="&lt;p&gt;I have been trying to install &lt;code&gt;YouCompleteMe&lt;/code&gt; for a long time. At first, I failed because I need to build &lt;code&gt;Vim&lt;/code&gt; having python support. Now I have it solved, but I always fail at building &lt;code&gt;YouCompleteMe&lt;/code&gt; itself because of various kinds of problems (if you guys want to help me on this, that's okay too :-)). The build log of &lt;code&gt;YouCompleteMe&lt;/code&gt; is this (using only &lt;code&gt;./install.py&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./install.py&#xA;-- The C compiler identification is GNU 5.3.1&#xA;...... Successful Detects ......&#xA;-- Detecting CXX compile features - done&#xA;Your C++ compiler supports C++11, compiling in that mode.&#xA;-- Found PythonLibs: /usr/local/lib/libpython2.7.a (found suitable version &quot;2.7.10&quot;, minimum required is &quot;2.6&quot;) &#xA;-- Found PythonInterp: /usr/local/bin/python2 (found suitable version &quot;2.7.10&quot;, minimum required is &quot;2.6&quot;) &#xA;NOT using libclang, no semantic completion for C/C++/ObjC will be available&#xA;-- Found PythonInterp: /usr/local/bin/python2 (found version &quot;2.7.10&quot;) &#xA;-- Looking for include file pthread.h&#xA;-- Looking for include file pthread.h - found&#xA;-- Looking for pthread_create&#xA;-- Looking for pthread_create - not found&#xA;-- Looking for pthread_create in pthreads&#xA;-- Looking for pthread_create in pthreads - not found&#xA;-- Looking for pthread_create in pthread&#xA;-- Looking for pthread_create in pthread - found&#xA;-- Found Threads: TRUE  &#xA;-- Configuring done&#xA;-- Generating done&#xA;-- Build files have been written to: /tmp/ycm_build.jmI4vO&#xA;Scanning dependencies of target BoostParts&#xA;[  0%] [  2%] [  2%] Building CXX object BoostParts/CMakeFiles/BoostParts.dir/libs/atomic/src/lockpool.cpp.o&#xA;...... Successfully Builds ......&#xA;[ 92%] Building CXX object ycm/CMakeFiles/ycm_client_support.dir/PythonSupport.cpp.o&#xA;In file included from /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/BoostParts/boost/type_traits/ice.hpp:15:0,&#xA;                 from /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/BoostParts/boost/python/detail/def_helper.hpp:9,&#xA;                 from /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/BoostParts/boost/python/class.hpp:29,&#xA;                 from /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/BoostParts/boost/python.hpp:18,&#xA;                 from /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/PythonSupport.h:21,&#xA;                 from /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/ycm_client_support.cpp:19:&#xA;/home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/BoostParts/boost/type_traits/detail/ice_or.hpp:17:71: note: #pragma message: NOTE: Use of this header (ice_or.hpp) is deprecated&#xA; # pragma message(&quot;NOTE: Use of this header (ice_or.hpp) is deprecated&quot;)&#xA;                                                                       ^&#xA;...... Some similar messages ......&#xA;In file included from /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/BoostParts/boost/type_traits/ice.hpp:18:0,&#xA;                 from /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/BoostParts/boost/python/detail/def_helper.hpp:9,&#xA;                 from /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/BoostParts/boost/python/class.hpp:29,&#xA;                 from /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/BoostParts/boost/python.hpp:18,&#xA;                 from /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/PythonSupport.h:21,&#xA;                 from /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/ycm_core.cpp:19:&#xA;/home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/BoostParts/boost/type_traits/detail/ice_eq.hpp:17:71: note: #pragma message: NOTE: Use of this header (ice_eq.hpp) is deprecated&#xA; # pragma message(&quot;NOTE: Use of this header (ice_eq.hpp) is deprecated&quot;)&#xA;                                                                       ^&#xA;[ 96%] Building CXX object ycm/CMakeFiles/ycm_client_support.dir/CustomAssert.cpp.o&#xA;[ 97%] Building CXX object ycm/CMakeFiles/ycm_client_support.dir/Result.cpp.o&#xA;[ 98%] [100%] Building CXX object ycm/CMakeFiles/ycm_core.dir/CustomAssert.cpp.o&#xA;Building CXX object ycm/CMakeFiles/ycm_core.dir/Result.cpp.o&#xA;Linking CXX shared library /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_support.so&#xA;/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC&#xA;/usr/local/lib/libpython2.7.a: error adding symbols: Bad value&#xA;collect2: error: ld returned 1 exit status&#xA;ycm/CMakeFiles/ycm_client_support.dir/build.make:387: recipe for target '/home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_support.so' failed&#xA;make[3]: *** [/home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_support.so] Error 1&#xA;CMakeFiles/Makefile2:130: recipe for target 'ycm/CMakeFiles/ycm_client_support.dir/all' failed&#xA;make[2]: *** [ycm/CMakeFiles/ycm_client_support.dir/all] Error 2&#xA;make[2]: *** Waiting for unfinished jobs....&#xA;Linking CXX shared library /home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so&#xA;/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC&#xA;/usr/local/lib/libpython2.7.a: error adding symbols: Bad value&#xA;collect2: error: ld returned 1 exit status&#xA;ycm/CMakeFiles/ycm_core.dir/build.make:387: recipe for target '/home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so' failed&#xA;make[3]: *** [/home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so] Error 1&#xA;CMakeFiles/Makefile2:165: recipe for target 'ycm/CMakeFiles/ycm_core.dir/all' failed&#xA;make[2]: *** [ycm/CMakeFiles/ycm_core.dir/all] Error 2&#xA;CMakeFiles/Makefile2:209: recipe for target 'ycm/CMakeFiles/ycm_support_libs.dir/rule' failed&#xA;make[1]: *** [ycm/CMakeFiles/ycm_support_libs.dir/rule] Error 2&#xA;Makefile:148: recipe for target 'ycm_support_libs' failed&#xA;make: *** [ycm_support_libs] Error 2&#xA;Traceback (most recent call last):&#xA;  File &quot;/home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py&quot;, line 372, in &amp;lt;module&amp;gt;&#xA;    Main()&#xA;  File &quot;/home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py&quot;, line 361, in Main&#xA;    BuildYcmdLibs( args )&#xA;  File &quot;/home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py&quot;, line 275, in BuildYcmdLibs&#xA;    subprocess.check_call( build_command )&#xA;  File &quot;/usr/local/lib/python2.7/subprocess.py&quot;, line 540, in check_call&#xA;    raise CalledProcessError(retcode, cmd)&#xA;subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'ycm_support_libs', '--', '-j', '4']' returned non-zero exit status 2&#xA;Traceback (most recent call last):&#xA;  File &quot;./install.py&quot;, line 32, in &amp;lt;module&amp;gt;&#xA;    Main()&#xA;  File &quot;./install.py&quot;, line 21, in Main&#xA;    subprocess.check_call( [ python_binary, build_file ] + sys.argv[1:] )&#xA;  File &quot;/usr/local/lib/python2.7/subprocess.py&quot;, line 540, in check_call&#xA;    raise CalledProcessError(retcode, cmd)&#xA;subprocess.CalledProcessError: Command '['/usr/local/bin/python', '/home/bunny/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py']' returned non-zero exit status 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;. So I install the package &lt;code&gt;vim-youcompleteme&lt;/code&gt; by &lt;code&gt;apt&lt;/code&gt; successfully. So how can I use &lt;code&gt;YouCompleteMe&lt;/code&gt; now?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;EDIT:&lt;/em&gt;&lt;/strong&gt; I used &lt;code&gt;vam&lt;/code&gt; to install &lt;code&gt;YouCompleteMe&lt;/code&gt;, no problem, but when I open &lt;code&gt;vi&lt;/code&gt;, it gives me this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function youcompleteme#Enable..    &amp;lt;SNR&amp;gt;30_SetUpPython:&#xA;line   29:&#xA;Traceback (most recent call last):&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function youcompleteme#Enable..&amp;lt;SNR&amp;gt;30_SetUpPython:&#xA;line   29:&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 25, in &amp;lt;module&amp;gt;&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function youcompleteme#Enable..&amp;lt;SNR&amp;gt;30_SetUpPython:&#xA;line   29:&#xA;  File &quot;/usr/share/vim-youcompleteme/python/ycm/youcompleteme.py&quot;, line 34, in &amp;lt;module&amp;gt;&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function youcompleteme#Enable..&amp;lt;SNR&amp;gt;30_SetUpPython:&#xA;line   29:&#xA;    from ycm.client.ycmd_keepalive import YcmdKeepalive&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function youcompleteme#Enable..&amp;lt;SNR&amp;gt;30_SetUpPython:&#xA;line   29:&#xA;  File &quot;/usr/share/vim-youcompleteme/python/ycm/client/ycmd_keepalive.py&quot;, line 22, in &amp;lt;module&amp;gt;&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function youcompleteme#Enable..&amp;lt;SNR&amp;gt;30_SetUpPython:&#xA;line   29:&#xA;from ycm.client.base_request import BaseRequest&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function youcompleteme#Enable..&amp;lt;SNR&amp;gt;30_SetUpPython:&#xA;line   29:&#xA;   File &quot;/usr/share/vim-youcompleteme/python/ycm/client/base_request.py&quot;, line 20, in &amp;lt;module&amp;gt;&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function youcompleteme#Enable..&amp;lt;SNR&amp;gt;30_SetUpPython:&#xA;line   29:&#xA;    import requests&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function youcompleteme#Enable..&amp;lt;SNR&amp;gt;30_SetUpPython:&#xA;line   29:&#xA;ImportError: No module named requests&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vi --version&lt;/code&gt; output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 11 2016 19:19:30)&#xA;Compiled by Vostro-3400&#xA;Normal version with GTK2 GUI.  Features included (+) or not (-):&#xA;-arabic          +file_in_path    -mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;+balloon_eval    +float           -mouse_urxvt     -tag_any_white&#xA;+browse          +folding         +mouse_xterm     -tcl&#xA;+builtin_terms   -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;+clientserver    -hangul_input    +netbeans_intg   +title&#xA;+clipboard       +iconv           +path_extra      +toolbar&#xA;+cmdline_compl   +insert_expand   -perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    -keymap          +postscript      +virtualedit&#xA;+comments        -langmap         +printer         +visual&#xA;-conceal         +libcall         -profile         +visualextra&#xA;+cryptv          +linebreak       +python          +viminfo&#xA;-cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con_gui  -lua             -rightleft       +windows&#xA;+diff            +menu            -ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      +X11&#xA;+dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     +xim&#xA;-emacs_tags      +mouseshape      -sniff           +xsmp_interact&#xA;+eval            -mouse_dec       +startuptime     +xterm_clipboard&#xA;+ex_extra        -mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    &#xA;-farsi           -mouse_netterm   +syntax          &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -I/usr/local/include  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -ldl    -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6380" LastEditorUserId="6380" LastEditDate="2016-02-12T08:56:03.760" LastActivityDate="2016-02-14T08:53:20.223" Title="Installation of YouCompleteMe" Tags="|plugin-you-complete-me|" AnswerCount="1" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="6447" PostTypeId="1" AcceptedAnswerId="6458" CreationDate="2016-02-12T10:40:48.380" Score="4" ViewCount="1233" Body="&lt;p&gt;I am write a plugin for neovim in python using &lt;a href=&quot;https://github.com/neovim/python-client&quot; rel=&quot;nofollow&quot;&gt;this client&lt;/a&gt; and I looking for a way to offer completion when executing a command. I have look at the &lt;a href=&quot;https://neovim.io/doc/user/remote_plugin.html&quot; rel=&quot;nofollow&quot;&gt;following example&lt;/a&gt; to structure my plugin. As an example, I could have a command Foo and when you call it the first time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Foo bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the second time you could autocomplete:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Foo b&amp;lt;tab&amp;gt; -&amp;gt; Foo bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as an example my this is what my plugin look like in my ~/.config/nvim/rplugin/python3/my_plugin.py:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import neovim&#xA;&#xA;@neovim.plugin&#xA;class MyPlugin(object):&#xA;    def __init__(self, vim):&#xA;        self.vim = vim&#xA;        self.current_args = []&#xA;&#xA;    @neovim.command(&quot;Cmd&quot;, range=&quot;&quot;, nargs=&quot;*&quot;, sync=True)&#xA;    def CmdHandler(self, args, range):&#xA;        if args[0] not in self.current_args:&#xA;            self.current_args.append(args[0])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I guess I would need to write a function for the completion for&#xA;the command?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@neovim.function(&quot;MyCompletionFunction&quot;)&#xA;def MyCompletionFunction(self, args):&#xA;    ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and set my function as completion function for my command.&#xA;any help appreciated&lt;/p&gt;&#xA;" OwnerUserId="6381" LastEditorUserId="6381" LastEditDate="2016-02-12T21:08:28.970" LastActivityDate="2016-02-13T01:33:56.860" Title="neovim: autocompletion on user defined command plugin" Tags="|autocompletion|neovim|plugin-system|vimscript-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6448" PostTypeId="1" AcceptedAnswerId="6450" CreationDate="2016-02-12T10:55:31.213" Score="3" ViewCount="635" Body="&lt;p&gt;Is there a way to run tests of the current opened file and get output in other window like &lt;a href=&quot;https://github.com/thinca/vim-quickrun&quot; rel=&quot;nofollow&quot;&gt;vim-QuickRun&lt;/a&gt; does?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I'm running tests by the command in command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/vagrant/my_project/app/Console/cake test app Console/Command/FeedParseShell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;+++UPDATE+++&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm calling &lt;code&gt;cake&lt;/code&gt; command in the project folder by absolute path, because I have several projects on my virtual machine. I'm still not aware how to make &lt;code&gt;vim&lt;/code&gt; to know where is the root folder of the project It's currently in.&#xA;And then I tell CakePHP console what command I want it to run by specifying the option &lt;code&gt;test&lt;/code&gt; and write the path to the test file.&#xA;It looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/vagrant/my_project/app/Console/cake test app Console/Command/FeedParseShell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;app&lt;/code&gt; is not necessary - we can specify the absolute path to the test file without &lt;code&gt;app&lt;/code&gt; like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/vagrant/my_project/app/Console/cake test /vagrant/my_project/app/Test/Case/Console/Command/FeedParseShell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Test files are locatedy in different folders. Here is the structure of &lt;code&gt;Test/Case&lt;/code&gt; folder:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Console  Controller  Lib  Model  View  allTest.php&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3302" LastEditorUserId="51" LastEditDate="2016-02-15T10:10:03.257" LastActivityDate="2016-02-15T10:10:03.257" Title="How do I run Cakephp's tests (PHPUnit) and output it to QuickRun or other window?" Tags="|quickfix|filetype-php|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6449" PostTypeId="1" CreationDate="2016-02-12T11:33:25.793" Score="2" ViewCount="464" Body="&lt;p&gt;I'm using old Debian linux an vim version 7.1.314. I would like to edit eclipse .cproject file that build using XML syntax. Currently vim shows not colored information. I found vim plugin that I hope wil solve my problem  &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1397&quot; rel=&quot;nofollow&quot;&gt;xml.vim&lt;/a&gt; . I hve done evrything as described in installation manual:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ln -s xml.vim docbk.vim&#xA;ln -s xml.vim xsl.vim&#xA;ln -s xml.vim html.vim&#xA;ln -s xml.vim xhtml.vim&#xA;cd ..&#xA;mkdir indent&#xA;echo &quot;let b:did_indent = 1&quot; &amp;gt; ~/.vim/indent/xml.vim &#xA;echo &quot;let b:did_indent = 1&quot; &amp;gt; ~/.vim/indent/xsl.vim &#xA;echo &quot;let b:did_indent = 1&quot; &amp;gt; ~/.vim/indent/html.vim &#xA;echo &quot;let b:did_indent = 1&quot; &amp;gt; ~/.vim/indent/xhtml.vim &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After I have restarted vim and opened file I found the same old not colored text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to be sure vim has loaded plugin? Where might be problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After  I have placed line &lt;code&gt;filetype indent on&lt;/code&gt; in &lt;code&gt;~/.vimrc&lt;/code&gt; I got error while loading vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /root/.vimrc:&#xA;line    1:&#xA;E319: Sorry, the command is not available in this version: filetype indent on&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD &#xA;:version uputput&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.1 (2007 May 12, compiled Oct 17 2008 18:03:34)&#xA;Included patches: 1-314&#xA;Compiled by jamessan@debian.org&#xA;Small version without GUI.  Features included (+) or not (-):&#xA;-arabic -autocmd -balloon_eval -browse +builtin_terms -byte_offset -cindent -clientserver -clipboard -cmdline_compl +cmdline_hist -cmdline_info -comments -cryptv -cscope -cursorshape -dialog -diff -digraphs -dnd -ebcdic -emacs_tags -eval -ex_extra -extra_search -farsi -file_in_path -find_in_path -folding -footer +fork() -gettext -hangul_input +iconv -insert_expand +jumplist -keymap -langmap -libcall -linebreak &#xA;-lispindent -listcmds -localmap -menu -mksession -modify_fname -mouse -mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_xterm +multi_byte -multi_lang -mzscheme -netbeans_intg -osfiletype -path_extra -perl -printer -profile -python -quickfix -reltime -rightleft -ruby -scrollbind -signs -smartindent -sniff -statusline -sun_workshop -syntax -tag_binary -tag_old_static -tag_any_white -tcl +terminfo -termresponse &#xA;-textobjects -title -toolbar -user_commands -vertsplit -virtualedit +visual -visualextra -viminfo -vreplace +wildignore -wildmenu +windows +writebackup -X11 +xfontset -xim -xsmp -xterm_clipboard -xterm_save &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -O2 -g -Wall -DTINY_VIMRC        &#xA;Linking: gcc   -Wl,--as-needed -L/usr/local/lib -o vim    -lncurses  -lselinux &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;UPD &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After I did simple &lt;code&gt;aptitude istall vim&lt;/code&gt; I got following in &lt;code&gt;:version&lt;/code&gt; output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:version&#xA;VIM - Vi IMproved 7.1 (2007 May 12, compiled Oct 17 2008 18:11:28)&#xA;Included patches: 1-314&#xA;Compiled by jamessan@debian.org&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv +cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall +linebreak &#xA;+lispindent +listcmds +localmap +menu +mksession +modify_fname +mouse -mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm +mouse_xterm +multi_byte +multi_lang -mzscheme -netbeans_intg -osfiletype +path_extra -perl +postscript +printer +profile -python +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl &#xA;+terminfo +termresponse +textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now xml looks formated, but still no colors&lt;/p&gt;&#xA;" OwnerUserId="6399" LastEditorUserId="6399" LastEditDate="2016-02-17T09:18:48.053" LastActivityDate="2016-02-17T09:18:48.053" Title="Make vim version 7 edit xml files" Tags="|vimrc|indentation|version|filetype-xml|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6450" PostTypeId="2" ParentId="6448" CreationDate="2016-02-12T14:01:56.930" Score="3" Body="&lt;p&gt;I'm not familiar with CakePHP, but you could use &lt;code&gt;:make&lt;/code&gt; for it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set makeprg=/vagrant/my_project/app/Console/cake\ test\ app\ Console/Command/FeedParseShell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, if you run &lt;code&gt;:make&lt;/code&gt;, the output of this command will be used to populate &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#quickfix&quot; rel=&quot;nofollow&quot;&gt;the quickfix list&lt;/a&gt; (which can be useful if the output identifies offending line numbers).&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-02-12T14:01:56.930" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6451" PostTypeId="1" CreationDate="2016-02-12T14:48:56.963" Score="2" ViewCount="147" Body="&lt;p&gt;Minimal (not-)working example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Test()&#xA;  let save=changenr()&#xA;  call append(0, &quot;THIS MUST BE UNDONE&quot;)&#xA;  exe &quot;undo &quot;.save&#xA;endfun&#xA;command! -nargs=0 T :call Test()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now open a file, insert some garbage (because &quot;undo 0&quot; won't work), then call the command &lt;code&gt;:T&lt;/code&gt; three times in a row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my machine at least, the first two times it works as expected (i.e. does nothing). But the last time the text &lt;code&gt;THIS MUST BE UNDONE&lt;/code&gt; is added to the buffer. On closer inspection, the value of &lt;code&gt;save&lt;/code&gt; used on the third execution is 2, while the two previous ones were both 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happened? (Probably something mysterious related to &lt;code&gt;undotree&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt;: while I'm at it, the fact that &lt;code&gt;undo 0&lt;/code&gt; does not work looks like a bug in itself. If I open a file and then do two modifications A and B, then &lt;code&gt;undo 1&lt;/code&gt; puts me after A, &lt;code&gt;undo 2&lt;/code&gt; puts me after A+B, but vim refuses to &lt;code&gt;undo 0&lt;/code&gt; to put me before A...&lt;/p&gt;&#xA;" OwnerUserId="1940" LastEditorUserId="1940" LastEditDate="2016-02-12T15:03:13.917" LastActivityDate="2016-02-12T19:45:50.523" Title="changenr() + undo does not work as expected" Tags="|undo-redo|" AnswerCount="1" CommentCount="8" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6452" PostTypeId="1" CreationDate="2016-02-12T16:26:42.523" Score="9" ViewCount="1722" Body="&lt;p&gt;I wanted to write this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A = mapping[0]&#xA;B = mapping[1]&#xA;C = mapping[2]&#xA;D = mapping[3]&#xA;E = mapping[4]&#xA;F = mapping[5]&#xA;G = mapping[6]&#xA;H = mapping[7]&#xA;I = mapping[8]&#xA;J = mapping[9]&#xA;K = mapping[10]&#xA;L = mapping[11]&#xA;M = mapping[12]&#xA;N = mapping[13]&#xA;O = mapping[14]&#xA;P = mapping[15]&#xA;Q = mapping[16]&#xA;R = mapping[17]&#xA;S = mapping[18]&#xA;T = mapping[19]&#xA;U = mapping[20]&#xA;V = mapping[21]&#xA;W = mapping[22]&#xA;X = mapping[23]&#xA;Y = mapping[24]&#xA;Z = mapping[25]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I ended up using LibreCalc, putting the different parts in different cells, adding the letters and numbers, concatenating the results and pasting the lot back into Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appreciate that what I wanted to write is awful code. I'm studying Python at the moment and have been trying to avoid going to find information myself that I know will be covered later in the course I'm following (&lt;a href=&quot;http://interactivepython.org/&quot;&gt;http://interactivepython.org/&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quickest way I knew of to do this in vim was to type something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A = mapping[0] &amp;lt;ESC&amp;gt; hh &amp;lt;CTRL&amp;gt;+&amp;lt;V&amp;gt; BBh y $ o B &amp;lt;ESC&amp;gt; y 1] &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know vim is very powerful (I've been using it for a couple of weeks, am really enjoying it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would it have been possible to write what I wanted to with some vim command?&lt;/p&gt;&#xA;" OwnerUserId="6402" LastEditorUserId="205" LastEditDate="2016-02-12T19:46:53.127" LastActivityDate="2016-02-15T18:28:22.903" Title="Can Vim write incremental lines? i.e. on each line A becomes B, and 1 becomes 2" Tags="|macro|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6453" PostTypeId="2" ParentId="6452" CreationDate="2016-02-12T16:40:59.647" Score="12" Body="&lt;p&gt;While it can be done with scripting, if you have a very recent version of Vim (e.g. the one in Arch Linux), you can use &lt;code&gt;g Ctrl-a&lt;/code&gt; to increment a visual block. In your case:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Write the original line: &lt;code&gt;A = mapping[0]&lt;/code&gt; &lt;code&gt;Esc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Yank line and put 25 copies of it below: &lt;code&gt;yy25p&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Visually select the column containing the &lt;code&gt;0&lt;/code&gt; char (block selection, using &lt;code&gt;Ctrl-v&lt;/code&gt;), excluding the &lt;code&gt;0&lt;/code&gt; from the 1st line (so you end up with a column containing the last 25 zeroes), then increment them with &lt;code&gt;g Ctrl-a&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Apply the same method for the column containing &lt;code&gt;A&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;Note&lt;/em&gt;: As comments show, one needs to add &lt;code&gt;alpha&lt;/code&gt; to the &lt;code&gt;nrformats&lt;/code&gt; options, in order to be able to increment letters, e.g.: &lt;code&gt;set nrformats+=alpha&lt;/code&gt;.My &lt;em&gt;vimrc&lt;/em&gt; has: &lt;code&gt;set nrformats=hex,alpha&lt;/code&gt;, thus disabling octal and binary increment, which I don't use)&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-02-14T23:02:52.940" LastActivityDate="2016-02-14T23:02:52.940" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="6454" PostTypeId="2" ParentId="6452" CreationDate="2016-02-12T17:49:08.663" Score="6" Body="&lt;p&gt;I prefer the visual increment solution that @VanLaser used (See &lt;code&gt;:h v_CTRL-A&lt;/code&gt;). However I will show this can be done via macro as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A = mapping[0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Record the following keypresses into a macro of your choice (e.g &lt;code&gt;q&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yyp:set nrformats+=alpha&amp;lt;cr&amp;gt;&amp;lt;c-a&amp;gt;:set nrformats-=alpha&amp;lt;c-a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will duplicate the line and then increment the first character (e.g. &lt;code&gt;A&lt;/code&gt;) and then increment the number portion. Run this macro 24 times and you are done, e.g. &lt;code&gt;24@q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; - start recording into register &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yyp&lt;/code&gt; - duplicate the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set nrformats+=alpha&amp;lt;cr&amp;gt;&lt;/code&gt; - &lt;code&gt;'nrformats&lt;/code&gt; does not have &lt;code&gt;alpha&lt;/code&gt; by default&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; - With &lt;code&gt;alpha&lt;/code&gt; we can now increment letters&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set nrformats-=alpha&amp;lt;cr&amp;gt;&lt;/code&gt; - remove &lt;code&gt;alpha&lt;/code&gt; from &lt;code&gt;'nrformats'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; - increment the next number&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; - stop recording&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;24@q&lt;/code&gt; - replay macro in register &lt;code&gt;q&lt;/code&gt; 24 times&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h q&#xA;:h @&#xA;:h yy&#xA;:h p&#xA;:h 'nrformats'&#xA;:h :set&#xA;:h CTRL-A&#xA;:h v_CTRL-A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-02-12T17:49:08.663" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6455" PostTypeId="2" ParentId="6430" CreationDate="2016-02-12T18:04:46.970" Score="2" Body="&lt;p&gt;I think I agree with the comments suggesting that this is the wrong way to approach whatever problem you're &lt;em&gt;actually&lt;/em&gt; trying to solve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said... You'd need to mark up the document in &lt;em&gt;some&lt;/em&gt; fashion to do this. Here's a exceedingly simple proof-of-concept:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SyncLines()&#xA;  let pairs = []&#xA;  call cursor(1, 1)&#xA;  while search(&quot;//&amp;gt;&quot;, &quot;eW&quot;) &amp;gt; 0&#xA;    let pattern = str2nr(strpart(getline(&quot;.&quot;), col(&quot;.&quot;)))&#xA;    if pattern &amp;gt; 0&#xA;      call add(pairs, [pattern, line(&quot;.&quot;)])&#xA;    endif&#xA;  endwhile&#xA;&#xA;  for pair in pairs&#xA;    call setline(pair[1], getline(pair[0]) . &quot;//&amp;gt;&quot; . pair[0])&#xA;  endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works by scanning the document for &lt;code&gt;//&amp;gt;X&lt;/code&gt; patterns. Where &lt;code&gt;//&amp;gt;X&lt;/code&gt; appears, the function will replace the entire line with the contents of line &lt;code&gt;X&lt;/code&gt; (plus the same &lt;code&gt;//&amp;gt;X&lt;/code&gt; token so the process is repeatable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously this is brittle in a few ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it moves the cursor and doesn't have a mechanism to restore the cursor to the old position, would be be needed in a more user-friendly implementation.&lt;/li&gt;&#xA;&lt;li&gt;it assumes the token sequence &lt;code&gt;//&amp;gt;&lt;/code&gt; has no other useful meaning in the file; this should be configurable or maybe based on the value of the &lt;code&gt;comments&lt;/code&gt; setting.&lt;/li&gt;&#xA;&lt;li&gt;it doesn't do anywhere near enough error or sanity checking; I didn't do anything more than a few quick tests to make sure it sorta-worked.&lt;/li&gt;&#xA;&lt;li&gt;it works on single lines only, not regions of lines&lt;/li&gt;&#xA;&lt;li&gt;it (most importantly) is not resilient to changes in the document moving the text and thus invalidating line numbers.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I were going to implement this &quot;for real,&quot; what I'd probably do is make the token sequence more complex, essentially allowing it to name a keyword. So I'd use &lt;code&gt;//!copyright&lt;/code&gt; to mark up a line that was the &lt;em&gt;source&lt;/em&gt; line (named &quot;copyright&quot;) and &lt;code&gt;//&amp;gt;copyright&lt;/code&gt; to denote the line that received the value of the &quot;copyright&quot; source line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd probably also set it up so that if the token appears entirely on a line on its own, it would mean that the function should read or write the line immediately &lt;em&gt;after&lt;/em&gt; the token, since that might be useful behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any event, once set up, you could wire this function into a pre-write or post-load autocommand, depending on your needs.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2016-02-12T18:04:46.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6456" PostTypeId="2" ParentId="6451" CreationDate="2016-02-12T18:34:57.407" Score="3" Body="&lt;p&gt;If you are going to learn how the undotree feature works, &lt;a href=&quot;https://vi.stackexchange.com/questions/6108/&quot;&gt;similar to this question&lt;/a&gt;, then you should use some plugin to have a graphic representation of the undotree while you try the commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also useful to increase the verbosity of your test function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Test()&#xA;  echom 'prev changenr() = '.changenr()&#xA;  let save=changenr()&#xA;  call append(0, &quot;THIS MUST BE UNDONE&quot;)&#xA;  exe &quot;undo &quot;.save&#xA;  echom 'post changenr() = '.changenr()&#xA;endfun&#xA;command! -nargs=0 T :call Test()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For your test case, I noticed that each execution of the &lt;code&gt;:T&lt;/code&gt; command inserts a node on the undotree. Before starting the test the &lt;a href=&quot;https://github.com/mbbill/undotree/&quot; rel=&quot;nofollow noreferrer&quot;&gt;undo tree plugin&lt;/a&gt; shows the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; *   &amp;gt;2&amp;lt;   (1 second ago)&#xA; *    1    (2 seconds ago)&#xA; *    0    (Original)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First execution of &lt;code&gt;:T&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;prev changenr() = 2&#xA;1 line less; after #2  20 seconds ago&#xA;post changenr() = 2&#xA;&#xA;&#xA; *   {3}   (1 second ago)&#xA; *   &amp;gt;2&amp;lt;   (21 seconds ago)&#xA; *    1    (22 seconds ago)&#xA; *    0    (Original)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After the second &lt;code&gt;:T&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;prev changenr() = 2&#xA;1 line less; after #2  31 seconds ago&#xA;post changenr() = 3&#xA;&#xA;&#xA; *   {4}   (1 second ago)&#xA; | *    3    (12 seconds ago)&#xA; |/&#xA; *   &amp;gt;2&amp;lt;   (32 seconds ago)&#xA; *    1    (33 seconds ago)&#xA; *    0    (Original)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;line less&lt;/code&gt; messages -- the command &lt;code&gt;:T&lt;/code&gt; changed the buffer, thus it changed the undotree. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible that the creation of the branch when change &lt;code&gt;{4}&lt;/code&gt; is introduced caused &lt;code&gt;changenr()&lt;/code&gt; to return the different value.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-02-12T19:45:50.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6457" PostTypeId="2" ParentId="6378" CreationDate="2016-02-12T19:35:17.523" Score="2" Body="&lt;p&gt;Another way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let n = 1 | g/^* /s//\=printf('%d. ', n)/g | let n = n + 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5912" LastActivityDate="2016-02-12T19:35:17.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6458" PostTypeId="2" ParentId="6447" CreationDate="2016-02-12T20:57:21.563" Score="1" Body="&lt;p&gt;First of all, when you define a new command in the way I do, a &lt;a href=&quot;https://neovim.io/doc/user/map.html#user-commands&quot; rel=&quot;nofollow&quot;&gt;user-command&lt;/a&gt;, you can specify in which way the command  will be autocompleted (&lt;a href=&quot;https://neovim.io/doc/user/map.html#:command-completion&quot; rel=&quot;nofollow&quot;&gt;command-completion&lt;/a&gt;) and there's a lot of choices.&#xA;So the way I did it is with a customlist function as follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@neovim.plugin&#xA;class MyPlugin(object):&#xA;&#xA;    def __init__(self, vim):&#xA;        self.vim = vim&#xA;        self.values = []&#xA;&#xA;    @neovim.command(&quot;Cmd&quot;, complete='customlist,MyFunc', range=&quot;&quot;, nargs=&quot;1&quot;, sync=True)&#xA;    def Cmd(self, args, range):&#xA;        new_value = args[0]&#xA;        self.values.append(new_value)&#xA;&#xA;    @neovim.function(&quot;MyFunc&quot;, sync=True)&#xA;    def MyFunc(self, *args, **kwargs):&#xA;        return self.values&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so each time I exec the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Cmd value1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;next time, I can&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Cmd va&amp;lt;Tab&amp;gt;  -&amp;gt; :Cmd value1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6381" LastEditorUserId="6381" LastEditDate="2016-02-13T01:33:56.860" LastActivityDate="2016-02-13T01:33:56.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6459" PostTypeId="1" CreationDate="2016-02-12T23:14:22.130" Score="9" ViewCount="278" Body="&lt;p&gt;I found it hard to understand these text object motions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *]]*&#xA;]]          [count] sections forward or to the next '{' in the&#xA;            first column.  When used after an operator, then also&#xA;            stops below a '}' in the first column.  |exclusive|&#xA;            Note that |exclusive-linewise| often applies.&#xA;&#xA;                            *][*&#xA;][          [count] sections forward or to the next '}' in the&#xA;            first column.  |exclusive|&#xA;            Note that |exclusive-linewise| often applies.&#xA;&#xA;                            *[[*&#xA;[[          [count] sections backward or to the previous '{' in&#xA;            the first column.  |exclusive|&#xA;            Note that |exclusive-linewise| often applies.&#xA;&#xA;                            *[]*&#xA;[]          [count] sections backward or to the previous '}' in&#xA;            the first column.  |exclusive|&#xA;            Note that |exclusive-linewise| often applies.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can understand that &quot;]&quot; means forward, just like &quot;]}&quot; go to the next unmatched &quot;}&quot;, and the second part &quot;}&quot; describe the target, which make sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what does the second brackets in &quot;]]&quot;, &quot;][&quot;, &quot;[[&quot;, &quot;[]&quot; means? If second &quot;]&quot; in &quot;]]&quot; means &quot;'{' in the first column&quot;, then what about the second &quot;]&quot; in &quot;[]&quot;, which means '}' rather than '{'. I just cannot make sense of these 4 text object motions. &lt;/p&gt;&#xA;" OwnerUserId="6405" LastActivityDate="2016-02-17T10:13:01.427" Title="Make sense of &quot;[[&quot;, &quot;]]&quot;, &quot;[]&quot;, &quot;][&quot;" Tags="|cursor-motions|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6460" PostTypeId="2" ParentId="6452" CreationDate="2016-02-13T01:26:13.217" Score="4" Body="&lt;p&gt;Fine answers already provided, I wouldn't have thought to go about it as nicely. I would have typed out all the letters on a single line and then introduced text and line break with an expression substitution (using line number for incremental number), something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iABCDEFGHIJKLMNOPQRSTUVXYZ&amp;lt;Esc&amp;gt;:s/./\=submatch(0).&quot; = mapping[&quot;.line('.').&quot;]\n&quot;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2016-02-13T01:26:13.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6462" PostTypeId="2" ParentId="6452" CreationDate="2016-02-13T10:39:37.807" Score="2" Body="&lt;p&gt;Almost always when doing something like this, I choose to use &lt;code&gt;:substitute&lt;/code&gt; over macros. Especially the capability to evaluate expression in replacement when starting with &lt;code&gt;\=&lt;/code&gt; makes it often possible (see &lt;code&gt;:h sub-replace-special&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have empty lines in place (&lt;code&gt;25i&amp;lt;Enter&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;), you can use command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,26s/^/\=nr2char(line('.')+64) . ' = mapping[' . (line('.')-1) . ']'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the necessary sequences are generated using current line (&lt;code&gt;'.'&lt;/code&gt; argument) number returned by function &lt;code&gt;line()&lt;/code&gt;, and using nr2char() to convert decimal numbers to ASCII equivalents (65 = A). Necessary strings are concatenated using &lt;code&gt;.&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1672" LastActivityDate="2016-02-13T10:39:37.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6463" PostTypeId="1" AcceptedAnswerId="6471" CreationDate="2016-02-13T11:25:49.703" Score="3" ViewCount="229" Body="&lt;p&gt;I have done a bit of research about this but found only very old answers, &lt;a href=&quot;http://vim_use.narkive.com/2WmlB8vD/buffer-local-mode&quot;&gt;like this one&lt;/a&gt;, and all on the negative side. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is the following --- suppose you are working on a document/program, say for example a LaTeX file. You have some error and you open another window/tab with the log file, which is opened in read-only mode (the same for the quickfix window). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you switch to insert mode in your main file, and &lt;em&gt;all&lt;/em&gt; the windows/tabs/buffers enters insert mode. So I can't switch rapidly to the &quot;log&quot; windows/tab to scroll/move/hitting &quot;q&quot; to close it, because it's in input mode... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QCNfY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QCNfY.png&quot; alt=&quot;example, log file in input mode&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the question is — is it possible to remember the mode at a window/tab level? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that it could have been confusing in the original &lt;code&gt;vi&lt;/code&gt;, but with things like &lt;code&gt;airline&lt;/code&gt; and colors it's quite handy to know the mode in which you are... &lt;/p&gt;&#xA;" OwnerUserId="854" LastActivityDate="2016-02-14T10:52:13.757" Title="Have different tabs/windows remembering their mode" Tags="|gvim|insert-mode|vim-windows|normal-mode|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6464" PostTypeId="1" CreationDate="2016-02-13T16:46:00.493" Score="1" ViewCount="413" Body="&lt;p&gt;Normally, &lt;code&gt;:syn match Entity &quot;e&quot; conceal&lt;/code&gt; and &lt;code&gt;:set conceallevel=3&lt;/code&gt; results in all &lt;code&gt;e&lt;/code&gt;s being concealed.  But, if I use vim-plug, this does not work in a tex-file … &lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="51" LastEditDate="2016-02-18T07:38:57.237" LastActivityDate="2016-02-18T07:38:57.237" Title="Conceal not working with tex files and vim-plug" Tags="|filetype-tex|conceal|plugin-vim-plug|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6465" PostTypeId="1" CreationDate="2016-02-13T19:57:34.063" Score="1" ViewCount="1188" Body="&lt;p&gt;I just added a few things to my &lt;code&gt;colorscheme.vim&lt;/code&gt; which is sourced from my &lt;code&gt;.vimrc&lt;/code&gt;.  In fact, it is the &lt;em&gt;last line&lt;/em&gt; in the &lt;code&gt;.vimrc&lt;/code&gt;.&lt;sup&gt;1&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source ~/.vim/colorscheme.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Oddly, now &lt;em&gt;most&lt;/em&gt; of it doesn't apply, yet some of it obviously does.  If I manually &lt;code&gt;:source ~/.vim/colorscheme.vim&lt;/code&gt; it works, and so the only solution I've found is to add a keybinding for that.  I.e., now everytime I start the editor I have to manually load the colorscheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's &lt;code&gt;colorscheme.vim&lt;/code&gt;.  The stuff I added was mostly for &lt;code&gt;Diff&lt;/code&gt; but a few other things got tweaked.  Loaded manually, it all seems to work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi ColorColumn guibg=Black guifg=#dbdbdb ctermbg=black ctermfg=yellow&#xA;hi Comment ctermbg=gray ctermfg=darkblue guibg=#dbbdbd guifg=#000088&#xA;hi Conditional cterm=bold ctermfg=yellow gui=bold guifg=#ffff00&#xA;hi Constant ctermfg=brown guifg=#ff8800&#xA;hi Cursor guibg=#ff0000 guifg=#ffff00&#xA;hi Directory ctermfg=gray&#xA;hi DiffAdd guibg=#000044 guifg=#ffff00&#xA;hi DiffChange guibg=#000044 guifg=#aaaaaa&#xA;hi DiffDelete guibg=#000044 guifg=#008888&#xA;hi DiffText guibg=#884400 guifg=#ff8800&#xA;hi ErrorMsg ctermbg=red ctermfg=cyan cterm=bold guibg=#880000 guifg=#ffffff gui=bold&#xA;hi Folded guibg=#00ff00 guifg=#3300aa ctermbg=blue ctermfg=green&#xA;hi Identifier ctermfg=darkgreen gui=none guifg=#449944&#xA;hi LineNr ctermbg=black ctermfg=darkblue guibg=#111111 guifg=#444444&#xA;hi NonText ctermfg=red guifg=#ff8800&#xA;hi Normal guibg=#222228 guifg=#dbdbdb&#xA;hi Number cterm=underline ctermfg=green gui=underline guifg=#00ff00&#xA;hi PreProc cterm=bold guifg=#cccc88 &#xA;hi Repeat cterm=bold ctermfg=cyan gui=bold guifg=#00ffff&#xA;hi StatusLine cterm=bold ctermfg=green ctermbg=darkmagenta guibg=#aa00aa guifg=#00ff00&#xA;hi StatusLineNC ctermfg=7 ctermbg=black&#xA;hi Special ctermfg=magenta gui=bold guifg=#ff0088 guibg=#303030&#xA;hi SpecialKey ctermfg=darkblue guifg=#111111&#xA;hi SpellBad ctermbg=gray ctermfg=darkred&#xA;hi Statement ctermfg=gray guifg=#448888 &#xA;hi Type ctermfg=darkcyan guifg=#dd88dd gui=italic&#xA;&#xA;if has(&quot;gui_running&quot;)&#xA;        set guioptions -=r&#xA;        set guioptions +=l&#xA;        set guioptions -=T&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A weird thing about &quot;some of it&quot; working is that it includes, e.g., &lt;code&gt;SpellBad&lt;/code&gt;, which is near the end.  So it is not flaking out at some point, it is just ignoring or overriding most of the other stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This applies to both console vim and gvim.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1. Note that &lt;strong&gt;there were no changes made to &lt;code&gt;.vimrc&lt;/code&gt;&lt;/strong&gt;, although since then I've tried moving that line to the top, etc., but this did not make any difference.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="4913" LastEditorUserId="4913" LastEditDate="2016-02-13T20:48:14.597" LastActivityDate="2022-11-15T02:00:50.107" Title="Color scheme won't fully source from .vimrc" Tags="|vimrc|colorscheme|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6466" PostTypeId="2" ParentId="6465" CreationDate="2016-02-13T21:50:49.087" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Your &quot;colorscheme&quot; is missing too many things to be called a &quot;colorscheme&quot;. Here is a fixed version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; 'strawberry.vim' -- Vim color scheme.&#xA;&quot; Author:       ...&#xA;&quot; Description:  ...&#xA;&#xA;hi clear&#xA;&#xA;if exists(&quot;syntax_on&quot;)&#xA;    syntax reset&#xA;endif&#xA;&#xA;let colors_name = &quot;strawberry&quot;&#xA;&#xA;hi Normal guibg=#222228 guifg=#dbdbdb&#xA;&#xA;set background=dark&#xA;&#xA;hi ColorColumn guibg=Black guifg=#dbdbdb ctermbg=black ctermfg=yellow&#xA;hi Comment ctermbg=gray ctermfg=darkblue guibg=#dbbdbd guifg=#000088&#xA;hi Conditional cterm=bold ctermfg=yellow gui=bold guifg=#ffff00&#xA;hi Constant ctermfg=brown guifg=#ff8800&#xA;hi Cursor guibg=#ff0000 guifg=#ffff00&#xA;hi Directory ctermfg=gray&#xA;hi DiffAdd guibg=#000044 guifg=#ffff00&#xA;hi DiffChange guibg=#000044 guifg=#aaaaaa&#xA;hi DiffDelete guibg=#000044 guifg=#008888&#xA;hi DiffText guibg=#884400 guifg=#ff8800&#xA;hi ErrorMsg ctermbg=red ctermfg=cyan cterm=bold guibg=#880000 guifg=#ffffff gui=bold&#xA;hi Folded guibg=#00ff00 guifg=#3300aa ctermbg=blue ctermfg=green&#xA;hi Identifier ctermfg=darkgreen gui=none guifg=#449944&#xA;hi LineNr ctermbg=black ctermfg=darkblue guibg=#111111 guifg=#444444&#xA;hi NonText ctermfg=red guifg=#ff8800&#xA;hi Number cterm=underline ctermfg=green gui=underline guifg=#00ff00&#xA;hi PreProc cterm=bold guifg=#cccc88&#xA;hi Repeat cterm=bold ctermfg=cyan gui=bold guifg=#00ffff&#xA;hi StatusLine cterm=bold ctermfg=green ctermbg=darkmagenta guibg=#aa00aa guifg=#00ff00&#xA;hi StatusLineNC ctermfg=7 ctermbg=black&#xA;hi Special ctermfg=magenta gui=bold guifg=#ff0088 guibg=#303030&#xA;hi SpecialKey ctermfg=darkblue guifg=#111111&#xA;hi SpellBad ctermbg=gray ctermfg=darkred&#xA;hi Statement ctermfg=gray guifg=#448888&#xA;hi Type ctermfg=darkcyan guifg=#dd88dd gui=italic&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Put your colorscheme in &lt;code&gt;~/.vim/colors/&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/colors/strawberry.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add this line to your &lt;code&gt;vimrc&lt;/code&gt; in order to enable your colorscheme:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme strawberry&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-02-13T21:50:49.087" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="6467" PostTypeId="2" ParentId="6463" CreationDate="2016-02-13T22:45:21.540" Score="3" Body="&lt;p&gt;I'm going to be bold and claim that your problem will be solved if you learn to use Vim/vi without using the mouse. Learn to stay in normal mode on a default basis, from which changing the window can be done with &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;&lt;/code&gt;. You will be happier in the long term, even though this may take some effort and time in the short term.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: I know this is not an answer to your actual question, and I'll accept being downvoted for that reason.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-02-13T22:45:21.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6468" PostTypeId="1" CreationDate="2016-02-14T05:49:07.983" Score="5" ViewCount="2615" Body="&lt;p&gt;I'm using Vim on Cygwin. Basically, Vim won't allow me to move past the last character on a line when I'm in normal/command mode. It will let me move right before the last character but not after it. Any thoughts on what might be wrong?&lt;/p&gt;&#xA;" OwnerUserId="6414" LastActivityDate="2016-02-14T06:44:35.863" Title="Can't Move to End of Line With Vim on Cygwin" Tags="|cygwin|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6469" PostTypeId="2" ParentId="6468" CreationDate="2016-02-14T06:44:35.863" Score="6" Body="&lt;p&gt;Vim's cursor is always &lt;em&gt;on&lt;/em&gt; a character position, never &lt;em&gt;between&lt;/em&gt; character positions, even though some cursor shapes make it appear that the cursor is between character positions. When your cursor appears to be before the last character, it is probably &lt;em&gt;on&lt;/em&gt; the last character. That is Vim's normal behavior. You can change it, if you like, by following saginaw's suggestion of using the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set virtualedit+=onemore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2016-02-14T06:44:35.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6470" PostTypeId="2" ParentId="6446" CreationDate="2016-02-14T08:43:42.357" Score="3" Body="&lt;p&gt;After some tries, I finally find out what's going on with my installation of &lt;code&gt;vim-youcompleteme&lt;/code&gt;, and I decided to answer my own question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, building from source is not a good idea, unless you &lt;em&gt;have&lt;/em&gt; to do it (just like my non-python support &lt;code&gt;vim&lt;/code&gt;). Installing pre-built packages is always a good idea and a good starting point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, the dependencies are important. When having the package installed and plugin installed by &lt;code&gt;vam&lt;/code&gt;(&lt;code&gt;vim-addon-manager&lt;/code&gt;), you need to solve the problems showing on the start of &lt;code&gt;vim&lt;/code&gt;. For me, the main problem is the &lt;code&gt;requests&lt;/code&gt; and &lt;code&gt;requests_futures&lt;/code&gt;. After figuring it out, just use &lt;code&gt;pip&lt;/code&gt; to install it and done!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, thank you for those guys have helped me! You guys give some good advice and hints!&lt;/p&gt;&#xA;" OwnerUserId="6380" LastEditorUserId="6380" LastEditDate="2016-02-14T08:53:20.223" LastActivityDate="2016-02-14T08:53:20.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6471" PostTypeId="2" ParentId="6463" CreationDate="2016-02-14T10:33:11.810" Score="4" Body="&lt;p&gt;In order for Vim to remember if you are in insert mode or not for each window opened, you could add the following autocmds inside your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup RememberMode&#xA;    autocmd!&#xA;    autocmd WinLeave * let w:mode_state = mode()&#xA;    autocmd WinEnter *&#xA;                \ if exists('w:mode_state') &amp;amp;&amp;amp; w:mode_state ==# 'i' |&#xA;                \     startinsert |&#xA;                \ elseif exists('w:mode_state') &amp;amp;&amp;amp; mode() ==# 'i' |&#xA;                \     stopinsert |&#xA;                \ endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one &lt;code&gt;autocmd WinLeave * let w:mode_state = mode()&lt;/code&gt; stores the mode in which you are when you leave a window (&lt;code&gt;WinLeave&lt;/code&gt; event) inside the window-local variable &lt;code&gt;w:mode_state&lt;/code&gt; (you can change the name of the variable if you don't like it, but keep the window-local scope &lt;code&gt;w:&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second one tests, when you enter a window (&lt;code&gt;WinEnter&lt;/code&gt; event), whether the window-local variable &lt;code&gt;w:mode_state&lt;/code&gt; exists (because if it's a window you just created, it will not exist and the following test would probably raise an error), and if its value is &lt;code&gt;'i'&lt;/code&gt;.&lt;br&gt;&#xA;If it is, it means that the last time you left this window you were in insert mode, so Vim puts you back in insert mode with the Ex command &lt;code&gt;:startinsert&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, the autocmd tests whether &lt;code&gt;w:mode_state&lt;/code&gt; exists and you're in insert mode. In this case, it means that you were already in this window in the past (otherwise the variable wouldn't exist), but you were not in insert mode (because this case has already been covered), you were in another mode. So Vim makes you quit insert mode with the Ex command &lt;code&gt;:stopinsert&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :augroup&#xA;:help :autocmd&#xA;:help WinLeave&#xA;:help WinEnter&#xA;:help w:&#xA;:help mode()&#xA;:help exists()&#xA;:help :startinsert&#xA;:help :stopinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-02-14T10:52:13.757" LastActivityDate="2016-02-14T10:52:13.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6472" PostTypeId="1" AcceptedAnswerId="6473" CreationDate="2016-02-14T11:16:01.413" Score="4" ViewCount="384" Body="&lt;p&gt;I just learnt from &lt;a href=&quot;http://vimcasts.org/episodes/formatting-text-with-par/&quot; rel=&quot;nofollow&quot;&gt;a vimcast (#18)&lt;/a&gt; that one can format paragraphs justified. This seemed very attractive to me, but I had one problem with it: I use double spaces after the end of sentences to distinguish periods from abbreviation dots. Using &lt;code&gt;set cpo+=J&lt;/code&gt;, &lt;code&gt;par&lt;/code&gt; does not preserve these double spaces; can it be made to?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="205" LastEditDate="2016-02-14T11:55:59.427" LastActivityDate="2016-02-14T12:41:25.683" Title="Formatting with par and justified option" Tags="|formatting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6473" PostTypeId="2" ParentId="6472" CreationDate="2016-02-14T12:41:25.683" Score="6" Body="&lt;p&gt;(Not to let this without an answer; even if a short one) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick digging on the internet shows the right &lt;code&gt;par&lt;/code&gt; option: &lt;code&gt;g1&lt;/code&gt;. To quote the &lt;a href=&quot;http://www.8t8.us/configs/vimrc.txt&quot;&gt;source&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set formatprg=par\ 72q\ g1  &quot; Use par for gq. use gw for internal formatting&#xA;                            &quot; g1 preserves double spaces after periods.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-02-14T12:41:25.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6474" PostTypeId="1" CreationDate="2016-02-14T12:42:06.990" Score="2" ViewCount="84" Body="&lt;p&gt;I have to put a macro in front of Greek text to get correct hyphenation, such that I have, e.g.: &lt;code&gt;possibly \textgreek{κινούμενον} and possibly not&lt;/code&gt;.  Could I use conceal to &lt;code&gt;conceal&lt;/code&gt; the macro and show the words in green? &lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="205" LastEditDate="2016-02-14T13:28:41.527" LastActivityDate="2016-02-14T13:28:41.527" Title="How do I hide a TeX macro and highlight the arguments?" Tags="|filetype-tex|highlight|conceal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6475" PostTypeId="2" ParentId="6474" CreationDate="2016-02-14T13:27:11.690" Score="3" Body="&lt;p&gt;You could:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight GreekHyphen guifg=green ctermfg=green&#xA;:syn region GreekHyphen matchgroup=GreekHyphenMark start='\\textgreek{' end='}' concealends&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to use &lt;code&gt;matchgroup&lt;/code&gt; for &lt;code&gt;concealends&lt;/code&gt; to work. &lt;code&gt;concealends&lt;/code&gt; is used to conceal only the boundaries of a match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;concealends                     *:syn-concealends*&#xA;&#xA;When the &quot;concealends&quot; argument is given, the start and end matches of&#xA;the region, but not the contents of the region, are marked as concealable.&#xA;Whether or not they are actually concealed depends on the setting on the&#xA;'conceallevel' option. The ends of a region can only be concealed separately&#xA;in this way when they have their own highlighting via &quot;matchgroup&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Beware though: I don't know how well this will work with nested commands.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-02-14T13:27:11.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6476" PostTypeId="2" ParentId="3542" CreationDate="2016-02-14T13:42:21.907" Score="2" Body="&lt;p&gt;Add the line&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;runtime! macros/matchit.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to your &lt;code&gt;vimrc&lt;/code&gt; and into &lt;code&gt;~/.vim/after/ftplugin/tex.vim&lt;/code&gt; the lines&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let b:match_words = get(b:, 'match_words', &amp;amp;l:matchpairs)&#xA;      \ ',' . '\%(^\|[ (/]\)\zs\\(' . ':' . '\\)\ze\%($\|[ )/.\,;\:?!\-]\)' .&#xA;      \ ',' . '\%(^\|[ (/]\)\zs\\\[' . ':' . '\\\]\ze\%($\|[ )/.\,;\:?!\-]\)' .&#xA;      \ ',' . '\%(^\|[ (/]\)\zs\$[^$ ]' . ':' . '[^$ ]\zs\$\ze\%($\|[ )/.\,;\:?!\-]\)' .&#xA;      \ ',' . '\%(^\|[ (/]\)\zs\$\$' . ':' . '\$\$\ze\%($\|[ )/.\,;\:?!\-]\)' .&#xA;      \ ',' . '\%(^\s*\)\zs\\begin{\(\w\+\*\?\)}' . ':' . '\%(^\s*\)\zs\\end{\1}' .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This lets you jump between TeX math and environment delimiters by &lt;code&gt;%&lt;/code&gt; (but isn't yet entirely robust).&lt;/p&gt;&#xA;" OwnerUserId="6416" LastEditorUserId="6416" LastEditDate="2024-03-25T10:01:15.630" LastActivityDate="2024-03-25T10:01:15.630" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6477" PostTypeId="1" AcceptedAnswerId="6553" CreationDate="2016-02-14T14:57:53.553" Score="2" ViewCount="115" Body="&lt;p&gt;When formatting paragraphs with concealed elements, the formatting program does not take into account that some characters are invisible, and renders some lines shorter than the rest, when using the justified text option (&lt;code&gt;set formatprg=par\ j&lt;/code&gt;).  Might there be an easy way to fix this?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-02-18T06:44:25.107" Title="Conflict: concealment and paragraph formatting" Tags="|formatting|conceal|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6478" PostTypeId="1" AcceptedAnswerId="6524" CreationDate="2016-02-14T17:07:26.900" Score="8" ViewCount="1394" Body="&lt;p&gt;Many systems offer + and - zoom buttons. Can someone please demonstrate how such two buttons can be emulated with &lt;code&gt;gvim&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that clicking the + button would increase the font size by one step.&#xA;The - button does just the opposite.&lt;/p&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="205" LastEditDate="2016-02-14T18:55:54.770" LastActivityDate="2021-09-25T12:33:34.313" Title="How do I create buttons on the toolbar to increase and decrease font size?" Tags="|gvim|font|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6479" PostTypeId="1" AcceptedAnswerId="6542" CreationDate="2016-02-15T09:29:29.323" Score="8" ViewCount="279" Body="&lt;p&gt;Rumor has reached me that it is possible to place &lt;code&gt;vim&lt;/code&gt; commands in the first five, or in the last five lines of a a file. But, I could not find this in Google. Any leads would be appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if it would be possible to employ this feature to define file specific additions to the word list. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&#xA;Thanks! The &lt;code&gt;modeline&lt;/code&gt; it is! Can it be used for spell checking in the manner suggested?&lt;/p&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="5919" LastEditDate="2016-02-15T10:36:24.350" LastActivityDate="2016-02-17T17:45:36.623" Title="The first and last 5 lines of a file? Use for file specific spell ignore list?" Tags="|autocmd|filetype|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6480" PostTypeId="1" AcceptedAnswerId="6481" CreationDate="2016-02-15T13:09:12.573" Score="8" ViewCount="1210" Body="&lt;p&gt;I have the text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var1=a&#xA;var2=aaa&#xA;var3=aaaaaa&#xA;&#xA;some text... &quot;&quot; ...&#xA;some text... &quot;&quot; ...&#xA;some text... &quot;&quot; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to paste the &lt;code&gt;a&lt;/code&gt;-part of the top 3 lines into the quotes in the last 3 line. The result should look like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some text... &quot;a&quot; ...&#xA;some text... &quot;aaa&quot; ...&#xA;some text... &quot;aaaaaa&quot; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now using Vim block selection &lt;kbd&gt;Ctrl+V&lt;/kbd&gt;, selecting block of &lt;code&gt;a&lt;/code&gt; til the end of each line using &lt;kbd&gt;$&lt;/kbd&gt; and then pasting it into the first &lt;code&gt;&quot;&quot;&lt;/code&gt; gives me the wrong result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some text... &quot;a     &quot; ...&#xA;some text... &quot;aaa   &quot; ...&#xA;some text... &quot;aaaaaa&quot; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, vim aligns pasted text by adding extra spaces, that I don't need in my case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why Vim inserting those spaces and how can I paste my block without those extra spaces get added?&lt;/p&gt;&#xA;" OwnerUserId="3230" LastActivityDate="2016-02-15T19:18:36.267" Title="Avoid extra spaces while pasting block with different line lengths" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6481" PostTypeId="2" ParentId="6480" CreationDate="2016-02-15T13:42:16.367" Score="4" Body="&lt;p&gt;Unfortunately, that's the standard behaviour, as far as I know. &lt;a href=&quot;https://stackoverflow.com/a/16943077/4113789&quot;&gt;As detailed in this answer&lt;/a&gt;, if you check the contents of your registers via &lt;code&gt;:reg&lt;/code&gt;, you'll see the whitespaces between linebreaks and text.&lt;/p&gt;&#xA;" OwnerUserId="4932" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-02-15T13:42:16.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6483" PostTypeId="1" CreationDate="2016-02-15T14:23:30.540" Score="8" ViewCount="649" Body="&lt;p&gt;Paragraphs are delimited by empty lines, both in vim and tex, but sometimes I wish vim to treat an entity as a paragraph and not tex. Can I, e.g., make vim treat lines containing only a &quot;%&quot; as a paragraph delimiter?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2016-04-17T11:49:00.897" LastActivityDate="2018-05-14T22:50:29.620" Title="Can I add a custom paragraph delimiter?" Tags="|cursor-motions|" AnswerCount="1" CommentCount="12" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6484" PostTypeId="1" CreationDate="2016-02-15T15:13:22.343" Score="2" ViewCount="192" Body="&lt;p&gt;I've started using&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set formatprg=par\ 66q\ g1\ j &quot; keep double spaces, justify&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which makes beautifully justified paragraphs.  But it would be better if the algorithm preferred to pad after .:;, in that order.  Perhaps some such algo. exists?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-02-15T15:13:22.343" Title="Formatting with par, better padding" Tags="|formatting|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6485" PostTypeId="1" AcceptedAnswerId="6488" CreationDate="2016-02-15T17:19:28.097" Score="4" ViewCount="2468" Body="&lt;p&gt;Referencing Post:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/22206332/vim-ag-search-and-replace-globally-and-within-a-directory&quot;&gt;https://stackoverflow.com/questions/22206332/vim-ag-search-and-replace-globally-and-within-a-directory&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Ag foo&#xA;:Qfdo s/foo/bar/c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I type &lt;code&gt;Ag miwt-os&lt;/code&gt;, I get this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OATJb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OATJb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which is the terminal, and I am lost her, how do I now get the results into the quckfix to run it through Qfdo?&lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-02-16T16:11:19.783" Title="Project Wide replace using Ag" Tags="|search|the-silver-searcher|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6486" PostTypeId="2" ParentId="6452" CreationDate="2016-02-15T18:28:22.903" Score="1" Body="&lt;p&gt;You can always try to use the operating system...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r ! perl -E 'for(A..Z){say &quot;$_ = mapping[&quot;, ord($_)-64 ,&quot;]&quot;}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3002" LastActivityDate="2016-02-15T18:28:22.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6487" PostTypeId="2" ParentId="6485" CreationDate="2016-02-15T18:39:52.747" Score="3" Body="&lt;p&gt;It looks like you have to &lt;code&gt;:AgAdd&lt;/code&gt; instead of just &lt;code&gt;Ag&lt;/code&gt;, which will add the results to quick links.&lt;/p&gt;&#xA;" OwnerUserId="3050" LastActivityDate="2016-02-15T18:39:52.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6488" PostTypeId="2" ParentId="6485" CreationDate="2016-02-15T19:42:03.353" Score="6" Body="&lt;p&gt;You don't need a plugin for using The Silver Searcher — or any other grep alternative — in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set grepprg=ag\ --nogroup\ --nocolor\ --ignore-case\ --column\ --vimgrep&#xA;set grepformat=%f:%l:%c:%m,%f:%l:%m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With those lines in your &lt;code&gt;vimrc&lt;/code&gt; you can simply do &lt;code&gt;:grep miwt-os&lt;/code&gt; to populate the quickfix list with matching lines or &lt;code&gt;:lgrep miwt-os&lt;/code&gt; to populate the location list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there you can open the quickfix/location window with either &lt;code&gt;:cw&lt;/code&gt; or &lt;code&gt;:lw&lt;/code&gt; to take a look at the list before going further or directly use &lt;code&gt;:Qfdo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the quickfix/location window to be opened automatically, add these lines to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup quickfix&#xA;    autocmd!&#xA;    autocmd QuickFixCmdPost [^l]* cwindow&#xA;    autocmd QuickFixCmdPost l*    lwindow&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-02-15T20:01:17.627" LastActivityDate="2016-02-15T20:01:17.627" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6489" PostTypeId="1" CreationDate="2016-02-15T19:48:43.087" Score="2" ViewCount="68" Body="&lt;p&gt;German nouns are normally spelt w/ a capital first letter, but can I make the spell checker stop caring about that? &lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-02-16T07:42:41.780" Title="Can I set German spell checking to ignore the case of nouns?" Tags="|spell-checking|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6490" PostTypeId="1" CreationDate="2016-02-15T20:15:47.923" Score="8" ViewCount="1211" Body="&lt;p&gt;I normally work with 2 windows, vertically split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I would like to solve, is: &lt;em&gt;easily jumping back and forth from header &amp;lt;-&gt; implementation file&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm investigating, without luck, 2 ways to do this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;em&gt;Open alternate file in &lt;strong&gt;current&lt;/strong&gt; window&lt;/em&gt;: There are many ways to do this, however, I can't find a way that remembers where I was in the previous file (i.e. jump to header, jump back, but not to the same place I was). &lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Open alternate file in the &lt;strong&gt;other&lt;/strong&gt; window&lt;/em&gt;: This is well-defined, since I only ever work with 2 windows, however I lack the vim-knowledge to do this.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6427" LastActivityDate="2016-02-16T19:39:09.580" Title="Switching .c/.h buffers" Tags="|vim-windows|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6491" PostTypeId="2" ParentId="6490" CreationDate="2016-02-15T20:59:10.413" Score="6" Body="&lt;p&gt;There's three main steps in accomplishing what you're asking:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;getting the alternate file's name&lt;/li&gt;&#xA;&lt;li&gt;opening that file in the current window or in another window as desired&lt;/li&gt;&#xA;&lt;li&gt;restoring cursor position within that file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To find the alternate file name you want to break the current file name into the &quot;root&quot; and the &quot;extension.&quot; A simple way to do this is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let parts = split(expand(&quot;%:p&quot;), &quot;[.]&quot;);&#xA;let root = parts[0]&#xA;let extension = parts[1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you know you're only ever switching between &lt;code&gt;.h&lt;/code&gt; and &lt;code&gt;.cpp&lt;/code&gt; files, you can change the extension from one to the other easily:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if extension == &quot;h&quot;&#xA;  let extension = &quot;cpp&quot;&#xA;else&#xA;  let extension = &quot;h&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, create a &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/37.html&quot;&gt;dictionary&lt;/a&gt; mapping known extensions to potentially valid alternate extensions. Or use &lt;code&gt;globpath()&lt;/code&gt; to get &lt;em&gt;all possible&lt;/em&gt; alternates for the current file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let alternates = globpath(expand(&quot;%:h&quot;), root . &quot;.*&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and pick the first one, or whatever. I prefer the &lt;code&gt;globpath&lt;/code&gt; approach, with some extra smarts I'll describe later. Once you have picked the target extension, form the full target path:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let target = root . &quot;.&quot; . alternates[whicheverAlternateExtensionYouWant]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can open the alternate file in the current window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;edit &quot; . target&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or use &lt;code&gt;winnr()&lt;/code&gt; to get the &quot;other window&quot; number (&lt;code&gt;winnr(&quot;#&quot;)&lt;/code&gt; is the window that &lt;code&gt;&amp;lt;C-W&amp;gt;p&lt;/code&gt; would jump to, or you can hard-code it if you know it will always be the same for your setup) and do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let window = winnr(&quot;#&quot;)&#xA;execute window . &quot;wincmd w&quot;&#xA;execute &quot;edit &quot; . target&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gives you a &lt;em&gt;really basic&lt;/em&gt; solution to opening alternate files. There's a few deficiencies with the above approach, since I wrote it to be straightforward and it's a bit off-the-cuff. I've written a &lt;a href=&quot;https://github.com/jpetrie/vim-counterpoint&quot;&gt;plugin&lt;/a&gt; that does alternate file switching &quot;the way I wanted,&quot; (cycling through all available &lt;code&gt;globpath()&lt;/code&gt; results). It addresses some of the problems with the simplicity of the above, you can check out its implementation if you're interested in exploring more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the &quot;restore cursor position&quot; point. I saved it for last since it's orthogonal to the alternate switching thing (my plugin doesn't handle it for example), but you could put it into your function if you're going to roll your own. &lt;code&gt;:help line()&lt;/code&gt; has an autocommand that is useful for restoring the cursor position to where it was when the file was last opened:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) | exe &quot;normal! g`\&quot;&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just put that, or something very similar, in my &lt;code&gt;.vimrc&lt;/code&gt; since I prefer the behavior all the time. You could easily just put the code elsewhere though.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2016-02-15T20:59:10.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6492" PostTypeId="1" CreationDate="2016-02-15T21:42:19.473" Score="2" ViewCount="23" Body="&lt;p&gt;I want to map &lt;code&gt;Ctrl-M&lt;/code&gt; to go to the last autocompletion word. Currently, &lt;code&gt;Ctrl-P&lt;/code&gt; does this. In my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-m&amp;gt; &amp;lt;c-p&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this adds the functionality I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I'm in &lt;em&gt;insert mode&lt;/em&gt; and hit &lt;code&gt;Enter&lt;/code&gt;, this also triggers the autocompletion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Happens in both macVim and CLI vim.&lt;/p&gt;&#xA;" OwnerDisplayName="user6428" LastEditorUserId="205" LastEditDate="2016-02-15T22:02:18.253" LastActivityDate="2016-02-15T22:02:18.253" Title="Remap last autocompletion word" Tags="|key-bindings|" AnswerCount="0" CommentCount="1" ClosedDate="2016-02-15T22:05:41.987" ContentLicense="CC BY-SA 3.0" />
  <row Id="6494" PostTypeId="2" ParentId="6485" CreationDate="2016-02-16T00:22:59.263" Score="1" Body="&lt;p&gt;But why you want to do this via Vim? It would be much easier to run &lt;code&gt;ag -l pattern | xargs -n1 sed 's/pattern/replacement/g&lt;/code&gt; in Your shell (or at least via &lt;code&gt;:!&lt;/code&gt;). &lt;/p&gt;&#xA;" OwnerUserId="1259" LastActivityDate="2016-02-16T00:22:59.263" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6495" PostTypeId="1" CreationDate="2016-02-16T06:15:57.660" Score="4" ViewCount="289" Body="&lt;p&gt;I have a folder with some input files (text files with extention &lt;code&gt;.in&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In same folder, I have made a Java program. I want to test the input of all the input files in this Java program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a GUI, I would just copy the text content in the input file and paste it in the console when I run my Java program, but I wonder if there is a really smart way to test the input files in the vim editor.&lt;/p&gt;&#xA;" OwnerUserId="6433" LastEditorUserId="54" LastEditDate="2016-02-16T08:19:01.870" LastActivityDate="2016-02-16T08:28:30.520" Title="Test `.in` files in Java program" Tags="|input-methods|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6496" PostTypeId="1" AcceptedAnswerId="6497" CreationDate="2016-02-16T06:39:52.113" Score="2" ViewCount="211" Body="&lt;p&gt;I have this in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $ROOTPATH=FindRootDirectory()&#xA;nnoremap &amp;lt;leader&amp;gt;ct :!clear&amp;lt;CR&amp;gt;:!$ROOTPATH/app/Console/cake test %:p&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can write this in one line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;a href=&quot;https://github.com/vim-scripts/vim-rooter&quot; rel=&quot;nofollow&quot;&gt;vim-rooter pluguin&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3302" LastActivityDate="2016-02-16T07:23:14.177" Title="How can I get path from vim-rooter's function and add it to another path VIM" Tags="|vimscript|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6497" PostTypeId="2" ParentId="6496" CreationDate="2016-02-16T07:04:36.267" Score="3" Body="&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;ct :exe &quot;!clear; &quot;.FindRootDirectory().&quot;/app/Console/cake test %:p&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key is the &lt;code&gt;:exe&lt;/code&gt; command, which executes its argument strings. In this case there is one argument string, which is the concatenation (&lt;code&gt;.&lt;/code&gt; operator) of &quot;!clear; &quot;, the output of the FindRootDirectory() function, and &quot;/app/Console/cake test %:p&quot;. The &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; terminates the mapping. I transformed the two shell commands into one, but you can use two commands if you prefer. See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2016-02-16T07:04:36.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6498" PostTypeId="2" ParentId="6496" CreationDate="2016-02-16T07:23:14.177" Score="3" Body="&lt;p&gt;An alternative to @garyjohn's answer is to use a map expression, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt;&amp;lt;leader&amp;gt;ct ':!clear&amp;lt;cr&amp;gt;:!' .&#xA;  \ FindRootDirectory() . '/app/Console/cake test ' . expand('%:p') . '&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; keyword for the mapping, the right-hand side is evaluated and it's result will be used as the mapping. In this case, the result is the concatanated string. See &lt;code&gt;:h map-expression&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-02-16T07:23:14.177" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6499" PostTypeId="2" ParentId="6489" CreationDate="2016-02-16T07:42:41.780" Score="2" Body="&lt;p&gt;No you cannot make the spellchecker take care of it. In fact, treating German nouns as lowercase would be an error.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-02-16T07:42:41.780" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6500" PostTypeId="1" AcceptedAnswerId="6518" CreationDate="2016-02-16T08:15:12.163" Score="8" ViewCount="100" Body="&lt;p&gt;I'm curious if it is possible to make a text object aware of its operator. In particular, I am writing a text object for LaTeX environments, where I want different behaviour depending on the operator. For instance, consider the following LaTeX snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{example}&#xA;  Hello world&#xA;\end{example}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here it is most convenient of &lt;code&gt;die&lt;/code&gt; deletes the content in a linewise fashion, whereas &lt;code&gt;cie&lt;/code&gt; deletes &quot;Hello world&quot;, but preserves the indentation, i.e., gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{example}&#xA;  |&#xA;\end{example}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;|&lt;/code&gt; is the cursor.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="1292" LastEditDate="2019-01-24T12:47:38.307" LastActivityDate="2019-01-24T12:47:38.307" Title="Define text object that depends on the current operator" Tags="|key-bindings|map-operator|custom-text-object|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6501" PostTypeId="2" ParentId="6495" CreationDate="2016-02-16T08:19:05.427" Score="5" Body="&lt;p&gt;Not really a job for Vim. Use make or a plain bash script to run your tests. You can use Vim's &lt;code&gt;:make&lt;/code&gt; integration to run the whole battery from the editor. &lt;code&gt;:help makeprg&lt;/code&gt; if you are not writing a Makefile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example &lt;code&gt;Makefile&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;test: *.in&#xA;&#xA;%.in: FORCE&#xA;    java MyProgram $@&#xA;&#xA;FORCE:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then a simple &lt;code&gt;:make&lt;/code&gt; (or &lt;code&gt;:make test&lt;/code&gt;, if you defined other rules) will suffice. If you don't want to make another file, you could do something ugly like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set makeprg=bash\ -c\ 'for\ i\ in\ *.in;\ do\ java\ MyProgram\ $i;\ done'      &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(remember to escape every space, and triple-escape every vertical bar.) With this, again, &lt;code&gt;:make&lt;/code&gt; runs everything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really are asking for a Vim answer, I guess it would be something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r!ls *.in&#xA;:g/^/execute &quot;:!java MyProgram &quot;.getline(&quot;.&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4729" LastEditorUserId="4729" LastEditDate="2016-02-16T08:28:30.520" LastActivityDate="2016-02-16T08:28:30.520" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6502" PostTypeId="1" AcceptedAnswerId="6504" CreationDate="2016-02-16T08:58:09.647" Score="10" ViewCount="3563" Body="&lt;p&gt;Using CtrlP with &lt;strong&gt;GVim&lt;/strong&gt; I often need to open a file with the name from the system clipboard (on Windows). So my workflow should be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+P&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;{somehow paste name from the clipboard}&lt;/li&gt;&#xA;&lt;li&gt;Select file and open it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the CtrlP input line I tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+R&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt; - it didn't work. &lt;kbd&gt;Ctrl+R&lt;/kbd&gt; is remapped by CtrlP.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+Ins&lt;/kbd&gt; it inserts &lt;code&gt;&quot;+P&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The equivalent without CtrlP plugin would be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:e&lt;/code&gt; **/&lt;kbd&gt;Ctrl+R&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt;&lt;kbd&gt;TAB&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is, how can I paste into the CtrlP input line from the system clipboard?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; This is not a problem, if using vim within the console, where proprietary coping and pasting is implemented.&lt;/p&gt;&#xA;" OwnerUserId="3230" LastEditorUserId="3230" LastEditDate="2016-02-16T11:14:00.523" LastActivityDate="2016-02-16T11:14:00.523" Title="Paste from clipboard into CtrlP input in GVim" Tags="|gvim|plugin-ctrlp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6503" PostTypeId="2" ParentId="6150" CreationDate="2016-02-16T09:49:20.793" Score="3" Body="&lt;p&gt;What about using the &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:sy[ntax] match {group-name} [{options}] [excludenl] {pattern}&#xA;  [{options}]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi NewLineWin ctermfg=248 guifg=#999999&#xA;:syntax match NewLineWin /\r\n/&#xA;:hi WhiteSpaceChar ctermfg=252 guifg=#999999&#xA;:syntax match WhiteSpaceChar / /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use any number of such match...&lt;/p&gt;&#xA;" OwnerUserId="4502" LastActivityDate="2016-02-16T09:49:20.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6504" PostTypeId="2" ParentId="6502" CreationDate="2016-02-16T10:00:21.470" Score="14" Body="&lt;p&gt;You can paste from any register (including the clipboard) into CtrlP, as explained in &lt;code&gt;:help ctrlp-pasting&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &amp;lt;Insert&amp;gt;,                                                   *'ctrlp-pasting'*&#xA;  &amp;lt;MiddleMouse&amp;gt;&#xA;    Paste the clipboard content into the prompt.&#xA;&#xA;  &amp;lt;c-\&amp;gt;&#xA;    Open a console dialog to paste &amp;lt;cword&amp;gt;, &amp;lt;cfile&amp;gt;, the content of the search&#xA;    register, the last visual selection, the clipboard or any register into the&#xA;    prompt.&#xA;&#xA;Choose your own mappings with |g:ctrlp_prompt_mappings|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the default mappings you should type &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;\&lt;/kbd&gt; followed by &lt;kbd&gt;c&lt;/kbd&gt; (the 'c' appears on the input prompt for clipboard).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another options are to use the &lt;kbd&gt;Insert&lt;/kbd&gt; key or the middle mouse button.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-02-16T11:03:55.220" LastActivityDate="2016-02-16T11:03:55.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6505" PostTypeId="1" AcceptedAnswerId="6506" CreationDate="2016-02-16T10:03:34.020" Score="6" ViewCount="1265" Body="&lt;p&gt;I'm trying to cut string returned from fugitive plugin. It returns branch name of current file. By default returned string is &lt;code&gt;Git(branchname)&lt;/code&gt; and this is why I want to get rid of odd &lt;code&gt;Git(..)&lt;/code&gt; wrapper. So here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;set statusline+=%{strpart(fugitive#statusline(), 4, 1)}&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I update &lt;code&gt;.vimrc&lt;/code&gt; it returns error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E540: Unclosed expression sequence: statusline+=%{strpart(fugitive#statusline(), &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What do I wrong?&lt;/p&gt;&#xA;" OwnerUserId="5321" LastActivityDate="2016-02-16T11:11:38.110" Title="How to cut/trim line in statusline?" Tags="|vimscript|vimrc|statusline|error|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6506" PostTypeId="2" ParentId="6505" CreationDate="2016-02-16T10:16:31.410" Score="8" Body="&lt;p&gt;Values used in &lt;code&gt;:set&lt;/code&gt; are strings. See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%3Aset-args&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h set-args&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                :set-args E487 E521&#xA;:se[t] {option}={value}         or&#xA;:se[t] {option}:{value}&#xA;                        Set string or number option to {value}.&#xA;                        ...&#xA;                        White space between {option} and '=' is allowed and&#xA;                        will be ignored.  White space between '=' and {value}&#xA;                        is not allowed.&#xA;                        See option-backslash for using white space and&#xA;                        backslashes in {value}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should escape the spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{strpart(fugitive#statusline(),\ 4,\ 1)}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Consider the example from the help for &lt;a href=&quot;https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt#L339&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;fugitive#statusline&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%&amp;lt;%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note how all the spaces (all two of them, anyway) are escaped.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Aside:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;strpart(x, 4, 1)&lt;/code&gt; is a single character, which is probably not what you wanted. &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Asplit&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;split()&lt;/code&gt;&lt;/a&gt; might be more useful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo strpart(fugitive#statusline(),4,1)&#xA;(&#xA;:echo split(fugitive#statusline(), '[()]')[1]&#xA;master&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, you probably want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{remove(split(fugitive#statusline(),'[()]'),1)}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will error out outside git repositories. It might better to write a small function at this point:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Current_git_branch()&#xA;    let l:branch = split(fugitive#statusline(),'[()]')&#xA;    if len(l:branch) &amp;gt; 1&#xA;         return remove(l:branch, 1)&#xA;    endif&#xA;    return &quot;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{Current_git_branch()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-02-16T11:11:38.110" LastActivityDate="2016-02-16T11:11:38.110" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6507" PostTypeId="1" AcceptedAnswerId="7742" CreationDate="2016-02-16T10:58:43.347" Score="4" ViewCount="721" Body="&lt;p&gt;Thanks to &lt;a href=&quot;https://vi.stackexchange.com/questions/6448/how-do-i-run-cakephps-tests-phpunit-and-output-it-to-quickrun-or-other-window/6450#6450&quot;&gt;@muru&lt;/a&gt; I was able to run and output the data to QuickRun by the &lt;code&gt;:make&lt;/code&gt; command and this setting in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set makeprg=/vagrant/my_project/app/Console/cake\ test\ app\ Console/Command/FeedParseShell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I have to press &lt;code&gt;Enter&lt;/code&gt; several times to get back to the &lt;code&gt;vim&lt;/code&gt; editor and open the output by typing &lt;code&gt;:copen&lt;/code&gt;. Is there a way to skip this steps and get the output without typing &lt;code&gt;:copen&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3302" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-01-06T15:21:46.483" Title="How to run custom console command and output results to QuickRun without pressing any key on keyboard?" Tags="|vimscript|vimrc|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6508" PostTypeId="1" AcceptedAnswerId="6509" CreationDate="2016-02-16T11:13:09.953" Score="1" ViewCount="462" Body="&lt;p&gt;How can I run vim-rooter's function &lt;code&gt;FindRootDirectory()&lt;/code&gt; instead of &lt;code&gt;/vagrant/my_project&lt;/code&gt;? I have tried multiple variations like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set makeprg=FindRootDirectory().'/app/Console/cake test '.expand('%:p')&#xA;set makeprg=FindRootDirectory().&quot;/app/Console/cake&quot; test %:p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;+++UPDATE+++&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let &amp;amp;makeprg=FindRootDirectory().&quot;/app/Console/cake test %:p&quot;&lt;/code&gt; does work, but I'm also getting a black screen instead of my previous opened file. Do you know how can I get only results in the bottom?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I'm getting this errors after running the &lt;code&gt;vim&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E117: 未知の関数です(Unknown function): FindRootDirectory&#xA;E15: 無効な式です(Invalid expression): FindRootDirectory().&quot;/app/Console/cake test %:p&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;+++UPDATE+++&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Was able to solve it by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * let &amp;amp;makeprg=FindRootDirectory().&quot;/app/Console/cake test %:p&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3302" LastEditorUserId="3302" LastEditDate="2016-02-25T03:43:57.327" LastActivityDate="2016-02-25T03:43:57.327" Title="How can I get path from vim-rooter's function and run it with QuickRun's makeprg?" Tags="|vimscript|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6509" PostTypeId="2" ParentId="6508" CreationDate="2016-02-16T11:43:22.030" Score="6" Body="&lt;p&gt;Use &lt;code&gt;:let &amp;amp;makeprg&lt;/code&gt; instead of &lt;code&gt;:set&lt;/code&gt;. The latter expects an un-quoted string.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="205" LastEditDate="2016-02-16T18:12:09.140" LastActivityDate="2016-02-16T18:12:09.140" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6510" PostTypeId="2" ParentId="3681" CreationDate="2016-02-16T12:49:38.830" Score="1" Body="&lt;p&gt;This plugin, &lt;strong&gt;gvimt&lt;/strong&gt;, &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4214&quot; rel=&quot;nofollow&quot;&gt;http://www.vim.org/scripts/script.php?script_id=4214&lt;/a&gt; gives you various options on the Windows right-click/Context menu, the SendTo menu (for those cases where you aren't allowed to edit the registry) and the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It lets you do these things with the files you specify:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Edit with Vim Tab&quot; (open each in a new tab)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Edit with Vim VSplit&quot; (vertically split the existing tab for each)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Edit with Vim Split&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Edit with Vim VSplit Tab&quot; (open a new tab first, then open all the files &#xA;you selected vertically split within it)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Edit with Vim Split Tab&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default it won't let you do it just by pressing [Enter], but since the actions appear on the Context menu I believe you could change the default action for text files to be whichever you liked.  I have not attempted this.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It's based on the methods discussed on the Vim wiki ( &lt;a href=&quot;http://vim.wikia.com/wiki/Launch_files_in_new_tabs_under_Windows&quot; rel=&quot;nofollow&quot;&gt;http://vim.wikia.com/wiki/Launch_files_in_new_tabs_under_Windows&lt;/a&gt; , this is the same link discussed in mjturner's answer ) but addresses some problems I had with those methods:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There is no --remote-split parameter so a different approach is needed for opening files in a new split window.  --remote-send can be used to send an arbitary command for this, but unlike --remote-tab it will not open a new instance of gvim if one doesn't already exist.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you select multiple files and use the Windows Context menu, each file gets its own invocation of the command.  gvim does not handle several simultaneous --remote-tab commands well.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The SendTo menu does pass all the selected files to one command, but it is an extra click on the right menu to get there, so it is nice to use the Context menu.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5698" LastActivityDate="2016-02-16T12:49:38.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6511" PostTypeId="1" AcceptedAnswerId="6519" CreationDate="2016-02-16T12:54:34.667" Score="8" ViewCount="1160" Body="&lt;p&gt;There are several times, I need to &lt;code&gt;grep&lt;/code&gt; for &lt;code&gt;some_pattern&lt;/code&gt; in some &lt;code&gt;XHTML&lt;/code&gt; files (many a time, file count in a specified folder goes beyond 10K+).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Previously, I have used &lt;a href=&quot;http://www.lugaru.com/&quot; rel=&quot;noreferrer&quot;&gt;Lugaru's Epsilon Programmer's Editor&lt;/a&gt; and there was &lt;code&gt;grep&lt;/code&gt; command which invokes the search, and results a list of all matched lines in a &lt;code&gt;grep-buffer&lt;/code&gt;. Afterwards, a user can use commands (like &lt;code&gt;keep-matching-lines&lt;/code&gt;, &lt;code&gt;delete-matching-lines&lt;/code&gt;, &lt;code&gt;sort-lines&lt;/code&gt;, &lt;code&gt;uniq&lt;/code&gt; etc.) on the &lt;code&gt;grep-buffer&lt;/code&gt;. Since, the &lt;code&gt;grep-buffer&lt;/code&gt; is editable, it is possible to post-process and mold the grep-result to desirable format as required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, that was weeks ago! This time, I have started to use Vim as my full-time editor. I am trying to quit all possible habits those are becoming obstacles to learning Vim. So, right now whenever I need to get such a search list, I am trying the same, in following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cd d:\test_files\&#xA;:cex [] | vimgrep /pattern/ *.xhtml&#xA;:cope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, this servers my purpose well, except that the buffer remains in &lt;code&gt;RO&lt;/code&gt; mode. So, every time it requires special post-editing process, I need to prepare a replica for the &lt;code&gt;quickfix-window&lt;/code&gt; and then do as required. The &lt;code&gt;quickfix-window&lt;/code&gt; is always uneditable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to make the &lt;code&gt;quickfix-window&lt;/code&gt; editable? I know the result can be post-processed with some other commands in a single line, but I do need to view all the search list as whole and only then can I judge what the next steps should be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any tweak that can be applied in the &lt;code&gt;vimrc&lt;/code&gt;? Am I missing something? Pointing out my error or any other approach to get job done, is greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5912" LastEditorUserId="205" LastEditDate="2016-02-16T18:10:58.077" LastActivityDate="2018-08-25T12:09:57.600" Title="How do I make list of search results editable?" Tags="|search|quickfix|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6512" PostTypeId="1" AcceptedAnswerId="6516" CreationDate="2016-02-16T15:38:05.127" Score="10" ViewCount="1720" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/tpope/vim-markdown&quot; rel=&quot;noreferrer&quot;&gt;tpope's vim-markdown plugin&lt;/a&gt; to edit markdown files. Somehow, neovim &lt;strong&gt;hides&lt;/strong&gt; the &lt;code&gt;_&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; chars and changes the text in between to italic or bold depending on quantity of chars.  I want to see these chars. How do I configure neovim or vim-markdown to &lt;strong&gt;not hide&lt;/strong&gt; the chars? (note, I looked for vim-markdown help and there is none)&lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="205" LastEditDate="2016-02-17T14:23:15.933" LastActivityDate="2016-04-26T15:37:59.597" Title="NeoVim hides the * chars when editing markdown" Tags="|neovim|filetype-markdown|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6513" PostTypeId="2" ParentId="6490" CreationDate="2016-02-16T15:58:53.890" Score="1" Body="&lt;p&gt;In your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; =====[ Remap to change windows quickly ]=============================&#xA;:nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-H&amp;gt; :wincmd h&amp;lt;CR&amp;gt;&#xA;:nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-J&amp;gt; :wincmd j&amp;lt;CR&amp;gt;&#xA;:nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-K&amp;gt; :wincmd k&amp;lt;CR&amp;gt;&#xA;:nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-L&amp;gt; :wincmd l&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows you to move between windows quickly, by simply using Ctrl and VIM direction keys from the home row.  The awesomeness of this, is you have one common way to jump to any window, including the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To quickly switch between header and source I use &lt;code&gt;vim-scripts/a.vim&lt;/code&gt; found here: &lt;a href=&quot;https://github.com/vim-scripts/a.vim&quot; rel=&quot;nofollow&quot;&gt;https://github.com/vim-scripts/a.vim&lt;/a&gt;, use &lt;code&gt;:A&lt;/code&gt; command to toggle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Side Note =&gt; If you use tmux, you can use &lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator&quot; rel=&quot;nofollow&quot;&gt;https://github.com/christoomey/vim-tmux-navigator&lt;/a&gt; to jump between vim or nvim windows and a terminal seamlessly.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="3050" LastActivityDate="2016-02-16T15:58:53.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6514" PostTypeId="2" ParentId="6485" CreationDate="2016-02-16T16:11:19.783" Score="3" Body="&lt;p&gt;Use macros to do what you want. Start at the first replacement, &lt;code&gt;:cr&lt;/code&gt;, then... (Comments just for description.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qbq &quot; clear b register&#xA;qa &quot; start recording macro a&#xA;:s/old text/new text/&#xA;:cn&#xA;q &quot; end macro&#xA;qb@a@bq &quot; create macro b to call macro a then itself&#xA;@b &quot; launch macro b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Watch it tear through your project.&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-16T16:11:19.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6516" PostTypeId="2" ParentId="6512" CreationDate="2016-02-16T16:25:03.183" Score="15" Body="&lt;p&gt;Those chars are hidden because the &lt;code&gt;conceal&lt;/code&gt; feature as you can see on the vim-markdown &lt;a href=&quot;https://github.com/tpope/vim-markdown/blob/63074a52/syntax/markdown.vim#L84-L90&quot;&gt;source&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can adjust how to this feature is applied to text using the option &lt;a href=&quot;https://neovim.io/doc/user/options.html#&amp;#39;conceallevel&amp;#39;&quot;&gt;&lt;code&gt;conceallevel&lt;/code&gt;&lt;/a&gt;. Setting it to &lt;code&gt;0&lt;/code&gt; will always show the text.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set conceallevel=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1453" LastEditorUserId="64" LastEditDate="2016-02-16T16:38:33.423" LastActivityDate="2016-02-16T16:38:33.423" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6517" PostTypeId="2" ParentId="6490" CreationDate="2016-02-16T16:36:52.567" Score="3" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://github.com/derekwyatt/vim-fswitch&quot; rel=&quot;nofollow&quot;&gt;vim-fswitch&lt;/a&gt; plugin together with the following configuration in your &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au! BufEnter *.cpp,*.cc,*.c let b:fswitchdst = 'h,hpp'    | let b:fswitchlocs = 'reg:/src/include/,../include,./'&#xA;au! BufEnter *.h,*.hpp      let b:fswitchdst = 'cpp,cc,c' | let b:fswitchlocs = 'reg:/include/src/,../src,./'&#xA;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;s :FSHere&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you type &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3CLeader%3E&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;&lt;/a&gt; (which is &lt;code&gt;\&lt;/code&gt; by default) followed by &lt;code&gt;s&lt;/code&gt; in a &lt;code&gt;.hpp&lt;/code&gt; or &lt;code&gt;.h&lt;/code&gt; file, the plugin will check if a matching &lt;code&gt;.cpp&lt;/code&gt;, &lt;code&gt;.cc&lt;/code&gt; or &lt;code&gt;.c&lt;/code&gt; file exists:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;by replacing &lt;code&gt;include&lt;/code&gt; by &lt;code&gt;src&lt;/code&gt; in the current file's path&lt;/li&gt;&#xA;&lt;li&gt;by looking in the &lt;code&gt;src&lt;/code&gt; folder above the current file&lt;/li&gt;&#xA;&lt;li&gt;by looking in the current file's folder&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are more options you could use to fit your project better in the &lt;a href=&quot;https://github.com/derekwyatt/vim-fswitch/blob/master/doc/fswitch.txt#L106&quot; rel=&quot;nofollow&quot;&gt;documentation&lt;/a&gt;. It'll take you a few minutes but once you'll get it right you should love it. I personally find it very flexible and extensible, plus it works just as well for many kinds of files (.m, .h, .inl etc...).&lt;/p&gt;&#xA;" OwnerUserId="6442" LastEditorUserId="205" LastEditDate="2016-02-16T18:18:34.977" LastActivityDate="2016-02-16T18:18:34.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6518" PostTypeId="2" ParentId="6500" CreationDate="2016-02-16T17:54:04.707" Score="5" Body="&lt;p&gt;The following example comes close to what you are asking for: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;expr&amp;gt; w '&amp;lt;esc&amp;gt;' . v:operator . v:count1 . (v:operator ==# 'd' ? 'aw' : 'iw')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It creates a textobject &lt;code&gt;w&lt;/code&gt; that is either &lt;code&gt;aw&lt;/code&gt;, in case it is used by the delete operator, that is, &lt;code&gt;dw&lt;/code&gt; = &lt;code&gt;daw&lt;/code&gt;, or &lt;code&gt;iw&lt;/code&gt; otherwise, for example &lt;code&gt;cw&lt;/code&gt; = &lt;code&gt;ciw&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6416" LastActivityDate="2016-02-16T17:54:04.707" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6519" PostTypeId="2" ParentId="6511" CreationDate="2016-02-16T19:00:44.473" Score="5" Body="&lt;p&gt;You definitively should try the plugin &lt;a href=&quot;https://github.com/sk1418/QFGrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;QFGrep plugin&lt;/a&gt;, which was created after the similar question mentioned in the comments: &lt;a href=&quot;https://stackoverflow.com/questions/15406138/is-it-possible-to-grep-vim%ca%bcs-quickfix&quot;&gt;Is it possible to grep Vimʼs quickfix?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been using it for a year and a half, and it works very well. It allows to grep (and reverse grep) the quickfix results, and also allows to restore the original contents. Check plugin homepage, which has &lt;a href=&quot;https://github.com/sk1418/QFGrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;a nice animated gif&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-02-16T19:00:44.473" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6520" PostTypeId="2" ParentId="6490" CreationDate="2016-02-16T19:39:09.580" Score="1" Body="&lt;p&gt;I'll just share my super quick&amp;amp;dirty version...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set up my mappings; alt-o opens the related file in the same window, alt-shift-o opens in a split...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;A-o&amp;gt; :call EditRelatedFile()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;A-O&amp;gt; :call SplitRelatedFile()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I have a function that gets the list of related files. I've been meaning to tweak it to chop the filename at the first dot rather than the last but that's still an exercise for the reader.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetRelatedFileList()&#xA;    &quot; This function may be overloaded in a site-specific vimrc.&#xA;    let l:thisPath = expand(&quot;%:p:r&quot;) . '.*'&#xA;    let l:files = glob(l:thisPath)&#xA;&#xA;    return split(l:files, '[\r\n]\+')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My .vimrc setup is sometimes specialized per client; some have source and includes in separate folder hierarchies, some have them together. By default I assume they're all nearby but if I need to hunt I'll provide a replacement function like this one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Override the basic GetRelatedFileList coming from vimrc.&#xA;function! GetRelatedFileList()&#xA;    let l:thisDir = expand(&quot;%:p:h:t&quot;)&#xA;    if (l:thisDir ==? &quot;src&quot;) || (l:thisDir ==? &quot;include&quot;)&#xA;        let l:thisPath = expand(&quot;%:p:h:h&quot;)&#xA;        let l:searchPaths = l:thisPath.'/include,' . l:thisPath.'/src'&#xA;        let l:thisBase = expand(&quot;%:t:r&quot;) . '.*'&#xA;        let l:files = globpath(l:searchPaths, l:thisBase)&#xA;    else&#xA;        let l:thisPath = expand(&quot;%:p:r&quot;) . '.*'&#xA;        let l:files = glob(l:thisPath)&#xA;    endif&#xA;&#xA;    return split(l:files, '[\r\n]\+')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I look through that list of files to find the current buffer's file and go to the next one in the list. It's not often as simple as a .cpp/.h pair, often I'll have other things that need to be considered.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetNextRelatedFile()&#xA;    let l:fileList = GetRelatedFileList()&#xA;&#xA;    let l:thisFile = expand(&quot;%:p&quot;)&#xA;    let l:index = index(l:fileList, l:thisFile) + 1&#xA;&#xA;    if l:index &amp;gt;= len(l:fileList)&#xA;        let l:index = 0&#xA;    endif&#xA;&#xA;    return l:fileList[l:index]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then finally the two functions that either open in the current window or do a split...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EditRelatedFile()&#xA;    let l:file = GetNextRelatedFile()&#xA;    execute &quot;edit&quot; l:file&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My splitting version always puts .cpp and .c files in a below split, otherwise split default (which in my case is above).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SplitRelatedFile()&#xA;    let l:file = GetNextRelatedFile()&#xA;    let l:ext = fnamemodify(l:file, &quot;:e&quot;)&#xA;    if (l:ext ==? &quot;cpp&quot;) || (l:ext ==? &quot;c&quot;)&#xA;        execute &quot;below split&quot; l:file&#xA;    else&#xA;        execute &quot;split&quot; l:file&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-16T19:39:09.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6521" PostTypeId="2" ParentId="6459" CreationDate="2016-02-16T19:48:51.233" Score="5" Body="&lt;p&gt;These are to move to the top and bottom of functions, where the assumption is that functions' opening and closing braces are always in the first column. (Editorial: this seems to not often be the case these days so these motions will be vestigial for many users.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The leading &lt;code&gt;[&lt;/code&gt; or &lt;code&gt;]&lt;/code&gt; indicate the direction you're going to go in the file, up or down respectively. Then the second &lt;code&gt;[&lt;/code&gt; or &lt;code&gt;]&lt;/code&gt; means to either go to an open brace at the function prologue or the close brace at the function epilogue; if it matches the leading character you go to the open brace, if it is different from the leading character you go to the close brace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt; quite regularly although I'd normally prefer to be put on the function definition. To me &lt;code&gt;[]&lt;/code&gt; and &lt;code&gt;][&lt;/code&gt; are non-intuitive while editing and I never use them; I wish I could figure out how to make them work in my brain because this is an operation I often accomplish via other means (e.g. the &lt;code&gt;a}&lt;/code&gt; motion often covers me).&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-16T19:48:51.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6522" PostTypeId="2" ParentId="6459" CreationDate="2016-02-16T19:50:03.293" Score="6" Body="&lt;p&gt;It helps to test these out on a file. You can think of these as &quot;forward&quot; and &quot;backward&quot; X &quot;to start&quot; and &quot;to end&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try using the four motions on this block of text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function one&#xA;{#1&#xA;&#xA;}#2&#xA;&#xA;function two&#xA;{#3&#xA;&#xA;}#4&#xA;&#xA;function three&#xA;{#5&#xA;&#xA;}#6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know how to do those often helpful movement gifs, but basically e.g. &lt;code&gt;]]&lt;/code&gt; &lt;code&gt;]]&lt;/code&gt; &lt;code&gt;]]&lt;/code&gt; will move from positions #1-&gt;3-&gt;5, and &lt;code&gt;[[&lt;/code&gt; in reverse; similarly move among #2&amp;lt;-&gt;4&amp;lt;-&gt;6 using the &lt;code&gt;][&lt;/code&gt; and &lt;code&gt;[]&lt;/code&gt; motions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a picture:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/MCJoA.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MCJoA.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4985" LastEditorUserId="4939" LastEditDate="2016-02-17T10:13:01.427" LastActivityDate="2016-02-17T10:13:01.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6523" PostTypeId="1" CreationDate="2016-02-16T20:46:37.193" Score="2" ViewCount="428" Body="&lt;p&gt;I installed the &lt;strong&gt;YouCompleteMe&lt;/strong&gt;(&lt;em&gt;YCM&lt;/em&gt;) plugin and compiled it using the provided instructions, one after the other for all options excluding rust. Below is a reproduction of the commands I ran, the reason for running one after the other is that I got an error running them all together and it was easier to read when doing one by one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe&#xA;python install.py --clang-completer  &#xA;python install.py --omnisharp-completer&#xA;python install.py --gocode-completer&#xA;python install.py --tern-completer &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These ran, then I restarted my system due to another issue(was installing driver updates) when I then started GVim it crashed. I can open vim in the shell but it doesn't recognize Vundle and none of the plugins it manages are working there. I don't know if that was the case before, I haven't been using the shell for editing on Windows 10. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Please advise!&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Response to comments&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;fruglemonkey&lt;/em&gt; - It was not configured for use on Windows, it was sourcing the .vimrc while I had opted to use the _vimrc purely for separation of concerns(keep the .vimrc for *nix environments and _ for windows) I copied the _vimrc to .vimrc and Vundle now works, though it doesn't recognise the colour scheme in use. I presume it isn't sourcing from the vim directory that GVim is using is all. Even now that it's sourcing properly it isn't recognizing Gundo or anything. I don't think it's related to the crashing of GVim, but I can provide more information regarding this on request. &lt;/p&gt;&#xA;" OwnerUserId="6446" LastEditorUserId="6452" LastEditDate="2016-02-17T16:13:48.727" LastActivityDate="2016-02-17T16:13:48.727" Title="gvim on windows - compiled ycm plugin now crashing on start" Tags="|gvim|microsoft-windows|plugin-you-complete-me|crash|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6524" PostTypeId="2" ParentId="6478" CreationDate="2016-02-16T20:59:47.237" Score="6" Body="&lt;p&gt;I think something along the following lines should work:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;anoremenu ToolBar.Builtin#31   :let &amp;amp;guifont=substitute(&amp;amp;guifont, '\(\d\+\)', '\=submatch(1)+1', '')&amp;lt;cr&amp;gt;&#xA;anoremenu ToolBar.Builtin#32   :let &amp;amp;guifont=substitute(&amp;amp;guifont, '\(\d\+\)', '\=submatch(1)-1', '')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now, to include nice icons, you simply need to add the icon argument.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="30440" LastEditDate="2021-09-25T12:33:34.313" LastActivityDate="2021-09-25T12:33:34.313" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="6525" PostTypeId="1" AcceptedAnswerId="6529" CreationDate="2016-02-16T23:46:49.077" Score="9" ViewCount="4034" Body="&lt;p&gt;I have a number of lines in a file, and I would like to copy each line 11 times (turning each line into 12 lines), and increment the last &quot;1&quot; in each line so that the 12 lines have &quot;1&quot; through &quot;12&quot;, where the &quot;1&quot; initially was. There may be other occurrences of &quot;1&quot; in each line, but the &quot;1&quot; I want to increment will always be the last occurrence in each line. Another way to look at it is that the last &quot;1&quot; is always after &quot;/nt/&quot; - as in &quot;/nt/1&quot; (and it will always be the only occurrence of &quot;/nt/1&quot; in each line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for example, if I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1stlineblahblahblah/nt/1blah&#xA;2ndlineblahblahblah/nt/1blah&#xA;3rdlineblahblahblah/nt/1blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to turn it into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1stlineblahblahblah/nt/1blah&#xA;1stlineblahblahblah/nt/2blah&#xA;1stlineblahblahblah/nt/3blah&#xA;1stlineblahblahblah/nt/4blah&#xA;1stlineblahblahblah/nt/5blah&#xA;1stlineblahblahblah/nt/6blah&#xA;1stlineblahblahblah/nt/7blah&#xA;1stlineblahblahblah/nt/8blah&#xA;1stlineblahblahblah/nt/9blah&#xA;1stlineblahblahblah/nt/10blah&#xA;1stlineblahblahblah/nt/11blah&#xA;1stlineblahblahblah/nt/12blah&#xA;2ndlineblahblahblah/nt/1blah&#xA;2ndlineblahblahblah/nt/2blah&#xA;2ndlineblahblahblah/nt/3blah&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I had previously found the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:for i in range(0,12) | put ='1stlineblahblahblah/nt/'.i.'blah' | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works for this purpose, but I would have to manually run this command for each line, and type each line in (or copy-and paste it) myself. Is there a way to take the lines that are already in the file, and just run one command that turns each line into twelve, in the manner that I've described?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance to anyone who can help me with this. I also just wanted to note that this is my second question here, and I was pleased to have gotten several quick and effective solutions to my first question, for which I was most grateful.&lt;/p&gt;&#xA;" OwnerUserId="6195" LastEditorUserId="205" LastEditDate="2016-02-18T00:29:35.270" LastActivityDate="2016-02-19T11:40:41.457" Title="How to copy each line 11 times, incrementing the last &quot;1&quot; in each line from 2-12" Tags="|text-generation|enumerate|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6526" PostTypeId="2" ParentId="6525" CreationDate="2016-02-17T00:18:30.130" Score="10" Body="&lt;p&gt;You could do this by&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;recording a macro, then&lt;/li&gt;&#xA;&lt;li&gt;using the &lt;code&gt;global&lt;/code&gt; ex command to execute the macro &lt;em&gt;n&lt;/em&gt; number of times for each line in the file.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;After recording the macro, undo the changes done while recording, or there will be &lt;em&gt;n + 1&lt;/em&gt; additional lines for the first line, and &lt;em&gt;n&lt;/em&gt; for consecutive lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Record the macro to the &lt;code&gt;a&lt;/code&gt; register with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qayyp$?\d&amp;lt;CR&amp;gt;&amp;lt;C-A&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This records into register &lt;code&gt;a&lt;/code&gt; (&lt;code&gt;qa...q&lt;/code&gt;) the following command:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;yyp&lt;/code&gt;: duplicate the current line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt;: move to end of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;?\d&amp;lt;CR&amp;gt;&lt;/code&gt;: search backwards for a single digit&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-A&amp;gt;&lt;/code&gt;: increment digit under the cursor by one&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When the macro is recorded, remove the changes made while recording it either by undoing (&lt;code&gt;uu&lt;/code&gt;) or by deleting the current line (&lt;code&gt;dd&lt;/code&gt;). Then repeat the macro &lt;code&gt;11&lt;/code&gt; (or any number of) times for each line in the file with the global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g//normal 11@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="1306" LastEditDate="2016-02-17T09:17:45.597" LastActivityDate="2016-02-17T09:17:45.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6527" PostTypeId="2" ParentId="6525" CreationDate="2016-02-17T00:20:50.303" Score="5" Body="&lt;p&gt;I find it easiest to use macros for one-shot tasks like that. Just start recording a macro with &lt;code&gt;q&lt;/code&gt; + name of register and do the task once. I see one repeatable task here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Select the line&lt;/li&gt;&#xA;&lt;li&gt;yank&lt;/li&gt;&#xA;&lt;li&gt;paste (will put you in the next line)&lt;/li&gt;&#xA;&lt;li&gt;go to end of line&lt;/li&gt;&#xA;&lt;li&gt;go back one word&lt;/li&gt;&#xA;&lt;li&gt;increment by one&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now record the required keystrokes to register &lt;code&gt;a&lt;/code&gt;, in normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qayyp$b&amp;lt;c-a&amp;gt;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Delete the line again to test whether executing the macro 11 times yields the right result for one line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;11@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does! So lets undo again and automate the whole process in a second macro &lt;code&gt;b&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qb11@aj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can execute &lt;code&gt;@b&lt;/code&gt; until the end of the file and it should produce the output you want. It sounds complicated but it really isn't once you're used to the typical editing patterns.&lt;/p&gt;&#xA;" OwnerUserId="6337" LastEditorUserId="6337" LastEditDate="2016-02-17T08:08:33.327" LastActivityDate="2016-02-17T08:08:33.327" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6528" PostTypeId="2" ParentId="6525" CreationDate="2016-02-17T00:25:46.423" Score="6" Body="&lt;p&gt;Two ways:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a macro!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1stlineblahblahblah/nt/1blah&#xA;2ndlineblahblahblah/nt/1blah&#xA;3rdlineblahblahblah/nt/1blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With your cursor on the first line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqyyp$?\d&amp;lt;CR&amp;gt;&amp;lt;Ctrl-a&amp;gt;q&#xA;10@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which does:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;qq&lt;/code&gt;&#xA;Start recording a macro into the q register&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;yyp&lt;/code&gt; yank the current line, and paste it below&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$?\d&amp;lt;CR&amp;gt;&lt;/code&gt; Go to the end of the line, and find the first digit looking backwards &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;Ctrl-a&amp;gt;&lt;/code&gt; Increment the number&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;q&lt;/code&gt; Stop recording the macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This leaves you with: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1stlineblahblahblah/nt/1blah&#xA;1stlineblahblahblah/nt/2blah&#xA;2ndlineblahblahblah/nt/2blah&#xA;2ndlineblahblahblah/nt/3blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the cursor on the second line. Simply repeat this macro as many times as desired (For example, repeat it ten times with 10@q). If you want to automate this process for each line, execute it globally across each line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:g//normal 11@q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, with a newer version of vim: Paste the line you want however many times, visual block select the digit you want to increment, and press &lt;code&gt;g &amp;lt;Ctrl-a&amp;gt;&lt;/code&gt;. This should increment all the numbers in the visual block as you desire. This is a more manual process, however.&lt;/p&gt;&#xA;" OwnerUserId="4932" LastActivityDate="2016-02-17T00:25:46.423" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6529" PostTypeId="2" ParentId="6525" CreationDate="2016-02-17T01:51:39.063" Score="8" Body="&lt;p&gt;Here's a substitution that solves the problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(.*\)1\(.*\)/\=join(map(range(1, 12), 'submatch(1) . v:val . submatch(2)'), &quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The substitution matches each line that contains &quot;1&quot; and captures the text before &lt;code&gt;{c1}&lt;/code&gt; and after &lt;code&gt;{c2}&lt;/code&gt; the last &quot;1&quot;. For each matched line, the range of numbers from one to twelve &lt;code&gt;{n}&lt;/code&gt; are &lt;a href=&quot;https://en.wikipedia.org/wiki/Map_%28higher-order_function%29&quot; rel=&quot;nofollow&quot;&gt;mapped&lt;/a&gt; to create twelve lines of the form &lt;code&gt;{c1}{n}{c2}&lt;/code&gt;. Each group of twelve lines replaces its associated, originally matched line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h sub-replace-expression&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6206" LastEditorUserId="6206" LastEditDate="2016-02-17T17:54:56.370" LastActivityDate="2016-02-17T17:54:56.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6530" PostTypeId="1" AcceptedAnswerId="6536" CreationDate="2016-02-17T06:56:07.603" Score="9" ViewCount="1258" Body="&lt;p&gt;I cannot convince vim to apply the coding-style I'd like to (&lt;code&gt;cindent&lt;/code&gt; and friends).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, integrating &lt;code&gt;clang-format.py&lt;/code&gt; (which uses the .clang-format of my project) actually makes me totally happy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Except that I have the reflex of using the &lt;kbd&gt;=&lt;/kbd&gt; + &lt;em&gt;motion&lt;/em&gt;-command. Which is actually very nice to indent a region or the whole file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I instruct vim to override the default functionality? I read about equalprg, but I'm unsure how to set it to make it work with clang-format.&lt;/p&gt;&#xA;" OwnerUserId="1542" LastEditorUserId="1542" LastEditDate="2016-02-17T09:53:02.387" LastActivityDate="2016-02-17T12:40:57.693" Title="How to override the '=' command?" Tags="|indentation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6531" PostTypeId="1" AcceptedAnswerId="6539" CreationDate="2016-02-17T07:23:16.337" Score="11" ViewCount="1158" Body="&lt;p&gt;I do not know if this question should be asked here or not. In almost every language, malware exists. Is the same also applicable for &lt;code&gt;vimscript&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose &lt;code&gt;vim&lt;/code&gt; is running with high system privileges. Is there any possibility that a new &lt;code&gt;vim&lt;/code&gt; user could ruin up his/her system by using a plugin or nice looking &lt;code&gt;vimrc&lt;/code&gt; file (i.e., so-called malicious scripts in other scripting languages)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the measures that a new user can take care of before running unknown script files? I know that disabling scripts is a obvious solution to that. But there are a really good number of plugins which are quite useful, even for the new learners.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again to say, this question might not fit here, but I do believe that security is also very important part of the entire picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pointing to some resources or info regarding this would be very much helpful for the new &lt;code&gt;vim&lt;/code&gt; users like me.&lt;/p&gt;&#xA;" OwnerUserId="5912" LastEditorUserId="205" LastEditDate="2016-02-17T14:00:36.337" LastActivityDate="2016-02-18T11:58:41.540" Title="How safe is it to use an unknown `_vimrc` or `vimscript` file?" Tags="|vimscript|vimrc|plugin-system|security|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6532" PostTypeId="1" CreationDate="2016-02-17T10:44:34.953" Score="5" ViewCount="772" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TrbYO.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On some files, a line (often the status line) overflows straight onto the next line, which screws up rendering until the size changes (when I close/resize a vertical split etc). This also happens regardless of whether I'm in tmux or not, to clarify. I'm using NeoVim, but I can reproduce the same behaviour in regular Vim too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's worse when I have airline enabled, but it still happens sometimes if I have it disabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The appropriate settings in my vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; tmux background fix&#xA;set t_Co=256&#xA;&#xA;&quot; show airline&#xA;set laststatus=2&#xA;&#xA;&quot; fix airline symbols&#xA;let g:airline_powerline_fonts = 1&#xA;let g:airline_theme = 'gotham'&#xA;&#xA;if !exists('g:airline_symbols')&#xA;  let g:airline_symbols = {}&#xA;  let g:airline_symbols.space = &quot;\ua0&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using urvxt, but I get the same results with gnome terminal, too. Here's the only configuration I've got for that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;URxvt.scrollBar: false&#xA;URxvt.font: xft:Inconsolata for Powerline:size=13:style=Medium&#xA;URxvt.boldFont: xft:Inconsolata for Powerline:size=13&#xA;URxvt.title: Terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The rest of &lt;a href=&quot;https://github.com/danprince/dotfiles&quot; rel=&quot;noreferrer&quot;&gt;my dotfiles&lt;/a&gt; are on Github.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea what could be causing this behaviour? It's especially bad when I do a vertical split and the panes have content that overflows. Scrolling one of them causes the other to get stuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ukzkw.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I suspect it might be something to do with the font. If I use &lt;code&gt;Inconsolata for Powerline-g&lt;/code&gt; then it doesn't always overflow, but the colors are wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9PadT.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to this, none of the following CSS coloring plugins work: &lt;code&gt;ap/vim-css-color&lt;/code&gt;, &lt;code&gt;skammer/vim-css-color&lt;/code&gt;  and &lt;code&gt;gorodinskiy/vim-coloresque&lt;/code&gt;. Colors just show up as regular syntax highlighted text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes it overflows anyway. Here you can see the written to file message rendered over the right side of airline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mcPYC.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="124" LastActivityDate="2016-02-17T14:23:16.263" Title="Vim split overflow" Tags="|split|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6533" PostTypeId="1" AcceptedAnswerId="6534" CreationDate="2016-02-17T11:36:41.847" Score="11" ViewCount="353" Body="&lt;p&gt;Sometimes, I would like to try a trick I find in the internet. It is often helpful to try this in vim (gvim if it is a gui trick), in virgin mode, i.e., without loading all my ~/.vimrc stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any tips for doing this efficiently?&lt;/p&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="205" LastEditDate="2016-02-17T14:02:00.330" LastActivityDate="2016-02-21T18:02:12.077" Title="Experimenting with vim/gvim in &quot;virgin&quot; mode" Tags="|plugin-system|invocation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6534" PostTypeId="2" ParentId="6533" CreationDate="2016-02-17T11:43:57.687" Score="16" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-2.5&quot;&gt;Vim FAQ 2.5&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This starts Vim in nocompatible mode (-N), without reading your&#xA;  viminfo file (-i NONE), without reading any configuration file (-u&#xA;  NONE for not reading .vimrc file and -U NONE for not reading a .gvimrc&#xA;  file) or even plugin.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After opening Vim/gVim you can use &lt;code&gt;:source &amp;lt;path&amp;gt;&lt;/code&gt; to load a test vimrc or plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use &lt;code&gt;-u NORC&lt;/code&gt; to skip only the vimrc but load the plugins (more details at &lt;code&gt;:help -u&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-02-17T11:43:57.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6535" PostTypeId="1" AcceptedAnswerId="6538" CreationDate="2016-02-17T12:24:46.153" Score="7" ViewCount="4838" Body="&lt;p&gt;Assume the content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo fnord bar;&quot; &amp;gt;&amp;gt; /tmp/foo/derp&#xA;gnarf foo fnord bar;&quot; &amp;gt;&amp;gt; /tmp/foo/derp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to jump to the &quot; and delete to end of line and repeat that over the rest of lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet when I:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f&quot;d$&#xA;j&#xA;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it only deletes from my current cursor position to the end of file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo fnord bar;&#xA;gnarf foo fno&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet I would have expected the line to read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gnarf foo fnord bar;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I have vim repeat the jump movement as well on repeat?&lt;/p&gt;&#xA;" OwnerUserId="5449" LastActivityDate="2020-05-07T00:21:37.613" Title="How to repeat last action with movement?" Tags="|substitute|normal-mode|repeated-commands|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6536" PostTypeId="2" ParentId="6530" CreationDate="2016-02-17T12:29:42.890" Score="9" Body="&lt;p&gt;If you have nothing against a plugin install, Rhysd's &lt;a href=&quot;https://github.com/rhysd/vim-clang-format&quot;&gt;vim-clang-format&lt;/a&gt; may be a valid solution, instead of a custom &lt;code&gt;equalprg&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the documentation states, with Kana's &lt;a href=&quot;https://github.com/kana/vim-operator-user&quot;&gt;vim-operator-user&lt;/a&gt; dependency installed, you can map &lt;code&gt;=&lt;/code&gt; to &lt;code&gt;&amp;lt;Plug&amp;gt;(operator-clang-format)&lt;/code&gt; (to function as a full operator) and use it with motions / text-objects such as &lt;code&gt;==&lt;/code&gt; or &lt;code&gt;=G&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should create a &lt;em&gt;buffer local mapping&lt;/em&gt;, only for C,C++ and Objective-C filetypes, to let default &lt;code&gt;=&lt;/code&gt; otherwise untouched:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType c,cpp,objc map &amp;lt;buffer&amp;gt; = &amp;lt;Plug&amp;gt;(operator-clang-format)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-02-17T12:40:57.693" LastActivityDate="2016-02-17T12:40:57.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6538" PostTypeId="2" ParentId="6535" CreationDate="2016-02-17T12:36:00.023" Score="10" Body="&lt;p&gt;From the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html&quot;&gt;repeat documentation&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.           Repeat last change, with count replaced with [count].&#xA;            Also repeat a yank command, when the 'y' flag is&#xA;            included in 'cpoptions'.  Does not repeat a&#xA;            command-line command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, as expected, you're repeating the last change (&lt;code&gt;d$&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to repeat your movement, use &lt;code&gt;;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;;           Repeat latest f, t, F or T [count] times. See |cpo-;|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;IE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f&quot;d$&#xA;j&#xA;;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could map a binding to perform &lt;code&gt;;.&lt;/code&gt; at the same time, if you want.&lt;/p&gt;&#xA;" OwnerUserId="4932" LastActivityDate="2016-02-17T12:36:00.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6539" PostTypeId="2" ParentId="6531" CreationDate="2016-02-17T13:53:38.787" Score="11" Body="&lt;p&gt;Well, Vim can execute arbitrary commands with &lt;code&gt;:!&lt;/code&gt;. It can set environment variables. Malware scripts that are shell scripts can, therefore, be run from Vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can make use of complex Perl, Python, Ruby or Lua programs. So malware written in any of these that makes use of only standard libraries could be embedded in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if neither of these were true, Vim is an editor. If run as root, we could easily edit your &lt;code&gt;/etc/passwd&lt;/code&gt; and &lt;code&gt;/etc/shadow&lt;/code&gt; files to create a new user and &lt;code&gt;/etc/sudoers&lt;/code&gt; to grant them complete &lt;code&gt;sudo&lt;/code&gt; privileges, and a &lt;code&gt;cronjob&lt;/code&gt; to run shell scripts to set this user up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As with executing random scripts off the internet, there's no &lt;em&gt;easy&lt;/em&gt; way to be safe. In Linux, you could run in a VM &lt;a href=&quot;https://askubuntu.com/a/548712/158442&quot;&gt;with an overlay&lt;/a&gt; might tell you what files a given vimrc modifies. It depends on how much risk you perceive.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.647" LastActivityDate="2016-02-17T22:08:04.390" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6540" PostTypeId="2" ParentId="6532" CreationDate="2016-02-17T14:23:16.263" Score="6" Body="&lt;p&gt;This is a known bug in &lt;a href=&quot;https://github.com/neovim/neovim/issues/4195&quot;&gt;neovim&lt;/a&gt; and &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/sb1jmVirXPU/mPhvDnZ-CwAJ&quot;&gt;vim&lt;/a&gt;. The problem however appears to be a lot smaller on vim, since I saw that only sometimes, while in neovim it seems to happen a lot more often with statusline highlighting plugins (e.g. airline). BTW: for airline, there is a workaround &lt;a href=&quot;https://github.com/vim-airline/vim-airline/blob/master/doc/airline.txt#L289-L291&quot;&gt;documented&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-02-17T14:23:16.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6541" PostTypeId="1" CreationDate="2016-02-17T16:01:50.703" Score="14" ViewCount="2679" Body="&lt;p&gt;I want to type in different languages using (g)Vim. But when I switch to another language using language bar (Devanagari or Hindi characters), and type anything, (g)vim displays &lt;code&gt;??? ??&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I tried:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;write ++enc=utf-8 foo.txt  &#xA;set fileencoding=utf-8   &#xA;set enc=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Information:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GVim version: 7.4, and also its +multi_byte.&lt;/li&gt;&#xA;&lt;li&gt;No changes in default vimrc file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have just started with (g)vim.&lt;/p&gt;&#xA;" OwnerUserId="6462" LastEditorUserId="6462" LastEditDate="2016-03-08T06:14:55.723" LastActivityDate="2016-10-04T11:48:16.547" Title="Not able to type Unicode with Gvim and VIM on Windows 7" Tags="|microsoft-windows|unicode|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6542" PostTypeId="2" ParentId="6479" CreationDate="2016-02-17T17:16:16.623" Score="8" Body="&lt;p&gt;Modelines may seem like a way to do this, but unfortunately they won't work. Modelines only support setting options (&lt;code&gt;shiftwidth&lt;/code&gt;, &lt;code&gt;colorcolumn&lt;/code&gt;, that sort of thing). You can use a modeline like &lt;code&gt;vim: spell&lt;/code&gt; to enable spellchecking for a document. However, &lt;code&gt;spellgood!&lt;/code&gt; is an Ex command, not an option. Further, you specifically &lt;em&gt;can't&lt;/em&gt; set some options (including &lt;code&gt;spellfile&lt;/code&gt;, see &lt;code&gt;:help spellfile&lt;/code&gt;) from modelines for security reasons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;could&lt;/em&gt; craft a bunch of file-specific autocommands in your vimrc, but that would become really hard to maintain over time, tedious if you ever happen to have two files with the same name in different locations, and wouldn't travel &quot;with the file.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, the best solution is probably to build your own modeline-like feature for adding words by parsing some defined block of text in the document. For example, you can look for lines starting with &lt;code&gt;&quot;spellgood:&quot;&lt;/code&gt; and automatically add the space-delimited set of words after to the internal word list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddLocalSpelling ()&#xA;  &quot; Save the cursor position.&#xA;  let cursor_position = getcurpos()&#xA;&#xA;  let location = searchpos(&quot;\&quot;spellgood:&quot;, &quot;c&quot;)&#xA;  while location != [0, 0]&#xA;    let words = split(getline(location[0]))&#xA;    &quot; The first 'word' will be the sentinel token itself (unless)&#xA;    &quot; we found the token in an embedded string or comment...&#xA;    if words[0] == &quot;\&quot;spellgood:&quot;&#xA;      call remove(words, 0)&#xA;      for word in words&#xA;        execute &quot;silent spellgood! &quot; . word&#xA;      endfor&#xA;    endif&#xA;    let location = searchpos(&quot;\&quot;spellgood:&quot;, &quot;W&quot;)&#xA;  endwhile&#xA;&#xA;  &quot; Restore cursor position.&#xA;  call setpos(&quot;.&quot;, cursor_position)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can set up an autocommand for, say &lt;code&gt;BufReadPost * call AddLocalSpelling()&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt;. In practice you'd probably want to make the above function more robust in the face of errors, and possibly use &lt;code&gt;comments&lt;/code&gt; to see what a valid comment token is (I picked &lt;code&gt;&quot;&lt;/code&gt; because I tested this in a VimL buffer). This &lt;a href=&quot;https://superuser.com/questions/641946/add-file-specific-good-words-to-internal-vim-wordlist-via-modeline&quot;&gt;SuperUser answer&lt;/a&gt; linked by JJoao in the comments provides a similar-but-alternative implementation that lets you use blocks of words instead of just a single line at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method will require &lt;em&gt;others&lt;/em&gt; use the same function or at least agree on the same parse rules, so it's not perfect. But you could take it and promote the functionality to a plugin if you so desired, enabling easier access for other users.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2016-02-17T17:45:36.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6544" PostTypeId="2" ParentId="6525" CreationDate="2016-02-17T20:28:58.177" Score="2" Body="&lt;p&gt;Save the following macro and use it for each line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqyy11p/\/\zs1&amp;lt;CR&amp;gt;&amp;lt;C-v&amp;gt;10jg&amp;lt;C-a&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The main difference over the other answers is that this makes use of &lt;code&gt;g&amp;lt;C-a&amp;gt;&lt;/code&gt; on a column selection that increments each line with a different number. Check &lt;code&gt;:help v_g_CTRL-A&lt;/code&gt; for more information. I've also used &lt;code&gt;\zs&lt;/code&gt; to select the pattern start position, such that the cursor stops at the number after the search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that you need a recent version of Vim for this to work.&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="599" LastEditDate="2016-02-19T11:40:41.457" LastActivityDate="2016-02-19T11:40:41.457" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6545" PostTypeId="1" AcceptedAnswerId="6546" CreationDate="2016-02-17T21:57:18.840" Score="4" ViewCount="276" Body="&lt;p&gt;I use &lt;a href=&quot;https://github.com/vim-scripts/dbext.vim&quot; rel=&quot;nofollow&quot;&gt;dbext.vim&lt;/a&gt; for any database related work so I have several connections configured on my &lt;code&gt;_vimrc&lt;/code&gt; and when I need to switch between them I use the &lt;code&gt;DBPromptForBufferParameters&lt;/code&gt; that this plugin provides.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I'm using gVim this shows an popup window because it uses the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#inputdialog%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;inputdialog()&lt;/code&gt;&lt;/a&gt; function, however I want to this function behave like the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#input%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;input()&lt;/code&gt;&lt;/a&gt; function that does not show a popup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is some way to do this or I would have to change the plugin &lt;a href=&quot;https://github.com/vim-scripts/dbext.vim/blob/master/autoload/dbext.vim#L6510-L6525&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt; ? I have looked at the documentation and source of the plugin and there isn`t any option to configure this.&lt;/p&gt;&#xA;" OwnerUserId="1453" LastActivityDate="2016-02-17T22:15:47.163" Title="How I can make inputdialog() behave like input() on GUI?" Tags="|vimscript|gvim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6546" PostTypeId="2" ParentId="6545" CreationDate="2016-02-17T22:15:47.163" Score="5" Body="&lt;p&gt;Adding &lt;code&gt;c&lt;/code&gt; to the &lt;code&gt;guioptions&lt;/code&gt; setting will replace simple GUI input popups with their console equivalents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guioptions+=c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;inputdialog()&lt;/code&gt; is called with a default value, &lt;code&gt;Backspace&lt;/code&gt; first if you want to replace it.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-02-17T22:15:47.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6547" PostTypeId="1" CreationDate="2016-02-17T23:29:58.390" Score="2" ViewCount="94" Body="&lt;p&gt;I manually installed the &lt;code&gt;txtfmt&lt;/code&gt; plugin (&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2208&quot; rel=&quot;nofollow&quot;&gt;Brett Stahlman's The Vim Highlighter&lt;/a&gt;) ver 3.0. After trying to run &lt;code&gt;:MakeTestPage&lt;/code&gt;, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;36_MakeTestPage: line 21:     &#xA;MakeTestPage(): Error opening test page: E108: No such variable: &quot;b:eclim_tab_id&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have eclim installed (although it's not running now). I'd really like to keep my eclim, if possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked for solutions in README, in &lt;code&gt;:help txtfmt&lt;/code&gt; and in google without any success. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if anyone can at least tell me what I need to do to fix the above problem or at least how to approach it (I'm relatively new to vimscript).&lt;/p&gt;&#xA;" OwnerUserId="6473" LastEditorUserId="205" LastEditDate="2016-02-18T00:25:14.883" LastActivityDate="2016-02-18T00:25:14.883" Title="How do I resolve Error E108: No such variable: &quot;b:eclim_tab_id&quot; in textfmt plugin v3.0?" Tags="|vimscript|plugin-eclim|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6548" PostTypeId="5" CreationDate="2016-02-18T00:38:30.450" Score="0" Body="&lt;p&gt;Vim supports automatically generating text following a pattern, via macros, motions and functions. For example, the following generates a sequence of numbers from 1 to 10:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i1&amp;lt;esc&amp;gt;qqYp&amp;lt;c-a&amp;gt;q8@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Breaking down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;i1&amp;lt;esc&amp;gt;&lt;/code&gt; write &lt;code&gt;1&lt;/code&gt; and back to normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; start recording a macro in the register &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Yp&lt;/code&gt; yank the line and paste it below&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; increment it&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; stop recording the macro&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;8@q&lt;/code&gt; repeat the macro in the register &lt;code&gt;q&lt;/code&gt; 8 times.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Other facilities for automation include using functions in the replacement of a &lt;code&gt;:substitute&lt;/code&gt; command, looping over text, etc.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-02-18T00:38:30.450" LastActivityDate="2016-02-18T00:38:30.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6549" PostTypeId="4" CreationDate="2016-02-18T00:38:30.450" Score="0" Body="Automatically generating text with Vim, using patterns like incrementing numbers, etc." OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-02-18T00:38:30.450" LastActivityDate="2016-02-18T00:38:30.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6550" PostTypeId="1" CreationDate="2016-02-18T03:33:39.420" Score="3" ViewCount="595" Body="&lt;p&gt;Sometime in the past little while either the clang on the systems I use (Fedora) were updated to use precompiled headers by default, or else my re-install of the clang complete git plugin from github did it (the previous install was a few years old) -- I'm not sure which since I have not been doing much C++ for a few months, and now I'm busy with it again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I don't use clang for normal compiles, I use GCC.  I don't believe the latter is involved because of the timestamps on the &lt;code&gt;.pch&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, the precompiled &lt;code&gt;.pch&lt;/code&gt; headers are left in &lt;code&gt;/tmp&lt;/code&gt;.  The problem is, regularly when checking source files I get mismatch errors in relation to the headers which are very obviously wrong in relation to the current version.  The error is then followed by a message to the effect that &quot;the current precompiled .pch is older than the header source&quot; &lt;em&gt;which persists no matter what&lt;/em&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Making minor edits to the header, resaving, re-running &lt;code&gt;ClangUpdateQuickFix&lt;/code&gt;; doesn't matter, still uses old compiled version.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Closing and reopening the header file and making changes and doing the same thing, no change.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Deleting all the &lt;code&gt;.pch&lt;/code&gt; files from &lt;code&gt;/tmp&lt;/code&gt;.  This makes the situation &lt;strong&gt;worse&lt;/strong&gt;.  Now UpdateQuickFix will do absolutely nothing for the files including the header.  I can add complete garbage to them and it still shows no errors.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This might be an XY problem -- I'm fine with a way that will recompile the headers when necessary.  It might be more of a clang related question, but looking through &lt;a href=&quot;http://clang.llvm.org/docs/UsersManual.html&quot; rel=&quot;nofollow&quot;&gt;their manual&lt;/a&gt; it only talks about enabling them on the command line and how useful they are, not how to get rid of the &quot;feature whether you like it or not&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only solution I've found is to shut down and restart vim, which it a complete PITA.&lt;/p&gt;&#xA;" OwnerUserId="4913" LastActivityDate="2016-02-25T17:52:29.267" Title="Clang complete, disable precompiled headers" Tags="|plugin-clang-complete|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6551" PostTypeId="1" AcceptedAnswerId="6555" CreationDate="2016-02-18T04:30:45.340" Score="8" ViewCount="563" Body="&lt;p&gt;In XCode, there is an add-on called vvdocument, which can detect three &lt;code&gt;/&lt;/code&gt; hits, and transfer &lt;code&gt;///&lt;/code&gt; into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*!&#xA;*  @author Robbie Yi JIANG, 29-Jan-2016 14:01:45&#xA;*&#xA;*  &#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do this in Vim.&lt;/p&gt;&#xA;" OwnerUserId="6227" LastEditorUserId="205" LastEditDate="2016-02-18T05:08:21.063" LastActivityDate="2016-02-22T18:49:23.233" Title="How can I create a /* comments section with /// like in XCode?" Tags="|comments|text-generation|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6552" PostTypeId="1" CreationDate="2016-02-18T06:28:35.173" Score="2" ViewCount="931" Body="&lt;p&gt;I've had a look at &lt;code&gt;:h matchparen&lt;/code&gt;, and it doesn't seem to have an option for highlighting the match for the parenthesis immediately before the cursor. In short, this is what I want:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Matchparen should try to match the paren before the cursor if it exists.&lt;/li&gt;&#xA;&lt;li&gt;It should default to the one under the cursor otherwise.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This would be very helpful for writing Lisp. It would be a plus if it did the above in insert mode, but went back to the default behavior in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to clarify, this does not need to affect the behavior of &lt;code&gt;%&lt;/code&gt;, and preferably should not.&lt;/p&gt;&#xA;" OwnerUserId="6476" LastActivityDate="2016-02-18T11:34:34.943" Title="Make Vim highlight the match for the paren *before* the cursor" Tags="|highlight|delimiter-matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6553" PostTypeId="2" ParentId="6477" CreationDate="2016-02-18T06:44:25.107" Score="2" Body="&lt;p&gt;There is no solution for that and Bram even &lt;a href=&quot;https://github.com/vim/vim/issues/260&quot; rel=&quot;nofollow&quot;&gt;stated&lt;/a&gt;, he does not consider that to be a bug. Concealing is only about the visual appearance and won't change the underlying text property. Besides being hard to get right (and possibly even slow), one would probably have many unwanted side effects, that are not wanted.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-02-18T06:44:25.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6554" PostTypeId="2" ParentId="6551" CreationDate="2016-02-18T08:37:30.903" Score="6" Body="&lt;p&gt;One way would be to create a file containing this snippet, and read it when you type &lt;code&gt;///&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, create &lt;code&gt;~/.vim/snippets/my_header.snip&lt;/code&gt; containing this header. Then define this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap /// &amp;lt;esc&amp;gt;:r ~/.vim/snippets/my_header.snip&amp;lt;cr&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap /// &amp;lt;esc&amp;gt;:call append(line('.')-1, readfile(expand('~/.vim/snippets/my_header.snip')))&amp;lt;cr&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the first mapping, your cursor will be placed on the first line of the inserted text; and in the second, the cursor will be placed below the inserted text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps the simplest mapping, in terms of jumping around modes, is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap /// &amp;lt;c-r&amp;gt;&amp;lt;c-o&amp;gt;=readfile(expand('~/.vim/snippets/my_header.snip'))&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more general usage, you might want to look into snippet plugins. &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow&quot;&gt;UltiSnips&lt;/a&gt; and &lt;a href=&quot;https://github.com/garbas/vim-snipmate&quot; rel=&quot;nofollow&quot;&gt;SnipMate&lt;/a&gt; are two popular ones. I don't use either, so I won't recommend one.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-02-20T00:52:39.060" LastActivityDate="2016-02-20T00:52:39.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6555" PostTypeId="2" ParentId="6551" CreationDate="2016-02-18T09:56:41.937" Score="9" Body="&lt;p&gt;The method in &lt;a href=&quot;https://vi.stackexchange.com/a/6554/205&quot;&gt;my earlier answer&lt;/a&gt; doesn't transform well to dynamic content. This is where snippet plugins like UltiSnips and SnipMate come in. I'll provide a demo of &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt; here. Install it using your favourite method from &lt;a href=&quot;https://vi.stackexchange.com/q/613/205&quot;&gt;How do I install a plugin in vim/vi?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, make an &lt;code&gt;UltiSnips&lt;/code&gt; directory in your &lt;code&gt;.vim&lt;/code&gt; or &lt;code&gt;_vimfiles&lt;/code&gt; directory. In it, place a &lt;code&gt;c.snippet&lt;/code&gt; file containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet /// &quot;My header&quot; A&#xA;/*!&#xA;*  @author Robbie Yi JIANG, `date +'%d-%b-%Y %T'`&#xA;*&#xA;*  &#xA;*/&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, if you open a C file and type &lt;code&gt;///&lt;/code&gt;, it should automatically get replaced with the header, including the current date and time. That's it!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually, UltiSnips inserts a snippet when you press &lt;kbd&gt;Tab&lt;/kbd&gt;. Here, we have specified that the snippet should be automatically entered - that's what the &lt;code&gt;A&lt;/code&gt; at the end of the first line indicates. Checkout &lt;code&gt;:help UltiSnips-syntax&lt;/code&gt; for more information on writing snippets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most people, however, start off with a collection of snippets, such as &lt;a href=&quot;https://github.com/honza/vim-snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-snippets&lt;/code&gt;&lt;/a&gt;. There are too many to describe here, but you might some of them very useful.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-02-18T09:56:41.937" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6556" PostTypeId="2" ParentId="6552" CreationDate="2016-02-18T10:15:28.783" Score="4" Body="&lt;p&gt;You should try &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1230&quot; rel=&quot;nofollow&quot;&gt;Rainbow Parenthesis : Highlight matching parens in a rainbow of colors&lt;/a&gt; (&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3772&quot; rel=&quot;nofollow&quot;&gt;or one of its clones&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This script highlights matching parenthesis with a rainbow&#xA;  of colors. This make it visually very obvious which matches what. Most&#xA;  useful for Lisp.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It highlights &lt;em&gt;all&lt;/em&gt; the parenthesis, not only the &lt;em&gt;one before the cursor&lt;/em&gt;. Nonetheless, it could help on your task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another alternative is &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2219&quot; rel=&quot;nofollow&quot;&gt;Limp : Lisp IDE&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It will do this for you:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;booting/attaching/detaching a Lisp (SBCL) from Vim or a command-line script, optionally specifying a core;&lt;/li&gt;&#xA;  &lt;li&gt;send code to the attached Lisp (and limited introspection, see Help Describe);&lt;/li&gt;&#xA;  &lt;li&gt;automatically close brackets;&lt;/li&gt;&#xA;  &lt;li&gt;ease s-exp navigation and (some) transposing;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;strong&gt;highlight current form under the cursor;&lt;/strong&gt;&lt;/li&gt;&#xA;  &lt;li&gt;lookup documentation from the HyperSpec;&lt;/li&gt;&#xA;  &lt;li&gt;complete (some) names.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are several plugins on &lt;a href=&quot;http://www.vim.org/scripts/script_search_results.php?keywords=lisp&amp;amp;script_type=&amp;amp;order_by=rating&amp;amp;direction=descending&amp;amp;search=search&quot; rel=&quot;nofollow&quot;&gt;vim.org&lt;/a&gt; which you may find helpful.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-02-18T11:34:34.943" LastActivityDate="2016-02-18T11:34:34.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6557" PostTypeId="2" ParentId="6531" CreationDate="2016-02-18T11:58:41.540" Score="7" Body="&lt;p&gt;Extending on muru's answer, you could inspect the code, specially as the plugin code is usually very short (the exceptions are some popular plugins, but by being popular they are safer -- you can expect that many others have reviewed the source).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't have to fully understand the code; it would is enough to look for &quot;dangerous&quot; commands:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:!&lt;/code&gt; and &lt;code&gt;system()&lt;/code&gt;: allows the execution of shell commands, thus could change your system&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:perldo&lt;/code&gt;, &lt;code&gt;:python&lt;/code&gt;, &lt;code&gt;:lua&lt;/code&gt;, &lt;code&gt;:tcl&lt;/code&gt;, and &lt;code&gt;:ruby&lt;/code&gt;: execute commands on different languages, which may contain system calls embedded&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:execute&lt;/code&gt;: this command executes a string as a command, so it can be use to conceal one of the previous commands (e.g.: in order to make harder to spot &lt;code&gt;call system('malware')&lt;/code&gt; or &lt;code&gt;perldo malware&lt;/code&gt;, someone could concatenate the string into a variable)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;function(&quot;MyFunc&quot;)&lt;/code&gt;: call function references -- accepts a variable as a parameter, thus allowing concealing of &lt;code&gt;system()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You could also try running some plugin functions using &lt;code&gt;'secure'&lt;/code&gt; or &lt;code&gt;sandbox&lt;/code&gt; to detect shell and external languages (perl, python, etc).&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-02-18T11:58:41.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6558" PostTypeId="1" CreationDate="2016-02-18T14:26:01.720" Score="11" ViewCount="2842" Body="&lt;p&gt;I have Python 2.7.9 installed. And now I get the message that the Gundo plugin requires 2.4. Is there a workaround?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'tpope/vim-surround'&#xA;Plugin 'easymotion/vim-easymotion'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'jlanzarotta/bufexplorer'&#xA;Plugin 'rstacruz/sparkup'&#xA;Plugin 'MarcWeber/vim-addon-mw-utils'&#xA;Plugin 'tomtom/tlib_vim'&#xA;Plugin 'jeffkreeftmeijer/vim-numbertoggle'&#xA;Plugin 'scrooloose/syntastic'&#xA;Plugin 'qpkorr/vim-renamer'&#xA;Plugin 'klen/python-mode'&#xA;Plugin 'ctrlpvim/ctrlp.vim'&#xA;Plugin 'dhruvasagar/vim-table-mode'&#xA;Plugin 'shinokada/listtrans.vim'&#xA;Plugin 'gavinbeatty/vmath.vim'&#xA;Plugin 'sjl/gundo.vim'&#xA;Plugin 'tpope/vim-abolish'&#xA;&#xA;&#xA;&quot; Bindings for Listtrans plugin&#xA;nmap  ;l   :call ListTrans_toggle_format()&amp;lt;CR&amp;gt;          &#xA;vmap  ;l   :call ListTrans_toggle_format('visual')&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Bindings for Gundo&#xA;nnoremap &amp;lt;F5&amp;gt; :GundoToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;_Bindings for vmath&#xA;&quot;nmap          ++  vip++&#xA;&quot;vmap          ++  VMATH_YankAndAnalyse()                     &#xA;&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&quot; To ignore plugin indent changes, instead use:&#xA;&quot;filetype plugin on&#xA;&quot;&#xA;&quot; Brief help&#xA;&quot; :PluginList       - lists configured plugins&#xA;&quot; :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate&#xA;&quot; :PluginSearch foo - searches for foo; append `!` to refresh local cache&#xA;&quot; :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal&#xA;&quot;&#xA;&quot; see :h vundle for more details or wiki for FAQ&#xA;&quot; Put your non-Plugin stuff after this line&#xA;&#xA;:syntax on&#xA;let NERDTreeQuitOnOpen=1&#xA;&#xA;:set hlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 31 2015 23:56:29)&#xA;Included patches: 1-488, 576&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by buildd@&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;-clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   -perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       -python          +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            -ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            +mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux -lacl -lattr -lgpm -ldl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5346" LastEditorUserId="1841" LastEditDate="2016-03-13T14:50:48.413" LastActivityDate="2017-10-08T08:14:53.887" Title="Gundo plugin requires python 2.4 when version 2.7 is installed" Tags="|plugin-system|version|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6559" PostTypeId="2" ParentId="6558" CreationDate="2016-02-18T15:23:42.153" Score="8" Body="&lt;p&gt;Try the &lt;a href=&quot;https://github.com/mbbill/undotree/&quot; rel=&quot;noreferrer&quot;&gt;undotree plugin&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Someone asked me about the difference with Gundo, here is a list of&#xA;  differences, or advantages.&lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;&lt;strong&gt;Pure vimscript implementation and no 3rd-party libraries(like python) is needed&lt;/strong&gt;, don't worry about performance, it's not such a big&#xA;  deal for vim to handle this. The only dependency is the 'diff' tool&#xA;  which always shipped with vim and even without 'diff' you still can&#xA;  use most of the features of this script.&lt;/li&gt;&#xA;  &lt;li&gt;Realtime updated undo tree. Once you make changes, the undo tree will be updated simultaneously.&lt;/li&gt;&#xA;  &lt;li&gt;Several useful marks, like current changeset, next redo changeset, saved changeset, etc.&lt;/li&gt;&#xA;  &lt;li&gt;Toggle between relative timestamp and absolute timestamp.&lt;/li&gt;&#xA;  &lt;li&gt;Realtime updated undo window.&lt;/li&gt;&#xA;  &lt;li&gt;Ability to clear undo history.&lt;/li&gt;&#xA;  &lt;li&gt;More customizable.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've switched from Gundo to undotree about some years ago and it works very well.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-02-18T15:23:42.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6560" PostTypeId="2" ParentId="2199" CreationDate="2016-02-18T16:03:02.560" Score="2" Body="&lt;p&gt;Inspired by Rich's great answer I've added the following lines to my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; For en/em dashes, respectively&#xA;autocmd FileType markdown imap -- –&#xA;autocmd FileType markdown imap --- —&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works like a treat!&lt;/p&gt;&#xA;" OwnerUserId="6484" LastEditorUserId="1453" LastEditDate="2016-02-18T22:24:08.217" LastActivityDate="2016-02-18T22:24:08.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6561" PostTypeId="1" AcceptedAnswerId="6562" CreationDate="2016-02-18T16:26:43.293" Score="4" ViewCount="9836" Body="&lt;p&gt;I have a CSV that uses ,(comma) as the delimiter. This CSV is nearly 20K lines long and there are 10 instances where a comma was used INSIDE the data. These errant commas are breaking my processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In VIM, how would you locate ONLY the lines that have more than 1 comma?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can find all commas using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/,//gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This tells me I have 17655 commas on 17646 lines. There should only be 17646 commas, 1 per line, in the entire file. What is an easy way to locate any line with more than one comma on it?&lt;/p&gt;&#xA;" OwnerUserId="1417" LastActivityDate="2016-02-19T08:49:52.380" Title="How to find multiple instances of same character on single line?" Tags="|search|regular-expression|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6562" PostTypeId="2" ParentId="6561" CreationDate="2016-02-18T16:57:30.347" Score="5" Body="&lt;p&gt;I can think of two expressions offhand that may work for you. They both worked on some quick, limited test data I tried. The first expression is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(.\{-},\)\{2,}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This translates to &quot;match at least 2 sequences of (as few as possible of anything followed by a comma).&quot; In other words this tries to find matches of two or more sequences of comma-delimited text ranges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.\{-},\@&amp;lt;=.*,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is &quot;find anything followed by a comma, but only if immediately prior to that you could find as few as possible of anything followed by a comma.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if one or the other is more preferable. I find the first one easier to reason about, even though I came up with the second, more complex one first. You &lt;em&gt;may&lt;/em&gt; need to anchor them with &lt;code&gt;^&lt;/code&gt; to the start of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/6563/72&quot;&gt;Karl Yngve Lervåg's answer&lt;/a&gt; has an even simpler regex that works just as well as my overengineered options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With them, you can use the &lt;code&gt;global&lt;/code&gt; command (&lt;code&gt;:help global&lt;/code&gt;) to operate on the matching lines with some Ex command: &lt;code&gt;:g/.\{-},\@&amp;lt;=.*,/d&lt;/code&gt; for example, will delete all the lines with more than one comma in them.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-02-19T08:49:52.380" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6563" PostTypeId="2" ParentId="6561" CreationDate="2016-02-18T17:05:25.800" Score="9" Body="&lt;p&gt;A simple search should suffice:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/,.*,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will match any line that has at least two commas.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2016-02-19T07:11:08.983" LastActivityDate="2016-02-19T07:11:08.983" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6564" PostTypeId="2" ParentId="2702" CreationDate="2016-02-19T01:26:32.767" Score="1" Body="&lt;p&gt;In Neovim you could use the following command which will open a terminal buffer running the tail command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:enew | call termopen('tail --follow=name --retry /path/to/file.log')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will continue to work even if the file is removed and recreated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or add the following to your &lt;code&gt;$MYVIMRC&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; :Tail /path/to/file&#xA;function! Tail(file)&#xA;  enew&#xA;  call termopen('tail --follow=name --retry ' . fnameescape(a:file))&#xA;endfunction&#xA;command! -nargs=1 Tail call Tail(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1472" LastEditorUserId="1472" LastEditDate="2016-02-19T02:12:58.247" LastActivityDate="2016-02-19T02:12:58.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6565" PostTypeId="1" CreationDate="2016-02-19T06:12:41.537" Score="5" ViewCount="103" Body="&lt;p&gt;I spent a lot of time getting vim to look just the way I want, but &lt;code&gt;nornu&lt;/code&gt; and &lt;code&gt;rnu&lt;/code&gt; number modes look different.  Is there any way to disable the special highlighting when in &lt;code&gt;rnu&lt;/code&gt; mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;nornu&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zLWXU.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zLWXU.png&quot; alt=&quot;nornu&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;rnu&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KD5Rf.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KD5Rf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6492" LastActivityDate="2016-02-20T18:42:18.820" Title="How do I remove the special highlighting on `rnu` numbers?" Tags="|colorscheme|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6566" PostTypeId="1" CreationDate="2016-02-19T06:18:51.403" Score="3" ViewCount="149" Body="&lt;p&gt;When the first line(s) in a change are new/added, and subsequent lines are changed, Vim marks the first lines as changed up the number of lines occupied by the original lefthand file, and the subsequent lines as new.  In reality, the first line is new, and the second line is changed. Vim does not correctly recognize the similar/same line. Is there a way resolve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cWYNR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cWYNR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6491" LastActivityDate="2016-02-19T08:23:37.300" Title="vimdiff marks wrong line as added when first line in change is new" Tags="|vimdiff|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6567" PostTypeId="2" ParentId="6566" CreationDate="2016-02-19T07:17:25.680" Score="4" Body="&lt;p&gt;Since Vim only parses a diff, it's not Vim's fault, but rather caused by the diff algorithm used. You can check, if my &lt;a href=&quot;https://github.com/chrisbra/vim-diff-enhanced&quot; rel=&quot;nofollow&quot;&gt;VimDiff Enhanced Plugin&lt;/a&gt; can create a better Diff by using, e.g., the patience diff algorithm.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="205" LastEditDate="2016-02-19T08:23:37.300" LastActivityDate="2016-02-19T08:23:37.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6568" PostTypeId="2" ParentId="6565" CreationDate="2016-02-19T07:21:15.247" Score="4" Body="&lt;p&gt;You can't change that it is left-aligned, but you can change the highlighting used by modifying the &lt;code&gt;CursorLineNr&lt;/code&gt; highlighting group, e.g. to make it the same as the other numbering, you could use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi! link CursorLineNr LineNr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="205" LastEditDate="2016-02-20T18:42:18.820" LastActivityDate="2016-02-20T18:42:18.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6569" PostTypeId="1" AcceptedAnswerId="6570" CreationDate="2016-02-19T07:42:08.973" Score="5" ViewCount="604" Body="&lt;p&gt;We are switching from &lt;code&gt;array()&lt;/code&gt; to &lt;code&gt;[]&lt;/code&gt; in our php code. And when I start to do code refactoring I found that almost all arrays are specified with &lt;code&gt;array()&lt;/code&gt; and not with &lt;code&gt;[]&lt;/code&gt;. How can I substitute it by &lt;code&gt;vim&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// アクセスログを取る&#xA;$this-&amp;gt;set('log_access', array(&#xA;    'target' =&amp;gt; 'topic',&#xA;    'id'     =&amp;gt; $id&#xA;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to change to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// アクセスログを取る&#xA;$this-&amp;gt;set('log_access', [&#xA;    'target' =&amp;gt; 'topic',&#xA;    'id'     =&amp;gt; $id&#xA;]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$opts    = array('http' =&amp;gt; array('header' =&amp;gt; 'User-Agent: iPhone-preview'));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to change to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$opts    = ['http' =&amp;gt; ['header' =&amp;gt; 'User-Agent: iPhone-preview']];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3302" LastEditorUserId="3302" LastEditDate="2016-02-19T07:52:52.950" LastActivityDate="2016-02-19T09:45:48.847" Title="How can I replace array(some_data) to [some_data]?" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6570" PostTypeId="2" ParentId="6569" CreationDate="2016-02-19T08:04:36.780" Score="7" Body="&lt;p&gt;Certainly looks like a case for a macro&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/array&amp;lt;CR&amp;gt;&lt;/code&gt; to jump to the first array&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; to record the macro into register q&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;de&lt;/code&gt; to delete the word array&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ma&lt;/code&gt; to save the cursor position on the first bracket at mark a&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%r]&lt;/code&gt; to jump to the matching bracket, replace it by another bracket&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`ar[&lt;/code&gt; to jump back to position a and replace that bracket&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; to end recording of the macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After that, it's just repeatedly pressing &lt;code&gt;n&lt;/code&gt; to jump to the next match and &lt;code&gt;@q&lt;/code&gt; to play the macro. You could make the search part of the macro and just execute until it stops, but I thought you might prefer to visually check each substition... you choose :)&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="4939" LastEditDate="2016-02-19T09:45:48.847" LastActivityDate="2016-02-19T09:45:48.847" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6571" PostTypeId="2" ParentId="2199" CreationDate="2016-02-19T11:15:59.363" Score="3" Body="&lt;p&gt;Install my &lt;a href=&quot;https://github.com/chrisbra/unicode.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;unicode plugin&lt;/a&gt;, enter Vim and type DASH followed by &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;X&lt;/kbd&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Z&lt;/kbd&gt; to activate unicode completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/N4PIg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/N4PIg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note the -N in the description which shows the digraph to enter that character)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-02-19T11:15:59.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6574" PostTypeId="1" AcceptedAnswerId="6575" CreationDate="2016-02-19T15:51:11.357" Score="5" ViewCount="624" Body="&lt;h3&gt;Problem:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Suppose I have the following text in my vim buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a commit msg.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Suppose further I have a git repo located at &lt;code&gt;~/my_repo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt; Make a vim script so that I can highlight the text above, and have it sent as a git commit message within &lt;code&gt;~/my_repo&lt;/code&gt;. It would look something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;Commit ~/my_repo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would also have auto-complete on its repo argument.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Attempted Solution:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;First, the autocomplete function (AFAIK I think this is OK?):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GitLocations()&#xA;  return find $HOME -name '.git' -printf '%h\n' &quot;generates a list of all folders which contain a .git dir&#xA;endfunction &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, the actual git commit function, which is incomplete:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CommitTextGitRepo(l1, l2, loc)&#xA;  let s:msg = ??? &quot; how do I make this the highlighted text from line l1 to line l2?&#xA;  execute '!cd ' . a:loc . '&amp;amp;&amp;amp; git commit --allow-empty -m \&quot;' . s:msg '\&quot;'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming I can figure out how to get &lt;code&gt;CommitTextGitRepo()&lt;/code&gt; working above, the final thing I would need is this (I think):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* -complete=custom,GitLocations -range Commit call CommitToGitRepo(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;, &amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm so close. How do I finish this up? :)&lt;/p&gt;&#xA;" OwnerUserId="6499" LastEditorUserId="6499" LastEditDate="2016-02-19T16:29:06.110" LastActivityDate="2016-02-19T17:07:53.020" Title="Vim Function to Send Highlighted Text to a Git Commit" Tags="|vimscript|git|functions|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6575" PostTypeId="2" ParentId="6574" CreationDate="2016-02-19T17:07:53.020" Score="5" Body="&lt;p&gt;&lt;code&gt;GitLocations&lt;/code&gt; won't work as expected, since you'll be calling Vim's &lt;code&gt;:find&lt;/code&gt;, not the &lt;code&gt;find&lt;/code&gt; command. You might try something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return system('find $HOME -name &quot;.git&quot; -printf &quot;%h\n&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you could add a &lt;code&gt;-type d&lt;/code&gt; to it to skip submodules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get visually selected text, you can use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getline()&lt;/code&gt;&lt;/a&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:msg = join(getline(&quot;'&amp;lt;&quot;, &quot;'&amp;gt;&quot;), &quot;\n&quot;) . &quot;\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it will be easier if you took advantage of &lt;code&gt;git commit&lt;/code&gt;'s ability to read the commit message from standard input. From &lt;a href=&quot;http://manpages.ubuntu.com/manpages/trusty/en/man1/git-commit.1.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;man git commit&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-F &amp;lt;file&amp;gt;, --file=&amp;lt;file&amp;gt;&#xA;   Take the commit message from the given file. Use - to read the&#xA;   message from the standard input.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Awrite_c&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;w !&lt;/code&gt;&lt;/a&gt;, you can write a set of lines to the standard input of a shell command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]w[rite] [++opt] !{cmd}&#xA;                        Execute {cmd} with [range] lines as standard input&#xA;                        (note the space in front of the '!').  {cmd} is&#xA;                        executed like with &quot;:!{cmd}&quot;, any '!' is replaced with&#xA;                        the previous command :!.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CommitToGitRepo(l1, l2, loc) range&#xA;    exec a:l1 . ',' . a:l2 'w !cd' shellescape(a:loc) '; git commit --allow-empty -F -'&#xA;endfunction&#xA;&#xA;command! -nargs=1 -range -complete=custom,GitLocations Commit call CommitToGitRepo(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;, &amp;lt;args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sources:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/8960966/2072269&quot;&gt;Call a vimscript function that has a range using local variables, from with in a vimscript function&lt;/a&gt; on Stack Overflow&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-02-19T17:07:53.020" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6576" PostTypeId="2" ParentId="4027" CreationDate="2016-02-19T17:44:46.580" Score="2" Body="&lt;p&gt;I put all of my plugins right into the hierarchy, I see the benefits of the various plugin managers but they don't do things that I want... I also locate my Vim configuration hierarchy &quot;remote&quot; from my user directory because it is shared between operating systems (via Bootcamp for instance) and across machines and even in some cases across the network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my current machine this is my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath^=~/Documents/dotfiles/vim&#xA;runtime vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On a different machine, running Windows, it's similar:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath^=C:/dotfiles/vim&#xA;runtime vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And my .gvimrc in both cases just uses &lt;code&gt;runtime gvimrc&lt;/code&gt;. If this directory is shared on the network I can also happily use (via batch file and to a shared location for the vim runtime too)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim -u \\my_pc\dotfiles\vim\vimrc -U \\my_pc\dotfiles\vim\gvimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All of this is in source control of course but if I'm just remoting into a computer sometimes it's easier just to load the config off of my host directly.&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-19T17:44:46.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6577" PostTypeId="1" CreationDate="2016-02-19T23:32:38.980" Score="2" ViewCount="54" Body="&lt;p&gt;While looking for ways to solve &lt;a href=&quot;https://vi.stackexchange.com/q/6551/205&quot;&gt;How can I create a /* comments section with /// like in XCode?&lt;/a&gt;, I cam across this puzzling behaviour. Say I have &lt;code&gt;foo.txt&lt;/code&gt; containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*!&#xA;*  @author Robbie Yi JIANG, 29-Jan-2016 14:01:45&#xA;*&#xA;*  &#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I open Vim, go to insert mode, and try &lt;code&gt;&amp;lt;c-r&amp;gt;=append(line('.'), readfile('foo.txt'))&lt;/code&gt;, instead of the above text, I see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0&#xA;/*!&#xA;*  @author Robbie Yi JIANG, 29-Jan-2016 14:01:45&#xA;*&#xA;*  &#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;0&lt;/code&gt; at the start! This also happens if I use &lt;code&gt;readfile('foo.txt', 'b')&lt;/code&gt;, or &lt;code&gt;&amp;lt;c-r&amp;gt;&amp;lt;c-r&amp;gt;=&lt;/code&gt;. Interestingly, the &lt;code&gt;0&lt;/code&gt; gets placed just before wherever the cursor was, and the file starts from the line below. So, if I had (&lt;code&gt;||&lt;/code&gt; being the cursor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo |b|ar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo 0bar&#xA;/*!&#xA;*  @author Robbie Yi JIANG, 29-Jan-2016 14:01:45&#xA;*&#xA;*  &#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't happen if I use &lt;code&gt;:call append(line('.'), readfile('foo.txt'))&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;foo.txt&lt;/code&gt; doesn't have any oddities:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ od -c foo.txt      &#xA;0000000   /   *   !  \n   *           @   a   u   t   h   o   r       R&#xA;0000020   o   b   b   i   e       Y   i       J   I   A   N   G   ,    &#xA;0000040   2   9   -   J   a   n   -   2   0   1   6       1   4   :   0&#xA;0000060   1   :   4   5  \n   *  \n   *          \n   *   /  \n&#xA;0000076&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tests were done using &lt;code&gt;vim -Nu NONE&lt;/code&gt;, 7.4.1129 and 7.4.1294. &lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-02-19T23:32:38.980" Title="Why does append(..., readfile()) add a zero when run using Ctrl-R?" Tags="|functions|text-generation|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="6578" PostTypeId="1" CreationDate="2016-02-20T06:06:09.910" Score="3" ViewCount="1083" Body="&lt;p&gt;I am always having problems, this time with java auto completion. I try to use the installation mentioned &lt;a href=&quot;https://github.com/bpowell/vim-android&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, so that I can use &lt;code&gt;vim&lt;/code&gt; to do my android development. However, after the installation, on editing of java files, it has errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;MainActivity.java&quot; 189L, 7779C&#xA;&quot;project.properties&quot; [New File]&#xA;Cannot open file &quot;project.properties&quot;&#xA;Error detected while processing function FindManifestFile:&#xA;line   44:&#xA;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 35, in &amp;lt;module&amp;gt;&#xA;vim.error: Vim(vimgrep):E480: No match: target=&#xA;Error detected while processing function &amp;lt;SNR&amp;gt;6_LoadFTPlugin:&#xA;line   17:&#xA;E170: Missing :endfor&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems like it is error of the plugin &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1785&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;javacomplete&lt;/code&gt;&lt;/a&gt;. How can I solve the problem? BTW, how can I locate error that &lt;code&gt;vim&lt;/code&gt; is having on starting so that I can solve them by myself? Thanks a lot.&lt;/p&gt;&#xA;" OwnerUserId="6380" LastEditorUserId="51" LastEditDate="2017-05-17T18:24:06.780" LastActivityDate="2017-05-17T18:24:06.780" Title="java completion" Tags="|autocompletion|filetype-java|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6579" PostTypeId="1" AcceptedAnswerId="6580" CreationDate="2016-02-20T08:06:37.893" Score="3" ViewCount="2459" Body="&lt;p&gt;I'm trying to search for the string &lt;code&gt;/c&lt;/code&gt; in the entire file, and when it's found I'd like to delete everything - including the &lt;code&gt;/c&lt;/code&gt; itself - up until the next occurrence of &lt;code&gt;/&lt;/code&gt; (but not the &lt;code&gt;/&lt;/code&gt; itself). For the purposes I'm using this for, you can assume that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;not every line will have a &lt;code&gt;/c&lt;/code&gt; in it, &lt;/li&gt;&#xA;&lt;li&gt;but when there is one in a line, it will always be the only one in that line, and &lt;/li&gt;&#xA;&lt;li&gt;there will always be a &lt;code&gt;/&lt;/code&gt; following it at some point in that same line.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I've learned of macros recently, and I found that if I create a macro with &lt;code&gt;qa/\/c&amp;lt;CR&amp;gt;dt/q&lt;/code&gt; and then run it a large number of times with &lt;code&gt;:g//normal 500@a&lt;/code&gt;, that it will make all the desired deletions (until it gets to the end of the file when it gives the error &lt;code&gt;E486: Pattern not found: \/c&lt;/code&gt;). But I was wondering if there is a simpler way to do it - with some kind of &lt;code&gt;:%s&lt;/code&gt; search command - that requires only one line. I'm quite certain there is, I just don't know how to do it. Alternatively, if a command or function could be created in the &lt;code&gt;_vimrc&lt;/code&gt; file that would accomplish this task, that would work too.&lt;/p&gt;&#xA;" OwnerUserId="6195" LastEditorUserId="205" LastEditDate="2016-02-20T08:31:12.560" LastActivityDate="2016-02-20T10:10:58.677" Title="Search entire file for a pattern; every time it's found, delete up until a certain character appears" Tags="|search|gvim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6580" PostTypeId="2" ParentId="6579" CreationDate="2016-02-20T08:37:41.327" Score="3" Body="&lt;p&gt;I think the following command should do what you need:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g:/c:s:/c[^/]*/:/:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Breaking it up:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:g&lt;/code&gt;: for every line that satisfies the condition&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;that it match &lt;code&gt;/c&lt;/code&gt; (note, I'm using &lt;code&gt;:&lt;/code&gt; as the regex delimiter for convenience, or I'd have to escape each &lt;code&gt;/&lt;/code&gt; that I use)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;run &lt;code&gt;s:/c[^/]*/:/:&lt;/code&gt;, which:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;looks for &lt;code&gt;/c&lt;/code&gt;, followed by any number of non-&lt;code&gt;/&lt;/code&gt; characters and then a &lt;code&gt;/&lt;/code&gt;, and&lt;/li&gt;&#xA;&lt;li&gt;replaces it with a &lt;code&gt;/&lt;/code&gt;. In effect, it leaves one &lt;code&gt;/&lt;/code&gt; in place of the matched text, which includes both the boundary &lt;code&gt;/&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Of course, you could have used your macro and run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g:/c:normal @a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The trick is to only run on those lines which match your condition.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-02-20T08:37:41.327" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6581" PostTypeId="2" ParentId="6579" CreationDate="2016-02-20T09:43:19.723" Score="4" Body="&lt;p&gt;I'm not sure what is the difficulty:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s:/c.*\ze/::&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s:/c.*/:/:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This searches in the whole file for &lt;code&gt;/c&lt;/code&gt; followed at some point by &lt;code&gt;/&lt;/code&gt; on the same line and: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;either replaces the pattern, excluding the final &lt;code&gt;/&lt;/code&gt;, with nothing (1st form)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;or, the whole pattern is replaced by a single &lt;code&gt;/&lt;/code&gt; (2nd form)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In order to avoid escaping &lt;code&gt;/&lt;/code&gt; I simply used a different substitute separator (&lt;code&gt;:&lt;/code&gt;). &lt;code&gt;.*&lt;/code&gt; means &quot;any number of unspecified characters, but only in the same line&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If more than one &lt;code&gt;/c.*/&lt;/code&gt; construct per line is possible, simply add &lt;code&gt;g&lt;/code&gt; at the end to replace them all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: the above match is greedy (matches until the last &lt;code&gt;/&lt;/code&gt; on the line, &quot;swallowing&quot; all others into the pattern). For a non-greedy match, use &lt;code&gt;[^/]*&lt;/code&gt; instead of &lt;code&gt;.*&lt;/code&gt;. There is also &lt;code&gt;.*\{-}&lt;/code&gt;, but it may not work with the 1st solution (before &lt;code&gt;\ze/&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-02-20T10:10:58.677" LastActivityDate="2016-02-20T10:10:58.677" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6582" PostTypeId="1" CreationDate="2016-02-20T09:54:13.213" Score="5" ViewCount="67" Body="&lt;p&gt;How can I specify a direction (for going backwards) for commands working on text objects like &lt;code&gt;2caw&lt;/code&gt;? E.g. I like to make &lt;code&gt;2caw&lt;/code&gt; replace &lt;code&gt;bbb ccc&lt;/code&gt; in &lt;code&gt;aaa bbb ccc ddd&lt;/code&gt; while on &lt;code&gt;c&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6512" LastActivityDate="2016-02-20T13:00:18.017" Title="How can I specify the movement direction for text objects?" Tags="|cursor-motions|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6583" PostTypeId="1" CreationDate="2016-02-20T10:28:06.323" Score="3" ViewCount="107" Body="&lt;p&gt;I have setup vim to use &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;nofollow&quot; title=&quot;Ag&quot;&gt;Ag&lt;/a&gt; for grepping and for use in the CtrlP plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For tag autocompletion, I am using &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;nofollow&quot; title=&quot;YouCompleteMe&quot;&gt;YouCompleteMe&lt;/a&gt;. To get autocompletion suggestions for functions throughout the whole project, I have to use ctags which generates tagfiles. I prefer to not use any files but just use Ag to dynamically look for autocompletion suggestions. I am aware of the fact that this could be possibly too slow, but I'd like to try anyway. Is there a way to configure YouCompleteMe to use Ag for autocompletion?&lt;/p&gt;&#xA;" OwnerUserId="6514" LastActivityDate="2016-02-20T10:28:06.323" Title="Can I use Ag in combination with YouCompleteMe for tag autocompletion?" Tags="|plugin-you-complete-me|the-silver-searcher|" AnswerCount="0" CommentCount="3" ClosedDate="2016-03-03T11:33:27.777" ContentLicense="CC BY-SA 3.0" />
  <row Id="6584" PostTypeId="1" AcceptedAnswerId="6586" CreationDate="2016-02-20T12:24:33.410" Score="3" ViewCount="429" Body="&lt;p&gt;Writing a vim plugin, I can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:InternalMethod()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for &lt;code&gt;InternalMethod&lt;/code&gt; to be local to the plugin environment. It will not be directly available to users nor overwrite their methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I perform a similar encapsulation on internal commands?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 InternalCommand &amp;lt;q-args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does this even make sense?&lt;/p&gt;&#xA;" OwnerUserId="2978" LastEditorUserId="205" LastEditDate="2016-02-20T17:06:59.407" LastActivityDate="2016-02-20T22:22:36.820" Title="How to declare commands local to a plugin?" Tags="|command-line|plugin-system|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6586" PostTypeId="2" ParentId="6584" CreationDate="2016-02-20T13:55:37.180" Score="4" Body="&lt;p&gt;Vim's help about defining a new command (&lt;code&gt;:com[mand][!] [{attr}...] {cmd} {rep}&lt;/code&gt; at &lt;code&gt;:h E174&lt;/code&gt;) states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Define a &lt;strong&gt;&lt;em&gt;user&lt;/em&gt;&lt;/strong&gt; command.  The name of the command is&#xA;      {cmd} and its replacement text is {rep}.  The command's&#xA;      attributes (see below) are {attr}.  If the command&#xA;      already exists, an error is reported, unless a ! is&#xA;      specified, in which case the command is redefined.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;em&gt;user&lt;/em&gt; attribute - in my understanding, commands (and mappings) are created for the user; this means that indeed it won't make much sense to have commands &quot;not directly available to users&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, since one can always call a function from a script, commands and mappings are user commodities :)&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-02-20T13:55:37.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6587" PostTypeId="1" AcceptedAnswerId="6590" CreationDate="2016-02-20T16:35:57.230" Score="3" ViewCount="66" Body="&lt;p&gt;If Vim command-line is being edited and the Vim instance receives a string due to &lt;code&gt;vim --remote-send KEYS&lt;/code&gt; executed on a shell somewhere, result is somewhat equivalent to pressing &lt;code&gt;Return&lt;/code&gt; in the command-line and typing the received &lt;code&gt;KEYS&lt;/code&gt; afterwards. Since the command that is unintentially executed can be hard to recover (an artificial example could be &lt;code&gt;!rm -rf *&lt;/code&gt;), is there a way to prevent this behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initial idea was to send e.g. &lt;code&gt;&amp;lt;Esc&amp;gt;&amp;lt;Esc&amp;gt;KEYS&lt;/code&gt; to discard any possible active input in the receiving Vim instance. This does quit a potentially active Insert mode and prevents &lt;code&gt;KEYS&lt;/code&gt; landing in the current buffer. But this is does not work for the command-line input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking of some autocommand-event to trigger user confirmation upon remote keys receipt, but none of available events looked right for the case.&lt;/p&gt;&#xA;" OwnerUserId="6517" LastActivityDate="2016-02-20T19:11:40.823" Title="Discard command-line contents when receiving remote keys" Tags="|command-line|autocmd|clientserver|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6588" PostTypeId="1" CreationDate="2016-02-20T18:02:45.550" Score="4" ViewCount="260" Body="&lt;p&gt;I have a symlinked directory as such:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/nested&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which points to this directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/whatever/yetanother/andanother/nested&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I launch gvim or command line vim (7.4, with the standard, built-in netrw for directory browsing) on my home directory, undesirable resolution of this symlink is performed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim ~&#xA;# now use netrw to navigate into &quot;nested&quot;&#xA;# now use netrw to open a file inside &quot;nested&quot;&#xA;# finally, use the :pwd command in the new file to see the problem&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if this is a netrw issue or an issue in vim proper. It may be an issue with vim proper, because in netrw when I open &lt;code&gt;~/nested&lt;/code&gt; I see &lt;code&gt;Netrw Directory Listing /home/myuserid/nested&lt;/code&gt; at the top of the screen, which is as I would like, but once I go into a file, vim shows the current directory as reported by &lt;code&gt;:pwd&lt;/code&gt; as &lt;code&gt;/home/myuserid/whatever/yetanother/andanother/nested&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the question, is there a setting to &quot;fix&quot; this, so that vim does not try to resolve my symlinks for me? I want the behavior to match my Linux command line, which doesn't do any such, I would say inappropriate, resolving for me.&lt;/p&gt;&#xA;" OwnerUserId="6519" LastEditorUserId="6519" LastEditDate="2016-02-20T22:39:04.470" LastActivityDate="2016-02-20T22:39:04.470" Title="Directory symlink browsing moves me to new location when autochdir is set" Tags="|command-line|gvim|netrw|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6589" PostTypeId="1" CreationDate="2016-02-20T18:18:13.660" Score="13" ViewCount="13737" Body="&lt;p&gt;Would like to perform a search and replace in a file with 12000 lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, if an occurrence of &lt;code&gt;^    SetFontSize 28&lt;/code&gt; exists after a &lt;code&gt;^Hide&lt;/code&gt; block and before the next &lt;code&gt;^Hide&lt;/code&gt; or &lt;code&gt;^Show&lt;/code&gt;, change &lt;code&gt;28&lt;/code&gt; to &lt;code&gt;18&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a snippet from the original file. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hide # Gear - Endgame&#xA;    ItemLevel &amp;gt;= 77&#xA;    Rarity = Magic&#xA;    LinkedSockets &amp;gt;= 3&#xA;    BaseType &quot;Runic Hatchet&quot;&#xA;    SetTextColor 140 190 255 # Magic Item Highlight&#xA;    SetFontSize 28&#xA;&#xA;Hide # Gear - Endgame&#xA;    ItemLevel &amp;gt;= 77&#xA;    Rarity = Magic&#xA;    Sockets &amp;gt;= 3&#xA;    BaseType &quot;Runic Hatchet&quot;&#xA;    SetTextColor 140 190 255 # Magic Item Highlight&#xA;    SetFontSize 28&#xA;&#xA;Show # Gear - Endgame&#xA;    ItemLevel &amp;gt;= 83&#xA;    Rarity = Normal&#xA;    Sockets &amp;lt; 3&#xA;    BaseType &quot;Tiger Hook&quot;&#xA;    SetTextColor 240 240 240 # Normal Item Highlight&#xA;    SetBackgroundColor 70 70 70&#xA;    SetFontSize 28&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The end result for one of the &lt;code&gt;Hide&lt;/code&gt; blocks should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hide # Gear - Endgame&#xA;    ItemLevel &amp;gt;= 77&#xA;    Rarity = Magic&#xA;    LinkedSockets &amp;gt;= 3&#xA;    BaseType &quot;Runic Hatchet&quot;&#xA;    SetTextColor 140 190 255 # Magic Item Highlight&#xA;    SetFontSize 18&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replacing &lt;code&gt;SetFontSize 28&lt;/code&gt; to &lt;code&gt;SetFontSize 18&lt;/code&gt;, but only if it appears in a &lt;code&gt;^Hide&lt;/code&gt; block. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The nasty regex I tried was:&#xA;&lt;code&gt;:%s/^Hide\(.*\)SetFontSize 28$/Hide\1SetFontSize 18/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But was told pattern not found. Please let me know if any additional information is required or if my request is unclear. &lt;/p&gt;&#xA;" OwnerUserId="6520" LastEditorUserId="205" LastEditDate="2016-02-20T18:23:03.817" LastActivityDate="2019-06-08T05:08:47.280" Title="Multiline Search and Replace" Tags="|search|replace|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6590" PostTypeId="2" ParentId="6587" CreationDate="2016-02-20T19:11:40.823" Score="4" Body="&lt;p&gt;One solution (not perfect) is to use &lt;code&gt;Ctrl-C&lt;/code&gt; instead, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --remote-send '&amp;lt;c-c&amp;gt;:echo &quot;test&quot;&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to work in command-line, normal, insert and visual mode, but not in operator-pending mode (at least in my test, after pressing &lt;code&gt;va&lt;/code&gt; from normal mode with no timeouts).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-02-20T19:11:40.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6591" PostTypeId="2" ParentId="6584" CreationDate="2016-02-20T22:22:36.820" Score="2" Body="&lt;p&gt;Yes it makes sense. I have a few plugins that define command not exported to the end user. Sometimes, we, plugin writers, are the user. And commands can help us provide more advanced stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I do it: I define the commands I need in the function scope where I use them, and finally (in a finally clause), I delete the commands I've defined for my own selfish needs.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-02-20T22:22:36.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6592" PostTypeId="1" AcceptedAnswerId="6595" CreationDate="2016-02-20T22:38:49.773" Score="3" ViewCount="280" Body="&lt;p&gt;I have MacVim 7.1 (patch level 903). When I drag a file onto it from the Finder, desktop, etc., it opens in a new tab. However, I would prefer that it open in a split. According to &lt;code&gt;:help drag-n-drop&lt;/code&gt;, holding down Ctrl should do this, but on my MacVim at least, this doesn't seem to do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible with MacVim?&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="51" LastEditDate="2016-02-22T23:35:34.813" LastActivityDate="2016-02-22T23:35:34.813" Title="How can I drag a file onto MacVim and make it open in a split, not a new tab?" Tags="|split|macvim|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6593" PostTypeId="1" AcceptedAnswerId="6594" CreationDate="2016-02-20T22:59:17.500" Score="4" ViewCount="205" Body="&lt;pre&gt;&lt;code&gt;Swap file &quot;.file.swp&quot; already exists!&#xA;[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I usually see this message when I accidentally &lt;code&gt;:edit&lt;/code&gt; the wrong file, i.e., one which I'm already editing in another terminal. My preferred solution in this case would be to tell Vim: oops, that was a mistake, please do nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both &lt;code&gt;[Q]uit&lt;/code&gt; and &lt;code&gt;[A]bort&lt;/code&gt; work, but they also add the file to the buffer list. I usually have a number of buffers open and page through them with the F3 and F4 keys, which I have mapped to &lt;code&gt;:up&lt;/code&gt; plus &lt;code&gt;:bp&lt;/code&gt; and &lt;code&gt;:bn&lt;/code&gt;, respectively. This means I have to manually &lt;code&gt;:bd&lt;/code&gt; the accidentally added file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This happens often enough that it's becoming annoying, and for some reason I don't seem to be learning from repeating this particular mistake. Is there a way to avoid adding the file to the buffer list? If not, what would be a good way to automate &quot;delete the last opened buffer&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/3227/whats-the-difference-between-quit-and-abort&quot;&gt;What&amp;#39;s the difference between &amp;quot;quit&amp;quot; and &amp;quot;abort&amp;quot;?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6523" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-02-21T02:17:17.670" Title="Swap choices: how can I &quot;skip&quot; instead of &quot;quit&quot; or &quot;abort&quot;?" Tags="|buffers|swap-file|quit|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6594" PostTypeId="2" ParentId="6593" CreationDate="2016-02-20T23:27:30.700" Score="5" Body="&lt;p&gt;I agree with you, and this seems like it could be improved, because one of those you would think would not create the buffer, and I just verified that I see the same behavior you describe, but if I were in your shoes what I would do to guarantee the buffer is immediately destroyed and which comes close to automatic is &lt;code&gt;[O]pen Read-Only&lt;/code&gt; followed immediately by a &lt;code&gt;:bw&lt;/code&gt; instead of &lt;code&gt;:bd&lt;/code&gt;. That's 3 additional keystrokes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One minor note, your question assumes you have a running session with other buffers that you want to keep, and this &lt;code&gt;:bw&lt;/code&gt; command will not quit that session in any context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I would note that the frequency of the &quot;Swap file exists&quot; message in general is a pet peeve of mine with GVim, even though I really adore GVim and Vim and even though I am aware of workarounds via remote_foreground, single sessions, and such. But I believe GVim should bring me to the editor that is already open, assuming it's another GVim instance. Bringing to front an existing GUI window already open on a certain file is a feature of GUI editors since &quot;the time immemorial.&quot;)&lt;/p&gt;&#xA;" OwnerUserId="6519" LastEditorUserId="6519" LastEditDate="2016-02-21T02:17:17.670" LastActivityDate="2016-02-21T02:17:17.670" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6595" PostTypeId="2" ParentId="6592" CreationDate="2016-02-21T00:53:56.883" Score="5" Body="&lt;p&gt;The &quot;Open files from applications&quot; preference in the General preference pane&#xA;gives more options on how dropped files should open, in case tabs are not&#xA;desired. See &lt;code&gt;:h macvim-drag-n-drop&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After setting up dropped files to be opened in splits, they will be opened in horizontal splits by default. If you prefer vertical splits, execute the following command. See &lt;code&gt;:h macvim-user-defaults&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;defaults write org.vim.MacVim MMVerticalSplit -bool TRUE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, you could add the following snippet to your &lt;code&gt;~/.vimrc&lt;/code&gt; file to automatically set these defaults.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('gui_running') &amp;amp;&amp;amp; has('macunix')&#xA;    &quot; open dropped files in vertical splits&#xA;    call system('defaults write org.vim.MacVim MMOpenLayout -bool TRUE')&#xA;    call system('defaults write org.vim.MacVim MMVerticalSplit -bool TRUE')&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6206" LastActivityDate="2016-02-21T00:53:56.883" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6596" PostTypeId="1" AcceptedAnswerId="6600" CreationDate="2016-02-21T01:19:13.347" Score="4" ViewCount="111" Body="&lt;p&gt;Writing unit tests in RSpec, I frequently change something like this,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;it 'eats pizza' do&#xA;  pizza = build(:pizza)&#xA;  expect(subject.eats?(pizza)).to be_true&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to this,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let(:pizza) { build(:pizza) }&#xA;&#xA;it 'eats pizza' do&#xA;  expect(subject.eats?(pizza)).to be_true&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to automate part of this to easily (and repeatably) convert&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name = value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let(:name) { value }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've done it with a macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mzIlet(:&amp;lt;Esc&amp;gt;ea)&amp;lt;Esc&amp;gt;f=r{A }&amp;lt;Esc&amp;gt;`z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I'd like something I can put in my vimrc. I came up with a command as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bang Let execute &quot;normal! mzIlet\&amp;lt;bang&amp;gt;(:\&amp;lt;Esc&amp;gt;ea)\&amp;lt;Esc&amp;gt;f=r{A }\&amp;lt;Esc&amp;gt;`z&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is a little better, since I can run &lt;code&gt;:Let&lt;/code&gt; to get &lt;code&gt;let(:name)&lt;/code&gt; or &lt;code&gt;:Let!&lt;/code&gt; to get &lt;code&gt;let!(:name)&lt;/code&gt;. But it's not repeatable with the dot command (though &lt;code&gt;@:&lt;/code&gt; is a decent consolation in this case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Going one step further, this searches backwards for the first &lt;code&gt;let&lt;/code&gt;, &lt;code&gt;context&lt;/code&gt;, or &lt;code&gt;describe&lt;/code&gt; line and puts the &lt;code&gt;let&lt;/code&gt; line below it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bang Let execute &quot;normal! dd?\\v^%(\\s+let&amp;gt;)|%(\\s*%(context|describe)&amp;gt;)\&amp;lt;CR&amp;gt;p==Ilet\&amp;lt;bang&amp;gt;(:\&amp;lt;Esc&amp;gt;ea)\&amp;lt;Esc&amp;gt;f=r{A }\&amp;lt;Esc&amp;gt;`'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Really feels like something that's outgrowing a command, and should be implemented as a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make this repeatable? Is a command not the way to go with this? Looks like tpope's repeat.vim can make key-maps repeatable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Update&lt;/em&gt;&#xA;The implementation has changed, as the problem is a better fit for pattern matching &amp;amp; substitution than I originally realized. I haven't made it &lt;code&gt;.&lt;/code&gt; repeatable yet, but that's the next step (and thanks to @saginaw for the advice below).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! RSpecLet(bang)&#xA;  delete&#xA;  normal! mz&#xA;&#xA;  call MoveAssignment()&#xA;  call ReplaceWithLet(a:bang)&#xA;&#xA;  normal! `z&#xA;endf&#xA;&#xA;func! MoveAssignment()&#xA;  call search('\v^\s*&amp;lt;let&amp;gt;|&amp;lt;context&amp;gt;|&amp;lt;describe&amp;gt;', 'b')&#xA;  put&#xA;  normal! ==&#xA;endf&#xA;&#xA;func! ReplaceWithLet(bang)&#xA;  execute 'substitute/\v^\s+\zs'&#xA;        \ '(\w+)%(\s*\=\s*)(.*\S)\s*$/'&#xA;        \ 'let'.a:bang.'(:\1) { \2 }'&#xA;endf&#xA;command! -bang Let call RSpecLet('&amp;lt;bang&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1855" LastEditorUserId="1855" LastEditDate="2016-02-21T16:49:45.327" LastActivityDate="2016-02-22T14:36:19.673" Title="Make a frequent RSpec edit easy &amp; repeatable" Tags="|key-bindings|macro|repeated-commands|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6597" PostTypeId="1" CreationDate="2016-02-21T04:55:34.657" Score="4" ViewCount="246" Body="&lt;p&gt;I am trying to get VIM to jump to the file listed in the error.  So the following is the error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|| 1) test01(ErrorTest0)&#xA;|| java.lang.NullPointerException&#xA;||  at Line.equals(Line.java:43)&#xA;||  at ErrorTest0.test01(ErrorTest0.java:22)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried the following errorformat &lt;code&gt;set errorformat='%.%#\ at\ %.%#(%f:%l)'&#xA;&lt;/code&gt;, but it does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So all I want it to do is jump to the file &lt;code&gt;Line.java&lt;/code&gt; line 43 when I click on it.  Am I missing something in errorfomat?&lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="51" LastEditDate="2017-05-17T18:24:24.723" LastActivityDate="2017-05-17T18:24:24.723" Title="errorformat for Java junit output" Tags="|errorformat|filetype-java|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6598" PostTypeId="1" AcceptedAnswerId="6609" CreationDate="2016-02-21T09:00:37.157" Score="1" ViewCount="1511" Body="&lt;p&gt;I have realized that the quickfix window isn't opening automatically when it's supposed to. I have tested this on both Gvim and vim 7.4 on Windows 10 Version   10.0.10586 Build 10586. I have a few plugins installed but I want to know how I might debug this first before I strip my vim configuration down to a minimum working example. Where do I start looking for the problem?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 18 2016 07:00:12)&#xA;MS-Windows 32-bit GUI version&#xA;Included patches: 1-1345&#xA;Compiled by jrinehar@JRINEHAR&#xA;Huge version with GUI.  Features included (+) or not (-):&#xA;+acl                +emacs_tags         +modify_fname       -sun_workshop&#xA;+arabic             +eval               +mouse              +syntax&#xA;+autocmd            +ex_extra           +mouseshape         +tag_binary&#xA;+balloon_eval       +extra_search       +multi_byte_ime/dyn +tag_old_static&#xA;+browse             +farsi              +multi_lang         -tag_any_white&#xA;++builtin_terms     +file_in_path       -mzscheme           -tcl&#xA;+byte_offset        +find_in_path       +netbeans_intg      -tgetent&#xA;+channel            +float              -ole                -termresponse&#xA;+cindent            +folding            +path_extra         +textobjects&#xA;+clientserver       -footer             -perl               +title&#xA;+clipboard          +gettext/dyn        +persistent_undo    +toolbar&#xA;+cmdline_compl      -hangul_input       -postscript         +user_commands&#xA;+cmdline_hist       +iconv/dyn          +printer            +vertsplit&#xA;+cmdline_info       +insert_expand      +profile            +virtualedit&#xA;+comments           +job                +python/dyn         +visual&#xA;+conceal            +jumplist           -python3            +visualextra&#xA;+cryptv             +keymap             +quickfix           +viminfo&#xA;+cscope             +langmap            +reltime            +vreplace&#xA;+cursorbind         +libcall            +rightleft          +wildignore&#xA;+cursorshape        +linebreak          -ruby               +wildmenu&#xA;+dialog_con_gui     +lispindent         +scrollbind         +windows&#xA;+diff               +listcmds           +signs              +writebackup&#xA;+digraphs           +localmap           +smartindent        -xfontset&#xA;-directx            +lua/dyn            -sniff              -xim&#xA;-dnd                +menu               +startuptime        -xterm_save&#xA;-ebcdic             +mksession          +statusline         +xpm_w32&#xA;   system vimrc file: &quot;$VIM\vimrc&quot;&#xA;     user vimrc file: &quot;$HOME\_vimrc&quot;&#xA; 2nd user vimrc file: &quot;$HOME\vimfiles\vimrc&quot;&#xA; 3rd user vimrc file: &quot;$VIM\_vimrc&quot;&#xA;      user exrc file: &quot;$HOME\_exrc&quot;&#xA;  2nd user exrc file: &quot;$VIM\_exrc&quot;&#xA;  system gvimrc file: &quot;$VIM\gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME\_gvimrc&quot;&#xA;2nd user gvimrc file: &quot;$HOME\vimfiles\gvimrc&quot;&#xA;3rd user gvimrc file: &quot;$VIM\_gvimrc&quot;&#xA;    system menu file: &quot;$VIMRUNTIME\menu.vim&quot;&#xA;Compilation: gcc -Iproto -DWIN32 -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -DHAVE_PATHDEF -DFEAT_HUGE -DHAVE_GETTEXT -DHAVE_LOCALE_H -DDYNAMIC_GETTEXT -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG -DFEAT_CHANNEL -DFEAT_GUI_W32 -DFEAT_CLIPBOARD -DFEAT_MBYTE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DDYNAMIC_ICONV -pipe -w -march=i686 -Wall -IC:/Lua/include -IC:/Lua -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=&quot;lua53.dll&quot; -DFEAT_PYTHON  -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=&quot;python27.dll&quot; -DFEAT_XPM_W32 -I xpm/x86/include -I xpm/x86/../include -O3 -fomit-frame-pointer -freg-struct-return -s&#xA;Linking: gcc -Iproto -DWIN32 -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -DHAVE_PATHDEF -DFEAT_HUGE -DHAVE_GETTEXT -DHAVE_LOCALE_H -DDYNAMIC_GETTEXT -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG -DFEAT_CHANNEL -DFEAT_GUI_W32 -DFEAT_CLIPBOARD -DFEAT_MBYTE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DDYNAMIC_ICONV -pipe -w -march=i686 -Wall -IC:/Lua/include -IC:/Lua -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=&quot;lua53.dll&quot; -DFEAT_PYTHON  -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=&quot;python27.dll&quot; -DFEAT_XPM_W32 -I xpm/x86/include -I xpm/x86/../include -O3 -fomit-frame-pointer -freg-struct-return -s -mwindows -o gvim.exe -lkernel32 -luser32 -lgdi32 -ladvapi32 -lcomdlg32 -lcomctl32 -lversion -lwsock32 -Lxpm/x86/lib -lXpm -lole32 -luuid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2062" LastActivityDate="2018-10-04T16:24:36.223" Title="Quickfix Window not Opening Automatically" Tags="|quickfix|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6599" PostTypeId="1" CreationDate="2016-02-21T09:47:58.087" Score="2" ViewCount="84" Body="&lt;p&gt;What is difference between autoformat and autoindent? What are most popular solutions in text formating in vim of both of these methods? &lt;/p&gt;&#xA;" OwnerUserId="6399" LastEditorUserId="4939" LastEditDate="2016-02-21T11:52:20.453" LastActivityDate="2016-02-22T23:11:23.353" Title="Difference between autoformat and autoindent" Tags="|indentation|formatting|plugin-vim-autoformat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6600" PostTypeId="2" ParentId="6596" CreationDate="2016-02-21T11:26:50.203" Score="2" Body="&lt;p&gt;To make your first command repeatable with dot, you could try the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:RSpecLet(bang)&#xA;    if a:bang ==# '!'&#xA;        execute &quot;normal! mzIlet!(:\eea)\ef=r{A }\e`z&quot;&#xA;        call repeat#set(&quot;\&amp;lt;Plug&amp;gt;RSpecBangLet&quot;)&#xA;    else&#xA;        execute &quot;normal! mzIlet(:\eea)\ef=r{A }\e`z&quot;&#xA;        call repeat#set(&quot;\&amp;lt;Plug&amp;gt;RSpecLet&quot;)&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;RSpecLet     :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;RSpecLet('')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;RSpecBangLet :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;RSpecLet('!')&amp;lt;CR&amp;gt;&#xA;&#xA;command! -bang Let call s:RSpecLet('&amp;lt;bang&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that it calls the &lt;code&gt;repeat#set()&lt;/code&gt; function provided by the &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow&quot;&gt;repeat plugin&lt;/a&gt; from tpope, so you would need to install the latter to make the previous code work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to install a plugin, it can be done, but the code would be around 40 lines longer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the code to be a bit easier to understand, you could break down your editions into small chunks (each of them could be preceded by a comment if needed) like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:RSpecLet(bang)&#xA;    normal! mz&#xA;&#xA;    if a:bang ==# '!'&#xA;        normal! Ilet!(:&#xA;    else&#xA;        normal! Ilet(:&#xA;    endif&#xA;&#xA;    normal! ea)&#xA;    normal! f=r{A }&#xA;    normal! `z&#xA;&#xA;    if a:bang ==# '!'&#xA;        call repeat#set(&quot;\&amp;lt;Plug&amp;gt;RSpecBangLet&quot;)&#xA;    else&#xA;        call repeat#set(&quot;\&amp;lt;Plug&amp;gt;RSpecLet&quot;)&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;RSpecLet     :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;RSpecLet('')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;RSpecBangLet :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;RSpecLet('!')&amp;lt;CR&amp;gt;&#xA;&#xA;command! -bang Let call s:RSpecLet('&amp;lt;bang&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To make the 2nd command repeatable with dot, you could try the following code, similar to the previous one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:RSpecLet(bang)&#xA;    if a:bang ==# '!'&#xA;        execute &quot;normal! dd?\\v^%(\\s+let&amp;gt;)|%(\\s*%(context|describe)&amp;gt;)\rp==Ilet!(:\eea)\ef=r{A }\e`'&quot;&#xA;        call repeat#set(&quot;\&amp;lt;Plug&amp;gt;RSpecBangLet&quot;)&#xA;    else&#xA;        execute &quot;normal! dd?\\v^%(\\s+let&amp;gt;)|%(\\s*%(context|describe)&amp;gt;)\rp==Ilet(:\eea)\ef=r{A }\e`'&quot;&#xA;        call repeat#set(&quot;\&amp;lt;Plug&amp;gt;RSpecLet&quot;)&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;RSpecLet     :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;RSpecLet('')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;RSpecBangLet :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;RSpecLet('!')&amp;lt;CR&amp;gt;&#xA;&#xA;command! -bang Let call s:RSpecLet('&amp;lt;bang&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've read your edit and I think you're right, your new implementation is probably better.&#xA;If you want to make it repeatable, here's a possible solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! RSpecLet(bang)&#xA;  delete&#xA;  normal! mz&#xA;&#xA;  call MoveAssignment()&#xA;  call ReplaceWithLet(a:bang)&#xA;&#xA;  execute 'call repeat#set(&quot;\&amp;lt;Plug&amp;gt;RSpec' . a:bang . 'Let&quot;)'&#xA;  normal! `z&#xA;endf&#xA;&#xA;func! MoveAssignment()&#xA;  call search('\v^\s*&amp;lt;let&amp;gt;|&amp;lt;context&amp;gt;|&amp;lt;describe&amp;gt;', 'b')&#xA;  put&#xA;  normal! ==&#xA;endf&#xA;&#xA;func! ReplaceWithLet(bang)&#xA;  execute 'substitute/\v^\s+\zs'&#xA;        \ '(\w+)%(\s*\=\s*)(.*\S)\s*$/'&#xA;        \ 'let'.a:bang.'(:\1) { \2 }'&#xA;endf&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;RSpecLet  :&amp;lt;C-U&amp;gt;call RSpecLet('')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;RSpec!Let :&amp;lt;C-U&amp;gt;call RSpecLet('!')&amp;lt;CR&amp;gt;&#xA;&#xA;command! -bang Let call RSpecLet('&amp;lt;bang&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't want to install the repeat.vim plugin, here's another possible solution (which copies the bare minimum from the original plugin):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! RSpecLet(bang)&#xA;  delete&#xA;  normal! mz&#xA;&#xA;  call MoveAssignment()&#xA;  call ReplaceWithLet(a:bang)&#xA;&#xA;  execute 'call RepeatSet(&quot;\&amp;lt;Plug&amp;gt;RSpec' . a:bang . 'Let&quot;)'&#xA;  normal! `z&#xA;endf&#xA;&#xA;func! MoveAssignment()&#xA;  call search('\v^\s*&amp;lt;let&amp;gt;|&amp;lt;context&amp;gt;|&amp;lt;describe&amp;gt;', 'b')&#xA;  put&#xA;  normal! ==&#xA;endf&#xA;&#xA;func! ReplaceWithLet(bang)&#xA;  execute 'substitute/\v^\s+\zs'&#xA;        \ '(\w+)%(\s*\=\s*)(.*\S)\s*$/'&#xA;        \ 'let'.a:bang.'(:\1) { \2 }'&#xA;endf&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;RSpecLet  :&amp;lt;C-U&amp;gt;call RSpecLet('')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;RSpec!Let :&amp;lt;C-U&amp;gt;call RSpecLet('!')&amp;lt;CR&amp;gt;&#xA;&#xA;command! -bang Let call RSpecLet('&amp;lt;bang&amp;gt;')&#xA;&#xA;func! RepeatSet(sequence,...)&#xA;    let g:repeat_sequence = a:sequence&#xA;    let g:repeat_count = a:0 ? a:1 : v:count&#xA;    let g:repeat_tick = b:changedtick&#xA;endf&#xA;&#xA;func! RepeatDot(count)&#xA;    if g:repeat_tick == b:changedtick&#xA;      let c = g:repeat_count&#xA;      let cnt = (a:count ? a:count : (c ? c : ''))&#xA;      call feedkeys(g:repeat_sequence, 'i')&#xA;      call feedkeys(cnt, 'ni')&#xA;    else&#xA;      call feedkeys((a:count ? a:count : '') . '.', 'ni')&#xA;    endif&#xA;endf&#xA;&#xA;func! RepeatWrap(command)&#xA;  let sync_test = (g:repeat_tick == b:changedtick)&#xA;  execute 'normal! ' . a:command . 'zv'&#xA;  if sync_test&#xA;    let g:repeat_tick = b:changedtick&#xA;  endif&#xA;endf&#xA;&#xA;let g:repeat_tick = -1&#xA;augroup Repeat&#xA;  autocmd!&#xA;  autocmd BufLeave,BufWritePre,BufReadPre * let g:repeat_tick =&#xA;          \ (g:repeat_tick == b:changedtick || g:repeat_tick == 0) ? 0 : -1&#xA;&#xA;  autocmd BufEnter,BufWritePost * if g:repeat_tick == 0 |&#xA;          \ let g:repeat_tick = b:changedtick |&#xA;          \ endif&#xA;augroup END&#xA;&#xA;nmap .     &amp;lt;Plug&amp;gt;(RepeatDot)&#xA;nmap u     &amp;lt;Plug&amp;gt;(RepeatUndo)&#xA;nmap U     &amp;lt;Plug&amp;gt;(RepeatUndoLine)&#xA;nmap &amp;lt;C-R&amp;gt; &amp;lt;Plug&amp;gt;(RepeatRedo)&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(RepeatDot)      :&amp;lt;C-U&amp;gt;call RepeatDot(v:count)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(RepeatUndo)     :&amp;lt;C-U&amp;gt;call RepeatWrap('u')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(RepeatUndoLine) :&amp;lt;C-U&amp;gt;call RepeatWrap('U')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(RepeatRedo)     :&amp;lt;C-U&amp;gt;call RepeatWrap(&quot;\&amp;lt;Lt&amp;gt;C-R&amp;gt;&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-02-21T21:27:16.310" LastActivityDate="2016-02-21T21:27:16.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6601" PostTypeId="1" AcceptedAnswerId="8533" CreationDate="2016-02-21T19:26:12.797" Score="3" ViewCount="239" Body="&lt;p&gt;I am searching for a plugin manager that has the option to install specific plugins only from tags on GitHub. I don't want to need to specify the tag. I want it to automatically use the newest tag. This would be a good option for plugins that do not keep a stable master branch, but do tag releases.&lt;/p&gt;&#xA;" OwnerUserId="1410" LastActivityDate="2016-07-01T04:30:49.077" Title="What plugin manager allows installing plugins from tags" Tags="|plugin-managers|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6602" PostTypeId="1" AcceptedAnswerId="6606" CreationDate="2016-02-21T19:52:03.650" Score="5" ViewCount="2771" Body="&lt;p&gt;I tried to change the syntax highlighting, by copying &lt;code&gt;/usr/share/vim/vim74/syntax/html.vim&lt;/code&gt; to &lt;code&gt;~/.vim/after/syntax/html.vim&lt;/code&gt;. Then I changed the syntax highlighting file, but I don't see any changes. &lt;code&gt;filetype&lt;/code&gt; is set properly, and when I change something in &lt;code&gt;/usr/share/vim/vim74/syntax/html.vim&lt;/code&gt;, I can see the changes. Is there anything I need to do to &quot;activate&quot; the &lt;code&gt;after/syntax&lt;/code&gt; folder for highlighting?&lt;/p&gt;&#xA;" OwnerUserId="6154" LastActivityDate="2023-07-29T00:13:23.327" Title="Personal syntax highlighting" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6603" PostTypeId="1" CreationDate="2016-02-21T20:19:02.833" Score="4" ViewCount="96" Body="&lt;p&gt;I recently switched to base16_default dark as my color theme.  I love it, but it's the first theme I've used where a modified buffer's airline bar doesn't change color.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do, however get the [+] symbol indicating the buffer has unsaved changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've set my iterm2 colors to preset 'base16-default.dark', my vim theme to 'base-16-default' and my airline theme to &lt;a href=&quot;https://github.com/vim-airline/vim-airline-themes/blob/master/autoload/airline/themes/base16_default.vim&quot; rel=&quot;nofollow&quot; title=&quot;this&quot;&gt;this&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6527" LastActivityDate="2016-02-21T20:19:02.833" Title="How do I edit my Airline config such that modified files will have a differently colored bar?" Tags="|plugin-airline|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6604" PostTypeId="1" AcceptedAnswerId="7124" CreationDate="2016-02-21T20:42:25.797" Score="5" ViewCount="4903" Body="&lt;p&gt;This is a Python 2.7 question. I have a custom python 2.7, that I have compiled and have been using successfully across my system. My custom python has the YAML modules installed as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The system wide Python 2.7 is in it's usual path on OSX:&#xA;&lt;code&gt;/System/Library/Frameworks/Python.framework/Versions/2.7/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyPythonFunction() abort&#xA;    echo a:testString&#xA;    python &amp;lt;&amp;lt; EOF&#xA;    import yaml&#xA;    print yaml&#xA;    print &quot;PYTHON: My Python function.&quot;&#xA;    EOF&#xA;    return 1&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run a Python based function as the one above, I can see that the system wide Python2.7 is active. So for that reason my YAML import fails, as I do not have YAML installed under my system Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to tell VIM to use my custom Python2.7 that lives inside:&#xA;&lt;code&gt;/Users/me/apps/Darwin64/python2.7/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or somehow call my custom YAML module?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have done a bit of research and I think there are things that I can tweak through VIM's Python modules (import vim) and there is a Python2 &lt;code&gt;rtp&lt;/code&gt; config. However I am not sure how to set those up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="5328" LastEditDate="2016-04-01T10:33:41.337" LastActivityDate="2017-07-26T14:36:37.193" Title="How to access a custom python module inside vim?" Tags="|vimscript|vimscript-python|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6605" PostTypeId="2" ParentId="2403" CreationDate="2016-02-21T23:43:37.903" Score="4" Body="&lt;p&gt;Since a couple of weeks, &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;nofollow&quot;&gt;YouCompleteMe&lt;/a&gt; does support Python3 completion using Jedi via a JediHTTP wrapper. Only install YouCompleteMe (no need to install jedi-vim) according to the installation instructions and add the following line to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_python_binary_path = '/usr/bin/python3'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This forces YCM to &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe#python-semantic-completion&quot; rel=&quot;nofollow&quot;&gt;use Jedi with Python3&lt;/a&gt; (default is to use Jedi with the same Python interpreter that is used by the ycmd server, which is Python2).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works no matter if your Vim is compiled with or without the &lt;code&gt;+python3&lt;/code&gt; flag - you get Python3 autocompletion (and documentation look up and more).&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2016-02-21T23:43:37.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6606" PostTypeId="2" ParentId="6602" CreationDate="2016-02-22T01:56:14.880" Score="10" Body="&lt;p&gt;To change the syntax highlighting of a filetype by copying &lt;code&gt;$VIMRUNTIME/syntax/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; to your &lt;code&gt;~/.vim&lt;/code&gt; directory, the proper place to copy it is &lt;code&gt;~/.vim/syntax/&lt;/code&gt;, not &lt;code&gt;~/.vim/after/syntax/&lt;/code&gt;. Vim will then use your syntax file &lt;em&gt;instead&lt;/em&gt; &lt;em&gt;of&lt;/em&gt; the one in &lt;code&gt;$VIMRUNTIME/syntax&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Your &lt;code&gt;~/.vim/after/syntax/&lt;/code&gt; directory is the proper place for files that make relatively small tweaks to the syntax highlighting, such as changing the colors of highlight groups. The problem with making major changes in the &lt;code&gt;~/.vim/after/syntax/&lt;/code&gt; directory is that the behavior of some of Vim's syntax rules depends on the order in which the rules are executed, and any rules in &lt;code&gt;~/.vim/after/syntax&lt;/code&gt; are going to be executed &lt;em&gt;after&lt;/em&gt; the rules in &lt;code&gt;$VIMRUNTIME/syntax&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I think the reason that the changes you make to &lt;code&gt;~/.vim/after/syntax/html.vim&lt;/code&gt; are not showing up is because of this line near the bottom of &lt;code&gt;$VIMRUNTIME/syntax/html.vim&lt;/code&gt;,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let b:current_syntax = &amp;quot;html&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and this block at the top of &lt;code&gt;$VIMRUNTIME/syntax/html.vim&lt;/code&gt;, which is presumably still in your copy in &lt;code&gt;~/.vim/after/syntax/html.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(&amp;quot;main_syntax&amp;quot;)&#xA;  if version &amp;lt; 600&#xA;    syntax clear&#xA;  elseif exists(&amp;quot;b:current_syntax&amp;quot;)&#xA;    finish&#xA;  endif&#xA;  let main_syntax = 'html'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;That block is detecting that &lt;code&gt;b:current_syntax&lt;/code&gt; has already been set, so it terminates the script at that point by executing &lt;code&gt;finish&lt;/code&gt;. None of your changes to that file are being executed.&lt;/p&gt;&#xA;&lt;p&gt;To find where &lt;code&gt;$VIMRUNTIME&lt;/code&gt; points to on your system, enter the command &lt;code&gt;:echo $VIMRUNTIME&lt;/code&gt; in Vim.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="2055" LastEditDate="2023-07-29T00:13:23.327" LastActivityDate="2023-07-29T00:13:23.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6607" PostTypeId="1" CreationDate="2016-02-22T02:42:34.220" Score="2" ViewCount="215" Body="&lt;p&gt;When you tweak your &lt;code&gt;.vimrc&lt;/code&gt; more and more, it is easy to lose the overview about all settings, functions etc. What are some good ways to structure a long &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2016-02-22T02:42:34.220" Title="What is a good way to structure a long .vimrc?" Tags="|vimrc|folding|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ClosedDate="2016-02-22T07:33:55.123" ContentLicense="CC BY-SA 3.0" />
  <row Id="6608" PostTypeId="2" ParentId="3814" CreationDate="2016-02-22T02:42:34.220" Score="13" Body="&lt;p&gt;It is a good idea to first define your own categories in your &lt;code&gt;.vimrc&lt;/code&gt; (like a list with sublists and subsublists) and add all your plugins/settings/functions to the respective categories. Combined with customized folding this can work great:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/68zh4.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/68zh4.gif&quot; alt=&quot;Example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example above shows possible categories that I find helpful to structure my &lt;code&gt;.vimrc&lt;/code&gt;. It uses the following customized fold settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot;  THIS IS A CATEGORY  &quot;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot;&quot; Autofolding .vimrc&#xA;&quot; see http://vimcasts.org/episodes/writing-a-custom-fold-expression/&#xA;&quot;&quot;&quot; defines a foldlevel for each line of code&#xA;function! VimFolds(lnum)&#xA;  let s:thisline = getline(a:lnum)&#xA;  if match(s:thisline, '^&quot;&quot; ') &amp;gt;= 0&#xA;    return '&amp;gt;2'&#xA;  endif&#xA;  if match(s:thisline, '^&quot;&quot;&quot; ') &amp;gt;= 0&#xA;    return '&amp;gt;3'&#xA;  endif&#xA;  let s:two_following_lines = 0&#xA;  if line(a:lnum) + 2 &amp;lt;= line('$')&#xA;    let s:line_1_after = getline(a:lnum+1)&#xA;    let s:line_2_after = getline(a:lnum+2)&#xA;    let s:two_following_lines = 1&#xA;  endif&#xA;  if !s:two_following_lines&#xA;      return '='&#xA;    endif&#xA;  else&#xA;    if (match(s:thisline, '^&quot;&quot;&quot;&quot;&quot;') &amp;gt;= 0) &amp;amp;&amp;amp;&#xA;       \ (match(s:line_1_after, '^&quot;  ') &amp;gt;= 0) &amp;amp;&amp;amp;&#xA;       \ (match(s:line_2_after, '^&quot;&quot;&quot;&quot;') &amp;gt;= 0)&#xA;      return '&amp;gt;1'&#xA;    else&#xA;      return '='&#xA;    endif&#xA;  endif&#xA;endfunction&#xA;&#xA;&quot;&quot;&quot; defines a foldtext&#xA;function! VimFoldText()&#xA;  &quot; handle special case of normal comment first&#xA;  let s:info = '('.string(v:foldend-v:foldstart).' l)'&#xA;  if v:foldlevel == 1&#xA;    let s:line = ' ◇ '.getline(v:foldstart+1)[3:-2]&#xA;  elseif v:foldlevel == 2&#xA;    let s:line = '   ●  '.getline(v:foldstart)[3:]&#xA;  elseif v:foldlevel == 3&#xA;    let s:line = '     ▪ '.getline(v:foldstart)[4:]&#xA;  endif&#xA;  if strwidth(s:line) &amp;gt; 80 - len(s:info) - 3&#xA;    return s:line[:79-len(s:info)-3+len(s:line)-strwidth(s:line)].'...'.s:info&#xA;  else&#xA;    return s:line.repeat(' ', 80 - strwidth(s:line) - len(s:info)).s:info&#xA;  endif&#xA;endfunction&#xA;&#xA;&quot;&quot;&quot; set foldsettings automatically for vim files&#xA;augroup fold_vimrc&#xA;  autocmd!&#xA;  autocmd FileType vim &#xA;                   \ setlocal foldmethod=expr |&#xA;                   \ setlocal foldexpr=VimFolds(v:lnum) |&#xA;                   \ setlocal foldtext=VimFoldText() |&#xA;     &quot;              \ set foldcolumn=2 foldminlines=2&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To define your own categories and subcategories use the following syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot;  Category  &quot;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot;&quot; Subcategory&#xA;&quot;&quot;&quot; Subsubcategory&#xA;&quot; Just a comment, gets ignored no matter where&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The top level category can be created really easy if you use &lt;a href=&quot;https://github.com/honza/vim-snippets&quot; rel=&quot;noreferrer&quot;&gt;vim-snippets&lt;/a&gt; (e.g. with &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;noreferrer&quot;&gt;UltiSnips&lt;/a&gt;): Just expand the &lt;code&gt;box&lt;/code&gt; or &lt;code&gt;bbox&lt;/code&gt; snippet provided by vim-snippets (write &lt;code&gt;box&lt;/code&gt; or &lt;code&gt;bbox&lt;/code&gt; and press the expand trigger).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To toggle folds open and closed even faster by pressing space twice:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;\&amp;lt;space&amp;gt;&quot;&#xA;&quot; Toggle folds&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;&amp;lt;Space&amp;gt; @=(foldlevel('.')?'za':&quot;\&amp;lt;Space&amp;gt;&quot;)&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;leader&amp;gt;&amp;lt;space&amp;gt; zf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way you have an well structured &lt;code&gt;.vimrc&lt;/code&gt; which can be navigated easily.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2016-02-22T02:42:34.220" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6609" PostTypeId="2" ParentId="6598" CreationDate="2016-02-22T09:52:47.697" Score="2" Body="&lt;p&gt;In &lt;a href=&quot;https://github.com/LucHermitte/vim-build-tools-wrapper&quot; rel=&quot;nofollow&quot;&gt;BuildToolWrappers&lt;/a&gt;, I have encapsulated &lt;code&gt;:make&lt;/code&gt; + &lt;code&gt;:cwindow&lt;/code&gt; behind another &lt;code&gt;:Make&lt;/code&gt; command. (the command does many more things, but this is the part you are looking for)&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-02-22T17:10:51.757" LastActivityDate="2016-02-22T17:10:51.757" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6610" PostTypeId="1" AcceptedAnswerId="6611" CreationDate="2016-02-22T10:48:43.360" Score="7" ViewCount="1693" Body="&lt;p&gt;I wonder if there's already a Vim syntax highlighting in existence that I could use out-of-the-box or modify if it's close to what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The log file format I want to highlight stuff in looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;14:37:16.255 T#4711 The didgeridoo checked out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More formally:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Each line starts with a timestamp of the format &lt;code&gt;HH:MM:SS.mmm&lt;/code&gt;, so it's fixed-width 12 characters.&lt;/li&gt;&#xA;&lt;li&gt;After the timestamp is a thread identifier that starts with &lt;code&gt;T#&lt;/code&gt; and is followed by 1 to 5 digits.&lt;/li&gt;&#xA;&lt;li&gt;After the identifier comes the actual log message&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'd like to see the timestamp and identifier highlighted in separate colors from the log message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If nothing like that already exists, what would be a reasonable way for me to add such a &quot;filetype&quot; myself?&lt;/p&gt;&#xA;" OwnerUserId="6107" LastEditorUserId="205" LastEditDate="2016-02-23T03:10:28.657" LastActivityDate="2018-06-14T21:51:30.270" Title="Does a Vim syntax highlighting file already exist for this log file format, or how can I easily make one?" Tags="|syntax-highlighting|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6611" PostTypeId="2" ParentId="6610" CreationDate="2016-02-22T10:54:08.503" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/dzeban/vim-log-syntax/tree/master/syntax&quot; rel=&quot;nofollow&quot;&gt;vim-log-syntax&lt;/a&gt; by Alex Dzyoba seems to do a pretty good job with this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only needed to add the millisecond pattern to the existing time pattern and add a region match for the &lt;code&gt;T#...&lt;/code&gt; identifier. :)&lt;/p&gt;&#xA;" OwnerUserId="6107" LastEditorUserId="205" LastEditDate="2016-02-23T03:11:19.973" LastActivityDate="2016-02-23T03:11:19.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6612" PostTypeId="2" ParentId="6596" CreationDate="2016-02-22T14:36:19.673" Score="1" Body="&lt;p&gt;I have an alternate solution using a plugin I created. The plugin is called &lt;a href=&quot;https://github.com/tommcdo/vim-express&quot; rel=&quot;nofollow&quot;&gt;express.vim&lt;/a&gt;, and it helps with the creation of ad-hoc operators. With it, you can create two types of operators:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Operators that run a VimScript expression over the supplied motion&lt;/li&gt;&#xA;&lt;li&gt;Operators that perform a substitution over the supplied motion&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;One thing I observed is that your edit could be performed using the &lt;code&gt;:substitute&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\(.\{-}\)\s*=\s*\(.*\)/let(:\1) { \2 }/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pattern looks for text like &lt;code&gt;foo = bar&lt;/code&gt;, capturing the left and right hand sides of the &lt;code&gt;=&lt;/code&gt; sign; the replacement inserts them into the RSpec &lt;code&gt;let&lt;/code&gt; statement as you specified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To create an operator that does this over a motion, we can use the &lt;code&gt;:MapSubpress&lt;/code&gt; command. In the below example, we'll map it to &lt;code&gt;cd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:MapSubpress cd /\(.\{-}\)\s*=\s*\(.*\)/let(:\1) { \2 }/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;cd&lt;/code&gt; is an operator that we can use and repeat with &lt;code&gt;.&lt;/code&gt; (this also depends on &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow&quot;&gt;repeat.vim&lt;/a&gt;). Note that since it's an &lt;em&gt;operator&lt;/em&gt;, it requires a motion to follow (just as &lt;code&gt;c&lt;/code&gt; or &lt;code&gt;y&lt;/code&gt; would). Since you're usually operating on lines, the &lt;code&gt;_&lt;/code&gt; motion will suffice. So we could use &lt;code&gt;cd_&lt;/code&gt; to transform &lt;code&gt;foo = bar&lt;/code&gt; into &lt;code&gt;let(:foo) { bar }&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're &lt;em&gt;always&lt;/em&gt; operating on a line, you might as well make a mapping that always invokes the &lt;code&gt;_&lt;/code&gt; motion. For this, I'd use a &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mapping with &lt;code&gt;:MapSubpress&lt;/code&gt;, and then create a map that refers to it. You could put something like this in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MapSubpress &amp;lt;Plug&amp;gt;(rspec-let) /\(.\{-}\)\s*=\s*\(.*\)/let(:\1) { \2 }/&#xA;nmap cd &amp;lt;Plug&amp;gt;(rspec-let)_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, our &lt;code&gt;cd&lt;/code&gt; mapping will operate on whole lines every time, and it's still repeatable with &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2016-02-22T14:36:19.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6613" PostTypeId="1" AcceptedAnswerId="6617" CreationDate="2016-02-22T18:12:54.337" Score="8" ViewCount="1760" Body="&lt;p&gt;I am a veteran user of &lt;code&gt;vi&lt;/code&gt;. When I started using it, there was basically nothing... Now, we have &lt;code&gt;vim&lt;/code&gt;. But, how do I program it?  Where does one start? With &lt;code&gt;help&lt;/code&gt;? Not sure this is a good start.&lt;/p&gt;&#xA;" OwnerUserId="5919" LastActivityDate="2016-02-22T19:47:35.390" Title="Tutorial for vim programming?" Tags="|vimscript|functions|" AnswerCount="3" CommentCount="2" ClosedDate="2016-02-22T23:36:34.583" ContentLicense="CC BY-SA 3.0" />
  <row Id="6614" PostTypeId="1" AcceptedAnswerId="6656" CreationDate="2016-02-22T18:15:50.227" Score="2" ViewCount="119" Body="&lt;p&gt;This is a followup question to &lt;a href=&quot;https://vi.stackexchange.com/questions/6305/auto-sorting-of-lists-of-include-files&quot;&gt;Auto sorting of lists of include files&lt;/a&gt;, which explains the motivation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;I am looking for a script and/or keybindings to look for VIM commands in a file, and then execute them on that file. As mentioned in the referenced question, the idea is that the script and the key bound to it, will do the following:&#xA;Look for lines that obey a certain patter in a file.&#xA;E.g., &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'// vim: some vim command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and execute these in sequence. &lt;/p&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-02-26T08:57:35.393" Title="A script and keybindings to look for VIM commands in a file, and then execute them on that file" Tags="|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6615" PostTypeId="1" AcceptedAnswerId="6646" CreationDate="2016-02-22T18:23:56.533" Score="4" ViewCount="4184" Body="&lt;p&gt;E.g., in this snippet&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if words[0] == &quot;\&quot;spellgood:&quot;&#xA;      call remove(words, 0)&#xA;      for word in words&#xA;        execute &quot;silent spellgood! &quot; . word&#xA;      endfor&#xA;    endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;taken from &quot;&lt;a href=&quot;https://vi.stackexchange.com/questions/6479/the-first-and-last-5-lines-of-a-file-use-for-file-specific-spell-ignore-list/6542?s=1|0.1230#6542&quot;&gt;The first and last 5 lines of a file? Use for file specific spell ignore list?&lt;/a&gt;&quot;&lt;/p&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2022-01-04T04:12:22.940" Title="What's the difference between call and execute?" Tags="|vimscript|" AnswerCount="3" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6616" PostTypeId="2" ParentId="6551" CreationDate="2016-02-22T18:49:23.233" Score="3" Body="&lt;p&gt;Write a function that returns the string and call it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! InsertHeader()&#xA;    let l:header = &quot;/*!\n&quot;&#xA;                \. &quot;* @author Robbie Yi JIANG, &quot; . strftime('%d-%b-%Y %H:%M:%S') . &quot;\n&quot;&#xA;                \. &quot;*\n&quot;&#xA;                \. &quot;* \n&quot;&#xA;                \. &quot;*/\n&quot;&#xA;    return l:header&#xA;endfunction&#xA;&#xA;inoremap /// &amp;lt;C-R&amp;gt;=InsertHeader()&amp;lt;Enter&amp;gt;&amp;lt;C-O&amp;gt;2k&amp;lt;C-O&amp;gt;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The details of &lt;code&gt;strftime&lt;/code&gt; depend on your platform, if you're not on Windows and it's not working then you'll need to &lt;code&gt;man strftime&lt;/code&gt; to figure out the arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works in insert mode but it does weird things to forward-slash processing. If you're doing C++-style &lt;code&gt;//&lt;/code&gt; comments, the second slash won't come out until you type a space or something after it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;C-R&amp;gt;=&lt;/code&gt; inserts an expression at the cursor position. The &lt;code&gt;InsertHeader()&amp;lt;Enter&amp;gt;&lt;/code&gt; bit is the expression that gets evaluated. I build up the string line by line in the function, &lt;code&gt;.&lt;/code&gt; is string concatenation and &lt;code&gt;\&lt;/code&gt; is the line continuation character (where continuation says &quot;combine this with the previous line,&quot; in contrast to how C and its family do it). Finally, two &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; operations, one to move up two lines and one to move to the end of the line where presumably a file comment is going to be entered; note the space at the end of the string in the fourth line of &lt;code&gt;l:header&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-22T18:49:23.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6617" PostTypeId="2" ParentId="6613" CreationDate="2016-02-22T18:53:06.260" Score="7" Body="&lt;p&gt;I can recommend &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot;&gt;Learn Vimscript the hard way&lt;/a&gt; from Steve Losh. It is a good tutorial which gives you most of the relevant knowledge and links you to &lt;code&gt;:help&lt;/code&gt; when it makes sense.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2016-02-22T18:53:06.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6618" PostTypeId="2" ParentId="6613" CreationDate="2016-02-22T18:56:13.487" Score="4" Body="&lt;p&gt;After running &lt;code&gt;vimtutor&lt;/code&gt; to get a handle of use of Vim (I'm surprised at how few people know the fundamentals) then yeah, &lt;code&gt;:help&lt;/code&gt; is really the way to go. The documentation is broken into fairly logical sections so if you're looking to script Vim in interesting ways the document that'll be your primary reference is eval.txt, &lt;code&gt;:h eval&lt;/code&gt;. That goes over syntax and all of the available functions. Pay special attention to the difference between single and double quoted strings, they beat me up for a long time...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also ask here! And search to see if your problem has been solved already; there is a ton of information on the Stack Exchange sites regarding customizing Vim.&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-22T18:56:13.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6619" PostTypeId="1" AcceptedAnswerId="6623" CreationDate="2016-02-22T19:05:03.293" Score="6" ViewCount="4062" Body="&lt;p&gt;I would like to create a global (configuration) variable that ideally would work as a comma separated list but that we could also append to it. The idea is to have the same behavior as when using &lt;code&gt;+=&lt;/code&gt; when setting &lt;code&gt;&amp;amp;runtimepath&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, it would be possible to do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:myvar+=&quot;newitem&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the variable contents would become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;item1&quot;,&quot;item2&quot;,&quot;newitem&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Two questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can such a variable be implemented in Vim (and how)?&lt;/li&gt;&#xA;&lt;li&gt;Would it be possible to allow and define a list for its tab completion?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="599" LastEditorUserId="51" LastEditDate="2016-02-22T23:33:18.083" LastActivityDate="2016-02-23T12:07:27.390" Title="Append to global variable and completion" Tags="|vimscript|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6620" PostTypeId="2" ParentId="6597" CreationDate="2016-02-22T19:10:54.283" Score="3" Body="&lt;p&gt;First thing I notice is that you have quotes in there. When using &lt;code&gt;set&lt;/code&gt; everything after the &lt;code&gt;=&lt;/code&gt; symbol is set to the value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;errorformat&lt;/code&gt; has spaces and backslashes my preferred way to set it is with &lt;code&gt;let&lt;/code&gt; and single-quoted strings, then string concatenation so I can break it up into more easily parsed lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;errorformat =&#xA;    \  '%*[^&quot;]&quot;%f&quot;%*\D%l: %m,'&#xA;    \. '&quot;%f&quot;%*\D%l: %m,'&#xA;    \. '%-G%f:%l: (Each undeclared identifier is reported only once,'&#xA;    \. etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in your case it's a lot easier, let's just try it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;errorformat = '%.%# at %.%#(%f:%l)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However you could get really fancy with multiline strings, using %E and its friends to collapse those error lines down into just the relevant info in your quickfix window but I still find that to be a bit fiddly.&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-22T19:10:54.283" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6621" PostTypeId="2" ParentId="6613" CreationDate="2016-02-22T19:47:35.390" Score="3" Body="&lt;p&gt;Some time back I found and played through &lt;a href=&quot;http://vim-adventures.com/&quot; rel=&quot;nofollow&quot;&gt;VIM Adventures&lt;/a&gt;. While it is more graphical, it does teach you the keybindings in an interesting, possibly easier-to-understand way.&lt;/p&gt;&#xA;" OwnerUserId="6536" LastActivityDate="2016-02-22T19:47:35.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6622" PostTypeId="1" AcceptedAnswerId="6624" CreationDate="2016-02-22T20:07:51.310" Score="4" ViewCount="1158" Body="&lt;p&gt;In Mac OS, I am trying to write a function that will say the current paragraph without moving the cursor, but something doesn't seem to work. This is what I have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SayIt()&#xA;    let l:line = line(&quot;.&quot;)&#xA;    let l:col  = col(&quot;.&quot;)&#xA;    execute &quot;normal V&quot;&#xA;    execute &quot;silent '&amp;lt;,'&amp;gt;w !say&quot;&#xA;   call cursor(l:line,l:col)&#xA;endfunction&#xA;&#xA;vnoremap &amp;lt;leader&amp;gt;v :call SayIt()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I remove the &lt;code&gt;execute &quot;normal V&quot;&lt;/code&gt; line the function works when I have previously selected a paragraph (or rather a long soft wrapped line). What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="1095" LastEditorUserId="205" LastEditDate="2016-02-23T01:18:32.167" LastActivityDate="2016-02-23T01:18:32.167" Title="How to visual select from vimscript" Tags="|vimscript|visual-mode|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6623" PostTypeId="2" ParentId="6619" CreationDate="2016-02-22T20:26:50.830" Score="7" Body="&lt;p&gt;You could have your variable be a list and add values with &lt;code&gt;:let g:var += ['item']&lt;/code&gt;. However, it won't be possible to prevent the same item to be added several times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why I've come up with &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/list.vim#L555&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;lh#list#push_if_new()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! lh#list#push_if_new(list, value) abort&#xA;  let matching = filter(copy(a:list), 'v:val == a:value')&#xA;  if empty(matching)&#xA;    call add (a:list, a:value)&#xA;  endif&#xA;  return a:list&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's quite cumbersome to use. Having a command that calls the function would help though. It would look like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; some plugin&#xA;command! -nargs=+ -complete=customlist,lh#let#_push_options_complete&#xA;      \ PushOptions call lh#let#_push_options(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And can be used this way regarding completion&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:foobar = {'titi': []}&#xA;:let g:acceptable_options_for['g:foobar.titi'] = ['s', 'foo', 'toto', 'titi' ]&#xA;&#xA;:PushOptions foo&amp;lt;tab&amp;gt;&#xA;&quot; -&amp;gt; g:foobar.&#xA;&quot; &amp;lt;tab&amp;gt; again -&amp;gt; g:foobar.titi&#xA;&quot; &amp;lt;space&amp;gt;&amp;lt;tab&amp;gt; -&amp;gt; list of possible choices: s, foo, toto, titi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Completion properties:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It can complete variables names, and even search for list/dict fields in dictionaries&lt;/li&gt;&#xA;&lt;li&gt;It can complete values from a list of possible values, which is filtered out of the values already set&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And here are the functions required for the completion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; # PushOptions {{{2&#xA;&quot;&#xA;&quot; Function: lh#let#_push_options(variable, ...) {{{3&#xA;function! lh#let#_push_options(variable, ...) abort&#xA;  let var = lh#let#if_undef(a:variable, '[]')&#xA;  for val in a:000&#xA;    call lh#list#push_if_new(var, val)&#xA;  endfor&#xA;  return var&#xA;endfunction&#xA;&#xA;&quot; Function: lh#let#_list_all_list_variables_in_scope(scope) {{{3&#xA;function! lh#let#_list_all_list_variables_in_scope(scope) abort&#xA;  let vars = map(keys({a:scope}), 'a:scope.v:val')&#xA;  &quot; Keep only lists and dictionaries&#xA;  call filter(vars, 'type({v:val}) == type([]) || type({v:val}) == type({})')&#xA;  return vars&#xA;endfunction&#xA;&#xA;&quot; Function: lh#let#_list_variables(lead) {{{3&#xA;function! lh#let#_list_variables(lead) abort&#xA;  if empty(a:lead)&#xA;    &quot; No variable spécified yet&#xA;    let vars &#xA;          \ = lh#let#_list_all_list_variables_in_scope('g:')&#xA;          \ + lh#let#_list_all_list_variables_in_scope('b:')&#xA;          \ + lh#let#_list_all_list_variables_in_scope('w:')&#xA;          \ + lh#let#_list_all_list_variables_in_scope('t:')&#xA;  elseif stridx(a:lead, '.') &amp;gt;= 0&#xA;    &quot; Dictionary&#xA;    let [all, dict, key ; trail] = matchlist(a:lead, '\v(.*)\.(.*)')&#xA;    let vars = keys({dict})&#xA;    call filter(vars, 'type({dict}[v:val]) == type([]) || type({dict}[v:val]) == type({})')&#xA;    call map(vars, 'v:val. (type({dict}[v:val])==type({})?&quot;.&quot;:&quot;&quot;)')&#xA;    call map(vars, 'dict.&quot;.&quot;.v:val')&#xA;    return vars&#xA;  else&#xA;    &quot; Simple variables&#xA;    if         (len(a:lead) == 1 &amp;amp;&amp;amp; a:lead    =~ '[gbwt]')&#xA;          \ || (len(a:lead) &amp;gt; 1  &amp;amp;&amp;amp; a:lead[1] == ':')&#xA;      let scope = a:lead[0]&#xA;      let filter_scope = ''&#xA;    else&#xA;      let scope = 'g'&#xA;      let filter_scope = 'g:'&#xA;    endif&#xA;    let vars = lh#let#_list_all_list_variables_in_scope(scope.':')&#xA;    call filter(vars, 'v:val =~ &quot;^&quot;.filter_scope.a:lead')&#xA;  endif&#xA;  &quot; Add dot to identified dictionaries&#xA;  call map(vars, 'v:val. (type({v:val})==type({})?&quot;.&quot;:&quot;&quot;)')&#xA;  return vars&#xA;endfunction&#xA;&#xA;&quot; Function: lh#let#_push_options_complete(ArgLead, CmdLine, CursorPos) {{{3&#xA;call lh#let#if_undef('g:acceptable_options_for', '{}')&#xA;&#xA;function! lh#let#_push_options_complete(ArgLead, CmdLine, CursorPos) abort&#xA;  let tmp = substitute(a:CmdLine, '\s*\S*', 'Z', 'g')&#xA;  let pos = strlen(tmp)&#xA;&#xA;  call s:Verbose('complete(lead=&quot;%1&quot;, cmdline=&quot;%2&quot;, cursorpos=%3)', a:ArgLead, a:CmdLine, a:CursorPos)&#xA;&#xA;  if     2 == pos&#xA;    &quot; First argument: a variable name&#xA;    return lh#let#_list_variables(a:ArgLead)&#xA;  elseif pos &amp;gt;= 3&#xA;    &quot; Doesn't handle 'foo\ bar', but we don't need this to fetch a variable&#xA;    &quot; name&#xA;    let args = split(a:CmdLine, '\s\+')&#xA;    let varname = args[1]&#xA;    call s:Verbose('complete: varname=%1', varname)&#xA;    &quot; Other arguments: acceptable values&#xA;    let acceptable_values = get(g:acceptable_options_for, varname, [])&#xA;    let crt_val = '\v^'.join(exists(varname)? eval(varname) : [], '|').'$'&#xA;    let acceptable_values = filter(copy(acceptable_values), 'v:val !~ crt_val')&#xA;    return acceptable_values&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-02-23T12:07:27.390" LastActivityDate="2016-02-23T12:07:27.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6624" PostTypeId="2" ParentId="6622" CreationDate="2016-02-22T20:31:12.817" Score="3" Body="&lt;p&gt;Your selection is being made with the &lt;code&gt;V&lt;/code&gt; command, so your &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; marks are just set to that line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to select the paragraph with the &lt;code&gt;ip&lt;/code&gt; motion after going into visual mode, then the range will be what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;execute&lt;/code&gt;s are unnecessary. Also that &lt;code&gt;cursor&lt;/code&gt; stuff isn't the way the pros do it. :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SayIt()&#xA;    let l:winview = winsaveview()&#xA;    normal Vip&#xA;    silent '&amp;lt;,'&amp;gt;w !say&#xA;    call winrestview(l:winview)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-22T20:31:12.817" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6625" PostTypeId="2" ParentId="5462" CreationDate="2016-02-22T20:38:37.873" Score="3" Body="&lt;p&gt;I actually do it a bit differently, I just make the edits in my vimrc and re-source it every time I write it. (I have a cascading set of vimrc files so this allows me to change any one of them.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if $MYVIMRC != ''&#xA;    autocmd BufWritePost    *vimrc      source $MYVIMRC&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-22T20:38:37.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6626" PostTypeId="2" ParentId="6622" CreationDate="2016-02-22T20:52:00.197" Score="3" Body="&lt;p&gt;Thank you for your help. In terms of functions, I think that the one posted by dash-tom-bang is the closest solution. But I have opted for the mapping suggested by saginaw.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;v :&amp;lt;C-U&amp;gt;silent! '{,'}w !say&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works without the function.&lt;/p&gt;&#xA;" OwnerUserId="1095" LastActivityDate="2016-02-22T20:52:00.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6627" PostTypeId="1" CreationDate="2016-02-22T21:54:11.780" Score="4" ViewCount="1911" Body="&lt;p&gt;If the file is named &lt;code&gt;*.markdown&lt;/code&gt; then the highlighting works correctly.  If it is named &lt;code&gt;*.md&lt;/code&gt; then it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if I type &lt;code&gt;:set syntax=markdown&lt;/code&gt;, the highlighting doesn't turn on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With other filetypes e.g. &lt;code&gt;awk&lt;/code&gt;, I can turn on the highlighting by running &lt;code&gt;:set syntax=awk&lt;/code&gt;.  But this doesn't work for markdown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately I want to &lt;a href=&quot;https://stackoverflow.com/a/14779012/5419599&quot;&gt;make Vim recognize .md files as markdown&lt;/a&gt;, but when the autocommand didn't work I tried just setting the syntax directly and found that didn't work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be causing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;a href=&quot;http://mobaxterm.mobatek.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MobaXterm&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2019-04-16T11:06:17.837" Title="Syntax highlighting for markdown can't be set manually" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6628" PostTypeId="2" ParentId="6599" CreationDate="2016-02-22T23:11:23.353" Score="1" Body="&lt;p&gt;As the name suggests, &lt;strong&gt;autoindent&lt;/strong&gt; helps mainly in indenting source code, while &lt;strong&gt;autoformat&lt;/strong&gt; can be used while editing text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, you can access vim help by typing &lt;code&gt;:help autoindent&lt;/code&gt; and &lt;code&gt;:help autoformat&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this post for additional info: &lt;a href=&quot;https://stackoverflow.com/questions/2355834/how-can-i-autoformat-indent-c-code-in-vim&quot;&gt;https://stackoverflow.com/questions/2355834/how-can-i-autoformat-indent-c-code-in-vim&lt;/a&gt;. It also addresses the 2nd part of your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim wiki at wikia has pages on these topics too:&#xA;&lt;a href=&quot;http://vim.wikia.com/wiki/Indenting_source_code&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Indenting_source_code&lt;/a&gt;&#xA;&lt;a href=&quot;http://vim.wikia.com/wiki/Automatic_formatting_of_paragraphs&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Automatic_formatting_of_paragraphs&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6470" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-02-22T23:11:23.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6629" PostTypeId="1" CreationDate="2016-02-22T23:42:19.223" Score="15" ViewCount="1907" Body="&lt;p&gt;I'm trying to find a way to map German umlaut keys (Ä,ä,Ö,ö,Ü,ü).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple shortcut like this won't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-ö&amp;gt; &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nothing happens when I hit &lt;code&gt;ctrl+ö&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know a solution to this?&lt;/p&gt;&#xA;" OwnerUserId="6542" LastEditorUserId="51" LastEditDate="2016-02-23T00:12:30.677" LastActivityDate="2019-07-22T12:51:03.393" Title="Can't map German 'umlaut' keys in .vimrc" Tags="|key-bindings|unicode|keyboard-layout|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6631" PostTypeId="1" AcceptedAnswerId="6639" CreationDate="2016-02-23T01:03:57.603" Score="5" ViewCount="54" Body="&lt;p&gt;I have this&#xA;&lt;code&gt;\(\w[^\w\u370-\u3ff\u1f00-\u1fff]*\)\([\u370-\u3ff\u1f00-\u1fff][^\w]*[\u370-\u3ff\u1f00-\u1fff]\)\([^\w]*\w\)&lt;/code&gt;,&#xA;which I need to improve, but it is getting uncomfortably complicated; is it possible to define shorthands for expressions that are reused, such as &lt;code&gt;\u370-\u3ff\u1f00-\u1fff&lt;/code&gt;? or is there some other way to make this easier to work with?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-02-23T10:50:56.083" Title="Can one define shorthands for unicode ranges?" Tags="|regular-expression|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6632" PostTypeId="2" ParentId="6619" CreationDate="2016-02-23T01:03:58.303" Score="3" Body="&lt;p&gt;If you want &lt;code&gt;g:myvar&lt;/code&gt; to be a string, you could define the following commands &lt;code&gt;:AddMyvar&lt;/code&gt; and &lt;code&gt;:RemoveMyvar&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=customlist,s:CompleteMyvar AddMyvar&#xA;         \ if !exists('g:myvar') |&#xA;         \     let g:myvar = '&amp;lt;args&amp;gt;' |&#xA;         \ elseif !count(split(g:myvar, ','), '&amp;lt;args&amp;gt;') |&#xA;         \     let g:myvar .= ',&amp;lt;args&amp;gt;' |&#xA;         \ endif&#xA;&#xA;command! -nargs=1 -complete=customlist,s:CompleteMyvar RemoveMyvar&#xA;    \ if exists('g:myvar') |&#xA;    \     let g:myvar = join(filter(split(g:myvar, ','), &quot;v:val !=# '&amp;lt;args&amp;gt;'&quot;), ',') |&#xA;    \ endif&#xA;&#xA;function! s:CompleteMyvar(A, L, P) abort&#xA;    let mycandidates = ['foo', 'bar', 'baz']&#xA;    return filter(mycandidates, 'v:val =~ &quot;^&quot; . a:A')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want &lt;code&gt;g:myvar&lt;/code&gt; to be a list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=customlist,s:CompleteMyvar AddMyvar&#xA;         \ if !exists('g:myvar') |&#xA;         \     let g:myvar = ['&amp;lt;args&amp;gt;'] |&#xA;         \ elseif !count(g:myvar, '&amp;lt;args&amp;gt;') |&#xA;         \     call add(g:myvar, '&amp;lt;args&amp;gt;') |&#xA;         \ endif&#xA;&#xA;command! -nargs=1 -complete=customlist,s:CompleteMyvar RemoveMyvar&#xA;         \ if exists('g:myvar') |&#xA;         \     call filter(g:myvar, &quot;v:val !=# '&amp;lt;args&amp;gt;'&quot;) |&#xA;         \ endif&#xA;&#xA;function! s:CompleteMyvar(A, L, P) abort&#xA;    let mycandidates = ['foo', 'bar', 'baz']&#xA;    return filter(mycandidates, 'v:val =~ &quot;^&quot; . a:A')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To use the commands, you would type:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:AddMyvar newitem&lt;/code&gt; to add &lt;code&gt;newitem&lt;/code&gt; to &lt;code&gt;g:myvar&lt;/code&gt;  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:RemoveMyvar olditem&lt;/code&gt; to remove &lt;code&gt;olditem&lt;/code&gt; from &lt;code&gt;g:myvar&lt;/code&gt;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The tab completion is managed by the &lt;code&gt;s:CompleteMyvar()&lt;/code&gt; function, which returns the list of suggestions &lt;code&gt;['foo', 'bar', 'baz']&lt;/code&gt;.&lt;br&gt;&#xA;If you type something after one of the commands, it is compared with the beginning of each item in the list, and only the items which match it will be returned.&lt;br&gt;&#xA;You would have to edit the list &lt;code&gt;mycandidates&lt;/code&gt; so that the function returns the suggestions you really want.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To explain how &lt;code&gt;:AddMyvar&lt;/code&gt; works a little:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=customlist,s:CompleteMyvar AddMyvar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;define the &lt;code&gt;:AddMyvar&lt;/code&gt; command which waits for one argument (&lt;code&gt;-nargs=1&lt;/code&gt;) and will make suggestions when you hit Tab based on what the &lt;code&gt;s:CompleteMyvar()&lt;/code&gt; function returns,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     \ if !exists('g:myvar') |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It tests if &lt;code&gt;g:myvar&lt;/code&gt; does not exist,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     \     let g:myvar = ['&amp;lt;args&amp;gt;'] |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if it doesn't, &lt;code&gt;g:myvar&lt;/code&gt; is defined as a single-item list containing the argument you provided on the command line. So if &lt;code&gt;g:myvar&lt;/code&gt; does not exist and you type &lt;code&gt;:AddMyvar foo&lt;/code&gt; then &lt;code&gt;g:myvar&lt;/code&gt; will be &lt;code&gt;['foo']&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     \ elseif !count(g:myvar, '&amp;lt;args&amp;gt;') |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;otherwise, it checks if the argument you provided is not already present inside &lt;code&gt;g:myvar&lt;/code&gt; to avoid adding the same item by mistake.&lt;br&gt;&#xA;&lt;code&gt;count()&lt;/code&gt; is a function which returns the number of times an item is present inside a list.&lt;br&gt;&#xA;In a test, a non-zero value is considered as true and a zero value as false.&lt;br&gt;&#xA;By prefixing the function with a bang you invert the test. non-zero will be false and zero will be true.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     \     call add(g:myvar, '&amp;lt;args&amp;gt;') |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, if the argument you provided was absent from &lt;code&gt;g:myvar&lt;/code&gt;, it's added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't like the command spreading on several lines, you could wrap the code inside a function and make the command call the latter.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;How &lt;code&gt;:RemoveMyvar&lt;/code&gt; works :  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=customlist,s:CompleteMyvar RemoveMyvar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;define a similar &lt;code&gt;:RemoveMyvar&lt;/code&gt; command,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     \ if exists('g:myvar') |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which tests if &lt;code&gt;g:myvar&lt;/code&gt; exists,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     \     call filter(g:myvar, &quot;v:val !=# '&amp;lt;args&amp;gt;'&quot;) |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and if it does, removes any item from &lt;code&gt;g:myvar&lt;/code&gt; which is not different from the argument you provided.&lt;br&gt;&#xA;&lt;code&gt;filter()&lt;/code&gt; is a function which can take each item of a list, here &lt;code&gt;g:myvar&lt;/code&gt;, and test it against an arbitrary condition, here &lt;code&gt;v:val !=# '&amp;lt;args&amp;gt;'&lt;/code&gt;.&lt;br&gt;&#xA;Inside the condition, you refer to an item from the list with the internal variable &lt;code&gt;v:val&lt;/code&gt;.&lt;br&gt;&#xA;If the test fails, &lt;code&gt;filter()&lt;/code&gt; removes the item from the list.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :command-completion-customlist&#xA;:help exists()&#xA;:help count()&#xA;:help split()&#xA;:help filter()&#xA;:help join()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-02-23T01:28:53.360" LastActivityDate="2016-02-23T01:28:53.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6633" PostTypeId="1" AcceptedAnswerId="6634" CreationDate="2016-02-23T01:44:06.240" Score="9" ViewCount="27862" Body="&lt;p&gt;I'm using airline with its default theme (relying from my theme gruvbox).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;:AirlineTheme base16&lt;/code&gt; while I have already opened my vim to change my airline theme to base16.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I want to change the default airline theme permanently, when I set &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AirlineTheme base16&#xA;call AirlineTheme base16&#xA;set AirlineTheme base16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;AirlineTheme base16&lt;/code&gt; -- Gives no failure message but removes all airline themes.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;call AirlineTheme base16&lt;/code&gt; -- Gives error &lt;code&gt;&quot;Missing parentheses&lt;/code&gt;. I also tried it as &lt;code&gt;call AirlineTheme base16()&lt;/code&gt;. Still same error. &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;set AirlineTheme base16&lt;/code&gt; -- This says &lt;code&gt;unknown option AirlineTheme&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How can I set it?&lt;/p&gt;&#xA;" OwnerUserId="6071" LastEditorUserId="205" LastEditDate="2016-02-23T02:21:36.943" LastActivityDate="2019-01-08T17:44:54.983" Title="How do I change the Airline theme?" Tags="|vimrc|plugin-airline|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6634" PostTypeId="2" ParentId="6633" CreationDate="2016-02-23T02:25:44.137" Score="17" Body="&lt;p&gt;Put the following in your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_theme='base16'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll also need to install the &lt;a href=&quot;https://github.com/vim-airline/vim-airline-themes&quot;&gt;vim-airline/vim-airline-themes&lt;/a&gt; plugin.&lt;/p&gt;&#xA;" OwnerUserId="4932" LastEditorUserId="205" LastEditDate="2016-02-23T02:41:00.320" LastActivityDate="2016-02-23T02:41:00.320" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6635" PostTypeId="1" AcceptedAnswerId="6636" CreationDate="2016-02-23T05:06:40.037" Score="8" ViewCount="1754" Body="&lt;p&gt;I am using the script from &lt;a href=&quot;https://github.com/chrisbra/vim_dotfiles/blob/a1a106081884647922395fe4512aa8fcc887d64c/plugin/CustomFoldText.vim&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, and it seems setting the  g:custom_foldtext_max_width variable cannot get rid of the extra &quot;--&quot; symbols in the end of the folded lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to make the folded line not go beyond 80 characters ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ktITw.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ktITw.png&quot; alt=&quot;screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6550" LastActivityDate="2019-01-17T15:09:12.213" Title="Get rid of extra fold dashes when using Vim folding" Tags="|vimrc|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6636" PostTypeId="2" ParentId="6635" CreationDate="2016-02-23T07:08:44.187" Score="9" Body="&lt;p&gt;You can&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fillchars=fold:\ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;fillchars&amp;#39;&quot;&gt;&lt;code&gt;:h fillchars&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-02-23T07:08:44.187" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6637" PostTypeId="1" AcceptedAnswerId="6640" CreationDate="2016-02-23T10:12:58.563" Score="8" ViewCount="8861" Body="&lt;p&gt;I have looked for this a lot already and every answer is about Vim in Linux. Is there a way to save a read-only file right from Vim in Windows?&lt;/p&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="205" LastEditDate="2016-02-26T09:15:01.627" LastActivityDate="2020-05-07T11:46:24.717" Title="How do I save a read-only file in Vim for Windows?" Tags="|microsoft-windows|save|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6638" PostTypeId="2" ParentId="6637" CreationDate="2016-02-23T10:45:39.347" Score="2" Body="&lt;p&gt;You can use my &lt;a href=&quot;https://github.com/chrisbra/SudoEdit.vim&quot; rel=&quot;nofollow&quot;&gt;SudoEdit&lt;/a&gt; plugin.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-02-23T10:45:39.347" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6639" PostTypeId="2" ParentId="6631" CreationDate="2016-02-23T10:50:56.083" Score="3" Body="&lt;p&gt;You can define a variable holding your pattern like this:&#xA;&lt;code&gt;:let g:pat='...'&lt;/code&gt;&#xA;(Note the use of single quotation marks, to prevent side-effects).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can search for that variable like this:&#xA;&lt;code&gt;:%s/&amp;lt;C-R&amp;gt;=g:pat&amp;lt;cr&amp;gt;/replacement_part/g&lt;/code&gt; This is described at &lt;code&gt;:h c_CTRL-R_=&lt;/code&gt;&#xA;or possibly easier:&#xA;&lt;code&gt;:exe '%s/'.g:pat.'/replacement/g'&lt;/code&gt; (you could also wrap this in a &lt;code&gt;printf()&lt;/code&gt; call)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-02-23T10:50:56.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6640" PostTypeId="2" ParentId="6637" CreationDate="2016-02-23T11:54:47.407" Score="11" Body="&lt;p&gt;As on other vi/vim versions, you can use &lt;code&gt;:w!&lt;/code&gt; to force the write, as long as you have permissions to override the read-only property.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you have set the file as read-only, the above will work.  If Windows itself or an administrator has set it read-only, you will need another option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @dash-tom-bang commented, one good example is within Program Files, where files are protected by default. &lt;a href=&quot;https://support.microsoft.com/en-us/kb/326549&quot; rel=&quot;nofollow&quot;&gt;This Microsoft knowledgebase article&lt;/a&gt; explains how that works in practice.&lt;/p&gt;&#xA;" OwnerUserId="6298" LastEditorUserId="6298" LastEditDate="2016-02-25T13:54:39.450" LastActivityDate="2016-02-25T13:54:39.450" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6641" PostTypeId="1" AcceptedAnswerId="6647" CreationDate="2016-02-23T15:39:51.390" Score="10" ViewCount="53193" Body="&lt;p&gt;UPDATE: I've tried both the &lt;code&gt;:set noswapfile swapfile&lt;/code&gt; solution and the &lt;code&gt;:e!&lt;/code&gt; solution and the swapfile one is better because it retains undo history even for large files, in this case meaning over 1.5 MB. For some reason, &lt;code&gt;:e!&lt;/code&gt; does not keep undo history in those cases even though it does keep it in the normal case (say sub-100KB). The &lt;code&gt;swapfile&lt;/code&gt; solution appears to me now to work under any circumstances, which is very impressive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bit of a weird question: How can I cleanly get rid of or move past the error message &quot;E297: Write error in swap file&quot;? I am running GVim when this happens and do not want to be forced to close it down and reopen a new GVim because I don't want to lose all my open buffers and ideally I'd like to keep all my undo history in each file too, but even a solution where I lose undo history would be an improvement. I have one limited workaround right now noted at bottom and am looking for something a little better...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why would I want to ignore such an error? A good question: I am running GVim in a virtual machine and I have it open on a file on the &quot;host&quot; file system rather than the VM's own file system and I &quot;suspend&quot; the VM. After coming back from the suspend, every GVim window open on a host system file will give this message. So the message is evidently due to the disconnection from the host file system that has to occur when the VM is suspended. GVim obviously thinks it still has a valid perhaps file descriptor and such when it doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the way the error arises is not anything alarming and I just need or want a way to move past it without having to close GVim and reopen it. For example, many times I might have this GVim open with many buffers and a lot of things going on. I don't want to be forced to shut down the whole GVim session because of this one error, or even to shut down &lt;em&gt;all&lt;/em&gt; buffers open on the host system's file system. When the error occurs, it's quite annoying and pops up every few moments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I tried so far is doing &lt;code&gt;:e&lt;/code&gt; on the same file, hoping that might be like refreshing from the file system, and that did &lt;em&gt;not&lt;/em&gt; get rid of the error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried sort of the nuclear option, &lt;code&gt;:bw&lt;/code&gt; to get rid of the buffer where this is occurring and that does work, but as I say ideally I would like to keep the session in the same state as much as possible, so shutting down buffers is not ideal either. Like let's say I have GVim open on 10 files on the host system. If I have to shut down all the buffers, then it's just as bad as having to shut down GVim altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of this applies to the command line Vim as well, and I'm using version 7.4 on Linux.&lt;/p&gt;&#xA;" OwnerUserId="6519" LastEditorUserId="6519" LastEditDate="2016-03-10T13:13:23.947" LastActivityDate="2021-09-14T17:40:17.867" Title="&quot;E297: Write error in swap file&quot; due to running in a VM" Tags="|swap-file|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6642" PostTypeId="2" ParentId="6641" CreationDate="2016-02-23T15:57:49.090" Score="2" Body="&lt;p&gt;You could try using sessions instead of suspending the VM. You could configure your Linux to launch Vim on startup, and your Vim to load the last session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, for the following task:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I am running GVim when this happens and do not want to be forced to&#xA;  &lt;strong&gt;close it down and reopen a new GVim because I don't want to lose all&lt;/strong&gt;&#xA;  &lt;strong&gt;my open buffers&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;, you could use the &lt;a href=&quot;https://github.com/xolox/vim-session/&quot; rel=&quot;nofollow&quot;&gt;session.vim plugin&lt;/a&gt; as it provides the &lt;code&gt;:RestartVim&lt;/code&gt; command, which restarts Vim/GVim and restores your windows/tabpages layout.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-02-23T15:57:49.090" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6643" PostTypeId="2" ParentId="6637" CreationDate="2016-02-23T16:06:27.793" Score="-1" Body="&lt;p&gt;Type &lt;code&gt;:f &quot;newfilename&quot;&lt;/code&gt; in command mode then when leaving &lt;code&gt;:w&lt;/code&gt; to save under the new file name.&lt;/p&gt;&#xA;" OwnerUserId="6556" LastEditorDisplayName="user72" LastEditDate="2016-02-23T16:27:51.927" LastActivityDate="2016-02-23T16:27:51.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6645" PostTypeId="1" AcceptedAnswerId="6655" CreationDate="2016-02-23T16:17:59.777" Score="5" ViewCount="486" Body="&lt;p&gt;With the ascii apostrophe ', the spell checker defaults to treating words with a genetive s as bad; can that be remedied?  &lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2016-02-23T16:29:02.330" LastActivityDate="2016-02-24T11:51:01.663" Title="Can the spell checker be told to stop marking words with apostrophes as bad?" Tags="|spell-checking|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6646" PostTypeId="2" ParentId="6615" CreationDate="2016-02-23T16:25:42.417" Score="9" Body="&lt;p&gt;As described in &lt;code&gt;:help call&lt;/code&gt;, &lt;code&gt;call&lt;/code&gt; is for invoking a built-in or user-defined &lt;em&gt;function&lt;/em&gt;. It's useful to use &lt;code&gt;call&lt;/code&gt; if you're invoking a function without the intention of capturing the return value, because of how vim's scripting works. That is, if you have a function &lt;code&gt;foo&lt;/code&gt; that returns an integer, you &lt;em&gt;must&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call foo()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to call &lt;code&gt;foo&lt;/code&gt; without caring about the result, whereas:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let result = foo()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can be used to call &lt;code&gt;foo&lt;/code&gt; and put the result in &lt;code&gt;result&lt;/code&gt;. Note how &lt;code&gt;call&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; required for the second example. &lt;code&gt;call&lt;/code&gt; also can take a range, which has the effect of invoking the function for every line in that range, usually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help execute&lt;/code&gt;, on the other hands, reveals that &lt;code&gt;execute&lt;/code&gt; is for evaluating strings as &lt;em&gt;Ex commands&lt;/em&gt;. Normally you don't need to use &lt;code&gt;execute&lt;/code&gt; in vim scripts, as most of what you type in them is interpreted as an Ex command. However, &lt;code&gt;execute&lt;/code&gt; exists and is particularly useful for invoking commands built up at &lt;em&gt;runtime&lt;/em&gt;, as was done in the answer you linked to in order to add a word discovered at runtime to the spelling dictionary.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorUserId="51" LastEditDate="2017-01-30T21:14:45.267" LastActivityDate="2017-01-30T21:14:45.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6647" PostTypeId="2" ParentId="6641" CreationDate="2016-02-23T20:38:05.757" Score="4" Body="&lt;p&gt;I would try to globally disable swapfiles and then reenable them for all buffers. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:bufdo :set noswapfile swapfile&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(One might want to check, whether the current buffer has a swapfile enabled before resetting this option).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-02-23T20:38:05.757" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6648" PostTypeId="1" CreationDate="2016-02-23T22:51:00.707" Score="3" ViewCount="99" Body="&lt;p&gt;I can edit remotely a file located on Machine_1 using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim name@Machine_1/file_1.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses my .vimrc, plugins and everything is great. However, there is also a Machine_2 in the history, that can only be accessed through Machine_1...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can edit the desired files on Machine_2 using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ssh login@Machine_1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and from there&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ssh login2@Machine_2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but all my plugins and settings won't be used, and that is not what I want... :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there any way to access the file_2.txt located on Machine_2 through Vim, on my local Machine?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that I don't own any of the two machines and also don't have physical access to them nor administrator powers.&lt;/p&gt;&#xA;" OwnerUserId="6558" LastActivityDate="2016-02-23T22:51:00.707" Title="Double SSH on Vim" Tags="|terminal|" AnswerCount="0" CommentCount="5" ClosedDate="2016-02-24T11:40:32.103" ContentLicense="CC BY-SA 3.0" />
  <row Id="6649" PostTypeId="1" CreationDate="2016-02-24T00:05:18.090" Score="1" ViewCount="524" Body="&lt;p&gt;I am trying to use the backslash key &lt;code&gt;\&lt;/code&gt; as the local leader.  I have done this before in other vim environments but on my windows pc the backslash key just makes an error sounding beep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to mess with ttimeout but I don't think that is the problem.  I can use my Leader key &lt;code&gt;,&lt;/code&gt; just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help&lt;/p&gt;&#xA;" OwnerUserId="6559" LastActivityDate="2016-02-24T13:49:40.490" Title="Error beep from backslash key '\', Unable to use as localleader. Gvim Windows 8" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6650" PostTypeId="1" CreationDate="2016-02-24T09:37:25.110" Score="2" ViewCount="536" Body="&lt;p&gt;I have vim set to relative line numbering with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number&#xA;set relativenumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason, every now and then, for some unknown reason, relative line numbering seems to turn off (or is stuck to the top of the buffer) in particular splits (though still active in other splits). Does anyone have any idea why this might be happening? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my full .vimrc as it currently stands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;if has('unix')&#xA;   set t_Co=256&#xA;endif&#xA;&#xA;&quot; Vundle stuff&#xA;set nocompatible&#xA;filetype off&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;call vundle#end()&#xA;filetype plugin indent on&#xA;&#xA;&quot; Hard Mode Plugin&#xA;&quot; autocmd VimEnter,BufNewFile,BufReadPost * silent! call HardMode()&#xA;&#xA;&quot; Other stuff&#xA;set number&#xA;set noerrorbells   &quot; Turn off the annoying error sounds&#xA;set relativenumber &quot; Turn relative line numbering on&#xA;set laststatus=2   &quot; Always keep the status line on&#xA;set wildmenu       &quot; Create graphical menu when tab completing file paths&#xA;&#xA;&quot; Syntastic&#xA;let syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes':   [],'passive_filetypes': [] } &quot; Turn it off for now&#xA;&#xA;&quot;Searching&#xA;set incsearch      &quot; Search as characters are entered&#xA;set ignorecase     &quot; Ignore case when searching&#xA;set smartcase      &quot; If a pattern contains an uppercase letter, it will match case sensitive, otherwise it will be case insensitive&#xA;&#xA;&quot; Setup folding&#xA;set foldenable         &quot; Turn folding on&#xA;set foldlevelstart=1&#xA;set foldmethod=syntax&#xA;&quot;&#xA;&quot; Backups&#xA;set nobackup&#xA;set nowritebackup&#xA;&#xA;&quot; Visual elements&#xA;set cursorline     &quot; Creates a highlight on the line containing the cursor&#xA;&#xA;&quot; Set Colourscheme from the ./vim/color directory&#xA;colorscheme valloric&#xA;&#xA;&quot; Override colours in scheme set below&#xA;highlight cursorline ctermbg=17&#xA;&#xA;&quot; Ident guides&#xA;let g:indent_guides_auto_colors = 0&#xA;let g:indent_guides_start_level = 2&#xA;let g:indent_guides_guide_size = 1&#xA;&#xA;&quot; let g:indent_guides_enable_on_vim_startup = 1&#xA;highlight IndentGuidesEven ctermbg=22&#xA;highlight IndentGuidesOdd ctermbg=28&#xA;&#xA;&quot; Identing and tabs&#xA;set autoindent&#xA;set smartindent&#xA;set tabstop=3     &quot; Number of visual spaces to visually display hard tabs with&#xA;set softtabstop=3 &quot; Number of spaces inserted with the tab key if expandtab is on&#xA;set shiftwidth=3&#xA;set expandtab     &quot; Turn all presses of the tab key into spaces&#xA;&#xA;&quot; Keymaps&#xA;map = :set foldlevel+=1&amp;lt;CR&amp;gt;&#xA;map - :set foldlevel-=1&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Swap files&#xA;set backupdir=~/.vim/backup//&#xA;set directory=~/.vim/swap//&#xA;set undodir=~/.vim/undo//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6560" LastActivityDate="2016-02-24T22:01:10.887" Title="Why does relative line numbering sometimes turn off" Tags="|vimrc|line-numbers|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ClosedDate="2016-02-26T07:58:47.673" ContentLicense="CC BY-SA 3.0" />
  <row Id="6651" PostTypeId="1" AcceptedAnswerId="6654" CreationDate="2016-02-24T09:41:57.740" Score="6" ViewCount="506" Body="&lt;p&gt;I have this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subject { }&#xA;&#xA;it 'delete user' do&#xA;  expect(BlaBla).to eq ''&#xA;  MyModel.my_method&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subject { MyModel.my_method }&#xA;&#xA;it 'delete user' do&#xA;  expect(BlaBla).to eq ''&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. First try&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do &lt;code&gt;dd&lt;/code&gt; and then past it inside my bracket with &lt;code&gt;i&amp;lt;CTRL&amp;gt;r&quot;&quot;&lt;/code&gt; I will get something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subject {   MyModel.my_method&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I have to go in insert mode to past the text and I have to clean some extra space and joins line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. Second try&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I go on the line &lt;code&gt;wy$&lt;/code&gt; then &lt;code&gt;&quot;_dd&lt;/code&gt; to remove the line without save it. Then go after the first &lt;code&gt;{&lt;/code&gt; : &lt;code&gt;?{&amp;lt;ENTER&amp;gt;lpa&amp;lt;space&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What will be a better motion to cut only the content of the line store into a register remove the line jump below past inside brackets?&lt;/p&gt;&#xA;" OwnerUserId="3357" LastEditorUserId="3357" LastEditDate="2016-02-24T10:08:03.817" LastActivityDate="2016-03-24T10:57:14.633" Title="Easiest way to cut line content and past it inside { }" Tags="|cut-copy-paste|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6652" PostTypeId="2" ParentId="6651" CreationDate="2016-02-24T10:27:18.540" Score="7" Body="&lt;p&gt;You can delete the content of a line (without the line break) with &lt;code&gt;^d$&lt;/code&gt;. You can delete to any register (e.g. 'l': &lt;code&gt;&quot;l^d$&lt;/code&gt;.)&#xA;If you use that often, I suggest mapping it to a new key:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap D ^d$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap D &quot;l^d$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;^&lt;/code&gt; in difference to &lt;code&gt;0&lt;/code&gt; does not contain leading whitespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, within the &lt;code&gt;{}&lt;/code&gt;, paste it via &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;&quot;lp&lt;/code&gt; respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Additional Note:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally often end up deleting the line after deleting its contents (or more general: deleting something afterwards that should not overwrite my unnamed register). Instead of using registers, for me &lt;a href=&quot;https://github.com/maxbrunsfeld/vim-yankstack&quot;&gt;this plugin&lt;/a&gt; feels more convenient. It effectively turns your unnamed register into a stack, so you can delete multiple things and when you paste, you can cycle through them.&lt;/p&gt;&#xA;" OwnerUserId="6495" LastActivityDate="2016-02-24T10:27:18.540" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6653" PostTypeId="2" ParentId="6651" CreationDate="2016-02-24T10:30:39.533" Score="4" Body="&lt;p&gt;With the cursor on &lt;code&gt;MyModel.my_method&lt;/code&gt;, I would do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^y$?{&amp;lt;CR&amp;gt;p``dd&#xA;&#xA;^          jump to first printable character&#xA;y$         yank the rest of the line&#xA;?{&amp;lt;CR&amp;gt;     jump to the opening bracket&#xA;p          put what I just yanked&#xA;``         jump back&#xA;dd         cut the line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-02-24T10:30:39.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6654" PostTypeId="2" ParentId="6651" CreationDate="2016-02-24T10:32:25.023" Score="5" Body="&lt;p&gt;If your problem is to repeat the operation in an efficient way you could use a macro:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First put &lt;code&gt;{&lt;/code&gt; in your search register with &lt;code&gt;/{&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then record your macro: &lt;code&gt;qq^DNp``ddq&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; record the macro in the q register&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ma&lt;/code&gt; put a mark on the line you'll delete&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; got to the first word of the line (ie. &lt;code&gt;MyModel&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;D&lt;/code&gt; delete the end of the line and put it in the unnamed register&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;N&lt;/code&gt; go to the previous occurence of the search register (&lt;code&gt;{&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; put the deleted text between the brackets&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'a&lt;/code&gt; go to the line you marked before&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dd&lt;/code&gt;delete the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; stop the macro recording&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then you'll simply have to go to the next occurence of &lt;code&gt;MyModel.my_method&lt;/code&gt; and use &lt;code&gt;@q&lt;/code&gt; to repeate the operation.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-02-24T10:32:25.023" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6655" PostTypeId="2" ParentId="6645" CreationDate="2016-02-24T11:51:01.663" Score="4" Body="&lt;p&gt;The words &lt;code&gt;potential's&lt;/code&gt; and &lt;code&gt;something's&lt;/code&gt; are not in the default spell file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked this by enabling spell checking, and then using the &lt;a href=&quot;http://vimhelp.appspot.com/spell.txt.html#%3aspelldump&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:spelldump&lt;/code&gt;&lt;/a&gt; command. This will create a new buffer with all valid words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do &lt;code&gt;:g/'s$/&lt;/code&gt; you will see that words ending with &lt;code&gt;'s&lt;/code&gt; are separate entries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your solution is to add these words to the spell file. This can be done easily with either &lt;a href=&quot;http://vimhelp.appspot.com/spell.txt.html#zg&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;zg&lt;/code&gt;&lt;/a&gt; from normal mode, or the &lt;a href=&quot;http://vimhelp.appspot.com/spell.txt.html#%3aspellgood&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:spellgood&lt;/code&gt;&lt;/a&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-02-24T11:51:01.663" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6656" PostTypeId="2" ParentId="6614" CreationDate="2016-02-24T13:05:50.620" Score="2" Body="&lt;p&gt;A possible solution is to add the following lines to your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; mapping to execute the function&#xA;nmap &amp;lt;F4&amp;gt; :call ExecuteCommandsFromFile()&amp;lt;CR&amp;gt;&#xA;&#xA;function! ExecuteCommandsFromFile()&#xA;    &quot; The pattern which will indicate the commands&#xA;    let l:pattern=&quot;'// vim: &quot;&#xA;    let l:res=1&#xA;&#xA;    &quot; Go to the first line of the file&#xA;    normal gg&#xA;&#xA;    &quot; While some commands are found in the file&#xA;    while search(l:pattern, &quot;We&quot;) != 0&#xA;&#xA;        &quot; Get the position of the text representing the command&#xA;        let l:start=col('.')&#xA;        let l:end=col('$')&#xA;&#xA;        &quot; Get the command&#xA;        let l:line=strpart(getline('.'), l:start, l:end)&#xA;&#xA;        &quot; Execute the command&#xA;        execute l:line&#xA;    endwhile&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Notes&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can replace &lt;code&gt;&amp;lt;F4&amp;gt;&lt;/code&gt; by any key you want to use to start the function&lt;/li&gt;&#xA;&lt;li&gt;The variable &lt;code&gt;l:pattern&lt;/code&gt; can be changed to match the pattern you'll use to indicate that the line contains a command to execute&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;search&lt;/code&gt; command in the &lt;code&gt;while&lt;/code&gt;loop uses the flag &lt;code&gt;W&lt;/code&gt; not to wrap around the file and thus executing the commands only once.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made this according to what I understood from the question but if the solution doesn't really fit your needs don't hesitate to give more details so that I can adapt the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it could be interesting to execute the commands after parsing all the file instead of executing it as soon as the command is read. So here is a second version where the function firstly get all the commands and then execute them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ExecuteCommandsFromFile2()&#xA;    &quot; The pattern which will indicate the commands&#xA;    let l:pattern=&quot;'// vim: &quot;&#xA;    let l:res=1&#xA;&#xA;    &quot; Go to the first line of the file&#xA;    normal gg&#xA;&#xA;    &quot; The list will contain the commands to execute&#xA;    let l:commands = []&#xA;&#xA;    &quot; While some commands are found in the file&#xA;    while search(l:pattern, &quot;We&quot;) != 0&#xA;&#xA;        &quot; Get the position of the text representing the command&#xA;        let l:start=col('.')&#xA;        let l:end=col('$')&#xA;&#xA;        &quot; Get the command&#xA;        let l:line=strpart(getline('.'), l:start, l:end)&#xA;&#xA;        &quot; Add the command to the list&#xA;        call add(l:commands, l:line)&#xA;    endwhile&#xA;&#xA;    &quot; Execute each command&#xA;    for l:command in l:commands&#xA;        execute l:command&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A possible evolution would be to refactor both of the function to get only one accepting an argument describing the mode to use... &lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-02-26T08:57:35.393" LastActivityDate="2016-02-26T08:57:35.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6657" PostTypeId="2" ParentId="6649" CreationDate="2016-02-24T13:49:40.490" Score="1" Body="&lt;p&gt;There was no problem with Vi.  It was a problem with me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the question statox referenced discusses, the beep is because there are no commands using the backslash key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case, this was because the ftplugin I was trying to use had not been loaded correctly.  After fixing that all worked OK&lt;/p&gt;&#xA;" OwnerUserId="6559" LastActivityDate="2016-02-24T13:49:40.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6658" PostTypeId="1" CreationDate="2016-02-24T14:06:41.537" Score="9" ViewCount="3321" Body="&lt;p&gt;I am trying to use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1397&quot; rel=&quot;noreferrer&quot;&gt;this plugin&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have created a copy of &lt;code&gt;xml.vim&lt;/code&gt; and named it &lt;code&gt;html.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the system ftplugin &lt;code&gt;C:\Program Files&#xA;(x86)\Vim\vim74\ftplugin\html.vim&lt;/code&gt; is loaded before the new one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have checked this with &lt;code&gt;:scriptnames&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the default &lt;code&gt;html.vim&lt;/code&gt; is loaded the custom one will NEVER work - even if loaded after.  My only way of fixing has been to remove/replace the default one with the custom one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works fine but I don't like having to edit the system files.  Feels like too much of a hack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that using &lt;code&gt;/ftplugin/after&lt;/code&gt; does not work because the default still gets loaded first and that seems to irretrievably break the custom ftplugin functionality. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a side note: i would really like the try the more recent xmledit plugin but don't know how to compile the vimball on Windows and I use Vundle (not Pathogen).  Help on that front would be great too!&lt;/p&gt;&#xA;" OwnerUserId="6559" LastEditorUserId="1841" LastEditDate="2016-02-24T14:32:23.540" LastActivityDate="2017-12-13T01:22:11.243" Title="How to override a ftplugin" Tags="|filetype-html|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6659" PostTypeId="2" ParentId="6658" CreationDate="2016-02-24T14:49:15.540" Score="9" Body="&lt;h1&gt;Overriding a plugin manually&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Unless you intend to change all of the settings set by Vim's existing html ftplugin, you want your plugin to be loaded before it. The setting of the &lt;code&gt;b:did_ftplugin&lt;/code&gt; variable will then cause Vim's version to exit immediately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Placing the plugin in your &lt;code&gt;~/.vim/ftplugin&lt;/code&gt; directory will cause it to be loaded before Vim's included version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's help discusses this in &lt;code&gt;:help ftplugin-overrule&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;2&quot;&gt;&#xA;  &lt;li&gt;&lt;p&gt;Make a copy of the plugin and change it.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You must put the copy in a directory early in 'runtimepath'.  For Unix, for&lt;br&gt;&#xA;  example, you could do this:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;cp $VIMRUNTIME/ftplugin/fortran.vim ~/.vim/ftplugin/fortran.vim&lt;/code&gt;  &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Then you can edit the copied file to your liking.  Since the &lt;code&gt;b:did_ftplugin&lt;/code&gt;&lt;br&gt;&#xA;  variable will be set, the global plugin will not be loaded.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h1&gt;Using Vundle&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;However, the first sentence of your question states that your goal is simply to use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1397&quot; rel=&quot;noreferrer&quot;&gt;this plugin&lt;/a&gt;, and the last sentence states that you use Vundle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is the case, then all you need to do to use the plugin is add the following line to your &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'othree/xml.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-02-24T15:22:58.523" LastActivityDate="2016-02-24T15:22:58.523" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6660" PostTypeId="1" CreationDate="2016-02-24T16:22:11.397" Score="10" ViewCount="534" Body="&lt;p&gt;If there are external changes made to a file being edited in Vim I understand that I can reload the content of the file by &lt;a href=&quot;https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim/149214&quot;&gt;&lt;code&gt;:edit&lt;/code&gt;&lt;/a&gt;. But, assume that (internally) I've made changes to the file that I want to preserve. Is there a way to integrate the two sets of changes (external and internal)? From what I understand, &lt;code&gt;:edit&lt;/code&gt; simply takes the external changes.&lt;/p&gt;&#xA;" OwnerUserId="2062" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2016-04-28T11:22:40.377" Title="Merge in external changes made while editing" Tags="|merge|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6661" PostTypeId="1" AcceptedAnswerId="6663" CreationDate="2016-02-24T16:37:02.820" Score="4" ViewCount="229" Body="&lt;p&gt;That is, one that would make &lt;code&gt;:echo good('crazy')&lt;/code&gt; print '1'.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-02-24T16:47:47.930" Title="Is there a function that says whether a word is good or bad?" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6662" PostTypeId="2" ParentId="6651" CreationDate="2016-02-24T16:42:41.340" Score="1" Body="&lt;p&gt;You might consider doing something like this on the following text: &lt;code&gt;5G&lt;/code&gt;, &lt;code&gt;^v$hd&lt;/code&gt;,&lt;code&gt;?{&amp;lt;cr&amp;gt;&lt;/code&gt;,&lt;code&gt;p&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1  subject { }&#xA;2&#xA;3  it 'delete user' do&#xA;4  expect(BlaBla).to eq ''&#xA;5  MyModel.my_method&#xA;6  end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;5G&lt;/code&gt; gets you to line 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^v$hd&lt;/code&gt; selects the text an line 5 and places it in a register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;?{&amp;lt;cr&amp;gt;&lt;/code&gt; moves to the nearest &lt;code&gt;{&lt;/code&gt; prior to line 5.&#xA;&lt;code&gt;p&lt;/code&gt; places the text in the register immediately after the &lt;code&gt;{&lt;/code&gt; (the current position of the cursor).&lt;/p&gt;&#xA;" OwnerUserId="2062" LastEditorUserId="2062" LastEditDate="2016-02-24T16:54:29.300" LastActivityDate="2016-02-24T16:54:29.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6663" PostTypeId="2" ParentId="6661" CreationDate="2016-02-24T16:47:47.930" Score="6" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#spellbadword%28%29&quot;&gt;&lt;code&gt;spellbadword&lt;/code&gt;&lt;/a&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;spellbadword([{sentence}])&#xA;    ...&#xA;    With argument: The result is the first word in {sentence} that&#xA;    is badly spelled.  If there are no spelling mistakes the&#xA;    result is an empty string.&#xA;&#xA;    The return value is a list with two items:&#xA;    - The badly spelled word or an empty string.&#xA;    - The type of the spelling error:&#xA;            &quot;bad&quot;           spelling mistake&#xA;            &quot;rare&quot;          rare word&#xA;            &quot;local&quot;         word only valid in another region&#xA;            &quot;caps&quot;          word should start with Capital&#xA;    Example: &#xA;            echo spellbadword(&quot;the quik brown fox&quot;)&#xA;           ['quik', 'bad'] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Good(word)&#xA;   return len(spellbadword(a:word)[0]) == 0&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo Good('crazy')&#xA;1&#xA;:echo Good('crzy')&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-02-24T16:47:47.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6664" PostTypeId="2" ParentId="6578" CreationDate="2016-02-24T18:11:33.513" Score="2" Body="&lt;p&gt;The error is from &lt;a href=&quot;https://github.com/bpowell/vim-android/blob/master/findAndroidManifest/after/ftplugin/java.vim#L36&quot; rel=&quot;nofollow&quot;&gt;vim-android&lt;/a&gt;. Your &lt;code&gt;project.properties&lt;/code&gt; file don't have a line with &lt;code&gt;target=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a new version for the java plugin &lt;a href=&quot;https://github.com/artur-shaik/vim-javacomplete2&quot; rel=&quot;nofollow&quot;&gt;vim-javacomplete2&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="177" LastActivityDate="2016-02-24T18:11:33.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6665" PostTypeId="1" AcceptedAnswerId="6675" CreationDate="2016-02-24T18:48:10.260" Score="6" ViewCount="411" Body="&lt;p&gt;Can I tell vim to assume a filename ends in &lt;code&gt;.tex&lt;/code&gt; if no extension is given? e.g. to open bird.tex if I say &lt;code&gt;:e bird&lt;/code&gt; (unless there is a file bird with no extension).&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="205" LastEditDate="2016-02-25T01:56:33.053" LastActivityDate="2016-02-25T06:48:17.200" Title="Setting a default file extension" Tags="|command-line|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6666" PostTypeId="1" CreationDate="2016-02-24T20:50:16.150" Score="2" ViewCount="402" Body="&lt;p&gt;I want to &lt;code&gt;:r[ead]&lt;/code&gt; a file into current buffer, and the file should be picked with the browser (that opens automatically e.g. when trying to &lt;code&gt;:e[dit]&lt;/code&gt; a directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:e ~/.vim/&lt;/code&gt; opens a file browser in the ~/.vim/ directory, but &lt;code&gt;:r ~/.vim/&lt;/code&gt; just complains about ~/.vim not being a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h browse&lt;/code&gt; seems to imply that &lt;code&gt;:bro r ~/.vim/&lt;/code&gt; should open a bowser to find a file to read, but it too doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb  9 2016 10:20:47)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Included patches: 1-1294&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Compiled by Arch Linux&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2082" LastEditorUserId="2082" LastEditDate="2016-02-24T22:12:04.760" LastActivityDate="2016-02-25T03:39:45.677" Title="Choose file with browser to :read into buffer" Tags="|filesystem|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6667" PostTypeId="2" ParentId="6650" CreationDate="2016-02-24T22:01:10.887" Score="4" Body="&lt;p&gt;I don't have an idea, but you can find out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When this happens again, do&#xA;&lt;code&gt;:verbose :set nu? rnu?&lt;/code&gt; and vim should tell you, which plugin turned it off.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-02-24T22:01:10.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6668" PostTypeId="2" ParentId="5499" CreationDate="2016-02-24T22:49:32.587" Score="1" Body="&lt;p&gt;You're asking to set up a search from the quickfix which as far as I know isn't possible via &lt;code&gt;errorformat&lt;/code&gt;. However you could write a function to do it and then map that function to a keymap or a command or something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function JumpToLinkerError()&#xA;    let l:matches = matchlist(getline('.'), '^[^:]*.o:\([^:]*\):.*'&#xA;                                         \. &quot;undefined reference to '\\([^']*\\)'&quot;)&#xA;    sbuffer l:matches[1]&#xA;    search('\&amp;lt;' . l:matches[2] . '\&amp;gt;')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although this makes some assumptions, such as the idea that 'test.c' is a buffer that you can switch to. Hopefully you can tweak to suit. It also doesn't handle any error conditions... Instead of &lt;code&gt;sbuffer&lt;/code&gt; maybe &lt;code&gt;sfind&lt;/code&gt; will work for you but that requires that you have set your &lt;code&gt;path&lt;/code&gt; correctly and it seems likely to me that if there's a new linker error it's probably in a file you were just editing.&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-24T22:49:32.587" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6669" PostTypeId="2" ParentId="6305" CreationDate="2016-02-24T22:58:52.557" Score="2" Body="&lt;p&gt;I had similar but different requirements for my &lt;code&gt;#include&lt;/code&gt; sorting. While this is tailored to C-like languages different functions with different patterns could be defined for other languages (or the pattern could simply be passed as a parameter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To hook up the automatic formatting right before saving:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre   *.{cpp,h,c,inl,cg,cgfx,fx}     call SortIncludes()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the meat. This sorts blocks of #includes, often I arrange them in sets based on whether they're project local, standard library, system, different dependent libraries... It also returns the cursor and window position to what it was before saving. (This also handles the case where some &lt;code&gt;#includes&lt;/code&gt; are part of a set but commented out or indented.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SortIncludes()&#xA;    let l:winview = winsaveview()&#xA;    call cursor(1, 1)&#xA;&#xA;    let l:done = 0&#xA;&#xA;    &quot; -- find the next line that starts with #include&#xA;    while !l:done &amp;amp;&amp;amp; search('^\(\s\|//\)*#include &quot;', 'W')&#xA;        let l:startline=line('.')&#xA;        &quot; -- and the next line that doesn't...&#xA;        let l:endline=search('^\(\(\s\|//\)*\)\@&amp;gt;\(#include\)\@!')&#xA;        if l:endline &amp;lt; l:startline&#xA;            let l:endline = line('$')&#xA;            let l:done = 1&#xA;        endif&#xA;        let l:lines=getline(l:startline, l:endline-1)&#xA;        let l:origlines=copy(l:lines)&#xA;        call sort(l:lines, 1)&#xA;        if l:origlines != l:lines&#xA;            call setline(l:startline, l:lines)&#xA;        endif&#xA;        call cursor(endline, 1)&#xA;    endwhile&#xA;&#xA;    call winrestview(l:winview)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-24T22:58:52.557" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6670" PostTypeId="2" ParentId="6666" CreationDate="2016-02-24T23:52:14.163" Score="1" Body="&lt;p&gt;When I try your command &lt;code&gt;:bro r ~/.vim/&lt;/code&gt;, I have the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E338: Sorry, no file browser in console mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There may be a native and simpler way, but assuming you use the default file browser netrw, then you could try the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup custom_netrw&#xA;    autocmd!&#xA;    autocmd FileType netrw nnoremap &amp;lt;buffer&amp;gt; e :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;ReadNetrw()&amp;lt;CR&amp;gt;&#xA;augroup END&#xA;&#xA;function! s:GetFileNames(first, last) abort&#xA;    &quot; Grab lines between first and last&#xA;    let l:files = getline(a:first, a:last)&#xA;&#xA;    &quot; If some of them are from the banner, remove them&#xA;    call filter(l:files, 'v:val !~# &quot;^\&quot; &quot;')&#xA;    &quot; If some of them are a directory, an executable, a fifo or a socket&#xA;    &quot; they end up with one of the symbols: /*|=&#xA;    &quot; Remove them&#xA;    call filter(l:files, 'v:val !~# &quot;[/*|=]$&quot;')&#xA;    &quot; Remove the text after the @ symbol (link):&#xA;    call map(l:files, &quot;substitute(v:val, '@\\t.*$', '', '')&quot;)&#xA;&#xA;    &quot; Prepend the path of the current directory in front of each filename&#xA;    return map(l:files, 'b:netrw_curdir . &quot;/&quot; . v:val')&#xA;endfunction&#xA;&#xA;function! s:ReadNetrw() abort&#xA;    &quot; Get the name of the file on the current line, and on following ones if&#xA;    &quot; a count was hit before the mapping (i.e. if v:count1 != 1)&#xA;    let l:files = s:GetFileNames(line('.'), line('.') - 1 + v:count1)&#xA;&#xA;    &quot; Go back to alternate buffer before reading&#xA;    b#&#xA;&#xA;    for i in range(len(l:files))&#xA;        &quot; Read each file&#xA;        execute 'read ' . l:files[i]&#xA;        &quot; After each insertion, move the cursor at the end of it&#xA;        ']&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It installs a buffer-local mapping on the &lt;code&gt;e&lt;/code&gt; key (&lt;code&gt;r&lt;/code&gt; seems already taken by netrw to reverse the sort order) which calls the function &lt;code&gt;ReadNetrw()&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you open netrw with &lt;code&gt;:e ~/.vim/&lt;/code&gt; and then hit &lt;code&gt;e&lt;/code&gt; on a file, its contents should be read in the alternate buffer (which should be the buffer from which you opened netrw).&lt;br&gt;&#xA;The mapping accepts a count, meaning that if you hit &lt;code&gt;3e&lt;/code&gt;, it should read the file under the cursor as well as the 2 following ones.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-02-25T03:39:45.677" LastActivityDate="2016-02-25T03:39:45.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6671" PostTypeId="2" ParentId="6665" CreationDate="2016-02-25T00:20:53.357" Score="1" Body="&lt;p&gt;Maybe you could try the following custom command &lt;code&gt;:E&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=file E&#xA;            \ let s:file = fnamemodify('&amp;lt;args&amp;gt;', ':p') |&#xA;            \ if fnamemodify(s:file, ':e') ==# '' &amp;amp;&amp;amp; !filereadable(s:file) |&#xA;            \     edit &amp;lt;args&amp;gt;.tex |&#xA;            \ else |&#xA;            \     edit &amp;lt;args&amp;gt; |&#xA;            \ endif |&#xA;            \ unlet s:file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It checks if the filename given as an argument has no extension if it doesn't exist. In this case, it executes &lt;code&gt;:edit {argument}.tex&lt;/code&gt;, otherwise it executes &lt;code&gt;:edit {argument}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you type: &lt;code&gt;:E bird&lt;/code&gt; it should load a buffer whose name is &lt;code&gt;bird.tex&lt;/code&gt; unless a file named &lt;code&gt;bird&lt;/code&gt; already exists.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-02-25T02:04:46.520" LastActivityDate="2016-02-25T02:04:46.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6672" PostTypeId="1" AcceptedAnswerId="6674" CreationDate="2016-02-25T01:32:25.077" Score="5" ViewCount="480" Body="&lt;p&gt;I have a large xhtml document that is broken into some 245 long paragraphs, each with a unique id in the form of &quot;ud###&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;p class=&quot;windowbg&quot; id=&quot;ud000&quot;&amp;gt;&#xA;   &amp;lt;!--- lots of content ---&amp;gt;&#xA;&amp;lt;/p&amp;gt;&#xA;...&#xA;&amp;lt;p class=&quot;windowbg&quot; id=&quot;ud244&quot;&amp;gt;&#xA;   &amp;lt;!--- and a bit more ---&amp;gt;&#xA;&amp;lt;/p&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since each 'paragraph' is several times larger than the viewport, i wanted to add links at the top of each to enable jumping around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what i came up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\&quot;ud\(\d\{3}\)\&quot;&amp;gt;/\=submatch(0).&quot;&amp;lt;a href =\&quot;#ud&quot;.printf(&quot;%03d&quot;, submatch(1) - 1).&quot;\&quot;&amp;gt;prev&amp;lt;\/a&amp;gt; &amp;lt;a href=\&quot;#ud&quot;.printf(&quot;%03d&quot;, submatch(1) + 1).&quot;\&quot;&amp;gt;next&amp;lt;\/a&amp;gt;&quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, the problem is that it didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first 9 replacements were perfect, with the relevant line coming out like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;p class=&quot;windowbg&quot; id=&quot;ud001&quot;&amp;gt;&amp;lt;a href=&quot;#ud000&quot;&amp;gt;prev&amp;lt;/a&amp;gt; &amp;lt;a href=&quot;#ud002&quot;&amp;gt;next&amp;lt;/a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But from 010 to 017, they came out weird, the links off by two &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;p class=&quot;windowbg&quot; id=&quot;ud010&quot;&amp;gt;&amp;lt;a href=&quot;#ud007&quot;&amp;gt;prev&amp;lt;/a&amp;gt; &amp;lt;a href=&quot;#ud009&quot;&amp;gt;next&amp;lt;/a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then 018 and 019 were perfect, 020 through 027 came out off by four, 028 and 029 were correct, 030 through 037 were off by 6...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how long the pattern holds, and I can't figure out why it shows up in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas? Is this some well known bug?&lt;/p&gt;&#xA;" OwnerUserId="6573" LastEditorUserId="4939" LastEditDate="2016-02-25T01:52:27.497" LastActivityDate="2016-02-25T08:48:38.320" Title="Substitution with math goes wrong" Tags="|substitute|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6673" PostTypeId="2" ParentId="6672" CreationDate="2016-02-25T01:43:20.490" Score="3" Body="&lt;p&gt;It's because Vim is interpreting the numbers as octal. See &lt;code&gt;:h octal&lt;/code&gt;. The suggestion there is to use &lt;code&gt;str2nr()&lt;/code&gt; so wrap your &lt;code&gt;submatch&lt;/code&gt; calls&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\&quot;ud\(\d\{3}\)\&quot;&amp;gt;/\=submatch(0).&quot;&amp;lt;a href =\&quot;#ud&quot;.printf(&quot;%03d&quot;, str2nr(submatch(1)) - 1).&quot;\&quot;&amp;gt;prev&amp;lt;\/a&amp;gt; &amp;lt;a href=\&quot;#ud&quot;.printf(&quot;%03d&quot;, str2nr(submatch(1)) + 1).&quot;\&quot;&amp;gt;next&amp;lt;\/a&amp;gt;&quot;/&#xA;                                                                   ^^^^^^^           ^                                                  ^^^^^^^           ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-25T01:43:20.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6674" PostTypeId="2" ParentId="6672" CreationDate="2016-02-25T01:44:59.817" Score="7" Body="&lt;p&gt;Octal numbers! Numbers starting with &lt;code&gt;0&lt;/code&gt; are taken to be in octal. So, 0010&lt;sub&gt;8&lt;/sub&gt; = 0008&lt;sub&gt;10&lt;/sub&gt;, and subtracting one, we get 0007&lt;sub&gt;10&lt;/sub&gt; = 0007&lt;sub&gt;8&lt;/sub&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#octal&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h octal&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                    octal&#xA;Conversion from a String to a Number is done by converting the first digits to&#xA;a number.  Hexadecimal &quot;0xf9&quot;, Octal &quot;017&quot;, and Binary &quot;0b10&quot; numbers are&#xA;recognized.  If the String doesn't start with digits, the result is zero.&#xA;…&#xA;To avoid a leading zero to cause octal conversion, or for using a different&#xA;base, use str2nr().&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, your substitution replacement will look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\=printf(&quot;%s &amp;lt;a href='#ud%03d'&amp;gt;prev&amp;lt;\/a&amp;gt; &amp;lt;a href='#ud%03d'&amp;gt;next&amp;lt;\/a&amp;gt;&quot;, submatch(0), str2nr(submatch(1)) - 1, str2nr(submatch(1)) + 1)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you can use a single &lt;code&gt;printf&lt;/code&gt; for the whole thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#str2nr%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;str2nr&lt;/code&gt;&lt;/a&gt; can take a base, but:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When {base} is omitted base 10 is used.  This also means that&#xA;a leading zero doesn't cause octal conversion to be used, as&#xA;with the default String to Number conversion.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-02-25T08:48:38.320" LastActivityDate="2016-02-25T08:48:38.320" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6675" PostTypeId="2" ParentId="6665" CreationDate="2016-02-25T02:20:07.317" Score="5" Body="&lt;p&gt;Adapting tricks I got from two of my previous questions, this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EditTex(name)&#xA;    if a:name !~ '\.[^/]*$'&#xA;        setlocal bufhidden=wipe&#xA;        exe 'e' fnameescape(a:name).'.tex'&#xA;        set bufhidden&amp;lt;&#xA;    endif&#xA;endfunction&#xA;&#xA;autocmd BufNewFile * nested call EditTex(expand('&amp;lt;afile&amp;gt;'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function checks if the filename has an extension, and if not, starts editing a TeX file with that name. Since a &lt;code&gt;BufNewFile&lt;/code&gt; &lt;code&gt;autocmd&lt;/code&gt; will only run for files that don't exist, we can avoid that check.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this, you can run &lt;code&gt;:e bird&lt;/code&gt; as you normally would.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sources:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/2009/205&quot;&gt;How do I make vim look in a set of directories for a file, if it doesn&amp;#39;t exist in the current directory?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/239/205&quot;&gt;How do I make Vim use a default filename when not given any filenames?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-02-25T06:48:17.200" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6676" PostTypeId="1" AcceptedAnswerId="6677" CreationDate="2016-02-25T06:41:41.490" Score="2" ViewCount="528" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/thinca/vim-quickrun&quot; rel=&quot;nofollow&quot;&gt;QuickRun&lt;/a&gt; to execute &lt;code&gt;php&lt;/code&gt; files or part of &lt;code&gt;php&lt;/code&gt; code by selecting it in &lt;code&gt;Visual Mode&lt;/code&gt;.&#xA;I have this mapping in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;r :QuickRun&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;leader&amp;gt;r :QuickRun&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;leader&amp;gt;rr &amp;lt;Esc&amp;gt;:QuickRun&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does work great.&#xA;But to make it work with selected code in &lt;code&gt;Visual Mode&lt;/code&gt; I have to add &amp;lt;&lt;code&gt;?php&lt;/code&gt; before selected text.&#xA;For example I have code like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;echo 'first line test';&#xA;echo &quot;\n&quot;;echo &quot;\n&quot;;&#xA;echo 'second line test';&#xA;echo &quot;\n&quot;;echo &quot;\n&quot;;&#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I select just this 2 lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo 'second line test';&#xA;echo &quot;\n&quot;;echo &quot;\n&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and by pressing &lt;code&gt;&amp;lt;leader&amp;gt;r&lt;/code&gt; how can I add &lt;code&gt;&amp;lt;?php&lt;/code&gt; tag before selected lines and then reselect it again to run it by &lt;code&gt;:QuickRun&amp;lt;CR&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3302" LastEditorUserId="205" LastEditDate="2016-02-25T08:42:08.227" LastActivityDate="2016-02-25T08:42:08.227" Title="How to add some text to selected text and reselect it again in visual mode?" Tags="|vimscript|visual-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6677" PostTypeId="2" ParentId="6676" CreationDate="2016-02-25T08:18:31.320" Score="4" Body="&lt;ul&gt;&#xA;&lt;li&gt;The visual mode range is stored in the &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%27%3c&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;'&amp;lt;&lt;/code&gt;&lt;/a&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; marks. You can set this with &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#m%3c&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;m&amp;lt;&lt;/code&gt;&lt;/a&gt; and &lt;code&gt;m&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You can start visual mode with the last selection with &lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#gv&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;gv&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;You can add lines to the buffer with the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#append%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;append()&lt;/code&gt;&lt;/a&gt; function.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Combining this, we could use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; The range keyword makes sure we run this function over the&#xA;&quot; entire range, instead of over each line in the range&#xA;fun! SetRange() range&#xA;    &quot; Append the text before the visual selection&#xA;    call append(line(&quot;'&amp;lt;&quot;) - 1, '&amp;lt;?php')&#xA;&#xA;    &quot; Expand visual selection by one line&#xA;    execute ':' . line(&quot;'&amp;lt;&quot;) - 1&#xA;    normal m&amp;lt;&#xA;&#xA;    &quot; Reselect&#xA;    normal gv&#xA;&#xA;    &quot; Run your function&#xA;    QuickRun&#xA;endfun&#xA;&#xA;noremap &amp;lt;Leader&amp;gt;r :call SetRange()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you also want to remove the added line, you could use the normal mode &lt;code&gt;dd&lt;/code&gt; command. Expanding this function to do that is left as an exercise for the reader ;-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-02-25T08:18:31.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6678" PostTypeId="2" ParentId="6177" CreationDate="2016-02-25T08:36:57.257" Score="11" Body="&lt;p&gt;Well, a bit belated but to respond to:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;6&quot;&gt;&#xA;  &lt;li&gt;Some magic (from a comment by Carpetsmoker in this thread)&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My general idea was that you always want to start &quot;private mode&quot; if you're using an encrypted file, so this autocommand will do that for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead * if &amp;amp;key!= &quot;&quot;&#xA;    \ | setlocal history=0 nobackup nomodeline noshelltemp noswapfile noundofile nowritebackup secure viminfo=&quot;&quot;&#xA;    \ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, every time a file is read from disk it checks if the &lt;code&gt;key&lt;/code&gt; setting is set (this is where your passphrased is stored), and if it is, it sets you settings. See &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocommand&quot;&gt;&lt;code&gt;:help autocommand&lt;/code&gt;&lt;/a&gt; for a general overview on how autocommands work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage to this is that can't forget to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, it requires that the file is encrypted. If it isn't, nothing is done. But not all is lost, we can use a filename to indicate a file is private, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead *.private setlocal ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would mark all files ending with &lt;code&gt;.private&lt;/code&gt; as such.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to randomly open files in &quot;private&quot; mode, then I would recommend using a simple shell alias, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vimprivate='vim -c &quot;source ~/.vim/private&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;~/.vim/private&lt;/code&gt; would contain:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal history=0 nobackup nomodeline noshelltemp noswapfile noundofile nowritebackup secure viminfo=&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why not &lt;code&gt;-u&lt;/code&gt;? Well, this way you have your own settings &lt;em&gt;and&lt;/em&gt; the &quot;private&quot; settings. You can also combine the two with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead * if &amp;amp;key!= &quot;&quot; | source ~/.vim/private | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-02-25T08:36:57.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6679" PostTypeId="1" AcceptedAnswerId="6680" CreationDate="2016-02-25T09:39:42.230" Score="3" ViewCount="1100" Body="&lt;p&gt;What exactly is Vim doing when executing the &lt;code&gt;:make&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was expecting that it just executes the content of the &lt;code&gt;makeprg&lt;/code&gt; variable just like running &lt;code&gt;:!make&lt;/code&gt; and additionally collects the output, but apparently the behavior is different. For example the terminal size is set up differently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example create a makefile with the following content&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;check:&#xA;    echo asdf &amp;gt; foo.txt&#xA;    aspell -c foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then compare the behavior of &lt;code&gt;:make&lt;/code&gt; and &lt;code&gt;:!make&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it different for you, too, or is this something strange with my setup?&lt;/p&gt;&#xA;" OwnerUserId="6584" LastEditorUserId="205" LastEditDate="2016-02-25T12:44:22.170" LastActivityDate="2016-02-25T12:44:22.170" Title="Terminal setup when running make from Vim" Tags="|makeprg|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6680" PostTypeId="2" ParentId="6679" CreationDate="2016-02-25T10:16:38.803" Score="5" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3Amake&quot;&gt;&lt;code&gt;:h :make&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The &quot;:make&quot; command executes the command given with the 'makeprg' option.&#xA;This is done by passing the command to the shell given with the 'shell'&#xA;option.  This works almost like typing&#xA;        &quot;:!{makeprg} [arguments] {shellpipe} {errorfile}&quot;.&#xA;&#xA;{makeprg} is the string given with the 'makeprg' option.  Any command can be&#xA;used, not just &quot;make&quot;.  …&#xA;&#xA;[arguments] is anything that is typed after &quot;:make&quot;.&#xA;{shellpipe} is the 'shellpipe' option.&#xA;{errorfile} is the 'makeef' option, with ## replaced to make it unique.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, it's not exactly the same as just &lt;code&gt;:!make&lt;/code&gt;. Following through, for &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27shellpipe%27&quot;&gt;&lt;code&gt;shellpipe&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                'shellpipe' 'sp'&#xA;'shellpipe' 'sp'        string  (default &quot;&amp;gt;&quot;, &quot;| tee&quot;, &quot;|&amp;amp; tee&quot; or &quot;2&amp;gt;&amp;amp;1| tee&quot;)&#xA;        …&#xA;        For Unix the default it &quot;| tee&quot;.  The stdout of the compiler is saved&#xA;        in a file and echoed to the screen.  If the 'shell' option is &quot;csh&quot; or&#xA;        &quot;tcsh&quot; after initializations, the default becomes &quot;|&amp;amp; tee&quot;.  If the&#xA;        'shell' option is &quot;sh&quot;, &quot;ksh&quot;, &quot;mksh&quot;, &quot;pdksh&quot;, &quot;zsh&quot; or &quot;bash&quot; the&#xA;        default becomes &quot;2&amp;gt;&amp;amp;1| tee&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, the actual command is more like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!make 2&amp;gt;&amp;amp;1 | tee bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And, in fact, if you run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aspell -c foo.txt 2&amp;gt;&amp;amp;1 | tee bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll get the same behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, this is &lt;a href=&quot;http://hitchhikers.wikia.com/wiki/Perfectly_Normal_Beast&quot;&gt;perfectly normal behaviour&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-02-25T10:16:38.803" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6681" PostTypeId="1" AcceptedAnswerId="6682" CreationDate="2016-02-25T13:20:56.657" Score="2" ViewCount="51" Body="&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;: I want to be able to quickly remove the last typed word while remaining in the Insert mode. However, &lt;code&gt;i_CTRL-W&lt;/code&gt; seems to be using &lt;code&gt;WORD&lt;/code&gt; definition of a word. I.e. it is not possible to just remove 'word' in &lt;code&gt;word-word-word&lt;/code&gt; even with &lt;code&gt;iskeyword=@,48-57,192-255,_,-&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;:help i_CTRL-W&lt;/code&gt;, I'm advised to &lt;code&gt;See the section &quot;word motions&quot;, |word-motions|, for the definition of a word.&lt;/code&gt; It is however unclear how its contents apply to &lt;code&gt;i_CTRL-W&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to achieve the desired behavior?&lt;/p&gt;&#xA;" OwnerUserId="6517" LastEditorUserId="51" LastEditDate="2016-02-25T15:03:11.450" LastActivityDate="2016-02-25T15:25:10.463" Title="Is there any way to influence how `i_CTRL-W` defines a word boundary of a word to be deleted?" Tags="|insert-mode|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6682" PostTypeId="2" ParentId="6681" CreationDate="2016-02-25T15:25:10.463" Score="3" Body="&lt;p&gt;As pointed out by comments to the question, &lt;code&gt;iskeyword&lt;/code&gt; actually has to influence &lt;code&gt;i_CTRL-W&lt;/code&gt; behavior and it indeed does. This was my misinterpretation of &lt;code&gt;iskeyword&lt;/code&gt; being a set of delimiters but it is of course a set of word characters instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So no wonder that having a &lt;code&gt;'-'&lt;/code&gt; in &lt;code&gt;iskeyword&lt;/code&gt; does not remove a single instance of &lt;em&gt;'word'&lt;/em&gt; from &lt;code&gt;word-word-word&lt;/code&gt; but all of it at once because it is considered to be a single word.&lt;/p&gt;&#xA;" OwnerUserId="6517" LastActivityDate="2016-02-25T15:25:10.463" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6683" PostTypeId="2" ParentId="6641" CreationDate="2016-02-25T16:17:28.870" Score="2" Body="&lt;p&gt;Didn't intend to reply to my own question, and this is not necessarily better than the &lt;code&gt;swapfile&lt;/code&gt; method, but this works too:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:w&lt;/code&gt; then &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#discard&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:e!&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I initially tried &lt;code&gt;:e&lt;/code&gt; as I mentioned but I hadn't tried &lt;code&gt;:e!&lt;/code&gt;. And I still have undo history with &lt;code&gt;:e!&lt;/code&gt; (tested only on Vim 7.4), just like with the &lt;code&gt;swapfile&lt;/code&gt; solution, &lt;em&gt;but&lt;/em&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The negative with this solution of course is that you will &lt;em&gt;lose any unsaved changes&lt;/em&gt; since that's ordinarily the purpose of the exclamation, to say &quot;I don't care if I lose changes since the last time saved,&quot; so make sure you use &lt;code&gt;:w&lt;/code&gt; before doing this. In these swap file error situations, I am always able to save just fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Vim docs mention that &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#discard&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:e!&lt;/code&gt;&lt;/a&gt; is useful when you want to &quot;start all over again&quot; which is kind of the situation here, though we don't want to needlessly throw away undo history:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:e! Edit the current file always.  Discard any changes to&#xA;  the current buffer.  This is useful if you want to&#xA;  start all over again.&lt;br&gt;&#xA;  - &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#discard&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :e!&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Because of the unsaved changes issue, I would say the &lt;code&gt;swapfile&lt;/code&gt; solution is overall the more advisable, even though &lt;code&gt;:e!&lt;/code&gt; is much quicker to type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A note on Vim 7.3: I believe you would more likely lose the undo history in 7.3 given a similar situation, since 7.4 has seemed to make improvements in reducing the number of situations where undo history is lost. (Thank you to Bram Moolenaar and whoever else helps him make Vim/GVim better!)&lt;/p&gt;&#xA;" OwnerUserId="6519" LastEditorUserId="6519" LastEditDate="2016-02-26T02:21:27.007" LastActivityDate="2016-02-26T02:21:27.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6684" PostTypeId="1" AcceptedAnswerId="6696" CreationDate="2016-02-25T16:17:40.397" Score="3" ViewCount="595" Body="&lt;p&gt;I have a command line tool that requires three parameters in the form of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command input1 input2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to write a custom complete function that handles completion for different arguments... well, differently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Determining which argument I'm on and returning a different set of completion options isn't hard; I've got that figured out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomCompletion(argLead, line, pos)&#xA;   let argList = split(a:line)&#xA;   if     len(argList) == 1&#xA;      &quot; Do completion for arg 1 (the command)&#xA;   elseif len(argList) == 2&#xA;      &quot; Do completion for arg 2&#xA;   elseif len(argList) == 3&#xA;      &quot; Do completion for arg 3&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is with the &quot;argLead&quot; variable. &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:command-completion-custom&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h command-completion-custom&lt;/code&gt;&lt;/a&gt; says this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ArgLead: the leading portion of the argument currently being&#xA;  completed on.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/6937984/is-there-a-way-to-make-use-of-two-custom-complete-functions-in-vim-script&quot;&gt;Places Iv'e researched&lt;/a&gt; seem to imply that this variable contains the current white-space separated argument that the cursor is on. However whenever I use it, the variable contains the whole command line (spaces and all). Additionally when I press tab after say, the second argument, the tab completion tries to match the whole command line instead just the current argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to tell the completion function to parse args based on white-space?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and I'm calling this function in the thrid paramater of input() if that makes any difference.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let user = input(&quot;Enter a command\n&quot;, &quot;&quot;, &quot;custom,CustomCompletion&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-02-26T19:35:06.587" Title="Using multiple arguments with custom tab completion" Tags="|autocompletion|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6685" PostTypeId="1" CreationDate="2016-02-25T16:40:38.960" Score="3" ViewCount="3558" Body="&lt;p&gt;I am on a Unixware 7.1 box and can't seem to get VI to backspace properly.  The current behavior is when you insert new characters and backspace over them, it will just shift the cursor to the left.  However, if I open a fresh file and do not type any new characters, the behavior of backspace is to do nothing at all.  The only time the cursor shifts is new files.  Here is my &lt;code&gt;.exrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ts=4&#xA;#set nocompatible&#xA;#set backspace=2&#xA;set bs=indent,eol,start&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also tried &lt;code&gt;set backspace=&lt;/code&gt; instead of &lt;code&gt;bs=&lt;/code&gt;.  As you can see I also tried the two commented out lines as well.  Here is what my &lt;code&gt;.profile&lt;/code&gt;looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stty intr &quot;^c&quot; erase &quot;^?&quot; swtch &quot;^z&quot; kill &quot;^u&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The current behavior of backspace in a regular terminal session (in putty) with that &lt;code&gt;.profile&lt;/code&gt; is to delete characters, so that aspect is working properly.  Any would be appreciated!&lt;/p&gt;&#xA;" OwnerUserId="6587" LastEditorUserId="205" LastEditDate="2016-02-26T03:11:33.427" LastActivityDate="2020-08-13T10:20:40.937" Title="Backspace does nothing" Tags="|insert-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6686" PostTypeId="2" ParentId="6685" CreationDate="2016-02-25T16:55:13.363" Score="6" Body="&lt;p&gt;I had to put the following in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map! &amp;lt;C-h&amp;gt; &amp;lt;BS&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note! Different systems handle backspace differently. To find out what your backspace is getting mapped to, start vi and go into insert mode. Press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; and then &lt;kbd&gt;Backspace&lt;/kbd&gt;. Most likely vim will output something like &lt;code&gt;^H&lt;/code&gt;. This means that Vi is not seeing backspace, but actually &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;H&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you figure out what Vi is seeing you can simply remap that to backspace as I did.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="205" LastEditDate="2016-02-26T03:13:00.550" LastActivityDate="2016-02-26T03:13:00.550" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6687" PostTypeId="2" ParentId="6550" CreationDate="2016-02-25T17:52:29.267" Score="2" Body="&lt;p&gt;Over the past week I've decided I was wrong about re-running &lt;code&gt;ClangUpdateQuickFix&lt;/code&gt; on a buffer containing the header not working. Although I would never have written that if I had not tried several times, it was probably all during the same session -- meaning I could have overlooked something such as having pre-compiled the headers with a different user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, re-clanging the header in vim seems to do the trick.&lt;/p&gt;&#xA;" OwnerUserId="4913" LastActivityDate="2016-02-25T17:52:29.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6688" PostTypeId="1" CreationDate="2016-02-25T21:49:24.010" Score="1" ViewCount="262" Body="&lt;p&gt;Are there any plugins to check code quality real-time when programming in vim? similar to tools like ReSharper(I imagine, I have only seen them used and never tried them myself) I would be interested in any plugins for refactoring, real-time format detection, code smell detection etc. It's not imperative but it would be nice! Would be nice to check for abbreviations and words not in my project glossary too, to ensure readability. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently particularly interested in c# for the unity game engine, but I prefer my tools to be as generic and widely applicable as possible! If possible, I would like all my tools to be open source, easily extended, well documented, as generic as possible. I want my tools to be available for all my needs for years to come, regardless of which operating system or programming language etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that's obviously asking quite a lot. But at the very least it would have to satisfy my current requirements, to be useful with C#. &lt;/p&gt;&#xA;" OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2016-02-25T22:54:31.650" LastActivityDate="2016-02-25T23:51:17.097" Title="vim plugins for improved workflow - any like this?" Tags="|ide|" AnswerCount="1" CommentCount="3" ClosedDate="2016-03-02T10:37:56.003" ContentLicense="CC BY-SA 3.0" />
  <row Id="6689" PostTypeId="2" ParentId="6688" CreationDate="2016-02-25T23:51:17.097" Score="3" Body="&lt;p&gt;I've got a &lt;a href=&quot;https://github.com/LucHermitte/vim-refactor&quot; rel=&quot;nofollow&quot;&gt;generic refactoring plugin&lt;/a&gt; for Vim. It's mainly tuned for the languages I work with (C++, VimL, ...). It can be extended to C#, however there already exist &lt;a href=&quot;http://vim.wikia.com/wiki/Vim_as_a_refactoring_tool_and_some_examples_in_C_sharp&quot; rel=&quot;nofollow&quot;&gt;refactoring &quot;things&quot; for C#&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this time, it relies on ctags. Someday I'd like to look into what is possible with clang (I know there is &lt;a href=&quot;https://github.com/realincubus/vim-clang-refactor&quot; rel=&quot;nofollow&quot;&gt;https://github.com/realincubus/vim-clang-refactor&lt;/a&gt;, but it doesn't seem to permit to automatically apply naming policies). BTW, the extract method/function refactoring doesn't work as well as I'd like to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding code smells detection, it requires the use and integration of other tools. It won't be very easy to have something generic as all languages have different code smells and good practices. syntastic plugin may be a first step in that direction. Note, that in lh-cpp I have a few syntax highlights that detect things like &lt;code&gt;if (foo = 42)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-02-25T23:51:17.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6690" PostTypeId="2" ParentId="84" CreationDate="2016-02-26T07:18:22.420" Score="-1" Body="&lt;p&gt;Every other answer has covered all the important things about the registers. I would like to add one more thing that I use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a way in Vim to directly copy the &lt;strong&gt;visually selected&lt;/strong&gt; text in to the clipboard. Just put this in your &lt;em&gt;vimrc&lt;/em&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guioptions+=a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And, with this whenever you visually select some text it will be copied to your clipboard. For more information on this, &lt;code&gt;:help guioptions&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, this is only for gVim.&lt;/p&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="927" LastEditDate="2017-07-01T19:53:30.980" LastActivityDate="2017-07-01T19:53:30.980" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6691" PostTypeId="1" CreationDate="2016-02-26T11:11:41.337" Score="8" ViewCount="129" Body="&lt;p&gt;When searching for a phrase in hard-wrapped text, one wants newlines to be treated as spaces.  Can one have that happen?  Saying &lt;code&gt;/the\_sphrase\_sI\_sseek&lt;/code&gt; is a bit awkward.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2016-02-26T14:52:40.993" LastActivityDate="2023-01-23T16:33:48.720" Title="Searching for a phrase in hard-wrapped text" Tags="|search|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6692" PostTypeId="1" AcceptedAnswerId="6699" CreationDate="2016-02-26T11:34:39.200" Score="4" ViewCount="6455" Body="&lt;p&gt;I'm using YouCompleteMe to do omni complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of these are fine. But when I want to complete Python3, there is something wrong. It only can complete python2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import urllib # Python2 &amp;amp; Python3 mod&#xA;&#xA;urllib.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to complete to &lt;code&gt;urllib.request.Request&lt;/code&gt;, but the completion menu doesn't have it. It is the same as Python2's &lt;code&gt;urlopen&lt;/code&gt;. (In Python3, it is &lt;code&gt;urllib.request.urlopen&lt;/code&gt;, but now is &lt;code&gt;urllib.urlopen&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have installed &lt;code&gt;jedi&lt;/code&gt; with both pip and pip3 ( &lt;code&gt;import jedi&lt;/code&gt; can be done in Python3 and Python2 )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have set &lt;code&gt;let g:ycm_python_binary_path = '/usr/local/bin/python3'&#xA;&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it seems to have no effect.&lt;/p&gt;&#xA;" OwnerUserId="2514" LastEditorUserId="205" LastEditDate="2016-02-26T21:29:45.470" LastActivityDate="2016-02-27T01:37:17.203" Title="How do I complete Python3 with YouCompleteMe?" Tags="|plugin-you-complete-me|filetype-python|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6693" PostTypeId="1" CreationDate="2016-02-26T14:56:39.100" Score="12" ViewCount="6844" Body="&lt;pre&gt;&lt;code&gt;This is a sample sentence.&#xA;This is a second sample sentence.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's say I select 'is a' of the first sentence. Now I want to change all occurrences of what is selected (including the selection itself) to 'is not a'. How do I do that?&lt;/p&gt;&#xA;" OwnerUserId="6542" LastEditorUserId="4939" LastEditDate="2016-02-26T15:00:55.270" LastActivityDate="2016-02-26T18:55:51.093" Title="Replace current selection and all identical occurrences in a file" Tags="|replace|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6694" PostTypeId="2" ParentId="6693" CreationDate="2016-02-26T15:13:57.997" Score="11" Body="&lt;p&gt;You could execute the following command: &lt;code&gt;:%s/is a/is not a&lt;/code&gt;&#xA;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Select and yank &lt;code&gt;is a&lt;/code&gt; with your favorite method (visual selection and &lt;kbd&gt;y&lt;/kbd&gt;, &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; with cursor on &lt;code&gt;is&lt;/code&gt;, etc...)&lt;/li&gt;&#xA;&lt;li&gt;Enter command mode with &lt;kbd&gt;:&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Begin to write your replacement command &lt;code&gt;%s/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Insert the text to replace with &lt;kbd&gt;Ctrl+r&lt;/kbd&gt; and &lt;kbd&gt;&quot;&lt;/kbd&gt;. (see &lt;strong&gt;Note2&lt;/strong&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Finish to write the replacement command &lt;code&gt;/is not a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Execute the replacement command with &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; if you have several occurrences of &lt;code&gt;is a&lt;/code&gt; on same line use the &lt;code&gt;g&lt;/code&gt; tag to substitute all occurrences of a same line: &lt;code&gt;:%s/is a/is not a/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 2&lt;/strong&gt; When you are in insert mode &lt;kbd&gt;Ctrl+r&lt;/kbd&gt; allows you to choose a register and to insert its content. When you yanked your text in the first step you yanked it to the unnamed register which is accessible with &lt;kbd&gt;&quot;&lt;/kbd&gt;. So when you type &lt;kbd&gt;Ctrl+r&lt;/kbd&gt; followed by &lt;kbd&gt;&quot;&lt;/kbd&gt; you're inserting the text you yanked before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-R&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-R&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#registers&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h registers&lt;/code&gt;&lt;/a&gt; as advised by @VanLaser for more details about registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:s&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :s&lt;/code&gt;&lt;/a&gt; for more informations about the search and replace function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; I had not seen the comment of @VanLaser who basically gave the same solution, sorry.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-02-26T16:08:16.977" LastActivityDate="2016-02-26T16:08:16.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6695" PostTypeId="2" ParentId="6693" CreationDate="2016-02-26T16:58:51.057" Score="8" Body="&lt;h3&gt;Using &lt;code&gt;gn&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt; for quick replacements&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;gn&lt;/code&gt; motion to make replacing matches quicker. Simply search for your text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then change the current match with the change operator, &lt;code&gt;c&lt;/code&gt;, and the &lt;code&gt;gn&lt;/code&gt; motion.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cgnbar&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Simply repeat this via the &lt;code&gt;.&lt;/code&gt; command as many times as you wish. You can also use &lt;code&gt;n&lt;/code&gt; to jump to the next match in case you want to skip any matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a nice Vimcasts episode on this topic: &lt;a href=&quot;http://vimcasts.org/episodes/operating-on-search-matches-using-gn/&quot; rel=&quot;noreferrer&quot;&gt;Operating on search matches using gn&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h gn&#xA;:h /&#xA;:h .&#xA;:h n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Aside: Tips on searching for selected text&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim's help doc provides the following mapping under &lt;code&gt;:h visual-search&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vmap X y/&amp;lt;C-R&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is better than searching by hand however it does not take escaping into consideration and causes the side effect of overwriting the unnamed register. Some of this can be mitigated by using &lt;code&gt;\V&lt;/code&gt; to turn on &quot;very &lt;code&gt;'nomagic'&lt;/code&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I would get a &lt;a href=&quot;https://github.com/nelstrom/vim-visual-star-search&quot; rel=&quot;noreferrer&quot;&gt;visual star&lt;/a&gt; plugin (&lt;a href=&quot;http://vimawesome.com/?q=star&quot; rel=&quot;noreferrer&quot;&gt;there are few out there&lt;/a&gt;). There is a nice Vimcast about this: &lt;a href=&quot;http://vimcasts.org/episodes/search-for-the-selected-text/&quot; rel=&quot;noreferrer&quot;&gt;Search for the selected text&lt;/a&gt;. This means you can select the line visually and then press &lt;code&gt;*&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a plugin isn't your thing you can add the following mapping to your &lt;code&gt;vimrc&lt;/code&gt; to mimic a visual star plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap * :&amp;lt;c-u&amp;gt;let @/=@&quot;&amp;lt;cr&amp;gt;gvy:let [@/,@&quot;]=[@&quot;,@/]&amp;lt;cr&amp;gt;/\V&amp;lt;c-r&amp;gt;=substitute(escape(@/,'/\'),'\n','\\n','g')&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: The mapping above will not work for visual-block mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h visual-search&#xA;:h c_CTRL-R&#xA;:h /\V&#xA;:h /magic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2016-02-26T18:55:51.093" LastActivityDate="2016-02-26T18:55:51.093" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6696" PostTypeId="2" ParentId="6684" CreationDate="2016-02-26T19:35:06.587" Score="2" Body="&lt;p&gt;I believe that saginaw is correct. The problem resides in the fact that &lt;code&gt;input()&lt;/code&gt; handles completion differently than the &lt;code&gt;command!&lt;/code&gt; function. I don't think that the author of the &lt;code&gt;input()&lt;/code&gt; function gave much thought to custom completion and only added partial support for it. As saginaw mentions, the &lt;code&gt;intput()&lt;/code&gt; function has no &lt;code&gt;-nargs&lt;/code&gt; parameter like &lt;code&gt;command!&lt;/code&gt;. As a result the &lt;code&gt;ArgLead&lt;/code&gt; parameter will always be the whole command line, and consequently the match will always be performed against the whole command line.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Workaround:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;One possible solution is to prepend the previously typed arguments for completion. That way when the match is performed it will at least be able to see that the user input matches the predefined completions. I accomplished this in this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomCompletion(argLead, line, pos)&#xA;   let argList = split(a:line)&#xA;   let returnString = &quot;&quot;&#xA;   if     len(argList) == 1&#xA;      &quot; This is the first argument so nothing special here&#xA;&#xA;   elseif len(argList) == 2&#xA;      &quot; Second argument needs to add first argument to completion&#xA;      for item in myCompletionList&#xA;         let returnString .= argList[0] . &quot; &quot; . item . &quot;\n&quot;&#xA;      endfor&#xA;      return returnString&#xA;&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does work reasonably well. The drawback is that if you have &lt;code&gt;windmenu&lt;/code&gt; set, the suggestions include the whole command line which is kind of annoying and hard to see if you have a lot of items.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/6pyzS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6pyzS.png&quot; alt=&quot;Whole command line match&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At present I see no other alternatives, so this will have to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as the other issue that saginaw mentioned, that is solved (as he stated) &lt;a href=&quot;https://stackoverflow.com/questions/6937984/is-there-a-way-to-make-use-of-two-custom-complete-functions-in-vim-script&quot;&gt;here&lt;/a&gt;. However, I didn't include it in the code since I didn't think it was relevant to the current problem and would just clutter the example.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-02-26T19:35:06.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6697" PostTypeId="1" CreationDate="2016-02-26T22:29:23.450" Score="14" ViewCount="2318" Body="&lt;p&gt;If I have the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I visually select it and copy it.&lt;br&gt;&#xA;The text is now stored in the unnamed register &lt;code&gt;&quot;&lt;/code&gt; and here is its contents (output of &lt;code&gt;:reg &quot;&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;   foo^Jbar^J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to this &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII#ASCII_control_code_chart&quot; rel=&quot;nofollow noreferrer&quot;&gt;chart&lt;/a&gt;, it seems &lt;code&gt;^J&lt;/code&gt; is the caret notation for a Line Feed.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I want to duplicate the unnamed register in the &lt;code&gt;a&lt;/code&gt; register by typing: &lt;code&gt;:let @a = @&quot;&lt;/code&gt;&lt;br&gt;&#xA;Here is its contents (output of &lt;code&gt;:reg a&lt;/code&gt;):  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;a   foo^Jbar^J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It didn't change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I now duplicate it in the search register by typing &lt;code&gt;:let @/ = @&quot;&lt;/code&gt;, here is its contents (output of &lt;code&gt;:reg /&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;/   foo^@bar^@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to the previous chart, it seems &lt;code&gt;^@&lt;/code&gt; is the caret notation for a Null character.&lt;br&gt;&#xA;Why is a Line Feed automatically converted into a Null character inside the search register (but not the &lt;code&gt;a&lt;/code&gt; register)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I insert the unnamed register on the command line (or inside a search after &lt;code&gt;/&lt;/code&gt;), by typing &lt;code&gt;:&amp;lt;C-R&amp;gt;&quot;&lt;/code&gt;, here is what is inserted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:foo^Mbar^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, according to the last chart, &lt;code&gt;^M&lt;/code&gt; seems to be the caret notation for a Carriage Return.&lt;br&gt;&#xA;Why is a Line Feed automatically converted into a Carriage Return on the command line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually you can insert a literal control character by typing:&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;C-{character in caret notation}&amp;gt;&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you can insert a literal &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; by typing &lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;.&lt;br&gt;&#xA;You can do it for seemingly any control character.&lt;br&gt;&#xA;However I've noticed that I'm unable to insert a literal LF inside a buffer or on the command line, because if I type: &lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;C-J&amp;gt;&lt;/code&gt; it inserts &lt;code&gt;^@&lt;/code&gt;, a null character, instead of &lt;code&gt;^J&lt;/code&gt;.&lt;br&gt;&#xA;Is it for the same reason a LF is converted into NUL inside the search register?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;:h key-notation&lt;/code&gt;, we can read this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Nul&amp;gt;       zero            CTRL-@    0 (stored as 10) &amp;lt;Nul&amp;gt;&#xA;&amp;lt;NL&amp;gt;        linefeed        CTRL-J   10 (used for &amp;lt;Nul&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;stored as 10&lt;/code&gt; part on the first line and &lt;code&gt;used for &amp;lt;Nul&amp;gt;&lt;/code&gt; on the second line could indicate that there's some sort of overlap between a LF and a NUL, and that they could be interpreted as the same thing. But they can't be the same thing, because after executing the previous command &lt;code&gt;:let @/ = @&quot;&lt;/code&gt;, if I type &lt;code&gt;n&lt;/code&gt; in normal mode to get to the next occurrence of the 2 lines &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;bar&lt;/code&gt;, instead of getting a positive match, I have the following error message:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E486: Pattern not found: foo^@bar^@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Besides this &lt;a href=&quot;https://stackoverflow.com/a/12876441&quot;&gt;link&lt;/a&gt; seems to explain that a NUL denotes the end of a string, whereas a LF denotes the end of a line in a text file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if a NUL is &lt;code&gt;stored as 10&lt;/code&gt; as the help says, which is the same code as for a LF, how is Vim able to make the difference between the 2?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 3&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe a LF and a NUL are coded with the same decimal code, &lt;code&gt;10&lt;/code&gt;, as the help says. And Vim makes the difference between the 2 thanks to the context. If it meets a character whose decimal code is &lt;code&gt;10&lt;/code&gt; in a buffer or any register, except the search and command registers, it interprets it as a LF.&lt;br&gt;&#xA;But in the search register (&lt;code&gt;:reg /&lt;/code&gt;) it interprets it as a NUL because in the context of a search, Vim only searches for a string where the concept of &lt;code&gt;end of line in a file&lt;/code&gt; doesn't make sense because a string is not a file (which is weird since you can still use the atom &lt;code&gt;\n&lt;/code&gt; in a searched pattern, but maybe that's only a feature of the regex engine?). So it automatically interprets &lt;code&gt;10&lt;/code&gt; as a NUL because it's the nearest concept (&lt;code&gt;end of string&lt;/code&gt; ≈ &lt;code&gt;end of line&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And in the same way, on the command line / command register (&lt;code&gt;:reg :&lt;/code&gt;) it interprets the code &lt;code&gt;10&lt;/code&gt; as a CR, because the concept of &lt;code&gt;end of line in a file&lt;/code&gt; doesn't make sense here. The nearest concept is &lt;code&gt;end of command&lt;/code&gt; so Vim interprets &lt;code&gt;10&lt;/code&gt; as a CR, because hitting &lt;code&gt;Enter&lt;/code&gt; is the way to end/execute a command and a CR is the same as hitting &lt;code&gt;Enter&lt;/code&gt;, since when you insert a literal one with &lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;, &lt;code&gt;^M&lt;/code&gt; is displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe the interpretation of the character whose code is &lt;code&gt;10&lt;/code&gt; changes according to the context:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;end of line in a buffer (&lt;code&gt;^J&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;end of string in a search (&lt;code&gt;^@&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;end of command on the command line (&lt;code&gt;^M&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-10-10T06:01:19.910" Title="Why is a Line Feed converted into a Null character inside the search register and into a Carriage Return on the command line?" Tags="|search|register|line-breaks|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6698" PostTypeId="1" CreationDate="2016-02-27T01:29:53.640" Score="5" ViewCount="1956" Body="&lt;p&gt;I am frequently editing markdown files, and when dealing with multi-line items in hierarchical lists, it would be great to have a rapid way to indent or un-indent a list item.  For example, how can I most easily indent the longest multi-line list item in the following text?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- Some list item&#xA;- Another list item that is long and so&#xA;  is split onto multiple lines&#xA;  that are more&#xA;  than I want to have to count&#xA;  or select manually&#xA;  - A sub-list item that is also&#xA;    split onto multiple lines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the list items were empty-line-separated then of course I could use &lt;code&gt;&amp;gt;ap&lt;/code&gt; but as it is I am using &lt;code&gt;5&amp;gt;&amp;gt;&lt;/code&gt; which involves counting, and of course I have to be at the first line of the list item to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note: I am mostly allergic to plugins.)&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2016-02-28T16:00:02.820" Title="Indent a markdown list item?" Tags="|indentation|filetype-markdown|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6699" PostTypeId="2" ParentId="6692" CreationDate="2016-02-27T01:37:17.203" Score="3" Body="&lt;p&gt;I tried to update YCM and recompile it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, it is fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Python3 support was added for last month and I just updated YCM last month.&lt;/p&gt;&#xA;" OwnerUserId="2514" LastActivityDate="2016-02-27T01:37:17.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6700" PostTypeId="2" ParentId="6698" CreationDate="2016-02-27T06:24:34.490" Score="4" Body="&lt;p&gt;Maybe you could try defining a custom object &lt;code&gt;li&lt;/code&gt; for list item. This way you could operate on it with any operator including &lt;code&gt;&amp;gt;&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A way to do that is to define a visual mapping with &lt;code&gt;:xnoremap&lt;/code&gt; which selects your object.&lt;br&gt;&#xA;Then you would define your list item object with &lt;code&gt;:onoremap li :normal vli&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;br&gt;&#xA;The &lt;code&gt;:onoremap&lt;/code&gt; mapping would tell Vim that whenever you hit &lt;code&gt;li&lt;/code&gt; after an operator, it would be the same as if you were in visual mode and had selected your object with the motion &lt;code&gt;li&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For example, let's say you want to create the object &lt;code&gt;i_&lt;/code&gt; for &lt;code&gt;inside underscores&lt;/code&gt; to operate on &lt;code&gt;bar&lt;/code&gt; in &lt;code&gt;foo_bar_baz&lt;/code&gt;. You could include this in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap i_ T_ot_&#xA;onoremap i_ :normal vi_&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the &lt;code&gt;{rhs}&lt;/code&gt; of the &lt;code&gt;:xnoremap&lt;/code&gt; mapping is &lt;code&gt;T_ot_&lt;/code&gt;, which is a motion which should select the text between 2 consecutive underscores on the same line.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;T_    move the left-hand side of the visual selection until the previous underscore&#xA;o     give the focus to the other side of the selection&#xA;t_    move the right-hand side of the selection until the next underscore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now to delete, change, yank or select the text between the two surrounding underscores, you could type &lt;code&gt;di_&lt;/code&gt;, &lt;code&gt;ci_&lt;/code&gt;, &lt;code&gt;yi_&lt;/code&gt;, &lt;code&gt;vi_&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In your case, it's more complex because you don't want to operate on the text between 2 consecutive underscores but between 2 consecutive lines beginning with a dash.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the tricky part would be the &lt;code&gt;{rhs}&lt;/code&gt; of the visual mapping which selects your object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a possible implementation, which is not very robust but seems to work on the simple example you provided:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;silent&amp;gt; li :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;ListItem()&amp;lt;CR&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; li :normal vli&amp;lt;CR&amp;gt;&#xA;&#xA;function! s:ListItem() abort&#xA;    if search('^\s*-', 'bcW') != 0&#xA;        call search('\v.\n\s*(-|$)', 'sW')&#xA;        normal! v``&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's the same thing as before, except this time the motion is managed by a function: &lt;code&gt;ListItem()&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function looks backward for the pattern &lt;code&gt;^\s*-&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^     beginning of line&#xA;\s*   zero or more whitespace&#xA;-     a dash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it finds something it then looks for the pattern &lt;code&gt;\v^\s*(-|$)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v       very magic mode&#xA;.        any character except a newline&#xA;\n       a newline&#xA;\s*      zero or more whitespace&#xA;(-|$)    a dash or an end of line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;search()&lt;/code&gt; function can be used with several flags, here there are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b    look backwards instead of forward&#xA;c    accept a match at current cursor position&#xA;s    set the mark ' before jumping to the match&#xA;W    don't wrap around the end of the file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last command in the function &lt;code&gt;normal! v``&lt;/code&gt; is responsible for selecting the object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v      go into visual mode&#xA;``     move the left-hand side of the selection to the location before&#xA;       the last search (to the beginning of the item)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I don't think it's very robust, for example if your cursor is after the last item, hitting &lt;code&gt;vli&lt;/code&gt; shouldn't select anything. But here, it will select the last item anyway. To solve this, the regexes passed to the &lt;code&gt;search()&lt;/code&gt; function should be tweaked.&#xA;For example, the first one should not match a &lt;code&gt;^\s*-&lt;/code&gt; if there's an empty line between it and the current cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still, it seems to work on your example by hitting &lt;code&gt;&amp;gt;li&lt;/code&gt; while the cursor is in any of the 3 items, without the need to count the number of lines or to be at the beginning of the item. So maybe it can be improved.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-02-28T16:00:02.820" LastActivityDate="2016-02-28T16:00:02.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6701" PostTypeId="1" CreationDate="2016-02-27T08:08:25.963" Score="5" ViewCount="281" Body="&lt;p&gt;I've enabled the relativenumbers in Vim. I would like to automate the following operation. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ma(number)(j|k)yy`a(p|P)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that is to say:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;mark the curr position in 'a'&lt;/li&gt;&#xA;&lt;li&gt;move up or down by 'number' lines&lt;/li&gt;&#xA;&lt;li&gt;yank current line&lt;/li&gt;&#xA;&lt;li&gt;jump back to position 'a'&lt;/li&gt;&#xA;&lt;li&gt;put line up or down&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm looking for an easier way to perform the same. Is there one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="6601" LastEditorUserId="51" LastEditDate="2016-02-27T08:28:53.463" LastActivityDate="2016-02-27T08:44:04.623" Title="yank and append line relative to the current one" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6702" PostTypeId="2" ParentId="6701" CreationDate="2016-02-27T08:44:04.623" Score="5" Body="&lt;p&gt;I guess I found the right way to do it with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.(+|-)(number)y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.-3y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;yanks 3 lines above.&lt;/p&gt;&#xA;" OwnerUserId="6601" LastActivityDate="2016-02-27T08:44:04.623" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6703" PostTypeId="1" AcceptedAnswerId="6704" CreationDate="2016-02-27T10:17:58.623" Score="4" ViewCount="159" Body="&lt;p&gt;I am playing around with vim syntax, matching expressions like &lt;code&gt;name.subname&lt;/code&gt; regardless of their layout. Here is a match pattern I came upon which does exactly what I want:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fcTSV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fcTSV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I wish that &lt;code&gt;subname&lt;/code&gt; would be the only colored part of my matches. This is a job for &lt;code&gt;\zs&lt;/code&gt;, right? Here is the result:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cmEdV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cmEdV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this so? Why does &lt;code&gt;\zs&lt;/code&gt; break my pattern? How can I get all &lt;code&gt;subnames&lt;/code&gt; in the first section colored and not the ones in the second section?&lt;/p&gt;&#xA;" OwnerUserId="2978" LastActivityDate="2016-02-27T17:03:29.420" Title="Start of match \zs seems to break my pattern" Tags="|syntax-highlighting|regular-expression|delimiter-matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6704" PostTypeId="2" ParentId="6703" CreationDate="2016-02-27T10:29:13.977" Score="5" Body="&lt;p&gt;Well, here is my explanation: there are restrictions on multi-line patterns for syntax highlighting: &lt;code&gt;\zs&lt;/code&gt; cannot be used if it makes it jump to a line which is not where the pattern started:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helph syn-multi-line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is a neat workaround with the keyword &lt;code&gt;contains&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight link SubGroup Error&#xA;syntax match SubGroup '\&amp;lt;subname\&amp;gt;' contained&#xA;syntax match Constant '\&amp;lt;name\&amp;gt;[ \n]*\.[ \n]*\&amp;lt;subname\&amp;gt;' contains=SubGroup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u2Pvl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u2Pvl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, here is another, maybe more efficient one: only highlight the end of the pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Error &quot;\&amp;lt;name\&amp;gt;[ \n]*\.[ \n]*\&amp;lt;subname\&amp;gt;&quot;he=-6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it seems to randomly color or not the intermediate &lt;code&gt;.&lt;/code&gt; though.&lt;/p&gt;&#xA;" OwnerUserId="2978" LastEditorUserId="2978" LastEditDate="2016-02-27T17:03:29.420" LastActivityDate="2016-02-27T17:03:29.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6705" PostTypeId="1" AcceptedAnswerId="6706" CreationDate="2016-02-27T13:31:28.633" Score="5" ViewCount="354" Body="&lt;p&gt;I want to be able to easily change the filename. This works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! var=%; mv % ${var/.txt/.asc}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this doesn't:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! mv % ${%/.txt/.asc}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Why doesn't this work? Doesn't VIM simply replace &lt;code&gt;%&lt;/code&gt; with the current filepath?       &lt;/li&gt;&#xA;&lt;li&gt;How can I use shell variable substitution with the current filename (in a more elegant way than the first I proposed).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4947" LastEditorUserId="205" LastEditDate="2016-02-27T15:36:48.887" LastActivityDate="2016-02-27T15:36:48.887" Title="Use shell variable substitution with current filepath" Tags="|command-line|external-command|bash|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6706" PostTypeId="2" ParentId="6705" CreationDate="2016-02-27T14:39:11.743" Score="9" Body="&lt;h2&gt;Why doesn't this work?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This doesn't work for exactly why you say, vim is replacing the % with the path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, your non working line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! mv % ${%/.txt/.asc}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is expanding to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! mv myfile.txt ${myfile.txt/.txt/.asc}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which bash will call a bad substitution; You are trying to expand a variable called myfile.txt, and bash doesn't support variable names with . in them (and the . may mean something else).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How can I do shell substitution?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;After a quick search, I could find no way to do substitutions without first assigning a value to a shell variable and operating on the variable itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not what you asked, but you could achieve similar results using Vim's filename-modifiers (&lt;code&gt;:help filename-modifiers&lt;/code&gt;) like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! mv % %:r.asc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:r&lt;/code&gt; after the % removes the last extension, and then we append &lt;code&gt;.asc&lt;/code&gt; to it. The downside is that, if the extension wasn't .txt, we're still replacing it with .asc, but maybe that's what you want anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! mv % %:s?.txt?.asc?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which does exactly like your bash example, I think, and has the bonus of giving you the full power of Vim's substitute command on the filename. Here the :s modifier invokes substitute logic just like the &lt;code&gt;:s&lt;/code&gt; ex command. Their example uses &lt;code&gt;?&lt;/code&gt; as the separation character instead of &lt;code&gt;/&lt;/code&gt; because you are more likely to use &lt;code&gt;/&lt;/code&gt; in file paths than &lt;code&gt;?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing you don't get are flags after the substituted text bit. Since the most likely flag you'd want is &lt;code&gt;g&lt;/code&gt; (to match all occurrences on this &quot;line&quot;), you can use &lt;code&gt;:gs?pat?sub?&lt;/code&gt; instead of &lt;code&gt;:s?pat?sub?&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2016-02-27T14:39:11.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6707" PostTypeId="2" ParentId="6291" CreationDate="2016-02-27T16:23:44.100" Score="5" Body="&lt;p&gt;As @carpetsmoker mentioned, recorded macros are stored in registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Non-empty registers are saved to your viminfo file when you exit Vim. According to &lt;code&gt;:help 'viminfo'&lt;/code&gt;, the default for all OSes when not running in vi mode is to store up to 50 lines of text for each register (the &lt;code&gt;&amp;lt;50&lt;/code&gt; bit). You might also see it as &lt;code&gt;&quot;50&lt;/code&gt; in your setting (they both mean the same thing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to not save registers on Vim exit (with the result of having all empty registers on Vim start) is to change your &lt;code&gt;viminfo&lt;/code&gt; setting. You can put something like the following in your .vimrc (a modification of the &#xA;others' default value):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viminfo='100,&amp;lt;0,s10,h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can check the current value of your viminfo setting live by running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set viminfo?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and use that as your starting point for getting rid of the registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; this will also lose any register contents gotten via yank, delete, etc. operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; There is no need to clean up the old content of the viminfo file; the moment you exit Vim, it will save a new file that won't have the contents you specify it to not have (i.e. it will erase existing saved registers when you exit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; If you do populate a register via a yank, delete, etc. operation and then fat-finger the &lt;code&gt;@&lt;/code&gt;, you can still end up with a bunch of garbage on the screen, since &lt;code&gt;@&lt;/code&gt; just runs whatever is in a register no matter how it got there (which is convenient for creating macros sometimes, but inconvenient if you accidentally hit &lt;code&gt;@&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2016-02-27T16:23:44.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6708" PostTypeId="1" AcceptedAnswerId="6710" CreationDate="2016-02-27T16:38:12.433" Score="11" ViewCount="2665" Body="&lt;p&gt;I'm new to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to open vim from command line and have it scroll to the bottom of a file automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use case is opening logs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically I open vim &quot;vim log&quot; and then scroll down using G. But I do this a lot. Does vim have a command line paramater to automatically scroll to the bottom like &quot;vim -b log&quot; ?&lt;/p&gt;&#xA;" OwnerUserId="6605" LastActivityDate="2016-02-27T16:51:29.780" Title="Open file and scroll to bottom command line param?" Tags="|command-line|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6709" PostTypeId="2" ParentId="6272" CreationDate="2016-02-27T16:46:08.440" Score="3" Body="&lt;p&gt;I hate to see a question count against the site's unanswered list when there are good answers linked, so here's a community wiki containing some of those answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://stackoverflow.com/questions/26315925/get-usable-window-width-in-vim-script&quot;&gt;https://stackoverflow.com/questions/26315925/get-usable-window-width-in-vim-script&lt;/a&gt; we have Christian Brabandt's answer, a snippet that uses redirection to make a query and math to calculate the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;redir =&amp;gt;l:a |exe &quot;sil sign place buffer=&quot;.bufnr('')|redir end&#xA;let l:signlist=split(l:a, '\n')&#xA;let width=winwidth(0) - &amp;amp;numberwidth - &amp;amp;foldcolumn - (len(signlist) &amp;gt; 2 ? 2 : 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On that same question, Ingo Karkat mentioned that he has a vimscript with that and other functions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4433&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.vim.org/scripts/script.php?script_id=4433&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;ingo#window#dimensions#NetWindowWidth()&lt;/code&gt; function.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-02-27T16:46:08.440" CommentCount="0" CommunityOwnedDate="2016-02-27T16:46:08.440" ContentLicense="CC BY-SA 3.0" />
  <row Id="6710" PostTypeId="2" ParentId="6708" CreationDate="2016-02-27T16:51:29.780" Score="10" Body="&lt;p&gt;The following works for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim log +$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;+&lt;/code&gt; bit tells vim to run a command after startup. The &lt;code&gt;$&lt;/code&gt; command moves to the last line in the file. Depending on your shell, you might need &lt;code&gt;\&lt;/code&gt; before the &lt;code&gt;$&lt;/code&gt; was to tell the shell to not treat the &lt;code&gt;$&lt;/code&gt; specially.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also put it before the file, which makes selecting from command history (e.g. up arrow in your shell) and modifying the filename easier, or making an alias:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +$ log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as an alias (using bash)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vimend=&quot;vim +$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;run like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;prompt$ vimend /var/log/dmesg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="227" LastActivityDate="2016-02-27T16:51:29.780" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6711" PostTypeId="2" ParentId="6251" CreationDate="2016-02-27T17:44:34.880" Score="1" Body="&lt;p&gt;Ordinarily, &lt;kbd&gt;tab&lt;/kbd&gt; (a.k.a. &lt;kbd&gt;ctrl+i&lt;/kbd&gt;) and &lt;kbd&gt;ctrl+o&lt;/kbd&gt; traverse the jump list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim supports adding entries to the jump list by setting the &lt;code&gt;'&lt;/code&gt; mark. As such, for your line numbers case, you could set up a jump list with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +&quot;12ma '|20ma '|56ma '&quot; file_name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, then Vim still starts on the file like normal, and at the end of the jumps list. As such, you can use &lt;kbd&gt;ctrl+o&lt;/kbd&gt; to move &lt;em&gt;back&lt;/em&gt; through the list (starting at line 56, then 20, then 12) and &lt;kbd&gt;tab&lt;/kbd&gt; to go back &lt;em&gt;forward&lt;/em&gt; through the list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such, it might make sense to construct your list in reverse, so that your first &lt;kbd&gt;ctrl+o&lt;/kbd&gt; gets you to the first entry you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Downsides:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Jump operations (described in &lt;code&gt;:help jump-motions&lt;/code&gt;) will move you to the end of the jumps list and add another entry, making it a bit interesting to then navigate to your saved entries.&lt;/li&gt;&#xA;&lt;li&gt;The backwards/forwards nature of this can be confusing&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I tried doing stuff to start the session at the beginning of the set of jumps, with stuff like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +&quot;12ma '|20ma '|56ma '|norm 3^O&quot; file_name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but they don't work unless I prevent my vimrc from running. I think I must have a plugin or something trying to be &quot;nice&quot; by moving my cursor around (probably that common snippet that places your cursor where you left it last on BufReadPost), so the following actually works, so long as you don't jump before you want to use &lt;kbd&gt;tab&lt;/kbd&gt; to get to the next line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u None +&quot;12ma '|20ma '|56ma '|norm 3^O&quot; file_name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the &lt;code&gt;3&lt;/code&gt; is however many items you put on the jump list and &lt;code&gt;^O&lt;/code&gt; is a literal control+o (typed like &lt;kbd&gt;ctrl+v&lt;/kbd&gt;&lt;kbd&gt;crtl+o&lt;/kbd&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Downsides:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Harder to type (but if it is constructed by a program, probably not bad)&lt;/li&gt;&#xA;&lt;li&gt;Might not be able to use your default vimrc (though, again, if you are running via a program, this is probably an advantage)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="227" LastActivityDate="2016-02-27T17:44:34.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6712" PostTypeId="2" ParentId="6238" CreationDate="2016-02-27T18:15:04.007" Score="3" Body="&lt;p&gt;I have seen this problem in other plugins as well (and some take a LOT more than 0.04 seconds).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue appears to be that Vim puts the terminal into &quot;cooked&quot; mode so that the command that is run can receive interrupt signals (from ctrl+c). This means that, for the duration of the command, your terminal is in line-editing mode. You can try this yourself by running, say, &quot;sleep 5&quot; in a system command and observe that wherever your cursor was when it was run, what you type starts there, and you can use backspace, ctrl+u, etc to edit the line. Whatever the line was when the command exits after your editing is then read by vim and processed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only Vim Proper ways to spawn an external program I can find (&lt;code&gt;:!cmd&lt;/code&gt;, &lt;code&gt;:r!cmd&lt;/code&gt;, and &lt;code&gt;system(&quot;cmd&quot;)&lt;/code&gt;) all suffer this, though only system doesn't redraw the screen, but all will flicker with redrawing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neovim is doing some work for handling terminal programs, but that doesn't help if your target audience includes Vim (and I haven't kept up with it so I don't know where that stands)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due to the architecture, I don't think there is a way around this in Vim proper. No matter how fast your external program runs, there is always a period of time where a character can enter the terminal while in cooked mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are willing to depend on one of the language extensions of Vim, you &lt;em&gt;could&lt;/em&gt; use that to run your external command without changing the terminal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:python import os&#xA;:python os.system(&quot;sleep 5&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the result that the terminal freezes for 5 seconds while the command runs. The text you type will make it to Vim afterwards without any line editing by the terminal (e.g. backspaces , ctrl+u, etc. will be interpreted by vim and in order of characters typed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The downsides of course are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;adds an extra dependency to your plugin (python, perl, or whatever you use)&lt;/li&gt;&#xA;&lt;li&gt;There is no way from the terminal to interrupt the operation now (can have a hung terminal unless someone interrupts the program via other means, like a kill command in another shell or process manager. Any ctrl+c a user types will be interpreted by vim once the command ends)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The latter might be mitigated by adjusting the terminal settings yourself in, say, python prior to calling the external command. Be careful there, though.&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2016-02-27T18:15:04.007" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6714" PostTypeId="1" CreationDate="2016-02-27T22:09:02.493" Score="6" ViewCount="214" Body="&lt;p&gt;To work with &lt;code&gt;pascal&lt;/code&gt; files, my &lt;code&gt;.vimrc&lt;/code&gt; contains this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot; Work with pascal files&#xA;augroup make_pascal&#xA;  autocmd!&#xA;  autocmd FileType pascal :compiler fpc&#xA;  autocmd FileType pascal :set makeprg=clear;\ fpc\ %&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To demonstrate the issue I am experiencing see this easy hello-world-like demonstration code written in &lt;code&gt;pascal&lt;/code&gt; which intentionally contains an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;program EasyExample (output);&#xA;&#xA;begin&#xA;  writeln ('Correct line.');&#xA;  thisWillCauseAnError;&#xA;end.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;:make&lt;/code&gt; on this file with my Vim cursor in any line that does not contain the error, everything works fine: the external &lt;code&gt;fpc&lt;/code&gt; compiler gets called and aborts compilation due to an error. After pressing &lt;code&gt;ENTER&lt;/code&gt; I get back to my source code and the cursor is in the line that contains the error, and the error message is displayed at the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I run &lt;code&gt;:make&lt;/code&gt; on this file with my Vim cursor in the line that does contain the error, an additional step is added (and I would like to remove it): After the compilation abortion pressing &lt;code&gt;ENTER&lt;/code&gt; does not get me back to my source code, but instead a new &quot;window&quot; (is that the quickfix list?) is shown with the following text at the bottom:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;(5 of 8): Error: Identifier not found &quot;thisWillCauseAnError&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Press ENTER or type command to continue&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After pressing &lt;code&gt;ENTER&lt;/code&gt; again I see my source code again, the cursor in the line that contains the error, and the error message is displayed at the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get rid of that additional &quot;window&quot; that appears, so that the behaviour when running &lt;code&gt;:make&lt;/code&gt; is always the same (i.e. press &lt;code&gt;ENTER&lt;/code&gt; once to see my source code with highlighted error)?&lt;/p&gt;&#xA;" OwnerUserId="3282" LastEditorUserId="3282" LastEditDate="2016-02-27T22:17:46.743" LastActivityDate="2016-02-29T01:27:23.490" Title="Returning from :make to source code has sometimes a step too much" Tags="|makeprg|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6715" PostTypeId="2" ParentId="6434" CreationDate="2016-02-28T00:15:52.140" Score="4" Body="&lt;p&gt;Thanks to @John O'M for putting me on the right path.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The cause of the lag was a plugin I'm using: &lt;a href=&quot;https://github.com/mattn/emmet-vim&quot; rel=&quot;nofollow&quot;&gt;emmet-vim&lt;/a&gt; which provides expansion of special abbreviations into full HTML elements, it creates lots of bindings to &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;C-y&amp;gt;&#xA;&#xA;v  &amp;lt;C-Y&amp;gt;c        &amp;lt;Plug&amp;gt;(emmet-code-pretty)&#xA;v  &amp;lt;C-Y&amp;gt;m        &amp;lt;Plug&amp;gt;(emmet-merge-lines)&#xA;n  &amp;lt;C-Y&amp;gt;A        &amp;lt;Plug&amp;gt;(emmet-anchorize-summary)&#xA;n  &amp;lt;C-Y&amp;gt;a        &amp;lt;Plug&amp;gt;(emmet-anchorize-url)&#xA;n  &amp;lt;C-Y&amp;gt;k        &amp;lt;Plug&amp;gt;(emmet-remove-tag)&#xA;n  &amp;lt;C-Y&amp;gt;j        &amp;lt;Plug&amp;gt;(emmet-split-join-tag)&#xA;n  &amp;lt;C-Y&amp;gt;/        &amp;lt;Plug&amp;gt;(emmet-toggle-comment)&#xA;n  &amp;lt;C-Y&amp;gt;i        &amp;lt;Plug&amp;gt;(emmet-image-size)&#xA;n  &amp;lt;C-Y&amp;gt;N        &amp;lt;Plug&amp;gt;(emmet-move-prev)&#xA;n  &amp;lt;C-Y&amp;gt;n        &amp;lt;Plug&amp;gt;(emmet-move-next)&#xA;v  &amp;lt;C-Y&amp;gt;D        &amp;lt;Plug&amp;gt;(emmet-balance-tag-outword)&#xA;n  &amp;lt;C-Y&amp;gt;D        &amp;lt;Plug&amp;gt;(emmet-balance-tag-outword)&#xA;v  &amp;lt;C-Y&amp;gt;d        &amp;lt;Plug&amp;gt;(emmet-balance-tag-inward)&#xA;n  &amp;lt;C-Y&amp;gt;d        &amp;lt;Plug&amp;gt;(emmet-balance-tag-inward)&#xA;n  &amp;lt;C-Y&amp;gt;u        &amp;lt;Plug&amp;gt;(emmet-update-tag)&#xA;n  &amp;lt;C-Y&amp;gt;;        &amp;lt;Plug&amp;gt;(emmet-expand-word)&#xA;v  &amp;lt;C-Y&amp;gt;,        &amp;lt;Plug&amp;gt;(emmet-expand-abbr)&#xA;n  &amp;lt;C-Y&amp;gt;,        &amp;lt;Plug&amp;gt;(emmet-expand-abbr)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm sure remapping it would solve the problem also, but without the plugin the lag goes away.&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2016-02-28T00:15:52.140" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6716" PostTypeId="1" AcceptedAnswerId="6722" CreationDate="2016-02-28T01:56:27.190" Score="12" ViewCount="1457" Body="&lt;p&gt;I have made a snippet which I want to give different triggers, so instead of say &lt;code&gt;trigger&lt;/code&gt; I also want to trigger it with &lt;code&gt;myothertrigger&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet trigger &quot;just an example&quot; &#xA;my text ...&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there an easy way to do this instead of copying the snippet?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; To be clear, I am using &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;UltiSnips&lt;/strong&gt;&lt;/a&gt;, but if there is a better plugin I might look into that.&lt;/p&gt;&#xA;" OwnerUserId="5280" LastEditorUserId="5280" LastEditDate="2016-02-28T11:30:27.677" LastActivityDate="2022-04-14T18:47:49.853" Title="How can I use several triggers for the same snippet?" Tags="|plugin-ultisnips|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6717" PostTypeId="1" CreationDate="2016-02-28T10:25:49.060" Score="4" ViewCount="158" Body="&lt;p&gt;I'm trying to make a text-object that is a paragraph surrounded by lines containing &lt;code&gt;%&lt;/code&gt;. To test something simpler, I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call textobj#user#plugin('pc', {&#xA;\   'code': {&#xA;\     'pattern': ['%&amp;lt;', '%'],&#xA;\     'scan': 'nearest',&#xA;\     'region-type': 'V',&#xA;\     'select-i': 'ir',&#xA;\   },&#xA;\ })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works, but if I use &lt;code&gt;%&lt;/code&gt; instead of &lt;code&gt;%&amp;lt;&lt;/code&gt;, it doesn't. Must the patterns be different? Why?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="1292" LastEditDate="2019-01-24T12:51:24.737" LastActivityDate="2019-01-24T12:51:24.737" Title="textobj-user: must the patterns be different?" Tags="|cursor-motions|custom-text-object|plugin-textobj-user|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6718" PostTypeId="1" CreationDate="2016-02-28T13:24:03.570" Score="4" ViewCount="2688" Body="&lt;p&gt;I use vim on Linux and Windows. Strangely, on Linux (Ubuntu), when I write C/C++ code, vim would search the included file for auto-completion (Ctrl-P), even if I don't add anything related in my &lt;code&gt;.vimrc&lt;/code&gt;. But on Windows, it doesn't behave that way. I have tried to add &lt;code&gt;set path+=$INCLUDE&lt;/code&gt; in my &lt;code&gt;_vimrc&lt;/code&gt; (&lt;code&gt;$INCLUDE&lt;/code&gt; is in my path and it's the path of the C/C++ header file), but that doesn't work either.&lt;/p&gt;&#xA;" OwnerUserId="2760" LastEditorUserId="205" LastEditDate="2016-02-29T14:08:13.660" LastActivityDate="2016-02-29T14:08:13.660" Title="On Linux, vim would search #include files automatically for auto-completion but on Windows not" Tags="|autocompletion|microsoft-windows|plugin-ctrlp|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6719" PostTypeId="2" ParentId="6698" CreationDate="2016-02-28T14:40:03.890" Score="1" Body="&lt;p&gt;How about&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;f ?^\s*\-\\|\%^&amp;lt;CR&amp;gt;V/\n^\s*\-\\|\%$&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which would allow you to use &lt;code&gt;&amp;lt;Leader&amp;gt;f&lt;/code&gt; to select the item your cursor is in in visual mode, so you can use &lt;code&gt;&amp;gt;&lt;/code&gt; indent further? Of course you could easily integrate the indent into the keypress, but you'd need another remap to decrease the indentation level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume you know the basics, here's what the regexps do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;?^\s*\-\\|\%^&lt;/code&gt; searches backwards for the next line that starts with whitespaces and a dash, or the start of the file (&lt;code&gt;\\|&lt;/code&gt; for the logical OR, and &lt;code&gt;\%^&lt;/code&gt; for the beginning of the file)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/\n^\s*\-\\|\%$&lt;/code&gt; searches for a newline (&lt;code&gt;\n&lt;/code&gt;) followed the a line as above, and if that isn't found, go to the end of the file (&lt;code&gt;\\|&lt;/code&gt; for the logical OR, and &lt;code&gt;\%$&lt;/code&gt; for the end of the file)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It has a rough edge, namely if you're on a dash itself, that follows only whitespaces, which works if the dash is indented itself, but if the dash is on column 1 it selects the previous entry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still though, imho it works good enough if you don't like a plugin, and since it only selects, you can easily spot if something's wrong, and you're just 2 keypresses away from the right cursor position to select the entry you wanted.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="1296" LastEditDate="2016-02-28T15:23:47.303" LastActivityDate="2016-02-28T15:23:47.303" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6720" PostTypeId="2" ParentId="6208" CreationDate="2016-02-28T21:39:16.290" Score="7" Body="&lt;p&gt;The existing answers all fail if your line contains certain items that are interpreted as a part of a pattern. The &lt;code&gt;\V&lt;/code&gt; point gets most of the way there but still messes up with the backslash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this to escape the backslashes...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\V&amp;lt;C-R&amp;gt;=escape(getline('.'), '\')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then if you're using it in a mapping you'll need one or two &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;s at the end depending on how you want it to work.&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-02-28T21:39:16.290" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6721" PostTypeId="2" ParentId="6714" CreationDate="2016-02-28T22:43:20.857" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/users/4939/saginaw&quot;&gt;saginaw&lt;/a&gt; pointed out in a now deleted comment that running &lt;code&gt;:silent! make | redraw! | cw&lt;/code&gt; instead of &lt;code&gt;:make&lt;/code&gt; solves my problem. If I run it the program compiles, and if there is an error the QuickFix list is opened on the bottom and the line with the error highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I expanded his solution further to deal with something else:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever the free pascal compiler &lt;code&gt;fpc&lt;/code&gt; is run on a file &lt;code&gt;example.pas&lt;/code&gt;, it produces an executable &lt;code&gt;example&lt;/code&gt; as well as an object file &lt;code&gt;example.o&lt;/code&gt;, which &lt;a href=&quot;http://www.freepascal.org/docs-html/user/userse10.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;can be deleted&lt;/a&gt; as I don't need it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The final solution in my &lt;code&gt;.vimrc&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot; Work with pascal files&#xA;augroup make_pascal&#xA;  autocmd!&#xA;  autocmd FileType pascal :compiler fpc&#xA;  autocmd FileType pascal :set makeprg=clear;fpc\ %&#xA;  autocmd FileType pascal nnoremap &amp;lt;buffer&amp;gt; &amp;lt;leader&amp;gt;c&#xA;      \ :w &amp;lt;bar&amp;gt; silent! make &amp;lt;bar&amp;gt; redraw! &amp;lt;bar&amp;gt; cw &amp;lt;bar&amp;gt;&#xA;      \ exe &quot;silent! !rm -f %:r.o&quot; &amp;lt;bar&amp;gt; redraw! &amp;lt;CR&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3282" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-02-29T01:27:23.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6722" PostTypeId="2" ParentId="6716" CreationDate="2016-02-29T01:45:50.533" Score="9" Body="&lt;p&gt;Currently there is no way to do this in UltiSnips. There is an &lt;a href=&quot;https://github.com/SirVer/ultisnips/issues/235&quot; rel=&quot;noreferrer&quot;&gt;open feature-request on Github&lt;/a&gt; for it though. Personally, I would like an alias functionality for triggers as indicated &lt;a href=&quot;https://github.com/SirVer/ultisnips/issues/359&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's hope SirVer (the maintainer of UltiSnips) will think so too and include it in the future :)&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2016-02-29T01:45:50.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6723" PostTypeId="2" ParentId="6718" CreationDate="2016-02-29T11:34:15.103" Score="4" Body="&lt;p&gt;with the help from VanLaser in the comments above,I eventually find out how to do that on Windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path+=C:/Program\\\ Files\\\ (x86)/Microsoft\\\ Visual\\\ Studio\\\ 12.0/VC/include&#xA;set path+=C:/Program\\\ Files\\\ (x86)/Microsoft\\\ SDKs/Windows/v7.1A/Include &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;just add these two lines in my vimrc then it would work. Those two &lt;code&gt;C:/xxxxx&lt;/code&gt; are my system &lt;code&gt;%INCLUDE%&lt;/code&gt; path, where all the necessary C/C++ header files located. Note the different version of Visual Studio and change those two path correspondingly. Also note that those &lt;code&gt;\\\&lt;/code&gt; are necessary to escaped the space(see &lt;code&gt;:h 'complete'&lt;/code&gt; (not &lt;code&gt;:h complete()&lt;/code&gt;) for more information).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, make sure that option &lt;code&gt;i&lt;/code&gt; is in your complete options(use &lt;code&gt;set complete?&lt;/code&gt; to see, and the default is &lt;code&gt;complete=.,w,b,u,t,i&lt;/code&gt;. See &lt;code&gt;:h 'complete'&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2760" LastActivityDate="2016-02-29T11:34:15.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6724" PostTypeId="1" AcceptedAnswerId="7769" CreationDate="2016-02-29T19:02:12.560" Score="15" ViewCount="5775" Body="&lt;p&gt;I know one can use &lt;code&gt;vim scp://host/path/to/file&lt;/code&gt; to edit locally remote files then update the remote machine when saving (&lt;code&gt;:w&lt;/code&gt;).&#xA;However I would like to know if it's possible to navigate through directories using ssh (or if there's a plugin to do that)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NERDTree doesn't support it, and when viming into a folder, although netrw allow me to navigate into directories, opening a file doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="6708" LastEditorUserId="205" LastEditDate="2016-03-07T13:48:55.237" LastActivityDate="2016-09-13T19:33:47.133" Title="Navigating using SSH" Tags="|netrw|ssh|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6725" PostTypeId="2" ParentId="6724" CreationDate="2016-02-29T19:37:35.110" Score="18" Body="&lt;p&gt;Instead of pointing Vim/Netrw to a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;scp://host/path/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;point it to a directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;scp://host/path/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gives you the same listing and the same shortcuts as if you were browsing your machine.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-02-29T19:37:35.110" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6726" PostTypeId="1" AcceptedAnswerId="6729" CreationDate="2016-03-01T00:10:24.490" Score="3" ViewCount="1607" Body="&lt;p&gt;I am looking at some plugin that happens to be configurable through a curious mapping (e.g. &lt;a href=&quot;https://github.com/Shougo/unite.vim/blob/master/doc/unite.txt#L210-L232&quot; rel=&quot;nofollow&quot;&gt;unite.vim&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;More advanced configuration example:&#xA;&amp;gt;&#xA;    &quot; The prefix key.&#xA;    nnoremap    [unite]   &amp;lt;Nop&amp;gt;&#xA;    nmap    f [unite]&#xA;&#xA;    nnoremap &amp;lt;silent&amp;gt; [unite]c  :&amp;lt;C-u&amp;gt;UniteWithCurrentDir&#xA;            \ -buffer-name=files buffer bookmark file&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does the &lt;code&gt;[unite]&lt;/code&gt; means ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that it stands for a custom leader/prefix only for the plugin, but what is it's meaning for Vim ?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-03-01T08:56:39.800" Title="Mapping with square bracket" Tags="|key-bindings|vimrc|plugin-system|plugin-unite.vim|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6727" PostTypeId="1" CreationDate="2016-03-01T05:36:21.430" Score="2" ViewCount="95" Body="&lt;p&gt;I am using MacVim version 7.4.&#xA;I am authoring a large LaTeX file and I use a GNU Makefile to compile the documents along with lots of figures and other targets. The command &lt;code&gt;make&lt;/code&gt; generates lots of output text from executing &lt;code&gt;pdflatex&lt;/code&gt; several times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My problem:&lt;/strong&gt; When I use &lt;code&gt;:!make&lt;/code&gt; from &lt;code&gt;gvim&lt;/code&gt; it works correctly, however, it is at least 10 times slower than typing &lt;code&gt;make&lt;/code&gt; in a terminal. I tried the same experiments from &lt;code&gt;vim&lt;/code&gt; in a terminal, and it seems to work fine.&#xA;Is there a fix to get &lt;code&gt;gvim&lt;/code&gt; up to speed?&lt;/p&gt;&#xA;" OwnerUserId="2199" LastActivityDate="2016-03-01T05:36:21.430" Title=":!make is at least 10times slower compared to terminal on MacOS X" Tags="|gvim|macvim|macos|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6728" PostTypeId="2" ParentId="4669" CreationDate="2016-03-01T07:16:58.190" Score="8" Body="&lt;p&gt;Try something like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight htmlBold gui=bold guifg=#af0000 ctermfg=124&#xA;highlight htmlItalic gui=italic guifg=#ff8700 ctermfg=214&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5232" LastActivityDate="2016-03-01T07:16:58.190" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6729" PostTypeId="2" ParentId="6726" CreationDate="2016-03-01T08:56:39.800" Score="2" Body="&lt;p&gt;After discussion with &lt;a href=&quot;https://vi.stackexchange.com/users/1800/vanlaser&quot;&gt;VanLaser&lt;/a&gt;, it seems that the &lt;code&gt;[unite]&lt;/code&gt; mapping is used only with a combination of another key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's break down the mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap    [unite]   &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Map &lt;code&gt;[unite]&lt;/code&gt; to nothing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap    f [unite]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Map &lt;code&gt;f&lt;/code&gt; to &lt;code&gt;[unite]&lt;/code&gt;. At this point if we press &lt;code&gt;f&lt;/code&gt;, nothing will happen, as &lt;code&gt;[unite]&lt;/code&gt; is mapped to &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when we add a &lt;code&gt;[unite]&lt;/code&gt;-based mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; [unite]c  :&amp;lt;C-u&amp;gt;UniteWithCurrentDir ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the &lt;code&gt;[unite]c&lt;/code&gt; (which will be triggered by pressing &lt;code&gt;fc&lt;/code&gt;) will call the desired command. If the &lt;code&gt;f&lt;/code&gt; key is pressed alone, after the map timeout, nothing will append as it will be translated to &lt;code&gt;[unite]&lt;/code&gt; alone.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-03-01T08:56:39.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6730" PostTypeId="1" AcceptedAnswerId="6733" CreationDate="2016-03-01T09:03:15.750" Score="19" ViewCount="14416" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;noreferrer&quot;&gt;vim-airline&lt;/a&gt; and it's really nice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jMB0Y.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jMB0Y.png&quot; alt=&quot;vim statusbar screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I get that second status bar below it which I want to hide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried &lt;code&gt;set noshowmode&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;, but that only seemed to hide the default mode indicator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously the filename there is redundant (airline covers it) and the lines and char count aren't so useful to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if I hide it, will it come back if I use &lt;code&gt;echoe &quot;hello&quot;&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://raw.githubusercontent.com/alexanderdickson/dotfiles/896344cabc02f29da7c2cb6979c9e97c4fad575b/vimrc&quot; rel=&quot;noreferrer&quot;&gt;My &lt;code&gt;.vimrc&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5650" LastEditorUserId="1821" LastEditDate="2016-03-01T16:57:28.843" LastActivityDate="2022-09-14T00:18:21.240" Title="How to get rid of the command line bar?" Tags="|statusline|plugin-airline|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6731" PostTypeId="1" AcceptedAnswerId="6963" CreationDate="2016-03-01T11:35:18.303" Score="19" ViewCount="7352" Body="&lt;p&gt;I'm struggling with learning vim regexps (I don't know any other regexp very well either), so the main problem is to define regexp that would match&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some_function_call(simple_value, keyword=value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;keyword in this example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it should match a word if it's inside parens and have equal sign after it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next problem is how to define syntax files in vim. I would appreciate help with that, but It shouldn't be that hard to learn, so I can do that on my own probably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT based on the answer I've maid my own syntax script for python. Feel free to try it.&#xA;&lt;a href=&quot;https://github.com/purpleP/python-syntax&quot; rel=&quot;noreferrer&quot;&gt;enter link description here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6634" LastEditDate="2016-10-15T17:24:46.110" LastActivityDate="2020-03-21T06:12:42.177" Title="Vim syntax pattern to highlight python keyword argument" Tags="|syntax-highlighting|regular-expression|filetype-python|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6732" PostTypeId="2" ParentId="6731" CreationDate="2016-03-01T11:58:20.147" Score="8" Body="&lt;p&gt;Here is where you can start from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/([^,]\+,\s\(\w\+\)=.*)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/(       start matching a (&#xA;[^,]\+   match multiple characters that are not ,&#xA;,\s      match a , and a space&#xA;\(       start a matching group&#xA;\w\+     match word characters&#xA;\)       end the matching group&#xA;=.*)      match an = and anything until the closing )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This needs improvements but gives you an overview of how you can do it.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-03-01T11:58:20.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6733" PostTypeId="2" ParentId="6730" CreationDate="2016-03-01T15:11:55.117" Score="7" Body="&lt;p&gt;No, it's impossible to hide the command-line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-- EDIT --&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can prevent Vim from echoing &lt;code&gt;&quot;filename&quot; XXXL, XXXC&lt;/code&gt; when editing a file by prepending &lt;code&gt;silent&lt;/code&gt; to &lt;code&gt;e&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent e foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-03-01T15:21:19.970" LastActivityDate="2016-03-01T15:21:19.970" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6735" PostTypeId="2" ParentId="6730" CreationDate="2016-03-01T18:52:58.433" Score="2" Body="&lt;p&gt;You hide the redundant line by setting &lt;code&gt;laststatus&lt;/code&gt; to 1. Then airline goes away unless you have a split. You might be able to make airline set the &lt;code&gt;rulerformat&lt;/code&gt; or set it to something else you like (and you probably need to &lt;code&gt;set ruler&lt;/code&gt; as well).&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-03-01T18:52:58.433" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6736" PostTypeId="1" AcceptedAnswerId="6737" CreationDate="2016-03-02T00:45:42.100" Score="11" ViewCount="992" Body="&lt;p&gt;I often use extremely long macros when handling repetitive editing and refactoring.  Whenever possible I write these as ex-mode commands rather than recording them as macros, because they are easier to edit interactively that way (with the command window).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, sometimes I need to add in a couple of normal mode commands, e.g. to yank just part of a line rather than a whole line for later use in my macro, or to line some text up the way I want it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to &lt;em&gt;continue&lt;/em&gt; an ex mode command after &lt;code&gt;norm&lt;/code&gt; is included?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(For an actual example of the kind of complexity I'm talking about:)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'a+s/\_^\s*\(\S*\)::\_[^&amp;gt;]*&amp;gt;\s*\(&quot;[^&quot;]*&quot;\)\s*;\_s*\_$/    &quot;\1&quot;, \2,/ | m 'a- | norm f,50a ^[d44|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can add more text on the end and have it execute as an ex mode command?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2016-03-02T02:33:17.570" Title="Continue an ex mode command after &quot;norm&quot;?" Tags="|normal-mode|ex-mode|macro|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6737" PostTypeId="2" ParentId="6736" CreationDate="2016-03-02T01:55:00.797" Score="13" Body="&lt;p&gt;If you have a sequence of keystrokes that you want to execute in normal mode from the command line, you can use the &lt;code&gt;:normal&lt;/code&gt; command.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, by default the &lt;code&gt;:normal&lt;/code&gt; command can't be followed by another command because as the help says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    This command cannot be followed by another command,&#xA;    since any '|' is considered part of the command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, if you want to add another Ex command after &lt;code&gt;:normal&lt;/code&gt;, you can wrap the whole &lt;code&gt;:normal&lt;/code&gt; command inside a string, and then make the &lt;code&gt;:execute&lt;/code&gt; command execute the latter. It could give something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 'norm {your keystrokes}' | Other Ex command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Contrary to &lt;code&gt;:normal&lt;/code&gt;, &lt;code&gt;:execute&lt;/code&gt; won't consider the pipe as a part of its argument. It will consider it as a command termination, and will only execute what is inside the string.&lt;br&gt;&#xA;&lt;code&gt;:normal&lt;/code&gt; won't see what's after on the command line, it will only see what's left in the string.&lt;br&gt;&#xA;Thus you should be able to add another Ex command afterwards without &lt;code&gt;:normal&lt;/code&gt; typing it in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's just a little thing to pay attention to:&lt;br&gt;&#xA;if you surround your string with single quotes, Vim won't interpret anything inside it, which can be a problem if you want &lt;code&gt;:normal&lt;/code&gt; to hit control characters such as &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-V&amp;gt;&lt;/code&gt; by writing special characters, respectively: &lt;code&gt;\e&lt;/code&gt;, &lt;code&gt;\r&lt;/code&gt;, &lt;code&gt;\t&lt;/code&gt; and &lt;code&gt;\&amp;lt;C-V&amp;gt;&lt;/code&gt;.&lt;br&gt;&#xA;These special characters are described in &lt;code&gt;:help expr-quote&lt;/code&gt;.&lt;br&gt;&#xA;In this case you could use double quotes instead of single quotes to surround the string, so that Vim can interpret them correctly.&lt;br&gt;&#xA;If your control characters are literal (that is if you see their caret notation: &lt;code&gt;^[&lt;/code&gt; for Escape, &lt;code&gt;^M&lt;/code&gt; for Enter, &lt;code&gt;^I&lt;/code&gt; for Tab, &lt;code&gt;^V&lt;/code&gt; for &lt;code&gt;&amp;lt;C-V&amp;gt;&lt;/code&gt;), you shouldn't need the double quotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you record a macro, the latter stores your control characters as literal ones, it doesn't use the kind of special characters described in &lt;code&gt;:h expr-quote&lt;/code&gt;, so you shouldn't need the double quotes. And if you want to edit a macro by adding a literal control character yourself, you can prefix it with &lt;code&gt;&amp;lt;C-V&amp;gt;&lt;/code&gt; (see &lt;code&gt;:h i_ctrl-v&lt;/code&gt; for more info). For example, to add a literal escape inside the register where your macro is stored or inside the sequence of keystrokes passed as an argument to &lt;code&gt;:normal&lt;/code&gt;, you could hit &lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-03-02T02:33:17.570" LastActivityDate="2016-03-02T02:33:17.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6738" PostTypeId="1" AcceptedAnswerId="6740" CreationDate="2016-03-02T08:56:39.350" Score="6" ViewCount="681" Body="&lt;p&gt;The &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_28.html#usr_28.txt&quot;&gt;chapter 28 of User Manual&lt;/a&gt; says the following about folding: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Folding is used to show a range of lines in the buffer as a single line on the screen.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And all the examples of folding that I've seen converts several lines to only one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I'm trying to do&lt;/strong&gt; is to create a folding within one line. For example if I have the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyFunction (with, really, a, lot, of, parameters, which, make, my, line, too, long)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to fold it this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyFunction (+-- folded)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So far I have tried&lt;/strong&gt; different things with no success:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I know that it's possible to use &lt;code&gt;set foldmethod=marker&lt;/code&gt; to add marker in the text to fold lines to it doesn't seem to work within a line. For example the following doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyFunction ( /*{{{*/ with, really, a, lot, of, parameters, which, make, my, line, too, long /*}}}*/)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I also know that it is possible to create folding using text objects: for example to fold a paragraph it is possible to use &lt;code&gt;zfap&lt;/code&gt; where &lt;code&gt;zf&lt;/code&gt; is the command to create a folding and &lt;code&gt;ap&lt;/code&gt; the text object to fold. I've tried to extend that with &lt;code&gt;zfi(&lt;/code&gt;, &lt;code&gt;zfa(&lt;/code&gt;, &lt;code&gt;zfib&lt;/code&gt; or &lt;code&gt;zfab&lt;/code&gt; but that give the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyFunction (with, really, a, lot, of, parameters, which, make, my, line, too, long)/*{{{*//*}}}*/&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finally I tried it with visual selection: &lt;code&gt;vib&lt;/code&gt; and &lt;code&gt;zf&lt;/code&gt; but the result is the same as the previous method.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So my questions are:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is it possible to use folding within a line? &lt;em&gt;From what I have tried I think that folds might not be the good way to do it&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;If so, how can I do it?&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If it is not possible with foldings, what should I try to use to get my result? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A bonus point would be to have a method which wouldn't need to add markers like &lt;code&gt;/*{{{*/&lt;/code&gt; and &lt;code&gt;/*}}}*/&lt;/code&gt; in my buffer but if it's the only way to do it I'm ok with that.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-03-02T16:32:07.417" Title="Is it possible to create a folding inside a single line?" Tags="|folding|formatting|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6739" PostTypeId="1" AcceptedAnswerId="6741" CreationDate="2016-03-02T10:06:29.790" Score="7" ViewCount="3039" Body="&lt;p&gt;I have a bad habit of using the shift key of the same side of the keyboard as the letter when tying uppercase letters. To type a &lt;code&gt;D&lt;/code&gt;, for example, I press the left shift with my left pinky and &lt;code&gt;d&lt;/code&gt; with  my left index finger. It is better to use the right shift in combination with keys on the left hand side of the keyboard, and &lt;em&gt;vise versa&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get rid of this habit I would like to disable the combinations of either shift key with keys on the same side of the keyboard. I can map shift-d with &lt;code&gt;&amp;lt;S-d&amp;gt;&lt;/code&gt;, but this applies to both shift keys. Is there a to apply only to the right hand shift key? &lt;/p&gt;&#xA;" OwnerUserId="3316" LastEditorUserId="1821" LastEditDate="2016-03-02T10:07:36.703" LastActivityDate="2021-03-26T20:08:47.073" Title="Differentiating between left and right shift key" Tags="|key-bindings|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6740" PostTypeId="2" ParentId="6738" CreationDate="2016-03-02T10:16:24.137" Score="8" Body="&lt;p&gt;You can hack around with some custom syntax and the use of the conceal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region FunctionArguments start=+(+hs=e+1 end=+)+he=e-1 conceal cchar=…&#xA;set concealleval=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function (a, b, c, d, e)&#xA;function (…)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Careful though, with this basic example, all &lt;code&gt;()&lt;/code&gt; will be concealed, so a little more work must be done here, but it should be a good opportunity to learn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, the content is hidden and replaced with the … char.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, you can't display more than one char with the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#conceal&quot;&gt;conceal&lt;/a&gt; feature.&#xA;The good news is you can apply new syntax to file without having to define a new syntax, so you can embed this in a function to activate-deactivate it.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-03-02T15:10:49.987" LastActivityDate="2016-03-02T15:10:49.987" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6741" PostTypeId="2" ParentId="6739" CreationDate="2016-03-02T10:57:37.647" Score="9" Body="&lt;p&gt;From the &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-20.4&quot;&gt;Vim FAQ 20.4. &quot;I am not able to create a mapping for the  key. What is wrong?&quot;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;1) First make sure, the key is passed correctly to Vim. To determine&#xA;  if this is the case, put Vim in Insert mode and then hit Ctrl-V (or&#xA;  Ctrl-Q if your Ctrl-V is remapped to the paste operation (e.g. on&#xA;  Windows if you are using the mswin.vim script file) followed by your&#xA;  key.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If nothing appears in the buffer (and assuming that you have&#xA;  'showcmd' on, ^V remains displayed near the bottom right of the Vim&#xA;  screen), then Vim doesn't get your key correctly and there is nothing&#xA;  to be done, other than selecting a different key for your mapping or&#xA;  using GVim, which should recognise the key correctly.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On my setup issuing &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;q&lt;/kbd&gt;+&lt;kbd&gt;Left Shfit&lt;/kbd&gt;-&lt;kbd&gt;d&lt;/kbd&gt; displays 'D', and issuing &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;q&lt;/kbd&gt;+&lt;kbd&gt;Right Shfit&lt;/kbd&gt;-&lt;kbd&gt;d&lt;/kbd&gt; leads to the same result. So at least here Vim is unable to detect the difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But maybe you could use some other tool to aid you on this; for instance, on Windows you could try &lt;a href=&quot;https://www.autohotkey.com/&quot;&gt;AutoHotkey&lt;/a&gt; with something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifWinActive ahk_class Vim&#xA;LShift &amp;amp; d::MsgBox You pressed the wrong 'Shift'!&#xA;#ifWinActive&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or to simple ignore the combination:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifWinActive ahk_class Vim&#xA;LShift &amp;amp; d::&#xA;#ifWinActive&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-03-02T11:05:27.757" LastActivityDate="2016-03-02T11:05:27.757" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6742" PostTypeId="2" ParentId="6738" CreationDate="2016-03-02T15:41:31.080" Score="5" Body="&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Actually I should have digged the doc a little more: using the &lt;code&gt;syntax match&lt;/code&gt; is much more appropriate than the &lt;code&gt;syntax region&lt;/code&gt; for what I want to do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The final solution that I will use it the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match LargeParenthesis +(\zs.\{40,}\ze)+ conceal cchar=?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;syntax match&lt;/code&gt; allows to create a conceal on a single pattern instead of using start and end patterns as &lt;code&gt;syntax region&lt;/code&gt; do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage of this solution is that using &lt;code&gt;(\zs&lt;/code&gt; and &lt;code&gt;\ze)&lt;/code&gt; I can match only the content of the brackets and not the brackets themselves. So a concealed function looks like &lt;code&gt;MyFunction(?)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also as I can use &lt;code&gt;.\{40,}&lt;/code&gt; I can conceal only the brackets containing more than 40 characters which let me see the shorter function directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally &lt;code&gt;syntax match&lt;/code&gt; works on single lines which is closer to what I wanted originally and don't create problems with nested or collapsing matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks to @Nobe4 who gave me useful gave me the hint of using &lt;code&gt;syntax match&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For references &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h syntax&lt;/code&gt;&lt;/a&gt; was pretty helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll leave my original answer here because it is a different approach and I still think it can sometimes be useful to be able to manually select a portion of text to fold.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original answer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Largely inspired by @Nobe4's solution I came with the following workaround:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to use the &lt;code&gt;conceal&lt;/code&gt; feature of Vim and create syntax region on the fly. The workflow would be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Visually selecting the text I want to conceal.&lt;/li&gt;&#xA;&lt;li&gt;Hitting &lt;kbd&gt;F1&lt;/kbd&gt;or whatever key is used on the mapping line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To do so I used a function which get the visually selected text found &lt;a href=&quot;https://stackoverflow.com/a/6271254/4194289&quot;&gt;here&lt;/a&gt;. Then I split the text in two parts to get a start and a end pattern to use in the syntax region. And finally I create the syntax region.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;F1&amp;gt; &amp;lt;Esc&amp;gt;:call OneLineFolding()&amp;lt;CR&amp;gt;&#xA;&#xA;function! OneLineFolding()&#xA;    &quot; Get the text to fold&#xA;    let l:textToFold    = s:get_visual_selection()&#xA;&#xA;    &quot; Don't fold less than 3 characters&#xA;    if (strlen(textToFold) &amp;lt; 3)&#xA;        echo &quot;The text to fold is too short&quot;&#xA;        return 0&#xA;    endif&#xA;&#xA;    &quot; Get the beginning and the end of the text&#xA;    let l:startPattern  = strpart(l:textToFold, 0, strlen(textToFold)/2)&#xA;    let l:endPattern    = strpart(l:textToFold, strlen(textToFold)/2, strlen(textToFold))&#xA;&#xA;    &quot; Generate a (more or less) unique name for the syntax zone&#xA;    let l:regionName = &quot;Region&quot; . localtime()&#xA;&#xA;    &quot; Forge the command which will create the syntax region&#xA;    let l:command =  &quot;syntax region &quot; . l:regionName . &quot; start=+&quot; . l:startPattern . &quot;+ end=+&quot; . l:endPattern . &quot;+ conceal cchar=-&quot;&#xA;&#xA;    &quot; Execute the command&#xA;    execute l:command&#xA;&#xA;endfunction&#xA;&#xA;&quot; Get visual selection (from https://stackoverflow.com/a/6271254/4194289)&#xA;function! s:get_visual_selection()&#xA;  let [lnum1, col1] = getpos(&quot;'&amp;lt;&quot;)[1:2]&#xA;  let [lnum2, col2] = getpos(&quot;'&amp;gt;&quot;)[1:2]&#xA;  let lines = getline(lnum1, lnum2)&#xA;  let lines[-1] = lines[-1][: col2 - (&amp;amp;selection == 'inclusive' ? 1 : 2)]&#xA;  let lines[0] = lines[0][col1 - 1:]&#xA;  return join(lines, &quot;\n&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's not totally ideal but that allow to select some text with any motion and fold it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still can see some problems with this solution:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A recurrent problem when working with syntax region is collapsing and nested region: on this point my solution might not really robust.&lt;/li&gt;&#xA;&lt;li&gt;I haven't tested it deeply but I'm afraid that if the string to fold contains special character it could mess with the command.&lt;/li&gt;&#xA;&lt;li&gt;It is not intended to work with with text on several lines and it won't work properly with it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-03-02T16:32:07.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6743" PostTypeId="1" AcceptedAnswerId="6745" CreationDate="2016-03-02T20:27:04.400" Score="2" ViewCount="138" Body="&lt;p&gt;I currently have the following map setup to allow me to quickly create a pair of parens by tapping &lt;code&gt;(&lt;/code&gt; twice, leaving the cursor between them for more typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap (( ()&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Separately, I have another map for skipping over the closing paren when it already exists.  That is, if you type &lt;code&gt;)&lt;/code&gt; when there is already a &lt;code&gt;)&lt;/code&gt; to the right of the cursor, instead of inserting another &lt;code&gt;)&lt;/code&gt; the cursor just jumps over the existing one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; )  strpart(getline('.'), col('.')-1, 1) == &quot;)&quot; ? &quot;\&amp;lt;Right&amp;gt;&quot; : &quot;)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem occurs in the interaction of these two maps.  That is, say my code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I realize that foo is not a value, but a function, and what I &lt;em&gt;really&lt;/em&gt; want is to pass the return value from calling &lt;code&gt;foo()&lt;/code&gt; to func, so I go ahead and move my cursor -- signified by &lt;code&gt;|&lt;/code&gt; between the &lt;code&gt;o&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo|)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now what I &lt;em&gt;want&lt;/em&gt; to do is simply tap &lt;code&gt;(&lt;/code&gt; twice, which will trigger my first map and leave me with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in fact, because of my second map, what I get is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I create an exception to my 2nd map so that it won't interfere with this specific case?  That is, when the typed &lt;code&gt;)&lt;/code&gt; is caused by another map rather than by me physically hitting a key, I don't want the 2nd map to be triggered.&lt;/p&gt;&#xA;" OwnerUserId="5373" LastActivityDate="2016-03-02T20:50:55.847" Title="Skip a map in a specific circumstance" Tags="|vimscript|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6744" PostTypeId="2" ParentId="5511" CreationDate="2016-03-02T20:32:48.173" Score="3" Body="&lt;p&gt;The problem seems to be in Solarized. If I comment out &lt;code&gt;color solarized&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt; it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a normal vim install &lt;code&gt;:highlight ColorColumn&lt;/code&gt; gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ColorColumn    xxx term=reverse ctermbg=1 guibg=LightRed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the &lt;code&gt;xxx&lt;/code&gt; example shows a red background, but with Solarized it gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ColorColumn    xxx ctermbg=235 guibg=DarkRed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the &lt;code&gt;xxx&lt;/code&gt; example shows as normal text (black on white in my case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't really investigate the cause of this; but I fixed it by adding this to the &lt;code&gt;.vimrc.local&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=80&#xA;set colorcolumn=+1&#xA;&#xA;highlight ColorColumn term=reverse ctermbg=1 guibg=LightRed&#xA;augroup colorcolumn&#xA;    autocmd!&#xA;    autocmd ColorScheme solarized highlight ColorColumn term=reverse ctermbg=1 guibg=LightRed&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;autocmd&lt;/code&gt; isn't strictly required, but if you change colour schemes all highlights are reset, so this makes sure it applies the fix again.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-03-02T20:32:48.173" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6745" PostTypeId="2" ParentId="6743" CreationDate="2016-03-02T20:50:55.847" Score="7" Body="&lt;p&gt;Unless I misunderstood you, all you need to do is change your first map to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap (( ()&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will ignore mappings on the right side and therefore will not trigger your second mapping. I tried it out and is seemed to work for me.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-03-02T20:50:55.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6746" PostTypeId="1" CreationDate="2016-03-02T23:52:44.753" Score="11" ViewCount="5417" Body="&lt;p&gt;Often when coding I have this window layout - which is mapped to the flow of the program I am editing.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tab1&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+------------+--------------+&#xA;|            |              |&#xA;|            |      B       |&#xA;|            |              |&#xA;|            |              |&#xA;|  A         +--------------+&#xA;|            |              |&#xA;|            |              |&#xA;|            |       C      |&#xA;|            |              |&#xA;+------------+--------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to open &lt;code&gt;B&lt;/code&gt; in a new tab to work on it, but I want to leave the layout of &lt;code&gt;tab1&lt;/code&gt; intact.&lt;br&gt;&#xA;Here is my desired outcome.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        tab1                         tab2&#xA;+------------+--------------+ +---------------------------+ &#xA;|            |              | |                           | &#xA;|            |      B       | |                           | &#xA;|            |              | |                           | &#xA;|            |              | |            B              | &#xA;|  A         +--------------+ |                           | &#xA;|            |              | |                           | &#xA;|            |              | |                           | &#xA;|            |       C      | |                           | &#xA;|            |              | |                           | &#xA;+------------+--------------+ +---------------------------+ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;What I have tried using vim&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;From inside &lt;code&gt;B&lt;/code&gt;, open it in a new tab with &lt;code&gt;&amp;lt;C-w&amp;gt;T&lt;/code&gt;.&lt;br&gt;&#xA;The problem is that destroys the &lt;code&gt;B&lt;/code&gt; window in &lt;code&gt;tab1&lt;/code&gt;.  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;tabe &amp;lt;full path to filename&amp;gt;&lt;/code&gt; - this works, but I am trying to find a &quot;shortcut&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;What I have tried using ctrlp&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt;, type in few characters of filename, &lt;code&gt;&amp;lt;C-t&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Unfortunately ctrlp excludes the current buffer from its results, I know I can move to another window, buy I always forget this when I am coding, so I just assume ctrlp cant find the file and resort to some other way to open the file.&lt;br&gt;&#xA;Is there a shortcut to open a file in a new tab, leaving the current one intact or to enable ctrlp to include the current buffer in its results?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2016-03-04T11:19:25.413" Title="How can I open a buffer in a new tab leaving the current window and buffer intact?" Tags="|vim-windows|tabbed-user-interface|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6747" PostTypeId="2" ParentId="6746" CreationDate="2016-03-03T00:49:54.117" Score="8" Body="&lt;p&gt;After some research I found a solution.&lt;br&gt;&#xA;If you are focused on the buffer/window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabe %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This opens the current buffer in new tab and leaves the current window intact.&lt;br&gt;&#xA;&lt;em&gt;why&lt;/em&gt; does it leave the old buffer intact when &lt;code&gt;&amp;lt;C-w&amp;gt;T&lt;/code&gt; destroys it? I guess its because &lt;code&gt;tabe&lt;/code&gt; generally &lt;em&gt;creates&lt;/em&gt; a new tab, whereas &lt;code&gt;&amp;lt;C-w&amp;gt;T&lt;/code&gt; seems to create a new tab and &lt;em&gt;move&lt;/em&gt; the current window and buffer to it.&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2016-03-03T01:06:19.023" LastActivityDate="2016-03-03T01:06:19.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6748" PostTypeId="2" ParentId="6746" CreationDate="2016-03-03T01:01:05.583" Score="11" Body="&lt;p&gt;&lt;code&gt;:tab split&lt;/code&gt; will create a new tab displaying the current buffer, since &lt;code&gt;:tab&lt;/code&gt; modifies any command that would normally create a split to instead create a tab page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to override &lt;code&gt;&amp;lt;C-w&amp;gt;T&lt;/code&gt; to do that instead of its default behavior, you can remap it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-w&amp;gt;T :tab split&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You may be wondering why I used &lt;code&gt;:tab split&lt;/code&gt; instead of &lt;code&gt;:tabedit %&lt;/code&gt;.  According to the documentation, &lt;code&gt;:tabedit {file}&lt;/code&gt; is just like creating a new tab and then running &lt;code&gt;:edit {file}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, it would be a bad idea to use since &lt;code&gt;:edit {file}&lt;/code&gt; on a modified buffer would try to reload the buffer.  &lt;code&gt;:tab split&lt;/code&gt; better fits the behavior you're describing of just opening a new view of the existing buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All that being said, the implementation of &lt;code&gt;:tabedit {file}&lt;/code&gt; apparently doesn't act &lt;em&gt;just&lt;/em&gt; like &lt;code&gt;:edit {file}&lt;/code&gt; since it doesn't actually reload the buffer.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2016-03-03T01:01:05.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6749" PostTypeId="1" CreationDate="2016-03-03T03:07:08.077" Score="26" ViewCount="2737" Body="&lt;p&gt;My cursor is in the middle of a paragraph when I decide suddenly I need to copy that paragraph:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qyw4Q.png&quot; alt=&quot;start&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I type &lt;code&gt;vip&lt;/code&gt; to select the paragraph visually:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bQBQa.png&quot; alt=&quot;selected&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I hit &lt;code&gt;cmd+C&lt;/code&gt; to copy to clipboard (this may vary on your system, but shouldn't be relevant to my post's central question), which leaves my cursor at the beginning of the paragraph:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/egWyR.png&quot; alt=&quot;final&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;rather than the desired position, which is where it was when I started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the same problem occurs when yanking the selection non-visually with &lt;code&gt;yip&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like the default behavior to be &quot;return to original cursor position&quot; after doing selection/copy actions like this.  Is there a configuration that makes this possible?&lt;/p&gt;&#xA;" OwnerUserId="5373" LastEditorUserId="5373" LastEditDate="2022-08-05T16:25:42.777" LastActivityDate="2022-08-05T22:34:32.900" Title="After copying a visual selection, return to original location" Tags="|vimscript|vimrc|cursor-movement|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6750" PostTypeId="2" ParentId="6749" CreationDate="2016-03-03T04:10:36.177" Score="5" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/svermeulen/vim-easyclip&quot; rel=&quot;noreferrer&quot;&gt;vim-easyclip plugin&lt;/a&gt; has a setting for this: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;g:EasyClipPreserveCursorPositionAfterYank&lt;/code&gt; - Default 0 (ie. disabled). Vim's default behaviour is to position the cursor at the beginning of the yanked text, which is consistent with other motions. However if you prefer the cursor position to remain unchanged when performing yanks, enable this option.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's a bit much for me to install an entire plugin just for this small feature, so I prefer using marks as per my comment.&lt;/p&gt;&#xA;" OwnerUserId="4932" LastActivityDate="2016-03-03T04:10:36.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6751" PostTypeId="2" ParentId="6749" CreationDate="2016-03-03T08:33:01.100" Score="18" Body="&lt;p&gt;A possible solution is to use jumps:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before yanking or visually selecting you can set a new jump which you'll be able to access after your cursor has moved. To do so use &lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;`&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then after your cursor has moved because of the yanking use &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt; to jump back in the jump list. Also you can see the list of the available jumps with &lt;code&gt;:jumps&lt;/code&gt; and navigate this list with &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt; and &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To sum up your workflow would be:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;`&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As using &lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;` &lt;/kbd&gt; sets a mark, you can jump to it with &lt;kbd&gt;`&lt;/kbd&gt;&lt;kbd&gt;`&lt;/kbd&gt; instead of &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#mark-motions&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h mark-motions&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#:jumps&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :jumps&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-10-18T11:38:54.363" LastActivityDate="2018-10-18T11:38:54.363" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="6752" PostTypeId="2" ParentId="6749" CreationDate="2016-03-03T08:41:55.987" Score="14" Body="&lt;p&gt;You can avoid moving the cursor with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'{,'}y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help range&lt;/code&gt;, &lt;code&gt;:help mark-motions&lt;/code&gt;, and &lt;code&gt;:help :y&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-03-03T08:41:55.987" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6753" PostTypeId="2" ParentId="5236" CreationDate="2016-03-03T09:43:59.717" Score="1" Body="&lt;p&gt;This behaviour is intentional. &lt;a href=&quot;https://groups.google.com/forum/?_escaped_fragment_=msg/vim_use/MZtoTLwmeCo/NANEk3mxBwAJ#!msg/vim_use/MZtoTLwmeCo/NANEk3mxBwAJ&quot; rel=&quot;nofollow&quot;&gt;From the maillist&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is because computing the size of the scrollbar thumb would require&#xA;  going through the whole file and computing the folds.  That can be very&#xA;  slow in a large file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-03-03T09:43:59.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6754" PostTypeId="2" ParentId="5224" CreationDate="2016-03-03T09:52:32.077" Score="1" Body="&lt;p&gt;Most indent files will either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;set &lt;code&gt;indentexpr&lt;/code&gt; and &lt;code&gt;indentkeys&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;set &lt;code&gt;cindent&lt;/code&gt; and &lt;code&gt;cinoptions&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can check the values by appending a question mark, and you can see where an option was set by prefixing it with &lt;code&gt;:verbose&lt;/code&gt;. For example for JS:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set cindent?&#xA;  cindent&#xA;        Last set from /usr/share/vim/vim74/indent/javascript.vim&#xA;:verbose set indentexpr?&#xA;  indentexpr=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or for Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set cindent? &#xA;  nocindent&#xA;:verbose set indent&#xA;  indentexpr=GetPythonIndent(v:lnum)&#xA;        Last set from /usr/share/vim/vim74/indent/python.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-03-03T09:52:32.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6755" PostTypeId="2" ParentId="6749" CreationDate="2016-03-03T10:26:10.807" Score="12" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My cursor is in the middle of a paragraph&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you've just edited it, the simplest solution is to type &lt;kbd&gt;g ;&lt;/kbd&gt; which will position your cursor on the last edit position.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if you haven't edited the paragraph, you could do a simple replace operation with the same character you are on (e.g. you're on &lt;code&gt;h&lt;/code&gt;, you type &lt;code&gt;rh&lt;/code&gt;) to trigger an edit &quot;event&quot; without actually editing anything.&lt;/p&gt;&#xA;" OwnerUserId="3280" LastEditorUserId="1841" LastEditDate="2016-03-03T11:04:05.910" LastActivityDate="2016-03-03T11:04:05.910" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6756" PostTypeId="2" ParentId="6604" CreationDate="2016-03-03T11:25:48.777" Score="2" Body="&lt;p&gt;Vim links against Python; it doesn't call an external Python binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see this with &lt;code&gt;ldd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ldd /usr/bin/vim | grep python&#xA;        libpython2.7.so.1.0 =&amp;gt; /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 (0x00007f94673fb000)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This output is for Linux, but your OSX output should be similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way to use your custom Python is to recompile Vim and link against &lt;code&gt;libpython&lt;/code&gt; in &lt;code&gt;/Users/me/apps/Darwin64/python2.7/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use a module from this Python, you can do so by modifying &lt;code&gt;sys.path&lt;/code&gt;, the default looks something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; sys.path&#xA;['', '/usr/lib/python2.7', '/home/martin/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a list which tells Python where to search for modules. You can modify it like any list. You can also use the &lt;code&gt;PYTHONPATH&lt;/code&gt; environment variable to the same effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the documentation for &lt;a href=&quot;https://docs.python.org/2/library/sys.html#sys.path&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;sys.path&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://docs.python.org/2/reference/simple_stmts.html#import&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;import&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can load the module using the &lt;a href=&quot;https://docs.python.org/2/library/imp.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;imp&lt;/code&gt;&lt;/a&gt; module. I didn't test this, but you should be able to use &lt;code&gt;load_dynamic&lt;/code&gt;. I don't recommend this, since a lot of this changed in Python 3 so your code won't be future-compatible.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-03-03T11:25:48.777" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6757" PostTypeId="2" ParentId="6421" CreationDate="2016-03-03T12:18:44.607" Score="2" Body="&lt;p&gt;The solution to this is similar to &lt;a href=&quot;https://vi.stackexchange.com/q/118/51&quot;&gt;How can I use Vim&amp;#39;s spellcheck with ‘smart quotes’&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/q/6645/51&quot;&gt;Can the spell checker be told to stop marking words with apostrophes as bad?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add your variants to &lt;code&gt;~/.vim/spell/en.utf-8.add&lt;/code&gt;, and mark the undesired as wrong by adding &lt;code&gt;/!&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;œconomy&#xA;economy/!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then compile it with &lt;code&gt;:mkspell&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!mkspell %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you should be good to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do this from normal more with &lt;code&gt;zg&lt;/code&gt; (mark good) and &lt;code&gt;zw&lt;/code&gt; (mark wrong). You don't need to use &lt;code&gt;:mkspell&lt;/code&gt; with this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this automatically for &lt;em&gt;all&lt;/em&gt; words is a bit more difficult. The æ in præcise or æther is an e, but the æ in encyclopædia or archæology is an ae... How do you know which one to use?&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-03-03T12:35:03.267" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6758" PostTypeId="2" ParentId="6330" CreationDate="2016-03-03T12:31:08.970" Score="2" Body="&lt;p&gt;The only way that I can figure out is to make a function which loops over all&#xA;the characters in the line and checks if it's concealed with&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#synconcealed%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;synconcealed()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to work well for help files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! VisualCol()&#xA;    let l:substract = 0&#xA;    for l:i in range(0, col('$'))&#xA;        if synconcealed('.', l:i)[0]&#xA;            let l:substract += 1&#xA;        endif&#xA;    endfor&#xA;&#xA;    return virtcol('$') - l:substract&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-03-03T18:59:10.690" LastActivityDate="2016-03-03T18:59:10.690" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6759" PostTypeId="2" ParentId="2003" CreationDate="2016-03-03T21:59:02.723" Score="14" Body="&lt;p&gt;One more tip: as caveman as it may seem, I do like adding :echom &quot;message&quot; to my .vimrc to see whats being executed and what is not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if executable('ag')&#xA;  :echom &quot;AG FOUND&quot;&#xA;&#xA;  ...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This helps me quickly see if the if block is being executed, etc. The message will be printed on the console next time you start vim.&lt;/p&gt;&#xA;" OwnerUserId="6664" LastActivityDate="2016-03-03T21:59:02.723" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6760" PostTypeId="2" ParentId="6731" CreationDate="2016-03-04T09:55:09.303" Score="6" Body="&lt;p&gt;In addition to @Nobe4 answer you could do the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Create the file &lt;code&gt;~/.vim/after/syntax/python.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Put theses line in the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match PythonArg /(.*\,\s*\zs\w\+\ze\s*=.*)/&#xA;hi PythonArg guibg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;Adapt the second one with your prefered values.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This will create a syntax file which will add a syntax match for your arguments followed by a &lt;code&gt;=&lt;/code&gt; and set the style to use. This topic &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#mysyntaxfile-add&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h mysyntaxfile-add&lt;/code&gt;&lt;/a&gt; should be interesting for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I used a different regex than the other answer, here is the detail (I don't know which one works better so you'll probably have to try):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(      Begin the pattern with a bracket&#xA;.*,    Look for any number of any character before a ,&#xA;\s*    Zero or more white spaces after the ,&#xA;\zs    Start the matching group (what will be highlighted)&#xA;\w\+   Match one or more word characters&#xA;\ze    End the matching group&#xA;\s*    Zero or more white spaces between your argument and the = sign&#xA;=      A literal = sign after your argument&#xA;.*)    Any number of any characters between your = sign and the closing bracket&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-03-04T09:55:09.303" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6761" PostTypeId="2" ParentId="6746" CreationDate="2016-03-04T11:19:25.413" Score="3" Body="&lt;p&gt;Another way, just for the fun of it…&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabnew|b#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;create a new tab page, containing a new window, containing a new empty buffer.&lt;/li&gt;&#xA;&lt;li&gt;then switch to the &quot;alternate file&quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-03-04T11:19:25.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6762" PostTypeId="1" AcceptedAnswerId="6767" CreationDate="2016-03-04T14:10:29.970" Score="4" ViewCount="310" Body="&lt;p&gt;I am curious to know how I can find the next instance of a SpellLocal mistake (either by a motion key or via a search command) in vim.&lt;/p&gt;&#xA;" OwnerUserId="6673" LastActivityDate="2016-03-04T22:02:42.957" Title="How to find the next SpellLocal" Tags="|search|cursor-motions|spell-checking|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6763" PostTypeId="2" ParentId="6762" CreationDate="2016-03-04T14:13:50.873" Score="1" Body="&lt;p&gt;For navigating along the different spell mistakes, you can use the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/spell.html#]s&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;\[s&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/spell.html#[s&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;\]s&lt;/code&gt;&lt;/a&gt; motions, which move to the previous and next mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/spell.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h spell-quickstart&lt;/code&gt;&lt;/a&gt; for an introduction on how to use spell.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-03-04T14:13:50.873" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6764" PostTypeId="2" ParentId="6762" CreationDate="2016-03-04T14:41:20.467" Score="4" Body="&lt;p&gt;You could try &lt;a href=&quot;https://github.com/vim-scripts/SrchRplcHiGrp.vim&quot; rel=&quot;nofollow&quot;&gt;SrchRplcHiGrp.vim&lt;/a&gt;: this plugin creates a command &lt;code&gt;SRSearch&lt;/code&gt; which allows to search for the occurrences of an highlight group. As &lt;code&gt;hl-SpellLocal&lt;/code&gt; is an highlight group that should do the trick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use it you'll have to find a word highlighted as a SpellLocal error, put your cursor on this word and use &lt;code&gt;SRChooseHiGrp&lt;/code&gt; to select the group you're looking for. Then you can use &lt;code&gt;SRSearch&lt;/code&gt; to go to the next word of the group.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-03-04T15:06:27.757" LastActivityDate="2016-03-04T15:06:27.757" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6765" PostTypeId="1" AcceptedAnswerId="6766" CreationDate="2016-03-04T19:10:55.473" Score="5" ViewCount="112" Body="&lt;p&gt;I use vim for writing code and often accidentally type this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;funciton() {}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;instead of&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;function() {}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's irritating and I know vim supports &lt;strong&gt;iabbrev&lt;/strong&gt; for this purpose.  But it doesn't work in this case since there is not a space after the word &lt;em&gt;function&lt;/em&gt;.  Blame our coding standards I guess.  But is there a way either out-of-the-box or through a plugin to automatically correct such a thing?&lt;/p&gt;&#xA;" OwnerUserId="6526" LastActivityDate="2016-03-04T19:38:04.580" Title="Can vim automatically correct a spelling mistake if the word doesn't end in a space?" Tags="|abbreviations|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6766" PostTypeId="2" ParentId="6765" CreationDate="2016-03-04T19:38:04.580" Score="6" Body="&lt;p&gt;As mentioned in the comments, the simple abbreviation &lt;code&gt;iabbr funciton function&lt;/code&gt;  works on my setup and in vanilla vim, without any need of type space -- it is triggered by the &lt;code&gt;(&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your problem is being caused by some specific configuration/plugin; thus you should follow the procedure described on &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-2.5&quot;&gt;Vim-FAQ  2.5&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2.5. I have a &quot;xyz&quot; (some) problem with Vim. How do I determine it is a&#xA;       problem with my setup or with Vim?  / Have I found a bug in Vim?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;First, you need to find out, whether the error is in the actual&#xA;  runtime files or any plugin that is distributed with Vim or whether it&#xA;  is a simple side effect of any configuration option from your .vimrc&#xA;  or .gvimrc. So first, start vim like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;this starts Vim in nocompatible mode (-N), without reading your&#xA;  viminfo file (-i NONE), without reading any configuration file (-u&#xA;  NONE for not reading .vimrc file and -U NONE for not reading a .gvimrc&#xA;  file) or even plugin.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If the error does not occur when starting Vim this way, then the&#xA;  problem is either related to some plugin of yours or some setting in&#xA;  one of your local setup files. You need to find out, what triggers the&#xA;  error, you try starting Vim this way: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;If the error occurs, the problem is your .viminfo file. Simply delete&#xA;  the viminfo file then. If the error does not occur, try: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u ~/.vimrc --noplugin -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This will simply use your .vimrc as configuration file, but not load&#xA;  any plugins. If the error occurs this time, the error is possibly&#xA;  caused by some configuration option inside your .vimrc file. Depending&#xA;  on the length of your vimrc file, it can be quite hard to trace the&#xA;  origin within that file.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The best way is to add :finish command in the middle of your .vimrc.&#xA;  Then restart again using the same command line. If the error still&#xA;  occurs, the bug must be caused because of a setting in the first half&#xA;  of your .vimrc. If it doesn't happen, the problematic setting must be&#xA;  in the second half of your .vimrc. So move the :finish command to the&#xA;  middle of that half, of which you know that triggers the error and&#xA;  move your way along, until you find the problematic option. If your&#xA;  .vimrc is 350 lines long, you need at a maximum 9 tries to find the&#xA;  offending line (in practise, this can often be further reduced, since&#xA;  often lines depend on each other).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If the problem does not occur, when only loading your .vimrc file, the&#xA;  error must be caused by a plugin or another runtime file (indent&#xA;  autoload or syntax script). Check the output of the :scriptnames&#xA;  command to see what files have been loaded and for each one try to&#xA;  disable each one by one and see which one triggers the bug. Often&#xA;  files that are loaded by vim, have a simple configuration variable to&#xA;  disable them, but you need to check inside each file separately.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-03-04T19:38:04.580" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6767" PostTypeId="2" ParentId="6762" CreationDate="2016-03-04T20:41:11.600" Score="5" Body="&lt;p&gt;What you can do is modify the &lt;code&gt;]s&lt;/code&gt; and &lt;code&gt;[s&lt;/code&gt; motions to skip over &lt;code&gt;SpellBad&lt;/code&gt; highlighted words. This is actually not very hard. With the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#spellbadword%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;spellbadword()&lt;/code&gt;&lt;/a&gt; function we can get information about the spell status of the current word:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example outputs of &lt;code&gt;:echo spellbadword()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;test: &lt;code&gt;['', '']&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;behavior (with en-gb locale): &lt;code&gt;['behavior', 'local']&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;qwe: &lt;code&gt;['qwe', 'bad']&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So what we need to make is a mapping which:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Runs &lt;code&gt;]s&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Checks if the word under the cursor has the status &lt;code&gt;local&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If so, stop.&lt;/li&gt;&#xA;&lt;li&gt;If the cursor position is unchanged, there are no more misspelled words and we stop.&lt;/li&gt;&#xA;&lt;li&gt;All else: go to the next word and back to 1.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;And here is exactly such a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! SpellLocal() abort&#xA;    let l:start_pos = getpos('.')&#xA;&#xA;    while 1&#xA;        &quot; Store the cursor position&#xA;        let l:cursor = getpos('.')&#xA;&#xA;        &quot; Run ]s&#xA;        normal ]s&#xA;&#xA;        &quot; The cursor position hasn't changed, this means ]s didn't find&#xA;        &quot; anything else.&#xA;        if getpos('.') == l:cursor&#xA;            &quot; Restore cursor position to match default ]s behaviour&#xA;            call setpos('.', l:start_pos)&#xA;            break&#xA;        endif&#xA;&#xA;        &quot; We found a SpellLocal; stop.&#xA;        if spellbadword()[1] == 'local'&#xA;            break&#xA;        &quot; Something else; continue to next word&#xA;        else&#xA;            normal w&#xA;        endif&#xA;    endwhile&#xA;endfun&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;]s :call SpellLocal()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can expand this by passing an argument which specifies the direction (&lt;code&gt;]s&lt;/code&gt; or &lt;code&gt;[s&lt;/code&gt;). This is left as an exercise for the reader :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-03-04T22:02:42.957" LastActivityDate="2016-03-04T22:02:42.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6768" PostTypeId="1" AcceptedAnswerId="6769" CreationDate="2016-03-04T21:57:08.303" Score="9" ViewCount="321" Body="&lt;p&gt;I often run into a situation where I have a file with a lot of mixed case. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CamelCase and camelCase&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm looking for a Vim regular expression replacement to produce,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AnotherCase and anotherCase&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Right now I do this in two steps after visually selecting the lines,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/CamelCase/AnotherCase/g&#xA;:s/camelCase/anotherCase/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this possible in one replacement step, or should I look into other options like a function in &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6674" LastActivityDate="2016-03-05T00:20:57.237" Title="Mixed case regular expression replacement, in Vim" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6769" PostTypeId="2" ParentId="6768" CreationDate="2016-03-04T22:01:46.310" Score="7" Body="&lt;p&gt;I would suggest using &lt;code&gt;:Subvert&lt;/code&gt; via Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-abolish&quot;&gt;Abolish.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%S/camelCase/anotherCase/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimcasts.org/&quot;&gt;Vimcasts&lt;/a&gt; episode: &lt;a href=&quot;http://vimcasts.org/episodes/supercharged-substitution-with-subvert/&quot;&gt;Supercharged substitution with :Subvert&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-03-04T22:01:46.310" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6771" PostTypeId="2" ParentId="6768" CreationDate="2016-03-05T00:20:57.237" Score="3" Body="&lt;p&gt;You also have the venerable &lt;a href=&quot;http://vim.sourceforge.net/scripts/script.php?script_id=6&quot; rel=&quot;nofollow&quot;&gt;keepcase&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SubstituteCase#\ctoto\(Titi\)tata#\1Tutu#g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you'll obtain:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; totoTitiTata -&amp;gt; titiTutu&#xA; TotoTitiTata -&amp;gt; TitiTutu&#xA; tototititata -&amp;gt; tititutu&#xA; tototitiTata -&amp;gt; titiTutu&#xA; TototitiTata -&amp;gt; TitiTutu &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-03-05T00:20:57.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6772" PostTypeId="1" CreationDate="2016-03-05T03:32:20.043" Score="3" ViewCount="5016" Body="&lt;p&gt;I have Vim 7.4 installed on Windows 10 as part of a Mingw64 installation. I installed the YouCompleteMe plugin on it through Vundle, then ran the &lt;code&gt;install.py&lt;/code&gt;, which completed successfully. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, every time I lunch Vim I get this message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;YouCompleteMe unavailable: requires Vim compiled with Python 2.x support&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the plugin doesn't seem to be active. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do have python 2.7 and 3.x installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;py --version&#xA;Python 3.5.1&#xA;&#xA;&amp;gt;py -2 --version&#xA;Python 2.7.11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;YouCompleteMe&lt;/code&gt; compilation and installation was successful, as far as I can tell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;user@computer MINGW64 ~/.vim/bundle/YouCompleteMe (master)&#xA;$ py -2 install.py&#xA;-- The C compiler identification is MSVC 19.0.23506.0&#xA;-- The CXX compiler identification is MSVC 19.0.23506.0&#xA;-- Check for working C compiler using: Visual Studio 14 2015 Win64&#xA;-- Check for working C compiler using: Visual Studio 14 2015 Win64 -- works&#xA;-- Detecting C compiler ABI info&#xA;-- Detecting C compiler ABI info - done&#xA;-- Check for working CXX compiler using: Visual Studio 14 2015 Win64&#xA;-- Check for working CXX compiler using: Visual Studio 14 2015 Win64 -- works&#xA;-- Detecting CXX compiler ABI info&#xA;-- Detecting CXX compiler ABI info - done&#xA;-- Detecting CXX compile features&#xA;-- Detecting CXX compile features - done&#xA;Your C++ compiler does NOT support C++11, compiling in C++03 mode.&#xA;-- Found PythonLibs: C:/Program Files/Python27/libs/python27.lib (found suitable version &quot;2.7.11&quot;, minimum required is &quot;2.6&quot;)&#xA;NOT using libclang, no semantic completion for C/C++/ObjC will be available&#xA;-- Found PythonInterp: C:/Program Files/Python35/python.exe (found version &quot;3.5.1&quot;)&#xA;-- Looking for pthread.h&#xA;-- Looking for pthread.h - not found&#xA;-- Found Threads: TRUE&#xA;-- Configuring done&#xA;-- Generating done&#xA;-- Build files have been written to: C:/Users/Eduardo/AppData/Local/Temp/ycm_build.irqgsp&#xA;Microsoft (R) Build Engine version 14.0.24730.2&#xA;Copyright (C) Microsoft Corporation. All rights reserved.&#xA;&#xA;Build started 3/4/2016 2:27:10 PM.&#xA;...&#xA;88 Warning(s)&#xA;0 Error(s)&#xA;&#xA;Time Elapsed 00:00:40.18&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, this Vim has been compiled with python support:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep 16 2015 08:44:57)&#xA;Included patches: 1-872&#xA;Compiled by &amp;lt;alexpux@gmail.com&amp;gt;&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;+clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   +perl/dyn        +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python/dyn      +viminfo&#xA;+cscope          +lispindent      +python3/dyn     +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            +ruby/dyn        +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            +mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        -mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;   system vimrc file: &quot;/etc/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/etc&quot;&#xA; f-b for $VIMRUNTIME: &quot;/usr/share/vim/vim74&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -D_FORTIFY_SOURCE=2 -I/usr/include/ncursesw  -march=x86-64 -mtune=generic -O2 -pipe -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -L. -pipe -fstack-protector -pipe -Wl,--as-needed -o vim.exe        -lm    -lncursesw -liconv -lintl   -pipe -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong  -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -ldl -lcrypt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, even though this output indicates python is enabled, when I the the command &lt;code&gt;:echo has('python')&lt;/code&gt; inside Vim I get a 0 response. I think this should be a 1, no? Not sure what's missing...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google had a couple of pointers but they are for things that I already checked (like Vim being compiled with python support), and all info was for Linux or Mac OSX. Nothing for Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim installation should be 64 bits since it was installed with Mingw64, and I'm running python also 64 bits, as evidenced by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ py -c 'import struct;print( 8 * struct.calcsize(&quot;P&quot;))'&#xA;64&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ py -2 -c 'import struct;print( 8 * struct.calcsize(&quot;P&quot;))'&#xA;64&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I fix this so that the &lt;code&gt;YouCompleteMe&lt;/code&gt; plugin will work properly?&lt;/p&gt;&#xA;" OwnerUserId="6664" LastEditorUserId="205" LastEditDate="2016-03-05T09:15:21.980" LastActivityDate="2016-04-05T11:16:37.933" Title="How to resolve &quot;requires Vim compiled with Python 2.x support&quot; when launching Vim?" Tags="|microsoft-windows|plugin-you-complete-me|vimscript-python|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6773" PostTypeId="1" AcceptedAnswerId="6775" CreationDate="2016-03-05T09:25:03.350" Score="5" ViewCount="1301" Body="&lt;h1&gt;Problem summary&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;vim&lt;/code&gt; to edit emails that I send with &lt;code&gt;mutt&lt;/code&gt;. I also use &lt;code&gt;format=flowed&lt;/code&gt;, which &quot;reflows&quot; text. That is, lines are limited to a fixed number of characters, and a &quot;soft wrap&quot; is applied, as indicated by the presence of a trailing space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;vim&lt;/code&gt;, I have the following set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setl tw=72&#xA;setl fo=aw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets the line length to 72 charaters, and sets up autoformatting with the trailing space. This works well in general. However, if I attempt to quote something with &lt;code&gt;&amp;gt;&lt;/code&gt;, this character is not treated as a special character, and will be considered &quot;inline&quot; to the text.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Example&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Copy the following text and paste it into &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Tempus. Vivamus. Dis natoque vitae erat. Consectetuer adipiscing nullam nec gravida non, at posuere enim, consectetuer ve. [1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim&lt;/code&gt; correctly breaks it into two lines, the first with a trailing space.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Tempus. Vivamus. Dis natoque vitae erat. Consectetuer adipiscing nullam &#xA;nec gravida non, at posuere enim, consectetuer ve. [1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I add &lt;code&gt;&amp;gt;&lt;/code&gt; by selecting the lines and using &lt;code&gt;:'&amp;lt;,'&amp;gt;s/^/&amp;gt; /&lt;/code&gt;, which results in the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; Tempus. Vivamus. Dis natoque vitae erat. Consectetuer adipiscing nullam &#xA;&amp;gt; nec gravida non, at posuere enim, consectetuer ve. [1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I now want to remove the &lt;code&gt;[1]&lt;/code&gt; from the end, so I navigate to the end and delete. &lt;code&gt;vim&lt;/code&gt; now reflows to the following, with the &lt;code&gt;&amp;gt;&lt;/code&gt; &quot;inline&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; Tempus. Vivamus. Dis natoque vitae erat. Consectetuer adipiscing &#xA;nullam &amp;gt; nec gravida non, at posuere enim, consectetuer ve.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's even worse is that I can delete the &lt;code&gt;&amp;gt;&lt;/code&gt; manually and insert a new &lt;code&gt;&amp;gt;&lt;/code&gt; before &lt;code&gt;nullam&lt;/code&gt;, but this will immediately be reflowed to the previous line as follows.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; Tempus. Vivamus. Dis natoque vitae erat. Consectetuer adipiscing &amp;gt; &#xA;nullam nec gravida non, at posuere enim, consectetuer ve.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make &lt;code&gt;vim&lt;/code&gt;'s flowing aware of &lt;code&gt;&amp;gt;&lt;/code&gt;? FWIW I've also tried &lt;a href=&quot;https://gist.github.com/wcaleb/633a63e9c29887493d3f&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; &lt;code&gt;mail.vim&lt;/code&gt; customised for format=flowed, but it suffers from the same problems.&lt;/p&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="205" LastEditDate="2016-03-05T09:49:00.663" LastActivityDate="2016-03-05T12:52:38.233" Title="How can I make vim's flowing aware of email replies?" Tags="|formatting|wrapping|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6774" PostTypeId="2" ParentId="6773" CreationDate="2016-03-05T09:57:46.367" Score="2" Body="&lt;p&gt;&lt;code&gt;setlocal formatoptions=jawtcqln&lt;/code&gt; worked for me. I'd put it in &lt;code&gt;~/.vim/ftplugin/mail.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6682" LastActivityDate="2016-03-05T09:57:46.367" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6775" PostTypeId="2" ParentId="6773" CreationDate="2016-03-05T10:11:16.177" Score="6" Body="&lt;p&gt;From &lt;a href=&quot;https://vi.stackexchange.com/a/6034/205&quot;&gt;one of my previous answers&lt;/a&gt;, you can get this to work if:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You have &lt;code&gt;nb:&amp;gt;&lt;/code&gt; in your &lt;code&gt;comments&lt;/code&gt; setting.&lt;/li&gt;&#xA;&lt;li&gt;And you have &lt;code&gt;q&lt;/code&gt; in your &lt;code&gt;formatoptions&lt;/code&gt; setting.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal comments+=nb:&amp;gt;&#xA;setlocal fo+=q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After doing these, I get the expected wrapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; Tempus. Vivamus. Dis natoque vitae erat. Consectetuer adipiscing &#xA;&amp;gt; nullam nec gravida non, at posuere enim, consectetuer ve.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-03-05T12:52:38.233" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6776" PostTypeId="2" ParentId="5920" CreationDate="2016-03-05T13:52:16.450" Score="1" Body="&lt;p&gt;Solved - restore all vimrc files except for the one in ~/.vimrc to their defaults.&lt;/p&gt;&#xA;" OwnerUserId="5758" LastActivityDate="2016-03-05T13:52:16.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6777" PostTypeId="1" CreationDate="2016-03-05T15:38:30.737" Score="2" ViewCount="880" Body="&lt;p&gt;I have the &lt;code&gt;ruler&lt;/code&gt; shown, but as soon as I drop into insert mode, it disappears and reappears upon entering normal mode. This is very annoying when trying to insert a certain number of spaces to have the cursor at column x.&#xA;MacVim shows no such behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I show the ruler in insert mode?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastEditorUserId="1066" LastEditDate="2016-03-05T16:54:40.910" LastActivityDate="2016-03-05T16:54:40.910" Title="Why is ruler not shown in insert mode?" Tags="|insert-mode|normal-mode|" AnswerCount="0" CommentCount="4" ClosedDate="2016-03-08T07:57:20.243" ContentLicense="CC BY-SA 3.0" />
  <row Id="6778" PostTypeId="1" AcceptedAnswerId="6781" CreationDate="2016-03-05T16:37:25.680" Score="22" ViewCount="2910" Body="&lt;p&gt;I was looking at &lt;a href=&quot;https://github.com/tpope/vim-sensible/blob/master/plugin/sensible.vim&quot;&gt;Tim Pope's vim-sensible plugin&lt;/a&gt; and I noticed this in the README...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;See the source for the authoritative list of features. (Don't worry, it's mostly &lt;code&gt;:set&lt;/code&gt; calls.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When I looked at the source, the &lt;code&gt;:set&lt;/code&gt; calls are like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's no &lt;code&gt;:&lt;/code&gt; before the &lt;code&gt;set&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty sure I've actually seen &lt;code&gt;:set&lt;/code&gt; in example &lt;code&gt;.vimrc&lt;/code&gt;s also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the difference?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which form should I use in my &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6689" LastEditorUserId="205" LastEditDate="2020-05-22T10:11:35.247" LastActivityDate="2020-05-22T10:11:35.247" Title="What is the difference between set and :set (commands with or without a leading colon)?" Tags="|vimscript|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6779" PostTypeId="2" ParentId="6778" CreationDate="2016-03-05T17:31:12.810" Score="10" Body="&lt;p&gt;There is no difference.  If vim sees a &lt;code&gt;:&lt;/code&gt; before a command in your vimrc &lt;em&gt;(or any vimscript file)&lt;/em&gt; it will ignore it.  Also, as mentioned above, this isn't specific to the &lt;code&gt;set&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually the &lt;code&gt;:&lt;/code&gt; means that the command would be run by you instead of being put in your vimrc &lt;em&gt;(or other vimscript file)&lt;/em&gt;, but that usually depends on the context.  Personally I think it looks much better to not put the colon before commands in vimscript files, and that seems to be what most other people do as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more on this see &lt;code&gt;:help script&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="865" LastEditorUserId="865" LastEditDate="2016-03-06T03:58:21.000" LastActivityDate="2016-03-06T03:58:21.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6780" PostTypeId="1" AcceptedAnswerId="6783" CreationDate="2016-03-05T17:45:01.387" Score="2" ViewCount="1370" Body="&lt;p&gt;I have many users who sudo to root to edit certain files. How can I allow each of them to use their own ~/.vimrc file once they have sudo'd to root? In other words. they each want to use their own color scheme, even though they are acting as root. Is there a way to have VIM use the original user's .vimrc file (before sudo)?&lt;/p&gt;&#xA;" OwnerUserId="6690" LastEditorUserId="205" LastEditDate="2016-03-05T21:46:38.700" LastActivityDate="2016-03-05T21:46:38.700" Title="How do I preserve my colorscheme when I sudo to root?" Tags="|vimrc|colorscheme|sudo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6781" PostTypeId="2" ParentId="6778" CreationDate="2016-03-05T18:45:27.237" Score="29" Body="&lt;p&gt;A &quot;script&quot; does nothing more than run a sequence of ex commands. An &quot;ex command&quot; is what you type when you use &lt;code&gt;:&lt;/code&gt; in Vim. For example &lt;code&gt;:wq&lt;/code&gt;, &lt;code&gt;:set wrap&lt;/code&gt;, &lt;code&gt;:e file&lt;/code&gt;, etc. are all ex commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:&lt;/code&gt; is not part of the command; it is merely a keystroke to start the command-line mode; you don't always need to include the &lt;code&gt;:&lt;/code&gt;, for example when you chain multiple commands with &lt;code&gt;|&lt;/code&gt; you don't need to repeat the &lt;code&gt;:&lt;/code&gt; more than once. For example, &lt;code&gt;:write | quit&lt;/code&gt; will work fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For convenience, the &lt;code&gt;:&lt;/code&gt; may be included though. This aids with copy/pasting and such, but you don't have to. It doesn't matter. In fact, all leading &lt;code&gt;:&lt;/code&gt;s are simply ignored. &lt;code&gt;:write&lt;/code&gt;, &lt;code&gt;write&lt;/code&gt;, and &lt;code&gt;:::::::::write&lt;/code&gt; are all equivalent in terms of functionality (although obviously not in terms of sanity).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's often useful to include the &lt;code&gt;:&lt;/code&gt; in documentation to clarify that this is an ex command. For example &lt;code&gt;w&lt;/code&gt; could refer either to &lt;code&gt;:w&lt;/code&gt; or the normal mode command &lt;code&gt;w&lt;/code&gt; to go to the next word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this applies to &lt;em&gt;everything&lt;/em&gt;. Control structures such as &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;endif&lt;/code&gt; are &lt;em&gt;also&lt;/em&gt; just ex commands; you can type something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:if 1&#xA;:echo 'one'&#xA;:endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from the Vim commandline just fine; no need for a &quot;script&quot;. Vim scripts are very &quot;non-magic&quot; and &quot;non-special&quot;; everything you can do from the ex commandline you can do in a Vim script, and vice versa.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-03-05T21:08:23.693" LastActivityDate="2016-03-05T21:08:23.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6782" PostTypeId="2" ParentId="6541" CreationDate="2016-03-05T18:59:24.280" Score="7" Body="&lt;p&gt;The default encoding seems to be &lt;code&gt;latin1&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set encoding?&#xA;  encoding=latin1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When entering characters, Vim tries to convert them from the incoming character set (probably unicode) to latin-1. This fails since latin-1 doesn't have these characters. Hence the question marks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Opening an existing file (Saved with notepad or some other program) should result in garbled text as now Vim is just trying to read bytes and interpret them according to the latin-1 character set, and not convert them to the latin-1 set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will want to use &lt;code&gt;utf-8&lt;/code&gt; or some such:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set encoding=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After which Malayalam script seems to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; that this will &lt;em&gt;not&lt;/em&gt; make pre-existing question marks work. These really &lt;em&gt;are&lt;/em&gt; converted to question marks (character &lt;code&gt;0x3f&lt;/code&gt;) on input. There is no way to get back what was entered. I suspect that this is the source of confusion of this question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27encoding%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help 'encoding'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a sidenote, unsupported glyphs in the font are usually rendered with a distinct glyph; this varies per font, but is typically either a square block or a different styled question mark. you can see the difference between a &quot;real&quot; question mark and an unsupported glyph with &lt;code&gt;g8&lt;/code&gt;, which will show the character code.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-10-04T11:48:16.547" LastActivityDate="2016-10-04T11:48:16.547" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6783" PostTypeId="2" ParentId="6780" CreationDate="2016-03-05T19:23:37.607" Score="5" Body="&lt;p&gt;The original user is stored in the &lt;code&gt;SUDO_USER&lt;/code&gt; environment variable. So your root's vimrc you could do something along the lines of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if file_readable('/home/' . $SUDO_USER . '/.vimrc')&#xA;    source '/home/' . $SUDO_USER . '/.vimrc'&#xA;elseif file_readable('/home/' . $SUDO_USER. '/.vim/vimrc')&#xA;    source  $'/home/' . $SUDO_USER. '/.vim/vimrc'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As mentioned in the comments, your users can also use &lt;code&gt;sudoedit&lt;/code&gt; (aka. &lt;code&gt;sudo -e&lt;/code&gt;). This will copy the file to a temporary location, &lt;code&gt;chown&lt;/code&gt; it to the current user, and run &lt;code&gt;EDITOR&lt;/code&gt; for it as the currently logged in user, and after &lt;code&gt;EDITOR&lt;/code&gt; is finished, the temporary file is moved back to the original. This was designed to solve exactly this problem ;-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-03-05T19:23:37.607" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6784" PostTypeId="1" CreationDate="2016-03-05T22:33:38.517" Score="7" ViewCount="1344" Body="&lt;p&gt;&lt;code&gt;sudoedit&lt;/code&gt;/&lt;code&gt;sudo -e&lt;/code&gt; is often used for safely editing files as root. The way it works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;sudoedit&lt;/code&gt; copies the named files to temporary files&lt;/li&gt;&#xA;&lt;li&gt;Then it opens the temporary files using the commands specified by the &lt;code&gt;SUDO_EDITOR&lt;/code&gt;, &lt;code&gt;VISUAL&lt;/code&gt; or &lt;code&gt;EDITOR&lt;/code&gt; variables,&lt;/li&gt;&#xA;&lt;li&gt;That command is run as the user who ran &lt;code&gt;sudo&lt;/code&gt;, instead of &lt;code&gt;root&lt;/code&gt; (or whoever the target user is).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, the editor runs under the user's environment, and not as root. And that is excellent if your user configuration has better completion and syntax highlighting than the system Vim.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The problem&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Since the files are copied to temporary files, the filename and location, which are often identifying characteristics for &lt;code&gt;filetype&lt;/code&gt; detection, are lost. So, where &lt;code&gt;/etc/apache2/apache2.conf&lt;/code&gt; would load syntax highlighting suitable for Apache2 configuration files (&lt;code&gt;set ft&lt;/code&gt; returns &lt;code&gt;filetype=apache&lt;/code&gt;), &lt;code&gt;/var/tmp/apache2XXcLFdTD.conf&lt;/code&gt; has &lt;code&gt;filetype=conf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how do I get Vim called by &lt;code&gt;sudoedit&lt;/code&gt; to correctly detect the filetype as it normally would, as if I'd opened the file directly in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus: It would be great to have any other settings that might have applied (like &lt;code&gt;autocmd&lt;/code&gt;s) work too.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Useful information&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;sudo&lt;/code&gt; command originally ran is available in the environment variable &lt;code&gt;SUDO_COMMAND&lt;/code&gt;. For example, with &lt;code&gt;sudoedit /etc/apache2/apache2.conf&lt;/code&gt;&lt;sup&gt;1&lt;/sup&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo $SUDO_COMMAND&#xA;sudoedit /etc/apache2/apache2.conf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It could be split to get the filenames - however, it's not easy to safely do this if filenames contain spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sup&gt;1&lt;/sup&gt;Surprisingly, &lt;code&gt;SUDO_COMMDAND&lt;/code&gt; contains the same string even if I'd run &lt;code&gt;sudo -e /etc/apache2/apache2.conf&lt;/code&gt;.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another source could be to use &lt;code&gt;/proc/&amp;lt;PID&amp;gt;/cmdline&lt;/code&gt;, which contains the commandline in a NUL-delimited format. The PID here would be Vim's parent ID, so something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let ppid = system('ps -o ppid:1= -p ' . getpid())&#xA;:let cmdline = readfile('/proc/' . ppid . '/cmdline')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Of course, &lt;code&gt;readfile&lt;/code&gt; splits on &lt;code&gt;LF&lt;/code&gt; and filenames &lt;em&gt;can&lt;/em&gt; contain that, but for now, I'm not running around editing files with newlines in the name.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A third way could be to use a wrapper script in &lt;code&gt;EDITOR&lt;/code&gt;/&lt;code&gt;VISUAL&lt;/code&gt;/&lt;code&gt;SUDO_EDITOR&lt;/code&gt;. The original filenames are not directly available:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ EDITOR='printf %s\n' sudo -e /etc/apache2/apache2.conf -p&#xA;/var/tmp/apache2XXyMSNHX.conf&#xA;/var/tmp/-p.XXCW2H47&#xA;sudo: /etc/apache2/apache2.conf unchanged&#xA;sudo: -p unchanged&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, we could use &lt;code&gt;/proc/&amp;lt;PID&amp;gt;/cmdline&lt;/code&gt; more easily in a shell script, perhaps.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Even if I manage to get the filenames somehow, how do I get Vim to use them to apply the correct &lt;code&gt;filetype&lt;/code&gt; settings?&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="51" LastEditDate="2016-03-06T00:49:54.990" LastActivityDate="2016-05-16T15:38:20.037" Title="How can I automate filetype detection when using sudoedit?" Tags="|filetype|unix|sudo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6785" PostTypeId="1" AcceptedAnswerId="6789" CreationDate="2016-03-06T02:35:37.063" Score="5" ViewCount="20334" Body="&lt;p&gt;My vim was installed on debian8 with the apt-get command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apt-get install vim&#xA;$ find / -name 'autoload'&#xA;/usr/share/vim/vim74/autoload&#xA;$ find  /  -name  '.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above command can find nothing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls  /etc/vim&#xA;vimrc  vimrc.tiny&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is my vim installed on  /usr/share/vim  properly?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="5181" LastEditDate="2016-03-06T02:51:37.863" LastActivityDate="2016-03-07T21:56:09.410" Title="Where is my vim installed?" Tags="|installing|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6786" PostTypeId="1" AcceptedAnswerId="6791" CreationDate="2016-03-06T04:57:55.223" Score="4" ViewCount="357" Body="&lt;p&gt;My terminal buffers get deleted automatically when I switch to a different buffer. Is that supposed to happen? It's really annoying. Is there a way to prevent this?&lt;/p&gt;&#xA;" OwnerUserId="1410" LastActivityDate="2016-03-08T07:45:44.477" Title="Why do terminal buffers get deleted in Neovim" Tags="|neovim|terminal-buffer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6787" PostTypeId="2" ParentId="6785" CreationDate="2016-03-06T10:29:44.173" Score="8" Body="&lt;p&gt;You are not supposed to do anything with the default runtime so where Vim was installed doesn't matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whatever customization you want to do, do it in &lt;code&gt;$HOME&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-03-06T10:29:44.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6788" PostTypeId="1" AcceptedAnswerId="6790" CreationDate="2016-03-06T10:32:38.643" Score="1" ViewCount="2886" Body="&lt;p&gt;My OS is Debian, with LXDE.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find  / -name '*vimrc'&#xA;/usr/share/vim/vimrc&#xA;/etc/vim/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the difference between these two vimrc? Which one controls my vim?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="205" LastEditDate="2016-03-06T13:21:14.433" LastActivityDate="2016-03-06T13:21:14.433" Title="What is the difference between the vimrc files in /etc/vim and /usr/share/vim?" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6789" PostTypeId="2" ParentId="6785" CreationDate="2016-03-06T11:00:17.403" Score="9" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Where is my vim installed?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you installed through &lt;code&gt;apt&lt;/code&gt; the following sequence should get you to the Vim installation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From inside Vim,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo $VIMRUNTIME&#xA;/usr/share/vim/vim74&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could look in here and you would discover the Vim files, but if you wanted a more programmatic, portable approach, you could then use &lt;code&gt;dpkg&lt;/code&gt; i.e.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;dpkg -S, -- search for file owner&lt;/code&gt;:&lt;br&gt;&#xA;this tells you which &lt;code&gt;.deb&lt;/code&gt; package/s are responsible for the path &lt;code&gt;/usr/share/vim/vim74&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ dpkg -S /usr/share/vim/vim74&#xA;vim-tiny, vim-runtime, vim-common: /usr/share/vim/vim7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These are the packages, so you can use &lt;code&gt;dpkg --list-files&lt;/code&gt; to tell you where all the files belonging to the packages are.  For example, if you run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dpkg --list-files vim-runtime&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you'll get a dump of file names, which will tell you where the bulk of the vim installation is.&lt;br&gt;&#xA;You'll see that on Debian and Ubuntu, most of Vim's files are in &lt;code&gt;/usr/share/&lt;/code&gt;. &lt;sup&gt;1&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sup&gt;1&lt;/sup&gt;folder for architecture independent files as per the &lt;a href=&quot;https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard&quot; rel=&quot;noreferrer&quot;&gt;Filesystem Hierarchy Standard&lt;/a&gt;.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="205" LastEditDate="2016-03-06T14:33:51.430" LastActivityDate="2016-03-06T14:33:51.430" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6790" PostTypeId="2" ParentId="6788" CreationDate="2016-03-06T11:29:24.280" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I want to know What is the difference between two vimrc?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In the Debian packaged version of vim, &lt;code&gt;/usr/share/vim/vimrc&lt;/code&gt; is a  symlink to &lt;code&gt;/etc/vim/vimrc&lt;/code&gt; - i.e., they are the same file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% ls -al /usr/share/vim/vimrc&#xA;lrwxrwxrwx 1 root root 14 Dec 27 16:26 /usr/share/vim/vimrc -&amp;gt; /etc/vim/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to know information about a file alway at least look inside it, e.g. the first few lines of comments give some explanation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% head -5 /etc/vim/vimrc &#xA;&#xA;&quot; All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by&#xA;&quot; the call to :runtime you can find below.  If you wish to change any of those&#xA;&quot; settings, you should do it in this file (/etc/vim/vimrc), since debian.vim&#xA;&quot; will be overwritten everytime an upgrade of the vim packages is performed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a system wide vimrc file, I believe it is run everytime vim is launched and for every user on the system.&lt;br&gt;&#xA;If you want to make custom changes to vim, you should do it in your &lt;code&gt;$HOME/.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="205" LastEditDate="2016-03-06T13:19:17.857" LastActivityDate="2016-03-06T13:19:17.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6791" PostTypeId="2" ParentId="6786" CreationDate="2016-03-06T14:13:32.160" Score="2" Body="&lt;p&gt;This seems to be related to a &lt;a href=&quot;https://github.com/neovim/neovim/issues/3340&quot; rel=&quot;nofollow&quot;&gt;known bug&lt;/a&gt; involving not listing the terminal buffer at times. This prevents the problem &lt;code&gt;set hidden&lt;/code&gt;. It is currently (March 2016) planned to fix this in the upcoming 0.2 release.&lt;/p&gt;&#xA;" OwnerUserId="1410" LastEditorUserId="51" LastEditDate="2016-03-08T07:45:44.477" LastActivityDate="2016-03-08T07:45:44.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6792" PostTypeId="1" AcceptedAnswerId="6794" CreationDate="2016-03-06T14:58:01.860" Score="1" ViewCount="1456" Body="&lt;p&gt;Is there a syntax to cast from one character type for another? For example can you cast from a char to an int?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let my_var = (int)some_char&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is not valid code.&lt;/p&gt;&#xA;" OwnerUserId="1410" LastActivityDate="2020-01-09T00:15:49.173" Title="Casting in VimScript/VimL" Tags="|vimscript|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="6793" PostTypeId="1" CreationDate="2016-03-06T15:44:06.533" Score="11" ViewCount="452" Body="&lt;p&gt;Whenever I hit the end or beginning of a line, I get this very odd character where my cursor was. Any idea what may be causing this? I believe I have my fonts and theme correctly installed. I'm using Debian with the default xfce terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ARy4S.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ARy4S.gif&quot; alt=&quot;gif video of the cursor error&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4748" LastEditorUserId="205" LastEditDate="2016-04-24T18:06:11.950" LastActivityDate="2017-02-18T23:13:50.543" Title="What is causing my cursor to look so strange?" Tags="|terminal|cursor|" AnswerCount="1" CommentCount="2" ClosedDate="2017-02-21T00:32:10.013" ContentLicense="CC BY-SA 3.0" />
  <row Id="6794" PostTypeId="2" ParentId="6792" CreationDate="2016-03-06T15:51:43.217" Score="2" Body="&lt;p&gt;The answer is no. There is no general syntax to cast from one type to another. There are unique ways of converting to different types, but no universal casting syntax.&lt;/p&gt;&#xA;" OwnerUserId="1410" LastActivityDate="2016-03-06T15:51:43.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6795" PostTypeId="1" CreationDate="2016-03-06T17:59:15.040" Score="9" ViewCount="2591" Body="&lt;p&gt;I'm trying to make it so I can write a buffer to disk with &lt;strong&gt;one&lt;/strong&gt; keystroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;(Side note:&lt;/strong&gt; ideally, I'd like this to work in all modes, but for the moment as a start I'm just trying to get it to work in normal mode.&lt;strong&gt;)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Vim wiki it says...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim supports representing control characters using symbolic notation like &lt;code&gt;&amp;lt;F1&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-S-F1&amp;gt;&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And also...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A key with the &lt;code&gt;Ctrl&lt;/code&gt; key modifier is represented using the &lt;code&gt;&amp;lt;C-key&amp;gt;&lt;/code&gt; notation. For example &lt;code&gt;Ctrl-R&lt;/code&gt; is represented using &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;. A key with the Shift key modifier is represented using the &lt;code&gt;&amp;lt;S-key&amp;gt;&lt;/code&gt; notation. For example &lt;code&gt;Shift-F2&lt;/code&gt; is represented using &lt;code&gt;&amp;lt;S-F2&amp;gt;&lt;/code&gt;. A key with the &lt;code&gt;Alt&lt;/code&gt; key modifier is represented using &lt;code&gt;&amp;lt;A-key&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;M-key&amp;gt;&lt;/code&gt; notation. You can combine one or more key modifiers. For example, to represent &lt;code&gt;Ctrl+Shift+F3&lt;/code&gt; you can use &lt;code&gt;&amp;lt;C-S-F3&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That seems to be saying that if I put this in my &lt;code&gt;.vimrc&lt;/code&gt; it should work...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; nnoremap &amp;lt;S-C-k&amp;gt; :w&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it has no effect. When I reload &lt;code&gt;.vimrc&lt;/code&gt; and press &lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;control&lt;/kbd&gt;+&lt;kbd&gt;K&lt;/kbd&gt; no &lt;code&gt;[File] written&lt;/code&gt; message appears in the bottom area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried this one but then &lt;kbd&gt;option&lt;/kbd&gt;+&lt;kbd&gt;K&lt;/kbd&gt; had no effect either...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; nnoremap &amp;lt;M-k&amp;gt; :w&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No error messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm on OS X.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;UPDATE&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok I just tried this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;M-s&amp;gt; Hey whats up&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then when I go into insert mode and press &lt;kbd&gt;option&lt;/kbd&gt;+&lt;kbd&gt;S&lt;/kbd&gt;, Vim outputs...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ß&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is OS X intercepting my keystrokes before Vim even receives them? Is that why this isn't working?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, is there a way to make it stop doing that other than buying a different computer?&lt;/p&gt;&#xA;" OwnerUserId="6689" LastEditorUserId="6689" LastEditDate="2016-03-06T18:49:31.830" LastActivityDate="2017-04-08T02:09:13.353" Title="Why is key mapping nnoremap &lt;S-C-k&gt; :w&lt;CR&gt; not working?" Tags="|key-bindings|vimrc|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6796" PostTypeId="2" ParentId="6793" CreationDate="2016-03-06T18:49:40.987" Score="0" Body="&lt;p&gt;My guess is that it is your font, encoding or both that are at work. It's very hard to tell exacly what the cause is, but i recommend you reinstall font or check if you have the same problem with another font. &lt;/p&gt;&#xA;" OwnerUserId="2689" LastEditorUserId="2689" LastEditDate="2016-03-06T19:09:21.630" LastActivityDate="2016-03-06T19:09:21.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6797" PostTypeId="2" ParentId="779" CreationDate="2016-03-06T19:14:36.200" Score="4" Body="&lt;p&gt;Ubuntu 16.04 now has &lt;code&gt;vim-*-py2&lt;/code&gt; packages included in the repo. This means all Debian Vim users can migrate to Ubuntu if needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The erstwhile &lt;code&gt;vim-*&lt;/code&gt; packages now provide &lt;code&gt;+python3&lt;/code&gt;, and the binaries are named differently to avoid conflict:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vim.nox&lt;/code&gt; for &lt;a href=&quot;http://packages.ubuntu.com/xenial/amd64/vim-nox/filelist&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;vim-nox&lt;/code&gt;&lt;/a&gt; and &lt;code&gt;+python3&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vim.nox-py2&lt;/code&gt; for &lt;a href=&quot;http://packages.ubuntu.com/xenial/amd64/vim-nox-py2/filelist&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;vim-nox-py2&lt;/code&gt;&lt;/a&gt; and &lt;code&gt;+python&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And so on.&lt;/p&gt;&#xA;" OwnerUserId="6700" LastEditorUserId="205" LastEditDate="2016-06-06T17:09:48.110" LastActivityDate="2016-06-06T17:09:48.110" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="6798" PostTypeId="1" CreationDate="2016-03-06T22:34:02.353" Score="6" ViewCount="1564" Body="&lt;p&gt;I found a &lt;a href=&quot;https://github.com/beloglazov/vim-online-thesaurus&quot; rel=&quot;noreferrer&quot;&gt;plugin&lt;/a&gt; that makes web calls to provide a thesaurus, and I also found &lt;a href=&quot;http://www.thegeekstuff.com/2008/12/vi-and-vim-editor-3-steps-to-enable-thesaurus-option/&quot; rel=&quot;noreferrer&quot;&gt;instructions&lt;/a&gt; to use thesaurus-files with Vim, but I wanted to ask if anyone knows if Vim comes with a thesaurus file? Where can we find a nice, mostly complete English thesaurus file, so that I don't need to use an internet-dependent plugin? I see no reason to use a local file on disk for this unless it is more than a few hundred megabytes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally I am exploring this topic because I discovered that the thesaurus helps a lot for creating sensible variable names. One day I chased a strange bug for a while and discovered by declaring &lt;code&gt;function process&lt;/code&gt; that I overwrote &lt;a href=&quot;https://nodejs.org/api/process.html#process_process&quot; rel=&quot;noreferrer&quot;&gt;this global variable&lt;/a&gt; and it broke the world. That was a nice little lesson and today I just tried to write another variable and name it process and it made me want to use a thesaurus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyhow, I digress. I am a programmer but having a thesaurus is a feature that word processor folks have had figured out for a while because I used it a lot in my middle school essay-writing days.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a potential wrinkle that I can foresee though. If a good proper thesaurus is really big, and if the Vim implementation is a bit naive it is possible that loading a big thesaurus file might bloat up the running Vim processes. I'd rather not do that and it may make sense to fall back to the online plugin depending on this. &lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="390" LastEditDate="2016-03-06T22:39:06.510" LastActivityDate="2016-03-06T22:43:00.483" Title="Vim has spellcheck; does it have thesaurus?" Tags="|thesaurus|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6799" PostTypeId="2" ParentId="6798" CreationDate="2016-03-06T22:43:00.483" Score="1" Body="&lt;p&gt;I thought about it and I think that this &lt;a href=&quot;https://stackoverflow.com/a/35680469/340947&quot;&gt;answer&lt;/a&gt; sufficiently addresses my concerns. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will use the web service and if it fails it will use a local mthesaur.txt fallback. It appears to provide a interface with sufficient usability. &lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-03-06T22:43:00.483" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6800" PostTypeId="1" AcceptedAnswerId="6801" CreationDate="2016-03-07T00:36:47.360" Score="3" ViewCount="387" Body="&lt;p&gt;I like to define some abbreviations like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cabbr csf cscope find&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought &lt;code&gt;cabbr&lt;/code&gt; would just be interpreted in the &lt;code&gt;:&lt;/code&gt; command line. However, when I entered the search mode &lt;code&gt;\&lt;/code&gt;, I found that &lt;code&gt;\csf&lt;/code&gt; would still be expanded to &lt;code&gt;\cscope find&lt;/code&gt;, which definitely was not what I want.&lt;br/&gt;&#xA;So how to deal with this situation? If I do want to search &lt;code&gt;csf&lt;/code&gt;, what should I do? Or there is another kind of abbreviation other than &lt;code&gt;cabbr&lt;/code&gt; intended to be valid just in the &lt;code&gt;:&lt;/code&gt; command line?&#xA;Thanks very much!&lt;/p&gt;&#xA;" OwnerUserId="4754" LastEditorUserId="51" LastEditDate="2016-03-07T01:39:47.577" LastActivityDate="2022-03-17T10:42:14.350" Title="cabbr definitions disturb searching in Vim" Tags="|command-line|abbreviations|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6801" PostTypeId="2" ParentId="6800" CreationDate="2016-03-07T01:39:29.470" Score="7" Body="&lt;p&gt;What you can do is use an expression abbreviation. This will allow you to use any Vim expression on the right-hand side, instead of just a static string. With &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getcmdtype%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;getcmdtype()&lt;/code&gt;&lt;/a&gt; we can check if we're doing a normal Ex command or something else.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cabbr &amp;lt;expr&amp;gt; csf getcmdtype() == ':' ? 'cscope find' : 'csf'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3amap%2d%3cexpr%3e&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :map-&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt; for the documentation.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-03-07T02:02:20.423" LastActivityDate="2016-03-07T02:02:20.423" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6802" PostTypeId="2" ParentId="6800" CreationDate="2016-03-07T02:43:35.770" Score="3" Body="&lt;p&gt;You could also define 2 custom commands &lt;code&gt;:Cab&lt;/code&gt; and &lt;code&gt;:Sab&lt;/code&gt; which would make the definition of such abbreviations easier.&lt;br&gt;&#xA;&lt;code&gt;:Cab&lt;/code&gt; would define an abbreviation which would only affect an Ex command, while &lt;code&gt;:Sab&lt;/code&gt; would only modify a search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code tries to define these commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ Cab call s:StrictAbbr(&amp;lt;q-args&amp;gt;, 1)&#xA;command! -nargs=+ Sab call s:StrictAbbr(&amp;lt;q-args&amp;gt;, 0)&#xA;&#xA;function! s:StrictAbbr(args, cmd) abort&#xA;    let l:lhs = matchstr(a:args, '^\s*\zs\S*')&#xA;    let l:rhs = matchstr(a:args, '^\s*\S*\s\+\zs.*')&#xA;    if a:cmd&#xA;        execute printf(&quot;cnoreabbrev &amp;lt;expr&amp;gt; %s getcmdtype() ==# ':' ? '%s' : '%s'&quot;, l:lhs, l:rhs, l:lhs)&#xA;    else&#xA;        execute printf(&quot;cnoreabbrev &amp;lt;expr&amp;gt; %s getcmdtype() =~ '[/?]' ? '%s' : '%s'&quot;, l:lhs, l:rhs, l:lhs)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now to define the abbreviation mentioned in your post, you could write :  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Cab csf cscope find&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And to define the abbreviation which transforms &lt;code&gt;fb&lt;/code&gt; in &lt;code&gt;foo bar&lt;/code&gt;, but only in a search:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sab fb foo bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These abbreviations could be written anywhere in your &lt;code&gt;vimrc&lt;/code&gt;, but only after the previous code, otherwise you'll have an error such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E492: Not an editor command: Sab fb foo bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code is heavily inspired from &lt;a href=&quot;http://vim.1045645.n5.nabble.com/How-to-disable-abbreviations-in-mode-tp5571590p5576487.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this post&lt;/a&gt; and from the accepted &lt;a href=&quot;https://vi.stackexchange.com/a/6801/4939&quot;&gt;answer&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-03-07T08:21:32.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6803" PostTypeId="1" CreationDate="2016-03-07T04:31:17.633" Score="3" ViewCount="1465" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7B5M4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7B5M4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to change the syntax highlighting in vimwiki in windows.&#xA;I could not properly see the line enclosed between [[some word]].&#xA;The same works well in Linux.&lt;/p&gt;&#xA;" OwnerUserId="6706" LastEditorUserId="51" LastEditDate="2016-03-07T07:07:33.073" LastActivityDate="2016-03-11T18:19:44.393" Title="Poor syntax highlighting in vimwiki (command prompt)" Tags="|syntax-highlighting|microsoft-windows|plugin-vimwiki|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6804" PostTypeId="1" CreationDate="2016-03-07T05:25:01.650" Score="4" ViewCount="380" Body="&lt;p&gt;Is there any way to display messages in vim depending on the &lt;code&gt;filetype&lt;/code&gt; being edited? It would be good if the messages pop after some specified time interval.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Use case&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We tend to forget style guide while editing files. Auto reminding would be a great feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that auto reminding is not possible hence, it would be good if those messages could be shown on each write.&lt;/p&gt;&#xA;" OwnerUserId="6074" LastEditorUserId="6074" LastEditDate="2016-03-07T08:03:32.577" LastActivityDate="2016-03-07T19:45:32.183" Title="How to display messages for a particular file type?" Tags="|vimscript|filetype|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6805" PostTypeId="1" AcceptedAnswerId="6806" CreationDate="2016-03-07T09:56:47.173" Score="3" ViewCount="1977" Body="&lt;p&gt;N.B. my question title might be poor, so feel free to improve it.&lt;/p&gt;&#xA;&lt;h2&gt;Background&lt;/h2&gt;&#xA;&lt;p&gt;I want to write a command to move my cursor to the body of my email, add blank lines, and change to insert mode. Previously, I used the following for &lt;strong&gt;new emails&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gb &amp;lt;C-Home&amp;gt;/^$&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;mutt&lt;/code&gt; would create a new email in &lt;code&gt;vim&lt;/code&gt;, then I'd press &lt;code&gt;gb&lt;/code&gt;. The cursor would move to the top of the email (&lt;code&gt;&amp;lt;C-Home&amp;gt;&lt;/code&gt;), find the first blank line and immediately stop highlighting (&lt;code&gt;/^$&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;&lt;/code&gt;), create a new line and start editing a new line (&lt;code&gt;o&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;However, I often &lt;strong&gt;reply to an email&lt;/strong&gt;, and I wanted to automatically create another &amp;quot;buffer&amp;quot; empty line below my cursor position. Hence, I changed the command to this following.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gb &amp;lt;C-Home&amp;gt;/^$&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;o&amp;lt;Esc&amp;gt;ko&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This would do as above, then get into normal mode &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, move up (&lt;code&gt;k&lt;/code&gt;), and create another new line to edit &lt;code&gt;o&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Conditional&lt;/h2&gt;&#xA;&lt;p&gt;I wanted to create a conditional. After searching for the first blank line (&lt;code&gt;&amp;lt;C-Home&amp;gt;/^$&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;&lt;/code&gt;), if this were the last line of the email, I'd be editing a new email, so just &lt;code&gt;o&lt;/code&gt;. Otherwise, I'd be replying, so &lt;code&gt;o&amp;lt;Esc&amp;gt;ko&lt;/code&gt;. The following doesn't work, because I've mangled together different syntaxes, but it should give an idea of what I want.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gb &amp;lt;C-Home&amp;gt;/^$&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;|if line('.') != line('$')|o&amp;lt;Esc&amp;gt;k|endif|o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I suspect &lt;code&gt;nnoremap &amp;lt;expr&amp;gt; gb ...&lt;/code&gt; is useful, but I'm not sure how to use it.&lt;/p&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-03-07T20:54:49.157" Title="How can I convert this remap to a &lt;expr&gt;?" Tags="|vimscript|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6806" PostTypeId="2" ParentId="6805" CreationDate="2016-03-07T10:33:17.207" Score="4" Body="&lt;p&gt;There you go, I'm not sure to have understood perfectly your use case, bu you can add your workflow to this example :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Mail()&#xA;  normal! gg&#xA;  call search('^$')&#xA;  nohlsearch&#xA;  if line('.') != line('$')&#xA;    normal! o&#xA;    normal! k&#xA;  endif&#xA;  normal! o&#xA;  startinsert&#xA;endfunction&#xA;&#xA;nnoremap gb :call Mail()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you can execute &lt;code&gt;normal!&lt;/code&gt; to prevent mapping to be used.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-03-07T20:54:49.157" LastActivityDate="2016-03-07T20:54:49.157" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6807" PostTypeId="2" ParentId="6804" CreationDate="2016-03-07T13:06:49.207" Score="4" Body="&lt;p&gt;&lt;strong&gt;Important disclaimer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This answer is mostly here for educational purposes: I wouldn't recommend to use the functions shown here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @Carpetsmoker pointed at it in the comments and in his answer, this kind of reminder can be pretty harmful for a developer and other solutions exists to check code guidelines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said the functions were fun to create and someone might use the code as inspiration to do something else&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trigger a function each time a buffer is written, if the filetype correspond to a predefined list, then a message to remind you to follow guidelines is prompted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RemindGuideLine()&#xA;    &quot; Echo a reminder only for these filetypes&#xA;    if &amp;amp;ft =~ 'vim\|txt\|java'&#xA;        echo &quot;Remember to follow the corporate guide lines&quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;autocmd BufWritePre * call RemindGuideLine()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;autocmd&lt;/code&gt; calls the function each time a buffer is written and the function checks the filetype and show a message if needed.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is inspired by the answer linked by Nobe4 in the comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the autocmd event &lt;code&gt;CursorHold&lt;/code&gt;, a function is called after a time of user inactivity. This function checks the amount of time since the last time it was called. If this delta of time is big enough and the filetype matches a predefined list, then a message is echoed. After a defined amount of echoed messages, the function stop giving reminders.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Call the function when the user doesn't press a key for some time&#xA;au CursorHold * call RemindGuideLine()&#xA;&#xA;&quot; When a buffer is opened, set a variable indicating the time it was opened on&#xA;au BufRead,BufNewFile * let b:save_time = localtime()&#xA;&quot; Also set a variable indicating the number of reminders to show&#xA;au BufRead,BufNewFile * let b:numberOfReminders = 3&#xA;&#xA;&quot; Set the minimum time to wait between 2 reminders&#xA;let g:remindTime = 10&#xA;&#xA;function! RemindGuideLine()&#xA;    &quot; Echo a reminder only for these filetypes&#xA;    if &amp;amp;ft =~ 'vim\|txt\|java'&#xA;        &quot; If we waited long enough and we haven't show the max number of reminders&#xA;        if((localtime() - b:start_time) &amp;gt;= g:remindTime &amp;amp;&amp;amp; b:numberOfReminders &amp;gt; 0)&#xA;            let b:start_time = localtime()&#xA;            let b:numberOfReminders = b:numberOfReminders - 1&#xA;            echo &quot;Remember to follow the corporate guide lines&quot; . b:numberOfReminders&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As the comments in the code says, the function is called when the user doesn't press any key for some time (&lt;em&gt;it is probably the best event to trigger to avoid spamming the user&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change the number of time the reminder will be prompted to you and the minimum time between the prompts with &lt;code&gt;let b:numberOfReminders&lt;/code&gt; and &lt;code&gt;let g:remindTime&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the function checks the filetype, the time since the last reminder and the number of reminders left and prompts a new one if necessary.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And to give to Caesar what belongs to Caesar, here as some links:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/6991712/4194289&quot;&gt;An answer&lt;/a&gt; linked by Nobe4 I used to create the second solution.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/6496995/4194289&quot;&gt;Another answer&lt;/a&gt; which inspired me the first solution.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocmd-events&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h autocmd-events&lt;/code&gt;&lt;/a&gt; to customize the &lt;code&gt;autocmd&lt;/code&gt;. I think &lt;code&gt;CursorHold&lt;/code&gt; is the best event to use in this case, but one might want to change that for reasons.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-03-07T19:45:32.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6809" PostTypeId="2" ParentId="6804" CreationDate="2016-03-07T18:46:16.183" Score="4" Body="&lt;p&gt;This is not really a &quot;Vim answer&quot;, but it is in my humble opinion the &quot;&lt;em&gt;correct&lt;/em&gt; answer&quot;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;We tend to forget style guide while editing files. Auto reminding would be a great feature.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So how would this work? Every five minutes you get a message with &quot;hey, don't forget to use the style guide&quot;? Is this really helpful? Because to me it sounds like:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;It distracts the programmer from whatever she's working on right now. Programming is hard and requires a lot of short-term memory. Distractions erase part of that short-term memory and it'll take time to &quot;catch up&quot; again.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;People are not going to keep paying attention to messages shown regularly. They tend to ignore those. you could make the messages more &quot;in your face&quot;, but that would only increase problem 1.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you absolutely &lt;em&gt;must&lt;/em&gt; do something from within Vim, then use &lt;a href=&quot;https://github.com/scrooloose/syntastic&quot; rel=&quot;nofollow noreferrer&quot;&gt;syntastic&lt;/a&gt;. This allows you to run automated syntax and style checkers whenever you write the file to disk with &lt;code&gt;:w&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Syntastic is a great plugin for checking syntax &lt;em&gt;errors&lt;/em&gt; as it allows quick feedback on typos and other errors that really &lt;em&gt;do&lt;/em&gt; &lt;em&gt;need&lt;/em&gt; to be fixed &lt;em&gt;right now&lt;/em&gt; to allow the code to run, but I feel that it's &lt;em&gt;harmful&lt;/em&gt; for notifications of style errors for the same reason as above: it breaks the concentration on the actual important and hard parts of programming. Is it &lt;em&gt;really&lt;/em&gt; important that that space gets fixed &lt;strong&gt;now&lt;/strong&gt;? I would say not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I joked about the &lt;a href=&quot;https://en.wikipedia.org/wiki/Office_Assistant&quot; rel=&quot;nofollow noreferrer&quot;&gt;clippy&lt;/a&gt; program in the comments. It was wildly perceived as spectacularly annoying precisely because it distracted people's concentration from the actual important task at hand (such as writing a letter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;best&lt;/em&gt; way to fix this is to set a pre-commit hook in your version control system (mercurial, git, subversion, SCCS, whatever. You &lt;em&gt;are&lt;/em&gt; using one, right?) That way the flow of operations is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Programming receives task.&lt;/li&gt;&#xA;&lt;li&gt;Programmer works to fix the task.&lt;/li&gt;&#xA;&lt;li&gt;A tester or programmer discovers bugs, works until they're fixed.&lt;/li&gt;&#xA;&lt;li&gt;Programmer fixes some &quot;lint&quot; such as style errors.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That way, there is a &quot;separation&quot; between the actual programming (step 2) and fixing the style errors (step 4) in such a way that doesn't distract from the actual important and hard task at hand (step 2).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, such a pre-commit hook only checks for errors when committing to the main branch(es) and not individual &quot;private&quot; branches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If setting this up is too much work for now, then just run the tools from the commandline. Setting up a notification to do so with a pre-commit hook is easy, although the &quot;people tend to ignore repeated warnings&quot; still applies here (but you could perhaps echo it in red and have it wait for ten seconds or some such).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, perhaps you should reconsider your &quot;style guide&quot;. I have seen some style guides that dwarf several Bible books and contain all sorts of pedantic details. There are a few truly important things everyone should agree on, but other than that I find that it doesn't really aid much in readability (and slavish obedience to style guides for the sake of it may even &lt;em&gt;harm&lt;/em&gt; readability in some cases).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This answer summarized in a cartoon:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/gbruJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gbruJ.png&quot; alt=&quot;This answer summarized in a cartoon&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-03-07T18:51:44.747" LastActivityDate="2016-03-07T18:51:44.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6810" PostTypeId="2" ParentId="6803" CreationDate="2016-03-07T20:39:40.903" Score="5" Body="&lt;p&gt;I think this is because Windows' cmd.exe has very limited support for colours; you can only use 16, and those 16 are different from what Unix terminals use (which mostly support at least 256 colours nowadays).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest solution is to just use Gvim. Windows is not designed to be used from the commandline, and doesn't really support it very well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change the colours with the &lt;code&gt;highlight&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First figure out which syntax highlight group is being used by going to the highlighted word with the cursor and:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 1), &quot;name&quot;)`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should give you a name such as &lt;code&gt;pythonConditional&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When using &lt;code&gt;:highlight pythonConditional&lt;/code&gt; you can see the attributes set for this as well as a short preview. In the case of &lt;code&gt;pythonConditional&lt;/code&gt; it links to another highlight group: &lt;code&gt;Conditional&lt;/code&gt;, which links to &lt;code&gt;Statement&lt;/code&gt;, which looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Statement      xxx term=bold ctermfg=3 gui=bold guifg=Brown&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;By using &lt;code&gt;:highlight pythonConditional &amp;lt;attributes&amp;gt;&lt;/code&gt; we can set attributes. For example &lt;code&gt;:highlight pythonConditional ctermfg=red&lt;/code&gt; would make the text red.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To make these changes permanent you need to add them to your vimrc file; but to make sure that it's not override by a filetype or colorscheme command, you'll typically want to do this in an &lt;code&gt;autocmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType python highlight pythonConditional ctermbg=green guibg=green&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also see the Vim documentation at &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3ahighlight&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :highlight&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#%3aautocmd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :autocmd&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-03-07T20:39:40.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6811" PostTypeId="2" ParentId="6785" CreationDate="2016-03-07T21:56:09.410" Score="3" Body="&lt;p&gt;&lt;a href=&quot;http://manpages.ubuntu.com/manpages/precise/man1/apt-file.1.html&quot; rel=&quot;nofollow&quot;&gt;apt-file&lt;/a&gt; can do it. To install use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apt-get install apt-file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apt-file list vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://manpages.ubuntu.com/manpages/precise/man1/apt-file.1.html&quot; rel=&quot;nofollow&quot;&gt;apt-file&lt;/a&gt; lists file names in all packages, whether they are installed or not.&lt;/p&gt;&#xA;" OwnerUserId="177" LastActivityDate="2016-03-07T21:56:09.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6812" PostTypeId="1" AcceptedAnswerId="6813" CreationDate="2016-03-07T23:19:36.090" Score="2" ViewCount="2075" Body="&lt;p&gt;Suppose I have a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class X(arg):&#xA;\t#blabbla&#xA;\tdef fun1(arg):&#xA;\t\tsome code&#xA;\n&#xA;\tdef fun2(arg):&#xA;\t\tsome code&#xA;\n&#xA;class A(arg):&#xA;\t#blabbla&#xA;\tdef fun0(arg):&#xA;\t\tsome code&#xA;\n&#xA;\tdef fun3(arg):&#xA;\t\tsome code&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I wish to copy all lines start with &lt;code&gt;class&lt;/code&gt; and &lt;code&gt;\tdef&lt;/code&gt;, and paste them to the end of file preserving the order, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class X(arg):&#xA;\tdef fun1(arg):&#xA;\tdef fun2(arg):&#xA;class A(arg):&#xA;\tdef fun0(arg):&#xA;\tdef fun3(arg):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I achieve that without using extra plug-ins? (\t is tab, \n is new line)&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="51" LastEditDate="2016-03-08T00:02:05.327" LastActivityDate="2016-03-08T04:26:45.480" Title="How to copy multiple lines and paste at the end of a file" Tags="|cut-copy-paste|multiple-lines|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6813" PostTypeId="2" ParentId="6812" CreationDate="2016-03-07T23:35:39.880" Score="3" Body="&lt;p&gt;Depending on what you want to perform (copy and paste or cut and paste), you could try one of the 2 following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\v^(class|\tdef)/t$&#xA;:g/\v^(class|\tdef)/m$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To duplicate (copy and paste) the current line after the last one, you can use the &lt;code&gt;:t&lt;/code&gt; command: &lt;code&gt;:t$&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like most Ex commands &lt;code&gt;:t&lt;/code&gt; can be prefixed with an optional range, and like most Ex commands, when you don't give one, the current line is assumed.&#xA;So &lt;code&gt;:t$&lt;/code&gt; is the same as &lt;code&gt;:.t$&lt;/code&gt; or &lt;code&gt;:.,.t$&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:t&lt;/code&gt; command must be followed by a line address which is the number of the line after which the duplicated lines must be pasted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With these 2 informations, you can perform an arbitrary duplication, such as: &lt;code&gt;:5,10t42&lt;/code&gt;&lt;br&gt;&#xA;Copy the lines between &lt;code&gt;5&lt;/code&gt; and &lt;code&gt;10&lt;/code&gt; and paste them below the line &lt;code&gt;42&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you express a line address, there are some useful symbols (called specifiers by the help) such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.      current line&#xA;$      last line&#xA;'x     line where the mark x has been last set&#xA;/foo/  next line where foo is found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :range&lt;/code&gt; for a comprehensive list of specifiers.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To move (cut and paste) the current line after the last one, you can use the &lt;code&gt;:move&lt;/code&gt; command: &lt;code&gt;:m$&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In your question, you want to repeat the same command &lt;code&gt;:t$&lt;/code&gt; or &lt;code&gt;:m$&lt;/code&gt; on a set of lines where the same pattern can be found.&#xA;Usually, this is a job for the global command &lt;code&gt;:g&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you could use the command: &lt;code&gt;:g/pattern/t$&lt;/code&gt; or &lt;code&gt;:g/pattern/m$&lt;/code&gt;&lt;br&gt;&#xA;It would execute &lt;code&gt;:t$&lt;/code&gt; or &lt;code&gt;:m$&lt;/code&gt; on every line where &lt;code&gt;pattern&lt;/code&gt; is found.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides, you want to operate on all the lines which begin with the word &lt;code&gt;class&lt;/code&gt;, or with a hard tab followed by the word &lt;code&gt;def&lt;/code&gt;.&lt;br&gt;&#xA;In a regex, it could be expressed like this: &lt;code&gt;\v^(class|\tdef)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, the command &lt;code&gt;:g/pattern/t$&lt;/code&gt; should be rewritten, like this: &lt;code&gt;:g/\v^(class|\tdef)/t$&lt;/code&gt;&lt;br&gt;&#xA;And &lt;code&gt;:g/pattern/m$&lt;/code&gt; like this: &lt;code&gt;:g/\v^(class|\tdef)/m$&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you execute the first command on your buffer, here's the transformation you should get (assuming there's an empty line at the end):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class X(arg):               class X(arg):     &#xA;    #blabbla                    #blabbla      &#xA;    def fun1(arg):              def fun1(arg):&#xA;        some code                   some code &#xA;&#xA;    def fun2(arg):              def fun2(arg):&#xA;        some code                   some code &#xA;&#xA;class A(arg):         ==&amp;gt;   class A(arg):     &#xA;    #blabbla                    #blabbla      &#xA;    def fun0(arg):              def fun0(arg):&#xA;        some code                   some code &#xA;&#xA;    def fun3(arg):              def fun3(arg):&#xA;        some code                   some code &#xA;&#xA;                            class X(arg):     &#xA;                                def fun1(arg):&#xA;                                def fun2(arg):&#xA;                            class A(arg):     &#xA;                                def fun0(arg):&#xA;                                def fun3(arg):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;More generally, when you want to copy or cut a set of lines and paste them at the end of your buffer, you can follow a 2-steps process:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;progressively build a search pattern until your search matches the desired lines&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;:g//t$&lt;/code&gt; or &lt;code&gt;:g//m$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It works because, when you don't supply a pattern to the global or substitute command, they reuse the last search (the one in the search register &lt;code&gt;:reg /&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :global&#xA;:help :t (or :copy)&#xA;:help :move&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-03-08T04:26:45.480" LastActivityDate="2016-03-08T04:26:45.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6814" PostTypeId="1" AcceptedAnswerId="6816" CreationDate="2016-03-08T05:27:44.593" Score="4" ViewCount="397" Body="&lt;p&gt;Sometimes I want to autocomplete a tag name containing a colon, for example &lt;code&gt;g:netrw_gx&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've added to the &lt;code&gt;'tags'&lt;/code&gt; option the location of the &lt;code&gt;tags&lt;/code&gt; file of the main documentation (which on my machine seems to be &lt;code&gt;/usr/share/vim/vim74/doc/tags&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tags+=$VIMRUNTIME/doc/tags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default mapping to autocomplete a tag name is &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is if I type &lt;code&gt;g:net&lt;/code&gt; and then hit &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;, Vim decides that the tag name begins after the colon, so the candidates which are suggested in the pop-up menu all begin with &lt;code&gt;net&lt;/code&gt;, while I want candidates beginning with &lt;code&gt;g:net&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the reason for this is given in an excerpt from &lt;code&gt;:h ctrl-x_ctrl-]&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            Alphabetic characters and characters in 'iskeyword' are used&#xA;            to decide which characters are included in the tag&#xA;            name (same as for a keyword).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When looking for the tag name to complete, Vim takes probably all the characters from the cursor position back to the first character which is not in the &lt;code&gt;'iskeyword'&lt;/code&gt; option.&lt;br&gt;&#xA;And a colon is not in &lt;code&gt;'isk'&lt;/code&gt;, as the output of &lt;code&gt;:echo &amp;amp;isk&lt;/code&gt; is &lt;code&gt;@,48-57,_,192-255,#&lt;/code&gt; which doesn't contain &lt;code&gt;:&lt;/code&gt; or &lt;code&gt;58&lt;/code&gt; (ascii code of &lt;code&gt;:&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to change the value of &lt;code&gt;'isk'&lt;/code&gt; as I suspect it would break many things (text-objects, plugins).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I autocomplete tag names containing a colon?&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-03-08T06:08:45.793" LastActivityDate="2016-03-08T11:12:48.563" Title="How to autocomplete tag names containing a colon?" Tags="|key-bindings|autocompletion|tags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6815" PostTypeId="1" CreationDate="2016-03-08T11:02:36.763" Score="12" ViewCount="861" Body="&lt;p&gt;I am often writing documents in &lt;a href=&quot;http://yihui.name/knitr/&quot;&gt;knitr&lt;/a&gt; using vim, which means that I have markdown code mixed with R code. I would like to have R syntax coloring on R chunks, but markdown or no coloring on all the other fragments. Is this doable? How?&lt;/p&gt;&#xA;" OwnerUserId="6718" LastActivityDate="2017-10-10T09:51:49.660" Title="Mixed color syntax in vim" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6816" PostTypeId="2" ParentId="6814" CreationDate="2016-03-08T11:12:48.563" Score="3" Body="&lt;p&gt;I understand that you prefer to avoid changing &lt;code&gt;'isk'&lt;/code&gt; &lt;em&gt;permanently&lt;/em&gt;, but what about changing it during the autocompletion?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomComplTag()&#xA;   setlocal isk+=:&#xA;   call feedkeys(&quot;\&amp;lt;c-x&amp;gt;\&amp;lt;c-]&amp;gt;&quot;, &quot;n&quot;)&#xA;endfunction&#xA;augroup CustomComplTagAutcmd&#xA;   au!&#xA;   autocmd CompleteDone * setlocal isk-=:&#xA;augroup END&#xA;&#xA;inoremap &amp;lt;C-x&amp;gt;&amp;lt;C-]&amp;gt; &amp;lt;C-o&amp;gt;:call CustomComplTag()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also check the plugins that use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3914&quot; rel=&quot;nofollow&quot;&gt;&quot;CompleteHelper : Generic functions to support custom insert mode completions&quot;&lt;/a&gt;, maybe one of them does what you want, or is close enough so you can write a patch.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-03-08T11:12:48.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6817" PostTypeId="1" AcceptedAnswerId="6818" CreationDate="2016-03-08T11:19:56.643" Score="5" ViewCount="113" Body="&lt;p&gt;Say I have a list of strings in my code, for example : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var array = [&#xA;    &quot;foo&quot;,&#xA;    &quot;bar&quot;,&#xA;    &quot;John&quot;,&#xA;    &quot;Doe&quot;,&#xA;    &quot;Mary&quot;&#xA;];&#xA;&#xA;test(&quot;foo&quot;);&#xA;test(&quot;bar&quot;, &quot;Doe&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Those strings are repeated at the bottom of the file, without any particular structure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to be able to know which strings are only there once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in the case above, the strings &quot;Mary&quot; and &quot;John&quot; should be highlighted, as they only appear once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be even better if you could explain the different steps, especially before/after the highlight, it would be best if we could have the list of unique words in a vimscript variable, so that we could do more than just highlight them (for example delete them)&lt;/p&gt;&#xA;" OwnerUserId="1543" LastActivityDate="2016-03-08T14:11:03.260" Title="Highlight words with no other occurence in file" Tags="|search|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6818" PostTypeId="2" ParentId="6817" CreationDate="2016-03-08T12:32:17.150" Score="7" Body="&lt;p&gt;The following code defines the command &lt;code&gt;:UniqueWords&lt;/code&gt; which tries to do what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! UniqueWords call UniqueWords()&#xA;&#xA;function! UniqueWords() abort&#xA;    let words = []&#xA;    silent! %s/&quot;\zs\w\{-}\ze&quot;/\=add(words, submatch(0))/gn&#xA;    let dic = {}&#xA;    let uniq_words = uniq(sort(copy(words)))&#xA;    for i in range(len(uniq_words))&#xA;        if uniq_words[i] != ''&#xA;            call extend(dic, {uniq_words[i]: count(words, uniq_words[i])})&#xA;        endif&#xA;    endfor&#xA;    call filter(dic, 'v:val == 1')&#xA;    let pattern = join(keys(dic), '\|')&#xA;    silent! execute 'match SpellBad /' . pattern . '/'&#xA;    return [keys(dic), pattern]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The command calls the &lt;code&gt;UniqueWords()&lt;/code&gt; function which does the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let words = []&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Define the empty list &lt;code&gt;words&lt;/code&gt; whose purpose will be to contain all the words surrounded by double quotes in your current buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! %s/&quot;\zs\w\{-}\ze&quot;/\=add(words, submatch(0))/gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Call the substitute command &lt;code&gt;:s&lt;/code&gt; to look for the pattern &lt;code&gt;&quot;\zs\w\{-}\ze&quot;&lt;/code&gt; (word characters between 2 consecutive double quotes). Whenever such a text is found it's added to the &lt;code&gt;words&lt;/code&gt; list, but without actually performing any substitution thanks to the &lt;code&gt;n&lt;/code&gt; flag.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let dic = {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Define an empty dictionary, whose purpose will be to contain all your quoted words as well as the number of times they appear.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let uniq_words = uniq(sort(copy(words)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Define the list &lt;code&gt;uniq_words&lt;/code&gt; which again contains all the words, but this time the list is sorted with the &lt;code&gt;sort()&lt;/code&gt; function, and the duplicates are removed with the &lt;code&gt;uniq()&lt;/code&gt; function. A copy of &lt;code&gt;words&lt;/code&gt; is also made, so that the latter is not altered in the process.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(len(uniq_words))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Begin a loop which iterates over the words in &lt;code&gt;uniq_words&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    call extend(dic, {uniq_words[i]: count(words, uniq_words[i])})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add a new item to the dictionary &lt;code&gt;dic&lt;/code&gt;, whose key is a word from &lt;code&gt;uniq_words&lt;/code&gt; (&lt;code&gt;uniq_words[i]&lt;/code&gt;) and whose value is the number of times it appears (&lt;code&gt;count(words, uniq_words[i])&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call filter(dic, 'v:val == 1')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Remove all the items from &lt;code&gt;dic&lt;/code&gt; whose values are different than one, because you're only interested in words which appear once.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let pattern = join(keys(dic), '\|')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Build a pattern by joining all the keys from &lt;code&gt;dic&lt;/code&gt; and separating them with &lt;code&gt;\|&lt;/code&gt; (that's how you separate two branches, see &lt;code&gt;:h /bar&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! execute 'match SpellBad /' . pattern . '/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Highlight the words which appear inside &lt;code&gt;pattern&lt;/code&gt; with the highlighting group &lt;code&gt;SpellBad&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return [keys(dic), pattern]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Return the keys from &lt;code&gt;dic&lt;/code&gt;, so that you can access them through a list, as well as the pattern so that you can use it later in a substitute command.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to see the list, you could type: &lt;code&gt;:echo UniqueWords()[0]&lt;/code&gt;&lt;br&gt;&#xA;And to remove the words which appear only once, you could type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe '%s/' . UniqueWords()[1] . '//g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :command&#xA;:help add()&#xA;:help copy()&#xA;:help sort()&#xA;:help uniq()&#xA;:help len()&#xA;:help range()&#xA;:help count()&#xA;:help extend()&#xA;:help filter()&#xA;:help keys()&#xA;:help join()&#xA;:help :match&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="51" LastEditDate="2016-03-08T14:11:03.260" LastActivityDate="2016-03-08T14:11:03.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6819" PostTypeId="1" AcceptedAnswerId="6849" CreationDate="2016-03-08T19:39:34.913" Score="2" ViewCount="921" Body="&lt;p&gt;I am currently learning OpenGL and C++ and I would like to have gl* completion ready on my C++ projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;YCM is not scanning the &lt;code&gt;&amp;lt;GL/glew.h&amp;gt;&lt;/code&gt; header when I include it - isn't it supposed to do it by default? That's how I understood it to work in the first place - maybe I'm wrong here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using following default global YCM config file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Generated by YCM Generator at 2016-03-06 01:49:19.854235&#xA;&#xA;# This file is NOT licensed under the GPLv3, which is the license for the rest&#xA;# of YouCompleteMe.&#xA;#&#xA;# Here's the license text for this file:&#xA;#&#xA;# This is free and unencumbered software released into the public domain.&#xA;#&#xA;# Anyone is free to copy, modify, publish, use, compile, sell, or&#xA;# distribute this software, either in source code form or as a compiled&#xA;# binary, for any purpose, commercial or non-commercial, and by any&#xA;# means.&#xA;#&#xA;# In jurisdictions that recognize copyright laws, the author or authors&#xA;# of this software dedicate any and all copyright interest in the&#xA;# software to the public domain. We make this dedication for the benefit&#xA;# of the public at large and to the detriment of our heirs and&#xA;# successors. We intend this dedication to be an overt act of&#xA;# relinquishment in perpetuity of all present and future rights to this&#xA;# software under copyright law.&#xA;#&#xA;# THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,&#xA;# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF&#xA;# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.&#xA;# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR&#xA;# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,&#xA;# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR&#xA;# OTHER DEALINGS IN THE SOFTWARE.&#xA;#&#xA;# For more information, please refer to &amp;lt;http://unlicense.org/&amp;gt;&#xA;&#xA;import os&#xA;import ycm_core&#xA;&#xA;flags = [&#xA;    '-x',&#xA;    'c++',&#xA;    '-std=c++11',&#xA;    '-isystem', '/usr/include',&#xA;    '-isystem', '/usr/local/include',&#xA;    '-I', 'src',&#xA;    '-I', 'include'&#xA;]&#xA;&#xA;&#xA;# Set this to the absolute path to the folder (NOT the file!) containing the&#xA;# compile_commands.json file to use that instead of 'flags'. See here for&#xA;# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html&#xA;#&#xA;# You can get CMake to generate this file for you by adding:&#xA;#   set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )&#xA;# to your CMakeLists.txt file.&#xA;#&#xA;# Most projects will NOT need to set this to anything; you can just change the&#xA;# 'flags' list of compilation flags. Notice that YCM itself uses that approach.&#xA;compilation_database_folder = ''&#xA;&#xA;if os.path.exists( compilation_database_folder ):&#xA;  database = ycm_core.CompilationDatabase( compilation_database_folder )&#xA;else:&#xA;  database = None&#xA;&#xA;SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]&#xA;&#xA;def DirectoryOfThisScript():&#xA;  return os.path.dirname( os.path.abspath( __file__ ) )&#xA;&#xA;&#xA;def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):&#xA;  if not working_directory:&#xA;    return list( flags )&#xA;  new_flags = []&#xA;  make_next_absolute = False&#xA;  path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]&#xA;  for flag in flags:&#xA;    new_flag = flag&#xA;&#xA;    if make_next_absolute:&#xA;      make_next_absolute = False&#xA;      if not flag.startswith( '/' ):&#xA;        new_flag = os.path.join( working_directory, flag )&#xA;&#xA;    for path_flag in path_flags:&#xA;      if flag == path_flag:&#xA;        make_next_absolute = True&#xA;        break&#xA;&#xA;      if flag.startswith( path_flag ):&#xA;        path = flag[ len( path_flag ): ]&#xA;        new_flag = path_flag + os.path.join( working_directory, path )&#xA;        break&#xA;&#xA;    if new_flag:&#xA;      new_flags.append( new_flag )&#xA;  return new_flags&#xA;&#xA;&#xA;def IsHeaderFile( filename ):&#xA;  extension = os.path.splitext( filename )[ 1 ]&#xA;  return extension in [ '.h', '.hxx', '.hpp', '.hh' ]&#xA;&#xA;&#xA;def GetCompilationInfoForFile( filename ):&#xA;  # The compilation_commands.json file generated by CMake does not have entries&#xA;  # for header files. So we do our best by asking the db for flags for a&#xA;  # corresponding source file, if any. If one exists, the flags for that file&#xA;  # should be good enough.&#xA;  if IsHeaderFile( filename ):&#xA;    basename = os.path.splitext( filename )[ 0 ]&#xA;    for extension in SOURCE_EXTENSIONS:&#xA;      replacement_file = basename + extension&#xA;      if os.path.exists( replacement_file ):&#xA;        compilation_info = database.GetCompilationInfoForFile(&#xA;          replacement_file )&#xA;        if compilation_info.compiler_flags_:&#xA;          return compilation_info&#xA;    return None&#xA;  return database.GetCompilationInfoForFile( filename )&#xA;&#xA;&#xA;def FlagsForFile( filename, **kwargs ):&#xA;  if database:&#xA;    # Bear in mind that compilation_info.compiler_flags_ does NOT return a&#xA;    # python list, but a &quot;list-like&quot; StringVec object&#xA;    compilation_info = GetCompilationInfoForFile( filename )&#xA;    if not compilation_info:&#xA;      return None&#xA;&#xA;    final_flags = MakeRelativePathsInFlagsAbsolute(&#xA;      compilation_info.compiler_flags_,&#xA;      compilation_info.compiler_working_dir_ )&#xA;&#xA;  else:&#xA;    relative_to = DirectoryOfThisScript()&#xA;    final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )&#xA;&#xA;  return {&#xA;    'flags': final_flags,&#xA;    'do_cache': True&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not very good at Python, though, and have not enough knowledge of compiler settings to configure this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make YCM to give me OpenGL completions in my case?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I think this option &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe#the-gycm_semantic_triggers-option&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Valloric/YouCompleteMe#the-gycm_semantic_triggers-option&lt;/a&gt; may have something to do with it, but I haven't managed to find the solution yet.&lt;/p&gt;&#xA;" OwnerUserId="6724" LastEditorUserId="6724" LastEditDate="2016-03-08T23:26:29.907" LastActivityDate="2016-03-12T01:56:09.833" Title="How to make YCM load &lt;GL/glew.h&gt; by default?" Tags="|autocompletion|plugin-you-complete-me|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6820" PostTypeId="1" AcceptedAnswerId="6847" CreationDate="2016-03-09T04:58:20.857" Score="0" ViewCount="1282" Body="&lt;p&gt;For example, if my path is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;C:\Program Files (x86)\Vim&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And I want it to be:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;C:\Users\~\Documents\Vim&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How do I do that so I will still be able to call &quot;gvim&quot; on CMD, for example?&lt;/p&gt;&#xA;" OwnerUserId="6728" LastEditorUserId="67" LastEditDate="2016-03-09T12:51:10.633" LastActivityDate="2016-03-11T17:00:09.213" Title="I want to change where the Vim folder is located" Tags="|microsoft-windows|installing|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6821" PostTypeId="1" AcceptedAnswerId="6965" CreationDate="2016-03-09T21:40:39.933" Score="6" ViewCount="406" Body="&lt;p&gt;I have mapped &lt;code&gt;[]&lt;/code&gt; and &lt;code&gt;{}&lt;/code&gt; on my German keyboard with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap Ö {&#xA;nmap Ä }&#xA;nmap ö [&#xA;nmap ä ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but if I try, for example, to delete inside &lt;code&gt;{}&lt;/code&gt; with &lt;code&gt;di}&lt;/code&gt; it won't delete.&#xA;It also fails with &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt; (for example, &lt;code&gt;f}&lt;/code&gt; and &lt;code&gt;t}&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone tell me if there is an additional map command for such operations?&lt;/p&gt;&#xA;" OwnerUserId="6710" LastEditorUserId="205" LastEditDate="2016-03-10T00:48:29.017" LastActivityDate="2016-03-21T16:43:17.203" Title="Umlaut accented keys won't work for text objects" Tags="|key-bindings|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6822" PostTypeId="2" ParentId="6821" CreationDate="2016-03-10T00:37:53.513" Score="5" Body="&lt;p&gt;I think you will be glad to have a look at &lt;code&gt;:help omap-info&lt;/code&gt;. You can specify mappings for exactly this case, when a text object or movement is expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you want text-objects, rather than movements, i guess you have to use these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap iö i[&#xA;vnoremap iö i[&#xA;onoremap aö a[&#xA;vnoremap aö a[&#xA;&#xA;onoremap iä i[&#xA;vnoremap iä i[&#xA;onoremap aä a[&#xA;vnoremap aä a[&#xA;&#xA;onoremap iÖ i{&#xA;vnoremap iÖ i{&#xA;onoremap aÖ a{&#xA;vnoremap aÖ a{&#xA;&#xA;onoremap iÄ i{&#xA;vnoremap iÄ i{&#xA;onoremap aÄ a{&#xA;vnoremap aÄ a{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As @VanLaser pointed out, the &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt; take commands take characters, not movements or text objects. I just learned about &lt;code&gt;:lmap&lt;/code&gt; and &lt;code&gt;language-mapping&lt;/code&gt; myself, but could not get it to work. A brainless workaround would be this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap tö t[&#xA;nnoremap fö f[&#xA;nnoremap tä t]&#xA;nnoremap fä f]&#xA;&#xA;nnoremap Tö T[&#xA;nnoremap Fö F[&#xA;nnoremap Tä T]&#xA;nnoremap Fä F]&#xA;&#xA;nnoremap tÖ t{&#xA;nnoremap fÖ f{&#xA;nnoremap tÄ t}&#xA;nnoremap fÄ f}&#xA;&#xA;nnoremap TÖ T{&#xA;nnoremap FÖ F{&#xA;nnoremap TÄ T}&#xA;nnoremap FÄ F}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6495" LastEditorUserId="6495" LastEditDate="2016-03-13T00:04:38.497" LastActivityDate="2016-03-13T00:04:38.497" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6823" PostTypeId="1" AcceptedAnswerId="6824" CreationDate="2016-03-10T02:28:39.083" Score="2" ViewCount="490" Body="&lt;p&gt;I'm using MacVim installed with &lt;code&gt;brew&lt;/code&gt; and everything works pretty fine, but (and there always is a &quot;but&quot;) when I launch it as &lt;code&gt;mvim&lt;/code&gt; from the terminal, it says &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /usr/local/Cellar/macvim/7.4-98/MacVim.app/Contents/Resources/vim/runtime/menu.vim:&#xA;line 1222:&#xA;E334: Menu not found: Window.Minimize&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm pretty sure that the problem is in my &lt;code&gt;.vimrc&lt;/code&gt; or my plugins, but I don't know how to find the one responsible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do to fix this? It's just a bit annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my &lt;code&gt;.vimrc&lt;/code&gt; (and it is in a bit of mess):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot;=====================================================&#xA;&quot; Vundle settings&#xA;&quot;=====================================================&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;Plugin 'gmarik/Vundle.vim'      &quot; let Vundle manage Vundle, required&#xA;&#xA;&quot;---------=== Code/project navigation ===-------------&#xA;Plugin 'scrooloose/nerdtree'            &quot; Project and file navigation&#xA;Plugin 'majutsushi/tagbar'              &quot; Class/module browser&#xA;&#xA;&quot;------------------=== Other ===----------------------&#xA;Plugin 'bling/vim-airline'              &quot; Lean &amp;amp; mean status/tabline for vim&#xA;Plugin 'fisadev/FixedTaskList.vim'      &quot; Pending tasks list&#xA;Plugin 'rosenfeld/conque-term'          &quot; Consoles as buffers&#xA;Plugin 'tpope/vim-surround'     &quot; Parentheses, brackets, quotes, XML tags, and more&#xA;&#xA;&quot;--------------=== Snippets support ===---------------&#xA;Plugin 'garbas/vim-snipmate'        &quot; Snippets manager&#xA;Plugin 'MarcWeber/vim-addon-mw-utils'   &quot; dependencies #1&#xA;Plugin 'tomtom/tlib_vim'        &quot; dependencies #2&#xA;Plugin 'honza/vim-snippets'     &quot; snippets repo&#xA;&#xA;&quot;---------------=== Languages support ===-------------&#xA;&quot; --- Python ---&#xA;Plugin 'klen/python-mode'           &quot; Python mode (docs, refactor, lints, highlighting, run and ipdb and more)&#xA;&quot;Plugin 'davidhalter/jedi-vim'      &quot; Jedi-vim autocomplete plugin&#xA;&quot;Plugin 'mitsuhiko/vim-jinja'       &quot; Jinja support for vim&#xA;Plugin 'mitsuhiko/vim-python-combined'  &quot; Combined Python 2/3 for Vim&#xA;&#xA;call vundle#end()                   &quot; required&#xA;filetype on&#xA;filetype plugin on&#xA;filetype plugin indent on&#xA;&#xA;&quot;=====================================================&#xA;&quot; General settings&#xA;&quot;=====================================================&#xA;set backspace=indent,eol,start&#xA;aunmenu Help.&#xA;aunmenu Window.&#xA;let no_buffers_menu=1&#xA;set mousemodel=popup&#xA;&#xA;set ruler&#xA;set completeopt-=preview&#xA;set gcr=a:blinkon0&#xA;if has(&quot;gui_running&quot;)&#xA;  set cursorline&#xA;endif&#xA;set ttyfast&#xA;&#xA;&quot; ???????? ????????? ????&#xA;syntax on&#xA;if has(&quot;gui_running&quot;)&#xA;&quot; GUI? ???????????? ???? ? ?????? ????&#xA;  set lines=50 columns=125&#xA;  colorscheme colorsbox-material &quot;monokai&#xA;&quot; ???????????????? ??? ??????, ???? ??????, ????? NERDTree/TagBar ????????????? ???????????? ??? ??????? vim&#xA;&quot; autocmd vimenter * TagbarToggle&#xA;&quot; autocmd vimenter * NERDTree&#xA;&quot; autocmd vimenter * if !argc() | NERDTree | endif&#xA;&#xA;&quot; ?? ???? vim?&#xA;set guifont=LiterationMonoPowerline:h11&#xA;set fuoptions=maxvert,maxhorz&#xA;endif&#xA;&#xA;tab sball&#xA;set switchbuf=useopen&#xA;&#xA;&quot; ????????? ??????? ? ???????&#xA;set visualbell t_vb= &#xA;set novisualbell       &#xA;&#xA;set enc=utf-8        &quot; utf-8 ?? ??????? ? ??????&#xA;set ls=2             &quot; ?????? ?????????? ?????????&#xA;set incsearch        &quot; ???????????????? ?????&#xA;set hlsearch         &quot; ????????? ??????????? ??????&#xA;set nu               &quot; ?????????? ?????? ?????&#xA;set scrolloff=5      &quot; 5 ????? ??? ??????? ?? ???&#xA;&#xA;&quot; ????????? ?????? ? ????-?????&#xA;set nobackup         &quot; no backup files&#xA;set nowritebackup    &quot; only in case you don't want a backup file while editing&#xA;set noswapfile       &quot; no swap files&#xA;&#xA;&quot; ?????? ????????&#xA;&quot;set guioptions-=m   &quot; ????&#xA;set guioptions-=T    &quot; ??????&#xA;&quot;set guioptions-=r   &quot;  ??????????&#xA;&#xA;&quot; ????????? ?? Tab&#xA;set smarttab&#xA;set tabstop=4&#xA;set softtabstop=0&#xA;set expandtab&#xA;set shiftwidth=4&#xA;&#xA;&quot;  ??? ???????? ?? ??????? ? 80 ???????? ? Ruby/Python/js/C/C++ ???????????? ?? ?????? ???? ?????&#xA;augroup vimrc_autocmds&#xA;    autocmd!&#xA;    autocmd FileType ruby,python,javascript,c,cpp highlight Excess ctermbg=DarkGrey guibg=Black&#xA;    autocmd FileType ruby,python,javascript match Excess /\%80v.*/&#xA;    autocmd FileType c,cpp match Excess /\%110v.*/&#xA;    autocmd FileType ruby,python,javascript,c,cpp set nowrap&#xA;augroup END&#xA;&#xA;&quot; ????????? ??????? ? ??????????? SnipMate&#xA;let g:snippets_dir = &quot;~/.vim/vim-snippets/snippets&quot;&#xA;&#xA;&quot; ????????? Vim-Airline&#xA;set laststatus=2&#xA;let g:airline_theme='badwolf'&#xA;let g:airline_powerline_fonts = 1&#xA;let g:airline#extensions#tabline#enabled = 1&#xA;let g:airline#extensions#tabline#formatter = 'unique_tail'&#xA;&#xA;&quot; TagBar ?????????&#xA;map &amp;lt;F4&amp;gt; :TagbarToggle&amp;lt;CR&amp;gt;&#xA;let g:tagbar_autofocus = 0 &quot; ????????? ?? Tagbar ??? ????????&#xA;&#xA;&quot; NerdTree ?????????&#xA;&quot; ???????? NERDTree ?? F3&#xA;map &amp;lt;F3&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&quot;????????????? ????? ? ????????????&#xA;let NERDTreeIgnore=['\~$', '\.pyc$', '\.pyo$', '\.class$', 'pip-log\.txt$', '\.o$']  &#xA;&#xA;&quot; TaskList ?????????&#xA;map &amp;lt;F2&amp;gt; :TaskList&amp;lt;CR&amp;gt;     &quot; ?????????? ?????? ?????? ?? F2&#xA;&#xA;&quot; ?????? ?????????&#xA;map &amp;lt;C-q&amp;gt; :bd&amp;lt;CR&amp;gt;      &quot; CTRL+Q - ??????? ??????? ??????&#xA;&#xA;&quot;=====================================================&#xA;&quot; Python-mode settings&#xA;&quot;=====================================================&#xA;&quot; ????????? ??????????? ?? ???? (? ??? ?????? ???? ???????????? jedi-vim)&#xA;&quot;let g:pymode_rope = 0&#xA;&quot;let g:pymode_rope_completion = 0&#xA;&quot;let g:pymode_rope_complete_on_dot = 0&#xA;&#xA;&quot; ????????????&#xA;let g:pymode_doc = 0&#xA;let g:pymode_doc_key = 'K'&#xA;&quot; ???????? ????&#xA;let g:pymode_lint = 1&#xA;let g:pymode_lint_checker = &quot;pyflakes,pep8&quot;&#xA;let g:pymode_lint_ignore=&quot;E501,W601,C0110&quot;&#xA;&quot; ??????? ???? ????? ??????????&#xA;let g:pymode_lint_write = 1&#xA;&#xA;&quot; ????????? virtualenv&#xA;let g:pymode_virtualenv = 1&#xA;&#xA;&quot; ????????? breakpoints&#xA;let g:pymode_breakpoint = 1&#xA;let g:pymode_breakpoint_key = '&amp;lt;leader&amp;gt;b'&#xA;&#xA;&quot; ?????????? ??????????&#xA;let g:pymode_syntax = 1&#xA;let g:pymode_syntax_all = 1&#xA;let g:pymode_syntax_indent_errors = g:pymode_syntax_all&#xA;let g:pymode_syntax_space_errors = g:pymode_syntax_all&#xA;&#xA;&quot; ????????? autofold ?? ????&#xA;let g:pymode_folding = 0&#xA;&#xA;&quot; ??????????? ????????? ???&#xA;let g:pymode_run = 0&#xA;&#xA;&quot; Disable choose first function/method at autocomplete&#xA;let g:jedi#popup_select_first = 0&#xA;&#xA;let g:airline_powerline_fonts = 1&#xA;&#xA;&quot;=====================================================&#xA;&quot; Languages support&#xA;&quot;=====================================================&#xA;&quot; --- Python ---&#xA;&quot;autocmd FileType python set completeopt-=preview &quot; ????????????????, ? ??????, ???? ?? ????, ????? jedi-vim ????????? ???????????? ?? ??????/??????&#xA;autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8&#xA;\ formatoptions+=croq softtabstop=4 smartindent&#xA;\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with&#xA;autocmd FileType pyrex setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4 smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with&#xA;&#xA;&quot; --- template language support (SGML / XML too) ---&#xA;autocmd FileType html,xhtml,xml,htmldjango,htmljinja,eruby,mako setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2&#xA;autocmd bufnewfile,bufread *.rhtml setlocal ft=eruby&#xA;autocmd BufNewFile,BufRead *.mako setlocal ft=mako&#xA;autocmd BufNewFile,BufRead *.tmpl setlocal ft=htmljinja&#xA;autocmd BufNewFile,BufRead *.py_tmpl setlocal ft=python&#xA;let html_no_rendering=1&#xA;let g:closetag_default_xml=1&#xA;let g:sparkupNextMapping='&amp;lt;c-l&amp;gt;'&#xA;autocmd FileType html,htmldjango,htmljinja,eruby,mako let b:closetag_html_style=1&#xA;autocmd FileType html,xhtml,xml,htmldjango,htmljinja,eruby,mako source ~/.vim/scripts/closetag.vim&#xA;&#xA;&quot; --- LaTeX ---&#xA;&quot; REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.&#xA;filetype plugin on&#xA;&#xA;&quot; IMPORTANT: grep will sometimes skip displaying the file name if you&#xA;&quot; search in a singe file. This will confuse Latex-Suite. Set your grep&#xA;&quot; program to always generate a file-name.&#xA;set grepprg=grep\ -nH\ $*&#xA;&#xA;&quot; OPTIONAL: This enables automatic indentation as you type.&#xA;filetype indent on&#xA;&#xA;&quot; OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to&#xA;&quot; 'plaintex' instead of 'tex', which results in vim-latex not being loaded.&#xA;&quot; The following changes the default filetype back to 'tex':&#xA;let g:tex_flavor='latex'&#xA;&#xA;&quot; --- Keyboard ---&#xA;let g:XkbSwitchEnabled = 1&#xA;let g:XkbSwitchIMappingsSkipFt = ['tex']&#xA;let g:XkbSwitchIMappings = ['ru']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5965" LastEditorUserId="1841" LastEditDate="2016-03-10T09:29:15.230" LastActivityDate="2016-03-10T09:29:15.230" Title="E334: Menu not found: Window.Minimize" Tags="|vimrc|macvim|error|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6824" PostTypeId="2" ParentId="6823" CreationDate="2016-03-10T09:27:01.840" Score="5" Body="&lt;p&gt;&lt;strong&gt;Important note&lt;/strong&gt; As I mentioned it in the comments when you begin to use Vim the best you can do is to start with an emtpy &lt;code&gt;.vimrc&lt;/code&gt;. From this you'll be able to build your own configuration which really suits your needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a &lt;a href=&quot;https://pragprog.com/book/dnvim/practical-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;lot&lt;/a&gt; &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;of&lt;/a&gt; &lt;a href=&quot;https://vi.stackexchange.com/questions/63/how-can-a-complete-beginner-learn-vim-using-just-vim-itself&quot;&gt;resources&lt;/a&gt; to help you beginning with Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;strong&gt;don't copy stuff you don't understand in your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/strong&gt; it I'll only cause trouble and lot of hard debugging time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also @Carpetsmoker did a great guide about &lt;a href=&quot;https://vi.stackexchange.com/q/2003/1841&quot;&gt;how to debug your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/a&gt;. You'll need it, trust me ;-)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Now about your particular problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have an error &lt;code&gt;E334: Menu not found: Window.Minimize&lt;/code&gt;. Conveniently Vim has a great help system so just type &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/gui.html#E334&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h E334&lt;/code&gt;&lt;/a&gt; to get an idea of what your problem comes from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here it is related to the settings of the menus in your GUI. If you scrolldown in the help page you'll see mentions of &lt;code&gt;aunmenu&lt;/code&gt; and &lt;code&gt;guioptions&lt;/code&gt; options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;.vimrc&lt;/code&gt; the lines 45 and 46 use these options to remove the help menu and the window menu in all modes. Then you know that these lines are creating a problem.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-03-10T09:27:01.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6825" PostTypeId="1" AcceptedAnswerId="6826" CreationDate="2016-03-10T10:03:37.227" Score="6" ViewCount="6500" Body="&lt;p&gt;I often use &lt;code&gt;:tab sball&lt;/code&gt; to open all buffers as tabs, but sometimes after doing so I would like to close the tab and remove file from buffers at the same time. How can I achieve that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know already that if I open a new tab with&lt;br&gt;&#xA;&lt;code&gt;:tabe&lt;/code&gt; and don't save it- it close it with buffer using: &lt;code&gt;q!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something similar to close tab and buffer at the same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using neovim (NVIM 0.1.3-dev).&lt;/p&gt;&#xA;" OwnerUserId="3254" LastActivityDate="2016-03-10T10:09:50.887" Title="how to close tab and remove this file from buffers" Tags="|buffers|neovim|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6826" PostTypeId="2" ParentId="6825" CreationDate="2016-03-10T10:09:50.887" Score="12" Body="&lt;p&gt;&lt;code&gt;:bd&lt;/code&gt; will do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#:bdelete&quot;&gt;documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[N]bd[elete][!]            *:bd* *:bdel* *:bdelete* *E516*&#xA;:bd[elete][!] [N]&#xA;        Unload buffer [N] (default: current buffer) and delete it from&#xA;        the buffer list.  If the buffer was changed, this fails,&#xA;        unless when [!] is specified, in which case changes are lost.&#xA;        The file remains unaffected.  Any windows for this buffer are&#xA;        closed.  If buffer [N] is the current buffer, another buffer&#xA;        will be displayed instead.  This is the most recent entry in&#xA;        the jump list that points into a loaded buffer.&#xA;        Actually, the buffer isn't completely deleted, it is removed&#xA;        from the buffer list |unlisted-buffer| and option values,&#xA;        variables and mappings/abbreviations for the buffer are&#xA;        cleared.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4932" LastActivityDate="2016-03-10T10:09:50.887" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6827" PostTypeId="1" AcceptedAnswerId="6828" CreationDate="2016-03-10T13:27:05.430" Score="5" ViewCount="2950" Body="&lt;p&gt;I configured my CursorLine to be lightyellow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Vfaz5.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Vfaz5.png&quot; alt=&quot;cursorline screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a couple of issues here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First, lightyellow is marked as an error when it is a valid color. How can I avoid this?&lt;/li&gt;&#xA;&lt;li&gt;Second, when the cursor line is over an error, the error background color disappears and it is really hard to read the text. Is there any way of preventing this behavior?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NDELI.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NDELI.png&quot; alt=&quot;screenshot cursor line error&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6754" LastEditorUserId="1841" LastEditDate="2016-03-10T13:35:01.353" LastActivityDate="2017-11-18T21:08:33.777" Title="CursorLine colors" Tags="|vimrc|colorscheme|cursor|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6828" PostTypeId="2" ParentId="6827" CreationDate="2016-03-10T14:37:05.540" Score="8" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The default syntax script for vim doesn't have &lt;code&gt;lightyellow&lt;/code&gt; listed for &lt;code&gt;vimHiCtermColor&lt;/code&gt;. You could patch it and submit your change to the vim_dev mailing list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, better, ask them if that is intentional.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;Error&lt;/code&gt; as a lower priority than &lt;code&gt;CursorLine&lt;/code&gt; but you can force it with this simple hack:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Error cterm=reverse ctermbg=white ctermfg=red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of white text on red background, you use red text on white background and reverse them with the &lt;code&gt;reverse&lt;/code&gt; attribute:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it gives you white on red,&lt;/li&gt;&#xA;&lt;li&gt;it increases the priority of &lt;code&gt;Error&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-03-10T14:37:05.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6829" PostTypeId="2" ParentId="6803" CreationDate="2016-03-10T15:41:05.530" Score="2" Body="&lt;p&gt;I have found a way to work 256 colors in windows using ConEmu, link available&#xA;&lt;a href=&quot;http://conemu.github.io/en/Downloads.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; for download.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After setting up ConEmu, check for these conditions -&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Vim’s executable must be named ‘vim.exe’;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Check options ‘Inject ConEmuHk’ and ‘ANSI X3.64 / xterm 256 colors’&#xA;on Features page&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Check option ‘TrueMod (24bit color) support’ on Colors page&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Edit your ‘vimrc’ file, sample lines are here.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The following code is to be added to &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !has(&quot;gui_running&quot;)&#xA;    set term=xterm&#xA;    set t_Co=256&#xA;    let &amp;amp;t_AB=&quot;\e[48;5;%dm&quot;&#xA;    let &amp;amp;t_AF=&quot;\e[38;5;%dm&quot;&#xA;    colorscheme zenburn&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, you need some 256-color vim scheme, it is ‘zenburn’ in the last line of this example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I have no syntax highlighting issues when using vim in ConEmu.&#xA;Check the &lt;a href=&quot;http://conemu.github.io/en/VimXterm.html&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt; for the official documentation.&lt;/p&gt;&#xA;" OwnerUserId="6706" LastEditorUserId="6706" LastEditDate="2016-03-11T18:19:44.393" LastActivityDate="2016-03-11T18:19:44.393" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6830" PostTypeId="1" AcceptedAnswerId="6831" CreationDate="2016-03-10T16:01:33.907" Score="7" ViewCount="406" Body="&lt;p&gt;Is it possible to pass a variable to a function in vimscript, and then use that value in a search and replace regex?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddTW5Links(tiddlerSetName) &#xA;&#xA;    %s/\(*\+\)\(\[\[\(.*\)\)\]\]/\1[[\3|\3 - $tiddlerSetName]]/g&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2016-03-10T23:54:39.817" Title="Putting the value of an argument into part of a regex in vimscript?" Tags="|vimscript|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6831" PostTypeId="2" ParentId="6830" CreationDate="2016-03-10T16:08:18.147" Score="8" Body="&lt;p&gt;You have the choice between using &lt;code&gt;:s&lt;/code&gt; after &lt;code&gt;:exe&lt;/code&gt;, or using &lt;code&gt;:s\=&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meaning (untested)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 's/\(*\+\)\(\[\[\(.*\)\)\]\]/\1[[\3|\3 - '.a:tiddlerSetName.']]/g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(beware of double-quote, you'll have to double all your backslashes with them)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\(*\+\)\(\[\[\(.*\)\)\]\]/=submatch(1).'[['.submatch(3).'|'.submatch(3).' - '.a:tiddlerSetName.']]'/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-03-10T23:54:39.817" LastActivityDate="2016-03-10T23:54:39.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6833" PostTypeId="1" CreationDate="2016-03-10T20:08:39.060" Score="4" ViewCount="214" Body="&lt;p&gt;How can I remove the left bar in the taglist plugin?&#xA;It is the gray part in picture.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Gfzi1.png&quot; alt=&quot;vim screenshot&quot; /&gt;&lt;/p&gt;&#xA;" OwnerUserId="6760" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-03-11T07:20:18.167" Title="How can I remove the left bar in the taglist plugin?" Tags="|plugin-airline|plugin-taglist|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6834" PostTypeId="1" AcceptedAnswerId="6886" CreationDate="2016-03-10T20:20:32.540" Score="25" ViewCount="19090" Body="&lt;p&gt;I know that running &lt;code&gt;:map&lt;/code&gt; commands without arguments should give me a list of user-defined mappings, but, for example, when I press Ctrl-W Ctrl-I something happens, yet I have no idea what function was just happened as built-in mappings don't appear in the &lt;code&gt;:map&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I find out what a key does?&lt;/p&gt;&#xA;" OwnerUserId="6761" LastEditorUserId="51" LastEditDate="2016-08-07T23:39:23.583" LastActivityDate="2021-03-03T10:50:29.090" Title="How to find out what a key is mapped to?" Tags="|key-bindings|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6836" PostTypeId="2" ParentId="6833" CreationDate="2016-03-11T05:14:45.487" Score="3" Body="&lt;p&gt;I've found the correct option:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open &lt;code&gt;.vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Add &lt;code&gt;let Tlist_Enable_Fold_Column=0&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It's now good ;-)&lt;/p&gt;&#xA;" OwnerUserId="6760" LastEditorUserId="51" LastEditDate="2016-03-11T07:20:18.167" LastActivityDate="2016-03-11T07:20:18.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6837" PostTypeId="1" AcceptedAnswerId="6839" CreationDate="2016-03-11T06:35:00.070" Score="2" ViewCount="2320" Body="&lt;p&gt;Why does the &lt;code&gt;:Explore&lt;/code&gt; command shows the &lt;code&gt;.&lt;/code&gt; directory? This seems  to be unnecessary as it's just one more line that I have to &lt;code&gt;j&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way I can disable this?&lt;/p&gt;&#xA;" OwnerUserId="6766" LastEditorUserId="6766" LastEditDate="2016-03-14T03:56:11.400" LastActivityDate="2016-03-14T03:56:11.400" Title=":Explore shows the &quot;.&quot; directory" Tags="|netrw|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6838" PostTypeId="2" ParentId="3559" CreationDate="2016-03-11T08:27:49.717" Score="3" Body="&lt;p&gt;&lt;strong&gt;Try this&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;up&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-o&amp;gt;gk&#xA;inoremap &amp;lt;down&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-o&amp;gt;gj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The difference is: I added &lt;code&gt;&amp;lt;c-\&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While Carpetsmoker's solution is also nice, I found that the solution might not work in some cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, when pop-up menu is not visible but we are still in the omni-completion mode (when we type or just select the suggested item, the pop-up menu disappears but the command line reads &lt;code&gt;Omni completion (^O^N^P)&lt;/code&gt;), a consequent &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; will work as an omnicomplete-related command, not special keys in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#ins-special-special&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help ins-special-special&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-O          execute one command, return to Insert mode   i_CTRL-O&#xA;CTRL-\ CTRL-O   like CTRL-O but don't move the cursor        i_CTRL-\_CTRL-O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which shows that &lt;code&gt;&amp;lt;c-\&amp;gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; is another way to achieve the same behavior like &lt;code&gt;&amp;lt;ctrl-o&amp;gt;&lt;/code&gt;. Using the aforementioned key mapping, I see that navigation using arrow keys in the insert mode does work without conflicting to omni-completion mode.&lt;/p&gt;&#xA;" OwnerUserId="6748" LastEditorUserId="1841" LastEditDate="2016-03-11T08:31:47.377" LastActivityDate="2016-03-11T08:31:47.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6839" PostTypeId="2" ParentId="6837" CreationDate="2016-03-11T09:12:51.620" Score="5" Body="&lt;p&gt;You could hide the dot directory (&lt;code&gt;./&lt;/code&gt;) by setting the global variables &lt;code&gt;g:netrw_list_hide&lt;/code&gt; and &lt;code&gt;g:netrw_hide&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_list_hide = '^\./$'&#xA;let g:netrw_hide = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first variable can contain a comma separated list of regex patterns describing what you want to hide.  Here, the pattern used is &lt;code&gt;'^\./$'&lt;/code&gt;:&lt;br&gt;&#xA;a beginning of string (&lt;code&gt;^&lt;/code&gt;), a literal dot &lt;code&gt;\.&lt;/code&gt;, a slash &lt;code&gt;/&lt;/code&gt; and an end of string &lt;code&gt;$&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also edit this variable from the file explorer netrw, by hitting &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the variable is set, from netrw, hitting &lt;code&gt;a&lt;/code&gt; will switch between different views:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;showing everything&lt;/li&gt;&#xA;&lt;li&gt;hiding items described by &lt;code&gt;g:netrw_list_hide&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;only showing items in &lt;code&gt;g:netrw_list_hide&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can configure which view is chosen by default by setting up &lt;code&gt;g:netrw_hide&lt;/code&gt; which can take 3 values (&lt;code&gt;0&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt; or &lt;code&gt;2&lt;/code&gt;).&lt;br&gt;&#xA;&lt;code&gt;1&lt;/code&gt; means hiding by default the items in &lt;code&gt;g:netrw_list_hide&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help g:netrw_list_hide&#xA;:help g:netrw_hide&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-03-11T09:20:14.767" LastActivityDate="2016-03-11T09:20:14.767" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6841" PostTypeId="1" CreationDate="2016-03-11T12:15:48.510" Score="2" ViewCount="1255" Body="&lt;p&gt;I can create code folding in marker based folding if there is only one starting marker and one ending marker. What if I have to fold a code which has two starting marker and only one ending marker?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example in the following code I am able to fold either &lt;code&gt;ifdef&lt;/code&gt; or &lt;code&gt;ifndef&lt;/code&gt; but not both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmarker=`ifdef,`endif&#xA;set foldmethod=marker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ifdef&#xA;     /*&#xA;      * some code&#xA;      */&#xA;ifndef&#xA;     /*&#xA;      * some code&#xA;      */&#xA;endif&#xA;     /*&#xA;      * some code&#xA;      */&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6771" LastEditorUserId="1841" LastEditDate="2016-03-11T12:36:04.750" LastActivityDate="2023-11-21T19:33:47.693" Title="Create folding with several starting markers" Tags="|folding|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6843" PostTypeId="2" ParentId="6841" CreationDate="2016-03-11T12:35:20.827" Score="2" Body="&lt;p&gt;I've done that for C &amp;amp; C++ in &lt;a href=&quot;https://github.com/LucHermitte/VimFold4C&quot; rel=&quot;nofollow&quot;&gt;VimFold4C&lt;/a&gt; -- along with folding brackets, includes, comments... However, there is a pending bug regarding nested #ifdef.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The task is not that trivial. That's why I won't post code here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're just interested in folding those, may be, the easier would be to hack the syntax file of your language and indicate that folding shall occur on those &quot;markers&quot; -- and then use the syntax folding method.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-03-11T12:35:20.827" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6844" PostTypeId="1" AcceptedAnswerId="6920" CreationDate="2016-03-11T14:18:25.957" Score="5" ViewCount="3083" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/equalsraf/neovim-qt&quot; rel=&quot;nofollow&quot;&gt;neovim-qt&lt;/a&gt; but cannot figure out how to set the size of the window.  I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim-qt -h&#xA;nvim-qt --help&#xA;nvim-qt --width=80&#xA;nvim-qt --geom 80x120&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But nothing gave me any indication as to how to do it. The &lt;a href=&quot;https://github.com/equalsraf/neovim-qt/wiki&quot; rel=&quot;nofollow&quot;&gt;wiki&lt;/a&gt; is equally unhelpful.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/equalsraf/neovim-qt/issues/108&quot; rel=&quot;nofollow&quot;&gt;issue 108: How should window resizing behave?&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="622" LastEditorUserId="622" LastEditDate="2016-03-18T12:49:08.690" LastActivityDate="2022-11-04T16:56:41.900" Title="How to set the size of the Neovim-qt GUI?" Tags="|neovim|neovim-qt|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6845" PostTypeId="5" CreationDate="2016-03-11T14:34:58.970" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/equalsraf/neovim-qt&quot; rel=&quot;nofollow&quot;&gt;Neovim-qt&lt;/a&gt; is a client library and minimalistic GUI, in Qt5 for Neovim. Its goals are:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Provide Qt5 bindings to write Neovim clients and plugins in Qt&lt;/li&gt;&#xA;  &lt;li&gt;Cross platform GUI for Neovim&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is in very early stages of development.&lt;/p&gt;&#xA;" OwnerUserId="622" LastEditorUserId="622" LastEditDate="2016-03-11T15:04:43.740" LastActivityDate="2016-03-11T15:04:43.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6846" PostTypeId="4" CreationDate="2016-03-11T14:34:58.970" Score="0" Body="Neovim-qt is a client library and minimalistic GUI (QT5) for neovim." OwnerUserId="622" LastEditorUserId="622" LastEditDate="2016-03-11T15:04:47.773" LastActivityDate="2016-03-11T15:04:47.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6847" PostTypeId="2" ParentId="6820" CreationDate="2016-03-11T17:00:09.213" Score="1" Body="&lt;p&gt;The best way to do this is, as @Carpetsmoker noted in the comments, to simply &lt;em&gt;uninstall gVim and reinstall it&lt;/em&gt;, selecting the desired installation directory. Depending on your installation options, gVim may have made some registry modifications to establish file associations when initially installed. For example, the &quot;Edit with Vim&quot; context menu option for explorer is a key under &lt;code&gt;HKEY_CLASSES_ROOT/*/shell/Vim/Command&lt;/code&gt; with a value of &lt;code&gt;&quot;C:\Program Files (x86)\vim\vim74\gvim.exe&quot; &quot;%1&quot;&lt;/code&gt;. Uninstalling and re-installing will ensure these keys have correct values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can, of course, simply move the entire &lt;code&gt;C:\Program Files (x86)\Vim&lt;/code&gt; folder somewhere else. If you do this, you'll have to at least fix up your &lt;code&gt;%PATH%&lt;/code&gt; environment variable to include the new location, or &lt;code&gt;gvim&lt;/code&gt; won't work. You'll also have to find and fix (or delete) any registry or similar associations you want to continue working or don't want to have any longer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Uninstalling and re-installing is definitely the ideal option here. It's way less work and will result in a much less broken installation.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2016-03-11T17:00:09.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6848" PostTypeId="1" CreationDate="2016-03-11T22:58:05.477" Score="2" ViewCount="23" Body="&lt;p&gt;Is anyone using this keymap file with success?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/vim-scripts/greek_polytonic.vim&quot; rel=&quot;nofollow&quot;&gt;https://github.com/vim-scripts/greek_polytonic.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get only Latin output after following the instructions.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-03-11T22:58:05.477" Title="greek_polytonic keymap file not working" Tags="|input-methods|key-bindings|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6849" PostTypeId="2" ParentId="6819" CreationDate="2016-03-12T01:56:09.833" Score="2" Body="&lt;p&gt;So, after some iterations and tests, the answer to this is by using the &lt;code&gt;g:ycm_semantic_triggers&lt;/code&gt; option as described here: &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe#the-gycm_semantic_triggers-option&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Valloric/YouCompleteMe#the-gycm_semantic_triggers-option&lt;/a&gt; This has to be done via the regex mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the relevant config line from my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_semantic_triggers =  { 'cpp,objcpp' : ['-&amp;gt;', '.', '::', 're!gl'] }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It adds the &lt;code&gt;'re!gl'&lt;/code&gt; item to the list of default semantic triggers in C++ and Obj-C++. This will trigger semantic completion on anything starting with &lt;code&gt;gl&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6724" LastActivityDate="2016-03-12T01:56:09.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6850" PostTypeId="2" ParentId="4056" CreationDate="2016-03-12T05:27:27.283" Score="35" Body="&lt;p&gt;For my specific case, the preview window was opened by plugins. So, I used plugin configuration to automatically close these windows.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Supertab&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;As suggested by Alex Kroll:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:SuperTabClosePreviewOnPopupClose = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;YouCompleteMe&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_autoclose_preview_window_after_insertion = 1&#xA;let g:ycm_autoclose_preview_window_after_completion = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the second variable is set, the first has no effect. From the docs:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;The *g:ycm_autoclose_preview_window_after_completion* option&#xA;&#xA;When this option is set to '1', YCM will auto-close the 'preview' window after&#xA;the user accepts the offered completion string. If there is no 'preview' window&#xA;triggered because there is no 'preview' string in 'completeopt', this option is&#xA;irrelevant. See the |g:ycm_add_preview_to_completeopt| option for more details.&#xA;&#xA;Default: '0'&#xA;&amp;gt;&#xA;  let g:ycm_autoclose_preview_window_after_completion = 0&#xA;&amp;lt;&#xA;-------------------------------------------------------------------------------&#xA;The *g:ycm_autoclose_preview_window_after_insertion* option&#xA;&#xA;When this option is set to '1', YCM will auto-close the 'preview' window after&#xA;the user leaves insert mode. This option is irrelevant if&#xA;|g:ycm_autoclose_preview_window_after_completion| is set or if no 'preview'&#xA;window is triggered. See the |g:ycm_add_preview_to_completeopt| option for more&#xA;details.&#xA;&#xA;Default: '0'&#xA;&amp;gt;&#xA;  let g:ycm_autoclose_preview_window_after_insertion = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-06-01T13:41:57.000" LastActivityDate="2016-06-01T13:41:57.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6851" PostTypeId="1" AcceptedAnswerId="6852" CreationDate="2016-03-12T13:32:47.390" Score="6" ViewCount="405" Body="&lt;p&gt;I have the following command in vim to scroll another window when only two windows are open. The specifics are not important as this is a general question, but the example is illustrative.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;d &amp;lt;C-w&amp;gt;w&amp;lt;C-d&amp;gt;&amp;lt;C-w&amp;gt;w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine most of the time, but if the other window is already at the bottom then I find my cursor often ends up stuck in the other window. I'm guessing this is because the &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; fails and the command stops running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've come across the same problem in other remappings and I'm sure there is a simple way to code around it. I know that for example in search and replace you stick an &lt;code&gt;e&lt;/code&gt; at the end. For example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bufdo s/foo/bar/ge | update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows later commands to run even if no patterns match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="6781" LastActivityDate="2016-03-13T09:44:16.347" Title="How to remap keys so that failed commands don't stop the command?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6852" PostTypeId="2" ParentId="6851" CreationDate="2016-03-12T15:12:22.090" Score="5" Body="&lt;p&gt;If you have 2 windows, in both of them you are in the middle of a buffer, and you type the following Ex command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;norm! \&amp;lt;C-W&amp;gt;w\&amp;lt;C-D&amp;gt;\&amp;lt;C-W&amp;gt;w&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should do what your mapping is trying to perform, which is scrolling the other window downwards and give the focus back to the original window.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if in the other window, your cursor is already at the very bottom of the buffer, it will not give the focus back because, like you said, the &lt;code&gt;&amp;lt;C-D&amp;gt;&lt;/code&gt; will fail and therefore the last keystrokes, &lt;code&gt;&amp;lt;C-W&amp;gt;w&lt;/code&gt;, won't be hit by &lt;code&gt;:normal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possible solution is to break the &lt;code&gt;:normal&lt;/code&gt; command into 2 parts, where an error may occur.&lt;br&gt;&#xA;Here, the error may occur on &lt;code&gt;&amp;lt;C-D&amp;gt;&lt;/code&gt;, so you could type the following Ex command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;norm! \&amp;lt;C-W&amp;gt;w\&amp;lt;C-D&amp;gt;&quot; | exe &quot;norm! \&amp;lt;C-W&amp;gt;w&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, even if the first &lt;code&gt;:normal&lt;/code&gt; command fails at the end, the second &lt;code&gt;:normal&lt;/code&gt; will still be executed regardless.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To convert the previous command into a mapping, you could write this in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;d :&amp;lt;C-U&amp;gt;exe &quot;norm! \&amp;lt;lt&amp;gt;C-W&amp;gt;w\&amp;lt;lt&amp;gt;C-D&amp;gt;&quot; &amp;lt;bar&amp;gt; exe &quot;norm! \&amp;lt;lt&amp;gt;C-W&amp;gt;w&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A few things that may help you better understand the previous mapping:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;In the &lt;code&gt;{rhs}&lt;/code&gt; of the mapping, &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; is there just in case you hit a number (by accident) before &lt;code&gt;&amp;lt;leader&amp;gt;d&lt;/code&gt;.&lt;br&gt;&#xA;If you hit a number before an Ex command, it's automatically converted into a range on the command line. For example, if you hit &lt;code&gt;5:&lt;/code&gt;, you should see &lt;code&gt;:.,.+4&lt;/code&gt;.&lt;br&gt;&#xA;But &lt;code&gt;:execute&lt;/code&gt; doesn't accept a range, so it would raise an error.&lt;br&gt;&#xA;With &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt;, if a range is inserted by accident, it will be deleted.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:normal&lt;/code&gt; doesn't need &lt;code&gt;:execute&lt;/code&gt; to type normal commands, however, &lt;code&gt;:execute&lt;/code&gt; allows you to prevent &lt;code&gt;:normal&lt;/code&gt; from typing the whole command line including the pipe.&lt;br&gt;&#xA;That's because &lt;code&gt;:normal&lt;/code&gt; interprets &lt;code&gt;|&lt;/code&gt; as a part of its argument, while &lt;code&gt;:execute&lt;/code&gt; interprets it as a command termination.&lt;br&gt;&#xA;Besides, it allows you to wrap the whole &lt;code&gt;:normal&lt;/code&gt; command inside a string where control characters may be represented with printable characters (a special type of notation described in &lt;code&gt;:help expr-quote&lt;/code&gt;). For example, here it allows you to represent a literal &lt;code&gt;&amp;lt;C-D&amp;gt;&lt;/code&gt; with the notation &lt;code&gt;\&amp;lt;C-D&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The bang after the &lt;code&gt;:normal&lt;/code&gt; command is here to prevent the keystrokes that you pass as an argument to be remapped. From &lt;code&gt;:help :normal&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Without it, when this command is called from a&#xA;non-remappable mapping (:noremap), the argument can&#xA;be mapped anyway.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usually you don't want the keys to be remapped, so even if it should not  be necessary here, it can be a good habit to put a bang after &lt;code&gt;:norm&lt;/code&gt;. But if for some reason you wanted the keys to be remapped, you could remove the bang.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When the string executed by &lt;code&gt;:execute&lt;/code&gt; contains special keys such as &lt;code&gt;&amp;lt;C-D&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt;, you should use double quotes instead of single ones, otherwise they won't be translated into literal control characters. As a result, instead of typing a literal &lt;code&gt;&amp;lt;C-D&amp;gt;&lt;/code&gt;, &lt;code&gt;:normal&lt;/code&gt; would type 5 keys &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;C&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;D&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In a mapping, the notation &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; can be used to represent a pipe character. Another possibility is &lt;code&gt;\|&lt;/code&gt;, but not &lt;code&gt;|&lt;/code&gt;. A simple pipe would be interpreted by &lt;code&gt;:nnoremap&lt;/code&gt; as a command termination instead of a usual character to type.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The keycode &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt; is necessary for the mapping to work. Without it, Vim will automatically translate &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-D&amp;gt;&lt;/code&gt; into literal control characters when your &lt;code&gt;vimrc&lt;/code&gt; is sourced and the mappings table is filled with all your mapping commands (the one you see through Vim's internal pager when you type &lt;code&gt;:map&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To better understand why &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt; is necessary, suppose you want to define a mapping in command line mode which maps &lt;code&gt;cw&lt;/code&gt; to the five characters &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt;, and you write this in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap cw &amp;lt;C-W&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, on the command line, you type (without hitting &lt;code&gt;Enter&lt;/code&gt; at the end):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;norm! \&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, you hit &lt;code&gt;cw&lt;/code&gt; thinking that it will insert &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; on the command line.&lt;br&gt;&#xA;But instead of getting &lt;code&gt;:exe &quot;norm! \&amp;lt;C-W&amp;gt;&lt;/code&gt;, you will get &lt;code&gt;:exe &quot;norm!&lt;/code&gt;. Why?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because, when your &lt;code&gt;:cnoremap&lt;/code&gt; command was sourced, inside the mappings table, &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; was automatically translated into a literal control character.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the effect of a literal &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; on the command line? It deletes the previous word.&lt;br&gt;&#xA;Here the previous word was the backslash, so it was deleted. But that's not what you wanted.&lt;br&gt;&#xA;You wanted the five characters &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; to be typed without any translation.&lt;br&gt;&#xA;So a better mapping would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap cw &amp;lt;lt&amp;gt;C-W&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This time, it will work as expected, because when the command will be sourced, inside the mappings table, only &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt; will be translated (into the character &lt;code&gt;&amp;lt;&lt;/code&gt;) and the result will be the 5 desired characters &lt;code&gt;&amp;lt;&lt;/code&gt; + &lt;code&gt;C-W&amp;gt;&lt;/code&gt; = &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt; as a way to protect a special key from being automatically translated when it's inside the &lt;code&gt;{rhs}&lt;/code&gt; of a mapping.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-03-13T09:44:16.347" LastActivityDate="2016-03-13T09:44:16.347" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6853" PostTypeId="1" AcceptedAnswerId="6866" CreationDate="2016-03-12T19:10:39.950" Score="4" ViewCount="330" Body="&lt;p&gt;I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.tex set filetype=tex&#xA;au BufRead,BufNewFile *.tex inoreabbrev ß \ss{}&#xA;au BufRead,BufNewFile *.tex inoreabbrev ö \&quot;{o}&#xA;au BufRead,BufNewFile *.tex inoreabbrev ä \&quot;{a}&#xA;au BufRead,BufNewFile *.tex inoreabbrev ü \&quot;{u}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;filetype.vim&lt;/code&gt;. When I open a TeX file and type &lt;code&gt;:ab&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i  ü           * \&quot;{u}                                                 &#xA;i  ä           * \&quot;{a}                                                &#xA;i  ö           * \&quot;{o}                                                &#xA;i  ß           * \ss{}&#xA;&#xA;Press ENTER or type command to continue &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;My abbreviations work in command line mode, &lt;code&gt;:ß&lt;/code&gt; results in &lt;code&gt;:\ss{}&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;but they don't in insert mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Why do my abbreviations only work in command line mode, but not in insert mode?&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="2354" LastEditDate="2016-03-13T15:05:06.607" LastActivityDate="2016-03-14T18:48:56.893" Title="insert mode Abbreviations work in command mode, but not in insert mode" Tags="|neovim|abbreviations|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6854" PostTypeId="1" AcceptedAnswerId="6855" CreationDate="2016-03-12T20:19:21.497" Score="9" ViewCount="2798" Body="&lt;p&gt;I switched to &lt;code&gt;vim-plug&lt;/code&gt; recently. In &lt;a href=&quot;https://github.com/junegunn/vim-plug/blob/master/README.md#on-demand-loading-of-plugins&quot;&gt;the README&lt;/a&gt;, there's this snippet for using YouCompleteMe with vim-plug:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Code to execute when the plugin is loaded on demand&#xA;Plug 'Valloric/YouCompleteMe', { 'for': 'cpp' }&#xA;autocmd! User YouCompleteMe if !has('vim_starting') | call youcompleteme#Enable() | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's the &lt;code&gt;autocmd&lt;/code&gt; for?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#User&quot;&gt;&lt;code&gt;:h User&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        User&#xA;User                            Never executed automatically.  To be used for&#xA;                                autocommands that are only executed with&#xA;                                &quot;:doautocmd&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, apparently it's something I should run manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The actual configuration I used was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; YCM command lifted from vim-plug readme&#xA;Plug 'Valloric/YouCompleteMe', { 'do': 'python2 ./install.py --clang-completer --gocode-completer --tern-completer', 'for': ['cpp', 'c', 'go', 'sh', 'js', 'vim'] }&#xA;autocmd! User YouCompleteMe if !has('vim_starting') | call youcompleteme#Enable() | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, for any of these filetypes, I don't need to run any command. YCM starts working as it normally used to, before I switched to &lt;code&gt;vim-plug&lt;/code&gt;. Running &lt;code&gt;:doautocmd User YouCompleteMe&lt;/code&gt; has no visible effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For anything else, &lt;code&gt;:doautocmd&lt;/code&gt; just throws an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing User Auto commands for &quot;YouCompleteMe&quot;:&#xA;E117: Unknown function: youcompleteme#Enable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, it seems I can't use it for enabling YCM for other filetypes on-demand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the point of that &lt;code&gt;autocmd&lt;/code&gt;, then?&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-03-12T21:20:02.210" Title="What does an `autocmd User` do?" Tags="|autocmd|plugin-you-complete-me|plugin-vim-plug|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6855" PostTypeId="2" ParentId="6854" CreationDate="2016-03-12T21:20:02.210" Score="5" Body="&lt;p&gt;In my understanding, that example creates a &lt;code&gt;User&lt;/code&gt; autocommand named &lt;code&gt;YouCompleteMe&lt;/code&gt; which will be fired by &lt;code&gt;vim-plug&lt;/code&gt; itself, in order to load the plugin on demand. If I'm not mistaken, here's the place where &lt;code&gt;vim-plug&lt;/code&gt; will run the custom autocommand: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:lod(names, types, ...)&#xA;  for name in a:names&#xA;    call s:remove_triggers(name)&#xA;    let s:loaded[name] = 1&#xA;  endfor&#xA;  call s:reorg_rtp()&#xA;&#xA;  for name in a:names&#xA;    let rtp = s:rtp(g:plugs[name])&#xA;    for dir in a:types&#xA;      call s:source(rtp, dir.'/**/*.vim')&#xA;    endfor&#xA;    if a:0&#xA;      if !s:source(rtp, a:1) &amp;amp;&amp;amp; !empty(s:glob(rtp, a:2))&#xA;        execute 'runtime' a:1&#xA;      endif&#xA;      call s:source(rtp, a:2)&#xA;    endif&#xA;    if exists('#User#'.name)&#xA;      execute 'doautocmd User' name        &amp;lt;&amp;lt;&amp;lt;&amp;lt; HERE &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&#xA;    endif&#xA;  endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source code: &lt;a href=&quot;https://github.com/junegunn/vim-plug/blob/820cc6356962927a73193daaafda6484ca461e4a/plug.vim#L442&quot;&gt;link&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically, the intended &quot;user&quot; of this autocmd is &lt;code&gt;vim-plug&lt;/code&gt; itself.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-03-12T21:20:02.210" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6856" PostTypeId="1" AcceptedAnswerId="6857" CreationDate="2016-03-12T22:30:14.263" Score="14" ViewCount="1499" Body="&lt;p&gt;I use &lt;code&gt;:browse oldfiles&lt;/code&gt; command to open recent files quickly. The list becomes very long with time -- I have 100 items in the list and need to tap space to complete this action. I want to reduce this list or show only last 10-20 items.  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How to set the limit for the history of opened files?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5243" LastActivityDate="2016-03-12T22:44:37.490" Title="Browse oldfiles list length" Tags="|gvim|file-operations|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6857" PostTypeId="2" ParentId="6856" CreationDate="2016-03-12T22:44:37.490" Score="14" Body="&lt;p&gt;&lt;code&gt;:browse oldfiles&lt;/code&gt; and &lt;code&gt;:oldfiles&lt;/code&gt; read from the viminfo file, so changing the maximum number of previously edited files to be remembered in the &lt;code&gt;'viminfo'&lt;/code&gt; option should work.  You can do this by changing the number after the &lt;code&gt;'&lt;/code&gt; character in the viminfo option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, doing &lt;code&gt;:set viminfo='50&lt;/code&gt; would mean that only 50 old files are remembered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this will overwrite everything currently set in the the &lt;code&gt;'viminfo'&lt;/code&gt; option, so make sure to set the other desired options as well.  For example, doing &lt;code&gt;:set viminfo='50,&amp;lt;50,s10,h&lt;/code&gt; would also mean that the maximum number of lines saved for each register would be 50, the maximum size of saved items is 10 KB and the effect of &lt;code&gt;'hlsearch'&lt;/code&gt; is disabled when loading the viminfo file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more on this topic, see &lt;code&gt;:help 'viminfo'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; You may need to wipe your viminfo file before the change will take effect, since all of your old files past your max number will be remembered still.&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2016-03-12T22:44:37.490" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6858" PostTypeId="1" AcceptedAnswerId="7272" CreationDate="2016-03-13T10:11:00.010" Score="8" ViewCount="8496" Body="&lt;p&gt;So I have downloaded &lt;code&gt;proton.vim&lt;/code&gt; (a colorscheme) and placed it inside my &lt;code&gt;.vim/colors&lt;/code&gt; folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In .vimrc, right at the bottom I have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme proton&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when Vim loads, it is set to the default colorscheme. If I type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:colorscheme proton&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after it has loaded, it works fine though. Anyone know what else I need to do to persist this colorscheme?&lt;/p&gt;&#xA;" OwnerUserId="6560" LastEditorUserId="205" LastEditDate="2016-04-08T18:13:43.303" LastActivityDate="2019-11-02T07:51:47.027" Title="Why does .vimrc not set colorscheme properly?" Tags="|vimrc|colorscheme|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6859" PostTypeId="1" AcceptedAnswerId="6861" CreationDate="2016-03-13T12:03:31.617" Score="3" ViewCount="4283" Body="&lt;p&gt;I have a file similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;aaaaaaaaaaaaaaaaaaaa&#xA;bbbbbbbbbbbbbbbbbbbb&#xA;cccccccccccccccccccc&#xA;dddddddddddddddddddd&#xA;&#xA;&#xA;aaaaaaaaaaaaaaaaaaaa&#xA;bbbbbbbbbbbbbbbbbbbb&#xA;cccccccccccccccccccc&#xA;dddddddddddddddddddd&#xA;&#xA;&#xA;aaaaaaaaaaaaaaaaaaaa&#xA;bbbbbbbbbbbbbbbbbbbb&#xA;cccccccccccccccccccc&#xA;dddddddddddddddddddd&#xA;&#xA;&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to join them to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&#xA;bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb&#xA;cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc&#xA;dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Until now I have done this by selecting blocks in (&lt;kbd&gt;ctrl&lt;/kbd&gt; + &lt;kbd&gt;v&lt;/kbd&gt;) and deleting them (&lt;kbd&gt;x&lt;/kbd&gt;) and pasting them to the end of the first block (&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;). This is very time consuming and I did not manage to get these things working in a macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;How can I combine multiple blocks of lines?&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="6793" LastEditorUserId="6793" LastEditDate="2016-03-17T14:08:33.410" LastActivityDate="2016-03-22T13:26:15.343" Title="Join multiple lines" Tags="|line-breaks|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6860" PostTypeId="1" AcceptedAnswerId="6872" CreationDate="2016-03-13T12:04:25.977" Score="5" ViewCount="323" Body="&lt;p&gt;When keymap is set and iminsert is 1, it says &lt;code&gt;-- INSERT (lang) --&lt;/code&gt; at the bottom of the screen.  Is there an easy way to change this string (or just the &lt;code&gt;lang&lt;/code&gt; string)?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-03-13T20:43:17.670" Title="Changing -- INSERT (lang) --" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6861" PostTypeId="2" ParentId="6859" CreationDate="2016-03-13T12:55:36.490" Score="5" Body="&lt;p&gt;I got the macro working:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqgg5j^V4j$xgg$p9jV4kd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; starts a macro called &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gg&lt;/code&gt; sets the startingpoint to the first line of the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;5j&lt;/code&gt; goes down 5 lines (the start of the block below it)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^V4j$&lt;/code&gt; goes into column selection mode and selects the first block&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;x&lt;/code&gt;  cut the content of the selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gg$p&lt;/code&gt; paste it to the end of the first block&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;9jV4kd&lt;/code&gt; delete the empty lines left after cutting&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Typing in &lt;code&gt;2@q&lt;/code&gt; performs this action twice combining all lines&lt;/p&gt;&#xA;" OwnerUserId="6793" LastEditorUserId="6793" LastEditDate="2016-03-13T13:02:45.930" LastActivityDate="2016-03-13T13:02:45.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6862" PostTypeId="1" AcceptedAnswerId="6865" CreationDate="2016-03-13T14:50:12.103" Score="8" ViewCount="1052" Body="&lt;p&gt;Is it possible to print a conditional string on the statusline?  e.g. &lt;code&gt;GREEK&lt;/code&gt; if iminsert=1 and &lt;code&gt;LATIN&lt;/code&gt; otherwise?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-03-13T15:24:14.960" Title="Conditional strings on the statusline" Tags="|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6863" PostTypeId="2" ParentId="6859" CreationDate="2016-03-13T15:08:09.297" Score="3" Body="&lt;p&gt;Another macro solution:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First go to the beginning of the first paragraph (in your example with &lt;code&gt;10G&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Then record macro: &lt;kbd&gt;qq&lt;/kbd&gt;&lt;kbd&gt;Ctrl-Shit-V&lt;/kbd&gt;&lt;kbd&gt;}&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Reuse the macro with &lt;kbd&gt;@q&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The detail of the macro:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-Shit-V&lt;/kbd&gt; start visual block mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;}&lt;/kbd&gt; select to the last line of the paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;$&lt;/kbd&gt; select to the end of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;d&lt;/kbd&gt; delete the selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;5k&lt;/kbd&gt; go to the first line of the previous paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;$&lt;/kbd&gt; got to the end of this line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;p&lt;/kbd&gt; past the previously deleted paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;0&lt;/kbd&gt; go to the beginning of the line to be able to repeat the macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-03-13T15:08:09.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6864" PostTypeId="2" ParentId="6859" CreationDate="2016-03-13T15:08:46.543" Score="3" Body="&lt;p&gt;What you do is almost .. graphical, so I'd use the mouse!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(of course you need &lt;code&gt;:set mouse+=a&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Select a block with the mouse, then &lt;code&gt;Ctrl-v&lt;/code&gt; &lt;code&gt;y&lt;/code&gt; to yank the selection in &quot;control-block&quot; mode (&amp;lt;- that's the &quot;secret&quot; sauce). Still using the mouse, place cursor on top right character of the 2nd block. Paste (&lt;code&gt;p&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Repeat :D ... That's all!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, it's probably not feasible for a macro, or a large number of repetitions, but how long a line do you want to make?&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-03-13T15:08:46.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6865" PostTypeId="2" ParentId="6862" CreationDate="2016-03-13T15:08:56.433" Score="8" Body="&lt;p&gt;From &lt;code&gt;:help 'statusline'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The result can contain %{} items that will be evaluated too.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if you write an expression inside &lt;code&gt;%{}&lt;/code&gt; and add it to your &lt;code&gt;'statusline'&lt;/code&gt; option, it should be evaluated and the result displayed. Here, your expression would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;amp;iminsert==1?'GREEK':'LATIN'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The syntax of this expression is described in &lt;code&gt;:help expr1&lt;/code&gt;; if the test before the question mark succeeds (here &lt;code&gt;&amp;amp;iminsert == 1&lt;/code&gt;), the evaluation of the expression is the value just after the question mark, otherwise if it fails, it's the value after the colon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To add this expression to your &lt;code&gt;'statusline'&lt;/code&gt; value, you could write in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{&amp;amp;iminsert==1?'GREEK':'LATIN'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-03-13T15:24:14.960" LastActivityDate="2016-03-13T15:24:14.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6866" PostTypeId="2" ParentId="6853" CreationDate="2016-03-13T15:09:07.933" Score="1" Body="&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; the answer below doesn't count for the current release 0.2, both examples work there.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It seems that neovim was a bit buggy on this topic.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; works in neovim&#xA;:ab ms Microsoft&#xA;&#xA;&#xA;&quot; doesn't work in neovim&#xA;:ab ß \ss{}      &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;=&gt; my solution was to move back to vim for now. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;a href=&quot;https://github.com/toogley/dotfiles/tree/593f8f89b2e1633a27e9d501a3a639cb4f34380b/nvim&quot; rel=&quot;nofollow&quot;&gt;my nvim config&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="2354" LastEditDate="2016-03-14T18:48:56.893" LastActivityDate="2016-03-14T18:48:56.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6867" PostTypeId="1" AcceptedAnswerId="6885" CreationDate="2016-03-13T15:37:15.993" Score="6" ViewCount="513" Body="&lt;p&gt;I would like to highlight all the HereDocs in a particular perl file as perl code. For example, I'd like to apply the normal perl highlighting to the subroutine in this HereDoc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my $code = &amp;lt;&amp;lt;'CODE';&#xA;   sub test {&#xA;      say &quot;this is a test&quot;;&#xA;   };&#xA;CODE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought I could do this with something like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region perlHereDocPL    start=+&amp;lt;&amp;lt;\s*'\z([^\\']*\%(\\.[^\\']*\)*\)'+ matchgroup=perlSnip end=+^\z1$+ contains=@perlTop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But apparently this doesn't work like I thought it did. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="6568" LastActivityDate="2016-03-15T12:55:42.987" Title="Highlight heredoc as perl code" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6868" PostTypeId="1" CreationDate="2016-03-13T17:53:52.230" Score="6" ViewCount="926" Body="&lt;p&gt;I would like to install the Vim plugin &quot;vim-devicons&quot;. But I am unable to install the patched font &quot;Hack&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I copied the following &lt;a href=&quot;https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/Hack/Regular/complete/Knack%20Regular%20Nerd%20Font%20Complete%20Mono.ttf&quot; rel=&quot;noreferrer&quot; title=&quot;file&quot;&gt;file&lt;/a&gt; into &lt;code&gt;~/.local/shared/fonts&lt;/code&gt;. The installation of the font seems okay to me because I am able to select it in Libre Office. But I can't choose it in the terminal. It won't show up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After copying into &lt;code&gt;~/.local/shared/fonts&lt;/code&gt; I ran the following command: &lt;code&gt;fc-cache -f -v&lt;/code&gt;. Rebooted for the third time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running Kubuntu 15.10 with the standard terminal (zsh).&lt;/p&gt;&#xA;" OwnerUserId="6797" LastEditorUserId="51" LastEditDate="2016-03-13T19:38:17.813" LastActivityDate="2016-03-13T19:38:17.813" Title="Patched font for devicons doesn't show up in terminal" Tags="|terminal|plugin-devicons|" AnswerCount="0" CommentCount="5" ClosedDate="2019-04-15T23:47:02.980" ContentLicense="CC BY-SA 3.0" />
  <row Id="6869" PostTypeId="1" CreationDate="2016-03-13T18:29:09.163" Score="3" ViewCount="1647" Body="&lt;p&gt;I would like to create a dictionary variable for a vimL script. That dictionary will hold information related to a folder structure. However, I have a bit of hard time designing this variable and also I came across some difficulties while handling the information stored in that variable. Below is an example dictionary variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:myTree = { &#xA;        \ 'base' : {&#xA;            \ 'path' : '__base',&#xA;            \ 'main' : {'path' : '__base/__main'},&#xA;            \ 'config' : {&#xA;                \ 'path' : '__base/__/config',&#xA;                \ 'modules' : {'path' : '__base/__config/__modules'},&#xA;                \ 'settings': {&#xA;                    \ 'path' : '__base/__config/__settings',&#xA;                    \ 'gui' : {&#xA;                        \ 'path' : '__base/__config/__settings/__gui',&#xA;                        \ 'linux' : {'path' : '__base/__config/__settings/__gui/__linux'},&#xA;                        \ },&#xA;                    \ },&#xA;                \ },&#xA;            \ },&#xA;        \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea was to be able to access the data bits with the &lt;code&gt;.&lt;/code&gt; notation. For example &lt;code&gt;g:myTree.base&lt;/code&gt; should return &lt;code&gt;__base&lt;/code&gt;. However, I have noticed that I need an additional key &lt;code&gt;path&lt;/code&gt; in order to be able to package the nested information, so the access is done through &lt;code&gt;g:myTree.base.path&lt;/code&gt; for &lt;code&gt;__base&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The first questions would be:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to avoid the use of &lt;code&gt;path&lt;/code&gt; and directly access the data in the following format:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:myTree.base&lt;/code&gt; for &lt;code&gt;__base&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:myTree.base.main&lt;/code&gt; for &lt;code&gt;__base/__main&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:myTree.base.config.modules&lt;/code&gt; for &lt;code&gt;__base/__config/__modules&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:myTree.base.config.settings.gui.linux&lt;/code&gt; for &lt;code&gt;__base/__config/__settings/__gui/__linux&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The second question would be:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do we iterate and access (or modify) the data bits stored in the &lt;code&gt;path&lt;/code&gt; key throughout the whole depth of the dictionary. I have encountered a problem due to the fact that the &lt;code&gt;path&lt;/code&gt; key stores a &lt;code&gt;string&lt;/code&gt; value but the next key would be storing a dictionary value. This creates a variable mismatch when iterating through the dictionary. What would be the solution to this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="51" LastEditDate="2016-03-14T05:15:10.573" LastActivityDate="2016-03-14T05:15:10.573" Title="How to handle a nested dictionary with mixed key/values?" Tags="|vimscript|variables|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6870" PostTypeId="1" CreationDate="2016-03-13T18:42:58.563" Score="1" ViewCount="45" Body="&lt;p&gt;I have this mapping in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F3&amp;gt; :%s/ä/\\&quot;{a}/g&amp;lt;CR&amp;gt; :%s/ö/\\&quot;{o}/g&amp;lt;CR&amp;gt; :%s/ü/\\&quot;{u}/g&amp;lt;CR&amp;gt;  :%s/ß/\ss{}/g&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after executing it, an 'R' is inserted above the current line, which of course doesn't make sense at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the same applies to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F3&amp;gt; :%s/ä/\\&quot;{a}/g&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I debug this? Is this mapping even possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; &lt;a href=&quot;https://github.com/toogley/dotfiles/blob/c8aad072a4335624884ac9ca1ed60ad231ec5193/vim/vimrc#L301&quot; rel=&quot;nofollow&quot;&gt;my vim config&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="51" LastEditDate="2016-03-13T19:41:16.423" LastActivityDate="2016-03-13T19:41:16.423" Title="mapping with multiple substitutes inserts just a newline with 'R'" Tags="|key-bindings|substitute|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6871" PostTypeId="2" ParentId="6869" CreationDate="2016-03-13T19:14:14.353" Score="3" Body="&lt;p&gt;I don't think you can set a key as the &quot;default&quot; for a dictionary. You should probably look into the other supported scripting languages, like Python or Ruby.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the second problem, you can check the type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RecurseForPath(dict)&#xA;    for key in keys(a:dict)&#xA;        if key == 'path'&#xA;            echo a:dict[key]&#xA;        elseif type(a:dict[key]) == type({})&#xA;            call RecurseForPath(a:dict[key])&#xA;        endif&#xA;    endfor&#xA;endfunction&#xA;&#xA;call RecurseForPath(myTree)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#type%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h type&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;type({expr})    The result is a Number, depending on the type of {expr}:&#xA;                        Number:     0&#xA;                        String:     1&#xA;                        Funcref:    2&#xA;                        List:       3&#xA;                        Dictionary: 4&#xA;                        Float:      5&#xA;                        Boolean:    6 (v:false and v:true)&#xA;                        None        7 (v:null and v:none)&#xA;                        Job         8&#xA;                        Channel     9&#xA;                To avoid the magic numbers it should be used this way: &#xA;                        :if type(myvar) == type(0)&#xA;                        :if type(myvar) == type(&quot;&quot;)&#xA;                        :if type(myvar) == type(function(&quot;tr&quot;))&#xA;                        :if type(myvar) == type([])&#xA;                        :if type(myvar) == type({})&#xA;                        :if type(myvar) == type(0.0)&#xA;                        :if type(myvar) == type(v:false)&#xA;                        :if type(myvar) == type(v:none)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output, with the variable from the question, is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;__base&#xA;__base/__main&#xA;__base/__/config&#xA;__base/__config/__modules&#xA;__base/__config/__settings/__gui/__linux&#xA;__base/__config/__settings/__gui&#xA;__base/__config/__settings&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-03-13T19:34:04.217" LastActivityDate="2016-03-13T19:34:04.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6872" PostTypeId="2" ParentId="6860" CreationDate="2016-03-13T20:43:17.670" Score="4" Body="&lt;p&gt;I'm not sure what you exactly mean with &quot;change this string&quot;; always change it globally? Change it depending on a setting? Change it at will?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At any rate, the &lt;code&gt;INSERT&lt;/code&gt; text is inserted with gettext in &lt;code&gt;screen.c&lt;/code&gt;, around line 10,049:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MSG_PUTS_ATTR(_(&quot; INSERT&quot;), attr);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;(lang)&lt;/code&gt; part is added in a similar way a few lines later (with some cruft removed):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (State &amp;amp; LANGMAP)&#xA;{&#xA;        MSG_PUTS_ATTR(_(&quot; (lang)&quot;), attr);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can change this text from a gettext po file (or just change the C source and recompile), but then it's &lt;em&gt;always&lt;/em&gt; changed.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-03-13T20:43:17.670" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6873" PostTypeId="2" ParentId="6869" CreationDate="2016-03-13T21:03:30.670" Score="3" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;The idea was to be able to access the data bits with the &lt;code&gt;.&lt;/code&gt; notation. For example &lt;code&gt;g:myTree.base&lt;/code&gt; should return &lt;code&gt;__base&lt;/code&gt;. However, I have noticed that I need an additional key path in order to be able to package the nested information, so the access is done through &lt;code&gt;g:myTree.base.path&lt;/code&gt; for &lt;code&gt;__base&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is not really how dictionaries (or hashes, or tables, or whatever your preferred term is) work in any language as far as I know. In fact, I can't see how it &lt;em&gt;could&lt;/em&gt; conceivably work.&lt;/p&gt;&#xA;&lt;p&gt;How would you disambiguate between calling &lt;code&gt;g:myTree.base&lt;/code&gt; when you really want to get this dict, and &lt;code&gt;g:myTree.base&lt;/code&gt; when you want &lt;code&gt;g:myTree.base.__base&lt;/code&gt;? There is no real way to to that.&lt;/p&gt;&#xA;&lt;p&gt;Even in more advanced languages with operator overloading, such as Python or Ruby, it would actually be a challenge to implement this; in Python we could override the &lt;code&gt;__getitem()__&lt;/code&gt; method, but that doesn't get called when we merely reference a dict. I would be surprised if anyone would be able to come up with a working implementation of this to be honest.&lt;/p&gt;&#xA;&lt;p&gt;What you &lt;em&gt;can&lt;/em&gt; do is assign functions to dictionaries to return the values you want; this is sort of like &amp;quot;poor man's object oriented programming&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;I'm not entirely sure what your task is or what you're trying to do, so I'm not sure if this is the &amp;quot;right tool for the right job&amp;quot;, but it could very well be.&lt;/p&gt;&#xA;&lt;p&gt;A simple example might look like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:full_path() dict&#xA;    return self.base . self.path&#xA;endfun&#xA;&#xA;let g:my_tree = {&#xA;    \ 'base': '/home/martin/',&#xA;    \ 'path': '.vim',&#xA;    \ 'full_path': function(&amp;quot;s:full_path&amp;quot;),&#xA;\}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And when calling &lt;code&gt;:echo g:my_tree.full_path()&lt;/code&gt; you will get &lt;code&gt;/home/martin/.vim&lt;/code&gt;.  See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#Dictionary%2dfunction&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help Dictionary-function&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#Funcref&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help Funcref&lt;/code&gt;&lt;/a&gt; for the full documentation.&lt;/p&gt;&#xA;&lt;p&gt;You could emulate &lt;em&gt;part&lt;/em&gt; of the behaviour described in your answer; but I'm not sure if that would be a sane thing to do.&lt;/p&gt;&#xA;&lt;p&gt;Above all, remember Eric S. Raymond's &amp;quot;Rule of Representation&amp;quot; from &lt;a href=&quot;http://catb.org/%7Eesr/writings/taoup/html/ch01s06.html#id2878263&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Art of Unix Programming&lt;/a&gt; (it's free!):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Rule of Representation: Fold knowledge into data, so program logic can be stupid and robust.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Even the simplest procedural logic is hard for humans to verify, but quite complex data structures are fairly easy to model and reason about. To see this, compare the expressiveness and explanatory power of a diagram of (say) a fifty-node pointer tree with a flowchart of a fifty-line program. Or, compare an array initializer expressing a conversion table with an equivalent switch statement. The difference in transparency and clarity is dramatic. See Rob Pike's Rule 5.&lt;/p&gt;&#xA;&lt;p&gt;Data is more tractable than program logic. It follows that where you see a choice between complexity in data structures and complexity in code, choose the former. More: in evolving a design, you should actively seek ways to shift complexity from code to data.&lt;/p&gt;&#xA;&lt;p&gt;The Unix community did not originate this insight, but a lot of Unix code displays its influence. The C language's facility at manipulating pointers, in particular, has encouraged the use of dynamically-modified reference structures at all levels of coding from the kernel upward. Simple pointer chases in such structures frequently do duties that implementations in other languages would instead have to embody in more elaborate procedures.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;As for the second part of your question, I believe muru already did a good job of answering that, so I'll not repeat it here ;-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-03-13T21:33:44.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6874" PostTypeId="2" ParentId="6859" CreationDate="2016-03-13T21:26:36.733" Score="2" Body="&lt;p&gt;Here's another way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure the &lt;code&gt;a&lt;/code&gt; register is empty&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a = ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Match all lines starting with &lt;code&gt;aa&lt;/code&gt;, and then append them to the &lt;code&gt;a&lt;/code&gt; register with &lt;code&gt;y&lt;/code&gt; (the capital &lt;code&gt;A&lt;/code&gt; means append, rather than overwrite). After that delete the line with &lt;code&gt;d&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^aa/y A | d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now we can paste this at the start of the buffer (or anywhere else you'd like):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1G&quot;aP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And join them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4gJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Repeat for &lt;code&gt;bbb&lt;/code&gt;, &lt;code&gt;ccc&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last step is perhaps easier done as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnnngJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which starts visual mode with &lt;code&gt;v&lt;/code&gt;, &lt;code&gt;n&lt;/code&gt; to skip past the lines, and then &lt;code&gt;J&lt;/code&gt; to join them. You could also press &lt;code&gt;J&lt;/code&gt; a few times in a row...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v/^bbb&amp;lt;Enter&amp;gt;kgJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which searches for &lt;code&gt;/^bbb&lt;/code&gt;, this has the advantage that the last used search pattern is now &quot;primed&quot; for our next &lt;code&gt;:g&lt;/code&gt; invocation, which can now read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g//y A | d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not specifying a pattern will use the last used search pattern (i.e. the &lt;code&gt;@/&lt;/code&gt; register).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-03-22T10:05:49.307" LastActivityDate="2016-03-22T10:05:49.307" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6875" PostTypeId="1" CreationDate="2016-03-13T22:08:22.773" Score="5" ViewCount="1726" Body="&lt;p&gt;I use 32bit gvim 7.4 on Win7 64bit CZ. I replaced the gettext and iconv libraries according to the guide on the vim website. I wanted to use utf-8 and have setup the &lt;code&gt;guifont&lt;/code&gt;, &lt;code&gt;encoding&lt;/code&gt; and &lt;code&gt;fileencoding&lt;/code&gt; options. I use the Czech localization (which is somehow default, probably based on OS language). Up to this point, everything is working fine. The content of utf-8 encoded files is read, rendered and written as expected. Even the gvim messages (like warnings or infos) using the &lt;code&gt;guifont&lt;/code&gt; renders as expected (in cs_CZ). But...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The application menu font is not able to render the international characters. Seems like it's using different encoding. Some characters are completely missing, some use weird symbols.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way, how to change the font/encoding the gvim.exe is using for the &lt;strong&gt;menu rendering&lt;/strong&gt; (the menu bar also as the contextual &quot;mouse&quot; menu)?&lt;/p&gt;&#xA;" OwnerUserId="6800" LastActivityDate="2017-08-20T20:05:44.773" Title="gvim incorrect font (or encoding) in menu" Tags="|gvim|microsoft-windows|font|encoding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6876" PostTypeId="1" CreationDate="2016-03-14T01:34:50.423" Score="4" ViewCount="68" Body="&lt;p&gt;For context, see &lt;a href=&quot;https://vi.stackexchange.com/q/6784/205&quot;&gt;How can I automate filetype detection when using sudoedit?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say &lt;code&gt;filea&lt;/code&gt; has &lt;code&gt;filetype&lt;/code&gt; &lt;code&gt;foo&lt;/code&gt;, which is detected based on varying factors, including the name, the full path or the contents of the file (or combinations thereof). I have a buffer containing &lt;code&gt;filea&lt;/code&gt;'s contents, and I want to apply &lt;code&gt;filea&lt;/code&gt;'s &lt;code&gt;filetype&lt;/code&gt;, without actually opening &lt;code&gt;filea&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume that I already have the path and name of the file, and the contents are in the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I go about this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that I may not be able to open the actual file. A simple example is Polkit configuration in Ubuntu systems. Files in &lt;code&gt;/etc/polkit-1/localauthority&lt;/code&gt; are accessible only to root.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Thanks to Carpetsmoker's tip about &lt;code&gt;:filetype detect&lt;/code&gt;, I came up with one way. Something like the following could do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function SetActualFiletype (actual_path)&#xA;    let l:cur_file=expand('%')&#xA;    exec 'file' fnameescape(a:actual_path)&#xA;    filetype detect&#xA;    exec 'file' fnameescape(cur_file)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, Vim has access to everything it would normally have when opening that file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This isn't safe from &lt;code&gt;autocmd&lt;/code&gt;s which are writing the file (and other such oddities).&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-03-14T03:17:14.030" Title="Can I apply one file's filetype to another, without actually opening the first file?" Tags="|filetype|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6877" PostTypeId="5" CreationDate="2016-03-14T03:56:51.040" Score="0" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/garbas/vim-snipmate&quot; rel=&quot;nofollow&quot;&gt;Homepage&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2540&quot; rel=&quot;nofollow&quot;&gt;Vim Script&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: There is also a second github repository:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/msanders/snipmate.vim&quot; rel=&quot;nofollow&quot;&gt;Homepage&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;which points to the same Vim Script.&lt;/p&gt;&#xA;" OwnerUserId="1708" LastEditorUserId="1708" LastEditDate="2016-03-14T05:16:02.153" LastActivityDate="2016-03-14T05:16:02.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6878" PostTypeId="4" CreationDate="2016-03-14T03:56:51.040" Score="0" Body="Adds &quot;Snippets&quot; to Vim, which allows you to quickly add pre-defined pieces of text with only a few keystrokes." OwnerUserId="1708" LastEditorUserId="1708" LastEditDate="2016-03-14T05:15:21.043" LastActivityDate="2016-03-14T05:15:21.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6879" PostTypeId="1" CreationDate="2016-03-14T05:48:40.477" Score="9" ViewCount="1324" Body="&lt;p&gt;C++14 provided us with the option of using single quotes to separate the digits of large numeric literals. This breaks Vim's syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, consider the following C++14 program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&#xA;&#xA;int main(int argc, char** argv) {&#xA;  // small numbers are fine&#xA;  int normal_number = 5;&#xA;&#xA;  // large numbers have the correct highlighting but they're hard to visually parse&#xA;  int huge_number = 1000000000;&#xA;&#xA;  // apostrophes help with visual parsing but mess up syntax higlighting&#xA;  int huge_number_again = 1'000'000'000;&#xA;&#xA;  return EXIT_SUCCESS;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I view this in Vim, I see the following syntax highlighting (note that I am using some &lt;a href=&quot;https://github.com/octol/vim-cpp-enhanced-highlight&quot; rel=&quot;nofollow noreferrer&quot;&gt;additional highlighting scripts&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mQquZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mQquZ.png&quot; alt=&quot;Vim syntax highlighting for the program described above&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like all of the digits in &lt;code&gt;huge_number_again&lt;/code&gt; to appear red. Is there a modification I can make to one of my syntax files or to my &lt;code&gt;~/.vimrc&lt;/code&gt; to correct this?&lt;/p&gt;&#xA;" OwnerUserId="6807" LastEditorUserId="1708" LastEditDate="2016-03-15T07:07:27.883" LastActivityDate="2016-08-30T10:02:16.430" Title="Vim syntax highlighting of numeric literals with single-quote digit separators" Tags="|syntax-highlighting|filetype-c++|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6880" PostTypeId="1" AcceptedAnswerId="6883" CreationDate="2016-03-14T09:01:56.843" Score="4" ViewCount="1365" Body="&lt;p&gt;&lt;code&gt;:help startup&lt;/code&gt; states, under &lt;code&gt;3. Execute Ex commands, from environment variables and/or files&lt;/code&gt; that (for Unix systems) &lt;code&gt;$HOME/.vimrc or $HOME/.vim/vimrc&lt;/code&gt; is read and that &lt;code&gt;The files are searched in the order specified above and only the first one that is found is read.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;do&lt;/em&gt; have a (read/writeable) ~/.vim/vimrc file, so I have expected this file to be read first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I start &lt;code&gt;gvim&lt;/code&gt; (debugged with the &lt;code&gt;-V20&lt;/code&gt; flag) I see that gvim first reads &lt;code&gt;/usr/share/vim/vimrc&lt;/code&gt;. When it is finished reading this file, it &lt;em&gt;then&lt;/em&gt; reads my &lt;code&gt;~/.vim/vimrc&lt;/code&gt; file. I don't want the &lt;code&gt;/usr/share/vim/vimrc&lt;/code&gt; file to be read at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The environment variable &lt;code&gt;$VIM&lt;/code&gt; is not set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly (and somewhat surprisingly for me): after gvim is started up fully, &lt;code&gt;:echo $MYVIMRC&lt;/code&gt; prints &lt;code&gt;/home/rene/.vim/vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my questions are: why does it behave differently from what is stated in the help file and how do I make sure that only &lt;code&gt;~/.vim/vimrc&lt;/code&gt; is read.&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="985" LastEditDate="2016-03-14T10:58:27.043" LastActivityDate="2016-03-14T13:45:18.437" Title="Why does gvim read /usr/share/vim/vimrc instead of ~/.vim/vimrc" Tags="|vimrc|linux|startup|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6881" PostTypeId="2" ParentId="6099" CreationDate="2016-03-14T10:30:54.697" Score="0" Body="&lt;p&gt;Well, it seems that the problem is gone. I didn't even notice when this happened, but I'm fine with that&lt;/p&gt;&#xA;" OwnerUserId="5965" LastActivityDate="2016-03-14T10:30:54.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6883" PostTypeId="2" ParentId="6880" CreationDate="2016-03-14T13:45:18.437" Score="9" Body="&lt;p&gt;Reading system-level configuration before user-level configuration is totally normal and expected in UNIX land.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, this sentence:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The files are searched in the order specified above and only the first one&#xA;that is found is read.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;only applies to &quot;personal initializations&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As explained a few paragraphs below, the system &lt;code&gt;vimrc&lt;/code&gt; is read no matter what: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b. For Unix, MS-DOS, MS-Windows, OS/2, VMS, Macintosh, RISC-OS and Amiga&#xA;   the system vimrc file is read for initializations.  The path of this&#xA;   file is shown with the &quot;:version&quot; command.  Mostly it's &quot;$VIM/vimrc&quot;.&#xA;   Note that this file is ALWAYS read in 'compatible' mode, since the&#xA;   automatic resetting of 'compatible' is only done later.  Add a &quot;:set&#xA;   nocp&quot; command if you like.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-03-14T13:45:18.437" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6884" PostTypeId="1" AcceptedAnswerId="6931" CreationDate="2016-03-14T15:24:35.360" Score="2" ViewCount="993" Body="&lt;p&gt;I am unable to start Vdebug. I am using Vim-Plug to handle my plugins, &lt;code&gt;:PlugStatus&lt;/code&gt; on a PHP file gives a status of &lt;code&gt;OK&lt;/code&gt;. However, when I press &lt;kbd&gt;F5&lt;/kbd&gt;, Vdebug is not started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone has any idea what is going wrong? I also tried to change the mappings, but this had no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using xfce4-terminal, and here is &lt;a href=&quot;https://github.com/rbnvrw/.dotfiles/blob/master/vimrc&quot; rel=&quot;nofollow&quot;&gt;my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim:fdm=marker:foldlevel=0&#xA;&quot; Vim settings for Ruben Verweij&#xA;&quot; Use Vim mode {{{&#xA;set nocompatible&#xA;&quot; }}}&#xA;&quot; Set encoding and file formats {{{&#xA;set encoding=utf-8 nobomb&#xA;scriptencoding utf-8&#xA;set fileformats=unix,mac,dos&#xA;set fileformat=unix&#xA;&quot; }}}&#xA;&quot; Use Plug for plugin management {{{&#xA;if empty(glob(&quot;~/.vim/autoload/plug.vim&quot;))&#xA;    execute '!curl -fLo ~/.vim/autoload/plug.vim https://raw.github.com/junegunn/vim-plug/master/plug.vim'&#xA;endif&#xA;call plug#begin('~/.vim/plugged')&#xA;&quot; }}}&#xA;&quot; Backup and undo settings {{{&#xA;if has(&quot;vms&quot;)&#xA;    set nobackup      &quot; do not keep a backup file, use versions instead&#xA;else&#xA;    set backup        &quot; keep a backup file (restore to previous version)&#xA;    set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp&#xA;    set backupskip=/tmp/*,/private/tmp/*&#xA;    set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp&#xA;    set writebackup&#xA;    set undofile      &quot; keep an undo file (undo changes after closing)&#xA;    set undolevels=500&#xA;    set undoreload=500&#xA;endif&#xA;set history=50      &quot; keep 50 lines of command line history&#xA;&quot; }}}&#xA;&quot; Langnoremap setting {{{&#xA;if has('langmap') &amp;amp;&amp;amp; exists('+langnoremap')&#xA;    &quot; Prevent that the langmap option applies to characters that result from a&#xA;    &quot; mapping.  If unset (default), this may break plugins (but it's backward&#xA;    &quot; compatible).&#xA;    set langnoremap&#xA;endif&#xA;&quot; }}}&#xA;&quot; Basic shortcuts (leader) {{{&#xA;&quot; Leader key&#xA;let mapleader=&quot;,&quot;&#xA;let maplocalleader=&quot;,,&quot;&#xA;&quot; Ever notice a slight lag after typing the leader key + command? This lowers&#xA;&quot; the timeout.&#xA;set timeoutlen=500&#xA;&quot; }}}&#xA;&quot; Movement commands {{{&#xA;&quot; move vertically by visual line&#xA;nnoremap j gj&#xA;nnoremap k gk&#xA;&quot; }}}&#xA;&quot; Insert mode misc settings {{{&#xA;&quot; allow backspacing over everything in insert mode&#xA;set backspace=indent,eol,start&#xA;&quot; }}}&#xA;&quot; Autoformat options {{{&#xA;set formatoptions=&#xA;set formatoptions+=c                  &quot; Auto-wrap comments using textwidth&#xA;set formatoptions+=r                  &quot; Continue comments by default&#xA;set formatoptions-=o                  &quot; do not continue comment using o or O&#xA;set formatoptions+=q                  &quot; continue comments with gq&#xA;set formatoptions+=n                  &quot; Recognize numbered lists&#xA;set formatoptions+=2                  &quot; Use indent from 2nd line of a paragraph&#xA;set formatoptions+=l                  &quot; Don't break lines that are already long&#xA;set formatoptions+=1                  &quot; Break before 1-letter words&#xA;&quot; Vim 7.4 only: no // comment when joining commented lines&#xA;if v:version &amp;gt;= 704 | set formatoptions+=j | endif&#xA;&quot; }}}&#xA;&quot; Syntax highlighting {{{&#xA;&quot; Switch syntax highlighting on, when the terminal has colors&#xA;syntax on&#xA;&quot; }}}&#xA;&quot; Omnicomplete settings {{{&#xA;set omnifunc=syntaxcomplete#Complete&#xA;set completeopt=longest,menuone&#xA;&quot; }}}&#xA;&quot; Text wrapping and tab widths {{{&#xA;set wrap&#xA;set textwidth=80&#xA;&quot; highlight just the 81st column of wide lines... (Damien Conway)&#xA;highlight ColorColumn ctermbg=magenta&#xA;call matchadd('ColorColumn', '\%81v', 100)&#xA;&#xA;&quot; tabwidth&#xA;set tabstop=4       &quot; visual spaces per tab&#xA;set softtabstop=4   &quot; spaces when editing&#xA;set shiftwidth=4&#xA;set expandtab&#xA;&quot; }}}&#xA;&quot; Autowrite settings {{{&#xA;&quot; Write the old file out when switching between files.&#xA;set autowrite&#xA;&quot; Saves file when Vim window loses focus&#xA;au FocusLost * :wa&#xA;&quot; Save file with sudo powers&#xA;cmap w!! w !sudo tee %&#xA;&quot; }}}&#xA;&quot; Jump to last cursor position {{{&#xA;augroup vimrcEx&#xA;    au!&#xA;&#xA;    &quot; When editing a file, always jump to the last known cursor position.&#xA;    &quot; Don't do it when the position is invalid or when inside an event handler&#xA;    &quot; (happens when dropping a file on gvim).&#xA;    autocmd BufReadPost *&#xA;                \ if line(&quot;'\&quot;&quot;) &amp;gt;= 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) |&#xA;                \   exe &quot;normal! g`\&quot;&quot; |&#xA;                \ endif&#xA;augroup END&#xA;&quot; }}}&#xA;&quot; Search settings {{{&#xA;set ignorecase  &quot; case insensitive search&#xA;set smartcase   &quot; only case sensitive when typing capitals&#xA;set incsearch   &quot; do incremental searching&#xA;set hlsearch    &quot; highlight search matches&#xA;&quot; }}}&#xA;&quot; Folding settings {{{&#xA;&quot; Enable code folding&#xA;set foldenable&#xA;&quot; Use space to toggle folds and create folds&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Space&amp;gt; @=(foldlevel('.')?'za':&quot;\&amp;lt;Space&amp;gt;&quot;)&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;Space&amp;gt; zf&#xA;&quot; Set foldmethod to indent and allow manual&#xA;augroup vimrc&#xA;    au BufReadPre * setlocal foldmethod=indent&#xA;    au BufWinEnter * if &amp;amp;fdm == 'indent' | setlocal foldmethod=manual | endif&#xA;augroup END&#xA;set foldlevelstart=10   &quot; Open most folds by default&#xA;set foldnestmax=10      &quot; 10 nested folds max&#xA;&quot; }}}&#xA;&quot; Git settings {{{&#xA;&quot; Ignore whitespaces with git diffs&#xA;set diffopt+=iwhite&#xA;&quot; }}}&#xA;&quot; Plug plugins {{{&#xA;Plug 'kien/ctrlp.vim'&#xA;Plug 'ervandew/supertab'&#xA;Plug 'shawncplus/phpcomplete.vim', { 'for': 'php' }&#xA;Plug 'StanAngeloff/php.vim', { 'for': 'php' }&#xA;Plug 'scrooloose/syntastic'&#xA;Plug 'joonty/vdebug', { 'for': 'php' }&#xA;Plug 'vim-airline/vim-airline'&#xA;Plug 'tpope/vim-commentary'&#xA;Plug 'skammer/vim-css-color', { 'for': 'css' }&#xA;Plug 'tpope/vim-fugitive'&#xA;Plug 'tpope/vim-git'&#xA;Plug 'airblade/vim-gitgutter'&#xA;Plug 'pangloss/vim-javascript', { 'for': 'javascript' }&#xA;Plug 'heavenshell/vim-jsdoc', { 'for': 'javascript' }&#xA;Plug 'leshill/vim-json', { 'for': 'json' }&#xA;Plug 'xolox/vim-misc'&#xA;Plug 'tpope/vim-repeat'&#xA;Plug 'vim-latex/vim-latex', { 'for': 'latex' }&#xA;Plug 'kshenoy/vim-signature'&#xA;Plug 'ntpeters/vim-better-whitespace'&#xA;Plug 'Chiel92/vim-autoformat'&#xA;Plug 'hynek/vim-python-pep8-indent', { 'for': 'python' }&#xA;Plug 'majutsushi/tagbar'&#xA;Plug 'ivalkeen/vim-ctrlp-tjump'&#xA;Plug 'Valloric/YouCompleteMe', { 'do': './install.py --tern-completer' }&#xA;&quot; }}}&#xA;&quot; Vim airline {{{&#xA;let g:airline#extensions#tabline#enabled = 1&#xA;let g:airline_enable_branch     = 1&#xA;set laststatus=2&#xA;let g:airline_powerline_fonts = 1&#xA;&quot; }}}&#xA;&quot; YouCompleteMe {{{&#xA;let g:ycm_key_list_select_completion = ['&amp;lt;C-TAB&amp;gt;', '&amp;lt;Down&amp;gt;']&#xA;let g:ycm_key_list_previous_completion = ['&amp;lt;C-S-TAB&amp;gt;', '&amp;lt;Up&amp;gt;']&#xA;let g:ycm_collect_identifiers_from_tags_files = 1&#xA;let g:ycm_path_to_python_interpreter = '/usr/bin/python'&#xA;let g:SuperTabDefaultCompletionType = '&amp;lt;C-Tab&amp;gt;'&#xA;&quot; }}}&#xA;&quot; CtrlP {{{&#xA;set updatetime=250&#xA;let g:ctrlp_map = '&amp;lt;c-p&amp;gt;'&#xA;let g:ctrlp_working_path_mode = 'ra'&#xA;let g:ctrlp_reuse_window = 1            &quot; Use same window&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;b :CtrlPBuffer&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;t :CtrlPTag&amp;lt;CR&amp;gt;&#xA;&quot; CtrlP tjump&#xA;nnoremap &amp;lt;c-]&amp;gt; :CtrlPtjump&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;c-]&amp;gt; :CtrlPtjumpVisual&amp;lt;cr&amp;gt;&#xA;&quot; Ignore settings&#xA;set wildignore+=*/vendor/**&#xA;&quot;}}}&#xA;&quot; The Silver Searcher {{{&#xA;&quot; Use ag over grep&#xA;set grepprg=ag\ --nogroup\ --nocolor&#xA;&#xA;&quot; Use ag in CtrlP for listing files. Lightning fast and respects&#xA;&quot; .gitignore&#xA;let g:ctrlp_user_command = 'ag %s -l --nocolor -g &quot;&quot;'&#xA;&#xA;&quot; ag is fast enough that CtrlP doesn't need to cache&#xA;let g:ctrlp_use_caching = 0&#xA;&#xA;&quot; define :Ag&#xA;if !exists(&quot;:Ag&quot;)&#xA;    command -nargs=+ -complete=file -bar Ag silent! grep! &amp;lt;args&amp;gt;|cwindow|redraw!&#xA;endif&#xA;&#xA;&quot; bind K to grep word under cursor&#xA;nnoremap K :silent! grep! &quot;\b&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;\b&quot;&amp;lt;CR&amp;gt;:cw&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; bind \ (backward slash) to grep shortcut&#xA;nnoremap \ :Ag&amp;lt;SPACE&amp;gt;&#xA;&quot; }}}&#xA;&quot; GitGutter {{{&#xA;let g:gitgutter_grep_command = 'ag --nocolor'&#xA;&quot; }}}&#xA;&quot; Syntastic {{{&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_loc_list_height = 5&#xA;let g:syntastic_auto_loc_list = 0&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 1&#xA;let g:syntastic_id_checkers = 1&#xA;let g:syntastic_aggregate_errors = 1&#xA;let g:syntastic_javascript_checkers = ['eslint']&#xA;let g:syntastic_python_python_exec = '/usr/bin/python3'&#xA;let g:syntastic_python_checkers = ['python', 'pylint']&#xA;let g:syntastic_enable_signs = 1&#xA;&#xA;let g:syntastic_error_symbol = '?'&#xA;let g:syntastic_style_error_symbol = '??'&#xA;let g:syntastic_warning_symbol = '??'&#xA;let g:syntastic_style_warning_symbol = '?'&#xA;&#xA;highlight link SyntasticErrorSign SignColumn&#xA;highlight link SyntasticWarningSign SignColumn&#xA;highlight link SyntasticStyleErrorSign SignColumn&#xA;highlight link SyntasticStyleWarningSign SignColumn&#xA;&quot; }}}&#xA;&quot; Tagbar {{{&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;s :TagbarToggle&amp;lt;CR&amp;gt;&#xA;&quot; }}}&#xA;&quot; PHP settings {{{&#xA;&quot; PHP Docblocks&#xA;function! PhpSyntaxOverride()&#xA;    hi! def link phpDocTags  phpDefine&#xA;    hi! def link phpDocParam phpType&#xA;endfunction&#xA;augroup phpSyntaxOverride&#xA;    autocmd!&#xA;    autocmd FileType php call PhpSyntaxOverride()&#xA;augroup END&#xA;&#xA;let g:formatdef_phpfmt = '&quot;php ~/bin/phpfmt --no-backup --psr --smart_linebreak_after_curly --visibility_order -&quot;'&#xA;let g:formatters_php = ['phpfmt']&#xA;&quot; }}}&#xA;&quot; XDebug with vdebug {{{&#xA;&quot; TODO: per project setting of path mapping?&#xA;let g:vdebug_options = {&#xA;            \   'path_maps': {&#xA;            \       &quot;/vagrant/dev_src/&quot;: &quot;/home/ruben/Code/studentsplus/dev_src/&quot;,&#xA;            \   },&#xA;            \   'timeout': 30,&#xA;            \   'break_on_open': 1&#xA;            \}&#xA;&quot;}}}&#xA;&quot; CSS settings {{{&#xA;let g:cssColorVimDoNotMessMyUpdatetime = 1&#xA;&quot; }}}&#xA;&quot; LaTeX Settings {{{&#xA;let g:tex_flavor='latex'&#xA;let g:Tex_DefaultTargetFormat = 'pdf'&#xA;let g:Tex_CompileRule_pdf = 'arara -v $*'&#xA;&quot; }}}&#xA;&quot; Clipboard shortcuts {{{&#xA;nnoremap &amp;lt;C-y&amp;gt; &quot;+y&#xA;vnoremap &amp;lt;C-y&amp;gt; &quot;+y&#xA;&quot; }}}&#xA;&quot; UI settings {{{&#xA;set ruler       &quot; show the cursor position all the time&#xA;set showcmd     &quot; display incomplete commands&#xA;set number      &quot; show linenumbers&#xA;set linespace=3 &quot; Prefer a slightly higher line height&#xA;set mousehide   &quot; Hide mouse when typing&#xA;set cursorline  &quot; Highlight current line&#xA;set wildmenu    &quot; visual autocomplete for command menu&#xA;set showmatch   &quot; highlight matching [{(&#xA;&quot; }}}&#xA;&quot; Theme {{{&#xA;&quot; Set the color scheme.&#xA;set background=dark&#xA;&quot; }}}&#xA;&quot; Vim signature (marks) {{{&#xA;let g:SignatureMarkTextHLDynamic = 1&#xA;let g:SignatureMarkerTextHLDynamic = 1&#xA;&quot; }}}&#xA;&quot; End Plug {{{&#xA;&quot; Add plugins to &amp;amp;runtimepath&#xA;call plug#end()&#xA;&quot; }}}&#xA;&quot; Identation settings {{{&#xA;&quot; Enable file type detection&#xA;&quot; Use the default filetype settings, so that mail gets 'tw' set to 72,&#xA;&quot; 'cindent' is on in C files, etc.&#xA;&quot; Also load indent files, to automatically do language-dependent indenting.&#xA;filetype plugin indent on&#xA;&#xA;set autoindent                        &quot; indent when creating newline&#xA;&#xA;&quot; for autoindent, use same spaces/tabs mix as previous line, even if&#xA;&quot; tabs/spaces are mixed. Helps for docblock, where the block comments have a&#xA;&quot; space after the indent to align asterisks&#xA;set copyindent&#xA;&#xA;&quot; Try not to change the indent structure on &quot;&amp;lt;&amp;lt;&quot; and &quot;&amp;gt;&amp;gt;&quot; commands. I.e. keep&#xA;&quot; block comments aligned with space if there is a space there.&#xA;set preserveindent&#xA;&#xA;&quot; Smart detect when in braces and parens. Has annoying side effect that it&#xA;&quot; won't indent lines beginning with '#'. Relying on syntax indentexpr instead.&#xA;set nosmartindent&#xA;&#xA;&quot; Global setting. I don't edit C-style code all the time so don't default to&#xA;&quot; C-style indenting.&#xA;set nocindent&#xA;&quot; }}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6514" LastEditorUserId="11357" LastEditDate="2018-08-31T10:22:15.720" LastActivityDate="2018-08-31T10:22:15.720" Title="Unable to start Vdebug" Tags="|plugin-vim-plug|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6885" PostTypeId="2" ParentId="6867" CreationDate="2016-03-14T19:16:46.600" Score="4" Body="&lt;p&gt;It looks like I found a solution. I was able to adapt config that formatted heredoc as SQL:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; .vim/after/syntax/perl/heredoc-perl.vim&#xA;runtime! syntax/perl.vim&#xA;unlet b:current_syntax&#xA;syntax include @Perl syntax/perl.vim&#xA;&#xA;syntax region sqlSnip matchgroup=Snip start=+&amp;lt;&amp;lt;['&quot;]RAW['&quot;].*;\s*$+ end=+^\s*RAW$+ contains=@Perl&#xA;syntax region sqlSnip matchgroup=Snip start=+&amp;lt;&amp;lt;['&quot;]TIDIED['&quot;].*;\s*$+ end=+^\s*TIDIED$+ contains=@Perl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This only applies to heredocs that are identified by RAW or TIDIED, but that is perfect for my purposes.&lt;/p&gt;&#xA;" OwnerUserId="6568" LastEditorUserId="6568" LastEditDate="2016-03-15T12:55:42.987" LastActivityDate="2016-03-15T12:55:42.987" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6886" PostTypeId="2" ParentId="6834" CreationDate="2016-03-15T04:06:47.453" Score="16" Body="&lt;p&gt;You can't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the C source code for what &lt;code&gt;&amp;lt;C-w&amp;gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; does:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;normal.c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * This table contains one entry for every Normal or Visual mode command.&#xA; * The order doesn't matter, init_normal_cmds() will create a sorted index.&#xA; * It is faster when all keys from zero to '~' are present.&#xA; */&#xA;static const struct nv_cmd&#xA;{&#xA;    int         cmd_char;       /* (first) command character */&#xA;    nv_func_T   cmd_func;       /* function for this command */&#xA;    short_u     cmd_flags;      /* NV_ flags */&#xA;    short       cmd_arg;        /* value for ca.arg */&#xA;} nv_cmds[] =&#xA;{&#xA;&#xA;[...]&#xA;&#xA;    {Ctrl_W,    nv_window,      0,                      0},&#xA;};&#xA;&#xA;[...]&#xA;&#xA;/*&#xA; * CTRL-W: Window commands&#xA; */&#xA;    static void&#xA;nv_window(cmdarg_T *cap)&#xA;{&#xA;    if (!checkclearop(cap-&amp;gt;oap))&#xA;        do_window(cap-&amp;gt;nchar, cap-&amp;gt;count0, NUL); /* everything is in window.c */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;window.c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * all CTRL-W window commands are handled here, called from normal_cmd().&#xA; */&#xA;    void&#xA;do_window(&#xA;[..]&#xA;) {&#xA;    switch (nchar)&#xA;    {&#xA;[..]&#xA;    case 'i':                       /* Go to any match */&#xA;    case Ctrl_I:&#xA;                type = FIND_ANY;&#xA;                /* FALLTHROUGH */&#xA;&#xA;[..]&#xA;    default:    beep_flush();&#xA;                break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not entirely sure where the &lt;code&gt;type&lt;/code&gt; variable gets picked up, I didn't feel like looking that up, but the point is, that there is no real facility to say &quot;this key is mapped to this functionality&quot;. It's basically just a &lt;code&gt;struct&lt;/code&gt; which maps a &lt;code&gt;char&lt;/code&gt; to a function, and the implementation of the second keystroke (&lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt;) is simply ad-hoc ugliness!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is different from Emacs, where (I presume) everything is in Lisp, and your custom mappings are not any different from Emacs' default mappings. But in Vim you have &quot;magic&quot; mappings that are provided by the C code which map against C functions that are never exposed in Vim. I always say that Vim has the better idea, but Emacs has the better implementation ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the only way is to look it up in the help files. This is why I closed this as a duplicate of &lt;a href=&quot;https://vi.stackexchange.com/q/2136/51&quot;&gt;How do I navigate to topics in Vim's documentation&lt;/a&gt; since that's the only &lt;em&gt;practical&lt;/em&gt; answer anyone can give. One could indeed argue that a more in-depth explanation to the question could be given (as I have just done), and had you argued &lt;em&gt;that&lt;/em&gt;, instead of giving the (now-deleted) response, I would probably have said &quot;you're right, sorry for the mistake&quot; and re-opened it ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At any rate, to briefly illustrate the conventions with some examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help w&lt;/code&gt; − normal mode mapping for &lt;code&gt;w&lt;/code&gt; (case-sensitive);&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help g8&lt;/code&gt; − normal mode mapping for &lt;code&gt;g8&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help v_o&lt;/code&gt; − visual mode mapping for &lt;code&gt;o&lt;/code&gt;; other modes are &lt;code&gt;c&lt;/code&gt; for command-line and &lt;code&gt;i&lt;/code&gt; for insert;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help CTRL-W&lt;/code&gt; − normal mode mapping for &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help i_CTRL-W&lt;/code&gt; − insert mode mapping for &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help  CTRL-W_CTRL-I&lt;/code&gt; − normal mode mapping for &lt;code&gt;&amp;lt;C-w&amp;gt;&amp;lt;C-i&amp;gt;&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help i_CTRL-G_&amp;lt;Down&amp;gt;&lt;/code&gt; − insert mode mapping for &lt;code&gt;&amp;lt;C-g&amp;gt;&amp;lt;Down&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-03-15T15:47:15.743" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6887" PostTypeId="1" CreationDate="2016-03-15T05:47:41.287" Score="4" ViewCount="720" Body="&lt;p&gt;I found out about printing using the &lt;code&gt;:hardcopy&lt;/code&gt; command, and on my Mac it opens up the output in a PDF named &quot;0.pdf&quot;, then the next printing from that file opens &quot;1.pdf&quot;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can save these files, of course, but I'm wondering: Where are these files stored on disk?  Is there a setting which controls it somewhere?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't been able to find the output files anywhere, including checking &lt;code&gt;/tmp&lt;/code&gt;.  Appreciate any tips in the right direction.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set printexpr?&lt;/code&gt; yields &lt;code&gt;system('open -a Preview '.v:fname_in) + v:shell_error&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The PDF viewer can't be made to show the file as being anywhere.  All usual methods for finding where the currently open file is aren't working at all.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="51" LastEditDate="2016-03-15T11:56:25.843" LastActivityDate="2016-03-15T11:56:25.843" Title="Where does MacVim send its printed files?" Tags="|macvim|printing|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6888" PostTypeId="2" ParentId="6887" CreationDate="2016-03-15T08:40:54.133" Score="4" Body="&lt;p&gt;I found it using &lt;code&gt;lsof&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/private/var/folders/cr/jsb8dl_50lbdy05hj7v2l9wr0000gn/T/com.apple.Preview/PreviewTemp-79NyiU/0.pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then I found the other files alongside it using &lt;code&gt;find&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find /private/var/folders/cr/jsb8dl_50lbdy05hj7v2l9wr0000gn/T/com.apple.Preview -type f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I still don't know &lt;em&gt;why&lt;/em&gt; it was put here, but at least I found it.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2016-03-15T08:40:54.133" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6889" PostTypeId="2" ParentId="6887" CreationDate="2016-03-15T08:57:56.840" Score="4" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/print.txt.html#pexpr%2doption&quot;&gt;&lt;code&gt;:help pexpr-option&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Expression that is evaluated to print the PostScript produced with&#xA;  &lt;code&gt;:hardcopy&lt;/code&gt;.&#xA;  The file name to be printed is in &lt;code&gt;v:fname_in&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's a bit of a hack, but you can simply &lt;code&gt;echo&lt;/code&gt; the &lt;code&gt;v:fname_in&lt;/code&gt; variable to a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let &amp;amp;printexpr = &quot;system('echo '.v:fname_in.'&amp;gt;&amp;gt; /home/martin/hardcopy')&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then examine the created hardcopy file, I found that on my Linux system it's &lt;code&gt;/tmp/vVLcfMS/6&lt;/code&gt;, which indeed looks like a postscript file with the contents of my buffer ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For OS X you probably want to use a path like &lt;code&gt;/Users/Wildcard/hardcopy&lt;/code&gt;... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pretty sure there's an easier way than this in OS X somehow, unless Saint Jobs the Magnificent decided that this was somehow not required for his petty mortal users (would not surprise me)... In any case, it's a useful lesson in basic &quot;printf debugging&quot; ;-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-03-15T08:57:56.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6890" PostTypeId="1" AcceptedAnswerId="6891" CreationDate="2016-03-15T11:28:32.897" Score="4" ViewCount="799" Body="&lt;p&gt;I've discovered the &lt;code&gt;:hardcopy&lt;/code&gt; command, which is the equivalent of the Command-P command in MacVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also found that it accepts ranges.  For instance, in my markdown file, I can split the sections into multiple PDFs like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,1/^#.* 4 /-ha | 1//,/^#.* 6 /-ha | 1//,/^#.* 7 /-ha | 1//,/^#.* 8 /-ha | 1//,/^#.* 9 /-ha | 1//,$ha&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(My section headers look like: &lt;code&gt;# Exercise 1 - (Name of exercise)&lt;/code&gt;, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command prints sections 1-3 into one file, sections 4-5 into the next, sections 6, 7, and 8 each in separate files, and from section 9 to the end of the file into another file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, with the default print header this results in all of these files starting with &quot;Page 1&quot;.  I can suppress that header and print only the filename by running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set pheader=%f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but ideally, I'd like to have all of these exercises in the same PDF, with proper page numbers in the header, and with the exercises each cleanly on their own page (and some short exercises printed together on the same page as per the printing command above).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I further found that with &lt;code&gt;:set popt=paper:letter&lt;/code&gt; (letter size PDF printouts), and no other settings modified from my system defaults, a single page of printout contains 69 lines of text, wrapped after 86 columns.  (So a line longer than 86 columns counts extra toward the 69 line per page limit.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that I can achieve what I want (exercises cleanly separated onto separate pages of the printout) by just inserting extra empty lines into the document so that the intended page breaks line up every 69 lines, being sure to compensate for any overly long lines.  However, this is really inconvenient when making edits up and down the document; I would have to keep fussing with the padding lines to ensure the printout stayed true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I force page breaks to occur in the MacVim printed output in specified locations?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="51" LastEditDate="2016-03-15T11:55:57.203" LastActivityDate="2016-03-15T13:13:37.183" Title="How can I force a page break in MacVim's printed output?" Tags="|macvim|wrapping|printing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6891" PostTypeId="2" ParentId="6890" CreationDate="2016-03-15T13:13:37.183" Score="6" Body="&lt;p&gt;From &lt;code&gt;:help popt-option&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;formfeed:y  When a form feed character is encountered, continue&#xA;            printing of the current line at the beginning of the&#xA;            first line on a new page.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So…&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;add the line below to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set printoptions+=formfeed:y&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;insert a form feed where you want your page break to occur with &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; in insert mode,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;do &lt;code&gt;:hardcopy&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-03-15T13:13:37.183" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6892" PostTypeId="1" CreationDate="2016-03-15T16:02:02.083" Score="5" ViewCount="3782" Body="&lt;p&gt;One of the neat features in Neovim is that &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Plugin-UI-architecture&quot; rel=&quot;noreferrer&quot;&gt;it should be possible to embed it into other applications&lt;/a&gt;, to make it look it as if it was the built in editor an IDE for example!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really want to do this with MATLAB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. Is it possible to embed Neovim into Matlab &quot;in place of&quot; the default MATLAB editor?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so: how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that is not the case: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. Would it need to be implemented on MATLAB's side, or could it be done with a plugin or something?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="2082" LastActivityDate="2016-05-11T16:06:40.580" Title="How to use Neovim as editor in MATLAB" Tags="|neovim|matlab|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6893" PostTypeId="1" CreationDate="2016-03-15T17:11:49.393" Score="6" ViewCount="135" Body="&lt;p&gt;When writing LaTeX, I like a newline between every sentence as it helps me jump around more easily. Additionally, I put two spaces at the start of lines where sentences don't start. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is the first sentence, and after 80 characters or so&#xA;  it wraps like this.&#xA;A new sentence looks like this.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea for how to automate this in Vim?&lt;/p&gt;&#xA;" OwnerUserId="6827" LastEditorUserId="1841" LastEditDate="2016-03-16T08:40:25.353" LastActivityDate="2017-11-15T17:36:20.380" Title="Autoformatting LaTeX: how to add characters in front of a wrapped line" Tags="|filetype-tex|wrapping|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6894" PostTypeId="1" CreationDate="2016-03-15T19:46:00.860" Score="4" ViewCount="537" Body="&lt;p&gt;With &lt;kbd&gt;F2&lt;/kbd&gt; unmapped, for instance, I get a load of error messages (see below). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realized I can fix this by mapping the f-keys, but I'm curious: are they mapped to something by Ultisnips, that doesn't work?  Or is this a symptom of an underlying problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This happens even with a minimal vimrc, that does nothing but load ultisnips with vim-plug.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS.  I think the problem has to do with the fact that in nvim &lt;code&gt;&amp;lt;f2&amp;gt;&lt;/code&gt; is mapped as if with &lt;code&gt;imap &amp;lt;f2&amp;gt; &amp;lt;F2&amp;gt;&lt;/code&gt;, which causes a loop (because for some reason, with ultisnips, &lt;code&gt;&amp;lt;F2&amp;gt;&lt;/code&gt; is interpreted as a key rather than as a string).  This can be confirmed by testing first &lt;code&gt;imap &amp;lt;f2&amp;gt; &amp;lt;f2&lt;/code&gt; and then &lt;code&gt;imap &amp;lt;f2&amp;gt; &amp;lt;f2&amp;gt;&lt;/code&gt;. Without ultisnips, the string &lt;code&gt;&amp;lt;F2&amp;gt;&lt;/code&gt; is inserted without any error messages.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function UltiSnips#TrackChange..provider#python3#Call:&#xA;line   18:&#xA;NvimError(b'Vim(new):E523: Not allowed here: botright new',)&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function UltiSnips#TrackChange..provider#python3#Call:&#xA;line   18:&#xA;Traceback (most recent call last):&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function UltiSnips#TrackChange..provider#python3#Call:&#xA;line   18:&#xA;  File &quot;/Users/lawrence/.config/nvim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py&quot;, line 61, in wrapper&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function UltiSnips#TrackChange..provider#python3#Call:&#xA;line   18:&#xA;    return func(self, *args, **kwds)&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function UltiSnips#TrackChange..provider#python3#Call:&#xA;line   18:&#xA;  File &quot;/Users/lawrence/.config/nvim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py&quot;, line 829, in _track_change&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function UltiSnips#TrackChange..provider#python3#Call:&#xA;line   18:&#xA;    inserted_char = _vim.eval('v:char')&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function UltiSnips#TrackChange..provider#python3#Call:&#xA;line   18:&#xA;  File &quot;/Users/lawrence/.config/nvim/plugged/ultisnips/pythonx/UltiSnips/_vim.py&quot;, line 117, in eval&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function UltiSnips#TrackChange..provider#python3#Call:&#xA;line   18:&#xA;    rv = vim.eval(as_vimencoding(text))&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function UltiSnips#TrackChange..provider#python3#Call:&#xA;line   18:&#xA;  File &quot;/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/neovim/api/nvim.py&quot;, line 124, in eval&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function UltiSnips#TrackChange..provider#python3#Call:&#xA;line   18:&#xA;    return self._session.request('vim_eval', string, async=async)&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="51" LastEditDate="2016-03-25T12:01:05.557" LastActivityDate="2021-11-26T17:04:45.430" Title="Ultisnips causes problem with unmapped f-keys in nvim insert mode" Tags="|neovim|plugin-ultisnips|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6896" PostTypeId="2" ParentId="84" CreationDate="2016-03-16T05:24:24.150" Score="5" Body="&lt;p&gt;I recommend you use Gvim, and add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/mswin.vim&#xA;behave mswin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This enables support for &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;X&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; like notepad in Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this will also add some other common Windows shortcuts, such as &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;S&lt;/kbd&gt; for &lt;code&gt;:w&lt;/code&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;A&lt;/kbd&gt; for select all, etc.&lt;/p&gt;&#xA;" OwnerUserId="6600" LastEditorUserId="51" LastEditDate="2016-03-16T11:27:28.173" LastActivityDate="2016-03-16T11:27:28.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6897" PostTypeId="2" ParentId="6379" CreationDate="2016-03-16T05:32:59.130" Score="1" Body="&lt;p&gt;guess you need autocompleter+snippet plugin, since Supertab will be slow when the tags file are large, recommand you two group plugins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(1) YouCompleteMe + UltiSnips&lt;/li&gt;&#xA;&lt;li&gt;(2) Neocomplete + clang_complete + Jedi + neosnippet + neosnippet-snippets&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;They are the best C/C++/Python completer+snippet plugin combinations I ever used, but incompatible with each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;YCM group is fast, easy to install on both Windows and Linux, big (450MB), good to use, you need to learn how to write a '.ycm_extra_conf.py' for your own project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neocomplete group is smooth, good, but need lua support. AFAIK, vim-gnome already support lua compiled with vim/gvim on many Linux(Fedora/Ubuntu/etc), but I don't use it for a long time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my vimrc: &lt;a href=&quot;https://github.com/zhaochenyou/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/zhaochenyou/vimrc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It support many plugins, very good to use, it based on Vundle, YouCompleteMe, ctags, cscope, the_silver_searcher/ag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you may need the Installation guide of YCM: &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Valloric/YouCompleteMe&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="6600" LastEditorUserId="6600" LastEditDate="2016-11-15T16:24:08.693" LastActivityDate="2016-11-15T16:24:08.693" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6898" PostTypeId="1" AcceptedAnswerId="6899" CreationDate="2016-03-16T13:37:14.297" Score="9" ViewCount="222" Body="&lt;p&gt;I have a file that is made up of two vertical parts. On the left side, the data is already formatted and I don't want to change it. I only want to format the data on the right side. Say I have a file with lines like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo=bar baz     # Neato       Junk&#xA;quux=xyzzy      # Bilbo Baggins Ring&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with many more lines like that. I only want to modify the text to the right of the '#' character. I selected the text I want with the following expressions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg&#xA;/#&#xA;ctrl-v&#xA;G&#xA;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but if I then try to modify it (say, with &lt;code&gt;:'&amp;lt;,'&amp;gt;!column -t&lt;/code&gt;), it actually modifies the entirety of every line. What is the correct expression to use to only modify the visually selected parts?&lt;/p&gt;&#xA;" OwnerUserId="5597" LastActivityDate="2016-03-16T16:09:54.723" Title="How to modify visually selected block with external command?" Tags="|visual-mode|external-command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6899" PostTypeId="2" ParentId="6898" CreationDate="2016-03-16T14:10:58.087" Score="6" Body="&lt;p&gt;You can also try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg&#xA;^V&#xA;G&#xA;t#&#xA;d&#xA;:%!column -t&#xA;gg&#xA;P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html#:visual_example&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :visual_example&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Currently the &quot;:&quot; command works on whole lines only.  When you select part of a line, doing something like &quot;:!date&quot; will replace the whole line.  If you want only part of the line to be replaced you will have to make a mapping for it.  In a future release &quot;:&quot; may work on partial lines.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html#visual-operators&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h visual-operators&lt;/code&gt;&lt;/a&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="1841" LastEditDate="2016-03-16T16:09:54.723" LastActivityDate="2016-03-16T16:09:54.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6900" PostTypeId="1" AcceptedAnswerId="9228" CreationDate="2016-03-17T05:19:28.140" Score="5" ViewCount="1015" Body="&lt;p&gt;I have this map in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-space&amp;gt; &amp;lt;C-o&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that, eg, if I'm in insert mode:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PHt4e.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PHt4e.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can just type &lt;code&gt;&amp;lt;C-space&amp;gt;&lt;/code&gt; to move out of parens:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gd7R8.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gd7R8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It all works great in the &lt;em&gt;middle&lt;/em&gt; of a line.  But if that &lt;code&gt;)&lt;/code&gt; were the last character on the line, then the cursor won't move when I hit &lt;code&gt;&amp;lt;C-space&amp;gt;&lt;/code&gt;.  Which makes sense, because there is nowhere for it move to.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what I &lt;em&gt;want&lt;/em&gt; in this case is for &lt;code&gt;&amp;lt;C-space&amp;gt;&lt;/code&gt; to behave as if I'd typed &lt;code&gt;&amp;lt;esc&amp;gt;$a&lt;/code&gt; -- ie, gone to the end of the line in normal mode and pressed &lt;code&gt;a&lt;/code&gt; to start appending characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I update my mapping to achieve this special behavior for the end of line case?&lt;/p&gt;&#xA;" OwnerUserId="5373" LastActivityDate="2016-08-16T19:24:37.237" Title="Skip over character in insert mode, even at the end of a line" Tags="|vimscript|key-bindings|cursor-movement|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6901" PostTypeId="1" AcceptedAnswerId="8393" CreationDate="2016-03-17T09:32:08.957" Score="3" ViewCount="161" Body="&lt;p&gt;I'm big on &lt;a href=&quot;https://unix.stackexchange.com/a/269076/135943&quot;&gt;scripted file edits using POSIX &lt;code&gt;ex&lt;/code&gt;&lt;/a&gt; rather than &lt;code&gt;sed -i&lt;/code&gt; and co.  The big trick of course is how to ensure &lt;code&gt;ex&lt;/code&gt; doesn't hang waiting for input if an error is encountered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just &lt;a href=&quot;https://unix.stackexchange.com/questions/25057/how-to-perform-a-sed-in-place-substitution-that-only-creates-backups-of-files-th#comment468964_25057&quot;&gt;wrote a comment&lt;/a&gt; about the possibility of using &lt;code&gt;ex&lt;/code&gt; to edit a file conditionally, and only save a backup of the file if edits were made.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that if there were some option which could be used to tell &lt;code&gt;ex&lt;/code&gt; &quot;In case of any error, &lt;code&gt;q!&lt;/code&gt;&quot; then this would be fairly simple conceptually:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '%s/pattern/replace/g | !cp % %.bup' -cx file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course that copy command will fail on &lt;em&gt;any&lt;/em&gt; special characters in the filename, but you get the concept; a better form would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '/pattern/ | w %.bup' -c '%s//replace/g | x' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Essentially what I'm asking for is a form of conditional logic in &lt;code&gt;ex&lt;/code&gt; batch scripting, such that &quot;If this pattern isn't found, &lt;code&gt;q!&lt;/code&gt;; otherwise continue.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this with &lt;code&gt;ex&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2016-06-23T14:59:45.383" Title="Cause `ex` to automatically exit without saving if a pattern isn't found?" Tags="|ex-mode|posix|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6902" PostTypeId="2" ParentId="6901" CreationDate="2016-03-17T10:28:42.783" Score="2" Body="&lt;p&gt;Maybe you could make the substitution and check if the buffer is modified by looking at the value of the option &lt;code&gt;'modified'&lt;/code&gt;.&lt;br&gt;&#xA;If it is modified, undo, make a backup, redo and exit.&lt;br&gt;&#xA;Otherwise, if the buffer is not modified, simply quit. It could give something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c '%s/pattern/replace/ge | exe &amp;amp;mod ? &quot;undo | w %.bup | redo | x&quot; : &quot;q&quot;' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But as you said in the comments, it's probably not POSIX. &lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="4939" LastEditDate="2016-03-17T12:00:32.977" LastActivityDate="2016-03-17T12:00:32.977" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6903" PostTypeId="1" CreationDate="2016-03-17T10:36:35.983" Score="5" ViewCount="132" Body="&lt;p&gt;I'd like to use the ins-completion function to suggest not words but WORDS, that is to say, space separated words. Is that possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: (latex)  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\mathbb{R}&#xA;&#xA;\ma(Ctrl-n)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6848" LastEditorUserId="6590" LastEditDate="2016-12-22T07:25:20.333" LastActivityDate="2018-04-28T15:45:34.283" Title="inscompletion: space separated words" Tags="|autocompletion|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6905" PostTypeId="1" AcceptedAnswerId="6911" CreationDate="2016-03-17T14:30:25.963" Score="2" ViewCount="121" Body="&lt;p&gt;Say I have two windows open, and I would like to copy lines from the first window to the second window, and then move back the original window. I do this as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;select lines in Visual mode&amp;gt;&#xA;y&#xA;Ctrl+w&#xA;w&#xA;p&#xA;Ctrl+w&#xA;w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to map this to a key.  My attempt is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;F2&amp;gt; y :wincmd j&amp;lt;CR&amp;gt; p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It successfully copies the lines from one window to the other, but I can't seem to successfully make it jump back up to the previous window.  How can I add this next part?  The following does not work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;F2&amp;gt; y :wincmd j&amp;lt;CR&amp;gt; p &amp;lt;ESC&amp;gt; :wincmd k&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6849" LastEditorUserId="54" LastEditDate="2016-03-17T16:00:58.280" LastActivityDate="2016-03-17T16:00:58.280" Title="Map key to copy to next window" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6906" PostTypeId="1" AcceptedAnswerId="6968" CreationDate="2016-03-17T14:59:41.873" Score="8" ViewCount="1322" Body="&lt;p&gt;According to the &lt;a href=&quot;http://vim.wikia.com/wiki/Syntax_folding_of_Vim_scripts&quot; rel=&quot;noreferrer&quot;&gt;WIKI&lt;/a&gt;, scripts can be folded based on syntax. Does anyone have a solution to fold Python docstrings?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, all I need is to fold &lt;code&gt;&quot;&quot;&quot; text between triple quotation marks &quot;&quot;&quot;&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9YtJS.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9YtJS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerDisplayName="user6649" LastEditorUserId="1841" LastEditDate="2016-03-17T15:24:52.217" LastActivityDate="2016-08-08T02:03:50.257" Title="Folding Python docstrings" Tags="|folding|filetype-python|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6907" PostTypeId="1" CreationDate="2016-03-17T15:05:18.243" Score="3" ViewCount="865" Body="&lt;p&gt;First of all I want to say that I know and use &lt;a href=&quot;https://github.com/Raimondi/delimitMate&quot; rel=&quot;nofollow&quot;&gt;delimitmate&lt;/a&gt; and &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow&quot;&gt;surround-vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And while they work pretty well, there is room for improvement. I'll explain what I mean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I'm writing the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo = bar() # some comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And what I need is to wrap bar function call in another function call.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo = baz(bar()) # some comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The best option I know right now is to use surround-vim. So suppose cursor is at the start of bar. I press &lt;code&gt;v w l l shift+S shift+(&lt;/code&gt; (then I type &lt;code&gt;bar&lt;/code&gt;, but that's not relevant).&#xA;Let's count, this is 6 key presses and two of them with &lt;kbd&gt;Shift&lt;/kbd&gt;, which is harder than without it, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm imagining another solution to this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if when I'm pressing &lt;code&gt;(&lt;/code&gt; (or some other key) the editor would detect that and propose some place to place the &lt;code&gt;)&lt;/code&gt; and I would choose that. The most effective way of doing that could be observed in &lt;a href=&quot;https://github.com/easymotion/vim-easymotion&quot; rel=&quot;nofollow&quot;&gt;easy-motion&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The editor could mark the choices with colored letters and the user would choose by pressing letter with pressed &lt;kbd&gt;Ctrl&lt;/kbd&gt; or something.&#xA;This would be just two key presses (one with &lt;kbd&gt;ctrl&lt;/kbd&gt; though) - 3 times less!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If such a plugin doesn't exist (and I think it doesn't) I'm willing to write one myself, but I don't know where to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, how do I detect that &lt;code&gt;(&lt;/code&gt; was pressed? And how do I mark choices with colored letters?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT1. I know about surround's &lt;code&gt;ys&lt;/code&gt; mapping, and I'm using it. But let's look at how many key presses you need to make with it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ysiWf baz &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Six key presses. And with my (proposed) plugin it's still only two. Notice the fact that with my plugin you don't need to think about what motion to use, I believe it's much better because of this.&#xA;But let's make things more interesting. Let's imagine I need to transform this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo = bar(), baz(), goo()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo = boo(bar(), baz()), goo()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I would need to press something &lt;code&gt;ys4ff bar &amp;lt;cr&amp;gt;&lt;/code&gt;. It's still 6 key presses, but I would need to count parenthesis and this gets messy quite soon with more complicated expressions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I believe that it's less natural to do it that way. Because I don't know about you, but at first I think about what function I need to use for wrapping and the next natural action is to type its name, not thinking about what motion I need to use to surround something.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="205" LastEditDate="2016-03-18T08:37:05.550" LastActivityDate="2016-03-18T09:44:12.347" Title="Vim plugin to help with surrounding things in brackets, quotes etc" Tags="|plugin-system|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6908" PostTypeId="1" CreationDate="2016-03-17T15:08:08.950" Score="5" ViewCount="865" Body="&lt;p&gt;I'm writing &lt;a href=&quot;https://cucumber.io/docs/reference#scenario-outline&quot; rel=&quot;nofollow&quot;&gt;cucumber&lt;/a&gt; example tables, which are formatted like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;| title   | title  |&#xA;| data    | data   |&#xA;| data    | data   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I replace one of the data or title cells with a word of differing length without disturbing the layout?&lt;/p&gt;&#xA;" OwnerUserId="1033" LastEditorUserId="205" LastEditDate="2016-03-18T02:58:07.893" LastActivityDate="2017-02-10T07:33:44.077" Title="How can I replace a word in a column without changing the width" Tags="|replace|alignment|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="6909" PostTypeId="2" ParentId="6907" CreationDate="2016-03-17T15:32:48.410" Score="3" Body="&lt;p&gt;&lt;code&gt;viW(&lt;/code&gt; with lh-brackets, or &lt;code&gt;vf(%(&lt;/code&gt; if you want something more robust... Something similar is certainly possible with surround without using the &lt;em&gt;interactive&lt;/em&gt; visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, you need first to do a &lt;code&gt;nnoremap&lt;/code&gt; on &lt;code&gt;(&lt;/code&gt; in normal mode I guess to enter in your mode. Then, you'll have to look at how easymotion handles its motion to do the same. And if you validate your action, then you can apply the actual surrounding, either with &lt;code&gt;S&lt;/code&gt; (that messes up registers, which is to be avoided in plugins : we can never know what register the end user is already using, and for what), either with the usual &lt;code&gt;'&amp;gt;astuff-to-append&amp;lt;esc&amp;gt;'&amp;lt;istuff-to-prepend&amp;lt;esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It may be best to start as a extension to Easymotion&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-03-18T09:44:12.347" LastActivityDate="2016-03-18T09:44:12.347" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="6910" PostTypeId="2" ParentId="6907" CreationDate="2016-03-17T15:34:15.960" Score="5" Body="&lt;p&gt;You can use surround's &lt;code&gt;ys&lt;/code&gt; operator with the &lt;code&gt;iW&lt;/code&gt; motion. Using the &lt;code&gt;f&lt;/code&gt; surrounding prompts for a function name.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ysiWfbaz&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h surround-mappings&#xA;:h iW&#xA;:h text-objects&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-03-17T15:34:15.960" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6911" PostTypeId="2" ParentId="6905" CreationDate="2016-03-17T15:40:55.703" Score="2" Body="&lt;p&gt;Because you are in visual mode when you press &lt;kbd&gt;F2&lt;/kbd&gt;, you need to map this key in visual mode, so you need to substitute &lt;code&gt;:map&lt;/code&gt; for &lt;code&gt;:vmap&lt;/code&gt;. But be careful with spaces because they move the cursor to the right in normal mode (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#l&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help l&lt;/code&gt;&lt;/a&gt;). Here you go.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vmap &amp;lt;F2&amp;gt; y:wincmd j&amp;lt;CR&amp;gt;p:wincmd k&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="6698" LastEditDate="2016-03-17T15:51:44.737" LastActivityDate="2016-03-17T15:51:44.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6912" PostTypeId="2" ParentId="6908" CreationDate="2016-03-17T17:01:42.090" Score="3" Body="&lt;p&gt;If you were using Vim them you could use some alignment plugin, as mentioned on the question comments. Or you could use &lt;a href=&quot;https://github.com/vimwiki/vimwiki&quot; rel=&quot;nofollow&quot;&gt;the vimwiki plugin&lt;/a&gt;, which provides several helpers to use tables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you are using VsVim, you could try to isolate the table formatting function in &lt;a href=&quot;https://github.com/vimwiki/vimwiki/blob/dev/autoload/vimwiki/tbl.vim#L495&quot; rel=&quot;nofollow&quot;&gt;vimwiki/autoload/vimwiki/tbl.vim&lt;/a&gt; and adapt it in a VsVim plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! vimwiki#tbl#format(lnum, ...) &quot;{{{&#xA;  if !(&amp;amp;filetype ==? 'vimwiki')&#xA;    return&#xA;  endif&#xA;  let line = getline(a:lnum)&#xA;  if !s:is_table(line)&#xA;    return&#xA;  endif&#xA;&#xA;  if a:0 == 2&#xA;    let col1 = a:1&#xA;    let col2 = a:2&#xA;  else&#xA;    let col1 = 0&#xA;    let col2 = 0&#xA;  endif&#xA;&#xA;  let indent = s:get_indent(a:lnum)&#xA;  if &amp;amp;expandtab&#xA;    let indentstring = repeat(' ', indent)&#xA;  else&#xA;    let indentstring = repeat(' ', indent / &amp;amp;tabstop) . repeat(' ', indent % &amp;amp;tabstop)&#xA;  endif&#xA;&#xA;  for [lnum, row] in s:get_aligned_rows(a:lnum, col1, col2)&#xA;    let row = indentstring.row&#xA;    call setline(lnum, row)&#xA;  endfor&#xA;&#xA;  let &amp;amp;tw = s:textwidth&#xA;endfunction &quot;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-03-17T17:01:42.090" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6913" PostTypeId="1" CreationDate="2016-03-17T19:18:27.453" Score="4" ViewCount="2366" Body="&lt;p&gt;I would like to be able to print in other than Courier font using the &lt;code&gt;:ha&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Investigating more closely, I found that it is documented that the Courier font is always used:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;- 'printfont' - The font name is ignored (the Courier family is always used -&#xA;  it should be available on all PostScript printers) but the font size is&#xA;  used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;— From &lt;code&gt;:help postscript-printing&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there must be some workaround, perhaps using an external tool.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to keep my Vim syntax highlighting in the printout, which rules out just opening the file in TextEdit (or TextWrangler) for printing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using MacVim snapshot 73, which is Vim 7.4.258.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I print a file to PDF using Vim's syntax highlighting but an alternate font?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="4676" LastEditDate="2016-03-18T01:53:02.207" LastActivityDate="2023-10-19T09:50:55.443" Title="How to change Vim's :hardcopy printfont?" Tags="|syntax-highlighting|macvim|font|printing|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6914" PostTypeId="2" ParentId="6913" CreationDate="2016-03-17T20:15:51.677" Score="8" Body="&lt;p&gt;Instead of printing from Vim, you could instead generate an HTML file using &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#:TOhtml&quot;&gt;&lt;code&gt;:TOhtml&lt;/code&gt;&lt;/a&gt;.  Then you can use CSS to set the font used for the HTML and print that.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2016-03-17T20:15:51.677" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6915" PostTypeId="2" ParentId="6908" CreationDate="2016-03-18T03:52:25.747" Score="2" Body="&lt;p&gt;Just copy paste the below functions (&lt;a href=&quot;https://github.com/imbichie/vim-vimrc-/blob/master/MCCB_MCCE.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/imbichie/vim-vimrc-/blob/master/MCCB_MCCE.vim&lt;/a&gt;) in your .vimrc or .gvimrc file and call the MCCB or MCCE function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; MCCB - Move the Character to the Column from the Begin of line&#xA;&quot; This is a function for Moving the specified Character &#xA;&quot; in a given range of lines to a the specified Column from the Begin of the line&#xA;&quot; NOTE 1 :- If the specified character and the first character of the line are same&#xA;&quot;           then the number of Occurrence (num_occr) will be one less than the actual&#xA;&quot; NOTE 2 :- Maximum space between the specified character with in the range &#xA;&quot;           of lines should be less than or equal to 80, if we need more than 80&#xA;&quot;           then we need to insert more spaces by increasing the value 80 in the &#xA;&quot;           &quot;nmap s 80i &amp;lt;ESC&amp;gt;&quot; line inside the function&#xA;&quot; Usage :-  in command mode do it like below&#xA;&quot; Eg 1:-    :5,11call MCCB(1, '=', 8)&#xA;&quot;           The above command will move the 1st Occurrence from the begin of Character =&#xA;&quot;           to the 8th Column of the lines from 5 to 11&#xA;&quot; Eg 2 :-   :7,10call MCCB(2, '+', 12)&#xA;&quot;           The above command will move the 2nd Occurrence of Character + to the 12th&#xA;&quot;           Column of the lines from 7 to 10&#xA;    function! MCCB (num_occr, mv_char, col_num) range&#xA;        if (a:firstline &amp;lt;= a:lastline)&#xA;            nmap s 80i &amp;lt;ESC&amp;gt;&#xA;            let line_num = a:firstline&#xA;            while line_num &amp;lt;= a:lastline&#xA;                execute &quot;normal &quot; . line_num . &quot;G0&quot; . a:num_occr . &quot;f&quot; . a:mv_char . &quot;s&quot; . a:col_num . &quot;|dw&quot;&#xA;                let line_num = line_num + 1&#xA;            endwhile&#xA;            nunmap s&#xA;        else&#xA;            execute printf('ERROR : Start line %d is higher thatn End line %d, a:firstline, a:lastline)&#xA;        endif&#xA;    endfunction&#xA;&#xA;&quot; MCCE - Move the Character to the Column from the End of line&#xA;&quot; This is a function for Moving the specified Character &#xA;&quot; in a given range of lines to a the specified Column from the End of the line&#xA;&quot; NOTE 1 :- If the specified character and the last character of the line are same&#xA;&quot;           then the number of Occurrence (num_occr) will be one less than the actual&#xA;&quot; NOTE 2 :- Maximum space between the specified character with in the range &#xA;&quot;           of lines should be less than or equal to 80, if we need more than 80&#xA;&quot;           then we need to insert more spaces by increasing the value 80 in the &#xA;&quot;           &quot;nmap s 80i &amp;lt;ESC&amp;gt;&quot; line inside the function&#xA;&quot; Usage :-  in command mode do it like below&#xA;&quot; Eg 1:-    :5,11call MCCE(1, ';', 20)&#xA;&quot;           The above command will move the 1st Occurrence from the End of Character ;&#xA;&quot;           to the 20th Column of the lines from 5 to 11&#xA;&quot; Eg 2 :-   :7,10call MCCE(5, ' ', 26)&#xA;&quot;           The above command will move the 5th Occurrence from the End of Character &quot; &quot; (white Space)&#xA;&quot;           to the 26th Column of the lines from 7 to 10&#xA;    function! MCCE (num_occr, mv_char, col_num) range&#xA;        if (a:firstline &amp;lt;= a:lastline)&#xA;            nmap s 80i &amp;lt;ESC&amp;gt;&#xA;            let line_num = a:firstline&#xA;            while line_num &amp;lt;= a:lastline&#xA;                execute &quot;normal &quot; . line_num . &quot;G$&quot; . a:num_occr . &quot;F&quot; . a:mv_char . &quot;s&quot; . a:col_num . &quot;|dw&quot;&#xA;                let line_num = line_num + 1&#xA;            endwhile&#xA;            nunmap s&#xA;        else&#xA;            execute printf('ERROR : Start line %d is higher thatn End line %d, a:firstline, a:lastline)&#xA;        endif&#xA;    endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4502" LastEditorUserId="4502" LastEditDate="2017-02-10T04:56:30.460" LastActivityDate="2017-02-10T04:56:30.460" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6916" PostTypeId="1" AcceptedAnswerId="6917" CreationDate="2016-03-18T07:29:16.747" Score="9" ViewCount="4064" Body="&lt;p&gt;I found that I frequently needed a command in &lt;code&gt;INSERT&lt;/code&gt; mode to open a line above the cursor (what &lt;kbd&gt;O&lt;/kbd&gt; does in &lt;code&gt;NORMAL&lt;/code&gt; mode)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I put this in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap ao &amp;lt;esc&amp;gt;O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works well. I chose the key sequence &lt;code&gt;ao&lt;/code&gt; because I rarely encounter &lt;kbd&gt;a&lt;/kbd&gt; and &lt;kbd&gt;o&lt;/kbd&gt; together (also I remember it as &quot;&lt;strong&gt;a&lt;/strong&gt;bove &lt;strong&gt;o&lt;/strong&gt;pen&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This set me thinking if there are some best practices when coming up with such mappings.&lt;br&gt;&#xA;I use Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-unimpaired/blob/master/doc/unimpaired.txt&quot; rel=&quot;noreferrer&quot;&gt;vim-unimpaired&lt;/a&gt; plugin and love his choice of keys (He says those are extracted out of his &lt;code&gt;vimrc&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are some best practices that I can follow to find good key sequences that my &lt;code&gt;.vimrc&lt;/code&gt; will also be easy to use for someone else?&lt;/p&gt;&#xA;" OwnerUserId="5484" LastEditorUserId="1841" LastEditDate="2016-03-18T08:35:11.310" LastActivityDate="2017-02-02T07:39:37.473" Title="key mapping best practices" Tags="|key-bindings|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6917" PostTypeId="2" ParentId="6916" CreationDate="2016-03-18T09:37:11.250" Score="6" Body="&lt;p&gt;&lt;code&gt;:help map-which-keys&lt;/code&gt; gives some information on the subject:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If you are going to map something, you will need to choose which key(s) to use&#xA;for the {lhs}.  You will have to avoid keys that are used for Vim commands,&#xA;otherwise you would not be able to use those commands anymore.  Here are a few&#xA;suggestions:&#xA;- Function keys &amp;lt;F2&amp;gt;, &amp;lt;F3&amp;gt;, etc..  Also the shifted function keys &amp;lt;S-F1&amp;gt;,&#xA;  &amp;lt;S-F2&amp;gt;, etc.  Note that &amp;lt;F1&amp;gt; is already used for the help command.&#xA;- Meta-keys (with the ALT key pressed).  Depending on your keyboard accented&#xA;  characters may be used as well. :map-alt-keys&#xA;- Use the '_' or ',' character and then any other character.  The &quot;_&quot; and &quot;,&quot;&#xA;  commands do exist in Vim (see _ and ,), but you probably never use them.&#xA;- Use a key that is a synonym for another command.  For example: CTRL-P and&#xA;  CTRL-N.  Use an extra character to allow more mappings.&#xA;- The key defined by &amp;lt;Leader&amp;gt; and one or more other keys.  This is especially&#xA;  useful in scripts. mapleader&#xA;&#xA;See the file &quot;index&quot; for keys that are not used and thus can be mapped without&#xA;losing any builtin function.  You can also use &quot;:help {key}^D&quot; to find out if&#xA;a key is used for some command.  ({key} is the specific key you want to find&#xA;out about, ^D is CTRL-D).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;They suggest:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;function keys and shifted function keys &lt;code&gt;&amp;lt;F1&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;S-F2&amp;gt;&lt;/code&gt;, ...&lt;/li&gt;&#xA;&lt;li&gt;Meta-keys (ALT + &lt;code&gt;{key}&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;_&lt;/code&gt; or &lt;code&gt;,&lt;/code&gt; + &lt;code&gt;{keys}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;using keys that are synonyms for a same command as a namespace&lt;br&gt;&#xA;e.g. &lt;code&gt;&amp;lt;C-N&amp;gt;&lt;/code&gt;, &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;j&lt;/code&gt; all move the cursor down one line ; you only need one and probably only use &lt;code&gt;j&lt;/code&gt; so &lt;code&gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; and &lt;code&gt;+&lt;/code&gt; could be good candidates to build a &lt;code&gt;{lhs}&lt;/code&gt; such as &lt;code&gt;&amp;lt;C-N&amp;gt; + {key}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; + &lt;code&gt;{keys}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;typing on the command line &lt;code&gt;:help {key}^D&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;{key}&lt;/code&gt; is the &lt;code&gt;{lhs}&lt;/code&gt; you would like to use for a mapping, and &lt;code&gt;^D&lt;/code&gt; is &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;D&lt;/kbd&gt;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the &lt;code&gt;unimpaired&lt;/code&gt; plugin, &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; have been chosen as namespaces.&lt;br&gt;&#xA;You could do the same, find some &lt;code&gt;{key}&lt;/code&gt; (or sequence of keys like &lt;code&gt;co&lt;/code&gt;) which is not used alone and use the latter as a namespace.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, as &lt;code&gt;:h map-which-keys&lt;/code&gt; suggests, to avoid overriding a default Vim command, you could type &lt;code&gt;:h {key}^D&lt;/code&gt;, to find out which commands begin with &lt;code&gt;{key}&lt;/code&gt;.&lt;br&gt;&#xA;For example, when typing &lt;code&gt;:h [^D&lt;/code&gt;, you should see &lt;code&gt;[c&lt;/code&gt; (a normal command to jump backwards to the previous start of a change in diff mode), but not &lt;code&gt;[a&lt;/code&gt; neither &lt;code&gt;[b&lt;/code&gt;.&lt;br&gt;&#xA;So &lt;code&gt;[a&lt;/code&gt; and &lt;code&gt;[b&lt;/code&gt; could be used as the &lt;code&gt;{lhs}&lt;/code&gt; of a mapping but not &lt;code&gt;[c&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastActivityDate="2016-03-18T09:37:11.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6918" PostTypeId="1" AcceptedAnswerId="6919" CreationDate="2016-03-18T10:04:59.253" Score="4" ViewCount="174" Body="&lt;p&gt;I'm using Exuberant Ctags to generate a tags file to use with Vim. However, in our project, we have javascript that makes remote procedure calls to the server (PHP). Functions like &lt;code&gt;getUsers&lt;/code&gt; are thus called &lt;code&gt;rpc_getUsers&lt;/code&gt; on the serverside. Is there a way to properly use things like &lt;code&gt;ctrl+]&lt;/code&gt; to jump to the associated function on the serverside, assuming it's a standard prefix/list of prefixes?&lt;/p&gt;&#xA;" OwnerUserId="6865" LastActivityDate="2016-03-18T11:35:01.933" Title="Search for tags with prefixes in other language files" Tags="|ctags|tags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6919" PostTypeId="2" ParentId="6918" CreationDate="2016-03-18T11:35:01.933" Score="3" Body="&lt;p&gt;You could use a mapping from &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;]&lt;/kbd&gt; to a custom function, similar to the one described at &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#CursorHold-example&quot; rel=&quot;nofollow&quot;&gt;:help CursorHold-example&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A nice addition is to highlight the found tag, avoid the &quot;:ptag&quot; when there&#xA;is no word under the cursor, and a few other things: &amp;gt;&#xA;&#xA;  :au! CursorHold *.[ch] nested call PreviewWord()&#xA;  :func PreviewWord()&#xA;  :  if &amp;amp;previewwindow                  &quot; don't do this in the preview window&#xA;  :    return&#xA;  :  endif&#xA;  :  let w = expand(&quot;&amp;lt;cword&amp;gt;&quot;)          &quot; get the word under cursor&#xA;  :  if w =~ '\a'                       &quot; if the word contains a letter&#xA;  :&#xA;  :    &quot; Delete any existing highlight before showing another tag&#xA;  :    silent! wincmd P                 &quot; jump to preview window&#xA;  :    if &amp;amp;previewwindow                        &quot; if we really get there...&#xA;  :      match none                     &quot; delete existing highlight&#xA;  :      wincmd p                       &quot; back to old window&#xA;  :    endif&#xA;  :&#xA;  :    &quot; Try displaying a matching tag for the word under the cursor&#xA;  :    try&#xA;  :       exe &quot;ptag &quot; . w&#xA;  :    catch&#xA;  :      return&#xA;  :    endtry&#xA;  :&#xA;  :    silent! wincmd P                 &quot; jump to preview window&#xA;  :    if &amp;amp;previewwindow                &quot; if we really get there...&#xA;  :      if has(&quot;folding&quot;)&#xA;  :        silent! .foldopen            &quot; don't want a closed fold&#xA;  :      endif&#xA;  :      call search(&quot;$&quot;, &quot;b&quot;)          &quot; to end of previous line&#xA;  :      let w = substitute(w, '\\', '\\\\', &quot;&quot;)&#xA;  :      call search('\&amp;lt;\V' . w . '\&amp;gt;') &quot; position cursor on match&#xA;  :      &quot; Add a match highlight to the word at this position&#xA;  :      hi previewWord term=bold ctermbg=green guibg=green&#xA;  :      exe 'match previewWord &quot;\%' . line(&quot;.&quot;) . 'l\%' . col(&quot;.&quot;) . 'c\k*&quot;'&#xA;  :      wincmd p                       &quot; back to old window&#xA;  :    endif&#xA;  :  endif&#xA;  :endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Perhaps your function could try &lt;code&gt;tag&lt;/code&gt; or &lt;code&gt;ptag&lt;/code&gt;, and in the catch clause it could try again including the &lt;code&gt;rpc_&lt;/code&gt; prefix.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-03-18T11:35:01.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6920" PostTypeId="2" ParentId="6844" CreationDate="2016-03-18T12:11:58.223" Score="3" Body="&lt;p&gt;Oh look, &lt;code&gt;--geometry&lt;/code&gt; is a &lt;a href=&quot;http://doc.qt.io/qt-5/qguiapplication.html&quot; rel=&quot;nofollow&quot;&gt;QT GUI application's main settings&lt;/a&gt; thus&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim-qt --geometry 500x320&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will create a windows just big enough to have 24 lines of 80 characters.&lt;/p&gt;&#xA;" OwnerUserId="622" LastActivityDate="2016-03-18T12:11:58.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6921" PostTypeId="1" AcceptedAnswerId="6922" CreationDate="2016-03-18T13:08:25.737" Score="9" ViewCount="1787" Body="&lt;p&gt;In &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap ii &amp;lt;esc&amp;gt;                               &quot; ii to go back into command mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is, after &lt;kbd&gt;ii&lt;/kbd&gt;, cursor jumps 35 columns right. The only other line which affects &lt;kbd&gt;Esc&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;esc&amp;gt;&amp;lt;esc&amp;gt; :noh&amp;lt;return&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried commenting it out, doesn't help.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.com/8ARcKfNm&quot; rel=&quot;noreferrer&quot;&gt;Full &lt;code&gt;.vimrc&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;filetype off&#xA;&#xA;&#xA;&quot; Vundle ---------------------------------------------------------------------&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'gmarik/Vundle.vim'&#xA;Plugin 'bling/vim-airline'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'scrooloose/nerdcommenter'&#xA;Plugin 'scrooloose/syntastic'&#xA;Plugin 'freitass/todo.txt-vim'&#xA;Plugin 'plasticboy/vim-markdown'&#xA;Plugin 'tpope/vim-fugitive'                     &quot; :GitCommands&#xA;Plugin 'tpope/vim-git'                          &quot; allows to see branch in airline&#xA;Plugin 'airblade/vim-gitgutter'                 &quot; git status in SL area&#xA;Plugin 'ctrlpvim/ctrlp.vim'                     &quot; TODO: learn more about this&#xA;Plugin 'Shougo/neocomplete.vim'                 &quot; TAB completion&#xA;&quot; Plugin 'tmhedberg/SimpylFold'                 &quot; should we add FastFold?&#xA;Plugin 'spf13/vim-autoclose'                    &quot; autoclose brackets(properly)&#xA;Plugin 'godlygeek/tabular'                      &quot; V -&amp;gt; : -&amp;gt; /SYMBOL_TO_LINE-UP&#xA;Plugin 'terryma/vim-multiple-cursors'           &quot; steep learning curve&#xA;Plugin 'Yggdroot/indentLine'                    &quot; shows | intendation&#xA;Plugin 'mhinz/vim-startify'                     &quot; start screen&#xA;Plugin 'hashivim/vim-vagrant'&#xA;Plugin 'pearofducks/ansible-vim'&#xA;Plugin 'whatyouhide/vim-gotham'&#xA;Plugin 'ryanoasis/vim-devicons'                 &quot; glyph icons everywhere&#xA;call vundle#end()&#xA;&#xA;&#xA;&quot; System ---------------------------------------------------------------------&#xA;set lazyredraw                                  &quot; do we need this?&#xA;set ttyfast                                     &quot; theoretically make things faster&#xA;set mouse=a                                     &quot; enable mouse&#xA;set guicursor=a:blinkon0                        &quot; don't blink with the cursor&#xA;set termencoding=utf-8                          &quot; terminal is UTF-8&#xA;set encoding=utf8                               &quot; ...as well as the editor&#xA;set fileformat=unix                             &quot; *nix format&#xA;set clipboard=unnamed                           &quot; Fix clipboard in *nix&#xA;set wildmenu&#xA;set wildmode=longest:full,full&#xA;set wildignore=*.o,*.pyc,*.DS_Store&#xA;set magic                                       &quot; needed for regexp&#xA;set hidden                                      &quot; allow switching buffers w/o saving&#xA;set nojoinspaces                                &quot; don't join spaces on paste&#xA;set formatoptions-=r formatoptions-=c formatoptions-=o &quot; don't autoextend comments&#xA;set lines=40 columns=90                         &quot; default size for GUI&#xA;set gdefault                                    &quot; replace all without /g&#xA;set virtualedit=all                             &quot; keep cursor horizontal pos. when scrolling&#xA;&#xA;set backup                                      &quot; backups ON&#xA;set undofile                                    &quot; persistent undo&#xA;set backupdir=~/.vim/backup&#xA;set directory=~/.vim/tmp&#xA;set undolevels=1000                             &quot; max number of undos&#xA;set undoreload=10000                            &quot; max lines to to save for undo&#xA;set history=1000                                &quot; 1000 of history (what?)&#xA;&#xA;set incsearch                                   &quot; incremental search&#xA;set smartcase                                   &quot; ... and case sensitive if Uppercase is present&#xA;&#xA;set expandtab                                   &quot; spaces instead of tabs&#xA;set smarttab                                    &quot; smart tabs/intends&#xA;set tabstop=4                                   &quot; TAB = 4 spaces&#xA;set softtabstop=4&#xA;set smartindent&#xA;set autoindent&#xA;set shiftwidth=4&#xA;set shiftround                                  &quot; round to 4&#xA;&#xA;let NERDSpaceDelims=1                           &quot; add space before comment&#xA;let NERDTreeMapOpenInTab='\r'                   &quot; open files in new tab&#xA;let g:vim_markdown_folding_disabled=1           &quot; don't fold *.md&#xA;&#xA;let g:neocomplete#enable_at_startup = 1         &quot; NeoComplete&#xA;let g:neocomplete#enable_auto_select = 1&#xA;let g:neocomplete#enable_smart_case = 1&#xA;let g:neocomplete#min_keyword_length = 2        &quot; min symbols before autocomplete&#xA;&#xA;&#xA;&quot; Visuals --------------------------------------------------------------------&#xA;filetype plugin indent on                       &quot; enable filetype plugins&#xA;syntax enable                                   &quot; enable syntax highlighting&#xA;let python_highlight_all=1                      &quot; full python highlighting&#xA;colorscheme gotham256                           &quot; GUI colours&#xA;let g:airline_theme = &quot;gotham256&quot;               &quot; airline theme&#xA;if has(&quot;gui_running&quot;)&#xA;    set cul&#xA;endif&#xA;&#xA;set title                                       &quot; set terminal title&#xA;set t_Co=256                                    &quot; 256 colors terminal&#xA;set guifont=Meslo\ LG\ S\ Regular\ for\ Powerline\ Nerd\ Font\ Complete\ Windows\ Compatible:h12&#xA;set guioptions=L                                &quot; disable right scrlbar&#xA;set guioptions=R                                &quot; disable left scrlbar&#xA;set number                                      &quot; show line numbers&#xA;set nowrap                                      &quot; don't wrap long lines&#xA;set fillchars+=vert:\?                          &quot; vertical unicode split&#xA;set shortmess+=I                                &quot; remove startup message&#xA;&#xA;set splitbelow                                  &quot; Natural splits&#xA;set splitright&#xA;&#xA;set hlsearch                                    &quot; highlight search results&#xA;set showmatch                                   &quot; show matching brackets&#xA;&#xA;set noerrorbells                                &quot; disable bells&#xA;set novisualbell&#xA;set vb t_vb=&#xA;&#xA;set laststatus=2                                &quot; always show airline&#xA;let g:airline_powerline_fonts=1                 &quot; use glyph fonts&#xA;let g:airline#extensions#tabline#enabled=1      &quot; enable tabline (top)&#xA;let g:airline#extensions#tabline#fnamemod=':t'  &quot; filename only&#xA;&#xA;set completeopt-=preview                        &quot; don't show doc. window by default&#xA;let g:SimplylFold_docstring_preview=1           &quot; keep docstring unfolded.&#xA;&#xA;let g:gitgutter_sign_added = '?'                &quot; Gitgutter&#xA;let g:gitgutter_sign_modified = '•'&#xA;let g:gitgutter_sign_removed = '?'&#xA;let g:indentLine_char = '¦'                     &quot; intendation vertical lines&#xA;&#xA;&#xA;&quot; Hotkeys --------------------------------------------------------------------&#xA;nnoremap &amp;lt;F1&amp;gt; &amp;lt;nop&amp;gt;                             &quot; F1 does noothing&#xA;map &amp;lt;F2&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;                    &quot; F2 to open NerdTree&#xA;set pastetoggle=&amp;lt;F3&amp;gt;                            &quot; F3 to switch in paste mode&#xA;map &amp;lt;F4&amp;gt; :mksession! ~/.vim/vim_session&amp;lt;CR&amp;gt;     &quot; F4 to write current session&#xA;map &amp;lt;F5&amp;gt; :source ~/.vim/vim_session&amp;lt;CR&amp;gt;         &quot; F5 to load prev. session&#xA;&#xA;inoremap ii &amp;lt;esc&amp;gt;                               &quot; ii to go back into command mode&#xA;let mapleader = &quot;\&amp;lt;Space&amp;gt;&quot;                      &quot; remap leader key from '\' to Space&#xA;map &amp;lt;leader&amp;gt;cd :cd %:p:h&amp;lt;cr&amp;gt;:pwd&amp;lt;cr&amp;gt;            &quot; CWD to the dir of the open buffer&#xA;nnoremap &amp;lt;esc&amp;gt;&amp;lt;esc&amp;gt; :noh&amp;lt;return&amp;gt;&amp;lt;esc&amp;gt;           &quot; 2xESC clears search highlights&#xA;&#xA;nnoremap &amp;lt;C-J&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-J&amp;gt;                       &quot; switch splits with CTRL+hjkl&#xA;nnoremap &amp;lt;C-K&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-K&amp;gt;&#xA;nnoremap &amp;lt;C-L&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-L&amp;gt;&#xA;nnoremap &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-H&amp;gt;&#xA;&#xA;nmap &amp;lt;leader&amp;gt;l :bn&amp;lt;CR&amp;gt;                          &quot; next buffer by Space+l&#xA;nmap &amp;lt;leader&amp;gt;h :bp&amp;lt;CR&amp;gt;                          &quot; previous buffer by Space+h&#xA;nmap &amp;lt;leader&amp;gt;q :bp &amp;lt;BAR&amp;gt; bd #&amp;lt;CR&amp;gt;               &quot; close buffer by Space+q&#xA;&#xA;vnoremap &amp;lt; &amp;lt;gv                                  &quot; leave txt selected after &amp;lt;&amp;gt;&#xA;vnoremap &amp;gt; &amp;gt;gv&#xA;&#xA;set t_ku=OA                                   &quot; fix arrow keys&#xA;set t_kd=OB&#xA;set t_kr=OC&#xA;set t_kl=OD&#xA;&#xA;nmap &amp;lt;leader&amp;gt;f1 :set foldlevel=0&amp;lt;CR&amp;gt;            &quot; change folding levels&#xA;nmap &amp;lt;leader&amp;gt;f2 :set foldlevel=1&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;f3 :set foldlevel=2&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;f4 :set foldlevel=3&amp;lt;CR&amp;gt;&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gs :Gstatus&amp;lt;CR&amp;gt;       &quot; GIT shortcuts&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gd :Gdiff&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gc :Gcommit&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gb :Gblame&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gl :Glog&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gp :Git push&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gr :Gread&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gw :Gwrite&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;ge :Gedit&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;ga :Git add %:p&amp;lt;CR&amp;gt;&#xA;&#xA;set backspace=eol,start,indent                  &quot; esoteric backspace fix&#xA;set whichwrap+=&amp;lt;,&amp;gt;                              &quot; move to another line with &amp;lt;- -&amp;gt;&#xA;&#xA;if bufwinnr(1)                                  &quot; resize splits with +-&#xA;  map + &amp;lt;C-W&amp;gt;+&#xA;  map - &amp;lt;C-W&amp;gt;-&#xA;endif&#xA;&#xA;&quot; NeoComplete&#xA;&quot; &amp;lt;CR&amp;gt;: close popup and save indent.&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;CR&amp;gt; &amp;lt;C-r&amp;gt;=&amp;lt;SID&amp;gt;my_cr_function()&amp;lt;CR&amp;gt;&#xA;function! s:my_cr_function()&#xA;    &quot; return neocomplete#close_popup() . &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;    &quot; For no inserting &amp;lt;CR&amp;gt; key.&#xA;    return pumvisible() ? neocomplete#close_popup() : &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;&quot; &amp;lt;TAB&amp;gt;: completion.&#xA;inoremap &amp;lt;expr&amp;gt;&amp;lt;TAB&amp;gt;  pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;TAB&amp;gt;&quot;&#xA;&#xA;&#xA;&quot; Macros ---------------------------------------------------------------------&#xA;&#xA;&quot; Emulate any other editor with tabs&#xA;try&#xA; set switchbuf=useopen,usetab,newtab&#xA;catch&#xA;endtry&#xA;&#xA;&quot; Close vim if NerdTree is the only buffer left&#xA;autocmd bufenter * if (winnr(&quot;$&quot;) == 1 &amp;amp;&amp;amp; exists(&quot;b:NERDTreeType&quot;) &amp;amp;&amp;amp; b:NERDTreeType == &quot;primary&quot;) | q | endif&#xA;&#xA;&quot; Return to last edit position when opening files&#xA;autocmd BufReadPost *&#xA;    \ if line(&quot;'\&quot;&quot;) &amp;gt; 0 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) |&#xA;    \   exe &quot;normal! g`\&quot;&quot; |&#xA;    \ endif&#xA;&#xA;&quot; Python with virtualenv support&#xA;py &amp;lt;&amp;lt; EOF&#xA;import os&#xA;import sys&#xA;if 'VIRTUAL_ENV' in os.environ:&#xA;  project_base_dir = os.environ['VIRTUAL_ENV']&#xA;  activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')&#xA;  execfile(activate_this, dict(__file__=activate_this))&#xA;EOF&#xA;&#xA;&quot; Enable omni completion.&#xA;autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS&#xA;autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags&#xA;autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS&#xA;autocmd FileType python setlocal omnifunc=pythoncomplete#Complete&#xA;autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags&#xA;&#xA;&quot; Enable heavy omni completion.&#xA;if !exists('g:neocomplete#sources#omni#input_patterns')&#xA;  let g:neocomplete#sources#omni#input_patterns = {}&#xA;endif&#xA;&#xA;&quot; format JSON code&#xA;com! FormatJSON %!python -m json.tool&#xA;&#xA;&quot; BG fix for tmux&#xA;set t_ut=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user6649" LastEditorUserId="205" LastEditDate="2016-03-18T17:02:48.070" LastActivityDate="2016-03-19T19:42:19.203" Title="Why does remapping &lt;Esc&gt; make the cursor jump?" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6922" PostTypeId="2" ParentId="6921" CreationDate="2016-03-18T14:11:15.997" Score="19" Body="&lt;p&gt;Your problem is that you put comments at the end of your lines separated by whitespaces. Vim interprets these whitespaces as part of your commands and mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you replace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap ii &amp;lt;esc&amp;gt;                               &quot; ii to go back into command mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ii to go back into command mode&#xA;inoremap ii &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will solve your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;As a general rule&lt;/strong&gt; don't put comments at the end of your lines in your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;And as a bonus&lt;/strong&gt; Here is a method to transform your &lt;code&gt;.vimrc&lt;/code&gt; in a proper format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; Use this command. (Compared to the original one, the new line character &lt;code&gt;\r&lt;/code&gt; can be directly copied and you don't have to use &lt;code&gt;^M&lt;/code&gt;. Thanks @Sato!) &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :%s/\(^.*\)\s\+\(&quot;.*\)/\2\r\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original command&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :%s/\(^.*\)\s\+\(&quot;.*\)/\2^M\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(To insert the &lt;code&gt;^M&lt;/code&gt; properly use &lt;kbd&gt;Ctrl-v&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; to insert a real new line character)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command will capture the beginning of lines containing a comment on the end of the line and replace the full line with two lines containing the comment and then the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Note that the command seems to mess with the function &lt;code&gt;my_cr_function&lt;/code&gt; so you might want to check that it doesn't create to much trouble in your &lt;code&gt;.vimrc&lt;/code&gt; maybe replace &lt;code&gt;%&lt;/code&gt; by some ranges and change your &lt;code&gt;.vimrc&lt;/code&gt; step by step)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;@Sato also suggested &lt;a href=&quot;https://github.com/vim/vim/issues/694#issuecomment-198063315&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt; about how comments and multiline works it is worth reading it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-03-19T19:42:19.203" LastActivityDate="2016-03-19T19:42:19.203" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6923" PostTypeId="1" AcceptedAnswerId="6925" CreationDate="2016-03-18T14:49:31.760" Score="3" ViewCount="1928" Body="&lt;p&gt;I'm trying to save the current relative path of my file and line number into my clipboard.&#xA;I would like to have &lt;code&gt;application/models/my_model.rb:34&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't understand how &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#expand()&quot; rel=&quot;nofollow&quot;&gt;expand&lt;/a&gt; works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They have this example :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Example:&#xA;            :let &amp;amp;tags = expand(&quot;%:p:h&quot;) . &quot;/tags&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I failed when I want to combine relative path &lt;code&gt;expand(&quot;%:h&quot;)&lt;/code&gt; and file_name &lt;code&gt;expand(&quot;%:t&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echom expand(&quot;%:h:t&quot;) . ':' . line(&quot;.&quot;)  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;returns &lt;code&gt;model:34&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas ?&lt;/p&gt;&#xA;" OwnerUserId="3357" LastActivityDate="2016-03-18T17:16:02.993" Title="Yank current file path and line number into system clipboard" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6924" PostTypeId="2" ParentId="6923" CreationDate="2016-03-18T14:54:53.510" Score="2" Body="&lt;p&gt;One way to do it to combine expand :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echom expand(&quot;%:h&quot;) . '/' . expand(&quot;%:t&quot;) . ':' . line(&quot;.&quot;)    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3357" LastActivityDate="2016-03-18T14:54:53.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6925" PostTypeId="2" ParentId="6923" CreationDate="2016-03-18T17:16:02.993" Score="6" Body="&lt;p&gt;You should just use &lt;code&gt;expand('%')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/..; vim ~/.vim/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo join([expand('%'),  line(&quot;.&quot;)], ':')&#xA;muru/.vim/vimrc:1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or with &lt;code&gt;cd ~/Documents; vim ~/.vim/vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo join([expand('%'),  line(&quot;.&quot;)], ':') join([expand('%:h'), expand('%:t')], '/')&#xA;/home/muru/.vim/vimrc:1 /home/muru/.vim/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;expand('%:h')&lt;/code&gt; does not offer any advantages here. Doing &lt;code&gt;expand(&quot;%:h&quot;) . '/' . expand(&quot;%:t&quot;)&lt;/code&gt; is just going to give you back &lt;code&gt;expand('%')&lt;/code&gt;, with the added problem that you lose portability - &lt;code&gt;/&lt;/code&gt; is not always the correct separator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Side note: &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#join%28%29&quot;&gt;&lt;code&gt;join()&lt;/code&gt;&lt;/a&gt; is a convenient function for joining strings with separators. Not necessary here, where we have only two items, but could be useful if you add more strings.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-03-18T17:16:02.993" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6926" PostTypeId="1" AcceptedAnswerId="6939" CreationDate="2016-03-19T02:56:02.817" Score="1" ViewCount="293" Body="&lt;p&gt;How I can make a window automatically visible on all tabs ? Like &lt;a href=&quot;https://github.com/jistr/vim-nerdtree-tabs&quot; rel=&quot;nofollow&quot;&gt;NerdTree-tabs&lt;/a&gt; plugin: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabs&#xA;Aba 1&#xA;    NERD_tree_1&#xA;    main.c&#xA;Aba 2&#xA;    NERD_tree_1&#xA;    Makefile&#xA;Aba 3&#xA;    NERD_tree_1&#xA;&amp;gt;   readme.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6876" LastEditorUserId="1841" LastEditDate="2016-03-19T17:28:46.760" LastActivityDate="2016-03-19T19:16:19.513" Title="How to make a window visible on all tabs" Tags="|vimrc|vim-windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6927" PostTypeId="1" CreationDate="2016-03-19T03:42:24.697" Score="4" ViewCount="151" Body="&lt;p&gt;I don't actually want &lt;code&gt;f&lt;/code&gt; itself to wrap across lines, but I would like to know how I can create a single key mapping which will jump to the next instance of the letter which follows it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mapping could be &lt;code&gt;f&lt;/code&gt; or something else; perhaps I would use &lt;code&gt;&amp;lt;C-/&amp;gt;&lt;/code&gt; which seems unbound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The intention is that it would operate sort of like a function, and would take the next letter as its argument and perform:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&amp;lt;argument&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this possible, or would there have to be a separate key mapping for every letter, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-/&amp;gt;a /a&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-/&amp;gt;b /b&amp;lt;CR&amp;gt;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="1841" LastEditDate="2016-03-19T19:08:29.850" LastActivityDate="2016-03-19T19:12:05.650" Title="How can I make f motions wrap across lines?" Tags="|key-bindings|cursor-motions|normal-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6928" PostTypeId="2" ParentId="6927" CreationDate="2016-03-19T07:14:32.033" Score="2" Body="&lt;p&gt;You could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-f&amp;gt; '/' . nr2char(getchar()) . '&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h getchar&lt;/code&gt; and &lt;code&gt;:h nr2char&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2016-03-19T19:12:05.650" LastActivityDate="2016-03-19T19:12:05.650" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="6929" PostTypeId="1" AcceptedAnswerId="6932" CreationDate="2016-03-19T07:22:34.920" Score="6" ViewCount="784" Body="&lt;p&gt;I read that &lt;code&gt;.&lt;/code&gt; is used for repeating the last command in Normal Mode. So if I used the command &lt;code&gt;2w&lt;/code&gt; move forward two words and then press &lt;code&gt;.&lt;/code&gt; then I would expect to move two words more however this does not happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anyone please tell me why ?  &lt;/p&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="1841" LastEditDate="2016-03-19T07:42:01.057" LastActivityDate="2016-03-19T12:34:21.000" Title="Repeating the last move using . (w followed by .)" Tags="|macvim|repeated-commands|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6930" PostTypeId="2" ParentId="6929" CreationDate="2016-03-19T07:58:23.140" Score="3" Body="&lt;p&gt;Vim answers this in the &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#.&quot; rel=&quot;nofollow&quot;&gt;help about the dot command&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.           Repeat last change, with count replaced with [count].&#xA;            Also repeat a yank command, when the 'y' flag is&#xA;            included in 'cpoptions'.  Does not repeat a&#xA;            command-line command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;.&lt;/code&gt; simply repeats the last &lt;em&gt;change&lt;/em&gt;, not motions, or command-line commands.&lt;/p&gt;&#xA;" OwnerUserId="246" LastActivityDate="2016-03-19T07:58:23.140" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6931" PostTypeId="2" ParentId="6884" CreationDate="2016-03-19T09:43:56.753" Score="1" Body="&lt;p&gt;Turns out, my &lt;code&gt;vim-gtk&lt;/code&gt; was not compiled with Python support, the output of&#xA;&lt;code&gt;&#xA;:echo has(&quot;python&quot;)&#xA;&lt;/code&gt;&#xA;Returned &lt;code&gt;0&lt;/code&gt;. Manually compiling vim with python support as listed &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; solved the issue.&lt;/p&gt;&#xA;" OwnerUserId="6514" LastActivityDate="2016-03-19T09:43:56.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6932" PostTypeId="2" ParentId="6929" CreationDate="2016-03-19T11:12:40.477" Score="6" Body="&lt;p&gt;As stated in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html#.&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h .&lt;/code&gt;&lt;/a&gt; the dot command only repeat changes, but commands like &lt;code&gt;w&lt;/code&gt; are motions not changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can repeat motions like &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt; and &lt;code&gt;T&lt;/code&gt; with the commands &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;g;&lt;/code&gt; (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#;&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h ;&lt;/code&gt;&lt;/a&gt;). And for more complex repeat you could have a look to the easymotion plugin &lt;a href=&quot;https://github.com/easymotion/vim-easymotion#repeat-motions&quot; rel=&quot;noreferrer&quot;&gt;readme&lt;/a&gt;: combined with &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;noreferrer&quot;&gt;vim-repeat&lt;/a&gt; you might be able to repeat the movements the way you want to do it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="64" LastEditDate="2016-03-19T12:34:21.000" LastActivityDate="2016-03-19T12:34:21.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6933" PostTypeId="1" CreationDate="2016-03-19T11:57:33.360" Score="4" ViewCount="1496" Body="&lt;p&gt;Markdown highlighting is great (&lt;a href=&quot;https://vi.stackexchange.com/q/6627/4676&quot;&gt;when it works&lt;/a&gt;), but I've seen a problem on two different boxes with underscores in inline code and I'm wondering if there's an easy solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I put, for instance, &lt;code&gt;file_names&lt;/code&gt; in inline code, the underscores in between the backticks are stripped of their special meaning as far as markdown rendering engines are concerned.  However, Vim still highlights them differently.  On one box (my Windows box using MobaXterm) the underscores themselves are highlighted in red, but none of the surrounding text is displayed differently (which isn't too bad).  But on my Mac, all the text from one underscore to the next is highlighted with a white background (on my black background terminal) which is extremely distracting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get the markdown syntax highlighting code to properly ignore the underscores when they occur between backticks?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2021-03-04T19:36:08.477" Title="Turn off markdown highlighting for underscores in inline code?" Tags="|syntax-highlighting|filetype-markdown|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6934" PostTypeId="1" AcceptedAnswerId="8804" CreationDate="2016-03-19T12:32:54.870" Score="3" ViewCount="237" Body="&lt;p&gt;&lt;strong&gt;Edit: Solved. See GitHub: &lt;a href=&quot;https://github.com/amix/vimrc/issues/204#issuecomment-231083581&quot; rel=&quot;nofollow&quot;&gt;amix/vimrc#204&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often drop a shell out of my vim window by &lt;code&gt;:!bash&lt;/code&gt; but I have two problems with it. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I can't use UTF8 for pipes&lt;/li&gt;&#xA;&lt;li&gt;with QWERTZ layout, I can't use Umlaut keys like &lt;code&gt;öäü&lt;/code&gt;, i.e. &lt;code&gt;ö&lt;/code&gt; behaves like &lt;code&gt;ALT-_&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think the problems are somehow related.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything I missed regarding both problems?&lt;/p&gt;&#xA;" OwnerUserId="6878" LastEditorUserId="6878" LastEditDate="2016-07-12T17:41:32.090" LastActivityDate="2016-07-15T15:27:47.117" Title="Strange shell (bash) behavior when started from vim" Tags="|bash|" AnswerCount="1" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="6935" PostTypeId="1" AcceptedAnswerId="6948" CreationDate="2016-03-19T16:02:03.587" Score="5" ViewCount="4432" Body="&lt;p&gt;I have a following python code, which contains both 4 space and 2 space indents.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Foo(object):&#xA;    def __init__(self,&#xA;                 flag = False):&#xA;      if flag:&#xA;        print(&quot;hello&quot;)&#xA;        print(&quot;how are you?&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I auto-indent the python code below with &lt;code&gt;gg=G&lt;/code&gt;, the above code becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Model(object):&#xA;    def __init__(self,&#xA;                 flag = False):&#xA;        if flag:&#xA;            print(&quot;hello&quot;)&#xA;        print(&quot;how are you?&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code is wrong because the last line should be under the &lt;code&gt;if&lt;/code&gt; block. Why is this happening?&lt;/p&gt;&#xA;" OwnerUserId="3290" LastActivityDate="2016-03-20T06:14:14.043" Title="Incorrect auto-indent in python code" Tags="|indentation|filetype-python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6936" PostTypeId="1" AcceptedAnswerId="6937" CreationDate="2016-03-19T16:11:31.883" Score="3" ViewCount="163" Body="&lt;p&gt;Usually, vim will get the highlighting right from the file extension, but this obviously doesn't work when I'm displaying content read from standard input.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat File.hs | some | processing | pipeline | view -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can obtain the proper highlighting with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set syntax=haskell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that's awkward to do multiple times. How do I select the highlighting right at command-line invocation?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat File.hs | vim -R {???syntax=haskell} -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6882" LastEditorUserId="1841" LastEditDate="2016-03-19T16:47:31.650" LastActivityDate="2016-03-19T16:47:31.650" Title="How can I select a syntax highlighting at the (shell-) command line?" Tags="|syntax-highlighting|invocation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6937" PostTypeId="2" ParentId="6936" CreationDate="2016-03-19T16:37:50.717" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;+command&lt;/code&gt; to execute &lt;code&gt;command&lt;/code&gt; after the &quot;file&quot; is loaded:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat File.hs | some | processing | pipeline | vim -R +'setf haskell' -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-03-19T16:37:50.717" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6938" PostTypeId="1" AcceptedAnswerId="6941" CreationDate="2016-03-19T16:41:57.077" Score="4" ViewCount="997" Body="&lt;p&gt;I see how to copy text in vim using visual mode, arrow keys, &lt;kbd&gt;y&lt;/kbd&gt; to yank, and &lt;kbd&gt;p&lt;/kbd&gt; to paste. I also see how to find a given starting string using back slash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'd appreciate knowing how to copy all the text from a given start phrase (such as &lt;code&gt;To list all available commands enter &quot;/?&quot;&lt;/code&gt;) to a given stop phrase (such as &lt;code&gt;Enter chat message or link here&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd normally just use arrow keys, but for my application, the number of lines in-between the start and stop phrases may vary, so I'd like one script to work in all cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot in advance!  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. Does the solution also work in vimium? I asked the question on this site because practically everything that works for vim also works for vimium, but my actual application uses vimium.&lt;/p&gt;&#xA;" OwnerUserId="5923" LastEditorUserId="1841" LastEditDate="2016-03-19T19:43:36.227" LastActivityDate="2016-03-19T19:43:36.227" Title="Copy text based on delimiting strings" Tags="|search|cut-copy-paste|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6939" PostTypeId="2" ParentId="6926" CreationDate="2016-03-19T16:46:27.830" Score="2" Body="&lt;p&gt;First, @romainl's comment is a really good advice: you'll learn a lot by reading a real plugin code and trying to understand its behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you're new to vimscript and coding, it can be pretty hard. So here is a solution. &lt;em&gt;(It is probably more simple and maybe not as efficient as NERDTree way to do it but it should work properly)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:windowToKeep=[]&#xA;&#xA;nnoremap &amp;lt;F2&amp;gt; :call SetWindowToKeep()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;F4&amp;gt; :call OpenTab()&amp;lt;CR&amp;gt;&#xA;&#xA;function! SetWindowToKeep()&#xA;    let g:windowToKeep = [expand(&quot;%:p&quot;), winheight(0), winwidth(0)]&#xA;endfunction&#xA;&#xA;function! OpenTab()&#xA;    execute &quot;tabedit &quot; . g:windowToKeep[0]&#xA;    execute &quot;vsplit&quot;&#xA;    execute &quot;resize &quot; . g:windowToKeep[1]&#xA;    execute &quot;vertical resize &quot; . g:windowToKeep[2]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea behind this code is that &quot;make a window visible on all tabs&quot; is actually doing the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Selecting a windows containing a buffer as the one you want to keep&lt;/li&gt;&#xA;&lt;li&gt;Then each time a new tab is created, it is splited to contain:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The selected window with the same buffer and the same size&lt;/li&gt;&#xA;&lt;li&gt;Another window containing a new buffer&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To do so, this code will create a variable &lt;code&gt;g:windowToKeep&lt;/code&gt; which will contain the window that you want to keep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To set this variable a mapping is done on &lt;kbd&gt;F2&lt;/kbd&gt;: you'll have to press this key to set the window to keep on your tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can call the function &lt;code&gt;OpenTab()&lt;/code&gt; either with ex mode or by pressing &lt;kbd&gt;F4&lt;/kbd&gt;. This function creates a new tab with a buffer you want to keep, split the tab and resize the window containing your buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 1&lt;/strong&gt; You can (of course) replace &lt;code&gt;&amp;lt;F2&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;F4&amp;gt;&lt;/code&gt; by your favorite mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 2&lt;/strong&gt; It is possible that the function isn't exactly what you expected because your workflow can be a little different than what I imagined while creating the code. As it's a pretty simple code you should be able to tweak it to fit your needs more closely. &lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-03-19T19:16:19.513" LastActivityDate="2016-03-19T19:16:19.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6940" PostTypeId="2" ParentId="6938" CreationDate="2016-03-19T17:32:50.903" Score="1" Body="&lt;p&gt;After some googling (mainly thanks to &lt;a href=&quot;https://vi.stackexchange.com/questions/1915/how-do-i-delete-a-large-block-of-text-without-counting-the-lines?rq=1&quot;&gt;this post&lt;/a&gt;), I seem to have come up with a solution. The crucial idea is to use marks.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, search for the starting phrase using the back slash command. Call this mark &lt;code&gt;a&lt;/code&gt; by typing &lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, search for the closing phrase using the back slash command again. Finally, once the cursor is at this position, type &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; (to yank to mark &lt;code&gt;a&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="5923" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-03-19T17:32:50.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6941" PostTypeId="2" ParentId="6938" CreationDate="2016-03-19T18:03:01.370" Score="4" Body="&lt;p&gt;I think the idea of using marks is indeed a good approach. Here is a function to add to your &lt;code&gt;.vimrc&lt;/code&gt; to ease the process:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SelectDelimitations(start, end)&#xA;    &quot; Set start mark&#xA;    call search(a:start)&#xA;    normal! ma&#xA;    &quot; Set end mark at the end of the match&#xA;    call search(a:end, &quot;e&quot;)&#xA;    normal! mb&#xA;&#xA;    &quot; Go to start mark and select the text&#xA;    normal! `a&#xA;    normal! v`b&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use the function this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call SelectDelimitation(&quot;Start pattern&quot;, &quot;end pattern&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will select the text between the patterns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An interesting point in this function is that the text is selected character wise thanks to the backtick used in the &lt;code&gt;normal&lt;/code&gt; command and the search flag &lt;code&gt;e&lt;/code&gt; used to go to the end of the second pattern.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="21" LastEditDate="2016-03-19T19:18:22.227" LastActivityDate="2016-03-19T19:18:22.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6942" PostTypeId="1" CreationDate="2016-03-19T22:37:39.057" Score="3" ViewCount="2771" Body="&lt;p&gt;By default my Ultisnips (or maybe it's Vim) associate &lt;em&gt;.h&lt;/em&gt; files with C++ snippets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was about to ask how to make how to make Ultisnipps associate &lt;em&gt;.h&lt;/em&gt; files with &lt;em&gt;c&lt;/em&gt; types, but then I realized that my C snippets are valid for C++, so my question is how can I use common snippets for C and C++ ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you !&lt;/p&gt;&#xA;" OwnerUserId="6078" LastActivityDate="2016-03-20T01:27:30.647" Title="Ultisnips: using common snippets for C and C++" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6943" PostTypeId="1" AcceptedAnswerId="6960" CreationDate="2016-03-19T23:48:01.833" Score="7" ViewCount="2674" Body="&lt;p&gt;I'm trying to write a syntax file for Linux logrotate scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often they contain inline definitions of scripts to be run before or after the rotate action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example (the &lt;code&gt;cups-daemon&lt;/code&gt; logrotate script as provided by Ubuntu 14.04):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    prerotate&#xA;            if [ -e /var/run/cups/cupsd.pid ]; then&#xA;                    invoke-rc.d --quiet cups stop &amp;gt; /dev/null&#xA;                    touch /var/run/cups/cupsd.stopped&#xA;            fi&#xA;    endscript&#xA;    postrotate&#xA;            if [ -e /var/run/cups/cupsd.stopped ]; then&#xA;                    rm /var/run/cups/cupsd.stopped&#xA;                    invoke-rc.d --quiet cups start &amp;gt; /dev/null&#xA;                    sleep 10&#xA;            fi&#xA;    endscript&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way to both:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;highlight &lt;code&gt;prerotate&lt;/code&gt; and &lt;code&gt;postrotate&lt;/code&gt; as keywords, and&lt;/li&gt;&#xA;&lt;li&gt;highlight all in between as a region?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I may define proper highlighting for either of those, but it seems not for both.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; this works&#xA;syntax keyword LogrotateKeyword prerotate postrotate endscript&#xA;&#xA;&quot; this also works&#xA;syntax region LogrotateScript start=/prerotate/ms=e+1 end=/endscript/me=s-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now both of those in the same syntax file yield only highlighting for keywords, regardless of the rule order used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;match&lt;/code&gt; (with &lt;code&gt;\zs&lt;/code&gt;/&lt;code&gt;\ze&lt;/code&gt; or lookaheads/lookbehinds) instead of &lt;code&gt;region&lt;/code&gt; too. I also tried to use &lt;code&gt;match&lt;/code&gt; for both the keywords and inline scripts, hoping it would not make the definitions overlap, the results seem to be just the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I might keep the default color for the inline script, but apparently frequently the inline stuff contains other logrotate keywords, which might be confusing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most likely irrelevant to this issue: Vim 7.4 with patches 1-1529 (pi-rho PPA) and Ubuntu 14.04.&lt;/p&gt;&#xA;" OwnerUserId="2329" LastActivityDate="2016-03-21T14:22:09.877" Title="Syntax highlight region / keyword overlap" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6944" PostTypeId="2" ParentId="6942" CreationDate="2016-03-20T01:27:30.647" Score="2" Body="&lt;p&gt;UltiSnips has the &lt;code&gt;extends&lt;/code&gt; keyword. You pass a comma separated list of filetypes to it and it will load the snippets for those filetypes before the snippets in the file the keyword is used in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;extends c, obj-c&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This way you can have a &quot;cpp.snippets&quot; file which &quot;extends&quot; your c filetype and obj-c type. The documentation doesn't mention cyclic extending but it will probably get in a loop and break something so don't do that. I'm pretty sure you can use a fake filetype so you can do something like this:&lt;br&gt;&#xA; - create a snippet file called &quot;cgeneral.snippets&quot; which shouldn't get loaded by UltiSnips automatically&lt;br&gt;&#xA; - create your &quot;c.snippets&quot; file&lt;br&gt;&#xA; - add &quot;extend cgeneral&quot; at the top (can actually be anywhere in the file)&lt;br&gt;&#xA; - repeat for &quot;cpp.snippets&quot;&lt;br&gt;&#xA;Now you can have all general stuff in &quot;cgeneral&quot; and import that into your c.snippets file and your cpp one, too.&lt;/p&gt;&#xA;" OwnerUserId="20" LastActivityDate="2016-03-20T01:27:30.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6945" PostTypeId="1" AcceptedAnswerId="6946" CreationDate="2016-03-20T02:53:11.643" Score="14" ViewCount="2141" Body="&lt;p&gt;Suppose I have the following four lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1&#xA;line2&#xA;line3&#xA;line4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I go to &lt;code&gt;line1&lt;/code&gt; and do a &lt;code&gt;yy&lt;/code&gt; which copies the line and then go to start of &lt;code&gt;line3&lt;/code&gt; and do a paste using 'p', I would get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;line3&#xA;line1&#xA;line4&#xA;....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why did it paste &lt;code&gt;line1&lt;/code&gt; after &lt;code&gt;line3&lt;/code&gt; in a new line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My initial though was because the newline character $ was attached to line3 and that when I pressed &lt;code&gt;p&lt;/code&gt; vim considered &lt;code&gt;line3$&lt;/code&gt; as one word so it pasted after &lt;code&gt;line3$&lt;/code&gt;. However it seems my understanding was wrong. Because if I do this &lt;code&gt;line3 $&lt;/code&gt; and then do a &lt;code&gt;p&lt;/code&gt; at the start of the line I get the same result. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does &lt;code&gt;p&lt;/code&gt; create a new line and paste in a new line after &lt;code&gt;line3&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="205" LastEditDate="2016-03-20T07:52:49.267" LastActivityDate="2016-03-20T07:52:49.267" Title="Why did p paste a copied line after the current line, instead of after the current word?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6946" PostTypeId="2" ParentId="6945" CreationDate="2016-03-20T04:09:04.727" Score="23" Body="&lt;p&gt;When you deleted the line using &lt;code&gt;dd&lt;/code&gt;, you performed a &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#linewise&quot; rel=&quot;noreferrer&quot;&gt;linewise&lt;/a&gt; delete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;p&lt;/code&gt; command pastes after the cursor position.  Since the default register was populated with linewise content, that means it will paste after the line the cursor is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you had instead deleted the contents of the line in a characterwise manner (e.g., &lt;code&gt;0D&lt;/code&gt;), then the register would have been characterwise and therefore pasted after the character the cursor was on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, the behavior should follow what be expected from a delete/yank and paste.  However, it is possible to modify the &lt;code&gt;-wise&lt;/code&gt;ness of a register using &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#getreg()&quot; rel=&quot;noreferrer&quot;&gt;getreg()&lt;/a&gt;/&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#setreg()&quot; rel=&quot;noreferrer&quot;&gt;setreg()&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be careful doing that, though.  Given your initial example, simply changing the register to be characterwise doesn't remove the newline that was part of the delete.  It just changes how the paste occurs.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For recommendations on the specific scenario of deleting an entire line but pasting it characterwise, see &lt;a href=&quot;https://vi.stackexchange.com/q/6651/15&quot;&gt;this post&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-03-20T04:09:04.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6948" PostTypeId="2" ParentId="6935" CreationDate="2016-03-20T06:14:14.043" Score="8" Body="&lt;p&gt;In this case, the auto-indentation seems confused because the &lt;code&gt;def __init__()&lt;/code&gt; is indented by four spaces, while the others are indented by two spaces. This is valid Python, but the Vim Python indentation code doesn't seem to be advanced enough to deal with this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Python source there's &lt;code&gt;Tools/scripts/reindent.py&lt;/code&gt;, which can fix indentation. When I run it on your example it seems to work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27equalprg%27&quot;&gt;&lt;code&gt;'equalprg'&lt;/code&gt;&lt;/a&gt; to run this with &lt;code&gt;=&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType python setlocal equalprg=/home/martin/src/Python-3.5.1/Tools/scripts/reindent.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some distros also package this script with the main Python package. Debian/Ubuntu puts it in the &lt;code&gt;python-examples&lt;/code&gt; package. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also some other tools, like &lt;a href=&quot;https://pypi.python.org/pypi/autopep8&quot;&gt;autopep8&lt;/a&gt;. Personally, I don't like autoformatting tools that do too much, as they break the most important style rule of all: think and do something sane.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked at the source of &lt;code&gt;reindent.py&lt;/code&gt;, and it seems like a well-built script (&lt;em&gt;Carpetsmoker seal of approval™&lt;/em&gt;). I believe &lt;code&gt;autopep8&lt;/code&gt; is used quite a lot, so I'll assume that works well enough too.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-03-20T06:14:14.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6949" PostTypeId="1" CreationDate="2016-03-20T07:50:49.923" Score="1" ViewCount="722" Body="&lt;p&gt;I am now using &lt;code&gt;vi&lt;/code&gt; to edit a &lt;code&gt;Gtk&lt;/code&gt; program in &lt;code&gt;C&lt;/code&gt;. I can compile it easily using the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gcc -Wall `pkg-config --cflags gtk+-3.0` -o gtk gtk.c `pkg-config --libs gtk+-3.0`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no problem doing this. But when I am editing it in &lt;code&gt;vi&lt;/code&gt;, there are lots of errors (I am using &lt;code&gt;ycmd&lt;/code&gt; for auto-completion):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/U54Ys.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/U54Ys.png&quot; alt=&quot;image&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and the first error being &lt;code&gt;&amp;lt;gtk/gtk.h&amp;gt; not found&lt;/code&gt;. If I change it to &lt;code&gt;&amp;lt;gtk-3.0/gtk/gtk.h&amp;gt;&lt;/code&gt; it will work, but it has problem in the header &lt;code&gt;gtk.h&lt;/code&gt; itself, like it can't find &lt;code&gt;&amp;lt;gdk/gdk.h&amp;gt;&lt;/code&gt;. Can anyone tell me how to solve this? Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;EDIT:&lt;/em&gt;&lt;/strong&gt; I use the following flags in the &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iD2vd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iD2vd.png&quot; alt=&quot;second&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in the end it also has these errors:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PezAC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PezAC.png&quot; alt=&quot;thrid&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6380" LastEditorUserId="6380" LastEditDate="2016-03-20T14:06:49.863" LastActivityDate="2016-03-20T14:06:49.863" Title="gtk.h not found" Tags="|autocompletion|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6950" PostTypeId="1" AcceptedAnswerId="6955" CreationDate="2016-03-20T15:48:16.397" Score="18" ViewCount="8740" Body="&lt;p&gt;I flip between Ruby and Markdown files a lot. Is there a way that I can have &lt;code&gt;set spell&lt;/code&gt; automatically set when I open a &lt;code&gt;*.md&lt;/code&gt; file, but not when I open a &lt;code&gt;*.rb&lt;/code&gt; one?&lt;/p&gt;&#xA;" OwnerUserId="4748" LastEditorUserId="1841" LastEditDate="2016-03-20T19:02:52.140" LastActivityDate="2018-03-07T13:55:10.270" Title="How to enable spell check for certain file types?" Tags="|vimrc|autocmd|spell-checking|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6951" PostTypeId="1" CreationDate="2016-03-20T16:10:24.243" Score="5" ViewCount="2105" Body="&lt;p&gt;I have two files in two different buffers and I want to get the difference between these two files in another file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this with Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;BUFFER1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rtl.de&#xA;sat1.de&#xA;pro7.de&#xA;spiegel.de&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;BUFFER2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rtl.de&#xA;sat1.de&#xA;heise.de&#xA;pro7.de&#xA;spiegel.de&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;buffer3&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;heise.de&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6893" LastEditorUserId="1841" LastEditDate="2016-03-20T18:42:08.507" LastActivityDate="2016-03-20T19:12:22.797" Title="How to put the difference of two files in another file" Tags="|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6952" PostTypeId="1" AcceptedAnswerId="6956" CreationDate="2016-03-20T16:12:17.953" Score="9" ViewCount="312" Body="&lt;p&gt;Consider a file with the following two lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;someLongFunction&#xA;someFunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I am in the insert mode in the middle of the second word&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some|Function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I press &lt;code&gt;Ctrl-n&lt;/code&gt;, I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;someLongFunctionFunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way of configuring Vim so that I get the following &quot;smart&quot; completion instead?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;someLongFunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6894" LastEditorUserId="6894" LastEditDate="2016-03-20T16:54:36.733" LastActivityDate="2016-03-20T20:08:43.860" Title="Smart word completion when in the middle of a word" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6953" PostTypeId="2" ParentId="6951" CreationDate="2016-03-20T18:52:22.993" Score="8" Body="&lt;p&gt;Vim offers a tool to see the difference between two buffers and put contents from one to another: &lt;code&gt;diffthis&lt;/code&gt; (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/diff.html#:diffthis&quot;&gt;&lt;code&gt;:h :diffthis&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get this diff mode you can either start it from the command line with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vimdiff file1 file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or from within Vim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open both of the buffers.&lt;/li&gt;&#xA;&lt;li&gt;create a split window to get both of the buffers on your screen. (with &lt;code&gt;:split&lt;/code&gt; and &lt;code&gt;:e&lt;/code&gt; for example)&lt;/li&gt;&#xA;&lt;li&gt;Start the diff mode with &lt;code&gt;:windo diffthis&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:diffput&lt;/code&gt; and &lt;code&gt;:diffget&lt;/code&gt; to modify the content of the buffers (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/diff.html#:diffput&quot;&gt;&lt;code&gt;:h :diffput&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/diff.html#:diffget&quot;&gt;&lt;code&gt;:h :diffget&lt;/code&gt;&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:diffoff&lt;/code&gt; to stop the diff mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now to put the diff of the files in a third one I would recommend to use the &lt;code&gt;diff&lt;/code&gt; from the (shell) command line with something like (See &lt;a href=&quot;http://linux.die.net/man/1/diff&quot;&gt;&lt;code&gt;man diff&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$diff file1 file2 &amp;gt; file3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From within Vim you can get the result of this command in a buffer with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:read !diff file1 file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;read&lt;/code&gt; allows to get the result of a command in the current buffer and &lt;code&gt;!&lt;/code&gt; allows to specify a string to be executed as an external command (here &lt;code&gt;diff file1 file2&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-03-20T19:12:22.797" LastActivityDate="2016-03-20T19:12:22.797" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6954" PostTypeId="1" CreationDate="2016-03-20T18:55:37.773" Score="1" ViewCount="140" Body="&lt;p&gt;I was trying to use &lt;a href=&quot;https://github.com/neilagabriel/vim-geeknote&quot; rel=&quot;nofollow&quot;&gt;vim-geeknote&lt;/a&gt; in MacVim (&lt;a href=&quot;https://github.com/splhack/macvim-kaoriya&quot; rel=&quot;nofollow&quot;&gt;Kaoriya Edition&lt;/a&gt;, MacVim modified for Japanese environment).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed &lt;a href=&quot;http://www.geeknote.me/install/&quot; rel=&quot;nofollow&quot;&gt;the official way&lt;/a&gt; of installing geeknote and it works in terminal (with &lt;code&gt;sudo&lt;/code&gt;).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used NeoBundle to install &lt;code&gt;vim-geeknote&lt;/code&gt;, writing the following code in &lt;code&gt;~/.vimrc&lt;/code&gt;:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Geeknote&#xA;NeoBundle 'sudo.vim'&#xA;NeoBundle 'neilagabriel/vim-geeknote'&#xA;noremap &amp;lt;F8&amp;gt; :Geeknote&amp;lt;cr&amp;gt;&#xA;let g:GeeknoteMaxExplorerWidth=60&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I execute &lt;code&gt;:Geeknote&lt;/code&gt; in MacVim, I got an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;  File &quot;/Users/Tak/.vim/bundle/vim-geeknote/plugin/vim_geeknote.py&quot;, line 4, in &amp;lt;module&amp;gt;&#xA;    from explorer import Explorer&#xA;  File &quot;/Users/Tak/.vim/bundle/vim-geeknote/plugin/explorer.py&quot;, line 4, in &amp;lt;module&amp;gt;&#xA;    from view   import *&#xA;  File &quot;/Users/Tak/.vim/bundle/vim-geeknote/plugin/view.py&quot;, line 4, in &amp;lt;module&amp;gt;&#xA;    from enml  import *&#xA;  File &quot;/Users/Tak/.vim/bundle/vim-geeknote/plugin/enml.py&quot;, line 5, in &amp;lt;module&amp;gt;&#xA;    from geeknote.out    import *&#xA;  File &quot;/Library/Python/2.7/site-packages/geeknote-0.2a-py2.7.egg/geeknote/out.py&quot;, line 11, in &amp;lt;&#xA;module&amp;gt;&#xA;    from editor import Editor&#xA;  File &quot;/Library/Python/2.7/site-packages/geeknote-0.2a-py2.7.egg/geeknote/editor.py&quot;, line 16, i&#xA;n &amp;lt;module&amp;gt;&#xA;    from log import logging&#xA;  File &quot;/Library/Python/2.7/site-packages/geeknote-0.2a-py2.7.egg/geeknote/log.py&quot;, line 11, in &amp;lt;&#xA;module&amp;gt;&#xA;    logging.basicConfig(format=FORMAT, filename=config.ERROR_LOG)&#xA;  File &quot;/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.p&#xA;y&quot;, line 1545, in basicConfig&#xA;    hdlr = FileHandler(filename, mode)&#xA;  File &quot;/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.p&#xA;y&quot;, line 911, in __init__&#xA;    StreamHandler.__init__(self, self._open())&#xA;  File &quot;/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.p&#xA;y&quot;, line 941, in _open&#xA;    stream = open(self.baseFilename, self.mode)&#xA;IOError: [Errno 13] Permission denied: '/Users/Tak/.geeknote/error.log'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the permission is denied, I tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;sudo chmod a+rw /Library/Python/2.7/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sudo chmod a+rw /System/Library/Frameworks/Python.framework/Versions/2.7/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;but they don't work and I keep getting the same error.&lt;br&gt;&#xA;Is there any way to execute commands with &lt;code&gt;sudo&lt;/code&gt;? Or are there any better way for this issue?&lt;/p&gt;&#xA;" OwnerUserId="6897" LastActivityDate="2016-03-20T18:55:37.773" Title="Permission Error when using vim-geeknote" Tags="|macvim|" AnswerCount="0" CommentCount="2" ClosedDate="2016-03-21T12:47:44.943" ContentLicense="CC BY-SA 3.0" />
  <row Id="6955" PostTypeId="2" ParentId="6950" CreationDate="2016-03-20T19:01:40.587" Score="24" Body="&lt;p&gt;The best way to set an option for a particular filetype is to use autocommands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you could add something like that in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown setlocal spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line will trigger the command &lt;code&gt;setlocal spell&lt;/code&gt; when the filetype of a buffer is set as markdown. you can also use the autocommand based on the extension of the file you edit with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead,BufNewFile *.md setlocal spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information you should read &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#:autocmd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :autocmd&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocmd-events&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h autocmd-events&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Using autocommands is not the best way to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, if you use the autocommands remember to put them in an &lt;code&gt;augroup&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup markdownSpell&#xA;    autocmd!&#xA;    autocmd FileType markdown setlocal spell&#xA;    autocmd BufRead,BufNewFile *.md setlocal spell&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way if you source your vimrc several times the autocommands won't stack and get executed several times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now a better solution would be to use a ftplugin. To do that you want to create the file &lt;code&gt;~/.vim/after/ftplugin/markdown.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This file will be sourced when the filetype of a buffer is set to &lt;code&gt;markdown&lt;/code&gt; and after the &lt;code&gt;ftplugin&lt;/code&gt; which comes with Vim by default has been sourced (this way you don't loose the already existing settings).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this file you can simply add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here you need to use &lt;code&gt;setlocal&lt;/code&gt; instead of &lt;code&gt;set&lt;/code&gt; to make sure that the settings will only apply to the current buffer and not to all buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some interesting related help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#ftplugin&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h ftplugin&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%3asetlocal&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :setlocal&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-03-07T13:55:10.270" LastActivityDate="2018-03-07T13:55:10.270" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6956" PostTypeId="2" ParentId="6952" CreationDate="2016-03-20T20:08:43.860" Score="5" Body="&lt;p&gt;The following is only a quick mock-up answer (i.e. functional until it doesn't, or until it breaks something :) ), but it shows that &quot;it is possible&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup completion&#xA;    autocmd!&#xA;    autocmd CompleteDone * call PostCompletion()&#xA;augroup END&#xA;&#xA;function! PostCompletion()&#xA;    if !empty(v:completed_item)&#xA;        &quot;check if text after current cursor position is part of the match&#xA;        let crt_word = expand('&amp;lt;cWORD&amp;gt;')&#xA;        let compl_word = v:completed_item['word']&#xA;        let lcw = len(compl_word)&#xA;        let leftover = strpart(crt_word, lcw)&#xA;        let lfl = len(leftover)&#xA;        if lfl &amp;gt; 0&#xA;            let endcompl = strpart(compl_word, lcw - lfl)&#xA;            if leftover ==# endcompl&#xA;                let cpos = getcurpos()&#xA;                normal dW&#xA;                call setpos('.', cpos)&#xA;            endif&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What the above code tries to do is: &lt;em&gt;after&lt;/em&gt; completion, verifies if the WORD under cursor is longer than the completed word, and, if so, it further checks if its 'remainder' matches the last part of the completion (in your example, &quot;Function&quot;). If it does, the rest of the WORD is deleted (this assumes some things about cursor position). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I'm pretty sure there are more clever ways to accomplish all this, and I'd like to see them!)&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-03-20T20:08:43.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6957" PostTypeId="1" AcceptedAnswerId="6962" CreationDate="2016-03-21T10:59:29.007" Score="3" ViewCount="219" Body="&lt;p&gt;The LaTeX-Box plugin is supposed to define the command &lt;code&gt;:Latexmk&lt;/code&gt;, but it doesn't!  Am I missing something obvious?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The reason I'm trying to run latexmk from vim is that I want to use the quickfix list.  If anyone does this without a plugin, please let me know how.)&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="51" LastEditDate="2016-04-03T00:30:59.920" LastActivityDate="2016-04-03T00:30:59.920" Title="LaTeX-Box does not define :Latexmk" Tags="|filetype-tex|plugin-latex-box|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="6958" PostTypeId="1" AcceptedAnswerId="6959" CreationDate="2016-03-21T12:33:42.407" Score="19" ViewCount="8385" Body="&lt;p&gt;I was searching for an answer to this, but haven't found anything yet, so if I missed something obvious, I apologize. I thought it would be a quick google search away, so maybe it's more complicated than I thought.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to conditionally load plugins based on the type of file I'm editing. For example, when editing python, I don't want the keybindings that &lt;code&gt;vim-sexp&lt;/code&gt; installs, but when working on clojure, I do want that plugin to be loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm currently using neovim and pathogen, but if there's a different plugin manager that does this for me, I'd be open to switching. Also, if this does exist, does &lt;code&gt;:set syntax whatever&lt;/code&gt; switch the plugins? Because that would be super :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any help/direction!&lt;/p&gt;&#xA;" OwnerUserId="6900" LastEditorUserId="1841" LastEditDate="2016-03-21T12:44:48.957" LastActivityDate="2016-03-21T14:13:17.197" Title="How to conditionally load plugins" Tags="|neovim|plugin-system|plugin-pathogen|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6959" PostTypeId="2" ParentId="6958" CreationDate="2016-03-21T12:48:47.553" Score="22" Body="&lt;p&gt;You can do this with Vim-Plug. See &lt;a href=&quot;https://github.com/junegunn/vim-plug#example&quot; rel=&quot;noreferrer&quot;&gt;the README&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; On-demand loading&#xA;Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }&#xA;Plug 'tpope/vim-fireplace', { 'for': 'clojure' }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think you'll have to use &lt;code&gt;:set filetype whatever&lt;/code&gt; instead of &lt;code&gt;set syntax whatever&lt;/code&gt; to enable the plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Some other plugin manager might allow you to do that, see &lt;a href=&quot;https://vi.stackexchange.com/q/388/1841&quot;&gt;What is the difference between the vim plugin managers?&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-03-21T13:19:21.010" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6960" PostTypeId="2" ParentId="6943" CreationDate="2016-03-21T12:57:10.397" Score="5" Body="&lt;p&gt;After some experimenting, here's something that works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax keyword LogrotateKeyword prerotate postrotate endscript contained&#xA;syntax region LogrotateScript start=/\v^\s*(pre|post)rotate\s*$/rs=e+1 end=/^\s*endscript\s*$/re=s-1 keepend contains=LogrotateKeyword&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get one &lt;code&gt;syntax&lt;/code&gt; set to cooperate with another that's overlapping, we can &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-contains&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;contain&lt;/em&gt;&lt;/a&gt; the narrower match within the broader match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I mark the keywords as &lt;code&gt;contained&lt;/code&gt; and the region as containing the keywords. Marking the keywords is not necessary, but, considering the nature of these keywords, they will always be accompanied by this region in the valid case.&lt;/li&gt;&#xA;&lt;li&gt;I had to use &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-keepend&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;keepend&lt;/code&gt;&lt;/a&gt; so that the match for the keyword doesn't obscure the match for the end of the region.&lt;/li&gt;&#xA;&lt;li&gt;I picked the broader regular expressions that cover the whole line, so that highlighting doesn't extend to these lines (or if you set a coloured background, it will look very weird).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Combining with Vim's shell script syntax highlighting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax include @sh syntax/sh.vim&#xA;syntax keyword LogrotateKeyword prerotate postrotate endscript contained&#xA;syntax region LogrotateScript start=/\v^\s*(pre|post)rotate\s*$/rs=e+1 end=/^\s*endscript\s*$/re=s-1 keepend contains=LogrotateKeyword,@sh&#xA;highlight LogrotateKeyword ctermfg=yellow &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/m3c6X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/m3c6X.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I used &lt;code&gt;re&lt;/code&gt; and &lt;code&gt;rs&lt;/code&gt; instead of &lt;code&gt;ms&lt;/code&gt;/&lt;code&gt;hs&lt;/code&gt;, &lt;code&gt;me&lt;/code&gt;/&lt;code&gt;he&lt;/code&gt;. With the other options, combining the keywords with shell script syntax didn't work, though I don't know why.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The following would be better:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region LogrotateScript matchgroup=LogrotateKeyword start=/\v(pre|post)rotate/ end=/endscript/ contains=@sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, I take advantage of &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-matchgroup&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;matchgroup&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        :syn-matchgroup&#xA;        &quot;matchgroup&quot; can be used to highlight the start and/or end pattern&#xA;        differently than the body of the region.  Example: &#xA;  :syntax region String matchgroup=Quote start=+&quot;+  skip=+\\&quot;+  end=+&quot;+&#xA;       This will highlight the quotes with the &quot;Quote&quot; group, and the text in&#xA;        between with the &quot;String&quot; group.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Looking back, &lt;code&gt;matchgroup&lt;/code&gt; was meant to solve exactly this problem. We don't need to list out the delimiting keywords separately, since &lt;code&gt;matchgroug&lt;/code&gt; lets us highlight the delimiters separately.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-03-21T14:22:09.877" LastActivityDate="2016-03-21T14:22:09.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6961" PostTypeId="2" ParentId="6958" CreationDate="2016-03-21T13:36:11.543" Score="9" Body="&lt;p&gt;Instead of calling &lt;code&gt;execute pathogen#infect()&lt;/code&gt; to load all plugins, call &lt;code&gt;pathogen#interpose&lt;/code&gt; for every plugin, i.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#interpose('bundle/unicode.vim')&#xA;execute pathogen#interpose('bundle/AnsiEsc.vim')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pathogen API isn't documented outside of &lt;a href=&quot;https://github.com/tpope/vim-pathogen/blob/master/autoload/pathogen.vim&quot; rel=&quot;noreferrer&quot;&gt;the source&lt;/a&gt;, but it's simple enough (even though the function names are obscure and non-descriptive). You can also use &lt;code&gt;pathogen#surround()&lt;/code&gt;for absolute paths.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can load plugins conditionally with a basic &lt;code&gt;autocmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Always use this plugin&#xA;execute pathogen#interpose('bundle/unicode.vim')&#xA;&#xA;&quot; Only for Python&#xA;autocmd FileType python execute pathogen#interpose('bundle/vim-sexp')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you find you have many of these cases, you could even split it up into different paths:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/bundle/always&lt;/code&gt; for plugins you always want&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/bundle/&amp;lt;filetype&amp;gt;&lt;/code&gt; for plugins for a  specific filetype&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;And then load it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Always use this plugin&#xA;execute pathogen#infect('bundle/always/{}')&#xA;&#xA;&quot; Load filetype plugins if they exist&#xA;autocmd FileType * if isdirectory('/home/martin/.vim/bundle/' . &amp;amp;ft) | execute pathogen#infect('bundle/' . &amp;amp;ft. '/{}') | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This way you don't have to add a whole bunch of &lt;code&gt;autocmd&lt;/code&gt;s for every filetype/plugin.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;if this does exist, does &lt;code&gt;:set syntax whatever&lt;/code&gt; switch the plugins? Because that would be super :)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Once a plugin is loaded, it's loaded. A &quot;plugin&quot; is simply a collection of &lt;code&gt;function&lt;/code&gt;, &lt;code&gt;command&lt;/code&gt;, and &lt;code&gt;map&lt;/code&gt; definitons. I don't know of any straightforward way to &quot;unload' this.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It &lt;em&gt;does&lt;/em&gt; load plugins for a filetype iff you use &lt;code&gt;:set filetype&lt;/code&gt;; In general, you always want to use &lt;code&gt;:set filetype&lt;/code&gt; and &lt;em&gt;not&lt;/em&gt; &lt;code&gt;:set syntax&lt;/code&gt;, as &lt;code&gt;syntax&lt;/code&gt; will only set the syntax highlighting, and not the indentation and other settings (e.g. &lt;code&gt;iskeyword&lt;/code&gt;, &lt;code&gt;formatexpr&lt;/code&gt;, etc.).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-03-21T14:13:17.197" LastActivityDate="2016-03-21T14:13:17.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6962" PostTypeId="2" ParentId="6957" CreationDate="2016-03-21T14:14:42.870" Score="3" Body="&lt;p&gt;The reason is that LaTeX-Box loads some of its function only when the filetype of the buffer is set to &lt;code&gt;tex&lt;/code&gt;. On some systems &lt;code&gt;*.tex&lt;/code&gt; files's filetype is set to &lt;code&gt;plaintext&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have two options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Renaming your files to &lt;code&gt;*.latex&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Adding &lt;code&gt;autocmd! BufReadPost,BufNewFile *.tex set filetype=tex&lt;/code&gt; to your &lt;code&gt;.vimrc&lt;/code&gt; to set the proper filetype to your &lt;code&gt;*.tex&lt;/code&gt; files.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-03-21T14:14:42.870" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6963" PostTypeId="2" ParentId="6731" CreationDate="2016-03-21T14:30:00.390" Score="14" Body="&lt;p&gt;With these settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region FCall start='[[:alpha:]_]\i*\s*(' end=')' contains=FCall,FCallKeyword&#xA;syn match FCallKeyword /\i*\ze\s*=[^=]/ contained&#xA;hi FCallKeyword ctermfg=yellow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VPgjF.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VPgjF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I define a &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-region&quot; rel=&quot;noreferrer&quot;&gt;syntax region&lt;/a&gt; within which keyword arguments can be found, which would be the function call. The &lt;code&gt;contains&lt;/code&gt; option lets me nest function calls.&lt;/li&gt;&#xA;&lt;li&gt;Within that region, I match any string made of valid identifier characters (&lt;code&gt;\i*&lt;/code&gt;) followed by &lt;code&gt;=&lt;/code&gt;, but not &lt;code&gt;==&lt;/code&gt;, so that equality tests are not matched.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;By using regions, I get to nest the matches as much as I need, which would have be very complicated (impossible?) if I'd gone for just a &lt;code&gt;match&lt;/code&gt; with regular expressions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe the regular expressions used for matching the function call and the keyword can be refined, but considering &lt;a href=&quot;https://stackoverflow.com/a/19482755/2072269&quot;&gt;what's valid in Python 3&lt;/a&gt;, that's not a task I'm willing to take on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Optionally, I think you can use this to highlight function calls, using a &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-matchgroup&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;matchgroup&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region FCall matchgroup=FName start='[[:alpha:]_]\i*\s*(' end=')' contains=FCall,FCallKeyword&#xA;syn match FCallKeyword /\i*\ze\s*=[^=]/ contained&#xA;hi FCallKeyword ctermfg=yellow&#xA;hi FName ctermfg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ws9ov.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ws9ov.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-03-23T09:02:34.143" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6965" PostTypeId="2" ParentId="6821" CreationDate="2016-03-21T16:43:17.203" Score="5" Body="&lt;p&gt;As Philipp has pointed out in his previous answer, &lt;code&gt;:lmap&lt;/code&gt; can be used to get &lt;code&gt;f&lt;/code&gt; and the likes to work with your mappings.&#xA;However, this will most likely not work out of the box for you since the &lt;code&gt;'iminsert'&lt;/code&gt; option needs to be set to &lt;code&gt;1&lt;/code&gt; while the default is &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;2&lt;/code&gt;.&#xA;Unfortunately, this will result in the mapping being applied in every mode, e.g. typing &lt;code&gt;Ö&lt;/code&gt; in insert mode will result in a &lt;code&gt;{&lt;/code&gt; being inserted in the text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prevent this, you need to disable &lt;code&gt;:lmap&lt;/code&gt; mappings in insert mode.&#xA;This can be done in two ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;typing &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; to toggle between disabling an enabling &lt;code&gt;:lmap&lt;/code&gt; mappings.&#xA;This solution has the additional drawback (aside from being rather tedious) that this key combination might not work on your keyboard (it didn't work on my german one).&#xA;Remapping other keys to this combination solves the issue, though.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;using auto commands to always disable them in insert mode using the &lt;code&gt;InsertEnter&lt;/code&gt; and &lt;code&gt;InsertLeave&lt;/code&gt; events.&#xA;In your case, the solution might look like this, using &lt;code&gt;'lmap'&lt;/code&gt; to make things work in cases like &lt;code&gt;diÖ&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * set iminsert=2&#xA;autocmd InsertLeave * set iminsert=1&#xA;lmap Ö {&#xA;lmap Ä }&#xA;lmap ö [&#xA;lmap ä ]&#xA;set lmap=Ö{Ä}ö[ä]&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2016-03-21T16:43:17.203" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6966" PostTypeId="2" ParentId="4919" CreationDate="2016-03-21T17:46:57.470" Score="83" Body="&lt;p&gt;The &lt;a href=&quot;https://vi.stackexchange.com/a/4922/11986&quot;&gt;answer by @romainl&lt;/a&gt; is correct but I wanted to add a bit more info for anyone that may have stumbled on this from google like I did.&lt;/p&gt;&#xA;&lt;p&gt;Directly from the docs we get this note:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Terminal mode has its own namespace for mappings, which is accessed&#xA;with the &amp;quot;t&amp;quot; prefix. It's possible to use terminal mappings to&#xA;customize interaction with the terminal. For example, here's how to&#xA;map  to exit terminal mode:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:tnoremap &amp;lt;Esc&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;With that knowledge you will most likely need to create some terminal mappings to stay inline with your current workflow (tab/window movement, etc.)&lt;/p&gt;&#xA;" OwnerUserId="2189" LastEditorUserId="2189" LastEditDate="2021-05-18T17:50:03.893" LastActivityDate="2021-05-18T17:50:03.893" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6967" PostTypeId="2" ParentId="3174" CreationDate="2016-03-21T18:10:12.617" Score="1" Body="&lt;p&gt;Folding is a pretty complicated mechanism (see &lt;a href=&quot;https://stackoverflow.com/questions/34563239/folding-of-scala-imports-in-vim/34581288#34581288&quot;&gt;another answer I gave about folds&lt;/a&gt; for a nuanced discussion of folding scanning).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to give a complete answer we will need to see what type of plugins you are loading when booting up an instance of vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd bet that there are a few plugins that are mucking with the default vim settings (&lt;code&gt;vim -u NONE&lt;/code&gt; should have reproduced this). Any plugin that changes the &lt;code&gt;foldmethod&lt;/code&gt; is a likely cause (I'd try to remove them 1 by 1 and see what causes the issue)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to muck with your plugins at all I'd recommend manually tweaking the syntax + parsing settings and then open a test buffer to confirm your functionality. It can be a frustrating journey to get it to play nicely but with some relentless digging in &lt;code&gt;:help&lt;/code&gt; you should be able to wrangle the beast that is folding.&lt;/p&gt;&#xA;" OwnerUserId="2189" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-03-21T18:10:12.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6968" PostTypeId="2" ParentId="6906" CreationDate="2016-03-21T18:36:03.637" Score="2" Body="&lt;p&gt;There are a few funky factors at play that we should consider when playing with folds (they are complicated and not easy to understand without digging into the docs..)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;setting &lt;code&gt;foldmethod&lt;/code&gt; to &lt;code&gt;syntax&lt;/code&gt; was my issue when I was fighting fold but lets take a look at the docs for more info..&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SYNTAX                                          &lt;em&gt;fold-syntax&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A fold is defined by syntax items that have the &quot;fold&quot; argument.&#xA;  |:syn-fold|&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The fold level is defined by nesting folds.  The nesting of folds is&#xA;  limited with 'foldnestmax'.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Be careful to specify proper syntax syncing.  If this is not done&#xA;  right, folds may differ from the displayed highlighting.  This is&#xA;  especially relevant when using patterns that match more than one line.&#xA;  In case of doubt, try using brute-force syncing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    :syn sync fromstart&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The main thing to note is the &lt;code&gt;sync fromstart&lt;/code&gt; this is a useful helper if you have regex that would match throughout the file and only want to catch the header. In your case you should be able to ignore this but just something to be aware of.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;top down regex scanning&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since the &lt;code&gt;&quot;&quot;&quot;&lt;/code&gt; is fairly predictable we can simplify the &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; to look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region foldImports start='&quot;&quot;&quot;' end='&quot;&quot;&quot;' fold keepend&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For both the &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; we are just trying to match on &lt;code&gt;'&quot;&quot;&quot;'&lt;/code&gt;(or regexp) for the script tags. I did not test the above code out as I'm not much of a python guy but I bet you can get it figured out from here.&lt;/p&gt;&#xA;" OwnerUserId="2189" LastActivityDate="2016-03-21T18:36:03.637" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6969" PostTypeId="2" ParentId="5901" CreationDate="2016-03-21T20:25:46.407" Score="2" Body="&lt;p&gt;The reason seems to stem from the fact that neovim sets &lt;code&gt;gui_running&lt;/code&gt; only &lt;em&gt;after&lt;/em&gt; your &lt;code&gt;.vimrc&lt;/code&gt; is sourced (&lt;a href=&quot;https://github.com/neovim/neovim/issues/2216&quot; rel=&quot;nofollow&quot;&gt;see here&lt;/a&gt;).&#xA; &lt;a href=&quot;https://github.com/neovim/neovim/issues/3646&quot; rel=&quot;nofollow&quot;&gt;In this discussion&lt;/a&gt; it is proposed to use the &lt;code&gt;GUIEnter&lt;/code&gt; event, thus a solution could be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd GUIEnter * set lines=999 columns=999&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2016-03-21T20:25:46.407" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6970" PostTypeId="1" CreationDate="2016-03-21T21:37:04.307" Score="8" ViewCount="624" Body="&lt;p&gt;I am trying to build my own indent file for JavaScript.  The default indent file for JavaScript turns cindent on, with minimal modifications, and I am using that as a base.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Vim 7.3 for OSX El Capitan, typing an array produces the following by default:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var test = [&#xA;1,&#xA;    2,&#xA;    3&#xA;    ];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And note, while not legal JavaScript, I noticed not using a comma produces a slightly different behavior:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var test = [&#xA;1&#xA;2&#xA;3&#xA;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On 7.4, typing the above two examples produces what I expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var test = [&#xA;    1,&#xA;    2,&#xA;    3&#xA;];&#xA;&#xA;var test = [&#xA;    1&#xA;    2&#xA;    3&#xA;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if you include some characters immediately following the open square bracket it goes back out of whack:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var test = [1&#xA;2,&#xA;    3,&#xA;    4&#xA;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What controls the indentation of the lines between square brackets as well as the placement of the closing square bracket?  When viewing the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/indent.html&quot; rel=&quot;noreferrer&quot;&gt;Vim documentation&lt;/a&gt;, I don't see a cinoptions value that captures this.&lt;/p&gt;&#xA;" OwnerUserId="6911" LastEditorUserId="6911" LastEditDate="2016-03-24T18:55:15.843" LastActivityDate="2016-04-30T06:06:29.877" Title="What controls indentation of lines following an open square bracket when using cindent?" Tags="|indentation|filetype|options|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6971" PostTypeId="1" CreationDate="2016-03-22T10:17:08.350" Score="1" ViewCount="986" Body="&lt;p&gt;I have a hard time just copying and pasting between vim and other programs (firefox, chrome, gnumeric) as well as other instances of vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally I try to copy/yank with &quot;+y and paste with &quot;+p. However this sometimes works, and sometimes does not work. I cannot even figure out when it works and when not. One thing which never seems to work is copying from vim, closing vim, then pasting into another program. But sometimes copy/paste even do not work if the original vim instance is still running. I also sometimes try &quot;*y and &quot;*p respectively, with varying results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is relevant, my .vimrc and .screenrc are here: &#xA;&lt;a href=&quot;https://github.com/antonkratz/fluffy-tribble&quot; rel=&quot;nofollow&quot;&gt;https://github.com/antonkratz/fluffy-tribble&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I &lt;em&gt;reliably&lt;/em&gt; copy and paste between vim and other programs, and other instances of vim? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;== &lt;/p&gt;&#xA;&#xA;&lt;p&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 31 2015 23:36:07) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;xfce4-terminal 0.6.3, under Xubuntu. &lt;/p&gt;&#xA;" OwnerDisplayName="user6479" LastActivityDate="2016-03-22T10:17:08.350" Title="How can I reliably copy and paste between vim and other programs?" Tags="|cut-copy-paste|" AnswerCount="0" CommentCount="2" ClosedDate="2016-03-23T17:14:31.200" ContentLicense="CC BY-SA 3.0" />
  <row Id="6973" PostTypeId="1" AcceptedAnswerId="6998" CreationDate="2016-03-22T13:10:38.607" Score="3" ViewCount="2071" Body="&lt;pre&gt;&lt;code&gt;set cc=10 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The simple command for vim version greater than 7.3 can create a red line from top till bottom on the 10th column.&lt;br&gt;&#xA;I want to get more info about &quot;set cc=number&quot; such as 'can make the line to be green'?&lt;br&gt;&#xA;What file or function or code blocks are called when to input &lt;code&gt;set cc=10&lt;/code&gt; in ex mode?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="5181" LastEditDate="2016-03-22T14:02:34.817" LastActivityDate="2016-03-23T18:02:41.987" Title="How to get info on set cc=number?" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6974" PostTypeId="2" ParentId="6859" CreationDate="2016-03-22T13:26:15.343" Score="2" Body="&lt;p&gt;The interesting thing is how to deal with movement. &#xA;If the lines to join start with same characters you can do (automated with a macro):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq*&quot;aD''*&quot;AD''$&quot;apj0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;&lt;kbd&gt;&lt;code&gt;q&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;q&lt;/code&gt;&lt;/kbd&gt;&lt;/kbd&gt; record a macro&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;&lt;kbd&gt;&lt;code&gt;*&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;&quot;&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;a&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;D&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;'&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;'&lt;/code&gt;&lt;/kbd&gt; &lt;/kbd&gt; move to the line whith next char like first char of the first line, put the line in the register &quot;a&quot; and delete&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;&lt;kbd&gt;&lt;code&gt;*&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;&quot;&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;A&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;D&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;'&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;'&lt;/code&gt;&lt;/kbd&gt;&lt;/kbd&gt; like 2. but append the line to the register&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;&lt;kbd&gt;&lt;code&gt;$&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;&quot;&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;a&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;p&lt;/code&gt;&lt;/kbd&gt;&lt;/kbd&gt; paste register &quot;a&quot; at the end of the first line&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;&lt;kbd&gt;&lt;code&gt;j&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;0&lt;/code&gt;&lt;/kbd&gt;&lt;/kbd&gt; move to the start of the next line&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then repeat the macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and delete the empty lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6915" LastActivityDate="2016-03-22T13:26:15.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6975" PostTypeId="1" AcceptedAnswerId="20666" CreationDate="2016-03-22T14:18:34.020" Score="8" ViewCount="1647" Body="&lt;p&gt;Is there any way to store the number of matches in a variable in a VIMScript function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/,//gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="1065" LastEditDate="2016-03-22T14:30:15.080" LastActivityDate="2019-07-19T00:05:51.877" Title="Store the number of matches in VimScript function?" Tags="|vimscript|regular-expression|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6976" PostTypeId="1" AcceptedAnswerId="6977" CreationDate="2016-03-22T14:21:40.097" Score="4" ViewCount="1521" Body="&lt;p&gt;How does one move to the next match in Vimscript? The way you would when matching an expression and then hitting &lt;code&gt;n&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="1841" LastEditDate="2016-03-22T20:32:10.240" LastActivityDate="2016-03-22T20:32:10.240" Title="How to move the cursor to the next match in VimScript?" Tags="|vimscript|search|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6977" PostTypeId="2" ParentId="6976" CreationDate="2016-03-22T15:00:24.417" Score="6" Body="&lt;p&gt;Just use &lt;code&gt;:normal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-&gt; &lt;code&gt;:norm n&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;:h :normal&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-03-22T15:00:24.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6978" PostTypeId="1" AcceptedAnswerId="6985" CreationDate="2016-03-22T17:16:48.503" Score="5" ViewCount="284" Body="&lt;p&gt;I use the complete function a lot. I have not found a solution to complete a WORD yet. For example, in LaTeX, I use the following expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;T_{R_{delta}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I type &lt;code&gt;T&lt;/code&gt; and then &lt;kbd&gt;Ctrl+x&lt;/kbd&gt;&lt;kbd&gt;Ctrl+n&lt;/kbd&gt;, it wouldn't complete the whole thing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I could use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set iskeyword+=_:; etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I want this behaviour just in this situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for a complete mechanism which completes everything like &lt;code&gt;vW&lt;/code&gt; would visualize.&lt;/p&gt;&#xA;" OwnerUserId="6919" LastEditorUserId="205" LastEditDate="2016-03-23T14:14:25.797" LastActivityDate="2016-03-23T14:14:25.797" Title="How do I complete a WORD?" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ClosedDate="2019-09-28T11:13:16.403" ContentLicense="CC BY-SA 3.0" />
  <row Id="6979" PostTypeId="1" AcceptedAnswerId="20490" CreationDate="2016-03-22T19:13:20.357" Score="3" ViewCount="577" Body="&lt;p&gt;I am using gVim on Windows, and have only recently run into a very problematic situation: my &lt;kbd&gt;Tab&lt;/kbd&gt; key stops working in insert mode! Pressing the &lt;kbd&gt;Tab&lt;/kbd&gt; key does not give any output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to use the plugin &lt;a href=&quot;https://github.com/msanders/snipmate.vim&quot; rel=&quot;nofollow&quot;&gt;snipmate&lt;/a&gt; which expands snippets by calling a function defined as &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt;-function, I have to remap &lt;kbd&gt;ctrl+q&lt;/kbd&gt; to achieve the functionality. However, when I map the same content to &lt;kbd&gt;Tab&lt;/kbd&gt;, pressing the key is still not bringing me anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked the mappings defined for &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; using two methods:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Using &lt;code&gt;Listmaps&lt;/code&gt; plugin, by calling the command &lt;code&gt;:Listmaps&lt;/code&gt;, and found that &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; has been defined correctly;&lt;/li&gt;&#xA;&lt;li&gt;The mapping on &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; seems to be valid upon checking &lt;code&gt;:map &amp;lt;tab&amp;gt;&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Nevertheless, &lt;kbd&gt;Tab&lt;/kbd&gt; seems to have been disabled. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I don't understand is that: how come the same syntax of mapping would bring about different results. Who should I specify the &lt;code&gt;&amp;lt;Plug&amp;gt;Func()&lt;/code&gt; mappings? If this is really wired, would it be worth it to try a fresh installation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pair of mappings that I have specified:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;c-q&amp;gt; &amp;lt;Plug&amp;gt;snipMateNextOrTrigger&#xA;imap &amp;lt;tab&amp;gt; &amp;lt;Plug&amp;gt;snipMateNextOrTrigger&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2398" LastEditorUserId="67" LastEditDate="2016-03-23T12:32:19.683" LastActivityDate="2019-07-03T03:22:58.653" Title="How to correctly map &lt;tab&gt; for &lt;Plug&gt;Functions() on Windows?" Tags="|vimrc|gvim|microsoft-windows|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6980" PostTypeId="2" ParentId="6976" CreationDate="2016-03-22T20:30:44.357" Score="6" Body="&lt;p&gt;You can use the vimscript function &lt;code&gt;search()&lt;/code&gt; (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#search()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h search()&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The signature of the function is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;search({pattern} [, {flags} [, {stopline} [, {timeout}]]])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It has several advantages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The function returns &lt;code&gt;0&lt;/code&gt; if no match is found and it returns the number of the line of the match if one is found.&lt;/li&gt;&#xA;&lt;li&gt;Thanks to the flags you can modify the behavior of the function. For example if you specify the tag &lt;code&gt;e&lt;/code&gt; your cursor will be positioned at the end of the match instead of at the beginning.&lt;/li&gt;&#xA;&lt;li&gt;You can restrict the search to a range of lines with the &lt;code&gt;stopline&lt;/code&gt; argument. For example is you specify a value which is not zero the search will not wrap around the end of the file i.e. when the last match of the file is found, the search will not continue to the top of the file.&lt;/li&gt;&#xA;&lt;li&gt;Also as @LucHermitte mentionned in his comment the use of this function won't mess the search register and history and will reduced the troubled of escaping.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-03-22T20:30:44.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6981" PostTypeId="1" AcceptedAnswerId="6982" CreationDate="2016-03-22T23:20:50.970" Score="36" ViewCount="19738" Body="&lt;p&gt;I was looking up at tips on  screen shifting and came across the following tips:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;zz = shift current line to middle of screen&#xA;zt = shift current line to top of screen&#xA;zb = shift current line to bottom of screen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is what is &lt;code&gt;z&lt;/code&gt;?  What does it stand for? what other functionality might &lt;code&gt;z&lt;/code&gt; have?&lt;/p&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="205" LastEditDate="2016-03-23T06:29:20.780" LastActivityDate="2016-03-23T06:29:20.780" Title="What does z stand for in vim?" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6982" PostTypeId="2" ParentId="6981" CreationDate="2016-03-23T00:16:35.407" Score="37" Body="&lt;p&gt;z doesn't stand for anything.  g and z were two letters that went unused as standalone commands (&lt;code&gt;z&amp;lt;CR&amp;gt;&lt;/code&gt;, &lt;code&gt;z.&lt;/code&gt;, &lt;code&gt;z+&lt;/code&gt;, &lt;code&gt;z-&lt;/code&gt;, and &lt;code&gt;z^&lt;/code&gt; existed) in vi, so they have been repurposed in Vim as a prefix for a variety of commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.appspot.com/index.txt.html#z&quot;&gt;:help z&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.appspot.com/index.txt.html#g&quot;&gt;:help g&lt;/a&gt; will show you all the commands that sit behind these prefixes.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2016-03-23T00:23:54.100" LastActivityDate="2016-03-23T00:23:54.100" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6983" PostTypeId="2" ParentId="6834" CreationDate="2016-03-23T08:00:13.367" Score="2" Body="&lt;p&gt;I think you can get the mappings via the following commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap - Mapping on normal mode&#xA;:cmap - Mapping on command mode&#xA;:vmap - Mapping on visual mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope it helps!&lt;/p&gt;&#xA;" OwnerUserId="6938" LastEditorUserId="1841" LastEditDate="2016-03-23T08:19:41.923" LastActivityDate="2016-03-23T08:19:41.923" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6984" PostTypeId="2" ParentId="6975" CreationDate="2016-03-23T08:53:14.797" Score="9" Body="&lt;p&gt;I know that @romainl debugged the question as a XY problem in the comments but I guess it still could be useful to some people, so here is a solution. &lt;em&gt;(It is deeply inspired from &lt;a href=&quot;https://stackoverflow.com/a/23724875/4194289&quot;&gt;this answer&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use this function (to add to your &lt;code&gt;.vimrc&lt;/code&gt; or to your script):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Count( word )&#xA;  redir =&amp;gt; cnt&#xA;    silent exe '%s/' . a:word . '//gn'&#xA;  redir END&#xA;&#xA;  let res = strpart(cnt, 0, stridx(cnt, &quot; &quot;))&#xA;  return res&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can call the function like this: &lt;code&gt;:call Count(&quot;pattern&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example in this file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a,bc&#xA;akj,dh&#xA;jlkdfa,&#xA;oiua ,lkj&#xA;oiua, lkj&#xA;oiua , lkj&#xA;i,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;:echo Count(&quot;,&quot;)&lt;/code&gt; you'll get &lt;code&gt;7&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-03-23T08:53:14.797" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6985" PostTypeId="2" ParentId="6978" CreationDate="2016-03-23T09:06:04.933" Score="2" Body="&lt;p&gt;I asked a similar question a few weeks ago (how to complete a tag name containing a colon) and here was the &lt;a href=&quot;https://vi.stackexchange.com/a/6816/4939&quot;&gt;answer&lt;/a&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your question is slightly different as you don't want to temporarily add a colon to the value of &lt;code&gt;'iskeyword'&lt;/code&gt; but all characters which can appear inside a WORD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a different version of the original answer which redefines the behavior of &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; to autocomplete WORDS instead of words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-X&amp;gt;&amp;lt;C-N&amp;gt; &amp;lt;C-O&amp;gt;:call &amp;lt;SID&amp;gt;CustomKeyword(join(map(range(char2nr('!'),char2nr('~')), 'nr2char(v:val)'), ''))&amp;lt;CR&amp;gt;&amp;lt;C-X&amp;gt;&amp;lt;C-N&amp;gt;&#xA;&#xA;function! s:CustomKeyword(chars) abort&#xA;    for char in split(a:chars, '\zs')&#xA;        execute 'setlocal iskeyword+=' . char2nr(char)&#xA;    endfor&#xA;    augroup custom_keyword&#xA;        autocmd!&#xA;        autocmd CompleteDone * setlocal iskeyword&amp;lt; | autocmd! custom_keyword&#xA;    augroup END&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The characters inside the string that you pass as an argument to the function &lt;code&gt;CustomKeyword()&lt;/code&gt; will be added to the buffer-local value of &lt;code&gt;'isk'&lt;/code&gt;, and the autocmd will reset the option once the completion is done by copying the global value into the buffer-local one (&lt;code&gt;setlocal iskeyword&amp;lt;&lt;/code&gt;), as well as remove itself (&lt;code&gt;| autocmd! custom_keyword&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides, you want to complete WORDS whose characters should be any printable character except a whitespace.&#xA;According to this &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII#ASCII_printable_code_chart&quot; rel=&quot;nofollow noreferrer&quot;&gt;chart&lt;/a&gt;, it seems the first printable character is the exclamation mark &lt;code&gt;!&lt;/code&gt; and the last is the tilde &lt;code&gt;~&lt;/code&gt;.&#xA;Thus, the string of printable characters could be obtained with the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;join(map(range(char2nr('!'),char2nr('~')), 'nr2char(v:val)'), '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is the string passed as an argument to &lt;code&gt;CustomKeyword()&lt;/code&gt; inside the &lt;code&gt;{rhs}&lt;/code&gt; of the previous mapping whose &lt;code&gt;{lhs}&lt;/code&gt; is &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-N&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that you could reuse the &lt;code&gt;CustomKeyword()&lt;/code&gt; function to change &lt;code&gt;'isk'&lt;/code&gt; in any way.&lt;br&gt;&#xA;For example, if you wanted to autocomplete tag names containing a colon, you could install the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-X&amp;gt;&amp;lt;C-]&amp;gt; &amp;lt;C-O&amp;gt;:call &amp;lt;SID&amp;gt;CustomKeyword(':')&amp;lt;CR&amp;gt;&amp;lt;C-X&amp;gt;&amp;lt;C-]&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The general syntax would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap {lhs} &amp;lt;C-O&amp;gt;:call &amp;lt;SID&amp;gt;CustomKeyword('characters_to_add_to_isk')&amp;lt;CR&amp;gt;{lhs}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;{lhs}&lt;/code&gt; is the keys you hit to trigger the completion (&lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-N&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;, ...).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to preserve the original behavior of &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-N&amp;gt;&lt;/code&gt;, and use another &lt;code&gt;{lhs}&lt;/code&gt; to trigger the custom completion, for example &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-A&amp;gt;&lt;/code&gt;, you could use this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-X&amp;gt;&amp;lt;C-A&amp;gt; &amp;lt;C-O&amp;gt;:call &amp;lt;SID&amp;gt;CustomKeyword(join(map(range(char2nr('!'),char2nr('~')), 'nr2char(v:val)'), ''))&amp;lt;CR&amp;gt;&amp;lt;C-X&amp;gt;&amp;lt;C-N&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You just have to change the first &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; in the original &lt;code&gt;{lhs}&lt;/code&gt;, but not the second one in the &lt;code&gt;{rhs}&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4939" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-03-23T11:19:53.987" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6986" PostTypeId="1" AcceptedAnswerId="6987" CreationDate="2016-03-23T09:38:55.113" Score="5" ViewCount="2130" Body="&lt;pre&gt;&lt;code&gt;:set cc=1,5,9,13,17&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command above here can create a series red lines on the edited file in vim whose version is lager than 7.3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why can't write it as &lt;code&gt;:set cc=range(1,17,4)&lt;/code&gt;  ?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="1841" LastEditDate="2016-03-23T09:53:09.500" LastActivityDate="2016-03-23T10:14:31.543" Title="How to use a range function in a normal command?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6987" PostTypeId="2" ParentId="6986" CreationDate="2016-03-23T09:48:47.367" Score="6" Body="&lt;p&gt;There's two reasons you can't use this syntax:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Firstly you can't mix functions calls and normal commands without distinction. Your syntax should be &lt;code&gt;exec &quot;:set cc=&quot; . range(1, 17, 4)&lt;/code&gt;. to concatenate the result of the function &lt;code&gt;range()&lt;/code&gt; with the normal command &lt;code&gt;:set cc=&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Secondly even with this syntax your command will not work: When you use &lt;code&gt;:echo range(1, 17, 4)&lt;/code&gt; you get a list: &lt;code&gt;[1, 5, 9, 13, 17]&lt;/code&gt; so the previous command would expand to &lt;code&gt;:set cc=[1, 5, 9, 13, 17]&lt;/code&gt; which isn't a correct syntax.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A possible solution would be to cast the result of &lt;code&gt;range&lt;/code&gt; as a string, remove the &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; characters and then concatenate the result with &lt;code&gt;:set cc=&lt;/code&gt; with the &lt;code&gt;exec&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; @Saginaw suggested to use the function &lt;code&gt;join()&lt;/code&gt; to implement the transformation of the list to a string without brackets characters. Using this idea the final solution for your question would be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec &quot;set cc=&quot; . join(range(1, 17, 4), &quot;,&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks to @Saginaw for his idea.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You might want to read:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#:execute&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :execute&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#join()&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h join()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-03-23T10:14:31.543" LastActivityDate="2016-03-23T10:14:31.543" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6988" PostTypeId="1" AcceptedAnswerId="6989" CreationDate="2016-03-23T11:35:36.437" Score="11" ViewCount="7492" Body="&lt;p&gt;I have read the manual in vim with &lt;code&gt;:h cc&lt;/code&gt; or &lt;code&gt;h: 'cc'&lt;/code&gt;, but I found nothing about how to remove the red lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First use case&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I create the red line with this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cc=1,5,9,13,17,21&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the following command I can disable &lt;code&gt;cc&lt;/code&gt; ,or to remove all the red lines created by the previous command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cc-=1,5,9,13,17,21  &quot;Use minus `-` to remove all the red lines here.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a more quickly way to remove all the red lines?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Use case 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I create the red line with this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec &quot;set cc=&quot;.join(range(1,21,4),&quot;,&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to deactive cc command in this case?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WatTh.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WatTh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="1841" LastEditDate="2016-04-05T12:04:45.950" LastActivityDate="2017-05-03T23:11:47.280" Title="How to deactive colorcolumn quickly in different situation?" Tags="|colorcolumn|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6989" PostTypeId="2" ParentId="6988" CreationDate="2016-03-23T12:13:17.200" Score="14" Body="&lt;p&gt;You can clear all the lines by just setting &lt;code&gt;cc&lt;/code&gt; to an empty value like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cc=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You also can create a command or mapping to toggle between the two, &lt;code&gt;&amp;amp;cc&lt;/code&gt; refers to the &lt;code&gt;cc&lt;/code&gt; setting, we need to use &lt;code&gt;let&lt;/code&gt; since we want to use an expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! ToggleCC :let &amp;amp;cc = &amp;amp;cc == '' ? '1,4,21' : ''&#xA;&#xA;nnoremap &amp;lt;F2&amp;gt; :let &amp;amp;cc = &amp;amp;cc == '' ? '1,4,21' : ''&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;&amp;amp;cc&lt;/code&gt; is empty, we set it to &lt;code&gt;1,4,21&lt;/code&gt;, if it has a value, we set it to nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is really a shorter version of the longer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ToggleCC()&#xA;  if &amp;amp;cc == ''&#xA;    set cc=1,4,21&#xA;  else&#xA;    set cc=&#xA;  endif&#xA;endfun&#xA;&#xA;nnoremap &amp;lt;F2&amp;gt; :call ToggleCC()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-05-03T23:11:47.280" LastActivityDate="2017-05-03T23:11:47.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6990" PostTypeId="1" AcceptedAnswerId="6992" CreationDate="2016-03-23T12:54:17.580" Score="3" ViewCount="187" Body="&lt;p&gt;It seems like the &lt;code&gt;command&lt;/code&gt; command expects a one line set of arguments. What is a good way to define a command from something longer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose defining a function with no argument and then calling the function from the command would work, but is that the standard, good,  way?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="205" LastEditDate="2016-05-03T08:18:13.437" LastActivityDate="2016-05-03T08:18:13.437" Title="Defining a command on more than one line" Tags="|key-bindings|functions|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6991" PostTypeId="1" CreationDate="2016-03-23T14:22:19.297" Score="1" ViewCount="101" Body="&lt;p&gt;I've installed the &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;nofollow noreferrer&quot;&gt;airline plugin&lt;/a&gt; and I find it useful. However, I'd like to customize it a bit to look like that:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/T6Smn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T6Smn.png&quot; alt=&quot;vim-airline&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not talking about the theme (it's gruvbox) I'm talking about how the different sections are separated. &#xA;In the image, they're are like arrows but in my terminal they're rectangles.&#xA;Is it something with my terminal?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/0DVOt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0DVOt.png&quot; alt=&quot;My vim-airline&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the README&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For the nice looking powerline symbols to appear, you will need to install a patched font. Instructions can be found in the official powerline documentation. Prepatched fonts can be found in the powerline-fonts repository.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I didn't think the &quot;nice looking powerline symbols&quot; made reference to the shape of the separators too.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, it works nice now. Thanks&lt;/p&gt;&#xA;" OwnerUserId="5081" LastEditorUserId="5081" LastEditDate="2016-03-23T15:26:44.197" LastActivityDate="2016-03-23T15:26:44.197" Title="Airline plugin configuration" Tags="|plugin-airline|" AnswerCount="0" CommentCount="1" ClosedDate="2016-03-23T14:26:42.983" ContentLicense="CC BY-SA 3.0" />
  <row Id="6992" PostTypeId="2" ParentId="6990" CreationDate="2016-03-23T14:27:05.983" Score="5" Body="&lt;p&gt;When wondering about the standard, good way of writing something in VimL I usually check two main resources: the Vim documentation, which is extremely comprehensive and well written, and Steve Losh's blogs (&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; and &lt;a href=&quot;http://stevelosh.com/blog/2011/09/writing-vim-plugins/#be-pathogen-compatible&quot; rel=&quot;nofollow&quot;&gt;Writing Vim Plugins&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One approach to find examples in the Vim documentation is finding the entry on the subject and them check the start of that file; for &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help :command&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This subject is introduced in sections |05.3|, |24.7| and |40.1| of the user&#xA;manual.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Searching the file for &lt;a href=&quot;http://vimhelp.appspot.com/usr_40.txt.html#40.2&quot; rel=&quot;nofollow&quot;&gt;the 40.1 section&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The &amp;lt;f-args&amp;gt; keyword contains the same information as the &amp;lt;args&amp;gt; keyword,&#xA;except in a format suitable for use as function call arguments.  For example:&#xA;&amp;gt;&#xA;    :command -nargs=* DoIt :call AFunction(&amp;lt;f-args&amp;gt;)&#xA;    :DoIt a b c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It shows something similar to what you guessed: calling separated functions, but with arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I couldn't find anything about this subject on the blogs mentioned above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As was mentioned on the question comments, the alternative is to use &lt;code&gt;\&lt;/code&gt; as line continuation, but that usually leads to clumsy and hard-to-read/edit code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a pattern that I have seen many times when people use the function approach and the &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Cbang%3E&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;&amp;lt;bang&amp;gt;&lt;/code&gt;&lt;/a&gt; which is made available by &lt;code&gt;:command&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -bang MyCmd call MyFunction(&amp;lt;bang&amp;gt;0, arg2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is useful because &lt;code&gt;&amp;lt;bang&amp;gt;&lt;/code&gt; expands on &lt;code&gt;!&lt;/code&gt; or nothing, so concatenating it with &lt;code&gt;0&lt;/code&gt; makes it easier to check with an &lt;code&gt;if&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned by Carpetsmoker, it is better to use script-local &lt;code&gt;s:a_function()&lt;/code&gt; instead of a global &lt;code&gt;AFunction()&lt;/code&gt;, as it is more localized and doesn't appear in tab completions and such.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-03-24T13:01:13.277" LastActivityDate="2016-03-24T13:01:13.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6993" PostTypeId="1" CreationDate="2016-03-23T14:56:32.127" Score="3" ViewCount="209" Body="&lt;p&gt;I am considering attaching a macro to the space bar to insert a space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is whether this will change its normal mode behavior. For example, if I type &lt;code&gt;23&amp;lt;space&amp;gt;&lt;/code&gt; will it execute the macro 23 times or do the normal thing (move forward 23 spaces)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to keep the old functionality for repetitive actions because the space navigation goes past end of line but 'L' navigation does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to clarify, this is the behavior I am envisioning:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;typing &quot;400&amp;lt; space bar &gt;&quot; moves forward 400 characters including past end of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;hitting the  bar inserts one space in normal mode, ie:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;space&amp;gt; i&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Not sure if it possible to achieve both these objectives. If it is not possible, then maybe the best option is to change the normal space bar behavior to a different key, since I very rarely use the space bar for navigation. Maybe Shift+Spacebar for movement?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="205" LastEditDate="2016-04-24T18:08:02.133" LastActivityDate="2016-05-13T02:13:41.643" Title="Will macro-ing the space bar mess up its command navigation?" Tags="|key-bindings|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6994" PostTypeId="2" ParentId="6993" CreationDate="2016-03-23T15:21:34.547" Score="0" Body="&lt;p&gt;I'm under the impression that a macro on space would become an annoyance very quickly. (assuming a macro is external to vi bindings) I had tried something like that with a &lt;code&gt;fn+key&lt;/code&gt; on my keyboard and found that it could be solved with some &lt;code&gt;vimL&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the question it sounds like you are looking for a way to navigate in &lt;code&gt;normal&lt;/code&gt; (having cursor wrap lines). I'd recommend staying within vim to accomplish your goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing I would look at is other events that are triggered when you navigate to the end of the line using &lt;code&gt;hjkl&lt;/code&gt;. On my config I hear the annoying bell which leads me to think there must be some event associated with cursor movement (assuming knowledge of &lt;code&gt;autocmds&lt;/code&gt;). After running &lt;code&gt;:help autocmd-events&lt;/code&gt; I stumbled on the following&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;          CursorMoved         &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;After the cursor was moved in Normal or Visual&#xA;                mode.  Also when the text of the cursor line&#xA;                has been changed, e.g., with &quot;x&quot;, &quot;rx&quot; or &quot;p&quot;.&#xA;                Not triggered when there is typeahead or when&#xA;                an operator is pending.&#xA;                For an example see |match-parens|.&#xA;                &lt;strong&gt;Careful: This is triggered very often, don't&#xA;                do anything that the user does not expect or&#xA;                that is slow.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Knowing that we have an event to drill into should give enough information to get started. If in doubt I'd head to google with that event in hand + &lt;code&gt;site:github.com&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(let me know if you'd like a more complete walkthrough of a solution [can make an attempt when I get some coffee in the system])&lt;/p&gt;&#xA;" OwnerUserId="2189" LastActivityDate="2016-03-23T15:21:34.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6995" PostTypeId="1" AcceptedAnswerId="7376" CreationDate="2016-03-23T15:57:53.723" Score="5" ViewCount="1264" Body="&lt;p&gt;I'm using vim-plug for managing plugins, primarily for its lazy-loading capabilities. This lets me do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'Valloric/YouCompleteMe', { 'do': 'python2 ./install.py --clang-completer --gocode-completer --tern-completer', …}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't have YCM in all systems where I do have my &lt;code&gt;.vim&lt;/code&gt; present and updated, and sometimes I'm not interested in having it present or installed - Supertab suffices for my needs in these cases, and installing YCM takes too much time, and YCM itself might be too heavyweight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I can skip the build step, since it is a shell command and I can probably do something like &lt;code&gt;'do': '[[ -z $INSTALL_YCM ]] &amp;amp;&amp;amp; python2 …'&lt;/code&gt;. Can I get vim-plug to skip cloning the YCM plugin altogether? It has a bunch of submodules (and submodules within submodules … it's turtles all the way down), and downloading all that would just be a waste of time and bandwidth.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;YCM is just an example. As I add more plugins (I have 17 now, and as I understand, some users have twice as many), I would be interested in skipping plugins on systems where they have no use at all. So, don't focus on YCM.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-09-15T20:07:34.750" Title="Can I get vim-plug to skip installing a plugin, based on some Vimscript condition?" Tags="|plugin-vim-plug|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6996" PostTypeId="1" AcceptedAnswerId="6999" CreationDate="2016-03-23T16:04:12.953" Score="5" ViewCount="3619" Body="&lt;p&gt;I want to work with quickfix without ever having a split window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I've set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set switchbuf=newtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as mentioned at &lt;a href=&quot;https://stackoverflow.com/questions/6852763/vim-quickfix-list-launch-files-in-new-tab&quot;&gt;https://stackoverflow.com/questions/6852763/vim-quickfix-list-launch-files-in-new-tab&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tab copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;opens the quickfix window on a new tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I hit enter on a quickfix item, instead of creating a new tab, it first opens the location on a split in the current tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only after this first split do new tabs get opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to get new tabs from the first &lt;code&gt;&amp;lt;enter&amp;gt;&lt;/code&gt;, and never see any splits?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tested on Vim 7.4.&lt;/p&gt;&#xA;" OwnerUserId="2038" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2024-02-20T14:09:53.227" Title="How to make &lt;enter&gt; open new tabs for the quickfix window when it is opened with &quot;tab copen&quot; including the first time?" Tags="|quickfix|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6997" PostTypeId="2" ParentId="6996" CreationDate="2016-03-23T16:23:08.953" Score="5" Body="&lt;p&gt;The &lt;code&gt;quickfix&lt;/code&gt;/&lt;code&gt;location list&lt;/code&gt; is an interesting beast. I'd recommend reading into &lt;code&gt;:help quickfix&lt;/code&gt; for some inner workings of these two features (pretty much interchangeable; list commands are prefixed with &lt;code&gt;l&lt;/code&gt; and quickfix with &lt;code&gt;q&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds like the default quickfix opens won't solve your problem (opening in a new tab is not supported by default)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd check out &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4778&quot; rel=&quot;noreferrer&quot;&gt;QFEnter&lt;/a&gt;. It was built to give extra control over the &lt;code&gt;quickfix&lt;/code&gt; menu and it looks like it should work out of the box for you.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;    Normal mode : Open an item under cursor in a new tab.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Visual mode : Open items in visual block in a sequence of new tabs.&lt;br&gt;&#xA;  Quickfix window is automatically opened in the new tab to help you&#xA;  open other Quickfix items.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2189" LastActivityDate="2016-03-23T16:23:08.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6998" PostTypeId="2" ParentId="6973" CreationDate="2016-03-23T16:43:22.523" Score="2" Body="&lt;p&gt;To get info on just &lt;code&gt;set cc&lt;/code&gt; try &lt;code&gt;:help 'cc'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a lot to talk about on the subject of highlighting.. The reason that I say this is because I am the author of a highlighting plugin and I went through the ringer trying to understand and master the art of highlighting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My plugin is called &lt;a href=&quot;https://github.com/DanBradbury/vim-poi&quot; rel=&quot;nofollow&quot;&gt;vim-poi&lt;/a&gt; and has been rewritten once from the original implementation (I'm still torn on which solution I like better but for the purposes of learning highlighting it should be enough to get started)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'cc'&lt;/code&gt; can do some cool thing. Taking a look at &lt;code&gt;:help 'cc'&lt;/code&gt; as Carpetsmoker mentioned we can see that this is just  highlighting under the covers&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'colorcolumn' 'cc'    string  (default &quot;&quot;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      local to window             {not in Vi}             {not available when compiled&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;without the |+syntax|             feature}&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;'colorcolumn' is a comma separated list of screen columns that are&#xA;    highlighted with ColorColumn |hl-ColorColumn|.  Useful to align&#xA;    text.  Will make screen redrawing slower.   The screen column can be&#xA;  an absolute number, or a number preceded with     '+' or '-', which is&#xA;  added to or subtracted from 'textwidth'. &gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  :set cc=+1  &quot; highlight column after 'textwidth'        :set cc=+1,+2,+3 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;&quot; highlight three columns after 'textwidth'       :hi ColorColumn&#xA;  ctermbg=lightgrey guibg=lightgrey&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The TLDR of all this is to learn highlighting (&lt;code&gt;:help hi&lt;/code&gt;). I'd definitely play around with some more complex &lt;code&gt;cc&lt;/code&gt;s and get used to navigating &lt;code&gt;:hi&lt;/code&gt; (list of all active highlights) and understanding where they all come from (colorschemes, plugins, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to read about more of my struggles with more advanced highlighting read &lt;a href=&quot;http://danbradbury.net/blog/2015/07/15/matchadd-vs-match/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; (&lt;code&gt;match&lt;/code&gt;/&lt;code&gt;2match&lt;/code&gt; vs &lt;code&gt;matchadd&lt;/code&gt; struggles)&lt;/p&gt;&#xA;" OwnerUserId="2189" LastEditorUserId="2189" LastEditDate="2016-03-23T18:02:41.987" LastActivityDate="2016-03-23T18:02:41.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6999" PostTypeId="2" ParentId="6996" CreationDate="2016-03-23T16:51:57.893" Score="9" Body="&lt;p&gt;This workaround seems to work (mind the capitalized &lt;code&gt;T&lt;/code&gt; in the end):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType qf nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Enter&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;Enter&amp;gt;&amp;lt;C-W&amp;gt;T&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will create a mapping that is local to the &lt;code&gt;quickfix&lt;/code&gt; buffer (it also works in &lt;code&gt;location lists&lt;/code&gt;, since they have the same filetype, i.e. &lt;code&gt;qf&lt;/code&gt;).&#xA;This mapping will first open the item under the cursor in a new window using &lt;code&gt;&amp;lt;C-W&amp;gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; and then move it to an new tab using &lt;code&gt;&amp;lt;C-W&amp;gt;T&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :autocmd&#xA;:help quickfix&#xA;:help CTRL-W_&amp;lt;Enter&amp;gt;&#xA;:help CTRL-W_T&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2016-03-23T16:51:57.893" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7000" PostTypeId="1" AcceptedAnswerId="7001" CreationDate="2016-03-23T17:06:51.447" Score="2" ViewCount="739" Body="&lt;p&gt;I'm writing a vim function to set hard tabs and refactor indents in a whole file.&#xA;This is the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function RefInd()&#xA;    :set tabstop=4 softtabstop=0 noexpandtab shiftwidth=4&#xA;    gg=G&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error executing the function RefInd:&#xA;Line 2:&#xA;E492: Not an editor command: ^Igg=G&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help?&lt;/p&gt;&#xA;" OwnerUserId="6953" LastEditorUserId="205" LastEditDate="2016-05-03T08:18:24.577" LastActivityDate="2016-05-03T08:18:24.577" Title="Function to refactor indents and tabs" Tags="|vimscript|indentation|functions|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7001" PostTypeId="2" ParentId="7000" CreationDate="2016-03-23T17:11:25.793" Score="7" Body="&lt;p&gt;The problem is that &lt;code&gt;gg&lt;/code&gt;, &lt;code&gt;=&lt;/code&gt; and &lt;code&gt;G&lt;/code&gt; are normal mode commands, as opposed to ex commands which are used within a script.&#xA;Writing &lt;code&gt;normal gg=G&lt;/code&gt; should solve your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @Carpetsmoker has pointed out in his comment, using &lt;code&gt;normal!&lt;/code&gt; instead of &lt;code&gt;normal&lt;/code&gt; might be prudent to avoid running user-defined mappings by accident.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3Anormal&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :normal&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3343" LastEditorUserId="3343" LastEditDate="2016-03-23T17:19:08.540" LastActivityDate="2016-03-23T17:19:08.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7003" PostTypeId="2" ParentId="6996" CreationDate="2016-03-23T18:20:45.747" Score="7" Body="&lt;p&gt;This mapping does what &lt;em&gt;I think&lt;/em&gt; you want, put it in &lt;code&gt;~/.vim/after/ftplugin/qf.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; :tabnew\|cc &amp;lt;C-r&amp;gt;=line(&quot;.&quot;)&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-03-23T18:20:45.747" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7004" PostTypeId="1" CreationDate="2016-03-23T18:42:17.857" Score="7" ViewCount="616" Body="&lt;p&gt;Is it possible to create mappings or macros based on &lt;code&gt;keydown&lt;/code&gt; and &lt;code&gt;keyup&lt;/code&gt; events?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you press &lt;code&gt;i&lt;/code&gt; you enter &lt;code&gt;insert&lt;/code&gt; mode, and if you press &lt;code&gt;esc&lt;/code&gt; you leave insert mode and enter &lt;code&gt;normal&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you make it so that if you pressed down &lt;code&gt;i&lt;/code&gt; you entered insert mode, and when you released it, you left insert mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(not that you would want to do that, I am just giving it as an example of behavior)&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="6952" LastEditDate="2016-03-23T20:03:07.647" LastActivityDate="2020-12-18T22:46:22.020" Title="Create mappings/macros with keydown?" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7005" PostTypeId="2" ParentId="7004" CreationDate="2016-03-23T19:11:32.650" Score="8" Body="&lt;p&gt;Short answer is no.&lt;/p&gt;&#xA;&lt;p&gt;Keys are registered as raw I/O; there's no concept of &lt;code&gt;keyup/down/press&lt;/code&gt; like you'd find in &lt;code&gt;javascript&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Rather vim thinks of input in terms of its modes. You have quite a bit of flexibility when creating bindings for different modes.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;:nmap - Display normal mode maps&lt;/p&gt;&#xA;&lt;p&gt;:imap - Display insert mode maps&lt;/p&gt;&#xA;&lt;p&gt;:vmap - Display visual and select mode maps&lt;/p&gt;&#xA;&lt;p&gt;:smap - Display select mode maps&lt;/p&gt;&#xA;&lt;p&gt;:xmap - Display visual mode maps&lt;/p&gt;&#xA;&lt;p&gt;:cmap - Display command-line mode maps&lt;/p&gt;&#xA;&lt;p&gt;:omap - Display operator pending mode maps&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;note:&lt;/strong&gt; In neovim and newer versions of Vim, there is an additional mode; terminal mode, which has its own set of mappings&lt;/p&gt;&#xA;" OwnerUserId="2189" LastEditorUserId="21251" LastEditDate="2020-12-18T22:46:22.020" LastActivityDate="2020-12-18T22:46:22.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7006" PostTypeId="1" AcceptedAnswerId="7016" CreationDate="2016-03-23T19:13:55.673" Score="11" ViewCount="787" Body="&lt;p&gt;Is there anything like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;eval(&quot;is_recording()&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that I can call in my vimscript to find out if I am currently recording a macro? I would have thought this works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;eval(&quot;mode(1)&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that just returns &lt;code&gt;&quot;n&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure if it matters, but I am using neovim, so if it's exclusive to neovim, that is okay.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-03-24T10:13:26.293" Title="Is there a way to detect if I'm recording in vimscript?" Tags="|vimscript|neovim|macro|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7007" PostTypeId="2" ParentId="7006" CreationDate="2016-03-23T19:40:29.760" Score="2" Body="&lt;p&gt;This is a pretty curious request since there is no &quot;mode&quot; for recording a macro. After digging through some docs I found the following in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_10.html#10.1&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;usr_10&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You start by moving to the first character of the first line.  Next&#xA;  you execute the following commands:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;qa            Start recording a macro &lt;strong&gt;in register a&lt;/strong&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;^         Move to the beginning of the line.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;i#include &quot;  Insert the string #include &quot; at the beginning           of&#xA;  the line.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;$         Move to the end of the line.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;a&quot;           Append the character double quotation mark (&quot;)          to the end&#xA;  of the line.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;j         Go to the next line.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;q         Stop recording the macro.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The standout thing to me was the line about &quot;Start recording a macro in register a&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since each macro is going to be saved to a register by default I was hoping that we'd be able to see it in the &lt;code&gt;:reg&lt;/code&gt; list. It turns out it works like a charm!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal mode: &lt;code&gt;qaisomething&amp;lt;Esc&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and inside of &lt;code&gt;:reg&lt;/code&gt; we see the entry!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;a   isomething^[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With that knowledge you should be able to &quot;spy&quot; on the registers to confirm that a macro is being recorded (use a named register on every recording [map &lt;code&gt;q&lt;/code&gt; to always use the same register (or something like that )]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you run into problems let me know and I'll try to help you out (since this functionality is new to me too :D)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt;&#xA;To address the issue of a register being used during yank I'd recommend to look into a special type of register that you can use only for the &lt;code&gt;vimL&lt;/code&gt; you are writing (no yank would ever be engaged on the register (&lt;code&gt;&quot;ay&lt;/code&gt;))&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a bit of info from &lt;code&gt;:help registers&lt;/code&gt; on the available registers&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There are ten types of registers:         &lt;em&gt;registers&lt;/em&gt; &lt;em&gt;E354&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;&lt;p&gt;The unnamed register &quot;&quot;&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;10 numbered registers &quot;0 to &quot;9&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;The small delete register &quot;-&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;26 named registers &quot;a to &quot;z or &quot;A to &quot;Z&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;three read-only registers &quot;:, &quot;., &quot;%&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;alternate buffer register &quot;#&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;the expression register &quot;=&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;The selection and drop registers &quot;*, &quot;+ and &quot;~ &lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;The black hole register &quot;_&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Last search pattern register &quot;/&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Assuming that you have a register that you are going to use now the issue becomes &quot;how do I know when recording has stopped?&quot;. To take care of this I'd take a look at the &lt;code&gt;autocmd-event&lt;/code&gt; for &lt;code&gt;CursorHold&lt;/code&gt;; the note in the help docs looks pretty promising (I'd try to figure out how I could differentiate normal cursorHold vs the idle/non-existant event that occurs when your register is being written to for the purposes of the macro)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;CursorHold            &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When the user doesn't press a key for the time&#xA;                specified with 'updatetime'.  Not re-triggered&#xA;                until the user has pressed a key (i.e. doesn't&#xA;                fire every 'updatetime' ms if you leave Vim to&#xA;                make some coffee. :)  See |CursorHold-example|&#xA;                for previewing tags.&#xA;                This event is only triggered in Normal mode.&#xA;                It is not triggered when waiting for a command&#xA;                argument to be typed, or a movement after an&#xA;                operator.&#xA;                While recording the CursorHold event is not&#xA;                triggered. |q|&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2189" LastEditorUserId="2189" LastEditDate="2016-03-23T21:06:13.307" LastActivityDate="2016-03-23T21:06:13.307" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7008" PostTypeId="1" AcceptedAnswerId="7009" CreationDate="2016-03-23T20:28:19.477" Score="5" ViewCount="209" Body="&lt;p&gt;Is it OK to use spaces for better readability in a .vimrc? For example, right now I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number| &quot;show line numbers&#xA;set history=1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would it be OK to write instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number | &quot;show line numbers&#xA;set history = 1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know that if a space is before the virgule in a key remapping then the space becomes part of the mapping, but in the example above the space would not seem to affect the &lt;code&gt;set&lt;/code&gt;  operation.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="205" LastEditDate="2016-03-24T06:33:05.670" LastActivityDate="2016-03-24T06:33:05.670" Title="Are spaces OK in set statements?" Tags="|vimrc|options|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7009" PostTypeId="2" ParentId="7008" CreationDate="2016-03-23T21:01:18.720" Score="8" Body="&lt;p&gt;From &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#:set-args&quot;&gt;&lt;code&gt;:help :set-args&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;White space between {option} and '=' is allowed and&#xA;  will be ignored.  White space between '=' and {value}&#xA;  is not allowed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set history=1000 &quot; is ok.&#xA;set history =1000 &quot; is also ok, but&#xA;set history= 1000 &quot; is not. Neighter is&#xA;set history = 1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the option doesn't take a value you can put as many spaces behind it as you want.&lt;/p&gt;&#xA;" OwnerUserId="20" LastActivityDate="2016-03-23T21:01:18.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7011" PostTypeId="1" AcceptedAnswerId="7013" CreationDate="2016-03-24T00:59:46.537" Score="11" ViewCount="37557" Body="&lt;p&gt;Is it possible to go to a class or function definition by search?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. in Sublime it is possible to search the file for class and function names, and the viewport will automatically jump to the current closest match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now if I want to find a specific function i use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&amp;lt;function name&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and press &lt;kbd&gt;n&lt;/kbd&gt; or &lt;kbd&gt;N&lt;/kbd&gt; accordingly, but I also find all the places it has been used in the code. Also, as this highlights the text as well I need to type &lt;code&gt;:noh&lt;/code&gt; afterwards to remove it.&lt;/p&gt;&#xA;" OwnerUserId="6957" LastEditorUserId="1841" LastEditDate="2016-03-24T06:32:30.587" LastActivityDate="2016-03-24T17:46:52.150" Title="How to go to function or class definition in current file" Tags="|search|tags|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7012" PostTypeId="2" ParentId="7011" CreationDate="2016-03-24T06:29:18.103" Score="5" Body="&lt;p&gt;You will have to use a program like ctags to generate a tag file. It is recommended to use &lt;a href=&quot;http://ctags.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;exuberant ctags&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you installed this program, go to the root directory of you project in a shell and generate a tagfile with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ctags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will create a text file which contains the lines corresponding to the definition of each of your functions. Vim is able to parse this file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once this file is created you'll be able to use &lt;kbd&gt;ctrl+]&lt;/kbd&gt; and &lt;kbd&gt;ctrl+t&lt;/kbd&gt; to jumps between the tags. You can refer to this &lt;a href=&quot;http://vim.wikia.com/wiki/Browsing_programs_with_tags&quot; rel=&quot;noreferrer&quot;&gt;wiki article&lt;/a&gt; for more details about the tag navigation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I would recommend using the &lt;a href=&quot;https://github.com/vim-scripts/taglist.vim&quot; rel=&quot;noreferrer&quot;&gt;taglist plugin&lt;/a&gt; which is pretty convenient to improve tag navigation. &lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-03-24T06:29:18.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7013" PostTypeId="2" ParentId="7011" CreationDate="2016-03-24T07:31:22.140" Score="19" Body="&lt;p&gt;You don't necessarily have to install a plugin like ctags (although this would be reliable and allow many more great features, because you have semantic knowledge of your code, of course). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has a built in function to go to the definition by doing a clever search:&#xA;With the cursor over a keyword, press &lt;code&gt;gd&lt;/code&gt; or &lt;code&gt;gD&lt;/code&gt;. &#xA;I recommend reading the help page on these, if you want to understand how they work exactly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to search for a function from anywhere in your code, I would recommend the &lt;a href=&quot;https://github.com/majutsushi/tagbar&quot; rel=&quot;noreferrer&quot;&gt;tagbar plugin&lt;/a&gt;. It requires ctags, however. I use it in a very similar way: Toggle the bar with a shortcut which gives me an automatically created list of function names and other tags. Like any other buffer, I can search it and jump to the definition with enter.&lt;/p&gt;&#xA;" OwnerUserId="6495" LastEditorUserId="205" LastEditDate="2016-03-24T17:46:52.150" LastActivityDate="2016-03-24T17:46:52.150" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7014" PostTypeId="1" CreationDate="2016-03-24T08:02:18.913" Score="9" ViewCount="925" Body="&lt;p&gt;My cursor in Gvim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Cc0Vw.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cc0Vw.png&quot; alt=&quot;My cursor in Gvim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My cursor in Gvim after pressing &lt;code&gt;d&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MBMhs.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MBMhs.png&quot; alt=&quot;My cursor in Gvim after pressing &amp;lt;code&amp;gt;d&amp;lt;/code&amp;gt;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can change the cursor in terminal Vim when in operator pending mode? It doesn't have to look exactly like the screenshots.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is done by &lt;code&gt;o:hor50-Cursor&lt;/code&gt; in &lt;code&gt;guicursor&lt;/code&gt; for Gvim. The only three options I see for Vim are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t_SI    start insert mode (bar cursor shape)        *t_SI* *'t_SI'*&#xA;t_SR    start replace mode (underline cursor shape) *t_SR* *'t_SR'*&#xA;t_EI    end insert or replace mode (block cursor shape) *t_EI* *'t_EI'*&#xA;    |termcap-cursor-shape|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But nothing about operator pending mode...&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-08-03T17:16:32.740" Title="Change the cursor shape in operator pending mode" Tags="|cursor-motions|terminal|cursor|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7015" PostTypeId="1" CreationDate="2016-03-24T08:02:59.247" Score="2" ViewCount="883" Body="&lt;p&gt;I am using the &lt;a href=&quot;https://github.com/ternjs/tern_for_vim&quot; rel=&quot;nofollow&quot;&gt;ternjs for vim plugin&lt;/a&gt;  (based on &lt;a href=&quot;http://ternjs.net/&quot; rel=&quot;nofollow&quot;&gt;tern js project&lt;/a&gt;) and standard vim omni-completion.&lt;br&gt;&#xA;I am unable to get basic eager loading working with tern or I am misunderstanding how the &lt;code&gt;loadEagerly&lt;/code&gt; option is supposed to work.&lt;br&gt;&#xA;Here is my setup of files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% tree -a &#xA;.&#xA;├── index.html&#xA;├── index.js&#xA;├── lib.js&#xA;├── Session.vim&#xA;└── .tern-project&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;file: &lt;code&gt;index.html&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&#xA;&amp;lt;head&amp;gt;&#xA;    &amp;lt;title&amp;gt;test tern&amp;lt;/title&amp;gt;&#xA;&#xA;&amp;lt;/head&amp;gt;&#xA;&amp;lt;body&amp;gt;&#xA;    &amp;lt;p&amp;gt;Hello world&amp;lt;/p&amp;gt;&#xA;    &amp;lt;script src=&quot;lib.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&#xA;    &amp;lt;script src=&quot;index.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;file: &lt;code&gt;lib.js&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var namespace = {&#xA;    fruits : ['apple', 'bannana', 'orange'],&#xA;        text : &quot;A tremor in the Force. The last time I felt it was in the presence of my old master.&quot;&#xA;};&#xA;&#xA;function go(compare_me) {&#xA;    return compare_me === &quot;reference&quot;;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;file: &lt;code&gt;.tern-project&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    &quot;libs&quot;: [&#xA;        &quot;ecma5&quot;,&#xA;        &quot;browser&quot;&#xA;    ],&#xA;    &quot;loadEagerly&quot;: [&quot;*.js&quot;],&#xA;    &quot;plugins&quot;: {&#xA;        &quot;node&quot;: {}&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;tern itself is working, e.g. if I am in &lt;code&gt;lib.js&lt;/code&gt; and type:&lt;br&gt;&#xA;g&lt;kbd&gt;Ctrl-x&lt;/kbd&gt;&lt;kbd&gt;Ctrl-o&lt;/kbd&gt;&lt;br&gt;&#xA; &lt;code&gt;go (fn)&lt;/code&gt; appears in autocompletion dropdown list and a function signature appears in the preview window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fn(compare_me: ?) -&amp;gt; bool &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when I open &lt;code&gt;index.js&lt;/code&gt; I am expecting &quot;loadEagerly&quot; to cause variables and functions from &lt;code&gt;lib.js&lt;/code&gt; to appear in completion.&lt;br&gt;&#xA;But its not - autocompletion is unresponsive, why?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2016-03-24T08:02:59.247" Title="How to setup loadEagerly with tern-js?" Tags="|plugin-ternjs|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7016" PostTypeId="2" ParentId="7006" CreationDate="2016-03-24T09:02:47.530" Score="4" Body="&lt;p&gt;Firstly, I think that your problem is mainly a &lt;a href=&quot;https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem&quot;&gt;XY problem&lt;/a&gt;. You should give us more information about what you are trying to do in the end and I think we could find another solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now here is a workaround, it is probably not ideal and certainly not very robust but you could add these lines to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:isRecording = 0&#xA;nnoremap Q :call ToggleRecording()&amp;lt;CR&amp;gt;q&#xA;&#xA;function! ToggleRecording()&#xA;    let g:isRecording = !g:isRecording&#xA;    echo &quot;is recording &quot; . g:isRecording&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is that the &quot;recording mode&quot; is toggled exclusively when you press &lt;kbd&gt;q&lt;/kbd&gt; in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on that you create a variable &lt;code&gt;g:isRecording&lt;/code&gt; which will be toggled each time you start or stop a recording. This way when you start recording &lt;code&gt;g:isRecording&lt;/code&gt; will be set to &lt;code&gt;1&lt;/code&gt; and to &lt;code&gt;0&lt;/code&gt; when you stop recording. You can then access the recording state via the value of the variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;drawback&quot; is that to avoid recursive mapping, you'll have to use &lt;kbd&gt;Shit-q&lt;/kbd&gt;  to start and stop recording instead of &lt;kbd&gt;q&lt;/kbd&gt;. &lt;em&gt;(Note that it is not such a big problem: I've been using &lt;kbd&gt;shift-q&lt;/kbd&gt; to toggle record mode for some time because I don't like the original &lt;kbd&gt;shift-q&lt;/kbd&gt; behavior)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main problem of this solution is that if you forgot about it and use &lt;kbd&gt;q&lt;/kbd&gt; the variable will not be toggled but you can't disable &lt;kbd&gt;q&lt;/kbd&gt; (e.g. with &lt;code&gt;nnoremap q &amp;lt;nop&amp;gt;&lt;/code&gt;) because if you do the &lt;kbd&gt;shift-q&lt;/kbd&gt; won't' work anymore.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-03-20T10:32:30.300" LastActivityDate="2016-03-24T10:13:26.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7017" PostTypeId="2" ParentId="6651" CreationDate="2016-03-24T10:57:14.633" Score="1" Body="&lt;p&gt;For this situations, I have a smart line delete cmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;dd ^D&quot;_dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you want to paste inside &lt;code&gt;{ }&lt;/code&gt;. I'm using &lt;code&gt;?{&amp;lt;ENTER&amp;gt;vi{p&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subject {MyModel.my_method}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6850" LastActivityDate="2016-03-24T10:57:14.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7018" PostTypeId="1" CreationDate="2016-03-24T10:59:12.497" Score="3" ViewCount="99" Body="&lt;p&gt;If some characters are concealed in a line, so that the effectively the entire line is visible, and &lt;code&gt;nowrap&lt;/code&gt; is set, moving to the end of the line can cause Vim to scroll if the actual line length is greater than what can be displayed. Lines without concealed characters aren't affected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nOSGC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nOSGC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The terminal is 95 characters wide. The current line is 78 characters long, and since it has nothing concealed, it doesn't scroll. The line above does have concealed characters, and it scrolls, leaving a jagged edge:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eTuNj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eTuNj.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The displayed part of both lines fit comfortably in 95 characters. Concealed characters are completely hidden (&lt;code&gt;set concealcursor=nvic conceallevel=3&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I tell Vim to not scroll in such cases?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;set sidescrolloff=0&lt;/code&gt; had no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, I'm viewing manpages, and I &lt;em&gt;know&lt;/em&gt; that the visible length will never be more than the display area. In this case, just disabling sidescrolling altogether would be fine.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-03-24T10:59:12.497" Title="Can I disable sidescrolling altogether?" Tags="|scrolling|conceal|" AnswerCount="0" CommentCount="5" ClosedDate="2016-03-24T15:20:25.080" ContentLicense="CC BY-SA 3.0" />
  <row Id="7019" PostTypeId="1" AcceptedAnswerId="7024" CreationDate="2016-03-24T12:09:16.027" Score="1" ViewCount="1137" Body="&lt;p&gt;There is the supertab binding &lt;code&gt;&amp;lt;c-tab&amp;gt;&lt;/code&gt; that is supposed to produce a normal tab, but that doesn't work on my system (Mac; tried in iTerm and terminal).  And I just remembered reading that Tab is equivalent to &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt;. Wouldn't that imply that &lt;code&gt;&amp;lt;c-tab&amp;gt;&lt;/code&gt; ≡ &lt;code&gt;&amp;lt;c-c-i&amp;gt;&lt;/code&gt; (≡ nonsense)? (I don't really need this binding, &lt;code&gt;&amp;lt;c-v&amp;gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; is fine; but it got me curious.)&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="205" LastEditDate="2016-03-24T17:11:47.980" LastActivityDate="2016-03-24T17:11:47.980" Title="Why isn't supertab's &lt;c-tab&gt; binding working?" Tags="|key-bindings|plugin-supertab|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7020" PostTypeId="1" AcceptedAnswerId="7021" CreationDate="2016-03-24T12:38:41.057" Score="3" ViewCount="328" Body="&lt;p&gt;&lt;code&gt;vim&lt;/code&gt; has some great highlighting for built-in keywords, functions and types, but when working on some non-built-in projects, this seems not enough.&lt;/p&gt;&#xA;&lt;p&gt;For instance, the keyword before a variable is mostly a &lt;code&gt;type&lt;/code&gt; keyword. Take a &lt;code&gt;gtk&lt;/code&gt; program for example:&lt;/p&gt;&#xA;&lt;p&gt;In &lt;code&gt;vim&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/A1Mg0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/A1Mg0.png&quot; alt=&quot;first&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Where the three &lt;code&gt;GtkWidget&lt;/code&gt;s should be marked as &lt;code&gt;type&lt;/code&gt; as that in SO:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nHBU1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nHBU1.png&quot; alt=&quot;SO&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;These are some basic syntax for the C language. Can one in &lt;code&gt;vim&lt;/code&gt; do the same highlighting?&lt;/p&gt;&#xA;" OwnerUserId="6380" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-03-24T12:54:17.350" Title="match special types in C" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7021" PostTypeId="2" ParentId="7020" CreationDate="2016-03-24T12:54:17.350" Score="4" Body="&lt;p&gt;There are several plugins in &lt;a href=&quot;http://www.vim.org/scripts/script_search_results.php?keywords=gtk&amp;amp;script_type=&amp;amp;order_by=rating&amp;amp;direction=descending&amp;amp;search=search&quot; rel=&quot;nofollow&quot;&gt;vim.org&lt;/a&gt; that should accomplish that, for instance:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1000&quot; rel=&quot;nofollow&quot;&gt;gtk-vim-syntax : Syntax highlighting for GLib, Gtk+, Xlib, Gimp, Gstreamer, and more.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=570&quot; rel=&quot;nofollow&quot;&gt;GTK+ : GTK+-2.2 syntax highlight&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If no existing plugin work as you expect them you should consider writing a new one (and possibly including it in vim.org) by following the explanation in &lt;a href=&quot;http://vimhelp.appspot.com/usr_44.txt.html#usr_44.txt&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help usr_44&lt;/code&gt;&lt;/a&gt; -- &quot;Your own syntax highlighted&quot;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-03-24T12:54:17.350" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7022" PostTypeId="1" AcceptedAnswerId="7023" CreationDate="2016-03-24T13:09:46.873" Score="13" ViewCount="996" Body="&lt;p&gt;Can I change a variable in an instance of vim from another shell (without sending keys through tmux)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ask because I would like to use latexmk's compiling_cmd, success_cmd, and failure_cmd options to show compilation status on the statusline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps I could have vim look for the existence or non-existence of certain files (using files as boolean variables)? But this seems a bit dirty; hopefully there is a better way.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2016-03-24T13:42:12.967" LastActivityDate="2016-03-24T15:52:37.217" Title="Talking to vim from outside" Tags="|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7023" PostTypeId="2" ParentId="7022" CreationDate="2016-03-24T13:40:12.263" Score="18" Body="&lt;p&gt;If you launch your first Vim session with the argument &lt;code&gt;--servername VIM&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --servername VIM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then you can send any command from any other shell with the argument &lt;code&gt;--remote-send&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you use your statusline to display the value of some variable &lt;code&gt;g:myvar&lt;/code&gt;, and you have the following lines in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:myvar = &quot;foo&quot;&#xA;set stl+=%{g:myvar}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can change its value (&lt;code&gt;:let g:myvar = &quot;bar&quot;&lt;/code&gt;) from another shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --remote-send ':let g:myvar = &quot;bar&quot;&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The statusline should reflect the change of the value.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As your last &lt;a href=&quot;https://vi.stackexchange.com/questions/7022/talking-to-vim-from-outside#comment11473_7023&quot;&gt;comment&lt;/a&gt; says it, if your Vim instance is not in normal mode, the previous command will not work as expected. There may be simpler, but here are 2 possible solutions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) add the key &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; to be in normal mode&lt;br&gt;&#xA;2) use the argument &lt;code&gt;--remote-expr&lt;/code&gt; instead of &lt;code&gt;--remote-send&lt;/code&gt; to evaluate an expression and write a small helper function whose code will assign the new value to your variable&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --remote-send '&amp;lt;esc&amp;gt;:let g:myvar = &quot;bar&quot;&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Define the following function in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Myfunc(value)&#xA;    let g:myvar = a:value&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, in your shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --remote-expr 'Myfunc(&quot;bar&quot;)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-03-24T15:52:37.217" LastActivityDate="2016-03-24T15:52:37.217" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7024" PostTypeId="2" ParentId="7019" CreationDate="2016-03-24T14:32:07.280" Score="3" Body="&lt;p&gt;You are right about &lt;kbd&gt;tab&lt;/kbd&gt; being the same same as &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;i&lt;/kbd&gt;, as explained in &lt;a href=&quot;http://vimhelp.appspot.com/intro.txt.html#keycodes&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help key-codes&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                    *key-notation* *key-codes* *keycodes*&#xA;These names for keys are used in the documentation.  They can also be used&#xA;with the &quot;:map&quot; command (insert the key name by pressing CTRL-K and then the&#xA;key you want the name for).&#xA;&#xA;notation    meaning         equivalent  decimal value(s)    ~&#xA;-----------------------------------------------------------------------&#xA;&amp;lt;Nul&amp;gt;       zero            CTRL-@    0 (stored as 10) *&amp;lt;Nul&amp;gt;*&#xA;&amp;lt;BS&amp;gt;        backspace       CTRL-H    8 *backspace*&#xA;&amp;lt;Tab&amp;gt;       tab         CTRL-I    9 *tab* *Tab*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Following the procedure on &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html&quot; rel=&quot;nofollow&quot;&gt;Vim FAQ &quot;20.4. I am not able to create a mapping for the  key. What is wrong?&quot;&lt;/a&gt; on my machine the output for &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; &lt;kbd&gt;tab&lt;/kbd&gt; differs from &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;tab&lt;/kbd&gt;, both on terminal and gVim, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So Vim is able to map &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;tab&lt;/kbd&gt; and &lt;kbd&gt;tab&lt;/kbd&gt; independently.&#xA;You could use the following mappings to check if your problem caused by some problem in Vim recognizing &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;tab&lt;/kbd&gt; or in supertab plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-tab&amp;gt; abc&#xA;inoremap &amp;lt;tab&amp;gt; def&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-03-24T14:32:07.280" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7025" PostTypeId="1" AcceptedAnswerId="7026" CreationDate="2016-03-24T17:06:03.357" Score="2" ViewCount="201" Body="&lt;p&gt;If I'm using a range in a regex, how can I replace with the character that was matched? For example, lets say I want to find all occurrences of &lt;code&gt;a&lt;/code&gt; or &lt;code&gt;b&lt;/code&gt;, and replace them with &lt;code&gt;aa&lt;/code&gt; or &lt;code&gt;bb&lt;/code&gt;. Can I do this in a single regex? For example, something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/[a-b]/\1\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;\1&lt;/code&gt; means the first matching character? Can I extend this to several characters? For example converting &lt;code&gt;camelCase&lt;/code&gt; to &lt;code&gt;snake_case&lt;/code&gt;. Can I do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/[a-z][A-Z]/\1_\2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;\1&lt;/code&gt; is the first matching character and &lt;code&gt;\2&lt;/code&gt; is the second matching character?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="205" LastEditDate="2016-03-24T17:18:57.800" LastActivityDate="2016-03-24T18:12:18.797" Title="How do I substitute with a character from the matched text, where the pattern contains a range?" Tags="|regular-expression|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7026" PostTypeId="2" ParentId="7025" CreationDate="2016-03-24T17:15:34.220" Score="3" Body="&lt;p&gt;For using the entire matched text, just use &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#s%2F%5C%26&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;&amp;amp;&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;magic   nomagic   action    &#xA;  &amp;amp;       \&amp;amp;      replaced with the whole matched pattern            s/\&amp;amp;&#xA; \&amp;amp;        &amp;amp;      replaced with &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/[a-b]/&amp;amp;&amp;amp;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For using the matched text in parts, use &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%28&quot; rel=&quot;nofollow&quot;&gt;regex groups&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(\)    A pattern enclosed by escaped parentheses.      /\( /\(\) /\)&#xA;        E.g., &quot;\(^a\)&quot; matches 'a' at the start of a line.&#xA;        E51 E54 E55 E872 E873&#xA;&#xA;\1      Matches the same string that was matched by     /\1 E65&#xA;        the first sub-expression in \( and \). {not in Vi}&#xA;        Example: &quot;\([a-z]\).\1&quot; matches &quot;ata&quot;, &quot;ehe&quot;, &quot;tot&quot;, etc.&#xA;\2      Like &quot;\1&quot;, but uses second sub-expression,      /\2&#xA;   ...                                                  /\3&#xA;\9      Like &quot;\1&quot;, but uses ninth sub-expression.       /\9&#xA;        Note: The numbering of groups is done based on which &quot;\(&quot; comes first&#xA;        in the pattern (going left to right), NOT based on what is matched&#xA;        first.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\([a-z]\)\([A-Z]\)/\1_\2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or more conveniently, &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2Fmagic&quot; rel=&quot;nofollow&quot;&gt;enabling magic&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v([a-z])([A-Z])/\1_\2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-03-24T17:15:34.220" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7027" PostTypeId="2" ParentId="7025" CreationDate="2016-03-24T18:00:09.437" Score="2" Body="&lt;p&gt;You can easily change from camelCase style to snake_case style via the &lt;a href=&quot;https://github.com/tpope/vim-abolish&quot; rel=&quot;nofollow&quot;&gt;Abolish.vim&lt;/a&gt; plugin&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\&amp;lt;\l\+\u\w\+/\=Abolish.snakecase(submatch(0))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Abolish also provides &quot;Coerce&quot; mappings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;crc&lt;/code&gt; - coerce to camelCase&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;crs&lt;/code&gt; - coerce to snake_case&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;crm&lt;/code&gt; - coerce to MixCased&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cru&lt;/code&gt; - coerce to UPPERCASE_SNAKE_CASE&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cr-&lt;/code&gt; - coerce to dashed-case&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There is Vimcasts eposide on use Abolish: &lt;a href=&quot;http://vimcasts.org/episodes/smart-search-with-subvert/&quot; rel=&quot;nofollow&quot;&gt;Smart search with :Subvert&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h /\&amp;lt;&#xA;:h /\l&#xA;:h /\u&#xA;:h sub-replace-expression&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2016-03-24T18:12:18.797" LastActivityDate="2016-03-24T18:12:18.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7028" PostTypeId="1" AcceptedAnswerId="7029" CreationDate="2016-03-24T18:33:20.717" Score="5" ViewCount="2275" Body="&lt;p&gt;Bash can natively match regular expressions in the &lt;code&gt;[[ ]]&lt;/code&gt; construct, using the &lt;code&gt;=~&lt;/code&gt; operator. When it matches something, the result is stored in the &lt;a href=&quot;https://www.gnu.org/software/bash/manual/bashref.html#index-BASH_005fREMATCH&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;BASH_REMATCH&lt;/code&gt;&lt;/a&gt; array variable. &lt;code&gt;BASH_REMATCH&lt;/code&gt; contains, in order, the entire matched text, and then each matched subexpression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ foo=abcd&#xA;$ [[ $foo =~ (.(.))(.) ]]&#xA;$ printf &quot;%s\n&quot; &quot;${BASH_REMATCH[@]}&quot;&#xA;abc&#xA;ab&#xA;b&#xA;c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there something that would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let foo = 'abcd'&#xA;let bar = groupmatch(foo, '\(.\(.\)\)\(.\)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;echo bar&lt;/code&gt; would give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['abc', 'ab', 'b', 'c']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would be something like &lt;code&gt;split()&lt;/code&gt;, but far, &lt;em&gt;far&lt;/em&gt; more powerful. The &lt;code&gt;(.(.))(.)&lt;/code&gt; is just a toy expression - the full power of regular expressions can be availed in &lt;code&gt;[[ ]]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-03-24T19:14:05.943" Title="Is there a function which can return a list of matching text for groups in a regex?" Tags="|vimscript|regular-expression|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7029" PostTypeId="2" ParentId="7028" CreationDate="2016-03-24T18:44:02.347" Score="8" Body="&lt;p&gt;Maybe you could try &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#matchlist%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;matchlist()&lt;/code&gt;&lt;/a&gt; and &lt;code&gt;filter()&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let foo = 'abcd'&#xA;:let bar = filter(matchlist(foo, '\v(.(.))(.)'), 'v:val !=# &quot;&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;:echo bar&lt;/code&gt; should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['abc', 'ab', 'b', 'c']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;matchlist()&lt;/code&gt; by itself always returns a list of ten items if the match was successful, one for each possible sub-expression, whether or not the pattern actually contained enough sub-expressions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo matchlist('abcd', '\v(.(.))(.)')&#xA;['abc', 'ab', 'b', 'c', '', '', '', '', '', '']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More than nine sub-expressions causes it to error out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo matchlist('abcdefghijklmn', '\v(.(.))(.(.))(.(.))(.(.))(.(.))(.(.))')&#xA;E872: (NFA regexp) Too many '('&#xA;E51: Too many (&#xA;[]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whereas Bash can go further:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ foo=abcdefghijklmn&#xA;$ [[ $foo =~ (.(.))(.(.))(.(.))(.(.))(.(.))(.(.)) ]]&#xA;$ printf &quot;%s\n&quot; &quot;${#BASH_REMATCH[@]}&quot; &quot;${BASH_REMATCH[@]}&quot;&#xA;13&#xA;abcdefghijkl&#xA;ab&#xA;b&#xA;cd&#xA;d&#xA;ef&#xA;f&#xA;gh&#xA;h&#xA;ij&#xA;j&#xA;kl&#xA;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-03-24T19:14:05.943" LastActivityDate="2016-03-24T19:14:05.943" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7031" PostTypeId="5" CreationDate="2016-03-24T19:46:56.643" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-24T19:46:56.643" LastActivityDate="2016-03-24T19:46:56.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7032" PostTypeId="4" CreationDate="2016-03-24T19:46:56.643" Score="0" Body="A plugin for Firefox that allows you to use vim keybindings, marks, and macros within the browser." OwnerUserId="1065" LastEditorUserId="1065" LastEditDate="2016-03-25T00:20:35.940" LastActivityDate="2016-03-25T00:20:35.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7033" PostTypeId="1" CreationDate="2016-03-24T20:34:26.173" Score="6" ViewCount="2235" Body="&lt;p&gt;I'm using Vim 7.4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a buffer open and I type &lt;code&gt;:vsplit&lt;/code&gt;. Vim splits the screen and I see my buffer in both windows. That's great. Just what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And at this point &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; &lt;kbd&gt;W&lt;/kbd&gt; switches the focus from one window to the other, as documented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However,&lt;/strong&gt; if I open a Netrw browser in one of the windows like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim opens Netrw in the focussed window, then switches focus to the &lt;strong&gt;other&lt;/strong&gt; window. (The one that's a file buffer, not a Netrw browser.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And after that, &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; &lt;kbd&gt;W&lt;/kbd&gt; has zero effect. Vim won't let me move the focus to the Netrw directory listing window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other commands for switching the focus won't let me enter the Netrw window either, like &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; &lt;kbd&gt;J&lt;/kbd&gt; or &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;J&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I end up with this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-----------------------------------&#xA;|  File buffer  |  Netrw listing  |&#xA;|   Has focus   |  Can't switch   |&#xA;|               |    to this      |&#xA;-----------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried restarting Vim like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, that causes Netrw to not be loaded at all so it's isn't very informative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only plugins I'm using are...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vim Sensible  &#xA;Ctrl  &#xA;Airline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help or advice would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="6689" LastEditorUserId="6689" LastEditDate="2016-03-24T21:59:38.963" LastActivityDate="2017-04-10T23:37:37.737" Title="If I split the screen and open a Netrw dir listing in one window, Vim won't let me focus that window" Tags="|vim-windows|split|netrw|window-management|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7034" PostTypeId="1" CreationDate="2016-03-25T00:33:41.653" Score="1" ViewCount="82" Body="&lt;p&gt;I ran into this doing a quick conversion of markdown into JIRA markdown.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- A standard markdown list&#xA;  - hierarchical&#xA;  - easy to read&#xA;    - tidy&#xA;&#xA;- A JIRA markdown list&#xA;-- Hierarchical&#xA;-- Somewhat more annoying to read&#xA;--- Why, JIRA, why?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Expressed in English, what I needed to do was:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On any line beginning with spaces followed by a hyphen followed by at least one space, replace &lt;code&gt;&quot;^  &quot;&lt;/code&gt; (two leading spaces) with &lt;code&gt;&quot;-&quot;&lt;/code&gt; repeatedly&#xA;    for all instances of two spaces up to the hyphen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I actually did, which comes close, was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\s\+- /s/  /-/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, if there are any instances of two consecutive spaces elsewhere in the line (after the first hyphen), this will incorrectly convert them to a hyphen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to make &lt;code&gt;:s&lt;/code&gt; match not globally, but only on some specified part of the line?  Perhaps on a backreference?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Imaginary syntax&lt;/strong&gt; for applying a substitute command globally, but only to the part of the line captured in a backreference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/g/^\s\+- / /^\(\s\+\)/ \1s/  /-/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="4676" LastEditDate="2016-03-25T00:59:55.920" LastActivityDate="2016-03-25T04:18:15.370" Title="Can I restrict :s to a particular substring of a line?" Tags="|regular-expression|substitute|ex-mode|filetype-markdown|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7036" PostTypeId="2" ParentId="7034" CreationDate="2016-03-25T03:58:51.563" Score="2" Body="&lt;p&gt;In this specific case, you want to replace leading matches of &lt;code&gt;&lt;/code&gt; with an equal number of &lt;code&gt;-&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\s\+- /s:^\(  \)*:\=repeat('-', strlen(submatch(0))/2):g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/7338794/2072269&quot;&gt;Vim regex replace with n characters&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;More generally, you can use expressions (in particular, the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#substitute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;subtitute()&lt;/code&gt;&lt;/a&gt; function) in the replacement in combination with &lt;code&gt;\zs&lt;/code&gt;/&lt;code&gt;\ze&lt;/code&gt; (or lookaheads and lookbehinds) (as seen in the example in &lt;a href=&quot;https://vi.stackexchange.com/a/5081/205&quot;&gt;this answer&lt;/a&gt;), to act &lt;em&gt;only&lt;/em&gt; on a section of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s:^\(  \)*:\=substitute(submatch(0), '  ', '-', 'g'):g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, the section is well-anchored already, and there was no need for &lt;code&gt;\zs&lt;/code&gt; or lookarounds.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-03-25T04:18:15.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7038" PostTypeId="1" AcceptedAnswerId="7049" CreationDate="2016-03-25T16:18:12.230" Score="1" ViewCount="678" Body="&lt;p&gt;If I use the color logging for maven, the file path is corrupted by the coloring syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[[1;31m[ERROR]^[[m /home/foo/bar/src/main/java/com/domain/bar/App.java&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ERROR] /home/foo/bar/src/main/java/com/domain/bar/App.java:[48,50] cannot find symbol&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I have a colored output and correct path for the quickfix window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;a href=&quot;http://www.aheritier.net/united-colors-of-maven/&quot; rel=&quot;nofollow&quot;&gt;http://www.aheritier.net/united-colors-of-maven/&lt;/a&gt; to have colored output.&lt;/p&gt;&#xA;" OwnerUserId="2510" LastEditorUserId="205" LastEditDate="2016-03-25T18:27:25.953" LastActivityDate="2016-03-26T12:45:17.120" Title="maven colored logging breaks filepath" Tags="|quickfix|makeprg|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7039" PostTypeId="1" AcceptedAnswerId="7046" CreationDate="2016-03-25T16:29:26.323" Score="2" ViewCount="48" Body="&lt;p&gt;Say I want to begin letters like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Dear world,&#xA;           hello.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's the simplest way to define a mapping that opens a new line preserving the cursor's horizontal position?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-03-26T00:04:41.730" Title="Opening a new line without returning the carriage" Tags="|formatting|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7040" PostTypeId="1" CreationDate="2016-03-25T17:58:49.583" Score="4" ViewCount="6482" Body="&lt;p&gt;I know i can scroll down using ctrl+e and up using control ctrl+y. Any idea how I can scroll multiple lines with ctrl+e ? I am looking for a quick solution for scrolling down in vim ?&lt;/p&gt;&#xA;" OwnerUserId="6877" LastActivityDate="2016-03-26T11:02:10.223" Title="Scrolling down multiple lines with Ctrl+e" Tags="|macvim|scrolling|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7041" PostTypeId="2" ParentId="7040" CreationDate="2016-03-25T18:10:51.443" Score="8" Body="&lt;p&gt;You can use a count before Ctrl-E − &lt;code&gt;15&amp;lt;C-e&amp;gt;&lt;/code&gt; moves down 15 lines. Ctrl-D moves down half a screen by default, although the amount it moves can be configured via the &quot;scroll&quot; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help motion.txt&lt;/code&gt;&lt;/a&gt; will provide this and a whole lot more details.&lt;/p&gt;&#xA;" OwnerUserId="6977" LastEditorUserId="51" LastEditDate="2016-03-26T11:02:10.223" LastActivityDate="2016-03-26T11:02:10.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7042" PostTypeId="2" ParentId="7040" CreationDate="2016-03-25T18:11:58.340" Score="7" Body="&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt; takes count, so the quick and simple way is to create a normal mode mapping like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-e&amp;gt; 10&amp;lt;C-e&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will simply do &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt; 10 times. You can change the number to the number of lines you want it to scroll at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's important to note that the mapping is of the &lt;code&gt;noremap&lt;/code&gt; type. Otherwise VIm will enter an infinite loop once you press the combination.&lt;/p&gt;&#xA;" OwnerUserId="20" LastActivityDate="2016-03-25T18:11:58.340" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7043" PostTypeId="1" CreationDate="2016-03-25T20:46:46.643" Score="2" ViewCount="389" Body="&lt;p&gt;At least not on my mac. it works fine in vim. is this simply an error in nvim?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="9333" LastEditDate="2022-04-15T12:34:48.327" LastActivityDate="2024-01-05T18:07:45.990" Title="&lt;s-f10&gt; cannot be mapped in neovim" Tags="|key-bindings|neovim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7045" PostTypeId="2" ParentId="7038" CreationDate="2016-03-25T21:49:24.460" Score="2" Body="&lt;p&gt;Vim does not support Ansi escape color codes. The &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=302&quot; rel=&quot;nofollow noreferrer&quot;&gt;AnsiEsc.vim&lt;/a&gt; plugin attempts to fix this for some cases. However I doubt AnsiEsc can be combined with the quickfix list in any meaningful way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you remove the color from your maven output so you can use the quickfix functionality like &lt;code&gt;:cnext&lt;/code&gt;/&lt;code&gt;:cprev&lt;/code&gt;. Here is a &lt;a href=&quot;https://stackoverflow.com/questions/9069095/errorformat-for-maven3-in-vim&quot;&gt;simple &lt;code&gt;'errorformat'&lt;/code&gt; value&lt;/a&gt; for maven 3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set errorformat=[ERROR]\ %f:[%l\\,%v]\ %m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :make&#xA;:h 'makeprg'&#xA;:h 'errorformat'&#xA;:h errorformat&#xA;:h quickfix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-03-25T21:49:24.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7046" PostTypeId="2" ParentId="7039" CreationDate="2016-03-26T00:04:41.730" Score="7" Body="&lt;p&gt;An easy way to achieve this using no vimscript is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;o yyp^v$r A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes you want to start the mapping in normal mode (otherwise just add &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to the beginning of your insert mode mapping).&#xA;It copies the current line with &lt;code&gt;yy&lt;/code&gt;, pastes it on the line below (&lt;code&gt;p&lt;/code&gt;), selects the pasted text in visual mode (&lt;code&gt;^v$&lt;/code&gt;), replaces the selection with whitespaces (&lt;code&gt;r&lt;/code&gt; followed by a space) and jumps to the end, putting you in insert mode (&lt;code&gt;A&lt;/code&gt;). &lt;/p&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2016-03-26T00:04:41.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7047" PostTypeId="2" ParentId="7040" CreationDate="2016-03-26T01:49:25.550" Score="5" Body="&lt;p&gt;As others have noted, you can prefix both &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt; with counts, to &quot;expose&quot; that many more lines up or down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another handy quick scrolling option lets you scroll so that the current line is at the top, middle, or bottom of your screen:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;z&amp;lt;CR&amp;gt;&lt;/code&gt; - scroll so current line is at the top of your screen&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;z.&lt;/code&gt; - scroll so current line is in the middle of your screen&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;z-&lt;/code&gt; - scroll so current line is at the bottom of your screen&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I find the above three versions easiest to type, but Vim does have counterparts for each that leave your cursor in the same column you started in:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;zt&lt;/code&gt; for top&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;zb&lt;/code&gt; for bottom&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;zz&lt;/code&gt; (LOWERCASE) for middle&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help scroll-cursor&lt;/code&gt; for more.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2016-03-26T01:49:25.550" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7049" PostTypeId="2" ParentId="7038" CreationDate="2016-03-26T12:45:17.120" Score="1" Body="&lt;p&gt;My solution to have color working into vim and console is to use&#xA;&lt;a href=&quot;https://github.com/jcgay/maven-color&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jcgay/maven-color&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then set the colored log pattern into &lt;code&gt;/opt/apache-maven-3.3.9/conf/logging/log4j2.xml&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Console name=&quot;maven-color-true&quot; target=&quot;SYSTEM_OUT&quot;&amp;gt;&#xA;  &amp;lt;PatternLayout pattern=&quot;%highlight{[%p] %mavenMsg%n%rEx}{FATAL=red, ERROR=red, WAR&amp;gt;&#xA;&amp;lt;/Console&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The tips is to keep the leading &lt;code&gt;[ERROR]&lt;/code&gt; using &lt;code&gt;[%p]&lt;/code&gt; into the pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then into &lt;code&gt;maven-compiler.vim/compiler/mvn.vim&lt;/code&gt; (thanks @Peter Rincker) &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CompilerSet errorformat+=%E%.%#[ERROR]\ %f:[%l\\,%c]\ %m,%Z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or the solution is to have color for console and into vim deactivate color in &lt;code&gt;maven-compiler.vim/compiler/mvn.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CompilerSet makeprg=MAVEN_OPTS=\&quot;$MAVEN_OPTS\ -Dmaven.color=false\&quot;\ mvn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2510" LastActivityDate="2016-03-26T12:45:17.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7050" PostTypeId="1" CreationDate="2016-03-26T13:01:23.283" Score="1" ViewCount="117" Body="&lt;p&gt;I use the Alt-Latin keyboard layout (set in OSX) to write diacritics in Vim. This layout uses combinations with the Alt and Shift keys for modified letters. For example &lt;code&gt;&amp;lt;A-.&amp;gt;&lt;/code&gt; followed by a letter prints that letter with a dot below, e.g. &lt;code&gt;ḍ&lt;/code&gt;. Now, in Vim, some of these combinations are overridden, so that in &lt;code&gt;&amp;lt;A-.&amp;gt;&lt;/code&gt; prints &lt;code&gt;®&lt;/code&gt;, for example. How can I disable these key combinations in Vim to get the combinations of the layout as defined in the OS. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is a follow-up of a previous question (which I deleted) in which I wrongly assumed that this had something to do with &lt;code&gt;diagraphs&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3316" LastEditorUserId="51" LastEditDate="2016-03-26T13:49:51.463" LastActivityDate="2016-03-26T13:49:51.463" Title="Disable Alt-key combinations for non ASCII characters" Tags="|key-bindings|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7052" PostTypeId="1" AcceptedAnswerId="7053" CreationDate="2016-03-26T20:33:20.913" Score="-1" ViewCount="449" Body="&lt;p&gt;Every time I need to create a list of strings in python or another language with similar list syntax (and they more or less the same everywhere) I have to do the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# resulting expression&#xA;a = ('word1', 'word2', 'word3')&#xA;&#xA;#cursor is between the parenthesis&#xA;a = (|)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;type &lt;code&gt;'word1&amp;lt;ESC&amp;gt;a,&lt;/code&gt; etc for each word. I don't have to type single quote twice, because I'm using delimitmate, but I have to use esc to move cursor out of the quotes.&#xA;There is a better way to do it.&#xA;What if I would type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = (word1 word2 word3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead and then use regex to surround all words inside parens with quotes and add comma after that? This would save me 3 key strokes for each word if I would remap this to some key.&#xA;The problem is I don't know how to do this replacement via regex.&#xA;So the best I've got so far is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v\((.*)\)/\=substitute(submatch(0) ....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The dots in the end is because I need to replace it with backreference in substitute, but I don't know how to do that.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2016-03-27T13:58:02.313" Title="create list of strings more easily" Tags="|regular-expression|substitute|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7053" PostTypeId="2" ParentId="7052" CreationDate="2016-03-26T21:50:54.033" Score="2" Body="&lt;pre&gt;&lt;code&gt;a = ('word1', 'word2', 'word3')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Technically, that's a tuple. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, for the &lt;code&gt;substitute()&lt;/code&gt; command, it depends on what the strings can contain. If they don't contain any whitespace, you can match non-whitespace characters with &lt;code&gt;\S&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/(\zs.*\ze)/\=substitute(submatch(0), '\S\+', &quot;'&amp;amp;',&quot;, 'g')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will leave a trailing comma, which shouldn't be a problem. You could also use &lt;code&gt;\w&lt;/code&gt; for word-characters, &lt;code&gt;\i&lt;/code&gt; for characters allowed in identifiers, etc. I have modified your expression to leave out the parentheses in the matched text - they don't belong in the strings and complicating the second pattern for handling them is unnecessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, you can use a delimiting character that won't appear in the strings (think CSV), then use all-but-that-character in the &lt;code&gt;substitute()&lt;/code&gt; pattern (&lt;code&gt;,&lt;/code&gt; and &lt;code&gt;[^,]&lt;/code&gt;, for example).&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-03-26T21:50:54.033" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7054" PostTypeId="1" AcceptedAnswerId="7055" CreationDate="2016-03-26T22:22:15.120" Score="3" ViewCount="120" Body="&lt;p&gt;Sometimes when I load several buffers at once into multiple windows I might get confused with the position of the cursor,  I get lost when I change from buffer to buffer.&#xA;Therefore I'd like to trigger the ex command &lt;code&gt;:set cursorline&lt;/code&gt; to be able to easily see the cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I trigger the command when I load two or more buffers into multiple windows but remove it when there's just one window left?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One window:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/DbU22.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DbU22.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Several windows:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ShCiz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ShCiz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5081" LastEditorUserId="205" LastEditDate="2016-03-26T23:11:46.397" LastActivityDate="2016-03-27T07:17:24.870" Title="How do I set an option only if there are multiple windows?" Tags="|vim-windows|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7055" PostTypeId="2" ParentId="7054" CreationDate="2016-03-27T07:17:24.870" Score="4" Body="&lt;p&gt;Maybe you could try the following autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup cursorline&#xA;    autocmd!&#xA;    autocmd WinEnter * exe winnr('$')&amp;gt;1 ? &quot;set cursorline&quot; : &quot;set nocursorline&quot;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whenever you enter a window (&lt;code&gt;WinEnter&lt;/code&gt; event), it executes the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe winnr('$')&amp;gt;1 ? &quot;set cursorline&quot; : &quot;set nocursorline&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The latter tests if there are several windows (&lt;code&gt;winnr('$')&amp;gt;1&lt;/code&gt;). If that's the case, it enables &lt;code&gt;'cursorline'&lt;/code&gt;, otherwise it disables it.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-03-27T07:17:24.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7056" PostTypeId="1" CreationDate="2016-03-27T11:25:45.647" Score="3" ViewCount="131" Body="&lt;p&gt;I have an archive which contains encrypted text files with sensitive data. Is it safe to open them with vim/gvim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm afraid vim/gvim will leave content of the files on the drive/memory even after I close them.&lt;/p&gt;&#xA;" OwnerUserId="6542" LastEditorUserId="1841" LastEditDate="2016-03-27T13:44:40.570" LastActivityDate="2022-11-29T22:16:24.083" Title="Is it safe to open encrypted/sensitive text files from a zip archive with vim/gvim?" Tags="|linux|security|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7057" PostTypeId="2" ParentId="7052" CreationDate="2016-03-27T13:58:02.313" Score="1" Body="&lt;p&gt;You could also use a macro:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = (word1 word2 word3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Go on the &lt;code&gt;(&lt;/code&gt; character with for example &lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;(&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then record this macro: &lt;code&gt;qqwi'&amp;lt;Esc&amp;gt;ea',&amp;lt;Esc&amp;gt;q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; start recording in register &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt; go to the next word&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;i'&amp;lt;esc&amp;gt;&lt;/code&gt; insert a &lt;code&gt;'&lt;/code&gt; before the word and leave insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;e&lt;/code&gt; go to the end of the word&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a',&amp;lt;Esc&amp;gt;&lt;/code&gt; append a &lt;code&gt;',&lt;/code&gt; after the word and leave insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; stop recording the macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can then replay the macro as many time as you have words in the list: here it would be &lt;code&gt;2@q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also leave would with a trailing coma that you'll have to remove.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-03-27T13:58:02.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7058" PostTypeId="1" AcceptedAnswerId="7063" CreationDate="2016-03-27T19:25:42.977" Score="5" ViewCount="1531" Body="&lt;p&gt;I've just added this line to my &lt;code&gt;.vimrc&lt;/code&gt; to be able to open chrome without leaving vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command GoogleChromeA execute &quot;!google-chrome &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works fine however, when I use the command &lt;code&gt;source $MYVIMRC&lt;/code&gt;, I get this error: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E174: command already exists: add ! to replace it&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I fix that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;br&gt;&#xA;I've tried &lt;code&gt;command!&lt;/code&gt;. It works fine but for some reason the statusline from vim-airline changes:&lt;br&gt;&#xA;This is how it usually looks like:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/veKBv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/veKBv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how it looks like after saving (sourcing) the file:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/zjakB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zjakB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could live with it since it just happens when sourcing my &lt;code&gt;.vimrc&lt;/code&gt; but... it would be better if this could be fixed :)&lt;/p&gt;&#xA;" OwnerUserId="5081" LastEditorUserId="8120" LastEditDate="2017-01-16T16:08:40.040" LastActivityDate="2017-01-17T14:31:11.620" Title="Error when sourcing my .vimrc" Tags="|vimrc|external-command|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7059" PostTypeId="1" AcceptedAnswerId="7066" CreationDate="2016-03-27T20:10:05.723" Score="5" ViewCount="5139" Body="&lt;p&gt;When I repeatedly inserting at the beginning of a line it is problematic because the cursor ends up in the middle of the line so I have to move back to the beginning of the line each time. So, for example, if I am commenting lines then might do something like &lt;code&gt;i##_&amp;lt;ESC&amp;gt;&lt;/code&gt; to comment the line, then I have to do &lt;code&gt;j^&lt;/code&gt; to get back to the beginning of the next line before pressing dot to do a repeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to simplify this? In particular I don't like having to type the hat to get to the beginnning of the line.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2016-03-28T08:53:14.573" Title="repeat insert at beginning of line" Tags="|repeated-commands|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7060" PostTypeId="2" ParentId="7059" CreationDate="2016-03-27T20:30:51.230" Score="7" Body="&lt;p&gt;Just hit the enter key. It will take you to the start of the next line.&lt;/p&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2016-03-27T20:30:51.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7061" PostTypeId="1" AcceptedAnswerId="7062" CreationDate="2016-03-27T21:59:45.113" Score="6" ViewCount="265" Body="&lt;p&gt;I ran &lt;code&gt;:help index&lt;/code&gt; to find out about key mappings and it's great, but there's one thing I don't get. At the top it says...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This file contains a list of all commands for each mode, &lt;strong&gt;with a tag&lt;/strong&gt; and a&#xA;  short description.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Indeed, the leftmost column of information in each section is &quot;tag&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So e.g., the first thing is...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tag             char            action in Insert mode&#xA;-------------------------------------------------------------------------&#xA;i_CTRL-@        CTRL-@          insert previously inserted text and stop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the nature and purpose of the tag &lt;code&gt;i_CTRL-@&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it do something useful I should know about?&lt;/p&gt;&#xA;" OwnerUserId="6619" LastActivityDate="2016-03-27T23:16:55.843" Title="What does &quot;tag&quot; mean in the context of Vim's help window?" Tags="|help-system|tags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7062" PostTypeId="2" ParentId="7061" CreationDate="2016-03-27T23:07:17.933" Score="8" Body="&lt;p&gt;The tag is useful for two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When using the &lt;a href=&quot;http://vimhelp.appspot.com/helphelp.txt.html#%3Ahelp&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help&lt;/code&gt;&lt;/a&gt; command, the tag is the exact phrase which will let you distinguish between similar terms.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                {subject} E149 E661&#xA;:h[elp] {subject}       Like &quot;:help&quot;, additionally jump to the tag {subject}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;code&gt;&amp;lt;c-A&amp;gt;&lt;/code&gt; is available in insert, normal and command-line modes. To get to the help entry for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;insert mode, do &lt;code&gt;:h i_CTRL-A&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;normal mode, do &lt;code&gt;:h CTRL-A&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;command-line mode, do &lt;code&gt;:h c_CTRL-A&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use them for tag navigation. From &lt;a href=&quot;http://vimhelp.appspot.com/tagsrch.txt.html#tag&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h tags&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;With the &quot;:tag&quot; command the cursor will be positioned on the tag.  With the&#xA;CTRL-] command, the keyword on which the cursor is standing is used as the&#xA;tag.  If the cursor is not on a keyword, the first keyword to the right of the&#xA;cursor is used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, when on a tag, you can press &lt;a href=&quot;http://vimhelp.appspot.com/tagsrch.txt.html#CTRL-%5D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;c-]&amp;gt;&lt;/code&gt;&lt;/a&gt; to jump to where the tag is defined, which is where the full help for that entry will be present. For example, in the list you show, if you move to &lt;code&gt;i_CTRL-A&lt;/code&gt; and press &lt;code&gt;&amp;lt;c-]&amp;gt;&lt;/code&gt;, you'll &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-%40&quot; rel=&quot;nofollow noreferrer&quot;&gt;get to&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                i_CTRL-@&#xA;CTRL-@          Insert previously inserted text and stop insert.  {Vi: only&#xA;                when typed as first char, only up to 128 chars}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can press &lt;a href=&quot;http://vimhelp.appspot.com/tagsrch.txt.html#CTRL-T&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;c-T&amp;gt;&lt;/code&gt;&lt;/a&gt; to jump back to where you were.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See also: points 6 and 9 in &lt;a href=&quot;https://vi.stackexchange.com/a/2137/205&quot;&gt;this excellent answer&lt;/a&gt; about the help system.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2016-03-27T23:16:55.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7063" PostTypeId="2" ParentId="7058" CreationDate="2016-03-28T02:53:51.257" Score="7" Body="&lt;p&gt;&lt;code&gt;command&lt;/code&gt; will give an error if a command with that name already exists. Vim has no way of knowing that the command in your vimrc is actually the same command; from Vim's viewpoint it's a &quot;new&quot; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to use &lt;code&gt;command!&lt;/code&gt; to override any existing commands.  The same applies to functions; use &lt;code&gt;function!&lt;/code&gt; to override existing functions. This also works for the shorthand versions (e.g. &lt;code&gt;comm!&lt;/code&gt;, &lt;code&gt;fun!&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another caveat are autocommands. If you use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNew * some_command()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you reload your vimrc then you will have &lt;em&gt;two&lt;/em&gt; autocommands defined! Vim has no way to &quot;see&quot; that this autocommand was already executed and installed on startup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this use &lt;code&gt;augroup&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Define a new autocommand group&#xA;augroup my_autocmd_name&#xA;    &quot; Clear all existing autocommands in this group&#xA;    autocmd!&#xA;&#xA;    &quot; This will now always be installed once only&#xA;    autocmd BufNew * some_command()&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A third caveat is realizing that not all autocommands are run when you reload your vimrc. Specifically, things like &lt;code&gt;VimEnter&lt;/code&gt;, &lt;code&gt;BufReadPost&lt;/code&gt;, &lt;code&gt;Filetype&lt;/code&gt; &lt;code&gt;WinEnter&lt;/code&gt;, etc. aren't executed when you type &lt;code&gt;:source $VIMRC&lt;/code&gt;. This is especially important if you have something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Real men use real tabs&#xA;set expandtab&#xA;&#xA;&quot; Python programmers aren't real men (augroup omitted for brevity)&#xA;autocmd Filetype *.py setlocal noexpandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you now reload your vimrc while you have a buffer with a Python file, the &lt;code&gt;:set&lt;/code&gt; command will reset &lt;code&gt;expandtab&lt;/code&gt; and the &lt;code&gt;Filetype&lt;/code&gt; autocommand is never executed to override it for Python files.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As for your airline issue − I don't know. &lt;a href=&quot;https://github.com/vim-airline/vim-airline/wiki/FAQ&quot; rel=&quot;noreferrer&quot;&gt;The FAQ&lt;/a&gt; recommends running the &lt;code&gt;:AirlineRefresh&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-03-28T02:53:51.257" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7064" PostTypeId="2" ParentId="7059" CreationDate="2016-03-28T07:43:06.637" Score="5" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Use block visual mode: &lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;Ctrl+V&lt;/kbd&gt;, select the range, &lt;kbd&gt;I&lt;/kbd&gt; (capital &lt;code&gt;i&lt;/code&gt;), &lt;code&gt;##&lt;/code&gt;, &lt;kbd&gt;Esc&lt;/kbd&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;Shift+V&lt;/kbd&gt;, select extent, &lt;code&gt;:s/^/## /g&lt;/code&gt;, &lt;kbd&gt;CR&lt;/kbd&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a commenting plugin, such as &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot;&gt;Commentary&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Make a macro: &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;, insert one comment, &lt;kbd&gt;CR&lt;/kbd&gt; to next line, &lt;kbd&gt;q&lt;/kbd&gt;, then just &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; to play it, and &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt; to repeat it (or use count).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4729" LastActivityDate="2016-03-28T07:43:06.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7065" PostTypeId="1" AcceptedAnswerId="7069" CreationDate="2016-03-28T08:27:35.703" Score="7" ViewCount="697" Body="&lt;p&gt;I am reading &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#:call&quot;&gt;&lt;code&gt;:help :call&lt;/code&gt;&lt;/a&gt;, which states the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Call a function. The name of the function and its arguments are as&#xA;  specified with &lt;code&gt;:function&lt;/code&gt;. Up to 20 arguments can be used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This makes me wondering: why is there a seemingly artificial limit on the number of function arguments?&lt;/p&gt;&#xA;" OwnerUserId="6894" LastEditorUserId="1841" LastEditDate="2016-03-28T09:13:06.143" LastActivityDate="2016-03-28T14:21:06.470" Title="Why is there a limit on the number of function arguments?" Tags="|vimscript|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7066" PostTypeId="2" ParentId="7059" CreationDate="2016-03-28T08:51:40.893" Score="12" Body="&lt;p&gt;Just use uppercase &lt;code&gt;I&lt;/code&gt; instead of lowercase &lt;code&gt;i&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;a&lt;/code&gt; Insert mode commands have uppercase versions &lt;code&gt;I&lt;/code&gt; (insert at beginning of line) and &lt;code&gt;A&lt;/code&gt; (append at end of line)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if you use &lt;code&gt;I##&amp;lt;Esc&amp;gt;&lt;/code&gt;, you can use &lt;code&gt;.&lt;/code&gt; to repeat on any other line, irrespective of where the cursor is&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to comment bunch of lines that are together, use visual mode as suggested by Amadan&lt;/p&gt;&#xA;" OwnerUserId="1616" LastActivityDate="2016-03-28T08:51:40.893" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7067" PostTypeId="2" ParentId="7059" CreationDate="2016-03-28T08:53:14.573" Score="3" Body="&lt;p&gt;&lt;kbd&gt;i&lt;/kbd&gt; inserts before the cursor.&#xA;If the cursor is in column 1, then &lt;em&gt;before the cursor&lt;/em&gt; also happens to be &lt;em&gt;at beginning of line&lt;/em&gt;, but this is accidental.&#xA;Repeating a change that begins with &lt;kbd&gt;i&lt;/kbd&gt; will always insert before the cursor, but not always at the beginning of line.&#xA;For repeated changes to insert at beginning of line you must make &quot;beginning of line&quot; part of the change that is repeated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;I&lt;/kbd&gt; inserts at the beginning of a line.&#xA;The command &lt;code&gt;I##_&amp;lt;Esc&amp;gt;&lt;/code&gt; inserts &quot;##_&quot; at beginning of line, not before the cursor.&#xA;(If the cursor is in column 1, then &lt;em&gt;beginning of line&lt;/em&gt; also happens to be &lt;em&gt;before the cursor&lt;/em&gt;, but this is accidental.)&#xA;This change can be repeated with &lt;kbd&gt;.&lt;/kbd&gt; and will always insert at beginning of line.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2016-03-28T08:53:14.573" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7068" PostTypeId="1" CreationDate="2016-03-28T13:19:50.057" Score="1" ViewCount="29" Body="&lt;p&gt;I would like to be able to yank and paste text from and to X clipboard (webbrowser, email client etc), is there an easy way to fuse the registers to have a single clipboard ?&lt;/p&gt;&#xA;" OwnerUserId="7005" LastActivityDate="2016-03-28T13:19:50.057" Title="How to get vim to use the same register as X?" Tags="|cut-copy-paste|" AnswerCount="0" CommentCount="2" ClosedDate="2016-03-28T13:37:07.263" ContentLicense="CC BY-SA 3.0" />
  <row Id="7069" PostTypeId="2" ParentId="7065" CreationDate="2016-03-28T14:21:06.470" Score="13" Body="&lt;p&gt;Because this is the size of the data structures used to store function arguments. From &lt;code&gt;eval.c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MAX_FUNC_ARGS   20      /* maximum number of function arguments */&#xA;&#xA;/* structure to hold info for a function that is currently being executed. */&#xA;typedef struct funccall_S funccall_T;&#xA;&#xA;struct funccall_S&#xA;{&#xA;[..]&#xA;    listitem_T  l_listitems[MAX_FUNC_ARGS];     /* listitems for a:000 */&#xA;[..]&#xA;};&#xA;&#xA;[..]&#xA;&#xA;/*&#xA; * Allocate a variable for the result of a function.&#xA; * Return OK or FAIL.&#xA; */&#xA;    static int&#xA;get_func_tv(&#xA;)&#xA;{&#xA;    typval_T    argvars[MAX_FUNC_ARGS + 1];     /* vars for arguments */&#xA;&#xA;[..]&#xA;&#xA;    /*&#xA;     * Get the arguments.&#xA;     */&#xA;    argp = *arg;&#xA;    while (argcount &amp;lt; MAX_FUNC_ARGS - (partial == NULL ? 0 : partial-&amp;gt;pt_argc))&#xA;    {&#xA;[..]&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well, and so forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could this be made dynamic to allow an arbitrary amount of arguments? Sure. But why?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! TooManyForSanity(one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, twentyone)&#xA;    echo &quot;Well...&quot;&#xA;endfun&#xA;&#xA;call TooManyForSanity('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'OH MY GOD IT NEVER ENDS')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the sort of code that makes programmers go mad and murder innocent bunnies in their sleep.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-03-28T14:21:06.470" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7070" PostTypeId="1" CreationDate="2016-03-28T14:30:24.747" Score="3" ViewCount="79" Body="&lt;p&gt;While using &lt;code&gt;git&lt;/code&gt; and other versioning systems, it is very useful that text lines occupy no more than (say) 80 characters. It is also more comfortable to edit text with &lt;code&gt;vi&lt;/code&gt; if lines are note excessively long. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like to write my text so that each sentence begins in a new line, e.g., &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The design of a programming language is a delicate art of balancing &#xA;  between conflicting trade-offs. &#xA;On the one hand, to make the language appealing, the language &#xA;  designer would like to equip future programmers with a variety &#xA;  of powerful and useful abstractions. &#xA;On the other hand, the folk-lore of language design is that any &#xA;  feature added to a language collects its tolls. &#xA;Such tolls may result in reduced elegance of the design,&#xA;  a steeper language learning curve, &#xA;  and complication of the construction of language processing tools.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My co-author, who uses &lt;code&gt;TeXMaker&lt;/code&gt; favors the convention of one line per paragraph. The above would look like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The design of a programming language is a delicate art of balancing    between conflicting trade-offs.  On the one hand, to make the language appealing, the language designer would like to equip future programmers with a variety of powerful and useful abstractions.  On the other hand, the folk-lore of language design is that any feature added to a language collects its tolls.  Such tolls may result in reduced elegance of the design, a steeper language learning curve, and complication of the construction of language processing tools.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What are the prospects of an attempt to implement a script to convert back and through the two conventions automatically? The main difficulty, so I believe is to identify periods, or other punctuations that end sentences. Dealing with parenthesized sentences etc. Ignoring the most frequent &lt;code&gt;LaTeX&lt;/code&gt; macros would also be handy.&lt;/p&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="4505" LastEditDate="2016-03-28T19:39:59.523" LastActivityDate="2016-03-29T07:08:29.533" Title="Switching back and forth between two text layout conventions of input to LaTeX" Tags="|formatting|filetype-tex|plugin-vim-latex|plugin-vimtex|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7072" PostTypeId="1" AcceptedAnswerId="7073" CreationDate="2016-03-28T23:21:39.987" Score="4" ViewCount="316" Body="&lt;p&gt;I've the following sample content which I want to edit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;table&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td title=&quot;Title 1&quot;&amp;gt;col1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;col2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;col3&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td title=&quot;Title 2&quot;&amp;gt;col1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;col2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;col3&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td title=&quot;Title 3&quot;&amp;gt;col1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;col2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;col3&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;/table&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: It doesn't matter it's HTML, that kind of operation can apply to any format, so I'm not interested in HTML parsers.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where I'd like to copy all values of &lt;code&gt;title&lt;/code&gt; into separate column, so the expected result is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;table&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td title=&quot;Title 1&quot;&amp;gt;col1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;col2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;col3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Title 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td title=&quot;Title 2&quot;&amp;gt;col1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;col2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;col3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Title 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td title=&quot;Title 3&quot;&amp;gt;col1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;col2&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;col3&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Title 3&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;/table&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My plan is to find all &lt;code&gt;td title&lt;/code&gt; using global command (&lt;code&gt;g&lt;/code&gt;) and execute normal commands:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Copy quoted text (&lt;code&gt;f&quot;lyt&quot;&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Find &lt;code&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;/code&gt; (&lt;code&gt;/&amp;lt;.td&amp;gt;&amp;lt;.tr&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;?).&lt;/li&gt;&#xA;&lt;li&gt;Append &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; (&lt;code&gt;a&amp;lt;div&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;?)&lt;/li&gt;&#xA;&lt;li&gt;Paste yanked text (&lt;code&gt;p&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Append &lt;code&gt;&amp;lt;/div&amp;gt;&lt;/code&gt; (&lt;code&gt;a&amp;lt;/div&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;?)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But I don't know how to simulate presses of &lt;kbd&gt;Enter&lt;/kbd&gt; and &lt;kbd&gt;Escape&lt;/kbd&gt; after search or text appending.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/td title/norm f&quot;lyt&quot;/&amp;lt;.td&amp;gt;&amp;lt;.tr&amp;gt;&amp;lt;CR&amp;gt;f&amp;gt;a&amp;lt;td&amp;gt;&amp;lt;Esc&amp;gt;pa&amp;lt;/td&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it doesn't work, because &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; aren't recognised as keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although it works when I insert these keystrokes manually while typing the command by using &lt;kbd&gt;Control&lt;/kbd&gt;-&lt;kbd&gt;V&lt;/kbd&gt;, then &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;Enter&lt;/kbd&gt; (&lt;code&gt;^M&lt;/code&gt;) or &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;Escape&lt;/kbd&gt; (&lt;code&gt;^[&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any alternative method where I can insert those keystrokes without using &lt;kbd&gt;Control&lt;/kbd&gt;-&lt;kbd&gt;V&lt;/kbd&gt;?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2016-03-29T16:27:47.913" LastActivityDate="2016-03-29T16:27:47.913" Title="How to simulate Return and Escape for global command without using Control-V?" Tags="|command-line|normal-mode|global-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7073" PostTypeId="2" ParentId="7072" CreationDate="2016-03-29T00:06:16.500" Score="4" Body="&lt;p&gt;&lt;code&gt;exec&lt;/code&gt; the &lt;code&gt;norm&lt;/code&gt; command. From &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3Anorm&quot;&gt;&lt;code&gt;:h :norm&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;An alternative is to use :execute, which uses an&#xA;expression as argument.  This allows the use of&#xA;printable characters to represent special characters.&#xA;&#xA;Example: &#xA;        :exe &quot;normal \&amp;lt;c-w&amp;gt;\&amp;lt;c-w&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the usage of double quotes &lt;em&gt;and&lt;/em&gt; the &lt;code&gt;\&lt;/code&gt; before &lt;code&gt;&amp;lt;&lt;/code&gt; for the special characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your example would translate to something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/td title/ exec 'norm f&quot;lyt&quot;/&amp;lt;.td&amp;gt;&amp;lt;.tr&amp;gt;' . &quot;\&amp;lt;CR&amp;gt;f&amp;gt;a&amp;lt;td&amp;gt;\&amp;lt;Esc&amp;gt;pa&amp;lt;/td&amp;gt;\&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, I have used single quotes for the initial part of the command, both because it has &lt;code&gt;&quot;&lt;/code&gt; inside, and because single quotes give you a literal string without interpretation. Then, double-quoted strings where you need &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to be interpreted.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="51" LastEditDate="2016-03-29T00:15:21.247" LastActivityDate="2016-03-29T00:15:21.247" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7074" PostTypeId="1" CreationDate="2016-03-29T05:29:12.807" Score="6" ViewCount="211" Body="&lt;p&gt;I used many macros assigned to registers, for instance I have this line in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @p='^[O&amp;lt;/p&amp;gt;^[0jj'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just type &lt;code&gt;@p&lt;/code&gt; and it closes the tag, very convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PROBLEM&lt;/strong&gt;: On my new keyboard &lt;code&gt;@&lt;/code&gt; (at-mark) is too far away.&lt;br&gt;&#xA;&lt;strong&gt;QUESTION&lt;/strong&gt;: Can I change it to another key? &lt;code&gt;;&lt;/code&gt; would be convenient.&lt;/p&gt;&#xA;" OwnerUserId="1083" LastActivityDate="2016-03-29T07:41:00.497" Title="Swap register key from @ to another more accessible key" Tags="|key-bindings|macro|register|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7075" PostTypeId="2" ParentId="7074" CreationDate="2016-03-29T05:29:12.807" Score="4" Body="&lt;p&gt;Add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap ; @&#xA;:noremap @ ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first line maps the &lt;code&gt;;&lt;/code&gt; key to the register feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second line maps the &lt;code&gt;@&lt;/code&gt; key to whatever feature was assigned to the &lt;code&gt;;&lt;/code&gt; key, just in case you need it. It is optional.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;noremap&lt;/code&gt; creates a &lt;strong&gt;no&lt;/strong&gt;n-&lt;strong&gt;re&lt;/strong&gt;cursive &lt;strong&gt;map&lt;/strong&gt;ping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Thanks to Carpetsmoker for the tip!&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="1083" LastEditorUserId="1083" LastEditDate="2016-03-29T05:37:42.130" LastActivityDate="2016-03-29T05:37:42.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7076" PostTypeId="2" ParentId="7070" CreationDate="2016-03-29T07:08:29.533" Score="3" Body="&lt;p&gt;This is a question that is difficult to write a very rigorous answer to. But I find it easy to state that the prospects are not quite good. At least not if you try to include the corner cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you say, you must identify periods and punctuations, but you should also parse many macros, such as &lt;code&gt;\emph{...}&lt;/code&gt;, and you should parse stuff like &lt;code&gt;some text {\macro more text} here&lt;/code&gt;. You must also allow inline math (&lt;code&gt;$...$&lt;/code&gt; or &lt;code&gt;\(...\)&lt;/code&gt;), and you must deal with equations that are &quot;part of&quot; the sentence, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Consider $f$, where&#xA;\begin{equation}&#xA;f(x) = 1,&#xA;\end{equation}&#xA;and so on.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, my point is that your script should in generally handle a lot of rather complicated stuff. I've written a lot of code for parsing LaTeX while working with &lt;a href=&quot;https://travis-ci.org/lervag/vimtex&quot; rel=&quot;nofollow&quot;&gt;vimtex&lt;/a&gt;, and my experience is that this problem is very non-trivial. To be more specific, I've written a custom &lt;code&gt;formatexpr&lt;/code&gt;, see &lt;code&gt;autoload/vimtex/format.vim&lt;/code&gt; in the vimtex repo. This &lt;code&gt;formatexpr&lt;/code&gt; allows one to format LaTeX paragraphs with &lt;code&gt;gq&lt;/code&gt;. Without this, Vim would include equations and similar environments, and so the paragraphs become &quot;garbled&quot;. My point is that even though the function is quite simple, I found it quite difficult to write. And the current version only handles the case where text is hardwrapped at a given column number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that said, I also want to point out that I don't think this is impossible either. Just difficult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, my suggestion is therefore instead to agree with your student on a single convention. And I think one line per sentence is the smarter choice, since it makes it more convenient to view diffs.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-03-29T07:08:29.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7077" PostTypeId="2" ParentId="7074" CreationDate="2016-03-29T07:41:00.497" Score="2" Body="&lt;p&gt;On azerty keyboards &lt;code&gt;@&lt;/code&gt; is on the same key as &lt;code&gt;à&lt;/code&gt; but it is less convenient to use since you have to press &lt;kbd&gt;Alt Gr&lt;/kbd&gt; to get it. As &lt;code&gt;à&lt;/code&gt; is not really useful in Vim I used &lt;code&gt;langmap&lt;/code&gt; to switch the key only in normal mode (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27langmap%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 'langmap'&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set langmap+=à@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can use &lt;kbd&gt;àp&lt;/kbd&gt; to execute the macro in the register &lt;code&gt;p&lt;/code&gt;. And the insert mode still works the same.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-03-29T07:41:00.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7079" PostTypeId="2" ParentId="7056" CreationDate="2016-03-29T12:21:50.823" Score="3" Body="&lt;p&gt;No. You should disable swap file and unset viminfo.&lt;br /&gt;&#xA;Also the memory contents is not encrypted.&lt;/p&gt;&#xA;&lt;p&gt;More info &lt;a href=&quot;http://vim.wikia.com/wiki/Encryption&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6915" LastEditorUserId="23502" LastEditDate="2022-11-29T22:16:24.083" LastActivityDate="2022-11-29T22:16:24.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7081" PostTypeId="1" AcceptedAnswerId="7082" CreationDate="2016-03-29T15:26:43.107" Score="13" ViewCount="770" Body="&lt;p&gt;I use gvim on windows very frequently. I have in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set confirm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this opens a little dialog box, so I have to use my mouse to quit. In command line vim, I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:q&#xA;Save changes to &quot;Untitled&quot;?&#xA;[Y]es, (N)o, (C)ancel:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there anyway I can configure gvim to behave this way?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="1841" LastEditDate="2016-03-30T13:30:44.017" LastActivityDate="2016-03-30T13:30:44.017" Title="Can I make gvim not use graphical dialog box for ':set confirm'?" Tags="|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7082" PostTypeId="2" ParentId="7081" CreationDate="2016-03-29T15:36:33.103" Score="11" Body="&lt;p&gt;That's a good question actually: I had never thought of this before but I added this setting now that I searched for it :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/gui_w32.html#gui-w32-dialogs&quot;&gt;&lt;code&gt;:h gui-w32-dialogs&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;6.1 Dialogs&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The dialogs displayed by the &quot;confirm&quot; family (i.e. the 'confirm' option,&#xA;  &lt;code&gt;:confirm&lt;/code&gt; command and &lt;code&gt;confirm()&lt;/code&gt; function) are GUI-based rather than the&#xA;  console-based ones used by other versions.  The 'c' flag in 'guioptions'&#xA;  changes this.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So using this in your &lt;code&gt;.vimrc&lt;/code&gt; will do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guioptions+=c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-03-29T15:43:00.110" LastActivityDate="2016-03-29T15:43:00.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7083" PostTypeId="1" CreationDate="2016-03-29T15:39:30.283" Score="3" ViewCount="410" Body="&lt;p&gt;&lt;em&gt;I would like to:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;First, save the current highlight state (nohlsearch? or hlsearch?).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;...the current cursor position and the current search pattern.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then search for the trailing spaces, highlighting those and also&#xA;be able to move around them.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Once done, turn OFF the trailing space highlighting and revert back&#xA;to whatever the highlight state was (same search pattern, same&#xA;highlighted characters).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;For example:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's search for the word &quot;line&quot; by typing &lt;code&gt;/line&lt;/code&gt; in the command line. The word &lt;strong&gt;line&lt;/strong&gt; lights up across the document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I would like to run &lt;code&gt;ShowWhiteSpace('ON')&lt;/code&gt; so now the word(s) &quot;line&quot; are no longer highlighted, but the trailing spaces are. By pressing &lt;code&gt;N&lt;/code&gt; or &lt;code&gt;n&lt;/code&gt; I can move around the trailing space sections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally I would like to run &lt;code&gt;ShowWhiteSpace('OFF')&lt;/code&gt; so now the trailing spaces are no longer highlighted and we are back at where we have started with the word(s) &lt;strong&gt;line&lt;/strong&gt; highlighted and our cursor at it's original position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;What I have so far:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I know that I can save the current search pattern and restore it through the &lt;code&gt;@/&lt;/code&gt; variable.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I also know how to store the cursor position so I can restore it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The problems start when I attempt to track the &lt;code&gt;hlsearch&lt;/code&gt; state. &lt;code&gt;echo &amp;amp;hlsearch&lt;/code&gt; would return &lt;code&gt;0&lt;/code&gt; if the current &lt;strong&gt;hl&lt;/strong&gt; state is set using the &lt;code&gt;:set nohlsearch&lt;/code&gt; command or &lt;code&gt;1&lt;/code&gt; if the &lt;code&gt;:set hlsearch&lt;/code&gt; command is used. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in cases where &lt;code&gt;:nohl&lt;/code&gt; is used, there is no way to know if there was a highlighted situation prior to executing the &lt;code&gt;ShowWhiteSpace('ON')&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possible solution is to give up trying to store and restore the &lt;code&gt;hlsearch&lt;/code&gt; state all together and simply restore the search pattern. Which works, however, once the trailing spaces are lit-up and &lt;code&gt;N&lt;/code&gt; or &lt;code&gt;n&lt;/code&gt; is used to move around them, the &lt;code&gt;hlsearch&lt;/code&gt; seems to be OFF once we restore the search pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any clean methods to handle a slightly more complex &lt;code&gt;TrailingSpace&lt;/code&gt; scenario?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;P.S: I know that I can use &lt;code&gt;match ExtraWhitespace /\s\+$/&lt;/code&gt; and a syntax highlighting, however, that would not give me the option to move around the highlighted trailing space regions.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="5328" LastEditDate="2016-03-29T21:05:51.113" LastActivityDate="2016-03-30T14:50:19.683" Title="How to restore a search highlight state after searching for trailing space?" Tags="|vimscript|highlight|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="7084" PostTypeId="2" ParentId="7083" CreationDate="2016-03-29T21:03:30.210" Score="2" Body="&lt;p&gt;The comments posted below the question and the function that I am adding at the end of this post should be enough as an answer to the topic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am adding my initial function below, as the answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleTrailingSpace()&#xA;    &quot; Initialize variables.&#xA;    if !exists('g:storedSearchPattern')&#xA;        let g:storedSearchPattern = &quot;&quot;&#xA;    endif&#xA;    if !exists('g:storedHlsearchState')&#xA;        let g:storedHlsearchState = 0&#xA;    endif&#xA;    if !exists('g:isTrailingSpaceActive')&#xA;        let g:isTrailingSpaceActive = 0&#xA;    endif&#xA;    if !exists('g:storedCursorPosition')&#xA;        let g:isTrailingSpaceActive = 0&#xA;    endif&#xA;    &quot; Debug.&#xA;    let l:hl_state = v:hlsearch ? 'TRUE' : 'FALSE'&#xA;    echom 'Current hlsearch state: [' . l:hl_state . ']'&#xA;    if !g:isTrailingSpaceActive&#xA;        &quot; Debug&#xA;        echom 'Highlight trailing space: [ON]'&#xA;        &quot; Store current states.&#xA;        let g:storedHlsearchState = v:hlsearch&#xA;        let g:storedSearchPattern = @/&#xA;        let g:storedCursorPosition = getpos('.')&#xA;        &quot;Debug.&#xA;        echom 'Stored search pattern: ['. g:storedSearchPattern . ']'&#xA;        echom 'Stored hlsearch state: [' . g:storedHlsearchState. ']'&#xA;        echom 'Stored position: ' . string(g:storedCursorPosition) . ']'&#xA;        &quot; Override the search pattern.&#xA;        let @/='\v(\s+$)|( +\ze\t)'&#xA;        &quot; Override the hlsearch state&#xA;        let &amp;amp;hlsearch=1&#xA;        &quot; Activate the syntax for the trailing space pattern.&#xA;        exe 'match ErrorMsg /\s\+$/'&#xA;        &quot; Update toggle controller.&#xA;        let g:isTrailingSpaceActive = 1&#xA;    else&#xA;        echom 'Highlight trailing space: [OFF]'&#xA;        &quot; Debug&#xA;        echom 'Restore the search pattern to: ['. g:storedSearchPattern . ']'&#xA;        echom 'Restore the hlsearch state to: [' . g:storedHlsearchState. ']'&#xA;        echom 'Restore the position to: ' . string(g:storedCursorPosition) . ']'&#xA;        &quot; Restore&#xA;        let @/=g:storedSearchPattern&#xA;        let &amp;amp;hlsearch=g:storedHlsearchState&#xA;        call setpos('.', g:storedCursorPosition)&#xA;        &quot; Activate the syntax for the trailing space pattern.&#xA;        exe &quot;match ErrorMsg '' | syn clear ErrorMsg&quot;&#xA;        &quot; Update toggle controller.&#xA;        let g:isTrailingSpaceActive = 0&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5328" LastActivityDate="2016-03-29T21:03:30.210" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7085" PostTypeId="1" AcceptedAnswerId="7087" CreationDate="2016-03-30T01:36:18.747" Score="5" ViewCount="456" Body="&lt;p&gt;Would you provide a key mapping for insert mode which could make letters between start of current word to current cursor uppercase?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;For string &lt;code&gt;abcd efgh&lt;/code&gt;, and now cursor is flickering at the end&#xA;following &lt;code&gt;h&lt;/code&gt;, then I could get &lt;code&gt;abcd EFGH&lt;/code&gt;.&lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;For string &lt;code&gt;abcd efgh&lt;/code&gt;, and now cursor is flickering on &lt;code&gt;g&lt;/code&gt;, then I&#xA;could get &lt;code&gt;abcd EFgh&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Please note, I know &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gU&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map! &amp;lt;C-F&amp;gt; &amp;lt;Esc&amp;gt;gUiw`]a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it cannot meet my second example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;&lt;strong&gt;Updated on GMT 2016/3/30, 2:26:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to comment from Carpetsmoker and as I tried, &lt;code&gt;gUb&lt;/code&gt; could meet my second example but not the first, while &lt;code&gt;gUiw&lt;/code&gt; could meet my first example but not the second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So would anyone help to implement necessary function or logic? Thus could meet my requirement completely. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or any other solution is also appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;&lt;strong&gt;Updated on GMT 2016/3/30, 3:19:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, there are two solutions, one is from muru and the other is from myself. Both works as I tried and are acceptable to me. I mark muru one as the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;&lt;strong&gt;Updated on GMT 2016/3/31, 23:19:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With comments from tommcdo and VanLaser, I updated my solution, and to me it's the current best one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Updated on GMT 2016/10/20, 14:25:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the solution of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-f&amp;gt; gUvb`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just found a bug. For example, in normal mode, we have &lt;code&gt;asdf qwer&lt;/code&gt;, and cursor is flicking on &lt;code&gt;q&lt;/code&gt; when we press &lt;code&gt;Ctrl-f&lt;/code&gt;, we will get &lt;code&gt;ASDF Qwer&lt;/code&gt;, rather than expected &lt;code&gt;asdf Qwer&lt;/code&gt;. So current best solution is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-f&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt;gUb&amp;lt;ESC&amp;gt;`]a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-f&amp;gt; a&amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt;gUb&amp;lt;ESC&amp;gt;`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6267" LastEditorUserId="6267" LastEditDate="2016-10-20T06:43:06.327" LastActivityDate="2018-01-03T13:21:08.613" Title="How to make letters between start of word and current cursor uppercase?" Tags="|key-bindings|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7086" PostTypeId="2" ParentId="7085" CreationDate="2016-03-30T03:04:55.983" Score="5" Body="&lt;p&gt;Thanks to the hint of &lt;code&gt;gUb&lt;/code&gt; from Carpetsmoker, I think out one solution as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-u&amp;gt; &amp;lt;ESC&amp;gt;gUlgUb`]la&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;gUl&lt;/code&gt; makes the current letter uppercase&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gUb&lt;/code&gt; makes the letters from word beginning to current letter uppercase&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`]&lt;/code&gt; moves cursor to the end of modification by &lt;code&gt;gUb&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;l&lt;/code&gt; to move cursor right by on letter&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&lt;/code&gt; to get back to insert mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;&lt;strong&gt;Updated on GMT 2016/3/31, 23:19:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With below comments from tommcdo and VanLaser, here provide a updated solution, which is &lt;strong&gt;simpler than my above one, and the best solution currently&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-f&amp;gt; &amp;lt;ESC&amp;gt;gUvbgi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;gUvb&lt;/code&gt; makes the letters from word beginning to current letter(including the current letter with cursor flicking on) uppercase. Backwards motions often omit the character the cursor appears to be on, and putting v between the operator and motion fixes that in most cases&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gi&lt;/code&gt; move cursor back to last insert position as insert mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6267" LastEditorUserId="6267" LastEditDate="2016-04-01T03:36:30.660" LastActivityDate="2016-04-01T03:36:30.660" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7087" PostTypeId="2" ParentId="7085" CreationDate="2016-03-30T03:06:03.613" Score="6" Body="&lt;p&gt;If you use &lt;code&gt;&amp;lt;Esc&amp;gt;…a&lt;/code&gt;, the cursor will move to the character before the cursor after &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. Use &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-O&quot;&gt;&lt;code&gt;&amp;lt;c-\&amp;gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-O          execute one command, return to Insert mode   i_CTRL-O&#xA;CTRL-\ CTRL-O   like CTRL-O but don't move the cursor        i_CTRL-\_CTRL-O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-F&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt;gUb&amp;lt;Esc&amp;gt;`]a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;Esc&amp;gt;…a&lt;/code&gt; is still needed to get the cursor back where it was.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-03-30T03:06:03.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7088" PostTypeId="1" AcceptedAnswerId="7090" CreationDate="2016-03-30T14:02:29.027" Score="2" ViewCount="236" Body="&lt;p&gt;I want to view a big blob of text (ascii-graphics), but when I use &lt;code&gt;:set nowrap&lt;/code&gt; some &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; symbols appears at the left and right borders of the buffer window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are kinda annoying and I want to use maximum of available width. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can hide them?&lt;/p&gt;&#xA;" OwnerUserId="7032" LastEditorUserId="1841" LastEditDate="2016-03-30T14:11:31.670" LastActivityDate="2016-03-30T16:04:49.160" Title="How to disable extends/precedes charaters in nowrap" Tags="|wrapping|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7089" PostTypeId="2" ParentId="7083" CreationDate="2016-03-30T14:50:19.683" Score="2" Body="&lt;p&gt;An alternative to use a custom function is to use Vim built functionality:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;First, save the current highlight state (nohlsearch? or hlsearch?).&lt;/li&gt;&#xA;  &lt;li&gt;...the current cursor position and the current search pattern.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Vim saves the current search pattern; you could navigate through your previous searches (similar to navigating to your previous commands on Vim or a shell). That could be achieved with the arrow keys up/down, &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;n&lt;/kbd&gt;/&lt;kbd&gt;p&lt;/kbd&gt; or &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use a mark (see &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#mark-motions&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help mark-motions&lt;/code&gt;&lt;/a&gt;) to remember the current position (e.g.: &lt;code&gt;mz&lt;/code&gt;) and them jump back to it later (&lt;code&gt;'z&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;3&quot;&gt;&#xA;  &lt;li&gt;Then search for the trailing spaces, highlighting those and also be able to move around them.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could use a simple mapping to make it easier than type the regex and set the highlight option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F3&amp;gt; :let @/='\v(\s+$)&amp;lt;bar&amp;gt;( +\ze\t)' &amp;lt;bar&amp;gt; set hlsearch&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;4&quot;&gt;&#xA;  &lt;li&gt;Once done, turn OFF the trailing space highlighting and revert back to whatever the highlight state was (same search pattern, same&#xA;  highlighted characters).&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could retrieve your previous search easily, as explained above. You could also toggle the &lt;code&gt;'hlsearch'&lt;/code&gt; using the mapping &lt;code&gt;coh&lt;/code&gt;, which is provided by the &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow&quot;&gt;plugin unimpaired&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This approach has the advantage that you don't have to change your workflow to remember or wait until you finished handling the trailing spaces before making other searches.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-03-30T14:50:19.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7090" PostTypeId="2" ParentId="7088" CreationDate="2016-03-30T16:04:49.160" Score="2" Body="&lt;p&gt;The command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set listchars-=extends:&amp;gt;,precedes:&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will &quot;hide&quot; them by removing them from the 'listchars' list. You can also change their value by modifying the string after the colon(:). (Colon and comma are forbidden.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way &lt;code&gt;:set-=&lt;/code&gt; works you need to pass the exact values to remove them, so it might be a good idea to check the values with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set listchars?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;before you remove them.&lt;/p&gt;&#xA;" OwnerUserId="20" LastActivityDate="2016-03-30T16:04:49.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7091" PostTypeId="1" CreationDate="2016-03-30T16:18:00.850" Score="1" ViewCount="59" Body="&lt;p&gt;I have an Autohotkey script to write Esperanto characters. It has the form&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AppsKey &amp;amp; G::&#xA;    if GetKeyState(&quot;Shift&quot;, &quot;P&quot;)&#xA;        send Ĝ&#xA;&#xA;    else&#xA;    send ĝ&#xA;return&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notepad has no problem with opening it in a way that shows both &lt;code&gt;Ĝ&lt;/code&gt; and &lt;code&gt;ĝ&lt;/code&gt;. On the other hand Vim can't display them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading &lt;a href=&quot;https://stackoverflow.com/questions/5166652/how-to-view-utf-8-characters-in-vim-or-gvim&quot;&gt;https://stackoverflow.com/questions/5166652/how-to-view-utf-8-characters-in-vim-or-gvim&lt;/a&gt;&#xA;I added to my _vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set enc=utf-8&#xA;set fileencoding=utf-8&#xA;set fileencodings=ucs-bom,utf8,prc&#xA;set guifont=Monaco:h11&#xA;set guifontwide=NSimsun:h12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim still doesn't display the character correctly. What do I have to do to get Vim to open the file properly?&lt;/p&gt;&#xA;" OwnerUserId="5469" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-03-30T16:18:00.850" Title="Open file with Esperanto characters `Ĝ` and `ĝ` in gVim" Tags="|unicode|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7092" PostTypeId="1" CreationDate="2016-03-30T17:08:42.567" Score="2" ViewCount="360" Body="&lt;p&gt;I run gVim7.4 on Windows 7 with the English International keyboard layout. The keyboard layout works in a way so that pressing `  + &lt;code&gt;i&lt;/code&gt; gives you &lt;code&gt;ì&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim insert mode that's the desired behavior. However it isn't in command mode where I effectively have to press ` + &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; + &lt;code&gt;i&lt;/code&gt; to go to the mark 'i'. I observed similar behavior for the caret &lt;code&gt;^&lt;/code&gt; key. Pressing it makes vim wait for a vowel to be able to render &lt;code&gt;â&lt;/code&gt;, &lt;code&gt;î&lt;/code&gt; etc instead of directly going to be beginning of the line. It only goes there when I press &lt;code&gt;^&lt;/code&gt; + &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In insert mode it's useful to be able to type &lt;code&gt;â&lt;/code&gt;. It isn't in command mode and there it's completely useless to wait for another character. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get better behavior by editing the vimrc or writing a autohotkey script? Is there a way to make vim behave in command mode that still allows me to u?&lt;/p&gt;&#xA;" OwnerUserId="5469" LastEditorUserId="5469" LastEditDate="2016-03-31T09:51:28.973" LastActivityDate="2019-09-15T10:09:25.453" Title="Making gVim behave with the English International keyboard layout" Tags="|keyboard-layout|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7093" PostTypeId="2" ParentId="7092" CreationDate="2016-03-30T18:06:45.647" Score="1" Body="&lt;p&gt;There is no easy way to avoid the &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt;; that is why I use single quote instead, &lt;kbd&gt;'&lt;/kbd&gt; + &lt;kbd&gt;i&lt;/kbd&gt;, which is similar enough for me (doesn't move to the column, but to the beginning of the line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also consider using another mark related movements, such as ]' and `].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find that you use &lt;kbd&gt;`&lt;/kbd&gt; + &lt;kbd&gt;i&lt;/kbd&gt; more often than &lt;kbd&gt;'&lt;/kbd&gt; + &lt;kbd&gt;i&lt;/kbd&gt; you could use a set of mappings to switch them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap 'a `a&#xA;nnoremap `a 'a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(possibly using a loop similar to the one in &lt;a href=&quot;https://github.com/tpope/vim-capslock/blob/master/plugin/capslock.vim#L21&quot; rel=&quot;nofollow&quot;&gt;the capslock plugin&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could switch just ]' and `] and its counterparts (8 mappings instead of 52), directly or through some plugin such as &lt;a href=&quot;https://github.com/kshenoy/vim-signature&quot; rel=&quot;nofollow&quot;&gt;signature&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-03-30T18:06:45.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7094" PostTypeId="1" CreationDate="2016-03-30T18:57:42.803" Score="2" ViewCount="1484" Body="&lt;p&gt;I have an ugly orange triangle appearing in the airline bar in my nvim regardless of the theme I use. Take a look at that : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/a655o.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/a655o.png&quot; alt=&quot;Look at the right side on the airline bar&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shocking, isn't it ? Now do you have an idea on how to correct this ?&lt;/p&gt;&#xA;" OwnerUserId="7005" LastEditorUserId="51" LastEditDate="2016-03-30T19:57:19.423" LastActivityDate="2016-09-22T08:14:00.533" Title="Ugly orange triangle in the airline theme using nvim" Tags="|neovim|plugin-airline|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7095" PostTypeId="1" AcceptedAnswerId="7096" CreationDate="2016-03-30T19:05:07.400" Score="3" ViewCount="112" Body="&lt;p&gt;If i'm editing a file, such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/src/test/service.spec.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to echo &lt;code&gt;service&lt;/code&gt; using &lt;code&gt;expand&lt;/code&gt;, is there a better way than:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo expand(&quot;%:t:r:r&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to be able to handle cases where multiple file extensions might be present, and doing &lt;code&gt;:r:r&lt;/code&gt; seems a bit narrow.&lt;/p&gt;&#xA;" OwnerUserId="7037" LastActivityDate="2016-03-30T19:39:33.827" Title="Using expand when multiple extensions are present in filename" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7096" PostTypeId="2" ParentId="7095" CreationDate="2016-03-30T19:39:33.827" Score="7" Body="&lt;p&gt;Maybe you could try using &lt;code&gt;split()&lt;/code&gt; to split the filename (&lt;code&gt;expand('%:t')&lt;/code&gt;) whenever there's a literal dot &lt;code&gt;\.&lt;/code&gt;. It would return a list whose first item (&lt;code&gt;[0]&lt;/code&gt;) should be what you are looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo split(expand('%:t'), '\.')[0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-03-30T19:39:33.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7097" PostTypeId="1" AcceptedAnswerId="7100" CreationDate="2016-03-31T01:39:17.413" Score="4" ViewCount="190" Body="&lt;p&gt;I often save my session using the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In vim: &lt;code&gt;mksession! ~/session.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;In gvim: &lt;code&gt;mksession! ~/sessionX.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, when I invoke vim with a sourcing of &lt;code&gt;~/session.vim&lt;/code&gt;, I'm finding that &lt;code&gt;~/sessionX.vim&lt;/code&gt; also gets sourced:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -S ~/session.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The regular expression &lt;code&gt;session[Xx]&lt;/code&gt; does not occur in my vimrc.  This file is used by both vim &amp;amp; gvim; it contains if-statements to distinguish between vim &amp;amp; gvim, and executes the appropriate code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did a recursive grep in &lt;code&gt;/usr/share/vim&lt;/code&gt; for &lt;code&gt;session[Xx]&lt;/code&gt; without any hits.  I did the same recursive grep in &lt;code&gt;~/.viminfo&lt;/code&gt; and &lt;code&gt;~/.vim&lt;/code&gt; (the latter is a folder).  The only place where &lt;code&gt;session[Xx]&lt;/code&gt; occurs is in &lt;code&gt;~/.viminfo&lt;/code&gt;, and that occurrence is simply the historical record of my &lt;code&gt;mksession&lt;/code&gt; command from a prior gvim session.  I removed the &lt;code&gt;.viminfo&lt;/code&gt; file, but the &lt;code&gt;sessionX.vim&lt;/code&gt; still gets sourced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to track down what leads to the sourcing of &lt;code&gt;sessionX.vim&lt;/code&gt; using verbose messages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~&#xA;'rm' -f vimLog.txt&#xA;vim -c 'set nomore' -V2vimLog.txt -S session.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This logs the startup at verbosity level 2, but I also tried verbosity level 10 (the default).  I can't discern anything obvious about what statements in what files are causing the rogue sourcing.  (I can post an anonymized version if anyone thinks this is helpful).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone suggest another avenue of tracking down the rogue sourcing?&lt;/p&gt;&#xA;" OwnerUserId="7041" LastEditorUserId="205" LastEditDate="2016-03-31T02:27:35.277" LastActivityDate="2016-03-31T10:25:04.273" Title="Source vim session file: Track down unexpected sourcing of other file" Tags="|sessions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7098" PostTypeId="2" ParentId="5898" CreationDate="2016-03-31T03:31:30.793" Score="1" Body="&lt;p&gt;The accepted answer is very, very good for a detailed, script-oriented way to accomplish a micro-optimization of a corner case, but many people in the same scenario don't want to be forced into a vimrc customization and those people usually also wouldn't have &quot;many, many files&quot; where saving two keystrokes is important and they still want a general and simple way to accomplish what you're describing.  So the simple and obvious solution for those people, and perhaps for you as well, is Vim's Visual Mode &lt;code&gt;gf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do a Visual Mode select of the text representing the weird file name, for example let's say with &lt;code&gt;vww&lt;/code&gt; or &lt;code&gt;v$&lt;/code&gt;, then type &lt;code&gt;gf&lt;/code&gt;. Done. Visual Mode &lt;code&gt;gf&lt;/code&gt; exists to cover the situation you're describing. Sure it changes a 2 keystroke combination into a 4 or 5 one, but it also works perfectly and visually and it works for this case as well as other similar cases, like let's say spaces in the file name.&lt;/p&gt;&#xA;" OwnerUserId="6519" LastEditorUserId="6519" LastEditDate="2016-06-16T15:22:43.560" LastActivityDate="2016-06-16T15:22:43.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7099" PostTypeId="1" CreationDate="2016-03-31T09:33:43.017" Score="2" ViewCount="399" Body="&lt;p&gt;I have this regex&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(\w\|[^[:punct:][:space:]]\|\%(\\\\\)*\\\)\%#\|\%#\%(\w\|[^[:space:][:punct:]]\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I wanted to is where this regex matches word characters &lt;code&gt;\w&lt;/code&gt; match word characters except &lt;code&gt;u&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; so I've changed all &lt;code&gt;\w&lt;/code&gt; to &lt;code&gt;[^\Wub]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%([^\Wub]\|[^[:punct:][:space:]]\|\%(\\\\\)*\\\)\%#\|\%#\%([^\Wub]\|[^[:space:][:punct:]]\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But somehow in this line new regex matches &lt;code&gt;e&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name=decode_header(file_name_info)[0][0].replace(),&#xA;                                               ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And old one doesn't.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="205" LastEditDate="2016-03-31T09:43:34.223" LastActivityDate="2016-03-31T13:02:00.263" Title="Why double negative regex matches when positive one doesn't?" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7100" PostTypeId="2" ParentId="7097" CreationDate="2016-03-31T10:25:04.273" Score="6" Body="&lt;p&gt;See &lt;code&gt;:h :mksession&lt;/code&gt;, the 10th point:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;10&quot;&gt;&#xA;  &lt;li&gt;If a file exists with the same name as the Session file, but ending in&#xA;  &quot;x.vim&quot; (for eXtra), executes that as well.  You can use *x.vim files to&#xA;  specify additional settings and actions associated with a given Session,&#xA;  such as creating menu items in the GUI version.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;... I have a feeling this is the issue.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-03-31T10:25:04.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7101" PostTypeId="2" ParentId="7099" CreationDate="2016-03-31T13:02:00.263" Score="5" Body="&lt;p&gt;&lt;code&gt;\W&lt;/code&gt; isn't understood as a character class inside a collection, so &lt;code&gt;[^\Wub]&lt;/code&gt; is specifying&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Match any character other than &lt;code&gt;\&lt;/code&gt;, &lt;code&gt;W&lt;/code&gt;, &lt;code&gt;u&lt;/code&gt;, and &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.appspot.com/pattern.txt.html#/collection&quot;&gt;&lt;code&gt;:help /[&lt;/code&gt;&lt;/a&gt; for the specifics about what can be used inside a collection.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2016-03-31T13:02:00.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7102" PostTypeId="1" CreationDate="2016-03-31T14:12:48.850" Score="1" ViewCount="92" Body="&lt;p&gt;Im using vim 7.4 and the Emmet plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While editing a css document and entering a selector &lt;code&gt;.mylink&lt;/code&gt; for example, pressing &lt;kbd&gt;Tab&lt;/kbd&gt; will typically yield a space, opening and closing braces and a blank line where the cursor is positionned to start adding rules. This is great and creates something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;.mylink {&#xA;    |&#xA;}&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;In this case the &lt;code&gt;|&lt;/code&gt; represents the cursor postion&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Setting the rule&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If I declare a background color, by entering &lt;kbd&gt;b&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt; it creates:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;.mylink {&#xA;    background: #|000;&#xA;}&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Again the &lt;code&gt;|&lt;/code&gt; represents the cursor position&lt;/em&gt;  &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The issue&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;While the cursor is positioned on the first character of the default &lt;code&gt;000&lt;/code&gt;, if I start to enter a new value it just acts as an insert. Is there any way to change that functionality?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would almost prefer it just default to the &lt;code&gt;#&lt;/code&gt; and let me enter my value rather than having to escape and &lt;kbd&gt;cw&lt;/kbd&gt; or something else to effectively reverse part of what the completion gives me. Or better yet, have it default to the &lt;code&gt;000&lt;/code&gt; being visually selected so that I could opt to keep the default in the rare event I wanted black. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help or suggestion is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="6358" LastEditorUserId="1841" LastEditDate="2016-03-31T14:32:09.090" LastActivityDate="2016-03-31T14:32:09.090" Title="Changing color value for css syntax when using tab completion via emmet" Tags="|autocompletion|plugin-emmet-vim|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7103" PostTypeId="1" CreationDate="2016-03-31T14:39:59.763" Score="3" ViewCount="306" Body="&lt;p&gt;I want to format a block of text and I am using a range to select the leading comment of a function. It's all lines starting with &lt;code&gt;// ...&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the range&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:?^[^\/][^\/]?+1,/^[^\/][^\/]/-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to select backwards up to the first line not starting with &lt;code&gt;//&lt;/code&gt;, then plus one to get the the start of the comment, and similar thing for the forward search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I prefix this with a sed command like &lt;code&gt;s,^,#,&lt;/code&gt; this works. But if I use &lt;code&gt;gq&lt;/code&gt; or &lt;code&gt;gw&lt;/code&gt; as command it fails telling me &lt;code&gt;Not an editor command: ...&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I apply the text format command to a range?&lt;/p&gt;&#xA;" OwnerUserId="7046" LastEditorUserId="7161" LastEditDate="2016-05-02T18:36:52.920" LastActivityDate="2016-05-02T20:43:54.190" Title="How to search and format a text range?" Tags="|search|formatting|range|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7104" PostTypeId="1" AcceptedAnswerId="7106" CreationDate="2016-03-31T15:40:37.563" Score="8" ViewCount="2044" Body="&lt;p&gt;I want to replace a character with its hex literal. For example before regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x68&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\([a-z]\)/\=printf(&quot;%#02x&quot;, submatch(0))/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this replaces it with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong? Is this even possible? &lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-03-31T16:06:53.507" Title="How do I replace a character with its hex value?" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7105" PostTypeId="1" AcceptedAnswerId="12951" CreationDate="2016-03-31T16:05:37.713" Score="9" ViewCount="837" Body="&lt;p&gt;I was experimenting with a DOT diagram and tried to do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! dot -Tpng -oFab.png %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I got an error because my filename has a special character (&quot;&lt;code&gt;ó&lt;/code&gt;&quot; in &quot;Fabricación&quot;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\windows\system32\cmd.exe /c ( dot -Tpng -oFab.png Fabricaci├│n.gv)&#xA;Error: dot: can't open Fabricaci├│n.gv&#xA;shell returned 2&#xA;Hit any key to close this window...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, the special character is being changed for &quot;&lt;code&gt;├│&lt;/code&gt;&quot;.&#xA;This is with vim and gVim 7.4 under Win7 and NTFS, so I assume the filename is in &lt;a href=&quot;https://stackoverflow.com/a/2051018/1701155&quot;&gt;UTF16&lt;/a&gt;.&#xA;I also assume that when invoking the shell/cmd the filename is being interpreted as some other encoding (thanks to &lt;a href=&quot;https://vi.stackexchange.com/users/51/carpetsmoker&quot;&gt;Carpetsmoker&lt;/a&gt; for pointing out it defaults to &lt;a href=&quot;https://superuser.com/q/269818/71885&quot;&gt;code page 850&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I fix this?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sure, I can simply rename the file, but I'd like to know why this happens and how to correct it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I just found &lt;a href=&quot;https://superuser.com/questions/682591/vim-uses-wrong-encoding-when-invoking-commands-in-the-terminal&quot;&gt;this question&lt;/a&gt; in superuser.SE (thanks to feedback by @&lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;ChristianBrabandt&lt;/a&gt;), but it doesn't seem to help either.&lt;/p&gt;&#xA;" OwnerUserId="475" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-07-19T23:40:36.180" Title="Wrong encoding while calling shell" Tags="|command-line|microsoft-windows|encoding|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7106" PostTypeId="2" ParentId="7104" CreationDate="2016-03-31T16:06:53.507" Score="10" Body="&lt;p&gt;In that way, &lt;code&gt;printf&lt;/code&gt; expects a decimal number to be converted to a hexadecimal one. All you need to do is convert the character to a number as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\([a-z]\)/\=printf(&quot;%#02x&quot;, char2nr(submatch(0)))/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#char2nr%28%29&quot;&gt;&lt;code&gt;:help char2nr()&lt;/code&gt;&lt;/a&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="6698" LastActivityDate="2016-03-31T16:06:53.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7107" PostTypeId="1" CreationDate="2016-03-31T19:18:52.137" Score="2" ViewCount="644" Body="&lt;p&gt;I'm using the vim-pandoc and vim-pandoc-syntax bundles in neovim. I'm converting the markdown to a docx file and I'm seeing that I need to do a double space in order to get a carriage return in the Word document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What setting am I misconfiguring?&lt;/p&gt;&#xA;" OwnerUserId="7051" LastEditorUserId="205" LastEditDate="2016-04-02T09:52:26.437" LastActivityDate="2016-04-02T09:52:26.437" Title="Pandoc and formatting" Tags="|formatting|neovim|filetype-markdown|plugin-vim-pandoc|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7108" PostTypeId="2" ParentId="7107" CreationDate="2016-03-31T19:27:31.367" Score="0" Body="&lt;p&gt;Got it...Markdown requires a double space at the end of a line to denote a carriage return.&lt;/p&gt;&#xA;" OwnerUserId="7051" LastActivityDate="2016-03-31T19:27:31.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7109" PostTypeId="2" ParentId="7107" CreationDate="2016-03-31T19:34:09.700" Score="5" Body="&lt;p&gt;Markdown has a concept of a &quot;paragraph&quot; different from that of MS Word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In MS Word, all text wrapping is &quot;soft wrapped&quot;—that is, you keep typing text without pressing &quot;Enter&quot; (or &quot;Return&quot;) until you have finished an entire paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Markdown, you &lt;em&gt;can&lt;/em&gt; do that, but more often markdown source will be &quot;hard wrapped&quot;—in other words, while typing a paragraph you will press &quot;Return&quot; whenever convenient to keep individual lines of text from becoming too long (much as you would on an old-fashioned typewriter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a Markdown paragraph consists of multiple consecutive lines of text.  To start a new paragraph, the usual action is to insert a blank line (i.e. press return &lt;em&gt;twice&lt;/em&gt; when you finish a paragraph).  However, you can also put a double space at the end of a line, as you discovered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The blank line for separation has the advantage of being easy to recognize visually whereas a double space at the end of a line is generally invisible when viewing the Markdown source.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2016-03-31T19:34:09.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7110" PostTypeId="1" AcceptedAnswerId="7111" CreationDate="2016-03-31T20:11:47.887" Score="4" ViewCount="447" Body="&lt;p&gt;When using vim-pandoc, I'm having some funny behavior with headers:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;if I position the cursor on a word and press &lt;code&gt;v-a-w&lt;/code&gt; and then &lt;code&gt;&amp;lt;localleader&amp;gt; - i&lt;/code&gt;, I get italics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if I position the cursor on a word and press &lt;code&gt;v-a-w&lt;/code&gt; and then &lt;code&gt;&amp;lt;localleader&amp;gt; - b&lt;/code&gt;, I get bold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I position the cursor on a word and press &lt;code&gt;v-a-w&lt;/code&gt; and then &lt;code&gt;&amp;lt;localleader&amp;gt; - #&lt;/code&gt;, I get &lt;code&gt;No String Under Cursor&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this the wrong way to assign a block of text to a header?&lt;/p&gt;&#xA;" OwnerUserId="7051" LastEditorUserId="51" LastEditDate="2016-03-31T22:00:41.630" LastActivityDate="2016-03-31T22:00:41.630" Title="Vim Pandoc &amp; Headers" Tags="|formatting|plugin-system|filetype-markdown|plugin-vim-pandoc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7111" PostTypeId="2" ParentId="7110" CreationDate="2016-03-31T20:17:58.897" Score="2" Body="&lt;p&gt;If you read vim-pandoc's help (&lt;code&gt;:h pandoc.txt&lt;/code&gt;) you will see, in the section called &lt;code&gt;*vim-pandoc-keyboard-module*&lt;/code&gt;, this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;localleader&amp;gt;#*     apply header (accepts a count) [n]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice the &lt;code&gt;[n]&lt;/code&gt; at the end of the line - it means the map is &lt;em&gt;only&lt;/em&gt; available when in normal mode. This probably means the map action applies to the whole current line.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-03-31T20:47:29.240" LastActivityDate="2016-03-31T20:47:29.240" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7112" PostTypeId="1" AcceptedAnswerId="7114" CreationDate="2016-03-31T23:06:10.737" Score="5" ViewCount="3268" Body="&lt;p&gt;When I load up vim inside tmux there is a background color behind all text as so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XzcLD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XzcLD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I load it up not in tmux I get the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iLW5L.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iLW5L.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want it to be like image 2, I can not understand why tmux is interfering?&lt;/p&gt;&#xA;" OwnerUserId="7052" LastEditorUserId="1682" LastEditDate="2016-04-09T18:05:43.370" LastActivityDate="2016-04-10T02:43:36.940" Title="Tmux messing with Vim highlighting" Tags="|syntax-highlighting|colorscheme|tmux|" AnswerCount="1" CommentCount="1" ClosedDate="2016-04-14T11:26:11.043" ContentLicense="CC BY-SA 3.0" />
  <row Id="7113" PostTypeId="1" AcceptedAnswerId="7115" CreationDate="2016-03-31T23:11:47.233" Score="11" ViewCount="461" Body="&lt;p&gt;Is there anyway I could make sure a file is locked so that I cant make any changes to it. Is there a command for locking / unlocking a file in vim. Some times i would like a file to be in readonly mode.&lt;/p&gt;&#xA;" OwnerUserId="7053" LastEditorUserId="51" LastEditDate="2016-04-01T01:17:42.463" LastActivityDate="2016-04-01T03:02:25.037" Title="How to make sure no changes are made to a file" Tags="|save|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7114" PostTypeId="2" ParentId="7112" CreationDate="2016-03-31T23:18:00.427" Score="6" Body="&lt;p&gt;Add this line to your &lt;code&gt;tmux.conf&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set -g default-terminal &quot;screen-256color&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add the line below to you shells rc file in my case its my &lt;code&gt;.zshrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [[ $TERM == xterm ]]; then TERM=xterm-256color; fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add the line below to your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above configuration works for me, but if this fails try to follow this link for another methor to fix &lt;a href=&quot;http://sunaku.github.io/vim-256color-bce.html&quot; rel=&quot;nofollow&quot;&gt;Fixing Vim's Background Color&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="1691" LastEditorUserId="4472" LastEditDate="2016-04-10T02:43:36.940" LastActivityDate="2016-04-10T02:43:36.940" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="7115" PostTypeId="2" ParentId="7113" CreationDate="2016-03-31T23:35:18.720" Score="12" Body="&lt;p&gt;You can set the file to read only and not modifiable&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set readonly&#xA;:set nomodifiable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'readonly'&#xA;:h 'modifiable'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-03-31T23:35:18.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7116" PostTypeId="1" CreationDate="2016-04-01T01:15:55.950" Score="5" ViewCount="328" Body="&lt;p&gt;Since importing a package and &lt;em&gt;not&lt;/em&gt; using it in Go is a compilation error,&#xA;fixing the &lt;code&gt;import&lt;/code&gt; manually can be a bit of a pain while debugging, so I'm currently using this to fix it up automatically before saving:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Filter all lines through cmd, and silently undo it if there's an error&#xA;fun! s:write_cmd(cmd)&#xA;    let l:save = winsaveview()&#xA;    keepjumps silent %!goimports&#xA;    if v:shell_error != 0&#xA;        normal! u&#xA;    endif&#xA;    call winrestview(l:save)&#xA;endfun&#xA;&#xA;&#xA;augroup ftype_go&#xA;    autocmd!&#xA;&#xA;    autocmd BufWritePre *.go call s:write_cmd('goimports')&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works, but has at least two problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pressing &lt;code&gt;u&lt;/code&gt; undoes this.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:!!&lt;/code&gt; now runs &lt;code&gt;goimports&lt;/code&gt; (and not, for example, &lt;code&gt;:!go run %&lt;/code&gt; which I&#xA;manually typed).&lt;/li&gt;&#xA;&lt;li&gt;Perhaps others side-effects I haven't noticed yet?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How can I &quot;transparently&quot; filter my buffer to an external command (meaning it won't cause any side-effects)?&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-01-05T06:43:02.203" Title="How can I filter a buffer to an external command on save without causing any side effects?" Tags="|external-command|undo-redo|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7117" PostTypeId="2" ParentId="7113" CreationDate="2016-04-01T03:02:25.037" Score="9" Body="&lt;p&gt;The easiest way is to open the file using the &lt;code&gt;-R&lt;/code&gt; flag when opening the file to set the &lt;code&gt;readonly&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -R filename.txt&#xA;vi -R filename.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For Vim, you can use the command &lt;code&gt;view&lt;/code&gt; when opening a file, which is equivalent to &lt;code&gt;vim -R&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;view filename.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;em&gt;the readonly option doesn't prevent a forced write&lt;/em&gt;.  If you use &lt;code&gt;:w!&lt;/code&gt; the file will be written regardless.  However, as a safety measure for &quot;look don't touch&quot;, &lt;code&gt;-R&lt;/code&gt; can be very helpful in preventing accidental writes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another workaround you could use is to open an empty file buffer, and read in the file you want to look at:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim&#xA;# Then, from inside vim:&#xA;:r filename.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is fairly safe since you have an unnamed buffer—you &lt;em&gt;can't&lt;/em&gt; accidentally overwrite the file you read in (although you could do so deliberately if you typed out the filename again).  However you may not get automatic syntax highlighting this way, depending on your settings.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2016-04-01T03:02:25.037" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7118" PostTypeId="2" ParentId="7116" CreationDate="2016-04-01T03:46:42.430" Score="3" Body="&lt;p&gt;For removing &lt;code&gt;:!goimports&lt;/code&gt; from the history, use &lt;code&gt;systemlist&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setline(1, systemlist('goimports', getline(0, line('$'))))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem here is that if there are fewer lines after &lt;code&gt;goimports&lt;/code&gt;, some garbage will remain at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the undo problem, use &lt;a href=&quot;http://vimhelp.appspot.com/undo.txt.html#%3Aundojoin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;undojoin&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If you want to write a function or script that doesn't create a new undoable&#xA;change but joins in with the previous change use this command:&#xA;&#xA;                                                :undoj :undojoin E790&#xA;:undoj[oin]             Join further changes with the previous undo block.&#xA;                        Warning: Use with care, it may prevent the user from&#xA;                        properly undoing changes.  Don't use this after undo&#xA;                        or redo.&#xA;                        {not in Vi}&#xA;&#xA;This is most useful when you need to prompt the user halfway through a change.&#xA;For example in a function that calls getchar().  Do make sure that there was&#xA;a related change before this that you must join with.&#xA;&#xA;This doesn't work by itself, because the next key press will start a new&#xA;change again.  But you can do something like this: &#xA;&#xA;        :undojoin | delete&#xA;&#xA;After this an &quot;u&quot; command will undo the delete command and the previous&#xA;change.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:write_cmd(cmd)&#xA;    let l:save = winsaveview()&#xA;    let l:post_imports = systemlist('goimports', getline(0, line('$')))&#xA;    let l:num_lines = len(l:post_imports)&#xA;    let l:cmds = ['undojoin', 'call setline(1, l:post_imports)']&#xA;    if l:num_lines &amp;lt; line('$')&#xA;        let l:cmds += [l:num_lines + 1 . ',$ delete']&#xA;    endif&#xA;    if v:shell_error == 0&#xA;        keepjumps silent exec join(l:cmds, '|')&#xA;    endif&#xA;    call winrestview(l:save)&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2017-01-05T06:43:02.203" LastActivityDate="2017-01-05T06:43:02.203" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7119" PostTypeId="1" AcceptedAnswerId="7120" CreationDate="2016-04-01T04:31:11.733" Score="0" ViewCount="343" Body="&lt;p&gt;I know to go to the last line of the page i use &lt;code&gt;L&lt;/code&gt;.&#xA;How do I get to the first line of the page ?&#xA;or what is the opposite of &lt;code&gt;L&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7053" LastEditorUserId="205" LastEditDate="2016-04-01T05:51:34.643" LastActivityDate="2016-04-01T05:51:34.643" Title="Goto First line of page" Tags="|cursor-motions|vim-windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7120" PostTypeId="2" ParentId="7119" CreationDate="2016-04-01T05:47:57.560" Score="5" Body="&lt;p&gt;The opposite of &lt;code&gt;L&lt;/code&gt; is &lt;code&gt;H&lt;/code&gt;. From &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#L&quot;&gt;&lt;code&gt;:h L&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                H&#xA;H                       To line [count] from top (Home) of window (default:&#xA;                        first line on the window) on the first non-blank&#xA;                        character linewise.  See also 'startofline' option.&#xA;                        Cursor is adjusted for 'scrolloff' option.&#xA;&#xA;                                                M&#xA;M                       To Middle line of window, on the first non-blank&#xA;                        character linewise.  See also 'startofline' option.&#xA;&#xA;                                                L&#xA;L                       To line [count] from bottom of window (default: Last&#xA;                        line on the window) on the first non-blank character&#xA;                        linewise.  See also 'startofline' option.&#xA;                        Cursor is adjusted for 'scrolloff' option.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-04-01T05:47:57.560" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7121" PostTypeId="2" ParentId="6604" CreationDate="2016-04-01T08:12:06.007" Score="1" Body="&lt;p&gt;On Mac OS X, if homebrew, python3, and vim are major components in your workflow then it works best if you leave the system python alone, &lt;em&gt;don't install python.org Python&lt;/em&gt; but rather install python ( 2 and 3 ) using &lt;code&gt;brew install&lt;/code&gt;.  Then install vim using homebrew also.  If you want python3 use the flags &lt;code&gt;--with-python3 --without-python&lt;/code&gt; and voila, you will indeed be using the same python in vim and out of vim.&#xA;pip3 should function as expected and leave your system python alone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reasoning behind why I say that you would want not to install the Python.org distribution of python alongside homebrew:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Homebrew wants to use &lt;em&gt;its own&lt;/em&gt; python.  Even if you are not installing python3 for your direct usage, chances are that something you install with homebrew will need it, and thus it will be installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mac OS X wants to to use it's own inbuilt python (2.7).  You're better off leaving this python alone, in terms of installing extra packages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want pip (and pip3) to install packages for the same python as what you would get when you go to your shell.  You should ideally be able to say &lt;code&gt;$ pip3 install foo&lt;/code&gt; at the shell and have 'foo' installed for the python you would reach at a &lt;code&gt;$ python3&lt;/code&gt; prompt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, lastly, you want vim to use that same python.  If vim is installed with homebrew, &lt;em&gt;your&lt;/em&gt; python, &lt;em&gt;homebrew's&lt;/em&gt; python, &lt;em&gt;pip's&lt;/em&gt; python, and &lt;em&gt;vim's&lt;/em&gt; python are all the same, and &lt;em&gt;OS X&lt;/em&gt; has it's own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, in this scenario, the addition of Python.org's python adds a third python, greatly complicating matters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Previously, I was accustomed to installing the Python.org pythons (2 and 3) just after a fresh install.  Then, I would install Xcode so I could clone vim from source and build with dynamic python3 support against python3.  Upon compiling vim, I would typically clobber the inbuilt vim7.3 of Mac OS X with my own.  This was all before I had touched homebrew – I was using MacPorts prior to that.  Homebrew follows a different philosophy than MacPorts, and I have found that it is much easier to go with the flow, so to speak, with homebrew and python, because the alternative is to always have to explicitly specify the full path to python whenever using pip.  Instead of &lt;code&gt;pip3 install foo&lt;/code&gt; it becomes &lt;code&gt;/Library/Frameworks/Python.framework/Versions/3.x/bin/python3 -m pip3 install foo&lt;/code&gt;.  It is not pretty or fun to have to worry about that.&lt;/p&gt;&#xA;" OwnerUserId="1717" LastEditorUserId="1717" LastEditDate="2016-04-03T00:33:11.497" LastActivityDate="2016-04-03T00:33:11.497" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7122" PostTypeId="1" CreationDate="2016-04-01T08:58:49.987" Score="28" ViewCount="5871" Body="&lt;p&gt;&lt;strong&gt;I love Vim&lt;/strong&gt;. I spend my whole life using it: At work I develop code with Vim, I edit config files with it, I write my emails with it. At home I write my todo lists and my buckets lists with it. On my free time I write a book in it. I go to meetups about Vim and I try to convince everyone I know to use it &lt;em&gt;(Unfortunately my grandma doesn't agree that she should use it to write letters to her friends)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With all this love for our beloved editor I am facing a huge problem: as a normally constituted human I sometimes want to relax and have fun. Naturally I'd want to do that in our godly editor, but I don't know how I can do that. Of course I have spent hours customizing my color scheme and writing recursive macro that I watch for long time but after six or seven hours straight it is not that fun anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm calling to you fellow Vimmers: &lt;strong&gt;How can I have fun in Vim?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; This post was obviously an April's fool &lt;em&gt;(of course my grandma loves to use Vim)&lt;/em&gt;. Thank you all for your answers and comments, some really cool ideas has been suggested! &lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-03T04:06:15.253" LastActivityDate="2016-05-12T13:14:50.233" Title="How can I really have some fun in Vim?" Tags="|vimscript|" AnswerCount="6" CommentCount="5" ClosedDate="2016-04-03T02:34:51.637" ContentLicense="CC BY-SA 3.0" />
  <row Id="7123" PostTypeId="2" ParentId="7122" CreationDate="2016-04-01T08:58:49.987" Score="20" Body="&lt;p&gt;There's a lot of way to have fun in Vim: for example, one could install the vim-script &lt;a href=&quot;https://github.com/vim-scripts/Nibble&quot; rel=&quot;noreferrer&quot;&gt;nibble plugin&lt;/a&gt; (this one has &lt;a href=&quot;https://github.com/vim-scripts/genutils&quot; rel=&quot;noreferrer&quot;&gt;a dependency&lt;/a&gt; which also must be installed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the plugin is installed the command &lt;code&gt;:Nibble&lt;/code&gt; will start a snake game in a new buffer. The snake can be controlled with &lt;kbd&gt;hjkl&lt;/kbd&gt; and the game can be paused with &lt;kbd&gt;space&lt;/kbd&gt;. With that it is possible to spend hours of fun in our beloved editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kx91M.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kx91M.png&quot; alt=&quot;nibble for vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now if you get bored with the snake you can still play a good old tetris game with &lt;a href=&quot;https://github.com/vim-scripts/TeTrIs.vim&quot; rel=&quot;noreferrer&quot;&gt;TeTrIs.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This one has no dependencies and the game is started with &lt;kbd&gt;Leader&lt;/kbd&gt;&lt;kbd&gt;te&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please admire how beautiful it is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8lyhZ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8lyhZ.png&quot; alt=&quot;Tetris in vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Finally, if you really are a hardcore gamer and still want some new experiences, you could try &lt;a href=&quot;https://github.com/vim-scripts/sokoban.vim&quot; rel=&quot;noreferrer&quot;&gt;sokoban&lt;/a&gt;. This game asks for too much cerebral skill for me but I'm sure some geniuses will still enjoy it. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; As the question is now closed, I'll add the &lt;a href=&quot;https://github.com/mattn/flappyvird-vim&quot; rel=&quot;noreferrer&quot;&gt;flappyvirb plugin&lt;/a&gt; suggested by @sp asic, which is actually much easier than the smartphone version:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wi9hU.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wi9hU.png&quot; alt=&quot;Flappy bird on Vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1189&quot; rel=&quot;noreferrer&quot;&gt;Matrix plugin&lt;/a&gt; suggested by @mMontu which will provide you hours of entertainment in front of an amazing matrix screensaver:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mutvH.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mutvH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2&lt;/strong&gt; Because the fun never ends, here is another plugin for the retro gamers: &lt;a href=&quot;https://github.com/katono/rogue.vim&quot; rel=&quot;noreferrer&quot;&gt;rogue.vim&lt;/a&gt; as its name says it is a port of rogue in vim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/B91pr.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/B91pr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explore a dungeon, fight monsters, win money: become a real Vim adventurer!&#xA;The game seems to be really complete, the doc is huge and clear and a lot of commands are available. And like in every good rogue like, the dungeon is randomly generated on each new game.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-12T13:14:50.233" LastActivityDate="2016-05-12T13:14:50.233" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7124" PostTypeId="2" ParentId="6604" CreationDate="2016-04-01T10:32:35.337" Score="3" Body="&lt;p&gt;Here is the answer to this question, however, first things first:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I do not use macports or brew.&lt;/li&gt;&#xA;&lt;li&gt;The ideal workflow for me would be to download the source code of any package, module, library or app and compile it myself.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For those reasons listed above, &lt;code&gt;brew&lt;/code&gt; was not an option for me. So here is the solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export CC=clang # Will be assumed automatically, most of the times&#xA;export vi_cv_path_python=/Users/me/apps/Darwin64/python2.7/bin/python&#xA;export vi_cv_dll_name_python=/Users/me/apps/Darwin64/python2.7/lib/libpython2.7.dylib&#xA;export DYNAMIC_PYTHON_DLL=/Users/me/apps/Darwin64/python2.7/lib/libpython2.7.dylib&#xA;&#xA;./configure --with-features=huge \&#xA;    --enable-cscope=yes \&#xA;    --enable-pythoninterp=yes \&#xA;    --enable-rubyinterp=yes \&#xA;    --enable-perlinterp=yes \&#xA;    --enable-luainterp=yes \&#xA;    --with-lua-prefix=/Users/me/apps/Darwin64/lua-5.2.3-clang-500.2.79 \&#xA;    --with-python-config-dir=/Users/me/apps/Darwin64/python2.7/lib/python2.7/config \&#xA;    --with-compiledby=Symbolix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Some of the ENV variables above, might not be necessary. I not sure about what I did regarding the $PYTHONHOME and $DYLD_LIBRARY_PATH variables. As far as I remember, those were not important for the above command to be successful. You might need to have your custom Python at the front of your $PATH variable though.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that I am linking against my own custom lua.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make&#xA;cd ./MacVim/build/Release/&#xA;open MacVim.app&#xA;cp -vr MacVim.app /Applications/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This worked for me on OSX 10.10.5 and VIM 7.4.1553 and I can confirm that VIM is linked properly against my own version of Python2.7. When I type: &lt;code&gt;:py import yaml; print yaml&lt;/code&gt; I get the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;module 'yaml' from '/Users/me/apps/Darwin64/python2.7/lib/python2.7/site-packages/yaml/__init__.pyc'&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am still testing this and it seems to be stable and working so far. Now, I am not depending on System Python and I can take care of my own packages etc. If something breaks, I will let you know. Also I do not need to alter any of the &lt;code&gt;sys.path&lt;/code&gt; or in fact I do not need to do anything extra to access my own python and the modules inside.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One important aspect is that if you run into trouble compiling this, make sure that you have the latest Xcode and you have run &lt;code&gt;xcode-select --install&lt;/code&gt; before compiling VIM from source. If things are still not working make sure to check the build log inside &lt;code&gt;./src/auto/config.log&lt;/code&gt; everything that you need to debug your build process is in there. Good luck.&lt;/p&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="11793" LastEditDate="2017-07-26T14:36:37.193" LastActivityDate="2017-07-26T14:36:37.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7125" PostTypeId="2" ParentId="7122" CreationDate="2016-04-01T12:49:09.140" Score="7" Body="&lt;p&gt;Imagine a file format for another hobby you have, and write a Vim plugin for it, just for you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's say you like to compose crosswords / puzzles. In this case, you could use/create a special file format, and complement it with a plugin that helps or automates certain operations, e.g. easy toggling of a black square, easy navigation from definition to word position in the puzzle, or automatic search in a specified dictionary for incomplete words, based on the current row/column cursor location. Stuff like that :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The idea comes from a Emacs book: &quot;Writing GNU Emacs Extensions&quot;)&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-04-01T12:49:09.140" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7126" PostTypeId="1" AcceptedAnswerId="7130" CreationDate="2016-04-01T12:58:53.407" Score="16" ViewCount="23601" Body="&lt;p&gt;My writing routine is like this: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I edit a .tex file using vim &lt;/li&gt;&#xA;&lt;li&gt;I go to the command line and I compile it using &lt;code&gt;pdflatex&lt;/code&gt;. I find myself always saving the file with &lt;code&gt;:w&lt;/code&gt; and immediately having to switch terminals to execute &lt;code&gt;pdflatex&lt;/code&gt; (I use Ubuntu) to compile it. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This annoys me. I would like to make this more efficient so that I can manage to do both steps with a single shot. Is there a way to configure vim so that every time I save a &lt;code&gt;.tex&lt;/code&gt; file with &lt;code&gt;:w&lt;/code&gt;, the command &lt;code&gt;pdflatex&lt;/code&gt; is executed automatically?&lt;/p&gt;&#xA;" OwnerUserId="7061" LastEditorUserId="205" LastEditDate="2016-04-02T08:04:05.163" LastActivityDate="2022-03-29T16:44:04.947" Title="How do I get Vim to compile my .tex file when executing :w?" Tags="|external-command|filetype-tex|" AnswerCount="6" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7127" PostTypeId="2" ParentId="7126" CreationDate="2016-04-01T13:44:55.500" Score="3" Body="&lt;p&gt;I wouldn't configure Vim for that. Instead, I would use something like &lt;a href=&quot;http://entrproject.org/&quot; rel=&quot;nofollow&quot;&gt;entr&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls foo.tex | entr &amp;lt;your command here&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-01T13:44:55.500" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7128" PostTypeId="2" ParentId="7126" CreationDate="2016-04-01T14:07:00.863" Score="4" Body="&lt;p&gt;If you use tpope's Dispatch plugin:&#xA;&lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow&quot;&gt;https://github.com/tpope/vim-dispatch&lt;/a&gt; you can run commands in the background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use this snippet to run xelatex on every save:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup latex&#xA;    autocmd!&#xA;    autocmd BufEnter *.tex let b:dispatch='xelatex --output-directory=output %'&#xA;    autocmd BufWrite * Dispatch!&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="284" LastActivityDate="2016-04-01T14:07:00.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7129" PostTypeId="1" CreationDate="2016-04-01T16:38:46.253" Score="2" ViewCount="49" Body="&lt;p&gt;I have been having some problems using UltiSnips with vim. It seems that &lt;code&gt;:mksession&lt;/code&gt; is adding a bunch of nonprintable characters to my session file(s). When this is sourced to restore my session, &lt;a href=&quot;https://github.com/SirVer/ultisnips/issues/627&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips has a problem dealing with these nonprintable characters&lt;/a&gt;. Does anyone know why vim might be adding these nonprintable characters to my session file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following are the two vim commands that I'm using to save a session and source a session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nmap &amp;lt;F2&amp;gt; :wa&amp;lt;CR&amp;gt;:mksession! $HOME/vim_session&amp;lt;CR&amp;gt; &quot; Write session to file&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nmap &amp;lt;F3&amp;gt; :wa&amp;lt;CR&amp;gt;:source $HOME/vim_session&amp;lt;CR&amp;gt; &quot; Load session from file&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NIdCv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NIdCv.png&quot; alt=&quot;Screenshot of gVim session file with many nonprintable characters&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2062" LastEditorUserId="2062" LastEditDate="2016-04-01T20:47:37.977" LastActivityDate="2016-04-01T20:47:37.977" Title=":mksession session file includes nonprintable characters" Tags="|plugin-ultisnips|sessions|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7130" PostTypeId="2" ParentId="7126" CreationDate="2016-04-01T17:00:06.813" Score="16" Body="&lt;p&gt;Don't be so inefficient! Your time is valuable. Use the &lt;code&gt;vimtex&lt;/code&gt; plugin offered by @lervag: &lt;a href=&quot;https://github.com/lervag/vimtex/&quot; rel=&quot;noreferrer&quot;&gt;see here&lt;/a&gt;. You can control all of the plugins you install by using &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;Vundle&lt;/code&gt;&lt;/a&gt; or any similar plugin manager (&lt;code&gt;vim-plug&lt;/code&gt; is getting pretty popular).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why waste your time installing &lt;code&gt;vimtex&lt;/code&gt;? Great question!&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Features&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Continuous compilation using &lt;code&gt;latexmk&lt;/code&gt; (please and thank you!)&lt;/li&gt;&#xA;&lt;li&gt;Automatic warning/error notification using the vim quickfix window.&lt;/li&gt;&#xA;&lt;li&gt;Forward and inverse search.&lt;/li&gt;&#xA;&lt;li&gt;Support for a variety of PDF viewers.&lt;/li&gt;&#xA;&lt;li&gt;Support for multi-file projects (I love this one) in conjunction with &lt;code&gt;gf&lt;/code&gt; and &lt;code&gt;&amp;lt;ctrl-w&amp;gt;gf&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt; commands that make things perform operations like &lt;code&gt;latexmk -C&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;It's under active development!&lt;/li&gt;&#xA;&lt;li&gt;So much more!&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note, feature number 1 is the one which addresses your question. Each time you execute &lt;code&gt;:w&lt;/code&gt; your document will be saved and automatically recompiled by &lt;code&gt;latexmk&lt;/code&gt;. &lt;code&gt;latexmk&lt;/code&gt; watches your LaTeX file for changes, automatically recompiling when changes are detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This post is not sponsored by or promoted by any developer or affiliate of the &lt;code&gt;vimtex&lt;/code&gt; team (I'm just a lover).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go be efficient!&lt;/p&gt;&#xA;" OwnerUserId="2062" LastActivityDate="2016-04-01T17:00:06.813" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7131" PostTypeId="2" ParentId="7122" CreationDate="2016-04-01T17:40:03.533" Score="12" Body="&lt;p&gt;Didn't notice &lt;code&gt;VimGolf&lt;/code&gt; listed here, so thought I'd throw it out there:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.vimgolf.com/&quot;&gt;VimGolf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a fun way to challenge yourself to do Vim things in fewer and fewer keystrokes. Apologies if you already knew of it.&lt;/p&gt;&#xA;" OwnerUserId="1847" LastActivityDate="2016-04-01T17:40:03.533" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7132" PostTypeId="2" ParentId="7122" CreationDate="2016-04-01T18:26:43.590" Score="7" Body="&lt;p&gt;Do you think you've mastered Vim? Do you know all the commands? Is using Vim getting boring and a banality? Are you longing for the days when discovering how to quit Vim was exciting and new?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then level up your Vim to achieve the next level of Vim mastery! It's as simple as using &lt;code&gt;:VimLevelUp&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:level_up()&#xA;    let l:all_mappings = []&#xA;    for k in range(33, 123) + [125, 126, 127]&#xA;        let l:all_mappings += [nr2char(l:k), '&amp;lt;C-' . nr2char(l:k) . '&amp;gt;']&#xA;    endfor&#xA;    let l:all_mappings += ['&amp;lt;Bar&amp;gt;', '&amp;lt;Left&amp;gt;', '&amp;lt;Right&amp;gt;', '&amp;lt;Up&amp;gt;', '&amp;lt;Down&amp;gt;']&#xA;    let l:all_mappings += ['&amp;lt;C-Bar&amp;gt;', '&amp;lt;C-Left&amp;gt;', '&amp;lt;C-Right&amp;gt;', '&amp;lt;C-Up&amp;gt;', '&amp;lt;C-Down&amp;gt;']&#xA;    let l:all_mappings += ['&amp;lt;S-Bar&amp;gt;', '&amp;lt;S-Left&amp;gt;', '&amp;lt;S-Right&amp;gt;', '&amp;lt;S-Up&amp;gt;', '&amp;lt;S-Down&amp;gt;']&#xA;    for i in range(1, 12)&#xA;        let l:all_mappings += ['&amp;lt;F' . l:i . '&amp;gt;', '&amp;lt;C-F' . l:i . '&amp;gt;', '&amp;lt;S-F' . l:i . '&amp;gt;']&#xA;    endfor&#xA;&#xA;    let l:random = map(systemlist('seq 0 ' . (len(l:all_mappings)-1) . ' | shuf'), 'str2nr(v:val)')&#xA;    for i in range(0, len(l:all_mappings)-1)&#xA;        execute 'nnoremap ' . l:all_mappings[i] . ' ' . l:all_mappings[l:random[i]]&#xA;    endfor&#xA;&#xA;    echo &quot;Welcome to level 2&quot;&#xA;endfun&#xA;&#xA;command! VimLevelUp :call s:level_up()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is guaranteed to give you a new way to experience Vim and endless hours of fun!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note: uses &lt;code&gt;seq&lt;/code&gt; and &lt;code&gt;shuf&lt;/code&gt; − it could be ported to BSD and OSX by using &lt;code&gt;jot&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-04-01T18:37:21.267" LastActivityDate="2016-04-01T18:37:21.267" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7133" PostTypeId="1" CreationDate="2016-04-01T20:37:59.533" Score="3" ViewCount="290" Body="&lt;p&gt;In git when patching you have to count:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &quot;leave alone&quot; lines&lt;/li&gt;&#xA;&lt;li&gt;The &quot;remove&quot; lines&lt;/li&gt;&#xA;&lt;li&gt;The &quot;add&quot; lines&lt;/li&gt;&#xA;&lt;li&gt;The &quot;leave alone&quot; + &quot;add&quot; lines&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've found ways to count all of these...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%s/^ / /n&lt;/code&gt; &quot;leave alone&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%s/^-/ /n&lt;/code&gt; &quot;remove&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%s/^+/ /n&lt;/code&gt; &quot;add&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%s/^ \|^+/ /n&lt;/code&gt; &quot;add&quot; + &quot;leave alone&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now what I'd like to do is display these counts in a new split buffer, so that my patching can go well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to display the resulting counts in an split buffer Window, either above or below the patch one using Vim Script?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2016-06-08T18:50:43.420" Title="How to display the counts of lines in a git patch / hunk?" Tags="|vimscript|git|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7134" PostTypeId="1" AcceptedAnswerId="7141" CreationDate="2016-04-01T22:48:10.720" Score="7" ViewCount="1870" Body="&lt;p&gt;I wrote a moderately complex routine for Vim and I need to programmatically set the height of windows. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way to do this is with &lt;code&gt;:resize [N]&lt;/code&gt; as the help says. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But my invocation didn't work until I employed &lt;code&gt;exec&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe `resize `.i[1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following doesn't work, it always resizes to a height of 1 instead of the required &lt;code&gt;i[1]&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;resize i[1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I understand that &lt;code&gt;resize&lt;/code&gt; takes a Number type and I am apparently feeding it a string, but I can't figure out how to avoid &lt;code&gt;exec&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe there's a trick I can use to use the &lt;code&gt;+&lt;/code&gt; operator with &lt;code&gt;0&lt;/code&gt;? In fact the Vim doc explicitly tells us to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried it, but it doesn't work! It works with &lt;code&gt;echo&lt;/code&gt; but not &lt;code&gt;res&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I tried setting the value &lt;code&gt;i[1] + 0&lt;/code&gt; to a variable and then using that. Indeed it seems that when I use &lt;code&gt;res&lt;/code&gt;, it does not attempt to expand the value of variables. Really perplexing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there another canonical fast way to convert an integer string into a Number? Perhaps some other thing is causing this unexpected behavior?&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="205" LastEditDate="2016-04-02T02:20:38.937" LastActivityDate="2016-04-02T02:30:03.183" Title="How do I use a variable with an ex command?" Tags="|vimscript|command-line|arithmetic|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7136" PostTypeId="1" AcceptedAnswerId="7137" CreationDate="2016-04-01T23:04:04.440" Score="3" ViewCount="507" Body="&lt;p&gt;When I use &lt;code&gt;:set iskeyword?&lt;/code&gt; to view keyword characters, result for shell scripts is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iskeyword=@,48-57,_,192-255,-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;:h iskeyword says @ expands to any alpha character that the isalpha() functions returns true on, but what about &lt;code&gt;48-57&lt;/code&gt; and &lt;code&gt;192-255&lt;/code&gt; how can I view these characters?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2021-06-15T17:37:57.453" Title="How can I print out the iskeyword characters?" Tags="|cursor-motions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7137" PostTypeId="2" ParentId="7136" CreationDate="2016-04-01T23:17:47.670" Score="9" Body="&lt;p&gt;You can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo map(range(48, 57), 'nr2char(v:val)')&#xA;:echo map(range(192, 255), 'nr2char(v:val)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which should output:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;['À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò',&#xA;  'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', '&#xA;  æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù&#xA;  ', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ']&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To break it down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;range(192, 255)&lt;/code&gt; makes a list from 192 to 255.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nr2char()&lt;/code&gt; converts a number from its ASCII code to a string.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;map()&lt;/code&gt; applies &lt;code&gt;nr2char()&lt;/code&gt; to every item in the list.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="205" LastEditDate="2016-04-02T02:17:24.717" LastActivityDate="2016-04-02T02:17:24.717" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7138" PostTypeId="1" CreationDate="2016-04-01T23:18:21.310" Score="9" ViewCount="10977" Body="&lt;p&gt;Is there any way I can use Vim with or Neovim to edit my project, and still be able to build it using Visual Studio?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note I am not talking about limited Vim emulators for Visual Studio but proper integration, with Vim at the front-end as the main tool and build tools at the back-end of the pipeline.&lt;/p&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="51" LastEditDate="2016-04-03T00:42:02.883" LastActivityDate="2020-04-04T06:39:10.767" Title="Can I use Vim with Visual Studio?" Tags="|microsoft-windows|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7139" PostTypeId="1" CreationDate="2016-04-02T00:51:10.873" Score="0" ViewCount="317" Body="&lt;p&gt;I want to ssh into a Linux server from my macbook, and code Matlab, execute my Matlab code and see the figures that are produced by Matlab all through the one single SSH channel. I note that, I don't want to use x11 forwarding and prefer to see everything inside a SSH channel. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I have the above setup with vim? Or should I go for Emacs?&lt;/p&gt;&#xA;" OwnerUserId="7071" LastEditorUserId="51" LastEditDate="2016-04-03T00:31:49.253" LastActivityDate="2016-04-03T00:31:49.253" Title="Vim remotely over SSH channel and see the MATLAB figures" Tags="|matlab|ssh|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7140" PostTypeId="1" AcceptedAnswerId="7143" CreationDate="2016-04-02T01:01:03.720" Score="6" ViewCount="291" Body="&lt;p&gt;If I have a shell script with code like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;chars+=('5')&#xA;chars+=('6')&#xA;...&#xA;chars+=('%')&#xA;chars+=('&amp;amp;')&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;iskeyword&lt;/code&gt; is defined as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iskeyword=@,48-57,_,192-255,-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This definition indicates to me Vim will consider a continuous sequence of characters from these &lt;code&gt;iskeywords&lt;/code&gt; characters to be a word.&lt;br&gt;&#xA;So if I am here&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;chars+=('5')&#xA; ^ (cursor)&#xA;chars+=('6') &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and press &lt;code&gt;w&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;chars+=('5')&#xA;     ^ (cursor)&#xA;chars+=('6')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I end up on &lt;code&gt;+&lt;/code&gt; which is not the beginning of a word as defined by iskeyword character set. Why? Does Vim stop at the beginning of a group of these non-iskeyword chars because it considers you might be interested in doing something with them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, wouldn't it be better to say &lt;code&gt;w&lt;/code&gt; takes you both to the beginning of the next &quot;word&quot; OR the beginning of the next &quot;anti-word&quot; (continuous sequence of characters NOT defined in iskeyword)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because code contains a lot of characters not in &lt;code&gt;iskeyword&lt;/code&gt;, I am interested in knowing the rules for &quot;w&quot; word motion regarding these non-word characters.&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="205" LastEditDate="2016-04-02T02:16:31.807" LastActivityDate="2022-02-23T02:03:08.750" Title="What are the rules for &quot;w&quot; word motion when characters are not in iskeyword?" Tags="|cursor-motions|vi-words|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7141" PostTypeId="2" ParentId="7134" CreationDate="2016-04-02T02:30:03.183" Score="7" Body="&lt;p&gt;You can't use a variable directly with &lt;code&gt;:res&lt;/code&gt;. Compare the help text for &lt;a href=&quot;http://vimhelp.appspot.com/window.txt.html#%3Ares&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:res&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Asubstitute&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:s&lt;/code&gt;&lt;/a&gt;, &lt;code&gt;:echo&lt;/code&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Aexecute&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:exe&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:res[ize] -N                                    :res :resize CTRL-W_-&#xA;CTRL-W -        Decrease current window height by N (default 1).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]&#xA;                        For each line in [range] replace a match of {pattern}&#xA;                        with {string}.&#xA;                        For the {pattern} see pattern.&#xA;                        {string} can be a literal string, or something&#xA;                        special; see sub-replace-special.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        :ec :echo&#xA;:ec[ho] {expr1} ..      Echoes each {expr1}, with a space in between.  The&#xA;                        first {expr1} starts on a new line.&#xA;                                                        :exe :execute&#xA;:exe[cute] {expr1} ..   Executes the string that results from the evaluation&#xA;                        of {expr1} as an Ex command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The text uses &lt;code&gt;expr1&lt;/code&gt; for &lt;code&gt;echo&lt;/code&gt; and &lt;code&gt;exe&lt;/code&gt;, but nothing of the sort for the other commands. For &lt;code&gt;:s&lt;/code&gt;, it's specially stated that the replacement can be &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-special&quot; rel=&quot;noreferrer&quot;&gt;something special&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                        sub-replace-special :s\=&#xA;When the {string} starts with &quot;\=&quot; it is evaluated as an expression, see&#xA;sub-replace-expression.  You can use that for complex replacement or special&#xA;characters.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In short, unless the command is expected to be followed by an &lt;em&gt;expression&lt;/em&gt;, don't expect variables to evaluated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:exe&lt;/code&gt; is the way to go, in this case.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;By the way, you don't need to use &lt;code&gt;.&lt;/code&gt; here, the following will work the same:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 'resize' i[1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;exe&lt;/code&gt; implicitly joins arguments with spaces. It's when you &lt;em&gt;don't&lt;/em&gt; want the sapce that you should use &lt;code&gt;.&lt;/code&gt; with &lt;code&gt;exe&lt;/code&gt; arguments.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-04-02T02:30:03.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7143" PostTypeId="2" ParentId="7140" CreationDate="2016-04-02T03:49:23.013" Score="7" Body="&lt;p&gt;I think the misunderstanding is that iskeyword doesn't define what a word is; rather, it adjusts where a boundary may happen by adjusting what a keyword is. Both keywords and non-keywords are still &quot;words&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;code&gt;:help word&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A word consists of a sequence of letters, digits and underscores, or a&#xA;  sequence of other non-blank characters, separated with white space (spaces,&#xA;  tabs, ).  This can be changed with the 'iskeyword' option.  An empty line&#xA;  is also considered to be a word.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But, that doesn't quite answer your question exactly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My understanding is that &quot;iskeyword&quot; is used to group the containing characters as a type of word called &quot;keyword&quot;, but that doesn't mean that characters (except whitespace) outside of iskeyword aren't words, but are just non-keywords. Also, it seems that letters and high unicode is considered part of a keyword regardless (from &lt;code&gt;help 'iskeyword'&lt;/code&gt; and &lt;code&gt;help 'isfname'&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such, when you press &lt;kbd&gt;w&lt;/kbd&gt; at the beginning of &lt;code&gt;chars+=&lt;/code&gt;, the letters are considered part of the same word because they form a keyword, but since &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;=&lt;/code&gt; are not in &lt;code&gt;iskeyword&lt;/code&gt;, that makes them a non-keyword word, which means there is a word separation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior that I observe is that, outside of whitespace separation, keywords and non-keywords are considered words, and a transition from keyword to non-keyword or from non-keyword to keyword forms a word boundary, just like whitespace forms a word or WORD boundary.&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2016-04-02T03:49:23.013" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7144" PostTypeId="2" ParentId="7139" CreationDate="2016-04-02T05:47:57.377" Score="3" Body="&lt;p&gt;So, 1) editing your file using the SSH protocol and 2) executing your code remotely is possible using vim. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;vim scp://[user@]machine/path&lt;/code&gt; or &lt;code&gt;vim&lt;/code&gt;, then &lt;code&gt;:e scp://[user@]machine/path&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:!/path/to/matlab some_matlab_file.m&lt;/code&gt; &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;However, your request to view your figures through SSH is impossible without using some window/display manager to view your images. So, in the SSH case, X11 forwarding would have to be used. Of course, you could alternatively use VNC or remote desktop to access this machine (assuming it supports either of those protocols and you have the proper permissions to use those applications on the remote).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this issue would not be ameliorated with emacs/any text editor. This is a limitation of SSH, which is just designed as a secure shell (SSH), i.e. text-based, protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, one option would be to generate &lt;code&gt;.fig&lt;/code&gt; files from your MATLAB code and use SCP to copy those files onto your local machine. If you have a copy of MATLAB installed on the local machine, then you could view your figures.&lt;/p&gt;&#xA;" OwnerUserId="2062" LastActivityDate="2016-04-02T05:47:57.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7145" PostTypeId="1" AcceptedAnswerId="7146" CreationDate="2016-04-02T06:22:56.073" Score="1" ViewCount="1462" Body="&lt;p&gt;Suppose I have the following text, how can I delete single quotation marks and comma in each line end? I know I can use &lt;code&gt;x&lt;/code&gt; command and delete &lt;code&gt;'&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt;  line by line. But are there any more clever way to do this? &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; doesn't work here.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;index',&#xA;wind_code',&#xA;date',&#xA;acct_rcv',&#xA;acct_payable',&#xA;adminexpensetogr',&#xA;debttoassets',&#xA;finaexpensetogr',&#xA;monetary_cap',&#xA;operateexpensetogr',&#xA;salescashintoor',&#xA;tot_assets',&#xA;arturn',&#xA;assetsturn',&#xA;bps',&#xA;cashtocurrentdebt',&#xA;cfps',&#xA;current',&#xA;currentdebttodebt',&#xA;eps_basic',&#xA;fin_exp_is',&#xA;grossprofitmargin',&#xA;invturn',&#xA;longdebttodebt',&#xA;net_cash_flows_oper_act',&#xA;net_profit_is',&#xA;netprofitmargin',&#xA;optoebt',&#xA;quick',&#xA;roa',&#xA;roe',&#xA;tot_cur_liab',&#xA;tot_liab',&#xA;tot_oper_rev',&#xA;tot_profit',&#xA;wgsd_assets',&#xA;wgsd_stkhldrs_eq',&#xA;yoy_or',&#xA;yoy_equity',&#xA;yoyprofit',&#xA;growth_totalequity'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks for help!&lt;/p&gt;&#xA;" OwnerUserId="4582" LastEditorUserId="205" LastEditDate="2016-04-03T00:38:44.367" LastActivityDate="2016-04-03T00:38:44.367" Title="How can I delete a quotation mark and comma at the end of every line?" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7146" PostTypeId="2" ParentId="7145" CreationDate="2016-04-02T07:57:41.590" Score="7" Body="&lt;p&gt;With &lt;code&gt;:help :s&lt;/code&gt;…&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/',&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;:help :normal&lt;/code&gt;…&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm $xx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;:help recording&lt;/code&gt;…&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq&#xA;$xxj&#xA;q&#xA;:,$norm @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or…&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq&#xA;$xxj&#xA;q&#xA;@q@@@@@@@@@@ (as many times as needed)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;:h .&lt;/code&gt;…&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/',&amp;lt;CR&amp;gt;&#xA;2x&#xA;n.n.n.n. (as many times as needed)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-02T07:57:41.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7147" PostTypeId="2" ParentId="7145" CreationDate="2016-04-02T10:16:43.300" Score="3" Body="&lt;p&gt;Simple answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/',$//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;delete &lt;code&gt;',&lt;/code&gt; ending in those lines that match the pattern.&lt;/p&gt;&#xA;" OwnerUserId="7079" LastEditorUserId="205" LastEditDate="2016-04-03T00:37:31.657" LastActivityDate="2016-04-03T00:37:31.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7148" PostTypeId="2" ParentId="7133" CreationDate="2016-04-02T13:14:19.143" Score="2" Body="&lt;p&gt;I don't know git so I'm not sure it will work in your case, but maybe you could try the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% CountGit let b:winview = winsaveview() | &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call s:count_git()&#xA;function! s:count_git() abort range&#xA;    let counts = repeat([0], 4)&#xA;    let patterns = ['^ ', '^-', '^+', '^ \|^+']&#xA;    for i in range(4)&#xA;        exe a:firstline ',' a:lastline 'g/' . patterns[i] . '/let counts[' i '] += 1'&#xA;    endfor&#xA;    lefta new&#xA;    sil! 0put =['leave alone: ', 'remove: ', 'add: ', 'add + leave alone: ']&#xA;    sil! 4put =counts&#xA;    sil! 1,4g/^/5m.|-j!&#xA;    $d_&#xA;    sil! %!column -t -s:&#xA;    if !bufexists('Counts') | file Counts | endif&#xA;    setl noma bt=nofile noswf nobl bh=wipe&#xA;    wincmd p&#xA;    call winrestview(b:winview) | unlet b:winview&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It defines a custom command &lt;code&gt;:CountGit&lt;/code&gt; which calls the &lt;code&gt;s:count_git()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function initializes the lists &lt;code&gt;counts&lt;/code&gt; and &lt;code&gt;patterns&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;counts&lt;/code&gt; should contain the number of occurrences of the lines you're interested in, while &lt;code&gt;patterns&lt;/code&gt; contains the description of the latter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;for&lt;/code&gt; loop executes a global command for each pattern which increments a number inside &lt;code&gt;counts&lt;/code&gt; for each occurrence of the pattern.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0put =...&lt;/code&gt; paste some description text (&lt;code&gt;leave alone:&lt;/code&gt;, &lt;code&gt;remove:&lt;/code&gt;...).  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;4put =...&lt;/code&gt; paste the number of occurrences after the 4th line.  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1,4g/^/5m.|-j!&lt;/code&gt; join the 2 blocks of text (description + counts).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sil! %!column -t -s:&lt;/code&gt; align the counts (remove this line if you don't have the shell &lt;code&gt;column&lt;/code&gt; utility)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The command accepts a range (which by default is &lt;code&gt;%&lt;/code&gt;) so you could for example select only a part of the buffer and type &lt;code&gt;:'&amp;lt;,'&amp;gt;CountGit&lt;/code&gt; to search for the patterns only inside the visual selection.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-06-08T18:50:43.420" LastActivityDate="2016-06-08T18:50:43.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7149" PostTypeId="1" AcceptedAnswerId="7150" CreationDate="2016-04-02T14:51:31.040" Score="17" ViewCount="6187" Body="&lt;p&gt;I'm trying to make a keyboard binding in Neovim that would send a selected block to the opened Neovim terminal. I've used these answers as guidelines &lt;a href=&quot;https://vi.stackexchange.com/a/3390/3405&quot;&gt;https://vi.stackexchange.com/a/3390/3405&lt;/a&gt; &lt;a href=&quot;https://stackoverflow.com/a/6271254/859391&quot;&gt;https://stackoverflow.com/a/6271254/859391&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though when i'm trying to call the  command with a Visual Line selected I keep getting the No Range Allowed error. Am I missing something obvious?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:get_visual_selection()&#xA;  &quot; Why is this not a built-in Vim script function?!&#xA;  let [lnum1, col1] = getpos(&quot;'&amp;lt;&quot;)[1:2]&#xA;  let [lnum2, col2] = getpos(&quot;'&amp;gt;&quot;)[1:2]&#xA;  let lines = getline(lnum1, lnum2)&#xA;  let lines[-1] = lines[-1][: col2 - (&amp;amp;selection == 'inclusive' ? 1 : 2)]&#xA;  let lines[0] = lines[0][col1 - 1:]&#xA;  return join(lines, &quot;\n&quot;)&#xA;endfunction&#xA;&#xA;augroup Terminal&#xA;  au!&#xA;  au TermOpen * let g:last_terminal_job_id = b:terminal_job_id&#xA;augroup END&#xA;&#xA;function! REPLSend(lines)&#xA;  call jobsend(g:last_terminal_job_id, lines[0])&#xA;  call jobsend(g:last_terminal_job_id, &quot;\r&quot;) &quot; needed for the way REPL handles the input&#xA;endfunction&#xA;&#xA;command! REPLSendLine call REPLSend([s:get_visual_selection()])&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;l :REPLSendLine&amp;lt;cr&amp;gt;&#xA;&quot; leader is &amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3405" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-04-02T15:24:44.110" Title="Mapping a command in Visual Mode results in error E481: No range alllowed" Tags="|key-bindings|visual-mode|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7150" PostTypeId="2" ParentId="7149" CreationDate="2016-04-02T15:10:01.120" Score="19" Body="&lt;p&gt;I'm not sure, but I think that when you hit &lt;code&gt;&amp;lt;leader&amp;gt;l&lt;/code&gt; to call &lt;code&gt;:REPLSendLine&lt;/code&gt;, Vim automatically inserts the visual range &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt;, and since your command is not defined with the attribute &lt;code&gt;-range&lt;/code&gt;, it raises an error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your visual mapping, you should probably add the keycode &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; to remove the visual range (it won't affect the marks &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt;, they will still be valid inside &lt;code&gt;s:get_visual_selection()&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;l :&amp;lt;C-U&amp;gt;REPLSendLine&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, maybe you could try removing the inline comment &lt;code&gt;&quot; needed for the way REPL handles the input&lt;/code&gt; and put it on a separate and dedicated line.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-04-02T15:24:44.110" LastActivityDate="2016-04-02T15:24:44.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7151" PostTypeId="2" ParentId="7094" CreationDate="2016-04-02T16:15:01.107" Score="3" Body="&lt;p&gt;The orange section by default should be the warning one:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;let g:airline_section_warning (ycm_warning_count, whitespace)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can find a list of all sections at the end of the 'CUSTOMIZATION' section of the airline help (&lt;code&gt;:help airline-customization&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It gets filled usually by the whitespace extension which is on by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the following in you vimrc file to &quot;close&quot; the section. I added the error section too, because it shows on my system so it might on yours in time (if you are using an older version at the moment):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_section_warning = ''&#xA;let g:airline_section_error = ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This fully disables the section so you won't be seeing anything in it.&lt;/strong&gt; I think this is what the issue I linked in the comments is about: hiding the section when no information is available and showing it when there is. Currently you seem to get only one of them.&lt;/p&gt;&#xA;" OwnerUserId="20" LastActivityDate="2016-04-02T16:15:01.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7152" PostTypeId="2" ParentId="7122" CreationDate="2016-04-02T17:05:20.597" Score="4" Body="&lt;h2&gt;Play Code-Golf!&lt;/h2&gt;&#xA;&lt;p&gt;Yes, the Internet's best&lt;sup&gt;[&lt;a href=&quot;//codegolf.stackexchange.com&quot; title=&quot;A sneaky link to the PPCG homepage&quot;&gt;citation needed&lt;/a&gt;]&lt;/sup&gt; competitive sport has come to Vim. You can try the &lt;a href=&quot;//codegolf.stackexchange.com/questions/tagged/vim&quot; title=&quot;There aren't enough of these...&quot;&gt;vim-only&lt;/a&gt; challenges, or prove Vim's superiority in the standard &lt;a href=&quot;//codegolf.stackexchange.com/questions/tagged/code-golf&quot; title=&quot;Golf with friends for more fun!&quot;&gt;code-golf&lt;/a&gt; challenges. Playing code-golf is a fun way to pass the time for avid Vim fans.&lt;br /&gt;&#xA;&lt;sub&gt;Disclaimer: I am an active user of Programming Puzzles and Code Golf, and am therefore affiliated with it.&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;On a serious note, we do need more puzzles and solutions using / about Vim: at the moment there are only &lt;a href=&quot;//codegolf.stackexchange.com/questions/tagged/vim&quot; title=&quot;There aren't enough of these...&quot;&gt;6 questions about Vim&lt;/a&gt;, and &lt;a href=&quot;//codegolf.stackexchange.com/search?q=vim+is%3Aanswer+-%5Bvim%5D&quot;&gt;72 answers using the language&lt;/a&gt; (excluding on those questions). So if you like Vim, you might like Programming Puzzles and Code Golf.&lt;/p&gt;&#xA;" OwnerUserId="7085" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-04-02T17:05:20.597" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7153" PostTypeId="1" CreationDate="2016-04-02T18:52:41.473" Score="5" ViewCount="1691" Body="&lt;p&gt;There is a (moderately complicated) &lt;a href=&quot;http://vim.wikia.com/wiki/Detect_window_creation_with_WinEnter&quot; rel=&quot;nofollow&quot;&gt;way&lt;/a&gt; to make an autocommand that only runs when windows are created, but I want to have one for when they are removed as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason is that whenever a window is created or removed I'd like to run a function I wrote which calculates window heights and re-assigns them into the open windows. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's mainly about efficient allocation of screen space (tiling). When you remove a window, or add one, any small files may get stretched out into the average height and then it is a pain to shrink them down again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know that there's a way to embed on this site, so here is gfy link. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://gfycat.com/UnrulyLikelyDrever&quot; rel=&quot;nofollow&quot;&gt;https://gfycat.com/UnrulyLikelyDrever&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 9 line file at the bottom ends up taking up half the space once the middle window is closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My routine automates it a bit so it works &lt;em&gt;sort of&lt;/em&gt; like a tiling window system, but since vimscript is missing some API that would make things nicer it is somewhat slow to run (as I have to use &lt;code&gt;wincmd j/k&lt;/code&gt; to move around a bunch inside the function). Therefore I'd like to trigger this only when necessary, which means only when creating or removing entire windows (not upon entry to or exiting focus from them).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed the linked solution for a window open autocommand doesn't even work properly, as I'd really need to have it run &lt;em&gt;after&lt;/em&gt; the buffer has loaded (to know the number of lines in the buffer), but I am willing to accept a half-baked solution at this stage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the point is I need some autocommands that effectively let me find out when window reflow has occurred. Since there's clearly no WindowReflowed autocommand for this I am looking for some hacks.&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="205" LastEditDate="2016-04-03T13:28:45.163" LastActivityDate="2022-01-20T21:42:58.303" Title="How to make an autocommand run for closing a window?" Tags="|vimscript|vim-windows|autocmd|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7154" PostTypeId="2" ParentId="7153" CreationDate="2016-04-02T19:39:03.930" Score="0" Body="&lt;p&gt;I didn't quite understand the functionality you are trying to implement, but I'll try to help anyway.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's an inefficient way, but you can run your function every time you enter a new window, using the &lt;code&gt;WinEnter&lt;/code&gt; event.&lt;br&gt;&#xA;You will obviously run your function a lot more than needed, but it will also run it when a split is being opened or closed. If you aren't doing anything too heavy, you won't notice it running every time you enter a new split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, this command will resize all the splits to be equal every time you open/close a split or move to a different split:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au WinEnter * normal ^W=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;note that &lt;code&gt;^W&lt;/code&gt; is actually &lt;code&gt;Ctrl-w&lt;/code&gt;, inserted by pressing &lt;kbd&gt;Ctrl-v&lt;/kbd&gt; and then &lt;kbd&gt;Ctrl-w&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7087" LastEditorUserId="1841" LastEditDate="2016-04-02T21:12:41.140" LastActivityDate="2016-04-02T21:12:41.140" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7155" PostTypeId="1" AcceptedAnswerId="7156" CreationDate="2016-04-02T20:37:29.143" Score="1" ViewCount="280" Body="&lt;p&gt;I'm trying to remap &lt;kbd&gt;C-o&lt;/kbd&gt; to be 'make new line below' (without going to insert mode, as opposed to &lt;code&gt;o&lt;/code&gt;) and &lt;kbd&gt;C-S-o&lt;/kbd&gt; 'make new line above' (without going to insert mode). I do this a lot when reformatting code. I set a mark so that I end up at the same location:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-o&amp;gt; mxo&amp;lt;Esc&amp;gt;`x&#xA;noremap &amp;lt;C-S-o&amp;gt; mxO&amp;lt;Esc&amp;gt;`x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it inserts a line above in both cases. Why doesn't it work? Can I make it work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using Terminal vim.&lt;/p&gt;&#xA;" OwnerUserId="4947" LastEditorUserId="1841" LastEditDate="2016-04-02T21:14:32.070" LastActivityDate="2016-04-02T21:30:29.220" Title="Mapping C-O and C-S-O" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ClosedDate="2016-04-03T00:00:20.953" ContentLicense="CC BY-SA 3.0" />
  <row Id="7156" PostTypeId="2" ParentId="7155" CreationDate="2016-04-02T21:24:11.927" Score="2" Body="&lt;p&gt;Because that's not possible inside a terminal, both keychords are interpreted as the same control character&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taken from &lt;a href=&quot;http://catern.com/posts/terminal_quirks.html&quot; rel=&quot;nofollow&quot;&gt;http://catern.com/posts/terminal_quirks.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To send a control character to the application running in a terminal, hold down Ctrl while pressing another character. This modifies the sent character code by clearing its 7th and 6th bits (indexed starting at 1).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://sticksandstones.kstrom.com/appen.html&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; you can see that both &lt;code&gt;O&lt;/code&gt; and &lt;code&gt;o&lt;/code&gt; have the binary representation of &lt;code&gt;00001111&lt;/code&gt; if you clear their 7th and 6th bit. Therefore the terminal can't distinguish between those two. That's a well known problem with vim and all terminal applications. It affects other chords with the control character as well.&lt;/p&gt;&#xA;" OwnerUserId="7090" LastEditorUserId="1841" LastEditDate="2016-04-02T21:30:29.220" LastActivityDate="2016-04-02T21:30:29.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7157" PostTypeId="2" ParentId="7122" CreationDate="2016-04-03T01:53:13.447" Score="5" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Install a bunch of colorschemes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Install &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1488&quot;&gt;the ScrollColors.vim plugin&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Split the window several times with several files.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Ensure &lt;code&gt;set mousefocus&lt;/code&gt; and &lt;code&gt;set mouse=a&lt;/code&gt;  (this works better in the GUI).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;au WinEnter * silent CN&lt;/code&gt; – change colorscheme when switching buffer&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Turn off the lights, crack a glow-stick, and wave your mouse around.  Make sure to warn anyone with epilepsy.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://webmshare.com/vAbwz&quot;&gt;http://webmshare.com/vAbwz&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1717" LastEditorUserId="205" LastEditDate="2016-04-03T02:04:04.713" LastActivityDate="2016-04-03T02:04:04.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7158" PostTypeId="2" ParentId="4192" CreationDate="2016-04-03T02:00:04.483" Score="1" Body="&lt;p&gt;I find that the live buffer of the window is available in the python interface. This means I can use python to iterate the lines and compute for myself how many times each line wraps over, and then this can be summed to obtain an estimate of what the real working height of the buffer in the window is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example of how you'd extricate some of this data from vimscript. I wrote this code here to inspect the data structures available inside &lt;code&gt;vim.windows&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python &amp;lt;&amp;lt; EOF                                                                &#xA;for win in vim.windows:                                                          &#xA;    print &quot;, &quot;.join([str(x) for x in [win.col, win.row, win.width, win.height]]);&#xA;    windir = dir(win)                                                            &#xA;    print 'dir: ' + str(windir)                                                  &#xA;    for method in windir:                                                        &#xA;        attr = getattr(win, method)                                              &#xA;        if method == 'buffer':                                                   &#xA;            print '    buffer: length ' + str(len(attr))                         &#xA;            print '    buffer[0]: ' + str(attr[0])                               &#xA;        elif method[0] != '_':                                                   &#xA;            print '    ' + method + ': ' + str(attr)                             &#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some rather annoying things to keep in mind:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;this height i'm talking about depends on the width of the vim window (when wrapping)&lt;/li&gt;&#xA;&lt;li&gt;have to correctly deal with tabs and other chars which take up more space. I am unable to think of anything other than the Tab that has these properties (and even if I did use Unicode characters which I rarely do, I'm pretty sure i've never seen any that are supposed to take up more than one column), and with Tab the semantics seem pretty simple, it will take up exactly &lt;code&gt;&amp;amp;tabstop&lt;/code&gt; columns. &lt;/li&gt;&#xA;&lt;li&gt;the width of the window &lt;em&gt;includes&lt;/em&gt; the numberline. The numberline's width is dependent on the line count of the buffer, but also at least as wide as &lt;code&gt;&amp;amp;numberwidth&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;the width of the window &lt;em&gt;also&lt;/em&gt; includes the sign gutter. Luckily this is only ever a width of 0 or 2, right now all i can figure out is we need to use &lt;code&gt;redir&lt;/code&gt; with &lt;code&gt;sign place [bufnr]&lt;/code&gt; to find out for sure about the presence of this sign column.&lt;/li&gt;&#xA;&lt;li&gt;the type of wrapping (&lt;code&gt;set linebreak&lt;/code&gt;) affects this (Maybe we replicate this wrap-by-word on the python side...)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There may be yet other factors that lead Vim to need more or less space than what we would naively compute in this way. Hopefully &lt;code&gt;linebreak&lt;/code&gt; is one of the few remaining Vim features (maybe, hopefully it's the only one) that affect this. I can confirm that &lt;code&gt;conceal&lt;/code&gt; does not interfere with wrapping offsets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obtaining the height this way should be many times more performant than using vimscript techniques, which invariably result in a lot more Vim frontend logic to execute.&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="390" LastEditDate="2016-04-03T03:04:34.360" LastActivityDate="2016-04-03T03:04:34.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7160" PostTypeId="1" AcceptedAnswerId="7162" CreationDate="2016-04-03T04:15:58.600" Score="3" ViewCount="5714" Body="&lt;p&gt;How do I turn vi colors off? I was using vim-tiny on on Ubuntu 14.04. Installed vim-nox. Version is version 7.4.52. Once I installed that, I got all these syntax colors by default. I have my Terminal set to a black background with bright green text. Now when I use vi with the colors, some of the text is unreadable against the dark background. I would rather just turn the colors off. How do I do this?&lt;/p&gt;&#xA;" OwnerUserId="1705" LastEditorUserId="1705" LastEditDate="2016-04-03T09:31:48.883" LastActivityDate="2016-04-04T11:40:16.703" Title="How do I turn Vi colors off in Ubuntu Linux 14.04" Tags="|syntax-highlighting|colorscheme|linux|bash|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="7161" PostTypeId="2" ParentId="7160" CreationDate="2016-04-03T04:34:30.580" Score="2" Body="&lt;p&gt;You can disable syntax highlighting by doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To turn it back on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax enable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-04-03T04:34:30.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7162" PostTypeId="2" ParentId="7160" CreationDate="2016-04-03T04:48:26.247" Score="7" Body="&lt;p&gt;You can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set t_Co=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will tell Vim that you're not using a colour terminal. The difference with using &lt;code&gt;:syntax off&lt;/code&gt; is that this will still enable &lt;em&gt;some&lt;/em&gt; syntax highlighting features with bold, underlined, and &quot;reverse video&quot;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-04-03T13:46:35.467" LastActivityDate="2016-04-03T13:46:35.467" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7163" PostTypeId="2" ParentId="7138" CreationDate="2016-04-03T05:41:23.297" Score="3" Body="&lt;p&gt;So, what you're asking about is totally possible. Your code is, ultimately, going to consist of a bunch of plain text files (with possibly some assets that are binary, but don't need to be editable). Since that is the case, you can always edit your source code with Vim, and then open Visual Studio to compile/build your project. But, I don't think that's really what you're asking about.&lt;/p&gt;&#xA;&lt;p&gt;If you want to integrate the C compiler released with Visual Studio with your source code, this wouldn't be so hard. You can map &lt;kbd&gt;F9&lt;/kbd&gt; to the command &lt;code&gt;!cl %&lt;/code&gt; which would use the &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/bb384838.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;cl&lt;/code&gt; compiler released with Visual Studio&lt;/a&gt; to compile the working file (I'm sure you can spice that up for passing the proper command line options). Another option would be to use &lt;a href=&quot;https://unix.stackexchange.com/a/52564&quot;&gt;this solution&lt;/a&gt; to set the compiler for all filetype of extension &lt;code&gt;.prog&lt;/code&gt;. That might be a bit more of 'idomatic vim`.&lt;/p&gt;&#xA;&lt;p&gt;Depending on your requirements, this functionality could be obtained with other languages using Visual Studio. But, you would need to be clearer regarding your particular requirements. In the simplest case, you can use the solution posted in the first paragraph.&lt;/p&gt;&#xA;&lt;h3&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/h3&gt;&#xA;&lt;p&gt;&lt;strong&gt;If you're okay with installing a plugin, Tim Pope (@tpope) produced a great plugin, &lt;code&gt;vim-dispatch&lt;/code&gt;, that can asynchronously compile projects and do some other fancy things, like parsing the error report generated by the compiler and automatically opening the quickfix window with all detected warnings/errors. You can easily configure which compiler you would like to use for a given file(type). That seems to be a really good way to go&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;If you're vacillating in regards to using this plugin, I highly recommend watching &lt;a href=&quot;http://vimeo.com/tpope/vim-dispatch-teaser&quot; rel=&quot;nofollow noreferrer&quot;&gt;this video&lt;/a&gt; which @tpope released, demonstrating the power of &lt;code&gt;vim-dispatch&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="2062" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-04-03T18:04:30.153" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7164" PostTypeId="1" CreationDate="2016-04-03T06:09:35.100" Score="1" ViewCount="284" Body="&lt;p&gt;I added &lt;code&gt;:set numberwidth=2&lt;/code&gt; in my vimrc, but this value is always returned to &lt;code&gt;4&lt;/code&gt; inside my windows. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems I need to use some autocommand to always force this value back to &lt;code&gt;2&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, even more alarming: when I force a short file to &lt;code&gt;:set numberwidth=2&lt;/code&gt; manually (to regain two columns of space), once I do ANYTHING at this point, it reverts. Switch window/tab/buffer, enter insert mode (!), you name it. I can move the cursor without it reverting, however. The same behavior is seen with other window-local settings I've tried such as &lt;code&gt;relativenumber&lt;/code&gt;. So I suspect perhaps some plugin might be culpable. But how to debug this?&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I would like to not use an autocommand to do this if necessary&lt;/li&gt;&#xA;&lt;li&gt;I would like to know what are the various things triggering this to reset to the default&lt;/li&gt;&#xA;&lt;li&gt;If I really do must use an autocommand to do this, which autocommand should I use?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="390" LastEditorUserId="390" LastEditDate="2016-04-03T07:18:44.970" LastActivityDate="2016-04-03T07:18:44.970" Title="Some &quot;local to window&quot; settings are being reset in Vim" Tags="|vim-windows|" AnswerCount="1" CommentCount="7" ClosedDate="2016-05-03T07:39:10.423" ContentLicense="CC BY-SA 3.0" />
  <row Id="7165" PostTypeId="2" ParentId="7164" CreationDate="2016-04-03T06:33:09.217" Score="4" Body="&lt;p&gt;The offending plugin is &lt;code&gt;jeffkreeftmeijer/vim-numbertoggle&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll go drop a note on the Github now, and try to debug it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: It's plain to see that the autocommands are being set very promiscuously. I never use this plugin anyway. I'm ditching the plugin obviously, and going to drop a note on the issues.&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2016-04-03T06:33:09.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7166" PostTypeId="1" CreationDate="2016-04-03T07:41:29.707" Score="1" ViewCount="187" Body="&lt;p&gt;I read that in order to navigate backwards in a jumplist. I could use &lt;code&gt;ctrl+i&lt;/code&gt;. However I noticed that if i press that key combination extra times vim opens up files that were loaded in vim before. I am familiar with the concept of buffers and my first thought was that the file that was being loaded up was present in the buffer so I did a &lt;code&gt;ls&lt;/code&gt; and the name of that file did not show up. My question is I would like to know why when the key combination &lt;code&gt;ctrl + i&lt;/code&gt; is pressed multiple times it loads up older documents. How can I prevent documents that are not currently open from opening up when navigation backwards over a jumplist using &lt;code&gt;Ctrl+i&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="7064" LastEditorUserId="51" LastEditDate="2016-08-08T01:54:26.210" LastActivityDate="2016-08-08T01:54:26.210" Title="ctrl+i loads older documents loaded in vim" Tags="|jumplist|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7167" PostTypeId="1" AcceptedAnswerId="7288" CreationDate="2016-04-03T07:52:30.713" Score="1" ViewCount="1104" Body="&lt;p&gt;I really like to jump from one &lt;code&gt;&amp;lt;el&amp;gt;&lt;/code&gt; to the end of &lt;code&gt;&amp;lt;/el&amp;gt;&lt;/code&gt; with matchit. I am using it for jsx, but it does not seem to work if I have an element that is declared with &lt;code&gt;/&amp;gt;&lt;/code&gt;, does anybody have an idea how to fix the issue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example of what is not working:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Scene key=&quot;tabbar&quot; component={NavigationDrawer}  initial={true}&amp;gt;&#xA;  &amp;lt;Scene key=&quot;main&quot; tabs={true} default=&quot;tab2&quot; &amp;gt;&#xA;    &amp;lt;Scene key=&quot;tab1&quot;  title=&quot;Tab #1&quot; icon={TabIcon} navigationBarStyle={{backgroundColor:&quot;red&quot;}} titleStyle={{color:&quot;white&quot;}}&amp;gt;&#xA;      &amp;lt;Scene key=&quot;tab1_1&quot; component={TabView} title=&quot;Tab #1_1&quot; onRight={()=&amp;gt;alert(&quot;Right button&quot;)} rightTitle=&quot;Right&quot; /&amp;gt;&#xA;      &amp;lt;Scene key=&quot;tab1_2&quot; component={TabView} title=&quot;Tab #1_2&quot; titleStyle={{color:&quot;black&quot;}}/&amp;gt;&#xA;    &amp;lt;/Scene&amp;gt;&#xA;    &amp;lt;Scene key=&quot;tab2&quot; initial={true} title=&quot;Tab #2&quot; icon={TabIcon}&amp;gt;&#xA;      &amp;lt;Scene key=&quot;tab2_1&quot; component={TabView} title=&quot;Tab #2_1&quot;/&amp;gt;&#xA;      &amp;lt;Scene key=&quot;tab2_2&quot; component={TabView} title=&quot;Tab #2_2&quot; onLeft={()=&amp;gt;alert(&quot;Left button!&quot;)} leftTitle=&quot;Left&quot; duration={1} panHandlers={null}/&amp;gt;&#xA;    &amp;lt;/Scene&amp;gt;&#xA;    &amp;lt;Scene key=&quot;tab3&quot; component={TabView} title=&quot;Tab #3&quot; hideTabBar={true} icon={TabIcon}/&amp;gt;&#xA;    &amp;lt;Scene key=&quot;tab4&quot; component={TabView} title=&quot;Tab #4&quot; hideNavBar={true} icon={TabIcon}/&amp;gt;&#xA;    &amp;lt;Scene key=&quot;tab5&quot; component={TabView} title=&quot;Tab #5&quot; icon={TabIcon} renderRightButton={()=&amp;gt;&amp;lt;Right/&amp;gt;}/&amp;gt;&#xA;  &amp;lt;/Scene&amp;gt;&#xA;&amp;lt;/Scene&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want for example to go from the first Scene open &lt;code&gt;&amp;lt;Scene&amp;gt;&lt;/code&gt; to the end &lt;code&gt;&amp;lt;/Scene&amp;gt;&lt;/code&gt;. However when I press &lt;code&gt;%&lt;/code&gt;, nothing happens.&lt;/p&gt;&#xA;" OwnerUserId="3003" LastEditorUserId="3003" LastEditDate="2016-04-03T09:28:42.623" LastActivityDate="2020-04-11T19:40:56.670" Title="How do I get matchit to work with '/&gt;' (self-closed tags)?" Tags="|cursor-motions|filetype-javascript|plugin-matchit|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7168" PostTypeId="2" ParentId="4192" CreationDate="2016-04-03T09:23:40.637" Score="1" Body="&lt;p&gt;It is better to employ &lt;code&gt;strdisplaywidth()&lt;/code&gt; for this job. It takes things like number, fold and sign columns into account as well as &lt;code&gt;&amp;amp;linebreak&lt;/code&gt;, &lt;code&gt;&amp;amp;showbreak&lt;/code&gt; and &lt;code&gt;&amp;amp;breakindent&lt;/code&gt; option effects. Problem is that you still have to somehow calculate width of the window available for text (i.e. exclude widths of number, fold and sign columns): &lt;code&gt;strdisplaywidth()&lt;/code&gt; returns how many display cells are occupied, but it does not tell you how many display cells there are. The following code should do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function WinTextWidth()&#xA;    let winwidth = winwidth(0)&#xA;    let winwidth -= (max([len(line('$')), &amp;amp;numberwidth]) * (&amp;amp;number || &amp;amp;relativenumber))&#xA;    let winwidth -= &amp;amp;foldcolumn&#xA;    redir =&amp;gt; signs&#xA;    execute 'silent sign place buffer=' . bufnr('%')&#xA;    redir END&#xA;    if signs !~# '^\n---[^\n]*\n$'&#xA;        let winwidth -= 2&#xA;    endif&#xA;    return winwidth&#xA;endfunction&#xA;function LineCount(...)&#xA;    let startlnr = get(a:000, 0, 1)&#xA;    let endlnr = get(a:000, 1, line('$'))&#xA;    let numlines = 0&#xA;    let winwidth = WinTextWidth()&#xA;    for lnr in range(startlnr, endlnr)&#xA;        let lwidth = strdisplaywidth(getline(lnr))&#xA;        let numlines += max([(lwidth - 1) / winwidth + 1, 1])&#xA;    endfor&#xA;    return numlines&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;strdisplaywidth(getline(lnr))&lt;/code&gt; may also be replaced with &lt;code&gt;virtcol([lnr, '$']) - 1&lt;/code&gt;, this should be slightly faster and more compatible with older Vim versions.&lt;/p&gt;&#xA;" OwnerUserId="2566" LastEditorUserId="2566" LastEditDate="2016-04-05T01:47:10.553" LastActivityDate="2016-04-05T01:47:10.553" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="7169" PostTypeId="2" ParentId="7166" CreationDate="2016-04-03T09:57:29.757" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My question is I would like to know why when the key combination &lt;code&gt;ctrl + i&lt;/code&gt; is pressed multiple times it loads up older documents.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Because that's how Vim works. From different places near &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#jumplist&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h jumplist&lt;/code&gt;&lt;/a&gt; you can read:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;A &quot;jump&quot; is one of the following commands: &quot;'&quot;, &quot;`&quot;, &quot;G&quot;, &quot;/&quot;, &quot;?&quot;, &quot;n&quot;,&#xA;  &quot;N&quot;, &quot;%&quot;, &quot;(&quot;, &quot;)&quot;, &quot;[[&quot;, &quot;]]&quot;, &quot;{&quot;, &quot;}&quot;, &quot;:s&quot;, &quot;:tag&quot;, &quot;L&quot;, &quot;M&quot;, &quot;H&quot; and&#xA;  the commands that start editing a new file.  If you make the cursor &quot;jump&quot;&#xA;  with one of these commands, the position of the cursor before the jump is&#xA;  remembered.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;Jumps are remembered in a jump list.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you have included the ' item in the 'viminfo' option the jumplist will be stored in the viminfo file and restored when starting Vim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The jumplist was designed the ease the navigation between previous locations in the files, it is normal that it remembers all of these locations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now about your second question:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I prevent documents that are not currently open from opening up when navigation backwards over a jumplist using Ctrl+i ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't know of an easy way to do so. One could imagine a piece of Vimscript which would remap &lt;kbd&gt;ctrl+i&lt;/kbd&gt; to check the position in the jumplist, check is the buffer is present in the buffer list and decide if it should make the jump or check the previous one (unfortunately I don't have time to develop that now).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you still could be interested by the &lt;code&gt;keepjumps&lt;/code&gt; command (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#:keepjumps&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :keepjumps&lt;/code&gt;&lt;/a&gt;). When a normal command is preceded by &lt;code&gt;keepjumps&lt;/code&gt; it doesn't update the jumplist, that can be useful in some cases.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-04-03T09:57:29.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7170" PostTypeId="2" ParentId="7153" CreationDate="2016-04-03T12:00:29.647" Score="4" Body="&lt;p&gt;You could listen to &lt;code&gt;WinEnter&lt;/code&gt; and then compare &lt;code&gt;winnr('$')&lt;/code&gt; result to the previous one you could have memorized for the current tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the number increases, it means &quot;new window&quot;, a decrease will mean &quot;a window has been closed&quot;&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-02-21T14:08:03.520" LastActivityDate="2018-02-21T14:08:03.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7171" PostTypeId="2" ParentId="7160" CreationDate="2016-04-03T14:15:55.697" Score="5" Body="&lt;p&gt;Just discovered this after viewing &lt;code&gt;/etc/vim/vimrc&lt;/code&gt; for the first time. Uncommenting the line &quot;&lt;code&gt;set background=dark&lt;/code&gt;&quot; in &lt;code&gt;vimrc&lt;/code&gt; solves my readability problem also. It changes the syntax colors so that they are distinguishable against my black background! This is actually better than what I had hoped for in the original question!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Presumably &lt;code&gt;:set background=dark&lt;/code&gt; would have worked, too? Or something like that?)&lt;/p&gt;&#xA;" OwnerUserId="1705" LastEditorUserId="1705" LastEditDate="2016-04-04T11:40:16.703" LastActivityDate="2016-04-04T11:40:16.703" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7173" PostTypeId="1" CreationDate="2016-04-03T22:23:51.987" Score="3" ViewCount="84" Body="&lt;p&gt;So, I have installed Vimium today, and when I first relaunched MacVim, my Little Snitch showed that it tried to connect to &lt;code&gt;vimium.github.io&lt;/code&gt;, which it never did before. Why did it do that and how has MacVim found out about Vimium in the first place?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Zbc1Y.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Zbc1Y.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5965" LastEditorUserId="5965" LastEditDate="2016-04-03T22:42:03.957" LastActivityDate="2016-04-03T22:42:03.957" Title="Why did MacVim try to connect to Vimium server?" Tags="|macvim|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7174" PostTypeId="1" AcceptedAnswerId="7175" CreationDate="2016-04-04T00:49:47.103" Score="3" ViewCount="1825" Body="&lt;p&gt;My vimrc sets the shell option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;shell='/bin/bash -i'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which I confirm using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &amp;amp;shell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-i&lt;/code&gt; makes the shell interactive.  I want to do this so that it runs &lt;code&gt;~/.bashrc&lt;/code&gt;, which contains the setting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;shopt -s extglob&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;extglob&lt;/code&gt; was not being set because &lt;code&gt;~/.bashrc&lt;/code&gt; was not being run, which in turn seems to be because the shell is not interactive.  I determined this by putting the vim cursor on each the following lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo $-&#xA;echo $PS1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and issuing the normal mode command &lt;code&gt;!!bash&lt;/code&gt;.  According to &lt;a href=&quot;http://www.gnu.org/software/bash/manual/html_node/Is-this-Shell-Interactive_003f.html&quot; rel=&quot;nofollow&quot;&gt;the Bash manual&lt;/a&gt;, the string returned by the first command should include the letter &lt;code&gt;i&lt;/code&gt; if the shell is interactive, while the string returned by the second command should include the text and control characters for the prompt that is shown at the bash command line (as opposed to nothing).  Both tests show the shell to be not interactive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why would the &lt;code&gt;-i&lt;/code&gt; flag in the shell option be ignored?  What further troubleshooting steps can I take?&lt;/p&gt;&#xA;" OwnerUserId="7041" LastEditorUserId="205" LastEditDate="2016-04-04T01:31:43.403" LastActivityDate="2016-04-04T07:00:36.950" Title="Why is bash not interactive after setting &amp;shell='/bin/bash -i'?" Tags="|bash|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7175" PostTypeId="2" ParentId="7174" CreationDate="2016-04-04T01:30:27.147" Score="6" Body="&lt;p&gt;Your test is flawed. If you run &lt;code&gt;!!bash&lt;/code&gt;, you're calling just the &lt;code&gt;bash&lt;/code&gt; command explicitly. Why would you expect &lt;code&gt;bash&lt;/code&gt; to be interactive in that case?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;!!&lt;/code&gt; is shorthand for &lt;code&gt;:.!&lt;/code&gt;, so you're running &lt;code&gt;:.!bash&lt;/code&gt;, which would become something like: &lt;code&gt;bash -i -c 'bash'&lt;/code&gt;. So the first &lt;code&gt;bash&lt;/code&gt; might have &lt;code&gt;extglob&lt;/code&gt; set, but the second won't. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run &lt;code&gt;:!echo $-&lt;/code&gt; for a better test:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;himBHc&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, the command run by Vim would look like: &lt;code&gt;bash -i -c 'echo $-'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do want to test with &lt;code&gt;!!&lt;/code&gt;, use the &lt;code&gt;pstree&lt;/code&gt; command (&lt;code&gt;pstree -psa $$&lt;/code&gt;) to see what the parent process is. In my case, the relevant part is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  `-vim,13387&#xA;      `-bash,13527 -i -c (bash) &amp;lt; /tmp/vAaJ5gB/7 &amp;gt;/tmp/vAaJ5gB/8 2&amp;gt;&amp;amp;1&#xA;          `-bash,13530&#xA;              `-pstree,13531 -psa 13530&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, Vim did call it with &lt;code&gt;-i&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or just run &lt;code&gt;:!shopt nullglob&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nullglob        on&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;By the way, the Vim way to add an option to the shell being used to run &lt;code&gt;:!&lt;/code&gt; commands is &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27shellcmdflag%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;shellcmdflag&lt;/code&gt;&lt;/a&gt;. From &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3A%21&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :!&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;On Unix the command normally runs in a non-interactive&#xA;shell.  If you want an interactive shell to be used&#xA;(to use aliases) set 'shellcmdflag' to &quot;-ic&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Invoked-non_002dinteractively&quot; rel=&quot;nofollow&quot;&gt;the Bash manual&lt;/a&gt;, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h3&gt;Invoked non-interactively&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;When Bash is started non-interactively, to run a shell script, for&#xA;  example, it looks for the variable &lt;code&gt;BASH_ENV&lt;/code&gt; in the environment,&#xA;  expands its value if it appears there, and uses the expanded value as&#xA;  the name of a file to read and execute. Bash behaves as if the&#xA;  following command were executed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [ -n &quot;$BASH_ENV&quot; ]; then . &quot;$BASH_ENV&quot;; fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;but the value of the &lt;code&gt;PATH&lt;/code&gt; variable is not used to search for the&#xA;  filename.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So a simple way to affect invocations of &lt;code&gt;!!bash&lt;/code&gt;, would be to set &lt;code&gt;BASH_ENV=~/.bash_extra&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $BASH_ENV=&quot;~/.bash_extra&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;~/.bash_extra&lt;/code&gt; would contain (among any other settings you need):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;shopt -s nullglob&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using an interactive shell has undesirable effects, like the output being cluttered with your prompt. This avoids that.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-04-04T07:00:36.950" LastActivityDate="2016-04-04T07:00:36.950" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7176" PostTypeId="1" AcceptedAnswerId="7177" CreationDate="2016-04-04T05:36:44.190" Score="8" ViewCount="2061" Body="&lt;p&gt;My color scheme has:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Cursor       ctermfg=black   ctermbg=red cterm=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is confirmed using &lt;code&gt;hi Curosr&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Cursor         xxx ctermfg=0 ctermbg=1 guifg=black guibg=orange&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I'm not getting the desired color in cygwin's mintty.  When the cursor blinks, I get a white back ground with black letters (which is visible enough, since the surrounding text is white on blue).  Unfortunately, it &lt;em&gt;doesn't&lt;/em&gt; show up well with my &lt;code&gt;CursorLine&lt;/code&gt; and &lt;code&gt;CursorColumn&lt;/code&gt; colors.  How can I troubleshoot the cause for my &lt;code&gt;Cursor&lt;/code&gt; colors being ignored?&lt;/p&gt;&#xA;" OwnerUserId="7041" LastActivityDate="2016-04-04T06:59:13.343" Title="Why is `:highlight Cursor ...` ignored?" Tags="|highlight|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7177" PostTypeId="2" ParentId="7176" CreationDate="2016-04-04T06:59:13.343" Score="14" Body="&lt;p&gt;Playing with the &lt;code&gt;Cursor&lt;/code&gt; highlight group is a waste of time because the cursor color is handled by your terminal emulator, not by Vim.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-04T06:59:13.343" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7179" PostTypeId="1" AcceptedAnswerId="7241" CreationDate="2016-04-04T11:31:04.650" Score="5" ViewCount="300" Body="&lt;p&gt;Sometimes ex commands have the useless side effect of jumping, probably to the last place they affected. Can this be prevented? I would prefer it if ex commands left my screen exactly the same as before their execution.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2016-04-04T15:37:42.810" LastActivityDate="2016-04-12T15:21:04.080" Title="Preventing ex commands from altering the screen" Tags="|command-line|" AnswerCount="2" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7181" PostTypeId="2" ParentId="5514" CreationDate="2016-04-04T12:29:21.160" Score="0" Body="&lt;p&gt;I think it is very hard to make the comparison, because of the changes in vi that have happened over time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I was in college, I used plain-vanilla vi on a dumb terminal (and also on a terminal emulator on a Mac) that connected to mainframes using System V. You can't even find that any more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'm not even sure that was true vi. About that time there were lots of clones and ports made because vi wasn't open-source at the time. And when vendors made clones, they added features that weren't in vi. The history is kind of convoluted. You can read it on Wikipedia and elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you weren't using certain vendors/hardware, you weren't using vi, but something &lt;em&gt;like&lt;/em&gt; vi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I do recall vi (or the clone I was using) being very minimalist in its interface (no colors, no INSERT labels, no mulitple undos, etc.) yet powerful in what it could actually accomplish. Very practical.&lt;/p&gt;&#xA;" OwnerUserId="1705" LastActivityDate="2016-04-04T12:29:21.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7182" PostTypeId="2" ParentId="5514" CreationDate="2016-04-04T13:17:13.483" Score="4" Body="&lt;p&gt;Most comparisons give more functionality to Vim than to vi, but there is one exception. There was an &quot;open&quot; mode in vi, and Vim doesn't really have this mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open mode is a single-line mode that was used back in the day with terminals that didn't have electronic displays, i.e. teletypes, letterprinters, and the like, and also with displays where the cursor remains only at the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there is documentation out there that says Vim simulates open mode, but my experience is that it doesn't. For I have seen it used with vi with my own eyes, and I have never seen Vim do it. It seems that Vim just uses the &lt;code&gt;open&lt;/code&gt; command simply to open and edit a file in visual mode. I do believe that Vim's official documentation states that it does not support open mode.&lt;/p&gt;&#xA;" OwnerUserId="1705" LastEditorUserId="927" LastEditDate="2020-01-03T15:37:14.483" LastActivityDate="2020-01-03T15:37:14.483" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7183" PostTypeId="1" AcceptedAnswerId="7184" CreationDate="2016-04-04T14:07:22.027" Score="3" ViewCount="1616" Body="&lt;p&gt;When I have to work on Windows I have the habit to reduce my windows with the key combo &lt;kbd&gt;Alt-Space&lt;/kbd&gt;+&lt;kbd&gt;u&lt;/kbd&gt; &lt;em&gt;(&lt;kbd&gt;Alt-Space&lt;/kbd&gt; will pop the window menu and &lt;kbd&gt;u&lt;/kbd&gt; is the shortcut to minimize the window and may change depending on the language of your system)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is pretty useful but Vim takes control of all Alt- combinations, to increase the number of possible mappings which prevent me from using this combination. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I do to use &lt;kbd&gt;Alt-Space-u&lt;/kbd&gt; to reduce gVim in Windows?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-04-04T14:07:22.027" Title="How to use &lt;Alt-Space&gt; to open the window menu on Windows?" Tags="|key-bindings|gvim|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7184" PostTypeId="2" ParentId="7183" CreationDate="2016-04-04T14:07:22.027" Score="3" Body="&lt;p&gt;&lt;em&gt;(I actually found a solution while writing my question and thought it could be useful to other people)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27winaltkeys%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 'winaltkeys'&lt;/code&gt;&lt;/a&gt; setting &lt;code&gt;winaltkeys&lt;/code&gt; to &lt;code&gt;yes&lt;/code&gt; should tell Vim to let the windowing system handle the combinations of &lt;kbd&gt;alt&lt;/kbd&gt; and another key &lt;em&gt;(setting it to &lt;code&gt;menu&lt;/code&gt; should tell Vim to let the windowing system handle &lt;kbd&gt;Alt&lt;/kbd&gt; + a menu key)&lt;/em&gt;. Unfortunately for a reason that I ignore, this option still doesn't let me use &lt;kbd&gt;Alt+Space&lt;/kbd&gt; on Windows. So I found another option:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to create the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;M-Space&amp;gt; :simalt ~&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;simalt&lt;/code&gt; command allows Vim to fake a Windows-style Alt keypress. This way when I press &lt;kbd&gt;Alt-Space&lt;/kbd&gt; I get this convenient pop up menu and I then can press &lt;kbd&gt;u&lt;/kbd&gt; to reduce my gVim Window.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-04-04T14:07:22.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7188" PostTypeId="1" AcceptedAnswerId="7192" CreationDate="2016-04-04T17:45:49.667" Score="3" ViewCount="721" Body="&lt;p&gt;I have a terminal color scheme that makes the default highlighting settings for diffs relatively hard to read. To address this, I’ve added my own custom settings inside of &lt;code&gt;~/.vim/after/syntax/diff.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi diffAdded term=NONE ctermfg=Green &#xA;hi diffRemoved term=NONE ctermfg=Red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works great for &lt;code&gt;git diff&lt;/code&gt;, for example, but the customizations do &lt;em&gt;not&lt;/em&gt; apply when I use &lt;code&gt;git commit -v&lt;/code&gt;, so I still get unreadable diffs. I looked in the syntax definition for &lt;code&gt;gitcommit.vim&lt;/code&gt;, and I noticed that it uses &lt;code&gt;syn include&lt;/code&gt; to create a nested region:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; gitcommit.vim&#xA;syn include @gitcommitDiff syntax/diff.vim&#xA;syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ fold contains=@gitcommitDiff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since it looks like it just uses &lt;code&gt;diff.vim&lt;/code&gt; under the hood, I figured that copying my custom styles to &lt;code&gt;~/.vim/after/syntax/gitcommit.vim&lt;/code&gt; would do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; identical to diff.vim&#xA;hi diffAdded term=NONE ctermfg=Green&#xA;hi diffRemoved term=NONE ctermfg=Red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this doesn’t seem to work—vim still uses the default syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What’s wrong? How can I customize the syntax highlighting for a region included with &lt;code&gt;syn include&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="354" LastActivityDate="2016-04-05T06:11:40.473" Title="Adjust syntax highlighting for region included with syn-include?" Tags="|vimscript|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7189" PostTypeId="2" ParentId="319" CreationDate="2016-04-04T18:04:10.083" Score="5" Body="&lt;p&gt;You are looking for the filter commands in Vim. See &lt;code&gt;:help filter&lt;/code&gt;. Here is the relevant documentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!{motion}{filter}   Filter {motion} text lines through the external&#xA;                    program {filter}.&#xA;!!{filter}          Filter [count] lines through the external program&#xA;                    {filter}.&#xA;{Visual}!{filter}   Filter the highlighted lines through the external&#xA;                    program {filter} (for {Visual} see |Visual-mode|).&#xA;                    {not in Vi}&#xA;&#xA;:{range}![!]{filter} [!][arg]               *:range!*&#xA;                    Filter {range} lines through the external program&#xA;                   {filter}.  ...[See documentation for details]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So typing &lt;code&gt;5!!sort&lt;/code&gt; will sort the next 5 lines starting from the cursor.&lt;/p&gt;&#xA;" OwnerUserId="2279" LastActivityDate="2016-04-04T18:04:10.083" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7190" PostTypeId="1" CreationDate="2016-04-05T04:47:21.743" Score="4" ViewCount="1639" Body="&lt;p&gt;According to the Vim help, using &lt;code&gt;g CTRL-A&lt;/code&gt; with visual mode should change several lines in A to that in B:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.    &#xA;1.    &#xA;1.    &#xA;1.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;B:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.    &#xA;2.    &#xA;3.    &#xA;4.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my Vim, the &lt;code&gt;CTRL-A&lt;/code&gt; is working in normal mode, which increments a number. But when I am using visual mode, whether it is linewise, block or visual, it will not work. For example, when I press &lt;code&gt;CTRL-A&lt;/code&gt; in a help file, it will have this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E21: Cannot make changes, 'modifiable' is off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I use visual mode, there is no such error and no change happens. The same goes for &lt;code&gt;g CTRL-A&lt;/code&gt; and for an editable file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I solve this problem? There are no requisites listed on the manual of this feature, so I probably won't need to recompile the Vim again?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;EDIT:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;E21&lt;/code&gt; is not the real problem, I just want to use it as an indicator that it doesn't work, i.e. it doesn't change or try to change anything.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:ver&lt;/code&gt; first line output: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 13 2016 12:09:32)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Included patches: 1-1725&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6380" LastEditorUserId="6380" LastEditDate="2016-05-04T03:25:11.453" LastActivityDate="2016-05-04T03:25:11.453" Title="CTRL-A with visual mode not working" Tags="|visual-mode|text-generation|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7191" PostTypeId="2" ParentId="7190" CreationDate="2016-04-05T05:41:00.270" Score="-2" Body="&lt;p&gt;Seems like &lt;code&gt;c-a&lt;/code&gt; has been mapped to some plugin in your vim. (In that plugin, &lt;code&gt;c-a&lt;/code&gt; is mapped to some 'modifiable' action, so that you get that error message....)&#xA;You might try &lt;code&gt;:vmap&lt;/code&gt; to list all key mappings in visual mode and check if there is some plugin or custom key binding who is using &lt;code&gt;c-a&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6731" LastActivityDate="2016-04-05T05:41:00.270" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7192" PostTypeId="2" ParentId="7188" CreationDate="2016-04-05T06:11:40.473" Score="3" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:syntax&lt;/code&gt; defines, well, syntax. It says &quot;if text matches this regular expression, it's a string&quot;, and so forth. To do so, it assigns a &lt;em&gt;highlight group&lt;/em&gt;. It doesn &lt;em&gt;not&lt;/em&gt; say anything about colours.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:highlight&lt;/code&gt; says &quot;highlight this group with these colours&quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Whatever &lt;code&gt;:syntax&lt;/code&gt; does is fairly irrelevant if you just want to change some colours. All we need to know is the correct highlight group that is assigned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is also how colour schemes work. Colour schemes are nothing more than a set of &lt;code&gt;highlight&lt;/code&gt; statements for a bunch of standard groups (&lt;code&gt;String&lt;/code&gt;, &lt;code&gt;Identifier&lt;/code&gt;, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no need to put &lt;code&gt;highlight&lt;/code&gt; statements in &lt;code&gt;~/.vim/after/syntax/diff.vim&lt;/code&gt;, since syntax files don't define these. This is only required for &lt;code&gt;:syntax&lt;/code&gt; rules.&lt;sup&gt;1&lt;/sup&gt; There is also no relation between the diff syntax being used with &lt;code&gt;syn include&lt;/code&gt; and nested and your custom &lt;code&gt;highlight&lt;/code&gt; not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight diffAdded ctermbg=green&#xA;highlight diffRemoved ctermbg=red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your vimrc should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;highlight&lt;/code&gt;s &lt;em&gt;are&lt;/em&gt; reset when setting colour schemes  So I typically do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:color()&#xA;    highlight diffAdded ctermbg=green&#xA;    highlight diffRemoved ctermbg=red&#xA;endfun&#xA;call s:color()&#xA;augroup my_colors&#xA;    autocmd!&#xA;    autocmd Colorscheme * call s:color()&#xA;augroup end &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make sure the custom &lt;code&gt;highlight&lt;/code&gt;s are always applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps this is the reason it doesn't work for you?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;: There is one exceptions to this: when you want to link a highlight group to another highlight group. But this is rare.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-04-05T06:11:40.473" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7193" PostTypeId="1" AcceptedAnswerId="7293" CreationDate="2016-04-05T07:34:10.860" Score="5" ViewCount="610" Body="&lt;p&gt;I noticed that vi's auto format adds two spaces after a full stop. I wonder how this can be changed, i.e., insert just one space after a full stop, or even a line break.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The application is in using a line based version control system such as &lt;code&gt;git&lt;/code&gt; for editing text documents (&lt;code&gt;LaTeX&lt;/code&gt; in particular). With the convetion of breaking lines at full stops, changes to an autoformatted paragraph would be confined to modified sentences.&lt;/p&gt;&#xA;" OwnerUserId="5919" LastActivityDate="2016-04-12T02:26:56.427" Title="Make autoformating insert a line break instead of two spaces after full stop" Tags="|formatting|filetype-tex|git|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7194" PostTypeId="1" AcceptedAnswerId="7195" CreationDate="2016-04-05T09:58:21.527" Score="4" ViewCount="1757" Body="&lt;p&gt;I've file in which there are some repeated parts and I want to get rid of the first occurrence. Normally I'd do &lt;code&gt;%s/_exclude//&lt;/code&gt; to perform substitute for all lines, however I want to replace only the first occurrence in the file, e.g. having: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name = foo&#xA;# unknown number of lines ...&#xA;features_exclude[rules_config][] = rule1 &#xA;features_exclude[rules_config][] = rule2 &#xA;features_exclude[rules_config][] = rule3 &#xA;features_exclude[rules_config][] = rule4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to do remove first occurrence of &lt;code&gt;_exclude&lt;/code&gt;, so it becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name = foo&#xA;# unknown number of lines ...&#xA;features[rules_config][] = rule1 &#xA;features_exclude[rules_config][] = rule2 &#xA;features_exclude[rules_config][] = rule3 &#xA;features_exclude[rules_config][] = rule4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if I repeat the action again, it'll remove the next one (on whichever line it is) and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the easiest way of doing that?&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2016-04-05T10:43:43.340" Title="How to substitute the first occurrence across the whole file?" Tags="|substitute|" AnswerCount="1" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7195" PostTypeId="2" ParentId="7194" CreationDate="2016-04-05T10:38:31.547" Score="8" Body="&lt;p&gt;Here is the method using pattern matches:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/_exclude/s/_exclude//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will first identify the line which has &lt;code&gt;_exclude&lt;/code&gt;, then do the substitution on that line (&lt;code&gt;s/_exclude//&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To repeat the last command-line change, use the &lt;code&gt;@:&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This can be simplified further more as per &lt;a href=&quot;https://vi.stackexchange.com/questions/7194/how-to-substitute-the-first-occurrence-across-the-whole-file/7195#comment11821_7195&quot;&gt;@muru&lt;/a&gt; suggestion by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/_exclude/s///&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;since an empty pattern will use the previous pattern.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-04-05T10:43:43.340" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7196" PostTypeId="2" ParentId="6772" CreationDate="2016-04-05T10:59:27.677" Score="1" Body="&lt;p&gt;I was having issues with this too - Vim, YouCompleteMe and Python all need to be of the same 'bitness' ie. 32 bit or 64 bit. As well, the version of Vim needs to be built with &lt;code&gt;+python&lt;/code&gt; support and linked to the correct versions of the Python dlls (currently Python 2.7.11 does not work).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I put together a script that installs the prerequisites and builds these components as 64 bit located &lt;a href=&quot;https://github.com/wilvk/winvimbuild&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; that may help. (Note: It takes a while to run)&lt;/p&gt;&#xA;" OwnerUserId="7119" LastEditorUserId="7119" LastEditDate="2016-04-05T11:16:37.933" LastActivityDate="2016-04-05T11:16:37.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7197" PostTypeId="5" CreationDate="2016-04-05T11:15:15.623" Score="0" Body="&lt;p&gt;The plugin comes packaged with newer versions of vim and can be enabled by adding the following line to the &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;runtime macros/matchit.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or installed as a 'normal' plugin using the &lt;a href=&quot;https://github.com/chrisbra/matchit&quot; rel=&quot;nofollow noreferrer&quot;&gt;matchit&lt;/a&gt; repository.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="23502" LastEditDate="2023-02-01T15:11:32.047" LastActivityDate="2023-02-01T15:11:32.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7198" PostTypeId="4" CreationDate="2016-04-05T11:15:15.623" Score="0" Body="This plugin makes the &quot;%&quot; command jump to matching HTML tags,&#xD;&#xA;if/else/endif in Vim scripts, etc." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-05T11:15:15.623" LastActivityDate="2016-04-05T11:15:15.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7199" PostTypeId="5" CreationDate="2016-04-05T11:17:37.093" Score="0" Body="&lt;p&gt;The plugin can be installed with the common plugin manager from &lt;a href=&quot;https://github.com/vim-pandoc/vim-pandoc&quot; rel=&quot;nofollow&quot;&gt;this github repository&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-05T11:17:37.093" LastActivityDate="2016-04-05T11:17:37.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7200" PostTypeId="4" CreationDate="2016-04-05T11:17:37.093" Score="0" Body="A plugin which provides facilities to integrate Vim with the pandoc document converter and work with documents written in its markdown variant " OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-05T11:17:37.093" LastActivityDate="2016-04-05T11:17:37.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7201" PostTypeId="1" AcceptedAnswerId="7212" CreationDate="2016-04-05T11:21:32.603" Score="5" ViewCount="988" Body="&lt;p&gt;I've the file, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name = foo&#xA;# unknown number of lines ...&#xA;features_exclude[rules_config][] = rule1 &#xA;features_exclude[rules_config][] = rule2 &#xA;features_exclude[rules_config][] = rule3 &#xA;features_exclude[rules_config][] = rule4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'd like to run &lt;a href=&quot;https://vi.stackexchange.com/a/7195/467&quot;&gt;&lt;code&gt;:/_exclude/s///&lt;/code&gt;&lt;/a&gt; command on it and repeat it one more time (&lt;code&gt;@:&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried things suggested in &lt;a href=&quot;https://vi.stackexchange.com/q/5165/467&quot;&gt;here&lt;/a&gt;, however it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when using &lt;code&gt;@:&lt;/code&gt; to repeat the last command-line change, it gives me the error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E30: No previous command line&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So it seems it doesn't recognise what was the previous command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex '+:/_exclude/s///p' '+@:' -scwq -V1 foo.txt &#xA;&quot;foo.txt&quot; &#xA;&quot;foo.txt&quot; 10 lines, 375 characters&#xA;search hit BOTTOM, continuing at TOP&#xA;features[rules_config][] = rule1 &#xA;&#xA;Error detected while processing command line:&#xA;E30: No previous command line&#xA;&quot;foo.txt&quot; &#xA;&quot;foo.txt&quot; 10 lines, 367 characters written&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is that?&#xA;Are there any other reliable ways of repeating the last Ex command?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-04-05T13:15:49.503" Title="How to repeat the last command in Ex?" Tags="|repeated-commands|ex-command|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7202" PostTypeId="2" ParentId="7201" CreationDate="2016-04-05T11:38:48.237" Score="3" Body="&lt;p&gt;I imagine there must be an easier way. Since &lt;code&gt;@:&lt;/code&gt; is accessing a special register, you can use registers yourself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -Nesc &quot;:let @a = '/_exclude/s///p'&quot; +@a +@a +wq foo    &#xA;features[rules_config][] = rule1 &#xA;features[rules_config][] = rule2 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-04-05T11:38:48.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7203" PostTypeId="5" CreationDate="2016-04-05T11:49:18.793" Score="0" Body="&lt;p&gt;The official page of the plugin can be found &lt;a href=&quot;http://vim-taglist.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. To work properly the plugin relies on the &lt;a href=&quot;http://ctags.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;exuberant ctags program&lt;/a&gt; which allows to generate the tag file of a code project and is available on Unix and Windows systems.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-05T11:49:18.793" LastActivityDate="2016-04-05T11:49:18.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7204" PostTypeId="4" CreationDate="2016-04-05T11:49:18.793" Score="0" Body="The Taglist plugin is a source code browser plugin which&#xD;&#xA;provides an overview of the structure of source code files and allows&#xD;&#xA;you to efficiently browse through source code files for different&#xD;&#xA;programming languages." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-05T11:49:18.793" LastActivityDate="2016-04-05T11:49:18.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7205" PostTypeId="5" CreationDate="2016-04-05T11:57:50.643" Score="0" Body="&lt;p&gt;The official Github repository for this plugin can be found &lt;a href=&quot;https://github.com/ryanoasis/vim-devicons&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. It requires to have a &lt;a href=&quot;https://github.com/ryanoasis/nerd-fonts&quot; rel=&quot;nofollow&quot;&gt;patched nerd font&lt;/a&gt; installed to work properly.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-05T11:57:50.643" LastActivityDate="2016-04-05T11:57:50.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7206" PostTypeId="4" CreationDate="2016-04-05T11:57:50.643" Score="0" Body="A plugin which adds font icons (glyphs ★♨☢) to programming languages, libraries, and web developer filetypes for: NERDTree, powerline, vim-airline, ctrlp, unite, lightline.vim, vim-startify, vimfiler, and flagship" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-05T11:57:50.643" LastActivityDate="2016-04-05T11:57:50.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7207" PostTypeId="5" CreationDate="2016-04-05T12:03:49.570" Score="0" Body="&lt;p&gt;The official Github repo is &lt;a href=&quot;https://github.com/Shougo/neocomplete&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-05T12:03:49.570" LastActivityDate="2016-04-05T12:03:49.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7208" PostTypeId="4" CreationDate="2016-04-05T12:03:49.570" Score="0" Body="A completion plugin which provides keyword completion system by maintaining a cache of keywords in the current buffer." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-05T12:03:49.570" LastActivityDate="2016-04-05T12:03:49.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7209" PostTypeId="5" CreationDate="2016-04-05T12:08:34.143" Score="0" Body="&lt;p&gt;A comma separated list of screen columns that are highlighted with &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#hl-ColorColumn&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;hl-ColorColumn&lt;/code&gt;&lt;/a&gt;. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27colorcolumn%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'colorcolumn'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Use this tag if...&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you have a question about the &lt;code&gt;'colorcolumn'&lt;/code&gt; option of vim&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Don't use this tag if...&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you have a question about, e.g., highlighting indent levels&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="10604" LastEditDate="2019-12-07T03:39:54.630" LastActivityDate="2019-12-07T03:39:54.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7210" PostTypeId="4" CreationDate="2016-04-05T12:08:34.143" Score="0" Body="A comma separated list of screen columns that are highlighted with hl-ColorColumn." OwnerUserId="1841" LastEditorUserId="11357" LastEditDate="2019-12-07T08:21:11.057" LastActivityDate="2019-12-07T08:21:11.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7211" PostTypeId="1" AcceptedAnswerId="7213" CreationDate="2016-04-05T12:27:06.273" Score="0" ViewCount="1929" Body="&lt;p&gt;For commenting and uncommenting I now use the &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-commentary plugin&lt;/a&gt;, also the &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERD commenter&lt;/a&gt; can be used as mentioned in:&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/130/how-to-comment-out-a-set-of-lines-which-are-selected-in-visual-mode/154#154&quot;&gt;How to comment out a set of lines which are selected in visual mode?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know if there is an easy combination to change comments, for example like &lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt; or delete the comments like &#xA;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;. Note that this does not work (for as far as I could find) with the vim-commentary or NERD commenter plugins.&lt;/p&gt;&#xA;" OwnerUserId="5280" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-04-05T14:56:49.447" Title="How can I change/delete comments easily?" Tags="|key-bindings|cursor-motions|comments|plugin-vim-commentary|plugin-nerdcommenter|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7212" PostTypeId="2" ParentId="7201" CreationDate="2016-04-05T13:15:49.503" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#E30&quot; rel=&quot;noreferrer&quot;&gt;:help E30&lt;/a&gt; states&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The command-line is only stored in this register when at least one character of it was typed.  Thus it remains unchanged if the command was completed from a mapping.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It seems like Vim is not considering commands specified via &lt;code&gt;+&lt;/code&gt; (or &lt;code&gt;-c&lt;/code&gt;) to be typed, so &lt;code&gt;&quot;:&lt;/code&gt; isn't updated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if that's expected behavior or just an oversight.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2016-04-05T13:15:49.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7213" PostTypeId="2" ParentId="7211" CreationDate="2016-04-05T14:13:52.213" Score="5" Body="&lt;p&gt;What you are looking for is a text-object representing a comment. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h text-objects&lt;/code&gt;&lt;/a&gt; for more information about text-objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default Vim doesn't contains text-objects representing comments but the &lt;a href=&quot;https://github.com/thinca/vim-textobj-comment&quot; rel=&quot;noreferrer&quot;&gt;vim-textobj-comment&lt;/a&gt; implements this feature. Once you've got it installed you'll be able to access comments with &lt;code&gt;ic&lt;/code&gt; and &lt;code&gt;ac&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, if this plugin isn't exactly what you want it is possible to define your own text-objects &lt;em&gt;(it's fun to do and a good occasion to learn new stuff)&lt;/em&gt;. To do so you can have a look &lt;a href=&quot;http://vim.wikia.com/wiki/Creating_new_text_objects&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-04-05T14:13:52.213" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7214" PostTypeId="2" ParentId="7211" CreationDate="2016-04-05T14:56:49.447" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow&quot;&gt;Commentary.vim&lt;/a&gt; provides the &lt;code&gt;gc&lt;/code&gt; text object for comments. You can use &lt;code&gt;dgc&lt;/code&gt; for example to delete a comment block. I find that my most common usage is &lt;code&gt;gcgc&lt;/code&gt; to uncomment a comment block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Commentary.vim does not provide a visual mode mapping for a comment text object. Meaning you can not do &lt;code&gt;vgc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-04-05T14:56:49.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7216" PostTypeId="1" AcceptedAnswerId="7218" CreationDate="2016-04-05T16:31:56.513" Score="7" ViewCount="260" Body="&lt;p&gt;I'm running a Vimscript that retrieves the result of a message and redirects it to a vimscript variable.  When the contents of the vimscript variable are displayed, it has a ^@ in it.  What does that represent and how can I get rid of it?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2016-04-05T16:58:23.740" Title="What is a ^@ in vim?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7217" PostTypeId="1" AcceptedAnswerId="7223" CreationDate="2016-04-05T16:49:27.440" Score="5" ViewCount="773" Body="&lt;p&gt;In order to open PDFs using an external application, one can use the following script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup nonvim&#xA;   au!&#xA;   au BufRead *.pdf sil exe &quot;!open &quot; . shellescape(expand(&quot;&amp;lt;afile&amp;gt;&quot;)) | bd  &#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this is not optimal, because the pdf would still be loaded into vim, which will take a while if it is large. More importantly, your window layout will be messed up if you have more than one window showing, because of &lt;code&gt;bd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I thought of using &lt;code&gt;BufReadPre&lt;/code&gt; instead of using &lt;code&gt;BufRead&lt;/code&gt;. This way, I may still be able to cancel reading the file into a buffer. The question is: how?&lt;/p&gt;&#xA;" OwnerUserId="4947" LastEditorUserId="4947" LastEditDate="2016-04-05T23:56:11.567" LastActivityDate="2016-04-06T16:56:59.737" Title="How can I cancel reading a file into a buffer on BufReadPre?" Tags="|autocmd|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7218" PostTypeId="2" ParentId="7216" CreationDate="2016-04-05T16:58:23.740" Score="10" Body="&lt;p&gt;&lt;code&gt;^@&lt;/code&gt;, if you look at &lt;a href=&quot;http://manpages.ubuntu.com/ascii.7&quot;&gt;&lt;code&gt;man ascii&lt;/code&gt;&lt;/a&gt;, is the ASCII NUL character. And from &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#NL-used-for-NUL&quot;&gt;the help&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Technical detail:               *NL-used-for-Nul*&#xA;&amp;lt;Nul&amp;gt; characters in the file are stored as &amp;lt;NL&amp;gt; in memory.  In the display&#xA;they are shown as &quot;^@&quot;.  The translation is done when reading and writing&#xA;files.  To match a &amp;lt;Nul&amp;gt; with a search pattern you can just enter CTRL-@ or&#xA;&quot;CTRL-V 000&quot;.  This is probably just what you expect.  Internally the&#xA;character is replaced with a &amp;lt;NL&amp;gt; in the search pattern.  What is unusual is&#xA;that typing CTRL-V CTRL-J also inserts a &amp;lt;NL&amp;gt;, thus also searches for a &amp;lt;Nul&amp;gt;&#xA;in the file.  {Vi cannot handle &amp;lt;Nul&amp;gt; characters in the file at all}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should look at eliminating it from the source. If that's not an option, do, using &lt;code&gt;&amp;lt;c-@&amp;gt;&lt;/code&gt; as given in the docs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/^@//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-04-05T16:58:23.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7219" PostTypeId="1" CreationDate="2016-04-05T19:56:42.233" Score="1" ViewCount="62" Body="&lt;p&gt;I need two commands: one to find all occurences of &lt;code&gt;\gr{...}&lt;/code&gt; and&#xA;remove the &lt;code&gt;\gr{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;, leaving the contents &lt;code&gt;...&lt;/code&gt;, which&#xA;should work accross lines; and another to find all strings&#xA;consisting of&#xA;Greek characters (unicode ranges 0x0370--0x03ff and&#xA;0x1f00--0x1fff), AND non-Latin punctuation characters, AND TeX&#xA;commands (words precedes by &lt;code&gt;\&lt;/code&gt;),  (the last is not terribly&#xA;importaint, as there will be few places to correct manually&#xA;without it), and embrace them with &lt;code&gt;\gr{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &quot; Greek and Coptic or Greek Extended&#xA; let g = '[\u370-\u3ff\u1f00-\u1fff]'&#xA; let G = '[^\u370-\u3ff\u1f00-\u1fff]'&#xA; let GL = '[^\u370-\u3ff\u1f00-\u1fffA-Za-z]'&#xA; let ACn = '%([^A-Za-z%]|\n)'&#xA; &quot; replacement string&#xA; let r1 = '\1\\gr{\2}\3'&#xA; let r = r1&#xA;&#xA; let p3 = '\v%(^|(\a'.GL.'*))('.g.ACn.'*'.g.')(\A*\w)'&#xA; let p = p3&#xA;&#xA; let tgr3 = 'v/\\in\=de\=x/s/'.p.'/'.r.'/g'&#xA; let tgr = tgr3&#xA;&#xA; command! GrClear %s/\v\\gr\{(\_[^}]*)\}/\1/g&#xA; command! GrInsert norm ,&amp;lt;c-r&amp;gt;=tgr&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works to an extent, but not great.  Any pointers in the right&#xA;direction will be greatly appreciated.---And I do apologize that&#xA;this attempt is poorly explained, and that I haven't explained&#xA;exactly what the fail cases are: it's been a while since I did&#xA;this, and I just wanted to see if this might be familiar and&#xA;simple to someone; otherwise, ignore it and I will post a better&#xA;question when I have more time. Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS.  I am now using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl&#xA;binmode STDIN,  &quot;:utf8&quot;;&#xA;binmode STDOUT, &quot;:utf8&quot;;&#xA;my $g=qr/[\x{0370}-\x{03FF}\x{1F00}-\x{1FFF}]/;&#xA;my $L=qr/[^a-zA-Z]/;&#xA;while (&amp;lt;&amp;gt;)&#xA;{&#xA;    s/( (?: $g $L* $g) )/\\gr{$1}/xg;&#xA;  print&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which must be called with the cmd-line option &lt;code&gt;-0&lt;/code&gt;. this works fine except a minor aesthetic problem: the pattern doesn't know whether a bracket at the end of it belongs inside or not.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2016-04-06T16:34:48.173" LastActivityDate="2016-04-06T16:34:48.173" Title="Embracing and debracing Greek passages" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7220" PostTypeId="2" ParentId="7219" CreationDate="2016-04-05T23:22:25.163" Score="1" Body="&lt;p&gt;For your first question, have you tried vim's &lt;em&gt;di{&lt;/em&gt; command to delete inside curly braces? It's less readable than what you have, but to remove \gr{xxx} leaving the xxx I would have written something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set lazyredraw&#xA;/\\gr{&#xA;qq3ldi{pd5hnq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then typed &lt;em&gt;@q&lt;/em&gt; a few times to check, and then done &lt;em&gt;1000@q&lt;/em&gt; or &lt;em&gt;10000@q&lt;/em&gt; a few times as necessary to take care of the rest.&lt;/p&gt;&#xA;" OwnerUserId="5466" LastActivityDate="2016-04-05T23:22:25.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7221" PostTypeId="1" CreationDate="2016-04-06T02:10:17.233" Score="1" ViewCount="354" Body="&lt;p&gt;I recently discovered that Vim 7.4 enables a hybrid number mode, such that if you do &lt;code&gt;set nu&lt;/code&gt; and &lt;code&gt;set rnu&lt;/code&gt;, you'll see the absolute line number of the current line and relative line numbers everywhere else (see &lt;a href=&quot;http://codeyarns.com/2015/03/24/absolute-relative-and-hybrid-line-numbers-in-vim/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://jeffkreeftmeijer.com/2013/vims-new-hybrid-line-number-mode/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;). I set this up on a Linux machine and it works great. Unfortunately it's not working on my MacBook Pro (El Capitan). If I type &lt;code&gt;:set rnu&lt;/code&gt; I'll get relative numbers with &lt;code&gt;0&lt;/code&gt; at the cursor line, and if I then type &lt;code&gt;:set nu&lt;/code&gt; it will switch to only absolute line numbers, unlike what I see on the Linux machine. I have Vim 7.4 installed via Homebrew. How do I get this to work? Do I need to reinstall with some particular setting?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;vim --version&lt;/code&gt; is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr  5 2016 22:32:58)&#xA;MacOS X (unix) version&#xA;Included patches: 1-1707&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +tag_binary&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_old_static&#xA;+autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;-balloon_eval    +float           +mouse_urxvt     -tcl&#xA;-browse          +folding         +mouse_xterm     +terminfo&#xA;++builtin_terms  -footer          +multi_byte      +termresponse&#xA;+byte_offset     +fork()          +multi_lang      +textobjects&#xA;+channel         -gettext         -mzscheme        +timers&#xA;+cindent         -hangul_input    +netbeans_intg   +title&#xA;-clientserver    +iconv           +packages        -toolbar&#xA;+clipboard       +insert_expand   +path_extra      +user_commands&#xA;+cmdline_compl   +job             +perl            +vertsplit&#xA;+cmdline_hist    +jumplist        +persistent_undo +virtualedit&#xA;+cmdline_info    +keymap          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       +python          +vreplace&#xA;+cscope          +lispindent      -python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con      -lua             +rightleft       +writebackup&#xA;+diff            +menu            +ruby            -X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;-dnd             +modify_fname    +signs           -xim&#xA;-ebcdic          +mouse           +smartindent     -xsmp&#xA;+emacs_tags      -mouseshape      +startuptime     -xterm_clipboard&#xA;+eval            +mouse_dec       +statusline      -xterm_save&#xA;+ex_extra        -mouse_gpm       -sun_workshop    -xpm&#xA;+extra_search    -mouse_jsbterm   +syntax          &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -F/usr/local/Frameworks -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: /usr/bin/clang   -L. -L/usr/local/lib -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python   -lruby.2.0.0 -lobjc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim 7.4 installed via Homebrew on my iMac desktop has hybrid number mode working fine, so there must be something specific about my laptop, but I have no idea what. Moving my &lt;code&gt;.vimrc&lt;/code&gt; and packages somewhere else didn't change anything.&lt;/p&gt;&#xA;" OwnerUserId="5043" LastEditorUserId="5043" LastEditDate="2016-04-06T14:12:17.727" LastActivityDate="2016-04-06T14:30:58.933" Title="Vim 7.4 hybrid number mode not working" Tags="|line-numbers|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7223" PostTypeId="2" ParentId="7217" CreationDate="2016-04-06T05:31:11.387" Score="6" Body="&lt;p&gt;A better option would be &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#BufReadCmd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;BufReadCmd&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        BufReadCmd&#xA;BufReadCmd                      Before starting to edit a new buffer.  Should&#xA;                                read the file into the buffer. Cmd-event&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since this is supposed to read the file into the buffer, you can just &lt;em&gt;not&lt;/em&gt; read it. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you try to do a &lt;code&gt;bd&lt;/code&gt; in a &lt;code&gt;BufReadPre&lt;/code&gt; &lt;code&gt;autocmd&lt;/code&gt;, you'll get an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E201: *ReadPre autocommands must not change current buffer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;BufReadCmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup nonvim&#xA;   au!&#xA;   au BufReadCmd *.pdf sil exe '!open' shellescape(expand(&quot;&amp;lt;afile&amp;gt;&quot;)) | bd&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't use a Mac, but replacing &lt;code&gt;open&lt;/code&gt; with &lt;a href=&quot;http://manpages.ubuntu.com/manpages/trusty/en/man1/xdg-open.1.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;xdg-open&lt;/code&gt;&lt;/a&gt;, it worked fairly well enough.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-04-06T05:31:11.387" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7224" PostTypeId="1" CreationDate="2016-04-06T07:44:39.063" Score="5" ViewCount="2065" Body="&lt;p&gt;I'm VIM user for a few months now (life changing) but I have a small issue with the backspace key which is quite far from everything else (I already use &lt;kbd&gt;CapsLock&lt;/kbd&gt; for the &lt;kbd&gt;Esc&lt;/kbd&gt; key).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which mapping is best appropriate for using vim and touch typing for the backspace key. Or is it my mistake for using backspace for deleting characters all together?&lt;/p&gt;&#xA;" OwnerUserId="7125" LastEditorUserId="1841" LastEditDate="2016-04-06T07:53:13.993" LastActivityDate="2016-04-06T20:43:52.633" Title="Where to map the Backspace key to better match touch-typing?" Tags="|key-bindings|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7225" PostTypeId="2" ParentId="7224" CreationDate="2016-04-06T09:02:47.557" Score="4" Body="&lt;p&gt;Personally I don't have the &lt;kbd&gt;backspace&lt;/kbd&gt; key remapped to another. Actually I think the important point about your question is how you use the different modes of Vim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;backspace&lt;/kbd&gt; erases characters only in insert mode which is only meant to insert text and do really minor changes to the text: This mean that you're supposed to use &lt;kbd&gt;backspace&lt;/kbd&gt; only to erase 1 or 2 characters while you are inserting a new word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to erase more text, that means that you are supposed to switch to normal mode (or occasionally visual mode). The normal mode is meant to do bigger changes to your text:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you need to erase a whole line you'll be able to use &lt;code&gt;dd&lt;/code&gt; and if you need to erase the end of the line you'll be able to use &lt;code&gt;D&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;If you need to erase the last 4 words you wrote you'll use &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;4&lt;/kbd&gt;&lt;kbd&gt;b&lt;/kbd&gt; to say to Vim: &quot;Use the &lt;code&gt;d&lt;/code&gt;eletion &lt;code&gt;4&lt;/code&gt; words &lt;code&gt;b&lt;/code&gt;ackward&quot;.&lt;/li&gt;&#xA;&lt;li&gt;If you need to erase until a specific character (let's says &lt;code&gt;a&lt;/code&gt;) you'll be able to use &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt; or &lt;code&gt;T&lt;/code&gt; in commands likes &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;F&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; to say &quot;delete until the last &lt;code&gt;a&lt;/code&gt; in the line&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So I think that you don't actually need to remap &lt;kbd&gt;backspace&lt;/kbd&gt; because you're not meant to use it extensively.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-04-06T09:02:47.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7226" PostTypeId="2" ParentId="7224" CreationDate="2016-04-06T09:38:27.170" Score="7" Body="&lt;p&gt;I agree with statox's answer, and I want to point out that you have insert-mode ways of deleting more than 1 character at the time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h insert-index&#xA;&#xA;...&#xA;|i_&amp;lt;BS&amp;gt;|    &amp;lt;BS&amp;gt;        delete character before the cursor&#xA;|i_CTRL-H|  CTRL-H      same as &amp;lt;BS&amp;gt;&#xA;|i_CTRL-U|  CTRL-U      delete all entered characters in the current line&#xA;|i_CTRL-W|  CTRL-W      delete word before the cursor&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found out that &lt;kbd&gt;C-h&lt;/kbd&gt; was actually easier to type than the &lt;kbd&gt;backspace&lt;/kbd&gt; key (little hands).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think you need to remap &lt;kbd&gt;backspace&lt;/kbd&gt; to anything for insert-mode deletion, there are already options for what you may want.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-04-06T09:44:16.623" LastActivityDate="2016-04-06T09:44:16.623" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7227" PostTypeId="1" AcceptedAnswerId="7228" CreationDate="2016-04-06T10:16:51.447" Score="12" ViewCount="1989" Body="&lt;p&gt;I have &lt;code&gt;hlsearch&lt;/code&gt; set, but it sometimes lulls me into thinking t&#xA;hat I have the search term visually selected, and can just hit &lt;code&gt;c&lt;/code&gt; to change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The term searched for may not be an easy number of letters, words, even lines - and anyway, I don't want to count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to &lt;code&gt;vh&lt;/code&gt; (or &lt;code&gt;ch&lt;/code&gt;), say, where &lt;code&gt;h&lt;/code&gt; runs until the current highlighting stops?&lt;/p&gt;&#xA;" OwnerUserId="5778" LastActivityDate="2016-09-20T08:02:05.440" Title="Visual select current search result" Tags="|search|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7228" PostTypeId="2" ParentId="7227" CreationDate="2016-04-06T10:20:18.720" Score="18" Body="&lt;p&gt;You can use the &lt;code&gt;gn&lt;/code&gt; motion for that, it selects the next searched element.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/foo&amp;lt;CR&amp;gt;&#xA;gn            -&amp;gt; select the next &quot;foo&quot;&#xA;sbar&amp;lt;Esc&amp;gt;     -&amp;gt; (optional) substitute it with &quot;bar&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Bonus: To have &lt;code&gt;.&lt;/code&gt; repeat the search and the change, use a &lt;code&gt;c&lt;/code&gt; to do everything in one command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/foo&amp;lt;CR&amp;gt;&#xA;cgnbar&amp;lt;Esc&amp;gt;&#xA;...           -&amp;gt; find and change the 3 next foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="630" LastEditDate="2016-09-20T08:02:05.440" LastActivityDate="2016-09-20T08:02:05.440" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7230" PostTypeId="1" AcceptedAnswerId="7238" CreationDate="2016-04-06T12:21:55.637" Score="4" ViewCount="92" Body="&lt;p&gt;In Vim, &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;_&lt;/kbd&gt; selects text from the current position to the actual begin of the line. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Test test&#xA;   Test te|st&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now pressing &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;_&lt;/kbd&gt; we get the selection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Test test&#xA;   [Test te]st&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From this I would expect, that &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;_ &lt;/kbd&gt; deletes the same characters instand of selecting it. But it turns out, that &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;_&lt;/kbd&gt; deleted the whole line, like &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; would.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: why?&lt;/p&gt;&#xA;" OwnerUserId="3230" LastEditorUserId="205" LastEditDate="2016-04-24T18:03:59.177" LastActivityDate="2016-04-24T18:03:59.177" Title="Deleting to the begin of the line with d _" Tags="|cut-copy-paste|cursor-motions|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="7231" PostTypeId="1" AcceptedAnswerId="7232" CreationDate="2016-04-06T13:31:28.880" Score="3" ViewCount="177" Body="&lt;p&gt;I've noticed that when I have several files open in Vim, and one of the files has been changed by an external program, &lt;code&gt;:wa&lt;/code&gt; doesn't actually try to write into that file. OTOH, going to that file and explicitly saying &lt;code&gt;:w&lt;/code&gt; does try to actually write (I get asked whether I want to overwrite the changes). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like &lt;code&gt;:wa&lt;/code&gt; to behave like &quot;for all files, do &lt;code&gt;:w&lt;/code&gt;&quot;, so that I got asked whether I want to overwrite all the externally-changed files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this?&lt;/p&gt;&#xA;" OwnerUserId="1081" LastActivityDate="2016-04-06T14:00:42.413" Title="How to make :wa overwrite externally-changed files?" Tags="|save|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7232" PostTypeId="2" ParentId="7231" CreationDate="2016-04-06T13:54:46.773" Score="3" Body="&lt;p&gt;Instead of &lt;code&gt;:wa&lt;/code&gt; you could try using &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#:bufdo&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:bufdo&lt;/code&gt;&lt;/a&gt;&lt;code&gt;w&lt;/code&gt;, which will issue &lt;code&gt;:w&lt;/code&gt; for each buffer in the buffer list.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that the &lt;code&gt;bufdo&lt;/code&gt; will change the buffer on the current window. The following command correct this and may also be easier to remember:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=0 Wa :bufdo w &amp;lt;bar&amp;gt; :edit #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-04-06T14:00:42.413" LastActivityDate="2016-04-06T14:00:42.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7233" PostTypeId="1" CreationDate="2016-04-06T13:59:51.483" Score="15" ViewCount="8325" Body="&lt;p&gt;I'm using &lt;code&gt;grep&lt;/code&gt; to find function occurrences in a project.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:grep &quot;set_val&quot; *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Goes out of vim and outputs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;code.py:68:        self._device.set_val('Level', new_level)&#xA;code.py:84:        self._device.set_val(&quot;Mode&quot;, &quot;Remote&quot;)&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I press enter and am at &lt;code&gt;code.py:68&lt;/code&gt; which is the first occurrence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I move to other occurrences?&lt;/p&gt;&#xA;" OwnerUserId="7129" LastActivityDate="2018-03-07T15:36:21.483" Title="How to go to the next grep result?" Tags="|external-command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7234" PostTypeId="2" ParentId="7221" CreationDate="2016-04-06T14:30:58.933" Score="2" Body="&lt;p&gt;It turns out the problem was not with Vim 7.4, Homebrew, Macs, or any combination of the 3. Just my brain. I was used to &lt;code&gt;vi&lt;/code&gt; pointing to the &lt;code&gt;vim&lt;/code&gt; that I want, but in my case &lt;code&gt;vim&lt;/code&gt; points to the Homebrewed version and &lt;code&gt;vi&lt;/code&gt; points to the version originally on my Mac, which was Vim 7.3. I usually use &lt;code&gt;vi&lt;/code&gt; and &lt;code&gt;vim&lt;/code&gt; interchangeably and that shot me in the foot here. I have &lt;code&gt;vi&lt;/code&gt; aliased to the Homebrewed Vim now and everything is dandy.&lt;/p&gt;&#xA;" OwnerUserId="5043" LastActivityDate="2016-04-06T14:30:58.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7235" PostTypeId="2" ParentId="7233" CreationDate="2016-04-06T14:54:42.557" Score="33" Body="&lt;p&gt;&lt;code&gt;:grep&lt;/code&gt;/&lt;code&gt;:vimgrep&lt;/code&gt; both use the quickfix list to store locations. As you have noticed vim will automatically jump to the first occurrence (use &lt;code&gt;!&lt;/code&gt; to avoid this behavior). Simply use &lt;code&gt;:cnext&lt;/code&gt; to go to the next location in the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Quickfix commands&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:cnext&lt;/code&gt;/&lt;code&gt;:cprevious&lt;/code&gt; to navigate the quickfix forwards and backwards in the quickfix list&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:cfirst&lt;/code&gt;/&lt;code&gt;:clast&lt;/code&gt; to jump to the start and end of the quickfix list&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:copen&lt;/code&gt; to open the quickfix window. Use &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to jump to an entry&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:cclose&lt;/code&gt; to close the quickfix window&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:cc&lt;/code&gt; to display the current error.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:colder&lt;/code&gt;/&lt;code&gt;:cnewer&lt;/code&gt; to jump older/newer quickfix lists&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would recommend you create mappings for &lt;code&gt;:cnext&lt;/code&gt; and &lt;code&gt;:cprevious&lt;/code&gt;. I personally use &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;noreferrer&quot;&gt;unimpaired.vim&lt;/a&gt; which provides &lt;code&gt;]q&lt;/code&gt; &amp;amp; &lt;code&gt;[q&lt;/code&gt; mappings for &lt;code&gt;:cnext&lt;/code&gt; and &lt;code&gt;:cprevious&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the quickfix window to open automatically put the following in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup autoquickfix&#xA;    autocmd!&#xA;    autocmd QuickFixCmdPost [^l]* cwindow&#xA;    autocmd QuickFixCmdPost    l* lwindow&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a &lt;a href=&quot;http://vimcasts.org/&quot; rel=&quot;noreferrer&quot;&gt;Vimcasts&lt;/a&gt; episode about this topic: &lt;a href=&quot;http://vimcasts.org/episodes/search-multiple-files-with-vimgrep/&quot; rel=&quot;noreferrer&quot;&gt;Search multiple files with :vimgrep&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Project-wide Search and Replace&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you are using &lt;code&gt;:grep&lt;/code&gt;/&lt;code&gt;:vimgrep&lt;/code&gt; as way to do a &lt;a href=&quot;http://vimcasts.org/episodes/project-wide-find-and-replace/&quot; rel=&quot;noreferrer&quot;&gt;project-wide search and replace&lt;/a&gt; then I suggest you use &lt;code&gt;:cdo&lt;/code&gt;/&lt;code&gt;:cfdo&lt;/code&gt; (in Vim 7.4.980+).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:grep 'foo'&#xA;:cfdo %s/foo/bar/g|w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your version of Vim does not have &lt;code&gt;:cdo&lt;/code&gt;/&lt;code&gt;:cfdo&lt;/code&gt; put the following commands in your &lt;code&gt;vimrc&lt;/code&gt; file to provide &lt;code&gt;:Cdo&lt;/code&gt;/&lt;code&gt;:Cfdo&lt;/code&gt; alternative commands.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(':cdo')&#xA;  command! -nargs=1 -complete=command Cdo try | sil cfirst |&#xA;        \ while 1 | exec &amp;lt;q-args&amp;gt; | sil cn | endwhile |&#xA;      \ catch /^Vim\%((\a\+)\)\=:E\%(553\|42\):/ |&#xA;      \ endtry&#xA;&#xA;  command! -nargs=1 -complete=command Cfdo try | sil cfirst |&#xA;        \ while 1 | exec &amp;lt;q-args&amp;gt; | sil cnf | endwhile |&#xA;      \ catch /^Vim\%((\a\+)\)\=:E\%(553\|42\):/ |&#xA;      \ endtry&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Using an alternative program for &lt;code&gt;:grep&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Sometimes &lt;code&gt;grep&lt;/code&gt; isn't quite good enough for your search needs. You can change your &lt;code&gt;:grep&lt;/code&gt; program via the &lt;code&gt;'grepprg'&lt;/code&gt; setting (may also need to change &lt;code&gt;'grepformat'&lt;/code&gt; as well). Personally I use &lt;a href=&quot;https://github.com/BurntSushi/ripgrep&quot; rel=&quot;noreferrer&quot;&gt;ripgrep&lt;/a&gt; by adding the following to my &lt;code&gt;vimrc&lt;/code&gt; file as instructed in &lt;code&gt;rg&lt;/code&gt;'s man page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set grepprg=rg\ --vimgrep&#xA;set grepformat^=%f:%l:%c:%m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: May want to use &lt;code&gt;-S&lt;/code&gt; flag, e.g. &lt;code&gt;set grepprg=rg\ -S\ --vimgrep&lt;/code&gt;, to use &quot;smart case&quot; searching (case insensitive searching when all lowercase letters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;:grep&lt;/code&gt; will use &lt;code&gt;rg&lt;/code&gt; to search. e.g. &lt;code&gt;:grep foo -t js&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Her are a few alternative grep programs to look into: &lt;a href=&quot;http://beyondgrep.com/&quot; rel=&quot;noreferrer&quot;&gt;ack&lt;/a&gt;, &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;noreferrer&quot;&gt;ag&lt;/a&gt;, &lt;a href=&quot;https://github.com/BurntSushi/ripgrep&quot; rel=&quot;noreferrer&quot;&gt;ripgrep&lt;/a&gt;, and &lt;a href=&quot;https://git-scm.com/docs/git-grep&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;git grep&lt;/code&gt;&lt;/a&gt; (&lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;noreferrer&quot;&gt;Fugitive.vim&lt;/a&gt; provides &lt;code&gt;:Ggrep&lt;/code&gt; wrapper)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;For more help see:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :grep&#xA;:h 'grepprg'&#xA;:h quickfix&#xA;:h :cnext&#xA;:h :copen&#xA;:h :ccl&#xA;:h :cc&#xA;:h :colder&#xA;:h :cdo&#xA;:h :cfdo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-03-07T15:36:21.483" LastActivityDate="2018-03-07T15:36:21.483" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7236" PostTypeId="2" ParentId="7217" CreationDate="2016-04-06T16:29:28.050" Score="3" Body="&lt;p&gt;Building on muru's answer, here  is a solution that makes opening PDF files through vim seamless. The problem with &lt;code&gt;:bd&lt;/code&gt; is that it messes up the window layout, but aside from that you may end up at a completely different buffer than where you opened the PDF from. This uses &lt;code&gt;:b#&lt;/code&gt; and then deletes the empty buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last annoyance - that the buffer is centerd on re-entry - can be fixed with &lt;a href=&quot;http://vim.wikia.com/wiki/Avoid_scrolling_when_switch_buffers&quot; rel=&quot;nofollow&quot;&gt;this script&lt;/a&gt;. (Use the original version or remove the check for &lt;code&gt;atStartOfFile&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup nonvim&#xA;   au!&#xA;   au BufReadCmd *.pdf sil exe &quot;!xdg-open &quot; . shellescape(expand(&quot;&amp;lt;afile&amp;gt;&quot;)) . &quot;&amp;amp;&amp;gt;/dev/null&quot; |&#xA;       \ let tobedeleted = bufnr('%') | b# | exe &quot;bd! &quot; . tobedeleted&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works with NERDtree.&lt;/p&gt;&#xA;" OwnerUserId="4947" LastEditorUserId="4947" LastEditDate="2016-04-06T16:56:59.737" LastActivityDate="2016-04-06T16:56:59.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7238" PostTypeId="2" ParentId="7230" CreationDate="2016-04-06T20:07:27.673" Score="3" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#linewise&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help linewise&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Generally, motions that move between lines affect lines&#xA;(are linewise), and motions that move within a line affect characters (are&#xA;characterwise).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;_&lt;/code&gt; is a motion which can move between lines. For example, &lt;code&gt;2_&lt;/code&gt; will move the cursor on the first non whitespace of the line below the current one. So, there's a good chance for &lt;code&gt;_&lt;/code&gt; to affect whole lines when preceded by an operator, which is confirmed by &lt;code&gt;:help _&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_  &amp;lt;underscore&amp;gt;     [count] - 1 lines downward, on the first non-blank&#xA;                    character linewise.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As explained in &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#o_v&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help o_v&lt;/code&gt;&lt;/a&gt;, by typing &lt;code&gt;v&lt;/code&gt; after an operator, you can still force the latter to use a linewise motion as a characterwise one instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v       When used after an operator, before the motion command: Force&#xA;        the operator to work characterwise, also when the motion is&#xA;        linewise.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, if you wanted to delete from the cursor back to the first non whitespace on the line using the &lt;code&gt;_&lt;/code&gt; motion, you could type &lt;code&gt;dv_&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="205" LastEditDate="2016-04-06T20:29:19.487" LastActivityDate="2016-04-06T20:29:19.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7239" PostTypeId="1" AcceptedAnswerId="7240" CreationDate="2016-04-07T04:48:47.283" Score="1" ViewCount="56" Body="&lt;p&gt;I am debugging a plugin, and to do so saving the output of &lt;code&gt;au&lt;/code&gt; into either a file or a temporary buffer would help immensely. Is there a way?&lt;/p&gt;&#xA;" OwnerUserId="6625" LastEditorUserId="1841" LastEditDate="2016-04-07T08:17:31.920" LastActivityDate="2016-04-07T08:17:31.920" Title="How to write the output of `:au` in a file" Tags="|vimscript|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7240" PostTypeId="2" ParentId="7239" CreationDate="2016-04-07T05:15:23.663" Score="1" Body="&lt;pre&gt;&lt;code&gt;:redir &amp;gt; filename&#xA;:autocmd&#xA;:redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :redir&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-07T05:15:23.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7241" PostTypeId="2" ParentId="7179" CreationDate="2016-04-07T08:42:12.120" Score="6" Body="&lt;p&gt;While I don't see in the doc any option/flag you can use for a ex command, I think you can simply use the &lt;code&gt;C-o&lt;/code&gt; command afterward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the documentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-O          Go to [count] Older cursor position in jump list&#xA;                (not a motion command).  {not in Vi}&#xA;                {not available without the |+jumplist| feature}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you do a ex command, you can go back to the previous position with &lt;code&gt;C-o&lt;/code&gt;. In my mind it does make sens to go to the last change resulting of the ex command, so that you can see if the change (i.e. in a substitution) had the desired effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do want to have a transparent call, you can use a custom command that take your ex command as an argument and restore the window automatically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! KeepEx(arg)&#xA;  let l:winview = winsaveview()&#xA;  execute a:arg&#xA;  call winrestview(l:winview)&#xA;endfunction&#xA;&#xA;command! -nargs=+ -completion=command K :call KeepEx(&quot;&amp;lt;args&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:K %s/a/b/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;winsaveview&lt;/code&gt; will fetch every info you need for restoring the view, so you get back to your previous state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: if you delete line above your cursor it might be possible that you cannot restore fully your window, but that's an edge case. &lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-04-12T15:21:04.080" LastActivityDate="2016-04-12T15:21:04.080" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="7242" PostTypeId="1" CreationDate="2016-04-07T10:33:42.480" Score="2" ViewCount="182" Body="&lt;p&gt;Suppose i've got two different positions in a buffer returned by &lt;code&gt;getpos()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;p1 = getpos(&quot;v&quot;)&#xA;p2 = getpos(&quot;.&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a simple or elegant way to find out which one is before the other in the buffer?  Doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if p1[1] &amp;lt; p2[1] || (p1[1] == p2[1] &amp;amp;&amp;amp; p1[2] &amp;lt; p2[2])&#xA;  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;each time looks ugly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, can i get the absolute positions -- the number of characters from the start of the file?&lt;/p&gt;&#xA;" OwnerUserId="1248" LastActivityDate="2016-04-07T10:33:42.480" Title="How to compare two positions in a buffer?" Tags="|vimscript|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7243" PostTypeId="1" AcceptedAnswerId="13999" CreationDate="2016-04-07T10:36:31.577" Score="1" ViewCount="339" Body="&lt;p&gt;As the title said, I would like to select and send to execute lines from my vim script to the statistical software package R (say an instance of it open in a different terminal).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While there is a maintained plugin (N-vim) that allows to do what I am looking for, it also provides a lot more clutter which I don't want/need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there away to achieve that one functionality? I am running Arch Linux on a headless server.&lt;/p&gt;&#xA;" OwnerUserId="6854" LastEditorUserId="6854" LastEditDate="2016-04-07T18:40:05.100" LastActivityDate="2017-10-21T13:12:05.777" Title="Send one-liners from vim to R" Tags="|command-line|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7244" PostTypeId="1" AcceptedAnswerId="7246" CreationDate="2016-04-07T10:40:08.127" Score="4" ViewCount="353" Body="&lt;p&gt;I'm trying to have something like this in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;has :w | ! reset; runhaskell % &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How ever, now it prompts an error when loading .vimrc and tells me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;:! reset; runhaskell r_packages.markdown &#xA;/bin/bash: -c: line 0: syntax error near unexpected token `newline'&#xA;/bin/bash: -c: line 0: ` reset; runhaskell r_packages.markdown '&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How should I write my key mapping so as the bash command is executed only on my leader key mapping ? And not when vim starts up.&lt;/p&gt;&#xA;" OwnerUserId="1682" LastActivityDate="2016-04-07T11:19:06.947" Title="Vimrc tries to execute command defined on leader" Tags="|key-bindings|vimrc|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7245" PostTypeId="1" AcceptedAnswerId="7248" CreationDate="2016-04-07T10:57:59.877" Score="3" ViewCount="403" Body="&lt;p&gt;I've been learning vi (as an autodidact) for some weeks. Actually I'm not yet sure about if I'm using vi or vim (does the command &lt;code&gt;vi&lt;/code&gt; open vim if vim is installed?).&lt;/p&gt;&#xA;&lt;p&gt;Now I'm trying to edit multiple files (more than two, in general). To do so I found useful the commands &lt;code&gt;:ar&lt;/code&gt;, &lt;code&gt;:argadd&lt;/code&gt;, &lt;code&gt;:argd&lt;/code&gt; and so on.&#xA;Then I read that another way is to use buffers, i.e. commands like &lt;code&gt;:ls&lt;/code&gt;, &lt;code&gt;:b&lt;/code&gt;, &lt;code&gt;:sb&lt;/code&gt; and so on.&lt;/p&gt;&#xA;&lt;p&gt;At the moment I don't understand the difference very well (I searched on the web and found something; maybe everything is clear but.. maybe I'm too new to vi to understand what I found).&lt;/p&gt;&#xA;&lt;p&gt;What I noticed is that if I navigate from a file to another using &lt;code&gt;:n&lt;/code&gt;, then the square brackets I see when entering &lt;code&gt;:ar&lt;/code&gt; have been transferred from the preceding to the following file.&#xA;If I use &lt;code&gt;:b n&lt;/code&gt; (n is the index of a buffer) the &lt;code&gt;%a&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; labels in the list &lt;code&gt;:ls&lt;/code&gt; correctly change, whereas if I enter &lt;code&gt;:ar&lt;/code&gt;, the brackets are still those before the  &lt;code&gt;:b&lt;/code&gt; command.&#xA;To summarize, I noticed that when I navigate arguments, both &lt;code&gt;:ls&lt;/code&gt; and &lt;code&gt;:ar&lt;/code&gt;'s outputs change; when I navigate buffers, only &lt;code&gt;:ls&lt;/code&gt;'s output changes, that of &lt;code&gt;:ar&lt;/code&gt; remaining fixed.&lt;/p&gt;&#xA;&lt;p&gt;Can anyone help me to understand &lt;em&gt;practical&lt;/em&gt; differences between arguments and buffers?&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Which are the pros and cons of navigate files in the former or latter method?&lt;/li&gt;&#xA;&lt;li&gt;Is it possible (and convenient/easy?) to use both the methods?&lt;/li&gt;&#xA;&lt;li&gt;And other question I'm not even capable of formulate now (i.e. other information are welcomed).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="6498" LastEditDate="2023-04-04T10:41:24.137" LastActivityDate="2023-04-04T10:41:24.137" Title="navigating multiple files - arguments and buffers" Tags="|buffers|multiple-files|argument-list|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7246" PostTypeId="2" ParentId="7244" CreationDate="2016-04-07T11:13:48.930" Score="7" Body="&lt;p&gt;Vim interprets the pipe character as a command termination and tries to execute what's afterwards as if it was an Ex command which was not part of the &lt;code&gt;nnoremap&lt;/code&gt; mapping.&lt;br&gt;&#xA;To prevent this, you have to escape the pipe or replace it with the corresponding keycode &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;has :w &amp;lt;bar&amp;gt; ! reset; runhaskell % &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-04-07T11:19:06.947" LastActivityDate="2016-04-07T11:19:06.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7248" PostTypeId="2" ParentId="7245" CreationDate="2016-04-07T12:35:27.067" Score="5" Body="&lt;p&gt;The only system I know of that comes with the real &lt;code&gt;vi&lt;/code&gt; by default is Arch Linux. In all the others, the &lt;code&gt;vi&lt;/code&gt; command is some kind of &quot;alias&quot; that points to a more advanced &lt;code&gt;vi&lt;/code&gt; clone like &lt;code&gt;nvi&lt;/code&gt; or &lt;code&gt;vim&lt;/code&gt;. So chances are that you are actually using Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, arguments and buffers have a special relationship.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding elements to the argument list also adds them to the buffer list but…&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;removing arguments from the argument list won't remove their counterpart in the buffer list and vice-versa,&lt;/li&gt;&#xA;&lt;li&gt;changing the order of the argument list has no impact on the order of the buffer list (which can't be changed).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On the navigation side, moving to another argument also changes the current buffer but moving to another buffer doesn't change the current argument.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Which are the pros and cons of navigate files in the former or latter method?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h3&gt;argument list pros&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;easy to manipulate → flexible&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;argument list cons&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;easy to manipulate → unreliable&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;buffer list pros&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;hard to manipulate → reliable&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;buffer list cons&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;hard to manipulate → inflexible&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible (and convenient/easy?) to use both the methods?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, but for different jobs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The buffer list is a dependable representation of (parts of) the current state of your editor and you can safely rely on it for all things &lt;em&gt;buffer-related&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a transient structure, the argument list can't really be used as the backbone of a structured workflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion is to stick with buffers for any &lt;em&gt;document&lt;/em&gt;-centric workflow and keep arguments for adding multiple buffers to the buffer list in one go and/or quick &lt;em&gt;file&lt;/em&gt;-oriented tasks like search-and-replace.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-07T12:35:27.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7249" PostTypeId="1" CreationDate="2016-04-07T14:17:21.983" Score="5" ViewCount="5079" Body="&lt;p&gt;I just downloaded and installed vim-addon-manager using &lt;code&gt;sudo apt-get install&lt;/code&gt;. I'm not sure what to do next, I entered &lt;code&gt;vim-addon-manager&lt;/code&gt; at the &lt;code&gt;bash&lt;/code&gt; prompt (Ubuntu 14.04). Here is the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~$ vim-addon-manager&#xA;# Name                     User Status  System Status &#xA;align                       removed       removed       &#xA;alternate                   removed       removed       &#xA;bufexplorer                 removed       removed       &#xA;calendar                    removed       removed       &#xA;closetag                    removed       removed       &#xA;colors-sampler-pack         removed       removed       &#xA;cvsmenu                     removed       removed       &#xA;debPlugin                   removed       removed       &#xA;detectindent                removed       removed       &#xA;doxygen-toolkit             removed       removed       &#xA;editexisting                removed       removed       &#xA;enhanced-commentify         removed       removed       &#xA;gnupg                       removed       removed       &#xA;info                        removed       removed       &#xA;justify                     removed       removed       &#xA;lbdbq                       removed       removed       &#xA;matchit                     removed       removed       &#xA;minibufexplorer             removed       removed       &#xA;nerd-commenter              removed       removed       &#xA;omnicppcomplete             removed       removed       &#xA;po                          removed       removed       &#xA;project                     removed       removed       &#xA;python-indent               removed       removed       &#xA;secure-modelines            removed       removed       &#xA;snippetsEmu                 removed       removed       &#xA;sokoban                     removed       removed       &#xA;supertab                    removed       removed       &#xA;surround                    removed       removed       &#xA;taglist                     removed       removed       &#xA;tetris                      removed       removed       &#xA;utl                         removed       removed       &#xA;vcscommand                  removed       removed       &#xA;vimplate                    removed       removed       &#xA;whatdomain                  removed       removed       &#xA;winmanager                  removed       removed       &#xA;xmledit                     removed       removed  &#xA;~$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't think these are the results that I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This started because I was trying to install something called nibble, and it doesn't look like this is it. Actually at this point I would settle for anything fun. Being unfamiliar with vi/vim's plugin system. I have looked at the man pages but I'm still at a loss where to begin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could really use the steps spelled out for me. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1705" LastEditorUserId="1705" LastEditDate="2016-04-08T12:02:28.657" LastActivityDate="2016-04-08T16:05:53.200" Title="Using vim-addon-manager" Tags="|linux|plugin-system|plugin-managers|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7250" PostTypeId="2" ParentId="747" CreationDate="2016-04-07T14:27:23.340" Score="3" Body="&lt;p&gt;This is an old question but for the benefit of future visitors: I find its easier to change the latex quotes with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\usepackage{csquotes} % change &quot; &quot; into nice double quotes  &#xA;\MakeOuterQuote{&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then &lt;code&gt;This thing is &quot;Foobar&quot;!&lt;/code&gt; will work fine in vim and latex.&lt;/p&gt;&#xA;" OwnerUserId="2792" LastActivityDate="2016-04-07T14:27:23.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7251" PostTypeId="1" AcceptedAnswerId="7253" CreationDate="2016-04-07T20:30:09.473" Score="0" ViewCount="3636" Body="&lt;p&gt;I would like to execute a certain function every time I leave a buffer associated with &lt;strong&gt;C++&lt;/strong&gt;, and another function every time I enter a &lt;strong&gt;C++&lt;/strong&gt; buffer. I came up with this so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Buffer Leave&#xA;augroup myBufferLeave&#xA;    autocmd BufLeave *.cpp,*.c,*.h call s:ExecuteLeave()&#xA;augroup END&#xA;&#xA;&quot; Buffer Enter&#xA;augroup myBufferEnter&#xA;    autocmd BufEnter *.cpp,*.c,*.h call s:ExecuteEnter()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another alternative is to hook into the global &lt;code&gt;BufEnter&lt;/code&gt; event and set a buffer variable or check the current &lt;code&gt;&amp;amp;ft&lt;/code&gt; and execute the appropriate function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter * if &amp;amp;ft = 'cpp' |&#xA;    \ call s:ExecuteEnter() |&#xA;    \ endif&#xA;&#xA;autocmd BufLeave * if &amp;amp;ft = 'cpp' |&#xA;    \ call s:ExecuteLeave() |&#xA;    \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a cleaner way to do this? Ideally, without tapping into the &lt;code&gt;*&lt;/code&gt; global buffer events. Ideally, I would like to use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; autocmd BufLeave cpp call s:ExecuteLeave()&#xA; autocmd BufEnter cpp call s:ExecuteEnter()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to pack the &lt;code&gt;*.cpp,*.c,*.h&lt;/code&gt; condition into one single definition such as &lt;code&gt;cpp&lt;/code&gt;? The &lt;code&gt;cpp&lt;/code&gt; definition is a &lt;code&gt;FileType&lt;/code&gt;, but file-types are not triggered on &lt;code&gt;BufEnter&lt;/code&gt; and &lt;code&gt;BufLeave&lt;/code&gt;. If one needs to add another file extension, such as &lt;code&gt;*.CXX&lt;/code&gt; for example, the list will become bloated eventually &lt;code&gt;*.cpp,*.c,*.h, *.CXX, *.C,&lt;/code&gt; and a bit hard to maintain.&lt;/p&gt;&#xA;" OwnerUserId="5328" LastActivityDate="2016-04-07T22:36:46.630" Title="Executing a function on buffer enter and on buffer leave events?" Tags="|buffers|autocmd|filetype|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7252" PostTypeId="1" CreationDate="2016-04-07T20:33:06.880" Score="2" ViewCount="1365" Body="&lt;p&gt;I have a problem with my cursor in gVim, this happens in both Normal and insert(Whenever I type fast) modes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I move my cursor it seems that the cursor goes to a random position for a very short time before it goes back where it should go. Here is a gif to demonstrate that : &lt;a href=&quot;http://giphy.com/gifs/xTiQyE5vLU7yBtONeU&quot; rel=&quot;nofollow&quot;&gt;Vim cursor&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7147" LastEditorUserId="1841" LastEditDate="2016-04-07T20:51:17.363" LastActivityDate="2020-11-05T15:18:00.480" Title="Gvim cursor jumps all over the place" Tags="|gvim|cursor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7253" PostTypeId="2" ParentId="7251" CreationDate="2016-04-07T22:08:01.050" Score="1" Body="&lt;p&gt;As the &lt;code&gt;completeopt&lt;/code&gt; is a global option, you are correct in that you need a way to toggle the &lt;code&gt;preview&lt;/code&gt; setting. I suggest you do this via the &lt;code&gt;BufEnter&lt;/code&gt; autocmd with a &lt;code&gt;*&lt;/code&gt; as the pattern.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup TogglePreview&#xA;  autocmd!&#xA;  autocmd Filetype,BufEnter * execute 'set completeopt'.(&amp;amp;ft == 'cpp' ? '+' : '-').'=preview'&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is that the autocmd uses &lt;code&gt;'filetype'&lt;/code&gt; upon entering a new buffer or settings the buffer's &lt;code&gt;'filetype'&lt;/code&gt; to decide to turn on/off the &lt;code&gt;preview&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to consider using &lt;code&gt;:pclose&lt;/code&gt; to close the preview window as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :au&#xA;:h BufEnter&#xA;:h 'completeopt'&#xA;:h :exe&#xA;:h :pclose&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2016-04-07T22:36:46.630" LastActivityDate="2016-04-07T22:36:46.630" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7254" PostTypeId="2" ParentId="3964" CreationDate="2016-04-08T03:19:29.983" Score="4" Body="&lt;p&gt;I think &lt;a href=&quot;https://www.johnhawthorn.com/2012/09/vi-escape-delays/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this post&lt;/a&gt; explains the difference between &lt;code&gt;timeoutlen&lt;/code&gt; and &lt;code&gt;ttimeoutlen&lt;/code&gt; nicely, especially when used to fix issues with airline/powerline:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Another solution is to use &lt;a href=&quot;http://www.polarhome.com/vim/manual/v57/options.html#%27timeoutlen%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;timeoutlen&lt;/code&gt; and &lt;code&gt;ttimeoutlen&lt;/code&gt;&lt;/a&gt;. &lt;code&gt;timeoutlen&lt;/code&gt; is used for mapping delays, and &lt;code&gt;ttimeoutlen&lt;/code&gt; is used for key code delays. My &lt;code&gt;.vimrc&lt;/code&gt; has:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;set timeoutlen=1000 ttimeoutlen=0&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;It might be more reasonable to give &lt;code&gt;ttimeoutlen&lt;/code&gt; a more reasonable value, like 10ms, although I have encountered no issues yet.&lt;/p&gt;&#xA;&lt;p&gt;This is especially nice with vim-powerline, which gives clear visual indication of the current mode.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="7149" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-04-08T03:19:29.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7255" PostTypeId="2" ParentId="7249" CreationDate="2016-04-08T07:58:34.490" Score="6" Body="&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt; This answer contains comments that are based on my experience and on the opinion that I got with the time, it might not be universal. I wrote this answer with keeping in mind the experience of a new Vim user.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; The package &lt;a href=&quot;https://packages.debian.org/sid/vim-addon-manager&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-addon-manager&lt;/a&gt; installed by OP is a command-line plugin manager that you run outside of Vim. It was created to install plugin packaged as debian packages (See &lt;a href=&quot;https://vi.stackexchange.com/q/7266/1841&quot;&gt;this question&lt;/a&gt; about its creation). It is pretty useful to solve some specific problems but it is less flexible than others plugin managers which directly fetch plugin from github or other sources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that to let a new comer achieve the goal stated by the question the package is not the easiest tool to use, that is why I made this answer detailing an easy way to install new plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if I understood correctly the documentation of the package and OP really wants to use it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;To install a new plugin with vim-addon-manager, the user should use &lt;code&gt;vim-addons install &amp;lt;plugin&amp;gt;&lt;/code&gt; with &lt;code&gt;&amp;lt;plugin&amp;gt;&lt;/code&gt; being one of the entries shown by the command &lt;code&gt;vim-addon&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;As the nibble requested by OP is not in the list posted in the question, it will be necessary to package the plugin as a debian package and I think the instructions to do so are beyond the scope of this site.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have tested &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow noreferrer&quot;&gt;several&lt;/a&gt; &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt; &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;managers&lt;/a&gt; but never vim-addon-manager. The main reason is because the minimum configuration that you need to make it work seems a little bit too long and messy for me and thus not adapted for a new comer to Vim. Also several opinions in &lt;a href=&quot;https://www.reddit.com/r/vim/comments/192twe/anyone_using_vimaddonmanager_how_does_it_compare/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this reddit thread&lt;/a&gt; made me think that it wasn't for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that if you're a new user who just want to easily and quickly get ready to discover the power of Vim plugins, you should choose another plugin manager and I would strongly recommend &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim-plug&lt;/a&gt; for its ease of use and its power. &lt;em&gt;(Of course one can always argue for another plugin manager, I choose to use this one in this answer to provide a minimal and easy set of instructions to get ready to use a plugin)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you was mentioning &lt;code&gt;apt-get&lt;/code&gt; I assume that you are on a Unix system, so this installation process is pretty straight-forward:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First in your favorite terminal use this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will automatically download the plugin manager and put it in the right place so you'll be able to use it right after the download.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Once the download is over, simply add theses lines in your &lt;code&gt;.vimrc&lt;/code&gt; (If you don't have a &lt;code&gt;.vimrc&lt;/code&gt; file you can simply create it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;touch ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this file you'll need to add the following lines to be able to start adding new plugins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;&quot; You'll replace this line with your plugin installations&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You're now ready to install new plugins. To do so, find a github repo of your plugin: if you wanted a nibble you can look at &lt;a href=&quot;https://github.com/vim-scripts/Nibble&quot; rel=&quot;nofollow noreferrer&quot;&gt;this repo&lt;/a&gt;. To install a plugin from github you'll have to add a line like the following one in your &lt;code&gt;.vimrc&lt;/code&gt; between the lines &lt;code&gt;call plug#begin('~/.vim/plugged')&lt;/code&gt; and &lt;code&gt;call plug#end()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'username/repo-name'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(The &lt;code&gt;username/repo-name&lt;/code&gt; are the end of the github url and can also be found on the top of the github webpage of the repo)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the nibble I linked you'll have to write 2 lines because the plugin has a dependecy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'vim-scripts/Nibble'&#xA;Plug 'vim-scripts/genutils'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Remember to save your &lt;code&gt;.vimrc&lt;/code&gt; with its new lines with &lt;code&gt;:w&lt;/code&gt; (Press on &lt;kbd&gt;:&lt;/kbd&gt; to enter the command mode, write &lt;code&gt;w&lt;/code&gt; and validate with &lt;kbd&gt;enter&lt;/kbd&gt;) and to source it so Vim is aware that you added new lines: &lt;code&gt;:source $MYVIMRC&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now comes the final step: tell to Vim-plug to fetch the source files of the plugin and install it. To do so in Vim simply use the command &lt;code&gt;:PlugInstall&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A new window with a buffer will appear showing you the progress of the install process. Once it's done you can close this buffer with &lt;code&gt;:bd&lt;/code&gt; and you're ready to use your plugins.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can then use the command &lt;code&gt;:Nibble&lt;/code&gt; and start enjoying your game.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As I said Vim-plug is a pretty easy to use and still powerful plugin manager, use it for a while learn how to use it and then when you'll be comfortable enough with it, give another try to vim-addon-manager if you really feel like it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-04-08T16:05:53.200" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7256" PostTypeId="1" CreationDate="2016-04-08T08:14:41.417" Score="5" ViewCount="300" Body="&lt;p&gt;I can't find an easy solution to the following problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider I'm in insert mode and I need to modify something in another point of the text. I exit insert mode and then move to the point I need to edit. Now suppose I perform some commands in normal mode. When I'm done I can go back to insert mode in the last insert position with command &lt;code&gt;gi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem comes when the edit I need to do also requires another insert operation. In that case, I would lose the last insert position in mark &lt;code&gt;^&lt;/code&gt; which makes the &lt;code&gt;gi&lt;/code&gt; command useless. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, I would need to jump to the next-to-last insert position.&#xA;Having a look  at &lt;code&gt;:marks&lt;/code&gt;, such a mark is not kept. So, what's an easy way to solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="6848" LastEditorUserId="205" LastEditDate="2016-04-08T18:16:40.447" LastActivityDate="2016-04-10T08:16:03.843" Title="How do I jump back to the next-to-last insert position?" Tags="|cursor-movement|mark|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7258" PostTypeId="1" AcceptedAnswerId="7263" CreationDate="2016-04-08T09:12:28.520" Score="41" ViewCount="18811" Body="&lt;p&gt;This drives me crazy, I do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ft=text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To see something, otherwise all the links disappear in markdown and quotes in JSON.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do disable this once and for all?&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="205" LastEditDate="2016-04-08T09:23:31.800" LastActivityDate="2023-02-25T14:13:00.990" Title="How do I prevent vim from hiding symbols in markdown and json?" Tags="|syntax-highlighting|" AnswerCount="9" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7259" PostTypeId="1" AcceptedAnswerId="7260" CreationDate="2016-04-08T09:20:35.080" Score="3" ViewCount="1685" Body="&lt;p&gt;I tried replacing 30 chars from the beginning of each line of my text, but could not figure out how to specify to &lt;code&gt;vi&lt;/code&gt; &lt;code&gt;sed&lt;/code&gt; to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.{3}/xx/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it could not find my pattern. I thought &lt;code&gt;{3}&lt;/code&gt; would mean &lt;em&gt;3 times&lt;/em&gt; the previous, but unfortunately not. &lt;code&gt;{&lt;/code&gt; is not interpreted as a regex command but as a search char.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;could anyone help?&lt;/p&gt;&#xA;" OwnerUserId="6946" LastEditorUserId="1841" LastEditDate="2016-04-08T09:38:25.933" LastActivityDate="2016-04-08T09:39:32.617" Title="How to replace a fixed number of chars from the beginning?" Tags="|regular-expression|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7260" PostTypeId="2" ParentId="7259" CreationDate="2016-04-08T09:29:21.377" Score="5" Body="&lt;p&gt;If you look at &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2Fmagic&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h magic&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;after:    \v       \m       \M       \V         matches &#xA;                'magic' 'nomagic'&#xA;          $        $        $        \$         matches end-of-line&#xA;          .        .        \.       \.         matches any character&#xA;          *        *        \*       \*         any number of the previous atom&#xA;          ~        ~        \~       \~         latest substitute string&#xA;          ()       \(\)     \(\)     \(\)       grouping into an atom&#xA;          |        \|       \|       \|         separating alternatives&#xA;          \a       \a       \a       \a         alphabetic character&#xA;          \\       \\       \\       \\         literal backslash&#xA;          \.       \.       .        .          literal dot&#xA;          \{       {        {        {          literal '{'&#xA;          a        a        a        a          literal 'a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default node in regular expressions is &lt;code&gt;\m&lt;/code&gt; (just magic), so you need to use &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%7B&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\{&lt;/code&gt;&lt;/a&gt; for the brace to seen as an operator:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                        /\{ E58 E60 E554 E870&#xA;\{n,m}  Matches n to m of the preceding atom, as many as possible&#xA;\{n}    Matches n of the preceding atom&#xA;\{n,}   Matches at least n of the preceding atom, as many as possible&#xA;\{,m}   Matches 0 to m of the preceding atom, as many as possible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/.\{30}/xx/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-04-08T09:29:21.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7261" PostTypeId="2" ParentId="7259" CreationDate="2016-04-08T09:38:09.827" Score="3" Body="&lt;p&gt;In AIX &lt;code&gt;vi&lt;/code&gt;, this will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.\{30\}/xx/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6946" LastEditorUserId="205" LastEditDate="2016-04-08T09:39:32.617" LastActivityDate="2016-04-08T09:39:32.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7262" PostTypeId="1" AcceptedAnswerId="14115" CreationDate="2016-04-08T10:23:29.023" Score="29" ViewCount="7395" Body="&lt;p&gt;I need a motion that moves to end/beginning of a python block, and I need another motion that moves to begining/end of previous/next method/class (all combinations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried vim-indent-object, python-mode, chapa, vim-python-object, etc. None of them support end of block, and none of them support all combinations of above motions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I remember once upon a time I had a plugin that provided &lt;code&gt;]]&lt;/code&gt;, &lt;code&gt;[[&lt;/code&gt;, &lt;code&gt;][&lt;/code&gt; and &lt;code&gt;[]&lt;/code&gt; motions for begining/end of previous/next method/class, but I can't find it in my plugged directory (searched &quot;][&quot; and &quot;[]&quot; in my plugged directory and analyzed all occurrences but didn't find anything that defines &quot;][&quot; or &quot;[]&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know the plugin I used to use? Do you know any plugin that provides this functionality?&lt;/p&gt;&#xA;" OwnerUserId="7153" LastActivityDate="2023-09-20T08:29:43.747" Title="End of python block motion" Tags="|cursor-motions|filetype-python|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7263" PostTypeId="2" ParentId="7258" CreationDate="2016-04-08T12:19:12.523" Score="46" Body="&lt;p&gt;(guessing here, please provide a screenshot/more information)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to change your &lt;code&gt;conceallevel&lt;/code&gt; setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'conceallevel'&#xA;'conceallevel' 'cole'       *'conceallevel'* *'cole'*&#xA;            number (default 0)&#xA;            local to window&#xA;            {not in Vi}&#xA;            {not available when compiled without the |+conceal|&#xA;            feature}&#xA;    Determine how text with the &quot;conceal&quot; syntax attribute |:syn-conceal|&#xA;    is shown:&#xA;&#xA;    Value       Effect ~&#xA;    0       Text is shown normally&#xA;    1       Each block of concealed text is replaced with one&#xA;            character.  If the syntax item does not have a custom&#xA;            replacement character defined (see |:syn-cchar|) the&#xA;            character defined in 'listchars' is used (default is a&#xA;            space).&#xA;            It is highlighted with the &quot;Conceal&quot; highlight group.&#xA;    2       Concealed text is completely hidden unless it has a&#xA;            custom replacement character defined (see&#xA;            |:syn-cchar|).&#xA;    3       Concealed text is completely hidden.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-04-12T06:27:59.707" LastActivityDate="2016-04-12T06:27:59.707" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7264" PostTypeId="1" AcceptedAnswerId="7265" CreationDate="2016-04-08T12:30:03.517" Score="5" ViewCount="2324" Body="&lt;p&gt;Sometimes I write something in brackets and then realize I've typed the wrong kind. For instance, in LaTeX:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\command(arguments)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\command{arguments}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can jump between the two parentheses/braces using &lt;code&gt;%&lt;/code&gt;, but since &lt;code&gt;%&lt;/code&gt; doesn't work after the opening delimiter has been changed, in order to change both of the braces I have to do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%r{f)r}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't seem like a big deal, but I find that switching from brace to parenthesis in the middle of the command sequence creates a surprising amount of cognitive dissonance, and this task often takes much longer than it feels like it ought to. Is there a plugin or simple hack that would provide an easier way? I would like it to be able to handle multiple pairs on the same line, so a simple substitution won't work, and I'd rather not define separate mappings for every pair of delimiters I'd like to convert between. (Just off the top of my head, &lt;code&gt;'&lt;/code&gt;, &lt;code&gt;&quot;&lt;/code&gt;, &lt;code&gt;()&lt;/code&gt;, &lt;code&gt;{}&lt;/code&gt;, and &lt;code&gt;[]&lt;/code&gt; are all in the list I need to convert between, and I'd probably sooner or later find a use for &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A related problem is entirely removing a pair of brackets -- say I'm writing prose and have a sentence in parentheses and then decide it shouldn't be in them anymore. I can use &lt;code&gt;da(&lt;/code&gt; to get rid of the whole clause, or &lt;code&gt;di(&lt;/code&gt; to get rid of the content, but I want to get rid of the parentheses. The resulting command &lt;code&gt;%xf)x&lt;/code&gt; is much less annoying, but there's still some room for improvement.&lt;/p&gt;&#xA;" OwnerUserId="2036" LastActivityDate="2016-04-08T12:51:06.573" Title="Change/delete matching brackets at the same time" Tags="|cursor-motions|replace|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7265" PostTypeId="2" ParentId="7264" CreationDate="2016-04-08T12:51:06.573" Score="8" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-surround&quot;&gt;Surround&lt;/a&gt; does what you want and &lt;em&gt;more&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ds(    delete first surrounding pair of parentheses&#xA;2ds(   delete second surrounding pair of parentheses&#xA;cs[{   change surrounding pair of square brackets into a pair of braces&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help surround&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-08T12:51:06.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7266" PostTypeId="1" AcceptedAnswerId="7267" CreationDate="2016-04-08T13:14:48.207" Score="10" ViewCount="899" Body="&lt;p&gt;On Debian based systems, there is a package named &lt;a href=&quot;https://packages.debian.org/sid/vim-addon-manager&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-addon-manager&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My understanding is that it allows to install some plugins based on a repository of available plugins. To be able to install them, the plugins have to be packaged and pushed to the debian repos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand the point of this package because it seems much less flexible than the &lt;a href=&quot;https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-package-managers/3678#3678&quot;&gt;other plugin managers&lt;/a&gt; which allows to install any plugin from github, a git repo or even a local folder, which allow parallel installation, lazy-loading, etc...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the first place I thought that the package was an old solution created before the other plugin managers and more or less deprecated, but its &lt;a href=&quot;https://salsa.debian.org/vim-team/vim-addon-manager&quot; rel=&quot;nofollow noreferrer&quot;&gt;git repo&lt;/a&gt; seems to indicate that its development is still active.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So my questions are:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there other differences than the available plugins betwwen vim-addon-manager and the other plugin managers? And if so, which differences?&lt;/li&gt;&#xA;&lt;li&gt;Are the packages and the other managers meant for the same purpose or are they complementary&lt;/li&gt;&#xA;&lt;li&gt;In which use-case is it more convenient to use the package instead of the other plugins?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; that my question is inspired by &lt;a href=&quot;https://vi.stackexchange.com/q/7249/1841&quot;&gt;this one&lt;/a&gt; but here I am not asking how to use the package, but rather why would someone need it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="15" LastEditDate="2018-05-29T23:56:17.173" LastActivityDate="2018-05-29T23:57:53.217" Title="When should I use vim-addon-manager instead of a regular package manager?" Tags="|plugin-system|plugin-managers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7267" PostTypeId="2" ParentId="7266" CreationDate="2016-04-08T14:11:20.953" Score="16" Body="&lt;p&gt;N.B., I'm one of the original authors of &lt;a href=&quot;https://manpages.debian.org/stable/vim-addon-manager/vam.1&quot; rel=&quot;noreferrer&quot;&gt;Debian's vim-addon-manager&lt;/a&gt; (which I'll refer to as dvam for the rest of this answer, to avoid confusion with &lt;a href=&quot;https://github.com/MarcWeber/vim-addon-manager&quot; rel=&quot;noreferrer&quot;&gt;Marc Weber's vam&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;dvam is intended solely to manage addons that are distributed in the form of Debian packages.  There are people that prefer, for various reason, to use packaged software even for things like Vim addons, instead of getting the software directly from upstream.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the broader sense, yes dvam and more general tools like plug, vundle, etc. are meant for the same purpose -- providing a mechanism for enabling the use of certain addons in your Vim environment.  They are targeting different use cases, though, and can be used to complement each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;dvam intends to give a user of a Debian-based system control over which packaged addons are enabled, both system-wide and for a specific user.  That is, it tries to solve the use cases of a sysadmin installing and enabling a packaged addon in the system-wide config but allowing the user to disable it, as well as the reverse (enabling an addon that's disabled in the system-wide config).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some warts in the way Debian's tool was initially designed (symlinking individual files rather than working on directory like pathogen does) which haven't fully been addressed yet.  I've been dragging my feet on fixing that, but should revisit it to see if Vim's new &lt;code&gt;'packpath'&lt;/code&gt;/&lt;code&gt;:packadd&lt;/code&gt; features help me with that at all.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2018-05-29T23:57:53.217" LastActivityDate="2018-05-29T23:57:53.217" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7268" PostTypeId="2" ParentId="3153" CreationDate="2016-04-08T15:42:13.973" Score="2" Body="&lt;p&gt;The suggested solution didn't work for me. &lt;code&gt;formatprg_args_expr_xml&lt;/code&gt; is no longer recognized in the current version (at &lt;a href=&quot;https://github.com/Chiel92/vim-autoformat/tree/713e7c258052d94dfd752647ea03cf423cace8ff&quot; rel=&quot;nofollow&quot;&gt;713e7c2&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I solved the issue by adding these two lines in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:formatdef_fmt_custom_xml = '&quot;tidy -xml -q --show-errors 0 --show-warnings 0 --indent-attributes 1&quot;'&#xA;let g:formatters_xml = ['fmt_custom_xml']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course I had to make sure tidy is already installed and present in my &lt;code&gt;$PATH&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5643" LastActivityDate="2016-04-08T15:42:13.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7269" PostTypeId="2" ParentId="6795" CreationDate="2016-04-08T16:29:16.137" Score="0" Body="&lt;p&gt;Change it to &lt;code&gt;&amp;lt;C-S-k&amp;gt;&lt;/code&gt;. It works fine for me. You can give some other key also, like &lt;code&gt;&amp;lt;F10&amp;gt;&lt;/code&gt; for &lt;code&gt;:wq!&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;F10&amp;gt; :wq!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="15" LastEditDate="2016-04-08T16:42:11.653" LastActivityDate="2016-04-08T16:42:11.653" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7270" PostTypeId="2" ParentId="7252" CreationDate="2016-04-08T16:36:32.780" Score="2" Body="&lt;p&gt;You should try following the procedure described on &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-2.5&quot; rel=&quot;nofollow&quot;&gt;Vim-FAQ  2.5&lt;/a&gt;. Some relevant parts follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2.5. I have a &quot;xyz&quot; (some) problem with Vim. How do I determine it is a&#xA;       problem with my setup or with Vim?  / Have I found a bug in Vim?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;First, you need to find out, whether the error is in the actual&#xA;  runtime files or any plugin that is distributed with Vim or whether it&#xA;  is a simple side effect of any configuration option from your .vimrc&#xA;  or .gvimrc. So first, start vim like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;this starts Vim in nocompatible mode (-N), without reading your&#xA;  viminfo file (-i NONE), without reading any configuration file (-u&#xA;  NONE for not reading .vimrc file and -U NONE for not reading a .gvimrc&#xA;  file) or even plugin.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If the error does not occur when starting Vim this way, then the&#xA;  problem is either related to some plugin of yours or some setting in&#xA;  one of your local setup files. You need to find out, what triggers the&#xA;  error, you try starting Vim this way: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;If the error occurs, the problem is your .viminfo file. Simply delete&#xA;  the viminfo file then. If the error does not occur, try: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u ~/.vimrc --noplugin -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This will simply use your .vimrc as configuration file, but not load&#xA;  any plugins. If the error occurs this time, the error is possibly&#xA;  caused by some configuration option inside your .vimrc file. Depending&#xA;  on the length of your vimrc file, it can be quite hard to trace the&#xA;  origin within that file.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The best way is to add :finish command in the middle of your .vimrc.&#xA;  Then restart again using the same command line. If the error still&#xA;  occurs, the bug must be caused because of a setting in the first half&#xA;  of your .vimrc. If it doesn't happen, the problematic setting must be&#xA;  in the second half of your .vimrc. So move the :finish command to the&#xA;  middle of that half, of which you know that triggers the error and&#xA;  move your way along, until you find the problematic option. If your&#xA;  .vimrc is 350 lines long, you need at a maximum 9 tries to find the&#xA;  offending line (in practise, this can often be further reduced, since&#xA;  often lines depend on each other).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If the problem does not occur, when only loading your .vimrc file, the&#xA;  error must be caused by a plugin or another runtime file (indent&#xA;  autoload or syntax script). Check the output of the :scriptnames&#xA;  command to see what files have been loaded and for each one try to&#xA;  disable each one by one and see which one triggers the bug. Often&#xA;  files that are loaded by vim, have a simple configuration variable to&#xA;  disable them, but you need to check inside each file separately.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-04-08T16:36:32.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7271" PostTypeId="2" ParentId="6858" CreationDate="2016-04-08T16:43:25.130" Score="1" Body="&lt;p&gt;Check whether the color scheme's name is mentioned properly, for case sensitivity.&#xA;Also, check whether &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let colors_name = &quot;name&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is found or not. If not, add this line and try again.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-04-08T18:12:15.827" LastActivityDate="2016-04-08T18:12:15.827" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7272" PostTypeId="2" ParentId="6858" CreationDate="2016-04-08T21:37:34.793" Score="5" Body="&lt;p&gt;Try this to help troubleshoot the issue:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Check the location where you have downloaded the color proton.vim file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Linux, the system default will be something like &lt;code&gt;/usr/share/vim/vim74/colors/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On MSWindows, the system default will be something like   &lt;code&gt;C:\Program Files (x86)\Vim\vim74\colors\&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also try setting up a home directory for colors: &lt;code&gt;$HOME/.vim/colors&lt;/code&gt; on Linux, or &lt;code&gt;$HOME/vimfiles/colors&lt;/code&gt; on MSWindows.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;See if the color scheme shows up outside of your &lt;code&gt;~/.vimrc&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Restart vim, then per &lt;a href=&quot;https://stackoverflow.com/questions/7331940/how-to-get-the-list-of-all-installed-color-schemes-in-vim&quot;&gt;this StackOverflow post&lt;/a&gt;, type &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:colorscheme&lt;/code&gt; then &lt;kbd&gt;Space&lt;/kbd&gt; followed by &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should list your colorscheme along with all other color schemes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;  &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; returns one list which shows all color schemes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use  &lt;code&gt;:colorscheme&lt;/code&gt; then &lt;kbd&gt;Space&lt;/kbd&gt; followed by &lt;kbd&gt;TAB&lt;/kbd&gt; you will iterate over the list of color schemes, one at a time, each time you press &lt;kbd&gt;TAB&lt;/kbd&gt;   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also see this behaviour if you use  &lt;code&gt;:colorscheme&lt;/code&gt; then &lt;kbd&gt;Space&lt;/kbd&gt; followed by &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;  ; you will iterate over the list of color schemes, one at a time, each time you press &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I troubleshoot an issue like this, I prefer &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; so I may see the entire list at once.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;type &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:let colors_name&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to return the name of the current colorscheme in use by vim&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you've added it to &lt;code&gt;~/.vimrc&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;to confirm which .vimrc file is being loaded by vim, type&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:scriptnames&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will show you the path to the &lt;code&gt;.vimrc&lt;/code&gt;, &#xA;the path to the current colorscheme loaded,&#xA;and all scripts sourced so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This file will be  &lt;code&gt;~\_vimrc&lt;/code&gt; on MSWindows.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-05-09T22:51:41.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7273" PostTypeId="1" AcceptedAnswerId="7558" CreationDate="2016-04-08T22:23:04.270" Score="1" ViewCount="641" Body="&lt;p&gt;I have a ultisnip that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet &quot;[A-Z]+-[0-9]+&quot; &quot;Jira Link&quot; r&#xA;[`!p snip.rv = match.group(0)`](https://ellation.atlassian.net/browse/`!p snip.rv = match.group(0)`)&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine. But I was hoping there might be a way to do this &lt;em&gt;without&lt;/em&gt; duplicating the two python blocks?&lt;/p&gt;&#xA;" OwnerUserId="1787" LastActivityDate="2016-04-30T09:58:48.410" Title="UltiSnip: Insert matched regex" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7274" PostTypeId="1" CreationDate="2016-04-08T23:35:52.703" Score="0" ViewCount="221" Body="&lt;p&gt;Of course in Vim you have &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; to increment a number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this POSIX specified?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I increment (or decrement) a number portably, such as in a scripted edit with &lt;code&gt;ex&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if the answer is just &quot;Use an external filter,&quot; what would be the best POSIX-specified tool for this job?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example specific requirement:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Increment the number found in the final field of line 1 by 1.&lt;/li&gt;&#xA;&lt;li&gt;Decrement the number found in the final field of line 2 by 1.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Example input:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Here is    a    number: 5&#xA;Here is another number: 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Here is    a    number: 6&#xA;Here is another number: 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2016-04-09T06:49:07.580" Title="Increment a number using POSIX features only?" Tags="|ex-mode|posix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7275" PostTypeId="2" ParentId="7274" CreationDate="2016-04-09T06:49:07.580" Score="2" Body="&lt;p&gt;&lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt; being normal mode commands, they are not really expected to work in &lt;code&gt;ex&lt;/code&gt; which doesn't have normal mode. Furthermore, those commands are not defined in &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/&quot; rel=&quot;nofollow&quot;&gt;the POSIX standard&lt;/a&gt;, either for &lt;code&gt;vi&lt;/code&gt; or for &lt;code&gt;ex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for a portable solution, you should probably write an &lt;code&gt;awk&lt;/code&gt; script that would contain something like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'{gsub( &quot;number: \d&quot;, &quot;number: &quot; $5++ ); print }' foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-09T06:49:07.580" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7276" PostTypeId="1" AcceptedAnswerId="7277" CreationDate="2016-04-09T10:50:32.597" Score="8" ViewCount="1515" Body="&lt;p&gt;When i check my mappings with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verb nmap y &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n  y&amp;lt;C-G&amp;gt;      *@:call setreg(v:register, &amp;lt;SNR&amp;gt;104_recall())&amp;lt;CR&amp;gt;&#xA;        Last set from ~/.vim/bundle/vim-fugitive-2.2/plugin/fugitive.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I try to unmap it with &lt;code&gt;:unmap y&amp;lt;C-G&amp;gt;&lt;/code&gt; and with &lt;code&gt;:unmap y&amp;lt;C-g&amp;gt;&lt;/code&gt;, but it has no effect and i get the error &lt;code&gt;E31: No such mapping&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can i remove this mapping?  Why doesn't &lt;code&gt;:unmap y&amp;lt;C-G&amp;gt;&lt;/code&gt; work here?&lt;/p&gt;&#xA;" OwnerUserId="1248" LastActivityDate="2016-04-09T22:33:48.630" Title="I cannot unmap a key combination `y&lt;C-G&gt;`" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7277" PostTypeId="2" ParentId="7276" CreationDate="2016-04-09T11:09:56.213" Score="8" Body="&lt;p&gt;It seems the mapping is local to a buffer as it was &lt;a href=&quot;https://github.com/tpope/vim-fugitive/blob/841adb49add27ccc45e73e231d02103f1be987c4/plugin/fugitive.vim#L200&quot; rel=&quot;noreferrer&quot;&gt;defined&lt;/a&gt; with the argument &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;.&lt;br&gt;&#xA;When you type &lt;code&gt;:unmap y&amp;lt;C-G&amp;gt;&lt;/code&gt;, you ask Vim to unmap a global mapping whose &lt;code&gt;{lhs}&lt;/code&gt; is &lt;code&gt;y&amp;lt;C-G&amp;gt;&lt;/code&gt;, but there's probably no such global mapping on your system hence the error.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to unmap the local mapping, you have to use the same argument &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; which was used to define it: &lt;code&gt;:unmap &amp;lt;buffer&amp;gt; y&amp;lt;C-G&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To automate the process you could install an autocmd watching the events &lt;code&gt;VimEnter&lt;/code&gt;, &lt;code&gt;BufNewFile&lt;/code&gt; and &lt;code&gt;BufReadPost&lt;/code&gt;. It would test if the mapping exists &lt;code&gt;if !empty(maparg('y&amp;lt;C-G&amp;gt;', 'n'))&lt;/code&gt;, before trying to delete it. It could give something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup custom_fugitive&#xA;    autocmd!&#xA;    autocmd VimEnter,BufNewFile,BufReadPost * if !empty(maparg('y&amp;lt;C-G&amp;gt;', 'n')) | unmap &amp;lt;buffer&amp;gt; y&amp;lt;C-G&amp;gt;| endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You couldn't write this in your &lt;code&gt;vimrc&lt;/code&gt; because the latter is sourced before your plugins which would override anything you do. Instead you would have to write it inside &lt;code&gt;~/.vim/after/plugin/mappings.vim&lt;/code&gt;. The filename (&lt;code&gt;mappings.vim&lt;/code&gt;) doesn't matter, only the directory is important (&lt;code&gt;~/.vim/after/plugin/&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As your last &lt;a href=&quot;https://vi.stackexchange.com/questions/7276/i-cannot-unmap-a-key-combination-yc-g#comment11936_7276&quot;&gt;comment&lt;/a&gt; says it, it seems there's another way to disable the mapping. &lt;code&gt;fugitive&lt;/code&gt; install the mappings &lt;code&gt;&amp;lt;C-R&amp;gt;&amp;lt;C-G&amp;gt;&lt;/code&gt; and &lt;code&gt;y&amp;lt;C-G&amp;gt;&lt;/code&gt; only if &lt;code&gt;g:fugitive_no_maps&lt;/code&gt; is different than zero. So if you include &lt;code&gt;let g:fugitive_no_maps=1&lt;/code&gt; inside your &lt;code&gt;vimrc&lt;/code&gt;, &lt;code&gt;y&amp;lt;C-G&amp;gt;&lt;/code&gt; should not be defined.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-04-09T22:33:48.630" LastActivityDate="2016-04-09T22:33:48.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7278" PostTypeId="2" ParentId="3875" CreationDate="2016-04-09T11:54:08.053" Score="3" Body="&lt;p&gt;These mappings will do exactly what you are looking for.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-n&amp;gt; @=&quot;m`o\eg``&quot;&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;c-p&amp;gt; @=&quot;m`O\eg``&quot;&amp;lt;cr&amp;gt;   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These insert n number of newlines before or after the cursor; keeping the cursor exactly where it is, without changing the jump list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution is to just make a shortcut that fills the &#xA;unnamed register with a newline. Then you can just use the put&#xA;commands, p or P to insert newlines. &#xA;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &quot;&amp;lt;cr&amp;gt; :let @@=&quot;\n&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7166" LastEditorUserId="7166" LastEditDate="2016-04-19T21:41:40.240" LastActivityDate="2016-04-19T21:41:40.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7279" PostTypeId="2" ParentId="376" CreationDate="2016-04-09T12:53:32.553" Score="1" Body="&lt;p&gt;In the vim help manual there's pretty nice mapping to make a word all  caps in insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-h&amp;gt; &amp;lt;esc&amp;gt;gUiw`]a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses &lt;kbd&gt;ctrl-h&lt;/kbd&gt;, which is normally just a backspace clone, so you're &#xA;not really losing anything with this mapping. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Caps lock is a nightmare when you're in normal mode!&#xA;I hope that helps!&lt;/p&gt;&#xA;" OwnerUserId="7166" LastEditorUserId="1841" LastEditDate="2016-04-09T13:41:15.410" LastActivityDate="2016-04-09T13:41:15.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7280" PostTypeId="2" ParentId="7256" CreationDate="2016-04-09T13:15:28.420" Score="1" Body="&lt;p&gt;The simplest solution I can think of is to set the previous context mark &lt;code&gt;m`&lt;/code&gt; when leaving insert mode. Then use &lt;code&gt;``&lt;/code&gt; to return to that location after editing elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note: that those are backtics &lt;code&gt;`&lt;/code&gt; and not normal apostrophes &lt;code&gt;'&lt;/code&gt;) &lt;br&gt;&#xA;A mapping like &lt;code&gt;:inoremap  m`&lt;/code&gt; can also be useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(edit)&lt;br&gt;&#xA;g; and g, should work great too! I'm glad I saw your comment, nicmus.&lt;/p&gt;&#xA;" OwnerUserId="7166" LastEditorUserId="7166" LastEditDate="2016-04-10T08:16:03.843" LastActivityDate="2016-04-10T08:16:03.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7281" PostTypeId="1" AcceptedAnswerId="7295" CreationDate="2016-04-09T16:55:43.817" Score="3" ViewCount="94" Body="&lt;p&gt;Due to some issues with the Programmer Dvorak implementation on my operating system and the desire to make a couple of small tweaks to the layout, I'm trying to implement the remapping entirely in vim (I don't type enough punctuation in any other editor to make this a limitation). I added &lt;code&gt;noremap&lt;/code&gt;, &lt;code&gt;inoremap&lt;/code&gt;, and &lt;code&gt;cnoremap&lt;/code&gt; commands to a Vimscript file, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap 1 &amp;amp;&#xA;inoremap ! %&#xA;inoremap 2 [&#xA;inoremap 3 {&#xA;inoremap 4 }&#xA;[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I source this file I can type perfectly in insert mode, and normal mode commands work as expected as well. However, characterwise search with &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt;, or &lt;code&gt;T&lt;/code&gt; unfortunately doesn't respect these mappings, it uses my system keyboard layout. This is probably to be expected from the method I've used, but is there any way to get around this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit to add: The same problem occurs in single-character replace with &lt;code&gt;r&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2036" LastEditorUserId="2036" LastEditDate="2016-04-09T17:23:03.017" LastActivityDate="2016-04-10T12:29:56.817" Title="Remapping keys for purpose of characterwise search" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7282" PostTypeId="1" CreationDate="2016-04-09T16:58:38.493" Score="3" ViewCount="77" Body="&lt;p&gt;I'm trying to understand how vimdiff work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here I tried to diff two simple files. The 1st:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abcdefghijklmnopqrstuvwxyz&#xA;&#xA;foo&#xA;&#xA;abcdefghijklmnopqrstuvwxyz iii&#xA;&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The 2nd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abcdefghijklmnopqrstuvwxyz&#xA;&#xA;abcdefghijklmnopqrstuvwxyz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is result from diffmerge utility:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/U641j.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/U641j.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is result from vim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CjAZn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CjAZn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that vim doesn't see the similarity between &lt;code&gt;abc...xyz&lt;/code&gt; and &lt;code&gt;abc...xyz iii&lt;/code&gt; lines and doesn't arrange them visually on one line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some settings to improve vimdiff in such cases?&lt;/p&gt;&#xA;" OwnerUserId="7169" LastActivityDate="2016-04-09T16:58:38.493" Title="The way to imrove vimdiff similarity-searching mechanism" Tags="|vimdiff|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7283" PostTypeId="1" AcceptedAnswerId="7284" CreationDate="2016-04-09T18:35:14.393" Score="5" ViewCount="972" Body="&lt;p&gt;Following &lt;a href=&quot;http://vim.wikia.com/wiki/Change_font_size_quickly#Mapping_solution&quot; rel=&quot;noreferrer&quot;&gt;this Vim tip&lt;/a&gt;, I've made two mappings to change font size on scroll wheel:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-ScrollWheelUp&amp;gt; :silent! let &amp;amp;guifont=substitute(&amp;amp;guifont,' \zs\d\+','\=eval(submatch(0)+1)','')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-ScrollWheelDown&amp;gt; :silent! let &amp;amp;guifont=substitute(&amp;amp;guifont,' \zs\d\+','\=eval(submatch(0)-1)','')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But despite the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; at the end, on single Ctrl+Scroll I still get &quot;Press Enter or type command to continue&quot; message, while the command above it is echoed without the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I suppress this message so that multiple successive scrolls just gradually changed the font size without need to press Enter after each scroll event?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it matters, I'm on Linux with GTK2 GUI for gVim.&lt;/p&gt;&#xA;" OwnerUserId="1081" LastActivityDate="2016-04-09T18:52:16.507" Title="How to avoid &quot;Press Enter or type command&quot; after execution of a mapped command?" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7284" PostTypeId="2" ParentId="7283" CreationDate="2016-04-09T18:52:16.507" Score="4" Body="&lt;p&gt;Adding a second &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; at the end fixes it for me. I have to admit I'm not sure why you need it, though.&lt;/p&gt;&#xA;" OwnerUserId="2036" LastActivityDate="2016-04-09T18:52:16.507" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7285" PostTypeId="1" CreationDate="2016-04-09T19:05:45.340" Score="4" ViewCount="3107" Body="&lt;p&gt;I assume this is coming from a Vim plugin, but I get no leads on where to look. What's the best way of debugging it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vim: Caught deadly signal SEGV&#xA;Vim: Finished.&#xA;&#xA;[1]    8119 segmentation fault &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4748" LastEditorUserId="51" LastEditDate="2016-07-21T17:33:45.550" LastActivityDate="2016-07-21T17:33:45.550" Title="How to debug a segmentation fault?" Tags="|linux|crash|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7286" PostTypeId="2" ParentId="7285" CreationDate="2016-04-09T23:20:24.327" Score="1" Body="&lt;p&gt;This has been here for four hours, I'll give you what help I can. The classical way of debugging programs is with &lt;code&gt;gdb&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ulimit -c unlimited&#xA;$ # [do whatever generates the segmentation fault]&#xA;$ ls -ld *core* # see new core file that I'll call $core&#xA;$ file $core # see program name that I'll call $program&#xA;$ gdb $program $core&#xA;(gdb) bt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should hopefully give a backtrace of function calls. If you're unlucky you'll get lots of ??, which means that debugging symbols are not enabled. You could get around that with access to the original program objects, but I don't suppose you'd have those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, one might also run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ gdb $program&#xA;(gdb) run arg1 arg2 argetc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However my experience with this is almost only with non-UI programs. I have no idea if either method will work when the segmentation fault happens inside a vim plugin . . .&lt;/p&gt;&#xA;" OwnerUserId="5466" LastActivityDate="2016-04-09T23:20:24.327" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7287" PostTypeId="1" CreationDate="2016-04-10T00:35:47.220" Score="3" ViewCount="592" Body="&lt;p&gt;There is a &lt;code&gt;CompleteDone&lt;/code&gt; and &lt;code&gt;MenuPopup&lt;/code&gt; event. However, I can't find an event for the triggering of the insert mode completion popup menu. So if I want to do something when triggering the completion popup menu, what should I do?&lt;br/&gt;&#xA;Since when navigating fast through a long long completion popup menu the menu usually flickers, I want to disable &lt;code&gt;cursorline&lt;/code&gt; and &lt;code&gt;cursorcolumn&lt;/code&gt; when I am navigating it in order to get a better performance. After the completion done, I can enable &lt;code&gt;cursorline&lt;/code&gt; and &lt;code&gt;cursorcolumn&lt;/code&gt; again using the &lt;code&gt;CompletionDone&lt;/code&gt; event.&lt;br/&gt;&#xA;If there isn't any event for this, can I at least make the &lt;code&gt;cursorcolumn&lt;/code&gt; still when I am navigating the completion menu? Now the highlighted cursor column will change all the time when I am navigating the menu.&lt;br/&gt;&#xA;Thanks very much!&lt;br/&gt;&#xA;One more question: is there any way to detect &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt;, that is when the screen is scrolling? For now, I will disable &lt;code&gt;cursorline&lt;/code&gt; when &lt;code&gt;CursorMoved&lt;/code&gt; is triggered. But &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt; sometimes won't trigger the &lt;code&gt;CursorMoved&lt;/code&gt; event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&#xA;These are all the plugins that I have installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'gtags.vim'&#xA;Plugin 'tpope/vim-surround'&#xA;Plugin 'closetag.vim'&#xA;Plugin 'majutsushi/tagbar'&#xA;Plugin 'Yggdroot/LeaderF'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4754" LastEditorUserId="246" LastEditDate="2016-07-10T02:39:35.083" LastActivityDate="2016-07-10T02:39:35.083" Title="Is there an autocmd event while triggering the insert mode completion popup menu?" Tags="|autocompletion|autocmd|performance|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7288" PostTypeId="2" ParentId="7167" CreationDate="2016-04-10T05:55:28.213" Score="1" Body="&lt;p&gt;Let's suppose you have the following lines in your &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/macros/matchit.vim&#xA;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the offending  lines are in a &lt;code&gt;.html&lt;/code&gt; file, then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b:match_words = '&amp;lt;:&amp;gt;,' .&#xA;    \ '&amp;lt;\@&amp;lt;=[ou]l\&amp;gt;[^&amp;gt;]*\%(&amp;gt;\|$\):&amp;lt;\@&amp;lt;=li\&amp;gt;:&amp;lt;\@&amp;lt;=/[ou]l&amp;gt;,' .&#xA;    \ '&amp;lt;\@&amp;lt;=dl\&amp;gt;[^&amp;gt;]*\%(&amp;gt;\|$\):&amp;lt;\@&amp;lt;=d[td]\&amp;gt;:&amp;lt;\@&amp;lt;=/dl&amp;gt;,' .&#xA;    \ '&amp;lt;\@&amp;lt;=\([^/][^ \t&amp;gt;]*\)[^&amp;gt;]*\%(&amp;gt;\|$\):&amp;lt;\@&amp;lt;=/\1&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the other hand, if they're in a &lt;code&gt;.jsx&lt;/code&gt; file and you're using &lt;a href=&quot;https://github.com/mxw/vim-jsx&quot; rel=&quot;nofollow&quot;&gt;vim-jsx&lt;/a&gt; (see &lt;a href=&quot;https://github.com/mxw/vim-jsx/blob/master/after/ftplugin/jsx.vim#L13-L14&quot; rel=&quot;nofollow&quot;&gt;jsx.vim&lt;/a&gt;), then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b:match_words = '(:),\[:\],{:},&amp;lt;:&amp;gt;,' .&#xA;    \ '&amp;lt;\@&amp;lt;=\([^/][^ \t&amp;gt;]*\)[^&amp;gt;]*\%(&amp;gt;\|$\):&amp;lt;\@&amp;lt;=/\1&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even though both values work well, It's necessary to take into account the following cases:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There could be some &lt;code&gt;&amp;gt;&lt;/code&gt; into some tags.&lt;/li&gt;&#xA;&lt;li&gt;There could be some tags with or without closing tags.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And you can do so by replacing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;\@&amp;lt;=\([^/][^ \t&amp;gt;]*\)[^&amp;gt;]*\%(&amp;gt;\|$\):&amp;lt;\@&amp;lt;=/\1&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;\@&amp;lt;=\([^/][^ \t&amp;gt;]*\)[^&amp;gt;]*\%(\%(=\|/\)\@&amp;lt;!&amp;gt;\|$\):&amp;lt;\@&amp;lt;=/\1&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; When you're using a &lt;code&gt;.jsx&lt;/code&gt; file but you aren't using any plugin, the &lt;code&gt;b:match_words&lt;/code&gt; variable doesn't exist. In that case you could issue the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let b:match_words='(:),\[:\],{:},&amp;lt;:&amp;gt;,&amp;lt;\@&amp;lt;=\([^/][^ \t&amp;gt;]*\)[^&amp;gt;]*\%(\%(=\|/\)\@&amp;lt;!&amp;gt;\|$\):&amp;lt;\@&amp;lt;=/\1&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="6698" LastEditDate="2016-04-10T18:27:23.360" LastActivityDate="2016-04-10T18:27:23.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7289" PostTypeId="2" ParentId="7287" CreationDate="2016-04-10T08:57:12.777" Score="1" Body="&lt;p&gt;First, addressing the low level issue…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's no flickering at all in the popup menu, no matter how long it is or if &lt;code&gt;cursorline&lt;/code&gt; and/or &lt;code&gt;cursorcolumn&lt;/code&gt; are enabled or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Flickering only happens in YCM (and possibly other bloated &quot;autocompletion&quot; plugins) where — judging by the volume of flicker issues — it is a &lt;em&gt;very&lt;/em&gt; common annoyance. I'd suggest trying to work with that plugin's author toward a proper solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, addressing the high level issue…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The standard way to customize the behavior of the popup menu consists of checking if you are in the popup menu from within insert mode mapping. Given the relative complexity of your requirements, you should put your logic into a proper function that you would use like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-n&amp;gt; &amp;lt;C-n&amp;gt;&amp;lt;C-r&amp;gt;=pumvisible() ? MyFunction() : &quot;\&amp;lt;lt&amp;gt;C-n&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-10T08:57:12.777" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7291" PostTypeId="2" ParentId="7179" CreationDate="2016-04-10T09:30:41.100" Score="0" Body="&lt;p&gt;If I understand the question correctly, I think I found a pretty good solution. You could use these to mappings to achieve the desired result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap  &amp;lt;space&amp;gt;: m`:&#xA;cnoremap &amp;lt;c-j&amp;gt; &amp;lt;cr&amp;gt;``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you want to simply replace the normal functionality:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap  : m`:&#xA;cnoremap &amp;lt;cr&amp;gt; &amp;lt;cr&amp;gt;``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These mapping will allow you to do something like &lt;code&gt;:%s/  /    /&lt;/code&gt; for an entire file without moving the screen or cursor at all.&lt;/p&gt;&#xA;" OwnerUserId="7166" LastActivityDate="2016-04-10T09:30:41.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7292" PostTypeId="1" AcceptedAnswerId="7294" CreationDate="2016-04-10T10:15:53.853" Score="6" ViewCount="911" Body="&lt;p&gt;I wanted to highlight all occurence of TODO and NOTE in my code.&#xA;Looking on the internet, I inserted the following code in my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:match GruvboxGreenBold /NOTE/&#xA;:2match ErrorMsg /TODO/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seemed to work fine at first. When I open a file with gvim, the syntax highlights correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as soon as I split my screen and the file appears twice, the second one get the correct highlighting but the first one loses it.&#xA;It repeats whenever I open a new buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a screenshot &lt;a href=&quot;https://i.stack.imgur.com/dq67k.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dq67k.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to correct this behavior ?&lt;/p&gt;&#xA;" OwnerUserId="7175" LastActivityDate="2016-04-10T13:43:07.103" Title="Highlighting with :match does not appear in all buffers" Tags="|syntax-highlighting|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7293" PostTypeId="2" ParentId="7193" CreationDate="2016-04-10T10:38:39.650" Score="3" Body="&lt;p&gt;When Vim joins a line that ends with a period to another line, it inserts two spaces between them. This is because &lt;code&gt;joinspaces&lt;/code&gt; is on by default. To make &lt;code&gt;gq&lt;/code&gt; only insert one space between lines, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nojs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim is also set to collapse lines shorter than textwidth with &lt;code&gt;gq&lt;/code&gt;. To make &lt;code&gt;gq&lt;/code&gt; not join lines together, you can use the format option &lt;code&gt;w&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set fo+=w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This option makes vim only collapses lines that end with a space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this helps! For more information see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27js%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help js&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#fo-table&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help fo-table&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7166" LastEditorUserId="7166" LastEditDate="2016-04-12T02:26:56.427" LastActivityDate="2016-04-12T02:26:56.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7294" PostTypeId="2" ParentId="7292" CreationDate="2016-04-10T11:55:24.810" Score="5" Body="&lt;p&gt;From &lt;code&gt;:help :match&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Note that highlighting the last used search pattern with&#xA;    'hlsearch' is used in all windows, while the pattern defined&#xA;    with &quot;:match&quot; only exists in the current window.  It is kept&#xA;    when switching to another buffer.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that the highlighting created by &lt;code&gt;:match&lt;/code&gt; is local to the current window, not to the current buffer. When you split your screen, you create a new window, so you probably have to reapply your highlighting.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want &lt;code&gt;:match&lt;/code&gt; and &lt;code&gt;:2match&lt;/code&gt; to be automatically executed whenever you launch Vim or enter a new window, you could install the following autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup custom_highlighting&#xA;    autocmd!&#xA;    autocmd VimEnter,WinEnter * match GruvboxGreenBold /NOTE/ | 2match ErrorMsg /TODO/&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-04-10T13:43:07.103" LastActivityDate="2016-04-10T13:43:07.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7295" PostTypeId="2" ParentId="7281" CreationDate="2016-04-10T12:19:45.277" Score="3" Body="&lt;p&gt;From &lt;code&gt;:help language-mapping&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                    *language-mapping*&#xA;&quot;:lmap&quot; defines a mapping that applies to:&#xA;- Insert mode&#xA;- Command-line mode&#xA;- when entering a search pattern&#xA;- the argument of the commands that accept a text character, such as &quot;r&quot; and&#xA;  &quot;f&quot;&#xA;- for the input() line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems &lt;code&gt;:lmap&lt;/code&gt; is a good way to define a mapping which would be used in insert mode and command-line mode, as well as affect the argument of the commands &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;r&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lnoremap 1 &amp;amp;&#xA;lnoremap ! %&#xA;lnoremap 2 [&#xA;lnoremap 3 {&#xA;lnoremap 4 }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These mappings will be used only if the value of the option &lt;code&gt;'iminsert'&lt;/code&gt; is &lt;code&gt;1&lt;/code&gt;. By default its value is &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;2&lt;/code&gt;, and it's local to the current buffer. To toggle the value, you can hit &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; in insert mode.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To see if the &lt;code&gt;:lmap&lt;/code&gt; mappings are on or off, you could add an indicator in your statusline such as:&lt;br&gt;&#xA;&lt;code&gt;set stl+=lmap:%{&amp;amp;imi==1?'on':'off'}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To enable the &lt;code&gt;:lmap&lt;/code&gt; mappings by default without having to hit &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;, you could add &lt;code&gt;set imi=1&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt;. Or you could install an autocmd which would set its value depending on some circumstances. See &lt;a href=&quot;https://vi.stackexchange.com/a/6965/6960&quot;&gt;here&lt;/a&gt; for an example where the &lt;code&gt;:lmap&lt;/code&gt; mappings are enabled everywhere except in insert mode.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-04-10T12:29:56.817" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7296" PostTypeId="1" CreationDate="2016-04-10T15:32:03.900" Score="1" ViewCount="101" Body="&lt;p&gt;Is there an option to make vim expand an abbreviaiation at the end of a word?&#xA;In other words let's say I map &lt;code&gt;:iab bb bar&lt;/code&gt;, how can I get the expansion:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;foobb&amp;lt;space&amp;gt;&lt;/code&gt; = &lt;code&gt;foobar&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6848" LastActivityDate="2016-04-10T15:32:03.900" Title="vim insert abbreviation with text in front of the map" Tags="|abbreviations|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7298" PostTypeId="1" AcceptedAnswerId="7304" CreationDate="2016-04-11T05:11:21.587" Score="3" ViewCount="942" Body="&lt;p&gt;Given file &lt;em&gt;alfa.txt&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foxtrot&#xA;golf&#xA;hotel&#xA;india&#xA;juliet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to insert a newline after lines 2 and 4. I have this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '2pu_|4pu_|x' alfa.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However it is inserting lines after line 2 and 3, instead of 2 and 4:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foxtrot&#xA;golf&#xA;&#xA;hotel&#xA;&#xA;india&#xA;juliet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="7184" LastEditDate="2016-04-16T15:46:42.853" LastActivityDate="2016-04-17T01:28:43.977" Title="Insert blank line after different lines" Tags="|ex-mode|ex-command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7299" PostTypeId="2" ParentId="7298" CreationDate="2016-04-11T06:08:42.903" Score="6" Body="&lt;p&gt;The commands are executed serially, which means that before the &lt;code&gt;4pu_&lt;/code&gt; command is executed, a newline has already been added and your previous line 4 is now line 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are at least three ways to solve this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Start from the back. This way, previous changes do not affect later changes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As suggested by Christian Brabrandt, you can add newlines based on a global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\v^%2l|%4l/pu _&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To understand this command, read about &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html#:global&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :global&lt;/code&gt;&lt;/a&gt;. &lt;em&gt;Note:&lt;/em&gt; To save a keypress I've used &lt;code&gt;\v&lt;/code&gt;. With &lt;code&gt;\v&lt;/code&gt;, we don't need to escape the &lt;code&gt;%l&lt;/code&gt; and &lt;code&gt;|&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Manually add to the number(s), i.e. do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '2pu_|5pu_|x' alfa.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2016-04-12T06:20:17.907" LastActivityDate="2016-04-12T06:20:17.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7300" PostTypeId="1" AcceptedAnswerId="7307" CreationDate="2016-04-11T11:57:12.213" Score="6" ViewCount="2650" Body="&lt;p&gt;I'm using Vim on a machine through SSH with PuTTY.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my shell (bash), I can copy/paste unicode characters, like &lt;code&gt;‘ ¿ ’&lt;/code&gt; using &lt;kbd&gt;Shift&lt;/kbd&gt; + &lt;kbd&gt;Insert&lt;/kbd&gt; and it works as expected. In Vim, within the same shell session, however, I get this instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;▒~@~X¿▒~@~Y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pulling up &lt;code&gt;:digraphs&lt;/code&gt; shows that this is happening with all unicode characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=utf-8&#xA;set fileencoding=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is the output from the &lt;code&gt;locale&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LANG=en_US.UTF-8&#xA;LC_CTYPE=&quot;en_US.UTF-8&quot;&#xA;LC_NUMERIC=&quot;en_US.UTF-8&quot;&#xA;LC_TIME=&quot;en_US.UTF-8&quot;&#xA;LC_COLLATE=&quot;en_US.UTF-8&quot;&#xA;LC_MONETARY=&quot;en_US.UTF-8&quot;&#xA;LC_MESSAGES=&quot;en_US.UTF-8&quot;&#xA;LC_ALL=en_US.UTF-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why can I not use special characters within Vim when they work fine on the command line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; The remote character set in PuTTY is set to UTF-8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt; Output from &lt;code&gt;vim --version&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 22 2009 06:30:54)&#xA;Compiled by steve@v480&#xA;Normal version with GTK GUI.  Features included (+) or not (-):&#xA;-arabic +autocmd +balloon_eval +browse +builtin_terms +byte_offset +cindent&#xA;+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments&#xA;+cryptv +cscope +cursorshape +dialog_con_gui +diff +digraphs +dnd -ebcdic&#xA;-emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path +find_in_path&#xA;+float +folding -footer +fork() -gettext -hangul_input -iconv +insert_expand&#xA;+jumplist -keymap -langmap +libcall +linebreak +lispindent +listcmds +localmap&#xA;+menu +mksession +modify_fname +mouse +mouseshape -mouse_dec -mouse_gpm&#xA;-mouse_jsbterm -mouse_netterm -mouse_sysmouse +mouse_xterm -multi_byte&#xA;+multi_lang -mzscheme +netbeans_intg -osfiletype +path_extra -perl +postscript&#xA;+printer -profile -python +quickfix +reltime -rightleft -ruby +scrollbind&#xA;+signs +smartindent -sniff +statusline -sun_workshop +syntax +tag_binary&#xA;+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title&#xA; +toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo&#xA;+vreplace +wildignore +wildmenu +windows +writebackup +X11 -xfontset +xim&#xA;+xsmp_interact +xterm_clipboard -xterm_save&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/local/include/gtk-1.2 -I/usr/local/include/glib-1.2 -I/usr/local/lib/glib/include -I/usr/X11R6/include -I/usr/openwin/include -I/usr/local/include -I/usr/local/ssl/include -I/usr/local/pgsql/include -I/usr/local/include/ncurses -I/usr/local/BerkeleyDB.4.2/include -I/usr/openwin/include -I/usr/local/rrdtool-1.2.19/include  -O2 -L/usr/local/pgsql/lib -R/usr/local/pgsql/lib -L/usr/local/lib -R/usr/local/lib -L/usr/local/ssl/lib -R/usr/local/ssl/lib -L/usr/openwin/lib -R/usr/openwin/lib -I/usr/local/rrdtool-1.2.19/include  -I/usr/X11R6/include -I/usr/openwin/include&#xA;Linking: gcc  -L/usr/X11R6/lib -R/usr/X11R6/lib -L/usr/openwin/lib -R/usr/openwin/lib   -L/usr/local/lib -R/usr/local/lib -R/usr/lib -L/usr/local/pgsql/lib -R/usr/local/pgsql/lib -L/usr/lib -R/usr/openwin/lib -L/usr/openwin/lib -L/usr/local/ssl/lib -R/usr/local/ssl/lib -L/usr/local/BerkeleyDB.4.2/lib -R/usr/local/BerkeleyDB.4.2/lib -L/usr/X11R6/lib -R/usr/X11R6/lib -o vim   -L/usr/local/lib -L/usr/X11R6/lib -R/usr/X11R6/lib -L/usr/openwin/lib -R/usr/openwin/lib -lgtk -lgdk -lgmodule -lglib -lintl -lXext -lXt -lX11 -lSM -lICE -lm -lncurses -lnsl -lsocket&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3264" LastEditorUserId="3264" LastEditDate="2016-04-12T14:13:38.147" LastActivityDate="2016-04-12T18:01:50.113" Title="Unicode characters available in shell but not within Vim" Tags="|unicode|digraphs|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7301" PostTypeId="1" CreationDate="2016-04-11T12:19:53.670" Score="3" ViewCount="660" Body="&lt;p&gt;I'd like to delete all spaces on empty lines before saving files. I've figured out how to do that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * silent! %s/\v^\s+$//e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this moves my cursor to the line where the spaces have been removed. I know that not in autocmd I can just press &lt;code&gt;''&lt;/code&gt; and that would do what I want, but I can't figure out how to achieve this in autocmd.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="1238" LastEditDate="2019-12-28T10:18:12.803" LastActivityDate="2019-12-28T10:18:12.803" Title="How to restore cursor position after search and replace in autocmd" Tags="|regular-expression|autocmd|cursor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7302" PostTypeId="2" ParentId="7301" CreationDate="2016-04-11T12:34:45.593" Score="4" Body="&lt;p&gt;You could achieve &lt;code&gt;''&lt;/code&gt; on an autocmd using the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setpos('.', getpos(&quot;''&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#function-list&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help function-list&lt;/code&gt;&lt;/a&gt; for built-in functionality on VimL.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;okay, how to combine it with search and replace? Another autocmd after&#xA;  the search and replace one?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Vim documentation is very comprehensive and well-written, you should definitively try reading it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are going to write autocmds then &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#cmdline-lines&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help cmd-lines&lt;/code&gt;&lt;/a&gt; is a must read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * %s/\v^\s+$//e | call setpos('.', getpos(&quot;''&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should also consider using autocmd groups, as explained in &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-groups&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help autocmd-groups&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-04-11T13:55:19.843" LastActivityDate="2016-04-11T13:55:19.843" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7304" PostTypeId="2" ParentId="7298" CreationDate="2016-04-12T01:21:55.780" Score="0" Body="&lt;p&gt;Here is an example based on the comment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc 'g/\v%2l|%4l/pu_' -cx alfa.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a working alternative to my original command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '4pu_|2pu_|x' alfa.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="7184" LastEditDate="2016-04-17T01:28:43.977" LastActivityDate="2016-04-17T01:28:43.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7306" PostTypeId="1" AcceptedAnswerId="7420" CreationDate="2016-04-12T01:11:28.827" Score="15" ViewCount="4564" Body="&lt;p&gt;I use vim in a few different contexts; typically, I like to put this in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;t_ti.=&quot;\&amp;lt;Esc&amp;gt;[1 q&quot;&#xA;let &amp;amp;t_SI.=&quot;\&amp;lt;Esc&amp;gt;[5 q&quot;&#xA;let &amp;amp;t_EI.=&quot;\&amp;lt;Esc&amp;gt;[1 q&quot;&#xA;let &amp;amp;t_te.=&quot;\&amp;lt;Esc&amp;gt;[0 q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes it so that insert and normal mode use different cursors (normal mode is a block cursor and insert mode is a vertical line). This works for me in mintty with cygwin, xterm, and also rvxt just fine. However, whenever I use GNU screen, my cursor no longer changes. I've seen references to fixing this for tmux (for instance here: &lt;a href=&quot;https://vi.stackexchange.com/questions/3379/cursor-shape-under-vim-tmux&quot;&gt;Cursor shape under vim + tmux&lt;/a&gt;), but nothing I've tried for Screen has worked. For now, I'm using this in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Underline currently edited line&#xA;if !has(&quot;gui_running&quot;)&#xA;    :autocmd InsertEnter * set cul&#xA;    :autocmd InsertLeave * set nocul&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That makes it so that when in insert mode the current line is underlined (the &lt;code&gt;:has(&quot;gui_running&quot;)&lt;/code&gt; prevents it from taking effect in gvim). I also use &lt;code&gt;set laststatus=2&lt;/code&gt; to keep the status bar on the bottom, which also helps. I just wish it worked a bit more like gvim. Has anyone found a fix for this?&lt;/p&gt;&#xA;" OwnerUserId="7203" OwnerDisplayName="ZeroG" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-04-23T16:25:55.737" Title="Vim normal and insert mode cursor not changing in GNU screen" Tags="|insert-mode|normal-mode|cursor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7307" PostTypeId="2" ParentId="7300" CreationDate="2016-04-12T01:46:01.303" Score="2" Body="&lt;p&gt;I tried this on my linux box via putty and via cygwin, both seemed to work as expected for me. I'm wondering if perhaps your putty is actually not configured for UTF-8; I know for example ncurses apps with line drawing characters are affected by the putty translation setting. Try right-clicking on your putty title bar, go to &quot;Change Settings...&quot;, then under Category navigate to &quot;Window-&gt;Translation&quot;, then change the Remote character set to UTF-8. When I change this to Win 1252, I get behavior a little bit like what you're seeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For completeness, here are all my translation settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Remote character set: UTF-8&#xA;Treat CJK ambiguous characters as wide: unchecked&#xA;Caps Lock acts as Cyrillic switch: unchecked&#xA;Handling of line drawing characters: Use Unicode line drawing code points&#xA;Copy and paste line drawing characters as lqqqk: unchecked&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With those settings, I'm able to paste the character you mentioned in vim successfully. If that works for you, obviously you can save those settings with your putty session.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It appears that the problem is lack of multi-byte support. If you need to recompile without root access, it's possible but tricky. I did it on my Linux Mint system to test:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Get the old vim from git:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wget https://github.com/vim/vim/archive/v7.2.000.tar.gz&#xA;tar xvzf v7.2.000.tar.gz&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Edit the Makefile (&lt;code&gt;vim vim-7.2.000/src/Makefile&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Find &lt;code&gt;prefix=$(HOME)&lt;/code&gt; and uncomment it so that the installer installs to your home directory&lt;/li&gt;&#xA;&lt;li&gt;Find and uncomment &lt;code&gt;CONF_OPT_MULTIBYTE = --enable-multibyte&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To install it to &lt;code&gt;~/bin/vim&lt;/code&gt;, run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make&#xA;make install&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run from your home bin directory&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This almost certainly will not work the first time; if you go this route, you'll have to get all the build dependencies built yourself ahead of time by getting each dep's source code. I recommend you try with the version of vim that's already on the system so that at least your runtime dependencies are already there.&lt;/p&gt;&#xA;" OwnerUserId="7203" LastEditorUserId="205" LastEditDate="2016-04-12T18:01:50.113" LastActivityDate="2016-04-12T18:01:50.113" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7308" PostTypeId="1" AcceptedAnswerId="7310" CreationDate="2016-04-12T09:50:42.060" Score="2" ViewCount="786" Body="&lt;p&gt;In insert-mode, I would like to extract the &lt;em&gt;current line number&lt;/em&gt; I'm editing in a &quot;variable&quot;/memory/buffer, and to be able to paste it through a remapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that &lt;code&gt;:echo line(&quot;.&quot;)&lt;/code&gt; gives me the line number. &#xA;I have found how to insert the line number at the beginning of each line, using &lt;code&gt;:s/^/\=line(&quot;.&quot;)&lt;/code&gt;.&#xA;But I would like to have a remapping like :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap \l &amp;lt;Esc&amp;gt;:echo line(&quot;.&quot;) &amp;gt; buffer&amp;lt;CR&amp;gt; p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that would extract the line number and paste it at my current cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Sources of previous searches :&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/688/how-to-add-permanent-line-numbers-to-a-file&quot;&gt;How to add permanent line numbers to a file?&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-04-12T16:34:26.943" Title="Extract line number as a variable to re-insert it" Tags="|line-numbers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7309" PostTypeId="2" ParentId="7308" CreationDate="2016-04-12T09:57:18.547" Score="4" Body="&lt;p&gt;You can save it in a register with &lt;code&gt;let&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap \l &amp;lt;Esc&amp;gt;:let @l = line(&quot;.&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to immediately paste it, you can do so with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap \p &amp;lt;Esc&amp;gt;:let @l = line(&quot;.&quot;)&amp;lt;CR&amp;gt;&quot;lp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-04-12T09:57:18.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7310" PostTypeId="2" ParentId="7308" CreationDate="2016-04-12T09:57:58.500" Score="4" Body="&lt;p&gt;This is a perfect use case for the expression register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;key&amp;gt; &amp;lt;C-r&amp;gt;=line(&quot;.&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;key&amp;gt; line(&quot;.&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help \=&lt;/code&gt;, &lt;code&gt;:help i_ctrl-r&lt;/code&gt;, and &lt;code&gt;:help &amp;lt;expr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-12T09:57:58.500" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7311" PostTypeId="1" AcceptedAnswerId="7312" CreationDate="2016-04-12T14:37:58.577" Score="2" ViewCount="11634" Body="&lt;p&gt;I know that there are a lot of answers to vim/regex, but I can't seem to find one that fits the bill for me. So, I'm trying to remove some attributes from HTML using the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/( id=&quot;\| onfocus=&quot;\| onBlur=&quot;\| style=&quot;\| title=&quot;) [a-zA-Z0-9:;&amp;amp;$_\.\s\(\)\-\,]*&quot;//gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to replace any of the specified attributes and everything up to and included the second &lt;code&gt;=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run this, I get &lt;code&gt;pattern not found&lt;/code&gt;. However, if I take the parens off of &lt;code&gt;id=&quot;\| onfocus=&quot;\| onBlur=&quot;\| style=&quot;\| title=&quot;&lt;/code&gt; I get a match for &lt;code&gt;id=&lt;/code&gt; and I get a match for everything on &lt;code&gt;title=&quot;hi&quot;&lt;/code&gt; How can I include all of the attributes in one regex?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; A result of running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/ id=&quot;\| onfocus=&quot;\| onBlur=&quot;\| style=&quot;\| title=&quot; [a-zA-Z0-9:;&amp;amp;$_\.\s\(\)\-\,]*&quot;//gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;input type=&quot;submit&quot; id=&quot;submit&quot; title=&quot;submit&quot; value=&quot;submit&quot; /&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;input type=&quot;submit&quot; submit&quot; value=&quot;submit&quot; /&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see it picks up the &lt;code&gt;id=&lt;/code&gt; but not the text and double quote after the attribute up to the next space. However, it is pattern matching the correct thing for the &lt;code&gt;title&lt;/code&gt; attribute. In this example &lt;code&gt;title=&quot;submit&quot;&lt;/code&gt; has been fully removed.&lt;/p&gt;&#xA;" OwnerUserId="7210" LastEditorUserId="7210" LastEditDate="2016-04-12T15:02:54.810" LastActivityDate="2016-04-12T15:02:54.810" Title="Creating a regex to match html attributes" Tags="|regular-expression|replace|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7312" PostTypeId="2" ParentId="7311" CreationDate="2016-04-12T15:01:40.880" Score="4" Body="&lt;p&gt;I found a way to do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; %s/\(id\|class\)=&quot;\([^&quot;]*\)&quot;/\2/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You catch &lt;code&gt;id&lt;/code&gt; and &lt;code&gt;class&lt;/code&gt; in the first group to add the &lt;strong&gt;big fat or&lt;/strong&gt; &lt;code&gt;\|&lt;/code&gt; operator.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You match &lt;code&gt;=&quot;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You catch the text you want to keep in the second capture group &lt;code&gt;\([^&quot;]*\)&lt;/code&gt; (assuming here you want anything up to a &lt;code&gt;&quot;&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You match the closing &lt;code&gt;&quot;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;And you leave only the second group.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can then use &lt;code&gt;\2&lt;/code&gt; as you want.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-04-12T15:01:40.880" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7313" PostTypeId="1" CreationDate="2016-04-12T15:20:43.243" Score="4" ViewCount="1985" Body="&lt;p&gt;I can use &lt;code&gt;%t&lt;/code&gt; in my &lt;code&gt;statusline&lt;/code&gt; to display the file name (tail) of the file in the buffer, but there's no corresponding option to display only the path, &lt;em&gt;without&lt;/em&gt; the file name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm after: I'd like to display the path to the file in the buffer (as &lt;code&gt;%f&lt;/code&gt; does), but I want the file name to stand out by giving it a different color. So if there were a corresponding &lt;code&gt;%h&lt;/code&gt; (head) item I would just do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=&#xA;set statusline+=%h           &quot; Path to file (head)&#xA;set statusline+=%#Keyword#   &quot; Switch color&#xA;set statusline+=%t           &quot; File name (tail)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how can I achieve this?&lt;/p&gt;&#xA;" OwnerUserId="3079" LastActivityDate="2016-04-15T11:59:28.127" Title="Status line: Display path to file in the buffer, *without* filename" Tags="|vimrc|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7314" PostTypeId="1" AcceptedAnswerId="7320" CreationDate="2016-04-12T15:27:06.990" Score="8" ViewCount="1560" Body="&lt;p&gt;I work on different projects that have preferences for tabs and others for spaces. Is there a way to toggle using tabs or spaces for indentation? I tried a function I saw online &lt;code&gt;function TabToggle()&lt;/code&gt; but it did not work. Any help would be great.&lt;/p&gt;&#xA;" OwnerUserId="4870" LastActivityDate="2016-04-12T19:33:49.553" Title="Toggling Tabs and Spaces" Tags="|vimrc|indentation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7315" PostTypeId="2" ParentId="7313" CreationDate="2016-04-12T15:37:53.577" Score="5" Body="&lt;p&gt;Maybe you could use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=&#xA;&quot; Path to file (head)&#xA;set statusline+=%{expand('%:h')}/&#xA;&quot; Switch color&#xA;set statusline+=%#Keyword#&#xA;&quot; File name (tail)&#xA;set statusline+=%t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%{}&lt;/code&gt; allows you to evaluate an expression, which here is &lt;code&gt;expand('%:h')&lt;/code&gt; (the head of the current file name).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your last &lt;a href=&quot;https://vi.stackexchange.com/questions/7313/status-line-display-path-to-file-in-the-buffer-without-filename/7315#comment11991_7315&quot;&gt;comment&lt;/a&gt; says that you don't want to expand the tilda &lt;code&gt;~&lt;/code&gt;, and that you want the head of the path to use the highlight group of the statusline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the 1st problem, you could add the filename modifier &lt;code&gt;:~&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{expand('%:~:h')}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the 2nd problem, you could use the highlight group &lt;code&gt;StatusLine&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%#StatusLine#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it &lt;a href=&quot;https://vi.stackexchange.com/questions/7313/status-line-display-path-to-file-in-the-buffer-without-filename#comment12041_7315&quot;&gt;seems&lt;/a&gt; that it wouldn't give the desired background color.&lt;br&gt;&#xA;So you could type &lt;code&gt;:hi&lt;/code&gt; to get a list of all the highlight groups currently defined on your system, look for the one whose colors you're interested in and use its name to set up the colors of the head of the path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would give something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=&#xA;set statusline+=%#YourHighlightGroup#&#xA;set statusline+=%{expand('%:~:h')}/&#xA;set statusline+=%#Keyword#&#xA;set statusline+=%t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-04-15T11:59:28.127" LastActivityDate="2016-04-15T11:59:28.127" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7316" PostTypeId="2" ParentId="7314" CreationDate="2016-04-12T15:42:55.300" Score="6" Body="&lt;p&gt;I &lt;strong&gt;&lt;em&gt;highly&lt;/em&gt;&lt;/strong&gt; recommend &lt;a href=&quot;http://editorconfig.org/&quot;&gt;editorconfig&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting a very simple &lt;code&gt;.editorconfig&lt;/code&gt; at the root of your project will make every IDE/editor with an editorconfig plugin automatically comply to the rules laid out in that config file. It's truly beautiful! No more mixed indentation!&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-12T15:42:55.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7317" PostTypeId="2" ParentId="7301" CreationDate="2016-04-12T15:44:30.163" Score="1" Body="&lt;p&gt;Inspired from &lt;a href=&quot;https://vi.stackexchange.com/a/7241/3343&quot;&gt;this answer&lt;/a&gt; on another post, a possible solution would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufWritePre * call KeepEx('silent! %s/\v^\s+$//e')&#xA;&#xA;function! KeepEx(arg)&#xA;  let l:winview = winsaveview()&#xA;  execute a:arg&#xA;  call winrestview(l:winview)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;using the function &lt;code&gt;KeepEx&lt;/code&gt; which can execute arbitrary functions and afterwards restore the old view.&lt;/p&gt;&#xA;" OwnerUserId="3343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-04-12T15:44:30.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7318" PostTypeId="1" AcceptedAnswerId="7322" CreationDate="2016-04-12T16:13:40.113" Score="2" ViewCount="404" Body="&lt;p&gt;I've been learning Vi/Vim for some month and, at the moment, I'm editing many files at once splitting the window, jumping from one buffer to the others. I find it very useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing I don't like is when I have to execute commands in the shell from within vim. I use, for example &lt;code&gt;:!make&lt;/code&gt;. This is easy to do. But when I have to run some executable I'd like to use command completion regardless of the case of the letters of the name. For instance, suppose I have to run an MPI program with &lt;code&gt;:!mpirun -np 8 Convection1D&lt;/code&gt;; actually I'm not so fast in typing the parts &lt;code&gt;:!&lt;/code&gt; and &lt;code&gt;-np&lt;/code&gt;, but I could save time by using command completion for the name of the executable. The obstacle is the capital letter (or letters); it'b be very good if I was allowed to type &lt;code&gt;:!mpir&amp;lt;tab&amp;gt; -np 8 con&amp;lt;tab&amp;gt;&amp;lt;enter&amp;gt;&lt;/code&gt; (especially considering that I can press tab repeatedly to view successive completions).&lt;/p&gt;&#xA;" OwnerUserId="6498" LastActivityDate="2016-04-12T17:46:10.237" Title="make external command completion case insensitive when called from within Vim" Tags="|autocompletion|external-command|letter-case|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7320" PostTypeId="2" ParentId="7314" CreationDate="2016-04-12T16:53:06.073" Score="12" Body="&lt;p&gt;Generally the &lt;code&gt;retab&lt;/code&gt; command and the &lt;code&gt;expandtab&lt;/code&gt; option can accomplish what you're talking about without plugins if that's what you want. Do &lt;code&gt;:set expandtab&lt;/code&gt; to set vim to prefer spaces to tabs, &lt;code&gt;:set noexpandtab&lt;/code&gt; to prefer tabs to spaces. Use &lt;code&gt;:retab!&lt;/code&gt; to switch a whole file to whichever you've set. This has caveats, and I recommend &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#:retab&quot;&gt;&lt;code&gt;:help :retab&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27expandtab%27&quot;&gt;&lt;code&gt;:help 'expandtab'&lt;/code&gt;&lt;/a&gt; for more information, and of course a plugin as already suggested will probably be more robust, but those settings are a quick-and-dirty way to get it done.&lt;/p&gt;&#xA;" OwnerUserId="7203" LastEditorUserId="6698" LastEditDate="2016-04-12T19:33:49.553" LastActivityDate="2016-04-12T19:33:49.553" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7321" PostTypeId="2" ParentId="7318" CreationDate="2016-04-12T17:20:56.907" Score="5" Body="&lt;p&gt;You can define a new command like &lt;code&gt;:E&lt;/code&gt; instead of &lt;code&gt;:!&lt;/code&gt; and write a custom completion function for it (see &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#user-commands&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :command&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ -complete=custom,s:CustComp E execute &quot;!&quot; . &quot;&amp;lt;args&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! &amp;lt;SID&amp;gt;CustComp(ArgLead, CmdLine, CursorPos)&#xA;    let l:current = split(a:CmdLine, '\s\+', 1)&#xA;    if len(l:current) == 2&#xA;        return system(&quot;compgen -ac&quot;)&#xA;    else&#xA;        let l:ls = split(system(&quot;ls&quot;), &quot;\n&quot;)&#xA;        return join(filter(ls, join(['v:val =~? &quot;', a:ArgLead, '&quot;'], '')), &quot;\n&quot;)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes you are using bash, if you are using something different you need to substitute the call to &lt;code&gt;compgen&lt;/code&gt; (including the flags of course) by some other program that list all possible commands for the given shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can instead use &lt;code&gt;:E mpir&amp;lt;tab&amp;gt; -np 8 con&amp;lt;tab&amp;gt;&amp;lt;enter&amp;gt;&lt;/code&gt; and it should work.&lt;/p&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2016-04-12T17:20:56.907" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7322" PostTypeId="2" ParentId="7318" CreationDate="2016-04-12T17:46:10.237" Score="4" Body="&lt;p&gt;Assuming that &lt;code&gt;Convection1D&lt;/code&gt; is a file name, you can use the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27wildignorecase%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;wildignorecase&lt;/code&gt;&lt;/a&gt; setting, which will Vim ignore case when completing file names and directories. This is available since Vim 7.3.075.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note you can use &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3a%21%21&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:!!&lt;/code&gt;&lt;/a&gt; to repeat the last &lt;code&gt;:!&lt;/code&gt; command, which may be useful for you.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-04-12T17:46:10.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7323" PostTypeId="1" AcceptedAnswerId="7329" CreationDate="2016-04-12T18:36:24.543" Score="6" ViewCount="1279" Body="&lt;p&gt;This question has been migrated from &lt;a href=&quot;https://stackoverflow.com/questions/36576762/hardcore-vim-mode-what-is-the-best-way-to-move-vertically&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have started using vim a while back and have been jumping with my right hand on and off &quot;home row&quot;.  As I learned more about efficient navigation, using &quot;f,t&quot; and &quot;F,T&quot; became my favourite way to navigate within the row, i.e. horizontally.  It is so convenient that i started considering &quot;hardcore vim&quot; mode where the homerow navigation is turned off altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, what would be the high precision vertical navigation approach in &quot;hardcore vim&quot; mode.  Move up one line, move down one line. Few key strokes to position your cursor exactly on a line without knowing or caring about the line number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I do know about moving per paragraph, enclosing brackets, but somehow i miss the type of precision that horizontal navigation has.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;After a bit of research:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/528/move-vertically-to-a-specific-character-on-a-different-line&quot;&gt;This question&lt;/a&gt; seems to be very close to what I am asking.  Although the accepted answer doesn't quite fit the bill for me, it contains a link to &lt;a href=&quot;https://github.com/easymotion/vim-easymotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;EasyMotion&lt;/a&gt; plugin, that could help to speed up navigation without using the home row.  Downside being having to install a plugin vs. using raw vim.  &lt;/p&gt;&#xA;" OwnerUserId="7215" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-04-13T19:55:47.703" Title="Hardcore vim mode: what is the best way to move vertically?" Tags="|normal-mode|" AnswerCount="1" CommentCount="3" ClosedDate="2016-04-29T01:42:07.917" ContentLicense="CC BY-SA 3.0" />
  <row Id="7324" PostTypeId="1" AcceptedAnswerId="7326" CreationDate="2016-04-13T01:09:09.353" Score="6" ViewCount="714" Body="&lt;p&gt;I can remove the last 10 lines like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '-9,d|x' f.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I would like to invert the selection, or remove all lines except the&#xA;last 10. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="7184" LastEditDate="2016-04-16T15:46:29.023" LastActivityDate="2016-04-16T15:46:29.023" Title="Invert range selection" Tags="|ex-mode|ex-command|range|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7325" PostTypeId="2" ParentId="7324" CreationDate="2016-04-13T11:55:34.143" Score="3" Body="&lt;p&gt;Here is a solution which comes from &lt;a href=&quot;http://earthwithsun.com/questions/72688/how-to-invert-the-selection-in-vim&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. &lt;strong&gt;Note&lt;/strong&gt; that might not be exactly what you're looking for since it's implies to use a visual (or normal) mode mapping instead of just an &lt;code&gt;ex&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to create the following mapping which will allow you to keep in your buffer only the visually selected lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;key&amp;gt; :&amp;lt;C-U&amp;gt;1,'&amp;lt;-1:delete&amp;lt;CR&amp;gt;:'&amp;gt;+1,$:delete&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mapping can be decomposed like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:&lt;/code&gt; enter ex mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; empty the lines from the first one to the current one.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1,'&amp;lt;-1&lt;/code&gt; Specify the range from the first line of the file to the line before the start of current selection.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:delete&amp;lt;CR&amp;gt;&lt;/code&gt; delete the lines previously sectioned by the range.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:'&amp;gt;+1,$&lt;/code&gt; create a range from the end of the selection to the end of the line/&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:delete&amp;lt;CR&amp;gt;&lt;/code&gt; delete the new range.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can then visually select the last 10 lines (or whatever lines you want to keep) and press &lt;code&gt;&amp;lt;key&amp;gt;&lt;/code&gt; used in the mapping to delete all the line not selected.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now based on this solution I have created the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! InvertRange(command) range&#xA;    execute (a:lastline+1) . &quot;,$ &quot; . a:command&#xA;    execute &quot;1,&quot; . (a:firstline-1) . &quot; &quot; . a:command&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should provide a command as argument and a range and the function will apply this command on the lines which are not in the range. Note that here the range under the selection is treated first otherwise if you provide &lt;code&gt;&quot;delete&quot;&lt;/code&gt; as argument the line position will change and the deletion will not happened on the line you wanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example call of the function is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:20,30 call InvertRange(&quot;delete&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will delete all lines excepted the ones between the 20th and the 30th.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Finally as a bonus here is a command that you can use to call the &lt;code&gt;InvertRange&lt;/code&gt; function more easily:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range -nargs=1 -complete=command IR &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call InvertRange(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command accept a range (if no one is provided it takes the current line) and allows the completion on the ex commands. Thus you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:20,30 IR delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To call the &lt;code&gt;InvertRange&lt;/code&gt; function with &lt;code&gt;delete&lt;/code&gt; as a command to execute and the range &lt;code&gt;20,30&lt;/code&gt; to invert.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-13T12:06:54.003" LastActivityDate="2016-04-13T12:06:54.003" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7326" PostTypeId="2" ParentId="7324" CreationDate="2016-04-13T13:27:52.900" Score="3" Body="&lt;p&gt;Here is a workaround:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '1,-10d|x' f.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;1,-10&lt;/code&gt; select all but last 10 lines&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;d&lt;/code&gt; delete&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;x&lt;/code&gt; save and close&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2016-04-13T13:27:52.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7327" PostTypeId="2" ParentId="3897" CreationDate="2016-04-13T19:35:44.653" Score="4" Body="&lt;p&gt;To restore the default tmux naming scheme when quitting vim you can also do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimLeave * call system(&quot;tmux setw automatic-rename&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7227" LastActivityDate="2016-04-13T19:35:44.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7328" PostTypeId="1" CreationDate="2016-04-13T19:45:16.477" Score="2" ViewCount="175" Body="&lt;p&gt;I found a lot of plugins (like &lt;a href=&quot;https://stackoverflow.com/questions/33453468/vim-thesaurus-file/35680469#35680469&quot;&gt;this&lt;/a&gt; for example) and sources for English, but almost nothing for Russian (and other languages).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there good source of thesaurus (or plugin for online tools) for non-English languages?&lt;/p&gt;&#xA;" OwnerUserId="5182" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-02-04T11:26:24.437" Title="Thesaurus file (or plugin for online thesaurus tools) for non-English languages" Tags="|thesaurus|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7329" PostTypeId="2" ParentId="7323" CreationDate="2016-04-13T19:55:47.703" Score="3" Body="&lt;p&gt;I usually use '/' and '?', (forward and backward search) when having to navigate to a line I can see in my buffer. Using a precise enough search I move directly to the wanted position.&lt;/p&gt;&#xA;" OwnerUserId="7228" LastActivityDate="2016-04-13T19:55:47.703" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7331" PostTypeId="1" CreationDate="2016-04-14T12:01:10.550" Score="4" ViewCount="1253" Body="&lt;p&gt;I'm trying to remap my Backspace key to do nothing in insert mode (want to start using more x and other different ways that are better for deletion in vim)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added in my &lt;code&gt;.vimrc&lt;/code&gt; this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;BS&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But after restarting my &lt;code&gt;vim&lt;/code&gt; the backspace still deletes a character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is part of my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;execute pathogen#infect()&#xA;syntax on&#xA;filetype plugin indent on&#xA;set laststatus=2&#xA;set background=dark&#xA;set number&#xA;set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab&#xA;set autochdir&#xA;&#xA;set noswapfile&#xA;set backspace=indent,eol,start&#xA;set incsearch&#xA;set ignorecase&#xA;set fileencoding=utf-8&#xA;set encoding=utf-8&#xA;set gdefault&#xA;set smartcase&#xA;set scrolloff=5&#xA;let mapleader=&quot;,&quot;&#xA;map &amp;lt;C-n&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;let g:ag_working_path_mode=&quot;ar&quot;&#xA;&#xA;let g:airline#extensions#tabline#enabled = 1&#xA;let g:airline#extensions#tabline#fnamemod = ':t'&#xA;&#xA;let g:ctrlp_map = '&amp;lt;c-p&amp;gt;'&#xA;let g:ctrlp_cmd = 'CtrlP'&#xA;&#xA; set wildignore+=*/tmp/*,*.so,*.swp,*.zip&#xA;let g:ctrlp_user_command = 'find %s -type f'&#xA;&#xA;set hidden&#xA;nmap &amp;lt;leader&amp;gt;T :enew&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;l :bnext&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;h :bprev&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;bq :bp &amp;lt;BAR&amp;gt; bd #&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;bl :ls&amp;lt;CR&amp;gt;&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;w :w&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;q :q&amp;lt;cr&amp;gt;&#xA;&#xA;noremap &amp;gt; &amp;gt;&amp;gt;&amp;lt;cr&amp;gt;&#xA;noremap &amp;lt; &amp;lt;&amp;lt;&amp;lt;cr&amp;gt;&#xA;&#xA;let g:ctrlp_custom_ignore = {&#xA;            \ 'dir':  '\v[\/]\.(git|hg|svn)$|/node_modules/',&#xA;            \ 'file': '\v\.(exe|so|dll)$',&#xA;            \ 'link': 'some_bad_symbolic_links',&#xA;            \ }&#xA;let g:ctrlp_dotfiles = 0&#xA;j&#xA;&quot;autocmd BufWritePre * :normal gg=G&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;c-j&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;c-b&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-z&amp;gt;&quot;&#xA;let g:UltiSnipsNoPythoWarning = 1&#xA;&#xA;&quot; Syntastic&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;&#xA;&quot; C tags&#xA;nmap &amp;lt;F8&amp;gt; :TagbarToggle&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;. :CtrlPTag&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;leader&amp;gt;; &amp;lt;C-o&amp;gt;A;&#xA;nnoremap &amp;lt;leader&amp;gt;; A;&#xA;&#xA;set diffopt+=vertical&#xA;inoremap &amp;lt;BS&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&quot;inoremap &amp;lt;Del&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7125" LastEditorUserId="1821" LastEditDate="2016-04-15T13:46:48.603" LastActivityDate="2016-04-15T13:46:48.603" Title="Remapping key to &lt;Nop&gt; not working" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7332" PostTypeId="2" ParentId="7331" CreationDate="2016-04-14T12:06:04.940" Score="2" Body="&lt;p&gt;I could reproduce your issue by starting Vim without &lt;code&gt;nocompatible&lt;/code&gt; set.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that the &lt;code&gt;inoremap&lt;/code&gt; is not in Vi, so it won't do the map if you don't add the &lt;code&gt;nocompatible&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. it works with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, as a general rule, you may want to start your &lt;code&gt;vimrc&lt;/code&gt; with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; next time have a look at &lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;How do I debug my vimrc file?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-04-14T12:15:24.303" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7333" PostTypeId="1" AcceptedAnswerId="7335" CreationDate="2016-04-14T12:25:34.087" Score="1" ViewCount="865" Body="&lt;p&gt;At my workplace using my current compiler I have a vim plugin enabled.&#xA;The only thing that I am uncomfortable with vim is vertical line navigation and I wanted to know how some of the vim gurus overcome this situation.My typical work scenario would be a situation such as this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I am on a page displaying lines 145 till 220. My cursor is on line 150 and I would like to go to line 183. To do so I would type &lt;code&gt;183G&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to know if there was an easier way to accomplish that(because sometimes a line number might be in the thousands). What techniques do people here use for vertical navigation ? In this case it seems to be easier if I just grabbed the mouse and moved there instead. Any advice on this situation would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="7053" LastEditorUserId="1841" LastEditDate="2016-04-14T12:39:21.007" LastActivityDate="2016-04-14T12:53:06.757" Title="Vertical Navigation secrets without a plugin" Tags="|normal-mode|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7335" PostTypeId="2" ParentId="7333" CreationDate="2016-04-14T12:46:44.017" Score="5" Body="&lt;p&gt;There are different way to move vertically in Vim, they all depends on what you want to do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In normal mode &lt;kbd&gt;{&lt;/kbd&gt; and &lt;kbd&gt;}&lt;/kbd&gt; allows to move to the beginning or the end of a paragraph (i.e. a block of lines without blank or empty line)&lt;/li&gt;&#xA;&lt;li&gt;In normal mode &lt;kbd&gt;Shift-h&lt;/kbd&gt;, &lt;kbd&gt;Shift-m&lt;/kbd&gt; and &lt;kbd&gt;Shift-l&lt;/kbd&gt; allows you to go the the top, the middle and the bottom of the screen.&lt;/li&gt;&#xA;&lt;li&gt;You can use &lt;code&gt;/pattern&lt;/code&gt; to search for the next occurrence of a desired pattern and use &lt;code&gt;?pattern&lt;/code&gt; to make a backward search. Use &lt;kbd&gt;n&lt;/kbd&gt; and &lt;kbd&gt;Shift-N&lt;/kbd&gt; to repeat the search in the same way or in the contrary way. To use this method you might want to add &lt;code&gt;set incsearch&lt;/code&gt; to your &lt;code&gt;.vimrc&lt;/code&gt; to see the pattern matched as you type it.&lt;/li&gt;&#xA;&lt;li&gt;Another solution is to use marks: if you know a place where you regularly need to go in your file you can set a mark at this line with &lt;kbd&gt;m-[X]&lt;/kbd&gt; where &lt;code&gt;[X]&lt;/code&gt; is one of the letters of the alphabet. You can then use &lt;kbd&gt;'-[X]&lt;/kbd&gt; anywhere in the file to go back to this line.&lt;/li&gt;&#xA;&lt;li&gt;Finally if you are editing source code files you can use a tag system (like &lt;a href=&quot;http://ctags.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;exuberant-ctags&lt;/a&gt; ) combined with the &lt;a href=&quot;https://github.com/vim-scripts/taglist.vim&quot; rel=&quot;noreferrer&quot;&gt;taglist plugin&lt;/a&gt; to navigate your code.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Use the corresponding method depending on how &quot;fast&quot; you need to navigate.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-14T12:53:06.757" LastActivityDate="2016-04-14T12:53:06.757" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7336" PostTypeId="1" AcceptedAnswerId="7337" CreationDate="2016-04-14T12:56:08.090" Score="9" ViewCount="893" Body="&lt;p&gt;I have a file with the following pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo 111&#xA;baz&#xA;foo 222&#xA;baz&#xA;foo 333&#xA;baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which needs to be turned into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo 111&#xA;bar 111&#xA;baz&#xA;foo 222&#xA;bar 222&#xA;baz&#xA;foo 333&#xA;bar 333&#xA;baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, duplicate all the lines beginning with &lt;code&gt;foo&lt;/code&gt;, and change only &lt;code&gt;foo&lt;/code&gt; in the duplicate but leave the rest of the line (which differs in each case) intact. How to do this?&lt;/p&gt;&#xA;" OwnerUserId="4446" LastEditorUserId="1841" LastEditDate="2016-04-14T12:59:41.027" LastActivityDate="2016-05-10T14:29:36.960" Title="Duplicate lines beginning with &quot;x&quot;, replacing &quot;x&quot; in the duplicate with &quot;y&quot;?" Tags="|regular-expression|search|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7337" PostTypeId="2" ParentId="7336" CreationDate="2016-04-14T13:09:54.210" Score="19" Body="&lt;p&gt;Here you go:   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/foo/t.|s//bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/foo/    &quot; start a global command applied on all lines matching 'foo'&#xA;t.         &quot; duplicate the current line (the cursor is now on the new line)&#xA;|          &quot; chain a new command&#xA;s//bar     &quot; substitute the last searched element with 'bar'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because the &lt;code&gt;g&lt;/code&gt; command will update the search pattern, so you can omit the pattern to replace in the substitute command. (ref: &lt;code&gt;:h :g&lt;/code&gt;, search for &lt;code&gt;search pattern&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Older version:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/foo/norm! yyp:s/foo/bar^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g            start a global command&#xA;/foo/         apply only on lines having 'foo'&#xA;norm!         execute a normal command&#xA;yyp           duplicate the line&#xA;:s//bar       replace foo with bar on the line (the duplicated one)&#xA;^M            add enter to execute the substitution&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To insert the &lt;code&gt;^M&lt;/code&gt; press &lt;kbd&gt;Ctrl+v&lt;/kbd&gt; and &lt;kbd&gt;enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: I originally came up with the &quot;older&quot; version, before I learned about the &lt;code&gt;t&lt;/code&gt; command. I'll leave it but I won't recommend using it. The first one is cleaner more straightforward.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1841" LastEditDate="2016-05-10T14:29:36.960" LastActivityDate="2016-05-10T14:29:36.960" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7338" PostTypeId="1" AcceptedAnswerId="7344" CreationDate="2016-04-14T16:09:32.160" Score="2" ViewCount="236" Body="&lt;p&gt;I have a lot of projects of the form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/karl/source/project-name/further/hierarchy/...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to extract just the &lt;code&gt;project-name&lt;/code&gt; to put into my statusline.  I use &lt;code&gt;autochdir&lt;/code&gt;, so I know I can create a function that calls &lt;code&gt;getcwd()&lt;/code&gt; and extracts that part.  However, I haven't been able to figure out how to do the parsing after that point.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function ProjectName()&#xA;  return ???getcwd()???&#xA;endfunc&#xA;&#xA;set statusline=%t\ %m%r%{ProjectName()}%{fugitive#statusline()}%=%l,%c\ [0x%B]\ %P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I edit something outside that folder, I'd like to leave the project blank.  Can someone fill in the &lt;code&gt;???&lt;/code&gt; for me?&lt;/p&gt;&#xA;" OwnerUserId="780" LastEditorUserId="780" LastEditDate="2016-04-15T14:53:53.670" LastActivityDate="2016-04-15T14:53:53.670" Title="How to extract part of the current working directory to the statusline?" Tags="|regular-expression|statusline|string-manipulation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7339" PostTypeId="2" ParentId="7338" CreationDate="2016-04-14T18:17:01.010" Score="2" Body="&lt;p&gt;Thanks to @romainl's comment for pointing me in the right direction.  Here's my solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function ProjectName()&#xA;    if expand(&quot;%:p&quot;) =~ &quot;^/home/karl/source/[^/]*/&quot;&#xA;        return &quot;[&quot; . fnamemodify('', ':p:s?/home/karl/source/\([^/]*\)/.*?\1?') . &quot;]&quot;&#xA;    else&#xA;        return &quot;&quot;&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="780" LastActivityDate="2016-04-14T18:17:01.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7340" PostTypeId="1" AcceptedAnswerId="7361" CreationDate="2016-04-14T18:38:16.263" Score="0" ViewCount="1544" Body="&lt;p&gt;I often have to write XML where text-width has been manually set by another editor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;context&amp;gt;&#xA;    &amp;lt;p&amp;gt;Here is a paragraph about some stuff that happened&#xA;       and someone did a nice printing that makes the text&#xA;       break and stuff, which is nice unless you have to&#xA;       it it, and now its a PITA.&amp;lt;/p&amp;gt;&#xA;    &amp;lt;p&amp;gt;Here is another paragraph. I suppose I could have&#xA;       Googled to get some lorem ipsum text to copy paste&#xA;       for this example, but that's not very fun and I wanted&#xA;       an excuse to use the then how could I use the word&#xA;       floccinaucinihilipilification?&amp;lt;/p&amp;gt;&#xA;    &amp;lt;p&amp;gt;Ignoring this paragraph would be absolute&#xA;       floccinaucinihilipilification!&amp;lt;/p&amp;gt;&#xA;&amp;lt;/context&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is really hard to work with when I need to re-write parts. What I'd rather have is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;context&amp;gt;&#xA;    &amp;lt;p&amp;gt;Here is a paragraph about some stuff that happened and someone did a nice printing that makes the text break and stuff, which is nice unless you have to it it, and now its a PITA.&amp;lt;/p&amp;gt;&#xA;    &amp;lt;p&amp;gt;Here is another paragraph. I suppose I could have Googled to get some lorem ipsum text to copy paste for this example, but that's not very fun and I wanted an excuse to use the then how could I use the word floccinaucinihilipilification?&amp;lt;/p&amp;gt;&#xA;    &amp;lt;p&amp;gt;Ignoring this paragraph would be absolute floccinaucinihilipilification!&amp;lt;/p&amp;gt;&#xA;&amp;lt;/context&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a vim command that can do this for me? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; While the example above uses &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;, there's a lot of possible block level elements. The content in question is written in DITA.&lt;/p&gt;&#xA;" OwnerUserId="3264" LastEditorUserId="1841" LastEditDate="2016-04-15T22:13:47.120" LastActivityDate="2016-04-16T05:58:53.263" Title="How to remove line breaks in xml tags?" Tags="|vimscript|formatting|wrapping|filetype-xml|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7342" PostTypeId="2" ParentId="7336" CreationDate="2016-04-15T02:43:19.583" Score="1" Body="&lt;p&gt;I do stuff like this all the time and just do something like &lt;code&gt;%s/^foo \(.*\)/foo \1\rbar \1/&lt;/code&gt; (partially because I also do a lot of similar tasks that can't be turned into something clever using a copy function, and &lt;code&gt;\(.*\)&lt;/code&gt; is part of my muscle memory by now).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect it's not POSIX-compliant (it doesn't work on other vi clones), but using &lt;code&gt;^M&lt;/code&gt; (&lt;kbd&gt;C-V&lt;/kbd&gt;&lt;kbd&gt;Return&lt;/kbd&gt;) instead of &lt;code&gt;\r&lt;/code&gt; seems to work on most other vi clones.&lt;/p&gt;&#xA;" OwnerUserId="880" LastActivityDate="2016-04-15T02:43:19.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7343" PostTypeId="1" AcceptedAnswerId="7367" CreationDate="2016-04-15T02:48:07.200" Score="2" ViewCount="288" Body="&lt;p&gt;I am interested in editing multiple files. Using this answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/788/#789&quot;&gt;How to edit files non-interactively (e.g. in pipeline)?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came up with my own test case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;seq 10 14 | tee pa.txt &amp;gt; qu.txt&#xA;ex -sc 'argdo %s/1/Z/ge|x' *.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However when I run the Ex command, the terminal just hangs, it does not complete&#xA;the command. If I remove the &lt;code&gt;-s&lt;/code&gt;, the command still hangs with this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;pa.txt&quot; 5 lines, 15 characters&#xA;Entering Ex mode.  Type &quot;visual&quot; to go to Normal mode.&#xA;:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-04-16T16:52:14.103" Title="argdo command hanging" Tags="|ex-command|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7344" PostTypeId="2" ParentId="7338" CreationDate="2016-04-15T06:29:01.063" Score="3" Body="&lt;p&gt;I think your solution might work, but I think this is a slightly cleaner and more readable version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function ProjectName()&#xA;  let l:path = expand('%:p')&#xA;  return (l:path =~# '^/home/karl/source/.\+')&#xA;        \ ? substitute(l:path, '^/home/karl/source/\([^/]*\)/.*', '\1', '')&#xA;        \ : '...'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, it seems you add the brackets &lt;code&gt;[...]&lt;/code&gt; both through the function and through the statusline option. I would think this should only come through the function.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-04-15T06:29:01.063" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7345" PostTypeId="2" ParentId="7328" CreationDate="2016-04-15T09:23:12.607" Score="3" Body="&lt;p&gt;I have added Russian Language support for my Plugin: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/Ron89/thesaurus_query.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Ron89/thesaurus_query.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To activate it, add the following line to your &lt;code&gt;~/.vimrc&lt;/code&gt; file after installing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tq_language=['ru','en']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you don't want to use English thesaurus query at all, remove 'en' from the example above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Russian synonym is queried from website &lt;a href=&quot;http://jeck.ru/tools/SynonymsDictionary/&quot; rel=&quot;nofollow noreferrer&quot;&gt;jeck.ru&lt;/a&gt;. Since this feature is just implemented and I am no Russian speaker. There might still be bugs/unexpected behaviour. Please send me feedback on Github if you find any while using.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin now support German (with woxikon.de), Russian (with jeck.ru) and Chinese (with cilin.txt) thesaurus query.&lt;/p&gt;&#xA;" OwnerUserId="6625" LastEditorUserId="6625" LastEditDate="2017-02-04T11:26:24.437" LastActivityDate="2017-02-04T11:26:24.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7346" PostTypeId="1" CreationDate="2016-04-15T11:32:17.267" Score="1" ViewCount="844" Body="&lt;p&gt;I know that it is possible: I googled it some time ago, but now I can't find the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I need add to &lt;code&gt;.vimrc&lt;/code&gt; to resize my current active window in full height automatically after window changing?&lt;/p&gt;&#xA;" OwnerUserId="7245" LastEditorUserId="1841" LastEditDate="2016-04-15T12:05:21.000" LastActivityDate="2016-04-15T14:57:31.190" Title="Automatically resize the active window to maximum height" Tags="|vimrc|vim-windows|autocmd|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7347" PostTypeId="2" ParentId="7346" CreationDate="2016-04-15T11:37:01.290" Score="3" Body="&lt;p&gt;You can do it with an auto command, filtering the &lt;code&gt;WinEnter&lt;/code&gt; event:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd WinEnter * resize&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;resize&lt;/code&gt; without argument expand the height to max.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Refs:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h resize&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h autocmd-events&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-04-15T11:37:01.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7348" PostTypeId="1" AcceptedAnswerId="7350" CreationDate="2016-04-15T12:27:40.953" Score="7" ViewCount="2074" Body="&lt;p&gt;I need to compute a &quot;XOR&quot;-like of two lines to find every char that differs between the two lines. I know the &lt;code&gt;vim-diff&lt;/code&gt; feature can easily achieve that, but for comparing two lines I wanted to keep everything in the same buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1wYT4SH8f8VjRA25u8AItlrTdAY4Y7n-g8if8VjRA3q25u8AItlrTdwTbv8if8VjRA3q25u8AItlrTdJjMY&#xA;1wYT4SH8f8VjRA25u8AItlrTdAY4Y7n-g8if8VjRA3q25u8AIt1rTdwTbv8if8VjRA3q25u8AItlrTdJjMY&#xA;                                                  1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can it be done ?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1841" LastEditDate="2016-04-15T18:21:28.367" LastActivityDate="2016-05-09T15:08:59.597" Title="XOR two lines to see differences" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7350" PostTypeId="2" ParentId="7348" CreationDate="2016-04-15T13:25:57.203" Score="14" Body="&lt;p&gt;This solution doesn't show the difference between the two lines but highlight them and allow you to navigate through them with &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HaB5Y.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HaB5Y.gif&quot; alt=&quot;Screen cast of the function&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;To do so add this function to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! CompareLines(line1, line2)&#xA;    let l1 = getline(a:line1)&#xA;    let l2 = getline(a:line2)&#xA;    let pattern = &amp;quot;&amp;quot;&#xA;&#xA;    for i in range(strlen(l1))&#xA;        if strpart(l1, i, 1) != strpart(l2, i, 1)&#xA;            if pattern != &amp;quot;&amp;quot;&#xA;                let pattern = pattern . &amp;quot;\\|&amp;quot;&#xA;            endif&#xA;            let pattern = pattern . &amp;quot;\\%&amp;quot; . a:line1 . &amp;quot;l&amp;quot; . &amp;quot;\\%&amp;quot; . ( i+1 ) . &amp;quot;c&amp;quot;&#xA;            let pattern = pattern . &amp;quot;\\|&amp;quot; . &amp;quot;\\%&amp;quot; . a:line2 . &amp;quot;l&amp;quot; . &amp;quot;\\%&amp;quot; . ( i+1 ) . &amp;quot;c&amp;quot;&#xA;        endif&#xA;    endfor&#xA;&#xA;    execute &amp;quot;let @/='&amp;quot; . pattern . &amp;quot;'&amp;quot;&#xA;    set hlsearch&#xA;    normal n&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can call the function with &lt;code&gt;:call CompareLines(1, 2)&lt;/code&gt; where the arguments are the numbers of the lines to compare.&lt;/p&gt;&#xA;&lt;p&gt;To add a bit more details about how the function works:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The first lines gets the lines to compare in some variables.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The loop iterates through these strings. Each characters of the strings are compared and when they don't match a pattern of the form &lt;code&gt;\%Xl\%Yc&lt;/code&gt; is added to the variable &lt;code&gt;pattern&lt;/code&gt; where &lt;code&gt;X&lt;/code&gt; and &lt;code&gt;Y&lt;/code&gt; are the line and the column of a character.&lt;/p&gt;&#xA;&lt;p&gt;(See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/ordinary-atom&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h /ordinary-atom&lt;/code&gt;&lt;/a&gt; and especially the last lines which explains that the pattern &lt;code&gt;\%23l&lt;/code&gt; allows to match the 23rd line and &lt;code&gt;\%23c&lt;/code&gt; the 23rd column)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Once the pattern is build it is injected in the search register (&lt;code&gt;let @/=&lt;/code&gt; allow to define the content of the register and the pattern has to be quoted).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finally &lt;code&gt;set hlsearch&lt;/code&gt; is used to highlight all the matches of the pattern and &lt;code&gt;normal n&lt;/code&gt; brings the cursor to the first different character.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note 1&lt;/strong&gt; The function will change your search history.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note 2&lt;/strong&gt; The part which uses the pattern to make the search could probably be greatly improved.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;And as a bonus&lt;/strong&gt; Add this line to your &lt;code&gt;.vimrc&lt;/code&gt; to create a command which will faster the call of the function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* CompLines call CompareLines(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This way you can simple use &lt;code&gt;:CompLines 1 2&lt;/code&gt; to compares two lines.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; And here is an improved version of the function and of the command. The difference is that you can call it in 3 different ways:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:CL&lt;/code&gt; will diff the current line and the following one&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:CL 23&lt;/code&gt; will diff the current line and the line 23&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:CL 23 42&lt;/code&gt; will diff the lines 23 and 42&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* CL call CompareLines(&amp;lt;f-args&amp;gt;)&#xA;&#xA;function! CompareLines(...)&#xA;&#xA;    &amp;quot; Check the number of arguments&#xA;    &amp;quot; And get lines numbers&#xA;    if len(a:000) == 0&#xA;        let l1=line(&amp;quot;.&amp;quot;)&#xA;        let l2=line(&amp;quot;.&amp;quot;)+1&#xA;    elseif len(a:000) == 1&#xA;        let l1 =line(&amp;quot;.&amp;quot;)&#xA;        let l2 =a:1&#xA;    elseif len(a:000) == 2&#xA;        let l1 = a:1&#xA;        let l2 = a:2&#xA;    else&#xA;        echom &amp;quot;bad number of arguments&amp;quot;&#xA;        return;&#xA;    endif&#xA;&#xA;    &amp;quot; Get the content of the lines&#xA;    let line1 = getline(l1)&#xA;    let line2 = getline(l2)&#xA;&#xA;    let pattern = &amp;quot;&amp;quot;&#xA;&#xA;    &amp;quot; Compare lines and create pattern of diff&#xA;    for i in range(strlen(line1))&#xA;        if strpart(line1, i, 1) != strpart(line2, i, 1)&#xA;            if pattern != &amp;quot;&amp;quot;&#xA;                let pattern = pattern . &amp;quot;\\|&amp;quot;&#xA;            endif&#xA;            let pattern = pattern . &amp;quot;\\%&amp;quot; . l1 . &amp;quot;l&amp;quot; . &amp;quot;\\%&amp;quot; . ( i+1 ) . &amp;quot;c&amp;quot;&#xA;            let pattern = pattern . &amp;quot;\\|&amp;quot; . &amp;quot;\\%&amp;quot; . l2 . &amp;quot;l&amp;quot; . &amp;quot;\\%&amp;quot; . ( i+1 ) . &amp;quot;c&amp;quot;&#xA;        endif&#xA;    endfor&#xA;&#xA;    &amp;quot; Search and highlight the diff&#xA;    execute &amp;quot;let @/='&amp;quot; . pattern . &amp;quot;'&amp;quot;&#xA;    set hlsearch&#xA;    normal n&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2&lt;/strong&gt; I made it &lt;a href=&quot;http://github.com/statox/vim-compare-lines&quot; rel=&quot;noreferrer&quot;&gt;a plugin&lt;/a&gt;. You can install it with a regular plugin manager with (e.g.):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'statox/vim-compare-lines'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-05-09T15:08:59.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7351" PostTypeId="1" CreationDate="2016-04-15T14:21:39.900" Score="1" ViewCount="477" Body="&lt;p&gt;I have a C++ template class &lt;code&gt;С&lt;/code&gt; and its member function &lt;code&gt;foo()&lt;/code&gt;.&#xA;I also have tags file generated with Exuberant Ctags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to access this function via the &lt;code&gt;:tag&lt;/code&gt; command, something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tag C::foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However it doesn't seem to work for me. Inspecting tags file for understanding what should I have passed as &lt;code&gt;:tag&lt;/code&gt; argument didn't help me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible? How should I specify template class? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;P.S.&lt;/strong&gt; &lt;code&gt;:tag foo&lt;/code&gt; works fine. The problem is that there a too many of them in different classes so it's hard to find appropriate tag in the taglist. It turned out the simplest way is to use &lt;code&gt;:tag C&lt;/code&gt; and then finding &lt;code&gt;/foo&lt;/code&gt; which is still a bit awkward.&lt;/p&gt;&#xA;" OwnerUserId="7248" LastEditorUserId="1821" LastEditDate="2016-04-15T14:57:21.993" LastActivityDate="2016-04-15T19:56:16.290" Title="How to navigate to template class member via tag command" Tags="|search|tags|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7352" PostTypeId="2" ParentId="7346" CreationDate="2016-04-15T14:47:43.810" Score="1" Body="&lt;p&gt;If I understand what you mean by window, this should do it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set winheight=999&#xA;set winminheight=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'winheight'&#xA;:help 'winminheight'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="2055" LastEditDate="2016-04-15T14:57:31.190" LastActivityDate="2016-04-15T14:57:31.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7353" PostTypeId="1" AcceptedAnswerId="7354" CreationDate="2016-04-15T11:54:31.230" Score="1" ViewCount="1699" Body="&lt;p&gt;I'm having trouble making indentation work as I expect in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Short version:&lt;/em&gt; What I want is to disable Tab mark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Long version:&lt;/em&gt; What I want is to ALWAYS insert four spaces when indenting (i.e. when hitting &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; AND when using &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, the second part is working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem comes from the &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; part: when hitting &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;, it inserts between 1 and 4 spaces to go to the next Tab mark. And I don't want that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, my Vim indentation parameters in &lt;code&gt;.vimrc&lt;/code&gt; are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set expandtab # To get spaces instead of Tab&#xA;set tabstop=4 # What actually is giving me trouble&#xA;# set softtabstop=-1 # I also tried this one but it gives me the same result&#xA;set shiftwidth=4 # To get 4 spaces Tab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I checked the others indentation parameters using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set sr? ai? cin? cink? cino? si? inde? indk?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which result was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noshiftround&#xA;noautoindent&#xA;nocindent&#xA;    cinkeys=0{,0},0),:,0#,!^F,o,O,e&#xA;    cinoption=&#xA;nosmartindent&#xA;indentexpr=&#xA;indentkeys=0{,0},:,0#,!^F,o,O,e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(If you're actually asking yourself why someone would be foul enough to want that, I'm writing some Robot Framework code in Vim and parameter separator are multiple spaces or tab. So when the Tab mark is 1 space after, it doesn't insert enough spaces.)&lt;/p&gt;&#xA;" OwnerDisplayName="Matthieu.P" LastEditorUserId="205" LastEditDate="2016-04-15T15:30:42.860" LastActivityDate="2016-04-15T15:30:42.860" Title="No shiftround when hitting Tab" Tags="|indentation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7354" PostTypeId="2" ParentId="7353" CreationDate="2016-04-15T13:04:35.217" Score="6" Body="&lt;p&gt;The current behavior is exactly how &lt;em&gt;indentation&lt;/em&gt; and &lt;em&gt;tabulation&lt;/em&gt; are supposed to work. What you want is neither indentation nor tabulation, therefore you need to find another mechanism.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest solution is to remap &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; to always insert four spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Tab&amp;gt; &amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll need the snippet below to make that mapping work &lt;em&gt;only&lt;/em&gt; in &lt;code&gt;*.robot&lt;/code&gt; files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup robot&#xA;    autocmd!&#xA;    autocmd BufNewFile,BufRead *.robot inoremap &amp;lt;buffer&amp;gt; &amp;lt;Tab&amp;gt; &amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" OwnerDisplayName="romainl" LastActivityDate="2016-04-15T13:04:35.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7355" PostTypeId="2" ParentId="7351" CreationDate="2016-04-15T15:29:56.700" Score="1" Body="&lt;p&gt;For what it's worth, you can use &lt;code&gt;ts&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ts foo&#xA; # pri kind tag               file&#xA; 1 F C f    foo               b.cpp&#xA;               class:B&#xA;               void foo(){&#xA; 2 F C f    foo               c.cpp&#xA;               class:C&#xA;               void foo(){&#xA;Type number and &amp;lt;Enter&amp;gt; (empty cancels):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see all matching elements, and select them. But I did not see any option to specify directly the parent element.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-04-15T15:29:56.700" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7356" PostTypeId="2" ParentId="7351" CreationDate="2016-04-15T16:21:31.703" Score="3" Body="&lt;p&gt;There are (universal?) tags options that can request functions names to be prefixed by full scope (namespace + class). Unfortunately, I can't remember which one it is among:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--c++-kinds=+f --fields=+imaSftn --extra=+q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any way, I highly recommend universal ctags instead of exuberant ctags for C++. And BTW, in &lt;a href=&quot;https://github.com/LucHermitte/lh-tags&quot; rel=&quot;nofollow&quot;&gt;lh-tags&lt;/a&gt; (that I'm maintaining), you'll find a more ergonomic way to select which overload you wish to jump to.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="205" LastEditDate="2016-04-15T19:56:16.290" LastActivityDate="2016-04-15T19:56:16.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7357" PostTypeId="1" AcceptedAnswerId="7358" CreationDate="2016-04-15T19:31:25.523" Score="3" ViewCount="924" Body="&lt;p&gt;I'm trying to copy just the matches in my regex search to a register in VIM on windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, I &lt;a href=&quot;http://vim.wikia.com/wiki/Copy_search_matches#Copy_matches&quot; rel=&quot;nofollow&quot;&gt;found&lt;/a&gt; the following script for doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CopyMatches(reg)&#xA;  let hits = []&#xA;  %s//\=len(add(hits, submatch(0))) ? submatch(0) : ''/ge&#xA;  let reg = empty(a:reg) ? '+' : a:reg&#xA;  execute 'let @'.reg.' = join(hits, &quot;\n&quot;) . &quot;\n&quot;'&#xA;endfunction&#xA;command! -register CopyMatches call CopyMatches(&amp;lt;q-reg&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I run the script and try to paste my matches from register a, it comes back blank.  Is there something else that I need to do to make this work?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2016-04-15T19:50:06.980" Title="Copying just the matches to a register?" Tags="|vimscript|regular-expression|register|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7358" PostTypeId="2" ParentId="7357" CreationDate="2016-04-15T19:50:06.980" Score="4" Body="&lt;p&gt;Note this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s//\=len(add(hits, submatch(0))) ? submatch(0) : ''/ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The search pattern is empty, which means it will re-use that last pattern that was used. So, this command relies on you having run &lt;code&gt;/foo&lt;/code&gt; before running this command.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-04-15T19:50:06.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7359" PostTypeId="2" ParentId="5823" CreationDate="2016-04-15T21:17:09.807" Score="0" Body="&lt;p&gt;Actually your first idea is possible, in an elegant way too.&#xA;You can create a user defined command and then call vim with the &lt;code&gt;+&lt;/code&gt; syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just define a custom user command in your &lt;code&gt;.vimrc&lt;/code&gt; file like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! CustomUserCommandName AnyVimCommandToExecute&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then from the command line you can start vim like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim +CustomUserCommandName&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used this in my &lt;code&gt;.vimrc&lt;/code&gt; for easy note taking, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Note Taking {{{&#xA;command! Note execute &quot;normal \&amp;lt;Plug&amp;gt;VimwikiMakeDiaryNote&quot;&#xA;command! Notes execute &quot;normal \&amp;lt;Plug&amp;gt;VimwikiDiaryIndex&quot; | execute &quot;normal \&amp;lt;Plug&amp;gt;VimwikiDiaryGenerateLinks&quot;&#xA;&quot; }}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows for calling it with this&lt;code&gt;vim +Note&lt;/code&gt;. Then make a shell alias in your shells &lt;code&gt;rc&lt;/code&gt; file, to allow even easier calling. In my &lt;code&gt;.bashrc&lt;/code&gt; file I alias the above vim commands like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias note=&quot;vim +Note&quot;&#xA;alias notes=&quot;vim +Notes&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Sample solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In your case you could write something along these lines in your &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! LightMode let g:lightmode=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then test for light mode however you want on per plugin basis or groups of plugins, etc... using a vim &lt;code&gt;if&lt;/code&gt; statement similar to this in your &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;g:lightMode&quot;)&#xA;    &quot; Do something cool with vim &#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Things to Note&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;!&lt;/code&gt; after the vim command &lt;code&gt;command!&lt;/code&gt; means that this will overwrite any similarly defined commands with the same name. This is preferable.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;CustomUserCommandName&lt;/code&gt; &lt;strong&gt;MUST&lt;/strong&gt; have the first letter capitalized &lt;/li&gt;&#xA;&lt;li&gt;You may not want to pollute your global scope with &lt;code&gt;g:&lt;/code&gt; you can use &lt;code&gt;s:&lt;/code&gt; or any scope that fits your needs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7254" LastActivityDate="2016-04-15T21:17:09.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7360" PostTypeId="1" AcceptedAnswerId="7362" CreationDate="2016-04-15T21:36:58.270" Score="4" ViewCount="912" Body="&lt;p&gt;How do I get the path to the currently executing VimL script from inside a function? I know from outside a function, you can use &lt;code&gt;expand('&amp;lt;sfile&amp;gt;')&lt;/code&gt;, but if you call that inside a function, you just get the function name. I know I asked this somewhere else before and got an answer, but now I forget how and can't find it anywhere.&lt;/p&gt;&#xA;" OwnerUserId="1410" LastActivityDate="2016-05-04T08:26:44.147" Title="Current VimL script path from inside a function" Tags="|vimscript|path|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7361" PostTypeId="2" ParentId="7340" CreationDate="2016-04-15T22:08:55.970" Score="3" Body="&lt;p&gt;Here is a solution which is not perfect but not that bad:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First add these lines to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReJoinTags() range&#xA;    set nowrapscan&#xA;    let @/='&amp;lt;\(\k\+\)&amp;gt;\([^&amp;lt;]\|\n\)\{-}&amp;lt;\/\1&amp;gt;'&#xA;&#xA;    let initialLine = line(&quot;.&quot;)&#xA;    normal ngnJ&#xA;&#xA;    if initialLine != line(&quot;.&quot;)&#xA;        call ReJoinTags()&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put your cursor on the root tag of your xml and call the function with &lt;code&gt;:call ReJoinTags()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function does several things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First set &lt;code&gt;nowrapscan&lt;/code&gt; so that a research will not wrap around the file.&lt;/li&gt;&#xA;&lt;li&gt;Set the search register to a regex which match only the content of tags which doesn't contains subtags (i.e. only the deepest tags). I'll detail the regex later.&lt;/li&gt;&#xA;&lt;li&gt;Get the current position of the cursor&lt;/li&gt;&#xA;&lt;li&gt;Go to the next match, select it and join the selection.&lt;/li&gt;&#xA;&lt;li&gt;Check if the cursor has moved and if so it means that a new tag has been joined so call the function again to try and join the next match.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is not perfect but on my system from this file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;context&amp;gt;&#xA;    &amp;lt;p&amp;gt;Here is a paragraph about some stuff that happened&#xA;       and someone did a nice printing that makes the text&#xA;       break and stuff, which is nice unless you have to&#xA;       it it, and now its a PITA.&amp;lt;/p&amp;gt;&#xA;    &amp;lt;p&amp;gt;Here is another paragraph. I suppose I could have&#xA;       Googled to get some lorem ipsum text to copy paste&#xA;       for this example, but that's not very fun and I wanted&#xA;       an excuse to use the then how could I use the word&#xA;       floccinaucinihilipilification?&amp;lt;/p&amp;gt;&#xA;    &amp;lt;p&amp;gt;Ignoring this paragraph would be absolute&#xA;       floccinaucinihilipilification!&amp;lt;/p&amp;gt;&#xA;    &amp;lt;a&amp;gt;&#xA;        &amp;lt;b&amp;gt;ldkfn sqkldfj lskjdfh&#xA;            sdfkljh lsdkfjh&amp;lt;/b&amp;gt;&#xA;        &amp;lt;b&amp;gt;sdf sflj zelrfkj erfh&#xA;            zer sdf sdf&amp;lt;/b&amp;gt;&#xA;        &amp;lt;b&amp;gt;a zerlfkj ezrlfk erf&amp;lt;/b&amp;gt;&#xA;    &amp;lt;/a&amp;gt;&#xA;    &amp;lt;a&amp;gt;&#xA;        &amp;lt;b&amp;gt;&#xA;            &amp;lt;c&amp;gt; sdf zerkj zer df&#xA;                zeroi ferioj&amp;lt;/c&amp;gt;&#xA;        &amp;lt;/b&amp;gt;&#xA;        &amp;lt;b&amp;gt;ldkfn sqkldfj lskjdfh&#xA;            sdfkljh lsdkfjh&amp;lt;/b&amp;gt;&#xA;        &amp;lt;b&amp;gt;sdf sflj zelrfkj erfh&#xA;            zer sdf sdf&amp;lt;/b&amp;gt;&#xA;    &amp;lt;/a&amp;gt;&#xA;&amp;lt;/context&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;context&amp;gt;&#xA;    &amp;lt;p&amp;gt;Here is a paragraph about some stuff that happened and someone did a nice printing that makes the text break and stuff, which is nice unless you have to it it, and now its a PITA.&amp;lt;/p&amp;gt;&#xA;    &amp;lt;p&amp;gt;Here is another paragraph. I suppose I could have Googled to get some lorem ipsum text to copy paste for this example, but that's not very fun and I wanted an excuse to use the then how could I use the word floccinaucinihilipilification?&amp;lt;/p&amp;gt;&#xA;    &amp;lt;p&amp;gt;Ignoring this paragraph would be absolute floccinaucinihilipilification!&amp;lt;/p&amp;gt;&#xA;    &amp;lt;a&amp;gt;&#xA;        &amp;lt;b&amp;gt;ldkfn sqkldfj lskjdfh sdfkljh lsdkfjh&amp;lt;/b&amp;gt;&#xA;        &amp;lt;b&amp;gt;sdf sflj zelrfkj erfh zer sdf sdf&amp;lt;/b&amp;gt;&#xA;        &amp;lt;b&amp;gt;a zerlfkj ezrlfk erf&amp;lt;/b&amp;gt; &amp;lt;/a&amp;gt;&#xA;    &amp;lt;a&amp;gt;&#xA;        &amp;lt;b&amp;gt;&#xA;            &amp;lt;c&amp;gt; sdf zerkj zer df zeroi ferioj&amp;lt;/c&amp;gt;&#xA;        &amp;lt;/b&amp;gt;&#xA;        &amp;lt;b&amp;gt;ldkfn sqkldfj lskjdfh sdfkljh lsdkfjh&amp;lt;/b&amp;gt;&#xA;        &amp;lt;b&amp;gt;sdf sflj zelrfkj erfh zer sdf sdf&amp;lt;/b&amp;gt; &amp;lt;/a&amp;gt;&#xA;&amp;lt;/context&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There seems to be a problem with some tags but it's still a beginning.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For the ones interested in the regex part, first feel free to tell me how to improve it: I'm far from being a regex guru so I'll be happy to learn more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now for the details:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;\(\k\+\)&amp;gt;\([^&amp;lt;]\|\n\)\{-}&amp;lt;\/\1&amp;gt;&#xA;&amp;lt;  \k\+  &amp;gt; The name of a tag&#xA;&amp;lt;\(\k\+\)&amp;gt; Captures the name of a tag&#xA;&#xA;          \([^&amp;lt;]\|\n\)\{-}      &#xA;          \(        \)\{-} Capture as few as possible occurences of the group&#xA;            [^&amp;lt;]\|\n       A group containing every character which is not '&amp;lt;' or is a new line      &#xA;&#xA;                          &amp;lt;\/\1&amp;gt; The closing tag&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-04-15T22:08:55.970" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7362" PostTypeId="2" ParentId="7360" CreationDate="2016-04-15T22:35:30.220" Score="7" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; If need to get the filename of your script I haven't found a good way to do that in the doc, so here is the solution I would suggested:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the beginning of your script define a script-variable (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#script-variable&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h script-variable&lt;/code&gt;&lt;/a&gt;) like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:filename=&quot;MyFileName.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The variable will be locale to the script so it is accessible and modifiable only from within the script. You can then access it with &lt;code&gt;echo s:filename&lt;/code&gt; for example, and concatenate it with the &lt;code&gt;expand('&amp;lt;sfile&amp;gt;')&lt;/code&gt; if you need the complete path. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDit 2&lt;/strong&gt; As @still_dreaming mentioned it in the comments it is possible to make this solution more robust:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;expand('&amp;lt;sfile&amp;gt;')&lt;/code&gt; returns &lt;code&gt;function&lt;/code&gt; only when it is called from inside a function, but when it is called from a script but outside a function it expands to the complete filename. Thus as long as the variable &lt;code&gt;s:filename&lt;/code&gt; is set at the beginning of the script outside of any function it is possible to set it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:filename=expand('&amp;lt;sfile&amp;gt;:p')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way it is not necessary to update the line if the file is renamed (but it will be necessary to source it again if its name is changed while it is in use).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A script would then be of this form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:filename=expand('&amp;lt;sfile&amp;gt;:p')&#xA;&#xA;function! Foo()&#xA;    &quot; Do magical Vim stuff&#xA;&#xA;    echo &quot;Path of this script: &quot; . s:filename&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You have to use the &lt;code&gt;:p&lt;/code&gt; filename modifier like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echom expand('&amp;lt;sfile&amp;gt;:p')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#filename-modifiers&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h filename-modifiers&lt;/code&gt;&lt;/a&gt; for more modifiers like &lt;code&gt;:~&lt;/code&gt; for example which reduce the path to a relative path to the home directory.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-04T08:26:44.147" LastActivityDate="2016-05-04T08:26:44.147" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7363" PostTypeId="5" CreationDate="2016-04-15T22:40:37.277" Score="0" Body="&lt;p&gt;Questions about replaying the same command. This includes the dot command &lt;code&gt;.&lt;/code&gt;,  &lt;code&gt;@&lt;/code&gt; macros,  &lt;code&gt;@:&lt;/code&gt;  and similar methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related: &lt;a href=&quot;/questions/tagged/multiple-lines&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;multiple-lines&amp;#39;&quot; rel=&quot;tag&quot;&gt;multiple-lines&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="2314" LastEditDate="2016-12-24T12:56:59.613" LastActivityDate="2016-12-24T12:56:59.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7364" PostTypeId="4" CreationDate="2016-04-15T22:40:37.277" Score="0" Body="Questions about replaying the same command. This includes the dot command (.), @ macros,  @:  and similar methods." OwnerUserId="1841" LastEditorUserId="205" LastEditDate="2016-12-24T12:58:44.127" LastActivityDate="2016-12-24T12:58:44.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7365" PostTypeId="5" CreationDate="2016-04-15T22:42:34.380" Score="0" Body="" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-15T22:42:34.380" LastActivityDate="2016-04-15T22:42:34.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7366" PostTypeId="4" CreationDate="2016-04-15T22:42:34.380" Score="0" Body="Question about the use of functions in Vimscript defined in the `.vimrc` or a script file." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-15T22:42:34.380" LastActivityDate="2016-04-15T22:42:34.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7367" PostTypeId="2" ParentId="7343" CreationDate="2016-04-15T23:47:08.123" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/7343#comment12060_7343&quot;&gt;muru’s comment&lt;/a&gt; lead me to the answer. According to &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#argument-list&quot; rel=&quot;nofollow noreferrer&quot;&gt;the docs&lt;/a&gt;, &lt;code&gt;argdo&lt;/code&gt;&#xA;requires the &lt;code&gt;listcmds&lt;/code&gt; feature at compile time. It appears I do not have it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex --version | grep -e Features -e listcmds&#xA;Small version without GUI.  Features included (+) or not (-):&#xA;-cursorshape     -listcmds        -reltime         +windows&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a workaround:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for b in *.txt&#xA;do&#xA;  ex -sc '%s/1/Z/|x' &quot;$b&quot;&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-04-16T16:52:14.103" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7368" PostTypeId="1" AcceptedAnswerId="7372" CreationDate="2016-04-16T00:23:08.097" Score="11" ViewCount="6567" Body="&lt;p&gt;I want to type the subscript i as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/b6uEz.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/b6uEz.png&quot; alt=&quot;subsript i&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have tried:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I got to know how to type numerial subscripts, by following &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/digraph.html&quot; rel=&quot;noreferrer&quot;&gt;this documentation&lt;/a&gt;.&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;ctrl-k&amp;gt;[digit]s&lt;/code&gt;    &lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I search the local help doc (absolutely the same as the above) by &lt;code&gt;:h digraphs&lt;/code&gt; and find only those for numbers also.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aw9Mg.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aw9Mg.png&quot; alt=&quot;help doc&quot;&gt;&lt;/a&gt;    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;No more no less.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I have found &lt;a href=&quot;https://github.com/Rykka/mathematic.vim/blob/master/keymap/mathematic.vim&quot; rel=&quot;noreferrer&quot;&gt;a plugin&lt;/a&gt; for doing this and got to know the author's &lt;a href=&quot;https://github.com/Rykka/mathematic.vim/blob/master/keymap/mathematic.vim#L105&quot; rel=&quot;noreferrer&quot;&gt;implementation&lt;/a&gt;.    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_i                       &amp;lt;char-0x1D62&amp;gt; &quot; ᵢ&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I raise this question for asking if I can type the alphabetic subscripts without plugins (which also means don't use the daunting commands as                   &lt;code&gt;&amp;lt;char-0x1D62&amp;gt;&lt;/code&gt;). I need commands like &lt;code&gt;&amp;lt;ctrl-k&amp;gt;[alphabet]s&lt;/code&gt;. Please don't recommend me LaTex as &lt;a href=&quot;https://superuser.com/a/41747/462466&quot;&gt;this answer&lt;/a&gt; since I'm learning it.     &lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2021-02-07T18:52:44.713" Title="How can I type the alphabetic subscripts?" Tags="|digraphs|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7369" PostTypeId="2" ParentId="7340" CreationDate="2016-04-16T05:58:53.263" Score="0" Body="&lt;p&gt;You can try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:v/^&amp;lt;p&amp;gt;/-1j!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inspired from this answer here&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://superuser.com/a/565566&quot;&gt;https://superuser.com/a/565566&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7079" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2016-04-16T05:58:53.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7370" PostTypeId="1" AcceptedAnswerId="7375" CreationDate="2016-04-16T08:11:13.730" Score="0" ViewCount="82" Body="&lt;p&gt;I want to align C variables declariations with &lt;a href=&quot;https://github.com/vim-scripts/Align&quot; rel=&quot;nofollow&quot;&gt;the Align plugin&lt;/a&gt; using &lt;code&gt;\adec&lt;/code&gt; as parameter, the problem is that it doesn't do anything.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct mutex {&#xA;    pthread_mutex_t listmsg;&#xA;    pthread_rwlock_t entity_rw;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I select the two lines in the struc in visual mode and then enter &lt;code&gt;:Align \&#xA;adec&lt;/code&gt; but nothing happens.&lt;/p&gt;&#xA;" OwnerUserId="6078" LastEditorUserId="1841" LastEditDate="2016-04-16T08:32:41.493" LastActivityDate="2016-04-16T13:39:16.093" Title="Using Align plugin" Tags="|alignment|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7371" PostTypeId="1" AcceptedAnswerId="7379" CreationDate="2016-04-16T08:57:19.023" Score="2" ViewCount="475" Body="&lt;p&gt;I am looking for a way to easily compile whole latex projects, based in several files through the following set of folders:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.&#xA;|- MyProjectsMainFile.tex&#xA;|- img/&#xA;|  |- image1.png&#xA;|  |- image2.jpg&#xA;|  `- etc.whatever&#xA;`- tex/&#xA;   |- part1.tex&#xA;   |- part2.tex&#xA;   `- conclusion.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The tricky bit is to do this even if I am editing a file in the &lt;code&gt;tex&lt;/code&gt; folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will explain a bit my usage first: In larger projects I use this structure, and I reference pictures using &lt;code&gt;\includegraphics{./img/name}&lt;/code&gt; and insert code from the other &lt;code&gt;.tex&lt;/code&gt; files by &lt;code&gt;\input{.tex/file.tex}&lt;/code&gt;, &lt;a href=&quot;https://en.wikibooks.org/wiki/LaTeX/Modular_Documents&quot; rel=&quot;nofollow&quot;&gt;as is the way to go for modular documents&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Up until now, this structure has only been needed in projects I have made with other people, and my own documents have always been so small that I didn't need the &lt;code&gt;tex&lt;/code&gt; folder. For this reason, while using Vim to write my own stuff, I compiled using the following in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; LaTeX macros for compiling and viewing&#xA;augroup latex_macros &quot; {&#xA;    autocmd!&#xA;    autocmd FileType tex :nnoremap &amp;lt;leader&amp;gt;c :w&amp;lt;CR&amp;gt;:!pdflatex %&amp;lt;CR&amp;gt;&#xA;    autocmd FileType tex :nnoremap &amp;lt;leader&amp;gt;v :!open %:r.pdf &amp;amp;&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;augroup END &quot; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;leader&amp;gt; c&lt;/code&gt; to compile, &lt;code&gt;&amp;lt;leader&amp;gt; v&lt;/code&gt; to view. This works well until you start going down into the folders, and the file that needs to be compiled is not the one you are working on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't rely on any LaTeX-extensions, and I would like to keep things that way for the most part (I use Ultisnips as my tab-complete tool with quite personalized snippets, and I don't want any extension to mess with my clearly superior completions!). I know there are extension out there that take care of this worry, but I don't want to a whole world of stuff just because of this little thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few assumptions that can be used as starting point:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I will always either be in the very file to be compiled, or in a file that is immediately inside &lt;code&gt;tex/&lt;/code&gt;. That is to say, &lt;code&gt;MyProjectsMainFile.tex&lt;/code&gt; will always either be in &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;..&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;MyProjectsMainFile.tex&lt;/code&gt; will be &lt;em&gt;the only&lt;/em&gt; &lt;code&gt;.tex&lt;/code&gt; file in my project main folder.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I prefer using the extension &lt;code&gt;.tex&lt;/code&gt; for the files in the &lt;code&gt;tex/&lt;/code&gt; folder as well.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It might be sufficient to include som comment at the top of every inserted file, and improve the above macro to check for this line and create a special case (I have seen extensions using this solution). I wouldn't know how to do that in Vimscript though, and perhaps there are better ways of solving this problem.&lt;/p&gt;&#xA;" OwnerUserId="7258" LastEditorUserId="205" LastEditDate="2016-04-16T11:10:53.303" LastActivityDate="2016-04-16T17:24:28.873" Title="Compiling whole LaTeX projects" Tags="|filetype-tex|previewing|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7372" PostTypeId="2" ParentId="7368" CreationDate="2016-04-16T11:38:30.457" Score="7" Body="&lt;p&gt;First off, &lt;a href=&quot;https://stackoverflow.com/a/6614102/5274741&quot;&gt;this answer&lt;/a&gt; suggests that there are no unicode subscript letters for all latin characters.&#xA;However you can still get some of them (a list is provided by several answers in the linked answer) by using &lt;code&gt;:digraphs&lt;/code&gt; with argumenst, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:digraphs as 8336&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;8336&lt;/code&gt; is the unicode encoding of the &quot;LATIN SUBSCRIPT SMALL LETTER A&quot; written in decimal.&#xA;This will allow you to type &lt;code&gt;&amp;lt;C-K&amp;gt;as&lt;/code&gt; and get a subscript &lt;code&gt;a&lt;/code&gt;, as desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since unicode encodings are usually given in hexadecimal, I suggest to do the following (here, &lt;code&gt;2901&lt;/code&gt; is the encoding of &quot;LATIN SUBSCRIPT SMALL LETTER E&quot; in hexadecimal):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;digraphs es &quot; . 0x2091&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which lets vim take care of the hex to decimal conversion and will give you the &lt;code&gt;&amp;lt;C-K&amp;gt;es&lt;/code&gt; mapping for a subscript e.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/digraph.html#:digraphs&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :digraphs&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3343" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-04-16T11:38:30.457" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7373" PostTypeId="2" ParentId="7371" CreationDate="2016-04-16T12:26:20.817" Score="2" Body="&lt;p&gt;Under the additional assumptions that there is always exactly one &lt;code&gt;.tex&lt;/code&gt; file in your project's root directory, the following should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetProjectRoot()&#xA;  if expand(&quot;%:p:h:t&quot;) == &quot;tex&quot;&#xA;    let l:dir=split(system(&quot;ls ..&quot;), &quot;\n&quot;)&#xA;    return fnamemodify(&quot;../&quot; . filter(l:dir, &quot;v:val =~ \&quot;.*\.tex\&quot;&quot;)[0],  &quot;:p&quot;)&#xA;  else&#xA;    return expand(&quot;%:p&quot;)&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems still pretty hackish, but lacking experience, this is all I could do in short time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can adjust your maps to look like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;v :execute &quot;:!open &quot; . fnamemodify(GetProjectRoot(), &quot;:r&quot;) . &quot;.pdf &amp;amp;&quot;&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;c :w&amp;lt;CR&amp;gt;:!pdflatex GetProjectRoot()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2016-04-16T12:26:20.817" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7374" PostTypeId="2" ParentId="7371" CreationDate="2016-04-16T12:26:27.900" Score="2" Body="&lt;p&gt;Given the conditions in the question, you could use this function to determine the main TeX file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetMainTeX()&#xA;    &quot; Start with the current file&#xA;    let l:main_file = expand('%')&#xA;    &quot; If it's in a tex folder&#xA;    if expand('%:p:h:t') == 'tex'&#xA;        &quot; Look for files in parent folder&#xA;        let l:files = glob(expand('%:p:h:h') . '/*.tex', 0, 1)&#xA;        &quot; There should be only one such file&#xA;        if len(l:files) &amp;gt; 1&#xA;            throw &quot;Multiple files found&quot;&#xA;        endif&#xA;        let l:main_file = l:files[0] &#xA;    endif&#xA;    return l:main_file&#xA;endfunction &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#glob%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;glob&lt;/code&gt;&lt;/a&gt; function can be used to look for files matching wildcard patterns. If your main file's name is fixed, you could also use the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#findfile%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;findfile&lt;/code&gt;&lt;/a&gt; function instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;findfile({name}[, {path}[, {count}]])                           findfile()&#xA;                Just like finddir(), but find a file instead of a directory.&#xA;                Uses 'suffixesadd'.&#xA;                Example: &#xA;                        :echo findfile(&quot;tags.vim&quot;, &quot;.;&quot;)&#xA;               Searches from the directory of the current file upwards until&#xA;                it finds the file &quot;tags.vim&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, something like the following could replace the entire function written above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;findfile('main.tex', '.;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-04-16T12:26:27.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7375" PostTypeId="2" ParentId="7370" CreationDate="2016-04-16T13:39:16.093" Score="3" Body="&lt;p&gt;&lt;code&gt;\adec&lt;/code&gt; is not a parameter to &lt;code&gt;:Align&lt;/code&gt;, it is a key mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't type &lt;code&gt;:Align \adec&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just hit the keys &lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2016-04-16T13:39:16.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7376" PostTypeId="2" ParentId="6995" CreationDate="2016-04-16T13:43:46.170" Score="3" Body="&lt;p&gt;As noted in the comments, you can use Vimscript within the vim-plug block, so I ended up checking for particular commands to control installation of plugins. For example, I rarely have cmake installed, I usually install it for YCM. So a &lt;code&gt;executable('cmake')&lt;/code&gt; check is good enough for that. Now, my vim-plug block has one section for common plugins, and a set of checks for those which are useful in specific cases: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin()&#xA;&quot; Common plugins&#xA;Plug 'vim-scripts/diffchar.vim'&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'ervandew/supertab'&#xA;Plug 'scrooloose/syntastic'&#xA;Plug 'tpope/vim-surround'&#xA;Plug 'bling/vim-airline'&#xA;Plug 'tpope/vim-fugitive'&#xA;Plug 'tomasr/molokai'&#xA;Plug 'ctrlpvim/ctrlp.vim'&#xA;Plug 'gabrielelana/vim-markdown', {'for': 'markdown'}&#xA;Plug 'majutsushi/tagbar', {'for': ['cpp', 'c', 'go', 'sh', 'js']}&#xA;Plug 'godlygeek/tabular'&#xA;&#xA;if executable('cmake')&#xA;    &quot; YCM command lifted from vim-plug readme&#xA;    Plug 'Valloric/YouCompleteMe', { 'do': YCMInstallCmd(), 'for': ['cpp', 'c', 'go', 'sh', 'js', 'vim'] }&#xA;    autocmd! User YouCompleteMe if !has('vim_starting') | call youcompleteme#Enable() | endif&#xA;endif&#xA;if executable('go')&#xA;    Plug 'fatih/vim-go', {'for': 'go'}&#xA;endif&#xA;if executable('latex')&#xA;    Plug 'lervag/vimtex', {'for': 'tex'}&#xA;endif&#xA;if executable('ghc')&#xA;    Plug 'dag/vim2hs', {'for': 'hs'}&#xA;endif&#xA;if executable('man')&#xA;    Plug 'murukeshm/vim-manpager'&#xA;endif&#xA;if executable('dpkg')&#xA;    Plug 'vim-scripts/deb.vim'&#xA;endif&#xA;if executable('logrotate')&#xA;    Plug 'moon-musick/vim-logrotate'&#xA;endif&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-04-16T13:53:15.640" LastActivityDate="2016-04-16T13:53:15.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7377" PostTypeId="1" AcceptedAnswerId="7392" CreationDate="2016-04-16T14:07:44.623" Score="17" ViewCount="3309" Body="&lt;p&gt;Sometimes my global substitutions don't substitute all matches in a line. It is confirmed by the fact that I can see it when I do substitutions with confirmation, a match is found in a line with multiple possible matches, but then it goes to another line.&lt;/p&gt;&#xA;&lt;p&gt;I use the &lt;code&gt;g&lt;/code&gt; or &lt;code&gt;gc&lt;/code&gt; parameters operating on the entire file with &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;On this file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;hello hello&#xA;hello&#xA;hello hello hello&#xA;hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If I do &lt;code&gt;%s/hello/goodbye/g&lt;/code&gt; I get:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;goodbye hello&#xA;goodbye&#xA;goodbye hello hello&#xA;goodbye&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;All I have in my &lt;code&gt;.vimrc&lt;/code&gt; about search/replace is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set hlsearch&#xA;set ignorecase&#xA;set incsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6078" LastEditorUserId="18609" LastEditDate="2020-12-01T15:09:47.303" LastActivityDate="2020-12-01T15:09:47.303" Title="Vim global substitution doesn't substitute all matches in a line" Tags="|substitute|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="7378" PostTypeId="1" AcceptedAnswerId="7382" CreationDate="2016-04-16T16:38:06.430" Score="12" ViewCount="4317" Body="&lt;p&gt;I recently found out about Vim hard mode and I've decided to try and use it. However, I'm running into some problems with fine grain movements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's say I really just want to move up or down one line. Since &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; are disabled, I'm not sure what better alternatives there are for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've run into the same problem when I want to move one or two characters to right or left. Does anyone know how one would replace these types of movements?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the plugin I am using: &lt;a href=&quot;https://github.com/wikitopian/hardmode&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/wikitopian/hardmode&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7260" LastEditorUserId="51" LastEditDate="2017-01-20T01:12:21.163" LastActivityDate="2023-03-30T02:16:58.780" Title="Vim HardMode Fine Grain Movements" Tags="|cursor-movement|" AnswerCount="5" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="7379" PostTypeId="2" ParentId="7371" CreationDate="2016-04-16T17:24:28.873" Score="5" Body="&lt;p&gt;I would say that you are approaching this the wrong way. If you want to use a very minimalistic solution without any plugins, I would claim that you should not have anything in your vimrc file for compiling. Instead, you should use &lt;a href=&quot;https://www.ctan.org/pkg/latexmk/&quot;&gt;latexmk&lt;/a&gt;. This is a very good automatic compilation tool for LaTeX, which will compile as many times as necessary, including bibliography files and similar. It is very customizible, for those who need that. In addition, with the option &lt;code&gt;-pvc&lt;/code&gt;, it can run in the background and compile your document whenever any relevant files change (including e.g. graphic files). Thus, my suggested solution is to simply keep a terminal open at the root of your project, and to run &lt;code&gt;latexmk -pvc MyMainFile.tex&lt;/code&gt;. This will allow you to keep your vimrc file clean, and to work on your LaTeX document without worrying about compiling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I will also suggest that my plugin, &lt;a href=&quot;https://github.com/lervag/vimtex&quot;&gt;vimtex&lt;/a&gt;, might suit your needs. It does not mingle with your other plugins, and it provides e.g. the ability to compile your document through &lt;code&gt;latexmk&lt;/code&gt; with the &lt;code&gt;&amp;lt;leader&amp;gt;ll&lt;/code&gt; mapping (continuous mode by default, but this can be changed). It also provides several other features that I think are quite nice, e.g. toggling of math delimiter modifiers (for example &lt;code&gt;\left ... \right&lt;/code&gt; pairs).&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-04-16T17:24:28.873" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7380" PostTypeId="1" AcceptedAnswerId="7381" CreationDate="2016-04-16T17:38:36.883" Score="2" ViewCount="527" Body="&lt;p&gt;Given file &lt;em&gt;alfa.txt&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10&#xA;11&#xA;12&#xA;13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to append a line of text after every line. This is simple enough&#xA;with sed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sed aBRAVO alfa.txt&#xA;10&#xA;BRAVO&#xA;11&#xA;BRAVO&#xA;12&#xA;BRAVO&#xA;13&#xA;BRAVO&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I am having hard time with Ex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex -sc '%a|BRAVO' -cx alfa.txt&#xA;$ cat alfa.txt&#xA;10&#xA;11&#xA;12&#xA;13&#xA;BRAVO&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2016-04-16T18:11:32.773" Title="Global append lines" Tags="|ex-mode|ex-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7381" PostTypeId="2" ParentId="7380" CreationDate="2016-04-16T18:11:32.773" Score="2" Body="&lt;p&gt;&lt;em&gt;append&lt;/em&gt; only supports a &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html#tag_20_40_13_12&quot; rel=&quot;nofollow&quot;&gt;single line address&lt;/a&gt;, not a range. Here is a&#xA;workaround with &lt;em&gt;global&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc 'g/^/a|BRAVO' -cx alfa.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and with &lt;em&gt;substitute&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '%s/$/\rBRAVO/|x' alfa.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2016-04-16T18:11:32.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7382" PostTypeId="2" ParentId="7378" CreationDate="2016-04-17T06:22:03.847" Score="20" Body="&lt;p&gt;These are just a few of the movements that vim is capable of, these should get you going for now.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;TL;DR&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use Vim's built in help feature on &lt;code&gt;navigation&lt;/code&gt; or better still &lt;code&gt;usr_03.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Search google for &lt;code&gt;vim advanced movements&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Navigate with/to words&lt;/li&gt;&#xA;&lt;li&gt;go here &lt;a href=&quot;http://vim.wikia.com/wiki/All_the_right_moves&quot;&gt;All the right moves&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Movements&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are many ways of getting around in vim I have listed some that I found by searching for &lt;code&gt;vim advanced movements&lt;/code&gt;, and a few that I use all the time. Im sure you know of most of these but the ones I think you will want to pay particular attention too are the word navigation's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are a few that allow for navigation inside a line.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; – go to the starting of the current line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; – go to the first non blank character of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt; – go to the end of the current line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g_&lt;/code&gt; – go to the last non blank character of the line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Navigation with words can be very helpful. To be more granular, you should navigate in relation to words, using:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;e&lt;/code&gt; – go to the end of the current word.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;E&lt;/code&gt; – go to the end of the current WORD.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;b&lt;/code&gt; – go to the previous (before) word.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;B&lt;/code&gt; – go to the previous (before) WORD.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt; – go to the next word.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;W&lt;/code&gt; – go to the next WORD.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A word consists of a sequence of letters, digits and underscores.&#xA;A WORD consists of a sequence of non-blank characters, separated with white space.&#xA;words|WORDS may also change depending on your vim settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example to show the difference between WORD and word&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;192.168.1.1&lt;/code&gt; is single WORD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;192.168.1.1&lt;/code&gt; is seven words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The search movements can be extremely useful too.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/pattern&lt;/code&gt; – Search for a pattern which will you take you to the next occurrence of &lt;code&gt;pattern&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt; will take you to the next match of &lt;code&gt;pattern&lt;/code&gt; below the cursor.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;?pattern&lt;/code&gt; – Search for a pattern which will you take you to the previous occurrence of &lt;code&gt;pattern&lt;/code&gt;.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;N&lt;/code&gt; will take you to the next match of &lt;code&gt;pattern&lt;/code&gt; above the the cursor.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;*&lt;/code&gt; – Go to the next occurrence of the current word under the cursor.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;#&lt;/code&gt; – Go to the previous occurrence of the current word under the cursor.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt; – Go to the matching braces, or parenthesis inside code.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here are a few you can do even before you open vim, from the command line&#xA;&lt;code&gt;Vim +N filename&lt;/code&gt; allows you to go to the Nth line of the file after opening it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim +10 /etc/passwd&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Vim +/pattern filename&lt;/code&gt; opens the file to the first line with the occurrence of the &lt;code&gt;pattern&lt;/code&gt;. In the following example, vim will open the README file and jump to the first occurrence of the word “install”.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim +/install README&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Vim +?patten filename&lt;/code&gt; opens the file to the last occurrence of &lt;code&gt;pattern&lt;/code&gt;. In the following example, it will open the README file and jump to the last occurrence of the word “bug”.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim +?bug README&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7254" LastEditorUserId="7254" LastEditDate="2016-06-28T21:02:38.473" LastActivityDate="2016-06-28T21:02:38.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7383" PostTypeId="1" CreationDate="2016-04-17T09:14:18.577" Score="2" ViewCount="618" Body="&lt;p&gt;The command &lt;code&gt;:'&amp;lt;,'&amp;gt;s/search/replace/g&lt;/code&gt; will replace in the whole line of the current selection, but what if I want to substitute only inside the current selection, not the whole line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Update&lt;/em&gt;: Found &lt;a href=&quot;https://vi.stackexchange.com/q/1922/1066&quot;&gt;the duplicate&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1066" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-04-17T10:11:36.087" Title="How do I :substitute inside a selection?" Tags="|substitute|visual-mode|replace|" AnswerCount="1" CommentCount="0" ClosedDate="2016-04-17T12:15:52.070" ContentLicense="CC BY-SA 3.0" />
  <row Id="7384" PostTypeId="2" ParentId="7383" CreationDate="2016-04-17T09:14:18.577" Score="3" Body="&lt;p&gt;Use &lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%Vsearch/replace/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;help substitute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;For the definition of a pattern, see |pattern|.  In Visual block mode, use&#xA;|/\%V| in the pattern to have the substitute work in the block only.&#xA;Otherwise it works on whole lines anyway.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2016-04-17T09:14:18.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7385" PostTypeId="2" ParentId="7378" CreationDate="2016-04-17T10:19:18.727" Score="8" Body="&lt;p&gt;As an alternative to hardmode, the following snippet will allow you to use &lt;code&gt;h&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, and &lt;code&gt;l&lt;/code&gt; as normal but produce an audible beep to warn you when they are used in rapid succession.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:BeepOnRepeat(key)&#xA;    let count1 = v:count1&#xA;&#xA;    if !exists('s:last_time')&#xA;        let s:last_time    = reltime()&#xA;        let s:repeat_count = 1&#xA;    else&#xA;        &quot; increment the repeat count if `h`, `j`, `k`, or `l` was pressed&#xA;        &quot; within the last second, otherwise reset it&#xA;        let now = reltime()&#xA;        if str2float(reltimestr(reltime(s:last_time, now))) &amp;lt; 1&#xA;            let s:repeat_count += 1&#xA;        else&#xA;            let s:repeat_count = 1&#xA;        endif&#xA;        let s:last_time = now&#xA;&#xA;        &quot; produce an audible beep if a sequence of `h`, `j`, `k`, and/or `l`,&#xA;        &quot; greater than three, was pressed (within the repeat count time limit)&#xA;        if s:repeat_count &amp;gt; 3&#xA;            let savebelloff    = &amp;amp;belloff&#xA;            let savevisualbell = &amp;amp;visualbell&#xA;            let &amp;amp;belloff    = ''&#xA;            let &amp;amp;visualbell = 0&#xA;            execute &quot;normal! \&amp;lt;Esc&amp;gt;&quot;&#xA;            let &amp;amp;belloff    = savebelloff&#xA;            let &amp;amp;visualbell = savevisualbell&#xA;        endif&#xA;    endif&#xA;&#xA;    execute 'normal! ' . count1 . a:key&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; h :&amp;lt;C-u&amp;gt;call &amp;lt;SID&amp;gt;BeepOnRepeat('h')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; j :&amp;lt;C-u&amp;gt;call &amp;lt;SID&amp;gt;BeepOnRepeat('j')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; k :&amp;lt;C-u&amp;gt;call &amp;lt;SID&amp;gt;BeepOnRepeat('k')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; l :&amp;lt;C-u&amp;gt;call &amp;lt;SID&amp;gt;BeepOnRepeat('l')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For another approach to limiting &lt;code&gt;hjkl&lt;/code&gt; usage, see &lt;a href=&quot;https://github.com/0x0dea/vim-molasses&quot;&gt;vim-molasses&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6206" LastActivityDate="2016-04-17T10:19:18.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7386" PostTypeId="1" AcceptedAnswerId="7394" CreationDate="2016-04-17T13:49:03.910" Score="22" ViewCount="1226" Body="&lt;p&gt;Is there a way to instruct Vim that I want to ignore diacritics/accents when searching? For example, I would like to be able to search for&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;kočička&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by entering&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/kocicka&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;ignorecase&amp;#39;&quot;&gt;&lt;code&gt;ignorecase&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;smartcase&amp;#39;&quot;&gt;&lt;code&gt;smartcase&lt;/code&gt;&lt;/a&gt; options are very useful, but they do not seem to have anything to do with diacritics/accents.&lt;/p&gt;&#xA;" OwnerUserId="6894" LastActivityDate="2023-09-01T08:41:02.770" Title="Ignoring diacritics/accents when searching" Tags="|search|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7387" PostTypeId="1" AcceptedAnswerId="7391" CreationDate="2016-04-17T16:35:13.297" Score="1" ViewCount="1020" Body="&lt;p&gt;Given file &lt;em&gt;alfa.txt&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10&#xA;11&#xA;12&#xA;13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can remove every other line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex -sc 'g/^/+d' -cx alfa.txt&#xA;$ cat alfa.txt&#xA;10&#xA;12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I cannot replace every other line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex -sc 'g/^/+s//&amp;gt; /' -cx alfa.txt&#xA;$ cat alfa.txt&#xA;10&#xA;&amp;gt; 11&#xA;&amp;gt; 12&#xA;&amp;gt; 13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2016-04-17T22:50:48.840" Title="Replace every other line" Tags="|ex-mode|ex-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7388" PostTypeId="1" CreationDate="2016-04-17T19:26:08.017" Score="16" ViewCount="5560" Body="&lt;p&gt;Assuming I have a line in a file with &lt;code&gt;XXXX&lt;/code&gt; being a placeholder I have selected via &lt;code&gt;v&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;XXXX Some other text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I change &lt;em&gt;only&lt;/em&gt; the &lt;code&gt;XXXX&lt;/code&gt; with the output of an external command, such as &lt;code&gt;date +%Y%m%d&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got as far as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!date +\%Y\%m\%d &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that replaced the whole line.&lt;/p&gt;&#xA;" OwnerUserId="2774" LastActivityDate="2018-11-18T13:46:41.313" Title="Replace selection with output of external command" Tags="|external-command|replace|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7389" PostTypeId="2" ParentId="7388" CreationDate="2016-04-17T19:56:49.370" Score="5" Body="&lt;p&gt;If you put the cursor on such a line you can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; to put the cursor in the first column.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f&lt;/code&gt; &lt;kbd&gt;Space&lt;/kbd&gt; to put the cursor in the first blank.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;i&lt;/code&gt; &lt;kbd&gt;Enter&lt;/kbd&gt; &lt;kbd&gt;Esc&lt;/kbd&gt; to split the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;l&lt;/code&gt; to move the cursor one line up.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:.!date +\%Y\%m\%d&lt;/code&gt; to execute the command.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;J&lt;/code&gt; to join the lines again.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html#:visual_example&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :visual_example&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Currently the &quot;:&quot; command works on whole lines only.  When you select part of a line, doing something like &quot;:!date&quot; will replace the whole line.  If you want only part of the line to be replaced you will have to make a mapping for it.  In a future release &quot;:&quot; may work on partial lines.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html#visual-operators&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h visual-operators&lt;/code&gt;&lt;/a&gt; for details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://vi.stackexchange.com/questions/6898/how-to-modify-visually-selected-block-with-external-command/6899#comment11226_6898&quot;&gt;this&lt;/a&gt; comment: You can also try the &lt;a href=&quot;http://www.drchip.org/astronaut/vim/#VIS&quot; rel=&quot;nofollow noreferrer&quot;&gt;vis&lt;/a&gt; or &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn&quot; rel=&quot;nofollow noreferrer&quot;&gt;NrrwRgn&lt;/a&gt; plugin. Both should handle it just fine. (Thanks @christian-brabandt for the tip).&lt;/p&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-04-17T20:33:46.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7390" PostTypeId="2" ParentId="7388" CreationDate="2016-04-17T19:57:09.717" Score="18" Body="&lt;p&gt;You could delete the text and insert the output of a command using &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;R&lt;/kbd&gt;-&lt;kbd&gt;=&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-R {0-9a-z&quot;%#*+:.-=}                                        i_CTRL-R&#xA;                Insert the contents of a register.  Between typing CTRL-R and&#xA;                the second character, '&quot;' will be displayed to indicate that&#xA;                you are expected to enter the name of a register.&#xA; …&#xA;                                                        i_CTRL-R_=&#xA;                        '='     the expression register: you are prompted to&#xA;                                enter an expression (see expression)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the expression, you can use the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#system%28%29&quot;&gt;&lt;code&gt;system()&lt;/code&gt;&lt;/a&gt; function to run external commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After selecting the text, press &lt;code&gt;c&lt;/code&gt;, then &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-R_%3D&quot;&gt;&lt;code&gt;&amp;lt;c-r&amp;gt;=&lt;/code&gt;&lt;/a&gt; and use &lt;code&gt;system('date +%Y%m%d')&lt;/code&gt; as the expression.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-04-17T19:57:09.717" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7391" PostTypeId="2" ParentId="7387" CreationDate="2016-04-17T22:50:48.840" Score="1" Body="&lt;p&gt;Here is a workaround:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '%s/\v(.*\n){2}/&amp;gt; &amp;amp;/|x' alfa.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;%&lt;/code&gt; select all lines&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;s&lt;/code&gt; substitute&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;\v&lt;/code&gt; turn on magic&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;x&lt;/code&gt; save and close&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2016-04-17T22:50:48.840" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7392" PostTypeId="2" ParentId="7377" CreationDate="2016-04-17T23:07:18.483" Score="19" Body="&lt;p&gt;Maybe you, or a plugin, had enabled the option &lt;code&gt;'gdefault'&lt;/code&gt;. This option adds the flag &lt;code&gt;g&lt;/code&gt; automatically whenever you perform a substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, when you manually add the flag &lt;code&gt;g&lt;/code&gt; while &lt;code&gt;'gdefault'&lt;/code&gt; is enabled, it's as if you had 2 &lt;code&gt;g&lt;/code&gt; flags which has the same effect as none. Therefore, Vim only substitutes the first occurrence of the pattern on every line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, this option is disabled, but to make sure it is, you could add at the end of your &lt;code&gt;vimrc&lt;/code&gt;: &lt;code&gt;set nogdefault&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if you suspect a plugin might have enabled the option, you could track it down with: &lt;code&gt;verb set gd?&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could get used to the option which means that when you want to substitute all the occurrences of a pattern, you don't add the &lt;code&gt;g&lt;/code&gt; flag (because &lt;code&gt;gdefault&lt;/code&gt; already did it), and when you want to only substitute the 1st occurrence of the pattern on a line, you add the &lt;code&gt;g&lt;/code&gt; flag (because 2 &lt;code&gt;g&lt;/code&gt; flags is the same as none).&lt;/p&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-04-17T23:07:18.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7393" PostTypeId="1" AcceptedAnswerId="7395" CreationDate="2016-04-17T23:21:49.593" Score="-1" ViewCount="682" Body="&lt;p&gt;I have to make explicit source file, eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -S ~/.vimrc whatever.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;otherwise it's either ignored or superseded by other configuration files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found running with strace the following order in which is such a directories/files are read:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edited according comment from muru (using :scriptnames):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: /etc/vimrc&#xA;  2: /usr/share/vim/vim74/syntax/syntax.vim&#xA;  3: /usr/share/vim/vim74/syntax/synload.vim&#xA;  4: /usr/share/vim/vim74/syntax/syncolor.vim&#xA;  5: /usr/share/vim/vim74/filetype.vim&#xA;  6: /usr/share/vim/vimfiles/ftdetect/stp.vim&#xA;  7: /usr/share/vim/vim74/ftplugin.vim&#xA;  8: ~/.vimrc&#xA;  9: /usr/share/vim/vim74/syntax/nosyntax.vim&#xA; 10: /usr/share/vim/vim74/ftoff.vim&#xA; 11: ~/.vim/bundle/Vundle.vim/autoload/vundle.vim&#xA; 12: ~/.vim/bundle/Vundle.vim/autoload/vundle/config.vim&#xA; 13: ~/.vim/plugin/acp.vim&#xA; 14: ~/.vim/autoload/acp.vim&#xA; 15: ~/.vim/plugin/plugin/NERD_tree.vim&#xA; 16: ~/.vim/plugin/plugin/clam.vim&#xA; 17: ~/.vim/bundle/vim-fugitive/plugin/fugitive.vim&#xA; 18: ~/.vim/bundle/L9/plugin/l9.vim&#xA; 19: ~/.vim/bundle/L9/autoload/l9.vim&#xA; 20: ~/.vim/bundle/command-t/plugin/command-t.vim&#xA; 21: ~/.vim/bundle/tabular/plugin/Tabular.vim&#xA; 22: /usr/share/vim/vim74/plugin/getscriptPlugin.vim&#xA; 23: /usr/share/vim/vim74/plugin/gzip.vim&#xA; 24: /usr/share/vim/vim74/plugin/logiPat.vim&#xA; 25: /usr/share/vim/vim74/plugin/matchparen.vim&#xA; 26: /usr/share/vim/vim74/plugin/netrwPlugin.vim&#xA; 27: /usr/share/vim/vim74/plugin/rrhelper.vim&#xA; 28: /usr/share/vim/vim74/plugin/spellfile.vim&#xA; 29: /usr/share/vim/vim74/plugin/tarPlugin.vim&#xA; 30: /usr/share/vim/vim74/plugin/tohtml.vim&#xA; 31: /usr/share/vim/vim74/plugin/vimballPlugin.vim&#xA; 32: /usr/share/vim/vim74/plugin/zipPlugin.vim&#xA; 33: ~/.vim/bundle/tabular/after/plugin/TabularMaps.vim&#xA; 34: ~/.vim/bundle/tabular/autoload/tabular.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My config file is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;set background=dark&#xA;set tabstop=3&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'gmarik/Vundle.vim'&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'L9'&#xA;Plugin 'git://git.wincent.com/command-t.git'&#xA;Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}&#xA;Plugin 'godlygeek/tabular'&#xA;Plugin 'plasticboy/vim-markdown'&#xA;call vundle#end()            &quot; required&#xA;ab animr {:&amp;amp;.rollIn}&#xA;ab animm {:&amp;amp;.moveIn}&#xA;ab animz {:&amp;amp;.zoomIn}&#xA;ab animf {:&amp;amp;.fadeIn}&#xA;ab animb {:&amp;amp;.bounceIn}&#xA;ab s[ [slide]&#xA;let g:vim_markdown_folding_disabled = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The version of vim is 7.4 and the Operating System is Fedora 23.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas about this behaviour?&lt;/p&gt;&#xA;" OwnerUserId="6950" LastEditorUserId="6950" LastEditDate="2016-04-18T09:51:33.427" LastActivityDate="2016-04-18T09:51:33.427" Title="vimrc is not the ultimate configuration file" Tags="|vimrc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7394" PostTypeId="2" ParentId="7386" CreationDate="2016-04-18T01:38:22.123" Score="19" Body="&lt;p&gt;As @muru mentioned in the &lt;a href=&quot;https://vi.stackexchange.com/questions/7386/ignoring-diacritics-accents-when-searching#comment12095_7386&quot;&gt;comment&lt;/a&gt;, you could use an equivalence class (described in &lt;code&gt;:help /[[&lt;/code&gt;) which seems to be a character class expression evaluated as a set of similar characters (i.e. are the same once you remove any accent/diacritic).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to look for &lt;code&gt;kočička&lt;/code&gt; and &lt;code&gt;kocicka&lt;/code&gt; with the same pattern, you could use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ko[[=c=]]i[[=c=]]ka&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;[[=c=]]&lt;/code&gt; is the equivalence class for the &lt;code&gt;c&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To automatically insert this character class whenever you hit &lt;code&gt;c&lt;/code&gt; while performing a search, you could use this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; c getcmdtype() =~ '[?/]' ? '[[=c=]]' : 'c'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which can be broken down like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; type the evaluation of an expression&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;getcmdtype() =~ '[?/]'&lt;/code&gt; test whether you're writing a backward or forward search&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'[[=c=]]'&lt;/code&gt; return the equivalence class for the &lt;code&gt;c&lt;/code&gt; character if the previous test succeeded&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'c'&lt;/code&gt; return the &lt;code&gt;c&lt;/code&gt; character otherwise &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The previous mapping has 2 drawbacks:  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;it only covers the &lt;code&gt;c&lt;/code&gt; character&lt;/li&gt;&#xA;&lt;li&gt;it can make the pattern difficult to read&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It could be improved by remapping &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;CR&amp;gt; &amp;lt;C-\&amp;gt;e getcmdtype() =~ '[?/]' ? substitute(getcmdline(), '\a', '[[=\0=]]', 'g'): getcmdline()&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you hit &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; after writing a pattern for a search, the mapping will automatically replace all the alphabetic characters by their equivalence class counterpart.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The mapping for &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is similar to the previous mapping for &lt;code&gt;c&lt;/code&gt;, except it doesn't use the argument &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; but the system mapping &lt;code&gt;&amp;lt;C-\&amp;gt;e&lt;/code&gt;.&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; allows you to insert the evaluation of an expression, while &lt;code&gt;&amp;lt;C-\&amp;gt;e&lt;/code&gt; allows you to replace the whole command line with the evaluation of an expression.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-04-18T12:16:13.947" LastActivityDate="2016-04-18T12:16:13.947" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7395" PostTypeId="2" ParentId="7393" CreationDate="2016-04-18T09:49:25.743" Score="1" Body="&lt;p&gt;The problem is by mistake, I've deleted the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on    &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That line goes right after:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call vundle#end()            &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation from vim documentation about &lt;code&gt;filetype plugin indent&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;You can enable loading the indent file for specific file types with:&#xA;        :filetype indent on&#xA;If filetype detection was not switched on yet, it will be as well.&#xA;This actually loads the file &quot;indent.vim&quot; in 'runtimepath'.&#xA;The result is that when a file is edited its indent file is loaded (if there&#xA;is one for the detected filetype). indent-expression&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2016-04-18T09:49:25.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7396" PostTypeId="1" CreationDate="2016-04-18T09:53:50.897" Score="0" ViewCount="95" Body="&lt;p&gt;If I have file &lt;code&gt;foo.txt&lt;/code&gt; open in a tab&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; tab1&#xA;+------------+------------+&#xA;|            |            |&#xA;|            |            |&#xA;|  file:     | file:      |&#xA;|  foo.txt   | bar.txt    |&#xA;|            |            |&#xA;|            |            |&#xA;+------------+------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then I open another tab using &lt;code&gt;tabe .&lt;/code&gt; the  NERDTree explorer launches, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tab1                               tab 2&#xA;+------------+------------+     +-------------------------+&#xA;|            |            |     |                         |&#xA;|            |            |     | ▸ resources-desktop/    |&#xA;|  file:     | file:      |     | ▸ resources-shared/     |&#xA;|  foo.txt   | bar.txt    |     | ▸ server_v2/            |&#xA;|            |            |     |   .gitignore            |&#xA;|            |            |     |   foo.txt               |&#xA;+------------+------------+     |   bar.txt               |&#xA;                                +-------------------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then using NERDTree in tab2 I navigate to  &lt;code&gt;foo.txt&lt;/code&gt; and select with &lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to happen is this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tab1                               tab 2&#xA;+------------+------------+     +-------------------------+&#xA;|            |            |     |                         |&#xA;|            |            |     |                         |&#xA;|  file:     | file:      |     |                         |&#xA;|  foo.txt   | bar.txt    |     |                         |&#xA;|            |            |     |                         |&#xA;|            |            |     |   foo.txt               |&#xA;+------------+------------+     |                         |&#xA;                                +-------------------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I am getting is no change focus just jumps back to first &lt;code&gt;foo.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tab1                               tab 2&#xA;+------------+------------+     +-------------------------+&#xA;|            |            |     |                         |&#xA;|            |            |     | ▸ resources-desktop/    |&#xA;|  file:     | file:      |     | ▸ resources-shared/     |&#xA;|  foo.txt   | bar.txt    |     | ▸ server_v2/            |&#xA;|            |            |     |   .gitignore            |&#xA;|            |            |     |   foo.txt               |&#xA;+------------+------------+     |   bar.txt               |&#xA;  ^^^^^                         +-------------------------+&#xA;  Focus just &#xA;  goes back here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to open &lt;code&gt;foo.txt&lt;/code&gt; in the 2nd tab/window with NERDTree?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="1821" LastEditDate="2016-04-18T10:02:01.187" LastActivityDate="2016-04-18T14:58:17.727" Title="How can I tell NERDTree to open a file in the current window, even if its open somewhere else?" Tags="|vim-windows|tabbed-user-interface|plugin-nerdtree|" AnswerCount="0" CommentCount="2" ClosedDate="2016-04-19T07:26:09.060" ContentLicense="CC BY-SA 3.0" />
  <row Id="7398" PostTypeId="1" AcceptedAnswerId="7416" CreationDate="2016-04-18T14:47:08.693" Score="1" ViewCount="344" Body="&lt;p&gt;I am using two different keyboard layouts (depending on the computer I use) on the same server (one being AZERTY, the other QWERTY). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to have &quot;conditional&quot; mapping options in my .vimrc file, depending on my layout, something like : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (keyboard_layout == QWERTY)&#xA;    nnoremap : ;&#xA;    nnoremap ; :&#xA;elseif (keyboard_layout == AZERTY)&#xA;    inoremap :w &amp;lt;Esc&amp;gt;:w&amp;lt;Return&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible ? Or is there a &quot;workaround&quot; not too heavy ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(sorry for the syntax, I haven't coded much .vimrc files yet)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;User @statox gave a very complete &lt;a href=&quot;https://vi.stackexchange.com/a/7414/7128&quot;&gt;answer&lt;/a&gt;  based on another question asked, I could not test it because I am not 'root' user on the server I'm working on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found another way through defining a function, that I &lt;a href=&quot;https://vi.stackexchange.com/a/7416/7128&quot;&gt;posted as answer here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-04-20T11:46:59.917" Title="How to deal with several keyboard layouts when accessing a remote server?" Tags="|vimrc|keyboard-layout|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7399" PostTypeId="1" AcceptedAnswerId="7400" CreationDate="2016-04-18T16:04:05.263" Score="40" ViewCount="14551" Body="&lt;p&gt;In my &lt;code&gt;.vimrc&lt;/code&gt; file, I would like to store in a variable the result of an external command, in my case:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ echo $LANG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So that my &lt;code&gt;.vimrc&lt;/code&gt; file would have :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let language = output(!echo $LANG)&#xA;if language == 'en'&#xA;   nnoremap &amp;lt;somekey&amp;gt; &amp;lt;ohanotherkey!&amp;gt;&#xA;end if&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So far I couldn't find how to do it. I've found that in command mode, &lt;code&gt;:read !echo $LANG &lt;/code&gt; would insert in my current file the content I am looking for. But I don't know how to write it down in a &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="1238" LastEditDate="2020-08-10T21:07:35.923" LastActivityDate="2020-08-10T21:07:35.923" Title="Extract the result of a shell command to a variable in a .vimrc file?" Tags="|vimscript|external-command|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7400" PostTypeId="2" ParentId="7399" CreationDate="2016-04-18T16:07:41.613" Score="45" Body="&lt;p&gt;You can do this with the &lt;code&gt;system&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let language = system('echo $LANG')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Bonus point: if your output is a list, you can use the &lt;code&gt;systemlist&lt;/code&gt; instead to get back a list. e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let files = systemlist('ls')&#xA;&quot; ['bin', 'dev', ... ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ref:&lt;/strong&gt; &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#system%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h system&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="205" LastEditDate="2016-04-18T16:38:07.000" LastActivityDate="2016-04-18T16:38:07.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7401" PostTypeId="2" ParentId="7399" CreationDate="2016-04-18T16:36:28.853" Score="17" Body="&lt;p&gt;If &lt;code&gt;LANG&lt;/code&gt; is an environment variable you can just do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let language = $LANG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, even simpler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if $LANG == 'en'&#xA;…&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="177" LastEditDate="2019-10-01T14:37:48.607" LastActivityDate="2019-10-01T14:37:48.607" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7402" PostTypeId="2" ParentId="2044" CreationDate="2016-04-18T19:32:03.837" Score="-1" Body="&lt;p&gt;Using the original vi, hit [n]u to go back n steps.&#xA;To progressively go back step by step...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;hit [n]u to go back n steps&lt;/li&gt;&#xA;&lt;li&gt;then hit [n]u to redo n steps&lt;/li&gt;&#xA;&lt;li&gt;then hit [n+1]u to go back [n+1] steps&lt;/li&gt;&#xA;&lt;li&gt;etc&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7276" LastActivityDate="2016-04-18T19:32:03.837" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7404" PostTypeId="1" CreationDate="2016-04-19T03:08:50.553" Score="1" ViewCount="139" Body="&lt;p&gt;So most of the time I have my standard layout like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9XilV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9XilV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And every now and then I want to open a split in the main buffer using &lt;code&gt;:vsp&lt;/code&gt; and most of the time that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/m7DmL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/m7DmL.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that is what I want but sometimes (particularly if I have been in a project for a while) when I use &lt;code&gt;:vsp&lt;/code&gt; in the main buffer it makes the right hand split bigger than the left and pushing NERDTree off screen like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dtMGX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dtMGX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone experienced this or know of what could be causing this???&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: I have figured out it is fzf.vim causing this with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:fzf_layout = { 'window': 'enew' }&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;enabled, after I perform a search using FZF my splits resize incorrectly.&lt;/p&gt;&#xA;" OwnerUserId="7052" LastEditorUserId="7052" LastEditDate="2016-04-19T05:06:01.400" LastActivityDate="2016-04-19T05:06:01.400" Title=":vsp sometimes making one split bigger than other and hiding NERDTree" Tags="|buffers|vim-windows|neovim|split|plugin-nerdtree|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7405" PostTypeId="2" ParentId="120" CreationDate="2016-04-19T05:59:11.887" Score="1" Body="&lt;p&gt;I use my own plugin &lt;a href=&quot;https://github.com/joeytwiddle/rc_files/blob/master/.vim/plugin/move_until_char_changes.vim&quot; rel=&quot;nofollow&quot;&gt;move_until_char_changes.vim&lt;/a&gt; for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I map it to &lt;code&gt;gK&lt;/code&gt; and &lt;code&gt;gJ&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will jump over many lines with the same character in the current column (not just whitespace), which can be useful in logfiles or SQL dumps with repeated strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default it first moves one line, before picking up the &quot;search&quot; character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works in Visual mode provided you don't try to use it twice, and you aren't in linewise or blockwise Visual mode... (fixes welcome!)&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2016-04-20T03:12:52.400" LastActivityDate="2016-04-20T03:12:52.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7406" PostTypeId="1" AcceptedAnswerId="7428" CreationDate="2016-04-19T06:19:24.103" Score="11" ViewCount="203" Body="&lt;p&gt;I cannot count the number of times I have tried to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set foldmethod=syn^I&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that completion doesn't work on option values!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In some cases options are complex strings where completion might not make sense.  (E.g. &lt;code&gt;'comments'&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But have there been any efforts to provide wildchar-completion for the common use-cases?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, how could I make the example above work?  (Assuming I wanted to complete to one of the strings &lt;code&gt;['manual', 'indent', 'expr', 'marker', 'syntax']&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="205" LastEditDate="2016-04-21T16:34:04.233" LastActivityDate="2023-09-30T17:47:40.797" Title="Auto completion for option values on the cmdline" Tags="|command-line|autocompletion|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7408" PostTypeId="2" ParentId="7406" CreationDate="2016-04-19T08:03:05.040" Score="2" Body="&lt;p&gt;AFAIK, we can't add cmdline-completion to builtin commands that don't provide it. Either we &quot;override&quot; the command with another one that'll support completion (here, you could define &lt;code&gt;:Set&lt;/code&gt; with a capital &lt;code&gt;S&lt;/code&gt;), or we hack into vim source code to add what is missing.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-04-19T08:03:05.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7409" PostTypeId="1" CreationDate="2016-04-19T08:19:56.850" Score="10" ViewCount="670" Body="&lt;p&gt;So I searched the web far and wide and I can not for the life of me figure out how to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following key binding:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;o :below 10sp term://.//$SHELL &amp;lt;cr&amp;gt; :set winfixheight &amp;lt;cr&amp;gt; i&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which works initially and if I open horizontal splits above the &lt;code&gt;:term&lt;/code&gt; but if I open anything below the &lt;code&gt;:term&lt;/code&gt;, &lt;code&gt;fzf&lt;/code&gt; for example the &lt;code&gt;:term&lt;/code&gt; resizes once I close the &lt;code&gt;fzf&lt;/code&gt; window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the above is a bit difficult to understand so I have attached a gif trying to demonstrate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PeaSI.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PeaSI.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7052" LastActivityDate="2016-04-20T14:18:45.030" Title="Persistently fix the height of a split in vim" Tags="|buffers|vim-windows|neovim|split|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7411" PostTypeId="1" AcceptedAnswerId="7412" CreationDate="2016-04-19T10:46:00.220" Score="4" ViewCount="1288" Body="&lt;p&gt;I want to create an abbreviation for  multiple lines. For example, when I type Doc, it has to print a four line text like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;###############&#xA;# function :&#xA;# returns :&#xA;#&#xA;##############&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I tried to do this the first line works, but other lines aren't inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tired with &lt;code&gt;abbr&lt;/code&gt;, &lt;code&gt;iabbr&lt;/code&gt; and &lt;code&gt;imap&lt;/code&gt;. I'm not able to get the desired behavior. I would prefer not to write a function to do that.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="1821" LastEditDate="2016-04-19T11:32:16.277" LastActivityDate="2016-04-19T11:32:16.277" Title="How to create multi-line abbreviations" Tags="|insert-mode|abbreviations|multiple-lines|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7412" PostTypeId="2" ParentId="7411" CreationDate="2016-04-19T10:57:15.413" Score="8" Body="&lt;p&gt;yes, you can do with the &lt;code&gt;^M&lt;/code&gt; character in your abbrev, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev Doc #^M# function :^M#^M# returns :^M#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will be transformed into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#&#xA;# function :&#xA;# &#xA;# returns :&#xA;#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get &lt;code&gt;^M&lt;/code&gt; you need to type &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-04-19T11:06:07.490" LastActivityDate="2016-04-19T11:06:07.490" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7413" PostTypeId="1" AcceptedAnswerId="7415" CreationDate="2016-04-19T12:17:48.527" Score="1" ViewCount="489" Body="&lt;p&gt;I want to create abbreviation for a large word, say &lt;code&gt;configuration&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim command works even if we type part of it. Example, &lt;code&gt;s[ubstitute]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you type &lt;code&gt;s&lt;/code&gt;, &lt;code&gt;su&lt;/code&gt;, &lt;code&gt;sub&lt;/code&gt;, &lt;code&gt;subs&lt;/code&gt;, &lt;code&gt;subst&lt;/code&gt;, &lt;code&gt;substi&lt;/code&gt;, &lt;code&gt;substit&lt;/code&gt;, etc., all these keywords work for the same command &lt;code&gt;substitute&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Likewise, When I type &lt;code&gt;Conf&lt;/code&gt; or &lt;code&gt;Confi&lt;/code&gt; or &lt;code&gt;Config&lt;/code&gt; or &lt;code&gt;Configu&lt;/code&gt;, ...&#xA;It has to expand to the full word. The user has to decide what should be the minimum part. In this case, it is &lt;code&gt;Conf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without writing function or multiple remappings, is there a way to make this work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this way&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:abbr conf[iguration] configuration&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it didn't work.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-04-21T16:31:59.747" LastActivityDate="2016-04-21T16:31:59.747" Title="How do I make abbreviations expand for minimal prefixes?" Tags="|vimscript|autocompletion|abbreviations|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7414" PostTypeId="2" ParentId="7398" CreationDate="2016-04-19T13:14:12.723" Score="2" Body="&lt;p&gt;What I would recommend is the following: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First on your local machine set an environment variable manually containing your layout:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export LAYOUT=AZERTY&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then configure ssh to receive this environment variable (Thanks to &lt;a href=&quot;https://superuser.com/a/702751/386795&quot;&gt;this question&lt;/a&gt; ):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do so use the &lt;code&gt;~/.ssh/config&lt;/code&gt; file and the &lt;code&gt;SendEnv&lt;/code&gt; command. A very basic example would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Host server&#xA;    HostName dev.example.com&#xA;    SendEnc LAYOUT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can then ssh to your server with &lt;code&gt;ssh server&lt;/code&gt;. (There a lot of documentation of ssh config, you can do a lot of stuff with that).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You also have to configure the server to accept this new variable: In &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; add the following line (as root):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AcceptEnv LAYOUT&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finnaly on the server side you can use the answer to &lt;a href=&quot;https://vi.stackexchange.com/q/7399/1841&quot;&gt;this question&lt;/a&gt; to read your variable and make your mappings accordingly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if $LAYOUT == 'AZERTY'&#xA;…&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-04-19T13:14:12.723" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7415" PostTypeId="2" ParentId="7413" CreationDate="2016-04-19T13:16:37.477" Score="5" Body="&lt;p&gt;If you really want to use abbreviations, I'm afraid you'll have to &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;either define one abbreviation for each leading part.&lt;/li&gt;&#xA;&lt;li&gt;or to define a mapping on a trigger like &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; (or whatever) that analyses what is before the cursor in order to expand the missing part. In the end, this is how snippets plugins are expanded (except they are much more advanced)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can also define a dictionary file and use it to explicitly complete text on &lt;code&gt;i_CTRL-X_CTRL-K&lt;/code&gt; (-&gt; &lt;code&gt;:h 'dictionary'&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-04-19T13:16:37.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7416" PostTypeId="2" ParentId="7398" CreationDate="2016-04-19T13:48:51.463" Score="1" Body="&lt;p&gt;I did not  use any &quot;environment&quot; variable, but I coded a function that I call in the .vimrc file :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; The function in my .vimrc file :&#xA;function! Kbdmodes(lang)&#xA;   if a:lang=='en'&#xA;      imap &amp;lt;akey&amp;gt; &amp;lt;anotherkey&amp;gt;&#xA;   elseif a:lang=='fr'&#xA;      imap &amp;lt;yetanotherkey&amp;gt; &amp;lt;iamthefourthkey&amp;gt;&#xA;   endif&#xA;endfunction&#xA;&#xA;let lang='en'&#xA;call Kbdmodes(lang)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far it seems to work. By default, upon starting, vim loads my 'qwerty' (english) bindings ; then if I do &lt;code&gt;:call Kbdmodes('fr')&lt;/code&gt; in normal mode, it switches the bindings to my 'azerty' (french) ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this can be useful to anybody !&lt;/p&gt;&#xA;" OwnerUserId="7128" LastActivityDate="2016-04-19T13:48:51.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7417" PostTypeId="2" ParentId="7413" CreationDate="2016-04-19T14:21:53.350" Score="4" Body="&lt;p&gt;Here is a little function that may help you, because I don't think you can do otherwise:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:ExpandAbbrev(word, start)&#xA;&#xA;  let l:start = a:start&#xA;&#xA;  while l:start &amp;lt; len(a:word)&#xA;    let l:tmp_abb = strpart(a:word, 0, l:start)&#xA;    let l:start += 1&#xA;&#xA;    execute 'iabbrev '.l:tmp_abb.' '.a:word&#xA;  endwhile&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You pass the string you want abbreviations for and the minimal length to be expanded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call &amp;lt;SID&amp;gt;ExpandAbbrev('Configuration', 3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will produce (result of &lt;code&gt;:iabbre&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i  Configuratio  Configuration&#xA;i  Configurati   Configuration&#xA;i  Configurat    Configuration&#xA;i  Configura     Configuration&#xA;i  Configur      Configuration&#xA;i  Configu       Configuration&#xA;i  Config        Configuration&#xA;i  Confi         Configuration&#xA;i  Conf          Configuration&#xA;i  Con           Configuration &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-04-19T14:21:53.350" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7418" PostTypeId="1" AcceptedAnswerId="7419" CreationDate="2016-04-19T15:16:16.837" Score="5" ViewCount="238" Body="&lt;p&gt;When I'm editing my vimrc, if I &lt;code&gt;gg=G&lt;/code&gt; vim autoindents nicely except where &lt;code&gt;augroup&lt;/code&gt; is involved&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I end up with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup movingBackup&#xA;    au!&#xA;    au BufWritePost * call WriteBackupFile(expand(&quot;%:t&quot;), expand(&quot;%:p:h&quot;))&#xA;    augroup end&#xA;&#xA;        augroup dotFile&#xA;            au!&#xA;            au BufWritePost *.dot :silent !start cmd /c &quot;dot -T png %:t &amp;gt; %:r.png&quot;&#xA;            augroup end&#xA;&#xA;                nmap j gj&#xA;                nmap k gk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I really want&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup movingBackup&#xA;    au!&#xA;    au BufWritePost * call WriteBackupFile(expand(&quot;%:t&quot;), expand(&quot;%:p:h&quot;))&#xA;augroup end&#xA;&#xA;augroup dotFile&#xA;    au!&#xA;    au BufWritePost *.dot :silent !start cmd /c &quot;dot -T png %:t &amp;gt; %:r.png&quot;&#xA;augroup end&#xA;&#xA;nmap j gj&#xA;nmap k gk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4543" LastActivityDate="2016-04-19T20:30:06.807" Title="augroup end indentation" Tags="|vimrc|indentation|autocmd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7419" PostTypeId="2" ParentId="7418" CreationDate="2016-04-19T15:23:00.273" Score="7" Body="&lt;p&gt;You should use &lt;code&gt;END&lt;/code&gt; instead of &lt;code&gt;end&lt;/code&gt; for the closing &lt;code&gt;augroup&lt;/code&gt; statement.&lt;/p&gt;&#xA;&lt;p&gt;Apparently it's a bug (cf Carpetsmoker's comment), it should behave the same but it does not. From the documentation (&lt;code&gt;:h :aug&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;                        *:aug* *:augroup*&#xA;:aug[roup] {name}       Define the autocmd group name for the&#xA;                        following &amp;quot;:autocmd&amp;quot; commands.  The name &amp;quot;end&amp;quot;&#xA;                        or &amp;quot;END&amp;quot; selects the default group.&#xA;                        To avoid confusion, the name should be&#xA;                        different from existing {event} names, as this&#xA;                        most likely will not do what you intended.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I opened &lt;a href=&quot;https://github.com/vim/vim/issues/767#issuecomment-212073625&quot; rel=&quot;nofollow noreferrer&quot;&gt;an issue&lt;/a&gt; regarding this question on the vim's github repo, and got an answer:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Although both &amp;quot;end&amp;quot; and &amp;quot;END&amp;quot; work, using &amp;quot;END&amp;quot; is recommended.&lt;/p&gt;&#xA;&lt;p&gt;I'll change the indent script to also accept &amp;quot;end&amp;quot; (negatively) for&#xA;incrementing the indent.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-04-19T20:30:06.807" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7420" PostTypeId="2" ParentId="7306" CreationDate="2016-04-19T18:53:25.680" Score="12" Body="&lt;p&gt;I think I figured it out, although I don't totally understand the fix. This appears to work for mintty, xterm, and rxvt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set up vertical vs block cursor for insert/normal mode&#xA;if &amp;amp;term =~ &quot;screen.&quot;&#xA;    let &amp;amp;t_ti.=&quot;\eP\e[1 q\e\\&quot;&#xA;    let &amp;amp;t_SI.=&quot;\eP\e[5 q\e\\&quot;&#xA;    let &amp;amp;t_EI.=&quot;\eP\e[1 q\e\\&quot;&#xA;    let &amp;amp;t_te.=&quot;\eP\e[0 q\e\\&quot;&#xA;else&#xA;    let &amp;amp;t_ti.=&quot;\&amp;lt;Esc&amp;gt;[1 q&quot;&#xA;    let &amp;amp;t_SI.=&quot;\&amp;lt;Esc&amp;gt;[5 q&quot;&#xA;    let &amp;amp;t_EI.=&quot;\&amp;lt;Esc&amp;gt;[1 q&quot;&#xA;    let &amp;amp;t_te.=&quot;\&amp;lt;Esc&amp;gt;[0 q&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This leans on your screenrc having something like &quot;term screen&quot; or &quot;term screen-256color&quot; so that the vimrc file can identify which terminal you're on. The only remaining terminal I use regularly where this &lt;em&gt;doesn't&lt;/em&gt; work is PuTTY, but I think it literally doesn't support terminal commands to change the cursor shape. Mintty was forked from PuTTY a while back, and I saw here (&lt;a href=&quot;https://www.cygwin.com/ml/cygwin-announce/2009-07/msg00011.html&quot; rel=&quot;noreferrer&quot;&gt;https://www.cygwin.com/ml/cygwin-announce/2009-07/msg00011.html&lt;/a&gt;) that DECSCUSR support was added to mintty after that fork.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is good enough for me - if I'm ssh'ing into a machine where I really want my block cursor in Vim, I guess I can either cygwin/ssh or PuTTY/XMing/rxvt my way through it instead of PuTTY.&lt;/p&gt;&#xA;" OwnerUserId="7203" LastEditorUserId="7203" LastEditDate="2016-04-23T16:25:55.737" LastActivityDate="2016-04-23T16:25:55.737" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7421" PostTypeId="1" AcceptedAnswerId="7426" CreationDate="2016-04-19T19:51:19.050" Score="5" ViewCount="8924" Body="&lt;p&gt;Here is my data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ team: 'NYY', result: 'L', rs: 1,6 },&#xA;{ team: 'NYY', result: 'W', rs: 4,3 },&#xA;{ team: 'NYY', result: 'L', rs: 3,6 },&#xA;{ team: 'NYY', result: 'L', rs: 5,6 },&#xA;{ team: 'NYY', result: 'L', rs: 4,8 },&#xA;{ team: 'NYY', result: 'W', rs: 14,4 },&#xA;{ team: 'NYY', result: 'W', rs: 6,5 },&#xA;{ team: 'NYY', result: 'L', rs: 3,4 },&#xA;{ team: 'NYY', result: 'L', rs: 5,7 },&#xA;{ team: 'NYY', result: 'W', rs: 5,4 },&#xA;{ team: 'NYY', result: 'W', rs: 9,0 },&#xA;{ team: 'NYY', result: 'W', rs: 5,3 },&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to replace the last comma in each line so the line looks like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ team: 'NYY', result: 'L', rs: 1, ra: 6 },&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I use &lt;code&gt;:%s&lt;/code&gt; to accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="7298" LastActivityDate="2021-07-07T17:25:01.540" Title="Replace Nth Occurrence Using Substitute" Tags="|substitute|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7422" PostTypeId="1" AcceptedAnswerId="7432" CreationDate="2016-04-19T20:02:59.183" Score="3" ViewCount="474" Body="&lt;p&gt;How do I align C preprocessor definitions using vim's &lt;a href=&quot;https://github.com/vim-scripts/Align&quot; rel=&quot;nofollow&quot;&gt;Align plugin&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ORING 'r'&#xA;#define OLRING &quot;ring&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the string &lt;code&gt;'r'&lt;/code&gt; should be aligned with &lt;code&gt;&quot;ring&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't find any example like this at &lt;a href=&quot;http://www.drchip.org/astronaut/vim/align.html#Examples&quot; rel=&quot;nofollow&quot;&gt;http://www.drchip.org/astronaut/vim/align.html#Examples&lt;/a&gt; they all use a separator like &lt;code&gt;=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried &lt;code&gt;:Align \tsp&lt;/code&gt; which might work because it aligns on whitespaces, but nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="6078" LastEditorUserId="1841" LastEditDate="2016-04-20T07:31:20.220" LastActivityDate="2016-04-20T07:37:25.663" Title="Align C preprocessor definitions" Tags="|alignment|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7423" PostTypeId="2" ParentId="7421" CreationDate="2016-04-19T20:33:20.357" Score="6" Body="&lt;p&gt;Using &lt;code&gt;\ze&lt;/code&gt; makes this pretty easy. Just match the end of the line so digit followed by ending curly bracket.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;%s/\ze\d\+ }/ ra: /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;\ze&lt;/code&gt; sets the end of the matched area. For more help see &lt;code&gt;:h /\zs&lt;/code&gt; &amp;amp; &lt;code&gt;:h \ze&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2021-07-07T17:25:01.540" LastActivityDate="2021-07-07T17:25:01.540" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7425" PostTypeId="1" CreationDate="2016-04-19T21:00:21.840" Score="0" ViewCount="582" Body="&lt;p&gt;I am still using Sublime Text a lot more than vim and when using vim, I use it directly from within my terminal for small tasks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to make the next step and jump purely to vim and had a look at the graphical vim (in my current case macvim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use sublime I, I can simply open a folder and everything is loaded.&#xA;How do you guys use the graphical vim quickly and open whole projects?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are your workflows?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that this is a pretty subjective questions, probably with no real definite answer. Anyway I am thankful for all the input I am receiving to get me started and prepared for the vim world!&lt;/p&gt;&#xA;" OwnerUserId="5674" LastEditorUserId="5674" LastEditDate="2016-04-20T15:53:37.717" LastActivityDate="2016-10-24T14:33:23.573" Title="Graphical vim: Workflows" Tags="|gvim|" AnswerCount="3" CommentCount="1" ClosedDate="2016-04-20T20:10:12.437" ContentLicense="CC BY-SA 3.0" />
  <row Id="7426" PostTypeId="2" ParentId="7421" CreationDate="2016-04-19T22:12:33.987" Score="12" Body="&lt;p&gt;Peter's answer achieves the result that you want, but not necessarily the question that you asked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This regular expression will match the Nth occurrence of your PATTERN:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(.\{-}\zsPATTERN\)\{N}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To unpack that a little bit, it matches everything non-greedily (that's what the {-} is) though each PATTERN N times (that's what the {N} is)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The \zs marks the start of what you want to replace. In the example above, you would end up replacing the comma with whatever your replacement text is. You could put the \zs after the pattern to add your replacement after the comma.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give a more concrete example with your data, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\(.\{-},\zs\)\{3}/ ra: /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would add in the text after the third comma.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, this doesn't really seem to be the best approach for this particular problem. Here, you could insert your &quot;ra&quot; in between any comma followed by a digit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/,\zs\ze\d/ ra: /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or use a macro to find the Nth occurrence and insert:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3f,a ra:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or use Tabular to align your commas, and then do a block select (ctrl+v) to insert your text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Tab /,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;" OwnerUserId="1155" LastActivityDate="2016-04-19T22:12:33.987" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7427" PostTypeId="1" AcceptedAnswerId="7437" CreationDate="2016-04-20T00:16:01.033" Score="4" ViewCount="218" Body="&lt;p&gt;It seems that mappings with &lt;code&gt;@=&quot;^E&quot;&lt;/code&gt; or &lt;code&gt;@=&quot;&amp;lt;c-e&amp;gt;&quot;&lt;/code&gt; result in &lt;code&gt;@=&quot;&quot;&lt;/code&gt; and do nothing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example if I use &lt;code&gt;nnoremap ^N @=&quot;^E&quot;^M&lt;/code&gt; then press &lt;kbd&gt;ctrl-n&lt;/kbd&gt; I will get a &lt;code&gt;@=&quot;&quot;&lt;/code&gt; message and nothing happens. However, when I use &lt;code&gt;nnoremap ^N @=&quot;^Y&quot;^M&lt;/code&gt; then press &lt;kbd&gt;ctrl-n&lt;/kbd&gt; I receive a &lt;code&gt;@=&quot;^Y&quot;&lt;/code&gt; message and the screen scrolls down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should also mention that if I enter &lt;code&gt;@=&quot;^E&quot;^M&lt;/code&gt; manually, -- and not as a mapping -- it works just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify I want to know how to pass &lt;code&gt;&amp;lt;c-e&amp;gt;&lt;/code&gt; into the expression register because I want to be able to use it in repeatable mappings. Such as &lt;code&gt;nnoremap &amp;lt;c-p&amp;gt; @=&quot;&amp;lt;c-e&amp;gt;j&quot;&lt;/code&gt; to scroll the window and move cursor down n lines.&lt;/p&gt;&#xA;" OwnerUserId="7166" LastEditorUserId="7166" LastEditDate="2016-04-20T19:03:32.973" LastActivityDate="2020-05-14T02:55:18.690" Title="Mappings with @=&quot;^E&quot; result in @=&quot;&quot; and do nothing" Tags="|vimrc|key-bindings|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7428" PostTypeId="2" ParentId="7406" CreationDate="2016-04-20T01:02:19.573" Score="3" Body="&lt;p&gt;You could try the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:option_values = {'foldmethod'  : ['manual', 'indent', 'expr', 'marker', 'syntax'],&#xA;                     \ 'bufhidden'   : ['hide', 'unload', 'delete', 'wipe'],&#xA;                     \ 'virtualedit' : ['block', 'insert', 'all', 'onemore'] ,}&#xA;&#xA;set wildcharm=&amp;lt;c-z&amp;gt;&#xA;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;tab&amp;gt;&#xA;            \ getcmdline() !~# '^\s*set\s\+\w\+=' &amp;lt;bar&amp;gt;&amp;lt;bar&amp;gt; wildmenumode() ?&#xA;            \ '&amp;lt;c-z&amp;gt;' :&#xA;            \ '&amp;lt;c-u&amp;gt;' . substitute(getcmdline(), 'set', 'Set', '') . '&amp;lt;c-z&amp;gt;'&#xA;&#xA;command! -nargs=1 -complete=customlist,s:SetComplete Set exe 'set' &amp;lt;q-args&amp;gt;&#xA;&#xA;function! s:SetComplete(A, L, P) abort&#xA;    let option = matchstr(a:A, '^.*\ze=')&#xA;    if !has_key(s:option_values, option)&#xA;        return&#xA;    endif&#xA;    let candidates = copy(s:option_values[option])&#xA;    call map(candidates, 'option . &quot;=&quot; . v:val')&#xA;    return filter(candidates, 'v:val =~ &quot;^&quot; . a:A')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It first defines a dictionary &lt;code&gt;s:option_values&lt;/code&gt; whose purpose is to contain your options (as its keys) and their values (as its values which are lists).  Here, as an example, 3 options + values are stored:&lt;br&gt;&#xA;&lt;code&gt;'foldmethod'&lt;/code&gt;, &lt;code&gt;'bufhidden'&lt;/code&gt;, &lt;code&gt;'virtualedit'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildcharm=&amp;lt;c-z&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line sets the &lt;code&gt;'wildcharm'&lt;/code&gt; option and tells Vim that if it sees &lt;code&gt;&amp;lt;c-z&amp;gt;&lt;/code&gt; in a mapping it must activate the wildmenu. Without setting this option, if you write &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; in a mapping, it will simply insert a literal tab character.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Begin the definition of a mapping which will type the evaluation of an expression whenever you hit &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; on the command-line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\ getcmdline() !~# '^\s*set\s\+\w\+=' &amp;lt;bar&amp;gt;&amp;lt;bar&amp;gt; wildmenumode() ?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mapping tests if the command-line matches the pattern &lt;code&gt;^\s*set\s\+\w\+=&lt;/code&gt;, which is a line following the form &lt;code&gt;set option=&lt;/code&gt;, or if the wildmenu is active.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\ '&amp;lt;c-z&amp;gt;' :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the previous test succeeds, the mapping activates the wildmenu.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\ '&amp;lt;c-u&amp;gt;' . substitute(getcmdline(), 'set', 'Set', '') . '&amp;lt;c-z&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Otherwise, it replaces the system command &lt;code&gt;:set&lt;/code&gt; with the custom command &lt;code&gt;:Set&lt;/code&gt;, and activates the wildmenu.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=customlist,s:SetComplete Set exe 'set' &amp;lt;q-args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Define the custom command &lt;code&gt;:Set&lt;/code&gt; which does the same thing as &lt;code&gt;:set&lt;/code&gt;, except it can use a custom completion function whose name is here &lt;code&gt;s:SetComplete()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:SetComplete(A, L, P) abort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Begin the definition of the custom completion function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It must return suggestions/candidates through a list.&lt;br&gt;&#xA;The &lt;code&gt;:Set&lt;/code&gt; command will automatically send 3 arguments to it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the leading portion of the argument currently being completed on (i.e. &lt;code&gt;option=...&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;the entire command line&lt;/li&gt;&#xA;&lt;li&gt;the cursor position in it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h :command-completion-customlist&lt;/code&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let option = matchstr(a:A, '^.*\ze=')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Extract the name of the option from the argument being completed on.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !has_key(s:option_values, option)&#xA;    return&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check whether &lt;code&gt;option&lt;/code&gt; is in your dictionary. If it's not, the function doesn't return anything.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let candidates = copy(s:option_values[option])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Get a copy of the list of values that the option can take from your dictionary.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call map(candidates, 'option . &quot;=&quot; . v:val')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For each value in the list &lt;code&gt;candidates&lt;/code&gt;, prepend the string &lt;code&gt;option=&lt;/code&gt; (where &lt;code&gt;option&lt;/code&gt; will be evaluated).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return filter(candidates, 'v:val =~ &quot;^&quot; . a:A')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Remove the items from &lt;code&gt;candidates&lt;/code&gt; whose beginning don't match the argument being completed on, and return the result.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-04-20T01:02:19.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7429" PostTypeId="2" ParentId="7425" CreationDate="2016-04-20T01:59:42.357" Score="3" Body="&lt;p&gt;Vim is a text editor not an IDE. Having said that vim is highly configurable, and can be customized per individual and usually is, but can be used as an IDE. (there are purists out there too) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim can be customized to do more with plugins, and the all mighty &lt;code&gt;.vimrc&lt;/code&gt; file. &#xA;This leads to very individualized vim experiences and no two vims are identical (well, at least for very long).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But most setups follow along this general structure:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A Plugin manager of your choosing (pathogen, Plug, vundle, etc) or install plugins manually&lt;/li&gt;&#xA;&lt;li&gt;A plugin for the file tree (NERDTree)&lt;/li&gt;&#xA;&lt;li&gt;A plugin for language specific syntax highlighting (not always needed, default syntax highlighter is pretty good)&lt;/li&gt;&#xA;&lt;li&gt;A plugin for auto-completion (omni-complete)&lt;/li&gt;&#xA;&lt;li&gt;A plugin for file search (ctrlp)&lt;/li&gt;&#xA;&lt;li&gt;any other plugin that you feel is necessary to complete your tasks&lt;/li&gt;&#xA;&lt;li&gt;all fine tuning can be done in your &lt;code&gt;~/.vimrc&lt;/code&gt; file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The suggestions above are not the only ones that exist but are the ones that I use / have used, you should find ones that suite your needs best&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are trying to start using vim as your main editor the path I would take is the following: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use vim as is... figure out what you actually need&lt;/li&gt;&#xA;&lt;li&gt;RTFM on vim and its config file, and see if what you want can be easily achieved via a few simple mappings.&lt;/li&gt;&#xA;&lt;li&gt;If a simple mapping cant handle it search for a plugin to do what you need and install it.&lt;/li&gt;&#xA;&lt;li&gt;If you find that you are downloading a lot of plugins then get a plugin manager&lt;/li&gt;&#xA;&lt;li&gt;Repeat steps 1-3 as needed&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you are too lazy to do 1-5, or just want something now&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) google &lt;code&gt;vim dotfiles&lt;/code&gt;  or dotfiles projects&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) google setups like &lt;code&gt;spf13&lt;/code&gt;, &lt;code&gt;dotvim&lt;/code&gt;, &lt;code&gt;janus&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;c) then trim the fat.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; A good rule of thumb to follow while editing your vimrc: Don't put anything in your vimrc you don't understand. This helps for several reasons to list a few though:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;keeps you safe&lt;/li&gt;&#xA;&lt;li&gt;helps to keep your vimrc lean&lt;/li&gt;&#xA;&lt;li&gt;keeps you educated&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A good place to start can be found &lt;a href=&quot;http://vim.wikia.com/wiki/Use_Vim_like_an_IDE&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7254" LastEditorUserId="7254" LastEditDate="2016-10-24T14:33:23.573" LastActivityDate="2016-10-24T14:33:23.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7430" PostTypeId="2" ParentId="7425" CreationDate="2016-04-20T04:46:53.667" Score="1" Body="&lt;p&gt;I think what you're looking for is sessions.  &lt;code&gt;:help :mksession&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;a href=&quot;https://github.com/tpope/vim-obsession&quot; rel=&quot;nofollow&quot;&gt;vim-obsession&lt;/a&gt; to auto load sessions when I enter a directory.  I don't know how it would work with gvim, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Peter mentioned, Vim has no concept of &quot;projects&quot;.  But, I would argue that the concept of a &quot;project&quot; is very subjective.  My idea of a project is any directory that has the &lt;code&gt;.git&lt;/code&gt; directory in it.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-04-20T04:46:53.667" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7431" PostTypeId="2" ParentId="7425" CreationDate="2016-04-20T05:30:35.167" Score="0" Body="&lt;p&gt;Vim doesn't know what a &quot;project&quot; is but it knows what the &quot;current directory&quot; is and that's usually enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, the current directory is the directory in which you started Vim.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you started the MacVim GUI by double-clicking on the icon or via Spotlight or whatever launcher, the current directory is &lt;code&gt;$HOME&lt;/code&gt;. You will need to &lt;code&gt;:cd&lt;/code&gt; to the right directory.&lt;/li&gt;&#xA;&lt;li&gt;If you double-clicked on a file associated with MacVim or used the &quot;Open with…&quot; contextual menu, the current directory is the directory containing your file, which may or may not be what you want. You will also probably need to &lt;code&gt;:cd&lt;/code&gt; at some time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;FWIW, the behavior is the same on all platforms with all GUI front ends, which are all after-thoughts, really. Vim is first and foremost designed for the shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, I've used &lt;a href=&quot;http://blog.shinyfrog.net/2008/06/07/finder-droplets-mac-editors/&quot; rel=&quot;nofollow&quot;&gt;this droplet&lt;/a&gt; for years, now, to start Vim from the finder with the right &quot;current directory&quot;. The effect is the same as &lt;code&gt;$ vim .&lt;/code&gt; in your shell, which is AFAIK the closest equivalent to Sublime's behavior.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-20T05:30:35.167" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7432" PostTypeId="2" ParentId="7422" CreationDate="2016-04-20T07:29:20.117" Score="4" Body="&lt;p&gt;You can use &lt;code&gt;:&amp;lt;range&amp;gt;Align \s&lt;/code&gt; which will use the white spaces as separators. It will give you the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define   ORING    'r'&#xA;#define   OLRING   &quot;ring&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To align only the part between the quotes you can use: &lt;code&gt;:&amp;lt;range&amp;gt;Align \('\|&quot;\).*&lt;/code&gt; which means &lt;em&gt;&quot;align starting on &lt;code&gt;'&lt;/code&gt; or &lt;code&gt;&quot;&lt;/code&gt; and all characters following it&quot;&lt;/em&gt;. This gives the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ORING  'r'     &#xA;#define OLRING &quot;ring&quot;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-20T07:37:25.663" LastActivityDate="2016-04-20T07:37:25.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7433" PostTypeId="1" AcceptedAnswerId="7440" CreationDate="2016-04-20T07:49:38.773" Score="3" ViewCount="338" Body="&lt;p&gt;Tabnew works when the filename is given directly.&#xA;I want to open a file using Its alias since the file is far away from the current file path and difficult to remember or type.  I use alias command for files in .cshrc file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# .cshrc&#xA;Alias abs vim /project/userid/trees/soft/abs.pl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In shell command line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/userid&amp;gt; abs&#xA;# -&amp;gt; Vim opens the file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, &#xA;I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabnew !abs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It opens a file named &lt;code&gt;!abs&lt;/code&gt; instead of original file.&#xA;Is there a way to combine commands using pipe or something like that, so that this filename is returned and &lt;code&gt;tabnew&lt;/code&gt; opens it?&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="1821" LastEditDate="2016-04-20T08:17:13.983" LastActivityDate="2016-04-21T03:22:25.697" Title="Open a filename given by an external command" Tags="|command-line|tabbed-user-interface|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7434" PostTypeId="2" ParentId="7427" CreationDate="2016-04-20T07:59:58.493" Score="3" Body="&lt;p&gt;I think you're not using the good way to do what you want:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The expression register (&lt;code&gt;&quot;=&lt;/code&gt;) is a way to evaluate an expression but what you are trying to use (&lt;kbd&gt;Ctrl-E&lt;/kbd&gt;) is simply a normal mode command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a in a normal mode mapping you can simply use it directly with &lt;code&gt;:nnoremap &amp;lt;C-n&amp;gt; &amp;lt;C-e&amp;gt;&lt;/code&gt; (or &lt;code&gt;:nnoremap &amp;lt;C-n&amp;gt; &amp;lt;C-y&amp;gt;&lt;/code&gt; or whatever). You don't need to consider that as an expression to be executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally speaking I don't think it is a good idea to use the expression register since it adds complexity to your mapping whereas you often have an other solution to do what you're trying to do.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-20T08:15:00.657" LastActivityDate="2016-04-20T08:15:00.657" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7435" PostTypeId="2" ParentId="7433" CreationDate="2016-04-20T08:26:59.707" Score="2" Body="&lt;p&gt;Using a pipeline solves the problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabnew | !abs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Opens the file through alias.&#xA;Similarly, you can use any system command and open the same way.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabnew | !perl a.pl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="1821" LastEditDate="2016-04-20T08:30:45.450" LastActivityDate="2016-04-20T08:30:45.450" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7436" PostTypeId="2" ParentId="7368" CreationDate="2016-04-20T12:09:50.250" Score="7" Body="&lt;p&gt;Thanks for the answer by Lngo. I've my answer posted bellow. &#xA;I just put these in my &lt;code&gt;~/.vimrc&lt;/code&gt; file:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;alphsubs ---------------------- {{{&#xA;        execute &quot;digraphs ks &quot; . 0x2096 &#xA;        execute &quot;digraphs as &quot; . 0x2090&#xA;        execute &quot;digraphs es &quot; . 0x2091&#xA;        execute &quot;digraphs hs &quot; . 0x2095&#xA;        execute &quot;digraphs is &quot; . 0x1D62&#xA;        execute &quot;digraphs ks &quot; . 0x2096&#xA;        execute &quot;digraphs ls &quot; . 0x2097&#xA;        execute &quot;digraphs ms &quot; . 0x2098&#xA;        execute &quot;digraphs ns &quot; . 0x2099&#xA;        execute &quot;digraphs os &quot; . 0x2092&#xA;        execute &quot;digraphs ps &quot; . 0x209A&#xA;        execute &quot;digraphs rs &quot; . 0x1D63&#xA;        execute &quot;digraphs ss &quot; . 0x209B&#xA;        execute &quot;digraphs ts &quot; . 0x209C&#xA;        execute &quot;digraphs us &quot; . 0x1D64&#xA;        execute &quot;digraphs vs &quot; . 0x1D65&#xA;        execute &quot;digraphs xs &quot; . 0x2093&#xA;&quot;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I get &lt;code&gt;&amp;lt;ctrl-k&amp;gt;[alphabet]s&lt;/code&gt; a shortcut for what I want. In the same way of thinking I can do that for all superscripts. I got all the unicode from that aforementioned repository.  &lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="1821" LastEditDate="2016-04-20T13:36:49.433" LastActivityDate="2016-04-20T13:36:49.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7437" PostTypeId="2" ParentId="7427" CreationDate="2016-04-20T12:56:44.433" Score="7" Body="&lt;p&gt;From &lt;code&gt;:help c_ctrl-e&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-E or &amp;lt;End&amp;gt;                 *c_CTRL-E* *c_&amp;lt;End&amp;gt;* *c_End*&#xA;                cursor to end of command-line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In command-line mode, &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; moves the cursor to the end of the line, and when you are inside the expression register &lt;code&gt;=&lt;/code&gt;, you are on the command-line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, when you hit &lt;code&gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; in normal mode, here's what Vim does:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;type &lt;code&gt;@=&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;move the cursor to the end of the command-line (it's already at the end anyway) because of &lt;code&gt;^E&lt;/code&gt; ; it doesn't insert the character &lt;code&gt;^E&lt;/code&gt; because the latter was interpreted as a motion&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;&quot;^M&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the end, it's as if you had typed: &lt;code&gt;@=&quot;&quot;&lt;/code&gt;, which is an empty string.  So, Vim doesn't execute anything.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would work if there was something in the string, for example if you type &lt;code&gt;@=&quot;dd&quot;&lt;/code&gt; in normal mode, it will delete the current line. But here, there's nothing left in the string, because &lt;code&gt;^E&lt;/code&gt; was interpreted as a motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this reason, you can't use &lt;code&gt;^E&lt;/code&gt; in your mapping.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your mapping works for &lt;code&gt;^Y&lt;/code&gt; because of this (&lt;code&gt;:help c_ctrl-y&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-Y      When there is a modeless selection, copy the selection into&#xA;            the clipboard. |modeless-selection|&#xA;            If there is no selection CTRL-Y is inserted as a character.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Like &lt;code&gt;^E&lt;/code&gt;, &lt;code&gt;^Y&lt;/code&gt; is associated with an action on the command-line. But not if there is no selection.&lt;br&gt;&#xA;In this case, contrary to &lt;code&gt;^E&lt;/code&gt;, it simply inserts a literal control character.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Depending on the context, there are various ways to write a control character like &lt;code&gt;^E&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^E&lt;/code&gt; (&lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Ctrl-E&lt;/kbd&gt;) to insert it on the command-line or in a buffer&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-E&amp;gt;&lt;/code&gt; in a mapping&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;\&amp;lt;C-E&amp;gt;&quot;&lt;/code&gt; in a string&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;\&amp;lt;lt&amp;gt;C-E&amp;gt;&quot;&lt;/code&gt; in a string read by a mapping command such as &lt;code&gt;:nnoremap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, if for some reason you really wanted to use the expression register (maybe because you wanted to create a &lt;a href=&quot;http://vimcasts.org/episodes/creating-mappings-that-accept-a-count/&quot; rel=&quot;nofollow noreferrer&quot;&gt;mapping&lt;/a&gt; accepting a count), you could use &lt;code&gt;&quot;\&amp;lt;lt&amp;gt;C-E&amp;gt;&quot;&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ^N @=&quot;\&amp;lt;lt&amp;gt;C-E&amp;gt;&quot;^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this mapping, 2 translations occur at different times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, when your &lt;code&gt;:nnoremap&lt;/code&gt; command is executed and add an entry in the mappings table, the keycode &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt; is translated as the character &lt;code&gt;&amp;lt;&lt;/code&gt;, and the resulting string is &lt;code&gt;&quot;\&amp;lt;C-E&amp;gt;&quot;&lt;/code&gt;.&lt;br&gt;&#xA;Then, when you hit &lt;code&gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; in normal mode, the string &lt;code&gt;&quot;\&amp;lt;C-E&amp;gt;&quot;&lt;/code&gt; is translated into the control character &lt;code&gt;^E&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The keycode &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt; is necessary to protect &lt;code&gt;&amp;lt;C-E&amp;gt;&lt;/code&gt; from being automatically translated into a literal control character when &lt;code&gt;:nnoremap&lt;/code&gt; is executed.&lt;br&gt;&#xA;If you don't protect &lt;code&gt;&amp;lt;C-E&amp;gt;&lt;/code&gt; with &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt;, the same problem as before will repeat; &lt;code&gt;^E&lt;/code&gt; will be intepreted as a motion on the command-line instead of a character to insert.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="17449" LastEditDate="2020-05-14T02:55:18.690" LastActivityDate="2020-05-14T02:55:18.690" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7438" PostTypeId="1" AcceptedAnswerId="7444" CreationDate="2016-04-20T14:05:33.313" Score="4" ViewCount="571" Body="&lt;p&gt;I am trying to debug the &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;vim-fugitive&lt;/code&gt;&lt;/a&gt; plugin, to dig into how it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I develop a piece of vim script, I am used to testing a function with the &lt;code&gt;debug&lt;/code&gt; command. Here it does not work because the function I try to access is not in the current scope.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;debug execute &amp;lt;SID&amp;gt;StageDiff('Gdiff')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But there is a mapping that call this function inside the plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; D :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gdiff')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;debug norm! D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get the following error (after a &lt;code&gt;step&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E21: Cannot make changes, 'modifiable' is off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess it's because the context of the &lt;code&gt;D&lt;/code&gt; is the debugger's window, so it's not modifiable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question is:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do you know a way to debug an external function?&lt;/li&gt;&#xA;&lt;li&gt;&lt;s&gt;How can the &lt;code&gt;debug norm! ...&lt;/code&gt; keep the focus on the current file, instead of jumping to the debug window?&lt;/s&gt; (see comments need to use &lt;code&gt;norm&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="51" LastEditDate="2016-07-21T17:32:58.423" LastActivityDate="2016-07-21T17:32:58.423" Title="How to debug an external function" Tags="|key-bindings|vimscript|functions|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7440" PostTypeId="2" ParentId="7433" CreationDate="2016-04-20T15:10:23.840" Score="6" Body="&lt;p&gt;From &lt;code&gt;:help backtick-expansion&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                    *backtick-expansion* *`-expansion*&#xA;On Unix and a few other systems you can also use backticks for the file name&#xA;argument, for example: &amp;gt;&#xA;    :next `find . -name ver\\*.c -print`&#xA;    :view `ls -t *.patch  \| head -n1`&#xA;The backslashes before the star are required to prevent the shell from&#xA;expanding &quot;ver*.c&quot; prior to execution of the find program.  The backslash&#xA;before the shell pipe symbol &quot;|&quot; prevents Vim from parsing it as command&#xA;termination.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, if you want to edit a filename given by the output of a shell command, you could write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabe `your shell command`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim should open the file given by the output of your shell command in a new tab.&lt;br&gt;&#xA;Note that if your shell command contains a pipe, it must be escaped to prevent Vim from parsing it as a command termination.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Besides, I'm not sure, but I think that if the output contains special characters, it won't work as expected and you will have the error &lt;code&gt;E79: Cannot expand wildcards&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, not sure, but I suspect it's because after getting the output of the shell command, if Vim sees some special characters, it tries to perform an expansion on them but sometimes the pattern can be illegal (see &lt;code&gt;:h e79&lt;/code&gt; for more information).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, &lt;code&gt;:help `=&lt;/code&gt; might help you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *`=*&#xA;You can have the backticks expanded as a Vim expression, instead of as an&#xA;external command, by putting an equal sign right after the first backtick,&#xA;e.g.: &amp;gt;&#xA;    :e `=tempname()`&#xA;The expression can contain just about anything, thus this can also be used to&#xA;avoid the special meaning of '&quot;', '|', '%' and '#'.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This syntax seems more reliable, maybe because Vim doesn't perform any expansion after evaluating the expression which follows the &lt;code&gt;=&lt;/code&gt; sign.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, you could also write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabe `=system('your shell command')`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that with this 2nd syntax, you don't need to escape a pipe character.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;However, as @muru &lt;a href=&quot;https://vi.stackexchange.com/questions/7433/open-a-filename-given-by-an-external-command#comment12175_7433&quot;&gt;explained&lt;/a&gt;, I don't think that what you are trying to achieve is possible, because no matter the syntax you use, your shell alias &lt;code&gt;abs&lt;/code&gt; doesn't echo the path to a file, it simply launches a new Vim session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But maybe you could export an environment variable in a file sourced by your shell like &lt;code&gt;~/.bashrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export ABS=/project/userid/trees/soft/abs.pl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then type in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabe $ABS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the session was launched from the shell, Vim should know the environment variable and expand automatically &lt;code&gt;$ABS&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another working case is given in your last &lt;a href=&quot;https://vi.stackexchange.com/questions/7433/open-a-filename-given-by-an-external-command#comment12172_7435&quot;&gt;comment&lt;/a&gt;: you want to open the file given by the shell command &lt;code&gt;ls -1 | tail -1&lt;/code&gt; in a new tab.&#xA;You could achieve this with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabe `ls -1 \| tail -1`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabe `=system('ls -1 | tail -1')`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-04-21T03:22:25.697" LastActivityDate="2016-04-21T03:22:25.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7441" PostTypeId="1" AcceptedAnswerId="7442" CreationDate="2016-04-20T15:58:57.953" Score="8" ViewCount="495" Body="&lt;p&gt;I am currently coding fortran, and I have huge &quot;subprograms&quot; (called &quot;&lt;em&gt;subroutine&lt;/em&gt;&quot; in fortran). So I would like the name of the current subroutine (the subprogram my cursor is currently in) to be displayed in my statusline. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what a subroutine looks like in fortran (this should make my trick clearer):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subroutine my_subprogram(args)&#xA;   stuff going on &#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found the following trick, currently in my .vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SubName()&#xA;   let current_line = line(&quot;.&quot;)  &quot; I store the current line number &#xA;   ?subroutine                   &quot; searches the previous occurence of &quot;subroutine&quot;&#xA;   let title_line = line(&quot;.&quot;)    &quot; stores the line where the subroutine title is&#xA;   execute &quot;:&quot;.title_line        &quot; go to the line where the title is&#xA;   normal! eeb                   &quot; put the cursor on the 2nd word :  &quot;my_subprogram&quot;&#xA;   let sub_name = expand(&quot;&amp;lt;cword&amp;gt;&quot;) &quot; extract the subroutine name in a variable&#xA;   execute &quot;:&quot;.current_line      &quot; come back to the initial position&#xA;   return sub_name&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I put the function in my statusline and it works &lt;em&gt;almost&lt;/em&gt; fine : the name is displayed but... &lt;strong&gt;I cant do &lt;code&gt;/&lt;/code&gt; searches anymore !&lt;/strong&gt; It highlights found text but I can't scroll to the next occurences of the pattern I'm looking for. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess this might be because the function is permanently called and thus Vim permanently performs researches because of the &lt;code&gt;?subroutine&lt;/code&gt; line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This is my first time trying to vimscript, so there are probably some ugly things there that you may want to correct -- please do not hesitate !)&lt;/p&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="4472" LastEditDate="2017-09-25T16:13:37.850" LastActivityDate="2017-09-25T16:13:37.850" Title="Display current subroutine/subprogram in statusline" Tags="|vimscript|statusline|filetype-fortran|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7442" PostTypeId="2" ParentId="7441" CreationDate="2016-04-20T16:58:56.043" Score="8" Body="&lt;p&gt;You could try the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SubName() abort&#xA;    let prev_sub_line_num = search('subroutine ', 'bcnW')&#xA;    return matchstr(getline(prev_sub_line_num), 'subroutine \zs\w\+')&#xA;endfunction&#xA;&#xA;set stl+=%{SubName()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let prev_sub_line_num = search('subroutine ', 'bcnW')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Call the &lt;code&gt;search()&lt;/code&gt; function to look for the pattern &lt;code&gt;subroutine&lt;/code&gt;.&lt;br&gt;&#xA;In the 2nd argument, 4 flags are passed to &lt;code&gt;search()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;b&lt;/code&gt; look backward instead of forward&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;c&lt;/code&gt; accept a match at current cursor position&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt; don't move the cursor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;W&lt;/code&gt; don't wrap around the end of the file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;search()&lt;/code&gt; returns the number of the line where the previous &lt;code&gt;subroutine&lt;/code&gt; text is found.&lt;br&gt;&#xA;This number is stored in the variable &lt;code&gt;prev_sub_line_num&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return matchstr(getline(prev_sub_line_num), 'subroutine \zs\w\+')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, &lt;code&gt;matchstr()&lt;/code&gt; is called, which looks for the pattern &lt;code&gt;subroutine \zs\w\+&lt;/code&gt; inside the contents of the line &lt;code&gt;prev_sub_line_num&lt;/code&gt;, and returns the matching text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2 arguments are passed to &lt;code&gt;matchstr()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;getline(prev_sub_line_num)&lt;/code&gt; which gets the contents of the previous line where &lt;code&gt;subroutine&lt;/code&gt; was found&lt;/li&gt;&#xA;&lt;li&gt;the pattern &lt;code&gt;subroutine \zs\w\+&lt;/code&gt; which matches the word (&lt;code&gt;\w\+&lt;/code&gt;) just after the text &lt;code&gt;subroutine&lt;/code&gt;. In a regex, &lt;code&gt;\zs&lt;/code&gt; allows you to set the start of a match. Here, it allows you to get rid of &lt;code&gt;subroutine&lt;/code&gt;, even though it's inside the pattern.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that the contents of the statusline including the expression &lt;code&gt;SubName()&lt;/code&gt; will be evaluated on every screen update, which could slow Vim down.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-04-20T17:22:00.403" LastActivityDate="2016-04-20T17:22:00.403" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7443" PostTypeId="2" ParentId="120" CreationDate="2016-04-20T17:21:39.733" Score="3" Body="&lt;p&gt;Since I don't see it here as an answer (&lt;strong&gt;edit&lt;/strong&gt; just noticed that &lt;strong&gt;superjer&lt;/strong&gt; mentioned something very similar). You can simply the / or ? search. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you can search downward for a non whitespace character in the 2nd column like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\%2v\S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The breakdown is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/    &quot;search downward (use ? for upward movement)&#xA;\%2v &quot;for the following char in the 2nd virtual column&#xA;\S   &quot;any non white space character&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can use the normal operators to repeat the search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info on the subject see &lt;code&gt;:help \%c&lt;/code&gt; and &lt;code&gt;:help \%v&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7166" LastEditorUserId="7166" LastEditDate="2016-04-20T18:15:59.037" LastActivityDate="2016-04-20T18:15:59.037" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7444" PostTypeId="2" ParentId="7438" CreationDate="2016-04-20T17:29:18.443" Score="2" Body="&lt;p&gt;Regarding the debugging of a script function, this is extremely tricky: you need to build the exact internal name of the function. Once you have that name you could use it to call the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alas, it isn't that easy to obtain it. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First you need to know the related script number (&lt;code&gt;:scriptnames&lt;/code&gt; may help), &lt;/li&gt;&#xA;&lt;li&gt;then inject that number in a function name generator that'll generate the sequence &lt;code&gt;&amp;lt;SNR&amp;gt;&lt;/code&gt;+thenumber+&lt;code&gt;_&lt;/code&gt;+functionname that can be used with &lt;code&gt;function()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My advice? Either debug these functions from the mapping they are meant to be executed from, or expose them through autoload plugins when you are their author.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-04-21T07:50:16.967" LastActivityDate="2016-04-21T07:50:16.967" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7445" PostTypeId="1" CreationDate="2016-04-20T17:32:43.863" Score="3" ViewCount="738" Body="&lt;p&gt;In html eruby files, I would like to highlight the &lt;code&gt;&amp;lt;% ... %&amp;gt;&lt;/code&gt; text in dark green only when it is inside double quotes. I.e. in in this example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mFbhb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mFbhb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want it dark green instead of white.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that &lt;code&gt;&amp;lt;% ... %&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;%= ... %&amp;gt;&lt;/code&gt; are respectively defined as &lt;code&gt;erubyBlock&lt;/code&gt; and &lt;code&gt;erubyExpression&lt;/code&gt; in terms of syntax highlighting. I could highlight them with &lt;code&gt;hi erubyBlock guifg=...&lt;/code&gt; etc, but I would like to do so only when they are inside double quotes (which have the &lt;code&gt;htmlString&lt;/code&gt; syntax definition).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically I would like to do something like &lt;code&gt;hi htmlString&amp;gt;erubyBlock guifg=...&lt;/code&gt; (if this syntax existed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried looking at the Vim help but could not find anything. Is there a way to do this?&lt;/p&gt;&#xA;" OwnerUserId="7318" LastEditorUserId="7318" LastEditDate="2016-04-20T17:37:49.173" LastActivityDate="2016-04-20T21:54:58.963" Title="Nested highlighting" Tags="|syntax-highlighting|filetype-html|filetype-ruby|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7446" PostTypeId="2" ParentId="7445" CreationDate="2016-04-20T20:38:13.903" Score="4" Body="&lt;p&gt;Ok, this is probably not the best solution because it is pretty invasive. But, it's all I could come up with so I will give it to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing we can do is basically manually do the highlighting ourselves. So we could easily do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   syn match quotedErubyBlock '&quot;&amp;lt;%.\{-}%&amp;gt;&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will define a new highlighting section that matches &lt;code&gt;&quot;&amp;lt;%&lt;/code&gt; followed by any text, followed by &lt;code&gt;%&amp;gt;&quot;&lt;/code&gt;. This should get us what we want, but the problem with this is that it will only affect strings that are not contained in any other syntax region. Clearly in your example this is going to show up in an htmlTag region, and so we need to get a bit more complicated. What I've come up with is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost *.html syn match quotedErubyBlock '&quot;&amp;lt;%.\{-}%&amp;gt;&quot;' contained&#xA;autocmd BufReadPost *.html syn region  htmlTag start=+&amp;lt;[^/]+   end=+&amp;gt;+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,quotedErubyBlock,@htmlPreproc,@htmlArgCluster&#xA;autocmd BufReadPost *.html hi link quotedErubyBlock Constant&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ok, that's a lot to swallow. Let's go through it.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The first line defines our new highlighting section &lt;code&gt;quotedErubyBlock&lt;/code&gt; and also specifies that it will be &lt;em&gt;contained&lt;/em&gt; in some other region.&lt;/li&gt;&#xA;&lt;li&gt;The next line is the invasive part. I've stolen this line from vim's &lt;code&gt;html.vim&lt;/code&gt; file. Basically we are &lt;em&gt;redefining&lt;/em&gt; what an htmlTag is. The only thing I changed is I added our &lt;code&gt;quotedErubyBlock&lt;/code&gt; to the &lt;code&gt;contains=&lt;/code&gt; list. This way vim can &quot;see&quot; our new highlighting section &lt;em&gt;within&lt;/em&gt; an htmlTag block.&lt;/li&gt;&#xA;&lt;li&gt;This line just tells vim what color to highlight our new section with. I've put &lt;code&gt;Constant&lt;/code&gt; because I think that will give you what you are looking for, but feel free to change it to whatever works best for you.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As a last note, the &lt;code&gt;autocmd BufReadPost *.html&lt;/code&gt; is an autocommand that will do our highlighting whenever a file is loaded with the extension &lt;code&gt;html&lt;/code&gt;. I'm not very familiar with eruby, so you may need to change this if that is not the proper filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;http://vim.wikia.com/wiki/Creating_your_own_syntax_files&quot; rel=&quot;nofollow&quot;&gt;vimwiki's page on creating your own syntax file&lt;/a&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-04-20T21:54:58.963" LastActivityDate="2016-04-20T21:54:58.963" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7447" PostTypeId="1" AcceptedAnswerId="7448" CreationDate="2016-04-20T22:32:55.490" Score="1" ViewCount="2987" Body="&lt;p&gt;I noticed 3 problems with my Vim terminal setup on Ubuntu which can be illustrated by the following picture of my current Vim. I get the same look with a lot of airline-themes (e.g. molokai, jellybeans, dark, etc.)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/XA0rI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XA0rI.png&quot; alt=&quot;current Vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first problem is that I'd like to have colors with my status bar which are clearly not appearing.&lt;/li&gt;&#xA;&lt;li&gt;Also I don't know if the symbols of the status bar are correct, because the arrows do not look like the ones shown below.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ZjcvA.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZjcvA.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Finally the upper bar indicating the buffers or the tabs clearly do not look like mine.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also, here are some potentially useful informations&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I installed the powerline patched Mac OS font Monaco. This helped me to replace some weird symbols and get the ones shown above.&lt;/li&gt;&#xA;&lt;li&gt;The only airline theme that was different was base16.&lt;/li&gt;&#xA;&lt;li&gt;I tried changing the Vim colorscheme to different ones, but it didn't solve anything.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Finally here is a copy of my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=utf8&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'&#xA;call vundle#begin()&#xA;&#xA;Plugin 'gmarik/Vundle.vim'&#xA;Plugin 'https://github.com/Valloric/YouCompleteMe.git'&#xA;Plugin 'https://github.com/scrooloose/nerdtree.git'&#xA;Plugin 'https://github.com/tpope/vim-surround.git'&#xA;Plugin 'https://github.com/terryma/vim-multiple-cursors.git'&#xA;&#xA;Plugin 'dkprice/vim-easygrep'&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;Plugin 'MarcWeber/vim-addon-mw-utils'&#xA;Plugin 'tomtom/tlib_vim'&#xA;Plugin 'garbas/vim-snipmate'&#xA;&#xA;&quot; Optional:&#xA;Plugin 'honza/vim-snippets'&#xA;&#xA;call vundle#end()&#xA;&#xA;filetype plugin indent on&#xA;filetype plugin on&#xA;filetype indent on&#xA;syntax on&#xA;&#xA;&quot; air-line&#xA;let g:airline_powerline_fonts = 1&#xA;&#xA;&quot;highlight Pmenu ctermfg=15 ctermbg=4 guifg=#ffffff guibg=#0000ff&#xA;&#xA;let g:ycm_show_diagnostics_ui = 1&#xA;let g:ycm_enable_diagnostic_highlighting = 0&#xA;set number&#xA;set autochdir&#xA;set ruler&#xA;set ts=4&#xA;set expandtab&#xA;set shiftwidth=4&#xA;set cursorline&#xA;set showmatch&#xA;set ignorecase&#xA;set showcmd&#xA;set list listchars=tab:\ \ ,trail:·&#xA;&quot; set timeoutlen = 200&#xA;set nofoldenable&#xA;set wildmode=full&#xA;set laststatus=2&#xA;set completeopt-=preview&#xA;&#xA;map &amp;lt;Tab&amp;gt; &amp;lt;C-W&amp;gt;W&#xA;nnoremap &amp;lt;F5&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;:nmap &amp;lt;F3&amp;gt; :vimgrep //j ** &amp;lt;bar&amp;gt; copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If more information is needed to solve these problems, I'll gladly provide it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; I solved the first two problems by putting 'set t_Co=256' in my .vimrc, but the upper bar is still the same is it normal?&lt;/p&gt;&#xA;" OwnerUserId="7320" LastEditorUserId="7320" LastEditDate="2016-04-21T21:02:31.830" LastActivityDate="2016-04-21T21:02:31.830" Title="Problem with color, symbols and upper bar using airline with Vim in terminal" Tags="|terminal|statusline|plugin-airline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7448" PostTypeId="2" ParentId="7447" CreationDate="2016-04-20T22:54:11.330" Score="3" Body="&lt;p&gt;I solved the first two problems by putting the &lt;code&gt;set t_Co=256&lt;/code&gt; in my .vimrc and solved the missing upper bar problem by putting this in my .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline#extensions#tabline#enabled = 1&#xA;&quot; Show just the filename&#xA;let g:airline#extensions#tabline#fnamemod = ':t'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7320" LastActivityDate="2016-04-20T22:54:11.330" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7449" PostTypeId="1" CreationDate="2016-04-21T01:41:23.723" Score="1" ViewCount="948" Body="&lt;p&gt;I'm testing out using vim with tmux. One thing that I could do with vim with a split window is yank text from one buffer and paste it into the other. This no longer works when I have vim buffers in different panes. Any idea how to get this working?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm working on Mac Terminal (El Capitan) over SSH into a Linux box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt; And it does not look like my version of vim has the &lt;code&gt;+clipboard&lt;/code&gt; feature compiled into it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; This is not a duplicate question as this is specifically about using tmux with vim. I want to be able to issue a &lt;code&gt;yy&lt;/code&gt; command like I usually do in one vim pane in tmux and &lt;code&gt;p&lt;/code&gt; it into another vim pane in tmux.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="205" LastEditDate="2016-04-21T16:35:51.157" LastActivityDate="2017-11-15T15:03:40.830" Title="How can I use tmux for copying if I can't access the system clipboard?" Tags="|cut-copy-paste|tmux|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7450" PostTypeId="1" AcceptedAnswerId="7456" CreationDate="2016-04-21T03:03:36.010" Score="16" ViewCount="3443" Body="&lt;p&gt;I have a file that has decided to scroll synchronously when I open it in a second window and start scrolling. &lt;code&gt;scrollbind&lt;/code&gt; and &lt;code&gt;diff&lt;/code&gt; are set to &lt;code&gt;off&lt;/code&gt;. (&lt;code&gt;:set scrollbind?&lt;/code&gt; prints &lt;code&gt;noscrollbind&lt;/code&gt; and &lt;code&gt;:set diff?&lt;/code&gt; prints &lt;code&gt;nodiff&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What else can I try?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using neovim.&lt;/p&gt;&#xA;" OwnerUserId="268" LastEditorUserId="1821" LastEditDate="2016-04-21T10:47:55.493" LastActivityDate="2016-04-21T13:07:53.750" Title="Turn off synchronous scrolling not caused by either scrollbind or diff" Tags="|neovim|vimdiff|scrolling|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="7453" PostTypeId="1" AcceptedAnswerId="7454" CreationDate="2016-04-21T09:12:32.843" Score="2" ViewCount="11624" Body="&lt;p&gt;I am using perl.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I press &lt;code&gt;gf&lt;/code&gt; while having the cursor on Testcase, it shows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E447: Can't find file &quot;Testcase.pm&quot; in path. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I added that path. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works for files under particular path which are set in &lt;code&gt;:set path&lt;/code&gt;. I have several libraries under subdirectories of lib folder.  &lt;code&gt;/project/tester/userid/SCOPE/infra/lib&lt;/code&gt; is the path. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I give all the paths, &lt;code&gt;gf&lt;/code&gt; is able to find it. Is there a way to include all subdirectories of a path recursively or making it work for all subdirectories even with the given path?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will help me to go to any library file without needing to know the path or greping every time.  There are more than 100 such files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Setting like &lt;code&gt;set path=$PROJ/lib/**&lt;/code&gt; doesn't work in .vimrc and plugins too. But when I give this command in current script file, it works. My .vimrc is under &lt;code&gt;/home/userid&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="1821" LastEditDate="2016-04-21T13:55:47.630" LastActivityDate="2016-04-25T05:17:20.653" Title="Access a file under subdirectories of a path through gf command" Tags="|vimrc|command-line|path|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7454" PostTypeId="2" ParentId="7453" CreationDate="2016-04-21T09:21:41.007" Score="8" Body="&lt;p&gt;You can add &lt;code&gt;**&lt;/code&gt; to your path:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path+=**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way it will find every file recursively based on your current directory.&#xA;But apparently &lt;a href=&quot;https://twitter.com/tpope/status/612991667751264256&quot; rel=&quot;noreferrer&quot;&gt;it's not recommended&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to add other paths, you can just add them as follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path+=/path/to/your/lib&#xA;set path+=c:/include&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-04-21T09:31:52.433" LastActivityDate="2016-04-21T09:31:52.433" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="7455" PostTypeId="2" ParentId="7438" CreationDate="2016-04-21T10:43:49.600" Score="2" Body="&lt;p&gt;This is not an answer to the question, as Luc Hermitte already answered it, but a development on his answer. I created a little piece of vimscript that try to generate the full name of a funciton:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:GetFunctionFullName(plugin_name, function_name)&#xA;  let l:scriptnames = []&#xA;&#xA;  &quot; save previous content of register a&#xA;  let l:a = @a&#xA;&#xA;  &quot; capture the scriptname output in register a&#xA;  redir @a&#xA;  silent scriptnames&#xA;  redir END&#xA;  &quot; split by new line&#xA;  let l:scriptnames = split(@a, '\n')&#xA;&#xA;  &quot; restore register a&#xA;  let @a = l:a&#xA;&#xA;  &quot; Filter the scriptnames with the plugin name / path&#xA;  call filter(l:scriptnames, 'v:val =~ &quot;'.a:plugin_name.'&quot;')&#xA;&#xA;  &quot; Accept only one answer&#xA;  if len(l:scriptnames) != 1&#xA;    echoerr(&quot;Please specify an existing unique filepath&quot;)&#xA;    echomsg(&quot;Your current result is:&quot;. l:scriptnames)&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; Get the script number&#xA;  let l:scriptnumber = substitute(&#xA;        \ split(l:scriptnames[0])[0],&#xA;        \  ':', '', '')&#xA;&#xA;  &quot; Return the function full name&#xA;  return '&amp;lt;SNR&amp;gt;'.l:scriptnumber.'_'.a:function_name.'()'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-04-21T10:43:49.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7456" PostTypeId="2" ParentId="7450" CreationDate="2016-04-21T13:07:53.750" Score="20" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/7450/turn-off-synchronous-scrolling-not-caused-by-either-scrollbind-or-diff#comment12220_7450&quot;&gt;Christian Brabandt suggested in a comment&lt;/a&gt;, this can be caused by the &lt;code&gt;'cursorbind'&lt;/code&gt; setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help 'cursorbind'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When this option is set, as the cursor in the current&#xA;  window moves other cursorbound windows (windows that also have&#xA;  this option set) move their cursors to the corresponding line and&#xA;  column.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:verbose set cursorbind?&lt;/code&gt; to find out what is switching this setting on.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2016-04-21T13:07:53.750" CommentCount="0" CommunityOwnedDate="2016-04-21T13:07:53.750" ContentLicense="CC BY-SA 3.0" />
  <row Id="7457" PostTypeId="1" AcceptedAnswerId="7458" CreationDate="2016-04-21T16:10:06.620" Score="15" ViewCount="43699" Body="&lt;p&gt;I am a frequent user of the Vim editor on Linux and now I want to use it on Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I downloaded Vim for Windows, which happens to be gVim. Several features of Vim doesn't work in gVim 7.4 like visual block, &lt;code&gt;rx&lt;/code&gt; command, and several other key combinations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want the same/original Vim from Linux to be used on Windows. Is that version available for Windows too? Or, can I use settings similar to the Unix format?&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="51" LastEditDate="2018-10-22T23:32:25.727" LastActivityDate="2021-02-11T16:23:47.770" Title="How can I get gVim on Windows to behave as on Linux?" Tags="|gvim|microsoft-windows|" AnswerCount="4" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7458" PostTypeId="2" ParentId="7457" CreationDate="2016-04-22T07:36:48.687" Score="14" Body="&lt;p&gt;When I have to work on Windows (which is more often than I would like), I use Cygwin to get a terminal a little less crappy than the original Windows command line. Cygwin provides an environment which tries to be close to a Bash console with standard Linux commands, and of course it is far from being flawless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;http://www.cygwin.com/&quot; rel=&quot;noreferrer&quot;&gt;project page&lt;/a&gt; of Cygwin. During the installation you'll end on a window allowing you to choose which packages you want to install. The search bar allows to look for packages to install, among other useful stuff (like &lt;code&gt;git&lt;/code&gt;, &lt;code&gt;tmux&lt;/code&gt;, &lt;code&gt;curl&lt;/code&gt;, &lt;code&gt;wget&lt;/code&gt;, etc.) you can type &lt;code&gt;vim&lt;/code&gt; and select packages like &lt;code&gt;vim&lt;/code&gt;, &lt;code&gt;vim-common&lt;/code&gt;, &lt;code&gt;vim-doc&lt;/code&gt;, &lt;code&gt;gvim&lt;/code&gt;. This will install a Vim editor pretty close to what you're used to on Linux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once everything is installed (which can sometimes be a little long) you'll be able to start Cygwin which will show a terminal, and you'll be able to start Vim as usual and use your Linux &lt;code&gt;.vimrc&lt;/code&gt; and your usual plugin manager. The main drawback is the compatibility of colors which often needs to be tweaked and still look crappy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; that I use Cygwin out of habit, but other solutions (like &lt;a href=&quot;http://cmder.net/&quot; rel=&quot;noreferrer&quot;&gt;cmder&lt;/a&gt; for example) exist. None of them are flawless, so you might want to try several and find your favorite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Also note&lt;/strong&gt; that &lt;a href=&quot;https://mintty.github.io/&quot; rel=&quot;noreferrer&quot;&gt;mintty&lt;/a&gt; is a good way to make Cygwin a little less crappy.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="927" LastEditDate="2017-08-30T09:17:01.353" LastActivityDate="2017-08-30T09:17:01.353" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7459" PostTypeId="1" AcceptedAnswerId="7460" CreationDate="2016-04-22T07:46:57.990" Score="12" ViewCount="5856" Body="&lt;p&gt;When we execute any system command and get the output, it prints in next line. But I want it in current line, next to the cursor or in place of cursor (not at the start of the current line)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r! ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Prints the list of files in the current folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this prints the output in next line. Is there any way to print the output in the current line, next to the cursor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some example situations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;listing of files inside quotes&lt;/li&gt;&#xA;&lt;li&gt;executing a perl/external program and getting its output pasted here.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-04-23T16:18:20.553" LastActivityDate="2016-04-23T16:18:20.553" Title="How do I insert the output of an external command at the cursor position?" Tags="|command-line|insert-mode|external-command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7460" PostTypeId="2" ParentId="7459" CreationDate="2016-04-22T07:50:25.360" Score="7" Body="&lt;p&gt;One can execute any external command in command line using the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#system%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;system&lt;/code&gt;&lt;/a&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a = system(&quot;ls -ltr&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when you want to paste, press &lt;kbd&gt;Ctrl+R&lt;/kbd&gt; and immediately &lt;kbd&gt;a&lt;/kbd&gt; to paste the content next to cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;@a&lt;/code&gt; is the register name. You can use whatever register you want.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-04-23T16:18:05.973" LastActivityDate="2016-04-23T16:18:05.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7461" PostTypeId="1" AcceptedAnswerId="7462" CreationDate="2016-04-22T08:55:13.403" Score="1" ViewCount="4576" Body="&lt;p&gt;I'm having some trouble to enable C/C++ completion with deoplete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know what plugins I should really install and how to configure deoplete to work with them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read that for C/C++ completion vim-marching is recommanded, but is it a plugin that would feed deoplete or a completion plugin on itself?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vim-marching documentation, it says that it requires vim-proc, also and I see some configurations with neocomplete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shougo plugins are like an ecosystem with interdependencies and excuse my poor ignorance but I really don't understand who does what, even after reading the (not always explicit) github pages and documentations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone would have the kindness to explains me how to configure C/C++ completion with Shougo's plugins I would really be grateful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My configuration for deoplete is:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:deoplete#enable_at_startup = 0&#xA;if !exists('g:deoplete#omni#input_patterns')&#xA;  let g:deoplete#omni#input_patterns = {}&#xA;endif &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried it because I got a lot of error at first without it, and now if I disable that configuration I get `Option 'omnifunc' is not set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Whith clang_complete I tried this:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:clang_complete_auto = 0&#xA;let g:clang_auto_select = 0&#xA;let g:clang_default_keymappings = -1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6078" LastEditorUserId="6078" LastEditDate="2016-04-22T11:03:10.783" LastActivityDate="2016-04-22T12:13:27.223" Title="Need help for setting up completion for C/C++ with deoplete and neovim" Tags="|autocompletion|neovim|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7462" PostTypeId="2" ParentId="7461" CreationDate="2016-04-22T12:13:27.223" Score="3" Body="&lt;p&gt;The problem came from the python support in neovim, plugins like clang_complete and deoplete needs python support.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check if python is supported, &lt;code&gt;:echo has('python')&lt;/code&gt; should print 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it prints 0, you need to install the python library python-neovim with &lt;code&gt;pip&lt;/code&gt; or you're distribution's package manager if a package exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Archlinux and packages exists, there is two packages: &lt;code&gt;python-neovim&lt;/code&gt; and &lt;code&gt;python2-neovim&lt;/code&gt;, the first one being for Python3 and the latter for Python2. For me &lt;strong&gt;both packages needed to be installed&lt;/strong&gt; to enable Python support, and that is where the problem came from.&lt;/p&gt;&#xA;" OwnerUserId="6078" LastActivityDate="2016-04-22T12:13:27.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7463" PostTypeId="1" CreationDate="2016-04-22T13:00:39.467" Score="3" ViewCount="174" Body="&lt;p&gt;I often need to insert the same text into a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My approach has been to put the text into my vimrc as a variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let map='&amp;lt;!DOCTYPE map PUBLIC &quot;-//OASIS//DTD DITA Map//EN&quot; &quot;map.dtd&quot;&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then insert it with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt;, =map &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;em&gt;works&lt;/em&gt; but it somehow feels wrong. It also prevents me from entering long, multiline snippets. Is there a better way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I'm open to a solution that uses a plugin, but I'm using an older version of Vim that's missing python and a few other features. I'd prefer a simple solution.&lt;/p&gt;&#xA;" OwnerUserId="3264" LastEditorUserId="205" LastEditDate="2016-04-24T18:07:48.443" LastActivityDate="2016-04-24T18:07:48.443" Title="Good method for saving and inserting commonly used snippets" Tags="|cut-copy-paste|snippets|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7464" PostTypeId="1" AcceptedAnswerId="7909" CreationDate="2016-04-22T14:27:17.440" Score="5" ViewCount="898" Body="&lt;p&gt;I'm on Ubuntu 16.04 (x86_64) and vim 7.4. In &lt;a href=&quot;https://gist.github.com/ShabbyX/3691170&quot; rel=&quot;nofollow&quot;&gt;my config file&lt;/a&gt;, I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autochdir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this was working for as long as I remember. Just after upgrading to Ubuntu 16.04, I see the following behavior (assume &lt;code&gt;pwd&lt;/code&gt; is &lt;code&gt;/path&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The following commands (&lt;code&gt;z&lt;/code&gt; is a file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim X/Y/z&#xA;:e .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;result in vim showing the contents of &lt;code&gt;/path&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim X/Y/z&#xA;:sp .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;result in vim showing the contents of &lt;code&gt;/path/X/Y&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim X/Y/z&#xA;:sp .&#xA;:q&#xA;:e .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;also result in vim showing the contents of &lt;code&gt;/path/X/Y&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The expected behavior for me was for all three cases to open &lt;code&gt;/path/X/Y&lt;/code&gt;. But it seems like &lt;code&gt;:sp&lt;/code&gt; is changing the current directory, but &lt;code&gt;:e&lt;/code&gt; is not. Before my upgrade to Ubuntu 16.04, I am sure all three cases did the same thing (open &lt;code&gt;/path/X/Y&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody else reproduce this? Is this intended behavior and documented?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Additionally, if I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim X/Y/z&#xA;:sp ./&amp;lt;TAB&amp;gt;          --or--&#xA;:e ./&amp;lt;TAB&amp;gt;           --or--&#xA;:w ./&amp;lt;TAB&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then vim iterates through the items in the &lt;code&gt;X&lt;/code&gt; directory, not &lt;code&gt;X/Y&lt;/code&gt;. Although if I do &lt;code&gt;:sp ./X/w&lt;/code&gt; where &lt;code&gt;X&lt;/code&gt; and &lt;code&gt;w&lt;/code&gt; were selected using &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; (i.e. vim finds the items based on the current directory), the file is not actually opened (an empty new file is opened, as if the file doesn't exist). This suggests that &lt;code&gt;autochdir&lt;/code&gt; has worked where opening the file is concerned, but hasn't worked where listing directory items is concerned.&lt;/p&gt;&#xA;" OwnerUserId="850" LastEditorUserId="205" LastEditDate="2016-05-03T08:15:24.610" LastActivityDate="2017-01-30T16:44:55.897" Title="autochdir working with :sp but not :e?" Tags="|command-line|working-directory|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7465" PostTypeId="2" ParentId="7463" CreationDate="2016-04-22T14:31:32.007" Score="4" Body="&lt;p&gt;I came across a solution that suits me well, it may be useful for you also. I add some mappings/abbreviations in insert mode starting with &lt;code&gt;\&lt;/code&gt; (or any character you like, and use not all the time): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; use an abbreviation (css debugging)&#xA;iabbrev \r *{color: red !important;}&#xA;&#xA;&quot; use a mapping (html doctype insertion)&#xA;inoremap \doctype &amp;lt;!DOCTYPE map PUBLIC &quot;-//OASIS//DTD DITA Map//EN&quot; &quot;map.dtd&quot;&amp;gt;&#xA;&#xA;&quot; if you want to keep cursor inside tag, use a mapping also&#xA;inoremap \td   &amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&quot; some more mappings&#xA;&#xA;&quot; if you used a mapping starting with \ make sure you can actually type \&#xA;inoremap \\ \&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The major down point of this is that the mappings you define can overlap other actual words you may want to use, but on the other side you can create a lot of mappings without use of any external plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed that mapping are not displayed while typed, but you can display them with &lt;code&gt;:set showcmd&lt;/code&gt; (thanks to a &lt;a href=&quot;https://vi.stackexchange.com/users/6698/jair-lopez&quot;&gt;jair lopez&lt;/a&gt; comment)&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-04-22T21:10:42.007" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7466" PostTypeId="1" CreationDate="2016-04-22T15:46:45.303" Score="50" ViewCount="31748" Body="&lt;p&gt;There is a great number of snippets plugins for vim: &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;noreferrer&quot;&gt;ultisnips&lt;/a&gt;, &lt;a href=&quot;https://github.com/msanders/snipmate.vim&quot; rel=&quot;noreferrer&quot;&gt;snipmate&lt;/a&gt;, &lt;a href=&quot;https://github.com/drmingdrmer/xptemplate&quot; rel=&quot;noreferrer&quot;&gt;xptemplate&lt;/a&gt;, &lt;a href=&quot;https://github.com/Shougo/neosnippet.vim&quot; rel=&quot;noreferrer&quot;&gt;neosnippet&lt;/a&gt; and a lot more.&lt;/p&gt;&#xA;&lt;p&gt;They all have pros and cons and more or less dependencies. So far I've been using ultisnips but never been totally satisfied with it.&lt;/p&gt;&#xA;&lt;p&gt;As we have a very interesting and complete question about &lt;a href=&quot;https://vi.stackexchange.com/q/388/1841&quot;&gt;plugin managers&lt;/a&gt; I think it would be pretty useful to have the same kind of explanations about snippets plugins.&lt;/p&gt;&#xA;&lt;p&gt;There is a listing &lt;a href=&quot;http://vim.wikia.com/wiki/Snippet_Plugin_Comparison&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; which could be a good start but some complete, clear and precise answers from our community would be pretty useful.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="7933" LastEditDate="2022-03-21T08:26:23.407" LastActivityDate="2022-03-21T08:26:23.407" Title="What is the difference between the vim snippets plugins?" Tags="|plugin-ultisnips|snippets|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="7467" PostTypeId="2" ParentId="7466" CreationDate="2016-04-22T17:04:00.513" Score="13" Body="&lt;p&gt;Here is a list of features from &lt;a href=&quot;https://github.com/LucHermitte/mu-template&quot; rel=&quot;noreferrer&quot;&gt;mu-template&lt;/a&gt;. Discl.: I'm its maintainer.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Template-files can be expanded:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;automatically when opening a new buffer (unless deactivated from the .vimrc),&lt;/li&gt;&#xA;&lt;li&gt;explicitly through menus or the command line,&lt;/li&gt;&#xA;&lt;li&gt;from the INSERT-mode in a snippet-like fashion ;&lt;/li&gt;&#xA;&lt;li&gt;from the VISUAL-mode to surround the selection with a snippet -- the surrounding may be applied to different zones in the snippet (e.g. code or condition zones in a &lt;code&gt;while&lt;/code&gt; control-statement) ;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;All snippets are defined in their own template-file -- all other snippet engines use one file per filetype and put all snippets in it ;&lt;/li&gt;&#xA;&lt;li&gt;The template-files can be overridden by the user, or in the context of a specific project ;&lt;/li&gt;&#xA;&lt;li&gt;Filetype specific snippets can be defined for the INSERT-mode (they can be inherited, e.g. C snippets can be used from C++, Java, etc.), the list of matching snippets will be presented with a hint for each snippet ;&lt;/li&gt;&#xA;&lt;li&gt;Computed VimL expressions can be inserted ;&lt;/li&gt;&#xA;&lt;li&gt;VimL instructions can be executed during the expansion -- I use it to automatically add missing includes or import statements ;&lt;/li&gt;&#xA;&lt;li&gt;Template-files can include other template-files in a function-like manner (parameters are even supported) -- AFAIK, very few snippet engines implement this, they aren't even able to support snippet aliases, which is trivial to implement thanks to this feature ;&lt;/li&gt;&#xA;&lt;li&gt;Fully integrated with my placeholders-system ;&lt;/li&gt;&#xA;&lt;li&gt;Supports re-indentation (if desired), and Python indentation ;&lt;/li&gt;&#xA;&lt;li&gt;Works well with vim folding ;&lt;/li&gt;&#xA;&lt;li&gt;I18n friendly ;&lt;/li&gt;&#xA;&lt;li&gt;When several snippets match, an advanced completion menu pops up (it has been inspired by YouCompleteMe popup menu) ;&lt;/li&gt;&#xA;&lt;li&gt;Style options are applied automatically (how do you prefer your brackets? &lt;code&gt;if (...) {\n}&lt;/code&gt;? &lt;code&gt;if (...)\n{\n}&lt;/code&gt;? Something else?), and of course, they can be fine tuned depending on the current project, or the current filetype, or even both ;&lt;/li&gt;&#xA;&lt;li&gt;The plugin is 100% VimL. Python could be used from the template file though.&lt;/li&gt;&#xA;&lt;li&gt;mu-template depends on two library plugins (lh-vim-lib and lh-dev), and on my placeholder system (lh-brackets) -- that's why I recommend to install it with VAM or VimFlavor as I provide the files that declare the dependencies ;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The licence is compatible with code generation -- that means that while mu-template code is under GPLv3, the snippets aren't, you can use them in proprietary code: some snippets are under Boost Software Licence though;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The expansion happens after any local vimrcs present are loaded -- in order to set project-specific variables before the expansion is done.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Thanks to Tom Link's StakeHolders plugin, µTemplate does have tied placeholders (modifying one named placeholder modifies other placeholders with the same name). Not installing Stakeholders will not prevent you from using µTemplate.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To be perfectly honest, the template syntax is a little bit cumbersome, and the placeholder system belongs to the first placeholders generation -- mu-template is one of the oldest template/snippets engine for Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the fact it permits snippets to include other snippets (conditionally, and with parameters) which may or may not be overridden is quite important. Typical applications are &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;the C++ file template &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;which includes a file header (usually fine tuned differently for each project in order to include the right copyright notice)&lt;/li&gt;&#xA;&lt;li&gt;then load the template best fit for the current type of file (.h, .cpp, or unit test file)&lt;/li&gt;&#xA;&lt;li&gt;&lt;ul&gt;&#xA;&lt;li&gt;in header-file case, anti-reinclusion guards will be included -- the way they are computed may be overridden (again to follow project policies)&lt;/li&gt;&#xA;&lt;li&gt;in .cpp files case, the matching .h file is automatically included if found&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I have a generic class snippet/wizard in lh-cpp. And &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp/blob/master/doc/snippets.md#class-patterns&quot; rel=&quot;noreferrer&quot;&gt;several specialized class kinds&lt;/a&gt; that use this common class template, but with different parameters.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-10-23T09:11:00.860" LastActivityDate="2016-10-23T09:11:00.860" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7468" PostTypeId="2" ParentId="7466" CreationDate="2016-04-22T18:54:39.870" Score="22" Body="&lt;p&gt;I've been using the original &lt;a href=&quot;https://github.com/msanders/snipmate.vim&quot; rel=&quot;noreferrer&quot;&gt;SnipMate&lt;/a&gt; since I started using Vim.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It doesn't have external dependencies.&lt;/li&gt;&#xA;&lt;li&gt;It uses a very simple syntax.&lt;/li&gt;&#xA;&lt;li&gt;It is very easy to set up.&lt;/li&gt;&#xA;&lt;li&gt;It has been abandoned since 2009.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have nothing to complain about.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-22T18:54:39.870" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="7470" PostTypeId="1" AcceptedAnswerId="7471" CreationDate="2016-04-22T22:25:06.253" Score="7" ViewCount="52242" Body="&lt;p&gt;I have installed YouCompleteMe with Clang completer in OS X 10.10.4, and in my new OS X 10.11.4 I want to reinstall it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The previous installation process downloaded about 140MB at very low speed. I have used the main &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/blob/master/README.md#mac-os-x&quot; rel=&quot;noreferrer&quot;&gt;tutorial&lt;/a&gt; to install with these commands (after installing the bundle with &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;noreferrer&quot;&gt;Vundle&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim/bundle/YouCompleteMe&#xA;./install.py --clang-completer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I manually download the additional file and install it offline?&lt;/p&gt;&#xA;" OwnerUserId="7357" LastActivityDate="2017-07-03T20:50:29.940" Title="How to install YouCompleteMe with Clang completer offline?" Tags="|plugin-you-complete-me|plugin-vundle|plugin-clang-complete|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7471" PostTypeId="2" ParentId="7470" CreationDate="2016-04-22T22:25:06.253" Score="13" Body="&lt;p&gt;I did the following to install (Although I could copy the whole &lt;code&gt;~/.vim&lt;/code&gt; directory to the new place instead of steps 3-6):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Install vim 7.4:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;brew install vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: If you are using mac operating system, make sure you create an alias in your bash_profile pointing to macvim i.e. &lt;code&gt;which mvim&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Install &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;noreferrer&quot;&gt;Vundle&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add &lt;code&gt;Plugin 'Valloric/YouCompleteMe'&lt;/code&gt; to &lt;code&gt;~/.vimrc&lt;/code&gt; and run &lt;code&gt;:PluginInstall&lt;/code&gt; in vim.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Download &lt;strong&gt;clang+llvm-&lt;em&gt;version&lt;/em&gt;-x86_64-apple-darwin.tar.xz&lt;/strong&gt; from &lt;code&gt;Pre-Built Binaries&lt;/code&gt; section of &lt;a href=&quot;http://llvm.org/releases/download.html&quot; rel=&quot;noreferrer&quot;&gt;LLVM Download Page&lt;/a&gt; manually (now it is the latest version).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Make the download directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ~/.vim/bundle/YouCompleteMe/third_party/ycmd/clang_archives&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Put the downloaded file in that directory.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mv  clang+llvm-*-x86_64-apple-darwin.tar.xz ~/.vim/bundle/YouCompleteMe/third_party/ycmd/clang_archives&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Compile YouCompleteMe:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim/bundle/YouCompleteMe&#xA;./install.py --clang-completer&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7357" LastEditorUserId="12899" LastEditDate="2017-07-03T20:50:29.940" LastActivityDate="2017-07-03T20:50:29.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7472" PostTypeId="1" AcceptedAnswerId="7473" CreationDate="2016-04-23T02:09:00.497" Score="3" ViewCount="400" Body="&lt;p&gt;I want to remap &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;y&lt;/kbd&gt;(scroll up) to &lt;kbd&gt;up&lt;/kbd&gt;.&lt;br&gt;&#xA;However, I also have yankring mapped to &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;y&lt;/kbd&gt;, and I wish to keep yankring's mapping.&lt;br&gt;&#xA;Now if I have this in .vimrc: &lt;code&gt;map &amp;lt;Up&amp;gt; &amp;lt;C-y&amp;gt;&lt;/code&gt;, pressing &lt;kbd&gt;up&lt;/kbd&gt; will trigger yankring.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there a way to remap Vim's default key mapping (or map to it's function), whilst having plugin mapped to it?&lt;br&gt;&#xA;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="7361" LastEditorUserId="205" LastEditDate="2016-04-24T18:07:33.207" LastActivityDate="2016-04-24T18:07:33.207" Title="Remap keys conflicting with plugin" Tags="|key-bindings|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7473" PostTypeId="2" ParentId="7472" CreationDate="2016-04-23T03:28:11.863" Score="5" Body="&lt;p&gt;Try: &lt;code&gt;noremap &amp;lt;up&amp;gt; &amp;lt;c-y&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regular key maps are recursive, meaning they will invoke your other defined key maps.  &lt;code&gt;noremap&lt;/code&gt; makes it so that the &lt;code&gt;{rhs}&lt;/code&gt; uses the default key maps.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-04-23T03:28:11.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7474" PostTypeId="2" ParentId="7459" CreationDate="2016-04-23T07:14:00.087" Score="18" Body="&lt;p&gt;In normal mode press double &lt;code&gt;!&lt;/code&gt;, then enter the command, or just type the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.!ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7316" LastActivityDate="2016-04-23T07:14:00.087" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7475" PostTypeId="1" CreationDate="2016-04-23T12:26:45.010" Score="0" ViewCount="1938" Body="&lt;p&gt;When a variable on which a statusline depends changes, I see the result only in statuslines of active windows.  Can inactive ones be made to see those changes too?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="1821" LastEditDate="2016-04-27T06:28:48.813" LastActivityDate="2016-04-27T06:28:48.813" Title="Auto-updating statuslines of inactive windows" Tags="|statusline|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7476" PostTypeId="1" CreationDate="2016-04-24T09:50:16.830" Score="3" ViewCount="70" Body="&lt;p&gt;I often use the sequence &lt;code&gt;gqap&lt;/code&gt; to hard wrap the current paragraph.&#xA;However I'd like some line to be excluded from the process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.&lt;br&gt;&#xA;Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. &#xA;&lt;strong&gt;&amp;lt;&amp;lt;--no wrap here--&gt;&gt;&lt;/strong&gt;&lt;br&gt;&#xA;Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.&lt;br&gt;&#xA;Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;after &lt;code&gt;gqap&lt;/code&gt; it becomes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;br&gt;&#xA;Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="6848" LastActivityDate="2016-04-24T12:59:15.683" Title="exclude a line from wrap" Tags="|wrapping|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7477" PostTypeId="2" ParentId="7476" CreationDate="2016-04-24T12:59:15.683" Score="1" Body="&lt;p&gt;I'm assuming you are wanting to &lt;em&gt;not&lt;/em&gt; wrap if the line is below &lt;code&gt;textwidth&lt;/code&gt; &lt;strong&gt;and&lt;/strong&gt; ends with &lt;code&gt;consequat.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ConsequatWrap() abort&#xA;  if v:char != '' || mode() == 'i'&#xA;    return 1&#xA;  endif&#xA;&#xA;  let start_line = v:lnum&#xA;  let end_line = v:lnum + v:count - 1&#xA;&#xA;  while start_line &amp;lt;= end_line&#xA;    call cursor(start_line, &amp;amp;l:textwidth)&#xA;&#xA;    if col('.') &amp;lt; &amp;amp;l:textwidth &amp;amp;&amp;amp; getline('.') !~? 'consequat\.$'&#xA;      normal! J&#xA;      let end_line -= 1&#xA;      continue&#xA;    endif&#xA;&#xA;    if col('$') &amp;gt;= &amp;amp;l:textwidth&#xA;          \ &amp;amp;&amp;amp; (search('consequat\.\%(\_$\)\@!', 'cbeW') == start_line&#xA;          \     || search('\s', 'cbeW') == start_line)&#xA;      execute &quot;normal! a\&amp;lt;cr&amp;gt;&quot;&#xA;      let end_line += 1&#xA;    endif&#xA;    let start_line += 1&#xA;  endwhile&#xA;endfunction&#xA;&#xA;set formatexpr=ConsequatWrap()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's happening above is that lines shorter than &lt;code&gt;textwidth&lt;/code&gt; are joined to the current line, unless the line ends with &lt;code&gt;consequat.&lt;/code&gt;.  Once the line is long enough to break, search backwards from &lt;code&gt;textwidth&lt;/code&gt; for a space or an occurrence of &lt;code&gt;consequat.&lt;/code&gt;, then insert &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; right after it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;formatexpr&lt;/code&gt; will allow you to format using any direction or text object.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-04-24T12:59:15.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7478" PostTypeId="1" AcceptedAnswerId="7479" CreationDate="2016-04-24T14:30:00.923" Score="6" ViewCount="286" Body="&lt;p&gt;I have several files that prefix file names with a &lt;code&gt;→&lt;/code&gt; character, for example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In →path/to/some/file, there is&#xA;a foo, in →path/to/other/file, there&#xA;is a bar. etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the cursor is over such a path, I'd like to use &lt;code&gt;gf&lt;/code&gt; to go the this file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gf&lt;/code&gt; uses &lt;code&gt;isfname&lt;/code&gt; to determine which characters belong to the file. Unfortunatly, &lt;code&gt;help isfname&lt;/code&gt; explicitely states&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Multi-byte characters 256 and above are always included, only the&#xA;  characters up to 255 are specified with this option.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is there another way to exclude &lt;code&gt;→&lt;/code&gt; from the characters recognized as file name characters?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="205" LastEditDate="2016-04-24T17:58:23.397" LastActivityDate="2016-04-24T17:58:23.397" Title="How do I exclude the → from file name characters?" Tags="|options|load|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7479" PostTypeId="2" ParentId="7478" CreationDate="2016-04-24T15:42:19.637" Score="8" Body="&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#gf&quot;&gt;&lt;code&gt;:h gf&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If the file can't be found, 'includeexpr' is used to&#xA;modify the name and another attempt is done.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And for &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27includeexpr%27&quot;&gt;&lt;code&gt;:h includeexpr&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                'includeexpr' 'inex'&#xA;'includeexpr' 'inex'    string  (default &quot;&quot;)&#xA;                        local to buffer&#xA;                        {not in Vi}&#xA;                        {not available when compiled without the&#xA;                        +find_in_path or +eval features}&#xA;        Expression to be used to transform the string found with the 'include'&#xA;        option to a file name.  Mostly useful to change &quot;.&quot; to &quot;/&quot; for Java: &#xA;                :set includeexpr=substitute(v:fname,'\\.','/','g')&#xA;       The &quot;v:fname&quot; variable will be set to the file name that was detected.&#xA;&#xA;        Also used for the gf command if an unmodified file name can't be&#xA;        found.  Allows doing &quot;gf&quot; on the name after an 'include' statement.&#xA;        Also used for &amp;lt;cfile&amp;gt;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, you could try something like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;:set includeexpr=substitute(v:fname,'^→','','')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-04-24T16:17:10.593" LastActivityDate="2016-04-24T16:17:10.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7480" PostTypeId="1" AcceptedAnswerId="7482" CreationDate="2016-04-24T18:57:14.157" Score="7" ViewCount="203" Body="&lt;p&gt;How   can  I   run  a   command   on  all lines   delimited,  say   by&#xA;&lt;code&gt;\begin{otherlanguage}&lt;/code&gt; and &lt;code&gt;\end{otherlanguage}&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 This line should not be affected,&#xA;2 \begin{otherlanguage}&#xA;3 but this should;&#xA;4 \end{otherlanguage}&#xA;5 this should not.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The cmd could be &lt;code&gt;norm A test&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="205" LastEditDate="2016-04-24T20:46:08.690" LastActivityDate="2016-04-24T21:05:32.880" Title="Executing a command on delimited lines" Tags="|regular-expression|ex-mode|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7481" PostTypeId="1" AcceptedAnswerId="7526" CreationDate="2016-04-24T20:04:58.510" Score="3" ViewCount="18841" Body="&lt;p&gt;I am root on the machine, and have my .vimrc at &lt;code&gt;/root/.vimrc&lt;/code&gt;.  Vim ignores this, even though &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# echo $HOME&#xA;/root&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim -u /root/.vimrc some-file-to-edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim still ignores it.  Setting &lt;code&gt;export MYVIMRC=root/.vimrc&lt;/code&gt; has no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim sources my file without problems if I start vim and type &lt;code&gt;:source /root/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note &lt;code&gt;VIMINIT&lt;/code&gt; is unset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What could be preventing vim from sourcing my .vimrc when starting up?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm happy to supply any other information that may be helpful, just let me know what.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 1: excerpt from running &lt;code&gt;vim -V filename&lt;/code&gt;:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;finished sourcing $VIM/vimrc&#xA;chdir(/root)&#xA;fchdir() to previous dir &#xA;sourcing &quot;$HOME/.vimrc&quot;&#xA;Searching for &quot;filetype.vim&quot; in &quot;/root/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,/root/.vim/after&quot;&#xA;Searching for &quot;/root/.vim/filetype.vim&quot;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The full output is long, so this is just an excerpt to show the line that verifies sourcing of &lt;code&gt;/root/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2: output from running &lt;code&gt;:scriptnames&lt;/code&gt; after vim normally*&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: /usr/share/vim/vimrc&#xA;  2: /usr/share/vim/vim74/debian.vim&#xA;  3: /usr/share/vim/vim74/syntax/syntax.vim&#xA;  4: /usr/share/vim/vim74/syntax/synload.vim&#xA;  5: /usr/share/vim/vim74/syntax/syncolor.vim&#xA;  6: /usr/share/vim/vim74/filetype.vim&#xA;  7: ~/.vimrc&#xA;  8: /usr/share/vim/vim74/indent.vim&#xA;  9: /usr/share/vim/vim74/ftplugin.vim&#xA; 10: /usr/share/vim/vim74/syntax/nosyntax.vim&#xA; 11: /usr/share/vim/vim74/plugin/getscriptPlugin.vim&#xA; 12: /usr/share/vim/vim74/plugin/gzip.vim&#xA; 13: /usr/share/vim/vim74/plugin/matchparen.vim&#xA; 14: /usr/share/vim/vim74/plugin/netrwPlugin.vim&#xA; 15: /usr/share/vim/vim74/plugin/rrhelper.vim&#xA; 16: /usr/share/vim/vim74/plugin/spellfile.vim&#xA; 17: /usr/share/vim/vim74/plugin/tarPlugin.vim&#xA; 18: /usr/share/vim/vim74/plugin/tohtml.vim&#xA; 19: /usr/share/vim/vim74/plugin/vimballPlugin.vim&#xA; 20: /usr/share/vim/vim74/plugin/zipPlugin.vim&#xA; 21: /usr/share/vim/vim74/indent/python.vim&#xA; 22: /usr/share/vim/vim74/ftplugin/python.vim&#xA; 23: /usr/share/vim/vim74/syntax/python.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, seems to be sourcing &lt;code&gt;/root/.vimrc&lt;/code&gt; (item 7).  Soo... line 8 makes me suspicious: my problem is that the indent settings in my vimrc aren't reflected.  Maybe they are being superceeded...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 3: Placing my file in &lt;code&gt;~/.vim/after/...&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moving my file to the following locations had no effect on the output of &lt;code&gt;scriptnames&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/after/indent.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/after/indent.vim/myscript.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/after/indent/myscript.vim&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/after/syntax/myscript.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/after/indent/myscript.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/after/myscript.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And, while moving my to &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/after/plugin/.vimrc&lt;/code&gt; &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;did change the output of &lt;code&gt;:scriptnames&lt;/code&gt;, causing my file to be sourced after item 20 (see above), it seems my indent settings are still getting overridden (probably by item 21).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use of the &lt;code&gt;after&lt;/code&gt; directory doesn't work how I imagined (see my list of attempts).  Only &lt;code&gt;after/plugins/&lt;/code&gt; seems to be considered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to ensure that the file is sourced after everything?&lt;/p&gt;&#xA;" OwnerUserId="7380" LastEditorUserId="16037" LastEditDate="2018-07-18T14:57:24.537" LastActivityDate="2018-07-18T14:57:24.537" Title="Vim not sourcing files on startup" Tags="|vimrc|invocation|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="7482" PostTypeId="2" ParentId="7480" CreationDate="2016-04-24T20:32:58.120" Score="9" Body="&lt;p&gt;You can use pattern delimiter for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/first/,/second/norm dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use any search pattern around the &lt;code&gt;,&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use only the inside of the matched patterns, use + and - like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/first/+1,/second/-1 norm dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-04-24T20:41:23.713" LastActivityDate="2016-04-24T20:41:23.713" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7483" PostTypeId="2" ParentId="7480" CreationDate="2016-04-24T21:00:01.273" Score="5" Body="&lt;p&gt;A more specific answer (since you seem to be editing a TeX file): if you use the &lt;code&gt;vimtex&lt;/code&gt; plugin (although &lt;code&gt;LaTeX-Box&lt;/code&gt; also has this IIRC), you can easily select the whole environment (without the &lt;code&gt;\begin&lt;/code&gt; and &lt;code&gt;\end&lt;/code&gt; marker lines) using the &lt;em&gt;inside environment&lt;/em&gt; text object (&lt;code&gt;ie&lt;/code&gt;). So, assuming the cursor is somewhere &lt;em&gt;inside&lt;/em&gt; the &lt;code&gt;otherlanguage&lt;/code&gt; environment, your example can be &quot;solved&quot; with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vie:norm A test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more vimtex mappings, see &lt;code&gt;:h vimtex-default-mappings&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-04-24T21:05:32.880" LastActivityDate="2016-04-24T21:05:32.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7484" PostTypeId="2" ParentId="7475" CreationDate="2016-04-25T00:27:29.210" Score="2" Body="&lt;p&gt;Edit: As @Christian Brabandt mentioned in this &lt;a href=&quot;https://vi.stackexchange.com/questions/7475/autoupdating-statuslines-of-inactive-windows#comment12293_7484&quot;&gt;comment&lt;/a&gt;, the Ex command &lt;code&gt;:redrawstatus&lt;/code&gt; does the same thing as the &lt;code&gt;'readonly'&lt;/code&gt; hack, and is probably even better. From &lt;code&gt;:help redraws&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *:redraws* *:redrawstatus*&#xA;:redraws[tatus][!]  Redraw the status line of the current window.  When !&#xA;            is included all status lines are redrawn.&#xA;            Useful to update the status line(s) when 'statusline'&#xA;            includes an item that doesn't cause automatic&#xA;            updating.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, after assigning a new value to your variable you could add &lt;code&gt;| redraws!&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:myvar='bar' | redraws!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The bang is necessary to update all the status lines, and not just the one of the current window.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I don't know why but it seems that setting the value of the &lt;code&gt;'readonly'&lt;/code&gt; option has also the side-effect of updating the status lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;:help 'statusline'&lt;/code&gt;, they mention this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If the statusline is not updated when you want it (e.g., after setting&#xA;a variable that's used in an expression), you can force an update by&#xA;setting an option without changing its value.  Example: &amp;gt;&#xA;    :let &amp;amp;ro = &amp;amp;ro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, suppose you have a variable &lt;code&gt;g:myvar&lt;/code&gt; whose value is &lt;code&gt;'foo'&lt;/code&gt; and appears in your status line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:myvar='foo'&#xA;set stl+=%{g:myvar}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you want to change its value to &lt;code&gt;'bar'&lt;/code&gt; as well as the change to be reflected in every status line. Maybe you could type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:myvar='bar' | let &amp;amp;l:ro = &amp;amp;l:ro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;&amp;amp;l:ro&lt;/code&gt; is the local-buffer value of &lt;code&gt;'readonly'&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it a little easier, you could install a custom command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Let exe 'let ' . &amp;lt;q-args&amp;gt; | let &amp;amp;l:ro = &amp;amp;l:ro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then, type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Let g:myvar='bar'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could remap &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in command-line mode to parse the command before its execution, check whether it matches a certain pattern (&lt;code&gt;let one_of_your_vars=&lt;/code&gt;), and substitute the end of the command to add &lt;code&gt;| let &amp;amp;l:ro = &amp;amp;l:ro&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-04-25T16:48:39.893" LastActivityDate="2016-04-25T16:48:39.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7485" PostTypeId="2" ParentId="7453" CreationDate="2016-04-25T04:11:22.307" Score="3" Body="&lt;p&gt;Another alternative is to use a plugin for file search that automatically adds all directories in your project. I like to use the CtrlP plugin to navigate to files in my project. I open file under cursor by &lt;code&gt;&amp;lt;Leader&amp;gt;gf&lt;/code&gt;. You will need this in your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Leader gf copies word under cursor to ctrlp&#xA;nmap &amp;lt;leader&amp;gt;gf :CtrlP&amp;lt;CR&amp;gt;&amp;lt;C-\&amp;gt;w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7386" LastEditorUserId="205" LastEditDate="2016-04-25T05:17:20.653" LastActivityDate="2016-04-25T05:17:20.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7486" PostTypeId="1" AcceptedAnswerId="7523" CreationDate="2016-04-25T05:08:54.083" Score="1" ViewCount="151" Body="&lt;p&gt;Running Fedora23 KDE spin. KDE Plasma 5.5.5. Qt 5.6.0. Konsole 15.12.3. zsh 5.1.1. vimx 7.4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have installed pathogen and SpeedDating using pathogen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I do &lt;code&gt;Ctrl-A&lt;/code&gt;, &lt;code&gt;Ctrl-X&lt;/code&gt; on a date field, nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:map&lt;/code&gt; shows both &lt;code&gt;Ctrl-A&lt;/code&gt; and &lt;code&gt;Ctrl-X&lt;/code&gt; as mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What must be going wrong? How do I set it right?&lt;/p&gt;&#xA;" OwnerUserId="3095" LastEditorUserId="1821" LastEditDate="2016-04-25T09:34:10.023" LastActivityDate="2016-04-27T15:02:47.800" Title="Speed dating does not work" Tags="|key-bindings|plugin-pathogen|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7487" PostTypeId="1" CreationDate="2016-04-25T06:51:53.460" Score="0" ViewCount="59" Body="&lt;p&gt;I'm mostly developing with python. I'm using pdbpp as python debugger so I'm contantly adding&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import pdb;pdb.set_trace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import pdb&#xA;pdb.set_trace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I wrote couple of functions.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddBreakPoint()&#xA;    let l:line = line('.')&#xA;    let l:indentChar = ' '&#xA;    call append(l:line - 1, repeat(l:indentChar, indent(l:line)) . &quot;import pdb;pdb.set_trace&quot;)&#xA;endfunction&#xA;&#xA;&#xA;function! RemoveAllBreakPoints()&#xA;    write&#xA;    silent! execute 'bufdo g/\v^\s+(import pdb|pdb.set_trace)/de'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with that now is that &lt;code&gt;RemoveAllBreakPoints()&lt;/code&gt; messes relative position of cursor on the screen. So for example if the cursor was in the middle of the screen after &lt;code&gt;zz&lt;/code&gt; it would be on the same line, but this line suddenly appears at the bottom of the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT1 OK, I solved it with KeepView plugin, but could someone explain to me why vim doing that and is there a native way to keep view after executing command?&lt;/p&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2016-04-25T07:23:14.803" Title="Save view after execute command?" Tags="|cut-copy-paste|ex-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7488" PostTypeId="2" ParentId="7487" CreationDate="2016-04-25T07:23:14.803" Score="3" Body="&lt;p&gt;You don't need a plugin for that, the functionality is built into Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RemoveAllBreakPoints()&#xA;    let view = winsaveview()&#xA;    write&#xA;    g/\v^\s+(import pdb|pdb.set_trace)/d&#xA;    call winrestview(view)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help winsaveview()&#xA;:help winrestview()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-25T07:23:14.803" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7489" PostTypeId="1" CreationDate="2016-04-25T07:15:52.997" Score="4" ViewCount="281" Body="&lt;p&gt;I know i can load a new or reload a vimrc file with the &lt;code&gt;:source&lt;/code&gt; command. But is there a reverse to this? Because every source only adds to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example. if I would load a vimrc file to map F5 to a certain action. would i be able to unload this binding? And what about custom function&lt;/p&gt;&#xA;" OwnerUserId="7394" OwnerDisplayName="Niek de Gooijer" LastEditorUserId="205" LastEditDate="2016-05-03T08:25:15.330" LastActivityDate="2016-05-03T08:25:15.330" Title="Reverting the vim source command" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7490" PostTypeId="2" ParentId="7489" CreationDate="2016-04-25T12:32:57.030" Score="5" Body="&lt;p&gt;You can have a look at the Tim Pope's plugin &lt;a href=&quot;https://github.com/tpope/vim-scriptease&quot;&gt;scriptease&lt;/a&gt;, it has a &lt;code&gt;Disarm&lt;/code&gt; command. I think it's the closest I know for your issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also want to create a custom source function that keep track of everything that has been added from the &lt;code&gt;source&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-04-25T12:32:57.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7491" PostTypeId="1" CreationDate="2016-04-25T21:23:36.097" Score="0" ViewCount="140" Body="&lt;p&gt;I am creating my firsts neosnippet-snippets in c.snip, it looks like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet head&#xA;  options head&#xA;  ////////////////////////////////////////////////////////////////////////////////&#xA;  // ${1:TITLE}&#xA;  ////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;  ${0:TARGET}&#xA;&#xA;  //// END OF $1&#xA;&#xA;snippet stdlib&#xA;  options head&#xA;  alias std&#xA;  #include &amp;lt;stdlib.h&amp;gt;${0}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first snippet expands correctly while the seconds expands to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  options head&#xA;  alias std&#xA;  #include &amp;lt;stdlib.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why so?&lt;/p&gt;&#xA;" OwnerUserId="6078" LastActivityDate="2016-04-26T09:24:06.700" Title="Neosnippet expands to &quot;options head&quot;" Tags="|snippets|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7492" PostTypeId="1" AcceptedAnswerId="7511" CreationDate="2016-04-25T22:15:35.447" Score="0" ViewCount="209" Body="&lt;p&gt;I'm new to using vim and am currently using pathogen to manage my plugins. I've attempted to install autoclose my placing the &lt;code&gt;autoclose.vim&lt;/code&gt; file in it's own directory in bundle. I've also added the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to the top of my vimrc file, but when I open a new vim file the plugin doesn't seem to work. &#xA;Any advice?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;filetype plugin indent on&#xA;set number&#xA;syntax on&#xA;set laststatus=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm successfully using vim-airline without issue. I have, however, had difficulty adding new color schemes as well.&lt;/p&gt;&#xA;" OwnerUserId="7399" LastEditorUserId="1841" LastEditDate="2016-04-26T07:29:48.980" LastActivityDate="2016-04-27T08:56:20.263" Title="Problem using autoclose plugin with pathogen" Tags="|plugin-pathogen|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7493" PostTypeId="2" ParentId="7491" CreationDate="2016-04-25T23:24:27.263" Score="2" Body="&lt;p&gt;It's because you &lt;strong&gt;indent&lt;/strong&gt; the snippet options ('keywords'), by not following the help example (&lt;code&gt;:h neosnippet-snippet-syntax&lt;/code&gt;). So, you need:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet stdlib&#xA;options head&#xA;alias std&#xA;    #include&amp;lt;stdlib.h&amp;gt;${0}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW, I'm not sure if &lt;code&gt;${0}&lt;/code&gt; is needed at all, in this example.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-04-26T09:24:06.700" LastActivityDate="2016-04-26T09:24:06.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7494" PostTypeId="1" CreationDate="2016-04-26T07:54:15.343" Score="4" ViewCount="2978" Body="&lt;p&gt;After listening to Damien Conways More Instantly Better Vim I've switch colon and semicolon in my vimrc like so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; remap colon to semicolon in norman and visual mode, but not in insert mode&#xA;nnoremap ; :&#xA;nnoremap : ;&#xA;vnoremap ; :&#xA;vnoremap : ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it was really convenient for me. But recently I've learned from vim help (I've finally started reading it systematically) that not only I can search for next occurence of character in line with f, but also repeat this search with semicolon and with comma in backward direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This creates the conflict between this two. So initially I've disabled remapping colon to semicolon. But it's so annoying now, that I'm trying to find another solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I change the key at which vim found repeat search, not just remap it for all commands?&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="1821" LastEditDate="2016-04-26T08:02:01.603" LastActivityDate="2016-04-26T22:15:50.140" Title="How to switch semicolon to colon to repeat last f or t search?" Tags="|key-bindings|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7495" PostTypeId="1" AcceptedAnswerId="7532" CreationDate="2016-04-26T07:57:58.617" Score="1" ViewCount="112" Body="&lt;p&gt;With Vim 7.2, when a perl block is aligned using &lt;code&gt;=&lt;/code&gt;, &#xA;Multi line comments are moved as per the blocks inner alignment. But they should be placed at immediate start of the line.&#xA;Is there any way to solve this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Executing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    :%s/^\s\+=/=/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;every time is time consuming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if($i==0)&#xA; {&#xA; $i=$i+3;&#xA;  =head&#xA;  This part can be optimised&#xA;  =cut&#xA; print $i;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After aligning (with &lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;{&lt;/kbd&gt; or &lt;kbd&gt;9&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   if($i==0)&#xA;  {&#xA;       $i=$i+3;&#xA;       =head&#xA;      This part can be optimised&#xA;      =cut&#xA;     print $i;&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Expected alignment;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   if($i==0)&#xA;   {&#xA;         $i=$i+3;&#xA;   =head&#xA;   This part can be optimised&#xA;   =cut&#xA;        print $i;&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="7415" LastEditDate="2016-04-28T09:45:35.100" LastActivityDate="2016-04-28T09:45:35.100" Title="perl multi line comments are not aligned properly" Tags="|normal-mode|alignment|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7496" PostTypeId="5" CreationDate="2016-04-26T08:25:10.060" Score="0" Body="&lt;p&gt;Vim ships with a built-in sort utility and you can also specify an external sorting tool. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. in order to keep only unique lines in Vim, you would:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:{range}sort u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More informations: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#sort&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h sort&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1841" LastEditDate="2016-04-26T08:30:03.227" LastActivityDate="2016-04-26T08:30:03.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7497" PostTypeId="4" CreationDate="2016-04-26T08:25:10.060" Score="0" Body="Vim command for sorting a set of lines." OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-04-26T10:20:09.043" LastActivityDate="2016-04-26T10:20:09.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7498" PostTypeId="5" CreationDate="2016-04-26T08:37:18.747" Score="0" Body="&lt;p&gt;Vim works like no other software (but a lot of software are inspired by vim navigation's commands), and mastering the core vim's functionalities can be very rewarding but also painful. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This tag is about habit breaking (not using the mouse, arrow key, ...) in order to gain efficiency using vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good &lt;a href=&quot;http://vimcasts.org/blog/2013/02/habit-breaking-habit-making/&quot; rel=&quot;nofollow&quot;&gt;vimcast article&lt;/a&gt; was posted about this subject, worth reading.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-04-26T10:20:06.260" LastActivityDate="2016-04-26T10:20:06.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7499" PostTypeId="4" CreationDate="2016-04-26T08:37:18.747" Score="0" Body="Breaking habits for a better Vim usage." OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-04-26T10:19:53.243" LastActivityDate="2016-04-26T10:19:53.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7500" PostTypeId="1" AcceptedAnswerId="7503" CreationDate="2016-04-26T09:23:06.203" Score="0" ViewCount="832" Body="&lt;p&gt;I'm trying to modify the plugin &lt;a href=&quot;https://github.com/jaxbot/semantic-highlight.vim&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jaxbot/semantic-highlight.vim&lt;/a&gt; to highlight variables of differing case with different colours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some example configuration the plugin generates: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute hi! def _semantic0 guifg=#9CD8F7&#xA;execute hi! def _semantic1 guifg=#F5FA1D&#xA;execute syn keyword _semantic0 json&#xA;execute syn keyword _semantic1 JSON&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the above, both &lt;code&gt;json&lt;/code&gt; and &lt;code&gt;JSON&lt;/code&gt; are highlighted with the same colour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is &lt;code&gt;syntax keyword&lt;/code&gt; case insensitive?&lt;/p&gt;&#xA;" OwnerUserId="5141" LastActivityDate="2016-04-26T09:42:17.657" Title="Is syntax keyword case sensitive?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7501" PostTypeId="1" AcceptedAnswerId="7502" CreationDate="2016-04-26T09:23:28.003" Score="2" ViewCount="48" Body="&lt;p&gt;I know I can apply changes to multiple lines by selecting the lines in visual mode (I use &lt;code&gt;ctrl-v&lt;/code&gt;) and defining the set of actions and the mode to start in (e.g. &lt;code&gt;norma A,&lt;/code&gt; will add a comma at the end of all selected lines).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering how can I go back to normal mode after using something like &lt;code&gt;A&lt;/code&gt; (which goes to insert mode). I'm not familiar with the terminology enough to google it properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to add a comma at the end of each line and then join all lines together. I assumed something like the following (not correct, obviously) should do it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ctrl-v&lt;/code&gt;, &lt;code&gt;G&lt;/code&gt;, &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;normal A, normal J&lt;/code&gt; &lt;code&gt;RET&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But obviously this appends &lt;code&gt;, normal J&lt;/code&gt; to each line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there are plenty of other ways to do it (regular expressions, macros ...) so I don't need alternatives, that's not my question.&lt;/p&gt;&#xA;" OwnerUserId="7404" LastActivityDate="2016-04-26T12:26:36.303" Title="Applying changes to lines in alternating modes" Tags="|insert-mode|normal-mode|range|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7502" PostTypeId="2" ParentId="7501" CreationDate="2016-04-26T09:39:33.940" Score="3" Body="&lt;p&gt;Well actually you can use a litteral &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; character to chain commands like you would do normally:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;norm! A,^II+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will insert a &lt;code&gt;,&lt;/code&gt; at the end of each line, and a &lt;code&gt;+&lt;/code&gt; at the start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To add the special &lt;code&gt;^I&lt;/code&gt; char, press &lt;code&gt;C-v&lt;/code&gt; and &lt;code&gt;ESC&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-04-26T12:26:36.303" LastActivityDate="2016-04-26T12:26:36.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7503" PostTypeId="2" ParentId="7500" CreationDate="2016-04-26T09:42:17.657" Score="3" Body="&lt;p&gt;Apparently it is, from the documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And a keyword with matching case always goes before a keyword with ignoring case.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;see: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#syn-define&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h syn-define&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-04-26T09:42:17.657" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7504" PostTypeId="1" AcceptedAnswerId="7505" CreationDate="2016-04-26T13:50:35.137" Score="2" ViewCount="88" Body="&lt;p&gt;I have a vim script that does the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal 3f,&#xA;normal lvnh&quot;+y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I search for anything other than &lt;code&gt;/,/&lt;/code&gt; before hand, the &lt;code&gt;n&lt;/code&gt; in &lt;code&gt;normal lvnh&quot;+y&lt;/code&gt; matches whatever I searched for last instead of the intended &lt;code&gt;,&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So why does it do this, and how do I get it to search for a &lt;code&gt;,&lt;/code&gt; instead?  Not a search and replace, but just a search for a &lt;code&gt;,&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="205" LastEditDate="2016-04-27T08:17:51.847" LastActivityDate="2016-04-27T08:17:51.847" Title="Why doesn't n jump to the last character matched with f?" Tags="|vimscript|cursor-motions|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="7505" PostTypeId="2" ParentId="7504" CreationDate="2016-04-26T14:12:24.727" Score="10" Body="&lt;p&gt;You confused &lt;code&gt;n&lt;/code&gt;which repeat the last search (made via &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;) and &lt;code&gt;;&lt;/code&gt; which allows to repeat the last &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt; or &lt;code&gt;T&lt;/code&gt; movement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a bonus &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt; go forward while &lt;code&gt;N&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt; go backward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#n&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h n&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#;&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h ;&lt;/code&gt;&lt;/a&gt; as references.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-27T07:28:40.777" LastActivityDate="2016-04-27T07:28:40.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7506" PostTypeId="1" AcceptedAnswerId="7507" CreationDate="2016-04-26T14:59:49.290" Score="2" ViewCount="904" Body="&lt;p&gt;In order to overcome my irritation with quoting and comma separating words in a list, I thought I would play with Vim's search and replace to allow myself to type lists like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;daqs = [this is a test of some cool vim stuff for creating a comma separated list of strings]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and use a regular expression to convert this line to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;daqs = [&quot;this&quot;, &quot;is&quot;, &quot;a&quot;, &quot;test&quot;, &quot;of&quot;, &quot;some&quot;, &quot;cool&quot;, &quot;vim&quot;, &quot;stuff&quot;, &quot;for&quot;, &quot;creating&quot;, &quot;a&quot;, &quot;comma&quot;, &quot;separated&quot;, &quot;list&quot;, &quot;of&quot;, &quot;strings&quot;, ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I visually selected everything inside the brackets, and used the expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V\S\+[^\]]/\&quot;&amp;amp;\&quot;, /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But a trailing whitespace character seems to be following my &quot;&amp;amp;&quot; insertion, giving me this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;daqs = [&quot;this &quot;, &quot;is &quot;, &quot;a &quot;, &quot;test &quot;, &quot;of &quot;, &quot;some &quot;, &quot;cool &quot;, &quot;vim &quot;, &quot;stuff &quot;, &quot;for &quot;, &quot;creating &quot;, &quot;a &quot;, &quot;comma &quot;, &quot;separated &quot;, &quot;list &quot;, &quot;of &quot;, &quot;strings&quot;, ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the final word does not have a space at the end within the quotes. How can I match each word between the brackets without carrying around this ending whitespace?&lt;/p&gt;&#xA;" OwnerUserId="7405" LastEditorUserId="1821" LastEditDate="2016-04-26T15:19:55.357" LastActivityDate="2016-04-26T21:22:21.943" Title="Extra trailing whitespace in regex match using &quot;&amp;&quot;" Tags="|regular-expression|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7507" PostTypeId="2" ParentId="7506" CreationDate="2016-04-26T15:09:27.920" Score="3" Body="&lt;p&gt;I made it work with a different regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V[^] ]\+/\&quot;&amp;amp;\&quot;,/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;decomposing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/       &quot; start a new substitution command&#xA;\%V            &quot; match inside the visual selection&#xA;[^] ]\+        &quot; match everything but a space and a closing ] (1 or more time)&#xA;/              &quot; replace with&#xA;\&quot;&amp;amp;\&quot;,         &quot; the quoted matched group followed by a space and a ,&#xA;/g             &quot; replace globally&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-04-26T21:22:21.943" LastActivityDate="2016-04-26T21:22:21.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7509" PostTypeId="2" ParentId="7506" CreationDate="2016-04-26T15:47:51.917" Score="4" Body="&lt;p&gt;Here is a vimscript-based alternative, just for the fun of it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\[\(.*\)\]/\=string(split(submatch(1), &quot; &quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help sub-replace-expression&lt;/code&gt;, &lt;code&gt;:help submatch()&lt;/code&gt;, &lt;code&gt;:help string()&lt;/code&gt;, and &lt;code&gt;:help split()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-04-26T15:47:51.917" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7510" PostTypeId="2" ParentId="7494" CreationDate="2016-04-26T22:15:50.140" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I change the key at which vim found repeat search […] ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Why, you already did so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap : ;&#xA;vnoremap : ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Colon now does what semicolon used to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;f&lt;/code&gt;/&lt;code&gt;t&lt;/code&gt;/&lt;code&gt;F&lt;/code&gt;/&lt;code&gt;T&lt;/code&gt; work in Normal and Visual modes, where you also have direct access to Command mode (by pressing &lt;code&gt;:&lt;/code&gt;). Thus, you can't map both &quot;next match&quot; and &quot;got to Command mode&quot; onto one key, as it will become &lt;em&gt;impossible&lt;/em&gt; for Vim to figure out what you ask of it. You have to consider what you need more often and either keep your current bindings (and learn to use &lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;;&lt;/kbd&gt; to go to next match) or drop them (and go through the pain of pressing &lt;kbd&gt;Shift&lt;/kbd&gt; each time you need to access Command mode.)&lt;/p&gt;&#xA;" OwnerUserId="7415" LastActivityDate="2016-04-26T22:15:50.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7511" PostTypeId="2" ParentId="7492" CreationDate="2016-04-26T22:28:14.787" Score="2" Body="&lt;p&gt;Vim plugins are, traditionally, just a set of files you copy into your &lt;code&gt;~/.vim/&lt;/code&gt;. Since Vim looks for different things in different places (&lt;code&gt;~/.vim/autoload/&lt;/code&gt; for plugins to load on start, &lt;code&gt;~/.vim/plugin/&lt;/code&gt; for things to load on-demand, etc.), plugins themselves follow the same file hierarchy. On installation, plugins are just copied over your existing &lt;code&gt;~/.vim/&lt;/code&gt;, and everything automatically falls into places.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plugin managers like Pathogen make installation and deinstallation more convinient by letting the user place the files into different directories (in Pathogen's case, somewhere under &lt;code&gt;~/.vim/bundle/&lt;/code&gt;), but they &lt;strong&gt;don't&lt;/strong&gt; change the layout. Thus, the contents of plugin directories still follow Vim's rules about &lt;code&gt;autoload&lt;/code&gt;, &lt;code&gt;plugin&lt;/code&gt; and so forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So all you need to do is respect these rules and place &lt;code&gt;AutoClose.vim&lt;/code&gt; into &lt;code&gt;~/.vim/bundle/AutoClose/plugin/&lt;/code&gt; directory.&lt;/p&gt;&#xA;" OwnerUserId="7415" LastActivityDate="2016-04-26T22:28:14.787" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7512" PostTypeId="2" ParentId="7481" CreationDate="2016-04-26T23:08:52.627" Score="7" Body="&lt;p&gt;You can see what Vim does on startup with &lt;code&gt;vim -V&lt;/code&gt;. Does it touch the file? Is there any errors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Safe for errors, my only guess is that filename contains non-ASCII character that looks like &quot;c&quot;; you might not notice it if you always autocomplete the name of the file instead of typing it out in its entirety.&lt;/p&gt;&#xA;" OwnerUserId="7415" LastActivityDate="2016-04-26T23:08:52.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7513" PostTypeId="2" ParentId="7449" CreationDate="2016-04-26T23:20:44.090" Score="2" Body="&lt;p&gt;Use &lt;a href=&quot;https://github.com/kana/vim-fakeclip&quot; rel=&quot;nofollow noreferrer&quot;&gt;fakeclip.vim&lt;/a&gt;. See &lt;a href=&quot;https://stackoverflow.com/a/22617497/2350060&quot;&gt;this answer&lt;/a&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="7415" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-04-26T23:20:44.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7514" PostTypeId="1" AcceptedAnswerId="7516" CreationDate="2016-04-27T01:49:15.270" Score="5" ViewCount="236" Body="&lt;p&gt;I'm pretty new to vimscript, and I wrote this little function to map &lt;code&gt;H&lt;/code&gt; so that the cursor will go to the first non-whitespace character of the line, or to the beginning of the line if the cursor is already at the first non-whitespace character. I just want to a) share this for anyone who might find this useful, and b) ask if there's a more efficient way to do this. I feel like there should be some more in-built way to do this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HFunc()&#xA;    let colnum1 = col(&quot;.&quot;)&#xA;    execute &quot;normal! ^&quot;&#xA;    let colnum2 = col(&quot;.&quot;)&#xA;    if(colnum1 == colnum2)&#xA;        execute &quot;normal! ^0&quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt;H :call HFunc()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5043" LastEditorUserId="5043" LastEditDate="2016-04-27T12:38:42.523" LastActivityDate="2016-07-15T19:23:06.503" Title="Is there a better way to create this &quot;semi-strong&quot; left motion?" Tags="|vimscript|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7515" PostTypeId="1" CreationDate="2016-04-27T03:46:36.567" Score="6" ViewCount="740" Body="&lt;p&gt;I've been using [Neo]vim for a few months now with a number of plugins.  One I decided to use was the built in &lt;code&gt;:Explore&lt;/code&gt; for my file-browsing needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am having some serious issues with &lt;code&gt;Explore&lt;/code&gt; and need some help in resolving (or tell me if it is normal).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the below issues happen in both &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;Neovim&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Ghost Buffers opening based on text clicked&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;With mouse-mode enabled, using &lt;code&gt;:Vex&lt;/code&gt; to open vertical explore and the &lt;em&gt;focus of the window is in the Explorer window&lt;/em&gt;, if I use the mouse to click into a window/buffer of an already opened file and I click a line of code:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A new blank buffer opens.&lt;/li&gt;&#xA;&lt;li&gt;The name of the buffer is the contents of the line I entered, in the form of &lt;code&gt;^Irun.Proxy()&lt;/code&gt; (the line of code I clicked on had &lt;code&gt;run.Proxy()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The Explore window now is blank/empty with no history.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Resolution is to close the empty buffer (which, without a plugin to close the buffer without closing the window is a PITA), close the window for the Explorer, re-open Explorer (and split, again, if I had to close the window).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very annoying.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Lanching &lt;code&gt;:Vex&lt;/code&gt; from a buffer of a sub-directory opens invalid file&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is not repeatable all the time...  But it does happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Launch &lt;code&gt;vim&lt;/code&gt; from a project root folder, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/code/projectA/&#xA;vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, open a file from a sub-directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e sub-folder/file.go&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now launch &lt;code&gt;:Vex&lt;/code&gt; and Explorer starts from that sub-directory because the current buffer is locates in &lt;code&gt;sub-folder/&lt;/code&gt;.  Ok, not a big issue.  I select &lt;code&gt;..&lt;/code&gt; in Explorer to backup to the project root.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the issue: from this same &lt;code&gt;:Vex&lt;/code&gt; window, if I open a file now at the project root, say &lt;code&gt;main.go&lt;/code&gt;, what opens is a buffer to a file located at &lt;code&gt;sub-folder/main.go&lt;/code&gt; instead of the file I selected in Explorer.  this buffer is blank.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT... if I close that buffer, change focus back to Explorer and select &lt;code&gt;main.go&lt;/code&gt; &lt;em&gt;again&lt;/em&gt;, now the correct file opens in a buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very annoying.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Explorer inconsistent in keeping sub-folders open&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Say I have &lt;code&gt;:Vex&lt;/code&gt; open with 3 sub-folders open.  Once I switch to a buffer and edit/save a file, if I switch back to the existing &lt;code&gt;:Vex&lt;/code&gt; that I still have open and select any other sub-folder:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The last sub-folder I opened collapses.  Often times, it is even the sub-folder I am in and I want to open yet a deeper sub-folder.&lt;/li&gt;&#xA;&lt;li&gt;The sub-folder I selected does not open.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What happens is I have to re-open the sub-folders I previously had opened.  But, not all.  Some reopen expanded.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no found any way to have Explore retain its own state of open folders, let me switch to Explorer and &lt;em&gt;explore further&lt;/em&gt; down the directory tree, without it collapsing everything else.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very annoying.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Summary&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Those are the biggest issues I have with Explore and it is seriously affecting my &lt;code&gt;vim mojo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last week I was code-pairing with a colleague and it horribly apparent how messed up this is.  I've been getting so used to working around this issues that when he saw all of these issues, he was so turned off from ever trying vim in the future.  &quot;I heard vim was pretty good; but wow, that's horrible man.  I couldn't stand it.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please tell me if this is common, in which case I'll switch to Nerdtree or alike.  Or, if this is just my setup.  In which case, how I would I debug?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using latest versions of vim and neovim from Homebrew.&lt;/p&gt;&#xA;" OwnerUserId="6413" LastEditorUserId="1841" LastEditDate="2016-04-27T05:27:19.973" LastActivityDate="2017-02-22T08:37:09.517" Title="Lots of Explore issues" Tags="|neovim|netrw|" AnswerCount="1" CommentCount="6" ClosedDate="2017-02-23T17:23:14.400" ContentLicense="CC BY-SA 3.0" />
  <row Id="7516" PostTypeId="2" ParentId="7514" CreationDate="2016-04-27T04:06:33.027" Score="5" Body="&lt;p&gt;It can definitely be simplified with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; H indent('.')+1 == col('.') ? '0' : '^'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; causes the map execute the expression on the &lt;code&gt;{rhs}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;indent('.')&lt;/code&gt; is the number of whitespace characters at the beginning of the line.  The character right after that would be the beginning of the line &lt;code&gt;^&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do the opposite:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; L col('.') == match(getline('.'), '\S\zs\s*$') ? '$' : 'g_'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if there's a better way, but &lt;code&gt;match(getline('.'), '\S\zs\s*$')&lt;/code&gt; finds the position of the last non-whitespace character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g_&lt;/code&gt; is a motion to go to the last non-whitespace character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for your script, you didn't really need to use the &lt;code&gt;execute&lt;/code&gt; statements since you weren't including variables.  They could've just been &lt;code&gt;normal! ^&lt;/code&gt; and &lt;code&gt;normal! 0&lt;/code&gt;.  Also, &lt;code&gt;normal! ^0&lt;/code&gt; is actually two motions: Move to the beginning of the line, then to the first column of the line.  The &lt;code&gt;^&lt;/code&gt; was redundant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, good job taking a stab at vim script.  It's not an easy language to learn &lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-04-27T12:59:35.790" LastActivityDate="2016-04-27T12:59:35.790" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="7517" PostTypeId="2" ParentId="7514" CreationDate="2016-04-27T04:34:51.083" Score="2" Body="&lt;p&gt;Here's another solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; H :call  search('\(^\s\+\)\@&amp;lt;=\S\\|^', 'b', line('.'))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's a bit convoluted but it works! :D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;search() will position your cursor at a given pattern. I've given it TWO patterns separated by &lt;code&gt;\|&lt;/code&gt; which means it will jump to the first one it finds. &lt;code&gt;\(^\s\+\)\@&amp;lt;=\S&lt;/code&gt; is a pattern that looks for the first non-whitespace character. (The look behind is necessary, because otherwise we would go to the first of the line.) &lt;code&gt;^&lt;/code&gt; Is a pattern looking for the beginning of the line (obviously). The &lt;code&gt;'b'&lt;/code&gt; is a flag telling search() to look backwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The one downside to this is that if you press &lt;code&gt;H&lt;/code&gt; While on the first character of the line, it will continue searching backwards. I tried to think of how to stop this, but nothing came to mind immediately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Fixed the multi-line problem by adding &lt;code&gt;line('.')&lt;/code&gt; to the search command. (Duh!)&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-07-15T19:23:06.503" LastActivityDate="2016-07-15T19:23:06.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7518" PostTypeId="2" ParentId="7492" CreationDate="2016-04-27T08:56:20.263" Score="2" Body="&lt;p&gt;I don't know where your &lt;code&gt;autoclose.vim&lt;/code&gt; comes from, but let say you use &lt;a href=&quot;https://github.com/Townk/vim-autoclose&quot; rel=&quot;nofollow&quot;&gt;this version&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Alexander Batischev said, your plugin must be put in the &lt;code&gt;plugin&lt;/code&gt; (or &lt;code&gt;autoload&lt;/code&gt;) directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should just be fine by running a &lt;code&gt;git clone ...&lt;/code&gt; or a copy/paste (inside the &lt;code&gt;bundle&lt;/code&gt; folder) if your plugin respect this architecture. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All plugin managers I know works the same way, and thus the plugin architecture should always be the following (not complete):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;plugin/          &quot; root&#xA;  |- plugin/     &quot; your plugin entry point, run on vim start&#xA;  |- autoload/   &quot; delayed plugin files loading&#xA;  |- doc/        &quot; your documentation files&#xA;  \  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Have a look at &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/42.html&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/43.html&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-04-27T08:56:20.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7519" PostTypeId="1" AcceptedAnswerId="7520" CreationDate="2016-04-27T11:26:03.653" Score="6" ViewCount="6385" Body="&lt;p&gt;&lt;code&gt;:set title&lt;/code&gt; enable the prompt of the title of the file in the window title.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I change the content of this title? For example, I want to give &lt;code&gt;My pattern&lt;/code&gt; before the filename every time it is edited.  How to modify or change the pattern of title through vim commands?&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="1841" LastEditDate="2016-04-27T11:34:46.387" LastActivityDate="2016-04-27T11:42:28.447" Title="How to change the title shown in the window top bar?" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7520" PostTypeId="2" ParentId="7519" CreationDate="2016-04-27T11:37:24.420" Score="11" Body="&lt;p&gt;As stated in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27title%27&quot;&gt;&lt;code&gt;:h title&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When on, the title of the window will be set to the value of&#xA;    'titlestring' (if it is not empty), or to:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;filename [+=-] (path) - VIM&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Where:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  filename    the name of the file being edited&#xA;  -       indicates the file cannot be modified, 'ma' off&#xA;  +       indicates the file was modified&#xA;  =       indicates the file is read-only&#xA;  =+      indicates the file is read-only and modified&#xA;  (path)      is the path of the file being edited&#xA;  - VIM       the server name |v:servername| or &quot;VIM&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you'll want to modify the content of &lt;code&gt;titlestring&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27titlestring%27&quot;&gt;&lt;code&gt;:h 'titlestring'&lt;/code&gt;&lt;/a&gt; for examples and explanations.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-27T11:42:28.447" LastActivityDate="2016-04-27T11:42:28.447" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7521" PostTypeId="1" CreationDate="2016-04-27T14:03:30.133" Score="1" ViewCount="684" Body="&lt;p&gt;Is it possible to assign a key combination to a snippet in Ultisnip?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried something hacky like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap KEYKOMBO iULTISNIPTRIGGER&amp;lt;TAB&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it doesn't trigger my snippet like it would, if I entered insert mode manually, then typed the Trigger-Word and pressed tab (which is the default Ultisnip keybinding for expanding).&lt;/p&gt;&#xA;" OwnerUserId="7421" LastEditorUserId="205" LastEditDate="2016-04-27T19:49:09.677" LastActivityDate="2016-04-27T19:49:09.677" Title="Assign keybinding to invoke my Ultisnip snippet" Tags="|key-bindings|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7522" PostTypeId="2" ParentId="7521" CreationDate="2016-04-27T14:37:42.967" Score="2" Body="&lt;p&gt;From documentation on &lt;code&gt;:nnoremap&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:no[remap]! {lhs} {rhs}&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[…] Disallow mapping of {rhs}, to avoid nested and recursive mappings.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But the whole point of your mapping is to use recursive mapping of &lt;kbd&gt;Tab&lt;/kbd&gt;! Use &lt;code&gt;:nmap&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, and even preferably, use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap KEYCOMBO iULTISNIPTRIGGER &amp;lt;esc&amp;gt;:call UltiSnips#ExpandSnippet()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(note the space after the trigger.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calling the function directly is better than invoking it through a key mapping, as it is resilient to the changes in the mappings—later on, you might remap UltiSnips to another key, but KEYCOMBO will keep working for as long as you have UltiSnips installed.&lt;/p&gt;&#xA;" OwnerUserId="7415" LastEditorUserId="7415" LastEditDate="2016-04-27T15:52:30.483" LastActivityDate="2016-04-27T15:52:30.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7523" PostTypeId="2" ParentId="7486" CreationDate="2016-04-27T15:02:47.800" Score="1" Body="&lt;p&gt;OK. I am answering it so that others who make the same mistake can correct it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the format you are trying to &lt;code&gt;Ctrl-A&lt;/code&gt; &lt;code&gt;Ctrl-X&lt;/code&gt; on is not defined in &lt;code&gt;:SpeedDatingFormat&lt;/code&gt; it will not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise it should.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case, there was a small error in the format.&lt;/p&gt;&#xA;" OwnerUserId="3095" LastActivityDate="2016-04-27T15:02:47.800" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7524" PostTypeId="1" AcceptedAnswerId="7525" CreationDate="2016-04-27T21:16:29.543" Score="3" ViewCount="195" Body="&lt;p&gt;I am trying to encapsulate variables with a method. For example, I am converting this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return variable1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return verify(variable1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to quickly repeat this action (ideally with the dot command or a macro of some sort) for other variables?&lt;/p&gt;&#xA;" OwnerUserId="7409" LastEditorUserId="1841" LastEditDate="2016-04-28T05:17:24.247" LastActivityDate="2016-04-28T07:53:40.007" Title="Is there a way to encapsulate a variable with a method with a repeatable action?" Tags="|vimscript|repeated-commands|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7525" PostTypeId="2" ParentId="7524" CreationDate="2016-04-27T21:42:51.740" Score="6" Body="&lt;p&gt;If you already have the &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow&quot;&gt;surround&lt;/a&gt; plugin, you can do &lt;code&gt;ysiwfverify&amp;lt;CR&amp;gt;&lt;/code&gt;. Tim Pope has another plugin called &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow&quot;&gt;repeat&lt;/a&gt; that lets you repeat surround commands with &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without any plugin or setup, you can simply do &lt;code&gt;ciwverify(&amp;lt;C-r&amp;gt;&amp;lt;C-o&amp;gt;&quot;)&amp;lt;Esc&amp;gt;&lt;/code&gt; and repeat with &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-04-28T05:46:43.287" LastActivityDate="2016-04-28T05:46:43.287" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7526" PostTypeId="2" ParentId="7481" CreationDate="2016-04-27T22:35:54.617" Score="6" Body="&lt;p&gt;Here is what worked for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First opening vim normally and doing &lt;code&gt;:scriptnames&lt;/code&gt; showed that, in fact, my &lt;code&gt;~/.vimrc&lt;/code&gt; &lt;em&gt;was&lt;/em&gt; sourced.  Other scripts were just overridding my indent settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moving just the lines pertaining to indentation from my &lt;code&gt;~/.vimrc&lt;/code&gt; into a new file at &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt; solved the problem.  The filename is crucial, and it is only executed when reading python files.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively put the file in &lt;code&gt;~/.vim/after/ftplugin/python/some-name.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7380" LastActivityDate="2016-04-27T22:35:54.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7527" PostTypeId="1" AcceptedAnswerId="7528" CreationDate="2016-04-27T23:24:08.640" Score="-1" ViewCount="1027" Body="&lt;p&gt;I'm wondering why vim is implemented using vimL? Is there other version of vim which is implemented with other modern language like python, javascript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know javascript and python, I just don't want to learn vimL, it looks too complex to me... sometimes I want to write a plugin for myself only find I need to learn vimL first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know vim somehow support writing plugins using python or other. But I just want to know if there's already a &quot;clean&quot; version that completely implemented using modern programming language?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastActivityDate="2016-04-28T00:31:41.893" Title="Is there a better version of vim which is not implemented in vimL?" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ClosedDate="2018-09-18T06:59:10.893" ContentLicense="CC BY-SA 3.0" />
  <row Id="7528" PostTypeId="2" ParentId="7527" CreationDate="2016-04-28T00:31:41.893" Score="10" Body="&lt;p&gt;Vim is &lt;em&gt;not&lt;/em&gt; implemented in VimL. Vim is implemented in C. As is NeoVim, a fork. Vim's &lt;em&gt;runtime&lt;/em&gt; features are written in VimL, but the core is C. There's no Vim implementation I know of that's in JavaScript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To write plugins in Vim, you have a few choices aside from VimL:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/if_lua.txt.html#if_lua.txt&quot;&gt;Lua&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/if_tcl.txt.html#if_tcl.txt&quot;&gt;TCL&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/if_perl.txt.html#if_perl.txt&quot;&gt;Perl&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/if_pyth.txt.html#if_pyth.txt&quot;&gt;Python&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/if_ruby.txt.html#if_ruby.txt&quot;&gt;Ruby&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/if_mzsch.txt.html#if_mzsch.txt&quot;&gt;Racket&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can get away with minimal knowledge of VimL, if you know one of these languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't like it, try another editor with Vim keybindings, like &lt;a href=&quot;https://github.com/atom/vim-mode&quot;&gt;Atom&lt;/a&gt; (which is written in JavaScript),  or maybe Sublime Text. But plugins written for Vim won't work there, so good luck!&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-04-28T00:31:41.893" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7529" PostTypeId="2" ParentId="7515" CreationDate="2016-04-28T02:31:02.527" Score="0" Body="&lt;ul&gt;&#xA;&lt;li&gt;May I suggest that you try the latest version of netrw: v157b, which you may get from &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#NETRW&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Ghost buffers -- unable to duplicate&lt;/li&gt;&#xA;&lt;li&gt;Launching...&#xA;Are you using the acd option?&#xA;What netrw options are you using; in particular, what is g:netrw_keepdir?&#xA;I've tried the procedure you mentioned five times now and never had the problem you had&lt;/li&gt;&#xA;&lt;li&gt;Explorer inconsistent...&#xA;Tried with three subfolders open, all just one level in, did a split, edit, save, switch to netrw -- no unwanted closures occurred.&#xA;Tried with with three nested subfolders open, did a split, edit, save, switch to netrw -- no unwanted closures occurred.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2016-04-28T02:31:02.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7530" PostTypeId="2" ParentId="82" CreationDate="2016-04-28T04:00:55.570" Score="9" Body="&lt;h2&gt;One option (what I currently use)&lt;/h2&gt;&#xA;&lt;p&gt;I don't use YouCompleteMe anymore. coc-clangd is much better and simpler.&lt;/p&gt;&#xA;&lt;p&gt;Today I use coc.nvim + coc-clangd instead.&lt;/p&gt;&#xA;&lt;h2&gt;Another option (what I used to use)&lt;/h2&gt;&#xA;&lt;p&gt;YouCompleteMe isn't that hard to install, and it has been quite stable for me, I've migrated from clang_complete to YouCompleteMe years ago. One thing I agree, it's indeed bloated with a huge commit history, many internal dependencies and support for many languages you may not care for but still will end up cloning its associated submodules. That, that's an issue with YouComplemeMe, still.... it does the work.&lt;/p&gt;&#xA;&lt;p&gt;I've &lt;a href=&quot;https://github.com/oblitum/YouCompleteMe&quot; rel=&quot;nofollow noreferrer&quot;&gt;worked on a fork&lt;/a&gt; with special purpose to better support C++, you may check this gif showing it off:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XorzK.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XorzK.gif&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://s3.amazonaws.com/f.cl.ly/items/1e2F0A123h331c1G0L0R/SadBart.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://s3.amazonaws.com/f.cl.ly/items/1e2F0A123h331c1G0L0R/SadBart.gif&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It leverages new parameter information that Clang is able to provide, you may learn more about this from this article of mine: &lt;a href=&quot;http://nosubstance.me/articles/2015-01-29-better-completion-for-cpp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://nosubstance.me/articles/2015-01-29-better-completion-for-cpp/&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;" OwnerUserId="6324" LastEditorUserId="10604" LastEditDate="2021-11-08T15:39:25.253" LastActivityDate="2021-11-08T15:39:25.253" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7531" PostTypeId="2" ParentId="7524" CreationDate="2016-04-28T07:33:49.377" Score="2" Body="&lt;p&gt;Another solution is to use macros (I love macros!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First put &lt;code&gt;return&lt;/code&gt; in the search register: &lt;code&gt;/return&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;:let @/=&quot;return&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then record your macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqnwiverify(&amp;lt;Esc&amp;gt;ea)q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which can be decomposed like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq start recording in the register q&#xA;n  go to the next occurence of the word in the search register (here 'return')&#xA;w  go to the beginning of the word following 'return'&#xA;i  enter insert mode&#xA;verify( input the function which will encapsulate your variable&#xA;e  go to the end of the word after the bracket&#xA;a  enter insert mode after the word&#xA;)  input the closing bracket&#xA;q  stop recording&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then execute the macro with &lt;code&gt;@q&lt;/code&gt; and repeat it with &lt;code&gt;@@&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; Thanks to @Nobe4 you can even make it one keystroke shorter this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqnwiverify(&amp;lt;c-o&amp;gt;w)q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; allows to go into normal mode for only one command and then go back automatically to insert mode.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-04-28T07:53:40.007" LastActivityDate="2016-04-28T07:53:40.007" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7532" PostTypeId="2" ParentId="7495" CreationDate="2016-04-28T09:35:18.543" Score="2" Body="&lt;p&gt;Your problem was fixed with &lt;a href=&quot;https://github.com/vim/vim/commit/9de999794999de1ccd3d743a2d5b361e5ce19273#diff-b506883eec17ba92662bbe9b001626ff&quot; rel=&quot;nofollow&quot;&gt;an update to &lt;code&gt;runtime/indent/perl.vim&lt;/code&gt;&lt;/a&gt; for 7.4: they reworked the indentation logic for heredocs and stuff that follows it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can &lt;a href=&quot;https://raw.githubusercontent.com/vim/vim/9de999794999de1ccd3d743a2d5b361e5ce19273/runtime/indent/perl.vim&quot; rel=&quot;nofollow&quot;&gt;download the file&lt;/a&gt; and put it into &lt;code&gt;~/.vim/after/indent/perl.vim&lt;/code&gt; (or into correspoding global dir).&lt;/p&gt;&#xA;" OwnerUserId="7415" LastActivityDate="2016-04-28T09:35:18.543" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7533" PostTypeId="2" ParentId="6660" CreationDate="2016-04-28T11:22:40.377" Score="3" Body="&lt;p&gt;To elaborate on the &lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;Christian Brabandt&lt;/a&gt;'s comment, here is a decomposition of the &lt;code&gt;DiffOrig&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis&#xA;    \ | wincmd p | diffthis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command DiffOrig        &quot; create a new command named DiffOrig&#xA;vert new                &quot; open a new buffer splitted vertically&#xA;| set bt=nofile         &quot; set buffer type to scratch &#xA;| r #                   &quot; read the alternate buffer (opened file to diff)&#xA;| 0d_                   &quot; delete the first line&#xA;| diffthis              &quot; diff the current buffer&#xA;| wincmd p              &quot; move cursor to opened file &#xA;| diffthis              &quot; diff the current buffer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An alternate version use the &lt;code&gt;++edit&lt;/code&gt; option for the read, it keeps the options values as if editing a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#vert&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h vert&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27bt%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'bt'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#read&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h read&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#++edit&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ++edit&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/diff.html#diffthis&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h diffthis&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#wincmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h wincmd&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-04-28T11:22:40.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7535" PostTypeId="1" AcceptedAnswerId="7540" CreationDate="2016-04-28T14:43:49.517" Score="2" ViewCount="170" Body="&lt;p&gt;So I have an input, something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let dir = input(&quot;What is the directory you're looking for? &quot;, &quot;&quot;, &quot;dir&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works great for typing and and getting directory input. But what if the path was really long and I want to run the command again? Normally I would just press &lt;kbd&gt; ↑ &lt;/kbd&gt; for command line recall, however when I do this it simply tries to complete a directory which is not what I want. I want &lt;kbd&gt;Tab&lt;/kbd&gt; to complete directories, and &lt;kbd&gt; ↑ &lt;/kbd&gt; to do command line recall. Is there any way to get this behavior without defining a custom completion function?&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="205" LastEditDate="2016-04-30T05:38:45.403" LastActivityDate="2016-04-30T05:38:45.403" Title="How to get an Input() with directory completion and command line recall?" Tags="|command-line|autocompletion|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7536" PostTypeId="1" AcceptedAnswerId="7537" CreationDate="2016-04-28T16:09:38.093" Score="1" ViewCount="520" Body="&lt;p&gt;I've got a list of files that I want to copy from one place to another, I need to change the name slightly and I'd rather copy the file names instead of typing them over and over again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do &lt;code&gt;YP&lt;/code&gt; I copy the entire line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best I can come up with is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;yEP&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;or &lt;code&gt;VEyP&lt;/code&gt; which I like a bit more because I can see the whitespace I'm about to muck up ahead of time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But is there an even easier key combo that doesn't require thinking about what I'm doing to accomplish?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;root root 640 /path/to/file/1&#xA;root me 530 /path/to/file/2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;root root 640 path_to_file_1 /path/to/file/1&#xA;root me 530 path_to_file_2 /path/to/file/2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;because I'm editing a script that'll copy a lot of files flattened into this directory into many other directories. &lt;/p&gt;&#xA;" OwnerUserId="1532" LastEditorUserId="1821" LastEditDate="2016-04-28T16:44:46.607" LastActivityDate="2016-04-28T16:44:46.607" Title="Can I yank from the current position of the cursor to the end of the line without the newline?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7537" PostTypeId="2" ParentId="7536" CreationDate="2016-04-28T16:13:52.127" Score="10" Body="&lt;p&gt;Does&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not solve your problem?&lt;br&gt;&#xA;Yank to the end of line.&lt;/p&gt;&#xA;" OwnerUserId="383" LastActivityDate="2016-04-28T16:13:52.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7538" PostTypeId="1" AcceptedAnswerId="7539" CreationDate="2016-04-28T17:04:18.713" Score="7" ViewCount="2223" Body="&lt;p&gt;Suppose I have the following piece of code through which I would like to navigate&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;===&amp;gt;Cursor is here and when I press {&#xA;    SomeTest&#xA;    {&#xA;       line1&#xA;       line2&#xA;       line3&#xA;&#xA;       line4&#xA;            =====&amp;gt;it ends up here&#xA;       line 5&#xA;    }&#xA;   ====&amp;gt;Cursor should end up here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like the cursor which is on top of &lt;code&gt;SomeTest&lt;/code&gt; statement to go at the end of the code paragraph. Normally I would use &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; to skip to the next paragraph. However the presence of blank lines before line4 and line 5 make this technique fail. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does having a single blank line above and below line 4 move the cursor there. What can I do to fix this ? What does Vim consider a paragraph ? I know I could use &lt;code&gt;]}&lt;/code&gt;to go the ending or beginning if I am inside the function. What I would like to do is jump through the function from top to the bottom and not going inside the function?&lt;/p&gt;&#xA;" OwnerUserId="7053" LastEditorUserId="205" LastEditDate="2016-04-29T01:47:53.163" LastActivityDate="2016-04-29T09:35:56.230" Title="What does vim consider a paragragh?" Tags="|cursor-motions|whitespace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7539" PostTypeId="2" ParentId="7538" CreationDate="2016-04-28T17:08:24.123" Score="9" Body="&lt;p&gt;You may want to move to the next section:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Documentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h paragraph&#xA;A paragraph begins after each empty line, and also at each of a set of&#xA;paragraph macros, specified by the pairs of characters in the 'paragraphs' option. &#xA;&#xA;:h section&#xA;A section begins after a form-feed (&amp;lt;C-L&amp;gt;) in the first column and at each of&#xA;a set of section macros, specified by the pairs of characters in the&#xA;'sections' option.  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-04-29T09:35:56.230" LastActivityDate="2016-04-29T09:35:56.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7540" PostTypeId="2" ParentId="7535" CreationDate="2016-04-28T17:41:44.287" Score="3" Body="&lt;p&gt;If you simply want to recall the last text given as an argument to &lt;code&gt;input()&lt;/code&gt;, you could try the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;Up&amp;gt; getcmdtype() ==# '@' ? '&amp;lt;C-E&amp;gt;&amp;lt;C-U&amp;gt;' . histget('@') : '&amp;lt;Up&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be broken down like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;: type the evaluation of an expression&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;getcmdtype() ==# '@'&lt;/code&gt;: check whether you are on the input line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;lt;C-E&amp;gt;&amp;lt;C-U&amp;gt;' . histget('@')&lt;/code&gt;: if the previous test succeeded, hit &lt;code&gt;&amp;lt;C-E&amp;gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; to clear the input line, then type the last entry from the input history (&lt;code&gt;histget('@')&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;lt;Up&amp;gt;'&lt;/code&gt;: otherwise, if you are somewhere else (command-line, expression register, search ...), simply hit &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to navigate across all the entries of the input history, you could try the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:input_hist_index=0&#xA;&#xA;function! s:InputHistory(dir) abort&#xA;    let s:input_hist_index += a:dir&#xA;    return &quot;\&amp;lt;C-E&amp;gt;\&amp;lt;C-U&amp;gt;&quot; . histget('@', s:input_hist_index)&#xA;endfunction&#xA;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;Up&amp;gt; getcmdtype() ==# '@' ? &amp;lt;SID&amp;gt;InputHistory(-1) : '&amp;lt;Up&amp;gt;'&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;Down&amp;gt; getcmdtype() ==# '@' ? &amp;lt;SID&amp;gt;InputHistory(1) : '&amp;lt;Down&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's similar to the previous mapping, except it must track where you are in the input history, hence the script-local variable &lt;code&gt;s:input_hist_index&lt;/code&gt;. There may be another way of doing it, maybe a native function, but I didn't find one in &lt;code&gt;:h history-functions&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can get more information with the following help topics:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h &amp;lt;expr&amp;gt;&#xA;:h getcmdtype()&#xA;:h histget()&#xA;:h c_ctrl-e&#xA;:h c_ctrl-u &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-04-30T00:13:55.520" LastActivityDate="2016-04-30T00:13:55.520" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7541" PostTypeId="2" ParentId="5123" CreationDate="2016-04-28T19:49:11.527" Score="2" Body="&lt;p&gt;You could create an alias that sets your &lt;code&gt;$TERM&lt;/code&gt; variable&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vi='TERM=rxvt-unicode-256color vi'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add that to your shell's rc file and it should be defined for every terminal you launch.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-04-28T19:49:11.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7542" PostTypeId="1" AcceptedAnswerId="7679" CreationDate="2016-04-28T20:01:52.140" Score="3" ViewCount="100" Body="&lt;p&gt;I want to use external &lt;code&gt;tr&lt;/code&gt; command on a line in &lt;code&gt;Vim&lt;/code&gt;. When the source or replace pattern includes Farsi numbers the result is unpredictable.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Executing &lt;code&gt;:.!tr 1 ۱&lt;/code&gt; on &lt;code&gt;1&lt;/code&gt; results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Û&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Executing &lt;code&gt;:.!tr ۱ 1&lt;/code&gt; on &lt;code&gt;۱&lt;/code&gt; results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;11&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Executing &lt;code&gt;:.!tr 12345 ۱۲۳۴۵&lt;/code&gt; on &lt;code&gt;12345&lt;/code&gt; results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Û±Û²Û&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;tr&lt;/code&gt; command works correctly in the shell with those parameters. How can I fix this (if it is not a bug)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the output of &lt;code&gt;vim --version&lt;/code&gt; on my OS X 10.11.4:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; $ vim --version&#xA; VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 22 2016 04:36:23)&#xA; MacOS X (unix) version&#xA; Included patches: 1-1755&#xA; Compiled by Homebrew&#xA; Huge version without GUI.  Features included (+) or not (-):&#xA; +acl             +farsi           +mouse_netterm   +tag_binary&#xA; +arabic          +file_in_path    +mouse_sgr       +tag_old_static&#xA; +autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white&#xA; -balloon_eval    +float           +mouse_urxvt     -tcl&#xA; -browse          +folding         +mouse_xterm     +terminfo&#xA; ++builtin_terms  -footer          +multi_byte      +termresponse&#xA; +byte_offset     +fork()          +multi_lang      +textobjects&#xA; +channel         -gettext         -mzscheme        +timers&#xA; +cindent         -hangul_input    +netbeans_intg   +title&#xA; -clientserver    +iconv           +packages        -toolbar&#xA; +clipboard       +insert_expand   +path_extra      +user_commands&#xA; +cmdline_compl   +job             +perl            +vertsplit&#xA; +cmdline_hist    +jumplist        +persistent_undo +virtualedit&#xA; +cmdline_info    +keymap          +postscript      +visual&#xA; +comments        +langmap         +printer         +visualextra&#xA; +conceal         +libcall         +profile         +viminfo&#xA; +cryptv          +linebreak       +python          +vreplace&#xA; +cscope          +lispindent      -python3         +wildignore&#xA; +cursorbind      +listcmds        +quickfix        +wildmenu&#xA; +cursorshape     +localmap        +reltime         +windows&#xA; +dialog_con      -lua             +rightleft       +writebackup&#xA; +diff            +menu            +ruby            -X11&#xA; +digraphs        +mksession       +scrollbind      -xfontset&#xA; -dnd             +modify_fname    +signs           -xim&#xA; -ebcdic          +mouse           +smartindent     -xsmp&#xA; +emacs_tags      -mouseshape      +startuptime     -xterm_clipboard&#xA; +eval            +mouse_dec       +statusline      -xterm_save&#xA; +ex_extra        -mouse_gpm       -sun_workshop    -xpm&#xA; +extra_search    -mouse_jsbterm   +syntax&#xA;    system vimrc file: &quot;$VIM/vimrc&quot;&#xA;      user vimrc file: &quot;$HOME/.vimrc&quot;&#xA;  2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;       user exrc file: &quot;$HOME/.exrc&quot;&#xA;   fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA; Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA; Linking: /usr/bin/clang   -L. -L/usr/local/lib -L/usr/local/lib -Wl,-headerpad_max_install_names -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python   -lruby.2.0.0 -lobjc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7357" LastActivityDate="2016-05-07T11:21:03.433" Title="Why using external &quot;tr&quot; command on lines with Farsi numbers does not work correctly?" Tags="|external-command|unicode|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7543" PostTypeId="1" AcceptedAnswerId="7544" CreationDate="2016-04-29T06:27:39.547" Score="2" ViewCount="452" Body="&lt;p&gt;I'm using Vim on Ubuntu 14.04 LTS. I've been confused by these two situations and I think they might have common cause:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open a text file in vim and paste some content that I copied from web browser using right click then paste, the pasted content cannot be recognized by the program that's supposed to process the text file anymore. Supposedly the program reads the entry from the text file and make this entries available to other programs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ornAna1 Platypus Mar. 2007 (WUGSC 5.0.1/ornAna1) (ornAna1)&#xA;galGal2 Chicken Feb. 2004 (WUGSC 1.0/galGal2) (galGal2)&#xA;galGal3 Chicken May 2006 (WUGSC 2.1/galGal3) (galGal3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I deleted the line starting with galGal2 manually and typed in new content so that it becomes the following, it can be recognized by the program correctly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ornAna1 Platypus Mar. 2007 (WUGSC 5.0.1/ornAna1) (ornAna1)&#xA;galGal4 Chicken Nov. 2011 (ICGSC Gallus_gallus-4.0/galGal4) (galGal4)&#xA;galGal3 Chicken May 2006 (WUGSC 2.1/galGal3) (galGal3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I paste the galGal4 line from web browser, then that line is skipped by the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then in a shell script, a similar situation happened. &#xA;I have a code block that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python2 -c &quot;import pip&quot; &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &#xA;if [[ $? -eq 0 ]]; then&#xA;    echo &quot;pip is installed&quot;&#xA;elif [[ $? -eq 1 ]]; then&#xA;    echo &quot;pip is not installed&quot;&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I type the whole thing in, then this part of the script works fine. If I copy this from an indented block within the shell script, by highlighting the texts and right click copy, then right click paste, then somehow this part doesn't seem to be executed at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be the cause of these problems? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update : While I'm certain that the problem with shell script (copying from indented text and pasting in the same file somewhere else) happened once, I wasn't able to reproduce it. There's a chance that it's a temporary glitch.  &lt;/p&gt;&#xA;" OwnerUserId="7444" LastEditorUserId="7444" LastEditDate="2016-04-29T10:00:57.447" LastActivityDate="2016-04-29T10:00:57.447" Title="Why does pasting screw up my text file and shell script?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="7544" PostTypeId="2" ParentId="7543" CreationDate="2016-04-29T09:25:17.940" Score="4" Body="&lt;p&gt;After a thorough discussion with OP and alexander-batischev, the issue was massively related to the way google doc handle quotation marks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has two mode, basic and smart quotes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;‘smart quote’ &#xA;'basic quote'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After investigating the pasting with &lt;a href=&quot;http://linuxcommand.org/man_pages/xxd1.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;xdd&lt;/a&gt;, we saw the pasting was done using the smart quotes instead of the basic ones (first line is basic, second is smart quotes):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ xxd&#xA;'a'&#xA;‘a’&#xA;0000000: 2761 270a e280 9861 e280 990a            'a'....a....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a post explaining how to change this config: &lt;a href=&quot;https://webapps.stackexchange.com/questions/63237/how-do-i-change-google-docs-default-quotation-symbols&quot;&gt;how-do-i-change-google-docs-default-quotation-symbols&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:57:24.870" LastActivityDate="2016-04-29T09:32:41.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7545" PostTypeId="1" AcceptedAnswerId="11100" CreationDate="2016-04-29T15:03:18.250" Score="0" ViewCount="1025" Body="&lt;p&gt;I now use Spacemacs Hybrid mode for local files but I often have to SSH into older machines that either do not have a modern Emacs (24) or only have Vim installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus I have gotten used to editing with vanilla Vim on these remote machines. That being said I have been aiming for some consistency these days and would like some of the Helm-like SPC leader key things to work on Vim so I was curious if anyone knows of a plugin for Vim out there that somewhat matches spacemacs (ie &lt;kbd&gt;space&lt;/kbd&gt;&lt;kbd&gt;b&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; instead of &lt;code&gt;:bd&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already have vimacs installed for my messed up &quot;hybrid&quot; mind. Just need the leader key mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR: make Vim a little more like spacemacs.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="10930" OwnerDisplayName="Adam Gent" LastEditorUserId="1841" LastEditDate="2016-05-01T09:16:19.873" LastActivityDate="2017-01-25T04:25:33.703" Title="Emulate some of spacemacs leader keys in Vim" Tags="|key-bindings|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7546" PostTypeId="1" CreationDate="2016-04-29T17:47:30.373" Score="0" ViewCount="443" Body="&lt;p&gt;For example if I have a line at the beginning of the screen and in the opened file there are other lines above it so the screen is not at the beginning of the file (it is scrolled down), if I go to that line and use a command I should see that line in the middle of the screen or as close as possible to the middle of the screen.&lt;/p&gt;&#xA;" OwnerUserId="5010" LastEditorUserId="205" LastEditDate="2016-05-03T08:16:46.803" LastActivityDate="2016-05-03T08:16:46.803" Title="How to move the line under the cursor to the middle of the screen by scrolling (not automatic)?" Tags="|vimscript|cursor-movement|scrolling|" AnswerCount="2" CommentCount="1" ClosedDate="2016-05-03T08:17:29.043" ContentLicense="CC BY-SA 3.0" />
  <row Id="7547" PostTypeId="2" ParentId="7546" CreationDate="2016-04-29T17:47:30.373" Score="0" Body="&lt;p&gt;In the page to which I offered a link in the old answer below I just had to look harder to find the &lt;code&gt;zz&lt;/code&gt; command which does exactly the same thing.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Old answer&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ended up using a solution inspired from &lt;a href=&quot;http://vim.wikia.com/wiki/Keep_your_cursor_centered_vertically_on_the_screen&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; by putting these lines in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use &amp;lt;F5&amp;gt; to scroll the current line to the middle of the screen&#xA;inoremap &amp;lt;F5&amp;gt; &amp;lt;Esc&amp;gt;:set so=999&amp;lt;CR&amp;gt;:set so=0&amp;lt;CR&amp;gt;i&#xA;nnoremap &amp;lt;F5&amp;gt; :set so=999&amp;lt;CR&amp;gt;:set so=0&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5010" LastEditorUserId="5010" LastEditDate="2016-04-29T18:07:23.820" LastActivityDate="2016-04-29T18:07:23.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7548" PostTypeId="2" ParentId="7546" CreationDate="2016-04-29T18:12:56.630" Score="3" Body="&lt;p&gt;Is &lt;code&gt;zz&lt;/code&gt; not what you're looking for?&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-04-29T18:12:56.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7549" PostTypeId="1" CreationDate="2016-04-29T19:12:17.353" Score="1" ViewCount="520" Body="&lt;p&gt;I want to be able to do this because I am used from other editors to use the cursor as a visual bookmark, so that after scrolling by letting the cursor off screen I can come back to its place later. I know that in Vim I can use marks but I think that when using a mouse to scroll it is more easy to put the cursor in a place and let yourself know the cursor remains there when scrolling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A similar question is &lt;a href=&quot;https://vi.stackexchange.com/q/202/5010&quot;&gt;this&lt;/a&gt;, but my question is different. Another acceptably similar question is &lt;a href=&quot;https://vi.stackexchange.com/q/6005/5010&quot;&gt;this&lt;/a&gt; but it is not very clearly similar and it has a single answer which is the accepted one and is not useful when put to my question.&lt;/p&gt;&#xA;" OwnerUserId="5010" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-04-29T22:45:47.083" Title="How to scroll without forcing the cursor on screen (by letting the cursor off screen)?" Tags="|vimscript|scrolling|cursor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7550" PostTypeId="1" CreationDate="2016-04-29T20:35:45.973" Score="1" ViewCount="100" Body="&lt;pre&gt;&lt;code&gt;command! -nargs=0 -bar UpdateBuff if empty(bufname('%'))&#xA;                           \|        browse confirm write&#xA;                           \|    else&#xA;                           \|        confirm write&#xA;                           \|    endif&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;A-s&amp;gt; :&amp;lt;C-u&amp;gt;UpdateBuff&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;A-q&amp;gt; :wqa&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;A-h&amp;gt; :SidewaysLeft&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;A-l&amp;gt; :SidewaysRight&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have mapped some of the useful commands to &lt;kbd&gt;Alt&lt;/kbd&gt; key, because it's easy to reach on my Windows keyboard on Linux. Macs, however, have &lt;kbd&gt;Command&lt;/kbd&gt; on this position, so on Mac I'd like to use &lt;kbd&gt;Command&lt;/kbd&gt; instead of &lt;kbd&gt;Alt&lt;/kbd&gt; in this mappings.&#xA;I know that I probably can configure it manually for each mapping, with &lt;code&gt;has('mac')&lt;/code&gt;, but this would be tedious and stupid. Is there a better way?&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="205" LastEditDate="2016-04-30T04:31:17.257" LastActivityDate="2016-04-30T05:05:59.377" Title="How do I make key mappings for both OS X and Linux?" Tags="|key-bindings|macos|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7551" PostTypeId="2" ParentId="7549" CreationDate="2016-04-29T22:45:47.083" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I am used from other editors to use the cursor as a visual bookmark, so that after scrolling by letting the cursor off screen I can come back to its place later.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you're just scrolling through the file and want to bookmark specific place, there's really no way around using Vim's marks. Sorry about that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you want to bookmark a place where you're editing (e.g. to quickly scroll and reference some other part of the text, then jump back and keep editing), Vim has got two niceties for you! It saves your last editing position as &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#&amp;#39;%5E&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'^&lt;/code&gt; mark&lt;/a&gt;, and it provides a &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#gi&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;gi&lt;/code&gt; command&lt;/a&gt; to quickly start Insert mode at that mark. Using those is labor-free and should cover at least part of your use-cases.&lt;/p&gt;&#xA;" OwnerUserId="7415" LastActivityDate="2016-04-29T22:45:47.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7552" PostTypeId="1" AcceptedAnswerId="7553" CreationDate="2016-04-30T00:32:19.830" Score="2" ViewCount="418" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;When I execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;normal! \&amp;lt;c-o&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;, it works as expected (it jumps to the previous cursor location).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;But when I execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;normal! \&amp;lt;c-i&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;, it outputs the &lt;code&gt;E471&lt;/code&gt; error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E471: Argument required&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then I need to prepend with &lt;code&gt;1&lt;/code&gt; to make it work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;normal! 1\&amp;lt;c-i&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is it a normal behaviour?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note I'm using vim-gtk (graphical).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim version : 7.4&lt;br&gt;&#xA;Rustines : 1-1689&lt;/p&gt;&#xA;" OwnerUserId="5516" LastEditorUserId="5516" LastEditDate="2016-04-30T01:43:03.557" LastActivityDate="2016-04-30T04:43:32.233" Title="Weird behaviour with &lt;c-i&gt; and :normal" Tags="|normal-mode|jumplist|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7553" PostTypeId="2" ParentId="7552" CreationDate="2016-04-30T00:57:08.763" Score="6" Body="&lt;p&gt;Yes I think it's a normal behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;:help keycode&lt;/code&gt;, you can read that &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; have the same decimal keycode (&lt;code&gt;9&lt;/code&gt;):  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Tab&amp;gt;       tab         CTRL-I    9 *tab* *Tab*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means that Vim and gVim can't make the difference between the two keys.&lt;br&gt;&#xA;You can find a technical reason for this &lt;a href=&quot;http://vim.1045645.n5.nabble.com/how-to-map-tab-and-c-i-independently-tp1185417p1185428.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;&quot;\&amp;lt;C-I&amp;gt;&quot;&lt;/code&gt; is translated into a literal tab character.&lt;br&gt;&#xA;After the translation, Vim probably parses the tab as a syntax character separating a command from its arguments (here &lt;code&gt;:normal&lt;/code&gt; from &lt;code&gt;{commands}&lt;/code&gt;) ; like a space.&lt;br&gt;&#xA;Since there's nothing after your tab, Vim doesn't pass anything to &lt;code&gt;:normal&lt;/code&gt;, and the latter complains with the error &lt;code&gt;E471: Argument required&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is given in &lt;code&gt;:help :normal&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    {commands} cannot start with a space.  Put a count of&#xA;    1 (one) before it, &quot;1 &quot; is one space.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have to prefix the &lt;code&gt;{commands}&lt;/code&gt; with &lt;code&gt;1&lt;/code&gt; when they begin with a space (and probably with a tab).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hitting &lt;kbd&gt;1&lt;/kbd&gt; then &lt;kbd&gt;Ctrl-I&lt;/kbd&gt; in normal mode has the same effect as hitting &lt;kbd&gt;Ctrl-I&lt;/kbd&gt; alone.&lt;br&gt;&#xA;But here on the command-line, by prefixing &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt; with a count, you prevent Vim from parsing it as a syntax character, but rather as a part of the argument &lt;code&gt;{commands}&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-04-30T04:43:32.233" LastActivityDate="2016-04-30T04:43:32.233" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7554" PostTypeId="2" ParentId="7550" CreationDate="2016-04-30T05:05:59.377" Score="2" Body="&lt;p&gt;The following function is a start; it will probably fail on a number of cases. You can build off it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyMap (...)&#xA;    let l:i = 0&#xA;    if a:0 &amp;gt; 2&#xA;        let l:opt = a:1&#xA;        let l:i += 1&#xA;    endif&#xA;    let l:key = a:000[i]&#xA;    let l:action = a:000[i+1]&#xA;&#xA;    let l:mod = 'A'&#xA;    if has('mac')&#xA;        let l:mod = 'D'&#xA;    endif&#xA;    echo 'nnoremap' l:opt printf('&amp;lt;%s-%s&amp;gt;', l:mod, l:key) l:action&#xA;    exe 'nnoremap' l:opt printf('&amp;lt;%s-%s&amp;gt;', l:mod, l:key) l:action&#xA;endfunction&#xA;&#xA;command! -na=+ MyMap call MyMap(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A break down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;function! MyMap (...)&lt;/code&gt; defines a function that takes a variable number of arguments. From &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#...&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h ...&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                        a:0 a:1 a:000 E740 ...&#xA;Up to 20 arguments can be given, separated by commas.  After the named&#xA;arguments an argument &quot;...&quot; can be specified, which means that more arguments&#xA;may optionally be following.  In the function the extra arguments can be used&#xA;as &quot;a:1&quot;, &quot;a:2&quot;, etc.  &quot;a:0&quot; is set to the number of extra arguments (which&#xA;can be 0).  &quot;a:000&quot; is set to a List that contains these arguments.  Note&#xA;that &quot;a:1&quot; is the same as &quot;a:000[0]&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;Next we check if we have more than two arguments, and if so, use the first one as special arguments to &lt;code&gt;nnoremap&lt;/code&gt;. The other arguments are the key and the action.&lt;/li&gt;&#xA;&lt;li&gt;Next, we set the modifier used to be &lt;code&gt;A&lt;/code&gt; (or &lt;kbd&gt;Alt&lt;/kbd&gt;) as a default, and change it to &lt;code&gt;D&lt;/code&gt; (or &lt;kbd&gt;Command&lt;/kbd&gt;) if &lt;code&gt;has('mac')&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Then we use &lt;code&gt;execute&lt;/code&gt; to create and run the &lt;code&gt;nnoremap&lt;/code&gt; command. &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#printf%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;printf('&amp;lt;%s-%s&amp;gt;', l:mod, l:key)&lt;/code&gt;&lt;/a&gt; will give &lt;code&gt;&amp;lt;A-x&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;D-x&amp;gt;&lt;/code&gt; accordingly.&lt;/li&gt;&#xA;&lt;li&gt;Finally we define a command to wrap the function. &lt;code&gt;&amp;lt;f-args&amp;gt;&lt;/code&gt; splits the arguments on spaces and tabs, so be careful about those.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can run the command like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyMap &amp;lt;silent&amp;gt; q :wqa&amp;lt;cr&amp;gt;:H&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, if additional special arguments are used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyMap &amp;lt;silent&amp;gt;\ &amp;lt;buffer&amp;gt; q :wqa&amp;lt;cr&amp;gt;:H&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-04-30T05:05:59.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7555" PostTypeId="2" ParentId="6970" CreationDate="2016-04-30T06:06:29.877" Score="1" Body="&lt;p&gt;Judging from your comment above, you want to use only &lt;code&gt;cinoptions&lt;/code&gt; to control the indent for square brackets.  It simply wasn't possible before 7.4.355 from what I see in the &lt;a href=&quot;https://github.com/vim/vim/blob/dc633cf82758f67f656cda7fa8ccc30414ee53f8/src/misc1.c#L8484&quot; rel=&quot;nofollow&quot;&gt;source code&lt;/a&gt;.  Click blame up top to see the tagged version, but it's going take a while to load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since it looks like &lt;code&gt;cinoptions&lt;/code&gt; was originally for C, C++, and Java, it only dealt with curly braces and parenthesis because square brackets are used for defining array sizes or accessing indexes in those languages－not initializing them.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What controls the indentation of the lines between square brackets as well as the placement of the closing square bracket?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After 7.4.355, it's the &lt;code&gt;J&lt;/code&gt; option that controls the indentation, but nothing specifically for square brackets.  From what I glossed over in the source, the &lt;code&gt;J&lt;/code&gt; option only signifies that JavaScript syntax should be considered (&lt;code&gt;curbuf-&amp;gt;b_ind_js&lt;/code&gt;).  It looks for a previous line that's terminated by a comma or opening bracket to line up with.  In your fourth example, the line ends with a &lt;code&gt;1&lt;/code&gt;, so it doesn't increase the indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the first line in your fourth example ended with a &lt;code&gt;[&lt;/code&gt; or &lt;code&gt;,&lt;/code&gt; (or both &lt;code&gt;[,&lt;/code&gt;) the subsequent lines would increase the indent.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-04-30T06:06:29.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7556" PostTypeId="1" AcceptedAnswerId="7557" CreationDate="2016-04-30T06:35:28.793" Score="4" ViewCount="1966" Body="&lt;p&gt;I am trying to map &lt;code&gt;q&lt;/code&gt; in vi (not Vim) to find a pattern and replace it with newline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Name1 Name2 Name3 Name4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Name1&#xA;Name2&#xA;Name3&#xA;Name4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try ([Ctrl-V] and [Enter] are actual keystrokes)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map q :%s/Name. /[Ctrl-V][Enter]&amp;amp;/g[Ctrl-V][Enter]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It fails, since it considers the first [Ctrl-V][Enter] itself as enter. I don't know how to make it a literal newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have read &lt;a href=&quot;https://unix.stackexchange.com/questions/91484/carriage-return-vs-newline-in-vim&quot;&gt;Carriage return vs newline in vim&lt;/a&gt; and it suggests using &lt;code&gt;\r&lt;/code&gt; for newline while replacing. This seems only to work in Vim and does not work under vi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help.&lt;/p&gt;&#xA;" OwnerUserId="7457" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2016-04-30T08:58:18.613" Title="How do I map a key to search for a pattern and replace it with newline in ex/vi?" Tags="|ex-mode|original-vi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7557" PostTypeId="2" ParentId="7556" CreationDate="2016-04-30T08:32:48.453" Score="3" Body="&lt;p&gt;This will be a bit convoluted, but, try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map q :%s/Name. /\^V^V^M&amp;amp;/g^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each &lt;code&gt;^&lt;em&gt;x&lt;/em&gt;&lt;/code&gt; is produced by pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;&lt;em&gt;x&lt;/em&gt;&lt;/kbd&gt;, so the actual sequence here is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; for the first &lt;code&gt;^V&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; for the second &lt;code&gt;^V&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; &lt;kbd&gt;Enter&lt;/kbd&gt; for the first &lt;code&gt;^M&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;And again for the last &lt;code&gt;^M&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://ex-vi.sourceforge.net/ex.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;man ex&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Lines may be split by substituting new-line characters into them. The&#xA;  newline in repl must be escaped by preceding it with a '\'. Other&#xA;  metacharacters available in pat and repl are described below.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And from &lt;a href=&quot;http://ex-vi.sourceforge.net/viin/paper-6.html#section42&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;An Introduction to Display Editing with Vi&lt;/em&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can use the map command from &lt;em&gt;vi&lt;/em&gt; (typically in your &lt;em&gt;EXINIT&lt;/em&gt;)&#xA;  with a command of the form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map lhs rhsCR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;mapping &lt;em&gt;lhs&lt;/em&gt; into &lt;em&gt;rhs&lt;/em&gt;. There are restrictions: lhs should be one&#xA;  keystroke (either 1 character or one function key) since it must be&#xA;  entered within one second (unless &lt;em&gt;notimeout&lt;/em&gt; is set, in which case&#xA;  you can type it as slowly as you wish, and &lt;em&gt;vi&lt;/em&gt; will wait for you to&#xA;  finish it before it echoes anything). The &lt;em&gt;lhs&lt;/em&gt; can be no longer than&#xA;  10 characters, the &lt;em&gt;rhs&lt;/em&gt; no longer than 100. To get a space, tab or&#xA;  newline into &lt;em&gt;lhs&lt;/em&gt; or &lt;em&gt;rhs&lt;/em&gt; you should escape them with a &lt;strong&gt;^V&lt;/strong&gt;. (It&#xA;  may be necessary to double the &lt;strong&gt;^V&lt;/strong&gt; if the map command is given&#xA;  inside &lt;em&gt;vi&lt;/em&gt;, rather than in &lt;em&gt;ex&lt;/em&gt;.) Spaces and tabs inside the &lt;em&gt;rhs&lt;/em&gt;&#xA;  need not be escaped.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We need to prefix the newline given to &lt;code&gt;:s&lt;/code&gt; with a &lt;code&gt;\&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If we were typing the command in &lt;code&gt;vi&lt;/code&gt;, then we'd press &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;M&lt;/kbd&gt; to get the newline in the command. That means we have to make the mapping so that it would be as if we had pressed &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;M&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;li&gt;We need &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; just to get one &lt;code&gt;^V&lt;/code&gt; to the command. But we need two, so that it would be as if we'd typed &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The reduction would be like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;^V^V^V^V^V^M&lt;/code&gt; typed&lt;/li&gt;&#xA;&lt;li&gt;Which the &lt;code&gt;map&lt;/code&gt; command will receive as &lt;code&gt;^V^V^M&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Which will be interpreted while executing the map as &lt;code&gt;^V^M&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;To get a literal &lt;code&gt;^M&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;After all that, the output still won't be what you wanted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;​&#xA;Name1&#xA;Name2&#xA;Name3 Name4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-04-30T08:58:18.613" LastActivityDate="2016-04-30T08:58:18.613" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7558" PostTypeId="2" ParentId="7273" CreationDate="2016-04-30T09:58:48.410" Score="1" Body="&lt;p&gt;Sure! Instead of interleaving actual text with Python code, build the whole string with Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet &quot;[A-Z]+-[0-9]+&quot; &quot;Jira Link&quot; r&#xA;`!p identifier = match.group(0)&#xA;snip.rv = &quot;&quot;.join([&#xA;    &quot;[&quot;, identifier, &quot;]&quot;&#xA;    &quot;(https://ellation.atlassian.net/browse/&quot;, identifier, &quot;)&quot;])`&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7415" LastActivityDate="2016-04-30T09:58:48.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7559" PostTypeId="1" AcceptedAnswerId="7580" CreationDate="2016-04-30T11:53:24.480" Score="3" ViewCount="106" Body="&lt;p&gt;How do I search for pattern that is not at the beginning of a line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Name1 Name2 Name3 Name4 Name5 Name6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/[^^]Name.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously the second &lt;code&gt;^&lt;/code&gt; symbol does not mean beginning of line inside &lt;code&gt;[]&lt;/code&gt;. Is there any symbol that means &quot;not at the beginning of line&quot;?&lt;/p&gt;&#xA;" OwnerUserId="7457" LastActivityDate="2016-05-01T11:42:34.750" Title="How to search for a pattern that starts at newline in ex/vi" Tags="|regular-expression|original-vi|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7560" PostTypeId="2" ParentId="7559" CreationDate="2016-04-30T15:00:13.453" Score="2" Body="&lt;p&gt;You could use a negative lookbehind:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\(^\)\@&amp;lt;!Name\d&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\( \)&lt;/code&gt; Are special matching parentheses&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^&lt;/code&gt;  Is beginning of line, of course&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\@&amp;lt;!&lt;/code&gt; is a negative lookbehind. Essentially, if it finds what's in the parentheses, it excludes it from the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h \@&amp;lt;!&lt;/code&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-04-30T15:00:13.453" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7561" PostTypeId="1" CreationDate="2016-05-01T06:10:05.270" Score="11" ViewCount="1703" Body="&lt;p&gt;Is there a way to make vim jump to the right matching definition &lt;em&gt;automatically&lt;/em&gt; in case of multiple definitions. Our C++ code heavily uses function overloading and vim's handling of ctags does not seems to be ready for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void abc(int a, int b) {&#xA;&#xA;}&#xA;&#xA;void abc(int a, int b, int c) {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Strangely, &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt; on &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc(1,2,3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;takes to the 1st definition and not the correct definition which is the 2nd. Also, &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt; prompts for options but that's not what I am looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="7464" LastEditorUserId="7464" LastEditDate="2016-05-02T07:55:05.240" LastActivityDate="2019-04-07T10:33:02.823" Title="Vim, ctags and overloading" Tags="|tags|ctags|filetype-c++|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7562" PostTypeId="1" AcceptedAnswerId="7563" CreationDate="2016-05-01T07:23:02.163" Score="12" ViewCount="8054" Body="&lt;p&gt;Given a series of lines that look similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2001 &quot;Some Kind of Title,&quot; Author's Name, Publication Name, 1 Mar.&#xA;2002 &quot;Some Kind of Title,&quot; Author's Name, Publication Name, 12 Oct.&#xA;2003 &quot;Some Kind of Title,&quot; Author's Name, Publication Name, 8 Apr.&#xA;2004 &quot;Some Kind of Title,&quot; Author's Name, Publication Name, 3 Jun.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way that I could grab those first four characters (the year), and copy them to the end of the line, so that it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2001 &quot;Some Kind of Title,&quot; Author's Name, Publication Name, 1 Mar. 2001&#xA;2002 &quot;Some Kind of Title,&quot; Author's Name, Publication Name, 12 Oct. 2002&#xA;2003 &quot;Some Kind of Title,&quot; Author's Name, Publication Name, 8 Apr. 2003&#xA;2004 &quot;Some Kind of Title,&quot; Author's Name, Publication Name, 3 Jun. 2004&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7465" LastEditorUserId="1841" LastEditDate="2016-05-01T09:48:14.443" LastActivityDate="2018-02-21T00:16:19.870" Title="How to copy first four characters of every line to the end of that same line?" Tags="|cut-copy-paste|replace|repeated-commands|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7563" PostTypeId="2" ParentId="7562" CreationDate="2016-05-01T08:02:18.037" Score="18" Body="&lt;pre&gt;&lt;code&gt;:% s/\v^(\d{4})(.*)$/\1\2 \1/ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is one way to do it&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; magic option, to avoid having to escape grouping &lt;code&gt;()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; start of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\d{4}&lt;/code&gt; match exactly four digits&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*&lt;/code&gt; rest of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\1&lt;/code&gt; &lt;code&gt;\2&lt;/code&gt; has the matched pattern within &lt;code&gt;()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;edit: @Jair Lopez mentions in comments, the regular expression can be further improved:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:% s/\v^(\d{4}).*/&amp;amp; \1/ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or the equivalent&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:% s/\v^(\d{4}).*/\0 \1/ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;&lt;/code&gt; and &lt;code&gt;\0&lt;/code&gt; contains the whole matched pattern&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For further reading, &lt;a href=&quot;http://vimregex.com/#backreferences&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimregex&lt;/a&gt; and &lt;a href=&quot;https://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean&quot;&gt;regex FAQ&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1616" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-05-01T16:03:19.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7564" PostTypeId="2" ParentId="7562" CreationDate="2016-05-01T08:35:24.787" Score="11" Body="&lt;p&gt;And a solution with a macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqyiwA &amp;lt;Esc&amp;gt;pj0q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq   Record the macro in the register q&#xA;yiw  Yank the text described by the text object iw (inner word): The date&#xA;A &amp;lt;Esc&amp;gt;   Append a white space to the end of the line and go back to insert mode&#xA;p    Paste the date&#xA;j0   Place your cursor on the first column of the next line (to be able to repeat the macro)&#xA;q    Stop recording&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then replay the macro as many time as you have line with &lt;code&gt;3@a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; As @evilsoup mentioned it in the comments, a more effective way to execute the macro on all the lines of the buffer is to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%normal @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can of course replace &lt;code&gt;%&lt;/code&gt; by a &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#:range&quot; rel=&quot;nofollow&quot;&gt;range&lt;/a&gt; describing the lines to modify.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-26T09:39:47.293" LastActivityDate="2016-05-26T09:39:47.293" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7565" PostTypeId="2" ParentId="7545" CreationDate="2016-05-01T09:07:26.793" Score="2" Body="&lt;p&gt;It seems that the github user sthysel made a port of spacemacs on Vim: &lt;a href=&quot;https://github.com/sthysel/vim-spacemacs&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sthysel/vim-spacemacs&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can install it with your favorite plugin manager and then you'll have to set your leader key to &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;\&amp;lt;SPACE&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; That it might be not as complete as spacemacs, you can see &lt;a href=&quot;https://github.com/sthysel/vim-spacemacs/blob/master/plugin/spacemacs.vim&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; the list of mappings created by the plugin.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-05-01T09:07:26.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7566" PostTypeId="2" ParentId="7562" CreationDate="2016-05-01T09:14:52.090" Score="4" Body="&lt;p&gt;If you have access to standard UNIX commands, you could use &lt;code&gt;AWK&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!awk '{print $0&quot; &quot;$1}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-05-01T09:14:52.090" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7567" PostTypeId="2" ParentId="7561" CreationDate="2016-05-01T09:24:46.037" Score="4" Body="&lt;p&gt;The documentation (&lt;code&gt;:help ctrl-]&lt;/code&gt;) says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When there are several matching tags for {ident}, jump&#xA;to the [count] one.  When no [count] is given the&#xA;first one is jumped to.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g]&lt;/code&gt; may not be what you are looking for but that's the best you can get in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, you can't expect ctags and Vim to &lt;em&gt;understand&lt;/em&gt; your code, so you'll have to look for a smarter indexer (like cscope, GNU GLOBAL, or something based on clang) or use an actual IDE.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="51" LastEditDate="2019-04-07T10:33:02.823" LastActivityDate="2019-04-07T10:33:02.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7568" PostTypeId="5" CreationDate="2016-05-01T09:36:11.573" Score="0" Body="&lt;p&gt;The option is a comma separated list of these words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;block   Allow virtual editing in Visual block mode.&#xA;insert  Allow virtual editing in Insert mode.&#xA;all     Allow virtual editing in all modes.&#xA;onemore Allow the cursor to move just past the end of the line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-01T09:36:11.573" LastActivityDate="2016-05-01T09:36:11.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7569" PostTypeId="4" CreationDate="2016-05-01T09:36:11.573" Score="0" Body="Questions about the usage of the option `'virtualedit'`.&#xD;&#xA;&#xD;&#xA;Virtual editing means that the cursor can be positioned where there is&#xD;&#xA;no actual character.  This can be halfway into a tab or beyond the end&#xD;&#xA;of the line.  Useful for selecting a rectangle in Visual mode and&#xD;&#xA;editing a table." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-01T09:36:11.573" LastActivityDate="2016-05-01T09:36:11.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7570" PostTypeId="5" CreationDate="2016-05-01T09:40:24.373" Score="0" Body="&lt;p&gt;See the &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow&quot;&gt;Vim-plug home page&lt;/a&gt; for more details about this plugin manager.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-01T09:40:24.373" LastActivityDate="2016-05-01T09:40:24.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7571" PostTypeId="4" CreationDate="2016-05-01T09:40:24.373" Score="0" Body="Questions about vim-plug: a minimalist plugin manager." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-01T09:40:24.373" LastActivityDate="2016-05-01T09:40:24.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7572" PostTypeId="5" CreationDate="2016-05-01T09:51:38.740" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow&quot;&gt;pathogen's home page&lt;/a&gt; for more details about its installation and its features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;http://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-package-managers&quot;&gt;this question&lt;/a&gt; for a quick overview of plugin-managers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pathogen manages the run time path.   It is not a plugin-manager the same way that &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow&quot;&gt;vim-plug&lt;/a&gt;, &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow&quot;&gt;Vundle&lt;/a&gt; and &lt;a href=&quot;https://github.com/Shougo/neobundle.vim&quot; rel=&quot;nofollow&quot;&gt;Neobundle&lt;/a&gt; are.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="6590" LastEditDate="2016-09-30T19:10:54.340" LastActivityDate="2016-09-30T19:10:54.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7573" PostTypeId="4" CreationDate="2016-05-01T09:51:38.740" Score="0" Body="Questions about the usage of the pathogen plugin.  &#xD;&#xA;&#xD;&#xA;" OwnerUserId="1841" LastEditorUserId="6590" LastEditDate="2016-09-30T19:11:10.320" LastActivityDate="2016-09-30T19:11:10.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7574" PostTypeId="5" CreationDate="2016-05-01T09:59:18.937" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;https://github.com/altercation/vim-colors-solarized&quot; rel=&quot;nofollow&quot;&gt;the plugin home page&lt;/a&gt; for installation instructions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After installing the plugin, remember to add the following lines to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax enable&#xA;set background=dark&#xA;colorscheme solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-01T09:59:18.937" LastActivityDate="2016-05-01T09:59:18.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7575" PostTypeId="4" CreationDate="2016-05-01T09:59:18.937" Score="0" Body="Questions about the vim-colors-solarized plugin which provides the solarized colorscheme for vim." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-01T09:59:18.937" LastActivityDate="2016-05-01T09:59:18.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7576" PostTypeId="5" CreationDate="2016-05-01T10:01:31.587" Score="0" Body="&lt;p&gt;See the project &lt;a href=&quot;https://github.com/powerline/powerline&quot; rel=&quot;nofollow&quot;&gt;home page&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-01T10:01:31.587" LastActivityDate="2016-05-01T10:01:31.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7577" PostTypeId="4" CreationDate="2016-05-01T10:01:31.587" Score="0" Body="Powerline is a statusline plugin for vim, and provides statuslines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome, i3 and Qtile." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-01T10:01:31.587" LastActivityDate="2016-05-01T10:01:31.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7578" PostTypeId="5" CreationDate="2016-05-01T10:02:50.093" Score="0" Body="&lt;p&gt;See the project &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow&quot;&gt;home page&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-01T10:02:50.093" LastActivityDate="2016-05-01T10:02:50.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7579" PostTypeId="4" CreationDate="2016-05-01T10:02:50.093" Score="0" Body="Vim plugin for intensely orgasmic commenting" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-01T10:02:50.093" LastActivityDate="2016-05-01T10:02:50.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7580" PostTypeId="2" ParentId="7559" CreationDate="2016-05-01T11:42:34.750" Score="3" Body="&lt;p&gt;In original vi, and in tools with POSIX BRE or ERE, there's no way to look for strings not at the beginning of the line. However, in all of these, you can use regex groups to match any character before your actual target pattern, and then keep it unchanged in the replacement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, when you want to insert something between two strings, you use groups, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\(pattern1\)\(pattern2\)/\1 foo \2/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Correspondingly, to match something &lt;em&gt;not&lt;/em&gt; at the beginning of the line, it will be the second pattern, and a &lt;code&gt;.&lt;/code&gt; will be the first. And for patterns not at the end of the line, it will be the first, and a &lt;code&gt;.&lt;/code&gt; the second:&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-05-01T11:42:34.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7581" PostTypeId="1" CreationDate="2016-05-01T12:12:15.840" Score="9" ViewCount="3999" Body="&lt;p&gt;My use case is the following, but I think a general solution, working for as&#xA;many plugins as possible would be preferable:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the &lt;a href=&quot;https://github.com/kana/vim-submode&quot; rel=&quot;noreferrer&quot;&gt;submodes plugin&lt;/a&gt; to create a&#xA;submode handling windows. In my &lt;code&gt;.vimrc&lt;/code&gt; I have several lines containing calls&#xA;to functions defined by this plugin (like that:)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; The submode is entered whith &amp;lt;Leader&amp;gt;k and exited with &amp;lt;Leader&amp;gt;&#xA;call submode#enter_with('WindowsMode', 'n', '', '&amp;lt;Leader&amp;gt;k', ':echo &quot;windows mode&quot;&amp;lt;C&#xA;call submode#leave_with('WindowsMode', 'n', '', '&amp;lt;Leader&amp;gt;')&#xA;&quot; Change of windows with hjkl&#xA;call submode#map('WindowsMode', 'n', '', 'j', '&amp;lt;C-w&amp;gt;j')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I am on a machine where I use my &lt;code&gt;.vimrc&lt;/code&gt; but I haven't installed the&#xA;plugin yet, I get errors on Vim starting: &lt;code&gt;E117: Unknown function :submode#enter_with&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is normal that this happen since the plugin isn't installed, Vim can't know&#xA;the function. But the message on my shell necessitating a key press to disappear is pretty annoying. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To avoid that I've tried several things&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Some (good) plugins declare a variable &lt;code&gt;g:loaded_pluginname&lt;/code&gt; which is&#xA;accessible at the time of the &lt;code&gt;.vimrc&lt;/code&gt; sourcing and can be used to test if&#xA;the plugin exists. Unfortunately submode (and other plugins) doesn't &#xA;provide such a variable (nor any variable available at &lt;code&gt;.vimrc&lt;/code&gt; sourcing time).&lt;/li&gt;&#xA;&lt;li&gt;Of course, I could use &lt;code&gt;:silent!&lt;/code&gt; in front of all the lines causing the&#xA;message to mute them. The problem is that it doesn't feels really clean to&#xA;proceed this way: I'd like keeping the potential error messages when the&#xA;plugin is installed.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The last solution I've found is to check if the file defining the plugin&#xA;exists and put the call to the function in this if:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (filereadable($HOME . &quot;/.vim/plugged/vim-submode/autoload/submode.vim&quot;))   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The fact is that it doesn't seem efficient nor reliable to me.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Thus I'm looking for the most generic way to programmatically test from my &lt;code&gt;.vimrc&lt;/code&gt; if a plugin&#xA;is already installed.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-01-15T14:30:56.187" Title="In my vimrc how to test if a plugin is installed?" Tags="|vimrc|plugin-system|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="7582" PostTypeId="1" CreationDate="2016-05-01T12:15:02.600" Score="7" ViewCount="1160" Body="&lt;p&gt;I'm loving the fact that I can jump using relative numbers and a movement command but I always seem to find myself using the backticks to try and go back to where I was before the movement jump. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that movement isn't added to the jump list and I agree with that if it's just a single movement but if it's a numbered jump (more than one) I feel like it should be added to the jump list. So my question is how do I do this?&lt;/p&gt;&#xA;" OwnerUserId="6905" LastEditorUserId="1821" LastEditDate="2016-05-01T19:51:52.713" LastActivityDate="2016-05-09T15:00:45.563" Title="How to add numbered movement to the jump list?" Tags="|cursor-movement|jumplist|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7583" PostTypeId="1" AcceptedAnswerId="7585" CreationDate="2016-05-01T13:49:42.607" Score="4" ViewCount="1382" Body="&lt;p&gt;When using &lt;code&gt;set number&lt;/code&gt; and &lt;code&gt;set numberwidth&lt;/code&gt; I'd like to have the line numbers padded with zeros instead of spaces. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0001&#xA;0002&#xA;0003&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can it be done?&lt;/p&gt;&#xA;" OwnerUserId="7467" LastActivityDate="2016-05-01T17:32:00.627" Title="Is there an option to zero-pad line numbers?" Tags="|line-numbers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7584" PostTypeId="2" ParentId="7562" CreationDate="2016-05-01T14:58:48.137" Score="6" Body="&lt;p&gt;Here is the way that I would do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm y4lA &amp;lt;C-o&amp;gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm                     &quot;Apply the following keystrokes to every line:&#xA;       y4l                 &quot;Yank 4 letters. You could also do 'yiw'&#xA;          A                &quot;Add a space to the end&#xA;            &amp;lt;C-o&amp;gt;          &quot;Do a single normal command&#xA;                 p         &quot;Paste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-05-01T14:58:48.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7585" PostTypeId="2" ParentId="7583" CreationDate="2016-05-01T15:18:10.530" Score="3" Body="&#xA;&#xA;&lt;p&gt;AFAIK, this can only be done by changing the Vim source code and rebuilding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The changes you need to make are as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For zero-padded &lt;code&gt;number&lt;/code&gt;, in &lt;a href=&quot;https://github.com/vim/vim/blob/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6/src/screen.c&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;src/screen.c&lt;/code&gt;&lt;/a&gt; on lines &lt;strong&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6/src/screen.c#L2502&quot; rel=&quot;nofollow&quot;&gt;2502&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6/src/screen.c#L3712&quot; rel=&quot;nofollow&quot;&gt;3712&lt;/a&gt;&lt;/strong&gt;, replace:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;char *fmt = &quot;%*ld &quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;char *fmt = &quot;%0*ld &quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For zero-padded &lt;code&gt;relativenumber&lt;/code&gt;, in the same file, on lines &lt;strong&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6/src/screen.c#L2519&quot; rel=&quot;nofollow&quot;&gt;2519&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6/src/screen.c#L3725&quot; rel=&quot;nofollow&quot;&gt;3725&lt;/a&gt;&lt;/strong&gt;, replace:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;fmt = &quot;%-*ld &quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;fmt = &quot;%0*ld &quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Line numbers noted above are for the current version on Github, 7.4.1799.&lt;/p&gt;&#xA;" OwnerUserId="7468" LastEditorUserId="205" LastEditDate="2016-05-01T17:32:00.627" LastActivityDate="2016-05-01T17:32:00.627" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7586" PostTypeId="1" AcceptedAnswerId="7588" CreationDate="2016-05-01T21:05:48.617" Score="0" ViewCount="409" Body="&lt;p&gt;Is there a autocmd for scrolling a window without moving a cursor, the one that occurs for CTRL+E/Y? Is there some autocmd that is triggered for that?  I googled but found nothing.&lt;/p&gt;&#xA;" OwnerUserId="5397" LastActivityDate="2021-07-29T19:40:41.283" Title="Autocmd for scrolling a window?" Tags="|autocmd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7587" PostTypeId="1" AcceptedAnswerId="7592" CreationDate="2016-05-01T21:08:07.583" Score="2" ViewCount="1639" Body="&lt;p&gt;I adopted the bracket notation, e.g., &lt;code&gt;x[i]&lt;/code&gt;, for the discrete signal &lt;code&gt;x&lt;/code&gt; where &lt;code&gt;i&lt;/code&gt; is the time index. The problem occurs in a &lt;code&gt;pgfplots&lt;/code&gt; figure but I figured, the syntax highlighting behavior is due to being math mode in a LaTeX command option, i.e., &lt;code&gt;\begin{command}[option] ... \end{command}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a MWE originally named &lt;code&gt;demonstration.tex&lt;/code&gt; which compiles correctly:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-tex prettyprint-override&quot;&gt;&lt;code&gt;\documentclass{article}&#xA;\usepackage{pgfplots}&#xA;\pgfplotsset{compat=1.12}&#xA;\begin{document}&#xA;Here, I show you a not so very interesting graph&#xA;\begin{figure}&#xA;    \centering&#xA;    \begin{tikzpicture}&#xA;        \begin{axis}[&#xA;                xlabel=$i$,&#xA;                ylabel={$x[i]$},&#xA;            ]&#xA;            \addplot+[ycomb] plot coordinates&#xA;            {&#xA;                (1,1)&#xA;                (2,2)&#xA;                (3,1)&#xA;            };&#xA;        \end{axis}&#xA;    \end{tikzpicture}&#xA;    \caption{Example figure}&#xA;\end{figure}&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The erroneous syntax highlighting occurs in the line with &lt;code&gt;ylabel={$x[i]$}&lt;/code&gt;. There, the closing bracket &lt;code&gt;]&lt;/code&gt; is matched with the opening &lt;code&gt;[&lt;/code&gt; two lines above. Then everything after the closing &lt;code&gt;$&lt;/code&gt; is displayed as if in math mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume the issue can be resolved by allowing math mode in command option mode (if these are the right terms) but I wasn't able to find or comprehend the right spot in the syntax file.&lt;/p&gt;&#xA;" OwnerUserId="7472" LastEditorUserId="205" LastEditDate="2016-05-02T07:26:46.757" LastActivityDate="2016-06-15T17:09:21.130" Title="How do I get Vim to correctly highlight Math mode in LaTeX command options?" Tags="|syntax-highlighting|filetype-tex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7588" PostTypeId="2" ParentId="7586" CreationDate="2016-05-01T21:51:39.410" Score="2" Body="&lt;p&gt;If you have a look at &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocmd-events&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h autocommand-events&lt;/code&gt;&lt;/a&gt; you will see all events triggered. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no autocommand that I see for scrolling without cursor moving.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to add extra functionalities to &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt; you can always remap them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-E&amp;gt; :echo 'a'&amp;lt;CR&amp;gt; | norm &amp;lt;C-E&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-05-01T21:51:39.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7589" PostTypeId="1" AcceptedAnswerId="7591" CreationDate="2016-05-02T04:30:59.020" Score="-2" ViewCount="286" Body="&lt;p&gt;I am aware of the fact that a delete or change yanks to the current register.Since I do not want that behaviour I make them yank to the Black hole register with these two lines in vim rc file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap dd &quot;xdd  &#xA;nnoremap c &quot;xc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I do not want &lt;code&gt;C&lt;/code&gt;to yank to the current register however when I do this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap C &quot;xC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I cannot get the same effect and the content which is deleted is stored in the current register.&lt;/p&gt;&#xA;" OwnerUserId="7053" LastEditorUserId="5229" LastEditDate="2016-05-02T06:42:53.853" LastActivityDate="2016-05-02T06:42:53.853" Title="Change copies to the current register" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7590" PostTypeId="1" CreationDate="2016-05-02T04:49:47.607" Score="8" ViewCount="877" Body="&lt;p&gt;I am using the  Julia programming language, and as of right now, there are no good syntax-completer for VIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am working on one, but haven't fully got my head around how to hook into &lt;code&gt;ycmd&lt;/code&gt;.&#xA;Til I find some free time to delve in deeply.&#xA;I was wondering (if as a stopgap), I could give YCM a list of all completions I want made available.&#xA;Then I could at least make all the functions from the Standard Library syntax complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or since I have code right now, that will take a source file, and output all completions for any packages it uses etc, I could generate this list of completions per file, and only have to regenerate when more packages were made use of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&#xA;It wouldn't end up smart I guess since it would not be able to detect when a &lt;code&gt;.&lt;/code&gt; should be used as a trigger, but I think anything is better than nothing.&lt;/p&gt;&#xA;" OwnerUserId="360" LastActivityDate="2016-05-02T04:49:47.607" Title="Can I give YouCompleteMe a static list of completions?" Tags="|autocompletion|plugin-you-complete-me|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="7591" PostTypeId="2" ParentId="7589" CreationDate="2016-05-02T05:09:49.620" Score="4" Body="&lt;p&gt;&lt;code&gt;_&lt;/code&gt; is the blackhole register, not &lt;code&gt;x&lt;/code&gt;.  You're just storing the text in the &lt;code&gt;x&lt;/code&gt; register, &lt;strong&gt;and&lt;/strong&gt; in the &lt;code&gt;&quot;&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap dd &quot;_dd  &#xA;nnoremap c &quot;_c&#xA;nnoremap C &quot;_C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should try getting used to the default behavior of the unnamed register.  &lt;code&gt;ddp&lt;/code&gt; is a very easy way to swap lines, just as &lt;code&gt;xp&lt;/code&gt; is an easy way to swap characters.  You won't get things like that if you blackhole the change mappings.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-05-02T05:09:49.620" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7592" PostTypeId="2" ParentId="7587" CreationDate="2016-05-02T06:36:39.063" Score="2" Body="&lt;p&gt;To achieve what you ask is, I believe, quite difficult. I'm the author of &lt;a href=&quot;https://github.com/lervag/vimtex/&quot; rel=&quot;nofollow&quot;&gt;vimtex&lt;/a&gt;, and I've added some custom syntax highlighting, see &lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/after/syntax/tex.vim&quot; rel=&quot;nofollow&quot;&gt;vimtex/after/syntax/tex.vim&lt;/a&gt;. As you might notice, the syntax highlighting syntax can become quite complex, and I think in this particular case, it will be very nontrivial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, instead of a direct answer to what you ask, I will instead suggest a workaround that I think should work well: Instead of adding the plot settings as an optional argument to the &lt;code&gt;axis&lt;/code&gt; environment, you can add them with &lt;code&gt;\pgfplotsset&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-tex prettyprint-override&quot;&gt;&lt;code&gt;\documentclass{article}&#xA;\usepackage{pgfplots}&#xA;\pgfplotsset{compat=1.12}&#xA;\begin{document}&#xA;Here, I show you a not so very interesting graph&#xA;\begin{figure}&#xA;    \centering&#xA;    \begin{tikzpicture}     &#xA;        \pgfplotsset{&#xA;            xlabel=$i$,&#xA;            ylabel={$x[i]$},&#xA;        }&#xA;        \begin{axis}&#xA;            \addplot+[ycomb] plot coordinates&#xA;            {&#xA;                (1,1)&#xA;                (2,2)&#xA;                (3,1)&#xA;            };&#xA;        \end{axis}&#xA;    \end{tikzpicture}&#xA;    \caption{Example figure}&#xA;\end{figure}&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information about this, see the &lt;a href=&quot;http://pgfplots.sourceforge.net/pgfplots.pdf&quot; rel=&quot;nofollow&quot;&gt;pgfplots manual&lt;/a&gt;, section 4.3.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2016-05-02T18:45:19.140" LastActivityDate="2016-05-02T18:45:19.140" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7593" PostTypeId="1" CreationDate="2016-05-02T07:44:42.813" Score="1" ViewCount="1798" Body="&lt;p&gt;I want to paste text which spans across multiple lines and is rectangular.&#xA;For example, a rectangular box representing a device topology diagram.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      +-------+&#xA;       |         |&#xA;       |         |&#xA;      +-------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I paste this box, it should replace the existing characters and get pasted. I believe this is kind of replace mode. Not only first line, every line in my block should be pasted at the same column in every line (, that is, the block should be pasted as block itself, without pasting the second line of my block in start of the line.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want is a mix of replace and visual block mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+------+&#xA;|        |&#xA;|        |&#xA;|        |&#xA;+------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  +------+.     +-------+&#xA; |      |&#xA; |      |&#xA;  |      |&#xA;  +------+&#xA; |      |&#xA; |      |&#xA; +------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; +------+.   +-----+&#xA; |      |     |     |&#xA; |      |     |     |&#xA; |      |     |     |&#xA; +------+.   +-----+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second box is the one I pasting.&#xA;I am familiar with visual block mode and can paste manually. But I want to paste this way, through a function or set of commands.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="7161" LastEditDate="2016-05-02T11:27:09.080" LastActivityDate="2016-05-07T22:00:43.957" Title="How to paste a text block in visual block mode?" Tags="|vimscript|command-line|replace|multiple-lines|visual-block|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7594" PostTypeId="5" CreationDate="2016-05-02T08:18:51.823" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-05-02T08:18:51.823" LastActivityDate="2016-05-02T08:18:51.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7595" PostTypeId="4" CreationDate="2016-05-02T08:18:51.823" Score="0" Body="Visual block mode enables users to copy and paste rectangular text. This mode is useful whenever a particular text is pasted to be pasted in every part of a rectangular text. " OwnerUserId="7161" LastEditorUserId="7161" LastEditDate="2016-05-02T10:35:32.437" LastActivityDate="2016-05-02T10:35:32.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7596" PostTypeId="1" AcceptedAnswerId="7597" CreationDate="2016-05-02T08:36:40.707" Score="11" ViewCount="1632" Body="&lt;p&gt;I'm currently trying to create the following mapping in my vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;s :split&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;code&gt;:split&lt;/code&gt; is followed by a trailing space. This makes sense so I can enter the file name without always manually preceding it with a space. This code works in fact. However, it's not very nice from a readability perspective because it's not obvious that there's a space at the end of the mapping. It would be nice if there were a way to express the second part of the mapping as a string.&lt;/p&gt;&#xA;&lt;p&gt;I'm not very experienced with vimscript, but I tried enclosing the second part of the mapping in double-quotes, single-quotes, and backticks, none of which result in a working mapping. Like I said, the mapping currently works as desired with the trailing space. But I would prefer a more programmer-friendly way of expressing the second part of the mapping. How can this be done?&lt;/p&gt;&#xA;" OwnerUserId="7476" LastEditorUserId="7476" LastEditDate="2020-08-23T04:03:11.623" LastActivityDate="2020-08-23T04:03:11.623" Title="How does one include a trailing space in a mapping?" Tags="|vimscript|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7597" PostTypeId="2" ParentId="7596" CreationDate="2016-05-02T09:04:30.823" Score="14" Body="&lt;p&gt;I think your best option is to use &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;s :split&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-05-02T09:04:30.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7598" PostTypeId="1" AcceptedAnswerId="7613" CreationDate="2016-05-02T10:32:44.810" Score="3" ViewCount="612" Body="&lt;p&gt;I'm testing the new built-in package manager. From &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#packages&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h packages&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When Vim starts up, after processing your .vimrc, it scans all directories in&#xA;'packpath' for plugins under the &quot;pack/*/start&quot; directory.  First all those&#xA;directories are added to 'runtimepath'.  Then all the plugins are loaded.&#xA;See packload-two-steps for how these two steps can be useful.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My folders are looking in this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.vim&#xA;  |--pack&#xA;    |--javascript&#xA;      |--start&#xA;        |--vim-javascript&#xA;          |--ftdetect&#xA;            |-- javascript.vim&#xA;          |--ftplugin&#xA;            |--javascript.vim&#xA;          |--indent&#xA;            |--javascript.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I'm opening a .js file, I get this log:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sourcing /opt/local/share/vim/vim74/syntax/javascript.vim    &#xA;sourcing /Users/me/.vim/pack/javascript/start/vim-javascript/syntax/javascript.vim    &#xA;sourcing /opt/local/share/vim/vim74/ftplugin/javascript.vim    &#xA;sourcing /Users/me/.vim/pack/javascript/start/vim-javascript/ftplugin/javascript.vim    &#xA;sourcing /opt/local/share/vim/vim74/indent/javascript.vim    &#xA;sourcing /Users/me/.vim/pack/javascript/start/vim-javascript/indent/javascript.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to look fine, but the plugin doesn't work at all. Where is the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&#xA;I'm using Vim version 7.4.1797, huge version without GUI on OSX. The plugin, that I try to load, is &lt;a href=&quot;https://github.com/pangloss/vim-javascript&quot; rel=&quot;nofollow&quot;&gt;pangloss/vim-javascript&lt;/a&gt;. With pathogen, plugin is loading, no problem. &lt;/p&gt;&#xA;" OwnerUserId="911" LastEditorUserId="911" LastEditDate="2016-05-02T15:00:10.477" LastActivityDate="2017-05-04T15:41:04.533" Title="How can I run a ft-plugin with the new built-in package manager in Vim?" Tags="|plugin-system|packages|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7599" PostTypeId="1" AcceptedAnswerId="7601" CreationDate="2016-05-02T12:37:41.433" Score="3" ViewCount="776" Body="&lt;p&gt;I want to set some commands for specific filetypes. For example an abbreviation: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:iabbr Sb SameBatch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The files have extension like &lt;code&gt;.data&lt;/code&gt;, &lt;code&gt;.pro&lt;/code&gt;. Their grammar, syntax-highlighting are defined in the framework. I am unaware of those things. Those files contain variables and their values for Perl scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au FileType data iabbr di ditto&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought that the extension is the file type of a file. Is it wrong and how to get it worked?&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="7161" LastEditDate="2016-05-02T13:16:14.623" LastActivityDate="2016-05-02T13:41:29.453" Title="How to set commands for unrecognised file type" Tags="|vimrc|command-line|autocmd|filetype|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7600" PostTypeId="2" ParentId="7581" CreationDate="2016-05-02T12:46:19.963" Score="5" Body="&lt;p&gt;Normally &lt;code&gt;exists('*submode#enter_with')&lt;/code&gt; can be used, however it was returning false in my case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;a href=&quot;https://vi.stackexchange.com/questions/7581/in-my-vimrc-how-to-test-if-a-plugin-is-installed#comment12478_7581&quot;&gt;@VanLaser&lt;/a&gt; suggested a pretty simple solution using the &lt;code&gt;try&lt;/code&gt; and &lt;code&gt;catch&lt;/code&gt; vimscript instruction to execute the lines which echoed errors when the plugin wasn't installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now I use this solution, it doesn't allow to determine if a plugin is installed or not but at least my instructions are run when it's possible and I got rid of the error messages when the instructions can't be executed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;try&#xA;    &quot; Create a submode to handle windows&#xA;    &quot; The submode is entered whith &amp;lt;Leader&amp;gt;k and exited with &amp;lt;Leader&amp;gt;&#xA;    call submode#enter_with('WindowsMode', 'n', '', '&amp;lt;Leader&amp;gt;k', ':echo &quot;windows mode&quot;&amp;lt;CR&amp;gt;')&#xA;    call submode#leave_with('WindowsMode', 'n', '', '&amp;lt;Leader&amp;gt;')&#xA;    &quot; Change of windows with hjkl&#xA;    call submode#map('WindowsMode', 'n', '', 'j', '&amp;lt;C-w&amp;gt;j')&#xA;catch&#xA;    &quot;echo &quot;The functions can't be executed&quot;&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think I could even put the following in the &lt;code&gt;catch&lt;/code&gt; block to automatically try to install the missing plugin.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;catch&#xA;    echo &quot;vim-submode is not installed, trying to install it&quot;&#xA;    PlugInstall vim-submode&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-01-15T13:20:33.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7601" PostTypeId="2" ParentId="7599" CreationDate="2016-05-02T12:59:37.943" Score="5" Body="&lt;p&gt;You could use the &lt;code&gt;BufEnter&lt;/code&gt; autocommand event like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufEnter *.data :iabbr &amp;lt;buffer&amp;gt; di ditto&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The abbreviation will be created when you enter a buffer which is named anything followed by &lt;code&gt;.data&lt;/code&gt; and will exists only in this buffer thanks to &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer more precisely the comment of @SibiCoder I'll detail the line:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;BufEnter&lt;/code&gt; trigger the command when a the user enter a buffer.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;*.data&lt;/code&gt; restrict the execution of the autocommand to files ending with &lt;code&gt;.data&lt;/code&gt; this way when you enter a file named &lt;code&gt;foo.c&lt;/code&gt; or &lt;code&gt;bar.sh&lt;/code&gt; the autocommand is not trigger.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:iabbr &amp;lt;buffer&amp;gt; di ditto&lt;/code&gt; is the command to execute and because of the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; argument the abbreviation will be defined only for the current buffer.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocommand-events&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h autocommand-events&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:abbreviate-%3Cbuffer%3E&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :abbreviate-&amp;lt;buffer&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-02T13:20:02.187" LastActivityDate="2016-05-02T13:20:02.187" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7602" PostTypeId="2" ParentId="1971" CreationDate="2016-05-02T13:01:57.767" Score="9" Body="&lt;p&gt;You can use this command :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:new | 0read ! command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will open up a new split and puts the output of the command in this split (&lt;em&gt;though not in the currently active split as you mentioned&lt;/em&gt;).&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;new&lt;/strong&gt; - creates new split&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;read&lt;/strong&gt; - to get the command output&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;command&lt;/strong&gt; - actual command&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="7479" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-05-02T16:42:25.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7603" PostTypeId="1" AcceptedAnswerId="7607" CreationDate="2016-05-02T13:03:13.510" Score="3" ViewCount="179" Body="&lt;p&gt;I wanted to have the output of a(any) shell command to open up in a vim split.&#xA;Did a bit of research and found out that the command to do so was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new | 0read | ! ls                       ---  (or something of this form)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the issue I am facing is that when I try to bind it to something like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap ,s :new | 0read | !            --- (without a specific command at the end)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Also tried with a specific command at the end and same result&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it is showing up this &lt;strong&gt;error everytime I open up vim&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line  277:&#xA;E32: No file name&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; : It was not exactly an issue with binding, the command had a small issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap ,s :new | 0read !&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Btw the accepted answer has a function implementation which is much better than this simple mapping&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="7479" LastEditorUserId="7479" LastEditDate="2016-05-02T16:47:30.817" LastActivityDate="2016-05-02T16:47:30.817" Title="Problem when assigning a keybinding to open the output of a shell command in vim" Tags="|key-bindings|command-line|split|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7604" PostTypeId="2" ParentId="7599" CreationDate="2016-05-02T13:06:42.573" Score="5" Body="&lt;p&gt;Use a function for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FTManage()&#xA;  let l:filetype = &amp;amp;filetype&#xA;  if l:filteype == 'data'&#xA;      &quot; do stuff&#xA;  endif&#xA;endfunction&#xA;&#xA;autocmd! FileType * call FTManage()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here you pass through the function when the filetype change, so you can filter by filetype and call custom commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main difference between statox's answer and this one is the type of filter. You can filter by file extension, but for some cases it's not relevant (because you can have an autocommand that change the filetype on read), so you can listen for the Filetype event and filter afterward.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-02T13:41:29.453" LastActivityDate="2016-05-02T13:41:29.453" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7607" PostTypeId="2" ParentId="7603" CreationDate="2016-05-02T13:34:21.247" Score="7" Body="&lt;p&gt;To open the output of a command in a new window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new +0r!ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the syntax of &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Anew&quot;&gt;&lt;code&gt;new&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[N]new [++opt] [+cmd]                                  :new&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And for &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%2Bcmd&quot;&gt;&lt;code&gt;+cmd&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        +cmd [+cmd]&#xA;The [+cmd] argument can be used to position the cursor in the newly opened&#xA;file, or execute any other command:&#xA;        +               Start at the last line.&#xA;        +{num}          Start at line {num}.&#xA;        +/{pat}         Start at first line containing {pat}.&#xA;        +{command}      Execute {command} after opening the new file.&#xA;                        {command} is any Ex command.&#xA;To include a white space in the {pat} or {command}, precede it with a&#xA;backslash.  Double the number of backslashes. &#xA;        :edit  +/The\ book           file&#xA;        :edit  +/dir\ dirname\\      file&#xA;        :edit  +set\ dir=c:\\\\temp  file&#xA;Note that in the last example the number of backslashes is halved twice: Once&#xA;for the &quot;+cmd&quot; argument and once for the &quot;:set&quot; command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, to run a command in a new window, you can just &lt;code&gt;+&lt;/code&gt; with &lt;code&gt;:new&lt;/code&gt;, the command being &lt;code&gt;0r!ls&lt;/code&gt;. This can quickly become a pain with complex commands, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In an map, leaving the command to you to enter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ,s :new +0r!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also write a function to read in the command:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;function! SplitRunCommand()&#xA;    call inputsave()&#xA;    let l:cmd = input('Command: ')&#xA;    new&#xA;    call append(0, systemlist(l:cmd))&#xA;    call inputrestore()&#xA;endfunction&#xA;&#xA;nnoremap ,s :call SplitRunCommand()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, when you type &lt;code&gt;,s&lt;/code&gt; you'll be prompted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Command:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Command: date '+%y%m%d'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you will have a new window with the output of &lt;code&gt;date '+%y%m%d'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-05-02T14:02:48.723" LastActivityDate="2016-05-02T14:02:48.723" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7608" PostTypeId="1" AcceptedAnswerId="7635" CreationDate="2016-05-02T17:51:08.950" Score="3" ViewCount="2287" Body="&lt;p&gt;Is there a function that can be called to open a file for editing? I know how to open and edit files in Vim, and I know I can use &lt;code&gt;:e filename&lt;/code&gt;, but is there a built in function I can call that does this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a function exists that does this, there probably is a reason for it to exist in addition to the &lt;code&gt;:e&lt;/code&gt; command and knowing about its existence and what it is called would enable me to look at it in the help and see the purpose of its existence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One problem with using &lt;code&gt;:e filepath&lt;/code&gt; is it gets confused when there are spaces in the path. I tried surrounding the path in quotes, and this allows the command to run without error. But then I can't save, as it seems to think the file is inside a non-existent directory. If I escaped the spaces with a &lt;code&gt;\&lt;/code&gt; character, it works when the command is run directly, but it is causing problems inside a plugin test of mine. I haven't figured out a good way to ask for help with that exact problem yet, so I want to keep this question focused on how to consistently open a path for editing regardless of what characters may be in it. A built in function to do this would be nice, but now I see making my own would be good as well.&lt;/p&gt;&#xA;" OwnerUserId="1410" LastEditorUserId="205" LastEditDate="2016-05-04T19:30:19.900" LastActivityDate="2016-05-04T21:52:51.027" Title="Function that opens file for editing" Tags="|functions|load|" AnswerCount="1" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="7609" PostTypeId="2" ParentId="7562" CreationDate="2016-05-02T20:16:46.153" Score="0" Body="&lt;p&gt;From a unix command line (or windows if you have unix command line tools installed)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sed -e &quot;s/\(....\)\(.*\)/\1\2 \1&quot; &amp;lt; inputFile &amp;gt; outputFile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7486" LastActivityDate="2016-05-02T20:16:46.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7610" PostTypeId="2" ParentId="7103" CreationDate="2016-05-02T20:43:54.190" Score="2" Body="&lt;p&gt;Per @statox comment...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using normal commands applied to ranges is the same as when they are used in scripts, requiring the &lt;code&gt;normal&lt;/code&gt; function to be called.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:?^[^\/][^\/]?+1,/^[^\/][^\/]/-1norm gq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A very common example of this is applying a macro to each line in a visually selected area. Lets say you want to uppercase the last word on each line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq$viwUq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you visually select an area and enter command mode you can apply the macro using &lt;code&gt;normal&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;normal @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-05-02T20:43:54.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7611" PostTypeId="1" CreationDate="2016-05-03T12:53:46.870" Score="1" ViewCount="184" Body="&lt;p&gt;Regardless of the mode I select, it appears on the status line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I switch to &lt;code&gt;select&lt;/code&gt; mode, it is not shown on the status line in Vim, whereas it is shown in gVim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I make it work?&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-05-07T18:46:48.130" LastActivityDate="2016-05-07T18:46:48.130" Title="Why doesn't select mode appear in the status line?" Tags="|visual-mode|statusline|" AnswerCount="0" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7612" PostTypeId="1" AcceptedAnswerId="7614" CreationDate="2016-05-03T18:07:24.467" Score="2" ViewCount="136" Body="&lt;p&gt;I read the following on vim tips&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'`&lt;em&gt;' ('&lt;/em&gt;' is a mark specifier): move to the position of the given&#xA;  mark) - mark '.' is the last edited position&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My question is suppose I have two line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line 1 &#xA;Line 2 &#xA;Line 3 &#xA;Line 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Suppose I edited line1 (insert mode) then escaped into normal mode and went to line 4 (edited line 4). What would be the best approach to go back to line 1 (Which was my inital edit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking that since `. would take us to the last edited position maybe &#xA;2``. would take us to the second last edited position. Sorry i added two back ticks since one back tick triggers formatting. Any suggestions on how the experts handle this. I know I could use marks but i dont feel like adding a mark to every line I edit unless i have no other option. &lt;/p&gt;&#xA;" OwnerUserId="7053" LastActivityDate="2016-05-04T07:31:28.550" Title="Going back to the [n] last edited position" Tags="|macvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7613" PostTypeId="2" ParentId="7598" CreationDate="2016-05-03T19:35:47.147" Score="0" Body="&lt;p&gt;I found myself a solution. I changed runtimepath to bring &lt;code&gt;pack/*/start/*/ftplugin&lt;/code&gt; in front of the PATH&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath^=~/Users/me/.vim/pack/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works for all ft plugin. This is a workaround, maybe there is a better solution?&lt;/p&gt;&#xA;" OwnerUserId="911" LastEditorUserId="911" LastEditDate="2016-05-03T19:48:12.850" LastActivityDate="2016-05-03T19:48:12.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7614" PostTypeId="2" ParentId="7612" CreationDate="2016-05-03T19:37:55.473" Score="5" Body="&lt;p&gt;What you want is the &quot;changelist&quot;: &lt;code&gt;:help changelist&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;3g;&lt;/code&gt; to jump to the third previous change in the &quot;changelist&quot; and &lt;code&gt;2g,&lt;/code&gt; to jump back 2 steps in the list.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-05-04T07:31:28.550" LastActivityDate="2016-05-04T07:31:28.550" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7615" PostTypeId="1" AcceptedAnswerId="7655" CreationDate="2016-05-03T20:51:27.220" Score="3" ViewCount="275" Body="&lt;p&gt;In my &lt;code&gt;.config/nvim/init.vim&lt;/code&gt; I have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost * Neomake&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works well when writing the file.  But when writing and quitting with &lt;code&gt;:wq&lt;/code&gt;, the results are prented on the terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[user:~] $ vi stackexchange.py&#xA;&#xA;Neomake: flake8 complete with exit code 0&#xA;Neomake: pep8 complete with exit code 0[user:~] $&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I quiet this output?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="69" LastEditDate="2016-05-03T20:58:00.327" LastActivityDate="2016-05-06T03:25:47.390" Title="Neomake prints results to terminal when invoking upon wq" Tags="|neovim|plugin-neomake|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7617" PostTypeId="1" AcceptedAnswerId="7618" CreationDate="2016-05-04T09:01:38.437" Score="5" ViewCount="1790" Body="&lt;p&gt;I'd like to automatically save buffer after moving into another split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If you're interested why I'm interested in that read section below.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've started using vim and then neovim not so long ago, so I'm still figuring stuff out. I've noticed a particular pattern in my workflow. I'm splitting terminal (for now I'm using tmux for splits, but I've used iterm2 and terminator for that previously) and one part of the screen is vim and other part is shell where I'm doing something, like running tests, REPL or debugging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want save files manually before running tests or debugging every time, so I've used&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup focus&#xA;    au!&#xA;    au TabLeave * silent! wall&#xA;    au FocusLost * silent! wall&#xA;augroup END&#xA;&#xA;set autowriteall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And a plugin so that focus related events would work with tmux. So If I use tmux everything works smoothly here for me, but I don't like that I need to memorize another set of keybindings that basically doing the same thing. Like splitting windows, creating windows etc. So I thought, why not just use neovim terminal emulator. It works well for me, but one thing is missing, when I'm invoking terminal in split my buffer isn't saved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe the right way to do it is just configure tmux somehow to replicate all vim keybindings (It has nice features like persistent sessions and stuff), but for now I'd like to use neovim emulator if possible.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2016-05-04T09:19:36.620" Title="How to auto save file when moving between split?" Tags="|neovim|split|save|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7618" PostTypeId="2" ParentId="7617" CreationDate="2016-05-04T09:19:36.620" Score="7" Body="&lt;p&gt;What you are looking for is a way to trigger the autocommand each time you leave a buffer to another location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conveniently the autocommand event &lt;code&gt;BufLeave&lt;/code&gt; was made precisely for that, so you just need to add a line like this in your autogroup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufLeave * silent! wall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a bonus: the command &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocommand-events&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h autocommand-events&lt;/code&gt;&lt;/a&gt; might be pretty useful to you when you are looking for a new autocommand event.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-05-04T09:19:36.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7619" PostTypeId="1" CreationDate="2016-05-04T09:32:17.067" Score="3" ViewCount="4129" Body="&lt;p&gt;So, I got it that Vim has no option to display all characters (including &lt;del&gt;whitespace&lt;/del&gt; and CR and LF distinctly)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already saw the question &lt;a href=&quot;https://askubuntu.com/questions/74485/how-to-display-hidden-characters-in-vim&quot;&gt;How to Display Hidden Characters in vim?&lt;/a&gt; and others on stackexchange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there at least a plugin to do that? I wasn't able to find any.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;&#xA;&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;EDIT:&#xA;&#xA;&lt;p&gt;I found out (from &lt;a href=&quot;https://vi.stackexchange.com/questions/727/how-to-differentiate-visually-the-white-spaces-in-vim/729#729&quot;&gt;this comment&lt;/a&gt;) that recent versions of Vim (since &lt;a href=&quot;https://github.com/vim/vim/commit/79278367337be1e9a12222698642dcce0af1e059&quot; rel=&quot;nofollow&quot;&gt;patch 7.4.710&lt;/a&gt;) have a &lt;code&gt;space&lt;/code&gt; option of &lt;code&gt;listchars&lt;/code&gt;.&lt;br/&gt;&#xA;The dot &lt;code&gt;.&lt;/code&gt; is quite good for it, but you can also use unicode characters such as the middle dot &lt;code&gt;·&lt;/code&gt;.&lt;br/&gt;&#xA;That solves perfectly the problem with whitespace, so there's no need of a plugin for that.&lt;br/&gt;&#xA;The problems with line terminators still stand though, and there might be no way to fix them...&lt;/p&gt;&#xA;" OwnerUserId="7503" LastEditorUserId="51" LastEditDate="2016-06-12T04:23:38.847" LastActivityDate="2016-06-12T04:23:38.847" Title="Any way to display *all* characters?" Tags="|whitespace|" AnswerCount="0" CommentCount="18" ContentLicense="CC BY-SA 3.0" />
  <row Id="7622" PostTypeId="1" AcceptedAnswerId="7623" CreationDate="2016-05-04T12:39:17.480" Score="4" ViewCount="214" Body="&lt;p&gt;I came across a question, while writing some vimscript. I wanted to know the &quot;distance in motion&quot; between two marks in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The interesting point of this can be to know how many time I have to exectue a vim motion to go from one mark to the other in order to calculate the number of moves between the two marks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you proceed?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-05-09T15:23:58.740" Title="Compute the distance between two marks" Tags="|cursor-motions|mark|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7623" PostTypeId="2" ParentId="7622" CreationDate="2016-05-04T12:51:59.200" Score="6" Body="&lt;p&gt;You could use this function to do what you want:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It takes 3 arguments:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A normal mode command (which should move the cursor)&lt;/li&gt;&#xA;&lt;li&gt;The mark where to beginning the motions&lt;/li&gt;&#xA;&lt;li&gt;The destination mark&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It will return the minimal number of motions required to reach or overstep the destination mark&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It test several cases and stop the function if&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The direction of the motion (forward or backward) doesn't allow to reach the destionation mark&lt;/li&gt;&#xA;&lt;li&gt;The command given as first parameter doesn't move the cursor&lt;/li&gt;&#xA;&lt;li&gt;One of the mark is undefined&lt;/li&gt;&#xA;&lt;li&gt;The mark are in the same position (0 is returned)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Examples of calls would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call CountMotions(&quot;fa&quot;, &quot;a&quot;, &quot;b&quot;)&#xA;:call CountMotions(&quot;w&quot;, &quot;c&quot;, &quot;b&quot;)&#xA;:call CountMotions(&quot;h&quot;, &quot;c&quot;, &quot;e&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Beware if the first parameter is a destructive command (&lt;code&gt;dd&lt;/code&gt; for example) it will be executed&#xA;at least once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! CountMotions(motion, mark1, mark2)&#xA;    &quot; Save the cursor position&#xA;    let savedPosition = getpos('.')&#xA;&#xA;    &quot; Get position of the marks&#xA;    execute &quot;let m1Position = getpos(\&quot;'&quot; . a:mark1 . &quot;\&quot;)&quot;&#xA;    execute &quot;let m2Position = getpos(\&quot;'&quot; . a:mark2 . &quot;\&quot;)&quot;&#xA;&#xA;    &quot; If a mark is undefined stop the function&#xA;    if (m1Position[1] == 0 &amp;amp;&amp;amp; m1Position[2] == 0)&#xA;        echo &quot;'&quot; . a:mark1 . &quot; is not defined&quot;&#xA;        return -1&#xA;    endif&#xA;    if (m2Position[1] == 0 &amp;amp;&amp;amp; m2Position[2] == 0)&#xA;        echo &quot;'&quot; . a:mark2 . &quot; is not defined&quot;&#xA;        return -1&#xA;    endif&#xA;&#xA;    &quot; If the marks are not on the same buffer stop the function&#xA;    if m1Position[0] != m2Position[0]&#xA;        echo &quot;The marks are not on the same buffer&quot;&#xA;        return -1&#xA;    endif&#xA;&#xA;    &quot; Position the cursor on the first mark&#xA;    call setpos('.', m1Position)&#xA;&#xA;    &quot; Get the distance between the two marks&#xA;    let distance = sqrt( pow((m2Position[1]-m1Position[1]),2) + pow(( m2Position[2]-m1Position[2] ),2) )&#xA;    let previousDistance = distance + 1&#xA;&#xA;    &quot; If the marks are on the same chatacter stop the function&#xA;    if ( distance == 0 )&#xA;        echo &quot;the marks are on the same character&quot;&#xA;        return 0&#xA;    endif&#xA;&#xA;    &quot; Check which mark is the first one in the buffer&#xA;    let firstMark = a:mark1&#xA;    if (m1Position[1] &amp;gt; m2Position[1])&#xA;        let firstMark = a:mark2&#xA;    elseif (m1Position[1] == m2Position[1])&#xA;        if (m1Position[2] &amp;gt; m2Position[2])&#xA;            let firstMark = a:mark2&#xA;        endif&#xA;    endif&#xA;&#xA;    &quot; Check in which direction the motion goes&#xA;        let direction = &quot;forward&quot;&#xA;        &quot; Execute one motion and increment the count&#xA;        execute &quot;normal &quot; . a:motion&#xA;        &quot; Get the position after the motion&#xA;        let newPosition = getpos('.')&#xA;        &quot; Reposition the cursor on the first mark&#xA;        call setpos('.', m1Position)&#xA;        if (m1Position == newPosition)&#xA;            echo &quot;The motion doesn't move the cursor&quot;&#xA;            return -1&#xA;        endif&#xA;        if (m1Position[1] &amp;gt; newPosition[1])&#xA;            let direction = &quot;backward&quot;&#xA;        elseif (m1Position[1] == newPosition[1])&#xA;            if (m1Position[2] &amp;gt; newPosition[2])&#xA;                let direction = &quot;backward&quot;&#xA;            endif&#xA;        endif&#xA;&#xA;    &quot; If the direction doesn't allows to reach the second mark stop the function&#xA;    if ( (firstMark == a:mark1 &amp;amp;&amp;amp; direction == &quot;backward&quot;) || (firstMark == a:mark2 &amp;amp;&amp;amp; direction == &quot;forward&quot;) )&#xA;        echo &quot;wrong way, mark unreachable&quot;&#xA;        return -1&#xA;    endif&#xA;&#xA;    let countMotion = 0&#xA;    let previousPosition = []&#xA;    let continue = 1&#xA;&#xA;    &quot; Count the number of motions&#xA;    while continue == 1&#xA;        &quot; Execute one motion and increment the count&#xA;        execute &quot;normal &quot; . a:motion&#xA;        let countMotion = countMotion + 1&#xA;&#xA;        &quot; Update position&#xA;        let m1Position = getpos('.')&#xA;&#xA;        &quot; Calculate the changes in the distance&#xA;        let previousDistance = distance&#xA;        let distance = sqrt( pow((m2Position[1] - m1Position[1]), 2) + pow((m2Position[2] - m1Position[2]), 2))&#xA;&#xA;        &quot;echo &quot;[&quot; . m1Position[1] . &quot; &quot; . m1Position[2] . &quot;]&quot; . &quot;[&quot; . m2Position[1] . &quot; &quot; . m2Position[2] . &quot;]&quot; . &quot;distances &quot; . string( distance ) . &quot;  &quot; . string( previousDistance )&#xA;&#xA;        &quot; Check if the loop should continue&#xA;        if (distance &amp;gt;= previousDistance)&#xA;            let continue = 0&#xA;        endif&#xA;    endwhile&#xA;&#xA;    &quot; restore cursor position&#xA;    call setpos('.', savedPosition)&#xA;&#xA;    echo a:motion . &quot; needed: &quot; . countMotion&#xA;    return countMotion&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-09T15:23:58.740" LastActivityDate="2016-05-09T15:23:58.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7624" PostTypeId="1" AcceptedAnswerId="10804" CreationDate="2016-05-04T14:39:24.890" Score="5" ViewCount="8517" Body="&lt;p&gt;I have installed the terminal neovim which starts by &lt;code&gt;nvim&lt;/code&gt;, and the graphical neovim. &#xA;I cannot find the keybinding to start the graphical neovim in Terminal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I installed the neovim by following instructions in Github &lt;a href=&quot;https://github.com/neovim/homebrew-neovim/blob/master/README.md&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, by Homebrew; still checking if it install also the graphical one which I have also&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;brew install neovim/neovim/neovim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My Graphical Neovim is NVIM 0.1.3 which homepage is &lt;a href=&quot;https://neovim.io/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;How can you start Neovim from Terminal?&lt;/p&gt;&#xA;" OwnerUserId="2923" LastEditorUserId="2923" LastEditDate="2016-05-04T15:16:07.453" LastActivityDate="2016-12-31T23:36:42.010" Title="How to Start Graphical Neovim from OS X Terminal?" Tags="|neovim|macos|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7625" PostTypeId="2" ParentId="7624" CreationDate="2016-05-04T15:23:53.113" Score="2" Body="&lt;p&gt;Looks like the only NeoVim GUI for Mac OS X at the moment is &lt;a href=&quot;https://github.com/rogual/neovim-dot-app&quot; rel=&quot;nofollow&quot;&gt;Neovim.app&lt;/a&gt;. It installs a script called &lt;code&gt;gnvim&lt;/code&gt; which behaves just like good old &lt;code&gt;gvim&lt;/code&gt;, starting a GUI version and accepting all the parameters (but see 'vim_diff.txt' for details on changed, missing and removed features.)&lt;/p&gt;&#xA;" OwnerUserId="7415" LastActivityDate="2016-05-04T15:23:53.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7626" PostTypeId="1" AcceptedAnswerId="7627" CreationDate="2016-05-04T15:26:07.943" Score="3" ViewCount="111" Body="&lt;p&gt;Code in .vimrc which starts graphical Neovim on a filename when pressing &lt;code&gt;gff&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% http://unix.stackexchange.com/q/277918/16920&#xA;:nnoremap gff :silent! exec &quot;!gnvim &quot; shellescape('&amp;lt;cfile&amp;gt;') &amp;lt;bar&amp;gt; redraw!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Situation&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;View: a list of files. &lt;/li&gt;&#xA;&lt;li&gt;Highlight some of them. &lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;gff&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;li&gt;Wanted: get many gvims of multiple documents open. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;How do I loop over a list of files from a visual selection?&lt;/p&gt;&#xA;" OwnerUserId="2923" LastEditorUserId="205" LastEditDate="2016-05-05T07:52:40.657" LastActivityDate="2016-05-05T07:52:40.657" Title="How do I loop over a list of files from a visual selection?" Tags="|key-bindings|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7627" PostTypeId="2" ParentId="7626" CreationDate="2016-05-04T16:27:24.790" Score="4" Body="&lt;pre&gt;&lt;code&gt;:vnoremap gff :&amp;lt;C-U&amp;gt;'&amp;lt;,'&amp;gt;g/^/silent! exec &quot;!gnvim &quot; . shellescape('&amp;lt;cfile&amp;gt;') &amp;lt;bar&amp;gt; redraw!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mapping is for visual mode, and performs a global on all lines that match &lt;code&gt;/^/&lt;/code&gt;...have a start. Then the rest is the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;exec&lt;/code&gt; is run synchronously you will only get one instance at a time and your current vim instance will block waiting for the first launched &lt;code&gt;gnvim&lt;/code&gt; to end. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get multiple instances at once you'll need to ether use the OS's background process management ( &lt;code&gt;&amp;amp;&lt;/code&gt; in unix systems), or use some sort of dispatching system like &lt;code&gt;screen&lt;/code&gt; or &lt;code&gt;tmux&lt;/code&gt;. See &lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow&quot;&gt;tpope's Dispatch plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So assuming you are on a Linux/BSD/OSX system&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnoremap gff :&amp;lt;C-U&amp;gt;'&amp;lt;,'&amp;gt;g/^/silent! exec &quot;!gnvim &quot; . shellescape('&amp;lt;cfile&amp;gt;') . &quot; &amp;amp;&quot; &amp;lt;bar&amp;gt; redraw!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are on Windows you can use &lt;code&gt;START /B program&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnoremap gff :&amp;lt;C-U&amp;gt;'&amp;lt;,'&amp;gt;g/^/silent! exec &quot;!START /B gnvim &quot; . shellescape('&amp;lt;cfile&amp;gt;') &amp;lt;bar&amp;gt; redraw!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To script this up using OS detection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;win32&quot;) || has(&quot;win64&quot;)&#xA;  :vnoremap gff :&amp;lt;C-U&amp;gt;'&amp;lt;,'&amp;gt;g/^/silent! exec &quot;!START /B gnvim &quot; . shellescape('&amp;lt;cfile&amp;gt;') &amp;lt;bar&amp;gt; redraw!&amp;lt;cr&amp;gt;&#xA;else&#xA;  :vnoremap gff :&amp;lt;C-U&amp;gt;'&amp;lt;,'&amp;gt;g/^/silent! exec &quot;!gnvim &quot; . shellescape('&amp;lt;cfile&amp;gt;') . &quot; &amp;amp;&quot; &amp;lt;bar&amp;gt; redraw!&amp;lt;cr&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2016-05-04T16:37:08.107" LastActivityDate="2016-05-04T16:37:08.107" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7628" PostTypeId="1" AcceptedAnswerId="7629" CreationDate="2016-05-04T16:38:03.267" Score="1" ViewCount="306" Body="&lt;p&gt;I am trying to view many files in a loop. I need a keybinding to close Gvim window. Possible choices in apt-get of Ubuntu 16.04&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Command 'gvim' from package 'vim' (main)&#xA; Command 'gvim' from package 'vim-gtk3' (universe)&#xA; Command 'gvim' from package 'vim-gnome' (main)&#xA; Command 'gvim' from package 'vim-athena' (universe)&#xA; Command 'gvim' from package 'vim-nox-py2' (universe)&#xA; Command 'gvim' from package 'vim-gtk-py2' (universe)&#xA; Command 'gvim' from package 'vim-nox' (universe)&#xA; Command 'gvim' from package 'vim-gtk3-py2' (universe)&#xA; Command 'gvim' from package 'vim-gnome-py2' (universe)&#xA; Command 'gvim' from package 'vim-tiny' (main)&#xA; Command 'gvim' from package 'vim-gtk' (universe)&#xA; Command 'gvim' from package 'vim-athena-py2' (universe)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vim-gtk3, no CTRL-W to close the window&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would like to get Neovim with such a feature. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Is there any GVim with window-closure by CTRL-W?&lt;/p&gt;&#xA;" OwnerUserId="2923" LastActivityDate="2016-05-04T16:43:04.217" Title="How to Get GVim which can be Killed by CTRL-W?" Tags="|gvim|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7629" PostTypeId="2" ParentId="7628" CreationDate="2016-05-04T16:43:04.217" Score="2" Body="&lt;p&gt;You can create a map in your vimrc to give &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; the action you are looking for.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoreamp &amp;lt;C-W&amp;gt; :q&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want it to force quit then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-W&amp;gt; :q!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-05-04T16:43:04.217" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7631" PostTypeId="1" AcceptedAnswerId="7634" CreationDate="2016-05-04T17:22:19.463" Score="4" ViewCount="5017" Body="&lt;p&gt;I would like to get Neovim because of its msgpack API and clear roadmap of development, but it is not in Ubuntu 16.04's repositories.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Command 'gvim' from package 'vim' (main)&#xA; Command 'gvim' from package 'vim-gtk3' (universe)&#xA; Command 'gvim' from package 'vim-gnome' (main)&#xA; Command 'gvim' from package 'vim-athena' (universe)&#xA; Command 'gvim' from package 'vim-nox-py2' (universe)&#xA; Command 'gvim' from package 'vim-gtk-py2' (universe)&#xA; Command 'gvim' from package 'vim-nox' (universe)&#xA; Command 'gvim' from package 'vim-gtk3-py2' (universe)&#xA; Command 'gvim' from package 'vim-gnome-py2' (universe)&#xA; Command 'gvim' from package 'vim-tiny' (main)&#xA; Command 'gvim' from package 'vim-gtk' (universe)&#xA; Command 'gvim' from package 'vim-athena-py2' (universe)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have now selected vim-gtk3 but it may limit me later.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;How do I get graphical Neovim with msgpack support?&lt;/p&gt;&#xA;" OwnerUserId="2923" LastEditorUserId="205" LastEditDate="2016-05-04T19:35:18.853" LastActivityDate="2016-05-04T19:42:57.863" Title="How do I install Neovim with GUI and msgpack support in Ubuntu?" Tags="|neovim|installing|neovim-qt|linux-ubuntu|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7632" PostTypeId="1" AcceptedAnswerId="7633" CreationDate="2016-05-04T17:26:33.990" Score="7" ViewCount="1568" Body="&lt;p&gt;How can I change the color that is used to highlight misspelled words in vim-lexical?&lt;/p&gt;&#xA;" OwnerUserId="6379" LastEditorUserId="6489" LastEditDate="2016-05-04T19:27:53.123" LastActivityDate="2016-05-04T19:27:53.123" Title="Change color of misspelled words in vim-lexical" Tags="|highlight|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7633" PostTypeId="2" ParentId="7632" CreationDate="2016-05-04T17:41:11.577" Score="12" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/reedes/vim-lexical&quot; rel=&quot;noreferrer&quot;&gt;The repository&lt;/a&gt; says it uses Vim's spellcheck, so you should be able edit your color file's SpellBad highlighting to do this. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi SpellBad ctermfg=red guifg=red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also put these in your vimrc, but your color file is really the proper place for it.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;cterm is for terminal vim&lt;/li&gt;&#xA;&lt;li&gt;gui is for gVim&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The full set of options are &lt;code&gt;cterm ctermbg ctermfg gui guibg guifg&lt;/code&gt;. You can use &lt;code&gt;:help&lt;/code&gt; on those terms for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also think about changing &lt;code&gt;SpellLocal&lt;/code&gt; and &lt;code&gt;SpellCap&lt;/code&gt; if you wan't to change Vim's other spell check colors.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-05-04T17:48:18.443" LastActivityDate="2016-05-04T17:48:18.443" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7634" PostTypeId="2" ParentId="7631" CreationDate="2016-05-04T18:32:05.513" Score="3" Body="&lt;p&gt;Instructions can be found on the &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Installing-Neovim&quot; rel=&quot;nofollow&quot;&gt;Neovim Wiki&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As of the posting of this answer, the site's current instructions are as follows:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Ubuntu&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Neovim has been added to a &lt;a href=&quot;https://launchpad.net/~neovim-ppa/+archive/ubuntu/unstable&quot; rel=&quot;nofollow&quot;&gt;Personal Package Archive&lt;/a&gt; which allows you to install it using &lt;code&gt;apt-get&lt;/code&gt; on Ubuntu &lt;a href=&quot;https://wiki.ubuntu.com/Releases&quot; rel=&quot;nofollow&quot;&gt;12.04 and later&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be able to use &lt;strong&gt;add-apt-repository&lt;/strong&gt; you may need to install software-properties-common:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install software-properties-common&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're using an older version Ubuntu you have to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install python-software-properties&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Run the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo add-apt-repository ppa:neovim-ppa/unstable&#xA;sudo apt-get update&#xA;sudo apt-get install neovim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Prerequisites for the Python modules:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install python-dev python-pip python3-dev python3-pip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're using an older version Ubuntu you have to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install python-dev python-pip python3-dev&#xA;sudo apt-get install python3-setuptools&#xA;sudo easy_install3 pip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For instructions on how to install the Python modules, see &lt;a href=&quot;http://neovim.io/doc/user/nvim_python.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help nvim_python&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use Neovim for some (or all) of the editor alternatives, use the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo update-alternatives --install /usr/bin/vi vi /usr/bin/nvim 60&#xA;sudo update-alternatives --config vi&#xA;sudo update-alternatives --install /usr/bin/vim vim /usr/bin/nvim 60&#xA;sudo update-alternatives --config vim&#xA;sudo update-alternatives --install /usr/bin/editor editor /usr/bin/nvim 60&#xA;sudo update-alternatives --config editor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, however, that special interfaces, like &lt;code&gt;view&lt;/code&gt; for &lt;code&gt;nvim -R&lt;/code&gt;, are not supported.  (See &lt;a href=&quot;https://github.com/neovim/neovim/issues/1646&quot; rel=&quot;nofollow&quot;&gt;#1646&lt;/a&gt; and &lt;a href=&quot;https://github.com/neovim/neovim/pull/2008&quot; rel=&quot;nofollow&quot;&gt;#2008&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The GUI portion needs to be installed separately. See the &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Related-projects&quot; rel=&quot;nofollow&quot;&gt;list of 3rd party GUIs&lt;/a&gt; on the Neovim site. &lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2016-05-04T19:42:57.863" LastActivityDate="2016-05-04T19:42:57.863" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7635" PostTypeId="2" ParentId="7608" CreationDate="2016-05-04T21:52:51.027" Score="5" Body="&lt;p&gt;Here is a function that does this. It is not tested, but it is based on File.edit() from &lt;a href=&quot;https://github.com/still-dreaming-1/vim-elhiv/blob/develop/src/File.vim&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/still-dreaming-1/vim-elhiv/blob/develop/src/File.vim&lt;/a&gt;, which I did test.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Edit(filepath)&#xA;    execute &quot;e &quot;.fnameescape(a:filepath)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1410" LastActivityDate="2016-05-04T21:52:51.027" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7636" PostTypeId="1" AcceptedAnswerId="7638" CreationDate="2016-05-05T05:22:12.527" Score="1" ViewCount="234" Body="&lt;p&gt;I have several lines in my code. I am aware that Ctrl+x,Ctrl+l shows suggestions for completing a line, based on the similar lines available in the script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I want only the part of a line, delimited by a character, to be shown as suggestions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   Print &quot;Verifying the contents again&quot;;&#xA;   .&#xA;   .&#xA;   .&#xA;   Print &quot;Verifying the output to be shown&quot;; // line 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I type &quot;Verify&quot;, it has to show the remaining part of string in the quotes as suggestion. So, both the lines should be shown.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastActivityDate="2016-05-05T15:12:10.523" Title="how to show suggestions for a group of words inside a quote or bracket" Tags="|autocompletion|insert-mode|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7637" PostTypeId="1" AcceptedAnswerId="7648" CreationDate="2016-05-05T05:32:53.530" Score="-1" ViewCount="217" Body="&lt;p&gt;Code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% http://vi.stackexchange.com/a/7627/2923&#xA;if has(&quot;win32&quot;) || has(&quot;win64&quot;)&#xA;  :vnoremap &amp;lt;Leader&amp;gt;gf :&amp;lt;C-U&amp;gt;'&amp;lt;,'&amp;gt;g/^/silent! exec &quot;!START /B gnvim &quot; . shellescape('&amp;lt;cfile&amp;gt;') &amp;lt;bar&amp;gt; redraw!&amp;lt;cr&amp;gt;&#xA;else&#xA;  :vnoremap &amp;lt;Leader&amp;gt;gf :&amp;lt;C-U&amp;gt;'&amp;lt;,'&amp;gt;g/^/silent! exec &quot;!gnvim &quot; . shellescape('&amp;lt;cfile&amp;gt;') . &quot; &amp;amp;&quot; &amp;lt;bar&amp;gt; redraw!&amp;lt;cr&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output in OS X: windows on top of each other. &#xA;Ubuntu Linux 16.04: evenly distributed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not want to use system dependent tools to do this like (AppleScript). &#xA;I want the same view in OS X and Ubuntu Linux. The current view of Ubuntu Linux is the best one. The possibility is to use NeoVim's API here. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Possible solution [8bittree]&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Do not open many GVim's, but use tabs. &#xA;The reason why I open many GUIs here is that I have not managed to install Airline in OS X (thread &lt;a href=&quot;https://apple.stackexchange.com/q/235615/15504&quot;&gt;here&lt;/a&gt; about &lt;em&gt;How to Install Vim Airline Plugin?&lt;/em&gt;) such that I can use similar settings in Ubuntu 16.04. &#xA;I think it would be ok if all filenames are visible on the top-bar. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnoremap &amp;lt;Leader&amp;gt;gf :&amp;lt;C-U&amp;gt;'&amp;lt;,'&amp;gt;g/^/silent! exec &quot;!nvim -p&quot; . shellescape('&amp;lt;cfile&amp;gt;') . &quot; &amp;amp;&quot; &amp;lt;bar&amp;gt; redraw!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where something problem with &lt;code&gt;nvim -p&lt;/code&gt;. Results in messy outputs in tabs. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;How can you distribute the windows evenly on OS X?&lt;/p&gt;&#xA;" OwnerUserId="2923" LastEditorUserId="-1" LastEditDate="2017-04-13T12:45:30.893" LastActivityDate="2016-05-05T17:54:57.403" Title="How do I evenly distribute GVim windows started from a key-binding?" Tags="|key-bindings|macos|window-management|" AnswerCount="1" CommentCount="7" FavoriteCount="0" ClosedDate="2016-05-08T03:39:07.933" ContentLicense="CC BY-SA 3.0" />
  <row Id="7638" PostTypeId="2" ParentId="7636" CreationDate="2016-05-05T08:37:02.237" Score="2" Body="&lt;p&gt;It wasn't tested very long and it doesn't take into account the fact that the group of words may be on several lines, but you could try the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set completefunc=CompleteInsideSymbols&#xA;&#xA;function! CompleteInsideSymbols(findstart, base) abort&#xA;    if a:findstart&#xA;        return searchpos('[&quot;''[]', 'bc', line('.'))[1] - 1&#xA;    else&#xA;        let groups_of_words = []&#xA;        sil! %s/\v(&quot;.{-1,}&quot;|'.{-1,}'|\[.{-1,}\])/\=add(groups_of_words,submatch(0))/gn&#xA;        return filter(groups_of_words, 'v:val =~ &quot;^&quot; . a:base')&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It defines a custom completion function which is triggered when you hit &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-U&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior of such a function is described in &lt;code&gt;:h complete-functions&lt;/code&gt;. Basically, when you hit the mapping once, the function whose name is defined by the option &lt;code&gt;'completefunc'&lt;/code&gt; is called twice, consecutively, each time with 2 arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 1st time, Vim gives to the function the arguments &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;''&lt;/code&gt; (empty string).&lt;br&gt;&#xA;The 2nd time, it gives the arguments &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;the text you want to complete&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside your function, you can call the 2 arguments however you like, but in the help they use &lt;code&gt;findstart&lt;/code&gt; and &lt;code&gt;base&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you write the function, you have to wrap the whole code inside an &lt;code&gt;if/else/endif&lt;/code&gt; block which tests the value of &lt;code&gt;findstart&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if it's &lt;code&gt;1&lt;/code&gt;, the function must return the byte index of the first character of the text you want to complete ;&lt;/li&gt;&#xA;&lt;li&gt;if it's &lt;code&gt;0&lt;/code&gt;, it must return the suggestions you want to see in the popup menu&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The autocompletion function &lt;code&gt;CompleteInsideSymbols()&lt;/code&gt; is built around such a block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if a:findstart&#xA;    ...&#xA;else&#xA;    ...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's what the function does when it's called for the 1st time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    return searchpos('[&quot;''[]', 'bcn', line('.'))[1] - 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It returns the byte index (byte index = column number - 1) of the previous single quote, double quote, or opening bracket before the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;searchpos()&lt;/code&gt; is a function which returns the line and column numbers of the next or previous occurrence of a pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can pass 3 arguments to &lt;code&gt;searchpos()&lt;/code&gt;:  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;a pattern&lt;/li&gt;&#xA;&lt;li&gt;some flags which change the behavior of the search&lt;/li&gt;&#xA;&lt;li&gt;a stopline which is the number of a line beyond which the search must stop&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here the pattern is &lt;code&gt;[&quot;''[]&lt;/code&gt; which matches a double quote, a single quote or an opening bracket.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the pattern is already surrounded by single quotes, the single quote it contains must be doubled. Besides, the opening and closing brackets are here to group the 3 characters as a collection (see &lt;code&gt;:h /[]&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The flags are &lt;code&gt;bc&lt;/code&gt; which respectively mean look backward and accept a match at current cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the stopline is &lt;code&gt;line('.')&lt;/code&gt; which is the current line number and means that &lt;code&gt;searchpos()&lt;/code&gt; won't look beyond the current line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's what &lt;code&gt;CompleteInsideSymbols()&lt;/code&gt; does when it's automatically called the 2nd time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let groups_of_words = []&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Initialize an empty list inside the variable &lt;code&gt;groups_of_words&lt;/code&gt; whose purpose will be to contain all the groups of words which are inside double quotes, single quotes, or brackets.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    sil! %s/\v(&quot;.{-1,}&quot;|'.{-1,}'|\[.{-1,}\])/\=add(groups_of_words,submatch(0))/gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Call the substitution command &lt;code&gt;:s&lt;/code&gt; to look for the pattern &lt;code&gt;\v(&quot;.{-1,}&quot;|'.{-1,}'|\[.{-1,}\])&lt;/code&gt; which should match all the groups of words which are surrounded by quotes and brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pattern contains the non-greedy multi &lt;code&gt;{-1,}&lt;/code&gt;, which allows you to repeat the previous atom 1 or more times, as few as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever this pattern is found, &lt;code&gt;:s&lt;/code&gt; evaluates the expression &lt;code&gt;add(groups_of_words, submatch(0))&lt;/code&gt; (see &lt;code&gt;:h sub-replace-expression&lt;/code&gt; and &lt;code&gt;:h submatch()&lt;/code&gt; for more information on this).&lt;br&gt;&#xA;As a result of this evaluation, the group of words is added as an item of the list &lt;code&gt;groups_of_words&lt;/code&gt;, but no substitution is made thanks to the &lt;code&gt;n&lt;/code&gt; flag (see &lt;code&gt;:h :s_flags&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    return filter(groups_of_words, 'v:val =~ &quot;^&quot; . a:base')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Return the groups of words whose beginning match the text you want to complete.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-05-05T15:12:10.523" LastActivityDate="2016-05-05T15:12:10.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7639" PostTypeId="2" ParentId="7636" CreationDate="2016-05-05T08:40:04.103" Score="2" Body="&lt;p&gt;There is a plugin named &lt;a href=&quot;https://github.com/vim-scripts/StringComplete/blob/master/plugin/StringComplete.vim&quot; rel=&quot;nofollow&quot;&gt;StringComplete.vim&lt;/a&gt; in Github. It shows all the quoted strings in the current file as suggestions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would have typed part of string and press &lt;code&gt;Ctrl-j&lt;/code&gt;, it will show the suggestions based on it. If nothing is typed and &lt;code&gt;Ctrl+j&lt;/code&gt; is pressed, it will show all quoted strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Works well for single line strings in single or double quotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin can be customized for words within brackets like &lt;code&gt;(&lt;/code&gt;,&lt;code&gt;{&lt;/code&gt;,&lt;code&gt;[&lt;/code&gt;,&lt;code&gt;&amp;lt;&lt;/code&gt; also.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="1821" LastEditDate="2016-05-05T13:59:18.423" LastActivityDate="2016-05-05T13:59:18.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7641" PostTypeId="1" AcceptedAnswerId="7642" CreationDate="2016-05-05T11:41:36.713" Score="11" ViewCount="3778" Body="&lt;p&gt;Is it possible to edit a directory inside Vim? (Some commands are working for directories). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know what kind of operations can be done in a directory inside Vim. Vim can open the directories for editing, I believe it will have commands also to work with. But usual commands behave differently for directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, pressing &lt;kbd&gt;I&lt;/kbd&gt; and typing a filename and saving the directory. When I give &lt;code&gt;ls&lt;/code&gt;, it should show that file. &lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="1821" LastEditDate="2016-05-05T12:03:28.650" LastActivityDate="2016-05-16T17:48:45.587" Title="Edit a directory inside Vim" Tags="|insert-mode|working-directory|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7642" PostTypeId="2" ParentId="7641" CreationDate="2016-05-05T12:05:55.660" Score="10" Body="&lt;p&gt;I'm assuming you are using &lt;code&gt;netrw&lt;/code&gt; here, as it's the default action when you do &lt;code&gt;vim .&lt;/code&gt; or &lt;code&gt;vim some/directory/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create a file/directory from &lt;code&gt;netrw&lt;/code&gt; with the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d : create a directory, you will be prompted to input the directory name&#xA;% : create a file, same workflow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Have a look at &lt;code&gt;:h netrw&lt;/code&gt; for more informations.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-05T15:55:48.830" LastActivityDate="2016-05-05T15:55:48.830" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7643" PostTypeId="2" ParentId="7641" CreationDate="2016-05-05T13:39:23.427" Score="3" Body="&lt;p&gt;Totally a different angle, but it works without having to install any plugins ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I want to create or rename a directory &lt;em&gt;from a running Vim session&lt;/em&gt;, I'll simply type &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;!&lt;/kbd&gt; followed by the appropriate shell command, doing something like the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Linux  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:! mkdir newdir&lt;/code&gt; to create a directory&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:! mv newdir renamed_dir&lt;/code&gt; to rename a directory&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For Windows&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:! mkdir newdir&lt;/code&gt; to create a directory&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:! move newdir renamed_dir&lt;/code&gt; to rename a directory&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As far as I know, you can literally execute whatever shell command you like this way without having to exit from Vim or having to open a separate terminal window.&lt;/p&gt;&#xA;" OwnerUserId="1111" LastEditorUserId="1111" LastEditDate="2016-05-16T17:48:45.587" LastActivityDate="2016-05-16T17:48:45.587" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7644" PostTypeId="1" AcceptedAnswerId="7654" CreationDate="2016-05-05T14:09:28.883" Score="15" ViewCount="11863" Body="&lt;p&gt;I do a lot of Python and I use almost all the time a &lt;a href=&quot;https://virtualenv.pypa.io/en/latest/&quot; rel=&quot;noreferrer&quot;&gt;virtualenv&lt;/a&gt; along with &lt;a href=&quot;http://virtualenvwrapper.readthedocs.io/en/latest/&quot; rel=&quot;noreferrer&quot;&gt;virtualenvwrapper&lt;/a&gt; to keep my modules organised.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I want to use those plugin from inside vim, through an external command, it seems that the shell is not aware of that config.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to have access to the &lt;code&gt;virtualenv&lt;/code&gt; because &lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(venv) $ python&#xA;&amp;gt;&amp;gt; import simple_history&#xA;&amp;gt;&amp;gt; # OK here&#xA;&#xA;(venv) $ vim&#xA;:!python &#xA;&amp;gt;&amp;gt; import simple_history&#xA;ImportError: No module named simple_history&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My shell is &lt;code&gt;shell=/bin/zsh&lt;/code&gt;, I guess I need to use this setting to access my &lt;code&gt;virtualenv&lt;/code&gt;, but I can't figure out how...&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-05T14:27:01.883" LastActivityDate="2022-11-08T14:33:37.870" Title="Use Vim with virtualenv" Tags="|external-command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7645" PostTypeId="1" CreationDate="2016-05-05T14:57:35.717" Score="1" ViewCount="40" Body="&lt;p&gt;I'd like to be able to highlight the current line the cursor is at, but not for files from certain directories. That's because I noticed the rendering becomes slow if I highlight the lines within a Rails project - probably because I use rails.vim and its slowing down things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there a way to highlight current line, but not when I'm in, say, &lt;code&gt;~/Work/my_rails_project_1&lt;/code&gt; or &lt;code&gt;~/Work/my_rails_project_2&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="7521" LastActivityDate="2016-05-06T08:21:46.097" Title="Highlight current line, but not for files inside certain dirs" Tags="|highlight|working-directory|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7646" PostTypeId="2" ParentId="7645" CreationDate="2016-05-05T15:13:38.843" Score="3" Body="&lt;p&gt;I assume by &quot;Highlight current line&quot; that you're referring to the &lt;code&gt;set cursorline&lt;/code&gt; option?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sounds like a job for autocmd's&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter * call UnhighlightLine()&#xA;&#xA;function! UnhighlightLine()&#xA;   if (expand('%:p') =~ '/Work/my_rails_project_1\|/Work/my_rails_project_2')&#xA;      set nocursorline&#xA;   else&#xA;      set cursorline&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufEnter *&lt;/code&gt; will trigger when you enter a new file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;expand('%:p')&lt;/code&gt; Gives the current files path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two paths separated by &lt;code&gt;\|&lt;/code&gt; meaning it can match either one. If you want more paths just continue to separate with &lt;code&gt;\|&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-05-05T20:56:26.173" LastActivityDate="2016-05-05T20:56:26.173" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7647" PostTypeId="1" AcceptedAnswerId="7652" CreationDate="2016-05-05T15:42:59.997" Score="6" ViewCount="326" Body="&lt;p&gt;In Vim, &lt;code&gt;C-x C-l&lt;/code&gt; performs line completion. However, it expects the prefix of the currently typed line to match the prefix of another line. For example, consider that &lt;code&gt;|&lt;/code&gt; below denotes the cursor position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;; A sentence I would like to auto complete.&#xA;...&#xA;A sentence|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press &lt;code&gt;C-x C-l&lt;/code&gt;, line completion obviously fails because the current line does not start with a semicolon. Is there a way of performing &quot;line&quot; completion that disregards line prefixes?&lt;/p&gt;&#xA;" OwnerUserId="6894" LastActivityDate="2016-05-05T18:53:44.500" Title="Line completion disregarding line prefix" Tags="|autocompletion|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7648" PostTypeId="2" ParentId="7637" CreationDate="2016-05-05T16:10:04.867" Score="2" Body="&lt;p&gt;It appears as though your needs may be met by using tabs. See &lt;code&gt;:help tabpage&lt;/code&gt; in Vim for general help, but here are a few relevant commands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Start Vim with &lt;code&gt;vim -p filename ...&lt;/code&gt; to open each file in a separate tab (Though this will be limited by the &lt;code&gt;tabpagemax&lt;/code&gt; setting).&lt;/li&gt;&#xA;&lt;li&gt;Move to the next tab with &lt;code&gt;gt&lt;/code&gt; and the previous with &lt;code&gt;gT&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabe&lt;/code&gt; or &lt;code&gt;:tabedit&lt;/code&gt; will open a new tab with a blank file. Provide &lt;em&gt;one&lt;/em&gt; filename to open that file.&lt;/li&gt;&#xA;&lt;li&gt;Many commands can be preceded with &lt;code&gt;:tab&lt;/code&gt; to have it operate on a tab instead of its normal target. An example would be &lt;code&gt;:tab split&lt;/code&gt; to open a new tab with the current file, instead of a new split. Another is &lt;code&gt;:tab ball&lt;/code&gt; to open all (listed, check via &lt;code&gt;:ls&lt;/code&gt;) buffers in tabs, again, up to &lt;code&gt;tabpagemax&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now, if you really want to try rearranging GUI windows, that's possible in GVim, although I've not tested it on a Mac nor with Neovim.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:winpos&lt;/code&gt; will display the current pixel coordinates of the upper left corner of the GUI window. Provide X and Y arguments to move it to those coordinates. This only works in GVIM, not in a terminal, and might not be available in all versions.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;lines&lt;/code&gt; and &lt;code&gt;columns&lt;/code&gt; are settings that store the current (character, not pixel) size of the GVIM gui window or terminal. Check their current value with &lt;code&gt;:set lines?&lt;/code&gt; and &lt;code&gt;:set columns?&lt;/code&gt; and change them with &lt;code&gt;:set lines=24 columns=80&lt;/code&gt;, substituting the desired numbers, of course.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Just to reiterate, &lt;code&gt;:winpos&lt;/code&gt; is GUI window only, &lt;code&gt;lines&lt;/code&gt; and &lt;code&gt;columns&lt;/code&gt; work in both GUI windows and terminals.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2016-05-05T16:10:04.867" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7650" PostTypeId="2" ParentId="7647" CreationDate="2016-05-05T17:12:31.437" Score="2" Body="&lt;p&gt;Here is a single line solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;C-X&amp;gt;&amp;lt;C-L&amp;gt; &amp;lt;ESC&amp;gt;mm:/&amp;lt;C-R&amp;gt;=substitute(getline('.'), '\n\+$', '', '')&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;ggn&quot;*y$'mo&amp;lt;ESC&amp;gt;&quot;*p&amp;lt;ESC&amp;gt;k&quot;_d:nohl&amp;lt;CR&amp;gt;A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Mapping to Insert Mode &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt; &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;l&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;mm&lt;/code&gt; Exit insert mode and mark location&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:/&amp;lt;C-R&amp;gt;=substitute(getline('.'), '\n\+$', '', '')&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt; Search for contents of this line, removing any new lines at the end&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ggn&lt;/code&gt; Go to top of file and search for first match.&lt;/li&gt;&#xA;&lt;li&gt;`&quot;*y$&quot; Yank from cursor (first match location) to end of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'m&lt;/code&gt; Go back to original edit line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&amp;lt;esc&amp;gt;&quot;*p&lt;/code&gt; Past yank to next line, goofy because we didn't yank a full line, but from cursor to end&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;k&quot;_d&lt;/code&gt; Move back up to original line and delete it&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:nohl&amp;lt;CR&amp;gt;&lt;/code&gt; if you have search highlighting it is cleared&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A&lt;/code&gt; append to end of line to continue writing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2016-05-05T18:32:35.927" LastActivityDate="2016-05-05T18:32:35.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7651" PostTypeId="1" CreationDate="2016-05-05T17:36:01.393" Score="1" ViewCount="244" Body="&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#object-motions&quot; rel=&quot;nofollow&quot;&gt;Text object motions&lt;/a&gt; are useful to move around in a file. Although these motion commands were specifically created for text (novel) writers, they can also be used in C source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The commands &lt;code&gt;gd&lt;/code&gt; and &lt;code&gt;gD&lt;/code&gt; make use of object-motions and I find them very helpful when working with C, but as far as I can tell there is no way of making it work for languages that do not use brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can see that it is possible to workaround this by remapping all these commands (example &lt;a href=&quot;https://github.com/edkolev/erlang-motions.vim/blob/master/after/ftplugin/erlang.vim&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But is there a way of configuring object-motions for languages that do not make use of brackets, such that the command &lt;code&gt;gd&lt;/code&gt; would be able to quickly find local variable definitions without having to remap it to a custom function?&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="599" LastEditDate="2016-05-07T02:38:20.193" LastActivityDate="2016-05-07T02:38:20.193" Title="How to customize object-motions?" Tags="|object-motions|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7652" PostTypeId="2" ParentId="7647" CreationDate="2016-05-05T18:46:04.230" Score="4" Body="&lt;p&gt;It's ... built-in. It's just not line completion, because, you're saying it, it's not an entire line you want to complete. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we start from your example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;; A sentence I would like to auto complete.&#xA;...&#xA;A sentence|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I now press &lt;code&gt;C-n&lt;/code&gt;, followed by &lt;code&gt;C-x C-n&lt;/code&gt; (secret sauce! - &lt;em&gt;context&lt;/em&gt; completion) it will complete the following word. Press &lt;code&gt;C-x C-n&lt;/code&gt; repeatedly to further complete the next words. If it doesn't work, try it from a &lt;code&gt;vim -N -u NONE&lt;/code&gt; and go from there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should probably use a more complex example, one that have multiple variants, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;; A sentence I would like to auto complete.&#xA;; A sentence you don't like to complete.&#xA;...&#xA;A sentence|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, when you hit a &quot;branch&quot; with options (e.g. &lt;code&gt;I&lt;/code&gt; or &lt;code&gt;you&lt;/code&gt;), you should select the continuation you want using the usual &lt;code&gt;C-p&lt;/code&gt; / &lt;code&gt;C-n&lt;/code&gt; keys, then go on with &lt;code&gt;C-x C-n&lt;/code&gt; as before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find the docs at &lt;code&gt;:h i_CTRL-X_CTRL-N&lt;/code&gt;, in the 2nd part (quoted, for reference):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    CTRL-N          Search forward for next matching keyword.  This&#xA;                    keyword replaces the previous matching keyword.&#xA;&#xA;    CTRL-P          Search backwards for next matching keyword.  This&#xA;                    keyword replaces the previous matching keyword.&#xA;&#xA;    CTRL-X CTRL-N or&#xA;    CTRL-X CTRL-P   Further use of CTRL-X CTRL-N or CTRL-X CTRL-P will&#xA;                    copy the words following the previous expansion in&#xA;                    other contexts unless a double CTRL-X is used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-05-05T18:53:44.500" LastActivityDate="2016-05-05T18:53:44.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7653" PostTypeId="2" ParentId="34" CreationDate="2016-05-05T21:36:49.147" Score="25" Body="&lt;p&gt;My own favorite addition Neovim brings to the table is terminal mode. You can now split your Neovim window and have a terminal emulator running on one side and be editing a file on the other side! I suppose you could even run Neovim inside of itself now, just in case you really wanted to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having asynchronous plugins is also going to be extremely useful soon; this means we're finally able to have really good code completion, after only 40 years of waiting!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neovim also has better mouse support than Vim does.&lt;/p&gt;&#xA;" OwnerUserId="7531" LastEditorUserId="7531" LastEditDate="2016-05-05T22:36:27.223" LastActivityDate="2016-05-05T22:36:27.223" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="7654" PostTypeId="2" ParentId="7644" CreationDate="2016-05-06T03:12:07.817" Score="18" Body="&lt;p&gt;I actually fixed this myself a long time ago.  The problem is that when you run &lt;code&gt;!python&lt;/code&gt; you're starting up a new shell with your existing environment.  But, this means &lt;code&gt;workon xxxx&lt;/code&gt; wasn't called to actually activate the virtualenv.  This lead to a lot of confusion for me since &lt;code&gt;$VIRTUAL_ENV&lt;/code&gt; was set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got around it by adding the following to my &lt;code&gt;~/.zshenv&lt;/code&gt; script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [[ -n $VIRTUAL_ENV &amp;amp;&amp;amp; -e &quot;${VIRTUAL_ENV}/bin/activate&quot; ]]; then&#xA;  source &quot;${VIRTUAL_ENV}/bin/activate&quot;&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;~/.zshenv&lt;/code&gt; is sourced within the current session, it's a pretty safe assumption that the &lt;code&gt;$VIRTUAL_ENV&lt;/code&gt; wasn't activated.  Now when you run &lt;code&gt;!python&lt;/code&gt; in Vim, it should use the virtualenv interpreter.  You can confirm this by running &lt;code&gt;:echo system('which python')&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-05-06T13:49:05.430" LastActivityDate="2016-05-06T13:49:05.430" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7655" PostTypeId="2" ParentId="7615" CreationDate="2016-05-06T03:25:47.390" Score="3" Body="&lt;p&gt;There is an open issue: &lt;a href=&quot;https://github.com/benekastah/neomake/issues/309&quot; rel=&quot;nofollow&quot;&gt;Do not run makers on &lt;code&gt;:wq&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The workaround mentioned in that issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! QuitPre * let g:neomake_verbose = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-05-06T03:25:47.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7656" PostTypeId="1" AcceptedAnswerId="7911" CreationDate="2016-05-06T06:26:45.820" Score="8" ViewCount="5487" Body="&lt;p&gt;I want to work between two vimwiki directories: a private vimwiki and a public vimwiki.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get multiple vimwikis in the gvim &lt;code&gt;Vimwiki &amp;gt; Open index &amp;gt;&lt;/code&gt;  menu?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my ~/.vimrc I have the two wikis defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vimwiki &#xA;let wiki_1 = {}&#xA;let wiki_1.path = '~/vimwiki'&#xA;let wiki_1.path_html = '~/vimwiki_html'&#xA;let wiki_2 = {}&#xA;let wiki_2.path = '~/private'&#xA;let wiki_2.path_html = '~/private_html'&#xA;let g:vimwiki_list = [wiki_1, wiki_2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In vim and gvim, when I press &lt;code&gt;\ws&lt;/code&gt; I can see the two options, as I expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1   ~/vimwiki/                                         &#xA;2 * ~/private/&#xA;Select Wiki (specify number):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, in gvim the menu only shows one entry, the tilde ( ~ ) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qYpzT.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qYpzT.png&quot; alt=&quot;gvim menu item Vimwiki &amp;gt; &amp;quot;Open Index&amp;quot; submenu item&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="1841" LastEditDate="2016-05-06T07:19:00.673" LastActivityDate="2020-02-11T09:26:53.347" Title="How do I get multiple vimwikis to show under &quot;Vimwiki / Open Index&quot; in the gvim menu?" Tags="|plugin-vimwiki|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7657" PostTypeId="2" ParentId="7645" CreationDate="2016-05-06T08:21:46.097" Score="2" Body="&lt;p&gt;This is a job for autocmds. This works for me:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;&quot; set by default&#xA;set cursorline&#xA;&quot; unset for specific cases  &#xA;autocmd BufEnter ~/Work/my_rails_project_1/*,~/Work/my_rails_project_2/* setlocal nocursorline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;*&lt;/code&gt;matches path separators, so this will apply to all directories inside &lt;code&gt;~/Work/my_rails_project_1/&lt;/code&gt; and &#xA;&lt;code&gt;~/Work/my_rails_project_2/&lt;/code&gt;. The &lt;code&gt;setlocal&lt;/code&gt; will restrict the change to matching buffers.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-05-06T08:21:46.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7658" PostTypeId="1" AcceptedAnswerId="7660" CreationDate="2016-05-06T09:18:12.910" Score="13" ViewCount="1493" Body="&lt;p&gt;I use the same versioned .vimrc on several machines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way of customise that file to enable/disable a plugin based on machine name or something like that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As example, I have something like that in my .bash_profile:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;# common things&#xA;...&#xA;&#xA;if [[ $(uname) == &quot;Darwin&quot; ]]&#xA;then&#xA;     # mac settings&#xA;else&#xA;     # linux settings&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6754" LastEditorUserId="205" LastEditDate="2016-05-25T17:18:28.433" LastActivityDate="2016-05-25T17:18:28.433" Title="Same vimrc, customized per machine" Tags="|vimrc|" AnswerCount="4" CommentCount="2" ClosedDate="2018-03-02T22:16:21.540" ContentLicense="CC BY-SA 3.0" />
  <row Id="7659" PostTypeId="2" ParentId="7658" CreationDate="2016-05-06T09:28:13.460" Score="7" Body="&lt;p&gt;Provided that you (or your system) can export the environmental variables that you need, you can do something like this in your &lt;code&gt;.vimrc&lt;/code&gt; (here I use the &lt;code&gt;vim-plug&lt;/code&gt; plugin manager as an example, and HOSTNAME is the exported variable you want to check):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype off&#xA;call plug#begin('~/.vim/plugged')&#xA;...&#xA;if executable('ctags') &amp;amp;&amp;amp; $HOSTNAME == 'macintosh'&#xA;    Plug 'Shougo/unite-outline'&#xA;    Plug 'tsukkee/unite-tag'&#xA;    Plug 'ludovicchabant/vim-gutentags'&#xA;endif&#xA;...&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's also common to use &lt;code&gt;has()&lt;/code&gt; (e.g. &lt;code&gt;has (&quot;gui_running&quot;)&lt;/code&gt; or &lt;code&gt;has (&quot;python&quot;)&lt;/code&gt;) to decide to install certain plugins.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-05-06T09:28:13.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7660" PostTypeId="2" ParentId="7658" CreationDate="2016-05-06T09:29:04.687" Score="15" Body="&lt;p&gt;You can access your environment variable and external command from vim, so you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if system('uname') =~ &quot;Darwin&quot;&#xA;     echo 'mac'&#xA;else&#xA;     echo 'other'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you can use &lt;code&gt;=~&lt;/code&gt; instead of &lt;code&gt;==&lt;/code&gt; to match the regex instead of the exact string (on my machine, &lt;code&gt;uname&lt;/code&gt; gives me a newline).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('$TMUX')&#xA;  echo 'in tmux'&#xA;else&#xA;  echo 'not in tmux'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-06T09:34:22.010" LastActivityDate="2016-05-06T09:34:22.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7661" PostTypeId="1" CreationDate="2016-05-06T10:02:00.187" Score="1" ViewCount="412" Body="&lt;p&gt;I have just set up the &lt;a href=&quot;https://github.com/jalvesaq/Nvim-R&quot; rel=&quot;nofollow&quot;&gt;Nvim-R&lt;/a&gt; plugin for &lt;code&gt;Neovim&lt;/code&gt; to send lines of code from an &lt;code&gt;.R&lt;/code&gt;-file opened with &lt;code&gt;Neovim&lt;/code&gt; to a terminal inside a &lt;code&gt;tmux&lt;/code&gt; session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Previously, I have worked with its predecessor &lt;a href=&quot;https://github.com/jcfaria/Vim-R-plugin&quot; rel=&quot;nofollow&quot;&gt;Vim-R&lt;/a&gt;, which is no longer being maintained. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the old &lt;code&gt;Vim-R&lt;/code&gt;, it was easy to send a visually selected block of code to the terminal by pressing the &lt;code&gt;r&lt;/code&gt; key while in visual mode after adding the following line to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vimrplugin_map_r = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this feature seems to be deprecated in the new &lt;code&gt;Nvim-R&lt;/code&gt;-plugin. As a workaround I have tried to add the following line to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;Space&amp;gt; &amp;lt;Plug&amp;gt;RDSendSelection &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This actually allows me to send a visually selected section to the terminal, however, it always includes the next non-empty line after the selection, which is irritating. This is especially so, because it even ignores multiple blank lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I modify this behavior?&lt;/p&gt;&#xA;" OwnerUserId="7533" LastEditorUserId="1821" LastEditDate="2016-05-06T10:05:48.050" LastActivityDate="2016-05-06T10:05:48.050" Title="Visual selection in Nvim-R plugin sends one line too much to terminal" Tags="|terminal|neovim|tmux|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7662" PostTypeId="1" AcceptedAnswerId="7668" CreationDate="2016-05-06T10:12:58.310" Score="2" ViewCount="1642" Body="&lt;p&gt;How to put at end of line with vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to use &lt;code&gt;p&lt;/code&gt; to put some text at the end of the current line without moving the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I would like to copy a word to the end of the line so I use &lt;code&gt;yw&lt;/code&gt; to copy the word and then how can I put it to the end of the current line?&lt;/p&gt;&#xA;" OwnerUserId="5154" LastEditorUserId="1841" LastEditDate="2016-05-06T13:10:26.607" LastActivityDate="2016-05-06T14:04:43.887" Title="How to put at end of line?" Tags="|normal-mode|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7663" PostTypeId="2" ParentId="7662" CreationDate="2016-05-06T11:00:43.517" Score="3" Body="&lt;p&gt;If I understand correctly, you want to &lt;strong&gt;put&lt;/strong&gt; a word at the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do that with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$&lt;/code&gt; move the cursor to the end of the line, &lt;code&gt;p&lt;/code&gt; put.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;print&lt;/code&gt; command on the other hand, is used to display lines of your file, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,2p &quot;print the first and second line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ref:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h p&lt;/code&gt;  (put)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :p&lt;/code&gt; (print)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorDisplayName="user859" LastEditDate="2016-05-06T14:01:18.860" LastActivityDate="2016-05-06T14:01:18.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7664" PostTypeId="2" ParentId="7662" CreationDate="2016-05-06T11:04:16.000" Score="3" Body="&lt;p&gt;You want to &quot;put&quot;, not &quot;print&quot;.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Move the cursor to the end of the line with &lt;code&gt;$&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;code&gt;p&lt;/code&gt; to &quot;put&quot; the content of the unnamed register (what you yanked with &lt;code&gt;yw&lt;/code&gt;) after the cursor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help p&lt;/code&gt;, &lt;code&gt;:help registers&lt;/code&gt;, &lt;code&gt;:help :print&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-05-06T11:04:16.000" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7665" PostTypeId="1" AcceptedAnswerId="7666" CreationDate="2016-05-06T13:05:27.047" Score="8" ViewCount="15477" Body="&lt;p&gt;I want to open another file in the same directory or any file with its path relative to the current directory  in command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My path is &lt;code&gt;/home/sibich/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; /home/sibich&amp;gt; vim a.pl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In vim,  I want to open b.pl in same directory, so I use :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vim b.pl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Bit I receive this message &lt;code&gt;Invalid pattern or filename&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I had to give it in shell.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  :!vim b.pl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to directly execute this in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example 2: sub is a folder under &lt;code&gt;/home/sibich&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  :vim sub/c.pl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to set options such that command line accepts path relative to current directory and allows opening files through split, tabnew and vim commands?&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="1841" LastEditDate="2016-05-06T13:45:20.883" LastActivityDate="2017-12-14T00:06:27.207" Title="opening another file with path relative to current directory" Tags="|working-directory|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7666" PostTypeId="2" ParentId="7665" CreationDate="2016-05-06T13:13:35.420" Score="20" Body="&lt;p&gt;Have you tried the edit command?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit b.pl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: Not sure if you edited in the last question, or I just missed it the first time. But the only reason you wouldn't be able to use relative paths on &lt;code&gt;:split&lt;/code&gt; or &lt;code&gt;:tabnew&lt;/code&gt; is if your current working directory isn't the same as the file you're currently editing. So I think what you're looking for is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set autochdir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This option basically makes your current working directory &quot;follow&quot; you whenever you change buffers. With that options set, you should be able to use relative paths. See &lt;code&gt;:h autochdir&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-05-06T14:12:57.210" LastActivityDate="2016-05-06T14:12:57.210" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7667" PostTypeId="1" CreationDate="2016-05-06T14:03:21.653" Score="1" ViewCount="47" Body="&lt;p&gt;I've noticed that omnicomplete and keyboard motions don't work in XML files with a &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; tag as expected. For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;related-links scope=&quot;external&quot; format=&quot;html&quot;&amp;gt;&#xA;    &amp;lt;link href=&quot;www.example.org&quot;&amp;gt;&#xA;        &amp;lt;linktext&amp;gt;Example Link&amp;lt;/linktext&amp;gt;&#xA;    &amp;lt;/link&amp;gt;&#xA;&amp;lt;/related-links&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I put the cursor within the &lt;code&gt;&amp;lt;link&amp;gt;...&amp;lt;/link&amp;gt;&lt;/code&gt; block and press &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;, I would expect to select lines 2-4. Instead it selects the outer tag (&lt;code&gt;&amp;lt;related-links&amp;gt;&lt;/code&gt; in this case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another example of this issue happened with the following XML file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;related-links scope=&quot;external&quot; format=&quot;html&quot;&amp;gt;&#xA;    &amp;lt;link href=&quot;www.example.org&quot;&amp;gt;&#xA;        &amp;lt;linktext&amp;gt;Example Link&amp;lt;/linktext&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I should be able to type &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt;,&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;o&lt;/kbd&gt; to invoke omnicomplete to close the &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; tag. Instead it skips it and closes the &lt;code&gt;&amp;lt;related-links&amp;gt;&lt;/code&gt; tag instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've noticed this issue with a few different versions of Vim. Is this the intended behavior of the built-in XML ft? If so, why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;I &lt;em&gt;am&lt;/em&gt; able to reproduce this with &lt;code&gt;vim --noplugin -u NONE -N&lt;/code&gt; (if I set &lt;code&gt;:filetype indent plugin on&lt;/code&gt; after starting Vim). This was with Vim 7.2.&lt;/p&gt;&#xA;" OwnerUserId="3264" LastEditorUserId="3264" LastEditDate="2016-05-06T15:32:09.090" LastActivityDate="2016-05-06T15:32:09.090" Title="Why does Vim treat the `&lt;link&gt;` tag in XML files differently?" Tags="|filetype-xml|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="7668" PostTypeId="2" ParentId="7662" CreationDate="2016-05-06T14:04:43.887" Score="5" Body="&lt;p&gt;If you want your cursor back to its previous position after putting the text at the end of the line you could use marks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ma$p`a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ma&lt;/code&gt; sets the mark &lt;code&gt;a&lt;/code&gt; to the current position&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$p&lt;/code&gt; As explained is the other answers put the text at the end of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(backtick)a&lt;/code&gt; go back to the position marked by &lt;code&gt;ma&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-05-06T14:04:43.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7669" PostTypeId="2" ParentId="4050" CreationDate="2016-05-06T15:34:33.037" Score="0" Body="&lt;p&gt;If you're searching for the string 'morning' inside file&#xA;&lt;code&gt;/morning&lt;/code&gt; then &lt;kbd&gt;enter&lt;/kbd&gt; and press &lt;kbd&gt;n&lt;/kbd&gt; to move forward direction&lt;/p&gt;&#xA;" OwnerUserId="7534" LastEditorUserId="1841" LastEditDate="2016-05-06T15:50:03.127" LastActivityDate="2016-05-06T15:50:03.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7670" PostTypeId="2" ParentId="7658" CreationDate="2016-05-06T16:52:36.747" Score="10" Body="&lt;p&gt;In order not to depend on external commands my suggestion would be to use something like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('mac')&#xA;     echo 'mac'&#xA;elseif has('win32') || has('win64')&#xA;     echo 'windows'&#xA;elseif has('unix')&#xA;     echo 'unix/linux'&#xA;else&#xA;     echo 'something else'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="599" LastActivityDate="2016-05-06T16:52:36.747" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7671" PostTypeId="2" ParentId="5869" CreationDate="2016-05-06T17:40:53.810" Score="2" Body="&lt;p&gt;It's not exactly what you asked, but it might be closer to what you really want:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In bash, you can type in vi mode! Just put type &lt;code&gt;set -o vi&lt;/code&gt; into bash and you'll be able to hit escape to switch to normal mode. Stick it in your .bashrc file for it to become an incredibly useful permanent change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: I just realized that this might be why you can't (by default) exit Neovim terminal mode with escape.&lt;/p&gt;&#xA;" OwnerUserId="7531" LastActivityDate="2016-05-06T17:40:53.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7672" PostTypeId="1" AcceptedAnswerId="7673" CreationDate="2016-05-06T19:19:16.783" Score="1" ViewCount="444" Body="&lt;p&gt;I have an XML file with this format (there could be some leading spaces):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    &amp;lt;Latitude&amp;gt;23.1138&amp;lt;/Latitude&amp;gt;&#xA;    &amp;lt;Longitude&amp;gt;8.2898&amp;lt;/Longitude&amp;gt;&#xA;    ...&#xA;    &amp;lt;Latitude&amp;gt;19.6247&amp;lt;/Latitude&amp;gt;&#xA;    &amp;lt;Longitude&amp;gt;-7.3267&amp;lt;/Longitude&amp;gt;&#xA;    ...&#xA;    &amp;lt;Latitude&amp;gt;49.4141&amp;lt;/Latitude&amp;gt;&#xA;    &amp;lt;Longitude&amp;gt;15.374&amp;lt;/Longitude&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using Vim, I would like to convert each line to Cesium's KML format like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    &amp;lt;Point&amp;gt;&amp;lt;coordinates&amp;gt;15.374,49.4141&amp;lt;/coordinates&amp;gt;&amp;lt;/Point&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is important to note KML puts the longitude first (contrary to every other standard). Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="7298" LastEditorUserId="6698" LastEditDate="2016-05-10T07:06:53.340" LastActivityDate="2016-05-10T21:22:44.190" Title="Conversion from XML to KML" Tags="|formatting|macro|filetype-xml|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7673" PostTypeId="2" ParentId="7672" CreationDate="2016-05-06T19:34:21.067" Score="3" Body="&lt;p&gt;I've come up with a search and replace function that should work for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(\s*\)&amp;lt;Latitude&amp;gt;\(-\=\d\+\.\d\+\)&amp;lt;\/Latitude&amp;gt;\_.\s*&amp;lt;Longitude&amp;gt;\(-\=\d\+\.\d\+\)&amp;lt;\/Longitude&amp;gt;/\1&amp;lt;Point&amp;gt;&amp;lt;coordinates&amp;gt;\3,\2&amp;lt;\/coordinates&amp;gt;&amp;lt;\/Point&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure to save your work as this command is destructive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s&lt;/code&gt; Does a search and replace over the all lines. I've swapped the two by using memory parenthesis &lt;code&gt;\(\)&lt;/code&gt; and then using backreferences in reverse order. ie. &lt;code&gt;\2\1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I've updated the function to take whitespace before the &lt;code&gt;&amp;lt;Longitude&amp;gt;&lt;/code&gt; tags into account.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-05-06T20:08:46.810" LastActivityDate="2016-05-06T20:08:46.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7674" PostTypeId="1" CreationDate="2016-05-06T22:35:52.043" Score="0" ViewCount="134" Body="&lt;p&gt;I have a bunch of includes at the top of my file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I use methods from the helpers throughout my file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I have it so that when my cursor is on a method name my editor can (by some keystrokes) opens up that file and go to the method definition?&lt;/p&gt;&#xA;" OwnerUserId="2041" LastActivityDate="2017-05-03T13:44:05.247" Title="When editing a ruby file with includes/requires how can I open the file containing the method I am on?" Tags="|filesystem|file-operations|include|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7675" PostTypeId="2" ParentId="7674" CreationDate="2016-05-07T06:41:16.903" Score="1" Body="&lt;p&gt;Use either &lt;code&gt;[d&lt;/code&gt; or &lt;code&gt;[i&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help include-search&lt;/code&gt; is a built-in but sadly overlooked feature.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-05-07T06:41:16.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7677" PostTypeId="1" AcceptedAnswerId="7678" CreationDate="2016-05-07T09:43:13.323" Score="5" ViewCount="1231" Body="&lt;p&gt;I want to create alert/prompt message in vim based on user's action. For example, if the user tries to save a changed config file, a message has to be shown like 'this is a config file and changing it might affect the project. Make sure you are confirm in saving it' and gthen show options like yes, no or quit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to make user defined alert/prompt messages in vim?&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-05-07T12:53:54.517" LastActivityDate="2016-05-07T12:53:54.517" Title="Creating user's own alert/prompt message" Tags="|vimscript|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7678" PostTypeId="2" ParentId="7677" CreationDate="2016-05-07T10:13:26.587" Score="6" Body="&lt;p&gt;You could try the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup CustomSaving&#xA;    autocmd!&#xA;    autocmd BufWriteCmd /tmp/* if &amp;amp;l:modified | call s:AskForConfirmation() | endif&#xA;augroup END&#xA;&#xA;function! s:AskForConfirmation() abort&#xA;    echom 'This is a config file and changing it might affect the project.'&#xA;    echom 'Are you sure you want to save?'&#xA;    while 1&#xA;        let choice = inputlist(['1. yes', '2. no', '3. quit'])&#xA;        if choice == 0 || choice &amp;gt; 3&#xA;            redraw!&#xA;            echohl WarningMsg&#xA;            echo 'Please enter a number between 1 and 3'&#xA;            echohl None&#xA;            continue&#xA;        elseif choice == 1&#xA;            silent! write&#xA;        elseif choice == 3&#xA;            quit!&#xA;        endif&#xA;        break&#xA;    endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently it would only affect the files under the &lt;code&gt;/tmp&lt;/code&gt; directory. If you wanted it to work for your project files, you would have to change the pattern &lt;code&gt;/tmp/*&lt;/code&gt; inside the autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWriteCmd /tmp/* if &amp;amp;l:modified | call s:AskForConfirmation() | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Into something like &lt;code&gt;/path/to/project/*&lt;/code&gt;, or if your config files have all the &lt;code&gt;.conf&lt;/code&gt; extension, into &lt;code&gt;/path/to/project/*.conf&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-05-07T12:50:07.337" LastActivityDate="2016-05-07T12:50:07.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7679" PostTypeId="2" ParentId="7542" CreationDate="2016-05-07T11:21:03.433" Score="1" Body="&lt;p&gt;I had tried version &lt;code&gt;7.4.1795&lt;/code&gt; before, but the results was the same. Now I upgraded &lt;code&gt;vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;brew upgrade vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the current version &lt;code&gt;7.4.1817&lt;/code&gt; the problem is solved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you all for your comments. This is the output of &lt;code&gt;vim --version&lt;/code&gt; on my OS X 10.11.4 now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May  7 2016 15:14:50)&#xA;MacOS X (unix) version&#xA;Included patches: 1-1817&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +tag_binary&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_old_static&#xA;+autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;-balloon_eval    +float           +mouse_urxvt     -tcl&#xA;-browse          +folding         +mouse_xterm     +termguicolors&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+channel         -gettext         -mzscheme        +textobjects&#xA;+cindent         -hangul_input    +netbeans_intg   +timers&#xA;-clientserver    +iconv           +packages        +title&#xA;+clipboard       +insert_expand   +path_extra      -toolbar&#xA;+cmdline_compl   +job             +perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python          +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            +ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      +startuptime     -xsmp&#xA;+eval            +mouse_dec       +statusline      -xterm_clipboard&#xA;+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save&#xA;+extra_search    -mouse_jsbterm   +syntax          -xpm&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -F/usr/local/Frameworks -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: /usr/bin/clang   -L. -L/usr/local/lib -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python   -lruby.2.0.0 -lobjc    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7357" LastActivityDate="2016-05-07T11:21:03.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7680" PostTypeId="1" CreationDate="2016-05-07T12:56:10.863" Score="1" ViewCount="48" Body="&lt;p&gt;One can make &lt;code&gt;e/&lt;/code&gt; produce &lt;code&gt;é&lt;/code&gt; with &lt;code&gt;inoremap e/ é&lt;/code&gt;; but this only works if &lt;code&gt;/&lt;/code&gt; is typed before &lt;code&gt;timeoutlen&lt;/code&gt; seconds have passed.  Is there a way to make &lt;code&gt;/&lt;/code&gt; after &lt;code&gt;e&lt;/code&gt; produce the same result, regardless of the time elapsed?  The bare &lt;code&gt;e&lt;/code&gt; should be visible after timeout, but changed if a &lt;code&gt;/&lt;/code&gt; is entered.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-05-08T02:53:19.160" Title="Adding diacritics slowly" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7681" PostTypeId="1" CreationDate="2016-05-07T15:21:07.893" Score="5" ViewCount="372" Body="&lt;p&gt;If I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo system('grep -IRn foobar ~/.vim | grep -v backup')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim displays the output of the shell command:&lt;br&gt;&#xA;&lt;code&gt;$ grep -IRn foobar ~/.vim | grep -v backup&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which is the list of files containing the pattern &lt;code&gt;foobar&lt;/code&gt; inside the folder &lt;code&gt;~/.vim&lt;/code&gt;, after removing the matches containing the pattern &lt;code&gt;backup&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo expand('`grep -IRn foobar ~/.vim | grep -v backup`')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim does the same thing (without the newline at the end).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e `=system('grep -IRn foobar ~/.vim | grep -v backup | tail -1 | cut -d: -f1')`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim edits the last file from the output of the previous shell command.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The last 3 commands work without escaping the pipe.&#xA;The latter is never interpreted as a command termination, probably because it's protected by the string. Maybe for the same reason this command works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo 'hello | world'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But If I want to populate the quickfix list with the same shell command and I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cexpr system('grep -IRn foobar ~/.vim | grep -v backup')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have the following errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E115: Missing quote: 'grep -IRn foobar ~/.vim &#xA;E116: Invalid arguments for function system('grep -IRn foobar ~/.vim &#xA;E15: Invalid expression: system('grep -IRn foobar ~/.vim &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that the pipe was interpreted as a command termination, and that it must be escaped:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cexpr system('grep -IRn foobar ~/.vim \| grep -v backup')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pipe is inside a string, and the command is almost identical to the first one with &lt;code&gt;:echo&lt;/code&gt; where the pipe is not escaped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is it suddenly interpreted as a command termination with &lt;code&gt;:cexpr system('shell cmd')&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-05-07T15:33:47.663" LastActivityDate="2019-12-06T23:38:40.300" Title="Why is a pipe interpreted as a command termination in :cexpr system('shell cmd')?" Tags="|command-line|external-command|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="7683" PostTypeId="1" AcceptedAnswerId="7748" CreationDate="2016-05-07T18:56:26.690" Score="2" ViewCount="1465" Body="&lt;p&gt;I try to get python support in gvim on windows to work with the help of &lt;a href=&quot;https://tuxproject.de/projects/vim/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; binary distribution.&lt;br&gt;&#xA;First I got the error &lt;code&gt;python27.dll could not be located&lt;/code&gt;, what I successfully fixed by copying &lt;code&gt;python27.dll&lt;/code&gt; to the &lt;code&gt;vim74&lt;/code&gt; directory.&lt;br&gt;&#xA; Although &lt;code&gt;:echo has('python')&lt;/code&gt; returns 1 now, if I try to execute &lt;code&gt;:py print(1)&lt;/code&gt; I get this error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Sorry, this command is disabled, the Pythons's site module could not be loaded&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I just don't understand what Vim is trying to tell me by that and what the problem is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;vim 7.4.1817 64bit&lt;/code&gt; with &lt;code&gt;+python/dyn&lt;/code&gt; &amp;amp; &lt;code&gt;+python3/dyn&lt;/code&gt; and &lt;code&gt;python 2.7.9 64bit&lt;/code&gt; (the newer &lt;code&gt;python 2.7.11 64bit&lt;/code&gt; produces the same behaviour)&lt;/p&gt;&#xA;" OwnerUserId="7555" LastEditorUserId="1746" LastEditDate="2016-05-26T23:07:50.473" LastActivityDate="2016-05-26T23:07:50.473" Title="What does vim try to tell me with: 'Sorry, this command is disabled, the Pythons's site module could not be loaded'?" Tags="|gvim|microsoft-windows|vimscript-python|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7684" PostTypeId="1" AcceptedAnswerId="7692" CreationDate="2016-05-07T20:27:10.943" Score="2" ViewCount="953" Body="&lt;p&gt;When I try and trigger PHPUnit tests within MacVim, I can't see coloured outputs in my command line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ntJRx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ntJRx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5991" LastEditorUserId="5991" LastEditDate="2016-05-08T08:45:07.630" LastActivityDate="2020-07-05T12:54:44.017" Title="Can't get color output in MacVim's command line" Tags="|command-line|macvim|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7686" PostTypeId="2" ParentId="7593" CreationDate="2016-05-07T22:00:43.957" Score="3" Body="&lt;p&gt;I'm not entirely sure what you want to accomplish, but from what I understand, you want to easily create boxes using commands/functions.  Maybe this will help you get started on a solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:makebox(...) abort&#xA;  let width = str2nr(a:1)&#xA;  let height = a:0 &amp;lt; 2 ? width : str2nr(a:2)&#xA;  let margin = a:0 &amp;gt; 2 ? str2nr(a:3) : 0&#xA;  let r_margin = repeat(' ', margin)&#xA;&#xA;  let x = '+'.repeat('-', width - 2).'+'.r_margin&#xA;  let y = '|'.repeat(' ', width - 2).'|'.r_margin&#xA;&#xA;  let lines = [x]&#xA;  call extend(lines, repeat([y], height - 2))&#xA;  call add(lines, x)&#xA;  call setreg('b', lines, 'b'.(width + margin))&#xA;endfunction&#xA;&#xA;&#xA;command! -nargs=+ MakeBox call s:makebox(&amp;lt;f-args&amp;gt;)&#xA;nnoremap &amp;lt;leader&amp;gt;b mb$&quot;bp`b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You create a box with &lt;code&gt;MakeBox width [[height] margin]&lt;/code&gt; which stores it in the &lt;code&gt;b&lt;/code&gt; register as blockwise text.  The &lt;code&gt;height&lt;/code&gt; and &lt;code&gt;margin&lt;/code&gt; are optional.  &lt;code&gt;&amp;lt;leader&amp;gt;b&lt;/code&gt; makes it easy to paste the stored box at the end of the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4hVHr.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4hVHr.gif&quot; alt=&quot;MakeBox example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-05-07T22:00:43.957" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7687" PostTypeId="1" AcceptedAnswerId="7690" CreationDate="2016-05-08T00:31:24.893" Score="5" ViewCount="1971" Body="&lt;p&gt;I tried python-mode, it seems that it can work when I press &lt;kbd&gt;K&lt;/kbd&gt; on &quot;numpy.array&quot;, but if I want to press &lt;kbd&gt;K&lt;/kbd&gt; on &quot;np.array&quot;, it won't work.&lt;/p&gt;&#xA;" OwnerUserId="7558" LastActivityDate="2018-08-05T20:48:14.640" Title="How can I get python library help in vim?" Tags="|vimscript-python|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7688" PostTypeId="2" ParentId="7672" CreationDate="2016-05-08T02:46:51.707" Score="1" Body="&lt;p&gt;If the XML file only have lines in that format you could try this shorter command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v\S{-}([0-9.-]+)\_.{-}([0-9.-]+)\S*/&amp;lt;Point&amp;gt;&amp;lt;coordinates&amp;gt;\2,\1&amp;lt;\/coordinates&amp;gt;&amp;lt;\/Point&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; stands for “Very magic”.  It means that in the pattern after it all ASCII characters except&#xA;&lt;code&gt;0-9&lt;/code&gt;, &lt;code&gt;a-z&lt;/code&gt;,  &lt;code&gt;A-Z&lt;/code&gt; and &lt;code&gt;_&lt;/code&gt; have a special meaning, so it isn't necessary to prefix them with (&lt;code&gt;\&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\S&lt;/code&gt; matches any character except whitespaces.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;{-}&lt;/code&gt; is the non-greedy version of &lt;code&gt;*&lt;/code&gt;,  i.e., matches &lt;code&gt;0&lt;/code&gt; or more of the preceding atom, as few as possible (see &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#non-greedy&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help non-greedy&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://stackoverflow.com/a/3075532/1121933&quot;&gt;this&lt;/a&gt; answer for details)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\S{-}&lt;/code&gt; matches the XML tag and without considering any leading spaces.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[0-9.-]+&lt;/code&gt; matches a number.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;([0-9.-]+)&lt;/code&gt; preserves the fist number in a sub-expression so that it's possible to reuse it in the substitution part with &lt;code&gt;\1&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\_.&lt;/code&gt; matches any single character or end-of-line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\_.{-}&lt;/code&gt; matches the &lt;code&gt;&amp;lt;/Latitude&amp;gt;&lt;/code&gt; tag, end-of-line, any leading space on the next line, and the &lt;code&gt;&amp;lt;Longitude&amp;gt;&lt;/code&gt; tag.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;([0-9.-]+)&lt;/code&gt; preserves the second number in a sub-expression so that it's possible to reuse it with &lt;code&gt;\2&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\S*&lt;/code&gt; matches the &lt;code&gt;&amp;lt;/Longitude&amp;gt;&lt;/code&gt; tag.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-05-09T20:12:53.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7689" PostTypeId="2" ParentId="7680" CreationDate="2016-05-08T02:53:19.160" Score="1" Body="&lt;p&gt;You could use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:accent_e()&#xA;  if getline('.') =~# 'e/$'&#xA;    call feedkeys(&quot;\&amp;lt;bs&amp;gt;\&amp;lt;bs&amp;gt;é&quot;)&#xA;  endif&#xA;endfunction&#xA;&#xA;autocmd! TextChangedI * call s:accent_e()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, that doesn't seem like a good solution.  You'll end up needing a way to disable it if you want to type path components that end with an &lt;code&gt;e&lt;/code&gt; since &lt;code&gt;i_CTRL-V&lt;/code&gt; wouldn't help with the method above.  Have you looked at &lt;code&gt;:help digraph&lt;/code&gt; and &lt;code&gt;:help i_CTRL-K&lt;/code&gt;?  In insert mode you can type &lt;kbd&gt;Ctrl-K&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt; to get &lt;code&gt;é&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few other examples:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl-K&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;kbd&gt;!&lt;/kbd&gt; = &lt;code&gt;è&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl-K&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt; = &lt;code&gt;ë&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;kbd&gt;Ctrl-K&lt;/kbd&gt;, not only will you be deliberate with the character entry, you'll have all the time you need.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-05-08T02:53:19.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7690" PostTypeId="2" ParentId="7687" CreationDate="2016-05-08T03:20:01.047" Score="9" Body="&lt;p&gt;Try using the &lt;a href=&quot;https://github.com/davidhalter/jedi-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;jedi-vim&lt;/a&gt; plugin.  It uses &lt;a href=&quot;https://github.com/davidhalter/jedi&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jedi&lt;/a&gt; to get completions and is much better at doing so than python-rope is.  It will resolve &lt;code&gt;np.array&lt;/code&gt; to &lt;code&gt;numpy.array&lt;/code&gt; and show the appropriate documentation in a tab/split.  Be warned that numpy is notoriously slow for Jedi to resolve when it's not cached.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;zondo's suggestion to use &lt;code&gt;:!pydoc numpy.array&lt;/code&gt; does work, but I find it annoying because I can't use Vim mappings to navigate the output, yank text from it, or leave it open for reference.  There's also the issue of using a virutalenv, which may not have &lt;code&gt;pydoc&lt;/code&gt; in the virtualenv's &lt;code&gt;$PATH&lt;/code&gt;.  In that case, you would have to use: &lt;code&gt;:!python -m pydoc numpy.array&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="16967" LastEditDate="2018-08-05T20:48:14.640" LastActivityDate="2018-08-05T20:48:14.640" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="7691" PostTypeId="1" CreationDate="2016-05-08T15:11:52.707" Score="1" ViewCount="140" Body="&lt;p&gt;First, I propose that this question be made into a &lt;a href=&quot;https://meta.stackexchange.com/questions/11740/what-are-community-wiki-posts&quot;&gt;community wiki&lt;/a&gt;--can a mod please do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I'd like to keep answers focused on one of two related but distinct themes: (a) how vim translates to a device with a touch screen, and (b) how vim translates to a device with a &lt;em&gt;small&lt;/em&gt; screen. I'd like completely to ignore a related issue (c) consisting of limitations imposed by particular mobile-device operating systems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are already some tools (some mentioned &lt;a href=&quot;https://vi.stackexchange.com/questions/13/does-any-solution-exist-to-use-vim-from-touch-screen&quot;&gt;here&lt;/a&gt;) to bring vim to mobile devices, which typically &lt;em&gt;combine&lt;/em&gt; ideas (a), (b), and (c); that is, they are efforts to make a small-screen, touch-screen vim on particular mobile platforms. However I think these efforts and answers sometimes miss the point because they conflate which of (a)/(b)/(c) are the issues they try to solve. Vim with a full external keyboard plugged into a jailbroken mobile device with a 4&quot; screen would largely function like any other vim; no further changes would be needed except possibly some zoom feature unavailable in traditional vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I would like vim users to offer their thoughts on what particular adaptations could be made to vim to accommodate (a) touch screens, with on-screen keyboards, and (b) small screens (independent of whether the keyboard is on-screen or external). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a simple example, an answer that seems appropriate regarding issue (a) would be:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A major advantage of using vim with a separate keyboard is navigating with the &lt;code&gt;hjkl&lt;/code&gt; keys, particularly because these keys are in the home row on a keyboard / are naturally where one's fingers rest when using a keyboard. Since on-screen keyboards do not have a natural resting point for the fingers, there is not an analogous advantage to navigating with keys in a particular row of the keyboard (though there may still be some advantage to navigating with keys all in the same row). Consequently, for a fully operational touch-screen vim to solve the document navigation problem as well as traditional vim, it would need a new paradigm for navigation. Since the natural resting stance for a touch screen is a finger over the screen, a potential navigation solution would be for directional finger motions over the screen to navigate in normal mode.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now please note that I am not claiming that I have offered a correct or great answer in my example, but there are three points about this example that I want to emphasize:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It expresses a feature of traditional vim that is a major selling point for vim / a highly desirable feature.&lt;/li&gt;&#xA;&lt;li&gt;It explains precisely why/how the touch-screen paradigm breaks this feature.&lt;/li&gt;&#xA;&lt;li&gt;It proposes a workaround for touch-screens to recover this feature.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;At the very least, components 1 and 2 are purely factual; while component 3 is subject to some debate, it is at least undebatable that the workaround &lt;em&gt;could&lt;/em&gt; work, and ideally via community discussion some understanding of the most promising solutions could be discovered.&lt;/p&gt;&#xA;" OwnerUserId="4985" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-06-10T22:46:59.553" Title="What are some ways vim's interface could accommodate small-screen and touch-screen devices?" Tags="|input-devices|" AnswerCount="0" CommentCount="6" ClosedDate="2016-05-09T11:25:15.057" ContentLicense="CC BY-SA 3.0" />
  <row Id="7692" PostTypeId="2" ParentId="7684" CreationDate="2016-05-08T17:19:39.607" Score="1" Body="&lt;p&gt;The GUI version of Vim (MacVim on Mac OS X, GVim everywhere else) comes with a &quot;dumb&quot; terminal emulator that doesn't understand color at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to run command-line programs without the ugly escape codes you'll need to either configure those programs to not use color when not possible or call them with dedicated options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!vendor/bin/phpunit --colors=never ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since we are at it:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Git&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The default value has been &lt;code&gt;auto&lt;/code&gt; for a while but if you use an old release:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ git config --global color.ui auto&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Npm&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This is a bit extreme but &lt;code&gt;npm&lt;/code&gt; expects a boolean, here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ npm config set color=false&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-05-08T17:19:39.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7693" PostTypeId="1" CreationDate="2016-05-08T18:16:33.950" Score="2" ViewCount="498" Body="&lt;p&gt;When I have a long constructor that forces me to put initialization list items on separate lines, my indentations look like this after &lt;code&gt;gg=G&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Really_Long_Class_Name::Really_Long_Class_Name(int _arg1, int _arg2) :&#xA;  arg1(_arg1),&#xA;  arg2(_arg2) {&#xA;    do_stuff();&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want it to be indented like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Really_Long_Class_Name::Really_Long_Class_Name(int _arg1, int _arg2) :&#xA;    arg1(_arg1),&#xA;    arg2(_arg2) {&#xA;  do_stuff();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After looking at a &lt;a href=&quot;https://stackoverflow.com/q/2288678/2680824&quot;&gt;similar question&lt;/a&gt;, I got closer by playing around with &lt;code&gt;cinoptions&lt;/code&gt;. By using &lt;code&gt;:set cino+=i4,e-4,0}-4&lt;/code&gt; I got it to look the way I want, but then my alignment is screwed up if all the initialization list items are on the same line, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Other_Class::Other_Class(int _arg1, int _arg2) : arg1(_arg1), arg2(_arg2) {&#xA;do_stuff();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I fix indentation for this one case without throwing off indentation for other cases?&lt;/p&gt;&#xA;" OwnerUserId="5043" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-05-08T23:30:26.577" Title="How do I fix indentation after multiline c++ initialization list?" Tags="|indentation|filetype-c++|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7694" PostTypeId="1" CreationDate="2016-05-09T06:38:24.997" Score="0" ViewCount="417" Body="&lt;p&gt;I'm using Vim 7.4.1825, huge version without GUI on OSX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I start Vim with &lt;code&gt;Vim -u NONE&lt;/code&gt;, navigating to mark a - set with &lt;code&gt;'a&lt;/code&gt; - is not working. Every other mark (b-z) is working well, only jump to mark a is not possible. I can see with &lt;code&gt;:marks&lt;/code&gt; that &lt;code&gt;a bar foo&lt;/code&gt; is set, but I cannot jump to it. Is there a explanation for this behavior?&lt;/p&gt;&#xA;" OwnerUserId="911" LastEditorUserId="1841" LastEditDate="2016-05-09T08:05:39.933" LastActivityDate="2018-09-20T01:26:36.190" Title="Why is navigation to mark a ('a) not working?" Tags="|mark|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7695" PostTypeId="1" CreationDate="2016-05-09T08:11:00.133" Score="2" ViewCount="1215" Body="&lt;p&gt;Is it possible to have an existing vim instance launch a server from within, without using the &lt;code&gt;--servername&lt;/code&gt; command-line option? (I would want to do this from a &lt;code&gt;FileType&lt;/code&gt; autocommand).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, is there any inconvenient in setting up a shell &lt;code&gt;alias vim='vim --servername $$'&lt;/code&gt; (or any other unique identifier), so that &lt;em&gt;any&lt;/em&gt; &lt;code&gt;vim&lt;/code&gt; instance is its own server? (Then when I need to contact a specific one, I can always patch something up out of &lt;code&gt;--serverlist&lt;/code&gt; and &lt;code&gt;--remote-cmd&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1940" LastActivityDate="2016-05-09T08:11:00.133" Title="Start server from within existing Vim instance" Tags="|clientserver|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7696" PostTypeId="2" ParentId="6749" CreationDate="2016-05-09T11:12:30.407" Score="0" Body="&lt;p&gt;Extending Al.G.'s answer, we can go to required location without editing. Solution is &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;. We will reached to the same position where we was in last insert mode before.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You are in the middle of the paragraph.&lt;/li&gt;&#xA;&lt;li&gt;switch to insert mode.&lt;/li&gt;&#xA;&lt;li&gt;switch to normal mode.&lt;/li&gt;&#xA;&lt;li&gt;press &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;li&gt;press &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;li&gt;switch to normal mode. (&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt; will left us to insert mode)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If we want to go to start or end of highlighted text.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :help v_o &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you yank the highlighted text, you will also return to normal mode and you may or may not retain the original cursor position.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If you start highlighting from higher to lower cursor position(from&#xA;lower line-column number to higher line-column number), you will&#xA;retain original cursor position on pressing &lt;kbd&gt;y&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Cursor will remain to current position if highlight start from lower to higher cursor position.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Returning to original location after yanking:&lt;/strong&gt;&lt;br&gt;&#xA;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; to get previous highlight.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can switch between original and current location in visual mode with key&lt;br&gt;&#xA; &lt;kbd&gt;o&lt;/kbd&gt; or &lt;kbd&gt;O&lt;/kbd&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Line and column number of status line will help to know exact cursor position.&lt;br&gt;&#xA;Documentation: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help visual-change&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7501" LastEditorUserId="7501" LastEditDate="2016-09-05T10:55:23.250" LastActivityDate="2016-09-05T10:55:23.250" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7697" PostTypeId="2" ParentId="7582" CreationDate="2016-05-09T13:55:04.953" Score="8" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; didn't realize someone posted the same answer in a comment rather than just posting an answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Per a post on &lt;a href=&quot;https://www.reddit.com/r/vim&quot; rel=&quot;noreferrer&quot;&gt;/r/vim&lt;/a&gt;, you can add numbered jumps by setting the previous context mark. These two lines will only set the mark when jumping more than 1 time (i.e. must be numbered like &lt;code&gt;3k&lt;/code&gt; or &lt;code&gt;20j&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; k (v:count &amp;gt; 1 ? &quot;m'&quot; . v:count : '') . 'k'&#xA;nnoremap &amp;lt;expr&amp;gt; j (v:count &amp;gt; 1 ? &quot;m'&quot; . v:count : '') . 'j'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2016-05-09T15:00:45.563" LastActivityDate="2016-05-09T15:00:45.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7698" PostTypeId="1" CreationDate="2016-05-09T16:25:25.807" Score="1" ViewCount="110" Body="&lt;p&gt;I'm currently configuring vim on my work computer and I'm encountering a problem with the colour scheme. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using pathogen and all of my plugins are working well. I downloaded the harlequin colour scheme and dropped it into my bundle folder just as I have with previous computers. When I go to my vimrc file and type &lt;code&gt;:colorscheme&lt;/code&gt; I can browse the available options and indeed harlequin is one of them. When I select harlequin however, I just get the default colorscheme. Not surprisingly when I type &lt;code&gt;colorscheme harlequin&lt;/code&gt; in my vimrc, it just maintains the default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suggestions? (here is a copy of my vimrc)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1 &quot;Use pathogen plugin manager&#xA; 2 execute pathogen#infect()&#xA; 3 &#xA; 4 &quot;change colour scheme&#xA; 5 colorscheme harlequin&#xA; 6 &#xA; 7 &quot;set line numbering&#xA; 8 set number&#xA; 9 &#xA;10 &quot;turn on status bar&#xA;11 set laststatus=2&#xA;12 &#xA;13 &quot;syntax and indenting on&#xA;14 syntax on&#xA;15 filetype plugin indent on&#xA;16 &#xA;17 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7399" LastEditorUserId="1841" LastEditDate="2016-05-09T18:19:15.003" LastActivityDate="2016-05-09T21:54:46.867" Title="Problem using harlequin colorscheme in vim with pathogen" Tags="|vimrc|colorscheme|plugin-pathogen|" AnswerCount="1" CommentCount="4" ClosedDate="2018-02-19T22:44:11.623" ContentLicense="CC BY-SA 3.0" />
  <row Id="7699" PostTypeId="1" AcceptedAnswerId="7700" CreationDate="2016-05-09T16:37:16.073" Score="29" ViewCount="13489" Body="&lt;p&gt;In Vim, I don't like how when you reach end of file it puts the last line at the bottom of the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway to make the last line be something like 10 lines above the bottom of the screen and just make blank lines under it?&lt;/p&gt;&#xA;" OwnerUserId="7571" LastEditorUserId="205" LastEditDate="2016-05-10T18:52:06.003" LastActivityDate="2023-02-26T20:12:22.197" Title="How do I make Vim always display several lines after EOF?" Tags="|cursor-movement|scrolling|cursor|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7700" PostTypeId="2" ParentId="7699" CreationDate="2016-05-09T17:44:11.020" Score="26" Body="&lt;p&gt;You can use &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;E&lt;/kbd&gt; to scroll down your file, when you are at the end of the file it will add &quot;virtual&quot; line so the last line of the file is not at the bottom of the windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally you can use the option &lt;code&gt;scrolloff&lt;/code&gt; to always let some lines after your cursor, add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set scrolloff=10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more details see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27scrolloff%27&quot;&gt;&lt;code&gt;:h 'scrolloff'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/scroll.html#CTRL-E&quot;&gt;&lt;code&gt;:h CTRL-E&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-09T18:12:21.127" LastActivityDate="2016-05-09T18:12:21.127" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7701" PostTypeId="1" CreationDate="2016-05-09T18:17:04.743" Score="22" ViewCount="20025" Body="&lt;p&gt;I got stuck in ex input mode by typing &lt;code&gt;:i&lt;/code&gt;. Now I cannot use any commands. All there is just a string of text. Pressing escape does not get me out of it, typing &lt;code&gt;:visual&lt;/code&gt; does not get me out of it, and typing &lt;code&gt;visual&lt;/code&gt; does not get me out of it. How do I get out of it?&lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="18609" LastEditDate="2020-06-03T22:06:36.180" LastActivityDate="2022-02-14T06:55:39.413" Title="How do I exit from input after using a `:i` command?" Tags="|user-input|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7702" PostTypeId="2" ParentId="7701" CreationDate="2016-05-09T18:40:20.953" Score="24" Body="&lt;p&gt;&lt;code&gt;:insert&lt;/code&gt; will keep asking for lines until you type a line only containing &lt;code&gt;.&lt;/code&gt;. For more help see &lt;code&gt;:h :i&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-05-09T18:40:20.953" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7704" PostTypeId="2" ParentId="7698" CreationDate="2016-05-09T20:54:26.203" Score="-1" Body="&lt;p&gt;romainl found the problem. My terminal didn't have 256 color, which konsole does actually support. Fixed it by changing the path and getting the proper script &lt;code&gt;256color.pl&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7399" LastEditorUserId="7399" LastEditDate="2016-05-09T21:54:46.867" LastActivityDate="2016-05-09T21:54:46.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7705" PostTypeId="1" CreationDate="2016-05-10T05:17:04.947" Score="0" ViewCount="144" Body="&lt;p&gt;When I reload my syntax file I receive this error: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E890: trailing char after ']': /v(.)@&amp;lt;=w+[nrs]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the line it's bugging out on, does anyone see why this doesn't work?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax keyword langMethod /\v(\.)\@&amp;lt;=\w+[]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7578" LastEditorUserId="205" LastEditDate="2016-05-12T20:03:04.257" LastActivityDate="2016-05-12T22:02:12.953" Title="E890 Trailing char after ']' - vim/neovim regex" Tags="|vimscript|regular-expression|neovim|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7706" PostTypeId="1" AcceptedAnswerId="7716" CreationDate="2016-05-10T05:24:01.163" Score="0" ViewCount="491" Body="&lt;p&gt;I want to auto indent code on pasting and found this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap p  p=`]                  --(not working)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it was not working for me as the code still came out unindented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;c-p&amp;gt;  p=`]              --(working)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it worked fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to have the remap in the first way, any idea why it does not work.&lt;/p&gt;&#xA;" OwnerUserId="7479" LastEditorUserId="1841" LastEditDate="2016-05-10T13:23:40.833" LastActivityDate="2016-05-10T13:23:40.833" Title="Issue with paste command remap in vim" Tags="|key-bindings|cut-copy-paste|indentation|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7707" PostTypeId="1" CreationDate="2016-05-10T07:26:52.867" Score="1" ViewCount="1071" Body="&lt;p&gt;I have several files opened in tabs in Vim.&#xA;I want to switch between tabs, so I use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;left&lt;/kbd&gt; to move left (previous) and for next also.&#xA;But my mapping doesn't work.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;C-Left&amp;gt; :tabprevious&amp;lt;CR&amp;gt;&#xA;:map &amp;lt;C-Right&amp;gt; :tabnext&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried in &lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;arrow&lt;/kbd&gt; combinations. It doesn't work in command line as well as vimrc also.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="15519" LastEditDate="2021-03-23T21:13:37.970" LastActivityDate="2023-12-09T04:04:25.513" Title="Mapping doesn't work for tabs" Tags="|key-bindings|vimrc|tabbed-user-interface|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="7708" PostTypeId="2" ParentId="7672" CreationDate="2016-05-10T09:22:40.233" Score="3" Body="&lt;p&gt;Think of the macros! Really, the regexps by Tumblr41 and Jair Lopez are freakishly smart, but can you really reproduce that in a different case in acceptable time? Here's how I would do it (cursor on line 1):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; record into buffer q&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; go to beginning of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;byit&lt;/code&gt; yank lattitude in buffer b&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; go to next line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;ayit&lt;/code&gt; yank longitued in buffer a&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&lt;/code&gt; new line below line 2 (should be indented correctly)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Ctrl-r&amp;gt;a,&amp;lt;Ctrl-r&amp;gt;b&amp;lt;Esc&amp;gt;&lt;/code&gt; to put the coordinates there in the right order&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;I&amp;lt;Point&amp;gt;&amp;lt;coordinates&amp;gt;&amp;lt;Esc&amp;gt;A&amp;lt;/Point&amp;gt;&amp;lt;/coordinates&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to input the other tags&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;kk2dd&lt;/code&gt; to delete the superflous lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; to go to the next line, that's not yet converted&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; to stop recording&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This might be more keystrokes, but will take little time to get right, and it doesn't really matter if you use ineffective motions, all will be replayed by the macro, and you just need to input it once.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="1296" LastEditDate="2016-05-10T21:22:44.190" LastActivityDate="2016-05-10T21:22:44.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7709" PostTypeId="1" AcceptedAnswerId="7710" CreationDate="2016-05-10T09:53:30.060" Score="5" ViewCount="5192" Body="&lt;p&gt;I am currently trying to set a custom syntax highlighting using a &lt;code&gt;mysyntax.vim&lt;/code&gt; file.&#xA;I have several keywords (&lt;code&gt;int&lt;/code&gt;, &lt;code&gt;real&lt;/code&gt;, &lt;code&gt;real2D&lt;/code&gt;, &lt;code&gt;real1D&lt;/code&gt;, etc) currently highlighted using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword VariableType real real1D real2D real3D int&#xA;hi VariableType ctermfg=darkgreen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I would like to also highlight the 'word' that comes right after. &#xA;I added &lt;code&gt;nextgroup=VarName&lt;/code&gt; to my first line above, and tried a few things like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match VarName '\w' contained&#xA;syn region VarName start=' ' end=' ' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(in my understanding, &lt;code&gt;'\w'&lt;/code&gt; accounts for a word).&#xA;However none of the solutions I tried worked. Am I missing something ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem seems to come from the way I define this : it should neither be a &quot;region&quot; or &quot;match&quot;, that would be evaluated as true basically at each word...&lt;/p&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="7128" LastEditDate="2016-05-10T10:23:06.710" LastActivityDate="2016-05-10T19:15:28.513" Title="Custom syntax highlighting: highlight word following keyword" Tags="|vimscript|syntax-highlighting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7710" PostTypeId="2" ParentId="7709" CreationDate="2016-05-10T11:23:12.133" Score="11" Body="&lt;p&gt;It is possible to tell Vim to match something after a keyword, using &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-nextgroup&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;nextgroup&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;nextgroup={group-name},..                               :syn-nextgroup&#xA;&#xA;The &quot;nextgroup&quot; argument is followed by a list of syntax group names,&#xA;separated by commas (just like with &quot;contains&quot;, so you can also use patterns).&#xA;&#xA;If the &quot;nextgroup&quot; argument is given, the mentioned syntax groups will be&#xA;tried for a match, after the match or region ends.  If none of the groups have&#xA;a match, highlighting continues normally.  If there is a match, this group&#xA;will be used, even when it is not mentioned in the &quot;contains&quot; field of the&#xA;current group.  This is like giving the mentioned group priority over all&#xA;other groups.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;syn keyword VariableType real real1D real2D real3D int nextgroup=VarName skipwhite&#xA;syn match VarName '\i\+' contained&#xA;hi VariableType ctermfg=darkgreen&#xA;hi VarName ctermfg=darkblue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;skipwhite&lt;/code&gt; tells Vim to skip spaces and tabs when looking for the &lt;code&gt;nextgroup&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5Ci&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\i&lt;/code&gt;&lt;/a&gt; might be better than &lt;code&gt;\w&lt;/code&gt;. &lt;code&gt;\i&lt;/code&gt; matches identifier characters.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;VarName&lt;/code&gt; is still contained so that it doesn't automatically apply to every identifier string in the file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Effect:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EjdOn.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EjdOn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could also define a region or match containing these keywords and the word that follows, and then contain the keywords within. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;syn match VarDecl '\v&amp;lt;(real([123]D)?|int)\s+\i+&amp;gt;' contains=VariableType,VarName&#xA;syn keyword VariableType real real1D real2D real3D int contained&#xA;syn match VarName '\i' contained&#xA;hi VariableType ctermfg=darkgreen&#xA;hi VarName ctermfg=darkblue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The regex:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt;: &quot;very magic&quot;. See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2Fmagic&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h /magic&lt;/code&gt;&lt;/a&gt;. Saves a lot on backslashes.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%3E&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt;&lt;/a&gt; match at word boundaries. This way, we won't match in the middle of a word (the middle line was intended to test this).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;real([123]D)?&lt;/code&gt; matches &lt;code&gt;real&lt;/code&gt; with an &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%3F&quot; rel=&quot;noreferrer&quot;&gt;optional&lt;/a&gt; &lt;code&gt;1D&lt;/code&gt;, &lt;code&gt;2D&lt;/code&gt; or &lt;code&gt;3D&lt;/code&gt; after it.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(real([123]D)?|int)&lt;/code&gt; matches either the above or &lt;code&gt;int&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s+&lt;/code&gt; matches &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%2B&quot; rel=&quot;noreferrer&quot;&gt;one or more&lt;/a&gt; &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5Cs&quot; rel=&quot;noreferrer&quot;&gt;whitespace&lt;/a&gt; characters.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\i+&lt;/code&gt; matches one or more &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5Ci&quot; rel=&quot;noreferrer&quot;&gt;identifier&lt;/a&gt; characters.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(&lt;/code&gt;, &lt;code&gt;\)&lt;/code&gt;, &lt;code&gt;\&amp;lt;&lt;/code&gt;, &lt;code&gt;\&amp;gt;&lt;/code&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%08ar&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\|&lt;/code&gt;&lt;/a&gt;, &lt;code&gt;\?&lt;/code&gt; and &lt;code&gt;\+&lt;/code&gt; don't need backslashes because of &lt;code&gt;\v&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-05-10T19:15:28.513" LastActivityDate="2016-05-10T19:15:28.513" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7711" PostTypeId="1" AcceptedAnswerId="7712" CreationDate="2016-05-10T11:34:06.713" Score="3" ViewCount="138" Body="&lt;p&gt;I have this function which displays line numbers. I want it to be called in different ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;from a command, specifying the lines as arguments&lt;/li&gt;&#xA;&lt;li&gt;with a visual selection, printing the first and last line numbers of the selection&lt;/li&gt;&#xA;&lt;li&gt;with a motion, printing the current line and the line at the end of the motion&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So far I have the first two ones:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* PL :call PrintLines('command',&amp;lt;f-args&amp;gt;)&#xA;vnoremap &amp;lt;silent&amp;gt; P :&amp;lt;C-U&amp;gt;call PrintLines('visual')&amp;lt;CR&amp;gt;&#xA;&#xA;function! PrintLines(type,...)&#xA;&#xA;  &quot; Get the lines to fold around&#xA;  if a:type == 'command'&#xA;    let l:line_before = a:000[0]&#xA;    let l:line_after = a:000[1]&#xA;  elseif a:type == 'visual'&#xA;    let l:line_before = line(&quot;'&amp;lt;&quot;)&#xA;    let l:line_after = line(&quot;'&amp;gt;&quot;)&#xA;  endif&#xA;&#xA;  echo l:line_before&#xA;  echo l:line_after&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I can't figure out the way to use this with a motion. Ideally it would be possible to do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; nnoremap P{motion} :&amp;lt;C-U&amp;gt;call('normal')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And use it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Pib&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1841" LastEditDate="2016-05-10T13:25:13.017" LastActivityDate="2016-05-10T13:25:13.017" Title="Use motion in normal mapping calling a function" Tags="|key-bindings|visual-mode|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7712" PostTypeId="2" ParentId="7711" CreationDate="2016-05-10T11:43:44.070" Score="6" Body="&lt;p&gt;You'll nee to use the &lt;code&gt;g@&lt;/code&gt; feature (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#g@&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h g@&lt;/code&gt;&lt;/a&gt;)&#xA;This operator allow to specify a motion after a function call and position the&#xA;marks &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt; at the beginning and the end of the text selected by the motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When calling a function this way the mode of selection (line-wise, character-wise,&#xA;block-wise) is passed as the first argument of the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this method you can use &lt;code&gt;line(&quot;'[&quot;)&lt;/code&gt; and &lt;code&gt;line(&quot;']&quot;)&lt;/code&gt; to get the number of the lines.&#xA;Your function should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PrintLines(type,...)&#xA;&#xA;    &quot; Get the lines to fold around&#xA;    if a:type == 'command'&#xA;        let l:line_before  = a:000[0]&#xA;        let l:line_after   = a:000[1]&#xA;    elseif a:type == 'visual'&#xA;        let l:line_before  = line(&quot;'&amp;lt;&quot;)&#xA;        let l:line_after   = line(&quot;'&amp;gt;&quot;)&#xA;    elseif a:type =~ 'line\|char\|block'&#xA;        &quot; Test the different mode that g@ can pass as argument&#xA;        &quot; and get the corresponding lines&#xA;        let l:line_before  = line(&quot;'[&quot;)&#xA;        let l:line_after   = line(&quot;']&quot;)&#xA;    endif&#xA;&#xA;    echomsg l:line_before.' '.l:line_after&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now about the mapping it should look like this (largely inspired from the example&#xA;of the doc):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; P :set opfunc=PrintLines&amp;lt;CR&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use your mapping &lt;kbd&gt;P&lt;/kbd&gt; and Vim will wait for a motion input&#xA;(like &lt;kbd&gt;}&lt;/kbd&gt; or &lt;kbd&gt;5j&lt;/kbd&gt;) to call the function correctly.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-05-10T11:43:44.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7713" PostTypeId="1" AcceptedAnswerId="7714" CreationDate="2016-05-10T11:48:31.263" Score="27" ViewCount="4445" Body="&lt;p&gt;We can retrieve search and replace history on IDEs and text editors.&lt;/p&gt;&#xA;&lt;p&gt;Likewise is there a search history or a way to retrieve previously searched expression in Vim?&lt;/p&gt;&#xA;" OwnerUserId="7501" LastEditorUserId="23502" LastEditDate="2023-05-29T11:39:03.153" LastActivityDate="2023-05-29T11:39:03.153" Title="Is there search and replace history in Vim?" Tags="|search|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7714" PostTypeId="2" ParentId="7713" CreationDate="2016-05-10T11:50:54.760" Score="27" Body="&lt;p&gt;Yes, you have the &lt;code&gt;history&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:history /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that it can be used for &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;?&lt;/code&gt;, &lt;code&gt;@&lt;/code&gt;, &lt;code&gt;all&lt;/code&gt;, &lt;code&gt;cmd&lt;/code&gt;, &lt;code&gt;debug&lt;/code&gt;, &lt;code&gt;expr&lt;/code&gt;, &lt;code&gt;input&lt;/code&gt; and &lt;code&gt;search&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can use the &lt;code&gt;q:&lt;/code&gt;, &lt;code&gt;q/&lt;/code&gt; and &lt;code&gt;q?&lt;/code&gt; commands to see previously entered commands and searches on a sepearate buffer. You can then modify as you want and replay them by pressing &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h :history&lt;/code&gt;, &lt;code&gt;:h q:&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="205" LastEditDate="2016-06-23T10:41:35.103" LastActivityDate="2016-06-23T10:41:35.103" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7715" PostTypeId="2" ParentId="7713" CreationDate="2016-05-10T11:52:43.513" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;:history s&lt;/code&gt; for search history. As a shortcut, you can use &lt;code&gt;:his s&lt;/code&gt;. Same way for command line history also.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="7161" LastEditDate="2016-06-23T09:39:15.373" LastActivityDate="2016-06-23T09:39:15.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7716" PostTypeId="2" ParentId="7706" CreationDate="2016-05-10T12:26:27.333" Score="4" Body="&lt;p&gt;When a mapping seems to do nothing or do something totally unexpected, the first reflex to have is to check if it is really mapped to what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do so the command &lt;code&gt;:map&lt;/code&gt; is your friend:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using only &lt;code&gt;:map&lt;/code&gt;, Vim will prompt all the mappings created in the current session. To restrict your search to the problematic mapping simply pass the not working keys as argument of the command: here it would be &lt;code&gt;:map p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you can use &lt;code&gt;:map &amp;lt;Leader&amp;gt;k&lt;/code&gt; to check what &lt;kbd&gt;Leader&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; is mapped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also good to know that commands like &lt;code&gt;:nmap&lt;/code&gt;, &lt;code&gt;:vmap&lt;/code&gt;, &lt;code&gt;:imap&lt;/code&gt; can be used to search for mapping in particular modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the &lt;code&gt;:map&lt;/code&gt; commands proved that your mapping is overrided you can easily find which file overrided it: &lt;code&gt;:verbose map &amp;lt;key&amp;gt;&lt;/code&gt; will prompt the last file which modified the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally in some cases it can be useful to know that &lt;code&gt;:mapc&lt;/code&gt; can be used to unmap a key sequence.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-05-10T12:26:27.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7717" PostTypeId="1" AcceptedAnswerId="7718" CreationDate="2016-05-10T12:29:52.387" Score="2" ViewCount="66" Body="&lt;p&gt;I have 69 files in which I want to prepend lines 5 to penultimate with a short string. How could I address the penultimate line? &lt;code&gt;:5,61s/^/X/g&lt;/code&gt; would do it if I manually look up that the last line is 62, but if I want to script it for all the files, how can I do that? I could imagine doing something like &#xA;&lt;code&gt;&#xA;vim &quot;+:5,$((`cat test.txt|wc -l` - 1))s/^/X/g|:x&quot; test.txt&#xA;&lt;/code&gt;&#xA;from the command line, but as I'm not dealing with a simple search and replace as in my above example I think I won't be able to provide it from the command line, how can I do it from within vim?&lt;/p&gt;&#xA;" OwnerUserId="2774" LastActivityDate="2016-05-10T12:41:50.143" Title="specifying a range the last of which is the penultimate line" Tags="|range|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7718" PostTypeId="2" ParentId="7717" CreationDate="2016-05-10T12:41:50.143" Score="3" Body="&lt;p&gt;You can express the penultimate line with &lt;code&gt;$-1&lt;/code&gt;. So, in your case, to prepend &lt;code&gt;X&lt;/code&gt; in front of all the lines from the fifth down to the second to last one, you could use the following substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5,$-1s/^/X&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find more information on how to write a range in &lt;code&gt;:help :range&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-05-10T12:41:50.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7719" PostTypeId="1" AcceptedAnswerId="7720" CreationDate="2016-05-10T13:08:44.640" Score="5" ViewCount="466" Body="&lt;p&gt;Sometimes, when I edit a large file, I like to focus only on a part of the document and not all of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to create a sort of fold that wrap a part of the document (e.g. the current function/paragraph) so the focus is narrowed on that ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea would be to produce something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+ --- the fold --- &amp;gt;&#xA;&#xA;// Interesting stuff, i.e. a cat&#xA;// &#xA;//   |\      _,,,---,,_&#xA;//  /,`.-'`'    -.  ;-;;,_&#xA;// |,4-  ) )-,_..;\ (  `'-'&#xA;// '---''(_/--' `-'\_)&#xA;//&#xA;&#xA;+ --- the fold --- &amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-10T16:51:03.033" LastActivityDate="2016-05-10T16:51:03.033" Title="Fold outside a selection" Tags="|folding|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7720" PostTypeId="2" ParentId="7719" CreationDate="2016-05-10T13:16:34.543" Score="4" Body="&lt;p&gt;A very basic solution would be to use the following macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqggzf'&amp;lt;'&amp;gt;zfGq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First visually select the text you want to focus on and use the macro with &lt;code&gt;@q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To detail:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; start recording the macro&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gg&lt;/code&gt; go to the top of the buffer&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;zf&lt;/code&gt; start a folding from your position (the first line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;lt;&lt;/code&gt; fold to the beginning of your selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;gt;&lt;/code&gt; go to the end of your selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;zf&lt;/code&gt; start a foding&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;G&lt;/code&gt; fold to the end of the file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is pretty basic and could probably be improved but its a quick workaround.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-05-10T13:16:34.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7721" PostTypeId="2" ParentId="7719" CreationDate="2016-05-10T13:40:10.170" Score="2" Body="&lt;p&gt;After trying to do so, I found a way to do it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Register a command, a visual and normal mapping&#xA;command! -nargs=* FAL :call FoldAroundLines('command',&amp;lt;f-args&amp;gt;)&#xA;vnoremap &amp;lt;silent&amp;gt; F :&amp;lt;C-U&amp;gt;call FoldAroundLines('visual')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; F :set opfunc=FoldAroundLines&amp;lt;CR&amp;gt;g@&#xA;&#xA;function! FoldAroundLines(type,...)&#xA;  &quot; Ensure we are in manual fold mode&#xA;  set foldmethod=manual&#xA;  &quot; Save first and list line of the current buffer&#xA;  let l:first_line = 1&#xA;  let l:last_line = line(&quot;$&quot;)&#xA;&#xA;  &quot; Get the lines to fold around&#xA;  if a:type == 'command'&#xA;    let l:line_before = a:000[0]&#xA;    let l:line_after = a:000[1]&#xA;  elseif a:type == 'visual'&#xA;    let l:line_before = line(&quot;'&amp;lt;&quot;)&#xA;    let l:line_after = line(&quot;'&amp;gt;&quot;)&#xA;  elseif a:type =~ 'line\|char\|block'&#xA;    let l:line_before = line(&quot;'[&quot;)&#xA;    let l:line_after = line(&quot;']&quot;)&#xA;  endif&#xA;&#xA;  &quot; Add a 1 padding to be sure to display the limit lines&#xA;  if l:line_before - 1 &amp;gt; l:first_line&#xA;    let l:line_before -= 1&#xA;  endif&#xA;&#xA;  if l:line_after + 1 &amp;lt; l:last_line&#xA;    let l:line_after += 1&#xA;  endif&#xA;&#xA;  &quot; Check selected lines are in the current buffer&#xA;  if (l:line_before &amp;lt; l:first_line || l:line_after &amp;gt; l:last_line)&#xA;    echom (&quot;A selected line is not in the buffer&quot;)&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; Remove every fold in the current buffer&#xA;  normal! zE&#xA;&#xA;  &quot; Fold first-&amp;gt;before and after-&amp;gt;last&#xA;  execute l:first_line.&quot;,&quot;.l:line_before.&quot;fold&quot;&#xA;  execute l:line_after.&quot;,&quot;.l:last_line.&quot;fold&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-05-10T13:40:10.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7722" PostTypeId="1" AcceptedAnswerId="7723" CreationDate="2016-05-10T13:52:46.640" Score="112" ViewCount="31487" Body="&lt;p&gt;I see a lot of questions on here where a user has a mapping which doesn't work&#xA;and most of the time the reasons are pretty similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest to make this question a reference for this kind of questions, to give a complete procedure to debug a mapping. If a user as a problem with&#xA;a mapping they could be redirected here to eliminate the most common issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course there will still be particular cases which will require a dedicated&#xA;question and will not be addressed here.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-23T10:07:52.380" LastActivityDate="2023-11-08T10:50:33.477" Title="How to debug a mapping?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7723" PostTypeId="2" ParentId="7722" CreationDate="2016-05-10T13:52:46.640" Score="149" Body="&lt;p&gt;Your mapping doesn't do what it should do or behaves differently than expected, several steps are to follow to troubleshoot that:&lt;/p&gt;&#xA;&lt;h2&gt;Check that the key is effectively mapped to what it should do&lt;/h2&gt;&#xA;&lt;p&gt;Vim provides a command &lt;code&gt;:map&lt;/code&gt;. By default, (when no argument is given) the&#xA;command will show all the mappings currently created. Here is an example of&#xA;the result of the command:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ODZN7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ODZN7.png&quot; alt=&quot;result of :map&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As always the doc is your friend: &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#map%2Dlisting&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h map-listing&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can see in the first column the mode of the mapping (&lt;code&gt;n&lt;/code&gt; for normal mode,&#xA;&lt;code&gt;v&lt;/code&gt; for visual mode, etc), the second column shows the keys mapped and the&#xA;last column what the keys are mapped to.&#xA;Note that before the mapped actions some additional characters may appear, it&#xA;is important to understand them:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;*&lt;/code&gt;  indicates that it is not remappable (i.e., it is not a recursive mapping, see &lt;code&gt;know when to use nore&lt;/code&gt; later in this answer)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;&lt;/code&gt;  indicates that only script-local mappings are re-mappable&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@&lt;/code&gt;  indicates a buffer-local mapping&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When asking for help about a mapping it is a good thing to add this&#xA;information since it can help other people to understand the behavior of your mapping.&lt;/p&gt;&#xA;&lt;p&gt;It is possible to restrict the prompt to a particular mode with the sister-commands&#xA;of &lt;code&gt;:map&lt;/code&gt;, like &lt;code&gt;:vmap&lt;/code&gt;, &lt;code&gt;:nmap&lt;/code&gt;, &lt;code&gt;:omap&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&lt;p&gt;Now to restrict your search to the problematic mapping you can pass the key&#xA;sequence you're debugging as the parameter of the commands, like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:map j&#xA;:map &amp;lt;Leader&amp;gt;m&#xA;:map &amp;lt;F5&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that the &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; key will be replaced by its actual value in the list.&lt;/p&gt;&#xA;&lt;p&gt;If the result of the command shows that your keys are correctly mapped, it probably&#xA;means that the problem doesn't come from Vim but from your terminal or your desktop&#xA;environment. See the part &lt;strong&gt;Check if your mapping is actually intercepted by Vim&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the result of the command shows that your keys are not correctly mapped see the&#xA;following part.&lt;/p&gt;&#xA;&lt;h2&gt;Check what overrode your mapping&lt;/h2&gt;&#xA;&lt;p&gt;Another convenient use of the &lt;code&gt;:map&lt;/code&gt; command is to combine it with &lt;code&gt;verbose&lt;/code&gt;:&#xA;This will prompt the last file which modified your mapping.&lt;/p&gt;&#xA;&lt;p&gt;For example, see these two screenshots which are the results of &lt;code&gt;:verbose map&lt;/code&gt;: the first one is a mapping modified by&#xA;my &lt;code&gt;.vimrc&lt;/code&gt; and the second a mapping created by a plugin:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/agrRe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/agrRe.png&quot; alt=&quot;Mapping set from vimrc&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WHnVa.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WHnVa.png&quot; alt=&quot;Mapping set from a plugin&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now if you see that another script modified your mapping you'll have to see if&#xA;you can remove it or modify its behavior. &lt;em&gt;(Note that some plugins provide&#xA;variable to enable/disable their mappings, unfortunately not all of the plugins&#xA;do that)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the last file which changed your mapping is your &lt;code&gt;.vimrc&lt;/code&gt;, make sure there is no other line that also defines a mapping for the same key. The &lt;code&gt;.vimrc&lt;/code&gt; file will happily override any mappings with the last one of its kind in the file.&lt;/p&gt;&#xA;&lt;h1&gt;Check if your mapping is actually intercepted by Vim&lt;/h1&gt;&#xA;&lt;p&gt;Several situations may indicate that Vim doesn't intercept your key:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The command &lt;code&gt;:map&lt;/code&gt; shows that your key is correctly mapped but pressing it does nothing.&lt;/li&gt;&#xA;&lt;li&gt;Your mapping works on gVim (GUI) but does nothing in terminal Vim&lt;/li&gt;&#xA;&lt;li&gt;Your mapping works on a defined terminal emulator but not on another&lt;/li&gt;&#xA;&lt;li&gt;Your mapping works on a defined OS but not another one.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;It is probably caused by one of the two following things:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Something intercepts the key before Vim&lt;/strong&gt;: It can be different applications: your OS, your desktop environment, your terminal emulator, Tmux (if you use it)…&lt;/p&gt;&#xA;&lt;p&gt;To troubleshoot that, you should:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Try to temporarily remove your &lt;code&gt;.tmux.conf&lt;/code&gt; if you use tmux&lt;/li&gt;&#xA;&lt;li&gt;Refer to the doc of your terminal or of your desktop environment.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You could also refer to sister-sites like &lt;a href=&quot;https://superuser.com/&quot;&gt;super-user&lt;/a&gt;,&#xA;&lt;a href=&quot;https://unix.stackexchange.com/&quot;&gt;Unix and Linux&lt;/a&gt;, &lt;a href=&quot;https://askubuntu.com/&quot;&gt;askUbuntu&lt;/a&gt;, etc…&lt;/p&gt;&#xA;&lt;p&gt;If this is the problem, you then have two solutions: either you spend&#xA;(a lot of) time to change&#xA;the behavior of the application which causes the problem, or you find&#xA;another key combination to map which isn't intercepted by another&#xA;application.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Your terminal emulator can't handle the key combination you're&#xA;trying to map&lt;/strong&gt;:&#xA;Terminal emulators are implemented differently and some of them&#xA;are not able to handle some particular key combination. &lt;em&gt;(The reason why&#xA;they can't is out of the scope of this question, see their doc or the&#xA;sister-sites mentioned before for more details).&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this case, you don't have a lot of solutions: either you change your&#xA;key for another one which is handled properly by your terminal or you&#xA;change your terminal emulator.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;Check for the common pitfalls&lt;/h1&gt;&#xA;&lt;p&gt;Some problems in mappings are pretty recurrent and mostly related to the vimscript syntax. If your mapping has an unexpected behavior remember to check the following points:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/6921/1841&quot;&gt;&lt;strong&gt;Do not put a comment on the same line as your mapping&lt;/strong&gt;&lt;/a&gt;, instead put the comment on the line above. Example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Don't do that:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  inoremap ii &amp;lt;esc&amp;gt;    &amp;quot; ii to go back into normal mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Vim will consider the white spaces, the &lt;code&gt;&amp;quot;&lt;/code&gt; and the comment as a part of the mapping which will result in an unexpected behavior.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Instead, do that:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  &amp;quot; ii to go back into normal mode&#xA;  inoremap ii &amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is easier to read and won't mess your mapping.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/7244/1841&quot;&gt;&lt;strong&gt;Do not pipe your commands with &lt;code&gt;|&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt;. Example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Don't do that:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  nnoremap &amp;lt;Leader&amp;gt;x :w | !% python -m json.tools&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Vim will consider the pipe &lt;code&gt;|&lt;/code&gt; as a command termination: When you source your &lt;code&gt;.vimrc&lt;/code&gt; the mapping &lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;x :w&lt;/code&gt; will be created then the external command &lt;code&gt;!% python -m json.tools&lt;/code&gt; will be executed.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Instead, do that:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  nnoremap &amp;lt;Leader&amp;gt;x :w &amp;lt;bar&amp;gt; !% python -m json.tools&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vi.stackexchange.com/q/2286/1841&quot;&gt;an explanation about &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Know when to use &lt;code&gt;nore&lt;/code&gt;: &lt;em&gt;always&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/05.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;LearnVimscriptTheHardWay&lt;/a&gt; explain it pretty clearly: never use &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;nmap&lt;/code&gt;, &lt;code&gt;vmap&lt;/code&gt;, etc… Always prefer the nore version: &lt;code&gt;noremap&lt;/code&gt;, &lt;code&gt;nnoremap&lt;/code&gt;, &lt;code&gt;vnoremap&lt;/code&gt;, etc…&#xA;Why? &lt;code&gt;nore&lt;/code&gt; stands for &lt;code&gt;non-recursive&lt;/code&gt; mapping it means that the right-hand side of the mapping will be considered as the built-in feature even if you remmaped it. Example:&lt;/p&gt;&#xA;&lt;p&gt;Let's say you want to map &lt;code&gt;&amp;gt;&lt;/code&gt; to delete a line and &lt;code&gt;-&lt;/code&gt; to increment the indent of a line. If you don't use non-recursive mappings you'll do that:&lt;/p&gt;&#xA;&lt;p&gt;(&lt;strong&gt;Do not do that it's for the example&lt;/strong&gt;)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  nmap &amp;gt; dd&#xA;  nmap - &amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When you'll hit &lt;kbd&gt;&amp;gt;&lt;/kbd&gt; your line will be deleted, that's good. But when you'll hit &lt;kbd&gt;-&lt;/kbd&gt; your line will also be deleted instead of being indented. Why? Because Vim understood “I received a hit on &lt;code&gt;-&lt;/code&gt; which I should translate to &lt;code&gt;&amp;gt;&lt;/code&gt; which I should, in turn, translate to &lt;code&gt;dd&lt;/code&gt;”.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Instead do that&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  nnoremap &amp;gt; dd&#xA;  nnoremap - &amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This way Vim will translate &lt;code&gt;-&lt;/code&gt; as &lt;code&gt;&amp;gt;&lt;/code&gt; and will not try to do any other translation because of the &lt;code&gt;nore&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit note&lt;/strong&gt; “Always” may be an exaggerated answer in some cases you'll need to use the recursive mapping form, but it is not really common. To clarify, I'll quote @romainl from &lt;a href=&quot;https://vi.stackexchange.com/a/10130/1841&quot;&gt;this answer&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Use a recursive mapping only if you intend to use any other mapping in your mapping. Use non-recursive mappings if you don't.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/3119/1841&quot;&gt;Remember that some key combinations are equivalent&lt;/a&gt;&lt;/strong&gt;:&#xA;Because of the hexadecimal codes that are produced some key combinations&#xA;will be interpreted by Vim as another key. For example&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/3119/1841&quot;&gt;&lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; is equivalent to &lt;code&gt;&amp;lt;backspace&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/5233/1841&quot;&gt;&lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; as &lt;code&gt;&amp;lt;enter&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;On French keyboards &lt;code&gt;&amp;lt;M-a&amp;gt;&lt;/code&gt; is the same as &lt;code&gt;á&lt;/code&gt; and the same goes with all the&#xA;&lt;code&gt;&amp;lt;m-&lt;/code&gt; mappings. As @LucHermitte pointed out in the comment that is a&#xA;problem with plugins using this type of mappings like vim-latex.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/4290/1841&quot;&gt;&lt;code&gt;&amp;lt;C-S-a&amp;gt;&lt;/code&gt; is equivalent to&#xA;&lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt;&lt;/a&gt;. Mapping Ctrl+upper case&#xA;letter separately from Ctrl+lower case letter is not possible cause of the&#xA;way the terminals send ASCII codes.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When your mapping seems to affect another key try to use another lhs&#xA;combination, if that solves the problem inspect which hexadecimal codes&#xA;are sent to Vim.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/8515/1841&quot;&gt;Check that your leader is correctly defined&lt;/a&gt;&lt;/strong&gt;: If your mappings involving &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; doesn't work, and you changed your leader with the command &lt;code&gt;mapleader&lt;/code&gt;, check that the definition of your leader is done &lt;em&gt;before&lt;/em&gt; the definition of the mappings. Otherwise, Vim will try to create mappings with a key which is not the one you think. Also, if you want to use the space bar as your leader &lt;em&gt;(which is pretty current)&lt;/em&gt; make sure that you used the correct notation: &lt;code&gt;let mapleader = &amp;quot;\&amp;lt;Space&amp;gt;&amp;quot;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;Your mapping still doesn't work?&lt;/h1&gt;&#xA;&lt;p&gt;If you went through all the steps of this answer and your mapping still doesn't work like you want, you'll probably want to ask for help on this site.&lt;/p&gt;&#xA;&lt;p&gt;To help people to help you remember to provide some crucial information like:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The command you used to define your mapping.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What you are expecting your mapping to do.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A precise description of the problem:&lt;/p&gt;&#xA;&lt;p&gt;“It doesn't work” won't be really helpful to people who will try to help you. You should precise if the mapping doesn't do anything or how it behaves differently than what you were expecting.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Also indicate that you actually followed the steps described here and the results you get with &lt;code&gt;:map&lt;/code&gt; and &lt;code&gt;:verbose map&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;All of this will save you and the users of the site a lot of time.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;A useful command: &lt;code&gt;:unmap&lt;/code&gt;&lt;/h1&gt;&#xA;&lt;p&gt;Sometimes it can be useful to reset a mapping without quitting Vim to help debugging its behavior.&lt;/p&gt;&#xA;&lt;p&gt;To do so you can use the command &lt;code&gt;:unmap &amp;lt;key&amp;gt;&lt;/code&gt; which will remove the mapping&#xA;assigned to &lt;code&gt;&amp;lt;key&amp;gt;&lt;/code&gt; for Normal, Visual and Operating-pending modes. &lt;code&gt;:iunmap&lt;/code&gt; will remove mappings for Insert mode. For other modes see &lt;code&gt;:help :unmap&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;References&lt;/h1&gt;&#xA;&lt;p&gt;An excellent introduction to mapping: &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/03.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;learnvimscriptthehardway&lt;/a&gt; (And a lot of other aspects of Vim)&lt;/p&gt;&#xA;&lt;p&gt;The doc: &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#mapping&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h mapping&lt;/code&gt;&lt;/a&gt;,&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :map&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/vim_faq.txt.html#faq-20&quot; rel=&quot;nofollow noreferrer&quot;&gt;Section 20 of Vim's FAQ&lt;/a&gt; is about mapping and contains interesting questions (&amp;quot;Why does mapping the &amp;lt;C-...&amp;gt; key not work?&amp;quot;, &amp;quot;I am not able to create a mapping for the  key. What is wrong?&amp;quot;, ...)&lt;/p&gt;&#xA;&lt;p&gt;And a bonus: &lt;a href=&quot;https://vi.stackexchange.com/q/6916/1841&quot;&gt;A question about best practices to find which keys to use in your mapping&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2023-11-08T10:50:33.477" LastActivityDate="2023-11-08T10:50:33.477" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="7724" PostTypeId="2" ParentId="7719" CreationDate="2016-05-10T13:54:31.837" Score="3" Body="&lt;p&gt;If you are ok with a plugin, I'd suggest &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn&quot; rel=&quot;nofollow&quot;&gt;NrrwRgn&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Per its description:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This plugin is inspired by the Narrowing feature of Emacs and means to focus on a selected region while making the rest inaccessible. You simply select the region, call &lt;code&gt;:NR&lt;/code&gt; and the selected part will open in a new split window while the rest of the buffer will be protected. Once you are finished, simply write the narrowed window (&lt;code&gt;:w&lt;/code&gt;)and all the changes will be moved back to the original buffer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-05-10T13:54:31.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7725" PostTypeId="2" ParentId="6406" CreationDate="2016-05-10T15:31:48.330" Score="3" Body="&lt;p&gt;The credits goes to @muru for this answer since &lt;a href=&quot;https://vi.stackexchange.com/questions/6406/adding-words-to-one-of-many-spellfiles#comment10095_6406&quot;&gt;his comment&lt;/a&gt; gave the solution 3 months ago. I write this answer to let users searching for this question know that it has a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The variable &lt;code&gt;spellfile&lt;/code&gt; may be a comma separated line of files. Those files are used to add &quot;good words&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;zg&lt;/code&gt; allows to add a &quot;good word&quot; to the files in &lt;code&gt;spellfile&lt;/code&gt;. By default the good word will be added to the first entry of &lt;code&gt;spellfile&lt;/code&gt; but when used with a count the command will add the word to the &lt;code&gt;n&lt;/code&gt;th file listed in &lt;code&gt;spellfile&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-05-10T15:31:48.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7726" PostTypeId="1" CreationDate="2016-05-10T16:08:32.330" Score="2" ViewCount="334" Body="&lt;p&gt;We can use the &lt;code&gt;u&lt;/code&gt;, &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; to undo/redo in Vim and it provides a lot of features to manage the undo tree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But sometimes, I make a change (let say on line 1) and I go do some other changes on another line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I come back to line 1, I may think that the previous value of this line was better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current workflow is: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;undo until I get the value back&lt;/li&gt;&#xA;&lt;li&gt;yank the line&lt;/li&gt;&#xA;&lt;li&gt;redo until the top of the undo tree&lt;/li&gt;&#xA;&lt;li&gt;replace the line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think this clearly can be improved, but do you know if there is a vim feature that provide an history of changes for each line?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-05-10T16:32:20.920" Title="Linewise history" Tags="|undo-redo|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7727" PostTypeId="2" ParentId="7726" CreationDate="2016-05-10T16:19:56.720" Score="1" Body="&lt;p&gt;This sounds like you are in dire need of &lt;a href=&quot;https://github.com/sjl/gundo.vim&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sjl/gundo.vim&lt;/a&gt;. Watch a screencast about it at &lt;a href=&quot;http://screenr.com/M9l&quot; rel=&quot;nofollow&quot;&gt;http://screenr.com/M9l&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2016-05-10T16:19:56.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7728" PostTypeId="2" ParentId="7726" CreationDate="2016-05-10T16:32:20.920" Score="1" Body="&lt;p&gt;You might want to take a look at &lt;a href=&quot;https://github.com/mbbill/undotree&quot; rel=&quot;nofollow&quot;&gt;undotree&lt;/a&gt;. Its pure vimscript and uses vim's undo-tree feature added in 7.0&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-05-10T16:32:20.920" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7729" PostTypeId="1" CreationDate="2016-05-10T17:49:09.633" Score="1" ViewCount="629" Body="&lt;p&gt;I wanted to know how I could map the escape key to the right &quot;alt&quot; key on the mac keyboard ? Is that possible ?&lt;/p&gt;&#xA;" OwnerUserId="7053" LastActivityDate="2017-02-03T13:29:43.103" Title="Map escape key to &quot;right alt&quot; key on a mac keyboard in .vimrc" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7730" PostTypeId="1" AcceptedAnswerId="7756" CreationDate="2016-05-11T02:12:51.907" Score="5" ViewCount="372" Body="&lt;p&gt;I have configured vim to automatically decompile &quot;.class&quot; files similar to the instructions in: &lt;a href=&quot;http://vim.wikia.com/wiki/VimTip54&quot; rel=&quot;nofollow&quot;&gt;http://vim.wikia.com/wiki/VimTip54&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have made a minor change to use &lt;a href=&quot;http://www.benf.org/other/cfr/&quot; rel=&quot;nofollow&quot;&gt;cfr_0_115&lt;/a&gt; as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augr class&#xA;au!&#xA;au bufreadpost,filereadpost *.class silent %!java -jar /blah/cfr_0_115.jar %&#xA;au bufreadpost,filereadpost *.class set readonly&#xA;au bufreadpost,filereadpost *.class set ft=java&#xA;au bufreadpost,filereadpost *.class silent normal gg=G&#xA;au bufreadpost,filereadpost *.class set nomodified&#xA;augr END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine when opening files from the shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes I work with JAR files and would like to achieve the following workflow:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:Explore&lt;/code&gt; (and navigate to the JAR file)&lt;/li&gt;&#xA;&lt;li&gt;View the JAR file and select a Class&lt;/li&gt;&#xA;&lt;li&gt;When this Class is opened, it should be ran through CFR.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Currently, when I get to step &quot;3&quot; the class is not decompiled for viewing. I'd love to know how I can get the class file from a JAR opened 'through' the class decompiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 1&lt;/strong&gt; - &#xA;With Vim logging enabled, when I open a class file that is NOT within a JAR file, I see &lt;code&gt;Executing BufRead Auto commands for &quot;*.class&lt;/code&gt; include the command I wish to run. However, when I open the class file from within a jar, I do not see the command in the logs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2&lt;/strong&gt; - &#xA;Relevant log entries when opening a JAR: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Executing BufReadCmd Auto commands for &quot;zipfile:*/*&quot;&#xA;autocommand call zip#Read(expand(&quot;&amp;lt;amatch&amp;gt;&quot;), 1)&#xA;&#xA;Calling shell to execute: &quot;(unzip -p -- '/blah/original-httpclienttest-1.0.jar' 'com/atlassianlabs/sslclient/Main.class') &amp;gt;/var/folders/ys/18xytj217f749_vx7rhs4t7w0000gp/T/vwqRYKe/1 2&amp;gt;&amp;amp;1&quot;&#xA;chdir(zipfile:/blah/original-httpclienttest-1.0.jar::com/)&#xA;fchdir() to previous dir&#xA;Reading viminfo file &quot;/blah/.viminfo&quot; marks&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and later:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Executing BufRead Auto commands for &quot;*.class&quot;&#xA;autocommand setf stata&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However when I open a class file by navigating to it directly with the file explore (:Explore) I see: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Executing BufRead Auto commands for &quot;*.class&quot;&#xA;autocommand silent %!java -jar /blah/cfr_0_115.jar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Follow-up&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know why the autocmd's that exist are not getting picked up when opening from a JAR, because VIM is actually running some autocmd, just not the one I want and &quot;autocommand setf stata&quot; is not even present when opening a class. I'm blocked in terms of how to debug this further. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;More Follow-up&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got this working to some extent by adding a function to the filetype.vim file on class files. However, vim reports the file name in the format: ZIPFILEPATH::PATHTOCLASS in the JAR.. I was hoping it would send though the temp file path instead.&lt;/p&gt;&#xA;" OwnerUserId="7587" LastEditorUserId="7587" LastEditDate="2016-05-12T03:32:59.597" LastActivityDate="2016-05-12T11:13:32.527" Title="Run file though a command when opening from Explore" Tags="|autocmd|filetype|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7731" PostTypeId="2" ParentId="6717" CreationDate="2016-05-11T08:12:36.983" Score="3" Body="&lt;p&gt;This is actually a know issue (see issues &lt;a href=&quot;https://github.com/kana/vim-textobj-user/issues/2&quot; rel=&quot;nofollow&quot;&gt;#2&lt;/a&gt; and &lt;a href=&quot;https://github.com/kana/vim-textobj-user/issues/15&quot; rel=&quot;nofollow&quot;&gt;#15&lt;/a&gt; in the plugin bug tracker).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The author of the plugin suggested a workaround of the following form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call textobj#user#plugin('handyobjects', {&#xA;\   'underscores_a': {&#xA;\     'select': 'ar',&#xA;\     '*pattern*': '%[^%]*%'&#xA;\   },&#xA;\   'underscores_i': {&#xA;\     'select': 'ir',&#xA;\     '*pattern*': '%\zs[^%]\+\ze%'&#xA;\   },&#xA;\ })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is not to use a beginning and a ending pattern but just one regex to match the region:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For the &lt;code&gt;ar&lt;/code&gt; motion the regex &lt;code&gt;%[^%]*%&lt;/code&gt; defines a region starting with a &lt;code&gt;%&lt;/code&gt; followed by anything which is not &lt;code&gt;%&lt;/code&gt; repeated zero or more times (i.e. &lt;code&gt;[^$]*&lt;/code&gt;) followed by another &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For the &lt;code&gt;ir&lt;/code&gt; motion the regex is more or less the same but the match excludes the delimitating &lt;code&gt;%&lt;/code&gt; characters thanks to &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So it is possible to use the same pattern for begin and end but you need to use only one regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important note&lt;/strong&gt; This is a workaround and it has a major drawback: I wasn't able to use it to match a region on several lines (which can be a problem in some cases).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; In some cases it is possible to create text objects which matches the same pattern on different lines. Here is what the author &lt;a href=&quot;https://github.com/kana/vim-textobj-user/issues/48&quot; rel=&quot;nofollow&quot;&gt;suggested&lt;/a&gt; to match two &lt;code&gt;_&lt;/code&gt; on different lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call textobj#user#plugin('handyobjects', {&#xA;\   'underscores_a': {&#xA;\     'select': 'au',&#xA;\     'pattern': '_\_[^_]*_'&#xA;\   },&#xA;\   'underscores_i': {&#xA;\     'select': 'iu',&#xA;\     'pattern': '_\zs\_[^_]\+\ze_'&#xA;\   },&#xA;\ })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; That after a really quick test I wasn't able to make it work with &lt;code&gt;%&lt;/code&gt; characters but I guess it what because of some escaping problem or something like this. I think that with some work on the regex it is possible to do it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-11T14:10:36.663" LastActivityDate="2016-05-11T14:10:36.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7732" PostTypeId="1" AcceptedAnswerId="7733" CreationDate="2016-05-11T10:21:41.653" Score="5" ViewCount="340" Body="&lt;p&gt;I never made any plugins but I would like to get some advice for a specific case. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm writing a lot of ruby. Sometimes I have very long lines that I want to split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyModel.first_method.second_method(arg).third_method(arg.method)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyModel&#xA;  .first_method&#xA;  .second_method(arg)&#xA;  .third_method(arg.method)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the moment I have only the macro with &lt;code&gt;f.i&amp;lt;CR&amp;gt;&amp;lt;ESC&amp;gt;w&lt;/code&gt; but it fails when there is a dot inside parentheses. And I have to count how many times I want the macro to run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering what is the best way to optimise this ? &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Search for a regex that will avoid searching dot inside regex?&lt;/li&gt;&#xA;&lt;li&gt;For the moment I have only that &lt;code&gt;:s/\./\1\r./g&lt;/code&gt; but my text is not indented and it doesn't deal with dot inside parentheses.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for your help.&lt;/p&gt;&#xA;" OwnerUserId="3357" LastEditorDisplayName="user859" LastEditDate="2016-05-17T11:10:39.220" LastActivityDate="2016-05-17T11:10:39.220" Title="Efficient ruby line splitting" Tags="|regular-expression|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7733" PostTypeId="2" ParentId="7732" CreationDate="2016-05-11T10:43:13.210" Score="4" Body="&lt;p&gt;I'm not sure it will work for all the cases, but it seems to work on the example you provided:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v\ze(\(\w+)@&amp;lt;!\./\r  /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The pattern used by the substitution command is: &lt;code&gt;\v\ze(\(\w+)@&amp;lt;!\.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; is the very magic switch (useful to get rid of backslashes)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\ze&lt;/code&gt; describes the end of the match. Since &lt;code&gt;\ze&lt;/code&gt; is at the beginning of the pattern, it means that nothing will be substituted/removed. The replacement part of the substitution command will simply be inserted in front of the match.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(\(\w+)@&amp;lt;!&lt;/code&gt; describes an open parenthesis and a word (&lt;code&gt;\(\w+&lt;/code&gt;) which must not precede what will follow in the pattern (&lt;code&gt;@&amp;lt;!&lt;/code&gt;). See &lt;code&gt;:h /\@&amp;lt;!&lt;/code&gt; for more info on this, or google negative lookbehind.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\.&lt;/code&gt; describes a dot&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Whenever this pattern is found, &lt;code&gt;:s&lt;/code&gt; inserts a newline and 2 spaces.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: I've just realised it would fail if there are several dots inside a pair of parentheses. For example, if you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyModel.first_method.second_method(arg).thrid_method(arg.method.foo.bar)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The previous substitution command will give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyModel&#xA;  .first_method&#xA;  .second_method(arg)&#xA;  .thrid_method(arg.method&#xA;  .foo&#xA;  .bar)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, the following one could be more robust:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v\ze(\(\w+(\.\w+)*)@&amp;lt;!\./\r  /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyModel&#xA;  .first_method&#xA;  .second_method(arg)&#xA;  .thrid_method(arg.method.foo.bar)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's the same command as before, except this time, in your negative lookbehind, after the open parenthesis and a word, you add zero or more dots and words: &lt;code&gt;(\.\w+)*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For the indentation problem, you could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v\ze(\(\w+(\.\w+)*)@&amp;lt;!\./\=&quot;\n  &quot; . matchstr(getline('.'), '^\s*')/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's, again, the same command, but this time the replacement part is the evaluation of an expression (&lt;code&gt;\=&lt;/code&gt;) which returns a newline, 2 spaces and the level of indentation of the current line (&lt;code&gt;matchstr(getline('.'), '^\s*')&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to first remove a level of indentation on the line and remove 2 spaces, you could use &lt;code&gt;:s/^  //&lt;/code&gt;, which would give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/^  // | s/\v\ze(\(\w+(\.\w+)*)@&amp;lt;!\./\=&quot;\n  &quot; . matchstr(getline('.'), '^\s*')/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit2: In the previous command &lt;code&gt;()&lt;/code&gt; is used to apply the multi &lt;code&gt;*&lt;/code&gt; to the sub-pattern&lt;code&gt;\.\w+&lt;/code&gt; and &lt;code&gt;@&amp;lt;!&lt;/code&gt; to &lt;code&gt;\(\w+(\.\w+)*&lt;/code&gt;. But in the replacement part, you don't use any backreference (&lt;code&gt;\1&lt;/code&gt;, ..., &lt;code&gt;\9&lt;/code&gt;). So, to make the regex a little bit faster, you could use &lt;code&gt;%()&lt;/code&gt; instead (&lt;code&gt;:h /\%(&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(\)   A pattern enclosed by escaped parentheses.  */\%(\)* */\%(* *E53*&#xA;    Just like \(\), but without counting it as a sub-expression.  This&#xA;    allows using more groups and it's a little bit faster.&#xA;    {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/^  // | s/\v\ze%(\(\w+%(\.\w+)*)@&amp;lt;!\./\=&quot;\n  &quot; . matchstr(getline('.'), '^\s*')/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit3:&#xA;To turn this command into a mapping, you could add this into your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;a :s/^  // &amp;lt;Bar&amp;gt; s/\v\ze%(\(\w+%(\.\w+)*)@&amp;lt;!\./\=&quot;\n  &quot; . matchstr(getline('.'), '^\s*')/g&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyMethods&#xA;  def mymethod&#xA;    MyModel.first_method.second_method(arg).thrid_method(arg.method)&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... if you hit &lt;code&gt;&amp;lt;Leader&amp;gt;a&lt;/code&gt; while the cursor is on the third line, it should give you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyMethods&#xA;  def mymethod&#xA;  MyModel&#xA;    .first_method&#xA;    .second_method(arg)&#xA;    .thrid_method(arg.method)&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-05-13T09:08:47.937" LastActivityDate="2016-05-13T09:08:47.937" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="7734" PostTypeId="1" AcceptedAnswerId="7735" CreationDate="2016-05-11T11:28:45.493" Score="17" ViewCount="3503" Body="&lt;p&gt;I am developing a plugin for Vim and I would like to define a mapping which would be available only while the &quot;execution of the plugin&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far the (simplified) workflow of the plugin is the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The user call a command of the plugin&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The command calls the pre-treatment function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:PreTreatmentFunction(function, ...)&#xA;    &quot; Do some pretreatment stuff&#xA;&#xA;    &quot; Create a mapping to call the TearDown&#xA;    nnoremap &amp;lt;C-c&amp;gt; :call TeardDown()&amp;lt;CR&amp;gt;&#xA;&#xA;    &quot; Call a function depending on the parameter passed to this one&#xA;    if function == &quot;foo&quot;&#xA;        call Foo()&#xA;    else&#xA;        call Bar()&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another function is called which change the state of the buffer (&lt;code&gt;Foo()&lt;/code&gt; or &lt;code&gt;Bar()&lt;/code&gt; in the last lines of the previous function)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;The user use the mapping to call the teardown function&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The tear down function remove the created mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:TearDown()&#xA;    &quot; Do some tear down stuff&#xA;&#xA;    &quot; Remove the mapping&#xA;    unmap &amp;lt;C-c&amp;gt;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am not satisfied with the way I handle my mapping: if the user already mapped it to something else he will loose his original mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is: &lt;strong&gt;How can I save what &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; is mapped to (if it is mapped) and restore it in my tear down function?&lt;/strong&gt;&#xA;Is there a built-in feature to do so?&#xA;I though about &lt;code&gt;grep&lt;/code&gt;ing the result of &lt;code&gt;:nmap &amp;lt;C-c&amp;gt;&lt;/code&gt; but that doesn't feel really &quot;clean&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few side notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I know that LearnVimScriptTheHardWay has &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/51.html#custom-mappings&quot;&gt;a section about that&lt;/a&gt;, but they say to use a ftplugin which is not possible here: the plugin is not dependent on a file type&lt;/li&gt;&#xA;&lt;li&gt;I could create a variable to let the user choose what keys to use: It is probably what I will do but I'm mainly interested in how to do the save and restore.&lt;/li&gt;&#xA;&lt;li&gt;I could use a local leader but I think it's a little bit overkill and I'm still mainly curious about the save and restore thing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-12-29T11:20:17.690" Title="How to save and restore a mapping?" Tags="|key-bindings|plugin-development|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7735" PostTypeId="2" ParentId="7734" CreationDate="2016-05-11T11:42:02.710" Score="33" Body="&lt;p&gt;You could use the &lt;code&gt;maparg()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test if the user mapped something to &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; in normal mode, you would write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !empty(maparg('&amp;lt;C-c&amp;gt;', 'n'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the user mapped something, to store the &lt;code&gt;{rhs}&lt;/code&gt; in a variable, you would write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let rhs_save = maparg('&amp;lt;C-c&amp;gt;', 'n')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want more information about the mapping, like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;is it silent (&lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; argument)?&lt;/li&gt;&#xA;&lt;li&gt;is it local to the current buffer (&lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; argument)?&lt;/li&gt;&#xA;&lt;li&gt;is the &lt;code&gt;{rhs}&lt;/code&gt; the evaluation of an expression (&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; argument)?&lt;/li&gt;&#xA;&lt;li&gt;does it remap the &lt;code&gt;{rhs}&lt;/code&gt; (&lt;code&gt;nnoremap&lt;/code&gt; vs &lt;code&gt;nmap&lt;/code&gt;)?&lt;/li&gt;&#xA;&lt;li&gt;if the user has another mapping which begins with &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt;, does Vim wait for more characters to be typed (&lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; argument)?&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then, you could give a third and a fourth argument: &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;.&lt;br&gt;&#xA;&lt;code&gt;0&lt;/code&gt; because you're looking for a mapping and not an abbreviation, and &lt;code&gt;1&lt;/code&gt; because you want a dictionary with a maximum of information and not just the &lt;code&gt;{rhs}&lt;/code&gt; value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let map_save = maparg('&amp;lt;C-c&amp;gt;', 'n', 0, 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Assuming the user didn't use any special argument in his mapping, and that it doesn't remap the &lt;code&gt;{rhs}&lt;/code&gt;, to restore it, you could simply write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let rhs_save = maparg('&amp;lt;C-c&amp;gt;', 'n')&#xA;&#xA;&quot; do some stuff which changes the mapping&#xA;&#xA;exe 'nnoremap &amp;lt;C-c&amp;gt; ' . rhs_save&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or to be sure and restore all the possible arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let map_save = maparg('&amp;lt;C-c&amp;gt;', 'n', 0, 1)&#xA;&#xA;&quot; do some stuff which changes the mapping&#xA;&#xA;exe (map_save.noremap ? 'nnoremap' : 'nmap') .&#xA;     \ (map_save.buffer ? ' &amp;lt;buffer&amp;gt; ' : '') .&#xA;     \ (map_save.expr ? ' &amp;lt;expr&amp;gt; ' : '') .&#xA;     \ (map_save.nowait ? ' &amp;lt;nowait&amp;gt; ' : '') .&#xA;     \ (map_save.silent ? ' &amp;lt;silent&amp;gt; ' : '') .&#xA;     \ ' &amp;lt;C-c&amp;gt; ' .&#xA;     \ map_save.rhs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: Sorry, I've just realised it wouldn't work as expected if the user calls a script-local function in the &lt;code&gt;{rhs}&lt;/code&gt; of the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose that the user has the following mapping inside his &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-c&amp;gt; :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;FuncA()&amp;lt;CR&amp;gt;&#xA;&#xA;function! s:FuncA()&#xA;    echo 'hello world!'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When he hits &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt;, it displays the message &lt;code&gt;hello world!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And in your plugin, you save a dictionary with all the information, then temporarily change his mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let map_save = maparg('&amp;lt;C-c&amp;gt;', 'n', 0, 1)&#xA;nnoremap &amp;lt;C-c&amp;gt; :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;FuncB()&amp;lt;CR&amp;gt;&#xA;&#xA;function! s:FuncB()&#xA;    echo 'bye all!'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, it will display &lt;code&gt;bye all!&lt;/code&gt;.&#xA;Your plugin does some work, and when it's over, it tries to restore the mapping with the previous command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will probably fail with a message looking like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E117: Unknown function: &amp;lt;SNR&amp;gt;61_FuncA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;61&lt;/code&gt; is just the identifier of the script in which your mapping command would be executed. It could be any other number. If your plugin is the 42th file sourced on the user's system, it will be &lt;code&gt;42&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside a script, when a mapping command is executed, Vim automatically translates the notation &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; into the special key code &lt;code&gt;&amp;lt;SNR&amp;gt;&lt;/code&gt;, followed by a number which is unique for the script, and an underscore. It has to do this, because when the user will hit &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt;, the mapping will be executed outside of the script, and thus it won't know in which script &lt;code&gt;FuncA()&lt;/code&gt; is defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the original mapping was sourced in a different script than your plugin, so here the automatic translation is wrong. It uses the identifier of your script, while it should use the identifier of the user's &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you could do the translation manually. The dictionary &lt;code&gt;map_save&lt;/code&gt; contains a key called &lt;code&gt;'sid'&lt;/code&gt; whose value is the correct identifier.&lt;br&gt;&#xA;So, to make the previous restoration command more robust, you could replace &lt;code&gt;map_save.rhs&lt;/code&gt; with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(map_save.rhs, '&amp;lt;SID&amp;gt;', '&amp;lt;SNR&amp;gt;' . map_save.sid . '_', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the &lt;code&gt;{rhs}&lt;/code&gt; of the original mapping contained &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt;, it should be properly translated. Otherwise, nothing should be changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if you want to shorten the code a little, you could replace the 4 lines which take care of the special arguments with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;join(map(['buffer', 'expr', 'nowait', 'silent'], 'map_save[v:val] ? &quot;&amp;lt;&quot; . v:val . &quot;&amp;gt;&quot;: &quot;&quot;'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;map()&lt;/code&gt; function should convert each item from the list &lt;code&gt;['buffer', 'expr', 'nowait', 'silent']&lt;/code&gt; into the corresponding mapping argument but only if its key inside &lt;code&gt;map_save&lt;/code&gt; is non-zero. And&lt;code&gt;join()&lt;/code&gt; should join all the items into a string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, a more robust way of saving and restoring the mapping could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let map_save = maparg('&amp;lt;C-c&amp;gt;', 'n', 0, 1)&#xA;&#xA;&quot; do some stuff which changes the mapping&#xA;&#xA;exe (map_save.noremap ? 'nnoremap' : 'nmap') .&#xA;    \ join(map(['buffer', 'expr', 'nowait', 'silent'], 'map_save[v:val] ? &quot;&amp;lt;&quot; . v:val . &quot;&amp;gt;&quot;: &quot;&quot;')) .&#xA;    \ map_save.lhs . ' ' .&#xA;    \ substitute(map_save.rhs, '&amp;lt;SID&amp;gt;', '&amp;lt;SNR&amp;gt;' . map_save.sid . '_', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm facing the same issue as you, how to save and restore a mapping in a drawing plugin. And I think I found 2 issues that the initial answer didn't see at the time I wrote it, sorry about that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First issue, suppose that the user uses &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; in a global mapping but also in a buffer-local mapping. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap          &amp;lt;C-c&amp;gt;    :echo 'global mapping'&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-c&amp;gt;    :echo 'local  mapping'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, &lt;code&gt;maparg()&lt;/code&gt; will give priority to the local mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo maparg('&amp;lt;C-c&amp;gt;', 'n', 0, 1)&#xA;&#xA;---&amp;gt; {'silent': 0, 'noremap': 1, 'lhs': '&amp;lt;C-C&amp;gt;', 'mode': 'n', 'nowait': 0, 'expr': 0, 'sid': 7, 'rhs': ':echo ''local  mapping''&amp;lt;CR&amp;gt;', 'buffer': 1}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is confirmed in &lt;code&gt;:h maparg()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    The mappings local to the current buffer are checked first,&#xA;    then the global mappings.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But maybe you aren't interested in the buffer-local mapping, maybe you want the global one.&lt;br&gt;&#xA;The only way I found to, reliably, get the information about the global mapping, is to try to temporarily unmap a potential, shadowing, buffer-local mapping using the same key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It could be done in 4 steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;save a (potential) buffer-local mapping using the key &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;execute &lt;code&gt;:silent! nunmap &amp;lt;buffer&amp;gt; &amp;lt;C-c&amp;gt;&lt;/code&gt; to delete a (potential) buffer-local mapping&lt;/li&gt;&#xA;&lt;li&gt;save the global mapping (&lt;code&gt;maparg('&amp;lt;C-c&amp;gt;', 'n', 0, 1)&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;restore the buffer-local mapping&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The second issue is the following. Suppose that the user didn't map anything to &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt;, then the output of &lt;code&gt;maparg()&lt;/code&gt; will be an empty dictionary. And in this case, the restoration process doesn't consist in the installation of a mapping (&lt;code&gt;:nnoremap&lt;/code&gt;), but in the destruction of a mapping (&lt;code&gt;:nunmap&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To try to solve these 2 new issues, you could try this function to save mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! Save_mappings(keys, mode, global) abort&#xA;    let mappings = {}&#xA;&#xA;    if a:global&#xA;        for l:key in a:keys&#xA;            let buf_local_map = maparg(l:key, a:mode, 0, 1)&#xA;&#xA;            sil! exe a:mode.'unmap &amp;lt;buffer&amp;gt; '.l:key&#xA;&#xA;            let map_info        = maparg(l:key, a:mode, 0, 1)&#xA;            let mappings[l:key] = !empty(map_info)&#xA;                                \     ? map_info&#xA;                                \     : {&#xA;                                        \ 'unmapped' : 1,&#xA;                                        \ 'buffer'   : 0,&#xA;                                        \ 'lhs'      : l:key,&#xA;                                        \ 'mode'     : a:mode,&#xA;                                        \ }&#xA;&#xA;            call Restore_mappings({l:key : buf_local_map})&#xA;        endfor&#xA;&#xA;    else&#xA;        for l:key in a:keys&#xA;            let map_info        = maparg(l:key, a:mode, 0, 1)&#xA;            let mappings[l:key] = !empty(map_info)&#xA;                                \     ? map_info&#xA;                                \     : {&#xA;                                        \ 'unmapped' : 1,&#xA;                                        \ 'buffer'   : 1,&#xA;                                        \ 'lhs'      : l:key,&#xA;                                        \ 'mode'     : a:mode,&#xA;                                        \ }&#xA;        endfor&#xA;    endif&#xA;&#xA;    return mappings&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and this one to restore them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! Restore_mappings(mappings) abort&#xA;&#xA;    for mapping in values(a:mappings)&#xA;        if !has_key(mapping, 'unmapped') &amp;amp;&amp;amp; !empty(mapping)&#xA;            exe     mapping.mode&#xA;               \ . (mapping.noremap ? 'noremap   ' : 'map ')&#xA;               \ . (mapping.buffer  ? ' &amp;lt;buffer&amp;gt; ' : '')&#xA;               \ . (mapping.expr    ? ' &amp;lt;expr&amp;gt;   ' : '')&#xA;               \ . (mapping.nowait  ? ' &amp;lt;nowait&amp;gt; ' : '')&#xA;               \ . (mapping.silent  ? ' &amp;lt;silent&amp;gt; ' : '')&#xA;               \ .  mapping.lhs&#xA;               \ . ' '&#xA;               \ . substitute(mapping.rhs, '&amp;lt;SID&amp;gt;', '&amp;lt;SNR&amp;gt;'.mapping.sid.'_', 'g')&#xA;&#xA;        elseif has_key(mapping, 'unmapped')&#xA;            sil! exe mapping.mode.'unmap '&#xA;                                \ .(mapping.buffer ? ' &amp;lt;buffer&amp;gt; ' : '')&#xA;                                \ . mapping.lhs&#xA;        endif&#xA;    endfor&#xA;&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;Save_mappings()&lt;/code&gt; function could be used to save mappings.&lt;br&gt;&#xA;It expects 3 arguments:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;a list of keys; example: &lt;code&gt;['&amp;lt;C-a&amp;gt;', '&amp;lt;C-b&amp;gt;', '&amp;lt;C-c&amp;gt;']&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;a mode; example: &lt;code&gt;n&lt;/code&gt; for normal mode or &lt;code&gt;x&lt;/code&gt; for visual mode&lt;/li&gt;&#xA;&lt;li&gt;a boolean flag; if it's &lt;code&gt;1&lt;/code&gt;, it means you're interested in global mappings, and if it's &lt;code&gt;0&lt;/code&gt;, in local ones&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;With it, you could save the global mappings using the keys &lt;code&gt;C-a&lt;/code&gt;, &lt;code&gt;C-b&lt;/code&gt; and &lt;code&gt;C-c&lt;/code&gt;, in normal mode, inside a dictionary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let your_saved_mappings = Save_mappings(['&amp;lt;C-a&amp;gt;', '&amp;lt;C-b&amp;gt;', '&amp;lt;C-c&amp;gt;'], 'n', 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, later, when you'll want to restore the mappings, you could call &lt;code&gt;Restore_mappings()&lt;/code&gt;, passing the dictionary containing all the info as an argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call Restore_mappings(your_saved_mappings)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There could be a 3rd problem, when saving/restoring buffer-local mappings.  Because, between the moment when we saved the mappings, and the moment when we try to restore them, the current buffer may have changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, maybe the &lt;code&gt;Save_mappings()&lt;/code&gt; function could be improved by saving the number of the current buffer (&lt;code&gt;bufnr('%')&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then, &lt;code&gt;Restore_mappings()&lt;/code&gt; would use this info to restore the buffer-local mappings in the right buffer. We could probably use the &lt;code&gt;:bufdo&lt;/code&gt; command, prefix the latter with a count (matching the buffer number previously saved), and suffix it with the mapping command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:{original buffer number}bufdo {mapping command}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We would have to check first if the buffer still exists, using the &lt;code&gt;bufexists()&lt;/code&gt; function, because it could have been deleted in the meantime.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-29T03:42:46.260" LastActivityDate="2016-12-29T03:42:46.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7736" PostTypeId="2" ParentId="2784" CreationDate="2016-05-11T14:30:30.563" Score="4" Body="&lt;p&gt;In my case, &lt;a href=&quot;https://vi.stackexchange.com/questions/2784/how-to-stop-gvim-wrapping-text-at-column-80/2786#comment2888_2784&quot;&gt;Vitor's comment&lt;/a&gt; suggested I run the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set tw?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doing so gave me the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;textwidth=78&#xA;      Last set from C:\Program Files (x86)\Vim\vim74\vimrc_example.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;em&gt;vimrc_example.vim&lt;/em&gt;, I found the relevant lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Only do this part when compiled with support for autocommands.&#xA;if has(&quot;autocmd&quot;)&#xA;&#xA;  ...&#xA;&#xA;  &quot; For all text files set 'textwidth' to 78 characters.&#xA;  autocmd FileType text setlocal textwidth=78&#xA;&#xA;  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I found that my &lt;em&gt;.vimrc&lt;/em&gt; is sourcing that file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/vimrc_example.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my case, I don't want &lt;code&gt;textwidth&lt;/code&gt; to be set for any files, so I just commented out the relevant line in &lt;em&gt;vimrc_example.vim&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2629" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-05-11T14:30:30.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7737" PostTypeId="2" ParentId="3728" CreationDate="2016-05-11T14:46:16.630" Score="7" Body="&lt;p&gt;To deal with splits I use the &lt;a href=&quot;https://github.com/kana/vim-submode.git&quot; rel=&quot;noreferrer&quot;&gt;submode-plugin&lt;/a&gt; which is actually pretty convenient: It allows you to create a new mode (&quot;mode&quot; like in normal mode, visual mode, insert mode, etc...) where you define new key bindings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that you don't have to use &lt;kbd&gt;Ctrl+w&lt;/kbd&gt; anymore and as you are in a new mode all the keys are free to bind: no more problems like &quot;Damn I can't find a key combination which as a signification and isn't mapped yet&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can install the plugin with any regular plugin manager, and here are some of my configuration to give you some inspiration:&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I created a new mode that I called &lt;code&gt;WindowsMode&lt;/code&gt; in which I manipulate my splits:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call submode#enter_with('WindowsMode', 'n', '', '&amp;lt;Leader&amp;gt;k', ':echo &quot;windows mode&quot;&amp;lt;CR&amp;gt;')&#xA;call submode#leave_with('WindowsMode', 'n', '', '&amp;lt;Leader&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These lines means that I enter in the mode with &lt;kbd&gt;Leader&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; and I exit the mode with &lt;kbd&gt;Leader&lt;/kbd&gt;: After I hit &lt;kbd&gt;Leader&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; all the keys I hit will:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do nothing if I didn't defined a mapping for them in this mode&lt;/li&gt;&#xA;&lt;li&gt;Do what I decided to map them in this mode (see the rest of the answer)&lt;/li&gt;&#xA;&lt;li&gt;Go back to normal mode if I hit &lt;kbd&gt;Leader&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Once I'm in &lt;code&gt;WindowsMode&lt;/code&gt; these lines make &lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt; navigate through the splits like &lt;kbd&gt;Ctrl+w&lt;/kbd&gt;&lt;kbd&gt;hjkl&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Change of windows with hjkl&#xA;call submode#map('WindowsMode', 'n', '', 'j', '&amp;lt;C-w&amp;gt;j')&#xA;call submode#map('WindowsMode', 'n', '', 'k', '&amp;lt;C-w&amp;gt;k')&#xA;call submode#map('WindowsMode', 'n', '', 'h', '&amp;lt;C-w&amp;gt;h')&#xA;call submode#map('WindowsMode', 'n', '', 'l', '&amp;lt;C-w&amp;gt;l')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I used these lines to split the windows with &lt;kbd&gt;/&lt;/kbd&gt; and &lt;kbd&gt;!&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; split windows with / and !&#xA;call submode#map('WindowsMode', 'n', '', '/', '&amp;lt;C-w&amp;gt;s')&#xA;call submode#map('WindowsMode', 'n', '', '!', '&amp;lt;C-w&amp;gt;v')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;kbd&gt;q&lt;/kbd&gt; close a split:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call submode#map('WindowsMode', 'n', '', 'q', '&amp;lt;C-w&amp;gt;c')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Move the splits with &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;hjkl&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call submode#map('WindowsMode', 'n', '', '&amp;lt;C-j&amp;gt;', '&amp;lt;C-w&amp;gt;J')&#xA;call submode#map('WindowsMode', 'n', '', '&amp;lt;C-k&amp;gt;', '&amp;lt;C-w&amp;gt;K')&#xA;call submode#map('WindowsMode', 'n', '', '&amp;lt;C-h&amp;gt;', '&amp;lt;C-w&amp;gt;H')&#xA;call submode#map('WindowsMode', 'n', '', '&amp;lt;C-l&amp;gt;', '&amp;lt;C-w&amp;gt;L')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Vim-submode allows to do a lot of powerful things, see &lt;a href=&quot;https://github.com/kana/vim-submode/blob/master/doc/submode.txt&quot; rel=&quot;noreferrer&quot;&gt;the doc&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Another approach of the Window submode is described &lt;a href=&quot;http://ddrscott.github.io/blog/2016/making-a-window-submode/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. I think the method used by the author is even closer to answer the question: Here is used to create a new mode but all the &lt;code&gt;&amp;lt;c-w&amp;gt;something&lt;/code&gt; mappings are available with the same keys in the submode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Go through every letter&#xA;for key in ['a','b','c','d','e','f','g','h','i','j','k','l','m',&#xA;\           'n','o','p','q','r','s','t','u','v','w','x','y','z']&#xA;  &quot; maps lowercase, uppercase and &amp;lt;C-key&amp;gt;&#xA;  call submode#map('window', 'n', '', key, '&amp;lt;C-w&amp;gt;' . key)&#xA;  call submode#map('window', 'n', '', toupper(key), '&amp;lt;C-w&amp;gt;' . toupper(key))&#xA;  call submode#map('window', 'n', '', '&amp;lt;C-' . key . '&amp;gt;', '&amp;lt;C-w&amp;gt;' . '&amp;lt;C-'.key . '&amp;gt;')&#xA;endfor&#xA;&#xA;&quot; Go through symbols. Sadly, '|', not supported in submode plugin.&#xA;for key in ['=','_','+','-','&amp;lt;','&amp;gt;']&#xA;  call submode#map('window', 'n', '', key, '&amp;lt;C-w&amp;gt;' . key)&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way all the mappings &lt;code&gt;&amp;lt;c-w&amp;gt;lowerCaseKey&lt;/code&gt;, &lt;code&gt;&amp;lt;c-w&amp;gt;upperCaseKey&lt;/code&gt;, &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;c-Key&amp;gt;&lt;/code&gt; and the mappings &lt;code&gt;&amp;lt;c-w&amp;gt;=_+-&amp;lt;&amp;gt;&lt;/code&gt; are all accessible in the window mode without the prefix &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-12T12:58:18.507" LastActivityDate="2016-05-12T12:58:18.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7738" PostTypeId="5" CreationDate="2016-05-11T15:14:51.550" Score="0" Body="&lt;p&gt;A very good introduction to plugin development can be found &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/41.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-11T15:14:51.550" LastActivityDate="2016-05-11T15:14:51.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7739" PostTypeId="4" CreationDate="2016-05-11T15:14:51.550" Score="0" Body="Questions about the development of plugins for Vim. *Do not* use this tag for questions about a specific plugin." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-11T15:14:51.550" LastActivityDate="2016-05-11T15:14:51.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7740" PostTypeId="2" ParentId="6892" CreationDate="2016-05-11T16:06:40.580" Score="1" Body="&lt;p&gt;&lt;strong&gt;Is it possible&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the major changes Neovim made was to decouple the GUI implementation from the core application. All GUI (and TUIs for that matter) communicate with the core application using the &lt;a href=&quot;http://msgpack.org/&quot; rel=&quot;nofollow&quot;&gt;msgpack RPC&lt;/a&gt; protocol. msgpack works over stdin/stdout, named pipes, tcp, etc. so its possible for pretty much any application to support neovim as its embedded editor. It just requires the GUI to handle all the GUI stuff, while pushing down keystrokes and text to the core to handle processing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Would it need to be implemented on MATLAB's side&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for MATLAB or any preexisting application, there is quite a few steps that need to be taken to implement this change. Basically all input and output needs to now be directed to and from the nvim RPC system. The text area needs to get its content from nvim. Each keystroke event handler needs to decide if its a vim request and send to nvim, or if it is something that MATLAB would handle. And of course, MATLAB would need to implement the startup of the nvim process and be able to do bi-directional communication (using msgpack). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While it would be nice to have vi-keybindings and even plugin support in MATLAB, I don't see there would be a huge motivation to do this, especially when you have plugins and access to the MATLAB cli. It would be quite a bit amount of work to wedge this in there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;When is this feature awesome&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where Neovim's embedded feature really shines is in new development and atypical installations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://c9.io&quot; rel=&quot;nofollow&quot;&gt;Cloud9&lt;/a&gt; is an online editor and IDE. It currently has a vim mode which gives you key-bindings, etc. Just think if you were able to remove all the code required to reinvent the &quot;vim wheel&quot; by creating a text area and an event handler to capture key presses and make a background nvim process do all the work? A JS based web-page that actually uses all of your VimL plugins you have on your desktop, how awesome would that be? When new features are added and bugs are fixed, just drop in a replacement nvim and you're good to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you currently have a GUI application that is in need of an editor function? Maybe you want a more powerful editor than just Backspace and Delete. Using an embedded version of nvim can give you that functionality very quickly. vi-keybindings are very common but most people don't notice (Gmail uses them for navigation for instance). If you don't like using hjkl, then setup a custom vimrc to remap all the key-bindings so no one knows its vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Think of all those devices out there with &quot;Easy to Use&quot; Configuration UIs that provide little advanced user functionality unless you go in and monkey with config files. Add in a button to edit the file right in your app.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;More Info&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information on the entire UI architecture check out the &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Plugin-UI-architecture&quot; rel=&quot;nofollow&quot;&gt;Neovim wiki&lt;/a&gt;. There are also a bunch of GUI implementations and Programming Language bindings available on the &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Related-projects&quot; rel=&quot;nofollow&quot;&gt;Related Projects&lt;/a&gt; page.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-05-11T16:06:40.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7741" PostTypeId="1" AcceptedAnswerId="7746" CreationDate="2016-05-11T16:15:44.873" Score="10" ViewCount="6943" Body="&lt;p&gt;I have a common usecase when I transform some python expression the following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;value 1&#xA;value 2&#xA;value 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['value 1', 'value 2', 'value 3']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The easiest way may be to use a mapping, but I wanted to use a substitution for this task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\(.*\n\)\+/[&amp;amp;]/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which result in &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[value 1&#xA;value 2&#xA;value 3&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This raise a question, because I want to be able to match the &lt;code&gt;\(.*\)&lt;/code&gt;, but not the &lt;code&gt;\n&lt;/code&gt; and the use the result of the matched inside a &lt;code&gt;'...'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know how to do this?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-28T23:41:30.643" Title="Nested matching group in regex" Tags="|regular-expression|replace|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7742" PostTypeId="2" ParentId="6507" CreationDate="2016-05-11T16:25:27.900" Score="2" Body="&lt;p&gt;If you are ok with no stdin functionality, you could use &lt;a href=&quot;http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; entry in the Vim wikia page.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -complete=shellcmd -nargs=+ Shell call RunShellCommand(&amp;lt;q-args&amp;gt;)&#xA;function! RunShellCommand(cmdline)&#xA;  let isfirst = 1&#xA;  let words = []&#xA;  for word in split(a:cmdline)&#xA;    if isfirst&#xA;      let isfirst = 0&#xA;    else&#xA;      if word[0] =~ '\v[%#&amp;lt;]'&#xA;        let word = expand(word)&#xA;      endif&#xA;      let word = shellescape(word, 1)&#xA;    endif&#xA;    call add(words, word)&#xA;  endfor&#xA;  let expand_cmdline = join(words)&#xA;  botright new&#xA;  setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap&#xA;  call setline(1, 'You entered: ' . a:cmdline)&#xA;  call setline(2, 'Expanded to: ' . expand_cmdline)&#xA;  call append(line('$'), substitute(getline(2), '.', '=', 'g'))&#xA;  silent execute '$read !'. expand_cmdline&#xA;  1&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command is great for running an autonomous command and getting the response in its own scratch buffer. &lt;code&gt;:RunShellCommand cmake test app Console/CommandFeedParserShell&lt;/code&gt; I use this for all the other non-make situations when I don't want to write the output to my current buffer (a la &lt;code&gt;:!command&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-05-11T16:25:27.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7743" PostTypeId="2" ParentId="6724" CreationDate="2016-05-11T17:33:12.680" Score="0" Body="&lt;p&gt;I'm not sure what you mean by &quot;notify new file&quot;; if you want to create a new file, when browsing via scp://hostname/directory, just press &quot;%&quot; like you would when in a local directory to create a new file.  See :help netrw-%.  You may create a directory using d (:help netrw-d).  If you want to modify an already existing file, select it with your cursor atop the filename in the netrw display and press &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; (there are other selection methods, too, including v, o, t, etc).  See :help netrw-quickmap for an overview on this.  I've just tried this and did not get an empty file (when pre-existing).  A new file, of course, will be empty.  &lt;/p&gt;&#xA;" OwnerUserId="2377" LastEditorUserId="2377" LastEditDate="2016-09-13T19:33:47.133" LastActivityDate="2016-09-13T19:33:47.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7744" PostTypeId="1" CreationDate="2016-05-11T18:02:51.297" Score="2" ViewCount="494" Body="&lt;p&gt;over at &lt;a href=&quot;https://hashrocket.com/blog/posts/8-great-vim-mappings&quot; rel=&quot;nofollow&quot;&gt;https://hashrocket.com/blog/posts/8-great-vim-mappings&lt;/a&gt; I came across said mapping. While it is clear to me it yanks a paragraph, I'm having trouble decomposing this command. What does the a do there? Why the angled brackets? What is going on?&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2016-05-11T18:19:14.893" Title="What does yap&lt;S-}&gt;p do?" Tags="|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7745" PostTypeId="2" ParentId="7744" CreationDate="2016-05-11T18:19:14.893" Score="8" Body="&lt;p&gt;It's just a poor method of writing it out. In general, anything between &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; is understood to mean &quot;Not literal keystrokes, but with modifiers&quot;. For example, if I was telling someone to press &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt;, I would write &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, &lt;code&gt;&amp;lt;S-}&amp;gt;&lt;/code&gt; means &lt;kbd&gt;shift&lt;/kbd&gt;+&lt;code&gt;}&lt;/code&gt;, which is a poor way of writing it out since this is the same thing as just &lt;code&gt;}&lt;/code&gt;, which (from &lt;code&gt;:help }&lt;/code&gt;) means&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;}           [count] paragraphs forward.  |exclusive| motion.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would have written&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap cp yap}p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this would do the exact same thing. You can test this yourself. If you do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap } &amp;lt;S-}&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and hit &lt;code&gt;}&lt;/code&gt; a couple of times, you can see that it does the same thing.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-05-11T18:19:14.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7746" PostTypeId="2" ParentId="7741" CreationDate="2016-05-11T18:45:13.433" Score="7" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to do this in one expression if we use a &quot;sub-replace-expression.&quot; See bottom for info on that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;/Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem here is that you want to do two different things.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Operate on the match as a whole (i.e. surround it with &lt;code&gt;[]&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Operate on each item in the match (i.e. surround them with &lt;code&gt;'',&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can easily do either one:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:s/\(.\+\n\)\+/[&amp;amp;]/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s/\(.\+\)\n/'\1', /&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;but as far as I know there's no way to do both in a single operation. I did try to get the proper output with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\(\(.\+\)\n\)\+/[\2]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But of course the problem with this is that the &lt;code&gt;\2&lt;/code&gt; matches only the last match from the second set of memory parentheses &lt;code&gt;\(\)&lt;/code&gt; and doesn't &quot;remember&quot; anything before that. So you end up with only the last line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend doing some pre/post processing with an additional &lt;code&gt;:s///&lt;/code&gt; command to get rid of the newlines before/after the fact. Here's what I came up with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FormatExpression()&#xA;   .,/\n^$/s/\(.*\)\n/'\1', /&#xA;   s/\(.*\), /[\1]/&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;1st line (Remove newlines)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;.,/\n^$/&lt;/code&gt; This is a range modifier for the search and replace. Without this, the command will go on to mutilate your entire file. Currently it goes from the current line &lt;code&gt;.&lt;/code&gt;, to the next blank line &lt;code&gt;\n^$&lt;/code&gt;. I'm not sure how you were intending to split things up, but you need some way to tell it to stop.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s/&lt;/code&gt; The beginning of a search and replace command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(.*\)\n&lt;/code&gt; Match the whole line, but only save the part without the newline.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'\1',&lt;/code&gt; Replace line with the match surrounded by single quotes and append a comma.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;2nd line (Surround in brackets)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\(.*\),&lt;/code&gt; Match the whole line but not the last comma and space&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[\1]&lt;/code&gt; Surround with brackets and also remove superfluous ending comma and space.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm going to keep looking into this, but at the moment I don't think it's possible with a single expression. :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found a way to do this with one expression! Internally this is actually two substitutions, but it &lt;em&gt;is&lt;/em&gt; technically one expression. Here's what I came up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v((.+\n)*.+)\n/\= &quot;['&quot; . substitute(submatch(1), '\n', &quot;', '&quot;, 'g') . &quot;']&quot; /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:s///&lt;/code&gt;: Do a substitution&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\v((.+\n)*.+)\n&lt;/code&gt;: Basically gathers up all the next non-blank lines and stores it all except for the final &lt;code&gt;\n&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\=&lt;/code&gt; Allows us to use an expression in the replacement (see &lt;code&gt;:h sub-replace-expression&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;substitute(submatch(1)...)&lt;/code&gt;: Replaces all stored &lt;code&gt;\n&lt;/code&gt; with &lt;code&gt;', '&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;['&quot; . ... . &quot;']&quot;&lt;/code&gt;: Prepends &lt;code&gt;['&lt;/code&gt; and appends &lt;code&gt;']&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This will start at the position of the cursor and go until it finds a blank line (&lt;code&gt;^\n&lt;/code&gt;). Not grabbing the last &lt;code&gt;\n&lt;/code&gt; is important as without that bit we're left with an additional &lt;code&gt;',&lt;/code&gt; that we don't want at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some might consider this more complex than the previous two-expression answer. But I thought I would go ahead and add this since it is in fact possible to do it with one expression. :)&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-07-28T22:42:05.037" LastActivityDate="2016-07-28T22:42:05.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7747" PostTypeId="2" ParentId="5658" CreationDate="2016-05-11T19:56:24.917" Score="3" Body="&lt;p&gt;Here is a script that will test if the movement will be going up or down a fold level and then open or close if appropriate.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MoveAndFold(dir)&#xA;  let pos = getpos('.')[1]&#xA;  let nxt = l:pos + a:dir&#xA;  let src = foldlevel(l:pos)&#xA;  let dst = foldlevel(l:nxt)&#xA;&#xA;  if l:src &amp;lt; l:dst&#xA;    exec l:nxt . &quot;foldopen&quot;&#xA;  elseif l:src &amp;gt; l:dst&#xA;    exec l:pos . &quot;foldclose&quot;&#xA;  endif&#xA;  exec &quot;:&quot; . l:nxt&#xA;endfunction&#xA;&#xA;nnoremap j :call MoveAndFold(1)&amp;lt;cr&amp;gt;&#xA;nnoremap k :call MoveAndFold(-1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Its a little verbose and can probably be reduced but it shows you what all the actions are.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-05-11T19:56:24.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7748" PostTypeId="2" ParentId="7683" CreationDate="2016-05-11T19:59:31.263" Score="1" Body="&lt;p&gt;I installed gvim from &lt;a href=&quot;https://bintray.com/micbou/generic/vim&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and &lt;code&gt;Python 2.7.9&lt;/code&gt; and it works like a charm now.&lt;br&gt;&#xA;I will further try to make it portable and edit the question if I succeed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;From my experience trying to get &lt;code&gt;python&lt;/code&gt; in gvim under windows to work, I have to say that there seems to be a problem with the 2.7.11 version and gvim 7.4.x&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="7555" LastActivityDate="2016-05-11T19:59:31.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7749" PostTypeId="1" CreationDate="2016-05-11T21:22:40.917" Score="2" ViewCount="163" Body="&lt;p&gt;Is there a way to take advantage of syntax highlighting for searches? For example, can a search be limited to comments or non-comments, if they are correctly marked by syntax highlighting?&lt;/p&gt;&#xA;" OwnerUserId="7222" LastActivityDate="2016-05-11T21:22:40.917" Title="Search within syntax group?" Tags="|syntax-highlighting|search|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7750" PostTypeId="1" AcceptedAnswerId="7763" CreationDate="2016-05-12T07:06:03.893" Score="10" ViewCount="3156" Body="&lt;p&gt;I have over 500 abbreviations(&lt;code&gt;iabbr&lt;/code&gt;, &lt;code&gt;abbr&lt;/code&gt;) and some mappings in my vimrc file from Java, PHP, C/C++ and Latex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not easy to remember right away when I don't use the languages for some time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering whether I can do completion on abbreviation name. Is there any better way to access/manage all these abbreviations?&lt;/p&gt;&#xA;" OwnerUserId="7597" LastEditorUserId="205" LastEditDate="2016-05-12T20:02:42.520" LastActivityDate="2019-10-14T04:55:50.120" Title="How do I manage and remember many abbreviations in my vimrc?" Tags="|abbreviations|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7751" PostTypeId="2" ParentId="7750" CreationDate="2016-05-12T07:23:03.307" Score="10" Body="&lt;p&gt;A wikia &lt;a href=&quot;http://vim.wikia.com/wiki/VimTip267&quot;&gt;tip&lt;/a&gt; suggest a method to selectively display your abbreviations:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can list all of your abbreviations with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ab&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(replace &lt;code&gt;ab&lt;/code&gt; by &lt;code&gt;iab&lt;/code&gt; to list only insert mode abbreviations) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you can list all the abbreviations with the same prefix with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ab prefix&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not as ideal as a completion on abbreviations but that could be a good way to rapidly have a list of your existing abbreviations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make this solution more efficient a good practice would be to create abbreviation specific to a filetype. For example this abbreviation is only useful in a java buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev syso System.out.println(&quot;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it is good to define it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! FileType java :iabbrev &amp;lt;buffer&amp;gt; syso System.out.println(&quot;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The autocommand part allows to create the abbreviation only when you are in a java buffer and the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; option make the abbreviation accessible only from this buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way &lt;code&gt;:iab&lt;/code&gt; will display the abbreviation only when you are in a java buffer. If you have a lot of abbreviations it could be interesting to create a function by filetype which would define all of the abbreviations and let the autocommand call the function. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! FileType latex call CreateLatexAbbrev()&#xA;&#xA;function! CreateLatexAbbrev()&#xA;    iabbrev &amp;lt;buffer&amp;gt; something something else&#xA;    &quot; All the other latex abbreviations&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another solution could be to create your own auto-complete function using a list of your abbreviation as a source of keywords.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally I have to say that I'm pretty impressed by &quot;over 500 abbreviations&quot;, I don't know which ones you are using but maybe it would be interesting for you to have a look at the concept of snippets if you are not familiar with them. As they are templates that are triggered by entering a keyword and pressing a hotkey, they are more flexible than abbreviations, it might allow you to reduce the number of abbreviations you're using. See &lt;a href=&quot;https://medium.com/brigade-engineering/sharpen-your-vim-with-snippets-767b693886db#.ekaawtumn&quot;&gt;here&lt;/a&gt; for an interesting introduction.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-12T08:57:34.407" LastActivityDate="2016-05-12T08:57:34.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7752" PostTypeId="1" AcceptedAnswerId="7753" CreationDate="2016-05-12T08:59:57.927" Score="2" ViewCount="340" Body="&lt;p&gt;I know that if I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;expr&amp;gt; . InsertDot()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the result of &lt;code&gt;InsertDot()&lt;/code&gt; will be inserted as &lt;code&gt;{rhs}&lt;/code&gt; of the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to do the same but with the &lt;code&gt;{lhs}&lt;/code&gt;, in order to be able to define some dynamic mappings that will take as key sequence what is defined in a var.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible? If so, how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="7599" LastActivityDate="2016-05-12T09:05:58.517" Title="Use an expression as `lhs` in a mapping" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7753" PostTypeId="2" ParentId="7752" CreationDate="2016-05-12T09:05:58.517" Score="5" Body="&lt;p&gt;You could use the &lt;code&gt;execute&lt;/code&gt; command. If your lhs is in the variable &lt;code&gt;l:lhs&lt;/code&gt; you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;inoremap &amp;lt;expr&amp;gt; &quot; . l:lhs . &quot; InsertDot()&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;execute&lt;/code&gt; will expand the content of the variable and then execute the string obtained by the concatenation of the quoted string and the value of the variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#:execute&quot;&gt;&lt;code&gt;:h :execute&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-05-12T09:05:58.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7754" PostTypeId="1" AcceptedAnswerId="7755" CreationDate="2016-05-12T09:16:37.667" Score="15" ViewCount="2828" Body="&lt;p&gt;If I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function foo(bar) {&#xA;    return bar + 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I use &lt;code&gt;cw&lt;/code&gt; to change the first &lt;code&gt;bar&lt;/code&gt; to &lt;code&gt;baz&lt;/code&gt;, how do I jump to the next matching &lt;code&gt;bar&lt;/code&gt;, so that I can use &lt;code&gt;.&lt;/code&gt; to make the same change?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't use &lt;code&gt;*&lt;/code&gt;, because that searches for the &lt;em&gt;current&lt;/em&gt; word under the cursor, and I foolishly didn't search for &lt;code&gt;bar&lt;/code&gt; the first time, so &lt;code&gt;n&lt;/code&gt; won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simple way to search for the next occurrence of the word as it was &lt;em&gt;before&lt;/em&gt; I changed it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;don't&lt;/em&gt; want to do a search and replace, because either there are other occurrences of &lt;code&gt;bar&lt;/code&gt; in my file that I don't want to change, or because there were only two instances of &lt;code&gt;bar&lt;/code&gt;, and I forgot about &lt;code&gt;:%s/bar/baz/&lt;/code&gt; before I started and that's too much effort to change the only remaining instance.&lt;/p&gt;&#xA;" OwnerUserId="5339" LastActivityDate="2016-05-12T16:16:27.807" Title="Jump to next occurrence of the word I just changed" Tags="|search|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7755" PostTypeId="2" ParentId="7754" CreationDate="2016-05-12T09:27:11.433" Score="15" Body="&lt;p&gt;The text you just changed with &lt;code&gt;cw&lt;/code&gt; was cut into the unnamed register so you can reuse it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&amp;lt;C-r&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to jump to the next occurrence of the text covered by your last change.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-05-12T09:27:11.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7756" PostTypeId="2" ParentId="7730" CreationDate="2016-05-12T11:13:32.527" Score="2" Body="&lt;p&gt;By starting vim using: &lt;code&gt;vim -V9aLogFile.log&lt;/code&gt; I was able to determine that when &lt;code&gt;:Explore&lt;/code&gt; opens a file, it checks the content of filetype.vim and autocmd's are working from there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because vim reports the filename of a class inside a jar file in the format &lt;code&gt;zipfile::path-to-jar::path-to-class&lt;/code&gt; I needed to workaround that as my Java decompiler couldn't handle this type of file path. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created a shell &quot;wrapper&quot; script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;&#xA;pathToDecompiler=/blah/cfr_0_115.jar&#xA;&#xA;&#xA;fileType=$(echo $* | cut -f1 -d:)&#xA;jarFile=$(echo $* | cut -f2 -d:) &#xA;classFile=$(echo $* | cut -f4 -d:) &#xA;uuid=$(uuidgen)&#xA;&#xA;&#xA;if [ $fileType = &quot;zipfile&quot; ]&#xA;then&#xA;    tmpDir=/tmp/$uuid&#xA;    unzip -qq $jarFile $classFile -d $tmpDir &#xA;    java -jar $pathToDecompiler $tmpDir/$classFile&#xA;    rm -rf /tmp/$uuid/ &amp;gt;&amp;amp;/dev/null&#xA;else&#xA;    java -jar $pathToDecompiler $*&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above script handles two cases, when opening a normal class file, and when opening a class file from the Explore Command, it creates a file in temp. Note: when writing this, I found entering &lt;code&gt;rm -rf ...&lt;/code&gt; particularly scary in the event a variable didn't get populated. I decided to play it safe and hard-code '/tmp'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I created a function back in the filetype.vim file: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Java Class&#xA;au BufRead *.class call SetClassOptions()&#xA;function SetClassOptions()&#xA;     setf stata&#xA;     silent %!/blah/get-class-from-jar.sh %&#xA;     set readonly&#xA;     set ft=java&#xA;     silent normal gg=G&#xA;     set nomodified&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's a little hacky, and I am sure it could be polished or completed in a more 'vim' way, but at least it has my usecase sorted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;final result is recorded: &lt;a href=&quot;https://giphy.com/gifs/l41Yf8WlUQWj3R6hy&quot; rel=&quot;nofollow&quot;&gt;https://giphy.com/gifs/l41Yf8WlUQWj3R6hy&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="7587" LastActivityDate="2016-05-12T11:13:32.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7758" PostTypeId="1" AcceptedAnswerId="18686" CreationDate="2016-05-12T13:11:07.030" Score="5" ViewCount="610" Body="&lt;p&gt;I've been authoring a lot of F# in Vim lately. Like Python it is pretty strictly indentation-based. However, unlike &lt;a href=&quot;https://github.com/klen/python-mode&quot; rel=&quot;nofollow&quot;&gt;Python mode&lt;/a&gt; for Vim, it does not appear that the standard &lt;a href=&quot;https://github.com/fsharp/vim-fsharp&quot; rel=&quot;nofollow&quot;&gt;F# Vim plugin&lt;/a&gt; supports any kinds of motions. I would like the ability to rapidly navigate over modules and functions, in the spirit of what is done with &lt;a href=&quot;https://github.com/klen/python-mode/blob/develop/doc/pymode.txt#L165&quot; rel=&quot;nofollow&quot;&gt;motions for classes and functions&lt;/a&gt; in Python mode:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;[M      Jump to previous class or method (normal, visual, operator modes)&#xA;]M      Jump to next class or method (normal, visual, operator modes)&#xA;aC      Select a class. Ex: vaC, daC, yaC, caC (normal, operator modes)&#xA;iC      Select inner class. Ex: viC, diC, yiC, ciC (normal, operator modes)&#xA;aM      Select a function or method. Ex: vaM, daM, yaM, caM (normal, operator modes)&#xA;iM      Select inner function or method. Ex: viM, diM, yiM, ciM (normal, operator modes)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So specifically, given some code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;module Foobar =&#xA;    let private foo'() =&#xA;        bar'()&#xA;        |&amp;gt; baz'()&#xA;        |&amp;gt; qux'()&#xA;&#xA;    let foo() =&#xA;        bar()&#xA;        |&amp;gt; baz()&#xA;        |&amp;gt; qux()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to be able to quick jump to the beginning and end of functions and modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can write some code to do this based on Python mode, but before jumping to that I was wondering, since Vim comes with so many motions built in, &lt;strong&gt;Is there a way to say, &quot;move to the first place where there is a nonblank line that is set back &lt;em&gt;n&lt;/em&gt; indentation levels from current line&quot;?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not been able to find anything, maybe because Vim was built originally more for C-style code, but I wanted to know if there was any existing functionality (or existing plugin for that matter) that handled this case, because if so that would probably take care of 95% of what I need without having to implement the motions for F#-specific semantics.&lt;/p&gt;&#xA;" OwnerUserId="1746" LastEditorUserId="1841" LastEditDate="2016-05-12T13:56:00.493" LastActivityDate="2019-01-24T10:52:47.073" Title="Motion to jump back one level of indentation, not including blank lines" Tags="|indentation|cursor-motions|visual-mode|normal-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7759" PostTypeId="2" ParentId="7754" CreationDate="2016-05-12T14:20:30.670" Score="2" Body="&lt;p&gt;If you do not mind pressing a different combination than &lt;code&gt;cw&lt;/code&gt;, then I believe you can get what you want easily, by defining a shortcut.  What you can do is to place the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;a &quot;1yiw:let @/=@1^Mciw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your &lt;code&gt;.vimrc&lt;/code&gt; file.  &lt;strong&gt;Note that&lt;/strong&gt; &lt;code&gt;^M&lt;/code&gt; is a capture of return key, and not the characters &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;M&lt;/code&gt;.  You get it by pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; in insert mode followed by &lt;kbd&gt;Enter&lt;/kbd&gt;.  Now, with this defined, pressing &lt;code&gt;&amp;lt;leader&amp;gt;a&lt;/code&gt; will do the same as &lt;code&gt;cw&lt;/code&gt;, but now the word (prior to the change) will be in your &quot;last search register&quot; (that is, the &lt;code&gt;/&lt;/code&gt; register), so pressing &lt;kbd&gt;n&lt;/kbd&gt; after you have made the change and returned to normal mode will get you to next occurrence.  Likewise, pressing &lt;kbd&gt;N&lt;/kbd&gt; will get you to the previous occurrence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The shortcut&lt;/strong&gt;  You can of course choose a different shortcut than &lt;code&gt;&amp;lt;leader&amp;gt;a&lt;/code&gt;, but I just find that this is a very accessible shortcut.  Personally I have set &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; to &lt;code&gt;,&lt;/code&gt; so that I just need to press &lt;kbd&gt;,&lt;/kbd&gt; followed by &lt;kbd&gt;a&lt;/kbd&gt;, but this is because I do not use an American keyboard, so that my &lt;kbd&gt;\&lt;/kbd&gt; is hidden away somewhat (I believe &lt;kbd&gt;\&lt;/kbd&gt; is the default &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;  The idea is really simple.  Yank the word under the cursor to the search register &lt;code&gt;/&lt;/code&gt; and then do &lt;code&gt;cw&lt;/code&gt;.  Thus &lt;code&gt;nmap &amp;lt;leader&amp;gt;a &quot;/yciw&lt;/code&gt; was what I was aiming for, but unfortunately I do not think that you can yank to the search register, so the workaround is to yank the word under the cursor to the &lt;code&gt;1&lt;/code&gt; register, then set the &lt;code&gt;/&lt;/code&gt; register equal to that, and then do &lt;code&gt;cw&lt;/code&gt;.  So &lt;code&gt;&quot;1yiw&lt;/code&gt; is the part that yanks the inner word under the cursor to the register &lt;code&gt;1&lt;/code&gt;.  If you do not know about inner words, you can check out &lt;code&gt;:help iw&lt;/code&gt;.  Afterwards, &lt;code&gt;:let @/=@1&lt;/code&gt; follows by a capture of &lt;kbd&gt;Enter&lt;/kbd&gt; puts the contents of the &lt;code&gt;1&lt;/code&gt; register into the &lt;code&gt;/&lt;/code&gt;.  At this point &lt;kbd&gt;n&lt;/kbd&gt; and &lt;kbd&gt;N&lt;/kbd&gt; works as next and previous occurrence of the word under the cursor, and then a &lt;code&gt;ciw&lt;/code&gt; is done so that the word under the curser is deleted and Vim is put into insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;word versus inner word&lt;/strong&gt;  I just realised that I assumed that you wanted the &lt;em&gt;entire&lt;/em&gt; word under the curser, and not just from the point of the curser and on.  This is why I used &lt;code&gt;iw&lt;/code&gt; instead of &lt;code&gt;w&lt;/code&gt; everywhere.  If this is not the case, then you should use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;a &quot;1yw:let @/=@1^Mcw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead.  If the cursor is on the first letter of the word, there is no difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;disclaimer&lt;/strong&gt;  This solution will probably not work well if you try to use it on something that contains stuff different from letters, for example by having the cursor stand on a &lt;code&gt;\&lt;/code&gt; or by replacing &lt;code&gt;iw&lt;/code&gt; by &lt;code&gt;iW&lt;/code&gt;, &lt;code&gt;ib&lt;/code&gt;, &lt;code&gt;is&lt;/code&gt; or &lt;code&gt;ip&lt;/code&gt; or something (though I do not know why you would want this feature with whole sentences)&lt;/p&gt;&#xA;" OwnerUserId="1498" LastEditorUserId="1498" LastEditDate="2016-05-12T15:49:15.420" LastActivityDate="2016-05-12T15:49:15.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7760" PostTypeId="2" ParentId="6105" CreationDate="2016-05-12T14:47:43.160" Score="5" Body="&lt;p&gt;It seems that &lt;a href=&quot;https://chocolatey.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;chocolatey&lt;/a&gt; could be the solution to your problem. It is a package manager for Windows. (With the ambition of being &amp;quot;sort of apt-get for Windows&amp;quot;)&lt;/p&gt;&#xA;&lt;p&gt;If you are ready to use it to install your softwares such as Vim it then provides a &lt;code&gt;choco upgrade &amp;lt;pkg&amp;gt;&lt;/code&gt; command to update your package.&lt;/p&gt;&#xA;&lt;p&gt;Fortunately, Vim is a package included in the list and seems to be updated pretty regularly (see the version history &lt;a href=&quot;https://chocolatey.org/packages/vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://chocolatey.org/install&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://chocolatey.org/install&lt;/a&gt; for install instructions.&lt;/p&gt;&#xA;&lt;p&gt;Then vim can be instlled with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;choco install vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and updated with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;choco upgrade vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;That is probably not as good as a good old apt-get but that could be an option.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="26758" LastEditDate="2021-08-07T21:40:06.043" LastActivityDate="2021-08-07T21:40:06.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="7761" PostTypeId="1" AcceptedAnswerId="7762" CreationDate="2016-05-12T15:19:25.573" Score="23" ViewCount="6674" Body="&lt;p&gt;I am trying to code a function that replaces the character in the sixth column of my current line with a dollar symbol (&lt;code&gt;$&lt;/code&gt;), but I would like my cursor to remain at the position it was before calling the function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I tried to store the current column, execute my changes, and then come back with the following function :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DollarSplit()&#xA;   let col_number=col(&quot;.&quot;)     &quot;stores the current column number of the cursor&#xA;   normal! 6|r$                &quot; replaces the 6th caracter in line with a $&#xA;   execute col_number.&quot;|&quot; &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am probably misunderstanding something about the &lt;code&gt;execute&lt;/code&gt; command... Or maybe I should create a string containing the command I want to be executed ? &lt;/p&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="1841" LastEditDate="2016-05-12T15:41:45.173" LastActivityDate="2019-12-22T13:00:12.270" Title="How to restore the position of the cursor after executing a normal command?" Tags="|vimscript|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7762" PostTypeId="2" ParentId="7761" CreationDate="2016-05-12T15:23:33.980" Score="31" Body="&lt;p&gt;You should use &lt;code&gt;getpos()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To save you position in a variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let save_pos = getpos(&quot;.&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;getpos()&lt;/code&gt; takes as argument a mark, here &lt;code&gt;&quot;.&quot;&lt;/code&gt; represents the current position of your cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And to restore it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setpos('.', save_pos)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the first argument indicate that you will move the mark of the current position of your cursor (hence your current position) and the second is where to put the mark (the position that you saved earlier).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your function would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DollarSplit()&#xA;   let save_pos = getpos(&quot;.&quot;)&#xA;   normal! 6|r$                &quot; replaces the 6th caracter in line with a $&#xA;   call setpos(&quot;.&quot;, save_pos)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more details see: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#getpos()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h getpos()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#setpos()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h setpos()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more details about your usage of &lt;code&gt;execute&lt;/code&gt;: this function will take a string and execute it. Your string can be only hardcoded characters between double quotes or the contents of variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you write &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute col_number.&quot;|&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are on the 12th column the expanded string will be &lt;code&gt;12|&lt;/code&gt;. Execute will try to execute this command but it won't work because &lt;code&gt;12|&lt;/code&gt; is not a vimscript function but a normal mode command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To execute it from a vimscript you have to say &quot;execute it as if I had typed it in normal mode`, that's what normal is used for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So without the execute you would have wrote:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal 12|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now to make your &lt;code&gt;execute&lt;/code&gt; call work you have to add the &lt;code&gt;normal&lt;/code&gt; keyword to your expanded string, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal &quot; . col_number . &quot;|&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-12T15:35:27.347" LastActivityDate="2016-05-12T15:35:27.347" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7763" PostTypeId="2" ParentId="7750" CreationDate="2016-05-12T15:25:55.083" Score="11" Body="&lt;p&gt;I don't know what's the best way to manage over 500 abbreviations. Maybe in the long term, as @statox explained, you could have a look at snippets to reduce this number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if you want to auto-complete abbreviations, you could try the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup GetAbbrev&#xA;    autocmd!&#xA;    autocmd VimEnter * let s:abbrev_list = [] |&#xA;                \ call substitute(join(readfile($MYVIMRC), &quot;\n&quot;), '\v%(^|\n)\s*i?%(nore)?ab%[brev]\s+%(%(\&amp;lt;expr\&amp;gt;|\&amp;lt;buffer\&amp;gt;)\s+){,2}(\k+)', '\=add(s:abbrev_list, submatch(1))', 'gn')&#xA;augroup END&#xA;&#xA;set completefunc=CompleteAbbrev&#xA;function! CompleteAbbrev(findstart, base)&#xA;    if a:findstart&#xA;        return searchpos('\&amp;lt;\k', 'bcnW', line('.'))[1] - 1&#xA;    else&#xA;        return filter(copy(s:abbrev_list), 'v:val =~ &quot;^&quot; . a:base')&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use it, you would have to hit &lt;code&gt;C-x C-u&lt;/code&gt; after the beginning of an abbreviation.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The autocmd sets up the variable &lt;code&gt;s:abbrev_list&lt;/code&gt; which should contain all your abbreviations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;CompleteAbbrev()&lt;/code&gt; should return a list of candidates based on the word before the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;'completefunc'&lt;/code&gt; option's value tells Vim which function to call when you hit &lt;code&gt;C-x C-u&lt;/code&gt;.&lt;br&gt;&#xA;Note that the option is local to the buffer, so you could still use other functions in different kind of buffers, using an autocmd and the &lt;code&gt;FileType&lt;/code&gt; event for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h complete-functions&lt;/code&gt; for more info on how the function works.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another solution would be to use synonyms completion. From &lt;code&gt;:h i_^x^t&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *i_CTRL-X_CTRL-T*&#xA;CTRL-X CTRL-T       Works as CTRL-X CTRL-K, but in a special way.  It uses&#xA;                    the 'thesaurus' option instead of 'dictionary'.  If a&#xA;                    match is found in the thesaurus file, all the&#xA;                    remaining words on the same line are included as&#xA;                    matches, even though they don't complete the word.&#xA;                    Thus a word can be completely replaced.&#xA;&#xA;                    For an example, imagine the 'thesaurus' file has a&#xA;                    line like this:&#xA;                            angry furious mad enraged&#xA;                    Placing the cursor after the letters &quot;ang&quot; and typing&#xA;                    CTRL-X CTRL-T would complete the word &quot;angry&quot;;&#xA;                    subsequent presses would change the word to &quot;furious&quot;,&#xA;                    &quot;mad&quot; etc.&#xA;                    Other uses include translation between two languages,&#xA;                    or grouping API functions by keyword.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use this solution, you would have to do 3 things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Write the &lt;code&gt;{lhs}&lt;/code&gt; of all your abbreviations inside a dedicated file.&lt;br&gt;&#xA;For example, &lt;code&gt;/home/user/mysynonyms.txt&lt;/code&gt;. And group them around similar themes.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add the path to this file to the option &lt;code&gt;'thesaurus'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set thesaurus+=/home/user/mysynonyms.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Hit &lt;code&gt;C-x C-t&lt;/code&gt; after the beginning of the name of any abbreviation inside a group.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For example, suppose you have the following abbreviations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iab cfa CFuncA&#xA;iab cfb CFuncB&#xA;iab cfc CFuncC&#xA;&#xA;iab jfa JavaFuncA&#xA;iab jfb JavaFuncB&#xA;iab jfc JavaFuncC&#xA;&#xA;iab pfa PhpFuncA&#xA;iab pfb PhpFuncB&#xA;iab pfc PhpFuncC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could group them according to the programming language they belong to.&lt;br&gt;&#xA;Inside &lt;code&gt;/home/user/mysynonyms.txt&lt;/code&gt;, you would write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cpp cfa cfb cfc&#xA;php pfa pfb pfc&#xA;java jfa jfb jfc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, whenever you hit &lt;code&gt;C-x C-t&lt;/code&gt; after the name of an abbreviation (or just its beginning), Vim should display, in the popup menu, all the abbreviations which are on the same line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how it would look:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XQovq.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XQovq.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the abbreviations don't need to begin with the same characters to be grouped, they could be entirely different. As long as they're on the same line in your synonyms file, Vim will show all of them.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you don't have to use the programming language to decide in which group put an abbreviation. You could group them according to any meaningful similarity/topic/category you have in mind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, when you forget a specific abbreviation, you could type the first letters of a category, hit &lt;code&gt;C-x C-t&lt;/code&gt; and choose the relevant one inside the menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;br&gt;&#xA;To dump all your abbreviations inside &lt;code&gt;/home/user/mysynonyms.txt&lt;/code&gt;, you could use these 3 Ex commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let abbrev_list = []&#xA;:call substitute(join(readfile($MYVIMRC), &quot;\n&quot;), '\v%(^|\n)\s*i?%(nore)?ab%[brev]\s+%(%(\&amp;lt;expr\&amp;gt;|\&amp;lt;buffer\&amp;gt;)\s+){,2}(\k+)', '\=add(abbrev_list, submatch(1))', 'gn')&#xA;:call writefile(abbrev_list, '/home/user/mysynonyms.txt')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit2:&lt;br&gt;&#xA;I've added the flag &lt;code&gt;n&lt;/code&gt; when the &lt;code&gt;substitute()&lt;/code&gt; function is called because you don't need any substitution. Its only purpose is to add an abbreviation inside a list whenever one is found.&lt;br&gt;&#xA;But because you have many abbreviations, it could make the process uselessly slow, I don't know. Initially, I didn't put it because I don't know which Vim version you're using. If your version is newer than &lt;a href=&quot;https://groups.google.com/forum/#!msg/vim_dev/Rbx48dxW8Fs/R14P09nNB8UJ&quot; rel=&quot;noreferrer&quot;&gt;7.3.627&lt;/a&gt;, it should be ok, otherwise you would have to remove the &lt;code&gt;n&lt;/code&gt; flag.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-05-12T19:04:57.727" LastActivityDate="2016-05-12T19:04:57.727" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7765" PostTypeId="2" ParentId="7754" CreationDate="2016-05-12T16:09:49.790" Score="6" Body="&lt;p&gt;To extend off of romainl as a complete workflow...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are more into performing an edit of this sort and then realize you need to apply the same edits over a paragraph/function you can use the &lt;code&gt;&quot;&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt; registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your example you can perform the initial edit of the argument. If you enter visual mode (I'd use Visual Line just to make sure you select everything correctly) and then apply a find and replace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt; - Visual Line, to end of paragraph/function.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;:&lt;/kbd&gt; - Since you're in visual mode this becomes &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt; - Find&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;&quot;&lt;/kbd&gt; - last yank/delete item (bar in the example)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;/&lt;/kbd&gt; - and Replace&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;.&lt;/kbd&gt; - last insert (baz in the example)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This pattern takes a little while to get use to since you have to use. Most of the time you'd want to just apply the find and replace to the entire function including the argument, but its a nice way to not perform the anti-pattern &quot;Do work, realize you should have done it better, undo and redo correctly.&quot;&lt;/p&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2016-05-12T16:16:27.807" LastActivityDate="2016-05-12T16:16:27.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7766" PostTypeId="2" ParentId="7705" CreationDate="2016-05-12T17:22:15.397" Score="1" Body="&lt;p&gt;Ok, I think I've figured it out. It has to do with your &quot;very magic&quot; option. You have a lookbehind: &lt;code&gt;(\.)\@&amp;lt;=&lt;/code&gt;. However, in very magic mode you are not supposed to escape the &lt;code&gt;@&lt;/code&gt; in a lookaround. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a slightly unrelated note, You have a &lt;code&gt;\s&lt;/code&gt; in your character class &lt;code&gt;[]&lt;/code&gt;. You can't use shortcuts in character classes. (@muru pointed out that what you're looking for here with this character class is &lt;code&gt;\_s&lt;/code&gt; which matches whitespace and newlines.) So the final expression I've come up with is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v(\.)@&amp;lt;=\w+\_s/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See if that works for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is my personal preference never to use the &lt;code&gt;\v&lt;/code&gt; flag for this very reason. Too many exceptions to remember. I just like to use the default regex and learn one set of rules. :P&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-05-12T22:02:12.953" LastActivityDate="2016-05-12T22:02:12.953" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7767" PostTypeId="1" AcceptedAnswerId="7772" CreationDate="2016-05-12T18:01:51.937" Score="4" ViewCount="700" Body="&lt;p&gt;I use Vim to write my Python source and use the debugging library &lt;code&gt;pdb&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say I have this code with break points commented out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import pdb&#xA;&#xA;#pdb.set_trace()&#xA;&#xA;def func1():&#xA;    #pdb.set_trace()&#xA;    foo_bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then want to globally un-comment all the &lt;code&gt;pdb.set_trace()&lt;/code&gt; commands.&#xA;Also, I'll want to re-comment them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured out how to search for the commented string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^\(\s*#\)\@!\s*pdb.set_trace() &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After this I don't know how to build a string of commands that would globally find the string and add a &lt;code&gt;#&lt;/code&gt; to the beginning of the string so as not to mess up the indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realized that I need to not re-comment lines with an existing &lt;code&gt;#&lt;/code&gt; so I&#xA;built upon the accepted answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To comment out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\s*\(#\)\@&amp;lt;!pdb.set_trace()/normal I#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7607" LastEditorUserId="7607" LastEditDate="2016-05-13T17:21:56.173" LastActivityDate="2016-05-13T17:21:56.173" Title="How do I comment out lines without changing indentation?" Tags="|vimscript|indentation|comments|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7768" PostTypeId="2" ParentId="7767" CreationDate="2016-05-12T18:10:38.163" Score="3" Body="&lt;p&gt;You should be able to do a search and replace.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(\s*\)#\(\s*pdb.set_trace()\)/\1\2/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To un-comment and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(\s*\)\(pdb.set_trace()\)/\1#\2/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To re-comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is done by using back-references. Anything matched in between memory parentheses &lt;code&gt;\(\)&lt;/code&gt; can be recalled by using a back-reference (&lt;code&gt;\1&lt;/code&gt; and &lt;code&gt;\2&lt;/code&gt; in this case). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Oh, and I kind of forgot that you said you wanted this in a script. For using this in a script just omit the first colon. :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example of using it in a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! UncommentSetTrace()&#xA;   %s/^\(\s*\)#\(\s*pdb.set_trace()\)/\1\2/&#xA;endfunction&#xA;&#xA;function! CommentSetTrace()&#xA;   %s/^\(\s*\)\(pdb.set_trace()\)/\1#\2/&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should be able to just call this function and it will comment/uncomment all instances in your current file. If you want to use a single keystroke you can map it to the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;A-c&amp;gt; :call CommentSetTrace()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This maps &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt; to comment all the instances.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-05-12T18:43:28.497" LastActivityDate="2016-05-12T18:43:28.497" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7769" PostTypeId="2" ParentId="6724" CreationDate="2016-05-12T18:29:42.513" Score="1" Body="&lt;p&gt;Oops forgot I had this question opened !&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the problem was that, with the netrw version I had (packaged with vim-gnome on Debian Jessie), modifying a file from the explorer (through ssh) would not use the correct URI (from memory, the '@' in the 'user@host' was missing).&#xA;It opened an empty file (because it didn't find anything) but it still saved the new file using the good URI (effectively overwriting the original file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@user21497's answer also helped me though because I never found that 'new file' shortcut, which is quite handy because using ':e' creates the file locally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, &lt;a href=&quot;https://stackoverflow.com/questions/9160499/go-to-back-directory-browsing-after-opening-file-in-vim&quot;&gt;this question helped me navigate better using netrw&lt;/a&gt; (getting back to the explorer after opening a file using :Ex)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help guys !&lt;/p&gt;&#xA;" OwnerUserId="6708" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-05-12T18:29:42.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7770" PostTypeId="2" ParentId="6589" CreationDate="2016-05-12T22:21:02.763" Score="3" Body="&lt;p&gt;One way to solve this would be to use &lt;code&gt;:global&lt;/code&gt; that generates a range output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typical use of the &lt;code&gt;global&lt;/code&gt; command would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]g/{pattern}/[cmd]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It also has the option of making this pattern generate a range rather than a single line match by using &lt;code&gt;,&lt;/code&gt; in the form of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]g/{first pattern}/,/{second pattern}/[cmd]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This generates a range that is applied to the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your example the first pattern would be matching the first &lt;code&gt;Hide&lt;/code&gt; entry and the second pattern is either &lt;code&gt;Hide&lt;/code&gt;, &lt;code&gt;Show&lt;/code&gt;, or the end of the file (assuming you want that last Hide case).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/Hide/,/\(Hide\|Show\|\%$\)/s/SetFontSize 28/SetFontSize 18/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first regex is simple, &lt;code&gt;/Hide/&lt;/code&gt;. The second regex contains a few interesting parts.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; creates a grouping of atoms to match&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\|&lt;/code&gt; is the OR operation&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%$&lt;/code&gt; represents the end of the file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Once we've defined our ranges, we apply substitute with a pattern and a string just like you normally would.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that the regex used in this example is very basic. You'll want to make sure that your identifiers for the beginning and end of the of the range captures the right areas.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-05-12T22:21:02.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7771" PostTypeId="2" ParentId="6993" CreationDate="2016-05-13T02:13:41.643" Score="1" Body="&lt;p&gt;Using a function, you can split the functionality of a key map. In this case, the determining factor is if a count is given to the command or not, which is stored in &lt;code&gt;v:count&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SpaceOrSpace(cnt)&#xA;  if a:cnt &amp;gt; 0&#xA;    exec &quot;normal &quot; . a:cnt . &quot;l&quot;&#xA;  else&#xA;    normal i ^[&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Space&amp;gt; :&amp;lt;C-U&amp;gt;call SpaceOrSpace(v:count)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; the &lt;code&gt;^[&lt;/code&gt; character in the script is created by pressing &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function is pretty simple. If the count is greater than zero move the cursor right as many times. Otherwise insert a space and return to normal mode.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-05-13T02:13:41.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7772" PostTypeId="2" ParentId="7767" CreationDate="2016-05-13T03:27:58.783" Score="8" Body="&lt;p&gt;Alternatively, you could use the &lt;code&gt;:g&lt;/code&gt; command. I would do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\s*#pdb.set_trace()/normal ^x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to uncomment and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\s*pdb.set_trace()/normal I#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to comment. This is nice because it's more readable (and shorter) than a search and replace command. Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\s*#pdb.set_trace()/             &quot;For every line matching this regex&#xA;                       normal       &quot;Execute the following normal mode keystrokes:&#xA;                               ^x   &quot;Go to first non-whitespace character and delete it.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The recommenting works the same, except it searches for a different string, and it uses &lt;code&gt;I#&lt;/code&gt; instead of &lt;code&gt;^x&lt;/code&gt;. &lt;code&gt;I#&lt;/code&gt; means insert &lt;code&gt;#&lt;/code&gt; at the first non-whitespace column.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-05-13T03:27:58.783" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7773" PostTypeId="1" CreationDate="2016-05-13T04:33:32.203" Score="0" ViewCount="70" Body="&lt;p&gt;I'd like to use Vim (version 7.4) to edit TeX files using the built-in, vanilla TeX mode. How do I find out about any available keybindings that are special for this mode? Does not seem to be listed in the &lt;code&gt;:help&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="7611" LastActivityDate="2016-05-13T05:35:49.957" Title="How to discover available keybindings for Vim's vanilla TeX mode?" Tags="|key-bindings|filetype-tex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7774" PostTypeId="2" ParentId="7773" CreationDate="2016-05-13T05:35:49.957" Score="2" Body="&lt;p&gt;There are none. The vanilla TeX mode (ftplugin and syntax plugin) defines syntax highlighting and sets some options. That's it. If you want any additional features, you have to create them yourself or use one of many plugins. See e.g. &lt;a href=&quot;https://vi.stackexchange.com/questions/2047/what-are-the-differences-between-latex-plugins&quot;&gt;this question&lt;/a&gt; for some information about different plugins.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-05-13T05:35:49.957" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7775" PostTypeId="1" AcceptedAnswerId="7777" CreationDate="2016-05-13T06:50:34.797" Score="2" ViewCount="347" Body="&lt;p&gt;For example, to replace current line with all lines starting with '# ' , I use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.! grep '^\# ' %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know about the &lt;code&gt;:g&lt;/code&gt; command that can filter lines to perform operations like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/call/d&#xA;:g/cat/ s/animal/mammal/g&#xA;:.,+20 g/^# / normal &amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I am not able to figure out a way to just paste the filtered lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And how to use inbuilt help in this case? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h :g&lt;/code&gt; gives an overview, how to find details on using commands like &lt;code&gt;:g/call/d&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1616" LastEditorUserId="1821" LastEditDate="2016-05-13T07:56:08.890" LastActivityDate="2016-05-13T09:42:43.987" Title="Replace current line with filtered lines" Tags="|global-command|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7776" PostTypeId="2" ParentId="7775" CreationDate="2016-05-13T07:12:39.220" Score="1" Body="&lt;p&gt;You can redirect the ex command output to any register and then paste the register's content in a line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   :redir @a&#xA;   :g/^#/p&#xA;   :redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, the lines starting with # are present in a register.&#xA;You can go to that line and press dd and then paste it using &quot;ap&#xA;The content is pasted in the line. I have taken 'a' register.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="7161" LastEditDate="2016-05-13T07:52:19.813" LastActivityDate="2016-05-13T07:52:19.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7777" PostTypeId="2" ParentId="7775" CreationDate="2016-05-13T07:52:21.120" Score="3" Body="&lt;p&gt;Here is a way to do so, it gives nearly what you want, so you may be able to build your proper solution on that.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;tl;dr&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;set a mark on the line to copy to with &lt;code&gt;ma&lt;/code&gt; and run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/C/t'a-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;decomposition&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;First of you can use the &lt;code&gt;g&lt;/code&gt; command here, it filters lines matching a pattern. Then you can use the &lt;code&gt;t&lt;/code&gt; command, which copy a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let say you have the following file (&lt;code&gt;A&lt;/code&gt; is just noise):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A&#xA;A&#xA;To replace&#xA;A&#xA;A&#xA;C 1&#xA;A&#xA;A&#xA;C 2&#xA;A&#xA;A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/C/t.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will duplicate the lines matching &lt;code&gt;C&lt;/code&gt;, because &lt;code&gt;.&lt;/code&gt; reference the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you want to duplicate the line at the current position, set a mark and use the command again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ma&#xA;:g/C/t'a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will have the following result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A&#xA;A&#xA;To replace&#xA;C 2&#xA;C 1&#xA;A&#xA;A&#xA;C 1&#xA;A&#xA;A&#xA;C 2&#xA;A&#xA;A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nearly there! You can add a &lt;code&gt;-&lt;/code&gt; to the address of the paste to achieve the paste in the correct order:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/C/t'a-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will produce:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A&#xA;A&#xA;C 1&#xA;C 2&#xA;To replace&#xA;A&#xA;A&#xA;C 1&#xA;A&#xA;A&#xA;C 2&#xA;A&#xA;A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can delete the &quot;To replace&quot; line if you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; you can use the absolute line number instead of a mark if you want, i.e. &lt;code&gt;:g/C/t12&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Regarding the help:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You already know about the &lt;code&gt;:h :g&lt;/code&gt; that gives you the information that &lt;code&gt;g&lt;/code&gt; takes an Ex command to perform action. So you might want to search for a command that copy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:copy&lt;/code&gt; exists and can be abbreviated by &lt;code&gt;:t&lt;/code&gt;. Both take an address to copy to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h {address}&lt;/code&gt; gives you want you need.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-13T09:42:43.987" LastActivityDate="2016-05-13T09:42:43.987" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7778" PostTypeId="2" ParentId="7775" CreationDate="2016-05-13T07:58:39.887" Score="2" Body="&lt;p&gt;There's &lt;code&gt;copy&lt;/code&gt;, or &lt;code&gt;t&lt;/code&gt; for short: &lt;code&gt;:g/^#/t3&lt;/code&gt; where 3 is the line you're currently on. You'd still need to delete the line itself afterwards (or before... when using &lt;code&gt;dd&lt;/code&gt; before the global call, you can use &lt;code&gt;:g/^#/t2&lt;/code&gt; to exactly have your replace). Of course, you could also define a function and bind that to a key to have it all in one step, but imho that's overkill in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking for docs, &lt;code&gt;:h global&lt;/code&gt; will tell you about the usage of &lt;code&gt;:g&lt;/code&gt;, which in turn refers to the &lt;code&gt;[cmd]&lt;/code&gt; part. You can find the ex commands with &lt;code&gt;:h ex-cmd&lt;/code&gt;. Also see &lt;a href=&quot;http://vim.wikia.com/wiki/Power_of_g&quot; rel=&quot;nofollow&quot;&gt;http://vim.wikia.com/wiki/Power_of_g&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastEditorUserId="1296" LastEditDate="2016-05-13T08:10:03.363" LastActivityDate="2016-05-13T08:10:03.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7779" PostTypeId="1" CreationDate="2016-05-13T08:06:26.843" Score="6" ViewCount="2833" Body="&lt;p&gt;In the command-line mode or in a vimscript I can use the following to duplicate a line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! Yp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now let's says that I map my leader key to do that: &lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;a Yp&lt;/code&gt;. If I use this key combination the following command will interpret litterally the characters or &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! &amp;lt;Leader&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I use a key combination including &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; in a normal command?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that other keys like &lt;code&gt;&amp;lt;Right&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;F3&amp;gt;&lt;/code&gt; doesn't work neither.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; Some side notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using &lt;code&gt;normal&lt;/code&gt; or &lt;code&gt;normal!&lt;/code&gt; doesn't seem to change something to the problem&lt;/li&gt;&#xA;&lt;li&gt;The point of the question is to be able to use &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; and not replace it by its value for two 2 reasons:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It is more portable if I use it in a script and want to distribute it.&lt;/li&gt;&#xA;&lt;li&gt;My leader is &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; so even if I replace &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; by its value I still have the same problem. (Note that I could maybe escape a space character but that is not the point of the question)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-13T08:19:39.097" LastActivityDate="2022-05-10T21:38:02.523" Title="How to use &lt;Leader&gt; in a normal command?" Tags="|vimscript|key-bindings|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7780" PostTypeId="2" ParentId="7779" CreationDate="2016-05-13T08:33:03.007" Score="7" Body="&lt;p&gt;I made up a solution to extract the leader, handle the special &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; case and execute the normal command.&lt;/p&gt;&#xA;&lt;p&gt;The space is a special case, because the &lt;code&gt;normal&lt;/code&gt; command does not accept expressions starting with a space:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:h normal&#xA;&#xA;{commands} cannot start with a space.  Put a count of&#xA;1 (one) before it, &amp;quot;1 &amp;quot; is one space.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here is the function and command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! ExecuteLeader(suffix)&#xA;  let l:leader = get(g:,&amp;quot;mapleader&amp;quot;,&amp;quot;\\&amp;quot;)&#xA;&#xA;  if l:leader == ' '&#xA;    let l:leader = '1' . l:leader&#xA;  endif&#xA;&#xA;  execute &amp;quot;normal &amp;quot;.l:leader.a:suffix&#xA;endfunction&#xA;&#xA;command! -nargs=1 NormLead call ExecuteLeader(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can use it this way:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:NormLead a&#xA;-&amp;gt; will execute `normal &amp;lt;leader&amp;gt;a`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;(Thanks @statox for the update):&#xA;If you want a one-liner command, without function, you can use the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 NormLead  let leader=get(g:,&amp;quot;mapleader&amp;quot;,&amp;quot;\\&amp;quot;) | exec &amp;quot;normal &amp;quot; . (leader==' '?&amp;quot;1&amp;quot;:leader).&amp;lt;f-args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;This is just for the leader key, but if you want to extend to any kind of key I think you need to use &lt;code&gt;execute&lt;/code&gt; anyway.&lt;/p&gt;&#xA;&lt;p&gt;In the &lt;code&gt;normal&lt;/code&gt; help:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;An alternative is to use :execute, which uses a&#xA;expression as argument.  This allows the use of&#xA;printable characters to represent special characters.&#xA;&#xA;Example:&#xA;    :exe &amp;quot;normal \&amp;lt;c-w&amp;gt;\&amp;lt;c-w&amp;gt;&amp;quot;&#xA;{not in Vi, of course}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="6498" LastEditDate="2022-05-10T21:38:02.523" LastActivityDate="2022-05-10T21:38:02.523" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7781" PostTypeId="1" AcceptedAnswerId="7783" CreationDate="2016-05-13T09:15:10.670" Score="2" ViewCount="58" Body="&lt;p&gt;When I press &lt;kbd&gt;SHIFT&lt;/kbd&gt;+&lt;kbd&gt;Ins&lt;/kbd&gt; in vim to paste text, who captures this key combination? Is it the terminal or &lt;code&gt;Vim&lt;/code&gt;? How about in &lt;code&gt;gVim&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="7366" LastEditorUserId="7366" LastEditDate="2016-05-13T09:39:17.313" LastActivityDate="2016-05-13T09:50:09.047" Title="What captures the &lt;Shift&gt;+&lt;Ins&gt; key combination?" Tags="|cut-copy-paste|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7782" PostTypeId="1" AcceptedAnswerId="7787" CreationDate="2016-05-13T09:23:40.983" Score="-2" ViewCount="119" Body="&lt;p&gt;I want to open the list of visual selection's files on new tabs such that the top-tab-bar is visible&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Wg19x.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wg19x.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mapping based on the answer &lt;a href=&quot;https://vi.stackexchange.com/a/7627/2923&quot;&gt;here&lt;/a&gt; about &lt;em&gt;How do I loop over a list of files from a visual selection?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Leader&amp;gt;gf :silent! exec &quot;!nvim &quot; shellescape('&amp;lt;cfile&amp;gt;') &amp;lt;bar&amp;gt; redraw!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where in the place of &lt;code&gt;!nvim&lt;/code&gt;, I have tried unsuccessfully &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nvim split&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;tabe&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The main point of the question is to open a list of several files formatted like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/masi/file1.txt&#xA;/Users/masi/file2.txt&#xA;/Users/masi/file3.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where you select in visual mode (&lt;code&gt;v&lt;/code&gt; and cover for instance two lines) and press &lt;code&gt;&amp;lt;Leader&amp;gt;gf&lt;/code&gt; for the activation of the command which will open all the selected files in new tabs.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;My Applicable .vimrc after statox and nobe4's answers&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I think semantics can confuse them. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot; Mapleader is space now from \ &#xA;let mapleader=&quot; &quot; &#xA;&quot;&quot; Quick tabs - Go to tab by number &#xA;noremap &amp;lt;leader&amp;gt;1 1gt &#xA;noremap &amp;lt;leader&amp;gt;2 2gt &#xA;noremap &amp;lt;leader&amp;gt;3 3gt &#xA;noremap &amp;lt;leader&amp;gt;4 4gt &#xA;noremap &amp;lt;leader&amp;gt;5 5gt &#xA;noremap &amp;lt;leader&amp;gt;6 6gt &#xA;noremap &amp;lt;leader&amp;gt;7 7gt &#xA;noremap &amp;lt;leader&amp;gt;8 8gt &#xA;noremap &amp;lt;leader&amp;gt;9 9gt &#xA;noremap &amp;lt;leader&amp;gt;0 :tablast&amp;lt;CR&amp;gt; &#xA;&quot;&quot; Go to last active tab &#xA;au TabLeave * let g:lasttab = tabpagenr() &#xA;nnoremap &amp;lt;C-Left&amp;gt; :tabprevious&amp;lt;CR&amp;gt; &#xA;nnoremap &amp;lt;C-Right&amp;gt; :tabnext&amp;lt;CR&amp;gt;      &#xA;&#xA;&quot;&quot; https://vi.stackexchange.com/a/7787/2923 &#xA;function! OpenSelectionAsTabs() range &#xA;    let tabnr = tabpagenr() &#xA;    for line in range(a:firstline, a:lastline) &#xA;        &quot;&quot; to allow whitespaces in names https://vi.stackexchange.com/a/7865/2923&#xA;        execute &quot;tabedit &quot; . fnameescape(getline(line))&#xA;        execute &quot;tabp&quot; &#xA;    endfor &#xA;endfunction &#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;gf :'&amp;lt;,'&amp;gt;call OpenSelectionAsTabs()&amp;lt;CR&amp;gt; &#xA;vnoremap &amp;lt;leader&amp;gt;gf :call OpenSelectionAsTabs()&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;How can you open a list of files into tabs with Tab-top-bar?&lt;/p&gt;&#xA;" OwnerUserId="2923" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-09-27T18:56:06.187" Title="How to open a list of files into tabs with Tab-top-bar?" Tags="|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7783" PostTypeId="2" ParentId="7781" CreationDate="2016-05-13T09:50:09.047" Score="3" Body="&lt;p&gt;You can read from &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/os_dos.html#&amp;lt;S-Insert&amp;gt;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h &amp;lt;S-Insert&amp;gt;&lt;/code&gt;&lt;/a&gt; that the key combination &lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;insert&lt;/kbd&gt; is a Vim mapping. That explain why it allows to past text in terminal Vim but also in gVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now about the terminal, it really depends on your system: some terminal are configured to handle this mapping and some other are not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you can see &lt;a href=&quot;https://askubuntu.com/a/402491/408927&quot;&gt;this question&lt;/a&gt; where a tool is needed to make gnome-terminal handle the mapping.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.647" LastActivityDate="2016-05-13T09:50:09.047" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7784" PostTypeId="1" AcceptedAnswerId="7785" CreationDate="2016-05-13T09:53:31.253" Score="4" ViewCount="4278" Body="&lt;p&gt;I have seen &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt; being used in Insert Mode in &lt;a href=&quot;http://vimgolf.com/challenges/57343555fd77ad227900df4a&quot; rel=&quot;nofollow&quot;&gt;a VimGolf challenge&lt;/a&gt;. In this scenario it inserts the text that was last typed and switches to Normal Mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I wonder if this is the real purpose of this binding or just a side effect, so I tried to find information on what it does but found nothing on &lt;code&gt;:help&lt;/code&gt; or Google.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the question is: Where can I find documentation about &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5036" LastEditorUserId="1841" LastEditDate="2016-05-13T10:00:12.890" LastActivityDate="2016-05-13T10:01:26.513" Title="What does &lt;C-@&gt; do?" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="1" ClosedDate="2016-05-13T14:00:52.193" ContentLicense="CC BY-SA 3.0" />
  <row Id="7785" PostTypeId="2" ParentId="7784" CreationDate="2016-05-13T09:54:56.970" Score="13" Body="&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-@&quot;&gt;&lt;code&gt;:h i_CTRL-@&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;CTRL-@        Insert previously inserted text and stop insert.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Also the mappings existing in insert mode are referenced in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html&quot;&gt;&lt;code&gt;:h insert.txt&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-13T10:01:26.513" LastActivityDate="2016-05-13T10:01:26.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7786" PostTypeId="2" ParentId="7767" CreationDate="2016-05-13T12:29:48.080" Score="5" Body="&lt;p&gt;There is a solution which can be pretty simple if you are willing to use a plugin: &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDCommenter&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin is made for &quot;intensely orgasmic commenting&quot; according to their github page. More precisely it creates several mappings to handle comments and one of the mappings is &lt;code&gt;&amp;lt;Leader&amp;gt;ci&lt;/code&gt; which allows to toggle the comments of a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Combined to a global command it allows you do to what you can. Let's say your leader is &lt;code&gt;,&lt;/code&gt; is can use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/pdb.set_trace()/normal ,ci&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that will toggle the comments on the lines matching &lt;code&gt;pdb.set_trace()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you cannot easily use &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;directly in the normal command (see &lt;a href=&quot;https://vi.stackexchange.com/q/7779/1841&quot;&gt;my question about that&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your leader is &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; you'll have to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/pdb.Set_trace()/normal 1 ci&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that it is easy to map it to a key:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :g/pdb.set_trace()/normal ,ci&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And finally the big advantage of this method is that NERDcommenter handles automatically the language you are editing so you can create a command which will togle the comments on lines matching a defined pattern no matter what language you're editing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 ToggleCom :execute &quot;g/&quot; . &amp;lt;f-args&amp;gt; . &quot;/normal ,ci&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now no matter which language you're editing you can use &lt;code&gt;:ToogleCom foo&lt;/code&gt; to toggle the comment of all the lines matching &lt;code&gt;foo&lt;/code&gt;. (If your leader is not &lt;code&gt;,&lt;/code&gt; see the previous paragraph of my answer)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need different commenting styles you can change the mapping used, see &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter/blob/master/doc/NERD_commenter.txt#L81&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h NERDComFunctionalitySummary&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-05-13T13:32:56.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7787" PostTypeId="2" ParentId="7782" CreationDate="2016-05-13T13:01:02.317" Score="6" Body="&lt;p&gt;If you want to open the file under your cursor in a new tab your mapping would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;gf :silent! execute &quot;tabe &quot; . expand('&amp;lt;cfile&amp;gt;') &amp;lt;bar&amp;gt; redraw!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your mapping didn't work because &lt;code&gt;shellescape&lt;/code&gt; only escapes some characters in the string it get as arguments, what you need is &lt;code&gt;expand&lt;/code&gt; to convert &lt;code&gt;&amp;lt;cfile&amp;gt;&lt;/code&gt; to its value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then to customize the appearance of the tabline you can see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/tabpage.html#setting-tabline&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h setting-tabline&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a function and a mapping to answer your update:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! OpenSelectionAsTabs() range&#xA;    let tabnr = tabpagenr()&#xA;    for line in range(a:firstline, a:lastline)&#xA;        execute &quot;tabedit &quot; . getline(line)&#xA;        execute &quot;tabp&quot;&#xA;    endfor&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;gf :'&amp;lt;,'&amp;gt;call OpenSelectionAsTabs()&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;leader&amp;gt;gf :call OpenSelectionAsTabs()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now in visual and in normal mode &lt;code&gt;&amp;lt;leader&amp;gt;gf&lt;/code&gt; will take the file visually selected and open them in new tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the result of the command: (my leader is &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt;, so the trigger of the command is &lt;code&gt;&amp;lt;space&amp;gt;gf&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vwWcC.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vwWcC.gif&quot; alt=&quot;Execution of the command&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Follow up of &lt;a href=&quot;https://vi.stackexchange.com/q/7864/1841&quot;&gt;this question&lt;/a&gt;: The function I created will fail if the path contains whitespaces. (Since Vim will consider the part after the space as a parameter of the command)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So as @Nobe4 said in his answer you'll need to replace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;tabedit &quot; . getline(line)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;tabedit &quot; . fnameescape(getline(line))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-05-19T11:57:01.917" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7788" PostTypeId="1" CreationDate="2016-05-13T16:06:37.013" Score="1" ViewCount="3315" Body="&lt;p&gt;I want to turn VIM into my Python 3 development environment. What is the best .vimrc configuration and what are good Plug-ins for the job?&lt;/p&gt;&#xA;" OwnerUserId="7618" LastEditorUserId="5465" LastEditDate="2016-05-14T14:42:52.227" LastActivityDate="2016-05-14T14:42:52.227" Title="Vim setup for Python 3" Tags="|vimrc|ide|" AnswerCount="0" CommentCount="6" ClosedDate="2016-05-13T22:48:38.413" ContentLicense="CC BY-SA 3.0" />
  <row Id="7790" PostTypeId="1" CreationDate="2016-05-13T17:31:48.887" Score="1" ViewCount="268" Body="&lt;p&gt;I try to write a function to toggle my mappings in &lt;strong&gt;Vim script&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the steps I have tested it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I load my vim. (open a file)&lt;/li&gt;&#xA;&lt;li&gt;Check my mapping in command mode with :imap and I can see mapping(etc. i ffff ...)&lt;/li&gt;&#xA;&lt;li&gt;I press F6 to toggle the function&lt;/li&gt;&#xA;&lt;li&gt;I got error message: &lt;strong&gt;No such mapping&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;I check my mapping in command mode with :imap again and I see the mapping(i ffff ...)&lt;/li&gt;&#xA;&lt;li&gt;In command mode, I can use iunmpa  ffff to unmap the ffff&#xA;&lt;strong&gt;:iunmap  ffff&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;The mapping is gone.(I can check with :imap)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Does anyone get any idea why &lt;strong&gt;iunmap&lt;/strong&gt; is not working inside my Vim script?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F6&amp;gt;    :call ToggleBracketGroup()&amp;lt;CR&amp;gt;&#xA;let g:bracketmap = 1&#xA;function! ToggleBracketGroup()&#xA;    if g:bracketmap == 1&#xA;        inoremap &amp;lt;buffer&amp;gt; ffff    print(&quot;cool&quot;)&#xA;        let g:bracketmap = 0&#xA;    else&#xA;        **iunmap &amp;lt;buffer&amp;gt; ffff**&#xA;        let g:bracketmap = 1&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7597" LastActivityDate="2016-07-12T21:28:38.450" Title="iunmap is not working inside my Vim script" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7793" PostTypeId="2" ParentId="7790" CreationDate="2016-05-13T21:05:39.063" Score="1" Body="&lt;p&gt;The issue with above code is there is &lt;strong&gt;space&lt;/strong&gt; after ffff, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to remove the space after ffff and it works perfectly&lt;/p&gt;&#xA;" OwnerUserId="7597" LastActivityDate="2016-05-13T21:05:39.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7794" PostTypeId="2" ParentId="5309" CreationDate="2016-05-13T21:43:51.973" Score="3" Body="&lt;p&gt;After a hint to use &lt;code&gt;getcmdpos()&lt;/code&gt;, i have ended up with the mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;C-d&amp;gt; (getcmdpos()==len(getcmdline())+1?'&amp;lt;C-d&amp;gt;':'&amp;lt;Del&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1248" LastActivityDate="2016-05-13T21:43:51.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7795" PostTypeId="1" AcceptedAnswerId="7796" CreationDate="2016-05-14T00:45:03.763" Score="5" ViewCount="362" Body="&lt;p&gt;Is there a way to make a function in vim that takes the difference between two time stamps under highlight?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 20:37:00 &#xA;2 20:42:30&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Supposing you highlight lines &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;2&lt;/code&gt; and run the command, say, &lt;code&gt;:TimeDifference&lt;/code&gt;, you get the output &lt;code&gt;5.5&lt;/code&gt; (i.e., &lt;code&gt;5.5&lt;/code&gt; minutes) which replaces lines &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;2&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6499" LastActivityDate="2019-10-10T00:36:24.123" Title="Diffing two time stamps under selection" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7796" PostTypeId="2" ParentId="7795" CreationDate="2016-05-14T02:12:05.963" Score="6" Body="&lt;p&gt;You could try the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; line1 is the line number the first timestamp is on.&#xA;&quot; line2 is the line number the second timestamp is on.&#xA;function! GetTimeDifference(line1,line2)&#xA;    &quot; Get line content and split it where &quot;:&quot; matches.&#xA;    let l:t1List = split( getline(a:line1), &quot;:&quot; )&#xA;    let l:t2List = split( getline(a:line2), &quot;:&quot; )&#xA;&#xA;    &quot; Get the difference in minutes between the timestamps.&#xA;    let l:difference = abs(  (l:t1List[0] * 3600 + l:t1List[1] * 60 + l:t1List[2]) - &#xA;                           \ (l:t2List[0] * 3600 + l:t2List[1] * 60 + l:t2List[2])   ) / 60.0&#xA;&#xA;    &quot; Replace the line with the result.&#xA;   call setline(a:line1, printf(&quot;%.1f&quot; ,l:difference))&#xA;&#xA;    &quot; Delete the other one.&#xA;    execute a:line2 . &quot;delete&quot;&#xA;endfunction&#xA;&#xA;&quot; Create a user-defined command.&#xA;command! -range TimeDifference :call GetTimeDifference(&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6698" LastActivityDate="2016-05-14T02:12:05.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7797" PostTypeId="2" ParentId="5647" CreationDate="2016-05-14T07:47:50.373" Score="3" Body="&lt;p&gt;I'm not sure this is what you want but you could try this mapping using the &lt;code&gt;&amp;lt;F7&amp;gt;&lt;/code&gt; key:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F7&amp;gt; :&amp;lt;C-U&amp;gt;sil! exe '!' . matchstr(getline(1), '#!\zs.*') . ' ' . shellescape(expand('%:p'), 1) &amp;lt;Bar&amp;gt; redraw!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;matchstr(getline(1), '#!\zs.*')&lt;/code&gt; extract the text after the shebang&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;shellescape(expand('%:p'), 1)&lt;/code&gt; expand the full path to the current file and protect characters that may have a special meaning for the shell; the second non-nul argument is useful to escape special items such as &lt;code&gt;!&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt;, &lt;code&gt;#&lt;/code&gt; which could be expanded by Vim on the command-line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want to see the output in the shell, you could remove &lt;code&gt;:sil!&lt;/code&gt; and &lt;code&gt;:redraw!&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F7&amp;gt; :&amp;lt;C-U&amp;gt;exe '!' matchstr(getline(1), '^#!\zs.*') shellescape(expand('%:p'), 1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-05-14T08:10:24.853" LastActivityDate="2016-05-14T08:10:24.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7798" PostTypeId="1" AcceptedAnswerId="7802" CreationDate="2016-05-14T08:23:07.120" Score="2" ViewCount="59" Body="&lt;p&gt;I just discovered that I am able to use &lt;code&gt;${ENVVAR}more_text&lt;/code&gt; in a vim installation on Unix, but not if installed on Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Unix, I did in a shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export ABC=/tmp/&#xA;echo foo&amp;gt;${ABC}foo&#xA;gvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, in the newly opened gvim Window, I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e ${ABC}foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which opened &lt;code&gt;/tmp/foo&lt;/code&gt;, as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Windows, however, I did (&lt;code&gt;cmd.exe&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ABC=c:\temp\&#xA;echo foo &amp;gt; %ABC%foo&#xA;gvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then, in gvim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e ${ABC}foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which opened a (non existing) file literally named &lt;code&gt;${ABC}foo&lt;/code&gt; (which is not what I expected).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to have vim expand the expression &lt;code&gt;${ABC}&lt;/code&gt; on Windows as well, or an equipotent alternative?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize, that for this &lt;em&gt;simple&lt;/em&gt; example, I could define the environment variable without trailing slash and add the slash in the &lt;code&gt;:e&lt;/code&gt; command while not using the braces at all. Yet, I want to achieve something more complex than that so that I fell I sort of need the &lt;code&gt;${ABC}&lt;/code&gt; construct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per &lt;em&gt;muru&lt;/em&gt;s comment: in Windows, after starting gvim, if I do &lt;code&gt;echo $ABC&lt;/code&gt;, gvim prints &lt;code&gt;c:\temp\&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="51" LastEditDate="2016-06-10T22:44:20.713" LastActivityDate="2016-06-10T22:44:20.713" Title="Is there a platform independent way to use &quot;${ENVVAR}more_text&quot; in vim?" Tags="|microsoft-windows|unix|environment-variables|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7799" PostTypeId="1" CreationDate="2016-05-14T10:22:17.697" Score="1" ViewCount="586" Body="&lt;p&gt;After trying out many auto-completion engines for Vim, NeoComplete combined with Jedi seems like a good choice for python development. However, I can't get it to use external libraries like PySide (Qt bindings for python). Is there anyway to give NeoComplete/Jedi the location of these libraries so they can cache them?&lt;/p&gt;&#xA;" OwnerUserId="7563" LastActivityDate="2016-05-14T10:22:17.697" Title="How to use external python modules with NeoComplete?" Tags="|autocompletion|filetype-python|plugin-jedi-vim|plugin-neocomplete|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7800" PostTypeId="1" AcceptedAnswerId="7801" CreationDate="2016-05-14T10:26:40.923" Score="2" ViewCount="191" Body="&lt;p&gt;I have a strange problem with completion and my cursor movement redefinitions and the excellent &lt;a href=&quot;https://github.com/davidhalter/jedi-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;jedi-vim&lt;/code&gt; plugin&lt;/a&gt; with &lt;code&gt;supertab&lt;/code&gt;. I have in my &lt;code&gt;.vimrc&lt;/code&gt; these maps for vertical movement in visual lines: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Visual movement with the arrows and End-Home &#xA;nnoremap &amp;lt;Down&amp;gt; gj&#xA;nnoremap &amp;lt;Up&amp;gt; gk&#xA;vnoremap &amp;lt;Down&amp;gt; gj&#xA;vnoremap &amp;lt;Up&amp;gt; gk&#xA;&quot;&#xA;&quot; these create problems with completions...&#xA;&quot;&#xA;inoremap &amp;lt;Down&amp;gt; &amp;lt;C-o&amp;gt;gj&#xA;inoremap &amp;lt;Up&amp;gt; &amp;lt;C-o&amp;gt;gk&#xA;inoremap &amp;lt;Home&amp;gt; &amp;lt;C-o&amp;gt;g&amp;lt;Home&amp;gt;&#xA;inoremap &amp;lt;End&amp;gt;  &amp;lt;C-o&amp;gt;g&amp;lt;End&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and the second group is almost always ok, but it creates problems with completions &lt;em&gt;only&lt;/em&gt; in python files, using &lt;code&gt;jed-vim&lt;/code&gt;. The effect is that if I have the expansion suggestions on: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JQxss.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JQxss.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and press one of the up/down arrow keys I have the literal &quot;gj&quot; added: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1ePVc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1ePVc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...but this thing does not happen for example with &lt;code&gt;latex&lt;/code&gt; completions: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5PAMP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5PAMP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;which is ok after a &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt; selection (although with a &quot;bip&quot; which is suspicious...). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is: it is possible to have the aforementioned &lt;code&gt;inoremap&lt;/code&gt; definition in normal insert mode, but automatically removed/ignored when in &lt;code&gt;supertab&lt;/code&gt; completion mode? &lt;/p&gt;&#xA;" OwnerUserId="854" LastActivityDate="2016-05-14T10:49:27.717" Title="Imaps automatically removed when in &quot;completion mode&quot;?" Tags="|key-bindings|plugin-jedi-vim|plugin-supertab|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7801" PostTypeId="2" ParentId="7800" CreationDate="2016-05-14T10:49:27.717" Score="3" Body="&lt;p&gt;I don't use your plugins so I can't be entirely sure it will fix your issue, but it seems you want mappings in insert mode which behave differently depending on whether the popup menu is visible or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;code&gt;pumvisible()&lt;/code&gt; function to test if the popup menu is visible, it returns 0 when it's not, 1 otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can build an expression with the ternary operator &lt;code&gt;?:&lt;/code&gt; (see &lt;code&gt;:h expr1&lt;/code&gt; for more info) to return a different string depending on the state of the popup menu. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pumvisible() ? '&amp;lt;C-N&amp;gt;' : '&amp;lt;C-O&amp;gt;gj'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This expression returns the string &lt;code&gt;'&amp;lt;C-N&amp;gt;'&lt;/code&gt; when the popup menu is visible (which contains a key you can hit to select the next item in the menu), or &lt;code&gt;'&amp;lt;C-O&amp;gt;gj'&lt;/code&gt; (which contains a key you can hit to go down one line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you need to tell your mapping that it must not type the &lt;code&gt;{rhs}&lt;/code&gt; directly but first evaluate it as an expression. To do so, you can pass to &lt;code&gt;:inoremap&lt;/code&gt; the argument &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It could give something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;Down&amp;gt; pumvisible() ? '&amp;lt;C-N&amp;gt;' : '&amp;lt;C-O&amp;gt;gj'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And something similar for &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;Up&amp;gt; pumvisible() ? '&amp;lt;C-P&amp;gt;' : '&amp;lt;C-O&amp;gt;gk'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-05-14T10:49:27.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7802" PostTypeId="2" ParentId="7798" CreationDate="2016-05-14T11:20:04.783" Score="3" Body="&lt;p&gt;I tried to use backtick expansion, but that does not seem to be working on Windows. So I think the easiest solution is something like this:&#xA;&lt;code&gt;:exe &quot;:e&quot; $ABC.&quot;foobar.txt&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2016-05-14T11:35:45.427" LastActivityDate="2016-05-14T11:35:45.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7803" PostTypeId="1" AcceptedAnswerId="16098" CreationDate="2016-05-14T15:47:53.877" Score="3" ViewCount="1613" Body="&lt;p&gt;I am trying to come up with a way to handle C++ projects with Vim. I have sorted out syntax and code completion etc. to some extend. Now, I am curios to hear about how people handle their Build &gt; Make &gt; Run cycles for their projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have so far:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) For the &lt;code&gt;build&lt;/code&gt; stage I use CMake. I am invoking CMake either from a terminal open just under my Vim window or through Vim using the &lt;code&gt;vim-dispatch&lt;/code&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By doing something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:Dispatch 'cd {my_project_dir}; rm -rf ./build/*; cd ./build; cmake ..'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This runs cmake and prepares the &lt;code&gt;make&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) For the &lt;code&gt;make&lt;/code&gt; stage, I am setting the &lt;code&gt;makeprg&lt;/code&gt; option of Vim for my current project and I am executing it with vim-dispatch using the &lt;code&gt;:Make&lt;/code&gt; wrapper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;makeprg=cd {my_project_dir}/build &amp;amp;&amp;amp; make&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This compiles the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) The final stage is running the compiled binary. For that I am using vim-dispatch as well. The run call looks like that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:Dispatch {my_project_dir}/build/bin/myproject&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All these stages seem to be working ok, what I am missing is an error check between those. Ideally, I would like to stop at stage (2) and not run the binary (which would be outdated) if the &lt;code&gt;make&lt;/code&gt; stage fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the best way to solve this problem? Is there some kind of an access to the exit codes for each of these stages?&lt;/p&gt;&#xA;" OwnerUserId="5328" LastActivityDate="2018-05-01T04:43:42.660" Title="How to set up a Build &gt; Make &gt; Run cycle for a C++ project?" Tags="|ide|makeprg|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7805" PostTypeId="2" ParentId="6019" CreationDate="2016-05-15T09:34:19.643" Score="3" Body="&lt;p&gt;I've taken the liberty to build on both @romainl and @LucHermite's answers. I define the &lt;code&gt;Stacktrace&lt;/code&gt; function, which can be called both manually and to get a trace for a specific error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction(...)&#xA;  &quot; Stacktrace can be called to get a manual stacktrace&#xA;  call Stacktrace()&#xA;&#xA;  &quot; It can also be called to get stacktrace for an error&#xA;  try&#xA;    &quot; ...&#xA;  catch&#xA;    call Stacktrace()&#xA;  endtry&#xA;endfunction&#xA;&#xA;function! Stacktrace()&#xA;  &quot;&#xA;  &quot; Get stack and exception&#xA;  &quot;&#xA;  if empty(v:throwpoint)&#xA;    try&#xA;      throw 'dummy'&#xA;    catch&#xA;      let l:stack = reverse(split(v:throwpoint, '\.\.'))[1:]&#xA;      let l:exception = 'Manual stacktrace'&#xA;    endtry&#xA;  else&#xA;    let l:stack = reverse(split(v:throwpoint, '\.\.'))&#xA;    let l:exception = v:exception&#xA;  endif&#xA;&#xA;  &quot;&#xA;  &quot; Build the quickfix entries&#xA;  &quot;&#xA;  let l:qflist = []&#xA;  let l:files = {}&#xA;  for l:func in l:stack&#xA;    let [l:name, l:offset] = (l:func =~# '\S\+\[\d')&#xA;          \ ? matchlist(l:func, '\(\S\+\)\[\(\d\+\)\]')[1:2]&#xA;          \ : matchlist(l:func, '\(\S\+\), line \(\d\+\)')[1:2]&#xA;&#xA;    if l:name =~# '\v(\&amp;lt;SNR\&amp;gt;|^)\d+_'&#xA;      let l:sid = matchstr(l:name, '\v(\&amp;lt;SNR\&amp;gt;|^)\zs\d+\ze_')&#xA;      let l:name  = substitute(l:name, '\v(\&amp;lt;SNR\&amp;gt;|^)\d+_', 's:', '')&#xA;      let l:filename = map(&#xA;            \ Command('scriptnames'),&#xA;            \ 'split(v:val, &quot;\\v:=\\s+&quot;)[1]')[l:sid-1]&#xA;    else&#xA;      let l:name = l:name&#xA;      let l:filename = matchstr(&#xA;            \ Command('verbose function ' . l:name)[1],&#xA;            \ '.\{-}\s\+\zs\f\+$')&#xA;    endif&#xA;&#xA;    let l:filename = fnamemodify(l:filename, ':p')&#xA;    if filereadable(l:filename)&#xA;      if !has_key(l:files, l:filename)&#xA;        let l:files[l:filename] = reverse(readfile(l:filename))&#xA;      endif&#xA;&#xA;      let l:lnum = l:offset + len(l:files[l:filename])&#xA;            \ - match(l:files[l:filename], '^\s*fu\%[nction]!\=\s\+' . l:name)&#xA;      let l:text = len(l:qflist) == 0 ? l:exception : '#' . len(l:qflist)&#xA;&#xA;      call add(l:qflist, {&#xA;            \ 'filename': l:filename,&#xA;            \ 'lnum': l:lnum,&#xA;            \ 'text': l:text,&#xA;            \})&#xA;    endif&#xA;  endfor&#xA;&#xA;  call setqflist(l:qflist)&#xA;  execute 'copen' len(l:qflist) + 2&#xA;  wincmd p&#xA;endfunction&#xA;&#xA;function! Command(cmd)&#xA;  let l:a = @a&#xA;  try&#xA;    silent! redir @a&#xA;    silent! execute a:cmd&#xA;    redir END&#xA;  finally&#xA;    let l:res = @a&#xA;    let @a = l:a&#xA;    return split(l:res, &quot;\n&quot;)&#xA;  endtry&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-05-15T09:34:19.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7806" PostTypeId="2" ParentId="5907" CreationDate="2016-05-15T15:41:44.847" Score="3" Body="&lt;p&gt;&lt;code&gt;vi&lt;/code&gt; was designed for use with &lt;a href=&quot;https://en.wikipedia.org/wiki/Computer_terminal#Early_VDUs&quot; rel=&quot;nofollow noreferrer&quot;&gt;glass terminals&lt;/a&gt;, the &lt;a href=&quot;https://unix.stackexchange.com/questions/5800/what-protocol-standard-is-used-by-terminals/5802#5802&quot;&gt;protocols of which&lt;/a&gt; often use many of the control-&lt;i&gt;x&lt;/i&gt; commands down at &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII#ASCII_control_code_chart&quot; rel=&quot;nofollow noreferrer&quot;&gt;the low end of ASCII&lt;/a&gt;. Others were reassigned in the move from paper terminals, such as &lt;kbd&gt;Ctrl-L&lt;/kbd&gt; (form feed), which &lt;code&gt;vi&lt;/code&gt; reinterprets from &quot;form feed&quot; to mean &quot;repaint display&quot; instead, that being more appropriate to a text editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Commands like &quot;jump to tag&quot; — &lt;kbd&gt;Ctrl-]&lt;/kbd&gt; — need to be usable in insert mode as well as command mode, so it couldn't use one of the printable ASCII characters. ASCII defines only 32 non-printable characters. Of those left, &lt;kbd&gt;Ctrl-]&lt;/kbd&gt; apparently seemed like the best choice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These standards go back something like 15 years before &lt;code&gt;vi&lt;/code&gt; was created, so &lt;code&gt;vi&lt;/code&gt; had to play within the existing landscape. You can imagine that all the good ones were taken by the time &lt;code&gt;vi&lt;/code&gt; came on the scene.&lt;/p&gt;&#xA;" OwnerUserId="6852" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2016-05-15T15:41:44.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7808" PostTypeId="2" ParentId="5157" CreationDate="2016-05-15T20:06:18.680" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;is Vim minimal (i.e. the default vi on Cygwin) basically a POSIX compliant implementation of vi?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. The &lt;code&gt;vi&lt;/code&gt; in Cygwin's &lt;code&gt;vim-minimal&lt;/code&gt; package still has features not &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html&quot; rel=&quot;nofollow&quot;&gt;defined by POSIX&lt;/a&gt;. I've verified the availability of &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html&quot; rel=&quot;nofollow&quot;&gt;visual mode&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html&quot; rel=&quot;nofollow&quot;&gt;windowing&lt;/a&gt; support, for example.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What other common 'minimal' vi's exist?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;BSD's &lt;a href=&quot;https://sites.google.com/a/bostic.com/keithbostic/vi/&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;nvi&lt;/code&gt;&lt;/a&gt; is pretty minimal, though it has some features not present in Cygwin's &lt;code&gt;vim-minimal&lt;/code&gt;, such as multiple undo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you're looking for a true throwback, I suggest that you look at &lt;a href=&quot;http://ex-vi.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;Heirloom &lt;code&gt;vi&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a comprehensive list of how Vim enhances on vi?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. See the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/vi_diff.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;vi_diff&lt;/code&gt; section&lt;/a&gt; of the user manual. It's also available in the online help via &lt;code&gt;:help vi_diff&lt;/code&gt;, though ironically the online help isn't included in Cygwin's &lt;code&gt;vim-minimal&lt;/code&gt; package.&lt;/p&gt;&#xA;" OwnerUserId="6852" LastActivityDate="2016-05-15T20:06:18.680" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7809" PostTypeId="1" AcceptedAnswerId="7814" CreationDate="2016-05-15T23:08:05.413" Score="1" ViewCount="2218" Body="&lt;p&gt;I am trying to write simple function which runs a shell command and prints the result into vims shell output window, this here is a basic version of the function which does work:&lt;br&gt;&#xA;function defined in &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Runphp()&#xA;    let s:runphp='cat /tmp/php_snippet | php'&#xA;    echo(system(s:runphp))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;file /tmp/php_snippet&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;$a = ['apple', 'orange', 'bannana', 'pear'];&#xA;print_r($a);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I run &lt;code&gt;:call Runphp()&lt;/code&gt; vim prints the result of the executed PHP in the result window, all good.&lt;br&gt;&#xA;The problem occurs where the &lt;code&gt;&amp;lt;?php&lt;/code&gt; tag doesn't already exist in &lt;code&gt;/tmp/php_snippet&lt;/code&gt; i.e.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;file /tmp/php_snippet looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$a = ['apple', 'orange', 'bannana', 'pear'];&#xA;print_r($a);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I try to inject &lt;code&gt;&amp;lt;?php&lt;/code&gt; as part of the shell command, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Runphp()&#xA;    let s:runphp='{ echo &quot;&amp;lt;?php&quot;; cat /tmp/php_snippet } | php'&#xA;    echo(system(s:runphp))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I &lt;code&gt;:call Runphp()&lt;/code&gt; now, vim returns&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Error detected while processing function Runphp:&lt;br&gt;&#xA;  line    3:&lt;br&gt;&#xA;  E484: Can't open file /tmp/vReTqKG/9&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How can I deal with this error so I can get this extra &lt;code&gt;&amp;lt;?php&lt;/code&gt; injected into the shell command?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2016-05-16T22:55:16.990" Title="Working with shell command strings in vim's system() function" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7810" PostTypeId="2" ParentId="6784" CreationDate="2016-05-16T15:38:20.037" Score="5" Body="&lt;h3&gt;&lt;a href=&quot;https://github.com/tpope/vim-eunuch&quot; rel=&quot;noreferrer&quot;&gt;tpope/vim-eunuch&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Like you've discussed, &lt;code&gt;$SUDO_COMMAND&lt;/code&gt; can be used to find the original filename(s). Together with a nifty usage of &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#fnameescape()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;fnameescape&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#:doautocmd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;doautocmd&lt;/code&gt;&lt;/a&gt; it is possible to deduce the correct filetype. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what &lt;strong&gt;&lt;a href=&quot;https://github.com/tpope/vim-eunuch&quot; rel=&quot;noreferrer&quot;&gt;tpope/vim-eunuch&lt;/a&gt;&lt;/strong&gt; does:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-eunuch/commit/4087a5463ff1d9e779dace6fddbdad10e072c1ea&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/tpope/vim-eunuch/commit/4087a5463ff1d9e779dace6fddbdad10e072c1ea&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If filetype detection is all you want, it should be possible to transform it to something that could be included in a vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Sudo environment variables&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Since sudo 1.8.13 however, the environment variables used by &lt;code&gt;sudo&lt;/code&gt; or &lt;code&gt;sudoedit&lt;/code&gt; are no longer exposed or available in vim like they used to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://bugzilla.sudo.ws/show_bug.cgi?id=688&quot; rel=&quot;noreferrer&quot;&gt;https://bugzilla.sudo.ws/show_bug.cgi?id=688&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sudoedit /etc/apache2/apache2.conf&#xA;:if !exists(&quot;$SUDO_COMMAND&quot;) | echo &quot;undefined&quot; | endif&#xA;undefined&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To restore &lt;code&gt;$SUDO_COMMAND&lt;/code&gt; one can use a wrapper function with an inline environment variable instead:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;bash:&lt;/strong&gt; (&lt;a href=&quot;https://github.com/tpope/vim-eunuch/issues/31&quot; rel=&quot;noreferrer&quot;&gt;source&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function sudoedit() {&#xA;    SUDO_COMMAND=&quot;sudoedit $@&quot; command sudoedit &quot;$@&quot;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;fish:&lt;/strong&gt; (&lt;a href=&quot;https://github.com/timss/dotfiles/blob/master/.config/fish/functions/sudoedit.fish&quot; rel=&quot;noreferrer&quot;&gt;source&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function sudoedit&#xA;    set -lx SUDO_COMMAND &quot;sudoedit $argv&quot;;&#xA;    command sudoedit $argv;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5070" LastActivityDate="2016-05-16T15:38:20.037" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7811" PostTypeId="1" AcceptedAnswerId="12339" CreationDate="2016-05-16T16:16:44.293" Score="4" ViewCount="1682" Body="&lt;p&gt;For those who might not know, &lt;a href=&quot;http://www.flycheck.org/en/latest/&quot; rel=&quot;noreferrer&quot;&gt;Flycheck&lt;/a&gt; is a plugin which checks the syntax of the code you're writing on the fly, without forcing you to save the file. It does that by periodically saving the buffer to a temporary file, and running the syntax checker on &lt;em&gt;that&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way, you get instant feedback whenever you make a mistake, just like in an IDE, and (most importantly) if you're doing live development, with your program running in the background and reloading its files whenever it detects a change, it won't crash and burn if you make a small typo or syntax error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugins I've looked into (Syntastic and python-mode) only run the syntax checker on save. Is there a better alternative?&lt;/p&gt;&#xA;" OwnerUserId="7644" LastEditorUserId="1841" LastEditDate="2016-05-16T17:09:19.140" LastActivityDate="2017-12-21T11:07:45.807" Title="How to check the syntax of a file on the fly?" Tags="|syntax-highlighting|filetype-python|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7813" PostTypeId="2" ParentId="7811" CreationDate="2016-05-16T18:50:31.450" Score="2" Body="&lt;p&gt;You can try &lt;a href=&quot;https://github.com/neomake/neomake&quot; rel=&quot;nofollow noreferrer&quot;&gt;neomake&lt;/a&gt; for Neovim and Vim 8.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="51" LastEditDate="2017-12-21T11:07:45.807" LastActivityDate="2017-12-21T11:07:45.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7814" PostTypeId="2" ParentId="7809" CreationDate="2016-05-16T22:50:00.333" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;http://manpages.ubuntu.com/manpages/trusty/en/man1/bash.1.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;man bash&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Compound Commands&#xA;   A compound command is one of the following:&#xA;   ...&#xA;   { list; }&#xA;          list  is simply executed in the current shell environment.  list&#xA;          must be terminated with a newline or semicolon.  This  is  known&#xA;          as  a  group  command. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: in &lt;code&gt;{ echo &quot;&amp;lt;?php&quot;; cat /tmp/php_snippet } | php&lt;/code&gt;, you need a &lt;code&gt;;&lt;/code&gt; before the closing brace. Unless you're using zsh, in which case the whole thing would have worked fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output from bash isn't particularly helpful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ bash -c '{ echo &quot;&amp;lt;?php&quot;; cat /tmp/php_snippet } | php'  &#xA;bash: -c: line 1: syntax error: unexpected end of file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I can find no way to get &lt;code&gt;system&lt;/code&gt; to return even this error message, without manually calling &lt;code&gt;bash -c&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-05-16T22:55:16.990" LastActivityDate="2016-05-16T22:55:16.990" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7815" PostTypeId="1" CreationDate="2016-05-17T01:03:46.717" Score="2" ViewCount="1832" Body="&lt;p&gt;I want to map&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;semicolon (&lt;code&gt;;&lt;/code&gt;) to Escape&lt;/li&gt;&#xA;&lt;li&gt;Ctrl+semicolon to semicolon&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and wrote the following in my .vmrc&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;inoremap ; &amp;lt;ESC&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;C-;&amp;gt; ;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;(1) allows me to escape from the insert mode, but (2) also behaves like Escape rather than giving &lt;code&gt;;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing here? Any help is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="6349" LastEditorUserId="205" LastEditDate="2016-05-17T16:27:05.537" LastActivityDate="2022-10-10T09:14:09.920" Title="Mapping ; to Escape and Ctrl+; to ;" Tags="|key-bindings|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7816" PostTypeId="1" AcceptedAnswerId="7823" CreationDate="2016-05-17T10:20:33.877" Score="1" ViewCount="754" Body="&lt;p&gt;I have a &lt;a href=&quot;https://vi.stackexchange.com/questions/7761/how-to-restore-the-position-of-the-cursor-after-executing-a-normal-command&quot;&gt;function&lt;/a&gt; that changes the 6th caracter of a line to a dollar symbol (&lt;code&gt;$&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want it to be performed on several lines, so I naively did a &quot;while&quot; loop using a counter (as shown under). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I have the feeling that there must be a much simpler, more &quot;vim-esque&quot; way to do that -- my function seems a bit complicated for such a simple task. Maybe I'm wrong, but I would appreciate any simplification/comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current function is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DollarSplit(nlines)&#xA;   let current_pos = getpos(&quot;.&quot;)&#xA;   let a:count = 0&#xA;   while a:count &amp;lt; a:nlines &#xA;      normal! 6|r$j&#xA;      a:count += 1&#xA;   endwhile&#xA;   call setpos(&quot;.&quot;, current_pos)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-09-20T21:43:40.957" Title="Call function on several lines" Tags="|vimrc|repeated-commands|functions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7817" PostTypeId="1" AcceptedAnswerId="7818" CreationDate="2016-05-17T10:27:33.067" Score="3" ViewCount="861" Body="&lt;p&gt;I am trying to define a string in vimscript containing a literal &lt;code&gt;#&lt;/code&gt; which  then gets passed to a shell command using &lt;code&gt;execute&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! g:Call_imagemagick_with_hex(hex_color)&#xA;    let a:display_command = &quot;! display -size 300x300 xc: '\#&quot; . a:hex_color . &quot;'&quot;&#xA;    execute a:display_command&#xA;    &quot;echo(a:display_command)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I would call this function like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call Call_imagemagick_with_hex('34495e')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what I want the shell to see via &lt;code&gt;execute&lt;/code&gt;' is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;display -size 300x300 xc: '#34495e'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that if &lt;code&gt;#&lt;/code&gt; appears unescaped in the string passed to &lt;code&gt;execute&lt;/code&gt;, vim  tries to expand it - it seems &lt;code&gt;#&lt;/code&gt; is like &lt;code&gt;%&lt;/code&gt; but represents the previous buffer.  e.g. If I use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a:display_command = &quot;! display -size 300x300 xc: '#&quot; . a:hex_color . &quot;'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim tries to expand &lt;code&gt;#&lt;/code&gt; and throws an error. If I use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a:display_command = &quot;! display -size 300x300 xc: '\#&quot; . a:hex_color . &quot;'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the shell sees:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;display -size 300x300 xc: '\#34495e'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the shell command doesn't work. From &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/26.html&quot; rel=&quot;nofollow&quot;&gt;learning vimscript the hardway&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Using single quotes tells Vim that you want the string exactly as-is, with no escape sequences. The one exception is that two single quotes in a row will produce one single quote.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It seems if &lt;code&gt;'&lt;/code&gt; does protects against meta-character expansion, it's possibly only in certain contexts.&lt;br&gt;&#xA;Otherwise, how can I pass a &lt;code&gt;#&lt;/code&gt; character to an underlying shell command?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2016-05-17T10:36:24.447" LastActivityDate="2016-05-17T10:56:09.590" Title="how to use a literal # in a vim string?" Tags="|vimscript|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7818" PostTypeId="2" ParentId="7817" CreationDate="2016-05-17T10:35:59.410" Score="4" Body="&lt;p&gt;You should use &lt;code&gt;system&lt;/code&gt; instead of &lt;code&gt;execute !&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call system(&quot;display -size 300x300 xc: '#&quot; . a:hex_color . &quot;'&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use the return value in a variable if you want, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:files = system('ls')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case you can prefer using the &lt;code&gt;systemlist()&lt;/code&gt; that returns a list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:files = systemlist('ls')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need to use special vim char in this context you can always use &lt;code&gt;expand&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference: &lt;code&gt;:h system()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-17T10:56:09.590" LastActivityDate="2016-05-17T10:56:09.590" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7819" PostTypeId="2" ParentId="7732" CreationDate="2016-05-17T10:44:42.703" Score="4" Body="&lt;p&gt;A greedy match should be enough to do the job.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! SplitDot let _s=@/ &amp;lt;bar&amp;gt; s/\v\.\w+%(\([^)]+\)|\{[^}]+})*/\r\0/g &amp;lt;bar&amp;gt; let @/=_s &amp;lt;bar&amp;gt; keepjumps normal! ``=']']&#xA;nnoremap &amp;lt;Leader&amp;gt;sd :SplitDot&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command works on the original example and this more complicated one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyMethods&#xA;  def mymethod&#xA;    MyModel.first_method.second(arg).third_method(arg.method).select{|a| a.valid?}.join&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After using the mapping the output is below and the cursor is at &lt;code&gt;^&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyMethods&#xA;  def mymethod&#xA;    MyModel&#xA;      .first_method&#xA;      .second(arg)&#xA;      .third_method(arg.method)&#xA;      .select{|a| a.valid?}&#xA;      .join&#xA;      ^&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pattern is longer, but easier to extend to more cases like &lt;code&gt;{}&lt;/code&gt; blocks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2B9fv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2B9fv.png&quot; alt=&quot;annotated regex and re-indent binding&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer using the &lt;code&gt;=&lt;/code&gt; method so Vim can indent for me using the indent rules already established by &lt;code&gt;filetype&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps and thanks for the idea. I've already used it in my own work flow.&lt;/p&gt;&#xA;" OwnerUserId="7654" LastEditorUserId="7654" LastEditDate="2016-05-17T10:53:14.277" LastActivityDate="2016-05-17T10:53:14.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7820" PostTypeId="2" ParentId="7816" CreationDate="2016-05-17T10:50:09.590" Score="2" Body="&lt;p&gt;You can use the following replace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DollarSplit(nlines)&#xA;   let current_pos = getpos(&quot;.&quot;)&#xA;&#xA;   execute ',+'.a:nlines.'s/^\(.\{5}\).\(.*\)/\1$\2/g'&#xA;&#xA;   call setpos(&quot;.&quot;, current_pos)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute '      &quot; prepare a command&#xA;,+             &quot; the command will operate on lines from current to&#xA;'.a:nlines.'   &quot; current+a:nlines&#xA;s/^            &quot; the command is a substitution, starting at start of line&#xA;\(.\{5}\)      &quot; capture the first 5 characters into a group (1)&#xA;.              &quot; match any 6th character&#xA;\(.*\)         &quot; capture the remaining of the line into a group (2)&#xA;/\1$\2         &quot; replace by group 1 $ group 2&#xA;/g'            &quot; end the substitution&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will basically create two matching group, surrounding the char you want to replace, and then restore the two groups with a &lt;code&gt;$&lt;/code&gt; inside.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h ranges&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h substitute&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-17T11:11:40.697" LastActivityDate="2016-05-17T11:11:40.697" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7821" PostTypeId="1" AcceptedAnswerId="7822" CreationDate="2016-05-17T10:58:37.793" Score="1" ViewCount="330" Body="&lt;p&gt;Supposing I have two scripts that share variables. What is the preferred way to do this, supposing I wanted to keep the variables only in one place? Is there a way to keep them script-local and not global?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Context: I'm writing two &lt;a href=&quot;https://github.com/scrooloose/syntastic/&quot; rel=&quot;nofollow&quot;&gt;syntastic&lt;/a&gt; syntax checkers that both the same errorformat (because underneath they use the same compiler). What would be the preferred way to share an &lt;code&gt;errorformat&lt;/code&gt; variable between the two files of these syntax checkers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was later &lt;a href=&quot;https://github.com/scrooloose/syntastic/pull/1772#issuecomment-219706885&quot; rel=&quot;nofollow&quot;&gt;explained&lt;/a&gt; by the maintainer that since these variables aren't meant to be changed often, I should just have them in two places. This question is still here because the how-to question is still answerable, although it is no longer relevant in the original context.&lt;/p&gt;&#xA;" OwnerDisplayName="user2598" LastEditorDisplayName="user2598" LastEditDate="2016-05-17T15:40:53.477" LastActivityDate="2016-05-17T15:40:53.477" Title="Sharing variables between different files in a plugin" Tags="|variables|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7822" PostTypeId="2" ParentId="7821" CreationDate="2016-05-17T11:00:31.857" Score="2" Body="&lt;p&gt;You should use a global variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h global-variable&#xA;&#xA;                    *global-variable* *g:var* *g:*&#xA;Inside functions global variables are accessed with &quot;g:&quot;.  Omitting this will&#xA;access a variable local to a function.  But &quot;g:&quot; can also be used in any other&#xA;place if you like.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use it as follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:my_variable = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then &lt;code&gt;g:my_variable&lt;/code&gt; is accessible from anywhere within vim and plugins.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-17T11:13:04.890" LastActivityDate="2016-05-17T11:13:04.890" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7823" PostTypeId="2" ParentId="7816" CreationDate="2016-05-17T11:39:04.430" Score="3" Body="&lt;pre&gt;&lt;code&gt;function! DollarSplit() range&#xA;   let current_pos = getpos(&quot;.&quot;)&#xA;   execute a:firstline . &quot;,&quot; . a:lastline . &quot;normal! 6|r$&quot;&#xA;   call setpos(&quot;.&quot;, current_pos)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help function-range-example&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-05-17T11:39:04.430" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7824" PostTypeId="1" CreationDate="2016-05-17T12:27:35.430" Score="3" ViewCount="263" Body="&lt;p&gt;When selecting about two dozens of lines in vim and copying it to the system register (&quot;+ y), and then paste it into another vim, it crashes. It does not paste the content of the register and the terminal window (gnome-terminal) stucks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have just a few lines to copy, everything works fine. The problem feels like there is a limit of some sort on the amount of characters to copy and paste. This cannot be. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any insight or suggestions what might be the problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;.vimrc &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number&#xA;set viminfo='100,&amp;lt;100,s10,h &#xA;&quot;set hlsearch&#xA;&#xA;&quot;to start the vi in insert mode  &#xA;:startinsert&#xA;&#xA;&quot;blocks comment &#xA;&quot;select with SHIFT+v and than hit # (for uncomment -#)&#xA;vnoremap # :s#^#\##&amp;lt;cr&amp;gt;&#xA;vnoremap -# :s#^\###&amp;lt;cr&amp;gt;&#xA;&#xA;&quot;leave &quot;+ regitry available for the system after closing vi&#xA;autocmd VimLeave * call system(&quot;xsel -ib&quot;, getreg('+'))&#xA;&quot;requires xsel &#xA;&#xA;set mouse=a &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim --version&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:47)&#xA;Included patches: 1-52&#xA;Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax         &#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary     &#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static &#xA;+balloon_eval    +float           +mouse_urxvt     -tag_any_white  &#xA;+browse          +folding         +mouse_xterm     +tcl            &#xA;++builtin_terms  -footer          +multi_byte      +terminfo       &#xA;+byte_offset     +fork()          +multi_lang      +termresponse   &#xA;+cindent         +gettext         -mzscheme        +textobjects    &#xA;+clientserver    -hangul_input    +netbeans_intg   +title          &#xA;+clipboard       +iconv           +path_extra      +toolbar        &#xA;+cmdline_compl   +insert_expand   +perl            +user_commands  &#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit      &#xA;+cmdline_info    +keymap          +postscript      +virtualedit    &#xA;+comments        +langmap         +printer         +visual         &#xA;+conceal         +libcall         +profile         +visualextra    &#xA;+cryptv          +linebreak       +python          +viminfo        &#xA;+cscope          +lispindent      -python3         +vreplace       &#xA;+cursorbind      +listcmds        +quickfix        +wildignore     &#xA;+cursorshape     +localmap        +reltime         +wildmenu       &#xA;+dialog_con_gui  +lua             +rightleft       +windows        &#xA;+diff            +menu            +ruby            +writebackup    &#xA;+digraphs        +mksession       +scrollbind      +X11            &#xA;+dnd             +modify_fname    +signs           -xfontset       &#xA;-ebcdic          +mouse           +smartindent     +xim            &#xA;+emacs_tags      +mouseshape      -sniff           +xsmp_interact  &#xA;+eval            +mouse_dec       +startuptime     +xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save     &#xA;+extra_search    -mouse_jsbterm   -sun_workshop    +xpm   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1541" LastEditorUserId="15" LastEditDate="2016-05-24T15:38:47.040" LastActivityDate="2016-05-24T15:38:47.040" Title="Is there a content length limit on the selection and drop register &quot;+?" Tags="|register|os-clipboard|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7826" PostTypeId="1" CreationDate="2016-05-17T13:44:33.460" Score="4" ViewCount="247" Body="&lt;p&gt;Is there  a way  to get insert  mode emacs  style meta&#xA;counts in neovim (which has support for the meta key)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Such that, for instance, &lt;code&gt;&amp;lt;m-3&amp;gt;-&lt;/code&gt; produces 3 hyphens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. I mean  is it possible  to produce the  exact same&#xA;behaviour.   In this  case,  &lt;code&gt;&amp;lt;m-3&amp;gt;-&lt;/code&gt;  is better  than&#xA;&lt;code&gt;&amp;lt;esc&amp;gt;3a-&amp;lt;esc&amp;gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="343" LastEditDate="2017-12-06T11:32:47.007" LastActivityDate="2017-12-06T11:32:47.007" Title="Insert mode counts in neovim" Tags="|key-bindings|neovim|count|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7827" PostTypeId="2" ParentId="7826" CreationDate="2016-05-17T13:59:02.503" Score="6" Body="&lt;p&gt;Yep. &lt;code&gt;{count}i{text}&amp;lt;esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: &lt;code&gt;80i-&amp;lt;esc&amp;gt;&lt;/code&gt; will insert 80 equal signs. Great as a markdown horizontal rule.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And mappable in your &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;hr 80i-&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Reference&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help insert&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7654" LastActivityDate="2016-05-17T13:59:02.503" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7828" PostTypeId="2" ParentId="7815" CreationDate="2016-05-17T14:10:46.047" Score="4" Body="&lt;p&gt;It looks like &lt;code&gt;&amp;lt;C-;&amp;gt;&lt;/code&gt; does not work in vim. Might I suggest using &lt;code&gt;&amp;lt;A-;&amp;gt;&lt;/code&gt; (Alt) instead? That one seems to work for me.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-05-17T14:10:46.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7829" PostTypeId="2" ParentId="5907" CreationDate="2016-05-17T14:15:07.927" Score="1" Body="&lt;p&gt;I can't speak to the history of the command, but I think of &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; as previous and next. It's used for many motions. See &lt;code&gt;help various-motions&lt;/code&gt; for several examples of square bracket motions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; becomes &quot;Control-Next&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;help CTRL-]&lt;/code&gt; describes it as &quot;Jump to the definition&quot;. When I'm pairing that's a bit long winded, so I usually say &quot;drill down&quot; instead.&lt;/p&gt;&#xA;" OwnerUserId="7654" LastActivityDate="2016-05-17T14:15:07.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7831" PostTypeId="2" ParentId="7803" CreationDate="2016-05-17T14:29:28.277" Score="1" Body="&lt;p&gt;I can't tell about the first step as I'm not using Dispatch, and my &lt;a href=&quot;https://github.com/LucHermitte/vim-build-tools-wrapper/blob/master/doc/cmake.md&quot; rel=&quot;nofollow&quot;&gt;CMake integration is different&lt;/a&gt;. As this isn't something we do that often, this isn't an important issue -- &lt;em&gt;Normally, this isn't required more than once per project and per build type to initialise a build configuration ; I know, sometimes we add variables and need to run (c)cmake again ; IMO this is best manually done in the console, or in nightly builds/CI)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the second step. Unfortunately, knowing when there is a compilation error isn't that trivial. In &lt;a href=&quot;https://github.com/LucHermitte/vim-build-tools-wrapper&quot; rel=&quot;nofollow&quot;&gt;BuildToolWrappers&lt;/a&gt;, I use the following code, stolen from LaTeX-Suite:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; --- The following code is borrowed from LaTeXSuite&#xA;&quot; close the quickfix window before trying to open it again, otherwise&#xA;&quot; whether or not we end up in the quickfix window after the :cwindow&#xA;&quot; command is not fixed.&#xA;let winnum = winnr()&#xA;cclose&#xA;cwindow&#xA; &quot; if we moved to a different window, then it means we had some errors.&#xA;if winnum != winnr()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(actually, my code is a little bit complex than that)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, it's still far from perfection, for instance, it's doesn't detect link errors correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, that Dispatch seems to be injecting completion information (see &lt;code&gt;dispatch#complete&lt;/code&gt;). May be it hides somewhere what you are looking for.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-05-17T14:29:28.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7832" PostTypeId="1" AcceptedAnswerId="7839" CreationDate="2016-05-17T14:33:47.803" Score="6" ViewCount="1114" Body="&lt;p&gt;A lot of operator like &lt;code&gt;delete&lt;/code&gt;, &lt;code&gt;change&lt;/code&gt;, &lt;code&gt;indent&lt;/code&gt;, &lt;code&gt;switch-case&lt;/code&gt; accept a motion to apply on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let say I want to replace the current word with all letter &lt;code&gt;a&lt;/code&gt;, I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;viwra&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Compared to the imagined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;riwa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why isn't it the same for the &lt;code&gt;replace&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's obviously by design, do you know the reason behind this choice?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-17T15:06:05.590" LastActivityDate="2016-05-18T08:12:24.737" Title="Why does replace not accept a motion?" Tags="|cursor-motions|replace|object-motions|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="7833" PostTypeId="2" ParentId="7832" CreationDate="2016-05-17T14:56:09.780" Score="2" Body="&lt;p&gt;&lt;code&gt;Replace&lt;/code&gt; is a specific type of situation, that I don't believe is equivalent to the others you listed that take motions. &lt;code&gt;r&lt;/code&gt; can take an optional count, but the action is the same. &lt;code&gt;3ra&lt;/code&gt; replaces 3 characters with the letter &quot;a&quot;. In its current state, adding a motion would only allow for the repetition of the replace action. You could &quot;replace word with the letter 'a'&quot; but anything else would be the equivalent to just doing a &lt;code&gt;change&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can achieve the same outcome using visual selection. &lt;code&gt;viwra&lt;/code&gt; would do a &quot;Visual selection in word, replace with 'a'&quot;. You'll notice that a lot of other actions that only provide counts, have the same sort of &quot;visual selection replacement for motion&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;R&lt;/code&gt; version of replace is a mode so there wouldn't be any type of motion, similar to how there is no motion for any other mode. &lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-05-17T14:56:09.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7834" PostTypeId="1" CreationDate="2016-05-17T16:32:56.270" Score="4" ViewCount="6837" Body="&lt;p&gt;I recently switched to Neovim and was trying to install the code checking plugin 'Neomake'. I followed the instructions for the setup in my vimrc. The plugin seems to run fine but the error list was not populated with errors even when I put in intentional errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A section of my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:neomake_python_flake8_maker = {&#xA;    \ 'exe': 'python3.4',&#xA;    \ 'errorformat': '%A%f: line %l\, col %v\, %m \ (%t%*\d\)',&#xA;    \ }&#xA;let g:neomake_python_enable_makers = ['flake8']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So how can I setup neomake properly with Python 2/3 support? Preferably using Flake8 as the checker.&lt;/p&gt;&#xA;" OwnerUserId="7563" LastActivityDate="2016-08-21T23:24:23.903" Title="How to setup Neomake with Python?" Tags="|vimrc|neovim|plugin-neomake|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7835" PostTypeId="1" CreationDate="2016-05-17T17:36:22.183" Score="6" ViewCount="9189" Body="&lt;p&gt;In vim when searching or replacing an exact word you need to type: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\&amp;lt;word\&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to match it exactly, this is cumbersome to type, and I find myself wanting to search/replace exact words a lot more often by default than part of a word. Is there a way to let vim use exact words by default, and then turn this option off/on when necessary? &lt;/p&gt;&#xA;" OwnerUserId="1305" LastActivityDate="2016-10-06T13:06:14.620" Title="Searching/replacing exact word in vim by default" Tags="|regular-expression|search|replace|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7836" PostTypeId="1" CreationDate="2016-05-17T19:17:47.807" Score="1" ViewCount="70" Body="&lt;p&gt;Is it possible to create an autocommand that executes whenever one &#xA;of the files in the arglist is written to?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-05-17T20:40:13.207" Title="Autocommand when writing to files in the arglist" Tags="|autocmd|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7837" PostTypeId="2" ParentId="7835" CreationDate="2016-05-17T19:51:31.187" Score="7" Body="&lt;p&gt;There isn't an option to treat the whole pattern as word bounded as far as I know.  Since you want to &lt;em&gt;replace&lt;/em&gt;, that means the text is already in the buffer.  You could use &lt;code&gt;*&lt;/code&gt; or &lt;code&gt;#&lt;/code&gt; on the word in normal mode which performs the &lt;code&gt;\&amp;lt;word\&amp;gt;&lt;/code&gt; search for you.  Then, &lt;code&gt;cgn&lt;/code&gt; to replace the next occurrence, and &lt;code&gt;.&lt;/code&gt; to repeat it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, once a search has been made with &lt;code&gt;*&lt;/code&gt;, you could use it to start a substitution pattern: &lt;code&gt;:%s//something/g&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be made into a key map: &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;r *:%s//&lt;/code&gt;.  It's used the same way as &lt;code&gt;*&lt;/code&gt; except it will also begin a substitution in the command line that you can finish yourself.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-05-18T02:04:44.360" LastActivityDate="2016-05-18T02:04:44.360" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7838" PostTypeId="2" ParentId="7836" CreationDate="2016-05-17T20:32:08.283" Score="3" Body="&lt;p&gt;There is not a specific Autocommand event for writes to the arglist files. What you can do is create a function that checks if the file is in the arglist and then set that to the &lt;code&gt;BufWrite&lt;/code&gt; event. So all buffer writes would trigger this function, but only arglist'd files would actually do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;bufname(&quot;%&quot;)&lt;/code&gt; to find the current buffer's name, and then use &lt;code&gt;argv()&lt;/code&gt; and &lt;code&gt;argc()&lt;/code&gt; to find the arglist entries.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! IsBufInArgs()&#xA;  let c = 0&#xA;  while c &amp;lt;= argc()&#xA;    if argv(c) == bufname(&quot;%&quot;)&#xA;      return 1&#xA;    endif&#xA;    let c += 1&#xA;  endwhile&#xA;&#xA;  return 0&#xA;endfunction&#xA;&#xA;function! DoOnlyWithArg()&#xA;  if IsBufInArgs() == 1&#xA;    echo &quot;Do something here&quot;&#xA;  endif&#xA;endfunction&#xA;&#xA;autocmd BufWrite * :call DoOnlyWithArg()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastEditorUserId="895" LastEditDate="2016-05-17T20:40:13.207" LastActivityDate="2016-05-17T20:40:13.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7839" PostTypeId="2" ParentId="7832" CreationDate="2016-05-17T21:13:45.603" Score="4" Body="&lt;p&gt;Actually. There is &lt;strong&gt;no&lt;/strong&gt; reason, apart from things being as they are, that would be against an &lt;code&gt;r&lt;/code&gt; operator. The simple fact that &lt;code&gt;viwra&lt;/code&gt; works means that &lt;code&gt;riwa&lt;/code&gt; &lt;em&gt;could&lt;/em&gt; work. The reason is simply a historical one, but there is nothing against an alternative implementation. It can help 'filling' some area defined by a motion/text-object with a single character. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the main idea against it was that e.g. &lt;code&gt;ri&lt;/code&gt; to replace the current character with &lt;code&gt;i&lt;/code&gt; was found more useful (= often needed) than an operator which for that case would need more letters (&lt;code&gt;rli&lt;/code&gt; would have probably sufficed for the above example: 'replace' operation + 'move one char to the right' motion + replacement char).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what's nice with Vim is that anybody can come up with this alternative :) &lt;code&gt;rri&lt;/code&gt; as &quot;replace all chars in line with &lt;code&gt;i&lt;/code&gt;&quot; doesn't look too bad :)&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-05-17T21:39:58.757" LastActivityDate="2016-05-17T21:39:58.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7840" PostTypeId="2" ParentId="7832" CreationDate="2016-05-18T08:12:24.737" Score="2" Body="&lt;p&gt;Not an answer, but a piece of code I used to &quot;simulate&quot; the functionality of an operator with &lt;code&gt;r&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ROperator()&#xA;  call inputsave()&#xA;  let l:replace_pattern = input('Replace &amp;gt; ')&#xA;  call inputrestore()&#xA;&#xA;  if len(l:replace_pattern) != 3&#xA;    throw &quot;Bad pattern size (expected 3)&quot;&#xA;  endif&#xA;&#xA;  let l:motion = strpart(replace_pattern, 0, 2)&#xA;  let l:char = strpart(replace_pattern, 2, 2)&#xA;&#xA;  execute &quot;normal! v&quot;.l:motion.&quot;r&quot;.l:char&#xA;&#xA;endfunction&#xA;&#xA;nnoremap gr :call ROperator()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be used like so (&lt;code&gt;[]&lt;/code&gt; is the cursor position):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; This is a se[n]tence.&#xA;&#xA; griw*&#xA;&#xA; This is a **[*]****.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-05-18T08:12:24.737" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7842" PostTypeId="1" AcceptedAnswerId="7846" CreationDate="2016-05-18T09:32:04.627" Score="5" ViewCount="680" Body="&lt;p&gt;I have some 30 characters in a line. When I press &lt;code&gt;80|&lt;/code&gt;, it should move 50 character to the right, thus move the cursor to 80th character. (30, 50, 80 are for examples)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to achieve this using mapping or commands?&#xA;I tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   :nmap &amp;lt;Bar&amp;gt; a&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="1821" LastEditDate="2016-05-18T13:38:40.500" LastActivityDate="2016-05-18T13:38:40.500" Title="Move to non-existing Nth column" Tags="|insert-mode|normal-mode|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7843" PostTypeId="2" ParentId="7842" CreationDate="2016-05-18T09:47:48.570" Score="6" Body="&lt;p&gt;There you go, a neat one-liner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;bar&amp;gt; &amp;lt;esc&amp;gt;:execute &quot;normal!&quot;.(input('Fill &amp;gt; ') - col('.')).&quot;a &quot;&amp;lt;CR&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;bar&amp;gt; &amp;lt;esc&amp;gt;:execute  &quot; leave insert mode and execute&#xA;&quot;normal!&quot;.                    &quot; a normal command&#xA;(&#xA;  input('Fill &amp;gt; ')            &quot; ask for the column to fill to&#xA;  - col('.')                  &quot; subtract to the current column&#xA;)&#xA;.&quot;a &quot;                         &quot; append spaces&#xA;&amp;lt;CR&amp;gt;i                         &quot; leave in insert mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use it like this (&lt;code&gt;[]&lt;/code&gt; is the cursor position):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; this is some text [|]&#xA;&#xA; Fill &amp;gt; 40&#xA; this is some text         ... 40 spaces ...      []&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; this has to be tested and improved, to handle the edge cases, and probably use this in a function, but you can start with that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS:&lt;/strong&gt; Answer made when OP said he wanted to append space to move the cursor.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-18T13:29:11.953" LastActivityDate="2016-05-18T13:29:11.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7844" PostTypeId="1" AcceptedAnswerId="7845" CreationDate="2016-05-18T10:11:51.197" Score="5" ViewCount="890" Body="&lt;p&gt;I answered a question that needed a user input using the built-in &lt;code&gt;input()&lt;/code&gt; function, which works great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if it was possible to ask vim for (let say) the next 3 characters input, without having to use the &lt;code&gt;input&lt;/code&gt; function, and without having to press &lt;kbd&gt;CR&lt;/kbd&gt; to confirm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I have not found anything in the documentation for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="205" LastEditDate="2016-05-20T01:45:22.017" LastActivityDate="2023-07-20T22:18:44.920" Title="How do I get the next n characters input by the user?" Tags="|vimscript|user-input|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7845" PostTypeId="2" ParentId="7844" CreationDate="2016-05-18T10:48:16.953" Score="9" Body="&lt;p&gt;Thanks to VanLaser comment, here is a little function to achieve what I wanted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetNChar()&#xA;  let l:number = 3&#xA;  let l:string = &quot;&quot;&#xA;&#xA;  while l:number &amp;gt; 0&#xA;    let l:string .= nr2char(getchar())&#xA;    let l:number -= 1&#xA;  endwhile&#xA;&#xA;  echo l:string&#xA;endfunction&#xA;&#xA;nnoremap gs :call GetNChar()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here I append the chars into a string and display it, but one could do whatever he wants with it.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-05-18T10:48:16.953" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7846" PostTypeId="2" ParentId="7842" CreationDate="2016-05-18T12:59:44.297" Score="10" Body="&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27virtualedit%27&quot;&gt;&lt;code&gt;'virtualedit'&lt;/code&gt;&lt;/a&gt; to allow moving to columns that don't contain text.  If you &lt;code&gt;set virtualedit=all&lt;/code&gt;, then &lt;code&gt;80|&lt;/code&gt; will place the cursor on column 80.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No spaces will be inserted until you actually perform some text editing there, though.  If your sole goal is to just extend the line to an arbitrary column, then a simple mapping taking advantage of &lt;code&gt;'virtualedit'&lt;/code&gt; can do that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Bar&amp;gt; &amp;lt;Bar&amp;gt;i &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you only want &lt;code&gt;'virtualedit'&lt;/code&gt; active for the mapping, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ExpandLine(col)&#xA;    let ve = &amp;amp;ve&#xA;    set virtualedit=all&#xA;    exe 'normal! '.a:col.'|i '&#xA;    let &amp;amp;ve = ve&#xA;endfun&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Bar&amp;gt; :&amp;lt;C-u&amp;gt;call ExpandLine(v:count)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2016-05-18T12:59:44.297" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7848" PostTypeId="1" AcceptedAnswerId="7849" CreationDate="2016-05-18T13:20:43.237" Score="2" ViewCount="68" Body="&lt;p&gt;My issue is with using the -c while calling vim from terminal like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -c jk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I want to be able to open the last session before quitting on typing &lt;code&gt;viml&lt;/code&gt; in terminal&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this I made a map to save the session as 'zzz' on exiting vim. All that works perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I made an alias in my &lt;code&gt;.zshrc&lt;/code&gt;/&lt;code&gt;.bashrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# SLoad is from a plugin Startify, it loads the session  &#xA;alias viml='vim -c :SLoad zzz'   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the issue I am facing is that when I run &lt;code&gt;viml&lt;/code&gt; alias, this happens&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5iEaL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5iEaL.png&quot; alt=&quot;image&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its really annoying that I have to press enter to start working. I tried using &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; at end but it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I fix this?&lt;/p&gt;&#xA;" OwnerUserId="7479" LastEditorUserId="1821" LastEditDate="2016-05-18T13:25:24.263" LastActivityDate="2016-05-18T13:37:55.200" Title="Using '-c' when calling vim from terminal" Tags="|terminal|load|sessions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7849" PostTypeId="2" ParentId="7848" CreationDate="2016-05-18T13:32:13.890" Score="3" Body="&lt;p&gt;The issue is that you need to escape your &lt;code&gt;space&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias viml='vim -c :SLoad\ zzz'   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's consider a simpler case:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a file named &lt;code&gt;a.vim&lt;/code&gt; in the current directory and my alias is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vv=&quot;vim -c :sp a.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;vv&lt;/code&gt; I get two buffers with &lt;code&gt;a.vim&lt;/code&gt; on each.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is that? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim open &lt;code&gt;a.vim&lt;/code&gt; and &lt;strong&gt;then&lt;/strong&gt; execute the command &lt;code&gt;:sp&lt;/code&gt;, which split the buffer in two, opening &lt;code&gt;a.vim&lt;/code&gt; again. The alias is used as follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; vim -c :sp a.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means &lt;code&gt;vim a.vim&lt;/code&gt; and then &lt;code&gt;:sp&lt;/code&gt;. &lt;code&gt;:sp&lt;/code&gt; and &lt;code&gt;a.vim&lt;/code&gt; are two different arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I have the alias:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vv=&quot;vim -c :sp\ a.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim open, and execute &lt;code&gt;:sp a.vim&lt;/code&gt;, opening the &lt;code&gt;a.vim&lt;/code&gt; file in a new split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is because the &lt;code&gt;space&lt;/code&gt; is escaped and thus the &lt;code&gt;:sp a.vim&lt;/code&gt; is one argument.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-18T13:37:55.200" LastActivityDate="2016-05-18T13:37:55.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7851" PostTypeId="1" AcceptedAnswerId="7855" CreationDate="2016-05-18T15:16:32.860" Score="1" ViewCount="570" Body="&lt;p&gt;Vim builtin indentation seems to get confused with the following script. I cannot get Vim to indent properly the while-loop after the pipe.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;#!/bin/bash&#xA;&#xA;while true&#xA;do&#xA;    # while loop is indented correctly&#xA;    while read line&#xA;    do&#xA;        echo $line&#xA;    done &amp;lt; myfile&#xA;&#xA;    # while loop after a pipe is NOT indented correctly despite gg=G&#xA;    cat myfile | while read line&#xA;do&#xA;    echo $line&#xA;done&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;gg=G&lt;/code&gt; does not fix the indentation.&#xA;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="7670" OwnerDisplayName="jbl" LastEditorUserId="205" LastEditDate="2016-05-20T01:44:10.340" LastActivityDate="2016-05-20T01:44:10.340" Title="Vim indentation of a bash script seems broken after a pipe" Tags="|bash|indentation|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7852" PostTypeId="2" ParentId="7851" CreationDate="2016-05-18T15:22:36.570" Score="3" Body="&lt;p&gt;I made the indentation works by splitting the &lt;code&gt;cat&lt;/code&gt;/&lt;code&gt;while&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while true&#xA;do&#xA;    ...&#xA;&#xA;    cat myfile |&#xA;    while read line&#xA;    do&#xA;        echo $line&#xA;    done&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" OwnerDisplayName="Nobe4" LastActivityDate="2016-05-18T15:24:31.727" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7853" PostTypeId="1" AcceptedAnswerId="7856" CreationDate="2016-05-18T20:03:45.407" Score="1" ViewCount="265" Body="&lt;p&gt;I do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find $HOME -type f -name &quot;*.tex&quot; -exec grep -il &quot;$1&quot; {} + | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I cannot exit vim with &lt;code&gt;q&lt;/code&gt; only because it gives the error which I do not understand why&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E37: No write since last change (add ! to override)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you have to do &lt;code&gt;q!&lt;/code&gt; instead. &#xA;However, I would like to let Vim know that there is nothing to override and use instead &lt;code&gt;q&lt;/code&gt;. So probably, it could be reached by altering the &lt;code&gt;find&lt;/code&gt; command. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;How can you &lt;code&gt;find&lt;/code&gt; such that Vim knows there is no need of overriding?&lt;/p&gt;&#xA;" OwnerUserId="2923" LastEditorUserId="205" LastEditDate="2016-05-20T00:26:09.573" LastActivityDate="2016-05-20T00:26:09.573" Title="Why do I need to use q! after `find ... | vim -`, i.e., reading from stdin?" Tags="|quit|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7854" PostTypeId="2" ParentId="7853" CreationDate="2016-05-18T20:49:18.973" Score="5" Body="&lt;p&gt;You are piping content into Vim, so it's starting a new &lt;em&gt;unsaved&lt;/em&gt; buffer.  If you don't need to save the content, you can add &lt;code&gt;+'set buftype=nofile'&lt;/code&gt; to your command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find $HOME -type f -name &quot;*.tex&quot; -exec grep -il &quot;$1&quot; {} + | vim +'set buftype=nofile' -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will treat the buffer as if it has no associated file.  Which would be good if you plan to use Vim as a pager.  When you make changes, it will not prompt you to save it, and when you write to a file with &lt;code&gt;:w test.txt&lt;/code&gt; the buffer will not be associated with the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to be prompted to save if there are changes, or you want the buffer to be associated with a file once written, you could use: &lt;code&gt;+'set nomodified'&lt;/code&gt; instead, which sets the initial state of the buffer as not modified.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-05-18T20:49:18.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7855" PostTypeId="2" ParentId="7851" CreationDate="2016-05-18T21:27:11.110" Score="2" Body="&lt;p&gt;You can't get what you want in this case without writing your own indent script or breaking up the lines like in Nobe4's answer.  Take a look at &lt;code&gt;GetShIndent()&lt;/code&gt; in &lt;code&gt;$VIMRUNTIME/indent/sh.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks for the &lt;strong&gt;previous&lt;/strong&gt; non-blank line that starts with &lt;code&gt;while&lt;/code&gt; and increases the indent level.  However, it checks if the current line starts with &lt;code&gt;do&lt;/code&gt; to decrease the indent level.  This is how it sets the correct indent if you use the inline &lt;code&gt;while ; do&lt;/code&gt; variant.  In your case, it finds the &lt;code&gt;do&lt;/code&gt; on the current line but not the &lt;code&gt;while&lt;/code&gt; on the previous line, so it drops the indent level lower than you expected.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-05-18T21:27:11.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7856" PostTypeId="2" ParentId="7853" CreationDate="2016-05-18T21:32:56.097" Score="6" Body="&lt;p&gt;You can change &lt;code&gt;vim -&lt;/code&gt; to &lt;code&gt;vim -R -&lt;/code&gt;.  From the manual:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Read-only  mode.   The  'readonly' option will be set.  You can still&#xA;  edit the buffer, but will be prevented from accidently overwriting &#xA;  a file.  If you do want to overwrite a file, add an exclamation mark&#xA;  to  the  Ex  command,  as  in &quot;:w!&quot;.   The  -R  option  also  implies &#xA;  the -n option (see below).  The 'readonly' option  can  be  reset &#xA;  with  &quot;:set noro&quot;.  See &quot;:help 'readonly'&quot;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[&lt;em&gt;The implied -n option disables the swap file.&lt;/em&gt;]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It doesn't explicitly state it, but read-only mode also implies &quot;+nomodified&quot;.  That is, you won't be prompted to save upon exiting if you don't make any changes.  If you attempt to make changes, it will first warn you that you are modifying a readonly file, and then prompt you to save the file upon exiting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on your system, &lt;code&gt;view&lt;/code&gt; may also be a symlink to &lt;code&gt;vim&lt;/code&gt; that is equivalent to &lt;code&gt;vim -R&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1688" LastEditorUserId="1688" LastEditDate="2016-05-18T21:40:21.980" LastActivityDate="2016-05-18T21:40:21.980" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7857" PostTypeId="1" CreationDate="2016-05-18T21:34:03.523" Score="0" ViewCount="180" Body="&lt;p&gt;To make things a bit quicker, I've remapped the window switching commands like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-j&amp;gt; &amp;lt;C-w&amp;gt;j&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-k&amp;gt; &amp;lt;C-w&amp;gt;k&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-h&amp;gt; &amp;lt;C-w&amp;gt;h&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-l&amp;gt; &amp;lt;C-w&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My goal is to type &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt;, etc., to switch between window splits. The &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-k&lt;/code&gt; bindings work, but for some reason &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; don't do anything. &lt;code&gt;&amp;lt;C-w&amp;gt;h&lt;/code&gt; and &lt;code&gt;&amp;lt;C-w&amp;gt;l&lt;/code&gt; work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run &lt;code&gt;:nmap&lt;/code&gt;, I see the following for those commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;n  &amp;lt;C-H&amp;gt;       * &amp;lt;C-W&amp;gt;h&#xA;n  &amp;lt;NL&amp;gt;        * &amp;lt;C-W&amp;gt;j&#xA;n  &amp;lt;C-K&amp;gt;       * &amp;lt;C-W&amp;gt;k&#xA;n  &amp;lt;C-L&amp;gt;       * &amp;lt;C-W&amp;gt;l&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using Neovim 0.1.4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mispoke earlier. It looks like &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; is working as well. That just leaves &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; not working.&lt;/p&gt;&#xA;" OwnerUserId="7675" LastEditorUserId="7675" LastEditDate="2016-05-19T01:43:44.157" LastActivityDate="2016-05-19T01:50:04.127" Title="Window Swtiching Mappings Not Working" Tags="|key-bindings|normal-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7858" PostTypeId="2" ParentId="7857" CreationDate="2016-05-19T01:50:04.127" Score="2" Body="&lt;p&gt;After digging into this some more, it looks like this is a &lt;a href=&quot;https://github.com/neovim/neovim/issues/2048&quot; rel=&quot;nofollow&quot;&gt;known issue&lt;/a&gt; with Neovim and tmux. iTerm2 is interpreting &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; as a backspace and sending that instead. As a workaround, I've mapped backspace to to the action I want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('nvim')&#xA;  nnoremap &amp;lt;bs&amp;gt; &amp;lt;C-w&amp;gt;h&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7675" LastActivityDate="2016-05-19T01:50:04.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7859" PostTypeId="1" AcceptedAnswerId="7861" CreationDate="2016-05-19T05:38:40.467" Score="8" ViewCount="900" Body="&lt;p&gt;When typing fast, sometimes the &lt;code&gt;:q&lt;/code&gt; is taken as &lt;code&gt;:Q&lt;/code&gt; and it is annoying when you have to repeat that for twice or thrice before actually quitting the Vim session. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make &lt;code&gt;:Q&lt;/code&gt; to &lt;code&gt;:q&lt;/code&gt; to overcome the above said problem ?&lt;/p&gt;&#xA;" OwnerUserId="7667" LastEditorUserId="1821" LastEditDate="2016-05-19T08:46:30.837" LastActivityDate="2016-05-19T08:46:30.837" Title="Workaround for :Q to :q while quitting in VIM" Tags="|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7860" PostTypeId="2" ParentId="7859" CreationDate="2016-05-19T06:03:14.693" Score="-3" Body="&lt;p&gt;You can use command abbreviation for it. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :cabbr Q q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put this in ~/.vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever you type :Q, it will be automatically converted to :q and file will be exited.&#xA;Similarly, you can use abbreviations like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :cabbr W! w!&#xA; :cabbr wQ wq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as well.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="7161" LastEditDate="2016-05-19T06:13:35.777" LastActivityDate="2016-05-19T06:13:35.777" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="7861" PostTypeId="2" ParentId="7859" CreationDate="2016-05-19T08:46:05.537" Score="8" Body="&lt;p&gt;Instead of mapping or abbreviating, I would use a custom command to actually create a new behavior for this edge-case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; command! Q :q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use &lt;code&gt;:Q&lt;/code&gt; to have the same effect as &lt;code&gt;:q&lt;/code&gt;, without any risk of overriding any function name/other mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then define other command depending on your usage, adding a &lt;code&gt;!&lt;/code&gt;, using &lt;code&gt;W&lt;/code&gt; ...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also worth knowing, as a workaround, to map &lt;code&gt;;&lt;/code&gt; to &lt;code&gt;:&lt;/code&gt; and &lt;code&gt;:&lt;/code&gt; to &lt;code&gt;;&lt;/code&gt;. This make the command line accessible without having to press the &lt;code&gt;shift&lt;/code&gt; key, thus preventing the &lt;code&gt;:Q&lt;/code&gt; to arise.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ; :&#xA;nnoremap : ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-05-19T08:46:05.537" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7862" PostTypeId="1" AcceptedAnswerId="7871" CreationDate="2016-05-19T08:55:57.377" Score="4" ViewCount="475" Body="&lt;p&gt;I'm writing my own &lt;code&gt;indentexpr&lt;/code&gt; to indent my code, the &lt;code&gt;indentexpr&lt;/code&gt; is run in a sandbox, so one important point is that I cannot change the text content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have set up the syntax highlighting for quoted strings, how do I know the cursor is at the boundary &lt;code&gt;&quot;&lt;/code&gt; in this case?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code&gt;&quot;A&quot;&quot;B&quot;&#xA;  ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Two strings &lt;code&gt;&quot;A&quot;&lt;/code&gt; and &lt;code&gt;&quot;B&quot;&lt;/code&gt; stick together. The API &lt;code&gt;synIDattr()&lt;/code&gt; can let me know the name of the syntax item, say &quot;myString&quot;, but cannot tell the start and end of this item.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot simply move the cursor from &lt;code&gt;&quot;A&quot;&lt;/code&gt; to &lt;code&gt;&quot;B&quot;&lt;/code&gt; (or vise versa) and say I find the last quote of &lt;code&gt;&quot;A&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an easy way to tell the difference between &lt;code&gt;&quot;A&quot;&lt;/code&gt; and &lt;code&gt;&quot;B&quot;&lt;/code&gt; without manually counting quotes (for performance)?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The example above is made up for easier comprehension. The real use case is about multiline strings. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;var s = &quot;A&#xA;&quot;&#xA;&quot;B&quot;.shout()&#xA;&#xA;s = &quot;&quot;&quot;A&#xA;&quot;&quot;&quot;&#xA;&quot;B&quot;.shout()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7676" LastEditorUserId="7676" LastEditDate="2016-05-19T13:24:53.713" LastActivityDate="2016-05-19T14:45:10.733" Title="How to check whether the cursor is at the boundary of a syntax item for indentexpr?" Tags="|vimscript|syntax-highlighting|indentation|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="7864" PostTypeId="1" AcceptedAnswerId="7865" CreationDate="2016-05-19T10:38:18.027" Score="-1" ViewCount="325" Body="&lt;p&gt;Code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot; http://vi.stackexchange.com/a/7787/2923&#xA;function! OpenSelectionAsTabs() range&#xA;    let tabnr = tabpagenr()&#xA;    for line in range(a:firstline, a:lastline)&#xA;        execute &quot;tabedit &quot; . getline(line)&#xA;        execute &quot;tabp&quot;&#xA;    endfor&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;gf :'&amp;lt;,'&amp;gt;call OpenSelectionAsTabs()&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;leader&amp;gt;gf :call OpenSelectionAsTabs()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Filelist where I select two files in Visual mode and Press &lt;code&gt;&amp;lt;leader&amp;gt;gf&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/masi/Raspberry Pi/me-hello-yes.tex&#xA;/Users/masi/hello.tex&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function OpenSelectionAsTabs:&#xA;line    3:&#xA;E172: Only one file name allowed: tabedit /Users/masi/Raspberry Pi/me-hello-yes.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are several complications such as artifact tabs. &#xA;I think the empty spaces can be one source of the problem. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Why is there the error message E172?&lt;/p&gt;&#xA;" OwnerUserId="2923" LastActivityDate="2016-05-19T10:42:58.497" Title="Why Error E172 on Execution?" Tags="|vimrc|error|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7865" PostTypeId="2" ParentId="7864" CreationDate="2016-05-19T10:42:58.497" Score="3" Body="&lt;p&gt;You need to escape the line so that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tabedit /Users/masi/Raspberry Pi/me-hello-yes.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tabedit /Users/masi/Raspberry\ Pi/me-hello-yes.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Otherwise, &lt;code&gt;tabedit&lt;/code&gt; sees two filenames &lt;code&gt;/Users/masi/Raspberry&lt;/code&gt; and &lt;code&gt;Pi/me-hello-yes.tex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do this with the function &lt;code&gt;fnameescape()&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;tabedit &quot; . fnameescape(getline(line))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-05-19T10:42:58.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7866" PostTypeId="2" ParentId="17" CreationDate="2016-05-19T10:56:16.793" Score="5" Body="&lt;p&gt;There is another way to search between particular lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/%&amp;gt;{linenumber}l\%&amp;lt;{linenumber}{pattern}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/%&amp;gt;199l\%&amp;lt;300lgood&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will search from line 200 to 299 for the pattern 'good'.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%&amp;gt;199l - l is for line, &amp;gt;199 denotes the lines greater than 199&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-05-20T00:26:39.967" LastActivityDate="2016-05-20T00:26:39.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7867" PostTypeId="1" CreationDate="2016-05-19T11:01:03.133" Score="11" ViewCount="9026" Body="&lt;p&gt;Editors like Sublime Text remember your session, so that whenever you open Sublime Text it is exactly how it was when you last closed it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All of the same files are open&lt;/li&gt;&#xA;&lt;li&gt;Your cursor is in the same position&lt;/li&gt;&#xA;&lt;li&gt;Sublime Text even remembers changes to unsaved files&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Can I get the same behavior in vim?&lt;/p&gt;&#xA;" OwnerUserId="7678" LastEditorUserId="1841" LastEditDate="2016-05-19T11:58:07.167" LastActivityDate="2023-11-09T18:02:23.697" Title="Remember previous session" Tags="|sessions|" AnswerCount="1" CommentCount="6" ClosedDate="2016-05-19T13:13:06.937" ContentLicense="CC BY-SA 3.0" />
  <row Id="7868" PostTypeId="2" ParentId="7867" CreationDate="2016-05-19T11:44:49.630" Score="12" Body="&lt;p&gt;Vim has a built-in session mechanism, from &lt;a href=&quot;https://vimhelp.org/starting.txt.html#Session&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h session&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A Session keeps the Views for all windows, plus the global settings.  You can&#xA;save a Session and when you restore it later the window layout looks the same.&#xA;You can use a Session to quickly switch between different projects,&#xA;automatically loading the files you were last working on in that project.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It should fill your 2 first requirements but the third one &lt;code&gt;Sublime Text even remembers changes to unsaved files&lt;/code&gt; isn't supported out of the box.&lt;/p&gt;&#xA;&lt;p&gt;To save your sessions you need to use &lt;code&gt;:mksession&lt;/code&gt; (&lt;a href=&quot;https://vimhelp.org/starting.txt.html#%3Amksession&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :mksession&lt;/code&gt;&lt;/a&gt;). By default the command will save the file in &lt;code&gt;./Session.vim&lt;/code&gt; but you can provide a file path as argument (e.g. &lt;code&gt;:mksession! ~/.Session.vim&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;You can also modify the default behavior with &lt;code&gt;sessionoptions&lt;/code&gt; (&lt;a href=&quot;https://vimhelp.org/options.txt.html#%27sessionoptions%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'sessionoptions'&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;To reload your session use &lt;code&gt;:source ~/.Session.vim&lt;/code&gt; (or whatever filepath you used with &lt;code&gt;:mksession&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Note that you need Vim to be compiled with the &lt;code&gt;+mksession&lt;/code&gt; feature to use the sessions.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Finally to automate the process you can add this to your vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Automatically save the session when leaving Vim&#xA;autocmd! VimLeave * mksession&#xA;&amp;quot; Automatically load the session when entering vim&#xA;autocmd! VimEnter * source ~/Session.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit 7 years later&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;As mentioned in the comments it might be better not to use the &lt;code&gt;VimEnter&lt;/code&gt; autocommand and trigger the sourcing manually to avoid sourcing the session in situations you don't want.&lt;/p&gt;&#xA;&lt;p&gt;Or you could make the autocmd a bit smarted and source the session file only when you are in a specific directory.&lt;/p&gt;&#xA;&lt;p&gt;Or you could have a shell alias like &lt;code&gt;alias lvim='vim -S ~/Session.vim'&lt;/code&gt; to start a session only when you want to. (That's the solution I ended up using in the long term)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2023-11-09T18:02:23.697" LastActivityDate="2023-11-09T18:02:23.697" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="7869" PostTypeId="1" CreationDate="2016-05-19T12:53:04.227" Score="4" ViewCount="1573" Body="&lt;p&gt;I want to install a plugin manager for vim, and after searching a bit, I saw that plugin managers for vim have evolved since last time I used one (e.g. neobundle is discontinued, etc.); and I also discovered two new ones: dein.vim and vim-plug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since they are both new to me, I don't know which one to chose. I enjoy simple and minimal software so I think of going for dein.vim, but it seems that vim-plug is quite popular.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here's the question: why should I go for either?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit: I have seen the question tagged as &quot;duplicate&quot; before writing this very question, and decided to still ask it because it doesn't treat the case of dein.vim, which appears to be a very interesting alternative. Therefore I don't consider this question to be duplicate, and am still interested in knowing the answer.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="7681" LastEditorUserId="7681" LastEditDate="2016-05-19T13:24:29.580" LastActivityDate="2016-05-19T13:24:29.580" Title="Why should I use either dein.vim or vim-plug?" Tags="|plugin-managers|" AnswerCount="0" CommentCount="11" ClosedDate="2016-05-19T13:15:01.037" ContentLicense="CC BY-SA 3.0" />
  <row Id="7870" PostTypeId="1" AcceptedAnswerId="7872" CreationDate="2016-05-19T14:37:18.947" Score="4" ViewCount="125" Body="&lt;p&gt;I would like to replace &lt;code&gt;foo&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt; and &lt;code&gt;Foo&lt;/code&gt; with &lt;code&gt;Bar&lt;/code&gt;. I can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/Foo/Bar/g&#xA;:s/foo/bar/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I do this in one command?&lt;/p&gt;&#xA;" OwnerUserId="6154" LastActivityDate="2016-05-19T14:50:22.007" Title="Search and replace depending on capitalization of letters" Tags="|search|replace|" AnswerCount="1" CommentCount="1" ClosedDate="2016-05-19T18:57:54.580" ContentLicense="CC BY-SA 3.0" />
  <row Id="7871" PostTypeId="2" ParentId="7862" CreationDate="2016-05-19T14:45:10.733" Score="3" Body="&lt;p&gt;This is a problem I encountered in my plugin: &lt;a href=&quot;https://github.com/tweekmonster/braceless.vim&quot; rel=&quot;nofollow&quot;&gt;braceless.vim&lt;/a&gt;.  You won't be able to do this using only syntax groups.  Some syntaxes make a distinction between strings and heredoc/docstring, but you will still face the same problem if those are sitting next to each other.  Here is the relevant snippet from braceless.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:docstr = '\%(&quot;&quot;&quot;\|''''''\)'&#xA;let s:syn_string = '\%(String\|Heredoc\|DoctestValue\|DocTest\|DocTest2\|BytesEscape\)$'&#xA;&#xA;&#xA;&quot; Test if the line is a string.  Accepts a column number to test.  If no &#xA;&quot; column number is provided, test the first and last column of the line.&#xA;function! s:is_string(line, ...)&#xA;  return synIDattr(synID(a:line, a:0 ? a:1 : col([a:line, '$']) - 1, 1), 'name') =~? s:syn_string&#xA;        \ &amp;amp;&amp;amp; (a:0 || synIDattr(synID(a:line, 1, 1), 'name') =~? s:syn_string)&#xA;endfunction&#xA;&#xA;&#xA;&quot; Returns the start and end lines for docstrings.  Accepts a second argument&#xA;&quot; to limit the search.&#xA;function! s:docstring(line, ...)&#xA;  let l = nextnonblank(a:line)&#xA;  let doc_head = 0&#xA;  let doc_tail = 0&#xA;&#xA;  let bounds = a:0 ? a:1 : [1, line('$')]&#xA;&#xA;  while l &amp;gt;= bounds[0]&#xA;    if getline(l) =~ s:docstr &amp;amp;&amp;amp; s:is_string(nextnonblank(l + 1))&#xA;          \ &amp;amp;&amp;amp; !s:is_string(prevnonblank(l - 1))&#xA;      let doc_head = l&#xA;      break&#xA;    elseif !s:is_string(l)&#xA;      break&#xA;    endif&#xA;    let l = prevnonblank(l - 1)&#xA;  endwhile&#xA;&#xA;  if doc_head == 0&#xA;    return [0, 0]&#xA;  endif&#xA;&#xA;  let l = prevnonblank(a:line)&#xA;  while l &amp;lt;= bounds[1]&#xA;    if getline(l) =~ s:docstr &amp;amp;&amp;amp; s:is_string(prevnonblank(l - 1))&#xA;          \ &amp;amp;&amp;amp; !s:is_string(nextnonblank(l + 1))&#xA;      let doc_tail = l&#xA;      break&#xA;    elseif !s:is_string(l)&#xA;      break&#xA;    endif&#xA;    let l = nextnonblank(l + 1)&#xA;  endwhile&#xA;&#xA;  return [doc_head, doc_tail]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s:docstring()&lt;/code&gt; starts by searching backwards from the supplied line number.  If it finds a matching docstring delimiter on the current line, it tests the previous line to see if it's not a string that spans an entire line.  This makes up for cases where a double quoted docstring might have single quote docstring delimiters in it (&lt;code&gt;&quot;&quot;&quot;a\n'''\nb&quot;&quot;&quot;&lt;/code&gt;).  It otherwise stops searching on the first non-blank non-string line encountered.  If it finds the beginning delimiter, it continues the search in the opposite direction from the supplied line number.  The speed of this function depends on how large the docstring block is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s = &quot;&quot;&quot;A&#xA;&quot;&quot;&quot;&#xA;&quot;B&quot;.shout()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s:docstring()&lt;/code&gt; could determine that &lt;code&gt;&quot;B&quot;&lt;/code&gt; is not part of the docstring above it.  But, for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var s = &quot;A&#xA;&quot;&#xA;&quot;B&quot;.shout()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would have to adapt the function to search for standard string delimiters, and search for standard string boundaries &lt;em&gt;after&lt;/em&gt; you have determined that the current line is not in a docstring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For my plugin's needs, I considered contiguous docstrings to be an entire block since they would indent to the same level.  If you still want to make a distinction between:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot;&#xA;A&#xA;&quot;&quot;&quot;&#xA;&quot;&quot;&quot;&#xA;B&#xA;&quot;&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could change the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if getline(l) =~ s:docstr &amp;amp;&amp;amp; s:is_string(nextnonblank(l + 1))&#xA;      \ &amp;amp;&amp;amp; (!s:is_string(prevnonblank(l - 1)) || getline(prevnonblank(l - 1)) !~ s:docstr)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way, if the previous non-blank line is not a string &lt;em&gt;or&lt;/em&gt; another docstring delimiter is encountered, it would take the current line as the beginning of the docstring. But, this would break the case cited above for mixed docstring delimiters (&lt;code&gt;&quot;&quot;&quot;a\n'''\nb&quot;&quot;&quot;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the sake of speed in &lt;code&gt;indentexpr&lt;/code&gt;, the function could be modified to &lt;em&gt;only&lt;/em&gt; search backwards, since indentation depends the lines above the current line.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-05-19T14:45:10.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7872" PostTypeId="2" ParentId="7870" CreationDate="2016-05-19T14:50:22.007" Score="6" Body="&lt;p&gt;You could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\cfoo/\=submatch(0)[0] ==# 'F' ? 'Bar' : 'bar'/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The replacement part of the substitution command is an expression which tests whether the first character of the pattern is &lt;code&gt;F&lt;/code&gt;.  If it is, the expression returns &lt;code&gt;Bar&lt;/code&gt;, otherwise &lt;code&gt;bar&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-05-19T14:50:22.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7873" PostTypeId="2" ParentId="6097" CreationDate="2016-05-19T16:42:17.707" Score="8" Body="&lt;p&gt;I was just looking this information up and I only found one x64 version not mentioned by Christian. Here's a summary of the interfaces each version supports today to give you an idea of how well they stay up to date:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;&lt;a href=&quot;https://github.com/vim/vim-win32-installer/releases&quot; rel=&quot;noreferrer&quot;&gt;Nearly Official&lt;/a&gt;&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim-win32-installer/releases/download/v7.4.1832/gvim_7.4.1832_x86.zip&quot; rel=&quot;noreferrer&quot;&gt;Vim 7.4.1832&lt;/a&gt; and &lt;a href=&quot;https://github.com/vim/vim-win32-installer/releases/download/v7.4.1832/gvim_7.4.1832_x64.zip&quot; rel=&quot;noreferrer&quot;&gt;x64&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Interfaces: ActivePerl 5.22, ActiveTcl 8.6, LuaBinaries 5.3, Python 2.7, Python 3.4, Racket 6.4, RubyInstaller 2.2&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;&lt;a href=&quot;https://tuxproject.de/projects/vim/&quot; rel=&quot;noreferrer&quot;&gt;TuxProject.de&lt;/a&gt;&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://tuxproject.de/projects/vim/complete-x86.exe&quot; rel=&quot;noreferrer&quot;&gt;Vim 7.4.1832&lt;/a&gt; and &lt;a href=&quot;http://tuxproject.de/projects/vim/complete-x64.exe&quot; rel=&quot;noreferrer&quot;&gt;x64&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Interfaces: Perl 5.22.2, Python 2.7.11, Python 3.5.1, Racket 6.4.0.4, Ruby 2.3.0, Lua 5.3.2, Tcl 8.6.4, libXpm. &lt;/li&gt;&#xA;&lt;li&gt;Python 2.7.11 requires you to rename a registry key when using the x86 builds. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;&lt;a href=&quot;https://bitbucket.org/Alexander-Shukaev/vim-for-windows&quot; rel=&quot;noreferrer&quot;&gt;Alexander-Shukaev (formerly Haroogan)&lt;/a&gt;&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://bitbucket.org/Alexander-Shukaev/vim-for-windows/downloads/vim-7.4.417-python-2.7-python-3.4-ruby-2.0.0-lua-5.2-perl-5.18-windows-x86.zip&quot; rel=&quot;noreferrer&quot;&gt;Vim 7.4.417&lt;/a&gt; and &lt;a href=&quot;https://bitbucket.org/Alexander-Shukaev/vim-for-windows/downloads/vim-7.4.417-python-2.7-python-3.4-ruby-2.0.0-lua-5.2-perl-5.18-windows-x64.zip&quot; rel=&quot;noreferrer&quot;&gt;x64&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Interfaces: python 2.7, python 3.4, ruby 2.0.0, lua 5.2, perl 5.18.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2045" LastActivityDate="2016-05-19T16:42:17.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7874" PostTypeId="1" AcceptedAnswerId="7876" CreationDate="2016-05-20T03:59:02.893" Score="6" ViewCount="9618" Body="&lt;p&gt;I have a file (around 1.6 million lines) which formatted like this:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-0.00697468 0 -1.95966e-49 101325 -3.06381  &#xA;-0.00697468 0 -1.95966e-49 101325 -3.06381  &#xA;-0.00697468 0 -1.95966e-49 101325 -3.06381  &#xA;. . .  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After some thousand lines, the format will be changed (no minus sign on the first character), like this:    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0.453945 -2.14126e-54 3.40152e-49 101325 214.355  &#xA;0.453945 -2.14126e-54 3.40152e-49 101325 214.355  &#xA;0.453945 -2.14126e-54 3.40152e-49 101325 214.355  &#xA;. . .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, how to delete the entire line, after the first whitespace on every line?&#xA;I have tried to search but couldn't get any answer that I want. Thanks!&#xA;(Note: some lines have different number of character, hence that I cannot simply delete some characters from the end of the line on every line)&lt;/p&gt;&#xA;" OwnerUserId="7575" LastEditorUserId="205" LastEditDate="2016-05-20T08:41:57.667" LastActivityDate="2016-05-20T08:42:58.483" Title="delete entire line after first whitespace on every line" Tags="|whitespace|multiple-lines|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7875" PostTypeId="2" ParentId="7874" CreationDate="2016-05-20T04:43:24.797" Score="5" Body="&lt;p&gt;If you wanted to delete entire line starting with a space, This pattern will be useful.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\s.*/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;g&lt;/code&gt; -global&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; - start of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s&lt;/code&gt; - space&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*&lt;/code&gt; - anything after that&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d&lt;/code&gt; - delete&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want the starting whitespace to remain, but delete the remaining content, you can use,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(\s\+\).*/\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-05-20T08:42:58.483" LastActivityDate="2016-05-20T08:42:58.483" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7876" PostTypeId="2" ParentId="7874" CreationDate="2016-05-20T05:29:12.973" Score="10" Body="&lt;p&gt;The two commands below will reduce every line to the first sequence of non-whitespace character followed by a space:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from&#xA;0.453945 -2.14126e-54 3.40152e-49 101325 214.355&#xA;&#xA;to&#xA;0.453945 &amp;lt;-- space&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But your question is a little confusing so I'm not sure I understood what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(\S\+\s\).*/\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With a macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%normal! WD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-05-20T05:29:12.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7877" PostTypeId="1" AcceptedAnswerId="7883" CreationDate="2016-05-20T06:36:36.003" Score="8" ViewCount="1460" Body="&lt;p&gt;I have created the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;F8&amp;gt; 3w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I pressed &lt;code&gt;2&amp;lt;F8&amp;gt;&lt;/code&gt;, I thought it would move six words (&lt;code&gt;2*3w&lt;/code&gt;), but it moves 23 words.&#xA;(This has been mentioned in help section of vim editor)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to map it to work for 6 moves instead of 23?&#xA;Also, please let me know if this feature is intentionally made to work like this for mappings?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In all other cases, it is straightforward like 2*3 instead ad of 23, like &lt;code&gt;2d3w&lt;/code&gt; is same as &lt;code&gt;6dw&lt;/code&gt;, as well as &lt;code&gt;d6w&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="343" LastEditDate="2017-12-06T11:31:35.850" LastActivityDate="2017-12-06T11:31:35.850" Title="Repeat n time a mapping starting with a count" Tags="|key-bindings|count|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7878" PostTypeId="2" ParentId="7877" CreationDate="2016-05-20T06:46:45.653" Score="9" Body="&lt;p&gt;You can use the expression register for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :nnoremap &amp;lt;F8&amp;gt;  @='3w'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will use the expression register to create a repeatable mapping you can prefix with a number:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 2&amp;lt;F8&amp;gt; will move 6 words&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A mapping in vim will replace the meaning of a key/sequence of key pressed. So when you do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;F8&amp;gt; 3w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2&amp;lt;F8&amp;gt;&#xA;23w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will convert the &lt;code&gt;&amp;lt;F8&amp;gt;&lt;/code&gt; to &lt;code&gt;3w&lt;/code&gt; and what you execute is &lt;code&gt;23w&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other side, when using the expression register, you end up doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 2&amp;lt;F8&amp;gt;&#xA; 2@='3w'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means, &quot;2 times, execute the content of the expression register&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess of if it has been done intentionally is that, given the meaning of mapping, it's the logical way it should execute.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-05-20T06:59:38.657" LastActivityDate="2016-05-20T06:59:38.657" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7879" PostTypeId="1" AcceptedAnswerId="7882" CreationDate="2016-05-20T07:18:49.533" Score="4" ViewCount="9848" Body="&lt;p&gt;I want to ask how to delete repeated lines in vim.&#xA;For now, I have a file which contained 12740 lines. There are only 98 unique lines, and each line is duplicated 129 times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^\(.*\)$\n\1$/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But my problem is, some unique lines are the same to each other, I don't know which lines are those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I input that command, my file becomes 95 lines, not 98 which I want. (3 lines are the same to each other, I guess, so it's also deleted).&lt;br&gt;&#xA;Any other solution?&lt;br&gt;&#xA;I'll edit if my question is still not clear enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My file:&lt;br&gt;&#xA;&lt;code&gt;-0.00697568&lt;/code&gt; - line 1&lt;br&gt;&#xA;&lt;code&gt;-0.00697568&lt;/code&gt; - line 2&lt;br&gt;&#xA;&lt;code&gt;...&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;0.00697568&lt;/code&gt;  - line 131&lt;br&gt;&#xA;&lt;code&gt;0.00697568&lt;/code&gt;  - line 132&lt;br&gt;&#xA;&lt;code&gt;0.00697568&lt;/code&gt;  - line 133&lt;br&gt;&#xA;&lt;code&gt;...&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;0.020909881&lt;/code&gt; - line 261&lt;br&gt;&#xA;&lt;code&gt;0.020909881&lt;/code&gt; - line 262&lt;br&gt;&#xA;&lt;code&gt;...&lt;/code&gt;&lt;br&gt;&#xA;  And so on.&lt;br&gt;&#xA;I need to keep the 130n+1 line, from n=0 until n=97.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; I need the lines to keep their order so a solution sorting the lines would not be an acceptable one.&lt;/p&gt;&#xA;" OwnerUserId="7575" LastEditorUserId="7575" LastEditDate="2016-05-20T09:58:35.717" LastActivityDate="2016-09-28T23:16:53.780" Title="delete repeated line in vim, keep the n-th line in Vim" Tags="|regular-expression|normal-mode|" AnswerCount="4" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="7881" PostTypeId="2" ParentId="7879" CreationDate="2016-05-20T07:39:44.323" Score="3" Body="&lt;p&gt;Let's get the exact number of unique lines first.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :sort u | echo line('$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command returns the total unique lines. &#xA;In your case, this might be 95.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's do that with a macro.&#xA;Empty register &lt;code&gt;n&lt;/code&gt; first. Press &lt;code&gt;qnq&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Start recording by pressing &lt;code&gt;qn&lt;/code&gt;. (n is the register name I have chosen)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qn&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to first line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;code&gt;Y&lt;/code&gt; (same as y$) to copy till end of line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Y&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Type &lt;code&gt;:g/&lt;/code&gt; and then press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;R&lt;/kbd&gt; and &lt;code&gt;&quot;&lt;/code&gt;. The line is pasted as search pattern. Then, type &lt;code&gt;d&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/Ctrl+R&quot;/d&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;All similar lines will be deleted including that one. Clear K register by pressing qkq. Now, let's copy the line to K register.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @K=&quot;@/\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;code&gt;q&lt;/code&gt; to stop recording.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now, you can press count and &lt;code&gt;@n&lt;/code&gt;. (We have obtained the count in the beginning through sort u and echo commands.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;98@n&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;File will be emptied and all the contents will be stored in @K. Go to insert mode and type Ctrl+R and k. The contents of register is inserted there.&#xA;  i&#xA;  Ctrl+R k&#xA;Now, the unique lines are pasted in file itself.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Edit: Recursive mapping is difficult for me to work with. This answer also gives what the user wanted.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="7161" LastEditDate="2016-05-20T10:46:38.537" LastActivityDate="2016-05-20T10:46:38.537" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7882" PostTypeId="2" ParentId="7879" CreationDate="2016-05-20T08:16:17.810" Score="9" Body="&lt;p&gt;To delete &lt;em&gt;n&lt;/em&gt; lines starting from every line, you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm ndd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, if I started with the numbers 1 to 10 repeated 5 times:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;1&#xA;1&#xA;1&#xA;1&#xA;2&#xA;2&#xA;2&#xA;2&#xA;2&#xA;3&#xA;3&#xA;3&#xA;3&#xA;3&#xA;4&#xA;4&#xA;4&#xA;4&#xA;4&#xA;5&#xA;5&#xA;5&#xA;5&#xA;5&#xA;6&#xA;6&#xA;6&#xA;6&#xA;6&#xA;7&#xA;7&#xA;7&#xA;7&#xA;7&#xA;8&#xA;8&#xA;8&#xA;8&#xA;8&#xA;9&#xA;9&#xA;9&#xA;9&#xA;9&#xA;10&#xA;10&#xA;10&#xA;10&#xA;10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm 4dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;2&#xA;3&#xA;4&#xA;5&#xA;6&#xA;7&#xA;8&#xA;9&#xA;10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, try &lt;code&gt;:%norm 129dd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is one of those instances where you &lt;em&gt;want&lt;/em&gt; &lt;code&gt;:%&lt;/code&gt; instead of &lt;code&gt;:g&lt;/code&gt;. &lt;code&gt;:g&lt;/code&gt; tags the lines so that modifications while running the &lt;code&gt;g&lt;/code&gt; command aren't counted for running the remaining iterations. &lt;code&gt;%&lt;/code&gt;, on the other hand, will run from every line from 1 to the end, and it will only look at the current line numbers at each iteration.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-05-21T17:45:20.083" LastActivityDate="2016-05-21T17:45:20.083" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="7883" PostTypeId="2" ParentId="7877" CreationDate="2016-05-20T08:41:24.220" Score="6" Body="&lt;p&gt;Another solution is to use the variable &lt;code&gt;v:count&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F8&amp;gt; :&amp;lt;C-u&amp;gt;execute &quot;normal! &quot; . v:count1 * 3 . &quot;w&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#v:count&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h v:count&lt;/code&gt;&lt;/a&gt;: The variable contains the count given for the last normal mode command and can thus be used to get a count before a mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the mapping uses &lt;code&gt;v:count1&lt;/code&gt; which is like &lt;code&gt;v:count&lt;/code&gt; but default to zero when no count is given.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mapping execute the normal command &lt;code&gt;normal! Xw&lt;/code&gt; where &lt;code&gt;X&lt;/code&gt; is replaced by 3 times the count given before the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; is required to remove the line range that get included when typing &lt;code&gt;:&lt;/code&gt; after a count.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also of course yes the behavior you observed is totally normal: your mapping makes Vim understand &lt;kbd&gt;F8&lt;/kbd&gt; as &lt;kbd&gt;3w&lt;/kbd&gt; when you types something before Vim as no way to understand that you want it to make a multiplication. Remember that a program can not understand your intention if you don't describes them to it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-20T11:52:05.493" LastActivityDate="2016-05-20T11:52:05.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7884" PostTypeId="1" AcceptedAnswerId="7885" CreationDate="2016-05-20T09:06:12.847" Score="4" ViewCount="561" Body="&lt;p&gt;I added something like this to my &lt;code&gt;tex.vim&lt;/code&gt; &lt;code&gt;ftplugin&lt;/code&gt; (I tried to simplify it because there are other plugins involved, but hopefully it makes sense):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set comments+=b:\\item&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; getline(&quot;.&quot;) =~ &quot;\item $&quot; ? &quot;&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;&quot; : &quot;&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when I type &lt;code&gt;\item foo&lt;/code&gt; and tap &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; another &lt;code&gt;\item&lt;/code&gt; is automatically added in the next line, and then if I tap &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; again without typing anything that last &lt;code&gt;\item&lt;/code&gt; is deleted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works great and it got me thinking that it should be like that for all comments. A second (and third and fourth) &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; when no text is entered should remove the last comment character instead of keeping adding comment lines forever. So I thought I'd write a function somewhat like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function CROrComment()&#xA;    for comment in comments&#xA;        if getline(&quot;.&quot;) =~ comment . &quot; $&quot;&#xA;            return &quot;\&amp;lt;c-w&amp;gt;\&amp;lt;c-w&amp;gt;&quot;&#xA;        endif&#xA;    endfor&#xA;    return &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then I'd use it to figure out if &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; should do a &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; or delete the last comment. This has many problems, though, some of which I can't figure out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all when I use &lt;code&gt;comments&lt;/code&gt; there it doesn't get the comment characters. I don't know how to get them to use them in the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I'd have to convert them into an array. I'd probably be able to figure that out by myself, though, for now I'm stuck at the first problem, but if anybody can help with that too it'll be even better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then there's the &lt;code&gt;return &quot;\&amp;lt;c-w&amp;gt;\&amp;lt;c-w&amp;gt;&quot;&lt;/code&gt; part, which I used to delete &lt;code&gt;\item&lt;/code&gt;, but it would be better if it adapted to the length of whatever the comment is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sorry if any of this is obvious, I just started playing around with Vim and I still don't know much about it.&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="7642" LastEditDate="2016-05-20T09:25:27.667" LastActivityDate="2016-05-20T17:46:32.480" Title="Check if current line ends in a comment" Tags="|vimscript|filetype-tex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7885" PostTypeId="2" ParentId="7884" CreationDate="2016-05-20T11:37:37.100" Score="3" Body="&lt;p&gt;I didn't test it very long, but you could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal formatoptions+=r&#xA;setlocal comments+=b:\\item&#xA;&#xA;function! CROrComment()&#xA;    for comment in map(split(&amp;amp;l:comments, ','), 'substitute(v:val, &quot;^.\\{-}:&quot;, &quot;&quot;, &quot;&quot;)')&#xA;        if getline('.') =~ '\V' . escape(comment, '\') . ' \$'&#xA;            return repeat(&quot;\&amp;lt;BS&amp;gt;&quot;, strchars(comment) + 1)&#xA;        endif&#xA;    endfor&#xA;    return &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; CROrComment()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't take into account the possible flags, so it needs to be improved but it's a start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you write &lt;code&gt;\item foo&lt;/code&gt; at the beginning of a line and hit enter, it should add a new line beginning with &lt;code&gt;\item&lt;/code&gt;, and if you write &lt;code&gt;\item&lt;/code&gt; (with a space at the end) and hit enter, it should just delete &lt;code&gt;\item&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;split(&amp;amp;l:comments, ',')&lt;/code&gt; returns a list containing the values inside the buffer-local value of the &lt;code&gt;'comments'&lt;/code&gt; option&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;map(split(...), 'substitute(...)')&lt;/code&gt; removes the flags inside each value of the list&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;if getline('.') =~ '\V' . escape(comment, '\') . ' \$'&lt;/code&gt; checks if the current line ends with a value from the list and a space (for the text to be compared literally, you have to add the very nomagic switch &lt;code&gt;\V&lt;/code&gt; and escape the possible backslashes)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;return repeat(&quot;\&amp;lt;BS&amp;gt;&quot;, strchars(comment) + 1)&lt;/code&gt; returns a sequence of backspaces to delete the comment and the space&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-05-20T17:46:32.480" LastActivityDate="2016-05-20T17:46:32.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7886" PostTypeId="2" ParentId="388" CreationDate="2016-05-20T12:27:37.477" Score="23" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/Shougo/dein.vim&quot; rel=&quot;noreferrer&quot;&gt;dein.vim&lt;/a&gt;: As a follow up of &lt;a href=&quot;https://vi.stackexchange.com/q/7869/1841&quot;&gt;this question&lt;/a&gt;, I'll add here the plugin manager made by the well-known Shougo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the README, the plugin has the following dependencies:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Vim &amp;gt;7.4 or neovim&lt;/code&gt;: while keeping Vim up to date is a good thing, it may be problematic for some users that previous versions are not supported&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;git&lt;/code&gt;: which is pretty common for a package manager&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;rsync&lt;/code&gt;: which is not as common as git&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The author claims that it is faster than NeoBundle. A benchmark can be found &lt;a href=&quot;https://github.com/junegunn/vim-startuptime-benchmark&quot; rel=&quot;noreferrer&quot;&gt;on the project's readme page&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One original concept of this plugin manager is that it does not provide any commands, but only functions: for example, to update your plugins you can't use something like &lt;code&gt;:PlugUpdate&lt;/code&gt;, you'll have to call: &lt;code&gt;:call dein#update()&lt;/code&gt;. To be honest I haven't found an explication of this design choice. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Also, someone created &lt;a href=&quot;https://github.com/haya14busa/dein-command.vim&quot; rel=&quot;noreferrer&quot;&gt;a plugin&lt;/a&gt; which provides these &quot;missing&quot; commands. I have no idea if this is a good idea or if this is against the main idea of the plugin manager but the author mentions it in the FAQ of the doc file.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Dein.vim supports getting plugins from Github (with a facilitated access to plugins from vimscript.org) and from local directories. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin manager provides some classical features like updating and disabling the plugins. It also allows the execution of hooks at installation time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that according to the FAQ, it seems you have to &lt;a href=&quot;https://github.com/Shougo/dein.vim/blob/master/doc/dein.txt#L937&quot; rel=&quot;noreferrer&quot;&gt;manually build the helptags&lt;/a&gt; of the plugins it installs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An interesting point is that the author wants dein.vim to be easy to test and to maintain so the repository also contains some test scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I'd say that this plugin manager seems to be designed to be lightweight and fast, which is interesting, but I think it is less user-friendly than &lt;a href=&quot;https://vi.stackexchange.com/a/397/1841&quot;&gt;vim-plug&lt;/a&gt; or &lt;a href=&quot;https://vi.stackexchange.com/a/391/1841&quot;&gt;Vundle&lt;/a&gt;, for example.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Oh, also, Shougo describes dein.vim as a &lt;a href=&quot;https://github.com/Shougo/dein.vim#about&quot; rel=&quot;noreferrer&quot;&gt;&quot;Dark powered Vim/Neovim plugin manager&quot;&lt;/a&gt; if any one knows what it means, feel free to edit this answer: I'm curious ;-)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-12-12T11:41:39.623" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="7887" PostTypeId="1" AcceptedAnswerId="7893" CreationDate="2016-05-20T14:27:36.027" Score="5" ViewCount="209" Body="&lt;p&gt;Haskell has a literal syntax for anonymous functions of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\pattern0 pattern1 [...] patternN -&amp;gt; expression&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which interacts oddly with vim's parenthesis text objects when &lt;code&gt;pattern0&lt;/code&gt; starts with a &lt;code&gt;(&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example in the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foldr (\(a,b) c -&amp;gt; a + b * c) 0 [ (0,1), (2,3) ]&#xA;          ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If my cursor is on the &lt;code&gt;,&lt;/code&gt; in &lt;code&gt;(a,b)&lt;/code&gt;, I'd like the normal mode command &lt;code&gt;di(&lt;/code&gt; to delete the &lt;code&gt;a,b&lt;/code&gt; and leave the cursor on the &lt;code&gt;)&lt;/code&gt;, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foldr (\() c -&amp;gt; a + b * c) 0 [ (0,1), (2,3) ]&#xA;         ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, with &lt;code&gt;cpoptions=aABceFs&lt;/code&gt;, the &lt;code&gt;\&lt;/code&gt; prevents the &lt;code&gt;(&lt;/code&gt; from matching the &lt;code&gt;)&lt;/code&gt; in &lt;code&gt;\(a,b)&lt;/code&gt;, so the entire start of the lambda expression is deleted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foldr () c -&amp;gt; a + b * c) 0 [ (0,1), (2,3) ]&#xA;       ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;cpoptions=aABceFsM&lt;/code&gt;, it's a little better as &lt;code&gt;%&lt;/code&gt; works properly, but the entire lambda expression is deleted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foldr () 0 [ (0,1), (2,3) ]&#xA;       ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get &lt;code&gt;di(&lt;/code&gt; to just delete &lt;code&gt;a,b&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="361" LastActivityDate="2016-05-20T20:04:32.533" Title="cpoptions and parenthesis text objects" Tags="|cursor-motions|options|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7888" PostTypeId="2" ParentId="7879" CreationDate="2016-05-20T18:21:46.203" Score="4" Body="&lt;p&gt;I usually solve problems like this with a macro.  Position yourself at the top of your file, then start recording with &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;.  The first &quot;q&quot; starts the recording.  The second &quot;q&quot; doesn't have to be &quot;q&quot;.  It can be any register letter, I just use &quot;q&quot; because it's convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Press &lt;kbd&gt;j&lt;/kbd&gt; to go to the second line, then &lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;9&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; to delete all the duplicates.  Then press &lt;kbd&gt;q&lt;/kbd&gt; to stop recording the macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you've taught vim how to do the operation once, and stored it in the &lt;code&gt;q&lt;/code&gt; macro.  You just have to replay the macro 97 more times, by typing &lt;kbd&gt;9&lt;/kbd&gt;&lt;kbd&gt;7&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really like macros for this sort of problem, because it's relatively easy to &lt;em&gt;do&lt;/em&gt; the action once manually, even if it's difficult to precisely &lt;em&gt;describe&lt;/em&gt; how you do it in an easily repeatable manner.  I can just record myself and let vim do the repetitious work.&lt;/p&gt;&#xA;" OwnerUserId="780" LastActivityDate="2016-05-20T18:21:46.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7889" PostTypeId="1" AcceptedAnswerId="13012" CreationDate="2016-05-20T18:36:49.537" Score="20" ViewCount="15496" Body="&lt;p&gt;I cannot exit vim even when I type &lt;code&gt;:q!&lt;/code&gt;. I get the error &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E37: No write since last change (add ! to override)&#xA;E162: No write since last change for buffer...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think the buffer is a NetrwTreeListing readonly.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="2920" LastEditDate="2016-05-20T22:04:32.177" LastActivityDate="2017-07-23T19:49:37.057" Title="Cannot exit Vim even using q!" Tags="|netrw|quit|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7890" PostTypeId="1" AcceptedAnswerId="7892" CreationDate="2016-05-20T19:02:13.800" Score="2" ViewCount="3083" Body="&lt;p&gt;I added &lt;code&gt;let g:netrw_bufsettings = 'noma nomod nu nobl nowrap ro'&lt;/code&gt; and &lt;code&gt;set nu&lt;/code&gt; to my vimrc on my Ubuntu machine. It can display line numbers in netrw (V149).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use the same vimrc on a remote server with netrw (V125), the line numbers disappear. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make netrw (V125) display line numbers? There is no way to update netrw on the remote server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set number&lt;/code&gt; in netrw works, I wonder if there is anyway to set it in the .vimrc file.&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="1292" LastEditDate="2018-12-14T12:00:09.627" LastActivityDate="2023-10-06T16:04:59.980" Title="How to display line numbers in netrw v125 (vim7.0)?" Tags="|netrw|line-numbers|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="7891" PostTypeId="2" ParentId="7889" CreationDate="2016-05-20T19:53:45.060" Score="5" Body="&lt;p&gt;Try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bdelete!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bd!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for short. This stands for &quot;buffer delete&quot; and will close the buffer you have open. (Credit goes to &lt;a href=&quot;https://stackoverflow.com/a/29868056/3524982&quot;&gt;Emil Asmussen&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, you should be able to do &lt;code&gt;:q!&lt;/code&gt; as normal.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-05-20T19:53:45.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7892" PostTypeId="2" ParentId="7890" CreationDate="2016-05-20T19:57:44.583" Score="4" Body="&lt;p&gt;Is there any reason that &lt;code&gt;:set number&lt;/code&gt; doesn't work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I see what you mean @user3813057. Netrw has a lot of control over its buffer, so we have to be a bit tricky when doing things that it doesn't support (or in your case, that it doesn't support &lt;em&gt;yet&lt;/em&gt;). I do have a couple of ways of doing this, but they're all kind of hacky. So take it or leave it I guess. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do anything based on an autocmd, it's likely that netrw is doing something as well and will overwrite whatever you did. So we either have to base our operation on something else or make &lt;strong&gt;sure&lt;/strong&gt; that we get the last say in setting options. I have a way to do both, but again, they're pretty hacky.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt; First method: Timer&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Let's start with the simpler of the two:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set updatetime=100&#xA;autocmd CursorHold * if (&amp;amp;filetype == 'netrw' &amp;amp;&amp;amp; &amp;amp;number == 0) | set number | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;set updatetime=100&lt;/code&gt;: this times (in milliseconds) how long it's been&#xA;since the user has typed something. If it gets to zero, it writes the&#xA;swp file to the disk and calls the &lt;code&gt;CursorHold&lt;/code&gt; autocmd.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;autocmd CursorHold ...&lt;/code&gt;: This line runs a command everytime the&#xA;&lt;code&gt;CursorHold&lt;/code&gt; event is triggered. It checks if it's in a netrw buffer&#xA;and the number option is off. If so, it sets the option.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This works pretty well, but as stated above, it's also changing how often the swp file gets written to disk, and if anything else is using the &lt;code&gt;CursorHold&lt;/code&gt; event, it could mess that up too. You can mess with the amount of time a bit and see what works best for you.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt; Second method: Controlling netrw &lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The next way is something that I'm doing currently in my vimrc, but some might be queasy about because we're actually grabbing the reins of netrw and doing a lot of the work for our self. I'm doing this because I wanted netrw to point at the file I just came from instead of starting at the beginning of the list every time. However, we can use this same technique to turn on the number option.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Ex :call Netrw()&#xA;function! Netrw()&#xA;   Explore&#xA;   set number&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This part is not so bad. It simply overrides the &lt;code&gt;:Ex&lt;/code&gt; command to make sure that once the &lt;code&gt;Explore&lt;/code&gt; operation is complete it sets the number option. The only problem is this will only work for the first page of netrw. As soon as you navigate to a different directory, netrw will turn off line numbers again. To complicate matters, netrw is using its own internal functions, making harder to replicate. But let's try anyway. :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup netrw_remap&#xA;   autocmd!&#xA;   autocmd filetype netrw call Remap_netrw()&#xA;augroup END&#xA;&#xA;function! Remap_netrw()&#xA;   noremap &amp;lt;buffer&amp;gt; -     :call NumberExplore()&amp;lt;CR&amp;gt;&#xA;   noremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt;  :call NumberInspect()&amp;lt;CR&amp;gt;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a good start, we now have control over what &lt;code&gt;-&lt;/code&gt; and &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; do when in a netrw buffer. Now we can rewrite them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NumberExplore()&#xA;   if (expand('%') != '')&#xA;      cd %&#xA;   endif&#xA;   call netrw#LocalBrowseCheck(expand('%:p:h:h'))&#xA;   set number&#xA;endfunction&#xA;&#xA;function! NumberInspect()&#xA;   if (expand('%') != '')&#xA;      cd %&#xA;   endif&#xA;   let file = getline('.')&#xA;   &quot; Get line that cursor is on&#xA;   if (file =~ '/$')&#xA;      &quot; If the line ends in a / then treat it like a directory&#xA;      exec &quot;call netrw#LocalBrowseCheck('&quot; . fnamemodify(file, &quot;:p&quot;). &quot;')&quot;&#xA;   else&#xA;      &quot; If the line doesn't end in a / then treat it like a file&#xA;      exec &quot;edit &quot;. fnamemodify(file, &quot;:p&quot;)&#xA;   endif&#xA;   set number&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A few notes for clarification:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;netrw#LocalBrowseCheck&lt;/code&gt; is netrw's internal navigation function. &lt;/li&gt;&#xA;&lt;li&gt;We use &lt;code&gt;cd %&lt;/code&gt; to make sure all paths are correct when navigating. &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;exec&lt;/code&gt; is a function that runs other functions. It allows us to use&#xA;parameters that are evaluated at runtime. &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;fnamemodify()&lt;/code&gt; is a great function for extending file names to their full path.&lt;/li&gt;&#xA;&lt;li&gt;In the expression &lt;code&gt;expand('%:p:h:h)&lt;/code&gt; the &lt;code&gt;%&lt;/code&gt; stands for the current file, the &lt;code&gt;:p&lt;/code&gt; fills the whole absolute path, &lt;code&gt;:h&lt;/code&gt; removes the last slash or directory/file name. So in our case the first &lt;code&gt;:h&lt;/code&gt; removes the slash and the second one removes the directory name making us go up one directory.&lt;/li&gt;&#xA;&lt;li&gt;On a side note, make sure you have &lt;code&gt;syntax on&lt;/code&gt;. I'm not sure why, but this doesn't work without it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now whenever you navigate, it will call netrw's internal navigation functions and then tops it off with a &lt;code&gt;set number&lt;/code&gt; giving us the desired result. ^.^&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I know this was an &lt;em&gt;extremely&lt;/em&gt; long-winded answer to something that you just wanted a quick and dirty solution for. Unfortunately, the best solution is only enabled in a later version of netrw (as you noted). &lt;/p&gt;&#xA;&#xA;&lt;h1&gt; Third method: Editing netrw &lt;/h1&gt;&#xA;&#xA;&lt;p&gt;There are some obvious downsides to this method, namely updating netrw would undo it, and your install of netrw will not be &quot;official&quot;, making it hard for any outsiders to help should there a be a problem. Nonetheless it is pretty simple and therefore worth mentioning. @user3813057 pointed out that you can simply edit netrw.vim found under &lt;code&gt;Vim/vim##/autoload/netrw.vim&lt;/code&gt;. There are two places where netrw specifies &lt;code&gt;nonu&lt;/code&gt;. You can either take this command out to have full control over the numbering, or you can change it to &lt;code&gt;nu&lt;/code&gt; to make netrw always turn on the numbers.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="18875" LastEditDate="2018-12-14T10:48:06.480" LastActivityDate="2018-12-14T10:48:06.480" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="7893" PostTypeId="2" ParentId="7887" CreationDate="2016-05-20T20:04:32.533" Score="4" Body="&lt;p&gt;This is a bug in vim that was &lt;a href=&quot;http://ftp.vim.org/vim/patches/7.4/7.4.662&quot; rel=&quot;nofollow&quot;&gt;patched in version 7.4.662&lt;/a&gt;, update and &lt;code&gt;di(&lt;/code&gt; will work as desired.&lt;/p&gt;&#xA;" OwnerUserId="361" LastActivityDate="2016-05-20T20:04:32.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7894" PostTypeId="1" AcceptedAnswerId="7895" CreationDate="2016-05-20T21:17:35.023" Score="5" ViewCount="7031" Body="&lt;p&gt;I have recently installed &lt;strong&gt;YouCompleteMe&lt;/strong&gt; and can't figure out how to disable its error checking feature. I am developing in C++ and wanted to use &lt;strong&gt;Neomake&lt;/strong&gt; as my checker.&lt;/p&gt;&#xA;" OwnerUserId="7563" LastEditorUserId="205" LastEditDate="2016-05-20T21:49:33.493" LastActivityDate="2016-05-20T21:49:33.493" Title="How to disable YouCompleteMe's error checking?" Tags="|plugin-you-complete-me|filetype-c++|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7895" PostTypeId="2" ParentId="7894" CreationDate="2016-05-20T21:24:29.607" Score="6" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe#the-gycm_show_diagnostics_ui-option&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;g:ycm_show_diagnostics_ui&lt;/code&gt;&lt;/a&gt; variable controls this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;The *g:ycm_show_diagnostics_ui* option&#xA;&#xA;When set, this option turns on YCM's diagnostic display features. See the&#xA;_Diagnostic display_ section in the _User Manual_ for more details.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_show_diagnostics_ui = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-05-20T21:24:29.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7896" PostTypeId="1" AcceptedAnswerId="7897" CreationDate="2016-05-20T21:31:07.923" Score="2" ViewCount="235" Body="&lt;p&gt;I do &lt;code&gt;vim .vimrc&lt;/code&gt; and my &lt;code&gt;vimrc&lt;/code&gt; opens with &lt;code&gt;formatoptions=jcroql&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I do &lt;code&gt;:source .vimrc&lt;/code&gt; and check the &lt;code&gt;formatoptions&lt;/code&gt; again; they changed to &lt;code&gt;tcq&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know there's nothing in my file that changes &lt;code&gt;formatoptions&lt;/code&gt;... and even if there were it should already happen when I open it the first time, right? So how come it opens one way and when I source it it changes to another? Is this supposed to happen? How do I fix it?&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="205" LastEditDate="2016-05-20T21:48:44.850" LastActivityDate="2016-05-20T21:48:44.850" Title="Sourcing vimrc changes vimrc's formatoptions" Tags="|vimrc|options|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7897" PostTypeId="2" ParentId="7896" CreationDate="2016-05-20T21:46:40.900" Score="3" Body="&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27formatoptions%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h formatoptions&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;                                        'formatoptions' 'fo'&#xA;'formatoptions' 'fo'    string (Vim default: &quot;tcq&quot;, Vi default: &quot;vt&quot;)&#xA;                        local to buffer&#xA;                        {not in Vi}&#xA;…&#xA;        NOTE: This option is set to the Vi default value when 'compatible' is&#xA;        set and to the Vim default value when 'compatible' is reset.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, if your &lt;code&gt;vimrc&lt;/code&gt; contains &lt;code&gt;set nocompatible&lt;/code&gt;, it's likely that caused Vim to set &lt;code&gt;fo&lt;/code&gt; to the Vim default (&lt;code&gt;tcq&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, try these commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set formatoptions=jcroql&#xA;set nocompatible&#xA;set formatoptions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  formatoptions=tcq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-05-20T21:46:40.900" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7898" PostTypeId="1" AcceptedAnswerId="7912" CreationDate="2016-05-20T22:37:21.330" Score="3" ViewCount="1233" Body="&lt;p&gt;Neovim has a very handy terminal emulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal mode, I can use all the read-only vim commands on the output, like scrolling or going to the file under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But more often than not, I want to delete some lines. Is it possible?&lt;/p&gt;&#xA;" OwnerUserId="7318" LastActivityDate="2023-07-24T13:22:12.167" Title="Is it possible to edit a terminal buffer in normal mode?" Tags="|neovim|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7899" PostTypeId="1" AcceptedAnswerId="8032" CreationDate="2016-05-21T00:50:16.993" Score="10" ViewCount="351" Body="&lt;p&gt;I use &lt;code&gt;tmux&lt;/code&gt; for the most part instead of using &lt;code&gt;vim&lt;/code&gt; tabs and splits. Does vim have the ability to share completions (via &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;) between running instances? Is there a way to set it up where each of the &lt;code&gt;vims&lt;/code&gt; are communicating with the server &lt;code&gt;vim&lt;/code&gt;.?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="4472" LastEditDate="2017-09-14T06:10:59.310" LastActivityDate="2017-09-14T06:10:59.310" Title="Share completions between running vim instances" Tags="|autocompletion|tmux|clientserver|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7900" PostTypeId="1" AcceptedAnswerId="7901" CreationDate="2016-05-21T01:41:47.847" Score="5" ViewCount="176" Body="&lt;p&gt;Let's say I have a window layout like below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[1][2]&#xA;[3..3]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to expand window 2 to look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[1][2]&#xA;[3][2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So window 2 will now be full height&lt;/p&gt;&#xA;" OwnerUserId="584" LastActivityDate="2016-05-21T02:11:26.473" Title="Can you increase the span of a window?" Tags="|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7901" PostTypeId="2" ParentId="7900" CreationDate="2016-05-21T02:11:26.473" Score="7" Body="&lt;p&gt;You can do this by moving window 2 rightwards (&lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#CTRL-W_L&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;C-W&amp;gt;&amp;lt;S-L&amp;gt;&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Awincmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:wincmd L&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Initially, with focus on window 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zCgob.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zCgob.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:wincmd L&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ejnZx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ejnZx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To get back to the original arrangement from here, move window 3 downwards: focus on window 3, then &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#CTRL-W_J&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;C-W&amp;gt;&amp;lt;S-J&amp;gt;&lt;/code&gt;&lt;/a&gt; or &lt;code&gt;:wincmd J&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-05-21T02:11:26.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7902" PostTypeId="1" CreationDate="2016-05-21T04:26:19.047" Score="2" ViewCount="318" Body="&lt;p&gt;I'm writing a debugger and when hitting a breakpoint or stepping through code I'm making a system call that instructs a gVim server to jump to the current line of the file being debugged, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;system_call(&quot;gvim --remote-send +\&quot;%dG&quot; --servername DEBUG --remote-tab-silent %s&quot;,&#xA;             line_number, file_name);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is each time gVim receives the command the gVim window steals focus and I have to alt-tab or mouse-click back to the debugger window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I prevent the gVim server window stealing focus when it receives at command?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I've tagged the question with &lt;code&gt;microsoft-windows&lt;/code&gt; and &lt;code&gt;linux&lt;/code&gt; as I alternate between both operating systems and as such an answer would ideally work on both.)&lt;/p&gt;&#xA;" OwnerUserId="7701" LastEditorUserId="205" LastEditDate="2016-05-22T02:12:25.120" LastActivityDate="2020-04-06T04:03:10.337" Title="How do I prevent a gVim server window stealing focus when receiving a remote command?" Tags="|gvim|window-management|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7904" PostTypeId="1" AcceptedAnswerId="7906" CreationDate="2016-05-21T11:06:58.483" Score="3" ViewCount="903" Body="&lt;p&gt;&lt;code&gt;:normal! )i&amp;lt;CR&amp;gt;&lt;/code&gt; will go to the start of the next sentence and insert the actual characters &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I modify this to insert a line break instead?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I've also tried &lt;code&gt;\n&lt;/code&gt; and &lt;code&gt;\r&lt;/code&gt; instead of &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, and escaping them like &lt;code&gt;\\r&lt;/code&gt;, but in every case, what's inserted is the characters themselves.)&lt;/p&gt;&#xA;" OwnerUserId="7702" LastActivityDate="2016-05-21T17:05:13.543" Title="How can I insert a line with `:normal!`?" Tags="|normal-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7905" PostTypeId="1" AcceptedAnswerId="7907" CreationDate="2016-05-21T15:02:56.973" Score="4" ViewCount="503" Body="&lt;p&gt;When I run the following command ex:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:! some_command&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's somewhat annoying the message:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Press ENTER or type command to continue&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is there a way to automatically return to current buffer without press &lt;kbd&gt;ENTER&lt;/kbd&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2016-05-21T17:15:32.187" Title="Autoreturn after external command" Tags="|external-command|" AnswerCount="1" CommentCount="1" ClosedDate="2016-05-28T18:13:22.593" ContentLicense="CC BY-SA 3.0" />
  <row Id="7906" PostTypeId="2" ParentId="7904" CreationDate="2016-05-21T16:58:49.803" Score="8" Body="&lt;p&gt;To expand &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; as a newline, you need to use commands which evaluate it as an expression. In this case, you need &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Aexecute&quot;&gt;&lt;code&gt;execute&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 'normal!' &quot;)i\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, as romainl says, you enter a literal newline using &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; &lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;\&lt;/code&gt; before &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;. From &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#string&quot;&gt;&lt;code&gt;:h string&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;string                                  string String expr-string E114&#xA;------&#xA;&quot;string&quot;                string constant         expr-quote&#xA;&#xA;Note that double quotes are used.&#xA;&#xA;A string constant accepts these special characters:&#xA;\...    three-digit octal number (e.g., &quot;\316&quot;)&#xA;…&#xA;\n      newline &amp;lt;NL&amp;gt;&#xA;\r      return &amp;lt;CR&amp;gt;&#xA;…&#xA;\&amp;lt;xxx&amp;gt;  Special key named &quot;xxx&quot;.  e.g. &quot;\&amp;lt;C-W&amp;gt;&quot; for CTRL-W.  This is for use&#xA;        in mappings, the 0x80 byte is escaped.  Don't use &amp;lt;Char-xxxx&amp;gt; to get a&#xA;        utf-8 character, use \uxxxx as mentioned above.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, with &lt;code&gt;:exe&lt;/code&gt;, you can also use &lt;code&gt;\r&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 'normal!' &quot;)i\r&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-05-21T17:05:13.543" LastActivityDate="2016-05-21T17:05:13.543" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7907" PostTypeId="2" ParentId="7905" CreationDate="2016-05-21T17:15:32.187" Score="5" Body="&lt;p&gt;A way to do this is to use the &lt;code&gt;silent&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent !ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will return to normal mode right after the command (here &lt;code&gt;ls&lt;/code&gt; has been executed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case the command produces output, you may want to force a redraw of the screen with the &lt;code&gt;redraw&lt;/code&gt; command: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;silent !ls&quot; | redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can even create a new command that does this for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ Silent execute 'silent &amp;lt;args&amp;gt;' | redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And use it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Silent !ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-05-21T17:15:32.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7908" PostTypeId="1" CreationDate="2016-05-21T18:57:41.613" Score="0" ViewCount="150" Body="&lt;p&gt;First, I did:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% vim ~/.vim/cvim/c-support/templates/Templates&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From there, I changed my User Macros to their desired values. I then saved my changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim, I went to Normal Mode and entered:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!vim test.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, my header created with User Macros did not appear at the top of the file. I am using &lt;a href=&quot;http://www.thegeekstuff.com/2009/01/tutorial-make-vim-as-your-cc-ide-using-cvim-plugin/&quot; rel=&quot;nofollow&quot;&gt;http://www.thegeekstuff.com/2009/01/tutorial-make-vim-as-your-cc-ide-using-cvim-plugin/&lt;/a&gt; as a reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, here: &lt;a href=&quot;https://lug.fh-swf.de/vim/vim-c/csupport.html#csupport-templates&quot; rel=&quot;nofollow&quot;&gt;https://lug.fh-swf.de/vim/vim-c/csupport.html#csupport-templates&lt;/a&gt;, section 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I put the following into my .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:C_Styles = { '.c,.h' : 'C', '.cc,.cpp,.c++,.C,.hh,.h++,*.H' : 'CPP' }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this did not work, and my heading is not inserted into my newly created C source files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this is a newbie question, but any help would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="7707" LastEditorUserId="1841" LastEditDate="2016-05-21T19:07:36.247" LastActivityDate="2016-05-23T08:19:00.147" Title="Header from Templates not appearing in newly created C source files" Tags="|vimrc|snippets|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7909" PostTypeId="2" ParentId="7464" CreationDate="2016-05-22T10:54:19.000" Score="5" Body="&lt;p&gt;This appears to be an issue that was introduced in a patch that was picked up by Ubuntu 16.04 and fixed in another patch.  Here's a link to the &lt;a href=&quot;https://github.com/vim/vim/issues/704&quot;&gt;bug report&lt;/a&gt;.  It was fixed in &lt;a href=&quot;https://github.com/vim/vim/commit/baec5c1768098f9dd867b465aaabfdfb294f10c2&quot;&gt;patch 1716&lt;/a&gt; but, unfortunately, 16.04 shipped with patches only up to 1689.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully there'll be an update soon.  Otherwise it's compile the latest version from source, I'm afraid.&lt;/p&gt;&#xA;" OwnerUserId="7710" LastActivityDate="2016-05-22T10:54:19.000" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7911" PostTypeId="2" ParentId="7656" CreationDate="2016-05-23T01:15:50.613" Score="10" Body="&lt;p&gt;I was missing a trailing slash on both &lt;code&gt;wiki_?.path&lt;/code&gt; values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I corrected my ~/.vimrc as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vimwiki &#xA;let wiki_1 = {}&#xA;let wiki_1.path = '~/vimwiki/'&#xA;let wiki_1.path_html = '~/vimwiki_html/'&#xA;&#xA;let wiki_2 = {}&#xA;let wiki_2.path = '~/private/'&#xA;let wiki_2.path_html = '~/private_html/'&#xA;&#xA;let g:vimwiki_list = [wiki_1, wiki_2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After a trailing slash is added, the correct entries show up in  the gvim &lt;code&gt;Vimwiki &amp;gt; Open index &amp;gt; menu&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ynkwK.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ynkwK.png&quot; alt=&quot;gvim Vimwiki Open index menu with options matching Leaderws&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What threw me was that in vim and gvim when I pressed &lt;code&gt;\ws&lt;/code&gt; I got the result I expected, yet the gvim menu showed a different set of wikis.  Both methods show the same result set now.&lt;/p&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="6590" LastEditDate="2016-05-24T22:37:32.377" LastActivityDate="2016-05-24T22:37:32.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7912" PostTypeId="2" ParentId="7898" CreationDate="2016-05-23T06:53:55.187" Score="3" Body="&lt;p&gt;You can use this mapping to copy the content of the terminal buffer into a new buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tnoremap &amp;lt;C-U&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;:%y \| vertical new \| normal! P&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; goes back to normal mode so you can use any normal mode command you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%y&lt;/code&gt; copy the content of the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vertical new&lt;/code&gt; create a new vertical split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;normal! P&lt;/code&gt; paste the previously yanked text into the buffer.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-05-23T06:53:55.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7913" PostTypeId="2" ParentId="7908" CreationDate="2016-05-23T07:58:03.593" Score="2" Body="&lt;p&gt;&lt;em&gt;Discl. I'm maintaining an &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;alternative&lt;/a&gt; to c.vim. As such, I don't use it and I don't know its intricacies.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you've installed c.vim into &lt;code&gt;~/.vim/cvim&lt;/code&gt; and if by &lt;code&gt;% vim ~/.vim/cvim/c-support/templates/Templates&lt;/code&gt; you are editing the original files shipped with the plugin, it's probably a bad idea. Indeed, next time you'll update the plugin, you'll lose all your changes. After a quick survey of the source code though, it seems to be the expected way of using it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beside, &lt;code&gt;~/.vim/cvim&lt;/code&gt; is a really odd place to install a plugin. Are you sure the plugin is working correctly? Reading your question, I'm not sure this is the case. (This reminds me of this Q/A: &lt;a href=&quot;https://vi.stackexchange.com/questions/2374/why-is-the-c-vim-plugin-not-working&quot;&gt;Why is the c.vim plugin not working?&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-05-23T08:19:00.147" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7914" PostTypeId="1" AcceptedAnswerId="7915" CreationDate="2016-05-23T17:26:20.973" Score="5" ViewCount="14086" Body="&lt;p&gt;I want to remove repeated spaces, but not if they occur at the start of a line (indendation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 1&#xA;  hi  there      i      have    spaces&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 1&#xA;  hi there i have spaces&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've gotten as far as &lt;code&gt;s/^\s\+/ /g&lt;/code&gt;, but that deletes only duplicate spaces that &lt;em&gt;are&lt;/em&gt; at the start of the line. I need to know how to negate the &lt;code&gt;^&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7702" LastActivityDate="2017-09-27T14:53:11.917" Title="Regex to match spaces that are NOT at the beginning of a line?" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7915" PostTypeId="2" ParentId="7914" CreationDate="2016-05-23T18:13:47.273" Score="12" Body="&lt;p&gt;You don't need to match the start of the line. Instead, match any non-whitespace character. This should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\S\zs\s\{2,}/ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\S\zs&lt;/code&gt; match any non-whitespace character and set start of pattern match after the character&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s\{2,}&lt;/code&gt; match at two or more spaces&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-05-23T18:13:47.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7917" PostTypeId="1" AcceptedAnswerId="7919" CreationDate="2016-05-23T23:13:45.987" Score="1" ViewCount="316" Body="&lt;p&gt;I have this in my &lt;code&gt;vimrc&lt;/code&gt; for setting the status line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set laststatus=2&#xA;set statusline=%3(%{mode()}\ %)&#xA;set statusline+=%1*\ %F&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;normal&lt;/code&gt; and &lt;code&gt;visual&lt;/code&gt; mode (but also for all other modes tested):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4LWyt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4LWyt.png&quot; alt=&quot;Normal&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/6bLPS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6bLPS.png&quot; alt=&quot;Visual Line&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for &lt;code&gt;visual block&lt;/code&gt; and &lt;code&gt;select block&lt;/code&gt; mode, the display is broken: the trailing space is not displayed with the same color:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xNO22.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xNO22.png&quot; alt=&quot;Visual Block&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the issue here?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-05-24T07:45:52.840" Title="Status line group constant width" Tags="|vimrc|statusline|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7918" PostTypeId="1" CreationDate="2016-05-24T02:33:23.057" Score="1" ViewCount="437" Body="&lt;p&gt;&lt;code&gt;vim-erlang-runtime&lt;/code&gt; is set up for indenting Erlang files that works for already existing files and does not work for any newly created ones. To elaborate, when starting a function body whenever I modify an old file, the indent of the new line is 4 spaces and in a new file it is 8 and it seems like vim ignores any rules.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% old file&#xA;func() -&amp;gt;&#xA;␣␣␣␣&#xA;    code.&#xA;&#xA;% new file&#xA;func() -&amp;gt;&#xA;␣␣␣␣␣␣␣␣&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I compared the files side by side, removed the plugin, added static indent instructions in &lt;code&gt;.vimrc&lt;/code&gt; and then reinstalled it but no joy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only difference in the output of &lt;code&gt;:set&lt;/code&gt;s is that the old files show &lt;code&gt;shiftwidth=4&lt;/code&gt; (as it should) but the new files are missing this option. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype&#xA;filetype detection:ON  plugin:ON  indent:ON&#xA;&#xA;:set filetype&#xA;filetype=erlang&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have used the exact same configuration on Fedora, Arch and this issue is on Ubuntu (whether it matters or not). I always clone my dotfiles from github and I haven't touch them for a while now. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sure there's an easy solution to this that I am overlooking but after 90 minutes of research and trying things out I am still not closer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Manually setting &lt;code&gt;:set shiftwidth=4&lt;/code&gt; works but it sucks to issue this command every time I open a new file.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE ===&#xA;Removed all the plugin, installed vim-erlang-runtime plugin only and then reinstalled all, and now it works on new files as well. Except for the one file that was created before all this where it still doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... aaand by changing directory and starting a new file with &lt;code&gt;touch&lt;/code&gt;, I am back to square one. SibiCoder's workaround does the job perfectly but it would be good to know what causes this.&lt;/p&gt;&#xA;" OwnerUserId="7706" LastEditorUserId="7706" LastEditDate="2016-05-24T03:33:32.200" LastActivityDate="2016-09-28T15:27:05.813" Title="Vim indent rules apply to existing files but not to new ones" Tags="|indentation|filetype|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7919" PostTypeId="2" ParentId="7917" CreationDate="2016-05-24T07:45:52.840" Score="2" Body="&lt;p&gt;&lt;code&gt;mode()&lt;/code&gt; returns a literal &lt;code&gt;Ctrl-V&lt;/code&gt; for visual block mode and a literal &lt;code&gt;Ctrl-S&lt;/code&gt; for select mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should write a custom wrapper around &lt;code&gt;mode()&lt;/code&gt; to avoid side effects.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-05-24T07:45:52.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7920" PostTypeId="1" AcceptedAnswerId="7921" CreationDate="2016-05-24T09:14:10.677" Score="1" ViewCount="529" Body="&lt;p&gt;I have a function that detects the name of the subroutine* my cursor is in, thanks to &lt;a href=&quot;https://vi.stackexchange.com/a/7442/7128&quot;&gt;this answer&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SubName() abort&#xA;   if &amp;amp;syntax !='fortran'&#xA;      return &quot;&quot;&#xA;   endif&#xA;   let prev_sub_line_num = search('subroutine ', 'bcnW')&#xA;   return matchstr(getline(prev_sub_line_num), 'subroutine \zs\w\+')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is used in my statusline as follows :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;syntax== 'fortran'&#xA;   set statusline+=%8*\ %{SubName()}\ &#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works well, excepted that I have to &lt;em&gt;source my &lt;code&gt;.vimrc&lt;/code&gt; file upon opening VIM every time I want it to work&lt;/em&gt;. I would like some sort of 'autocmd' that would save me this sourcing at each session I'm starting -- and also understanding what's happening !&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I naively tried &lt;code&gt;autocmd BufWritePre,BufRead *.f* call SubName()&lt;/code&gt; but it does not seem to change anything).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;user9433424 gave me an &lt;a href=&quot;https://vi.stackexchange.com/a/7921/7128&quot;&gt;explanation as well as a solution&lt;/a&gt; through taking away the test around the &lt;code&gt;set statusline&lt;/code&gt; command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works, but now when opening a &lt;em&gt;non-fortran&lt;/em&gt; file I get a small empty zone in my statusline with color highlight &lt;code&gt;%8&lt;/code&gt;... And it's a little ugly. I understand why but I'd love to get rid of it !&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Maybe I could just add a &lt;code&gt;else&lt;/code&gt; case in my &lt;code&gt;SubName&lt;/code&gt; function like :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;else&#xA;   return &quot;You're awesome !&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it was not really my initial plan !)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit II&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As asked by user9433424, here is the part of my &lt;code&gt;.vimrc&lt;/code&gt; that concerns my statusline.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/2wtJS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2wtJS.png&quot; alt=&quot;Here one can see the little empty space in purple&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*&quot;subroutine&quot; is the name for Fortran's subprograms.&lt;/p&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-05-24T10:19:50.360" Title="Statusline function only displayed when sourcing .vimrc" Tags="|vimscript|vimrc|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7921" PostTypeId="2" ParentId="7920" CreationDate="2016-05-24T09:41:24.877" Score="2" Body="&lt;p&gt;&lt;code&gt;'syntax'&lt;/code&gt; is an option which is local to a buffer, I don't think you should test it inside your &lt;code&gt;vimrc&lt;/code&gt; but inside your function &lt;code&gt;SubName()&lt;/code&gt;, which you already did. So, you probably don't need the test around &lt;code&gt;set statusline+=%8*\ %{SubName()}\&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside your &lt;code&gt;vimrc&lt;/code&gt;, you could simply write this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SubName()&#xA;   return &amp;amp;syntax !=# 'fortran' ? '' : ' ' . matchstr(getline(search('subroutine ', 'bcnW')), 'subroutine \zs\w\+') . ' '&#xA;endfunction&#xA;&#xA;set statusline+=%8*%{SubName()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The reason why it didn't work is because during the startup, when Vim sources your &lt;code&gt;vimrc&lt;/code&gt;, it's not in the context of a &lt;code&gt;fortran&lt;/code&gt; buffer. The test fails and no &lt;code&gt;%{SubName()}&lt;/code&gt; item is added to the statusline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The test has to be performed in the context of the current buffer, inside the function.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The reason why, when opening a non-fortran file, you get a small empty zone in your statusline with color highlight &lt;code&gt;%8&lt;/code&gt; is because you didn't move the spaces around the item from your &lt;code&gt;'statusline'&lt;/code&gt; option to your function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your previous code, you had this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%8*\ %{SubName()}\ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The backslash and space before and after the &lt;code&gt;%{SubName()}&lt;/code&gt; item shouldn't be there, they should be inside your function where the syntax test is realised.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the code I wrote earlier, there's this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   return &amp;amp;syntax !=# 'fortran' ? '' : ' ' . matchstr(getline(search('subroutine ', 'bcnW')), 'subroutine \zs\w\+') . ' '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before and after the &lt;code&gt;matchstr()&lt;/code&gt; function, there's &lt;code&gt;' ' .&lt;/code&gt; and &lt;code&gt;. ' '&lt;/code&gt;. These are the original spaces which will be added around your subroutine name, but only if you're inside a fortran file.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-05-24T10:19:50.360" LastActivityDate="2016-05-24T10:19:50.360" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7922" PostTypeId="1" AcceptedAnswerId="8076" CreationDate="2016-05-24T09:51:22.903" Score="13" ViewCount="3646" Body="&lt;p&gt;I work a lot with visual block mode, which I find really useful for quick changes across a lot of lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But something I'm struggling to do is inserting a newline like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Selection is noted as &lt;code&gt;[]&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Some [t]ext&#xA;Some [t]ext&#xA;Some [t]ext&#xA;Some [t]ext&#xA;Some [t]ext&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I press &lt;code&gt;I&lt;/code&gt; and I can add some text to be inserted before the &lt;code&gt;t&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Some other text&#xA;Some [t]ext&#xA;Some [t]ext&#xA;Some [t]ext&#xA;Some [t]ext&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; I get the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Some other text&#xA;Some other text&#xA;Some other text&#xA;Some other text&#xA;Some other text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But now if I press &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; instead of the text I want to add, the newline is inserted as desired but not for the other lines. The result is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Some &#xA;text&#xA;Some text&#xA;Some text&#xA;Some text&#xA;Some text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you know why this isn't working?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; since it works for &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;r&lt;/code&gt; I'm not sure why is this not working...&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-03T12:24:21.097" Title="Visual block insert new line" Tags="|insert-mode|visual-block|" AnswerCount="1" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7923" PostTypeId="2" ParentId="2010" CreationDate="2016-05-24T14:41:38.050" Score="0" Body="&lt;p&gt;What worked for me was to remove this part of your settings&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('gui_running')&#xA;   set background=dark&#xA;else&#xA;   set background=dark&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am running a xfce4-terminal&lt;/p&gt;&#xA;" OwnerUserId="7735" LastEditorUserId="6698" LastEditDate="2016-05-24T15:31:22.993" LastActivityDate="2016-05-24T15:31:22.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7924" PostTypeId="1" AcceptedAnswerId="7926" CreationDate="2016-05-24T16:20:18.783" Score="9" ViewCount="2656" Body="&lt;p&gt;In &lt;a href=&quot;https://stackoverflow.com/questions/9869057/vim-linenr-and-cursorline-colour-configuration-change&quot;&gt;this Q&amp;amp;A&lt;/a&gt;, it's observed that there is a highlight group for &lt;code&gt;CursorLineNr&lt;/code&gt;, which applies to the line number for the cursor line when &lt;code&gt;set cursorline&lt;/code&gt; is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I notice that using cursorline also changes the color for another highlight group, &lt;code&gt;SpecialKey&lt;/code&gt;, which applies if you have, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; set list listchars=tab:\|_,trail:-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with this for me is I use a dark background (and so a dark cursorline).  My normal &lt;code&gt;SpecialKey&lt;/code&gt; setting is also very dark, so that the &lt;code&gt;listchar&lt;/code&gt; symbols are only marginally visible.  But using &lt;code&gt;cursorline&lt;/code&gt; &lt;em&gt;they're white&lt;/em&gt;, which makes the &lt;code&gt;trail&lt;/code&gt; char indistinguishable from having actually hit &lt;code&gt;-&lt;/code&gt;.  The trail character is used every time you type a space at the end of a line, so this is more than a minor issue; usually typing a line from beginning to end involves a number of spaces that should be easily distinguished from a dash typo while working (or vice versa, a space typo when you intended a dash).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since none of the other highlight groups seem to be affected, something like &lt;code&gt;CursorLineNr&lt;/code&gt; is presumably being applied, but looking through the &lt;code&gt;hi&lt;/code&gt; list I don't see anything appropriate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know what this is?  Better yet, does anyone know of a way to modify any highlight group for cursorline?&lt;/p&gt;&#xA;" OwnerUserId="4913" LastEditorUserId="4913" LastEditDate="2017-06-01T18:01:13.953" LastActivityDate="2019-05-02T09:55:34.230" Title="SpecialKey foreground color w/ cursorline set" Tags="|syntax-highlighting|colorscheme|whitespace|cursorline|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7925" PostTypeId="1" CreationDate="2016-05-24T16:35:11.980" Score="14" ViewCount="2261" Body="&lt;p&gt;I work on a rather large C++ project. One of the more frustrating aspects of its organization is very large functions placed inside ridiculously large files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often want to search for any instance of a particular global variable or function call, restricted to the current function. Is there a reasonably simple formula for accomplishing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I do have ctags installed and use Tagbar... which might be helpful for this)&lt;/p&gt;&#xA;" OwnerUserId="6659" LastEditorUserId="205" LastEditDate="2016-05-26T01:00:38.937" LastActivityDate="2021-06-04T17:13:42.693" Title="Quick search, limited to a C++ function" Tags="|search|filetype-c++|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7926" PostTypeId="2" ParentId="7924" CreationDate="2016-05-24T16:57:13.957" Score="8" Body="&lt;p&gt;I've been struggling with that behavior for a &lt;em&gt;long&lt;/em&gt; time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, the foreground color of &lt;code&gt;SpecialKey&lt;/code&gt; on the current line is changed to the foreground color of &lt;code&gt;Normal&lt;/code&gt; if:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;code&gt;cursorline&lt;/code&gt; option is enabled,&lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;CursorLine&lt;/code&gt; highlight group has a background color set.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've never been able to fix that behavior, no matter what I tried. The problem lies somewhere in Vim's source code.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-05-24T16:57:13.957" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7927" PostTypeId="2" ParentId="7925" CreationDate="2016-05-24T17:27:56.130" Score="10" Body="&lt;p&gt;Here's how I would do it. Add this to your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap if [[O][&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation: vnoremap means map the left hand side &lt;code&gt;if&lt;/code&gt; to the right hand side &lt;code&gt;[[mO][&lt;/code&gt; while you're in visual mode. &lt;code&gt;if&lt;/code&gt; means &lt;em&gt;In Function&lt;/em&gt;, although you can rename this if you like. &lt;code&gt;[[&lt;/code&gt; jumps to the beginning of the function. &lt;code&gt;O&lt;/code&gt; moves to the other end of your visually selected text, and then &lt;code&gt;][&lt;/code&gt; moves to the end of the function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if you want to search in a function, now you enter visual mode with &lt;code&gt;v&lt;/code&gt;, and select the whole function with &lt;code&gt;if&lt;/code&gt;. Now exit visual mode with &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, and search with &lt;code&gt;/\%V&lt;/code&gt;. &lt;code&gt;\%V&lt;/code&gt; restricts your search to the previously selected text. If you don't want to have to hit &lt;code&gt;&amp;lt;esc&amp;gt;/\%V&lt;/code&gt; you could also add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap / &amp;lt;esc&amp;gt;/\%V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, your sequence of keystrokes would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vif/foo&amp;lt;enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this will find all occurrences of foo in the current function.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The only downside to this method is that it expects the opening and closing braces to both have 0 indentation. If you regularly work with code that doesn't have this, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int foo() {&#xA;    bar()&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then this slightly more complicated version will work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap if ][ma%O'a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This only expects the closing brace to have 0 indentation. If the opening brace has indents, it still works, although it does take up a mark. If you regularly use mark 'a', you can move this e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap if ][mb%O'b&#xA;vnoremap if ][mc%O'c&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-05-26T16:23:24.467" LastActivityDate="2016-05-26T16:23:24.467" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7928" PostTypeId="1" AcceptedAnswerId="7930" CreationDate="2016-05-24T21:10:57.167" Score="1" ViewCount="5512" Body="&lt;p&gt;When I am inserting a big block of code or text, often I will want to copy and paste text from elsewhere into that block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the only way to do this to leave insert mode, go get the text and paste, then go back to insert mode?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="2920" LastEditDate="2016-05-25T02:31:27.503" LastActivityDate="2016-05-25T02:31:27.503" Title="Copying and pasting while inserting" Tags="|cut-copy-paste|insert-mode|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7929" PostTypeId="2" ParentId="7928" CreationDate="2016-05-24T21:24:15.513" Score="2" Body="&lt;p&gt;I'm not exactly sure what you want to do here, but I think you're looking for &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h i_ctrl-r&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're in insert mode, and need to copy text from a webbrowser or other application (or window). Do the copy, return to vim, and type &lt;code&gt;&amp;lt;C-R&amp;gt;*&lt;/code&gt; or &lt;code&gt;&amp;lt;C-R&amp;gt;+&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to insert something yanked earlier in vim while staying in insert mode, you might be looking for &lt;code&gt;&amp;lt;C-R&amp;gt;&quot;&lt;/code&gt; instead&lt;/p&gt;&#xA;" OwnerUserId="6659" LastActivityDate="2016-05-24T21:24:15.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7930" PostTypeId="2" ParentId="7928" CreationDate="2016-05-24T21:24:34.427" Score="7" Body="&lt;p&gt;You don't have to leave insert mode if you don't want to. While in insert mode, paste text from a register by pressing &lt;code&gt;&amp;lt;C-r&amp;gt;registername&lt;/code&gt;, e.g. &lt;code&gt;&amp;lt;C-r&amp;gt;+&lt;/code&gt; to paste from system clipboard or &lt;code&gt;&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt; to paste lines yanked inside vim (from the unnamed register).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the clarification in your comment, I would recommend that you adapt a different workflow in vim: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While being in insert mode, just type the beginning of your long constant or variable name, e.g. the first 3 characters followed by &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt;. Vim will use its built-in autocompletion to complete the word. If more than one word starts with the same sequence, press &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; repeatedly (or use &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; to select previous item).&lt;/p&gt;&#xA;" OwnerUserId="3282" LastEditorUserId="3282" LastEditDate="2016-05-24T21:36:56.677" LastActivityDate="2016-05-24T21:36:56.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7931" PostTypeId="2" ParentId="7928" CreationDate="2016-05-24T21:29:31.297" Score="0" Body="&lt;p&gt;If you want to use vim like a traditional, notepad-like editor, you can use select mode. This is like visual mode, but with your mouse, and it behaves more like a traditional editor does. Add these to your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set selectmode+=mouse&#xA;snoremap &amp;lt;C-v&amp;gt; &quot;+y&#xA;snoremap &amp;lt;C-x&amp;gt; &quot;+d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then for paste, do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoreamp &amp;lt;C-v&amp;gt; &amp;lt;C-o&amp;gt;&quot;*p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Personally, I recommend against mapping to &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; since this is really useful in insert mode. I would map it to &lt;code&gt;&amp;lt;M-v&amp;gt;&lt;/code&gt; (alt+v) but it's up to you. &lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-05-24T21:29:31.297" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7932" PostTypeId="1" AcceptedAnswerId="7974" CreationDate="2016-05-24T21:58:00.627" Score="4" ViewCount="1091" Body="&lt;p&gt;Whenever I try to source &lt;code&gt;~/.vimrc&lt;/code&gt; file when NERDTree is open, I get square brackets around the file icons like so:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bBRN8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bBRN8.png&quot; alt=&quot;square brackets around file icons&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to get rid of them? Is it a bug?&lt;/p&gt;&#xA;&lt;p&gt;I have already &lt;a href=&quot;https://github.com/scrooloose/nerdtree/issues/557&quot; rel=&quot;nofollow noreferrer&quot;&gt;posted this question on the NERDTree github repo&lt;/a&gt;, but have not received any answer yet.&lt;/p&gt;&#xA;&lt;p&gt;UPDATE: I have opened &lt;a href=&quot;https://github.com/ryanoasis/vim-devicons/issues/154&quot; rel=&quot;nofollow noreferrer&quot;&gt;an issue with the vim-devicons project&lt;/a&gt; about this.&lt;/p&gt;&#xA;" OwnerUserId="7596" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-05-27T00:39:53.443" Title="sourcing .vimrc file put square brackets around file icons" Tags="|vimrc|plugin-nerdtree|plugin-devicons|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7933" PostTypeId="2" ParentId="7925" CreationDate="2016-05-24T22:32:10.007" Score="4" Body="&lt;p&gt;Finding the beginning and end of a function can be difficult, especially in a language without a &lt;code&gt;function&lt;/code&gt; keyword… and many conflicting indent styles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your function ends with a closing brace alone on its own line (as in 10 out of the 13 styles listed &lt;a href=&quot;https://en.wikipedia.org/wiki/Indent_style#Placement_of_braces&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;), you could visually select it with something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap if /^\s*}&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;V%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From there, searching for &lt;code&gt;foo&lt;/code&gt; within your function is only a matter of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;g/foo/#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Putting it all together, we can get a rather nice mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap if /^\s*}&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;V%&#xA;nmap &amp;lt;key&amp;gt; vif:g//#&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XZMEo.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XZMEo.gif&quot; alt=&quot;search in function&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, the visual mode mapping would probably be easily fooled by a &lt;code&gt;while&lt;/code&gt; or an &lt;code&gt;if&lt;/code&gt; so it would probably benefit from a bit of polishing. Also, keeping the visual selection may not be a very good idea…&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-05-24T22:32:10.007" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7934" PostTypeId="1" AcceptedAnswerId="7935" CreationDate="2016-05-24T23:10:03.590" Score="-3" ViewCount="1442" Body="&lt;p&gt;I only use vi when I must. The commands I memorized so far are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:q!&lt;/code&gt; exit&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ZZ&lt;/code&gt; save and exit&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$&lt;/code&gt; go to end of line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^&lt;/code&gt; go to beginning of line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently installed OpenBSD 5.9. Then I had to use &lt;code&gt;vi&lt;/code&gt; or &lt;code&gt;ed&lt;/code&gt; to bring up the system because there are no other editors included. So once again I had to search for how to edit and save file with vi and I forget it already. Now I now it's something with pressing &lt;kbd&gt;ctrl&lt;/kbd&gt;  once or twice to switch between modes and &lt;code&gt;:x!!&lt;/code&gt; to save and exit. It seems that I only must remember two commands to do what I must and get out of the vi confusion but I use vi so rarely that I tend to forget it what I must know. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if I once and for all try to learn the minimal requirement of what I should know e g how to edit a file and save it, which I have been able to do and then I installed nano and emacs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, I will never forget &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;prtscr&lt;/kbd&gt;+&lt;kbd&gt;B&lt;/kbd&gt;+&lt;kbd&gt;U&lt;/kbd&gt;+&lt;kbd&gt;S&lt;/kbd&gt;+&lt;kbd&gt;I&lt;/kbd&gt;+&lt;kbd&gt;E&lt;/kbd&gt;+&lt;kbd&gt;R&lt;/kbd&gt; because of the mnemonic, how can I learn the basics of vi once and for all? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or did I miss something and vi is actually so much better that the editors I use today (Clion, emacs, nano, Sublime, Gedit). Now I find that I can do almost everything I want by just remembering these simple commands:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:x&lt;/code&gt; save and exit &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;i&lt;/code&gt; insert&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; switch to control mode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I find that I can actually use the vi editor to create a file, edit it and save it with this basic knowledge: I create and open the file by writing &lt;code&gt;vi myfile.txt&lt;/code&gt; then I can press &lt;kbd&gt;i&lt;/kbd&gt; to get into insert mode, write my text and then press &lt;kbd&gt;:&lt;/kbd&gt; &lt;kbd&gt;x&lt;/kbd&gt; to save and exit. If all goes wrong, I can press Esc twice and &lt;code&gt;:q&lt;/code&gt; to get out of vi without saving and start again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you answer or comment if this very basic knowledge of vi will be good enough to save me from googling next time or can you infer what I should or must know next time I'm on a system that only has vi?&lt;/p&gt;&#xA;" OwnerUserId="7466" LastEditorUserId="7466" LastEditDate="2018-05-30T17:48:19.400" LastActivityDate="2018-05-30T17:48:19.400" Title="How to remember the most basic commands" Tags="|insert-mode|normal-mode|" AnswerCount="2" CommentCount="4" FavoriteCount="0" ClosedDate="2016-05-26T09:01:56.757" ContentLicense="CC BY-SA 4.0" />
  <row Id="7935" PostTypeId="2" ParentId="7934" CreationDate="2016-05-25T00:18:47.100" Score="1" Body="&lt;p&gt;I had the same issue and created a help file with an easy to remember mnemonic eg sf-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=3&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0ahUKEwiS1K7N9fPMAhWFXaYKHXiICFgQFgg_MAI&amp;amp;url=http%3A%2F%2Fvim.1045645.n5.nabble.com%2Fcreating-Vim-help-files-td1188156.html&amp;amp;usg=AFQjCNEQQV-OTkxXlbJn6j5YCOKlAKzTOQ&amp;amp;sig2=r939q8pTphiIsOlQM-iT5w&amp;amp;bvm=bv.122852650,d.dGY&quot; rel=&quot;nofollow noreferrer&quot;&gt;creating Vim help files&lt;/a&gt; amongst many more&lt;/p&gt;&#xA;&#xA;&lt;p&gt;basically it's a linked list so you have a tag to the help file that loads the help, yeah OK it's probably something else in vim speak but I'm no longer a programmer :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|sf-transpose-string|   /*the Bar before &amp;amp; after denotes this as the index.&#xA;                        /* Basically a key&#xA;*sf-transpose-string*  /* The * denotes the helpt text location followed by&#xA;                      /* the help text which is unformatted&#xA;&#xA;For example to manipulate the below to change , eg, Page, Jimmy to Jimmy&#xA;Page &#xA;&#xA;Example  &#xA;------------&#xA;Plant, Robert A.&#xA;Page, Jimmy&#xA;&#xA;Use&#xA;^* :s/\v([a-z]+),\s+([a-z]+)(\s+[a-z.]+)?/\2\3 \1 ^*   &#xA;&#xA;Breaking it down:&#xA;&#xA;....&#xA;/*Separator to the next entry&#xA;==============================================================&#xA;*sf-replace-nbsp-with-space* *sf-utf* *sf-hex* /*Additional index keys link here&#xA;To replace a nbsp with a space do the following&#xA;^* :%s/\%xa0/ /g  ^*   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I save it in $VIM\vimfiles\doc with a backup elsewhere as a .txt file. Run &lt;code&gt;:helptags [dir]&lt;/code&gt; after saving it to create the help tags needed then in vim type &lt;code&gt;:h sf-vim-general-topics&lt;/code&gt; for eg to get to the help&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sure there are other ways but I've set up some mappings and functions to let me add to it on the fly. I use indent folding to make it neater and syntax colouring to makes things stand out but basic text works well&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hIIHU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hIIHU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1313" LastEditorUserId="1313" LastEditDate="2016-05-25T02:57:17.753" LastActivityDate="2016-05-25T02:57:17.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7936" PostTypeId="1" CreationDate="2016-05-25T03:29:56.437" Score="1" ViewCount="2000" Body="&lt;p&gt;in normal mode &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt; scrolls the buffer itself. from &lt;code&gt;:h CTRL-E&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;CTRL-E ...........................................* Scroll window *&lt;br&gt;&#xA;  [count] lines downwards in the buffer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would like to remap that so when I press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt; vim performs 3 x &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt;.&lt;br&gt;&#xA;I've tried&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;map &amp;lt;Ctrl-e&amp;gt; 3&amp;lt;Ctrl-e&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap &amp;lt;Ctrl-e&amp;gt; 3&amp;lt;Ctrl-e&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap ^E 3^E&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;but these have no effect, how can I perform this mapping?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2016-05-25T05:49:48.760" LastActivityDate="2016-05-25T05:49:48.760" Title="How can I define a key mapping which involves a control character?" Tags="|key-bindings|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7937" PostTypeId="2" ParentId="7936" CreationDate="2016-05-25T03:50:27.387" Score="1" Body="&lt;p&gt;in the end this worked&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;hit &lt;code&gt;:nnoremap&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;enter command line mode&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;to put a space between &lt;code&gt;nnoremap&lt;/code&gt; and control char about to come&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;to enter &quot;digraph&quot;? mode see more info see: &lt;code&gt;:h c_CTRL_k&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;enter &lt;code&gt;Ctrl-e&lt;/code&gt; twice to generate special non-printed character which appears as &lt;code&gt;^E&lt;/code&gt; but if you manually type &lt;code&gt;^E&lt;/code&gt; in your mapping it doesn't seem to work?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;at this point the command line or buffer looks like (note: the digraph generated character sequences appear a different color to normal text and they are treated as a single character not &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;E&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap ^E&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;add a 3 and another digraph generated &lt;code&gt;^E&lt;/code&gt; till command line or buffer looks like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap ^E 3^E&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2016-05-25T04:37:54.483" LastActivityDate="2016-05-25T04:37:54.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7938" PostTypeId="2" ParentId="7936" CreationDate="2016-05-25T04:55:29.597" Score="4" Body="&lt;p&gt;The reason why &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoreamp ^E 3^E&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doesn't work is because &lt;code&gt;^E&lt;/code&gt; is &lt;em&gt;two&lt;/em&gt; separate characters. You can tell because you have to hit the arrow keys twice to move backwards past it. So you are really remapping &lt;kbd&gt;^&lt;/kbd&gt; &lt;kbd&gt;E&lt;/kbd&gt; to &lt;kbd&gt;3&lt;/kbd&gt; &lt;kbd&gt;^&lt;/kbd&gt; &lt;kbd&gt;E&lt;/kbd&gt;, which is probably not what you want to do, especially since &lt;code&gt;^&lt;/code&gt; doesn't take a number argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use a digraph, this is displayed as two characters, but it is a &lt;em&gt;single&lt;/em&gt; character, which you can tell because backspace and arrow keys treat it as a single character. The other way you can tell is because vim will (&lt;em&gt;probably&lt;/em&gt;) display it as a different color. For me, this digraph appears blue, but it might be different for you depending on your setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer you came up with &lt;em&gt;works&lt;/em&gt; but it isn't the ideal way or the idiomatic way. A better way of entering a digraph is with &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;, rather than &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt;. With &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; you have to hit ctrl+e twice, but if you were to use &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; you could just hit ctrl+e one time and it would work. So that would look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap&amp;lt;space&amp;gt;&amp;lt;C-v&amp;gt;&amp;lt;C-e&amp;gt;&amp;lt;space&amp;gt;3&amp;lt;C-v&amp;gt;&amp;lt;C-e&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is a little easier than what you were doing. An even &lt;em&gt;better&lt;/em&gt; way (IMO) is to use an ASCII literal, rather then a digraph. I prefer this method since:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;It keeps your &lt;code&gt;.vimrc&lt;/code&gt; tidier.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It is easier to understand what is pressed vs what is sent to vim.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It's more readable.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It avoids nasty unicode unprintables.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You were close with your initial try of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Ctrl-e&amp;gt; 3&amp;lt;Ctrl-e&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You just got one minor detail wrong. &lt;code&gt;&amp;lt;Ctrl-e&amp;gt;&lt;/code&gt; does not describe any keystroke that vim can understand. You should have written&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-e&amp;gt; 3&amp;lt;C-e&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-05-25T04:55:29.597" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7939" PostTypeId="1" AcceptedAnswerId="7941" CreationDate="2016-05-25T05:15:49.840" Score="3" ViewCount="778" Body="&lt;p&gt;Converting odt to markdown produces &lt;code&gt;\&lt;/code&gt; around special characters. So I need to change &lt;code&gt;\\&lt;/code&gt; to &lt;code&gt;\&lt;/code&gt; and remove if &lt;code&gt;\&lt;/code&gt; is standalone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* \[\] match any of the character specified within \[\], use \[^\] to invert the selection&#xA;* \\W opposite of \\w i.e short cut for \[^a-zA-Z0-9\_\]&#xA;* \\w match alphabets (both upper &amp;amp; lower cases), numbers and \_ i.e short cut for \[a-zA-Z0-9\_\]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Expected output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* [] match any of the character specified within [], use [^] to invert the selection&#xA;* \W opposite of \w i.e short cut for [^a-zA-Z0-9_]&#xA;* \w match alphabets (both upper &amp;amp; lower cases), numbers and _ i.e short cut for [a-zA-Z0-9_]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On using &lt;code&gt;:% s/\v([^\\])\\([^\\])/\1\2/g&lt;/code&gt; I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* [\] match any of the character specified within [\], use [^] to invert the selection&#xA;* \\W opposite of \\w i.e short cut for [^a-zA-Z0-9_\]&#xA;* \\w match alphabets (both upper &amp;amp; lower cases), numbers and _ i.e short cut for [a-zA-Z0-9_\]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I use the substitution again to take care of sequences like &lt;code&gt;\[\]&lt;/code&gt; followed by &lt;code&gt;:% s/\\\\/\\/g&lt;/code&gt; to get the desired final output. Is there is a simpler way to do this?&lt;/p&gt;&#xA;" OwnerUserId="1616" LastEditorUserId="21" LastEditDate="2016-05-25T06:10:01.967" LastActivityDate="2016-06-01T08:11:34.750" Title="Reduce two consecutive character to just one and remove if that character is standalone" Tags="|regular-expression|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7940" PostTypeId="2" ParentId="7934" CreationDate="2016-05-25T05:32:26.313" Score="1" Body="&lt;p&gt;Most vi (or Vim) commands are easy to remember since the keys allotted for a function  will be related namewise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some examples for you&#xA;    Name wise relation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;By remembering the first letter of a function name, you can do it actually.&#xA;&#xA; d - delete&#xA; p - paste&#xA; v - visual&#xA; J - join&#xA; g - global&#xA; c - change&#xA; r - replace&#xA; i - insert&#xA;&#xA; g/re/p - globally, regular expressions, print&#xA;&#xA; Using object motions&#xA; aw - a word&#xA; iw - in word&#xA; a(  -  a ( and content and ending till )&#xA; i(  - text inside ( and )&#xA; a{ - a block&#xA;  ap - a paragraph&#xA;&#xA; You can combine operations with these objects.&#xA; daw - delete a word&#xA; yaw - Yank a word&#xA; di&quot; - delete inside double quotes (&quot;)&#xA; ya{ - yank a block&#xA; dap - delete a paragraph&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add a count to any of these commands, to perform that many times.&#xA;      Example. &#xA;       5daw - five times delete a word&#xA;       d5aw - same as above. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, most other commands are also easy to remember since they are related to them in some way or the other.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="7161" LastEditDate="2016-05-25T06:55:17.497" LastActivityDate="2016-05-25T06:55:17.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7941" PostTypeId="2" ParentId="7939" CreationDate="2016-05-25T06:12:42.563" Score="5" Body="&lt;p&gt;This should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\\\?\zs\\//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the first &lt;code&gt;\\\?\zs&lt;/code&gt; is used to ignore the first &lt;code&gt;\&lt;/code&gt; if there are two of them. See &lt;code&gt;:h \?&lt;/code&gt; and &lt;code&gt;:h \zs&lt;/code&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-05-25T06:12:42.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7942" PostTypeId="2" ParentId="7925" CreationDate="2016-05-25T08:32:49.903" Score="8" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/7927/626&quot;&gt;DJ McMayhem's solution&lt;/a&gt; inspired me to write my own that relies on ctags and on matchit to do a proper analysis of function boundaries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difficult part has been already done by &lt;a href=&quot;https://github.com/LucHermitte/lh-dev&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-dev&lt;/a&gt; and lh-tags for several years:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the current file is parsed through ctags with the right options&lt;/li&gt;&#xA;&lt;li&gt;we look for all function definitions in the tags database which is restricted to the tags obtained for the current file&lt;/li&gt;&#xA;&lt;li&gt;thanks to the DB, we have the start line numbers for all functions (well the &lt;code&gt;template&lt;/code&gt; and &lt;code&gt;inline&lt;/code&gt; part may be missed by ctags)&lt;/li&gt;&#xA;&lt;li&gt;with a simple iterative search (a binary search could have been done, but well, files are supposed to be &quot;short&quot;), the beginning of the current function is found&lt;/li&gt;&#xA;&lt;li&gt;And thanks to matchit plugin, its final line is found as well -- I see that universal ctags is offering a &lt;code&gt;end&lt;/code&gt; field that can be used with C, C++, Python, and Vim that could also be used to find the end of a function.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that any parts of this algorithm could be overridden on a file-type basis. i.e. the boundaries detection of python functions could search for &lt;code&gt;def&lt;/code&gt; and analyse indentation, we could just search for &lt;code&gt;function&lt;/code&gt; in javascript, and so on -- In other words, the current version also works with Java, Vim and some other languages (I still have some work to do for Python)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I define now two new mappings: a visual mode mapping, and an operator-pending mode mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;silent&amp;gt; if :&amp;lt;c-u&amp;gt;call lh#dev#_select_current_function()&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; if :&amp;lt;c-u&amp;gt;call lh#dev#_select_current_function()&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which rely on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! lh#dev#_select_current_function() abort&#xA;  let fn = lh#dev#find_function_boundaries(line('.'))&#xA;  exe fn.lines[0]&#xA;  normal! v&#xA;  exe fn.lines[1]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I spare you the several hundred lines of code of &lt;a href=&quot;https://github.com/LucHermitte/lh-dev/blob/master/autoload/lh/dev.vim#L64&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;lh#dev#find_function_boundaries()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And thanks to DJ McMayhem's mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Note that my vim settings requires two backslashes here instead of one&#xA;vnoremap / &amp;lt;esc&amp;gt;/\\%V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;we can do a &lt;code&gt;vif/pattern&lt;/code&gt; to search for &lt;code&gt;pattern&lt;/code&gt; in the current function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can also delete functions with &lt;code&gt;dif&lt;/code&gt;, yank them with &lt;code&gt;yif&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what it looks like when applied on a &lt;em&gt;realistic&lt;/em&gt; C++ function (i.e. not 0 indented): &lt;a href=&quot;https://i.stack.imgur.com/MsCux.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MsCux.gif&quot; alt=&quot;Screencast: Select C++ function&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-08-01T09:52:32.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7943" PostTypeId="2" ParentId="7925" CreationDate="2016-05-25T09:39:56.933" Score="3" Body="&lt;p&gt;Another way:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use ctags etc. to find the target function, go there&lt;/li&gt;&#xA;&lt;li&gt;move cursor forward inside the function body&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;use Osyo Manga's &lt;a href=&quot;https://github.com/osyo-manga/vim-operator-search&quot; rel=&quot;nofollow&quot;&gt;search operator&lt;/a&gt; (depends on &lt;a href=&quot;https://github.com/kana/vim-operator-user&quot; rel=&quot;nofollow&quot;&gt;vim-operator-user&lt;/a&gt;) to only search inside the current block. E.g.: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; configure the plugin (once, vimrc):&#xA; map g/ &amp;lt;Plug&amp;gt;(operator-search)&#xA;&#xA;&quot; 1. use ctags etc. to jump to the beginning of the target function;&#xA;&quot; 2. move cursor inside the function definition, then:&#xA;g/i{&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;... now you can insert your search term at the given prompt; hit &lt;code&gt;n&lt;/code&gt; to see how the search results are limited to the current provided motion/text-object. Since this is a Vim (i.e. composable) operator, if you have a good function text-object, you don't even need to move inside the definition body before searching, but directly use smthing like &lt;code&gt;g/if&lt;/code&gt;, or similar.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-05-26T16:07:56.113" LastActivityDate="2016-05-26T16:07:56.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7944" PostTypeId="1" AcceptedAnswerId="7945" CreationDate="2016-05-25T12:02:20.353" Score="10" ViewCount="1230" Body="&lt;p&gt;I regularly find myself in the situation that I am reading a help topic and see an identifier (the blue underlined words) that I want to follow with &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;. However, most of the time the identifier is not (yet) under my cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of searching for the identifier with &lt;code&gt;/part_of_identifier&amp;lt;CR&amp;gt;&lt;/code&gt; I would like to use a smarter variant, a &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;noreferrer&quot;&gt;unimpaired-like&lt;/a&gt; mapping like &lt;code&gt;]i&lt;/code&gt; to go to the next available identifier after my cursor (and &lt;code&gt;[i&lt;/code&gt; to go to the previous identifier).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I create such a mapping? Or is there a builtin command already for that? If not, do you see an alternative/smarter way how I could navigate identifiers inside Vim help files? Or can I tag all Vim's and the plugins' help files with ctags and use &lt;code&gt;]t&lt;/code&gt; somehow?&lt;/p&gt;&#xA;" OwnerUserId="3282" LastEditorUserId="1841" LastEditDate="2016-05-25T12:21:09.293" LastActivityDate="2020-11-03T21:04:24.163" Title="Jump to next identifier in Vim help files" Tags="|cursor-movement|cursor-motions|help-system|plugin-unimpaired|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7945" PostTypeId="2" ParentId="7944" CreationDate="2016-05-25T12:05:35.193" Score="9" Body="&lt;p&gt;In the help files the identifiers are actually marked as &lt;code&gt;|identifier|&lt;/code&gt; (but you don't see the &lt;code&gt;|&lt;/code&gt; because of the syntax file, use &lt;code&gt;set ft=txt&lt;/code&gt; in an help buffer to check what I'm talking about).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could then create a mapping which would look for the next pattern &lt;code&gt;\|\W*\|&lt;/code&gt; and you should be good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;nnoremap ]i :call search('\\|\\w*\\|')&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The execute and multi &lt;code&gt;\\|&lt;/code&gt; are here to deal with the escaping problems)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; @EvergreenTree came up with a much more elegant solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ]i :call search('\v\\|.{-}\\|')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It is also possible to use the same method to jump to the help topics (the string used in the commands &lt;code&gt;:h foo&lt;/code&gt;) which are delimited by &lt;code&gt;*&lt;/code&gt; characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ]i :call search('*\w*\*')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="21" LastEditDate="2016-05-25T13:06:12.683" LastActivityDate="2016-05-25T13:06:12.683" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="7946" PostTypeId="2" ParentId="7944" CreationDate="2016-05-25T12:31:10.237" Score="5" Body="&lt;p&gt;This is &lt;a href=&quot;https://github.com/joeytwiddle/rc_files/blob/master/.vim/ftplugin/help/navigate.vim&quot; rel=&quot;nofollow&quot;&gt;what I use&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As well as &lt;code&gt;|.....|&lt;/code&gt; tags, it will also stop on options of the form &lt;code&gt;'.....'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it's not pretty...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;### ~/.vim/ftplugin/help/navigate.vim ###&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; ]i /\('\zs\k\+'\\|[&amp;lt;Bar&amp;gt;]\zs\k\+[&amp;lt;Bar&amp;gt;]\)&amp;lt;CR&amp;gt;:set nohlsearch&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; [i ?\('\zs\k\+'\\|[&amp;lt;Bar&amp;gt;]\zs\k\+[&amp;lt;Bar&amp;gt;]\)&amp;lt;CR&amp;gt;:set nohlsearch&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We use &lt;code&gt;&amp;lt;zs&amp;gt;&lt;/code&gt; to land the cursor on the start of the word, rather than on the &lt;code&gt;|&lt;/code&gt; or &lt;code&gt;'&lt;/code&gt; character.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2016-05-26T03:06:20.170" LastActivityDate="2016-05-26T03:06:20.170" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7947" PostTypeId="1" CreationDate="2016-05-25T13:13:12.537" Score="9" ViewCount="199" Body="&lt;p&gt;Sometimes when entering a command in normal mode you may make a typo, for example if I intend to type &lt;code&gt;10dk&lt;/code&gt;, I might accidentally start typing &lt;code&gt;19d&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the command has not been completed/committed yet, is it possible to delete the incorrect keys using backspace, as such: &lt;code&gt;19d&amp;lt;backspace&amp;gt;&amp;lt;backspace&amp;gt;0dk&lt;/code&gt;, instead of having to hit escape and retry the command? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Side question: Is there a Vim term for the data structure which holds the current command before it's committed?&lt;/p&gt;&#xA;" OwnerUserId="7749" LastEditorUserId="7749" LastEditDate="2016-05-25T13:33:25.920" LastActivityDate="2016-05-27T14:48:38.620" Title="Use backspace to modify the current command in normal mode?" Tags="|vimrc|normal-mode|command-history|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7948" PostTypeId="1" CreationDate="2016-05-25T14:13:10.617" Score="13" ViewCount="1430" Body="&lt;p&gt;When I have to type a lot of text I often tend to keep my finger pressed on &lt;kbd&gt;shift&lt;/kbd&gt; when I write the first letter of a sentence which often give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[...]end of sentence. NEw sentence[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the &lt;code&gt;E&lt;/code&gt; of &lt;code&gt;NEw&lt;/code&gt; should be lower case. I am then trying to create a function which would detect if the second letter of the first word of the sentence I'm typing is upper case and which would lower case it. The important part would be that the correction should be done automatically while I'm typing the end of my sentence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I've tried to play with the autocommand event &lt;code&gt;InsertCharPre&lt;/code&gt; before realizing that the text can't be modified by a function triggered by this event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be a good solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; That so far I don't need to focus on edges cases like acronyms which should be in upper case or this kind of things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; I've made this, which is a not-perfect workaround:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorMovedI * call RemoveUnwantedUpper()&#xA;&#xA;function! RemoveUnwantedUpper()&#xA;    &quot; Get the current sentence&#xA;    &quot; Based on http://stackoverflow.com/a/23315227/4194289&#xA;    let l:save_clipboard = &amp;amp;clipboard&#xA;    set clipboard= &quot; Avoid clobbering the selection and clipboard registers.&#xA;    let l:save_reg = getreg('&quot;')&#xA;    let l:save_regmode = getregtype('&quot;')&#xA;&#xA;    normal! y(&#xA;    normal! ``&#xA;&#xA;    let l:sentence =getreg('&quot;') &#xA;&#xA;    call setreg('&quot;', l:save_reg, l:save_regmode)&#xA;    let &amp;amp;clipboard = l:save_clipboard&#xA;&#xA;    &quot; Check that we entered a new word (space inserted)&#xA;    if l:sentence[len(l:sentence)-1] != &quot; &quot;&#xA;       return&#xA;    endif &#xA;&#xA;    &quot; Check if the word is the first one of the sentence&#xA;    let l:size = len(split(l:sentence, &quot; &quot;))&#xA;    if l:size &amp;gt; 1 &#xA;        return&#xA;    endif&#xA;&#xA;    &quot; If the last char entered is a space (new word) remove the unwanted Upper case&#xA;   normal! bl&#xA;   normal! vu&#xA;   normal! ``&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It has a problem since the first character I enter in insert mode is moved to the end of the line, but I think that can be corrected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess now my question becomes a &lt;a href=&quot;https://vi.meta.stackexchange.com/q/1337/1841&quot;&gt;code review question&lt;/a&gt;: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I get rid of the side effect which moves the first character inserted?&lt;/li&gt;&#xA;&lt;li&gt;Is it the best method possible?&lt;/li&gt;&#xA;&lt;li&gt;This method seems to slow down Vim: how could it be improved?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-03-16T16:43:02.423" LastActivityDate="2016-05-25T16:24:33.750" Title="How to automatically lower case the second letter of a word?" Tags="|autocmd|formatting|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7949" PostTypeId="2" ParentId="7948" CreationDate="2016-05-25T15:00:16.143" Score="6" Body="&lt;p&gt;Here's a little something a cooked up really fast. It's less robust I think, but it's also much lighter. Maybe you could incorporate it into yours to make it faster? I'll probably revise this a bit when I have time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Space&amp;gt; &amp;lt;C-o&amp;gt;:call CheckCase()&amp;lt;CR&amp;gt;&amp;lt;Space&amp;gt;&#xA;&#xA;function! CheckCase()&#xA;   normal! may2b&#xA;   let l:words = getreg('&quot;')&#xA;   if l:words[0] == '.'&#xA;      normal! wlvu&#xA;   endif&#xA;   normal! `a&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not a full solution I think, but thought I would try a different approach and see if it sparked anything for you. :)&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-05-25T15:00:16.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7950" PostTypeId="2" ParentId="7948" CreationDate="2016-05-25T15:03:17.913" Score="4" Body="&lt;p&gt;I don't know how reliable it is, but you could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup FixDoubleUppercase&#xA;    autocmd!&#xA;    autocmd InsertCharPre * if v:char =~ '\u' &amp;amp;&amp;amp; getline('.') =~ '\v(\.\s+|^\s*)\u%' . col('.') . 'c' | let v:char = tolower(v:char) | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It installs an autocmd which executes the following command before you insert a character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if v:char =~ '\u' &amp;amp;&amp;amp; getline('.') =~ '\v(\.\s+|^\s*)\u%' . col('.') . 'c' | let v:char = tolower(v:char) | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The character you're about to insert is stored in the internal variable &lt;code&gt;v:char&lt;/code&gt;, and if the test:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v:char =~ '\u' &amp;amp;&amp;amp; getline('.') =~ '\v(\.\s+|^\s*)\u%' . col('.') . 'c'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... succeeds, then the autocmd assigns a new value to &lt;code&gt;v:char&lt;/code&gt;, which is &lt;code&gt;tolower(v:char)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The test checks whether you were about to insert an uppercase letter (&lt;code&gt;v:char =~ '\u'&lt;/code&gt;) and your cursor is after the first character of the first word of a sentence:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getline('.') =~ '\v(\.\s+|^\s*)\u%' . col('.') . 'c'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: I don't know if there's a difference (performance-wise) between these 2 syntaxes:  &lt;code&gt;:let myvar = test ? new_value : old_value&lt;/code&gt; and &lt;code&gt;:if test | let myvar = new_value | endif&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I once read that when you want to optimize your code, you have to use as few Ex commands as possible. So maybe the 2nd syntax (which could be counted as 3 Ex commands: &lt;code&gt;:if&lt;/code&gt;, &lt;code&gt;:let&lt;/code&gt;, &lt;code&gt;:endif&lt;/code&gt;) is slower than the 1st one, I don't know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if this is the case, you could replace the autocmd with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertCharPre * let v:char = (v:char =~ '\u' &amp;amp;&amp;amp; getline('.') =~ '\v(\.\s+|^\s*)\u%' . col('.') . 'c') ? tolower(v:char) : v:char&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-05-25T15:48:59.537" LastActivityDate="2016-05-25T15:48:59.537" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7952" PostTypeId="2" ParentId="7948" CreationDate="2016-05-25T16:19:19.193" Score="1" Body="&lt;p&gt;Another way to do it (not so automatic, and not so universal; just shorter):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;since you are writing sentences/prose, not code, have Vim activate spell checking in your text buffers&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;create a fast insert mode combo key that goes back to the last spelling mistakes, fixes it, then resumes position/state; e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-s&amp;gt; &amp;lt;Esc&amp;gt;[s1z=gi&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So now, say you start writing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;THis is a mistake|&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and you just realize the mistake - what to do? - simply hit &lt;code&gt;&amp;lt;C-s&amp;gt;&lt;/code&gt; and continue writing your sentence.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-05-25T16:24:33.750" LastActivityDate="2016-05-25T16:24:33.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7953" PostTypeId="2" ParentId="7562" CreationDate="2016-05-25T16:40:17.120" Score="1" Body="&lt;p&gt;I think that the existing mechanisms to do this are better, but it is also possible to do this using &lt;strong&gt;visual block mode&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Copy the dates: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg          # Go to the top of the file&#xA;&amp;lt;ctrl&amp;gt;y     # Enter visual block mode&#xA;G           # Go to the bottom of the file&#xA;w           # Select the first word&#xA;&quot;jy         # Copy in to the j register&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pad the end of first line: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg      # Top of file&#xA;A       # Append the line&#xA;        # Some spaces&#xA;&amp;lt;ESC&amp;gt;   # Return to command mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Paste: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg &#xA;# Move right to the length of the longest line&#xA;&quot;jp   # Paste the block&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2172" LastEditorUserId="2172" LastEditDate="2016-05-25T21:58:14.863" LastActivityDate="2016-05-25T21:58:14.863" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7954" PostTypeId="2" ParentId="7658" CreationDate="2016-05-25T16:47:40.487" Score="1" Body="&lt;p&gt;This is not a direct answer to the question, but I think is still a reasonable solution.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I handle this is I have several .vimrc files: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vimrc-all&lt;/code&gt; - All common things&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vimrc-win&lt;/code&gt; - Windows configuration&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vimrc-linux&lt;/code&gt; - Linux configuration&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vimrc-workMachine&lt;/code&gt; - Things specific to my work machine&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vimrc-homeMachine&lt;/code&gt; - Things specific to my home machine&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On my workMachine, I create a symlink from &lt;code&gt;~/.vimrc&lt;/code&gt; to &lt;code&gt;~/dotfiles/vimConfig/vimrc-workMachine&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what my &lt;code&gt;vimrc-workMachine&lt;/code&gt; looks like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ======================================&#xA;&quot; Source general vim config&#xA;&quot; ======================================&#xA;source ~/dotfiles/vimConfig/vimrc-all.vim&#xA;source ~/dotfiles/vimConfig/vimrc-linux.vim&#xA;&#xA;&quot; ======================================&#xA;&quot; All other stuff&#xA;&quot; ======================================&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2172" LastActivityDate="2016-05-25T16:47:40.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7955" PostTypeId="1" AcceptedAnswerId="7956" CreationDate="2016-05-25T17:12:54.840" Score="1" ViewCount="53" Body="&lt;p&gt;I have a lot of older LaTeX files about physics, which contain values like &lt;code&gt;9.81 m/s^2&lt;/code&gt;. Since I'm now using &lt;code&gt;siunitx&lt;/code&gt; and it's very useful &lt;code&gt;\SI&lt;/code&gt; command, I have to change this to &lt;code&gt;\SI{9.81}{m/s^2}&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There must be a better way than inserting &lt;code&gt;\SI{&lt;/code&gt;, replacing the space with &lt;code&gt;}{&lt;/code&gt;, moving past the unit and insert &lt;code&gt;}&lt;/code&gt;. I would like a command like &lt;code&gt;&amp;lt;localleader&amp;gt;si&lt;/code&gt; which can be called with the cursor within the value.&lt;/p&gt;&#xA;" OwnerUserId="979" LastActivityDate="2016-05-27T16:35:22.880" Title="Create ,SI command to pack numbers and unit into \SI{...}{...}" Tags="|vimscript|filetype-tex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7956" PostTypeId="2" ParentId="7955" CreationDate="2016-05-25T17:33:03.777" Score="2" Body="&lt;p&gt;Sure, try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;LocalLeader&amp;gt;si lBi\SI{&amp;lt;Esc&amp;gt;Ea}{&amp;lt;Del&amp;gt;&amp;lt;Esc&amp;gt;Ea}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively you could do basically the same thing by creating a macro. Start recording a macro with &lt;code&gt;qq&lt;/code&gt;, type what you need to do the change. Type &lt;code&gt;q&lt;/code&gt; again. Next time you need to do the replacement, just use &lt;code&gt;@q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h recording&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-05-27T16:35:22.880" LastActivityDate="2016-05-27T16:35:22.880" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7957" PostTypeId="1" CreationDate="2016-05-25T18:12:31.150" Score="0" ViewCount="562" Body="&lt;p&gt;Buffer-specific mappings are supported by vim out of the box. I am trying to implement window-specific mappings. My plan is to override the default keybinding by one that checks if a window-specific map should be executed, if so, it executes that, and if not, execues the default action for that keybinding (this is the &lt;code&gt;ExecuteWindowMap&lt;/code&gt; function).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm having trouble with setting the map, see &lt;code&gt;SetWindowMap&lt;/code&gt;. This function is called with an argument, &lt;code&gt;a:map&lt;/code&gt;, a string of keys. It needs to include pass this string of keys to a function call, so it makes sense to use &lt;code&gt;noremap&lt;/code&gt;; with &lt;code&gt;map&lt;/code&gt; these keys would get pressed instead of passed to the function! On the other hand, I can only call that function using&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, which doesn't work with &lt;code&gt;noremap&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see two possible solutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;map&lt;/code&gt; and somehow escape the key sequence contained in &lt;code&gt;a:map&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;noremap&lt;/code&gt; in a way that allows a calling a function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SetWindowMap(map)&#xA;  exe &quot;noremap &quot; . a:map . &quot; :call ExecuteWindowMap('&quot; . a:map . &quot;')&amp;lt;CR&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;function! ExecuteWindowMap(map)&#xA;  if exists(&quot;w:winMaps&quot;) &amp;amp;&amp;amp; has_key(w:winMaps, a:map)&#xA;        exe w:winMaps[a:map]&#xA;  else&#xA;        exe &quot;unmap &quot; . a:map &#xA;        exe &quot;'a:map'&quot;&#xA;        call SetWindowMap(a:map) &#xA;  endif&#xA;endfunction&#xA;&#xA;function! WindowMap(map, cmd)&#xA;  if !exists(&quot;w:winMaps&quot;)&#xA;        let w:winMaps = {}&#xA;  endif&#xA;  let w:winMaps[a:map] = a:cmd&#xA;  call SetWindowMap(a:map)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4947" LastEditorUserId="205" LastEditDate="2016-05-26T00:57:18.903" LastActivityDate="2016-05-26T00:57:18.903" Title="How to escape strings containing keys (when mapping) or call function with noremap" Tags="|vimscript|key-bindings|buffers|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7958" PostTypeId="1" CreationDate="2016-05-25T18:19:38.920" Score="4" ViewCount="2957" Body="&lt;p&gt;I have a file, e.g. &lt;code&gt;~/abc def.mp3&lt;/code&gt; that I want to open from within a Vim buffer that already contains these lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there were no whitespaces in the filename, I could simply open the file with the standard application for that file type by having the cursor on its name somewhere and pressing &lt;code&gt;gx&lt;/code&gt;. How could I make this work with a file that includes whitespaces?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already tried to visually select it and press &lt;code&gt;gx&lt;/code&gt; (with or withouth including a &lt;code&gt;\&lt;/code&gt; before the whitespace, surrounding double quotes etc.) but can't figure it out.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2024-01-02T00:06:10.737" Title="Open files with &quot;whitespace names&quot; from within Vim with gx" Tags="|netrw|filesystem|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7959" PostTypeId="1" CreationDate="2016-05-25T18:31:54.353" Score="0" ViewCount="220" Body="&lt;p&gt;I'm trying to create function and a mapping to insert/remove breakpoints in python code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I got this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddBreakPoint()&#xA;    let l:line = line('.')&#xA;    let l:indentChar = ' '&#xA;    call append(l:line - 1, repeat(l:indentChar, indent(l:line)) . &quot;import pdb;pdb.set_trace()&quot;)&#xA;endfunction&#xA;&#xA;&#xA;function! RemoveAllBreakPoints()&#xA;    execute 'args *.py'&#xA;    silent! KeepView execute 'argdo g/\v^\s+(import pdb|pdb.set_trace)/de'&#xA;    write&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried both bufdo and argdo and none of them works properly. With bufdo it breaks with neovim terminal emulator buffers, saing buffer doesn't have some property. With argo do it shows some error very quickly and while it removes breakpoints it also messes my splits. For example it can change the active buffer in split to another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also argdo is really wouldn't work for me, because I don't need to search all python files, for large projects this would be too slow. I only need files that have been modified recently or more likely in that same editing session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT1&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;schedules = {&#xA;    1: True,&#xA;    import pdb;pdb.set_trace()&#xA;    2: True,&#xA;    3: True,&#xA;    4: True,&#xA;    5: True,&#xA;    6: False,&#xA;    7: False,&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's a test file for you.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6634" LastEditDate="2016-06-03T20:03:29.177" LastActivityDate="2016-06-03T20:03:29.177" Title="How to remove lines matching pattern in all files changed in one editing session?" Tags="|regular-expression|neovim|argument-list|terminal-buffer|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="7961" PostTypeId="1" CreationDate="2016-05-26T00:03:48.707" Score="2" ViewCount="133" Body="&lt;p&gt;So I do a lot of python work in GVim on Windows 7, and I'm running into an annoying roadblock. This might be more of a Windows question, but it's happening in Vim, so ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this in my &lt;code&gt;python.vim&lt;/code&gt; file to quickly run the current file in python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;F5&amp;gt; :!start cmd /c &quot;python %:p&quot; &amp;amp; pause&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'm working on a python script that calls ImageMagick via the shell.&#xA;So, I hit &lt;kbd&gt;F5&lt;/kbd&gt;, and I get an error that ImageMagick is &quot;not recognized as an internal or external command&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I run the python file from outside of GVim, it performs perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eventually, I ran &lt;code&gt;:!start cmd&lt;/code&gt;, and printed the Windows &lt;code&gt;%PATH%&lt;/code&gt; from that command prompt. Much to my chagrin, the ImageMagick folder was not on my path. However, &lt;code&gt;:echo $PATH&lt;/code&gt; from within vim has it, the path is correct in my System Properties -&gt; Environment Variables, and any other command prompt has it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[edit] Per request, these are the different paths:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start cmd path (the bad one):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Path=C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Python27;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files (x86)\Common Files\Autodesk Shared\;C:\Program Files (x86)\Common Files\Softimage;C:\Program Files\Common Files\Softimage;C:\Program Files\Intel\DMIX;C:\PROGRA~2\ALPSER~1;C:\PROGRA~2\ALPSER~1\(x86);C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\WinMerge;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Python27\Scripts;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\doxygen\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Graphviz2.38\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\Vim\vim74 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Regular path (the good one):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Path=C:\Program Files\ImageMagick-6.9.0-Q16;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Python27;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files (x86)\Common Files\Autodesk Shared\;C:\Program Files (x86)\Common Files\Softimage;C:\Program Files\Common Files\Softimage;C:\Program Files\Intel\DMIX;C:\PROGRA~2\ALPSER~1;C:\PROGRA~2\ALPSER~1\(x86);C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\WinMerge;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Python27\Scripts;C:\Program Files (x86)\Autodesk\Backburner\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\doxygen\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Graphviz2.38\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\CMake\bin;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anybody have an idea where this difference is coming from?&lt;/p&gt;&#xA;" OwnerUserId="7766" LastEditorUserId="7766" LastEditDate="2016-05-27T18:38:26.330" LastActivityDate="2016-05-27T18:38:26.330" Title="The $path used by &quot;:!start cmd&quot; is different from my system $path in windows" Tags="|microsoft-windows|path|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7962" PostTypeId="2" ParentId="7957" CreationDate="2016-05-26T00:50:14.523" Score="2" Body="&lt;p&gt;I was encouraged to answer my own question, I initially deleted it, because I was just not familiar with the way strings work in vim. When you use double quotes, characters preceded by a backslash are escaped before the string is used by the function. You thus need to use double backslashes, or use a literal string with single quotes. It is explained further &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/26.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/31.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; (Chapter 26 &amp;amp; 31 of Learn Vimscript the Hard Way).&lt;/p&gt;&#xA;" OwnerUserId="4947" LastActivityDate="2016-05-26T00:50:14.523" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7964" PostTypeId="2" ParentId="7925" CreationDate="2016-05-26T06:41:47.917" Score="3" Body="&lt;p&gt;An imperfect solution is &lt;a href=&quot;http://vim.wikia.com/wiki/Search_only_in_unfolded_text&quot; rel=&quot;nofollow noreferrer&quot;&gt;using folds&lt;/a&gt;. Fold everything:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=syntax&#xA;set foldlevel=0&#xA;set foldminlines=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tell Vim not to open folded areas for search results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldopen-=search&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then open the fold on the function in question (&lt;code&gt;zO&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, all hits for the searched the text in a folded region will result in Vim jumping to the fold line once, then proceeding to the next hit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in the case below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/06zAh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/06zAh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The folded function has many usages of &lt;code&gt;size&lt;/code&gt;, but &lt;code&gt;n&lt;/code&gt; won't leading me around every usage of &lt;code&gt;size&lt;/code&gt; in that function.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-05-26T06:41:47.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7966" PostTypeId="1" CreationDate="2016-05-26T10:16:51.900" Score="30" ViewCount="15952" Body="&lt;p&gt;I know that Vim allows a client server mode (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/remote.html#clientserver&quot;&gt;&lt;code&gt;:h clientserver&lt;/code&gt;&lt;/a&gt;): it is possible to turn it into a server which will get some commands and execute them and as a client which will send the commands to the server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get how it works, but I can't imagine a practical use of this feature: in which cases is it useful, and what workflow can be created using this feature?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is simple: &lt;strong&gt;What is the use of the client server mode of Vim?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I point out again that my question is not about how to make it work or how it works but why use it.)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2016-05-27T11:19:52.030" LastActivityDate="2022-07-05T00:34:58.637" Title="What are practical uses of the client-server mode?" Tags="|clientserver|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7967" PostTypeId="2" ParentId="7966" CreationDate="2016-05-26T10:34:28.483" Score="25" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Before the channel/job recent feature of Vim 7.4, the client-server feature was the only way to do a decent background compilation -- without any dependency to Python. We start compilation as a background job, and when it finishes, it notifies back to vim, thanks to the client-server channel, that it has finished.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It's also indirectly used by &quot;plugins&quot; like pyclewn to integrate a debugger into vim. Actually pyclewn uses the +netbeans feature (that is built on top of +clientserver). Other notable projects use this netbeans interface to integrate vim with an IDE -- see &lt;code&gt;:h netbeans-intro&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It's also used by some tests plugins like vimrunner to run tests in Vim from the command line. I use it to tests my plugins on travis.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I also remember synchronizing my clicks in xdvi interface to my LaTeX source code thanks to +clientserver.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-05-26T10:34:28.483" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7968" PostTypeId="2" ParentId="7966" CreationDate="2016-05-26T11:23:34.070" Score="18" Body="&lt;p&gt;My use of this is a little more simplistic (and perhaps commonplace) than Luc Hermitte's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you start an instance of &lt;em&gt;gvim&lt;/em&gt; with this compiled in (and it is, and has been for a long time, on, e.g., major linux distros like Fedora and Debian), it starts in server mode. I emphasized &quot;gvim&quot; because what I'm about to describe does not seem to apply to a singular &lt;code&gt;vim&lt;/code&gt; instance in a GUI terminal (although I suppose it could be if you use the paramater appropriately).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, you can then open any file from anywhere in that gvim instance with &lt;code&gt;gvim --remote [file path]&lt;/code&gt; (with no &lt;code&gt;--servername&lt;/code&gt; specified).  I'm a fan of this because I don't navigate the filesystem much directly with vim; instead I use an &lt;a href=&quot;https://en.wikipedia.org/wiki/File_manager#Orthodox_file_managers&quot;&gt;orthodox file browser&lt;/a&gt; (midnight commander) -- or rather, piles of them open to different locations since &lt;code&gt;mc&lt;/code&gt; is lightweight and allows for various color scheme skins to simplify differentiating between them (so I tend to have two or three open in separate tabs in at least one GUI terminal).  However, I think the same principle will apply to any file browser which allows you some form of customized hotkey you can associate with &lt;code&gt;gvim --remote %f&lt;/code&gt;.  In &lt;code&gt;mc&lt;/code&gt; I have it in the user menu, so F2 + e and the highlighted/selected file is sent to the gvim instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This gets a little better: If you open a &lt;em&gt;second&lt;/em&gt; gvim instance, say, on monitor #2 of the same desktop, or a separate desktop, and perhaps a different colorscheme in that one, and this time give it an explicit &lt;code&gt;--servername foo&lt;/code&gt;, you can send files to that instance instead with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; gvim --servername foo --remote [file path]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Something which may or may not come in handy depending on the scope of what you are doing, etc.&lt;/p&gt;&#xA;" OwnerUserId="4913" LastActivityDate="2016-05-26T11:23:34.070" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7969" PostTypeId="1" AcceptedAnswerId="7970" CreationDate="2016-05-26T15:28:34.587" Score="2" ViewCount="994" Body="&lt;p&gt;I store my &lt;code&gt;.vimrc&lt;/code&gt; in my dotfiles repository located at &lt;code&gt;~/dotfiles/.vimrc&lt;/code&gt;, which I want to manage with Git using &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow&quot;&gt;vim-fugitive&lt;/a&gt;. I have symlinks from my home directory to my dotfiles, i.e. &lt;code&gt;~/.vimrc -&amp;gt; ~/dotfiles/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I two problems with this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I can't do something like &lt;code&gt;:edit $MYVIMRC&lt;/code&gt;, change something and run &lt;code&gt;:Gcommit&lt;/code&gt;, as &lt;a href=&quot;https://github.com/tpope/vim-fugitive/issues/147&quot; rel=&quot;nofollow&quot;&gt;fugitive does not follow symbolic links&lt;/a&gt;. Via the symlink my &lt;code&gt;~/dotfiles/.vimrc&lt;/code&gt; opens when running the edit command, but fugitive commands are not available.&lt;/li&gt;&#xA;&lt;li&gt;In my &lt;code&gt;.vimrc&lt;/code&gt; I define a number of autocommands that do use &lt;code&gt;$MYVIMRC&lt;/code&gt; - some of them do no longer work, because they also have their troubles with the symlink.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Both problems could be easily fixed if I could change the value of &lt;code&gt;$MYVIMRC&lt;/code&gt;, but I can't figure out how to do that. &lt;strong&gt;How can I change the value of &lt;code&gt;$MYVIMRC&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that I can also just ignore &lt;code&gt;$MYVIMRC&lt;/code&gt;, i.e. replace it in all autocommands and not use it to edit my &lt;code&gt;.vimrc&lt;/code&gt;, but this seems not like a good solution.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2016-05-26T15:35:43.170" Title="Changing value of $MYVIMRC" Tags="|vimrc|plugin-fugitive|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7970" PostTypeId="2" ParentId="7969" CreationDate="2016-05-26T15:35:43.170" Score="5" Body="&lt;p&gt;&lt;code&gt;let&lt;/code&gt; command in vimL allows you to assign a value to a variable. A variable may be a environment variable, or a register or an option.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :let $MYVIMRC=value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command sets the value to &lt;code&gt;$MYVIMRC&lt;/code&gt;. You can put this in .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :let $MYVIMRC=C:\Users\acer\Desktop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7161" LastActivityDate="2016-05-26T15:35:43.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7971" PostTypeId="2" ParentId="7683" CreationDate="2016-05-26T17:07:36.840" Score="0" Body="&lt;p&gt;Running with the Chocolatey package &lt;code&gt;vim-tux&lt;/code&gt; on Windows 7, I was getting the same error. I fixed the problem by running &lt;a href=&quot;https://github.com/vim/vim-win32-installer/blob/master/appveyor.bat#L89-L91&quot; rel=&quot;nofollow&quot;&gt;this command&lt;/a&gt; (be warned: this is registry editing):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;reg copy HKLM\SOFTWARE\Python\PythonCore\2.7 HKLM\SOFTWARE\Python\PythonCore\2.7-32 /s /reg:64&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found this solution on &lt;a href=&quot;http://comments.gmane.org/gmane.editors.vim.devel/57883&quot; rel=&quot;nofollow&quot;&gt;this forum&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1746" LastActivityDate="2016-05-26T17:07:36.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7972" PostTypeId="2" ParentId="7966" CreationDate="2016-05-26T17:18:32.163" Score="5" Body="&lt;p&gt;Embedded development. A lot of times in embedded development you have a IP socket, but limited local hard drive space, or no non-volatile memory, or any number of other things. You can start a server on the embedded board, and then client into it on your development computer and have all your configuration and tags setup locally. &lt;/p&gt;&#xA;" OwnerUserId="7778" LastActivityDate="2016-05-26T17:18:32.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7973" PostTypeId="2" ParentId="678" CreationDate="2016-05-26T23:06:30.027" Score="12" Body="&lt;p&gt;I can recommend a vim plugin from Tim Pope called &lt;a href=&quot;https://github.com/tpope/vim-eunuch&quot; rel=&quot;noreferrer&quot;&gt;vim-eunuch&lt;/a&gt; which defines many extremely useful commands when your work on UNIX/Linux with Vim (check out &lt;a href=&quot;https://github.com/tpope/vim-eunuch#eunuchvim&quot; rel=&quot;noreferrer&quot;&gt;its features&lt;/a&gt;!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say you open vim with &lt;code&gt;vim this/is/a/test&lt;/code&gt; and none of these directories existed before. Just run &lt;code&gt;:Mkdir!&amp;lt;CR&amp;gt;&lt;/code&gt; and vim-eunuch creates them for you (with &lt;code&gt;mkdir -p&lt;/code&gt;), so you can now save your file with &lt;code&gt;:w&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3282" LastActivityDate="2016-05-26T23:06:30.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7974" PostTypeId="2" ParentId="7932" CreationDate="2016-05-27T00:39:53.443" Score="4" Body="&lt;p&gt;Putting this in your &lt;code&gt;vimrc&lt;/code&gt; &lt;strong&gt;should&lt;/strong&gt; fix the re-source issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; after a re-source, fix syntax matching issues (concealing brackets):&#xA;if exists('g:loaded_webdevicons')&#xA;    call webdevicons#refresh()&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6875" LastActivityDate="2016-05-27T00:39:53.443" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7975" PostTypeId="1" AcceptedAnswerId="7977" CreationDate="2016-05-27T09:07:53.823" Score="66" ViewCount="111191" Body="&lt;p&gt;I just discovered I could indent and un-indent easily in Vi with : &lt;kbd&gt;&amp;lt;&amp;lt;&lt;/kbd&gt; and &lt;kbd&gt;&gt;&gt;&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default it adds a &lt;code&gt;tab&lt;/code&gt; character. Now I'm wondering, could this be to a number of spaces via a configuration in my &lt;code&gt;.vimrc&lt;/code&gt;? And how should I do it?&lt;/p&gt;&#xA;" OwnerUserId="6946" LastEditorUserId="1841" LastEditDate="2016-05-27T09:21:00.340" LastActivityDate="2023-04-11T12:35:47.030" Title="How can I change the indent size?" Tags="|indentation|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7976" PostTypeId="2" ParentId="7975" CreationDate="2016-05-27T09:12:37.750" Score="6" Body="&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can set &lt;code&gt;shiftwidth&lt;/code&gt; to any number of spaces.&#xA;This works both in &lt;code&gt;vi&lt;/code&gt; and  &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set shiftwidth=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, the width shifted for each &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; will be 2.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="1821" LastEditDate="2016-06-10T17:44:25.650" LastActivityDate="2016-06-10T17:44:25.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7977" PostTypeId="2" ParentId="7975" CreationDate="2016-05-27T09:17:59.887" Score="72" Body="&lt;p&gt;Several settings controls the behavior:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First &lt;code&gt;set expandtab&lt;/code&gt; allows to replace the tabs by white spaces characters &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27expandtab%27&quot;&gt;&lt;code&gt;:h 'expandtab'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;set shiftwidth=4&lt;/code&gt; makes the tabulations be 4 white spaces &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27shiftwidth%27&quot;&gt;&lt;code&gt;:h 'shiftwidth'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also be interested by by &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27tabstop%27&quot;&gt;&lt;code&gt;:h 'tabstop'&lt;/code&gt;&lt;/a&gt; which defines the number of spaces that a tab character in the file counts for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a bonus see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27smartindent%27&quot;&gt;&lt;code&gt;:h 'smartindent'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27autoindent%27&quot;&gt;&lt;code&gt;:h 'autoindent'&lt;/code&gt;&lt;/a&gt; which are pretty useful.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-05-27T09:17:59.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7978" PostTypeId="5" CreationDate="2016-05-27T09:39:35.543" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27cursorline%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 'cursorline'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Highlight the screen line of the cursor with CursorLine&#xA;      hl-CursorLine.  Useful to easily spot the cursor.  Will make screen&#xA;      redrawing slower.&#xA;      When Visual mode is active the highlighting isn't used to make it&#xA;      easier to see the selected text.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T09:39:35.543" LastActivityDate="2016-05-27T09:39:35.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7979" PostTypeId="4" CreationDate="2016-05-27T09:39:35.543" Score="0" Body="Question about the usage of the option cursorline" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T09:39:35.543" LastActivityDate="2016-05-27T09:39:35.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7980" PostTypeId="2" ParentId="7975" CreationDate="2016-05-27T09:40:09.820" Score="26" Body="&lt;p&gt;In fact, aside from other answers, it is also possible to use &lt;code&gt;autoindent&lt;/code&gt; (to automatically indent newlines) and &lt;a href=&quot;https://vi.stackexchange.com/questions/5818/what-is-the-difference-between-autoindent-and-smartindent-in-vimrc&quot;&gt;&lt;code&gt;smartindent&lt;/code&gt;&lt;/a&gt; (which works with C-like braces languages less strictly than &lt;code&gt;cindent&lt;/code&gt;). Then the &lt;code&gt;shiftwidth&lt;/code&gt; I wanted was &lt;code&gt;2&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I modified my &lt;code&gt;$HOME/.vimrc&lt;/code&gt; like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set shiftwidth=2&#xA;:set autoindent&#xA;:set smartindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6946" LastEditorUserId="10604" LastEditDate="2023-04-11T12:35:47.030" LastActivityDate="2023-04-11T12:35:47.030" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="7981" PostTypeId="1" CreationDate="2016-05-27T10:00:15.313" Score="0" ViewCount="303" Body="&lt;p&gt;I have set vim to be my default reader for program like less and I have rebind some of the key of my vim via &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, less doesn't pick them up. I have trying setting the keybinds system wide via &lt;code&gt;/etc/vimrc&lt;/code&gt; but it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get all programs using vim as a pager to use my custom keybinds?&lt;/p&gt;&#xA;" OwnerUserId="6854" LastActivityDate="2016-05-28T00:11:22.680" Title="Make my .vimrc config work with less" Tags="|key-bindings|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7982" PostTypeId="5" CreationDate="2016-05-27T10:06:34.760" Score="0" Body="&lt;p&gt;This is a special tag that is designed to be used only by the system for questions that have had all of their other tags removed. Do not add this tag to existing questions, it is reserved for use by the system to identify posts with no valid tags&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T10:06:34.760" LastActivityDate="2016-05-27T10:06:34.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7983" PostTypeId="4" CreationDate="2016-05-27T10:06:34.760" Score="0" Body="This is a special tag that is designed to be used only by the system for questions that have had all of their other tags removed. Do not add this tag to existing questions, it is reserved for use by the system to identify posts with no valid tags" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T10:06:34.760" LastActivityDate="2016-05-27T10:06:34.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7984" PostTypeId="5" CreationDate="2016-05-27T11:52:48.493" Score="0" Body="&lt;p&gt;Question referring to the motions based on text objects like: &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt; or &lt;code&gt;[[&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#object-motions&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h object-motions&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T11:52:48.493" LastActivityDate="2016-05-27T11:52:48.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7985" PostTypeId="4" CreationDate="2016-05-27T11:52:48.493" Score="0" Body="Question about text object motions" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T11:52:48.493" LastActivityDate="2016-05-27T11:52:48.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7986" PostTypeId="5" CreationDate="2016-05-27T12:06:58.180" Score="0" Body="&lt;p&gt;A snippet is a reusable piece of code (or more generally of text) which can be easily inserted in a bugged when the text entered triggers an event or when a particular mapping is invoked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some plugins enable these features (non exhaustive list):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/LucHermitte/mu-template&quot; rel=&quot;nofollow&quot;&gt;vim-snippets&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/msanders/snipmate.vim&quot; rel=&quot;nofollow&quot;&gt;snipmate&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/LucHermitte/mu-template&quot; rel=&quot;nofollow&quot;&gt;mu template&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/sirver/UltiSnips&quot; rel=&quot;nofollow&quot;&gt;ultisnips&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T12:06:58.180" LastActivityDate="2016-05-27T12:06:58.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7987" PostTypeId="4" CreationDate="2016-05-27T12:06:58.180" Score="0" Body="Questions about the usage of snippets within Vim." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T12:06:58.180" LastActivityDate="2016-05-27T12:06:58.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7988" PostTypeId="2" ParentId="7947" CreationDate="2016-05-27T14:48:38.620" Score="3" Body="&lt;p&gt;There is no way to do it and it is normal that there isn't: normal mode commands are generally pretty short and can be cancelled with &lt;kbd&gt;Esc&lt;/kbd&gt; if you mess it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possible workaround would be to use the &lt;code&gt;:normal&lt;/code&gt; command. It makes the process longer but for example if you type &lt;code&gt;:normal 10j&lt;/code&gt; in the command line, Vim will execute &lt;code&gt;10j&lt;/code&gt; as if you typed it in normal mode. (See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/various.html#:normal&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :normal&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also add these lines to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F4&amp;gt; :call NormalModeCommand()&amp;lt;CR&amp;gt;&#xA;&#xA;function! NormalModeCommand()&#xA;    let command = input(&quot;Normal command: &quot;)&#xA;    execute &quot;normal &quot; . command&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They create a mapping (here &lt;kbd&gt;F4&lt;/kbd&gt; but use whatever you want) which will call the function &lt;code&gt;NormalModeCommand()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function allows you to type a string in the command line and then execute the string you typed as a normal mode command. As you type the string in the command line you can correct it as every other command. Of course it is not ideal but once again Vim isn't meant to do that.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-05-27T14:48:38.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7990" PostTypeId="2" ParentId="7959" CreationDate="2016-05-27T18:29:56.630" Score="1" Body="&lt;p&gt;Give this a shot:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:eddited_python_files = []&#xA;autocmd BufWritePost *.py if (count(g:eddited_python_files, expand('%:p')) == 0) | call add(g:eddited_python_files, expand('%:p')) | endif&#xA;&#xA;command! RB call RemoveAllBreakPoints()&#xA;&#xA;function! RemoveAllBreakPoints()&#xA;   tabnew &quot; Don't clobber the current tab&#xA;   for file in g:eddited_python_files&#xA;      exe &quot;edit &quot; . l:file&#xA;      g/\v^\s+(import pdb|pdb.set_trace)/d&#xA;      write&#xA;   endfor&#xA;   quit &quot; Go back to original tab&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I changed the autocmd to only add unique files. I just used your regular expression, I'm not familiar with python brakpoints. I'm also not sure how you wanted to call this function so I just put in a command for it. This means you can do a &lt;code&gt;:RB&lt;/code&gt; to do the operation.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-05-27T18:39:59.710" LastActivityDate="2016-05-27T18:39:59.710" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7991" PostTypeId="5" CreationDate="2016-05-27T21:43:22.373" Score="0" Body="&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#argument-list&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h argument-list&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you give more than one file name when starting Vim, this list is remembered&#xA;  as the argument list.  You can jump to each file in this list.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Do not confuse this with the buffer list, which you can see with the&#xA;  &lt;code&gt;:buffers&lt;/code&gt; command.  The argument list was already present in Vi, the buffer&#xA;  list is new in Vim.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This subject is introduced in section &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_07.html#07.2&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;07.2&lt;/code&gt;&lt;/a&gt; of the user manual.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;There is one global argument list, which is used for all windows by default.&#xA;  It is possible to create a new argument list local to a window, see&#xA;  &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#:arglocal&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :arglocal&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You can use the argument list with the following commands, and with the&#xA;  expression functions &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#argc()&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;argc()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#argv()&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;argv()&lt;/code&gt;&lt;/a&gt;.  These all work on the argument&#xA;  list of the current window.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T21:43:22.373" LastActivityDate="2016-05-27T21:43:22.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7992" PostTypeId="4" CreationDate="2016-05-27T21:43:22.373" Score="0" Body="Questions about the usage and the manipulation of the argument list. The argument list is the list of file names you give when starting Vim." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T21:43:22.373" LastActivityDate="2016-05-27T21:43:22.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7993" PostTypeId="5" CreationDate="2016-05-27T21:48:37.337" Score="0" Body="&lt;p&gt;These questions include (but are not restricted to) topics like the usage of the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#quote=&quot; rel=&quot;nofollow&quot;&gt;expression register&lt;/a&gt; or commands like &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#CTRL-A&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;CTRL-A&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#CTRL-X&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;CTRL-X&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T21:48:37.337" LastActivityDate="2016-05-27T21:48:37.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7994" PostTypeId="4" CreationDate="2016-05-27T21:48:37.337" Score="0" Body="Question about ways to make quick calculations in Vim." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T21:48:37.337" LastActivityDate="2016-05-27T21:48:37.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7995" PostTypeId="5" CreationDate="2016-05-27T21:51:10.660" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#conceal&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h conceal&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T21:51:10.660" LastActivityDate="2016-05-27T21:51:10.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7996" PostTypeId="4" CreationDate="2016-05-27T21:51:10.660" Score="0" Body="The 'conceal' feature allows to hide or replace some part of a buffer thanks to Vim's syntax highlighting mechanism." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T21:51:10.660" LastActivityDate="2016-05-27T21:51:10.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7997" PostTypeId="5" CreationDate="2016-05-27T21:52:54.700" Score="0" Body="&lt;p&gt;Cygwin is a Unix-like environment and command-line interface for Microsoft Windows. Cygwin provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment. Thus it is possible to launch Windows applications from the Cygwin environment, as well as to use Cygwin tools and applications within the Windows operating context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;http://cygwin.com/&quot; rel=&quot;nofollow&quot;&gt;cygwin homepage&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T21:52:54.700" LastActivityDate="2016-05-27T21:52:54.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7998" PostTypeId="4" CreationDate="2016-05-27T21:52:54.700" Score="0" Body="Question about the usage of Vim in a cygwin environment." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T21:52:54.700" LastActivityDate="2016-05-27T21:52:54.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7999" PostTypeId="5" CreationDate="2016-05-27T21:55:57.153" Score="0" Body="&lt;p&gt;The syntax of the command is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]g[lobal]/{pattern}/[cmd]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html#:global&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :global&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T21:55:57.153" LastActivityDate="2016-05-27T21:55:57.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8000" PostTypeId="4" CreationDate="2016-05-27T21:55:57.153" Score="0" Body="Questions about the usage of the global command `:g` which executes an Ex command (default &quot;:p&quot;) on the lines within a range a where a pattern matches." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T21:55:57.153" LastActivityDate="2016-05-27T21:55:57.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8001" PostTypeId="5" CreationDate="2016-05-27T22:00:57.347" Score="0" Body="&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#jumplist&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h jumplist&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Jumps are remembered in a jump list.  With the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#CTRL-O&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;CTRL-O&lt;/code&gt;&lt;/a&gt;&#xA;  and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#CTRL-I&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;CTRL-I&lt;/code&gt;&lt;/a&gt; command you&#xA;  can go to cursor positions before older jumps, and back again.  Thus you can&#xA;  move up and down the list.  There is a separate jump list for each window.&#xA;  The maximum number of entries is fixed at 100.&#xA;  {not available without the &lt;code&gt;+jumplist&lt;/code&gt; feature}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T22:00:57.347" LastActivityDate="2016-05-27T22:00:57.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8002" PostTypeId="4" CreationDate="2016-05-27T22:00:57.347" Score="0" Body="Questions about the manipulation of the jump list. The jump list remembers the previous jumps and allows the user to navigate in the buffer to the location of the previous modifications." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T22:00:57.347" LastActivityDate="2016-05-27T22:00:57.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8003" PostTypeId="5" CreationDate="2016-05-27T22:02:51.153" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#mark-motions&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h mark-motions&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T22:02:51.153" LastActivityDate="2016-05-27T22:02:51.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8004" PostTypeId="4" CreationDate="2016-05-27T22:02:51.153" Score="0" Body="Question about the navigation in a buffer via the marks mechanism and the general usage of marks." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T22:02:51.153" LastActivityDate="2016-05-27T22:02:51.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8005" PostTypeId="5" CreationDate="2016-05-27T22:05:36.150" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27path%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h 'path'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T22:05:36.150" LastActivityDate="2016-05-27T22:05:36.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8006" PostTypeId="4" CreationDate="2016-05-27T22:05:36.150" Score="0" Body="Questions about the usage of the Vim's path variable. this variable lists the directories which will be searched with commands like `gf`, [f, ]f, ^Wf, `:find`, `:sfind`, `:tabfind`" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T22:05:36.150" LastActivityDate="2016-05-27T22:05:36.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8007" PostTypeId="5" CreationDate="2016-05-27T22:08:10.680" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/ervandew/eclim&quot; rel=&quot;nofollow&quot;&gt;Eclim homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T22:08:10.680" LastActivityDate="2016-05-27T22:08:10.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8008" PostTypeId="4" CreationDate="2016-05-27T22:08:10.680" Score="0" Body="Expose eclipse features inside of vim (Java)." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T22:08:10.680" LastActivityDate="2016-05-27T22:08:10.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8009" PostTypeId="5" CreationDate="2016-05-27T22:09:49.203" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow&quot;&gt;vim-textobj-user homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T22:09:49.203" LastActivityDate="2016-05-27T22:09:49.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8010" PostTypeId="4" CreationDate="2016-05-27T22:09:49.203" Score="0" Body="This plugin has for goal to ease the creation of your own text objects." OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-05-27T22:09:49.203" LastActivityDate="2016-05-27T22:09:49.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8011" PostTypeId="1" AcceptedAnswerId="8013" CreationDate="2016-05-28T00:06:56.710" Score="5" ViewCount="3091" Body="&lt;p&gt;I was told when add a line like &lt;code&gt;# vim: filetype=r&lt;/code&gt; in a file, vim can recognizes the file type. It seems that for some files like &lt;code&gt;*.cpp&lt;/code&gt;,&lt;code&gt;*.java&lt;/code&gt;, vim can recognize the file while for files like &lt;code&gt;*.CPP&lt;/code&gt;, &lt;code&gt;*.JAVA&lt;/code&gt;, it needs the first line information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two questions. The first is that what should I type in the first line of a &lt;code&gt;*.sh&lt;/code&gt; shell script file? The second is that is there any list for the extension names or the extension name to be typed in the first line is simply the extension name of the original file with all letters in small case?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I've read &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27filetype%27&quot;&gt;this&lt;/a&gt; link, but didn't find my answer.&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="205" LastEditDate="2016-05-28T03:35:10.510" LastActivityDate="2018-07-31T17:39:17.320" Title="Is there any list of filetype extension names?" Tags="|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8012" PostTypeId="2" ParentId="7981" CreationDate="2016-05-28T00:11:22.680" Score="4" Body="&lt;p&gt;While viewing text in &lt;code&gt;less&lt;/code&gt;, you can press &lt;code&gt;v&lt;/code&gt; to view the text in &lt;code&gt;$VISUAL&lt;/code&gt; or &lt;code&gt;$EDITOR&lt;/code&gt;.  If you want to change the keys for &lt;code&gt;less&lt;/code&gt;, you can use &lt;code&gt;lesskey&lt;/code&gt;.  But, it's not available on OS X without compiling &lt;code&gt;less&lt;/code&gt; yourself or installing it from homebrew.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As pointed out in the question's comments, there are plugins and environment variables that can change the pager program.  However, I mainly wanted to answer this question to point something out to new users who are enthusiastic about having Vim all over the place:  &lt;strong&gt;You really don't want Vim to be your pager.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want your pager to be fast, and &lt;code&gt;less&lt;/code&gt; is &lt;em&gt;fast&lt;/em&gt; at displaying text.  It's fast because it only loads as many lines as there are in your terminal session.  You can open up a giant text file with less and it will appear instantly in most cases.  You're not going to be able to jump to the bottom of a 20GB text file with &lt;code&gt;less&lt;/code&gt;, but you'll at least be able to briefly regret the decision and quit quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Compared to &lt;code&gt;less&lt;/code&gt;, Vim is &lt;strong&gt;not fast&lt;/strong&gt;.  Vim loads the entire text into memory.  If you're unlucky, Vim will also find a matching syntax file for what's loaded and you'll be stuck waiting for the text to be highlighted.  On top of that, you might hit the wrong keys and cause Vim to re-indent a giant text file.  Optimistically, you'll be waiting a minute, but most likely, the process will have to be killed.  Sure, you can make Vim run in read-only mode, but that only keeps you from saving the file.  Vim can still do things very slowly to the text that's loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim is a great text editor, but it's not good for all text-related activities.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-05-28T00:11:22.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8013" PostTypeId="2" ParentId="8011" CreationDate="2016-05-28T03:31:10.690" Score="16" Body="&lt;p&gt;The reason Vim detects the filetype for &lt;code&gt;*.cpp&lt;/code&gt; and not for &lt;code&gt;*.CPP&lt;/code&gt; files is that Vim has auto-commands for &lt;code&gt;*.cpp&lt;/code&gt; setting the filetype, but nothing for &lt;code&gt;*.CPP&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;:au BufRead *.cpp&#xA;--- Auto-Commands ---&#xA;filetypedetect  BufRead&#xA;    *.cpp     if exists(&quot;cynlib_syntax_for_cpp&quot;)|setf cynlib|else|setf cpp|endif&#xA;&#xA;:au BufRead *.java&#xA;--- Auto-Commands ---&#xA;filetypedetect  BufRead&#xA;    *.java    setf java&#xA;&#xA;:au BufRead *.CPP&#xA;--- Auto-Commands ---&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What you need is a similar &lt;code&gt;autocmd&lt;/code&gt; for &lt;code&gt;*.CPP&lt;/code&gt; and &lt;code&gt;*.JAVA&lt;/code&gt; files:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;au BufRead *.CPP setf cpp&#xA;au BufRead *.JAVA setf java&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add these to your &lt;code&gt;.vimrc&lt;/code&gt;, or more appropriately from an organizational view, to a &lt;code&gt;.vim&lt;/code&gt; file in &lt;code&gt;~/.vim/ftdetect/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;.sh&lt;/code&gt; files, Vim should already be detecting the filetype correctly, and the filetype would be &lt;code&gt;sh&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;# vim: filetype=r&lt;/code&gt; is  &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#modeline&quot;&gt;a modeline&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;There are two forms of modelines.  The first form:&#xA;        [text]{white}{vi:|vim:|ex:}[white]{options}&#xA;…&#xA;Examples:&#xA;   vi:noai:sw=3 ts=6 &#xA;   vim: tw=77 &#xA;&#xA;The second form (this is compatible with some versions of Vi):&#xA;&#xA;        [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]&#xA;…&#xA;Examples:&#xA;   /* vim: set ai tw=75: */ &#xA;   /* Vim: set ai tw=75: */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you absolutely must use a modeline, try something like the following &lt;em&gt;after&lt;/em&gt; the shebang:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;# vim: ft=sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The filetypes are not necessarily the extensions. For example, &lt;code&gt;.conf&lt;/code&gt; files can have a filetype of &lt;code&gt;apache&lt;/code&gt;, &lt;code&gt;.sh&lt;/code&gt; files can have a filetype of &lt;code&gt;zsh&lt;/code&gt; if the shebang is &lt;code&gt;#! /bin/zsh&lt;/code&gt;, and so on. Open a file for which you know the filetype is correctly detected and run &lt;code&gt;set ft?&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ft?&#xA;  filetype=apache&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default rules for setting the filetype are in &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/filetype.vim&quot;&gt;&lt;code&gt;$VIMRUNTIME/filetype.vim&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;vim +'e $VIMRUNTIME/filetype.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Look for &lt;code&gt;setf&lt;/code&gt; in that file.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-05-28T03:31:10.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8014" PostTypeId="2" ParentId="7939" CreationDate="2016-05-28T05:41:40.500" Score="2" Body="&lt;p&gt;Alternate solution (based on a comment I received for this question, but was deleted before I could reply)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(\\?)\\/\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is useful as I can now use &lt;code&gt;sed&lt;/code&gt; also (couldn't find equivalent of &lt;code&gt;\zs&lt;/code&gt; in sed):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sed -r 's/(\\?)\\/\1/g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;\K&lt;/code&gt; seems equivalent of &lt;code&gt;\zs&lt;/code&gt; in &lt;code&gt;Perl&lt;/code&gt; (saw it while going through this &lt;a href=&quot;https://unix.stackexchange.com/questions/13466/can-grep-output-only-specified-groupings-that-match&quot;&gt;answer&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\\?\K\\//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1616" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2016-05-28T05:56:54.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8015" PostTypeId="1" CreationDate="2016-05-28T16:35:34.983" Score="1" ViewCount="1615" Body="&lt;p&gt;I've been trying in vain the past few days to get Vim to recognize tags in my JS file. My problem is very similar to this other question: &lt;a href=&quot;https://vi.stackexchange.com/questions/2560/how-to-view-javascript-tags-in-vim-using-tagbar-jsctags-tern-for-vim-ctags&quot;&gt;How to view javascript tags in vim using tagbar + jsctags + tern_for_vim + ctags_exuberant?&lt;/a&gt; and I have a similar setup:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Universal ctags installed (since exuberant-ctags seems to be not updating as much)&lt;/li&gt;&#xA;&lt;li&gt;Jsctags via a global gem&lt;/li&gt;&#xA;&lt;li&gt;tern_for_vim &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I've tried to debug the tagbar plugin and it seems to call &lt;code&gt;jsctags&lt;/code&gt; fine and does not print any errors. I've also tried to run &lt;code&gt;jsctags&lt;/code&gt; via the command line with this command per the git repo's &lt;a href=&quot;https://github.com/ramitos/jsctags&quot; rel=&quot;nofollow&quot;&gt;readme&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -type f -iregex &quot;.*\.js$&quot; -not -path &quot;./node_modules/*&quot; -exec jsctags {} -f \; | sed '/^$/d' | sort &amp;gt; tags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This generates a tags file fine, and if I run &lt;code&gt;echo tagfiles()&lt;/code&gt; the output gives me &lt;code&gt;['tags']&lt;/code&gt;, which means it's pointing to the correct tag file location (confirmed using &lt;code&gt;:pwd&lt;/code&gt;). &lt;code&gt;:tag&lt;/code&gt; gives me &lt;code&gt;tag stack empty&lt;/code&gt; and if I put my cursor over any method or object and hit &lt;code&gt;Ctrl-]&lt;/code&gt; I'll get &lt;code&gt;tag not found: Controller&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've referenced &lt;a href=&quot;https://vi.stackexchange.com/questions/4382/cant-get-ctags-working&quot;&gt;Can&amp;#39;t get Ctags working&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/2560/how-to-view-javascript-tags-in-vim-using-tagbar-jsctags-tern-for-vim-ctags&quot;&gt;How to view javascript tags in vim using tagbar + jsctags + tern_for_vim + ctags_exuberant?&lt;/a&gt;, both of which don't have solutions, hence the question here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attaching a section of my &lt;code&gt;.vimrc&lt;/code&gt; to show my list of plugins, js file and &lt;code&gt;.ctags&lt;/code&gt; if relevant:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;.vimrc&lt;/b&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'gmarik/Vundle.vim' &quot; Plugin Management&#xA;Plugin 'tmhedberg/matchit' &quot; Matching configuration for %&#xA;Plugin 'jelera/vim-javascript-syntax' &quot; Additional JS syntax highlighting&#xA;Plugin 'tpope/vim-surround' &quot;provides mappings to easily delete, change and add surroundings like quotes, parenths etc&#xA;Plugin 'plasticboy/vim-markdown' &quot;Markdown support&#xA;Plugin 'davidoc/taskpaper.vim' &quot;Taskpaper support&#xA;Plugin 'tpope/vim-commentary' &quot; Simple commenting in vim &#xA;Plugin 'scrooloose/nerdtree' &quot;Tree navigation&#xA;Plugin 'Xuyuanp/nerdtree-git-plugin' &quot;Nerdtree git tags for files support&#xA;Plugin 'scrooloose/syntastic' &quot;Syntax check&#xA;Plugin 'majutsushi/tagbar' &quot;Browse the tags of the current file and get an overview of its structure.&#xA;Plugin 'ctrlpvim/ctrlp.vim' &quot;Full path fuzzy file, buffer, mru, tag, ... finder for Vim.&#xA;Plugin 'bling/vim-airline' &quot;Statusbar &#xA;Plugin 'tpope/vim-fugitive' &quot;Vim wrapper, allow for git viewing in airline&#xA;Plugin 'vim-airline/vim-airline-themes' &quot;Airline themes&#xA;Plugin 'burnettk/vim-angular' &quot; Angular functionality&#xA;Plugin 'jiangmiao/auto-pairs' &quot;Insert or delete brackets, parens, quotes in pair&#xA;Plugin 'Yggdroot/indentLine' &quot;A vim plugin to display the indention levels with thin vertical lines&#xA;Plugin 'altercation/vim-colors-solarized' &quot;Solarized color theme&#xA;Plugin 'chriskempson/vim-tomorrow-theme' &quot;Tomorrow color theme&#xA;Plugin 'w0ng/vim-hybrid' &quot;Hybrid Solarized, codecademy, Jellybeans, and Tomorrow-Night&#xA;Plugin 'Valloric/YouCompleteMe' &quot; Code completion &#xA;Plugin 'marijnh/tern_for_vim' &quot;Vim tern usage, greatly improves YouCompleteMe JS use&#xA;Plugin 'elzr/vim-json' &quot; JSON highlighting &#xA;Plugin 'rking/ag.vim' &quot; Advanced searching &#xA;&quot; For JavaScript development&#xA;Plugin 'pangloss/vim-javascript' &quot;Javascript syntax highlighting&#xA;Plugin 'moll/vim-node' &quot; Node js &#xA;Plugin 'groenewege/vim-less' &quot; Less syntax&#xA;Plugin 'othree/javascript-libraries-syntax.vim' &quot; Javascript syntax library highlighting&#xA;Plugin 'othree/jspc.vim' &quot; Javascript parameter completion&#xA;Plugin '1995eaton/vim-better-javascript-completion' &quot; Expansion of vim's javascript syntax file for HTML5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;.ctags&lt;/b&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--recurse=yes&#xA;--exclude=.git&#xA;--exclude=vendor/*&#xA;--exclude=node_modules/*&#xA;--exclude=db/*&#xA;--exclude=log/*&#xA;--exclude=*.min.js&#xA;--exclude=*.css&#xA;&#xA;--langdef=less&#xA;--langmap=less:.less&#xA;--regex-less=/^[ t ]*.([A-Za-z0-9_-]+)/1/c,class,classes/&#xA;--regex-less=/^[ t ]*#([A-Za-z0-9_-]+)/1/i,id,ids/&#xA;--regex-less=/^[ t ]*(([A-Za-z0-9_-]+[ tn, ]+)+){/1/t,tag,tags/&#xA;--regex-less=/^[ t ]*@medias+([A-Za-z0-9_-]+)/1/m,media,medias/&#xA;&#xA;--languages=-JavaScript&#xA;--langdef=js&#xA;--langmap=js:.js&#xA;&#xA;&#xA;--regex-js=/[ \t. ]([A-Z][A-Z0-9._$]+)[ \t ]*[=:][ \t ]*([0-9&quot;'\[\{]|null)/\1/n,constant/&#xA;--regex-js=/\.([A-Za-z0-9._$]+)[ \t ]*=[ \t ]*\{/\1/o,object/&#xA;--regex-js=/['&quot;]*([A-Za-z0-9_$]+)['&quot;]*[ \t ]*:[ \t ]*\{/\1/o,object/&#xA;--regex-js=/([A-Za-z0-9._$]+)\[[&quot;']([A-Za-z0-9_$]+)[&quot;']\][ \t ]*=[ \t ]*\{/\1\.\2/o,object/&#xA;&#xA;--regex-js=/([A-Za-z0-9._$]+)[ \t ]*=[ \t ]*\(function\(\)/\1/c,class/&#xA;--regex-js=/['&quot;]*([A-Za-z0-9_$]+)['&quot;]*:[ \t ]*\(function\(\)/\1/c,class/&#xA;--regex-js=/class[ \t ]+([A-Za-z0-9._$]+)[ \t ]*/\1/c,class/&#xA;--regex-js=/([A-Za-z$][A-Za-z0-9_$()]+)[ \t ]*=[ \t ]*[Rr]eact.createClass[ \t ]*\(/\1/c,class/&#xA;--regex-js=/([A-Z][A-Za-z0-9_$]+)[ \t ]*=[ \t ]*[A-Za-z0-9_$]*[ \t ]*[{(]/\1/c,class/&#xA;--regex-js=/([A-Z][A-Za-z0-9_$]+)[ \t ]*:[ \t ]*[A-Za-z0-9_$]*[ \t ]*[{(]/\1/c,class/&#xA;&#xA;--regex-js=/([A-Za-z$][A-Za-z0-9_$]+)[ \t ]*=[ \t ]*function[ \t ]*\(/\1/f,function/&#xA;--regex-js=/(function)*[ \t ]*([A-Za-z$_][A-Za-z0-9_$]+)[ \t ]*\([^)]*\)[ \t ]*\{/\2/f,function/&#xA;--regex-js=/['&quot;]*([A-Za-z$][A-Za-z0-9_$]+)['&quot;]*:[ \t ]*function[ \t ]*\(/\1/m,method/&#xA;--regex-js=/([A-Za-z0-9_$]+)\[[&quot;']([A-Za-z0-9_$]+)[&quot;']\][ \t ]*=[ \t ]*function[ \t ]*\(/\2/m,method/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;js file&lt;/b&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;define(['jquery',&#xA;        'lodash',&#xA;        'backbone',&#xA;        'mobile/chart/model/chart-model',&#xA;        'mobile/chart/views/chart-view',&#xA;        'services/analytic-service'],&#xA;    function ($, _, Backbone, ChartModel, ChartView, AnalyticsService) {&#xA;        'use strict';&#xA;        // not exactly like the full chart controller&#xA;        //jshint unused:false&#xA;        function log(msg) {&#xA;            console.log('%c' + msg, 'font-size:12pt; color: #30F');&#xA;        }&#xA;        //jshint unused:true&#xA;&#xA;        function newGuid(noDashes) {&#xA;            var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {&#xA;                var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r &amp;amp; 0x3 | 0x8);&#xA;                return v.toString(16);&#xA;            });&#xA;            return noDashes ? guid.replace(/-/g, '') : guid;&#xA;        }&#xA;&#xA;        function parseJson(jsonString) {&#xA;            //our JSON may include long integer numbers that can have more digits&#xA;            // than the JS Number type supports. These numbers are all IDs so we&#xA;            // can convert them to strings before parsing.&#xA;            var massagedJson = jsonString.replace(/([^\\]{1})\&quot;:(?: {0,})([0-9]{16,})([^\.])/g, &quot;$1\&quot;:\&quot;$2\&quot;$3&quot;);&#xA;            //JSON docs are not supposed to have NaN or nan but some of our servers are adding them anyway.&#xA;            massagedJson = massagedJson.replace(/([^\\]{1})\&quot;:(?: {0,})(nan)/gi, &quot;$1\&quot;:\&quot;NaN\&quot;&quot;);&#xA;            return JSON.parse(massagedJson);&#xA;        }&#xA;&#xA;        function processHistoricalData(data) {&#xA;            if(this.isDestroyed) {&#xA;                return;&#xA;            }&#xA;&#xA;            var bars = data.bars,&#xA;                subscription = this.subscriptions[data.subscriptionId];&#xA;&#xA;            if (_.isUndefined(this.earliestTickReceived) &amp;amp;&amp;amp; data.requestIsFinal) {&#xA;                this.model.set('lastError', 'Contract has no historical data');&#xA;                this.model.set('noHistoricalData', true);&#xA;                return;&#xA;            }&#xA;&#xA;            this.model.set({&#xA;                'requestIsPending': data.requestIsPending,&#xA;                'requestIsFinal': data.requestIsFinal,&#xA;                'requestIsCompleted': data.requestIsCompleted,&#xA;                'lastError': null,&#xA;                'retryingConnection': false,&#xA;                'remainingRetries': 5&#xA;            });&#xA;&#xA;            if (bars &amp;amp;&amp;amp; bars.length &amp;gt; 0) {&#xA;                if (bars.length &amp;gt; 0) {&#xA;                    // The server can return an array of bars which only have inside market updates. In this&#xA;                    // case the converted bars array will be empty.&#xA;                    subscription.earliestTickReceived = new Date(bars[0].tickTime);&#xA;                }&#xA;            } else {&#xA;                bars = [];&#xA;            }&#xA;&#xA;            this.view.historicalData(bars);&#xA;        }&#xA;&#xA;        function processLiveData(data) {&#xA;            if(this.isDestroyed) {&#xA;                return;&#xA;            }&#xA;            this.view.liveData(data.bars);&#xA;        }&#xA;&#xA;        function isVAP(name) {&#xA;            return (name.indexOf('VAP') &amp;gt; -1);&#xA;        }&#xA;&#xA;        var Controller = function (Host, $chartEl) {&#xA;            var self = this,&#xA;                uniqueId = null,&#xA;                onErrorHandler = null,&#xA;                onClosedHandler = null,&#xA;                onConnectedHandler = null,&#xA;                onHistoricalDataHandler = null,&#xA;                onLiveDataHandler = null;&#xA;        this.analyticsService = new AnalyticsService({&#xA;            analyticsUrl: analyticsUrl,&#xA;            accessToken: Host.getAuthToken(),&#xA;            logDebug: function () {&#xA;                console.log.apply(console, arguments);&#xA;            }&#xA;        });&#xA;&#xA;        this.model = new ChartModel();&#xA;        uniqueId = this.model.getUniqueId();&#xA;        this.view = new ChartView({&#xA;            model: this.model,&#xA;            el: $chartEl[0],&#xA;            $el: $chartEl,&#xA;            controller: this&#xA;        });&#xA;&#xA;        onErrorHandler = function (err) {&#xA;            self.Host.dismissProgress();&#xA;            self.model.set('retryingConnection', false);&#xA;            self.model.set('firstHistoricalCallbackIteration', true);&#xA;            self.model.set('retryingConnection', false);&#xA;&#xA;            if (err &amp;amp;&amp;amp; err.error) {&#xA;                self.model.set('lastError', err.error);&#xA;                self.Host.log('Analytics Server Error: ' + err.error);&#xA;            }&#xA;            else {&#xA;                self.model.set('lastError', 'Analytics Server Error');&#xA;                self.Host.log('Analytics Server Error, unspecified reason');&#xA;            }&#xA;        };&#xA;   });&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks all and please let me know if I need to provide any additional details. &lt;/p&gt;&#xA;" OwnerUserId="7800" LastEditorUserId="1841" LastEditDate="2016-05-29T16:17:42.697" LastActivityDate="2016-05-29T16:17:42.697" Title="Getting tags to show in tagbar for JS file" Tags="|tags|ctags|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8016" PostTypeId="1" CreationDate="2016-05-28T18:01:12.820" Score="1" ViewCount="68" Body="&lt;p&gt;I am currently having an issue with MacVim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If two tabs are open say &lt;code&gt;tabA&lt;/code&gt; and &lt;code&gt;tabB&lt;/code&gt;. When I am on &lt;code&gt;tabA&lt;/code&gt; and then close &lt;code&gt;tabB&lt;/code&gt;, the &lt;code&gt;tabA&lt;/code&gt; goes black and I need to refresh it. I do the refresh with &lt;kbd&gt;command&lt;/kbd&gt; + &lt;kbd&gt;A&lt;/kbd&gt; (select All) .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea why that is happening and how I can fix it ?&lt;/p&gt;&#xA;" OwnerUserId="7053" LastEditorUserId="1841" LastEditDate="2016-05-29T16:13:25.863" LastActivityDate="2016-05-29T16:13:25.863" Title="MacVim current tab goes black when closing another tab" Tags="|macvim|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8020" PostTypeId="1" CreationDate="2016-05-30T08:34:41.380" Score="3" ViewCount="986" Body="&lt;p&gt;My colour scheme (morning) doesn't play nice with the quickfix window: I cannot read the selected item's location, because the foreground and background colours are the same. Because of this I want to redefine some highlighting styles, e.g. for &lt;code&gt;Search&lt;/code&gt; and &lt;code&gt;LineNr&lt;/code&gt;. However, I only want to do this in the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I edit &lt;code&gt;~/.vim/syntax/qf.vim&lt;/code&gt; with my changes, this affects also highlighting in other syntaxes. How can I change highlighting styles for one syntax only? I'm using, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Search ctermbg=white&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user2598" LastActivityDate="2020-02-11T10:27:59.993" Title="Overriding highlighting style for one syntax" Tags="|syntax-highlighting|search|colorscheme|quickfix|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8022" PostTypeId="2" ParentId="8020" CreationDate="2016-05-30T11:10:45.040" Score="0" Body="&lt;p&gt;You can use auto commands and put them in &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au QuickFixCmdPre * hi Search ctermbg=white&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command will set &lt;code&gt;ctermbg&lt;/code&gt; color as White before entering quickfix.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-05-30T19:46:25.410" LastActivityDate="2016-05-30T19:46:25.410" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8025" PostTypeId="1" AcceptedAnswerId="8060" CreationDate="2016-05-31T01:36:24.523" Score="3" ViewCount="1912" Body="&lt;p&gt;I'm having some issue with the default &quot;Dr. Chip&quot; &lt;code&gt;sh.vim&lt;/code&gt; highlighter. Specifically, it's failing to recognise the comment character &lt;code&gt;#&lt;/code&gt; after a &lt;code&gt;touch&lt;/code&gt; command. e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;touch foo # it's here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't see the &lt;code&gt;#&lt;/code&gt;, and hence the &lt;code&gt;'&lt;/code&gt; is parsed, marking all lines after this a &quot;quoted string&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/P6bMl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/P6bMlm.png&quot; alt=&quot;Syntax failing&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In @akshay's case, highlighting &lt;a href=&quot;https://i.stack.imgur.com/QwQTt.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;works&lt;/a&gt; as expected. I'm using the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arch Linux&lt;/li&gt;&#xA;&lt;li&gt;Vim 7.4 (2013 Aug 10, compiled Apr 29 2016 11:28:12); Included patches: 1-1797&lt;/li&gt;&#xA;&lt;li&gt;sh.vim version 147, but I also tried version 151&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've also tested without plugins or vimrc activated (&lt;code&gt;vim -u NONE /tmp/test.sh&lt;/code&gt;), but this also fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, &lt;code&gt;:scriptnames&lt;/code&gt; produces the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: /usr/share/vim/vim74/syntax/syntax.vim&#xA;  2: /usr/share/vim/vim74/syntax/synload.vim&#xA;  3: /usr/share/vim/vim74/syntax/syncolor.vim&#xA;  4: /usr/share/vim/vim74/filetype.vim&#xA;  5: /usr/share/vim/vimfiles/ftdetect/csv.vim&#xA;  6: /usr/share/vim/vimfiles/ftdetect/r.vim&#xA;  7: /usr/share/vim/vim74/syntax/sh.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;:set filetype?&lt;/code&gt; shows &lt;code&gt;filetype=sh&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="1278" LastEditDate="2016-05-31T08:27:15.373" LastActivityDate="2016-06-02T02:54:30.560" Title="How can I fix the default bash syntax highlighter?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8026" PostTypeId="1" AcceptedAnswerId="8103" CreationDate="2016-05-31T10:04:27.410" Score="2" ViewCount="169" Body="&lt;p&gt;In LaTeX the &lt;code&gt;\ldots&lt;/code&gt; command is used to make an ellipsis, so I wanted something like &lt;code&gt;iabbrev ... \ldots&lt;/code&gt; that would work in the middle of words, so &lt;code&gt;whatever...&lt;/code&gt; would become &lt;code&gt;whatever\ldots&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="7642" LastActivityDate="2016-06-06T07:50:42.197" Title="Something like iabbrev that works in the middle of words?" Tags="|filetype-tex|abbreviations|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8027" PostTypeId="1" AcceptedAnswerId="8028" CreationDate="2016-05-31T10:07:10.137" Score="2" ViewCount="1163" Body="&lt;p&gt;I started off with the following line in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call matchadd(...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This applies a highlight to the current window. However, if I split a new window, that window will not have the highlight applied to it. I want the highlight to be applied to every new window as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I currently have in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWinEnter * let w:matchId = matchadd(...)&#xA;autocmd BufWinLeave * call matchdelete(w:matchId)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gets the job done. However, it can lead to duplicate entries in the list of highlights given by &lt;code&gt;getmatches()&lt;/code&gt;. The issue is that &lt;code&gt;BufWinLeave&lt;/code&gt; does not trigger if the buffer that is being left is open in another window. As such, its entry does not get deleted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried using similar events to trigger the &lt;code&gt;matchadd()&lt;/code&gt; and &lt;code&gt;matchdelete()&lt;/code&gt; actions, and this is as close as I've gotten to the desired functionality.&lt;/p&gt;&#xA;" OwnerUserId="7476" LastEditorUserId="7476" LastEditDate="2016-06-01T19:59:11.203" LastActivityDate="2016-06-02T09:00:20.607" Title="Automatically call matchadd() in every new window without producing duplicate entries" Tags="|buffers|vim-windows|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8028" PostTypeId="2" ParentId="8027" CreationDate="2016-05-31T11:10:58.720" Score="7" Body="&lt;p&gt;If I understand correctly, you have the highlight applied to all windows, and not deleted.&lt;/p&gt;&#xA;&lt;p&gt;So, you have two scenarios:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;A highlight is already active and you open a new window.&lt;/p&gt;&#xA;&lt;p&gt;As the window is opened, you'll jump to it. &lt;code&gt;WinEnter&lt;/code&gt; shall be triggered. Thus, you just have to know whether the window is opened for the first time or not. You already have &lt;code&gt;w:matchId&lt;/code&gt; for that. Just test for its existence -&amp;gt;&lt;br /&gt;&#xA;&lt;code&gt;autocmd WinEnter * if !exists('w:matchId') | let w:matchId = matchadd(...) | endif&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You have several windows already opened and want to add a new highlight.&lt;/p&gt;&#xA;&lt;p&gt;Use what I've written in my initial answer to loop over all the windows. If the window already has a &lt;code&gt;w:matchId&lt;/code&gt; defined, you'll need to delete it. And finally, record &lt;code&gt;matchadd()&lt;/code&gt; result into &lt;code&gt;w:matchId&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;If you want to support several highlight simultaneously, you'll need to have a global dictionary of highlights, and for each highlight, you'll need to associate it to a pair of window id (not a window number! -&amp;gt; &lt;code&gt;win_getid()&lt;/code&gt; -- there is code to emulate it on old versions of vim in a old Q/A on SO, and in my lh-vim-lib) and &lt;code&gt;matchadd&lt;/code&gt; result or order to keep track of the match added in case you may want to remove them.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;em&gt;Below: My initial answer, before the edit.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;You could&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;simply execute &lt;code&gt;:windo call whatever(....)&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;or&#xA;&lt;ul&gt;&#xA;&lt;li&gt;record the current window id with &lt;code&gt;win_getid()&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;then jump manually, with &lt;code&gt;wincmd w&lt;/code&gt;, to each window in between 1 and &lt;code&gt;winnr('$')&lt;/code&gt; to call your function&lt;/li&gt;&#xA;&lt;li&gt;and finally return the window where you were.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-06-02T09:00:20.607" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8029" PostTypeId="1" AcceptedAnswerId="8031" CreationDate="2016-05-31T12:10:28.933" Score="8" ViewCount="2349" Body="&lt;h2&gt;Problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I am trying to implement &quot;trimming trailing whitespace in changed lines only&quot;. For this purpose, I intercept &lt;code&gt;TextChanged&lt;/code&gt; and &lt;code&gt;TextChangedI&lt;/code&gt; autocmd events and record the current line (&lt;code&gt;line(.)&lt;/code&gt;) in the handler. The changed lines are then trimmed in a &lt;code&gt;BufWritePre&lt;/code&gt; autocmd event handler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works OK, except for the case when a line is inserted/removed. In this case, I need to shift existing records.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially I assumed that the cursor always gets placed on last inserted/first removed line (with this knowledge, it is possible to calculate the range, if you remember the previous line count), but with undo and paste this is not true.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;How to determine the exact line range which has been inserted/removed with current TextChanged event?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Code&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The current (broken) python handler code is here (I use &lt;a href=&quot;https://github.com/amoffat/snake&quot; rel=&quot;noreferrer&quot;&gt;amoffat/snake&lt;/a&gt; to script in python):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@on_autocmd(&quot;TextChanged,TextChangedI&quot;, &quot;*&quot;)&#xA;def trim_whitespace_remember_line(context):&#xA;    line_count_old = int(my_get(&quot;line_count&quot;))&#xA;    line_count = int(vim.eval(&quot;line(\&quot;$\&quot;)&quot;))&#xA;    line = int(vim.eval(&quot;line(\&quot;.\&quot;)&quot;))&#xA;&#xA;    if line_count_old != line_count:&#xA;        log(&quot;trim_whitespace_remember_line: line_count %d -&amp;gt; %d&quot; % (line_count_old, line_count))&#xA;        if line_count &amp;gt; line_count_old:&#xA;            # FIXME: we assume that the cursor is placed on the last inserted line&#xA;            diff = line_count - line_count_old&#xA;            log(&quot;trim_whitespace_remember_line: %d lines inserted, current line %d&quot; % (diff, line))&#xA;            trim_whitespace_lines_inserted(context, line - diff + 1, line)&#xA;        else:&#xA;            # FIXME: we assume that the cursor is placed on the first line after removed block,&#xA;            # i. e. on the first removed line (before reaccounting)&#xA;            diff = line_count_old - line_count&#xA;            log(&quot;trim_whitespace_remember_line: %d lines removed, current line %d&quot; % (diff, line))&#xA;            trim_whitespace_lines_removed(context, line, line + diff - 1)&#xA;    else:&#xA;        log(&quot;trim_whitespace_remember_line: line changed, current line %d&quot; % line)&#xA;        lines = my_get(&quot;modified_lines&quot;)&#xA;        line = str(line) + &quot; &quot;&#xA;        if lines.rfind(&quot; &quot; + line) == -1:&#xA;            lines = lines + line&#xA;            my_let(context, &quot;modified_lines&quot;, lines)&#xA;&#xA;    my_let(context, &quot;line_count&quot;, line_count)&#xA;&#xA;    log(&quot;trim_whitespace_remember_line: new lines = '%s'&quot; % my_get(&quot;modified_lines&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Clarification&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This all is needed because I often work on projects with a legacy codebase where no one paid attention to trailing whitespace and/or sanity of code formatting altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trimming &lt;em&gt;all&lt;/em&gt; trailing whitespace produces a diff polluted with unrelated changes all over the file, which makes troubles at code review. Hence, I want to avoid trimming whitespace on unchanged lines, but at the same time ensure that there is no trailing whitespace introduced by &lt;em&gt;me&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7826" LastEditorUserId="7826" LastEditDate="2016-05-31T19:47:34.793" LastActivityDate="2016-06-03T23:35:48.193" Title="From a TextChanged autocommand event, how to get the range that has been changed?" Tags="|autocmd|whitespace|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8030" PostTypeId="1" CreationDate="2016-05-31T13:45:23.233" Score="2" ViewCount="975" Body="&lt;p&gt;I've been trying to get my Vim setup similar to other IDE's (pycharm, webstorm) and I'm hoping to get the functionality of having code completion for injected objects. I have YouCompleteMe and tern_for_vim properly installed and configured so I'm able to get in-file code completion and general javascript syntax completion, but I'm wondering if it's possible to get this kind of code completion as well:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EAzZJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EAzZJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, here's my .tern-project file at the root of my project hierarchy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    &quot;libs&quot;: [&#xA;        &quot;browser&quot;,&#xA;        &quot;jquery&quot;&#xA;    ],&#xA;&#xA;    &quot;plugins&quot;: {&#xA;        &quot;requirejs&quot;: {&#xA;            &quot;baseURL&quot;: &quot;./pytrader/static/scripts/&quot;,&#xA;            &quot;paths&quot;: {&#xA;                &quot;core&quot;: &quot;./pytrader/static/scripts/core.js&quot;,&#xA;                &quot;libs&quot;: &quot;./pytrader/static/scripts/lib&quot;,&#xA;                &quot;jquery&quot;: &quot;./pytrader/static/scripts/lib/jquery&quot;,&#xA;                &quot;lodash&quot;: &quot;./pytrader/static/scripts/lib/lodash&quot;,&#xA;                &quot;backbone&quot;: &quot;./pytrader/static/scripts/lib/backbone&quot;,&#xA;                &quot;stxKernel&quot;: &quot;./pytrader/static/scripts/lib/chartIQ&quot;,&#xA;                &quot;bootstrap&quot;: &quot;./pytrader/static/scripts/lib/bootstrap&quot;&#xA;            }&#xA;        },&#xA;        &quot;node&quot;: {}&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here's the list of plugins I'm using in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'gmarik/Vundle.vim' &quot; Plugin Management&#xA;Plugin 'tmhedberg/matchit' &quot; Matching configuration for %&#xA;Plugin 'jelera/vim-javascript-syntax' &quot; Additional JS syntax highlighting&#xA;Plugin 'tpope/vim-surround' &quot;provides mappings to easily delete, change and add surroundings like quotes, parenths etc&#xA;Plugin 'plasticboy/vim-markdown' &quot;Markdown support&#xA;Plugin 'davidoc/taskpaper.vim' &quot;Taskpaper support&#xA;Plugin 'tpope/vim-commentary' &quot; Simple commenting in vim &#xA;Plugin 'scrooloose/nerdtree' &quot;Tree navigation&#xA;Plugin 'Xuyuanp/nerdtree-git-plugin' &quot;Nerdtree git tags for files support&#xA;Plugin 'scrooloose/syntastic' &quot;Syntax check&#xA;Plugin 'majutsushi/tagbar' &quot;Browse the tags of the current file and get an overview of its structure.&#xA;Plugin 'ctrlpvim/ctrlp.vim' &quot;Full path fuzzy file, buffer, mru, tag, ... finder for Vim.&#xA;Plugin 'bling/vim-airline' &quot;Statusbar &#xA;Plugin 'tpope/vim-fugitive' &quot;Vim wrapper, allow for git viewing in airline&#xA;Plugin 'vim-airline/vim-airline-themes' &quot;Airline themes&#xA;Plugin 'burnettk/vim-angular' &quot; Angular functionality&#xA;Plugin 'jiangmiao/auto-pairs' &quot;Insert or delete brackets, parens, quotes in pair&#xA;Plugin 'Yggdroot/indentLine' &quot;A vim plugin to display the indention levels with thin vertical lines&#xA;Plugin 'altercation/vim-colors-solarized' &quot;Solarized color theme&#xA;Plugin 'chriskempson/vim-tomorrow-theme' &quot;Tomorrow color theme&#xA;Plugin 'w0ng/vim-hybrid' &quot;Hybrid Solarized, codecademy, Jellybeans, and Tomorrow-Night&#xA;Plugin 'Valloric/YouCompleteMe' &quot; Code completion &#xA;Plugin 'marijnh/tern_for_vim' &quot;Vim tern usage, greatly improves YouCompleteMe JS use&#xA;Plugin 'elzr/vim-json' &quot; JSON highlighting &#xA;Plugin 'rking/ag.vim' &quot; Advanced searching &#xA;&quot;For JavaScript development&#xA;Plugin 'pangloss/vim-javascript' &quot;Javascript syntax highlighting&#xA;Plugin 'moll/vim-node' &quot; Node js &#xA;Plugin 'groenewege/vim-less' &quot; Less syntax&#xA;Plugin 'othree/javascript-libraries-syntax.vim' &quot; Javascript syntax library highlighting&#xA;Plugin 'othree/jspc.vim' &quot; Javascript parameter completion&#xA;Plugin '1995eaton/vim-better-javascript-completion' &quot; Expansion of vim's javascript syntax file for HTML5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please let me know if I need to put any more details or information. &lt;/p&gt;&#xA;" OwnerUserId="7800" LastActivityDate="2016-05-31T13:45:23.233" Title="Code Completion for Module based JavaScript files in Vim" Tags="|autocompletion|plugin-you-complete-me|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8031" PostTypeId="2" ParentId="8029" CreationDate="2016-05-31T15:44:03.110" Score="5" Body="&lt;p&gt;Is your concern about performance?  Calling out to Python code will add unneeded overhead that would make an attempt at performance optimization moot.  In any case, you can get the boundaries with &lt;code&gt;getpos()&lt;/code&gt; using the marks &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let start = getpos(&quot;'[&quot;)[1:2]&#xA;let end = getpos(&quot;']&quot;)[1:2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I think you may be over-engineering the problem.  The solution can be much simpler using &lt;code&gt;autocmd&lt;/code&gt;'s depending on when you want the trailing whitespace trimmed:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;After leaving insert mode&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertLeave * '[,']s/\s\+$//e | normal! `^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the marks mentioned above, replace trailing whitespace only on the last inserted lines.  The &lt;code&gt;/e&lt;/code&gt; flag ignores the &quot;pattern not found error&quot;.  &lt;code&gt;normal! `^&lt;/code&gt; returns your cursor to the last insert position.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;On TextChanged&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd TextChanged * silent! '[,']s/\s\+$//e | normal! `.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The same as above, but with &lt;code&gt;silent!&lt;/code&gt; since the marks may be invalid after a delete/undo.  &lt;code&gt;normal! `.&lt;/code&gt; returns the cursor to the last change position.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;When the buffer is saved&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * g/\s\+$/s///e&#xA;autocmd BufWritePost * normal! `^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the one I prefer since I don't like surprises while I'm typing.  It uses &lt;code&gt;:global&lt;/code&gt; to first find lines that have trailing whitespace.  Then the &lt;code&gt;s///e&lt;/code&gt; substitution reuses the pattern from &lt;code&gt;:global&lt;/code&gt; to remove the trailing whitespace. The &lt;code&gt;BufWritePost&lt;/code&gt; autocmd puts your cursor back after the buffer is saved.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;When the buffer is saved (A better implementation)&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:strip_whitespace()&#xA;    let saved = @/&#xA;    let l = line(&quot;.&quot;)&#xA;    let c = col(&quot;.&quot;)&#xA;    %s/\s\+$//e&#xA;    let @/ = saved&#xA;    call cursor(l, c)&#xA;endfunction&#xA;&#xA;autocmd BufWritePre * call s:strip_whitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This one is wrapped in a function that restores the previous search and cursor position.  It uses &lt;code&gt;:%s&lt;/code&gt; which operates on all buffer lines.  &lt;code&gt;g/\s\+$/s///e&lt;/code&gt; already does this, but the pattern would match twice on each line.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Remove blank lines&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In case you want to also remove blank lines, you can again use &lt;code&gt;:global&lt;/code&gt; to find and remove them, e.g. &lt;code&gt;'[,']g/^\s*$/normal! &quot;_dd&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-05-31T18:40:45.863" LastActivityDate="2016-05-31T18:40:45.863" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="8032" PostTypeId="2" ParentId="7899" CreationDate="2016-05-31T16:59:45.710" Score="2" Body="&lt;p&gt;Vim is able to use the same completion database if the database is external to each vim instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, completion will be somewhat 'shared' if you use &lt;code&gt;ctags&lt;/code&gt; completion or &lt;code&gt;youcompleteme&lt;/code&gt; or any other plugin that uses external processes or files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Word completion is not quite useful for you because it will only use words in the same file: &lt;code&gt;C-N&lt;/code&gt;/&lt;code&gt;C-P&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;omni&lt;/code&gt; and &lt;code&gt;ctags&lt;/code&gt; completion will use &lt;code&gt;ctags&lt;/code&gt; database (which should be built by &lt;code&gt;exuberant ctags&lt;/code&gt; beforehand) and will be shared among all instances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Type &lt;code&gt;C-X C-O&lt;/code&gt; for omni-completion, &lt;code&gt;C-X C-]&lt;/code&gt; for ctags completion.&lt;/p&gt;&#xA;" OwnerUserId="5999" LastActivityDate="2016-05-31T16:59:45.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8033" PostTypeId="2" ParentId="8029" CreationDate="2016-05-31T19:36:08.737" Score="1" Body="&lt;p&gt;In case anyone is interested, the full code is &lt;a href=&quot;https://github.com/intelfx/dotfiles/blob/master/.vimrc.py&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; (GitHub), and autocmd handler looks like this (again, python code using snake):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@on_autocmd(&quot;TextChanged,TextChangedI&quot;, &quot;*&quot;)&#xA;def trim_whitespace_remember_line(context):&#xA;    line_count_old = int(my_get(&quot;line_count&quot;))&#xA;    line_count = int(vim.eval(&quot;line(\&quot;$\&quot;)&quot;))&#xA;&#xA;    if line_count_old != line_count:&#xA;        change_start = int(vim.eval(&quot;line(\&quot;'[\&quot;)&quot;))&#xA;        change_end = int(vim.eval(&quot;line(\&quot;']\&quot;)&quot;))&#xA;&#xA;        if line_count &amp;gt; line_count_old:&#xA;            trim_whitespace_lines_inserted(context, change_start, change_end)&#xA;        else:&#xA;            diff = line_count_old - line_count&#xA;            assert change_start == change_end&#xA;            trim_whitespace_lines_removed(context, change_start, change_start + diff - 1)&#xA;    else:&#xA;        line = vim.eval(&quot;line(\&quot;.\&quot;)&quot;) + &quot; &quot;&#xA;        lines = my_get(&quot;modified_lines&quot;)&#xA;&#xA;        if lines.rfind(&quot; &quot; + line) == -1:&#xA;            lines = lines + line&#xA;            my_let(context, &quot;modified_lines&quot;, lines)&#xA;&#xA;    my_let(context, &quot;line_count&quot;, line_count)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7826" LastEditorUserId="7826" LastEditDate="2016-05-31T19:48:22.663" LastActivityDate="2016-05-31T19:48:22.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8034" PostTypeId="1" AcceptedAnswerId="8039" CreationDate="2016-05-31T21:29:36.757" Score="2" ViewCount="768" Body="&lt;p&gt;I found a vim tip a while back recommending swapping visual and visual block mode (&lt;a href=&quot;http://howivim.com/2016/damian-conway/&quot; rel=&quot;nofollow&quot;&gt;http://howivim.com/2016/damian-conway/&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the most part this is really useful. I frequently find myself wanting to only capture a part of a block containing similar text or to delete or insert a bunch of text at the beginning of the line and have it affect every line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing I'm missing in this setup is the ability to yank all the lines in that the visual block touches. Because &lt;code&gt;Y&lt;/code&gt; yanks the whole line in normal mode, I expected it to the same in Visual Block, is there a way to configure it to yank the whole of every line in the visual block selection?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2016-06-14T18:47:08.507" Title="Visual block yank to end of line" Tags="|key-bindings|visual-block|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8035" PostTypeId="1" CreationDate="2016-05-31T22:03:08.213" Score="1" ViewCount="89" Body="&lt;p&gt;I'm in neovim command mode and press &lt;code&gt;x&lt;/code&gt; on keyboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way a python remote plugin can react to this keypress?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What to do if the plugin should react to several different keys?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my setup: Neovim is started like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NVIM_LISTEN_ADDRESS=/tmp/nvim nvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;remoteplugin.py&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;from neovim import attach&#xA;nvim = attach('socket', path='/tmp/nvim')&#xA;def mycallback():&#xA;    //react on 'x' keypress&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I frankly didn't understand the suggestion on the &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Plugin-UI-architecture&quot; rel=&quot;nofollow&quot;&gt;neowiki pages&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while true&#xA;    handle(next_vim_event())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What would be the corresponding python code?&lt;/p&gt;&#xA;" OwnerUserId="7831" LastEditorUserId="205" LastEditDate="2016-06-01T11:56:24.547" LastActivityDate="2016-06-23T22:48:10.337" Title="How do I react to keypress in a neovim python remote plugin?" Tags="|neovim|plugin-system|" AnswerCount="0" CommentCount="3" ClosedDate="2016-06-24T07:56:27.980" ContentLicense="CC BY-SA 3.0" />
  <row Id="8036" PostTypeId="1" CreationDate="2016-05-31T22:19:21.403" Score="2" ViewCount="13606" Body="&lt;p&gt;The following will replace the first comma on each line with a pipe:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/,/|/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do the same for the last comma?&lt;/p&gt;&#xA;" OwnerUserId="7832" LastEditorUserId="205" LastEditDate="2016-06-01T11:48:17.243" LastActivityDate="2016-06-01T14:51:32.253" Title="Replacing last comma on each line" Tags="|regular-expression|search|replace|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8037" PostTypeId="2" ParentId="8036" CreationDate="2016-05-31T22:24:24.167" Score="6" Body="&lt;p&gt;The best way to do this is to allow any character except for a newline, &lt;code&gt;.&lt;/code&gt; any number of times, &lt;code&gt;*&lt;/code&gt; followed by a comma &lt;code&gt;,&lt;/code&gt;. This gives us the following regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(.*\),/\1|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, the more readable way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(.*),/\1|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works because &lt;code&gt;*&lt;/code&gt; is &lt;a href=&quot;http://vimregex.com/#Non-Greedy&quot;&gt;&lt;em&gt;&quot;greedy&quot;&lt;/em&gt;&lt;/a&gt; by default, meaning it will match as many characters as possible.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-05-31T22:24:24.167" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8038" PostTypeId="2" ParentId="8034" CreationDate="2016-05-31T22:36:30.773" Score="2" Body="&lt;p&gt;Well, this isn't the perfect solution, since it requires using an extra register, but it works. Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap Y &amp;lt;esc&amp;gt;:let @a=&quot;&quot;&amp;lt;cr&amp;gt;gv:norm &quot;AY&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;esc&amp;gt;:let @a=&quot;&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Escape, and clear register 'a'. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reselect our last visual block.    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Apply the following keystrokes to every line in the visual selection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;AY&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yank the whole line, and append it to register 'a'.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-05-31T22:36:30.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8039" PostTypeId="2" ParentId="8034" CreationDate="2016-05-31T23:33:37.413" Score="8" Body="&lt;p&gt;Maybe this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap Y :yank&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Being an ex command, &lt;code&gt;:yank&lt;/code&gt; will automatically copy whole lines.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-05-31T23:33:37.413" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8040" PostTypeId="2" ParentId="8036" CreationDate="2016-05-31T23:46:06.540" Score="3" Body="&lt;p&gt;An alternative, just for the sake of it :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v.*\zs,\ze[^,]*/|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be translated as: go search (&lt;code&gt;s&lt;/code&gt;) on each line (&lt;code&gt;%&lt;/code&gt;) for any number of chars (&lt;code&gt;.*&lt;/code&gt;) followed by &quot;a comma not followed by another one, i.e. followed by any other character, but comma&quot; (&lt;code&gt;,[^,]*&lt;/code&gt;). Using &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; around that one comma, we alter the match to only contain the character we want to act on. Therefore, the replacement part is simply the bar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit/Update&lt;/em&gt;: of course, as &lt;a href=&quot;https://vi.stackexchange.com/users/21/karl-yngve-lerv%c3%a5g&quot;&gt;Karl Yngve Lervåg&lt;/a&gt; mentions, the part after the comma isn't needed at all ..., so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.*\zs,/|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... is the better incantation.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-06-01T10:44:46.760" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8041" PostTypeId="2" ParentId="8036" CreationDate="2016-06-01T05:16:29.780" Score="4" Body="&lt;p&gt;Another one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/,\ze[^,]\{-}$/|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-06-01T05:16:29.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8042" PostTypeId="2" ParentId="8036" CreationDate="2016-06-01T05:26:19.927" Score="1" Body="&lt;p&gt;I will prefer to go with a macro.&#xA;Go to line 1 &lt;code&gt;:1&lt;/code&gt;.&#xA;Press &lt;code&gt;qa&lt;/code&gt; to start recording in  register &lt;code&gt;A&lt;/code&gt;.&#xA;Then, type &lt;code&gt;$&lt;/code&gt; to move to end of line. Then, &lt;code&gt;F,&lt;/code&gt; or &lt;code&gt;/,&amp;lt;CR&amp;gt;N&lt;/code&gt; to search backwards for a comma. Then, press &lt;code&gt;r|&lt;/code&gt; to replace it with a bar. Press &lt;code&gt;j&lt;/code&gt; to move to next line. Press &lt;code&gt;@a&lt;/code&gt; to replay macro recursively. Then, stop macro by pressing &lt;code&gt;q&lt;/code&gt;.&#xA;(In cade, if The macro runs infinitely at the last line of file. You can abort it by pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;Kbd&gt;C&lt;/kbd&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="7161" LastActivityDate="2016-06-01T05:26:19.927" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8044" PostTypeId="2" ParentId="7939" CreationDate="2016-06-01T08:11:34.750" Score="1" Body="&lt;p&gt;I think you are over-complicating your original regex by trying to trap the character &lt;em&gt;before&lt;/em&gt; the backslash. The following seems to work on your sample text. You will need to expand the [...] expression to include all special characters you may come across. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s!\v\\([][\_])!\1!g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;[][\_]&lt;/code&gt; is a single entity comprising ] (which has to come first) and [,\,_ but you probably already knew that. &lt;/p&gt;&#xA;" OwnerUserId="7836" LastActivityDate="2016-06-01T08:11:34.750" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8045" PostTypeId="1" AcceptedAnswerId="8047" CreationDate="2016-06-01T11:57:40.353" Score="6" ViewCount="1523" Body="&lt;p&gt;I need to create a list containing a predefined number of zeros.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can create an empty one with &lt;code&gt;let foo = []&lt;/code&gt; but I would need to initialize it with a number of zeros contained in a variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#List&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h List&lt;/code&gt;&lt;/a&gt; doesn't seem to mention this use case, what's the most efficient way to do that?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A second part of my question is about nested lists:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to create a list of lists, with the number of inner lists contained in a variable and the length of the inner lists in another variable. (The inner lists are all of the same size)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to the method used for one list in this case?&#xA;If not how to do it?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-06-01T12:12:38.883" LastActivityDate="2016-06-01T15:29:44.797" Title="What's the best way to initialize a list of a predefined length?" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8047" PostTypeId="2" ParentId="8045" CreationDate="2016-06-01T11:58:45.743" Score="6" Body="&lt;p&gt;You can combine the &lt;code&gt;map&lt;/code&gt; and &lt;code&gt;range&lt;/code&gt; function for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo map(range(4), 0)&#xA;[0, 0, 0, 0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;range(4)&lt;/code&gt; returns a list of number defined by the arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[0, 1, 2, 3]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map([0, 1, 2, 3], 0)&lt;/code&gt; replace every element in the array with &lt;code&gt;0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Fill(len, char)&#xA;    return map(range(a:len), a:char)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo Fill(4, 'a')&#xA;['a', 'a', 'a', 'a']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For the recursive fill, you can use the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FillRecursive(len1, len2, char)&#xA;  if a:len2 == -1&#xA;    return map(range(a:len1), 'a:char')&#xA;  endif&#xA;&#xA;  return map(range(a:len1), 'FillRecursive(a:len2, -1, a:char)')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo FillRecursive(4,4,'a')&#xA;[['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see the interesting part in the map: instead of passing the &lt;code&gt;l:inner&lt;/code&gt; directly, because the &lt;code&gt;map&lt;/code&gt; function cannot accept a list, but it can accept the literal string containing the list.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-01T12:26:29.507" LastActivityDate="2016-06-01T12:26:29.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8048" PostTypeId="1" AcceptedAnswerId="8062" CreationDate="2016-06-01T12:49:03.663" Score="5" ViewCount="772" Body="&lt;p&gt;I am running a simple substitution on many files with &lt;code&gt;:argdo %s/foo/\rfoo/ge | update&lt;/code&gt;. Vim shows the progress through files (number of substitutions in file) and when the screen fills up it blocks with the prompt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;&quot;Data_357.csv&quot; 63 lines, 22551 characters&#xA;&quot;Data_358.csv&quot; 204 lines, 946953 characters&#xA;-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I make it run non-stop?&lt;/p&gt;&#xA;" OwnerUserId="7004" LastActivityDate="2016-06-02T07:39:28.917" Title="Block-less argdo on many files?" Tags="|buffers|substitute|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8049" PostTypeId="2" ParentId="8045" CreationDate="2016-06-01T12:50:35.257" Score="5" Body="&lt;pre&gt;&lt;code&gt;repeat([0], 4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is what you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h repeat()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Regarding the inner lists/matrices, we could think about:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo repeat([repeat([0], 5)], 2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however, it will do a shallow copy of the first inner list.  See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let t = repeat([repeat([0], 5)], 2)&#xA;let t[0][0] = 42&#xA;echo t[0]&#xA;echo t[1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All inner lists need to be copied. We are back to &lt;code&gt;map()&lt;/code&gt;+&lt;code&gt;copy()&lt;/code&gt;. Note that somehow with a more complex need may require the use of &lt;code&gt;deepcopy()&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let t = map(repeat([repeat([0], 5)], 2), 'copy(v:val)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-06-01T15:29:44.797" LastActivityDate="2016-06-01T15:29:44.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8050" PostTypeId="1" CreationDate="2016-06-01T13:54:27.987" Score="2" ViewCount="75" Body="&lt;p&gt;I'm using the &lt;a href=&quot;https://github.com/ntpeters/vim-better-whitespace/&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;ntpeters/vim-better-whitespace&lt;/code&gt;&lt;/a&gt; plugin to automatically highlight trailing whitespaces (and removing them). I also want to highlight &quot;irregular&quot; whitespace characters, such as &lt;code&gt; (U+00A0)&lt;/code&gt; and so I've added this to my &lt;code&gt;.vimrc&lt;/code&gt;;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight IrregularWhitespace ctermbg=red&#xA;match IrregularWhitespace / / &quot; U+00A0 (not a traditional space)&#xA;autocmd BufWinEnter,CursorMovedI * highlight IrregularWhitespacee ctermbg=red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I have the &lt;code&gt;vim-better-whitespace&lt;/code&gt; plugin enabled, this does not seem to work at all? If I disable the plugin, it works exactly like I want it to.&lt;/p&gt;&#xA;" OwnerUserId="7840" LastEditorUserId="7840" LastEditDate="2016-06-01T16:16:42.343" LastActivityDate="2016-06-01T16:16:42.343" Title="Autocmd overshadowing?" Tags="|vimrc|highlight|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8051" PostTypeId="2" ParentId="8036" CreationDate="2016-06-01T14:10:30.443" Score="3" Body="&lt;p&gt;Oh, I'll jump on the bandwagon. I can't resist a good regular expression question. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since really what we're trying to find is a &quot;comma with no commas after it,&quot; i propose we use a negative lookahead. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/,\(.*,\)\@!/|/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This matches a comma only if it does not have &lt;code&gt;.*,&lt;/code&gt; following it. However it only matches the comma since anything in a lookaround is only for context and not part of the match. Then we substitute it with a pipe, and our job is done.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-06-01T14:51:32.253" LastActivityDate="2016-06-01T14:51:32.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8052" PostTypeId="2" ParentId="8050" CreationDate="2016-06-01T14:27:23.380" Score="3" Body="&lt;p&gt;If you're just looking to see that character I believe this will do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list listchars=nbsp:·&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can put whatever character you like after the colon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h listchars&lt;/code&gt; for more info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to change the hilighting of that character you can  use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight SpecialKey...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But be warned that this will also affect the representation of characters like &lt;code&gt;^Z&lt;/code&gt; as well.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-06-01T14:27:23.380" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8053" PostTypeId="1" AcceptedAnswerId="8055" CreationDate="2016-06-01T15:22:26.790" Score="6" ViewCount="1476" Body="&lt;p&gt;In Gvim there is an option upon rightclicking a highlighted word to ignore all such words. What is the shortcut for that?&lt;/p&gt;&#xA;" OwnerUserId="7842" LastActivityDate="2016-06-01T15:30:17.513" Title="vim shortcut for ignore spell-checked word" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8055" PostTypeId="2" ParentId="8053" CreationDate="2016-06-01T15:30:17.513" Score="11" Body="&lt;p&gt;Use &lt;kbd&gt;zG&lt;/kbd&gt;. From &lt;code&gt;:help zG&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *zG*&#xA;zG          Like &quot;zg&quot; but add the word to the internal word list&#xA;            |internal-wordlist|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and from &lt;code&gt;:help internal-wordlist&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *internal-wordlist*&#xA;The internal word list is used for all buffers where 'spell' is set.  It is&#xA;not stored, it is lost when you exit Vim.  It is also cleared when 'encoding'&#xA;is set.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-01T15:30:17.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8056" PostTypeId="1" CreationDate="2016-06-01T17:17:44.390" Score="20" ViewCount="3598" Body="&lt;p&gt;I have an autocmd for TeX and Markdown files to save the file automatically. Nothing unusual:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorHold *.tex,*.md w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, as custom settings for these files increased, I split them off into &lt;code&gt;ftplugin/tex.vim&lt;/code&gt; and &lt;code&gt;ftplugin/markdown.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ftplugin/tex.vim&#xA;autocmd CursorHold *.tex w&#xA;&quot; ftplugin/markdown.vim&#xA;autocmd CursorHold *.md w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, these files are sourced only for the appropriate files, so the pattern matching is redundant. Apparently, &lt;code&gt;autocmd&lt;/code&gt;s can be buffer-local. From &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-buffer-local&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h autocmd-buffer-local&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Buffer-local autocommands are attached to a specific buffer.  They are useful&#xA;if the buffer does not have a name and when the name does not match a specific&#xA;pattern.  But it also means they must be explicitly added to each buffer.&#xA;&#xA;Instead of a pattern buffer-local autocommands use one of these forms:&#xA;        &amp;lt;buffer&amp;gt;        current buffer&#xA;        &amp;lt;buffer=99&amp;gt;     buffer number 99&#xA;        &amp;lt;buffer=abuf&amp;gt;   using &amp;lt;abuf&amp;gt; (only when executing autocommands)&#xA;                        &amp;lt;abuf&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That seems to be meant for such usage. Now, both &lt;code&gt;ftplugin/tex.vim&lt;/code&gt; and &lt;code&gt;ftplugin/markdown.vim&lt;/code&gt; can have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorHold &amp;lt;buffer&amp;gt; w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not really concerned about the actual extension as long as the filetype is correct, so this saves me from having to worry about &lt;code&gt;*.md&lt;/code&gt; and &lt;code&gt;*.markdown&lt;/code&gt; and whatever other extensions are valid for Markdown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this usage of &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; correct? Are there any pitfalls I should be aware of? Will things get messy if I wipe a buffer and open another (hopefully the numbers won't collide, but …)?&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-11-22T11:04:48.410" Title="For an autocmd in a ftplugin, should I use pattern matching or &lt;buffer&gt;?" Tags="|autocmd|filetype|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8057" PostTypeId="1" AcceptedAnswerId="8058" CreationDate="2016-06-01T20:31:29.253" Score="1" ViewCount="1378" Body="&lt;p&gt;I'm trying to use &lt;a href=&quot;http://ethanschoonover.com/solarized&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; color scheme on my Ubuntu system. I installed the package using Option 1 in &lt;a href=&quot;https://github.com/altercation/vim-colors-solarized&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub&lt;/a&gt;, and modified .vimrc as instructed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out that the colors displayed are different as in the author's website. C code has the following scheme according to the website:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8GcEk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8GcEk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The C++ code has the following scheme on my own machine:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xXLk7.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xXLk7.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure my &lt;code&gt;.vimrc&lt;/code&gt; to have the same display effect as in the website? Or do I need to setup something on my terminal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-------------Edited-------&lt;/p&gt;&#xA;&#xA;&lt;p&gt;gvim displays the color as expected. The only problem is vim on terminal&lt;/p&gt;&#xA;" OwnerUserId="1080" LastEditorUserId="1080" LastEditDate="2016-06-02T00:29:41.307" LastActivityDate="2016-06-11T17:37:20.970" Title="Ethan Schoonover's Solarized color scheme does not work as expected" Tags="|vimrc|terminal|colorscheme|linux-ubuntu|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8058" PostTypeId="2" ParentId="8057" CreationDate="2016-06-01T20:59:08.793" Score="1" Body="&lt;p&gt;To be able to take advantage of that theme you must select an appropriate palette in your terminal settings as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8n7fHm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8n7fHm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FqmIum.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FqmIum.png&quot; alt=&quot;screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't find that palette in your terminal settings (for instance if you are on Ubuntu 14.04 LTS) you must install a &lt;em&gt;solarized&lt;/em&gt; Theme for the gnome-terminal first.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get the repo from &lt;a href=&quot;https://github.com/Anthony25/gnome-terminal-colors-solarized&quot; rel=&quot;nofollow noreferrer&quot;&gt;gnome-terminal-colors-solarized&#xA;&lt;/a&gt; on Github&lt;/li&gt;&#xA;&lt;li&gt;create a new profile for your terminal to easily get rid of that color-scheme in case you don't like it&#xA;&lt;a href=&quot;https://i.stack.imgur.com/DuaKpm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DuaKpm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tMKMFm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tMKMFm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;switch to that profile&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/SxUgKm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SxUgKm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;now install the color-scheme with &lt;code&gt;./install.sh&lt;/code&gt; from the cloned git-repo, you will be asked two questions, be sure to answer the second one with the profile you just created&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Please select a Gnome Terminal profile:&lt;br&gt;&#xA;        1) Default&lt;br&gt;&#xA;        2) solarized&lt;br&gt;&#xA;        #? 2&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now you are ready to install the vim-solarized theme.&lt;/p&gt;&#xA;" OwnerUserId="1238" LastEditorUserId="1238" LastEditDate="2016-06-11T17:37:20.970" LastActivityDate="2016-06-11T17:37:20.970" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8059" PostTypeId="1" AcceptedAnswerId="8061" CreationDate="2016-06-02T01:57:25.593" Score="21" ViewCount="382" Body="&lt;p&gt;This is something that has bugged me for a long time, but I've never gotten around to asking about. Say the text in your buffer looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hello&#xA;World&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I put my cursor somewhere in line 2, and do &lt;kbd&gt;yk&lt;/kbd&gt;, my cursor will end on line 1. This seems to imply an operator plus a motion also moves the cursor. However, if I start on line 1 and do &lt;kbd&gt;yj&lt;/kbd&gt;, my cursor remains in the same spot. The same inconsistency happens with a lot of keys.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Moves   Doesn't move&#xA;gg      G&#xA;h       l&#xA;{       }&#xA;(       )&#xA;T       t&#xA;F       f&#xA;?       /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So what's with this behavior? Is this expected and well documented? Is there a name for this? Can it be overridden? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, it seems like &quot;Backwards moves, forwards does not&quot;, but is there a way I can definitively tell whether or not an operator+motion will move the cursor or not?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="1841" LastEditDate="2016-06-02T07:34:08.600" LastActivityDate="2022-08-20T08:40:36.113" Title="Why does &quot;Operator&quot; + &quot;Motion&quot; behave inconsistently?" Tags="|cursor-motions|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8060" PostTypeId="2" ParentId="8025" CreationDate="2016-06-02T02:54:30.560" Score="2" Body="&lt;p&gt;I contacted Charles E Campbell (aka Dr Chip), the maintainer of default &lt;code&gt;sh.vim&lt;/code&gt; highlighter. He responded very quickly with a new &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH&quot; rel=&quot;nofollow noreferrer&quot;&gt;version 152&lt;/a&gt; that fixes this problem for me. I'm still not sure why this problem only affected me and not @akshay though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KPW3y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KPW3ym.png&quot; alt=&quot;fixes syntax&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1278" LastActivityDate="2016-06-02T02:54:30.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8061" PostTypeId="2" ParentId="8059" CreationDate="2016-06-02T03:30:14.717" Score="18" Body="&lt;p&gt;From &lt;code&gt;:h operator&lt;/code&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;After applying the operator the cursor is mostly left at the start of the text&#xA;that was operated upon.  For example, &amp;quot;yfe&amp;quot; doesn't move the cursor, but &amp;quot;yFe&amp;quot;&#xA;moves the cursor leftwards to the &amp;quot;e&amp;quot; where the yank started.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;What's happening is that the cursor is being moved to the &lt;em&gt;beginning&lt;/em&gt; (where &lt;em&gt;beginning&lt;/em&gt; means: first character for characterwise text objects and first line for linewise text objects) of the text object.  Enabling visual mode will make it more apparent.  You can think of it as the text is being selected before it is operated on.  Use &lt;code&gt;vby&lt;/code&gt; to see what I mean.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="23502" LastEditDate="2022-08-20T08:40:36.113" LastActivityDate="2022-08-20T08:40:36.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8062" PostTypeId="2" ParentId="8048" CreationDate="2016-06-02T07:39:28.917" Score="7" Body="&lt;pre&gt;&lt;code&gt;:silent argdo %s/foo/\rfoo/ge | update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent! argdo %s/foo/\rfoo/g | update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;silent&lt;/code&gt; skips displaying normal messages&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;!&lt;/code&gt; skips error messages as well&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As per &lt;a href=&quot;http://vimcasts.org/episodes/using-argdo-to-change-multiple-files/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this vimcast&lt;/a&gt;, the &lt;code&gt;e&lt;/code&gt; flag in substitute command can also be removed&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more options and in-built help, refer to &lt;a href=&quot;https://superuser.com/questions/430843/use-argdo-with-search-pattern-to-delete-line-while-suppressing-errors-and-requir&quot;&gt;this Q&amp;amp;A&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1616" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2016-06-02T07:39:28.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8063" PostTypeId="1" AcceptedAnswerId="8065" CreationDate="2016-06-02T09:18:37.473" Score="4" ViewCount="2734" Body="&lt;p&gt;Search highlight is very convenient for me when I'm searching, but after I'm done with doing stuff with search matches it's distracting to me, so I'm using &lt;code&gt;:noh&lt;/code&gt; mapped to &lt;code&gt;F3&lt;/code&gt; everytime I've done what I needed to do with matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to automate this process as it is very annoying to me (this is what vim is about right?).&#xA;Is it possible to turn off highlighting if &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;N&lt;/code&gt; isn't pressed for a couple of seconds?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Guys, don't bother explain to me how YOU use vim (toggle highlight in insert mode etc).&#xA;I know exactly what I want and asked precise question. I know you're trying to be helpful, but you're not, sorry.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6634" LastEditDate="2016-06-02T16:07:33.210" LastActivityDate="2021-12-25T02:26:49.800" Title="How to disable search highlight automatically after searching?" Tags="|search|highlight|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8064" PostTypeId="1" CreationDate="2016-06-02T09:38:07.863" Score="3" ViewCount="1075" Body="&lt;p&gt;When we search for a word, it gets highlighted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to search for another word keeping the previous one highlighted (with a different color probably). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please let me know if it's doable. &lt;/p&gt;&#xA;" OwnerUserId="7849" LastEditorUserId="1821" LastEditDate="2016-06-02T10:31:31.953" LastActivityDate="2016-06-02T10:31:31.953" Title="multiple highlight with multiple color" Tags="|search|highlight|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8065" PostTypeId="2" ParentId="8063" CreationDate="2016-06-02T10:03:31.243" Score="8" Body="&lt;p&gt;I recently wrote &lt;a href=&quot;https://github.com/romainl/vim-cool&quot;&gt;a small plugin&lt;/a&gt; that seems to do exactly what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works by remapping search-related normal mode commands &lt;code&gt;/?nN*#g*g#&lt;/code&gt; and &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in command-line mode, and installing a &lt;code&gt;cursorMoved&lt;/code&gt; autocommand.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-06-02T10:03:31.243" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8066" PostTypeId="1" AcceptedAnswerId="8071" CreationDate="2016-06-02T11:48:19.033" Score="1" ViewCount="461" Body="&lt;pre&gt;&lt;code&gt;set scrollopt+=hor&#xA;set scrollopt-=ver&#xA;set nowrap&#xA;set mouse=a&#xA;2split&#xA;windo set scrollbind&#xA;set statusline=%F%m%r%h%w[%{&amp;amp;ff}]%y%p%%\ %04l\/%04L\ Oc:Hx\ %b:%B%=%qF[%n]%t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Above .vimrc is working quite well for me but I'd like to start already in that second (main split) ready to scroll with mouse etc rather than having to click into it from the first split - which is intended to work as a header...&lt;br&gt;&#xA;Really surprised I have not managed to find this anywhere yet!  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am issuing &lt;code&gt;vim file_to_inspect&lt;/code&gt; to start Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is not possible to be directly in split 2 by .vimrc but the command line can do it that would be second best, then a fix up in my shell would allow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -{some opts} file_to_inspect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(My second day of looking into vim, getting a bit polished in a few places but lots of rooms to explore.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:wincmd k (&amp;amp;j)&#xA;within vim typing the command :wincmd j &amp;amp; then wincmd k DO toggle me between splits in the same way that &amp;lt;C-w&amp;gt; j &amp;amp; k do.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Line placed in .vimrc I arrive in 1st split (the header) either (j or k variant) line at the end of .vimcr made no difference in either case. Here is the file I tried with j as last char (I tried k too).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set scrollopt+=hor&#xA;:set scrollopt-=ver&#xA;:set nowrap&#xA;:set mouse=a&#xA;:2split&#xA;:windo set scrollbind&#xA;:set statusline=%F%m%r%h%w[%{&amp;amp;ff}]%y%p%%\ %04l\/%04L\ Oc:Hx\ %b:%B%=%qF[%n]%t&#xA;:wincmd j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tried &lt;code&gt;autocmd VimEnter * winced j&lt;/code&gt; and that is what I needed.&lt;br&gt;&#xA;@Tumbler41 Thanks! If you'd like to make an answer I can accept it.&lt;br&gt;&#xA;(NO idea why the rather obvious winced did not work - my first noob stab at that yesterday was to try and enter the ctrl-w command somehow directly in .vimrc)&lt;/p&gt;&#xA;" OwnerUserId="7852" LastEditorUserId="7852" LastEditDate="2016-06-02T15:25:43.320" LastActivityDate="2016-06-02T15:30:38.713" Title="How to change the entry split from the .vimrc?" Tags="|vimrc|split|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8068" PostTypeId="2" ParentId="8063" CreationDate="2016-06-02T13:34:05.017" Score="4" Body="&lt;p&gt;I actually like to keep the search highlighting, but find it annoying in insert mode.  This is something I use in my config to toggle it off when editing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Removes the search highlight on insert mode and restores it in normal mode&#xA;function! s:toggle_highlight()&#xA;  if exists('b:last_hlsearch')&#xA;    let &amp;amp;l:hlsearch = b:last_hlsearch&#xA;    unlet b:last_hlsearch&#xA;  elseif &amp;amp;l:hlsearch&#xA;    let b:last_hlsearch = &amp;amp;l:hlsearch&#xA;    setlocal nohlsearch&#xA;  endif&#xA;endfunction&#xA;&#xA;augroup vimrc_search&#xA;  autocmd!&#xA;  autocmd InsertEnter * call s:toggle_highlight()&#xA;  autocmd InsertLeave * call s:toggle_highlight()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also use this key map so I don't have to move my hands from the home row:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;&amp;lt;space&amp;gt; :nohlsearch&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With faster access to &lt;code&gt;:nohlsearch&lt;/code&gt;, I serve as a much better judge for determining when search highlighting is not useful.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-02T13:34:05.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8069" PostTypeId="1" CreationDate="2016-06-02T13:40:05.433" Score="1" ViewCount="560" Body="&lt;p&gt;I'm using neovim. I want to map the &lt;code&gt;0&lt;/code&gt; register to the system clipboard and the unnamed register to the system primary (mouse middle click). Is it possible? I can map the unnamed register to primary with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard=unnamed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how to map the &lt;code&gt;0&lt;/code&gt; register to the clipboard? (Without remapping all yank operations to yank to &lt;code&gt;+&lt;/code&gt; register).&lt;/p&gt;&#xA;" OwnerUserId="5694" LastActivityDate="2016-06-02T13:40:05.433" Title="linux: yank to clipboard, cut to primary" Tags="|cut-copy-paste|neovim|linux|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8070" PostTypeId="1" CreationDate="2016-06-02T14:36:22.020" Score="8" ViewCount="875" Body="&lt;p&gt;I want to have uniform highlighting of line numbers (provided by the &lt;em&gt;LineNr&lt;/em&gt; and &lt;em&gt;CursorLineNr&lt;/em&gt; hl-groups) but the line numbers of folded lines don't obey a particular group (as far as I know), but obey the highlighting of the &lt;em&gt;Folded&lt;/em&gt; group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see in the image of my &lt;em&gt;~/.vimrc&lt;/em&gt; file, the line-numbers of unfolded lines are bold with yellow foreground; while the line-numbers of folded lines are regular with white foreground (the same configuration of the rest of the folded line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/puq9R.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/puq9R.png&quot; alt=&quot;Example of irregular line-number color of folded lines&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how can I make the folded-lines' number become equal of the rest of the LineNr column?&lt;/p&gt;&#xA;" OwnerUserId="7855" LastActivityDate="2016-06-02T14:36:22.020" Title="Highlight line number of folded lines" Tags="|folding|highlight|line-numbers|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8071" PostTypeId="2" ParentId="8066" CreationDate="2016-06-02T15:30:38.713" Score="2" Body="&lt;p&gt;One method is using an autocmd when vim enters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * wincmd j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only reason I can think why this would work better than just putting &lt;code&gt;wincmd j&lt;/code&gt; is perhaps it delays the command by a bit and lets the &lt;code&gt;2split&lt;/code&gt; take full effect maybe?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If @statox could tell us how he got his to work I'd be grateful.)&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-06-02T15:30:38.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8072" PostTypeId="2" ParentId="8063" CreationDate="2016-06-02T16:41:49.950" Score="3" Body="&lt;p&gt;If your vim has the &lt;code&gt;+timers&lt;/code&gt; functionality you can use them like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:current_timer = -1&#xA;&#xA;function! DisableHL(timerId)&#xA;  set nohlsearch&#xA;endfunction&#xA;&#xA;function! ResetTimer()&#xA;  if s:current_timer &amp;gt; -1&#xA;    call timer_stop(s:current_timer)&#xA;  endif&#xA;  let s:current_timer = timer_start(2000, 'DisableHL')&#xA;endfunction&#xA;&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; n n:call ResetTimer()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-02T16:41:49.950" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8073" PostTypeId="1" CreationDate="2016-06-02T17:34:18.623" Score="5" ViewCount="1787" Body="&lt;p&gt;I am used to coding python in Spyder IDE and wanted to change to vim. I started using vim not long ago, but I miss the variable explorer implemented in Spyder. For those not familiar with Spyder, the variable explorer is a tool that displays all the variables from the compiled python file. I find this very useful because I don't need to print all the variables I want and can view the arrays completely. Is there any plugin for vim that has a similar tool?&lt;/p&gt;&#xA;" OwnerUserId="7860" LastActivityDate="2016-06-02T17:34:18.623" Title="Vim Equivalent of Spyder's Variable Explorer" Tags="|vimrc|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8074" PostTypeId="1" CreationDate="2016-06-03T00:10:59.210" Score="0" ViewCount="102" Body="&lt;p&gt;A problem that bothers much my editing work with vim happens when pasting text and the mouse wheel rotates slightly by accident with the result that text is inserted elsewhere in the file under edition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to remove this behavior by including &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;~/.vimrc&lt;/code&gt; but the annoying behavior remains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there perhaps another variable that controls the mouse behavior?&lt;/p&gt;&#xA;" OwnerUserId="7868" LastEditorUserId="205" LastEditDate="2016-06-03T05:51:31.410" LastActivityDate="2018-12-12T17:36:55.230" Title="accidental turn of mouse wheel when pasting text" Tags="|cut-copy-paste|mouse|linux-debian|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8075" PostTypeId="1" AcceptedAnswerId="8077" CreationDate="2016-06-03T11:30:53.690" Score="2" ViewCount="1302" Body="&lt;p&gt;So I want to disable the arrow keys in insert mode. So I added the following lines at the end of &lt;code&gt;~/.vimrc&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;up&amp;gt; &amp;lt;nop&amp;gt;&#xA;inoremap &amp;lt;down&amp;gt; &amp;lt;nop&amp;gt;&#xA;inoremap &amp;lt;left&amp;gt; &amp;lt;nop&amp;gt;&#xA;inoremap &amp;lt;right&amp;gt; &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, every time I open a file the following effect happens: The left and right arrow are disabled in insert mode, like they should. The up and down arrows are still working though. Only after &lt;code&gt;:source ~/.vimrc&lt;/code&gt; the up and down arrows are disabled. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does this happen? Why aren't the up and down keys disabled automatically right after vim starts?&lt;/p&gt;&#xA;" OwnerUserId="7877" LastActivityDate="2016-06-06T05:32:27.943" Title="inoremap only works after source" Tags="|key-bindings|vimrc|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8076" PostTypeId="2" ParentId="7922" CreationDate="2016-06-03T12:17:38.540" Score="5" Body="&lt;p&gt;Visual block &lt;code&gt;I&lt;/code&gt; doesn't work like that. The best you can probably do is something like the following.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Highlight a column in visual block mode (with &lt;code&gt;[b]&lt;/code&gt; denoting a highlighted character as in your question):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaa[b]bb&#xA;aaa[b]bb&#xA;aaa[b]bb&#xA;aaa[b]bb&#xA;cccccc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Perform a substitution on the visual area with &lt;code&gt;\%V&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V/\r/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will insert the &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; for you when you press &lt;code&gt;:&lt;/code&gt;, so you don't need to type that bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaa&#xA;bbb&#xA;aaa&#xA;bbb&#xA;aaa&#xA;bbb&#xA;aaa&#xA;bbb&#xA;cccccc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need to split lines at a visual block often, chances are it'll be readily available in your history, and you may not need to do any more than highlight, then &lt;code&gt;:&amp;lt;up&amp;gt;&amp;lt;return&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-06-03T12:24:21.097" LastActivityDate="2016-06-03T12:24:21.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8077" PostTypeId="2" ParentId="8075" CreationDate="2016-06-03T12:21:30.450" Score="1" Body="&lt;p&gt;Thanks everybody.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the command &lt;code&gt;:verbose :imap &amp;lt;up&amp;gt;&lt;/code&gt; and &lt;code&gt;:verbose :imap &amp;lt;down&amp;gt;&lt;/code&gt; if found out, that both arrows are used by YouCompleteMe. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default keys for selecting a suggestion are tab and up, and for selecting a previous suggestion are s-tab and down. Since I only use tab and s-tab anyways, I was able to set the selection keys to only tab and s-tab with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_key_list_select_completion = ['&amp;lt;TAB&amp;gt;']&#xA;let g:ycm_key_list_previous_completion = ['&amp;lt;S-TAB&amp;gt;']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the disabling of the arrow keys works just fine. &lt;/p&gt;&#xA;" OwnerUserId="7877" LastActivityDate="2016-06-03T12:21:30.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8078" PostTypeId="1" AcceptedAnswerId="8085" CreationDate="2016-06-03T12:43:17.243" Score="3" ViewCount="358" Body="&lt;p&gt;Consider the following &lt;code&gt;'errorformat'&lt;/code&gt; configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set errorformat=%f:%l:\ %m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the following message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%Warning-ASSIGNDLY: test.v:1: Unsupported: Ignoring delay.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While I expected that this message would not match, for some reason, after running &lt;code&gt;:make&lt;/code&gt; Vim is identifying this as a valid error message with the file name &lt;code&gt;%Warning-ASSIGNDLY: test.v&lt;/code&gt;. My &lt;code&gt;'isfname'&lt;/code&gt; is with its default value (&lt;code&gt;@,48-57,/,.,-,_,+,,,#,$,%,~&lt;/code&gt;), so I really don't understand how Vim is able to match a white space in the file name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="599" LastEditDate="2016-06-03T13:53:39.503" LastActivityDate="2016-06-03T17:00:42.967" Title="`'errorformat'` incorrectly matching file name" Tags="|errorformat|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8079" PostTypeId="2" ParentId="8078" CreationDate="2016-06-03T13:44:38.463" Score="2" Body="&lt;p&gt;&lt;em&gt;Disclaimer: I have never used errorformat before.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Deleted pointless stuff that was a mis-understanding of the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One other note. Earlier in the help doc it states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If &quot;%f&quot; is followed by a '%' or a&#xA;  backslash, it will look for a sequence of 'isfname' characters.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since yours doesn't, maybe that's why it can match a space?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @JigglyNaga pointed out in the comments, make sure you use two back backslashes as without it &lt;code&gt;set&lt;/code&gt; will try to escape the next character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is just my (non-expert) take on it. Hope it sparks something for you.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-06-03T16:52:02.653" LastActivityDate="2016-06-03T16:52:02.653" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8080" PostTypeId="1" AcceptedAnswerId="8081" CreationDate="2016-06-03T14:30:41.653" Score="1" ViewCount="226" Body="&lt;p&gt;Let's say I have string like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a = 'iHello&amp;lt;cr&amp;gt;World'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I can use it for a remap:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'nnoremap a '.a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in order to use it with &lt;code&gt;normal!&lt;/code&gt;, I would have to convert &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to a literal newline.&#xA;I know I can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b = escape(a, '&amp;lt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;b&lt;/code&gt; is 'iHello\World'. But how can I parse it to become 'iHello\nWorld' (where \n is a literal linefeed character)&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-06-03T15:01:48.223" Title="Parse literal string as if enclosed by double quotes" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8081" PostTypeId="2" ParentId="8080" CreationDate="2016-06-03T14:45:09.143" Score="4" Body="&lt;p&gt;Instead of &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;, use &lt;code&gt;^M&lt;/code&gt; in your string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a = 'iHello^MWorld'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can insert this with &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;+&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, this is a graphical representation of a newline in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will work in those cases:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;normal &quot;.a&#xA;:execute &quot;normal! &quot;.a&#xA;:execute &quot;nnoremap a &quot;.a     (then press a in normal mode)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if your want to make it work in the following case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;nnoremap a :normal! &quot;.a     (then press a in normal mode)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to use the following (c.f. &lt;a href=&quot;https://stackoverflow.com/a/37617159/2558252&quot;&gt;this answer&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a = 'iHello&amp;lt;C-v&amp;gt;&amp;lt;CR&amp;gt;World&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-06-03T15:01:48.223" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="8082" PostTypeId="1" AcceptedAnswerId="8086" CreationDate="2016-06-03T16:23:48.597" Score="8" ViewCount="1233" Body="&lt;p&gt;I'm writing HTML lists, and I want to be able to automagically paste 10 list items where the item text is the only thing that changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could accomplish this using PHP and then just copying the rendered HTML code but if there's a way to skip that step and do it directly from Vim that would save me so much time.&lt;/p&gt;&#xA;" OwnerUserId="7795" LastEditorUserId="1821" LastEditDate="2016-06-03T17:22:06.900" LastActivityDate="2016-06-03T17:22:06.900" Title="How do I paste the same line of code X times but change one word in the line each time?" Tags="|cut-copy-paste|replace|filetype-html|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8084" PostTypeId="2" ParentId="8082" CreationDate="2016-06-03T16:56:01.940" Score="2" Body="&lt;p&gt;I would probably do this with a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :nmap ^B o&amp;lt;li&amp;gt;&amp;lt;/li&amp;gt;^[4hi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The plan is to insert to tags and then place the insert inbetween them, so that you can type in the text, escape back into normal mode and then do ctrl-b again. (PS, the ^B and ^[ are entered using ctrl_V, but you probably knew that already.) To put in ten rows in single command, you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10ctrl_b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was not clear if you have some automagic way of actually creating the item text? &lt;/p&gt;&#xA;" OwnerUserId="7836" LastEditorUserId="1821" LastEditDate="2016-06-03T17:19:57.323" LastActivityDate="2016-06-03T17:19:57.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8085" PostTypeId="2" ParentId="8078" CreationDate="2016-06-03T17:00:42.967" Score="5" Body="&lt;p&gt;As Tumbler41 &lt;a href=&quot;https://vi.stackexchange.com/a/8079/7600&quot;&gt;notes&lt;/a&gt;, &lt;code&gt;isfname&lt;/code&gt; has to be turned on:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If &quot;%f&quot; is followed by a '%' or a backslash, it will look for a sequence of 'isfname' characters.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I had no luck inserting a % (&lt;code&gt;%:&lt;/code&gt; is an invalid format), but I succeeded with a backslash.  This requires a second backslash to escape the first.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set efm=%f\\:%l:\ %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;set efm&lt;/code&gt; shows the single backslash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;errorformat=%f\:%l: %m &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7600" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-06-03T17:00:42.967" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8086" PostTypeId="2" ParentId="8082" CreationDate="2016-06-03T17:20:19.770" Score="9" Body="&lt;p&gt;For what you want to do, &lt;a href=&quot;https://github.com/mattn/emmet-vim&quot;&gt;emmet-vim&lt;/a&gt;, as nobe4 suggested, is your best bet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In insert mode, &lt;code&gt;li{item $}*10&amp;lt;c-y&amp;gt;,&lt;/code&gt; will expand 10 &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt;s with &lt;code&gt;item N&lt;/code&gt; prefilled as the text.  You'll start editing the contents of the first one.  While still in insert mode, pressing &lt;code&gt;&amp;lt;c-y&amp;gt;n&lt;/code&gt; will move to the next tag for editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your list items are not a sequence repeated text, you can use &lt;a href=&quot;https://github.com/tpope/vim-surround&quot;&gt;vim-surround&lt;/a&gt; to help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example list of text that needs to be wrapped:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc&#xA;def&#xA;ghi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you start with your cursor somewhere in the text, pressing &lt;code&gt;^vip$&amp;lt;c-v&amp;gt;Stli&amp;lt;cr&amp;gt;&lt;/code&gt; will wrap each line with &lt;code&gt;&amp;lt;li&amp;gt;&amp;lt;/li&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^     - move to the first column&#xA;vip   - select the paragraph&#xA;$     - Move to the last column in the selection&#xA;&amp;lt;c-v&amp;gt; - Convert the visual selection into a block. Without the&#xA;        previous $, it would only select 1 column.&#xA;St    - Start vim-surround's tag entry&#xA;li    - The tag name&#xA;&amp;lt;cr&amp;gt;  - Enter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be made into an easy to use key map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;li ^vip$&amp;lt;c-v&amp;gt;Stli&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-03T17:20:19.770" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8087" PostTypeId="1" AcceptedAnswerId="8090" CreationDate="2016-06-03T18:30:26.750" Score="1" ViewCount="463" Body="&lt;p&gt;I can't find info in help about whether it should or shouldn't turn on highlighting, but I find it strange that I have to press &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;N&lt;/code&gt; after &lt;code&gt;*&lt;/code&gt; or &lt;code&gt;#&lt;/code&gt; to turn on search highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I enable this in vim if that's 'normal' behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got only these lines in my vimrc related to search highlighting.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !has('nvim')&#xA;    set smartcase&#xA;    set hlsearch      &quot; highlight search terms&#xA;    set incsearch     &quot; show search matches as you type&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6489" LastEditDate="2016-06-04T11:40:42.847" LastActivityDate="2016-06-04T11:43:32.643" Title="Why doesn't search for word under cursor (* and #) turn on search highlighting and how do I enable it?" Tags="|search|highlight|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8089" PostTypeId="2" ParentId="8029" CreationDate="2016-06-03T23:35:48.193" Score="1" Body="&lt;p&gt;After reading your clarification, I feel that my answer isn't very correct in the context of your question.  I have been in situations where I wished the whitespace wasn't stripped from previously committed files, so I can now appreciate what you are trying to do.  It inspired me to write a plugin: &lt;a href=&quot;https://github.com/tweekmonster/wstrip-changed.vim&quot; rel=&quot;nofollow&quot;&gt;wstrip-changed.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Group a consecutive sequence of lines&#xA;function! s:line_groups(lines) abort&#xA;  if empty(a:lines)&#xA;    return []&#xA;  endif&#xA;&#xA;  let start_line = a:lines[0]&#xA;  let prev_line = a:lines[0]&#xA;  let groups = []&#xA;&#xA;  for l in a:lines&#xA;    if l == prev_line || l - 1 == prev_line&#xA;      let prev_line = l&#xA;    else&#xA;      call add(groups, [start_line, prev_line])&#xA;      let start_line = l&#xA;      let prev_line = l&#xA;    endif&#xA;  endfor&#xA;&#xA;  call add(groups, [start_line, prev_line])&#xA;  return groups&#xA;endfunction&#xA;&#xA;&#xA;function! wstrip_changed#clean() abort&#xA;  let bfile = expand('%')&#xA;  if empty(bfile) || !filereadable(bfile)&#xA;    let lines = range(1, line('$'))&#xA;  else&#xA;    let lines = systemlist(&quot;diff --unchanged-line-format='' --old-line-format='' &quot;&#xA;          \ . &quot;--new-line-format='%dn\n' '&quot;.bfile.&quot;' -&quot;, getline(1, '$') + [''])&#xA;  endif&#xA;&#xA;  if empty(lines)&#xA;    return&#xA;  endif&#xA;&#xA;  let view = winsaveview()&#xA;  for group in s:line_groups(lines)&#xA;    execute join(group, ',').'s/\s\+$//e'&#xA;  endfor&#xA;  call histdel('search', -1)&#xA;  let @/ = histget('search', -1)&#xA;  call winrestview(view)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The most significant part of the script runs a diff of the buffer content against the existing file and only prints the changed line numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let lines = systemlist(&quot;diff --unchanged-line-format='' --old-line-format='' &quot;&#xA;      \ . &quot;--new-line-format='%dn\n' '&quot;.bfile.&quot;' -&quot;, getline(1, '$') + [''])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this, you can easily get the line numbers of the changes without needing complicated change tracking.  This can be combined with a single &lt;code&gt;autocmd&lt;/code&gt; to strip the whitespace on save:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre *.py StripChangedWhitespace&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The script works well enough, but the more rational part of me thinks that removing whitespace from the entire script via &lt;code&gt;%s/\s\+$//e&lt;/code&gt; is still preferable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't own the code, perhaps you can get permission to do a full sweep with &lt;code&gt;sed&lt;/code&gt; to strip trailing whitespace from project scripts and make it a single cleanup commit.  Then you and your peers won't have to worry about it any more.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-03T23:35:48.193" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8090" PostTypeId="2" ParentId="8087" CreationDate="2016-06-04T11:43:32.643" Score="4" Body="&lt;p&gt;You can hook up the &lt;code&gt;hlsearch&lt;/code&gt; command like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap * :set hlsearch&amp;lt;CR&amp;gt;*&#xA;nnoremap # :set hlsearch&amp;lt;CR&amp;gt;#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if you want to highlight the current word without moving the cursor you can add the &lt;code&gt;N&lt;/code&gt; movement afterwards:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap * :set hlsearch&amp;lt;CR&amp;gt;*N&#xA;nnoremap # :set hlsearch&amp;lt;CR&amp;gt;#N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-04T11:43:32.643" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8091" PostTypeId="1" CreationDate="2016-06-04T14:23:20.610" Score="7" ViewCount="493" Body="&lt;p&gt;I have the following definitions in a .tex file preamble:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\newcommand{\beq}{\begin{eqnarray}}&#xA;\newcommand{\eeq}{\end{eqnarray}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I then use &lt;code&gt;\beq&lt;/code&gt; and &lt;code&gt;\eeq&lt;/code&gt; to define an equation array region, spell checking is turned on in this region, where it would not be if I had used &lt;code&gt;\begin{eqnarray}&lt;/code&gt; and &lt;code&gt;\end{eqnarray}&lt;/code&gt;. I tried to turn off spell-checking in these custom regions using the method presented &lt;a href=&quot;https://tex.stackexchange.com/a/9520&quot;&gt;here&lt;/a&gt;, i.e. copy the &lt;code&gt;$VIMRUNTIME/syntax/tex.vim&lt;/code&gt; file to &lt;code&gt;~/.vim/syntax&lt;/code&gt; and edit the file. I added a line like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region texZone start=&quot;\\beq&quot; end=&quot;\\eeq\|%stopzone\&amp;gt;&quot; contains=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to the file, but it didn't work, and spellchecking is not disabled between &lt;code&gt;\beq&lt;/code&gt; and &lt;code&gt;\eeq&lt;/code&gt; tags. I am very unfamiliar with Vim syntax files, so I don't know how to debug this or take further steps. Any thoughts on how to turn off spell check just in my custom region would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5043" LastEditorUserId="-1" LastEditDate="2017-04-13T12:34:32.317" LastActivityDate="2016-07-04T14:51:51.653" Title="Turn off Vim spellcheck in custom region" Tags="|filetype-tex|spell-checking|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8092" PostTypeId="2" ParentId="8091" CreationDate="2016-06-04T14:44:29.413" Score="4" Body="&lt;p&gt;By placing that line by itself in &lt;code&gt;~/.vim/after/syntax/tex.vim&lt;/code&gt; instead of adding it to a copy of &lt;code&gt;$VIMRUNTIME/syntax/tex.vim&lt;/code&gt; in &lt;code&gt;~/.vim/syntax/tex.vim&lt;/code&gt;, the spell checking behavior was disabled between &lt;code&gt;\beq&lt;/code&gt; and &lt;code&gt;\eeq&lt;/code&gt; tags as I wanted. Unfortunately, this line doesn't tell Vim it's a math region, so math syntax highlighting is different between these tags than it is between &lt;code&gt;\begin{eqnarray}&lt;/code&gt; and &lt;code&gt;\end{eqnarray}&lt;/code&gt; tags.&lt;/p&gt;&#xA;" OwnerUserId="5043" LastActivityDate="2016-06-04T14:44:29.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8093" PostTypeId="1" AcceptedAnswerId="9511" CreationDate="2016-06-04T15:21:58.767" Score="2" ViewCount="670" Body="&lt;p&gt;I have a remap that calls a function with a key combination as an argument. In this function I want to execute another remap to yet another function.&#xA;But whatever I do, it complains about a missing closing quote at the &lt;code&gt;iHello...&lt;/code&gt; part. This seems to be happening inside &lt;code&gt;s:Test()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also happens when I replace the literal carriage return (&lt;code&gt;^M&lt;/code&gt;) with &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;, or when I remove the &lt;code&gt;string()&lt;/code&gt; function from the &lt;code&gt;s:Test()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Test(obj)&#xA;    execute 'inoremap &amp;lt;silent&amp;gt; &amp;lt;tab&amp;gt; &amp;lt;esc&amp;gt;:&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;Test2('.string(a:obj).')&amp;lt;cr&amp;gt;'&#xA;endfunction&#xA;&#xA;function! s:Test2(obj)&#xA;    &quot; do something&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;localleader&amp;gt;a :call &amp;lt;sid&amp;gt;Test({'cmd':'Hello^MWorld'})&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-09-10T20:09:58.393" Title="Carriage return as argument breaks the function" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8094" PostTypeId="1" CreationDate="2016-06-04T16:32:18.417" Score="2" ViewCount="1134" Body="&lt;p&gt;How can I match a pattern like&#xA;&lt;code&gt;\\gr{\_.*:}&lt;/code&gt;&#xA;but so that the brackets have to match?&#xA;That is, &#xA;&lt;code&gt;\gr{this should match:}&lt;/code&gt;,&#xA;&lt;code&gt;\gr{this should {not:} match}&lt;/code&gt;&#xA;&lt;code&gt;\gr{nor} should {this:}&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2016-06-05T00:38:51.773" LastActivityDate="2016-06-05T12:45:12.360" Title="Matching matching brackets" Tags="|regular-expression|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8096" PostTypeId="2" ParentId="8094" CreationDate="2016-06-05T06:27:04.437" Score="1" Body="&lt;p&gt;Based on what you said shouldn't match (&lt;code&gt;:}&lt;/code&gt; is the significant delimiter), it should be as simple as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\\gr{\_[^{]\{-}:}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if something like &lt;code&gt;\gr{}:}&lt;/code&gt; is valid since the first &lt;code&gt;}&lt;/code&gt; isn't preceded by a colon:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\\gr{\%(\%({\_[^}]\{-}}\)\@!\_.\)\{-}:}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\%(\%({\_[^}]*}\)\@!\_.\)&lt;/code&gt; is a negative match for anything wrapped in braces.  Even if the braces were nested, it should be enough to stop matching once encountered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This pattern can be used if the braces can be escaped with a backslash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\\gr{\%(\%(\\\@&amp;lt;!{\_[^}]\{-}\\\@&amp;lt;!}\)\@!\_.\)\{-}:}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would be able to match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\gr{this \{should} match:} \gr{this \{should\} match:}&#xA;\gr{this {should\} match:} \gr{this {should:} not match:}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, this one poses a problem because it can bleed into the next line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\gr{both lines are}&#xA;\gr{a \{single\} match:}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because of &lt;code&gt;\\\@&amp;lt;!}&lt;/code&gt; in the pattern, though I'm not sure why.  If there isn't a need for these to span multiple lines, this pattern should be able to ignore escaped braces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\\gr{\%(\%(\\\@&amp;lt;!{[^}]\{-}\\\@&amp;lt;!}\)\@!.\)\{-}:}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should be noted that these patterns uses the non-greedy &lt;code&gt;\{-}&lt;/code&gt; repetition.  If &lt;code&gt;*&lt;/code&gt; is used, the match would span consecutive lines which is something you wouldn't want if you wish to operate on each &lt;code&gt;\gr{...:}&lt;/code&gt; group individually.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-06-05T12:45:12.360" LastActivityDate="2016-06-05T12:45:12.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8097" PostTypeId="1" CreationDate="2016-06-05T14:23:38.663" Score="0" ViewCount="1456" Body="&lt;p&gt;I am trying to use &lt;code&gt;unicode&lt;/code&gt; characters in vim. Since &lt;code&gt;msdos&lt;/code&gt; prompt didnt support unicode, I downloaded &lt;code&gt;cygwin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added some commands in &lt;code&gt;.vimrc&lt;/code&gt; through cygwin.&#xA;Basic commands like setting &lt;code&gt;encoding&lt;/code&gt;, &lt;code&gt;fileencoding&lt;/code&gt; to utf8. Since cygwin also doesn't support diacritits or multiple characters. So, to add Tamil character keymappings and abbreviations, I opened notepad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I opened the same file through &lt;code&gt;notepad&lt;/code&gt;, I got multiple sentences in single line. The new line characters were hidden. when i move to the end of line, that cursor has to be moved twice. So, I manually entered a new line by pressing &lt;code&gt;Enter&lt;/code&gt; everytime and saved it.&#xA;I thought that the fileformat might be wrong and gave &lt;code&gt;:set fileformat+=msdos,unix&lt;/code&gt; in vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I opened cygwin and inside it, opened a file through vim. I am getting an error like&#xA;&lt;code&gt;E492: Not an editor command : ^M&lt;/code&gt; for every line in the vimrc file.&#xA;I understand that the newline character is causing trouble, but dont know how to solve it. Please help.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastActivityDate="2016-06-10T17:43:54.410" Title="Getting Error while opening files through vim" Tags="|vimrc|line-breaks|unicode|encoding|cygwin|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8098" PostTypeId="2" ParentId="8097" CreationDate="2016-06-05T14:32:31.820" Score="1" Body="&lt;p&gt;Though Cygwin is installed in Windows, it resembles linux.&#xA;So, setting the &lt;code&gt;fileformat&lt;/code&gt; to unix solves the problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set fileformat=unix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, the unicode characters are accepted by Cygwin.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="1821" LastEditDate="2016-06-10T17:43:54.410" LastActivityDate="2016-06-10T17:43:54.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8099" PostTypeId="2" ParentId="8075" CreationDate="2016-06-05T19:29:23.290" Score="3" Body="&lt;p&gt;Fileypte plugins, etc., can silently overwrite mappings&#xA;you've defined in your vimrc. &lt;code&gt;:map &amp;lt;unique&amp;gt;&lt;/code&gt; exists to&#xA;prevent this, but not all plugins bother.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the general case you can prevent your mappings being&#xA;overwritten by defining mappings in an autocommand, such&#xA;that your mappings are set after those defined by a plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! FinalMappings()&#xA;    inoremap &amp;lt;buffer&amp;gt; &amp;lt;up&amp;gt; &amp;lt;nop&amp;gt;&#xA;    inoremap &amp;lt;buffer&amp;gt; &amp;lt;down&amp;gt; &amp;lt;nop&amp;gt;&#xA;    inoremap &amp;lt;buffer&amp;gt; &amp;lt;left&amp;gt; &amp;lt;nop&amp;gt;&#xA;    inoremap &amp;lt;buffer&amp;gt; &amp;lt;right&amp;gt; &amp;lt;nop&amp;gt;&#xA;endfun&#xA;&#xA;augroup FinalMappings&#xA;    au!&#xA;    au VimEnter,BufNewFile,BufReadPost,FileReadPost,BufFilePost,&#xA;            \BufEnter,BufWinEnter,BufNew,FileType,WinEnter,&#xA;            \WinLeave * call FinalMappings()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's probably overkill with the autocommand events. Note&#xA;that this needs to go after the line in your vimrc that sets&#xA;up the autocommands for filetype detection, e.g. &lt;code&gt;filetype&#xA;plugin indent on&lt;/code&gt;, since autocommands are executed in the&#xA;order in which they are registered. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This isn't foolproof, but should work 99% of the time.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-06-06T05:32:27.943" LastActivityDate="2016-06-06T05:32:27.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8100" PostTypeId="1" AcceptedAnswerId="8104" CreationDate="2016-06-05T20:57:37.760" Score="4" ViewCount="1900" Body="&lt;p&gt;I am new to vim and currently learning as well.&#xA;I just started using syntastic in vim to lint my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have set following vars in my &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If any error comes error window gets open, and show the list of errors.&#xA;I just want to know is there any way to switch betweeb opened error window and current window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also is there any keystroke which I can use to move to next and prev error? (not by using &lt;code&gt;:lnext&lt;/code&gt; and &lt;code&gt;:lprev&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YfWew.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YfWew.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="5890" LastEditorUserId="1841" LastEditDate="2016-06-06T08:07:12.213" LastActivityDate="2016-06-06T08:07:12.213" Title="How to switch between syntastic error window and editor window" Tags="|vim-windows|plugin-syntastic|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8101" PostTypeId="1" CreationDate="2016-06-05T22:40:23.420" Score="1" ViewCount="309" Body="&lt;p&gt;I have the following in my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-J&amp;gt; o&amp;lt;Esc&amp;gt;k$&#xA;nnoremap &amp;lt;C-K&amp;gt; O&amp;lt;Esc&amp;gt;j$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The bottom mapping works as expected, but &lt;code&gt;c-j&lt;/code&gt; now produces the same effect as &lt;code&gt;i&lt;/code&gt; (which is really dumb). To troubleshoot, I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;verbose map c-j &#xA;&quot; UPDATE: the above is wrong. Instead use:&#xA;verbose map &amp;lt;c-j&amp;gt; &#xA;verbose map &amp;lt;buffer&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The top command returns &lt;strike&gt;nothing&lt;/strike&gt; (see last update), and the bottom nothing relevant. How can I find out what's wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update.&lt;/strong&gt; Someone said this is a duplicate of &lt;a href=&quot;https://vi.stackexchange.com/questions/3225/disable-esc-but-keep-c&quot;&gt;this post&lt;/a&gt;, but I don't understand how. For what it's worth, I got the idea for the mapping from the &lt;a href=&quot;http://vim.wikia.com/wiki/Insert_newline_without_entering_insert_mode&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim wiki&lt;/a&gt;, so it must've worked for some people. In fact, it was working for me, too, before it stopped. Also, according to the help, &lt;code&gt;c-j&lt;/code&gt; is supposed to be the same as &lt;code&gt;c-n&lt;/code&gt; and &lt;code&gt;&amp;lt;nl&amp;gt;&lt;/code&gt;, but that's not the case here as I said earlier. It behaves like &lt;code&gt;i&lt;/code&gt;, and I would like to know how to figure out why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update II.&lt;/strong&gt; The mapping now works fortuitously after the following change. If there's a decent explanation, I'll accept it as answer. Otherwise, I'm happy enough to get this to work. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; old&#xA;&quot; nnoremap &amp;lt;CR&amp;gt; :noh&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&quot; new&#xA;nnoremap &amp;lt;CR&amp;gt; :noh&amp;lt;return&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update III.&lt;/strong&gt; It's not working again, but I now realize that my &lt;code&gt;verbose map&lt;/code&gt; syntax above is incorrect. The correct syntax gives me something to work with. Thanks all. &lt;/p&gt;&#xA;" OwnerUserId="7810" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-06-07T00:04:06.017" Title="Troubleshooting mapping" Tags="|key-bindings|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8102" PostTypeId="2" ParentId="5462" CreationDate="2016-06-06T03:52:50.827" Score="5" Body="&lt;p&gt;More directly to the question than my other answer, you could define a mapping to like this (&lt;code&gt;nnoremap&lt;/code&gt; for no selection, just execute the current line; &lt;code&gt;vnoremap&lt;/code&gt; for when visual mode is active):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; :execute getline(&quot;.&quot;)&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;F2&amp;gt; :&amp;lt;C-u&amp;gt;for line in getline(&quot;'&amp;lt;&quot;, &quot;'&amp;gt;&quot;) \| execute line \| endfor&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In both cases, the &quot;current line&quot; is &lt;code&gt;:execute&lt;/code&gt;d, so in the visual version you're &lt;code&gt;:execute&lt;/code&gt;ing one line after another through the visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As stated in another answer, the &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; deletes the range specification that pops up in the command line when &lt;kbd&gt;:&lt;/kbd&gt; is typed. The &lt;code&gt;|&lt;/code&gt; characters need to be escaped because otherwise they're interpreted as the end of the &lt;code&gt;vnoremap&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This could also be turned into a function to get rid of some of the escape gymnastics but it doesn't seem like a huge win to me at this time. It would basically be the vnoremap expanded into multiple lines and &lt;code&gt;call&lt;/code&gt;ed with a range or not depending on the [nv] mapping mode.&lt;/p&gt;&#xA;" OwnerUserId="6430" LastEditorUserId="6430" LastEditDate="2016-06-06T04:17:02.353" LastActivityDate="2016-06-06T04:17:02.353" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8103" PostTypeId="2" ParentId="8026" CreationDate="2016-06-06T06:53:11.127" Score="1" Body="&lt;p&gt;If you really want an abbreviation rather than a mapping, a compromise would be an end-id abbreviation (see &lt;code&gt;:h abbreviations&lt;/code&gt;). These end in a keyword character, but the other characters in the abbreviation must be non-keyword characters. These will expand directly after a keyword character. So you could do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:iabbrev ..s \ldots&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, typing &lt;code&gt;'whatever..s '&lt;/code&gt; will be expanded to &lt;code&gt;'whatever\ldots '&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One benefit of this is that &lt;code&gt;...&lt;/code&gt; won't be expanded when you don't want it to be.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-06-06T07:50:42.197" LastActivityDate="2016-06-06T07:50:42.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8104" PostTypeId="2" ParentId="8100" CreationDate="2016-06-06T08:03:57.323" Score="7" Body="&lt;p&gt;To switch between two windows see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#window-move-cursor&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h window-move-cursor&lt;/code&gt;&lt;/a&gt;. Here you'll use &lt;kbd&gt;Ctrl-w&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; and &lt;kbd&gt;Ctrl-w&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;, since the windows are horizontally split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to use &lt;code&gt;:lnext&lt;/code&gt; and &lt;code&gt;:lprev&lt;/code&gt; more easily you could use a mapping as suggested by @muru. To do so add something like that to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-n&amp;gt; :lnext&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line will make &lt;kbd&gt;Ctrl-n&lt;/kbd&gt; execute &lt;code&gt;:lnext&lt;/code&gt; in normal mode. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#mapping&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h mapping&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course change the mapped keys (here &lt;code&gt;&amp;lt;c-n&amp;gt;&lt;/code&gt;) to whatever fits your needs.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="2313" LastEditDate="2016-06-06T08:05:56.603" LastActivityDate="2016-06-06T08:05:56.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8105" PostTypeId="1" AcceptedAnswerId="8106" CreationDate="2016-06-06T11:44:26.143" Score="5" ViewCount="470" Body="&lt;p&gt;I want to align my statements around a particular word or token.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import React          from 'react';&#xA;import { browserHistory, Router, Route } from 'react-router';&#xA;import Main           from './components/main';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, I want my statements to be aligned around &lt;code&gt;from&lt;/code&gt; word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import React                             from 'react';&#xA;import { browserHistory, Router, Route } from 'react-router';&#xA;import Main                              from './components/main';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have installed a plugin called &lt;code&gt;tabular&lt;/code&gt; but I don't know how to align around a word. I can align around &lt;code&gt;=&lt;/code&gt; or any other token but not around a word.&lt;/p&gt;&#xA;" OwnerUserId="5890" LastEditorUserId="205" LastEditDate="2016-06-06T16:16:13.547" LastActivityDate="2016-06-06T20:15:11.323" Title="How to align statements around a particular word or token?" Tags="|alignment|plugin-tabular|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8106" PostTypeId="2" ParentId="8105" CreationDate="2016-06-06T12:01:30.583" Score="8" Body="&lt;p&gt;The Tabular plugin works with regular expressions. So, you can give a word or a pattern, not just a single character.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Tabularize /from/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will align in the way you wanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find a great tutorial about &lt;a href=&quot;http://vimcasts.org/episodes/aligning-text-with-tabular-vim/&quot; rel=&quot;nofollow&quot;&gt;Tabular on Vimcasts&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-06-06T20:15:11.323" LastActivityDate="2016-06-06T20:15:11.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8107" PostTypeId="1" AcceptedAnswerId="8108" CreationDate="2016-06-06T15:57:05.750" Score="12" ViewCount="6177" Body="&lt;p&gt;I am currently editing one file and, after finishing its edit, I want &#xA;to close the current file and at the same time (i.e., without closing Vim) open another file for editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How it can be achieved?&lt;/p&gt;&#xA;" OwnerUserId="5890" LastEditorUserId="1821" LastEditDate="2016-06-06T16:05:52.147" LastActivityDate="2016-06-06T16:14:42.207" Title="How to quit one file and simultaneously open another file in vim?" Tags="|multiple-files|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8108" PostTypeId="2" ParentId="8107" CreationDate="2016-06-06T16:14:42.207" Score="13" Body="&lt;p&gt;I don't think this can be done using a single command. You'll have to use a combination of commands:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/8107/how-to-quit-one-file-and-simultaneously-open-another-file-in-vim#comment13550_8107&quot;&gt;statox suggested&lt;/a&gt;, delete &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Abd&quot; rel=&quot;noreferrer&quot;&gt;the current buffer&lt;/a&gt; and open a new one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bd | e filename&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Afile_f&quot; rel=&quot;noreferrer&quot;&gt;rename the current file&lt;/a&gt; and edit it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:file filename | e&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;:w | bd | e filename&lt;/code&gt; or &lt;code&gt;:w | file filename | e&lt;/code&gt; to save the current file and start on a new one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can, of course, use maps or custom commands to simplify this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command -nargs=+ WE w | bd | e &amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:WE new-filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-06-06T16:14:42.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8109" PostTypeId="1" CreationDate="2016-06-06T16:47:57.497" Score="4" ViewCount="150" Body="&lt;p&gt;If I have syntax highlighting rules setup using &lt;code&gt;conceal&lt;/code&gt; to hide or change certain characters in a file, how do I search what is displayed, as opposed to what the buffer actually contains?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The concealed part may contain formatting markup, for example, which I wish to ignore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like a method that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;doesn't rely on the specific rules used to create the concealed text.&lt;/li&gt;&#xA;&lt;li&gt;provides some level of compatibility with the traditional search operators like &lt;code&gt;n&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Can this be done without re-implementing &lt;code&gt;n&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt; and the like?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/5524/205&quot;&gt;How can I copy the displayed text, instead of the actual text?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-06-06T17:28:17.383" Title="How do I search only the displayed part of concealed text?" Tags="|search|conceal|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8110" PostTypeId="2" ParentId="8109" CreationDate="2016-06-06T17:28:17.383" Score="3" Body="&lt;p&gt;This is not really possible, as concealing was meant as a sole method for displaying chars instead of the actual content. In the same sense, you can't really search for what has been folded or signs. The only method I know is using &lt;code&gt;screenchar()&lt;/code&gt; function as shown in my other answer, but that is not really ready to use.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-06-06T17:28:17.383" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8111" PostTypeId="1" CreationDate="2016-06-06T21:58:46.113" Score="4" ViewCount="243" Body="&lt;p&gt;I want to insert the unicode character Thorn &lt;code&gt;Þ&lt;/code&gt; into my document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.fileformat.info/info/unicode/char/00de/index.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.fileformat.info/info/unicode/char/00de/index.htm&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The character seems to be inserted when I type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i&amp;lt;C-v&amp;gt;u00DE&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But is displayed as the replacement character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;�&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.fileformat.info/info/unicode/char/fffd/index.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.fileformat.info/info/unicode/char/fffd/index.htm&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume this is because there is no glyph that vim can map to the unicode character. I am not sure how to proceed to update vim to get that character displayed correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: This is different from the question marked as duplicate in that I already insert the correct unicode character. The problem is that it is not displayed correctly.&lt;/p&gt;&#xA;" OwnerUserId="383" LastEditorUserId="383" LastEditDate="2016-06-07T20:53:04.263" LastActivityDate="2016-06-07T20:53:04.263" Title="Latin Capital Letter Thorn" Tags="|unicode|font|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8112" PostTypeId="1" CreationDate="2016-06-07T06:26:43.893" Score="3" ViewCount="754" Body="&lt;p&gt;I would like to know if it was possible to change the color used to display function name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's take the following example (using Python):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def function1(arg):&#xA;    function2(arg)&#xA;    # ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;function1&lt;/code&gt; has a custom color, while &lt;code&gt;function2&lt;/code&gt; keeps the default text-color. I would like to change its color to something else (or, by the one used to highlight &lt;code&gt;function1&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to change the color function names when they're called? I wasn't able to find any lead on that…&lt;/p&gt;&#xA;" OwnerUserId="7906" LastEditorUserId="1841" LastEditDate="2016-06-07T07:31:39.363" LastActivityDate="2016-06-07T07:31:39.363" Title="How to change the color used to highlight function calls?" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8113" PostTypeId="1" AcceptedAnswerId="8217" CreationDate="2016-06-07T06:55:50.827" Score="9" ViewCount="340" Body="&lt;p&gt;I frequently use &lt;a href=&quot;https://codegolf.stackexchange.com/&quot;&gt;Programming Puzzles and Code-golf&lt;/a&gt;. Lots of users over there have written custom languages purely for golfing. I'm even working on my own right now. Lots of these languages have their own custom encodings so that they can squish more commands into a single byte. For example, &lt;a href=&quot;https://github.com/Mego/Seriously/blob/master/docs/commands.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;seriously&lt;/a&gt;, &lt;a href=&quot;https://github.com/DennisMitchell/jelly/wiki/Code-page&quot; rel=&quot;nofollow noreferrer&quot;&gt;jelly&lt;/a&gt; and &lt;a href=&quot;https://github.com/Adriandmen/05AB1E/blob/master/List-commands.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;05AB1E&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I configure vim to use my own custom encoding? I'd like to configure a mapping of bytes to unicode code-points. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x01 == &quot;¢&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, when I type &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;C-a&amp;gt;&lt;/code&gt;, it would display a &lt;code&gt;¢&lt;/code&gt; character, and when I write, it would save the byte &lt;code&gt;0x01&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this even remotely possible? And also, would this work well with the system clipboard? (e.g., I can copy and paste from my browser to vim and vice-versa)&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:39:29.623" LastActivityDate="2016-06-13T16:21:32.797" Title="Can I define a custom encoding for vim?" Tags="|encoding|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8114" PostTypeId="1" AcceptedAnswerId="8115" CreationDate="2016-06-07T09:26:34.840" Score="15" ViewCount="520" Body="&lt;p&gt;I have a line like this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function my_function(argument, another argument, but there are spaces)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to substitute the space characters (inside the argument's names) with underscore. I thus would like to use :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\ /_/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but how can I choose not to apply it to the whole line, but starting from, say, the cursor position ? (Or the third word) ?&lt;/p&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="51" LastEditDate="2016-11-23T11:14:50.583" LastActivityDate="2016-11-23T11:14:50.583" Title="How can I run :substitute on only part of the line and not all of it?" Tags="|regular-expression|substitute|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8115" PostTypeId="2" ParentId="8114" CreationDate="2016-06-07T09:35:08.840" Score="15" Body="&lt;p&gt;You could use the following solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First use &lt;kbd&gt;v$&lt;/kbd&gt; to select the text from the cursor to the end of the line. Then use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\%V\ /_/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\%V&lt;/code&gt; indicate to change the text in the previously visually selected area, see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5C%V&quot;&gt;&lt;code&gt;:h /\%V&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I take your example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function my_function(argument, another argument, but there are spaces)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If my cursor is on the 40th column and I use the command I just wrote I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function my_function(argument, another argument,_but_there_are_spaces)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In answer to your comment you can also use &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\%#&lt;/code&gt; which matches from the cursor position&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%&amp;gt;23c&lt;/code&gt; which matches after the 23rd column.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%&amp;gt;'m&lt;/code&gt; which matches after the position of a mark&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5C%#&quot;&gt;&lt;code&gt;:h /\%#&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5C%&amp;gt;c&quot;&gt;&lt;code&gt;:h /\%&amp;gt;c&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5C%&amp;gt;%27m&quot;&gt;&lt;code&gt;:h /\%&amp;gt;'m&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@User9433424 gave a way to use &lt;code&gt;\%#&lt;/code&gt; in his comment. For the pattern with the mark you can set it wit &lt;kbd&gt;ma&lt;/kbd&gt; and then use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\%&amp;gt;'a /_/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;An explanation of the pattern given by @User9433424 is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v(%#.*)@&amp;lt;= /_/&#xA;:s/                    substitution command&#xA;   \v                  Enable the very magic mode&#xA;      %#.*             Any characters from the cursor position&#xA;           @&amp;lt;=         Check for matches just before what follows&#xA;              space    Followed by a space&#xA;               /_/     Substitute the matches by underscores&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll want to see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#%5Cv&quot;&gt;&lt;code&gt;:h \v&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5C@&amp;lt;=&quot;&gt;&lt;code&gt;:h /\@&amp;lt;=&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-06-07T10:03:02.537" LastActivityDate="2016-06-07T10:03:02.537" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8116" PostTypeId="1" AcceptedAnswerId="8349" CreationDate="2016-06-07T10:06:03.877" Score="4" ViewCount="4601" Body="&lt;p&gt;As far as my setup is concerned, I'm running Tmux 2.2 (with true color support enabled) inside iTerm2 version 3 on a Mac. To clarify, there are &lt;a href=&quot;https://vi.stackexchange.com/questions/7112/tmux-messing-with-vim-highlighting&quot;&gt;other&lt;/a&gt; &lt;a href=&quot;https://vi.stackexchange.com/questions/238/tmux-is-changing-part-of-the-background-in-vim&quot;&gt;questions&lt;/a&gt; already answered which address essentially the same problem I am experiencing, but none of the offered solutions (&lt;code&gt;ttyfast&lt;/code&gt; or &lt;code&gt;set t_ut=&lt;/code&gt;) fix the issue for me unless I turn &lt;code&gt;termguicolors&lt;/code&gt; off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I see when I run Vim in iTerm2 directly. Everything looks as I expect:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/itOEx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/itOEx.png&quot; alt=&quot;Vim in iTerm2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I end up with strange background issues when I run inside Tmux:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oGbpl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oGbpl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the colors are pretty close, so it might be hard to see, but it's actually very jarring when I'm running full screen with split panes and lots of text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To my eye it looks like the text background color is rendering correctly, and the background color for &lt;em&gt;blank lines&lt;/em&gt; renders correctly, but for some reason the background color past the end of the text renders incorrectly. This is probably consistent with other similar questions I've seen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a picture showing what I mean. Blank lines also render the background color correctly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/19q5E.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/19q5E.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a final data point, I ran &lt;code&gt;set termcap&lt;/code&gt; to dump the terminal settings and verified that everything matches between when I run Vim in iTerm vs when I run in Tmux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some additional details brought out from the comments below:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The theme always works in Neovim (v0.1.4), whether I run in Tmux or in iTerm directly. This leads me to believe it is not an issue with the theme, or with Tmux.&lt;/li&gt;&#xA;&lt;li&gt;The terminal in Tmux is set to &lt;code&gt;screen-256-color&lt;/code&gt;. Because of limitations in the way Vim handles &lt;code&gt;termguicolors&lt;/code&gt;, this means I end up having to manually set &lt;code&gt;t_8f&lt;/code&gt; and &lt;code&gt;t_8b&lt;/code&gt; values.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If anyone has any suggestions on what I can try to fix this issue, I'm all ears.&lt;/p&gt;&#xA;" OwnerUserId="7165" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2016-06-21T00:28:10.557" Title="Truecolor (termguicolors) causes display issues in Tmux" Tags="|tmux|iterm2|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8117" PostTypeId="1" CreationDate="2016-06-07T12:34:37.693" Score="7" ViewCount="275" Body="&lt;p&gt;I was messing with the expression register (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#@=&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h @=&lt;/code&gt;&lt;/a&gt;) and noticed that it is not possible to put text directly in it. The doc says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The expression register is read-only; you cannot put text into it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Let's say my buffer contains an operation like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1+2+3+4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I want to get the result in the expression register, I have to do the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;yf4&lt;/kbd&gt;: Put the expression into the unnamed register&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;&quot;=&lt;/kbd&gt;: Start editing the expression register&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-r&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;enter&lt;/kbd&gt;: Put the content of the unnamed register into the expression register&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If the expression register weren't read only I could have done it more easily:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;&quot;=yf4&lt;/kbd&gt; Select the expression register and put the line into it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So my question is not about how I could change this behavior but &lt;strong&gt;what can explain this implementation?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it because yanking directly into the expression register would be &quot;against the Vim way&quot;? Is it because of a technical limitation? Is there another reason?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the comments, the states of the expression register has changed recently:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;:version&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ovi7P.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ovi7P.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;:h @=&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dCBzw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dCBzw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But @romainl and @lcd047 told me that the doc says the register is read-write. So I looked up &lt;a href=&quot;ftp://ftp.vim.org/pub/vim/patches/7.4/README&quot; rel=&quot;nofollow noreferrer&quot;&gt;the list of the patches&lt;/a&gt; but didn't find one about this change... I have to admit that I'm pretty confused by the situation now.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-06-09T08:20:06.983" LastActivityDate="2016-06-09T08:20:06.983" Title="Why is the expression register &quot;read only&quot;?" Tags="|history-of|expression-register|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="8118" PostTypeId="5" CreationDate="2016-06-07T12:37:53.457" Score="0" Body="&lt;p&gt;The expression register allows us to perform Back-of-the-Envelope calculations and then insert the result directly into our document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#@=&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h @=&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-06-07T12:37:53.457" LastActivityDate="2016-06-07T12:37:53.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8119" PostTypeId="4" CreationDate="2016-06-07T12:37:53.457" Score="0" Body="Questions about the usage of expression register &quot;=" OwnerUserId="1841" LastEditorUserId="51" LastEditDate="2017-01-02T02:24:37.043" LastActivityDate="2017-01-02T02:24:37.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8120" PostTypeId="2" ParentId="8117" CreationDate="2016-06-07T13:08:40.297" Score="1" Body="&lt;p&gt;The expression register expects an &lt;em&gt;expression&lt;/em&gt;. &lt;code&gt;yf4&lt;/code&gt; is not an expression so there's no reason to expect the expression register to make any sense of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use what you just yanked &lt;em&gt;as an expression&lt;/em&gt;, use &lt;code&gt;@&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-06-07T13:29:49.003" LastActivityDate="2016-06-07T13:29:49.003" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8122" PostTypeId="1" AcceptedAnswerId="8123" CreationDate="2016-06-07T14:03:02.483" Score="9" ViewCount="3609" Body="&lt;p&gt;I have some files in my vim buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:ls&lt;/code&gt; shows the list of active buffer,&#xA;I want to open a file from buffer into a vertically/horizontally split window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know &lt;code&gt;:vsp&lt;/code&gt; or &lt;code&gt;:sp&lt;/code&gt; open split window in vim but how to open a split window from files in buffer?&lt;/p&gt;&#xA;" OwnerUserId="5890" LastEditorUserId="1841" LastEditDate="2016-06-07T14:47:58.370" LastActivityDate="2016-06-07T15:01:29.273" Title="How to open a file from active buffer into a split window?" Tags="|vim-windows|split|multiple-files|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8123" PostTypeId="2" ParentId="8122" CreationDate="2016-06-07T14:12:08.347" Score="6" Body="&lt;p&gt;You can give &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vsplit | buffer buffernumber/buffername&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to open a buffer in vertical split mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:split | buffer 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Same applies to horizontal split mode too. You can use &lt;code&gt;:sp&lt;/code&gt; as a shortcut for &lt;code&gt;:split&lt;/code&gt; and &lt;code&gt;:vs&lt;/code&gt; for &lt;code&gt;:vsplit&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-06-07T15:01:19.443" LastActivityDate="2016-06-07T15:01:19.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8124" PostTypeId="2" ParentId="8122" CreationDate="2016-06-07T14:20:21.063" Score="3" Body="&lt;p&gt;&lt;code&gt;:sp&lt;/code&gt; and &lt;code&gt;:vs&lt;/code&gt; take a filename as argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can do &lt;code&gt;:sp filename&lt;/code&gt; and &lt;code&gt;:sp filename&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The doc &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#:sp&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :sp&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:[N]sp[lit] [++opt] [+cmd] [file]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If [file] is given it will be edited in the new window.  If it&#xA;          is not loaded in any buffer, it will be read.  Else the new&#xA;          window will use the already loaded buffer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-06-07T14:20:21.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8125" PostTypeId="2" ParentId="8122" CreationDate="2016-06-07T14:21:54.767" Score="7" Body="&lt;p&gt;You can do &lt;code&gt;:2sbN&lt;/code&gt; or &lt;code&gt;:sbN 2&lt;/code&gt; to split the window and go to the 2 buffer. To split the window vertically, you can use &lt;code&gt;:vert sbN 3&lt;/code&gt; to go to buffer 3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative solution is to use the &lt;code&gt;:sp [+cmd]&lt;/code&gt; syntax. To vertical split the window and go to buffer 10 you would then use &lt;code&gt;:vsp +b10&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="205" LastEditDate="2016-06-07T15:01:29.273" LastActivityDate="2016-06-07T15:01:29.273" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8126" PostTypeId="2" ParentId="8114" CreationDate="2016-06-07T15:35:39.823" Score="5" Body="&lt;p&gt;You can use look behind (&lt;code&gt;:h \@&amp;lt;=&lt;/code&gt;) to make sure there is a preceding '(',&#xA;and an end-of-word boundary (&lt;code&gt;:h \&amp;gt;&lt;/code&gt;) to make sure the substitution happens where you want it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, with the text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function my_function(argument, another argument, but there are spaces)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;running the command: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\((.*\)\@&amp;lt;=\&amp;gt; /_/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will produce:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function my_function(argument, another_argument, but_there_are_spaces)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This might be easier than having to position the cursor each time, provided the substitution always has a known starting point.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-06-07T15:35:39.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8127" PostTypeId="1" AcceptedAnswerId="8136" CreationDate="2016-06-07T16:50:03.527" Score="7" ViewCount="147" Body="&lt;p&gt;I want to be able to search only within the &lt;code&gt;DiffText&lt;/code&gt; regions of a file that I'm editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related question: &lt;a href=&quot;https://stackoverflow.com/questions/2683521/vim-search-in-c-c-code-lines&quot;&gt;https://stackoverflow.com/questions/2683521/vim-search-in-c-c-code-lines&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The accepted answer here seems to work great for say, &lt;code&gt;Comment&lt;/code&gt; or &lt;code&gt;Type&lt;/code&gt; syntax groups, but any of the Diff groups don't work. I surmise it something to do with the diff groups being nested within other groups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My specific scenario is that I've removed a bunch of tabs and trailing spaces from a bunch of files. I've diffed the files with the originals and want to make sure that nothing except tabs and trailing spaces are different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I don't want to do a global replace of all the tabs because my predecessor used inconsistent indentation and I need to manually check all of it.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-06-09T14:49:07.383" Title="Is there a way to restrict search results to differences in a diff?" Tags="|syntax-highlighting|search|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8128" PostTypeId="1" AcceptedAnswerId="8129" CreationDate="2016-06-07T17:48:15.820" Score="13" ViewCount="17737" Body="&lt;p&gt;I'm coming from Atom, and with that I can highlight multiple lines and hit &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt; and it'll toggle comments for those lines. I how easy this is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I do something similar using &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt; with vim? I don't want to be doing &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;, highlight rows, &lt;code&gt;//&lt;/code&gt;, escape. That's too much effort.&lt;/p&gt;&#xA;" OwnerUserId="7911" LastEditorUserId="1841" LastEditDate="2016-06-07T20:23:57.180" LastActivityDate="2016-06-09T19:33:18.093" Title="How to toggle comments with ctrl+/?" Tags="|comments|" AnswerCount="2" CommentCount="3" ClosedDate="2016-06-09T19:33:34.590" ContentLicense="CC BY-SA 3.0" />
  <row Id="8129" PostTypeId="2" ParentId="8128" CreationDate="2016-06-07T19:06:31.730" Score="13" Body="&lt;p&gt;It all depends on how extensive you want it to be. What type of files are you editing? I have the following in my &lt;code&gt;.vimrc&lt;/code&gt; that works with python files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let Comment='#'&#xA;&#xA;xnoremap # :norm 0i&amp;lt;C-r&amp;gt;=Comment&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;xnoremap &amp;amp; :norm ^&amp;lt;C-r&amp;gt;=len(Comment)&amp;lt;CR&amp;gt;x&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works well, but you have to manually setup each filetype, so a little bit of a pain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would a plugin work for you? &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot;&gt;tpope/commentary&lt;/a&gt; is a very useful and popular plugin for comments. It has this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                *v_gc*&#xA;{Visual}gc              Comment or uncomment the highlighted lines.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could easily add &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;C-\&amp;gt; gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your vimrc, and this would do what exactly what you describe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As well as many other useful mappings so you don't need to even enter visual mode. For exampe:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gc}                     Comment or uncomment a paragraph&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-07T19:06:31.730" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8130" PostTypeId="2" ParentId="8128" CreationDate="2016-06-07T19:29:20.120" Score="4" Body="&lt;p&gt;Unfortunately, as far as I know &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;/&lt;/kbd&gt; cannot be bound to in vim. :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you're not attached to that particular mapping the rest is pretty simple. Here's an example that uses &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;M&lt;/kbd&gt; (simply because it's close to you're mapping):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C-m&amp;gt; :normal! I//&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works for C like files, but we can do better.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C-m&amp;gt; :&amp;lt;S-Left&amp;gt;exe &quot;&amp;lt;S-Right&amp;gt;normal! I&quot;.b:commentType&amp;lt;CR&amp;gt;&#xA;&#xA;autocmd BufReadPost *.[ch] let b:commentType='//' &quot;C files&#xA;autocmd BufReadPost *.pl let b:commentType='#'    &quot;Perl files&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a bit longer but it allows us to specify different types of comments for different types of files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works because when you visually select something and then press &lt;kbd&gt;:&lt;/kbd&gt;, vim automatically fills in the a range of &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; for you. This is the range of the selection. The &lt;code&gt;&amp;lt;S-Left&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;S-Right&amp;gt;&lt;/code&gt; moves above are simply navigating around this pre-filled text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Making it a toggle button adds quite a bit of complexity. The big problem is determining whether or not the lines you have selected are comments or not. This becomes increasingly harder when we don't know what syntax starts a comment. I believe that the most robust way to do this will be to rely on vim's syntax highlighter to tell us when we are in a comment or not. Here's what I've got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;expr&amp;gt; &amp;lt;C-m&amp;gt; (synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 0), &quot;name&quot;) =~ 'comment\c') ?&#xA;\ ':&amp;lt;S-Left&amp;gt;exe &quot;&amp;lt;S-Right&amp;gt;normal! &quot;.b:unCommentCommand&amp;lt;CR&amp;gt;' :&#xA;\ ':&amp;lt;S-Left&amp;gt;exe &quot;&amp;lt;S-Right&amp;gt;normal! &quot;.b:commentCommand&amp;lt;CR&amp;gt;'&#xA;&#xA;autocmd BufReadPost *.[ch] let b:commentCommand='I//'   &quot;Comment for C files&#xA;autocmd BufReadPost *.[ch] let b:unCommentCommand='^xx' &quot;un-Comment for C files&#xA;autocmd BufReadPost *.pl   let b:commentCommand='I#'    &quot;Comment for perl files&#xA;autocmd BufReadPost *.pl   let b:unCommentCommand='^x'  &quot;un-Comment for perl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will decide whether or not to comment or uncomment based on if your cursor is in a comment region or not. This isn't perfect because if your cursor is perhaps in the initial indentation of a comment it will not register as a comment. But this works reasonably well.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;synIDattr(...)&lt;/code&gt; finds the syntax group under the cursor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; allows us to do a conditional mapping&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Of course for each file type you want to edit you will have to add another autocmd for the &lt;code&gt;b:commentCommand&lt;/code&gt; and &lt;code&gt;b:unCommentCommand&lt;/code&gt;. This takes the form of a normal command that will do the comment/un-comment for that file type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I relized that I could simplify all my &lt;code&gt;&amp;lt;Left&amp;gt;&lt;/code&gt; calls to a single &lt;code&gt;&amp;lt;S-Left&amp;gt;&lt;/code&gt; and have updated my answer above as well.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-06-09T19:33:18.093" LastActivityDate="2016-06-09T19:33:18.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8131" PostTypeId="2" ParentId="8111" CreationDate="2016-06-07T20:51:55.933" Score="3" Body="&lt;p&gt;The answer was posted in the comments by @DJ McMayhem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set enc?&#xA;latin-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So by changing it to utf-8 the text becomes readable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set enc=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="383" LastActivityDate="2016-06-07T20:51:55.933" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8132" PostTypeId="2" ParentId="8127" CreationDate="2016-06-07T22:13:31.570" Score="3" Body="&lt;p&gt;Well, the simple way to search the differences (all&#xA;different lines, not just DiffText, sorry) would be to run&#xA;&lt;code&gt;diff&lt;/code&gt; on the two files, put the output in a buffer and&#xA;search there. Assuming you're viewing filea and fileb in&#xA;vimdiff:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new | r! diff -u0 filea fileb&#xA;/search-for-something&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Line numbers will be in the output, in lines like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@@ -9,3 +8,6 @@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so you could easily jump&#xA;to the line (9) in the original file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?@@&amp;lt;CR&amp;gt;0/\d&amp;lt;CR&amp;gt;yw:q!:@&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This searches backwards for a line-number line, yanks the line number into&#xA;@&quot;, closes the temporary search buffer, and jumps to the line number. You'll probably&#xA;want to massage that to take into account your window&#xA;layout, etc., and maybe map it to a key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also include context lines in the diff, to make it easier read, but make sure that your searches look in lines with changes, i.e. those that start with a non-blank:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^\S.*\zssearch-for-something&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-06-07T23:43:55.880" LastActivityDate="2016-06-07T23:43:55.880" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8133" PostTypeId="1" AcceptedAnswerId="8137" CreationDate="2016-06-08T05:09:45.033" Score="4" ViewCount="232" Body="&lt;p&gt;When using &lt;code&gt;:Glog&lt;/code&gt; or other git plugins like &lt;code&gt;:GV&lt;/code&gt; (&lt;code&gt;gitv&lt;/code&gt;?) and checking revisions or commit you end up in Read-Only mode viewing something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fugitive:///.git//300ed70aa473b7e8f983a2590c2af908cd0a0621/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get to the original &lt;code&gt;file&lt;/code&gt; in the current working tree?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is especially handy when using &lt;code&gt;:Glog&lt;/code&gt; and stepping back in time, to get back to &quot;now&quot;.&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="205" LastEditDate="2016-06-08T10:33:56.290" LastActivityDate="2016-06-08T10:33:56.290" Title="How do I get back to the current working copy while viewing git revisions?" Tags="|git|plugin-fugitive|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8134" PostTypeId="1" AcceptedAnswerId="8135" CreationDate="2016-06-08T05:49:37.847" Score="3" ViewCount="3902" Body="&lt;p&gt;I am trying to configure the statusline using plugins &quot;vim-airline&quot; and &quot;vim-airline-themes&quot;. And i get this character &quot;☰&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me understand why is this being displayed and how to fix this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following is my .vimrc settings: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Backup Settings&#xA;set backup&#xA;set noswapfile&#xA;set backupdir=~/.vim/tmp/backup//&#xA;set undodir=~/.vim/tmp/undo//&#xA;set directory=~/.vim/tmp/swap//&#xA;&#xA;&quot; Vundle Settings&#xA;set nocompatible&#xA;filetype off&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'flazz/vim-colorschemes'&#xA;Plugin 'altercation/vim-colors-solarized'&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'scrooloose/nerdcommenter'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'junegunn/vim-easy-align'&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'MarcWeber/vim-addon-mw-utils'&#xA;Plugin 'tomtom/tlib_vim'&#xA;Plugin 'honza/vim-snippets'&#xA;Plugin 'garbas/vim-snipmate'&#xA;Plugin 'scrooloose/syntastic'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;&#xA;call vundle#end()&#xA;&#xA;filetype plugin indent on&#xA;&#xA;set tabstop=4&#xA;set softtabstop=4&#xA;set shiftwidth=4&#xA;set showmatch&#xA;set ruler&#xA;set nohlsearch&#xA;set incsearch&#xA;set cursorline&#xA;set wildmenu&#xA;set laststatus=2&#xA;set guitablabel=%t&#xA;syntax on&#xA;set showcmd&#xA;set autoindent&#xA;set hidden&#xA;set smartindent&#xA;set smarttab&#xA;set completeopt+=longest,menuone,preview&#xA;&#xA;&quot; Begin of airline settings&#xA;&quot; Load powerline fonts/symbols for airline&#xA;let g:airline_powerline_fonts = 1&#xA;&#xA;&quot; AirLine Theme&#xA;:let g:airline_theme='badwolf'&#xA;&#xA;&quot; Enable the list of buffers&#xA;let g:airline#extensions#tabline#enabled = 1&#xA;&#xA;&quot; Show just the filename&#xA;let g:airline#extensions#tabline#fnamemod = ':t'&#xA;&#xA;&quot; End of airline settings&#xA;&#xA;&quot; Show two lines for the status line&#xA;set laststatus=2&#xA;&#xA;&quot; Make sure Vim returns to the same line when you reopen a file.&#xA;augroup line_return&#xA;     au!&#xA;         au BufReadPost *&#xA;                 \ if line(&quot;'\&quot;&quot;) &amp;gt; 0 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) |&#xA;        \     execute 'normal! g`&quot;zvzz' |&#xA;        \ endif&#xA;augroup END&#xA;&#xA;&quot; Always show the last line&#xA;set display+=lastline&#xA;&#xA;&quot; Set encoding to utf-8&#xA;set encoding=utf-8&#xA;&#xA;&quot; Set dictionary&#xA;set dictionary=/usr/share/dict/words&#xA;&#xA;&quot; Syntastic settings&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;&#xA;let g:syntastic_enable_signs=1&#xA;let g:syntastic_error_symbol = '✗✗'&#xA;let g:syntastic_style_error_symbol = '✠✠'&#xA;let g:syntastic_warning_symbol = '∆∆'&#xA;let g:syntastic_style_warning_symbol = '≈≈'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nfeqI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nfeqI.png&quot; alt=&quot;vim-airline issue&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7919" LastEditorUserId="1841" LastEditDate="2016-06-08T13:09:17.187" LastActivityDate="2018-01-12T07:05:28.807" Title="Why vim-airline displays ☰ character?" Tags="|plugin-airline|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8135" PostTypeId="2" ParentId="8134" CreationDate="2016-06-08T07:47:49.127" Score="11" Body="&lt;p&gt;That symbols stands for the last line number. So if it displays:&#xA;&lt;code&gt;1/10 ☰&lt;/code&gt; you know that you are on line 1 of 10 lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: this symbol is in the documentation, search for maxlinenr.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-06-08T07:47:49.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8136" PostTypeId="2" ParentId="8127" CreationDate="2016-06-08T08:02:31.383" Score="7" Body="&lt;p&gt;Not natively (also I have written a patch, that would allow to add a skip expression to the search() function, but this hasn't been included yet).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you can workaround it by writing your own function that checks, whether the match is in a diff region contained. Something like this (very basic approach):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Search(pat)&#xA;    while search(a:pat, 'w') &amp;gt; 0&#xA;        if diff_hlID(line('.'),col('.')) != 0&#xA;            break&#xA;        endif&#xA;    endwhile&#xA;endfunction&#xA;&#xA;com! -nargs=1 Search :call Search(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Error checking and handling more edge cases (abort after the search has wrapped around, eg.) left as excercise to the user.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2016-06-09T14:49:07.383" LastActivityDate="2016-06-09T14:49:07.383" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8137" PostTypeId="2" ParentId="8133" CreationDate="2016-06-08T08:07:04.750" Score="5" Body="&lt;p&gt;The &lt;code&gt;Gedit&lt;/code&gt; command is here for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It takes an argument which is the revision you want to use, using the same logic as &lt;a href=&quot;https://git-scm.com/docs/git-rev-parse&quot;&gt;git-rev-parse&lt;/a&gt; (meaning you can use it without argument to get back to your working copy), so, on your file, type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Gedit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you're back to your working copy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h fugitive-:Gedit&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h fugitive-revision&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-08T08:07:04.750" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8138" PostTypeId="1" AcceptedAnswerId="8141" CreationDate="2016-06-08T10:48:05.180" Score="4" ViewCount="259" Body="&lt;p&gt;I want to define a Vim command that will install all LaTeX packages used in a &lt;code&gt;.tex&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To install packages I can do &lt;code&gt;sudo tlmgr install package1 package2 package3&lt;/code&gt; etc. in the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now I need a way to get the names of all packages used in the file and use them with &lt;code&gt;tlmgr&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be even better if I don't have to leave the buffer to type the &lt;code&gt;sudo&lt;/code&gt; password, but that's not strictly necessary.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The packages are added like so: &lt;code&gt;\usepackage{whatever}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if this is the best way to do it, but I'm doing this to match the lines that call packages:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/^\\usepackage\(\[.*\]\)\?{\(.*\)}$&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it matches the whole line. Then I added that second pair of escaped parenthesis hoping to capture just the name of the package… but now I have no idea how to call &lt;code&gt;tlmgr&lt;/code&gt; using just those names.&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="7642" LastEditDate="2016-09-18T21:13:32.180" LastActivityDate="2016-09-18T21:13:32.180" Title="Use search matches as parameters in external command" Tags="|command-line|external-command|filetype-tex|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8139" PostTypeId="1" AcceptedAnswerId="8149" CreationDate="2016-06-08T10:50:51.823" Score="2" ViewCount="116" Body="&lt;p&gt;There are several plug-ins can accomplish this task, auto-add a closing bracket when we type: &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;[&lt;/code&gt; or &lt;code&gt;{&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then the cursor will be in the middle of paired bracket, when we finish inserting, we need to &lt;kbd&gt;ESC&lt;/kbd&gt;, &lt;code&gt;li&lt;/code&gt; to continue typing rest of the content. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is quite frustrating, just autocomplete one character, we need to type 3 additional keys, is there a way to get around this? I still want to keep bracket auto-pairing though. &lt;/p&gt;&#xA;" OwnerUserId="7916" LastEditorUserId="205" LastEditDate="2016-06-08T10:59:12.160" LastActivityDate="2016-06-08T21:00:51.447" Title="additional input complication due to auto-match bracket in Vim" Tags="|cursor-movement|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8140" PostTypeId="2" ParentId="8138" CreationDate="2016-06-08T11:05:05.737" Score="3" Body="&lt;p&gt;I'm not sure because I don't have the &lt;code&gt;tlmgr&lt;/code&gt; shell command to test it, but you could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! InstallTexPackages call s:install_tex_packages()&#xA;function! s:install_tex_packages() abort&#xA;    let winview = winsaveview()&#xA;    let packages = []&#xA;    sil! %s/^\\usepackage{\zs.*\ze}$/\=add(packages, submatch(0))/gn&#xA;    exe '!sudo tlmgr' join(packages)&#xA;    call winrestview(winview)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It installs the &lt;code&gt;:InstallTexPackages&lt;/code&gt; command which calls the &lt;code&gt;s:install_tex_packages()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pattern used to search for the packages names is &lt;code&gt;^\\usepackage{\zs.*\ze}$&lt;/code&gt; which should match &lt;code&gt;foo&lt;/code&gt;, &lt;code&gt;bar&lt;/code&gt;, &lt;code&gt;baz&lt;/code&gt; in the following buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\usepackage{foo}&#xA;\usepackage{bar}&#xA;\usepackage{baz}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The atoms &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; allow you to use the text before and after the packages names as anchors, and not include them in the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The names are stored in the list &lt;code&gt;packages&lt;/code&gt;, and the substitution command &lt;code&gt;:s&lt;/code&gt; is called to progressively populate the list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each time a package name is found, &lt;code&gt;:s&lt;/code&gt; evaluates (&lt;code&gt;\=&lt;/code&gt;) the expression &lt;code&gt;add(packages, submatch(0))&lt;/code&gt;. &lt;code&gt;add()&lt;/code&gt; adds an item to a list. Here the list is &lt;code&gt;packages&lt;/code&gt; and the item is &lt;code&gt;submatch(0)&lt;/code&gt;, which is the text which has just been matched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No substitution is made thanks to the &lt;code&gt;n&lt;/code&gt; flag (&lt;code&gt;:h :s_flags&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be able to evaluate an expression with the &lt;code&gt;n&lt;/code&gt; flag, your Vim version needs to be newer than 7.3.627. If it's not, you would have to replace the substitution command with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call cursor(1, 1)&#xA;let matchline = search('^\\usepackage{\zs.*\ze}$', 'cW')&#xA;while matchline&#xA;    let packages += [matchstr(getline(matchline), '^\\usepackage{\zs.*\ze}$')]&#xA;    let matchline = search('^\\usepackage{\zs.*\ze}$', 'W')&#xA;endwhile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-06-08T11:30:00.800" LastActivityDate="2016-06-08T11:30:00.800" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8141" PostTypeId="2" ParentId="8138" CreationDate="2016-06-08T11:44:15.107" Score="7" Body="&lt;p&gt;To avoid leaving the buffer for entering the password, you can use &lt;code&gt;sudo&lt;/code&gt;'s &lt;a href=&quot;http://manpages.ubuntu.com/manpages/trusty/en/man8/sudo.8.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;-S&lt;/code&gt; flag&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt; -S, --stdin&#xA;             Write the prompt to the standard error and read the password&#xA;             from the standard input instead of using the terminal device.&#xA;             The password must be followed by a newline character.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then your function could look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! InstallPackages()&#xA;    let winview = winsaveview()&#xA;    call inputsave()&#xA;    let cmd = ['sudo -S tlmgr install']&#xA;    %call add(cmd, matchstr(getline('.'), '\\usepackage\(\[.*\]\)\?{\zs.*\ze\}'))&#xA;    echomsg join(cmd)&#xA;    let pass = inputsecret('Enter sudo password:') . &quot;\n&quot;&#xA;    echo system(join(cmd), pass)&#xA;    call inputrestore()&#xA;    call winrestview(winview)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the second argument to &lt;code&gt;system&lt;/code&gt; is passed as standard input, we can use Vim's &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#inputsecret%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;inputsecret()&lt;/code&gt;&lt;/a&gt; function to read the password and send it to &lt;code&gt;sudo&lt;/code&gt; (but we need to add the trailing newline ourselves, or &lt;code&gt;sudo&lt;/code&gt; will wait around for it).&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-06-08T19:44:37.960" LastActivityDate="2016-06-08T19:44:37.960" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8142" PostTypeId="1" CreationDate="2016-06-08T14:29:30.320" Score="4" ViewCount="1501" Body="&lt;p&gt;This is a really minor thing but it keeps bugging me. Whenever I try to open &lt;code&gt;foo.txt&lt;/code&gt; if a &lt;code&gt;.foo.txt.swp&lt;/code&gt; file exists, the error message that shows up displays in a color that painfully clashes with my background color as seen below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u5WTX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u5WTX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Playing with colors in my Terminal.app preferences didn't change this color. How do I change this color?&lt;/p&gt;&#xA;" OwnerUserId="5043" LastActivityDate="2020-06-27T21:49:35.593" Title="Change color of Vim error message when .swp file exists" Tags="|colorscheme|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8143" PostTypeId="2" ParentId="8142" CreationDate="2016-06-08T14:41:43.327" Score="2" Body="&lt;p&gt;You can change the color by changing the colorscheme you are using. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are probably many entries on the file defining your colorscheme, but you can find which one you should change by executing &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Ahighlight&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:highlight&lt;/code&gt;&lt;/a&gt;, which will list all current highlight groups and how they are displayed. Just look for the one that hurts your eyes and change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using a colorscheme that comes bundled with vim you could follow the instructions at &lt;a href=&quot;http://vimhelp.appspot.com/usr_06.txt.html#06.3&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help 6.3&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;You could also write your own color scheme.  This is how you do it:&#xA;&#xA;1. Select a color scheme that comes close.  Copy this file to your own Vim&#xA;   directory.  For Unix, this should work:&#xA;&#xA;    !mkdir ~/.vim/colors&#xA;    !cp $VIMRUNTIME/colors/morning.vim ~/.vim/colors/mine.vim&#xA;&#xA;   This is done from Vim, because it knows the value of $VIMRUNTIME.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When I run :highlight none of the colors match the one I don't like,&#xA;  including the MoreMsg highlighting group. Nothing changes when I put&#xA;  the line hi MoreMsg term=bold ctermfg=black gui=bold guifg=black in&#xA;  ~/.vim/colors/mine.vim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is really unexpected. Try restarting Vim or issuing &lt;code&gt;:colorscheme mine&lt;/code&gt; to ensure that your changes are being read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The colors are usually defined by the colorscheme, but there is a chance that some plugin you are using is overwriting the highlight group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first you should check if the colorscheme is indeed the culprit. Try commenting all the lines on the current colorscheme and then restart Vim. If nothing changes you could also try changing the colorscheme and check if the color of the message changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the problem persists, you should follow the procedure described on &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-2.5&quot; rel=&quot;nofollow&quot;&gt;Vim-FAQ  2.5&lt;/a&gt;. Some relevant parts follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2.5. I have a &quot;xyz&quot; (some) problem with Vim. How do I determine it is a&#xA;       problem with my setup or with Vim?  / Have I found a bug in Vim?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;First, you need to find out, whether the error is in the actual&#xA;  runtime files or any plugin that is distributed with Vim or whether it&#xA;  is a simple side effect of any configuration option from your .vimrc&#xA;  or .gvimrc. So first, start vim like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;this starts Vim in nocompatible mode (-N), without reading your&#xA;  viminfo file (-i NONE), without reading any configuration file (-u&#xA;  NONE for not reading .vimrc file and -U NONE for not reading a .gvimrc&#xA;  file) or even plugin.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If the error does not occur when starting Vim this way, then the&#xA;  problem is either related to some plugin of yours or some setting in&#xA;  one of your local setup files. You need to find out, what triggers the&#xA;  error, you try starting Vim this way: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;If the error occurs, the problem is your .viminfo file. Simply delete&#xA;  the viminfo file then. If the error does not occur, try: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u ~/.vimrc --noplugin -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This will simply use your .vimrc as configuration file, but not load&#xA;  any plugins. If the error occurs this time, the error is possibly&#xA;  caused by some configuration option inside your .vimrc file. Depending&#xA;  on the length of your vimrc file, it can be quite hard to trace the&#xA;  origin within that file.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The best way is to add :finish command in the middle of your .vimrc.&#xA;  Then restart again using the same command line. If the error still&#xA;  occurs, the bug must be caused because of a setting in the first half&#xA;  of your .vimrc. If it doesn't happen, the problematic setting must be&#xA;  in the second half of your .vimrc. So move the :finish command to the&#xA;  middle of that half, of which you know that triggers the error and&#xA;  move your way along, until you find the problematic option. If your&#xA;  .vimrc is 350 lines long, you need at a maximum 9 tries to find the&#xA;  offending line (in practise, this can often be further reduced, since&#xA;  often lines depend on each other).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If the problem does not occur, when only loading your .vimrc file, the&#xA;  error must be caused by a plugin or another runtime file (indent&#xA;  autoload or syntax script). Check the output of the :scriptnames&#xA;  command to see what files have been loaded and for each one try to&#xA;  disable each one by one and see which one triggers the bug. Often&#xA;  files that are loaded by vim, have a simple configuration variable to&#xA;  disable them, but you need to check inside each file separately.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If your problem still occurs when using &lt;code&gt;vim -u NONE -U NONE -N -i NONE&lt;/code&gt; then you could check if it is specific to your terminal by trying to reproduce it on another type of terminal (xterm, urxvt, etc).&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-06-09T13:01:07.463" LastActivityDate="2016-06-09T13:01:07.463" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8144" PostTypeId="2" ParentId="8142" CreationDate="2016-06-08T14:49:21.357" Score="7" Body="&lt;p&gt;This is using the &lt;code&gt;MoreMsg&lt;/code&gt; highlighting group, so in your colorscheme, you want to tweak this highlighting option.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-06-08T14:49:21.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8145" PostTypeId="1" CreationDate="2016-06-08T16:32:01.960" Score="-3" ViewCount="173" Body="&lt;p&gt;My vim  doesn't represent the uppercase letter q &lt;code&gt;Q&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to fix this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is my vimrc :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;syntax on&#xA;set incsearch&#xA;set tabstop=4 softtabstop=4 shiftwidth=4&#xA;&#xA;set expandtab&#xA;&#xA;autocmd BufWinLeave *.* mkview&#xA;autocmd BufWinEnter *.* silent loadview &#xA;&#xA;set smarttab&#xA;set expandtab&#xA;se smartindent&#xA;if exists(&quot;:nohls&quot;)&#xA;  nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-L&amp;gt; :nohls&amp;lt;CR&amp;gt;&amp;lt;C-L&amp;gt;&#xA;endif&#xA;set noswapfile&#xA;set pastetoggle=&amp;lt;F10&amp;gt;&#xA;set guifont=Monospace\ 6&#xA;se relativenumber&#xA;se number&#xA;nnoremap &amp;lt;leader&amp;gt;s :syntax on&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;S :syntax off&amp;lt;CR&amp;gt;&#xA;colorscheme evening&#xA;set hlsearch&#xA;&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_loc_list_height = 5&#xA;let g:syntastic_auto_loc_list = 0&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;&#xA;let g:syntastic_html_tidy_exec = 'tidy5'&#xA;let g:syntastic_javascript_checkers = ['standard']&#xA;let g:syntastic_javascript_checkers = ['eslint']&#xA;let g:syntastic_javascript_eslint_exec = 'eslint_d'&#xA;&#xA;let g:syntastic_error_symbol = '❌'&#xA;let g:syntastic_style_error_symbol = '⁉️'&#xA;let g:syntastic_warning_symbol = '⚠️'&#xA;let g:syntastic_style_warning_symbol = ''&#xA;&#xA;highlight link SyntasticErrorSign SignColumn&#xA;highlight link SyntasticWarningSign SignColumn&#xA;highlight link SyntasticStyleErrorSign SignColumn&#xA;highlight link SyntasticStyleWarningSign SignColumn&#xA;&#xA;nmap * &amp;lt;Plug&amp;gt;AgActionWord&#xA;vmap * &amp;lt;Plug&amp;gt;AgActionVisual&#xA;let g:vim_action_ag_escape_chars = '#%.^$*+?()[{\\|'&#xA;nnoremap &amp;lt;F5&amp;gt; :GundoToggle&amp;lt;CR&amp;gt;&#xA;nnoremap gr :grep &amp;lt;cword&amp;gt; *&amp;lt;CR&amp;gt;&#xA;nnoremap Gr :grep &amp;lt;cword&amp;gt; %:p:h/*&amp;lt;CR&amp;gt;&#xA;nnoremap gR :grep '\b&amp;lt;cword&amp;gt;\b' *&amp;lt;CR&amp;gt;&#xA;nnoremap GR :grep '\b&amp;lt;cword&amp;gt;\b' %:p:h/*&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;F12&amp;gt;f :exe ':silent !firefox %'&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;F8&amp;gt; :TagbarToggle&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;F12&amp;gt;c :exe ':silent !google-chrome %'&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;% :MtaJumpToOtherTag&amp;lt;cr&amp;gt;&#xA;let g:airline#extensions#tabline#enabled = 1&#xA;nnoremap &amp;lt;F12&amp;gt;o :exe ':silent !opera %'&amp;lt;CR&amp;gt;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;let g:vcool_ins_rgba_map = '&amp;lt;A-z&amp;gt;'&#xA;    set so=5&#xA;call vundle#begin()&#xA;syntax enable&#xA;filetype plugin indent on&#xA;&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;map &amp;lt;A-U&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;Bundle &quot;justinj/vim-react-snippets&quot;&#xA;&#xA;Bundle &quot;MarcWeber/vim-addon-mw-utils&quot;&#xA;Bundle &quot;tomtom/tlib_vim&quot;&#xA;Bundle &quot;garbas/vim-snipmate&quot;&#xA;&#xA;Bundle &quot;honza/vim-snippets&quot;&#xA;Plugin 'scrooloose/syntastic'&#xA;&#xA;Plugin 'rking/ag.vim'&#xA;Plugin 'Chun-Yang/vim-action-ag'&#xA;Plugin 'Yggdroot/indentLine'&#xA;Bundle &quot;chrisbra/histwin.vim&quot;&#xA;Plugin 'KabbAmine/vCoolor.vim'&#xA;Bundle &quot;sjl/gundo.vim&quot;&#xA;Plugin 'ctrlpvim/ctrlp.vim'&#xA;Plugin 'majutsushi/tagbar'&#xA;Bundle 'scrooloose/nerdtree'&#xA;Plugin 'jeffkreeftmeijer/vim-numbertoggle'&#xA;Plugin 'mattn/emmet-vim'&#xA;Plugin 'bling/vim-airline'&#xA;Bundle 'vim-scripts/xtemplate'&#xA;Bundle 'ap/vim-templates'&#xA;Plugin 'Valloric/MatchTagAlways'&#xA;Plugin 'pangloss/vim-javascript'&#xA;Plugin 'ap/vim-css-color'&#xA;Plugin 'tpope/vim-commentary'&#xA;Plugin 'tpope/vim-repeat'&#xA;Plugin 'tpope/vim-unimpaired'&#xA;Bundle 'tpope/vim-surround'&#xA;&#xA;Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7431" LastEditorUserId="1821" LastEditDate="2016-06-09T08:06:21.383" LastActivityDate="2016-06-09T08:06:21.383" Title="Make gvim show Q letter (character)" Tags="|vimrc|gvim|letter-case|" AnswerCount="1" CommentCount="11" ClosedDate="2016-06-10T22:37:33.170" ContentLicense="CC BY-SA 3.0" />
  <row Id="8146" PostTypeId="2" ParentId="8145" CreationDate="2016-06-08T17:58:45.757" Score="4" Body="&lt;p&gt;Something in your &lt;code&gt;.vimrc&lt;/code&gt; or plugins is mapped to &lt;code&gt;Q&lt;/code&gt;. Run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:iunmap Q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After sourcing your &lt;code&gt;.vimrc&lt;/code&gt;, and that should fix it for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that works, you can make this permanent by adding that to the end of your &lt;code&gt;.vimrc&lt;/code&gt;, but make sure that happens &lt;em&gt;after&lt;/em&gt; every plugin call or mapping you do.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-06-08T18:02:58.807" LastActivityDate="2016-06-08T18:02:58.807" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8147" PostTypeId="1" AcceptedAnswerId="8148" CreationDate="2016-06-08T19:26:30.443" Score="2" ViewCount="2380" Body="&lt;p&gt;I've found this little trick in vim wiki.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;s :%s/\&amp;lt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;\&amp;gt;//g&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Immediately I thought that in some cases it would be beneficial to use word in substitution, so I've added capturing parentheses for back reference.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;* *:%s/\v(&amp;lt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;&amp;gt;)//g&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using this primarily as a replacement for rename refactoring, so I thought: &quot;You know what? In all those IDEs when I've renamed things it's always been a little pain to change one or two words in multiword variable&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mean something like &lt;code&gt;first&lt;/code&gt; in &lt;code&gt;first_second_third&lt;/code&gt; or &lt;code&gt;FirstSecondThird&lt;/code&gt; or &lt;code&gt;firstSecondThird&lt;/code&gt;. Thanks to extensibility of vim this should be easy to do. I just need to split the word under cursor by rule that depends of whether its a camel case word of snake case word (easy to determine if we would take as a rule, that the word either a snake case or camel case, but not both). And then to produce the argument to the substitute command with each actual word in variable name surrounded by capturing parens, like so.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v(first)_(second)_(third)//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With that if I need to change second word all I need to do is enter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\1something_other\2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is pretty neat in my opinion.&#xA;The problem is that I don't know how to make a mapping call substitute with dynamic parameters.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2016-06-08T21:46:48.990" Title="How to map key to a substitute command with dynamic text?" Tags="|search|replace|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8148" PostTypeId="2" ParentId="8147" CreationDate="2016-06-08T19:49:57.683" Score="3" Body="&lt;p&gt;I'm not sure but maybe the following code could work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;s &amp;lt;SID&amp;gt;change_word_under_cursor()&#xA;fu! s:change_word_under_cursor() abort&#xA;    let word = expand('&amp;lt;cword&amp;gt;')&#xA;    let subwords = split(word, word =~# '_' ? '_' : '\ze\u')&#xA;    return ':%s/\v' . join(map(subwords, '&quot;(&quot; . v:val . &quot;)&quot;'), word =~# '_' ? '_' : '') . '//g' . &quot;\&amp;lt;Left&amp;gt;\&amp;lt;Left&amp;gt;&quot;&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; is an argument that you can pass to a mapping command such as &lt;code&gt;:nnoremap&lt;/code&gt;. It tells Vim to not consider the &lt;code&gt;{rhs}&lt;/code&gt; as keys to type, but as an expression to evaluate, and then type the evaluation as keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the expression is the function &lt;code&gt;s:change_word_under_cursor&lt;/code&gt;.&lt;br&gt;&#xA;In order to not pollute your global namespace, it's local to the script where you'll write the code.&lt;br&gt;&#xA;The problem is that when you'll hit &lt;code&gt;&amp;lt;Leader&amp;gt;s&lt;/code&gt;, the function will be called from outside the script, and Vim won't know where to look for it.&lt;br&gt;&#xA;The solution is to add &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; in front of the name of the function. When your mapping will be sourced and add an entry in the mappings table, &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; will be translated into something like &lt;code&gt;&amp;lt;SNR&amp;gt;{some_number}_&lt;/code&gt;. &lt;code&gt;{some_number}&lt;/code&gt; will tell Vim in which script to look for the function.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The function does the following thing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let word = expand('&amp;lt;cword&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Store the word under the cursor inside the variable &lt;code&gt;word&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let subwords = split(word, word =~# '_' ? '_' : '\ze\u')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;word =~# '_' ? '_' : '\ze\u'&lt;/code&gt; is an expression using the ternary operator &lt;code&gt;?:&lt;/code&gt; which checks whether the word contains an underscore. If it does, its evaluation is the string &lt;code&gt;'_'&lt;/code&gt; otherwise the string &lt;code&gt;'\ze\u'&lt;/code&gt;. This string will be used by the &lt;code&gt;split()&lt;/code&gt; function to know where to split the word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;split(word, …)&lt;/code&gt; splits the word every time an underscore or an uppercase letter is found, and returns a list containing the result.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return ':%s/\v' . join(map(subwords, '&quot;(&quot; . v:val . &quot;)&quot;'), word =~# '_' ? '_' : '') . '//g' . &quot;\&amp;lt;Left&amp;gt;\&amp;lt;Left&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Return the keys to type.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map(subwords, '…')&lt;/code&gt; applies a transformation on each word inside the list &lt;code&gt;subwords&lt;/code&gt;, which surrounds them with parentheses.&lt;br&gt;&#xA;And &lt;code&gt;join(map(…), word =~# '_' ? '_' : '')&lt;/code&gt; concatenates the items inside the list by adding an underscore or nothing between 2 consecutive items.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can find more information on this with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h &amp;lt;expr&amp;gt;&#xA;:h &amp;lt;sid&amp;gt;&#xA;:h /\ze&#xA;:h split()&#xA;:h map()&#xA;:h join()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-06-08T20:32:48.513" LastActivityDate="2016-06-08T20:32:48.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8149" PostTypeId="2" ParentId="8139" CreationDate="2016-06-08T21:00:51.447" Score="3" Body="&lt;p&gt;Fleshing out @nobe4's comment, you could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; ) matchstr(getline('.'), '\%' . col('.') . 'c.')==')'? '&amp;lt;Right&amp;gt;': ')'&#xA;inoremap &amp;lt;expr&amp;gt; ] matchstr(getline('.'), '\%' . col('.') . 'c.')==']'? '&amp;lt;Right&amp;gt;': ']'&#xA;inoremap &amp;lt;expr&amp;gt; } matchstr(getline('.'), '\%' . col('.') . 'c.')=='}'? '&amp;lt;Right&amp;gt;': '}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;: allows us to do a conditional mapping &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;matchstr(...)&lt;/code&gt;: finds the character under the cursor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It will either insert the needed parin/bracket/brace, or pass over the one that's already there.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-06-08T21:00:51.447" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8150" PostTypeId="2" ParentId="8147" CreationDate="2016-06-08T21:46:48.990" Score="2" Body="&lt;p&gt;Plugins like KeepCase already defines commands to substitute things keeping the case. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, unlike what you have specified, in &lt;code&gt;foo_foingFoo&lt;/code&gt;, &lt;code&gt;:SubstituteCase/\cfoo/Bar/g&lt;/code&gt; will transform the word into &lt;code&gt;bar_baringBar&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-06-08T21:46:48.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8151" PostTypeId="1" AcceptedAnswerId="8152" CreationDate="2016-06-08T22:16:46.560" Score="2" ViewCount="593" Body="&lt;p&gt;Inspired by a &lt;a href=&quot;https://stackoverflow.com/questions/21937545/use-search-in-browse-oldfiles-list&quot;&gt;nice solution&lt;/a&gt; on a Stack Overflow, the following was put in my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Bro :vnew +setl\ buftype=nofile | 0put =v:oldfiles &#xA;  \| nnoremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; :e &amp;lt;C-r&amp;gt;=getline('.')&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are two problems with it I'd like to fix:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I want to view the list from the top (most recent) rather than the bottom, as is currently the case. I've tried adding &lt;code&gt;1G&lt;/code&gt; to the script, but to no avail.&lt;/li&gt;&#xA;&lt;li&gt;I would rather the list be open in the current window, so I don't have to come back to close it later. Using &lt;code&gt;enew&lt;/code&gt; instead of &lt;code&gt;vnew&lt;/code&gt; produces an E488 error, and &lt;code&gt;e&lt;/code&gt; puts the list of files in current file.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update.&lt;/strong&gt; Since the purpose of this exercise is to make the file list searchable, it's probably a good idea to append &lt;code&gt;:noh&amp;lt;CR&amp;gt;&lt;/code&gt; to the &lt;code&gt;nnoremap&lt;/code&gt; so that once you've searched, found your file, and opened it by pressing &lt;kbd&gt;Enter&lt;/kbd&gt;, search terms are not highlighted in the file.&lt;/p&gt;&#xA;" OwnerUserId="7810" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-06-08T23:48:19.730" Title="Better &quot;bro ol&quot;" Tags="|user-commands|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8152" PostTypeId="2" ParentId="8151" CreationDate="2016-06-08T22:32:54.737" Score="7" Body="&lt;p&gt;This should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Bro :enew | setl buftype=nofile |  0put =v:oldfiles&#xA;  \| nnoremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; gf | 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Aenew&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:enew&lt;/code&gt;&lt;/a&gt; doesn't support &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%5B%2Bcmd%5D&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;+cmd&lt;/code&gt;&lt;/a&gt;, unlike &lt;code&gt;:vnew&lt;/code&gt;, so just split the &lt;code&gt;:setl&lt;/code&gt; out to a new, chained, command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I changed the mapping to use &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#gf&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;gf&lt;/code&gt;&lt;/a&gt;, which IMHO, is more native. The last command, &lt;code&gt;1&lt;/code&gt;, should move the cursor to the first line. Unlike the &lt;code&gt;:e … getline()&lt;/code&gt; version, &lt;code&gt;gf&lt;/code&gt; will fail if the file doesn't exist - the help in fact suggests using that if you always want to edit a new file if it doesn't exit and suggests a simpler variant:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;To make gf always work like that: &#xA;        :map gf :e &amp;lt;cfile&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you could also do &lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; :e &amp;lt;cfile&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;. But I suppose this isn't really a problem - files in the history are more likely to exist than not. :)&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-06-08T23:23:46.210" LastActivityDate="2016-06-08T23:23:46.210" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8155" PostTypeId="1" CreationDate="2016-06-09T12:04:11.480" Score="2" ViewCount="314" Body="&lt;p&gt;I know that there can be a delay when inserting a new line with &lt;code&gt;O&lt;/code&gt; after pressing &lt;code&gt;Esc&lt;/code&gt;. However, I am experiencing that delay with &lt;code&gt;o&lt;/code&gt; and &lt;code&gt;i&amp;lt;CR&amp;gt;&lt;/code&gt; as well. This should not be related to &lt;code&gt;vim&lt;/code&gt; 'waiting' as in the &lt;code&gt;O&lt;/code&gt; case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This occurs when inserting new lines towards the end of a 90-line Python file; it does not occur when editing other Python files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've isolated the problem to this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2932" LastEditorUserId="2932" LastEditDate="2016-06-09T12:32:30.913" LastActivityDate="2016-06-09T12:32:30.913" Title="Delay when inserting new lines" Tags="|insert-mode|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="8157" PostTypeId="1" CreationDate="2016-06-09T14:37:56.413" Score="1" ViewCount="128" Body="&lt;p&gt;I tried to use the &quot;scroll-smooth&quot; tip given in &lt;code&gt;:h tips&lt;/code&gt; (see &lt;code&gt;:h scroll-smooth&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to change &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; by a series of &lt;code&gt;&amp;lt;C-Y&amp;gt;&lt;/code&gt;'s (and the same for &lt;code&gt;&amp;lt;C-D&amp;gt;&lt;/code&gt; with &lt;code&gt;&amp;lt;C-E&amp;gt;&lt;/code&gt;'s) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-U&amp;gt; &amp;lt;C-Y&amp;gt;&amp;lt;C-Y&amp;gt;&amp;lt;C-Y&amp;gt;&amp;lt;C-Y&amp;gt;&amp;lt;C-Y&amp;gt;&amp;lt;C-Y&amp;gt;&amp;lt;C-Y&amp;gt;&amp;lt;C-Y&amp;gt;&amp;lt;C-Y&amp;gt;&amp;lt;C-Y&amp;gt;&amp;lt;C-Y&amp;gt;&amp;lt;C-Y&amp;gt;&#xA;map &amp;lt;C-D&amp;gt; &amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However it works &lt;strong&gt;only when I split to another window&lt;/strong&gt; inside my running VIM, as if creating a buffer was necessary. The smooth scrolling works only in the second window, not the first one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I open another tab (&lt;code&gt;:tabf myfile&lt;/code&gt;), the mapping fails again ; if I split this second tab using &lt;code&gt;:vs&lt;/code&gt;, the mapping works... again only in the second window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to check &lt;code&gt;:map &amp;lt;C-U&amp;gt;&lt;/code&gt; as advised in &lt;a href=&quot;https://vi.stackexchange.com/questions/7722/how-to-debug-a-mapping&quot;&gt;this post&lt;/a&gt;, but it gives a satisfying result :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-D&amp;gt; &amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to be clearer, when I say that it does not work, I mean that the screen is moved N lines down or up, but &lt;em&gt;not&lt;/em&gt; with the expected &quot;smoothing&quot; effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Nobe4, I tried  with &lt;code&gt;vim -Nu NONE&lt;/code&gt;, issuing command &lt;code&gt;map &amp;lt;C-D&amp;gt; &amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&amp;lt;C-E&amp;gt;&lt;/code&gt;. Again, when pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;D&lt;/kbd&gt;, the screen is moved a few lines down but without the smoothing effect.&lt;/p&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-06-09T17:04:49.243" Title="&quot;scroll-smooth&quot; remapping works only in second buffer" Tags="|vimrc|scrolling|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8158" PostTypeId="1" CreationDate="2016-06-09T17:11:27.083" Score="6" ViewCount="8616" Body="&lt;p&gt;Is there any way to copy / paste blocks of text when &lt;code&gt;v&lt;/code&gt; is not implemented?`&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="51" LastEditDate="2016-06-10T01:50:24.093" LastActivityDate="2020-06-07T09:49:11.310" Title="Copying lines when v is not implemented?" Tags="|visual-mode|busybox-vi|" AnswerCount="5" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="8159" PostTypeId="2" ParentId="8158" CreationDate="2016-06-09T17:37:43.443" Score="2" Body="&lt;p&gt;Visual mode is not available in original vi. However, you should still be able to use a numbered yank or marks.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In normal mode press &lt;code&gt;#y&lt;/code&gt; to yank a block of code (where &lt;code&gt;#&lt;/code&gt; is the number of lines you want to yank starting &lt;em&gt;after&lt;/em&gt; the cursor's current line). Then you can just use &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;P&lt;/code&gt; to paste it.&lt;/li&gt;&#xA;&lt;li&gt;In normal mode press &lt;code&gt;ma&lt;/code&gt;. This will mark your current position in the file. Then move your cursor to the other end of the section of text you want to yank. Press &lt;code&gt;y'a&lt;/code&gt;. This will yank everything between your cursor and the mark &quot;a&quot;. Then you can use &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;P&lt;/code&gt; just like before. Note: You can replace the &quot;a&quot; with any alphabetic character.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Se &lt;code&gt;:h y&lt;/code&gt; and &lt;code&gt;:h m&lt;/code&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-06-09T18:10:54.200" LastActivityDate="2016-06-09T18:10:54.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8160" PostTypeId="1" AcceptedAnswerId="8161" CreationDate="2016-06-09T18:38:56.090" Score="2" ViewCount="1825" Body="&lt;p&gt;I have the following within my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; toggle comments&#xA;noremap &amp;lt;C-m&amp;gt; :&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;exe &quot;&amp;lt;Right&amp;gt;&amp;lt;Right&amp;gt;&amp;lt;Right&amp;gt;&amp;lt;C-Right&amp;gt;&amp;lt;Right&amp;gt;normal! I&quot;.g:commentType&amp;lt;CR&amp;gt;&#xA;autocmd BufReadPost *.php let g:commentType='//'      &quot;Perl files&#xA;autocmd BufReadPost *.styl let g:commentType='//' &quot;C files&#xA;autocmd BufReadPost *.js let g:commentType='//' &quot;C files&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want it so if I do 'ctrl+m' on a line that is already commented, it'll uncomment it, and if the line doesn't have comments, it'll add it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;blah blah text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// blah blah text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and if I do it again&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// blah blah text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;blah blah text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How may i do this?&lt;/p&gt;&#xA;" OwnerUserId="7911" LastActivityDate="2016-06-09T19:41:37.150" Title="Toggling comments on and off" Tags="|comments|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8161" PostTypeId="2" ParentId="8160" CreationDate="2016-06-09T19:17:27.443" Score="9" Body="&lt;p&gt;if you're willing to use a plugin, there are many commenting plugins out there. Some of the most popular examples are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;noreferrer&quot;&gt;tpope/vim-commentary&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/tomtom/tcomment_vim&quot; rel=&quot;noreferrer&quot;&gt;tomtom/tcomment_vim&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;noreferrer&quot;&gt;scrooloose/nerdcommenter&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All of these have mappings for toggling comments. You can remap &lt;code&gt;&amp;lt;C-m&amp;gt;&lt;/code&gt; to this command. For example, if you go with tpope/commentary, you could do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-m&amp;gt; gcc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which toggles a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to install a plugin, you'll need to write a vimscript that detects if a line starts with a comment, and then adds or removes it accordingly. This is definitely possible, but I don't know how to do it myself, so I'll let someone else answer that if they want to.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-06-09T19:41:37.150" LastActivityDate="2016-06-09T19:41:37.150" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8162" PostTypeId="2" ParentId="8158" CreationDate="2016-06-09T19:46:39.053" Score="4" Body="&lt;p&gt;In case one uses number mode (enabled with &lt;code&gt;:set nu&lt;/code&gt;) and both source and destination of the copy action are visible one can use a &lt;code&gt;ex&lt;/code&gt; command:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;t&amp;lt;dest_line&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;e.g:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5,9t17&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;copies lines 5-9 to line 17.&lt;/p&gt;&#xA;" OwnerUserId="7892" LastEditorUserId="51" LastEditDate="2016-06-10T01:49:36.513" LastActivityDate="2016-06-10T01:49:36.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8163" PostTypeId="1" CreationDate="2016-06-09T20:26:42.313" Score="2" ViewCount="450" Body="&lt;p&gt;Coming from Sublime, I find the following behaviour frustrating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MdGyd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MdGyd.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I select some text, the first (or last depending upon which way you select) character flashes between the text color and your background color (in my case, black). So it gives the impression that only the '4' characters are selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway to change the background color of your current cursor position when text is highlighted, so I can blend it into the selection when it flashes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using gnome terminal, on ubuntu.&lt;/p&gt;&#xA;" OwnerUserId="7911" LastActivityDate="2016-06-09T20:26:42.313" Title="Changing background color of cursor during selection" Tags="|syntax-highlighting|terminal|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8164" PostTypeId="1" CreationDate="2016-06-09T20:57:24.027" Score="4" ViewCount="1399" Body="&lt;p&gt;How can I include the contents of a register when recording a macro? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;R&lt;/kbd&gt; &lt;kbd&gt;x&lt;/kbd&gt; I get a &quot;pointer&quot; to register &lt;code&gt;x&lt;/code&gt;, i.e., my macro will contain &lt;code&gt;^Rx&lt;/code&gt; instead of the register contents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Motivation:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often I need to record a macro which involves a substitution using a complex regex:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;create the regex with the aid of incremental search (&lt;code&gt;'incsearch'&lt;/code&gt;), and using highlight search results (&lt;code&gt;'hlsearch'&lt;/code&gt;) to ensure that I'm matching the correct text&lt;/li&gt;&#xA;&lt;li&gt;create the substitution command with &lt;code&gt;s/&amp;lt;c-r&amp;gt;//&amp;lt;replacement&amp;gt;&lt;/code&gt;, so I end up with &lt;code&gt;s/&amp;lt;complete regex&amp;gt;/&amp;lt;replacement&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;start recording a macro, do some stuff, repeat the substitution with &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;up&lt;/kbd&gt;&lt;kbd&gt;ENTER&lt;/kbd&gt; (or &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;or &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;ENTER&lt;/kbd&gt;), add the end steps and stop recording the macro.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The problem with this approach is that the macro stops working as soon as I use another ex command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could copy the &lt;code&gt;:&lt;/code&gt; to another register and use it on the macro, but then it is necessary to keep avoiding to overwrite that register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I'm copying the substitution command on a split window an re-typing it, but certainly there must be a less cumbersome solution. &lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-06-09T21:10:22.850" LastActivityDate="2016-06-09T22:05:40.260" Title="insert register contents on a macro" Tags="|command-line|macro|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8165" PostTypeId="2" ParentId="8164" CreationDate="2016-06-09T21:15:36.640" Score="4" Body="&lt;p&gt;&lt;strong&gt;Edit: Better answer -&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After you search you can do a &lt;code&gt;:let @z = @/&lt;/code&gt;. This will copy your complex regex into register &lt;code&gt;z&lt;/code&gt;. You can now freely use &lt;code&gt;&amp;lt;C-r&amp;gt;z&lt;/code&gt; in your macro without having to retype the regex into your document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also realize that you said you didn't want to have worry about overwriting a register. Fun fact: the registers you use for macros are actually the &lt;em&gt;same&lt;/em&gt; registers that you can yank to. So you &lt;em&gt;could&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Record your macro, say to register &lt;code&gt;q&lt;/code&gt;, using &lt;code&gt;&amp;lt;C-r&amp;gt;/&lt;/code&gt; to input your search pattern&lt;/li&gt;&#xA;&lt;li&gt;Do &lt;code&gt;&quot;qp&lt;/code&gt; to see your macro written out&lt;/li&gt;&#xA;&lt;li&gt;Delete the resulting &lt;code&gt;^R/&lt;/code&gt; and replace it with the actual text from your search pattern. (Again using &lt;code&gt;&amp;lt;C-r&amp;gt;/&lt;/code&gt; to avoid typing it.)&lt;/li&gt;&#xA;&lt;li&gt;Do a &lt;code&gt;&quot;qdd&lt;/code&gt; to then copy the &lt;em&gt;new&lt;/em&gt; macro back to register &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;@q&lt;/code&gt; as needed&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now at least you're only using one register to store the macro, and you don't have to actually reference any other ones.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt; Old answer: &lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Is there anything wrong with writing out &lt;code&gt;&amp;lt;complexregex&amp;gt;&lt;/code&gt;, yanking it to a register that you don't use very often (Let's say &lt;code&gt;z&lt;/code&gt;), and then using &lt;code&gt;&amp;lt;C-r&amp;gt;z&lt;/code&gt; in your macro?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Workflow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Type out regex&lt;/li&gt;&#xA;&lt;li&gt;Visually select&lt;/li&gt;&#xA;&lt;li&gt;Delete to register z: &lt;code&gt;&quot;zd&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Record macro, something like: &lt;code&gt;qq:s/&amp;lt;C-r&amp;gt;z/foo/^Mq&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use macro as needed: &lt;code&gt;@q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-06-09T21:54:50.613" LastActivityDate="2016-06-09T21:54:50.613" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8167" PostTypeId="1" AcceptedAnswerId="8168" CreationDate="2016-06-10T00:03:58.203" Score="0" ViewCount="551" Body="&lt;p&gt;I have been changing &quot;$OLD&quot; to &quot;~/new&quot; in a lot of files lately, so I am now used to starting vim like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum $OLD&#xA;Lorem .OLD ipsum&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;%&lt;/kbd&gt;&lt;kbd&gt;up&lt;/kbd&gt; (brings back &lt;code&gt;%s:\$OLD:\~/new:gc&lt;/code&gt;)&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I added a new autocommand in ~/.vimrc, like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;autocmd&quot;)&#xA;  au BufEnter %s:\$OLD:\~/new:gc&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  au BufEnter :%s:\$OLD:\~/new:gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And next time I tried vim, it wasn't as impressed as I was hoping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Auto-Commands ---&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum $OLD&#xA;Lorem .OLD ipsum&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is vim just telling me about the commands, instead of running them?&lt;/p&gt;&#xA;" OwnerUserId="182" LastEditorUserId="182" LastEditDate="2016-06-10T00:24:13.523" LastActivityDate="2016-06-10T12:21:59.013" Title="Why does vim tell me that I added an autocommand?" Tags="|autocmd|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8168" PostTypeId="2" ParentId="8167" CreationDate="2016-06-10T01:08:04.607" Score="4" Body="&lt;p&gt;You didn't provide a pattern to &lt;code&gt;au&lt;/code&gt;. Note &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#%3Aau&quot; rel=&quot;nofollow&quot;&gt;the syntax&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au[tocmd] [group] {event} {pat} [nested] {cmd}&#xA;                        Add {cmd} to the list of commands that Vim will&#xA;                        execute automatically on {event} for a file matching&#xA;                        {pat} autocmd-patterns.&#xA;&#xA;:au[tocmd] [group] {event} {pat}&#xA;                        Show the autocommands associated with {event} and&#xA;                        {pat}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first adds an autocommand, and the second lists autocommands. That's why you got that output.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-06-10T01:08:04.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8169" PostTypeId="1" CreationDate="2016-06-10T02:04:26.687" Score="12" ViewCount="1073" Body="&lt;p&gt;Often times I edit a file - think my work is done - then close the file and move on to the next thing. But then I realise I need to go back to that code and tweak it a bit more.&lt;br&gt;&#xA;If I open the file again, I can  use the &lt;code&gt;.&lt;/code&gt; mark and jump to the position of the last edit with &lt;code&gt;'.&lt;/code&gt;.&lt;br&gt;&#xA;Now I'm trying to find a way to use vim's marks to jump to locations in files I have recently visited, but not changed.&lt;br&gt;&#xA;I know I can set a mark manually, but most of the time, I don't expect to come back and so I don't set a mark and need to use a mark that vim generates automatically.&lt;br&gt;&#xA;The &lt;code&gt;&quot;&lt;/code&gt; mark seems like this could be a way to achieve this, from &lt;code&gt;:h motion&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;&quot;&lt;/code&gt;           To the cursor position when last exiting the current&#xA;              buffer.  Defaults to the first character of the first&#xA;              line.  See |last-position-jump| for how to use this&#xA;              for each opened file.&#xA;              Only one position is remembered per buffer, not one&#xA;              for each window.  As long as the buffer is visible in&#xA;              a window the position won't be changed.&#xA;              {not in Vi}.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However  if I&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;close all windows showing a buffer (but the buffer is still present in the buffer list). or:&lt;/li&gt;&#xA;&lt;li&gt;kill all instances of the buffer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;the mark doesn't seem to update, how can I use a mark to jump to a location of the last cursor position in the buffer/file?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2018-03-16T12:25:23.897" Title="How can I use marks to jump to locations in files I have recently opened, but not changed?" Tags="|cursor-motions|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8170" PostTypeId="2" ParentId="8169" CreationDate="2016-06-10T03:44:59.767" Score="3" Body="&lt;p&gt;I wrote this vimscript statement which seems to work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufLeave * :normal ml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Explanation&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;BufLeave&lt;/code&gt; auto command: this seems to trigger when you&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;move to another window &lt;/li&gt;&#xA;&lt;li&gt;when you close the &lt;strong&gt;last&lt;/strong&gt; window displaying the buffer&lt;/li&gt;&#xA;&lt;li&gt;when you close the buffer itself with &lt;code&gt;bd&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:normal&lt;/code&gt; - it seems by default, the &lt;code&gt;command&lt;/code&gt; part of autocmd is an ex command. So to tell vim  to run  a normal mode command , you need to add &lt;code&gt;:normal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ml&lt;/code&gt; - set a mark &lt;code&gt;l&lt;/code&gt; (mnemonic: &lt;em&gt;last&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Usage&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;to recall the cursor position from the last time you were in the buffer simply hit&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2016-06-10T03:53:06.660" LastActivityDate="2016-06-10T03:53:06.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8171" PostTypeId="2" ParentId="8158" CreationDate="2016-06-10T05:22:22.237" Score="7" Body="&lt;p&gt;I downloaded Busybox out of curiosity, and can reproduce&#xA;the problems you're having with that version of vi.&#xA;I have version &lt;code&gt;1.25.0-FRP-441-g53c3b08 2016-05-24 12:20:38 BST&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A large number of vi commands seem to be unimplemented,&#xA;such as &lt;code&gt;:copy&lt;/code&gt;, &lt;code&gt;v&lt;/code&gt;, and &lt;code&gt;S&lt;/code&gt;. &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; don't seem to work&#xA;properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of yanking, the motions &lt;code&gt;}&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt; don't work,&#xA;nor does jumping to marks, e.g. &lt;code&gt;y'a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;f&lt;/code&gt; does work, e.g. &lt;code&gt;yfx&lt;/code&gt;. More usefully you can use e.g. &lt;code&gt;2yy&lt;/code&gt;&#xA;to yank a known number of lines. Even better, it looks&#xA;like you can set two marks with &lt;code&gt;m&lt;/code&gt; and then yank between them with&#xA;with the ex command &lt;code&gt;:'a,'by&lt;/code&gt; (yanking from a mark to the&#xA;cursor doesn't work).&lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-06-10T05:22:22.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8172" PostTypeId="2" ParentId="8169" CreationDate="2016-06-10T06:12:12.033" Score="6" Body="&lt;p&gt;Here is a classic solution: use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`H&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to jump to the last HTML file and so on…&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup VIMRC&#xA;  autocmd!&#xA;&#xA;  autocmd BufLeave *.css  normal! mC&#xA;  autocmd BufLeave *.html normal! mH&#xA;  autocmd BufLeave *.js   normal! mJ&#xA;  autocmd BufLeave *.php  normal! mP&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-06-10T06:12:12.033" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8173" PostTypeId="1" AcceptedAnswerId="8174" CreationDate="2016-06-10T11:34:35.647" Score="2" ViewCount="126" Body="&lt;p&gt;I like to wrap my text to 80 characters all the time, even when I am editing Markdown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a problem when I open parentheses: it doesn't wrap right anymore. Since it is hard for me to explain it, and because a picture is worth a thousand words, here is a screeshot of what is happening:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XbIVB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XbIVB.png&quot; alt=&quot;screenshot of the problem&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone knows how to solve this, this would save my life.&lt;/p&gt;&#xA;" OwnerUserId="7945" LastActivityDate="2016-06-10T11:47:30.593" Title="automatic text wrapping messed up with parenthesis" Tags="|indentation|wrapping|filetype-markdown|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8174" PostTypeId="2" ParentId="8173" CreationDate="2016-06-10T11:40:19.537" Score="2" Body="&lt;p&gt;&lt;code&gt;set nocindent&lt;/code&gt; will do the trick. To have that persistent put it in a ftplugin: &lt;code&gt;~/.vim/ftplugin/markdown.vim&lt;/code&gt; e.g. (See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_41.html#ftplugin&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h ftplugin&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerDisplayName="user276" LastEditorUserId="1841" LastEditDate="2016-06-10T11:47:30.593" LastActivityDate="2016-06-10T11:47:30.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8175" PostTypeId="2" ParentId="8167" CreationDate="2016-06-10T12:09:11.210" Score="4" Body="&lt;p&gt;You should change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufEnter %s:\$OLD:\~/new:gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufEnter * %s:\$OLD:\~/new:gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or something else.&lt;/p&gt;&#xA;" OwnerUserId="7942" LastEditorUserId="1841" LastEditDate="2016-06-10T12:21:59.013" LastActivityDate="2016-06-10T12:21:59.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8176" PostTypeId="2" ParentId="8134" CreationDate="2016-06-10T12:12:33.057" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Kkz37.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Kkz37.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For me, I use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_symbols.maxlinenr= ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7942" LastEditorUserId="205" LastEditDate="2016-06-10T17:39:24.627" LastActivityDate="2016-06-10T17:39:24.627" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8177" PostTypeId="1" CreationDate="2016-06-10T13:19:22.380" Score="2" ViewCount="573" Body="&lt;p&gt;I'm using rails.vim with the command &lt;code&gt;:AS&lt;/code&gt; which open the alternate file (like &lt;code&gt;test&lt;/code&gt;) and split the window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, it's always on the top and I would like to open it below the current window. I would like to know if it's possible to merge these two commands properly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm able to do it with &lt;code&gt;:execute 'AS' | wincmd J&lt;/code&gt; but is this the best way to to it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I be sure it goes just below? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And how do I add it to a leader key?&lt;/p&gt;&#xA;" OwnerUserId="3357" LastEditorUserId="2920" LastEditDate="2016-06-10T16:11:35.523" LastActivityDate="2016-06-10T16:11:35.523" Title="Remap plugin command with plugin command + vim shortcuts" Tags="|vim-windows|normal-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8178" PostTypeId="2" ParentId="8177" CreationDate="2016-06-10T14:09:27.337" Score="5" Body="&lt;p&gt;You can do this in different forms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the command you already created and bind this to a mapping (here with the leader key):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;as :execute 'AS' &amp;lt;bar&amp;gt; wincmd J&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can create a new command that acts the same way (B for below):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! ASB :execute 'AS' | wincmd J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But using &lt;code&gt;wincmd J&lt;/code&gt; is overwhelming, prefer the split commands :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:abo[veleft] {cmd}&#xA;:bel[owright] {cmd}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can have your mapping/command like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;as :bel AS&amp;lt;CR&amp;gt;&#xA;command! ASB :bel AS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that if you &lt;strong&gt;always&lt;/strong&gt; want to open a split below you can set the option in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set splitbelow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h abo&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h bel&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h command&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h &amp;lt;leader&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-10T14:29:22.637" LastActivityDate="2016-06-10T14:29:22.637" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8179" PostTypeId="1" AcceptedAnswerId="8180" CreationDate="2016-06-10T20:24:03.137" Score="26" ViewCount="16555" Body="&lt;p&gt;I'd like to replace 'x' in this file with current line number. That is, change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x&#xA;x&#xA;x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;2&#xA;3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For now, I use a Perl one-liner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;perl -pi -e '$x=$.; s/x/$x/' myfile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think UltraEdit can do it with a vertical select and replace. Can this be done in vim? (My example here assumes 'x' is all there is on one line. But the lines in my real file are much more complicated.)&lt;/p&gt;&#xA;" OwnerUserId="7953" LastEditorUserId="2920" LastEditDate="2016-06-10T20:34:40.893" LastActivityDate="2023-10-04T17:27:54.697" Title="Replace a pattern with current line number" Tags="|replace|line-numbers|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8180" PostTypeId="2" ParentId="8179" CreationDate="2016-06-10T20:38:19.147" Score="39" Body="&lt;p&gt;Yes, vim can do this! Do a global search for &lt;code&gt;x&lt;/code&gt;, and replace it with &lt;code&gt;\=printf(&quot;%d&quot;, line('.')&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/x/\=printf(&quot;%d&quot;, line('.'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also change &lt;code&gt;x&lt;/code&gt; to another search, if you need to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This replaces every occurence of &lt;code&gt;x&lt;/code&gt; (or whatever you search for) with the evaluation register &lt;code&gt;\=&lt;/code&gt;. This register evaluates vimscript code, and returns a string. In this case, the code being evaluated is &quot;Print the line we are on as a decimal number&quot;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-10T20:38:19.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8181" PostTypeId="5" CreationDate="2016-06-10T22:47:48.903" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-06-10T22:47:48.903" LastActivityDate="2016-06-10T22:47:48.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8182" PostTypeId="4" CreationDate="2016-06-10T22:47:48.903" Score="0" Body="Vim's package system" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-06-10T22:47:48.903" LastActivityDate="2016-06-10T22:47:48.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8183" PostTypeId="1" CreationDate="2016-06-11T00:42:31.750" Score="1" ViewCount="201" Body="&lt;p&gt;In order to automatically trigger a mark holding the last cursor position when I left a buffer or window, I added these statements to my &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;br&gt;&#xA;&lt;sub&gt;for more background on why I wanted to add these commands please refer to &lt;a href=&quot;https://vi.stackexchange.com/questions/8169/how-can-i-use-marks-to-jump-to-locations-in-files-i-have-recently-opened-but-no&quot;&gt;this vi.stackexchange question&lt;/a&gt;&lt;/sub&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufLeave * :normal mB&#xA;autocmd WinLeave * :normal mW&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The statements are causing errors when moving out of, or closing buffers created by &lt;code&gt;NERDTree&lt;/code&gt; or &lt;code&gt;netrw&lt;/code&gt;. e.g. when closing a &lt;code&gt;netrw&lt;/code&gt; buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;85_NetrwBookHistHandler:&#xA;line  154:&#xA;E121: Undefined variable: g:netrw_bookmarklist&#xA;E15: Invalid expression: g:netrw_bookmarklist[iremove - 1]&#xA;line  158:&#xA;E121: Undefined variable: g:netrw_bookmarklist&#xA;E116: Invalid arguments for function remove&#xA;line  159:&#xA;E121: Undefined variable: dremove&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also NERDTree is sometimes making addiditonal copies of directories, so when I run &lt;code&gt;git status&lt;/code&gt;, git is showing new  directories.&lt;br&gt;&#xA;I suspect the cause of the error is the fact that NERDTree and netrw are creating new mappings, so that the command &lt;code&gt;:normal mB&lt;/code&gt; when executed in a  NERDTree buffer is triggering something like &lt;code&gt;m&lt;/code&gt;,&lt;code&gt;l&lt;/code&gt; -which in NERDTree mappings means &quot;modify&quot; and &quot;list&quot; rather than set a new mark.&lt;br&gt;&#xA;Does this reasoning sound right?&lt;br&gt;&#xA;If so how could I detect when focus is in a NERDTree or netrw buffer, so the mappings can be turned off. Otherwise what could the cause to this problem? &lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-06-11T12:11:47.777" Title="autocmd mark statements causing problems with nerd tree and netrw?" Tags="|netrw|plugin-nerdtree|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8184" PostTypeId="1" AcceptedAnswerId="8186" CreationDate="2016-06-11T02:12:18.703" Score="2" ViewCount="100" Body="&lt;p&gt;When navigating within a line, I find myself navigating one character or word at a time, which I feel it one of my greatest inefficiencies.  Navigating to a particular line is easy, because we have line numbers displayed on the screen.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to display column numbers so that I could navigate similarly within a line?  Are there any other good techniques for quickly and accurately navigating within a line?&lt;/p&gt;&#xA;" OwnerUserId="7956" LastActivityDate="2016-06-11T03:35:26.677" Title="For column navigation, is there a nice to display column numbers the way we typically display line numbers?" Tags="|cursor-motions|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8185" PostTypeId="2" ParentId="8179" CreationDate="2016-06-11T02:53:56.847" Score="18" Body="&lt;p&gt;Since you mentioned vertical select and replace, you can do that too. Use &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; to do select the lock of text you want to replace, then  &lt;code&gt;c&lt;/code&gt; and type 0, to replace that with 0s. Then, select those 0s:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KCF9W.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KCF9W.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then press &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#v_g_CTRL-A&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;g&amp;lt;c-a&amp;gt;&lt;/code&gt;&lt;/a&gt; (&lt;kbd&gt;g&lt;/kbd&gt;+&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6KPPl.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6KPPl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you had replaced a single column, then you can use &lt;code&gt;gv&lt;/code&gt; to quickly reselect the same area.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-06-11T02:53:56.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8186" PostTypeId="2" ParentId="8184" CreationDate="2016-06-11T03:35:26.677" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a way to display column numbers so that I could navigate similarly within a line?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not really.  If you are looking for column precision, there is the &lt;code&gt;|&lt;/code&gt; motion.  &lt;code&gt;50|&lt;/code&gt; will jump to the 50th column (one column being a character).  I don't see this being that helpful unless you're writing a script or dealing with a well known text format.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are there any other good techniques for quickly and accurately navigating within a line?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes!  You can find them in &lt;code&gt;:help motion.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Within the current line:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;e&lt;/code&gt; or &lt;code&gt;b&lt;/code&gt; - You're already familiar with these and their friends.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; - Move to the first character on the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; - Move to the first column on the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt; - Move to the last column of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g_&lt;/code&gt; - Move to the last character on the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f&lt;/code&gt; and &lt;code&gt;F&lt;/code&gt; - Forward and backward, respectively.  Press one of these, then the character you want to jump to.  e.g. &lt;code&gt;fb&lt;/code&gt; will jump to the next &lt;code&gt;b&lt;/code&gt; in the line.  If you press &lt;code&gt;;&lt;/code&gt;, you'll jump to the next one.  Pressing &lt;code&gt;,&lt;/code&gt; will go in the opposite direction.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;t&lt;/code&gt; and &lt;code&gt;T&lt;/code&gt; - The same as above, but the cursor will land just before the character.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It might not seem ideal at first, but if you know you need to get to the last &lt;code&gt;b&lt;/code&gt; in the line, you can press &lt;code&gt;$Fb&lt;/code&gt; to get to it instead of pressing &lt;code&gt;fb&lt;/code&gt; and mashing &lt;code&gt;;&lt;/code&gt; a few times.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Move by searching:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You are looking at where you need to move your cursor, so searching is a valid way to get there.  &lt;code&gt;/abc&lt;/code&gt; will jump to the first occurrence of &lt;code&gt;abc&lt;/code&gt;.  Pressing &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;N&lt;/code&gt; will move your cursor between all the matches.  &lt;code&gt;gn&lt;/code&gt; and &lt;code&gt;gN&lt;/code&gt; will move the cursor and select the match in visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, searching will move beyond the current line, which is not within the current line like you mentioned.  To stay within the line, you can select it with &lt;kbd&gt;shift-v&lt;/kbd&gt; and search with &lt;code&gt;/\%Vabc&lt;/code&gt;.  &lt;code&gt;\%V&lt;/code&gt; causes the search to only happen within the visual selection.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Plugins:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/easymotion/vim-easymotion&quot;&gt;easymotion&lt;/a&gt; - This gives you shortcuts based on the kind of text jump you want.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/justinmk/vim-sneak&quot;&gt;vim-sneak&lt;/a&gt; - Similar to easymotion, but is more like &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt; mentioned above combined with searching. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-11T03:35:26.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8187" PostTypeId="1" AcceptedAnswerId="8304" CreationDate="2016-06-11T07:03:58.060" Score="2" ViewCount="133" Body="&lt;p&gt;Here is are the startup errors when I run vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i  &amp;lt;Up&amp;gt;        * &amp;lt;Esc&amp;gt;&amp;lt;Up&amp;gt;&#xA;i  &amp;lt;Down&amp;gt;      * &amp;lt;Esc&amp;gt;&amp;lt;Down&amp;gt;&#xA;i  &amp;lt;Left&amp;gt;      * &amp;lt;Esc&amp;gt;&amp;lt;Left&amp;gt;&#xA;i  &amp;lt;Right&amp;gt;     * &amp;lt;Esc&amp;gt;&amp;lt;Right&amp;gt;&#xA;i  &amp;lt;Home&amp;gt;      * &amp;lt;Esc&amp;gt;y&#xA;i  &amp;lt;End&amp;gt;       * &amp;lt;Esc&amp;gt;l&#xA;i  &amp;lt;PageUp&amp;gt;    * &amp;lt;Esc&amp;gt;&amp;lt;PageUp&amp;gt;&#xA;i  &amp;lt;PageDown&amp;gt;  * &amp;lt;Esc&amp;gt;&amp;lt;PageDown&amp;gt;&#xA;i  &amp;lt;kEnter&amp;gt;    * &amp;lt;Esc&amp;gt;o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which result from these mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;kEnter&amp;gt; &amp;lt;Esc&amp;gt;o &#xA;inoremap &amp;lt;PageDown&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;PageDown&amp;gt; &#xA;inoremap &amp;lt;PageUp&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;PageUp&amp;gt; &#xA;inoremap &amp;lt;End&amp;gt; &amp;lt;Esc&amp;gt;l &#xA;inoremap &amp;lt;Home&amp;gt; &amp;lt;Esc&amp;gt;y &#xA;inoremap &amp;lt;Right&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;Right&amp;gt; &#xA;inoremap &amp;lt;Left&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;Left&amp;gt; &#xA;inoremap &amp;lt;Down&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;Down&amp;gt; &#xA;inoremap &amp;lt;Up&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;Up&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't figure out what this is trying to tell me, because these bindings appear to work for me.&lt;/p&gt;&#xA;" OwnerUserId="7960" LastEditorUserId="54" LastEditDate="2016-06-11T07:44:49.380" LastActivityDate="2016-06-18T12:34:22.000" Title="Why is vim giving me an &quot;i &lt;Up&gt; * &lt;Esc&gt;&lt;Up&gt;&quot; startup error with the mapping &quot;inoremap &lt;Up&gt; &lt;Esc&gt;&lt;Up&gt;&quot;?" Tags="|vimrc|error|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8188" PostTypeId="1" CreationDate="2016-06-11T07:46:51.527" Score="1" ViewCount="462" Body="&lt;p&gt;I'm using MacVim, and I want to write codes for R in MacVim.&lt;br&gt;&#xA;I want to have a hotkey which can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Send a line where the cursor is in MacVim to RStudio, execute the code in RStudio, and back a cursor to MacVim (line by line execution)&lt;/li&gt;&#xA;&lt;li&gt;If Visual Mode is used in MacVim, copy the chunk selected in MacVim and send it to RStudio (copy lines and paste on RStudio), execute the lines and back a cursor to MacVim (chunk execution)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is it possible to realize this hotkey using what is prepared in Vim?&lt;/p&gt;&#xA;" OwnerUserId="6897" LastEditorUserId="6897" LastEditDate="2016-06-11T08:32:42.403" LastActivityDate="2016-06-11T17:35:10.850" Title="Integrate MacVim and RStudio" Tags="|vimrc|macvim|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="8189" PostTypeId="1" AcceptedAnswerId="8190" CreationDate="2016-06-11T09:04:03.347" Score="1" ViewCount="185" Body="&lt;p&gt;I want to add a motion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:onoremap &amp;lt;silent&amp;gt; f( :&amp;lt;C-U&amp;gt;normal! f)vF(b&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I have this line, where the asterisk is my current position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int a = fo*o(4, 5, 99);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to type &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;(&lt;/kbd&gt; and select &lt;code&gt;foo(4, 5, 99)&lt;/code&gt;. Later on I want to add the equivalents for &lt;code&gt;[&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt;, and &lt;code&gt;&amp;lt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the above sadly doesn't work. This is an altered version of something I found under &lt;code&gt;:help omap-info&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Actually, it work with &lt;kbd&gt;c&lt;/kbd&gt; and &lt;kbd&gt;d&lt;/kbd&gt;, but not with &lt;kbd&gt;v&lt;/kbd&gt;. Why is that?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="6300" LastEditDate="2016-06-11T09:23:59.487" LastActivityDate="2016-06-11T16:25:41.540" Title="Motion remap to select function doesn't work with v" Tags="|vimscript|cursor-motions|normal-mode|cursor|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8190" PostTypeId="2" ParentId="8189" CreationDate="2016-06-11T09:43:06.853" Score="2" Body="&lt;p&gt;&lt;code&gt;Operator pending mode&lt;/code&gt; has to be used only when waiting for a motion. You have used &lt;code&gt;f&lt;/code&gt;, which waits for a character and moves there. Since you have given both &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;(&lt;/code&gt; together, &lt;code&gt;f&lt;/code&gt; has got a character to find and move to. Hence, there isn't any operator 'pending'! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you can map in normal mode itself, like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :noremap &amp;lt;silent&amp;gt; f( :&amp;lt;C-U&amp;gt;normal! f)vF(b&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(This works in my vim.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, you can use a simple mapping like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :nmap \sf bvf(f)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(s - select, f - function)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; You can put &lt;code&gt;[&lt;/code&gt;,&lt;code&gt;{&lt;/code&gt;,&lt;code&gt;&amp;lt;&lt;/code&gt;  instead of &lt;code&gt;(&lt;/code&gt; in the above mappings to use with &lt;code&gt;[&lt;/code&gt;,&lt;code&gt;{&lt;/code&gt;,&lt;code&gt;&amp;lt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create your own text objects as well as use plugins like easy motions for that.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastActivityDate="2016-06-11T09:43:06.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8191" PostTypeId="2" ParentId="8183" CreationDate="2016-06-11T12:11:47.777" Score="1" Body="&lt;p&gt;per user9433424 comments this is working so far without issues.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufLeave * :normal! mb &#xA;autocmd WinLeave * :normal! mw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm guessing using this command may mean the original functions netrw and NERDTree assigned to the &lt;code&gt;mb&lt;/code&gt; and &lt;code&gt;mw&lt;/code&gt; maps may be lost, but for me, I wasn't using them anyway. &lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2016-06-11T12:11:47.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8192" PostTypeId="2" ParentId="8189" CreationDate="2016-06-11T13:49:24.473" Score="3" Body="&lt;p&gt;You (also) need to address the &lt;code&gt;visual&lt;/code&gt; mode map (&lt;code&gt;onoremap&lt;/code&gt; doesn't do that):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:xnoremap &amp;lt;silent&amp;gt; f( :&amp;lt;C-U&amp;gt;normal! f)vF(b&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;a href=&quot;http://vim.wikia.com/wiki/Creating_new_text_objects&quot; rel=&quot;nofollow&quot;&gt;http://vim.wikia.com/wiki/Creating_new_text_objects&lt;/a&gt;&lt;br&gt;&#xA;(where the &lt;code&gt;omap&lt;/code&gt; is made based on the &lt;code&gt;vnoremap&lt;/code&gt;). &lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-06-11T13:49:24.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8193" PostTypeId="2" ParentId="8189" CreationDate="2016-06-11T14:29:50.000" Score="2" Body="&lt;p&gt;&lt;code&gt;:onoremap &amp;lt;silent&amp;gt; f( :&amp;lt;C-U&amp;gt;normal! f)vF(b&amp;lt;CR&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;works well for&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;int a = foo(4, 5, 99);&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;but if you are using &lt;code&gt;fo*o&lt;/code&gt; you need you &lt;code&gt;b&lt;/code&gt; three times&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, you can use &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:onoremap &amp;lt;silent&amp;gt; f( :&amp;lt;C-U&amp;gt;normal! f)vF(F l&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2016-06-11T14:29:50.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8194" PostTypeId="2" ParentId="8189" CreationDate="2016-06-11T16:25:41.540" Score="1" Body="&lt;p&gt;I accomplished what I wanted to do initially and it works quite nicely.&#xA;I didn't use &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt; and etc. because I made it behave similiar to &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow&quot;&gt;tpope's vim-surround&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:StatementOperator(opennext, closenext)&#xA;    let current_col = col(&quot;.&quot;)&#xA;    execute 'normal! m&quot;f' . a:closenext&#xA;    let last_col = col(&quot;.&quot;)&#xA;    execute 'normal! vF' . a:opennext . 'b'&#xA;    let first_col = col(&quot;.&quot;)&#xA;&#xA;    if first_col &amp;gt; current_col || current_col &amp;gt; last_col&#xA;        normal! v`&quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;onoremap &amp;lt;silent&amp;gt; pb :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;StatementOperator('(',')')&amp;lt;cr&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; pB :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;StatementOperator('{','}')&amp;lt;cr&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; pr :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;StatementOperator('[',']')&amp;lt;cr&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; pa :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;StatementOperator('&amp;lt;','&amp;gt;')&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; pb :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;StatementOperator('(',')')&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; pB :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;StatementOperator('{','}')&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; pr :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;StatementOperator('[',']')&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; pa :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;StatementOperator('&amp;lt;','&amp;gt;')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-06-11T16:25:41.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8195" PostTypeId="1" CreationDate="2016-06-11T16:35:55.020" Score="9" ViewCount="931" Body="&lt;p&gt;Is there a way to move to the next unmatched line with in vimdiff? Not &quot;move to the next changed line&quot;, but move to the next unmatched line for the current file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case I'm trying to compare two large files, one of which should be practically a subset of the other. What I want to do is to see if there's any lines in the smaller file which are missing in the larger file. I figured I should be able to place my cursor in the larger file, and then directly jump to the next &quot;missing&quot; line annotation. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It just so happens that the current files in question are sorted, so I can probably use the &quot;comm&quot; command line utility to find the missing lines, but I was wondering if there's an easy way to do it in vimdiff, particularly if the lines aren't sorted.   &lt;/p&gt;&#xA;" OwnerUserId="7964" LastActivityDate="2016-08-21T21:03:07.613" Title="Move to next unmatched line with vimdiff" Tags="|cursor-movement|vimdiff|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8196" PostTypeId="1" CreationDate="2016-06-11T17:05:49.713" Score="2" ViewCount="145" Body="&lt;p&gt;When I'm on an empty line and press &lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;, nothing happens, whereas on a line with an &lt;code&gt;a&lt;/code&gt;, it will go into insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;silent&amp;gt; a :normal! Favfz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whether I am on an empty line or a line where the pattern is actually present, I will always go into Insert mode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I emulate that behavior in my own mappings?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want a solution for the above, I would be happy with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;silent&amp;gt; a &amp;lt;don't enter onoremap&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-06-11T17:05:49.713" Title="Avoid ending up in mode from onoremap" Tags="|vimscript|insert-mode|map-operator|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8197" PostTypeId="1" AcceptedAnswerId="8199" CreationDate="2016-06-11T17:21:37.463" Score="4" ViewCount="2957" Body="&lt;p&gt;I wanted to know if there might be a way to open a text file in an existing console vim.  This would really help my current workflow. I default to sublime when opening things from the desktop because I haven't been able to find a good way to do this. Also, I do know about gvim, but I'm not a big fan of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="7260" LastActivityDate="2016-06-11T19:11:24.910" Title="Open text file in an existing console vim window" Tags="|vim-windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8198" PostTypeId="2" ParentId="8188" CreationDate="2016-06-11T17:35:10.850" Score="4" Body="&lt;p&gt;I don't know if you have &lt;code&gt;Rscript&lt;/code&gt; installed, but you should have.&#xA;If you don't install R using &lt;a href=&quot;https://rud.is/b/2015/10/22/installing-r-on-os-x-100-homebrew-edition/&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just run Terminal.app and run &lt;code&gt;Rscript&lt;/code&gt; and if says &quot;command not found&quot;, you need to install R using the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;Rscript&lt;/code&gt; now works, you can run R code directly from vim.&#xA;First copy the R code from vim (using &lt;kbd&gt;y&lt;/kbd&gt;) to the unnamed register (&quot;), which is the register vim uses, if you don't define a register. Now use the cmdline mode (with &lt;kbd&gt;:&lt;/kbd&gt;) and type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo system(&quot;read arg; Rscript -e $arg&quot;, @&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The script should run, and the output is displayed on your screen.&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-06-11T17:35:10.850" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8199" PostTypeId="2" ParentId="8197" CreationDate="2016-06-11T19:11:24.910" Score="7" Body="&lt;p&gt;To do this from the command line is actually very easy. First, open an instance of vim. Then, in a new cmd, type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --remote-silent +e filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --remote-silent +split filename&#xA;vim --remote-silent +tabedit filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on the behavior you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, running stuff in the command line isn't always the most convenient, especially in windows. To add this to the context menu, e.g. right click a file then have this option, do the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Make a file with a &lt;code&gt;.reg&lt;/code&gt; extension, and save this to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Windows Registry Editor Version 5.00&#xA;[HKEY_CLASSES_ROOT\*\Shell\vimEdit]&#xA;@=&quot;Edit in existing vim&quot;&#xA;[HKEY_CLASSES_ROOT\*\Shell\vimEdit\command]&#xA;@=&quot;\&quot;C:\\Program Files (x86)\\Vim\\vim74\\vim.exe\&quot; --remote-tab-silent +edit %1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Double click this file. This will add &quot;Edit in existing vim&quot; to your context menu. Now, you can right click on a file, and it will open in a new vim if you don't have one open, or in a new tab on an existing vim if you don't.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you don't want this in a new tab, just change &lt;code&gt;--remote-tab-silent&lt;/code&gt; to &lt;code&gt;--remote-silent&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-11T19:11:24.910" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8202" PostTypeId="1" AcceptedAnswerId="8203" CreationDate="2016-06-12T04:39:57.093" Score="5" ViewCount="335" Body="&lt;p&gt;I'm using Vim 7.4.  I tried to search backward for &lt;code&gt;front&lt;/code&gt; and &lt;code&gt;frnt&lt;/code&gt;, so I pressed &lt;kbd&gt;?&lt;/kbd&gt; and entered the regular expression &lt;code&gt;fro\?nt&lt;/code&gt;.  Vim tells me that it can't find &lt;code&gt;fro?nt&lt;/code&gt; (the backslash is missing in the message).  None of the occurances that I can see are highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, if I search &lt;em&gt;forward&lt;/em&gt;, it finds them just fine.  Even if I am at the end of the file and can't find anymore by searching forward, Vim recognizes their occurance earlier in the file by highlighting them.  In that case, the message is that it can't find &lt;code&gt;fro\?nt&lt;/code&gt;, i.e., the backslash is not missing in the message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get that pressing &lt;kbd&gt;?&lt;/kbd&gt; to search backward might cause a problem with the &lt;code&gt;\?&lt;/code&gt; in the regular expression, but I would have thought that the backslash would have removed any doubt that question mark in the regular expression is not a delimiter.  I was wondering if this was the actual intended behaviour.  I couldn't find anything in the help that speaks to this.  I also see the same behaviour for gVim complied for Windows 7 as well as the version packaged with Cygwin.&lt;/p&gt;&#xA;" OwnerUserId="7970" LastEditorUserId="205" LastEditDate="2016-06-12T15:35:04.507" LastActivityDate="2016-06-12T15:35:04.507" Title="Backward search command ignores &quot;\&quot; in regexp &quot;o\?&quot;" Tags="|regular-expression|search|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8203" PostTypeId="2" ParentId="8202" CreationDate="2016-06-12T05:39:45.153" Score="8" Body="&lt;p&gt;This is because of search feature called offsets. From &lt;code&gt;:help 27.3&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*27.3*  Offsets&#xA;&#xA;By default, the search command leaves the cursor positioned on the beginning&#xA;of the pattern.  You can tell Vim to leave it some other place by specifying&#xA;an offset.  For the forward search command &quot;/&quot;, the offset is specified by&#xA;appending a slash (/) and the offset: &amp;gt;&#xA;&#xA;    /default/2&#xA;&#xA;This command searches for the pattern &quot;default&quot; and then moves to the&#xA;beginning of the second line past the pattern.  Using this command on the&#xA;paragraph above, Vim finds the word &quot;default&quot; in the first line.  Then the&#xA;cursor is moved two lines down and lands on &quot;an offset&quot;.&#xA;&#xA;...&#xA;&#xA;SEARCHING BACKWARDS&#xA;&#xA;The &quot;?&quot; command uses offsets in the same way, but you must use &quot;?&quot; to separate&#xA;the offset from the pattern, instead of &quot;/&quot;: &amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is definitely the intended behavior. From &lt;code&gt;:help \?&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            */\?*&#xA;\?  Just like \=.  Cannot be used when searching backwards with the &quot;?&quot;&#xA;    command. {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The solution is pretty simple. Just use &lt;code&gt;\=&lt;/code&gt; instead of &lt;code&gt;\?&lt;/code&gt;. That works for me.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-12T05:39:45.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8205" PostTypeId="1" AcceptedAnswerId="8206" CreationDate="2016-06-12T13:11:18.283" Score="9" ViewCount="2515" Body="&lt;p&gt;As far as I understand Vim has a built-in support for tags (&lt;code&gt;ctags&lt;/code&gt; in this case)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I have a common C source and C header file. The header file has &lt;code&gt;void foo(void);&lt;/code&gt; and the source file has &lt;code&gt;void foo(void) { /* */ }&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when I'm in the source file, I can use &lt;code&gt;:tags foo&lt;/code&gt;, it will jump to the function definition in the source file. But if I use &lt;code&gt;:tnext&lt;/code&gt; now, it won't jump to the function declaration in the header file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I feel like this should be somehow possible. Is it?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="51" LastEditDate="2016-06-12T13:51:12.603" LastActivityDate="2016-06-12T17:21:22.890" Title="Jumping from function definition tag to prototype tag" Tags="|tags|ctags|filetype-c|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8206" PostTypeId="2" ParentId="8205" CreationDate="2016-06-12T17:21:22.890" Score="7" Body="&lt;p&gt;Okay I've done it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It all has to do with &lt;code&gt;ctags&lt;/code&gt;:&#xA;First create two files called &lt;code&gt;foo.c&lt;/code&gt; and &lt;code&gt;foo.h&lt;/code&gt; to test it:&#xA;In &lt;code&gt;foo.h&lt;/code&gt; write down:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int bar(void);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;foo.c&lt;/code&gt; write down:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int bar(void) { /* */ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in the directory where those two files is, execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctags --list-kinds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You get a long list of languages with there types of tags. Find C. Notice the following line:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;p  function prototypes [off]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would call it &lt;em&gt;function declaration&lt;/em&gt; but anyway. So you need to activate tags for &lt;em&gt;function prototypes&lt;/em&gt; when executing &lt;code&gt;ctags&lt;/code&gt;. You do that by calling:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctags -R --c-kinds=+p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that the same applies to any other languages, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctags -R --java-kinds=+l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can open &lt;code&gt;foo.c&lt;/code&gt; (&lt;code&gt;vim foo.c&lt;/code&gt;) and enter &lt;code&gt;:tag bar&lt;/code&gt;. It will show you the function definition. Enter &lt;code&gt;:tnext&lt;/code&gt; and you will jump into &lt;code&gt;foo.h&lt;/code&gt; to the declaration of &lt;code&gt;bar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However also notice that &lt;code&gt;ctags&lt;/code&gt; doesn't care about correctness. E.g. the &lt;code&gt;bar&lt;/code&gt; declaraction couldn't even apply to the definition of &lt;code&gt;bar&lt;/code&gt;, as I havn't included the header file.&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-06-12T17:21:22.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8207" PostTypeId="1" AcceptedAnswerId="8225" CreationDate="2016-06-12T17:38:48.563" Score="5" ViewCount="801" Body="&lt;p&gt;I am trying to highlight a word in the current buffer dynamically like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Highlight()&#xA;&#xA;  let @/ = 'word'&#xA;  set hlsearch&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run this function, the register &lt;code&gt;/&lt;/code&gt; contains &lt;code&gt;word&lt;/code&gt; as desired but the word &lt;code&gt;word&lt;/code&gt; is not highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This surprises me because if I remove the &lt;code&gt;set hlsearch&lt;/code&gt; part and after the function runs, I call it manually, it highlight correctly the word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do to have the correct behavior?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-16T08:27:57.753" LastActivityDate="2016-06-16T08:27:57.753" Title="Set highlight in vim function" Tags="|search|highlight|" AnswerCount="2" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="8208" PostTypeId="1" AcceptedAnswerId="8213" CreationDate="2016-06-12T22:27:45.817" Score="5" ViewCount="574" Body="&lt;p&gt;Now if I select something in visual mode, is there some way to get the selected area without having to yank it to some register?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked through &lt;code&gt;:h functions&lt;/code&gt; but didn't find anything.&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-06-13T05:45:58.367" Title="Way to get content of Visual Selection?" Tags="|cut-copy-paste|visual-mode|functions|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8209" PostTypeId="1" AcceptedAnswerId="8214" CreationDate="2016-06-12T22:49:42.353" Score="3" ViewCount="95" Body="&lt;p&gt;Given the file &lt;em&gt;alfa.c&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Lorem ipsum dolor sit amet, apeirian constituam interpretaris no his, soluta salutandi persequeris vel ne, facete impedit contentiones te eam. Ut utamur habemus qualisque usu&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;int main() {&#xA;  puts(&quot;hello world&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to format all long comments to get results like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Lorem ipsum dolor sit amet, apeirian constituam interpretaris no his, soluta salutandi&#xA;// persequeris vel ne, facete impedit contentiones te eam. Ut utamur habemus qualisque usu&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;int main() {&#xA;  puts(&quot;hello world&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I see Vim has &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#format-comments&quot; rel=&quot;nofollow&quot;&gt;an option&lt;/a&gt; to format comments, however I did not see any Ex&#xA;mode commands. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2016-06-14T02:39:50.740" Title="Break long comments" Tags="|ex-mode|comments|ex-command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8210" PostTypeId="2" ParentId="8208" CreationDate="2016-06-12T23:28:45.163" Score="5" Body="&lt;p&gt;There is no other way but to yank it into a register. At best, you can restore the register once you're done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, I have the &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/visual.vim#L51&quot; rel=&quot;noreferrer&quot;&gt;following utility function&lt;/a&gt; that cleans behind itself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! lh#visual#selection()&#xA;  try&#xA;    let a_save = @a&#xA;    normal! gv&quot;ay&#xA;    return @a&#xA;  finally&#xA;    let @a = a_save&#xA;  endtry&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note I know this question has been asked a few time on SO, but I'm not sure about vi.SE)&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-06-12T23:28:45.163" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8211" PostTypeId="2" ParentId="8209" CreationDate="2016-06-13T03:38:57.003" Score="0" Body="&lt;p&gt;You can set a limit for a line, like 80 columns for a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can set a autocommand to split such lines whenever you save the file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au BufWrite *.* :%s#^\s\*//.\{78\}#&amp;amp;\r//#g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put this in your &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="7161" LastEditDate="2016-06-14T02:39:50.740" LastActivityDate="2016-06-14T02:39:50.740" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8212" PostTypeId="2" ParentId="8208" CreationDate="2016-06-13T04:18:48.940" Score="2" Body="&lt;p&gt;There is a way to select the previously selected visual area. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have selected some text through &lt;code&gt;v&lt;/code&gt;, &lt;code&gt;V&lt;/code&gt;, or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;code&gt;v&lt;/code&gt;, you can reselect the portion by pressing &lt;code&gt;gv&lt;/code&gt; in normal mode. (You can reselect it irrespective of whether you did any operation or cancelled the selection)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Functions accept line range and marks as well. You can use your functions with visual marks like &lt;code&gt;:'&amp;lt;,'&amp;gt;function()&lt;/code&gt;. This will apply the function within the recently selected visual range.&#xA;Or, you can select the text through any of the visual modes and cancel selection and then use this in your function by executing &lt;code&gt;gv&lt;/code&gt; inside the function, like &lt;code&gt;:execute 'gv'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="7161" LastEditDate="2016-06-13T05:09:05.117" LastActivityDate="2016-06-13T05:09:05.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8213" PostTypeId="2" ParentId="8208" CreationDate="2016-06-13T05:45:58.367" Score="6" Body="&lt;p&gt;If you really want to avoid the registers, you can use the visual marks to figure out byte positions of the selected text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:pos2byte(pos) abort&#xA;    return line2byte(a:pos[1]) + a:pos[2]&#xA;endfunction&#xA;&#xA;function! s:get_visual_text() abort&#xA;    let b1 = s:pos2byte(getpos(&quot;'&amp;lt;&quot;))&#xA;    let b2 = s:pos2byte(getpos(&quot;'&amp;gt;&quot;))&#xA;    let text = ''&#xA;&#xA;    while b1 &amp;lt; b2&#xA;        let l = byte2line(b1)&#xA;        let lb = line2byte(l)&#xA;        let line = strpart(getline(l), b1 - lb - 1)&#xA;        let text .= line&#xA;        let b1 += len(line)&#xA;    endwhile&#xA;&#xA;    return strpart(text, 0, len(text) - (b1 - b2) + 1)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works well enough, but there's something about it that I don't trust.  I think it might need more checks to make sure an infinite loops doesn't happen, and it won't work on visual blocks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer using the temporary register method because I don't have to think too hard about what's going to happen.  This is the proper way to do it if you want to leave the buffer state undisturbed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:get_visual_text() abort&#xA;    &quot; Save the window's view because `gv` may change the scroll position.&#xA;    let view = winsaveview()&#xA;&#xA;    &quot; Preserve the yank/change marks&#xA;    let m1 = getpos(&quot;'[&quot;)&#xA;    let m2 = getpos(&quot;']&quot;)&#xA;&#xA;    &quot; Preserve the 'a' register, as well as what kind of register it is.&#xA;    let reg_val = getreg('a')&#xA;    let reg_type = getregtype('a')&#xA;&#xA;    &quot; Yank text into the 'a' register and get the text&#xA;    normal! gv&quot;ay&#xA;    let text = getreg('a')&#xA;&#xA;    &quot; Restore the 'a' register&#xA;    call setreg('a', reg_val, reg_type)&#xA;&#xA;    &quot; Restore the yank/change marks&#xA;    call setpos(&quot;'[&quot;, m1)&#xA;    call setpos(&quot;']&quot;, m2)&#xA;&#xA;    &quot; Restore the window's view&#xA;    call winrestview(view)&#xA;&#xA;    return text&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-13T05:45:58.367" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8214" PostTypeId="2" ParentId="8209" CreationDate="2016-06-13T06:23:56.487" Score="3" Body="&lt;p&gt;Depending on your configuration you can achieve the desired result with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to use this as a ex command you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! gqq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to format the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aslo, it's worth adding the flags &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;c&lt;/code&gt; to your &lt;code&gt;'formatoption'&lt;/code&gt; configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fo+=ac&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will try to preserve the current comment formatting as well as automatically formatting the paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to have a look at:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h format&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h gq&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h fo-table&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h 'fo'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-13T06:23:56.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8215" PostTypeId="1" AcceptedAnswerId="8216" CreationDate="2016-06-13T12:42:09.570" Score="30" ViewCount="11304" Body="&lt;p&gt;I know I can use &lt;code&gt;:new&lt;/code&gt; to open a new buffer in a split window (defined by &lt;code&gt;set splitbelow&lt;/code&gt; and &lt;code&gt;set splitright&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how can I just open a new, empty buffer without opening it in a split?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="205" LastEditDate="2016-06-13T21:00:26.283" LastActivityDate="2016-06-13T21:00:26.283" Title="How do I open a new buffer without opening it in a split?" Tags="|buffers|split|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8216" PostTypeId="2" ParentId="8215" CreationDate="2016-06-13T12:46:49.963" Score="37" Body="&lt;p&gt;You can use &lt;code&gt;:enew&lt;/code&gt;. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#:enew&quot;&gt;&lt;code&gt;:h :enew&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Edit a new, unnamed buffer.  This fails when changes&#xA;              have been made to the current buffer, unless 'hidden'&#xA;              is set or 'autowriteall' is set and the file can be&#xA;              written.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And you can use &lt;code&gt;:enew!&lt;/code&gt; to discard unsaved changes in the current buffer.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-06-13T12:46:49.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8217" PostTypeId="2" ParentId="8113" CreationDate="2016-06-13T13:40:07.723" Score="7" Body="&lt;p&gt;As romainl suggested, you can achieve so with the &lt;code&gt;conceal&lt;/code&gt; feature of vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a script example that can be used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let rules = [&#xA;      \ ['01' , '☺'],&#xA;      \ ['02' , '☻'],&#xA;      \ ['03' , '♥'],&#xA;      \ ['04' , '♦'],&#xA;      \ ['05' , '♣'],&#xA;      \ ['06' , '♣'],&#xA;      \ ['07' , '•'],&#xA;      \ ['08' , '◘'],&#xA;      \ ['^A' , '¢'],&#xA;      \ ]&#xA;&#xA;for [value, display] in rules&#xA;  execute &quot;syntax match vartest /&quot;.value.&quot;/ conceal cchar=&quot;.display&#xA;endfor&#xA;&#xA;&quot; Ensure the character is concealed&#xA;set conceallevel=2&#xA;set concealcursor=nvc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, I took some of the &lt;a href=&quot;https://github.com/Mego/Seriously/blob/master/docs/commands.txt&quot; rel=&quot;nofollow&quot;&gt;seriously mapping&lt;/a&gt; and your &lt;code&gt;^A&lt;/code&gt; example.&#xA;Careful if you want to copy/paste this code, the &lt;code&gt;^A&lt;/code&gt; needs to be typed &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; &lt;code&gt;&amp;lt;C-A&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What this code does is, it define for each &lt;code&gt;value&lt;/code&gt;/&lt;code&gt;display&lt;/code&gt; pair a syntax matching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match vartest /08/ conceal cchar=◘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will match every &lt;code&gt;08&lt;/code&gt; sequence and the file and conceal them with the &lt;code&gt;◘&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will &lt;strong&gt;see&lt;/strong&gt; &lt;code&gt;◘&lt;/code&gt;, but the actual text in the file is &lt;code&gt;08&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can then take a list of rules and (with a fancy macro, i.e. for seriously: &lt;code&gt;0i\ ['^[f s', '^[lxf)s'],^[ld$&lt;/code&gt;) transforme each line into a usable vim array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you want to type literal unicode with vim, you can use this workflow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-V&amp;gt; u XXXX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;XXXX&lt;/code&gt; is the unicode value, so typing &lt;code&gt;&amp;lt;C-V&amp;gt;u0001&lt;/code&gt; will insert &lt;code&gt;^A&lt;/code&gt; as  desired.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to verify the content of the file, I recommend using a hex dump of the file, that you can have with &lt;a href=&quot;http://linuxcommand.org/man_pages/xxd1.html&quot; rel=&quot;nofollow&quot;&gt;xxd&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim&#xA;&#xA;&amp;lt;C-V&amp;gt;&amp;lt;C-A&amp;gt;&amp;lt;C-V&amp;gt;&amp;lt;C-B&amp;gt;&#xA;:x a.txt&#xA;&#xA;$ xxd a.txt&#xA;0000000: 0102 0a                                  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see here your &lt;code&gt;^A&lt;/code&gt; as &lt;code&gt;01&lt;/code&gt; and your &lt;code&gt;^B&lt;/code&gt; as &lt;code&gt;02&lt;/code&gt;. (&lt;code&gt;0a&lt;/code&gt; represents the new line at the end of the file)&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="6489" LastEditDate="2016-06-13T16:21:32.797" LastActivityDate="2016-06-13T16:21:32.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8218" PostTypeId="2" ParentId="8215" CreationDate="2016-06-13T14:57:26.860" Score="5" Body="&lt;p&gt;Vim also offers &lt;code&gt;:tabnew&lt;/code&gt;, which opens a new, unnamed buffer in a new tab allows you to easily switch between buffers (tabs) using &lt;code&gt;gt&lt;/code&gt; and &lt;code&gt;gT&lt;/code&gt;. This consumes the full width of the editor, albeit, technically in a different window (in a different tab).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Corrected from romainl's comment&lt;/p&gt;&#xA;" OwnerUserId="7547" LastEditorUserId="7547" LastEditDate="2016-06-13T20:21:57.550" LastActivityDate="2016-06-13T20:21:57.550" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8219" PostTypeId="1" AcceptedAnswerId="8220" CreationDate="2016-06-13T23:46:29.823" Score="6" ViewCount="921" Body="&lt;p&gt;If I have a &lt;code&gt;regex&lt;/code&gt; in a recorded macro and then run it over a line that the &lt;code&gt;regex&lt;/code&gt; fails to match the macro stops.  For example, I have a list of files.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;family-reunion-2015.webm&#xA;road-festival-20150607.webm&#xA;ireland.webm&#xA;bike-festival-201407.webm&#xA;bike-festival-201409.webm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which I want to convert to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;a href=&quot;family-reunion-2015.webm&quot;&amp;gt;&#xA;family reunion 2015&amp;lt;/a&amp;gt;&#xA;&amp;lt;a href=&quot;road-festival-20150607.webm&quot;&amp;gt;&#xA;road festival 20150607&amp;lt;/a&amp;gt;&#xA;&amp;lt;a href=&quot;ireland.webm&quot;&amp;gt;&#xA;ireland&amp;lt;/a&amp;gt;&#xA;&amp;lt;a href=&quot;bike-festival-201407.webm&quot;&amp;gt;&#xA;bike festival 201407&amp;lt;/a&amp;gt;&#xA;&amp;lt;a href=&quot;bike-festival-201409.webm&quot;&amp;gt;&#xA;bike festival 201409&amp;lt;/a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I record the following &lt;code&gt;macro&lt;/code&gt; inside the &lt;kbd&gt;q&lt;/kbd&gt; register:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;qq&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yyp:s/\-/ /g&amp;lt;ENTER&amp;gt;A&amp;lt;Esc&amp;gt;xxxxxi&amp;lt;/a&amp;gt;&amp;lt;Esc&amp;gt;kI&amp;lt;a href=&quot;&amp;lt;Esc&amp;gt;A&quot;&amp;gt;&amp;lt;Esc&amp;gt;JJ0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I start from the first character of the first line and finish at the first character of the next line, i.e. at the end of the macro i move to the beginning of the next line (&lt;code&gt;JJ0&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I repeat the macro by typing &lt;kbd&gt;4@q&lt;/kbd&gt;.  But i end with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;a href=&quot;family-reunion-2015.webm&quot;&amp;gt;&#xA;family reunion 2015&amp;lt;/a&amp;gt;&#xA;&amp;lt;a href=&quot;road-festival-20150607.webm&quot;&amp;gt;&#xA;road festival 20150607&amp;lt;/a&amp;gt;&#xA;ireland.webm&#xA;ireland.webm&#xA;bike-festival-201407.webm&#xA;bike-festival-201409.webm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And an error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E486: Pattern not found: \-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is correct, but it stops the macro from advancing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can i tell vim to ignore this error and continue the macro processing?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'm getting around this by doing &lt;code&gt;:%s/webm$/we-bm/&lt;/code&gt; and adding an extra &lt;code&gt;x&lt;/code&gt; to my macro.  But there should be a more elegant way.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="205" LastEditDate="2016-06-15T07:06:39.823" LastActivityDate="2016-06-15T07:06:39.823" Title="How do I ignore regex failure while running a macro?" Tags="|regular-expression|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8220" PostTypeId="2" ParentId="8219" CreationDate="2016-06-13T23:53:28.297" Score="9" Body="&lt;p&gt;Use the &lt;code&gt;/e&lt;/code&gt; flag. From &lt;code&gt;:help s_flag&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[e]     When the search pattern fails, do not issue an error message and, in&#xA;    particular, continue in maps as if no error occurred.  This is most&#xA;    useful to prevent the &quot;No match&quot; error from breaking a mapping.  Vim&#xA;    does not suppress the following error messages, however:&#xA;        Regular expressions can't be delimited by letters&#xA;        \ should be followed by /, ? or &amp;amp;&#xA;        No previous substitute regular expression&#xA;        Trailing characters&#xA;        Interrupted&#xA;    {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-13T23:53:28.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8221" PostTypeId="1" CreationDate="2016-06-14T02:38:06.927" Score="8" ViewCount="4677" Body="&lt;p&gt;Is there an easy way to jump to the beginning or end of the function your cursor is currently inside? It doesn't seem like sentence/paragraph/section have useful syntax aware meanings when editing C++.&lt;/p&gt;&#xA;" OwnerUserId="7994" LastEditorUserId="205" LastEditDate="2016-06-14T05:43:16.870" LastActivityDate="2016-06-14T17:36:22.233" Title="Jumping to start/end of function definition in C++" Tags="|cursor-motions|filetype-c++|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8222" PostTypeId="2" ParentId="8221" CreationDate="2016-06-14T02:57:41.680" Score="4" Body="&lt;p&gt;I'm not aware of anything direct and foolproof.  It may very well exist in a plugin somewhere, of course.  &lt;kbd&gt;][&lt;/kbd&gt; will take you to the next closing curly brace in column one. If your code is properly formatted, that's almost certainly the end of the function but the movement doesn't pay any attention to the syntax of any other characters at all. It just walks down column one looking for a &lt;code&gt;}&lt;/code&gt;. &lt;kbd&gt;]}&lt;/kbd&gt; will take you to the end of the current code block. It does pay attention to nested braces. That may or may not be the end of the function but you can usually get there quickly by repeating it a time or two.&lt;/p&gt;&#xA;" OwnerUserId="7995" LastEditorUserId="2920" LastEditDate="2016-06-14T03:08:36.640" LastActivityDate="2016-06-14T03:08:36.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8223" PostTypeId="2" ParentId="8221" CreationDate="2016-06-14T05:36:06.693" Score="8" Body="&lt;p&gt;As we cannot expect C++ code to have their function-scope brackets on the first column, we cannot rely on the default behaviour of &lt;code&gt;]]&lt;/code&gt; and &lt;code&gt;][&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few weeks ago I've &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp/commit/32a2c69c874bd1df056807a35cdd42c36cd2c6f4&quot; rel=&quot;nofollow noreferrer&quot;&gt;added&lt;/a&gt; this feature into &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-cpp&lt;/a&gt;. I won't describe here how it works as I've done it in answer to another similar question on vi.SE: &lt;a href=&quot;https://vi.stackexchange.com/questions/7925/quick-search-limited-to-a-c-function/7942#7942&quot;&gt;Quick search, limited to a C++ function&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(the idea is that I rely on ctags to parse the current file and obtain the boundaries of the current function)&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-06-14T17:36:22.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8224" PostTypeId="2" ParentId="7466" CreationDate="2016-06-14T07:47:46.337" Score="33" Body="&lt;p&gt;I've been using &lt;a href=&quot;https://github.com/sirver/UltiSnips&quot; rel=&quot;noreferrer&quot;&gt;ultisnips&lt;/a&gt; for several&#xA;weeks now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the main advantages of this plugin are the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It is pretty fast even with a great number of snippets available.&lt;/li&gt;&#xA;&lt;li&gt;The basic syntax to define a new snippet is easy to understand, thus it is&#xA;easy to quickly create a new snippet doing what you want to do. (For more&#xA;complex snippets some additional work can be required.)&lt;/li&gt;&#xA;&lt;li&gt;It works very well out of the box; a basic configuration allow you to use&#xA;snippets very quickly.&lt;/li&gt;&#xA;&lt;li&gt;It is really configurable. Even if the basic configuration works well, if&#xA;you're a power user you can really tune it pretty finely.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;First of all ultisnips is a snippet engine which means that the plugin provides&#xA;features to use snippets but doesn't provide the snippets themselves. To get the&#xA;snippets, the author recommends &#xA;&lt;a href=&quot;https://github.com/honza/vim-snippets&quot; rel=&quot;noreferrer&quot;&gt;vim-snippets&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you got both plugins installed you'll be able to use your snippets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The snippets' definitions are stored in files named following patterns:&#xA;&lt;code&gt;ft.snippets&lt;/code&gt;, &lt;code&gt;ft_*.snippets&lt;/code&gt;, or &lt;code&gt;ft/*&lt;/code&gt;, where &lt;code&gt;ft&lt;/code&gt; is the 'filetype' of the&#xA;current document and &lt;code&gt;*&lt;/code&gt; is a shell-like wildcard matching any string including&#xA;the empty string. &lt;em&gt;(Note that dotted filetype syntax like &lt;code&gt;cuda.cpp&lt;/code&gt; is&#xA;supported.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way snippets specific to a filetype are expanded only when the buffer's&#xA;filetype is set. A special filetype &lt;code&gt;all&lt;/code&gt; is available to create snippets&#xA;expanded on all buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to the snippets provided by vim-snippets, the user can define its&#xA;own snippets. My recommendation would be to place them in the directory&#xA;&lt;code&gt;~/.vim/my-snippets/Ultisnips&lt;/code&gt; this way Ultisnips will find them without&#xA;additional configuration and it is easy to maintain them in a dotfile&#xA;repository.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To expand the snippets, Ultisnips provides a variable &lt;code&gt;g:UltiSnipsExpandTrigger&lt;/code&gt;&#xA;which defines the mapping which will trigger the expansion (I chose&#xA;&lt;kbd&gt;**&lt;/kbd&gt; which is pretty convenient for me). Note that an integration&#xA;should be possible but I didn't test it by myself).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For power users, Ultisnips also provides some functions to customize the behavior&#xA;of the expansion, or to trigger it differently. See &lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt#L271&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h&#xA;UltiSnips-trigger-functions&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is the first snippet manager that I really used extensively and I think this&#xA;is a good one to begin with for its simplicity out of the box and its&#xA;possibility to be tuned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally here is a list of screencasts which give a good introduction to the&#xA;plugin:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.sirver.net/blog/2011/12/30/first-episode-of-ultisnips-screencast/&quot; rel=&quot;noreferrer&quot;&gt;Episode 1: What are snippets and do I need them?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.sirver.net/blog/2012/01/08/second-episode-of-ultisnips-screencast/&quot; rel=&quot;noreferrer&quot;&gt;Episode 2: Creating Basic Snippets&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.sirver.net/blog/2012/02/05/third-episode-of-ultisnips-screencast/&quot; rel=&quot;noreferrer&quot;&gt;Episode 3: What's new in version 2.0&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.sirver.net/blog/2012/03/31/fourth-episode-of-ultisnips-screencast/&quot; rel=&quot;noreferrer&quot;&gt;Episode 4: Python Interpolation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="3224" LastEditDate="2019-12-04T09:04:22.033" LastActivityDate="2019-12-04T09:04:22.033" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8225" PostTypeId="2" ParentId="8207" CreationDate="2016-06-14T08:17:42.290" Score="3" Body="&lt;p&gt;A workaround:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Highlight()&#xA;&#xA;  call matchadd('error', 'word')&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;matchadd&lt;/code&gt; function takes an highlight group (here &lt;code&gt;'error'&lt;/code&gt;) and a regex to match (here &lt;code&gt;'word'&lt;/code&gt;), it will create a new highlight a return it's ID.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to change the highlight over time, you can store this ID, call &lt;code&gt;matchdelete(ID)&lt;/code&gt; to clear the current highlight and call &lt;code&gt;matchadd&lt;/code&gt; again to add a new highlight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. pressing &lt;code&gt;&amp;lt;C-H&amp;gt;&lt;/code&gt; will highlight the word under the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:current_matching = -1&#xA;&#xA;function! Highlight()&#xA;&#xA;  if s:current_matching != -1&#xA;    call matchdelete(s:current_matching)&#xA;  endif&#xA;  let s:current_matching = matchadd('error', expand('&amp;lt;cword&amp;gt;'))&#xA;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;C-H&amp;gt; :call Highlight()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-14T08:17:42.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8226" PostTypeId="1" AcceptedAnswerId="8227" CreationDate="2016-06-14T18:07:02.690" Score="8" ViewCount="2552" Body="&lt;p&gt;The following mapping doesn't work as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap $ &amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would expect that when I press &lt;kbd&gt;$&lt;/kbd&gt; in command line mode, it cancels the current command line and returns to normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But instead of that, it &lt;em&gt;runs&lt;/em&gt; the current command line, and returns to normal mode (as if I had pressed the &lt;kbd&gt;Return&lt;/kbd&gt; key).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :echo &quot;Hello&quot;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will echo &lt;code&gt;Hello&lt;/code&gt; before exiting the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a normal behaviour, and how can I map a key to cancel the command line mode?&lt;/p&gt;&#xA;" OwnerUserId="5516" LastActivityDate="2016-06-14T20:10:15.913" Title="cnoremap and the &lt;esc&gt; key" Tags="|key-bindings|command-line|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8227" PostTypeId="2" ParentId="8226" CreationDate="2016-06-14T18:21:25.247" Score="10" Body="&lt;p&gt;I don't know why &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; doesn't work, but you &lt;em&gt;can&lt;/em&gt; use &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt;. I.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap $ &amp;lt;C-c&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Found the reason for this behavior in &lt;code&gt;:h c_&amp;lt;Esc&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In macros or when 'x' present in 'cpoptions', start entered command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-06-14T18:49:17.500" LastActivityDate="2016-06-14T18:49:17.500" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8228" PostTypeId="2" ParentId="8226" CreationDate="2016-06-14T18:21:58.350" Score="5" Body="&lt;p&gt;I'm not sure what causes this behavior, but I do know a way you could get around it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap $ &amp;lt;C-u&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; clears the current command. From &lt;code&gt;:help c_CTRL-U&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *c_CTRL-U*&#xA;CTRL-U      Remove all characters between the cursor position and&#xA;        the beginning of the line.  Previous versions of vim&#xA;        deleted all characters on the line.  If that is the&#xA;        preferred behavior, add the following to your .vimrc: &amp;gt;&#xA;            :cnoremap &amp;lt;C-U&amp;gt; &amp;lt;C-E&amp;gt;&amp;lt;C-U&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-14T18:21:58.350" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8230" PostTypeId="2" ParentId="8034" CreationDate="2016-06-14T18:47:08.507" Score="2" Body="&lt;p&gt;I'm going to add this as another answer, because it's a &lt;em&gt;very&lt;/em&gt; different (and in my opinion better) approach than my other answer. I would do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap Y Vy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;V enters &quot;visual line mode&quot; where the selection is done linewise instead of character wise, and then y is obviously yank.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-14T18:47:08.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8231" PostTypeId="1" CreationDate="2016-06-14T22:38:32.320" Score="5" ViewCount="3520" Body="&lt;p&gt;I want to be able to delete indenting spaces one at a time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I set &lt;code&gt;shiftwidth&lt;/code&gt; to 4, it deletes 4 spaces at a time if vim counts them as indentation. Setting &lt;code&gt;shiftwidth&lt;/code&gt; to 1 fixes the problem, but makes vim autoindents using 1 space instead of a tab and inserts 1 space when I try to insert a tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to delete spaces counted as indentation one at a time while keeping &lt;code&gt;shiftwidth&lt;/code&gt; equal to 4?&lt;/p&gt;&#xA;" OwnerUserId="8006" LastEditorUserId="343" LastEditDate="2022-10-04T19:45:36.983" LastActivityDate="2022-10-04T19:45:36.983" Title="Delete indenting spaces one at a time" Tags="|indentation|tab-characters|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8232" PostTypeId="1" AcceptedAnswerId="8233" CreationDate="2016-06-14T22:57:20.940" Score="4" ViewCount="237" Body="&lt;p&gt;I know the separate answers. For example,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;To open several files: &lt;code&gt;:n \**/*.f90&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;To save &lt;code&gt;*.f90&lt;/code&gt; file to HTML: &lt;code&gt;:TOhtml&lt;/code&gt; and &lt;code&gt;:wq&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, I don't know how to combine both of them.&lt;/p&gt;&#xA;" OwnerUserId="8010" LastEditorUserId="4472" LastEditDate="2017-09-26T18:05:29.783" LastActivityDate="2017-09-28T09:24:56.093" Title="How do I open several FORTRAN files in Vim and save them as HTML files?" Tags="|filetype-html|filetype-fortran|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8233" PostTypeId="2" ParentId="8232" CreationDate="2016-06-14T23:14:39.897" Score="6" Body="&lt;p&gt;After you've added your files to the arguments list with &lt;code&gt;:n ./**/*.f90&lt;/code&gt; (&lt;code&gt;:args&lt;/code&gt; + filenames would do the same thing and is perhaps more obvious) you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdo exe 'TOhtml' | wq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:argdo&lt;/code&gt; will execute its following commands for each buffer that's in the argument list. Note that you need to use &lt;code&gt;TOhtml&lt;/code&gt; with &lt;code&gt;:execute&lt;/code&gt; since it isn't defined to allow a following &lt;code&gt;|&lt;/code&gt;. Using &lt;code&gt;:execute&lt;/code&gt; allows you to work around this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may wish to modify the &lt;code&gt;:w&lt;/code&gt; command to write the generated HTML buffer into another directory (e.g. &lt;code&gt;w html/%&lt;/code&gt;). And it's probably a good idea to close each generated window as you go with &lt;code&gt;:q&lt;/code&gt; so Vim doesn't run out of room for windows if you have lots of files to process.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2017-09-28T09:24:56.093" LastActivityDate="2017-09-28T09:24:56.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8234" PostTypeId="2" ParentId="8231" CreationDate="2016-06-14T23:52:54.820" Score="3" Body="&lt;p&gt;I think some of your confusion comes down to terminology. There are two separate characters, space &lt;code&gt;&quot; &quot;&lt;/code&gt; and tab &lt;code&gt;&quot;\t&quot;&lt;/code&gt;. Tabs are a single character, but get displayed as several blank columns. This can be configured with &quot;shiftwidth&quot;. If you do &lt;code&gt;:set shiftwidth=4&lt;/code&gt; this means&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When I press tab, insert a tab character, and display it as 4 blank columns (or as 4 spaces).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When you hit backspace, it deletes a single tab character that looks like 4 spaces. Now, if you want a tab character to insert 4 &lt;em&gt;actual space characters&lt;/em&gt;, you should use &lt;code&gt;expandtab&lt;/code&gt;. If you &lt;code&gt;:set expandtab&lt;/code&gt;, it means:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When I press tab, enter &lt;em&gt;tabstop&lt;/em&gt; spaces instead of a tab character.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, if you &lt;code&gt;:set tabstop=4&lt;/code&gt;, the tab key will insert 4 spaces, and backspace will delete one of them at a time. For reference, here are the relevant lines in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Indent settings&#xA;set autoindent&#xA;set expandtab&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-14T23:52:54.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8235" PostTypeId="2" ParentId="8231" CreationDate="2016-06-15T02:56:13.970" Score="2" Body="&lt;p&gt;Figured out the answer. Set &lt;code&gt;softtabstop&lt;/code&gt; to 0. Wasn't working with my version of neovim, but it works when tested with original vim.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: Per &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27softtabstop%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;options.txt#softtabstop&lt;/a&gt; in Vim's help, setting &lt;code&gt;softtabstop&lt;/code&gt; to 0 disables the &lt;code&gt;softtabstop&lt;/code&gt; feature. The reason this allows for deleting &amp;quot;tab-like&amp;quot; sequences of spaces in a space-by-space way is presumably because &lt;code&gt;softtabstop&lt;/code&gt; controls the &amp;quot;number of spaces that a &amp;lt;Tab&amp;gt; counts for while performing editing operations, like…using &amp;lt;BS&amp;gt;,&amp;quot; per the manual. It's a bit strange to me in light of this that the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27tabstop%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation for &lt;code&gt;tabstop&lt;/code&gt;&lt;/a&gt; says that it controls the &amp;quot;number of spaces that a &amp;lt;Tab&amp;gt; counts for,&amp;quot; full stop, but I suppose you're meant to infer that &lt;code&gt;tabstop&lt;/code&gt; is about the file's &amp;quot;appearance,&amp;quot; e.g. in normal mode, whereas &lt;code&gt;softtabstop&lt;/code&gt; is about &amp;quot;editing,&amp;quot; e.g. in insert mode. You would be wrong in practice if you did that though, because &lt;code&gt;tabstop&lt;/code&gt; does control how many spaces you end up inserting in place of a tab if you have &lt;code&gt;expandtab&lt;/code&gt; on. The whole &amp;quot;appearance vs. reality&amp;quot; thing kind of makes less sense with spaces than it does with tabs, I guess.&lt;/p&gt;&#xA;&lt;p&gt;To those who doubt the usefulness of doing this, I use it in plaintext files meant for human consumption, because I like to indent things out to arbitrary distances in that context. It works nicely there to set a big &lt;code&gt;tabstop&lt;/code&gt; like 8, set &lt;code&gt;softtabstop&lt;/code&gt; to 0, and enable &lt;code&gt;expandtab&lt;/code&gt;, because you can use the tab key to indent something about as far out as you want and then delete a few spaces to get it just right. I also have &lt;code&gt;&amp;lt;s-Tab&amp;gt;&lt;/code&gt; (i.e. &amp;lt;Shift&amp;gt;-&amp;lt;Tab&amp;gt;) mapped to 4 spaces if I wanted to add a few spaces instead of delete a few.&lt;/p&gt;&#xA;" OwnerUserId="8006" LastEditorUserId="42959" LastEditDate="2022-07-30T20:50:01.653" LastActivityDate="2022-07-30T20:50:01.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8236" PostTypeId="2" ParentId="8231" CreationDate="2016-06-15T04:30:26.423" Score="1" Body="&lt;p&gt;Since you actually want indentation to be four spaces, I assume that this is a once-in-a-while thing you want to do.  You could always use &lt;code&gt;dh&lt;/code&gt; in normal mode.  In the worst case, you'd be typing &lt;code&gt;dh&lt;/code&gt; three times.  Any more than three and you might as well be pressing the backspace key.  To be a little bit more efficient with these four spaces, you could type &lt;code&gt;dh&lt;/code&gt;, then start mashing &lt;code&gt;.&lt;/code&gt; to repeat the deletion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that you're only dealing with four spaces, the math is simple enough to use a count such as &lt;code&gt;d2h&lt;/code&gt; without needing to think hard about it.  Again, &lt;code&gt;d2h&lt;/code&gt; is repeatable with &lt;code&gt;.&lt;/code&gt; so you can delete 2 spaces at a time.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-15T04:30:26.423" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8237" PostTypeId="1" CreationDate="2016-06-15T05:11:48.430" Score="2" ViewCount="1553" Body="&lt;p&gt;Is it possible to copy the absolute filepath of the file under the cursor in Netrw?&lt;/p&gt;&#xA;" OwnerUserId="8013" LastEditorUserId="2920" LastEditDate="2016-07-19T20:40:06.603" LastActivityDate="2021-09-22T06:35:11.940" Title="Copying absolute filepath of selected file in Netrw" Tags="|netrw|filesystem|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8238" PostTypeId="2" ParentId="8237" CreationDate="2016-06-15T06:27:14.393" Score="3" Body="&lt;p&gt;You can select the file under cursor through visual block mode, like &lt;code&gt;Ctrl+V&lt;/code&gt;, then press &lt;code&gt;$&lt;/code&gt; and then a &lt;code&gt;j&lt;/code&gt; and then a &lt;code&gt;y&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, in command line mode,&#xA;Type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo @%.@&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will show the full path of the file under cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also map it to a key,&#xA;Like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map \f ^&amp;lt;C-V&amp;gt;$jy:echo @%.@&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, you can press &lt;code&gt;\f&lt;/code&gt; while the cursor is on a file and it will print it's full path in command line.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-06-15T07:05:31.183" LastActivityDate="2016-06-15T07:05:31.183" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8239" PostTypeId="2" ParentId="8232" CreationDate="2016-06-15T06:29:03.490" Score="2" Body="&lt;p&gt;I would suggest the following combined command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args ./**/*.f90 | argdo execute TOhtml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First, use &lt;code&gt;args&lt;/code&gt; to fill the argument list, then use &lt;code&gt;argdo&lt;/code&gt; to execute the &lt;code&gt;TOhtml&lt;/code&gt; command. There should be no reason to &lt;code&gt;wq&lt;/code&gt;, since there is no change to the files, thus I would instead do e.g. &lt;code&gt;:qa&lt;/code&gt; when you were finished and happy.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-06-15T06:29:03.490" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8240" PostTypeId="1" AcceptedAnswerId="8241" CreationDate="2016-06-15T10:13:22.827" Score="48" ViewCount="28577" Body="&lt;p&gt;This is probably an incredibly simple question, but I did not find any answer so far (I must lack the right sources, and I don't know where to search in vim's help).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a condition and I would like it to include 'AND', like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (condition1 .AND. condition2)&#xA;   &quot;do what I want you to do&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I couldn't find the syntax. Same thing for 'OR'.&lt;/p&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="1841" LastEditDate="2016-06-15T14:00:49.283" LastActivityDate="2021-04-23T09:01:32.597" Title="Use conditional operators AND or OR in an IF statement?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8241" PostTypeId="2" ParentId="8240" CreationDate="2016-06-15T11:20:24.460" Score="51" Body="&lt;p&gt;Vimscript use C-like operators &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; and &lt;code&gt;||&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can find description of their usage on &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#expr2&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h expr2&lt;/code&gt;&lt;/a&gt;. Some important points mentioned by the doc are the following&lt;/p&gt;&#xA;&lt;p&gt;You'll find that the operators can be concatenated and &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; takes precedence over &lt;code&gt;||&lt;/code&gt;, so&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;amp;nu || &amp;amp;list &amp;amp;&amp;amp; &amp;amp;shell == &amp;quot;csh&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is equivalent to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;amp;nu || (&amp;amp;list &amp;amp;&amp;amp; &amp;amp;shell == &amp;quot;csh&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also once the result is known, the expression &amp;quot;short-circuits&amp;quot;, that is, further arguments are not evaluated.  This is like what happens in C.&lt;/p&gt;&#xA;&lt;p&gt;If you use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if a || b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The expression will be valid even is &lt;code&gt;b&lt;/code&gt; is not defined.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2021-04-23T09:01:32.597" LastActivityDate="2021-04-23T09:01:32.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8242" PostTypeId="1" AcceptedAnswerId="8250" CreationDate="2016-06-15T12:33:31.687" Score="2" ViewCount="688" Body="&lt;p&gt;I would like to get not the &lt;strong&gt;&lt;em&gt;first&lt;/em&gt;&lt;/strong&gt;, but the &lt;strong&gt;&lt;em&gt;second&lt;/em&gt;&lt;/strong&gt; occurrence of my &lt;code&gt;pattern&lt;/code&gt; using &lt;code&gt;search('pattern', 'myflags')&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could not find any flag or option in &lt;code&gt;search()&lt;/code&gt; documentation that could help me do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really liked my flags, especially '&lt;code&gt;b&lt;/code&gt;' to search backwards and '&lt;code&gt;n&lt;/code&gt;' to avoid cursor movement, so I wanted to see if there was a way to reach the second occurrence of my pattern with this function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted the question to be as short and general as possible, here's a bit more context : I'm coding in Fortran and I want the name of the subroutine I'm currently in to be displayed in my statusline. &#xA;I therefore ended up with a little function (thanks to &lt;a href=&quot;https://vi.stackexchange.com/q/7441/7128&quot;&gt;this&lt;/a&gt; post) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SubName() abort&#xA;   let n_line = search('subroutine ', 'bcnW')  &quot; find previous occurrence of 'subroutine'&#xA;   return matchstr(getline(n_line), 'subroutine \zs\w\+')  &quot; extract the word right after 'subroutine', which should be its name&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I sometimes write the word 'subroutine' in my code comments (for instance, &lt;code&gt;This subroutine really useful is incomprehensible.&lt;/code&gt;). In that case, right after the comment line, the function will extract &quot;&lt;em&gt;really&lt;/em&gt;&quot; thinking it's my subroutine's name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I came up with a condition to detect comments (if the beginning of the line is a '!' or a 'c' character).&#xA;But if this condition is true, I need to do my &lt;code&gt;search()&lt;/code&gt; again, this time up to the second match, so that the 'subroutine' pattern that is found is really the declaration of the subroutine, and not just one of my comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A generic fortran code could be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subroutine mySubroutine  &#xA;! This is an useful subroutine yeah.&#xA;! Stuff happens &#xA;end &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, I would like my function to extract &quot;mySubroutine&quot; instead of &quot;yeah&quot;, even if my cursor is at the bottom.&lt;/p&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-06-19T13:53:22.537" Title="Get 'second previous' occurrence using `search()`" Tags="|vimscript|search|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8244" PostTypeId="1" AcceptedAnswerId="8248" CreationDate="2016-06-15T14:33:38.317" Score="5" ViewCount="3930" Body="&lt;p&gt;After performing some search operation vim highlights its occurrences.&#xA;These occurrences persist as long as editor is opened or another search is performed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to clear previous search highlights after performing some operation? &lt;/p&gt;&#xA;" OwnerUserId="5890" LastActivityDate="2016-06-15T14:51:29.280" Title="How to clear previous search highlight in vim?" Tags="|search|gvim|highlight|" AnswerCount="1" CommentCount="0" ClosedDate="2016-06-15T18:07:52.907" ContentLicense="CC BY-SA 3.0" />
  <row Id="8246" PostTypeId="1" AcceptedAnswerId="8247" CreationDate="2016-06-14T23:16:10.857" Score="0" ViewCount="14057" Body="&lt;p&gt;I'm using VI right now to create a php file in AWS. I wanted to know if there was any way I could paste (as in copy/paste) an array from another file into my VI on PuTTY.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program is supposed to iterate over an array of addresses to parse them but I can't seem to figure out an efficient or easy way to upload the list of addresses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what the array looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/BKLNc.png&quot; alt=&quot;Snippet of the array&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8024" OwnerDisplayName="ybordag" LastActivityDate="2016-06-15T14:40:26.317" Title="How to paste from an external source on VI/VIM" Tags="|command-line|" AnswerCount="1" CommentCount="0" ClosedDate="2016-06-15T20:07:37.047" ContentLicense="CC BY-SA 3.0" />
  <row Id="8247" PostTypeId="2" ParentId="8246" CreationDate="2016-06-14T23:32:43.310" Score="2" Body="&lt;p&gt;Just use &lt;code&gt;Shift&lt;/code&gt;+&lt;code&gt;Insert&lt;/code&gt; or right-click -&gt; paste like you normally do? As long as vi is in 'insert' mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively upload the file and open it in the same vim instance (&lt;code&gt;:split&lt;/code&gt;, &lt;code&gt;:vsplit&lt;/code&gt; or &lt;code&gt;:tabedit&lt;/code&gt;), &lt;code&gt;y,&amp;lt;number of lines&amp;gt;,y&lt;/code&gt; to copy and &lt;code&gt;p&lt;/code&gt; to paste. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To navigate between tabs type &lt;code&gt;gt&lt;/code&gt;, between split panes use &lt;code&gt;Ctrl&lt;/code&gt;+&lt;code&gt;W&lt;/code&gt;, &lt;/p&gt;&#xA;" OwnerDisplayName="ToVine" LastActivityDate="2016-06-14T23:38:47.570" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8248" PostTypeId="2" ParentId="8244" CreationDate="2016-06-15T14:51:29.280" Score="10" Body="&lt;p&gt;You can look in the doc at &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#nohl&quot;&gt;&lt;code&gt;:h nohl&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When there is a previous search pattern, highlight all its matches.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A useful mapping is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-l&amp;gt; :nohl&amp;lt;CR&amp;gt;&amp;lt;C-L&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Originally &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; redraw the screen, with this mapping you first clear the highlighting and then redraw the screen.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-06-15T14:51:29.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8249" PostTypeId="1" AcceptedAnswerId="8253" CreationDate="2016-06-15T15:56:51.667" Score="8" ViewCount="2757" Body="&lt;p&gt;I have a file like the following : two different files were yanked one after another, and the numbers subsequently don't match anymore.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                ...   46&#xA;atom   142   option   47&#xA;atom   143   option   48       &#xA;atom    12   option    7  # There's a discontinuity in the numbers at this line&#xA;atom    13   option    8&#xA;atom    14   option    9&#xA;atom    ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to take the columns of numbers &lt;strong&gt;using visual-selection&lt;/strong&gt;, and &lt;strong&gt;add the missing constant&lt;/strong&gt; (in my example, for the first column, adding 132 to the last three lines would be perfect).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if regexp allow mathematical operations (otherwise I could try  a macro using Ctrl-X / Ctrl-A, but it won't use visual selection anymore and I'd like to keep it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The expected result would be something like:) &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                ...   46&#xA;atom   142   option   47&#xA;atom   143   option   48       &#xA;atom   144   option    7  # Discontinuity in the first numbers column is gone !&#xA;atom   145   option    8&#xA;atom   146   option    9&#xA;atom    ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7128" LastActivityDate="2016-06-15T17:36:54.903" Title="Add constant integer to visually selected numbers" Tags="|regular-expression|visual-block|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8250" PostTypeId="2" ParentId="8242" CreationDate="2016-06-15T16:10:49.027" Score="2" Body="&lt;p&gt;The following will get the name of the subroutine that the &lt;em&gt;cursor is within&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SubName() abort&#xA;  let line = search('^\(\s*\)subroutine\&amp;gt;\_.\{-}\%#\_.\{-}\_^\1end\&amp;gt;', 'ncbW')&#xA;  if line&#xA;    return matchstr(getline(line), '^\s*subroutine\s\+\zs\k\+')&#xA;  endif&#xA;  return ''&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Explanation&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^\(\s*\)&lt;/code&gt; - Search for a line that starts with any amount of whitespace and capture it into group 1.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;subroutine\&amp;gt;&lt;/code&gt; - Match &lt;code&gt;subroutine&lt;/code&gt; when it's not followed by keywords.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\_.\{-}\%#\_.\{-}&lt;/code&gt; - Match any character, including newlines, surrounding &lt;code&gt;\%#&lt;/code&gt; (the cursor).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\_^\1end\&amp;gt;&lt;/code&gt; - A line that begins with the same amount as whitespace as the beginning line (capture group 1), and is followed with &lt;code&gt;end&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the &lt;code&gt;matchstr()&lt;/code&gt; call, the pattern uses &lt;code&gt;\k&lt;/code&gt; to match keywords (&lt;code&gt;:h iskeyword&lt;/code&gt;) instead of &lt;code&gt;\w&lt;/code&gt;.  I don't know if this matters in Fortran, but &lt;code&gt;\k&lt;/code&gt; is a better way to match a keyword regardless of what the filetype is.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Caveat&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If your cursor is on the beginning subroutine line, but before the subroutine name, there will be no match.  This is because the cursor is matched after matching the word &lt;code&gt;subroutine&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get around that, you could move the cursor to the end of the line before running &lt;code&gt;search()&lt;/code&gt; then return it afterwards.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-06-19T13:53:22.537" LastActivityDate="2016-06-19T13:53:22.537" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8251" PostTypeId="2" ParentId="8249" CreationDate="2016-06-15T16:14:49.337" Score="4" Body="&lt;p&gt;&lt;strong&gt;edit :&lt;/strong&gt; answer posted before knowing OP had no support for the visual increment.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is a possible solution:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Select the last &lt;em&gt;good&lt;/em&gt; number, &lt;code&gt;143&lt;/code&gt; and yank it.&lt;/li&gt;&#xA;&lt;li&gt;In visual-block (&lt;kbd&gt;C-V&lt;/kbd&gt;), select the column under the &lt;code&gt;143&lt;/code&gt; you just yanked (where you want to update the numbers).&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;p&lt;/kbd&gt; will past &lt;code&gt;143&lt;/code&gt; over the entire selection.&lt;/li&gt;&#xA;&lt;li&gt;Select again the pasted &lt;code&gt;143&lt;/code&gt; column.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;C-A&lt;/kbd&gt; will increment gradually the selection, giving you overall increment.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-15T16:14:49.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8252" PostTypeId="2" ParentId="8249" CreationDate="2016-06-15T16:29:00.713" Score="9" Body="&lt;p&gt;As of Vim 7.4.754+ you can use &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; in visual mode. See &lt;code&gt;:h v_CTRL-A&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However since you can not upgrade Vim you may want to look into &lt;a href=&quot;https://github.com/tpope/vim-speeddating&quot; rel=&quot;noreferrer&quot;&gt;speeddating.vim&lt;/a&gt; which does some visual incrementing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are &lt;a href=&quot;http://vimawesome.com/?q=visual%20increment&quot; rel=&quot;noreferrer&quot;&gt;other plugins&lt;/a&gt; that might work as well:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/deris/vim-visualinc&quot; rel=&quot;noreferrer&quot;&gt;visualinc&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/triglav/vim-visual-increment&quot; rel=&quot;noreferrer&quot;&gt;visual-increment.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Otherwise you need to use a macro or use visual mode and then use &lt;code&gt;:normal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm 132&amp;lt;c-v&amp;gt;&amp;lt;c-a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :norm&#xA;:h v_CTRL-A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2016-06-15T17:36:54.903" LastActivityDate="2016-06-15T17:36:54.903" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8253" PostTypeId="2" ParentId="8249" CreationDate="2016-06-15T16:46:29.953" Score="14" Body="&lt;p&gt;Visually select all the lines you want to increment, and do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\d\+/\=submatch(0) + 132&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does exactly what you describe. Visually selects a bunch of numbers, and adds a mathematical constant to each of them. If you leave of the &lt;code&gt;/g&lt;/code&gt; flag, it will only increment the first number on each line. This uses the &quot;expression register&quot;. To learn more, &lt;code&gt;:help &quot;=&lt;/code&gt; has much more useful info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you mentioned trying a macro, here's what you were probably missing from your macro. Add &lt;code&gt;gv&lt;/code&gt; to the beginning of your macro. This reselects your last visual selection. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqgv&amp;lt;C-a&amp;gt;q132@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note, I don't know if this works in 7.2, and since I don't have it installed I can't test it)&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-15T16:46:29.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8254" PostTypeId="2" ParentId="8249" CreationDate="2016-06-15T16:53:59.830" Score="2" Body="&lt;p&gt;A possible solution is to yank the number before and after the sequential break and let vim do the math for you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;C-a&amp;gt; :call CalculatedIncrement(@p, @o)&amp;lt;CR&amp;gt;&#xA;&#xA;function! CalculatedIncrement(first, second)&#xA;   if (a:first &amp;gt; a:second)&#xA;      exe 'normal! '. (a:first-a:second+1) .'^A'&#xA;   else&#xA;      exe 'normal! '. (a:second-a:first+1) .'^X'&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you can't just copy and paste this. You'll need to re-input &lt;code&gt;^A&lt;/code&gt; and &lt;code&gt;^X&lt;/code&gt; yourself with &lt;code&gt;&amp;lt;C-v&amp;gt;+&amp;lt;C-A&amp;gt;&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use this, yank the first number into buffer p: &lt;code&gt;&quot;pyiw&lt;/code&gt;, and the second number into o: &lt;code&gt;&quot;oyiw&lt;/code&gt;. Then just visually select the lines you want to change and press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-06-15T17:10:42.377" LastActivityDate="2016-06-15T17:10:42.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8255" PostTypeId="2" ParentId="7587" CreationDate="2016-06-15T17:09:21.130" Score="0" Body="&lt;p&gt;If you use syntax/tex.vim v96 (available at &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX&quot; rel=&quot;nofollow&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX&lt;/a&gt;) then the errant highlighting is fixed.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2016-06-15T17:09:21.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8256" PostTypeId="1" CreationDate="2016-06-15T17:15:47.817" Score="6" ViewCount="258" Body="&lt;p&gt;When saving a session with &lt;code&gt;:mksession&lt;/code&gt; and &lt;code&gt;source&lt;/code&gt;ing it back, I noticed that alternate files (accessed via &lt;code&gt;C-^&lt;/code&gt;) are not persisted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The docs don't mention anything about persisting alternate files. Is there a way/workaround/hack to do so?&lt;/p&gt;&#xA;" OwnerUserId="7318" LastEditorUserId="2920" LastEditDate="2016-06-15T18:39:21.453" LastActivityDate="2016-06-21T22:16:22.307" Title="Make Vim sessions save alternate files" Tags="|sessions|alternate-file|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8257" PostTypeId="1" CreationDate="2016-06-15T17:23:20.910" Score="5" ViewCount="222" Body="&lt;p&gt;I'd like to be able to view the last n commands, similar to the &lt;code&gt;history&lt;/code&gt; command in bash, and then be able to execute the nth command similar to the way it is done in bash by using &lt;code&gt;!&amp;lt;command number&amp;gt;&lt;/code&gt; is there an equivalent to this in vim?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="205" LastEditDate="2016-06-16T17:00:42.023" LastActivityDate="2019-10-29T17:58:23.917" Title="Equivalent of !n in bash in vim for ex commands?" Tags="|ex-mode|command-history|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8258" PostTypeId="1" AcceptedAnswerId="40046" CreationDate="2016-06-15T17:25:50.863" Score="6" ViewCount="1746" Body="&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt;: I am doing more and more stuff directly from inside Neovim, and less and less from the terminal or even the terminal emulator. So instead of going to the desired directory to work in, and then starting Neovim, I prefer to just start Neovim, and then change to the desired directory. This next part is a bit of a tangent so you can skip to the next paragrapah if you just want the important details, but I know people tend to want to know why I am doing things a certain way so they can potentially suggest a better way. I do this because I will often need to change to different directories anyway multiple times at different points after I start working in Neovim. This way I don't have to close Neovim and open it again from another directory, or else start another instance of Neovim and then not be able to yank and put between them and have to keep track of which running Neovim instance is for what. In order to make it easier to work with a single Neovim instance and change directories, I do 2 things. I have NERDTree setup so that changing the current working directory in Neovim also changes the tree root in NERDTree, and vice versa. I also create commands to quickly navigate to different commonly used directores. Think of these like aliases. These all start with &lt;code&gt;:C&lt;/code&gt;. For example if I want to work on my vim-project-tags plugin, I enter the command &lt;code&gt;:Cproj&lt;/code&gt; and this will change to the directory where that code is.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;: When I first start Neovim, the current buffer is not pointed at any file. If I run the vim-fugitive command &lt;code&gt;:G&lt;/code&gt; this only works if the directory I started Neovim in has a git repository. So far this is fine. The problem comes in when I then change to a different working directory from inside Neovim, and then run the &lt;code&gt;:G&lt;/code&gt; command. At this point, the command is still associated with the directory I started Neovim in, not the current working directory. This works the same way in regular Vim. It doesn't matter to me at this point if I previously had a buffer open to a certain file and this still exists or not. I still want fugitive to use the current working directory even in that case. I'm not saying I want fugitive to become working directory based in stead of buffer based. I'm saying I want it to use the last changed of the two, either I opened a buffer to a different file, or I changed the working directory.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: How do I get vim-fugitive to base its commands on the current working directory when the current buffer is not pointed at a file?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Further Thoughts&lt;/strong&gt;: I know I could just start editing a file from that project, and then vim-fugitive will know which repository to work with. But that is precisely what I am trying to avoid. For me, one of the main appeals of Vim/Neovim is you can do micro-optimizations for everything about your workflow. I don't want to have to change to the correct directory and open a file from it before I can work with vim-fugitive because it is less steps to just change to that directory and then start working with it. I realize that I could accomplish this in the same number of steps by somehow opening the desired file without changing to that directory first, and then working with vim-fugitive, but that would be harder to accomplish and less useful for me. It is easier to edit the files of choice when the current working directory is the project root directory, and this makes working with that project much easier in lots of ways. Alternatively, I could make the command/alias I use to change to the directory of choice also open some kind of default/index file for that project in addition to changing to that directory, but that is not ideal for me. I would have to decide which file is the default/index file for each project. Having it automatically open that file would typically be mentally distracting and then I would have one more buffer I need to delete at some point if I don't want to work with it. Also, there would be times that I change to the directory of choice in a different way, such as navigating around with NERDTree.&lt;/p&gt;&#xA;" OwnerUserId="1410" LastEditorUserId="1410" LastEditDate="2023-02-04T15:21:05.567" LastActivityDate="2023-02-04T21:35:33.347" Title="Make vim-fugitive care about the current working directory when a file is not being edited" Tags="|plugin-fugitive|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="8259" PostTypeId="1" AcceptedAnswerId="8260" CreationDate="2016-06-15T17:31:58.987" Score="6" ViewCount="672" Body="&lt;p&gt;Reading the documentation about alternate file, I thought I could manipulate &lt;code&gt;#&lt;/code&gt; like a global variable, but it's not the case. I was thinking doing something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;#='/path/to/alternate/file'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is not possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you set manually the alternate file?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="2920" LastEditDate="2016-06-15T17:45:32.027" LastActivityDate="2016-06-15T17:45:32.027" Title="How to set manually the alternate file" Tags="|register|multiple-files|alternate-file|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8260" PostTypeId="2" ParentId="8259" CreationDate="2016-06-15T17:41:22.013" Score="8" Body="&lt;p&gt;The alternate file is stored in a register, &lt;code&gt;&quot;#&lt;/code&gt;. Change you line to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @#='/path/to/alternate/file'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h registers&#xA;:h quote#&#xA;:h :let-@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-06-15T17:41:22.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8262" PostTypeId="1" AcceptedAnswerId="8263" CreationDate="2016-06-16T05:54:28.787" Score="1" ViewCount="329" Body="&lt;p&gt;Is there any way to jump to a file / folder starting with a given set of characters?&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-06-16T09:59:45.347" LastActivityDate="2016-06-16T09:59:45.347" Title="explore, netrw: How to navigate to a file / folder starting with &quot;abc&quot;" Tags="|netrw|filesystem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8263" PostTypeId="2" ParentId="8262" CreationDate="2016-06-16T06:06:09.177" Score="2" Body="&lt;p&gt;Regular search works fine, something went wrong last time when I tried to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/^folder_name&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-06-16T06:06:09.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8264" PostTypeId="1" AcceptedAnswerId="8266" CreationDate="2016-06-16T06:42:50.630" Score="1" ViewCount="1373" Body="&lt;p&gt;I guess this is not a problem for Linux users, but in Windows disks have drive letters. How can I switch drive letters in netrw on Window?&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="1841" LastEditDate="2016-06-16T07:51:17.337" LastActivityDate="2016-06-16T07:51:17.337" Title="Changing of disk partition with netrw on Windows" Tags="|microsoft-windows|netrw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8265" PostTypeId="1" CreationDate="2016-06-16T07:35:14.820" Score="3" ViewCount="193" Body="&lt;p&gt;For regular match groups, the last defined group will be the first to match.&#xA;When using match groups added to a cluster, I can't determine what the match order is. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match allgroupcol3 &quot;\%3c.\{10}&quot; contained   &quot; match 10 chars in col 3-12&#xA;syn match klgroupcol3 &quot;\%3c\s*kl\zs.\{10}&quot; contained   &quot; match 10 chars in col 3-12, must start with 'kl'&#xA;&#xA;syn cluster colCluster add=allgroupcol3&#xA;syn cluster colCluster add=klgroupcol3 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;allgroupcol3&lt;/code&gt; always matches, even if something in cols 3-12 starts with 'kl'. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the order of matches inside a cluster?&lt;/p&gt;&#xA;" OwnerUserId="8035" LastEditorUserId="1821" LastEditDate="2016-06-16T09:57:54.220" LastActivityDate="2016-06-16T09:57:54.220" Title="Order of matches in syn-cluster" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8266" PostTypeId="2" ParentId="8264" CreationDate="2016-06-16T07:48:26.193" Score="3" Body="&lt;p&gt;According to &lt;a href=&quot;https://stackoverflow.com/q/23161254/4194289&quot;&gt;this answer&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e D:\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will open the D:\ drive in a netrw buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still according to the answer, you can use &lt;code&gt;:cd D:\&lt;/code&gt; to change the current directory and then use your favorite netrw command.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-06-16T07:48:26.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8267" PostTypeId="2" ParentId="8256" CreationDate="2016-06-16T08:01:57.373" Score="2" Body="&lt;p&gt;Since there is no option to do this directly, you can hack around like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MkSession(filename)&#xA;  execute 'mksession! '.a:filename&#xA;&#xA;  let l:alternate = fnameescape(expand('#'))&#xA;&#xA;  if l:alternate != ''&#xA;    call system('echo &quot;let @#=\&quot;'.l:alternate.'\&quot;&quot; &amp;gt;&amp;gt; '.a:filename)&#xA;  endif&#xA;&#xA;endfunction&#xA;&#xA;command! -nargs=1 MkSession call MkSession(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function will add the alternate file setting in the session, so when the session is loaded up, the alternate file is restored. (thanks to &lt;a href=&quot;https://vi.stackexchange.com/a/8260/1821&quot;&gt;this answer&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be able to use it &lt;em&gt;as is&lt;/em&gt; although I'm not sure it's 100% stable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:MkSession session.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-06-16T08:13:16.970" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8268" PostTypeId="2" ParentId="8207" CreationDate="2016-06-16T08:27:27.063" Score="0" Body="&lt;p&gt;For reference, and maybe further research:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a long discussion with &lt;a href=&quot;https://vi.stackexchange.com/users/7878/antony&quot;&gt;antony&lt;/a&gt; we found out that this behavior is enable in compatible mode but not in nocompatible mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e. the code will highlight when called from &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but not from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -Nu NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Moreover, we found that setting &lt;code&gt;hls&lt;/code&gt; and &lt;code&gt;nohls&lt;/code&gt; one after the other will make the highlight work for both &lt;code&gt;compatible&lt;/code&gt; and &lt;code&gt;nocompatible&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. this code correctly highlight for both &lt;code&gt;compatible&lt;/code&gt; and &lt;code&gt;nocompatible&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Highlight()&#xA;  let @/ = 'word'&#xA;  set hlsearch&#xA;endfunction&#xA;&#xA;let @/=''&#xA;set hls&#xA;set nohls&#xA;&#xA;&quot; source %&#xA;&quot; call Highlight()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-06-16T08:27:27.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8269" PostTypeId="1" AcceptedAnswerId="8270" CreationDate="2016-06-16T09:36:27.593" Score="2" ViewCount="254" Body="&lt;p&gt;I'm using the Airline plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I show the &lt;code&gt;+&lt;/code&gt; register in Airline ?&lt;/p&gt;&#xA;" OwnerUserId="6893" LastEditorUserId="2313" LastEditDate="2016-06-16T13:48:57.460" LastActivityDate="2016-06-16T13:48:57.460" Title="How can I show the + register in Airline?" Tags="|vimscript|vimrc|plugin-airline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8270" PostTypeId="2" ParentId="8269" CreationDate="2016-06-16T09:52:03.660" Score="3" Body="&lt;p&gt;(not using Airline, guessing from the documentation)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add the following to your status line and it will show the content of the register +:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{@+}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you have different choice in airline (also guessing from the doc):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;add_statusline_func&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let w:airline_section_b = '%{@+}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;airline-sections&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_section_c = airline#section#create(['%{@+}'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-16T09:52:03.660" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8271" PostTypeId="1" AcceptedAnswerId="8272" CreationDate="2016-06-16T10:25:00.200" Score="5" ViewCount="113" Body="&lt;p&gt;I am trying to use the command line window in a vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the experiment I have with is not good and I am not able to achieve the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! q:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should open the command history buffer, but the &lt;code&gt;normal&lt;/code&gt; doc states:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{commands} should be a complete command.  If&#xA;{commands} does not finish a command, the last one&#xA;will be aborted as if &amp;lt;Esc&amp;gt; or &amp;lt;C-C&amp;gt; was typed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you know if there is a way around this limitation?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-16T11:03:17.430" Title="Open command window dynamically" Tags="|command-line|command-history|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8272" PostTypeId="2" ParentId="8271" CreationDate="2016-06-16T11:03:17.430" Score="6" Body="&lt;p&gt;You could use the &lt;code&gt;feedkeys()&lt;/code&gt; function to add the keys &lt;code&gt;q:&lt;/code&gt; inside the typeahead buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call feedkeys('q:', 'in')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;feedkeys()&lt;/code&gt; waits for one argument (the keys you want to add), and a 2nd optional one which contains some flags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the previous command, 2 flags are used &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;n&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;i&lt;/code&gt; means that the keys won't be appended to the typeahead buffer but inserted (in other words they should be typed before the already present keys, not after). Maybe you won't need this flag, I don't know, but the few times where I needed &lt;code&gt;feedkeys()&lt;/code&gt;, I needed &lt;code&gt;i&lt;/code&gt; so I thought it would be a good idea to mention it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;n&lt;/code&gt; means that the keys won't be remapped. It's similar to the bang after &lt;code&gt;:normal!&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-06-16T11:03:17.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8273" PostTypeId="2" ParentId="8257" CreationDate="2016-06-16T11:05:28.483" Score="1" Body="&lt;p&gt;This is highly hacky but should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReExecute(historyNumber)&#xA;  &quot; Open the command window&#xA;  call feedkeys('q:', 'in')&#xA;&#xA;  &quot; Jump to the desired line&#xA;  call feedkeys(a:historyNumber.'gg', 'tn')&#xA;&#xA;  &quot; Execute the command&#xA;  call feedkeys(&quot;\&amp;lt;CR&amp;gt;&quot;, 'tn')&#xA;endfunction&#xA;&#xA;command! -nargs=1 R call ReExecute(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now use &lt;code&gt;R 2&lt;/code&gt; to replay the command at line 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for &lt;a href=&quot;https://vi.stackexchange.com/users/6960/user9433424&quot;&gt;user9433424&lt;/a&gt; for &lt;a href=&quot;https://vi.stackexchange.com/a/8272/1821&quot;&gt;his answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; It seems a little hard to use like this, because you execute the command without seeing it, hence this little modification:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReExecute(historyNumber)&#xA;  &quot; Open the command window&#xA;  call feedkeys('q:', 'in')&#xA;&#xA;  &quot; Jump to the desired line&#xA;  call feedkeys(a:historyNumber.'gg', 'tn')&#xA;&#xA;  &quot; Copy the current command and quit&#xA;  call feedkeys(&quot;y$:q\&amp;lt;CR&amp;gt;&quot;, 'tn')&#xA;&#xA;  &quot; Add the value into the command line&#xA;  call feedkeys(':'.@&quot;, 'tn')&#xA;endfunction&#xA;&#xA;command! -nargs=1 R call ReExecute(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This populate your command line with the nth last command, which is more what you asked in the first place anyway.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-06-16T11:38:41.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8274" PostTypeId="1" AcceptedAnswerId="8277" CreationDate="2016-06-16T13:04:12.740" Score="2" ViewCount="865" Body="&lt;p&gt;I have a function that depends on the character under the cursor : if it's a &lt;code&gt;)&lt;/code&gt;, then the function does nothing ; if it's not, the function adds a &lt;code&gt;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Ket()&#xA;   let char = getline(&quot;.&quot;)[col('.')-1]&#xA;   if char != ')'&#xA;      execute &quot;normal! a)\&amp;lt;esc&amp;gt;&quot;&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I call it &lt;em&gt;from normal mode&lt;/em&gt;, using &lt;code&gt;:call Ket()&lt;/code&gt;, &lt;em&gt;it works fine&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I have it remapped &lt;em&gt;from insert mode&lt;/em&gt;, as follows :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap ) &amp;lt;Esc&amp;gt;l:call Ket()&amp;lt;CR&amp;gt;a&lt;/code&gt;. This mapping should (from my understanding) :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;escape insert mode with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;go one character to the right with &lt;code&gt;l&lt;/code&gt; (because escape to normal mode moves the cursor to the left), &lt;/li&gt;&#xA;&lt;li&gt;call my &lt;code&gt;Ket()&lt;/code&gt; function,&lt;/li&gt;&#xA;&lt;li&gt;get back to insert mode (&lt;code&gt;a&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I am in insert mode, and my cursor is on a &lt;code&gt;)&lt;/code&gt; character, then I get what I expect by pressing &lt;kbd&gt;)&lt;/kbd&gt; : the cursor moves to the right, and I end up in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if my cursor is on any &lt;em&gt;other&lt;/em&gt; character, pressing &lt;kbd&gt;)&lt;/kbd&gt; only &lt;em&gt;escapes insert mode&lt;/em&gt;, as if I had pressed &lt;kbd&gt;Esc&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7128" LastActivityDate="2016-06-16T13:56:37.567" Title="Function does not work when called as from a mapping" Tags="|vimscript|insert-mode|normal-mode|functions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8275" PostTypeId="1" CreationDate="2016-06-16T13:17:47.163" Score="9" ViewCount="156" Body="&lt;p&gt;The &lt;code&gt;.&lt;/code&gt; command is super useful for quickly doing the last primitive action again. However, any other modification I do in between will override this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to recall&amp;amp;repeat older changes without having to define them as a macro, similar to how the &lt;code&gt;&quot;2&lt;/code&gt; buffer always contains the pænultimate yank?&lt;/p&gt;&#xA;" OwnerUserId="6882" LastActivityDate="2016-06-16T16:21:28.123" Title="Is there a way to repeat the pænultimate (or older) change?" Tags="|repeated-commands|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8276" PostTypeId="1" AcceptedAnswerId="8278" CreationDate="2016-06-16T13:49:09.163" Score="1" ViewCount="46" Body="&lt;p&gt;Following answer I got &lt;a href=&quot;https://vi.stackexchange.com/a/7977/6946&quot;&gt;there&lt;/a&gt; to allow &lt;kbd&gt;&gt;&gt;&lt;/kbd&gt; to indent, I edited my &lt;code&gt;.vimrc&lt;/code&gt; to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set shiftwidth=2&#xA;:set autoindent&#xA;:set smartindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But now when I copy/paste (via putty), it indents incrementally, by inserting unwanted &quot;tabs&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I copy&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;&#xA;int main() {&#xA;    std::cout &amp;lt;&amp;lt; &quot; Hello Vi and Vim!&quot;;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and when I paste in edit mode, it indent incrementally and it becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;&#xA;    int main() {&#xA;            std::cout &amp;lt;&amp;lt; &quot; Hello Vi and Vim!&quot;;&#xA;                    return 0;&#xA;                        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It won't happen if I remove my &lt;code&gt;.vimrc&lt;/code&gt;. Does it ring any bells?&lt;/p&gt;&#xA;" OwnerUserId="6946" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-06-16T15:09:21.470" Title="Indenting now add suspicious chars to my files when pasting" Tags="|vimrc|cut-copy-paste|indentation|putty|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8277" PostTypeId="2" ParentId="8274" CreationDate="2016-06-16T13:56:37.567" Score="2" Body="&lt;p&gt;Instead of leaving insert mode you could try to do the same without the need for a function (because in this case it's a simple case):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; )  strpart(getline('.'), col('.')-1, 1) == &quot;)&quot; ? &quot;\&amp;lt;Right&amp;gt;&quot; : &quot;)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; )  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will insert the result of the mapping as instead of )&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strpart(getline('.'), col('.')-1, 1) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;get the current character under cursor&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;== &quot;)&quot; ? &quot;\&amp;lt;Right&amp;gt;&quot; : &quot;)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if it's a &lt;code&gt;)&lt;/code&gt; insert the right key, if not, insert a &lt;code&gt;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to keep your function, you can do it as well like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Ket()&#xA;  if strpart(getline('.'), col('.')-1, 1) == &quot;)&quot; &#xA;    return &quot;\&amp;lt;Right&amp;gt;&quot; &#xA;  else&#xA;    return  &quot;)&quot;&#xA;  endif&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; ) Ket()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-16T13:56:37.567" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8278" PostTypeId="2" ParentId="8276" CreationDate="2016-06-16T13:59:16.760" Score="4" Body="&lt;p&gt;Yup, you should set the &lt;code&gt;paste&lt;/code&gt; option to prevent indentation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set paste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you are done, you should then set &lt;code&gt;nopaste&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens is that the pasted file is already indented but Vim try to indent it as well, the &lt;code&gt;paste&lt;/code&gt; option prevent this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also set a key to turn &lt;code&gt;paste&lt;/code&gt; on and off with, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set pastetoggle=&amp;lt;C-P&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="8044" LastEditDate="2016-06-16T15:09:21.470" LastActivityDate="2016-06-16T15:09:21.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8279" PostTypeId="1" AcceptedAnswerId="8280" CreationDate="2016-06-16T14:50:16.673" Score="8" ViewCount="367" Body="&lt;p&gt;I want to be notified when a line is too long to fit in the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I have this in &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wrap&#xA;let &amp;amp;showbreak = '        +++ '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to change that to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nowrap&#xA;let &amp;amp;somesetting = ' &amp;gt; '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Such that &lt;code&gt;somesetting&lt;/code&gt; tells vim to put a &lt;code&gt;&amp;gt;&lt;/code&gt; on the right margin of any line is too long to be fully displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I coulda sworn vim could do this but I can't find the setting.&lt;/p&gt;&#xA;" OwnerUserId="8044" LastEditorUserId="24" LastEditDate="2016-06-17T16:17:45.670" LastActivityDate="2016-06-17T16:17:45.670" Title="How do I configure vim to show a character when a line is too long to be displayed?" Tags="|vimrc|line-breaks|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8280" PostTypeId="2" ParentId="8279" CreationDate="2016-06-16T14:58:37.627" Score="10" Body="&lt;p&gt;You should the this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set listchars+=precedes:&amp;lt;,extends:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ref:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h wrap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h 'listchars'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-16T14:58:37.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8282" PostTypeId="2" ParentId="8275" CreationDate="2016-06-16T16:21:28.123" Score="6" Body="&lt;p&gt;No, this is not possible. After some searching on the web, it appears other people have asked about this very feature before on other stack exchange sites:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/36719/repeat-the-nth-last-command-in-vim&quot;&gt;Repeat the nth last command in vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And even on the vim mailing group:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_use/CZ8KYt1i9BM&quot; rel=&quot;nofollow noreferrer&quot;&gt;History for dot operator&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Both of these say it is impossible. However, Bram Moolenaar (the author and maintainer of vim) is on that email thread, and while he didn't say that feature was possible, he did hint at the possibility of implementing it sometime eventually.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How about Vim keeping a list of the last N typed keys? &#xA;  Suppose there is a function keyhistory(1), where the argument is how far &#xA;  back you look. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;I wonder how that would be used in a plugin. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't know how high on his priority list this is (probably not very high), but I suppose you could sponsor vim and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/sponsor.html#vote-for-features&quot; rel=&quot;nofollow noreferrer&quot;&gt;vote for this feature&lt;/a&gt; if you &lt;em&gt;really&lt;/em&gt; want it.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2016-06-16T16:21:28.123" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8283" PostTypeId="1" CreationDate="2016-06-16T17:21:03.197" Score="3" ViewCount="1672" Body="&lt;p&gt;When saving a session with &lt;code&gt;:mksession&lt;/code&gt; and &lt;code&gt;:source&lt;/code&gt;ing it back, the content of &lt;code&gt;[No Name]&lt;/code&gt; unnamed buffers is lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like to sometimes write temporary throwaway code or notes on a unnamed or scratch buffer, for the length of my session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just like Sublime Text saves the content of &quot;untitled new tabs&quot; when quitting and reopening it, is there a way/workaround/hack/plugin to save the state of unnamed buffers in Vim?&lt;/p&gt;&#xA;" OwnerUserId="7318" LastEditorUserId="1841" LastEditDate="2016-06-17T14:04:07.903" LastActivityDate="2016-06-21T22:02:00.507" Title="Make Vim sessions save the content of unnamed buffers" Tags="|buffers|sessions|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8284" PostTypeId="2" ParentId="8283" CreationDate="2016-06-16T17:29:48.770" Score="2" Body="&lt;p&gt;&lt;strong&gt;Vim workarounds:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;write temporary notes/code in predefined system-wide or project-wide files (possibly with the help of some custom functions/mappings)&lt;/li&gt;&#xA;&lt;li&gt;use a Vim note-taking plugin&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In both cases notes are saved in files, so when reopening your session their content will not be lost. When starting a new unit of work, just erase the previous content of the files (possibly with some automation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;External workaround:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a dedicated external session management tool, like tmux (which also does a lot of other stuff that one would not necessarily care about). I eventually chose this solution and am happy with it. Not only does it save the state of my Vim, but also the state of all my other console tabs/windows.&lt;/p&gt;&#xA;" OwnerUserId="7318" LastEditorUserId="7318" LastEditDate="2016-06-21T22:02:00.507" LastActivityDate="2016-06-21T22:02:00.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8285" PostTypeId="1" AcceptedAnswerId="8288" CreationDate="2016-06-17T05:59:49.297" Score="10" ViewCount="7334" Body="&lt;p&gt;I know there is one way to search and replace variable occurrences across a source file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But is there any better way by which if I rename a variable at one place it gets renamed at other places as well without search and replace or substitute?&lt;/p&gt;&#xA;" OwnerUserId="5890" LastEditorUserId="1841" LastEditDate="2016-06-17T14:50:12.447" LastActivityDate="2018-03-10T12:46:36.083" Title="What is the best way to re-factor a variable name in vim?" Tags="|substitute|ide|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8286" PostTypeId="2" ParentId="8285" CreationDate="2016-06-17T06:18:46.053" Score="7" Body="&lt;p&gt;You can use a substitute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/original/replaced/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will &lt;code&gt;s&lt;/code&gt;ubstitute across the entire file (&lt;code&gt;%&lt;/code&gt;) &lt;code&gt;original&lt;/code&gt; by &lt;code&gt;replaced&lt;/code&gt;. And will replace multiple occurrences on the same line &lt;code&gt;g&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are not confident about automatically replacing, you can add the &lt;code&gt;c&lt;/code&gt; flag to ask for confirmation each time.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-17T06:26:58.360" LastActivityDate="2016-06-17T06:26:58.360" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8287" PostTypeId="1" AcceptedAnswerId="8289" CreationDate="2016-06-17T06:19:21.230" Score="9" ViewCount="3757" Body="&lt;p&gt;If I try to copy a word via this &lt;code&gt;yw&lt;/code&gt; – yank the current word and paste it to somewhere, it works but If I try to paste it somewhere else one more time old world gets lost with previous replaced word.&lt;/p&gt;&#xA;&lt;p&gt;I want to paste multiple times with the original yanked word.&lt;/p&gt;&#xA;" OwnerUserId="5890" LastEditorUserId="23502" LastEditDate="2023-03-01T06:06:22.227" LastActivityDate="2023-03-01T06:06:22.227" Title="Copy a word and paste the same word at multiple places in Vim" Tags="|cut-copy-paste|gvim|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8288" PostTypeId="2" ParentId="8285" CreationDate="2016-06-17T06:22:29.213" Score="16" Body="&lt;p&gt;You can just use the usual workflow &lt;code&gt;search&lt;/code&gt; and &lt;code&gt;replace&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/original&#xA;cwreplaced&#xA;n.n.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can take also advantage of the &lt;code&gt;gn&lt;/code&gt; motion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/original&amp;lt;CR&amp;gt;&#xA;cgnreplaced&amp;lt;ESC&amp;gt;&#xA;.....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;cgn&lt;/code&gt; will &lt;code&gt;c&lt;/code&gt;hange the &lt;code&gt;n&lt;/code&gt;ext matched pattern, so instead of using &lt;code&gt;n.n.&lt;/code&gt; to &lt;code&gt;go to next&lt;/code&gt; and &lt;code&gt;repeat&lt;/code&gt; you can just &lt;code&gt;..&lt;/code&gt; which means &lt;code&gt;replace next&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gn&lt;/code&gt; means &quot;search for next occurence and start a visual selection over it&quot;, you can read more about it on the doc: &lt;code&gt;:h gn&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-17T06:27:59.007" LastActivityDate="2016-06-17T06:27:59.007" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8289" PostTypeId="2" ParentId="8287" CreationDate="2016-06-17T06:26:30.953" Score="9" Body="&lt;p&gt;You should use the register &lt;code&gt;0&lt;/code&gt;. It contains the last yanked text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt; use the unnamed register &lt;code&gt;&quot;&quot;&lt;/code&gt; to store all modified text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the numbered registers &lt;code&gt;&quot;0&lt;/code&gt; contains the previously yanked text and only that. You can use :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;0p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With confidence it will past the last yanked text.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-17T06:26:30.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8290" PostTypeId="1" CreationDate="2016-06-17T10:04:14.720" Score="1" ViewCount="68" Body="&lt;p&gt;I want to escape in my file some of the &lt;code&gt;&quot;&lt;/code&gt; by &lt;code&gt;\&quot;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I want to transform &lt;code&gt;foo&quot;bar&quot;xyz&quot;&lt;/code&gt; to &lt;code&gt;foo\&quot;bar\&quot;xyz\&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Attempt 1 :&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;search for &lt;code&gt;&quot;&lt;/code&gt; (typing &lt;code&gt;/&quot;&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;create my macro (typing &lt;code&gt;qai\&lt;/code&gt;, &lt;code&gt;Esc&lt;/code&gt;, &lt;code&gt;RightArrow&lt;/code&gt;, &lt;code&gt;nq&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;use my macro with &lt;code&gt;@a&lt;/code&gt;. Unfortunately, this last step failed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Attempt 2 :&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;search for &lt;code&gt;&quot;&lt;/code&gt; (typing &lt;code&gt;/&quot;&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;create my macro (typing &lt;code&gt;qai\&lt;/code&gt;, &lt;code&gt;Esc&lt;/code&gt;, &lt;code&gt;l&lt;/code&gt;, &lt;code&gt;nq&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;use my macro with &lt;code&gt;@a&lt;/code&gt;. Works like a charm.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Question :&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Why this macro fails when using arrows, and works perfectly when using &lt;code&gt;l&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the first time it happens to me, so my guess is that it has to do something with vim interpreting the &lt;code&gt;\&lt;/code&gt; to actually escape something in the macro itself, but I don't know how to check my assertion. &lt;/p&gt;&#xA;" OwnerUserId="8059" LastEditorUserId="1821" LastEditDate="2016-06-17T16:38:50.783" LastActivityDate="2016-06-17T16:38:50.783" Title="Macro fails using arrows" Tags="|macro|" AnswerCount="0" CommentCount="5" ClosedDate="2016-06-18T04:28:25.367" ContentLicense="CC BY-SA 3.0" />
  <row Id="8291" PostTypeId="1" AcceptedAnswerId="8293" CreationDate="2016-06-17T11:14:39.763" Score="3" ViewCount="993" Body="&lt;p&gt;Just like the topic says; is it possible to add a certain text string in the beginning of a file if I create a certain file type?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I create a random Python file with &lt;code&gt;vim random.py&lt;/code&gt;. Can I configure my vim to automatically add &lt;code&gt;#!/usr/bin/python&lt;/code&gt; at line 1?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a standard vim installation without any plugins or anything, I didn't even have a .vimrc in my /home so I manually created it. As you might have imagined by now, I am very new to using vim so my apologies if this is a dumb question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;https://vi.stackexchange.com/questions/6358/how-do-i-add-skeleton-text-to-new-vim-files&quot;&gt;How do I add skeleton text to new vim files?&lt;/a&gt; but I am not sure if that is what I am looking for, or how to do it. If it turns out that this question is a duplicate of the question linked, I will try to look it up furthermore once I get home from work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for all the answers and I am sorry that this question indeed was a duplicate.&lt;/p&gt;&#xA;" OwnerUserId="8062" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-06-17T12:33:25.177" Title="Is it possible to add a specific text string in the beginning of creating a certain file type?" Tags="|vimrc|filetype|filetype-python|" AnswerCount="3" CommentCount="2" ClosedDate="2016-06-18T04:27:56.240" ContentLicense="CC BY-SA 3.0" />
  <row Id="8292" PostTypeId="2" ParentId="8291" CreationDate="2016-06-17T11:23:47.780" Score="3" Body="&lt;p&gt;Yup the question you linked should have helped you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile *.py normal! ggI#!/bin/python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your vimrc will create an autocomd which will trigger when you create a new file &lt;code&gt;BufNewFile&lt;/code&gt; of the filetype python &lt;code&gt;*.py&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When It is trigger it will go to the first line of the file &lt;code&gt;gg&lt;/code&gt;, start insert mode &lt;code&gt;I&lt;/code&gt; and add the shebang line&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the autocommand triggers on &lt;code&gt;BufNewFile&lt;/code&gt; the file is empty since it has just been created, the &lt;code&gt;gg&lt;/code&gt; is not necessary. Also using &lt;code&gt;i&lt;/code&gt; instead of &lt;code&gt;I&lt;/code&gt; will not change anything as the line is empty.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-06-17T12:11:51.600" LastActivityDate="2016-06-17T12:11:51.600" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8293" PostTypeId="2" ParentId="8291" CreationDate="2016-06-17T11:24:39.437" Score="1" Body="&lt;p&gt;You can accomplish it by placing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile *.py norm i#!/usr/bin/python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your &lt;code&gt;.vimrc&lt;/code&gt; file.  This should insert the text at the beginning of the first file, whenever you open a non-existing file with the file extension &lt;code&gt;py&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The part &lt;code&gt;norm i#!/usr/bin/python&lt;/code&gt; is simply commands which are executed when the file is opened.  As it is a new file, the cursor vil automatically be on the first line, which is empty.  Then &lt;code&gt;norm&lt;/code&gt; treats the rest of the commands as you where in normal mode, which means that &lt;code&gt;i&lt;/code&gt; takes you to insert mode and, when in insert mode &lt;code&gt;#!/usr/bin/python&lt;/code&gt; simply types these characters.&lt;/p&gt;&#xA;" OwnerUserId="1498" LastActivityDate="2016-06-17T11:24:39.437" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8294" PostTypeId="2" ParentId="8291" CreationDate="2016-06-17T11:25:30.250" Score="3" Body="&lt;p&gt;You can use the following autocommand&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile *.py call append(0,'#!/bin/python')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Have a look at &lt;code&gt;:h append()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-17T11:25:30.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8295" PostTypeId="1" AcceptedAnswerId="8297" CreationDate="2016-06-17T13:07:54.857" Score="3" ViewCount="282" Body="&lt;p&gt;When creating an operator pending mapping in vim, it is possible make the mapping work on an arbitrary (consecutive) piece of text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for a way to abort the operation. For the case of deletion (e.g. &lt;code&gt;di)&lt;/code&gt;) this can be done by having the mapping do nothing. The cursor will not be moved and nothing will be deleted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when using a change command (e.g. &lt;code&gt;ci)&lt;/code&gt;) one is left in insert mode. To illustrate a bit more the following commands can be run in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:function! Foo()&#xA;  :return&#xA;:endfunction&#xA;:onoremap i) :call Foo()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By issuing &lt;code&gt;ci)&lt;/code&gt; in normal mode on the text &lt;code&gt;(bar)&lt;/code&gt; it is immediately clear that one is left in insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question now is whether it is possible to change the function in such a way that the mapping will not have any effect. In practice the function will of course use logic to determine whether it should abort or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For what it's worth, I'm running gVim 7.4 32-bit on windows 7. The end goal of this particular mapping is to remap &lt;code&gt;i)&lt;/code&gt; and the like such that they will select inside the next set of parenthesis if the cursor is not currently inside any parenthesis. If anyone has a suggestion for doing this some other way, it would of course be welcome, but I would still be interested in the answer to my original question.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastEditorUserId="2920" LastEditDate="2016-06-17T16:10:03.617" LastActivityDate="2016-06-17T16:10:03.617" Title="Abort an operating pending mapping" Tags="|vimscript|map-operator|object-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8296" PostTypeId="2" ParentId="8283" CreationDate="2016-06-17T13:48:31.473" Score="6" Body="&lt;p&gt;You could use the following function. It is extremely hacky and I haven't tested&#xA;it plenty but it seems to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to create a command &lt;code&gt;:Mksession&lt;/code&gt; which will work like the original&#xA;&lt;code&gt;:mksession&lt;/code&gt; but will also save the unnamed buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note that I had some inspiration from &lt;a href=&quot;https://vi.stackexchange.com/a/8267/1841&quot;&gt;this&#xA;answer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do so it will call a function which does the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First handle the argument so that you can call the command with of without a filename as argument&lt;/li&gt;&#xA;&lt;li&gt;Execute the original &lt;code&gt;:mksession&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use a list which will contain the content of the unnamed buffer&lt;/li&gt;&#xA;&lt;li&gt;Use a command which will test the name of each buffers. When the name is empty, &lt;code&gt;getline()&lt;/code&gt; is used to add the content of the buffer to the list of contents.&lt;/li&gt;&#xA;&lt;li&gt;Finally for each set of line, instructions are added to the session file to create a new buffer and put the content into it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Add theses lines to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MkSession(...)&#xA;    &quot; Handle the argument&#xA;    if empty(a:000)&#xA;        let filename = &quot;Session.vim&quot;&#xA;    else&#xA;        let filename = fnameescape(a:1)&#xA;    endif&#xA;&#xA;    &quot; Create the session file according to the argument passed&#xA;    execute 'mksession! ' . filename&#xA;&#xA;    &quot; The list containing the lines on the unnmaed buffers&#xA;    let noname_buffers = []&#xA;&#xA;    &quot; Get the lines of all the unnamed buffers in the list&#xA;    execute &quot;silent! bufdo \| if expand('%')=='' \| call add(noname_buffers, getline(1, '$')) \| endif&quot;&#xA;&#xA;    &quot; For each set of lines&#xA;    &quot; Add into the session file a line creating an empty buffer&#xA;    &quot; and a line adding its content&#xA;    for lines in noname_buffers&#xA;        call system('echo &quot;enew&quot; &amp;gt;&amp;gt; '.filename)&#xA;        call system('echo &quot;call append(0, [\&quot;'. join(lines, '\&quot;,\&quot;') .'\&quot;])&quot; &amp;gt;&amp;gt;'. filename)&#xA;    endfor&#xA;&#xA;endfunction&#xA;&#xA;command! -nargs=? Mksession call MkSession(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then simply call the command like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Mksession&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or with a file name&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Mksession mysession.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @DJ McMayhem pointed it out in the comments you can even add this line to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap mksession Mksession&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would make ̀ :mksession&lt;code&gt;(without capitalized&lt;/code&gt;m&lt;code&gt;) behave like the&lt;/code&gt;:Mksession&lt;code&gt;command we just defined (with capitalized&lt;/code&gt;M`). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mentioned it because for some user it could be seen as an advantage. However I would not recommend to use it: it hides the fact that you're using a custom function and if a side-effect appears it could add some difficulty to debug a problem. &lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-06-18T14:35:00.577" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8297" PostTypeId="2" ParentId="8295" CreationDate="2016-06-17T14:07:11.240" Score="3" Body="&lt;p&gt;This works for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:function! Foo()&#xA;  call feedkeys(&quot;\&amp;lt;esc&amp;gt;&quot;)&#xA;  return&#xA;:endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works since you can hit &lt;kbd&gt;esc&lt;/kbd&gt; in operator pending mode (for example, &lt;code&gt;c&amp;lt;esc&amp;gt;&lt;/code&gt;), and it will not complete the operator.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-17T14:07:11.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8298" PostTypeId="1" AcceptedAnswerId="8300" CreationDate="2016-06-17T17:47:15.423" Score="4" ViewCount="1023" Body="&lt;p&gt;I am trying to use KBC Poker 3 keyboard which combines `,&lt;code&gt;~&lt;/code&gt; and &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; as one key with Vim and wondering if it is possible to use the quick press of the escape key as char '`', and long press of escape key (longer than 500ms) as escape key.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible?&lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="3050" LastEditDate="2016-06-17T17:58:32.897" LastActivityDate="2016-06-17T19:02:48.507" Title="Use the same key for `, ~, esc" Tags="|keyboard-layout|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8299" PostTypeId="2" ParentId="8258" CreationDate="2016-06-17T18:57:03.200" Score="2" Body="&lt;p&gt;Here is a hack/workaround I am using in my config file. It is not an ideal solution, but it is the best I can come up with until someone hopefully makes an autocmd event for the current working directory changing. I created a custom function that changes the current working directory. I try to use that function to change the directory as much as possible instead of the built in way. This relies in internal code from Fugitive, so it may stop working if the Fugitive code changes.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! ChangeDirectoryCustom(dir_path)&#xA;    let before_dir= getcwd()&#xA;    execute 'cd '.fnameescape(a:dir_path)&#xA;    let after_dir= getcwd()&#xA;    if before_dir !=# after_dir&#xA;        &amp;quot; place custom current directory changed event handler code here&#xA;        &amp;quot; Make vim-fugitive use the new current directory repository if there is no current file&#xA;        let current_file_name= expand('%')&#xA;        if current_file_name == ''&#xA;            if exists('b:git_dir')&#xA;                unlet b:git_dir&#xA;            endif&#xA;            call FugitiveDetect(getcwd())&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After many years, I'm now realizing this approach doesn't make any sense. It doesn't change what git directory fugitive works with, it changes what git directory fugitive associates with the current buffer even though it could be for a file from a different/irrelevant directory/git repo.&lt;/p&gt;&#xA;" OwnerUserId="1410" LastEditorUserId="1410" LastEditDate="2023-02-04T20:53:50.557" LastActivityDate="2023-02-04T20:53:50.557" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8300" PostTypeId="2" ParentId="8298" CreationDate="2016-06-17T19:02:48.507" Score="4" Body="&lt;p&gt;As far as I know there is no built-in support for mappings that change based on the time you hold the key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But as the problematic key is &lt;kbd&gt;Esc&lt;/kbd&gt;, you have some good alternatives:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt;, which works by default (as explained in &lt;a href=&quot;http://vimhelp.appspot.com/intro.txt.html#key-codes&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help key-codes&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;       escape          CTRL-[   27 *escape* *&amp;lt;Esc&amp;gt;*&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As &lt;kbd&gt;Esc&lt;/kbd&gt; is a heavily used key in Vim, many people use mappings for it, such as &lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;, &lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;, or &lt;kbd&gt;CapsLock&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/397229/&quot;&gt;Reaching up to hit the escape key sucks&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.reddit.com/r/vim/comments/2u051z/do_you_remap_your_escape_key/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Do you remap your Escape key?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/10.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way - chapter 10&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you choose to remap the &lt;kbd&gt;CapsLock&lt;/kbd&gt; (as I did myself), you may find the &lt;a href=&quot;https://github.com/tpope/vim-capslock&quot; rel=&quot;nofollow noreferrer&quot;&gt;capslock plugin&lt;/a&gt; useful.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-06-17T19:02:48.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8301" PostTypeId="1" AcceptedAnswerId="8302" CreationDate="2016-06-17T22:34:28.737" Score="3" ViewCount="117" Body="&lt;p&gt;If I have a test.py and a word with dots, &lt;code&gt;w&lt;/code&gt; motion goes through each &quot;subword&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have a test.sh and the same word with dots, &lt;code&gt;w&lt;/code&gt; skips the dots.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I debug this to know what is causing this difference in behavior for &lt;code&gt;w&lt;/code&gt; motion in .py and .sh files? I want the .py behavior in all of my files.&lt;/p&gt;&#xA;" OwnerUserId="8073" LastEditorUserId="8073" LastEditDate="2016-06-19T15:18:21.063" LastActivityDate="2016-06-24T05:44:24.903" Title="Word motion and dots behaves differently in bash scripts" Tags="|object-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8302" PostTypeId="2" ParentId="8301" CreationDate="2016-06-17T22:55:04.703" Score="5" Body="&lt;p&gt;This comes down to the &lt;code&gt;iskeyword&lt;/code&gt; setting. When I run &lt;code&gt;:set iskeyword?&lt;/code&gt; in a bash file, I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iskeyword=@,48-57,_,192-255,.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run the same command with a python file, I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iskeyword=@,48-57,_,192-255&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you have the filetype plugin set up, you could add this to your python file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword+=.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or this to your bash file (depending on which way you want it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword-=.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't have the filetype plugin set up, you can achieve this with autocommands. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPre *.py set iskeyword+=.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPre *.sh set iskeyword-=.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Updated answer:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Do you have any idea why? Historical reasons? Some kind of POSIX thing? Should we ask Bram Moolenaar itself?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Actually, we have the most authoritative answer you could possibly get. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you run &lt;code&gt;:scriptnames&lt;/code&gt; you can see a list of all the files that vim has loaded this particular session. Somewhere in there you'll see &lt;code&gt;$VIMRUNTIME/syntax/sh.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not because of Bram Moolenaar, however the author did leave his name on the file. The reason this setting is on is because of &quot;Charles E. Campbell&quot;. Here is some relevant code and even reasoning behind the settings from that file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Vim syntax file&#xA;&quot; Language:     shell (sh) Korn shell (ksh) bash (sh)&#xA;&quot; Maintainer:       Charles E. Campbell  &amp;lt;NdrOchipS@PcampbellAfamily.Mbiz&amp;gt;&#xA;&quot; Previous Maintainer:  Lennart Schultz &amp;lt;Lennart.Schultz@ecmwf.int&amp;gt;&#xA;&quot; Last Change:      Jul 02, 2013&#xA;&quot; Version:      131&#xA;&quot; URL:      http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax&#xA;&quot; For options and settings, please use:      :help ft-sh-syntax&#xA;&quot; This file includes many ideas from ?ric Brunet (eric.brunet@ens.fr)&#xA;&#xA;...&#xA;&#xA;&#xA;&quot; AFAICT &quot;.&quot; should be considered part of the iskeyword.  Using iskeywords in&#xA;&quot; syntax is dicey, so the following code permits the user to&#xA;&quot;  g:sh_isk set to a string : specify iskeyword.&#xA;&quot;  g:sh_noisk exists    : don't change iskeyword&#xA;&quot;  g:sh_noisk does not exist    : (default) append &quot;.&quot; to iskeyword&#xA;if exists(&quot;g:sh_isk&quot;) &amp;amp;&amp;amp; type(g:sh_isk) == 1    &quot; user specifying iskeyword&#xA; exe &quot;setl isk=&quot;.g:sh_isk&#xA;elseif !exists(&quot;g:sh_noisk&quot;)        &quot; optionally prevent appending '.' to iskeyword&#xA; setl isk+=.&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So actually, my previous recommendation of &lt;code&gt;autocmd BufReadPre *.sh set iskeyword-=.&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; the ideal way to fix it. If you put &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:sh_noisk = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your &lt;code&gt;.vimrc&lt;/code&gt;, you can override this setting.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-06-24T05:44:24.903" LastActivityDate="2016-06-24T05:44:24.903" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8303" PostTypeId="2" ParentId="6338" CreationDate="2016-06-18T01:12:21.780" Score="3" Body="&lt;p&gt;One way to run NeoVim on Windows 10 is through &quot;bash on windows&quot;. After setting up ubuntu on bash on windows, you can just install NeoVim the same way you would on a Ubuntu machine (add the PPA, etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need at least Windows Insider Preview Build 14366 and NeoVim 0.1.5-dev (prior to this build it would crash).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might wish to wait until the proper release of the Windows 10 anniversary update, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/neovim/neovim/issues/4507&quot; rel=&quot;nofollow&quot;&gt;https://github.com/neovim/neovim/issues/4507&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13390779-neovim-crashes-on-bash-on-windows&quot; rel=&quot;nofollow&quot;&gt;https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13390779-neovim-crashes-on-bash-on-windows&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8076" LastActivityDate="2016-06-18T01:12:21.780" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8304" PostTypeId="2" ParentId="8187" CreationDate="2016-06-18T12:34:22.000" Score="2" Body="&lt;p&gt;In my case, I had a stray &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;i[nore]map&lt;/code&gt;  &lt;a href=&quot;http://paste.ubuntu.com/17200916/&quot; rel=&quot;nofollow&quot;&gt;Line 220&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;command, which by itself will print all insert maps. Removing this fixed my problem.&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2016-06-18T12:34:22.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8305" PostTypeId="1" AcceptedAnswerId="8307" CreationDate="2016-06-18T12:40:35.067" Score="10" ViewCount="683" Body="&lt;p&gt;Let us suppose that a user maps &lt;code&gt;-&lt;/code&gt; to &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt;. How can I, as a script writer, execute a &lt;code&gt;:normal&lt;/code&gt; command that correctly uses the default behaviour of &lt;code&gt;-&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="7010" LastEditorUserId="205" LastEditDate="2016-06-19T02:52:44.563" LastActivityDate="2016-06-19T02:52:44.563" Title="Is it possible to execute a :normal command ignoring user-defined maps?" Tags="|vimscript|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8306" PostTypeId="1" AcceptedAnswerId="8310" CreationDate="2016-06-18T12:47:04.573" Score="5" ViewCount="405" Body="&lt;p&gt;So Lets say I have a list&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\Summit&#xA;\SummitSign&#xA;\sun&#xA;\ProgrammingOnABoat&#xA;\SunCloud&#xA;\SunshineOpenCircled&#xA;\sup&#xA;\supdsub&#xA;\supdsub&#xA;\supedot&#xA;\suphsol&#xA;\suphsub&#xA;\Summit&#xA;\SummitSign&#xA;\sun&#xA;\Summit&#xA;\boatProgramming&#xA;\sup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do not want to sort the list, I just want to remove identical rows, leaving only the first, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\Summit&#xA;\SummitSign&#xA;\sun&#xA;\ProgrammingOnABoat&#xA;\SunCloud&#xA;\SunshineOpenCircled&#xA;\sup&#xA;\supdsub&#xA;&#xA;\supedot&#xA;\suphsol&#xA;\suphsub&#xA;&#xA;&#xA;&#xA;&#xA;\boatProgramming&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\Summit&#xA;\SummitSign&#xA;\sun&#xA;\ProgrammingOnABoat&#xA;\SunCloud&#xA;\SunshineOpenCircled&#xA;\sup&#xA;\supdsub&#xA;\supedot&#xA;\suphsol&#xA;\suphsub&#xA;\boatProgramming&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, it was not sorted, but the latter entries were removed.&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2016-06-18T16:34:01.013" Title="In Vim, how can you delete following identical rows in a visual selection, without sorting?" Tags="|ex-mode|replace|sort|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8307" PostTypeId="2" ParentId="8305" CreationDate="2016-06-18T12:51:01.963" Score="11" Body="&lt;p&gt;You have to put &lt;code&gt;!&lt;/code&gt; after &lt;code&gt;:normal&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:normal! -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;!&lt;/code&gt; will make it ignore mappings. From &lt;a href=&quot;https://vimhelp.appspot.com/various.txt.html#:normal&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :normal&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If the [!] is given, mappings will not be used.&#xA;  Without it, when this command is called from a&#xA;  non-remappable mapping (:noremap), the argument can&#xA;  be mapped anyway.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="20" LastEditorUserId="5229" LastEditDate="2016-06-18T13:03:21.367" LastActivityDate="2016-06-18T13:03:21.367" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8310" PostTypeId="2" ParentId="8306" CreationDate="2016-06-18T14:00:02.710" Score="5" Body="&lt;p&gt;If you don't care about removing the first occurrence (leaving the last one), you can use the following global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^\(.*\)\n\_.*\(^\1$\)/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/                     /d   &quot; the global command will delete matched lines&#xA;  ^\(.*\)                   &quot; Match anything from start of the line (create a group)&#xA;         \n                 &quot; Match the end of the line&#xA;           \_.*             &quot; Match any character (with new line) 0 or more time&#xA;               \(^\1$\)     &quot; Match the previously matched group&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will find any line that has a duplicate later in the file and delete it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will delete duplicate lines but keeping only the last one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As a workaround for the seek of keeping only the first occurence, you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; g/^/move 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before and after the substitution, this will reverse the order of the file, thus keeping the first line.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-18T14:05:47.337" LastActivityDate="2016-06-18T14:05:47.337" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8311" PostTypeId="1" AcceptedAnswerId="8330" CreationDate="2016-06-18T16:29:20.987" Score="1" ViewCount="594" Body="&lt;p&gt;According to &lt;code&gt;:h compatible&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;(...) when a |vimrc| or |gvimrc| file exists,&#xA;  Vim will use the Vim defaults, otherwise it will use the Vi defaults.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But when I try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ mv ~/.vimrc vimrc&#xA;$ vim -c 'set cp?'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim tells me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nocompatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I force it by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -u NONE -c 'set cp?'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim correctly answers me with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;compatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm confident I have no &lt;code&gt;~/.gvimrc&lt;/code&gt;, what could cause this vim behaviour?&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-06-19T22:41:37.347" Title="Removed my vimrc but vim still starts in nocp mode" Tags="|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8312" PostTypeId="2" ParentId="8311" CreationDate="2016-06-18T16:47:12.240" Score="5" Body="&lt;p&gt;I just tried it, and I think I know what causes this. When I delete my vimrc, start vim, and run &lt;code&gt;:scriptnames&lt;/code&gt; it says a default vimrc is loaded from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: C:\Program Files (x86)\vim\_vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(although this probably depends on what operating system you're on). If you delete this file, vim will start in compatible mode. You can find out where this file is by running &lt;code&gt;:scriptnames&lt;/code&gt;, and it should be the first result.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-18T16:47:12.240" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8313" PostTypeId="1" AcceptedAnswerId="8314" CreationDate="2016-06-18T17:16:54.600" Score="1" ViewCount="363" Body="&lt;p&gt;I decided to remap the arrow keys to &lt;code&gt;C-h&lt;/code&gt;, &lt;code&gt;C-j&lt;/code&gt;, etc. in my vimrc. Then I decided to allow half-page scrolling (which I use a lot) with &lt;code&gt;C-u&lt;/code&gt; and &lt;code&gt;C-d&lt;/code&gt;. But now I'm realizing that I rarely use hotkeys in insert mode otherwise, and it would be possible to remap most of the normal navigation commands by prefixing them with &lt;code&gt;C&lt;/code&gt; or &lt;code&gt;M&lt;/code&gt; (Alt). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you think this is this against the modal philosophy of Vim, or is otherwise bad practice? Kind of feels like my world is breaking down; isn't the idea of &quot;normal mode&quot; just switching Read Only Mode on and off, with the clever allocation of hotkeys that could be achieved instead by prefixing all of them? Also are there some examples of useful Insert Mode hotkeys I'm not aware of that I should want to preserve?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="2920" LastEditDate="2016-06-18T17:49:55.493" LastActivityDate="2016-07-06T06:29:16.293" Title="Philosophical question: Is remapping keys to allow navigation in Insert Mode bad practice? In fact, why even have Normal Mode?" Tags="|key-bindings|vimrc|cursor-motions|insert-mode|normal-mode|" AnswerCount="2" CommentCount="3" ClosedDate="2016-07-06T12:22:29.910" ContentLicense="CC BY-SA 3.0" />
  <row Id="8314" PostTypeId="2" ParentId="8313" CreationDate="2016-06-18T17:49:27.197" Score="4" Body="&lt;p&gt;The &lt;em&gt;philosophy&lt;/em&gt; of vim, is that it's extremely customizable, and whatever workflow is most efficient for you is completely up to you. So, no I don't think this goes against the philosophy of vim. I have &lt;code&gt;&amp;lt;C-H&amp;gt; &amp;lt;C-J&amp;gt; &amp;lt;C-K&amp;gt; &amp;lt;C-L&amp;gt;&lt;/code&gt; remapped to cursor keys in my &lt;code&gt;.vimrc&lt;/code&gt;. If it makes you more productive, who cares if it goes against the norm of vim? &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Isn't the idea of &quot;normal mode&quot; just switching Read Only Mode on and off, with the clever allocation of hotkeys that could be achieved instead by prefixing all of them?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not really. I'm not sure what you mean &quot;switching read only mode on and off&quot;. Vim does have a read-only mode, but this has nothing to do with normal vs insert mode. The way I think of normal mode means &quot;each key is a composable function&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for philosophical thoughts on this, the workflow you're proposing sounds very emacs-ey. Emacs heavily relies on modifiers (such as ctrl-alt-super, etc.) for the equivalent of normal mode commands in vim. It might be worth a shot to try out emacs if that sounds appealing. &lt;strong&gt;Disclaimer:&lt;/strong&gt; I have never used emacs before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you want to use vim with your own fusion of normal and insert mode, I see no problem with that. You'll find the &lt;code&gt;i_CTRL-o&lt;/code&gt; and &lt;code&gt;gi&lt;/code&gt; commands both very useful while you're creating your mappings.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also are there some examples of useful Insert Mode hotkeys I'm not aware of that I should want to preserve?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is very subjective. What I find useful, another might find annoying, and vice-versa. For example, I find &lt;code&gt;&amp;lt;C-V&amp;gt; &amp;lt;C-N&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; extremely useful. In the end, only you can decide which &lt;code&gt;i_CTRL-*&lt;/code&gt; keystrokes are useful to you or not. I would recommend just checking &lt;code&gt;:help i-CTRL-&amp;lt;some key&amp;gt;&lt;/code&gt; whenever you want to map something new in insert mode.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-07-05T21:19:56.680" LastActivityDate="2016-07-05T21:19:56.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8316" PostTypeId="1" AcceptedAnswerId="8317" CreationDate="2016-06-18T23:36:29.637" Score="4" ViewCount="69" Body="&lt;p&gt;I always have problems selecting visual areas with the &lt;code&gt;normal!&lt;/code&gt; command in vim. Against all I expected, the following doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:foo()&#xA;    normal! v/\S\&amp;lt;cr&amp;gt;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; a :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;foo()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It just selects nothing. &lt;code&gt;normal!&lt;/code&gt; doesn't seem to work with &lt;code&gt;/&lt;/code&gt;. Have I reached the limit of vim's capabilities or am I just doing something wrong? &lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="205" LastEditDate="2016-06-19T04:33:24.587" LastActivityDate="2016-06-19T04:33:24.587" Title="Certain functionality doesn't work with `normal!`" Tags="|cursor-movement|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8317" PostTypeId="2" ParentId="8316" CreationDate="2016-06-18T23:57:48.377" Score="5" Body="&lt;p&gt;Rather than using vim key-descriptions (such as &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;) you'll have to enter the literal key you want to press. &lt;code&gt;\&amp;lt;CR&amp;gt;&lt;/code&gt; &lt;em&gt;looks&lt;/em&gt; like it means &quot;Press the enter key&quot; it &lt;em&gt;really&lt;/em&gt; means &quot;Search for &lt;code&gt;\&amp;lt;&lt;/code&gt; start of word, followed by the text &lt;code&gt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do a literal newline character instead of &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;, try pressing &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt;. This will appear as &lt;code&gt;^M&lt;/code&gt;. That works for me.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-06-19T00:18:55.227" LastActivityDate="2016-06-19T00:18:55.227" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8318" PostTypeId="1" CreationDate="2016-06-19T03:05:02.767" Score="5" ViewCount="177" Body="&lt;p&gt;I am using Vim for Rust development.  I have a custom error format that works very well, except that newline characters in error messages are suppressed when scrolling through errors with &lt;code&gt;:cn&lt;/code&gt;.  This is a problem because &lt;code&gt;rustc&lt;/code&gt;'s error messages are usually multiple lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to get Vim to display all of the lines in the error messages, on multiple lines, as they would be displayed on a terminal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:  My error format is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CompilerSet errorformat=&#xA;     \%+E%f:%l:%c:\ %*\\d:%*\\d\ error:\ %m,&#xA;     \%+W%f:%l:%c:\ %*\\d:%*\\d\ warning:\ %m,&#xA;     \%+A%f:%l:%c:\ %*\\d:%*\\d\ note:\ %m,&#xA;     \%+C%f:%l:%c:\ error:\ %m,&#xA;     \%+C%f:%l:%c:\ warning:\ %m,&#xA;     \%+C%f:%l:%c:\ note:\ %m,&#xA;     \%+C%f:%l\ %s,&#xA;     \%+C\ %m,&#xA;     \%+C\(%m,&#xA;     \%+G%*[\ ]^,&#xA;     \%+G%*[\ ]^%*[~],&#xA;     \%+G%*[\ ]...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;:CompilerSet&lt;/code&gt; is defined as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   command -nargs=* CompilerSet setlocal &amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error message is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;read.rs:439:26: 439:74 error: mismatched types [E0308]&#xA;read.rs:439                     *x = State::DottedList { isSquare: a, depth: length }&#xA;                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#xA;read.rs:439:26: 439:74 help: run `rustc --explain E0308` to see a detailed explanation&#xA;read.rs:439:26: 439:74 note: expected type `&amp;amp;read::read::State` &#xA;read.rs:439:26: 439:74 note:    found type `read::read::State` &#xA;read.rs:439:26: 439:74 note: expected &amp;amp;-ptr, found enum `read::read::State` &#xA;read.rs:439                     *x = State::DottedList { isSquare: a, depth: length }&#xA;                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8074" LastEditorUserId="8074" LastEditDate="2016-09-01T01:21:24.473" LastActivityDate="2018-11-17T10:22:07.187" Title="How can I display multiple lines in the same compiler error when using :cn?" Tags="|vimscript|quickfix|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8319" PostTypeId="1" AcceptedAnswerId="8320" CreationDate="2016-06-19T10:57:45.580" Score="1" ViewCount="186" Body="&lt;pre&gt;&lt;code&gt;function! s:foo()&#xA;    normal! yiw&#xA;    if @&quot; =~# '\vf[0-9]b\('&#xA;        echom 'Matches!'&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; * :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;foo()&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; f2b⣿(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When my cursor position is &lt;code&gt;⣿&lt;/code&gt; and I press *, why doesn't it say 'Matches!'.&#xA;I just can't get any braces to match (&lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;[&lt;/code&gt;, or &lt;code&gt;{&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also be very happy about any recommended references, as I &lt;code&gt;h regex&lt;/code&gt; or &lt;code&gt;h =~&lt;/code&gt; isn't really helpful, as it just covers the basics...&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-06-19T11:13:11.913" Title="Braces don't match with regex equals operator" Tags="|vimscript|key-bindings|regular-expression|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8320" PostTypeId="2" ParentId="8319" CreationDate="2016-06-19T11:13:11.913" Score="4" Body="&lt;p&gt;For the &lt;code&gt;w&lt;/code&gt;, motion, see &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#word&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h word&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;                                                        word&#xA;A word consists of a sequence of letters, digits and underscores, or a&#xA;sequence of other non-blank characters, separated with white space (spaces,&#xA;tabs, &amp;lt;EOL&amp;gt;).  This can be changed with the 'iskeyword' option.  An empty line&#xA;is also considered to be a word.&#xA;                                                        WORD&#xA;A WORD consists of a sequence of non-blank characters, separated with white&#xA;space.  An empty line is also considered to be a WORD.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, you probably need to set &lt;code&gt;iskeyword&lt;/code&gt;, or use &lt;code&gt;W&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, depending on what your actual use for this thing is, you don't need to copy the text. Use &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3A%3Ccword%3E&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;&lt;/a&gt; (or &lt;code&gt;&amp;lt;cWORD&amp;gt;&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;    &amp;lt;cword&amp;gt;    is replaced with the word under the cursor (like star)&#xA;    &amp;lt;cWORD&amp;gt;    is replaced with the WORD under the cursor (see WORD)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:foo()&#xA;    let l:word = expand('&amp;lt;cWORD&amp;gt;')&#xA;    if l:word =~# '\vf[0-9]b\('&#xA;        echom 'Matches!'&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-06-19T11:13:11.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8321" PostTypeId="1" AcceptedAnswerId="8324" CreationDate="2016-06-19T13:21:11.660" Score="1" ViewCount="71" Body="&lt;p&gt;When my cursor is inside a brace, e.g.,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(( &quot;Hello World!⣿&quot; ))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;⣿&lt;/code&gt; is my cursor, and I use &lt;code&gt;%&lt;/code&gt;, I will automatically select the first opening &lt;code&gt;(&lt;/code&gt;. Is there some way to make the &lt;code&gt;%&lt;/code&gt; only jump if it's currently on a opening or closing brace?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="205" LastEditDate="2016-06-19T17:41:27.047" LastActivityDate="2016-06-19T17:41:27.047" Title="% operator without using enclosing brace" Tags="|cursor-movement|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8322" PostTypeId="1" CreationDate="2016-06-19T13:25:32.137" Score="7" ViewCount="377" Body="&lt;p&gt;From &lt;code&gt;:h /\+&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\+  Matches 1 or more of the preceding atom, as many as possible.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;:h /\{&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\{n,}   Matches at least n of the preceding atom, as many as possible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems the multi &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;{1,}&lt;/code&gt; have the same meaning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I have a buffer containing 4 identical lines and a fifth different line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some random text&#xA;some random text&#xA;some random text&#xA;some random text&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I type the following substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(.*\n)\1+//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(.*\n)\1{1,}//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't get the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are almost identical, the only difference is that one uses the multi &lt;code&gt;+&lt;/code&gt; while the other uses &lt;code&gt;{1,}&lt;/code&gt;. So I should get the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second one works as expected, because it removes the four lines &lt;code&gt;some random text&lt;/code&gt;.&lt;br&gt;&#xA;But the first one doesn't work as expected, because it keeps one of the four &lt;code&gt;some random text&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems the problem comes from the regex engine, because by default Vim uses the new NFA engine, but if I ask Vim to use the old one by prefixing the pattern with &lt;code&gt;\%#=1&lt;/code&gt;, I get the expected result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\%#=1\v(.*\n)\1+//    removes all 'some random text' lines when using old engine&#xA;:%s/\%#=2\v(.*\n)\1+//    keeps a 'some random text' line when using new engine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it a bug or does it simply mean that the new engine doesn't support repeating a backref with the multi &lt;code&gt;+&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the latter case, shouldn't Vim automatically select the old engine?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it doesn't, where can I find information on what the new regex engine does not support?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In case it matters, the value of &lt;code&gt;'regexpengine'&lt;/code&gt; is &lt;code&gt;0&lt;/code&gt;, which means, according to the help, that Vim can automatically switch the engine if the default one becomes too costly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;@romainl: I was trying to find a substitution command to reduce all consecutive duplicate lines with a single occurrence:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo          foo&#xA;foo    =&amp;gt;    bar&#xA;foo          qux&#xA;foo&#xA;bar&#xA;bar&#xA;bar&#xA;bar&#xA;qux&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can do it with this substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v^(.*)(\n\1)+/\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in the process of finding this command, I found the behavior described earlier which I don't understand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you move the newline &lt;code&gt;\n&lt;/code&gt; from the second captured group to the first one (which I know you shouldn't because then it won't manage the case where a duplicate line is at the very end of the buffer), then, depending on whether you use the multi &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;{1,}&lt;/code&gt;, you don't get the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can let Vim choose the engine (provided &lt;code&gt;'re'&lt;/code&gt;'s value is &lt;code&gt;0&lt;/code&gt;), force it to use the old one with &lt;code&gt;\%#=1&lt;/code&gt;, or force it to use the new one with &lt;code&gt;%#=2&lt;/code&gt;, which makes 3 choices.&lt;br&gt;&#xA;You can use the multi &lt;code&gt;+&lt;/code&gt; or the multi &lt;code&gt;{1,}&lt;/code&gt;, which makes 2 other choices, so 6 possible commands in total:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(1)    %s:\v^(.*\n)\1+:\1:         (4)    %s:\v^(.*\n)\1{1,}:\1:&#xA;&#xA;(2)    %s:\%#=1\v^(.*\n)\1+:\1:    (5)    %s:\%#=1\v^(.*\n)\1{1,}:\1:&#xA;(3)    %s:\%#=2\v^(.*\n)\1+:\1:    (6)    %s:\%#=2\v^(.*\n)\1{1,}:\1:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The commands &lt;code&gt;(2)&lt;/code&gt;, &lt;code&gt;(4)&lt;/code&gt; and &lt;code&gt;(5)&lt;/code&gt; give the expected result against the previous buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar&#xA;qux&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The commands &lt;code&gt;(1)&lt;/code&gt;, &lt;code&gt;(3)&lt;/code&gt; and &lt;code&gt;(6)&lt;/code&gt; don't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;foo&#xA;bar&#xA;bar&#xA;qux&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that using the new engine is the problem (&lt;code&gt;(3)&lt;/code&gt; and &lt;code&gt;(6)&lt;/code&gt; use it explicitly while &lt;code&gt;(1)&lt;/code&gt; probably uses it by default).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(2)&lt;/code&gt; and &lt;code&gt;(5)&lt;/code&gt; work because they use the old engine explicitly. &lt;code&gt;(4)&lt;/code&gt; works, probably because it uses the old engine by default (contrary to &lt;code&gt;(1)&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's weird is that as soon as the newline is moved outside the first captured group, everything works no matter the multi and no matter the engine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s:\v^(.*)(\n\1)+:\1:         %s:\v^(.*)(\n\1){1,}:\1:&#xA;&#xA;%s:\%#=1\v^(.*)(\n\1)+:\1:    %s:\%#=1\v^(.*)(\n\1){1,}:\1:&#xA;%s:\%#=2\v^(.*)(\n\1)+:\1:    %s:\%#=2\v^(.*)(\n\1){1,}:\1:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All these 6 commands work and perform the exact same transformation.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-06-20T00:43:17.023" LastActivityDate="2016-06-20T00:43:17.023" Title="In a regex, why aren't the multi + and {1,} always parsed exactly the same way?" Tags="|regular-expression|substitute|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8324" PostTypeId="2" ParentId="8321" CreationDate="2016-06-19T13:58:59.450" Score="3" Body="&lt;p&gt;There is not option for this, but you can remap &lt;code&gt;%&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; % index([&quot;(&quot;, &quot;{&quot;, &quot;[&quot;, &quot;)&quot;, &quot;}&quot;, &quot;]&quot;], getline(&quot;.&quot;)[col(&quot;.&quot;)-1]) &amp;gt; -1 ? &quot;%&quot; : &quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; keyword makes Vim evaluate an &lt;em&gt;expression&lt;/em&gt; (i.e. a snippet of VimScript), rather than a fixed set of normal commands. The result of this expression is then used as the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this expression we check if the current character is one of the brace characters (&lt;code&gt;(&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt;, or &lt;code&gt;[&lt;/code&gt;), and if it is, it evaluates to &lt;code&gt;%&lt;/code&gt;, if it's not, it evaluates to nothing. Perhaps it is easier to understand if we turn it into a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Percent()&#xA;    &quot; Get current character&#xA;    let current_char = getline(&quot;.&quot;)[col(&quot;.&quot;)-1]&#xA;&#xA;    &quot; Match these braces&#xA;    let match = [&quot;(&quot;, &quot;{&quot;, &quot;[&quot;, &quot;)&quot;, &quot;}&quot;, &quot;]&quot;]&#xA;&#xA;    &quot; Find current_chat in match&#xA;    if index(match, current_char) &amp;gt; -1&#xA;        return &quot;%&quot;&#xA;    &quot; No match, do nothing&#xA;    else&#xA;        return &quot;&quot;&#xA;    endif&#xA;endfun&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt; % Percent()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both ways behave exactly the same.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-06-19T13:58:59.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8325" PostTypeId="1" AcceptedAnswerId="8326" CreationDate="2016-06-19T14:39:31.010" Score="5" ViewCount="2687" Body="&lt;p&gt;In &lt;code&gt;C&lt;/code&gt; you can do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int foo(int a) { return a + 1; }&#xA;int main(void) {&#xA;    int a = 0;&#xA;    while ((a = foo(a)) &amp;lt; 10) {&#xA;        /* */&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do the same thing in vimscript, i.e. something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:foo()&#xA;    let l:foo = 0&#xA;    while (let l:foo = l:foo + 1) &amp;lt; 10)&#xA;        echo 'hi'&#xA;    endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i.e. I want to make the while loop dependent on a value that is assigned anew with every loop. You could do this with traditional for or do-while loops, but sadly Vimscript doesn't have these. One way I see how you can do this is, is like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:foo()&#xA;    let l:foo = 0&#xA;&#xA;    while l:foo + 1 &amp;lt; 10&#xA;        let l:foo = l:foo + 1&#xA;        echo 'hi'&#xA;    endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if the operation is expensive and you need to make more than one comparison (&lt;em&gt;is it equal to 5, 7, or 12&lt;/em&gt;, &lt;em&gt;etc&lt;/em&gt;), this gets ridiculous pretty quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There must be a better way to do this...&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-06-19T15:30:04.647" Title="How to initialize variables in while loops" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8326" PostTypeId="2" ParentId="8325" CreationDate="2016-06-19T15:30:04.647" Score="9" Body="&lt;p&gt;You can't.  Every line in the script is the same as running it in the command window (e.g. &lt;code&gt;:while 1 | echo 'hi' | endwhile&lt;/code&gt;).  The &lt;code&gt;:while&lt;/code&gt; command evaluates a boolean/numeric expression to the right of it, and &lt;code&gt;:let&lt;/code&gt; is a command that defines a variable.  Commands don't return a value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;for...endfor&lt;/code&gt; loop is the only loop that I know of that will create variables if you're iterating over a sequence, like &lt;code&gt;for i in range(10)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your loop condition is really going to be complicated you could use an indefinite loop and break when your condition is met:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let foo = 0&#xA;&#xA;while 1&#xA;  if foo + 1 &amp;gt;= 10 || s:other_condition()&#xA;    break&#xA;  endif&#xA;  let foo += 1&#xA;  echo 'hi'&#xA;endwhile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let done = 0&#xA;let foo = 1&#xA;&#xA;while !done&#xA;  let foo += 1&#xA;  echo 'hi'&#xA;  let done = foo + 1 &amp;gt; 10 || s:other_condition()&#xA;endwhile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;IMO, both are the equivalent of what you're wanting to accomplish.  Except that in the second one, you can't thoughtlessly &lt;code&gt;continue&lt;/code&gt; from anywhere in the body.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-19T15:30:04.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8327" PostTypeId="1" CreationDate="2016-06-19T16:06:22.417" Score="3" ViewCount="1369" Body="&lt;p&gt;I have the following autocmds to automatically open the quickfix window or the location list window after executing a quickfix command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup quickfix_window&#xA;    autocmd!&#xA;    autocmd QuickFixCmdPost [^l]* nested cwindow | setlocal nowrap | redraw!&#xA;    autocmd QuickFixCmdPost l* nested lwindow | setlocal nowrap | redraw!&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to work except with the &lt;code&gt;:lhelpgrep&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I type &lt;code&gt;:lvim /autocmd/ %&lt;/code&gt; to look for all the words matching &lt;code&gt;autocmd&lt;/code&gt; inside the current buffer, the location list is populated with all the matches and the location list window is automatically opened (provided there are matches).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But If I type &lt;code&gt;:lh autocmd&lt;/code&gt; to look for the word &lt;code&gt;autocmd&lt;/code&gt; inside the help files, even though the command is run and the location list is populated with results, the location list window is not opened, I have to do it manually with &lt;code&gt;:lwindow&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;code&gt;:h QuickFixCmdPre&lt;/code&gt;, &lt;code&gt;The pattern is matched against the command being run.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the command name is &lt;code&gt;:lh&lt;/code&gt; which begins with the &lt;code&gt;l&lt;/code&gt; character, so it should match the pattern &lt;code&gt;l*&lt;/code&gt; in the 2nd autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I replace &lt;code&gt;:lwindow&lt;/code&gt; with &lt;code&gt;:lopen&lt;/code&gt;, the previous command &lt;code&gt;:lh autocmd&lt;/code&gt; raises the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing QuickFixCmdPost Auto commands for &quot;l*&quot;:&#xA;E776: No location list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems &lt;code&gt;:lh&lt;/code&gt; populates the location list after the &lt;code&gt;QuickFixCmdPost&lt;/code&gt; event, instead of before like I expected.  Is it normal?&#xA;Is there another way to make the location list window automatically opened after &lt;code&gt;:lh&lt;/code&gt; has been run?&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-06-19T20:30:31.307" LastActivityDate="2016-06-19T20:30:31.307" Title="How to automatically open the location list window after using the :lhelpgrep command?" Tags="|autocmd|quickfix|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8328" PostTypeId="2" ParentId="8327" CreationDate="2016-06-19T19:29:56.140" Score="3" Body="&lt;p&gt;Thanks to &lt;a href=&quot;https://vi.stackexchange.com/questions/8327/how-to-automatically-open-the-location-list-window-after-using-the-lhelpgrep-co#comment13986_8327&quot;&gt;Sato Katsura&lt;/a&gt;, I've realised that I was wrong, &lt;code&gt;:lh&lt;/code&gt; does not populate the location list after the &lt;code&gt;QuickFixCmdPost&lt;/code&gt; event, but before like it should.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that &lt;code&gt;:lh foobar&lt;/code&gt; (contrary to &lt;code&gt;:lvim /foobar/ %&lt;/code&gt;) creates a help window (if we aren't already in one) to display the first match of our search.&lt;br&gt;&#xA;The location list populated by &lt;code&gt;:lh&lt;/code&gt; is associated to this newly created window not to the one where we initially typed &lt;code&gt;:lh foobar&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This causes a problem for an autocmd. Because, when the &lt;code&gt;QuickFixCmdPost&lt;/code&gt; event is triggered, the help window hasn't been created by &lt;code&gt;:lh&lt;/code&gt; yet.&#xA;So, &lt;code&gt;:lwindow&lt;/code&gt; will fail, because there's no location list associated to the current window. A possible solution would be to delay the execution of &lt;code&gt;:lwindow&lt;/code&gt; (10ms should be enough).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There may a better way of doing it, but for the time being, I've come up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup quickfix_window&#xA;    autocmd!&#xA;    autocmd QuickFixCmdPost [^l]* nested cwindow | setlocal nowrap | redraw!&#xA;    autocmd QuickFixCmdPost l[^h]* nested lwindow | setlocal nowrap | redraw!&#xA;    autocmd QuickFixCmdPost lhelpgrep nested call timer_start(10, s:snr() . 'lh_lwindow')&#xA;augroup END&#xA;&#xA;fu! s:lh_lwindow(id) abort&#xA;    lwindow&#xA;    setlocal nowrap&#xA;    redraw!&#xA;endfu&#xA;&#xA;fu! s:snr()&#xA;    return matchstr(expand('&amp;lt;sfile&amp;gt;'), '&amp;lt;SNR&amp;gt;\d\+_')&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It delays the execution of the &lt;code&gt;:lwindow&lt;/code&gt; command for 10ms when the quickfix command is &lt;code&gt;:lhelpgrep&lt;/code&gt;, which should give enough time for the help window to be created.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-06-19T20:30:08.997" LastActivityDate="2016-06-19T20:30:08.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8329" PostTypeId="1" AcceptedAnswerId="8347" CreationDate="2016-06-19T20:52:48.017" Score="3" ViewCount="180" Body="&lt;p&gt;To copy a line to the alternate file in original vi I use something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;ayy&#xA;:e#&#xA;&quot;aP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first vi version did have the alternate file feature (with switch command &lt;code&gt;:e`&lt;/code&gt;) but did not have named buffers. Is there a &lt;em&gt;reasonable&lt;/em&gt; way to copy lines between two files in original vi &lt;em&gt;without&lt;/em&gt; using named buffers?&lt;/p&gt;&#xA;" OwnerUserId="7892" LastEditorUserId="7892" LastEditDate="2016-06-21T08:59:50.913" LastActivityDate="2016-06-21T10:09:13.133" Title="Original vi (version 1.1): Copy lines to alternate file without using named buffer" Tags="|original-vi|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8330" PostTypeId="2" ParentId="8311" CreationDate="2016-06-19T21:20:14.480" Score="3" Body="&lt;p&gt;Thanks to DJ McMayhem pointing me in the right direction I found that Linux distros meddle with the &lt;code&gt;nocompatible&lt;/code&gt; behaviour of &lt;code&gt;vim&lt;/code&gt;.  Since I cannot expect that everyone here know &lt;code&gt;unix&lt;/code&gt; jargon, where I use &lt;code&gt;$&lt;/code&gt; I'm working as a normal user and where I use &lt;code&gt;#&lt;/code&gt; i do commands as the superuser (&lt;code&gt;root&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;1. Vim ignores &lt;code&gt;/etc/vimrc&lt;/code&gt; for the purpose of setting &lt;code&gt;nocompatible&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;:scriptnames&lt;/code&gt; I found &lt;code&gt;vim&lt;/code&gt; loads the &lt;code&gt;/etc/vimrc&lt;/code&gt; script.  I then removed both &lt;code&gt;vimrc&lt;/code&gt; scripts and tested:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ mv ~/.vimrc ~/vimrc.bak&#xA;# mv /etc/vimrc /etc/vimrc.bak&#xA;$ vim -c 'set cp?'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And got&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;compatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is what we expected, but I tested further.  I have created a &lt;code&gt;/etc/vimrc&lt;/code&gt; containing &lt;code&gt;set ff=unix&lt;/code&gt; (completely unrelated from &lt;code&gt;nocp&lt;/code&gt;) and checked:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# echo set ff=unix &amp;gt; /etc/vimrc&#xA;$ vim -c 'set cp?'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And surprisingly I got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;compatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Moreover &lt;code&gt;:scriptnames&lt;/code&gt; clearly indicated:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: /etc/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Adding a &lt;code&gt;~/.vimrc&lt;/code&gt; on the other hand triggers &lt;code&gt;nocompatible&lt;/code&gt; correctly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo set ff=unix &amp;gt; ~/.vimrc&#xA;$ vim -c 'set cp?'&#xA;nocompatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim did not understood the existence of &lt;code&gt;/etc/vimrc&lt;/code&gt; as a &lt;code&gt;vimrc&lt;/code&gt; file for the purpose of setting &lt;code&gt;nocompatible&lt;/code&gt;, but it did understood the existence of &lt;code&gt;~/.vimrc&lt;/code&gt;.  In &lt;code&gt;unix&lt;/code&gt; philosophy that is correct, since it is a multi-user system by default the existence of a global configuration file shall never make a difference for a user.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;2. &lt;code&gt;/etc/vimrc&lt;/code&gt; is created by the package manager on *nix systems&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The suspicion about the strange behaviour I got in the question falls on the contents of the original &lt;code&gt;/etc/vimrc&lt;/code&gt; file (currently backed up as &lt;code&gt;/etc/vimrc.bak&lt;/code&gt;).  Looking through it I found this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime! archlinux.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm running &lt;code&gt;vim&lt;/code&gt; on &lt;code&gt;archlinux&lt;/code&gt; therefore it makes some sense.  I found the file at &lt;code&gt;/usr/share/vim/vimfiles/archlinux.vim&lt;/code&gt; and it does contain:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as the first non-comment line!  That explains it all.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Conclusion&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I then checked on a &lt;code&gt;centos&lt;/code&gt; and a &lt;code&gt;debian&lt;/code&gt; machines.  It turns out that in one way or another (by using &lt;code&gt;runtime&lt;/code&gt; or directly in &lt;code&gt;/etc/vimrc&lt;/code&gt;) they all perform:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;explicitly, inside the configuration that is maintained by the package manager (&lt;code&gt;yum&lt;/code&gt;, &lt;code&gt;apt&lt;/code&gt;, &lt;code&gt;pacman&lt;/code&gt;).  That is &lt;em&gt;bad&lt;/em&gt; practice!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moral of the story:  Your Linux distro is likely meddling in the global &lt;code&gt;vim&lt;/code&gt; configuration files.  Be sure to check these files before arguing about strange behaviour of &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-06-19T22:41:37.347" LastActivityDate="2016-06-19T22:41:37.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8331" PostTypeId="1" CreationDate="2016-06-19T23:22:21.437" Score="3" ViewCount="678" Body="&lt;p&gt;I entered these statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let list = [[[0,0],[0,0],0], [[0,0],[0,0],0]]&#xA;for [a,b,c] in list&#xA;    let c = 5&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then when I executed &lt;code&gt;echo list&lt;/code&gt;, I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[[[0,0],[0,0],0], [[0,0],[0,0],0]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I.e. nothing changed at all. Why is this? This seems like an error to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Especially because&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let list = [[[0,0],[0,0],0], [[0,0],[0,0],0]]&#xA;for [a,b,c] in list&#xA;    let b[0] = 5&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does what you would expect it does. What explains this seemingly erratic behavior?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-06-20T19:34:31.600" Title="Iteration over list seems to be broken" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8332" PostTypeId="2" ParentId="8331" CreationDate="2016-06-19T23:36:39.467" Score="7" Body="&lt;p&gt;The problem is that you're deconstructing each list item into &lt;code&gt;[a, b, c]&lt;/code&gt;.  &lt;code&gt;c&lt;/code&gt; is a copy since it's not an object, which would be the case in a lot of other languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is basically what your example does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let list = [[[0,0],[0,0],0], [[0,0],[0,0],0]]&#xA;for item in list&#xA;  let c = item[2]&#xA;  let c = 5&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is what you want to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let list = [[[0,0],[0,0],0], [[0,0],[0,0],0]]&#xA;for item in list&#xA;  let item[2] = 5&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-06-20T19:34:31.600" LastActivityDate="2016-06-20T19:34:31.600" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8333" PostTypeId="1" CreationDate="2016-06-20T01:06:13.010" Score="6" ViewCount="2141" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/scrooloose/nerdcommenter/&lt;/a&gt; plugin to comment the code. It's working fine, but I would like to do a modification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently these are the default mappings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;leader&amp;gt;cc&lt;/code&gt; comments the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;leader&amp;gt;ci&lt;/code&gt; inverts the comment&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;leader&amp;gt;cu&lt;/code&gt; undo last comment/uncomment action&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am looking to map &lt;code&gt;&amp;lt;leader&amp;gt;cc&lt;/code&gt; to the action of invert comment i.e. &lt;code&gt;&amp;lt;leader&amp;gt;ci&lt;/code&gt;. It's not a nerdcommenter question, but a question of vim mappings itself, hence asking here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;cc &amp;lt;leader&amp;gt;ci&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and also&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;cc &amp;lt;leader&amp;gt;ci&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But there doesn't seems to be any effect of these mapping. On pressing &lt;code&gt;&amp;lt;leader&amp;gt;cc&lt;/code&gt;, I am seeing original action of it not the one I am trying to define.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&#xA;FYI, answer to this question &lt;a href=&quot;https://vi.stackexchange.com/a/763/8092&quot;&gt;https://vi.stackexchange.com/a/763/8092&lt;/a&gt; doesn't help either. i.e. to define custom mappings in &lt;code&gt;.vim/after/plugin/somefile.vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="8092" LastEditorUserId="13656" LastEditDate="2020-03-02T00:45:42.633" LastActivityDate="2020-04-26T14:44:09.333" Title="Configure custom key mapping for plugin actions" Tags="|key-bindings|vimrc|comments|plugin-nerdcommenter|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8334" PostTypeId="2" ParentId="5829" CreationDate="2016-06-20T06:40:33.533" Score="1" Body="&lt;p&gt;just a note as this happen to me. Official gvim on window is 32bits (even though it can be run on 64bits!), so the python installed has to be 32 bits as well. Otherwise same error pop up and you thought the path was set wrongly... &lt;/p&gt;&#xA;" OwnerUserId="3240" LastActivityDate="2016-06-20T06:40:33.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8335" PostTypeId="1" AcceptedAnswerId="8336" CreationDate="2016-06-20T07:01:01.843" Score="8" ViewCount="2201" Body="&lt;p&gt;I'm trying to write a vimscript function that moves the cursor all the way up or all the way down without changing the column. (similar to the way &lt;code&gt;:set nostartofline&lt;/code&gt; works). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works, but when I tried to add a mapping for visual mode, it would exit visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! StraightDown()&#xA;  let line=line('.')&#xA;  let end=line('$')&#xA;  exe &quot;normal &quot;.eval(end-line).&quot;j&quot;&#xA;endfunction&#xA;&#xA;function! StraightUp()&#xA;  let line=line('.')&#xA;  exe &quot;normal &quot;.eval(line-1).&quot;k&quot;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;M-j&amp;gt; :&amp;lt;C-u&amp;gt;call StraightDown()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;M-k&amp;gt; :&amp;lt;C-u&amp;gt;call StraightUp()&amp;lt;cr&amp;gt;&#xA;&#xA;xnoremap &amp;lt;M-j&amp;gt; :&amp;lt;C-u&amp;gt;call StraightDown()&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;M-k&amp;gt; :&amp;lt;C-u&amp;gt;call StraightUp()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After experimenting with it, it seems like any command executed with &lt;code&gt;normal ...&lt;/code&gt; will leave visual mode unless it starts with &lt;code&gt;v&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possible workaround I thought of is to add some more logic, and if I call the function in visual mode, add &lt;code&gt;v&lt;/code&gt; to the normal command. However, this doesn't work if I'm in visual line or visual block mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So really, my TL;DR question is how can I do a &lt;code&gt;normal&lt;/code&gt; command in visual mode without changing modes?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-07-04T02:26:13.660" Title="How to I get around &quot;normal&quot; exiting visual mode?" Tags="|vimscript|visual-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8336" PostTypeId="2" ParentId="8335" CreationDate="2016-06-20T07:30:12.893" Score="10" Body="&lt;p&gt;There are two things we need to do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Since you are using a mapping to execute your function, the mapping rightly has to do &lt;code&gt;:&amp;lt;c-u&amp;gt;&lt;/code&gt; in order to reliably call the function.  But calling a function that way will indeed break us out of visual mode.  So you should restore the last visual selection by putting &lt;code&gt;normal gv&lt;/code&gt; near the top of your function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But since you only want to do that in visual mode, let's do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! StraightDown()&#xA;    ...&#xA;endfunction&#xA;&#xA;function! StraightDownVisual()&#xA;    normal gv&#xA;    call StraightDown()&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;M-j&amp;gt; :&amp;lt;C-u&amp;gt;call StraightDown()&amp;lt;cr&amp;gt;&#xA;&#xA;vnoremap &amp;lt;M-j&amp;gt; :&amp;lt;C-u&amp;gt;call StraightDownVisual()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(An alternative single-function approach would be to pass an argument to indicate whether we were in visual mode or not: &lt;code&gt;call StraightDown(0)&lt;/code&gt; or &lt;code&gt;call StraightDown(1)&lt;/code&gt;.  Or another approach is &lt;a href=&quot;https://github.com/joeytwiddle/rc_files/blob/b7f429a16c042922751c76f56cdf60ea151c65f8/.vim/plugin/move_until_char_changes.vim#L29-L40&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I suspect your &lt;code&gt;exe &quot;normal ...&quot;&lt;/code&gt; will now work fine, preserving the visual selection.  But if it really does clear it, then don't use &lt;code&gt;normal&lt;/code&gt; to move the cursor, call a Vim function instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let target_col = getcurpos()[4]&#xA;call setpos('.', [0, end, target_col])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more info, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h setpos(&#xA;:h getcurpos(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could use &lt;code&gt;[2]&lt;/code&gt; of &lt;code&gt;getcurpos()&lt;/code&gt; for the current column, but if &lt;code&gt;[4]&lt;/code&gt; works for you, then that's probably what you really wanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly, if I press &lt;code&gt;$&lt;/code&gt; and then ask&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo getcurpos()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then the last number displayed is 2147483647.  I think that is Vim's way of telling me the user wants to be on the &lt;em&gt;final&lt;/em&gt; column, not whatever column they have actually landed on.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2019-07-04T02:26:13.660" LastActivityDate="2019-07-04T02:26:13.660" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8337" PostTypeId="1" AcceptedAnswerId="8338" CreationDate="2016-06-20T17:20:12.753" Score="6" ViewCount="226" Body="&lt;p&gt;By pressing &lt;code&gt;l&lt;/code&gt; you can move to the next position in a line. Unless you are at the end of the current line, in which case you won't move at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some simple way to automatically move to the next line, if you reached the end of the current line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I don't want to use this in my normal workflow, but rather this would make my script much more feasible, because I wouldn't always have to concern myself with that possibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Actually &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; does that, but how are you supposed to execute space with the &lt;code&gt;normal!&lt;/code&gt; command? It will just ignore it and complain that there are no arguments...&lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="6300" LastEditDate="2016-06-20T17:36:06.413" LastActivityDate="2016-06-20T17:41:29.443" Title="Move unambiguously to the next position with changing rows" Tags="|cursor-movement|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8338" PostTypeId="2" ParentId="8337" CreationDate="2016-06-20T17:41:29.443" Score="7" Body="&lt;p&gt;Using &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; as the first command with &lt;code&gt;normal&lt;/code&gt; is discussed in the help. From &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3Anormal&quot;&gt;&lt;code&gt;:h :normal&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{commands} cannot start with a space.  Put a count of&#xA;1 (one) before it, &quot;1 &quot; is one space.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So: &lt;code&gt;:normal! 1 &lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-06-20T17:41:29.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8339" PostTypeId="1" AcceptedAnswerId="8353" CreationDate="2016-06-20T13:11:42.813" Score="6" ViewCount="1676" Body="&lt;p&gt;I'd like to automatically set my Vim preferences on the root account, when I use it (throught a &lt;code&gt;sudo bash&lt;/code&gt; or &lt;code&gt;sudo su&lt;/code&gt;-like command), without changing the default configuration of the root account (because it's a shared account), and without having to use a lot of keystrokes to do this (I have to switch often).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To complicate things, our home directories are not available when in root mode (they are NFS-mounted, and, for security purposes, root isn't allowed to see inside, as root can be most anybody)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for now, I've put a nice little bundle of scripts in a subdirectory under /tmp, which happens to be readable and writable both under my non-root and under the root accounts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I've written a tiny script to allow me to connect as root with this slightly longer command (it works):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec sudo bash --init-file /tmp/MY_DIR/MY_BASH_CONFIG_FILE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inside the &lt;code&gt;MY_BASH_CONFIG_FILE&lt;/code&gt;, I put a lot of things, mostly environment variable definitions, along with &lt;code&gt;source /root/.bashrc&lt;/code&gt; (in order to build from the usual root config, not from scratch).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, after all this exposition, let's get to the heart of the problem:&#xA;I've looked at Vim's man page, and found a &lt;code&gt;-u FILE&lt;/code&gt; option. However, this option will ONLY load the given file, and bypass any other Vim configuration file.&#xA;Which means that when I tried &lt;code&gt;alias vi=vim -u MY_DIR/MY_TMP_VIMRC&lt;/code&gt;, I would get a broken Vim, with arrow keys no longer working as intended, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also tried merely naming the file &lt;code&gt;vimrc&lt;/code&gt; in my &lt;code&gt;/tmp&lt;/code&gt; subdir, and using in the bash config file the line &lt;code&gt;export VIM='MY_TMP_SUBDIR'&lt;/code&gt;. However, it still doesn't load the &lt;code&gt;MY_TMP_SUBDIR/vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the files loaded when I run Vim as my unprivileged user (as given by the &lt;code&gt;scriptnames&lt;/code&gt; Vim command):&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: /etc/vimrc&#xA;  2: /usr/share/vim/vim74/syntax/syntax.vim&#xA;  3: /usr/share/vim/vim74/syntax/synload.vim&#xA;  4: /usr/share/vim/vim74/syntax/syncolor.vim&#xA;  5: /usr/share/vim/vim74/filetype.vim&#xA;  6: /usr/share/vim/vimfiles/ftdetect/puppet.vim&#xA;  7: /usr/share/vim/vim74/ftplugin.vim&#xA;&#xA;  8: ~/.vimrc&#xA;&#xA;  9: /usr/share/vim/vim74/plugin/getscriptPlugin.vim&#xA; 10: /usr/share/vim/vim74/plugin/gzip.vim&#xA; 11: /usr/share/vim/vim74/plugin/matchparen.vim&#xA; 12: /usr/share/vim/vim74/plugin/netrwPlugin.vim&#xA; 13: /usr/share/vim/vim74/plugin/rrhelper.vim&#xA; 14: /usr/share/vim/vim74/plugin/spellfile.vim&#xA; 15: /usr/share/vim/vim74/plugin/tarPlugin.vim&#xA; 16: /usr/share/vim/vim74/plugin/tohtml.vim&#xA; 17: /usr/share/vim/vim74/plugin/vimballPlugin.vim&#xA; 18: /usr/share/vim/vim74/plugin/zipPlugin.vim&#xA;&#xA; 19: /usr/share/vim/vim74/scripts.vim&#xA; 20: /usr/share/vim/vim74/syntax/conf.vim&#xA; 21: /usr/share/vim/vim74/ftplugin/conf.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Now, here's what I get, running Vim as root:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: /etc/vimrc&#xA;  2: /usr/share/vim/vim74/syntax/syntax.vim&#xA;  3: /usr/share/vim/vim74/syntax/synload.vim&#xA;  4: /usr/share/vim/vim74/syntax/syncolor.vim&#xA;  5: /usr/share/vim/vim74/filetype.vim&#xA;  6: /usr/share/vim/vim74/ftplugin.vim&#xA;  7: /usr/share/vim/vim74/plugin/getscriptPlugin.vim&#xA;  8: /usr/share/vim/vim74/plugin/gzip.vim&#xA;  9: /usr/share/vim/vim74/plugin/matchparen.vim&#xA; 10: /usr/share/vim/vim74/plugin/netrwPlugin.vim&#xA; 11: /usr/share/vim/vim74/plugin/rrhelper.vim&#xA; 12: /usr/share/vim/vim74/plugin/spellfile.vim&#xA; 13: /usr/share/vim/vim74/plugin/tarPlugin.vim&#xA; 14: /usr/share/vim/vim74/plugin/tohtml.vim&#xA; 15: /usr/share/vim/vim74/plugin/vimballPlugin.vim&#xA; 16: /usr/share/vim/vim74/plugin/zipPlugin.vim&#xA;&#xA; 17: /usr/share/vim/vim74/scripts.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've spaced some lines for readability:&#xA;As unprivileged used, I see that the &lt;code&gt;~/.vimrc&lt;/code&gt; file is loaded, but not when I run as root (even though the Vim environment variable is exported, and points to the tmp dir, which is readable, and contains a &lt;code&gt;vimrc&lt;/code&gt; file, which is readable too)&#xA;Also, the end lines (19 to 21 in user mode, or line 17 in root mode) appear only when using Vim on a file (if I type &lt;code&gt;vi&lt;/code&gt;, and then ask for the scriptnames on the title screen, I don't get them. However, if I type &lt;code&gt;vi SOMEFILE&lt;/code&gt;, then they appear). I'm not sure that's relevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have an idea as to what I should do to get out of this predicament ?&#xA;I'll be happy to provide more info, if needed, but I fear this post might already be too long...&lt;/p&gt;&#xA;" OwnerUserId="8109" OwnerDisplayName="Kzwix" LastEditorUserId="205" LastEditDate="2016-06-20T18:20:03.927" LastActivityDate="2016-06-21T14:28:48.657" Title="How to use a specific vimrc file and still load the usual files?" Tags="|vimrc|linux|invocation|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8340" PostTypeId="1" AcceptedAnswerId="8341" CreationDate="2016-06-20T20:37:33.790" Score="3" ViewCount="220" Body="&lt;p&gt;&lt;code&gt;:h \V&lt;/code&gt; tells me:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use of &quot;\V&quot; means that in the pattern after it only the backslash and the&#xA;  terminating character (/ or ?) has a special meaning.  &quot;very nomagic&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo ')' =~# '\V\[)]}&amp;gt;\]'   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will tell me 0. How come so?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-06-20T20:55:13.927" Title="'Very nomagic' doesn't work as expected" Tags="|vimscript|regular-expression|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8341" PostTypeId="2" ParentId="8340" CreationDate="2016-06-20T20:55:13.927" Score="5" Body="&lt;p&gt;The problem is that you misplaced a slash.  This is what it should look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo ')' =~# '\V\[)\]}&amp;gt;]'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\[]&lt;/code&gt; is a character collection with &lt;code&gt;nomagic&lt;/code&gt; enabled.  Note that it doesn't close with &lt;code&gt;\]&lt;/code&gt;.  Including an opening brace inside of the collection needs to be escaped with a slash.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-20T20:55:13.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8342" PostTypeId="2" ParentId="6061" CreationDate="2016-06-20T20:58:30.023" Score="21" Body="&lt;p&gt;&lt;code&gt;Y&lt;/code&gt; was the yank command of the first vi version (ex-1.1, January 1, 1978). This version did not have the &lt;code&gt;yy&lt;/code&gt; cammand. ex-2.2 (May 6, 1979) did have both &lt;code&gt;yy&lt;/code&gt; and &lt;code&gt;Y&lt;/code&gt;. So actually &lt;code&gt;yy&lt;/code&gt; is a synonym for &lt;code&gt;Y&lt;/code&gt; (&lt;code&gt;Y&lt;/code&gt; predates &lt;code&gt;yy&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="7892" LastActivityDate="2016-06-20T20:58:30.023" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8343" PostTypeId="2" ParentId="5406" CreationDate="2016-06-20T21:17:36.073" Score="3" Body="&lt;p&gt;According to the &lt;a href=&quot;http://daringfireball.net/projects/markdown/syntax#html&quot; rel=&quot;nofollow&quot;&gt;Markdown specification&lt;/a&gt;, you are allowed to use &lt;em&gt;inline HTML&lt;/em&gt; for any markup that is not covered by Markdown's syntax.  For this reason, the &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/ftplugin/markdown.vim&quot; rel=&quot;nofollow&quot;&gt;Markdown configuration of Vim's &lt;code&gt;ftplugin&lt;/code&gt;&lt;/a&gt; also loads the HTML configuration, as you pointed out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of modifying this well-considered relation of default syntax configurations, I would suggest you modify your local &lt;code&gt;ftplugin/html.vim&lt;/code&gt; so that commands very specific to HTML are only applied to files that are &lt;em&gt;purely&lt;/em&gt; HTML.  You could do so, for example, by wrapping these settings in a block of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (&amp;amp;filetype == 'html')&#xA;    &quot; commands that only apply to files of filetype HTML&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5360" LastEditorUserId="5360" LastEditDate="2016-06-21T06:47:02.287" LastActivityDate="2016-06-21T06:47:02.287" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8344" PostTypeId="1" AcceptedAnswerId="8350" CreationDate="2016-06-20T22:19:02.050" Score="5" ViewCount="291" Body="&lt;p&gt;I suspect that it doesn't. I don't see anything about it in the documentation(&lt;code&gt;:h spell&lt;/code&gt;), but I'd love to be proven wrong.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-06-21T15:20:25.260" LastActivityDate="2016-06-21T16:25:34.297" Title="Does vim support spell checking in the command line?" Tags="|command-line|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8345" PostTypeId="1" AcceptedAnswerId="8352" CreationDate="2016-06-20T23:24:28.500" Score="25" ViewCount="49259" Body="&lt;p&gt;Is there a built-in way to make Vim open a new buffer with file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want open a &lt;strong&gt;file&lt;/strong&gt;. &lt;code&gt;:enew&lt;/code&gt; doesn't take any arguments and opens a &lt;strong&gt;blank&lt;/strong&gt; buffer.&#xA;&lt;code&gt;:edit&lt;/code&gt; closes my existing buffer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Related (about &lt;code&gt;:enew&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/8215/how-do-i-open-a-new-buffer-without-opening-it-in-a-split&quot;&gt;How do I open a new buffer without opening it in a split?&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/2768/how-do-you-open-a-new-buffer-in-the-current-window&quot;&gt;How do you open a new buffer in the current window?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerDisplayName="user4779" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-06-21T00:54:08.207" Title="A built-in way to make Vim open a new buffer with file?" Tags="|buffers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8346" PostTypeId="2" ParentId="8345" CreationDate="2016-06-20T23:24:55.813" Score="11" Body="&lt;p&gt;I can accomplish the behavior using this, but it's kinda annoying to have to do a few extra keystrokes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:enew         &quot; shorthand: ene&#xA;:edit &amp;lt;file&amp;gt;  &quot; shorthand: e&#xA;&#xA;&quot; Shorthand to do both&#xA;:ene|e &amp;lt;file&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user4779" LastActivityDate="2016-06-20T23:24:55.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8347" PostTypeId="2" ParentId="8329" CreationDate="2016-06-20T23:38:32.573" Score="3" Body="&lt;p&gt;When I used to use a real &lt;code&gt;vi&lt;/code&gt;, I'd write to and read from a file,&#xA;like you mention in your comment. I had something like this in my &lt;code&gt;.exrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ab wtemp w !/bin/cat &amp;gt; ~/temp&#xA;ab rtemp r !/bin/cat ~/temp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So to yank the current line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.wtemp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or set marks, then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'a,'b wtemp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then hit &lt;code&gt;^6&lt;/code&gt; to switch to the alternate file (same as &lt;code&gt;:e #&lt;/code&gt;), then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:rtemp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can change the abbreviations to mappings if that's easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that using &lt;code&gt;:read !&lt;/code&gt; and &lt;code&gt;:write !&lt;/code&gt; with &lt;code&gt;cat&lt;/code&gt; avoids setting the alternate file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an aside, should you ever use Vim, you can remove the &lt;code&gt;a&lt;/code&gt; flag&#xA;from &lt;code&gt;'cpoptions'&lt;/code&gt; to prevent &lt;code&gt;:read&lt;/code&gt; with a filename from setting&#xA;the alternate file, and similarly with &lt;code&gt;A&lt;/code&gt; for writing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the reference manual for v1.1, the command set appears to be highly restrictive.&#xA;The only way I can see to achieve the copy in this early version of vi is to append to the alternate file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range] write! &amp;gt;&amp;gt; `&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then switch to the alternate file and move the appended lines to where you want.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-06-21T10:09:13.133" LastActivityDate="2016-06-21T10:09:13.133" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8348" PostTypeId="2" ParentId="2044" CreationDate="2016-06-20T23:59:55.803" Score="1" Body="&lt;p&gt;The closest thing the original &lt;code&gt;vi&lt;/code&gt; has to multiple undo (aside from &lt;code&gt;U&lt;/code&gt; which can revert multiple changes within a single line) is the numbered registers,&#xA;which hold the nine most recent changes or deletions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you put from a numbered register, subsequent dot commands&#xA;will increment that register when it repeats the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. with the following text, with the cursor line indicated with &lt;code&gt;&amp;gt;&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  aaaa&#xA;&amp;gt; bbbb&#xA;  cccc&#xA;  dddd&#xA;  eeee&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the command &lt;code&gt;dd..&lt;/code&gt; will result in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  aaaa&#xA;&amp;gt; eeee&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you then type &lt;code&gt;&quot;1P&lt;/code&gt;, vi will put the most recent deletion&#xA;from register &lt;code&gt;&quot;1&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  aaaa&#xA;&amp;gt; dddd&#xA;  eeee&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hitting &lt;code&gt;.&lt;/code&gt; will put the contents of the next most recent&#xA;register, by doing &lt;code&gt;&quot;2P&lt;/code&gt;, and hitting &lt;code&gt;.&lt;/code&gt; again will put&#xA;the contents of register &lt;code&gt;&quot;3&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in short, &lt;code&gt;&quot;P..&lt;/code&gt; will put back all the text you deleted,&#xA;leaving you with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  aaaa&#xA;&amp;gt; bbbb&#xA;  cccc&#xA;  dddd&#xA;  eeee&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not brilliant, but better than nothing! More usefully you&#xA;can use it at the beginning or end of the buffer to quickly&#xA;inspect what's in your numbered registers. Then you can&#xA;easily delete what you don't need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's documented in&#xA;vim under &lt;code&gt;:help redo-register&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-12-26T15:10:21.870" LastActivityDate="2016-12-26T15:10:21.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8349" PostTypeId="2" ParentId="8116" CreationDate="2016-06-21T00:28:10.557" Score="4" Body="&lt;p&gt;Turns out this was a bug in Vim itself. The problem is resolved as of Vim 7.4.1942.&lt;/p&gt;&#xA;" OwnerUserId="7165" LastActivityDate="2016-06-21T00:28:10.557" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8350" PostTypeId="2" ParentId="8344" CreationDate="2016-06-21T00:34:00.853" Score="3" Body="&lt;p&gt;Not in the command line that I know of since I'm pretty sure the command line prompt doesn't highlight text.  But, you can enable spell checking in the &lt;em&gt;command window&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Press &lt;code&gt;ctrl-f&lt;/code&gt; on the command line or press &lt;code&gt;q:&lt;/code&gt; in normal mode.  This brings up the command window which can be treated almost like any other buffer.  From here you can run &lt;code&gt;:set spell&lt;/code&gt; to enable spell checking.  However, the command window uses &lt;code&gt;filetype=vim&lt;/code&gt; which doesn't show spelling errors for some reason.  Running &lt;code&gt;set filetype=&lt;/code&gt; to disable the syntax highlighting allows the spell check highlight to show.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use an &lt;code&gt;autocmd&lt;/code&gt; to set up the command window when it opens:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CmdwinEnter * if &amp;amp;ft =~# 'vim' | setlocal spell ft= | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a better solution based on your comment below about using &lt;code&gt;input()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CmdwinEnter * if getcmdwintype() == '@' | setlocal spell | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will enable spellcheck for the &lt;code&gt;input()&lt;/code&gt; history window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h cmdwin-char&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The character used for the pattern indicates the type of command-line:&#xA;    :   normal Ex command&#xA;    &amp;gt;   debug mode command debug-mode&#xA;    /   forward search string&#xA;    ?   backward search string&#xA;    =   expression for &quot;= expr-register&#xA;    @   string for input()&#xA;    -   text for :insert or :append&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your version of Vim does not have &lt;code&gt;getcmdwintype()&lt;/code&gt;, you could use a expression map since &lt;code&gt;getcmdtype()&lt;/code&gt; is only available when editing the command line or an expression mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;c-f&amp;gt; getcmdtype() == '@' ? &quot;\&amp;lt;c-f&amp;gt;:setlocal spell\&amp;lt;cr&amp;gt;&quot; : &quot;\&amp;lt;c-f&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-06-21T16:25:34.297" LastActivityDate="2016-06-21T16:25:34.297" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8352" PostTypeId="2" ParentId="8345" CreationDate="2016-06-21T00:54:08.207" Score="43" Body="&lt;p&gt;I think you might be misunderstanding what you're seeing happen.  &lt;code&gt;:edit&lt;/code&gt; does not close your current buffer.  It just &lt;em&gt;replaces&lt;/em&gt; it in the current &lt;em&gt;window&lt;/em&gt;.  If you type &lt;code&gt;:buffers&lt;/code&gt; your previous buffer should still be listed.  It is still open and in Vim's memory.  The only way to make them go away is to run &lt;code&gt;:bd&lt;/code&gt; or &lt;code&gt;:bw&lt;/code&gt; (or &lt;code&gt;:q&lt;/code&gt; of course).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to answer your question: &lt;code&gt;:e newfile.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your previous buffer is now the &lt;code&gt;alternate file&lt;/code&gt; to the current buffer (&lt;code&gt;:help alternate-file&lt;/code&gt;).  You can switch back to it using &lt;code&gt;ctrl-^&lt;/code&gt; or &lt;code&gt;ctrl-6&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are commands similar to &lt;code&gt;:edit&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:split&lt;/code&gt; - horizontal split&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:vsplit&lt;/code&gt; - vertical split&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Both of these commands (shortened &lt;code&gt;:sp&lt;/code&gt; and &lt;code&gt;:vs&lt;/code&gt; respectively) take an optional &lt;code&gt;file&lt;/code&gt; argument like &lt;code&gt;:edit&lt;/code&gt; does.  So, if you wanted to vertically split and create a new file in one command, you would type: &lt;code&gt;:vs newfile.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Give &lt;code&gt;:help edit-intro&lt;/code&gt; a read to get an idea of how Vim handles files, and &lt;code&gt;:help windows-intro&lt;/code&gt; to read up on windows, buffers, and tabs.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-21T00:54:08.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8353" PostTypeId="2" ParentId="8339" CreationDate="2016-06-21T01:51:25.923" Score="4" Body="&lt;p&gt;A simple/hacky workaround for this is to use -u to point to a vimrc that uses &lt;code&gt;so&lt;/code&gt; (abbreviated version of &lt;code&gt;source&lt;/code&gt;) to read the vimrcs you want to load in the order in which you want to load them. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; this is our vimrc specified by -u&#xA;so /etc/vimrc&#xA;so /tmp/personal_vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5296" LastEditorUserId="7878" LastEditDate="2016-06-21T14:28:48.657" LastActivityDate="2016-06-21T14:28:48.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8354" PostTypeId="1" CreationDate="2016-06-21T01:51:42.320" Score="7" ViewCount="10081" Body="&lt;p&gt;On my local computer, I have the following in &lt;code&gt;~/.vimrc&lt;/code&gt;, which allows me use to the mouse (e.g. to select text) and to copy to the system clipboard with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=a&#xA;vnoremap &amp;lt;C-C&amp;gt; &quot;+y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Having &lt;code&gt;set mouse=a&lt;/code&gt; means I can copy the &quot;real&quot; text, rather than what the terminal interprets (e.g. with control characters and whitespace). Paradoxically, it also lets me select text &lt;em&gt;without&lt;/em&gt; the mouse to copy. Without this setting, I &lt;em&gt;need&lt;/em&gt; to use the mouse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have these settings on a remote computer, and I enable X11 forwarding, I can also copy directly into my local clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have a version of &lt;code&gt;vim&lt;/code&gt; installed on another server compiled without &lt;code&gt;+clipboard&lt;/code&gt;. Here, copying fails. Is it possible to copy directly into my local clipboard, while still having &lt;code&gt;set mouse=a&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="1278" LastEditDate="2016-06-21T01:59:38.410" LastActivityDate="2020-02-07T15:26:30.420" Title="How can I copy over an ssh session without +clipboard?" Tags="|cut-copy-paste|os-clipboard|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8355" PostTypeId="2" ParentId="6269" CreationDate="2016-06-21T02:41:20.527" Score="3" Body="&lt;p&gt;&lt;strong&gt;Vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim you can match any character including newline with &lt;code&gt;\_.&lt;/code&gt;.&#xA;You can use this to construct a pattern that matches a whole line,&#xA;any amount of stuff, and then that same line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\(^.*$\)\_.*\n\1$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you want to delete all lines in&#xA;a file that match the first, not including the first. The&#xA;substitution to delete the last line that matches the first is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1 s/\(^.*$\)\_.*\zs\n\1$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:global&lt;/code&gt; to make sure that the substitution is repeated&#xA;enough times to delete all the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/ 1s/\(^.*$\)\_.*\zs\n\1$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;POSIX ex&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@saginaw shows a neater way to do this in Vim in a comment to your question,&#xA;but we can adapt the above technique for POSIX ex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this in a POSIX-compatible way, you have to disallow&#xA;multi-line matching, but you can still make use of&#xA;backreferences. This requires some extra work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/ t- | s/^/@@@/ | 1t- | s/^/&quot;/ | j! | s/^&quot;\(.*\)@@@\1$/d/ | d x | @x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the breakdown:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/                   for each line&#xA;&#xA;t- |                    copy it above&#xA;&#xA;s/^/@@@/ |              prefix it with something unique (@@@)&#xA;                        (do a search in the buffer first to make&#xA;                        sure it really is unique)&#xA;&#xA;1t- |                   copy the first line above this one&#xA;&#xA;s/^/&quot;/ |                prefix with &quot;&#xA;&#xA;j! |                    join those two lines (no spaces)&#xA;&#xA;s/^&quot;\(.*\)@@@\1$/d/ |   if the part after the &quot; and before the @@@&#xA;                        matches the part after the @@@, replace the line&#xA;                        with d&#xA;&#xA;d x |                   delete the line into register x&#xA;&#xA;@x                      execute it&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if the current line is a duplicate of line 1, register x will contain &lt;code&gt;d&lt;/code&gt;.&#xA;Executing it will delete the current line. If it isn't a duplicate, it will&#xA;contain nonsense prefixed with &lt;code&gt;&quot;&lt;/code&gt; which when executed is a no-op, since &lt;code&gt;&quot;&lt;/code&gt;&#xA;starts a comment. I don't know if this is the neatest way to accomplish this,&#xA;it's just the first that came to mind!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It just so happens that the first line can't be deleted because the copying&#xA;process temporarily changes what line 1 is. If this hadn't been the case you&#xA;could prefix the &lt;code&gt;:g&lt;/code&gt; with a &lt;code&gt;2,$&lt;/code&gt; range instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tested in Vim and ex-vi version 4.0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And a simpler way, which escapes special characters to create a search&#xA;pattern (with &lt;code&gt;'nomagic'&lt;/code&gt; set), builds a &lt;code&gt;:global&lt;/code&gt; command, then executes it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nomagic&#xA;:1t1 | .g/^/ s#\[$^\/]#\\\&amp;amp;#g | s#\.\*#2,$g/^\&amp;amp;$/d# | d x&#xA;:@x&#xA;:set magic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can't do this as a one-liner though, since you'd have a nested&#xA;&lt;code&gt;:global&lt;/code&gt;, which isn't allowed.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-06-21T16:40:26.027" LastActivityDate="2016-06-21T16:40:26.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8356" PostTypeId="2" ParentId="8354" CreationDate="2016-06-21T04:26:28.363" Score="8" Body="&lt;p&gt;Depending on your terminal, doing one of the following will allow you to select text that's being displayed in the terminal:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;holding &lt;code&gt;alt&lt;/code&gt; and dragging&lt;/li&gt;&#xA;&lt;li&gt;holding &lt;code&gt;shift&lt;/code&gt; and dragging&lt;/li&gt;&#xA;&lt;li&gt;middle/right click dragging&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;On the more broad topic of sharing the registers between separate terminal sessions:&lt;/p&gt;&#xA;&lt;p&gt;There is a plugin &lt;a href=&quot;https://github.com/kana/vim-fakeclip&quot; rel=&quot;noreferrer&quot;&gt;vim-fakeclip&lt;/a&gt; that will make use of &lt;code&gt;xsel&lt;/code&gt;, &lt;code&gt;xclip&lt;/code&gt;, &lt;code&gt;pbcopy&lt;/code&gt;/&lt;code&gt;pbpaste&lt;/code&gt;, and &lt;code&gt;tmux&lt;/code&gt;'s buffers.  But, it's a little heavy handed with the keybindings and won't help over the network.&lt;/p&gt;&#xA;&lt;p&gt;If you aren't against using Neovim, it allows a script to control how the &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;+&lt;/code&gt; registers are stored.  By default, it supports &lt;code&gt;xsel&lt;/code&gt;, &lt;code&gt;xclip&lt;/code&gt;, OS X's &lt;code&gt;pbcopy&lt;/code&gt;/&lt;code&gt;pbpaste&lt;/code&gt;, and &lt;a href=&quot;https://github.com/pocke/lemonade&quot; rel=&quot;noreferrer&quot;&gt;lemonade&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I also created my own plugin that I've used for over a year now: &lt;a href=&quot;https://github.com/tweekmonster/sshclip&quot; rel=&quot;noreferrer&quot;&gt;sshclip&lt;/a&gt;.  It's a client/server thing similar to how &lt;a href=&quot;https://github.com/pocke/lemonade&quot; rel=&quot;noreferrer&quot;&gt;lemonade&lt;/a&gt; works, but it keeps everything encrypted on a server and uses ssh to transmit the data.  I've been able to yank and paste between terminals and servers pretty reliably using this.  It also works with vanilla Vim thanks to inspiration drawn from &lt;a href=&quot;https://github.com/kana/vim-fakeclip&quot; rel=&quot;noreferrer&quot;&gt;vim-fakeclip&lt;/a&gt; (it maps &lt;em&gt;a lot&lt;/em&gt; in Vim).  Unfortunately, I haven't made much of an effort to make it user friendly.  So, I can only recommend it if you don't mind reading scripts to get an idea of how it works.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-06-21T04:26:28.363" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8357" PostTypeId="1" AcceptedAnswerId="8359" CreationDate="2016-06-21T04:46:18.953" Score="10" ViewCount="5810" Body="&lt;p&gt;I'm trying to figure out how the vim concept of buffers, windows, and tabs maps onto emacs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems to me that &lt;code&gt;&amp;lt;c-w&amp;gt;s&lt;/code&gt; and &lt;code&gt;&amp;lt;c-w&amp;gt;v&lt;/code&gt; are roughly equivalent to Emacs &lt;code&gt;C-x 2&lt;/code&gt; and &lt;code&gt;C-x 3&lt;/code&gt;. They're not exactly equivalent since vim splits are equally spaced by default and emacs will bisect the current window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the equivalent of &lt;code&gt;C-x 0&lt;/code&gt; (close this window), &lt;code&gt;C-x 1&lt;/code&gt; (close everything except this window) for vim? I'd like to be able to hide the buffers I'm not currently looking it without closing them, so they can still be summoned later with bufexplorer or something similar.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2016-06-21T07:25:34.820" Title="Vim hide buffer like in emacs?" Tags="|buffers|window-management|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8358" PostTypeId="2" ParentId="8357" CreationDate="2016-06-21T05:17:51.103" Score="4" Body="&lt;p&gt;Close window: &lt;code&gt;Ctrl-w c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Close all other windows: &lt;code&gt;Ctrl-w o&lt;/code&gt;, (&lt;code&gt;o&lt;/code&gt; for &quot;only&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information open vim and enter the command &lt;code&gt;:help window&lt;/code&gt;. Look particularly at sections 3 and 4.&lt;/p&gt;&#xA;" OwnerUserId="8105" LastActivityDate="2016-06-21T05:17:51.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8359" PostTypeId="2" ParentId="8357" CreationDate="2016-06-21T07:25:34.820" Score="16" Body="&lt;p&gt;By default, Vim will refuse to replace the current buffer with another one if it contains unsaved changes. You'll need to add the option below to your &lt;code&gt;vimrc&lt;/code&gt; if you don't want that behavior (and you don't want that):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set hidden&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Buffers are Vim's equivalent of documents in other programs. When you switch to another document, you switch to another buffer. This is done with commands like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:b2            switch to buffer number 2&#xA;:b#            switch to previous buffer&#xA;:b foo&amp;lt;tab&amp;gt;    switch to buffer with foo in its name + tab completion&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Windows are a limited abstraction built on top of buffers. They are viewports used to display buffers but &lt;strong&gt;they are not and can't be tied to any specific buffer&lt;/strong&gt;. Switching to a window or closing a window are definitely not the same as switching to buffer or closing a buffer. You can work with windows with the commands listed under &lt;code&gt;:help ctrl-w&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-w&amp;gt;s    split current window in two, focus on the new one&#xA;&amp;lt;C-w&amp;gt;c    close the current window&#xA;&amp;lt;C-w&amp;gt;o    closes all other windows&#xA;&amp;lt;C-w&amp;gt;p    switch to previous window&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tab pages are another limited abstraction built on windows. They are workspaces designed to contain one or more windows. Like windows, &lt;strong&gt;they can't be used as file/document proxies.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help windows&lt;/code&gt; and &lt;code&gt;:help tab-page&lt;/code&gt; for a thorough description.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-06-21T07:25:34.820" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8360" PostTypeId="1" AcceptedAnswerId="8362" CreationDate="2016-06-21T11:22:31.750" Score="5" ViewCount="220" Body="&lt;p&gt;After I &lt;code&gt;set syntax=vhdl&lt;/code&gt; and &lt;code&gt;set fo=tcq&lt;/code&gt;, running &lt;code&gt;gqip&lt;/code&gt; on the following paragraph does not work as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- Lorem ipsum dolor sit amet, &#xA;-- tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,&#xA;-- laboris nisi ut aliquip ex ea commodo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- Lorem ipsum dolor sit amet, -- tempor incididunt ut labore et dolore magna&#xA;aliqua. Ut enim ad minim veniam, -- laboris nisi ut aliquip ex ea commodo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Interestingly, using the same comment in a C++ (.cpp) file works as expected. This behavior shouldn't be related to any plugins since I tried with &lt;code&gt;vim -u NONE&lt;/code&gt;; vim version is 7.4. Any ideas what could be wrong here?&lt;/p&gt;&#xA;" OwnerUserId="8108" LastActivityDate="2016-06-21T20:01:56.843" Title="gqip for VHDL comments does not work" Tags="|formatting|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8361" PostTypeId="1" AcceptedAnswerId="8364" CreationDate="2016-06-21T11:40:34.203" Score="5" ViewCount="4130" Body="&lt;p&gt;I was working on building a regex in the command prompt. After a few iterations, my prompt looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echom 'test_foo_bar.py' =~ '^test_.*\.py$' ? 'yes' : 'no'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now that I have my regex ready, I want to put it in the script I'm editing. Is there an easy way to take the text from my command prompt and stick it in the current buffer? I'm specifically interested in the regex, but if I could dump the whole prompt to the buffer it would be easy enough to edit out the rest.&lt;/p&gt;&#xA;" OwnerUserId="6475" LastActivityDate="2022-07-11T14:41:19.687" Title="How can I insert text from the command prompt?" Tags="|command-line|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8362" PostTypeId="2" ParentId="8360" CreationDate="2016-06-21T11:57:19.080" Score="5" Body="&lt;p&gt;You should tell Vim what a comment is using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set comments+=:--,b:--&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;comments&lt;/code&gt; option contains a comma separated list of strings that can start a comment line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:--&lt;/code&gt; specifies the comment string (&lt;code&gt;--&lt;/code&gt; in that case) repeats at the start of each line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;b:--&lt;/code&gt; specifies a blank (&lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; or&lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt;) is required after &lt;code&gt;--&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#format-comments&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help format-comments&lt;/code&gt;&lt;/a&gt; for details.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I see you typed  &lt;code&gt;:set syntax=vhdl&lt;/code&gt; manually. If this script is put in the &lt;code&gt;.vimrc&lt;/code&gt; file, Vim will set this option for you whenever you enter &lt;code&gt;:set syntax=vhdl&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vhdlsyntax&#xA;   autocmd!&#xA;   autocmd Syntax vhdl &#xA;      \ set formatoptions=tcq&#xA;      \     comments+=:--,b:--&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the other hand, Vim actually can identify when a &lt;code&gt;.vhdl&lt;/code&gt; file is been edited, but for some reason these options aren't (at least in this  case) properly set in &lt;a href=&quot;https://github.com/vim/vim/blob/38df43bd13a2498cc96b3ddd9a20dd75126bd171/runtime/ftplugin/vhdl.vim#L18-L23&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;$VIMRUNTIME/ftplugin/vhdl.vim&lt;/code&gt;&lt;/a&gt;. However you can fix this issue by adding the &lt;code&gt;FileType&lt;/code&gt; event to the previous script, like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vhdlsyntax&#xA;   autocmd!&#xA;   autocmd FileType,Syntax vhdl &#xA;      \ set formatoptions=tcq&#xA;      \     comments+=:--,b:--&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="6698" LastEditDate="2016-06-21T20:01:56.843" LastActivityDate="2016-06-21T20:01:56.843" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8363" PostTypeId="2" ParentId="8361" CreationDate="2016-06-21T11:58:08.153" Score="11" Body="&lt;p&gt;Press &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;F&lt;/kbd&gt; (or in normal mode, press &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#q%3A&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;q:&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;OPEN                                            c_CTRL-F q: q/ q?&#xA;&#xA;There are two ways to open the command-line window:&#xA;1. From Command-line mode, use the key specified with the 'cedit' option.&#xA;   The default is CTRL-F when 'compatible' is not set.&#xA;2. From Normal mode, use the &amp;quot;q:&amp;quot;, &amp;quot;q/&amp;quot; or &amp;quot;q?&amp;quot; command.&#xA;   This starts editing an Ex command-line (&amp;quot;q:&amp;quot;) or search string (&amp;quot;q/&amp;quot; or&#xA;   &amp;quot;q?&amp;quot;).  Note that this is not possible while recording is in progress (the&#xA;   &amp;quot;q&amp;quot; stops recording then).&#xA;&#xA;When the window opens it is filled with the command-line history.  The last&#xA;line contains the command as typed so far.  The left column will show a&#xA;character that indicates the type of command-line being edited, see&#xA;cmdwin-char.&#xA;&#xA;Vim will be in Normal mode when the editor is opened, except when 'insertmode'&#xA;is set.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then you can just &lt;code&gt;yy&lt;/code&gt; the required line (the current, or previous line, as the case may be), and paste it in the target window.&lt;/p&gt;&#xA;&lt;p&gt;Or, better (if you want to copy only the regex) copy by placing the cursor at the beginning of the regex and type &lt;code&gt;ya'&lt;/code&gt;, then close the command-line window (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; twice) and paste it in the text.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RlkwI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RlkwI.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="10604" LastEditDate="2022-07-11T14:41:19.687" LastActivityDate="2022-07-11T14:41:19.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8364" PostTypeId="2" ParentId="8361" CreationDate="2016-06-21T13:33:34.760" Score="10" Body="&lt;p&gt;In addition to the &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;F&lt;/kbd&gt;, which provides complete navigation on the command history, you could use &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-R&quot;&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;R&lt;/kbd&gt;+&lt;kbd&gt;:&lt;/kbd&gt; in insert mode&lt;/a&gt; (faster but works only for the latest command):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-R {0-9a-z&quot;%#*+:.-=}                    *i_CTRL-R*&#xA;        Insert the contents of a register.  Between typing CTRL-R and&#xA;        the second character, '&quot;' will be displayed to indicate that&#xA;        you are expected to enter the name of a register.&#xA;        The text is inserted as if you typed it, but mappings and&#xA;        abbreviations are not used.  If you have options like&#xA;        'textwidth', 'formatoptions', or 'autoindent' set, this will&#xA;        influence what will be inserted.  This is different from what&#xA;        happens with the &quot;p&quot; command and pasting with the mouse.&#xA;        Special registers:&#xA;            '&quot;' the unnamed register, containing the text of&#xA;                the last delete or yank&#xA;            '%' the current file name&#xA;            '#' the alternate file name&#xA;            '*' the clipboard contents (X11: primary selection)&#xA;            '+' the clipboard contents&#xA;            '/' the last search pattern&#xA;            ':' the last command-line&#xA;            '.' the last inserted text&#xA;            '-' the last small (less than a line) delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also use the equivalent in &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#p&quot;&gt;normal mode: &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *p* *put* *E353*&#xA;[&quot;x]p           Put the text [from register x] after the cursor&#xA;            [count] times.  {Vi: no count}&#xA;&#xA;                            *P*&#xA;[&quot;x]P           Put the text [from register x] before the cursor&#xA;            [count] times.  {Vi: no count}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-06-21T13:41:59.237" LastActivityDate="2016-06-21T13:41:59.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8365" PostTypeId="1" AcceptedAnswerId="8367" CreationDate="2016-06-21T16:23:38.407" Score="7" ViewCount="427" Body="&lt;p&gt;Entering in vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au FileType netrw echom &quot;ft is now netrw&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Afterwards, I open a netrw window with &lt;code&gt;:E .&lt;/code&gt;&#xA;Now, I expect to have a message entry in &lt;code&gt;:messages&lt;/code&gt;. However, no message is there. Why is there no message?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &quot;&lt;a href=&quot;https://vi.stackexchange.com/questions/7890/how-to-display-line-number-in-netrw&quot;&gt;How to display line number in netrw?&lt;/a&gt;&quot;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you do anything based on an autocmd, it's likely that netrw is doing  something as well and will overwrite whatever you did.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Afaik, this relates in particular to vim settings which have to be adjusted with &lt;code&gt;g:netrw_bufsettings&lt;/code&gt; instead of &lt;code&gt;au FileType netrw set nu&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My motivation for the question is tpope vinegar plugin which uses following autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vinegar&#xA;  autocmd!&#xA;  autocmd FileType netrw call s:setup_vinegar()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where I want to modify &lt;code&gt;s:setup_vinegar()&lt;/code&gt;. However, my modification has no effect.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Update&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;To make the comment by  Karl Yngve Lervåg more noticeable, I add the working &lt;code&gt;unsilent&lt;/code&gt; version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au FileType netrw unsilent echom &quot;ft is now netrw&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-06-22T19:27:40.720" Title="au FileType netrw echom &quot;ft is now netrw&quot; does not show up in :messages" Tags="|autocmd|netrw|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8366" PostTypeId="1" CreationDate="2016-06-21T17:57:32.753" Score="2" ViewCount="568" Body="&lt;p&gt;YCM does not work for the reason given above. When I type &lt;code&gt;:python import sys; print sys.version&lt;/code&gt; I obtain:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2.7.9 (default, Dec 13 2014, 15:13:49)&#xA;[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when I compiled YCM, I set it up to use &lt;code&gt;/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7&lt;/code&gt;. Doing &lt;code&gt;./python2.7 --version&lt;/code&gt; in this folder returns &lt;code&gt;2.7.10.&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured I could recompile vim and make it use the same python in &lt;code&gt;/System/Library/Frameworks/Python.framework/Versions/2.7/bin&lt;/code&gt;, but I don't see a way to do so. The option &lt;code&gt;--with-python-config-dir=PATH&lt;/code&gt; doesn't seem to do much. In fact I can see in the &lt;code&gt;config.log&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;configure:5872: checking for python&#xA;configure:5890: found /usr/bin/python&#xA;configure:5902: result: /usr/bin/python&#xA;configure:5915: checking Python version&#xA;configure:5924: result: 2.7&#xA;configure:5927: checking Python is 2.3 or better&#xA;configure:5932: result: yep&#xA;configure:5935: checking Python's install prefix&#xA;configure:5944: result: /System/Library/Frameworks/Python.framework/Versions/2.7&#xA;configure:5947: checking Python's execution prefix&#xA;configure:5956: result: /System/Library/Frameworks/Python.framework/Versions/2.7&#xA;configure:5978: checking Python's configuration directory&#xA;configure:6000: result: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config&#xA;configure:6059: checking Python's dll name&#xA;configure:6072: result: Python.framework/Versions/2.7/Python&#xA;configure:6088: checking if -pthread should be used&#xA;configure:6130: result: no&#xA;configure:6141: checking if compile and link flags for Python are sane&#xA;configure:6158: gcc -o conftest -g -O2 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -DPYTHON_HOME='&quot;/System/Library/Frameworks/Python.framework/Versions/2.7&quot;'  -DMACOS_X_UNIX  -L/usr/local/lib conftest.c  -framework Python &amp;gt;&amp;amp;5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks like it will use also &lt;code&gt;/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7&lt;/code&gt;, but when I compile and type &lt;code&gt;:python import sys; print sys.version&lt;/code&gt;  I still get 2.7.9. The python in &lt;code&gt;/usr/bin/python&lt;/code&gt; is also 2.7.10 and it's not a symlink to &lt;code&gt;/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7&lt;/code&gt;. This could be conflicting I guess. I also wanted to see where the python vim is using is by typing &lt;code&gt;python import sys; print sys.executable&lt;/code&gt;, but this returns the vim bin, not python. Any suggestions? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="1713" LastEditorUserId="2920" LastEditDate="2016-06-21T18:19:18.033" LastActivityDate="2016-06-22T22:26:22.183" Title="Conflict between python used by vim and by YouCompleteMe" Tags="|plugin-you-complete-me|vimscript-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8367" PostTypeId="2" ParentId="8365" CreationDate="2016-06-21T18:46:03.213" Score="5" Body="&lt;p&gt;Your autocmd is clearly correct, as you can see that the message is printed if you explicitly set the &lt;code&gt;'ft'&lt;/code&gt; with &lt;code&gt;setl ft=netrw&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem you are facing is that something is blocking the messages (such as &lt;code&gt;:silent&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But your autocmd is being called when the filetype is first set; you can ensure that by using this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType netrw echom &quot;ft is now netrw&quot;|let var=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After the &lt;code&gt;:E .&lt;/code&gt; the variable &lt;code&gt;var&lt;/code&gt; is being set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your problem is unrelated to echoing messages you can check variables instead of the output of &lt;code&gt;:messages&lt;/code&gt; when you need to verify if your autocmd was executed. Otherwise you will need to follow the plugin code to find where the message is being suppressed.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-06-21T18:46:03.213" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8368" PostTypeId="2" ParentId="4170" CreationDate="2016-06-21T19:56:48.693" Score="7" Body="&lt;p&gt;If we use the small delete register &quot;-, we can restore the cursor position after deleting above n lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;-&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt; deletes above 1 line and restores the cursor back where it was.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt; deletes characters from the cursor to the first character of the line. Since &lt;kbd&gt;0&lt;/kbd&gt; is an exclusive motion, the character under the cursor is not deleted. And the deleted characters are put into the small delete regsiter &quot;-.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; deletes above 1 line. This will leave the current line, because &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; is not linewise and exclusive.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;-&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt; puts the text from the small delete register &quot;-.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It is a sort of hack. But if you are looking for non-ex commands, consider using it.&lt;/p&gt;&#xA;" OwnerUserId="8031" LastEditorUserId="8031" LastEditDate="2016-06-23T05:49:41.467" LastActivityDate="2016-06-23T05:49:41.467" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8369" PostTypeId="2" ParentId="8256" CreationDate="2016-06-21T22:16:22.307" Score="0" Body="&lt;p&gt;Instead of shoehorning fully-fledged session management into Vim with hacky Vimscript code, I eventually decided to use an external session management tool dedicated for this task. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I chose tmux (which also does a lot of other stuff that one would not necessarily care about) and am happy with it. Not only does it save the state of my Vim, but also the state of all my other console tabs/windows.&lt;/p&gt;&#xA;" OwnerUserId="7318" LastActivityDate="2016-06-21T22:16:22.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8370" PostTypeId="1" AcceptedAnswerId="8375" CreationDate="2016-06-22T10:06:32.293" Score="6" ViewCount="3370" Body="&lt;p&gt;Generally you can select a visual block for the first n characters of a range of lines, and just press &lt;kbd&gt;c&lt;/kbd&gt;, insert characters, and press &lt;kbd&gt;Esc&lt;/kbd&gt; to have it apply to all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this method is rarely possible for all the latter characters, because lines of code are likely to vary in length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I easily change the last three characters of a range of lines?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastEditorUserId="1841" LastEditDate="2016-06-22T11:30:05.817" LastActivityDate="2020-07-18T10:07:54.323" Title="How do you change the last n characters for a range of lines?" Tags="|insert-mode|visual-block|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8371" PostTypeId="1" CreationDate="2016-06-22T10:47:35.580" Score="4" ViewCount="1873" Body="&lt;p&gt;I currently have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead *.sage&#xA;        \ set filetype=python |&#xA;        \ let b:syntastic_skip_checks=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works as intended (sage files are treated as Python, but with Syntastic disabled), and I would like to add &lt;code&gt;BufNewFile&lt;/code&gt; (i.e. &lt;code&gt;autocmd BufRead,BufNewFile&lt;/code&gt;) to it, but when I do, vim complains due to the &lt;code&gt;b:syntastic_skip_checks&lt;/code&gt; buffer-local variable not yet existing at the time the BufNewFile event is triggered. Is there a way to either force Syntastic to load in that buffer before the autocmd executes, or to defer setting that variable until after the buffer is fully initialised?&lt;br&gt;&#xA;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="8122" LastActivityDate="2016-06-22T11:30:48.107" Title="How to set a local variable for a plugin in a BufNewFile autocmd" Tags="|buffers|autocmd|plugin-syntastic|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8372" PostTypeId="2" ParentId="8370" CreationDate="2016-06-22T11:13:49.710" Score="10" Body="&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Here is a better solution than the one I gave previously:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;g/.*/norm! $4hCfoo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; apply the command to the visual selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g/.*/&lt;/code&gt; apply the global command on all the lines (of the visual selection)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;norm!&lt;/code&gt; interpret the following string as a normal command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$4hCfoo&lt;/code&gt; go 4 characters before the end of the line and replace them by foo&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2&lt;/strong&gt; And another one for the fun:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;g/.*/execute &quot;s/\\%&quot; . (len(getline('.'))-4) . &quot;c.*$/toto&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think it is overcomplicated but is interesting to understand the behavior of the global command:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; Apply on the visual selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g/.*/&lt;/code&gt; Apply the global command on all the lines of the visual selection &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;execute &quot;...&quot;&lt;/code&gt; Execute the following string as a command (We use it to insert a calculation) &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s/&lt;/code&gt; Aplly a substitution on the following pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\\%&quot;&lt;/code&gt; Beginning of the pattern of the form &lt;code&gt;\%Xc.*$&lt;/code&gt; i.e. from the Xth column to the end of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;. (len(getline('.'))-4) .&lt;/code&gt; Calculate the number of the column based on the size of the line minus the number of column to change&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;c.*$&lt;/code&gt; end of the pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;toto&quot;&lt;/code&gt; The string to use as replacement&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The interesting part is that to be able to use &lt;code&gt;. (len(getline('.'))-4) .&lt;/code&gt; in the substitution you have to use the global command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The global command will execute the command on each selected lines one after one, so &lt;code&gt;getline('.')&lt;/code&gt; is updated on each line. If you only used &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;'&amp;lt;,'&amp;gt;s/\\%&quot; . (len(getline('.'))-4) . &quot;c.*$/toto&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;getline('.')&lt;/code&gt; would only be the current line and thus you would get unexpected results.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There are probably some better solutions but you could do it using a macro. For example to replace the last 4 characters by &lt;code&gt;foo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa$4hCfoo&amp;lt;Esc&amp;gt;jq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qa&lt;/code&gt; record a macro&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$4h&lt;/code&gt; go 4 character before the end of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C&lt;/code&gt; remove the end of the line and enter insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;foo&lt;/code&gt; the text to insert&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; leave insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; go to the next line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; stop recording the macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can then go to the first line and use &lt;code&gt;5@a&lt;/code&gt; to apply the macro on the 5 next lines.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-06-22T11:49:11.473" LastActivityDate="2016-06-22T11:49:11.473" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8373" PostTypeId="2" ParentId="8371" CreationDate="2016-06-22T11:23:19.950" Score="3" Body="&lt;p&gt;Despite you can use autocmds to set the &lt;code&gt;'filetype'&lt;/code&gt;, it is better to create a &lt;code&gt;~/.vim/filetype.vim&lt;/code&gt;, as mentioned in &lt;a href=&quot;http://vimhelp.appspot.com/usr_43.txt.html#43.2&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help 43.2&lt;/code&gt;&lt;/a&gt; and explained in &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-26.8&quot; rel=&quot;nofollow&quot;&gt;Vim FAQ 26.8&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A better alternative to the above approach is to create a filetype.vim&#xA;  file in the ~/.vim directory (or in one of the directories specified&#xA;  in the 'runtimepath' option) and add the following lines: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; my filetype file&#xA;if exists(&quot;did_load_filetypes&quot;)&#xA;    finish&#xA;endif&#xA;augroup filetypedetect&#xA;    au! BufRead,BufNewFile *.x       setfiletype c&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then you could use the python filetype plugin (check &lt;a href=&quot;http://vimhelp.appspot.com/usr_43.txt.html#43.1&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help filetype-plugin&lt;/code&gt;&lt;/a&gt; if you aren't using it) to select the correct configuration for the sage files  -- it is sourced when the filetype is being set, so the buffer will be fully initialised:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; at ~/.vim/ftplugin/python.vim:&#xA;if expand(&quot;%:e&quot;) == &quot;sage&quot;&#xA;   let b:syntastic_skip_checks=1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-06-22T11:30:48.107" LastActivityDate="2016-06-22T11:30:48.107" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8374" PostTypeId="2" ParentId="8370" CreationDate="2016-06-22T11:56:49.853" Score="14" Body="&lt;p&gt;Building on @statox's answer,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\v.{3}$/foo/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; very magic option, see &lt;code&gt;:h \v&lt;/code&gt; for more info&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.{3}$&lt;/code&gt; last 3 characters of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;foo&lt;/code&gt; desired replacement string&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1616" LastActivityDate="2016-06-22T11:56:49.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8375" PostTypeId="2" ParentId="8370" CreationDate="2016-06-22T12:15:41.637" Score="13" Body="&lt;p&gt;It would not work all the time, but maybe you could temporarily right-align the right border of the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose you have the following code containing 3 lines, each with the same level of indentation (&lt;code&gt;8&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        here is foo&#xA;        here will be foo&#xA;        here was foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you want to change &lt;code&gt;foo&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt;. You could use the following commands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vip&lt;/code&gt;       = select the current paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:right&lt;/code&gt;    = right-align it&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ff&lt;/code&gt;        = move the cursor on the &lt;code&gt;f&lt;/code&gt; character&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C-v G&lt;/code&gt;     = go into visual block mode and select the column of &lt;code&gt;f&lt;/code&gt; characters&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C&lt;/code&gt;         = cut everything after the column&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;bar Esc&lt;/code&gt;   = insert &lt;code&gt;bar&lt;/code&gt; and escape to go back in normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gv&lt;/code&gt;        = visually select the last changed text (the &lt;code&gt;bar&lt;/code&gt; column)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:left 8&lt;/code&gt;   = left-align the paragraph, giving it back its original level of indentation &lt;code&gt;8&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It would look like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/JA1W9.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JA1W9.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If however, the lines in the block have different levels of indentation, then I don't think this solution can work, as you would probably have to remember the original level of each line, then fix it afterwards.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-06-22T12:15:41.637" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8376" PostTypeId="1" CreationDate="2016-06-22T15:55:28.453" Score="2" ViewCount="246" Body="&lt;p&gt;While I can understand the percentage sign &lt;kbd&gt;%&lt;/kbd&gt; being chosen to represent the current file, just because you need to choose some character for that, I am curious as to why &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; is representative of the current visual selection.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Why not just use a single character to represent the visual selection?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can these characters be parsed to have a different meaning?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;is &lt;code&gt;'&amp;lt;&lt;/code&gt; supposed to mean something like,&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The &lt;strong&gt;lesser than&lt;/strong&gt; value of the &lt;strong&gt;quoted&lt;/strong&gt; text ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Are there any other useful variations of &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; that I should know, say for example, &lt;code&gt;'&amp;gt;,'&amp;lt;&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7960" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-06-22T17:19:22.590" Title="Why is the visual selection represented by these characters: '&lt;,'&gt; ? Can it be parsed?" Tags="|visual-mode|history-of|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8377" PostTypeId="2" ParentId="8376" CreationDate="2016-06-22T16:05:02.660" Score="6" Body="&lt;p&gt;This is actually &lt;em&gt;mark&lt;/em&gt; notation. Anytime you go into a visual selection the beginning of the selection is marked with the mark &lt;code&gt;&amp;lt;&lt;/code&gt;, and the end with the mark &lt;code&gt;&amp;gt;&lt;/code&gt;. You can also do ex-commands between two arbitrary marks that you place yourself. i.e. &lt;code&gt;:'a,'bs/foo/bar/&lt;/code&gt;. Vim is just borrowing from the system already in place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for what &lt;code&gt;'&amp;gt;,'&amp;lt;&lt;/code&gt; would mean. Since we now know this is mark notation, we can see that this would give us a backwards range. (I think vim can sometimes operate on backwards ranges, but it's generally not very happy about them.)&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-06-22T17:19:22.590" LastActivityDate="2016-06-22T17:19:22.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8378" PostTypeId="1" AcceptedAnswerId="8379" CreationDate="2016-06-22T16:40:20.970" Score="56" ViewCount="26942" Body="&lt;p&gt;How do I dump an internal vim command (not shell command) into a new buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I want to dump a listing of all plugins into &lt;code&gt;:enew&lt;/code&gt; from &lt;code&gt;:scriptnames&lt;/code&gt; so that I can search it.&lt;/p&gt;&#xA;" OwnerUserId="2786" LastEditorUserId="2786" LastEditDate="2016-06-23T04:33:57.067" LastActivityDate="2021-01-23T13:44:16.960" Title="Dump the output of internal vim command into buffer" Tags="|command-line|buffers|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8379" PostTypeId="2" ParentId="8378" CreationDate="2016-06-22T16:55:32.017" Score="71" Body="&lt;p&gt;You can use &lt;code&gt;:redir&lt;/code&gt; to redirect the output to a variable, register, or file. Example of redirecting to the unnamed register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @&quot;&amp;gt;|silent scriptnames|redir END|enew|put&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-scriptease&quot; rel=&quot;noreferrer&quot;&gt;scriptease.vim&lt;/a&gt; provides the &lt;code&gt;:Scriptnames&lt;/code&gt; command which will load &lt;code&gt;:scriptnames&lt;/code&gt; into the quickfix list and &lt;code&gt;:copen&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find yourself redirecting many commands you may want to wrap up this up in a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ -complete=command Redir let s:reg = @@ | redir @&quot;&amp;gt; | silent execute &amp;lt;q-args&amp;gt; | redir END | new | pu | 1,2d_ | let @@ = s:reg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use the &lt;code&gt;:Redir&lt;/code&gt; command to redirect the output to a new buffer. e.g. &lt;code&gt;:Redir scriptnames&lt;/code&gt; or &lt;code&gt;:Redir ls&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Vim 8+&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim 8 ships with the new &lt;code&gt;execute()&lt;/code&gt; function. You can use the &lt;code&gt;execute()&lt;/code&gt; function to instead of &lt;code&gt;:redir&lt;/code&gt; to capture ex-command output.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :enew|pu=execute('scriptnames') &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :redir&#xA;:h :silent&#xA;:h :scriptnames&#xA;:h :enew&#xA;:h :put&#xA;:h execute()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-06-15T14:07:17.293" LastActivityDate="2018-06-15T14:07:17.293" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8380" PostTypeId="2" ParentId="8365" CreationDate="2016-06-22T19:27:40.720" Score="2" Body="&lt;p&gt;Update from Charles Campbell (the author of netrw). In response to my comment, &quot;netrw executes all of its autocmd's silently.&quot; He states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I've changed that in netrw v157h.  Consider that change as&#xA;  experimental &#xA;  -- if I don't get complaints, it may stay that way.  You can get v157h  from my website: &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#NETRW&lt;/a&gt;&#xA;  . &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Regards,  Chip Campbell&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here's the &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_use/nkF9ydh3kf4&quot; rel=&quot;nofollow&quot;&gt;full context&lt;/a&gt; if you want it.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-06-22T19:27:40.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8381" PostTypeId="1" CreationDate="2016-06-22T20:08:04.750" Score="15" ViewCount="8875" Body="&lt;p&gt;I started using &lt;strong&gt;syntastic&lt;/strong&gt; plugin with &lt;strong&gt;vim&lt;/strong&gt; to report lint errors in my &lt;code&gt;javascript&lt;/code&gt; code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also integrated &lt;strong&gt;eslint&lt;/strong&gt; with &lt;strong&gt;syntastic&lt;/strong&gt;, and it shows me nice errors, warnings in case they are present as per rules written in my &lt;strong&gt;.eslintrc&lt;/strong&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way in which I can fix some common errors e.g missing semi-colon, missing space etc with a key-stroke?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found that &lt;strong&gt;eslint&lt;/strong&gt; has an option &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  --fix Automatically fix problems&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which can be used for such cases.&#xA;I need to run this command to let eslint fix those issues&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;eslint --fix -c myconfig file.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to know how that can be integrated with &lt;strong&gt;vim&lt;/strong&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5890" LastEditorUserId="5890" LastEditDate="2016-06-23T12:35:39.310" LastActivityDate="2019-05-14T12:36:07.263" Title="How to auto fix common linting errors reported via syntastic?" Tags="|quickfix|filetype-javascript|plugin-syntastic|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8382" PostTypeId="1" AcceptedAnswerId="8383" CreationDate="2016-06-22T21:45:55.733" Score="9" ViewCount="9939" Body="&lt;p&gt;I have encountered something that I have never seen before in Vim.  While I was tentatively modifying some of the source code for software I've been planning to work on, I noticed vim was displaying incorrect spacing for the line of code that I added.  Gedit shows the code with the correct spacing.  I know Gedit has the correct spacing because the Python code delivers errors if I change the code in Vim to be where it appears to belong within the Vim window.  I have attached the Images below.  The line that I added is the line that says: print &quot;I am about to evaluate a factorial&quot;.  I have included my short .vimrc file as well.  Has anyone seen this?  I have been using vim for months now and can't recall anything like this ever occuring.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Vim (Incorrect):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Pygxb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Pygxb.png&quot; alt=&quot;Vim wrong&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Gedit (Correct):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rs8tl.jpg&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;gedit&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rs8tl.jpg&quot; alt=&quot;Gedit right&quot; title=&quot;gedit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Vimrc: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wAJdo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wAJdo.png&quot; alt=&quot;Vimrc file&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8137" LastEditorUserId="51" LastEditDate="2019-05-03T03:23:50.023" LastActivityDate="2022-03-11T17:10:27.857" Title="Vim doesn't use the correct indentation in Python files" Tags="|indentation|whitespace|tab-characters|filetype-python|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8383" PostTypeId="2" ParentId="8382" CreationDate="2016-06-22T21:53:32.680" Score="17" Body="&lt;p&gt;It gets reset by the Python filetype plugin; from &lt;code&gt;/usr/share/vim/vim74/ftplugin/python.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; As suggested by PEP8.&#xA;setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This file is loaded every time a Python file is loaded.&lt;/p&gt;&#xA;&lt;p&gt;To override it add this in your vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup python&#xA;    autocmd!&#xA;    &amp;quot; Add shiftwidth and/or softtabstop if you want to override those too.&#xA;    autocmd FileType python setlocal noexpandtab tabstop=4&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will get loaded after the ftplugin file, overriding the settings from there.&lt;/p&gt;&#xA;&lt;p&gt;I would recommend against using tabs in Python files, as the community standard is to use spaces.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2021-01-29T04:00:51.387" LastActivityDate="2021-01-29T04:00:51.387" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8384" PostTypeId="2" ParentId="8366" CreationDate="2016-06-22T22:26:22.183" Score="1" Body="&lt;p&gt;I was able to solve this issue by using the command &lt;code&gt;lsof -p PID&lt;/code&gt;. This gave me the python vim was using (which I couldn't find with &lt;code&gt;sys.executable&lt;/code&gt;). Then I realized I was including this directory in &lt;code&gt;DYLD_FRAMEWORK_PATH&lt;/code&gt; in my &lt;code&gt;.bash_profile&lt;/code&gt;. I just deleted it and vim could pick up the correct python version.&lt;/p&gt;&#xA;" OwnerUserId="1713" LastActivityDate="2016-06-22T22:26:22.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8385" PostTypeId="1" AcceptedAnswerId="8387" CreationDate="2016-06-22T23:53:10.590" Score="4" ViewCount="1563" Body="&lt;p&gt;When I use &lt;code&gt;:read &amp;lt;filename&amp;gt;&lt;/code&gt; in Vim, does it only look in the current working directory? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to set up vim to have the &lt;code&gt;:read&lt;/code&gt; read reference multiple directories when attempting to open a particular file?&lt;/p&gt;&#xA;" OwnerUserId="8138" LastEditorUserId="1821" LastEditDate="2016-06-27T08:22:16.903" LastActivityDate="2016-06-27T08:22:16.903" Title="directory path search for :read" Tags="|path|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8386" PostTypeId="1" AcceptedAnswerId="8394" CreationDate="2016-06-23T00:10:41.117" Score="4" ViewCount="243" Body="&lt;p&gt;I find myself performing a small shell loop (involving &lt;code&gt;vim&lt;/code&gt;) to transform files into the correct line endings for my system.  It looks as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in *; do vim -c 'set ff=dos' -c 'wq' $i; done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works.  The problem is that the terminal flashes during the loop as vim &lt;strong&gt;opens and closes repeatedly&lt;/strong&gt;.  There should be a more elegant way to perform this.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Attempt 1 (-e -s)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;-e&lt;/code&gt; and &lt;code&gt;-s&lt;/code&gt; from &lt;code&gt;:h arguments&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in *; do vim -e -s -c 'set ff=dos' -c 'wq' $i; done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it is not doing what I believed it would do. &lt;code&gt;set ff=&lt;/code&gt; is an &lt;code&gt;ex&lt;/code&gt; command alright, and the command above works if I do not include &lt;code&gt;-s&lt;/code&gt;.  But if I leave &lt;code&gt;-s&lt;/code&gt; out it opens and closes vim just like the original command.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Attempt 2 (:argdo)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I'm afraid of &lt;code&gt;argdo&lt;/code&gt; because I never understood how it can perform changes to several buffers without writing them back to disk.  And I just run into this exact issue in this attempt.  I open all files with &lt;code&gt;vim *&lt;/code&gt; and try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdo set ff=unix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But after changing the current file I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E37: No write since last change (add ! to override)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'm probably missing something simple in both attempts.  I'm very keen on finding a good solution for attempt 1, since it is easier to automate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the elegant way of performing such a multi-file conversion in vim?&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-06-28T15:40:04.220" Title="Can I run -c in batch mode (without opening the curses display)?" Tags="|ex-mode|argument-list|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8387" PostTypeId="2" ParentId="8385" CreationDate="2016-06-23T00:40:00.190" Score="6" Body="&lt;p&gt;You cannot configure the path that &lt;code&gt;:read&lt;/code&gt; will use.  It will always start from the current directory. &lt;code&gt;:read&lt;/code&gt; is not affected by the &lt;code&gt;path&lt;/code&gt; variable in vim (see &lt;code&gt;:h path&lt;/code&gt;). Although, see the workaround sections below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that once you input &lt;code&gt;:read&lt;/code&gt; into the prompt you can use &lt;kbd&gt;tab&lt;/kbd&gt; for file and directory completion, including going up (with &lt;code&gt;..&lt;/code&gt;) and down the directory tree.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Workaround 1: use &lt;code&gt;:find&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:find&lt;/code&gt; will open the file if it is present in any directory present in the &lt;code&gt;path&lt;/code&gt; variable.  If you set the &lt;code&gt;path&lt;/code&gt; as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set path=.,/home/me/myfiles&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then when you perform:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:find myfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;myfile&lt;/code&gt; is not present in the working directory, vim will look for &lt;code&gt;/home/me/myfiles/myfile&lt;/code&gt; and open it instead (if it exists).  You can have as many paths, separated by commas (&lt;code&gt;,&lt;/code&gt;), in the &lt;code&gt;path&lt;/code&gt; variable as needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h path&lt;/code&gt; is very useful.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Workaround 2: script it&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you need the full functionality of &lt;code&gt;:read&lt;/code&gt; (e.g. to add the contents of a file to another file), you can use the fact that &lt;code&gt;:read&lt;/code&gt; can use the standard output of a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:read !&amp;lt;command&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Therefore you can write a script such as (I'm using &lt;code&gt;bash&lt;/code&gt; here for brevity):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;cd /home/me/myfiles&#xA;cat $1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's say that the script is in the executable path (&lt;code&gt;PATH&lt;/code&gt; on *nix, &lt;code&gt;%PATH%&lt;/code&gt; on windows) and is called &lt;code&gt;myread.sh&lt;/code&gt;, then you can perform:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r !myread.sh myfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To open &lt;code&gt;/home/me/myfiles/myfile&lt;/code&gt; from &lt;em&gt;any&lt;/em&gt; working directory.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-06-26T23:59:11.687" LastActivityDate="2016-06-26T23:59:11.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8389" PostTypeId="1" CreationDate="2016-06-23T04:06:24.413" Score="4" ViewCount="382" Body="&lt;p&gt;I was reading that the way to indent in vim is a &lt;code&gt;gg=G&lt;/code&gt; sequence. This however loses my cursor position. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I indent my file without losing my cursor position?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2016-06-24T14:03:13.973" Title="How can you indent your current file without losing your cursor position?" Tags="|cursor-movement|indentation|cursor-motions|cursor|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8390" PostTypeId="2" ParentId="8389" CreationDate="2016-06-23T04:54:49.397" Score="3" Body="&lt;p&gt;You should use a mark, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;magg=G`a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;ma&lt;/code&gt; will set the &lt;code&gt;a&lt;/code&gt; mark at the current position, then &lt;code&gt;gg=G&lt;/code&gt; indents the file, and &lt;code&gt;`a&lt;/code&gt; will jump to the mark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to put the cursor at the center of the screen afterwards, you could finish this off with &lt;code&gt;zz&lt;/code&gt;. See &lt;code&gt;:h scroll-cursor&lt;/code&gt; for more info and for similar scroll mappings.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2016-06-23T06:40:05.417" LastActivityDate="2016-06-23T06:40:05.417" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8391" PostTypeId="2" ParentId="8389" CreationDate="2016-06-23T05:20:02.987" Score="5" Body="&lt;p&gt;Expanding on Karl Yngve Lervåg's answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;maHmbgg=G`bzt`a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ma   - Set mark 'a'&#xA;H    - Jump to the top of the window&#xA;mb   - Set mark 'b'&#xA;gg=G - Indent from the first line to the last&#xA;`b   - Jump to mark 'b'&#xA;zt   - Scroll the cursor line to the top of the window&#xA;`a   - Jump to mark 'a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will preserve your scroll position after indenting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to preserve the relative cursor position after the cursor line has been indented, you have to update the new cursor position after indenting.  The following script expands on romainl's answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:reindent(line1, line2)&#xA;  let view = winsaveview()&#xA;  let text = getline('.')&#xA;  execute a:line1.','.a:line2.'normal! =='&#xA;  let view.col -= strchars(text) - strchars(getline(view.lnum))&#xA;  call winrestview(view)&#xA;endfunction&#xA;&#xA;&#xA;command! -range=% Reindent call s:reindent(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-06-24T14:03:13.973" LastActivityDate="2016-06-24T14:03:13.973" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8392" PostTypeId="2" ParentId="8389" CreationDate="2016-06-23T05:23:55.583" Score="8" Body="&lt;p&gt;You could define a custom command using &lt;code&gt;:help winsaveview()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% Equal let b:wv = winsaveview() | silent execute &amp;lt;line1&amp;gt; . ',' . &amp;lt;line2&amp;gt; . 'normal! ==' | call winrestview(b:wv)&#xA;&#xA;:Equal             like gg=G&#xA;:12,23Equal        like :12,23normal! ==&#xA;v{motion}:Equal    like v{motion}=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-06-23T05:23:55.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8393" PostTypeId="2" ParentId="6901" CreationDate="2016-06-23T06:02:50.453" Score="2" Body="&lt;p&gt;Since posting this question I've learned the trick of wrapping automated &lt;code&gt;ex&lt;/code&gt; edits in pipelines, with &lt;code&gt;printf&lt;/code&gt; used to send the actual commands.  This has the advantage that &lt;code&gt;ex&lt;/code&gt; will not hang on error conditions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I would do this now for a portable script would be:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Make a copy (backup) of the file.&lt;/li&gt;&#xA;&lt;li&gt;Do the edits using &lt;code&gt;printf&lt;/code&gt; to pipe commands to &lt;code&gt;ex&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Delete the backup if it is identical to the edited file (i.e. no changes have been made).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Simplistically, this would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cp file file.bak&#xA;printf '%s\n' '%s/pattern/replace/g' x | ex file&#xA;cmp -s file file.bak &amp;amp;&amp;amp; rm file.bak&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More robustly, I might do it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;[ -e file.bak ] &amp;amp;&amp;amp; exit 1&#xA;[ -w file ] &amp;amp;&amp;amp; [ -r file ] || exit 1&#xA;cp file file.bak&#xA;printf '%s\n' '%s/pattern/replace/g' x | ex file&#xA;cmp -s file file.bak &amp;amp;&amp;amp; rm file.bak&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2016-06-23T06:02:50.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8394" PostTypeId="2" ParentId="8386" CreationDate="2016-06-23T09:00:29.407" Score="3" Body="&lt;p&gt;You can use the following, it is nearly what you have done (using another example to see difference), you need to add the &lt;code&gt;hidden&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ touch a b c&#xA;$ cat *&#xA;$ vi * +&quot;set hidden&quot; +&quot;argdo r\!ls&quot; +&quot;xall&quot;&#xA;$ cat *&#xA;&#xA;a&#xA;b&#xA;c&#xA;&#xA;a&#xA;b&#xA;c&#xA;&#xA;a&#xA;b&#xA;c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set hidden&lt;/code&gt; tells vim you can switch buffer without saving them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still want to use your loop, you can do the same:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in *; do vim +&quot;r\!ls&quot; +&quot;x&quot; $i; done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-23T22:16:01.247" LastActivityDate="2016-06-23T22:16:01.247" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8395" PostTypeId="1" AcceptedAnswerId="8403" CreationDate="2016-06-23T09:41:10.853" Score="1" ViewCount="1341" Body="&lt;p&gt;Right now I am working on a latex project. When I open a netrw/vinegar window, I get following coloring:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6oiWR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6oiWR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently, certain filetypes are grayed out and other are not. I like the idea to emphasize files which are user input files and those which are generated/binary types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Netrw has following boolean variable &lt;code&gt;g:netrw_special_syntax&lt;/code&gt;. It enables  highlighting for certain group of filetypes.  Details can be found in &lt;code&gt;$VIMRUNTIME/syntax/netrw.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, following file extensions are not specified in &lt;code&gt;$VIMRUNTIME/syntax/netrw.vim&lt;/code&gt;, but are still grayed out in my screenshot: &lt;code&gt;.fdb_latexmk, .log, .aux, .fls, .out, .toc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What has to be done to gray out, e.g. the special files of the &lt;code&gt;minitoc&lt;/code&gt; package?&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2016-06-23T14:15:17.277" Title="Customize syntax highlighting in netrw" Tags="|syntax-highlighting|netrw|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8396" PostTypeId="1" AcceptedAnswerId="8397" CreationDate="2016-06-23T11:20:50.913" Score="6" ViewCount="6839" Body="&lt;p&gt;When I try to get a program to compile, I use the following process:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:sh&lt;/code&gt; to open a shell&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;make&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;scroll up to see the compilation errors&lt;/li&gt;&#xA;&lt;li&gt;exit to get back to vim&lt;/li&gt;&#xA;&lt;li&gt;fix errors that I remember (usually 2 or 3 of them)&lt;/li&gt;&#xA;&lt;li&gt;goto step 1&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is kind of tedious, ideally I would like to see the errors in a horizontal split pane alongside the code I am editing. However, unlike emacs I cannot open a buffer that has a terminal in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I improve my process?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="1841" LastEditDate="2016-06-23T11:51:50.273" LastActivityDate="2016-06-23T12:27:19.813" Title="Working with error lists while compiling" Tags="|buffers|split|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8397" PostTypeId="2" ParentId="8396" CreationDate="2016-06-23T11:35:19.397" Score="7" Body="&lt;p&gt;You should look at &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix.txt&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h quickfix.txt&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim has a special mode to speedup the edit-compile-edit cycle.  This is&#xA;  inspired by the quickfix option of the Manx's Aztec C compiler on the Amiga.&#xA;  The idea is to save the error messages from the compiler in a file and use Vim&#xA;  to jump to the errors one by one.  You can examine each problem and fix it,&#xA;  without having to remember all the error messages.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To compile your code use the &lt;code&gt;:make&lt;/code&gt; command (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :make&lt;/code&gt;&lt;/a&gt;)&#xA;Then to move between your errors you can use &lt;code&gt;:cnext&lt;/code&gt; and &lt;code&gt;:cprevious&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The doc describes the behavior of &lt;code&gt;:make&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If vim was built with &lt;code&gt;+autocmd&lt;/code&gt;, all relevant &lt;code&gt;QuickFixCmdPre&lt;/code&gt; autocommands are executed.&lt;/li&gt;&#xA;&lt;li&gt;If the &lt;code&gt;'autowrite'&lt;/code&gt; option is on, write any changed buffers&lt;/li&gt;&#xA;&lt;li&gt;An errorfile name is made from &lt;code&gt;'makeef'&lt;/code&gt;.  If &lt;code&gt;'makeef'&lt;/code&gt; doesn't contain &lt;code&gt;&quot;##&quot;&lt;/code&gt;, and a file with this name already exists, it is deleted.&lt;/li&gt;&#xA;&lt;li&gt;The program given with the &lt;code&gt;'makeprg'&lt;/code&gt; option is started (default &quot;make&quot;) with the optional &lt;code&gt;[arguments]&lt;/code&gt; and the output is saved in the errorfile (for Unix it is also echoed on the screen).&lt;/li&gt;&#xA;&lt;li&gt;The errorfile is read using &lt;code&gt;'errorformat'&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If vim was built with &lt;code&gt;+autocmd&lt;/code&gt;, all relevant &lt;code&gt;QuickFixCmdPost&lt;/code&gt; autocommands are executed.  See example below.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;code&gt;[!]&lt;/code&gt; is not given the first error is jumped to.&lt;/li&gt;&#xA;&lt;li&gt;The errorfile is deleted.&lt;/li&gt;&#xA;&lt;li&gt;You can now move through the errors with commands like &lt;code&gt;:cnext&lt;/code&gt; and &lt;code&gt;:cprevious&lt;/code&gt;, see above.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You should also have a look at &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27makeprg%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'makeprg'&lt;/code&gt;&lt;/a&gt; to define the behavior of &lt;code&gt;:make&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that Vim must be compiled with &lt;code&gt;+autocmd&lt;/code&gt; enabled.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some additional commands to navigate the quickfix list are the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cnext  Jump to next item&#xA;:cprev  Jump to previous item&#xA;:cfirst Jump to first item&#xA;:clast  Jump to last item&#xA;:cnfile Jump to first item in next file&#xA;:cpfile Jump to last item in previous file&#xA;:cc     N Jump to nth item&#xA;:copen  Open the quickfix window&#xA;:cclose Close the quickfix window&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could also be interested in the location-list feature (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#location-list&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h location-list&lt;/code&gt;&lt;/a&gt;). There can only be one quickfix list whereas there can be several location-list (one by window), thus you can compile two files and switch between them without erasing the location of the errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To manipulate the location-list you can use the same commands as the ones used with the quickfix but prefixing them with &lt;code&gt;l&lt;/code&gt;: &lt;code&gt;:lmake&lt;/code&gt;, &lt;code&gt;:lnext&lt;/code&gt;, etc... The commands interacting with the location-list will use the location-list of the current window.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I would also recommend reading &lt;a href=&quot;https://pragprog.com/book/dnvim/practical-vim&quot; rel=&quot;noreferrer&quot;&gt;Practical Vim&lt;/a&gt; which provides some very good tips and has a section dedicated to compilation and using the quickfix list.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-06-23T12:27:19.813" LastActivityDate="2016-06-23T12:27:19.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8398" PostTypeId="2" ParentId="6901" CreationDate="2016-06-23T12:57:06.357" Score="2" Body="&lt;p&gt;You could store whether to exit or not in a register, then execute it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; store q! in register x&#xA;s/$/^Mq!/ | d x&#xA;&quot;&#xA;&quot; if pattern exists, store &quot; in register x&#xA;g/pattern/ s/$/^M&quot;/ | d x&#xA;&quot;&#xA;&quot; execute :q! if pattern wasn't found, :&quot; if it was&#xA;@x&#xA;&quot;&#xA;w %.bup&#xA;&quot;&#xA;&quot; ... more edits ...&#xA;&quot;&#xA;wq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You probably don't want to use ex for any complicated control flow though. Maybe use a more fully featured programming language. Or in this case you could grep for the pattern first:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ grep pattern file &amp;amp;&amp;amp; ex -c 'commands' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-06-23T14:59:45.383" LastActivityDate="2016-06-23T14:59:45.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8399" PostTypeId="1" AcceptedAnswerId="8400" CreationDate="2016-06-23T13:06:39.520" Score="3" ViewCount="184" Body="&lt;p&gt;My file consists of the following text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;one&#xA;bone&#xA;stone&#xA;cuttlebone&#xA;minestrone&#xA;cornerstone&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to select all instances of &lt;code&gt;bone&lt;/code&gt; and &lt;code&gt;stone&lt;/code&gt;, so I get the following highlighted text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;one&#xA;BONE&#xA;STONE&#xA;cuttleBONE&#xA;minestrone&#xA;cornerSTONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NB: &lt;em&gt;capitals indicate highlighted text since I can't format in code&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried the following search patterns, but none of them work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/bone|stone&#xA;/[st|b]one&#xA;/[\(st\)b]one&#xA;/[bst]one&#xA;/[b(st)]one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is &lt;code&gt;stone&lt;/code&gt; and &lt;code&gt;bone&lt;/code&gt; are different lengths, and I don't know how to match to two different length options.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I match all instances of &lt;code&gt;stone&lt;/code&gt; and &lt;code&gt;bone&lt;/code&gt; in my file?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="3209" LastActivityDate="2016-06-23T14:10:44.697" Title="Search for mismatched length alternative pattern?" Tags="|regular-expression|search|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8400" PostTypeId="2" ParentId="8399" CreationDate="2016-06-23T13:21:50.963" Score="8" Body="&lt;p&gt;You need to escape the &lt;code&gt;|&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/bone\|stone&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to reuse the &lt;code&gt;one&lt;/code&gt; part, you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\(b\|st\)one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This create a sub expression &lt;code&gt;b\|st&lt;/code&gt; and add &lt;code&gt;one&lt;/code&gt; to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As DJ McMayhem suggested, you can use the &lt;code&gt;\v&lt;/code&gt; &quot;verymagic&quot; flag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v(b|st)one &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-23T14:10:44.697" LastActivityDate="2016-06-23T14:10:44.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8401" PostTypeId="2" ParentId="8395" CreationDate="2016-06-23T13:29:27.530" Score="1" Body="&lt;p&gt;I think the &lt;code&gt;g:netrw_special_syntax&lt;/code&gt; specify wether you want the special highlight or not, you should not be able to change the files types. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add you own syntax to your &lt;code&gt;.vimrc&lt;/code&gt; if you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match netrwMiniTOC \(\S\+ \)*\S\+\.minitoc\&amp;gt;&quot; contains=netrwTreeBar,@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-23T13:29:27.530" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8402" PostTypeId="2" ParentId="8399" CreationDate="2016-06-23T13:57:23.803" Score="5" Body="&lt;p&gt;Nobe4's answer is spot-on. Here's an alternative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-abolish&quot;&gt;vim-abolish&lt;/a&gt;. This plugin works fantastic for searching and/or replacing simple variants on a word. For example, let's say you want to turn 'child' to 'adult', while also getting 'children' to 'adults', and all case-variants. You can do that with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Subvert/child{,ren}/adult{,s}/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your case, you can do a subvert search with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Subvert /{st,b}one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-23T13:57:23.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8403" PostTypeId="2" ParentId="8395" CreationDate="2016-06-23T14:08:36.630" Score="0" Body="&lt;p&gt;With the help of &lt;a href=&quot;https://vi.stackexchange.com/users/1821/nobe4&quot;&gt;nobe4&lt;/a&gt; I figured it out.&#xA;The plugin vinegar by tpope adds &lt;code&gt;netrwSuffixes&lt;/code&gt; to &lt;code&gt;SpecialKey&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  exe 'syn match netrwSuffixes =\%(\S\+ \)*\S\+\%('.join(map(split(&amp;amp;suffixes, ','), s:escape), '\|') . '\)[*@]\=\S\@!='&#xA;  hi def link netrwSuffixes SpecialKey&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I have to extend the definition of &lt;code&gt;'suffixes'&lt;/code&gt; for the latex package &lt;code&gt;minitoc&lt;/code&gt; generated files to gray them out as it happens for other generated files by latex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To change the coloring shown in the screenshot, add following to &lt;code&gt;~/.vim/after/ftplugin/tex.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal suffixes+=.maf&#xA;setlocal suffixes+=.mtc&#xA;setlocal suffixes+=.mtc0&#xA;setlocal suffixes+=.mtc1&#xA;setlocal suffixes+=.mtc2&#xA;setlocal suffixes+=.ptc&#xA;setlocal suffixes+=.stc1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-06-23T14:15:17.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8404" PostTypeId="1" AcceptedAnswerId="8428" CreationDate="2016-06-23T15:18:54.657" Score="3" ViewCount="1414" Body="&lt;p&gt;I am using NeoVim terminal with picocom.  Every so ofter, I would like to clear the terminal buffer/screen inside the NeoVim terminal without exiting picocom, is there a short cut that clears the NeoVIM terminal buffer?&lt;/p&gt;&#xA;" OwnerUserId="3050" LastActivityDate="2016-06-24T05:23:40.600" Title="Clear NeoVim Terminal window" Tags="|neovim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8405" PostTypeId="1" AcceptedAnswerId="8407" CreationDate="2016-06-23T15:52:37.767" Score="7" ViewCount="1438" Body="&lt;p&gt;Vim help's &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/doc/change.txt#L1171-L1180&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;change.txt&lt;/code&gt;&lt;/a&gt; states that&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that after a characterwise yank command, Vim leaves the cursor on the&#xA;  first yanked character that is closest to the start of the buffer.  This means&#xA;  that &quot;yl&quot; doesn't move the cursor, but &quot;yh&quot; moves the cursor one character&#xA;  left.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Rationale:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;In Vi the &quot;y&quot; command followed by a backwards motion would&#xA;  sometimes not move the cursor to the first yanked character,&#xA;  because redisplaying was skipped.  In Vim it always moves to&#xA;  the first character, as specified by Posix.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;With a linewise yank command the cursor is put in the first line, but the&#xA;  column is unmodified, thus it may not be on the first yanked character.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sure enough, if I have my cursor at &lt;code&gt;V&lt;/code&gt; in &lt;code&gt;someVerySpecificSubclass&lt;/code&gt; and do a &lt;code&gt;yiw&lt;/code&gt;, the cursor will move to the start of the word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to yank this word without having the cursor move, because a lot of the time I want to change &lt;code&gt;someVerySpecificSubclass&lt;/code&gt; to &lt;code&gt;someSubclass&lt;/code&gt; but I'll need &lt;code&gt;someVerySpecificSubclass&lt;/code&gt; somewhere else in the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This movement is not added to the jumplist, so I can't jump back with &lt;code&gt;CTRL-o&lt;/code&gt;. I can force adding it to the jumplist with &lt;code&gt;m'&lt;/code&gt;, so I could &lt;code&gt;m'yiw&amp;lt;C-o&amp;gt;&lt;/code&gt;, but that is somewhat long (and I'm not sure how to map it properly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, it doesn't make sense to me that a yank operation would move the cursor at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/3806629/yank-a-region-in-vim-without-the-cursor-moving-to-the-top-of-the-block&quot;&gt;Yank a region in VIM without the cursor moving to the top of the block?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/2523/keep-cursor-from-moving-when-yanking-upwards&quot;&gt;Keep cursor from moving when yanking upwards&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/2686/backward-motions-in-operator-pending-mode-move-cursor?rq=1&quot;&gt;Backward motions in Operator-pending mode move cursor&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;None of the solutions provided work for my use case, they all seem to assume you want the cursor to be placed at the end of the yanked text, not necessarily at the original position, which can (and in my case is) somehwere in the middle of the yanked text.&lt;/p&gt;&#xA;" OwnerUserId="5374" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2022-08-05T22:32:39.600" Title="Prevent the cursor from moving to the start of the yanked text?" Tags="|key-bindings|cursor-movement|cut-copy-paste|jumplist|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8406" PostTypeId="1" AcceptedAnswerId="8408" CreationDate="2016-06-23T16:31:33.263" Score="6" ViewCount="6763" Body="&lt;p&gt;I recently got to know that useful info can be shown in title of bash terminal when editing files using vim. Adding below displays file name, path of the file being edited.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set title&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But on exiting vim, the title is set to 'Thanks for flying vim'. I have different title set for each bash terminal and would like it to be restored once I close the vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way to change this behaviour of vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before:&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/R1uo0.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/R1uo0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While editing a file in vim:&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/C0hl8.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/C0hl8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After:&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tDz9O.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tDz9O.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Animation: see the title text&#xA;&lt;a href=&quot;https://i.stack.imgur.com/BpCPU.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BpCPU.gif&quot; alt=&quot;Animation&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8092" LastEditorUserId="8092" LastEditDate="2016-06-23T21:39:43.550" LastActivityDate="2020-08-14T23:33:41.210" Title="How to restore bash terminal title if using 'set title' in vim?" Tags="|vimrc|terminal|" AnswerCount="6" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8407" PostTypeId="2" ParentId="8405" CreationDate="2016-06-23T16:38:41.440" Score="3" Body="&lt;p&gt;Here's some vimscript I whipped up that seems to work pretty well. (&lt;strong&gt;disclaimer:&lt;/strong&gt; I have not done extensive testing on this. I just threw it together in a couple minutes)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! YankNoMove()&#xA;  let repcount = v:count&#xA;  if v:count == 0&#xA;    let repcount = 1&#xA;  endif&#xA;  exe &quot;normal! m'&quot;.repcount.&quot;y&quot;.nr2char(getchar()).&quot;^O&quot;&#xA;endfunction&#xA;&#xA;function! YankObjectNoMove(object)&#xA;  let repcount = v:count&#xA;  if v:count == 0&#xA;    let repcount = 1&#xA;  endif&#xA;  exe &quot;normal! m'&quot;.repcount.&quot;y&quot;.a:object.nr2char(getchar()).&quot;^O&quot;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; y :&amp;lt;c-u&amp;gt;call YankNoMove()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; yi :&amp;lt;c-u&amp;gt;call YankObjectNoMove('i')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; ya :&amp;lt;c-u&amp;gt;call YankObjectNoMove('a')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note, &lt;code&gt;^O&lt;/code&gt; is the control character &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; and I typed it with &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works the way you thought of, but neatly wraps it up in a vimscript function. It works with counts, but only if the count is before the yank. For example, &lt;code&gt;2yw&lt;/code&gt; works, but &lt;code&gt;y2w&lt;/code&gt; does not. This will also only work with basic motions like &lt;code&gt;yb&lt;/code&gt;, &lt;code&gt;yw&lt;/code&gt;, &lt;code&gt;yiw&lt;/code&gt;, etc. It will &lt;em&gt;not&lt;/em&gt; work with &lt;code&gt;y/foo&lt;/code&gt; or &lt;code&gt;yfn&lt;/code&gt;, and unfortunately, it also breaks them. You could get around this by doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap yf yf&#xA;nnoremap yF yF&#xA;nnoremap yt yt&#xA;nnoremap yT yT&#xA;nnoremap y/ y/&#xA;nnoremap y? y?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although this is not the ideal solution. Probably the easier way would just be to treat &lt;code&gt;YankNoMove&lt;/code&gt; as an alternate operator, separate from &lt;code&gt;y&lt;/code&gt; and do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;y :&amp;lt;c-u&amp;gt;call YankNoMove()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;yi :&amp;lt;c-u&amp;gt;call YankObjectNoMove('i')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;ya :&amp;lt;c-u&amp;gt;call YankObjectNoMove('a')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, you can choose your own key sequence if you do not like &lt;code&gt;&amp;lt;leader&amp;gt;y&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-23T16:38:41.440" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8408" PostTypeId="2" ParentId="8406" CreationDate="2016-06-23T17:00:53.390" Score="16" Body="&lt;p&gt;Use the &lt;code&gt;titleold&lt;/code&gt; setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Update term title but restore old title after leaving Vim&#xA;set title&#xA;set titleold=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27titleold%27&quot;&gt;&lt;code&gt;:help 'titleold'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This option will be used for the window title when exiting Vim if the original title cannot be restored.  Only happens if 'title' is on or 'titlestring' is not empty.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-06-23T17:00:53.390" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8409" PostTypeId="1" AcceptedAnswerId="8410" CreationDate="2016-06-23T18:12:28.800" Score="1" ViewCount="1004" Body="&lt;p&gt;I am currently setting up my Vim to work with matlab. In matlab, sections are separated by &lt;code&gt;%%&lt;/code&gt;, and I am looking for a command to select my current section. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;f mf:?%%&amp;lt;CR&amp;gt;&amp;lt;Down&amp;gt;v/%%&amp;lt;CR&amp;gt;&amp;lt;Up&amp;gt;$:SlimuxREPLSendSelection&amp;lt;CR&amp;gt;`f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to mark the current position as f, search upwards for %%, and select to the next occurrence of %%. The selection is then send to the matlab terminal via Slimux and then I go back to mark f.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would like to extend this to the case when there is no %% before the cursor (then vim should go to the beginning of the file) or when there is no %% after the cursor (then vim should go to the end of the file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution by Tumbler41 almost worked for me, I had to change it a tiny bit because the Slimux function call wouldn't work and to make it able to cope when the cursor is on &lt;code&gt;%%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;f :call SendSection()&amp;lt;CR&amp;gt;:SlimuxREPLSendSelection&amp;lt;CR&amp;gt;`f&#xA;&#xA;function! SendSection()&#xA;   normal! mf&#xA;   if (search('%%', 'b') &amp;lt;= line(&quot;'f&quot;))&#xA;      normal! jV&#xA;   else&#xA;      normal! ggV&#xA;   endif&#xA;   if (search('%%') &amp;gt; line(&quot;'f&quot;))&#xA;      normal! k&#xA;   else&#xA;      normal! G&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8152" LastEditorUserId="8152" LastEditDate="2016-06-23T22:37:27.647" LastActivityDate="2016-06-23T22:41:35.420" Title="Find first occurrence of string or return end of file" Tags="|search|matlab|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8410" PostTypeId="2" ParentId="8409" CreationDate="2016-06-23T18:40:16.340" Score="0" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;f :call SendSection()&amp;lt;CR&amp;gt;&#xA;&#xA;function! SendSection()&#xA;   normal! mf&#xA;   let firstLine = search('%%', 'b')&#xA;   if (firstLine != 0 &amp;amp;&amp;amp; firstLine &amp;lt;= line(&quot;'f&quot;))&#xA;      normal! jV&#xA;   else&#xA;      normal! ggV&#xA;   endif&#xA;   if (search('%%') &amp;gt; line(&quot;'f&quot;))&#xA;      normal! k&#xA;   else&#xA;      normal! G&#xA;   endif&#xA;   '&amp;lt;,'&amp;gt;SlimuxREPLSendSelection&#xA;   normal! `f&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I don't have Slimux and therefore can't test that part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;search()&lt;/code&gt; to find out if there is a &lt;code&gt;%%&lt;/code&gt; before and after the mark &lt;code&gt;f&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-06-23T22:41:35.420" LastActivityDate="2016-06-23T22:41:35.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8411" PostTypeId="2" ParentId="8409" CreationDate="2016-06-23T18:53:00.260" Score="0" Body="&lt;p&gt;Assuming you are using the &lt;a href=&quot;https://github.com/epeli/slimux&quot; rel=&quot;nofollow&quot;&gt;slimux&lt;/a&gt; you can use &lt;code&gt;:SlimuxREPLSendLine&lt;/code&gt; with a line range. &lt;code&gt;\%^&lt;/code&gt; and &lt;code&gt;\%$&lt;/code&gt; mark the start and end of the file respectively. Combine these regex anchors with a pattern alternation (&lt;code&gt;\|&lt;/code&gt;), we can search for &lt;code&gt;%%&lt;/code&gt; or one of the anchors.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;f mf:+?\(%%\n\zs\&amp;lt;bar&amp;gt;\%^\)?,-/\(\zs\n%%\&amp;lt;bar&amp;gt;\%$\)/SlimuxREPLSendLine&amp;lt;cr&amp;gt;`f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: Due to how trickiness of the range, this mapping will not work when you are on a &lt;code&gt;%%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To take this further you may want to may want to look into &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow&quot;&gt;vim-textobj-user&lt;/a&gt;. Here is a quick and dirty text objects:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap i% :&amp;lt;c-u&amp;gt;call search('\(%%\&amp;lt;bar&amp;gt;\%^\)\_s*\zs.', 'cbW')&amp;lt;cr&amp;gt;m&amp;lt;:call search('.\ze\_s*\(%%\&amp;lt;bar&amp;gt;\%$\)', 'We')&amp;lt;cr&amp;gt;m&amp;gt;gv&#xA;onoremap i% :normal vi%&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use &lt;code&gt;i%&lt;/code&gt; text object. Now we can pair it with the a new mapping which uses this text object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;f mfvi%:SlimuxREPLSendSelection&amp;lt;cr&amp;gt;`m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :range&#xA;:h /\|&#xA;:h /\zs&#xA;:h /\%^&#xA;:h /\%$&#xA;:h search(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2016-06-23T19:15:12.980" LastActivityDate="2016-06-23T19:15:12.980" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8412" PostTypeId="1" CreationDate="2016-06-23T19:47:27.687" Score="3" ViewCount="202" Body="&lt;p&gt;Is there a way to preload a named register in vim? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: I would like to have an empty comment always available in register &quot;c&quot;. This way I could insert it and quickly add the text.&lt;/p&gt;&#xA;" OwnerUserId="8138" LastEditorUserId="8138" LastEditDate="2016-06-23T19:58:26.000" LastActivityDate="2022-07-29T00:30:06.503" Title="Preload a named register?" Tags="|vimrc|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8413" PostTypeId="2" ParentId="8412" CreationDate="2016-06-23T19:55:57.933" Score="9" Body="&lt;p&gt;You can edit the contents of any register in vimscript by using &quot;@&quot; before the letter and then using it like a variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @c=&quot;Your text here.&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-06-23T20:03:08.627" LastActivityDate="2016-06-23T20:03:08.627" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8414" PostTypeId="1" CreationDate="2016-06-23T20:01:30.010" Score="2" ViewCount="2656" Body="&lt;p&gt;I am trying to map &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;q&lt;/kbd&gt; to quit editing the file. I added the below line to my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; nnoremap &amp;lt;C-q&amp;gt; :execute &quot;q&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On pressing the above key combination, nothing happens, vim doesn't quit. No Error, no message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you please help me figure out what is wrong with this setting?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; My vimrc file is &lt;a href=&quot;https://gist.github.com/mdtareque/9d28c7b63b2b77d15679374a8dfbad20&quot; rel=&quot;nofollow&quot;&gt;https://gist.github.com/mdtareque/9d28c7b63b2b77d15679374a8dfbad20&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see no effect of pressing &lt;code&gt;&amp;lt;C-q&amp;gt;&lt;/code&gt;, probably something is conflicting with existing setup/plugins. Above is my vimrc, almost all settings are being used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output of &lt;code&gt;verbose map &amp;lt;C-q&amp;gt;&lt;/code&gt; is &lt;code&gt;Last set from ~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI. I am on ubuntu 15.10, and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 21 2015 12:30:04)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8092" LastEditorUserId="8092" LastEditDate="2016-06-23T21:42:20.207" LastActivityDate="2016-06-23T21:42:20.207" Title="mapping to quit using &quot;&lt;Ctrl&gt; + q&quot; not coming into effect" Tags="|key-bindings|quit|" AnswerCount="1" CommentCount="11" ClosedDate="2016-06-23T22:00:02.137" ContentLicense="CC BY-SA 3.0" />
  <row Id="8415" PostTypeId="1" CreationDate="2016-06-23T20:01:37.970" Score="3" ViewCount="98" Body="&lt;p&gt;I have a program that lists hostnames and IPs. Some hostnames have multiple IPs assigned to them. When I download the IP column .csv, it lists as such: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;192.168.xx.xx&#xA;&quot;192.168.xx.xx, 192.168.xx.xx&quot;&#xA;192.168.xx.xx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am putting the contents of this .csv file into a VI file. What I would like to do is figure out how to script it so that the lines with 2 IPs (with the &quot; &quot; and ,) move one of the IPs to a new line and remove all of the &quot; &quot;  and , so that I can easily run this through a Powershell script to ping each and get their up/down status. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Goal would be to get this file: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;192.xx.xx&#xA;192.xx.xx&#xA;192.xx.xx&#xA;192.xx.xx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any suggestions? Thanks so much!&lt;/p&gt;&#xA;" OwnerUserId="8154" LastEditorUserId="2920" LastEditDate="2016-06-23T20:40:39.093" LastActivityDate="2016-06-24T11:43:35.093" Title="How to move multiple IPs to different lines" Tags="|regular-expression|substitute|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8416" PostTypeId="2" ParentId="8415" CreationDate="2016-06-23T20:13:15.230" Score="4" Body="&lt;p&gt;You can use the &lt;code&gt;:substitute&lt;/code&gt; command for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&quot;//g | %s/, /\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First replace all quotation marks with nothing (I assume there will be no escaped &lt;code&gt;&quot;&lt;/code&gt;s since these are just IP addresses). Then (&lt;code&gt;|&lt;/code&gt; is the command separator) replace all &lt;code&gt;', '&lt;/code&gt; with linebreaks (&lt;code&gt;\r&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Asubstitute&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help :substitute&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3Arange&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help range&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#pattern&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help pattern&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="205" LastEditDate="2016-06-24T11:43:35.093" LastActivityDate="2016-06-24T11:43:35.093" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8417" PostTypeId="2" ParentId="8414" CreationDate="2016-06-23T20:13:28.290" Score="4" Body="&lt;p&gt;Why do you need the call to &lt;code&gt;execute&lt;/code&gt;? This should work just fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-q&amp;gt; :q&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course if your file has been edited vim will give you a warning and won't quit.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-06-23T20:13:28.290" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8419" PostTypeId="1" AcceptedAnswerId="8420" CreationDate="2016-06-23T21:24:02.740" Score="4" ViewCount="1212" Body="&lt;p&gt;I have cursor at first &lt;code&gt;t&lt;/code&gt; and I want to delete all this code from &lt;code&gt;t&lt;/code&gt; to &lt;code&gt;};\n&lt;/code&gt; without counting lines. How can I achieve it? Is there more cleaner way than &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;}&lt;/kbd&gt;&lt;kbd&gt;;&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tabControl.PropertyChanged += (s, e) =&amp;gt;&#xA;{&#xA;    ...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it matters, this is C#.&lt;/p&gt;&#xA;" OwnerUserId="8149" LastEditorUserId="8149" LastEditDate="2016-07-02T08:50:43.797" LastActivityDate="2016-07-03T17:45:34.440" Title="vim delete parenthesis" Tags="|cut-copy-paste|" AnswerCount="4" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="8420" PostTypeId="2" ParentId="8419" CreationDate="2016-06-23T21:27:18.213" Score="5" Body="&lt;p&gt;I would have gone for &lt;code&gt;v&amp;lt;down&amp;gt;%&amp;lt;right&amp;gt;d&lt;/code&gt;, or &lt;code&gt;vj%ld&lt;/code&gt; if you're allergic to cursor keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to &lt;code&gt;v&lt;/code&gt; we can go into visual mode and from here, it looks like an interactive mode to select something on which a command will be applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: As Tumbler has indicated, you could also have used &lt;code&gt;V&amp;lt;down&amp;gt;%d&lt;/code&gt; which will neatly handle the last line.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-06-24T06:17:31.497" LastActivityDate="2016-06-24T06:17:31.497" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8421" PostTypeId="1" AcceptedAnswerId="8422" CreationDate="2016-06-23T21:42:11.227" Score="6" ViewCount="950" Body="&lt;p&gt;Let's say I have this piece of code (cursor/selection is represented by &lt;code&gt;[]&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[f]unction a()&#xA;{&#xA;    // ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I want to select the function declaration and the curly braces (and of course the content) I can do &lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;%&lt;/kbd&gt;, which select the first line, goes to the opening &lt;code&gt;{&lt;/code&gt; and jump to the matching &lt;code&gt;}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or I can do &lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;{&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; which goes down to select around the &lt;code&gt;{}&lt;/code&gt;, goes back to the start of the selection and move up to select the remaining line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the question: why can't I do &lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;{&lt;/kbd&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it could select the first line, then move down and expand around the curly braces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this not possible?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="2313" LastEditDate="2016-06-24T06:42:37.397" LastActivityDate="2016-06-24T06:42:37.397" Title="Expand visual selection to inner curly braces" Tags="|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8422" PostTypeId="2" ParentId="8421" CreationDate="2016-06-23T21:59:39.697" Score="9" Body="&lt;p&gt;It's trying to select the block that encompasses &lt;strong&gt;all&lt;/strong&gt; of the selection. Since your selection is &quot;leaking&quot; out of the block and there's no other block containing it, it fails. Try &lt;code&gt;Vja{&lt;/code&gt; on this to see what I mean:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;   [f]unction a()&#xA;   {&#xA;       // ...&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-06-23T21:59:39.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8423" PostTypeId="1" AcceptedAnswerId="8427" CreationDate="2016-06-23T22:43:58.520" Score="4" ViewCount="571" Body="&lt;p&gt;I have a working prototype for some kind of linux-based neovim-app. Sole functionality is &quot;vsplit if 'k' is pressed&quot;. It is based on tarruda's &lt;a href=&quot;https://gist.github.com/tarruda/37f7a3e22996addf8921&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;nvim-terminal-edit-py&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is started through &lt;code&gt;start_nvim.sh&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;NVIM_LISTEN_ADDRESS='/tmp/nvim' /usr/bin/nvim &amp;amp;&#xA;./myapp.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;myapp.py&lt;/code&gt; is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python&#xA;import os, sys, time, subprocess&#xA;from neovim import attach&#xA;&#xA;tf = '/tmp/nvim'&#xA;&#xA;env = dict(os.environ)&#xA;env['NVIM_LISTEN_ADDRESS'] = tf&#xA;&#xA;#os.execvpe(&quot;nvim&quot;, [&quot;nvim&quot;], env)&#xA;#subprocess.Popen([&quot;/usr/bin/nvim&quot;], env=env)&#xA;#subprocess.call(['/usr/bin/nvim', '&amp;amp;'], env=env)&#xA;&#xA;nvim = attach(&quot;socket&quot;, path=tf)&#xA;&#xA;def key_subscribe(key, to):&#xA;    cid = nvim.channel_id                                                                                                               &#xA;    nvim.command( ('nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; %s ' + ':call rpcnotify(%d, &quot;keypress&quot;, &quot;%s&quot;)&amp;lt;cr&amp;gt;') % (key, cid, to))&#xA;&#xA;&#xA;def _request_cb(*args):&#xA;    pass&#xA;&#xA;&#xA;def _notification_cb(*args):&#xA;    nvim.command('vsplit')&#xA;&#xA;&#xA;def _setup_cb():&#xA;    key_subscribe('k', 'up')&#xA;&#xA;&#xA;nvim.run_loop(_request_cb, _notification_cb, _setup_cb)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to start &lt;code&gt;/usr/bin/nvim&lt;/code&gt; from within &lt;code&gt;myapp.py&lt;/code&gt;, so that &lt;code&gt;start_nvim.sh&lt;/code&gt; is not necessary?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did try various things. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Uncommenting the respective line in &lt;code&gt;myapp.py&lt;/code&gt; and directly executing &lt;code&gt;./myapp.py&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;execvpe&lt;/code&gt; does start nvim, but if I press &lt;code&gt;k&lt;/code&gt; no vsplit is triggered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Popen&lt;/code&gt; and &lt;code&gt;call&lt;/code&gt; yield&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Traceback (most recent call last):&#xA;  File &quot;./myapp.py&quot;, line 18, in &amp;lt;module&amp;gt;&#xA;    nvim = attach(&quot;socket&quot;, path=tf)&#xA;...&#xA;FileNotFoundError: [Errno 2] No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, Popen/call didn't pass &lt;code&gt;/tmp/nvim&lt;/code&gt; to &lt;code&gt;nvim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8156" LastEditorUserId="6489" LastEditDate="2016-06-23T22:45:50.863" LastActivityDate="2016-06-24T03:57:23.973" Title="Start and attach to neovim in same python file" Tags="|neovim|vimscript-python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8425" PostTypeId="1" CreationDate="2016-06-23T22:55:16.870" Score="5" ViewCount="322" Body="&lt;p&gt;I am new to Vim and I am trying to remap the four (arrow) navigation keys &lt;code&gt;hjkl&lt;/code&gt; one step to the right on the keyboard to get&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;j down&lt;/li&gt;&#xA;&lt;li&gt;k up &lt;/li&gt;&#xA;&lt;li&gt;l left&lt;/li&gt;&#xA;&lt;li&gt;; right&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am following the recommendations given in &lt;a href=&quot;https://stackoverflow.com/a/15330610/2173773&quot;&gt;this answer&lt;/a&gt;&lt;sup&gt;[1]&lt;/sup&gt;, and&#xA;I am using a norwegian keyboard where the &lt;kbd&gt;;&lt;/kbd&gt; key is replaced by an &lt;kbd&gt;ø&lt;/kbd&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my &lt;code&gt;~/.vimrc&lt;/code&gt; I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap l h&#xA;nnoremap ø l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have installed the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2174&quot; rel=&quot;nofollow noreferrer&quot;&gt;repmo&lt;/a&gt; plugin, and I suspect that is the cause of the problems I have with this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the problem is that the &lt;code&gt;l&lt;/code&gt; key does not map to &lt;code&gt;h&lt;/code&gt; (left); instead, when I press &lt;code&gt;l&lt;/code&gt;, the cursor moves to the right.&#xA;To debug, I tried to print out the actual mappings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:map h&lt;/code&gt; gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nx h           &amp;amp; &amp;lt;SNR&amp;gt;9_repmo('h','l')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:map l&lt;/code&gt; gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n  l             &amp;lt;SNR&amp;gt;9_lastkey&#xA;x  l             &amp;lt;SNR&amp;gt;9_lastkey&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Footnotes:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&#xA;[1] Answer to stackoverflow.com question: &lt;a href=&quot;https://stackoverflow.com/q/6698521/2173773&quot;&gt;Vim users, where do you rest your right hand?&lt;/a&gt;&#xA;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="8079" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-08-08T01:49:41.857" Title="Remapping home row keys hjkl when using repmo plugin" Tags="|key-bindings|" AnswerCount="0" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8426" PostTypeId="2" ParentId="8419" CreationDate="2016-06-24T03:07:09.833" Score="2" Body="&lt;p&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;b&lt;/kbd&gt;` is for deleting a block. You can also use &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;{&lt;/kbd&gt; for that to take effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case if &lt;code&gt;;&lt;/code&gt; at the end is not deleted, you can press &lt;kbd&gt;x&lt;/kbd&gt; to delete that character &lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="8149" LastEditDate="2016-07-02T11:42:35.160" LastActivityDate="2016-07-02T11:42:35.160" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8427" PostTypeId="2" ParentId="8423" CreationDate="2016-06-24T03:57:23.973" Score="3" Body="&lt;p&gt;Your problem is that you're starting a Neovim subprocess and it's blocking before processing the rest of your script.  When you quit Neovim, the rest of the script executes well after the file socket has outlived its use to Neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to start it from a thread so that the rest of the script can execute.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;#!/usr/bin/env python&#xA;import os&#xA;import time&#xA;import threading&#xA;import subprocess&#xA;&#xA;from neovim import attach&#xA;&#xA;tf = '/tmp/nvim'&#xA;&#xA;&#xA;def start_neovim():&#xA;    env = dict(os.environ)&#xA;    env['NVIM_LISTEN_ADDRESS'] = tf&#xA;    subprocess.call(['/usr/bin/nvim'], env=env)&#xA;&#xA;&#xA;t = threading.Thread(target=start_neovim)&#xA;t.daemon = True&#xA;t.start()&#xA;&#xA;# Give Neovim time to start&#xA;time.sleep(1)&#xA;&#xA;nvim = attach(&quot;socket&quot;, path=tf)&#xA;&#xA;&#xA;def key_subscribe(key, to):&#xA;    cid = nvim.channel_id&#xA;    nvim.command(('nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; %s ' + ':call rpcnotify(%d, &quot;keypress&quot;, &quot;%s&quot;)&amp;lt;cr&amp;gt;') % (key, cid, to))&#xA;&#xA;&#xA;def _request_cb(*args):&#xA;    pass&#xA;&#xA;&#xA;def _notification_cb(*args):&#xA;    nvim.command('vsplit')&#xA;&#xA;&#xA;def _setup_cb():&#xA;    key_subscribe('k', 'up')&#xA;&#xA;&#xA;nvim.run_loop(_request_cb, _notification_cb, _setup_cb)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope you're just doing this as an exercise.  Configuring key bindings using the RPC interface is a little silly considering you still have to use Vim's language to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The more common approach is to use &lt;code&gt;.vim&lt;/code&gt; scripts to setup the keybindings and API, then use Python for things that aren't practical to do in Vim such as networking or long running asynchronous work.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-24T03:57:23.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8428" PostTypeId="2" ParentId="8404" CreationDate="2016-06-24T05:23:40.600" Score="4" Body="&lt;p&gt;What you want isn't possible.  &lt;code&gt;picocom&lt;/code&gt; would need to clear the screen, but it's not a curses program so it can't.  If you want to declutter the screen so you can stay focused on new output, you can &quot;clear&quot; what's on the screen by modifying the colors of what's displayed in the terminal window.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:fake_clearterm() abort&#xA;  let top = line('w0') - 1&#xA;  let bottom = min([line('$'), line('w$')]) + 1&#xA;  silent! call matchdelete(1234)&#xA;  call matchadd('FakeClearTerm', '\%&amp;gt;'.top.'l\_.*\%&amp;lt;'.bottom.'l', 0, 1234)&#xA;endfunction&#xA;&#xA;highlight default FakeClearTerm ctermfg=234 ctermbg=16 guifg=#333333 guibg=#000000&#xA;tnoremap &amp;lt;silent&amp;gt; &amp;lt;c-l&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;:&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;fake_clearterm()&amp;lt;cr&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Explanation:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;FakeClearTerm&lt;/code&gt; highlight group sets a dark gray foreground and black background which dims the text.  You would have to adjust this to match your color scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s:fake_clearterm()&lt;/code&gt; gets the terminal window's top and bottom lines (&lt;code&gt;w0&lt;/code&gt; and &lt;code&gt;w$&lt;/code&gt; respectively).  Then it creates a pattern matching any line within window and applies the &lt;code&gt;FakeClearTerm&lt;/code&gt; highlight group to it. The match is given a priority of &lt;code&gt;0&lt;/code&gt; which allows searches to highlight text within the dimmed text.  The match ID &lt;code&gt;1234&lt;/code&gt; is arbitrary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ctrl-l&lt;/code&gt; is used to &quot;clear&quot; the text.  It's using &lt;code&gt;tnoremap&lt;/code&gt; which means it has to be used in the terminal's insert mode.  In normal mode &lt;code&gt;ctrl-l&lt;/code&gt; redraws the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After &quot;clearing&quot;, new text below the matched region will use default colors.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Caveats:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Neovim's highlighting won't overrule colors set by terminal's output.  Since &lt;code&gt;picocom&lt;/code&gt; doesn't print colors, this shouldn't be a big deal.&lt;/li&gt;&#xA;&lt;li&gt;Scrolling up is still possible and the text in the scrollback won't be dimmed.&lt;/li&gt;&#xA;&lt;li&gt;You have to &lt;code&gt;:call matchdelete(1234)&lt;/code&gt; yourself to remove the highlight.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-24T05:23:40.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8429" PostTypeId="2" ParentId="8419" CreationDate="2016-06-24T06:11:12.300" Score="7" Body="&lt;pre&gt;&lt;code&gt;Vj%d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is one solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V/^};&amp;lt;CR&amp;gt;d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whatever works for you, really.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-06-24T06:11:12.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8430" PostTypeId="2" ParentId="8415" CreationDate="2016-06-24T07:38:35.293" Score="2" Body="&lt;p&gt;You can use macros to do the same thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For removing &lt;code&gt;&quot;&lt;/code&gt;,  do this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qaqqa/&quot;&amp;lt;CR&amp;gt;xn@aq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For removing &lt;code&gt;,&lt;/code&gt; and replacing it with a new line,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qsqqs/,&amp;lt;CR&amp;gt;i&amp;lt;CR&amp;gt;xx@sq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa - start recording a  macro and stores in register `a`&#xA;q - stops the macro (empties register content.&#xA;/&quot; - find double quotes&#xA;&amp;lt;CR&amp;gt; - enter. Don't type &amp;lt;CR&amp;gt; but press enter instead of this.&#xA;x - delete the current character&#xA;n - find next occurrence&#xA;@a - replay the macro recursively&#xA;q stop the macro.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can execute the macros by pressing &lt;code&gt;@a&lt;/code&gt; and &lt;code&gt;@s&lt;/code&gt; in normal mode.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="205" LastEditDate="2016-06-24T07:57:07.950" LastActivityDate="2016-06-24T07:57:07.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8431" PostTypeId="1" AcceptedAnswerId="8432" CreationDate="2016-06-24T13:43:41.713" Score="6" ViewCount="528" Body="&lt;p&gt;I have the following vimscript: it contains a vimscript function which executes a python code thanks to &lt;code&gt;python &amp;lt;&amp;lt; EOF&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test(myArgument)&#xA;python &amp;lt;&amp;lt; EOF&#xA;def test(myArgument):&#xA;    print &quot;My argument &quot; + myArgument&#xA;&#xA;test(&quot;foo&quot;)&#xA;EOF&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I use the argument of the vimscript function &lt;code&gt;a:myArgument&lt;/code&gt; and pass it as argument to my python function (instead of &lt;code&gt;foo&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-06-24T13:43:57.927" Title="How to use the argument of a vimscript function in an inner python function?" Tags="|vimscript|vimscript-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8432" PostTypeId="2" ParentId="8431" CreationDate="2016-06-24T13:43:57.927" Score="6" Body="&lt;p&gt;You can use the &lt;code&gt;vim&lt;/code&gt; package inside python, you should be able to gain access to vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test(myArgument)&#xA;    python &amp;lt;&amp;lt; EOF&#xA;import vim&#xA;&#xA;def test(myArgument):&#xA;    print &quot;My argument &quot; + myArgument&#xA;&#xA;test(vim.eval('a:myArgument'))&#xA;EOF&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can read about the python integration at &lt;code&gt;:h python&lt;/code&gt; and about this particular feature at &lt;code&gt;:h python-eval&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-24T13:43:57.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8433" PostTypeId="1" AcceptedAnswerId="8436" CreationDate="2016-06-24T13:58:07.813" Score="21" ViewCount="2710" Body="&lt;p&gt;I often have to manually indent, but when I enter a visual mode, select my lines to indent, and press &lt;code&gt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;gt;&lt;/code&gt;, I leave visual mode whether I want to or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would rather have it so I stay in visual mode, and keep my selection and cursor position intact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2017-05-23T23:00:27.550" Title="How do you indent &gt; &lt; without leaving visual mode and losing your current selection?" Tags="|indentation|visual-mode|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8434" PostTypeId="2" ParentId="8433" CreationDate="2016-06-24T14:02:33.220" Score="10" Body="&lt;p&gt;I know this isn't an automatic solution, but you can accomplish this by using &lt;code&gt;gv&lt;/code&gt; after the visual indent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will go into visual mode with the previous selection selected, and your cursor at the last line. See &lt;code&gt;:h gv&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-06-24T14:02:33.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8435" PostTypeId="2" ParentId="8433" CreationDate="2016-06-24T14:06:37.980" Score="-1" Body="&lt;p&gt;I tried adding the following mapping to my vimrc :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt; &amp;lt;a&#xA;vmap &amp;gt; &amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to have interesting results, maybe that's what you're looking for ?&lt;/p&gt;&#xA;" OwnerUserId="7128" LastActivityDate="2016-06-24T14:06:37.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8436" PostTypeId="2" ParentId="8433" CreationDate="2016-06-24T14:07:37.390" Score="26" Body="&lt;p&gt;I have this in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;keep visual mode after indent&#xA;vnoremap &amp;gt; &amp;gt;gv&#xA;vnoremap &amp;lt; &amp;lt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you could also simply use &lt;code&gt;.&lt;/code&gt; (dot) to repeat the last indent action.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-06-24T14:07:37.390" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8437" PostTypeId="1" CreationDate="2016-06-24T14:31:53.507" Score="4" ViewCount="136" Body="&lt;p&gt;I see a lot of members here manipulating and using regexp very easily. &#xA;I am slowly learning, one trick at a time, how to search for this or that, how to handle this case, how to escape that case... But at this rate, it will take me ages before I can efficiently use VIM's regexp. I also tried to read the documentation, but all the small symbols/special characters are not the easiest to remember.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am therefore asking if there is any kind of &quot;regexp&quot; tutorial you came across during your learning process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;http://vimregex.com/&quot; rel=&quot;nofollow&quot;&gt;vimregex.com&lt;/a&gt; that's already a very good start, but maybe some of you have even better / more interactive / easier answers ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&#xA;This question was put &quot;on hold&quot; for being &quot;primarily opinion-based&quot;, which I understand. The few answers and comments I got however gave a few interesting tips, so I changed my question to the current one. &#xA;I guess it's still opinion-based ? But maybe more useful this way ? &lt;/p&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="7128" LastEditDate="2016-06-28T08:57:50.137" LastActivityDate="2016-06-28T08:57:50.137" Title="Your tips to learn regexp" Tags="|regular-expression|" AnswerCount="1" CommentCount="8" ClosedDate="2016-06-24T18:59:55.493" ContentLicense="CC BY-SA 3.0" />
  <row Id="8438" PostTypeId="2" ParentId="8437" CreationDate="2016-06-24T16:37:49.183" Score="3" Body="&lt;p&gt;Along with what everybody else said, I have a custom help file specifically for regex. Anytime I learn something that's useful, but might be hard to remember, I stick it in the help file. I can pull up this help file with a single keystroke and reference it whenever I need. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way when you learn things it's not like trying you're trying to hold all your knowledge in a sieve. And as time goes on, you might be able to remove things from the help file because you've used them so much that you know them by heart. Ultimately it's a process that you're just going to have to go through, but this tool has helped me a LOT, so I thought I'd share it.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-06-24T16:37:49.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8441" PostTypeId="1" CreationDate="2016-06-24T18:44:23.327" Score="3" ViewCount="1928" Body="&lt;p&gt;Is there a way to auto insert text in vim when a new file is created? Maybe there is a plugin for it? Here is what I'm talking about:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I work a lot with C/C++ and Python. Very often I need to create .h and .py files. We have some coding standards ( duh ). For example every .h file needs to have a following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef _filename&#xA;#define _filename&#xA;&#xA;#endif // _filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and every python file needs to have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if '__main__' == __name__:&#xA;    main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin that will auto insert this type of code automatically when the file is created? I know there are snippets out there, but I would prefer for it to be done automatically without engaging them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2865" LastActivityDate="2016-06-24T20:33:22.650" Title="auto insert text when creating a new file" Tags="|autocompletion|snippets|" AnswerCount="1" CommentCount="3" ClosedDate="2016-06-24T22:17:15.517" ContentLicense="CC BY-SA 3.0" />
  <row Id="8442" PostTypeId="2" ParentId="8441" CreationDate="2016-06-24T19:09:48.877" Score="4" Body="&lt;p&gt;As multiple people have said in various comments, check out &lt;code&gt;:h skeleton&lt;/code&gt;. This sounds like just what your looking for. However if you want a little more customizability you can try the following...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Detecting when a file is &quot;created&quot; might be hard, since vim creates files by writing buffers to files. But you can detect when you write to a file with the &lt;code&gt;BufWritePre&lt;/code&gt; autocmd. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possible solution would be to use the &lt;code&gt;BufNewfile&lt;/code&gt; autocmd. You can substitute either in the code below to find out what works best for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;/Edit&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could call a function to insert the text. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile *.h  :call CheckHFile()&#xA;autocmd BufNewFile *.py :call CheckPyFile()&#xA;&#xA;function! CheckHFile()&#xA;   let filename = expand(&quot;%:t&quot;)&#xA;   if (getline(&quot;1&quot;) !~ '#ifndef _'.filename)&#xA;      exe &quot;normal!ggO#ifndef _&quot;.filename&#xA;      exe &quot;normal!o#define _&quot;.filename&#xA;      exe &quot;normal!o^M#endif // _&quot;.filename&#xA;   endif&#xA;endfunction&#xA;&#xA;function! CheckPyFile()&#xA;   if (getline(&quot;1&quot;) !~ &quot;if '__main__' == __name__:&quot;)&#xA;      normal!ggOif '__main__' == __name__:&#xA;      normal!o    main()&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will make sure that these lines exist in the file before writing. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;expand(&quot;%:t&quot;)&lt;/code&gt; retrieves the file name to be used in the template.&lt;/li&gt;&#xA;&lt;li&gt;Note that &lt;code&gt;^M&lt;/code&gt; will need to be re-typed with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt;, &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h autocmd&#xA;:h expand&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-06-24T20:33:22.650" LastActivityDate="2016-06-24T20:33:22.650" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8443" PostTypeId="1" AcceptedAnswerId="8444" CreationDate="2016-06-24T20:51:57.707" Score="1" ViewCount="1448" Body="&lt;p&gt;I'm writing a Fortran parallel code using MPI.&#xA;I mapped &lt;code&gt;ctrl-C&lt;/code&gt; to run &lt;code&gt;make&lt;/code&gt;, in order to compile the program with proper options and dependencies. I also mapped &lt;code&gt;ctrl-&amp;lt;&lt;/code&gt; to run the program executing the command &lt;code&gt;mpirun -np 8 program&lt;/code&gt;, but this is limiting, since it runs the program on 8 processes. I would like to map the command so that I can press &lt;code&gt;ctrl-&amp;lt;&lt;/code&gt; and then type &lt;code&gt;n enter&lt;/code&gt; to run the program on &lt;code&gt;n&lt;/code&gt; processes.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastActivityDate="2016-06-24T21:07:26.230" Title="Map a command that accepts an argument" Tags="|command-line|key-bindings|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8444" PostTypeId="2" ParentId="8443" CreationDate="2016-06-24T21:06:59.183" Score="2" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Mpirn()&#xA;  let n = nr2char(getchar())&#xA;  exe &quot;!mpirun -np &quot;.n.&quot; program&quot;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;C-c&amp;gt; :&amp;lt;C-u&amp;gt;call Mpirn()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note, I had trouble mapping to &lt;code&gt;&amp;lt;C-&amp;lt;&amp;gt;&lt;/code&gt; so I left it mapped to &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; You can change this to whatever mapping you already have.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pretty straightforward answer. Takes a single number as input, and runs that command. If you ever need to run this with a two digit or more number, you can do this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MpirnArg(n)&#xA;  exe &quot;!mpirun -np &quot;.a:n.&quot; program&quot;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;C-c&amp;gt; :&amp;lt;C-u&amp;gt;call MpirnArg(v:count)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the way you call this is in reverse. e.g, &lt;code&gt;17&amp;lt;C-c&amp;gt;&lt;/code&gt; Rather than &lt;code&gt;&amp;lt;C-c&amp;gt;17&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I'm not familiar with fortran or MPI, so I don't know if &lt;code&gt;0&lt;/code&gt; is valid. If &lt;code&gt;0&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; valid, change that last mapping to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-c&amp;gt; :&amp;lt;C-u&amp;gt;call MpirnArg(v:count1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you can leave it the same.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-24T21:06:59.183" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8445" PostTypeId="2" ParentId="8443" CreationDate="2016-06-24T21:07:26.230" Score="0" Body="&lt;p&gt;I think what you're looking for is &lt;code&gt;v:count&lt;/code&gt;. You can use this in your mapping to see what number was entered before the mapping was pressed. From &lt;code&gt;:h v:count&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:map _x :echo &quot;the count is &quot; . v:count&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-06-24T21:07:26.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8446" PostTypeId="1" AcceptedAnswerId="8449" CreationDate="2016-06-24T21:31:21.373" Score="8" ViewCount="1041" Body="&lt;h2&gt;Context&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;vifm&lt;/code&gt; as my file manager (that's off topic here, i know, but keep reading) which allows me to edit filenames inside a &lt;code&gt;vim&lt;/code&gt; buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One issue i found myself annoyed at are numbered files where I want to keep leading zeros (e.g. &lt;code&gt;movie0001.webm&lt;/code&gt;).  I can't get vim to format them properly.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;code&gt;vim&lt;/code&gt; buffer containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mov70.webm&#xA;mov71.webm&#xA;mov72.webm&#xA;mov73.webm&#xA;mov74.webm&#xA;mov75.webm&#xA;mov76.webm&#xA;mov77.webm&#xA;mov78.webm&#xA;mov79.webm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And my cursor starts at the &lt;code&gt;m&lt;/code&gt; in the first line.  I then do &lt;code&gt;VG&lt;/code&gt; to mark everything and &lt;code&gt;69&amp;lt;C-x&amp;gt;&lt;/code&gt; to transform it into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mov1.webm&#xA;mov2.webm&#xA;mov3.webm&#xA;mov4.webm&#xA;mov5.webm&#xA;mov6.webm&#xA;mov7.webm&#xA;mov8.webm&#xA;mov9.webm&#xA;mov10.webm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But i would really like to reach this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mov01.webm&#xA;mov02.webm&#xA;mov03.webm&#xA;mov04.webm&#xA;mov05.webm&#xA;mov06.webm&#xA;mov07.webm&#xA;mov08.webm&#xA;mov09.webm&#xA;mov10.webm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;What i have tried&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The problem with numbers with leading zeros is that &lt;code&gt;vim&lt;/code&gt; will treat them as &lt;code&gt;octal&lt;/code&gt;, therefore I changed &lt;code&gt;nrformats&lt;/code&gt; to an empty string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nrformats=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet, that did not help.  I have searched around in &lt;code&gt;:h nrformats&lt;/code&gt; without finding anything useful.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-06-25T14:31:53.197" LastActivityDate="2016-06-25T14:31:53.197" Title="How I force [count]&lt;C-x&gt; to leave leading zeros?" Tags="|visual-block|number-formatting|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8447" PostTypeId="5" CreationDate="2016-06-24T21:42:14.390" Score="0" Body="&lt;p&gt;Vim can edit numbers across different lines in an ordered fashion.  For example, it can add or subtract a &lt;code&gt;count&lt;/code&gt; from several list elements at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim also understands different number formats and edits each format accordingly to its rules:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;binary numbers, starting with &lt;code&gt;0b&lt;/code&gt; or &lt;code&gt;0B&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;hexadecimal numbers, starting with &lt;code&gt;0x&lt;/code&gt; or &lt;code&gt;0X&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;octal numbers, staring with a leading zero&lt;/li&gt;&#xA;&lt;li&gt;and decimal numbers, starting with &lt;code&gt;[1-9]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It can also understand alphabetical characters as numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27nrformats%27&quot; rel=&quot;nofollow&quot;&gt;:h nrformats&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#CTRL-X&quot; rel=&quot;nofollow&quot;&gt;:h CTRL-X&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#CTRL-A&quot; rel=&quot;nofollow&quot;&gt;:h CTRL-A&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-06-24T22:16:41.263" LastActivityDate="2016-06-24T22:16:41.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8448" PostTypeId="4" CreationDate="2016-06-24T21:42:14.390" Score="0" Body="Editing several numbers at once in a way that will keep their ordering and format (e.g. binary, octal, hex) unaltered." OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-06-24T22:16:43.763" LastActivityDate="2016-06-24T22:16:43.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8449" PostTypeId="2" ParentId="8446" CreationDate="2016-06-24T22:54:05.670" Score="6" Body="&lt;p&gt;This can be done in two relatively simple steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Decrement the lines with &lt;code&gt;ctrl-x&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Run a substituion on the changed lines to add the leading zeros: &lt;code&gt;'[,']s/\d\@&amp;lt;!\d\&amp;gt;/0\0/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You could turn that into a command/function if you think you'll need to do this often.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way is to do as muru mentioned and use &lt;code&gt;substitute&lt;/code&gt; + &lt;code&gt;printf&lt;/code&gt;, which can preserve the string length of the replaced digits:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;s/\d\+/\=printf('%0*d', len(submatch(0)), submatch(0) - 69)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This could also be turned into a reusable command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -range Decr &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;s/\d\+/\=printf('%0*d', len(submatch(0)), submatch(0) - &amp;lt;args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which you can run with &lt;code&gt;:'&amp;lt;,'&amp;gt;Decr 69&lt;/code&gt; to decrement the visual lines by 69.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-24T22:54:05.670" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8450" PostTypeId="2" ParentId="8446" CreationDate="2016-06-24T23:24:17.763" Score="8" Body="&lt;p&gt;While I'd definitely go with &lt;code&gt;:s&lt;/code&gt; + &lt;code&gt;printf&lt;/code&gt; for complex replacements, I can get the effect you desire if I start from &lt;code&gt;00&lt;/code&gt;, and have &lt;code&gt;set nrformats-=octal&lt;/code&gt;. That is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Select the numbers in a visual block:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ERSTO.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ERSTO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I have added &lt;code&gt;mov76.webm&lt;/code&gt; - you don't actually have ten files in your example list.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Replace with zeros and select the same region again: &lt;code&gt;r0gv&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GpaIV.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GpaIV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;g&amp;lt;c-a&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lL5CW.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lL5CW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Without &lt;code&gt;set nrformats-=octal&lt;/code&gt;, you'll see &lt;code&gt;010&lt;/code&gt;, &lt;code&gt;011&lt;/code&gt;, etc.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-06-24T23:24:17.763" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8451" PostTypeId="1" AcceptedAnswerId="8453" CreationDate="2016-06-25T03:42:27.447" Score="18" ViewCount="11104" Body="&lt;p&gt;That is, when you hit the marks operator key &lt;kbd&gt;`&lt;/kbd&gt; or &lt;kbd&gt;'&lt;/kbd&gt; you get a list of the available marks - i.e. the list Vim gives from the ex command &lt;code&gt;:marks&lt;/code&gt;. Then, when you press a letter to jump to the mark, you will be taken there - as usual. So if I want to jump to say mark &lt;code&gt;m&lt;/code&gt;, with the normal mode command &lt;kbd&gt;`m&lt;/kbd&gt; you would type:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;`&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;:marks&lt;/code&gt; window or similar would appear and you can see the available marks&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;m&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;cursor jumps to the &lt;code&gt;m&lt;/code&gt; mark&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For those people familiar with it, the &lt;a href=&quot;http://ranger.nongnu.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ranger file manager&lt;/a&gt; already performs the exact way I would like Vim to regarding the usage of marks. Ranger is terminal file explorer that uses Vim key bindings and concepts, a ranger bookmark denotes a file and not a line and column position in a text file, but the concept is the same. Here is a &lt;a href=&quot;https://youtu.be/qooLR8NmYKs?t=10m25s&quot; rel=&quot;nofollow noreferrer&quot;&gt;screencast demonstration of ranger's marks feature&lt;/a&gt; that I want to make happen in vim.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to do this in  Vim, or is there a plugin that does this?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="23502" LastEditDate="2023-09-06T05:03:24.273" LastActivityDate="2024-03-25T03:54:54.250" Title="Is it possible to have Vim displaying the list of available marks when using marks?" Tags="|cursor-motions|mark|previewing|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8452" PostTypeId="2" ParentId="5495" CreationDate="2016-06-25T05:21:12.890" Score="2" Body="&lt;p&gt;This solution works with &quot;repeat last command&quot; (aka &lt;code&gt;.&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; /c :set opfunc=ChangeOccurence&amp;lt;CR&amp;gt;g@&#xA;&#xA;function! ChangeOccurence(type)&#xA;  exec 'normal! `[v`]y'&#xA;  let @/ = @&quot;&#xA;  call feedkeys('cgn', 'n')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When repeating, you don't even need to use &lt;code&gt;n&lt;/code&gt;, you can just use &lt;code&gt;.&lt;/code&gt; to directly fetch and replace the next occurence if you want to go faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Optionally, if you like having highlights of the matching words, you can replace &lt;code&gt;'cgn'&lt;/code&gt; by &lt;code&gt;'n``cgn'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7318" LastEditorUserId="7318" LastEditDate="2016-07-11T01:53:30.633" LastActivityDate="2016-07-11T01:53:30.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8453" PostTypeId="2" ParentId="8451" CreationDate="2016-06-25T09:10:13.053" Score="18" Body="&lt;p&gt;You can define a very simple custom mapping that lists the available marks and pre-populates the command-line with the right command stub, ready for you to type the desired mark name:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :&amp;lt;C-u&amp;gt;marks&amp;lt;CR&amp;gt;:normal! `&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that this simply follows the same pattern as &lt;a href=&quot;http://of-vim-and-vigor.blogspot.fr/p/vim-vigor-comic.html&quot; rel=&quot;noreferrer&quot;&gt;that famous mapping&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :ls&amp;lt;CR&amp;gt;:b&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which can be expanded to other similar uses:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :undolist&amp;lt;CR&amp;gt;:u&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-06-25T14:03:16.480" LastActivityDate="2016-06-25T14:03:16.480" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8454" PostTypeId="1" AcceptedAnswerId="8489" CreationDate="2016-06-25T17:09:01.453" Score="5" ViewCount="722" Body="&lt;p&gt;I'm learning some Vimscript code from here .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the next lines will not compile:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Mapped(fn ,l)&#xA;     let new_list = deepcopy(a:l)&#xA;     call map(new_list, string(a:fn) . '(v:val)')&#xA;     return new_list&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I'm running &lt;code&gt;:source %&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm getting the following error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Invalid argument: Mapped(fn, l)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cant' seem to figure out how.  &lt;/p&gt;&#xA;" OwnerUserId="7125" LastEditorUserId="2313" LastEditDate="2016-06-25T17:51:20.770" LastActivityDate="2016-06-28T06:22:17.367" Title="Vimscript - Invalid argument in function declaration" Tags="|vimscript|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8455" PostTypeId="1" CreationDate="2016-06-26T11:18:51.127" Score="1" ViewCount="403" Body="&lt;p&gt;Say I have one window open displaying folder &lt;em&gt;foo&lt;/em&gt;. Then I open a new window by doing &lt;code&gt;:vs ~/bar&lt;/code&gt;. Then I get a Nerdtree, and when using Ctrlp's fuzzyfinder by doing &lt;code&gt;,,&lt;/code&gt;. I expect the files displayed to be the path of folder &lt;em&gt;bar&lt;/em&gt;, but instead I get files for folder &lt;em&gt;foo&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make Ctrlp display the files for the right folder? Is there any other command than &lt;code&gt;:vs&lt;/code&gt; I should be using?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution that works is opening a file in the &lt;em&gt;bar&lt;/em&gt; folder. But I don't really want to fill up my buffer list with files I'm not using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;dotvim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8175" LastActivityDate="2016-06-26T11:18:51.127" Title="Split window &amp; Fuzzy finder path with Nerdtree" Tags="|plugin-nerdtree|plugin-ctrlp|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8456" PostTypeId="1" CreationDate="2016-06-26T12:28:23.063" Score="1" ViewCount="383" Body="&lt;p&gt;I have my colon key remapped to switch with semicolon using both &lt;code&gt;nnoremap&lt;/code&gt; and &lt;code&gt;vnoremap&lt;/code&gt;. This works fine except when I want to repeat the last command line with &lt;code&gt;@:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the remapping does not work when doing this, so I have to type &lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;@&lt;/kbd&gt; and &lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;:&lt;/kbd&gt; instead of just &lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;@&lt;/kbd&gt; &lt;kbd&gt;:&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is the remapping not working in this context?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="6698" LastEditDate="2016-06-26T14:49:20.293" LastActivityDate="2016-06-26T14:49:20.293" Title="Colon remap not working for registers(?)" Tags="|key-bindings|command-line|register|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8457" PostTypeId="2" ParentId="8456" CreationDate="2016-06-26T13:36:49.957" Score="2" Body="&lt;p&gt;You have to remap &lt;code&gt;@:&lt;/code&gt; as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap @; @:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might as well remap &lt;code&gt;q:&lt;/code&gt; while you're at it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap q; q:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-26T13:36:49.957" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8458" PostTypeId="1" AcceptedAnswerId="8459" CreationDate="2016-06-26T14:02:55.303" Score="0" ViewCount="648" Body="&lt;p&gt;When I use &lt;code&gt;sublime text&lt;/code&gt; I find that it starts searching every time I press a key in the search, i.e. every time I add another letter to the search&lt;code&gt;sublime&lt;/code&gt; performs the search and shows a match with all that I typed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vim once I type &lt;kbd&gt;/&lt;/kbd&gt; and input a search I need to press &lt;kbd&gt;Enter&lt;/kbd&gt; for the search to be performed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to have &lt;code&gt;vim&lt;/code&gt; with a similar behavior to &lt;code&gt;sublime&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="7700" LastEditDate="2016-06-26T18:27:54.507" LastActivityDate="2016-06-27T16:05:54.510" Title="How to make vim search every time I add a new character to the search?" Tags="|search|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8459" PostTypeId="2" ParentId="8458" CreationDate="2016-06-26T14:42:41.070" Score="8" Body="&lt;p&gt;If you want to highlight matches as you search, you need to &lt;code&gt;set incsearch&lt;/code&gt;.  Read &lt;code&gt;:help 'incsearch'&lt;/code&gt; for full details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;incsearch&lt;/code&gt; will scroll to the first match.  Pressing &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; while searching will cancel and restore the scroll position.  Pressing &lt;code&gt;&amp;lt;enter&amp;gt;&lt;/code&gt; will move the cursor to the first match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change the incremental search highlight using the &lt;code&gt;IncSearch&lt;/code&gt; highlight group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a plugin called &lt;a href=&quot;https://github.com/haya14busa/incsearch.vim&quot; rel=&quot;nofollow&quot;&gt;incsearch.vim&lt;/a&gt; that will highlight all matches as you type, in addition to other features.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-06-27T16:05:54.510" LastActivityDate="2016-06-27T16:05:54.510" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8460" PostTypeId="1" AcceptedAnswerId="8462" CreationDate="2016-06-26T16:03:04.160" Score="1" ViewCount="205" Body="&lt;p&gt;Is there anyway to get MiniBufExpl to only list the buffers that belongs to the active window?&lt;/p&gt;&#xA;" OwnerUserId="8175" LastActivityDate="2016-06-26T19:56:18.773" Title="MiniBufExpl: List buffers by window" Tags="|buffers|vim-windows|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8461" PostTypeId="1" CreationDate="2016-06-26T19:19:20.880" Score="7" ViewCount="246" Body="&lt;p&gt;&lt;code&gt;setcolors.vim&lt;/code&gt; of &lt;a href=&quot;http://vim.wikia.com/wiki/Switch_color_schemes#Script&quot; rel=&quot;noreferrer&quot;&gt;vim's Wikia&lt;/a&gt; defines these keybindings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;   F8                next scheme&#xA;&quot;   Shift-F8          previous scheme&#xA;&quot;   Alt-F8            random scheme&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when I use &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;F8&lt;/kbd&gt; (the other two work fine) vim just changes the case of the 2 letters on and exactly after the cursor.&#xA;Running &lt;code&gt;:map&lt;/code&gt; I see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &amp;lt;S-F8&amp;gt;      * :call NextColor(-1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so why am I getting this change-2-character-case behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, I tried to unmap Shift-F8 by running &lt;code&gt;:unmap ^[[32~&lt;/code&gt; obtaining &lt;code&gt;^[[32~&lt;/code&gt; by &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; and then &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;F8&lt;/kbd&gt;, but this did not work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how do get the desired behavior, getting the previous color scheme with &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;F8&lt;/kbd&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt; + PS: I use vim in &lt;code&gt;urxvt&lt;/code&gt;/&lt;code&gt;tmux&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created another user account in my machine (linux), logged in and run vim on a virtual terminal (&lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;Alt&lt;/kbd&gt; + &lt;kbd&gt;F2&lt;/kbd&gt;) and I get the same behavior with &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;F8&lt;/kbd&gt;, and clearly, I have no vim plugins there, and no &lt;code&gt;tmux&lt;/code&gt; either(!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, in my account instead of running &lt;code&gt;urxvt&lt;/code&gt;+&lt;code&gt;tmux&lt;/code&gt;+&lt;code&gt;vim&lt;/code&gt; I run &lt;code&gt;xterm&lt;/code&gt;+&lt;code&gt;vim&lt;/code&gt;, and &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;F8&lt;/kbd&gt; works just fine! Then I run &lt;code&gt;xterm&lt;/code&gt;+&lt;code&gt;tmux&lt;/code&gt;+&lt;code&gt;vim&lt;/code&gt; but now &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;F8&lt;/kbd&gt; changes 4 characters instead of 2! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it should be a terminal/&lt;code&gt;tmux&lt;/code&gt; related issue and not a vim issue. I have not managed to find what causes the problem though and how to fix it though...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update after comments&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;echo $TERM&lt;/code&gt; is &lt;code&gt;xterm-256color&lt;/code&gt; in:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;xterm&lt;/code&gt;, &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;urxvt&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;tmux&lt;/code&gt; inside &lt;code&gt;urxvt&lt;/code&gt; or &lt;code&gt;xterm&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vim&lt;/code&gt;, running &lt;code&gt;:!echo $TERM&lt;/code&gt; inside every one of the above.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; and immediately after &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;F8&lt;/kbd&gt; produces:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^[[19;2~&lt;/code&gt; in &lt;code&gt;xterm&lt;/code&gt; or in&lt;code&gt;vim&lt;/code&gt; inside &lt;code&gt;xterm&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^[[34~&lt;/code&gt; in &lt;code&gt;tmux&lt;/code&gt; inside &lt;code&gt;xterm&lt;/code&gt; or in &lt;code&gt;vim&lt;/code&gt; inside &lt;code&gt;tmux&lt;/code&gt; inside &lt;code&gt;xterm&lt;/code&gt;, and&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^[[32~&lt;/code&gt; in &lt;code&gt;urxvt&lt;/code&gt; or in &lt;code&gt;tmux&lt;/code&gt; inside &lt;code&gt;urxvt&lt;/code&gt; or in &lt;code&gt;vim&lt;/code&gt; inside &lt;code&gt;tmux&lt;/code&gt; or in &lt;code&gt;vim&lt;/code&gt; inside &lt;code&gt;tmux&lt;/code&gt; inside &lt;code&gt;urxvt&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;vim&lt;/code&gt;, &lt;code&gt;:version&lt;/code&gt; shows &lt;code&gt;+terminfo&lt;/code&gt; and there is clearly no &lt;code&gt;+termcap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;:set ttybuiltin termcap&lt;/code&gt; differs slightly between:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://pastebin.com/3XvzxEQy&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;vim&lt;/code&gt; inside &lt;code&gt;xterm&lt;/code&gt;&lt;/a&gt; and&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://pastebin.com/u5gjjgmY&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;vim&lt;/code&gt; inside &lt;code&gt;tmux&lt;/code&gt; inside &lt;code&gt;xterm&lt;/code&gt;&lt;/a&gt;, which appears the same as in &lt;code&gt;vim&lt;/code&gt; inside (&lt;code&gt;tmux&lt;/code&gt;/)&lt;code&gt;urxvt&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2017" LastEditorUserId="205" LastEditDate="2016-07-03T13:10:26.330" LastActivityDate="2016-07-03T13:10:26.330" Title="Shift+F8 changes letter case for 2 letters; how to unmap this?" Tags="|key-bindings|" AnswerCount="0" CommentCount="17" ClosedDate="2018-09-02T17:16:16.403" ContentLicense="CC BY-SA 3.0" />
  <row Id="8462" PostTypeId="2" ParentId="8460" CreationDate="2016-06-26T19:56:18.773" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Buffers are global, they don't belong to any specific window.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you didn't find a positive answer in the plugin's documentation, the answer is very likely to be negative.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-06-26T19:56:18.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8463" PostTypeId="5" CreationDate="2016-06-27T02:05:16.057" Score="0" Body="&lt;p&gt;When you run the &lt;code&gt;:make [arguments]&lt;/code&gt; command, Vim runs the program defined in the &lt;code&gt;makeprg&lt;/code&gt; variable.  The default for &lt;code&gt;makeprg&lt;/code&gt; is simply the &quot;make&quot; program (with the arguments as defined in the &lt;code&gt;[arguments]&lt;/code&gt; part of the command) but it can be changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is common to have different &lt;code&gt;makeprg&lt;/code&gt; configurations for different file formats, see &lt;a href=&quot;/questions/tagged/autocmd&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;autocmd&amp;#39;&quot; rel=&quot;tag&quot;&gt;autocmd&lt;/a&gt; for information on how to perform this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since different programs may require extra arguments, you can use Vim expansions in &lt;code&gt;makeprg&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt; expands to name of the file being edited.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;#&lt;/code&gt; expands to the name of the alternate file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%&amp;lt;&lt;/code&gt; expands to the name of the current file without the extension.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Haskell: &lt;code&gt;set makeprg=ghc\ %&amp;lt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Python: &lt;code&gt;set makeprg=python\ %&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27makeprg%27&quot; rel=&quot;nofollow&quot;&gt;:h makeprg&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make_makeprg&quot; rel=&quot;nofollow&quot;&gt;:h make_makeprg&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make&quot; rel=&quot;nofollow&quot;&gt;:h make&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#:_%&quot; rel=&quot;nofollow&quot;&gt;:h _%&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#:_#&quot; rel=&quot;nofollow&quot;&gt;:h _#&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#:_%%3C&quot; rel=&quot;nofollow&quot;&gt;:h _%&amp;lt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-06-27T02:57:30.780" LastActivityDate="2016-06-27T02:57:30.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8464" PostTypeId="4" CreationDate="2016-06-27T02:05:16.057" Score="0" Body="The program that will be run when the `:make` command is executed." OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-06-27T04:43:04.273" LastActivityDate="2016-06-27T04:43:04.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8465" PostTypeId="5" CreationDate="2016-06-27T04:50:30.653" Score="0" Body="&lt;p&gt;To scroll in vim, you can use the scroll bar on the mouse, or you can use &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; to scroll up and down respectively. More information, and other ways to scroll can be found in &lt;code&gt;:help scrolling&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-06-27T09:39:25.373" LastActivityDate="2016-06-27T09:39:25.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8466" PostTypeId="4" CreationDate="2016-06-27T04:50:30.653" Score="0" Body="For questions about scrolling, and configuring the behavior of vim-scrolls" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-06-27T09:39:33.467" LastActivityDate="2016-06-27T09:39:33.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8467" PostTypeId="1" AcceptedAnswerId="8468" CreationDate="2016-06-27T11:37:30.220" Score="16" ViewCount="4016" Body="&lt;p&gt;I use the registers a lot for copy/pasting, but I always forgot in which register my content is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to display the registers before pasting?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally it would leave the register on screen when selecting the one we want. &lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-27T17:41:06.343" Title="How can I easily list the content of the registers before pasting?" Tags="|cut-copy-paste|register|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8468" PostTypeId="2" ParentId="8467" CreationDate="2016-06-27T11:39:00.163" Score="7" Body="&lt;p&gt;I made up this mapping to display the register list and select the one to be pasted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &quot;p :reg &amp;lt;bar&amp;gt; exec 'normal! &quot;'.input('&amp;gt;').'p'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This display the register list with &lt;code&gt;:reg&lt;/code&gt; and execute the normal command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Xp &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;X&lt;/code&gt; is the result of &lt;code&gt;input()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-27T11:39:00.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8469" PostTypeId="1" AcceptedAnswerId="8470" CreationDate="2016-06-27T11:43:48.563" Score="9" ViewCount="460" Body="&lt;p&gt;Is there a practical difference between using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Except for readability, where it make sense in a mapping to use &lt;code&gt;:edit&lt;/code&gt;, because it's more explicit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a difference between them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; This apply as well to &lt;strong&gt;all&lt;/strong&gt; other commands. &lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-27T12:10:11.470" LastActivityDate="2016-06-27T12:13:29.210" Title="Difference between full and short command" Tags="|command-line|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8470" PostTypeId="2" ParentId="8469" CreationDate="2016-06-27T12:08:13.520" Score="10" Body="&lt;p&gt;There is no actual difference but in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_20.html#usr_20.txt&quot;&gt;&lt;code&gt;:h usr_20.txt&lt;/code&gt;&lt;/a&gt;, you can read:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It is recommended that in Vim scripts you write the full command name.  That&#xA;  makes it easier to read back when you make later changes.  Except for some&#xA;  often used commands like &lt;code&gt;:w&lt;/code&gt; (&lt;code&gt;:write&lt;/code&gt;) and &lt;code&gt;:r&lt;/code&gt; (&lt;code&gt;:read&lt;/code&gt;).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A particularly confusing one is &lt;code&gt;:end&lt;/code&gt;, which could stand for &lt;code&gt;:endif&lt;/code&gt;,&#xA;  &lt;code&gt;:endwhile&lt;/code&gt; or &lt;code&gt;:endfunction&lt;/code&gt;.  Therefore, always use the full name.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I would recommend to follow the doc and use the long name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And another paragraph interesting about the short names:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How short can a command get?  There are 26 letters, and many more commands.&#xA;  For example, &lt;code&gt;:set&lt;/code&gt; also starts with &lt;code&gt;:s&lt;/code&gt;, but &lt;code&gt;:s&lt;/code&gt; doesn't start a &lt;code&gt;:set&lt;/code&gt;&#xA;  command.  Instead &lt;code&gt;:set&lt;/code&gt; can be abbreviated to &lt;code&gt;:se&lt;/code&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When the shorter form of a command could be used for two commands, it&#xA;  stands for only one of them.  There is no logic behind which one, you have to&#xA;  learn them.  In the help files the shortest form that works is mentioned.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-06-27T12:13:29.210" LastActivityDate="2016-06-27T12:13:29.210" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8471" PostTypeId="2" ParentId="8467" CreationDate="2016-06-27T12:49:53.590" Score="14" Body="&lt;p&gt;This &lt;a href=&quot;https://github.com/junegunn/vim-peekaboo&quot; rel=&quot;noreferrer&quot;&gt;peekaboo&lt;/a&gt; plugin is pretty good for for previewing registers.  When you press &lt;code&gt;&quot;&lt;/code&gt; or &lt;code&gt;@&lt;/code&gt; in normal mode, or &lt;code&gt;ctrl-r&lt;/code&gt; in insert mode, a split will open to show you the register contents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Preview from the plugin repo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/junegunn/vim-peekaboo&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3oglB.gif&quot; alt=&quot;peekaboo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-27T12:49:53.590" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8472" PostTypeId="1" CreationDate="2016-06-27T13:12:05.400" Score="6" ViewCount="4727" Body="&lt;p&gt;I have following code. I want to add spaces around =. With the minimal keystrokes (May be with the help of macro). Do not want search and replace approach.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div className=&quot;row&quot;&amp;gt;&#xA;    &amp;lt;div className=&quot;col-md-12 text-center&quot;&amp;gt;&#xA;        &amp;lt;h3&amp;gt;vOrderv&amp;lt;/h3&amp;gt;&#xA;    &amp;lt;/div&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After changes it should look&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div className = &quot;row&quot;&amp;gt;&#xA;    &amp;lt;div className = &quot;col-md-12 text-center&quot;&amp;gt;&#xA;        &amp;lt;h3&amp;gt;vOrderv&amp;lt;/h3&amp;gt;&#xA;    &amp;lt;/div&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5890" LastEditorUserId="626" LastEditDate="2016-06-27T13:40:52.220" LastActivityDate="2016-06-27T23:00:11.330" Title="How to add space around a symbol using vim?" Tags="|whitespace|alignment|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8473" PostTypeId="1" AcceptedAnswerId="8475" CreationDate="2016-06-27T13:20:07.113" Score="6" ViewCount="329" Body="&lt;p&gt;I recently noticed that on some help files it is not possible to move the cursor to the very first column of some lines. To explain it clearly, here is a screenshot where I have done the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vim -u NONE&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h help&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;3j&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E1db3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E1db3.png&quot; alt=&quot;Screenshot of helpfile&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see my cursor is not on the first column of the line. And I have no means to put my cursor on it (even using &lt;kbd&gt;h&lt;/kbd&gt; or any other command).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;strong&gt;Note&lt;/strong&gt; that I also used &lt;code&gt;:set ft=txt&lt;/code&gt; to check if the help syntax wasn't hiding something)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It happens in a lot of different help files but I don't think it happens on all the indented lines, thus I'm wondering what is causing this behavior.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; I should have specified this before but I asked the question because this behavior only happens on the help buffers but not on any other buffer, e.g., &lt;code&gt;vim -u NONE ~/.vimrc&lt;/code&gt;, I'm able to go to the beginning of the lines:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WvnuO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WvnuO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="205" LastEditDate="2016-06-27T16:09:50.003" LastActivityDate="2022-05-17T13:31:54.463" Title="What prevents the cursor from moving to the first column on some help files?" Tags="|cursor-movement|help-system|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8474" PostTypeId="2" ParentId="8472" CreationDate="2016-06-27T13:39:15.673" Score="3" Body="&lt;p&gt;Search and replace can be used, but I must admit, the syntax is not simple to remember:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\s*=\@&amp;lt;!==\@!\s*/ = /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first &lt;code&gt;\@&amp;lt;!&lt;/code&gt; matches with zero width if the preceding atom doesn't match &lt;code&gt;=&lt;/code&gt; (1st one) before &lt;code&gt;=&lt;/code&gt; (2nd one)&lt;/li&gt;&#xA;&lt;li&gt;The second &lt;code&gt;\@!&lt;/code&gt; matches with zero width if the preceding atom (3rd &lt;code&gt;=&lt;/code&gt;) doesn't match after the current position (2nd &lt;code&gt;=&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Of course, you can add other characters to the &lt;em&gt;black-list&lt;/em&gt;. See for instance &lt;a href=&quot;https://stackoverflow.com/a/23072106/15934&quot;&gt;https://stackoverflow.com/a/23072106/15934&lt;/a&gt; on the same topic.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-06-27T13:39:15.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8475" PostTypeId="2" ParentId="8473" CreationDate="2016-06-27T13:40:45.440" Score="6" Body="&lt;p&gt;By default, the cursor is positioned on the last cell used to display a tab character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change that behavior by enabling the &lt;code&gt;list&lt;/code&gt; option and defining custom values for the &lt;code&gt;listchars&lt;/code&gt; option (the default &lt;code&gt;^I&lt;/code&gt; for tabs is not very practical):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list&#xA;set listchars=tab:»\ ,extends:›,precedes:‹,nbsp:·,trail:·&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(that &lt;code&gt;listchars&lt;/code&gt; is mine, use what you want)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help list&lt;/code&gt; and &lt;code&gt;:help listchars&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;help&lt;/code&gt; buffers, the &lt;code&gt;list&lt;/code&gt; option is disabled by default so you get the default behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you absolutely need the ability to move your cursor on the first cell of tabs, you can add the line below to &lt;code&gt;after/ftplugin/help.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-06-27T15:00:00.387" LastActivityDate="2016-06-27T15:00:00.387" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8476" PostTypeId="2" ParentId="8473" CreationDate="2016-06-27T13:41:04.803" Score="1" Body="&lt;p&gt;It's because your cursor is resting on the first character which is a tab.  Use &lt;code&gt;setlocal tabstop=1&lt;/code&gt; so you can see what cursor movement looks like.  Vim's help files requires &lt;code&gt;tabstop&lt;/code&gt; to be set to 8.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-27T13:41:04.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8477" PostTypeId="2" ParentId="8472" CreationDate="2016-06-27T13:43:09.800" Score="6" Body="&lt;p&gt;I'm not sure why you don't want to use search/replace, but here's a reusable command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! HTMLArgEq %s/\s\@&amp;lt;!=\+\s\@!/ \0 /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses search/replace, but you only need to create it once.  Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/    - Substitute entire buffer&#xA;\s\@&amp;lt;! - Not preceded by whitespace&#xA;=\+    - One or more equal characters&#xA;\s\@!  - Not followed by whitespace&#xA;/ \0   - Add spaces around the match&#xA;/g     - Replace globally&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-27T13:43:09.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8478" PostTypeId="2" ParentId="8472" CreationDate="2016-06-27T16:17:37.717" Score="5" Body="&lt;p&gt;Here's what I would do. Visually select all of your HTML you want to do this to, and hit the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm f=i&amp;lt;space&amp;gt;&amp;lt;C-v&amp;gt;&amp;lt;esc&amp;gt;la&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; are keystrokes, not literal text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:norm&lt;/code&gt; Means apply the following set of keystrokes to every selected line. &lt;code&gt;f=&lt;/code&gt; means move to the first equals sign. This conveniently has the added benefit of stopping playback if an &lt;code&gt;=&lt;/code&gt; character is not found. &lt;code&gt;i&amp;lt;space&amp;gt;&amp;lt;C-v&amp;gt;&amp;lt;esc&amp;gt;&lt;/code&gt; means enter insert mode, insert a space, and then esc. &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; allows us to enter a literal esc character, which is necessary since we are doing this from the command line. &lt;code&gt;la&amp;lt;space&amp;gt;&lt;/code&gt; moves one to the right (so we are on top of the equals sign), and appends a space after the equals sign.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only downside to this approach is that you must manually select every section of HTML to do this to, which is necessary if you do not want to use a regex search and replace.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-06-27T16:17:37.717" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8479" PostTypeId="2" ParentId="8467" CreationDate="2016-06-27T17:27:55.257" Score="7" Body="&lt;p&gt;I would recommend using &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:reg&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will show the contents of all registers (you can scroll through using j and k). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just want to show the contents of one register, you can go to command mode and type &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;: Ctrl + r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then the register, for example the x register&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will paste the contents of the register into the command line. You can then escape out of the command line after viewing your register. &lt;/p&gt;&#xA;" OwnerUserId="2757" LastEditorUserId="2757" LastEditDate="2016-06-27T17:41:06.343" LastActivityDate="2016-06-27T17:41:06.343" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8480" PostTypeId="1" AcceptedAnswerId="8483" CreationDate="2016-06-27T19:47:54.550" Score="3" ViewCount="292" Body="&lt;p&gt;I get a human readable list of api functions using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new|put =map(api_info().functions, 'v:val.name')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in neovim as suggested on &lt;a href=&quot;https://neovim.io/doc/user/msgpack_rpc.html&quot; rel=&quot;nofollow&quot;&gt;https://neovim.io/doc/user/msgpack_rpc.html&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem is, this doesn't show the method signatures like the perl example on &lt;a href=&quot;http://techblog.babyl.ca/entry/neovim-way-to-go&quot; rel=&quot;nofollow&quot;&gt;http://techblog.babyl.ca/entry/neovim-way-to-go&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env perl &#xA;use Neovim::RPC;&#xA;my $rpc = Neovim::RPC-&amp;gt;new-&amp;gt;api-&amp;gt;print_command;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;yielding&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;vim_replace_termcodes ( String str, Boolean from_part, Boolean do_lt, Boolean special ) -&amp;gt; String&#xA;...&#xA;vim_set_current_line ( String line ) -&amp;gt; void&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But: I don't use perl, I want to use python and want to print a formatted dump of the neovim api as suggested in &lt;a href=&quot;https://neovim.io/doc/user/msgpack_rpc.html&quot; rel=&quot;nofollow&quot;&gt;https://neovim.io/doc/user/msgpack_rpc.html&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim --api-info | python -c 'import msgpack, sys, yaml; print( yaml.dump(msgpack.unpackb(sys.stdin.read())) )'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;  File &quot;/home/info/w/sc/lib/python3.4/codecs.py&quot;, line 319, in decode&#xA;     (result, consumed) = self._buffer_decode(data, self.errors, final)&#xA; UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 0: invalid start byte&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Trying to isolate the error, I did&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim --api-info | python -c 'import sys; print( sys.stdin.read() )'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;resulting in the same error as above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the reason is me using python 3.4 not python 2.7. How do you correctly code this in python 3.4?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover, there seems to be a discrepancy between the api function and the python implementation, e.g. if you want to access the api function &lt;code&gt;vim_set_current_line&lt;/code&gt;, you need to write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from neovim import attach&#xA;v = attach('socket', path='/tmp/nvim')&#xA;v.api.set_current_line(&quot;zzzz&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and not &lt;code&gt;v.api.vim_set_current_line(&quot;zzzz&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to find out about &quot;pythonic&quot; api-functions (apart from consulting &lt;a href=&quot;https://github.com/neovim/python-client/tree/master/neovim/api&quot; rel=&quot;nofollow&quot;&gt;https://github.com/neovim/python-client/tree/master/neovim/api&lt;/a&gt;) ?&lt;/p&gt;&#xA;" OwnerUserId="8156" LastEditorUserId="8156" LastEditDate="2016-06-27T20:08:26.087" LastActivityDate="2019-07-07T08:14:27.933" Title="Print neovim api-info using python 3" Tags="|neovim|neovim-python-client|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8481" PostTypeId="5" CreationDate="2016-06-27T19:55:27.683" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/neovim/python-client&quot; rel=&quot;nofollow&quot;&gt;neovim python-client&lt;/a&gt; is an official library from the neovim group that allows communicating with a neovim session over msgpack through python. This library is very similar to the python-vimscript library, but with improvements allowing for asynchronous IO and embedding neovim into a python script, rather than just connecting over a socket. This library also allows for remote plugins.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-06-27T20:57:00.327" LastActivityDate="2016-06-27T20:57:00.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8482" PostTypeId="4" CreationDate="2016-06-27T19:55:27.683" Score="0" Body="For questions about scripting neovim with the python-client" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-06-27T20:56:35.073" LastActivityDate="2016-06-27T20:56:35.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8483" PostTypeId="2" ParentId="8480" CreationDate="2016-06-27T20:14:10.410" Score="3" Body="&lt;p&gt;In Python 3, there's an emphasis on unicode strings.  &lt;code&gt;sys.stdin&lt;/code&gt; has a &lt;code&gt;buffer&lt;/code&gt; attribute that lets you get to the underlying byte buffer, but Python 2's &lt;code&gt;sys.stdin&lt;/code&gt; does not.  If you want something that'll work for both versions, you can use the &lt;code&gt;-u&lt;/code&gt; command line argument, as well as &lt;code&gt;getattr()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim --api-info | python -u -c 'import sys,msgpack; print(msgpack.unpackb(getattr(sys.stdin, &quot;buffer&quot;, sys.stdin).read()))'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The relevant bit is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getattr(sys.stdin, &quot;buffer&quot;, sys.stdin).read()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're more comfortable using Neovim to work with the text, there is also the &lt;code&gt;api_info()&lt;/code&gt; function in Neovim.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-27T20:14:10.410" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8484" PostTypeId="1" CreationDate="2016-06-27T21:11:43.300" Score="1" ViewCount="866" Body="&lt;p&gt;I've just upgraded to a new laptop with Ubuntu 16.04 and installed Vim 7.4 1-1952.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I installed most of my plugins when I noticed that 80% of the time when I press &lt;kbd&gt;F11&lt;/kbd&gt; to go fullscreen, Vim doesn't &quot;update&quot;/redraw unless I press a button or click on the screen. Here's a photo of what happens when I press &lt;kbd&gt;F11&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yheJs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yheJs.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried disabling my plugins to see if one of them might be the issue. I realized that this only happens when I have some sort of syntactic-checker enabled such as YouCompleteMe or syntastic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, the issue resolves itself immediately once I press &lt;em&gt;any&lt;/em&gt; button but I can't figure out what could be causing it. I don't have the same problem anywhere else aside from Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: This only occurs with Full Screen, Pressing  CTRL + ALT + Numpad in order to maximize the &lt;strong&gt;window&lt;/strong&gt; works just fine.&lt;br&gt;&#xA;EDIT2: This also seems to occur with neovim&lt;/p&gt;&#xA;" OwnerUserId="4804" LastEditorUserId="2313" LastEditDate="2016-06-29T17:35:49.803" LastActivityDate="2016-08-28T18:04:51.950" Title="Vim doesn't refresh screen when going fullscreen" Tags="|terminal|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8485" PostTypeId="2" ParentId="8472" CreationDate="2016-06-27T23:00:11.330" Score="1" Body="&lt;p&gt;If you want to make changes interactively, you can still use &lt;code&gt;:substitute&lt;/code&gt; but with the &lt;code&gt;c&lt;/code&gt; flag ('c' for 'confirm'):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/=/ = /gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The cursor will land on the first match and you'll be prompted whether&#xA;you want to carry out the substitution. Hit &lt;code&gt;y&lt;/code&gt; for yes, &lt;code&gt;n&lt;/code&gt; for no.&#xA;Then the cursor will jump to the next match, and so on. &lt;code&gt;q&lt;/code&gt; to quit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :substitute&lt;/code&gt;, and, specifically, &lt;code&gt;:help :s_c&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-06-27T23:00:11.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8486" PostTypeId="1" AcceptedAnswerId="8487" CreationDate="2016-06-28T03:29:53.717" Score="4" ViewCount="159" Body="&lt;p&gt;How to map keystrokes to a command in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I would like to create a custom command &lt;code&gt;Cmt&lt;/code&gt;, and I could use it to comment out lines 10-20 like this: &lt;code&gt;:10,20Cmt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried something like &lt;code&gt;:command -range Cmt &amp;lt;line1&amp;gt;gg O ...&lt;/code&gt; but it didn't work.&lt;/p&gt;&#xA;" OwnerUserId="8197" LastActivityDate="2016-06-28T04:09:24.090" Title="How to map keystrokes to a command?" Tags="|key-bindings|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8487" PostTypeId="2" ParentId="8486" CreationDate="2016-06-28T04:09:24.090" Score="4" Body="&lt;p&gt;You want to use the &lt;code&gt;:normal!&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -range Cmt normal! &amp;lt;line1&amp;gt;ggO&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Commands take everything to the right of the name (&lt;code&gt;Cmt&lt;/code&gt;) and runs it as an ex command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=1 LetX let g:x = '&amp;lt;args&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Substitutions are made on the command before it's executed.  So, running &lt;code&gt;10Cmt&lt;/code&gt; will execute &lt;code&gt;:normal! 10ggO&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-28T04:09:24.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8488" PostTypeId="1" AcceptedAnswerId="8494" CreationDate="2016-06-28T05:34:50.443" Score="2" ViewCount="2577" Body="&lt;p&gt;So I've installed &lt;a href=&quot;http://vimawesome.com/plugin/vim-polyglot&quot; rel=&quot;nofollow&quot;&gt;http://vimawesome.com/plugin/vim-polyglot&lt;/a&gt; as per those instructions (it shows up with &lt;code&gt;:ListPlugins&lt;/code&gt; ), but it's not highlighting any of my code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realise that's not a lot to go on, but is there any configuration work? Or should it all be automatic?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do see yellow and blue tag indicators though - is it possible that terminal theming breaks the syntax highlighting?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any experience or would know why? Thanks. :)&lt;/p&gt;&#xA;" OwnerUserId="8198" LastEditorUserId="1821" LastEditDate="2016-06-28T06:33:53.750" LastActivityDate="2019-05-06T20:46:58.827" Title="Syntax highlighting not working vim-polyglot" Tags="|macvim|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="8489" PostTypeId="2" ParentId="8454" CreationDate="2016-06-28T06:22:17.367" Score="2" Body="&lt;p&gt;Because of a bug in &lt;code&gt;vim_dev&lt;/code&gt; parser, the space before coma is not accepted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus you must use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Mapped(fn,l)&#xA;     let new_list = deepcopy(a:l)&#xA;     call map(new_list, string(a:fn) . '(v:val)')&#xA;     return new_list&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6946" LastActivityDate="2016-06-28T06:22:17.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8490" PostTypeId="1" CreationDate="2016-06-28T10:39:13.143" Score="1" ViewCount="98" Body="&lt;p&gt;Let say I have a minified javascript function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function(){for(a=0;++a&amp;gt;0;){console.log(a);}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to apply an &lt;em&gt;agressive&lt;/em&gt; split on it, that is insert a new line for some characters. So I would have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function(&#xA;)&#xA;{&#xA;for(&#xA;a=0;&#xA;++a&amp;gt;0;&#xA;)&#xA;{&#xA;console.log(&#xA;a&#xA;)&#xA;;&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course I can use multiple substitute like :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/{/{\r/g&#xA;:s/}/\r}/g&#xA;:s/(/(\r/g&#xA;:s/)/\r)/g&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to use one (or two) substitute(s) to do the whole job?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-28T10:45:38.377" LastActivityDate="2016-06-28T11:08:02.640" Title="Split a line by non-letter characters" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8491" PostTypeId="2" ParentId="8490" CreationDate="2016-06-28T10:55:18.183" Score="4" Body="&lt;p&gt;yes, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/[}{();]/&amp;amp;\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just noticed that, the output of above leave a:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it does matter, you can do a:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/.\zs)/\r)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to fix it.&lt;/p&gt;&#xA;" OwnerUserId="1569" LastEditorUserId="1569" LastEditDate="2016-06-28T11:08:02.640" LastActivityDate="2016-06-28T11:08:02.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8492" PostTypeId="1" AcceptedAnswerId="8493" CreationDate="2016-06-28T11:33:48.020" Score="1" ViewCount="1475" Body="&lt;p&gt;The only workaround I can come up with is after opening a vim session:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set updatecount=0 | e +setlocal\ noswapfile FILENAME | set updatecount&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are there any shorter vim commands or options that could achieve the same effect?&lt;/p&gt;&#xA;" OwnerUserId="2295" LastEditorUserId="2295" LastEditDate="2016-06-28T11:38:51.077" LastActivityDate="2016-06-28T12:36:55.997" Title="edit file without swap file within a vim session" Tags="|swap-file|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8493" PostTypeId="2" ParentId="8492" CreationDate="2016-06-28T12:36:55.997" Score="6" Body="&lt;p&gt;You could try &lt;a href=&quot;http://vimhelp.appspot.com/recover.txt.html#:nos&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:noswapfile e FILENAME&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  :nos[wapfile]   {command}         *:nos* *:noswapfile*&#xA;        Execute {command}. If it contains a command that loads a new&#xA;        buffer, it will be loaded without creating a swapfile and the&#xA;        'swapfile' option will be reset.  If a buffer already had a&#xA;        swapfile it is not removed and 'swapfile' is not reset.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But keep in mind that usually there are better solutions, depending on what you are trying to achieve, because without a swap file you are more likely to lose your work.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-06-28T12:36:55.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8494" PostTypeId="2" ParentId="8488" CreationDate="2016-06-28T13:22:50.490" Score="4" Body="&lt;p&gt;To be able to use the syntax highlighting in vim you must put the following line on your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on your preferences/plugin manager (if any), it may want to put it at the start of your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h usr_06.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h syntax&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS:&lt;/strong&gt; to sort my vim options, I use the &lt;code&gt;:options&lt;/code&gt; command and sort using the existing groups.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-28T13:22:50.490" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8495" PostTypeId="2" ParentId="8484" CreationDate="2016-06-28T13:36:48.087" Score="1" Body="&lt;p&gt;I've fixed it in a very peculiar way, and have no idea how you'd figure this out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Ubuntu, go to &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;System Settngs&lt;/strong&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Appearance&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Behaviour&lt;/strong&gt;  and then &lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Show the menus for a window&lt;/strong&gt; &lt;/li&gt;&#xA;&lt;li&gt;check &lt;strong&gt;In the window's title bar&lt;/strong&gt; .  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The problem seems to be fixed now, but I'm guessing it's still a bug in vim or some plugin.&lt;/p&gt;&#xA;" OwnerUserId="4804" LastEditorUserId="1821" LastEditDate="2016-06-28T14:14:54.250" LastActivityDate="2016-06-28T14:14:54.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8496" PostTypeId="1" AcceptedAnswerId="8498" CreationDate="2016-06-28T14:55:01.800" Score="4" ViewCount="284" Body="&lt;p&gt;I have an autocommand function in my &lt;code&gt;.vimrc&lt;/code&gt; that resets the cursor to where it was before I last closed the file. This function looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ResCur()&#xA;  if line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;)&#xA;    normal! g`&quot;      &#xA;    return 1&#xA;  endif&#xA;endfunction                                                             &#xA;autocmd BufWinEnter * call ResCur()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I started using &lt;a href=&quot;https://github.com/aperezdc/vim-template&quot; rel=&quot;nofollow&quot;&gt;vim-template&lt;/a&gt; which recognizes a &lt;code&gt;%HERE%&lt;/code&gt; variable in the templates that sets the cursor location. My custom function overrides this capability. Is there a way to change my autocommand to only reset the cursor when a template is not loaded so the &lt;code&gt;%HERE%&lt;/code&gt; variable still works when a template is loaded? If part of the solution involves using a different template plugin, I would be happy to hear that as well.&lt;/p&gt;&#xA;" OwnerUserId="5043" LastActivityDate="2016-06-28T15:38:47.200" Title="How do I keep custom cursor reset function from interfering with vim-template?" Tags="|cursor-movement|autocmd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8497" PostTypeId="1" AcceptedAnswerId="8501" CreationDate="2016-06-28T15:23:54.123" Score="4" ViewCount="262" Body="&lt;p&gt;Say I type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and hit return.  In a .cpp file, or a .js file, the cursor would continue adding &lt;code&gt;*&lt;/code&gt;s for me.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA; *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in a .php file, the cursor just moves to the next line.  It's very annoying because I'm trying to document our API, which completely lacks it at the moment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relevant output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;formatoptions=tcroq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't have anything in my vimrc that is specific to PHP.  I do have syntastic installed, but for some reason in php files, comment lines aren't even being grayed out as if they were comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?  Is there a way I can find out what file is setting different settings?&lt;/p&gt;&#xA;" OwnerUserId="8206" LastEditorUserId="2313" LastEditDate="2016-06-28T19:23:22.757" LastActivityDate="2016-06-28T19:23:22.757" Title="New lines are not continuing block comments, only in php" Tags="|vimrc|syntax-highlighting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8498" PostTypeId="2" ParentId="8496" CreationDate="2016-06-28T15:32:36.510" Score="7" Body="&lt;p&gt;Since this should only work for existing files, you'll want to use &lt;code&gt;BufRead&lt;/code&gt; instead of &lt;code&gt;BufWinEnter&lt;/code&gt;.  &lt;code&gt;vim-template&lt;/code&gt; won't trigger &lt;code&gt;BufRead&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really need &lt;code&gt;BufWinEnter&lt;/code&gt; to be used to process modelines before calling your function, you can use &lt;code&gt;BufRead&lt;/code&gt; to set a buffer variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead * let b:not_new = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And check if the variable exists before moving the cursor.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-28T15:32:36.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8499" PostTypeId="2" ParentId="8496" CreationDate="2016-06-28T15:38:47.200" Score="4" Body="&lt;p&gt;Looking at the &lt;a href=&quot;https://github.com/aperezdc/vim-template/blob/master/plugin/templates.vim#L394&quot; rel=&quot;nofollow&quot;&gt;vim-template source&lt;/a&gt;, it checks for the existence of &lt;code&gt;%HERE%&lt;/code&gt; when jumping, you could do the same:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ResCur()&#xA;  if search(&quot;%HERE%&quot;, &quot;n&quot;)&#xA;    return&#xA;  endif&#xA;&#xA;  if line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;)&#xA;    normal! g`&quot;      &#xA;    return 1&#xA;  endif&#xA;endfunction                                                             &#xA;autocmd BufWinEnter * call ResCur()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;n&lt;/code&gt; flag means &lt;code&gt;do not move the cursor on search&lt;/code&gt; and the function return the line number, you can check its existence before moving. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should be fine (I've not tested though, as I don't have the plugin installed).&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-06-28T15:38:47.200" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8500" PostTypeId="2" ParentId="8386" CreationDate="2016-06-28T15:40:04.220" Score="1" Body="&lt;p&gt;I already accepted an answer but I found a simpler way to perform this.  Given a couple of files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo yay &amp;gt; a&#xA;$ echo yay &amp;gt; b&#xA;$ echo yay &amp;gt; c&#xA;$ file *&#xA;a: ASCII text&#xA;b: ASCII text&#xA;c: ASCII text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can use the several &lt;code&gt;:argdo&lt;/code&gt; commands separated by &lt;code&gt;|&lt;/code&gt;, this way I do not need to rely on &lt;code&gt;:set hidden&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -u NONE -c 'argdo set ff=dos | w' -c 'q' *&#xA;$ file *&#xA;a: ASCII text, with CRLF line terminators&#xA;b: ASCII text, with CRLF line terminators&#xA;c: ASCII text, with CRLF line terminators&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works similar to &lt;code&gt;:set hidden&lt;/code&gt; + &lt;code&gt;:xall&lt;/code&gt; in terms of how the command appears on the screen but it writes the files one by one.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-06-28T15:40:04.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8501" PostTypeId="2" ParentId="8497" CreationDate="2016-06-28T18:21:42.363" Score="7" Body="&lt;p&gt;According to a very similar thread on StackOverflow:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/2061321/incorrect-comments-set-for-php-in-vim&quot;&gt;https://stackoverflow.com/questions/2061321/incorrect-comments-set-for-php-in-vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Checked that &lt;code&gt;filetype plugin on&lt;/code&gt; came before &lt;code&gt;filetype indent on&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;.  It did, so that wasn't the cause of the problem.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Added the following line to make vim register comment lines in php files:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;au FileType php setlocal comments=s1:/*,mb:*,ex:*/,://,:#&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;au FileType php setlocal formatoptions+=cro&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I made mine match the rest of my files' format options, so I set it to &lt;code&gt;tcroq&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim 7.4 on ArchLinux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;Oddly, this didn't set the colors of comments to be grayed out like my colorscheme specifies, but it does have the correct indention behavior.&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:  Last statement was because of missing &lt;code&gt;&amp;lt;?php ?&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;&#xA;" OwnerUserId="8206" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-06-28T19:02:33.187" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8503" PostTypeId="1" CreationDate="2016-06-29T09:42:36.230" Score="3" ViewCount="208" Body="&lt;p&gt;I want to run shell command with system function and the command output has some Chinese chars.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo system('svn status')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I got incorrect encoding output like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;svn:  ?\232?\173?\166?\229?\145?\138: W155007: ?\226?\128?\156/Users/mfw?\226?\128?\157?\228?\184?\141?\230?\152?\175?\229?\183?\165?\228?\189?\156?\229?\137?\175?\230?\156?\172&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the correct output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;svn:  警告: W155007: “/Users/mfw”不是工作副本&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So How can I get Chinese chars output correctly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="8220" LastActivityDate="2016-06-29T09:42:36.230" Title="system function output with Chinese chars" Tags="|functions|encoding|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8504" PostTypeId="1" AcceptedAnswerId="8505" CreationDate="2016-06-29T14:32:30.503" Score="2" ViewCount="4850" Body="&lt;p&gt;I have a file containing special comments in the following forms:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// SPECIAL&#xA;// Some stuff&#xA;// Some other stuff&#xA;// Last line of other stuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I need to be able to delete the line containing &lt;code&gt;SPECIAL&lt;/code&gt; and the 3 nexts. Assuming the &lt;code&gt;SPECIAL&lt;/code&gt; does not appear in the 3 lines after one &lt;code&gt;SPECIAL&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can search for &lt;code&gt;SPECIAL&lt;/code&gt; and then &lt;code&gt;4dd&lt;/code&gt; but there are a lot in the file so I would prefer to do it automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to do this?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-29T14:56:44.667" LastActivityDate="2016-06-29T15:28:19.710" Title="How to delete searched line and next" Tags="|search|cut-copy-paste|global-command|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8505" PostTypeId="2" ParentId="8504" CreationDate="2016-06-29T14:33:00.997" Score="9" Body="&lt;p&gt;You could use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/SPECIAL/.,.+3d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be detailled like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/      Apply a command on all the lines matching a pattern&#xA;SPECIAL/ The pattern to match&#xA;.,.+3d   The command to execute&#xA;.,.+3    Is a range. &quot;.&quot; represent the current line (i.e. the matched one&#xA;         It is updated each time a line is matched&#xA;         The full range says &quot;apply the command on the current line and the 3 following&quot;&#xA;     d   Is the delete function &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:d&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :d&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; As usual, @romainl had a cool trick to improve the answer, thanks to him:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/SPECIAL/,+3d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vimgolfers will like it!&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-06-29T15:11:31.677" LastActivityDate="2016-06-29T15:11:31.677" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="8506" PostTypeId="2" ParentId="8504" CreationDate="2016-06-29T14:50:12.107" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;vim macro&lt;/code&gt;s!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: As @statox suggested, we can search the pattern first and then record macro. It will avoid searching the same pattern every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Search for the pattern &lt;code&gt;/pattern&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Press &lt;code&gt;qaq&lt;/code&gt; to clean the register &lt;code&gt;a&lt;/code&gt;. &#xA;Press &lt;code&gt;qa&lt;/code&gt; to start recording. Press &lt;code&gt;n&lt;/code&gt; to search  the next occurrence of the pattern. Then press &lt;code&gt;4dd&lt;/code&gt; to delete four lines including that line. Press &lt;code&gt;@a&lt;/code&gt; to repeat the process. Press &lt;code&gt;q&lt;/code&gt; to stop recording.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now onwards, you can press &lt;code&gt;@a&lt;/code&gt; once. It will search for the pattern and delete four lines. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;           qaq - start recording in `a` register and stop recording. (Indirectly, means that you are clearing register a.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="7161" LastEditDate="2016-06-29T15:02:04.017" LastActivityDate="2016-06-29T15:02:04.017" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8507" PostTypeId="1" CreationDate="2016-06-29T15:16:27.220" Score="3" ViewCount="245" Body="&lt;p&gt;Let's say I have the following buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo.txt&#xA;bar buzz.txt&#xA;fizz/foo.txt&#xA;fizz/fuzz/fozz.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Representing an arborescence that I need to create.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I easily create it from Vim?  I.e. How can I visually select the list of&#xA;files and execute a function which would create the directories and files in the&#xA;current folder?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-06-29T15:18:27.780" LastActivityDate="2016-06-30T06:37:07.513" Title="Creating a list of files contained in a buffer" Tags="|external-command|filesystem|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8508" PostTypeId="2" ParentId="8504" CreationDate="2016-06-29T15:18:10.747" Score="2" Body="&lt;p&gt;Even though you say you want a single command that does it automatically, I would suggest not doing that unless you really have a ton of them. Often attempting to come up with one command that does it all in one go is problematic compared to a simpler approach. You might have to try several commands before you come up with one that really works, whereas with a simpler approach you will probably get it right on your first or second attempt and you can think of what to do much quicker and without asking for help. Also, I often find that while I believe I know exactly how this pattern I want to delete appears every time in the file, there are often slight variances of it I had forgotten about or was not aware of. These variances might get picked up by the single command approach and deleted. You may not have wanted to delete them or it might delete more or less than what you wanted for a particular variance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is safer to let yourself see each match and decide to or not to delete it. Here is the approach I would take.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Type the following:&#xA;&lt;code&gt;/\/\/ SPECIAL&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point it should be clear that you did or did not enter the search correctly before you ever delete anything, which is one of the advantages of this approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you verify you searched for the right thing, instead of pressing &lt;code&gt;4dd&lt;/code&gt;, enter linewise visual mode with a captial &lt;code&gt;V&lt;/code&gt;. Instead of finding how many lines to go down, which will consume some of your mental visual processing ability for the day, do it the lazy way. Just press &lt;code&gt;j&lt;/code&gt; a few times until it looks right. That way is much easier to visually process. This also has the advantage of preventing you from mistakenly thinking you needed to delete 4 lines when you actually needed to delete 5 or some other amount, as you can clearly see highlighted what you are about to delete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have highlighted the lines you want to delete, just press &lt;code&gt;d&lt;/code&gt; to delete them. You only need to press it once, since you are in linewise visual mode. At this point, you can see that you either did or did not actually want to delete it that way without altering the entire file. It is not uncommon to notice that while you did delete what you intended, it would be better to also delete the line below it, as it is just white space. This is one of the advantages of this approach, you can refine exactly what you want to delete in one place before moving on to the rest of the file. The key here is to make sure that you undo the change that wasn't quite correct, and then delete all of it with a single command so that &lt;code&gt;.&lt;/code&gt; will work well for you going forward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have deleted what you want, press &lt;code&gt;n&lt;/code&gt; to jump to the next search result. Look and see if you really want to delete that next one. To delete it, just press &lt;code&gt;.&lt;/code&gt; to repeat your last deletion. Keep doing this until they are all deleted. So basically, you are pressing &lt;code&gt;n.&lt;/code&gt; over and over again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way with each result you can visually decide if that match is really the same and if you really want to delete it each time, and then deleting it is as simple as pressing &lt;code&gt;.&lt;/code&gt;. If you encounter a match where you want to delete it differently, ignore it for now, move onto the next result. Otherwise, you will mess up your &lt;code&gt;.&lt;/code&gt;. Finish deleting all the places that don't require any changes in how you delete it. Then keep pressing &lt;code&gt;n&lt;/code&gt; and try some variance of this approach to delete the remaining matches.&lt;/p&gt;&#xA;" OwnerUserId="1410" LastEditorUserId="1410" LastEditDate="2016-06-29T15:28:19.710" LastActivityDate="2016-06-29T15:28:19.710" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8509" PostTypeId="2" ParentId="8507" CreationDate="2016-06-29T15:18:18.173" Score="6" Body="&lt;p&gt;You can take advantage of the way vim execute command when applied over a range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Select your lines and do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;call system('mkdir -p '. fnamemodify(fnameescape(getline('.')),':h:p').' &amp;amp;&amp;amp; touch '.fnamemodify(fnameescape(getline('.')),':p'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will apply the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call system(...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;over &lt;strong&gt;every line&lt;/strong&gt; you've selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command is calling two external tools, &lt;code&gt;mkdir&lt;/code&gt; and &lt;code&gt;touch&lt;/code&gt; (you may change this if you work in windows).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;mkdir -p&lt;/code&gt; will create the directory (and subdirectories if necessary).&#xA;The argument is the escaped current line modified to show only the folder path (not the filename)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;touch&lt;/code&gt; will create the file&#xA;The argument is the escaped current line modified to show the path and the filename&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You need to add the &lt;code&gt;shellescape&lt;/code&gt; function so that the filename is correctly escaped for the system call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;fnamemodify&lt;/code&gt; is handy if you want to modify the filename and path.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively to &lt;code&gt;shellescape&lt;/code&gt;, you can use one of the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;code&gt;:S&lt;/code&gt; modifier in &lt;code&gt;fnamemodify&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;enclose the string with double quotes &lt;code&gt;&quot;&lt;/code&gt; (thanks @Tommy\ A for the suggestion)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h v_:&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h system&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h getline()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h shellescape()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h fnamemodify()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h ::S&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-30T06:37:07.513" LastActivityDate="2016-06-30T06:37:07.513" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8510" PostTypeId="1" AcceptedAnswerId="9492" CreationDate="2016-06-29T16:17:28.247" Score="8" ViewCount="1037" Body="&lt;p&gt;Is there any way to make the special symbol &lt;code&gt;%&lt;/code&gt; work with path names on the command line? For instance, I'd like to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:diffsplit Path\to\other\directory\%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that I can do a &lt;code&gt;@:&lt;/code&gt; to quickly compare files of the same name. However, this just opens up a new buffer called &lt;code&gt;%&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course I &lt;em&gt;could&lt;/em&gt; do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 'diffsplit Path\to\other\directory\'.expand('%')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this is cumbersome as I can't tab complete directories when typing the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any other better way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/3498/bring-up-the-current-file-name-for-edition-in-the-command-line&quot;&gt;Here's a related question&lt;/a&gt;, but it doesn't address my situation exactly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Just to clarify, I would like to be able to re-use the command exactly for different files. So a solution that simply autofills the current file in the command line will not work. The same command needs to work for &lt;em&gt;different&lt;/em&gt; file names.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-09-08T16:29:18.683" Title="How to pass current file name with a different path to the command line" Tags="|filesystem|multiple-files|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8511" PostTypeId="2" ParentId="8510" CreationDate="2016-06-29T16:21:40.787" Score="0" Body="&lt;p&gt;I don't know if this is ok for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:diffsplit Path/to/somewhere/&amp;lt;c-r&amp;gt;%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just one more keystroke to your original, the &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt;, in order to fill the &lt;code&gt;%&lt;/code&gt; register value.&lt;/p&gt;&#xA;" OwnerUserId="1569" LastActivityDate="2016-06-29T16:21:40.787" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8512" PostTypeId="1" CreationDate="2016-06-29T16:39:41.563" Score="3" ViewCount="662" Body="&lt;p&gt;So first, I realize that this question is slightly out of the ordinary for this site. I will explain the backstory to avoid the XY problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Over on &lt;a href=&quot;https://codegolf.stackexchange.com/&quot;&gt;Programming Puzzles and Code Golf&lt;/a&gt;, lots of users (especially me) like to answer programming challenges using vim, and since vim is great at manipulating strings, it does pretty well as a &quot;Programming language&quot; of sorts. However, testing these answers is a little bit of a pain. I've written &lt;a href=&quot;https://codegolf.stackexchange.com/a/74717/31716&quot;&gt;100+ keystroke&lt;/a&gt; answers in vim before, and actually typing this out to test it is a pain. Also, sometimes users who aren't as familiar with vim will make mistakes like pressing &lt;kbd&gt;&amp;lt;&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt;&lt;kbd&gt;-&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;&gt;&lt;/kbd&gt; instead of &lt;kbd&gt;ctrl+a&lt;/kbd&gt;, or not starting vim with &lt;code&gt;vim -u NONE -i NONE&lt;/code&gt; which can cause issues with mappings and registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to remedy this, I'm working on a &quot;vim interpreter&quot; that you can run in your browser. You can enter in a sequence of keystrokes, such as &lt;code&gt;iHello&amp;lt;esc&amp;gt;Yp&lt;/code&gt;, and the browser will display the text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hello&#xA;Hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this creates a security hole. A malicious user could enter something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r !ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to get a listing of files and directories on the server, and then something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e /foo/somefile.txt&#xA;dG:wq&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To wipe out files. To get around this, initially I tried sourcing the following script before running the interpreter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufReadPre * :q!&#xA;au BufWritePre * :q!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and calling neovim with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim -Z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to disable shell access.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, then I found out the user could still enter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noautocmd e /foo/somefile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I added this to the script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmap noautocmd q!&amp;lt;cr&amp;gt;&#xA;cmap noa q!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, a user can still get around this with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cunmap nog&amp;lt;bs&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The &lt;code&gt;g&amp;lt;bs&amp;gt;&lt;/code&gt; to get around 'noa' being remapped as you type it)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I added&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmap cu q!&amp;lt;cr&amp;gt;&#xA;cmap cunmap q!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &lt;em&gt;works&lt;/em&gt; as far as I know, but it feels like I'm just polishing poop and adding duct tape. So my two questions are&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is my current method secure, or are there ways to get around what I have right now?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a better way to accomplish this? If this is a linux-based solution (the server is running ubuntu), rather than a vim-based solution, that's &lt;em&gt;okay&lt;/em&gt; I guess, but since I don't own the server it will be running on, I'd rather have it be a vim-based solution, since I'm more in control of that and it's less work on the server-owner's part.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:39:29.623" LastActivityDate="2016-06-29T19:24:48.790" Title="How can I securely restrict vim access to a single file?" Tags="|autocmd|neovim|linux|filesystem|security|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8513" PostTypeId="5" CreationDate="2016-06-29T16:40:44.070" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-06-29T16:40:44.070" LastActivityDate="2016-06-29T16:40:44.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8514" PostTypeId="4" CreationDate="2016-06-29T16:40:44.070" Score="0" Body="For questions about staying secure while using vim" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-06-30T07:22:43.037" LastActivityDate="2016-06-30T07:22:43.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8515" PostTypeId="1" AcceptedAnswerId="8520" CreationDate="2016-06-29T17:50:10.767" Score="4" ViewCount="1587" Body="&lt;p&gt;In my vimrc I have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;h :bp&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;l :bn&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I have to source my vimrc to enable them with (&lt;code&gt;:so $MYVIMRC&lt;/code&gt;). If I do a &lt;code&gt;:map&lt;/code&gt; after starting vim I will see all my other shortcuts map with leader but not this one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Their also so no other shortcut map to &lt;code&gt;&amp;lt;Leader&amp;gt;h&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How this can happen?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the same problem with &lt;code&gt;let @+=join([expand('%'),  line(&quot;.&quot;)], ':')&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/benoittgt/dotfiles_osx/blob/master/.vimrc&quot; rel=&quot;nofollow&quot;&gt;My full vimrc&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="3357" LastActivityDate="2016-06-29T22:15:13.840" Title="Leader shortcuts ignored" Tags="|vimrc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8516" PostTypeId="2" ParentId="8510" CreationDate="2016-06-29T18:39:57.717" Score="10" Body="&lt;p&gt;Special characters (see &lt;code&gt;:h cmdline-special&lt;/code&gt;) and filename modifiers (see &lt;code&gt;:h filename-modifiers&lt;/code&gt;) are expanded on the command line, so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:diffsplit Path/to/other/directory/%:t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-06-29T18:39:57.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8517" PostTypeId="2" ParentId="8512" CreationDate="2016-06-29T19:24:48.790" Score="1" Body="&lt;p&gt;Have you looked at &lt;code&gt;:h :sandbox&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;These items are not allowed in the sandbox:&#xA;  - changing the buffer text&#xA;  - defining or changing mapping, autocommands, functions, user commands&#xA;  - setting certain options (see |option-summary|)&#xA;  - setting certain v: variables (see |v:var|)  *E794*&#xA;  - executing a shell command&#xA;  - reading or writing a file&#xA;  - jumping to another buffer or editing a file&#xA;  - executing Python, Perl, etc. commands&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If that's too restrictive, I would use a chroot like @grochmal said. But, I suppose you have other options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Fork Vim and neuter file reading functions so they fail as if a file wasn't found.&lt;/li&gt;&#xA;&lt;li&gt;Fork Vim and alter the sandbox behavior to allow changing buffer text.&lt;/li&gt;&#xA;&lt;li&gt;Create a docker container that has no volumes and is destroyed after a session.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-06-29T19:24:48.790" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8518" PostTypeId="2" ParentId="8507" CreationDate="2016-06-29T19:26:27.077" Score="4" Body="&lt;p&gt;If you must do it with Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Touch() range abort                       &#xA;    for fn in getline(a:firstline, a:lastline)&#xA;        if !filereadable(fn)&#xA;            let base = fnamemodify(fn, ':h')&#xA;            if !isdirectory(base)&#xA;                call mkdir(base, 'p')&#xA;            endif &#xA;            call writefile([], fn, 'a')&#xA;        endif     &#xA;    endfor        &#xA;endfunction       &#xA;&#xA;command! -range Touch &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call Touch()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Beware that this doesn't try to be the most efficient, and only does minimal error checking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same thing with a shell script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#! /bin/sh                                            &#xA;while IFS= read -r FN; do&#xA;    mkdir -p &quot;$(dirname &quot;$FN&quot;)&quot; &amp;amp;&amp;amp; touch &quot;$FN&quot; || exit 1&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can pipe the relevant range of lines to it.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="2313" LastEditDate="2016-06-29T20:22:53.843" LastActivityDate="2016-06-29T20:22:53.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8519" PostTypeId="1" CreationDate="2016-06-29T19:39:06.497" Score="1" ViewCount="63" Body="&lt;p&gt;I have been reading through the documentation on the &lt;code&gt;[d&lt;/code&gt; command, and other related commands.&#xA;My understanding is that they allow you to search for the definition of the function that's currently under the cursor, and that they should search in included files, as well as the current file.&#xA;The search pattern they use is controlled by the &lt;code&gt;define&lt;/code&gt; and &lt;code&gt;include&lt;/code&gt; settings, and the defaults are set for C syntax.&#xA;I have managed to make searching work in the current buffer with this setting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal define=^\\s*def\\s*\\(self.\\)\\?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I place the cursor on the name of a method defined in the current file and enter &lt;code&gt;[&amp;lt;c-d&amp;gt;&lt;/code&gt; I am taken to the method definition, but it still won't search included files.&#xA;Here is my current &lt;code&gt;include&lt;/code&gt; setting.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal include=^\\s*require\\(_relative\\)\\?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The search pattern successfully finds &lt;code&gt;require&lt;/code&gt; and &lt;code&gt;require_relative&lt;/code&gt; statements when I search manually, but &lt;code&gt;[d&lt;/code&gt; still can't find function definitions in required files. I'm not sure if I need to change the &lt;code&gt;iskeyword&lt;/code&gt; setting so vim can recognize the filenames. What can I do to make all this work? I would also be interested in ruby plugins that provide the same functionality.&lt;/p&gt;&#xA;" OwnerUserId="8105" LastEditorUserId="8105" LastEditDate="2016-06-29T19:44:55.167" LastActivityDate="2016-06-29T19:44:55.167" Title="Use [d with ruby functions" Tags="|include|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8520" PostTypeId="2" ParentId="8515" CreationDate="2016-06-29T22:15:13.840" Score="8" Body="&lt;p&gt;From &lt;code&gt;:h mapleader&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that the value of &quot;mapleader&quot; is used at the moment the mapping&#xA;  is defined.  Changing &quot;mapleader&quot; after that has no effect for already&#xA;  defined mappings.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your &lt;code&gt;mapleader&lt;/code&gt; is changed after your mappings in question. Meaning your mappings will use the the default &lt;code&gt;mapleader&lt;/code&gt; of a &lt;code&gt;\&lt;/code&gt;. e.g. Your mappings will be &lt;code&gt;\h&lt;/code&gt; and &lt;code&gt;\l&lt;/code&gt;. Simply define your &lt;code&gt;mapleader&lt;/code&gt; before all your mappings to get the effect you desire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see &lt;code&gt;:h mapleader&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-06-29T22:15:13.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8521" PostTypeId="1" CreationDate="2016-06-30T02:44:39.963" Score="1" ViewCount="1535" Body="&lt;p&gt;I installed Airline status line for Neovim and put the following line in my init.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_powerline_fonts = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also followed the instructions for installing powerline symbols from &lt;a href=&quot;https://gist.github.com/demil133/4f16bd5bf7e6c68b2529&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As well as downloading the patched powerline fonts from &lt;a href=&quot;https://github.com/powerline/fonts/tree/master/samples&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But instead of the nice triangles on the status line all I get is rectangle placeholder symbols. I'm out of ideas for what else I need to do.&lt;/p&gt;&#xA;" OwnerUserId="8234" LastEditorUserId="2313" LastEditDate="2016-06-30T05:13:03.017" LastActivityDate="2016-06-30T05:13:03.017" Title="Neovim Airline Powerline Fonts won't work" Tags="|plugin-airline|font|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8522" PostTypeId="1" AcceptedAnswerId="8524" CreationDate="2016-06-30T09:11:19.053" Score="4" ViewCount="1177" Body="&lt;p&gt;I have a text file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line text,line text&#xA; next line&#xA; 3rd line&#xA;Line x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where 2nd and 3rd, etc lines begin with a single space.  I need to concatenate all lines prefixed with a space to the previous one without a space, so that the result looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line text,line text next line 3rd line&#xA;Line x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The lengths of the lines can vary, and there can be many blocks like this.  Can I re-format the entire file with a single command?&lt;/p&gt;&#xA;" OwnerUserId="8239" LastEditorUserId="2313" LastEditDate="2016-06-30T11:19:51.827" LastActivityDate="2016-06-30T12:27:07.613" Title="Concatenating continuation lines" Tags="|replace|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8523" PostTypeId="2" ParentId="8522" CreationDate="2016-06-30T09:13:47.443" Score="5" Body="&lt;p&gt;You can join lines with &lt;code&gt;J&lt;/code&gt;. In your case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will join your 3 lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case you want more than 3 lines, you can do as follow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;enter visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/^[^ ]/-1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;J&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This will select the desired lines and join them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The search will look to the next line starting with a non-space character, and move up one line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to do this without entering visual mode, you can use the &lt;code&gt;join&lt;/code&gt; command preceded by the desired range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:,/^[^ ]/-1 j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-06-30T09:48:55.267" LastActivityDate="2016-06-30T09:48:55.267" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8524" PostTypeId="2" ParentId="8522" CreationDate="2016-06-30T09:15:58.340" Score="9" Body="&lt;p&gt;You can replace the new lines plus space by a space:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\n\s/ /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is an ex command i.e. a command used in the command line mode. To enter the command line mode, press &lt;kbd&gt;:&lt;/kbd&gt;. Then insert the command which does the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%        Apply the command on all the lines of the buffer&#xA;s/       The command to apply. 's' is for substitute&#xA;\n\s     The pattern to substitute here it is a new line \n followed by a space \s&#xA;/&amp;lt;space&amp;gt; The expression used to replace the pattern (here it is a simple space&#xA;/        The command must end with a / because you could add some flags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:s&quot;&gt;&lt;code&gt;:h :s&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-06-30T09:37:42.510" LastActivityDate="2016-06-30T09:37:42.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8525" PostTypeId="1" AcceptedAnswerId="8526" CreationDate="2016-06-30T09:52:44.260" Score="0" ViewCount="853" Body="&lt;p&gt;I have found the setting that are currently working for me for python development in vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;set tabs to have 4 spaces&#xA;set ts=4&#xA;&#xA;&quot; expand tabs into spaces&#xA;set expandtab&#xA;&#xA;&quot; enable all Python syntax highlighting features&#xA;let python_highlight_all = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue is, that these settings are getting in the way when opening other documents, for example Makefiles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use these settings to apply only for &lt;code&gt;*.py&lt;/code&gt; files?&lt;/p&gt;&#xA;" OwnerUserId="7129" LastEditorUserId="7129" LastEditDate="2016-06-30T10:52:57.220" LastActivityDate="2016-06-30T11:20:12.360" Title="How to apply certain vim config only to .py files" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ClosedDate="2016-06-30T13:00:57.063" ContentLicense="CC BY-SA 3.0" />
  <row Id="8526" PostTypeId="2" ParentId="8525" CreationDate="2016-06-30T09:55:37.310" Score="3" Body="&lt;p&gt;You are looking for autocommands, something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType python setlocal showmatch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would set the &lt;code&gt;showmatch&lt;/code&gt; option only on buffers with the python filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#:autocmd&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :autocmd&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ###############################&#xA;&quot; Settings I want for all files #&#xA;&quot; ###############################&#xA;&#xA;&#xA;&quot; enable syntax highlighting for all the languages vim recognizes by default&#xA;syntax enable&#xA;&#xA;&quot; indent when moving to the next line while writing code&#xA;set autoindent&#xA;&#xA;&quot; show the matching part of the pair for [] {} and ()&#xA;set showmatch&#xA;&#xA;&quot; ########################################&#xA;&quot; Settings related to python development #&#xA;&quot; ########################################&#xA;&#xA;&#xA;autocmd Filetype    python &#xA;                \   setlocal ts=4 |&#xA;                \   setlocal expandtab &#xA;&#xA;&quot; enable all Python syntax highlighting features&#xA;&quot; it doesn't highlight issues on other files even &#xA;&quot; though it's not in autocmd. Don't know&#xA;let python_highlight_all = 1 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="7129" LastEditDate="2016-06-30T11:20:12.360" LastActivityDate="2016-06-30T11:20:12.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8527" PostTypeId="2" ParentId="8522" CreationDate="2016-06-30T10:09:46.040" Score="13" Body="&lt;p&gt;For every line beginning with a space, join it with the previous one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^ /-j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;References&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help :global&lt;/code&gt;&lt;br /&gt;&#xA;&lt;code&gt;:help pattern&lt;/code&gt;&lt;br /&gt;&#xA;&lt;code&gt;:help [range]&lt;/code&gt;&lt;br /&gt;&#xA;&lt;code&gt;:help :join&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-06-30T12:27:07.613" LastActivityDate="2016-06-30T12:27:07.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8528" PostTypeId="2" ParentId="5339" CreationDate="2016-06-30T11:26:46.223" Score="2" Body="&lt;p&gt;I had the same problem. Try just to use &lt;code&gt;/&lt;/code&gt; in paths, and escape whitespace like this &lt;code&gt;\ &lt;/code&gt;.&#xA;For example I add this line in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp=C:/Program\ Files\ (x86)/Vim/vim74/vim.exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Than if you will command &lt;code&gt;:echo &amp;amp;rtp&lt;/code&gt; you can see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:/Program Files (x86)/Vim/vim74/vim.exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that here is no &lt;code&gt;\&lt;/code&gt; before whitespace.&lt;/p&gt;&#xA;" OwnerUserId="8149" LastEditorUserId="8149" LastEditDate="2016-06-30T13:03:06.703" LastActivityDate="2016-06-30T13:03:06.703" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8529" PostTypeId="1" AcceptedAnswerId="8532" CreationDate="2016-06-30T13:09:49.730" Score="9" ViewCount="272" Body="&lt;p&gt;I have defined an operator mapping which takes a region of text, then asks for an input string and then aligns the region with &lt;a href=&quot;https://github.com/godlygeek/tabular&quot;&gt;Tabular&lt;/a&gt; using the input string as an argument. It works nicely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have implemented it like this, using &lt;a href=&quot;https://github.com/kana/vim-operator-user&quot;&gt;vim-operator-user&lt;/a&gt; to help defining a new operator:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map \aa &amp;lt;Plug&amp;gt;(operator-align)&#xA;call operator#user#define('align', 'Align')&#xA;function! Align(motion_wiseness)&#xA;    let expr = input(&quot;align: &quot;)&#xA;    if len(expr) != 0&#xA;        execute &quot;'[,']Tabularize /&quot;.expr&#xA;    endif&#xA;endfunction&#xA;&#xA;&#xA;function! Getchar()&#xA;    let c = getchar()&#xA;    if c =~ '^\d\+$'&#xA;        let c = nr2char(c)&#xA;    endif&#xA;    return c&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I wondered if I could make it update on the fly while entering the regular expression to align with. The problem with the current approach is that you have to undo and then redo if you are not using the correct expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the interactive attempt, I made this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map \== &amp;lt;Plug&amp;gt;(operator-align-interactive)&#xA;call operator#user#define('align-interactive', 'AlignInteractive')&#xA;function! AlignInteractive(motion_wiseness)&#xA;    let prompt = &quot;Align: &quot;&#xA;    echon prompt&#xA;    let expr = &quot;&quot;&#xA;    let c = Getchar()&#xA;     &quot; CR has to be checked for separately as it acts as putting the cursor back to zero position&#xA;    while c != &quot;\&amp;lt;Esc&amp;gt;&quot; &amp;amp;&amp;amp; c != &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;        if c == &quot;\&amp;lt;BS&amp;gt;&quot;&#xA;            if len(expr) != 0&#xA;                let expr = expr[0:-2]&#xA;                echon &quot;\&amp;lt;CR&amp;gt;&quot;.substitute(expr, &quot;.&quot;, &quot; &quot;, &quot;g&quot;)&#xA;                echon &quot;\&amp;lt;CR&amp;gt;&quot;.prompt.expr&#xA;            endif&#xA;        else&#xA;            let expr .= c&#xA;            echon c&#xA;            let cmd = &quot;'[,']Tabularize /&quot;.expr&#xA;            execute cmd &#xA;        endif&#xA;        let c = Getchar()&#xA;    endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It &lt;em&gt;should&lt;/em&gt; work but the aligning is not done before I hit enter, that is after I have finished entering input, effectively meaning that it works the same way as the non-interactive function. I wonder if the problem could be something like the screen / content not being updated during an operator execution, only after.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on what the problem could be is appreciated!&lt;/p&gt;&#xA;" OwnerUserId="8243" LastEditorUserId="6489" LastEditDate="2016-06-30T13:15:44.490" LastActivityDate="2016-06-30T18:13:08.057" Title="How to define an operator which is updating while it is taking input?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8530" PostTypeId="1" AcceptedAnswerId="8531" CreationDate="2016-06-30T14:21:23.370" Score="9" ViewCount="368" Body="&lt;p&gt;I performed following command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/2/digit/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;on the code below manually visually selected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return _.round(this.getTotalAbs(), 2).toFixed(2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it worked as intended &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return _.round(this.getTotalAbs(), digit).toFixed(digit);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to &lt;strong&gt;repeat&lt;/strong&gt; the same &lt;strong&gt;substitute&lt;/strong&gt; command on another code snippet manually selected via visual selection mode, with &lt;strong&gt;one keystroke&lt;/strong&gt;(if possible).&lt;/p&gt;&#xA;" OwnerUserId="5890" LastEditorUserId="1841" LastEditDate="2016-06-30T14:36:28.310" LastActivityDate="2016-06-30T15:35:59.733" Title="Perform previous substitution for different selection with single keystroke" Tags="|substitute|visual-mode|replace|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8531" PostTypeId="2" ParentId="8530" CreationDate="2016-06-30T14:28:41.657" Score="15" Body="&lt;p&gt;I think you want to do &lt;kbd&gt;@:&lt;/kbd&gt; which replays the last ex command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html#@:&quot;&gt;&lt;code&gt;:h @:&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this command can be called from normal mode and from visual mode. Also in this case it is not useful but you can also prefix it with a count.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; In the comments @Antony pointed out an interesting command: &lt;code&gt;:&amp;amp;&lt;/code&gt; (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:&amp;amp;&quot;&gt;&lt;code&gt;:h :&amp;amp;&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;&lt;/code&gt; can be used in normal mode to repeat the last substitute command without its flags&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:&amp;amp;&amp;amp;&lt;/code&gt; can be used in ex mode to repeat the last substitute command keeping the flags. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-06-30T15:35:59.733" LastActivityDate="2016-06-30T15:35:59.733" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8532" PostTypeId="2" ParentId="8529" CreationDate="2016-06-30T14:52:32.933" Score="8" Body="&lt;p&gt;You need to &lt;code&gt;undo&lt;/code&gt; and &lt;code&gt;redraw&lt;/code&gt; if you want to see changes in the buffer right away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AlignInteractive(motion_wiseness)&#xA;  let prompt = &quot;Align: &quot;&#xA;  let undo = 0&#xA;  let expr = &quot;&quot;&#xA;  let range = line(&quot;'[&quot;).','.line(&quot;']&quot;)&#xA;  let failed = 0&#xA;  let accept = 0&#xA;&#xA;  echon prompt&#xA;  let c = Getchar()&#xA;&#xA;  while c != &quot;\&amp;lt;Esc&amp;gt;&quot; &amp;amp;&amp;amp; c != &quot;\&amp;lt;c-c&amp;gt;&quot;&#xA;    let undo = len(expr)&#xA;&#xA;    if c == &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;      let accept = 1&#xA;      break&#xA;    elseif c == &quot;\&amp;lt;BS&amp;gt;&quot;&#xA;      if len(expr)&#xA;        let expr = expr[0:-2]&#xA;      endif&#xA;    else&#xA;      let expr .= c&#xA;    endif&#xA;&#xA;    if undo &amp;amp;&amp;amp; !failed&#xA;      silent! undo&#xA;    endif&#xA;&#xA;    if len(expr)&#xA;      try&#xA;        call match('', expr)&#xA;        let failed = 0&#xA;        execute range.&quot;Tabularize /&quot;.expr&#xA;      catch //&#xA;        let failed = 1&#xA;      endtry&#xA;    endif&#xA;&#xA;    redraw&#xA;&#xA;    echon prompt&#xA;    if failed&#xA;      echohl ErrorMsg&#xA;    endif&#xA;    echon expr&#xA;    echohl None&#xA;    let c = Getchar()&#xA;  endwhile&#xA;&#xA;  if !accept &amp;amp;&amp;amp; len(expr) &amp;amp;&amp;amp; !failed&#xA;    silent! undo&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Explanation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;range&lt;/code&gt; variable stores the &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt; marks.  This is for sanity's sake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A variable called &lt;code&gt;undo&lt;/code&gt; is set based on the &lt;em&gt;previous&lt;/em&gt; length of &lt;code&gt;expr&lt;/code&gt;.  This means whenever there is input from the user, the next iteration can safely undo before executing &lt;code&gt;Tabularize&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;call match('', expr)&lt;/code&gt; tests the expression for pattern errors.  If it fails, &lt;code&gt;undo&lt;/code&gt; should not be executed.  Pattern failures can happen as you're typing atoms such as &lt;code&gt;\zs&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;redraw&lt;/code&gt; will clear the command line.  This is why the full prompt is printed on every iteration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the pattern contains an error, it is highlighted with &lt;code&gt;ErrorMsg&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;accept&lt;/code&gt; is set when &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; is pressed.  If it's false, undo the changes (if any).  Anything else that breaks the loop cancels.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Existing plugin&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There is a plugin called &lt;a href=&quot;https://github.com/junegunn/vim-easy-align&quot;&gt;vim-easy-align&lt;/a&gt; that can do what you're attempting.  You could &lt;a href=&quot;https://github.com/junegunn/vim-easy-align/blob/0cb6b98fc155717b0a56c110551ac57d1d951ddb/autoload/easy_align.vim#L623-L820&quot;&gt;draw inspiration from it's script&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-06-30T18:13:08.057" LastActivityDate="2016-06-30T18:13:08.057" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8533" PostTypeId="2" ParentId="6601" CreationDate="2016-07-01T04:30:49.077" Score="5" Body="&lt;p&gt;The current version of vim-plug allows you to specify tags with wildcards and it selects the latest version (&lt;code&gt;--sort -version:refname&lt;/code&gt;) if multiple matching tags are found. So you can simply write &lt;code&gt;*&lt;/code&gt; if you want the latest tag. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'fatih/vim-go', { 'tag': '*' }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you'll see that the installer handles it as expected.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- Finishing ... Done!&#xA;- Latest tag for * -&amp;gt; v1.7.1 (vim-go)&#xA;- vim-go: Cloning into '/Users/jg/.vim/plugged/vim-go'...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="661" LastActivityDate="2016-07-01T04:30:49.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8534" PostTypeId="1" CreationDate="2016-07-01T06:25:38.667" Score="13" ViewCount="1304" Body="&lt;p&gt;If I run &lt;code&gt;:cnext&lt;/code&gt; when I'm already at the end of the quickfix list I get the error message&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E553: No more items&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and nothing happens. Instead of this, when I enter &lt;code&gt;:cnext&lt;/code&gt; at the end of the list, I would like vim to cycle back around to the first quickfix entry. Is it possible configure vim for this behavior?&lt;/p&gt;&#xA;" OwnerUserId="8105" LastActivityDate="2016-07-01T14:24:26.507" Title="Make cnext and cprevious loop back to the begining" Tags="|quickfix|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8535" PostTypeId="2" ParentId="8534" CreationDate="2016-07-01T07:01:41.280" Score="21" Body="&lt;p&gt;You can write some commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Cnext try | cnext | catch | cfirst | catch | endtry&#xA;command! Cprev try | cprev | catch | clast | catch | endtry&#xA;&#xA;command! Lnext try | lnext | catch | lfirst | catch | endtry&#xA;command! Lprev try | lprev | catch | llast | catch | endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the exception is caught, it jumps to the first/last item.  You can use &lt;code&gt;cabbrev&lt;/code&gt; so you don't have to use the upper case commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cabbrev cnext Cnext&#xA;cabbrev cprev CPrev&#xA;cabbrev lnext Lnext&#xA;cabbrev lprev Lprev&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-07-01T14:24:26.507" LastActivityDate="2016-07-01T14:24:26.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8536" PostTypeId="1" AcceptedAnswerId="8537" CreationDate="2016-07-01T11:53:32.320" Score="8" ViewCount="3740" Body="&lt;p&gt;I use vim to edit &lt;code&gt;latex&lt;/code&gt;, but latex is bit too heavy for taking notes casually on daily basis, so I decided to use markdown instead.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I want to configure vim so that I could view markdown formatted file using &lt;code&gt;\lv&lt;/code&gt; command  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;code&gt;Mac OS X 10.11&lt;/code&gt;. How should I modify .vimrc file?&lt;/p&gt;&#xA;" OwnerUserId="1819" LastEditorUserId="1819" LastEditDate="2016-07-01T12:38:34.557" LastActivityDate="2019-06-26T07:52:09.657" Title="How to preview the result of markdown file edited in vim?" Tags="|vim-windows|macvim|filetype-markdown|unix|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8537" PostTypeId="2" ParentId="8536" CreationDate="2016-07-01T12:09:26.980" Score="10" Body="&lt;p&gt;While I mostly agree with @romainl comment (markdown was made to be explicit enough not to need a preview) you can do this in different ways:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[OSX / Unix]&lt;/strong&gt; The &lt;a href=&quot;https://github.com/suan/vim-instant-markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;instant-markdown plugin&lt;/a&gt; is a solution. You need to have node.js installed and to use the following command: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[sudo] npm -g install instant-markdown-d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You also need to have the packages &lt;code&gt;xdg-utils&lt;/code&gt;, &lt;code&gt;curl&lt;/code&gt; and &lt;code&gt;nodejs-legacy&lt;/code&gt; installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that when you open a markdown buffer, an html page will be opened in your web browser and you'll see the changes in real time.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[Unix]&lt;/strong&gt; &lt;a href=&quot;https://unix.stackexchange.com/a/4141/90314&quot;&gt;This answer&lt;/a&gt; suggests to use the &lt;a href=&quot;http://daringfireball.net/projects/downloads/Markdown_1.0.1.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;daringfireball markdown&lt;/a&gt; program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have downloaded it you can use the following command to see the file in &lt;a href=&quot;http://lynx.browser.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lynx&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./Markdown.pl ~/testfile.markdown | lynx -stdin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could use it in a Vim command with something like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!./Markdown.pl % | lynx -stdin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[Unix]&lt;/strong&gt; Another plugin which could be useful is &lt;a href=&quot;https://github.com/greyblake/vim-preview&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-preview&lt;/a&gt; it seems to have some dependencies but should work on markdown, rdoc, textile, ronn and rts files.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[Windows / OSX]&lt;/strong&gt; Finally the github user natesilva made &lt;a href=&quot;https://gist.github.com/natesilva/960015&quot; rel=&quot;nofollow noreferrer&quot;&gt;a very good gist&lt;/a&gt; which only requires the &lt;code&gt;markdown&lt;/code&gt; command in your path. Once you sourced the script &lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; should open your markdown in the default browser.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&#xA;&quot; While editing a Markdown document in Vim, preview it in the&#xA;&quot; default browser.&#xA;&quot;&#xA;&quot; Author: Nate Silva&#xA;&quot;&#xA;&quot; To install: Place markdown.vim in ~/.vim/ftplugin or&#xA;&quot; %USERPROFILE%\vimfiles\ftplugin.&#xA;&quot;&#xA;&quot; To use: While editing a Markdown file, press ',p' (comma p)&#xA;&quot;&#xA;&quot; Tested on Windows and Mac OS X. Should work on Linux if you set&#xA;&quot; BROWSER_COMMAND properly.&#xA;&quot;&#xA;&quot; Requires the `markdown` command to be on the system path. If you&#xA;&quot; do not have the `markdown` command, install one of the following:&#xA;&quot;&#xA;&quot; http://www.pell.portland.or.us/~orc/Code/discount/&#xA;&quot; http://www.freewisdom.org/projects/python-markdown/&#xA;&quot;&#xA;function!PreviewMarkdown()&#xA;    &quot; **************************************************************&#xA;    &quot; Configurable settings&#xA;&#xA;    let MARKDOWN_COMMAND = 'markdown'&#xA;&#xA;    if has('win32')&#xA;        &quot; note important extra pair of double-quotes&#xA;        let BROWSER_COMMAND = 'cmd.exe /c start &quot;&quot;'&#xA;    else&#xA;        let BROWSER_COMMAND = 'open'&#xA;    endif&#xA;&#xA;    &quot; End of configurable settings&#xA;    &quot; **************************************************************&#xA;&#xA;    silent update&#xA;    let output_name = tempname() . '.html'&#xA;&#xA;    &quot; Some Markdown implementations, especially the Python one,&#xA;    &quot; work best with UTF-8. If our buffer is not in UTF-8, convert&#xA;    &quot; it before running Markdown, then convert it back.&#xA;    let original_encoding = &amp;amp;fileencoding&#xA;    let original_bomb = &amp;amp;bomb&#xA;    if original_encoding != 'utf-8' || original_bomb == 1&#xA;        set nobomb&#xA;        set fileencoding=utf-8&#xA;        silent update&#xA;    endif&#xA;&#xA;    &quot; Write the HTML header. Do a CSS reset, followed by setting up&#xA;    &quot; some basic styles from YUI, so the output looks nice.&#xA;    let file_header = ['&amp;lt;html&amp;gt;', '&amp;lt;head&amp;gt;',&#xA;        \ '&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&amp;gt;',&#xA;        \ '&amp;lt;title&amp;gt;Markdown Preview&amp;lt;/title&amp;gt;',&#xA;        \ '&amp;lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://yui.yahooapis.com/3.3.0/build/cssreset/reset-min.css&quot;&amp;gt;',&#xA;        \ '&amp;lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://yui.yahooapis.com/3.3.0/build/cssbase/base-min.css&quot;&amp;gt;',&#xA;        \ '&amp;lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://yui.yahooapis.com/3.3.0/build/cssfonts/fonts-min.css&quot;&amp;gt;',&#xA;        \ '&amp;lt;style&amp;gt;body{padding:20px;}div#container{background-color:#F2F2F2;padding:0 20px;margin:0px;border:solid #D0D0D0 1px;}&amp;lt;/style&amp;gt;',&#xA;        \ '&amp;lt;/head&amp;gt;', '&amp;lt;body&amp;gt;', '&amp;lt;div id=&quot;container&quot;&amp;gt;']&#xA;    call writefile(file_header, output_name)&#xA;&#xA;    let md_command = '!' . MARKDOWN_COMMAND . ' &quot;' . expand('%:p') . '&quot; &amp;gt;&amp;gt; &quot;' .&#xA;        \ output_name . '&quot;'&#xA;    silent exec md_command&#xA;&#xA;    if has('win32')&#xA;        let footer_name = tempname()&#xA;        call writefile(['&amp;lt;/div&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;'], footer_name)&#xA;        silent exec '!type &quot;' . footer_name . '&quot; &amp;gt;&amp;gt; &quot;' . output_name . '&quot;'&#xA;        exec delete(footer_name)&#xA;    else&#xA;        silent exec '!echo &quot;&amp;lt;/div&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&quot; &amp;gt;&amp;gt; &quot;' .&#xA;            \ output_name . '&quot;'&#xA;    endif&#xA;&#xA;    &quot; If we changed the encoding, change it back.&#xA;    if original_encoding != 'utf-8' || original_bomb == 1&#xA;        if original_bomb == 1&#xA;            set bomb&#xA;        endif&#xA;        silent exec 'set fileencoding=' . original_encoding&#xA;        silent update&#xA;    endif&#xA;&#xA;    silent exec '!' . BROWSER_COMMAND . ' &quot;' . output_name . '&quot;'&#xA;&#xA;    exec input('Press ENTER to continue...')&#xA;    echo&#xA;    exec delete(output_name)&#xA;endfunction&#xA;&#xA;&quot; Map this feature to the key sequence ',p' (comma lowercase-p)&#xA;map ,p :call PreviewMarkdown()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; @TommyA also suggested &lt;a href=&quot;https://github.com/joeyespo/grip&quot; rel=&quot;nofollow noreferrer&quot;&gt;grip&lt;/a&gt; this is not a vim plugin but it can be installed with &lt;code&gt;pip install grip&lt;/code&gt;. The main advantage of this program is that it uses GitHub's markdown API so the render should be pretty close to what your markdown will look like on Github pages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This program will serve your markdown files on &lt;code&gt;localhost:6419&lt;/code&gt; by default. You should be able to invoke it from Vim with &lt;code&gt;:!grip&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-06-26T07:52:09.657" LastActivityDate="2019-06-26T07:52:09.657" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="8538" PostTypeId="1" CreationDate="2016-07-01T13:32:42.247" Score="1" ViewCount="2536" Body="&lt;p&gt;I'm trying to use vim-tmux-navigator. I'd like to use default key bindings to move between vim and tmux splits. Which is &lt;code&gt;&amp;lt;C-W&amp;gt;hjkl&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it isn't working. Either you can't remap anything with &lt;code&gt;C-W&lt;/code&gt; prefix or something else, I don't know. Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that a lot of people use &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; to switch between splits, but I don't like it. I'd like to use default bindings for that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tmux_navigator_no_mappings = 1&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-w&amp;gt;h :TmuxNavigateLeft&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-w&amp;gt;j :TmuxNavigateDown&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-w&amp;gt;k :TmuxNavigateUp&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-w&amp;gt;l :TmuxNavigateRight&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-w&amp;gt;p :TmuxNavigatePrevious&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my config. I can confirm again, that it isn't working for me. It's moves between vim splits without a problem, but isn't calling TmuxNavigate commands obviously, because can't move to another tmux split. At the same time it's moving between vim and tmux splits perfectly when issuing TmuxNavigate command manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which is why I created this question in the first place. Guys, are you sure this is working for you?&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6634" LastEditDate="2016-07-01T18:53:05.057" LastActivityDate="2019-04-01T13:52:46.097" Title="How to remap &lt;C-W&gt;hjkl to navigate tmux panes and vim splits" Tags="|key-bindings|split|tmux|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8539" PostTypeId="2" ParentId="8538" CreationDate="2016-07-01T13:45:52.003" Score="1" Body="&lt;p&gt;Some commands are defined by the plugin, you can use them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-W&amp;gt;l :TmuxNavigateRight&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Have a look at &lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator/blob/74ee1dbc13bb774f5f63234c086ed2d48fa1fc32/plugin/tmux_navigator.vim#L98-L102&quot; rel=&quot;nofollow&quot;&gt;the plugin's code&lt;/a&gt; for more informations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And note you can also disable the default mapping with the variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g:tmux_navigator_no_mappings&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-01T13:45:52.003" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8540" PostTypeId="1" AcceptedAnswerId="8548" CreationDate="2016-07-01T15:31:55.157" Score="1" ViewCount="499" Body="&lt;p&gt;I'm sorry if the question doesn't make much sense, but I really don't know how else to describe it. I'll do my best to clarify.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say I have a text file containing the words&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;here is some text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I were to place the cursor on the 'h' and press and hold &lt;kbd&gt;x&lt;/kbd&gt; to delete the line (or any number of characters) it copies the last letter of the line over the rest of the text. If I were to delete the entire line by holding &lt;kbd&gt;x&lt;/kbd&gt; it would then become&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xxxxxxxxxxxxxxxxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I can't move the cursor past the first column on that line, so the text is properly deleted, it just doesn't display correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also only happens in tiling window managers. I have tested it in ratpoison, StumpWM, spectrwm, dwm, and i3. I use XFCE4 as my everyday desktop and have been looking into switching to a tiling one, but without vim I can't do that. I have no idea why this is happening either, which makes it that much worse.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.vimrc:&#xA;set nocompatible&#xA;set number&#xA;syntax on&#xA;set shiftwidth=2&#xA;set softtabstop=2  &#xA;set incsearch&#xA;set tabstop=2&#xA;set expandtab&#xA;set smartindent&#xA;set ruler&#xA;set wildmenu  &#xA;set relativenumber&#xA;set showcmd&#xA;set ignorecase&#xA;set smartcase&#xA;set laststatus=2&#xA;set mat=2&#xA;set showmatch&#xA;set so=999&#xA;scriptencoding utf-8&#xA;set enc=utf-8&#xA;set fileencoding=utf-8&#xA;set matchpairs+=&amp;lt;:&amp;gt;&#xA;set matchpairs+=/:/&#xA;&quot;Key Bindings&#xA;noremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&quot;vim-latexsuite mappings&#xA;filetype plugin on&#xA;set grepprg=grep\ -nH\ $* &#xA;let g:tex_flavor='latex'&#xA;set iskeyword+=:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8251" LastEditorUserId="205" LastEditDate="2016-07-02T17:38:33.907" LastActivityDate="2016-07-02T17:38:33.907" Title="Vim not displaying deleted text correctly in tiling WM" Tags="|cut-copy-paste|terminal|linux|" AnswerCount="1" CommentCount="20" ContentLicense="CC BY-SA 3.0" />
  <row Id="8541" PostTypeId="2" ParentId="5310" CreationDate="2016-07-01T19:58:50.370" Score="-1" Body="&lt;p&gt;Yes this solved for me also this unkind effect:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I opened, and edited my ~/.vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype indent off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you do not like the higlight scheme, you just search the selected colorscheme here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/vim/vim74/colors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i use generaly &quot;colorscheme desert&quot;, in the 77-th row you find:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  hi Search cterm=NONE ctermfg=grey ctermbg=lightblue&#xA;  hi Search cterm=bold ctermfg=black ctermbg=green&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that was for me better than the lightbue&lt;/p&gt;&#xA;" OwnerUserId="8257" LastEditorUserId="1841" LastEditDate="2016-07-02T10:49:21.210" LastActivityDate="2016-07-02T10:49:21.210" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8542" PostTypeId="1" AcceptedAnswerId="8546" CreationDate="2016-07-01T22:28:50.747" Score="9" ViewCount="583" Body="&lt;p&gt;I want to sort the following based on their keys&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case IndexError:&#xA;    PyErr_SetString(PyExc_IndexError, exc.str.c_str());&#xA;    break;&#xA;case ValueError:&#xA;    PyErr_SetString(PyExc_ValueError, exc.str.c_str());&#xA;    break;&#xA;case RuntimeError:&#xA;    PyErr_SetString(PyExc_RuntimeError, exc.str.c_str());&#xA;    break;&#xA;case IOError:&#xA;    PyErr_SetString(PyExc_IOError, exc.str.c_str());&#xA;    break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so it becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case IOError:&#xA;    PyErr_SetString(PyExc_IOError, exc.str.c_str());&#xA;    break;&#xA;case IndexError:&#xA;    PyErr_SetString(PyExc_IndexError, exc.str.c_str());&#xA;    break;&#xA;case RuntimeError:&#xA;    PyErr_SetString(PyExc_RuntimeError, exc.str.c_str());&#xA;    break;&#xA;case ValueError:&#xA;    PyErr_SetString(PyExc_ValueError, exc.str.c_str());&#xA;    break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Essentially, I am only sorting the lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case IOError:&#xA;case IndexError:&#xA;case RuntimeError:&#xA;case ValueError:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The contents of the other lines (the ones that do not begin with a &lt;code&gt;case&lt;/code&gt;) do not matter but I want them to be sorted with the cases.&lt;/p&gt;&#xA;" OwnerUserId="8259" LastActivityDate="2016-07-02T13:51:17.140" Title="Sort every few lines" Tags="|multiple-lines|sort|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8546" PostTypeId="2" ParentId="8542" CreationDate="2016-07-02T05:14:41.207" Score="10" Body="&lt;p&gt;The easy way: join the lines in the logical blocks before sorting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In detail:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;mark the lines&lt;/li&gt;&#xA;&lt;li&gt;join the indented lines to the lines above: &lt;code&gt;:'&amp;lt;,'&amp;gt;s/\n /^A/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;mark the lines again: &lt;code&gt;gv&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;sort them: &lt;code&gt;:'&amp;lt;,'&amp;gt;sort&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;mark the lines one more time: &lt;code&gt;gv&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;split the lines back and restore indentation: &lt;code&gt;:'&amp;lt;,'&amp;gt;s/^A/\r /g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^A&lt;/code&gt; above is the character &lt;kbd&gt;Ctrl-A&lt;/kbd&gt; (ASCII &lt;code&gt;SOH&lt;/code&gt;).  It could be any character that doesn't appear in the lines to be sorted, but &lt;kbd&gt;Ctrl-A&lt;/kbd&gt; fits the bill.  You can enter it as &lt;kbd&gt;Ctrl-v&lt;/kbd&gt;&lt;kbd&gt;Ctrl-a&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-07-02T05:14:41.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8547" PostTypeId="2" ParentId="8542" CreationDate="2016-07-02T06:03:39.803" Score="4" Body="&lt;p&gt;&lt;strong&gt;Idea:&lt;/strong&gt; Let's join the &lt;code&gt;n&lt;/code&gt; number of lines under case to a single line.&#xA;Follow the process for all cases. Then, use sort to sort the cases. Then, cut those lines back and indent them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Steps:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1)  Join &lt;code&gt;n&lt;/code&gt; lines following &lt;code&gt;case&lt;/code&gt; by typing this. (in your case, n is 3)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/case / normal! 3gJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2) Select all such cases using visual mode. Press &lt;code&gt;v&lt;/code&gt; ot &lt;code&gt;V&lt;/code&gt; to select all cases. Press &lt;code&gt;:&lt;/code&gt;. It will appear like &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt;. Type sort.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;sort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;3) Put the lines of case under it. Select them again by pressing gv.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\(;\|:\)    /&amp;amp;\r    /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This splits the case lines. If lines arent indented properly, you can align them by selecting &lt;code&gt;gv&lt;/code&gt; and then &lt;code&gt;==&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works for any number of lines, provided that you use the steps customised for your purpose.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastActivityDate="2016-07-02T06:03:39.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8548" PostTypeId="2" ParentId="8540" CreationDate="2016-07-02T16:07:46.577" Score="2" Body="&lt;p&gt;I managed to figure it out guys. I looked at the help entry for the '-u' command and saw there was also a '-u NORC' option which only skipped the vimrc file, not plugins. When I ran it, the problem was gone meaning that the problem had to be in the RC file. The first thing I did was delete the three lines regarding the enconding, but that didn't change anything either. After I looked at ':scriptnames' I saw there was another vimrc being loaded at /etc/vimrc, which was an exact copy of the one in my home directory prior to the edits I made. After commenting out the entire file and removing the comments one by one, I managed to figure out it is the&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set enc=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;line that was giving me all the trouble. My guess is that xterm was not being run in utf-8 mode, which was causing problems when trying to display (or more accurately delete) characters. Thanks for you help guys!&lt;/p&gt;&#xA;" OwnerUserId="8251" LastActivityDate="2016-07-02T16:07:46.577" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8549" PostTypeId="1" CreationDate="2016-07-02T16:44:44.680" Score="1" ViewCount="141" Body="&lt;p&gt;Working on a C file, Vim correctly indents as I type. In Objective-C, however, it gets indentation right, but &lt;em&gt;de&lt;/em&gt;indentation wrong for instance methods, unless I exit insert mode and use the &lt;code&gt;=&lt;/code&gt; operator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if &lt;code&gt;|&lt;/code&gt; is the cursor, in C I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main()|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;hit &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main()&#xA;    |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;type &lt;kbd&gt;{&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main()&#xA;{|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;hit &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main()&#xA;{&#xA;    |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;type &lt;kbd&gt;}&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main()&#xA;{&#xA;}|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in Objective-C, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- (void)method&#xA;{|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;hit &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- (void)method&#xA;{&#xA;    |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;type &lt;kbd&gt;}&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- (void)method&#xA;{&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have 'autoindent' on, 'smartindent' off, 'cindent' on, and 'cinkeys' is &lt;code&gt;0{,0},0),:,0#,!^F,o,O,e&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1855" LastEditorUserId="6489" LastEditDate="2016-07-13T21:48:24.567" LastActivityDate="2016-07-13T21:48:24.567" Title="What controls (de)indenting when inserting a brace character?" Tags="|indentation|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8550" PostTypeId="2" ParentId="7138" CreationDate="2016-07-02T21:28:08.783" Score="5" Body="&lt;p&gt;&lt;strong&gt;External Editing&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have Visual Studio up and running while you edit the project files in a separate window under Vim, every time you switch back to Visual Studio, it looks at the on-disk timestamps for every file you have open in Visual Studio, including the project file. For each file that changed since you switched away from Visual Studio, it asks if you want to reload it from disk. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It even asks if you want to just reload everything that's changed, so you can edit multiple files without Alt-Tabbing back to Visual Studio after each edit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Building from Vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using Visual Studio 2010 or newer, they've switched to &lt;a href=&quot;https://en.wikipedia.org/wiki/MSBuild&quot; rel=&quot;nofollow noreferrer&quot;&gt;MSBuild&lt;/a&gt; for Visual C++ projects. (Prior to that, MSBuild was only for projects in .NET languages.) That means you can integrate MSBuild into Vim as a build system:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set errorformat=\ %#%f(%l\\\,%c):\ %m&#xA;:set makeprg=msbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Swiped from &lt;a href=&quot;https://stackoverflow.com/a/3621753/142454&quot;&gt;here&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Visual-Studio-Like Command Key Mappings&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These command mappings are inspired by old versions of Visual Studio:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;S-F4&amp;gt; :cp&amp;lt;cr&amp;gt;&#xA;map &amp;lt;F4&amp;gt; :cn&amp;lt;cr&amp;gt;&#xA;map &amp;lt;F5&amp;gt; :make run&amp;lt;cr&amp;gt;&#xA;map &amp;lt;F7&amp;gt; :make&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Microsoft keeps changing these command keys, and I keep switching them back when installing new versions, so I can't remember what they're using these days. Adjust to taste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Emulating Vim Inside Visual Studio&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, there's another way to go entirely here: emulate Vim inside Visual Studio!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This was once the province of only those who bought Visual Studio Professional or higher, but with the release of Visual Studio 2015, the free version finally has the ability to load third-party extensions. There are a couple of them that do this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://visualstudiogallery.msdn.microsoft.com/59ca71b3-a4a3-46ca-8fe1-0e90e3f79329&quot; rel=&quot;nofollow noreferrer&quot;&gt;VsVim&lt;/a&gt;, a free extension available through the Visual Studio Gallery&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.viemu.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ViEmu&lt;/a&gt;, a commercial extension. Presumably it's better in some way, else they wouldn't still be in business.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Or, you can go join the cool kids and start using &lt;a href=&quot;https://code.visualstudio.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Visual Studio Code&lt;/a&gt;, which has at least three Vim emulator extensions. I haven't test-driven them extensively, but here they are ordered by how well they matched my expectations of how a Vim emulation should behave:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/VSCodeVim/Vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;VsCodeVim&lt;/a&gt; (a.k.a. just &quot;Vim&quot;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/aioutecism/amVim-for-VSCode&quot; rel=&quot;nofollow noreferrer&quot;&gt;amVim&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=74th.vimStyle&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimStyle&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To install any of them, just hit &lt;kbd&gt;Ctrl-Shift-P&lt;/kbd&gt; (Windows) inside Visual Studio code, type &lt;code&gt;inst&lt;/code&gt;, select &lt;code&gt;Extensions: Install Extension&lt;/code&gt;, then type &lt;code&gt;vim&lt;/code&gt;. All three will come up, along with a few other things which are not Vim emulators for VSCode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of those extensions are flawless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I say this as one who uses Vim daily, and installs such extensions only to ease the transition when I do occasionally have to use Visual Studio and VSCode.)&lt;/p&gt;&#xA;" OwnerUserId="6852" LastEditorUserId="6852" LastEditDate="2020-04-04T06:39:10.767" LastActivityDate="2020-04-04T06:39:10.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8551" PostTypeId="1" CreationDate="2016-07-02T22:52:07.220" Score="5" ViewCount="841" Body="&lt;p&gt;I have recently reinstalled vim and I noticed that the Spell checking is working very slowly. Whenever I do a &lt;code&gt;z=&lt;/code&gt; on an incorrectly spelled word, Vim takes a good 4-5 seconds to show the spelling suggestions which is really really long. This used to happen almost instantly before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It used to work fine before and I have no idea what happened. I checked this with bare vim too using &lt;code&gt;vim -u NONE&lt;/code&gt; and it is still slow. So, I guess I can rule out this being an issue with my settings or with the plugins. And, Every thing else is behaving normally. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on why this is happening and what can be do to speed this up? I am using the recent version of Vim for windows. &lt;/p&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="51" LastEditDate="2016-07-13T21:39:02.730" LastActivityDate="2016-07-13T21:39:02.730" Title="Vim is taking a really long time to open spelling suggestions" Tags="|microsoft-windows|spell-checking|" AnswerCount="0" CommentCount="13" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8552" PostTypeId="2" ParentId="8419" CreationDate="2016-07-02T23:06:04.417" Score="0" Body="&lt;p&gt;A few solutions have already been mentioned and I would like to add one more that &lt;strong&gt;might&lt;/strong&gt; help. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a blank line after &lt;code&gt;};&lt;/code&gt;, which I am assuming is not rare considering that its the end of a block, you can just do &lt;kbd&gt;&lt;code&gt;d&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;}&lt;/code&gt;&lt;/kbd&gt; and that will delete till the blank line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But Of course this won't work if the next line starts immediately without a blank line or if there is a blank line inside the block. I hope that helped.&lt;/p&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="5481" LastEditDate="2016-07-03T17:45:34.440" LastActivityDate="2016-07-03T17:45:34.440" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8553" PostTypeId="2" ParentId="236" CreationDate="2016-07-02T23:25:55.970" Score="1" Body="&lt;p&gt;There are already a lot of things covered in the existing answers. I just like to add one mapping that I use very often for indentation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;i  mzgg=G`z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have seen some vimrc with this mapped to &lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either way this is a great mapping to have and I use this almost everytime especially when pasting code copied from somewhere else. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or even better put this in an &lt;code&gt;autocmd&lt;/code&gt; so that Vim indents it just before you write the changes to the disk. &lt;/p&gt;&#xA;" OwnerUserId="5481" LastActivityDate="2016-07-02T23:25:55.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8554" PostTypeId="1" AcceptedAnswerId="8555" CreationDate="2016-07-02T23:49:06.200" Score="3" ViewCount="828" Body="&lt;p&gt;I have a cygwin shell in my windows computer and it has a Vim installation of its own in it. And, so the plugins I have for Gvim are not available for the Cygwin vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried symlinking the plugins from cygwin to the gvim but Vim is complaining about the File's line endings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, Is it possible to use the same plugin folders for both vim inside cygwin and vim in windows with out the file ending conflict?&lt;/p&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="51" LastEditDate="2016-07-04T16:42:15.707" LastActivityDate="2016-07-06T01:24:36.667" Title="Using the same plugin folders for gvim and with vim in cygwin" Tags="|microsoft-windows|plugin-system|cygwin|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8555" PostTypeId="2" ParentId="8554" CreationDate="2016-07-02T23:58:04.393" Score="2" Body="&lt;p&gt;There are &lt;a href=&quot;https://cygwin.com/cygwin-ug-net/using.html#pathnames-symlinks&quot; rel=&quot;nofollow&quot;&gt;several different types of symlinks on Cygwin&lt;/a&gt;. Only the native NTFS symlink type will be understood by a non-Cygwin build of gVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That gives you two options, depending on which direction you want the symlink to point:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Cygwin Vim as Master, Native gVim Pointing to It&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Right-click the Cygwin Terminal icon, select &quot;Run as administrator,&quot; then give the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd &quot;$USERPROFILE&quot;&#xA;CYGWIN=winsymlinks:nativestrict ln -s ~/.vim vimfiles &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use Vim plugins in the Unix way, with &lt;code&gt;~/.vim&lt;/code&gt; as the directory where Cygwin Vim looks for local plugins and such, with Windows gVim continuing to find them in the &lt;code&gt;vimfiles&lt;/code&gt; directory under your Windows user profile directory, not realizing that it is being directed through an NTFS symlink to the directory Cygwin Vim uses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may need to do this for &lt;code&gt;.vimrc&lt;/code&gt; as well. (See below for why &quot;may.&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although Cygwin Vim uses Unix style line endings (i.e. LF-only) for plugins and such and native Windows gVim uses DOS style (CRLF) endings, I did not find it necessary to convert the Unix line endings in my Vim configuration to DOS style to get gVim to read the files correctly. This is doubtless because Vim itself gracefully copes with such things as a text editor, so naturally it would do the same for the configuration and script files it reads.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Native gVim as Master, Cygwin Vim Pointing to It&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Doing it this direction is simpler, since only Cygwin needs to understand the symlink, and because Cygwin symlinks don't have all the restrictions of &lt;a href=&quot;https://en.wikipedia.org/wiki/NTFS_symbolic_link&quot; rel=&quot;nofollow&quot;&gt;NTFS symbolic links&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a regular (i.e. non-admin) Cygwin terminal, type this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ln -s &quot;$(cygpath -u &quot;$USERPROFILE&quot;)&quot;/vimfiles ~/.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Much simpler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be clear, there's nothing stopping you from combining both options, using an NTFS symlink to point Cygwin at a &lt;code&gt;vimfiles&lt;/code&gt; directory as &lt;code&gt;.vim&lt;/code&gt;. There's just no advantage to it over the above.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Bonus Option: Using the Cygwin Mount Table&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Symlinks work fine for this purpose, but there is another option: use the Cygwin mount table. Add something like the following to your Cygwin &lt;code&gt;/etc/fstab&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/cygdrive/c/Users/warren/vimfiles    /home/warren/.vim    ntfs    text   0 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then type &lt;code&gt;mount -a&lt;/code&gt; at a Cygwin command prompt to make the change take effect immediately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to change the user name in both paths, of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has one advantage over a symlink, which is that using a &lt;a href=&quot;https://cygwin.com/cygwin-ug-net/using.html#mount-table&quot; rel=&quot;nofollow&quot;&gt;Cygwin &lt;code&gt;text&lt;/code&gt; mount&lt;/a&gt; forces Cygwin to use and accept CRLFs in text files, which reduces the mismatch between Cygwin and native Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beware, however, that this mount option can be very troublesome in practice. For this very limited purpose, I can't see any reason to choose this option, but if you find yourself needing to maintain CRLF line endings under Cygwin, you might find better uses for text mounts than this example.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Sharing More&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Now, all of that is fine as far as it goes, but if you're going to try and merge the native Windows world with Cygwin in this way, you might want to take the next step by adding the following line to &lt;code&gt;/etc/nsswitch.conf&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;db_home: windows&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Move &lt;code&gt;/etc/passwd&lt;/code&gt; and &lt;code&gt;/etc/group&lt;/code&gt; out of the way, if you still have them, as you will if you installed Cygwin prior to 1.7.34. Then restart Cygwin, whereupon you will find that your home directory has changed from &lt;code&gt;/home/$USER&lt;/code&gt; to &lt;code&gt;c:\Users\%USERNAME%&lt;/code&gt;, a.k.a. &lt;code&gt;%USERPROFILE%&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Naturally, you will also need to move all your per-user Cygwin files over from the old Cygwin home directory to the new one after doing this.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not only does that mean your Cygwin home directory now has &lt;code&gt;Documents&lt;/code&gt;, &lt;code&gt;Downloads&lt;/code&gt;, &lt;code&gt;Pictures&lt;/code&gt;, etc. as subdirectories, it also means native Windows gVim and Cygwin Vim will look for &lt;code&gt;.vimrc&lt;/code&gt; in the same location, avoiding the need to create a symlink for it, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(As for why a native Windows build of Vim doesn't use &lt;code&gt;.vim&lt;/code&gt; as the Unix and Linux builds do, that's a pre-NT restriction on path names, preventing them from starting with a dot, because dots have semantic meaning to the FAT file system, or at least to the old &lt;code&gt;command.com&lt;/code&gt; shell. A file name beginning with a dot under that system &lt;em&gt;has&lt;/em&gt; no file name, only an extension, so it barfs if you try. Vim is old and portable enough for that to have mattered within its lifetime, so the coping strategy they chose way back then carries forward to today.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beware that you cannot combine this option with the mount table option since Cygwin will refuse to use mount points outside the Cygwin root, even if you use its &lt;code&gt;cygdrive&lt;/code&gt; mechanism. Presumably this is because mount points are handled at a lower level than &lt;code&gt;cygdrive&lt;/code&gt; within Cygwin.&lt;/p&gt;&#xA;" OwnerUserId="6852" LastEditorUserId="6852" LastEditDate="2016-07-06T01:24:36.667" LastActivityDate="2016-07-06T01:24:36.667" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8556" PostTypeId="2" ParentId="5795" CreationDate="2016-07-03T05:06:27.510" Score="2" Body="&lt;p&gt;The warning comes from indent. You may got same warning in command line from indent when feeding some incomplete source lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And check your vim's equalprg/formatprg setting if it's global or specific on certain filetype. I never tried indent on python code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my vim setting for c/cpp filetype, with indent's warning surpressed,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType c,cpp set equalprg=indent\ 2&amp;gt;/dev/null\ -gnu;true&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;2&amp;gt;/dev/null&lt;/code&gt; surpress any warning messages from indent&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;;true&lt;/code&gt; return 0(success) to make vim happy&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6243" LastEditorUserId="6243" LastEditDate="2016-07-03T05:13:55.857" LastActivityDate="2016-07-03T05:13:55.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8559" PostTypeId="1" AcceptedAnswerId="8561" CreationDate="2016-07-03T10:11:08.340" Score="5" ViewCount="925" Body="&lt;p&gt;I use four spaces for indent. I would like to replace the indentation with some UTF-8 chars.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo(bar):&#xA;    for jaffa in bar:&#xA;        print jaffa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var foo = function(bar){&#xA;    bar.forEach(function(jaffa){&#xA;        console.log(jaffa);&#xA;    });&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I want:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo(bar):&#xA;►for jaffa in bar:&#xA;►►print jaffa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var foo = function(bar){&#xA;►bar.forEach(function(jaffa){&#xA;►►console.log(jaffa);&#xA;►});&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried using conceal myself, but I couldn't come up with a pattern to match the indentation spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I accomplish changing the indentation to UTF-8 chars using vim conceal as described in the examples?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Muru gave the answer for this question. But what if I want to conceal the last 'block' of the indentation spaces differently than the ones before it? Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var foo = function(bar){&#xA;►bar.forEach(function(jaffa){&#xA;◼►console.log(jaffa);&#xA;►});&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8271" LastEditorUserId="205" LastEditDate="2016-07-03T13:10:07.657" LastActivityDate="2016-07-03T13:10:07.657" Title="Vim conceal indentation. Replace indentation spaces with utf-8 chars" Tags="|regular-expression|indentation|conceal|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8560" PostTypeId="2" ParentId="8559" CreationDate="2016-07-03T11:25:04.777" Score="5" Body="&lt;p&gt;This could be used &lt;code&gt;call matchadd('Conceal', '\s\{'.&amp;amp;ts.'\}', 10, -1, {'conceal': '►'})&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This uses the &lt;code&gt;matchadd()&lt;/code&gt; function to conceal parts of your text, which needs a 7.4.500 release or something. This has the advantage, that the &lt;code&gt;match&lt;/code&gt; functions can override syntax rules, the other way around might not be always possible.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-03T11:25:04.777" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8561" PostTypeId="2" ParentId="8559" CreationDate="2016-07-03T11:32:45.150" Score="6" Body="&lt;p&gt;With the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set conceallevel=2&#xA;syn match IndentWS '\v(^( {4}|\t)*)@&amp;lt;=( {4}|\t)' conceal cchar=▶&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NfljX.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NfljX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regex &lt;code&gt;\v(^( {4}|\t)*)@&amp;lt;=( {4}|\t)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;uses &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%0B&quot; rel=&quot;noreferrer&quot;&gt;very magic&lt;/a&gt; &lt;code&gt;\v&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;matches a sets of 4 spaces (&lt;code&gt; {4}&lt;/code&gt;) or a tab &lt;code&gt;\t&lt;/code&gt;, at the beginning of the line, &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%40%3C%3D&quot; rel=&quot;noreferrer&quot;&gt;with zero width &lt;code&gt;\@&amp;lt;=&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;and then a set of 4 spaces or a tab.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Of course, if you use only tabs or spaces, you can simplify the regex accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the update, with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set conceallevel=2&#xA;syn match IndentWS '\v^( {4}|\t)+\S@=' contains=IndentEndWS,IndentStartWS&#xA;syn match IndentStartWS '\v( {4}|\t)' conceal cchar== &#xA;syn match IndentEndWS '\v( {4}|\t)\S@=' conceal cchar=▶&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6HjiK.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6HjiK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Making ends highlight differently would need a region, or contained matches. In this case I used two contained matches, one for general  indentation whitespace, and one for indentation just before a non-whitespace character (&lt;code&gt;\S&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-07-03T13:02:33.277" LastActivityDate="2016-07-03T13:02:33.277" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8562" PostTypeId="2" ParentId="3576" CreationDate="2016-07-03T13:45:01.070" Score="2" Body="&lt;p&gt;You need to set up options&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $NVIM_TUI_ENABLE_TRUE_COLOR=1 &#xA;set termguicolors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your &lt;code&gt;.config/nvim/init.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2016-07-03T13:45:01.070" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8563" PostTypeId="1" AcceptedAnswerId="8564" CreationDate="2016-07-03T18:59:09.847" Score="6" ViewCount="5972" Body="&lt;p&gt;I put the following lines from &lt;a href=&quot;http://vim.wikia.com/wiki/Highlight_unwanted_spaces&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; into my &lt;code&gt;~/.vimrc&lt;/code&gt; to highlight trailing whitespace in red:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight ExtraWhitespace ctermbg=red guibg=red&#xA;match ExtraWhitespace /\s\+$/&#xA;autocmd BufWinEnter * match ExtraWhitespace /\s\+$/&#xA;autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@&amp;lt;!$/&#xA;autocmd InsertLeave * match ExtraWhitespace /\s\+$/&#xA;autocmd BufWinLeave * call clearmatches()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to have this be the default behavior, but be able to toggle this behavior on and off with something like &lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;. I found a code snippet from this answer that looks promising. After editing it I had something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:toggleHighlightWhitespace = 1&#xA;function! ToggleHighlightWhitespace(...)&#xA;  if a:0 == 1 &quot;toggle behaviour&#xA;    let g:toggleHighlightWhitespace = 1 - g:toggleHighlightWhitespace&#xA;  endif&#xA;&#xA;  if g:toggleHighlightWhitespace == 1 &quot;normal action, do the hi&#xA;    highlight ExtraWhitespace ctermbg=red guibg=red&#xA;    match ExtraWhitespace /\s\+$/&#xA;    autocmd BufWinEnter * match ExtraWhitespace /\s\+$/&#xA;    autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@&amp;lt;!$/&#xA;    autocmd InsertLeave * match ExtraWhitespace /\s\+$/&#xA;    autocmd BufWinLeave * call clearmatches()&#xA;  else&#xA;    call clearmatches()&#xA;  endif&#xA;endfunction&#xA;&#xA;autocmd BufWinEnter * call ToggleHighlightWhitespace()&#xA;autocmd InsertEnter * call ToggleHighlightWhitespace()&#xA;autocmd InsertLeave * call ToggleHighlightWhitespace()&#xA;autocmd BufWinLeave * call ToggleHighlightWhitespace()&#xA;nnoremap &amp;lt;leader&amp;gt;w :call ToggleHighlightWhitespace(1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With these lines, typing &lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; in normal mode gets rid of the highlighting, but as soon as I re-enter insert mode, the highlighting returns. How do I get the toggling to work? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to help from Grochmal, my final snippet from &lt;code&gt;~/.vimrc&lt;/code&gt; is shown below. I split the toggle function into a toggle function and a refresh function for clarity.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:toggleHighlightWhitespace = 1    &#xA;function! ToggleHighlightWhitespace()    &#xA;  let g:toggleHighlightWhitespace = 1 - g:toggleHighlightWhitespace     &#xA;  call RefreshHighlightWhitespace()    &#xA;endfunction    &#xA;&#xA;function! RefreshHighlightWhitespace()    &#xA;  if g:toggleHighlightWhitespace == 1 &quot; normal action, do the hi    &#xA;    highlight ExtraWhitespace ctermbg=red guibg=red    &#xA;    match ExtraWhitespace /\s\+$/    &#xA;    augroup HighLightWhitespace    &#xA;      autocmd BufWinEnter * match ExtraWhitespace /\s\+$/    &#xA;      autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@&amp;lt;!$/    &#xA;      autocmd InsertLeave * match ExtraWhitespace /\s\+$/    &#xA;      autocmd BufWinLeave * call clearmatches()    &#xA;    augroup END    &#xA;  else &quot; clear whitespace highlighting    &#xA;    call clearmatches()    &#xA;    autocmd! HighLightWhitespace BufWinEnter    &#xA;    autocmd! HighLightWhitespace InsertEnter    &#xA;    autocmd! HighLightWhitespace InsertLeave    &#xA;    autocmd! HighLightWhitespace BufWinLeave    &#xA;  endif    &#xA;endfunction    &#xA;&#xA;autocmd BufWinEnter * call RefreshHighlightWhitespace()    &#xA;autocmd BufWinLeave * call RefreshHighlightWhitespace()    &#xA;nnoremap &amp;lt;leader&amp;gt;w :call ToggleHighlightWhitespace()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5043" LastEditorUserId="5043" LastEditDate="2016-07-03T21:24:49.640" LastActivityDate="2016-07-06T12:17:44.500" Title="Toggle highlighting of trailing whitespace" Tags="|highlight|whitespace|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8564" PostTypeId="2" ParentId="8563" CreationDate="2016-07-03T19:21:36.653" Score="4" Body="&lt;h3&gt;Extraneous &lt;code&gt;autocmd&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;First, you told Vim to call your toggle function every time you enter or leave the insert mode.  i.e. by using the &lt;code&gt;InsertEnter&lt;/code&gt; and &lt;code&gt;InsertLeave&lt;/code&gt; events as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * call ToggleHighlightWhitespace()&#xA;autocmd InsertLeave * call ToggleHighlightWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Those events are &lt;strong&gt;not needed there&lt;/strong&gt;.  Therefore, kill these two lines.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Long standing &lt;code&gt;autocmd&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;On the other hand &lt;strong&gt;these events are needed in the match sections&lt;/strong&gt;, because in insert mode you might be typing at spaces at the end of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@&amp;lt;!$/&#xA;autocmd InsertLeave * match ExtraWhitespace /\s\+$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do not kill these &lt;code&gt;autocmd&lt;/code&gt;s.  But that is not all, these &lt;code&gt;autocmd&lt;/code&gt;s will trigger &lt;code&gt;match&lt;/code&gt; whether your toggle is on or off, which is not what a toggle is intended for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These &lt;code&gt;autocmd&lt;/code&gt;s need to be disabled when the toggle is off, but there is no way to disable an &lt;code&gt;autocmd&lt;/code&gt;!  You need to wrap these &lt;code&gt;autocmd&lt;/code&gt;s inside an &lt;code&gt;augroup&lt;/code&gt; so they are not &lt;em&gt;long standing&lt;/em&gt;, i.e. so they can be disabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In essence, your condition needs to looks as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if g:toggleHighlightWhitespace == 1 &quot;normal action, do the hi&#xA;  highlight ExtraWhitespace ctermbg=red guibg=red&#xA;  match ExtraWhitespace /\s\+$/&#xA;  augroup HighlightWhitespace&#xA;  autocmd BufWinEnter * match ExtraWhitespace /\s\+$/&#xA;  autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@&amp;lt;!$/&#xA;  autocmd InsertLeave * match ExtraWhitespace /\s\+$/&#xA;  autocmd BufWinLeave * call clearmatches()&#xA;  augroup END&#xA;else&#xA;  call clearmatches()   &#xA;  autocmd! HighlightWhitespace BufWinEnter&#xA;  autocmd! HighlightWhitespace InsertEnter&#xA;  autocmd! HighlightWhitespace InsertLeave&#xA;  autocmd! HighlightWhitespace BufWinLeave&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd!&lt;/code&gt; can only disable an &lt;code&gt;autocmd&lt;/code&gt; if it is named by an &lt;code&gt;augroup&lt;/code&gt; (I'm not 100% certain of this statement, but it does work well for the script at hand).&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-07-03T21:41:51.980" LastActivityDate="2016-07-03T21:41:51.980" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8565" PostTypeId="1" AcceptedAnswerId="8581" CreationDate="2016-07-03T20:04:41.820" Score="3" ViewCount="317" Body="&lt;p&gt;In Emacs, &lt;code&gt;C-o&lt;/code&gt; or &lt;code&gt;M-x open-line&lt;/code&gt; creates a blank new line under the point/cursor without moving it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;c-l&lt;/code&gt; isn't used in insert mode and I like I have the following two lines in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; C-o from emacs (open line at current point)&#xA;inoremap &amp;lt;c-o&amp;gt; &amp;lt;esc&amp;gt;&amp;lt;esc&amp;gt;mpA&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;&amp;lt;esc&amp;gt;`pa&#xA;&quot; make C-l do C-o's job&#xA;inoremap &amp;lt;c-l&amp;gt; &amp;lt;c-o&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping has a number of drawbacks&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It clobbers whatever is in the &lt;code&gt;p&lt;/code&gt; register&lt;/li&gt;&#xA;&lt;li&gt;If I use the &lt;code&gt;c-o&lt;/code&gt; binding when my cursor is at the beginning of the line, after executing &lt;code&gt;c-o&lt;/code&gt; my cursor is at position 1 instead of position 0.&lt;/li&gt;&#xA;&lt;li&gt;I have &lt;code&gt;set so=7&lt;/code&gt; so that I always see seven lines around my cursor if possible. If I'm near the bottom of this window invoking &lt;code&gt;c-o&lt;/code&gt; counts as cursor movement &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is there a way of adding a new line below the cursor without changing its position or using a register?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2016-07-05T15:50:44.257" Title="Equivalent of emacs open line C-o" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ClosedDate="2016-07-06T21:41:49.910" ContentLicense="CC BY-SA 3.0" />
  <row Id="8566" PostTypeId="1" AcceptedAnswerId="8568" CreationDate="2016-07-04T00:01:28.340" Score="11" ViewCount="1980" Body="&lt;h3&gt;Context&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I have been using Vim for more than 6 years and have compiled it from source a couple of times during that period.  Over the years my &lt;code&gt;vimrc&lt;/code&gt; did grow.  Now, I am trying to clean my &lt;code&gt;vimrc&lt;/code&gt; and I came upon a dinosaur configuration:  &lt;code&gt;has(&quot;autocmd&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I started using Vim I copied my first &lt;code&gt;vimrc&lt;/code&gt; from a colleague and it already contained a condition with a call to &lt;code&gt;has(&quot;autocmd&quot;)&lt;/code&gt;, as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;autocmd&quot;)&#xA;    &quot; ... several autocmds, most of them on the FileType event&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim (likely) can be compiled without &lt;code&gt;autocmd&lt;/code&gt; support, and, I believe, during those days it was still possible to find a Vim instance without &lt;code&gt;autocmd&lt;/code&gt; support.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Over the years some 60-70% of my &lt;code&gt;vimrc&lt;/code&gt; migrated into that &lt;code&gt;if&lt;/code&gt; block, and now that block is huge (300+ lines).  If I run a Vim without &lt;code&gt;autocmd&lt;/code&gt; support I'll lose the majority of my &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On the other hand, I believe that &lt;code&gt;has(&quot;autocmd&quot;)&lt;/code&gt; is rather irrelevant these days.  And, therefore, I want to get rid of that &lt;code&gt;if&lt;/code&gt; altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked through &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/configure.in&quot; rel=&quot;noreferrer&quot;&gt;Vim's &lt;code&gt;configure.in&lt;/code&gt;&lt;/a&gt; and there is no way to explicitly disable &lt;code&gt;autocmd&lt;/code&gt; in there.  Looking through &lt;a href=&quot;https://github.com/neovim/neovim/tree/master/cmake&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;neovim&lt;/code&gt;'s source tree&lt;/a&gt; I do not see an &lt;code&gt;Find*&lt;/code&gt; cmake for &lt;code&gt;autocmd&lt;/code&gt; either, I do not believe that &lt;code&gt;neovim&lt;/code&gt; can be compiled without &lt;code&gt;autocmd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;The Question&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Since &quot;relevance&quot; is a rather opinionated topic, let's focus on the objective points of &lt;code&gt;has(&quot;autocmd&quot;)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Under which conditions Vim can be/is compiled without &lt;code&gt;autocmd&lt;/code&gt; support?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Are there official compiled packages/distribution of Vim without &lt;code&gt;autocmd&lt;/code&gt; support?  (Maybe on embedded devices)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Both questions above but for &lt;code&gt;neovim&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="51" LastEditDate="2016-07-13T21:20:41.413" LastActivityDate="2016-07-13T21:20:41.413" Title="What is the relevance of has(&quot;autocmd&quot;) today?" Tags="|vimrc|autocmd|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8568" PostTypeId="2" ParentId="8566" CreationDate="2016-07-04T09:09:48.827" Score="10" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If you install from your package manager a Vim with the feature set tiny or small, you won't get autocommand support. &#xA;Also if you compile your own Vim and disable autocommand feature in feature.h (or used the &lt;code&gt;--with-features=small&lt;/code&gt; or &lt;code&gt;--with-features=tiny&lt;/code&gt; argument)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;depends on how you install Vim. Debian/Ubuntu provides official tiny and I think small packages. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;don't know.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In short, that line is still relevant and does not hurt.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-04T09:09:48.827" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8569" PostTypeId="1" CreationDate="2016-07-04T09:49:40.547" Score="3" ViewCount="1123" Body="&lt;p&gt;Currently I’m adding source sections manually, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*******************************************************************************&#xA; *                                entry point&#xA; ******************************************************************************/&#xA;fn main () { println!(&quot;Hello World!&quot;); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The commands required to create this particular heading is quite&#xA;long:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0a*&amp;lt;ESC&amp;gt;oentry point&amp;lt;ESC&amp;gt;:ce&amp;lt;CR&amp;gt;kYjpr $r/kk0r/jl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For languages only supporting line comments the sequence is a bit shorter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once I have an initial section, I simply copy and paste it to create all&#xA;subsequent ones, which reduces the effort to find some header, past it to&#xA;where I need it, replace the label text, and re-center it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What would be a less pedestrian way to achieve this?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sectioning should employ the current comment character settings of the Nerd&#xA;Commenter plugin. Supplying their own list would be fine too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No language specific plugins please.&lt;/p&gt;&#xA;" OwnerUserId="8282" LastEditorUserId="1841" LastEditDate="2016-07-04T12:46:43.393" LastActivityDate="2017-07-26T11:41:30.933" Title="How to conveniently add ornate headers to source code?" Tags="|vimscript|formatting|" AnswerCount="5" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="8570" PostTypeId="2" ParentId="8569" CreationDate="2016-07-04T10:34:24.677" Score="7" Body="&lt;p&gt;I actually wrote a blog post about this: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rainymood.github.io/jekyll/update/2016/06/25/vim-macro.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://rainymood.github.io/jekyll/update/2016/06/25/vim-macro.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tl;dr use a Vim Macro&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Macro used for the image below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qai###&amp;lt;Esc&amp;gt;A&amp;lt;Esc&amp;gt;&amp;lt;Space&amp;gt;###&amp;lt;Esc&amp;gt;YppkkVR#jjVR#q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0S3ta.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0S3ta.gif&quot; alt=&quot;image&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could probably do something similar&lt;/p&gt;&#xA;" OwnerUserId="5319" LastEditorUserId="205" LastEditDate="2017-03-08T14:05:20.450" LastActivityDate="2017-03-08T14:05:20.450" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8571" PostTypeId="2" ParentId="8569" CreationDate="2016-07-04T12:09:30.900" Score="8" Body="&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note 1&lt;/strong&gt; As I said in the comment this kind of box is not a good thing: it distract the eye from the important part of your file (the comment itself or the actual code). There are better way to create headers. Now this is only my opinion and this site is not here to argue about this so here is a solution.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note 2&lt;/strong&gt; I give here a solution with the plugins I know but you could probably use any snippet manager other than Ultisnips.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note 3&lt;/strong&gt; Using a snippet manager only for this snippet is probably overkill and you should probably considering creating your own vimscript function. For example, here is &lt;a href=&quot;https://vi.stackexchange.com/a/4358/1841&quot;&gt;an answer&lt;/a&gt; I made (with a &lt;strong&gt;great&lt;/strong&gt; help from @Peter Rincker) for a similar question. It uses only vimscript and creates headers a little lighter.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What you are looking for is an intelligent snippet, it is also a built-in feature of Ultisnips + vim-snippets:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, install &lt;a href=&quot;https://github.com/sirver/UltiSnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;ultisnips&lt;/a&gt; which is a snippet engine (it will allow you to work with snippets but doesn't provide the snippets themselves).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you have two ways to get the snippet you're looking for:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Method 1&lt;/strong&gt; You can install &lt;a href=&quot;https://github.com/honza/vim-snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-snippets&lt;/a&gt; which provides a whole list of predefined snippets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Method 2&lt;/strong&gt; You can declare the snippet by yourself (which is a little bit more work but is lighter since you get only the snippet you need):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First create a file &lt;code&gt;~/.vim/my-snippets/Ultisnips/all.snippets&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then in this file add this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global !p&#xA;def make_box(twidth, bwidth=None):&#xA;    b, m, e, i = (s.strip() for s in get_comment_format())&#xA;    bwidth_inner = bwidth - 3 - max(len(b), len(i + e)) if bwidth else twidth + 2&#xA;    sline = b + m + bwidth_inner * m[0] + 2 * m[0]&#xA;    nspaces = (bwidth_inner - twidth) // 2&#xA;    mlines = i + m + &quot; &quot; + &quot; &quot; * nspaces&#xA;    mlinee = &quot; &quot; + &quot; &quot;*(bwidth_inner - twidth - nspaces) + m&#xA;    eline = i + m + bwidth_inner * m[0] + 2 * m[0] + e&#xA;    return sline, mlines, mlinee, eline&#xA;&#xA;def get_comment_format():&#xA;    &quot;&quot;&quot; Returns a 4-element tuple (first_line, middle_lines, end_line, indent)&#xA;    representing the comment format for the current file.&#xA;&#xA;    It first looks at the 'commentstring', if that ends with %s, it uses that.&#xA;    Otherwise it parses '&amp;amp;comments' and prefers single character comment&#xA;    markers if there are any.&#xA;    &quot;&quot;&quot;&#xA;    commentstring = vim.eval(&quot;&amp;amp;commentstring&quot;)&#xA;    if commentstring.endswith(&quot;%s&quot;):&#xA;        c = commentstring[:-2]&#xA;        return (c, c, c, &quot;&quot;)&#xA;    comments = _parse_comments(vim.eval(&quot;&amp;amp;comments&quot;))&#xA;    for c in comments:&#xA;        if c[0] == &quot;SINGLE_CHAR&quot;:&#xA;            return c[1:]&#xA;    return comments[0][1:]&#xA;endglobal&#xA;&#xA;snippet box &quot;A nice box with the current comment symbol&quot; b&#xA;`!p&#xA;box = make_box(len(t[1]))&#xA;snip.rv = box[0]&#xA;snip += box[1]&#xA;`${1:content}`!p&#xA;box = make_box(len(t[1]))&#xA;snip.rv = box[2]&#xA;snip += box[3]`&#xA;$0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The part in the &lt;code&gt;global/endglobal&lt;/code&gt; are python helper function made to create a box and get the comment character for the buffer. The part in the &lt;code&gt;snippet/endsnippet&lt;/code&gt; is the actual snippet using the python interpolations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then independently from the method you followed, you simply have to type &lt;code&gt;box&lt;/code&gt; and then use the key you defined in your vimrc to trigger a snippet and the box will be created. You'll then enter insert mode allowing you to type the text you want to put in a box, the length of the box will be updated while you enter the text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; that I didn't create the code in this answer, it comes directly from the vim-snippets directory &lt;a href=&quot;https://github.com/honza/vim-snippets/blob/master/pythonx/vimsnippets.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://github.com/honza/vim-snippets/blob/master/UltiSnips/all.snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some interesting resources about snippets:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I asked &lt;a href=&quot;https://vi.stackexchange.com/q/7466/1841&quot;&gt;a question&lt;/a&gt; to differentiate the different snippets managers. As long as you choose snipmate compatible snippets engines, the one I gave you should work.&lt;/li&gt;&#xA;&lt;li&gt;Vimcast made &lt;a href=&quot;http://vimcasts.org/episodes/meet-ultisnips/&quot; rel=&quot;nofollow noreferrer&quot;&gt;some good episodes&lt;/a&gt; about Ultisnips.&lt;/li&gt;&#xA;&lt;li&gt;And of course &lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;the ultisnip doc&lt;/a&gt; is a good place to start.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-07-04T13:30:10.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8572" PostTypeId="5" CreationDate="2016-07-05T00:38:24.457" Score="0" Body="&lt;p&gt;Vim is compiled on &lt;em&gt;most platforms&lt;/em&gt; (&lt;code&gt;GNU/Linux&lt;/code&gt;, &lt;code&gt;*BSD&lt;/code&gt;, &lt;code&gt;Solaris&lt;/code&gt;, &lt;code&gt;AIX&lt;/code&gt;, &lt;code&gt;HP-UX&lt;/code&gt;) by executing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make  # (which runs ./configure)&#xA;make install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On Microsoft Windows it can be compiled with &lt;code&gt;Visual Studio&lt;/code&gt; (&lt;code&gt;nmake&lt;/code&gt;), &lt;code&gt;MinGW&lt;/code&gt; (&lt;code&gt;make&lt;/code&gt;/&lt;code&gt;gcc&lt;/code&gt;), &lt;code&gt;Cygwin&lt;/code&gt; or the &lt;code&gt;Borland&lt;/code&gt; compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim can also be compiled on &lt;code&gt;Amiga&lt;/code&gt; (with &lt;code&gt;make&lt;/code&gt;) and &lt;code&gt;VMS&lt;/code&gt; (with some patching).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Vim derivatives are sometimes compiled in different ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;neovim&lt;/code&gt; is compiled using &lt;code&gt;cmake&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nvi&lt;/code&gt; and &lt;code&gt;elvis&lt;/code&gt; are compiled with the classic &lt;code&gt;autoconf&lt;/code&gt; triplet: &lt;code&gt;./configure &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;macvim&lt;/code&gt; is compiled in the same fashion as Vim itself (it cloned its compilation scripts).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;At compilation time several features can be enabled or disabled.  A compiled Vim will display the features it was compiled with by running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/various.html#:version&quot; rel=&quot;nofollow&quot;&gt;:h :version&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#has()&quot; rel=&quot;nofollow&quot;&gt;:h has()&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#feature-list&quot; rel=&quot;nofollow&quot;&gt;:h feature-list&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-07-05T03:35:06.017" LastActivityDate="2016-07-05T03:35:06.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8573" PostTypeId="4" CreationDate="2016-07-05T00:38:24.457" Score="0" Body="The process of compiling Vim (or one of its derivatives) from source code.  Problems with the compilation process and features that can be enables or disabled during the compilation." OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-07-05T03:35:16.517" LastActivityDate="2016-07-05T03:35:16.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8574" PostTypeId="1" AcceptedAnswerId="8721" CreationDate="2016-07-05T09:07:32.893" Score="2" ViewCount="331" Body="&lt;p&gt;I have tried to attach to following fugitive mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; D :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gdiff')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;a &lt;code&gt;:h window-move-cursor&lt;/code&gt; mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-diff prettyprint-override&quot;&gt;&lt;code&gt;diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim&#xA;index 805518a..897295a 100644&#xA;--- a/plugin/fugitive.vim&#xA;+++ b/plugin/fugitive.vim&#xA;@@ -2552,8 +2552,8 @@ function! s:BufReadIndex() abort&#xA;     nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; cc :&amp;lt;C-U&amp;gt;Gcommit&amp;lt;CR&amp;gt;&#xA;     nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; cva :&amp;lt;C-U&amp;gt;Gcommit --amend --verbose&amp;lt;CR&amp;gt;&#xA;     nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; cvc :&amp;lt;C-U&amp;gt;Gcommit --verbose&amp;lt;CR&amp;gt;&#xA;-    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; D :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gdiff')&amp;lt;CR&amp;gt;&#xA;-    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; dd :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gdiff')&amp;lt;CR&amp;gt;&#xA;+    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; D :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gdiff')&amp;lt;Bar&amp;gt;exe &quot;normal \&amp;lt;C-w&amp;gt;P&quot;&amp;lt;CR&amp;gt;&#xA;+    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; dd :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gdiff')&amp;lt;Bar&amp;gt;exe &quot;normal \&amp;lt;C-w&amp;gt;P&quot;&amp;lt;CR&amp;gt;&#xA;     nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; dh :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gsdiff')&amp;lt;CR&amp;gt;&#xA;     nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; ds :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gsdiff')&amp;lt;CR&amp;gt;&#xA;     nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; dp :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiffEdit()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the &lt;code&gt;:h fugitive-:Gstatus&lt;/code&gt; window is a preview window which is supposed to be unique.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related issues on github are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;&lt;a href=&quot;https://github.com/tpope/vim-fugitive/issues/132&quot; rel=&quot;nofollow&quot;&gt;#132 – Easy way to move between diffs (Unimpaired-style)&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;&lt;a href=&quot;https://github.com/tpope/vim-fugitive/issues/339&quot; rel=&quot;nofollow&quot;&gt;#339 - Preview changes from Gstatus&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;&lt;a href=&quot;https://github.com/tpope/vim-fugitive/issues/476&quot; rel=&quot;nofollow&quot;&gt;#476 - Gdiff without focus change in Gstatus&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2016-07-11T09:00:19.417" LastActivityDate="2016-07-11T11:35:14.780" Title="Keep cursor in fugitive-:Gstatus window when view diffs/splits" Tags="|key-bindings|vim-windows|plugin-fugitive|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8575" PostTypeId="1" CreationDate="2016-07-05T10:12:19.930" Score="4" ViewCount="2761" Body="&lt;p&gt;I'm running NeoVim &quot;straight out of the box&quot;; after running the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config}&#xA;ln -s ~/.vim $XDG_CONFIG_HOME/nvim&#xA;ln -s ~/.vimrc $XDG_CONFIG_HOME/nvim/init.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After this transfer, the colors from &lt;code&gt;nvim&lt;/code&gt; don't match the ones for &lt;code&gt;vim&lt;/code&gt;;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know, my colors for &lt;code&gt;vim&lt;/code&gt; are &lt;em&gt;purely&lt;/em&gt; the terminal colors (which are indeed customized); it seems that &lt;code&gt;nvim&lt;/code&gt; does not fully respect those, as evidenced from the picture below. How can I made &lt;code&gt;nvim&lt;/code&gt; respect the terminal colors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In the below, Vim is on the left)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TAiWJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TAiWJ.png&quot; alt=&quot;Comparison of colors: Vim on the left, NeoVim on the right&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8293" LastEditorUserId="5229" LastEditDate="2016-07-05T17:29:57.260" LastActivityDate="2016-07-05T17:29:57.260" Title="NeoVim: default colors don't match vim's" Tags="|neovim|colorscheme|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8576" PostTypeId="2" ParentId="8569" CreationDate="2016-07-05T10:21:22.613" Score="2" Body="&lt;p&gt;I wrote a little script, to block the selected texts with customized characters. well it is not yet valid C/java comment, however it shouldn't be hard to adjust. Take a look if it helps:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/sk1418/blockit&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sk1418/blockit&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the Readme includes gif animation and introductions.&lt;/p&gt;&#xA;" OwnerUserId="1569" LastActivityDate="2016-07-05T10:21:22.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8577" PostTypeId="1" AcceptedAnswerId="8579" CreationDate="2016-07-05T12:02:11.340" Score="2" ViewCount="817" Body="&lt;p&gt;I have a file containing contents(Unicode escape string in specific) like this:   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;title=\&quot;\u5e2e\u4e0a\u5934\u6761\&quot;&amp;gt;\u5e2e\u4e0a\u5934\u6761&amp;lt;\/a&amp;gt;&amp;lt;\/li&amp;gt;\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my working Vim window and want to show it as Chinese. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the output of the locale command in my terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LANG=en_US.UTF•8&#xA;LANGUAGE=en&#xA;LC_CTYPE=en_US.UTF•8&#xA;LC_NUMERIC=en_US.UTF•8&#xA;LC_TIME=en_US.UTF•8&#xA;LC_COLLATE=“en_US.UTF-8”&#xA;LC_MONETARY=en_US.UTF•8&#xA;LC_MESSAGES=“en_US.UTF-8”&#xA;LC_PAPER=en_US.UTF•8&#xA;LC_NAME=en_US.UTF•8&#xA;LC_ADDRESS=en_US.UTF•8&#xA;LC_TELEPHONE=en_US.UTF•8&#xA;LC_MEASUREMENT=en_US.UTF•8&#xA;LC_IDENTIFICATION=en_US.UTF•8&#xA;LC_ALL=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the OS I use is Ubuntu 14.04. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can print the Chinese characters using Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print u&quot;\u5e2e\u4e0a\u5934\u6761&quot;.encode('utf-8')&#xA;# encode the unicode string to utf-8 string which matches the terminal encoding. &#xA;# If I write the result to a file I can see Chinese characters if I open it by vim. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way for me to make vim to show the Chinese characters? Can I do this using vimscript inside vim with a toggle to switch between these two encoding systems if possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aware that I can realize the function with the thoughts above I want to know if there is existing scripts, which will prevent me recreating wheals. &lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="1788" LastEditDate="2018-08-23T03:15:55.187" LastActivityDate="2018-08-23T03:15:55.187" Title="Can I change the encoding of the content of a file to show Chinese characters?" Tags="|encoding|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8578" PostTypeId="1" AcceptedAnswerId="8583" CreationDate="2016-07-05T12:31:21.640" Score="2" ViewCount="147" Body="&lt;p&gt;Take any long comment in paragraph form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1 // This is a comment that is really long because it is describing something&#xA;  2 // worth being verbose about, possibly at the beginning of the program (like a&#xA;  3 // preamble).  It is desirable to keep the width limited to 80-characters,&#xA;  4 // conveniently done by typing the whole comment out on one line, selecting&#xA;  5 // with SHIFT+V and executing gq.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As mentioned, the paragraph is made to span several lines with Vim's &lt;code&gt;gq&lt;/code&gt; so the width doesn't run off the edge of certain UI's (such as the StackExchange code block).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: &lt;strong&gt;how can the paragraph-comment be edited in Vim?&lt;/strong&gt;  I have been:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Deleting the comment slashes with &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;selecting the text with &lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;joining with &lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;editing and using &lt;code&gt;gq&lt;/code&gt; to join them again.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is there a better (i.e., faster, built-in) way to do this?&lt;/p&gt;&#xA;" OwnerUserId="3209" LastActivityDate="2016-07-05T16:29:04.517" Title="Edit width-limited comment blocks faster" Tags="|comments|visual-block|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8579" PostTypeId="2" ParentId="8577" CreationDate="2016-07-05T13:19:32.883" Score="5" Body="&lt;p&gt;You could use something like this to convert to Unicode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\%(\\u\x\+\)\+/\=eval('&quot;'.submatch(0).'&quot;')/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And back:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/[^\x00-\x7f]/\=printf('\u%x', char2nr(submatch(0)))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a naive toggle command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:toggle_unicode(line1, line2) abort&#xA;  if search('\\u\x\+', 'n')&#xA;    execute a:line1.','.a:line2.'s/\%(\\u\x\+\)\+/\=eval(''&quot;''.submatch(0).''&quot;'')/g'&#xA;  else&#xA;    execute a:line1.','.a:line2.'s/[^\x00-\x7f]/\=printf(''\u%x'', char2nr(submatch(0)))/g'&#xA;  endif&#xA;endfunction&#xA;&#xA;command! -range=% UnicodeToggle call s:toggle_unicode(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-07-05T13:19:32.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8580" PostTypeId="1" CreationDate="2016-07-05T13:58:49.150" Score="1" ViewCount="300" Body="&lt;p&gt;I have &lt;code&gt;airline&lt;/code&gt; plugin installed with pathogen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It displays &lt;code&gt;&amp;lt;bf&amp;gt;&amp;lt;bf&amp;gt;&lt;/code&gt; etc instead of showing normal characters. If I source my &lt;code&gt;_vimrc&lt;/code&gt;, &lt;code&gt;airline&lt;/code&gt; displays everything normally. I sometimes have to source twice. It used to work with no problems but recently I uninstalled Vim then installed a 64bit version (unofficial) and then uninstalled the latter and reinstalled vim74 32bit version (windows).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my &lt;code&gt;_vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set maxcombine=6  &#xA;set autochdir&#xA;set backspace=2&#xA;set encoding=utf-8&#xA;set guifont=Hack:h9&#xA;set shiftwidth=3&#xA;set smartcase&#xA;set autoindent&#xA;set cindent&#xA;set smartindent &#xA;set number numberwidth=4 relativenumber&#xA;set noerrorbells&#xA;set hlsearch&#xA;set hidden&#xA;set nobackup&#xA;set history=1000&#xA;set noswapfile&#xA;set guioptions-=T&#xA;set guitablabel=%t&#xA;set laststatus=2&#xA;set tabstop=3&#xA;set background=light&#xA;&#xA;&#xA;hi Search guifg=red guibg=yellow &#xA;&#xA;execute pathogen#infect()&#xA;&#xA;syntax on&#xA;filetype on&#xA;filetype plugin on&#xA;filetype indent on&#xA;&#xA;colorscheme solarized &#xA;&#xA;let g:solarized_italic=0&#xA;let g:solarized_bold=0&#xA;let g:solarized_contrast=&quot;normal&quot;&#xA;&#xA;let g:airline_powerline_font=1&#xA;if !exists('g:airline_symbols')&#xA;    let g:airline_symbols = {}&#xA;endif&#xA;&#xA; &quot;airline symbols&#xA;let g:airline_left_sep = ''&#xA;let g:airline_left_alt_sep = ''&#xA;let g:airline_right_sep = ''&#xA;let g:airline_right_alt_sep = ''&#xA;let g:airline_symbols.branch = ''&#xA;let g:airline_symbols.readonly = ''&#xA;let g:airline_symbols.linenr = ''&#xA;&#xA;&#xA;autocmd BufNewFile,BufReadPost *.c,*.cpp,*.h,*.cxx,*.hpp,*.C,*.cc,*.cp,*.H,*.hxx set filetype=cpp nowrap&#xA;autocmd BufNewFile,BufReadPost *.java set filetype=java nowrap&#xA;autocmd BufNewFile,BufReadPost *.html,*.html,*.htm5,*.html5 set filetype=html nowrap&#xA;autocmd BufNewFile,BufReadPost *.mysql,*.sql  set filetype=mysql nowrap&#xA;&#xA;inoremap &amp;lt;c-u&amp;gt; &amp;lt;esc&amp;gt;viwU&amp;lt;esc&amp;gt;i&#xA;nnoremap - ddp&#xA;nnoremap &amp;lt;leader&amp;gt;ev :edit $MYVIMRC&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;sv :source $MYVIMRC&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;p &quot;+p&#xA;nnoremap &amp;lt;leader&amp;gt;sd :nohl&amp;lt;cr&amp;gt;:nohl&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;u kA&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;[ &amp;lt;c-w&amp;gt;W&#xA;nnoremap &amp;lt;leader&amp;gt;] &amp;lt;c-w&amp;gt;w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using the following plugins with pathogen:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;autocomplpop&lt;/li&gt;&#xA;&lt;li&gt;nerdtree&lt;/li&gt;&#xA;&lt;li&gt;nerdcommenter&lt;/li&gt;&#xA;&lt;li&gt;vim-airline&lt;/li&gt;&#xA;&lt;li&gt;vim-airline-themes&lt;/li&gt;&#xA;&lt;li&gt;vim-colors-solarized&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For better understanding my problem, here are some screenshots:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before sourcing &lt;code&gt;_vimrc&lt;/code&gt;:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/DuNby.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DuNby.png&quot; alt=&quot;Before...&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After sourcing &lt;code&gt;_vimrc&lt;/code&gt;:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/QvOj6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QvOj6.png&quot; alt=&quot;After...&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;New stuff:&#xA;An extremely weird thing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;moving &lt;code&gt;colorscheme solarized&lt;/code&gt; below &lt;code&gt;let g:&lt;/code&gt; etc makes sourcing &lt;code&gt;_vimrc&lt;/code&gt; &lt;em&gt;once&lt;/em&gt; enough to display &lt;code&gt;airline&lt;/code&gt; correctly. Before that I used to source twice.&lt;/p&gt;&#xA;" OwnerUserId="8295" LastEditorUserId="205" LastEditDate="2017-03-08T14:21:51.647" LastActivityDate="2017-03-08T14:21:51.647" Title="Airline does not display correctly unless I source _vimrc" Tags="|vimrc|plugin-airline|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8581" PostTypeId="2" ParentId="8565" CreationDate="2016-07-05T15:50:44.257" Score="1" Body="&lt;p&gt;You could also try a vimscript function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function NewLine()&#xA;    let l:position = getcurpos()&#xA;    normal o&#xA;    call cursor(l:position[1], l:position[2])&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can then map it to  with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;c-l&amp;gt; &amp;lt;c-o&amp;gt;:call NewLine()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2757" LastActivityDate="2016-07-05T15:50:44.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8582" PostTypeId="2" ParentId="8569" CreationDate="2016-07-05T16:00:47.357" Score="0" Body="&lt;p&gt;Came up with my own script: &lt;a href=&quot;https://gist.github.com/anonymous/7878a79fccc74bbc00db6cf0c330c23f&quot; rel=&quot;nofollow&quot;&gt;https://gist.github.com/anonymous/7878a79fccc74bbc00db6cf0c330c23f&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It parses &lt;code&gt;&amp;amp;comments&lt;/code&gt; to generate a formatted block&#xA;with separators expanded to &lt;code&gt;&amp;amp;textwidth&lt;/code&gt;. By default,&#xA;Leaderh inserts the block while&#xA;in insert and normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;comments&lt;/code&gt; is a bit weird to process, the script&#xA;will output garbage for certain values. But it’s been&#xA;tweaked enough to work for the ones that matter to me&#xA;personally.&lt;/p&gt;&#xA;" OwnerUserId="8282" LastActivityDate="2016-07-05T16:00:47.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8583" PostTypeId="2" ParentId="8578" CreationDate="2016-07-05T16:29:04.517" Score="2" Body="&lt;p&gt;Why not just use a macro or a mapping? Here's what I whipped up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;u {j&amp;lt;C-v&amp;gt;}k^ldgvVJ0i//&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Think of leader+u as &quot;(U)format&quot;. Of course, you can choose different keys if you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how it works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{j&amp;lt;C-v&amp;gt;                    &quot;Start a visual block at the top of the paragraph&#xA;       }k^l                &quot;Move to the end of the paragraph, to select all the '//'&#xA;           d               &quot;Delete it&#xA;            gvV            &quot;Reselect the whole paragraph&#xA;               J           &quot;And join it&#xA;                0i//&amp;lt;esc&amp;gt;  &quot;Add a comment back in.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is essentially the same process as you described, but easier and faster. Best part of this method? It's faster &lt;em&gt;and&lt;/em&gt; builtin. =)&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-05T16:29:04.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8584" PostTypeId="2" ParentId="8580" CreationDate="2016-07-05T16:43:33.913" Score="-1" Body="&lt;p&gt;I fixed the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add this to your &lt;code&gt;_vimrc&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;scriptencoding utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8295" LastEditorUserId="2920" LastEditDate="2016-07-05T17:06:15.840" LastActivityDate="2016-07-05T17:06:15.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8585" PostTypeId="2" ParentId="8575" CreationDate="2016-07-05T17:28:15.297" Score="3" Body="&lt;p&gt;Posting an answer because a comment would be too long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neovim doesn't allow you to set &lt;code&gt;t_Co&lt;/code&gt;.  It detects your terminal's color capabilities using &lt;a href=&quot;https://github.com/mauke/unibilium&quot; rel=&quot;nofollow noreferrer&quot;&gt;unibilium&lt;/a&gt; and sets &lt;code&gt;t_Co&lt;/code&gt; accordingly.  The color difference you're seeing is because Vim was using an 8 or 16 color palette.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;colortest.vim&lt;/code&gt; uses named colors.  &lt;code&gt;brown&lt;/code&gt; in a 256 color palette will use the color index &lt;code&gt;130&lt;/code&gt; while &amp;lt;16 color palette will use &lt;code&gt;3&lt;/code&gt;.  &lt;code&gt;3&lt;/code&gt; is &lt;code&gt;yellow&lt;/code&gt; in the base palette.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to go back to the color scheme you had before, you will need to change the highlight colors to use numeric values less than 16.  But, you may want to just find their 256 color index equivalents and set your terminal's base palette back to colors that match their names: black, red, green, yellow, blue, magenta, cyan, and white.  Programs expect these colors to somewhat match the name so they can at least try to ensure that text is legible on colored backgrounds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you adjust your theme to use the 256 palette, you could set Vim's &lt;code&gt;t_Co&lt;/code&gt; to 256 for consistency with Neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a couple sites that can help with color scheming if you want to go that route:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://terminal.sexy/&quot; rel=&quot;nofollow noreferrer&quot;&gt;terminal.sexy&lt;/a&gt; - Helps preview the base 16 color palette.  It has a lot of existing themes and can export your colors for specific terminals.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://bytefluent.com/vivify/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vivify&lt;/a&gt; - Create and preview vim color schemes.  This also has a lot of themes.  You can customize them by clicking on text to set syntax group colors.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://chriskempson.github.io/base16/&quot; rel=&quot;nofollow noreferrer&quot;&gt;base16&lt;/a&gt; - Pre-made color schemes for various editors and terminals.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Your color scheme looks fairly close to the base16 &quot;railscast&quot; colors, which you could use as a starting point for customization:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lQrMy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lQrMy.png&quot; alt=&quot;railscast&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-07-05T17:28:15.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8586" PostTypeId="1" AcceptedAnswerId="8588" CreationDate="2016-07-05T17:34:57.427" Score="0" ViewCount="1973" Body="&lt;p&gt;How would I yank all the function names in a file?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For example in C, you might want to take all your function definitions in &lt;code&gt;foo.c&lt;/code&gt;, and grab them for declarations in your header file &lt;code&gt;foo.h&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void hello(int a) {&#xA;  ...&#xA;}&#xA;void hello2(char b) {&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void hello(int a);&#xA;void hello2(char b);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In Python, you might want to export your functions declared in a module &lt;code&gt;foo/foo.py&lt;/code&gt; by importing all of them in &lt;code&gt;foo/__init__.py&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def hello(a):&#xA;    ...&#xA;def hello2(b):&#xA;    ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from foo import hello, hello2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2786" LastActivityDate="2016-07-05T18:10:14.687" Title="Yank all function names in a file" Tags="|regular-expression|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8587" PostTypeId="2" ParentId="8574" CreationDate="2016-07-05T17:57:53.877" Score="2" Body="&lt;p&gt;Here is what I came up with to put in your &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;augroup vimrc_fugitive_status&#xA;  autocmd!&#xA;  autocmd BufEnter index if get(b:, 'fugitive_type') == 'index' | call &amp;lt;SID&amp;gt;fugitive_status_mappings() | endif&#xA;augroup END&#xA;&#xA;function! s:fugitive_status_mappings()&#xA;  if get(b:, 'status_mappings', 0) == 0&#xA;    call s:map_with_preview('dd', 'n')&#xA;    call s:map_with_preview('D', 'n')&#xA;  endif&#xA;  let b:status_mappings = 1&#xA;endfunction&#xA;&#xA;function! s:map_with_preview(map, mode)&#xA;  call s:update_maping(a:map, a:mode, 'v:val . &quot;:call &amp;lt;SID&amp;gt;focus_preview()\&amp;lt;cr&amp;gt;&quot;') &#xA;endfunction&#xA;&#xA;function! s:focus_preview()&#xA;  call feedkeys(&quot;\&amp;lt;c-w&amp;gt;P&quot;)&#xA;endfunction&#xA;&#xA;function! s:update_maping(map, mode, expr)&#xA;  let map = maparg(a:map, a:mode, 0, 1)&#xA;  execute a:mode .&#xA;        \ (map.noremap ? 'noremap ' : 'map ') .&#xA;        \ (map.buffer ? '&amp;lt;buffer&amp;gt; ' : '') .&#xA;        \ (map.silent ? '&amp;lt;silent&amp;gt; ' : '') .&#xA;        \ (map.expr ? '&amp;lt;expr&amp;gt; ' : '') .&#xA;        \ (map.nowait ? '&amp;lt;nowait&amp;gt; ' : '') .&#xA;        \ map.lhs . ' ' .&#xA;        \ map([substitute(map.rhs, '&amp;lt;SID&amp;gt;', '&amp;lt;SNR&amp;gt;' . map.sid. '_', 'g')], a:expr)[0]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The basic idea is to capture the old mapping with &lt;code&gt;maparg()&lt;/code&gt; and then issue &lt;code&gt;&amp;lt;c-w&amp;gt;P&lt;/code&gt; with &lt;code&gt;feedkeys()&lt;/code&gt; after executing the old mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a non-trivial solution due to the following issues:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Fugitive does not supply &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mappings for the status window mappings so we must use &lt;code&gt;maparg()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Due to the way the &lt;code&gt;autocmd&lt;/code&gt;'s fire we must use an event like &lt;code&gt;BufEnter&lt;/code&gt; in lieu of the &lt;code&gt;FileType&lt;/code&gt; event&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;feedkeys()&lt;/code&gt; is tricky inside mappings due to proper escaping so use function call instead&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There may very well be a more concise and/or better solution to altering &lt;code&gt;:Gstatus&lt;/code&gt; mappings, but I am unsure how to properly do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To add more mappings simply add more lines like so to &lt;code&gt;s:fugitve_status_mappings&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call s:map_with_preview('ds', 'n')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2016-07-07T16:28:35.287" LastActivityDate="2016-07-07T16:28:35.287" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8588" PostTypeId="2" ParentId="8586" CreationDate="2016-07-05T18:10:14.687" Score="4" Body="&lt;p&gt;Well first, you need to be more clear about what exactly you expect a function to look like. For example, you could say a C function looks like &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A word at the beginning of a line, followed by whitespace, followed by one more word, followed by any number of spaces, followed by a parenthesis. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, this could definitely have some false positives. For example, this is &lt;em&gt;clearly&lt;/em&gt; not a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;this is_not_a_function(but it looks like one);&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might change this so that the line must end with an opening bracket. But that will not match&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int foo() { //Foo is a function!&#xA;...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you might say there must be an opening bracket &lt;em&gt;somewhere&lt;/em&gt;. But that will have a false positive, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int foo; //Haha, broke your regex() {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it will not match this valid function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int foo()&#xA;{&#xA;...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it will be very hard to make a foolproof regex that &lt;em&gt;only&lt;/em&gt; matches functions, and matches &lt;em&gt;every&lt;/em&gt; function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regardless, here's a start. You will probably have to modify this to make it match your data better, but I can at least put you on the right track.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=&quot;&quot;&#xA;:g/\v^(&amp;lt;\w+&amp;gt;\s*){2}\(/normal &quot;AY&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, clear out register &quot;a&quot; with &lt;code&gt;:let @a=&quot;&quot;&lt;/code&gt;. Then, we can use the &lt;code&gt;:g&lt;/code&gt; command to yank every line that matches our regex, and append it to register &lt;code&gt;&quot;a&lt;/code&gt;. (Capital A means append to the register, rather than overwrite). This is the regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v^(&amp;lt;\w+&amp;gt;\s*){2}\(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\v&lt;/code&gt; means &quot;magic&quot;. This just makes the regex shorter. Without it, we would have to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^\(\&amp;lt;\w\+\&amp;gt;\s*\)\{2}(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then we have &lt;code&gt;(&amp;lt;\w+&amp;gt;\s*)&lt;/code&gt; which means a word, then any amount of whitespace. Then &lt;code&gt;{2}&lt;/code&gt;, which means two of the previous atom. Then &lt;code&gt;\(&lt;/code&gt; which is a literal left parenthesis. Since we have &lt;code&gt;^&lt;/code&gt; at the beginning, this will only match if it's at the beginning of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The python regex is much simpler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/def[^#]*:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is &quot;def&quot;, followed by any number of non &quot;#&quot; characters, followed by a colon.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-05T18:10:14.687" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8589" PostTypeId="1" AcceptedAnswerId="8590" CreationDate="2016-07-05T19:28:49.727" Score="6" ViewCount="3646" Body="&lt;p&gt;Im trying to increase my efficiency at moving between buffers, and the Ctrl-w-(hjkl) movement doesn't work for me. How can I remap Ctrl-(hjkl) to the Ctrl-w version? I have already tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-j&amp;gt; &amp;lt;C-wj&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that doesnt work.&lt;/p&gt;&#xA;" OwnerUserId="8302" LastEditorUserId="8302" LastEditDate="2016-07-05T19:43:20.073" LastActivityDate="2016-07-05T19:43:20.073" Title="Remapping Ctrl-(h j k l) to move between windows" Tags="|vimrc|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8590" PostTypeId="2" ParentId="8589" CreationDate="2016-07-05T19:30:44.340" Score="8" Body="&lt;p&gt;You almost had it. Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C-h&amp;gt; &amp;lt;C-w&amp;gt;h&#xA;noremap &amp;lt;C-j&amp;gt; &amp;lt;C-w&amp;gt;j&#xA;noremap &amp;lt;C-k&amp;gt; &amp;lt;C-w&amp;gt;k&#xA;noremap &amp;lt;C-l&amp;gt; &amp;lt;C-w&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also add the &lt;code&gt;inoremap&lt;/code&gt; if you want it to work from insert mode.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-07-05T19:30:44.340" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8591" PostTypeId="1" AcceptedAnswerId="8592" CreationDate="2016-07-05T20:34:49.717" Score="1" ViewCount="332" Body="&lt;p&gt;When I open my private spellfile &lt;code&gt;en.utf-8.add&lt;/code&gt;, words containing&#xA;unusual characters, such as pœësis, are rendered incorrectly;&#xA;in this case, pÅÃ«sis.  At the bottom of the screen it says&#xA;&lt;code&gt;[converted]&lt;/code&gt;, and &lt;code&gt;:set&lt;/code&gt; shows that the fileencoding is latin1.&#xA;What is happening here and how can I have vim render such words&#xA;correctly?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastActivityDate="2016-07-05T21:11:30.513" Title="Encoding of the spellfile en.utf-8.add" Tags="|encoding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8592" PostTypeId="2" ParentId="8591" CreationDate="2016-07-05T21:11:30.513" Score="4" Body="&lt;p&gt;Try reopening the file and forcing it to load in &quot;utf-8&quot; mode. You can do this with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e! ++enc=utf-8 %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help ++opt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *++opt* *[++opt]*&#xA;The [++opt] argument can be used to force the value of 'fileformat',&#xA;'fileencoding' or 'binary' to a value for one command, and to specify the&#xA;behavior for bad characters.  The form is: &amp;gt;&#xA;    ++{optname}&#xA;Or: &amp;gt;&#xA;    ++{optname}={value}&#xA;&#xA;Where {optname} is one of:      *++ff* *++enc* *++bin* *++nobin* *++edit*&#xA;    ff     or  fileformat   overrides 'fileformat'&#xA;    enc    or  encoding     overrides 'fileencoding'&#xA;    bin    or  binary       sets 'binary'&#xA;    nobin  or  nobinary     resets 'binary'&#xA;    bad             specifies behavior for bad characters&#xA;    edit            for |:read| only: keep option values as if editing&#xA;                a file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would also recommend adding&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=utf8&#xA;set fenc=utf8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your &lt;code&gt;.vimrc&lt;/code&gt; if you have not already done so.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-05T21:11:30.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8593" PostTypeId="1" CreationDate="2016-07-05T22:03:35.267" Score="2" ViewCount="63" Body="&lt;p&gt;Let's say I have a line of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(1, 100):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My cursor is on the &lt;code&gt;f&lt;/code&gt; in &lt;code&gt;for&lt;/code&gt;, and I want to delete the text inside the parenthesis. In other words, I want my line to look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range():&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where my cursor is on the second parenthesis. My initial instinct, after reading &lt;a href=&quot;https://danielmiessler.com/study/vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this post&lt;/a&gt;, was to type &lt;code&gt;di(&lt;/code&gt; (see &quot;A text object reference&quot;). However, this does nothing. &#xA;I also tried &lt;code&gt;dib&lt;/code&gt; as suggested by &lt;a href=&quot;https://stackoverflow.com/questions/405415/can-you-grab-or-delete-between-parentheses-in-vi-vim&quot;&gt;this post&lt;/a&gt; (see second answer), but again, nothing happened. What should I do to delete the text between the two parentheses?&lt;br&gt;&#xA;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="5923" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-07-05T22:03:35.267" Title="Command to delete inside parentheses doesn't work" Tags="|cut-copy-paste|" AnswerCount="0" CommentCount="2" ClosedDate="2016-07-06T01:04:58.390" ContentLicense="CC BY-SA 3.0" />
  <row Id="8594" PostTypeId="2" ParentId="8313" CreationDate="2016-07-06T06:29:16.293" Score="0" Body="&lt;p&gt;There is absolutely nothing wrong with remapping keys.  Though, I discourage doing it simply to match the feel of another editor.  If you're going to override what a built-in key does, you should at least be sure that you won't miss it.  You can see what's built in with &lt;code&gt;:h normal-index&lt;/code&gt;, &lt;code&gt;:h insert-index&lt;/code&gt;, and &lt;code&gt;:h visual-index&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal and visual mode, it's usually best to use &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;localleader&amp;gt;&lt;/code&gt; if you want custom key mappings.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;isn't the idea of &quot;normal mode&quot; just switching Read Only Mode on and off&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;normal mode&lt;/code&gt; is not a readonly mode.  It's a &lt;em&gt;context&lt;/em&gt; where you're not directly inserting text.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In fact, why even have Normal Mode?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Think of how you use a GUI text editor with a mouse.  If you're typing, both hands are on the keyboard and all fingers are dedicated to &lt;em&gt;inserting&lt;/em&gt; text.  This is &lt;code&gt;insert mode&lt;/code&gt;.  But, when you want to move the cursor or select text, you remove one hand to operate the mouse or hold down a modifier key.  Since all of your fingers aren't dedicated to inserting text, you are no longer in &quot;insert mode&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using the mouse to access the editor's menus or are using one hand to hold a modifier key, you could think of that as doing &lt;code&gt;normal mode&lt;/code&gt; operations.  Selecting text would be &lt;code&gt;visual mode&lt;/code&gt; until you clear the selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's &lt;code&gt;normal mode&lt;/code&gt; is how you get things done without a mouse.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-07-06T06:29:16.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8595" PostTypeId="1" CreationDate="2016-07-06T07:16:22.850" Score="2" ViewCount="554" Body="&lt;p&gt;I have this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;755 :silent !chmod 755 %&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I trigger the mapping in a buffer that displays a file with a permission other than 755, it prints the message&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;W16 &quot;Warning: Mode of file &quot;...&quot; has changed since editing started&quot; &#xA;See &quot;:help W16&quot; for more info&#xA;[O]k, (L)oad File&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to proceed with editing, I have to acknowledge this message. Is there a way to prevent this message in my mapping.&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2016-07-06T07:37:15.013" Title="How do I prevent W16 &quot;Warning: Mode of file &quot;...&quot; has changed since editing started&quot;" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8596" PostTypeId="1" AcceptedAnswerId="8598" CreationDate="2016-07-06T07:30:24.260" Score="1" ViewCount="598" Body="&lt;p&gt;Is there a way to know which installed Vim/Neovim plugin sets a specified variable?&#xA;For example, I use Neovim 1.5-dev with the following plugins installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;morhetz/gruvbox&#xA;tomasr/molokai&#xA;mhartington/oceanic-next&#xA;ryanoasis/vim-devicons&#xA;vim-airline/vim-airline&#xA;Yggdroot/indentLine&#xA;chrisbra/Colorizer&#xA;tpope/vim-commentary&#xA;tpope/vim-repeat&#xA;tpope/vim-surround&#xA;tpope/vim-unimpaired&#xA;tpope/vim-fugitive&#xA;tpope/vim-vinegar&#xA;godlygeek/tabular&#xA;junegunn/fzf&#xA;junegunn/fzf.vim&#xA;majutsushi/tagbar&#xA;Shougo/deoplete.nvim&#xA;carlitux/deoplete-ternjs&#xA;Raimondi/delimitMate&#xA;mattn/emmet-vim&#xA;ludovicchabant/vim-gutentags&#xA;neomake/neomake&#xA;andreshazard/vim-freemarker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is that when I open a Json file I cannot see double quotes characters. I set in my &lt;em&gt;init.vim&lt;/em&gt; &lt;code&gt;set conceallevel=0&lt;/code&gt;, but this is overwritten by some plugin to &lt;code&gt;conceallevel=2&lt;/code&gt; and I would like to know which plugin overwrite this setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Opening a Json file in Neovim with &lt;code&gt;nvim -u NONE&lt;/code&gt; I can see double quotes, so it has to be a plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="1765" LastActivityDate="2016-07-06T07:42:30.783" Title="Get which plugin sets a specified variable?" Tags="|neovim|conceal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8597" PostTypeId="2" ParentId="8595" CreationDate="2016-07-06T07:37:15.013" Score="2" Body="&lt;p&gt;You can use &quot;autoread&quot;. From &lt;code&gt;:help autoread&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                 *'autoread'* *'ar'* *'noautoread'* *'noar'*&#xA;'autoread' 'ar'     boolean (default off)&#xA;            global or local to buffer |global-local|&#xA;            {not in Vi}&#xA;    When a file has been detected to have been changed outside of Vim and&#xA;    it has not been changed inside of Vim, automatically read it again.&#xA;    When the file has been deleted this is not done.  |timestamp|&#xA;    If this option has a local value, use this command to switch back to&#xA;    using the global value: &amp;gt;&#xA;        :set autoread&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've used this for when a file has been edited outside of vim. I just tested it, and it also works for when a file's mode has been changed. It's a slightly different use-case, but hey, it works!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to add &lt;code&gt;:w&lt;/code&gt; to the beginning, to guarantee that it will actually reload. Otherwise, you'll get different errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did run into a weird problem when I tested it. It might just be my terminal+window manager setup, so you may or may not have this too. Vim would refuse to update after doing this. To fix this, you can add &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; to the end of your mapping. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting this all together, the remapping should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;755 :w | silent !chmod 755 %&amp;lt;CR&amp;gt;&amp;lt;C-l&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-06T07:37:15.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8598" PostTypeId="2" ParentId="8596" CreationDate="2016-07-06T07:42:30.783" Score="10" Body="&lt;p&gt;You can use &lt;code&gt;:help :verbose&lt;/code&gt; to inspect the value of an option (they are &quot;options&quot;, not &quot;variables&quot;) &lt;em&gt;and&lt;/em&gt; see where it was last defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set conceallevel?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you must use the question mark to inspect boolean options while it doesn't change anything for other types so… stay safe, always use the question mark.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-07-06T07:42:30.783" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8600" PostTypeId="2" ParentId="8569" CreationDate="2016-07-06T08:54:51.600" Score="4" Body="&lt;h1&gt;&lt;code&gt;!!boxes&lt;/code&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Another solution is filtering the line through the command line tool &lt;a href=&quot;http://boxes.thomasjensen.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;(ascii-)&lt;code&gt;boxes&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!!boxes -s 72 -d c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or use visual selection&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;!boxes -s 72 -d c &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;-s 72&lt;/code&gt; size of box&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-d c&lt;/code&gt; select box type (design); here the c box; to see box designs run &lt;code&gt;$ boxes -l&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;boxes&lt;/code&gt; can be installed via homebrew/linuxbrew and linux distro packages, e.g. debian (&lt;a href=&quot;https://packages.debian.org/jessie/boxes&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://packages.debian.org/jessie/boxes&lt;/a&gt;) and ubuntu (&lt;a href=&quot;http://packages.ubuntu.com/yakkety/boxes&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://packages.ubuntu.com/yakkety/boxes&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;&lt;br&gt;&#xA;However, I agree boxes can reduce code readability. Use them wisely.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2017-07-26T11:41:30.933" LastActivityDate="2017-07-26T11:41:30.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8601" PostTypeId="2" ParentId="8563" CreationDate="2016-07-06T12:17:44.500" Score="3" Body="&lt;p&gt;Take into account that vim already includes this highlight functionality. The options &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27list%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;'list'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27listchars%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;'listchars&lt;/code&gt;'&lt;/a&gt; can be used for that purpose by adding the following lines to vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list&#xA;set listchars=trail:*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="599" LastActivityDate="2016-07-06T12:17:44.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8602" PostTypeId="1" AcceptedAnswerId="8606" CreationDate="2016-07-06T12:35:44.257" Score="3" ViewCount="1171" Body="&lt;p&gt;99% of the time when I am opening a diff (using the &lt;code&gt;:diffsplit&lt;/code&gt; command), it's because I want to reference some code, but still edit the file I started in. However, whenever you open a diff with diffsplit, the new file gets focus. I'd like to make vim automatically switch back (Or not switch in the first place if that's an option). I didn't see anything about it in &lt;code&gt;diffopt&lt;/code&gt; so I tried an autocmd to accomplish this but to no avail:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FilterWritePost * if(&amp;amp;diff) | wincmd w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-07-22T18:07:43.437" LastActivityDate="2016-07-23T16:22:11.763" Title="Make vim switch to other window after opening a diff" Tags="|autocmd|vimdiff|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8603" PostTypeId="1" AcceptedAnswerId="8604" CreationDate="2016-07-06T13:21:22.673" Score="10" ViewCount="10967" Body="&lt;p&gt;I was just exploring the control key in vim (to make myself more familiar with vim overall) and I don't quite get what exactly happens when I press &amp;lt;ctrl-h&amp;gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when I used &amp;lt;ctrl-h&amp;gt; in my (modded) vim, it just goes one to the left, &lt;strong&gt;but&lt;/strong&gt;, when I'm at the first column of a line, it will go to the previous line instead. Now this functionality would be immensely useful in scripting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when I use an unmodded vim (with &lt;code&gt;vim -u NONE&lt;/code&gt;), it basically is , i.e. it doesn't do the line changing thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help ctrl-h&lt;/code&gt; doesn't help me at all, as it talks about netrw, which is nice to know, but I'm interested in the normal mode shortcut.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What settings changed the &amp;lt;ctrl-h&amp;gt; key in my modded vim?&lt;/li&gt;&#xA;&lt;li&gt;Is there something that does the opposite of &amp;lt;ctrl-h&amp;gt;, i.e. it goes to the right and if it's in the last column, it skips to the next line (if there is one)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="6489" LastEditDate="2016-07-06T13:41:53.327" LastActivityDate="2016-07-06T13:42:12.597" Title="What does &lt;ctrl-h&gt; do?" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8604" PostTypeId="2" ParentId="8603" CreationDate="2016-07-06T13:26:47.373" Score="14" Body="&lt;p&gt;It's usually interpreted as a back space.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:help ctrl-h doesn't help me at all, as it talks about netrw,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Try &lt;code&gt;:h CTRL-h&lt;/code&gt;, yes case makes a difference for some reason.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there something that does the opposite of , i.e. it goes to the right and if it's in the last column, it skips to the next line (if there is one)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, try &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; for scripting, or &lt;kbd&gt;Space&lt;/kbd&gt; in normal mode.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-07-06T13:42:12.597" LastActivityDate="2016-07-06T13:42:12.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8605" PostTypeId="2" ParentId="4347" CreationDate="2016-07-06T15:48:18.647" Score="1" Body="&lt;p&gt;This bug has been solved in the meantime, as of at least v155.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The errant behavior does not occur anymore. All remote files are opened correctly.&lt;/p&gt;&#xA;" OwnerUserId="3102" LastActivityDate="2016-07-06T15:48:18.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8606" PostTypeId="2" ParentId="8602" CreationDate="2016-07-06T16:35:21.370" Score="7" Body="&lt;p&gt;You could add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=file Diffsplit diffsplit &amp;lt;args&amp;gt; | wincmd p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This create a &lt;code&gt;Diffsplit&lt;/code&gt; command (note the capitalized &lt;code&gt;D&lt;/code&gt;) which takes one argument and accept file names as completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command will create the diffsplit with the argument provided and use the command &lt;code&gt;windcm p&lt;/code&gt; to go back to the initial file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#user-commands&quot;&gt;&lt;code&gt;:h user-commands&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#wincmd&quot;&gt;&lt;code&gt;:h wincmd&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-07-06T16:35:21.370" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8607" PostTypeId="1" AcceptedAnswerId="8610" CreationDate="2016-07-06T19:04:30.767" Score="4" ViewCount="960" Body="&lt;p&gt;I'm having a hard time understanding how the ANSI colors affect the named colors in Vim. My KiTTY terminal has &quot;regular&quot; and &quot;bold&quot; versions for the main 8 colors, plus foreground/background colors. How are these assigned to the representations of DarkGray, etc. often used to define Vim colorschemes? When I checked with &lt;code&gt;:runtime syntax/colortest.vim&lt;/code&gt; after modifying the ANSI colors, some were changed in unexpected ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm obviously a beginner in Vim/terminal customization.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="2920" LastEditDate="2016-07-06T19:36:48.377" LastActivityDate="2016-07-06T20:18:52.270" Title="How do PuTTY/KiTTY ANSI colors affect Vim colorschemes?" Tags="|vimrc|terminal|colorscheme|putty|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8608" PostTypeId="2" ParentId="2009" CreationDate="2016-07-06T20:00:43.167" Score="1" Body="&lt;p&gt;With &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#user-commands&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'user-commands'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#Dictionary&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'Dictionary'&lt;/code&gt;&lt;/a&gt;, we can edit the files without creating a buffer for overriding the file which we want to edit on the buffer. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com -nargs=* E call Editfile(&amp;lt;q-args&amp;gt;)&#xA;let s:fileLocation = {'vimrc':'~/.vim/', '.zshrc':'~/'}&#xA;function Editfile(filename)&#xA;    if has_key(s:fileLocation, a:filename)&#xA;        exe &quot;e &quot; . fnameescape(s:fileLocation[a:filename].a:filename)&#xA;    else&#xA;        exe &quot;e &quot; . fnameescape(a:filename)&#xA;    endif&#xA;endfunction &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the function &lt;code&gt;Editfile&lt;/code&gt; does not try to verify its argument. Let's have vim handle all errors like other normal Ex-commands. If the argument is correct then vim starts to edit the file, and if not correct then vim will report errors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion, we need not to create a buffer. It has two main drawbacks.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The &lt;code&gt;'not-edited'&lt;/code&gt; flag would be set. As jamessan points out in &lt;a href=&quot;https://vi.stackexchange.com/a/2206/8031&quot;&gt;his answer&lt;/a&gt;, if we set the current file name with &lt;code&gt;:file&lt;/code&gt;command and try to write the file, we will meet the error message &lt;code&gt;E13: File exists (use ! to override)&lt;/code&gt; This is because vim marks the file as &quot;not edited&quot; when we change the name of the file with &lt;code&gt;:file&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;li&gt;We have to try to keep the alternate file name with &lt;code&gt;:keepalt&lt;/code&gt; command. When we try to edit vimrc while editing 'foo.bar', we expect to the alternate file name should be 'foo.bar'. But if we creates a buffer and change the name, the alternate file name becomes not the &quot;foo.bar&quot; but the buffer's old name 'vimrc'. Even worse, the old buffer will be left as &lt;code&gt;unlisted-buffer&lt;/code&gt; or &lt;code&gt;inactive-buffer&lt;/code&gt;. That's why we should use &lt;code&gt;:keepalt&lt;/code&gt; command in order to keep the alternate file name as we expect and set the &lt;code&gt;bufhidden&lt;/code&gt; option to be &lt;code&gt;wipe&lt;/code&gt; to wipe out the old buffer.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If the capital letter in the command name (all user-defined commands should start with capital letter) does not concern us, it would be better to use it. Because it does not create a buffer, we are free of burden for managing the buffer. Just pass the file name to vim and see how vim handles it.&lt;/p&gt;&#xA;" OwnerUserId="8031" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-07-06T20:00:43.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8609" PostTypeId="2" ParentId="8607" CreationDate="2016-07-06T20:17:17.513" Score="4" Body="&lt;p&gt;The sixteen so-called &quot;ANSI&quot; colors can be used via their index, &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;15&lt;/code&gt; or via their semi-standard names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help cterm-colors&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NR-16   NR-8    COLOR NAME&#xA;0       0       Black&#xA;1       4       DarkBlue&#xA;2       2       DarkGreen&#xA;3       6       DarkCyan&#xA;4       1       DarkRed&#xA;5       5       DarkMagenta&#xA;6       3       Brown, DarkYellow&#xA;7       7       LightGray, LightGrey, Gray, Grey&#xA;8       0*      DarkGray, DarkGrey&#xA;9       4*      Blue, LightBlue&#xA;10      2*      Green, LightGreen&#xA;11      6*      Cyan, LightCyan&#xA;12      1*      Red, LightRed&#xA;13      5*      Magenta, LightMagenta&#xA;14      3*      Yellow, LightYellow&#xA;15      7*      White&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your terminal is limited to 8 colors, &lt;code&gt;Green&lt;/code&gt; or &lt;code&gt;LightGreen&lt;/code&gt; can be obtained by adding the &lt;code&gt;bold&lt;/code&gt; attribute to &lt;code&gt;2&lt;/code&gt; or &lt;code&gt;DarkGreen&lt;/code&gt;. Note that colors &lt;code&gt;8&lt;/code&gt; to &lt;code&gt;15&lt;/code&gt; can only be used as foreground color in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your terminal is capable of displaying 16 colors or more, using &lt;code&gt;10&lt;/code&gt;, &lt;code&gt;Green&lt;/code&gt;, &lt;code&gt;LightGreen&lt;/code&gt; (or any case-insensitive variant) is &lt;em&gt;more or less&lt;/em&gt; guaranteed to look the same. Any of those 16 colors can be used by Vim for foreground and for background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The actual RGB values used to display those colors are &lt;em&gt;not&lt;/em&gt; standardized, though. Terminal emulators generally have their own default palettes, sometimes inherited from their GUI toolkit or from the desktop environment…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All terminal emulators allow you to change those default colors to whatever you want and most &quot;modern&quot; terminal emulators even let you do that via a handy GUI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that there's no guarantee whatsoever that &lt;code&gt;Red&lt;/code&gt; is going to be even remotely red-ish. Or, if you use the Windows Console, that all names and indices are mapped like in the table above.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-07-06T20:17:17.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8610" PostTypeId="2" ParentId="8607" CreationDate="2016-07-06T20:18:52.270" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How are these assigned to the representations of DarkGray, etc. often used to define Vim colorschemes?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I can't speak for the actual design of the color schemes since that might require looking into mailing list archives to see if there were discussions about what would be good defaults.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, in &lt;code&gt;syntax.c&lt;/code&gt; of &lt;a href=&quot;https://github.com/vim/vim/blob/80632db65e8f5f775dadbbc10c5ba6c173ebb24f/src/syntax.c#L7625-L7663&quot; rel=&quot;nofollow&quot;&gt;Vim's source code&lt;/a&gt;, there's a table for limited palettes in the &lt;code&gt;do_highlight()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;static char *(color_names[28]) = {&#xA;      &quot;Black&quot;, &quot;DarkBlue&quot;, &quot;DarkGreen&quot;, &quot;DarkCyan&quot;,&#xA;      &quot;DarkRed&quot;, &quot;DarkMagenta&quot;, &quot;Brown&quot;, &quot;DarkYellow&quot;,&#xA;      &quot;Gray&quot;, &quot;Grey&quot;,&#xA;      &quot;LightGray&quot;, &quot;LightGrey&quot;, &quot;DarkGray&quot;, &quot;DarkGrey&quot;,&#xA;      &quot;Blue&quot;, &quot;LightBlue&quot;, &quot;Green&quot;, &quot;LightGreen&quot;,&#xA;      &quot;Cyan&quot;, &quot;LightCyan&quot;, &quot;Red&quot;, &quot;LightRed&quot;, &quot;Magenta&quot;,&#xA;      &quot;LightMagenta&quot;, &quot;Yellow&quot;, &quot;LightYellow&quot;, &quot;White&quot;, &quot;NONE&quot;};&#xA;static int color_numbers_16[28] = {0, 1, 2, 3,&#xA;         4, 5, 6, 6,&#xA;         7, 7,&#xA;         7, 7, 8, 8,&#xA;         9, 9, 10, 10,&#xA;         11, 11, 12, 12, 13,&#xA;         13, 14, 14, 15, -1};&#xA;/* for xterm with 88 colors... */&#xA;static int color_numbers_88[28] = {0, 4, 2, 6,&#xA;         1, 5, 32, 72,&#xA;         84, 84,&#xA;         7, 7, 82, 82,&#xA;         12, 43, 10, 61,&#xA;         14, 63, 9, 74, 13,&#xA;         75, 11, 78, 15, -1};&#xA;/* for xterm with 256 colors... */&#xA;static int color_numbers_256[28] = {0, 4, 2, 6,&#xA;         1, 5, 130, 130,&#xA;         248, 248,&#xA;         7, 7, 242, 242,&#xA;         12, 81, 10, 121,&#xA;         14, 159, 9, 224, 13,&#xA;         225, 11, 229, 15, -1};&#xA;/* for terminals with less than 16 colors... */&#xA;static int color_numbers_8[28] = {0, 4, 2, 6,&#xA;         1, 5, 3, 3,&#xA;         7, 7,&#xA;         7, 7, 0+8, 0+8,&#xA;         4+8, 4+8, 2+8, 2+8,&#xA;         6+8, 6+8, 1+8, 1+8, 5+8,&#xA;         5+8, 3+8, 3+8, 7+8, -1};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;DarkGray&lt;/code&gt;'s index is &lt;code&gt;12&lt;/code&gt; in the &lt;code&gt;color_names&lt;/code&gt; table.  Assuming you have an 16 color palette, you would get the 12th item in &lt;code&gt;color_numbers_16&lt;/code&gt;, which is color index 8.  This would be the bright variant of color index &lt;code&gt;0&lt;/code&gt; (&lt;code&gt;8 % 8&lt;/code&gt;) which is &lt;code&gt;bright black&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-07-06T20:18:52.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8611" PostTypeId="1" AcceptedAnswerId="8612" CreationDate="2016-07-06T21:22:39.150" Score="6" ViewCount="2210" Body="&lt;p&gt;Couldn't find anything on this by searching, so hopefully it's not super obvious. Every now and then, through some accidental sequence of keys, a solid bar appears to the left of my line numbers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea how to get rid of it. Note that this is not a result of me searching the empty string, as 'response' is the highlighted string match. It is local to the particular file, so it doesn't show up when I open other documents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any insight would be much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TrS8Q.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TrS8Q.jpg&quot; alt=&quot;Vertical Bar&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8314" LastActivityDate="2016-07-06T21:32:30.390" Title="Weird vertical bar to left of line numbers" Tags="|linux|line-numbers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8612" PostTypeId="2" ParentId="8611" CreationDate="2016-07-06T21:32:30.390" Score="6" Body="&lt;p&gt;I have a couple guesses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first guess is that this is because you have &quot;diff&quot; on, most likely because you had done &quot;diffthis&quot; at some point, or started vim in diff mode. From &lt;code&gt;:help diffthis&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *:difft* *:diffthis*&#xA;:difft[his] Make the current window part of the diff windows.  This sets&#xA;        the options like for &quot;vimdiff&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can turn this mode off with &lt;code&gt;:diffoff&lt;/code&gt;, or if you prefer the shorter version &lt;code&gt;:diffo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's not that, it might also be &quot;foldcolumn&quot;. Does &lt;code&gt;:set foldcolumn=0&lt;/code&gt; fix it?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-06T21:32:30.390" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8613" PostTypeId="1" CreationDate="2016-07-06T23:36:02.807" Score="9" ViewCount="3268" Body="&lt;p&gt;When I am working in vim, I often have a split, or splits, open containing a help files.&lt;br&gt;&#xA;If I close other windows using &lt;code&gt;:q&lt;/code&gt; such that vim would be left in a state with only help windows open, vim closes the entire editor, which causes me to lose my position in the help pages. e.g. Say I have this layout&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  tab1 (this is the only tab open)&#xA;+------------------+-------------+-----------------+&#xA;|                  |             |                 |&#xA;|                  |:h usr_26.txt|                 |&#xA;|  A normal file,  |             |    :h change.txt|&#xA;|  containing code |section 26.2 |                 |&#xA;|  e.g.            |line 47      |    line 272     |&#xA;|                  |             |                 |&#xA;|  app_db.sql      |             |                 |&#xA;|                  |             |                 |&#xA;|                  |             |                 |&#xA;|                  |             |                 |&#xA;|                  |             |                 |&#xA;|                  |             |                 |&#xA;|                  |             |                 |&#xA;+------------------+-------------+-----------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I were to enter the window containing &lt;code&gt;app_db.sql&lt;/code&gt; an issue the &lt;code&gt;:q&lt;/code&gt; command, surprisingly the entire editor would be lost.&lt;br&gt;&#xA;It often takes me a long time - up to 15-20mins - of searching the help to finally discover that help content, so even though it's not exactly lost work, it's definitely a lot of time lost when this happens.&lt;br&gt;&#xA;How can I prevent vim closing the editor itself when I close a window with only help windows open?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possible solutions I've considered&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Simply don't close the last window when there are help windows open.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the problem with this is I am not paying attention to what's in other  windows when I close the current window.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;mksession&lt;/code&gt; &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;this requires that you know ahead of time that you need to &lt;code&gt;:mksession&lt;/code&gt; and the editor closing always occurs unexpectedly.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use a plugin like &lt;a href=&quot;https://github.com/tpope/vim-obsession&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim obsession&lt;/a&gt; which constantly update a &lt;code&gt;Session.vim&lt;/code&gt; file.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I've currently paused using vim-obsession because of (ironically), the &lt;code&gt;Session.vim&lt;/code&gt; files vim obsession makes often don't restore tabs containing help pages, but the &lt;code&gt;Session.vim&lt;/code&gt; files generated by &lt;code&gt;:mksession&lt;/code&gt; do restore the tabs with help windows. (Also another issue with tab labels getting mis-matched with the tabs themselves) &lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4603" LastEditorDisplayName="user5791" LastEditDate="2019-01-29T05:49:12.643" LastActivityDate="2019-01-29T05:49:12.643" Title="Prevent vim closing the editor when the last window/splits are help pages" Tags="|help-system|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="8614" PostTypeId="1" AcceptedAnswerId="8615" CreationDate="2016-07-07T00:04:38.597" Score="3" ViewCount="2130" Body="&lt;h3&gt;Context&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I have shortcuts to edit my &lt;code&gt;vimrc&lt;/code&gt; and to source my &lt;code&gt;vimrc&lt;/code&gt;.  When I'm writing code I can quickly add a new mapping and then source &lt;code&gt;vimrc&lt;/code&gt;.  And all that would be good if I did not use &lt;code&gt;autocmd FileType&lt;/code&gt; for most of my mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since most mappings are specific to one file type I keep my &lt;code&gt;vimrc&lt;/code&gt; in a form similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FtPython()&#xA;  setlocal expandtab shiftwidth=4 softtabstop=4 autoindent&#xA;  nnoremap &amp;lt;buffer&amp;gt; &amp;lt;localleader&amp;gt;c I#&amp;lt;esc&amp;gt;&#xA;&#xA;  &quot; Let's say that this is a new mapping&#xA;  nnoremap &amp;lt;buffer&amp;gt; &amp;lt;localleader&amp;gt;cc ^wC:&amp;lt;esc&amp;gt;&amp;lt;left&amp;gt;i&#xA;&#xA;endfunction&#xA;&#xA;if has(&quot;autocmd&quot;)&#xA;  augroup filetype_vimrc&#xA;    autocmd!&#xA;    autocmd FileType python call FtPython()&#xA;    ...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet, when I add a new mapping to &lt;code&gt;FtPython()&lt;/code&gt; and source my &lt;code&gt;vimrc&lt;/code&gt;, the new mapping is not present in the &lt;code&gt;python&lt;/code&gt; buffers because the &lt;code&gt;FileType&lt;/code&gt; event happened long ago, when the file was read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I read a buffer back into a window &lt;code&gt;FileType&lt;/code&gt; will be fired and the mapping will be added, but that does not happen when a window is already open and I just move into it (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt;).  In essence, once I add a new mapping all &lt;strong&gt;currently open windows&lt;/strong&gt; need to be &quot;kicked&quot; to get the new mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I work around it by doing (I force the &lt;code&gt;FileType&lt;/code&gt; event to fire):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ft=python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that is quite a lot of typing, sometimes I have 2-3 &lt;code&gt;python&lt;/code&gt; files in different windows (&lt;code&gt;split/vsplit&lt;/code&gt;) and I need to do it for each.  &lt;code&gt;argdo&lt;/code&gt; is not an option since it will close the windows (as far as I know).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Question&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Is there a good way to fire the &lt;code&gt;FileType&lt;/code&gt; event on all windows that Vim is currently showing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, maybe, is there a better way to structure the mappings?&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-07-07T16:14:21.487" Title="Fire autocmd FileType on current buffers in windows" Tags="|vimrc|autocmd|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8615" PostTypeId="2" ParentId="8614" CreationDate="2016-07-07T02:00:39.313" Score="7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a good way to fire the FileType event on all windows that Vim is currently showing?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;:e&lt;/code&gt; instead of &lt;code&gt;:set ft=python&lt;/code&gt; to reset the current buffer.  It re-reads the file and triggers the relevant autocmds for the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: I missed the part about different files.  You could re-set the filetype for all buffers with &lt;code&gt;:bufdo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo doautocmd FileType&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;alternatively:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo let &amp;amp;ft=&amp;amp;ft&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;code&gt;doautoall&lt;/code&gt; which can re-trigger the &lt;code&gt;FileType&lt;/code&gt; autocmd in all buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:doautoall FileType&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The methods above are a bit heavy handed and not without drawbacks.  If you want to affect only &lt;code&gt;python&lt;/code&gt; filetypes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo if &amp;amp;ft == 'python' | doautocmd FileType | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as a command that accepts the filetype as an argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -complete=filetype -nargs=1 FiletypeReload bufdo if &amp;amp;ft =~# '\&amp;lt;&amp;lt;args&amp;gt;\&amp;gt;' | doautocmd FileType | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Or, maybe, is there a better way to structure the mappings?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could use filetype scripts in &lt;code&gt;~/.vim/after/ftplugin/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt;.  Then you wouldn't need to source &lt;code&gt;vimrc&lt;/code&gt; to pick up the changes. The methods above will cause the ftplugin scripts to be sourced for you.  Since it's sourced &lt;em&gt;after&lt;/em&gt; other filetype scripts, it will also guarantee that the mapped keys are actually yours and not something a plugin introduced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using this method, you can change the command above to use the &lt;code&gt;filetypeplugin&lt;/code&gt; group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -complete=filetype -nargs=1 FiletypeReload bufdo if &amp;amp;ft =~# '\&amp;lt;&amp;lt;args&amp;gt;\&amp;gt;' | doautocmd filetypeplugin FileType | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;filetypeplugin&lt;/code&gt; group is used to trigger only the &lt;code&gt;FileType&lt;/code&gt; autocmd in &lt;code&gt;$VIMRUNTIME/ftplugin.vim&lt;/code&gt; which is responsible for running &lt;code&gt;ftplugin&lt;/code&gt; scripts.  This would be preferred since the outcome is slightly more predictable than triggering &lt;code&gt;FileType&lt;/code&gt; autocmds setup at runtime.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-07-07T16:14:21.487" LastActivityDate="2016-07-07T16:14:21.487" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8616" PostTypeId="2" ParentId="8613" CreationDate="2016-07-07T04:05:24.303" Score="9" Body="&lt;p&gt;using the command &lt;code&gt;:clo[se]&lt;/code&gt; instead of &lt;code&gt;:q&lt;/code&gt; seems to have solved the problem for me.&lt;br&gt;&#xA;I.e. if I issue &lt;code&gt;:clo&lt;/code&gt; with the above window layout, it causes vim to throw &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E444: Cannot close last window.  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In fact it seems &lt;code&gt;:close&lt;/code&gt; was intended for this situation, i.e. to prevent accidental closing of the editor when all you wanted to do was close a window (or tab)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;from &lt;code&gt;:h windows.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:clo[se][!]&#xA;:{count}clo[se][!]&#xA;CTRL-W c                    *CTRL-W_c* *:clo* *:close*&#xA;        Without {count}: Close the current window.  If {count} is&#xA;        given close the {count} window.&#xA;&#xA;        When the 'hidden' option is set, or when the buffer was&#xA;        changed and the [!] is used, the buffer becomes hidden (unless&#xA;        there is another window editing it).&#xA;&#xA;        When there is only one window in the current tab page and&#xA;        there is another tab page, this closes the current tab page.&#xA;        |tab-page|.&#xA;&#xA;        This command fails when:            *E444*&#xA;        - There is only one window on the screen.&#xA;        - When 'hidden' is not set, [!] is not used, the buffer has&#xA;          changes, and there is no other window on this buffer.&#xA;        Changes to the buffer are not written and won't get lost, so&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2016-07-07T04:05:24.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8617" PostTypeId="1" AcceptedAnswerId="8620" CreationDate="2016-07-07T09:49:24.347" Score="6" ViewCount="827" Body="&lt;p&gt;I cannot figure out how to open a file that starts with &lt;code&gt;+&lt;/code&gt;, e.g. &lt;code&gt;+models/File.m&lt;/code&gt;. This is a naming convention for packages in Matlab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried escaping &lt;code&gt;\+models/File.m&lt;/code&gt;.  This doesn't work because the backslash is interpreted by the shell.  Double escaping &lt;code&gt;\\+models/File.m&lt;/code&gt; allows vim to receive the backslash,  but it then opens &lt;code&gt;\+models/File.m&lt;/code&gt; literally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way to do this seems to be by creating the file first with &lt;code&gt;touch&lt;/code&gt; or whatever, and then opening inside vim with Ctrl-P.  I don't want to &lt;code&gt;cd&lt;/code&gt; into &lt;code&gt;+models&lt;/code&gt; because I am also working on files in sibling directories.  Any Ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My shell is bash if that makes a difference.&lt;/p&gt;&#xA;" OwnerUserId="8113" LastEditorUserId="1841" LastEditDate="2016-07-07T10:04:33.200" LastActivityDate="2016-07-07T15:05:10.080" Title="Is it possible to open a new file that starts with '+'?" Tags="|filesystem|escape|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8618" PostTypeId="2" ParentId="7674" CreationDate="2016-07-07T09:52:04.217" Score="0" Body="&lt;p&gt;Have you tried using &lt;code&gt;gf&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to have a look at installing rails-vim if you haven't already.&#xA;&lt;a href=&quot;http://vimawesome.com/plugin/rails-vim&quot; rel=&quot;nofollow&quot;&gt;http://vimawesome.com/plugin/rails-vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user8323" LastActivityDate="2016-07-07T09:52:04.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8619" PostTypeId="2" ParentId="8617" CreationDate="2016-07-07T10:13:24.243" Score="2" Body="&lt;p&gt;You can open &lt;code&gt;vim&lt;/code&gt; without any arguments.&#xA;And then, in command line, type &lt;code&gt;:e! \+filename&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7161" LastActivityDate="2016-07-07T10:13:24.243" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8620" PostTypeId="2" ParentId="8617" CreationDate="2016-07-07T10:21:36.457" Score="6" Body="&lt;p&gt;From &lt;code&gt;vim --help:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arguments:&#xA;   --                   Only file names after this&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this works on the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -- +models/File.m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From inside Vim you need to escape the &lt;code&gt;+&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e \+models/File.m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-07-07T10:21:36.457" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8621" PostTypeId="1" AcceptedAnswerId="8662" CreationDate="2016-07-07T11:00:58.517" Score="15" ViewCount="17037" Body="&lt;p&gt;I have a list of files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./a.temp.txt     ./a.temp.txt&#xA;./a/b.temp.txt   ./a/b.temp.txt&#xA;./a/b/c.temp.txt ./a/b/c.temp.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to remove the &lt;code&gt;temp.&lt;/code&gt; on each line, but only the &lt;strong&gt;second occurence&lt;/strong&gt;, thus, the file should look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./a.temp.txt     ./a.txt&#xA;./a/b.temp.txt   ./a/b.txt&#xA;./a/b/c.temp.txt ./a/b/c.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How should I do this?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2020-03-29T10:33:45.790" Title="Substitute second occurence on line" Tags="|regular-expression|substitute|" AnswerCount="11" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8622" PostTypeId="2" ParentId="8621" CreationDate="2016-07-07T11:16:25.457" Score="1" Body="&lt;p&gt;I'd write a macro with the cursor starting at the top left.&#xA;&lt;code&gt;qq4f.dfpq&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I'd select the rest of the lines using &lt;code&gt;V&lt;/code&gt; and run the macro on those lines with &lt;code&gt;:'&amp;lt;,'&amp;gt;norm!@q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will only work if the text format stays the same in relation to the number of dots before the second temp.&lt;/p&gt;&#xA;" OwnerDisplayName="user8323" LastActivityDate="2016-07-07T11:16:25.457" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8624" PostTypeId="2" ParentId="8621" CreationDate="2016-07-07T11:23:43.233" Score="14" Body="&lt;p&gt;This is much easier done with &lt;code&gt;sed&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sed 's/\.temp\././2'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With Vim you need non-greedy matching, and it isn't easy to extend the method to replacing the 3rd, 4th, etc. occurrence of &lt;code&gt;temp&lt;/code&gt;.  But it can be done if you insist:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\.temp\..\{-}\.\zstemp\.//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-07-07T11:23:43.233" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8625" PostTypeId="1" CreationDate="2016-07-07T12:22:13.210" Score="11" ViewCount="978" Body="&lt;p&gt;I want to insert text like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;similar text wordA similar text ...&#xA;similar text wordB similar text ...&#xA;similar text wordC similar text ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know I can paste the text many times then use the substitution to change single word for each line, however I still find this method very inconvenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to save a word or a word list into a &quot;variable&quot; then use this variable to generate similar text ?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; I made something unclear in the original question, in fact I'm trying to make some very alike function definitions, so &lt;code&gt;wordA&lt;/code&gt; &lt;code&gt;wordB&lt;/code&gt;... may appear many times in each clone of text and the text may contain many lines. the pattern is exactly like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;similar_text1 wordA similar_text2 wordA similar_text3 ...&#xA;similar_text1 wordB similar_text2 wordB similar_text3 ...&#xA;similar_text1 wordC similar_text2 wordC similar_text3 ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(text may contain new lines, and wordA,wordB... may exist many times)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2nd EDIT&lt;/strong&gt;&#xA;The &quot;similar_text&quot; parts maybe different each time I do such job, so the solution for this job is better to be reusable. Because I'm trying to make very alike function definitions, or a string to function mapping table.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading answers and some practice, I find that it is more convenient to think this job as some kind of substitution, because separate &quot;part1&quot;,&quot;part2&quot;...&quot;partN&quot; which may contain newlines is hard to write, so write a template first:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;similar_text1 $WORD similar_text2 $WORD similar_text3 ...&#xA;(text may contain &amp;lt;ENTER&amp;gt;, make sure $WORD not exist in &quot;similar_text&quot; parts )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then trying to put clones of the text but replacing $WORD with a list of words is more straight thinking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it seems my problem changed to be &quot;how to clone a text block many times, but each time by substituting a keyword in it with a word from a list?&quot;&lt;/p&gt;&#xA;" OwnerUserId="8325" LastEditorUserId="1841" LastEditDate="2016-07-08T09:19:56.493" LastActivityDate="2021-09-22T16:54:04.177" Title="How to insert repetitive text with minor difference in vim?" Tags="|cut-copy-paste|macro|repeated-commands|text-generation|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8626" PostTypeId="2" ParentId="8625" CreationDate="2016-07-07T12:30:00.027" Score="7" Body="&lt;p&gt;You can use the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GenerateLines()&#xA;    let firstpart=&quot;similar text part 1&quot;&#xA;    let secondpart=&quot;similar text part 2&quot;&#xA;&#xA;    let words=[&quot;wordA&quot;,&quot;wordB&quot;,&quot;wordC&quot;,&quot;wordD&quot;,&quot;wordE&quot;]&#xA;&#xA;    for word in words&#xA;        let line = firstpart . word . secondpart&#xA;        call append(line('.')+1, line)&#xA;        normal j&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the variables &lt;code&gt;firstpart&lt;/code&gt; and &lt;code&gt;secondpart&lt;/code&gt; put the text to repeate before and after the words and in the list &lt;code&gt;words&lt;/code&gt; put the words which should change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the loop will create the content of the line for each word of the list, insert the line in the buffer and go to this new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then simply call the function: &lt;code&gt;call GenerateLines()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; To make it easier to manipulate you can also pass the different parts as arguments, the function should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GenerateLines(firstpart, secondpart, words)&#xA;    for word in a:words&#xA;        call append(line('.')+1, a:firstpart . word . a:secondpart)&#xA;        normal j&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can call it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call GenerateLines(&quot;first part&quot;, &quot;second part&quot;, [&quot;wordA&quot;,&quot;wordB&quot;,&quot;wordC&quot;,&quot;wordD&quot;,&quot;wordE&quot;])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-07-07T12:44:47.987" LastActivityDate="2016-07-07T12:44:47.987" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8627" PostTypeId="2" ParentId="8621" CreationDate="2016-07-07T12:31:09.457" Score="5" Body="&lt;p&gt;In Vim, you can define the column before/at/after which you want your matching to happen with &lt;code&gt;:help \%c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\%&amp;gt;17c\.temp/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will get rid of every &lt;code&gt;.temp&lt;/code&gt; found after column 17 of every line in the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note 1: the &lt;code&gt;/g&lt;/code&gt; is not necessary with your sample.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note 2: I use that handy feature very often with &lt;a href=&quot;http://www.nongnu.org/renameutils/&quot; rel=&quot;noreferrer&quot;&gt;qmv&lt;/a&gt;. Recommended!&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-07-07T12:31:09.457" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8628" PostTypeId="1" CreationDate="2016-07-07T13:15:44.337" Score="4" ViewCount="719" Body="&lt;p&gt;A common task I run into is having to change the order of arguments. So, for example, I might have something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stringInsert( &quot;text to insert&quot;, buffer );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and need to change it into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stringInsert( buffer, &quot;text to insert&quot; );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typically the way I do this is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;da&quot;&lt;/code&gt; (or whatever is required to delete the first arg)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f)h&lt;/code&gt;  (or f, if I am inserting in the middle of the arg list)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Enter insert, insert any necessary spaces in insert mode, leave insert mode&lt;/li&gt;&#xA;&lt;li&gt;Go back to beginning and delete unnecessary commas and spaces from beginning of arglist with &lt;code&gt;x&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Obviously, this is kind of tedious. What is a better way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been trying out a macro that looks like this and so far it seems to be working pretty well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;da&quot;2f_i,&amp;lt;ESC&amp;gt;p2F_x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="6952" LastEditDate="2016-07-07T15:34:36.967" LastActivityDate="2016-07-07T15:34:36.967" Title="Change or reverse order of arguments" Tags="|cursor-motions|rearrangement|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8629" PostTypeId="2" ParentId="8621" CreationDate="2016-07-07T13:23:54.177" Score="8" Body="&lt;p&gt;You can also do this with a lookbehind.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(temp\..*\)\@&amp;lt;=temp\.//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to remove &lt;em&gt;ALL&lt;/em&gt; occurrences after the first, you can append the &lt;code&gt;g&lt;/code&gt; flag at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\(\)\@&amp;lt;=&lt;/code&gt; Will search for any pattern between &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; but will not add the found text to the match. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h \@&amp;lt;=&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-07-07T13:40:06.313" LastActivityDate="2016-07-07T13:40:06.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8630" PostTypeId="1" AcceptedAnswerId="8638" CreationDate="2016-07-07T13:25:31.923" Score="8" ViewCount="2148" Body="&lt;p&gt;Sometimes I need to replace &lt;code&gt;.&lt;/code&gt; with &lt;code&gt;-&amp;gt;&lt;/code&gt; when fixing code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually search and replace cannot be used because there will be many (hundreds of) dots (&lt;code&gt;.&lt;/code&gt;) and only a few ones of them must be changed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I find the ones that need to be changed when I am going through a make &lt;em&gt;changelist&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the repetition operator does not quite work because if I change one instance and then repeat with the dot command, then I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;structBlah-&amp;gt;.memberBlah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I then use &lt;kbd&gt;x&lt;/kbd&gt; to delete the extraneous dot, then paste and dot no longer work because the last change was a delete. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, basically the problem is that the repetition operator repeats a motion and an edit, whereas here we need to repeat two edits: a delete and an insert.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any convenient way to do this? One idea I had was to maybe use a macro like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xi-&amp;gt;&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="1841" LastEditDate="2016-07-07T14:06:53.550" LastActivityDate="2016-07-08T10:06:03.777" Title="Replace . with -&gt; in specific places" Tags="|cut-copy-paste|repeated-commands|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8631" PostTypeId="2" ParentId="8630" CreationDate="2016-07-07T13:31:28.973" Score="11" Body="&lt;p&gt;You could use the &lt;code&gt;s&lt;/code&gt; operator, which deletes the character under your cursor and puts you in insert mode. You can then type the replacement and later use &lt;code&gt;.&lt;/code&gt; to repeat the whole replacement. Workflow becomes:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/\.&lt;/code&gt; to highlight all periods.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt; to first dot&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s-&amp;gt;&lt;/code&gt; and then &lt;kbd&gt;Esc&lt;/kbd&gt;. This will replace the dot and insert the text with a single operation.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt; to next dot&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt; to change when needed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h s&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-07-07T16:52:31.087" LastActivityDate="2016-07-07T16:52:31.087" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8632" PostTypeId="2" ParentId="8621" CreationDate="2016-07-07T13:32:43.300" Score="7" Body="&lt;p&gt;You can use a macro as @Meshpi already suggested. But, this is another way you can accomplish the same thing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;02/temp^Mdwx+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0 - Go to the starting of a line&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;2/temp - Search for temp and go to the second occurance&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;^M - This is just pressing the Enter key&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;dw - delete the word (temp)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;x - delete the '.'&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;+ - Go to the beginning of the next line&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And, then you can just repeat it till the end. And, there will be a lot more ways to do the same. &lt;/p&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="5481" LastEditDate="2016-07-08T10:38:14.957" LastActivityDate="2016-07-08T10:38:14.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8633" PostTypeId="2" ParentId="8630" CreationDate="2016-07-07T13:40:46.200" Score="7" Body="&lt;p&gt;I recommande using the substitute command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\./-&amp;gt;/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s     substitute over all lines&#xA;/\.     match dot&#xA;/-&amp;gt;     replace by arrow&#xA;/g      replace all on lines&#xA;c       ask for confirmation&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will go through all &lt;code&gt;.&lt;/code&gt; of your file and asking each time if you want to substitute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Press &lt;code&gt;y&lt;/code&gt; for substitute, &lt;code&gt;n&lt;/code&gt; to go to the next dot. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;see &lt;code&gt;:h :s_c&lt;/code&gt; for all options.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-07T13:40:46.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8634" PostTypeId="2" ParentId="8628" CreationDate="2016-07-07T13:48:39.450" Score="6" Body="&lt;p&gt;You can try to put this function in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! InvertArgs()&#xA;    &quot; Get the arguments of the current line (remove the spaces)&#xA;    let args=substitute(matchstr(getline('.'), '(\zs.*\ze)'), '\s', '', 'g')&#xA;&#xA;    &quot; Split the arguments as a list and reverse the list&#xA;    let argsList=split(args, ',')&#xA;    call reverse(argsList)&#xA;&#xA;    &quot; Join the reversed list with a comma and a space separing the arguments&#xA;    let invertedArgs=join(argsList, ', ')&#xA;&#xA;    &quot; Remove the old arguments and put the new list&#xA;    execute &quot;normal! 0f(ci(&quot; . invertedArgs&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Go to the a line containing &lt;code&gt;function (arg1, arg2, arg3)&lt;/code&gt; and call the function with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call InvertArgs()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The main advantage of this function is that the number of arguments in your funciton doesn't matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also create a mapping like &lt;code&gt;nnoremap &amp;lt;key&amp;gt; :call InvertArgs()&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I just noticed that your example has a string with withe spaces in it: the function will mess with it, thus the subtitution in the first line should be removed like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let args=matchstr(getline('.'), '(\zs.*\ze)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-07-07T14:11:58.710" LastActivityDate="2016-07-07T14:11:58.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8636" PostTypeId="2" ParentId="8628" CreationDate="2016-07-07T13:52:18.300" Score="5" Body="&lt;p&gt;Statox's is much more robust, but if you only wanted to ever do two arguments a lighter solution could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;key&amp;gt; :s/(\(.*\), \(.*\))/(\2, \1)/e&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses the search and replace function.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\(\)&lt;/code&gt; captures output&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\1&lt;/code&gt; recalls the 1st capture&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;e&lt;/code&gt; flag makes it not complain if the search fails&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h :s&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-07-07T14:30:52.200" LastActivityDate="2016-07-07T14:30:52.200" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8637" PostTypeId="2" ParentId="8630" CreationDate="2016-07-07T14:02:26.300" Score="7" Body="&lt;p&gt;If you don't want to use a substitution or the dot command as suggested by the other answers your best bet is probably to create a macro which you can use when your cursor is next to a dot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can record the macro&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qaf.vc-&amp;gt;^[q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will go to the following dot on the line (&lt;code&gt;f.&lt;/code&gt;) visually select it (&lt;code&gt;v&lt;/code&gt;) and replace it (&lt;code&gt;c-&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when you navigate your code and you spot a dot which should be changed you can call the macro with &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can even put that in your &lt;code&gt;.vimrc&lt;/code&gt; to keep the macro between you different coding sessions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a=&quot;f.vc-&amp;gt;^[&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; @grochmal suggested in the comments to use a second register to have a backward moving macro which seems pretty useful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @e=&quot;F.vc-&amp;gt;^[&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-07-07T19:50:53.323" LastActivityDate="2016-07-07T19:50:53.323" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8638" PostTypeId="2" ParentId="8630" CreationDate="2016-07-07T14:13:35.120" Score="8" Body="&lt;p&gt;The cw(change word) command will solve your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put your cursor on the period and type &lt;code&gt;cw-&amp;gt;&amp;lt;Escape&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;something.somethingelse&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;turns into &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;something-&gt;somethingelse&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and the &lt;code&gt;.&lt;/code&gt; operator will still work, because cw is one operation that does both the deletion and substitution. &lt;/p&gt;&#xA;" OwnerUserId="2757" LastEditorUserId="2757" LastEditDate="2016-07-07T14:28:50.423" LastActivityDate="2016-07-07T14:28:50.423" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8639" PostTypeId="2" ParentId="8628" CreationDate="2016-07-07T14:16:59.887" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/AndrewRadev/sideways.vim&quot; rel=&quot;nofollow&quot;&gt;sideways.vim&lt;/a&gt; is nice for this.  You can use &lt;code&gt;:SidewaysLeft&lt;/code&gt; or &lt;code&gt;:SidewaysRight&lt;/code&gt; to shift arguments and it's repeatable if you have &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow&quot;&gt;vim-repeat&lt;/a&gt; installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Text objects you could map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;omap aa &amp;lt;Plug&amp;gt;SidewaysArgumentTextobjA&#xA;xmap aa &amp;lt;Plug&amp;gt;SidewaysArgumentTextobjA&#xA;omap ia &amp;lt;Plug&amp;gt;SidewaysArgumentTextobjI&#xA;xmap ia &amp;lt;Plug&amp;gt;SidewaysArgumentTextobjI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Limitations I noticed:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The text objects seem to be sensitive about where the cursor is placed.&lt;/li&gt;&#xA;&lt;li&gt;Selected text objects don't shrink or expand when repeated.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-07-07T14:16:59.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8640" PostTypeId="1" AcceptedAnswerId="8655" CreationDate="2016-07-07T14:56:10.353" Score="2" ViewCount="151" Body="&lt;p&gt;I'm writing a Syntax file for &lt;a href=&quot;http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html&quot; rel=&quot;nofollow&quot;&gt;Robot Framework&lt;/a&gt;.  I want to create a color scheme for the &lt;code&gt;[Documentation]&lt;/code&gt; tag, such that the text following the tag, and all subsequent lines beginning with &lt;code&gt;...&lt;/code&gt; until the next line that does not begin with &lt;code&gt;...&lt;/code&gt; are matched.  So for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1    Test Case 1&#xA;2        [Documentation]  This&#xA;3        ...    Is&#xA;4        ...    Documentation&#xA;5        [Setup]    Run Keywords    Keyword1&#xA;6        ...    AND        Keyword2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to match lines 2-4, but not 1, 5, or 6.  I'm not sure if this is possible, and if so, I have no idea where to start.&lt;/p&gt;&#xA;" OwnerUserId="8328" LastActivityDate="2016-07-07T19:15:36.087" Title="syntax: match all lines with a given pattern that follow a line with a different pattern" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8641" PostTypeId="2" ParentId="8617" CreationDate="2016-07-07T15:05:10.080" Score="3" Body="&lt;p&gt;More generally, you can start by specifying a directory name, so that the + (plus sign) appears &lt;em&gt;in the middle&lt;/em&gt; of the file specification instead of at the beginning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because all *nix operating systems, and others like MS-DOS / Windows that adopted Unix conventions, (just about any place you can run &lt;em&gt;vim&lt;/em&gt;...,) refer to the current directory as &lt;code&gt;.&lt;/code&gt; (&quot;dot&quot;, &quot;period&quot;, and so on,) then you can specify &lt;strong&gt;any&lt;/strong&gt; file name beginning with an unusual symbol by preceding it with the string &lt;code&gt;./&lt;/code&gt; (or in Windows with back- instead of forward-slash &lt;code&gt;.&amp;lt;&lt;/code&gt;) and thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./+models/File.m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;just about anywhere that you can use a &quot;regular&quot; file name.&lt;/p&gt;&#xA;" OwnerUserId="8329" LastActivityDate="2016-07-07T15:05:10.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8642" PostTypeId="1" CreationDate="2016-07-07T15:42:04.727" Score="0" ViewCount="861" Body="&lt;p&gt;I find that one of my most common actions is to insert a space, therefore I am thinking about changing the spacebar to insert a space. Right now I rarely use the space bar in normal mode, which is tragic because it is the most accessible key on the board, so by logic it should be mapped to something useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The normal mode use is to move forward one space (like &lt;kbd&gt;l&lt;/kbd&gt;), the difference being that &lt;kbd&gt;l&lt;/kbd&gt; actually means &quot;move right&quot; and &lt;kbd&gt;space&lt;/kbd&gt; means move one character forwards, which means that &lt;kbd&gt;space&lt;/kbd&gt; can move forwards past end of line, but &lt;kbd&gt;l&lt;/kbd&gt; cannot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would seem to make sense to change &lt;kbd&gt;l&lt;/kbd&gt; to have the &lt;kbd&gt;space&lt;/kbd&gt; behavior and change &lt;kbd&gt;space&lt;/kbd&gt; to insert a space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any gotchas or non-obvious problems with this idea?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="1821" LastEditDate="2016-07-07T15:45:09.123" LastActivityDate="2016-07-07T15:51:35.307" Title="Gotchas for changing spacebar to insert a space?" Tags="|key-bindings|cursor-motions|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8643" PostTypeId="2" ParentId="8642" CreationDate="2016-07-07T15:51:35.307" Score="6" Body="&lt;p&gt;I would recommande mapping &lt;kbd&gt;space&lt;/kbd&gt; to the leader key instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The space key is such a huge key that it may be your &quot;personal namespace&quot; for normal mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on your configuration, you may find that you have a lot of mapping that are only making sens to you. So, having them inside a &quot;namespace&quot; (just an image, there is no relation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can set in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader=&quot;\&amp;lt;Space&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then define new mapping with the &quot;namespace&quot; of the leader key:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;a ...&#xA;nnoremap &amp;lt;leader&amp;gt;b ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then if you use the action &quot;insert a space&quot; often you can map it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;i i &amp;lt;ESC&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;a a &amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To insert a space before and after the cursor.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-07T15:51:35.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8644" PostTypeId="1" AcceptedAnswerId="8646" CreationDate="2016-07-07T15:59:56.387" Score="2" ViewCount="209" Body="&lt;p&gt;When I'm searching my document with &lt;code&gt;/&lt;/code&gt; when the next match line is off screen, the cursor jumps down so that the matched line is the very last line in the window.  For example, if I'm searching for &lt;code&gt;countWordsWithMap&lt;/code&gt; in &lt;a href=&quot;https://www.cs.utexas.edu/~scottm/cs314/javacode/CodingSamples/WordCount.java&quot; rel=&quot;nofollow noreferrer&quot;&gt;this sample file&lt;/a&gt;, it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/R7Ey1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/R7Ey1.png&quot; alt=&quot;sample&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to make it so the cursor jumps to the line where the match is found, but the window moves below that by a certain amount? For example, if I set the value to 10, the cursor should move to the match on line 59, but the window would jump to line 69, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/a3pra.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/a3pra.png&quot; alt=&quot;desire&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I always want the few lines below the match to be visible, unless the match is at the end of the file.&lt;/p&gt;&#xA;" OwnerUserId="8328" LastActivityDate="2016-07-07T16:04:03.600" Title="search: move window below next found line" Tags="|search|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8645" PostTypeId="1" CreationDate="2016-07-07T16:02:39.820" Score="2" ViewCount="1459" Body="&lt;p&gt;Currently I tend to use macros and have not learned how to use the leader key which seems to provide much the same functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aside from it being easier to type &lt;kbd&gt;,&lt;/kbd&gt; than &lt;kbd&gt;@&lt;/kbd&gt; what is the gestalt of using a leader key as opposed to a macro?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2016-07-07T19:27:58.763" Title="Leader versus macros" Tags="|key-bindings|macro|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8646" PostTypeId="2" ParentId="8644" CreationDate="2016-07-07T16:04:03.600" Score="3" Body="&lt;p&gt;Yes you have an option for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set scrolloff=10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will always (or at least, when it's possible) leave 10 line above and below the cursor. When scrolling, searching, jumping, ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's worth knowing the same for horizontal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set sidescrolloff=10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-07T16:04:03.600" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8647" PostTypeId="2" ParentId="8645" CreationDate="2016-07-07T16:09:34.613" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;the leader key which seems to provide much the same functionality&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A macro is the recording of a succession of keystrokes, that you can replay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The leader key is a &lt;em&gt;special&lt;/em&gt; key that you can use in your mapping with &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; and change only once in your configuration file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to use &lt;strong&gt;a macro&lt;/strong&gt; when having a repetitive task that you can repeat easily with a succession of keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to use &lt;strong&gt;the leader key&lt;/strong&gt; when a mapping you are defining needs not to override an existing mapping or when you want to put the mapping in your &quot;personal mapping&quot;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-07T16:09:34.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8648" PostTypeId="1" CreationDate="2016-07-07T16:11:39.300" Score="-1" ViewCount="84" Body="&lt;p&gt;Is there a key binding to change a single character, i.e., delete character and enter insert mode? This would be analogous to &lt;code&gt;cw&lt;/code&gt; (change word). For example, &lt;code&gt;cx&lt;/code&gt; would seem to be logical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously a macro can be created to do this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qx`xi`q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... but a two character macro does not have much logic.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="1841" LastEditDate="2016-07-07T17:22:10.877" LastActivityDate="2016-07-07T17:22:10.877" Title="How to change the character after the cursor?" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8649" PostTypeId="2" ParentId="8645" CreationDate="2016-07-07T16:11:51.143" Score="7" Body="&lt;p&gt;I can see some confusion if you have been reading the help docs because they use some similar names even though these two things are pretty different. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The @ command will &quot;play back&quot; the contents of the register. Usually, macros are recorded into the registers with the q command. You can also set the registers by yanking into them or through vimscript. You can view &lt;code&gt;:h @&lt;/code&gt; for more info on how vim macros work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The leader is designed to make managing your keybindings easier. For example, in my vimrc I have a keybinding to make quitting faster. &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;q :q&amp;lt;cr&amp;gt;&lt;/code&gt;. If I set my leader to &lt;code&gt;,&lt;/code&gt; the command to quit would be &lt;code&gt;,q&lt;/code&gt;. If I set the leader to space, the command will be &lt;code&gt;q&lt;/code&gt;. When you have a lot of keybindings, it can be convenient to have one &quot;prefix&quot; that you can type to use them all, to minimize the collisions with the native keybindings. &lt;code&gt;:h leader&lt;/code&gt; will give you more information about this.&lt;/p&gt;&#xA;" OwnerUserId="2757" LastActivityDate="2016-07-07T16:11:51.143" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8650" PostTypeId="2" ParentId="8621" CreationDate="2016-07-07T16:14:20.433" Score="5" Body="&lt;p&gt;This is actually pretty simple. To match the second temp, allow anything followed by &quot;temp&quot; followed by anything, then look for temp again.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/.*temp.*\zstemp\.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\zs&lt;/code&gt; means &quot;Start the selection here&quot; so that the first part of the match (everything before the second temp) isn't removed. It's actually an extremely useful feature that I just learned about! Without it, the regex would have to look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(.*temp.*\)temp\./\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-07T16:14:20.433" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8651" PostTypeId="2" ParentId="8648" CreationDate="2016-07-07T16:15:29.143" Score="9" Body="&lt;p&gt;Yup it's &lt;code&gt;s&lt;/code&gt; in normal mode. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#s&quot;&gt;&lt;code&gt;:h s&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&quot;x]s           Delete [count] characters [into register x] and start&#xA;                insert (s stands for Substitute).  Synonym for &quot;cl&quot;&#xA;                (not linewise).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-07-07T16:15:29.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8652" PostTypeId="2" ParentId="8648" CreationDate="2016-07-07T17:03:19.083" Score="6" Body="&lt;p&gt;First off, Statox's answer is great. Use &lt;code&gt;s&lt;/code&gt;. But, I have a couple more thoughts beyond the answer that are a little more in depth than a comment is worth. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if we didn't have the 's' command, there is already a way to do this! Think about it. We have the command &lt;code&gt;change + motion&lt;/code&gt;. The &quot;motion&quot; is a single character. So it's just &lt;code&gt;cl&lt;/code&gt;. As far as I'm concerned, the &lt;code&gt;s&lt;/code&gt; command is just a synonym for &lt;code&gt;cl&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if we didn't have either of these features, there is a much more sensible way to implement them. Rather than doing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qx`xi`q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which would be a pain to record, and a pain to type &lt;code&gt;@x&lt;/code&gt; whenever you want this, you could just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap cx xi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-07T17:03:19.083" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8653" PostTypeId="1" AcceptedAnswerId="8656" CreationDate="2016-07-07T18:52:49.177" Score="6" ViewCount="198" Body="&lt;pre&gt;&lt;code&gt;autocmd FileType cpp nnoremap &amp;lt;buffer&amp;gt; C ct;&#xA;autocmd FileType cpp nnoremap &amp;lt;buffer&amp;gt; D dt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These two are quite useful, but sometimes there is no &lt;code&gt;;&lt;/code&gt; after the cursor and then &lt;code&gt;D&lt;/code&gt; doesn't do anything. And then I have to &lt;em&gt;press 3 keys to delete &lt;code&gt;t$&lt;/code&gt;&lt;/em&gt;. (!)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to check if the last action (i.e. &lt;code&gt;Dt;&lt;/code&gt;) didn't change anything, and in that case, execute something else (&lt;code&gt;Dt$&lt;/code&gt;)?&lt;br&gt;&#xA;or&lt;br&gt;&#xA;How how to check if there's a semicolon &lt;em&gt;after&lt;/em&gt; the cursor and do &lt;code&gt;Dt;&lt;/code&gt;, otherwise &lt;code&gt;Dt$&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3280" LastActivityDate="2016-07-07T21:23:49.457" Title="Delete to ; if exists, otherwise to end of line" Tags="|key-bindings|vimscript|vimrc|cursor-motions|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8654" PostTypeId="2" ParentId="8625" CreationDate="2016-07-07T18:58:03.400" Score="5" Body="&lt;p&gt;My strategy in such cases will vary, but it often follows the following steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Write the unique word(s), e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wordA&#xA;wordB&#xA;...&#xA;wordK&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Either&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) do a search and replace, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\w\+/similar text \0 similar text .../&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;b) or use visual block mode, see &lt;code&gt;:h blockwise-visual&lt;/code&gt;. In particular, I woul select the words and use &lt;code&gt;I&lt;/code&gt; to insert similar text in front, or &lt;code&gt;A&lt;/code&gt; to append similar text after.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I would argue that this strategy makes sense when you do this kind of editing task relatively seldom. However, if you find you need to do this often, then you should follow @statox's suggestion with a function that expands the list of words.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-07-07T18:58:03.400" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8655" PostTypeId="2" ParentId="8640" CreationDate="2016-07-07T19:15:36.087" Score="5" Body="&lt;p&gt;This should be possible with a &lt;code&gt;syntax region&lt;/code&gt;. If you put the following in your syntax file, it should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region Documentation&#xA;  \ start=/^\s*\[Documentation\]/&#xA;  \ end=/^\s*\[\|^\s*$/me=s-1&#xA;highlight link Documentation Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The highlight is only for testing to show that it works, and you probably both can and should use a different highlight. At least I think this will provide an example that you can build further upon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For relevant help, see&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :syn-region&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :syn-pattern&lt;/code&gt; (for the &lt;code&gt;me=s-1&lt;/code&gt; part)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-07-07T19:15:36.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8656" PostTypeId="2" ParentId="8653" CreationDate="2016-07-07T19:15:59.607" Score="7" Body="&lt;p&gt;This should do the trick for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; C (getline('.')[getpos('.')[2]:] =~ ';')? &quot;ct;&quot; : &quot;c$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; allows us to do conditional mapping&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;getline('.') =~ ';'&lt;/code&gt; searches the current line for a semicolon&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;getpos('.')[2]&lt;/code&gt; finds the column that the cursor is on and only searches after it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-07-07T19:15:59.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8657" PostTypeId="2" ParentId="8645" CreationDate="2016-07-07T19:27:58.763" Score="6" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;A macro is a sequence of keystrokes. Whether they are recorded or not, whether they are stored in a register or not is &lt;em&gt;completely&lt;/em&gt; irrelevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Macros can be recorded in an arbitrary register with &lt;code&gt;:help q&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa&#xA;2dw&#xA;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and played back with &lt;code&gt;:help @&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Macros can be saved into an arbitrary register via &lt;code&gt;:help y&lt;/code&gt; or via vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;ay&#xA;:let @a = 'd2w'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and used the same way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Macros can also be saved in a variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let foo = 'd2w'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and used in a slightly different way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@=foo&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Macros can also be typed verbatim in the command-line, to be executed with &lt;code&gt;:help :normal&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:normal! d2w&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Macros can also be saved for later in the form of a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;key&amp;gt; d2w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and used by pressing &lt;code&gt;&amp;lt;key&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In all the examples above, &lt;code&gt;d2w&lt;/code&gt; is your macro. All the rest is more or less orthogonal to that macro.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; key is not a special key &lt;em&gt;at all&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What you are trying to compare are two ways to play back macros, not… macros and something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are more comfortable with registers, use registers along with any of the register-related methods above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are more comfortable with mappings, use mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are just starting with Vim, try both and decide for yourself.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;a href=&quot;http://blog.extracheese.org/2010/11/screencast-custom-vim-refactorings.html&quot;&gt;The best Vim video ever&lt;/a&gt; happens to revolve largely around macros.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-07-07T19:27:58.763" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8658" PostTypeId="1" AcceptedAnswerId="8659" CreationDate="2016-07-07T20:48:36.403" Score="4" ViewCount="883" Body="&lt;p&gt;Is it possible to make Vim automatically exit whatever mode it's in and return to normal mode when the terminal window loses focus?&lt;/p&gt;&#xA;" OwnerUserId="8328" LastActivityDate="2016-07-07T21:22:08.197" Title="return to normal mode when the window loses focus" Tags="|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8659" PostTypeId="2" ParentId="8658" CreationDate="2016-07-07T21:08:41.920" Score="8" Body="&lt;p&gt;Add this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FocusLost * call feedkeys(&quot;\&amp;lt;esc&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This essentially means &quot;If we lose focus (&lt;code&gt;autocmd FocusLost&lt;/code&gt;) on any filetype (&lt;code&gt;*&lt;/code&gt;), then type an escape key as if I pressed it (&lt;code&gt;call feedkeys(&quot;\&amp;lt;esc&amp;gt;&quot;&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recommended reading: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#FocusLost&quot;&gt;&lt;code&gt;:help FocusLost&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html&quot;&gt;&lt;code&gt;:help autocommand&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Statox pointed out in the comments, this will only work for GVim, and certain terminals. &lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-07-07T21:22:08.197" LastActivityDate="2016-07-07T21:22:08.197" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8660" PostTypeId="1" AcceptedAnswerId="9048" CreationDate="2016-07-07T21:13:54.910" Score="3" ViewCount="1342" Body="&lt;p&gt;In &lt;code&gt;vim&lt;/code&gt;, the numerical &lt;kbd&gt;Enter ⎆&lt;/kbd&gt; key behaves differently from the carriage &lt;kbd&gt;Return ⏎&lt;/kbd&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any practical reason why the numerical &lt;kbd&gt;Enter ⎆&lt;/kbd&gt; behaves like that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can the numerical &lt;kbd&gt;Enter ⎆&lt;/kbd&gt; be made to behave like the carriage &lt;kbd&gt;Return ⏎&lt;/kbd&gt; key (including in combination with &lt;kbd&gt;Shift ⇧&lt;/kbd&gt; and if so, how?&lt;/p&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="3168" LastEditDate="2016-07-07T21:28:40.120" LastActivityDate="2016-08-02T09:52:50.297" Title="Can the ENTER key be made to behave like the RETURN key? Should I do so in vim?" Tags="|key-bindings|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8662" PostTypeId="2" ParentId="8621" CreationDate="2016-07-07T22:17:12.483" Score="18" Body="&lt;p&gt;In general you can match the Nth occurrence of something&#xA;using &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\{N}&lt;/code&gt;. There's an example given at &lt;code&gt;:help \zs&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case the command would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(.\{-}\zstemp\.\)\{2}//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-07-07T22:17:12.483" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8663" PostTypeId="2" ParentId="8621" CreationDate="2016-07-07T23:21:21.717" Score="1" Body="&lt;p&gt;There is nothing preventing you from using &lt;em&gt;two regexes&lt;/em&gt; instead of just one, i.e. change the first occurrence and then swap the columns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\.temp//|%s/^\(\S\+\)\(\s\+\)\(\S\+\)/\3\2\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Might not be extra clever but I find it very readable.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-07-07T23:21:21.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8665" PostTypeId="2" ParentId="8625" CreationDate="2016-07-08T02:07:30.697" Score="2" Body="&lt;p&gt;I'll argue that this is a job for the visual block (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;).  First I would write all distinct words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wordA&#xA;wordB&#xA;wordC&#xA;wordD&#xA;wordE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Starting with the cursor on the first &lt;code&gt;w&lt;/code&gt; I would then perform:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;c-v&amp;gt;5j$yA &amp;lt;esc&amp;gt;pA &amp;lt;esc&amp;gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can control how many columns I need by pressing &lt;code&gt;A &amp;lt;esc&amp;gt;p&lt;/code&gt; as many times I want.  Let's assume that I needed three columns just like the command above shows.  Now we have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wordA wordA wordA&#xA;wordB wordB wordB&#xA;wordC wordC wordC&#xA;wordD wordD wordD&#xA;wordE wordE wordE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the cursor is at the the beginning of the 3rd &lt;code&gt;wordA&lt;/code&gt; in the first line.   Next I would block select the column of whitespace between the columns going backward and adding the text in between.  From the current cursor location:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;h&amp;lt;c-v&amp;gt;5jI similar text 3&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This results in (the % marks the cursor position):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wordA wordA%similar text 3 wordA&#xA;wordB wordB similar text 3 wordB&#xA;wordC wordC similar text 3 wordC&#xA;wordD wordD similar text 3 wordD&#xA;wordE wordE similar text 3 wordE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Repeat for next column:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bh&amp;lt;c-v&amp;gt;5jI similar text 2&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the last/first (the one on the left side) column:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b&amp;lt;c-v&amp;gt;5jIsimilar text 1 &amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally resulting in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;similar text 1 wordA similar text 2 wordA similar text 3 wordA&#xA;similar text 1 wordB similar text 2 wordB similar text 3 wordB&#xA;similar text 1 wordC similar text 2 wordC similar text 3 wordC&#xA;similar text 1 wordD similar text 2 wordD similar text 3 wordD&#xA;similar text 1 wordE similar text 2 wordE similar text 3 wordE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Update: added a screencast&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ICcEL.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ICcEL.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This appears to be a lot of typing but it is actually very easy to get used to.  It provides you the freedom to change the number of words, number of columns and even spacing between the columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The drawback is that you need to know the &lt;em&gt;number&lt;/em&gt; of distinct words you're using.  I have a &lt;code&gt;5&lt;/code&gt; hardcoded in all commands above because it is the number of rows the commands are operating on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Debugging note: all commands start and end in normal mode, if you find yourself in visual or insert mode at the end of a command you're doing something wrong.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-07-09T00:05:33.887" LastActivityDate="2016-07-09T00:05:33.887" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8666" PostTypeId="2" ParentId="8621" CreationDate="2016-07-08T02:15:10.793" Score="3" Body="&lt;p&gt;Instead of regex, I'd go with a command which does:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Jump to end of line&lt;/li&gt;&#xA;&lt;li&gt;Search backwards for &lt;code&gt;temp&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Delete 5 characters&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and run it on every line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g//normal $?temp^[5x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NB. &lt;code&gt;^[&lt;/code&gt; is special and represents pressing the Escape key; you type it with: &lt;code&gt;Ctrl-q &amp;lt;Esc&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But a regex option, which I don't think has been suggested yet, is to match &lt;code&gt;temp.&lt;/code&gt; followed by anything except a &lt;code&gt;.&lt;/code&gt;, anchored to the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/temp\.\([^.]\+\)$/\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will match &lt;code&gt;temp.txt&lt;/code&gt; at the end of a line and replace it with just the &lt;code&gt;txt&lt;/code&gt; bit.&lt;/p&gt;&#xA;" OwnerUserId="8343" LastEditorUserId="8343" LastEditDate="2016-07-08T02:23:11.810" LastActivityDate="2016-07-08T02:23:11.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8667" PostTypeId="1" CreationDate="2016-07-08T08:13:29.720" Score="6" ViewCount="759" Body="&lt;p&gt;I was looking for a way to set &lt;code&gt;virtualedit=block&lt;/code&gt; before executing visual block select with additional binding &lt;code&gt;g&amp;lt;C-v&amp;gt;&lt;/code&gt; and after that turning it off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are few things in my workflow that require that behavior. I didn't find anything after some research. So currently I have this in my vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap g&amp;lt;C-v&amp;gt; :setl virtualedit=block&amp;lt;CR&amp;gt;&amp;lt;C-v&amp;gt;&#xA;nnoremap &amp;lt;C-v&amp;gt; :setl virtualedit=&amp;lt;CR&amp;gt;&amp;lt;C-v&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another example is to disable &lt;code&gt;incsearch&lt;/code&gt; for custom command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; K :setl nois&amp;lt;CR&amp;gt;:grep! &quot;\b&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;\b&quot;&amp;lt;CR&amp;gt;:setl is&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So my question is, is there right or just better than the one I came up with way to set option just for one command and switch it back after command is done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&#xA;Here is example of function that can help with second case&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Example()&#xA;  let &amp;amp;l:virtualedit=&quot;block&quot;&#xA;  exe &quot;normal \&amp;lt;C-v&amp;gt;&quot;&#xA;  let &amp;amp;l:virtualedit=&quot;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this way does not work for cases like in first example&lt;/p&gt;&#xA;" OwnerUserId="7820" LastEditorUserId="7820" LastEditDate="2016-07-08T11:51:50.520" LastActivityDate="2016-07-08T12:00:41.063" Title="Set option just for one command" Tags="|vimrc|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8668" PostTypeId="1" CreationDate="2016-07-08T08:28:12.523" Score="2" ViewCount="1339" Body="&lt;p&gt;I would like to execute a shell script, with parameters, from vim by mapping it to &lt;kbd&gt;F6&lt;/kbd&gt;, however the current mapping I have in my &lt;code&gt;.vimrc&lt;/code&gt; isn't working:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Map F6 to sync project changes to dev server&#xA;nmap &amp;lt;F6&amp;gt; :! ~/path/dev_sync.sh alistair /Users/user/svn&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess there might be a problem that it is in a different directory? Or perhaps the fact I have to pass in parameters? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried a few variations on this mapping and with no such luck, if anyone has any ideas it would be very appreciated, thank you.&lt;/p&gt;&#xA;" OwnerUserId="8346" LastEditorUserId="1821" LastEditDate="2016-07-08T09:46:38.587" LastActivityDate="2016-08-07T11:47:26.823" Title="Mapping key to execute shell script from vim" Tags="|key-bindings|vimrc|external-command|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="8670" PostTypeId="1" AcceptedAnswerId="8671" CreationDate="2016-07-08T10:21:57.137" Score="6" ViewCount="564" Body="&lt;p&gt;By default, Vim will fold everything it can if folding is enabled. This can be useful from big complicated files, but it tends to get in the way for smaller, simpler files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I open a code file that contains just one class, it makes no sense to have that class folded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think a reasonable metric for whether folding should happen, is the length of a file. If the file is much bigger than the terminal you're viewing it in, folding is probably beneficial. If it would (nearly) fit on a page unfolded, folding is probably more of a hindrance than a help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make Vim only enable folding only if the file you're opening is longer than some size?&lt;/p&gt;&#xA;" OwnerUserId="8349" LastEditorUserId="927" LastEditDate="2016-07-08T18:44:16.253" LastActivityDate="2016-07-08T20:35:23.323" Title="How can I enable folding only for files longer than a certain length?" Tags="|vimrc|folding|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8671" PostTypeId="2" ParentId="8670" CreationDate="2016-07-08T10:36:54.833" Score="9" Body="&lt;p&gt;You can use the &lt;code&gt;line()&lt;/code&gt; function to fold or unfold your file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; In your vimrc&#xA;&#xA;if line('$') &amp;gt; 20&#xA;   set foldlevel = 1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;line('$')&lt;/code&gt; returns the line number of the last (&lt;code&gt;$&lt;/code&gt;) line of your document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, this is executed only when you are launching Vim, so you can use a autocommand like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufReadPost * :if line('$') &amp;gt; 20 | set foldlevel=1 | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="927" LastEditDate="2016-07-08T20:35:23.323" LastActivityDate="2016-07-08T20:35:23.323" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8672" PostTypeId="2" ParentId="8670" CreationDate="2016-07-08T11:02:46.943" Score="3" Body="&lt;p&gt;Another way to do this, as you specified:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;if I open a code file that contains just one class [...]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can count the number of classes in your file and act based on the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let n=[0] | %s/^class/\=map(n,'v:val+1')[1:]/gen | if n[0] &amp;gt; 1 | set foldlevel=1 | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let n=[0]                Create an array to be filled with the number of occurence&#xA;%s/^class/               Substitute on all lines for the word class starting a line&#xA;\=map(n,'v:val+1')[1:]   Increment the n value on each found class&#xA;/en                      Don't move the cursor, and don't actually substitute&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The remaining is just a condition, like my other response. You can also use an autocommand for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The count method comes from Stack Overflow question &lt;em&gt;&lt;a href=&quot;https://stackoverflow.com/questions/8073780/using-vim-how-do-you-use-a-variable-to-store-count-of-patterns-found/8074421#8074421&quot;&gt;Using Vim, how do you use a variable to store count of patterns found?&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-07-08T18:44:04.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8673" PostTypeId="2" ParentId="8667" CreationDate="2016-07-08T11:25:40.017" Score="3" Body="&lt;p&gt;You could try calling a function from your mappings, which would save the current value of the relevant option, change the option, set an &lt;code&gt;autocmd&lt;/code&gt; (with &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-events&quot; rel=&quot;nofollow&quot;&gt;events&lt;/a&gt; such as &lt;code&gt;ShellCmdPost&lt;/code&gt;/&lt;code&gt;QuickFixCmdPost&lt;/code&gt; for grep/vimgrep, and &lt;code&gt;CursorMoved&lt;/code&gt;/&lt;code&gt;CursorMoved&lt;/code&gt; for the visual block), and then run the original command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But note that there may be better alternatives than switching those options. For example, if are creating a mapping for &lt;code&gt;:grep&lt;/code&gt; and wishes to disable &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27ignorecase%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;'ignorecase'&lt;/code&gt;&lt;/a&gt; (because as far as I understand &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27incsearch%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;'incsearch'&lt;/code&gt;&lt;/a&gt; won't affect this command) then you could add &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#/%5CC&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;\C&lt;/code&gt;&lt;/a&gt; in the begging of the pattern and leave the option unchanged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also some options which are commonly changed during a workflow. For those, you could try using &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow&quot;&gt;unimpaired plugin&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OPTION TOGGLING                                 unimpaired-toggling&#xA;&#xA;On      Off     Toggle  Option&#xA;[ob     ]ob     cob     'background' (dark is off, light is on)&#xA;[oc     ]oc     coc     'cursorline'&#xA;[od     ]od     cod     'diff' (actually |:diffthis| / |:diffoff|)&#xA;[oh     ]oh     coh     'hlsearch' (coh: first |:nohlsearch|, then |'nohlsearch'|)&#xA;[oi     ]oi     coi     'ignorecase'&#xA;[ol     ]ol     col     'list'&#xA;[on     ]on     con     'number'&#xA;[or     ]or     cor     'relativenumber'&#xA;[os     ]os     cos     'spell'&#xA;[ou     ]ou     cou     'cursorcolumn'&#xA;[ov     ]ov     cov     'virtualedit'&#xA;[ow     ]ow     cow     'wrap'&#xA;[ox     ]ox     cox     'cursorline' 'cursorcolumn' (x as in crosshairs)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are looking for &lt;em&gt;native&lt;/em&gt; solutions, them you should look in the built-in documentation. There are some commands for a few options, such as &lt;code&gt;:noswapfile&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nos[wapfile]   {command}           *:nos* *:noswapfile*&#xA;        Execute {command}. If it contains a command that loads a new&#xA;        buffer, it will be loaded without creating a swapfile and the&#xA;        'swapfile' option will be reset.  If a buffer already had a&#xA;        swapfile it is not removed and 'swapfile' is not reset.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;code&gt;:noautocmd&lt;/code&gt;, which disables autocmds. To search for more, you could try &lt;code&gt;:help :no&amp;lt;ctrl-d&amp;gt;&lt;/code&gt; to list the possible matches in the documentation that starts with &lt;code&gt;:no&lt;/code&gt;, or use &lt;code&gt;:helpgrep&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to the mapping+function workaround suggested above, you could implement a custom commands for options not covered by the built-in functionality -- this approach is used by some plugins, such as &lt;a href=&quot;https://github.com/dbakker/vim-projectroot/blob/master/doc/projectroot.txt#L112&quot; rel=&quot;nofollow&quot;&gt;ProjectRoot&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-07-08T12:00:41.063" LastActivityDate="2016-07-08T12:00:41.063" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8674" PostTypeId="1" CreationDate="2016-07-08T11:36:22.300" Score="13" ViewCount="2887" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%3Aset&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :set&lt;/code&gt;&lt;/a&gt; we&#xA;know that&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;:se[t]&lt;/code&gt;      Show all options that differ from their default value.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In a vimscript I'd like to save all these options which have been modified by&#xA;the user, modify them and later restore them to the value set by the user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do that easily?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have a way to simply store the result of &lt;code&gt;:set&lt;/code&gt; (or a similar command) into a variable that I could source or pass to another command later to restore what it contains?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or do I have to manually parse the output of the command (which I can do but is a lot of work for nothing if a simpler alternative exists)?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-11-22T10:17:11.967" LastActivityDate="2020-11-11T12:36:41.703" Title="How to save and restore the result of the command 'set'?" Tags="|vimscript|options|" AnswerCount="4" CommentCount="19" ContentLicense="CC BY-SA 3.0" />
  <row Id="8675" PostTypeId="2" ParentId="8668" CreationDate="2016-07-08T11:43:24.633" Score="1" Body="&lt;p&gt;You could try to &lt;code&gt;:echo&lt;/code&gt; the command in Vim instead of executing it in the shell to ensure it is what you expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, if you are starting to use mappings, you should definitively stick to the &lt;code&gt;noremap&lt;/code&gt; version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                *:nore* *:norem*&#xA;:no[remap]  {lhs} {rhs}         |mapmode-nvo|   *:no*  *:noremap* *:nor*&#xA;:nn[oremap] {lhs} {rhs}         |mapmode-n|     *:nn*  *:nnoremap*&#xA;:vn[oremap] {lhs} {rhs}         |mapmode-v|     *:vn*  *:vnoremap*&#xA;:xn[oremap] {lhs} {rhs}         |mapmode-x|     *:xn*  *:xnoremap*&#xA;:snor[emap] {lhs} {rhs}         |mapmode-s|     *:snor* *:snoremap*&#xA;:ono[remap] {lhs} {rhs}         |mapmode-o|     *:ono* *:onoremap*&#xA;:no[remap]! {lhs} {rhs}         |mapmode-ic|    *:no!* *:noremap!*&#xA;:ino[remap] {lhs} {rhs}         |mapmode-i|     *:ino* *:inoremap*&#xA;:ln[oremap] {lhs} {rhs}         |mapmode-l|     *:ln*  *:lnoremap*&#xA;:cno[remap] {lhs} {rhs}         |mapmode-c|     *:cno* *:cnoremap*&#xA;                        Map the key sequence {lhs} to {rhs} for the modes&#xA;                        where the map command applies.  Disallow mapping of&#xA;                        {rhs}, to avoid nested and recursive mappings.  Often&#xA;                        used to redefine a command.  {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your problem may be caused by some mapping in command mode which changes the command before executing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If such kind of problem persists, it is often a good idea to try to reproduce it with all your settings and plugins disable, by starting Vim with &lt;code&gt;vim -u NONE -U NONE -N -i NONE&lt;/code&gt;. You can find more about this on &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-2.5&quot; rel=&quot;nofollow&quot;&gt;Vim-FAQ  2.5 - &lt;em&gt;I have a &quot;xyz&quot; (some) problem with Vim. How do I determine it is a problem with my setup or with Vim?  / Have I found a bug in Vim?&lt;/em&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-07-08T11:43:24.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8676" PostTypeId="1" AcceptedAnswerId="8677" CreationDate="2016-07-08T11:47:24.550" Score="3" ViewCount="191" Body="&lt;p&gt;I have the following workflow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Create a new unnamed buffer with &lt;code&gt;:enew&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use a snippet to add a modeline to it. E.g. &lt;code&gt;vim:tw=80:ft=text:spell&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Once I've done that the modeline isn't applied and I can't do &lt;code&gt;:e %&lt;/code&gt; to reload&#xA;the buffer and apply the modeline since it is an unnamed buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do to apply the modeline in this unnamed buffer?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-11-22T10:14:52.617" Title="How to apply a modeline added to an unnamed buffer?" Tags="|modeline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8677" PostTypeId="2" ParentId="8676" CreationDate="2016-07-08T11:48:56.017" Score="6" Body="&lt;p&gt;If you look at the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#auto%2Dsetting&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h auto-setting&lt;/code&gt;&lt;/a&gt; help file, you will see that the options are set on different occasions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;At initialization&lt;/li&gt;&#xA;&lt;li&gt;On autocommands&lt;/li&gt;&#xA;&lt;li&gt;When starting editing the file with the modeline on&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can reload the modeline without actually reloading the buffer by calling manually an autocommand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:doautocmd BufRead&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will reload your modeline without reloading your file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you need to have set &lt;code&gt;modeline&lt;/code&gt; prior to this (otherwise the modeline won't be used).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference: &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#%3Adoautocmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :doautocmd&lt;/code&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: if you want to actually execute an autocommand without reloading the modeline, you can pass the &lt;code&gt;&amp;lt;nomodeline&amp;gt;&lt;/code&gt; to the &lt;code&gt;doautocmd&lt;/code&gt; method.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1841" LastEditDate="2016-11-22T10:14:52.617" LastActivityDate="2016-11-22T10:14:52.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8678" PostTypeId="2" ParentId="8674" CreationDate="2016-07-08T12:17:42.600" Score="4" Body="&lt;p&gt;You can access a setting's value using &lt;code&gt;let option_val = &amp;amp;option&lt;/code&gt; in a script.  What I've seen done is using a dict to store the options that you want to change.  You iterate over the dict to store the old value and set the new.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Example&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is a more direct approach.  I would use this if the settings are known ahead of time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:do_something() abort&#xA;  &quot; Options needed by the plugin&#xA;  let plugin_options = {&#xA;        \ 'list': 0,&#xA;        \ 'winfixwidth': 1,&#xA;        \ 'autoindent': 0,&#xA;        \ 'filetype': 'ini',&#xA;        \ }&#xA;&#xA;  echo 'desired:' plugin_options&#xA;&#xA;  for option in keys(plugin_options)&#xA;    execute 'let old_val = &amp;amp;'.option&#xA;    execute 'let &amp;amp;'.option.' = plugin_options[option]'&#xA;    let plugin_options[option] = old_val&#xA;  endfor&#xA;&#xA;  echo 'changed:' plugin_options&#xA;&#xA;  for option in keys(plugin_options)&#xA;    execute 'let &amp;amp;'.option.' = plugin_options[option]'&#xA;  endfor&#xA;endfunction&#xA;&#xA;&#xA;call s:do_something()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;plugin_options&lt;/code&gt; variable is scoped to the function, so it can be reused to store the old option values.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Advanced Example&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The script below will allow you to change the settings anywhere within your script while maintaining the original settings until you call &lt;code&gt;s:restore_settings()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:set(option, value) abort&#xA;  if !exists('b:_saved_settings')&#xA;    let b:_saved_settings = {}&#xA;  endif&#xA;&#xA;  &quot; Only save the original values&#xA;  if !has_key(b:_saved_settings, a:option)&#xA;    execute 'let b:_saved_settings[a:option] = &amp;amp;'.a:option&#xA;  endif&#xA;&#xA;  execute 'let &amp;amp;'.a:option.' = a:value'&#xA;endfunction&#xA;&#xA;function! s:restore_settings(...) abort&#xA;  if !exists('b:_saved_settings')&#xA;    return&#xA;  endif&#xA;&#xA;  if a:0&#xA;    for option in a:000&#xA;      if has_key(b:_saved_settings, option)&#xA;        execute 'let &amp;amp;'.option.' = b:_saved_settings[option]'&#xA;        call remove(b:_saved_settings, option)&#xA;      endif&#xA;    endfor&#xA;  else&#xA;    for option in keys(b:_saved_settings)&#xA;      execute 'let &amp;amp;'.option.' = b:_saved_settings[option]'&#xA;    endfor&#xA;&#xA;    unlet! b:_saved_settings&#xA;  endif&#xA;endfunction&#xA;&#xA;&#xA;&quot; Options needed by the plugin&#xA;call s:set('list', 0)&#xA;call s:set('winfixwidth', 1)&#xA;call s:set('autoindent', 0)&#xA;call s:set('filetype', 'ini')&#xA;&#xA;echo 'original:' b:_saved_settings&#xA;call s:restore_settings('list', 'filetype')&#xA;echo 'partial restore:' b:_saved_settings&#xA;&#xA;call s:restore_settings()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s:set()&lt;/code&gt; is somewhat similar to &lt;code&gt;set&lt;/code&gt;.  It will save the original setting's value if it hasn't been saved yet, then use your setting's value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calling &lt;code&gt;s:restore_settings()&lt;/code&gt; without arguments will do a full restore of your changes.  With arguments, it will partially restore them.  If you decide to use this, it would be worth calling &lt;code&gt;s:restore_settings()&lt;/code&gt; before initially calling &lt;code&gt;s:set()&lt;/code&gt; in case your script previously ran into an error before restoration.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-07-08T14:47:07.640" LastActivityDate="2016-07-08T14:47:07.640" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8680" PostTypeId="1" CreationDate="2016-07-08T19:06:30.177" Score="2" ViewCount="2649" Body="&lt;p&gt;Let's say I do a simple shell command like &lt;code&gt;ls&lt;/code&gt;. Is there some way to directly pipe the output into a new vim buffer, so that I could edit it in place or just have a look at it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically like &lt;code&gt;less&lt;/code&gt; + the ability to edit it and directly save it in some place on the system?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-07-08T20:29:04.133" Title="Is there some way to echo from terminal into new vim buffer" Tags="|options|startup|" AnswerCount="2" CommentCount="1" ClosedDate="2016-07-09T14:03:31.817" ContentLicense="CC BY-SA 3.0" />
  <row Id="8681" PostTypeId="2" ParentId="8680" CreationDate="2016-07-08T19:20:56.207" Score="5" Body="&lt;p&gt;You can do this from directly inside of vim with the &lt;code&gt;:read&lt;/code&gt; command, which is abbreviated to &lt;code&gt;:r&lt;/code&gt; The 'read' command is intended to allow you to read a file, e.g. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will insert the contents of &lt;code&gt;foo.txt&lt;/code&gt; after your current cursor position. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help :r&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *:r* *:re* *:read*&#xA;:r[ead] [++opt] [name]&#xA;            Insert the file [name] (default: current file) below&#xA;            the cursor.&#xA;            See |++opt| for the possible values of [++opt].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, you can read a command that outputs to STOUT just as if it was a file. To call the external command, just prepend an exclamation mark. This gives us:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r !ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also do this from the terminal before you start vim by using pipes. For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls | vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, you must explicitly tell vim to read from STDIN, which can by starting vim with a &lt;code&gt;-&lt;/code&gt; at the end. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From :help --`&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *--*&#xA;-       This argument can mean two things, depending on whether Ex&#xA;        mode is to be used.&#xA;&#xA;        Starting in Normal mode: &amp;gt;&#xA;            vim -&#xA;            ex -v -&#xA;        Start editing a new buffer, which is filled with text&#xA;        that is read from stdin.  The commands that would normally be&#xA;        read from stdin will now be read from stderr.  Example: &amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-08T19:20:56.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8682" PostTypeId="2" ParentId="8680" CreationDate="2016-07-08T19:29:53.637" Score="2" Body="&lt;p&gt;If you want to just get the input from a terminal command, then just do the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Same for any other command output you want to pipe to Vim.&#xA;If you want to read the output you can use &lt;code&gt;read&lt;/code&gt; or &lt;code&gt;r&lt;/code&gt; as already mentioned. You can also use the dot (&lt;code&gt;.&lt;/code&gt;) to do the same. &#xA;So doing this, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;: . !ls &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will give the same result as using &lt;code&gt;read&lt;/code&gt;. &#xA;Similarly for inserting date, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;: . !date&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="5481" LastEditDate="2016-07-08T20:29:04.133" LastActivityDate="2016-07-08T20:29:04.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8683" PostTypeId="1" AcceptedAnswerId="8684" CreationDate="2016-07-08T19:40:43.567" Score="5" ViewCount="298" Body="&lt;p&gt;Sometimes in a diff I want to obtain just the single line that I'm on. So I made the following mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap dO :.diffget&amp;lt;CR&amp;gt;&#xA;nnoremap dP :.diffput&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This worked well, &lt;em&gt;except&lt;/em&gt; now whenever I do &lt;code&gt;dd&lt;/code&gt; it sits and waits for more input since the last &lt;code&gt;d&lt;/code&gt; could be the start of one of my new mappings. Now, of course I &lt;em&gt;could&lt;/em&gt; just change my mappings to something different to solve this problem, but this means that I can't use &lt;strong&gt;any&lt;/strong&gt; of the &lt;code&gt;d&lt;/code&gt; namespace that &lt;a href=&quot;http://vimcasts.org/blog/2014/02/follow-my-leader/&quot; rel=&quot;nofollow&quot;&gt;isn't currently being used&lt;/a&gt; which is quite unfortunate. I want vim to understand that I'm simply trying to extend the &lt;code&gt;d&lt;/code&gt; namespace. &lt;code&gt;dd&lt;/code&gt; is a finished command and &lt;code&gt;ddO&lt;/code&gt; is invalid, therefore there is no need to wait after &lt;code&gt;dd&lt;/code&gt; has been entered. Is there a way to accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-07-08T21:03:15.457" LastActivityDate="2016-07-09T02:56:15.397" Title="Mapping without polluting the original operator" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8684" PostTypeId="2" ParentId="8683" CreationDate="2016-07-08T20:29:31.450" Score="9" Body="&lt;p&gt;What you're referring to as a &quot;namespace&quot; is an &lt;code&gt;operator&lt;/code&gt;.  When you press &lt;code&gt;d&lt;/code&gt;, you are put in &lt;code&gt;Operator-pending&lt;/code&gt; mode.  That is, the operator is waiting for a key (typically a motion to define a range) before executing their respective commands, such as &lt;code&gt;:delete&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change your maps to operator maps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;expr&amp;gt; O v:operator == 'd' ? ':.diffget&amp;lt;cr&amp;gt;' : '&amp;lt;esc&amp;gt;'&#xA;onoremap &amp;lt;expr&amp;gt; P v:operator == 'd' ? ':.diffput&amp;lt;cr&amp;gt;' : '&amp;lt;esc&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Operator maps aren't usable until you're in &lt;code&gt;Operator-pending&lt;/code&gt; mode.  That means that the maps above could be used with &lt;em&gt;all&lt;/em&gt; operators.  But you only want it to work with &lt;code&gt;d&lt;/code&gt;, so check to see if the pending operator is &lt;code&gt;d&lt;/code&gt; before allowing &lt;code&gt;O&lt;/code&gt; and &lt;code&gt;P&lt;/code&gt; to be used for the diff commands.  Using another operator such as &lt;code&gt;cO&lt;/code&gt; would return &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; cancelling the operator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Operator maps can be more complicated than this.  Read &lt;code&gt;:h omap-info&lt;/code&gt;, &lt;code&gt;:h 'operatorfunc'&lt;/code&gt;, &lt;code&gt;:h v:operator&lt;/code&gt; and &lt;code&gt;:h g@&lt;/code&gt; to learn more about them.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-07-09T02:56:15.397" LastActivityDate="2016-07-09T02:56:15.397" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8685" PostTypeId="1" AcceptedAnswerId="8690" CreationDate="2016-07-08T21:00:11.017" Score="8" ViewCount="1923" Body="&lt;p&gt;I've enabled &lt;code&gt;set nowrap&lt;/code&gt; since I find that line wrapping makes it harder for me to quickly scan a document. It's also annoying having to scroll right to see the entire line that I am working on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if there's a way to enable line-wrapping only on the line that my cursor is currently on and exclude all other lines.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2022-12-02T16:19:19.933" Title="Vim wrap only current line" Tags="|wrapping|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8686" PostTypeId="2" ParentId="8685" CreationDate="2016-07-08T21:24:11.010" Score="1" Body="&lt;p&gt;I don't think setting the line-wrapping for just a single line is possible. &#xA;But, there is a small work around that you can use to see the entire content of the current line. &#xA;First set the text width as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set textwidth=80 &quot;Any number that works for you&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then to format the current line do a &lt;code&gt;gqq&lt;/code&gt; on it and now you should be able to see your entire line. (&lt;code&gt;help gqq&lt;/code&gt; for more)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But Unfortunately, this doesn't preserve the line number of the original line since it breaks the lines in to multiple lines. So, you have to undo the change every time you do this. I hope there is a better way than this but this is what I can think of now. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This whole process might become easier if you can put a &lt;code&gt;toggle&lt;/code&gt; mapping of this with your &lt;code&gt;Leader&lt;/code&gt; key. That way it should be much  faster. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: As pointed out in the comments, this method won't work when you've to edit a line because that will be in your undo stack. If you are using an Undo Tree plugin like GUndo or UndoTree, it should be fine for you as you can go back and forth in the list.&lt;/p&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="5481" LastEditDate="2016-07-09T07:07:46.217" LastActivityDate="2016-07-09T07:07:46.217" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8687" PostTypeId="2" ParentId="4643" CreationDate="2016-07-08T21:26:54.487" Score="4" Body="&lt;p&gt;The most obvious use case I can think of is programming. Have you ever wanted to run tests inside Vim, or compile, or use any console tool? I know people use Tmux, but now that you can do it inside Neovim I have to say, this is pretty awesome.&lt;/p&gt;&#xA;&lt;p&gt;If you use buffers you can add, remove, hide and show terminals as you please. That's the profit ;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8XY2H.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8XY2H.png&quot; alt=&quot;Running a shell inside Neovim&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8360" LastEditorUserId="8558" LastEditDate="2022-01-01T19:11:56.033" LastActivityDate="2022-01-01T19:11:56.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8688" PostTypeId="2" ParentId="8685" CreationDate="2016-07-08T21:47:18.533" Score="4" Body="&lt;p&gt;Soft wrapping per line is not possible.  All you can really do is manually wrap the line with &lt;code&gt;gql&lt;/code&gt; and undo it after you're done looking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might not be the exact answer that you're looking for, but you can make horizontal scrolling more ergonomic.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;left&amp;gt; 5zh&#xA;nnoremap &amp;lt;right&amp;gt; 5zl&#xA;xnoremap &amp;lt;left&amp;gt; 5zh&#xA;xnoremap &amp;lt;right&amp;gt; 5zl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;code&gt;&amp;lt;left&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;right&amp;gt;&lt;/code&gt; arrows, you'll horizontally scroll by 5 characters.  You can adjust the count to what feels right.  A count can be used to make bigger horizontal jumps.  Since &lt;code&gt;5&lt;/code&gt; is used in the map, &lt;code&gt;5&amp;lt;right&amp;gt;&lt;/code&gt; would jump 25 characters to the right.  The key can be held to keep scrolling, but the count won't be repeated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to use the arrow keys, you could still use &lt;code&gt;zh&lt;/code&gt;, &lt;code&gt;zl&lt;/code&gt;, &lt;code&gt;zH&lt;/code&gt;, and &lt;code&gt;zL&lt;/code&gt; a little more efficiently using the &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow&quot;&gt;vim-repeat&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:scroll(keys) abort&#xA;  silent! call repeat#set(a:keys, v:count1)&#xA;  execute 'normal! '.v:count1.a:keys&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; zh :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;scroll('zh')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; zl :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;scroll('zl')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; zH :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;scroll('zH')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; zL :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;scroll('zL')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;vim-repeat&lt;/code&gt; involved, you initiate scrolling with the standard horizontal scroll maps, then hold &lt;code&gt;.&lt;/code&gt; to keep repeating it. In this method, using a count (like &lt;code&gt;5zl&lt;/code&gt;) will be repeated.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-07-09T03:00:01.727" LastActivityDate="2016-07-09T03:00:01.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8689" PostTypeId="2" ParentId="8621" CreationDate="2016-07-09T03:02:58.740" Score="12" Body="&lt;p&gt;This solution is similar to TessellatingHeckler's but is more easily adapted to whatever pattern has to be deleted.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/temp\./normal 2ngnd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's how it works:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:g/temp\./&lt;/code&gt; for every line matching &quot;temp.&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal&lt;/code&gt; execute the following in normal mode&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;code&gt;2n&lt;/code&gt; find the second ocurrence of the pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gn&lt;/code&gt; select it&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d&lt;/code&gt; and delete it.&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This will work for whatever pattern is given to &lt;code&gt;:g&lt;/code&gt;.&#xA;&lt;code&gt;normal&lt;/code&gt; may be abbreviated to &lt;code&gt;norm&lt;/code&gt;.&#xA;&lt;code&gt;gnd&lt;/code&gt; is equivalent to &lt;code&gt;dgn&lt;/code&gt;.&#xA;&lt;em&gt;Edit: In fact &lt;code&gt;2ngnd&lt;/code&gt; is equivalent to &lt;code&gt;d2gn&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vim.wikia.com/wiki/Power_of_g&quot;&gt;the Vim Tips Wiki&lt;/a&gt; for more examples of the global command.&lt;/p&gt;&#xA;" OwnerUserId="8311" LastActivityDate="2016-07-09T03:02:58.740" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8690" PostTypeId="2" ParentId="8685" CreationDate="2016-07-09T04:41:48.280" Score="6" Body="&lt;p&gt;I was thinking about this more.  You can't wrap just the current line in the current window, but you can open the buffer in a new window and enable wrapping there without affecting your current window.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Use a new window&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;split | setlocal wrap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After you're done, close the window that has wrapping enabled.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Use a new tab&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If your horizontal space is limited because you're using multiple windows, opening a new tab will let you use the full terminal size without losing your current window layout.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tabedit % | setlocal wrap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since it's the only window in that tab, you can close it with &lt;code&gt;:q&lt;/code&gt; instead of &lt;code&gt;:tabclose&lt;/code&gt;.  You don't even have to write the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either of the options above can be made into quick keys:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;s :&amp;lt;c-u&amp;gt;split&amp;lt;cr&amp;gt;:setlocal wrap&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;t :&amp;lt;c-u&amp;gt;tabedit %&amp;lt;cr&amp;gt;:setlocal wrap&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Use NrrwRgn&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Another way of editing the lines in a split is using &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn&quot; rel=&quot;noreferrer&quot;&gt;NrrwRgn&lt;/a&gt;.  It's a plugin that takes a range of lines and isolates them in a new window.  You select the lines you want to focus on and press &lt;code&gt;&amp;lt;leader&amp;gt;nr&lt;/code&gt;.  The drawback to this is that it's a new buffer and you won't have the undo history from the original buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This autocmd will set the wrap option in the NrrwRgn window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType * if exists('w:nrrw_rgn_id') | setlocal wrap | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;FileType&lt;/code&gt; had to be used because &lt;code&gt;BufWinEnter&lt;/code&gt; doesn't trigger.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-07-09T04:41:48.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8691" PostTypeId="2" ParentId="8231" CreationDate="2016-07-09T05:59:09.000" Score="1" Body="&lt;p&gt;A simple solution would be pressing x in normal mode. This will delete spaces one by one, no matter what are your settings.&lt;/p&gt;&#xA;" OwnerUserId="8360" LastActivityDate="2016-07-09T05:59:09.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8692" PostTypeId="1" AcceptedAnswerId="8748" CreationDate="2016-07-09T06:07:39.727" Score="12" ViewCount="1569" Body="&lt;p&gt;I mapped &lt;code&gt;zz&lt;/code&gt; to &lt;code&gt;1z=&lt;/code&gt;, which is great most of the time, but every now and then the first suggestion isn't the right one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'd like to keep repeating &lt;code&gt;zz&lt;/code&gt; (or &lt;code&gt;.&lt;/code&gt;) to cycle through the other suggestions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A second &lt;code&gt;zz&lt;/code&gt; on the same word, then, would work like &lt;code&gt;u2z=&lt;/code&gt;, a third &lt;code&gt;zz&lt;/code&gt; would work like &lt;code&gt;u3z=&lt;/code&gt; and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to do that?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on @nobe4's awesome answer I managed to do what I want, but I'll leave it here for a while in case anyone has any improvements or suggestions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:spell_position = []&#xA;let s:spell_count = 0&#xA;let s:spell_word = &quot;&quot;&#xA;&#xA;function! LoopSpell()&#xA;&#xA;    if s:spell_position != getpos('.') ||&#xA;            \ (s:spell_count &amp;gt; 0 &amp;amp;&amp;amp; s:spell_word !~ expand(&quot;&amp;lt;cword&amp;gt;&quot;))&#xA;        let s:spell_count = 0&#xA;        let s:spell_position = getpos('.')&#xA;    endif&#xA;&#xA;    if s:spell_count &amp;gt; 0&#xA;        silent execute &quot;normal! u&quot;&#xA;    endif&#xA;&#xA;    let s:current_word = expand(&quot;&amp;lt;cword&amp;gt;&quot;)&#xA;    if len(s:current_word) &amp;lt;= 0&#xA;        return&#xA;    endif&#xA;&#xA;    let s:spell_suggestions = spellsuggest(expand(s:current_word))&#xA;    if len(s:spell_suggestions) &amp;lt;= 0&#xA;        return&#xA;    endif&#xA;&#xA;    if s:spell_count &amp;gt;= len(s:spell_suggestions)&#xA;        let s:spell_word = s:current_word&#xA;        let s:spell_count = 0&#xA;    else&#xA;        let s:spell_word = s:spell_suggestions[s:spell_count]&#xA;        let s:spell_count += 1&#xA;    endif&#xA;    silent execute &quot;normal! ciw&quot; . s:spell_word&#xA;    let s:spell_position = getpos('.')&#xA;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;c-m&amp;gt; :call LoopSpell()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I changed the mapping to &lt;code&gt;&amp;lt;c-m&amp;gt;&lt;/code&gt; because of @Vitor's comment. Also this allows me to hold those keys down and sort of scroll through the suggestions really fast. I'm thinking of it as &lt;code&gt;&amp;lt;c-mistake&amp;gt;&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="7642" LastEditDate="2016-07-12T20:32:21.610" LastActivityDate="2016-08-08T01:31:48.283" Title="Command to loop through spelling suggestions" Tags="|key-bindings|vimscript|spell-checking|functions|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8693" PostTypeId="1" AcceptedAnswerId="8702" CreationDate="2016-07-09T08:50:49.637" Score="5" ViewCount="3562" Body="&lt;p&gt;I usually work on tabs in Vim, and on many occasions, I end up requiring a shell to do run some command, etc. (&lt;code&gt;Escape&lt;/code&gt; -&gt; &lt;code&gt;:!sh&lt;/code&gt;). Is there any way I can open the shell in only one tab in Vim? I would like to be able to switch between tabs containing the files I'm editing, and the shell. Right now, when I type in &lt;code&gt;:!sh&lt;/code&gt;, all the tabs go away, and are replaced by the shell.&lt;/p&gt;&#xA;" OwnerUserId="8365" LastActivityDate="2020-02-06T19:00:55.703" Title="How do I open a shell in only one tab in Vim?" Tags="|tabbed-user-interface|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8696" PostTypeId="1" AcceptedAnswerId="8700" CreationDate="2016-07-09T12:55:43.033" Score="4" ViewCount="119" Body="&lt;p&gt;I've got this 4-line content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;baa&#xA;baz&#xA;quz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'd like to replace &lt;code&gt;baa&lt;/code&gt; to &lt;code&gt;bar&lt;/code&gt; only when &lt;code&gt;quz&lt;/code&gt; is found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried these commands (which highlights &lt;code&gt;baa&lt;/code&gt; correctly, but says it's not found):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/quz/s/baa/bar/&#xA;:/quz/1,$s@baa@bar@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E486: Pattern not found: baa&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/quz/%s/baa/bar/&#xA;:/baa/,/quz/%s/baa/bar/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E488: Trailing characters&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/quz/s/baa/bar/&#xA;/quz/%s/baa/bar/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;search hit BOTTOM, continuing at TOP&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What I am doing wrong? What is the correct syntax?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2016-07-09T19:06:46.787" LastActivityDate="2016-07-09T19:06:46.787" Title="How to change text in other line when the pattern is found?" Tags="|substitute|replace|multiple-lines|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8697" PostTypeId="2" ParentId="8696" CreationDate="2016-07-09T13:06:24.893" Score="2" Body="&lt;p&gt;Ok, it was very close and this actually worked:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/baa/,/quz/s/baa/bar/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="467" LastActivityDate="2016-07-09T13:06:24.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8699" PostTypeId="2" ParentId="8692" CreationDate="2016-07-09T14:07:59.383" Score="5" Body="&lt;p&gt;As @statox suggested, you can use the plugin I wrote: &lt;a href=&quot;https://github.com/nobe4/vimcorrect&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimcorrect&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll explain basically how it works, so if you want to reuse some part of it, you can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To focus on the next misspelled word I use directly &lt;code&gt;]s&lt;/code&gt; and &lt;code&gt;[s&lt;/code&gt; as they jump to the next/previous match. I defined a custom match function to highlight the current word:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E7Rb6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E7Rb6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matchadd('error', '\%'.line('.').'l'.'\%'.col('.').'c'.s:current_word)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which add to the match group &lt;code&gt;error&lt;/code&gt; the current word at the current line/column (to prevent multiple matching on the same line).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;spellbadword()&lt;/code&gt; function return a list of possible correction for the word under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I simply display this list in a buffer, and I map &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to replace the misspelled word by the current line (i.e. a possible corrected word).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I also map &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; to &lt;code&gt;]s&lt;/code&gt; and &lt;code&gt;[s&lt;/code&gt;, as I am used to press them to search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;q&lt;/code&gt; is mapped to quit the plugin, close the split and remove the highlight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: it's still highly unstable, but I plan on making some change soon. If you feel like you can/want to improve this plugin, feel free to fork/open a pull request.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-09T14:07:59.383" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8700" PostTypeId="2" ParentId="8696" CreationDate="2016-07-09T16:06:07.660" Score="4" Body="&lt;p&gt;&lt;code&gt;:/baa/,/quz/s/baa/bar/&lt;/code&gt; works, but that will only work with the first occurrence of &lt;code&gt;baa&lt;/code&gt;.  If you want to replace all occurrences of &lt;code&gt;baa&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt; that come before &lt;code&gt;quz&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;,/quz/s/baa/bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your scenario calls for replacing all occurrences of &lt;code&gt;baa&lt;/code&gt; if &lt;code&gt;quz&lt;/code&gt; is found:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; /quz/,%s/baa/bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will replace all occurrences of &lt;code&gt;baa&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt; if &lt;code&gt;quz&lt;/code&gt; is found.  This is basically using the range &lt;code&gt;/quz/,1,$&lt;/code&gt; which is permitted  (&lt;code&gt;%&lt;/code&gt; is equivalent to &lt;code&gt;1,$&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h cmdline-ranges&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If more line specifiers are given than required for the command, the first one(s) will be ignored.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So if the first line specifier &lt;code&gt;/quz/&lt;/code&gt; fails, it generates an error and causes the rest of the command to not execute.  But, if it does find a match, the &lt;code&gt;1,$&lt;/code&gt; range is used since substitution only needs 2 range specifiers.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Conditional substitution&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you want to conditionally replace &lt;code&gt;baa&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt;, you'll want to use the &lt;code&gt;:global&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want replace &lt;code&gt;baa&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt; if it comes &lt;em&gt;before&lt;/em&gt; &lt;code&gt;quz&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/quz/?baa?,s//bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/quz/   - Moves to the next 'quz'&#xA;?baa?,   - Create a range from the last 'baa' to the current line&#xA;s//bar   - Reuse the previous pattern (baa) and substitute with 'bar'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, that only matches the first &lt;code&gt;baa&lt;/code&gt; that comes before &lt;code&gt;quz&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to replace all occurrences of &lt;code&gt;baa&lt;/code&gt; that comes &lt;em&gt;before&lt;/em&gt; &lt;code&gt;quz&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/quz/?quz\|\%^?,s/baa/bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/quz/       - Moves to the next 'quz'&#xA;?quz\|\%^?,  - Create a range from the previous 'quz' or the&#xA;               beginning of the buffer.&#xA;s/baa/bar    - Replace 'baa' with 'bar'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to replace all occurrences of &lt;code&gt;baa&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt; if they're &lt;em&gt;between&lt;/em&gt; two &lt;code&gt;quz&lt;/code&gt; lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/quz/silent! ??,s/baa/bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/quz/      - Moves to the next 'quz'&#xA;silent!     - The first occurence of 'quz' won't have a previous&#xA;              'quz' match. So, ignore the error about an invalid&#xA;              range.&#xA;??,         - Reuse 'quz' pattern to search for the previous occurrence&#xA;s/baa/bar   - Replace 'baa' with 'bar'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-07-09T16:06:07.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8702" PostTypeId="2" ParentId="8693" CreationDate="2016-07-09T16:36:58.803" Score="3" Body="&lt;p&gt;UPDATE AS OF VIM 8 and 9: Vim now has an in-built terminal.  It works reasonably on most OSes (at least far more consistently than terminal extensions).  For the question at hand. &lt;code&gt;:tab teminal&lt;/code&gt; does the job pefectly.  The workarounds are now only needed for Vim 7 and lower.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As AI.G. said &lt;code&gt;neovim&lt;/code&gt; is an option, it has a built in terminal emulator.  Yet, if you are not afraid of using a &lt;code&gt;python&lt;/code&gt; based plugin in Vim, have a look at the &lt;a href=&quot;https://code.google.com/archive/p/conque/&quot; rel=&quot;nofollow noreferrer&quot;&gt;conque&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;conque&lt;/code&gt; can not only run a terminal but almost any interactive command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YscQO.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YscQO.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can even exit insert mode in the shell (or &lt;code&gt;lynx&lt;/code&gt; as in the example) and use visual mode to yank into a register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;conque&lt;/code&gt; requires &lt;code&gt;python&lt;/code&gt;, and, if you are not on a *nix OS, also requires &lt;code&gt;cygwin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There are some issues with keybindings if you try to run Vim, inside a shell inside a Vim tab.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2020-02-06T19:00:55.703" LastActivityDate="2020-02-06T19:00:55.703" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8703" PostTypeId="1" CreationDate="2016-07-09T16:55:01.737" Score="3" ViewCount="168" Body="&lt;p&gt;My situation is, I have &lt;code&gt;set nowrapscan&lt;/code&gt;, however now, when I hit the end of a file, it will display&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E385: search hit BOTTOM without match for: \v^[^=]*(…&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I avoid that from displaying? I used &lt;code&gt;help&lt;/code&gt; but couldn't find anything about it.&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-07-10T09:54:24.463" Title="How to not display a certain error" Tags="|search|options|error|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8704" PostTypeId="1" CreationDate="2016-07-09T17:37:11.833" Score="2" ViewCount="914" Body="&lt;p&gt;I have the following autocmd to search for function definitions in C files. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype c,cpp execute &quot;nnoremap ]m /\\v^[^=]*(([a-zA-Z_][a-zA-Z_0-9]+)|(operator .*))\\(.*\\)( const|:)?( \\{)?$\&amp;lt;cr&amp;gt;:nohl\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As I have &lt;code&gt;incsearch&lt;/code&gt; defined, it will hightlight all the matches, why I can &lt;code&gt;:nohl&lt;/code&gt; at the end.&#xA;However the search fails if there are no matches found, and the :nohl is not executed in this case&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be fine, if the search didn't fail and throw an error if it found nothing, but would just didn't change the cursor (which it should).&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-07-09T18:32:02.927" Title="Don't fail if pattern is not found" Tags="|search|error|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8705" PostTypeId="2" ParentId="8703" CreationDate="2016-07-09T18:07:01.900" Score="2" Body="&lt;p&gt;you can use a custom command, if &lt;code&gt;:sil norm! n&lt;/code&gt; is too much to type in interactive mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:com! :Nextmatch :sil :norm n&#xA;:nnoremap &amp;lt;silent&amp;gt; n :Nextmatch&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="1821" LastEditDate="2016-07-10T09:54:24.463" LastActivityDate="2016-07-10T09:54:24.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8706" PostTypeId="2" ParentId="8704" CreationDate="2016-07-09T18:32:02.927" Score="4" Body="&lt;p&gt;Here's a mapping that won't change the last search register or print errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; ]m filter([search('pattern', 'nW'), line('.')], 'v:val')[0].'G'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;filter()&lt;/code&gt; takes a list of items and returns a list containing the ones that are satisfied by the second argument.  It's using a simple &lt;code&gt;'v:val'&lt;/code&gt; to evaluate the item as a boolean.  Note that it's using the first item from the filtered list: &lt;code&gt;filter(...)[0].'G'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;search()&lt;/code&gt; returns a matching line number on success, it will be the first item in that list.  If there is no match, it'll return &lt;code&gt;0&lt;/code&gt; and won't be in the filtered list.  As a fallback, the current line number is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the pattern matches on line &lt;code&gt;15&lt;/code&gt; the map expression will return &lt;code&gt;15G&lt;/code&gt; which jumps to that line.  Since &lt;code&gt;G&lt;/code&gt; is a jump motion, the jump list will be updated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can work in the opposite direction by adding the &lt;code&gt;b&lt;/code&gt; flag to the search flags:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; [m filter([search('pattern', 'bnW'), line('.')], 'v:val')[0].'G'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you wanted it to wrap around the buffer, you could remove the &lt;code&gt;W&lt;/code&gt; flag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A real example of this working:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc_fugitive&#xA;  autocmd!&#xA;  autocmd FileType gitcommit&#xA;        \ nnoremap &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; } filter([search('\%(\_^#\?\s*\_$\)\\|\%$', 'nW'), line('$')], 'v:val')[0].'G' |&#xA;        \ nnoremap &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; { max([1, search('\%(\_^#\?\s*\_$\)\\|\%^', 'nbW')]).'G'&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is what I'm using to get paragraph motions back in &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow&quot;&gt;vim-fugitive&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-07-09T18:32:02.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8707" PostTypeId="1" AcceptedAnswerId="8708" CreationDate="2016-07-09T23:39:52.093" Score="13" ViewCount="2782" Body="&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update 2020-07-17&lt;/strong&gt;: Now I would recommend using the &lt;a href=&quot;https://github.com/andymass/vim-matchup&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-matchup&lt;/a&gt; plugin. When matching pair highlighting is turned on, vim-matchup also highlights matching keywords like &lt;code&gt;if/else/endif&lt;/code&gt; or &lt;code&gt;while/continue/break&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update 2017-12-04&lt;/strong&gt;: I've updated the answer by @Tommy A below to account for poorly specified &lt;code&gt;matchit.vim&lt;/code&gt; groups, and other situations where the &lt;code&gt;%&lt;/code&gt; operator does not return the cursor to the original position, ever. Check out the differences in the &amp;quot;while&amp;quot; loop. Anyone reading this thread is advised to use this version, to avoid infinite loops:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Loop until `%` returns the original line number. Abort if:&#xA;&amp;quot; (1) the % operator keeps us on the same line, or&#xA;&amp;quot; (2) the % operator doesn't return us to the same line after some nubmer of jumps&#xA;function! s:get_match_lines(line) abort&#xA;  let a:tolerance = 25&#xA;  let a:badbrea = 1&#xA;  let a:linebefore = -1&#xA;  let lines = []&#xA;  while a:tolerance &amp;amp;&amp;amp; a:linebefore != line('.')&#xA;    let a:linebefore = line('.')&#xA;    let a:tolerance -= 1&#xA;    normal! %&#xA;    if line('.') == a:line&#xA;      let a:badbreak = 0&#xA;      break&#xA;    endif&#xA;    call add(lines, line('.'))&#xA;  endwhile&#xA;  exe 'normal! ' . a:line . 'gg'&#xA;  if a:badbreak == 1&#xA;    return []&#xA;  else&#xA;    return lines&#xA;  endif&#xA;endfunction&#xA;&#xA;&amp;quot; Trigger matching line highlights.&#xA;&amp;quot; Here `b:hl_last_line` prevents running the script again while the&#xA;&amp;quot; cursor is moved to matching pair on the same line.&#xA;function! s:hl_matching_lines() abort&#xA;  if exists('b:hl_last_line') &amp;amp;&amp;amp; b:hl_last_line == line('.')&#xA;    return&#xA;  endif&#xA;  let b:hl_last_line = line('.')&#xA;  let view = winsaveview()&#xA;  silent! call matchdelete(12345)  &amp;quot; arbitrary match ID&#xA;  let lines = s:get_match_lines(view.lnum)&#xA;  if empty(lines)  &amp;quot; try detecting at column 1&#xA;    call cursor(view.lnum, 1)&#xA;    let lines = s:get_match_lines(view.lnum)&#xA;  endif&#xA;  if len(lines)&#xA;    &amp;quot; call add(lines, view.lnum)  &amp;quot; highlight current line as well as other lines&#xA;    if exists('*matchaddpos')  &amp;quot; faster than using 'matchadd' patterns (if available)&#xA;      call matchaddpos('MatchLine', lines, 0, 12345)&#xA;    else  &amp;quot; highlight matching lines using the \%l atom and add highlight group&#xA;      call matchadd('MatchLine', join(map(lines, '''\%''.v:val.''l'''), '\|'), 0, 12345)&#xA;    endif&#xA;  endif&#xA;  call winrestview(view)&#xA;endfunction&#xA;function! s:hl_matching_lines_clear() abort&#xA;  silent! call matchdelete(12345)&#xA;  unlet! b:hl_last_line&#xA;endfunction&#xA;&#xA;&amp;quot; Define highlight groups used for matching lines.&#xA;&amp;quot; Use the `MatchParen` group by default.&#xA;highlight default link MatchLine MatchParen&#xA;augroup matching_lines&#xA;  autocmd!&#xA;  autocmd CursorMoved * call s:hl_matching_lines()&#xA;  autocmd InsertEnter * call s:hl_matching_lines_clear()&#xA;  autocmd TextChanged,TextChangedI * call s:hl_matching_lines_clear()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Original question&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;p&gt;Currently vim highlights matching parentheses, brackets, quotes, etc. with cyan background and white foreground -- the cursor can be moved between these with &lt;code&gt;%&lt;/code&gt;. Thanks to my matchit.vim, I can also switch with &lt;code&gt;%&lt;/code&gt; between if/end, for/end, etc., however these are not highlighted on selection.&lt;/p&gt;&#xA;&lt;p&gt;How can I automatically highlight these matching pairs upon selection, like is automatically done with parentheses?&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, how can I modify the background color used for these pairs using &lt;code&gt;:highlight&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2023-08-18T15:09:03.307" LastActivityDate="2023-08-18T15:09:03.307" Title="How can I highlight matching &quot;%&quot; names (e.g. if/end, for/end) defined by matchit.vim on selection?" Tags="|vimrc|syntax-highlighting|highlight|delimiter-matching|plugin-matchit|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="8708" PostTypeId="2" ParentId="8707" CreationDate="2016-07-10T03:21:01.493" Score="13" Body="&lt;p&gt;I thought this idea was interesting, so I gave it a shot.  It will be particularly useful in dense files, such as HTML.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CcpTo.gif&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CcpTo.gif&quot; alt=&quot;match lines&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following script simply lets &lt;code&gt;matchit.vim&lt;/code&gt; do what it does while recording the line numbers.  Explanations are in the script's comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tweekmonster/dootfiles/blob/ba90beafb092e1559fb89d72b6d0818cc45bc5c5/vim/_source/all/99-matchlines.vim&quot;&gt;matchlines.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:get_match_lines(line) abort&#xA;  let lines = []&#xA;&#xA;  &quot; Loop until `%` returns the original line number&#xA;  while 1&#xA;    normal %&#xA;    if line('.') == a:line&#xA;      &quot; Note that the current line number is never added to the `lines`&#xA;      &quot; list.&#xA;      break&#xA;    endif&#xA;    call add(lines, line('.'))&#xA;  endwhile&#xA;&#xA;  return lines&#xA;endfunction&#xA;&#xA;function! s:hl_matching_lines() abort&#xA;  &quot; `b:hl_last_line` prevents running the script again while the cursor is&#xA;  &quot; moved on the same line.  Otherwise, the cursor won't move if the current&#xA;  &quot; line has matching pairs of something.&#xA;  if exists('b:hl_last_line') &amp;amp;&amp;amp; b:hl_last_line == line('.')&#xA;    return&#xA;  endif&#xA;&#xA;  let b:hl_last_line = line('.')&#xA;&#xA;  &quot; Save the window's state.&#xA;  let view = winsaveview()&#xA;&#xA;  &quot; Delete a previous match highlight.  `12345` is used for the match ID.&#xA;  &quot; It can be anything as long as it's unique.&#xA;  silent! call matchdelete(12345)&#xA;&#xA;  &quot; Try to get matching lines from the current cursor position.&#xA;  let lines = s:get_match_lines(view.lnum)&#xA;&#xA;  if empty(lines)&#xA;    &quot; It's possible that the line has another matching line, but can't be&#xA;    &quot; matched at the current column.  Move the cursor to column 1 to try&#xA;    &quot; one more time.&#xA;    call cursor(view.lnum, 1)&#xA;    let lines = s:get_match_lines(view.lnum)&#xA;  endif&#xA;&#xA;  if len(lines)&#xA;    &quot; Since the current line is not in the `lines` list, only the other&#xA;    &quot; lines are highlighted.  If you want to highlight the current line as&#xA;    &quot; well:&#xA;    &quot; call add(lines, view.lnum)&#xA;    if exists('*matchaddpos')&#xA;      &quot; If matchaddpos() is availble, use it to highlight the lines since it's&#xA;      &quot; faster than using a pattern in matchadd().&#xA;      call matchaddpos('MatchLine', lines, 0, 12345)&#xA;    else&#xA;      &quot; Highlight the matching lines using the \%l atom.  The `MatchLine`&#xA;      &quot; highlight group is used.&#xA;      call matchadd('MatchLine', join(map(lines, '''\%''.v:val.''l'''), '\|'), 0, 12345)&#xA;    endif&#xA;  endif&#xA;&#xA;  &quot; Restore the window's state.&#xA;  call winrestview(view)&#xA;endfunction&#xA;&#xA;function! s:hl_matching_lines_clear() abort&#xA;  silent! call matchdelete(12345)&#xA;  unlet! b:hl_last_line&#xA;endfunction&#xA;&#xA;&#xA;&quot; The highlight group that's used for highlighting matched lines.  By&#xA;&quot; default, it will be the same as the `MatchParen` group.&#xA;highlight default link MatchLine MatchParen&#xA;&#xA;augroup matching_lines&#xA;  autocmd!&#xA;  &quot; Highlight lines as the cursor moves.&#xA;  autocmd CursorMoved * call s:hl_matching_lines()&#xA;  &quot; Remove the highlight while in insert mode.&#xA;  autocmd InsertEnter * call s:hl_matching_lines_clear()&#xA;  &quot; Remove the highlight after TextChanged.&#xA;  autocmd TextChanged,TextChangedI * call s:hl_matching_lines_clear()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't really like this happening on &lt;code&gt;CursorMoved&lt;/code&gt;, though.  I think it's better as a key map that can be used when I need it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;l :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;hl_matching_lines()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-07-10T16:16:53.470" LastActivityDate="2016-07-10T16:16:53.470" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8709" PostTypeId="1" CreationDate="2016-07-10T15:15:46.470" Score="6" ViewCount="603" Body="&lt;p&gt;I am writing a plugin which needs to have two windows displayed at the same time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; _______&#xA;|   |   |&#xA;| A | B |&#xA;|___|___|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need to keep in memory a reference to those windows as I execute my plugin. This is because I need to be able to jump between the two windows automaticaly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the &lt;code&gt;winnr()&lt;/code&gt; function that returns the current window number, which I can use later like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:winA = winnr()&#xA;new&#xA;let s:winB = winnr()&#xA;&#xA;&quot; stuff&#xA;&#xA;&quot; go to window A&#xA;execute s:winA . &quot;wincmd w&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in this case, both variables will have the value &lt;code&gt;1&lt;/code&gt;, this is because the &lt;code&gt;winnr()&lt;/code&gt; return the position of the current window in the tab display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use the &lt;code&gt;bufnr('%')&lt;/code&gt; which return the buffer number for the current buffer. This is great, but when I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:bufA = bufnr('%')&#xA;new&#xA;let s:bufB = bufnr('%')&#xA;&#xA;&quot; stuff&#xA;&#xA;&quot; go to buffer A&#xA;execute 'buffer '. s:bufA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The current window load the buffer, and the cursor will not jump to the existing window containing the buffer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is my question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to store permanent information about windows so the cursor can jump on it later?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-11T11:22:32.317" Title="Keep windows reference in memory" Tags="|vimscript|buffers|vim-windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8710" PostTypeId="1" AcceptedAnswerId="8713" CreationDate="2016-07-10T15:18:19.020" Score="1" ViewCount="562" Body="&lt;p&gt;&lt;strong&gt;How do I attach a callback to &lt;code&gt;:NeomakeProject&lt;/code&gt; so that &lt;code&gt;:cwindow&lt;/code&gt; is executed after compilation finishes?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e. I'm too lazy and want everything (open the error list) to happen automatically. (currently I'm opening :cwindow with a shortcut)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/callback&lt;/code&gt; in &lt;code&gt;:help neomake&lt;/code&gt; shows that &lt;code&gt;neomake#Make()&lt;/code&gt; accepts a callback as third argument but this doesn't seem to be connected to my problem as it's a function, called internally by &lt;code&gt;:Neomake&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Googling for &quot;neovim job control&quot; shows that callbacks are set as argument to the &lt;code&gt;jobstart&lt;/code&gt; function. A search for &lt;code&gt;jobstart&lt;/code&gt; in the &lt;a href=&quot;https://github.com/neomake/neomake&quot; rel=&quot;nofollow&quot;&gt;neomake repository&lt;/a&gt; shows that neomake sets &lt;code&gt;neomake#MakeHandler&lt;/code&gt; as a callback. And the fact that this function is 98 lines long stopped my further research.&lt;/p&gt;&#xA;" OwnerUserId="3280" LastActivityDate="2016-07-10T16:03:03.973" Title="Run :cwindow after :Neomake finishes" Tags="|neovim|plugin-neomake|job-control|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8711" PostTypeId="2" ParentId="8709" CreationDate="2016-07-10T15:30:08.227" Score="3" Body="&lt;p&gt;You can't store a window number reliably because it changes every time a window is created and destroyed.  You can use &lt;code&gt;winbufnr()&lt;/code&gt; if you know the buffer's ID.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the buffer doesn't matter, I use a window variable to keep track of the windows I open:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;new&#xA;let w:_plugin_variable = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The variable above is just a boolean, but you could use your own identifier if you want to keep windows paired to each other.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let w:_plugin_variable = ['parent', 123]&#xA;new&#xA;let w:_plugin_variable = ['child', 123]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first item being the relationship and the second as some special identifier.  This way is useful if both windows might contain the same buffer but have different settings/purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To find the windows, you just iterate over all window numbers to get the variable you're looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(1, winnr('$'))&#xA;  let id = getwinvar(i, '_plugin_variable', -1)&#xA;  if id != -1&#xA;    &quot; Do something with the information.&#xA;    break&#xA;  endif&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the loop above, &lt;code&gt;i&lt;/code&gt; is the window's number.  You can get settings from the window with &lt;code&gt;getwinvar(i, '&amp;amp;textwidth')&lt;/code&gt; or switch to it with &lt;code&gt;execute i 'wincmd w'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same thing can be done with tabs using &lt;code&gt;tabpagenr()&lt;/code&gt;, &lt;code&gt;tabpagewinnr()&lt;/code&gt;, &lt;code&gt;gettabvar()&lt;/code&gt;, &lt;code&gt;gettabwinvar()&lt;/code&gt;, etc.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-07-10T15:30:08.227" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8712" PostTypeId="2" ParentId="8710" CreationDate="2016-07-10T15:44:13.720" Score="4" Body="&lt;p&gt;I don't know first hand if it works with your fork but the following snippets works perfectly in real Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup qf&#xA;    autocmd!&#xA;&#xA;    &quot; automatically open the location/quickfix window after :make, :grep,&#xA;    &quot; :lvimgrep and friends if there are valid locations/errors&#xA;    autocmd QuickFixCmdPost [^l]* cwindow&#xA;    autocmd QuickFixCmdPost l*    lwindow&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="1821" LastEditDate="2016-07-10T16:03:03.973" LastActivityDate="2016-07-10T16:03:03.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8713" PostTypeId="2" ParentId="8710" CreationDate="2016-07-10T15:52:13.083" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/neomake/neomake/blob/310a86903200f343117425fd82fe61ae2c8a83d5/doc/neomake.txt#L380-L403&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neomake runs a user autocmd called &lt;code&gt;NeomakeFinished&lt;/code&gt; when it's done.&lt;/a&gt;  It sets the context variable: &lt;code&gt;g:neomake_hook_context.file_mode&lt;/code&gt;.  If it's &lt;code&gt;1&lt;/code&gt; it's using the location list.&lt;/p&gt;&#xA;&lt;p&gt;If you only want it to run when it's finished with a project:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd User NeomakeFinished if !g:neomake_hook_context.file_mode | cwindow | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There is also an option:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/neomake/neomake/blob/310a86903200f343117425fd82fe61ae2c8a83d5/doc/neomake.txt#L210-L213&quot; rel=&quot;nofollow noreferrer&quot;&gt;*g:neomake_open_list*&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This setting will open the |loclist| or |quickfix| list (depending on whether&#xA;it is operating on a file) when adding entries. A value of 2 will preserve the&#xA;cursor position when the |loclist| or |quickfix| window is opened. Defaults to 0.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-07-10T15:52:13.083" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8715" PostTypeId="1" AcceptedAnswerId="25283" CreationDate="2016-07-10T16:44:23.837" Score="1" ViewCount="264" Body="&lt;p&gt;Given this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '%!alfa' -cx file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get this result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sh: alfa: command not found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is to be expected. However an unintended side effect of this is that the&#xA;file is emptied and saved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this command be modified so that if the external command is not found, then&#xA;Vim bails instead of saving an empty file?&lt;/p&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-05-13T01:53:27.460" Title="File emptied when command not found" Tags="|external-command|ex-mode|ex-command|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8716" PostTypeId="1" AcceptedAnswerId="8717" CreationDate="2016-07-10T17:14:08.540" Score="4" ViewCount="1089" Body="&lt;p&gt;I tried to set a mark using a digit: &lt;code&gt;m1&lt;/code&gt; and apparently that does not work, because later I typed &lt;code&gt;`1&lt;/code&gt; and I think it opened the last opened file or something else, I'm not sure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does &lt;code&gt;m1&lt;/code&gt; do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are marks restricted to letters?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="1821" LastEditDate="2016-07-12T08:43:50.173" LastActivityDate="2016-07-12T08:43:50.173" Title="What does `1 do?" Tags="|mark|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8717" PostTypeId="2" ParentId="8716" CreationDate="2016-07-10T17:19:12.743" Score="13" Body="&lt;p&gt;You can jump to numbered marks, but you can't set them directly. According to &lt;code&gt;:h mark-motions&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Numbered marks '0 to '9 are quite different.  They can not be set directly. &#xA;  They are only present when using a viminfo file &lt;code&gt;viminfo-file&lt;/code&gt;.  Basically '0 is the location of the cursor when you last exited Vim, '1 the last but one time, etc.  Use the &quot;r&quot; flag in 'viminfo' to specify files for which no Numbered mark should be stored.  See &lt;code&gt;viminfo-file-marks&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-07-10T17:19:12.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8718" PostTypeId="1" AcceptedAnswerId="8767" CreationDate="2016-07-11T00:14:11.223" Score="9" ViewCount="2360" Body="&lt;p&gt;I want my C code indented as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (x)&#xA;{&#xA;    case 1:&#xA;        break;&#xA;    case 2:&#xA;    {&#xA;        break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (x)&#xA;{&#xA;    case 1:&#xA;        break;&#xA;    case 2:&#xA;        {&#xA;            break;&#xA;        }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I looked through cinoptions, but didn't find what I need. I'm looking for some options I missed or other indentation script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="8385" LastActivityDate="2020-09-16T13:54:43.967" Title="Vim switch statement cindent options" Tags="|indentation|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8719" PostTypeId="1" CreationDate="2016-07-11T04:13:02.207" Score="2" ViewCount="71" Body="&lt;p&gt;Suppose I have a pretty-printed JSON file that I'm trying to navigate and my cursor is at the &lt;code&gt;X&lt;/code&gt; position. Is there a motion to move to the nearest line above/below the current one with an indentation level less than or equal to my cursor's current location?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    &quot;foo&quot;: [&#xA;        &amp;lt;object&amp;gt;,&#xA;        &amp;lt;object&amp;gt;,&#xA;        &amp;lt;object&amp;gt;,&#xA;     X  ...,&#xA;        &amp;lt;object&amp;gt;&#xA;    ]&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I go &quot;up&quot; I'd like to jump to the &lt;code&gt;&quot;foo&quot;: [&lt;/code&gt; line.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2016-07-11T04:13:02.207" Title="Structural navigation by indentation level" Tags="|indentation|" AnswerCount="0" CommentCount="1" ClosedDate="2016-07-11T22:17:38.063" ContentLicense="CC BY-SA 3.0" />
  <row Id="8721" PostTypeId="2" ParentId="8574" CreationDate="2016-07-11T09:32:13.580" Score="0" Body="&lt;p&gt;Based on the answer by Peter Rincker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;feedkeys&lt;/code&gt; works in contrast to attaching the mapping &lt;code&gt;\&amp;lt;C-w&amp;gt;P&lt;/code&gt; via &lt;code&gt;&amp;lt;Bar&amp;gt; normal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem with the answer by Peter Rincker:&lt;br&gt;&#xA;Fugitive defines mappings on the fly based on different events which override occasionally the mappings set up by the event &lt;code&gt;BufEnter&lt;/code&gt;. I couldn't figure out which events I would have to add to Peter Rinckers answer to retain the extended mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple way to circumvent this problem is to directly modify the mappings in fugitive:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-diff prettyprint-override&quot;&gt;&lt;code&gt;$ git diff&#xA;diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim&#xA;index 805518a..f0120f8 100644&#xA;--- a/plugin/fugitive.vim&#xA;+++ b/plugin/fugitive.vim&#xA;@@ -14,6 +14,10 @@ endif&#xA;&#xA; &quot; Section: Utility&#xA;&#xA;+function! s:focus_preview()&#xA;+  call feedkeys(&quot;\&amp;lt;c-w&amp;gt;P&quot;)&#xA;+endfunction&#xA;+&#xA; function! s:function(name) abort&#xA;   return function(substitute(a:name,'^s:',matchstr(expand('&amp;lt;sfile&amp;gt;'), '&amp;lt;SNR&amp;gt;\d\+_'),''))&#xA; endfunction&#xA;@@ -2552,12 +2556,12 @@ function! s:BufReadIndex() abort&#xA;     nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; cc :&amp;lt;C-U&amp;gt;Gcommit&amp;lt;CR&amp;gt;&#xA;     nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; cva :&amp;lt;C-U&amp;gt;Gcommit --amend --verbose&amp;lt;CR&amp;gt;&#xA;     nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; cvc :&amp;lt;C-U&amp;gt;Gcommit --verbose&amp;lt;CR&amp;gt;&#xA;-    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; D :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gdiff')&amp;lt;CR&amp;gt;&#xA;-    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; dd :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gdiff')&amp;lt;CR&amp;gt;&#xA;-    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; dh :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gsdiff')&amp;lt;CR&amp;gt;&#xA;-    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; ds :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gsdiff')&amp;lt;CR&amp;gt;&#xA;-    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; dp :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiffEdit()&amp;lt;CR&amp;gt;&#xA;-    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; dv :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gvdiff')&amp;lt;CR&amp;gt;&#xA;+    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; D :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gdiff')&amp;lt;Bar&amp;gt;exe &amp;lt;SID&amp;gt;focus_preview()&amp;lt;CR&amp;gt;&#xA;+    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; dd :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gdiff')&amp;lt;Bar&amp;gt;exe &amp;lt;SID&amp;gt;focus_preview()&amp;lt;CR&amp;gt;&#xA;+    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; dh :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gsdiff')&amp;lt;Bar&amp;gt;exe &amp;lt;SID&amp;gt;focus_preview()&amp;lt;CR&amp;gt;&#xA;+    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; ds :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gsdiff')&amp;lt;Bar&amp;gt;exe &amp;lt;SID&amp;gt;focus_preview()&amp;lt;CR&amp;gt;&#xA;+    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; dp :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiffEdit()&amp;lt;Bar&amp;gt;exe &amp;lt;SID&amp;gt;focus_preview()&amp;lt;CR&amp;gt;&#xA;+    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; dv :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StageDiff('Gvdiff')&amp;lt;Bar&amp;gt;exe &amp;lt;SID&amp;gt;focus_preview()&amp;lt;CR&amp;gt;&#xA;     nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; p :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StagePatch(line('.'),line('.')+v:count1-1)&amp;lt;CR&amp;gt;&#xA;     xnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; p :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StagePatch(line(&quot;'&amp;lt;&quot;),line(&quot;'&amp;gt;&quot;))&amp;lt;CR&amp;gt;&#xA;     nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; P :&amp;lt;C-U&amp;gt;execute &amp;lt;SID&amp;gt;StagePatch(line('.'),line('.')+v:count1-1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, they will be overwritten if you pull in a new version of fugitive.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2016-07-11T11:35:14.780" LastActivityDate="2016-07-11T11:35:14.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8722" PostTypeId="2" ParentId="8718" CreationDate="2016-07-11T11:21:04.097" Score="5" Body="&lt;p&gt;I don't think it's possible &lt;em&gt;as is&lt;/em&gt;, you can work around that though.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For your current example you can set&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set  cino={-s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will reindent each &lt;code&gt;{&lt;/code&gt;/&lt;code&gt;}&lt;/code&gt; pair found to reduce the shift width setting. This will work on the example you gave:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (x)&#xA;{&#xA;  case 1:&#xA;    break;&#xA;  case 2:&#xA;  {&#xA;      break;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But not on an example with more complex syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (x)&#xA;{&#xA;  case 1:&#xA;    break;&#xA;  case 2:&#xA;  {&#xA;      break;&#xA;      if( 1 )&#xA;    {&#xA;        //stuff&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Apparently, by looking at &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#cindent&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h cindent&lt;/code&gt;&lt;/a&gt;, Vim prefers the curly brace on the same line as the statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I would recommand using the following formatting instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (x) {&#xA;&#xA;  case 1:&#xA;    break;&#xA;&#xA;  case 2: {&#xA;    break;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this, you can set &lt;code&gt;cino=l1&lt;/code&gt; and indent will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (x) {&#xA;&#xA;  case 1:&#xA;    break;&#xA;&#xA;  case 2: {&#xA;    break;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, it might not suit your coding style but AFAIK, it the best way to properly indent the case statement.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-11T11:21:04.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8723" PostTypeId="2" ParentId="8709" CreationDate="2016-07-11T11:22:32.317" Score="7" Body="&lt;p&gt;I think what you are looking for is the function &lt;code&gt;win_getid()&lt;/code&gt; combined to the&#xA;function &lt;code&gt;win_gotoid()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#win_getid()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h win_getid()&lt;/code&gt;&lt;/a&gt;&#xA;says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;win_getid([{win} [, {tab}]])&lt;br/&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Get the window ID for the specified window.&lt;br/&gt;&#xA;     When {win} is missing use the current window.&lt;br/&gt;&#xA;     With {win} this is the window number.  The top window has&#xA;     number 1.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The advantage of these functions is that ID is linked to a window and does not&#xA;change when the position of the window is changed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your script would become something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:winA = win_getid()&#xA;new&#xA;let s:winB = win_getid()&#xA;&#xA;&quot; stuff&#xA;&#xA;&quot; go to window A&#xA;call win_gotoid(s:winA)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-07-11T11:22:32.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8725" PostTypeId="2" ParentId="8693" CreationDate="2016-07-11T13:10:45.177" Score="2" Body="&lt;p&gt;You can also have a look at &lt;a href=&quot;https://github.com/Shougo/vimshell.vim&quot; rel=&quot;nofollow&quot;&gt;vimshell.vim&lt;/a&gt;, which is another shell you can run inside vim.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Otherwise I tend to use &lt;code&gt;&amp;lt;C-Z&amp;gt;&lt;/code&gt; for the &lt;code&gt;Vim&lt;/code&gt;&amp;lt;--&gt;&lt;code&gt;shell&lt;/code&gt; quick switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This puts vim in the background and let you run commands your shell. It's quicker than opening a new tab a new shell. &lt;code&gt;fg&lt;/code&gt; can be used to go back to Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus:&lt;/strong&gt;&#xA;If you're using &lt;code&gt;zsh&lt;/code&gt; you can also put this snippet in your configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fancy-ctrl-z () {&#xA;    if [[ $#BUFFER -eq 0 ]]; then&#xA;        BUFFER=&quot;fg&quot;&#xA;        zle accept-line&#xA;    else&#xA;        zle push-input&#xA;        zle clear-screen&#xA;    fi&#xA;}&#xA;&#xA;zle -N fancy-ctrl-z&#xA;bindkey '^Z' fancy-ctrl-z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will call &lt;code&gt;fg&lt;/code&gt; if you press &lt;code&gt;&amp;lt;C-Z&amp;gt;&lt;/code&gt; and there is a job in the background. So you can &lt;code&gt;&amp;lt;C-Z&amp;gt;&lt;/code&gt; &lt;code&gt;&amp;lt;C-Z&amp;gt;&lt;/code&gt; quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/&quot; rel=&quot;nofollow&quot;&gt;Source&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-11T13:10:45.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8726" PostTypeId="1" CreationDate="2016-07-11T15:00:49.447" Score="6" ViewCount="431" Body="&lt;p&gt;I have a file that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Section 1&#xA;#&#xA;# new: a.txt&#xA;# new: b.txt&#xA;#&#xA;#&#xA;# Section 2&#xA;#&#xA;# [n]ew: c.txt&#xA;# new: d.txt&#xA;# new: e.txt&#xA;#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My cursor is on the first &lt;code&gt;new&lt;/code&gt; of the second section and I want to select all the &quot;paragraph&quot;, i.e. the 3 &lt;code&gt;new&lt;/code&gt; lines starting at this one. But because the paragraph is defined as a set of non-empty lines, &lt;code&gt;vip&lt;/code&gt; selects all the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I select only those 3 lines? This should apply for any number of lines and the cursor should be placed anywhere in the &quot;paragraph&quot;, i.e. &lt;code&gt;vip&lt;/code&gt;/equivalent should select the current &lt;code&gt;new&lt;/code&gt; paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is the following: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I omit a column of text when visually selecting a paragraph?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1841" LastEditDate="2016-07-11T15:03:21.550" LastActivityDate="2016-07-13T07:28:33.113" Title="How to ignore a column when visually selecting a paragraph" Tags="|cursor-motions|visual-mode|" AnswerCount="5" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="8727" PostTypeId="2" ParentId="8726" CreationDate="2016-07-11T16:00:59.970" Score="1" Body="&lt;p&gt;Unfortunately, vim doesn't yet support custom-defined paragraphs (from :h todo). &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Add regex for 'paragraphs' and 'sections': 'parare' and 'sectre'.  Combine&#xA;  the two into a regex for searching. (Ned Konz)&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Not all hope is lost though, regex to the rescue!!!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;EDIT: A function to do it!&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SelectBlock()&#xA;  execute &quot;normal! ?#\\s*$\&amp;lt;cr&amp;gt;&quot; &quot;go to top of current block&#xA;  execute &quot;normal! j&quot; &quot; go down one line&#xA;  execute &quot;normal! v/\\_.#\\s*$\&amp;lt;cr&amp;gt;&quot; &quot;visually select to end of block&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can type :call SelectBlock() or map it to something to make this happen. It works wherever your cursor is. &#xA;To do it, type &lt;code&gt;v/\_.#\s*$&lt;/code&gt;, which will match all the lines under the current line (including the current line) until a line with a # followed by non-whitespace characters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation of the last command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;v&lt;/code&gt; - visual select mode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/&lt;/code&gt; - select until the following search result (our regex)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\_.&lt;/code&gt; - select any characters, including newlines&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;#\s*$&lt;/code&gt; - end the regex match if there's a line with a # followed by nothing but whitespace&lt;/p&gt;&#xA;" OwnerUserId="2757" LastEditorUserId="2757" LastEditDate="2016-07-11T20:24:09.023" LastActivityDate="2016-07-11T20:24:09.023" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8728" PostTypeId="2" ParentId="8674" CreationDate="2016-07-11T16:24:42.240" Score="7" Body="&lt;p&gt;&lt;strong&gt;1. &lt;code&gt;:mkexrc&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way is to use &lt;code&gt;:mkexrc&lt;/code&gt; command. With this command, we can save all changed options into a file. When you need to restore back all the saved options from the file, just&lt;code&gt;:source&lt;/code&gt; it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkexrc snapshot&#xA;source snapshot&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. &lt;code&gt;:set&lt;/code&gt; and &lt;code&gt;:redir&lt;/code&gt;&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:mkexrc&lt;/code&gt; command necessarily uses a file to hold all options.(And it also saves current key mappings.) When we do not want to use any file, we can redirect output of &lt;code&gt;:set&lt;/code&gt; command into vim variable with &lt;code&gt;:redir&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;redir =&amp;gt; snapshot&#xA;silent set&#xA;redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, we can restore back all the options from snapshot as follows.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for opt in split(snapshot,'\n')[1:]&#xA;    exe &quot;silent set &quot; . opt&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above approach is quick and easy to use. But the approach has two problems. First, we have to escape some characters including white spaces from the snapshot(&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#option-backslash&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help option-backslash&lt;/code&gt;)&lt;/a&gt;. Otherwise we might meet errors when these characters not being escaped. For instance, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set breakat=@ !+=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;raises the error 'E518' but,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set breakat=@\ \!+=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And second problem is that all the special keys are changed to normal characters when we redirect the output to snapshot. For example, &lt;code&gt;^I&lt;/code&gt;(tab) is literally changed to &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;I&lt;/code&gt;. The workaround could be complicated a little bit.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:optionDict = {}&#xA;&#xA;function SaveOpts()&#xA;    redir =&amp;gt; snapshot&#xA;    &quot; We make a snapshot of options which differ from their default value.&#xA;    &quot; If we want to make a snapshot of all options, do set all.&#xA;    silent set&#xA;    redir END&#xA;&#xA;    for opt in split(snapshot, '\W\+')&#xA;        if strlen(opt) &amp;gt; 3&#xA;            if exists('&amp;amp;' . opt)&#xA;                exe 'let g:optionDict.'. opt . '=&amp;amp;' . opt&#xA;            elseif opt[0:1] == 'no' &amp;amp;&amp;amp; exists('&amp;amp;' . opt[2:])&#xA;                exe 'let g:optionDict.'. opt[2:]. '=&amp;amp;' . opt[2:]&#xA;            endif&#xA;        endif&#xA;    endfor&#xA;endfunc&#xA;&#xA;function RestoreOpts()&#xA;    for [opt, val] in items(g:optionDict)&#xA;        try&#xA;            exe 'silent set ' . opt . '=' . escape(val, &quot; \t|\\\&quot;&quot;)&#xA;        catch /:E474/ &quot; Invalid argument, do set {option} or no{option}&#xA;            if val == '1'&#xA;                exe 'silent set ' . opt&#xA;            elseif val == '0'&#xA;                exe 'silent set no' . opt&#xA;            endif&#xA;        endtry&#xA;    endfor&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3. &lt;code&gt;:setlocal&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can also save an restore option manually with &lt;code&gt;:setlocal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:setlocal&lt;/code&gt; only affects current buffer or window. If we change options with &lt;code&gt;:setlocal&lt;/code&gt;, &lt;code&gt;:setlocal {option}&amp;lt;&lt;/code&gt; or &lt;code&gt;:set {option}&amp;lt;&lt;/code&gt; can restore back the changed options. The former one sets the local value of {option} from its global value and the latter one remove all the local options so all the option values return to their global values. For instance,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal ts=16&#xA;set ts&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8031" LastEditorUserId="8031" LastEditDate="2016-07-11T23:36:39.690" LastActivityDate="2016-07-11T23:36:39.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8729" PostTypeId="1" CreationDate="2016-07-11T18:29:11.880" Score="5" ViewCount="4667" Body="&lt;p&gt;I am using git 2.7.0.windows.1 in Windows 10, with &lt;code&gt;core.editor&lt;/code&gt; set to &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim was downloaded from vim.org latest version binary:&#xA;VIM - Vi IMproved 7.4.1023 (2013 Aug 10, compiled Jan  2 2016 14:24:35)&#xA;MS-Windows 32-bit console version&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I do a git commit in a &lt;code&gt;cmd&lt;/code&gt; window, it goes into a vim right in the command window. And there is no text shown or maybe black text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is &lt;a href=&quot;https://i.stack.imgur.com/bv2Iy.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;a link to an album with detailed description on the behaviors of the bug.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8cLXY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8cLXY.png&quot; alt=&quot;black text on black screen&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do have &lt;code&gt;syntax on&lt;/code&gt; setting in my .vimrc. When I type in command &lt;code&gt;:syntax off&lt;/code&gt; the text shows up but goes away if I move the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; color scheme and syntax highlighting&#xA;syntax on&#xA;colorscheme industry&#xA;&#xA;&quot; line number&#xA;set number&#xA;&#xA;&quot; tab settings&#xA;set softtabstop=2 shiftwidth=2 expandtab&#xA;&#xA;&quot; set initial window size&#xA;set lines=30 columns=80&#xA;&#xA;&quot; set to auto write buffer before hidden&#xA;set autowrite&#xA;&#xA;&quot; set font&#xA;if has(&quot;gui_running&quot;)&#xA;  if has(&quot;gui_gtk2&quot;)&#xA;    set guifont=Inconsolata\ 12&#xA;  elseif has(&quot;gui_macvim&quot;)&#xA;    set guifont=Menlo\ Regular:h14&#xA;  elseif has(&quot;gui_win32&quot;)&#xA;    set guifont=Consolas:h11:cANSI&#xA;  endif&#xA;endif&#xA;&#xA;&quot; turn on spell check&#xA;set spell spelllang=en_us&#xA;set spellfile=$HOME/Dropbox/vim/spell/en.utf-8.add&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to remove the two lines below which made it worse.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme industry&#xA;syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the screen is totally black and does not even responding to &lt;code&gt;:q&lt;/code&gt; correctly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;/e/java-projects/test/.git/COMMIT_EDITMSG&quot; [converted][unix] 16L, 310C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am doubting it might be some communication bug between git, Windows command line, and vim. I do have a work around: use gvim or use git bash instead, neither have the black text problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I correct this?&lt;/p&gt;&#xA;" OwnerUserId="8393" LastEditorUserId="205" LastEditDate="2016-09-14T00:51:50.877" LastActivityDate="2021-10-04T23:16:03.910" Title="Vim black text on black background in command line in Windows 10 while editing git commit message" Tags="|syntax-highlighting|vim-windows|colorscheme|git|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8730" PostTypeId="2" ParentId="8726" CreationDate="2016-07-11T18:32:54.473" Score="3" Body="&lt;p&gt;You could delete the first column, then select the paragraph with &lt;code&gt;vip&lt;/code&gt;, then restore the deleted &lt;code&gt;#&lt;/code&gt;'s and reselect the last visual selection with &lt;code&gt;gv&lt;/code&gt;. Basically something like this mapped to the &lt;code&gt;Q&lt;/code&gt; key for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap Q :%s/^#// \| exe 'norm!``vip&quot;9y' \| silent %s/^/#/ \| nohl \| norm!gv&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It yanks the paragraph into register &lt;code&gt;9&lt;/code&gt; just so vim will remember the selection for the &lt;code&gt;gv&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="2674" LastActivityDate="2016-07-11T18:32:54.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8731" PostTypeId="2" ParentId="8726" CreationDate="2016-07-11T19:49:31.160" Score="1" Body="&lt;p&gt;If you do not mind leaving dirty marks behind you can use them to mark the paragraph.  i.e. you can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;mark your position,&lt;/li&gt;&#xA;&lt;li&gt;select the entire commented text,&lt;/li&gt;&#xA;&lt;li&gt;return to the mark&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vip&lt;/code&gt; to select the paragraph&lt;/li&gt;&#xA;&lt;li&gt;use marks again to mark the paragraph itself&lt;/li&gt;&#xA;&lt;li&gt;undo the change&lt;/li&gt;&#xA;&lt;li&gt;use the marks to select the single paragraph&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;vip mqvip:s/^./&amp;lt;cr&amp;gt;`qvip&amp;lt;esc&amp;gt;`&amp;lt;mw`&amp;gt;meu`w0v`e$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;mq&lt;/code&gt; marks the current position&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vip&lt;/code&gt; selects the problematic paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s/^./&amp;lt;cr&amp;gt;&lt;/code&gt; removes the problematic characters (can be adapted to other forms of comments)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`q&lt;/code&gt; returns the cursor to the original position&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vip&lt;/code&gt; now selects the desired paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; forces the current visual to be the latest selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`&amp;lt;mw&lt;/code&gt; marks the beginning of the desired paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`&amp;gt;me&lt;/code&gt; marks the end of the desired paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;u&lt;/code&gt; undoes the change, puts the comments back&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`w0&lt;/code&gt; goes to the beginning of the desired paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v&lt;/code&gt; enters visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`e$&lt;/code&gt; moves to the end of the desired paragraph completing the selection.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is a little dirty since the marks end one character off after the undo, that is the reason to use &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt; in the final selection.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-07-11T19:49:31.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8732" PostTypeId="2" ParentId="8726" CreationDate="2016-07-11T20:04:18.707" Score="5" Body="&lt;p&gt;Using Kana Natsuno's &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;textobj-user&lt;/a&gt;: install &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;textobj-user&lt;/a&gt;, then put the following in a file &lt;code&gt;textobj-comment-lines/plugin/textobj/comment_lines.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if exists('g:loaded_textobj_comment_lines')&#xA;    finish&#xA;endif&#xA;let g:loaded_textobj_comment_lines = 1&#xA;&#xA;let s:save_cpo = &amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;&#xA;call textobj#user#plugin('commentlines', {&#xA;    \   '-': {&#xA;    \     'select-a': &amp;quot;a#&amp;quot;,  '*select-a-function*': 'CommentLinesSelectA',&#xA;    \     'select-i': &amp;quot;i#&amp;quot;,  '*select-i-function*': 'CommentLinesSelectI'&#xA;    \   }&#xA;    \ })&#xA;&#xA;function! CommentLinesSelectA() &amp;quot; {{{1&#xA;    if getline(line('.')) !~# '\m^#.*\S'&#xA;        return 0&#xA;    endif&#xA;&#xA;    let head_pos = search('\m\%(\%^\|^\n\|^[^#].*\n\|^#\s*\n\)\zs#.*\S', 'cbnW')&#xA;    let tail_pos = search('\m\%#.*\n\%(^#.*\S.*\n\)*\%(^#\s*\n\)*\zs\%(^#\s*\n\)', 'cnW')&#xA;    if tail_pos &amp;gt; 0&#xA;        if getline(tail_pos) !~# '\m^#'&#xA;            let tail_pos -= 1&#xA;        endif&#xA;    else&#xA;        let tail_pos = search('\m^#.*\S.*\n\ze\%(\%$\|^\n\|^[^#].*\n\|^#\s*\n\)', 'cnW')&#xA;    endif&#xA;    return ['V', [0, head_pos, 1, 0], [0, tail_pos, 1, 0]]&#xA;endfunction &amp;quot; }}}1&#xA;&#xA;function! CommentLinesSelectI() &amp;quot; {{{1&#xA;    if getline(line('.')) !~# '\m^#.*\S'&#xA;        return 0&#xA;    endif&#xA;&#xA;    let head_pos = search('\m\%(\%^\|^\n\|^[^#].*\n\|^#\s*\n\)\zs#.*\S', 'cbnW')&#xA;    let tail_pos = search('\m^#.*\S.*\n\ze\%(\%$\|^\n\|^[^#].*\n\|^#\s*\n\)', 'cnW')&#xA;    if !tail_pos&#xA;        let tail_pos = line('$')&#xA;    endif&#xA;    return ['V', [0, head_pos, 1, 0], [0, tail_pos, 1, 0]]&#xA;endfunction &amp;quot; }}}1&#xA;&#xA;let &amp;amp;cpo = s:save_cpo&#xA;unlet s:save_cpo&#xA;&#xA;&amp;quot; vim: set sw=4 sts=4 fdm=marker:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This adds two mappings, &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;#&lt;/kbd&gt; and  &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;#&lt;/kbd&gt;, and the first one does what you want.  The gist is the regexp searches, the rest is mostly boilerplate.&lt;/p&gt;&#xA;&lt;p&gt;The comments are hard-coded to &lt;code&gt;#&lt;/code&gt; anchored at the beginning of line.  Dealing with other kinds of comments (f.i. &lt;code&gt;/*&lt;/code&gt; ... &lt;code&gt;*/&lt;/code&gt;) would be possible, but not trivial.  You can, of course, refine this in many ways.&lt;/p&gt;&#xA;&lt;p&gt;Reference: &lt;a href=&quot;https://github.com/kana/vim-textobj-user/blob/master/doc/textobj-user.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;textobj-user user manual&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-07-13T07:28:33.113" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8733" PostTypeId="1" AcceptedAnswerId="8792" CreationDate="2016-07-11T21:21:01.077" Score="7" ViewCount="5068" Body="&lt;p&gt;I need to be break it to you guys, I use &lt;code&gt;emacs&lt;/code&gt;.  But just for one little thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently I've been working with a good deal of Japanese people (the company is Japanese) and I got some idea of the language, moreover sometimes I need to write something in Japanese.  I do not have a Japanese keyboard and I need to convert some form of &quot;romaji&quot; (Japanese written in latin letters).  At first I used google translated but then I learned about &lt;code&gt;emacs&lt;/code&gt;'s japanese mode.  Here is a screenshot of it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cGmap.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cGmap.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(forgive my Japanese please)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;emacs&lt;/code&gt; does this with the help of the &lt;a href=&quot;http://openlab.ring.gr.jp/skk/dic.html&quot; rel=&quot;noreferrer&quot;&gt;skk dictionary&lt;/a&gt; with some customisations for the actual typing (&lt;code&gt;lisp/international/ja-dic-cvn.el&lt;/code&gt;, &lt;code&gt;lisp/international/ja-dic-utl.el&lt;/code&gt; and &lt;code&gt;lisp/international/kkc.el&lt;/code&gt; in &lt;code&gt;emacs&lt;/code&gt; code).  Everything happens in UTF-8, the above screenshot is &lt;code&gt;emacs&lt;/code&gt; running inside a UTF-8 terminal.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Is there a viable way to perform this in Vim?  I'm hoping someone wrote an interface to SKK already, since my Japanese is definitely not good enough to read its documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or maybe, is there a different method to write Japanese text in Vim?&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2020-12-12T07:45:11.373" Title="Can I write Japanese (SKK) text in Vim?" Tags="|unicode|keyboard-layout|text-generation|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8734" PostTypeId="2" ParentId="8726" CreationDate="2016-07-12T00:08:41.507" Score="2" Body="&lt;p&gt;An alternative is &lt;code&gt;?#$&amp;lt;cr&amp;gt;jVNk&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ba3RO.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ba3RO.gif&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;?#$&lt;/code&gt; jumps back to the previous occurrence of &lt;code&gt;#&lt;/code&gt; on its own line (&lt;code&gt;$&lt;/code&gt; in regex means &quot;end of line&quot;), &lt;code&gt;j&lt;/code&gt; moves to the start of the paragraph to select, we start &lt;code&gt;V&lt;/code&gt;isual mode and move to the &lt;code&gt;N&lt;/code&gt;ext occurrence of &lt;code&gt;#&lt;/code&gt; by itself, and finally move back up one line with &lt;code&gt;k&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is relatively short, so you can type it manually when necessary to avoid having to bind a key to it, but it does have the disadvantage that it clobbers the search history. If you &lt;em&gt;do&lt;/em&gt; make it a mapping, though, you can keep search history intact with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;keeppatterns normal! ?#$\&amp;lt;cr&amp;gt;jV/#$\&amp;lt;cr&amp;gt;k&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or the shorthand&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;keepp norm! ?#$\&amp;lt;cr&amp;gt;jV/#$\&amp;lt;cr&amp;gt;k&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastActivityDate="2016-07-12T00:08:41.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8735" PostTypeId="5" CreationDate="2016-07-12T05:45:41.597" Score="0" Body="&lt;p&gt;This tag is for questions about closing the vim text editor. From troubleshooting problems closing it, to configuring what happens when you close it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, there are three ways to exit vim from normal mode:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:q&amp;lt;cr&amp;gt;&lt;/code&gt; This will quit without saving. If there are unsaved changes, you must add an exclamation mark to force it: &lt;code&gt;:q!&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:x&amp;lt;cr&amp;gt;&lt;/code&gt; This will quit &lt;em&gt;and&lt;/em&gt; save.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;ZZ&lt;/code&gt; This is just a synonym of &lt;code&gt;:x&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you are using graphical vim (Gvim), you may also quit by clicking on the exit button on the window.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-07-12T11:20:07.220" LastActivityDate="2016-07-12T11:20:07.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8736" PostTypeId="4" CreationDate="2016-07-12T05:45:41.597" Score="0" Body="Use this tag for questions about exiting vim." OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-07-12T11:19:59.377" LastActivityDate="2016-07-12T11:19:59.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8737" PostTypeId="2" ParentId="8692" CreationDate="2016-07-12T06:29:25.293" Score="2" Body="&lt;p&gt;Here is a function that should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:last_spell_changedtick = {}&#xA;&#xA;function! LoopSpell()&#xA;  &quot; Save current line and column&#xA;  let l:line = line('.')&#xA;  let l:col = col('.')&#xA;&#xA;  &quot; check if the current line/column is already in the last_spell_changedtick&#xA;  if has_key(s:last_spell_changedtick, l:line) == 0&#xA;    let s:last_spell_changedtick[l:line] = {}&#xA;  endif&#xA;&#xA;  if has_key(s:last_spell_changedtick[l:line], l:col) == 0&#xA;    let s:last_spell_changedtick[l:line][l:col] = 0&#xA;  endif&#xA;&#xA;  &quot; If the value already exists, undo the change&#xA;  if s:last_spell_changedtick[l:line][l:col] != 0&#xA;    normal u&#xA;  endif&#xA;&#xA;  &quot; Get the current word&#xA;  let l:current_word = spellbadword()&#xA;  if len(l:current_word) == 0&#xA;    call &amp;lt;SID&amp;gt;Quit()&#xA;  endif&#xA;&#xA;  &quot; Get suggestions for the current word&#xA;  let s:current_word = l:current_word[0]&#xA;  let l:suggestions = spellsuggest(expand(s:current_word))&#xA;&#xA;  &quot; If the current word present no spelling suggestions, pass&#xA;  if len(suggestions) &amp;lt;= 0&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; Replace the word with suggestion&#xA;  silent execute &quot;normal! ce&quot; . l:suggestions[s:last_spell_changedtick[l:line][l:col]]&#xA;  normal! b&#xA;&#xA;  &quot; Increment the count&#xA;  let s:last_spell_changedtick[l:line][l:col] = s:last_spell_changedtick[l:line][l:col] + 1&#xA;&#xA;endfunction&#xA;&#xA;function! LoopConfirm()&#xA;  let s:last_spell_changedtick = {}&#xA;endfunction&#xA;&#xA;nnoremap zz :call LoopSpell()&amp;lt;CR&amp;gt;&#xA;nnoremap z= :call LoopConfirm()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The basic idea is to map every changed word to a line/column pair (so that it will not work only for one element) and check whether the element had already been modified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do the replace, it's pretty much what my plugin does:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;fetch the current misspelled word&lt;/li&gt;&#xA;&lt;li&gt;check if corrections exists&lt;/li&gt;&#xA;&lt;li&gt;replace word with corrected suggestion&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When using this, if you want to go back to the misspelled word you can simply press &lt;code&gt;u&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;LoopConfirm&lt;/code&gt; function reset the dictionary, so if you change your text, you can call it to prevent collisions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me know if you run into any issue/if you have questions.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-07-12T17:45:41.360" LastActivityDate="2016-07-12T17:45:41.360" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8739" PostTypeId="1" CreationDate="2016-07-12T11:16:52.570" Score="1" ViewCount="338" Body="&lt;p&gt;I'm trying to implement a custom regexp string to be used by &lt;a href=&quot;https://github.com/tmhedberg/matchit&quot; rel=&quot;nofollow noreferrer&quot;&gt;matchit.vim&lt;/a&gt; for identifying matching keywords that can be jumped between with &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I found a utility from &lt;a href=&quot;https://www.mathworks.com/matlabcentral/fileexchange/21798-editing-matlab-files-in-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;FileExchange&lt;/a&gt; (in the ftplugin folder when downloaded and unzipped), but it is not perfect in that&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;It detects &lt;code&gt;for&lt;/code&gt;, &lt;code&gt;if&lt;/code&gt;, etc. in comment lines (the &lt;code&gt;%&lt;/code&gt; character in Matlab)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It incorrectly tries to match &lt;code&gt;end&lt;/code&gt; with something for certain formats of array indexing (e.g. &lt;code&gt;MyArray(1,end,2)&lt;/code&gt; uses &lt;code&gt;end&lt;/code&gt; to return a scalar slice, but since it is separated by commas the original tried to match it with something)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It only matches starting/ending pairs (e.g. no &lt;code&gt;elseif&lt;/code&gt; or &lt;code&gt;else&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I've tried making a modified version that fixes these, but I'm getting errors. One is &lt;code&gt;E51: Too many \(&lt;/code&gt;, which means too many groups or something, right? Not sure how that's possible. Also when I include an escaped comma &lt;code&gt;\,&lt;/code&gt; in the &lt;code&gt;\(\)\@!&lt;/code&gt; and &lt;code&gt;\(\)\@&amp;lt;!&lt;/code&gt; blocks the error &lt;em&gt;changes&lt;/em&gt; which suggests to me the string is not getting parsed properly between un-escaped commas (disparate keyword groups) and colons (keywords in each keyword group). But really not sure.&lt;/p&gt;&#xA;&lt;p&gt;Anyway, was hoping for some ideas on what could be wrong here. The original and modified regexps are below. Thanks!&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: &lt;a href=&quot;https://neovim.io/doc/user/pi_matchit.html#b:match_words&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here is the matchit documentation&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It appears that comma separation works (e.g. a simple &lt;code&gt;if:end,for:end&lt;/code&gt;) but when I try more than one line I get the errors:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;E872: (NFA regexp) Too many '(' E51: Too many \(&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is in addition to the error when I include &lt;code&gt;\,&lt;/code&gt; in the &lt;code&gt;[]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Can either be circumvented somehow? It appears my problem has to do with limitations in terms of numbers of regular expressions, and also for some reason matchit tried to parse on the escaped comma.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Original b:match_words&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let s:conditionalEnd = '\([-+{\*\:(\/]\s*\)\@&amp;lt;!\&amp;lt;end\&amp;gt;\(\s*[-+}\:\*\/)]\)\@!'&#xA;let b:match_words = '\&amp;lt;classdef\&amp;gt;\|\&amp;lt;methods\&amp;gt;\|\&amp;lt;events\&amp;gt;\|\&amp;lt;properties\&amp;gt;\|\&amp;lt;if\&amp;gt;\|\&amp;lt;while\&amp;gt;\|\&amp;lt;for\&amp;gt;\|\&amp;lt;switch\&amp;gt;\|\&amp;lt;try\&amp;gt;\|\&amp;lt;function\&amp;gt;:' . s:conditionalEnd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Modified b:match_words&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let s:conditionalEnd = '\(%\+.*\|[\,-+{\*\:(\/]\s*\)'.'\@&amp;lt;!'.'\&amp;lt;end\&amp;gt;'.'\(\s*[\,-+}\:\*\/)]\)'.'\@!'&#xA;let s:noComment = '\(%\+.*\)\@&amp;lt;!'&#xA;let b:match_words = s:noComment.'\&amp;lt;if\&amp;gt;' .':'. s:noComment.'\&amp;lt;elseif\&amp;gt;' .':'. s:noComment.'\&amp;lt;else\&amp;gt;' .':'. s:conditionalEnd .','.&#xA;\ s:noComment.'\&amp;lt;switch\&amp;gt;' .':'. s:noComment.'\&amp;lt;case\&amp;gt;' .':'. s:noComment.'\&amp;lt;otherwise\&amp;gt;' .':'. s:conditionalEnd .','.&#xA;\ s:noComment.'\&amp;lt;classdef\&amp;gt;\|\&amp;lt;properties\&amp;gt;\|\&amp;lt;methods\&amp;gt;\|\&amp;lt;events\&amp;gt;\|\&amp;lt;enumeration\&amp;gt;' .':'. s:conditionalEnd .','.&#xA;\ s:noComment.'\&amp;lt;for\&amp;gt;\|\&amp;lt;parfor\&amp;gt;\|\&amp;lt;while\&amp;gt;' .':'. s:noComment.'\&amp;lt;continue\&amp;gt;' .':'. s:noComment.'\&amp;lt;break\&amp;gt;' .':'. s:conditionalEnd .','.&#xA;\ s:noComment.'\&amp;lt;function\&amp;gt;' .':'. s:noComment.'\&amp;lt;return\&amp;gt;' .':'. s:conditionalEnd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2022-10-31T21:41:21.327" LastActivityDate="2022-10-31T21:41:21.327" Title="Matchit Plugin: issues when resetting regular expressions in &quot;b:match_words&quot; for detecting Matlab file keywords" Tags="|vimrc|regular-expression|delimiter-matching|matlab|plugin-matchit|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8740" PostTypeId="1" CreationDate="2016-07-12T15:06:53.347" Score="1" ViewCount="158" Body="&lt;p&gt;I have been trying to get &lt;a href=&quot;http://pyclewn.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;PyClewn&lt;/a&gt; to work by&#xA;following the instructions step by step without much luck. This is the error I&#xA;get when I type &lt;code&gt;:PyClewn&lt;/code&gt; into vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Running nbstart, &amp;lt;C-C&amp;gt; to interrupt.&#xA;.'import sitecustomize' failed; use -v for traceback&#xA;Traceback (most recent call last):&#xA;  File &quot;/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py&quot;, line 162, in _run_module_as_main&#xA;    &quot;__main__&quot;, fname, loader, pkg_name)&#xA;  File &quot;/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py&quot;, line 72, in _run_code&#xA;    exec code in run_globals&#xA;  File &quot;/usr/local/lib/python3.5/site-packages/clewn/__main__.py&quot;, line 9, in &amp;lt;module&amp;gt;&#xA;    from . import vim&#xA;  File &quot;clewn/vim.py&quot;, line 663&#xA;    self.nbserver = yield from(self.loop.create_server(protocol_factory,&#xA;                             ^&#xA;SyntaxError: invalid syntax&#xA;..................&#xA;The 'Pyclewn' command has been aborted.&#xA;Error: pyclewn failed to start.&#xA;To get the cause of the problem set the global variable 'pyclewn_terminal' to:&#xA;:let g:pyclewn_terminal = &quot;xterm, -e&quot;&#xA;Press the &amp;lt;Enter&amp;gt; key to continue.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also pyclewn won't work from terminal either and get's me this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; python -m clewn&#xA;'import sitecustomize' failed; use -v for traceback&#xA;Traceback (most recent call last):&#xA;  File &quot;/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py&quot;, line 162, in _run_module_as_main&#xA;    &quot;__main__&quot;, fname, loader, pkg_name)&#xA;  File &quot;/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py&quot;, line 72, in _run_code&#xA;    exec code in run_globals&#xA;  File &quot;/usr/local/lib/python3.5/site-packages/clewn/__main__.py&quot;, line 9, in &amp;lt;module&amp;gt;&#xA;    from . import vim&#xA;  File &quot;clewn/vim.py&quot;, line 663&#xA;    self.nbserver = yield from(self.loop.create_server(protocol_factory,&#xA;                             ^&#xA;SyntaxError: invalid syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried reinstalling but didn't fix it. &lt;/p&gt;&#xA;" OwnerUserId="8403" LastEditorUserId="1841" LastEditDate="2016-07-12T15:59:37.007" LastActivityDate="2016-07-12T17:52:49.320" Title="PyClewn Failed to start error" Tags="|terminal|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8741" PostTypeId="1" CreationDate="2016-07-12T16:52:26.217" Score="36" ViewCount="34189" Body="&lt;p&gt;I love the &quot;hlsearch&quot; setting, but after I'm done searching, I find it obnoxious. Especially if I search for something that has a lot of matches. I know that I can turn this off with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nohlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this takes a whole 16 keystrokes, and even more annoyingly, I have to turn it back on for my next search with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set hlsearch    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can have hlsearch automatically toggle on when I start searching, and off when I am done searching? For example, if I enter insert mode, or modify the text, have hlsearch turn off without any additional keystrokes?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-07-12T17:55:43.803" LastActivityDate="2023-03-18T15:36:56.147" Title="How to automatically turn off &quot;hlsearch&quot; after I'm done searching?" Tags="|search|highlight|" AnswerCount="12" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8742" PostTypeId="2" ParentId="8741" CreationDate="2016-07-12T16:52:26.217" Score="42" Body="&lt;p&gt;There is a much more convenient way. Rather than using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nohlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which actually turns the hlsearch setting off, use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nohls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will only turn hlsearch off until you search again. From &lt;code&gt;:help nohls&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                 *'hlsearch'* *'hls'* *'nohlsearch'* *'nohls'*&#xA;'hlsearch' 'hls'    boolean (default off)&#xA;            global&#xA;            {not in Vi}&#xA;            {not available when compiled without the&#xA;            |+extra_search| feature}&#xA;&#xA;    ...&#xA;&#xA;    When you get bored looking at the highlighted matches, you can turn it&#xA;    off with |:nohlsearch|.  This does **not change the option value**, as&#xA;    soon as you use a search command, the highlighting comes back.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this solution isn't perfect, since you still have to type out &lt;code&gt;:nohls&lt;/code&gt; which is pain to do after every search. You can get around this with a mapping, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;esc&amp;gt;&amp;lt;esc&amp;gt; :silent! nohls&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But there is an even &lt;em&gt;better&lt;/em&gt; solution! &lt;a href=&quot;https://github.com/haya14busa/incsearch.vim&quot;&gt;haya14busa/incsearch.vim&lt;/a&gt;. This is, at least in my opinion, an &lt;em&gt;essential&lt;/em&gt; vim plugin. The main feature is that &lt;strong&gt;all&lt;/strong&gt; search matches are highlighted in real time, as you are typing out your regex. For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UUHD4.gif&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UUHD4.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, a secondary feature that is also provided is the option to &lt;em&gt;immediately&lt;/em&gt; toggle hlsearch on and off when you start/stop searching. To enable this feature, you will have to add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set hlsearch&#xA;let g:incsearch#auto_nohlsearch = 1&#xA;map n  &amp;lt;Plug&amp;gt;(incsearch-nohl-n)&#xA;map N  &amp;lt;Plug&amp;gt;(incsearch-nohl-N)&#xA;map *  &amp;lt;Plug&amp;gt;(incsearch-nohl-*)&#xA;map #  &amp;lt;Plug&amp;gt;(incsearch-nohl-#)&#xA;map g* &amp;lt;Plug&amp;gt;(incsearch-nohl-g*)&#xA;map g# &amp;lt;Plug&amp;gt;(incsearch-nohl-g#)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have any other &lt;code&gt;n&lt;/code&gt; mappings, you will have to turn these off. For example, I used to have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap n nzz&#xA;nnoremap N Nzz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These two mappings are not compatible with eachother!&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-12T16:52:26.217" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8743" PostTypeId="2" ParentId="8740" CreationDate="2016-07-12T17:52:49.320" Score="1" Body="&lt;p&gt;Hey guys I found what the problem was. In the second output you see above that it goes to my python2.7 directory but the PyClewn was compiled/installed on my python3 directory and when I went to check to the Python2.7 directory there was nothing there and that's why it wouldn't run. &#xA;Working fine now. &lt;/p&gt;&#xA;" OwnerUserId="8403" LastActivityDate="2016-07-12T17:52:49.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8744" PostTypeId="1" CreationDate="2016-07-12T19:21:22.730" Score="3" ViewCount="531" Body="&lt;p&gt;I screwed up my vimrc and now solarized doesn't work. I think I fixed it but now I'm worried about the rest of my vimrc. Can someone tell me if it's properly organized?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;set pastetoggle=&amp;lt;F2&amp;gt;&#xA;filetype off                  &quot; required&#xA;set smartindent&#xA;set spell spelllang=en_us&#xA;set relativenumber&#xA;set number&#xA;set showcmd&#xA;set cursorline&#xA;set wildmenu&#xA;set lazyredraw&#xA;set showmatch&#xA;set incsearch           &quot; search as characters are entered&#xA;set hlsearch            &quot; highlight matches&#xA;set background=dark&#xA;&quot; move vertically by visual line&#xA;nnoremap j gj&#xA;nnoremap k gk&#xA;&#xA;&#xA;imap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; pumvisible() ? &quot;\&amp;lt;c-y&amp;gt;&quot; : &quot;&amp;lt;Plug&amp;gt;delimitMateCR&quot;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;&#xA;&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'Chiel92/vim-autoformat'&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'rust-lang/rust.vim'&#xA;Plugin 'vim-airline/vim-airline'&#xA;Bundle 'airblade/vim-gitgutter'&#xA;Bundle 'Conque-Shell'&#xA;Bundle 'altercation/vim-colors-solarized'&#xA;Bundle 'Valloric/YouCompleteMe'&#xA;Bundle 'scrooloose/syntastic'&#xA;Bundle 'scrooloose/nerdtree'&#xA;Bundle 'tpope/vim-sensible'&#xA;Bundle 'Raimondi/delimitMate'&#xA;&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on&#xA;colorscheme solarized&#xA;syntax enable&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;let g:syntastic_cpp_compiler = &quot;g++&quot;&#xA;let g:syntastic_cpp_compiler_options = &quot;-std=c++11 -Wall&quot;&#xA;let g:syntastic_c_remove_include_errors = 1&#xA;let g:syntastic_cpp_remove_include_errors = 1&#xA;let g:syntastic_auto_loc_list = 0&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:ycm_enable_diagnostic_signs = 1&#xA;let g:ycm_goto_buffer_command = 'same-buffer' &quot;[ 'same-buffer', 'horizontal-split', 'vertical-split', 'new-tab' ]&#xA;let g:ycm_filetype_whitelist = { '*': 1 }&#xA;let g:ycm_key_invoke_completion = '&amp;lt;C-Space&amp;gt;'&#xA;let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8407" LastActivityDate="2016-07-12T19:21:22.730" Title="Is my vimrc properly organized?" Tags="|vimrc|" AnswerCount="0" CommentCount="6" ClosedDate="2016-07-13T08:04:23.193" ContentLicense="CC BY-SA 3.0" />
  <row Id="8745" PostTypeId="1" CreationDate="2016-07-12T19:43:27.840" Score="1" ViewCount="857" Body="&lt;p&gt;Would be nice to color the single column just left of the beginning of the line, but I don't think it has a group name like &lt;code&gt;CursorLine&lt;/code&gt;. Anyone have any ideas? Maybe some simple macro would do, using &lt;code&gt;colorcolumn&lt;/code&gt;, but I'm not sure where to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="51" LastEditDate="2016-07-13T21:33:13.933" LastActivityDate="2016-07-13T21:33:13.933" Title="How to color the column right after the line numbers and before the beginning of line?" Tags="|vimrc|highlight|colorcolumn|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8746" PostTypeId="1" AcceptedAnswerId="8752" CreationDate="2016-07-12T20:21:44.577" Score="-2" ViewCount="562" Body="&lt;p&gt;Since Vim is one of the most popular editors maybe it does not need marketing, but does it have a marketing symbol, like the Linux Penguin?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="2920" LastEditDate="2016-07-12T20:58:17.253" LastActivityDate="2016-07-13T07:56:22.987" Title="Does Vim have a marketing symbol?" Tags="|history-of|" AnswerCount="1" CommentCount="7" ClosedDate="2016-07-15T05:15:50.967" ContentLicense="CC BY-SA 3.0" />
  <row Id="8748" PostTypeId="2" ParentId="8692" CreationDate="2016-07-13T03:16:55.737" Score="6" Body="&lt;p&gt;Here's what I came up with:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Spell Rotate&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vE9sM.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vE9sM.gif&quot; alt=&quot;spell rotate&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Features&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt; marks are used to keep track of the text being worked on.  Making a change elsewhere will effectively &quot;accept&quot; the suggested change.&lt;/li&gt;&#xA;&lt;li&gt;Accepts a count.&lt;/li&gt;&#xA;&lt;li&gt;Goes backwards using &lt;code&gt;zp&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Repeatable using &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-repeat&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Undo once to restore the original word regardless of how many suggestions have been cycled.&lt;/li&gt;&#xA;&lt;li&gt;Works in visual mode to get suggestions for split words (e.g. &quot;head line&quot; -&gt; &quot;headline&quot;)&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Uses &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; marks to keep track of the text.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Note&lt;/strong&gt;: Doesn't seem to be repeatable with &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-repeat&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;The original word being changed is kept in the unnamed register.&lt;/li&gt;&#xA;&lt;li&gt;The original, previous, current, and next suggestions are displayed in the command line.&lt;/li&gt;&#xA;&lt;li&gt;Naive command &lt;code&gt;:SpellRotateSubAll&lt;/code&gt; to replace all text matching the original with the current suggestion.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Plugin: &lt;a href=&quot;https://github.com/tweekmonster/spellrotate.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;spellrotate.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:spell_rotate(dir, visual) abort&#xA;  if a:visual&#xA;    &quot; Restore selection.  This line is seen throughout the function if the&#xA;    &quot; selection is cleared right before a potential return.&#xA;    normal! gv&#xA;    if getline(&quot;'&amp;lt;&quot;) != getline(&quot;'&amp;gt;&quot;)&#xA;      echo 'Spell Rotate: can''t give suggestions for multiple lines'&#xA;      return&#xA;    endif&#xA;  endif&#xA;&#xA;  if !&amp;amp;spell&#xA;    echo 'Spell Rotate: spell not enabled.'&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; Keep the view to restore after a possible jump using the change marks.&#xA;  let view = winsaveview()&#xA;  let on_spell_word = 0&#xA;&#xA;  if exists('b:_spell') &amp;amp;&amp;amp; getline(&quot;'[&quot;) == getline(&quot;']&quot;)&#xA;    let bounds = b:_spell.bounds&#xA;    &quot; Confirm that the cursor is between the bounds being tracked.&#xA;    let on_spell_word = bounds[0][0] == bounds[1][0]&#xA;          \ &amp;amp;&amp;amp; view.lnum == bounds[0][0]&#xA;          \ &amp;amp;&amp;amp; view.col &amp;gt;= bounds[0][1]&#xA;          \ &amp;amp;&amp;amp; view.col &amp;lt;= bounds[1][1]&#xA;  endif&#xA;&#xA;  &quot; Make sure the correct register is used&#xA;  let register = &amp;amp;clipboard == 'unnamed'&#xA;        \ ? '*' : &amp;amp;clipboard == 'unnamedplus'&#xA;        \ ? '+' : '&quot;'&#xA;&#xA;  &quot; Store the text in the unnamed register.  Note that yanking will clear&#xA;  &quot; the visual selection.&#xA;  if on_spell_word&#xA;    if a:visual&#xA;      keepjumps normal! y&#xA;    else&#xA;      keepjumps normal! `[v`]y&#xA;    endif&#xA;    call winrestview(view)&#xA;  elseif a:visual&#xA;    keepjumps normal! y&#xA;  else&#xA;    keepjumps normal! viwy&#xA;  endif&#xA;&#xA;  let cword = getreg(register)&#xA;&#xA;  if !on_spell_word || b:_spell.alts[b:_spell.index] != cword&#xA;    &quot; Start a new list of suggestions.  The word being replaced will&#xA;    &quot; always be at index 0.&#xA;    let spell_list = [cword] + spellsuggest(cword)&#xA;    let b:_spell = {&#xA;          \ 'index': 0,&#xA;          \ 'bounds': [[0, 0], [0, 0]],&#xA;          \ 'cword': cword,&#xA;          \ 'alts': spell_list,&#xA;          \ 'n_alts': len(spell_list),&#xA;          \ }&#xA;&#xA;    if len(b:_spell.alts) &amp;gt; 1&#xA;      &quot; Do something to change the buffer and force a new undo point to be&#xA;      &quot; created.  This is because `undojoin` is used below and it won't&#xA;      &quot; work if we're not at the last point of the undo history.&#xA;      if a:visual&#xA;        normal! xP&#xA;      else&#xA;        normal! ix&#xA;        normal! x&#xA;      endif&#xA;    endif&#xA;  endif&#xA;&#xA;  if a:visual&#xA;    normal! gv&#xA;  endif&#xA;&#xA;  if len(b:_spell.alts) &amp;lt; 2&#xA;    echo 'Spell Rotate: No suggestions'&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; Force the next changes to be part of the last undo point&#xA;  undojoin&#xA;&#xA;  &quot; Setup vim-repeat if it exists.&#xA;  silent! call repeat#set(printf(&quot;\&amp;lt;Plug&amp;gt;(SpellRotate%s%s)&quot;,&#xA;        \ a:dir &amp;lt; 0 ? 'Backward' : 'Forward', a:visual ? 'V' : ''))&#xA;&#xA;  &quot; Get the suggested, previous, and next text&#xA;  let i = (b:_spell.index + (a:dir * v:count1)) % b:_spell.n_alts&#xA;  if i &amp;lt; 0&#xA;    let i += b:_spell.n_alts&#xA;  endif&#xA;&#xA;  let next = (i + 1) % b:_spell.n_alts&#xA;  let prev = (i - 1) % b:_spell.n_alts&#xA;  if prev &amp;lt; 0&#xA;    let prev += b:_spell.n_alts&#xA;  endif&#xA;&#xA;  let next_word = b:_spell.alts[next]&#xA;  let prev_word = b:_spell.alts[prev]&#xA;&#xA;  let b:_spell.index = i&#xA;  call setreg(register, b:_spell.alts[i])&#xA;&#xA;  if a:visual&#xA;    normal! p`[v`]&#xA;  else&#xA;    keepjumps normal! gvp&#xA;  endif&#xA;&#xA;  &quot; Keep the original word in the unnamed register&#xA;  call setreg(register, b:_spell.cword)&#xA;&#xA;  let b:_spell.bounds = [&#xA;        \ getpos(a:visual ? &quot;'&amp;lt;&quot; : &quot;'[&quot;)[1:2],&#xA;        \ getpos(a:visual ? &quot;'&amp;gt;&quot; : &quot;']&quot;)[1:2],&#xA;        \ ]&#xA;&#xA;  echon printf('Suggestion %*s of %s for &quot;', strlen(b:_spell.n_alts - 1), b:_spell.index, b:_spell.n_alts - 1)&#xA;  echohl Title&#xA;  echon b:_spell.cword&#xA;  echohl None&#xA;  echon '&quot;:  '&#xA;&#xA;  if a:dir &amp;lt; 0&#xA;    echohl String&#xA;  else&#xA;    echohl Comment&#xA;  endif&#xA;  echon prev_word&#xA;  echohl None&#xA;&#xA;  echon ' &amp;lt; '&#xA;&#xA;  echohl Keyword&#xA;  echon b:_spell.alts[i]&#xA;  echohl None&#xA;&#xA;  echon ' &amp;gt; '&#xA;&#xA;  if a:dir &amp;gt; 0&#xA;    echohl String&#xA;  else&#xA;    echohl Comment&#xA;  endif&#xA;  echon next_word&#xA;  echohl None&#xA;&#xA;  redraw&#xA;endfunction&#xA;&#xA;&#xA;function! s:spell_rotate_suball() abort&#xA;  if !exists('b:_spell') || len(b:_spell.alts) &amp;lt; 2&#xA;    return&#xA;  endif&#xA;  execute '%s/'.b:_spell.cword.'/'.b:_spell.alts[b:_spell.index].'/g'&#xA;endfunction&#xA;&#xA;&#xA;command! SpellRotateSubAll call s:spell_rotate_suball()&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(SpellRotateForward) :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;spell_rotate(v:count1, 0)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(SpellRotateBackward) :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;spell_rotate(-v:count1, 0)&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(SpellRotateForwardV) :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;spell_rotate(v:count1, 1)&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(SpellRotateBackwardV) :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;spell_rotate(-v:count1, 1)&amp;lt;cr&amp;gt;&#xA;&#xA;nmap &amp;lt;silent&amp;gt; zz &amp;lt;Plug&amp;gt;(SpellRotateForward)&#xA;nmap &amp;lt;silent&amp;gt; zp &amp;lt;Plug&amp;gt;(SpellRotateBackward)&#xA;vmap &amp;lt;silent&amp;gt; zz &amp;lt;Plug&amp;gt;(SpellRotateForwardV)&#xA;vmap &amp;lt;silent&amp;gt; zp &amp;lt;Plug&amp;gt;(SpellRotateBackwardV)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-07-13T05:18:45.200" LastActivityDate="2016-07-13T05:18:45.200" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8749" PostTypeId="1" AcceptedAnswerId="8750" CreationDate="2016-07-13T06:29:41.627" Score="1" ViewCount="57" Body="&lt;p&gt;In my syntax description file I'm trying to define something like the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match arbSAMPLEop   &quot;\&amp;lt;\(TEX\|TEX_SAT\|TXP\|TXP_SAT\|TXB\|TXB_SAT\)\&amp;gt;&quot;&#xA;syn match arbTexTarget     &quot;\&amp;lt;\(1D\|2D\|3D\|CUBE\|RECT\)\&amp;gt;&quot; contained&#xA;syn region arbSampleInstruction start=&quot;\&amp;lt;\(TEX\|TEX_SAT\|TXP\|TXP_SAT\|TXB\|TXB_SAT\)\&amp;gt;&quot; end=&quot;;&quot; contains=arbSAMPLEop,arbTexTarget&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows to highlight texture sampling instructions and texture targets only inside the region started by a sampling instruction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What bothers me is that the region starts by &lt;code&gt;arbSAMPLEop&lt;/code&gt;, but the string to define &lt;code&gt;arbSAMPLEop&lt;/code&gt; is copy-pasted as the &lt;code&gt;start=&lt;/code&gt; pattern. Is there any way I could achieve the same without duplicating the string?&lt;/p&gt;&#xA;" OwnerUserId="1081" LastActivityDate="2016-07-13T07:21:31.740" Title="How to avoid repeating pattern strings in syntax files?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8750" PostTypeId="2" ParentId="8749" CreationDate="2016-07-13T07:00:59.447" Score="2" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match arbTexTarget &quot;\&amp;lt;\(1D\|2D\|3D\|CUBE\|RECT\)\&amp;gt;&quot; contained&#xA;syn region arbSampleInstruction matchgroup=arbSAMPLEop start=&quot;\&amp;lt;\(TEX\|TEX_SAT\|TXP\|TXP_SAT\|TXB\|TXB_SAT\)\&amp;gt;&quot; end=&quot;;&quot; contains=arbTexTarget&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;matchgroup&lt;/code&gt; allows highlighting the delimiting patterns of&#xA;a region separately from the body of the region.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help syn-matchgroup&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really had to, you could store a pattern in a string variable, and then use &lt;code&gt;execute&lt;/code&gt; to build up your &lt;code&gt;syntax&lt;/code&gt; command. However I doubt this is necessary in a well-structured syntax file.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-07-13T07:21:31.740" LastActivityDate="2016-07-13T07:21:31.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8751" PostTypeId="1" AcceptedAnswerId="8755" CreationDate="2016-07-13T07:17:58.933" Score="12" ViewCount="21515" Body="&lt;h1&gt;Original post&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I've got a colorscheme configured in my .vimrc but sometimes I'd like to turn it off completely which means that I would like Vim to use the default background and foreground colors of my terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that I don't know how to easily do it. When I use &lt;code&gt;:syntax off&lt;/code&gt; Vim turns off most of its coloring but it doesn't remove the cursorline color. It doesn't change the background color to the terminal's default one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command like &lt;code&gt;:nocolorscheme&lt;/code&gt; or &lt;code&gt;vim -u NONE&lt;/code&gt; but just for the colors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware of the fact that I can create a custom .vimrc file and load it with the &lt;code&gt;-u&lt;/code&gt; option. I am looking for an easier solution though.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Major update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Because you've suggested me a number of different commands and approaches I decided to show you some photos of the screen after calling those commands.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Terminal envirnoment&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I use &lt;a href=&quot;http://st.suckless.org/&quot; rel=&quot;noreferrer&quot;&gt;st(1) terminal from suckless.org&lt;/a&gt; with a custom config.h so that I've got &lt;code&gt;defaultfg = 10&lt;/code&gt; (bright green) and &lt;code&gt;defaultbg = 0&lt;/code&gt; (black). I'm running the GNU/Linux version that PocketC.H.I.P. ships with (&lt;code&gt;uname -a&lt;/code&gt; results in &lt;em&gt;Linux chip 4.3.0-ntc #1 SMP Wed May 11 21:57:30 UTC 2016 arm7l GNU/Linux&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Screenshots&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;h3&gt;No colorscheme (this is what I want)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JMyc2m.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JMyc2m.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I want to achieve without having to start Vim with &lt;code&gt;vim -u NONE&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h3&gt;Normal colors&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/S7MmQm.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S7MmQm.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get these colors when:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I normally start my Vim (this is my standard colorscheme).&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I call &lt;code&gt;:set t_Co=0&lt;/code&gt;.&lt;br&gt;&#xA;It is worth noting that it doesn't change anything when I use my custom monokai colorscheme. It does change the appearance in the default colorscheme as you can see in 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The funny thing is that the output of &lt;code&gt;:verbose set t_Co?&lt;/code&gt; called subsequently is &lt;code&gt;t_Co=256&lt;/code&gt; which indicates that &lt;em&gt;literaly&lt;/em&gt; nothing has changed. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I start Vim with &lt;code&gt;TERM=xterm vim&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h3&gt;Default colors&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zZHY3m.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zZHY3m.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get these colors when:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I call &lt;code&gt;:colorscheme default&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h3&gt;Vim removed most of colors but doesn't fall back into terminal's defaults&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/f2qoUm.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/f2qoUm.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get it after:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Calling &lt;code&gt;:syntax off&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h3&gt;Almost no colorscheme&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/W2x3Em.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/W2x3Em.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get this after running these 4 commands one after another:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; The effect is more visible on the default colorscheme &#xA;&quot; than on my molokai colorscheme.&#xA;:set t_Co=0&#xA;:colorscheme default&#xA;:hi clear&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;:hi LineNr&lt;/code&gt; afterwards I get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt; LineNr          XXX term=underline ctermfg=6 guifg=Brown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h3&gt;Strings and types underlined in a C source file&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zX2ofm.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zX2ofm.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After applying &lt;code&gt;:set term=vt100&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h3&gt;Broken redrawing in Vim&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=Yz6g4kXFQik&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://img.youtube.com/vi/Yz6g4kXFQik/mqdefault.jpg&quot; alt=&quot;Video thumbnail&quot;&gt;&lt;br&gt;&#xA;Vim broke after calling :set term=builtin_dumb (video) &lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After applying &lt;code&gt;:set term=builtin_dumb&lt;/code&gt; my Vim forgets how to redraw lines as I move around using &lt;kbd&gt;j&lt;/kbd&gt; and &lt;kbd&gt;k&lt;/kbd&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h3&gt;Examine the defaults of my temrminal&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gVHAQ.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gVHAQ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I get after running &lt;code&gt;echo -e &quot; \033[0;4mfoo\033[0;0mbar&quot;&lt;/code&gt; in my terminal.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6043" LastEditorUserId="6043" LastEditDate="2016-07-20T20:12:54.427" LastActivityDate="2023-12-31T07:56:32.947" Title="How to completely turn off colorscheme?" Tags="|syntax-highlighting|colorscheme|" AnswerCount="4" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="8752" PostTypeId="2" ParentId="8746" CreationDate="2016-07-13T07:56:22.987" Score="4" Body="&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vim.sexy/img/Vimlogo.svg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://vim.sexy/img/Vimlogo.svg&quot; alt=&quot;Vim Logo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks Tumbler41 for the link.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-13T07:56:22.987" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8753" PostTypeId="2" ParentId="8741" CreationDate="2016-07-13T10:07:41.490" Score="6" Body="&lt;p&gt;As you've &lt;a href=&quot;https://vi.stackexchange.com/a/8742/343&quot;&gt;already noted in your own answer&lt;/a&gt;, it's far more efficient to turn off highlighting with the &lt;code&gt;:nohlsearch&lt;/code&gt; command (which can be abbreviated to &lt;code&gt;:noh&lt;/code&gt;) rather than turning off the entire feature and then turning it back on the next time you search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to switch off highlighting every time you use &lt;code&gt;i&lt;/code&gt; to enter insert mode, you can create a simple mapping to do so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap i :noh&amp;lt;cr&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's left as an exercise for the reader to create similar mappings for other commands where they want highlighting switched off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More recent versions of Vim have an &lt;code&gt;InsertEnter&lt;/code&gt; autocommand which you might think could be used to easily create a cleaner implementation of switching off highlighting, but unfortunately, the &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%3Anohlsearch&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:nohlsearch&lt;/code&gt; command has no effect within an autocommand&lt;/a&gt;. A possible workaround is instead to reset the search pattern when entering insert mode, but that obviously has side effects you may not desire:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup ClearSearch&#xA;  autocmd!&#xA;  autocmd InsertEnter * let @/ = ''&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is, however, a better technique, which is to use &lt;code&gt;feedkeys&lt;/code&gt; from the autocommand. This is what the &lt;a href=&quot;https://github.com/romainl/vim-cool&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-cool plugin&lt;/a&gt; mentioned in &lt;a href=&quot;https://vi.stackexchange.com/a/13378/343&quot;&gt;Jon Parise's answer&lt;/a&gt; uses.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-02-11T16:21:31.883" LastActivityDate="2020-02-11T16:21:31.883" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8754" PostTypeId="1" AcceptedAnswerId="8756" CreationDate="2016-07-13T10:19:20.367" Score="0" ViewCount="167" Body="&lt;p&gt;I would like to easily transform these two lines : &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;One line.&lt;br&gt;&#xA;  long line with many words in this example&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;into the line :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;One long line with many words in this example line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How I currently do it :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;place cursor on the &lt;em&gt;l&lt;/em&gt; of &lt;em&gt;long&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;enter visual mode&lt;/li&gt;&#xA;&lt;li&gt;go to the end of the line with &lt;code&gt;$&lt;/code&gt; key&lt;/li&gt;&#xA;&lt;li&gt;go one character backward (to deselect the line-break character)&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;x&lt;/code&gt; to cut the words in the line and leave visual mode&lt;/li&gt;&#xA;&lt;li&gt;place cursor on the space betwen &lt;em&gt;One&lt;/em&gt; and &lt;em&gt;line&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;p&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;add a space after &lt;em&gt;example&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How I wish it was possible to do it :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;place cursor anywhere on second line&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;shift-v&lt;/code&gt; to visualize the second line&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;x&lt;/code&gt; (optionally &lt;code&gt;y&lt;/code&gt; to keep second line)&lt;/li&gt;&#xA;&lt;li&gt;place cursor on the space betwen &lt;em&gt;One&lt;/em&gt; and &lt;em&gt;line&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;hit a &lt;code&gt;magick key&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;if needs be, insert the space&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Remarks : &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In general I would like not to keep the trailing blank characters from the second line.&lt;/li&gt;&#xA;&lt;li&gt;it is already possible to paste a line that you cut with &lt;code&gt;shift-v&lt;/code&gt; then &lt;code&gt;x&lt;/code&gt; but it will be pasted as a line, before (or after) the current line.&lt;/li&gt;&#xA;&lt;li&gt;if the two lines are side by side and if one simply wants to move the second line at the end of the first one, one can use the join command (that has options regarding spaces to insert).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated !&lt;/p&gt;&#xA;" OwnerUserId="8409" LastActivityDate="2016-07-13T12:11:15.007" Title="How to paste a line inside another line ? i.e. How to paste a line as words?" Tags="|key-bindings|cursor-movement|cut-copy-paste|visual-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8755" PostTypeId="2" ParentId="8751" CreationDate="2016-07-13T10:25:04.417" Score="8" Body="&lt;h2&gt;Disabling Colours Entirely&lt;/h2&gt;&#xA;&lt;p&gt;If you want Vim not to use colours at &lt;em&gt;all&lt;/em&gt;, you just need to run the command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set t_Co=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This tells Vim that it is running in a terminal that does not support colours, so Vim will only output black and white text (which will then be displayed by your terminal in its default colours).&lt;/p&gt;&#xA;&lt;p&gt;However, note that after changing the &lt;code&gt;t_Co&lt;/code&gt; setting the current colorscheme is reloaded (so that it can make appropriate changes to the colours it defines). The &amp;quot;monokai&amp;quot; colorscheme you are using starts with the line &lt;code&gt;:set t_Co=256&lt;/code&gt;, immediately resetting the option.&lt;/p&gt;&#xA;&lt;p&gt;I'd argue that this is incorrect behaviour, and should be filed as a bug with the maintainer of that colorscheme. Of course, they might well disagree and argue that as their colorscheme requires 256 colours, it doesn't make sense to try and use it in a terminal which does not support this (and that this line helps monokai work correctly when Vim is running in an incorrectly configured terminal).&lt;/p&gt;&#xA;&lt;p&gt;Either way, you will need to change colorscheme away from monokai first before setting the &lt;code&gt;t_Co&lt;/code&gt; option, as you have discovered.&lt;/p&gt;&#xA;&lt;h2&gt;Restricting Colours to Those Used Commonly in the Shell&lt;/h2&gt;&#xA;&lt;p&gt;The colours that Vim uses for its output can be defined and viewed with the &lt;code&gt;:highlight&lt;/code&gt; command. Running &lt;code&gt;:highlight clear&lt;/code&gt; will reset these to Vim's defaults (effectively the same as running &lt;code&gt;:colorscheme defaults&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Excerpt from &lt;code&gt;:help :highlight&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:hi[ghlight] clear        Reset all highlighting to the defaults.  Removes all  &#xA;                          highlighting for groups added by the user!&#xA;                          Uses the current value of 'background' to decide which&#xA;                          default colors to use.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;(N.B. Note the comment about the &lt;code&gt;'background'&lt;/code&gt; option.)&lt;/p&gt;&#xA;&lt;p&gt;If this doesn't produce the output you desire, you have a couple of options.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If you're currently using Vim in 256-colour mode, you could try using 16-colour mode instead, as this would result in Vim selecting from the palette of colours that you are more likely to see when in the shell.&lt;/p&gt;&#xA;&lt;p&gt;The clean way to do this is by running Vim with a different $TERM variable set. The value you need to use depends on your terminal, but, for example, if your &lt;code&gt;$TERM&lt;/code&gt; is usually &lt;code&gt;xterm-256color&lt;/code&gt;, then running vim with the following command will do the trick:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; TERM=xterm vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;(You can also achieve a similar effect in a more hacky fashion by setting the terminal option directly inside vim: &lt;code&gt;:set t_Co=16&lt;/code&gt;.)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Alternatively if it's only a handful of particular items that are coloured incorrectly, you could just change the colours of those items with the &lt;code&gt;:highlight&lt;/code&gt; command. e.g. to remove the background colour from the cursor line:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; :highlight CursorLine ctermbg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you're not sure which group you need to change, you can either just run &lt;code&gt;:highlight&lt;/code&gt; with no arguments or you can run: &lt;code&gt;:so $VIMRUNTIME/syntax/hitest.vim&lt;/code&gt; to open a new window displaying all current highlighting.&lt;/p&gt;&#xA;&lt;p&gt;See the sections at the bottom of this answer for tips on how to make doing this quick with a custom command or by setting up a new colorscheme.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2&gt;Background Colour Erase (BCE)&lt;/h2&gt;&#xA;&lt;p&gt;If you have a problem with the background looking different when it contains text, you might be encountering BCE (Background Color Erase). You can disable this with the command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set t_ut=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/238/tmux-is-changing-part-of-the-background-in-vim/247#247&quot;&gt;There is a specific question about this here&lt;/a&gt;, and the problem is covered in more detail in &lt;a href=&quot;https://sunaku.github.io/vim-256color-bce.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this blog post&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Update (Overriding Underlines):&lt;/h2&gt;&#xA;&lt;p&gt;From our discussion in the comments, it's become clear that one of the problems you have is that your terminal displays underlined text in a different colour. You have two options to workaround this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Fix your terminal configuration so it renders underlined text in the same colour! I can't help you with this.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Turn off the underlining in Vim. You can do this with the &lt;code&gt;:highlight&lt;/code&gt; command: e.g. the following will remove all colour/formatting from the line numbers:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; :highlight LineNr NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2&gt;Switching the Colours Off with a Command&lt;/h2&gt;&#xA;&lt;p&gt;In order to make this quick to do, you could set up a command to do all the required steps in one go:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; function! TurnOffColors()&#xA;   :set t_Co=0&#xA;   :highlight LineNr NONE&#xA;   :highlight CursorLine NONE&#xA;   &amp;quot; Add any other necessary highlight lines here&#xA; endfunction&#xA; &#xA; command! TurnOffColors call TurnOffColors()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Creating a New &lt;code&gt;colorscheme&lt;/code&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Alternatively, you could create a new &amp;quot;NoColorsNoUnderlines&amp;quot; colorscheme where you turn off underlines as appropriate. For instructions for how to do this, run the command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:edit $VIMRUNTIME/colors/README.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You could use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=335&quot; rel=&quot;nofollow noreferrer&quot;&gt;this black and white colorscheme&lt;/a&gt; as a starting point.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-07-22T08:30:46.833" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8756" PostTypeId="2" ParentId="8754" CreationDate="2016-07-13T11:07:16.087" Score="1" Body="&lt;p&gt;To be honest I don't see the point of creating a custom mapping (what you called &lt;code&gt;magic key&lt;/code&gt;) to a simple scenario like this. You have many ways to achieve this, without even using visual mode. One approach could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gJBdf.A &amp;lt;esc&amp;gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;gJ&lt;/code&gt;: on the first line, join with the second without including spaces&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt;: move to second word&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;df.&lt;/code&gt;: delete 'one.'. This could be replaced with &lt;code&gt;d&amp;lt;count&amp;gt;f&amp;lt;char&amp;gt;&lt;/code&gt; or &lt;code&gt;d/&amp;lt;pattern&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;&lt;/code&gt;: insert an space at the end&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt;: past the deleted contents&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If this has to be repeated several times it would be easier to record a macro using some pattern on the target lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Going back to your &lt;code&gt;magic key&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F3&amp;gt; i&amp;lt;c-r&amp;gt;&quot;&amp;lt;backspace&amp;gt;&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-R&quot; rel=&quot;nofollow&quot;&gt;The &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt; in insert mode&lt;/a&gt; places the contents of the specified register in place (&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#quote_quote&quot; rel=&quot;nofollow&quot;&gt;the unnamed register &lt;code&gt;&quot;&lt;/code&gt;&lt;/a&gt; in this case, which holds the last copied/deleted text), so it will drop the end of the first line to next line due to the carriage return deleted along the second line. The mapping then replaces this &lt;code&gt;\n&lt;/code&gt; with a space and leaves insert mode. Note that this is based on the &lt;code&gt;'backspace'&lt;/code&gt; options containing &lt;code&gt;eol&lt;/code&gt;, which is part of $VIMRUNTIME/mswin.vim. This option can be saved and restored by the mapping if you don't use it, or you could join the lines in insert mode.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-07-13T12:11:15.007" LastActivityDate="2016-07-13T12:11:15.007" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8757" PostTypeId="1" CreationDate="2016-07-13T11:23:25.983" Score="5" ViewCount="1638" Body="&lt;p&gt;When I insert a line break inside a line of Python 3 code, the remaining part of the line is indented by two additional tab widths (2 time 4 spaces) in the next line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Before&#xA;example_function(argument_name_1, argument_name_2)&#xA;&#xA;# After&#xA;example_function(argument_name_1,&#xA;        argument_name_2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I change this to only one additional indent?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Desired&#xA;example_function(argument_name_1,&#xA;    argument_name_2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3255" LastEditorUserId="1841" LastEditDate="2016-07-13T11:30:33.170" LastActivityDate="2019-11-03T16:42:35.967" Title="How to set the relative indent after breaking Python lines?" Tags="|formatting|filetype-python|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8758" PostTypeId="2" ParentId="8754" CreationDate="2016-07-13T11:40:48.890" Score="1" Body="&lt;p&gt;You could use something like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;v 0v$hd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then your key flow would become&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Go anywhere on the second line&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; to get yank the content of the second line and delete it&lt;/li&gt;&#xA;&lt;li&gt;Go to the space first line (e.g. &lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;space&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;kbd&gt;p&lt;/kbd&gt; to put the second line between the two words.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(You could also remove the last &lt;code&gt;d&lt;/code&gt; of the mapping to make &lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; only visually select the line to let you do whatever you want with it)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; As OP pointed out in the comment, using &lt;code&gt;^&lt;/code&gt; instead of &lt;code&gt;0&lt;/code&gt; is a good way to get rid of leading whitespaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;v ^v$hd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-07-13T12:08:43.470" LastActivityDate="2016-07-13T12:08:43.470" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8759" PostTypeId="1" AcceptedAnswerId="8760" CreationDate="2016-07-13T12:02:28.370" Score="2" ViewCount="316" Body="&lt;p&gt;In a new buffer, the expression &lt;code&gt;&amp;amp;l:autoread&lt;/code&gt; evaluates to the value &lt;code&gt;-1&lt;/code&gt;, indicating that the &lt;em&gt;local&lt;/em&gt; option &lt;code&gt;autoread&lt;/code&gt; has not yet been set with &lt;code&gt;:setl autoread&lt;/code&gt; or &lt;code&gt;:setl noautoread&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I set the local option with &lt;code&gt;:setl autoread&lt;/code&gt;, the expression evaluates to &lt;code&gt;1&lt;/code&gt;, when I unset it with &lt;code&gt;:setl noautoread&lt;/code&gt;, it evaluates to &lt;code&gt;0&lt;/code&gt;. In either case, I won't be able to automatically have the global value for the option set with &lt;code&gt;:set autoread&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there a possibility to completely unset/delete the local option so that the expression &lt;code&gt;&amp;amp;l:autoread&lt;/code&gt; will evaluate to &lt;code&gt;-1&lt;/code&gt; again?&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2023-06-15T17:24:19.830" Title="How do I delete/unset a buffer local option (such as autoread)?" Tags="|buffers|options|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8760" PostTypeId="2" ParentId="8759" CreationDate="2016-07-13T12:24:12.477" Score="2" Body="&lt;p&gt;You could directly set the local option to -1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setl autoread&#xA;let &amp;amp;l:autoread=-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At this point &lt;code&gt;echo &amp;amp;l:autoread&lt;/code&gt; returns -1, and &lt;code&gt;setl autoread?&lt;/code&gt; outputs &lt;code&gt;--autoread&lt;/code&gt;, which is the exact same output of a new buffer, meaning that the global value is being used for that option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        *:setl* *:setlocal*&#xA;:setl[ocal] ...         Like &quot;:set&quot; but set only the value local to the&#xA;                        (...)&#xA;                        Without argument: Display local values for all local&#xA;                        options which are different from the default.&#xA;                        When displaying a specific local option, show the&#xA;                        local value.  For a global/local boolean option, when&#xA;                        the global value is being used, &quot;--&quot; is displayed&#xA;                        before the option name.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-07-13T12:24:12.477" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8761" PostTypeId="2" ParentId="8741" CreationDate="2016-07-13T12:48:34.353" Score="6" Body="&lt;p&gt;I use &lt;code&gt;&amp;lt;Leader&amp;gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; as a shortcut to &lt;code&gt;:noh&lt;/code&gt;. (My leader is &lt;code&gt;,&lt;/code&gt;, so it's pretty close)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will turn off the highlights until your next search.&lt;/p&gt;&#xA;" OwnerUserId="8412" LastActivityDate="2016-07-13T12:48:34.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8762" PostTypeId="1" CreationDate="2016-07-13T13:28:52.777" Score="1" ViewCount="422" Body="&lt;p&gt;I use Vim 7.4.52&lt;sup&gt;1&lt;/sup&gt; under Kubuntu 14.04.4. I downloaded and installed Nvim-R 0.9.5 (for Vim &gt;= 7.4.1829) via &lt;code&gt;:so %&lt;/code&gt;. Doing the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim somefile.R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;on a file containing R code results in Vim reporting:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Nvim-R requires ... Vim &amp;gt;= 7.4.1829&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;If using Vim, it must have been compiled with both +channel and +job features.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version | grep &quot;channel\|job&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;returns nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need to download&lt;sup&gt;2&lt;/sup&gt; a newer or different version of Vim? I'd like to avoid compiling Vim from scratch ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1: &lt;em&gt;As reported on the splash screen when starting Vim. &lt;code&gt;apt-get&lt;/code&gt; reports version &quot;7.4.&lt;strong&gt;0&lt;/strong&gt;52&quot;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2: &lt;em&gt;&lt;a href=&quot;http://www.vim.org&quot; rel=&quot;nofollow&quot;&gt;vim.org&lt;/a&gt; is down at the moment.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="2932" LastEditorUserId="51" LastEditDate="2016-07-13T21:26:12.023" LastActivityDate="2016-07-13T21:26:12.023" Title="Vim compilation requirements for Nvim-R" Tags="|installing|version|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8763" PostTypeId="2" ParentId="8757" CreationDate="2016-07-13T15:21:25.177" Score="3" Body="&lt;p&gt;I'm assuming you are using the default vim python indentation file. That's where this behavior is set, and it's pretty easy to remove. My default indentation file is located at /usr/local/share/vim/vim74/indent/python.vim. Yours might be somewhere else, but you can search for it with this command (assuming you are on a unix environment) &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find / -name &quot;python.vim&quot; -type f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The indentation file will be in some directory probably called indent. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, relevant part of the file looks like this. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &quot; When inside parenthesis: If at the first line below the parenthesis add&#xA;  &quot; two 'shiftwidth', otherwise same as previous line.&#xA;  &quot; i = (a&#xA;  &quot;       + b&#xA;  &quot;       + c)&#xA;  &quot; NOTE: extra lines omitted for brevity&#xA;  return indent(plnum) + (exists(&quot;g:pyindent_nested_paren&quot;) ? eval(g:pyindent_nested_paren) : shiftwidth())&#xA;      endif&#xA;      return indent(plnum) + (exists(&quot;g:pyindent_open_paren&quot;) ? eval(g:pyindent_open_paren) : (shiftwidth() * 2))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We will change the last line (or preferably, comment it out!) to remove the *2. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return indent(plnum) + (exists(&quot;g:pyindent_open_paren&quot;) ? eval(g:pyindent_open_paren) : (shiftwidth()))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't want to mess with default files (which you probably shouldn't), you should copy the file and put it in &lt;code&gt;~/.vim/indent/python.vim&lt;/code&gt;, and make your changes the the file in there. It will override the default file. &lt;/p&gt;&#xA;" OwnerUserId="2757" LastActivityDate="2016-07-13T15:21:25.177" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8765" PostTypeId="1" CreationDate="2016-07-13T19:22:39.930" Score="0" ViewCount="2552" Body="&lt;p&gt;In vim without tmux:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/GadaH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GadaH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vim with tmux:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/GU79Y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GU79Y.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Color in Vim is 'default'    &lt;/li&gt;&#xA;&lt;li&gt;My .vimrc has nothing related to colors.&lt;/li&gt;&#xA;&lt;li&gt;My .tmux.conf is empty.&lt;/li&gt;&#xA;&lt;li&gt;My .bashrc is untouched.&lt;/li&gt;&#xA;&lt;li&gt;I am using gnome-terminal with a custom color pallete.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any help, please.&lt;/p&gt;&#xA;" OwnerUserId="8415" LastActivityDate="2016-07-13T20:29:21.493" Title="Wrong colors inside tmux" Tags="|terminal|colorscheme|tmux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8766" PostTypeId="2" ParentId="8765" CreationDate="2016-07-13T19:36:45.647" Score="3" Body="&lt;p&gt;Term creates new terminals with &#xA;&lt;code&gt;TERM=screen-256color&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put this in your .bashrc to fix the issue&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;export TERM=xterm-256color&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; &#xA;As pointed out in the comments, you should probably run &lt;code&gt;echo $TERM&lt;/code&gt; when you are not in tmux, then set &lt;code&gt;export TERM=&lt;/code&gt; to whatever the output of echo was.&lt;/p&gt;&#xA;" OwnerUserId="2757" LastEditorUserId="2757" LastEditDate="2016-07-13T20:29:21.493" LastActivityDate="2016-07-13T20:29:21.493" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8767" PostTypeId="2" ParentId="8718" CreationDate="2016-07-13T23:44:50.240" Score="1" Body="&lt;p&gt;I finally came up with a solution with custom indent script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal comments=s1:/*,mb:*,ex:*/&#xA;&#xA;setlocal cindent&#xA;setlocal cinoptions=Ls,t0,(0&#xA;&#xA;setlocal indentexpr=GetCaseBlockCorrectedIndent()&#xA;setlocal indentkeys=!^F,0{,0},0),0#,o,O,e,:&#xA;&#xA;function! s:PrevNonBlankOrComment(startlnum)&#xA;    let lnum = a:startlnum&#xA;    while lnum &amp;gt; 0&#xA;        let lnum = prevnonblank(lnum)&#xA;        if (getline(lnum) =~ '^\s*\(/\|\*\)')&#xA;            let lnum -= 1&#xA;        else&#xA;            break&#xA;        endif&#xA;    endwhile&#xA;    return lnum&#xA;endfunction&#xA;&#xA;function! GetCaseBlockCorrectedIndent()&#xA;    let lnum = v:lnum&#xA;    let prevlnum = s:PrevNonBlankOrComment(lnum - 1)&#xA;    let idnt = cindent(v:lnum)&#xA;    let adj = 0&#xA;    if getline(prevlnum) =~ '^\s*case\&amp;gt;' &amp;amp;&amp;amp; getline(lnum) =~ '^\s*{'&#xA;       let adj = -&amp;amp;shiftwidth&#xA;    endif&#xA;    return idnt + adj&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8385" LastActivityDate="2016-07-13T23:44:50.240" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8768" PostTypeId="1" CreationDate="2016-07-14T00:50:02.737" Score="7" ViewCount="533" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I turned this into a little plugin. This is my first attempt at writing one and I have no idea what I'm doing, so any help is much appreciated. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here it is: &lt;a href=&quot;https://github.com/danielbmarques/vim-dialect&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/danielbmarques/vim-dialect&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;----------&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I want to keep using &lt;code&gt;zg&lt;/code&gt; and &lt;code&gt;zw&lt;/code&gt; to add words to the global vim &lt;code&gt;spellfile&lt;/code&gt;s, but I want to use &lt;code&gt;zG&lt;/code&gt; and &lt;code&gt;zW&lt;/code&gt; to add words to a &lt;code&gt;spellfile&lt;/code&gt; &lt;em&gt;specific to the file I'm editing&lt;/em&gt;. In other words, I want &lt;code&gt;zG&lt;/code&gt; and &lt;code&gt;zW&lt;/code&gt; to be persistent for each file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting the &lt;code&gt;spellfile&lt;/code&gt; changes the &lt;code&gt;zg&lt;/code&gt; and &lt;code&gt;zw&lt;/code&gt; commands, while what I want is to change only the &lt;code&gt;zG&lt;/code&gt; and &lt;code&gt;zW&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I just did this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au BufNewFile,BufRead * let &amp;amp;l:spellfile = expand('%:p:h') . '/.' .&#xA;    \ substitute(expand('%:t'), '\(.*\)\..*', '\1', '') . '.utf-8.add'&#xA;nnoremap zG :call LocalSpell(&quot;zG&quot;)&amp;lt;cr&amp;gt;&#xA;nnoremap zW :call LocalSpell(&quot;zW&quot;)&amp;lt;cr&amp;gt;&#xA;nnoremap zuG :call LocalSpell(&quot;zuG&quot;)&amp;lt;cr&amp;gt;&#xA;nnoremap zuW :call LocalSpell(&quot;zuW&quot;)&amp;lt;cr&amp;gt;&#xA;nnoremap zg :call GlobalSpell(&quot;zg&quot;)&amp;lt;cr&amp;gt;&#xA;nnoremap zw :call GlobalSpell(&quot;zw&quot;)&amp;lt;cr&amp;gt;&#xA;nnoremap zug :call GlobalSpell(&quot;zug&quot;)&amp;lt;cr&amp;gt;&#xA;nnoremap zuw :call GlobalSpell(&quot;zuw&quot;)&amp;lt;cr&amp;gt;&#xA;vnoremap zG :call LocalSpell(&quot;gvzG&quot;)&amp;lt;cr&amp;gt;&#xA;vnoremap zW :call LocalSpell(&quot;gvzW&quot;)&amp;lt;cr&amp;gt;&#xA;vnoremap zuG :call LocalSpell(&quot;gvzuG&quot;)&amp;lt;cr&amp;gt;&#xA;vnoremap zuW :call LocalSpell(&quot;gvzuW&quot;)&amp;lt;cr&amp;gt;&#xA;vnoremap zg :call GlobalSpell(&quot;gvzg&quot;)&amp;lt;cr&amp;gt;&#xA;vnoremap zw :call GlobalSpell(&quot;gvzw&quot;)&amp;lt;cr&amp;gt;&#xA;vnoremap zug :call GlobalSpell(&quot;gvzug&quot;)&amp;lt;cr&amp;gt;&#xA;vnoremap zuw :call GlobalSpell(&quot;gvzuw&quot;)&amp;lt;cr&amp;gt;&#xA;&#xA;function! LocalSpell(cmd)&#xA;    if &amp;amp;l:spellfile == &quot;&quot;&#xA;        execute &quot;normal! &quot; . a:cmd&#xA;    else&#xA;        execute &quot;normal! &quot; . tolower(a:cmd)&#xA;    endif&#xA;endfunction&#xA;&#xA;function! GlobalSpell(cmd)&#xA;    let b:spellfile = &amp;amp;l:spellfile&#xA;    setlocal spellfile=&#xA;    execute &quot;normal! &quot; . a:cmd&#xA;    let &amp;amp;l:spellfile = b:spellfile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it works… but it doesn't look like a nice solution to me (edit: it's getting better already :)). So I thought I'd post it here in case anyone has any better ideas or improvements to suggest. What do you think?&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="7642" LastEditDate="2016-07-16T09:51:14.683" LastActivityDate="2018-01-26T14:57:12.427" Title="Make zG and zW persistent" Tags="|key-bindings|vimscript|spell-checking|functions|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="8769" PostTypeId="1" CreationDate="2016-07-14T01:51:38.377" Score="2" ViewCount="327" Body="&lt;p&gt;Is there a way to make Vim close Syntastic buffer when closing the main file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I.e. I'd like Syntastic to run automatically on file opening, and &quot;disappear&quot; when I choose the main file with either &lt;kbd&gt;Z&lt;/kbd&gt;&lt;kbd&gt;Z&lt;/kbd&gt; or &lt;code&gt;:q!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With my default configuration Syntastic buffer remains (if there are unresolved warnings) and must be closed manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; entries related to Syntastic:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5334" LastEditorUserId="5334" LastEditDate="2016-07-14T07:34:04.427" LastActivityDate="2016-07-14T07:34:04.427" Title="How to make Vim close Syntastic buffer when closing main file?" Tags="|plugin-syntastic|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8770" PostTypeId="1" CreationDate="2016-07-14T16:06:02.370" Score="2" ViewCount="529" Body="&lt;p&gt;For example, if I had source text like this (with the numbers on the left representing line numbers that are not part of the source text):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1  foo&#xA;2  bar&#xA;3&#xA;4  baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it would appear as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1  foo&#xA;2  bar&#xA;4  baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To clarify, when I say &quot;blank lines&quot; I mean lines that would match the regex &lt;code&gt;^$&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8423" LastActivityDate="2016-07-15T07:46:55.180" Title="How can I hide blank lines in vim without actually removing them from the text I am editing?" Tags="|conceal|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8771" PostTypeId="2" ParentId="8770" CreationDate="2016-07-14T16:13:46.327" Score="2" Body="&lt;p&gt;You can do this with a feature called &quot;Folds&quot;. Try adding this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match MyEmptyLines &quot;\(^$\)\+&quot; fold&#xA;syn sync fromstart&#xA;setlocal foldmethod=syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This tell's vim to create folds based off of the syntax of your file, and then adds a new syntax, e.g. any number of lines that match &lt;code&gt;^$&lt;/code&gt;. Then, you can fold all of these matches at once with &lt;code&gt;zM&lt;/code&gt;, and unfold all of them with &lt;code&gt;zR&lt;/code&gt;. You can also use &lt;code&gt;za&lt;/code&gt; to expand the fold that is under your cursor. I have this in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;space&amp;gt; za&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-07-14T16:48:49.013" LastActivityDate="2016-07-14T16:48:49.013" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8772" PostTypeId="1" AcceptedAnswerId="8773" CreationDate="2016-07-14T17:38:52.090" Score="15" ViewCount="11992" Body="&lt;p&gt;I'm trying to fix syntax highlighting for python; my colors are different from those in screenshots of what it &quot;should&quot; look like in different vim color schemes. And you can see the difference in comparing .rb (which displays correctly) to .py, which looks like it's off:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/R3iry.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/R3iry.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, notice how &lt;code&gt;self&lt;/code&gt; isn't highlighted. (This is in base16, but the comparison would be similar in other color schemes). Generally, it looks like the object syntax highlighting is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some things I've tried:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Looking at the syntax scripts vim loads; the only difference between .py and .rb in the example below is that, of course, ruby gets indent/ruby.vim and syntax/ruby.vim while python gets indent/python.vim and syntax/python.vim. These are the files that come with homebrew vim.&lt;/li&gt;&#xA;&lt;li&gt;Loading the same files in macvim rather than terminal (iterm2) vim; same problem, the files look exactly the same as in the picture.&lt;/li&gt;&#xA;&lt;li&gt;Adding the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=790&quot; rel=&quot;noreferrer&quot;&gt;new python.vim&lt;/a&gt; file. Doesn't solve the problem, even if used as an &lt;code&gt;.vim/after&lt;/code&gt; script.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any suggestions are welcome; I've been banging my head on this for hours, and can't figure out why the highlighting isn't working as expected.&lt;/p&gt;&#xA;" OwnerUserId="8424" LastEditorUserId="51" LastEditDate="2016-12-17T02:40:04.703" LastActivityDate="2016-12-17T02:40:04.703" Title="How can I fix &quot;missing&quot; syntax highlighting for Python keywords such as &quot;self&quot;?" Tags="|syntax-highlighting|filetype-python|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8773" PostTypeId="2" ParentId="8772" CreationDate="2016-07-14T18:24:04.163" Score="18" Body="&lt;p&gt;How syntax highlighting works in brief:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;In &lt;code&gt;syntax/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; the syntax rules are defined with the &lt;code&gt;:syntax&lt;/code&gt; command. This command defines, well, syntax. It says &quot;if text matches this regular expression, it's a string&quot;, and so forth. To do so, it assigns a &lt;em&gt;highlight group&lt;/em&gt;. It does &lt;em&gt;not&lt;/em&gt; say anything about colours as such.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:highlight&lt;/code&gt; says &quot;highlight this group with these colours&quot;. This is done in the &lt;em&gt;colour scheme&lt;/em&gt;, not the syntax file. There are a bunch of default Highlight groups (&lt;code&gt;String&lt;/code&gt;, &lt;code&gt;Function&lt;/code&gt;, &lt;code&gt;Special&lt;/code&gt;, and so forth) which all colour schemes should define.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're by no means restricted to these default groups though, and you can create as many groups as you want (but default syntax files typically don't).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;indent/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; file controls automatic indentation. For example for Ruby it says &quot;the line after &lt;code&gt;def&lt;/code&gt; should increase the indentation level&quot; and &quot;the line after &lt;code&gt;end&lt;/code&gt; should decrease the indentation one level&quot;. It doesn't do anything with colours or syntax highlighting.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Why do different programming languages get highlighted different? In part because of the of personal aesthetics and opinions of whoever wrote it. For example in Ruby the &lt;code&gt;Type&lt;/code&gt; highlight group is used for class names. But it could also have been &lt;code&gt;Function&lt;/code&gt; or something else. Why is it &lt;code&gt;Type&lt;/code&gt;? Probably because the author thought that it looked better in his or her colour scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But more importantly, the languages have different semantics and sensibilities. In Ruby, &lt;code&gt;self&lt;/code&gt; is a special keyword. You can't do &lt;code&gt;self = &quot;foo&quot;&lt;/code&gt; or &lt;code&gt;def self()&lt;/code&gt;. These are errors. But this is &lt;em&gt;not&lt;/em&gt; the case in Python. It's just another variable without any special properties. Doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = Object()&#xA;x.foo()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is really &quot;translated&quot; by Python to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Object.foo(x)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The name &lt;code&gt;self&lt;/code&gt; is just convention (almost universally adopted) but you can name it anything you like; &lt;code&gt;def x(this):&lt;/code&gt; or &lt;code&gt;def x(xxx):&lt;/code&gt; are equally valid. You can also use the name &lt;code&gt;self&lt;/code&gt; anywhere you like; &lt;code&gt;self = 'foo'&lt;/code&gt; and &lt;code&gt;def self():&lt;/code&gt; are perfectly fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would argue that &lt;code&gt;self&lt;/code&gt; shouldn't be highlighted, as it's neither a special keyword, nor a pre-defined variable (like &lt;code&gt;str&lt;/code&gt;). There is no trace of the word &lt;code&gt;self&lt;/code&gt; in the syntax file, so it looks like the author of it reasoned the same :-)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want &lt;code&gt;self&lt;/code&gt; highlighted you'll have to create a syntax rule for it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn keyword pythonBuiltin self&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;pythonBuiltin&lt;/code&gt; group name is already defined in the default syntax file and linked to the &lt;code&gt;Function&lt;/code&gt; highlight group. To use a new highlight group, use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn keyword pythonSelf self&#xA;:highlight def link pythonSelf Special&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make these changes you can't just stick 'em in your vimrc file. The syntax file will override it. Instead you'll need to run it &lt;em&gt;after&lt;/em&gt; the syntax file loads, which you can do in two ways:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a &lt;code&gt;FileType&lt;/code&gt; autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup python&#xA;    autocmd!&#xA;    autocmd FileType python&#xA;                \   syn keyword pythonSelf self&#xA;                \ | highlight def link pythonSelf Special&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#after%2ddirectory&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;after-directory&lt;/code&gt;&lt;/a&gt;, &lt;code&gt;~/.vim/after/syntax/python.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword pythonSelf self&#xA;highlight def link pythonSelf Special&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Both methods are effectively the same. Use whichever you prefer.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-07-14T18:24:04.163" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8774" PostTypeId="1" AcceptedAnswerId="8775" CreationDate="2016-07-14T20:03:27.240" Score="1" ViewCount="50" Body="&lt;p&gt;I'm editing a table in extended-markdown, and I'm wondering how to easily edit cells without moving the dividing lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tables are formatted like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;| HEADING1         | HEADING2       | etc...&#xA;| ---------------- | -------------- | etc...&#xA;| row 1            | column2        | etc...&#xA;| etc...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Suppose I want to change an entry but leave the next &lt;code&gt;|&lt;/code&gt; in its place. Ideally, I'd go to the first word in the cell and use &lt;code&gt;c&amp;lt;something&amp;gt;&lt;/code&gt;, type the new entry, and, upon leaving &lt;code&gt;insert&lt;/code&gt; mode, a sufficient number of spaces would be inserted or deleted after the new text to ensure that the &lt;code&gt;|&lt;/code&gt; character is restored to its original location, &lt;em&gt;if possible&lt;/em&gt;. (Obviously if too much text is entered, this won't be possible; one solution for this would be to somehow restrict the insert operation to the maximum number of characters to permit retaining the cell-shape, though I don't know if Vim permits this.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems like it should be possible to implement by creating a new text-object or something, though I realize there would be a fair amount of &quot;magic&quot; involved since leaving insert mode would trigger a second edit operation.&lt;/p&gt;&#xA;" OwnerUserId="1060" LastEditorUserId="2920" LastEditDate="2016-07-14T20:22:56.997" LastActivityDate="2016-07-14T20:22:56.997" Title="&quot;Change&quot; as much whitespace as necessary" Tags="|formatting|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8775" PostTypeId="2" ParentId="8774" CreationDate="2016-07-14T20:05:59.270" Score="5" Body="&lt;p&gt;Have you tried the &lt;code&gt;R&lt;/code&gt; operator? This will let you overwrite whatever text you need to without moving the &lt;code&gt;|&lt;/code&gt;. If your word is shorter than what you're replacing, you can simply fill the rest with spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h R&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-07-14T20:05:59.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8776" PostTypeId="1" AcceptedAnswerId="8784" CreationDate="2016-07-14T20:22:28.967" Score="0" ViewCount="62" Body="&lt;p&gt;I have this rather big if statement to test if a certain cursor position is within two other cursor positions&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Altogether it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &quot; a&#xA;  &quot; thecursor&#xA;  &quot; b&#xA;  if (a:a[l:ROW] &amp;lt;# a:thecursor[l:ROW] &amp;amp;&amp;amp; a:thecursor[l:ROW] &amp;lt;# a:b[l:ROW]) ||&#xA;&#xA;    &quot; a&#xA;    &quot; thecursor a&#xA;          \ (a:a[l:ROW] &amp;lt;# a:thecursor[l:ROW] &amp;amp;&amp;amp; a:thecursor[l:ROW] ==# a:b[l:ROW] &amp;amp;&amp;amp;&#xA;          \ a:thecursor[l:COL] &amp;lt;# a:b[l:COL]) ||&#xA;&#xA;    &quot; a thecursor&#xA;    &quot; a&#xA;          \ (a:thecursor[l:ROW] ==# a:a[l:ROW] &amp;amp;&amp;amp; a:c_a[l:COL] &amp;lt;# a:thecursor[l:COL] &amp;amp;&amp;amp;&#xA;          \ a:thecursor[l:ROW] &amp;lt;# a:b[l:ROW]) ||&#xA;&#xA;    &quot; a thecursor b&#xA;          \ (a:thecursor[l:ROW] ==# a:a[l:ROW] &amp;amp;&amp;amp; a:thecursor[l:ROW] ==# a:b[l:ROW] &amp;amp;&amp;amp;&#xA;          \ a:a[l:COL] &amp;lt;# a:thecursor[l:COL] &amp;amp;&amp;amp; a:thecursor[l:COL] &amp;lt;# a:b[l:COL])&#xA;    return v:true&#xA;  endif      &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However when executed I get this error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E15: Invalid expression: (a:a[l:ROW] &amp;lt;# a:thecursor[l:ROW] &amp;amp;&amp;amp; &#xA;  a:thecursor[l:ROW] &amp;lt;# a:b[l:ROW]) ||    &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is because you can't enter comments within a statement that is continued using &lt;code&gt;\&lt;/code&gt;. Is there some way to still use comments in such a situation?                                                                                     &lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="6300" LastEditDate="2016-07-14T21:06:15.667" LastActivityDate="2016-07-14T21:50:20.087" Title="How to insert comments into longer expression" Tags="|vimscript|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8777" PostTypeId="1" CreationDate="2016-07-14T20:24:23.163" Score="1" ViewCount="149" Body="&lt;p&gt;When I visually select text and enter &lt;code&gt;:&lt;/code&gt; I'll get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I can enter a substitution to be done on those lines. However, what if I wanted to do several substitution, e.g. &lt;code&gt;foo&lt;/code&gt; to &lt;code&gt;bar&lt;/code&gt; and &lt;code&gt;hello&lt;/code&gt; to &lt;code&gt;world&lt;/code&gt;? What would I need to do then?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="51" LastEditDate="2016-07-16T23:24:38.883" LastActivityDate="2016-07-16T23:24:38.883" Title="Way to do mulitple substitutions on selection" Tags="|visual-mode|substitute|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8778" PostTypeId="2" ParentId="8777" CreationDate="2016-07-14T20:31:11.140" Score="3" Body="&lt;p&gt;While there are probably ways to do it all in a single substitution, I think that probably the most &lt;em&gt;practical&lt;/em&gt; way of doing it is simply:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do the first substitution&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;g&lt;/kbd&gt; then &lt;kbd&gt;v&lt;/kbd&gt; (this will select the previous visual selection)&lt;/li&gt;&#xA;&lt;li&gt;Do the second substitution&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h gv&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-07-14T20:31:11.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8779" PostTypeId="2" ParentId="8777" CreationDate="2016-07-14T20:41:13.497" Score="5" Body="&lt;p&gt;Using &lt;code&gt;gv&lt;/code&gt; is a good option. Another alternative is to just hit &lt;kbd&gt;:&lt;/kbd&gt;&#xA;&lt;kbd&gt;Up&lt;/kbd&gt; after you do your first substitution. This will bring up your previous substitution with the &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt; text at the beginning. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, you can edit the previous command with your cursor keys and backspace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works because conveniently, the &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt; causes the substitution to be limited to your current &lt;em&gt;or previous&lt;/em&gt; visual selection  if you don't have text visually selected at the moment.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-14T20:41:13.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8780" PostTypeId="1" AcceptedAnswerId="8783" CreationDate="2016-07-14T20:47:58.187" Score="6" ViewCount="5271" Body="&lt;p&gt;This happens to me semi-frequently. I have two tabs open, and I would like to merge them into one tab with a vertical split. Essentially, I want to do the opposite of &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#CTRL-W_T&quot; rel=&quot;noreferrer&quot;&gt;CTRL-w_T&lt;/a&gt;. Right now, I have to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:wq&amp;lt;cr&amp;gt;&amp;lt;C-w&amp;gt;v:browse old&amp;lt;cr&amp;gt;q1&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any more convenient way to do this? If there isn't a builtin way, I wouldn't be opposed to adding a vimscript function, or installing a plugin.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-14T21:58:47.817" Title="Can I move my current tab to a split in a different tab?" Tags="|vim-windows|split|tabbed-user-interface|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8781" PostTypeId="2" ParentId="8780" CreationDate="2016-07-14T21:18:45.020" Score="2" Body="&lt;p&gt;Dirty solution (only works if you have exactly two tabs):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -p file1 file2&#xA;&#xA;:exe 'normal! gt' | exe 'vsplit ' . bufname('#') | exe &quot;normal! gt&quot;| q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Move to the other tab to make the first tab the alternate file,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vsplit&lt;/code&gt; against the alternate file,&lt;/li&gt;&#xA;&lt;li&gt;Move to the other tab again and quit.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A little better solution, it works when you have more tabs but leaves a global variable hanging:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let this_tab = bufname('%') | exe 'normal! gt' | exe 'vsplit ' . this_tab | exe &quot;normal! gT&quot;| q | unlet this_tab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation (same as above but):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Saves the buffer on the tab on the left,&lt;/li&gt;&#xA;&lt;li&gt;Uses the saved buffer when performing &lt;code&gt;vsplit&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(the hanging variable can be avoided by making a function)&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-07-14T21:18:45.020" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8782" PostTypeId="2" ParentId="8777" CreationDate="2016-07-14T21:30:13.300" Score="2" Body="&lt;p&gt;Define a dictionary containing your substitutions:&#xA;&lt;code&gt;&#xA;let g:dict={'foo': 'bar', 'hello': 'world'}&#xA;&lt;/code&gt;&#xA;Then you can substitute several items at once:&#xA;&lt;code&gt;&#xA;'&amp;lt;,'&amp;gt;s/foo\|hello/\=get(dict, submatch(0))/g&#xA;&lt;/code&gt;&#xA;or even completly dynamic:&#xA;&lt;code&gt;&#xA;exe &quot;'&amp;lt;,'&amp;gt;s/&quot;. join(keys(dict), '\|'). '/\=get(dict,submatch(0))/g'&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works also, if you want to replace at the same time foo by bar and bar by foo.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2016-07-14T22:15:23.907" LastActivityDate="2016-07-14T22:15:23.907" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8783" PostTypeId="2" ParentId="8780" CreationDate="2016-07-14T21:31:40.840" Score="3" Body="&lt;p&gt;Assuming I understand you correctly, try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MergeTab()&#xA;    let bufnums = tabpagebuflist()&#xA;    hide tabclose&#xA;    topleft vsplit&#xA;    for n in bufnums&#xA;        execute 'sbuffer ' . n&#xA;        wincmd _&#xA;    endfor&#xA;    wincmd t&#xA;    quit&#xA;    wincmd =&#xA;endfunction&#xA;command! MergeTab call MergeTab()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will merge all windows in a tab into a vertical&#xA;split at the left hand side of the following tab (or the preceding tab&#xA;if you happen to be on the last tab).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There might be issues if you run out of room, but you'll&#xA;still have your buffers in the buffer list.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-07-14T21:58:47.817" LastActivityDate="2016-07-14T21:58:47.817" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8784" PostTypeId="2" ParentId="8776" CreationDate="2016-07-14T21:35:22.263" Score="2" Body="&lt;p&gt;You do not need to compare numbers with any string sensitivity. You are receiving this error due to lack of escaping new lines with &lt;code&gt;\&lt;/code&gt; and your use of comments.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Comments in expression&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim will not understand the expression properly if you try and sandwich a comment inside of it. It would be much better to create a set of temporary variables that are well named for each portion and comment those. Example of one such variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; a&#xA;&quot; thecursor&#xA;&quot; b&#xA;let between_the_lines = a:a[l:ROW] &amp;lt; a:thecursor[l:ROW] &amp;amp;&amp;amp; a:thecursor[l:ROW] &amp;lt; a:b[l:ROW])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Refactor&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;General rule of thumb: If some portion of code is repetitive and hard to understand, then it is time to refactor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's create a compare function, &lt;code&gt;s:cmp&lt;/code&gt;, that takes in lists and compares one list another to one item at a time returning &lt;code&gt;-1&lt;/code&gt; (less than), &lt;code&gt;0&lt;/code&gt; (equal), or &lt;code&gt;1&lt;/code&gt; (greater than).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:cmp(a, b)&#xA;  for i in range(len(a:a))&#xA;    if a:a[i] &amp;lt; a:b[i]&#xA;      return -1&#xA;    elseif a:a[i] &amp;gt; a:b[i]&#xA;      return 1&#xA;    endif&#xA;  endfor&#xA;  return 0&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By cleverly crafting our List in the form &lt;code&gt;[LNUM, COL]&lt;/code&gt; we can use our &lt;code&gt;s:cmp&lt;/code&gt; function to compare different positions in the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of using this code to determine if the cursor is within the visual selection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let cursor = getpos('.')[1:2]&#xA;let v_start = getpos(&quot;'&amp;lt;&quot;)[1:2]&#xA;let v_end = getpos(&quot;'&amp;gt;&quot;)[1:2]&#xA;&#xA;echo s:cmp(v_start, cursor) &amp;lt;= 0 &amp;amp;&amp;amp; s:cmp(cursor, v_end) &amp;lt;= 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I imagine this code is far simpler to understand when you come back to it at later time.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;For more help&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h user-function&#xA;:h getpos()&#xA;:h List&#xA;:h range()&#xA;:h len()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2016-07-14T21:50:20.087" LastActivityDate="2016-07-14T21:50:20.087" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8785" PostTypeId="2" ParentId="8770" CreationDate="2016-07-14T21:54:33.533" Score="3" Body="&lt;p&gt;Here is a possibility which uses foldexpressions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! FoldEmptyLines(lnum)&#xA;    if !empty(getline(a:lnum)) &amp;amp;&amp;amp; a:lnum+1 &amp;lt; line('$') &amp;amp;&amp;amp; empty(getline(a:lnum+1))&#xA;        return 1&#xA;    elseif empty(getline(a:lnum))&#xA;        return '='&#xA;    else&#xA;        return 0&#xA;    endif&#xA;endfu&#xA;setl foldenable foldexpr=FoldEmptyLines(v:lnum) foldmethod=expr foldtext=getline(v:foldstart).repeat('\ ',winwidth(0)-len(split(getline(v:foldstart))))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses a foldexpression to check every line and decide whether the next line is empty. If it is, it will be marked as being inside of foldlevel 1. If the current line is already empty, use the previous foldlevel, else it isn't in a fold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to also fold lines, containing of only blanks, you would change the &lt;code&gt;empty(getline(...))&lt;/code&gt; part to &lt;code&gt;empty(split(getline(...)))&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To decide, how the folded line looks like, it uses the &lt;code&gt;'foldtext'&lt;/code&gt; setting and sets it explicitly to the text of the start of the folded line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two problems with this approach. It will be probably slow for long files and second, you lose syntax highlighting for the folded lines.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2016-07-15T07:46:55.180" LastActivityDate="2016-07-15T07:46:55.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8786" PostTypeId="2" ParentId="8777" CreationDate="2016-07-14T22:00:51.733" Score="5" Body="&lt;p&gt;Assuming your exact example case you can use &lt;code&gt;:Subvert&lt;/code&gt; from Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-abolish&quot;&gt;abolish.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%S/{foo,hello}/{bar,world}/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see this in action in the the &lt;a href=&quot;http://vimcasts.org/&quot;&gt;Vimcasts&lt;/a&gt; episode: &lt;a href=&quot;http://vimcasts.org/episodes/supercharged-substitution-with-subvert/&quot;&gt;Supercharged substitution with :Subvert&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-07-14T22:00:51.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8787" PostTypeId="1" AcceptedAnswerId="8788" CreationDate="2016-07-14T22:53:43.983" Score="1" ViewCount="31" Body="&lt;p&gt;When I press &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt; for autocompletion a list based on my &lt;code&gt;complete&lt;/code&gt; setting appears.  I have a completion file as follows (at &lt;code&gt;~/emails&lt;/code&gt;)`:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;barabara.high@someplace.com&#xA;john.doe@gmail.com&#xA;john.carpenter@ooo.ooo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I write (in insert mode) &lt;code&gt;joh&lt;/code&gt; and press &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt; only&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;john.doe&#xA;john.carpenter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Appear as the completions.  i.e. without the email domains.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;iskeyword&lt;/code&gt; and &lt;code&gt;complete&lt;/code&gt; are as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword=@,48-57,_,-,.,192-255&#xA;set complete=k~/emails&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;iskeyword&lt;/code&gt; has &lt;code&gt;@&lt;/code&gt; explicitly included, why does the completion list do not treat the entire email as a cword?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;:expand('&amp;lt;cword&amp;gt;')&lt;/code&gt; does not take the entire email as a cword either).&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-07-14T23:09:03.393" Title="Can I use emails in the completion list from CTRL-P" Tags="|autocompletion|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8788" PostTypeId="2" ParentId="8787" CreationDate="2016-07-14T23:09:03.393" Score="4" Body="&lt;p&gt;The format for &lt;code&gt;'iskeyword'&lt;/code&gt; is explained at &lt;code&gt;:help 'isfname'&lt;/code&gt;. In particular:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To include '@' itself use &quot;@-@&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;@&lt;/code&gt; is shorthand meaning 'all characters where isalpha() returns TRUE'.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-07-14T23:09:03.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8789" PostTypeId="1" AcceptedAnswerId="8791" CreationDate="2016-07-14T23:22:16.460" Score="6" ViewCount="771" Body="&lt;p&gt;So I do a visual selection and hit a &lt;code&gt;vnoremap&lt;/code&gt; which calls a function and executes &lt;code&gt;mode()&lt;/code&gt;, but everything it ever does it output &lt;code&gt;n&lt;/code&gt;, indicating I'm in normal mode, even though that is certainly not true.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;silent&amp;gt; qb :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;func()&amp;lt;cr&amp;gt;&#xA;&#xA;function! func()&#xA;  echo mode()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="6300" LastEditDate="2016-07-14T23:32:02.587" LastActivityDate="2016-07-15T00:21:49.527" Title="`mode()` always seems to return 'n'" Tags="|vimscript|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8790" PostTypeId="2" ParentId="8789" CreationDate="2016-07-14T23:50:13.130" Score="3" Body="&lt;p&gt;Vim has left Visual mode by the time &lt;code&gt;Func&lt;/code&gt; is called.&#xA;The following will get &lt;code&gt;mode()&lt;/code&gt; to echo&lt;code&gt;'V'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Func()&#xA;    normal! V&#xA;    echoerr mode()&#xA;endfunction&#xA;&#xA;call Func()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-07-14T23:50:13.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8791" PostTypeId="2" ParentId="8789" CreationDate="2016-07-15T00:21:49.527" Score="8" Body="&lt;p&gt;In &lt;code&gt;visual mode&lt;/code&gt;, press &lt;code&gt;:&lt;/code&gt;, then press enter or escape.  The selection is gone and you're in &lt;code&gt;normal mode&lt;/code&gt;.  This is what's happening with your maps and why &lt;code&gt;mode()&lt;/code&gt; returns &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To deal with this, you need tell your function that it &lt;em&gt;should be&lt;/em&gt; in visual mode.  You already know that it will be since you're using &lt;code&gt;vmap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;silent&amp;gt; qb :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;func(1)&amp;lt;cr&amp;gt;&#xA;&#xA;function! func(visual)&#xA;  if a:visual&#xA;    normal! gv&#xA;  endif&#xA;  echo mode()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;echo mode()&lt;/code&gt; will then give you the correct mode.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-07-15T00:21:49.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8792" PostTypeId="2" ParentId="8733" CreationDate="2016-07-15T01:04:53.040" Score="5" Body="&lt;p&gt;OK, this took several days of struggle against the &lt;a href=&quot;https://github.com/tyru/skk.vim&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;skk.vim&lt;/code&gt; plugin&lt;/a&gt; mentioned by @SatoKatsura.  All the documentation is in Japanese therefore I still do not know of most of its features, and, certainly, there are better ways to accomplish SKK conversion (&quot;Henkan&quot; in Japanese) in Vim than the one presented here.  Yet, it works well enough to be comparable to &lt;code&gt;emacs&lt;/code&gt;' SKK mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all you need to donwload the SKK dictionary.  Any of them would be enough but I suggests the &lt;a href=&quot;http://openlab.ring.gr.jp/skk/dic/SKK-JISYO.L.gz&quot; rel=&quot;noreferrer&quot;&gt;large dictionary&lt;/a&gt; for the sake of completeness.  The dictionary comes in the &lt;code&gt;EUC-JP&lt;/code&gt; encoding, therefore we need to convert it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gunzip SKK-JISYO.L.gz&#xA;iconv -f euc-jp -t utf-8 SKK-JISYO.L &amp;gt; skk-jisyo-utf-8.l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your Vim has the &lt;code&gt;+iconv&lt;/code&gt; feature the &lt;code&gt;iconv&lt;/code&gt; utility should be available on your machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SKK dictionary is in the correct format to be used as a thesaurus, therefore we will set that in Vim and use &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-t&amp;gt;&lt;/code&gt; to perform thesaurus completion.  Every line in the SKK dictionary looks as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;kana entry&amp;gt; / &amp;lt;kanji entry&amp;gt; / &amp;lt;kanji entry&amp;gt; / ...&#xA;わきでy / 湧き出 / 涌き出 /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, we only need to write the &lt;code&gt;&amp;lt;kana entry&amp;gt;&lt;/code&gt; part and Vim will be capable of completing the rest for us.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;skk.vim&lt;/code&gt; can write in Kana in insert-mode.  It can write in both Hiragana and Katakana but the SKK dictionary has entries in Hiragana only.  Therefore we add a Toogle function wrapper around &lt;code&gt;skk.vim&lt;/code&gt; to use either Hiragana or Katakana when in insert-mode.  When we want SKK completion we must be in Hiragana mode (this is analogous to &lt;code&gt;emacs&lt;/code&gt;'s SKK mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I wrote in my &lt;code&gt;.vimrc&lt;/code&gt; to wrap &lt;code&gt;skk.vim&lt;/code&gt; and use the SKK dictionary as a thesaurus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:skk_initial_mode = 'hira'&#xA;let g:skk_script = '~/vim/skk/skk.vim'&#xA;&#xA;set completeopt=menuone,preview&#xA;set thesaurus=~/vim/skk/skk-jisyo-utf-8.l&#xA;&#xA;function! ToogleMode()&#xA;  if 'hira' ==# g:skk_initial_mode&#xA;    let g:skk_initial_mode = 'kata'&#xA;  else&#xA;    let g:skk_initial_mode = 'hira'&#xA;  endif&#xA;  execute &quot;source &quot; . g:skk_script&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To enter Kana mode you press &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt; to complete a Kanji you need to press &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt; to exit Kana mode and then &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-t&amp;gt;&lt;/code&gt; to bring up thesaurus completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is how it looks (the text is exactly the same as in the question):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ymjlZ.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ymjlZ.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disadvantages and quirks:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Since we are using Vim's thesaurus we need to add spaces between words.  This is not needed in &lt;code&gt;emacs&lt;/code&gt;'s SKK becuase it keeps a selection trailing behind (see the screenshot in the question).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This code is terribly hacky, I just cannot understand about 70% of &lt;code&gt;skk.vim&lt;/code&gt; because I'm unable to read the documentation.  There certainly are better ways to perform this.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You need to exit the Kana mode to perform the thesaurus completion, in Kana mode &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-t&amp;gt;&lt;/code&gt; does not work as expected.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-07-15T01:10:50.430" LastActivityDate="2016-07-15T01:10:50.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8793" PostTypeId="1" AcceptedAnswerId="8795" CreationDate="2016-07-15T03:06:59.673" Score="5" ViewCount="15480" Body="&lt;p&gt;I accidentally discovered that the key combination  will concatenate the current line and the next line. However, I do not recall it being mentioned in the &lt;code&gt;quickref&lt;/code&gt;. After a quick Google, I did not find anything. Do any have a clue about where in the&#xA;documents can I find more about this key combination?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;BTW, I have confirmed that this is not mapped in the &lt;code&gt;:map&lt;/code&gt;.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the help from a comment, (Curiously, I saw it in a message. But after I opened the website, it disappeared.) I found that I am actually using the &lt;code&gt;&amp;lt;shift-j&amp;gt;&lt;/code&gt;, i.e. &lt;code&gt;&amp;lt;J&amp;gt;&lt;/code&gt; key to join lines. Thanks to this &lt;a href=&quot;https://stackoverflow.com/questions/1912905/how-do-i-join-two-lines-in-vi&quot;&gt;post&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2&lt;/strong&gt;: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;J&lt;/code&gt; in visual mode provides extra capabilities. See &lt;code&gt;:help v_J&lt;/code&gt;. (Thanks to @Antony's comment.)&lt;/p&gt;&#xA;" OwnerUserId="8036" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-07-16T07:28:31.387" Title="What does &lt;Shift-v&gt;&lt;Shift-j&gt; do in Vim" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8794" PostTypeId="1" AcceptedAnswerId="8802" CreationDate="2016-07-15T03:17:15.770" Score="1" ViewCount="1462" Body="&lt;p&gt;I just realized that the standard setting of  is actual not 'going back one space', but deleting everything selected. Is there some basic way to get that some functionality in Vim visual mode, without resorting to  in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I noticed that  was even listed in &lt;code&gt;:map&lt;/code&gt;, which I found odd...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Okay, I now tried it with &lt;code&gt;vim -u NONE&lt;/code&gt; and then &lt;code&gt;:map&lt;/code&gt;, which showed me that...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v  &amp;lt;BS&amp;gt;          &quot;-d&#xA;v  &amp;lt;D-x&amp;gt;         &quot;*d&#xA;v  &amp;lt;D-c&amp;gt;         &quot;*y&#xA;v  &amp;lt;D-v&amp;gt;         &quot;-d&quot;*P&#xA;n  &amp;lt;D-v&amp;gt;         &quot;*P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These are the only mappings, but why are these mapping there anyway? I tried &lt;code&gt;vunmap &amp;lt;bs&amp;gt;&lt;/code&gt; but that doesn't work (it still doesn't go back like I want it to)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT2:&#xA;Okay so I made a screencapture to show my dilemma.&#xA;It should be self explanatory: On the left I call vim normally, load all my plugins, but then disable my mappings.&#xA;When I start visual mode I can use &lt;code&gt;&amp;lt;bs&amp;gt;&lt;/code&gt; (and &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt;) to change lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the right, using &lt;code&gt;vim -u NONE&lt;/code&gt; I can't do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There must be some setting to set that behavior...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/syOHN.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/syOHN.gif&quot; alt=&quot;Vim picture&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="1841" LastEditDate="2016-07-15T12:41:26.593" LastActivityDate="2016-07-15T12:41:41.643" Title="How to set functionality of &lt;BS&gt;" Tags="|key-bindings|visual-mode|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="8795" PostTypeId="2" ParentId="8793" CreationDate="2016-07-15T03:55:25.923" Score="9" Body="&lt;p&gt;I am guessing you were holding the &lt;kbd&gt;Shift&lt;/kbd&gt; key even while pressing &lt;code&gt;j&lt;/code&gt;. &#xA;Because &lt;code&gt;V + j&lt;/code&gt; alone would not have concatenated the lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;V&lt;/code&gt; is for selecting the entire line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;j&lt;/code&gt; moves the selection down. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, this is not the combination that did that for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;V + J&lt;/code&gt; on the other hand does exactly that. (holding &lt;code&gt;shift&lt;/code&gt; for v and j)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;J&lt;/code&gt; here joins the current line to next line (J for Join), which is a default setting in Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will get the same functionality without having to press &lt;code&gt;V&lt;/code&gt;. Press &lt;code&gt;J&lt;/code&gt; in normal mode and it will Join the next line with the current line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info, try &lt;code&gt;help :join&lt;/code&gt; in Vim.&lt;/p&gt;&#xA;" OwnerUserId="5481" LastActivityDate="2016-07-15T03:55:25.923" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8797" PostTypeId="1" AcceptedAnswerId="8801" CreationDate="2016-07-15T09:22:38.940" Score="8" ViewCount="294" Body="&lt;p&gt;In my fortran code I have a lot of blocks like the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subroutine name(arg1,arg2,arg3,...)&#xA;:&#xA;end subroutine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want them to become&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subroutine name(arg1,arg2,arg3,...)&#xA;:&#xA;end subroutine name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where each of these blocks can be indented by any amount of spaces (in fact, such blocks can be nested).&#xA;I tried with the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^ *subroutine \(.*\)/;/end subrout/s/end subroutine/&amp;amp; \1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which changes each line (I read it in the bottom line) changing nothing, just as the buffer &lt;code&gt;\1&lt;/code&gt; is empty.&#xA;The command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^ *subroutine \(.*\)/;/end subrout/s/end subroutine/&amp;amp; hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works well, but is obviously not what I want.&#xA;So the question is: how can I use in the replacement string a pattern matched by the global ex command &lt;code&gt;:g&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;I'm editing the question since, at the time I posted it , I hurriedly accepted the answer which was an answer to the specific case I referred to, but not to the title of the question, which is a little bit more general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I go to the point. I have a file like the following (non-sense just to make it as general as possible):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# sec1&#xA;fun1  are you a function?&#xA;fun2 no.&#xA;fun3 ok, nice to meet you!&#xA;&#xA;# 2nd part&#xA;first line&#xA;third line&#xA;ops (it was the second)&#xA;there were 3 lines in the preceding #&#xA;&#xA;# fourth group&#xA;now there's just one&#xA;and foreveeer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(In fact, the lines following each &lt;code&gt;#&lt;/code&gt;-line are hundreds.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to make substitutions in every line following each &lt;code&gt;#&lt;/code&gt;-line (and preceding the following &lt;code&gt;#&lt;/code&gt;-line); these substitutions should all use the text after the leading &lt;code&gt;#&lt;/code&gt;-line (or part of it). An example of want I would like to achieve is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# sec1&#xA;fun1 in sec1  are you a function?&#xA;fun2 in sec1 no.&#xA;fun3 in sec1 ok, nice to meet you!&#xA;&#xA;# 2nd part&#xA;first in 2nd line&#xA;third in 2nd line&#xA;ops in 2nd (it was the second)&#xA;there in 2nd were 3 lines in the preceding #&#xA;&#xA;# fourth group&#xA;now in fourth there's just one&#xA;and in fourth foreveeer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that only the first word following &lt;code&gt;#&lt;/code&gt; is inserted in the following lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, as I already said, I'd like to know if the pattern of the &lt;code&gt;:g&lt;/code&gt; command can be used in substitute string. I'm so interested in this answer since it is very annoying to register a macro (one wrong keystroke means starting all over again!), whereas a command like this,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^# \(\&amp;lt;\w\+\&amp;gt;\)/+;/^#/- s/\(\&amp;lt;\w\+\&amp;gt;\)\(.\+$\)/\2 \1 \3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would be perfect! ... And it's hard for me to belive that there's no way to use a command that does the job!&lt;/p&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="4472" LastEditDate="2017-09-25T16:13:25.793" LastActivityDate="2017-09-25T16:13:25.793" Title="Use pattern of global ex command found on a line to substitute in another line" Tags="|search|replace|global-command|filetype-fortran|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8798" PostTypeId="2" ParentId="8797" CreationDate="2016-07-15T09:51:38.290" Score="5" Body="&lt;p&gt;A possible workaround is to use a macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa/^subroutine&amp;lt;CR&amp;gt;f&amp;lt;space&amp;gt;/end subroutine&amp;lt;CR&amp;gt;$pq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be detailled like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa                  Record a macro in the a register&#xA;/^subroutine&amp;lt;CR&amp;gt;    Go to the next occurence of a subroutine declaration&#xA;f&amp;lt;space&amp;gt;            Go to the space separating &quot;subroutine&quot; and the name&#xA;y$                  Yank till the end of line (i.e. the name)&#xA;/end subroutine&amp;lt;CR&amp;gt; Go to the next occurence of &quot;end subroutine&quot;&#xA;$p                  Put the name at the end of the line&#xA;q                   Stop recording the macro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then execute your macro with &lt;code&gt;X@a&lt;/code&gt; where &lt;code&gt;X&lt;/code&gt; is the number of subroutines to proceed&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-07-15T09:51:38.290" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8799" PostTypeId="2" ParentId="8797" CreationDate="2016-07-15T10:08:58.977" Score="3" Body="&lt;p&gt;You can go with a substitute command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(^subroutine (.+)\_.{-}end subroutine)/\1 \2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This match the whole &lt;code&gt;subroutine / end subroutine&lt;/code&gt;in the group 1 and the subroutine name in the group 2, and concatenate them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;{-}&lt;/code&gt; is a non-greedy &lt;code&gt;*&lt;/code&gt; so it will stop at the first element found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\_.&lt;/code&gt; match everything and a &lt;code&gt;new-line&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-07-15T10:30:26.523" LastActivityDate="2016-07-15T10:30:26.523" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8800" PostTypeId="2" ParentId="8797" CreationDate="2016-07-15T11:17:45.997" Score="4" Body="&lt;p&gt;Here's the macro solution by &lt;a href=&quot;https://vi.stackexchange.com/users/1841/statox&quot;&gt;@statox&lt;/a&gt;, modified to deal with subroutine parameters and nested subroutines.  This assumes you also have installed &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=39&quot; rel=&quot;nofollow noreferrer&quot;&gt;matchit&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; - clear register &lt;code&gt;@a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; - start recording in register &lt;code&gt;@a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/^\s*subroutine\zs&amp;lt;CR&amp;gt;&lt;/code&gt; - search for &lt;code&gt;subroutine&lt;/code&gt;; &lt;code&gt;\zs&lt;/code&gt; leaves cursor on the space following it&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; - yank the name; &lt;code&gt;2&lt;/code&gt; because we want to include the space, &lt;code&gt;w&lt;/code&gt; because we want a &lt;code&gt;word&lt;/code&gt; (this stops at &lt;code&gt;(&lt;/code&gt; etc.)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;h&lt;/kbd&gt; - go left, to the end of &lt;code&gt;subroutine&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;%&lt;/kbd&gt; - go to matching &lt;code&gt;end subroutine&lt;/code&gt; (three cheers for &lt;code&gt;matchit&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; - paste the name&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;_&lt;/kbd&gt; - go to the first non-blank character, i.e. the beginning of  (the) &lt;code&gt;end&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;%&lt;/kbd&gt; - back to the matching &lt;code&gt;subroutine&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;j&lt;/kbd&gt; - down, to look for more &lt;code&gt;subroutine&lt;/code&gt;s&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;0&lt;/kbd&gt; - go to the beginning of line, so that not to miss a &lt;code&gt;subroutine&lt;/code&gt; on the current line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; - call the current macro recursively&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt; - end macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To run it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:set nowrapscan&lt;/code&gt; - avoid an infinite loop: the macro will bail out when it reaches the bottom of file&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;G&lt;/kbd&gt; - go to top of file&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; - run macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-07-15T11:23:37.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8801" PostTypeId="2" ParentId="8797" CreationDate="2016-07-15T12:30:41.033" Score="4" Body="&lt;p&gt;You could use a combination of &lt;code&gt;:global&lt;/code&gt;, &lt;a href=&quot;https://github.com/tmhedberg/matchit&quot; rel=&quot;nofollow&quot;&gt;matchit&lt;/a&gt; and &lt;code&gt;:normal!&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\s*subroutine/norm ^whye^%$p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:g/^\s*subroutine&lt;/code&gt;: for all lines matching &lt;code&gt;^\s*subroutine&lt;/code&gt;, do:&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal&lt;/code&gt;: enter normal mode (&lt;del&gt;&lt;code&gt;!&lt;/code&gt; means no mappings&lt;/del&gt; do &lt;strong&gt;not&lt;/strong&gt; use &lt;code&gt;norm!&lt;/code&gt;, as the &lt;code&gt;!&lt;/code&gt; removes the call to matchit (thanks @SatoKatsura))&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; go to the first non-blank character (not &lt;code&gt;0&lt;/code&gt;, to handle nested subroutines)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;whye&lt;/code&gt;: go to second word (name), go back 1 character (space) and copy it (the space is to make the pasting at the end a bit easier)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^%&lt;/code&gt;: go back to the first non-blank character and use matchit to find the matching &lt;code&gt;end&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$p&lt;/code&gt;: paste &lt;code&gt;name&lt;/code&gt; (with a leading whitespace) at the end of the line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="683" LastEditorUserId="6489" LastEditDate="2016-07-15T13:50:57.630" LastActivityDate="2016-07-15T13:50:57.630" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8802" PostTypeId="2" ParentId="8794" CreationDate="2016-07-15T12:41:41.643" Score="1" Body="&lt;p&gt;Okay I just figured it out, it's set by the &lt;code&gt;compatible&lt;/code&gt; option... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sets the &lt;code&gt;whichwrap&lt;/code&gt; option, which actually controls this behavior.&#xA;The &lt;code&gt;vi&lt;/code&gt; default is &lt;code&gt;&quot;&quot;&lt;/code&gt;, while the &lt;code&gt;vim&lt;/code&gt; default is &lt;code&gt;&quot;b,s&quot;&lt;/code&gt;, which is the space and the backspace key.&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-07-15T12:41:41.643" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8803" PostTypeId="1" AcceptedAnswerId="8805" CreationDate="2016-07-15T15:27:37.023" Score="5" ViewCount="915" Body="&lt;p&gt;I'd like to write content of the file into separate files each for each line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem &#xA;ipsum&#xA;dolor&#xA;sit&#xA;amet&#xA;consectetur&#xA;adipiscing&#xA;elit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to write 1st line into &lt;code&gt;line1.txt&lt;/code&gt;, 2nd into &lt;code&gt;line2.txt&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:. w line1.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works for the current line, however this doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:. w line\=line('.').txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;even though it would save only a single line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I write a file for each line dynamically based on the current line number?&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2016-08-25T17:36:00.623" Title="How to write each line into separate file?" Tags="|save|line-numbers|global-command|multiple-lines|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8804" PostTypeId="2" ParentId="6934" CreationDate="2016-07-15T15:27:47.117" Score="2" Body="&lt;p&gt;The Problem here is in the &lt;code&gt;.vimrc&lt;/code&gt; I use, it overwrote my locale. So I commented that out and everything works fine again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the corresponding GitHub issue: &lt;a href=&quot;https://github.com/amix/vimrc/issues/204#issuecomment-231083581&quot; rel=&quot;nofollow&quot;&gt;amix/vimrc#204&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to @Carpetsmoker for pointing out an answer would be more sufficent than an edit of the question ^^&lt;/p&gt;&#xA;" OwnerUserId="6878" LastActivityDate="2016-07-15T15:27:47.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8805" PostTypeId="2" ParentId="8803" CreationDate="2016-07-15T15:33:42.980" Score="11" Body="&lt;p&gt;Try a global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/exe &quot;.w! line&quot;.line('.').&quot;.txt&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:g/^/&lt;/code&gt; Do a command for every line (you can adjust this regular expression if you only want to save &lt;em&gt;certain&lt;/em&gt; lines, i.e. &lt;code&gt;.&lt;/code&gt; for non-empty lines)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;exe &quot;&quot;&lt;/code&gt; execute the following command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.w!&lt;/code&gt; save the current line and overwrite if already exists. (Remove &lt;code&gt;!&lt;/code&gt; if you don't want to auto-overwrite everything)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;line&quot;.line('.').&quot;.txt&quot;&lt;/code&gt; dynamically insert the line number.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%3Aglobal&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :g&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Aexecute&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h execute&lt;/code&gt;&lt;/a&gt; for  more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-08-25T17:36:00.623" LastActivityDate="2016-08-25T17:36:00.623" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8806" PostTypeId="2" ParentId="19" CreationDate="2016-07-15T17:13:38.973" Score="8" Body="&lt;p&gt;The other answers covered &lt;em&gt;why&lt;/em&gt; this happens. Here's a nice way to work around it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/wellle/targets.vim&quot; rel=&quot;noreferrer&quot;&gt;wellle/targets.vim&lt;/a&gt;. I just recently found this plugin, and I think it's extremely underrated. It provides a new text object: &lt;code&gt;din(&lt;/code&gt; Mnemonic: (d)elete (i)nside (n)ext &quot;(&quot;. This is compatible with other operators and several different objects, such as &lt;code&gt;an(&lt;/code&gt;, &lt;code&gt;in&quot;&lt;/code&gt;, &lt;code&gt;il(&lt;/code&gt; (inside last parenthesis) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also overrides the default behavior of &lt;code&gt;i(&lt;/code&gt; so that it first looks to see if the cursor is in parentheses, and then if it isn't it works the same way as &lt;code&gt;in(&lt;/code&gt;. This behavior can be turned on or off. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo(bar):&#xA;^cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;ci(&lt;/code&gt; acts the same as &lt;code&gt;cin(&lt;/code&gt;, since the cursor is not in parentheses.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo( ):&#xA;        ^Cursor here, and in insert mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also accepts a count:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo(bar):           #Define function foo(bar)&#xA;^cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;c2in(&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo(bar):           #Define function foo( )&#xA;                                             ^cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also provides a new object, &quot;argument&quot;. For example, &lt;code&gt;dana&lt;/code&gt; means &quot;Delete around the next argument&quot;. This also accepts a count. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo(arg1, arg2, BADarg3):&#xA;^ cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;d3ana&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo(arg1, arg2):&#xA;                  ^ cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are &lt;em&gt;many&lt;/em&gt; other features this plugin has, but these are the basic ones.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-15T17:13:38.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8808" PostTypeId="1" AcceptedAnswerId="8810" CreationDate="2016-07-15T19:21:22.220" Score="2" ViewCount="1172" Body="&lt;p&gt;Currently when I click somewhere in the terminal with &lt;code&gt;mouse=a&lt;/code&gt; enabled, Vim exits visual mode. How can I force Vim to remain in Visual mode, and thereby use mouse &lt;em&gt;clicks&lt;/em&gt; (not drags) to create a selection from the line/location where visual mode was entered?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I came up with a set of remaps that solves this perfectly (earlier I posted an overly complex macro here; you should use this instead). Just put these in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap v mzv&#xA;nnoremap V mzV&#xA;nnoremap &amp;lt;C-v&amp;gt; mz&amp;lt;C-v&amp;gt;&#xA;vnoremap &amp;lt;expr&amp;gt; &amp;lt;LeftMouse&amp;gt; '&amp;lt;LeftMouse&amp;gt;my`z' . :exe 'normal! ' . visualmode()&amp;lt;CR&amp;gt; . '`y'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2023-06-25T20:55:23.223" LastActivityDate="2023-06-25T20:55:23.223" Title="How to keep Vim from exiting Visual Mode due to mouse clicks while mouse=a?" Tags="|vimrc|visual-mode|visual-block|mouse|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8809" PostTypeId="2" ParentId="8808" CreationDate="2016-07-15T19:40:54.513" Score="1" Body="&lt;p&gt;This behavior works fine on &lt;strong&gt;gVim&lt;/strong&gt; if the mouse is enabled (&lt;code&gt;:set mouse=a&lt;/code&gt;) and the &lt;code&gt;'selectmode'&lt;/code&gt; option is at the default value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                *'selectmode'* *'slm'*&#xA;'selectmode' 'slm'      string  (default &quot;&quot;)&#xA;                        global&#xA;                        {not in Vi}&#xA;        This is a comma separated list of words, which specifies when to start&#xA;        Select mode instead of Visual mode, when a selection is started.&#xA;        Possible values:&#xA;           mouse        when using the mouse&#xA;           key          when using shifted special keys&#xA;           cmd          when using &quot;v&quot;, &quot;V&quot; or CTRL-V&#xA;        See |Select-mode|.&#xA;        The 'selectmode' option is set by the |:behave| command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't seems to work in my terminal. You can find the details in &lt;code&gt;:help mouse-using&lt;/code&gt;. If I understand correctly your use case shouldn't work for some terminals, such as xterm:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In an xterm, with the currently active mode included in the 'mouse' option,&#xA;normal mouse clicks are used by Vim, mouse clicks with the shift or ctrl key&#xA;pressed go to the xterm.  With the currently active mode not included in&#xA;'mouse' all mouse clicks go to the xterm.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that what you are asking is explicitly discouraged in &lt;code&gt;:help design-improved&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- Use the keyboard as much as feasible.  The mouse requires a third hand,&#xA;  which we don't have.  Many terminals don't have a mouse.&#xA;- When the mouse is used anyway, avoid the need to switch back to the&#xA;  keyboard.  Avoid mixing mouse and keyboard handling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-07-15T19:40:54.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8810" PostTypeId="2" ParentId="8808" CreationDate="2016-07-15T19:49:14.650" Score="3" Body="&lt;p&gt;You could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:xnoremap &amp;lt;LeftMouse&amp;gt; m`&amp;lt;LeftMouse&amp;gt;v``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows you to &lt;em&gt;click&lt;/em&gt; on where you want to extend the visual selection to, rather than drag. It works best if you also &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set slm=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-15T19:49:14.650" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8811" PostTypeId="1" CreationDate="2016-07-15T20:51:29.290" Score="1" ViewCount="112" Body="&lt;p&gt;I have a tags plugin that I'm adding features to. In order to test that it is working correctly, I need to examine the tags inside a tags file. I am trying to make sure the correct tags appear in the file and they are not there too many times. My test code is in VimL/Vimscript, so this is a VimL question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to do this is to have the tags file open in a Vim buffer, and then use the search() function to search for that text. Then I just check to see if it appears at the beginning of the line. The problem is search() accepts a regular expression, which is not what I am providing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could bring in each line as a string and examine them one at a time, but that sounds slow and like more work compared to getting search() to work for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get search() to work without regular expressions, or in some other way find the tags matching a non-regular expression search in a tags file?&lt;/p&gt;&#xA;" OwnerUserId="1410" LastActivityDate="2016-07-16T14:25:43.233" Title="Find a non-regular expression tag in a specific tags file" Tags="|regular-expression|search|tags|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8812" PostTypeId="1" CreationDate="2016-07-15T21:07:03.193" Score="1" ViewCount="700" Body="&lt;p&gt;For the majority of Semantic triggers in C++ YCM works fine, but I've been unable to make it work for the &lt;code&gt;.&lt;/code&gt; operator on a type. (For example, for a vector type I'd like to have the list of its available methods)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=H0zTuAMfBU0&quot; rel=&quot;nofollow&quot;&gt;This video&lt;/a&gt; illustrates my point above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I haven't found a single user of YCM complain about this problem, I assume there's a way to fix it via config I hope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case you need it, &lt;a href=&quot;https://gist.github.com/jlstr/167a825a47c656002dcf3944e41b6b14&quot; rel=&quot;nofollow&quot;&gt;this is what my .vimrc file looks like&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does this have something to do with the &lt;strong&gt;.ycm_extra_conf.py&lt;/strong&gt;? (which I have no idea how to configure)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;-J&lt;/p&gt;&#xA;" OwnerUserId="8441" LastActivityDate="2016-09-12T18:33:44.800" Title="YouCompleteMe C++ semantic completion does not work for . operator" Tags="|macvim|plugin-you-complete-me|filetype-c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8813" PostTypeId="1" AcceptedAnswerId="8821" CreationDate="2016-07-15T21:44:13.747" Score="1" ViewCount="109" Body="&lt;p&gt;Vim quits abruptly whenever I try to use omni-completion &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; in a Python file. This doesn't happen with other filetypes. &lt;code&gt;:echo &amp;amp;omnifunc&lt;/code&gt; produces &lt;code&gt;pythoncomplete#Complete&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I troubleshoot this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update.&lt;/strong&gt; A possible clue. When I do &lt;code&gt;:python&lt;/code&gt; in Vim (e.g. per &lt;a href=&quot;https://stackoverflow.com/a/2086309/1493867&quot;&gt;these instructions&lt;/a&gt;), then Vim quits in the same way.&lt;/p&gt;&#xA;" OwnerUserId="7810" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-07-16T15:59:16.030" Title="Unexpected exit when &lt;c-x&gt;&lt;c-o&gt; in Python file" Tags="|autocompletion|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8814" PostTypeId="1" AcceptedAnswerId="8826" CreationDate="2016-07-16T01:22:30.263" Score="4" ViewCount="2848" Body="&lt;p&gt;I am very used to the shell autocompletion, which uses the &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; character.  Therefore I tried to build something similar into my &lt;code&gt;.vimrc&lt;/code&gt;. I'm aware of the super popular YCM plugin but let's face this as an exercise in learning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have built the following piece of vimscript to: first, allow me to use different types of &lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; completions by changing a variable; second, do not fire a completion if the cursor is not after a cword character.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tab_completion_keys = &quot;\&amp;lt;c-x&amp;gt;\&amp;lt;c-p&amp;gt;&quot;&#xA;function! TabCompletion1()&#xA;  let l:char = matchstr(getline('.'), '\%' . col('.') . 'c.')&#xA;  if l:char =~# '\k'&#xA;    execute &quot;normal! a&quot; . g:tab_completion_keys . &quot;\&amp;lt;esc&amp;gt;&quot;&#xA;  else&#xA;    execute &quot;normal! a\&amp;lt;tab&amp;gt;\&amp;lt;esc&amp;gt;&quot;&#xA;  endif&#xA;endfunction&#xA;inoremap &amp;lt;tab&amp;gt; &amp;lt;esc&amp;gt;:call TabCompletion1()&amp;lt;cr&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that I cannot leave &lt;code&gt;normal!&lt;/code&gt; in insert-mode.  i.e. I cannot enter insert-mode in &lt;code&gt;normal!&lt;/code&gt; and finish the command without exiting the insert-mode.  Thanks to that, the code above opens the completion list and always selects the first completion, because I leave the insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make an insert-mode mapping that leaves me in insert-mode for some time (to select one word from the completion list) and then continues the mapping?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, maybe, there is a better way to deal with &lt;code&gt;exe normal!&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-07-17T00:34:28.470" Title="How can I make an inoremap that calls a function" Tags="|key-bindings|autocompletion|insert-mode|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8815" PostTypeId="1" CreationDate="2016-07-16T04:52:33.977" Score="1" ViewCount="218" Body="&lt;p&gt;I have special commenting macros for different languages in my &lt;code&gt;ftplugin&lt;/code&gt; files, and macros for creating &quot;dividers&quot; (i.e. commented out line of dashes &lt;code&gt;#--------...&lt;/code&gt;). I also define a Vimscript filetype for &lt;code&gt;.vimrc&lt;/code&gt; and files ending in &lt;code&gt;.vim&lt;/code&gt; using an entry in &lt;code&gt;.vim/ftdetect&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason, when I switch between tabs/windows, my commenting macro &lt;strong&gt;changes&lt;/strong&gt; but my &quot;insert divider&quot; macro &lt;strong&gt;does not change&lt;/strong&gt; (i.e. the comment character for the former macro is modified, but the comment character for the latter is not).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any possible reasons for this? Sorry if this seems vague but I'm at a loss here.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here are the macros; I have no idea how they could possibly be different enough to invoke this reaction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Matlab remaps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;c mA^i%&amp;lt;Esc&amp;gt;`A&#xA;nnoremap &amp;lt;Leader&amp;gt;_ mAo%&amp;lt;Esc&amp;gt;100a-&amp;lt;Esc&amp;gt;`A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vimscript remaps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;c mA^i&quot;&amp;lt;Esc&amp;gt;`A&#xA;nnoremap &amp;lt;Leader&amp;gt;_ mAo&quot;&amp;lt;Esc&amp;gt;100a-&amp;lt;Esc&amp;gt;`A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2016-07-16T05:36:09.323" LastActivityDate="2016-07-16T05:36:09.323" Title="Some mappings in my .vim/ftplugin/*.vim change upon entering a window with different filetype, and some don't. What could be the reason for this?" Tags="|key-bindings|vimrc|filetype|plugin-system|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8816" PostTypeId="1" AcceptedAnswerId="8817" CreationDate="2016-07-16T05:34:21.823" Score="3" ViewCount="774" Body="&lt;p&gt;I am making some remaps for inserting/removing comments and &quot;dividers&quot; for different languages. In my ftplugins files the variable &lt;code&gt;g:CommentChar&lt;/code&gt; is defined. For some reason I am getting the following error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;E114: Missing quote: &quot;\&#xA;E15: Invalid expression: &quot;:normal! mA^i&quot;.g:CommentChar.&quot;\&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;when trying to use the &lt;code&gt;&amp;lt;Leader&amp;gt;c&lt;/code&gt; macro. How is this possible? I thought &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; was valid in execute command if it was escaped.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;_ :execute 'normal! mAo'.g:CommentChar.'\&amp;lt;esc&amp;gt;100a-\&amp;lt;esc&amp;gt;`A'&#xA;nnoremap &amp;lt;Leader&amp;gt;c :execute 'normal! mA^i'.g:CommentChar.'\&amp;lt;esc&amp;gt;`A'&#xA;nnoremap &amp;lt;Leader&amp;gt;C :execute 'normal! mA^mBi'.g:CommentChar.'\&amp;lt;esc&amp;gt;f'.g:CommentChar.'dl`Bdl`A'&#xA;vnoremap &amp;lt;Leader&amp;gt;c :execute ':s/^/'.g:CommentChar.'/&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;'&#xA;vnoremap &amp;lt;Leader&amp;gt;C :execute ':s/'.g:CommentChar.'//&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2016-07-16T06:17:22.810" LastActivityDate="2016-07-17T08:11:58.887" Title="Escaped &quot;escape&quot; in key binding with :execute normal! is not getting escaped! String is terminated in middle of remap" Tags="|key-bindings|vimrc|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8817" PostTypeId="2" ParentId="8816" CreationDate="2016-07-16T06:47:16.090" Score="3" Body="&lt;p&gt;Use &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; instead of &lt;code&gt;:execute 'normal! ...'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;_ 'mao'.g:CommentChar.'&amp;lt;Esc&amp;gt;100a-&amp;lt;Esc&amp;gt;`a&amp;lt;CR&amp;gt;'&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;c 'mA^i'.g:CommentChar.'&amp;lt;Esc&amp;gt;`A&amp;lt;CR&amp;gt;'&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;C 'mA^mBi'.g:CommentChar.'&amp;lt;Esc&amp;gt;f'.g:CommentChar.'dl`Bdl`A&amp;lt;CR&amp;gt;'&#xA;vnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;c ':s/^/'.g:CommentChar.'/&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;'&#xA;vnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;C ':s/'.g:CommentChar.'//&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-07-16T06:47:16.090" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8818" PostTypeId="1" AcceptedAnswerId="8819" CreationDate="2016-07-16T13:32:56.923" Score="4" ViewCount="10638" Body="&lt;p&gt;I frequently search in my files using &lt;code&gt;/&lt;/code&gt;, and &lt;code&gt;\c&lt;/code&gt; is really helpful in these situations.  Is there any similar way to ignore white space and line breaks?  It would really be nice to be able to add something, like &lt;code&gt;\&amp;lt;something&amp;gt;&lt;/code&gt;, to the search&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/the words I am looking for&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so that it would match this, even if there where multiple white spaces and line breaks in-between the words.  It is a bit tedious to have to write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/the\_\s*words\_\s*I\_\s*am\_\s*looking\_\s*for&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;every time I want to search.  In this example I somehow indicated that it was the spaces &lt;code&gt;&lt;/code&gt; that represented the places where the extra white space or line breaks could occur, however, it would not bother me if it also matched something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t h e   wo r d sI a   m l o o k i ngfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as there will usually not be any &quot;silly&quot; matches of this sort (or at least few) in the searches I make.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not in very high hopes that this is possible, and, in case there is nothing like this, is there other ways to obtain something similar, with a function maybe.  However, it is only relevant, it if makes it easier than typing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/the\_\s*words\_\s*I\_\s*am\_\s*looking\_\s*for&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1498" LastEditorUserId="7161" LastEditDate="2016-07-16T15:18:18.243" LastActivityDate="2016-07-20T19:10:03.133" Title="ignoring spaces in search like ignoring cases" Tags="|regular-expression|search|whitespace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8819" PostTypeId="2" ParentId="8818" CreationDate="2016-07-16T14:17:50.290" Score="5" Body="&lt;p&gt;You can use a mapping and replace all spaces by e.g.  &lt;code&gt;\_s*&lt;/code&gt; which would match linebreaks as well. Something like this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:func! ReplaceSearch()&#xA;if getcmdtype() =~# '[?/]'&#xA;    return substitute(getcmdline(), ' \+', '\\_s*', 'g')&#xA;else&#xA;    return getcmdline()&#xA;endif&#xA;:endfunc&#xA;:cmap &amp;lt;F7&amp;gt; &amp;lt;C-\&amp;gt;eReplaceSearch()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This maps &lt;kbd&gt;F7&lt;/kbd&gt; in command line mode, so hit &lt;kbd&gt;F7&lt;/kbd&gt; when entering a search pattern to have it transformed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Theoretically, you could use the enter key for mapping, but if your function makes an error you will never get out of the command line again. Therefor I usually don't advise to map that key.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2016-07-20T19:10:03.133" LastActivityDate="2016-07-20T19:10:03.133" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8820" PostTypeId="2" ParentId="8811" CreationDate="2016-07-16T14:25:43.233" Score="2" Body="&lt;p&gt;You can use a function, that would search for the string literally. Something like this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! SearchLiterally(pat, flags)&#xA;    return search('\V'.escape(a:pat, '\\'), a:flags)&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can even do that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! ReplaceSearch()&#xA;    let cmd=getcmdtype()&#xA;    if cmd =~# '[?/]'&#xA;        return SearchLiterally(getcmdline(), cmd)&#xA;    else&#xA;        return getcmdline()&#xA;    endif&#xA;endfunc&#xA;&#xA;func! SearchLiterally(pat, search)&#xA;    return '\V'.escape(a:pat, '\\'. a:search)&#xA;endfunc&#xA;&#xA;cmap &amp;lt;F7&amp;gt; &amp;lt;C-\&amp;gt;eReplaceSearch()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-16T14:25:43.233" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8821" PostTypeId="2" ParentId="8813" CreationDate="2016-07-16T15:59:16.030" Score="0" Body="&lt;p&gt;OK, this is too long for a comment.  Also, I misunderstood one of the comments at first and it resulted in the unnecessary long list of comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your Vim does not support &lt;code&gt;python&lt;/code&gt; you cannot perform &lt;code&gt;python&lt;/code&gt; completion.  This is because the script that performs python completion relies on python.  The code is in &lt;code&gt;$VIMRUNTIME/autoload/pythoncomplete.vim&lt;/code&gt; and looks as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! pythoncomplete#Complete(findstart, base)&#xA;    ...&#xA;        endwhile&#xA;        execute &quot;python vimcomplete('&quot; . cword . &quot;', '&quot; . a:base . &quot;')&quot;&#xA;        return g:pythoncomplete_completions&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That &lt;code&gt;execute&lt;/code&gt; in there calls &lt;code&gt;:python&lt;/code&gt; and will fail if your Vim install has no python support.  To check for python support you can do either:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo has('python')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or check the output of &lt;code&gt;vim --version&lt;/code&gt; for &lt;code&gt;+python&lt;/code&gt; (or &lt;code&gt;+python3&lt;/code&gt; which will work as well since there is a &lt;code&gt;$VIMRUNTIME/autoload/python3complete.vim&lt;/code&gt; which uses python3).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After searching a little here on stack exchange I found that on MS Windows Vim often comes without &lt;code&gt;python&lt;/code&gt; support.  But have faith, have a look at &lt;a href=&quot;https://stackoverflow.com/questions/4718122/how-to-enable-python-support-in-gvim-on-windows&quot;&gt;this question&lt;/a&gt; on stack overflow to find how to enable &lt;code&gt;python&lt;/code&gt; on MS Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In summary, if you install &lt;code&gt;python&lt;/code&gt; on MS Windows with the default Windows installer (not the ActivePython) the Vim installer will be capable of finding the python &lt;code&gt;.dll&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, there is the classic catch that both Vim and python must be binaries of the same architecture.  i.e. you must make sure that both are either &lt;code&gt;i386&lt;/code&gt; (32bit) or &lt;code&gt;x86_64&lt;/code&gt; (64bit) binaries.  On MS Windows it should be easy to check based on the directory they're in: &lt;code&gt;Program Files (x86)&lt;/code&gt; or &lt;code&gt;Program Files&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/4718122/how-to-enable-python-support-in-gvim-on-windows&quot;&gt;How to enable Python support in gVim on Windows?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-07-16T15:59:16.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8822" PostTypeId="1" AcceptedAnswerId="8823" CreationDate="2016-07-16T17:53:51.520" Score="2" ViewCount="69" Body="&lt;p&gt;I have some visual-mode commenting macros that should place a comment character &lt;code&gt;g:CommentChar&lt;/code&gt; before the first non-whitespace character of each line in the selection. However, it places it right of the &lt;code&gt;0&lt;/code&gt; position instead. How can I remedy this/what could be the reason for this? I'm guessing in Visual Mode &lt;code&gt;^&lt;/code&gt; signifies the first highlighted character in the line? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to place comment characters before non-whitespace instead of at the beginning of line so I can &lt;strong&gt;preserve indent-based folding&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here are the macros (&lt;code&gt;g:CommentChar&lt;/code&gt; is defined in ftplugin files).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;c ':s/^/'.g:CommentChar.'/&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;'&#xA;vnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;C ':s/'.g:CommentChar.'//&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8084" LastActivityDate="2016-07-16T18:05:58.350" Title="Running find-and-replace in Visual Mode :'&lt;,'&gt;s/^/string/g inserts &quot;string&quot; at 0 position instead of ^ (first non-whitespace) position" Tags="|key-bindings|vimrc|search|visual-mode|string-manipulation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8823" PostTypeId="2" ParentId="8822" CreationDate="2016-07-16T18:05:58.350" Score="2" Body="&lt;p&gt;&lt;code&gt;^&lt;/code&gt; in &lt;code&gt;s/^/.../&lt;/code&gt; is a regexp, not a visual mode command.  I suggest the following mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;c ':s/^\s*\zs/'.escape(g:CommentChar, '/\').'/&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;'&#xA;vnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;C ':s/^\s*\zs\V'.escape(g:CommentChar, '/\').'//&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Better yet, you should consider using one of the commenter plugins instead of writing your own macros.  They can deal with corner situations you aren't even aware of at this time.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-07-16T18:05:58.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8824" PostTypeId="1" AcceptedAnswerId="8832" CreationDate="2016-07-16T19:16:51.030" Score="7" ViewCount="3662" Body="&lt;p&gt;I've had some issues reconciling my &lt;code&gt;.vimrc&lt;/code&gt; with files in &lt;code&gt;ftplugin&lt;/code&gt; and &lt;code&gt;after/ftplugin&lt;/code&gt;. In what order are they all read?&lt;/p&gt;&#xA;&lt;p&gt;For example: When vim encounters the line &lt;code&gt;plugin filetype on&lt;/code&gt; in a &lt;code&gt;.vimrc&lt;/code&gt; file, is the filetype program read immediately, or after the rest of &lt;code&gt;.vimrc&lt;/code&gt; executes? Further, am I correct in assuming that vim checks for a &lt;code&gt;.vim/ftplugin/filetype.vim&lt;/code&gt; file before loading the &amp;quot;default&amp;quot; &lt;code&gt;$VIMRUNTIME/ftplugin/filetype.vim&lt;/code&gt; (only running the default file if no user version is found), then checks for files in &lt;code&gt;.vim/after/ftplugin&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2023-11-27T01:15:31.897" LastActivityDate="2023-11-27T01:15:31.897" Title="In what order does vim read ftplugin files, syntax files, and the .vimrc when `filetype plugin on` and `set syntax=filetype` are called?" Tags="|vimrc|filetype|plugin-system|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8826" PostTypeId="2" ParentId="8814" CreationDate="2016-07-17T00:34:28.470" Score="2" Body="&lt;p&gt;Just like Sato Katsura said, this is a job for the map modifier &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;.  With &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; you can return the key combination from the function.  The final code looks as this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:tab_completion_keys = &amp;quot;\&amp;lt;c-x&amp;gt;\&amp;lt;c-p&amp;gt;&amp;quot;&#xA;function! TabCompletion()&#xA;  let l:col = max([col('.')-1, 1])&#xA;  let l:char = matchstr(getline('.'), '\%' . l:col . 'c.')&#xA;  if l:char =~# '\k'&#xA;    return g:tab_completion_keys&#xA;  else&#xA;    return &amp;quot;\&amp;lt;tab&amp;gt;&amp;quot;&#xA;  endif&#xA;endfunction&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;tab&amp;gt; TabCompletion()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;In practice it is much better to use a full plugin.  I am now using &lt;a href=&quot;https://github.com/ervandew/supertab&quot; rel=&quot;nofollow noreferrer&quot;&gt;supertab&lt;/a&gt; suggested by SibiCoder.&lt;/p&gt;&#xA;&lt;p&gt;supertab has many more configuration options than the code above, including: defined patterns for which no completion shall be attempted, different completion contexts based on the text around the cursor and even an option to use a different key than&#xA;&lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-07-17T00:34:28.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8827" PostTypeId="5" CreationDate="2016-07-17T03:29:16.777" Score="0" Body="&lt;p&gt;Questions about the &lt;a href=&quot;http://vimwiki.github.io/&quot; rel=&quot;nofollow&quot;&gt;Vimwiki plugin&lt;/a&gt; which allows a personal &lt;a href=&quot;https://en.wikipedia.org/wiki/Wiki&quot; rel=&quot;nofollow&quot;&gt;wiki&lt;/a&gt; to be created within vim. The wiki content comes from interlinked text files which may use Markdown, Mediawiki, or Vimwiki's own syntax.  Vimwiki provides support for tables, an export to HTML function, &lt;a href=&quot;https://github.com/vimwiki/utils&quot; rel=&quot;nofollow&quot;&gt;additional wiki utilities&lt;/a&gt; and much, much more.  Vimwiki has been used as a component of a &lt;a href=&quot;http://www.stochasticgeometry.ie/2012/11/23/vimwiki/&quot; rel=&quot;nofollow&quot;&gt;distributed, encrypted lab notebook&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="6590" LastEditDate="2016-07-17T08:43:03.030" LastActivityDate="2016-07-17T08:43:03.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8828" PostTypeId="4" CreationDate="2016-07-17T03:29:16.777" Score="0" Body="Questions about the Vimwiki plugin which allows a personal wiki to be created within vim. The wiki content comes from interlinked text files written in a wiki syntax.&#xD;&#xA;" OwnerUserId="6590" LastEditorUserId="6590" LastEditDate="2016-07-17T16:25:02.020" LastActivityDate="2016-07-17T16:25:02.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8829" PostTypeId="1" AcceptedAnswerId="8831" CreationDate="2016-07-17T07:05:01.450" Score="3" ViewCount="870" Body="&lt;p&gt;I have a Vi running as BusyBox executable (VMware ESXi):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vi --version&#xA;BusyBox v1.20.2 (2014-08-27 12:48:18 PDT) multi-call binary.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to disable auto-indent when pasting the code? Neither of the methods described in &lt;a href=&quot;https://stackoverflow.com/questions/2514445/turning-off-auto-indent-when-pasting-text-into-vim&quot;&gt;Turning off auto indent when pasting text into vim&lt;/a&gt; works for Busybox.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can &lt;code&gt;set noautoindent&lt;/code&gt; before pasting and &lt;code&gt;set autoindent&lt;/code&gt; after, but is there a persistent method?&lt;/p&gt;&#xA;" OwnerUserId="5334" LastActivityDate="2019-07-19T03:18:58.137" Title="How to disable auto-indent when pasting in BusyBox's Vi?" Tags="|indentation|busybox-vi|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8830" PostTypeId="2" ParentId="8816" CreationDate="2016-07-17T08:11:58.887" Score="2" Body="&lt;p&gt;The problem with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;c :execute 'normal! mA^i'.g:CommentChar.'\&amp;lt;esc&amp;gt;`A'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is that &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; is valid in &lt;code&gt;nnoremap&lt;/code&gt;, never mind &lt;code&gt;execute&lt;/code&gt;&#xA;and causes the command line up to that point to be executed.&#xA;(Plus you're missing a &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; at the end of the mapping.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way around this is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;c :execute 'normal! mA^i'.g:CommentChar.'^V^V^V^[`A'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where ^V is a literal Ctrl-V character and ^[ is a literal escape character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;^V^V^V^[&lt;/code&gt; is translated to &lt;code&gt;^V^[&lt;/code&gt; upon playback, which&#xA;inserts an escape character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to use &lt;code&gt;execute&lt;/code&gt;, do it like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 'nnoremap &amp;lt;Leader&amp;gt;c mA^i' . g:CommentChar . '&amp;lt;Esc&amp;gt;`A'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At this point you may as well use &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; as shown in @SatoKatsura's answer. The difference with &lt;code&gt;map &amp;lt;expr&amp;gt;&lt;/code&gt; is that the expression is evaluated at runtime, and a few operations are disallowed (see &lt;code&gt;:h map-&amp;lt;expr&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-07-17T08:11:58.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8831" PostTypeId="2" ParentId="8829" CreationDate="2016-07-17T08:16:43.330" Score="5" Body="&lt;p&gt;Judging by &lt;a href=&quot;https://git.busybox.net/busybox/tree/editors/vi.c&quot;&gt;the source&lt;/a&gt;, the only settable options in &quot;BusyBox Vi&quot; are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autoindent&#xA;showmatch&#xA;ignorecase&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, the answer seems to be &quot;no&quot;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-07-17T08:16:43.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8832" PostTypeId="2" ParentId="8824" CreationDate="2016-07-17T08:46:55.543" Score="5" Body="&lt;p&gt;When &lt;code&gt;filetype plugin on&lt;/code&gt; is encountered in your vimrc, &lt;code&gt;$VIMRUNTIME/ftplugin.vim&lt;/code&gt; is immediately executed. This creates an auto command which does the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe 'runtime! ftplugin/' . name . '.vim ftplugin/' . name . '_*.vim ftplugin/' . name . '/*.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This executes all matching files in each directory in &lt;code&gt;'runtimepath'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that auto commands are executed in the order in which they are defined,&#xA;so if you have the following in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au filetype php echoerr 'before'&#xA;filetype plugin on&#xA;au filetype php echoerr 'after'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And have this at the top of &lt;code&gt;$VIMRUNTIME/ftplugin/php.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echoerr 'during'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you will see the errors &lt;code&gt;'before'&lt;/code&gt;, &lt;code&gt;'during'&lt;/code&gt;, &lt;code&gt;'after'&lt;/code&gt; echoed in sequence when you edit a php file.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-07-17T08:46:55.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8833" PostTypeId="1" AcceptedAnswerId="8834" CreationDate="2016-07-17T10:27:45.810" Score="3" ViewCount="784" Body="&lt;p&gt;The situation: I want to use &lt;a href=&quot;https://github.com/junegunn/vader.vim&quot; rel=&quot;nofollow&quot;&gt;vader.vim&lt;/a&gt; to write some unit tests for a script of mine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However to really test it, it would be best to only have my plugin and &lt;code&gt;vader.vim&lt;/code&gt; loaded. I know how that you can use &lt;code&gt;vim -c 'your-commands-here'&lt;/code&gt; via the cmdline. However when I try to use &lt;code&gt;vim -c 'set rtp+=my-plugin'&lt;/code&gt; it simply does nothing. I feel like the whole bootup process is finished and &lt;em&gt;then&lt;/em&gt; it gets added to the &lt;code&gt;rtp&lt;/code&gt;, which is unfortunate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the question: How do I effectively whole plugins from the cmdline, &lt;em&gt;or&lt;/em&gt; how do I &lt;em&gt;resource&lt;/em&gt; my plugins in my rtp?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-07-17T14:08:56.573" Title="How to load a single plugin when starting vim from the cmdline" Tags="|plugin-system|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8834" PostTypeId="2" ParentId="8833" CreationDate="2016-07-17T14:08:56.573" Score="1" Body="&lt;p&gt;Use custom vimrc to source those plugins and use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u /path/to/custom_vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or, as suggested by @hgiesel, use &lt;a href=&quot;http://mywiki.wooledge.org/ProcessSubstitution&quot; rel=&quot;nofollow&quot;&gt;process substitution&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u &amp;lt;( cat &amp;lt;&amp;lt;&amp;lt; 'commands to be sourced' )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1616" LastActivityDate="2016-07-17T14:08:56.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8835" PostTypeId="1" AcceptedAnswerId="8836" CreationDate="2016-07-17T14:08:59.447" Score="11" ViewCount="2281" Body="&lt;p&gt;Let's say I'm in the shell (&lt;code&gt;bash&lt;/code&gt;) and want to see output that &lt;code&gt;:scriptnames&lt;/code&gt; would give, but don't want to start vim or maybe I want to echo that into another file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I execute&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +scriptnames&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which shows me all the scripts, but how do I echo that into the shell's stdout?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2020-10-13T06:56:26.923" Title="How to output result of vim commands to shell" Tags="|bash|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8836" PostTypeId="2" ParentId="8835" CreationDate="2016-07-17T14:30:34.950" Score="10" Body="&lt;p&gt;That happens, because usually Vim switches to the alternate screen and works there. Upon exiting, Vim will switch back and therefore you don't see anything left from your Vim session, but the result of the command executed even before starting Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This feature is explained at &lt;code&gt;:h xterm-screens&lt;/code&gt; &lt;a href=&quot;https://vimhelp.appspot.com/tips.txt.html#xterm-screens&quot;&gt;(link)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you basically don't want that and therefore want to disable that. You can do so, by setting &lt;code&gt;:set t_ti= t_te=&lt;/code&gt; the terminal codes that perform this to empty. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together, you would want to start Vim like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim -c ':set t_ti= t_te= nomore' -c 'scriptnames|q!'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are resetting the &lt;code&gt;'more'&lt;/code&gt; option, so that you don't see the hit-enter-prompt.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-17T14:30:34.950" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8837" PostTypeId="1" CreationDate="2016-07-17T16:32:56.087" Score="5" ViewCount="2200" Body="&lt;p&gt;I was trying out nvim (neovim) for the first time and I find that I have to type &lt;code&gt;&amp;lt;escape&amp;gt;&lt;/code&gt; twice to get out of insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if this is a feature or a &lt;a href=&quot;https://github.com/neovim/neovim/issues/3593&quot; rel=&quot;nofollow&quot;&gt;bug&lt;/a&gt;.  I see the same behaviour on both Mac and Linux (i.e. escape, followed by a move command such as 'k', inserts a k in my buffer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to configure this editor to use a single escape instead of two to get to NORMAL mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I'm not using tmux (at least not explicitly).  I'd tried the tmux method of changing the timeout, but it produced a syntax error, so I wasn't sure that was the issue.  However, the issue I am seeing does appear to be timeout related nonetheless.  If I wait (an unnaturally long time compared to what I am used to), the editor does switch back to normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT2.1: The software I am using is: Mac terminal + ssh + screen + nvim.  Initially it seemed like adding a .tmux.conf file (on my mac) with 'set -s escape-time 0' in it fixes this issue (on the mac), but I still see escape delays with terminal+ssh+screen+nvim and cause me to mess up my editing session after hitting escape and not waiting long enough.&lt;/p&gt;&#xA;" OwnerUserId="8454" LastEditorUserId="25223" LastEditDate="2019-10-26T18:57:13.080" LastActivityDate="2019-10-26T18:57:13.080" Title="How can I configure nvim to use a single escape to exit insert mode?" Tags="|neovim|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="8838" PostTypeId="2" ParentId="6900" CreationDate="2016-07-17T17:23:33.367" Score="2" Body="&lt;p&gt;If I understand correctly what you want, you can simply set &lt;code&gt;:set virtualedit=onemore&lt;/code&gt; and your mapping will start to work even at the line end case.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-17T17:23:33.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8839" PostTypeId="1" CreationDate="2016-07-17T17:44:47.153" Score="1" ViewCount="2543" Body="&lt;p&gt;I recently started to use &lt;code&gt;netrw&lt;/code&gt; as a file manager next to my editing session.  But I had a coupe of issues with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all &lt;code&gt;netrw&lt;/code&gt; reads unhidden buffers from the disk every time.  Which made me lose changes when I left a file (without writing it) and then came back to it.  Therefore I needed to &lt;code&gt;set hidden&lt;/code&gt;.  (Not sure whether that is correct but I did not investigate further.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now I have an issue with &lt;code&gt;:wall&lt;/code&gt;.  Let's say I have these two files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo foo &amp;gt; foo&#xA;echo bar &amp;gt; bar&#xA;echo foobar &amp;gt; fooba&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I open one of them with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u ~/.testvimrc foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;.testvimrc&lt;/code&gt; looks as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_liststyle=3&#xA;let g:netrw_chgwin=2&#xA;let g:netrw_winsize=22&#xA;set nocompatible&#xA;set hidden&#xA;set noautowrite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I edit &lt;code&gt;foo&lt;/code&gt; do not write it.  And open &lt;code&gt;netrw&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:22Lexplore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And open the &lt;code&gt;bar&lt;/code&gt; file using the &lt;code&gt;netrw&lt;/code&gt; window.  I then edit &lt;code&gt;bar&lt;/code&gt; and do not write it either.  I notice that I forgot the &lt;code&gt;r&lt;/code&gt; in the last file &lt;code&gt;fooba&lt;/code&gt;, therefore I go into the &lt;code&gt;netrw&lt;/code&gt; window (&lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;&lt;/code&gt;) and press &lt;code&gt;R&lt;/code&gt; to rename the file &lt;code&gt;fooba&lt;/code&gt; -&gt; &lt;code&gt;foobar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:wall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To write everything but then Vim writes an extra file.  The final file listing looks as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bar&#xA;foo&#xA;foobar&#xA;NetrwTreeListing 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This only happens when I have &lt;code&gt;netrw&lt;/code&gt; configured.  If I comment the &lt;code&gt;netrw&lt;/code&gt; lines out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;let g:netrw_liststyle=3&#xA;&quot;let g:netrw_chgwin=2&#xA;&quot;let g:netrw_winsize=22&#xA;set nocompatible&#xA;set hidden&#xA;set noautowrite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And perform the same procedure I do not get the &lt;code&gt;NetrwTreeListing 1&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is a MCVE, in a real world editing I often get dozens of those &lt;code&gt;NetrwTeeListing *&lt;/code&gt; files after a session of editing ans renaming files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am confident I'm configuring &lt;code&gt;netrw&lt;/code&gt; wrong.  I have been using it just for a couple of days, so I'm a little clueless on its configuration.  On the other hand I'm confident that the &lt;code&gt;netrw&lt;/code&gt; listings are &lt;code&gt;readonly&lt;/code&gt; buffers, therefore &lt;code&gt;:wall&lt;/code&gt; shall not be writing them (contrary to &lt;code&gt;:wall!&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm doing wrong?  I'm tired of removing those &lt;code&gt;NetrwTreeLisitng *&lt;/code&gt; files after an editing session.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Extra note: I renamed my &lt;code&gt;~/.vim&lt;/code&gt; directory for the MCVE (&lt;code&gt;mv ~/.vim ~/.old-vim&lt;/code&gt;) to make sure plugins are not interfering.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Update&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;It does look like a bug.  A new buffer is created every time a refresh happens on the tree listing (&lt;code&gt;let g:netrw_liststyle=3&lt;/code&gt;) in &lt;code&gt;netrw.vim&lt;/code&gt;.  The refresh happens in &lt;code&gt;s:NetrwRefresh&lt;/code&gt;, specifically in the lines 8502-8507 (in the newest &lt;code&gt;netrw&lt;/code&gt; available):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sil! NetrwKeepj %d _&#xA;if a:islocal&#xA; NetrwKeepj call netrw#LocalBrowseCheck(a:dirname)&#xA;else&#xA; NetrwKeepj call s:NetrwBrowse(a:islocal,a:dirname)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I enter &lt;code&gt;netrw&lt;/code&gt; in tree list mode and hit any command that triggers a refresh (&lt;code&gt;R&lt;/code&gt;, &lt;code&gt;r&lt;/code&gt;, &lt;code&gt;D&lt;/code&gt;) that code runs and produces a modified buffer.  The output of &lt;code&gt;:buffers!&lt;/code&gt; after a refresh looks as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:buffers!                           &#xA;  1 #a   &quot;foo&quot;                          line 0&#xA;  2u h + &quot;NetrwTreeListing 1&quot;           line 1&#xA;  4u%a-  &quot;NetrwTreeListing 2&quot;           line 8&#xA;  5u     &quot;NetrwTreeListing&quot;             line 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;h +&lt;/code&gt; next to the old listing.  I'm continuing the investigation. (I'm using this question as a scratch pad for notes about the issue)&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-07-17T20:12:17.100" LastActivityDate="2016-07-17T20:12:17.100" Title="How I configure Vim for use with netrw?" Tags="|netrw|save|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8841" PostTypeId="2" ParentId="8835" CreationDate="2016-07-17T23:42:09.033" Score="3" Body="&lt;p&gt;We can also use &lt;code&gt;:redir&lt;/code&gt; command to redirect the results of vim commands into a file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;redir! &amp;gt; vimout | scriptnames | redir END | q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This redirects the output of &lt;code&gt;scriptnames&lt;/code&gt; into the file &quot;vimout&quot;&lt;/p&gt;&#xA;" OwnerUserId="8031" LastActivityDate="2016-07-17T23:42:09.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8843" PostTypeId="1" CreationDate="2016-07-18T07:48:07.070" Score="1" ViewCount="60" Body="&lt;p&gt;I have a trouble with text objects and parentheses.&#xA;For example with this sentence:&#xA;&lt;code&gt;&amp;lt;bla bla=&quot;test&quot;&amp;gt;(hello)&amp;lt;/bla&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the cursor at the beginning of the line, when I use &lt;code&gt;ci&quot;&lt;/code&gt; (&quot;change inner double quote&quot;) the cursor jumps properly in the double quotes and erases the content in the double quote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I do &lt;code&gt;ci(&lt;/code&gt;, it doesn't work. It requires me to jump on the parenthesis (or in the parentheses) before it changes the content &lt;code&gt;f(ci(&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a bug? Is there some customization to do in &lt;code&gt;vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am on Windows, VIM 7.4.&lt;/p&gt;&#xA;" OwnerUserId="8460" LastEditorUserId="2920" LastEditDate="2016-07-18T16:40:56.503" LastActivityDate="2016-07-18T16:40:56.503" Title="Vim Text object and parentheses" Tags="|vimrc|object-motions|" AnswerCount="0" CommentCount="1" ClosedDate="2016-07-18T21:37:57.113" ContentLicense="CC BY-SA 3.0" />
  <row Id="8844" PostTypeId="1" AcceptedAnswerId="8846" CreationDate="2016-07-18T08:21:17.190" Score="3" ViewCount="807" Body="&lt;p&gt;I use &lt;code&gt;matchit.vim&lt;/code&gt; and it works. Indeed I write a Fortran code and I can jump from &lt;code&gt;IF&lt;/code&gt; to &lt;code&gt;END IF&lt;/code&gt; pressing &lt;code&gt;%&lt;/code&gt;.&#xA;I'm trying to add the couple &lt;code&gt;&amp;lt;+&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt; to &lt;code&gt;b:match_words&lt;/code&gt;,&#xA;adding&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:match_words = b:match_words . '&amp;lt;+:&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to my &lt;code&gt;~/.vimrc&lt;/code&gt; file, but I get errors E121 and E15 bout undefined variable &lt;code&gt;b:match_words&lt;/code&gt; and invalid expression &lt;code&gt;b:match_words . '&amp;lt;+:&amp;gt;'&lt;/code&gt;, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If i change to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:match_words = '&amp;lt;+:&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error disappear, but obviously I cannot match anything else that this only pair.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="6498" LastEditDate="2016-07-18T13:33:28.727" LastActivityDate="2016-07-18T13:33:28.727" Title="I cannot append a matching pair to b:match_words" Tags="|vimscript|plugin-matchit|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8845" PostTypeId="1" AcceptedAnswerId="8847" CreationDate="2016-07-18T10:01:19.713" Score="2" ViewCount="1141" Body="&lt;p&gt;I currently have something like this in my vimrc. The reason i have this is because I do not want items to be copied to the default register when I delete or change.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Copy the contents of delete to the black hole register&#xA;nnoremap dd &quot;_dd&#xA;nnoremap d &quot;_d&#xA;vnoremap d &quot;_d&#xA;&quot;Copy the contents of yank to the black hole register&#xA;nnoremap c &quot;_c&#xA;nnoremap C &quot;_C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now lately i felt the need of adding a cut command as well which deletes and yank. I understand by default Vim does not have a delete but it has a cut command. However i have customised it to my liking. I wanted to know if there was a way for me to cut text that would work with the above keybinding. I tried doing this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;*dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that does not work and I guess that's because dd above gets mapped to &lt;code&gt;&quot;_dd&lt;/code&gt;&#xA;Any suggestions on how I can accomplish a cut while maintaining my current shortcuts ?&lt;/p&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="7161" LastEditDate="2016-07-18T11:46:46.207" LastActivityDate="2016-07-18T15:24:08.050" Title="Cut and copy : Blackhole and default register assignment" Tags="|key-bindings|cut-copy-paste|macvim|register|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8846" PostTypeId="2" ParentId="8844" CreationDate="2016-07-18T10:38:13.663" Score="4" Body="&lt;p&gt;You want to extend &lt;code&gt;matchit&lt;/code&gt;'s default &lt;code&gt;b:match_words&lt;/code&gt;, so you'll have to to wait for it to be initialised first.  The docs make reference to setting it from &lt;code&gt;ftplugin&lt;/code&gt;s, so the solution is to add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:match_words .= ',&amp;lt;+:&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to a file &lt;code&gt;after/ftplugin/fortran.vim&lt;/code&gt;.  That's about all there is to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a side note: beware that &lt;code&gt;&amp;lt;+&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; above are actually regexps.  This is important if you want to add more pairs to &lt;code&gt;b:match_words&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-07-18T10:38:13.663" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8847" PostTypeId="2" ParentId="8845" CreationDate="2016-07-18T15:24:08.050" Score="4" Body="&lt;p&gt;First off, I think your first mapping is unnecessary. Since the second &lt;code&gt;d&lt;/code&gt; is in operator mode, it does not get remapped to &lt;code&gt;&quot;_d&lt;/code&gt;, so it maps out to &lt;code&gt;&quot;_dd&lt;/code&gt;. Secondly, you could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap d &quot;_d&#xA;nnoremap D &quot;_D&#xA;&#xA;nnoremap &quot;*d &quot;*d&#xA;nnoremap &quot;*D &quot;*D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works since it uses &lt;code&gt;noremap&lt;/code&gt;. Of course, you can change the register this yanks to, or the keystrokes you use to call it. For example, you could do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &quot;*d d&#xA;nnoremap &quot;*D D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make it yank to the unnamed register.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-18T15:24:08.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8849" PostTypeId="1" CreationDate="2016-07-18T19:58:11.840" Score="1" ViewCount="337" Body="&lt;p&gt;I am working on a plugin and as part of that plugin I am trying to update the statusline with &lt;code&gt;setlocal statusline=%!GetMPCStatusline()&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this causes vimrun.exe to open and close very fast. This happens only when I focus in the window where the &lt;code&gt;statusline&lt;/code&gt; is set and not the others. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am attaching this screen grab of Vimrun.exe opening and closing. It just keeps happening in the background but it doesn't open anything. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/S5e9e.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S5e9e.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, Why is this happening and what can I do to make this stop?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I am using GVim 7.4 on Windows. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I just tried this in the terminal Vim (powershell) and Vim in cygwin. There even though I am not getting this, something weird is happening there too. The cursor moves really really slow as if something is obstructing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit 2: This is the function its calling. It gets the output from the &lt;code&gt;mpc status&lt;/code&gt;, &lt;code&gt;mpc playlist&lt;/code&gt; command and parses them. When I run this function manually I can see the vimrun on the taskbar once and it disappears after that. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetMPCStatusline()&#xA;    let cmd = &quot;mpc status&quot;&#xA;    let result = split(system(cmd), '\n')&#xA;    let status = len(result) == 3 ? result[2] : result[0]&#xA;&#xA;    let [s:count, s:settings] =&#xA;                \ [len(split(system('mpc playlist'), '\n')),&#xA;                \ split(status, '   ')]&#xA;&#xA;    let s:statusline = &quot; &quot;&#xA;                \ . s:settings[1] . &quot; --- &quot;&#xA;                \ . s:settings[2] . &quot; ---%=&quot;&#xA;                \ . s:count . &quot; songs &quot;&#xA;    return s:statusline&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit 3: This doesn't happen when I have another function for the statusline. So, the only thing common in all the above tests is the statusline function above and hence I guess that has to be the reason why this is happening. Any ideas on why that is the case?&lt;/p&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="5481" LastEditDate="2016-07-19T04:36:50.577" LastActivityDate="2016-07-19T04:36:50.577" Title="Vimrun.exe keeps opening and closing when statusline is updated" Tags="|gvim|microsoft-windows|statusline|functions|" AnswerCount="0" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="8850" PostTypeId="1" CreationDate="2016-07-19T07:00:00.847" Score="1" ViewCount="213" Body="&lt;p&gt;I've found that ultisnips is one of the slowest plugins to load at startup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I use &lt;code&gt;NeoBundleLazy&lt;/code&gt; to load ultisnips later, eg upon entering insert mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NeoBundleLazy 'SirVer/ultisnips', {&#xA;    \ 'autoload': {&#xA;    \   'insert': 1,&#xA;    \   },&#xA;    \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But get this error message on loading vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing FileType Auto commands for &quot;*&quot;:&#xA;E117: Unknown function: UltiSnips#FileTypeChanged&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="1841" LastEditDate="2016-07-19T07:26:49.490" LastActivityDate="2016-07-19T07:26:49.490" Title="Loading ultisnips with NeoBundleLazy" Tags="|plugin-ultisnips|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8851" PostTypeId="1" CreationDate="2016-07-19T09:29:36.457" Score="6" ViewCount="915" Body="&lt;p&gt;I have an adapted version of &lt;a href=&quot;https://youtu.be/aHm36-na4-4#t=4m59s&quot; rel=&quot;nofollow noreferrer&quot;&gt;Damian Conway's Die Blinkënmatchen&lt;/a&gt; in my &lt;code&gt;~/.vimrc&lt;/code&gt; that &quot;highlight-flashes&quot; search matches as I step through them with &lt;code&gt;n&lt;/code&gt; / &lt;code&gt;N&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; 'hlsearch' makes it hard to tell which is the *current* match, so we&#xA;&quot; do some trickery to highlight that one in a special way (flashing for&#xA;&quot; 0.4 seconds).&#xA;&#xA;&quot; function to flash the current match a number of times&#xA;function! HLNext (blink)&#xA;    let [bufnum, lnum, col, off] = getpos('.')&#xA;    let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))&#xA;    let target_pat = '\c\%#\%('.@/.'\)'&#xA;    let i = 1&#xA;    while i &amp;lt; a:blink&#xA;        exec 'sleep 50m'&#xA;        let ring = matchadd('Comment', target_pat, 101)&#xA;        redraw&#xA;        exec 'sleep 50m'&#xA;        call matchdelete(ring)&#xA;        redraw&#xA;        let i += 1&#xA;    endwhile&#xA;endfunction&#xA;&#xA;&quot; Rewire n and N to step-and-call-function&#xA;nnoremap &amp;lt;silent&amp;gt; n   n:call HLNext(5)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; N   N:call HLNext(5)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works nice, but has one drawback -- skipping through many matches takes &lt;strong&gt;much&lt;/strong&gt; longer, as the next match is not highlighted until the flashing of the current one has finished.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to have the function interrupt the highlighting / flashing if &lt;code&gt;n&lt;/code&gt; / &lt;code&gt;N&lt;/code&gt; is pressed again while the function still runs?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am afraid my knowledge of Vim programming is very limited (to copy &amp;amp; paste, mostly), so I hope to find the necessary brainpower among you lot.&lt;/p&gt;&#xA;" OwnerUserId="1726" LastEditorUserId="343" LastEditDate="2017-01-06T09:25:50.620" LastActivityDate="2017-09-20T21:51:27.853" Title="Interrupting (blink-highlighting) function if mapping is invoked again" Tags="|vimscript|vimrc|" AnswerCount="1" CommentCount="12" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8852" PostTypeId="1" AcceptedAnswerId="8853" CreationDate="2016-07-19T10:06:40.023" Score="2" ViewCount="1300" Body="&lt;p&gt;In insert mode, when you hit &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; on a partially written word, a menu pops up with possible matches for completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I customize those matches ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I have a ruby-clangc gem that I want to use with the ruby-neovim gem in order to write my completion plugin for C/C++ code)&lt;/p&gt;&#xA;" OwnerUserId="8475" OwnerDisplayName="cedlemo" LastEditorUserId="1841" LastEditDate="2016-07-19T13:33:44.603" LastActivityDate="2016-07-19T13:42:46.790" Title="How to customize the entries in the completion menu?" Tags="|vimscript|vimrc|autocompletion|neovim|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8853" PostTypeId="2" ParentId="8852" CreationDate="2016-07-19T13:28:41.713" Score="5" Body="&lt;p&gt;About &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;, &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-P&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;the doc&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Find previous match for words that start with the&#xA;  keyword in front of the cursor, looking in places&#xA;  specified with the 'complete' option.  The found&#xA;  keyword is inserted in front of the cursor.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can then look at &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27complete%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h'complete'&lt;/code&gt;&lt;/a&gt;&#xA;to learn how to modify the behavior of the completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll see that you have several options to make the search of the match&#xA;restricted to the current buffer, using the other loaded buffers or even looking&#xA;for the spell dictionaries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To modify the setting simply add a line like this in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set complete=.,w,b,u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now for your completion plugin what you are looking for is a custom comlete function. Vims allows you to write such a function, for more information you should refer &lt;a href=&quot;https://vi.stackexchange.com/q/4584/1841&quot;&gt;this question&lt;/a&gt; and to the doc:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#complete-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h complete-functions&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27completefunc%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'completefunc'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I think you might also be interested in reading &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#ins-completion&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ins-completion&lt;/code&gt;&lt;/a&gt; which explains how the different completion modes of Vim works. (There are about ten different completion modes used to complete different items, learning them can be long but it should make your completion pretty efficient in the end)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-07-19T13:42:46.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8854" PostTypeId="1" AcceptedAnswerId="8860" CreationDate="2016-07-19T16:28:17.320" Score="1" ViewCount="176" Body="&lt;p&gt;Using these options&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wrap linebreak nolist&#xA;&#xA;set showbreak=~ &quot;adds specified character after wrap&#xA;&#xA;set breakindent &quot;forces word wrap to start at last lines indentation level&#xA;&#xA;set display=lastline &quot;shows as much of last line as possible in wrap mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when editing prose that expands over multiple lines, if you insert text the wrapping will correctly keep adjusting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you instead do &lt;code&gt;cw&lt;/code&gt; or &lt;code&gt;2cw&lt;/code&gt; or whatever, text no longer wraps on word, but visually appears to be wrapped by character. But this is actually false, because when you hit &lt;kbd&gt;x&lt;/kbd&gt; or some similar command, the character deleted is not the one that was under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to hit &lt;code&gt;:se wrap&lt;/code&gt; to adjust the text after doing a &lt;code&gt;2cw&lt;/code&gt; type of command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a setting I'm missing, or one I'm using that might be causing this bug?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using just the plain mac osx Terminal.app&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to reproduce this bug after commenting out my whole .vimrc and running only&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wrap linebreak nolist&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if I &lt;code&gt;c2w&lt;/code&gt;, and &lt;code&gt;f,&lt;/code&gt; &lt;code&gt;;&lt;/code&gt; a few times to get to a comma on the next line, the cursor will highlight with an inaccuracy of the number of characters that should have been wrapped. So if &quot;Perhaps&quot; was cut off at &quot;Perh&quot; the cursor will be on the second &quot;e&quot; in &quot;, deeper&quot;, but pressing x will still delete the comma. So it's a visual problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might not be obvious, but this is a case where you insert more than you deleted with the change command. So &lt;code&gt;cw&lt;/code&gt; &quot;a man&quot; and replace with &quot;something there&quot; or whatever, in order to force the wrapping to need to readjust.&lt;/p&gt;&#xA;" OwnerUserId="8483" LastEditorUserId="8483" LastEditDate="2016-07-19T17:19:05.220" LastActivityDate="2016-07-19T21:27:25.620" Title="wrap breaks when using delete or change word type commands" Tags="|cursor-motions|wrapping|line-breaks|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="8855" PostTypeId="1" AcceptedAnswerId="8858" CreationDate="2016-07-19T17:12:50.890" Score="15" ViewCount="5349" Body="&lt;p&gt;I am trying to change the default grep call to avoid unnecessary plugin installation. What I want from vim is to call the external search using the builtin command :grep with custom arguments, this is what I've tried putting in my rc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set wildignore=*.o,*.obj,*~,*.pyc,.git/**,tags,cscope*&#xA;let &amp;amp;grepprg='grep -n -R --exclude=' . &amp;amp;wildignore . ' $*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;usage:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set verbose grepprg&#xA;verbose=0                                                                &#xA;grepprg=grep -n -R --exclude=*.o,*.obj,*~,*.pyc,.git/**,tags,cscope* $*&#xA;:lgrep &amp;quot;_cast&amp;quot; ./src/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:!grep -n -R --exclude=*.o,*.obj,*~,*.pyc,.git/**,tags,cscope* &amp;quot;_cast&amp;quot; ./src/* 2&amp;gt;&amp;amp;1| tee /tmp/nvimzj3oo1/225                                                           zsh:1: no matches found: --exclude=*.o,*.obj,*~,*.pyc,.git/**,tags,cscope* &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;if I execute what vim tried:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ grep -n -R --exclude=*.o,*.obj,*~,*.pyc,.git/**,tags,cscope* &amp;quot;_cast&amp;quot; ./src/* 2&amp;gt;&amp;amp;1| tee /tmp/nvimzj3oo1/225&#xA;./src/daemon/lim_l3_server_mw.cc:160:    LimL3Server *self = static_cast&amp;lt;LimL3Server *&amp;gt;(st);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;so, I'm falling to see the problem, any ideas?&lt;/p&gt;&#xA;" OwnerUserId="2561" LastEditorUserId="28" LastEditDate="2020-11-03T17:10:30.840" LastActivityDate="2020-11-03T17:10:30.840" Title="How can I change the default grep call (grepprg) to exclude directories?" Tags="|neovim|ex-command|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8856" PostTypeId="1" AcceptedAnswerId="8857" CreationDate="2016-07-19T17:29:29.547" Score="15" ViewCount="5175" Body="&lt;p&gt;I am trying to map my Ctrl and plus sign together. This is what I am trying in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-=&amp;gt;    : echo &quot;Hello&quot; &amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However it seems like the mapping is not being triggered.&#xA;Any suggestions on what I might be doing wrong? I am using macvim.&lt;/p&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="2920" LastEditDate="2016-07-19T17:55:33.167" LastActivityDate="2018-10-22T12:33:28.297" Title="Mapping Ctrl with equal sign" Tags="|key-bindings|macvim|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8857" PostTypeId="2" ParentId="8856" CreationDate="2016-07-19T17:53:56.477" Score="21" Body="&lt;p&gt;Unfortunately, there's no reliable way of mapping &lt;kbd&gt;Ctrl-=&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of the way that &lt;code&gt;ctrl+key&lt;/code&gt; chords interact with the terminal and are represented internally, the only Ctrl-mappings that Vim is guaranteed to be able to detect are the ones defined in the ASCII standard. Here is the full list of such &lt;code&gt;ctrl+key&lt;/code&gt; combinations, and the byte each represents. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ctrl-@                 0x00            NUL&#xA;Ctrl-A to Ctrl-Z       0x01 to 0x1A&#xA;Ctrl-a to Ctrl-z       0x01 to 0x1A&#xA;Ctrl-[                 0x1B            ESC&#xA;Ctrl-\                 0x1C&#xA;Ctrl-]                 0x1D&#xA;Ctrl-^                 0x1E&#xA;Ctrl-_                 0x1F&#xA;Ctrl-?                 0x7F            DEL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, note that most of these are already have a function in Vim, and some are essentially identical to/indistinguishable from other keystrokes. e.g. &lt;code&gt;CTRL-M&lt;/code&gt; has the same keycode as &lt;code&gt;Enter&lt;/code&gt;, so if you map either of those you are also unavoidably mapping the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-20.5&quot; rel=&quot;noreferrer&quot;&gt;Vim-FAQ&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might be able to get around the restrictions above by configuring your terminal to send a certain byte-sequence for your mapping, like in &lt;a href=&quot;https://stackoverflow.com/a/2179779/3524982&quot;&gt;this stack-overflow thread&lt;/a&gt;, but that will definitely be a pain. Personally, I'd rather just pick a different mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This might eventually be fixed, but it's unlikely, since Vim relies upon the terminal it's running in. However, there's a good possibility this will work in Neovim. I don't know if that works right now or not.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="343" LastEditDate="2018-10-22T12:33:28.297" LastActivityDate="2018-10-22T12:33:28.297" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8858" PostTypeId="2" ParentId="8855" CreationDate="2016-07-19T18:52:36.167" Score="20" Body="&lt;p&gt;If any of the &lt;a href=&quot;https://unix.stackexchange.com/questions/131032/globbing-fails-in-zsh-but-works-in-bash&quot;&gt;globs has no match&lt;/a&gt;, in zsh, the command will be aborted. This means you need to &lt;a href=&quot;https://stackoverflow.com/questions/221921/use-grep-exclude-include-syntax-to-not-grep-through-certain-files&quot;&gt;escape your globs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you use &lt;code&gt;shellescape()&lt;/code&gt; to build your &lt;code&gt;'grepprg'&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;grepprg='grep -n -R --exclude=' . shellescape(&amp;amp;wildignore) . ' $*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'grepprg'&#xA;:h shellescape()&#xA;man zshexpn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Alternatives to &lt;code&gt;grep&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Have you thought about using a different program for &lt;code&gt;'grepprg'&lt;/code&gt; like &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;noreferrer&quot;&gt;ag, the silver searcher&lt;/a&gt;, &lt;code&gt;git grep&lt;/code&gt;, &lt;a href=&quot;https://beyondgrep.com/&quot; rel=&quot;noreferrer&quot;&gt;ack&lt;/a&gt;, or &lt;a href=&quot;https://github.com/BurntSushi/ripgrep&quot; rel=&quot;noreferrer&quot;&gt;ripgrep&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Ag, The Silver Searcher&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Ag by default ignores the following files:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ignores binary files e.g. &lt;code&gt;*.o&lt;/code&gt; and &lt;code&gt;*.pyc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Ignores version control directories e.g. &lt;code&gt;.git&lt;/code&gt;, &lt;code&gt;.hg&lt;/code&gt;, and &lt;code&gt;.svn&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Will ignore files that matched your &lt;code&gt;.gitignore&lt;/code&gt; files. I imagine your &lt;code&gt;tags&lt;/code&gt; and cscope file will be ignored by this&lt;/li&gt;&#xA;&lt;li&gt;Uses PRCE regular expressions&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This completely or nearly completely eliminates your excludes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set grepprg=ag\ --vimgrep\ $*&#xA;set grepformat=%f:%l:%c:%m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If vanilla grep settings aren't your thing then you can use &lt;a href=&quot;https://github.com/mileszs/ack.vim&quot; rel=&quot;noreferrer&quot;&gt;Ack.vim&lt;/a&gt; which works with ag despite its name.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Using Ripgrep:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/BurntSushi/ripgrep&quot; rel=&quot;noreferrer&quot;&gt;Ripgrep&lt;/a&gt; is similar to Ag, the silver searcher.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ignores binary files e.g. &lt;code&gt;*.o&lt;/code&gt; and &lt;code&gt;*.pyc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Ignores version control directories e.g. &lt;code&gt;.git&lt;/code&gt;, &lt;code&gt;.hg&lt;/code&gt;, and &lt;code&gt;.svn&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Will ignore files that matched your &lt;code&gt;.gitignore&lt;/code&gt; files. I imagine your &lt;code&gt;tags&lt;/code&gt; and cscope file will be ignored by this&lt;/li&gt;&#xA;&lt;li&gt;Uses Rust's regular expressions&lt;/li&gt;&#xA;&lt;li&gt;Super fast! &lt;a href=&quot;http://blog.burntsushi.net/ripgrep/&quot; rel=&quot;noreferrer&quot;&gt;Ripgrep is faster than {grep, ag, git grep, ucg, pt, sift}&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Setting for you &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set grepprg=rg\ --vimgrep&#xA;set grepformat=%f:%l:%c:%m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Using &lt;code&gt;git grep&lt;/code&gt; or &lt;code&gt;:Ggrep&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you are using &lt;code&gt;git&lt;/code&gt; and &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;noreferrer&quot;&gt;fugitive.vim&lt;/a&gt;'s &lt;code&gt;:Ggrep&lt;/code&gt; which uses &lt;code&gt;git grep&lt;/code&gt;. &lt;code&gt;git grep&lt;/code&gt; can be a wonderful option because it will by default only search inside of tracked files. Therefore sidestepping the need to add ignores.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;git grep&lt;/code&gt; without fugitive.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set grepprg=git\ --no-pager\ grep\ --no-color\ -n\ $*&#xA;set grepformat=%f:%l:%m,%m\ %f\ match%ts,%f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: this uses the current working directory as a starting point&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Using ack&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://beyondgrep.com/&quot; rel=&quot;noreferrer&quot;&gt;Ack&lt;/a&gt; is a tool like grep, optimized for programmers. Ack is a perl script that can be easier to install on locked down system. It is the forerunner to both Ag and Ripgrep.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ignore version control directories by default&lt;/li&gt;&#xA;&lt;li&gt;Ignore backup files and core dumps by default&lt;/li&gt;&#xA;&lt;li&gt;Can use &lt;code&gt;ackrc&lt;/code&gt; file to ignore more files by default&lt;/li&gt;&#xA;&lt;li&gt;Ack 1.* series ignores binary files by default. 2.* does not.&lt;/li&gt;&#xA;&lt;li&gt;Uses Perl's regular expressions&lt;/li&gt;&#xA;&lt;li&gt;Often faster than normal grep because it searches less files by default&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:grep&lt;/code&gt; settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set grepprg=ack\ -s\ -H\ --nopager\ --nocolor\ --nogroup\ --column&#xA;set grepformat=%f:%l:%c:%m,%f:%l:%m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If vanilla grep settings aren't your thing then you can use &lt;a href=&quot;https://github.com/mileszs/ack.vim&quot; rel=&quot;noreferrer&quot;&gt;Ack.vim&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-01-03T22:32:45.933" LastActivityDate="2018-01-03T22:32:45.933" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8860" PostTypeId="2" ParentId="8854" CreationDate="2016-07-19T21:27:25.620" Score="1" Body="&lt;p&gt;My version of vim was out of date. As Christian Brabandt pointed out, patch 576 repaired this bug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To update my vim on Mac OSX, I used&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;brew update&lt;/code&gt;&#xA;&lt;code&gt;brew upgrade vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without update, brew thought I had the latest version.&lt;/p&gt;&#xA;" OwnerUserId="8483" LastActivityDate="2016-07-19T21:27:25.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8861" PostTypeId="2" ParentId="8237" CreationDate="2016-07-19T22:35:26.533" Score="2" Body="&lt;p&gt;This does not seem to be possible out of the box. Here is a small patch, that should do what you want:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim&#xA;index de85844..c18d85d 100644&#xA;--- a/runtime/autoload/netrw.vim&#xA;+++ b/runtime/autoload/netrw.vim&#xA;@@ -6052,6 +6052,7 @@ fun! s:NetrwMaps(islocal)&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; v       :call &amp;lt;SID&amp;gt;NetrwSplit(5)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; x       :&amp;lt;c-u&amp;gt;call netrw#BrowseX(&amp;lt;SID&amp;gt;NetrwBrowseChgDir(1,&amp;lt;SID&amp;gt;NetrwGetWord(),0),0)&amp;quot;&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; X       :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;NetrwLocalExecute(expand(&amp;quot;&amp;lt;cword&amp;gt;&amp;quot;))&amp;quot;&amp;lt;cr&amp;gt;&#xA;+   nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; _        :call setreg(v:register, get(b:, 'current_dir', getcwd()). '/'. &amp;lt;SID&amp;gt;NetrwGetWord())&amp;lt;cr&amp;gt;&#xA;&amp;quot;   &amp;quot; local insert-mode maps&#xA;&amp;quot;   inoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; a      &amp;lt;c-o&amp;gt;:call &amp;lt;SID&amp;gt;NetrwHide(1)&amp;lt;cr&amp;gt;&#xA;&amp;quot;   inoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; c      &amp;lt;c-o&amp;gt;:exe &amp;quot;NetrwKeepj lcd &amp;quot;.fnameescape(b:netrw_curdir)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Using this, you can copy a file path using the &lt;kbd&gt;_&lt;/kbd&gt; key&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Update (2021)&lt;/em&gt;:&lt;br&gt;&#xA;With netrw v170 you can also do this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:echo getcwd() .. (&amp;amp;shellslash ? '/' : '\') .. netrw#Call(&amp;quot;NetrwGetWord&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can of course map it to e.g. return the result directly into a register.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2021-09-22T06:35:11.940" LastActivityDate="2021-09-22T06:35:11.940" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8862" PostTypeId="1" AcceptedAnswerId="8863" CreationDate="2016-07-20T06:09:50.353" Score="2" ViewCount="397" Body="&lt;p&gt;I can expand a vertical split screen to occupy most of the area using &lt;code&gt;Ctrl+w+|&lt;/code&gt;&#xA;Now I would like to map that shortcut to &lt;code&gt;Ctrl+m&lt;/code&gt;. I tried the following but it failed. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-m&amp;gt;    &amp;lt;C-W&amp;gt;|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However this does not seem to work I also tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-m&amp;gt;    &amp;lt;C-W-l&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However that fails also. Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="2920" LastEditDate="2016-07-20T06:46:36.930" LastActivityDate="2016-07-20T07:08:48.063" Title="Assign shortcut to a Split window resize Ctrl+w+|" Tags="|key-bindings|macvim|split|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8863" PostTypeId="2" ParentId="8862" CreationDate="2016-07-20T07:08:48.063" Score="6" Body="&lt;p&gt;&lt;code&gt;|&lt;/code&gt; is the command separator, so it terminates the map. You need to escape it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-m&amp;gt; &amp;lt;c-w&amp;gt;\|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or use &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-m&amp;gt; &amp;lt;c-w&amp;gt;&amp;lt;bar&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :bar&lt;/code&gt; and &lt;code&gt;:help map_bar&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-07-20T07:08:48.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8866" PostTypeId="1" AcceptedAnswerId="8867" CreationDate="2016-07-20T12:54:51.260" Score="8" ViewCount="964" Body="&lt;p&gt;When I'm trying to increase numbers with &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;A&lt;/kbd&gt; it removes the leading and the trailing zeros.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.009500&#xA;1.09500&#xA;1.0009500&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results after pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;A&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.009500  -&amp;gt;  1.9501&#xA;1.09500   -&amp;gt;  1.9501&#xA;1.0009500 -&amp;gt;  1.9501&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or if cursor in front of the &lt;code&gt;.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.009500  -&amp;gt;  2.009500&#xA;1.09500   -&amp;gt;  2.09500&#xA;1.0009500 -&amp;gt;  2.0009500&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make it work like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.009500  -&amp;gt;  1.009501&#xA;1.09500   -&amp;gt;  1.09501&#xA;1.0009500 -&amp;gt;  1.0009501&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried this on&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 12 2015 04:35:19)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3302" LastEditorUserId="1841" LastEditDate="2016-07-20T13:38:26.427" LastActivityDate="2016-07-20T14:56:27.320" Title="How can I increase floating number with ctrl-a without deleting zeros?" Tags="|key-bindings|vimrc|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="8867" PostTypeId="2" ParentId="8866" CreationDate="2016-07-20T13:53:19.070" Score="8" Body="&lt;p&gt;Thanks to @statox's suggestion, you can solve your issue with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nrformats-=octal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Firstly, Vim does not increment decimal number, it will try to increment &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;009500&lt;/code&gt; separately. So the question is why incrementing &lt;code&gt;009500&lt;/code&gt; removes the leading &lt;code&gt;0&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As suggested by @sp asic, I think vim is treating this number as an octal number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the source code of Vim, a &lt;a href=&quot;https://github.com/vim/vim/blob/22fcfad29276bd5f317faf516637dcd491b96a12/src/ops.c#L5689&quot; rel=&quot;noreferrer&quot;&gt;conversion between the string and the actual number is done&lt;/a&gt;, using the &lt;code&gt;str2nr()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see the definition of numbers in &lt;code&gt;:h expr-number&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                            hex-number octal-number&#xA;&#xA;Decimal, Hexadecimal (starting with 0x or 0X), or Octal (starting with 0).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;009500&lt;/code&gt; is a number starting with a &lt;code&gt;0&lt;/code&gt;, but containing a &lt;code&gt;9&lt;/code&gt;, it's not an octal number, and should not have a leading &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see the same result calling the &lt;code&gt;str2nr()&lt;/code&gt; function yourself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo str2nr(000100)&#xA;64&#xA;:echo str2nr(000900) &#xA;900&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;00100&lt;/code&gt; is a valid octal number, incrementing it will just add &lt;code&gt;1&lt;/code&gt; to the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;00900&lt;/code&gt; is an &lt;em&gt;invalid&lt;/em&gt; decimal number, incrementing it will &lt;em&gt;fix&lt;/em&gt; it (removing the leading &lt;code&gt;0&lt;/code&gt;) and incrementing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This is what I've understood of the little dig I've done in the Vim code, as I didn't understood everything I've read I may be wrong.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I believe the code responsible for the decimal conversion is the following (&lt;a href=&quot;https://github.com/vim/vim/blob/ee2615af64fdcee87d8e4b13b65356e77fbd969b/src/charset.c#L1937-L1943&quot; rel=&quot;noreferrer&quot;&gt;source&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (VIM_ISDIGIT(*ptr))&#xA;{&#xA;    un = 10 * un + (uvarnumber_T)(*ptr - '0');&#xA;    ++ptr;&#xA;    if (n++ == maxlen)&#xA;    break;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Considering the result is &lt;code&gt;un&lt;/code&gt;, you can see that the first &lt;code&gt;0&lt;/code&gt; won't add any value to the decimal number.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-07-20T14:24:49.150" LastActivityDate="2016-07-20T14:24:49.150" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8868" PostTypeId="2" ParentId="8866" CreationDate="2016-07-20T14:56:27.320" Score="4" Body="&lt;p&gt;You found the answer, which is caused by the default Vim setting of &lt;code&gt;'nrformat'&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'd like to mention another possibility to overcome this problem. This would be to use visual mode, select the last number and press &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;A&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this needs a relative recent Vim version, something like 7.4.1000, since visual mode incrementing/decrementing has been added just recently.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-20T14:56:27.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8869" PostTypeId="1" CreationDate="2016-07-20T15:07:45.727" Score="4" ViewCount="867" Body="&lt;p&gt;I had problem with YCMD server not shutting down properly, so I tried to kill it on VimLeave. After a couple tries I detected that VimLeave/VimLeavePre event not firing on vim exit. VimEnter is working though. What could be the cause of this?&lt;/p&gt;&#xA;" OwnerUserId="8492" LastEditorUserId="8492" LastEditDate="2016-07-20T15:14:57.917" LastActivityDate="2016-07-20T15:14:57.917" Title="autocmd VimLeave event not firing" Tags="|autocmd|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="8870" PostTypeId="1" AcceptedAnswerId="8871" CreationDate="2016-07-20T16:23:55.540" Score="2" ViewCount="1148" Body="&lt;p&gt;I tried doing the following command on a new install of Ubuntu and got a &quot;Sorry, command not supported on this version message&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo @%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How could any version of vim not support echo? The reported version is 7.4 Small version without GUI.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="2920" LastEditDate="2016-07-20T16:38:17.133" LastActivityDate="2016-07-20T16:47:13.430" Title="No echo command?" Tags="|command-line|linux|linux-ubuntu|echo|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8871" PostTypeId="2" ParentId="8870" CreationDate="2016-07-20T16:37:15.550" Score="2" Body="&lt;p&gt;Ubuntu comes packaged with a tiny version of vim. It is nearly vi. To install the &lt;em&gt;real&lt;/em&gt; version of vim, run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Personally, I prefer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install vim-gnome&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;since this comes with things like python and clipboard support, and gvim, but installing the default vim version should be enough to get echo working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't remember &lt;em&gt;exactly&lt;/em&gt; what the difference between the two is, and I don't have Ubuntu set up so I can't test it right now, but &lt;code&gt;apt-get install vim&lt;/code&gt; should come with the sane defaults and &lt;code&gt;apt-get install vim-gnome&lt;/code&gt; should get you the full features.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="6952" LastEditDate="2016-07-20T16:43:44.737" LastActivityDate="2016-07-20T16:43:44.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8872" PostTypeId="5" CreationDate="2016-07-20T16:38:56.887" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-07-20T16:38:56.887" LastActivityDate="2016-07-20T16:38:56.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8873" PostTypeId="4" CreationDate="2016-07-20T16:38:56.887" Score="0" Body="Use this tag for questions specific to using Vim on the Ubuntu flavor of linux." OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-07-20T21:53:16.103" LastActivityDate="2016-07-20T21:53:16.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8874" PostTypeId="2" ParentId="8870" CreationDate="2016-07-20T16:43:12.407" Score="4" Body="&lt;p&gt;you got a small version of Vim installed. That means, many functions are not supported, you can read about, what each flavor supports at &lt;code&gt;:h +feature-list&lt;/code&gt; (&lt;a href=&quot;https://vimhelp.appspot.com/various.txt.html#+feature-list&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So among the features not supported are multibyte, eval (plugins), diff, folding and quickfix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest solution to get a better full-working Vim is to install vim-gtk (full version with GTK Gui), vim-nox (full version without gui support) or vim-gnome (full version with Gnome Support)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-20T16:43:12.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8875" PostTypeId="2" ParentId="8870" CreationDate="2016-07-20T16:47:13.430" Score="1" Body="&lt;p&gt;The &lt;code&gt;echo&lt;/code&gt; command depends on the &lt;code&gt;eval&lt;/code&gt; feature.  The &lt;code&gt;eval&lt;/code&gt; faeture is compiled in only in models &lt;code&gt;normal&lt;/code&gt; and larger.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-07-20T16:47:13.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8876" PostTypeId="1" AcceptedAnswerId="8880" CreationDate="2016-07-20T17:04:18.290" Score="11" ViewCount="3780" Body="&lt;p&gt;I'd like to echo a custom message upon startup, based on whether or not certain startup functions were successful. I tried this in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo 'test'&#xA;&#xA;&quot;All my settings&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like vim to echo a message as if I had just typed &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo 'foo'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from the command line &lt;em&gt;after&lt;/em&gt; opening vim, but instead I get this obnoxious dialog box that comes up before my vim windows has even opened. I also tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe 'echo &quot;test&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent echo 'test'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but neither of these worked.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-02-09T01:53:27.410" Title="Echo message on startup without prompting" Tags="|vimrc|echo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8877" PostTypeId="1" CreationDate="2016-07-20T17:09:11.003" Score="6" ViewCount="6893" Body="&lt;p&gt;Is it possible to use &lt;code&gt;vim diff&lt;/code&gt; to open and compare all the differences between &lt;code&gt;HEAD&lt;/code&gt; and the files in the working directory?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2016-07-21T21:48:57.427" Title="Using vim diff to compare the working directory to the HEAD in git?" Tags="|vimdiff|git|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8878" PostTypeId="1" AcceptedAnswerId="8879" CreationDate="2016-07-20T17:25:44.787" Score="16" ViewCount="1481" Body="&lt;p&gt;I'm not really sure how to describe what I'd like to do. Basically I'd like to use visual block mode to select a region of text and then paste it &quot;as a collection of lines&quot; rather than as a rectangle.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a b&#xA;c d&#xA;e f&#xA;g h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after pressing &lt;code&gt;gg0&amp;lt;c-v&amp;gt;Gy&lt;/code&gt; the rectangle &lt;code&gt;a/c/e/g&lt;/code&gt; is in the default yank register (I forgot what it's called).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I then paste the rectangle &lt;code&gt;p&lt;/code&gt; I get the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aa b&#xA;cc d&#xA;ee f&#xA;gg h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if it's possible to paste a rectangle / visual block selection on a group of lines by itself, as if it were an ordinary visual selection.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&#xA;c&#xA;e&#xA;g&#xA;a b&#xA;c d&#xA;e f&#xA;g h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="2920" LastEditDate="2016-07-20T17:29:47.580" LastActivityDate="2016-07-20T17:34:26.823" Title="Paste visual block selection on its own lines" Tags="|cut-copy-paste|visual-block|" AnswerCount="1" CommentCount="1" ClosedDate="2023-04-19T13:03:36.060" ContentLicense="CC BY-SA 3.0" />
  <row Id="8879" PostTypeId="2" ParentId="8878" CreationDate="2016-07-20T17:34:26.823" Score="18" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put! &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:put&lt;/code&gt;: insert the contents of the specified register&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;!&lt;/code&gt;: insert before the current line (the default is after)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;&lt;/code&gt;: the unnamed register (check &lt;code&gt;:help registers&lt;/code&gt; for details)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could do it from insert mode as well: &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;r&lt;/kbd&gt;+&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-07-20T17:34:26.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8880" PostTypeId="2" ParentId="8876" CreationDate="2016-07-20T20:19:44.407" Score="16" Body="&lt;p&gt;You might want to use an autocommand that runs after VimEnter is triggered. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The autocommand can look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * echo 'foo'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When vim starts up, it runs the command, and 'foo' is visible in the bottom left, as it would if you had just run the command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would put this autocommand somewhere in your .vimrc&lt;/p&gt;&#xA;" OwnerUserId="2757" LastActivityDate="2016-07-20T20:19:44.407" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8881" PostTypeId="1" AcceptedAnswerId="8883" CreationDate="2016-07-20T20:51:26.260" Score="1" ViewCount="376" Body="&lt;p&gt;Is a &lt;kbd&gt;Command&lt;/kbd&gt;+&lt;kbd&gt;s&lt;/kbd&gt; shortcut on a MacVim equivalent to &lt;code&gt;wa&lt;/code&gt; ? I know that a &lt;code&gt;wa&lt;/code&gt; will save all the data being displayed in all the viewport. Will the &lt;kbd&gt;Command&lt;/kbd&gt;+&lt;kbd&gt;s&lt;/kbd&gt; shortcut do the same ?&lt;/p&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="6043" LastEditDate="2016-07-21T03:05:08.117" LastActivityDate="2016-07-21T03:05:08.117" Title="What does Command+s do in MacVim?" Tags="|macvim|save|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8882" PostTypeId="2" ParentId="8829" CreationDate="2016-07-20T22:49:34.580" Score="0" Body="&lt;p&gt;Don't know about BusyBox, but avoiding indentations is effective with the &lt;code&gt;:se paste&lt;/code&gt; command. I include in my &lt;code&gt;~/.vimrc&lt;/code&gt; the definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map #P :se paste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so by doing &lt;code&gt;#P&lt;/code&gt; I can turn indenting off. Useful when copying and pasting from&#xA;one terminal to another.&lt;/p&gt;&#xA;" OwnerUserId="7868" LastEditorUserId="2920" LastEditDate="2016-07-21T01:06:44.160" LastActivityDate="2016-07-21T01:06:44.160" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8883" PostTypeId="2" ParentId="8881" CreationDate="2016-07-21T00:45:54.653" Score="1" Body="&lt;p&gt;I tried &lt;kbd&gt;⌘&lt;/kbd&gt;+&lt;kbd&gt;s&lt;/kbd&gt; and it saves only the current file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is basically a simple save like &lt;kbd&gt;⌘&lt;/kbd&gt;+&lt;kbd&gt;s&lt;/kbd&gt; or &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;s&lt;/kbd&gt; in most GUI programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ax0NUl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ax0NUl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6043" LastActivityDate="2016-07-21T00:45:54.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8884" PostTypeId="1" AcceptedAnswerId="20522" CreationDate="2016-07-21T03:23:48.003" Score="4" ViewCount="562" Body="&lt;p&gt;Assume we have this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;baaa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;matchaddpos(&quot;Error&quot;, [[1,2]])&lt;/code&gt; highlights the second character (the first 'a') as &quot;Error&quot; group.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;baaa&#xA; ^ highlighted&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I insert a 'b' at the beginning, it becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bbaaa&#xA; ^ highlighted&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks like the color is stick to the &quot;grid&quot; instead of the character underneath.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I wanted is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bbaaa&#xA;  ^ highlighted&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, is there a &quot;thing&quot; that, when I call &lt;code&gt;thing(&quot;Group&quot;, [[lnum,col]])&lt;/code&gt;, the color is added to the character at that position, so that even when the character moves, the color follows it?&lt;/p&gt;&#xA;" OwnerUserId="8499" LastActivityDate="2019-07-04T19:55:23.227" Title="Is there anything like matchaddpos() but stick the highlight with the character instead of grid?" Tags="|highlight|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8885" PostTypeId="2" ParentId="8884" CreationDate="2016-07-21T04:08:56.413" Score="7" Body="&lt;p&gt;You can't do that with &lt;code&gt;matchadpos()&lt;/code&gt;.  This is a known problem with Vim highlighting, and it isn't likely to be solved any time soon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best you can do is to use &lt;code&gt;matcadd()&lt;/code&gt; with a regexp that matches on line 1, and anchor it at the first &lt;code&gt;a&lt;/code&gt;.  Perhaps like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd('Error', '\%1l[^a]\zsa')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-07-21T04:08:56.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8887" PostTypeId="1" AcceptedAnswerId="16226" CreationDate="2016-07-21T09:25:32.000" Score="2" ViewCount="228" Body="&lt;p&gt;At the moment I'm writing, I removed the &lt;code&gt;matchit&lt;/code&gt; plugin and the &lt;code&gt;%&lt;/code&gt; works well, making the cursor jump from a &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;[&lt;/code&gt;, or &lt;code&gt;{&lt;/code&gt; to the corresponding closing character and vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I installed &lt;code&gt;matchit&lt;/code&gt; again, adding &lt;code&gt;Plugin 'vim-scripts/matchit.zip'&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt; and then running Vundle's &lt;code&gt;:PluginInstall&lt;/code&gt;. Having done so, I can now jump back and forth from &lt;code&gt;subroutine&lt;/code&gt; to &lt;code&gt;end subroutine&lt;/code&gt; in my &lt;code&gt;.f90&lt;/code&gt; files and so on (and I can do it with &lt;code&gt;.cpp&lt;/code&gt; and so on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But&lt;/strong&gt; I cannot make this jumps with parenthesis and brackets and other &quot;standard&quot; pairs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea what could be the reason of such strange behavior in Vim. I hope the following observations can be useful for you to help me.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Wherever I press &lt;code&gt;%&lt;/code&gt; (to jump between a standard or non standard pair, or on an empty line with no reason), then I cannot use it anymore, as well as the cursor remains in the buffer related to a &lt;code&gt;.f90&lt;/code&gt; file.&lt;/li&gt;&#xA;&lt;li&gt;If I move to another buffer/window related to a NON &lt;code&gt;.f90&lt;/code&gt; file (by &lt;code&gt;:n&amp;lt;CR&amp;gt;&lt;/code&gt;, &lt;code&gt;:N&amp;lt;CR&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-W&amp;gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; and so on, or simply &lt;code&gt;:help&amp;lt;CR&amp;gt;&lt;/code&gt;) &lt;strong&gt;and&lt;/strong&gt; press &lt;code&gt;%&lt;/code&gt; at least once (to jump between ... as before), then I can go back to a &lt;code&gt;.f90&lt;/code&gt; buffer/window and use &lt;code&gt;%&lt;/code&gt; with standard pairs once (just &lt;strong&gt;once&lt;/strong&gt;!) again.&lt;/li&gt;&#xA;&lt;li&gt;Jumping between new pairs (&lt;code&gt;IF&lt;/code&gt;, &lt;code&gt;DO&lt;/code&gt;, and so on) is not affected.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Maybe I should underline that I got the feeling that this happens only with Fortran files (&lt;code&gt;.f90&lt;/code&gt; and &lt;code&gt;.f95&lt;/code&gt;), since it doesn't happen with help pages (&lt;code&gt;.txt&lt;/code&gt;) nor with &lt;code&gt;.cpp&lt;/code&gt; files.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="17549" LastEditDate="2018-05-19T13:20:16.950" LastActivityDate="2018-05-19T13:20:16.950" Title="with matchit installed %match parenthesis and brackets only once in Fortran files" Tags="|delimiter-matching|plugin-matchit|filetype-fortran|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="8888" PostTypeId="2" ParentId="8877" CreationDate="2016-07-21T12:10:57.043" Score="7" Body="&lt;p&gt;To view unstaged modifications to your git working tree  in vimdiff, try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git difftool --tool=vimdiff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or for staged changes &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git difftool --tool=vimdiff [ --staged | --cached ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These commands are invoking &lt;code&gt;git difftool&lt;/code&gt; and specifying &lt;code&gt;vimdiff&lt;/code&gt; at invocation, so should work without any prior configuration.&lt;br&gt;&#xA;However, until you configure &lt;code&gt;vimdiff&lt;/code&gt; as the default difftool, you will have to continue passing the &lt;code&gt;--tool=vimdiff&lt;/code&gt; option to &lt;code&gt;git difftool&lt;/code&gt;.&lt;br&gt;&#xA;Also, I suggest incrementally increasing your usage of vim as a git diffing tool, some people suggest jumping right in re-mapping the &lt;code&gt;git diff&lt;/code&gt; command to use vimdiff, but retaining the ability to use &lt;code&gt;git diff&lt;/code&gt; can still be useful.&lt;br&gt;&#xA;Also some people suggest turning off prompting, i.e. running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git config --global difftool.prompt false&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't use this because I want to go back to a shell between viewing files, so I can cancel out of the diff'ing if necessary.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;making edits right there in vimdiff&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;An advantage of using vim over &lt;code&gt;git diff&lt;/code&gt; is that when you are viewing unstaged or staged files in &lt;code&gt;vimdiff&lt;/code&gt; you can go ahead and change the file right there in vim, which is really handy.&lt;br&gt;&#xA;You need to use &lt;code&gt;:w!&lt;/code&gt; to force past vims warning of modifying a read only file though. Also, if you change a file that was staged, you will need to re-stage to include the edit into the next commit.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Setting vimdiff as your git difftool&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git config --global diff.tool vimdiff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or put &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[diff]&#xA;    tool = vimdiff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into your &lt;code&gt;~/.gitconfig&lt;/code&gt; or to be repo specific: &lt;code&gt;.git/config&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2016-07-21T21:48:57.427" LastActivityDate="2016-07-21T21:48:57.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8890" PostTypeId="1" CreationDate="2016-07-21T18:32:15.830" Score="2" ViewCount="106" Body="&lt;p&gt;I'm editing some HTML, which has embedded &lt;a href=&quot;http://handlebarsjs.com/&quot; rel=&quot;nofollow&quot;&gt;handlebars&lt;/a&gt; templates. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;script id=&quot;rowTemplate&quot; type=&quot;text/x-handlebars-template&quot;&amp;gt;&#xA;&amp;lt;tr&amp;gt;&#xA;    &amp;lt;td&amp;gt;{{ id }}&amp;lt;/td&amp;gt;&#xA;    &amp;lt;td&amp;gt;{{ address }}&amp;lt;/td&amp;gt;&#xA;    &amp;lt;td&amp;gt;{{ num_connections }}&amp;lt;/td&amp;gt;&#xA;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;/script&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Syntastic doesn't like it, and complains about &lt;code&gt;'&amp;lt;' + '/' + letter not allowed here&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I get Syntastic to do something more intelligent with embedded templates?&lt;/p&gt;&#xA;" OwnerUserId="5339" LastActivityDate="2016-07-21T18:32:15.830" Title="Syntastic checking for embedded handlebars code?" Tags="|gvim|plugin-syntastic|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8891" PostTypeId="5" CreationDate="2016-07-21T19:33:58.470" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-07-21T19:33:58.470" LastActivityDate="2016-07-21T19:33:58.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8892" PostTypeId="4" CreationDate="2016-07-21T19:33:58.470" Score="0" Body="Questions having to do with the range modifier in ex (command-line) commands." OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-07-22T05:37:17.020" LastActivityDate="2016-07-22T05:37:17.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8893" PostTypeId="1" CreationDate="2016-07-21T21:32:24.423" Score="1" ViewCount="47" Body="&lt;p&gt;Let's say I have a text file opened in vim. I'd like to be able to edit this file from bash, let's say with the command &lt;code&gt;echo &quot;text&quot; &amp;gt;&amp;gt; file&lt;/code&gt; while the file is already opened in vim. Ideally, vim would just refresh the new content and wouldn't bother with a .swp file, asking for what version I want to restore. Any idea how to do this?&lt;/p&gt;&#xA;" OwnerUserId="7005" LastEditorUserId="2920" LastEditDate="2016-07-21T21:41:52.173" LastActivityDate="2016-07-21T21:43:01.790" Title="How to allow editing of a file from other sources while it's already open in vim?" Tags="|swap-file|" AnswerCount="1" CommentCount="0" ClosedDate="2016-07-21T23:26:22.523" ContentLicense="CC BY-SA 3.0" />
  <row Id="8894" PostTypeId="2" ParentId="8893" CreationDate="2016-07-21T21:43:01.790" Score="2" Body="&lt;p&gt;I believe the option you're looking for is &lt;code&gt;autoread&lt;/code&gt;. To use it put this in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoread&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h 'autoread'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When a file has been detected to have been changed outside of Vim and&#xA;    it has not been changed inside of Vim, automatically read it again.&#xA;    When the file has been deleted this is not done.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-07-21T21:43:01.790" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8895" PostTypeId="1" AcceptedAnswerId="8897" CreationDate="2016-07-22T04:11:35.127" Score="19" ViewCount="8350" Body="&lt;p&gt;Can I set something like &lt;code&gt;ctrl+s&lt;/code&gt; to save the file?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to use &lt;code&gt;:w&lt;/code&gt; every time.&lt;/p&gt;&#xA;" OwnerUserId="8500" LastEditorUserId="2920" LastEditDate="2016-07-22T05:07:18.750" LastActivityDate="2023-10-30T14:29:11.907" Title="How to map a shortcut for saving the file" Tags="|key-bindings|save|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8896" PostTypeId="2" ParentId="8895" CreationDate="2016-07-22T04:22:14.183" Score="4" Body="&lt;p&gt;Yes, that's actually set up in the mswin.vim file that distributed with Vim 6.2 and above for windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It contains the following mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use CTRL-S for saving, also in Insert mode&#xA;noremap &amp;lt;C-S&amp;gt; :update&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;C-S&amp;gt; &amp;lt;C-C&amp;gt;:update&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;C-S&amp;gt; &amp;lt;C-O&amp;gt;:update&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vim.wikia.com/wiki/Map_Ctrl-S_to_save_current_or_new_files&quot; rel=&quot;nofollow&quot;&gt;Vim Wikia page on mapping Ctrl-S&lt;/a&gt; for this and other possible mappings.&lt;/p&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2016-07-22T04:22:14.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8897" PostTypeId="2" ParentId="8895" CreationDate="2016-07-22T04:53:53.687" Score="21" Body="&lt;p&gt;First of all stop using &lt;code&gt;:w&lt;/code&gt; to save. Use &lt;code&gt;:update&lt;/code&gt; instead. &lt;code&gt;:update&lt;/code&gt; writes the file to disk only when there are changes. So, it could be really helpful especially if the file is huge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to map &lt;code&gt;&amp;lt;C-S&amp;gt;&lt;/code&gt; to &lt;code&gt;:update&lt;/code&gt; here is how you do it&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-S&amp;gt; :update&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may also want to have this mapping in Insert mode too. For that use this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-S&amp;gt; &amp;lt;Esc&amp;gt;:update&amp;lt;cr&amp;gt;gi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping goes normal mode, executes the &lt;code&gt;:update&lt;/code&gt; command and then leaves you back where you are in &lt;code&gt;insert&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, that is how you remap a key.&#xA;But I have &lt;code&gt;:update&lt;/code&gt; mapped to &lt;code&gt;zz&lt;/code&gt; in my &lt;code&gt;vimrc&lt;/code&gt; file. &lt;code&gt;zz&lt;/code&gt; is far more easy to hit than &lt;code&gt;Ctrl + S&lt;/code&gt;. Also, mapping &lt;code&gt;Ctrl + S&lt;/code&gt; can cause issues in Unix terminals as pointed out in the comments by @Sato Katsura.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you wish to use &lt;code&gt;zz&lt;/code&gt;, you can add that as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap zz :update&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="5481" LastEditDate="2016-07-22T09:11:17.723" LastActivityDate="2016-07-22T09:11:17.723" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="8898" PostTypeId="1" CreationDate="2016-07-22T06:45:29.783" Score="0" ViewCount="757" Body="&lt;p&gt;I want to be able to write German texts using my Vim 7.4 installed on a Windows 10 machine with Russian locale and German keyboard layout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; file looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=utf-8&#xA;set fileencoding=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't neither enter German Umlauts, nor display those entered in another editor (i. e. &lt;code&gt;ä&lt;/code&gt; is displayed like &lt;code&gt;a&lt;/code&gt; etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Russian text can be both entered and is displayed correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make sure that I can write in German, English and Russian in the Vim editor (in the same file) ?&lt;/p&gt;&#xA;" OwnerUserId="8524" LastEditorUserId="1841" LastEditDate="2016-07-22T07:21:18.283" LastActivityDate="2016-07-22T07:29:10.103" Title="How to enter and display German Umlauts on a Windows 10 machine with Russian locale?" Tags="|microsoft-windows|unicode|keyboard-layout|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8899" PostTypeId="2" ParentId="8898" CreationDate="2016-07-22T07:29:10.103" Score="1" Body="&lt;p&gt;After I reinstalled the program with &quot;Native language support&quot; disabled (in the installer), the problem disappeared.&lt;/p&gt;&#xA;" OwnerUserId="8524" LastActivityDate="2016-07-22T07:29:10.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8900" PostTypeId="1" AcceptedAnswerId="8902" CreationDate="2016-07-22T07:36:12.443" Score="2" ViewCount="793" Body="&lt;p&gt;I want to use the auto complete feature from vim (&lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt;).&#xA;How can I activate this feature automatically after I have entered e.g. 3 chars?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You&lt;/p&gt;&#xA;" OwnerUserId="8525" LastEditorUserId="1841" LastEditDate="2016-07-22T08:07:29.757" LastActivityDate="2016-07-22T08:36:47.977" Title="Autocomplete after serveral chars" Tags="|autocompletion|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8901" PostTypeId="1" AcceptedAnswerId="8905" CreationDate="2016-07-22T07:41:04.397" Score="2" ViewCount="2473" Body="&lt;p&gt;I want to use the &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow&quot;&gt;UltiSnips&lt;/a&gt; plugin in Vim 7.4 under Windows 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When enter &lt;code&gt;:version&lt;/code&gt; I see that python is there, but when I launch gVim, it says in a dialog box &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UltiSnips requires py &amp;gt;= 2.7 or py3`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I make my system compatible with UltiSnips (e. g. find a Vim distro with support for Python 2.7 or 3) ?&lt;/p&gt;&#xA;" OwnerUserId="8524" LastEditorUserId="1841" LastEditDate="2016-07-22T09:53:03.220" LastActivityDate="2016-07-22T09:53:03.220" Title="Why can't UltiSnips use python while 'python' is enabled?" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8902" PostTypeId="2" ParentId="8900" CreationDate="2016-07-22T08:31:09.443" Score="1" Body="&lt;p&gt;A reddit user &lt;a href=&quot;https://www.reddit.com/r/vim/comments/4tu844/vim_completion_without_plugin/&quot; rel=&quot;nofollow&quot;&gt;posted this&lt;/a&gt; which could be a base to what you are looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code creates an autocommand triggered after you insert a character. This autocommand calls a function which will feed the &lt;code&gt;v:char&lt;/code&gt; variable used by the autocompletion mechanism and call the autocompletion. You can then use &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; as if you &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt; as you'd do if you had triggered the autocompletion by yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code also remaps &lt;kbd&gt;enter&lt;/kbd&gt; to accept the current autocompletion suggestion.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Minimalist-AutoCompletePop-Plugin&#xA;set completeopt=menu,menuone,noinsert&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; pumvisible() ? &quot;\&amp;lt;C-Y&amp;gt;&quot; : &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;autocmd InsertCharPre * call AutoComplete()&#xA;fun! AutoComplete()&#xA;    if v:char =~ '\K'&#xA;        \ &amp;amp;&amp;amp; getline('.')[col('.') - 4] !~ '\K'&#xA;        \ &amp;amp;&amp;amp; getline('.')[col('.') - 3] =~ '\K'&#xA;        \ &amp;amp;&amp;amp; getline('.')[col('.') - 2] =~ '\K' &quot; last char&#xA;        \ &amp;amp;&amp;amp; getline('.')[col('.') - 1] !~ '\K'&#xA;&#xA;        call feedkeys(&quot;\&amp;lt;C-P&amp;gt;&quot;, 'n')&#xA;    end&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(I repeat that the code isn't mine but was made by maxboisvert it is available on &lt;a href=&quot;https://gist.github.com/maxboisvert/a63e96a67d0a83d71e9f49af73e71d93&quot; rel=&quot;nofollow&quot;&gt;his github&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also as I said in my comment I think that &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;nofollow&quot;&gt;YouCompleteMe&lt;/a&gt; provides this features but I wouldn't recommend that to you. This plugin is really heavy and is a lot of trouble to install and to use.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-07-22T08:36:47.977" LastActivityDate="2016-07-22T08:36:47.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8903" PostTypeId="1" AcceptedAnswerId="20305" CreationDate="2016-07-22T09:27:37.543" Score="3" ViewCount="447" Body="&lt;p&gt;I am looking for a key mapping hint plugin, which has a similar functionality to the &lt;a href=&quot;http://spacemacs.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;spacemacs'&lt;/a&gt; space key. Here is a window that displays the key mappings after pressing a spacebar:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2B3Y5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2B3Y5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... and when I press &lt;code&gt;g&lt;/code&gt;, I can access git functions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TBedv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TBedv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... then, pressing &lt;code&gt;S&lt;/code&gt; would close the hint window and stage the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is great, because I can learn key mappings of plugins very easily, without reading the docs. Needless to say, it is impossible to remember all those bindings for longer time, even those defined by myself in vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin with similar functionality, where pressing a leader key would open such window, awaiting for further user input?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be still great if it only accepted custom bindings from a config, so I can read the docs once, create bindings, add some labels with info for each entry, and forget about the details.&lt;/p&gt;&#xA;" OwnerUserId="2562" LastActivityDate="2019-06-13T08:20:18.417" Title="key mapping hints plugin" Tags="|key-bindings|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8904" PostTypeId="1" AcceptedAnswerId="8913" CreationDate="2016-07-22T09:35:32.927" Score="2" ViewCount="3227" Body="&lt;p&gt;I've installed the UltiSnips and vim-snippets plugins. In order for the snippets to work, I need to activate &lt;code&gt;vim-snippets&lt;/code&gt; for UltiSnips in my &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vundle version for snipmate looks like this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ActivateAddons vim-snippets snipmate&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I need to do the same, but for Pathogen and UltiSnips instead of snipmate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 1:&lt;/strong&gt; My current &lt;code&gt;.vimrc&lt;/code&gt; (UltiSnips doesn't work).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=utf-8&#xA;set fileencoding=utf-8&#xA;syntax on&#xA;execute pathogen#infect()&#xA;filetype plugin indent on&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;c-b&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-z&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using Windows 10 (Russian locale, German keyboard layout).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; With this &lt;code&gt;.vimrc&lt;/code&gt; file, snippet expansion works in gVim, but not in Vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set encoding=utf-8&#xA;set fileencoding=utf-8&#xA;syntax on&#xA;execute pathogen#infect()&#xA;filetype plugin indent on&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;c-b&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-z&amp;gt;&quot;&#xA;let g:UltiSnipsSnippetsDir = $HOME.'/vimfiles/bundle/vim-snippets/UltiSnips'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8524" LastEditorUserId="8524" LastEditDate="2016-07-22T12:48:37.603" LastActivityDate="2016-07-22T12:48:37.603" Title="How to activate vim-snippets for UltiSnips and Pathogen?" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8905" PostTypeId="2" ParentId="8901" CreationDate="2016-07-22T09:48:40.347" Score="3" Body="&lt;p&gt;The problem comes from the fact that your Vim setup supports python, but python is not installed on your system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When Vim has the &lt;code&gt;'python'&lt;/code&gt; and/or &lt;code&gt;'python3'&lt;/code&gt; features enabled that means that it provides an interface to interact with python code: you can make Vim to ask the system to execute a python statement or a whole python code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if the interface is enabled, Vim is not a python compiler/executer: you still need to install them on your system so that Vim can make a call to these tools. See &lt;a href=&quot;https://www.python.org/downloads/windows/&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; to get the executable to install python.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In the comments OP also had a question about which version of python (python2 or python3) to install:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here python was needed to make UltiSnips working, as UltiSnips doesn't recommend a specific version I'd recommend to install whatever version you want, both should work. Remember that it is possible to install several version of python on the same system.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-07-22T09:48:40.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8906" PostTypeId="1" AcceptedAnswerId="8914" CreationDate="2016-07-22T09:52:24.990" Score="5" ViewCount="1552" Body="&lt;p&gt;I have a very large file containing about, for example, 5 million lines like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Songs=****, Singers=****&#xA;Singers=***&#xA;Songs=***&#xA;.... # many many lines&#xA;SongType=***&#xA;... # many many lines again&#xA;Album=***, Singers=**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since all characters replaced by &lt;code&gt;*&lt;/code&gt; are Chinese characters I use &lt;code&gt;/[a-zA-Z]*=&lt;/code&gt; to match &quot;Songs&quot;, &quot;Singers&quot;. And I don't know if I've matched the third: &quot;SongType&quot; since I cannot see it using my eyes, let alone the fourth: &quot;Album&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that: can I use a vague pattern, in my case &lt;code&gt;[a-zA-Z]*=&lt;/code&gt; to know all distinct possibilities(of the same pattern)? I mean all the four strings here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course I can use &lt;code&gt;g&lt;/code&gt; command to delete all that matched and see those left. But what if the fifth and others are so rare that I cannot pick them out in the left lines? And in this way the &quot;Album&quot; is deleted and I can never find it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to first copy all matched strings to a register and then &lt;code&gt;sort u&lt;/code&gt; it in an other file to check, but failed because of the register limitation. &lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="1788" LastEditDate="2016-07-22T11:11:49.957" LastActivityDate="2016-07-22T11:52:15.810" Title="How to show all unique types of a pattern?" Tags="|search|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8908" PostTypeId="1" CreationDate="2016-07-22T10:14:52.720" Score="0" ViewCount="230" Body="&lt;p&gt;Coming from non-modal editors, I still get confused with &lt;kbd&gt;e&lt;/kbd&gt;, &lt;kbd&gt;w&lt;/kbd&gt;, &lt;kbd&gt;b&lt;/kbd&gt; in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One feature I like about non-modal editors is jumping words by simply combining &lt;kbd&gt;Ctrl&lt;/kbd&gt; with &lt;kbd&gt;&amp;larr;&lt;/kbd&gt;&lt;kbd&gt;&amp;rarr;&lt;/kbd&gt; arrow. So I thought I just create a Vim equivalent using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;h&lt;/kbd&gt; instead of &lt;kbd&gt;b&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;l&lt;/kbd&gt; instead of &lt;kbd&gt;e&lt;/kbd&gt;. Both in visual and normal mode. It looks like there are no other shortcuts interfering by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to change &lt;code&gt;.vimrc&lt;/code&gt; to map the keys accordingly?&lt;/p&gt;&#xA;" OwnerUserId="6542" LastEditorUserId="6542" LastEditDate="2016-11-16T09:06:13.700" LastActivityDate="2016-11-16T09:06:13.700" Title="Map movement keys to jump words like in non-modal editors" Tags="|key-bindings|cursor-movement|" AnswerCount="1" CommentCount="8" ClosedDate="2016-07-30T14:32:38.953" ContentLicense="CC BY-SA 3.0" />
  <row Id="8909" PostTypeId="1" AcceptedAnswerId="8912" CreationDate="2016-07-22T10:49:15.060" Score="2" ViewCount="1377" Body="&lt;p&gt;Suppose I have the following table:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E   12.02&#xA;T   9.10&#xA;A   8.12&#xA;O   7.68&#xA;I   7.31&#xA;N   6.95&#xA;S   6.28&#xA;R   6.02&#xA;H   5.92&#xA;D   4.32&#xA;L   3.98&#xA;U   2.88&#xA;C   2.71&#xA;M   2.61&#xA;F   2.30&#xA;Y   2.11&#xA;W   2.09&#xA;G   2.03&#xA;P   1.82&#xA;B   1.49&#xA;V   1.11&#xA;K   0.69&#xA;X   0.17&#xA;Q   0.11&#xA;J   0.10&#xA;Z   0.07&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Values are separated by tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to put this table in &lt;em&gt;n&lt;/em&gt; columns of maximum length &lt;em&gt;m&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, for &lt;em&gt;n&lt;/em&gt;=7 (&lt;em&gt;m&lt;/em&gt;=4):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E   12.02   I   7.31    H   5.92    C   2.71    W   2.09    V   1.11    J   0.10&#xA;T   9.10    N   6.95    D   4.32    M   2.61    G   2.03    K   0.69    Z   0.07&#xA;A   8.12    S   6.28    L   3.98    F   2.30    P   1.82    X   0.17&#xA;O   7.68    R   6.02    U   2.88    Y   2.11    B   1.49    Q   0.11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How would I do that?&lt;/p&gt;&#xA;" OwnerDisplayName="user2598" LastActivityDate="2016-07-22T11:38:15.310" Title="Transforming a long table into multiple columns" Tags="|formatting|tab-characters|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8910" PostTypeId="2" ParentId="8908" CreationDate="2016-07-22T10:53:49.470" Score="3" Body="&lt;p&gt;Found a solution. This works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-h&amp;gt; b&#xA;nnoremap &amp;lt;C-l&amp;gt; e&#xA;vnoremap &amp;lt;C-h&amp;gt; b&#xA;vnoremap &amp;lt;C-l&amp;gt; e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6542" LastEditorUserId="6542" LastEditDate="2016-07-23T06:26:53.370" LastActivityDate="2016-07-23T06:26:53.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8911" PostTypeId="2" ParentId="8909" CreationDate="2016-07-22T11:33:27.983" Score="9" Body="&lt;p&gt;If you want to do that in vim you can use the following macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa^V3j$d&quot;_4dd^V3jI&amp;lt;tab&amp;gt;&amp;lt;Esc&amp;gt;Pq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be decomposed like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa          Record the macro in the register a&#xA;^V          Enter visual block mode (use ctrl-v)&#xA;3j$         Select the lines you want to put in a column&#xA;d           Delete them&#xA;&quot;_4dd       Delete the lines which contained the column in the black hole register&#xA;^V          Enter visual block mode again&#xA;3j          Select the lines&#xA;I           Start inserting characters in front of the selection&#xA;&amp;lt;tab&amp;gt;       Insert a tab character&#xA;&amp;lt;esc&amp;gt;       Exit insert mode&#xA;P           Insert the column you previously deleted&#xA;q           Stop recording the macro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use @a as long as you still have lines to put in the columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I would recommend you to use a tool like &lt;code&gt;awk&lt;/code&gt; or &lt;code&gt;split&lt;/code&gt; like @sp asic suggested.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-07-22T11:33:27.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8912" PostTypeId="2" ParentId="8909" CreationDate="2016-07-22T11:35:07.743" Score="3" Body="&lt;p&gt;Using the *nix commands &lt;code&gt;split&lt;/code&gt; and &lt;code&gt;paste&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ split -l 4 ip.txt op ; paste op* &amp;gt; ip.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, from within vim as suggested by OP:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!split -l 4 % /tmp/split; paste /tmp/split* &amp;gt; %; rm /tmp/split*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1616" LastEditorDisplayName="user2598" LastEditDate="2016-07-22T11:38:15.310" LastActivityDate="2016-07-22T11:38:15.310" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8913" PostTypeId="2" ParentId="8904" CreationDate="2016-07-22T11:50:01.727" Score="2" Body="&lt;p&gt;I don't think you have to do that for Pathogen + UltiSnips + vim-snippets.&#xA;I have such setup and only thing in my vimrc is &lt;code&gt;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;c-j&amp;gt;&quot;&lt;/code&gt;. Both plugins are in &lt;code&gt;~/.vim/bundle&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-07-22T11:50:01.727" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8914" PostTypeId="2" ParentId="8906" CreationDate="2016-07-22T11:52:15.810" Score="6" Body="&lt;p&gt;You can do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let b:types=[]&#xA;:%s/[A-Za-z]*\&amp;gt;/\=add(b:types, submatch(0))/ng&#xA;:echo uniq(b:types)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This searches for the pattern &lt;code&gt;/[A-Za-z]*\&amp;gt;&lt;/code&gt; and adds the result to the List variable &lt;code&gt;b:types&lt;/code&gt;. Since we are only interested in the adding the matches to the list, and don't want to change the buffer, we use the &lt;code&gt;n&lt;/code&gt; flag to the &lt;code&gt;:s&lt;/code&gt; command. The &lt;code&gt;g&lt;/code&gt; flag is there, to get all matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now this will populate your list with all matches, so since we are only interested in the uniq entries, we run the &lt;code&gt;uniq()&lt;/code&gt; function on the result again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the &lt;code&gt;uniq()&lt;/code&gt; function is only available with a Vim 7.4.500 or so, so it is relative recent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are further interested in the statistics, you can do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Count(match)&#xA;  if has_key(b:types, a:match)&#xA;      let b:types[a:match]+=1&#xA;  else&#xA;      let b:types[a:match]=1&#xA;  endif&#xA;  return a:match&#xA;endfu&#xA;let b:types={}&#xA;%s/[A-Za-z]*\&amp;gt;/\=Count(submatch(0))/gn&#xA;echo b:types&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will count each match. The output of the &lt;code&gt;b:types&lt;/code&gt; variable might look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{'SongType': 1, 'Songs': 2, 'Singers': 3, 'Album': 1}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-22T11:52:15.810" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8915" PostTypeId="1" AcceptedAnswerId="8917" CreationDate="2016-07-22T14:50:55.440" Score="2" ViewCount="535" Body="&lt;p&gt;I'm thinking about a feature which I think would improve my workflow a lot. I don't know if it already exists..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The feature is about moving the cursor vertically over code blocks without losing its horizontal position in a speedy way. I would regard it as a more convenient alternative for &lt;kbd&gt;{&lt;/kbd&gt; and &lt;kbd&gt;}&lt;/kbd&gt;. Or you could say it would be the vertical equivalent for &lt;kbd&gt;w&lt;/kbd&gt;/&lt;kbd&gt;e&lt;/kbd&gt; and &lt;kbd&gt;b&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I really don't like about &lt;kbd&gt;{&lt;/kbd&gt; and &lt;kbd&gt;}&lt;/kbd&gt; is that I lose the horizontal position of the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior of the feature for moving the cursor should be like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Move the cursor up/down to the next line that is preceded or followed by an empty line. (ignore white spaces)&lt;/li&gt;&#xA;&lt;li&gt;Don't lose the horizontal position of the cursor. If the line is shorter put the cursor on the last position of that line, but remember the position it came from. Even if you hit &lt;kbd&gt;j&lt;/kbd&gt; or &lt;kbd&gt;k&lt;/kbd&gt; afterwards the cursor should maintain its initial horizontal position. (same behavior as &lt;kbd&gt;j&lt;/kbd&gt;/&lt;kbd&gt;k&lt;/kbd&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example for moving down:&lt;/strong&gt;&#xA;(moving up behaves the same, just in the other direction.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;X0&lt;/code&gt; indicates the initial position.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&#xA;AAAAAAAAAAA[X0]AAAAAAA&#xA;AAAAAAAAAAAAA&#xA;AAAAAAAAA[X1]&#xA;&#xA;BBBBBBBBBBB[X2]BBBBBBBBBBBBBBBBBB&#xA;BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB&#xA;BBBBBBBBBBBBBBBBBBB&#xA;BBBBBBBBBBB[X3]BBBBBBBB&#xA;&#xA;CCCCCCCCCCC[X4]CCCCCCCCCCCCCCCCCCCC&#xA;CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC&#xA;CCCCC[X5]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I hit &lt;kbd&gt;k&lt;/kbd&gt; on the last line it would go back to position 11, right under &lt;code&gt;X4&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know of such a feature or do you know how I could create it?&lt;/p&gt;&#xA;" OwnerUserId="6542" LastEditorUserId="6542" LastEditDate="2016-07-22T15:04:47.940" LastActivityDate="2016-07-22T18:17:17.850" Title="Jump cursor vertically over code blocks. Keep horizontal position" Tags="|cursor-movement|cursor-motions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8916" PostTypeId="2" ParentId="8915" CreationDate="2016-07-22T15:08:52.060" Score="0" Body="&lt;p&gt;You can start working from this simple mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap J :let c=col('.') &amp;lt;bar&amp;gt; execute &quot;normal! }k&quot;.c.&quot;&amp;lt;bar&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposition&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let c=col('.')     &quot; save the current column into the variable c&#xA;&amp;lt;bar&amp;gt;               &quot; chain another command&#xA;execute &quot;normal!    &quot; execute a normal command&#xA;}k                  &quot; go to next paragraph and up one line&#xA;c.&quot;&amp;lt;bar&amp;gt;&quot;           &quot; go to the column number `c`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; this won't work without a newline after the paragraph.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-22T15:08:52.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8917" PostTypeId="2" ParentId="8915" CreationDate="2016-07-22T15:55:24.763" Score="4" Body="&lt;p&gt;Here is a small function, that seems to do what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Move(up)&#xA;    let curpos = getcurpos()&#xA;    let firstline='\(^\s*\n\)\zs\S\+'&#xA;    let lastline ='\S\+\ze\n\s*$'&#xA;    let flags = 'Wn'. (a:up ? 'b' : '')&#xA;    &quot; Move to first or last line of paragraph,&#xA;    &quot; or to the beginning/end of file&#xA;    let pat = '\('.firstline.'\|'.lastline.'\)\|\%^\|\%$'&#xA;    &quot; make sure cursor moves and search&#xA;    &quot; does not get stuck on current line&#xA;    call cursor(line('.'), a:up ? 1 : col('$'))&#xA;    let target=search(pat, flags)&#xA;    if target &amp;gt; 0&#xA;        let curpos[1]=target&#xA;        let curpos[2]=curpos[4]&#xA;    endif&#xA;    call setpos('.',curpos)&#xA;endfu&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;j :call Move(0)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;k :call Move(1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This relies on the getcurpos() function, which has been included as patch 7.4.578. If you don't have it, you can use the &lt;code&gt;winsaveview()/winrestview()&lt;/code&gt; function, to work around it. This might however mess up the screen, not sure this will work reliably. (with a newer vim, you can throw away the values in the dictionary returned by &lt;code&gt;winsaveview()&lt;/code&gt; and only update the other values, but that is not possible with older vims as well).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Move(up)&#xA;    let curpos = winsaveview()&#xA;    let firstline='\(^\s*\n\)\zs\S\+'&#xA;    let lastline ='\S\+\ze\n\s*$'&#xA;    let flags = 'Wn'. (a:up ? 'b' : '')&#xA;    &quot; Move to first or last line of paragraph,&#xA;    &quot; or to the beginning/end of file&#xA;    let pat = '\('.firstline.'\|'.lastline.'\)\|\%^\|\%$'&#xA;    &quot; make sure cursor moves and search&#xA;    &quot; does not get stuck on current line&#xA;    call cursor(line('.'), a:up ? 1 : col('$'))&#xA;    let target=search(pat, flags)&#xA;    if target &amp;gt; 0&#xA;        let curpos.lnum=target&#xA;        let curpos.col=curpos.curswant&#xA;    endif&#xA;    call winrestview(curpos)&#xA;endfu&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;j :call Move(0)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;k :call Move(1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2016-07-22T18:17:17.850" LastActivityDate="2016-07-22T18:17:17.850" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8919" PostTypeId="1" AcceptedAnswerId="8922" CreationDate="2016-07-22T19:11:03.930" Score="4" ViewCount="1734" Body="&lt;p&gt;I'm aware of &lt;a href=&quot;https://vi.stackexchange.com/questions/24/how-do-i-reload-my-vimrc-without-leaving-vim&quot;&gt;this question&lt;/a&gt;, but sourcing that way is not the same as restarting Vim.  I want to do that without restarting Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like, if you have &lt;code&gt;set fo+=c&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt; then re-sourcing changes it to something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fo=&amp;lt;default_values&amp;gt;,c,c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I avoid this behavior? Is there any default config inside Vim that I could source before &lt;code&gt;vimrc&lt;/code&gt; to get the same effect as a clean restart?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using neovim.&lt;/p&gt;&#xA;" OwnerUserId="2561" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-07-23T13:09:20.483" Title="How can I reload my .vimrc without appending anything to my current settings?" Tags="|vimrc|neovim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8921" PostTypeId="2" ParentId="8919" CreationDate="2016-07-22T19:37:53.910" Score="4" Body="&lt;p&gt;That is no problem:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:se[t] {option}+={value}&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Add the {value} to a number option, or append&#xA;  the {value} to a string option.  When the option is a comma separated&#xA;  list, a comma is added, unless the value was empty. If the option is a&#xA;  list of flags, superfluous flags are removed.  &lt;strong&gt;When adding a flag that&#xA;  was already present the option value doesn't change&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is described at &lt;code&gt;:h :set+=&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-22T19:37:53.910" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8922" PostTypeId="2" ParentId="8919" CreationDate="2016-07-22T19:39:53.513" Score="5" Body="&lt;p&gt;I have not tried it, and I would not be surprised if it has some unexpected side effects, but you could try to add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set all&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;at the top of your &lt;code&gt;.vimrc&lt;/code&gt; file. This will reset all options to their default setting, cf. &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#:set-&amp;amp;&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :set-&amp;amp;&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, I am not sure how well this will work with respect to plugins. That is, some/many plugins set some vim options, and if you reset all options in your &lt;code&gt;.vimrc&lt;/code&gt; file, and then resource the &lt;code&gt;.vimrc&lt;/code&gt; file, then this might affect one or more of your active plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A workaround might be to parse the output of &lt;code&gt;:scriptnames&lt;/code&gt; and reload each of the loaded scripts in the given order. This should be done after the &lt;code&gt;.vimrc&lt;/code&gt; file has been reloaded, and it should only happen after reloading, not upon restarting.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-07-22T19:39:53.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8923" PostTypeId="2" ParentId="8195" CreationDate="2016-07-22T20:42:29.487" Score="2" Body="&lt;p&gt;If I understand correctly what you want and you want to find those lines, that are unique in one buffer and therefore marked as &quot;DiffAdd&quot; in the other buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, there is no native way to do it using the &lt;code&gt;search()&lt;/code&gt; function, therefore you have to work around it with the following function, that works by searching for a line, that has the &quot;DiffAdd&quot; highlighting.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NextChange()&#xA;    while search('^.*', 'w') &amp;gt; 0&#xA;        if synIDattr(diff_hlID(line('.'),col('.')), 'name') is# 'DiffAdd'&#xA;            break&#xA;        endif&#xA;    endwhile&#xA;endfunction&#xA;com! NextChange :call NextChange()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-22T20:42:29.487" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8924" PostTypeId="1" CreationDate="2016-07-22T21:26:26.223" Score="1" ViewCount="405" Body="&lt;p&gt;I'm actually using i3wmw so I'd like NERDtree, or any other option that works as a file tree to open the selected file in a new instance of vim, instead of in a new tab/buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway to make nerdtree work that way? If not, what other vim script or application would work like that? I'm using arch linux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks! &lt;/p&gt;&#xA;" OwnerUserId="8531" LastEditorUserId="2920" LastEditDate="2016-07-22T21:44:21.843" LastActivityDate="2016-07-22T21:44:21.843" Title="Open file in a new instance of vim from nerdtree" Tags="|linux|plugin-nerdtree|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8926" PostTypeId="1" AcceptedAnswerId="8927" CreationDate="2016-07-23T03:44:52.647" Score="7" ViewCount="4800" Body="&lt;p&gt;I know Vim provides functions to display window's dimensions. But does it also&#xA;provide ways for me to know current buffer/split's dimensions? Like how many lines&#xA;and columns in displable area? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently all I can find online is the information on how to change the split&#xA;width and height rather than obtaining the current dimension. But I don't need&#xA;to change the split size, only need to know its size information to&#xA;organize some material in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: As indicated by @Tommy A in his comment, the reason I have this question&#xA;is that I misunderstood of the terminology. To quote him:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A window is a viewport for a buffer. &quot;Split&quot; is just a verb in Vim. I think&#xA;  you might be mixing up the terminology for windows and buffers. Soft wrapping&#xA;  occurs at winwidth(0) and it's also the the total number of characters that&#xA;  can be displayed horizontally. Hard wrapping occurs at &amp;amp;textwidth. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Hence what I want to do is to show the window dimension, by &lt;code&gt;winwidth(0)&lt;/code&gt; and&#xA;&lt;code&gt;winheight(0)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, as mentioned in Question &lt;a href=&quot;https://stackoverflow.com/questions/26315925/get-usable-window-width-in-vim-script/26318602#26318602&quot;&gt;Get Usable Window Width in Vim&#xA;Script&lt;/a&gt;,&#xA;&lt;code&gt;winwidth(0)&lt;/code&gt; is usually larger than the usable width of the window for the&#xA;content. To obtain the correct size information, please refer to the answer in&#xA;that question.&lt;/p&gt;&#xA;" OwnerUserId="6625" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-07-23T12:48:51.183" Title="Is it possible to obtain the displayable area, width and height of current buffer in Vim?" Tags="|vimscript|buffers|split|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8927" PostTypeId="2" ParentId="8926" CreationDate="2016-07-23T06:06:38.177" Score="12" Body="&lt;p&gt;These are the different ways (that I know of) to get dimensional information from Vim.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Vim&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;amp;columns&lt;/code&gt; and &lt;code&gt;&amp;amp;lines&lt;/code&gt; will give you the total width and height of the screen Vim is displayed in.  These can be changed at runtime, but it's not recommended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;amp;cmdheight&lt;/code&gt; will give you the height of the command line.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Windows&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;winwidth(0)&lt;/code&gt; and &lt;code&gt;winheight(0)&lt;/code&gt; will give you the dimensions for the current window.  It includes the width of the gutter columns, but not the window separator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to get the size as a ratio, you would need to turn one of the values into a float:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let width_ratio = winwidth(0) / str2float(&amp;amp;columns)&#xA;let height_ratio = winheight(0) / str2float(&amp;amp;lines)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Buffers&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you want the total number of lines in a buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let total_lines = line('$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want the number of &lt;em&gt;visible&lt;/em&gt; lines in a buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let visible_lines = line('w$') - line('w0')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;w$&lt;/code&gt; is the bottom line and &lt;code&gt;w0&lt;/code&gt; is the top line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the maximum column from the buffer, you could use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BufferWidth() abort&#xA;  let view = winsaveview()&#xA;  let max_col = 0&#xA;  g/^/let max_col=max([max_col, col('$') - 1])&#xA;  call histdel('search', -1)&#xA;  let @/ = histget('search', -1)&#xA;  call winrestview(view)&#xA;  return max_col&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:global&lt;/code&gt; command is used to get the last column in every line and keep the highest value.  The rest of the function saves/restores the state since &lt;code&gt;:global&lt;/code&gt; moves the cursor and changes the search history.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2016-07-23T12:48:51.183" LastActivityDate="2016-07-23T12:48:51.183" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8928" PostTypeId="2" ParentId="8602" CreationDate="2016-07-23T06:40:20.067" Score="4" Body="&lt;p&gt;Here you can find the source code defining the &lt;code&gt;diffsplit&lt;/code&gt; command: &lt;a href=&quot;https://github.com/vim/vim/blob/7c0a2f367f2507669560b1a66423155c70d2e75b/src/diff.c#L1069-L1106&quot; rel=&quot;nofollow&quot;&gt;vim/vim&lt;/a&gt;, let see what it does:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It set some reference to the old window, as we will create a new one.&lt;/li&gt;&#xA;&lt;li&gt;It disable the tab opening&lt;/li&gt;&#xA;&lt;li&gt;Split the window (create a new window, that where the &lt;code&gt;old_curwin&lt;/code&gt; is useful)&lt;/li&gt;&#xA;&lt;li&gt;Edit the desired file &lt;/li&gt;&#xA;&lt;li&gt;Check that we are on a new window&lt;/li&gt;&#xA;&lt;li&gt;Set the diffs options for the current window&lt;/li&gt;&#xA;&lt;li&gt;Check the old window is still a valid window&lt;/li&gt;&#xA;&lt;li&gt;Set the diffs options for the old window&lt;/li&gt;&#xA;&lt;li&gt;Check the old buffer reference is still valid&lt;/li&gt;&#xA;&lt;li&gt;Change the &lt;strong&gt;line number&lt;/strong&gt; to match the one of the old window.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As you can see, there is nothing in this function that change the cursor from the new window to the original one. I think the official* answer is that &quot;it's by design that you stay on the new window&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, you can, as other answer suggested, use an autocommand to add the &lt;code&gt;switch to original&lt;/code&gt; step, I think it's the best you can do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;* From what I understand, I wont talk for the official Vim maintainers.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Why your autocomand does not work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FilterWritePost * ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it is called from the &lt;code&gt;diffsplit&lt;/code&gt; command, both files will trigger this event (and both files will have the &lt;code&gt;&amp;amp;diff&lt;/code&gt; variable set), you can check that with the following autocommand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd FilterWritePre * if &amp;amp;diff | echomsg expand('%')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think your best solution is still to use a custom command.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have tried to work with the following autocommand events: &lt;code&gt;BufEnter&lt;/code&gt;, &lt;code&gt;BufWinEnter&lt;/code&gt;, &lt;code&gt;OptionSet&lt;/code&gt;, &lt;code&gt;WinEnter&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But none of them gave results, because it gets triggered two times, or because it gets triggered before the buffer has the &lt;code&gt;diff&lt;/code&gt; option set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once more, I think your best solution is to use a custom command.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-07-23T16:22:11.763" LastActivityDate="2016-07-23T16:22:11.763" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8929" PostTypeId="1" CreationDate="2016-07-23T12:30:31.680" Score="1" ViewCount="272" Body="&lt;p&gt;When in vim I try to execute a persistent command, ie &lt;code&gt;alias gh=&quot;history | grep -a cd&quot;&lt;/code&gt; it seems to work at first but then I go to shell and type &lt;code&gt;gh&lt;/code&gt; it says &lt;code&gt;command not found&lt;/code&gt;. Note : I'm in &lt;code&gt;tty&lt;/code&gt; shell, I'd like this to work both in terminal emulator and tty.&lt;/p&gt;&#xA;" OwnerUserId="7005" LastActivityDate="2016-07-23T20:11:29.287" Title="How to execute persistent command from vim to bash?" Tags="|external-command|" AnswerCount="1" CommentCount="5" ClosedDate="2016-07-25T03:49:16.380" ContentLicense="CC BY-SA 3.0" />
  <row Id="8930" PostTypeId="2" ParentId="8929" CreationDate="2016-07-23T20:11:29.287" Score="1" Body="&lt;p&gt;According to POSIX 2008 a shell level &lt;code&gt;alias&lt;/code&gt; shall not affect applications invoked by a shell (only explicit subshells).  Excerpt from &lt;code&gt;man alias&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   An alias definition shall affect the current shell execution environment and the execution environments of the sub‐&#xA;   shells of the current shell. When used as specified by this volume of POSIX.1‐2008, the alias definition shall  not&#xA;   affect  the parent process of the current shell nor any utility environment invoked by the shell; see Section 2.12,&#xA;   Shell Execution Environment.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Therefore Vim will never be able to use a shell alias in a system compliant to POSIX 2008.  I'd solve this with a &lt;code&gt;cabbrev&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cabbrev gh history \| grep -a cd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pipe needs to be escaped because it is the Vim command separator.  Then doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!gh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will perform&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!history | grep -a cd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-07-23T20:11:29.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8931" PostTypeId="1" CreationDate="2016-07-23T22:36:19.737" Score="8" ViewCount="6467" Body="&lt;p&gt;I want to use syntax highlighting for custom C types. Based on my coding convention, types can occur in the following places:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef type1 type2;&#xA;&#xA;(static | extern | register | volatile)? type ...;&#xA;&#xA;(struct | enum | union) type ...;&#xA;&#xA;func(type1 x, type2 x, ...);  // might be a harder case&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't include all the situations, but can already cover probably more than 90% of the usage. It seems to me like just a simple pattern matching problem, but I was a bit frustrated playing with vim syntax script, and couldn't get what I need. For example, I don't know how to match part of the pattern without highlighting the rest. Any ideas how to do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="8536" LastEditorUserId="51" LastEditDate="2016-07-23T23:36:47.360" LastActivityDate="2016-08-08T11:00:09.347" Title="Vim syntax highlighting for custom C types" Tags="|syntax-highlighting|filetype-c|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8932" PostTypeId="1" CreationDate="2016-07-24T09:59:12.640" Score="1" ViewCount="1594" Body="&lt;p&gt;Where can I find a list of all the default &lt;em&gt;vim&lt;/em&gt; key bindings/mappings? Something like this &lt;a href=&quot;http://hea-www.harvard.edu/~fine/Tech/vi.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;alphabetical listing for vi&lt;/a&gt;, but specifically for vim, not vi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can use &lt;code&gt;:map&lt;/code&gt;, &lt;code&gt;:imap&lt;/code&gt;, &lt;code&gt;:nmap&lt;/code&gt;, etc, however these show me the mappings based on my current configuration. I'm aware of &lt;a href=&quot;https://vi.stackexchange.com/questions/6834/how-to-find-out-what-a-key-is-mapped-to&quot;&gt;this question&lt;/a&gt;, but don't believe it to be a duplicate because it is about the current mappings &lt;em&gt;based upon&lt;/em&gt; the user's configuration. I'm specifically looking for the &lt;em&gt;default mappings&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I see the defaults?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-07-28T15:42:56.403" Title="How can I find the list of all of vim's default keybindings?" Tags="|key-bindings|" AnswerCount="0" CommentCount="0" ClosedDate="2016-07-24T12:51:27.607" ContentLicense="CC BY-SA 3.0" />
  <row Id="8933" PostTypeId="2" ParentId="6834" CreationDate="2016-07-24T10:10:06.897" Score="16" Body="&lt;p&gt;It's in the vim help files at &lt;a href=&quot;http://vimhelp.appspot.com/index.txt.html&quot;&gt;&lt;code&gt;:help index&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to know which keys &lt;em&gt;aren't&lt;/em&gt; mapped by default, see &#xA;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#map-which-keys&quot;&gt;&lt;code&gt;:help map-which-keys&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: the above are clickable links to the latest &lt;a href=&quot;http://vimhelp.appspot.com/&quot;&gt;vim reference manual&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2016-07-27T03:12:09.707" LastActivityDate="2016-07-27T03:12:09.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8934" PostTypeId="1" AcceptedAnswerId="8941" CreationDate="2016-07-24T20:30:34.453" Score="2" ViewCount="176" Body="&lt;p&gt;I'm trying to write a &quot;Paste-over&quot; operator. It will work like a combination of &lt;kbd&gt;p&lt;/kbd&gt; and &lt;kbd&gt;R&lt;/kbd&gt;, so it will paste the contents of a register over the text currently in the buffer. I have this so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PasteOver(before)&#xA;  if a:before&#xA;    call feedkeys(&quot;m`&quot;)&#xA;  endif&#xA;&#xA;  call feedkeys(&quot;R&quot;)&#xA;  for i in split(@&quot;, '\zs')&#xA;    call feedkeys(i)&#xA;  endfor&#xA;  call feedkeys(&quot;\&amp;lt;esc&amp;gt;&quot;)&#xA;&#xA;  if a:before&#xA;    call feedkeys(&quot;\&amp;lt;C-o&amp;gt;&quot;)&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;M-p&amp;gt; :&amp;lt;C-u&amp;gt;call PasteOver(0)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;M-P&amp;gt; :&amp;lt;C-u&amp;gt;call PasteOver(1)&amp;lt;cr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it works great. However, I have a dilemma. I'd like this operator to work with registers, the same way that &lt;kbd&gt;p&lt;/kbd&gt; does, e.g. &lt;code&gt;&quot;a&amp;lt;M-p&amp;gt;&lt;/code&gt; will paste over from the contents of register 'a', and have this work with every register. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's two ways I could think of to do this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Write a mapping for every single register. I think it goes without saying that this is a terribly inefficient and sloppy way of doing this. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Make the register argument come &lt;em&gt;after&lt;/em&gt; the operator, so &lt;code&gt;&quot;a&amp;lt;M-p&amp;gt;&lt;/code&gt; would become &lt;code&gt;&amp;lt;M-p&amp;gt;a&lt;/code&gt;. This would work fine, but it makes pasting from the default register less convenient, and I prefer the first way since it feels more natural (since my fingers have already learned &lt;code&gt;&quot;ap&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is there a builtin way to get the register argument to an operator? I'm thinking something like &lt;code&gt;v:count&lt;/code&gt;, but &lt;code&gt;v:register&lt;/code&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-25T09:37:14.770" Title="How can I define an operator that takes a register as an argument?" Tags="|key-bindings|vimscript|cut-copy-paste|replace|register|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8935" PostTypeId="1" CreationDate="2016-07-24T23:07:01.773" Score="1" ViewCount="3992" Body="&lt;p&gt;I'm new to iTerm and vim and have been trying to follow readme at: &lt;a href=&quot;https://github.com/chriskempson/base16-shell&quot; rel=&quot;nofollow&quot;&gt;https://github.com/chriskempson/base16-shell&lt;/a&gt; to try to get a theme to work in iTerm2/vim. The theme will only run if I chmod it and run it first then go to vim from there. On startup, iTerm will revert to the default theme in profiles. I have in &lt;code&gt;~/.config/base16-shell/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;base16-shell.png&#xA;colortest&#xA;profile_helper.sh&#xA;scripts&#xA;setting-256-colourspace-not-supported.png&#xA;templates&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run colortest it doesn't pass the test specified at the bottom of the page &lt;a href=&quot;https://github.com/chriskempson/base16-shell&quot; rel=&quot;nofollow&quot;&gt;https://github.com/chriskempson/base16-shell&lt;/a&gt;. However, from there I go in &lt;code&gt;/scripts&lt;/code&gt; and run &lt;code&gt;base16-ocean.sh&lt;/code&gt;, the theme is run, and from there if I run colortest again it passes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let base16colorspace=256&#xA;colorscheme base16-ocean&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8546" LastActivityDate="2017-05-20T14:02:22.730" Title="How to install base16 for iTerm2?" Tags="|colorscheme|iterm2|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8936" PostTypeId="1" AcceptedAnswerId="8954" CreationDate="2016-07-25T04:22:41.883" Score="5" ViewCount="913" Body="&lt;p&gt;I'm trying to write a plugin that highlights overused words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After much effort I managed to write a function (and a command, &lt;code&gt;:Ditto&lt;/code&gt;) that will highlight the most used word in the file or in a specific range. So I can select a paragraph and call that function and the most frequent word in that paragraph will be highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/danielbmarques/vim-ditto/blob/master/plugin/ditto.vim&quot; rel=&quot;nofollow&quot;&gt;This is the result of that first attempt&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to be able to call that function/command once for every paragraph in the file. So instead of selecting each paragraph and calling it I'd be able to do it just once and the most frequent word in each paragraph would be highlighted in that paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I go about that?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;PS: Any other ideas/suggestions/recommendations are more than welcome. I know nearly nothing about vimscript. Also it would be great if besides running the function once for each paragraph the plugin could do it once per sentence and maybe other scopes… and after that I hope to be able to cycle through the most used words, so I could see the second most used word, then the third, and so on. I thought I'd start with my current problem, which is just running that function once for each paragraph, but if anybody can help with the rest that would be awesome too. Thanks! :)&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="7642" LastEditDate="2016-07-26T20:44:38.567" LastActivityDate="2016-07-28T13:29:37.557" Title="Run a function once on every paragraph" Tags="|vimscript|regular-expression|highlight|global-command|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8937" PostTypeId="2" ParentId="8935" CreationDate="2016-07-25T05:14:08.777" Score="5" Body="&lt;p&gt;You have to run the script when your shell starts and it has to be ran from the &lt;code&gt;base16-vim&lt;/code&gt; color scheme, &lt;a href=&quot;https://github.com/chriskempson/base16-shell#shells&quot; rel=&quot;nofollow noreferrer&quot;&gt;which is tersely documented&lt;/a&gt; in &lt;code&gt;base16-shell&lt;/code&gt;.  But, you don't want to use that script.  It'll just create more confusion later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;base 16&quot; colors are the 8 standard colors + 8 brighter variants of those colors.  &lt;code&gt;base16&lt;/code&gt;'s themes treat them as 16 &lt;em&gt;distinct&lt;/em&gt; colors instead.  All shell programs that use color expect these colors to be what's labeled below, but have no idea what the &lt;em&gt;actual&lt;/em&gt; color is on your screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/skMu1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/skMu1.png&quot; alt=&quot;colors&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;base16&lt;/code&gt; is fine if you're using a profile dedicated to Vim.  Otherwise, you will get non-obvious results if you use other programs that have no awareness of this.  For instance, if a program only uses the basic 8 colors and wants to display &quot;bright green&quot;, it'll show up on your screen as a very dark gray, which won't be visible if you have a black background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your terminal supports palette customization (it does), the &lt;code&gt;base16-shell&lt;/code&gt; script allows you to keep the standard 8 colors + 8 bright variants, but at the cost of changing five of the the &lt;a href=&quot;https://commons.wikimedia.org/wiki/File:Xterm_256color_chart.svg&quot; rel=&quot;nofollow noreferrer&quot;&gt;216 color palette&lt;/a&gt;.  In the &lt;code&gt;base16&lt;/code&gt; Vim colorscheme, it will use colors &lt;code&gt;0-7&lt;/code&gt; and &lt;code&gt;17-21&lt;/code&gt;, instead of &lt;code&gt;0-15&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Colors &lt;code&gt;17-21&lt;/code&gt; are shades of blue, which is shown in the troubleshooting section of the &lt;a href=&quot;https://github.com/chriskempson/base16-shell#troubleshooting&quot; rel=&quot;nofollow noreferrer&quot;&gt;README&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wK5wv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wK5wv.png&quot; alt=&quot;blues&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Colors &lt;code&gt;16-231&lt;/code&gt; are a fixed set of colors and programs that use this palette expect these colors to be constant.  So, you'll also get unexpected results if &lt;code&gt;17-21&lt;/code&gt; are used by anything other than Vim, which again, is fine if you are fully aware of this and use a separate profile just for Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This was a clever approach, but IMO, gives little guidance to users and is far too much effort to alter a well established palette to get a pretty color scheme.  For a little bit less effort, you can get the latest build of Vim (v7.4.1799+) or Neovim (v0.1.5 [dev]) and use the &lt;code&gt;termguicolors&lt;/code&gt; setting to use the &lt;code&gt;#rrggbb&lt;/code&gt; GUI colors instead since iTerm2 supports truecolor.  Then you wouldn't be limited to 256 colors and can use &lt;em&gt;any&lt;/em&gt; of the &lt;code&gt;base16-vim&lt;/code&gt; color schemes without screwing up the shell's colors.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="12700" LastEditDate="2017-05-20T14:02:22.730" LastActivityDate="2017-05-20T14:02:22.730" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8938" PostTypeId="1" CreationDate="2016-07-25T06:56:54.623" Score="1" ViewCount="64" Body="&lt;p&gt;Is there a way to target the set of lines changed in the previous command? Say I do a search and replace, bulk indent, or some other command that affects either a series or  scattered collection of lines. Next, I want to run a command that targets those lines only. Is there a range shortcut or other motion command to target the previous action?&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="7161" LastEditDate="2016-07-25T07:46:39.430" LastActivityDate="2016-07-28T13:41:55.337" Title="Act on lines changed by previous command" Tags="|cursor-motions|range|object-motions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8939" PostTypeId="1" CreationDate="2016-07-25T08:07:05.220" Score="0" ViewCount="272" Body="&lt;p&gt;I came across a vim plugin called &lt;a href=&quot;https://github.com/dkprice/vim-easygrep&quot; rel=&quot;nofollow&quot;&gt;EasyGrep&lt;/a&gt; and so far it has been great however i wanted to know if it was possible to search only the buffer you are in and if possible specify the path you would like to grep ? &lt;/p&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="51" LastEditDate="2016-08-25T15:44:32.253" LastActivityDate="2017-02-21T18:53:25.307" Title="EasyGrep plugin - is there a way to search only the current buffer" Tags="|plugin-easygrep|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8940" PostTypeId="2" ParentId="8939" CreationDate="2016-07-25T08:49:17.400" Score="2" Body="&lt;p&gt;You can use the &lt;code&gt;%&lt;/code&gt; for defining the path you are searching through: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:grep pattern %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a more generic way, after the pattern, you can specify the path you want to search in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:grep pattern **/*.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on the grep program you use, you may need to adjust this but it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;code&gt;:h grep&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-25T08:49:17.400" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8941" PostTypeId="2" ParentId="8934" CreationDate="2016-07-25T09:37:14.770" Score="4" Body="&lt;p&gt;You can use &lt;code&gt;v:register&lt;/code&gt; to grab the name of the last register supplied&#xA;to a command, &lt;code&gt;getreg()&lt;/code&gt; to grab its contents, and &lt;code&gt;&amp;lt;c-r&amp;gt;=&lt;/code&gt; to insert text from a register when in&#xA;insert (or replace) mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;m-p&amp;gt; R&amp;lt;c-r&amp;gt;=getreg(v:register)&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;&#xA;nnoremap &amp;lt;m-P&amp;gt; R&amp;lt;c-r&amp;gt;=getreg(v:register)&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;`[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;`[&lt;/code&gt; to jump to the beginning of the last changed text.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-07-25T09:37:14.770" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8942" PostTypeId="1" AcceptedAnswerId="8943" CreationDate="2016-07-25T19:00:09.060" Score="5" ViewCount="2681" Body="&lt;p&gt;When you execute the shell in &lt;code&gt;vim&lt;/code&gt; via the &lt;code&gt;:sh&lt;/code&gt; command, the shell that is set in the &lt;code&gt;shell&lt;/code&gt; option is executed. However, is it possible to pass some information from the vim instance that you are running to the invoked shell?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course that would be easily doable if you could alter the &lt;code&gt;shell&lt;/code&gt; option to have some environment variables prepended to it (e.g. &lt;code&gt;a=foo b=bar /usr/bin/bash&lt;/code&gt;). However that doesn't seem to be possible. Is there some other way?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="2920" LastEditDate="2016-07-25T19:38:52.603" LastActivityDate="2016-09-19T02:08:42.787" Title="How to export information from vim to bash" Tags="|external-command|bash|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8943" PostTypeId="2" ParentId="8942" CreationDate="2016-07-25T19:47:38.160" Score="7" Body="&lt;p&gt;You can set or modify an environment variable in Vim like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let $MY_ENV = 'coconuts!'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Child processes inherit the parent process's environment, so this is available when you start a new shell process with &lt;code&gt;:sh&lt;/code&gt; (which is a child of the vim process:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sh&#xA;&#xA;$ echo $MY_ENV&#xA;coconuts!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It also works with NeoVim's &lt;code&gt;:terminal&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:terminal&#xA;&#xA;$ echo $MY_ENV&#xA;coconuts!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3alet%2d%24&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :let-$&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-09-19T02:08:42.787" LastActivityDate="2016-09-19T02:08:42.787" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8944" PostTypeId="1" CreationDate="2016-07-25T20:47:49.913" Score="3" ViewCount="4675" Body="&lt;p&gt;How can I remap the ctags hotkeys?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main hotkeys are &lt;code&gt;Ctrl-]&lt;/code&gt; to jump to a definition, &lt;code&gt;Ctrl-t&lt;/code&gt; to go back, then there are also commands, for example &lt;code&gt;:ts&lt;/code&gt; lists the definitions for the last tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than using the vulcan nerve pinches, I was thinking I might remap these commands to leader keys. But am not sure exactly how to do this. I know how to do regular mappings, but have not mapped plugin hotkeys before. Do I just do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Ctrl-]&amp;gt; &amp;lt;leader-a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or something like that? How do I remap the ex commands?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2019-04-06T05:54:32.130" Title="Mapping ctags keys" Tags="|key-bindings|ctags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8945" PostTypeId="2" ParentId="8936" CreationDate="2016-07-25T21:26:47.340" Score="2" Body="&lt;p&gt;Ok, with some help from @Tumbler41 I arrived at this pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(^\n\|\%1l\)\s*\S\_.\{-}\n$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which seems to match paragraphs exactly, even when they're right at the start or right at the end of a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now I can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\(^\n\|\%1l\)\s*\S\_.\{-}\n$/execute &quot;normal! vap:MyCommand\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it'll run that command once for every paragraph. The only caveat is that it won't work with &lt;code&gt;vip&lt;/code&gt;, only with &lt;code&gt;vap&lt;/code&gt;, because the match starts at at the new line right before a paragraph, so that line is all that gets selected with &lt;code&gt;vip&lt;/code&gt;. I tried to fix that by adding &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; to the pattern, but it doesn't work properly when I run it with global (using &lt;code&gt;normal vipd&lt;/code&gt; as a command, for instance), I don't know why. If anyone can fix that I'll gladly accept their answer. :)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: Since I'm using &lt;code&gt;vap&lt;/code&gt; anyway I changed the pattern to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(^\n\|\%1l\).\_.\{-}\n$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's a breakdown:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The match must start with an empty line (&lt;code&gt;^\n&lt;/code&gt;) or the first line (&lt;code&gt;\%1l&lt;/code&gt;) (so it'll match the first paragraph even if there's no new line before it)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then there must be anything except a new line (&lt;code&gt;.&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then there must be absolutely anything (&lt;code&gt;\_.&lt;/code&gt;) as many times as necessary up until (&lt;code&gt;\{-}&lt;/code&gt;) a new line (&lt;code&gt;\n&lt;/code&gt;) and the end of a line (&lt;code&gt;$&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\s*\S&lt;/code&gt; part was necessary because otherwise, if a file had many empty lines one after the other, the pattern would find matches starting on each of those blank lines (doing &lt;code&gt;n&lt;/code&gt; would stop at each one), and my command would run many times on the same paragraph. The &lt;code&gt;\s*&lt;/code&gt; would match white spaces so the paragraph could be indented, and then there had to be anything but a white space &lt;code&gt;\S&lt;/code&gt; to make sure it wasn't another empty line right after that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A blank line isn't the same as an empty line though, and that pattern wouldn't match a paragraph that had a blank line (besides the empty line) right before it, so I changed that part to &lt;code&gt;.&lt;/code&gt; (anything but a new line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also that &lt;code&gt;\n\n&lt;/code&gt; at the end wouldn't match a paragraph that ends right at the end of the file, without any lines below it, but &lt;code&gt;\n$&lt;/code&gt; does.&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="7642" LastEditDate="2016-07-26T10:02:44.883" LastActivityDate="2016-07-26T10:02:44.883" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8946" PostTypeId="2" ParentId="8944" CreationDate="2016-07-25T21:28:03.937" Score="7" Body="&lt;p&gt;There are q few misconceptions here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;Hotkey&quot; is not a thing in Vim. You have &quot;commands&quot;, &quot;mappings&quot;, &quot;abbreviations&quot;… but no &quot;hotkeys&quot;. &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-t&amp;gt;&lt;/code&gt; and &lt;code&gt;:tselect&lt;/code&gt; are all &quot;commands&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There's no such thing as &quot;leader keys&quot;. You can create and use &quot;leader&quot; mappings that use the &quot;leader key&quot;, if you want, but there's nothing special with them.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Ex commands are not &quot;mappings&quot; so you can't &quot;remap&quot; them.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now, what's wrong with your mapping?&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The order:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's supposed to be &lt;code&gt;{map command} {what you want to press} {what you want to happen}&lt;/code&gt; but you did &lt;code&gt;{map command} {what you want to happen} {what you want to press}&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The key notation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You used &lt;code&gt;&amp;lt;Ctrl-]&amp;gt;&lt;/code&gt; instead of the correct &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;leader-a&amp;gt;&lt;/code&gt; instead of the correct &lt;code&gt;&amp;lt;leader&amp;gt;a&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is what your mapping should look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;a &amp;lt;C-]&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to create a &quot;leader mapping&quot; for &lt;code&gt;:ts&lt;/code&gt; you can do it like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;s :tselect&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help key-notation&lt;/code&gt; and &lt;code&gt;:help mapping&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="51" LastEditDate="2019-04-06T05:54:32.130" LastActivityDate="2019-04-06T05:54:32.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8947" PostTypeId="1" CreationDate="2016-07-25T22:50:52.080" Score="1" ViewCount="119" Body="&lt;p&gt;I have found &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#netrw-externapp&quot; rel=&quot;nofollow&quot;&gt;fairly clear documentation&lt;/a&gt; on the usage and customization of &lt;code&gt;netrw&lt;/code&gt;, but a perusal of the plugin source code shows only method-level comments, and does not give a good indication of the places one needs to modify to add a new protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does there exist documentation for people attempting to implement new remote protocols?&lt;/p&gt;&#xA;" OwnerUserId="1750" LastActivityDate="2016-07-25T22:50:52.080" Title="Is there any documentation available on the internals of netrw?" Tags="|netrw|plugin-system|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8948" PostTypeId="1" CreationDate="2016-07-25T23:59:53.413" Score="1" ViewCount="275" Body="&lt;p&gt;I'm trying to write a plugin to highlight overused words in a file. After &lt;a href=&quot;https://vi.stackexchange.com/q/8936/7642&quot;&gt;this question&lt;/a&gt; I now have a way to highlight the most frequent words in each paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To restrict the highlighting of a word to a single paragraph I'm using &lt;code&gt;matchadd&lt;/code&gt; with a line range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matchadd('Error', word . '\%&amp;gt;' . (a:firstline - 1) . 'l\%&amp;lt;' . (a:lastline + 1) . 'l')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that if the user adds or removes a line in the middle of a file it messes up the highlighting of the following lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I keep the highlighting up to date after changes in the file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first thought is to just clear the previous matches and highlight everything all over again when a line is added or removed. Is there no better way to do it? If there isn't, how can I detect if a line was added or removed so I can clear the matches and add them again?&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-07-27T05:34:31.440" Title="Keep matchadd and matchaddpos up to date after file changes" Tags="|vimscript|highlight|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8949" PostTypeId="1" CreationDate="2016-07-26T00:10:27.423" Score="11" ViewCount="1183" Body="&lt;p&gt;I'm trying to define a macro which quickly generates a list of random-ish words.&lt;br&gt;&#xA;I want the macro to turn this into a list like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&#xA;b&#xA;c&#xA;d&#xA;e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arezzo&#xA;bywords&#xA;czars&#xA;détente&#xA;eyrie&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I have so far:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;put cursor on letter &lt;code&gt;a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;start recording macro &lt;code&gt;qq&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&lt;/code&gt; enter insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-k&amp;gt; - perform dictionary completion on the character before cursor - in this case the letter&lt;/code&gt;a`&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; select the last item in the completion list that appears, on my system its the word &lt;code&gt;arezzo&lt;/code&gt;. (N.B. I have &lt;code&gt;longest&lt;/code&gt; included in my &lt;code&gt;'completeopt'&lt;/code&gt; setting, which is required for &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; to work in this way during completion: &lt;code&gt;'set completeopt=longest,menuone,preview'&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt; accept the completion&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^[^[&lt;/code&gt; exit insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; move down to the next line, ready to do the same operation on the next line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; stop recording&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;when I create the macro and go through the steps manually, everything works fine, however when I execute the macro, I see a message flashing in the command line something like:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;scanning dictionary file&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and nothing happens, of the commands in the macro only &lt;code&gt;j&lt;/code&gt; is run, i.e. the cursor moves down the line, but none of the completion commands run.&lt;br&gt;&#xA;Is it possible to use insert mode completions in a macro, and if so, how can I do it?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="343" LastEditDate="2017-11-13T11:47:47.730" LastActivityDate="2017-11-14T16:53:28.907" Title="How can I use insert mode completion in a macro?" Tags="|autocompletion|macro|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8950" PostTypeId="1" AcceptedAnswerId="8959" CreationDate="2016-07-26T06:39:52.107" Score="2" ViewCount="1092" Body="&lt;p&gt;My settings for shell are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shell=powershell\ -ExecutionPolicy\ Unrestricted\ -NoProfile\ -NoLogo\ -NonInteractive&#xA;set shellcmdflag=-Command &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when i'm using that, I'm getting following error&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;E97: Cannot create diffs&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I revert back to default windows shell (cmd) that's working fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to set shell in diffexpr function, but got an error on calling diff.exe (I haven't found error message).&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="1821" LastEditDate="2016-07-26T06:44:52.467" LastActivityDate="2016-07-26T13:57:00.197" Title="vim diff isn't working while my shell is powershell" Tags="|vim-windows|vimdiff|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8951" PostTypeId="1" CreationDate="2016-07-26T07:04:13.233" Score="1" ViewCount="158" Body="&lt;p&gt;In a vim buffer, I want to insert the path to a file named &lt;code&gt;blablabla\barbar-Überbar\bazbazbaz.txt&lt;/code&gt; which exists under the current working directory - and I am running gvim in a MS-Windows environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I type &lt;code&gt;ibla&lt;/code&gt; (to insert &lt;code&gt;bla&lt;/code&gt; in the buffer) then &lt;code&gt;ctrl-x ctrl-f&lt;/code&gt;. Vim expands to &lt;code&gt;blablabla\&lt;/code&gt;. I further type &lt;code&gt;bar&lt;/code&gt; and then &lt;code&gt;ctrl-x ctrl-f&lt;/code&gt;. Vim expands to &lt;code&gt;foofoofoo\barbar-Überbar\&lt;/code&gt;. I type &lt;code&gt;baz&lt;/code&gt; (so the text reads &lt;code&gt;foofoofoo\barbar-Überbar\baz&lt;/code&gt; and the cursor is immediatly after &lt;code&gt;baz&lt;/code&gt;) and use &lt;code&gt;ctrl-x ctrl-f&lt;/code&gt; again. This time, vim won't expand the path as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, however, the path contains a lowercase &lt;code&gt;ü&lt;/code&gt; instead of the uppercase cousin, it will expand as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I assume that support for the uppercase U Umlaut is broken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone verify my assumption?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: BTW, on Linux, it seems to work fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit II&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, my vimrc sets &lt;code&gt;encoding&lt;/code&gt; to &lt;code&gt;utf8&lt;/code&gt;. If I change the encoding to &lt;code&gt;latin1&lt;/code&gt; the whole completion mechanism seems to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;However&lt;/em&gt;, I cannot change the encoding to &lt;code&gt;latin1&lt;/code&gt; as I have many utf-8 files I am editing, and they are then displayed very wierdly.&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="51" LastEditDate="2016-07-26T17:20:48.357" LastActivityDate="2016-07-26T17:20:48.357" Title="Is Vim's filename completion broken in Windows when using uppercase u umlaute (Ü)?" Tags="|microsoft-windows|unicode|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8952" PostTypeId="1" AcceptedAnswerId="8953" CreationDate="2016-07-26T07:54:16.807" Score="0" ViewCount="134" Body="&lt;p&gt;When vim sources a file (&lt;code&gt;vimrc&lt;/code&gt;, or &lt;code&gt;:so ...&lt;/code&gt;), how does it know in what encoding the file was written? Can I specify the encoding with which it should source the file?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="51" LastEditDate="2016-07-26T17:20:53.030" LastActivityDate="2016-07-26T17:20:53.030" Title="Can I specify the encoding of a sourced file?" Tags="|unicode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8953" PostTypeId="2" ParentId="8952" CreationDate="2016-07-26T08:05:43.897" Score="1" Body="&lt;p&gt;Vim has a built-in option for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'encoding'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's by default &quot;latin1&quot; or the value of the environment variable &lt;code&gt;$LANG&lt;/code&gt; (e.g. in my case &lt;code&gt;:echo $LANG&lt;/code&gt; returns &lt;code&gt;en_US.UTF-8&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The value of encoding is derived from &lt;code&gt;$LANG&lt;/code&gt;, not taken verbatim. &lt;code&gt;en_US.UTF-8&lt;/code&gt; would give you &lt;code&gt;utf-8&lt;/code&gt;. (credits to @romainl)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can control this value like any other option in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note that in the case of your &lt;code&gt;vimrc&lt;/code&gt;, you cannot take advantage of the modeline for setting this option. As said in the doc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This option cannot be set from a modeline.  It would most likely&#xA;corrupt the text.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also have a look at the different encoding options proposed in Vim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h scriptencoding&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h 'encoding'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h 'fileencoding'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h 'termencoding'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-07-26T08:30:05.797" LastActivityDate="2016-07-26T08:30:05.797" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8954" PostTypeId="2" ParentId="8936" CreationDate="2016-07-26T10:43:05.047" Score="1" Body="&lt;p&gt;With the following command (for testing):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! -range MyCom &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt; s/^/&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;: /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can pass each paragraph in a buffer to &lt;code&gt;MyCom&lt;/code&gt; with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/\v.(\n\n|\n*%$)/ '{,. MyCom&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It searches for the last line of a paragraph, then uses from&#xA;the previous paragraph mark to that point as the range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll get a single leading blank line as part of the&#xA;paragraph though (if there is one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To have a function handle a range, append the &lt;code&gt;range&lt;/code&gt; keyword to the definition (e.g. &lt;code&gt;function Foo() range&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it's called with a range (e.g. &lt;code&gt;:1,5 call Foo()&lt;/code&gt;) it will be invoked once, rather than once for each line. You also have access to the magic arguments &lt;code&gt;a:firstline&lt;/code&gt; and &lt;code&gt;a:lastline&lt;/code&gt; within the function body so you can handle the range yourself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help a:firstline&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-07-28T13:29:37.557" LastActivityDate="2016-07-28T13:29:37.557" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8955" PostTypeId="1" AcceptedAnswerId="12108" CreationDate="2016-07-26T10:47:54.983" Score="5" ViewCount="651" Body="&lt;p&gt;I'm looking for a ChatScript language Syntax highlighting, of course for the Vim editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/bwilcox-1234/ChatScript&quot; rel=&quot;nofollow noreferrer&quot;&gt;ChatScript&lt;/a&gt; is a great (underrated) open-source language to build chatbots dialog flows scripts, made by &lt;a href=&quot;https://en.wikipedia.org/wiki/Bruce_Wilcox&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bruce Wilcox&lt;/a&gt;. But it seems to me that doesn't yet exist any syntax support for Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, There is already a splendid syntax package for sublime text editor, see for possible inspiration:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://packagecontrol.io/packages/ChatScript%20Syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://packagecontrol.io/packages/ChatScript%20Syntax&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kuzyn/chatscript-tmlanguage&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kuzyn/chatscript-tmlanguage&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uwpvY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uwpvY.png&quot; alt=&quot;chatscript example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is: there is someone already created a syntax highlighting .vim file for ChatScript ? Or want to do a github project with me to share as open source a chatscript.vim syntax file ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Premising I'm beginner on vim scripting (for syntax highlighting), any suggestion to how to proceed ? Is &lt;a href=&quot;http://vim.wikia.com/wiki/Creating_your_own_syntax_files&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; a good start ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&#xA;Anyone know if there is any &quot;tmLanguage or CSON&quot; converter to .vim syntax highlighting file (if so I could just convert work done &lt;a href=&quot;https://github.com/kuzyn/chatscript-tmlanguage/blob/master/grammars/ChatScript.cson&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&#xA;giorgio&lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="51" LastEditDate="2016-07-26T17:21:06.407" LastActivityDate="2018-06-29T15:00:28.433" Title="Vim syntax highlighting for ChatScript language?" Tags="|vimscript|syntax-highlighting|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8956" PostTypeId="2" ParentId="8955" CreationDate="2016-07-26T11:08:21.217" Score="4" Body="&lt;p&gt;You can search for vim plugins at &lt;a href=&quot;http://www.vim.org/scripts/script_search_results.php?keywords=chatscript&amp;amp;script_type=&amp;amp;order_by=rating&amp;amp;direction=descending&amp;amp;search=search&quot; rel=&quot;nofollow&quot;&gt;Vim.org&lt;/a&gt;, which used to be the official repository. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But nowadays many people store their plugins directly at github and doesn't provide a link no Vim.org. Fortunately there is &lt;a href=&quot;http://vimawesome.com/about&quot; rel=&quot;nofollow&quot;&gt;Vim Awesome&lt;/a&gt;, which attempts to gather all the information about Vim plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a quick search it seems there is no syntax highlight plugin for this language; but it is not hard to write one at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to the wiki link you mentioned and the &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/45.html&quot; rel=&quot;nofollow&quot;&gt;great book (Learn Vimscript the Hard Way)&lt;/a&gt; mentioned by @nobe4, you should definitively check the explanation at &lt;a href=&quot;http://vimhelp.appspot.com/usr_44.txt.html&quot; rel=&quot;nofollow&quot;&gt;:help usr_44&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vim comes with highlighting for a couple of hundred different file types.  If&#xA;the file you are editing isn't included, read this chapter to find out how to&#xA;get this type of file highlighted.  Also see |:syn-define| in the reference&#xA;manual.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you already have the syntax highlight plugin for another editors, it will probably be a matter of translating it to Vim format. Usually the part that takes more time is writing the regular expressions; but in this case you could just translate them with the aid of &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27incsearch%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;'incsearch'&lt;/code&gt;&lt;/a&gt; and  &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27hlsearch%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;'hlsearch'&lt;/code&gt;&lt;/a&gt; options, and the descriptions at &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help pattern&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you succeed you should consider including it at vim.org :)&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-07-26T11:08:21.217" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8958" PostTypeId="1" AcceptedAnswerId="8960" CreationDate="2016-07-26T13:20:31.000" Score="4" ViewCount="379" Body="&lt;p&gt;Is there an easy way to align a function documentation (I'm using Python) from this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arg1 :: Some text&#xA;&#xA;arg2345 :: Some very long text text text text&#xA;&#xA;arg3:: Other text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arg1    :: Some text&#xA;&#xA;arg2345 :: Some very long text text &#xA;           text text&#xA;&#xA;arg3    :: Other text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the second argument is wrapped by a maximum number of columns (I'm using a maximum of 80 columns). I'm used to align with &lt;code&gt;gqip&lt;/code&gt; but that formats a whole paragraph. I tried recording some movements but it gets complex, I was wondering if there was a better way to do this.&lt;/p&gt;&#xA;" OwnerUserId="4623" LastActivityDate="2016-07-26T14:36:34.673" Title="Align code functions documentation" Tags="|alignment|string-manipulation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8959" PostTypeId="2" ParentId="8950" CreationDate="2016-07-26T13:57:00.197" Score="2" Body="&lt;p&gt;Every time you receive an error from Vim, you can use lookup the documentation for more information. In this case, &lt;code&gt;:help E97&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *E810* *E97*&#xA;Vim will do a test if the diff output looks alright.  If it doesn't, you will&#xA;get an error message.  Possible causes:&#xA;-  The &quot;diff&quot; program cannot be executed.&#xA;-  The &quot;diff&quot; program doesn't produce normal &quot;ed&quot; style diffs (see above).&#xA;-  The 'shell' and associated options are not set correctly.  Try if filtering&#xA;   works with a command like &quot;:!sort&quot;.&#xA;-  You are using 'diffexpr' and it doesn't work.&#xA;If it's not clear what the problem is set the 'verbose' option to one or more&#xA;to see more messages.&#xA;&#xA;The self-installing Vim for MS-Windows includes a diff program.  If you don't&#xA;have it you might want to download a diff.exe.  For example from&#xA;http://gnuwin32.sourceforge.net/packages/diffutils.htm.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Based on that explanation you could try:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Ensure that you have the diff program on powershell. Maybe by changing the default shell you prevent Vim from reaching the diff program it installs on Windows (as stated in the last paragraph)&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Check all shell related options. From &lt;code&gt;:help 'shell'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'shell' 'sh'        string  (default $SHELL or &quot;sh&quot;,&#xA;                    MS-DOS and Win32: &quot;command.com&quot; or&#xA;                    &quot;cmd.exe&quot;, OS/2: &quot;cmd&quot;)&#xA;            global&#xA;    Name of the shell to use for ! and :! commands.  When changing the&#xA;    value also check these options: 'shelltype', 'shellpipe', 'shellslash'&#xA;    'shellredir', 'shellquote', 'shellxquote' and 'shellcmdflag'.&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Try using the &lt;code&gt;'verbose'&lt;/code&gt; option (or the &lt;code&gt;:10verbose &amp;lt;cmd&amp;gt;&lt;/code&gt; command) to find what is the string Vim is trying to pass to the command line. Then you could try to call that line directly on your shell, where it would be easier to debug it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-07-26T13:57:00.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8960" PostTypeId="2" ParentId="8958" CreationDate="2016-07-26T14:14:02.453" Score="4" Body="&lt;p&gt;Vim's comment formatting only handles&#xA;comment characters that appear at the&#xA;start of the line. However you could make&#xA;use of the list formatting facility (&lt;code&gt;:help 'formatlistpat'&lt;/code&gt;)&#xA;that kicks in when &lt;code&gt;n&lt;/code&gt; is in &lt;code&gt;'formatoptions'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, define an appropriate pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set flp=^.*::\\s\\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(You may need to adjust this: I don't speak Python.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then add &lt;code&gt;n&lt;/code&gt; to &lt;code&gt;'formatoptions'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set fo+=n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;gqq&lt;/code&gt; on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arg2345 :: Some very long text text text text asfd asdf asd fas fdasd fasd fas fdas fdsa fdas df sad asdf adsf asdf asdf as dfa sdfa sdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;code&gt;:set tw=40&lt;/code&gt; for demonstration purposes, will result in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arg2345 :: Some very long text text text&#xA;           text asfd asdf asd fas fdasd&#xA;           fasd fas fdas fdsa fdas df&#xA;           sad asdf adsf asdf asdf as&#xA;           dfa sdfa sdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But you also want to align the &lt;code&gt;::&lt;/code&gt; markers. &#xA;If you don't mind picking a column position to align on (not a bad idea: it enforces consistency and doesn't let really long argument names produce silly indentation),&#xA;you can use a substitute that uses an expression&#xA;as the replacement part (&lt;code&gt;:help sub-replace-expression&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v(.*)\s*\ze::/\=submatch(0).repeat(' ',13-len(submatch(1)))/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running this on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arg1 :: Some text&#xA;arg2345 :: Some text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will produce:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arg1         :: Some text&#xA;arg2345      :: Some text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adjust &lt;code&gt;13&lt;/code&gt; to taste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can put it all together with a &lt;code&gt;:global&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/::/ s/\v(.*)\s*\ze::/\=submatch(0).repeat(' ',13-len(submatch(1)))/ | norm!gqq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running it on a buffer with these contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arg1 :: Some text&#xA;&#xA;arg2345 :: Some very long text text text text asfd asdf asd fas fdasd fasd fas fdas fdsa fdas df sad asdf adsf asdf asdf as dfa sdfa sdf&#xA;&#xA;Don't touch me! Don't touch me! Don't touch me! Don't touch me! Don't touch me!&#xA;&#xA;arg3:: Other text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;produces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arg1         :: Some text&#xA;&#xA;arg2345      :: Some very long text text&#xA;                text text asfd asdf asd&#xA;                fas fdasd fasd fas fdas&#xA;                fdsa fdas df sad asdf&#xA;                adsf asdf asdf as dfa&#xA;                sdfa sdf&#xA;&#xA;Don't touch me! Don't touch me! Don't touch me! Don't touch me! Don't touch me!&#xA;&#xA;arg3         :: Other text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes that &lt;code&gt;/::/&lt;/code&gt; is enough to identify a documentation line. You might want to tighten this up.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-07-26T14:36:34.673" LastActivityDate="2016-07-26T14:36:34.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8961" PostTypeId="1" AcceptedAnswerId="8963" CreationDate="2016-07-26T16:18:50.530" Score="8" ViewCount="1201" Body="&lt;p&gt;When wrapping text in GVim, the wrap occurs at the right side of the GVim window. I would prefer to have it wrap at column 80 however. A solution I have found is to &lt;code&gt;:set columns=80&lt;/code&gt;, but this shrinks the window and gives me a kind of claustrophobic feeling. Therefore I was wondering whether anyone knows a way to wrap the text at a fixed column, without modifying the file on disk and without modifying the GVim window size. A fixed size blank space on the right of the screen would also work, but would not have my preference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it makes a difference: I'm mainly using GVim 7.4 on a Windows machine.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2016-07-26T16:37:35.923" Title="soft linewrap width" Tags="|gvim|wrapping|" AnswerCount="2" CommentCount="1" ClosedDate="2021-09-24T11:47:34.897" ContentLicense="CC BY-SA 3.0" />
  <row Id="8962" PostTypeId="2" ParentId="8961" CreationDate="2016-07-26T16:37:06.100" Score="3" Body="&lt;p&gt;Unfortunately, this is not possible. There are many many ways to configure how a wrap should occur, such as with &lt;code&gt;textwidth&lt;/code&gt; and &lt;code&gt;wrapmargin&lt;/code&gt;, but these are only for hardwraps, not softwraps. The only way to change a softwrap is by changing your window size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some plugins that &lt;em&gt;sort of&lt;/em&gt; do what you want, where the wrap occurs in an area smaller than your window. There is &lt;a href=&quot;https://github.com/mikewest/vimroom&quot; rel=&quot;nofollow&quot;&gt;mikewest/vimroom&lt;/a&gt; and &lt;a href=&quot;https://github.com/junegunn/goyo.vim&quot; rel=&quot;nofollow&quot;&gt;junegunn/goyo.vim&lt;/a&gt;, but for both of these, a smaller softwrap is mainly just a side-effect of the main purpose of the plugin: To declutter your vim window and remove distractions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An ugly workaround could be to open a split and resize it to column 80, but this hardly feels like an ideal solution. (Especially since the location of the split will change when you resize your window)&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-26T16:37:06.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8963" PostTypeId="2" ParentId="8961" CreationDate="2016-07-26T16:37:35.923" Score="3" Body="&lt;p&gt;One non-Ideal solution is open another window and then set the vertical res to 80. The command would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnew | wincmd p | vertical res 80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know this isn't &lt;em&gt;quite&lt;/em&gt; what you had in mind, but it's better than nothing.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-07-26T16:37:35.923" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8964" PostTypeId="1" CreationDate="2016-07-26T18:58:42.897" Score="2" ViewCount="144" Body="&lt;p&gt;Recently, &lt;a href=&quot;https://github.com/lervag/vimtex/issues/436#issuecomment-234905144&quot; rel=&quot;nofollow&quot;&gt;someone noticed&lt;/a&gt; a strange behaviour with indenting during formatting with my LaTeX plugin, &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow&quot;&gt;vimtex&lt;/a&gt;. I've researched it, and I've ended up creating a minimal example. Load the following code as a minimal vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set indentexpr=MyIndent()&#xA;&#xA;function! MyIndent()&#xA;  let l:nprev = prevnonblank(v:lnum - 1)&#xA;  if l:nprev == 0 | return 0 | endif&#xA;&#xA;  let l:cur = getline(v:lnum)&#xA;  let l:prev = getline(l:nprev)&#xA;&#xA;  let l:indent  = max([Count(l:prev, '(') - Count(l:prev, ')'), 0])&#xA;  let l:indent -= max([Count(l:cur, ')') - Count(l:cur, '('),   0])&#xA;&#xA;  return indent(l:nprev) + &amp;amp;sw*l:indent&#xA;endfunction&#xA;&#xA;function! Count(line, pattern)&#xA;  let sum = 0&#xA;  while 1&#xA;    if match(a:line, a:pattern, 0, sum + 1) == -1&#xA;      return sum&#xA;    endif&#xA;    let sum += 1&#xA;  endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the above minimal vimrc file, load the following text into a buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Therefore, in that case the observed dynamics cannot be truly&#xA;Markovian. We can still approximately capture the observed density dynamics&#xA;with eq.~\ref{eq:fpe}; however the local coefficients are then effectively&#xA;averages over the co-evolving unobserved distribution. For example, $\vec&#xA;v(\vec x,t)=\int p(\vec x^u|\vec x,t)v(\vec x,\vec x^u,t)dx^u$. This has some&#xA;important consequences. First, the effective Markovian coefficients $\vec v,&#xA;\lambda, D$, will generally depend on time, reflecting the time evolution of&#xA;the hidden $p(\vec x^u)$ over the time scale of the experiment. Second, the&#xA;effective coefficients may also depend on the initial condition: a cell&#xA;population started concentrated around label $\vec x_0$ implies a certain&#xA;distribution over $x^u$ when sampled at label $\vec x$ some time later; another&#xA;population started around $\vec x_1$ carries a different history when it, too,&#xA;visits $\vec x$ later. Therefore, for instance the effective drift $\vec v(\vec&#xA;x)$ will be different in the two cases. We conclude that, if unobserved degrees&#xA;of freedom have dynamics on the time scale of the experiment eq.~\ref{eq:fpe}&#xA;is an approximation whose coefficients become \emph{non-universal} (dependent&#xA;on intial conditions) and \emph{time-dependent}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now do &lt;code&gt;gg=G&lt;/code&gt;, as expected, the indentation does not change. However, if we instead do &lt;code&gt;gggwG&lt;/code&gt;, it ends up indenting and reformatting the last 4 lines. I've found that while formatting with &lt;code&gt;gw&lt;/code&gt;, the &lt;code&gt;getline()&lt;/code&gt; function does not return the expected lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: Does anyone understand this behaviour? I suspect it might be an error or bug in Vim, and will submit it as a bug report, unless someone here has an explanation.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-07-26T19:34:40.390" Title="Can someone explain the strange behaviour with indenting during reformatting?" Tags="|indentation|formatting|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8966" PostTypeId="2" ParentId="8936" CreationDate="2016-07-26T20:47:47.037" Score="0" Body="&lt;p&gt;I already answered this question with one approach to solve it, and @Antony's answer is very nice too, but I kept looking around and thought of another possibility that looks even better to me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\(^\n\|\%1l\)\_s*\zs\S\_.\{-}\ze\n$/execute &quot;normal! gN:MyCommand\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That pattern seems to perfectly match just the text of each paragraph, and then &lt;code&gt;gN&lt;/code&gt; visually selects each match and runs the command with it. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;At first I was trying this with &lt;code&gt;gn&lt;/code&gt;, but most of the time it seems to select two paragraphs, even if te pattern matches just one. If I do &lt;code&gt;/\(^\n\|\%1l\)\_s*\zs\S\_.\{-}\ze\n$&lt;/code&gt; and go like &lt;code&gt;gggn&amp;lt;esc&amp;gt;ngn&amp;lt;esc&amp;gt;ngn&amp;lt;esc&amp;gt;ngn&amp;lt;esc&amp;gt;&lt;/code&gt;, each gn usually selects more than one paragraph and sometimes even more, I don't know why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;gN&lt;/code&gt;, on the other hand, that command seems to work perfectly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: Uhm, I found a problem with this. If the paragraphs aren't indented, the command won't be run on the last one, I don't know why. It looks like the match has to start after the first character in the paragraph for some reason, or the last paragraph won't match…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to work around that I can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\(^\n\|\%1l\).\zs\_.\{-}\ze\n$/execute &quot;normal! gNV:MyCommand\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The match starts after the first character but then the selection is turned into linewise visual mode with &lt;code&gt;V&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It still works, but now it's getting a little confusing, so I'm not sure if this is the best option anymore.&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="7642" LastEditDate="2016-07-26T22:21:00.747" LastActivityDate="2016-07-26T22:21:00.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8967" PostTypeId="2" ParentId="8948" CreationDate="2016-07-26T21:29:26.570" Score="0" Body="&lt;p&gt;After looking into &lt;code&gt;:h autocmd-events&lt;/code&gt; for a bit I came up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:lastline = 0&#xA;&#xA;function! MyAutoFunction()&#xA;    if line('$') != s:lastline&#xA;        &quot; Clear previous matches&#xA;        &quot; Add matches back&#xA;        let s:lastline = line('$')&#xA;    endif&#xA;endfunction&#xA;&#xA;au TextChanged,TextChangedI * call MyAutoFunction()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it seems to work pretty well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anybody has a better idea, I'm all ears. :)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="7642" LastEditDate="2016-07-27T05:34:31.440" LastActivityDate="2016-07-27T05:34:31.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8968" PostTypeId="2" ParentId="8942" CreationDate="2016-07-27T00:53:12.283" Score="2" Body="&lt;p&gt;Carpetsmoker's solution is probably more useful if you want to keep the same environment variable around long-term, but if you wanted to do this in a single line, you could use ! to execute the external shell, and pass it whatever you want.  I'm a Linux hacker, so I can't say how well this will behave in Windows or OS X, but an example in my environment would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! FOO=abc bash &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would execute bash with $FOO set to 'abc'.  &lt;/p&gt;&#xA;" OwnerUserId="8560" LastActivityDate="2016-07-27T00:53:12.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8970" PostTypeId="2" ParentId="8948" CreationDate="2016-07-27T03:29:42.843" Score="1" Body="&lt;p&gt;I also have the same issue in my plugin, &#xA;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4932&quot; rel=&quot;nofollow&quot;&gt;diffchar.vim&lt;/a&gt;.&#xA;This plugin highlights the exact diff units with matchadd/matchaddpos&#xA;and tries to interactively update those highlights while editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My approach is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;always record which lines are highlighted&lt;/li&gt;&#xA;&lt;li&gt;get TextChanged/TextChangedI events&lt;/li&gt;&#xA;&lt;li&gt;get the post-edit contents of highlighted lines&lt;/li&gt;&#xA;&lt;li&gt;do 'undo'&lt;/li&gt;&#xA;&lt;li&gt;get the pre-edit contents of highlighted lines&lt;/li&gt;&#xA;&lt;li&gt;do 'redo'&lt;/li&gt;&#xA;&lt;li&gt;compare between pre and post to find which lines are changed&lt;/li&gt;&#xA;&lt;li&gt;clear highlights of changed line and then draw them &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since I do not think it is perfect, I am still looking for a better approach :-).&lt;/p&gt;&#xA;" OwnerUserId="1641" LastActivityDate="2016-07-27T03:29:42.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8971" PostTypeId="1" AcceptedAnswerId="8979" CreationDate="2016-07-27T04:49:08.563" Score="1" ViewCount="597" Body="&lt;p&gt;My vim version is &quot;huge&quot; without GUI. Nevertheless, it is missing a lot of features like clipboard and python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get a more full-featured version? I read that there is a version vim-nox which has a lot features. Is it as simple as &lt;code&gt;apt-get install vim-nox&lt;/code&gt;? If I do such an install does it overwrite my current version?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="6952" LastEditDate="2016-07-27T10:31:45.130" LastActivityDate="2016-07-27T15:11:30.080" Title="How can I get more features?" Tags="|os-clipboard|vimscript-python|version|linux-debian|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8972" PostTypeId="1" AcceptedAnswerId="8975" CreationDate="2016-07-27T06:44:59.510" Score="6" ViewCount="11897" Body="&lt;p&gt;I want to select a color scheme in gVim such that it's used always (i. e. if I select color scheme X, close gVim, and start it again, it should start with X as the color scheme, not the default one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/30bY0.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/30bY0.png&quot; alt=&quot;Screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just selecting the color scheme (see menu in the screenshot above) doesn't help.&lt;/p&gt;&#xA;" OwnerUserId="8524" LastActivityDate="2022-07-14T23:43:37.140" Title="How to save color scheme in gVim between sessions?" Tags="|gvim|colorscheme|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8973" PostTypeId="2" ParentId="4474" CreationDate="2016-07-27T07:05:05.973" Score="0" Body="&lt;p&gt;I use terminal Vim on Cygwin Mintty with both using solarized scheme on Windows. I've got the same problem and found a workaround which is not perfect but might be suitable for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal was to copy syntax highlighted code to E-Mails and documents. For this to achieve, I don't have to generate HTML. I configured Mintty terminal to copy rich text:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Right-Click the title&lt;/li&gt;&#xA;&lt;li&gt;Options...&lt;/li&gt;&#xA;&lt;li&gt;Mouse&lt;/li&gt;&#xA;&lt;li&gt;Select 'Copy as rich text'&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As I use the solarized dark scheme in Vim, I paste the content to other applications and remove the background color there. The result looks fine:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VIM with solarized dark scheme:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u9GY3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u9GY3.png&quot; alt=&quot;VIM with solarized dark scheme&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pasted to MS Word with background color removed manually:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jL19X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jL19X.png&quot; alt=&quot;Pasted to MS Word with background color removed manually&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, with this solution, you lose the ability to Vim-select the text. This brings problems with splits and line numbers. But you can close all splits and remove the line numbers using &lt;code&gt;:set nonumber&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8580" LastEditorUserId="1821" LastEditDate="2016-07-27T07:36:12.797" LastActivityDate="2016-07-27T07:36:12.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8974" PostTypeId="1" AcceptedAnswerId="8980" CreationDate="2016-07-27T07:11:07.410" Score="0" ViewCount="1480" Body="&lt;p&gt;I have just started using vim. Due to that I don't instinctively hit the &lt;kbd&gt;x&lt;/kbd&gt;/&lt;kbd&gt;X&lt;/kbd&gt; key to backspace. This causes me problems as the backspace key moves you over as if you were hitting &lt;kbd&gt;h&lt;/kbd&gt; in command mode. I wanted  to know if there was a way I could disable this so that in command mode the backspace button does nothing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried looking this up online and I found this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On some Linux systems, pressing backspace in xterm or uxterm will move&#xA;  the cursor left (without deleting the character). To fix, add:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;xterm.*backarrowKey: false&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;To your .Xresources file and run:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;xrdb -merge ~/.Xresources&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;credit: &lt;a href=&quot;http://vim.wikia.com/wiki/Backspace_and_delete_problems&quot; rel=&quot;nofollow&quot;&gt;http://vim.wikia.com/wiki/Backspace_and_delete_problems&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it did not change anything.&#xA;I am running vim on the command line in Bunson labs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help you can give me would be great.&lt;/p&gt;&#xA;" OwnerUserId="8582" LastEditorUserId="2920" LastEditDate="2016-07-27T16:54:11.373" LastActivityDate="2016-07-27T16:54:11.373" Title="How To Disable Backspace in normal mode" Tags="|key-bindings|vimrc|cursor-movement|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8975" PostTypeId="2" ParentId="8972" CreationDate="2016-07-27T07:36:23.543" Score="9" Body="&lt;p&gt;In Vim, settings are saved across sessions by writing them in an init script called &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;On Windows, that &lt;code&gt;vimrc&lt;/code&gt; is supposed to be at:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$HOME\_vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or (if HOME is not defined):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;C:\Users\yourlogin\_vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;On Unix at:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$HOME/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The installer may or may not have created that file for you, so you'll have to create if it doesn't exist. Do &lt;code&gt;:echo $HOME&lt;/code&gt; in Vim to know where to create that directory and that file.&lt;/p&gt;&#xA;&lt;p&gt;To save your colorscheme choice, add this line to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme slate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/romainl/idiomatic-vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;this document&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="23502" LastEditDate="2022-07-13T23:56:34.153" LastActivityDate="2022-07-13T23:56:34.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8976" PostTypeId="1" AcceptedAnswerId="8978" CreationDate="2016-07-27T08:23:10.413" Score="6" ViewCount="651" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;noreferrer&quot;&gt;ctrlpvim/ctrlp.vim&lt;/a&gt; to open files by fuzzy search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get the full path of the searched file and insert it under cursor, instead of opening it?&lt;/p&gt;&#xA;" OwnerUserId="3302" LastActivityDate="2016-07-27T11:27:02.970" Title="Is there a way to insert a path of the file instead of opening it with CtrlP plugin?" Tags="|plugin-ctrlp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8977" PostTypeId="2" ParentId="8976" CreationDate="2016-07-27T09:08:53.073" Score="2" Body="&lt;p&gt;This is &lt;s&gt;really&lt;/s&gt; hacky, but it worked for me, if you source this mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;pf :let @p=expand(&quot;%&quot;)&amp;lt;CR&amp;gt;:tabclose&amp;lt;CR&amp;gt;&quot;pp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;put your cursor where you want the filename to be put&lt;/li&gt;&#xA;&lt;li&gt;use &lt;kbd&gt;Ctrl + p&lt;/kbd&gt;, as normal to find your file, then open the file in a new tab&lt;br&gt;&#xA;(open a file in a new tab from inside Ctrl-p is &lt;kbd&gt;Ctrl + t&lt;/kbd&gt;)&lt;/li&gt;&#xA;&lt;li&gt;run my leader mapping &lt;code&gt;&amp;lt;Leader&amp;gt;pf&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;the mapping will assign the file that Ctrl-p opened to the &lt;code&gt;p&lt;/code&gt; register, close the tab and paste the &lt;code&gt;p&lt;/code&gt; register where your cursor was.&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2016-07-27T09:08:53.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8978" PostTypeId="2" ParentId="8976" CreationDate="2016-07-27T11:27:02.970" Score="7" Body="&lt;p&gt;You can customize the function handling the opening of files, as explained at &lt;code&gt;:help 'g:ctrlp_open_func'&lt;/code&gt;.&#xA;You could try something similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CtrlPOpenFunc(action, line)&#xA;   if a:action =~ '^h$'    &#xA;      &quot; Get the filename&#xA;      let filename = fnameescape(fnamemodify(a:line, ':p'))&#xA;&#xA;      &quot; Close CtrlP&#xA;      call ctrlp#exit()&#xA;      call ctrlp#mrufiles#add(filename)&#xA;&#xA;      &quot; insert the contents of filename into the buffer&#xA;      put =filename&#xA;   else    &#xA;      &quot; Use CtrlP's default file opening function&#xA;      call call('ctrlp#acceptfile', [a:action, a:line])&#xA;&#xA;   endif&#xA;endfunction&#xA;&#xA;let g:ctrlp_open_func = { &#xA;         \ 'files': 'CtrlPOpenFunc',&#xA;         \ 'mru files': 'CtrlPOpenFunc' &#xA;         \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;, in order to insert the file path by pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;x&lt;/kbd&gt; in the Ctrlp window.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-07-27T11:27:02.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8979" PostTypeId="2" ParentId="8971" CreationDate="2016-07-27T14:23:43.103" Score="4" Body="&lt;p&gt;If you want more features (and something more up to date than whats in the apt packages), you have to compile it yourself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You say you are on Debian, and all these should work on that platform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will first want to clone the repo and remove any existing vim installations. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/vim/vim.git&#xA;&#xA;sudo apt-get remove --purge vim*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, you want to install the headers that you will need for a basic vim installation. This might not be a comprehensive list, but it works for me. If you get errors in the compilation you should be able to find what packages you still need via a quick google search. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install  libncurses5-dev libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, you want to install the headers for any features you are planning to use. Here, I am using python, ruby, and perl.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install python-dev ruby-dev libperl-dev&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, cd into your directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd vim/src&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Run the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make distclean&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, you need to select what features you want. You can look at the &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/Makefile&quot; rel=&quot;nofollow&quot;&gt;makefile source&lt;/a&gt; for more information about how to do this. To see a list of available features, you can look at &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/feature.h&quot; rel=&quot;nofollow&quot;&gt;feature.h&lt;/a&gt;. I suggest setting the options like I do below instead of manually messing with comments in the makefile and feature.h. I feel it makes it easier to change your configuration. It's worth noting that features=huge should include both the clipboard and xterm=clipboard features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run this command: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure \&#xA;            --with-compiledby=f41lurizer\&#xA;            --with-features=huge \&#xA;            --enable-rubyinterp \&#xA;            --enable-largefile \&#xA;            --disable-netbeans \&#xA;            --enable-multibyte\&#xA;            --enable-python3-interp\&#xA;            --enable-pythoninterp \&#xA;            --with-python-config-dir=/usr/lib/python2.7/config \&#xA;            --enable-perlinterp \&#xA;        --enable-gui=auto \&#xA;            --enable-fail-if-missing \&#xA;            --enable-cscope &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, simply do a:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make &#xA;sudo make install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you should be good to go, assuming there are no errors.&lt;/p&gt;&#xA;" OwnerUserId="2757" LastEditorUserId="2757" LastEditDate="2016-07-27T15:11:30.080" LastActivityDate="2016-07-27T15:11:30.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8980" PostTypeId="2" ParentId="8974" CreationDate="2016-07-27T15:20:51.243" Score="3" Body="&lt;p&gt;I think you mean you want to remap backspace in normal mode, not command mode. You can do this using &lt;code&gt;:nnoremap &amp;lt;backspace&amp;gt; &amp;lt;nop&amp;gt;&lt;/code&gt;. 'nnoremap' allows you to remap keys in normal mode, &lt;code&gt;&amp;lt;backspace&amp;gt;&lt;/code&gt; indicates the backspace key and &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; indicates that it should do nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you're new to Vim, I would like to point out that you enter these commands in Vim (just press all the keys in the code sections consecutively on your keyboard). The key will be remapped until you close Vim. If you want to permanently disable to key you could add this command as a line to your .vimrc. If you seriously want to start using Vim, I can highly recommend the &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt;. It covers the basics of Vim script (the language used to customize Vim) and gives you a good overview of the extend to which Vim can be customized. It is a pretty long read though. In general, I have also found the help system of Vim to be very good. Have a look at &lt;code&gt;:help :nnoremap&lt;/code&gt; for more info on remapping for example.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastEditorUserId="8061" LastEditDate="2016-07-27T15:27:06.807" LastActivityDate="2016-07-27T15:27:06.807" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8981" PostTypeId="1" AcceptedAnswerId="8982" CreationDate="2016-07-27T16:46:00.537" Score="6" ViewCount="9328" Body="&lt;p&gt;If I purge my existing vim-full installation and install a GUI version like vim-gnome or vim-gtk, can I still use it in the text mode I am familiar with?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if I am using it from a terminal via SSH? How does the gui mode interact with a terminal-based user?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen the gui version of Vim referred to as &quot;gvim&quot;. Does that mean you start it with the command &lt;code&gt;gvim&lt;/code&gt; instead of &lt;code&gt;vim&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="51" LastEditDate="2016-08-07T14:46:02.183" LastActivityDate="2016-08-07T14:46:02.183" Title="Can I still use console vim if I install a GUI version?" Tags="|gvim|installing|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8982" PostTypeId="2" ParentId="8981" CreationDate="2016-07-27T17:04:57.350" Score="10" Body="&lt;p&gt;&lt;strong&gt;Yes.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim-gnome does install gvim, but it also installs a much more feature-filled version of command line vim, including &lt;a href=&quot;https://askubuntu.com/a/281972/289381&quot;&gt;Perl, Python, Ruby, and TCL scripting&lt;/a&gt;, system-clipboard, newer patches, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So not only can you continue to use command line vim, you will get a better version of command line vim along with the GUI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for SSH editing, I don't believe anything will change for you. I personally have never used vim to edit over SSH, but according to &lt;a href=&quot;http://linuxblog.pansapiens.com/2008/07/13/edit-remote-files-over-ssh-scp-using-gvim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt;, you can edit remote files from directly within gvim with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e scp://username@someremotehost/./path/to/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even if that doesn't work, your original command line vim will be the same, so (assuming you can edit through SSH now) you could just choose to use command line vim instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, yes the GUI version is called &quot;gvim&quot;, and can be launched either with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help -g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *-g*&#xA;-g      Start Vim in GUI mode.  See |gui|. For the opposite see |-v|.&#xA;        {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and from &lt;code&gt;:help gui-start&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. Starting the GUI             *gui-start* *E229* *E233*&#xA;&#xA;First you must make sure you actually have a version of Vim with the GUI code&#xA;included.  You can check this with the &quot;:version&quot; command, it says &quot;with xxx&#xA;GUI&quot;, where &quot;xxx&quot; is X11-Motif, X11-Athena, Photon, GTK, GTK2, etc., or&#xA;&quot;MS-Windows 32 bit GUI version&quot;.&#xA;&#xA;How to start the GUI depends on the system used.  Mostly you can run the&#xA;GUI version of Vim with:&#xA;    gvim [options] [files...]&#xA;&#xA;The X11 version of Vim can run both in GUI and in non-GUI mode.  See&#xA;|gui-x11-start|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.647" LastActivityDate="2016-07-27T17:15:20.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8983" PostTypeId="2" ParentId="8981" CreationDate="2016-07-27T17:05:09.857" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;can I still use it in the text mode I am familiar with?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, you can still use the terminal version of vim.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How does the gui mode interact with a terminal-based user?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you SSH into a machine and run vim there, you won't be able to use the GUI unless you have some setup for remote desktop. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Does that mean you start it with the command gvim instead of vim?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Actually using the GUI version (which is indeed executed with &lt;code&gt;gvim&lt;/code&gt; or &lt;code&gt;vim -g&lt;/code&gt;) is entirely optional. I never use the GUI, except for text files from the web browser. But I'd still recommend installing the GUI version because it will allow you to access the clipboard which is very handy (I.e. &lt;code&gt;&quot;+yy&lt;/code&gt; to copy the current line to the X11 clipboard which you can paste into any other application).&lt;/p&gt;&#xA;" OwnerUserId="6337" LastActivityDate="2016-07-27T17:05:09.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8984" PostTypeId="1" AcceptedAnswerId="8987" CreationDate="2016-07-27T23:33:26.023" Score="5" ViewCount="212" Body="&lt;p&gt;I just started using ycm with clang-completer, which apparently can also do syntax checking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It instantly reminded me why I avoided syntax checking in gVim: As soon as an error is found, the signs appear on the left in an extra column. By doing so they shift the window to the right to make place for the characters of the sign.&#xA;As soon as I correct the error and it was just a single error in the file, the signs disappear and with it the sign column.&#xA;This can become quite flashy, see the gif&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5T2uu.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5T2uu.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make it steady, so that the sign column stays, and just he signs disappear?&#xA;I found the :sing unplace but don't know how to NOT execute it. Or maybe expand beforehand and don't expand anymore when signs are added?&lt;/p&gt;&#xA;" OwnerUserId="8595" LastEditorUserId="8595" LastEditDate="2016-07-28T00:29:34.753" LastActivityDate="2016-07-28T07:02:10.820" Title="Make column for signs permanent in gVim" Tags="|gvim|plugin-you-complete-me|signs|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8985" PostTypeId="1" AcceptedAnswerId="8986" CreationDate="2016-07-28T01:09:32.130" Score="-2" ViewCount="1697" Body="&lt;p&gt;While doing a fun vim exercise I ran into an odd redraw problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap goo :execute ':call GoogleIt(&quot;' . input(&quot;What would you like to google?: &quot;) . '&quot;)'&amp;lt;cr&amp;gt;&#xA;&#xA;function GoogleIt(content)&#xA;        silent execute &quot;!ggl &quot; . a:content &#xA;        redraw&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Silent works, but the redraw function only redraws the first line of the file that I was working in. Any suggestions or answers?&lt;/p&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="2695" LastEditDate="2016-07-28T14:41:37.480" LastActivityDate="2016-07-31T00:22:28.880" Title="How to redraw vim after a function call to the commandline" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8986" PostTypeId="2" ParentId="8985" CreationDate="2016-07-28T02:14:26.333" Score="4" Body="&lt;p&gt;Very simple fix, simply add an &lt;code&gt;!&lt;/code&gt;.&#xA;Change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent execute &quot;!ggl &quot; . a:content &#xA;        redraw&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent execute &quot;!ggl &quot; . a:content &#xA;        redraw!&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help redraw&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When ! is included it is cleared first.&lt;/p&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="2695" LastEditDate="2016-07-31T00:22:28.880" LastActivityDate="2016-07-31T00:22:28.880" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8987" PostTypeId="2" ParentId="8984" CreationDate="2016-07-28T04:11:58.337" Score="3" Body="&lt;p&gt;You can do what some plugins do and create a dummy sign:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sign define Dummy&#xA;autocmd VimEnter,SessionLoadPost,BufRead * execute 'sign place 97349278 line=9999 name=Dummy buffer='.bufnr('%')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All this does is creates an empty sign on line &lt;code&gt;9999&lt;/code&gt;, which should be far enough from valid lines in a file you actually want to see signs in.  It has to be set on a far off line since only one sign can occupy a line at a time.  &lt;code&gt;97349278&lt;/code&gt; is an ID for the sign, which I got by mashing the keyboard.  All that matters is that it's unique.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't use YCM, but it might have an option to use a dummy sign.  It may also remove your dummy sign, in which case, you'll have to look in its source to see how it can be prevented.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-07-28T04:11:58.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8988" PostTypeId="1" AcceptedAnswerId="8989" CreationDate="2016-07-28T05:33:22.380" Score="5" ViewCount="59" Body="&lt;p&gt;This is a newbie's question, so please be patient if I do not use the right terms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can use &quot;.&quot; to redo my last edit operation. But, is there a way to redo the one just before that?&lt;/p&gt;&#xA;" OwnerUserId="5919" LastActivityDate="2016-07-28T06:34:46.087" Title="Redo earlier edit operation" Tags="|undo-redo|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8989" PostTypeId="2" ParentId="8988" CreationDate="2016-07-28T06:34:46.087" Score="5" Body="&lt;p&gt;Unfortunately, this feature is not possible in vim right now. Although it's apparently a popular request, as many people have &lt;a href=&quot;https://unix.stackexchange.com/questions/36719/repeat-the-nth-last-command-in-vim&quot;&gt;asked&lt;/a&gt; the &lt;a href=&quot;https://www.reddit.com/r/vim/comments/2mniws/does_vim_have_a_last_edit_history_eg_3_to_redo/&quot; rel=&quot;nofollow noreferrer&quot;&gt;same thing&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did find this &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_use/CZ8KYt1i9BM&quot; rel=&quot;nofollow noreferrer&quot;&gt;discussion&lt;/a&gt; from two years ago on the vim mailing group. Bram Moolenaar (The founder, inventor, head developer, and current maintainer of vim) chimed in, and mentioned the possibility of a function &lt;code&gt;keyhistory(n)&lt;/code&gt; where &lt;code&gt;n&lt;/code&gt; is how far back to look. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Plugins having to install a lot of maps to be able to know what was &#xA;  typed before the key that triggers an action is clumsy. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;How about Vim keeping a list of the last N typed keys? &#xA;  Suppose there is a function keyhistory(1), where the argument is how far &#xA;  back you look. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;I wonder how that would be used in a plugin. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So while &lt;em&gt;theoretically&lt;/em&gt; this feature might be eventually implemented, I wouldn't hold your breath. The best alternative would be to use a macro as &lt;a href=&quot;https://vi.stackexchange.com/questions/8988/redo-earlier-edit-operation#comment15568_8988&quot;&gt;romainl suggested.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-07-28T06:34:46.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8990" PostTypeId="2" ParentId="8984" CreationDate="2016-07-28T07:02:10.820" Score="4" Body="&lt;p&gt;Apart from the hack with adding a dummy sign (which is what most sign plugins do), there is nothing that can be done. If that bothers you, cheer at vim-dev, that my &lt;a href=&quot;https://groups.google.com/forum/#!msg/vim_dev/CrBId6DRbvo/RafV2hAQUGkJ&quot; rel=&quot;nofollow&quot;&gt;patch&lt;/a&gt; gets integraged. (Als available as issue &lt;a href=&quot;https://github.com/vim/vim/issues/117&quot; rel=&quot;nofollow&quot;&gt;117&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-28T07:02:10.820" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8992" PostTypeId="1" AcceptedAnswerId="8997" CreationDate="2016-07-28T07:26:45.947" Score="3" ViewCount="621" Body="&lt;p&gt;When I use &lt;code&gt;zt&lt;/code&gt; to scroll the screen relative to the cursor and then switch buffers with, say, &lt;code&gt;:bn&lt;/code&gt; followed by &lt;code&gt;:bN&lt;/code&gt;, the screen jumps back to the position before executing &lt;code&gt;zt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using for example &lt;code&gt;ctrl-d&lt;/code&gt; to scroll in the buffer doesn't have this side effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I keep the cursor &amp;amp; screen position when using the &lt;code&gt;z&lt;/code&gt;-family of commands and toggling between buffers?&lt;/p&gt;&#xA;" OwnerUserId="6357" LastActivityDate="2016-07-28T09:30:36.130" Title="How to keep the screen position from &quot;zt&quot; after switching buffer" Tags="|buffers|scrolling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8993" PostTypeId="1" AcceptedAnswerId="9049" CreationDate="2016-07-28T07:40:20.243" Score="3" ViewCount="470" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/lervag/vimtex/wiki/usage#default-mappings&quot; rel=&quot;nofollow&quot;&gt;vimtex&lt;/a&gt; lists some commands like &lt;code&gt;ie&lt;/code&gt; to be entered in mode &lt;code&gt;nxo&lt;/code&gt;. How do I do that? What is mode &lt;code&gt;nxo&lt;/code&gt;? (Usually &lt;code&gt;i&lt;/code&gt; brings me into insert mode, and &lt;code&gt;e&lt;/code&gt; then just inserts an &lt;code&gt;e&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="8598" LastActivityDate="2016-08-02T13:16:17.597" Title="How to enter commands starting with i" Tags="|insert-mode|normal-mode|plugin-vimtex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8994" PostTypeId="2" ParentId="8993" CreationDate="2016-07-28T08:14:18.497" Score="4" Body="&lt;p&gt;N represents Normal mode and O represents operational mode and X represents Ex mode.  Mappings can be done in normal, ex (similar to command line), visual, insert and operational mode as well. &#xA;To know more,&#xA;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/intro.html&quot; rel=&quot;nofollow&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/intro.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim knows to distinguish key mappings and predefined commands. For example, if you have a mapping like &lt;code&gt;ie&lt;/code&gt; in normal mode, when you press &lt;code&gt;i&lt;/code&gt;, it waits for some time (timeout) and checks whether you entered &lt;code&gt;e&lt;/code&gt; so that it can execute the mapping. If you didn't press any key within that time, it goes to insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, whatever mapping you have, you have to press the characters in mapping one after the other immediately (within the timeout time). If you do so, that mapping get executed. If you fail to complete the mapping  (fail to press all keys within time), the predefined command with the first key or (first+second key) gets executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One example: &#xA;Let's take &lt;code&gt;di{&lt;/code&gt;. This mapping deletes text inside a &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; pair. Suppose if you press &lt;code&gt;d&lt;/code&gt; , it waits for some keys to be pressed. This waiting mode is called operational mode. If you didn't press &lt;code&gt;i{&lt;/code&gt; within that time, the command is incomplete and gets cancelled.&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="7161" LastEditDate="2016-07-28T08:23:29.967" LastActivityDate="2016-07-28T08:23:29.967" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8995" PostTypeId="1" AcceptedAnswerId="8996" CreationDate="2016-07-28T08:33:05.213" Score="2" ViewCount="483" Body="&lt;p&gt;I am currently trying to edit a git hunk file (a diff: &lt;code&gt;.git/addp-hunk-edit.diff&lt;/code&gt;), and to say to git that a line containing whitespace is unchanged it needs to have &lt;code&gt;&lt;/code&gt; (a line with a single space) as its first character. The problem is that Vim removes all whitespace in otherwise empty lines as soon as I save the file!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This only happens on this file type, not for for instance &lt;code&gt;.vimrc&lt;/code&gt;. How can I manually disable this behavior, and even better, permanently disable it for diff files?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MacVim 7.4.77, installed via Homebrew. &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/fatso83/dotfiles/blob/master/common-setup/vim/vimrc&quot; rel=&quot;nofollow&quot;&gt;My .vimrc&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1087" LastEditorUserId="1087" LastEditDate="2016-07-28T09:32:57.893" LastActivityDate="2016-07-28T09:32:57.893" Title="Stop vim from removing whitespace on save for diff files" Tags="|vimdiff|whitespace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8996" PostTypeId="2" ParentId="8995" CreationDate="2016-07-28T08:41:48.183" Score="6" Body="&lt;p&gt;Since there was nothing explicit in my &lt;code&gt;.vimrc&lt;/code&gt; that acted on only-whitespace lines and the &lt;code&gt;diff&lt;/code&gt; syntax file did no such thing either, this had to with my plugins somehow. I find out that I had an EditorConfig file in this project, and in it it had these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[*]&#xA;# other&#xA;#stuff &#xA;trim_trailing_whitespace = true&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then subsequently added a section for diff files&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[*.diff]&#xA;trim_trailing_whitespace = false&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and voila, everything works as intended :)&lt;/p&gt;&#xA;" OwnerUserId="1087" LastActivityDate="2016-07-28T08:41:48.183" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8997" PostTypeId="2" ParentId="8992" CreationDate="2016-07-28T09:30:36.130" Score="6" Body="&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;  use autocommands, see the end of this post.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's the result of the investigation I've made:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calling &lt;code&gt;bn&lt;/code&gt; call the &lt;a href=&quot;https://github.com/vim/vim/blob/2932359000b2f918d5fade79ea4d124d5943cd07/src/ex_docmd.c#L5517-L5522&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;ex_bnext&lt;/code&gt; function&lt;/a&gt; which does two things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Go to the desired buffer via the &lt;code&gt;goto_buffer&lt;/code&gt; function&lt;/li&gt;&#xA;&lt;li&gt;Execute any command line command passed to the &lt;code&gt;bnext&lt;/code&gt; command&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/vim/vim/blob/2932359000b2f918d5fade79ea4d124d5943cd07/src/buffer.c#L831&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;goto_buffer&lt;/code&gt; function&lt;/a&gt; apparently wrap the more generic &lt;code&gt;do_buffer&lt;/code&gt; function and calls it with special argument related to the action of going to a buffer (see the first argument is the action which is either &lt;code&gt;DOBUF_SPLIT&lt;/code&gt; or &lt;code&gt;DOBUF_GOTO&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/vim/vim/blob/2932359000b2f918d5fade79ea4d124d5943cd07/src/buffer.c#L1143&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;do_buffer&lt;/code&gt; function&lt;/a&gt; is pretty long, but you can see the interesting part around the end. This function calls the &lt;code&gt;set_curbuf&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/vim/vim/blob/2932359000b2f918d5fade79ea4d124d5943cd07/src/buffer.c#L1485&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;set_curbuf&lt;/code&gt; function&lt;/a&gt; set the current buffer to the desired buffer and calls &lt;code&gt;enter_buffer&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/vim/vim/blob/2932359000b2f918d5fade79ea4d124d5943cd07/src/buffer.c#L1604&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;enter_buffer&lt;/code&gt; function&lt;/a&gt; set/reset some options for the newly displayed buffer &lt;strong&gt;and&lt;/strong&gt; calls &lt;code&gt;scroll_cursor_halfway&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finnaly, the &lt;a href=&quot;https://github.com/vim/vim/blob/2932359000b2f918d5fade79ea4d124d5943cd07/src/move.c#L2066&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;scroll_cursor_halfway&lt;/code&gt; function&lt;/a&gt; changes the topline value, meaning the cursor will be displayed halfway the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sooo, I think it's the designed behavior.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What you can do is, when leaving a buffer, save the current window display with &lt;code&gt;winsaveview&lt;/code&gt; and on entering a buffer, reset the view with autocommands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufWinLeave * let b:winview = winsaveview()&#xA;autocmd! BufWinEnter * if exists('b:winview') | call winrestview(b:winview) | unlet b:winview&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-28T09:30:36.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8998" PostTypeId="1" CreationDate="2016-07-28T11:42:32.000" Score="0" ViewCount="104" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow&quot;&gt;pathogen&lt;/a&gt; (from the Ubuntu 16.04 &lt;code&gt;vim-pathogen&lt;/code&gt; package) and a git clone of &lt;a href=&quot;https://github.com/lervag/vimtex/&quot; rel=&quot;nofollow&quot;&gt;vimtex&lt;/a&gt; in &lt;code&gt;~/.vim/bundle/vimtex/&lt;/code&gt;. Now &lt;code&gt;:help vimtex&lt;/code&gt; does not work. I can read &lt;code&gt;~/.vim/bundle/vimtex/doc/vimtex.txt&lt;/code&gt;, but vim displays it as plain text and thus the tags do not work for navigation.&lt;/p&gt;&#xA;" OwnerUserId="8598" LastActivityDate="2016-07-28T11:59:15.950" Title="How to install vimtex.txt helpfile properly?" Tags="|help-system|plugin-vimtex|plugin-pathogen|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8999" PostTypeId="2" ParentId="8998" CreationDate="2016-07-28T11:59:15.950" Score="1" Body="&lt;p&gt;Run &lt;code&gt;:Helptags&lt;/code&gt; after installing a new package. Then &lt;code&gt;:help vimtex&lt;/code&gt; works.&lt;/p&gt;&#xA;" OwnerUserId="8598" LastActivityDate="2016-07-28T11:59:15.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9000" PostTypeId="2" ParentId="8938" CreationDate="2016-07-28T13:41:55.337" Score="2" Body="&lt;p&gt;As @romainl said, you can use the &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; marks for this purpose, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gc `[v`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt; visually select the previous change.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'[,']s/var_name/varName/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace in the last modified lines every &lt;code&gt;var_name&lt;/code&gt; with &lt;code&gt;varName&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use it in your function you can get informations about the last changed lines like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let firstline = line(&quot;'[&quot;)&#xA;let lastline = line(&quot;']&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See: &lt;code&gt;:h ']&lt;/code&gt; and &lt;code&gt;:h '[&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-07-28T13:41:55.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9001" PostTypeId="1" AcceptedAnswerId="9002" CreationDate="2016-07-28T14:45:47.603" Score="9" ViewCount="3973" Body="&lt;p&gt;I would like to be able to search google from within any Vim file. A nice command might be &lt;code&gt;:goo&lt;/code&gt; while in normal mode.&lt;/p&gt;&#xA;&lt;p&gt;Then I type what I want to search and bam it opens my default browser with the search.&lt;/p&gt;&#xA;&lt;p&gt;How would I do this?&lt;/p&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="23502" LastEditDate="2023-11-03T07:53:14.000" LastActivityDate="2023-11-03T07:53:14.000" Title="How do I search google from Vim?" Tags="|external-command|bash|" AnswerCount="5" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="9002" PostTypeId="2" ParentId="9001" CreationDate="2016-07-28T14:55:32.307" Score="11" Body="&lt;p&gt;You have a couple of options here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a plugin:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4183&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-g&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3551&quot; rel=&quot;nofollow noreferrer&quot;&gt;gsearch&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/christoomey/vim-quicklink&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-quicklink&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Or, if you prefer a lightweight solution, you can try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GoogleSearch()&#xA;     let searchterm = getreg(&quot;g&quot;)&#xA;     silent! exec &quot;silent! !firefox \&quot;http://google.com/search?q=&quot; . searchterm . &quot;\&quot; &amp;amp;&quot;&#xA;endfunction&#xA;vnoremap &amp;lt;F6&amp;gt; &quot;gy&amp;lt;Esc&amp;gt;:call GoogleSearch()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;a href=&quot;https://superuser.com/a/212060/367359&quot;&gt;source&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;a href=&quot;https://github.com/xolox/vim-shell&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-shell&lt;/a&gt; plugin you can rewrite this to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GoogleSearch()&#xA;     let searchterm = getreg(&quot;g&quot;)&#xA;     Open &quot;http://google.com/search?q=&quot; . searchterm . &quot;\&quot; &amp;amp;&quot;&#xA;endfunction&#xA;vnoremap &amp;lt;F6&amp;gt; &quot;gy&amp;lt;Esc&amp;gt;:call GoogleSearch()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also have a look at those links:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Search_the_web_for_text_selected_in_Vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Search_the_web_for_text_selected_in_Vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.reddit.com/r/vim/comments/37ou4p/help_me_search_google_from_vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.reddit.com/r/vim/comments/37ou4p/help_me_search_google_from_vim/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Internet_search_for_the_current_word&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Internet_search_for_the_current_word&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And I highly recommend &lt;a href=&quot;https://vimeo.com/122615320&quot; rel=&quot;nofollow noreferrer&quot;&gt;this video by Drew Niel&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-03-20T10:04:45.077" LastActivityDate="2016-07-29T08:11:01.723" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9003" PostTypeId="1" AcceptedAnswerId="9004" CreationDate="2016-07-28T16:02:08.193" Score="8" ViewCount="887" Body="&lt;p&gt;If I open a file that isn't in the current directly, when I used Vim to autocomplete a filename, Vim provides files relative to the location where I launched Vim, not the currently edited file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ find .&#xA;  nice-file.xml&#xA;  xml/&#xA;      messy-file.xml&#xA;      ok-file.xml&#xA;$ vim xml/messy-file.xml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I type &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt;,&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;f&lt;/kbd&gt;, Vim provides &quot;nice-file.xml&quot; as a complete option. It doesn't offer ok-file.xml, even though it's in the same directory as the file I'm currently editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like Vim to complete filenames relative to whatever file I'm editing. Is that possible?&lt;/p&gt;&#xA;" OwnerUserId="3264" LastEditorUserId="599" LastEditDate="2016-07-29T16:22:36.313" LastActivityDate="2016-07-29T16:22:36.313" Title="File name completion relative to currently edited file" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9004" PostTypeId="2" ParentId="9003" CreationDate="2016-07-28T16:08:26.663" Score="8" Body="&lt;p&gt;You can &lt;code&gt;:cd&lt;/code&gt; in Vim to change the current directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cd xml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or more generally, if you want to set it sometimes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gp :cd %:p:h&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you want to always be in the current file's directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autochdir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note that this may break some plugins, because they may rely on the current directory, you can use in place:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter * silent! lcd %:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you don't want to change the current directory, you can also add the current folder to your completion path:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead *&#xA;  \ let s:tempPath=escape(escape(expand(&quot;%:p:h&quot;), ' '), '\ ') |&#xA;  \ exec &quot;set path+=&quot;.s:tempPath&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-07-29T06:34:40.140" LastActivityDate="2016-07-29T06:34:40.140" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9005" PostTypeId="1" AcceptedAnswerId="9006" CreationDate="2016-07-28T19:21:41.293" Score="2" ViewCount="1139" Body="&lt;p&gt;I am trying to format a list that uses tabs for indentation so it will render as a &lt;a href=&quot;https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=lists&quot; rel=&quot;nofollow noreferrer&quot;&gt;bulleted list on Confluence&lt;/a&gt;. That means that each instance of a tab needs to be replaced with an asterisk (*), plus one leading asterisk, and then a space at the end of the string of asterisks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Level 1&#xA;\tLevel 2&#xA;\tLevel 2&#xA;\t\tLevel 3&#xA;\tLevel 2&#xA;Level 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* Level 1&#xA;** Level 2&#xA;** Level 2&#xA;*** Level 3&#xA;** Level 2&#xA;* Level 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried doing a global replace (&lt;code&gt;s/\t/\*/g&lt;/code&gt;) and then adding an asterisk at the beginning of each line, but that leaves me without the trailing space. I also tried the \ze atom as detailed &lt;a href=&quot;https://vi.stackexchange.com/questions/6293/substitute-all-except-the-last-asterisk-in-groups-of-two-or-more-asterisks&quot;&gt;here&lt;/a&gt; (&lt;code&gt;s/\*\ze/\* /&lt;/code&gt;), but that replaces the first asterisk, not the last. I feel like I'm really close but there's something I'm missing that will make this clear.&lt;/p&gt;&#xA;" OwnerUserId="8603" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2021-01-18T20:28:28.890" Title="Replace last instance of character (and there's more)" Tags="|regular-expression|replace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9006" PostTypeId="2" ParentId="9005" CreationDate="2016-07-28T19:42:12.223" Score="3" Body="&lt;p&gt;Here's a solution I came up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(\t*\)/\=&quot;*&quot; . substitute(submatch(1), '\t', '\*', 'g') . &quot; &quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%s///&lt;/code&gt;: Do a substitute on every line in the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^\(\t*\)&lt;/code&gt;: Match as many tabs as you can find at the beginning of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\=&lt;/code&gt;: Allows us to use an expression in the replacement&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;substitute(submatch(1), '\t', '\*', 'g')&lt;/code&gt;: Replace all the tabs with asterisks. (The &lt;code&gt;submatch(1)&lt;/code&gt; selects the the first group of &quot;memory parentheses&quot; &lt;code&gt;\(\)&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;*&quot; . ... . &quot; &quot;&lt;/code&gt;: Prepend an asterisk and append a space character&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h submatch&lt;/code&gt; and &lt;code&gt;:h sub-replace-\=&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-07-28T19:55:07.820" LastActivityDate="2016-07-28T19:55:07.820" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9007" PostTypeId="2" ParentId="9005" CreationDate="2016-07-28T20:30:22.550" Score="1" Body="&lt;p&gt;I imagine the easiest way is to run 2 simple substitutions.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\t/*/g&#xA;:%s/\w/* &amp;amp;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The first to replaces tab characters with stars and the second to puts an additional star and space before the first character.&lt;/p&gt;&#xA;&lt;p&gt;If you can't use the &lt;code&gt;%&lt;/code&gt; range then you can combine this with the global command, &lt;code&gt;:g&lt;/code&gt;, to execute a command on each line that matches a pattern.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\t*/s/\t/*/g|s/\w/* &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;We use the &lt;code&gt;|&lt;/code&gt; to run 2 separate commands so we can run multiple commands in one line.&lt;/p&gt;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:h :s&#xA;:h s/\\&amp;amp;&#xA;:h /\w&#xA;:h :g&#xA;:h :|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="-1" LastEditDate="2021-01-18T20:28:28.890" LastActivityDate="2021-01-18T20:28:28.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9008" PostTypeId="2" ParentId="7741" CreationDate="2016-07-28T23:32:54.277" Score="2" Body="&lt;p&gt;Visually highlight, then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt; s/.*/['&amp;amp;']/ | *j! | s/]\[/, /ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It surrounds each line, to make e.g. &lt;code&gt;['value 1']&lt;/code&gt;, joins&#xA;them all, then replaces adjacent &lt;code&gt;]&lt;/code&gt; and &lt;code&gt;[&lt;/code&gt; with comma-space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation for the &lt;code&gt;*&lt;/code&gt; in &lt;code&gt;*j!&lt;/code&gt; is at &lt;code&gt;:help cpo-star&lt;/code&gt;, by the way. &#xA;That one's a bit tricky to find.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-07-28T23:41:30.643" LastActivityDate="2016-07-28T23:41:30.643" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9009" PostTypeId="1" CreationDate="2016-07-29T06:23:25.553" Score="1" ViewCount="366" Body="&lt;p&gt;When I configured cscope in vim, I have installed some plugins such as Minibufexplorer, but I found that when I use &lt;code&gt;cs find s&lt;/code&gt;, the result could be showed in the quickfix, and none of the option file could be displayed in file explorer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is that? and how to solve it. thanks! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FKoSv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FKoSv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8607" LastEditorUserId="1841" LastEditDate="2016-07-29T08:18:19.087" LastActivityDate="2016-07-29T08:19:18.837" Title="Why the result file of cscope found in quickfix window can't be showed in file explorer?" Tags="|quickfix|cscope|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9011" PostTypeId="2" ParentId="9001" CreationDate="2016-07-29T11:35:20.640" Score="2" Body="&lt;p&gt;As others have  pointed out, Searching from Vim is not something one would want to do every time, but I do understand that there are some situations where you just want to search for a particular word in Vim. In those situations this plugin might be useful. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mind you, this is something I wrote only for the purpose of searching for the word under the cursor, nothing more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/durgaswaroop/vim-scour&quot; rel=&quot;nofollow&quot;&gt;Vim-Scour&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Readme file has info about how to use this. And even if you don't want to use the plugin itself, look at the plugin file. Its really small and you will get an idea about how you can do system calls. &lt;/p&gt;&#xA;" OwnerUserId="5481" LastActivityDate="2016-07-29T11:35:20.640" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9012" PostTypeId="1" AcceptedAnswerId="9014" CreationDate="2016-07-29T19:13:27.347" Score="3" ViewCount="1301" Body="&lt;p&gt;How can you do a case insensitive search with line contexts displayed in vim while using the &lt;code&gt;:g&lt;/code&gt; ex command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following but it doesn't seem to work...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/pattern/z#.1i|echo &quot;================================&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/pattern/iz#.1|echo &quot;================================&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...but it results in an error.&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2016-07-29T19:42:22.367" Title="Case Insensitive Search with g ex command?" Tags="|ex-mode|letter-case|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9013" PostTypeId="2" ParentId="9012" CreationDate="2016-07-29T19:18:30.617" Score="2" Body="&lt;p&gt;You can do a &lt;code&gt;set ic&lt;/code&gt; before the search command.&lt;/p&gt;&#xA;" OwnerUserId="7892" LastActivityDate="2016-07-29T19:18:30.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9014" PostTypeId="2" ParentId="9012" CreationDate="2016-07-29T19:28:49.300" Score="8" Body="&lt;p&gt;There are two ways to achieve this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;One&lt;/em&gt; is to &lt;code&gt;set ignorecase&lt;/code&gt;, then the pattern regex will ignore the case.  Yet, this solution is poor if you are writing a script that may need to be reused by someone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;em&gt;better solution&lt;/em&gt; is to use the &lt;code&gt;\c&lt;/code&gt; (ignore case) &lt;code&gt;\C&lt;/code&gt; (do not ignore case) modifiers in the regex.  This command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/\cpattern/z#.1|echo &quot;================================&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will always ignore the case of &lt;code&gt;pattern&lt;/code&gt; no matter what you have set &lt;code&gt;ignorecase&lt;/code&gt; to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/\Cpattern/z#.1|echo &quot;================================&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will always perform a case sensitive search for &lt;code&gt;pattern&lt;/code&gt;, even if you have &lt;code&gt;ignorecase&lt;/code&gt; set to true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference (the forward slash is important):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help /ignorecase&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-07-29T19:42:22.367" LastActivityDate="2016-07-29T19:42:22.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9015" PostTypeId="1" CreationDate="2016-07-29T19:29:41.270" Score="1" ViewCount="222" Body="&lt;p&gt;I prefer this indentation style for switch cases with local variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (expr) {&#xA;case CONST_BLAH1: {&#xA;        int decl; // scope local to this case&#xA;        stmt;&#xA;        break;&#xA;case CONST_BLAH2: } {&#xA;        stmt;&#xA;        break;&#xA;case CONST_BLAH3: } {&#xA;        int x, y;&#xA;        stmt;&#xA;        break;&#xA;case CONST_BLAH4: }&#xA;        // because this is the last case we don't introduce new scope&#xA;        int x, y;&#xA;        stmt;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My current C-indentation options are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cinoptions=:0,l1,(s,m1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And Vim indents the code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (expr) {&#xA;case CONST_BLAH1: {&#xA;        int decl;&#xA;        stmt;&#xA;        break;&#xA;case CONST_BLAH2: } {&#xA;        stmt;&#xA;        break;&#xA;case CONST_BLAH3: } {&#xA;        int x, y;&#xA;        stmt;&#xA;        break;&#xA;case CONST_BLAH4: } &#xA;                  int x, y;&#xA;                  stmt;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does it align the statements in &lt;code&gt;CONST_BLAH4&lt;/code&gt; to the previous closing &lt;code&gt;}&lt;/code&gt;? And how do I remove this behavior?&lt;/p&gt;&#xA;" OwnerUserId="3032" LastEditorUserId="51" LastEditDate="2016-08-07T14:45:32.150" LastActivityDate="2016-08-07T14:45:32.150" Title="Why does cindent align statements to closing } in switch case?" Tags="|indentation|filetype-c|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9016" PostTypeId="1" CreationDate="2016-07-30T04:36:05.833" Score="17" ViewCount="1551" Body="&lt;p&gt;What is the difference between the following in vim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;buffer&lt;/li&gt;&#xA;&lt;li&gt;window&lt;/li&gt;&#xA;&lt;li&gt;viewport&lt;/li&gt;&#xA;&lt;li&gt;split&lt;/li&gt;&#xA;&lt;li&gt;tab&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5324" LastActivityDate="2016-08-03T04:38:03.497" Title="What is the difference between a tab, viewport, window, split and buffer?" Tags="|buffers|vim-windows|split|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9017" PostTypeId="2" ParentId="9016" CreationDate="2016-07-30T04:36:05.833" Score="18" Body="&lt;p&gt;A &lt;strong&gt;buffer&lt;/strong&gt; is the in-memory text of a file. It may differ from the saved version of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;strong&gt;window&lt;/strong&gt; is a view of a buffer. You can have two (or more) windows editing different parts of the same buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;strong&gt;viewport&lt;/strong&gt; is synonymous with a window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;strong&gt;tab&lt;/strong&gt; page contains one or more windows. You can see what windows are in which tab with &lt;code&gt;:tabs&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;strong&gt;split&lt;/strong&gt; is where the screen space previously occupied by one window is then allocated to two windows. A window can be split either horizontally (&lt;code&gt;:split&lt;/code&gt;) or vertically (&lt;code&gt;:vsplit&lt;/code&gt;), and a window inside a split can itself be split again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further reading:&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help windows&lt;/code&gt;&lt;/a&gt;, &#xA;&lt;a href=&quot;http://vimhelp.appspot.com/tabpage.txt.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :tab-page&lt;/code&gt;&lt;/a&gt;, &#xA;&lt;a href=&quot;https://sanctum.geek.nz/arabesque/buffers-windows-tabs/&quot; rel=&quot;noreferrer&quot;&gt;Buffers, windows and tabs&lt;/a&gt; - Tom Ryder&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="7621" LastEditDate="2016-08-03T04:38:03.497" LastActivityDate="2016-08-03T04:38:03.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9018" PostTypeId="2" ParentId="300" CreationDate="2016-07-30T05:15:30.530" Score="3" Body="&lt;p&gt;I've been using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;3&lt;/kbd&gt; since quite some time, I find it easier to type than most alternatives and seems to work nicely (at least on Linux).&#xA;My &lt;kbd&gt;Caps Lock&lt;/kbd&gt; is mapped to &lt;kbd&gt;Ctrl&lt;/kbd&gt;, so it's very comfy to type it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt; for some time, but I had some issues with it which I don't recall exactly now, but I wasn't getting the exact same behavior as &lt;kbd&gt;Esc&lt;/kbd&gt;, like I get now with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;3&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8613" LastActivityDate="2016-07-30T05:15:30.530" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9019" PostTypeId="1" AcceptedAnswerId="9020" CreationDate="2016-07-30T06:00:50.950" Score="1" ViewCount="52" Body="&lt;p&gt;So when I go to the first character in a line, the first character in that line is a tab character, and I execute &lt;code&gt;echo col('.')&lt;/code&gt;, I will get &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when I type &lt;code&gt;2|&lt;/code&gt; I won't go to the next character, but I will stay in the current position, which is because the tab character fills 8 display spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I make &lt;code&gt;|&lt;/code&gt; behave like &lt;code&gt;col('.')&lt;/code&gt; and use characters instead of display spaces?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="865" LastEditDate="2016-07-30T14:36:01.437" LastActivityDate="2016-07-30T14:36:01.437" Title="Make pipe behave like `col('.')`" Tags="|cursor-motions|tab-characters|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9020" PostTypeId="2" ParentId="9019" CreationDate="2016-07-30T06:45:51.383" Score="3" Body="&lt;p&gt;This is just barely tested. So it might still have some bugs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! Go(char)&#xA;    let ret = '/^.\{'. a:char. '}\%'. line('.'). &quot;l/e\&amp;lt;cr&amp;gt;&quot;&#xA;    return ret&#xA;endfunc&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;&amp;lt;Bar&amp;gt;  Go(v:count1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to search for the given number of chars in the current line.&#xA;Use the &lt;code&gt;\|&lt;/code&gt; mapping to go where you want.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-30T06:45:51.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9021" PostTypeId="2" ParentId="3934" CreationDate="2016-07-30T10:01:35.107" Score="6" Body="&lt;p&gt;In the past I could upload a patch to the issue tracker of the Google Code repository for vim which was accepted after some months or send a mail and hope to get some feedback. Google Code is no more, but &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_announce/JwhLSKf39kM&quot; rel=&quot;noreferrer&quot;&gt;since 24 August 2015&lt;/a&gt; vim's development happens on a Github project (including source code and issue tracking).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More instructions for contributing can be found in the &lt;a href=&quot;https://github.com/vim/vim/blob/master/CONTRIBUTING.md&quot; rel=&quot;noreferrer&quot;&gt;CONTRIBUTING.md&lt;/a&gt; file. Do note that this Github project is an unusual one. If you propose a PR, the change might be taken and squashed with other commits (examples: &lt;a href=&quot;https://github.com/vim/vim/pull/943/commits/c90f6e1387a0a66dafd8ebbac4c42a6c4d272f63&quot; rel=&quot;noreferrer&quot;&gt;PR&lt;/a&gt; and &lt;a href=&quot;https://github.com/vim/vim/commit/8c08b5b569e2a9e9f63dea514591ecfa2d3bb392&quot; rel=&quot;noreferrer&quot;&gt;commit&lt;/a&gt;, another larger &lt;a href=&quot;https://github.com/vim/vim/pull/936/commits/3112daef193b8d8be0723a1f536034404e0baae7&quot; rel=&quot;noreferrer&quot;&gt;PR&lt;/a&gt; and &lt;a href=&quot;https://github.com/vim/vim/commit/6f1d9a096bf22d50c727dca73abbfb8e3ff55176&quot; rel=&quot;noreferrer&quot;&gt;commit&lt;/a&gt;). The commit messages follow a very specific format and you have to look very hard to find the origin and discussion of patches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Links:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/develop.php&quot; rel=&quot;noreferrer&quot;&gt;http://www.vim.org/develop.php&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/vim/vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2698" LastActivityDate="2016-07-30T10:01:35.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9022" PostTypeId="1" CreationDate="2016-07-30T17:41:16.230" Score="1" ViewCount="327" Body="&lt;p&gt;I frequently use vim to edit multiple files.  On the command line, I'll type &lt;code&gt;vim *&lt;/code&gt; or the like, and use &lt;code&gt;:wn&lt;/code&gt; to move through the files until I get to the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Invariably, I get to the last file, and type &lt;code&gt;:wn&lt;/code&gt; and get the maddening message &lt;code&gt;E165: Cannot go beyond last file&lt;/code&gt;, when really what I want vim to do is quit at that point (&lt;code&gt;:wq&lt;/code&gt;).  Is there a configuration that controls this behavior?&lt;/p&gt;&#xA;" OwnerUserId="8621" LastActivityDate="2018-06-13T16:17:14.093" Title="&quot;Next&quot; behavior and &quot;E165: Cannot go beyond last file&quot;" Tags="|key-bindings|multiple-files|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9023" PostTypeId="2" ParentId="9022" CreationDate="2016-07-30T17:54:53.907" Score="1" Body="&lt;p&gt;I don't think there is a configuration option to change that behaviour. However you can create a custom command, that catches error E165 and quits in that case. Something like this should work (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! -count -bang Wnext try | &amp;lt;count&amp;gt;wn&amp;lt;bang&amp;gt; | catch /^Vim\%((\a\+)\)\=:E165/ | q | endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-07-30T17:54:53.907" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9024" PostTypeId="2" ParentId="300" CreationDate="2016-07-30T18:26:07.913" Score="3" Body="&lt;p&gt;FWIW I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map! ;l ^[&#xA;:vmap ;l ^[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It feels similar to hitting Return. &#xA;I use &lt;code&gt;;&lt;/code&gt; as the leader for other  Insert-mode mappings too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only time I've needed to type ';' + letter is when code golfing; I've not had any conflicts otherwise. &lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-07-30T18:26:07.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9025" PostTypeId="2" ParentId="9022" CreationDate="2016-07-30T20:00:01.203" Score="0" Body="&lt;p&gt;This is the normal behaviour of vi. You can do a &lt;code&gt;:rew&lt;/code&gt; to start with the first file again. In vim you can also use &lt;code&gt;:bn&lt;/code&gt; and &lt;code&gt;:bp&lt;/code&gt; to go to the next or previous file. But &lt;code&gt;:rew&lt;/code&gt; works with any vi variant.&lt;/p&gt;&#xA;" OwnerUserId="7892" LastActivityDate="2016-07-30T20:00:01.203" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9026" PostTypeId="1" CreationDate="2016-07-31T02:01:22.573" Score="0" ViewCount="102" Body="&lt;p&gt;I am writing a small plugin to manage my address book (the actual plugin interfaces with the &lt;code&gt;abook&lt;/code&gt; program).  I use a special buffer (&lt;code&gt;nofile&lt;/code&gt;) and I redraw the entire buffer each time something changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I create the buffer (and have a mapping to call this function)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; creates a special buffer&#xA;function! MkAbook()&#xA;  let g:abook_prevbuf = bufnr('%')  &quot; save current buffer&#xA;  if g:abook_buf&#xA;    execute 'buffer ' . string(g:abook_buf)&#xA;  else&#xA;    edit [abook]&#xA;  endif&#xA;  setlocal buftype=nofile&#xA;  setlocal nomodifiable&#xA;  setlocal filetype=abook&#xA;  setlocal nobuflisted&#xA;  call AbookDraw()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I clear and draw the entire buffer when it opens (and when it is changed).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; fakes a change in buffer&#xA;function! AbookDraw()&#xA;  &quot; this is a dummy variable, I actually build it from a file&#xA;  let b:dict = {&#xA;  \   'header1' : 'content1'&#xA;  \ , 'header2' : 'content2'&#xA;  \ }&#xA;  setlocal modifiable&#xA;  &quot; clear the buffer&#xA;  normal ggdG&#xA;  put! ='abook list'&#xA;  put  ='=========='&#xA;  put  =''&#xA;  for k in keys(b:dict)&#xA;    put ='[' . k . ']'&#xA;    put =b:dict[k]&#xA;    put =''&#xA;  endfor&#xA;  setlocal nomodifiable&#xA;  setlocal nomodified&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My issue is that &lt;code&gt;put ='string'&lt;/code&gt; seems like a hack.  I am also worried about the &lt;strong&gt;execution speed&lt;/strong&gt;.  Other options I have thought of are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let content  = &quot;abook list\n&quot;&#xA;let content += &quot;==========\n&quot;&#xA;...&#xA;put =content&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let content = []&#xA;call add(content, &quot;abook list&quot;)&#xA;call add(content, &quot;==========&quot;)&#xA;...&#xA;call append(line('$'), content)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is the most efficient way to perform this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I believe that, once the amount of things to redraw everytime becomes big, execution speed will become important.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In other words, the question is about &lt;strong&gt;execution speed&lt;/strong&gt;.  I do not yet have a buffer big enough to measure the execution speed of each method in a consistent manner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone measured Vim's execution speed of different draw-an-entire-buffer methods?&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="51" LastEditDate="2016-08-07T14:45:19.727" LastActivityDate="2016-08-07T14:45:19.727" Title="How do I &quot;draw&quot; a buffer from scratch in an efficient manner?" Tags="|buffers|performance|input-methods|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9027" PostTypeId="1" CreationDate="2016-07-31T02:01:41.897" Score="4" ViewCount="167" Body="&lt;p&gt;I am curious to see if it would be possible to write a vim fold expression for fountain.io files. Fountain files are plaintext files used by screenwriters. A good start would be to fold along two different terms that occur commonly in screenplays (INT. and EXT.), obviously I'd like to drill down into blocks of dialogue etc. down the road. But for now I'd like to start with INT. and EXT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use a folding expression for markdown as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MarkdownFolds()&#xA;  let thisline = getline(v:lnum)&#xA;  if match(thisline, '^#') &amp;gt;= 0&#xA;    return &quot;&amp;gt;1&quot;&#xA;  else&#xA;    return &quot;=&quot;&#xA;  endif&#xA;endfunction&#xA;setlocal foldmethod=expr&#xA;setlocal foldexpr=MarkdownFolds()&#xA;&#xA;function! MarkdownFoldText()&#xA;  let foldsize = (v:foldend-v:foldstart)&#xA;  return getline(v:foldstart).' ('.foldsize.' lines)'&#xA;endfunction&#xA;setlocal foldtext=MarkdownFoldText()&#xA;&#xA;&quot; SOURCE&#xA;&quot; https://gist.github.com/anonymous/4149842&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm thinking there is a way to modify something like this to do what I want to. Anyone have any ideas, I would greatly appreciate it. If we get this fleshed out, I'll make sure to get this in front of whoever uses vim and fountain in conjunction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="4585" LastActivityDate="2016-08-03T15:21:13.030" Title="Writing a vim fold expression for fountain.io files" Tags="|vimscript|folding|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9028" PostTypeId="1" AcceptedAnswerId="9029" CreationDate="2016-07-31T04:25:09.533" Score="118" ViewCount="260212" Body="&lt;p&gt;How do I select all the content of a file in Vim and VsVim? Like in other editors &lt;kbd&gt;Ctrl-A&lt;/kbd&gt; does the job for select all.&lt;/p&gt;&#xA;" OwnerUserId="4799" LastEditorUserId="23502" LastEditDate="2023-03-12T15:23:41.327" LastActivityDate="2024-02-18T09:40:49.730" Title="What is the command for &quot;Select All&quot; in Vim and VsVim?" Tags="|key-bindings|" AnswerCount="9" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9029" PostTypeId="2" ParentId="9028" CreationDate="2016-07-31T06:29:35.803" Score="135" Body="&lt;p&gt;&lt;code&gt;ggVG&lt;/code&gt; selects all content. &lt;code&gt;gg&lt;/code&gt; moves to first line. &lt;code&gt;V&lt;/code&gt; starts visual mode. &lt;code&gt;G&lt;/code&gt; jumps to last line thereby selecting from first to last line &lt;/p&gt;&#xA;" OwnerUserId="7161" LastActivityDate="2016-07-31T06:29:35.803" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9030" PostTypeId="2" ParentId="9027" CreationDate="2016-07-31T07:46:17.577" Score="4" Body="&lt;p&gt;OP here. I figured it out, turns out that even though I don't understand programming all too well, it was totally doable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FountainFolds()&#xA;  let thisline = getline(v:lnum)&#xA;  if match(thisline, '^INT.') &amp;gt; -1&#xA;    return &quot;&amp;gt;1&quot;&#xA;  elseif match (thisline, '^EXT.') &amp;gt; -1&#xA;    return &quot;&amp;gt;1&quot;&#xA;  elseif match (thisline, '^Title:') &amp;gt; -1&#xA;    return &quot;&amp;gt;1&quot;&#xA;  else&#xA;    return &quot;=&quot;&#xA;  endif&#xA;endfunction&#xA;&#xA;&#xA;setlocal foldmethod=expr&#xA;setlocal foldexpr=FountainFolds()&#xA;&#xA;function! FountainFoldText()&#xA;  let foldsize = (v:foldend-v:foldstart)&#xA;  return getline(v:foldstart).' ('.foldsize.' lines)'&#xA;endfunction&#xA;&#xA;setlocal foldtext=FountainFoldText()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Probably not the best or perfect way to do it. But it works. I may work to integrate other hierarchical elements that are common to fountain file. If I do, I will update this. I may also make this a gist on github.&lt;/p&gt;&#xA;" OwnerUserId="4585" LastEditorUserId="4585" LastEditDate="2016-08-03T15:21:13.030" LastActivityDate="2016-08-03T15:21:13.030" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9031" PostTypeId="1" CreationDate="2016-07-31T12:44:35.607" Score="2" ViewCount="529" Body="&lt;p&gt;So I've been using Vim at school with a vimrc that seemed to be well set up, and learn few extra commands like set nu or syntax on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I'm trying I'm using Vi on my computer, and was struck by how bad Vi default configuration was, and am trying to set my vimrc but it's hell as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 filetype indent on&#xA;2 set tabstop=4&#xA;3 set backspace=indent,eol,start&#xA;4 syntax enable&#xA;5 set nu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The backspace is unpractical (not deleting letters as it should naturally), my vimrc is displaying an error message when I start it up. Are the function summoned in vimrc wrong? Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Yup, nope, this irrational backspace crap is driving me crazy. I can't get a regular backspace behavior (deletes previous character, period). Set backspace and filetype indent don't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit#2: So Vim backspace still won't behave humanly, I'm still trying to figure the f how to implement a normal backspace (which removes previous characters, period)&lt;/p&gt;&#xA;" OwnerUserId="8624" LastEditorUserId="8624" LastEditDate="2016-08-06T17:10:37.113" LastActivityDate="2016-09-06T15:56:39.160" Title="Trouble with vimrc" Tags="|vimrc|indentation|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9032" PostTypeId="2" ParentId="9031" CreationDate="2016-07-31T13:20:10.413" Score="1" Body="&lt;p&gt;2 suggestions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Are you trying to use Vi or Vim? On most systems 'vi' is just a link to vim, but it may not be the case on your system. Your description of the backspace makes it sound a little like you may be using vi instead of vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) If you don't like the default vim options, you could look into NeoVim (&lt;a href=&quot;https://neovim.io/&quot; rel=&quot;nofollow&quot;&gt;https://neovim.io/&lt;/a&gt;). I believe one of their objectives is to improve on what options are enabled by default.&lt;/p&gt;&#xA;" OwnerUserId="5596" LastActivityDate="2016-07-31T13:20:10.413" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9033" PostTypeId="2" ParentId="9028" CreationDate="2016-07-31T17:11:38.753" Score="47" Body="&lt;p&gt;Along with SibiCoder's answer, if you have a clear idea of what you want to do you can use the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%X&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where &lt;code&gt;X&lt;/code&gt; is a command, for example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%d             -&amp;gt; delete every line&#xA;:%y             -&amp;gt; yank every line&#xA;:%normal! &amp;gt;&amp;gt;    -&amp;gt; indent every line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You have also the global command &lt;code&gt;:g&lt;/code&gt; which, with the search pattern &lt;code&gt;^&lt;/code&gt;, can do the same thing:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/d             -&amp;gt; delete every line&#xA;:g/^/y             -&amp;gt; yank every line&#xA;:g/^/normal! &amp;gt;&amp;gt;    -&amp;gt; indent every line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If what you want is selecting the text, then &lt;code&gt;ggVG&lt;/code&gt; is fine, but keep in mind these method, in the case you already know what is the next step. Note that it won't leave the cursor in visual mode.&lt;/p&gt;&#xA;&lt;p&gt;See: &lt;code&gt;:h :%&lt;/code&gt; and &lt;code&gt;:h :g&lt;/code&gt; for reference.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Note that, even though the &lt;code&gt;C-A&lt;/code&gt; mapping is used in vim (see &lt;code&gt;:h CTRL-A&lt;/code&gt;), you can map it to do what other editors do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-A&amp;gt; ggVG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Just be aware that mapping &lt;code&gt;C-A&lt;/code&gt; could clash with other plugins' mappings or with &lt;code&gt;screen&lt;/code&gt;'s default prefix.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="10604" LastEditDate="2022-05-03T13:53:58.137" LastActivityDate="2022-05-03T13:53:58.137" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9034" PostTypeId="5" CreationDate="2016-07-31T17:28:25.367" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/jaredpar/VsVim&quot; rel=&quot;nofollow&quot;&gt;VsVim&lt;/a&gt; is a plugin for Microsoft's Visual Studio IDE that allows vim-like editing. Use this tag for questions about effectively using and configuring this plugin for editing text. &lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-08-01T11:48:17.430" LastActivityDate="2016-08-01T11:48:17.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9035" PostTypeId="4" CreationDate="2016-07-31T17:28:25.367" Score="0" Body="For questions about VsVim, the Visual Studio plugin that emulates Vim. " OwnerUserId="2920" LastEditorUserId="1821" LastEditDate="2016-08-01T11:34:54.353" LastActivityDate="2016-08-01T11:34:54.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9036" PostTypeId="2" ParentId="9028" CreationDate="2016-07-31T17:34:56.057" Score="5" Body="&lt;p&gt;The other answers are good. Here's another alternative. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you mention that you are using VsVim, you can change which keys are handled by visual Studio, and which keys are handled by vsvim. Go to &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Tools -&gt; Options -&gt; VsVim -&gt; Keyboard&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From there you can set Ctrl-a to be handled by Visual Studio, rather than VsVim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I do not recommend this since you will not be able to use vim's &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt;, which I find to be an essential feature. Though it's up to you. &lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-07-31T17:34:56.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9037" PostTypeId="1" AcceptedAnswerId="9038" CreationDate="2016-08-01T08:25:49.823" Score="3" ViewCount="779" Body="&lt;p&gt;I have a function somewhat like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction()&#xA;    g/\v.(\n\n|\n*%$)/execute &quot;normal! v{:call AnotherFunction()\&amp;lt;cr&amp;gt;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to be able to pass a range to that function. The problem is… how can I add the range (&lt;code&gt;a:firstline&lt;/code&gt; and &lt;code&gt;a:lastline&lt;/code&gt;) before the &lt;code&gt;g&lt;/code&gt; command? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried all the combinations I could think of (like &lt;code&gt;execute a:firstline.','.a:lastline' 'g/...&lt;/code&gt;), but I can't get it to work (maybe because I already use &lt;code&gt;execute&lt;/code&gt; in the global command).&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="1821" LastEditDate="2016-08-01T09:41:51.300" LastActivityDate="2016-08-01T09:44:56.143" Title="Run global with range from within function" Tags="|vimscript|global-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9038" PostTypeId="2" ParentId="9037" CreationDate="2016-08-01T09:39:21.393" Score="5" Body="&lt;p&gt;From the documentation (&lt;code&gt;:h function-range-example&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Cont() range&#xA;  execute (a:firstline + 1) . &quot;,&quot; . a:lastline . 's/^/\t\\ '&#xA;endfunction&#xA;4,8call Cont()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to use execute to pass the variables to the &lt;code&gt;g&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, this simplified example should work (at least it works here):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction()&#xA;    execute a:firstline . ',' . a:lastline . 'g/^/execute &quot;normal! &amp;gt;&amp;gt;&quot;'&#xA;endfunction&#xA;1,3call MyFunction()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-08-01T09:44:56.143" LastActivityDate="2016-08-01T09:44:56.143" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9039" PostTypeId="2" ParentId="9026" CreationDate="2016-08-01T11:26:01.180" Score="1" Body="&lt;p&gt;I believe it is fine to use either &lt;code&gt;:put&lt;/code&gt; or &lt;code&gt;setline()&lt;/code&gt;. But as you are reading the contents from an external program, you could consider &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#:r!&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:read !&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]r[ead] [++opt] !{cmd}&#xA;            Execute {cmd} and insert its standard output below&#xA;            the cursor or the specified line.  A temporary file is&#xA;            used to store the output of the command which is then&#xA;            read into the buffer.  'shellredir' is used to save&#xA;            the output of the command, which can be set to include&#xA;            stderr or not.  {cmd} is executed like with &quot;:!{cmd}&quot;,&#xA;            any '!' is replaced with the previous command |:!|.&#xA;            See |++opt| for the possible values of [++opt].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could use the &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#:r&quot; rel=&quot;nofollow&quot;&gt;regular &lt;code&gt;:read&lt;/code&gt;&lt;/a&gt; to insert the header from a template file, and &lt;code&gt;:$read! &amp;lt;cmd&amp;gt;&lt;/code&gt; to include information from your &lt;code&gt;abook&lt;/code&gt; program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if it is already working and you don't notice any delays, you should consider leaving it as it is; from the great book &quot;&lt;strong&gt;The Practice of Programming&lt;/strong&gt;&quot;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Thus the first principle of optimization is &lt;strong&gt;&lt;em&gt;don't&lt;/em&gt;&lt;/strong&gt;. Is the program good&#xA;  enough already? Knowing how a program will be used and the environment&#xA;  it runs in, is there any benefit to making it faster? Programs written&#xA;  for assignments in a college class are never used again; speed rarely&#xA;  matters. Nor will speed matter for most personal programs, occasional&#xA;  tools, test frameworks, experiments, and prototypes.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-08-01T11:31:54.477" LastActivityDate="2016-08-01T11:31:54.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9040" PostTypeId="1" CreationDate="2016-08-01T11:28:48.567" Score="2" ViewCount="233" Body="&lt;p&gt;I'm attemping to call a function when pressing y + motion like this in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:MyFunction(reg)&#xA;  echo a:reg&#xA;endfunction&#xA;&#xA;nnoremap y :&amp;lt;C-U&amp;gt; call &amp;lt;SID&amp;gt;MyFunction(v:register)&amp;lt;CR&amp;gt;y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I type &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;, MyFunction echoes &lt;code&gt;'a'&lt;/code&gt; like expected, but the yanked word is never written to register &lt;code&gt;&quot;a&lt;/code&gt;, instead it is written to the yank register &lt;code&gt;&quot;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why and how to fix this so my mapping honors the specified named register?&lt;/p&gt;&#xA;" OwnerUserId="8636" LastEditorUserId="8636" LastEditDate="2016-08-01T11:59:05.093" LastActivityDate="2016-08-01T14:22:25.350" Title="When remapping the yank operator, the named register it lost" Tags="|vimscript|register|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9041" PostTypeId="2" ParentId="9040" CreationDate="2016-08-01T14:22:25.350" Score="3" Body="&lt;p&gt;It seem that the v:register &lt;em&gt;is&lt;/em&gt; lost after calling MyFunction. After a bit of reading I found &lt;code&gt;map-expression&lt;/code&gt; that can be used to solve the issue like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:MyFunction(reg)&#xA;  echo a:reg&#xA;  return '&quot;'.a:reg.'y'&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt; y &amp;lt;SID&amp;gt;MyFunction(v:register)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8636" LastActivityDate="2016-08-01T14:22:25.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9042" PostTypeId="2" ParentId="2944" CreationDate="2016-08-01T15:29:05.090" Score="2" Body="&lt;p&gt;You can use my &lt;a href=&quot;https://github.com/still-dreaming-1/vim-project-tags&quot; rel=&quot;nofollow&quot;&gt;project-tags&lt;/a&gt; plugin for this. It requires a tiny bit more setup than the fugitive.vim approach, but it is also more of a power user tool. Once you set it up for your projects, it will automatically generate tags for you in your projects and it will automatically select the correct tags file for you. It is largely designed around avoiding false positives when the tags file is used for auto-completion or jump to. It uses the following techniques to reduce the number of false positives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;tags are generated per project, instead of having a global tags file&lt;/li&gt;&#xA;&lt;li&gt;tags are also separated per language instead of one tags file for the entire project&lt;/li&gt;&#xA;&lt;li&gt;An optional configuration option allows you to specifically exclude certain directories from being used to generate tags. If you tend to get a lot of false positives from code inside a specific directory, excluding it might improve your tags experience.&lt;/li&gt;&#xA;&lt;li&gt;An optional configuration option allows you to specifically include a directory outside your project that your project tags file will also have tags from. This is useful when you reference a library that is not inside your project directory. It can also be helpful when used in combination with the exclude option. You can generate tags inside the excluded directory that include the tags from the rest of the project. That way when you are browsing / working with code inside the excluded directory, the tags will still be there and work properly.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1410" LastActivityDate="2016-08-01T15:29:05.090" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9043" PostTypeId="1" AcceptedAnswerId="9044" CreationDate="2016-08-01T17:26:11.963" Score="3" ViewCount="66" Body="&lt;p&gt;I am wondering what the letters before the filename in a non focused tab stands for. &#xA;In the example in the picture &lt;code&gt;c/s/s/&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ES23j.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ES23j.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8641" LastActivityDate="2016-08-01T17:28:57.243" Title="What is the letter's meaning in non focused tabs" Tags="|gvim|plugin-airline|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9044" PostTypeId="2" ParentId="9043" CreationDate="2016-08-01T17:28:57.243" Score="3" Body="&lt;p&gt;It's a short-hand describing your path.&#xA;I.e. if you path was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Some/Long/Path/file.txt &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The resulting tab would end up looking like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;S/L/P/file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-08-01T17:28:57.243" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9045" PostTypeId="1" AcceptedAnswerId="9046" CreationDate="2016-08-01T18:06:33.373" Score="7" ViewCount="6297" Body="&lt;p&gt;I'm trying to run a command (from within a function) that goes somewhat like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute a:firstline . ',' . a:last line . 'g/\(\.\|!\|?\)\()\|]\|&quot;\|'\)*\($\|\s\)/execute &quot;normal! v(:call MyFunction()\&amp;lt;cr&amp;gt;&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work and I think it's because of all the quotes. I tried escaping them with backslashes, but that doesn't work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="7642" LastActivityDate="2016-08-01T18:25:11.730" Title="Escape quotes within quotes in command" Tags="|vimscript|regular-expression|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9046" PostTypeId="2" ParentId="9045" CreationDate="2016-08-01T18:25:11.730" Score="11" Body="&lt;p&gt;Either put the quotes into an extra variable and use that, which saves you from the effort to escape them, or double the single quotes. &#xA;But notes, this makes it really hard to read (and understand) later your regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quote from the help (&lt;code&gt;:h literal-string&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This string is taken as it is.    No backslashes are removed or have a&#xA;  special meaning.  The only exception is that two quotes stand for one&#xA;  quote.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-08-01T18:25:11.730" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9047" PostTypeId="1" AcceptedAnswerId="9050" CreationDate="2016-08-01T19:43:17.543" Score="4" ViewCount="114" Body="&lt;p&gt;In Vim pressing &lt;code&gt;G&lt;/code&gt; takes you to the last physical line. But, if the last line is wrapped around &lt;code&gt;G&lt;/code&gt; puts the cursor on the first wrapped line in that last line, not the last wrapped line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there a way to get to the last wrapped line when pressing &lt;code&gt;G&lt;/code&gt; without me having to press &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;gj&lt;/code&gt; a bunch of times?&lt;/p&gt;&#xA;" OwnerUserId="5481" LastActivityDate="2016-08-02T18:30:35.150" Title="Go to the last wrapped line with G" Tags="|cursor-movement|wrapping|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9048" PostTypeId="2" ParentId="8660" CreationDate="2016-08-01T19:45:30.650" Score="2" Body="&lt;p&gt;Since this issue was affecting only the normal mode, it was solved by adding the following lines at the very bottom of my &lt;code&gt;.vimrc&lt;/code&gt; configuration file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;kEnter&amp;gt; &amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;S-kEnter&amp;gt; &amp;lt;S-CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Apparently, some plugin had messed up the default behaviour.&lt;/p&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="3168" LastEditDate="2016-08-02T09:52:50.297" LastActivityDate="2016-08-02T09:52:50.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9049" PostTypeId="2" ParentId="8993" CreationDate="2016-08-02T13:16:17.597" Score="5" Body="&lt;p&gt;In vimtex, the mappings like &lt;code&gt;ie&lt;/code&gt; are actually vim text objects (not sure about the right vim nomenclature though). They work together with vim operators like &lt;code&gt;d&lt;/code&gt; (delete). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular &lt;code&gt;ie&lt;/code&gt; stands for any tex environment like &lt;code&gt;equation&lt;/code&gt;, &lt;code&gt;itemize&lt;/code&gt;, .... For example, if you cursor is somewhere inside&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{equation}&#xA;    Ax = b&#xA;\end{equation}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the command &lt;code&gt;die&lt;/code&gt; will delete everything between &lt;code&gt;\begin{equation}&lt;/code&gt; and &lt;code&gt;\end{equation}&lt;/code&gt; and leave you with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{equation}\end{equation}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;. &lt;/p&gt;&#xA;" OwnerUserId="8648" LastActivityDate="2016-08-02T13:16:17.597" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9050" PostTypeId="2" ParentId="9047" CreationDate="2016-08-02T18:30:35.150" Score="2" Body="&lt;p&gt;There are a couple solutions. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You could use &lt;code&gt;G$g0&lt;/code&gt;, like it was suggested in the comments. For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap G G$g0&#xA;xnoremap G G$g0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You don't really need to provide an &lt;code&gt;omap&lt;/code&gt; since G is a line based movement, not a character-based movement. &lt;strong&gt;Explanation&lt;/strong&gt;: &lt;code&gt;G&lt;/code&gt; Moves to the last line, and &lt;code&gt;$&lt;/code&gt; moves to the end of that line. Then &lt;code&gt;g0&lt;/code&gt; moves to the beginning of that visual line, e.g. the first column of the last wrap.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This is admittedly a pretty strange solution, but you could use a recursive macro. This is essentially the same thing as hitting &lt;code&gt;gj&lt;/code&gt; a bunch of times, except that it is only one keystroke and it happens faster. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap G :let @g='gj@q'&amp;lt;cr&amp;gt;@g&#xA;xnoremap G :&amp;lt;C-u&amp;gt;let @g='gj@q'&amp;lt;cr&amp;gt;@g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a side note, this will not move you to the first column, but the same column. You could always add &lt;code&gt;g0&lt;/code&gt; to the end, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap G :let @g='gj@q'&amp;lt;cr&amp;gt;@gg0&#xA;xnoremap G :&amp;lt;C-u&amp;gt;let @g='gj@q'&amp;lt;cr&amp;gt;@gg0&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I recommend going with the first option.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-08-02T18:30:35.150" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9051" PostTypeId="1" AcceptedAnswerId="9052" CreationDate="2016-08-02T19:21:58.687" Score="2" ViewCount="174" Body="&lt;p&gt;I'm hoping to create a &lt;a href=&quot;http://www.twilightlandscapes.com/IRAFtutorial/IRAFintro_04.html&quot; rel=&quot;nofollow&quot;&gt;.cl&lt;/a&gt; script to run in &lt;a href=&quot;http://iraf.noao.edu/&quot; rel=&quot;nofollow&quot;&gt;IRAF&lt;/a&gt;.  I have a list of spectra on which I want to run &lt;a href=&quot;http://stsdas.stsci.edu/cgi-bin/gethelp.cgi?dispcor&quot; rel=&quot;nofollow&quot;&gt;dispcor&lt;/a&gt;.  I was wondering if there's an easy way to paste the output file names with incrementing numbers.  The lines look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dispcor extracted_ori5_r1.0001.fits calibrated_ori5_r1.0001.fits&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want the output file name to increase (&lt;code&gt;.0001&lt;/code&gt;, &lt;code&gt;.0002&lt;/code&gt;, etc.).  Any help would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="8655" LastEditorUserId="54" LastEditDate="2016-08-02T19:29:09.020" LastActivityDate="2016-08-03T05:50:03.230" Title="Incrementing File Names" Tags="|visual-block|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9052" PostTypeId="2" ParentId="9051" CreationDate="2016-08-02T19:38:43.270" Score="3" Body="&lt;p&gt;Starting point:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dispcor extracted_ori5_r1.0001.fits calibrated_ori5_r1.0001.fits&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Start recording in register &lt;code&gt;a&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Yank the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yy&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Put it right under the current line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Move the cursor to the first &lt;code&gt;0001&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f.l&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Increment the number:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Move the cursor to the next &lt;code&gt;0001&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;;;l&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Increment again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Stop recording:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Play it back 23 times:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;23@a&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In short:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qayypf.l&amp;lt;C-a&amp;gt;;;l.q&#xA;23@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dispcor extracted_ori5_r1.0001.fits calibrated_ori5_r1.0001.fit&#xA;dispcor extracted_ori5_r1.0002.fits calibrated_ori5_r1.0002.fit&#xA;dispcor extracted_ori5_r1.0003.fits calibrated_ori5_r1.0003.fit&#xA;dispcor extracted_ori5_r1.0004.fits calibrated_ori5_r1.0004.fit&#xA;dispcor extracted_ori5_r1.0005.fits calibrated_ori5_r1.0005.fit&#xA;dispcor extracted_ori5_r1.0006.fits calibrated_ori5_r1.0006.fit&#xA;dispcor extracted_ori5_r1.0007.fits calibrated_ori5_r1.0007.fit&#xA;dispcor extracted_ori5_r1.0008.fits calibrated_ori5_r1.0008.fit&#xA;dispcor extracted_ori5_r1.0009.fits calibrated_ori5_r1.0009.fit&#xA;[...]&#xA;dispcor extracted_ori5_r1.0025.fits calibrated_ori5_r1.0025.fit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-02T19:38:43.270" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9053" PostTypeId="2" ParentId="9051" CreationDate="2016-08-02T20:16:12.073" Score="3" Body="&lt;p&gt;Here is a different solution.&#xA;Copy the line: &lt;code&gt;yy&lt;/code&gt;, paste 23 times: &lt;code&gt;23p&lt;/code&gt;, go to the &lt;strong&gt;second&lt;/strong&gt; line: &lt;code&gt;:2&lt;/code&gt;, Move to the &lt;code&gt;0001&lt;/code&gt;: &lt;code&gt;$F1&lt;/code&gt;, block select the range you want to be incremented &lt;code&gt;&amp;lt;ctrl&amp;gt;vGh&lt;/code&gt;, increment each number sequentially: &lt;code&gt;g&amp;lt;ctrl-a&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This needs a relative recent Vim, something like 7.4.1000 should do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the help at &lt;code&gt;:h g_Ctrl-A&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="2313" LastEditDate="2016-08-03T05:50:03.230" LastActivityDate="2016-08-03T05:50:03.230" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9054" PostTypeId="1" AcceptedAnswerId="9057" CreationDate="2016-08-02T20:37:37.790" Score="3" ViewCount="363" Body="&lt;p&gt;I'm working on a plugin and I use visual selections all the time in my code. Stuff like &lt;code&gt;normal! v{:call whatever()\&amp;lt;cr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that if the user does &lt;code&gt;gv&lt;/code&gt; in his file it won't select his last visual selection, but the last visual selection used by my plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there any way I can prevent that from happening?&lt;/p&gt;&#xA;" OwnerUserId="7642" LastActivityDate="2016-08-02T21:28:06.943" Title="Using visual mode without changing gv" Tags="|vimscript|visual-mode|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9055" PostTypeId="1" AcceptedAnswerId="9068" CreationDate="2016-08-02T20:40:26.540" Score="3" ViewCount="826" Body="&lt;p&gt;In insert mode I want &lt;kbd&gt;Backspace&lt;/kbd&gt; to delete the characters to the left of my cursor but it's acting just like &lt;kbd&gt;Del&lt;/kbd&gt; and removing characters under my cursor.  I saw somewhere I can use &lt;code&gt;ctrl-k&lt;/code&gt; then a key to see what VIM thinks that key is.  For &lt;kbd&gt;Backspace&lt;/kbd&gt; it's returning &lt;code&gt;&amp;lt;Del&amp;gt;&lt;/code&gt; and for &lt;kbd&gt;Del&lt;/kbd&gt; it's returning &lt;code&gt;&amp;lt;kDel&amp;gt;&lt;/code&gt;.  How can I get my &lt;kbd&gt;Backspace&lt;/kbd&gt; key to map to &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; like it should be?  In bash &lt;kbd&gt;Backspace&lt;/kbd&gt; is operating normally without me making any special changes.&#xA;In PuTTY &lt;kbd&gt;Backspace&lt;/kbd&gt; is set to &lt;code&gt;^?&lt;/code&gt; not &lt;code&gt;ctrl-h&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I tested vim with the &lt;code&gt;ctrl-h&lt;/code&gt; backspace setting and vim started working properly.. However I would prefer to leave that PuTTY setting alone unless someone can convince me switching to &lt;code&gt;ctrl-h&lt;/code&gt; is what I should do, I don't know much about why there are different key codes for backspace and maybe I'd be less hesitant to switch the default PuTTY setting if I knew more.&lt;/p&gt;&#xA;" OwnerUserId="8657" LastEditorUserId="8657" LastEditDate="2016-08-03T13:23:40.580" LastActivityDate="2016-08-08T17:33:12.550" Title="Physical backspace button mapped to &lt;Del&gt;" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="9057" PostTypeId="2" ParentId="9054" CreationDate="2016-08-02T21:28:06.943" Score="6" Body="&lt;p&gt;Based on the comments by @Tumbler41 and @ChristianBrabant I managed to do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:lastSelectionStart = getpos(&quot;'&amp;lt;&quot;)&#xA;let l:lastSelectionEnd = getpos(&quot;'&amp;gt;&quot;)&#xA;&#xA;&quot; My code...&#xA;&#xA;call setpos(&quot;'&amp;lt;&quot;, l:lastSelectionStart)&#xA;call setpos(&quot;'&amp;gt;&quot;, l:lastSelectionEnd)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7642" LastActivityDate="2016-08-02T21:28:06.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9058" PostTypeId="2" ParentId="8232" CreationDate="2016-08-02T21:36:39.230" Score="2" Body="&lt;p&gt;As pointed by &quot;Karl Yngve Lervåg&quot; in his comments, combining the answers of both &quot;Karl Yngve Lervåg&quot; and &quot;Antony&quot; gave me the desired result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, after opening the first .f90 file, you should use the below command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args ./**/*.f90 | argdo exe 'TOhtml' | wq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only trouble which I am still facing with the above method is: generated html files doesn't have colors of vim (except for the first .f90 file).&lt;/p&gt;&#xA;" OwnerUserId="8010" LastEditorUserId="8010" LastEditDate="2016-08-02T21:52:01.417" LastActivityDate="2016-08-02T21:52:01.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9059" PostTypeId="1" CreationDate="2016-08-02T22:49:19.350" Score="2" ViewCount="108" Body="&lt;p&gt;Today I learned that you can use &lt;code&gt;&amp;lt;C-_&amp;gt;&lt;/code&gt; in insert mode to toggle &quot;Reverse insert&quot; on and off, provided that &lt;code&gt;:set allowrevins&lt;/code&gt; is set. This sounds like a useful feature (Albeit an obscure and strange feature), so I would like to have it on. However, when I do this, it says &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- REVERSE INSERT Hebrew&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- REVERSE INSERT &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I hit&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i&amp;lt;C-_&amp;gt;Hello World!&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!dlrow olleH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Like I would expect, I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!âêøíW íêê÷H&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this the intended feature, or is it a bug? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix this? I suppose I could just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-_&amp;gt; &amp;lt;C-o&amp;gt;:set ri!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this seems kinda hacky.I'd prefer to just change some setting. Plus I'm still curious why it goes to Hebrew mode in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case it's relevant, this happened with version 7.4.1023 and 7.4.2066, both gvim on windows.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-08-02T22:49:19.350" Title="Why does reverse indent enter Hebrew?" Tags="|insert-mode|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9060" PostTypeId="2" ParentId="9028" CreationDate="2016-08-03T06:13:22.340" Score="0" Body="&lt;p&gt;you can use a big number like &lt;strong&gt;99999yy&lt;/strong&gt; to select all the content of your file&lt;/p&gt;&#xA;" OwnerUserId="8661" LastActivityDate="2016-08-03T06:13:22.340" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9061" PostTypeId="1" CreationDate="2016-08-03T09:44:58.633" Score="6" ViewCount="2896" Body="&lt;p&gt;Is there a way to open a &lt;a href=&quot;https://gnupg.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GnuPG&lt;/a&gt; encrypted file with &lt;code&gt;neovim&lt;/code&gt; so that one can read/edit it and on write the file is re-encrypted?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is possible via &lt;a href=&quot;https://github.com/jamessan/vim-gnupg&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-gnupg&lt;/a&gt; in classic &lt;code&gt;vim&lt;/code&gt; but &lt;a href=&quot;https://github.com/jamessan/vim-gnupg/issues/32&quot; rel=&quot;nofollow noreferrer&quot;&gt;has not been ported to neovim&lt;/a&gt;. I cannot use the &lt;code&gt;gpg-agent&lt;/code&gt; hack as I do not have &lt;code&gt;X11&lt;/code&gt; installed on the remote machine I wish to use this on.&lt;/p&gt;&#xA;" OwnerUserId="622" LastEditorUserId="15" LastEditDate="2017-05-18T17:20:27.823" LastActivityDate="2024-03-31T15:00:52.887" Title="GnuPG encrypted file editing with Neovim" Tags="|neovim|encryption|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9062" PostTypeId="1" CreationDate="2016-08-03T12:08:57.753" Score="1" ViewCount="531" Body="&lt;p&gt;It worked fine on my home pc, but it messes up colors on my working machine.&#xA;Here is my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;filetype off&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'FelikZ/ctrlp-py-matcher'&#xA;Plugin 'JulesWang/css.vim'&#xA;Plugin 'altercation/vim-colors-solarized'&#xA;Plugin 'ap/vim-css-color'&#xA;Plugin 'bronson/vim-trailing-whitespace'&#xA;Plugin 'cakebaker/scss-syntax.vim'&#xA;Plugin 'christoomey/vim-tmux-navigator'&#xA;Plugin 'gcorne/vim-sass-lint'&#xA;Plugin 'kien/ctrlp.vim'&#xA;Plugin 'mattn/emmet-vim'&#xA;Plugin 'mileszs/ack.vim'&#xA;Plugin 'mxw/vim-jsx'&#xA;Plugin 'othree/html5.vim'&#xA;Plugin 'othree/javascript-libraries-syntax.vim'&#xA;Plugin 'othree/yajs.vim'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'scrooloose/syntastic'&#xA;Plugin 'tpope/vim-surround'&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;&#xA;call vundle#end()&#xA;&#xA;filetype plugin on&#xA;filetype plugin indent on&#xA;&#xA;set autoread&#xA;set wildmenu&#xA;set ruler&#xA;set backspace=eol,start,indent&#xA;set whichwrap+=&amp;lt;,&amp;gt;,h,l&#xA;set lazyredraw&#xA;&#xA;set noerrorbells&#xA;set novisualbell&#xA;set t_vb=&#xA;set tm=500&#xA;&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;set smarttab&#xA;set expandtab&#xA;set smartindent&#xA;set autoindent&#xA;&#xA;set gdefault&#xA;set showmatch&#xA;set hlsearch&#xA;set incsearch&#xA;set ignorecase&#xA;&#xA;set ffs=unix,dos,mac&#xA;set fencs=utf-8,cp1251,koi8-r,ucs-2,cp866&#xA;&#xA;set relativenumber&#xA;set cursorline&#xA;set showcmd&#xA;set laststatus=2&#xA;set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l&#xA;&#xA;set nobackup&#xA;set noswapfile&#xA;&#xA;let NERDTreeShowHidden=1&#xA;let g:ctrlp_custom_ignore = 'vendor\|node_modules\|.git'&#xA;&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 1&#xA;let g:syntastic_javascript_checkers = ['eslint']&#xA;let g:syntastic_css_checkers = ['csslint']&#xA;let g:syntastic_sass_checkers = ['sass_lint']&#xA;let g:syntastic_scss_checkers = ['sass_lint']&#xA;let g:syntastic_php_checkers = ['php']&#xA;&#xA;let mapleader=&quot; &quot;&#xA;nnoremap &amp;lt;leader&amp;gt;g :CtrlP&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;f /&#xA;nnoremap &amp;lt;leader&amp;gt;F :Ack!&amp;lt;space&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;h :%s/&#xA;nnoremap &amp;lt;leader&amp;gt;o :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;&amp;lt;space&amp;gt; :noh&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;n :tabn&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;p :tabp&amp;lt;CR&amp;gt;&#xA;nnoremap j gj&#xA;nnoremap k gk&#xA;nnoremap &amp;lt;leader&amp;gt;j &amp;lt;C-]&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;k &amp;lt;C-O&amp;gt;&#xA;nnoremap &amp;lt;F4&amp;gt; :Ack! &amp;lt;cword&amp;gt;&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;F12&amp;gt; :!ctags -R --exclude=node_modules .&amp;lt;cr&amp;gt;&#xA;inoremap &amp;lt;Up&amp;gt; &amp;lt;NOP&amp;gt;&#xA;inoremap &amp;lt;Down&amp;gt; &amp;lt;NOP&amp;gt;&#xA;inoremap &amp;lt;Left&amp;gt; &amp;lt;NOP&amp;gt;&#xA;inoremap &amp;lt;Right&amp;gt; &amp;lt;NOP&amp;gt;&#xA;noremap &amp;lt;Up&amp;gt; &amp;lt;NOP&amp;gt;&#xA;noremap &amp;lt;Down&amp;gt; &amp;lt;NOP&amp;gt;&#xA;noremap &amp;lt;Left&amp;gt; &amp;lt;NOP&amp;gt;&#xA;noremap &amp;lt;Right&amp;gt; &amp;lt;NOP&amp;gt;&#xA;inoremap &amp;lt;C-h&amp;gt; &amp;lt;C-o&amp;gt;h&#xA;inoremap &amp;lt;C-j&amp;gt; &amp;lt;C-o&amp;gt;j&#xA;inoremap &amp;lt;C-k&amp;gt; &amp;lt;C-o&amp;gt;k&#xA;inoremap &amp;lt;C-l&amp;gt; &amp;lt;C-o&amp;gt;l&#xA;map &amp;lt;Leader&amp;gt;bg :let &amp;amp;background = ( &amp;amp;background == &quot;dark&quot;? &quot;light&quot; : &quot;dark&quot; )&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;s :StackOverflow&amp;lt;space&amp;gt;&#xA;set pastetoggle=&amp;lt;F2&amp;gt;&#xA;&#xA;syntax enable&#xA;syntax sync minlines=256&#xA;&#xA;set t_Co=256&#xA;set background=dark&#xA;colorscheme solarized&#xA;&#xA;&quot; Run these commands before startup&#xA;autocmd VimEnter * AirlineTheme solarized&#xA;autocmd BufWritePre * :%s/\s\+$//e&#xA;autocmd FileType php set omnifunc=phpcomplete#CompletePHP&#xA;autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS&#xA;autocmd FileType css set omnifunc=csscomplete#CompleteCSS&#xA;autocmd FileType html set omnifunc=htmlcomplete#CompleteTags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my .bashrc I export TERM=xterm-256color.&#xA;Am I missing something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: it happens both in and out of tmux, vim version - 7.4.576, terminal - bash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screenshot:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/QVAlW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QVAlW.png&quot; alt=&quot;screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem I'm trying to solve is cursorline and relativenumber column being black, should've clarified this earlier...&lt;/p&gt;&#xA;" OwnerUserId="6135" LastEditorUserId="10072" LastEditDate="2016-11-11T16:36:56.923" LastActivityDate="2016-11-11T16:36:56.923" Title="Solarized colorscheme is not displayed correctly (cursorline and relativenumber column)" Tags="|vimrc|colorscheme|plugin-vundle|plugin-solarized|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9063" PostTypeId="1" AcceptedAnswerId="9069" CreationDate="2016-08-03T12:49:54.383" Score="1" ViewCount="689" Body="&lt;p&gt;Currently I have the following maps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap J 5j&#xA;nmap K 5k&#xA;nmap L 5l&#xA;nmap H 5h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works great if I hit Shift j, it moves down for quick cursor movement. However if I let go of shift while holding j to go back to regular movement speed the cursor stops. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same is true for if I am moving slowly by holding j then hit shift to accelerate. It just stops. Any work around for this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I am using git bash in windows.&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As much as holding down keys is an anti pattern, some mornings I am not up to thinking harder to use better movements.&lt;/p&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="2695" LastEditDate="2016-08-03T14:00:19.537" LastActivityDate="2022-04-06T03:37:30.103" Title="How to make hjkl with shift more flexible?" Tags="|key-bindings|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9064" PostTypeId="1" AcceptedAnswerId="9066" CreationDate="2016-08-03T13:19:22.683" Score="13" ViewCount="2889" Body="&lt;p&gt;I was trying to migrate to neovim from vim. But in the end, there's some plugins which require python3 support and neovim package doesn't build with python3 by default( I'm on ubuntu, install neovim package according to the official documentation on the website ), finally I give up, it just seems complicated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but now the problem I'm facing that I need to switch back to vim. the major difference is the path to vim directory. in neovim, the path is &lt;code&gt;~/.config/nvim/&lt;/code&gt;, in vim, the path is &lt;code&gt;~/.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to keep the most part of my vimrc unchanged. So I would like to use some conditional statement to judge if the current vim is neovim or regular vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastActivityDate="2021-04-02T14:41:17.590" Title="Is there any way to distinguish between neovim and regular vim?" Tags="|vimscript|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9065" PostTypeId="1" AcceptedAnswerId="9067" CreationDate="2016-08-03T13:25:43.097" Score="4" ViewCount="512" Body="&lt;p&gt;I like always knowing where my cursor is. I do this by having it in the center line of the screen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if I am working at the top of the file the cursor stops centering because there is no more content above to display. This annoys me as sometimes I have to strain already tired eyes to find the blinking white blotch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the question is how would I automatically add visual white space (like the tildes ~ that populate the bottom) to the top of the file if I am at the start of file?&lt;/p&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="23502" LastEditDate="2023-08-30T14:01:38.277" LastActivityDate="2023-08-30T14:01:38.277" Title="How to center a cursor on the screen, even at the start of the file?" Tags="|cursor|navigation|whitespace|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9066" PostTypeId="2" ParentId="9064" CreationDate="2016-08-03T14:04:18.283" Score="17" Body="&lt;p&gt;Use &lt;a href=&quot;https://neovim.io/doc/user/nvim.html#nvim-from-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;if has('nvim')&lt;/code&gt;&lt;/a&gt; to detect if you're running Neovim.&lt;/p&gt;&#xA;&lt;p&gt;Note that, unlike Vim, Neovim doesn't have the language bindings built in.  They're provided by external plugins.  You would need to install the Python3 version of the neovim module, as described in &lt;a href=&quot;https://neovim.io/doc/user/provider.html#provider-python&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help provider-python&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="10604" LastEditDate="2021-04-02T14:41:17.590" LastActivityDate="2021-04-02T14:41:17.590" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9067" PostTypeId="2" ParentId="9065" CreationDate="2016-08-03T15:18:11.753" Score="4" Body="&lt;p&gt;&lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;z&lt;/kbd&gt; does what you want, sort of, but it doesn't work near the top of the file, nor near the bottom (when the file is too short).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is another way to keep track of the cursor, by highlighting cursor's line and column:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cursorline cursorcolumn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But there is a price to pay for it though, these settings can slow down scrolling for some &lt;code&gt;filetype&lt;/code&gt;s.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-08-03T15:18:11.753" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9068" PostTypeId="2" ParentId="9055" CreationDate="2016-08-03T15:55:32.947" Score="0" Body="&lt;p&gt;After reading through comments I came to the conclusion that this isn't an issue with vim that I can fix with &lt;code&gt;.vimrc&lt;/code&gt;  The server is expecting &lt;kbd&gt;Backspace&lt;/kbd&gt; to be &lt;code&gt;ctrl-h&lt;/code&gt; while PuTTY is set to &lt;code&gt;ctrl-?&lt;/code&gt; by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading the information &lt;a href=&quot;http://tartarus.org/~simon/putty-snapshots/htmldoc/Chapter4.html#config-backspace&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, particularly this: &lt;code&gt;If you do have the choice, we recommend configuring PuTTY to generate Control-? and configuring the server to expect it, because that allows applications such as emacs to use Control-H for help.&lt;/code&gt; I decided to change what the server is expecting instead of modifying PuTTy settings. (But the PuTTY setting could be changed instead)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the server to expect &lt;kbd&gt;Backspace&lt;/kbd&gt; to be &lt;code&gt;ctrl-?&lt;/code&gt; use the command &lt;code&gt;stty erase ^?&lt;/code&gt; I added this to my &lt;code&gt;.profile&lt;/code&gt; to have it automatically get set when I remote into the machine.&lt;/p&gt;&#xA;" OwnerUserId="8657" LastEditorUserId="8657" LastEditDate="2016-08-08T17:33:12.550" LastActivityDate="2016-08-08T17:33:12.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9069" PostTypeId="2" ParentId="9063" CreationDate="2016-08-03T20:00:52.107" Score="5" Body="&lt;p&gt;Instead of remapping, you should consider the other options for moving the cursor around, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C-D        Move the cursor Down one page (controlled by the 'scroll' option)&#xA;C-U        Move the cursor Up one page (controlled by the 'scroll' option)&#xA;M          Move the cursor to the Middle line of the window&#xA;H          Move the cursor to the Highest line of the window&#xA;L          Move the cursor to the Lowest line of the window&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, considering you know where you want to go (which is not the case all the time), take advantage of the &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;?&lt;/code&gt;, &lt;code&gt;G&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt; commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/pattern   Search for the next pattern    &#xA;?pattern   Search for the previous pattern   &#xA;NG         Go to line N   (Ngg does the same)&#xA;N%         Go to the Nth percentage of the file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are in a structured language, note the following commands that moves the cursor to the start/end of the following/previous function: &lt;code&gt;]m&lt;/code&gt;, &lt;code&gt;]M&lt;/code&gt;, &lt;code&gt;[m&lt;/code&gt;, &lt;code&gt;[M&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing some C/C++/... ? &lt;code&gt;[#&lt;/code&gt;, &lt;code&gt;]#&lt;/code&gt; jumps to conditional macros (&lt;code&gt;#if&lt;/code&gt;, &lt;code&gt;#else&lt;/code&gt;, ...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moving across &lt;code&gt;/* */&lt;/code&gt; comments? &lt;code&gt;[*&lt;/code&gt;, &lt;code&gt;]*&lt;/code&gt;, &lt;code&gt;[/&lt;/code&gt;, &lt;code&gt;]/&lt;/code&gt; are your friends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also jump to the next/previous &lt;code&gt;{}()&lt;/code&gt; with &lt;code&gt;[{&lt;/code&gt;,&lt;code&gt;[(&lt;/code&gt;, &lt;code&gt;]}&lt;/code&gt;, &lt;code&gt;])&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Soo, my point here is that you already have a lot of ways to move around in Vim (there's more than the little list I made). So I would suggest learning those ways before trying to remap core commands as &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt;.   &lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-08-03T20:00:52.107" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9070" PostTypeId="1" AcceptedAnswerId="9071" CreationDate="2016-08-03T20:49:51.787" Score="8" ViewCount="1033" Body="&lt;p&gt;I don't have much use for line numbers while in insert mode so I would like to turn them off. However they are great for normal mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Constantly using &lt;code&gt;set nu!&lt;/code&gt; is tiresome. Is there a way to tie &lt;code&gt;set nu!&lt;/code&gt; to exiting and entering normal mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any solutions using the above or any other method?&lt;/p&gt;&#xA;" OwnerUserId="2695" LastEditorUserId="2920" LastEditDate="2016-08-03T21:32:20.273" LastActivityDate="2016-08-04T11:42:10.157" Title="Set line numbers only while in normal mode" Tags="|insert-mode|normal-mode|line-numbers|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9071" PostTypeId="2" ParentId="9070" CreationDate="2016-08-03T21:31:13.820" Score="13" Body="&lt;p&gt;You can do this with autocommands.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au InsertEnter * set nonumber&#xA;au InsertLeave * set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not much explanation is needed. This does exactly what you asked for. It ties &quot;entering and exiting insert mode&quot; to &quot;turning line numbers on and off&quot;.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-08-03T21:31:13.820" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9072" PostTypeId="1" CreationDate="2016-08-04T05:13:21.557" Score="3" ViewCount="5697" Body="&lt;p&gt;below is my vimrc code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   &quot; widen or narrow a window&#xA;    nmap &amp;lt;M-l&amp;gt; 10&amp;lt;c-w&amp;gt;&amp;gt;&#xA;    nmap &amp;lt;M-h&amp;gt; 10&amp;lt;c-w&amp;gt;&amp;lt;&#xA;    &quot; increase of decrease the hight of a window&#xA;    nmap &amp;lt;M-j&amp;gt; 8&amp;lt;c-w&amp;gt;-&#xA;    nmap &amp;lt;M-k&amp;gt; 8&amp;lt;c-w&amp;gt;+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using kitty on window and ssh into an Ubuntu server. When I start neovim, the mapping is working correctly, but when I start normal vim, it just doesn't work at all, nothing happens. Below is the result when I run &lt;code&gt;vim --version&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug  3 2016 23:52:02)&#xA;Included patches: 1-2152&#xA;Compiled by i056958@mo-cebd4b858&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     -tcl&#xA;+balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;+browse          -footer          +multi_byte      +terminfo&#xA;++builtin_terms  +fork()          +multi_lang      +termresponse&#xA;+byte_offset     +gettext         -mzscheme        +textobjects&#xA;+channel         -hangul_input    -netbeans_intg   +timers&#xA;+cindent         +iconv           +num64           +title&#xA;+clientserver    +insert_expand   +packages        +toolbar&#xA;+clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        -perl            +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       +python          +vreplace&#xA;+cscope          +lispindent      -python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con_gui  +lua             +rightleft       +writebackup&#xA;+diff            +menu            +ruby            +X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;+dnd             +modify_fname    +signs           +xim&#xA;-ebcdic          +mouse           +smartindent     +xsmp_interact&#xA;+emacs_tags      +mouseshape      +startuptime     +xterm_clipboard&#xA;+eval            +mouse_dec       +statusline      -xterm_save&#xA;+ex_extra        +mouse_gpm       -sun_workshop    +xpm&#xA;+extra_search    -mouse_jsbterm   +syntax&#xA;+farsi           +mouse_netterm   +tag_binary&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio&#xA;-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/in&#xA;clude/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_&#xA;64-linux-gnu/glib-2.0/include -I/usr/include/freetype2   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic  -L/usr/local/lib -Wl,--as-needed -o vim&#xA; -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -l&#xA;freetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2  -L/usr/lib/python3/dist-p&#xA;ackages -lpython2.7   -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1276" LastActivityDate="2016-08-04T10:13:11.113" Title="Why alt key mapping not working in vim? but it works in neovim" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9073" PostTypeId="2" ParentId="9072" CreationDate="2016-08-04T08:14:22.253" Score="10" Body="&lt;p&gt;Historically, Alt and certain Ctrl keys cannot be reliably detected across all systems Vim runs on. Basically it depends on the terminal configuration how certain keys are passed on to Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, since keyboard handling internally uses the ASCII charset, it is not possible to distinguish e.g. between &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;H&lt;/kbd&gt; and &lt;kbd&gt;BS&lt;/kbd&gt; key, since by definition the backspace key is the same as &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;H&lt;/kbd&gt;. (The same holds true for &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;I&lt;/kbd&gt; and &lt;kbd&gt;Tab&lt;/kbd&gt;.) Therefore you often get the annoying behaviour when mapping the ctrl key, that the same mapping triggers when pressing another key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, historically, pressing &lt;kbd&gt;Alt&lt;/kbd&gt; was not an own key, but basically just toggled the high bit of the second character. e.g. the terminal would see &lt;kbd&gt;ALT&lt;/kbd&gt;-&lt;kbd&gt;a&lt;/kbd&gt; as &lt;code&gt;á&lt;/code&gt;, which means when you map &lt;kbd&gt;ALT&lt;/kbd&gt;-&lt;kbd&gt;a&lt;/kbd&gt; the same mapping would trigger when you press &lt;code&gt;á&lt;/code&gt;. However this also depends how your terminal was configured e.g. it is possible that pressing &lt;kbd&gt;ALT&lt;/kbd&gt; would send an escape sequence followed by the actual key. (This is btw. one of the reasons, why sometimes Vim waits a little after receiving an escape key to see, if there is another key coming). Also cursor keys usually send an &lt;code&gt;&amp;lt;escape&amp;gt;[&amp;lt;letter&amp;gt;&lt;/code&gt; sequence which is the reason, why those keys usually don't work in compatible mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make this easier, Vim includes several options to handle certain aspects of the input handling better, e.g. &lt;code&gt;esckeys&lt;/code&gt; option or the various &lt;code&gt;timeout&lt;/code&gt; settings or many of the terminal related &lt;code&gt;t_xx&lt;/code&gt; keycodes and some of them are even triggered with the &lt;code&gt;compatible/nocompatible&lt;/code&gt; setting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means however, that configuring Vim is really complex, since there are so many options and many depends on how your &lt;code&gt;$TERM&lt;/code&gt; variable is set and how your terminal is setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the graphical version, things look a lot better, and therefore it often works with Gvim, but on the console you are bound to whatever the terminal detects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together, this means, mapping  and  (in combination with &lt;code&gt;&amp;lt;shift&amp;gt;&lt;/code&gt;) is not reliably detected by Vim (or the terminal). And therefore, it is not recommended to use those keys for mapping. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the neovim guys have changed the input handling and rely on an extra library that is supposed to detect keys better in the terminal. This library was not available back in the days, when Vim was developed, therefore Vim does not use it (yet). I am not sure, if keyboard handling in the terminal is so much better in Neovim, at least I see a lot of keyboard related questions in the neovim bug tracker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also the faq &lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-20.4&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-20.5&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2016-08-04T10:13:11.113" LastActivityDate="2016-08-04T10:13:11.113" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9074" PostTypeId="2" ParentId="9070" CreationDate="2016-08-04T11:42:10.157" Score="5" Body="&lt;p&gt;Here's an alternative solution which will only hide the numbers, but won't actually change the margin on the left so you text doesn't jump around so much when entering/leaving insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number&#xA;&#xA;augroup number&#xA;    autocmd!&#xA;    autocmd InsertEnter * highlight LineNr ctermfg=white guifg=white&#xA;    autocmd InsertLeave * highlight LineNr ctermfg=130 guifg=Brown&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When entering insert mode this will set the text colour to the background colour. In my case this is white, but this may be different in your case. When we leave insert mode it resets it to the default for my colour scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find out the default for your colour scheme with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight LineNr&#xA;LineNr         xxx term=underline ctermfg=130 guifg=Brown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-08-04T11:42:10.157" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9076" PostTypeId="1" AcceptedAnswerId="9078" CreationDate="2016-08-04T17:25:28.660" Score="2" ViewCount="3107" Body="&lt;p&gt;To overwrite some formatoptions provided by my plugins I made &lt;code&gt;~/.vim/after/final.vim&lt;/code&gt; file and add this location to my $RUNTIMEPATH by putting these lines just after (vundle) plugins in my .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp-=~/.vim/after &#xA;set rtp+=~/.vim/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I check if it's OK by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set rtp?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is OK. ~/.vim/after is at the the end of the list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the &lt;code&gt;:h after-directory&lt;/code&gt; all *.vim files under ~/.vim/after should be loaded as a plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't work. When I type &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:scriptnames&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;there is nothing from my ~/.vim/after folder. What is going on?&lt;/p&gt;&#xA;" OwnerUserId="8444" LastActivityDate="2016-08-04T18:29:59.193" Title="after-directory is not loaded" Tags="|vimscript|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9077" PostTypeId="2" ParentId="6795" CreationDate="2016-08-04T18:00:54.490" Score="1" Body="&lt;p&gt;Your keyboard response can be different than you expect. For e.g. it can provide some special characters of your language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check out what your system does by pressing any combination:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ctrl+v&lt;/code&gt; in insert mode and then &lt;code&gt;option+k&lt;/code&gt; or &lt;code&gt;alt+k&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the output symbol in your vimrc mapping instead of &lt;code&gt;&amp;lt;M-k&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;WARNING: this method is rough - symbols depend on system, terminal ect. So you have to put in your .vimrc conditions like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;gui_running&quot;)&#xA;    if has(&quot;x11&quot;)&#xA;        &amp;lt;map_command_here&amp;gt;&#xA;    if has(&quot;gui_gtk2&quot;)&#xA;        &amp;lt;map_command_here&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or to detect systems (OS X) like &lt;a href=&quot;https://stackoverflow.com/questions/2842078/how-do-i-detect-os-x-in-my-vimrc-file-so-certain-configurations-will-only-appl&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8444" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-08-04T18:14:42.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9078" PostTypeId="2" ParentId="9076" CreationDate="2016-08-04T18:29:59.193" Score="5" Body="&lt;p&gt;First, you don't need to add &lt;code&gt;~/.vim/after/&lt;/code&gt; to &lt;code&gt;runtimepath&lt;/code&gt; as it's already part of the default value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, the content of &lt;code&gt;~/.vim/after/&lt;/code&gt; is supposed to match the structure found in &lt;code&gt;/usr/share/vim/vim7x/&lt;/code&gt; and &lt;code&gt;~/.vim/&lt;/code&gt; so, for your &lt;code&gt;final.vim&lt;/code&gt; to be sourced like a plugin, you only need to put it where it belongs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ~/.vim/after/plugin/final.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'runtimepath'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-04T18:29:59.193" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9079" PostTypeId="1" AcceptedAnswerId="9172" CreationDate="2016-08-04T18:33:36.317" Score="6" ViewCount="2555" Body="&lt;p&gt;Using &lt;a href=&quot;https://github.com/junegunn/fzf&quot; rel=&quot;noreferrer&quot;&gt;FZF&lt;/a&gt; in Vim, is it possible to search project directory and a library directory?  For example when executing FZF, it would search directories:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/project/&lt;/code&gt; and &lt;code&gt;~/libs/include&lt;/code&gt;, and provide results.&lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="51" LastEditDate="2016-08-07T14:42:25.613" LastActivityDate="2016-08-12T09:45:50.010" Title="VIM FZF, searching multiple directories" Tags="|plugin-fzf|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9080" PostTypeId="1" CreationDate="2016-08-04T23:24:02.357" Score="7" ViewCount="2129" Body="&lt;p&gt;I'm trying to create a custom key mapping which start bring up commandline mode with some text inserted. I would like to have the cursor position not at the end but in a specific position, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/|/nextposition/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;|&lt;/code&gt; represents the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be perfect if the cursor could be positioned to the &lt;code&gt;nextposition&lt;/code&gt; place if user types &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; or some other key stroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="51" LastEditDate="2016-08-08T02:19:37.350" LastActivityDate="2016-08-08T02:19:37.350" Title="How to predefine the cursor position in command?" Tags="|key-bindings|command-line|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9081" PostTypeId="1" AcceptedAnswerId="9097" CreationDate="2016-08-04T23:30:19.763" Score="13" ViewCount="8805" Body="&lt;p&gt;When writing to a file, I often accidentally type &lt;code&gt;:wq&lt;/code&gt; instead of &lt;code&gt;:w&lt;/code&gt; since the two keys are right next to each other. But since I almost always have more than one buffer open, Vim stays up and whatever file I just closed stays in the list of buffers (&lt;code&gt;:ls&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is sometimes a lot of work to reopen the file manually. And worse, sometimes I don't even remember the file name of what I just edited! So I have to pore over &lt;code&gt;:ls&lt;/code&gt; and try to remember.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to &quot;reopen&quot; the most recently closed window?&lt;/p&gt;&#xA;" OwnerUserId="8683" LastActivityDate="2016-08-06T02:54:38.030" Title="Reopen the most recently closed buffer" Tags="|buffers|tabbed-user-interface|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9082" PostTypeId="1" AcceptedAnswerId="9084" CreationDate="2016-08-05T00:57:10.163" Score="1" ViewCount="3238" Body="&lt;p&gt;I have a following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   &amp;lt;a href=&quot;/episodes/show-invisibles/&quot;&amp;gt; Show invisibles: http://vimcasts.org/episodes/show-invisibles/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;..and I have a &lt;code&gt;:s/\v^[^\&amp;gt;]+\&amp;gt;\s//g&lt;/code&gt; substitution command which changes this line to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Show invisibles: http://vimcasts.org/episodes/show-invisibles/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As I understand the regular expression of this substitution, then &lt;code&gt;^[^\&amp;gt;]+\&amp;gt;\s&lt;/code&gt; part will match one or more whatever character(except &lt;code&gt;&amp;gt;&lt;/code&gt;) from the beginning of the line until &lt;code&gt;&amp;gt;&lt;/code&gt; and whitespace character appear. However, why is the &lt;code&gt;\v&lt;/code&gt; needed? According to vim manual:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Use of &quot;\v&quot; means that in the pattern after it all ASCII characters except&#xA;'0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning.  &quot;very magic&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, why is this needed in this particular case?&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2016-08-05T02:11:26.573" Title="understand the need of &quot;\v&quot; in substitution" Tags="|substitute|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9083" PostTypeId="2" ParentId="9081" CreationDate="2016-08-05T02:06:31.910" Score="1" Body="&lt;p&gt;Not the exact solution but a rather popular one is the &lt;a href=&quot;https://github.com/yegappan/mru&quot; rel=&quot;nofollow&quot;&gt;MRU plugin&lt;/a&gt; by &lt;em&gt;yegappan&lt;/em&gt;.  It provides you with a temporary window (just like a &lt;code&gt;quickfix&lt;/code&gt; window) that contains the name and path of the current files and recently closed files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After you close the a file with &lt;code&gt;:wq&lt;/code&gt; and swear that you should not have done it, you can do &lt;code&gt;:MRC&lt;/code&gt; and a temporary window opens.  It allows for opening/reopening the files present in this temporary window in different ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; opens the file in the current window (or different window if there are non-written changes in the current window).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&lt;/code&gt; opens the file in a new window always&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;t&lt;/code&gt; opens the file in a new tab&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-08-05T02:06:31.910" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9084" PostTypeId="2" ParentId="9082" CreationDate="2016-08-05T02:11:26.573" Score="9" Body="&lt;p&gt;In this particular case, using &lt;code&gt;\v&lt;/code&gt; doesn't make much difference&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/^[^&amp;gt;]\+&amp;gt;\s//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is perhaps cleaner than using the very magic modifier&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Consider swapping two words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\(\w\+\) \(\w\+\)/\2 \1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;\v&lt;/code&gt; it is much cleaner and readable&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\v(\w+) (\w+)/\2 \1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So, it might be a habit to always use &lt;code&gt;\v&lt;/code&gt; and it is closer to regular expression syntax used in &lt;code&gt;perl&lt;/code&gt;, &lt;code&gt;sed -r&lt;/code&gt;, &lt;code&gt;awk&lt;/code&gt; etc&lt;/p&gt;&#xA;" OwnerUserId="1616" LastActivityDate="2016-08-05T02:11:26.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9085" PostTypeId="2" ParentId="9081" CreationDate="2016-08-05T07:29:10.537" Score="11" Body="&lt;p&gt;You can try &lt;code&gt;CTRL-O&lt;/code&gt;, this will go to last cursor posision in jump list, even for closed buffers. This will even work from fresh vim instance, so you can open last file with that.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-08-05T07:29:10.537" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9086" PostTypeId="2" ParentId="9080" CreationDate="2016-08-05T07:41:01.677" Score="9" Body="&lt;p&gt;You can use that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :s//nextposition/g&amp;lt;c-b&amp;gt;&amp;lt;right&amp;gt;&amp;lt;right&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mapping will first go into command mode: &lt;code&gt;:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then write &lt;code&gt;s//nextposition/g&lt;/code&gt; in the command lines&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go to the beginning of the command &lt;code&gt;&amp;lt;c-b&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And move to the desired position: &lt;code&gt;&amp;lt;right&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some interesting command line mappings can be found here: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#cmdline-editing&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h cmdline-editing&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now about the part where you want to move the cursor to another place with &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; it is something that you can do in insert mode with a snippet engine like UltiSnips but I'm not sure you can make it work in command line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also not exactly related but Damian Conway has two pretty interesting mappings described in his &lt;a href=&quot;http://howivim.com/2016/damian-conway/&quot; rel=&quot;noreferrer&quot;&gt;how I vim&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First he says that to simplify his substitutions he created the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap  S  :%s//g&amp;lt;LEFT&amp;gt;&amp;lt;LEFT&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So he can press &lt;code&gt;S&lt;/code&gt; and then just &lt;code&gt;pattern/replacement&lt;/code&gt; to do the substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then to improve it he created the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;expr&amp;gt;  M  ':%s/' . @/ . '//g&amp;lt;LEFT&amp;gt;&amp;lt;LEFT&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way he can make a search &lt;code&gt;/pattern&lt;/code&gt;, see the results and simply type &lt;code&gt;M&lt;/code&gt; followed by the replacement string and the pattern is automatically added to the substitution command. &lt;em&gt;(Note that it is convenient to see the pattern in the command but doing &lt;code&gt;:%s//replacement/g&lt;/code&gt; will also use the last search pattern)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that it is not what OP is asking for but I thought it could be an inspiration source.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-08-05T08:07:09.180" LastActivityDate="2016-08-05T08:07:09.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9088" PostTypeId="1" CreationDate="2016-08-05T08:20:01.350" Score="1" ViewCount="191" Body="&lt;p&gt;I use Vim 7.4.2149 and the plugin &lt;a href=&quot;https://github.com/pangloss/vim-javascript&quot; rel=&quot;nofollow&quot;&gt;pangloss/vim-javascript&lt;/a&gt; for js indentation. I need to get comments like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; *&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But instead I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;     *&#xA;     *&#xA;     */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not really interested in syntax so I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I tried these settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;formatoptions=croql&#xA;comments=s1:/*,mb:*,ex:*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What should I do to get the comment formatting I'm looking for.&lt;/p&gt;&#xA;" OwnerUserId="8686" LastEditorUserId="51" LastEditDate="2016-08-08T02:10:42.523" LastActivityDate="2016-08-08T02:10:42.523" Title="Indentation in three piece comments in javascript" Tags="|formatting|comments|filetype-javascript|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9089" PostTypeId="1" CreationDate="2016-08-05T13:18:56.377" Score="7" ViewCount="535" Body="&lt;p&gt;Let's say that I have a file containing several occurrences of the word &lt;code&gt;foo&lt;/code&gt; and several&#xA;occurrences of the word &lt;code&gt;bar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to make all the words &lt;code&gt;foo&lt;/code&gt; become &lt;code&gt;bar&lt;/code&gt; and inversely all the words&#xA;&lt;code&gt;bar&lt;/code&gt; become &lt;code&gt;foo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the most efficient way to do that?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My first thought was to make it 3 steps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First make &lt;code&gt;bar&lt;/code&gt; become something temporary: &lt;code&gt;%s/bar/barTEMP/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Then make &lt;code&gt;foo&lt;/code&gt; become &lt;code&gt;bar&lt;/code&gt;: &lt;code&gt;:%s/foo/bar/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Finally substitute &lt;code&gt;barTEMP&lt;/code&gt;: &lt;code&gt;:%s/barTEMP/foo/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It is an implementation of a classical algorithm to switch the value of two&#xA;variables but is there a more efficient way to do this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I know I can write a function to do the 3 substitutions for me but&#xA;what I'm wondering is if there is a different method than using a temporary&#xA;substitution. For example I was thinking maybe something could be done by using&#xA;an &lt;code&gt;|&lt;/code&gt; in the search pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(foo\|bar\)/???/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that would require to make the replacement string change depending on the&#xA;actually matched word and I don't know how to do that. &lt;em&gt;(Note that this idea is&#xA;just an example, if someone come up with something better that would be nice&#xA;too)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-10-27T16:22:36.040" Title="What is the most efficient way to invert two words?" Tags="|substitute|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9090" PostTypeId="2" ParentId="9089" CreationDate="2016-08-05T14:29:28.613" Score="15" Body="&lt;p&gt;Posting this so it can have an answer on our SE, but &lt;a href=&quot;https://stackoverflow.com/questions/765894/can-i-substitute-multiple-items-in-a-single-regular-expression-in-vim-or-perl/766093#766093&quot;&gt;this&lt;/a&gt; is this source with full explanation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a good way to use a single regex to do multiple substitutions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/foo\|bar/\={'foo':'bar','bar':'foo'}[submatch(0)]/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help sub-replace-expression&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#Dictionary&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help Dictionary&lt;/code&gt;&lt;/a&gt; for Vim's documentation on how this works.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-10-27T16:22:36.040" LastActivityDate="2017-10-27T16:22:36.040" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9091" PostTypeId="2" ParentId="9089" CreationDate="2016-08-05T17:05:39.883" Score="2" Body="&lt;p&gt;For vanilla vim, &lt;a href=&quot;https://vi.stackexchange.com/questions/9089/what-is-the-most-efficient-way-to-invert-two-words/9090#9090&quot;&gt;Tumbler41's answer&lt;/a&gt; is probably the best way to go. If you are OK with installing plugins, you could use &lt;a href=&quot;https://github.com/tpope/vim-abolish&quot; rel=&quot;nofollow noreferrer&quot;&gt;tpope/vim-abolish&lt;/a&gt; to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin supplies &lt;em&gt;many&lt;/em&gt; awesome feature, but the relevant one for this case is called &quot;Subvert&quot; (abbreviated to &lt;code&gt;:%S&lt;/code&gt;. Essentially, it allows you to create a list of matches, and a list of replacements. I like the example from the README on the plugin, so I'll use that. If you want to change &quot;child&quot; to &quot;adult&quot;, while simultaneously changing &quot;children&quot; to &quot;adults&quot;, that is a single subvert command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%S/child{,ren}/adult{,s}/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your case, you could do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%S/{foo,bar}/{bar,foo}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One important note about this approach is that it doesn't support regexes very well, and it defaults to case-sensitive, so it would also change &quot;FOO&quot; to &quot;BAR&quot;.  However, for simple substitutions, this approach is very simple and convenient.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-08-09T20:33:10.727" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9092" PostTypeId="1" AcceptedAnswerId="9093" CreationDate="2016-08-05T17:50:26.533" Score="4" ViewCount="27312" Body="&lt;p&gt;I would like to replace every instance of &lt;code&gt;...&lt;/code&gt; with the string &lt;code&gt;\ldots&lt;/code&gt;, but both strings contain special characters. I have tried &lt;code&gt;:%s/\&amp;lt;...\&amp;gt;/\ldots&lt;/code&gt; but this searches for all three character words and seemingly replaces them with &quot;dots&quot;. How can I do this correctly? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="8691" LastEditorUserId="2920" LastEditDate="2016-08-05T19:10:31.493" LastActivityDate="2016-08-05T19:10:31.493" Title="Search and replace with multiple special characters" Tags="|substitute|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9093" PostTypeId="2" ParentId="9092" CreationDate="2016-08-05T17:58:52.593" Score="5" Body="&lt;p&gt;I'm not positive as you're a little vague on the details, but I believe the problem stems from the fact that &lt;code&gt;\l&lt;/code&gt; is not interpreted literally. Use &lt;code&gt;\\l&lt;/code&gt; to get a literal &lt;code&gt;\l&lt;/code&gt; in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a search and replace a &lt;code&gt;\l&lt;/code&gt; will make the next character lowercase. To avoid this we escape the backslash with another backslash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second problem is that &lt;code&gt;.&lt;/code&gt; in regex stands for any character. So, in fact &lt;code&gt;\&amp;lt;...\&amp;gt;&lt;/code&gt; will search for any three character word as you've described. As Sato Katusura suggests, use &lt;code&gt;\.\.\.&lt;/code&gt; to get three dots.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-08-05T18:04:27.603" LastActivityDate="2016-08-05T18:04:27.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9094" PostTypeId="2" ParentId="3814" CreationDate="2016-08-05T18:29:44.373" Score="2" Body="&lt;p&gt;Inspired by @PeterRincker's &lt;a href=&quot;https://vi.stackexchange.com/a/3820/8692&quot;&gt;answer&lt;/a&gt;, I crafted the following to use ATX style headers.  Add it to the end of your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;# Folding&#xA;&#xA;&quot; Fold with ATX style headers - &quot;# is H1, &quot;## is H2, and so on&#xA;&quot; vim:fdm=expr:fdl=0&#xA;&quot; vim:fde=getline(v\:lnum)=~'^&quot;#'?'&amp;gt;'.(matchend(getline(v\:lnum),'&quot;#*')-1)\:'='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8692" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2016-08-05T18:29:44.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9095" PostTypeId="2" ParentId="9092" CreationDate="2016-08-05T19:09:57.247" Score="4" Body="&lt;p&gt;Tumbler41's answer is a great explanation of why your approach doesn't work. Here's another solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the &quot;magic&quot; flag. This tells vim which characters should be treated as special and which ones should not. If you specify &quot;Nomagic&quot; with &lt;code&gt;\V&lt;/code&gt;, than only the backslash character will be special.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\V.../\\ldots/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help magic&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3. Magic                            */magic*&#xA;&#xA;Some characters in the pattern are taken literally.  They match with the same&#xA;character in the text.  When preceded with a backslash however, these&#xA;characters get a special meaning.&#xA;&#xA;Other characters have a special meaning without a backslash.  They need to be&#xA;preceded with a backslash to match literally.&#xA;&#xA;                            */\v* */\V*&#xA;Use of &quot;\v&quot; means that in the pattern after it all ASCII characters except&#xA;'0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning.  &quot;very magic&quot;&#xA;&#xA;Use of &quot;\V&quot; means that in the pattern after it only the backslash and the&#xA;terminating character (/ or ?) has a special meaning.  &quot;very nomagic&quot;&#xA;&#xA;Examples:&#xA;after:      \v       \m       \M         \V       matches&#xA;             $       $        $          \$       matches end-of-line&#xA;             .       .        \.         \.       matches any character&#xA;             *       *        \*         \*       any number of the previous atom&#xA;             ~       ~        \~         \~       latest substitute string&#xA;             ()      \(\)     \(\)       \(\)     grouping into an atom&#xA;             |       \|       \|         \|       separating alternatives&#xA;             \a      \a       \a         \a       alphabetic character&#xA;             \\      \\       \\         \\       literal backslash&#xA;             \.      \.       .          .        literal dot&#xA;             \{      {        {          {        literal '{'&#xA;             a       a        a          a        literal 'a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-08-05T19:09:57.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9097" PostTypeId="2" ParentId="9081" CreationDate="2016-08-06T02:54:38.030" Score="12" Body="&lt;p&gt;I played around with this a bit and the following seems to work for the cases I tested, including closing a window split and a tab with one window using &lt;code&gt;:q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup bufclosetrack&#xA;  au!&#xA;  autocmd WinLeave * let g:lastWinName = @%&#xA;augroup END&#xA;function! LastWindow()&#xA;  exe &quot;split &quot; . g:lastWinName&#xA;endfunction&#xA;command -nargs=0 LastWindow call LastWindow()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This creates an autocommand in a new augroup (only need to put it in a group if you risk loading the script file multiple times) to run just before the cursor leaves a window (see &lt;code&gt;:help WinLeave&lt;/code&gt;), which includes closing a window, be it just a split or the last window in a tab, closing the tab. We set this to occur on &lt;em&gt;any&lt;/em&gt; buffer name by using th &lt;code&gt;*&lt;/code&gt;. Then we set the action save the file name of that window into a global variable, we'll call &lt;code&gt;g:lastWinName&lt;/code&gt;, but you could use any variable name you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we create a function that will split the current window, giving the split command the value of the variable we saved to. This is done by concatenating the string &lt;code&gt;&quot;split &quot;&lt;/code&gt; with the variable &lt;code&gt;g:lastWinName&lt;/code&gt; using the &lt;code&gt;.&lt;/code&gt; operator. The &lt;code&gt;exe&lt;/code&gt; command executes the resulting string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you accidentally close a window or tab, then, you can call the LastWindow command as &lt;code&gt;:LastWindow&lt;/code&gt;, which calls a function which will open a new split on that last file name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Caveats:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if you accidentally change window (just moving cursor to another window for example) after you close a window, this won't recover the closed window&lt;/li&gt;&#xA;&lt;li&gt;If you have vim change its working directory based on the path of the file for the active buffer, this will probably fail (likewise if you change directory manually after the window is closed)&lt;/li&gt;&#xA;&lt;li&gt;Using this after closing a tabfull of windows (e.g. using &lt;code&gt;:tabc&lt;/code&gt;) results in the save called multiple times. Running LastWindow only restores one of them (whichever Vim actually closed last)&lt;/li&gt;&#xA;&lt;li&gt;This only restores the buffer by name; none of the other window information is restored (e.g. window size, position in buffer, window local settings, etc)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Possible future improvements:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It might be possible to track the buffer number of the window before it closes and track that; that should solve the problem with changing directory&lt;/li&gt;&#xA;&lt;li&gt;Some window settings could be copied to other variables and restored on function call&lt;/li&gt;&#xA;&lt;li&gt;Other commands/functions in a similar vein could allow other methods of restoration, e.g. to open in a new tab instead of a new split&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="227" LastActivityDate="2016-08-06T02:54:38.030" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9098" PostTypeId="2" ParentId="9079" CreationDate="2016-08-06T04:03:03.930" Score="-1" Body="&lt;p&gt;FZF will search the total pwd. If pwd is &lt;code&gt;~&lt;/code&gt;, both directories &lt;code&gt;~/project/&lt;/code&gt; and &lt;code&gt;~/libs/include&lt;/code&gt; will be searched.&lt;/p&gt;&#xA;" OwnerUserId="8702" LastEditorUserId="51" LastEditDate="2016-08-07T14:41:41.033" LastActivityDate="2016-08-07T14:41:41.033" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9099" PostTypeId="2" ParentId="24" CreationDate="2016-08-06T04:15:17.237" Score="2" Body="&lt;pre&gt;&lt;code&gt;&quot; Quickly edit/reload this configuration file&#xA;nnoremap gev :e $MYVIMRC&amp;lt;CR&amp;gt;&#xA;nnoremap gsv :so $MYVIMRC&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To &lt;strong&gt;automatically&lt;/strong&gt; reload upon save, add the following to your &lt;code&gt;$MYVIMRC&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has ('autocmd') &quot; Remain compatible with earlier versions&#xA; augroup vimrc     &quot; Source vim configuration upon save&#xA;    autocmd! BufWritePost $MYVIMRC source % | echom &quot;Reloaded &quot; . $MYVIMRC | redraw&#xA;    autocmd! BufWritePost $MYGVIMRC if has('gui_running') | so % | echom &quot;Reloaded &quot; . $MYGVIMRC | endif | redraw&#xA;  augroup END&#xA;endif &quot; has autocmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then for the last time, type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:so %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The next time you save your &lt;code&gt;vimrc&lt;/code&gt;, it will be automatically reloaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Features:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Tells the user what has happened (also logging to &lt;code&gt;:messages&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Handles various names for the configuration files&lt;/li&gt;&#xA;&lt;li&gt;Ensures that it wil only match the actual configuration file (ignores copies in other directories, or a &lt;code&gt;fugitive://&lt;/code&gt; diff)&lt;/li&gt;&#xA;&lt;li&gt;Won't generate an error if using &lt;code&gt;vim-tiny&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Of course, the automatic reload will only happen if you edit your &lt;code&gt;vimrc&lt;/code&gt; in vim.&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2016-09-02T14:26:07.110" LastActivityDate="2016-09-02T14:26:07.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9100" PostTypeId="1" AcceptedAnswerId="9101" CreationDate="2016-08-06T13:15:33.813" Score="4" ViewCount="118" Body="&lt;p&gt;I would like to set some options for all things I will read but not modify. &#xA;That is special settings for read-only files (and files in vim view mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Particularly I'm interested in &lt;code&gt;setlocal wrap&lt;/code&gt; for read-only files.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I know that for special type files (like quickfix) I can use &lt;a href=&quot;https://vi.stackexchange.com/questions/2843/how-to-automatically-set-wrapping-for-quickfix-window&quot;&gt;autocmd&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8444" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2018-10-03T10:50:31.910" Title="Permission dependent behavior" Tags="|vimrc|autocmd|wrapping|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9101" PostTypeId="2" ParentId="9100" CreationDate="2016-08-06T13:32:09.883" Score="5" Body="&lt;p&gt;I think, you can use an &lt;code&gt;BufEnter&lt;/code&gt; autocommand, that checks, whether the file is modifiable. Something like this should work (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup ReadOnly&#xA;    au!&#xA;    au BufEnter *  if (!&amp;amp;modifiable || &amp;amp;ro) | setl wrap | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-08-06T13:32:09.883" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9102" PostTypeId="1" AcceptedAnswerId="9103" CreationDate="2016-08-06T14:23:38.160" Score="2" ViewCount="219" Body="&lt;p&gt;I was very excited to see the relative line number feature in vim. Now vertical navigation would be a breeze, and instead of typing huge numbers, I can simply do &lt;code&gt;10j&lt;/code&gt; to move 10 lines down. However,  after doing some research, it seems this way of &quot;moving down&quot; (I wont call it jumping) is not remembered or placed in the jumplist. My question is if there is a way for me to have this mechanism placed there so I could remember my previous cursor locations. Is there a plugin that might assist in this matter?&lt;/p&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="2920" LastEditDate="2016-08-06T18:27:01.827" LastActivityDate="2016-08-07T22:51:03.573" Title="ctrl+o and ctrl+i don't work with line skip motion 10j" Tags="|cursor-movement|macvim|jumplist|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9103" PostTypeId="2" ParentId="9102" CreationDate="2016-08-06T18:44:28.740" Score="6" Body="&lt;p&gt;You don't need a plugin, all you need is two lines of vimscript!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like &lt;em&gt;every&lt;/em&gt; time you press 'j' or 'k' to be added to the jumplist, this is pretty easy. You could do it with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; j :&amp;lt;C-u&amp;gt;exe &quot;normal! m'&quot;.v:count1.&quot;j&quot;&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; k :&amp;lt;C-u&amp;gt;exe &quot;normal! m'&quot;.v:count1.&quot;k&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Essentially, this just makes it so when you press &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt;, vim act as if you had pressed &lt;code&gt;m'&lt;/code&gt; right before the &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt;. &lt;code&gt;m'&lt;/code&gt; is just adds your current location to the jumplist. From &lt;code&gt;:help m'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *m'* *m`*&#xA;m'  or  m`      Set the previous context mark.  This can be jumped to&#xA;            with the &quot;''&quot; or &quot;``&quot; command (does not move the&#xA;            cursor, this is not a motion command).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it could be obnoxious to have &lt;em&gt;every single time&lt;/em&gt; you press &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt; to be added to the jumplist. We can make it be added to the jumplist &lt;em&gt;only&lt;/em&gt; if you provide a count.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; k :&amp;lt;C-U&amp;gt;execute 'normal!' (v:count &amp;gt; 1 ? &quot;m'&quot; . v:count : '') . 'k'&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; j :&amp;lt;C-U&amp;gt;execute 'normal!' (v:count &amp;gt; 1 ? &quot;m'&quot; . v:count : '') . 'j'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is more convenient, since it will not clutter up your jumplist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How it works:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So first, the obvious part. &lt;code&gt;nnoremap k&lt;/code&gt; means, &quot;When I press 'k', act as if I had typed this instead&quot;. The &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; is just to prevent messages from being echoed when the command is executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, on the righthand side, we have &lt;code&gt;:&amp;lt;C-U&amp;gt;execute 'normal!' (v:count &amp;gt; 1 ? &quot;m'&quot; . v:count : '') . 'k'&amp;lt;CR&amp;gt;&lt;/code&gt;. The &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; is needed for any mapping involving ex commands. You can read about what it does &lt;a href=&quot;https://stackoverflow.com/questions/13830874/onoremap-vim-c-u-purpose&quot;&gt;here&lt;/a&gt;. Now, the &lt;code&gt;execute&lt;/code&gt; command allows us to execute a string as an ex command, and &lt;code&gt;&quot;'normal!' (v:count &amp;gt; 1 ? &quot;m'&quot; . v:count : '') . 'k'&amp;lt;CR&amp;gt;&quot;&lt;/code&gt; evaluates to a string. &lt;code&gt;v:count&lt;/code&gt; is a special variable that vim sets when you call a mapping with a count. So, for example, if you type &lt;code&gt;2j&lt;/code&gt;, it will set &lt;code&gt;v:count&lt;/code&gt; to equal 2. Using the ternary operator, which you should be familiar with if you've done much programming, is used to evaluate this whole expression to either &lt;code&gt;normal! m'&amp;lt;n&amp;gt;k&lt;/code&gt; if count is greater than 0, or &lt;code&gt;normal! k&lt;/code&gt; if it is not.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Credit goes to &lt;a href=&quot;https://superuser.com/questions/539708/vim-moving-around-using-relativenumber-and-adding-it-to-the-jump-list-for-use-w&quot;&gt;this super user thread&lt;/a&gt;!&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-08-07T22:51:03.573" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9104" PostTypeId="1" CreationDate="2016-08-06T21:54:17.353" Score="2" ViewCount="837" Body="&lt;p&gt;I have been experimenting with colours for my statusline recently and I put the plugin file in the &lt;code&gt;bundle&lt;/code&gt; directory. I use &lt;code&gt;pathogen&lt;/code&gt; which loads everything up from that directory. But, Even though the status line plugin is getting sourced, the colours are not appearing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I manually source the file from GVim it adds all the colours but its not doing this automatically when the plugin loads up. This is happening only in Gvim. Vim in Powershell and Cygwin that use the same plugin show the statusline colours properly when they start up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be the reason for this and what can I change in the plugin to get it working in gvim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I have the following line for the colorscheme in my &lt;code&gt;gvimrc&lt;/code&gt;, when I remove it from gvimrc and add it in &lt;code&gt;vimrc&lt;/code&gt;, everything works fine. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Github link for the plugin's source - &lt;a href=&quot;https://github.com/durgaswaroop/vim-streamline&quot; rel=&quot;nofollow&quot;&gt;Vim Streamline&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="5481" LastEditDate="2016-08-08T06:59:47.353" LastActivityDate="2016-08-08T07:21:17.130" Title="Gvim : Statusline is loading but not its colours" Tags="|gvim|statusline|plugin-pathogen|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9107" PostTypeId="2" ParentId="8931" CreationDate="2016-08-08T00:54:07.073" Score="4" Body="&lt;p&gt;The way built-in types are declared is very simple. From &lt;code&gt;/usr/share/vim/vim74/syntax/c.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword     cType           int long short char void&#xA;syn keyword     cType           signed unsigned float double&#xA;&quot; [..etc..]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then later on it sets a highlight group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi def link cType               Type&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adding to this syntax group is easy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn keyword cType type1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or is you want a different highlight group, use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn keyword cTypeCustom type1&#xA;:hi def link cTypeCustom MyType&#xA;:hi MyType ctermfg=darkblue guifg=darkblue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The trick here is to let Vim know &lt;em&gt;which&lt;/em&gt; custom types are yours. You &lt;em&gt;could&lt;/em&gt; &quot;regex it&quot;, but it seems to me that a far better and more robust solution would be to actually parse the C files and generate this information. It should be fairly easy to get this information with clang (this &lt;a href=&quot;http://amnoid.de/tmp/clangtut/tut.html&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt;) might help), you could then make this program write to &lt;code&gt;~/.vim/after/syntax/c.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-08-08T00:54:07.073" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9108" PostTypeId="2" ParentId="8692" CreationDate="2016-08-08T01:31:48.283" Score="3" Body="&lt;p&gt;Aside from the other answers, there is actually a way built right in to Vim: &lt;code&gt;&amp;lt;C-x&amp;gt;s&lt;/code&gt;. This will use Vim's insert mode completion menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;code&gt;&amp;lt;C-x&amp;gt;s&lt;/code&gt; from insert mode should correct the word under the cursor to the first suggestion and show the completion menu with further suggestions (if any). You can use the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27completeopt%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'completeopt'&lt;/code&gt;&lt;/a&gt; setting to customise some settings for the completion menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a bit annoying that this only works from insert mode and using using &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-s&amp;gt;&lt;/code&gt; can be problematic (see the note below), so you can define your own mapping for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-@&amp;gt;  pumvisible() ?  &quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;C-x&amp;gt;s&quot;&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-@&amp;gt; pumvisible() ?  &quot;i\&amp;lt;C-n&amp;gt;&quot; : &quot;i\&amp;lt;C-x&amp;gt;s&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-@&amp;gt;&lt;/code&gt; is Control + Space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#ins%2dcompletion&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ins-completion&lt;/code&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL%2dX_s&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-X_s&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I personally use a more advanced version which will &quot;guess&quot; if we want to either spell check the work, or use regular auto-completion for code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! GuessType()&#xA;    &quot; Use omnicomplete for Go&#xA;    if &amp;amp;filetype == 'go'&#xA;        let l:def = &quot;\&amp;lt;C-x&amp;gt;\&amp;lt;C-o&amp;gt;&quot;&#xA;    &quot; Keyword complete for anything else&#xA;    else&#xA;        let l:def = &quot;\&amp;lt;C-x&amp;gt;\&amp;lt;C-n&amp;gt;&quot;&#xA;    endif&#xA;&#xA;    &quot; If we have spell suggestions for the current word, use that. Otherwise use&#xA;    &quot; whatever we figured out above.&#xA;    try&#xA;        if spellbadword()[1] != ''&#xA;            return &quot;\&amp;lt;C-x&amp;gt;s&quot;&#xA;        else&#xA;            return l:def&#xA;        endif&#xA;    catch&#xA;        return l:def&#xA;    endtry&#xA;endfun&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-@&amp;gt;  pumvisible() ?  &quot;\&amp;lt;C-n&amp;gt;&quot; : GuessType()&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Down&amp;gt; pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;Down&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Up&amp;gt; pumvisible() ? &quot;\&amp;lt;C-p&amp;gt;&quot; : &quot;\&amp;lt;Up&amp;gt;&quot;&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-@&amp;gt; pumvisible() ?  &quot;i\&amp;lt;C-n&amp;gt;&quot; : 'i' . GuessType()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I believe there are also some plugins which do roughly similar things (like SuperTab, which is fairly popular), but I could never get them to behave as I want to.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;: If you are using Vim from a terminal, then &lt;code&gt;&amp;lt;C-s&amp;gt;&lt;/code&gt; will mean &quot;stop output&quot;. This is why both &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-s&amp;gt;&lt;/code&gt; &lt;em&gt;and&lt;/em&gt; &lt;code&gt;&amp;lt;C-x&amp;gt;s&lt;/code&gt; are mapped by default. Use &lt;code&gt;&amp;lt;C-q&amp;gt;&lt;/code&gt; to continue output if you press &lt;code&gt;&amp;lt;C-s&amp;gt;&lt;/code&gt; by accident. You can also disable &lt;code&gt;&amp;lt;C-s&amp;gt;&lt;/code&gt; if you don't use it (see &lt;a href=&quot;https://vi.stackexchange.com/q/2419/51&quot;&gt;this question&lt;/a&gt;). If you are using GVim you can ignore this.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-08-08T01:31:48.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9109" PostTypeId="1" AcceptedAnswerId="9112" CreationDate="2016-08-08T01:58:08.840" Score="0" ViewCount="651" Body="&lt;p&gt;I have tagbar installed and for javascript files I'm using jsctags to generate tags. It's working perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can use &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; in tagbar to jump to a tag. But what I want is an ex command to search tags with a pattern. If it's found, then it should jump to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="51" LastEditDate="2016-08-08T06:57:07.680" LastActivityDate="2016-08-08T06:57:07.680" Title="How to search and jump to tag without going to window of tagbar?" Tags="|tags|plugin-tagbar|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9110" PostTypeId="2" ParentId="6906" CreationDate="2016-08-08T02:03:50.257" Score="1" Body="&lt;p&gt;Here is a better method which will preserve all highlighting inside triple-quoted strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region  pythonString matchgroup=pythonTripleQuotes &#xA;      \ start=+[uU]\=\z('''\|&quot;&quot;&quot;\)+ end=&quot;\z1&quot; keepend fold&#xA;      \ contains=pythonEscape,pythonSpaceError,pythonDoctest,@Spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add this to &lt;code&gt;~/.vim/after/syntax/python.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command is taken exactly from &lt;code&gt;/usr/share/vim/vim74/syntax/python.vim&lt;/code&gt; and only has the &lt;code&gt;fold&lt;/code&gt; keyword added. Why does this preserve highlighting when Dan's answer doesn't? The key is that this has:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;contains=pythonEscape,pythonSpaceError,pythonDoctest&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Normally, Vim applies only &lt;em&gt;one&lt;/em&gt; syntax region, but with &lt;code&gt;contains=&lt;/code&gt; you can tell it that a syntax region can &lt;em&gt;contain&lt;/em&gt; other syntax regions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also highlighted as a &lt;code&gt;String&lt;/code&gt; because it does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HiLink pythonString           String&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just defining a &lt;em&gt;syntax region&lt;/em&gt; is not enough, you need to link this to a &lt;em&gt;highlight group&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-08-08T02:03:50.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9112" PostTypeId="2" ParentId="9109" CreationDate="2016-08-08T05:46:31.080" Score="3" Body="&lt;p&gt;Vim comes with a complete set of commands and options for using tags. You can read all about it in &lt;code&gt;:help tags&lt;/code&gt; (the generic stuff) and &lt;code&gt;:help ctags&lt;/code&gt; (the ctags-specific stuff that also applies to jsctags).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But your plugin doesn't use any of those commands and settings and don't even use an actual &lt;code&gt;tags&lt;/code&gt; file so you have an hyper-specialized plugin &lt;em&gt;and&lt;/em&gt; a built-in mechanism that work in largely overlapping silos. This means that you have to learn two different systems instead of just one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My advice (as a &quot;senior&quot; front end developer and as an experienced vimmer) is to not use that plugin and rely entirely on built-in features. This will make your life a lot easier and your coding faster.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-08T05:46:31.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9113" PostTypeId="2" ParentId="9104" CreationDate="2016-08-08T07:07:07.353" Score="4" Body="&lt;p&gt;The problem is that there are various scenarios in which Vim will reload the colour scheme such as using &lt;code&gt;:colorscheme&lt;/code&gt; or &lt;code&gt;:syntax enable&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Colour schemes should always start with &lt;code&gt;:highlight clear&lt;/code&gt; to clear all existing highlight groups. Why? See what happens when you do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight Test ctermfg=red&#xA;:highlight Test ctermbg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is &lt;code&gt;Test&lt;/code&gt; now set to?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To fix this, you should always hook in to the &lt;code&gt;ColorScheme&lt;/code&gt; autocommand when you define highlight groups:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:highlight()&#xA;    highlight Foo ctermbg=red&#xA;endfun&#xA;&#xA;augroup myplugin_highlight&#xA;  autocmd!&#xA;  autocmd ColorScheme * call s:highlight()&#xA;augroup end&#xA;call s:highlight()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used a function because we want to run this &lt;em&gt;both&lt;/em&gt; on startup &lt;em&gt;and&lt;/em&gt; when the &lt;code&gt;ColorScheme&lt;/code&gt; autocommand is fired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a bit ugly, but it's the only way.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The reason this breaks when putting &lt;code&gt;colorscheme&lt;/code&gt; inside gvimrc, but not vimrc, is because of the load order. In &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#startup&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help startup&lt;/code&gt;&lt;/a&gt; we can see that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Loading the vimrc is step 3&lt;/li&gt;&#xA;&lt;li&gt;Loading plugins is step 4&lt;/li&gt;&#xA;&lt;li&gt;Loading gvimrc is step 8.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So the gvimrc file will override plugins, but vimrc won't. This is also why you shouldn't put things like &lt;code&gt;g:some_plugin_setting&lt;/code&gt; in the gvimrc file.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-08-08T07:21:17.130" LastActivityDate="2016-08-08T07:21:17.130" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9114" PostTypeId="1" AcceptedAnswerId="9119" CreationDate="2016-08-08T10:10:48.390" Score="1" ViewCount="811" Body="&lt;p&gt;How do I get &lt;a href=&quot;https://github.com/tmm1/ripper-tags&quot; rel=&quot;nofollow&quot;&gt;ripper-tags&lt;/a&gt; to automatically generate a &lt;code&gt;tags&lt;/code&gt; file for my ruby buffers upon save?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2016-08-08T16:06:10.333" LastActivityDate="2016-08-08T16:35:05.817" Title="How do I automatically generate a tags file with ripper-tags for ruby?" Tags="|tags|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9115" PostTypeId="1" AcceptedAnswerId="9116" CreationDate="2016-08-08T10:38:40.670" Score="0" ViewCount="268" Body="&lt;p&gt;In my &lt;a href=&quot;https://github.com/gfarrell/dotfiles/blob/master/vim/vimrc&quot; rel=&quot;nofollow&quot;&gt;vimrc&lt;/a&gt; I have a shortcut for opening a vertical split:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = ','&#xA;map &amp;lt;leader&amp;gt;v :vsplit&amp;lt;CR&amp;gt; &quot; ,v for vsplit&#xA;map &amp;lt;leader&amp;gt;s :split&amp;lt;CR&amp;gt;  &quot; ,s for split&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has been working fine for months, but recently it's started misbehaving: almost every time I try to split the window, it does split but then changes a load of text at the cursor and leaves itself in &lt;em&gt;insert&lt;/em&gt; mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;before split&lt;/strong&gt;: &lt;code&gt;const queryValidation&lt;/code&gt;&lt;br&gt;&#xA;&lt;strong&gt;after split&lt;/strong&gt;: &lt;code&gt;plit&quot;,                   n&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All that I did was hit &lt;code&gt;,v&lt;/code&gt; which has been working fine until recently. I can't work out why this is happening now. My vim version is &lt;strong&gt;7.4.2109&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This doesn't happen if I just use &lt;code&gt;:vsplit&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="8713" LastEditorUserId="21" LastEditDate="2016-08-09T06:38:46.110" LastActivityDate="2016-08-09T06:38:46.110" Title="Vertical split keymap suddenly broken" Tags="|key-bindings|split|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9116" PostTypeId="2" ParentId="9115" CreationDate="2016-08-08T10:46:48.847" Score="5" Body="&lt;p&gt;You should not use end-of-line comments, in particular for mappings. See &lt;code&gt;:h comment&lt;/code&gt;. Also, I suggest that you use &lt;code&gt;nnoremap&lt;/code&gt; instead of simply &lt;code&gt;map&lt;/code&gt;. Thus, you should use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;v :vsplit&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;s :split&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-08-08T10:46:48.847" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9118" PostTypeId="1" CreationDate="2016-08-08T16:04:35.987" Score="18" ViewCount="5593" Body="&lt;p&gt;I'm a little puzzled about some default values in Vim.&#xA;In particular, for &lt;code&gt;gq{motion}&lt;/code&gt;, is said that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[...]&#xA;If the 'textwidth' option is 0, the formatted line&#xA;length is the screen width (with a maximum width of&#xA;79).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought that it should have made more sense if it would have set the max width to &lt;code&gt;80&lt;/code&gt;, instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone enlighten me about this?&#xA;I guess I'm missing something.&lt;/p&gt;&#xA;" OwnerUserId="4670" LastEditorUserId="4670" LastEditDate="2016-08-08T16:18:58.460" LastActivityDate="2021-09-07T10:22:54.790" Title="Why Vim sets max text width to 79 instead of 80?" Tags="|formatting|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="9119" PostTypeId="2" ParentId="9114" CreationDate="2016-08-08T16:28:36.390" Score="4" Body="&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; I don't have ripper-tags installed, this is my best guess on browsing the documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the documentation it says that the typical usage is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ripper-tags -R --exclude=vendor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This parses all &lt;code&gt;*.rb&lt;/code&gt; files in the current project, excluding ones in &lt;code&gt;vendor/&lt;/code&gt; directory, and saves tags in Vim format to a file named &lt;code&gt;./tags&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Using this with an autocmd on save I would get something like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.rb !ripper-tags -R --exclude=vendor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;autocmd BufWritePost&lt;/code&gt; Sets up an auto command to do something everytime we write to a file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;*.rb&lt;/code&gt; Only execute on ruby files (.rb extension)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;!...&lt;/code&gt; Executes following command in a shell&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Put this line in your &lt;code&gt;vimrc&lt;/code&gt; file to enable the auto command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h BufWritePost&lt;/code&gt; and &lt;code&gt;:h !&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-08-08T16:35:05.817" LastActivityDate="2016-08-08T16:35:05.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9120" PostTypeId="1" CreationDate="2016-08-08T20:15:38.137" Score="7" ViewCount="2642" Body="&lt;p&gt;I'm trying to configure vim for python development. Right now I'm working on code autocompletion feature. I'm using YouCompleteMe plugin and it seems to be working great but only when I've already imported given module. For example, if I type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import datetime&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;datetime.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get list of available classes/modules/functions etc.&#xA;What I'm missing is the possibility to get module suggestions when writing import statements. Datetime module seem to be trivial in this case, so I use Django framework as an example. I'd like to achieve something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from django.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;lists all modules within django, I choose one of them, e.g.  views&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from django.views.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;lists all modules within django.views, I choose e.g. generic&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from django.views.generic import&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then I'd like to have autocompletion of classes, functions, variables available from this module e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from django.views.generic import TemplateView&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you have any suggestion how this can be achieved?&lt;/p&gt;&#xA;" OwnerUserId="8722" LastActivityDate="2017-03-25T16:47:12.700" Title="Python imports autocompletion" Tags="|autocompletion|plugin-you-complete-me|filetype-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9121" PostTypeId="1" CreationDate="2016-08-09T02:41:41.313" Score="1" ViewCount="805" Body="&lt;p&gt;I very often want to do the following or similar:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;indent all lines from previous position to current position inclusive&lt;/li&gt;&#xA;&lt;li&gt;repeat, repeat, repeat (to further indent the same lines)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I feel I should be able to do that by saying:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;''...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(greater-than single-quote single-quote period period period).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work.  The first &lt;code&gt;&amp;gt;''&lt;/code&gt; successfully indents the desired lines,&#xA;but then &quot;previous position&quot; is lost, and each &lt;code&gt;.&lt;/code&gt; only indents the current line&#xA;(which is always the &lt;em&gt;first&lt;/em&gt; of the desired lines, for some reason,&#xA;no matter whether I started at the beginning or end of the desired lines).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, instead, my recipe for indent-and-repeat is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'' if necessary to get to first line to be indented&#xA;ma to mark it &quot;a&quot;&#xA;'' to get to last line to be indented&#xA;mb to mark it &quot;b&quot;&#xA;&amp;gt;'a to indent from mark &quot;a&quot; to current position (mark &quot;b&quot;)&#xA;&amp;gt;'b to do it again (since the &amp;gt;'a moved me to mark &quot;a&quot; for some reason)&#xA;&amp;gt;'b to do it again (since the &amp;gt;'b did *not* move me to mark &quot;b&quot; for some reason)&#xA;&amp;gt;'b to do it again&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, to indent the lines 4 times and retain ability to jump to previous position, I say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;''ma''mb&amp;gt;'a&amp;gt;'b&amp;gt;'b&amp;gt;'b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of simply the following which doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;''...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is WAY more time and effort and mental burden than I would like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative workaround, still awful, and loses &quot;previous position&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;''&#xA;look for something like &quot;63 lines &amp;gt;ed 1 time&quot;, and type that number:&#xA;63&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make &lt;code&gt;&amp;gt;''...&lt;/code&gt; work as I would like it to?&#xA;Perhaps by some clever rebinding of the &lt;code&gt;&amp;gt;&lt;/code&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Requirement: &lt;code&gt;&amp;gt;''&lt;/code&gt; must indent the lines &lt;em&gt;without&lt;/em&gt; changing the current or previous&#xA;cursor position (regardless of whether &lt;code&gt;''&lt;/code&gt; refers to earlier or later in the file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Requirement: &lt;code&gt;.&lt;/code&gt; must do the same, as must subsequent &lt;code&gt;.&lt;/code&gt;'s.&lt;/p&gt;&#xA;" OwnerUserId="2065" LastEditorUserId="2065" LastEditDate="2016-08-09T07:27:10.963" LastActivityDate="2016-08-09T08:22:44.417" Title="repeat indent-to-previous-position in vim?" Tags="|indentation|repeated-commands|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9122" PostTypeId="2" ParentId="6307" CreationDate="2016-08-09T04:47:04.910" Score="1" Body="&lt;p&gt;You must have &lt;code&gt;set showcmd&lt;/code&gt; &lt;strong&gt;after&lt;/strong&gt; &lt;code&gt;set nocompatible&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible &#xA;set showcmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know the reason but i faced the same problem and this worked with me.&lt;/p&gt;&#xA;" OwnerUserId="8728" LastEditorUserId="1841" LastEditDate="2016-08-09T07:00:07.443" LastActivityDate="2016-08-09T07:00:07.443" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9123" PostTypeId="2" ParentId="9121" CreationDate="2016-08-09T07:39:30.057" Score="2" Body="&lt;p&gt;After your first &lt;code&gt;&amp;gt;''&lt;/code&gt; you can do &lt;code&gt;&amp;gt;']&lt;/code&gt; to indent the last changed lines, which can be repeated with &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not quite &lt;code&gt;&amp;gt;''...&lt;/code&gt;, but &lt;code&gt;&amp;gt;''&amp;gt;']..&lt;/code&gt; is certainly better than &lt;code&gt;''ma''mb&amp;gt;'a&amp;gt;'b&amp;gt;'b&amp;gt;'b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could use visual mode and this fairly common mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;gt; &amp;gt;gv&#xA;xnoremap &amp;lt; &amp;lt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and simply do &lt;code&gt;v''&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-08-09T07:43:39.210" LastActivityDate="2016-08-09T07:43:39.210" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9124" PostTypeId="2" ParentId="9121" CreationDate="2016-08-09T08:22:44.417" Score="3" Body="&lt;p&gt;Similar to &lt;a href=&quot;https://vi.stackexchange.com/a/9123/343&quot;&gt;romainl's suggestion&lt;/a&gt;, but without the mapping, I would do this by using one extra keystroke to enter visual mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v''&amp;gt;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-08-09T08:22:44.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9125" PostTypeId="1" AcceptedAnswerId="9164" CreationDate="2016-08-09T15:07:04.317" Score="2" ViewCount="145" Body="&lt;p&gt;I've noticed that when using the &lt;code&gt;complete()&lt;/code&gt; function if I backspace out of it, vim will go into &quot;Whole line completion&quot; mode. This is very frustrating as it makes things very sluggish when working with big files. Worse yet, I don't know of a good way to get out of that mode aside from backing out to normal mode. &lt;code&gt;:h complete_CTRL-E&lt;/code&gt; says to use &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; to get out and return to the original text, but that will actually delete the rest of the line in my case. I've prepared an MCVE to demonstrate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set backspace=2&#xA;&#xA;autocmd CursorMovedI * call CheckConversions(expand('&amp;lt;cword&amp;gt;'))&#xA;&#xA;function! CheckConversions(word)&#xA;   let firstColumn = col('.') - strlen(a:word)&#xA;   if (a:word =~ '\&amp;lt;foo')&#xA;      call complete(firstColumn, ['foo', 'foobar', 'foobarbar'])&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try typing &quot;bar foo&quot;. The completion popup shows up. So far so good. Now backspace. The popup goes away and now &lt;code&gt;-- Whole line completion (^L^N^P) Back at original&lt;/code&gt; shows at the bottom. Now press &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt;. The whole line is now replaced with &quot;fo&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't figure out why &quot;Whole line completion&quot; mode is even starting in the first place! Is this a bug, or is this somehow intended? I'd like to either not trigger this mode, or have a good way of getting out of it without having to leave insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Context to avoid XY problem: I'm writing a plugin that will detect when typing numbers and automatically give base conversion suggestions in the complete() menu. I've got it working pretty well except for this annoying bug that makes backspacing a pain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Version is: 7.4.0. Tested using gVim and vim on Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit2: Guess I'll try on &lt;code&gt;vim_dev&lt;/code&gt;. I'll update here if I find anything out.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-08-11T15:23:33.567" LastActivityDate="2016-08-11T20:44:27.673" Title="Strange behavior from the complete() function" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9126" PostTypeId="1" CreationDate="2016-08-09T19:34:40.120" Score="2" ViewCount="91" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/mhinz/vim-grepper&quot; rel=&quot;nofollow&quot;&gt;vim-grepper&lt;/a&gt; plugin, but I guess it doesn't really matter.&#xA;What I want is when I'm searching for something inside my project via vim-grepper or some grepprg if there are matches inside opened files they would be highlighted as if I was searched for them with &lt;code&gt;/some search&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6489" LastEditDate="2016-08-09T19:40:08.617" LastActivityDate="2016-08-09T19:48:39.033" Title="Is there a way to highlight searches done with grepprg?" Tags="|search|the-silver-searcher|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9128" PostTypeId="1" AcceptedAnswerId="9129" CreationDate="2016-08-09T23:14:45.863" Score="3" ViewCount="3508" Body="&lt;p&gt;I have written two functions two select inner and outer indent levels, which work perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I tried to use vim scoping alà &lt;code&gt;function scope#name&lt;/code&gt;, which sadly doesn't seem to work in my case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;silent&amp;gt; iz :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;sick#iz_motion(0)&amp;lt;cr&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; az :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;sick#iz_motion(&amp;amp;tabstop)&amp;lt;cr&amp;gt;                     &#xA;vnoremap &amp;lt;silent&amp;gt; iz :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;sick#iz_motion(0)&amp;lt;cr&amp;gt;                            &#xA;vnoremap &amp;lt;silent&amp;gt; az :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;sick#iz_motion(&amp;amp;tabstop)&amp;lt;cr&amp;gt;    &#xA;&#xA;function s:sick#iz_motion(margin)                                                     &#xA;  let l:cur_indent = indent(line(&quot;.&quot;))                                                &#xA;  while indent(line('.') - 1) &amp;gt;= l:cur_indent - a:margin                              &#xA;    \ &amp;amp;&amp;amp; getline(line('.') - 1) != ''                                                 &#xA;    execute 'normal k'                                                                &#xA;  endwhile                                                                            &#xA;&#xA;  execute &quot;normal V&quot;  &#xA;  while indent(line('.') + 1) &amp;gt;= l:cur_indent - a:margin                              &#xA;    \ &amp;amp;&amp;amp; getline(line('.') + 1) != ''                                                 &#xA;    execute 'normal j'                                                                &#xA;  endwhile                                                                            &#xA;endfunction                 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2016-08-10T00:51:10.363" Title="Having scoped script functions" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9129" PostTypeId="2" ParentId="9128" CreationDate="2016-08-10T00:51:10.363" Score="12" Body="&lt;p&gt;You can't mix the &lt;code&gt;s:&lt;/code&gt; prefix and the autoload syntax. Doing so would make no sense: the &lt;code&gt;s:&lt;/code&gt; prefix is designed to limit the scope to the current script, while the autoload syntax with &lt;code&gt;#&lt;/code&gt; is designed for autoloading exported functions (that is, functions that are available outside the current script).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use either just &lt;code&gt;s:name&lt;/code&gt; (if you only need it to be available from the current script) or &lt;code&gt;filename#name&lt;/code&gt; (if you want to call it from other scripts). Since you're using it in a mapping, you need to export it; so you'll have to use the autoload syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#write%2dlibrary%2dscript&quot;&gt;&lt;code&gt;:help write-library-script&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#local%2dfunction&quot;&gt;&lt;code&gt;:help local-function&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-08-10T00:51:10.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9130" PostTypeId="1" AcceptedAnswerId="9132" CreationDate="2016-08-10T01:05:36.503" Score="3" ViewCount="912" Body="&lt;p&gt;I use a mix of buffers and split panes to manage my workflow. Sometimes, I (perhaps accidentally) open a directory listing instead of a file. My buffers may look like this then:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jh2CM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jh2CM.png&quot; alt=&quot;directory listing&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point, I can &lt;code&gt;:bnext&lt;/code&gt; or &lt;code&gt;:bprevious&lt;/code&gt; to bounce between my buffers, but when in the directory listing I cannot &lt;code&gt;:bp  &amp;lt;BAR&amp;gt;&lt;/code&gt; as I would normally to close a buffer and I'm seemingly stuck with this awkward buffer that I can't remove. (I have these all &lt;code&gt;nmap&lt;/code&gt;ed in some capacity, FWIW)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, my habits should get me to use &lt;code&gt;CTRL+P&lt;/code&gt; more to search for files, but sometimes I find this method of file traversal useful, so understanding the proper way to manage these would be superb.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="8745" LastEditorUserId="7700" LastEditDate="2016-08-10T07:07:01.083" LastActivityDate="2016-08-10T07:07:01.083" Title="How do I properly manage a directory listing within a buffer?" Tags="|buffers|netrw|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9131" PostTypeId="1" AcceptedAnswerId="9133" CreationDate="2016-08-10T01:50:07.540" Score="11" ViewCount="9212" Body="&lt;p&gt;I want to change cursors to a &lt;code&gt;|&lt;/code&gt; character in insert mode, and then back to a block in normal mode. I am using urxvt as my terminal, and neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To switch cursors in my terminal, I run the following to get a blinking I-beam&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo -e &quot;\033[5 q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then to go to a solid block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo e &quot;\033[1 q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried this in my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;t_SI = &quot;\033[1 q&quot;&#xA;let &amp;amp;t_SR = &quot;\033[5 q&quot;&#xA;let &amp;amp;t_EI = &quot;\033[5 q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it didn't work. Nothing different from normal happens when I enter and exit insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried this in my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;autocmd&quot;)&#xA;  au InsertEnter * silent execute &quot;!print -n -- '\033[1 q'&quot;&#xA;  au InsertLeave * silent execute &quot;!print -n -- '\033[3 q'&quot;&#xA;  au VimLeave * silent execute &quot;!print -n -- '\033[5 q'&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I enter insert mode with this, the editor shifts up one line, and the status bar is shown twice at the bottom. When I exit insert mode, I see the text &lt;code&gt;[3 q&lt;/code&gt; below the statusbar. Any ideas? Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some links that I tried:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://bbs.archlinux.org/viewtopic.php?id=177281&quot; rel=&quot;noreferrer&quot;&gt;https://bbs.archlinux.org/viewtopic.php?id=177281&lt;/a&gt;&#xA;&lt;a href=&quot;https://bbs.archlinux.org/viewtopic.php?id=155802&quot; rel=&quot;noreferrer&quot;&gt;https://bbs.archlinux.org/viewtopic.php?id=155802&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8746" LastEditorUserId="1841" LastEditDate="2016-11-15T08:31:00.833" LastActivityDate="2016-11-15T08:31:00.833" Title="I can't switch to | cursor in insert mode" Tags="|vimrc|neovim|insert-mode|cursor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9132" PostTypeId="2" ParentId="9130" CreationDate="2016-08-10T02:20:50.500" Score="4" Body="&lt;p&gt;What you call a directory listing is actually a special buffer with type &lt;code&gt;netrw&lt;/code&gt;.  It is created by a plugin also called &lt;code&gt;netrw&lt;/code&gt;. Your issue probably stems from the fact that &lt;code&gt;netrw&lt;/code&gt; (with the default listing) creates &lt;em&gt;several&lt;/em&gt; hidden buffers, one for each directory listing you pass through, i.e. every time you change directory a new hidden buffer is created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But your question is about how to &lt;em&gt;manage&lt;/em&gt; the directory listing. &lt;code&gt;netrw&lt;/code&gt; can be opened from within Vimin different ways, and, probably, at least one of these ways will prove more useful to your workflow.  You can open &lt;code&gt;netrw&lt;/code&gt; with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:Explore&lt;/code&gt;: The default,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:Hexplore&lt;/code&gt;: In a horizontal split,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:Lexlplore&lt;/code&gt;: Left split that can be used as a toggle,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:Sexplore&lt;/code&gt;: Horizontal split using the current's file CWD,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:Vexplore&lt;/code&gt;: As &lt;code&gt;Sexplore&lt;/code&gt; but in a vertical split.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:Texplore&lt;/code&gt;: In a new tab.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And there is also &lt;code&gt;:Rexplore&lt;/code&gt; which returns the current window to a previous buffer that is not a &lt;code&gt;netrw&lt;/code&gt; buffer.  In other words, you can use &lt;code&gt;:Rex&lt;/code&gt; to exit from the directory listing into the closest regular buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet, I'd definitely suggest to you to explore (pun intended) the other options of running the &lt;code&gt;netrw&lt;/code&gt; listing.  Personally I find:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:22Lexplore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To be extremely useful.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Extra note: &lt;code&gt;netrw&lt;/code&gt; has several global variables that can be set inside your &lt;code&gt;vimrc&lt;/code&gt; to customize how the listing looks and behaves.  See &lt;code&gt;:help netrw&lt;/code&gt; for an extensive list.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-08-10T02:20:50.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9133" PostTypeId="2" ParentId="9131" CreationDate="2016-08-10T03:34:42.570" Score="13" Body="&lt;p&gt;Neovim does not use &lt;code&gt;vimrc&lt;/code&gt; it uses &lt;code&gt;$XDG_CONFIG_PATH/nvim/init.vim&lt;/code&gt;.  Yet, there is more to it.  In Vim you should use &lt;code&gt;\&amp;lt;esc&amp;gt;&lt;/code&gt; to represent the escape key.  I can change the cursor on Arch Linux on &lt;code&gt;urxvt&lt;/code&gt; with the following in my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;t_SI = &quot;\&amp;lt;esc&amp;gt;[5 q&quot;&#xA;let &amp;amp;t_SR = &quot;\&amp;lt;esc&amp;gt;[5 q&quot;&#xA;let &amp;amp;t_EI = &quot;\&amp;lt;esc&amp;gt;[2 q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also tried the &lt;code&gt;autocmd&lt;/code&gt; technique and it works.  Instead of the previous three lines I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au InsertEnter * silent execute &quot;!echo -en \&amp;lt;esc&amp;gt;[5 q&quot;&#xA;au InsertLeave * silent execute &quot;!echo -en \&amp;lt;esc&amp;gt;[2 q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the cursor changes to a bar (&lt;code&gt;|&lt;/code&gt;) in insert mode.  In &lt;code&gt;urxvt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;1&lt;/code&gt; is the blinky block cursor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2&lt;/code&gt; is the default (non-blinky) block cursor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;3&lt;/code&gt; is blinky underscore&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;4&lt;/code&gt; fixed underscore&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;5&lt;/code&gt; pipe bar (blinking)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;6&lt;/code&gt; fixed pipe bar&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;neovim&lt;/code&gt; things work differently.  Although &lt;code&gt;:help termcap-cursor-shape&lt;/code&gt; is the same as in Vim it appears to ignore &lt;code&gt;t_SI&lt;/code&gt;, &lt;code&gt;t_SR&lt;/code&gt; and &lt;code&gt;t_EI&lt;/code&gt;.  As Caleb Eby found out the &lt;code&gt;NVIM_TUI_ENABLE_CURSOR_SHAPE&lt;/code&gt; variable controls &lt;code&gt;neovim&lt;/code&gt;'s cursor shape instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can therefore add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $NVIM_TUI_ENABLE_CURSOR_SHAPE = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To your &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt; and the cursor will work as if the termcap variables were set as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;t_SI = &quot;\&amp;lt;esc&amp;gt;[5 q&quot;&#xA;let &amp;amp;t_SR = &quot;\&amp;lt;esc&amp;gt;[3 q&quot;&#xA;let &amp;amp;t_EI = &quot;\&amp;lt;esc&amp;gt;[2 q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(But you cannot change the values, as far as I meddled with this)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/term.html#termcap-cursor-shape&quot; rel=&quot;noreferrer&quot;&gt;:h termcap-cursor-shape&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://hamberg.no/erlend/posts/2014-03-09-change-vim-cursor-in-iterm.html&quot; rel=&quot;noreferrer&quot;&gt;Changing cursor in Vim in iTerm&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-08-10T05:09:47.300" LastActivityDate="2016-08-10T05:09:47.300" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9134" PostTypeId="2" ParentId="9130" CreationDate="2016-08-10T05:57:33.537" Score="3" Body="&lt;p&gt;When you end up in a netrw window you can do &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; (or &lt;code&gt;&amp;lt;C-6&amp;gt;&lt;/code&gt;, depending on your keyboard layout) to switch to &quot;the alternate file&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, &quot;the alternate file&quot; is simply the buffer that was previously displayed in the current window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; is a global command not related to &lt;code&gt;netrw&lt;/code&gt;. See &lt;code&gt;:help ctrl-^&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-10T05:57:33.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9135" PostTypeId="1" AcceptedAnswerId="9138" CreationDate="2016-08-10T08:33:30.160" Score="1" ViewCount="219" Body="&lt;p&gt;Often I rename files using &lt;code&gt;netrw-R&lt;/code&gt;. It opens a rename confirmation on the commandline(?). E.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Moving /home/ber/Documenten/xxx/xxx/test/services/member_balance_calculator_test.rb to : /home/ber/Documenten/xxx/xxx/test/services/member_balance_calculator_test.rb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's say, I want to change the name to &lt;code&gt;calculate_member_balance_test.rb&lt;/code&gt;. All I can get to work, is&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Hit the &lt;kbd&gt;left&lt;/kbd&gt; 7 times&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;kbd&gt;backspace&lt;/kbd&gt; 9 times&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;kbd&gt;left&lt;/kbd&gt; another 13 times&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;calculate&lt;/code&gt; &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm sure there is a way to navigate and operate this &quot;dialog&quot; more efficient but don't see where or how. Nor do I know where to look in the &lt;code&gt;:help&lt;/code&gt; for this.&lt;/p&gt;&#xA;" OwnerUserId="8750" LastEditorUserId="1841" LastEditDate="2016-08-10T09:20:26.533" LastActivityDate="2016-08-10T09:20:26.533" Title="How to navigate when using netrw-R (rename)" Tags="|cursor-movement|netrw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9136" PostTypeId="2" ParentId="7834" CreationDate="2016-08-10T08:51:47.963" Score="4" Body="&lt;p&gt;I just had the same problem as soon as I started adding options, I had to copy the error format from the plugin code to my options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:neomake_python_flake8_maker = {&#xA;    \ 'args': ['--ignore=E221,E241,E272,E251,W702,E203,E201,E202',  '--format=default'],&#xA;    \ 'errorformat':&#xA;        \ '%E%f:%l: could not compile,%-Z%p^,' .&#xA;        \ '%A%f:%l:%c: %t%n %m,' .&#xA;        \ '%A%f:%l: %t%n %m,' .&#xA;        \ '%-G%.%#',&#xA;    \ }&#xA;let g:neomake_python_enabled_makers = ['flake8']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8751" LastActivityDate="2016-08-10T08:51:47.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9138" PostTypeId="2" ParentId="9135" CreationDate="2016-08-10T09:14:05.633" Score="2" Body="&lt;p&gt;The relevant part of the documentation is &lt;code&gt;:help cmdline-editing&lt;/code&gt; but, as you can see, the possibilities are pretty limited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your best option is to open the &quot;command-line window&quot; with &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt;, which lets you edit the current command-line with the full power of Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help cmdline-window&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-10T09:14:05.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9139" PostTypeId="1" AcceptedAnswerId="9140" CreationDate="2016-08-10T10:36:10.537" Score="7" ViewCount="1107" Body="&lt;p&gt;I have a text file where I keep my personal notes. They're structured in a certain way, so I can operate on those notes with vim commands. I would like to map a keyboard shortcut to a specific set of commands, but that mapping should be available only in this file. So I tried writing a modeline at the end of my file, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: nmap \a A [a]&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, that didn't work: when opening the file, vim says &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing modelines:&#xA;line  273:&#xA;E518: Unknown option: nmap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I set a mapping that only works in this file? Preferably without writing to .vimrc or another file. Also, my file doesn't have a filetype, it's just text, and the file doesn't have any extension.&lt;/p&gt;&#xA;" OwnerUserId="8754" LastActivityDate="2016-08-10T11:16:49.097" Title="How to set a key mapping in the modeline?" Tags="|key-bindings|modeline|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9140" PostTypeId="2" ParentId="9139" CreationDate="2016-08-10T11:16:49.097" Score="8" Body="&lt;p&gt;Moving to answers, as requested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modelines are run in a restricted sandbox, there is only a limited number of things they can do, and defining keyboard maps is not among those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;can&lt;/em&gt; however set a &lt;code&gt;filetype&lt;/code&gt; in a modeline, then define a map in a corresponding &lt;code&gt;ftplugin&lt;/code&gt; file.  If you add the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; qualifier the map will be defined only for the buffers of that &lt;code&gt;filetype&lt;/code&gt; (cf. &lt;code&gt;:h :map-&amp;lt;buffer&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the &lt;code&gt;filetype&lt;/code&gt; doesn't have to be a &quot;well-known&quot; name, a made-up name would work just as well as a well-known one.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-08-10T11:16:49.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9141" PostTypeId="1" AcceptedAnswerId="9142" CreationDate="2016-08-10T11:43:17.497" Score="0" ViewCount="489" Body="&lt;p&gt;I followed the same procedure as in &lt;a href=&quot;https://tex.stackexchange.com/questions/112698/how-to-install-vim-latex&quot;&gt;the answer to this question&lt;/a&gt; to download and install latex-vim. But when I compile a tex file, I get the following error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|| I can't find file `Rapport'. Rapport  sur la structure des groupes des units.tex&#xA;|| Emergency stop. Rapport  sur la structure des groupes des units.tex&#xA;||  ==&amp;gt; Fatal error occurred, no output PDF file produced!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that I cannot compile files with spaces in the name, but, using other applications like &lt;code&gt;sublime text&lt;/code&gt;, it all works quite fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using a mac el capitan, and both the vim in terminal and the mac vim fail to compile correctly the tex files, while other functionalities such as folding and indenting are all good and fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am new to the world of vim, so thanks sincerely in advance for any help and reference, in advance.&lt;/p&gt;&#xA;" OwnerUserId="8756" LastEditorUserId="-1" LastEditDate="2017-04-13T12:34:32.317" LastActivityDate="2024-02-27T22:35:24.847" Title="LaTex-vim cannot compile files with spaces in name" Tags="|plugin-vim-latex|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9142" PostTypeId="2" ParentId="9141" CreationDate="2016-08-10T15:58:36.650" Score="1" Body="&lt;p&gt;Until an official fix is available, you can do the following:&#xA;Edit the &lt;code&gt;ftplugin/latex-suite/compiler.vim&lt;/code&gt; and change the lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mainfname = expand('%:p:t')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mainfname = Tex_GetMainFileName(':p:t')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mainfname = fnameescape(expand('%:p:t'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mainfname = fnameescape(Tex_GetMainFileName(':p:t'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;repectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to fix the problem.&lt;/p&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2016-08-10T15:58:36.650" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9144" PostTypeId="1" CreationDate="2016-08-10T18:06:38.093" Score="3" ViewCount="17699" Body="&lt;p&gt;Does it exist?  Is it Linux only?  Do I have to install it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Improved_hex_editing&quot; rel=&quot;nofollow&quot;&gt;According to this&lt;/a&gt;, it's &lt;code&gt;:!xxd&lt;/code&gt; to convert the file to hex, and it's &lt;code&gt;:!xxd -r&lt;/code&gt; to convert it back again.&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="205" LastEditDate="2016-08-10T18:17:16.977" LastActivityDate="2020-05-08T19:51:51.490" Title="Where is xxd in Windows gvim?" Tags="|microsoft-windows|binary-file|xxd|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9145" PostTypeId="5" CreationDate="2016-08-10T18:08:59.400" Score="0" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:!xxd&lt;/code&gt; will convert the contents of the buffer into hex and allow&#xA;you to edit in hex mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:!xxd -r&lt;/code&gt; will convert the contents of the buffer back into it's original format to be edited in normal mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="1065" LastEditDate="2016-08-10T18:18:06.337" LastActivityDate="2016-08-10T18:18:06.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9146" PostTypeId="4" CreationDate="2016-08-10T18:08:59.400" Score="0" Body="`xxd` is an external program that ships with Vim for converting text files and binary files." OwnerUserId="1065" LastEditorUserId="51" LastEditDate="2016-08-10T20:54:23.310" LastActivityDate="2016-08-10T20:54:23.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9147" PostTypeId="2" ParentId="9144" CreationDate="2016-08-10T19:59:54.630" Score="7" Body="&lt;p&gt;It is distributed with Vim (as &lt;code&gt;xxd.exe&lt;/code&gt;), along with &lt;code&gt;diff.exe&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it exists and should work on Windows. You don't need to install anything separately, as it is already bundled with Vim (at least in the versions available from vim.org).&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="18609" LastEditDate="2020-05-08T19:51:51.490" LastActivityDate="2020-05-08T19:51:51.490" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9149" PostTypeId="1" AcceptedAnswerId="9150" CreationDate="2016-08-11T07:18:17.193" Score="0" ViewCount="46" Body="&lt;p&gt;If I select several lines in visual block mode and then append it works, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;jjj$A;&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will append a semicolon to 4 lines. However if select a paragraph it does not work. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;ip$A;&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does not work. Why is this?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="343" LastEditDate="2016-08-11T08:51:30.153" LastActivityDate="2016-08-11T08:51:30.153" Title="Visual block append does not seem to work with Inside Paragraph (ip)" Tags="|visual-block|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9150" PostTypeId="2" ParentId="9149" CreationDate="2016-08-11T07:43:26.493" Score="5" Body="&lt;p&gt;It doesn't work because using a text-object switches to &lt;em&gt;visual-line&lt;/em&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vip&amp;lt;C-v&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;ip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help ip&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-11T07:43:26.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9151" PostTypeId="1" AcceptedAnswerId="9152" CreationDate="2016-08-11T07:55:30.773" Score="1" ViewCount="228" Body="&lt;p&gt;If I select multiple lines and do substitution at the beginning of text it actually substitutes at the beginning of the line. For example, given:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc&#xA;    def&#xA;  ghi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If we do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vjj:s/^/--&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then we get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--&amp;gt;    abc&#xA;--&amp;gt;        def&#xA;--&amp;gt;      ghi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this is no different than &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vjj:s/0/--&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What we actually want is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--&amp;gt; abc&#xA;    --&amp;gt; def&#xA;  --&amp;gt; ghi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would have expected the circumflex accent, &lt;code&gt;^&lt;/code&gt;, to go to the &lt;em&gt;beginning of text&lt;/em&gt;, not the beginning of line like &lt;code&gt;0&lt;/code&gt; does. What is going wrong here?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="1841" LastEditDate="2016-08-11T09:52:19.037" LastActivityDate="2016-08-11T09:52:19.037" Title="Substitution at the beginning of the text line, not the absolute beginning of line" Tags="|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9152" PostTypeId="2" ParentId="9151" CreationDate="2016-08-11T08:01:05.993" Score="2" Body="&lt;p&gt;&lt;code&gt;^&lt;/code&gt;  represents the beginning of the line in regex language it is not related to the motion &lt;code&gt;^&lt;/code&gt; that's why your solution won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have to use that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(^\s*\)/\1--&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here you use the substitution with a capture group, here is a detail of the pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(    \)     Will be used to capture characters and reuse them in the subtitution string&#xA;  ^\s*       You capture any number of whitespaces at the beginning of the line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the substitution string &lt;code&gt;\1&lt;/code&gt; is used to insert the content of your capture group.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can even simplify the expression with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\s*/&amp;amp;--&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here you don't use capture group (&lt;code&gt;\(  \)&lt;/code&gt;) because &lt;code&gt;&amp;amp;&lt;/code&gt; makes reference to the whole matched pattern.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-08-11T08:05:18.180" LastActivityDate="2016-08-11T08:05:18.180" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9153" PostTypeId="2" ParentId="9151" CreationDate="2016-08-11T08:12:09.480" Score="4" Body="&lt;p&gt;What's going wrong, here, is your reluctance to Read The Fantastic Manual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, &lt;code&gt;V&lt;/code&gt; is useless in that context because Ex commands like &lt;code&gt;:s&lt;/code&gt; are &lt;em&gt;always&lt;/em&gt; line-wise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, &lt;code&gt;vjj:s/0/--&amp;gt;/&lt;/code&gt; would do nothing on your sample because it doesn't contain a single &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third, the &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;0&lt;/code&gt; you refer to are motions. What they do in normal/visual mode has no bearing on their meaning as search pattern atoms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fourth, what the &lt;code&gt;^&lt;/code&gt; atom does is clearly explained in &lt;code&gt;: help /^&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fifth, you need a space after &lt;code&gt;--&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use this pattern for a zero-width match before the first printable character on a line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^\s*\zs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For your example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vjj:s/^\s*\zs/--&amp;gt; /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another approach:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vjj:s/^\s*/&amp;amp;--&amp;gt; /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And another one, without visual selection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3:s/^\s*/&amp;amp;--&amp;gt; /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help /\s&lt;/code&gt;, &lt;code&gt;:help /*&lt;/code&gt;, &lt;code&gt;:help /\zs&lt;/code&gt;, &lt;code&gt;:help s/\&amp;amp;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-08-11T08:17:26.807" LastActivityDate="2016-08-11T08:17:26.807" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9154" PostTypeId="2" ParentId="4307" CreationDate="2016-08-11T08:55:06.293" Score="9" Body="&lt;p&gt;More Vim ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First task:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\section[foobar baz]{foobar baz}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Workflow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\section[]{}&#xA;hh&#xA;ifoobar baz&amp;lt;Esc&amp;gt;&#xA;$.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Second task:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable1 = 2&#xA;my_variable2 = 12&#xA;var3 = 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3:norm ea_somestuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable1_somestuff = 2&#xA;my_variable2_somestuff = 12&#xA;var3_somestuff = 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-08-11T09:05:03.590" LastActivityDate="2016-08-11T09:05:03.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9155" PostTypeId="1" CreationDate="2016-08-11T09:14:26.420" Score="1" ViewCount="1002" Body="&lt;p&gt;The description of Lexplore says that it &quot;toggles&quot; a directory window on the left side, but I don't see the difference between that and Vexplore, which seems to do exactly the same thing. If I do :Lex twice in row, then a second netrw window is created, so it does not appear to turn the window off (q) as a toggle would normally mean. What does the help mean by &quot;toggle&quot; in this context if it does not mean to close the window? The help itself is unclear because it does not explain what the command does (any different than Vex).&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="6952" LastEditDate="2016-08-11T11:51:24.427" LastActivityDate="2016-08-11T11:51:24.427" Title="What does &quot;toggle&quot; mean in the context of Lexplore?" Tags="|netrw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9156" PostTypeId="1" AcceptedAnswerId="9161" CreationDate="2016-08-11T09:19:21.700" Score="16" ViewCount="3211" Body="&lt;p&gt;Lately I've been drastically reducing the number of plugins I'm using so I'm&#xA;looking for answers using only built-in Vim features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been noticing a flaw in my workflow when I'm editing a lot of buffers: I am&#xA;on a buffer and I want to switch to another one of which I don't remember the&#xA;name and which isn't the alternative buffer. So using &lt;code&gt;:b#&lt;/code&gt; is not possible and&#xA;using the completion with the command &lt;code&gt;:b&lt;/code&gt; isn't convenient neither.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do that I was doing the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First use &lt;code&gt;:buffers&lt;/code&gt; to get the list of open buffers&lt;/li&gt;&#xA;&lt;li&gt;Remember the number of the buffer I want to use&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;Enter&lt;/kbd&gt; to close the list of buffers&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:bX&lt;/code&gt; with &lt;code&gt;X&lt;/code&gt; the number of the buffer to use.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This workflow seemed pretty heavy to me so I added the following lines to my&#xA;&lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Improve the navigation in the buffers &#xA;nnoremap &amp;lt;Leader&amp;gt;&amp;lt;S-b&amp;gt; :B&amp;lt;CR&amp;gt; &#xA;command! B call Buffers() &#xA;&#xA;function! Buffers() &#xA;    execute &quot;buffers&quot; &#xA;    let buffer=input(&quot;Enter a buffer:&quot;) &#xA;    execute &quot;b&quot; . buffer &#xA;endfunction &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This give me a command &lt;code&gt;:B&lt;/code&gt; (and a mapping) which calls the function &lt;code&gt;:buffers&lt;/code&gt; wait for an input&#xA;and finally calls &lt;code&gt;:b&lt;/code&gt; followed by the input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works well but I'm surprised that I had to develop such a function: usually&#xA;Vim has a pretty efficient default workflow so I'm wondering if there is a&#xA;better way to switch to a buffer of which I don't know anything excepted that it&#xA;as already been opened in my editing session.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-10-05T07:52:43.953" Title="What is a more efficient way to use buffers?" Tags="|buffers|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9158" PostTypeId="2" ParentId="9155" CreationDate="2016-08-11T09:43:34.343" Score="6" Body="&lt;p&gt;With &lt;code&gt;:Vexplore&lt;/code&gt;, the current window is split in two and a netrw buffer is displayed in the new window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Repeating that command again and again will keep splitting the current window until the left half of the workspace is filled with very narrow netrw windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:Lexplore&lt;/code&gt; is a &lt;em&gt;toggle&lt;/em&gt;, this means that it switches between two states:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The netrw window created with &lt;code&gt;:Lexplore&lt;/code&gt; is not present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A new window is created.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The netrw window created with &lt;code&gt;:Lexplore&lt;/code&gt; is present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That window is closed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-11T09:43:34.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9159" PostTypeId="2" ParentId="9156" CreationDate="2016-08-11T09:46:37.583" Score="8" Body="&lt;p&gt;I encountered the same problem a while ago and I found a solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :buffers&amp;lt;CR&amp;gt;:buffer&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will open the buffer list and &lt;em&gt;without&lt;/em&gt; hiding it, give you the option to switch buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that it makes sense that Vim does not have a &quot;list and select&quot; option here, these are two separate actions. But Vim is powerful enough to combine command together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Think of it as the Unix philosophy: Do one thing and do it well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:buffers&lt;/code&gt; lists the buffers and &lt;code&gt;:buffer xxx&lt;/code&gt; allows you to select one.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1841" LastEditDate="2016-08-11T14:15:04.697" LastActivityDate="2016-08-11T14:15:04.697" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9160" PostTypeId="2" ParentId="4572" CreationDate="2016-08-11T09:48:56.393" Score="3" Body="&lt;p&gt;The Smart Tabs plug-in that you mentioned is about as good as it gets. I initially ran into the same error that you did and gave up but eventually spent a few minutes to fix it. Try applying the following patch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- ctab.vim.orig   2016-08-11 17:05:20.767275274 +0800&#xA;+++ ctab.vim    2016-08-11 17:15:20.039286525 +0800&#xA;@@ -221,7 +221,7 @@&#xA;       if a:line == line('.')&#xA;         let b:ctab_lastalign=a:line&#xA;       else&#xA;-        unlet b:ctab_lastalign&#xA;+        unlet! b:ctab_lastalign&#xA;       endif&#xA;       set ts=50&#xA;       set sw=50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I later found that someone has suggested a similar fix in the &lt;a href=&quot;http://vim.wikia.com/wiki/Script:231&quot; rel=&quot;nofollow&quot;&gt;Smart Tabs wiki section&lt;/a&gt;. Alas, there hasn't been a new release.&lt;/p&gt;&#xA;" OwnerDisplayName="user8769" LastActivityDate="2016-08-11T09:48:56.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9161" PostTypeId="2" ParentId="9156" CreationDate="2016-08-11T10:17:56.127" Score="14" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I've been noticing a flaw in my workflow when I'm editing a lot of buffers: I am on a buffer and I want to switch to another one of which I don't remember the name and which isn't the alternative buffer. So using &lt;code&gt;:b#&lt;/code&gt; is not possible and using the completion with the command &lt;code&gt;:b&lt;/code&gt; isn't convenient neither.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On the contrary, I find tab-completion to be extremely convenient. Setting the right options to values that work for you may help a lot. These are the relevant lines from &lt;em&gt;my&lt;/em&gt; &lt;code&gt;vimrc&lt;/code&gt; &lt;em&gt;(they work for me but they may not work for you so don't just copy them)&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ,b :buffer *&#xA;set wildmenu&#xA;set wildignore+=*.swp,*.bak&#xA;set wildignore+=*.pyc,*.class,*.sln,*.Master,*.csproj,*.csproj.user,*.cache,*.dll,*.pdb,*.min.*&#xA;set wildignore+=*/.git/**/*,*/.hg/**/*,*/.svn/**/*&#xA;set wildignore+=*/min/*,*/vendor/*,*/node_modules/*,*/bower_components/*&#xA;set wildignore+=tags,cscope.*&#xA;set wildignore+=*.tar.*&#xA;set wildignorecase&#xA;set wildmode=full&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With that, the right buffer is rarely more than five or six keystrokes away:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Mu4lE.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Mu4lE.gif&quot; alt=&quot;tab-completion&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This give me a command &lt;code&gt;:B&lt;/code&gt; (and a mapping) which calls the function &lt;code&gt;:buffers&lt;/code&gt; wait for an input and finally calls &lt;code&gt;:b&lt;/code&gt; followed by the input.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Barry Arthur came up with a much simpler solution years ago that has become quite popular since then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :ls&amp;lt;CR&amp;gt;:b&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;of which I proposed a slightly more versatile variant a couple years ago:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gb :ls&amp;lt;CR&amp;gt;:b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/U8jDD.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/U8jDD.gif&quot; alt=&quot;gb&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Since we are talking vimscript, here is a nice little function I wrote that &quot;auto-populates&quot; the command-line with the right command stub after list-like commands like &lt;code&gt;:ls&lt;/code&gt; or &lt;code&gt;:ilist&lt;/code&gt;. The advantage of that function over the mappings above is that I don't have to remember specific mappings. It works just like Vim, &lt;em&gt;but with a little twist&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; smooth listing&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; &amp;lt;SID&amp;gt;CCR()&#xA;&#xA;function! s:CCR()&#xA;    if getcmdtype() == &quot;:&quot;&#xA;        let cmdline = getcmdline()&#xA;            if cmdline =~ '\v\C^(dli|il)' | return &quot;\&amp;lt;CR&amp;gt;:&quot; . cmdline[0] . &quot;jump  &quot; . split(cmdline, &quot; &quot;)[1] . &quot;\&amp;lt;S-Left&amp;gt;\&amp;lt;Left&amp;gt;&quot;&#xA;        elseif cmdline =~ '\v\C^(cli|lli)' | return &quot;\&amp;lt;CR&amp;gt;:silent &quot; . repeat(cmdline[0], 2) . &quot;\&amp;lt;Space&amp;gt;&quot;&#xA;        elseif cmdline =~ '\C^changes' | set nomore | return &quot;\&amp;lt;CR&amp;gt;:sil se more|norm! g;\&amp;lt;S-Left&amp;gt;&quot;&#xA;        elseif cmdline =~ '\C^ju' | set nomore | return &quot;\&amp;lt;CR&amp;gt;:sil se more|norm! \&amp;lt;C-o&amp;gt;\&amp;lt;S-Left&amp;gt;&quot;&#xA;        elseif cmdline =~ '\C^ol' | set nomore | return &quot;\&amp;lt;CR&amp;gt;:sil se more|e #&amp;lt;&quot;&#xA;        elseif cmdline =~ '\C^undol' | return &quot;\&amp;lt;CR&amp;gt;:u &quot;&#xA;        elseif cmdline =~ '\C^ls' | return &quot;\&amp;lt;CR&amp;gt;:b&quot;&#xA;        elseif cmdline =~ '/#$' | return &quot;\&amp;lt;CR&amp;gt;:&quot;&#xA;        else | return &quot;\&amp;lt;CR&amp;gt;&quot; | endif&#xA;    else | return &quot;\&amp;lt;CR&amp;gt;&quot; | endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Vnl3e.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Vnl3e.gif&quot; alt=&quot;ccr&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That said, I'm a big proponent of &quot;symbol-based navigation&quot; over &quot;file-based navigation&quot;. When applicable, symbol-based navigation is much faster and much more economic than file-based navigation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last GIF shows &lt;em&gt;one&lt;/em&gt; mean of symbol-based navigation, by the way. The example is silly but… oh well. &lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-10-05T07:52:43.953" LastActivityDate="2016-10-05T07:52:43.953" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9162" PostTypeId="1" AcceptedAnswerId="9163" CreationDate="2016-08-11T15:18:25.173" Score="8" ViewCount="1295" Body="&lt;p&gt;I came across a plugin for vim and it comes in a .vmb file. Currently I use pathogen and it's quite simple I place the downloaded files into the bundle folder and it gets picked up automagically (in a sense). I am not sure about a vmb based plugin. So far in order to install it I found this regarding installing a .vmb plugin&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The easiest way to install SuperTab is to grab the file supertab.vmb&#xA;  (which is an archive called a “vimball”) and place it into your&#xA;  “~/.vim/bundle” directory. Then open it in Vim and source the file:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;vim supertab.vmb :so %&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My question is how would I go about deleting this plugin if i did not want it?&lt;/p&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="51" LastEditDate="2016-08-11T15:32:14.283" LastActivityDate="2016-08-11T15:32:14.283" Title="Uninstalling a plugin that was installed through a Vimball" Tags="|vimball|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9163" PostTypeId="2" ParentId="9162" CreationDate="2016-08-11T15:31:00.697" Score="10" Body="&lt;p&gt;Use the &lt;code&gt;:RmVimball&lt;/code&gt; command. From &lt;a href=&quot;http://vimhelp.appspot.com/pi_vimball.txt.html#%3aRmVimball&quot;&gt;&lt;code&gt;:help :RmVimball&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;REMOVING A VIMBALL                      :RmVimball&#xA;&#xA;        :RmVimball vimballfile [path]&#xA;&#xA;    This command removes all files generated by the specified vimball&#xA;    (but not any directories it may have made).  One may choose a path&#xA;    for de-installation, too (see 'runtimepath'); otherwise, the&#xA;    default is the first existing directory on the 'runtimepath'.&#xA;    To implement this, a file (.VimballRecord) is made in that directory&#xA;    containing a record of what files need to be removed for all vimballs&#xA;    used thus far.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you an also install it to a specific path with &lt;a href=&quot;http://vimhelp.appspot.com/pi_vimball.txt.html#%3aUseVimball&quot;&gt;&lt;code&gt;:UseVimball&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MANUALLY INVOKING VIMBALL EXTRACTION                :UseVimball&#xA;&#xA;        :UseVimball [path]&#xA;&#xA;    This command is contained within the vimball itself; it invokes the&#xA;    vimball#Vimball() routine which is responsible for unpacking the&#xA;    vimball.  One may choose to execute it by hand instead of sourcing&#xA;    the vimball; one may also choose to specify a path for the&#xA;    installation, thereby overriding the automatic choice of the first&#xA;    existing directory on the 'runtimepath'.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if you want to install a vimball to &lt;code&gt;~/.vim/bundle/plugin&lt;/code&gt; so it will be loaded with pathogen instead of &lt;code&gt;~/.vim&lt;/code&gt; you can use this.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-08-11T15:31:00.697" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9164" PostTypeId="2" ParentId="9125" CreationDate="2016-08-11T20:44:27.673" Score="0" Body="&lt;p&gt;This &lt;strong&gt;is&lt;/strong&gt; a bug but it has already been fixed. I'm not sure exactly which patch it was fixed in but it at least is gone in v.7.4.2196.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-08-11T20:44:27.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9165" PostTypeId="1" AcceptedAnswerId="9168" CreationDate="2016-08-11T22:11:54.750" Score="3" ViewCount="924" Body="&lt;p&gt;In the &lt;a href=&quot;https://pragprog.com/book/dnvim2/practical-vim-second-edition&quot; rel=&quot;nofollow&quot;&gt;Practical Vim&lt;/a&gt; book, there is an example of a regular expression that matches duplicate words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v&amp;lt;(\w+)\_s+\1&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While this works beautifully, I don't quite understand why it also matches the &lt;code&gt;a a&lt;/code&gt; part in &lt;code&gt;Once upon a a time.&lt;/code&gt;. I mean, shouldn't the &lt;code&gt;&amp;lt;&lt;/code&gt; be same as &lt;code&gt;\W\zs\w&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; same as &lt;code&gt;\w\ze\W&lt;/code&gt;? If yes, then already the beginning of the regex(&lt;code&gt;/\v\W\zs\w(\w+)...&lt;/code&gt;) should require at least two consecutive word characters because of &lt;code&gt;\w(\w+)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8626" LastEditorUserId="2920" LastEditDate="2016-08-11T22:36:19.930" LastActivityDate="2016-08-12T03:20:09.520" Title="Understanding the beginning and end of word pattern-atoms" Tags="|regular-expression|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9166" PostTypeId="1" CreationDate="2016-08-12T00:50:24.577" Score="6" ViewCount="1788" Body="&lt;p&gt;If I am viewing a HTML file that someone else wrote, it often has &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags containing javascript, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-html prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&#xA;&#xA;&amp;lt;html&amp;gt;&#xA;    &amp;lt;head&amp;gt;&#xA;    &amp;lt;/head&amp;gt;&#xA;    &amp;lt;body&amp;gt;&#xA;        &amp;lt;video autoplay&amp;gt;&amp;lt;/video&amp;gt;&#xA;&#xA;        &amp;lt;script&amp;gt;&#xA;        var errorCallback = function(e) {&#xA;            console.log('Reeeejected!', e);&#xA;        };&#xA;&#xA;// Not showing vendor prefixes.&#xA;navigator.getUserMedia({video: true, audio: true}, function(localMediaStream) {&#xA;    var video = document.querySelector('video');&#xA;    video.src = window.URL.createObjectURL(localMediaStream);&#xA;&#xA;    // Note: onloadedmetadata doesn't fire in Chrome when using it with getUserMedia.&#xA;    // See crbug.com/110938.&#xA;    video.onloadedmetadata = function(e) {&#xA;        // Ready to go. Do some stuff.&#xA;    };&#xA;}, errorCallback);&#xA;        &amp;lt;/script&amp;gt;&#xA;    &amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to indent the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags and the javascript code it contains to some reasonable levels of indentation, using a command like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg=G&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or visual select the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag and hit &lt;code&gt;=&lt;/code&gt;&lt;br&gt;&#xA;How can I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am setting the &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:html_indent_style1 = &quot;inc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I believe that only affects newly written code.&#xA;I have also tried setting the filetype to javascript, selecting the area and then hitting &lt;code&gt;=&lt;/code&gt;, none of these seem to work.&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="205" LastEditDate="2016-09-14T00:48:31.090" LastActivityDate="2016-10-14T03:18:41.370" Title="How can I indent JavaScript that's within &lt;script&gt; tags in an HTML file?" Tags="|indentation|filetype-html|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="9168" PostTypeId="2" ParentId="9165" CreationDate="2016-08-12T03:20:09.520" Score="10" Body="&lt;p&gt;&lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; are zero-width word boundaries.  They allow you to match the beginning and end of words without moving the cursor that's currently evaluating the character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference between &lt;code&gt;\W&lt;/code&gt; and &lt;code&gt;\&amp;lt; \&amp;gt;&lt;/code&gt; is that &lt;code&gt;\W&lt;/code&gt; is simply &lt;code&gt;[^0-9A-Za-z_]&lt;/code&gt; whereas &lt;code&gt;\&amp;lt; \&amp;gt;&lt;/code&gt; are affected by &lt;code&gt;'iskeyword'&lt;/code&gt; which can be different depending on the &lt;code&gt;filetype&lt;/code&gt;.  In some files, &lt;code&gt;hypenated-word&lt;/code&gt; is one word, while in others it's two words separated by a non-word character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; are zero-width atoms that &lt;em&gt;set&lt;/em&gt; the boundaries for capture group &lt;code&gt;\0&lt;/code&gt;.  They are useful for changing what is considered a match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, you have a list of words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;berry&#xA;cherry&#xA;ferry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You want to replace &lt;code&gt;erry&lt;/code&gt; in everything below, but not when &lt;code&gt;h&lt;/code&gt; comes before it.  A substitution like &lt;code&gt;%s/[^h]erry/xxx/g&lt;/code&gt; would result in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xxx&#xA;cherry&#xA;xxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It didn't replace &lt;code&gt;cherry&lt;/code&gt;, but it replaced the character that came before &lt;code&gt;erry&lt;/code&gt; in the other words.  This is because &lt;code&gt;[^h]&lt;/code&gt; is still part of the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;\zs&lt;/code&gt; to set the beginning of the match for the substitution with &lt;code&gt;%s/[^h]\zserry/xxx/g&lt;/code&gt;, which will give you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bxxx&#xA;cherry&#xA;fxxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\ze&lt;/code&gt; works the same way, but sets where the match ends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; are particularly useful with the &lt;code&gt;search()&lt;/code&gt; and &lt;code&gt;matchstr()&lt;/code&gt; functions.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-08-12T03:20:09.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9169" PostTypeId="1" AcceptedAnswerId="9173" CreationDate="2016-08-12T04:12:20.237" Score="2" ViewCount="570" Body="&lt;p&gt;I want to scroll the current line to be the topmost line in the window, even with &lt;code&gt;scroloff&lt;/code&gt; set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! TestColours :echo &quot;Please wait...&quot; | :so /usr/share/vim/vim74/syntax/colortest.vim | normal 8G{{move line to top of screen}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2016-08-12T10:00:08.760" LastActivityDate="2016-08-15T08:53:46.567" Title="How move current line to top of the window with `scrolloff` set" Tags="|scrolling|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9170" PostTypeId="1" CreationDate="2016-08-12T05:08:55.337" Score="4" ViewCount="2147" Body="&lt;p&gt;I have my vim setup according to &quot;Solution #1: Replicating Tabs with Buffers&quot; on this site &lt;a href=&quot;http://joshldavis.com/2014/04/05/vim-tab-madness-buffers-vs-tabs/&quot; rel=&quot;nofollow&quot;&gt;buffers-vs-tabs&lt;/a&gt; with the vim-airline plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I open numerous files in buffer 'tabs' &lt;code&gt;:bprevious&lt;/code&gt;/&lt;code&gt;:bnext&lt;/code&gt; just cycles through them great (and wrap when you get to the end of the 'tabs').&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as soon as I attempt to use netrw by calling vim on a directory all of the sudden things start misbehaving.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I execute vim on a directory (&lt;code&gt;vim .&lt;/code&gt;) and use netrw to drill down a directory hierarchy and hit &lt;kbd&gt;Enter&lt;/kbd&gt; to open a file, it opens in a new buffer 'tab'.  If I do &lt;code&gt;:bprevious&lt;/code&gt;, it goes back to the netrw explorer.  If I open another file with the explorer, it opens yet another buffer 'tab' to the right of the first file. &lt;code&gt;:bprevious&lt;/code&gt; brings me back to netrw, not the file buffer to the left of the of the most recently opened file.  Also when getting back to the file explorer, if I do another &lt;code&gt;:bprevious&lt;/code&gt;, the cursor just jumps to the top of the netrw window and then doesn't move again with repeated &lt;code&gt;:bprevious&lt;/code&gt;. Note that during this scenario the netrw is showing up as a buffer 'tab' in the tabline but not highlighted like files.  Also note that the NetrwTreeListing 'count' on the bottom keeps incrementing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if I execute vim without a directory and just use ctrlp to open some files and then use &lt;code&gt;:Ex&lt;/code&gt;, A) it does not create a buffer 'tab', it simply displays a buffer/window with the netrw listing and I can open another file and it pops up as the leftmost buffer tab and &lt;code&gt;:b(previous|next)&lt;/code&gt; works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In either case &lt;code&gt;:ls!&lt;/code&gt; shows a ton of NetrwTreeListing buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I removed vim-vinegar to make sure it was not due to that and there wasn't really any change but the '-' feature of vim-vinegar does expose this issue as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: I apologize for poor terminology with regards to tabs/buffers/windows, but hopefully my explanation makes sense.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Things get slightly better if I remove this from my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_liststyle=3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sometimes I still get 'stuck' at the file explorer and &lt;code&gt;:bprevious&lt;/code&gt; stays still.&lt;/p&gt;&#xA;" OwnerUserId="8786" LastEditorUserId="1841" LastEditDate="2016-08-12T07:24:13.633" LastActivityDate="2019-10-31T20:22:53.953" Title="How do I make netrw behave with respects to cycling through buffers with :bprevious/:bnext" Tags="|buffers|netrw|plugin-airline|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9171" PostTypeId="1" CreationDate="2016-08-12T07:06:38.960" Score="2" ViewCount="897" Body="&lt;p&gt;I'm having a bit of trouble with running scripts with python-mode while in a specific conda virtual environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've installed spf13 &amp;amp; an additional plugin (&lt;a href=&quot;https://github.com/cjrh/vim-conda&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;vim-conda&lt;/code&gt;&lt;/a&gt;) which allows to change conda virtual environment inside vim. vim-conda works exactly as it's supposed to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:CondaChangeEnv py35&#xA;:!python %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;executes my Python script in shell with libraries specific to py35 environment&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if i use &lt;code&gt;:PymodeRun&lt;/code&gt; (from &lt;a href=&quot;https://github.com/klen/python-mode&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;python-mode&lt;/code&gt;&lt;/a&gt;) to run the same script it throws an error which says that it's unable to find libraries I mentioned above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:echo system(&quot;python -V&quot;)&lt;/code&gt; show proper version of Python (different for different conda environments)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help on how to explore this will be greatly appreciated.&#xA;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="8787" LastEditorUserId="23502" LastEditDate="2022-10-24T06:20:44.797" LastActivityDate="2022-10-24T06:20:44.797" Title="python-mode python interpreter &amp; cjrh/vim-conda" Tags="|vimscript-python|plugin-spf13|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9172" PostTypeId="2" ParentId="9079" CreationDate="2016-08-12T09:45:50.010" Score="3" Body="&lt;p&gt;You can specify the command to obtain the input of fzf by using the &lt;code&gt;fzf#run()&lt;/code&gt; function.&#xA;In your case, this can look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call fzf#run({'source': 'find ~/project/ ~/libs/include -type f', &#xA;             \ 'sink':  'edit'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and if you want, you can add a command like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! FZFLib call fzf#run({'source': 'find ~/project/ ~/libs/include -type f', 'sink':  'edit'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The options of &lt;code&gt;fzf#run()&lt;/code&gt; are listed on the &lt;a href=&quot;https://github.com/junegunn/fzf#usage-as-vim-plugin&quot; rel=&quot;nofollow&quot;&gt;fzf homepage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2016-08-12T09:45:50.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9173" PostTypeId="2" ParentId="9169" CreationDate="2016-08-12T09:55:45.663" Score="2" Body="&lt;p&gt;If the goal is simply to place line 8 at the top of the window, you can achieve this in the command line with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;normal gg7\&amp;lt;c-e&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This jumps to the top of the file, and then scrolls down 7 lines.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Further to discussions in the comments, in order to create a &lt;code&gt;zT&lt;/code&gt; mapping that moves the current line to the top of the window &lt;em&gt;without&lt;/em&gt; using the &lt;code&gt;&amp;lt;c-e&amp;gt;&lt;/code&gt; normal mode command, you can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap zT :execute &quot;normal! &quot; . (line(&quot;.&quot;) + &amp;amp;scrolloff) . &quot;Gzt&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Old answer&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The below was written when the question implied the user wanted to change the behaviour of '&lt;code&gt;zt&lt;/code&gt;' Not removing it, because it includes some useful features of Vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could achieve this by remapping 'zt' to scroll the extra amount by using the normal mode &lt;code&gt;&amp;lt;c-e&amp;gt;&lt;/code&gt; command with a count of &lt;code&gt;&amp;amp;scrolloff&lt;/code&gt; after carrying out its usual behaviour:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap zt zt:execute &quot;normal!&quot; . &amp;amp;scrolloff . &quot;\&amp;lt;lt&amp;gt;c-e&amp;gt;\&amp;lt;lt&amp;gt;esc&amp;gt;&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if your goal is simply to move line 8 to the top of the window, and you don't want to change the behaviour of 'zt', you could instead change your command to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;... | execute &quot;normal! &quot; . (8 + &amp;amp;scrolloff) . &quot;Gzt&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This places the cursor &lt;code&gt;&amp;amp;scrolloff&lt;/code&gt; lines &lt;em&gt;below&lt;/em&gt; line 8, and then performs a standard &lt;code&gt;zt&lt;/code&gt;, moving line 8 to the top of the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that after using either solution, the line at the very top of the screen will no longer be the &quot;current&quot; line. This is impossible to achieve with &lt;code&gt;'scrolloff'&lt;/code&gt; set, as that state is precisely what &lt;code&gt;'scrolloff'&lt;/code&gt; is intended to prevent.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-08-15T08:53:46.567" LastActivityDate="2016-08-15T08:53:46.567" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9174" PostTypeId="1" AcceptedAnswerId="9178" CreationDate="2016-08-12T10:10:35.043" Score="10" ViewCount="1266" Body="&lt;p&gt;I use gvim for writing emails and use &lt;code&gt;tw=72&lt;/code&gt; to break long lines. Now I also edit basic mail headers in the same document, e.g. I am adding recipients to my mail. Now with &lt;code&gt;tw=72&lt;/code&gt; it also breaks every time after 72 characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I set &lt;code&gt;tw=0&lt;/code&gt; on the first 4 lines (that's the header part), and &lt;code&gt;tw=72&lt;/code&gt; for the rest of the document?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My formatoptions look like this, if that's relevant:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fo+=tcqn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8791" LastEditorUserId="51" LastEditDate="2016-08-13T13:24:14.597" LastActivityDate="2016-08-13T13:51:29.617" Title="Line number specific text-width setting" Tags="|formatting|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9175" PostTypeId="1" AcceptedAnswerId="9177" CreationDate="2016-08-12T10:52:36.037" Score="7" ViewCount="5469" Body="&lt;p&gt;I have this mapping in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;vlc :exe &amp;quot;!open -a vlc '&amp;quot;.getline('.').&amp;quot;'&amp;quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It does work great with some files, but I'm getting error message with files that have single quote in it:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;/Users/dude/Downloads/check/39min tpope's Vim Config and&#xA;Plugins-MGmIJyTf8pg.mp4&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The error message:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;/bin/bash: -c: line 0: unexpected EOF while looking for matching `''&lt;/p&gt;&#xA;&lt;p&gt;/bin/bash: -c: line 1: syntax error: unexpected end of file&lt;/p&gt;&#xA;&lt;p&gt;shell returned 2&lt;/p&gt;&#xA;&lt;p&gt;Press ENTER or type command to continue&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3302" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-08-12T11:12:19.407" Title="How to escape single quote in Vim" Tags="|vimscript|external-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9176" PostTypeId="2" ParentId="9174" CreationDate="2016-08-12T10:56:24.180" Score="1" Body="&lt;p&gt;I don't believe this is possible. However, there are a couple workarounds.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You could write your header and &lt;em&gt;then&lt;/em&gt; &lt;code&gt;:set tw=72&lt;/code&gt;. Since &lt;code&gt;tw&lt;/code&gt; doesn't apply retroactively to the text already in your buffer,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You could type the entire thing with &lt;code&gt;:set tw=0&lt;/code&gt; and then once you are finished, move to line 4, &lt;code&gt;:set tw=72&lt;/code&gt;, and &lt;code&gt;gqG&lt;/code&gt;. Or, if you don't feel like doing that manually, you could macro it or map it. For example, both of these would work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @r=&quot;:set tw=72&amp;lt;cr&amp;gt;4GgqG:set tw=0&amp;lt;cr&amp;gt;&quot;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;r :set tw=72&amp;lt;cr&amp;gt;4GgqG:set tw=0&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&quot;r&quot; for &quot;reformat&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could even set this up to happen automatically when you close vim, assuming that you want it to reformat when you close vim, and that there is a filetype that you use just for emails. For example, if all of your emails had the &lt;code&gt;.email&lt;/code&gt; extension, you could do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocommand VimLeavePre *.email set tw=72 | exe &quot;normal! 4GgqG&quot; | w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, you'd have to change &lt;code&gt;*.email&lt;/code&gt; to whatever file extension you actually use. If you use something like &lt;code&gt;.txt&lt;/code&gt;, I would &lt;em&gt;not&lt;/em&gt; recommend this, since it will mess with &lt;em&gt;every&lt;/em&gt; &lt;code&gt;.txt&lt;/code&gt; file you have.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-08-12T10:56:24.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9177" PostTypeId="2" ParentId="9175" CreationDate="2016-08-12T11:07:51.690" Score="6" Body="&lt;p&gt;Rather than add quotes yourself, use the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#shellescape%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;shellescape()&lt;/code&gt;&lt;/a&gt; function, which should take care or all edge cases:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;vlc :exe &quot;!open -a vlc &quot; . shellescape(getline('.'))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another way is to use the &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%25%3aS&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;%:S&lt;/code&gt;&lt;/a&gt; filename modifier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo fnamemodify(&quot;Hello 'world&quot;, '')&#xA;Hello 'world&#xA;&#xA;:echo fnamemodify(&quot;Hello 'world&quot;, ':S')&#xA;'Hello '\''world'&#xA;&#xA;:echo expand('%')&#xA;hello 'world&#xA;&#xA;:echo expand('%:S')&#xA;'hello '\''world'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this particular case &lt;code&gt;shellescape()&lt;/code&gt; probably makes more sense, but &lt;code&gt;:S&lt;/code&gt; is useful especially when you want to combine it with other filename modifiers.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-08-12T11:07:51.690" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9178" PostTypeId="2" ParentId="9174" CreationDate="2016-08-12T11:42:37.297" Score="6" Body="&lt;p&gt;Thanks to @Carpetsmoker's comment on my question, I was able to solve this exactly like I wanted it to have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the following function in .vimrc (or in my case in a special file that it only loaded when editing my emails), tw is set to 500 if the line number is smaller than 5, otherwise it's 72. With &lt;code&gt;au CursorMovedI&lt;/code&gt; this is checked everytime the cursor moves.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set tw to 500 if in the first 4 lines, else 500&#xA;au CursorMovedI * call ModifyTextWidth()   &quot; execute when cursor has moved, use for all files&#xA;function! ModifyTextWidth()&#xA;    if line('.') &amp;lt; 5               &quot; if line number smaller than 5&#xA;        setlocal textwidth=500     &quot; use high tw setting&#xA;    else&#xA;        setlocal textwidth=72      &quot; Otherwise use normal textwidth&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If someone plans to implement this, consider replacing the wildcard in &lt;code&gt;au CursorMovedI *&lt;/code&gt; with a fixed path or file suffix.&lt;/p&gt;&#xA;" OwnerUserId="8791" LastEditorUserId="51" LastEditDate="2016-08-13T13:45:33.510" LastActivityDate="2016-08-13T13:45:33.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9179" PostTypeId="2" ParentId="9174" CreationDate="2016-08-12T11:48:14.363" Score="2" Body="&lt;p&gt;You could achieve this using autocmds. You could include them in your vimrc, but it is usually better to include them in a filetype, as &lt;a href=&quot;https://vi.stackexchange.com/a/8373/1405&quot;&gt;explained here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you could use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup headerTw&#xA;   au!&#xA;   autocmd InsertEnter &amp;lt;buffer&amp;gt;&#xA;            \ if line('.') &amp;lt; 5 |&#xA;            \    setl tw=0 |&#xA;            \ endif&#xA;   autocmd InsertLeave &amp;lt;buffer&amp;gt;&#xA;            \ if line('.') &amp;lt; 5 |&#xA;            \    setl tw=72 |&#xA;            \ endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you prefer to use it without a filetype plugin you will need to replace the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; with a file pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to change the &lt;code&gt;'textwidth'&lt;/code&gt; when you enter insert mode, and restore it when you leave it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you usually navigate in the text while in insert mode (e.g.: using the arrow keys) you could enhance it based on the link mentioned by @Carpetsmoke: &lt;a href=&quot;https://vi.stackexchange.com/questions/564/prevent-vim-from-breaking-up-links-mid-tag-in-markdown&quot;&gt;Prevent Vim from breaking up links mid-tag in markdown.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-08-12T11:48:14.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9180" PostTypeId="2" ParentId="9170" CreationDate="2016-08-12T16:37:03.420" Score="4" Body="&lt;p&gt;So this has to do with the fact that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Opens the current directory into a netrw buffer that is not unlisted.  This is what causes odd behavior with &lt;code&gt;:bp/:bn&lt;/code&gt;.  If I &lt;code&gt;:bdelete 1&lt;/code&gt; soon as I open vim on a directory, then I don't have this issue for the rest of the session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +':Ex'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does effectively the same thing but with the netrw buffer being unlisted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can use an alias to work around this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But is there way to cause the default behavior of running &lt;code&gt;vim&lt;/code&gt; on a directory to open an unlisted netrw buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT for more context: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there are two issues: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A) treestyle netrw (style 3) is full of issues/bugs so I've given up on it.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;B) Even with style 0, there is the issue of &lt;code&gt;vim .&lt;/code&gt; opening the current directory and &lt;code&gt;:ls!&lt;/code&gt; would show:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:ls!&#xA;  1  h   &quot;~/gitworkspace/temp&quot;          line 1&#xA;  2u%a-  &quot;[No Name]&quot;                    line 1&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the first buffer is not unlisted like it should be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've come to find that it is due to &lt;code&gt;set hidden&lt;/code&gt; in my vimrc.  Unfortunately my vim workflow requires being able to edit a buffer and not write it before hopping around to another so I'm unwilling to give that setting up.  Apparently netrw does not play well with that setting.&lt;/p&gt;&#xA;" OwnerUserId="8786" LastEditorUserId="8786" LastEditDate="2016-08-15T05:13:26.350" LastActivityDate="2016-08-15T05:13:26.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9181" PostTypeId="1" CreationDate="2016-08-12T18:39:08.227" Score="1" ViewCount="2952" Body="&lt;p&gt;I must be turning a corner because I keep thinking of moving my text drafts off my Windows machine and onto my Linux box to get the convenience of editing them in Vim instead of Notepad++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing I am going to miss though is Notepad++'s buffer window on the left that shows all my files. I just click on a file to open it in the view. Sublime Text has a similar ability, I believe, although I do not use Sublime.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get a pane like this that would show all the buffers, for example, in Vim and have a number or something so you could quickly activate whichever one you want? In Notepad++ I usually have about 50 to 60 different text files loaded at any given time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Notepad++ this functionality is called &quot;Document List Panel&quot; (Settings / General / Document List Panel show), shown on the left below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Eer5R.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Eer5R.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="6952" LastEditDate="2016-08-12T18:44:42.073" LastActivityDate="2016-08-12T22:18:36.833" Title="List of buffers in view pane" Tags="|buffers|navigation|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9182" PostTypeId="2" ParentId="9181" CreationDate="2016-08-12T19:11:00.197" Score="7" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use GVim on Windows so Vim is not really a valid reason for switching to Linux.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can display a list of buffers with &lt;code&gt;:ls&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For the last time: &lt;strong&gt;R&lt;/strong&gt;ead &lt;strong&gt;T&lt;/strong&gt;he &lt;strong&gt;F&lt;/strong&gt;antastic &lt;strong&gt;M&lt;/strong&gt;anual.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-12T19:11:00.197" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9183" PostTypeId="2" ParentId="9181" CreationDate="2016-08-12T19:26:07.600" Score="6" Body="&lt;p&gt;I would also add that in gVim you can get a very close approximation to this feature. If you click on the buffers menu item and then click the &quot;tear off&quot; (&lt;code&gt;--✂-----&lt;/code&gt;) button. It opens up a little window that shows you all your buffers and does pretty much what you want. You can also do this with &lt;code&gt;:tearoff Buffers&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I.E.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/IHEDI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IHEDI.png&quot; alt=&quot;Buffer window&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-08-12T22:18:36.833" LastActivityDate="2016-08-12T22:18:36.833" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9184" PostTypeId="1" AcceptedAnswerId="9185" CreationDate="2016-08-09T00:58:08.423" Score="1" ViewCount="395" Body="&lt;p&gt;I have a large file, about &lt;code&gt;1.5 Gb&lt;/code&gt;. When opening the file in vim, I typically will &lt;code&gt;ctrl-c&lt;/code&gt; escape the buffering so I don't have to wait for the whole file to load. For one particular file, it was modified by a prepackaged program, which subsequently made it made read-only. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I needed to edit this file somewhere near the beginning, so I did so and then saved it using &lt;code&gt;:wq!&lt;/code&gt; (as prompted to do so by vim). When I exited, I noticed that the file had decreased in size from about &lt;code&gt;1.5Gb&lt;/code&gt; to &lt;code&gt;~200Mb&lt;/code&gt;. I believe it only saved what it had loaded before I exited with &lt;code&gt;:wq!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a known behavior of vim? It seems like a bad design flaw that it would tell you to exit with &lt;code&gt;wq!&lt;/code&gt; when a file is read-only, but not warn you that it won't write what hasn't buffered yet. &lt;/p&gt;&#xA;" OwnerDisplayName="lstbl" LastEditorUserId="51" LastEditDate="2016-08-13T13:13:50.343" LastActivityDate="2016-08-13T13:19:18.743" Title="vim :wq! on file with read-only permissions after escaping loading loses information in that file" Tags="|save|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9185" PostTypeId="2" ParentId="9184" CreationDate="2016-08-09T07:11:43.023" Score="3" Body="&lt;p&gt;Not sure what is the question here, but this is a known behaviour.&lt;br&gt;&#xA;This is the reason why loading only part of the file (with &lt;code&gt;ctrl-c&lt;/code&gt; as you did) opens the file in read-only mode, to prevent data losses like the one you described.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find more information here: &lt;a href=&quot;https://stackoverflow.com/questions/908575/how-to-edit-multi-gigabyte-text-files-vim-doesnt-work&quot;&gt;https://stackoverflow.com/questions/908575/how-to-edit-multi-gigabyte-text-files-vim-doesnt-work&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7825" OwnerDisplayName="Elisha" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-08-09T07:11:43.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9186" PostTypeId="2" ParentId="9184" CreationDate="2016-08-13T13:19:18.743" Score="2" Body="&lt;p&gt;Control + C in Vim means the same as in the shell: &quot;cancel everything you're doing as soon as possible&quot;. This includes cancelling actually reading the file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you open a file, Vim will load it in memory (&quot;a buffer&quot;), and &lt;code&gt;:w&lt;/code&gt; will write the buffer to disk. If Vim only loaded 200MB in the buffer, it will only write 200MB to disk. This is expected behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vi.stackexchange.com/q/149/51&quot;&gt;How can I open very large files with good performance?&lt;/a&gt; for tips on how to improve performance.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-08-13T13:19:18.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9187" PostTypeId="2" ParentId="9174" CreationDate="2016-08-13T13:43:33.563" Score="4" Body="&lt;p&gt;A more robust alternative to mxmehl's answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;filetype=mail&lt;/code&gt; Vim will highlight headers for you:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PoCpT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PoCpT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can use the syntax information to determine if a line is a header, and set the textwidth accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The syntax name of the headers are &lt;code&gt;mailHeaderKey&lt;/code&gt;, &lt;code&gt;mailSubject&lt;/code&gt;, &lt;code&gt;mailHeaderEmail&lt;/code&gt;, and &lt;code&gt;mailHeader&lt;/code&gt;. I found this out by looking at &lt;code&gt;/usr/share/vim/vim74/syntax/mail.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I prefer this solution is that it doesn't depend on arbitrary line numbers, but that it works equally correct for emails with one header and twenty headers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetypes&#xA;    autocmd!&#xA;&#xA;    autocmd FileType mail call s:mail()&#xA;augroup end&#xA;&#xA;&quot; Set up ft=mail&#xA;fun! s:mail()&#xA;    augroup ft_mail&#xA;        autocmd!&#xA;        autocmd CursorMoved,CursorMovedI *&#xA;            \  if index([&quot;mailHeaderKey&quot;, &quot;mailSubject&quot;, &quot;mailHeaderEmail&quot;, &quot;mailHeader&quot;], synIDattr(synID(line('.'), col('.'), 1), 'name')) &amp;gt;= 0&#xA;            \|     setlocal textwidth=500&#xA;            \| else&#xA;            \|     setlocal textwidth=72&#xA;            \| endif&#xA;    augroup end&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-08-13T13:51:29.617" LastActivityDate="2016-08-13T13:51:29.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9189" PostTypeId="1" AcceptedAnswerId="9191" CreationDate="2016-08-13T17:47:05.827" Score="4" ViewCount="1795" Body="&lt;p&gt;It would be fine if after &lt;code&gt;:make&lt;/code&gt; command vim opened the new buffer with errors and put the cursor to it. Exactly like &lt;code&gt;:make | copen&lt;/code&gt; command. How to map sequence &lt;code&gt;:make | copen&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8810" LastActivityDate="2017-06-03T08:54:17.993" Title="How to map &quot;make&quot; to &quot;make | copen&quot;?" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9190" PostTypeId="2" ParentId="9189" CreationDate="2016-08-13T18:33:54.167" Score="7" Body="&lt;p&gt;The best solution is to not create a mapping at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply put the following snippet in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup quickfix&#xA;    autocmd!&#xA;    &quot; automatic location/quickfix window&#xA;    autocmd QuickFixCmdPost [^l]* cwindow&#xA;    autocmd QuickFixCmdPost    l* lwindow&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will open the quickfix window automatically after &lt;code&gt;:make&lt;/code&gt; and other quickfix-related commands like &lt;code&gt;:grep&lt;/code&gt;, when there are valid errors (&lt;code&gt;:cwindow&lt;/code&gt; versus &lt;code&gt;:copen&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same for location-related commands like &lt;code&gt;:lvimgrep&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--- EDIT ---&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The general structure of an autocommand is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd [&amp;lt;group&amp;gt;] &amp;lt;EventName&amp;gt;[,&amp;lt;EventName&amp;gt;[,...]] &amp;lt;pattern&amp;gt; &amp;lt;command&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;code&gt;&amp;lt;pattern&amp;gt;&lt;/code&gt; is matched against Ex command names:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;l*&lt;/code&gt; matches all command names starting with &lt;code&gt;l&lt;/code&gt; (&lt;code&gt;:lgrep&lt;/code&gt;, &lt;code&gt;:lmake&lt;/code&gt;, etc.),&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^l]*&lt;/code&gt; matches all command names &lt;em&gt;not&lt;/em&gt; starting with &lt;code&gt;l&lt;/code&gt; (&lt;code&gt;:grep&lt;/code&gt;, &lt;code&gt;:make&lt;/code&gt;, etc.).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Quickfix-related command names start with different letters while location-related command names all start with an &lt;code&gt;l&lt;/code&gt; so &lt;code&gt;l&lt;/code&gt; as first character is a convenient way to discriminate them.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2017-06-03T08:54:17.993" LastActivityDate="2017-06-03T08:54:17.993" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9191" PostTypeId="2" ParentId="9189" CreationDate="2016-08-13T19:14:11.160" Score="4" Body="&lt;p&gt;You could create an abbreviation in the command line mode by adding this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cabbrev mc make&amp;lt;bar&amp;gt;copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when you'll type &lt;code&gt;mc&lt;/code&gt; in the command line it will be replaced by &lt;code&gt;make|copen&lt;/code&gt; making it faster to type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also create a mapping to invoke the commands you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :make&amp;lt;bar&amp;gt;copen&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; As @Sato Katsura pointed it out in the comment my first version of &lt;code&gt;cabbrev&lt;/code&gt; is not a good one: Indeed in the first version &lt;code&gt;mc&lt;/code&gt; will be replaced no matter where it is placed in the command line, so for example I you want to search in a buffer for the string &lt;code&gt;mc&lt;/code&gt; and you try to hit &lt;code&gt;/mc&lt;/code&gt; it will be replaced by &lt;code&gt;/make|copen&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To resolve that @Sato linked &lt;a href=&quot;http://vim.wikia.com/wiki/Replace_a_builtin_command_using_cabbrev&quot; rel=&quot;nofollow&quot;&gt;an interesting tip&lt;/a&gt;. With the following syntax &lt;code&gt;mc&lt;/code&gt; will be replaced only if it is the first thing typed in the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cabbrev make &amp;lt;c-r&amp;gt;=(getcmdtype()==':' &amp;amp;&amp;amp; getcmdpos()==1 ? 'make&amp;lt;bar&amp;gt;copen' : 'make')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-08-18T13:26:55.590" LastActivityDate="2016-08-18T13:26:55.590" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9192" PostTypeId="2" ParentId="4584" CreationDate="2016-08-13T22:33:07.103" Score="8" Body="&lt;p&gt;Sometimes you want a custom auto-completion that doesn't interfere with any of&#xA;the built-in or user-defined autocompletions at all. This is especially useful&#xA;for scripts or plugins that are intended to work for a wide range of filetypes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be done fairly easy with the&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#complete%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;complete()&lt;/code&gt;&lt;/a&gt;&#xA;function and a simple wrapper; most of the procedure is the same as described in &#xA;&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#complete%2dfunctions&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help complete-functions&lt;/code&gt;&lt;/a&gt;&#xA;and Statox's answer, except that you need to define your own mappings and have&#xA;to call &lt;code&gt;complete()&lt;/code&gt; yourself instead of returning a value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a basic example, the comments should explain how it works.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Map &amp;lt;C-x&amp;gt;&amp;lt;C-m&amp;gt; for our custom completion&#xA;inoremap &amp;lt;C-x&amp;gt;&amp;lt;C-m&amp;gt; &amp;lt;C-r&amp;gt;=MyComplete()&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Make subsequent &amp;lt;C-m&amp;gt; presses after &amp;lt;C-x&amp;gt;&amp;lt;C-m&amp;gt; go to the next entry (just like&#xA;&quot; other &amp;lt;C-x&amp;gt;* mappings)&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-m&amp;gt; pumvisible() ?  &quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;C-m&amp;gt;&quot;&#xA;&#xA;&quot; Complete function for addresses; we match the name &amp;amp; address&#xA;fun! MyComplete()&#xA;    &quot; The data. In this example it's static, but you could read it from a file,&#xA;    &quot; get it from a command, etc.&#xA;    let l:data = [&#xA;        \ [&quot;Elmo the Elk&quot;, &quot;daring@brave.com&quot;],&#xA;        \ [&quot;Eek the Cat&quot;, &quot;doesnthurt@help.com&quot;]&#xA;    \ ]&#xA;&#xA;    &quot; Locate the start of the word and store the text we want to match in l:base&#xA;    let l:line = getline('.')&#xA;    let l:start = col('.') - 1&#xA;    while l:start &amp;gt; 0 &amp;amp;&amp;amp; l:line[l:start - 1] =~ '\a'&#xA;        let l:start -= 1&#xA;    endwhile&#xA;    let l:base = l:line[l:start : col('.')-1]&#xA;&#xA;    &quot; Record what matches − we pass this to complete() later&#xA;    let l:res = []&#xA;&#xA;    &quot; Find matches&#xA;    for m in l:data&#xA;        &quot; Check if it matches what we're trying to complete; in this case we&#xA;        &quot; want to match against the start of both the first and second list&#xA;        &quot; entries (i.e. the name and email address)&#xA;        if l:m[0] !~? '^' . l:base &amp;amp;&amp;amp; l:m[1] !~? '^' . l:base&#xA;            &quot; Doesn't match&#xA;            continue&#xA;        endif&#xA;&#xA;        &quot; It matches! See :help complete() for the full docs on the key names&#xA;        &quot; for this dict.&#xA;        call add(l:res, {&#xA;            \ 'icase': 1,&#xA;            \ 'word': l:m[0] . ' &amp;lt;' . l:m[1] . '&amp;gt;, ',&#xA;            \ 'abbr': l:m[0],&#xA;            \ 'menu': l:m[1],&#xA;            \ 'info': len(l:m) &amp;gt; 2 ? join(l:m[2:], &quot;\n&quot;) : '',&#xA;        \ })&#xA;    endfor&#xA;&#xA;    &quot; Now call the complete() function&#xA;    call complete(l:start + 1, l:res)&#xA;    return ''&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-08-13T22:33:07.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9193" PostTypeId="2" ParentId="5393" CreationDate="2016-08-14T15:31:24.983" Score="4" Body="&lt;p&gt;It's installed in the .vim/ dir, because of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.config/nvim/plugged')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead, as answered above&lt;/p&gt;&#xA;" OwnerUserId="8817" LastActivityDate="2016-08-14T15:31:24.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9194" PostTypeId="2" ParentId="196" CreationDate="2016-08-14T19:53:14.543" Score="3" Body="&lt;p&gt;You can also use the &lt;code&gt;[^\]+/.&lt;/code&gt; to prevent greediness. &lt;code&gt;[^/]&lt;/code&gt; means &quot;match anything expect &lt;code&gt;/&lt;/code&gt;, and &lt;code&gt;+&lt;/code&gt; repeats that one or more times..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s!\v^(https?)\://([^/]+)/.*$!Protocol:\1 \t Domain:\2!g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I have &lt;code&gt;/&lt;/code&gt; in the regex, I will use &lt;code&gt;!&lt;/code&gt; as a separator so that I don't have to escape &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Example&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Let's suppose you have the following urls:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://academy.mises.org/courses/econgd/&#xA;http://academy.mises.org/moodle/course/view.php?id=172&#xA;http://acmsel.safaribooksonline.com/book/-/9781449358204?bookview=overview&#xA;http://acmsel.safaribooksonline.com/home&#xA;http://acordes.lacuerda.net/bebo__cigala/lagrimas_negras-2.shtml&#xA;http://acordes.lacuerda.net/jose_antonio_labordeta/albada.shtml&#xA;http://anarchitext.wordpress.com/category/new-middle-east/&#xA;https://courses.edx.org/courses/course-v1%3ADelftX%2BFP101x%2B3T2015/wiki/DelftX.FP101x.3T2015/resources-and-links/&#xA;https://cseweb.ucsd.edu/classes/wi11/cse230/lectures.html&#xA;https://developer.mozilla.org/en-US/docs/CSS&#xA;https://developers.google.com/edu/python&#xA;https://developers.google.com/structured-data/testing-tool/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Applying the substitution you would get that :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Protocol:http    Domain:academy.mises.org&#xA;Protocol:http    Domain:academy.mises.org&#xA;Protocol:http    Domain:acmsel.safaribooksonline.com&#xA;Protocol:http    Domain:acmsel.safaribooksonline.com&#xA;Protocol:http    Domain:acordes.lacuerda.net&#xA;Protocol:http    Domain:acordes.lacuerda.net&#xA;Protocol:http    Domain:anarchitext.wordpress.com&#xA;Protocol:https   Domain:courses.edx.org&#xA;Protocol:https   Domain:cseweb.ucsd.edu&#xA;Protocol:https   Domain:developer.mozilla.org&#xA;Protocol:https   Domain:developers.google.com&#xA;Protocol:https   Domain:developers.google.com&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8800" LastEditorUserId="51" LastEditDate="2019-05-21T02:06:07.867" LastActivityDate="2019-05-21T02:06:07.867" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9195" PostTypeId="1" AcceptedAnswerId="9204" CreationDate="2016-08-14T22:55:17.393" Score="2" ViewCount="80" Body="&lt;p&gt;I am trying to write a VIM highlight file for Gaussian 09 inputs. One example of &quot;control&quot; line is shown below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# P TPSSTPSS 6-31G* DENSITYFIT&#xA;  OPT(VERYTIGHT) INT(ULTRAFINE)&#xA;  FREQ(NORAMAN)&#xA;&#xA;TITLE LINE, NOT CONTROL LINE, SO OPT HERE SHOULD NOT HIGHLIGHT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The point is, if a &lt;code&gt;#&lt;/code&gt; mark is found at the beginning of the line, then the following lines are concatenated until an empty line is found, and the words are considered as keywords, e.g. &lt;code&gt;OPT&lt;/code&gt; is a keyword in the second row, however it is no longer a keyword in the fifth row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I let the &lt;code&gt;syntax&lt;/code&gt; command in VIM know it needs to join them, and restrict the keywords inside it?&lt;/p&gt;&#xA;" OwnerUserId="8820" LastActivityDate="2016-08-15T16:06:24.680" Title="How to do restrict keyword inside special lines?" Tags="|syntax-highlighting|multiple-lines|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9196" PostTypeId="1" CreationDate="2016-08-15T08:39:42.447" Score="0" ViewCount="47" Body="&lt;p&gt;for example, I want to comment out all printLog() functions in a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//printLog();&#xA;printLog();&#xA;//printLog();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but some printLog() are already comment out, and replacing printLog() with //printLog() directly would result in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;////printLog();&#xA;//printLog();&#xA;////printLog();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is it possible to replace &quot;printLog();&quot; into &quot;//printLog();&quot; but not &quot;printLog();&quot; originally in &quot;//printLog();&quot;?&lt;/p&gt;&#xA;" OwnerUserId="3292" LastActivityDate="2016-08-15T16:57:06.973" Title="How to replace all &quot;printLog();&quot; into &quot;//printLog();&quot; but not resulting &quot;////printLog();&quot;?" Tags="|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9197" PostTypeId="2" ParentId="9196" CreationDate="2016-08-15T09:27:14.580" Score="1" Body="&lt;p&gt;You could anchor your search pattern to the beginning of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s@^printLog@//&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and maybe take leading white space into account for more safety:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s@^\s*printLog@//&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Breaking it down…&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:s&lt;/code&gt; allows you to use other characters than forward slashes as separators, that's handy when your search pattern or replacement contain forward slashes. Here I use &lt;code&gt;@&lt;/code&gt; but you can use any character except &lt;code&gt;a-zA-Z0-9\&quot;|&lt;/code&gt;. See &lt;code&gt;:help e146&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;^&lt;/code&gt; atom represents the beginning of the line so &lt;code&gt;^printLog&lt;/code&gt; will only match &lt;code&gt;printLog&lt;/code&gt; if it is at the beginning of a line. See &lt;code&gt;:help /^&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;In the &quot;safe&quot; variant, we add &quot;zero or more white space characters&quot; (&lt;code&gt;\s*&lt;/code&gt;) between the beginning of the line and &lt;code&gt;printLog&lt;/code&gt;. See &lt;code&gt;:help \s&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;In the replacement part, we reuse the matched text with &lt;code&gt;&amp;amp;&lt;/code&gt;. See &lt;code&gt;:help s/\&amp;amp;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-08-15T09:44:45.643" LastActivityDate="2016-08-15T09:44:45.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9198" PostTypeId="1" CreationDate="2016-08-15T09:45:45.620" Score="4" ViewCount="219" Body="&lt;p&gt;Considerthis text with shopping and todo list&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;First thing in the morning&#xA;- call Bob&#xA;- buy carrots&#xA;- buy bread&#xA;- text Charlie&#xA;- buy butter&#xA;- email Alice&#xA;only then start the day&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I am looking for a is a vim command to be applied from the first line that starts with a minus, to the last one that does. Something of the short of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/^\s*-/,!/^\s*-/!sort -u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will produce&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;First thing in the morning&#xA;- buy bread&#xA;- buy butter&#xA;- buy carrots&#xA;- call Bob&#xA;- email Alice&#xA;- text Charlie&#xA;only then start the day&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="51" LastEditDate="2016-08-15T12:00:31.807" LastActivityDate="2016-08-15T13:10:37.210" Title="Define range as: &quot;from first line matching to last line matching a given pattern&quot;" Tags="|range|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9199" PostTypeId="2" ParentId="9198" CreationDate="2016-08-15T11:02:25.927" Score="2" Body="&lt;p&gt;Here are two functions that you could use.&#xA;Both takes as argument a pattern to search and a command to execute on the&#xA;consecutive lines matching the pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can call them with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call RangeFromPattern(&quot;^\s*-&quot;, &quot;!sort -u&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one goes to the first line of the buffer, searches for the first line&#xA;matching the pattern, then goes to the last line of the buffer, searches for the&#xA;last line matching the pattern and then apply the command to the range&#xA;&lt;code&gt;firstline,lastline&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if you buffer contains several sections like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. First line&#xA;2. - matching pattern&#xA;3. - matching pattern&#xA;4. not matching pattern&#xA;5. - matching pattern&#xA;6. - matching pattern&#xA;7. Last line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command will be applied to lines 2 to 6 (including the line 4 which doesn't&#xA;match the pattern)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RangeFromPattern(pattern, command)&#xA;    &quot; Save cursor position&#xA;    let saveCursor = getcurpos()&#xA;&#xA;    &quot; Get the first line matching the pattern&#xA;    call cursor(1, 1)&#xA;    let firstLine = search(a:pattern, &quot;c&quot;)&#xA;&#xA;    &quot; Get the last line matching the pattern&#xA;    call cursor('$', 1)&#xA;    let lastLine = search(a:pattern, &quot;b&quot;)&#xA;&#xA;    &quot; Restore the pattern position&#xA;    call setpos('.', saveCursor)&#xA;&#xA;    &quot; Execute the command&#xA;    execute firstLine . &quot;,&quot; . lastLine . a:command&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now to avoid the problem of the previous function here is another version which&#xA;will start the search on the current line, keep the number of the first matching&#xA;line, increment this number while the next lines matches the pattern and finally&#xA;apply the command to this set of lines. On the previous example I gave, if you&#xA;call the function with your cursor on line 5, the command will be applied on&#xA;range 5 to 6.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RangeFromPattern2(pattern, command)&#xA;    &quot; Save cursor position&#xA;    let saveCursor = getcurpos()&#xA;&#xA;    &quot; Get the first line matching the pattern&#xA;    let firstLine = search(a:pattern, &quot;c&quot;)&#xA;&#xA;    &quot; Get the contiguous lines matching the pattern&#xA;    let prevLine = firstLine&#xA;    while (search(a:pattern) == prevLine + 1)&#xA;        let prevLine += 1&#xA;    endwhile&#xA;&#xA;    &quot; Restore the pattern position&#xA;    call setpos('.', saveCursor)&#xA;&#xA;    &quot; Execute the command&#xA;    execute firstLine . &quot;,&quot; . prevLine . a:command&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;An example of the function on your example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kIWjQ.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kIWjQ.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-08-15T11:16:49.690" LastActivityDate="2016-08-15T11:16:49.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9200" PostTypeId="2" ParentId="9198" CreationDate="2016-08-15T11:25:16.767" Score="1" Body="&lt;p&gt;Based on &lt;a href=&quot;https://stackoverflow.com/questions/3498768/how-do-i-define-a-range-and-sort-by-number-in-vim-using-regular-expressions&quot;&gt;this answer on SO&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/^\s*-/,/^only/-1 !sort -u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;provided the cursor is not placed anywhere on the lines starting with &lt;code&gt;-&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, I don't know why&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/^\s*-/,/^\s*[^-]/-1 !sort -u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works only if cursor is positioned on the line immediately before start of search pattern&lt;/p&gt;&#xA;" OwnerUserId="1616" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-08-15T11:25:16.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9201" PostTypeId="2" ParentId="9198" CreationDate="2016-08-15T13:10:37.210" Score="2" Body="&lt;p&gt;Assuming the lines that start with a minus will be contiguous, I would use visual mode (assuming vim). Highlight the minus lines, then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will get you there.&#xA;The whole sequence, assuming a file with that format, starting at the first character of the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;jVGk:sort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8824" LastActivityDate="2016-08-15T13:10:37.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9202" PostTypeId="1" AcceptedAnswerId="9203" CreationDate="2016-08-15T13:44:30.070" Score="6" ViewCount="1125" Body="&lt;p&gt;I understand that the right way to delete until the end of line is d$, but why does dt$ not work also?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2016-10-12T19:39:28.597" Title="Why does dt$ not delete until the end of line?" Tags="|object-motions|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9203" PostTypeId="2" ParentId="9202" CreationDate="2016-08-15T14:04:14.180" Score="31" Body="&lt;p&gt;Because &lt;code&gt;t&lt;/code&gt; takes a character, so it looking for a literal &lt;code&gt;$&lt;/code&gt; character, not a motion like end of line&lt;/p&gt;&#xA;" OwnerUserId="1828" LastActivityDate="2016-08-15T14:04:14.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9204" PostTypeId="2" ParentId="9195" CreationDate="2016-08-15T15:30:18.337" Score="1" Body="&lt;p&gt;You can do this with a syntax region. Basically you have to define that your keywords will be contained in a region and then define the region that they will be contained in. Like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword ConcatKeywords OPT INT FREQ contained&#xA;syn region Concat start='^#' end='^$' contains=ConcatKeywords&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The important part here is the &lt;code&gt;contained&lt;/code&gt; option after the first line and the &lt;code&gt;contains=&lt;/code&gt; option after the second line. This will make vim look for these keywords &lt;em&gt;only&lt;/em&gt; in the regions that have it &lt;code&gt;contained&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will, of course, then need to highlight your keywords. You can define your own or link it to an already exsisting highlight:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi link ConcatKeywords PreProc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more info I would recommend &lt;a href=&quot;http://vim.wikia.com/wiki/Creating_your_own_syntax_files&quot; rel=&quot;nofollow&quot;&gt;this great tutorial on the vim wiki&lt;/a&gt;, as well as these help documents: &lt;code&gt;:h syn-keyword&lt;/code&gt;, &lt;code&gt;:h syn-match&lt;/code&gt;, and &lt;code&gt;:h syn-region&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-08-15T16:06:24.680" LastActivityDate="2016-08-15T16:06:24.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9205" PostTypeId="1" AcceptedAnswerId="9207" CreationDate="2016-08-15T16:53:47.013" Score="2" ViewCount="809" Body="&lt;p&gt;I have a following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Search items: [http://vimdoc.net/search?q=/\\][s]&#xA;&#xA;...&#xA;[s]: http://vimdoc.net/search?q=/\\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I would like to find the &lt;code&gt;http://vimdoc.net/search?q=/\\&lt;/code&gt; string from this text. I can do this with &lt;code&gt;\Vhttp:\/\/vimdoc.net\/search?q=\/\\\\&lt;/code&gt; search pattern. However, I would expect &lt;code&gt;\Vhttp:\/\/vimdoc.net\/search\?q=\/\\\\&lt;/code&gt; to also work(&lt;code&gt;?&lt;/code&gt; is escaped). I mean in case of &lt;code&gt;\V&lt;/code&gt;, the backslash(&lt;code&gt;\&lt;/code&gt;) character has a special meaning. Could somebody please explain this.&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2016-08-15T19:28:45.723" Title="understand backslash in search pattern in case of &quot;very nomagic&quot; mode" Tags="|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9207" PostTypeId="2" ParentId="9205" CreationDate="2016-08-15T17:28:08.550" Score="5" Body="&lt;p&gt;According to the manual:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use of &quot;\V&quot; means that in the pattern after it only the backslash and the&#xA;  terminating character (/ or ?) has a special meaning.  &quot;very nomagic&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The phrasing is somewhat misleading.  What this actually means is that you always need to escape the backslash (&lt;code&gt;\&lt;/code&gt; -&gt; &lt;code&gt;\\&lt;/code&gt;), but you only need to escape &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;?&lt;/code&gt; when they are used as &lt;em&gt;terminating characters&lt;/em&gt;.  Namely:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;To search forward you have to start with &lt;code&gt;/&lt;/code&gt;, so &lt;code&gt;/&lt;/code&gt; becomes a terminating character.  Thus you need to escape &lt;code&gt;/&lt;/code&gt; (and &lt;code&gt;\&lt;/code&gt;), but not &lt;code&gt;?&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\Vhttp:\/\/vimdoc.net\/search?q=\/\\\\&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To search backwards you have to start with &lt;code&gt;?&lt;/code&gt;, so &lt;code&gt;?&lt;/code&gt; becomes a terminating character.  Thus you need to escape &lt;code&gt;?&lt;/code&gt; (and &lt;code&gt;\&lt;/code&gt;), but not &lt;code&gt;/&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?\Vhttp://vimdoc.net/search\?q=/\\\\&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, when you do a replace you can avoid the &lt;a href=&quot;https://en.wikipedia.org/wiki/Leaning_toothpick_syndrome&quot; rel=&quot;nofollow&quot;&gt;leaning toothpick syndrome&lt;/a&gt; almost entirely, by choosing a terminating character that is neither &lt;code&gt;/&lt;/code&gt; nor &lt;code&gt;?&lt;/code&gt;.  Here only &lt;code&gt;\&lt;/code&gt; needs to be escaped:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s!\Vhttp://vimdoc.net/search?q=/\\\\!...!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can still minimise your pain even when searching forward.  Since you have way more slashes than question marks in your pattern you can start by searching backwards first, just to set the pattern, then change the search direction:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?\Vhttp://vimdoc.net/search\?q=/\\\\&#xA;/&#xA;n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another consequence is that you only ever need to escape &lt;code&gt;\&lt;/code&gt; when using &lt;code&gt;\V&lt;/code&gt; patterns with the &lt;code&gt;search()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo search('\Vhttp://vimdoc.net/search?q=/\\\\', 'c')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="2313" LastEditDate="2016-08-15T19:28:45.723" LastActivityDate="2016-08-15T19:28:45.723" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9209" PostTypeId="1" AcceptedAnswerId="9211" CreationDate="2016-08-16T07:04:26.170" Score="-1" ViewCount="419" Body="&lt;p&gt;I've done vimtutor several times when I get bored. I love the idea of Vim. It's keyboard shortcuts have a lot of relevancy to me and I just feel like there's a lot available to me, that wasn't available in my current editor (Atom). Plus I like the idea of the extensibility that vim offers. As of now I can't get away from Atom just because I can't just start using Vim at work and have a slow curve to get back to speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test my speed I wrote the basic Hello, World program in C. In Atom I was able to accomplish this in under 30 seconds. However in Vim, it took me over 2 minutes. Are there any good resources out there to get over that initial hump?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;br/&gt;&#xA;So I found the reason I was so much slower on Vim was not because of Vim itself, but the version I have installed on my Mac was bugged and wouldn't let me do things like backspace in INSERT mode. Having only used Vim on my Mac I always thought this was correct. So I would be slowed down by typos because I would have to go to NORMAL mode and then use X on any misplaced characters. I retried this time test on my Linux machine, and I was actually (slightly)faster on Vim. This made the &quot;learning curve&quot; I was having seem non-existent. &lt;/p&gt;&#xA;" OwnerUserId="8834" LastEditorUserId="8834" LastEditDate="2016-08-18T14:25:23.487" LastActivityDate="2016-08-18T14:25:23.487" Title="Good Ways to Get Over that Vim Learning Curve?" Tags="|macvim|" AnswerCount="2" CommentCount="9" ClosedDate="2016-08-16T21:21:58.913" ContentLicense="CC BY-SA 3.0" />
  <row Id="9210" PostTypeId="2" ParentId="9209" CreationDate="2016-08-16T07:23:25.953" Score="1" Body="&lt;p&gt;It took me 4 months to reach, and eventually surpass, my previous productivity level. In the mean time I just kept using TextMate as my main editor. Be patient.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-16T07:23:25.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9211" PostTypeId="2" ParentId="9209" CreationDate="2016-08-16T08:01:13.517" Score="3" Body="&lt;p&gt;The only good resource I can recommend is Vim itself. It's only with practice that you will gain in productivity. So make a deal with yourself, use only Vim, no matter what, stick to it. It'll take some time before you can type as quickly as you used to, but you'll learn so much more. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I can't just start using Vim at work and have a slow curve to get back to speed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I understand, and it seems to be a blocking point, but you can overcome it. For example, when you're at home, and writing something, whether it's a mail, some code, a blog post, ... do it with Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now and then, when you start to feel comfortable with the basic movement and edition command, start your day with Vim. And if you can't afford to be slower, go back to Atom. But each day try to start with Vim, for 10 minutes, 30 minutes, 1 hour, ... And one day you'll never leave it again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did the same thing while switching from Sublime Text 2, and the transition was made the day I typed in ST2 &lt;code&gt;ciw&lt;/code&gt;. The memory muscle was starting to build up and could not go back (not in a bad way though, I found the Vim way much more productive).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for any kind of activity, the results come with practice. Practice Vim, talk about it, exchange with others, go to meetings, and read the doc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want for resources to help you understand Vim, I could not recommend enough:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Learn to read the doc: &lt;code&gt;:help intro&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://pragprog.com/book/dnvim/practical-vim&quot; rel=&quot;nofollow&quot;&gt;Practical Vim by Drew Niel&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com&quot; rel=&quot;nofollow&quot;&gt;Learn Vim Script the Hard Way by Steve Losh&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/episodes/archive/&quot; rel=&quot;nofollow&quot;&gt;Vim Casts by Drew Niel&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=_NUO4JEtkDw&quot; rel=&quot;nofollow&quot;&gt;And&lt;/a&gt; &lt;a href=&quot;https://www.youtube.com/watch?v=aHm36-na4-4&quot; rel=&quot;nofollow&quot;&gt;some&lt;/a&gt; &lt;a href=&quot;https://www.youtube.com/watch?v=wlR5gYd6um0&quot; rel=&quot;nofollow&quot;&gt;videos&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But keep in mind, the real only way to learn Vim, is to open Vim and use it.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-08-16T08:01:13.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9212" PostTypeId="1" AcceptedAnswerId="9213" CreationDate="2016-08-16T08:03:20.217" Score="35" ViewCount="47626" Body="&lt;p&gt;In vim &lt;code&gt;:make&lt;/code&gt; makes it easy to build and fix errors, and &lt;code&gt;:grep&lt;/code&gt; and &lt;code&gt;:vimgrep&lt;/code&gt; behaves like &lt;code&gt;:make&lt;/code&gt;.  But why do you need these two commands? Why not just search for the pattern and just press &lt;code&gt;n&lt;/code&gt;? What are the advantages of them over just searching? &lt;/p&gt;&#xA;" OwnerUserId="8790" LastEditorUserId="8790" LastEditDate="2016-08-16T08:31:26.103" LastActivityDate="2018-10-15T13:35:22.657" Title="When to use :grep and :vimgrep in vim?" Tags="|command-line|search|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9213" PostTypeId="2" ParentId="9212" CreationDate="2016-08-16T08:09:11.603" Score="23" Body="&lt;p&gt;As the doc say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vim has two ways to find matches for a pattern: Internal and external.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a nutshell, &lt;code&gt;:vimgrep&lt;/code&gt; uses Vim's grep mechanism to read and find in files. &lt;code&gt;:grep&lt;/code&gt; uses an external commands to achieve the same job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;/&lt;/code&gt; search is for the current buffer only, whereas &lt;code&gt;:[vim]grep&lt;/code&gt; search through a pattern of files, allowing you to search in an entire project at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at &lt;code&gt;:h grep&lt;/code&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-08-16T08:09:11.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9214" PostTypeId="2" ParentId="9212" CreationDate="2016-08-16T08:10:13.683" Score="4" Body="&lt;p&gt;&lt;code&gt;/?&lt;/code&gt; only search the current buffer but &lt;code&gt;:grep&lt;/code&gt; and &lt;code&gt;:vimgrep&lt;/code&gt; take arbitrary files/patterns/globs as arguments.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-16T08:10:13.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9215" PostTypeId="1" AcceptedAnswerId="9217" CreationDate="2016-08-16T09:34:07.670" Score="1" ViewCount="257" Body="&lt;p&gt;I have this in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * if !argc() | NERDTree | se nu  | se rnu | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, I have an alias in my &lt;code&gt;.bashrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias fv='find &quot;$PWD&quot; -maxdepth 1 | vim -R -'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After I run &lt;code&gt;fv&lt;/code&gt; in command line - It opens &lt;code&gt;vim&lt;/code&gt; with &lt;code&gt;NERDTree&lt;/code&gt; opened in it. Is there a way to not open &lt;code&gt;NERDTree&lt;/code&gt; when I run &lt;code&gt;vim&lt;/code&gt; with &lt;code&gt;-R&lt;/code&gt; option?&lt;/p&gt;&#xA;" OwnerUserId="3302" LastEditorUserId="4472" LastEditDate="2017-09-21T05:47:21.627" LastActivityDate="2017-09-21T05:47:21.627" Title="How to hide NERDTree when vim called with -R option?" Tags="|vimrc|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9217" PostTypeId="2" ParentId="9215" CreationDate="2016-08-16T12:32:42.527" Score="3" Body="&lt;p&gt;Instead of just asking if there are no arguments, you could also ask if the buffer is empty.&#xA;If you substitute &lt;code&gt;!argc()&lt;/code&gt; in your &lt;code&gt;autocmd&lt;/code&gt; by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!argc() &amp;amp;&amp;amp; bufnr('$') == 1 &amp;amp;&amp;amp; line('$') == 1 &amp;amp;&amp;amp; getline(1) == '' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you should get the desired result.&lt;/p&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2016-08-16T12:32:42.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9218" PostTypeId="1" AcceptedAnswerId="10321" CreationDate="2016-08-16T13:07:54.633" Score="2" ViewCount="3022" Body="&lt;p&gt;For me it's very annoying to have two functions to close window (&lt;code&gt;:quit&lt;/code&gt;) or quit vim. I just want one command to close window and another command to quit vim. For example &lt;code&gt;:q&lt;/code&gt; command to close window and &lt;code&gt;:e&lt;/code&gt; to quit/exit vim. How to create these shortcuts in vim configuration?&lt;/p&gt;&#xA;" OwnerUserId="8709" LastEditorUserId="1841" LastEditDate="2016-08-16T13:56:37.160" LastActivityDate="2016-11-17T19:44:22.493" Title="How to stop quitting vim but close windows?" Tags="|key-bindings|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9219" PostTypeId="2" ParentId="9218" CreationDate="2016-08-16T13:59:30.123" Score="7" Body="&lt;p&gt;If it's windows you're after, use &lt;code&gt;:close&lt;/code&gt; or &lt;code&gt;ctrl-w c&lt;/code&gt; to close windows one by one (except the last one - it won't let you do it). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also have &lt;code&gt;:only&lt;/code&gt; to keep just the current window and close all others (or &lt;code&gt;ctrl-w o&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The buffers, that's another story.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-08-16T15:16:34.317" LastActivityDate="2016-08-16T15:16:34.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9220" PostTypeId="1" AcceptedAnswerId="9221" CreationDate="2016-08-16T14:23:17.257" Score="1" ViewCount="215" Body="&lt;p&gt;I want to &lt;code&gt;imap&lt;/code&gt; the sequence &lt;code&gt;^^&lt;/code&gt; to &lt;code&gt;^{}&amp;lt;++&amp;gt;&lt;/code&gt; and then place the cursor inside the brackets. (This is handy when editing &lt;em&gt;Latex&lt;/em&gt; code and is a nice feature of the &lt;em&gt;vim latex suite&lt;/em&gt; which I have recently abandoned) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The straight forward approach doesn't work for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:imap ^^ ^{x}&amp;lt;++&amp;gt;&amp;lt;esc&amp;gt;Fxs&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="8648" LastActivityDate="2016-08-17T11:55:52.300" Title="imap `^^` to `^{}&lt;++&gt;` and place cursor inside" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9221" PostTypeId="2" ParentId="9220" CreationDate="2016-08-16T14:33:26.693" Score="3" Body="&lt;pre&gt;&lt;code&gt;inoremap ^^ ^{}&amp;lt;++&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is ugly, but it should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h i_&amp;lt;Left&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-08-16T15:25:57.713" LastActivityDate="2016-08-16T15:25:57.713" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9223" PostTypeId="1" AcceptedAnswerId="9226" CreationDate="2016-08-16T15:40:21.313" Score="3" ViewCount="1672" Body="&lt;p&gt;When I install vim from repository on Arch Linux, it has a completion feature that I don't like. What is it called and how do I turn it off? (It is active even with a blank .vimrc.) I would rather get vim exactly as it is in, e.g., Linux Mint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[edit 2] here's an example of one of the things it does. (This is after I've enabled syntax highlighting and line numbers.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nqdhB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nqdhB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[edit] the output of :scriptnames&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/etc/vimrc&#xA;/usr/share/vim/vimfiles/archlinux.vim&#xA;~/.vimrc&#xA;/usr/share/vim/vim74/syntax/syntax.vim&#xA;/usr/share/vim/vim74/syntax/synload.vim&#xA;/usr/share/vim/vim74/syntax/syncolor.vim&#xA;/usr/share/vim/vim74/filetype.vim&#xA;/usr/share/vim/vimfiles/ftdetect/UltiSnips.vim&#xA;/usr/share/vim/vimfiles/ftdetect/snippets.vim&#xA;/usr/share/vim/vim74/colors/winter.vim&#xA;/usr/share/vim/vim74/colors/default.vim&#xA;/usr/share/vim/vimfiles/plugin/DoxygenToolkit.vim&#xA;/usr/share/vim/vimfiles/plugin/NERD_commenter.vim&#xA;/usr/share/vim/vimfiles/plugin/NERD_tree.vim&#xA;/usr/share/vim/vimfiles/plugin/SyntaxFolds.vim&#xA;/usr/share/vim/vimfiles/plugin/UltiSnips.vim&#xA;/usr/share/vim/vimfiles/autoload/UltiSnips/map_keys.vim&#xA;/usr/share/vim/vimfiles/plugin/a.vim&#xA;/usr/share/vim/vimfiles/plugin/airline-themes.vim&#xA;/usr/share/vim/vimfiles/plugin/airline.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/init.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/parts.vim&#xA;/usr/share/vim/vimfiles/plugin/bufexplorer.vim&#xA;/usr/share/vim/vimfiles/plugin/ctrlp.vim&#xA;/usr/share/vim/vimfiles/autoload/ctrlp/mrufiles.vim&#xA;/usr/share/vim/vimfiles/plugin/filebrowser.vim&#xA;/usr/share/vim/vimfiles/plugin/fugitive.vim&#xA;/usr/share/vim/vimfiles/plugin/guicolorscheme.vim&#xA;/usr/share/vim/vimfiles/plugin/imaps.vim&#xA;/usr/share/vim/vimfiles/plugin/indent-object.vim&#xA;/usr/share/vim/vimfiles/plugin/jad.vim&#xA;/usr/share/vim/vimfiles/plugin/jedi.vim&#xA;/usr/share/vim/vim74/ftplugin.vim&#xA;/usr/share/vim/vimfiles/plugin/libList.vim&#xA;/usr/share/vim/vimfiles/plugin/minibufexpl.vim&#xA;/usr/share/vim/vimfiles/plugin/project.vim&#xA;/usr/share/vim/vimfiles/plugin/remoteOpen.vim&#xA;/usr/share/vim/vimfiles/plugin/supertab.vim&#xA;/usr/share/vim/vimfiles/plugin/surround.vim&#xA;/usr/share/vim/vimfiles/plugin/tagbar.vim&#xA;/usr/share/vim/vimfiles/plugin/taglist.vim&#xA;/usr/share/vim/vimfiles/plugin/vcsbzr.vim&#xA;/usr/share/vim/vimfiles/plugin/vcscommand.vim&#xA;/usr/share/vim/vimfiles/plugin/vcscvs.vim&#xA;/usr/share/vim/vimfiles/plugin/vcsgit.vim&#xA;/usr/share/vim/vimfiles/plugin/vcshg.vim&#xA;/usr/share/vim/vimfiles/plugin/vcssvk.vim&#xA;/usr/share/vim/vimfiles/plugin/vcssvn.vim&#xA;/usr/share/vim/vimfiles/plugin/workspace.vim&#xA;/usr/share/vim/vim74/plugin/getscriptPlugin.vim&#xA;/usr/share/vim/vim74/plugin/gzip.vim&#xA;/usr/share/vim/vim74/plugin/logiPat.vim&#xA;/usr/share/vim/vim74/plugin/manpager.vim&#xA;/usr/share/vim/vim74/plugin/matchparen.vim&#xA;/usr/share/vim/vim74/plugin/netrwPlugin.vim&#xA;/usr/share/vim/vim74/plugin/rrhelper.vim&#xA;/usr/share/vim/vim74/plugin/spellfile.vim&#xA;/usr/share/vim/vim74/plugin/tarPlugin.vim&#xA;/usr/share/vim/vim74/plugin/themes.vim&#xA;/usr/share/vim/vim74/plugin/tohtml.vim&#xA;/usr/share/vim/vim74/plugin/vimballPlugin.vim&#xA;/usr/share/vim/vim74/plugin/zipPlugin.vim&#xA;/usr/share/vim/vimfiles/after/plugin/UltiSnips_after.vim&#xA;/usr/share/vim/vimfiles/autoload/UltiSnips.vim&#xA;/usr/share/vim/vim74/syntax/python.vim&#xA;/usr/share/vim/vimfiles/after/syntax/python.vim&#xA;/usr/share/vim/vimfiles/autoload/jedi.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/extensions.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/extensions/quickfix.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/extensions/netrw.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/extensions/ctrlp.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/extensions/tagbar.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/extensions/branch.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/extensions/whitespace.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/extensions/po.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/extensions/wordcount.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/section.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/highlighter.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/themes/dark.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/themes.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/util.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/builder.vim&#xA;/usr/share/vim/vimfiles/autoload/airline/extensions/default.vim&#xA;/usr/share/vim/vimfiles/ftplugin/python/jedi.vim&#xA;/usr/share/vim/vim74/ftplugin/python.vim&#xA;/usr/share/vim/vimfiles/after/ftplugin/python/jedi.vim&#xA;/usr/share/vim/vimfiles/autoload/ctrlp/utils.vim&#xA;/usr/share/vim/vimfiles/nerdtree_plugin/exec_menuitem.vim&#xA;/usr/share/vim/vimfiles/nerdtree_plugin/fs_menu.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8842" LastEditorUserId="51" LastEditDate="2016-08-16T17:57:42.827" LastActivityDate="2016-08-16T17:57:42.827" Title="How to turn off completion (enabled by default in Arch)?" Tags="|autocompletion|installing|linux-arch|" AnswerCount="1" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9224" PostTypeId="2" ParentId="9218" CreationDate="2016-08-16T15:48:47.713" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I just want one command to close window&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:quit&lt;/code&gt;, or &lt;code&gt;:quit!&lt;/code&gt; to abandon changes.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and another command to quit vim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:qa&lt;/code&gt;, or &lt;code&gt;:qa!&lt;/code&gt; to abandon ALL changes.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-08-16T15:48:47.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9225" PostTypeId="2" ParentId="7834" CreationDate="2016-08-16T16:01:58.810" Score="2" Body="&lt;p&gt;In my case I setup all my dev environments like a virtualenv, using pyenv. For errors and warnings, I put &lt;code&gt;pylama&lt;/code&gt; inside my virtualenv (come in my requirements.txt) and pylama requires mccabe, pep257, pep8 and pyflakes.&#xA;All this are probed by neomake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this setup, pylama give me alerts from all these integrated, no extra settings needed. But I must remember to always have active the virtualenv before running neovim for the IDE to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: you can check here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/neomake/neomake/blob/master/autoload/neomake/makers/ft/python.vim&quot; rel=&quot;nofollow&quot;&gt;https://github.com/neomake/neomake/blob/master/autoload/neomake/makers/ft/python.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;that pylama is supported by pymake for default.&lt;/p&gt;&#xA;" OwnerUserId="8843" LastEditorUserId="8843" LastEditDate="2016-08-21T23:24:23.903" LastActivityDate="2016-08-21T23:24:23.903" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9226" PostTypeId="2" ParentId="9223" CreationDate="2016-08-16T16:38:01.900" Score="4" Body="&lt;p&gt;I unknowingly had installed on my system the set of packages &quot;vim-plugins&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Among these was &quot;vim-jedi&quot; which seems to be the one causing behavior I didn't want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used the package manager to remove it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks very much for the commenters who helped me diagnose this!&lt;/p&gt;&#xA;" OwnerUserId="8842" LastActivityDate="2016-08-16T16:38:01.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9227" PostTypeId="2" ParentId="9220" CreationDate="2016-08-16T18:26:23.350" Score="1" Body="&lt;p&gt;With &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets&quot; rel=&quot;nofollow&quot;&gt;lh-bracket&lt;/a&gt;s (which proposes similar features, and which is compatible with latex-suite when installed -- latex-suite installs a plugin named imaps.vim that has side effects with mappings (*)), It would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Brackets ^{ } -trigger=^^ -visual=0 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The placeholder will be added as well, and the result will be compatible with vim 7.4-&lt;em&gt;patchnumberIdontremember&lt;/em&gt; redo feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) If you are still able to use placeholders (as I see you'll like to have &lt;code&gt;&amp;lt;++&amp;gt;&lt;/code&gt; after the closing bracket), and if you are not using lh-brackets, it's likely you have imap.vim still active. This may explain why the mappings proposed in the other answers don't work in your case. Another possible explanation is that &lt;code&gt;^&lt;/code&gt; is a dead key on some keyboard. Half the time it's the case on my French systems.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-08-17T11:55:52.300" LastActivityDate="2016-08-17T11:55:52.300" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9228" PostTypeId="2" ParentId="6900" CreationDate="2016-08-16T19:24:37.237" Score="3" Body="&lt;p&gt;Another option is to simply change your mapping to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-space&amp;gt; &amp;lt;C-o&amp;gt;&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; moves forward one character even when at end of line.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-08-16T19:24:37.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9229" PostTypeId="1" CreationDate="2016-08-16T22:17:02.983" Score="5" ViewCount="256" Body="&lt;p&gt;I haven't found a way to disable spell checking for single character &quot;words&quot;, like when you type 100k (k as in thousand) and it gets highlighted as a mistake. I already tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match SingleChar '/\&amp;lt;\S\&amp;gt;' contains=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't do a thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I could add all characters in a spell file but that seems a bit cheap and would require me to move my spell file around with me instead of just the vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="8848" LastActivityDate="2016-08-16T22:17:02.983" Title="Disable spell check for single character words" Tags="|spell-checking|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9230" PostTypeId="1" CreationDate="2016-08-17T04:52:33.020" Score="1" ViewCount="158" Body="&lt;p&gt;I want to create syntax highlighting for indentation sensitive language that I'm designing, my question is how to highlight multiline comment that begins with #!&lt;br&gt;&#xA;something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#! xxxxxxxxxxx&#xA; xxxxxxxxx&#xA;    xxxxxxxxx&#xA; xxxxxx&#xA;    xxxxxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func arg1 arg2 #! xxxxxxxxxxx&#xA;                 xxxxxxxxx&#xA;                xxxxxxxxx&#xA;                xxxxxx&#xA;                  xxxxxx&#xA;  arg3&#xA;  arg4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;br&gt;&#xA;I found a solution for the first example  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match CommentBlock /\( *\)#!.*\n\(\1 .*\n\)*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8851" LastEditorUserId="8851" LastEditDate="2016-08-17T18:08:04.323" LastActivityDate="2016-08-17T18:08:04.323" Title="syntax highlighting for indentation sensitive multiline comment" Tags="|vimscript|syntax-highlighting|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="9231" PostTypeId="1" AcceptedAnswerId="9288" CreationDate="2016-08-17T09:23:12.437" Score="6" ViewCount="1094" Body="&lt;p&gt;I tend to open multiple tabs in vim and multiple windows within a tab.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a habit of traversing the code in a tree format - I open a tag in a new tab, so that my current view of the window remains unchanged. I can simply close the newly opened tab/window to resume to my previous view.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider a case where I have window &lt;code&gt;A&lt;/code&gt; focused. I open a new split as window &lt;code&gt;B&lt;/code&gt;. Now, when I close window &lt;code&gt;B&lt;/code&gt;, it should focus the earlier window &lt;code&gt;A&lt;/code&gt;. Currently, it always focuses the window on left side of &lt;code&gt;B&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, for tab close case, it always selects the tab on the right side of tab being closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to keep track of the tab/window opening sequence in vim? Then I can trace back the sequence while closing the tab/windows...&lt;br&gt;&#xA;Or better, is there a vim &lt;code&gt;set&lt;/code&gt; command option or an internal variable that handles this automatically?&lt;/p&gt;&#xA;" OwnerUserId="2749" LastActivityDate="2023-08-30T08:47:37.277" Title="Focus previous tab/window when closing current" Tags="|vim-windows|tabbed-user-interface|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9232" PostTypeId="2" ParentId="9231" CreationDate="2016-08-17T11:46:39.550" Score="1" Body="&lt;p&gt;For the windows you could use a function which get the number of the current window, goes to the previous one and close the window of which you got the number earlier. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function CloseAndGoToPreviousW()&#xA;    let prevWin = winnr()&#xA;    execute &quot;wincmd p&quot;&#xA;    execute prevWin . &quot;wincmd q&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then call the function directly or create a mapping to call it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :call CloseAndGoToPreviousW()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Based on that I think you can do the same with the buffers with &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#tabpagenr()&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h tabpagenr()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/tabpage.html#:tabclose&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h :tabclose&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-08-17T11:46:39.550" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9233" PostTypeId="1" AcceptedAnswerId="9234" CreationDate="2016-08-17T13:45:44.713" Score="11" ViewCount="2190" Body="&lt;p&gt;While editing syntax file, I found something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\s*\%(\%(:\@&amp;lt;!\/\/.*\)\=\|\%(\/\*.*\*\/\s*\)*\)$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm familiar with any other than &lt;code&gt;\%&lt;/code&gt; and &lt;code&gt;\@&lt;/code&gt; there. I can't even googling because I don't know what is it's name. So what it is and what it does?&lt;/p&gt;&#xA;" OwnerUserId="1526" LastEditorUserId="1841" LastEditDate="2016-08-17T13:59:21.647" LastActivityDate="2016-08-17T13:59:21.647" Title="What is '\%' and '\@' token's name in vim regex? And what does it do?" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9234" PostTypeId="2" ParentId="9233" CreationDate="2016-08-17T13:52:44.427" Score="15" Body="&lt;p&gt;Before googling, try the doc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#E53&quot;&gt;&lt;code&gt;:h \%&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(\)   A pattern enclosed by escaped parentheses.&#xA;    Just like \(\), but without counting it as a sub-expression.  This&#xA;    allows using more groups and it's a little bit faster.&#xA;    {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5C@&amp;lt;!&quot;&gt;&lt;code&gt;:h \@&amp;lt;!&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\@&amp;lt;!    Matches with zero width if the preceding atom does NOT match just&#xA;    before what follows.  Thus this matches if there is no position in the&#xA;    current or previous line where the atom matches such that it ends just&#xA;    before what follows.&#xA;&#xA;    Like &quot;(?&amp;lt;!pattern)&quot; in Perl, but Vim allows non-fixed-width patterns.&#xA;    The match with the preceding atom is made to end just before the match&#xA;    with what follows, thus an atom that ends in &quot;.*&quot; will work.&#xA;    Warning: This can be slow (because many positions need to be checked&#xA;    for a match).  Use a limit if you can, see below.&#xA;&#xA;    Example         matches ~&#xA;&#xA;    \(foo\)\@&amp;lt;!bar      any &quot;bar&quot; that's not in &quot;foobar&quot;&#xA;&#xA;    \(\/\/.*\)\@&amp;lt;!in    &quot;in&quot; which is not after &quot;//&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-08-17T13:58:09.803" LastActivityDate="2016-08-17T13:58:09.803" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9235" PostTypeId="2" ParentId="7457" CreationDate="2016-08-17T14:34:39.173" Score="12" Body="&lt;p&gt;As of Windows 10 Anniversary Update, you can use the &lt;a href=&quot;https://msdn.microsoft.com/en-us/commandline/wsl/about&quot; rel=&quot;noreferrer&quot;&gt;Bash on Ubuntu terminal&lt;/a&gt; to run a Linux subsystem where you can &lt;code&gt;apt install&lt;/code&gt; anything you're used to inside Ubuntu. Your Windows file system is mounted so you can use Vim inside the shell to edit your files.&lt;/p&gt;&#xA;" OwnerUserId="8857" LastActivityDate="2016-08-17T14:34:39.173" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9236" PostTypeId="1" CreationDate="2016-08-18T07:52:44.517" Score="3" ViewCount="1635" Body="&lt;p&gt;I have encountered very strange problem using vimgrep command. I try to find a match in all the files in all subdirs of a specified directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /word_I_search/ path\to\my\dir\**\*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(there are backslashes in path because I am on Windows). Command reports:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E480: No match: word_I_search&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I know there are matches! And if I do not search in subdirs or if I start searching one level higher everything is ok. Following commands successfully find what I want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /word_I_search/ path\to\my\dir\*&#xA;:vimgrep /word_I_search/ path\to\my\**\*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have never encountered this problem on my Linux machine and do not know where to start troubleshooting it. Any ideas? Please help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;command works as expected if I use less backslashes. Following commands work as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /word_I_search/ path/to/my/dir/**/*&#xA;:vimgrep /word_I_search/ path\to\my\dir\**/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6194" LastEditorUserId="6194" LastEditDate="2016-08-18T08:14:42.767" LastActivityDate="2019-06-18T17:07:48.210" Title="vimgrep can not find a pattern in specified directory" Tags="|search|vim-windows|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9237" PostTypeId="1" AcceptedAnswerId="9238" CreationDate="2016-08-18T08:06:18.697" Score="1" ViewCount="166" Body="&lt;p&gt;I have this two lines in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;d :s/$/ die();&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;dd :s/ die();/&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For debugging purposes I usually use &lt;code&gt;die();&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe, someone knows, how I can toggle &lt;code&gt;die();&lt;/code&gt;: Pressing &lt;code&gt;&amp;lt;leader&amp;gt;d&lt;/code&gt; would add &lt;code&gt;die();&lt;/code&gt; and the next time I press &lt;code&gt;&amp;lt;leader&amp;gt;d&lt;/code&gt; it would remove &lt;code&gt;die();&lt;/code&gt; if &lt;code&gt;die();&lt;/code&gt; is present on current line?&lt;/p&gt;&#xA;" OwnerUserId="3302" LastEditorUserId="1841" LastEditDate="2016-08-18T08:35:37.193" LastActivityDate="2016-08-18T08:54:25.667" Title="How to add or remove a string in a line depending on the presence of this string?" Tags="|vimscript|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9238" PostTypeId="2" ParentId="9237" CreationDate="2016-08-18T08:32:04.067" Score="2" Body="&lt;p&gt;You can use something like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;d :call AddDie()&amp;lt;CR&amp;gt;&#xA;&#xA;function! AddDie()&#xA;    if ( match(getline('.'), &quot;die()&quot;) == -1 )&#xA;        execute &quot;:s/$/ die();/&quot;&#xA;    else&#xA;        execute &quot;:s/ die();/&quot;&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function will test if the current line contains &lt;code&gt;die()&lt;/code&gt;, if it doesnt it will add it at the end of the line otherwise it will remove it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mapping calls the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: You can also make it a one liner, I don't like it because it is not as readable as a function but that is a good reminder of how to use a conditional structure in a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;d :if ( match(getline('.'), &quot;die()&quot;) == -1 ) &amp;lt;bar&amp;gt; execute &quot;:s/$/ die();/&quot; &amp;lt;bar&amp;gt; else &amp;lt;bar&amp;gt; execute &quot;:s/ die();/&quot; &amp;lt;bar&amp;gt; endif&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-08-18T08:54:25.667" LastActivityDate="2016-08-18T08:54:25.667" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9239" PostTypeId="1" CreationDate="2016-08-18T09:15:24.597" Score="5" ViewCount="1453" Body="&lt;p&gt;We have two separate files:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;f1.txt&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;17.0,&#xA;155.7,&#xA;1123,9,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;f2.txt&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;2&#xA;3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After opening files vertically with &lt;code&gt;vim -O ~/f1.txt ~/f2.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How to obtain?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;17.0,1&#xA;155.7,2&#xA;1123,9,3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is the equivalent of &lt;code&gt;paste -d '' f1.txt f2.txt&lt;/code&gt; in bash&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I tried all I could but in the end I got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;17.0,1&#xA;155.72,&#xA;1123,39,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the column was pasted vertically but not appended to the end of the existing line.&lt;/p&gt;&#xA;" OwnerUserId="8867" LastEditorUserId="8867" LastEditDate="2016-08-18T09:23:55.630" LastActivityDate="2016-08-19T15:37:24.170" Title="How to paste columns vertically to columns with unequal number of characters" Tags="|cut-copy-paste|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9240" PostTypeId="1" CreationDate="2016-08-18T09:23:06.200" Score="1" ViewCount="484" Body="&lt;p&gt;I'm trying to create my first own &lt;code&gt;.vimrc&lt;/code&gt; file. I'm having some trouble when trying to load plugins with Vundle. For example, I want to use &lt;code&gt;vim-airline&lt;/code&gt;, so I have (in the correct place I believe) in my &lt;code&gt;.vimrc&lt;/code&gt; file this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I installed them using &lt;code&gt;:PluginInstall&lt;/code&gt; succesfully.  However, when I try to set the theme for the airline plugin, using in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AirlineTheme luna&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't work; vim says on startup &lt;code&gt;E492: Not an editor command: AirlineTheme luna&lt;/code&gt;. When I continue and manually do &lt;code&gt;:AirlineTheme luna&lt;/code&gt; while vim is running, it works. So for some reason, I can't use any commands provided by the plugins in the &lt;code&gt;.vimrc&lt;/code&gt; file. What do I do wrong, or how do I circumvent this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, here is a stripped version of my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ====== Load Plugins ======&#xA;set nocompatible              &quot; be iMproved, required&#xA;&#xA;filetype off                  &quot; required&#xA;&quot; Set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; Vundle manages itself&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&quot; Add other plugins to Vundle&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;&#xA;call vundle#end()&#xA;filetype plugin indent on&#xA;&#xA;&#xA;&quot; ======= Allow for project specific .vimrc files =======&#xA;set exrc&#xA;set secure&#xA;&#xA;&#xA;&quot; ====== Configure Plugins  ======&#xA;&#xA;&quot; Airline Theme&#xA;set laststatus=2&#xA;AirlineTheme luna&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that it is the very last line that does not work.&lt;/p&gt;&#xA;" OwnerUserId="8868" LastEditorUserId="8868" LastEditDate="2016-08-18T09:37:57.620" LastActivityDate="2016-11-16T18:14:26.053" Title="Vundle load plugins while still in .vimrc" Tags="|vimrc|plugin-vundle|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9241" PostTypeId="2" ParentId="9239" CreationDate="2016-08-18T09:31:14.037" Score="3" Body="&lt;p&gt;I'd rather use the &lt;code&gt;paste&lt;/code&gt; command line tool, if you are using Linux/BSD/OSX:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;paste -d '' f1.txt f2.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should do what you want. You can also read the result into the current vi buffer with &lt;code&gt;:r!paste -d '' f1.txt f2.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's block-visual mode can be very useful but for CSV-ish data, I'd recommend &lt;code&gt;paste&lt;/code&gt; or &lt;a href=&quot;https://github.com/chrisbra/csv.vim&quot; rel=&quot;nofollow&quot;&gt;chrisbra/csv.vim&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6337" LastActivityDate="2016-08-18T09:31:14.037" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9242" PostTypeId="2" ParentId="9239" CreationDate="2016-08-18T09:38:47.787" Score="2" Body="&lt;p&gt;Using a macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;y$&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;$p+&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;+&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;q2@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt;: Start recording a macro,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;&lt;/code&gt;: Switch to second window,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;y$&lt;/code&gt;: yank the contents of the line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;&lt;/code&gt;: Switch back to first window,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$p&lt;/code&gt;: Paste at the end of the line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;+&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;+&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;&lt;/code&gt;: Move down a line in both windows,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: End the recording,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2@q&lt;/code&gt;: Replay the recording twice.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastActivityDate="2016-08-18T09:38:47.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9243" PostTypeId="2" ParentId="7470" CreationDate="2016-08-18T10:35:35.813" Score="0" Body="&lt;p&gt;Try something like this :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put this at the top of your .vimrc to use Vundle.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Run following to install: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim&#xA;cd ~/.vim/bundle&#xA;git clone https://github.com/Valloric/YouCompleteMe.git&#xA;cd YouCompleteMe&#xA;git submodule update --init --recursive&#xA;./install.sh --clang-completer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8869" LastActivityDate="2016-08-18T10:35:35.813" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9245" PostTypeId="2" ParentId="9240" CreationDate="2016-08-18T12:13:06.753" Score="0" Body="&lt;p&gt;Turns out I was able to fix it using this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_theme = 'luna'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For now, I'll assume that the commands created by plugins are not available in your &lt;code&gt;.vimrc&lt;/code&gt; file itself.&lt;/p&gt;&#xA;" OwnerUserId="8868" LastActivityDate="2016-08-18T12:13:06.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9247" PostTypeId="2" ParentId="442" CreationDate="2016-08-18T16:20:57.323" Score="3" Body="&lt;p&gt;As you have mentioned that you want to paste the text in a new file.&#xA;This would work once you have the text selected&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;w new_filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8874" LastActivityDate="2016-08-18T16:20:57.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9248" PostTypeId="2" ParentId="9202" CreationDate="2016-08-18T16:29:41.553" Score="5" Body="&lt;p&gt;&lt;code&gt;t&lt;/code&gt; (and its variants &lt;code&gt;T&lt;/code&gt;, &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;F&lt;/code&gt;) take a single character afterwards to denote the target of motion within the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the effects of the two commands are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;d$&lt;/code&gt; - delete to end of current line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dt$&lt;/code&gt; - delete up-to-but-not-including a literal $ on the current line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8770" LastEditorUserId="8770" LastEditDate="2016-10-12T19:39:28.597" LastActivityDate="2016-10-12T19:39:28.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9249" PostTypeId="1" AcceptedAnswerId="9272" CreationDate="2016-08-18T23:03:41.963" Score="3" ViewCount="10495" Body="&lt;p&gt;Somehow, over the last few days, the visual mode in Vim no longer flips the background highlight, as it used to.  Now, if the file is recognized by something it can syntax highlight, it seems to unbold and darken colored text.  But, for non-syntax highlighted text, or files it doesn't know the syntax of, there is no highlighting at all.  Visual mode still selects normally for selections, but there's not visual difference over a selected area for non-syntax highlighted text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I clear/correct/reset the visual mode selection highlighting?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clarifying Details:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vim 7.4&lt;/li&gt;&#xA;&lt;li&gt;Vundle for plugins&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I've tried removing and disabling any new plugins, no effect&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vim -u NONE&lt;/code&gt; seems to restore it to what I would expect&lt;/li&gt;&#xA;&lt;li&gt;Turning on &lt;code&gt;set :hlsearch&lt;/code&gt; properly enables search highlighting as usual&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8882" LastActivityDate="2017-03-20T21:25:00.120" Title="How do I restore visual mode selection highlighting?" Tags="|syntax-highlighting|visual-mode|colorscheme|highlight|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9250" PostTypeId="1" AcceptedAnswerId="9254" CreationDate="2016-08-19T13:42:33.447" Score="19" ViewCount="9068" Body="&lt;p&gt;Is it possible to include external files to be sourced in the vimrc file?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it as simple a matter as just adding &lt;code&gt;source somefile&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2021-09-22T11:12:05.977" Title="Includes in vimrc?" Tags="|vimscript|vimrc|include|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9251" PostTypeId="2" ParentId="9239" CreationDate="2016-08-19T13:44:12.823" Score="9" Body="&lt;p&gt;I have answered a similar question here: &lt;a href=&quot;https://stackoverflow.com/a/20050503/164835&quot;&gt;https://stackoverflow.com/a/20050503/164835&lt;/a&gt; &#xA;But that question is not exactly same as this one, so I answer here once again:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in &lt;strong&gt;File1&lt;/strong&gt; do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:%right&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0&amp;lt;ctrl-v&amp;gt;G$&lt;/code&gt; -&gt; column select all&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt; -&gt; yank&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;in &lt;strong&gt;File2&lt;/strong&gt; do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt; -&gt; paste &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:%left&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Done&lt;/strong&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is pure vim solution, and goes pretty easy,  looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/y3JI1.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/y3JI1.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1569" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-08-19T13:44:12.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9252" PostTypeId="2" ParentId="9250" CreationDate="2016-08-19T13:55:48.993" Score="3" Body="&lt;p&gt;Yes, or even just &lt;code&gt;so somefile&lt;/code&gt;. See &lt;code&gt;:help so&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7892" LastActivityDate="2016-08-19T13:55:48.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9253" PostTypeId="2" ParentId="9250" CreationDate="2016-08-19T14:05:56.700" Score="5" Body="&lt;p&gt;@romainl's answer is the best practice. But as an additional example I have these lines in my vimrc which might interest you. I use them to source a local vimrc which I don't keep in my dotfiles source control:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Source a local vimrc {{{&#xA;    if has('win32')&#xA;        let $MYLOCALVIMRC = $HOME . &amp;quot;/_local.vim&amp;quot;&#xA;    else&#xA;        let $MYLOCALVIMRC = $HOME . &amp;quot;/.local.vim&amp;quot;&#xA;    endif&#xA;&#xA;    if filereadable($MYLOCALVIMRC)&#xA;        source $MYLOCALVIMRC&#xA;    endif&#xA;&amp;quot; }}} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The first part which defines the file name to source may not be interesting for you but the second part which checks if the file can be sourced before sourcing it could be interesting.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; that &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html#source&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h source&lt;/code&gt;&lt;/a&gt; states:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Read Ex commands from {file}. These are commands that start with a &amp;quot;:&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So this will allow you to source a file containing vimscript but you can't source directly a file containing another language with this method, even if the first line contains the right shebang (&lt;code&gt;#!/bin/...&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2021-09-22T11:12:05.977" LastActivityDate="2021-09-22T11:12:05.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9254" PostTypeId="2" ParentId="9250" CreationDate="2016-08-19T14:23:30.163" Score="21" Body="&lt;p&gt;Unlike &lt;code&gt;:source&lt;/code&gt;, &lt;code&gt;:runtime&lt;/code&gt; doesn't need an absolute path to work. It is much better than &lt;code&gt;:source&lt;/code&gt; for building portable setups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :runtime&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the following example, we tell Vim to look for a &lt;code&gt;vimrc&lt;/code&gt; file in the directories given by the &lt;code&gt;runtimepath&lt;/code&gt; variable. Since &lt;code&gt;~/.vim/&lt;/code&gt; is the first directory in the list, &lt;code&gt;runtime vimrc&lt;/code&gt; works just like &lt;code&gt;:source ~/.vim/vimrc&lt;/code&gt; without the need to provide a system-dependent path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-08-19T15:57:39.190" LastActivityDate="2016-08-19T15:57:39.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9255" PostTypeId="2" ParentId="2129" CreationDate="2016-08-19T14:47:38.223" Score="4" Body="&lt;p&gt;Currently I'm using &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;+&lt;code&gt;number&lt;/code&gt; key to switch. The leader key is my &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; key.&#xA;I also use &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;nofollow&quot;&gt;vim-airline&lt;/a&gt; to show the buffer nr on top of the window.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; airline settings&#xA;let g:airline#extensions#tabline#buffer_nr_show = 1&#xA;let g:airline#extensions#tabline#enabled = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While the bufnr often exceeds 10, so I tweak my own mapping, if the &lt;code&gt;number&lt;/code&gt; is the only match, switch buffer immediately, otherwise wait for more number input or &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; key for confirm:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;1 tweak#wtb_switch#key_leader_bufnum(1)&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;2 tweak#wtb_switch#key_leader_bufnum(2)&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;3 tweak#wtb_switch#key_leader_bufnum(3)&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;4 tweak#wtb_switch#key_leader_bufnum(4)&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;5 tweak#wtb_switch#key_leader_bufnum(5)&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;6 tweak#wtb_switch#key_leader_bufnum(6)&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;7 tweak#wtb_switch#key_leader_bufnum(7)&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;8 tweak#wtb_switch#key_leader_bufnum(8)&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;9 tweak#wtb_switch#key_leader_bufnum(9)&#xA;&#xA;&#xA;&#xA;&#xA;func! tweak#wtb_switch#key_leader_bufnum(num)&#xA;    let l:buffers = tweak#wtb_switch#buflisted()&#xA;    let l:input = a:num . &quot;&quot;&#xA;&#xA;    while 1&#xA;&#xA;        let l:cnt = 0&#xA;        let l:i=0&#xA;        &quot; count matches&#xA;        while l:i&amp;lt;len(l:buffers)&#xA;            let l:bn = l:buffers[l:i] . &quot;&quot;&#xA;            if l:input==l:bn[0:len(l:input)-1]&#xA;                let l:cnt+=1&#xA;            endif&#xA;            let l:i+=1&#xA;        endwhile&#xA;&#xA;        &quot; no matches&#xA;        if l:cnt==0 &amp;amp;&amp;amp; len(l:input)&amp;gt;0&#xA;            echo &quot;no buffer [&quot; . l:input . &quot;]&quot;&#xA;            return ''&#xA;        elseif l:cnt==1&#xA;            return &quot;:b &quot; . l:input . &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;        endif&#xA;&#xA;        echo &quot;:b &quot; . l:input&#xA;&#xA;        let l:n = getchar()&#xA;&#xA;        if l:n==char2nr(&quot;\&amp;lt;BS&amp;gt;&quot;) ||  l:n==char2nr(&quot;\&amp;lt;C-h&amp;gt;&quot;)&#xA;            &quot; delete one word&#xA;            if len(l:input)&amp;gt;=2&#xA;                let l:input = l:input[0:len(l:input)-2]&#xA;            else&#xA;                let l:input = &quot;&quot;&#xA;            endif&#xA;        elseif l:n==char2nr(&quot;\&amp;lt;CR&amp;gt;&quot;) || (l:n&amp;lt;char2nr('0') || l:n&amp;gt;char2nr('9'))&#xA;            return &quot;:b &quot; . l:input . &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;        else&#xA;            let l:input = l:input . nr2char(l:n)&#xA;        endif&#xA;&#xA;        let g:n = l:n&#xA;&#xA;    endwhile&#xA;endfunc&#xA;&#xA;func! tweak#wtb_switch#buflisted()&#xA;  return filter(range(1, bufnr('$')), 'buflisted(v:val)')&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code is pasted from &lt;a href=&quot;https://github.com/roxma/vim-tweak/commit/53e8e54748ab22e3b93617d3122facde77616120&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, I also use &lt;code&gt;&amp;lt;S-h&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;S-l&amp;gt;&lt;/code&gt; for &lt;code&gt;:bp&lt;/code&gt; and &lt;code&gt;:bn&lt;/code&gt;, or &lt;code&gt;:tabp&lt;/code&gt; and &lt;code&gt;:tabn&lt;/code&gt; if more than one tabpage is opened currently. It's quite intuitive for me.&lt;/p&gt;&#xA;" OwnerUserId="8890" LastEditorUserId="8890" LastEditDate="2016-08-19T14:55:09.933" LastActivityDate="2016-08-19T14:55:09.933" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9256" PostTypeId="2" ParentId="9239" CreationDate="2016-08-19T15:37:24.170" Score="2" Body="&lt;p&gt;And here is another solution, probably not the most efficient one or the cleaner one but I had some time to make some vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PasteAtEndOfLine()&#xA;    &quot; Check that the selection is blockwise&#xA;    if ( getregtype('&quot;')[0] != '' )&#xA;        echo &quot;not blockwise&quot;&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; Get the selection and split it on new lines&#xA;    let regcontent = getreg('&quot;')&#xA;    let lines = split(regcontent, '\n')&#xA;&#xA;    &quot; Save the cursor position and the current line&#xA;    let save_cursor = getpos('.')&#xA;    let line_number = save_cursor[1]&#xA;&#xA;    &quot; For each line add the content of the register at the end&#xA;    &quot; And go to next line&#xA;    for line in lines&#xA;        execute &quot;normal A&quot; . line&#xA;        let line_number += 1&#xA;        call setpos('.', [0, line_number, 0, 0])&#xA;    endfor&#xA;&#xA;    &quot; Restore the initial position&#xA;    call setpos('.', save_cursor)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use it you should:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Visually select block wise the lines you want to paste from f2.txt: &lt;kbd&gt;ctrl+v&lt;/kbd&gt;&lt;kbd&gt;G&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Yank the text to the unnamed register: &lt;kbd&gt;y&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Go to the first line of f1.txt&lt;/li&gt;&#xA;&lt;li&gt;Call the function: &lt;code&gt;:call PasteAtEndOfLine()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;You're done&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-08-19T15:37:24.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9257" PostTypeId="1" AcceptedAnswerId="9258" CreationDate="2016-08-19T16:06:43.863" Score="0" ViewCount="547" Body="&lt;p&gt;I am using following vim plugins &lt;code&gt;vinegar&lt;/code&gt; and &lt;code&gt;unimpaired&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I enter a netrw directory listing with &lt;code&gt;-&lt;/code&gt;, the mappings of &lt;code&gt;unimpaired&lt;/code&gt; starting with &lt;code&gt;c&lt;/code&gt; (e.g. toggle line numbers with &lt;code&gt;con&lt;/code&gt;)  do not work because netrw has mapped the single letter &lt;code&gt;c&lt;/code&gt; (&lt;code&gt;:h netrw-c&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to patch &lt;code&gt;vinegar&lt;/code&gt; to add an unmapping for the &lt;code&gt;c&lt;/code&gt; mapping of netrw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For completeness I give here the mapping of &lt;code&gt;c&lt;/code&gt; as done in &lt;code&gt;$VIMRUNTIME/autoload/netrw.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; c  :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;NetrwLcd(b:netrw_curdir)&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to add in &lt;code&gt;plugin/vinegar.vim&lt;/code&gt; to the &lt;code&gt;function! s:setup_vinegar() abort&lt;/code&gt; following line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nunmap c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this does not work. This might be an issue of the load or evaluation order of vinegar w.r.t. netrw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE Sept 2018&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Netrw v162 has changed the mapping to &lt;code&gt;netrw-cd&lt;/code&gt; and therefore I do not need this anymore.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-09-25T14:08:15.367" LastActivityDate="2018-09-25T14:08:15.367" Title="Unmap netrw-c in vinegar.vim" Tags="|key-bindings|netrw|plugin-unimpaired|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9258" PostTypeId="2" ParentId="9257" CreationDate="2016-08-19T16:06:43.863" Score="2" Body="&lt;p&gt;I've figured it out while writing my question. Answer is given here: &lt;a href=&quot;https://vi.stackexchange.com/questions/7276/i-cannot-unmap-a-key-combination-yc-g&quot;&gt;I cannot unmap a key combination `y&amp;lt;C-G&amp;gt;`&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nunmap &amp;lt;buffer&amp;gt; c&lt;/code&gt; works.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;❯ git diff&#xA;diff --git a/plugin/vinegar.vim b/plugin/vinegar.vim&#xA;index 28adce4..7afeafc 100644&#xA;--- a/plugin/vinegar.vim&#xA;+++ b/plugin/vinegar.vim&#xA;@@ -98,6 +98,7 @@ function! s:setup_vinegar() abort&#xA;   xnoremap &amp;lt;buffer&amp;gt; . &amp;lt;Esc&amp;gt;: &amp;lt;C-R&amp;gt;=&amp;lt;SID&amp;gt;escaped(line(&quot;'&amp;lt;&quot;), line(&quot;'&amp;gt;&quot;))&amp;lt;CR&amp;gt;&amp;lt;Home&amp;gt;&#xA;   nmap &amp;lt;buffer&amp;gt; ! .!&#xA;   xmap &amp;lt;buffer&amp;gt; ! .!&#xA;+  nunmap  &amp;lt;buffer&amp;gt; c&#xA;   nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; cg :exe 'keepjumps cd ' .&amp;lt;SID&amp;gt;fnameescape(b:netrw_curdir)&amp;lt;CR&amp;gt;&#xA;   nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; cl :exe 'keepjumps lcd '.&amp;lt;SID&amp;gt;fnameescape(b:netrw_curdir)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2016-08-19T16:06:43.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9259" PostTypeId="2" ParentId="2129" CreationDate="2016-08-19T16:47:01.837" Score="14" Body="&lt;h2&gt;&lt;code&gt;[b&lt;/code&gt; and &lt;code&gt;]b&lt;/code&gt; from plugin &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-unimpaired&lt;/code&gt;&lt;/a&gt; (&amp;gt; 3k ★)&lt;/h2&gt;&#xA;&lt;p&gt;If you happen to have installed &lt;code&gt;vim-unimpaired&lt;/code&gt;, you can use&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;[b&lt;/code&gt; (&lt;code&gt;:bp[revious]&lt;/code&gt;)&lt;/strong&gt; and&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;]b&lt;/code&gt; (&lt;code&gt;:bn[ext]&lt;/code&gt;)&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;for cycling through open buffers. No need to define more precious mappings for the same commands. Furthermore, jumping to the first and last buffer can be done by&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[B&lt;/code&gt; (&lt;code&gt;:bf[irst]&lt;/code&gt;) and&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;]B&lt;/code&gt; (&lt;code&gt;:bl[ast]&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There are &lt;a href=&quot;https://github.com/tpope/vim-unimpaired/blob/master/doc/unimpaired.txt#L18-L41&quot; rel=&quot;nofollow noreferrer&quot;&gt;plenty more bracket-mappings&lt;/a&gt; contained in &lt;code&gt;vim-unimpaired&lt;/code&gt; which you might find useful. They all follow the same scheme which makes it easy to memorize them.&lt;/p&gt;&#xA;&lt;h3&gt;The dark side vs. the light side&lt;/h3&gt;&#xA;&lt;p&gt;This plugin can be considered lightweight and 'vimish'. It is denoted by the &lt;a href=&quot;https://www.vi-improved.org/plugins/&quot; rel=&quot;nofollow noreferrer&quot;&gt;#vim community&lt;/a&gt; as a &amp;quot;does not harm&amp;quot; plugin.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2022-12-18T14:37:15.410" LastActivityDate="2022-12-18T14:37:15.410" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9260" PostTypeId="2" ParentId="2129" CreationDate="2016-08-19T17:12:14.517" Score="24" Body="&lt;h2&gt;&lt;code&gt;:CtrlPBuffer&lt;/code&gt; from plugin &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;CtrlP&lt;/a&gt; (5k ★)&lt;/h2&gt;&#xA;&lt;p&gt;Main feature of this plugin is to provide a &lt;em&gt;fuzzy matching&lt;/em&gt; to conveniently open a different buffer with visual feedback.&lt;/p&gt;&#xA;&lt;p&gt;Open the fuzzy buffer listing with &lt;code&gt;:CtrlPBuffer&lt;/code&gt; or press &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; followed by &lt;code&gt;&amp;lt;C-b&amp;gt;&lt;/code&gt; to change the mode to &lt;code&gt;buffer&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Enter a sufficient number of characters to specify the buffer you want to open.&lt;br /&gt;&#xA;You can also use &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; to cycle through the list and select manually the buffer.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6iGQj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6iGQj.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Customization&lt;/h3&gt;&#xA;&lt;p&gt;If you wish to open the buffer list immediately with &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt;, add following line to your vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_cmd = 'CtrlPBuffer'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can use &lt;code&gt;&amp;lt;C-f/b&amp;gt;&lt;/code&gt; to switch the mode of the ctrlp window.&lt;/p&gt;&#xA;&lt;p&gt;I personally use &lt;code&gt;let g:ctrlp_cmd = 'CtrlPMRU'&lt;/code&gt;. The most recently used (mru) list  also contains the opened buffers. If you use different ctrlp modes and want to stick to your last mode, you can set &lt;code&gt;let g:ctrlp_cmd = 'CtrlPLastMode [--dir]'&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Similar plugins&lt;/h3&gt;&#xA;&lt;p&gt;There are many more plugins which provide a buffer list with an interactive prompt with fuzzy matching, e.g.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;fzf.vim&lt;/strong&gt;&lt;/a&gt; (8.5k ★) by Junegunn (+terminal, go)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/nvim-telescope/telescope.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;telescope.nvim&lt;/strong&gt;&lt;/a&gt; (8k ★) by TJ DeVries  (for neovim)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/wincent/command-t&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;command-t&lt;/strong&gt;&lt;/a&gt; by Wincent (+ruby)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;The dark side vs. the light side&lt;/h3&gt;&#xA;&lt;p&gt;(i.e. plugin-heavy vim setup vs. the vim way)&lt;/p&gt;&#xA;&lt;p&gt;Before you decide to use these more complex plugins, study the answers by &lt;a href=&quot;https://vi.stackexchange.com/a/2131/1292&quot;&gt;@Doorknob&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/a/2187/1292&quot;&gt;@joeytwiddle&lt;/a&gt;. In particular, check the one-liner if one of them already fulfills your needs.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;b :b &amp;lt;C-d&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;b :ls&amp;lt;Cr&amp;gt;:b&amp;lt;Space&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Installing the plugins just for buffer switching might be an overkill.&#xA;See also the remarks on &lt;a href=&quot;https://www.vi-improved.org/recommendations/#bufexplorer-ctrl-p-gtfo-minibufexpl-nerdtree-vinegar&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.vi-improved.org/recommendations&lt;/a&gt; and the article by Drew Neil &lt;a href=&quot;http://vimcasts.org/blog/2012/08/on-sharpening-the-saw/&quot; rel=&quot;nofollow noreferrer&quot;&gt;‘On sharpening the saw’&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2022-12-18T14:37:56.753" LastActivityDate="2022-12-18T14:37:56.753" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9263" PostTypeId="2" ParentId="9250" CreationDate="2016-08-20T00:37:43.883" Score="6" Body="&lt;p&gt;The answer should depend on what you want to scatter in several files. There are a few different ways to have a configuration in several files. Note: the difference between &lt;code&gt;runtime&lt;/code&gt; and &lt;code&gt;source&lt;/code&gt; has been described, I won't say anything again on this subject.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So. You'll also have to take into account the what. Nowadays, we seldom have a need to use &lt;code&gt;so&lt;/code&gt; or &lt;code&gt;ru&lt;/code&gt; from .vimrc. Yet, I still do it in only two cases:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;get sure a non autoload plugin gets loaded before the end of the .vimrc (in order to define other things that depends on this plugin)&lt;/li&gt;&#xA;&lt;li&gt;load OS specific settings&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For the other cases:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;for function definitions, there are autoload plugins ;&lt;/li&gt;&#xA;&lt;li&gt;for syntax highlighting, colorschemes, there are dedicated files in the eponymous directories ;&lt;/li&gt;&#xA;&lt;li&gt;for filetype specific settings, there are filetype plugins (having autocommands in the .vimrc is a poor man solution, one that doesn't scale) ;&lt;/li&gt;&#xA;&lt;li&gt;for project specific settings, there are plugins like local_vimrc ;&lt;/li&gt;&#xA;&lt;li&gt;for any other set of complex mappings or features, there are plugins where we can regroup thematic definitions ;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the end, I have in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;global options set with &lt;code&gt;:set&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;the procedure needed by the plugin manager I'm using&lt;/li&gt;&#xA;&lt;li&gt;various configurations for the plugins I use (I override the default keybindings in the .vimrc)&lt;/li&gt;&#xA;&lt;li&gt;and a few things (too many actually) I've been dragging along for 20 years.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-08-20T00:37:43.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9264" PostTypeId="1" AcceptedAnswerId="9265" CreationDate="2016-08-20T03:47:23.290" Score="4" ViewCount="2129" Body="&lt;p&gt;Let's say I have the following text and my cursor is on the &quot;d&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;someCamelCaseWord&#xA;                ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to delete &quot;Word&quot; so that the text reads &quot;someCamelCase&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the fewest number of keystrokes required to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="7454" LastActivityDate="2016-08-22T02:29:46.940" Title="Fastest way to delete part of word from end of word?" Tags="|cursor-movement|cursor-motions|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9265" PostTypeId="2" ParentId="9264" CreationDate="2016-08-20T04:46:08.137" Score="7" Body="&lt;p&gt;In this specific instance, the best I could come up with is 4, including holding the shift key. There are several possibilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;xxxx - delete the character under the cursor.&lt;br&gt;&#xA;3Xx - delete 3 characters to the left, delete the character under the cursor.&lt;br&gt;&#xA;3hdw - Move 3 characters to the left, delete to the end of the word.&lt;br&gt;&#xA;3hD - Move 3 characters to the left, delete to the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other tries, with 5 keystrokes[1], that doesn't use repeated commands or movement counts:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;dFWx - delete, moving left to the 'W', then delete the remaining character, since the 'd' does not delete the character under the cursor, when moving left.&lt;br&gt;&#xA;FWdw - move left to the 'W', then delete to the end of the word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 - I only count them as 5 due to holding the shift key down for consecutive keystrokes.&lt;/p&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2016-08-20T04:46:08.137" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9266" PostTypeId="2" ParentId="2784" CreationDate="2016-08-20T08:45:36.620" Score="6" Body="&lt;p&gt;As per Kenny Evitt's answer, you can find where textwidth is being set using verbose:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set tw?&#xA;  textwidth=78&#xA;    Last set from c:\Program Files (x86)\Vim\vim74\vimrc_example.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are happy editing that file, do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would prefer not to edit whichever file (or cannot), then you can override it in your own .vimrc (or _vimrc) file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it not being set via an autocmd, you can simply undo it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it is an autocmd, then it won't be set until you open the .txt file (or whatever) and simply setting textwidth=0 in your own .vimrc file won't do anything because it will be overridden.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, you need to prevent or override the autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To my way of thinking, you ought to be able to undo the autocmd using something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! FileType text set textwidth=78&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For me, that doesn't work in .vimrc. It does work if you give it manually once vim has started, but that's not so much use. This feels like a bug in vim, but maybe there's a good reason for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does work for me is to add this to my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType text set textwidth=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8897" LastActivityDate="2016-08-20T08:45:36.620" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9267" PostTypeId="2" ParentId="9264" CreationDate="2016-08-20T08:55:23.387" Score="1" Body="&lt;p&gt;One.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Press x and hold. Wait until it deletes 4 characters, then release it.&lt;/p&gt;&#xA;" OwnerUserId="8897" LastActivityDate="2016-08-20T08:55:23.387" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9268" PostTypeId="2" ParentId="9264" CreationDate="2016-08-20T09:01:38.420" Score="1" Body="&lt;p&gt;As you said, your cursor is positioned at &lt;code&gt;d&lt;/code&gt;. Thus with &lt;code&gt;?W&lt;/code&gt; you can jump the cursor position to &lt;code&gt;W&lt;/code&gt; and with  &lt;code&gt;cw&lt;/code&gt; or &lt;code&gt;dw&lt;/code&gt; you can remove &lt;code&gt;Word&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In total this is 4 keys pressed, but this saves time on counting characters needed for something like multiple &lt;code&gt;x&lt;/code&gt; keypresses or &lt;code&gt;4h&lt;/code&gt;. Especially will be useful for targeting the capital letter of camelcase words. For instance , with &lt;code&gt;public static void PaymentsSubmittedToday&lt;/code&gt; string and cursor at &lt;code&gt;y&lt;/code&gt; , we can just do &lt;code&gt;?S&lt;/code&gt; then &lt;code&gt;dw&lt;/code&gt;, and the string becomes &lt;code&gt;public static void Payments&lt;/code&gt; with cursor at &lt;code&gt;s&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7589" LastEditorUserId="7589" LastEditDate="2016-08-20T09:15:40.437" LastActivityDate="2016-08-20T09:15:40.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9269" PostTypeId="1" CreationDate="2016-08-20T10:53:00.687" Score="4" ViewCount="1719" Body="&lt;p&gt;How do I get a &lt;code&gt;vimdiff&lt;/code&gt; view of the effects of patching a file?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastActivityDate="2016-08-20T10:53:00.687" Title="Get a vimdiff view of changes made by a patch / diff file" Tags="|vimdiff|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9270" PostTypeId="2" ParentId="9269" CreationDate="2016-08-20T10:53:00.687" Score="5" Body="&lt;p&gt;Use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim &amp;lt;file&amp;gt; +&quot;vertical diffpatch &amp;lt;patch-file&amp;gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note the warning&lt;/em&gt; from &lt;code&gt;:help&lt;/code&gt; inside this this script I call &lt;code&gt;vimdiffpatch&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;&#xA;if [[ $# -ne 2 ]]; then&#xA;  echo &quot;Usage: $(basename &quot;$0&quot;) &amp;lt;base-file&amp;gt; &amp;lt;patch-file&amp;gt;&quot; 2&amp;gt;&amp;amp;1&#xA;echo&#xA;echo &quot;From ':help diffpatch':&quot;&#xA;echo &quot;Note that {patchfile} should only contain a diff for one file,&quot;&#xA;echo &quot;the current file.  If {patchfile} contains diffs for other&quot;&#xA;echo &quot;files as well, the results are unpredictable.  Vim changes&quot;&#xA;echo &quot;directory to /tmp to avoid files in the current directory&quot;&#xA;echo &quot;accidentally being patched.  But it may still result in&quot;&#xA;echo &quot;various &quot;.rej&quot; files to be created.  And when absolute path&quot;&#xA;echo &quot;names are present these files may get patched anyway.&quot;&#xA;&#xA;  exit 1&#xA;fi&#xA;&#xA;vim &quot;$1&quot; +&quot;vertical diffpatch $2&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For bonus points, &lt;a href=&quot;https://github.com/rickhowe/diffchar.vim&quot; rel=&quot;noreferrer&quot;&gt;highlight the exact differences, based on characters and words&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5324" LastActivityDate="2016-08-20T10:53:00.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9271" PostTypeId="1" AcceptedAnswerId="9273" CreationDate="2016-08-20T11:22:19.840" Score="9" ViewCount="604" Body="&lt;p&gt;I wonder if there is any command similar to &lt;code&gt;:TOhtml&lt;/code&gt;, but for plain text only and representing the whole Vim display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, given the display:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ft55E.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ft55E.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would create the following text file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1 B                         1 a                     &#xA;~                           ~                         &#xA;~                           ~                         &#xA;~                           ~                         &#xA;~                           ~                         &#xA;~                           ~                         &#xA;~                           ~                         &#xA;~                           ~                         &#xA; N  &amp;lt;me] [+]      100% 1:1  ~                         &#xA;  1 a                       ~                         &#xA;~                           ~                         &#xA;~                           ~                         &#xA;~                           ~                         &#xA;~                           ~                         &#xA;~                           ~                         &#xA;~                           ~                         &#xA; N  &amp;lt;me] [+]      100% 1:1   N  &amp;lt;e] [+]      100% 1:1 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(this has been done via copy/paste from the terminal and manually formatting the text)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did not found any option to do so, I think there is none.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How, if possible, can Vim achieve this?&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-09-20T21:39:00.150" Title="Output Vim display to Text" Tags="|vimscript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9272" PostTypeId="2" ParentId="9249" CreationDate="2016-08-20T13:43:35.080" Score="1" Body="&lt;p&gt;Debugging my &lt;code&gt;.vimrc&lt;/code&gt; file led me to discover that my &lt;code&gt;colorscheme&lt;/code&gt; seemed to be the cause.  Changing it to something else fixed the problem. &lt;/p&gt;&#xA;" OwnerUserId="8882" LastActivityDate="2016-08-20T13:43:35.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9273" PostTypeId="2" ParentId="9271" CreationDate="2016-08-21T03:57:20.800" Score="5" Body="&lt;p&gt;Yes, there is a way to do this! You can use the &lt;code&gt;screenchar()&lt;/code&gt; function. From &lt;code&gt;:help screenchar()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;screenchar(row, col)                        *screenchar()*&#xA;        The result is a Number, which is the character at position&#xA;        [row, col] on the screen.  This works for every possible&#xA;        screen position, also status lines, window separators and the&#xA;        command line.  The top left position is row one, column one&#xA;        The character excludes composing characters.  For double-byte&#xA;        encodings it may only be the first byte.&#xA;        This is mainly to be used for testing.&#xA;        Returns -1 when row or col is out of range.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use this in a script, you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! ScreenCapture()&#xA;    let array=[]&#xA;    for i in range(1,&amp;amp;lines)&#xA;        let row=''&#xA;        for j in range(1,&amp;amp;columns)&#xA;            let row.=nr2char(screenchar(i,j))&#xA;        endfor&#xA;        call add(array, row)&#xA;    endfor&#xA;    tabnew&#xA;    call setline(1,array)&#xA;endfu&#xA;com! ScreenCapture :call ScreenCapture()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This lovely piece of vimscript was written by &lt;a href=&quot;https://vi.stackexchange.com/a/5525/2920&quot;&gt;Christian Brabandt&lt;/a&gt;, so if you find it useful go give him an upvote. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example of it in action. When I ran this function on my vim window:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3BGjz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3BGjz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1                                    |  1                                     &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;[No Name]            0,0-1          All|~                                       &#xA;  1                                    |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;~                                      |~                                       &#xA;[No Name]            0,0-1          All [No Name]             0,0-1          All&#xA;:call ScreenCapture()                                                           &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-08-21T03:57:20.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9274" PostTypeId="1" CreationDate="2016-08-21T12:23:02.780" Score="1" ViewCount="88" Body="&lt;p&gt;Is it possible to make indenting/unindenting not re-align text, eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * Some Text&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Indents to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /*&#xA;    * Some Text&#xA;    */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would prefer/expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /*&#xA;     * Some Text&#xA;     */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I saw spacemacs has an option for this, was curious to know if vim does too.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2016-08-21T12:35:05.423" Title="How to prevent indent, unindent (&gt;&gt;, &lt;&lt;) from re-aligning text?" Tags="|indentation|whitespace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9275" PostTypeId="2" ParentId="9274" CreationDate="2016-08-21T12:35:05.423" Score="2" Body="&lt;p&gt;This is caused by having &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shiftround &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set in the &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2016-08-21T12:35:05.423" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9276" PostTypeId="1" AcceptedAnswerId="9279" CreationDate="2016-08-21T16:54:48.127" Score="1" ViewCount="1182" Body="&lt;p&gt;Currently, my vimrc contains the lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap j gj&#xA;xnoremap j gj&#xA;nnoremap gj j&#xA;xnoremap gj j&#xA;nnoremap k gk&#xA;xnoremap k gk&#xA;nnoremap gk k&#xA;xnoremap gk k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, the &lt;code&gt;j&lt;/code&gt; key in both visual and normal mode will go to the next displayed line, not the next actual line. However, this is rather silly in visual line mode, since, well, it only operates on actual lines. It doesn't make much sense in visual block mode either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make a mapping apply only in visual mode, not visual line mode or visual block mode?&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2016-08-21T18:55:28.167" Title="How can I create a mapping only in &quot;plain&quot; visual mode?" Tags="|key-bindings|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9277" PostTypeId="1" AcceptedAnswerId="9278" CreationDate="2016-08-21T17:00:20.150" Score="3" ViewCount="615" Body="&lt;p&gt;I am looking for a way to create a newline with an indentation equal to the current column position of my cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example. Say I'm editing some line of code looking like this, with my cursor on the opening bracket &lt;code&gt;[&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;data Foo a = Bar a | Baz [a]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to have a command that act a bit like &lt;code&gt;o&lt;/code&gt; but instead of creating an empty line, it would create an indented line and leave me right under the opening bracket &lt;code&gt;[&lt;/code&gt;, allowing me to directly type e.g. &lt;code&gt;(a,a)&lt;/code&gt; to obtain&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;data Foo a = Bar a | Baz [a]&#xA;                         (a,a)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note this is not something that can be automated via the &lt;code&gt;smartindent&lt;/code&gt; option since there isn't only one interesting indentation (depending on what I want to do, the pipe or the beginning of the line could also be interesting positions to be at; forcing one of those via &lt;code&gt;smartindent&lt;/code&gt; wouldn't solve my problem in a general way).&lt;/p&gt;&#xA;" OwnerUserId="2438" LastActivityDate="2016-08-24T19:40:56.260" Title="Create a new line with indentation matching the cursor position" Tags="|indentation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9278" PostTypeId="2" ParentId="9277" CreationDate="2016-08-21T17:39:58.030" Score="3" Body="&lt;p&gt;To do this manually you probably just open a new line below the current and insert a bunch of whitespace. You can create a command that does this, and a convenient map to execute the command. Try something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;LocalLeader&amp;gt;o :OpenIndentToCursorCol&amp;lt;CR&amp;gt;&#xA;command! OpenIndentToCursorCol call append('.', repeat(' ', getcurpos()[2] -1)) | exe &quot;normal j&quot; | startinsert!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This calls the &lt;code&gt;append()&lt;/code&gt; function to insert a line after some other line. This function is passed two arguments: 1) the line after which the new line should be inserted, 2) the content of the new line. The first argument used is &lt;code&gt;'.'&lt;/code&gt;, which is the current line. The second argument is the whitespace to achieve the indendation, and it is in turn built with a call to the &lt;code&gt;repeat()&lt;/code&gt; function, which repeats an expression &lt;code&gt;n&lt;/code&gt; times and returns the concatenation. The expression is a single white space and the number of times is the column in which the cursor resides, minus 1. The current column is retrieved as the third value in the list returned by the &lt;code&gt;getcurpos()&lt;/code&gt; function (&lt;code&gt;getcurpos()[2]&lt;/code&gt;). Next we use &lt;code&gt;:execute&lt;/code&gt; to execute a normal mode command &lt;code&gt;j&lt;/code&gt;, to move the cursor to the new line. (There is probably a less verbose way to do this, but none comes to mind at the moment.) Finally enter insert mode with &lt;code&gt;:startinsert!&lt;/code&gt;. The bang (&lt;code&gt;!&lt;/code&gt;) means &lt;em&gt;after&lt;/em&gt; cursor: &lt;code&gt;startinsert!&lt;/code&gt; is to &lt;code&gt;startinsert&lt;/code&gt; what &lt;code&gt;a&lt;/code&gt; is to &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;A&lt;/code&gt; is to &lt;code&gt;I&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will leave you with a new line inserted containing white space to the number of the cursor column minus one, with the cursor after the last character of the new line, and in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help append()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help repeat()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getcurpos()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :execute&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :startinsert&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2016-08-21T17:39:58.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9279" PostTypeId="2" ParentId="9276" CreationDate="2016-08-21T18:55:28.167" Score="4" Body="&lt;p&gt;You could rewrite your mappings as &quot;expression mappings&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;expr&amp;gt; j  mode() ==# &quot;v&quot; ? &quot;gj&quot; : &quot;j&quot;&#xA;xnoremap &amp;lt;expr&amp;gt; gj mode() ==# &quot;v&quot; ? &quot;j&quot;  : &quot;j&quot;&#xA;xnoremap &amp;lt;expr&amp;gt; k  mode() ==# &quot;v&quot; ? &quot;gk&quot; : &quot;k&quot;&#xA;xnoremap &amp;lt;expr&amp;gt; gk mode() ==# &quot;v&quot; ? &quot;k&quot;  : &quot;gk&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help &amp;lt;expr&amp;gt;&lt;/code&gt; and &lt;code&gt;:help mode()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-21T18:55:28.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9281" PostTypeId="2" ParentId="9264" CreationDate="2016-08-22T02:29:46.940" Score="-1" Body="&lt;pre&gt;&lt;code&gt;dFW&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Search backwards for the fist W, and delete everything up-to and including it. &lt;code&gt;d&lt;/code&gt; means delete and &lt;code&gt;FW&lt;/code&gt; is a motion command that means move the cursor backwards to the first encountered &lt;code&gt;W&lt;/code&gt; character.&lt;/p&gt;&#xA;" OwnerUserId="8912" LastActivityDate="2016-08-22T02:29:46.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9282" PostTypeId="1" AcceptedAnswerId="9286" CreationDate="2016-08-22T03:48:50.220" Score="1" ViewCount="221" Body="&lt;p&gt;I like having &lt;code&gt;hlsearch&lt;/code&gt; on, but find it annoying in insert mode. So I tried doing the following autocommand to disable it whenever I enter insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * nohlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For whatever reason, this does not work. So that I could verify this wasn't a problem with my &lt;code&gt;.vimrc&lt;/code&gt;, I tried this after launching vim with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim -u NORC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help debugging this would be greatly appreciated! I'm using gvim version 7.4.1023 on windows.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-08-22T06:24:19.527" Title="Why does this auto command to disable hlsearch not work?" Tags="|gvim|autocmd|highlight|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9283" PostTypeId="1" AcceptedAnswerId="9285" CreationDate="2016-08-22T06:10:24.713" Score="1" ViewCount="51" Body="&lt;p&gt;Currently I have the following mapping in my vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap d &quot;_d&#xA;nnoremap D &quot;_D&#xA;nnoremap C &quot;_C&#xA;nnoremap c &quot;_c&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;d &quot;*d&#xA;nnoremap &amp;lt;leader&amp;gt;D &quot;*D&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result of the above mapping is that everything that is yanked after deleting or changing goes to the black hole register. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the last problem I am having is after I paste onto a visual line, the replaced text gets yanked on to the clipboard (default) register. So I tried to use this function which attempts to solve this problem&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RestoreRegister()&#xA;  let @&quot; = s:restore_reg&#xA;  return ''&#xA;endfunction&#xA;function! s:Repl()&#xA;  let s:restore_reg = @&quot;&#xA;  return &quot;p@=RestoreRegister()\&amp;lt;cr&amp;gt;&quot;&#xA;endfunction&#xA;vmap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; p &amp;lt;sid&amp;gt;Repl()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does not seem to work and I am not sure why. Any help on this issue would be appreciated. Could this have to do with my custom mappings that I defined above?&lt;/p&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="2920" LastEditDate="2016-08-22T06:25:13.907" LastActivityDate="2016-08-22T06:25:13.907" Title="How would I modify this function to restore from a specified register?" Tags="|vimscript|cut-copy-paste|visual-mode|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9284" PostTypeId="2" ParentId="7033" CreationDate="2016-08-22T06:18:36.697" Score="0" Body="&lt;p&gt;I could not reproduce this - the focus worked fine for me - only difference I see is that I have enabled mouse focus, perhaps that could help you&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have enabled mouse focus like this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set mouse=a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8869" LastActivityDate="2016-08-22T06:18:36.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9285" PostTypeId="2" ParentId="9283" CreationDate="2016-08-22T06:24:07.910" Score="2" Body="&lt;p&gt;I'm not sure what's wrong with your function (I didn't look super hard) but there is much simpler solution. Rather than pasting and then restoring the previous register, delete the visual selection to the black hole register before pasting. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap p &quot;_dp&#xA;vnoremap P &quot;_dP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also provide similar mappings for when you want to capture this to the system clipboard:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;leader&amp;gt;p &quot;*dp&#xA;vnoremap &amp;lt;leader&amp;gt;P &quot;*dP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-08-22T06:24:07.910" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9286" PostTypeId="2" ParentId="9282" CreationDate="2016-08-22T06:24:19.527" Score="5" Body="&lt;p&gt;&lt;code&gt;:nohlsearch&lt;/code&gt; doesn't work inside an autocommand, as explained in &lt;code&gt;:help :nohlsearch&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Stop the highlighting for the 'hlsearch' option.  It is automatically turned back on when using a search command, or setting the 'hlsearch' option. &lt;strong&gt;This command doesn't work in an autocommand, because the highlighting state is saved and restored when executing autocommands. Same thing for when invoking a user function.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;https://github.com/romainl/vim-cool&quot;&gt;vim-cool&lt;/a&gt;, I worked around that &quot;issue&quot; by using &lt;code&gt;:set nohlsearch&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-22T06:24:19.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9287" PostTypeId="1" AcceptedAnswerId="9289" CreationDate="2016-08-22T06:51:26.330" Score="8" ViewCount="13935" Body="&lt;p&gt;When using VIM, it is possible to get a file listing in one split window by doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vsp&#xA;:e.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you have something that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JHcKD.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JHcKD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you open a file then how can you get back to the listing? Normally when you open a file in vim then you write &lt;code&gt;:wq&lt;/code&gt; for writing change and then exit, however if you do this in this case, then the split window is closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to exit the file and return to previous listing setup? If so , how could it be done?&lt;/p&gt;&#xA;" OwnerUserId="8869" LastEditorUserId="2920" LastEditDate="2016-08-22T14:00:57.043" LastActivityDate="2018-07-20T08:04:44.913" Title="how to use Netrw Directory Listing in VIM split window without exiting it when a file has been read" Tags="|split|netrw|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9288" PostTypeId="2" ParentId="9231" CreationDate="2016-08-22T08:13:20.697" Score="2" Body="&lt;p&gt;I have written the script for this purpose.&lt;br&gt;&#xA;It can be downloaded as vimball based plugin from &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=5430&quot; rel=&quot;nofollow&quot;&gt;http://www.vim.org/scripts/script.php?script_id=5430&lt;/a&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Installation details:&#xA;$ wget http://www.vim.org/scripts/download_script.php?src_id=24462 -O FocusPrevious.vmb&#xA;$ vim FocusPrevious.vmb&#xA;&#xA;Within vim:&#xA;:source %&#xA;:q&#xA;&#xA;Restart vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2749" LastActivityDate="2016-08-22T08:13:20.697" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9289" PostTypeId="2" ParentId="9287" CreationDate="2016-08-22T08:31:28.133" Score="11" Body="&lt;p&gt;There is a dedicated command for opening a netrw listing in a vertical split:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Vex[plore]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a dedicated command for going back to the latest netrw listing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Rex[plore]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Netrw comes with a complete documentation; read it: &lt;code&gt;:help netrw&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-22T08:31:28.133" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9290" PostTypeId="1" AcceptedAnswerId="9351" CreationDate="2016-08-22T09:22:08.857" Score="2" ViewCount="130" Body="&lt;p&gt;consider the bit of vimscript like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! ClangFormatFile()&#xA;    silent exec &quot;:! mv % %.old &amp;amp;&amp;amp; clang-format %.old &amp;gt;&amp;gt; %&quot;&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which means I'd like to format the current file with &lt;code&gt;clang-format&lt;/code&gt; but keep the old version. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On top of that I'd like to disable the &quot;File has changed, do you want to reload?&quot; prompt, but just reload the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;set autoread&lt;/code&gt;, then execute the &lt;code&gt;mv&lt;/code&gt; and &lt;code&gt;clang-format&lt;/code&gt;, then &lt;code&gt;set noautoread&lt;/code&gt; within the function has unfortunately no effect.&lt;/p&gt;&#xA;" OwnerUserId="8917" LastActivityDate="2016-08-25T19:45:24.010" Title="set noautoread for one function" Tags="|vimscript|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9291" PostTypeId="1" AcceptedAnswerId="9292" CreationDate="2016-08-22T10:48:48.990" Score="2" ViewCount="381" Body="&lt;p&gt;I want to replace &lt;code&gt;if (condition) //comment \n\s*{&lt;/code&gt; (\n - newline, \s* 0 or more whitespaces), or rather restructure it, so brace is on same line as if and comment is moved to next one and is indented by one tab more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a Vim practice task, so please don't give me whole solution, instead help me understand what I'm missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My regex works and catches what I want (starting with comment on purpose):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s#\(//\)\(.\)*\n\(\s\)*{#{\r\t\3\1 \2#g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My replace pattern however doesn't catch groups&lt;/strong&gt;, using &lt;code&gt;\1 \2 \3&lt;/code&gt; doesn't work. To be more precise, only &lt;code&gt;\1&lt;/code&gt; works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get a brace, a new line, one more indent as wanted, then groups (except for &lt;code&gt;\1&lt;/code&gt; (meaning &lt;code&gt;//&lt;/code&gt;) are NOT there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (condition) {&#xA;    //&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No comment text, no tabs/whitespaces aside from one I specifically put there. What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="2227" LastEditorUserId="2227" LastEditDate="2016-08-22T12:19:54.360" LastActivityDate="2016-08-22T13:21:00.220" Title="Substitution using groups from regex works only on one group out of three" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9292" PostTypeId="2" ParentId="9291" CreationDate="2016-08-22T13:21:00.220" Score="4" Body="&lt;p&gt;Given this text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (condition) //comment&#xA;    {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the following substitute&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s#\(//\)\(.\)*\n\(\s\)*{#{\r\t\3\1 \2#g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (condition) {&#xA;     // t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't fully understand, but &lt;code&gt;\(.\)*&lt;/code&gt; would repeat the atom of capturing any single character zero or more times, resulting in capturing the last character of first line &lt;code&gt;t&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the intention was to capture all the text following &lt;code&gt;//&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt; should have been inside the capturing group. Same goes for &lt;code&gt;\(\s\)*&lt;/code&gt;. The &lt;code&gt;g&lt;/code&gt; flag is not needed as well&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s#\(//\)\(.*\)\n\(\s*\){#{\r\t\3\1 \2#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (condition) {&#xA;        // comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the very magic modifier, the regex would be (see &lt;code&gt;:h \v&lt;/code&gt; for help)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s#\v(//)(.*)\n(\s*)\{#{\r\t\3\1 \2#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1616" LastActivityDate="2016-08-22T13:21:00.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9293" PostTypeId="1" AcceptedAnswerId="9307" CreationDate="2016-08-22T14:26:59.790" Score="3" ViewCount="1313" Body="&lt;p&gt;I often want to diff more than 4 files, but I run into &lt;code&gt;E96: Can not diff more than 4 buffers&lt;/code&gt;. This limit seems to be compiled into vim, and it also seems rather arbitrary. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything I can do to fix this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;http://vim_use.narkive.com/iwfmPcTT/can-not-diff-more-than-4-buffers&quot;&gt;here&lt;/a&gt; that I'd need to change &lt;code&gt;DB_COUNT&lt;/code&gt;, but that thread is two years old and it doesn't look like they actually tried to implement that fix. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would it work? Would it break anything?&lt;/p&gt;&#xA;" OwnerUserId="8921" LastEditorUserId="1821" LastEditDate="2016-08-22T16:02:10.420" LastActivityDate="2016-08-25T07:35:56.877" Title="Diff more than 4 buffers at the same time" Tags="|vimdiff|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9294" PostTypeId="1" AcceptedAnswerId="9295" CreationDate="2016-08-22T15:28:46.613" Score="1" ViewCount="139" Body="&lt;p&gt;What I want to do is replace this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;|Filename.ext|5|0|&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;|Filename.ext|5|0|&amp;gt;&#xA;&amp;lt;|Filename.ext|5|1|&amp;gt;&#xA;&amp;lt;|Filename.ext|5|2|&amp;gt;&#xA;&amp;lt;|Filename.ext|5|3|&amp;gt;&#xA;&amp;lt;|Filename.ext|5|4|&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wrote a necessary regular expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;|\(\w\| \)\+\.\w\+|\d\{1,2}|0|&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, substitution would go something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; %s/&amp;lt;|\(\w\| \)\+\.\w\+|\d\{1,2}|0|&amp;gt;/REPLACEMENT/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what should &lt;em&gt;REPLACEMENT&lt;/em&gt; actually be?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&#xA;Please, note that &lt;em&gt;5&lt;/em&gt; in the example could be any other number: I am looking for a general solution. So, this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;|Filename.ext|n|0|&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;----&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;|Filename.ext|n|0|&amp;gt;&#xA;&amp;lt;|Filename.ext|n|1|&amp;gt;&#xA;&amp;lt;|Filename.ext|n|2|&amp;gt;&#xA;...&#xA;&amp;lt;|Filename.ext|n|n-2|&amp;gt;&#xA;&amp;lt;|Filename.ext|n|n-1|&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sorry for not making this clear right away.&lt;/p&gt;&#xA;" OwnerUserId="7816" LastEditorUserId="7816" LastEditDate="2016-08-22T16:23:27.083" LastActivityDate="2016-08-23T11:37:32.417" Title="Replace using info from the replaced string" Tags="|regular-expression|replace|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9295" PostTypeId="2" ParentId="9294" CreationDate="2016-08-22T16:00:23.807" Score="3" Body="&lt;p&gt;If you have Vim version &lt;code&gt;7.4.754&lt;/code&gt; or later you can do this simply with some copy/paste and &lt;code&gt;g&amp;lt;C-a&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yy4pf0&amp;lt;C-v&amp;gt;3jg&amp;lt;C-a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yy4p      duplicate the line 4 time and put you on the 2nd line&#xA;f0        go to the 0&#xA;&amp;lt;C-v&amp;gt;3j   start a visual block selection and go down 3 lines&#xA;g&amp;lt;C-a&amp;gt;    increment successively (1, 2, 3, 4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OP ask for a &quot;general&quot; solution,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can replace &lt;code&gt;4&lt;/code&gt; and &lt;code&gt;3&lt;/code&gt; by &lt;code&gt;N&lt;/code&gt; and &lt;code&gt;N-1&lt;/code&gt; to produce the same effect over &lt;code&gt;N&lt;/code&gt; lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at : &lt;code&gt;:h v_g_CTRL-A&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-08-22T16:27:02.477" LastActivityDate="2016-08-22T16:27:02.477" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="9296" PostTypeId="1" CreationDate="2016-08-22T16:09:58.277" Score="6" ViewCount="1224" Body="&lt;p&gt;I've recently mapped &lt;code&gt;jj&lt;/code&gt; to &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; in insert mode for quick escaping. While everything is functional, I find the brief delay after typing &lt;code&gt;j&lt;/code&gt; while it waits for a second input very distracting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible for a &lt;code&gt;j&lt;/code&gt; to always be instantly inserted into the buffer, then if I press &lt;code&gt;j&lt;/code&gt; again the first one is removed before returning to normal mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need to use some sort of script for this? I've tried fiddling with the &lt;code&gt;timeoutlength&lt;/code&gt; and &lt;code&gt;ttimeoutlength&lt;/code&gt; options but they don't seem to do what I want.&lt;/p&gt;&#xA;" OwnerUserId="8923" LastEditorUserId="1821" LastEditDate="2016-08-22T16:23:19.797" LastActivityDate="2019-11-25T22:01:40.263" Title="How do I prevent the delay when mapping jj to &lt;ESC&gt; in insert mode?" Tags="|insert-mode|normal-mode|escape|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9297" PostTypeId="2" ParentId="9294" CreationDate="2016-08-22T16:16:57.093" Score="1" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/|\(0\)|&amp;gt;/\=&quot;|&quot;.(submatch(1)+1).&quot;|&amp;gt;&quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to use &lt;code&gt;\=&lt;/code&gt;, which allows to use an arbitrary expression for the replacement part. Note that it doesn't allows &lt;code&gt;\1&lt;/code&gt;, thus the use of &lt;code&gt;submatch()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info: &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help sub-replace-expression&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-08-22T16:16:57.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9298" PostTypeId="2" ParentId="9294" CreationDate="2016-08-22T16:22:59.383" Score="2" Body="&lt;p&gt;Another way you could do this is with a macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqyyp$bb^aq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;n@q&lt;/code&gt; where n is how many additional lines you want&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt;: record a macro in register &quot;q&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yyp&lt;/code&gt;: yank the current line and put it below&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$bb&lt;/code&gt;: move to the end of line and then back two &quot;words&quot; (This positions the cursor over the second number)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^a&lt;/code&gt;: this is &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; and not a literal &quot;^a&quot;. This increments the number by one.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: end the macro&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@q&lt;/code&gt;: play the macro at register &quot;q&quot;. Can be prefaced with a number as stated before.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-08-22T16:22:59.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9299" PostTypeId="1" AcceptedAnswerId="9301" CreationDate="2016-08-22T16:53:48.040" Score="2" ViewCount="493" Body="&lt;p&gt;pug, and python are both indent-sensitive languages.  I believe that if you have your editor correctly configured this can serve as an advantage, but if it is not correctly configured it's quite a bit of a nuisance.  Are there any settings I should have in my vim to make it easy to indent with the correct number of spaces each time I press tab to indent?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2016-08-22T17:01:50.993" Title="Best Practices for working with an indent-sensitive language?" Tags="|indentation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9301" PostTypeId="2" ParentId="9299" CreationDate="2016-08-22T17:01:50.993" Score="3" Body="&lt;p&gt;I think &lt;code&gt;expandtab&lt;/code&gt; is what you are looking for. It will make tab insert a number of spaces (defined by other options) instead of an actual tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;code&gt;:h expandtab&lt;/code&gt;, &lt;code&gt;:h shiftwidth&lt;/code&gt;, &lt;code&gt;:h tabstop&lt;/code&gt;, &lt;code&gt;:h softtabstop&lt;/code&gt;, and &lt;code&gt;:h filetype-indent&lt;/code&gt;. These are all that settings that affect tabs/indentation that I know of. &lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-08-22T17:01:50.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9302" PostTypeId="1" AcceptedAnswerId="9305" CreationDate="2016-08-23T03:34:44.597" Score="3" ViewCount="13068" Body="&lt;p&gt;I have setup a tags files in my project directory by running &lt;code&gt;ctags -R .&lt;/code&gt;, so then when I put the cursor on a word that is a tag and use the command &lt;code&gt;]&lt;/code&gt;, vim &quot;jumps&quot; to that tag.  Or more correctly, vim loads the file containing the tag in my current window and moves cursor to the tag definition.&lt;br&gt;&#xA;This all works fine, however if I put the cursor on the tag and run the ex command &lt;code&gt;:ptag&lt;/code&gt; to open the tag definition in a preview window, I get   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E73: tag stack empty&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I then use &lt;code&gt;]&lt;/code&gt; instead, again vim will open the tag fine, however, the original &lt;code&gt;:ptag&lt;/code&gt; command is obviously being remembered because when I use the &lt;code&gt;]&lt;/code&gt; command vim will open the tag in a preview window.&lt;br&gt;&#xA;I notice vim reports this message regularly. I always just use &lt;code&gt;]&lt;/code&gt; and then vim will open the tag as intended.&lt;br&gt;&#xA;The help doesn't give any useful background, from: &lt;code&gt;:h E73&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;E73&lt;/em&gt;&lt;br&gt;&#xA;  When you try to use the tag stack while it doesn't contain anything you will get an error message.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Its not plugins either, as the exact same behaviour happens when I open the file with: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -N -U NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;why do I keep getting this error message when I expect vim to jump to the tag definition?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2016-08-23T04:11:57.703" LastActivityDate="2016-08-23T06:26:37.553" Title="Why do I get the &quot;tag stack empty&quot; error when using :ptag and other commands?" Tags="|tags|ctags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9303" PostTypeId="1" CreationDate="2016-08-23T05:44:13.880" Score="4" ViewCount="151" Body="&lt;p&gt;Say you have some text like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;## countries, primary&#xA;United States,Washington,North America&#xA;Canada,Ottawa,North America&#xA;Australia,Canberra,Oceania&#xA;## countries, secondary&#xA;France,Paris,Europe&#xA;Japan,Tokyo,Asia&#xA;United Kingdom,London,Europe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you want to filter &lt;em&gt;only the non-comment lines&lt;/em&gt; through an external program, say &lt;code&gt;column -ts,&lt;/code&gt;, to align the comma-separated fields. In other words, the expected output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;## countries, primary&#xA;United States   Washington  North America&#xA;Canada          Ottawa      North America&#xA;Australia       Canberra    Oceania&#xA;## countries, secondary&#xA;France          Paris       Europe&#xA;Japan           Tokyo       Asia&#xA;United Kingdom  London      Europe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do this in vim with a single command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought maybe combining &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html#:global&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:g&lt;/code&gt;&lt;/a&gt; with &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:range!&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:range!&lt;/code&gt;&lt;/a&gt; would work, but it doesn't:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g!/^\s*#/!column -ts,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above just runs &lt;code&gt;:!column -ts,&lt;/code&gt; once for each line that matched the &lt;code&gt;:g&lt;/code&gt; command. In other words, it doesn't actually filter anything, it just runs a system command with stdin connected to the terminal, once for each matching line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the general question is, how can we filter discontinuous line sets through an external program, passing all the lines as one block to the stdin of the external program, and returning the output lines back to their corresponding line numbers in the buffer?&lt;/p&gt;&#xA;" OwnerUserId="8927" LastActivityDate="2018-09-01T20:10:25.360" Title="How to filter discontinuous line sets through an external program (Is it possible to combine :g global command with :range! external program filter)?" Tags="|command-line|external-command|range|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9304" PostTypeId="1" CreationDate="2016-08-23T05:56:09.377" Score="2" ViewCount="79" Body="&lt;p&gt;Is there any way to trace the source of an auto-complete event within (Mac)Vim? Ie, where within which plugin this is and how it can be turned off?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case, I type &lt;code&gt;{}&lt;/code&gt; in a .tex file and it automatically converts it to &lt;code&gt;{}&amp;lt;++&amp;gt;&lt;/code&gt;, necessitating an &lt;code&gt;Esc&lt;/code&gt; &lt;code&gt;u&lt;/code&gt; to return to the original &lt;code&gt;{}&lt;/code&gt;. I just want to be able to type &lt;code&gt;{}&lt;/code&gt; and for the auto-complete event not to occur.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;, although I have this specific problem, I am looking for general information about tracing the origin of such problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="2001" LastActivityDate="2016-08-23T11:28:18.330" Title="How to trace the origin of an autocomplete feature, in order to turn it off?" Tags="|autocompletion|macvim|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9305" PostTypeId="2" ParentId="9302" CreationDate="2016-08-23T06:26:37.553" Score="5" Body="&lt;p&gt;First, the command to jump to a tag is &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;, not &lt;code&gt;]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, &lt;code&gt;:ptag&lt;/code&gt; doesn't care about the word under your cursor. It works just like &lt;code&gt;:tag&lt;/code&gt; but uses the preview window instead of jumping directly to the tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:tag&lt;/code&gt; and &lt;code&gt;:ptag&lt;/code&gt;, without argument, are used to jump to the first tag in &lt;em&gt;the tag stack&lt;/em&gt;. You'll obviously get an error if the tag stack is empty, or a semi-useless behavior if it only contains the current tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use &lt;code&gt;:ptag&lt;/code&gt; to display the definition of the word under the cursor in the preview window you need to pass that word as argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ptag foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can insert the word under the cursor in the command-line with &lt;code&gt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ptag &amp;lt;c-r&amp;gt;&amp;lt;C-w&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also press &lt;code&gt;&amp;lt;C-w&amp;gt;}&lt;/code&gt; to the same effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help :ptag&lt;/code&gt;, &lt;code&gt;:help tag-stack&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-08-23T06:26:37.553" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9307" PostTypeId="2" ParentId="9293" CreationDate="2016-08-23T09:24:13.737" Score="3" Body="&lt;p&gt;Changing DB_COUNT  in structs.h does indeed work, and so far, I haven't run into any issues. Here's the git diff of my change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diff --git a/src/structs.h b/src/structs.h&#xA;index 4488bf8..7524bd1 100644&#xA;--- a/src/structs.h&#xA;+++ b/src/structs.h&#xA;@@ -2296,7 +2296,7 @@ struct file_buffer&#xA; /*&#xA;  * Stuff for diff mode.&#xA;  */&#xA;-# define DB_COUNT 4    /* up to four buffers can be diff'ed */&#xA;+# define DB_COUNT 16   /* up to four buffers can be diff'ed */&#xA;&#xA; /*&#xA;  * Each diffblock defines where a block of lines starts in each of the buffers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Update: This has now been added to Vim in &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v7.4.2251&quot; rel=&quot;nofollow&quot;&gt;patch 7.4.2251&lt;/a&gt;. However, it has only increased to 8, not to 16. If you need it to be higher than 8, you'll still need to increase DB_COUNT and compile Vim yourself.&lt;/p&gt;&#xA;" OwnerUserId="8921" LastEditorUserId="8921" LastEditDate="2016-08-25T07:35:56.877" LastActivityDate="2016-08-25T07:35:56.877" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9308" PostTypeId="1" AcceptedAnswerId="9310" CreationDate="2016-08-23T10:53:31.903" Score="6" ViewCount="3296" Body="&lt;p&gt;The question is somewhat straightforward. To open a vertical split, I use: &lt;code&gt;:vs&lt;/code&gt;. When opening a vertical split, I'd like to initialize it with a file directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do &lt;code&gt;:vs myfile.txt&lt;/code&gt; this will move the file I am currently working on to the right and open &lt;code&gt;myfile.txt&lt;/code&gt; on the left of the split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather, I would like the opposite to happen: the file I am working on before the vertical split stays on the left, and &lt;code&gt;myfile.txt&lt;/code&gt; opens on the right of the split.&lt;/p&gt;&#xA;" OwnerUserId="4562" LastEditorUserId="1841" LastEditDate="2016-08-23T11:30:38.880" LastActivityDate="2016-08-23T11:58:21.177" Title="How to change the location of a new vertical split?" Tags="|split|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9309" PostTypeId="1" AcceptedAnswerId="9323" CreationDate="2016-08-23T11:03:33.130" Score="2" ViewCount="6269" Body="&lt;p&gt;I want to be able to run a script to indent the line of code I have just written each time I press enter key in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More concretely,currently I use following key binding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-K&amp;gt; :pyf ~/clang-format.py&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the sequence of events I have to make happen is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;write a line&lt;/li&gt;&#xA;&lt;li&gt;come out of insert mode&lt;/li&gt;&#xA;&lt;li&gt;auto format (with &lt;kbd&gt;Ctrl+K&lt;/kbd&gt;)&lt;/li&gt;&#xA;&lt;li&gt;go back to insert mode&lt;/li&gt;&#xA;&lt;li&gt;press enter key and start editing next line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What I wish to achieve is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;write a line&lt;/li&gt;&#xA;&lt;li&gt;press enter key in insert mode (and automatically trigger &lt;code&gt;pyf ~/clang-format.py&lt;/code&gt;) &lt;/li&gt;&#xA;&lt;li&gt;and get the line formatted without any hassle.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8932" LastEditorUserId="1841" LastEditDate="2016-08-23T11:17:08.710" LastActivityDate="2016-08-24T09:33:23.570" Title="Key binding for enter key in insert mode" Tags="|key-bindings|indentation|formatting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9310" PostTypeId="2" ParentId="9308" CreationDate="2016-08-23T11:21:22.837" Score="7" Body="&lt;p&gt;You should use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:botright vsp myFile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#:botright&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h botright&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Execute {cmd}.  If it contains a command that splits a window,&#xA;          it will appear at the bottom and occupy the full width of the&#xA;          Vim window.  When the split is vertical the window appears at&#xA;          the far right and occupies the full height of the Vim window.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Credit goes to &lt;a href=&quot;https://vi.stackexchange.com/questions/9308/how-to-change-the-location-of-a-new-vertical-split/9310?noredirect=1#comment16180_9310&quot;&gt;ingo&lt;/a&gt; for this one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can make &lt;code&gt;botright&lt;/code&gt; the default behavior by using the &lt;code&gt;splitright&lt;/code&gt; option in your vimrc. In this configuration &lt;code&gt;topleft&lt;/code&gt; can be used to open a split on the left.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-08-23T11:58:21.177" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9311" PostTypeId="2" ParentId="9304" CreationDate="2016-08-23T11:28:18.330" Score="1" Body="&lt;p&gt;This is due either to an &lt;code&gt;imap&lt;/code&gt; or an &lt;code&gt;iabbrev&lt;/code&gt;. You can do either of these to check if there are any current definitions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[verbose ]imap {}&#xA;:[verbose ]iabbrev {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;code&gt;verbose&lt;/code&gt; is optional and will tell you where things are defined.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The particular mapping in your question is defined by &lt;a href=&quot;https://github.com/vim-latex/vim-latex&quot; rel=&quot;nofollow&quot;&gt;vim-latex&lt;/a&gt;, and as suggested by @romainl in a comment to your question, it is an &lt;code&gt;imap&lt;/code&gt;. However, the same &quot;problem&quot; could also come from an abbreviation, which is defined with the &lt;code&gt;:iabbrev&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For relevant help sections, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :imap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :iabbrev&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :verbose&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h latex-macros&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-08-23T11:28:18.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9312" PostTypeId="2" ParentId="9294" CreationDate="2016-08-23T11:37:32.417" Score="0" Body="&lt;p&gt;To add a solution only using &lt;code&gt;:s&lt;/code&gt;, I would suggest&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/^.*$/\=map(range(0,split(getline(&quot;.&quot;),&quot;|&quot;)[2]), 'join(split(getline(&quot;.&quot;), &quot;|&quot;)[0:2] + [v:val] + split(getline(&quot;.&quot;), &quot;|&quot;)[4:4], &quot;|&quot;)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will work for any &lt;code&gt;foo|bar|x|0|end&lt;/code&gt;, where &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;bar&lt;/code&gt; are string not containing the pipe character &lt;code&gt;|&lt;/code&gt;, &lt;code&gt;x&lt;/code&gt; is the number that indicates the number of repetitions, and &lt;code&gt;end&lt;/code&gt; is an arbitrary string.&lt;/p&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2016-08-23T11:37:32.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9313" PostTypeId="1" AcceptedAnswerId="9315" CreationDate="2016-08-23T11:53:19.970" Score="71" ViewCount="25523" Body="&lt;p&gt;Why use the keys &lt;kbd&gt;hjkl&lt;/kbd&gt; on the same line instead of keys in a triangle like &lt;kbd&gt;wasd&lt;/kbd&gt; for moving on video games?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why not something equivalent with right hand, like &lt;kbd&gt;ijkl&lt;/kbd&gt; or &lt;kbd&gt;pl;'&lt;/kbd&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8935" LastEditorUserId="51" LastEditDate="2017-07-30T23:08:05.497" LastActivityDate="2017-07-30T23:08:05.497" Title="Why does vim use hjkl for cursor keys?" Tags="|cursor-motions|history-of|keyboard-layout|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9314" PostTypeId="2" ParentId="5048" CreationDate="2016-08-23T11:53:27.690" Score="5" Body="&lt;p&gt;Based on the previous answer suggesting the use of &lt;code&gt;silent&lt;/code&gt; I made the following &lt;code&gt;:Vmake&lt;/code&gt; command with a small modification to redraw the screen: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! Vmake silent w | silent make | unsilent redraw! | cwindow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It saves the buffer and runs make silently to avoid the hit enter prompt. Then redraws the screen to workaroud the &lt;code&gt;:silent&lt;/code&gt; weirdness (see &lt;code&gt;:help :silent&lt;/code&gt;). Then automatically closes the quickfix window if there where no errors.&lt;/p&gt;&#xA;" OwnerUserId="8934" LastEditorUserId="8934" LastEditDate="2016-08-23T14:12:34.687" LastActivityDate="2016-08-23T14:12:34.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9315" PostTypeId="2" ParentId="9313" CreationDate="2016-08-23T12:10:03.307" Score="86" Body="&lt;p&gt;From &lt;a href=&quot;http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/&quot;&gt;http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When Bill Joy created the vi text editor he used the ADM-3A terminal, which had the arrows on hjkl keys. Naturally he reused the same keys and the rest is history!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/K4ZfL.jpg&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/K4ZfL.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-08-23T12:10:03.307" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="9316" PostTypeId="1" CreationDate="2016-08-23T13:23:51.233" Score="2" ViewCount="157" Body="&lt;p&gt;It's pretty common for me to have code like this in Python and Javascript.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_obj = [&#xA;    { id: 0, name: 'foo', age: 123 },&#xA;    { id: 1, name: 'foo', age: 321 }&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'd like to automate is formatting it so the results look like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_obj = [&#xA;    { &#xA;        id: 0, &#xA;        name: 'foo',&#xA;        age: 123 &#xA;    },&#xA;    {&#xA;        id: 1, &#xA;        name: 'foo', &#xA;        age: 321 &#xA;    }&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin or something that handles this? I could only find vim-align, but it doesn't appear to handle this scenario.&lt;/p&gt;&#xA;" OwnerUserId="8937" LastActivityDate="2016-08-23T13:23:51.233" Title="How can I format objects wrapped inside curly braces?" Tags="|formatting|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9317" PostTypeId="2" ParentId="9303" CreationDate="2016-08-23T13:36:08.077" Score="2" Body="&lt;p&gt;If you want to have the table spacing inferred using the whole file, you could delete the headlines, run &lt;code&gt;column&lt;/code&gt; on the resulting file and reinsert the headlines using something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Column()&#xA;  let b:headlines={}&#xA;  g/^##.*$/let b:headlines[line(&quot;.&quot;)+len(b:headlines)]=getline(&quot;.&quot;)|d&#xA;  %!column -ts,&#xA;  call map(b:headlines, 'append(v:key-1, v:val)')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if you want each block between to headlines to be a separate table (possibly with different tabstops than the others), you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^\s*##.*\n\_.*\n\s*##/ .+1,/^\s*##/-1!column -ts,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will work for all but the last block, which can be selected using visual line mode and treated using &lt;code&gt;:'&amp;lt;,'&amp;gt;!column -ts,&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2016-08-23T13:36:08.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9318" PostTypeId="2" ParentId="9313" CreationDate="2016-08-23T16:47:38.907" Score="19" Body="&lt;p&gt;As to why these arrows were printed on these keys... it's because they could be used with the control key for local cursor movement. Ctrl-H and Ctrl-J (backspace and line feed) are obvious, and an easy mnemonic even today. Ctrl-K is &quot;vertical tab&quot;, but was sometimes used for reverse linefeed on pre-ANSI terminals. The use of Ctrl-L for a non-destructive cursor forward was probably chosen based on its keyboard location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also have noticed in the picture of the keyboard in the other answer that &quot;HOME&quot; is on the &lt;code&gt;^&lt;/code&gt;/&lt;code&gt;~&lt;/code&gt; key. Of course, Ctrl-^ homes the cursor (sends to the top left of the screen, or bottom left, depending on mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These control mappings were also used for Wyse terminals, the Kermit protocol, and were supported in some versions of PC ANSI.SYS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sources:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vt100.net/lsi/adm3a-om/&quot; rel=&quot;noreferrer&quot;&gt;The ADM-3A Operator's Manual&lt;/a&gt;, page 3-5 [pdf page 38] onward describes the control functions.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://invisible-island.net/ncurses/terminfo.src.html&quot; rel=&quot;noreferrer&quot;&gt;Terminfo database&lt;/a&gt; for other terminals; search for &lt;code&gt;kcuf1=^L&lt;/code&gt; and &lt;code&gt;kcuu1=^K&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="880" LastEditorUserId="880" LastEditDate="2016-08-24T18:16:11.303" LastActivityDate="2016-08-24T18:16:11.303" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9320" PostTypeId="2" ParentId="9303" CreationDate="2016-08-23T20:55:01.903" Score="1" Body="&lt;p&gt;A simple way is to remove commas from comment lines before filtering,&#xA;then replace them afterwards:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^##/ s/,/COMMA/ | s/^/,,/&#xA;:%!column -ts,&#xA;:g/^\s*##/ s/\s*// | s/COMMA/,/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You also need to prepend comment lines with commas if you don't want&#xA;them to affect the alignment; you may find that a bit hacky.&#xA;It's also not a single command, but why does that need to be a requirement?&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-08-23T21:16:24.660" LastActivityDate="2016-08-23T21:16:24.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9321" PostTypeId="1" CreationDate="2016-08-24T00:21:20.523" Score="1" ViewCount="322" Body="&lt;p&gt;I have the following in &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=2 softtabstop=-1 shiftwidth=0 expandtab&#xA;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I type the following in an HTML file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html id=&quot;somethingverylong&quot;&#xA;&amp;gt;&#xA;&amp;lt;head&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I expect the following indentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html id=&quot;somethingverylong&quot;&#xA;      &amp;gt;&#xA;  &amp;lt;head&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; to be indented two spaces. However, I get the following indentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html id=&quot;somethingverylong&quot;&#xA;      &amp;gt;&#xA;      &amp;lt;head&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I make Vim respect the &lt;code&gt;shiftwidth&lt;/code&gt; setting and indent the inner tag with 2 spaces, instead of aligning with the closing &lt;code&gt;&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug  2 2016 05:21:06)&#xA;Included patches: 1-2143&#xA;Compiled by Arch Linux&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1182" LastEditorUserId="1182" LastEditDate="2016-08-26T23:05:39.333" LastActivityDate="2016-08-26T23:05:39.333" Title="Fix indentation after a multiline HTML tag" Tags="|indentation|filetype-html|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9323" PostTypeId="2" ParentId="9309" CreationDate="2016-08-24T09:20:13.150" Score="4" Body="&lt;p&gt;You can use the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;CR&amp;gt; &amp;lt;Esc&amp;gt;:pyf ~/clang-format.py&amp;lt;CR&amp;gt;o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be explained like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The mapping command:&#xA;inoremap                creates a mapping in insert mode&#xA;&#xA;The left hand part:&#xA;&amp;lt;CR&amp;gt;                    you want to map the 'enter' key and its code is &amp;lt;CR&amp;gt;&#xA;&#xA;The right hand part:&#xA;&amp;lt;Esc&amp;gt;                   exit insert mode&#xA;:pyf ~/clang-format.py  write the command to execute&#xA;&amp;lt;CR&amp;gt;                    press 'enter' to execute the command&#xA;o                       pressing 'o' in normal mode will add a new line and switch to insert mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the comments you asked why it doesn't work in paste mode. It is normal you can't create mapping in paste mode it would defeat the purpose of this mode. See &lt;a href=&quot;https://stackoverflow.com/q/3897992/4194289&quot;&gt;this question on SO&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally a note on the efficiency of your workflow: I might be wrong but if I understand correctly you want to reformat all of your file each time you insert a new line. That doesn't seem ideal since Vim as some options to help you format your code as you right it. Now as I don't really know what your command does maybe it is the best solution.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; To answer your comment, if you want to trigger the command only when you exit insert mode when editing a python file you can use autocommands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! InsertLeave *.py pyf ~/clang-format.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h :autocmd&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-08-24T09:33:23.570" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9326" PostTypeId="1" CreationDate="2016-08-24T14:40:29.357" Score="3" ViewCount="384" Body="&lt;p&gt;I found that to press &lt;code&gt;]]&lt;/code&gt; to close a matching bracket by means of &lt;code&gt;&amp;lt;Plug&amp;gt;(vimtex-delim-close)&lt;/code&gt; a little inconvenient, as I am using a French keyboard and have to press two keys to type &lt;code&gt;]&lt;/code&gt;. So I tried to use other keys, such as &lt;code&gt;)&lt;/code&gt;. And typing the following when in a tex file works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap ) &amp;lt;C-R&amp;gt;=&amp;lt;Plug&amp;gt;vimtex#delim#close()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, if I put the above inside my &lt;code&gt;.vimrc&lt;/code&gt; file, I receive the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E15: Invalid expression: &amp;lt;Plug&amp;gt;vimtex#delim#close()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;twice.&#xA;I don't really understand how this works, such as &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;. So maybe I am just doing it wrong? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, any help or reference would be greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I think this is not a &lt;code&gt;vimtex&lt;/code&gt;-specific question, but, as it involves this good package, I shall still tag as such.&lt;/p&gt;&#xA;" OwnerUserId="8756" LastActivityDate="2016-08-24T14:50:55.810" Title="How to remap &lt;Plug&gt;vimtex#delim#close()&lt;CR&gt;?" Tags="|key-bindings|vimrc|plugin-vimtex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9327" PostTypeId="2" ParentId="9326" CreationDate="2016-08-24T14:45:15.223" Score="5" Body="&lt;pre&gt;&lt;code&gt;:imap ) &amp;lt;Plug&amp;gt;vimtex#delim#close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are supposed to deal with &quot;Plug mappings&quot; just like you would deal with any other mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, since you want to reuse another mapping in your own mapping you must use a &lt;em&gt;recursive&lt;/em&gt; mapping. &lt;code&gt;:inoremap&lt;/code&gt; is a non-recursive mapping, &lt;code&gt;:imap&lt;/code&gt; is a recursive mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, since &lt;code&gt;&amp;lt;Plug&amp;gt;vimtex#delim#close()&lt;/code&gt; is not an expression, using it as such is useless… so you don't need &lt;code&gt;&amp;lt;C-r&amp;gt;=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third, the trailing &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is also useless, for the same reason.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-08-24T14:50:55.810" LastActivityDate="2016-08-24T14:50:55.810" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9329" PostTypeId="2" ParentId="9313" CreationDate="2016-08-24T16:17:16.077" Score="28" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/9315/2920&quot;&gt;Nobe4's answer&lt;/a&gt; is great, and explains why we use &lt;code&gt;hjkl&lt;/code&gt; very well. However, it's really interesting to see the full keyboard, and a lot of strange things about vim make more sense when you can see the full keyboard it was designed on. For example, why does vi rely so heavily on the &lt;code&gt;esc&lt;/code&gt; key, when it's in such a weird and uncomfortable place? This is why:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qdO06.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qdO06.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, &lt;code&gt;esc&lt;/code&gt; is where tab is on most keyboards. &lt;code&gt;ctrl&lt;/code&gt; is another key that is slightly awkward to reach, but in a very comfortable location on this keyboard (where caps lock usually is). &lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-08-24T18:25:21.720" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9331" PostTypeId="1" AcceptedAnswerId="9332" CreationDate="2016-08-24T18:25:37.163" Score="2" ViewCount="399" Body="&lt;p&gt;I am actually stuck level 10 at &lt;a href=&quot;http://vim-adventures.com&quot; rel=&quot;nofollow&quot;&gt;vim-adventures&lt;/a&gt;, but this question concerns vim in general. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a new file with this content: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;99 bottles of beer    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I yank the line with &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;Y&lt;/kbd&gt; I get &lt;code&gt;99 bottles of beer&amp;lt;cr&amp;gt;&lt;/code&gt;, if I do &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt; I get &lt;code&gt;99 bottles of beer&lt;/code&gt; without the new line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is how can I just append &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; that I yank from somewhere into my registers?&lt;/p&gt;&#xA;" OwnerUserId="2548" LastEditorUserId="6489" LastEditDate="2016-08-24T18:37:52.777" LastActivityDate="2016-08-25T08:38:49.727" Title="How to append &lt;cr&gt; to a register from a yank?" Tags="|cut-copy-paste|register|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9332" PostTypeId="2" ParentId="9331" CreationDate="2016-08-24T18:33:02.297" Score="2" Body="&lt;p&gt;One way is to use a capital &quot;A&quot; for the yank command which appends to the register instead of replacing it. So you would need to position your cursor on a blank line and then do &lt;code&gt;&quot;AY&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h quote&lt;/code&gt; for more info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to do it would be to run the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a = @a . &quot;\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Registers can be address like variables with @ notation.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-08-24T18:40:39.560" LastActivityDate="2016-08-24T18:40:39.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9333" PostTypeId="2" ParentId="9277" CreationDate="2016-08-24T19:34:42.903" Score="-1" Body="&lt;p&gt;As a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map ,, :let @&quot;=repeat(' ',col(&quot;.&quot;)-1).&quot;\n&quot;^Mpi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;^M is produced in vim by Ctrl-vCtrl-m, which is the same as the more usual left-angle cr right-angle which this cock-a-mamie editor refuses to show.&lt;/p&gt;&#xA;" OwnerUserId="5220" LastEditorUserId="6489" LastEditDate="2016-08-24T19:40:56.260" LastActivityDate="2016-08-24T19:40:56.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9334" PostTypeId="2" ParentId="5989" CreationDate="2016-08-24T20:01:27.503" Score="5" Body="&lt;p&gt;I have found the method of taking the output of a program as redirected from sub-shell to be very easy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim &amp;lt;( program )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; vim &amp;lt;( grep -nH  hello  myFile.cpp )&#xA; vim &amp;lt;( find . -name '*.cpp' -exec grep -nH code_expr {} \+ )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8984" LastActivityDate="2016-08-24T20:01:27.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9335" PostTypeId="2" ParentId="8855" CreationDate="2016-08-24T21:19:51.553" Score="0" Body="&lt;p&gt;I couldn't really use the proposed solution because &lt;code&gt;shellescape&lt;/code&gt; returns a string with simple quotes &lt;code&gt;'&lt;/code&gt; so I couldn't use it inside the &lt;code&gt;--exclude&lt;/code&gt; grep opt.&lt;/p&gt;&#xA;&lt;p&gt;This is what I worked:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;grepprg=&amp;quot;grep -n -r --exclude=\\*.{o,obj,~,pyc,git}\\* --exclude={tags,cscope}\\* $* /dev/null&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2561" LastEditorUserId="10604" LastEditDate="2020-10-27T01:30:30.500" LastActivityDate="2020-10-27T01:30:30.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9336" PostTypeId="1" AcceptedAnswerId="9337" CreationDate="2016-08-24T21:37:33.723" Score="4" ViewCount="258" Body="&lt;p&gt;I have file where I would like to indent all the lines between curly braces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;html {&#xA;margin: 0;&#xA;padding: 0;&#xA;border: 0;&#xA;font-size: 100%;&#xA;font: inherit;&#xA;vertical-align: baseline;&#xA;}&#xA;body {&#xA;line-height: 1.5;&#xA;color: black;&#xA;background: white;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could do this with &lt;code&gt;:g/{/ .+1,/}/-1 &amp;gt;&lt;/code&gt; &lt;code&gt;Ex&lt;/code&gt; command. However, I also tried to do the same with regular expression &lt;code&gt;:g/\v\{\_s?\zs\_.{-}\ze\}/ &amp;gt;&lt;/code&gt;. This will match all the lines between curly braces and I expected &lt;code&gt;&amp;gt;&lt;/code&gt; command to indent the matched lines. Instead, it indents the &lt;code&gt;html {&lt;/code&gt; and &lt;code&gt;body {&lt;/code&gt; lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        html {&#xA;margin: 0;&#xA;padding: 0;&#xA;border: 0;&#xA;font-size: 100%;&#xA;font: inherit;&#xA;vertical-align: baseline;&#xA;}&#xA;        body {&#xA;line-height: 1.5;&#xA;color: black;&#xA;background: white;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the reason for such behavior?&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2016-09-04T19:20:00.750" Title="indent command does not indent matched lines" Tags="|indentation|global-command|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9337" PostTypeId="2" ParentId="9336" CreationDate="2016-08-24T21:48:23.413" Score="5" Body="&lt;p&gt;I'm guessing the problem is that &lt;code&gt;:global&lt;/code&gt; operates linewise, so the &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; in your regex don't do anything; They still apply to the line that matched the &lt;em&gt;entire pattern&lt;/em&gt;, not the line that the &lt;em&gt;selection&lt;/em&gt; starts and ends on. For example, if you have the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/foo\n\zsb/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will delete &lt;code&gt;foo&lt;/code&gt; rather than deleting &lt;code&gt;bar&lt;/code&gt;. Keep in mind, this is mostly a guess, I've never ran into this behavior before, all though it's reproducible. Really though, if you think about it, it makes sense. The definition of the global command is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]g[lobal]/{pattern}/[cmd]&#xA;            Execute the Ex command [cmd] (default &quot;:p&quot;) on the&#xA;            LINES within [range] where {pattern} matches.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Emphasis added). &lt;code&gt;foo&lt;/code&gt; matches the pattern &lt;code&gt;foo\n\zsbar&lt;/code&gt;, so it's irrelevant that you moved the selection forward; the line still matches. On the other hand, there is no possible way for &lt;code&gt;bar&lt;/code&gt; to match the pattern &lt;code&gt;foo\n\zsbar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing you could do to make your command simpler is to use the negative global command, e.g. an ex command on every line &lt;em&gt;not&lt;/em&gt; matching. That could just be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g!/{\|}/&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-08-24T21:56:13.570" LastActivityDate="2016-08-24T21:56:13.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9338" PostTypeId="1" AcceptedAnswerId="9339" CreationDate="2016-08-25T00:25:51.977" Score="6" ViewCount="2283" Body="&lt;p&gt;And I add this in the vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown iabbrev mkdc &amp;lt;!--i--&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I want to do is source the vimrc and make the abbreviation effective for the current file I'm editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:!sc&lt;/code&gt;, &lt;code&gt;:redraw!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:source $MYVIMRC&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:q&lt;/code&gt; and rerun Vim&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But it seems that only the last method works. Is there any way to get this to work without leaving Vim? Why doesn't the second method as stated in all other related answers work in this situation?&lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="51" LastEditDate="2016-08-26T09:56:15.670" LastActivityDate="2020-04-10T15:36:03.803" Title="Why cannot I source vimrc for the current file being editing?" Tags="|vimrc|load|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9339" PostTypeId="2" ParentId="9338" CreationDate="2016-08-25T06:10:36.463" Score="11" Body="&lt;p&gt;Your autocommand is executed when the &lt;code&gt;FileType&lt;/code&gt; event is triggered, with the &lt;code&gt;markdown&lt;/code&gt; value. Sourcing your &lt;code&gt;vimrc&lt;/code&gt; is not enough because it only adds the autocommand but the event is not triggered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to do is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Source your &lt;code&gt;vimrc&lt;/code&gt; with &lt;code&gt;:source $MYVIMRC&lt;/code&gt;, this will add your autocommand to the existing ones.&lt;/li&gt;&#xA;&lt;li&gt;Reload your current buffer with &lt;code&gt;:e&lt;/code&gt;, this will trigger the &lt;code&gt;FileType&lt;/code&gt; event and thus run your autocommand.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also, adding half-understood &lt;code&gt;FileType&lt;/code&gt; autocommands to your &lt;code&gt;vimrc&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; a good way to get filetype-specific settings/mappings/abbreviations/commands/whatever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you should use the built-in filetype detection and put your filetype-specific stuff in proper &lt;em&gt;ftplugins&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;in &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;in &lt;code&gt;~/after/ftplugin/markdown.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev &amp;lt;buffer&amp;gt; mkdc &amp;lt;!--i--&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-08-25T07:51:29.333" LastActivityDate="2016-08-25T07:51:29.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9340" PostTypeId="2" ParentId="9331" CreationDate="2016-08-25T08:12:06.210" Score="1" Body="&lt;p&gt;Another option is to use the &lt;code&gt;setreg()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg('a', &quot;\n&quot;, 'a')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the help of &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#setreg()&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h setreg()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first parameter is the name of the register to modify&lt;/li&gt;&#xA;&lt;li&gt;The second one is the string to put into the register&lt;/li&gt;&#xA;&lt;li&gt;The third one is optional, if it contains &lt;code&gt;a&lt;/code&gt; then the string is appended to the content of the register otherwise it replace the existing content.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-08-25T08:12:06.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9341" PostTypeId="2" ParentId="9331" CreationDate="2016-08-25T08:38:49.727" Score="1" Body="&lt;p&gt;There is &lt;code&gt;setreg()&lt;/code&gt; method, you can not only modify the value of the register, but also the &quot;mode&quot; see &lt;code&gt;:h setreg(&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you can just convert the char-based selection/yank to line-based selection/yank, without changing the value of &lt;code&gt;@a&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg('a',@a,'V')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg('a',@a,'l')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1569" LastActivityDate="2016-08-25T08:38:49.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9342" PostTypeId="1" AcceptedAnswerId="9343" CreationDate="2016-08-25T10:09:32.343" Score="1" ViewCount="1195" Body="&lt;p&gt;Does anyone one know of a short key sequence that would do the equivalent of &lt;code&gt;:1,-d:+,$d&lt;/code&gt;? Yes, I know you can define a function, macro, and that would be nice. But, maybe a bit more elegant if you could hit some predefined keys, letters, controls, and get the same result.&lt;/p&gt;&#xA;" OwnerUserId="5919" LastActivityDate="2016-08-25T10:42:37.843" Title="Erase all lines except for the current one" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9343" PostTypeId="2" ParentId="9342" CreationDate="2016-08-25T10:22:14.330" Score="8" Body="&lt;p&gt;Maybe this will do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:v/\%#/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should deal with corner cases like the line you want to keep being the&#xA;first line in the buffer, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or perhaps &lt;code&gt;:move&lt;/code&gt; the current line to the beginning of the buffer and delete the rest:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:m0|+,$d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;YggPjdG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To repeat later, either map it to a key, or maybe grab it from your history with &lt;code&gt;:v&amp;lt;up&amp;gt;&lt;/code&gt; for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;References:&lt;/em&gt;&lt;br&gt;&#xA;&lt;code&gt;:help :v&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;:help /\%#&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-08-25T10:42:37.843" LastActivityDate="2016-08-25T10:42:37.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9344" PostTypeId="1" AcceptedAnswerId="9345" CreationDate="2016-08-25T10:53:15.883" Score="4" ViewCount="876" Body="&lt;p&gt;I have the file /path/a.md which has many sections as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# abc&#xA;this this the content of section abc&#xA;# def&#xA;this this the content of section abc&#xA;## defg&#xA;this this the content of subsection defg of def&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in an other file /path/b.md I have the the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I want to switch to def section by this link [section def in a.md](./a.md#def), &#xA;yeh the file name and the section name are separated by &quot;#&quot; &#xA;and this kind of link is also possible:[subsection defg in a.md](./a.md##defg)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="1788" LastEditDate="2016-08-25T11:32:15.833" LastActivityDate="2020-02-08T19:48:07.967" Title="Open markdown filename under cursor like gf, and jump to the section?" Tags="|key-bindings|multiple-files|filetype-markdown|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9345" PostTypeId="2" ParentId="9344" CreationDate="2016-08-25T11:54:33.117" Score="9" Body="&lt;p&gt;This function is not thoroughly tested but it should provide a good enough bootstrap for your own experiments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;~/.vim/after/ftplugin/markdown.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:MDGoToSection()&#xA;    let raw_filename = expand('&amp;lt;cfile&amp;gt;')&#xA;    let arg = substitute(raw_filename, '\([^#]*\)\(#\{1,6\}\)\([^#]*\)', '+\/\2\\\\s\3 \1', 'g')&#xA;    execute &quot;edit&quot; arg&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;key&amp;gt; :call &amp;lt;SID&amp;gt;MDGoToSection()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lRPuX.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lRPuX.gif&quot; alt=&quot;gf++&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The filename under the cursor is split into three groups:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\([^#]*\)......................... everything before the first #              &#xA;         \(#\{1,6\}\)............. 1 to 6 #&#xA;                     \([^#]*\).... everything after #######&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and reordered into a proper argument for &lt;code&gt;:edit&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+\/\2\\\\s\3 \1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which should split &lt;code&gt;./foo.md##bar&lt;/code&gt; into &lt;code&gt;./foo.md&lt;/code&gt;, &lt;code&gt;##&lt;/code&gt;, and &lt;code&gt;bar&lt;/code&gt;, and finally pass &lt;code&gt;+/##\\sbar ./foo.md&lt;/code&gt; to &lt;code&gt;:edit&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit +/##\\sbar ./foo.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-08-25T13:33:13.000" LastActivityDate="2016-08-25T13:33:13.000" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9346" PostTypeId="2" ParentId="9344" CreationDate="2016-08-25T11:54:56.557" Score="5" Body="&lt;p&gt;As I said in the comments on my setup gf didn't opened the file because &lt;code&gt;#&lt;/code&gt; was in &lt;code&gt;isfname&lt;/code&gt;, so using &lt;code&gt;set isfname-=#&lt;/code&gt; allowed &lt;code&gt;gf&lt;/code&gt; to jump to the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I also said I think the feature to go to a section of the file is not built in so you can try this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MarkdownGF()&#xA;    &quot; Get the filename under the cursor&#xA;    let cfile=expand('&amp;lt;cfile&amp;gt;')&#xA;    &quot; Separate the filename from the section&#xA;    let parts=split(cfile, '#')&#xA;&#xA;    &quot; No section marked&#xA;    if (len(parts) == 1)&#xA;        execute &quot;normal! gf&quot;&#xA;    &quot; There was a subsection in the file name&#xA;    else&#xA;        execute &quot;e &quot; . parts[0]&#xA;        let pattern = &quot;^&quot; . repeat('\#',len(parts)-1) . &quot;\\\s*&quot; . parts[len(parts)-1] . &quot;$&quot;&#xA;        call search(pattern, 'w')&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function is to be called when the cursor is on the file you want to open. It will go to the file and if a subsection is specified it will search for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it easier to call you could remap the function only on markdown buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! Filetype markdown nnoremap &amp;lt;buffer&amp;gt; gf :call MarkdownGF()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;" OwnerUserId="1841" LastEditorUserId="10550" LastEditDate="2020-02-08T19:48:07.967" LastActivityDate="2020-02-08T19:48:07.967" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9347" PostTypeId="1" AcceptedAnswerId="9349" CreationDate="2016-08-25T12:32:20.380" Score="3" ViewCount="440" Body="&lt;p&gt;I want to search and replace the selection I made in Visual mode. For example I have the following text:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Lorem ipsum dolor sit &lt;strong&gt;amet.&lt;/strong&gt; Consectetur adipiscing elit. Sed quis gravida lectus &lt;strong&gt;amet.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And my selection is &lt;code&gt;amet.&lt;/code&gt; I want to have this as a result:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Lorem ipsum dolor sit &lt;strong&gt;foo&lt;/strong&gt; Consectetur adipiscing elit. Sed quis gravida lectus &lt;strong&gt;foo&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is there a way to achieve this without having to manually type the &lt;code&gt;amet\.&lt;/code&gt; part in &lt;code&gt;:%s/amet\./foo/g&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8366" LastEditorUserId="8366" LastEditDate="2016-08-25T12:52:21.173" LastActivityDate="2016-08-25T22:48:22.653" Title="Search and replace a visual selection in the whole file" Tags="|visual-mode|substitute|replace|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9349" PostTypeId="2" ParentId="9347" CreationDate="2016-08-25T12:55:54.277" Score="6" Body="&lt;p&gt;You could try the yanking the visual selection before starting the ex command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y:%s/&amp;lt;c-r&amp;gt;&quot;/foo/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt;: yank the visual selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s/&lt;/code&gt;: start the ex command&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt; &lt;kbd&gt;&quot;&lt;/kbd&gt;: insert the last yanked/deleted text&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/foo/g&lt;/code&gt;: the remaining ex command&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that it won't escape the dot -- you will probably need to write a custom function to achieve that (if you intend to follow this approach, you could use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4602&quot; rel=&quot;nofollow&quot;&gt;the &quot;PatternsOnText&quot; plugin&lt;/a&gt; as a starting point).&#xA;One simple solution, using &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#/%5CV&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;\V&lt;/code&gt;&lt;/a&gt; as suggested by Kent to avoid the need to escape special characters, is the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;F4&amp;gt; y:%s/\V&amp;lt;c-r&amp;gt;&quot;//g&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are trying to reduce the number of key strokes you should consider the following (specially if you intend to change a small number of matches):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y/\V&amp;lt;c-r&amp;gt;&quot;&amp;lt;cr&amp;gt;cgnfoo&amp;lt;esc&amp;gt;..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt;: yank and exit visual selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/\V&lt;/code&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;: use the last yanked text to start a search&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cgn&lt;/code&gt;: change the next match&lt;/li&gt;&#xA;&lt;li&gt;foo&lt;kbd&gt;Esc&lt;/kbd&gt;: insert foo and exit insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt;: repeat last change&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-08-25T13:57:47.757" LastActivityDate="2016-08-25T13:57:47.757" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9350" PostTypeId="1" CreationDate="2016-08-25T19:30:58.057" Score="3" ViewCount="140" Body="&lt;p&gt;Any way to do this? I'm attaching a pic so you can see what I mean. There is one column on the left that I can't get rid of when re-sizing the split. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/w9ZYA.gif&quot; alt=&quot;a busy cat&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want the dashed bar to go all the way to the side so I can't see the tildes on the left. &lt;/p&gt;&#xA;" OwnerUserId="9002" LastEditorUserId="51" LastEditDate="2016-08-25T20:05:43.983" LastActivityDate="2016-08-25T20:05:43.983" Title="allow splits to have 0 width and height" Tags="|vim-windows|split|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9351" PostTypeId="2" ParentId="9290" CreationDate="2016-08-25T19:45:24.010" Score="0" Body="&lt;p&gt;&lt;code&gt;clang-format&lt;/code&gt; reads from stdin, so you can use &lt;code&gt;%!&lt;/code&gt; to filter the entire buffer to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! ClangFormatFile()&#xA;    silent exec &quot;:%!clang-format&quot;&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, you can still make a backup file if you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! ClangFormatFile()&#xA;    silent exec &quot;:!mv % %.old&quot;&#xA;    silent exec &quot;:%!clang-format&quot;&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The advantage of this is that it works for any buffer, including those without a filename or with unsaved content. For example, what if someone makes modifications to a buffer, &lt;em&gt;doesn't&lt;/em&gt; save, and then runs your version of &lt;code&gt;ClangFormatFile()&lt;/code&gt;? Those changes would then be lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, you should always avoid modifying files directly if possible. If a tool doesn't support this, then it's probably best to make a simple wrapper script.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-08-25T19:45:24.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9352" PostTypeId="2" ParentId="9350" CreationDate="2016-08-25T19:57:28.580" Score="3" Body="&lt;p&gt;thanks to romainl in the comments above I found the answer, just put:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set winminheight=0&#xA;set winminwidth=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9003" LastActivityDate="2016-08-25T19:57:28.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9353" PostTypeId="2" ParentId="422" CreationDate="2016-08-25T22:07:46.377" Score="38" Body="&lt;h1&gt;Highlighting tabs&lt;/h1&gt;&#xA;&lt;h2&gt;Temporary &lt;kbd&gt;Tab&lt;/kbd&gt; highlighting&lt;/h2&gt;&#xA;&lt;p&gt;For occasional use, one can simply highlight all tabs in a document using the following search &lt;code&gt;/&lt;/code&gt; command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/\t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To remove the highlighting, simply type &lt;code&gt;:noh&lt;/code&gt; which is short for &lt;code&gt;:nohlsearch&lt;/code&gt; —no high lighting.&lt;/p&gt;&#xA;&lt;h2&gt;Permanent &lt;kbd&gt;Tab&lt;/kbd&gt; highlighting&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Highlight tabs as errors.&#xA;&amp;quot; https://vi.stackexchange.com/a/9353/3168&#xA;match Error /\t/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/SfuIJ.png&quot; alt=&quot;Tab highlighting in vim&quot; /&gt;&lt;/p&gt;&#xA;&lt;h2&gt;More highlighting&lt;/h2&gt;&#xA;&lt;p&gt;For more of these useful highlighting commands —including combined with trailing whitespace and making this permanent— see the &lt;a href=&quot;http://vim.wikia.com/wiki/Highlight_unwanted_spaces&quot; rel=&quot;noreferrer&quot;&gt;Vim wiki&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-08-15T16:46:54.243" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9356" PostTypeId="1" CreationDate="2016-08-26T09:35:44.833" Score="2" ViewCount="1594" Body="&lt;p&gt;I've added the following lines to my .vimrc after reading about folding the other day (taken from vim.wikia.com):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Syntax html,python,tex setlocal foldmethod=indent&#xA;autocmd Syntax html,python,tex normal zR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wanted indented folds enabled, but to be open when I first open a file. However, when I open a python file all the folds are closed, and when I open a .tex file all the folds are open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know what the problem is here?&lt;/p&gt;&#xA;" OwnerUserId="9013" LastEditorUserId="1841" LastEditDate="2016-08-26T09:45:44.173" LastActivityDate="2016-08-26T09:45:44.173" Title="autocmd not being executed when opening file" Tags="|vimrc|autocmd|folding|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9357" PostTypeId="1" AcceptedAnswerId="9358" CreationDate="2016-08-26T14:50:49.290" Score="3" ViewCount="1779" Body="&lt;p&gt;I am looking for a way to be able to open a side pane listing the files in the current directories where the listing is sorted by modification dates. I want to be able to open the files from the listing as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the NERDTREE plugin, but I can't find a way to sort by dates. Perhaps I am missing some tricks?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is there some other plugin that can achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="9018" LastActivityDate="2016-10-31T14:00:58.377" Title="A side pane file explorer that can list files by modification dates?" Tags="|filesystem|plugin-nerdtree|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9358" PostTypeId="2" ParentId="9357" CreationDate="2016-08-26T14:55:24.903" Score="4" Body="&lt;p&gt;If you use the netrw plugin (which is included by default in recent versions), you can sort by date. Start netrw with the command &lt;code&gt;:Ex&lt;/code&gt; (or &lt;code&gt;:Vex&lt;/code&gt; to make it open as vertical split or &quot;side pane&quot; as you call it) then change the sorting order with &lt;kbd&gt;s&lt;/kbd&gt;. You may also want to see the change dates. You can see this by pressing &lt;kbd&gt;i&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-08-26T15:46:05.243" LastActivityDate="2016-08-26T15:46:05.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9359" PostTypeId="1" CreationDate="2016-08-26T15:49:52.577" Score="2" ViewCount="126" Body="&lt;p&gt;What I would like to do is issue a &lt;code&gt;raiw&lt;/code&gt; where the current word would be replaced by an &lt;code&gt;aaaaa&lt;/code&gt; word. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is a w[o]rd &amp;lt;--- cursor on []&#xA;raiw             &amp;lt;--- command&#xA;this is a aaaa   &amp;lt;--- result.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;iw&lt;/code&gt; is a motion, but it could be any motion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;a markdown recurring example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|    -  [ ]  |   &amp;lt;--- cursor on []&#xA;rai|             &amp;lt;--- command&#xA;|------------|   &amp;lt;--- result&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7010" LastEditorUserId="2920" LastEditDate="2016-08-26T16:34:23.027" LastActivityDate="2016-08-26T16:34:23.027" Title="Is there a way to make the `r` operator accept a motion?" Tags="|cursor-motions|replace|map-operator|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9360" PostTypeId="2" ParentId="9359" CreationDate="2016-08-26T16:32:44.723" Score="6" Body="&lt;p&gt;Like &lt;a href=&quot;https://vi.stackexchange.com/questions/9359/is-there-a-way-to-make-the-r-operator-accept-a-motion#comment16295_9359&quot;&gt;romainl said&lt;/a&gt;, the easiest way to that is with visual mode. However, if you absolutely want this to be an operator, you can define you own with &lt;code&gt;operatorfunc&lt;/code&gt;. From &lt;code&gt;:help opfunc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *'operatorfunc'* *'opfunc'*&#xA;'operatorfunc' 'opfunc' string  (default: empty)&#xA;            global&#xA;            {not in Vi}&#xA;    This option specifies a function to be called by the |g@| operator.&#xA;    See |:map-operator| for more info and an example.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, the way it works is you define a function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Replace(type, ...) range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;:set opfunc=Replace&lt;/code&gt;, and now the &lt;code&gt;g@&lt;/code&gt; operator will call your function like an operator. From &lt;code&gt;:help g@&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g@{motion}  Call the function set by the 'operatorfunc' option.&#xA;            The '[ mark is positioned at the start of the text&#xA;            moved over by {motion}, the '] mark on the last&#xA;            character of the text.&#xA;            The function is called with one String argument:&#xA;                &quot;line&quot;  {motion} was |linewise|&#xA;                &quot;char&quot;  {motion} was |characterwise|&#xA;                &quot;block&quot; {motion} was |blockwise-visual|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When your function is called, it will set two marks: &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt;. The first one is the start of whatever motion your function was called with, and the second was the end. Then you check the string argument to see if the motion was &lt;code&gt;linewise&lt;/code&gt;, &lt;code&gt;characterwise&lt;/code&gt;, or &lt;code&gt;blockwise&lt;/code&gt;. Then inside your function, you can use these marks to visually select whatever text you want to operate on. Putting this all together, we have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Replace(type, ...) range&#xA;  if a:0&#xA;    silent exe &quot;normal! gv&quot;&#xA;  elseif a:type == 'line'&#xA;    silent exe &quot;normal! '[V']&quot;&#xA;  else&#xA;    silent exe &quot;normal! `[v`]&quot;&#xA;  endif&#xA;&#xA;  let r = nr2char(getchar())&#xA;  silent exe &quot;normal! r&quot;.r&#xA;endfunction&#xA;&#xA;nnoremap r :set opfunc=Replace&amp;lt;cr&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's worth noting that the order of keystrokes is reversed from what you described, e.g. rather than &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;raiw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you would have to press&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;riwa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tested this, and it &lt;em&gt;sort of&lt;/em&gt; works with the dot operator, but you still have to enter the character you would like to replace the motion with. With some more hacking, and possibly with &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;tpope/vim-repeat&lt;/a&gt;, you might be able to figure out the rest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps!&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-08-26T16:32:44.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9361" PostTypeId="5" CreationDate="2016-08-26T16:39:11.130" Score="0" Body="&lt;p&gt;Vim allows you to create custom operators. From &lt;code&gt;:help :map-operator&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.11 MAPPING AN OPERATOR                *:map-operator*&#xA;&#xA;An operator is used before a {motion} command.  To define your own operator&#xA;you must create mapping that first sets the 'operatorfunc' option and then&#xA;invoke the |g@| operator.  After the user types the {motion} command the&#xA;specified function will be called.&#xA;&#xA;                            *g@* *E774* *E775*&#xA;g@{motion}      Call the function set by the 'operatorfunc' option.&#xA;            The '[ mark is positioned at the start of the text&#xA;            moved over by {motion}, the '] mark on the last&#xA;            character of the text.&#xA;            The function is called with one String argument:&#xA;                &quot;line&quot;  {motion} was |linewise|&#xA;                &quot;char&quot;  {motion} was |characterwise|&#xA;                &quot;block&quot; {motion} was |blockwise-visual|&#xA;            Although &quot;block&quot; would rarely appear, since it can&#xA;            only result from Visual mode where &quot;g@&quot; is not useful.&#xA;            {not available when compiled without the |+eval|&#xA;            feature}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The basic usage is to define a function, and the map your desired keystroke to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set opfunc=MyCustomFunc&amp;lt;cr&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;g@&lt;/code&gt; operator will call whatever function you have bound to &lt;code&gt;opfunc&lt;/code&gt;, and set some marks to allow you to define how your operator should behave.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-08-26T16:54:41.133" LastActivityDate="2016-08-26T16:54:41.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9362" PostTypeId="4" CreationDate="2016-08-26T16:39:11.130" Score="0" Body="Use this tag for questions about creating your own operator within vim." OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-08-26T16:54:36.637" LastActivityDate="2016-08-26T16:54:36.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9363" PostTypeId="1" AcceptedAnswerId="9364" CreationDate="2016-08-26T18:49:38.923" Score="5" ViewCount="921" Body="&lt;p&gt;Suppose I open multiple files in &lt;code&gt;vim&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim a.cc b.cc x.cc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim&lt;/code&gt; will open all files, but show only one at a time, the rest being accessible using the &lt;code&gt;:next&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After having these files opened, how to spread them into a split view, like if I had used the &lt;code&gt;-O&lt;/code&gt; flag when opening them? Also, it would be nice to know how can I spread them into tabs too.&lt;/p&gt;&#xA;" OwnerUserId="4963" LastEditorUserId="4963" LastEditDate="2016-08-26T20:43:28.987" LastActivityDate="2016-08-26T20:43:28.987" Title="Spread already open files into split view" Tags="|buffers|split|multiple-files|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9364" PostTypeId="2" ParentId="9363" CreationDate="2016-08-26T19:23:52.357" Score="8" Body="&lt;p&gt;Here are a bunch of helpful commands for you:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To open every buffer in a horizontal split:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sball&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To open every buffer in a &lt;em&gt;vertical&lt;/em&gt; split:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vert sball&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can do the same thing with tabs, e.g, to open every buffer into its own tab:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo tab split&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you would like more control over how they get split, you can do this individually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, list every open buffer with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can choose what to do for each buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To open buffer &lt;strong&gt;N&lt;/strong&gt; in a horizontal split:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sb N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;sb is an abbreviation of &lt;code&gt;:sbuffer&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To open buffer &lt;strong&gt;N&lt;/strong&gt; in a vertical split:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vert sb N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To open buffer &lt;strong&gt;N&lt;/strong&gt; in a new tab:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabedit | bN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-08-26T20:35:07.683" LastActivityDate="2016-08-26T20:35:07.683" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9365" PostTypeId="1" CreationDate="2016-08-26T21:35:38.370" Score="1" ViewCount="384" Body="&lt;p&gt;I mapped my capslock key to escape but sometimes I accidentally press capslock when I meant to press shift.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I remap &lt;code&gt;&amp;lt;Esc&amp;gt;+key&lt;/code&gt; to send me back to insert mode and insert the proper character?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I would like to press &lt;code&gt;&amp;lt;Esc&amp;gt;+9&lt;/code&gt; and be put back into insert mode and insert the &lt;code&gt;(&lt;/code&gt; character (as if I had just pressed &lt;code&gt;&amp;lt;Shift&amp;gt;+9&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possible?&lt;/p&gt;&#xA;" OwnerUserId="9023" LastActivityDate="2016-08-29T16:16:03.883" Title="Mapping Esc+key (hold down escape and press another key to perform action)" Tags="|key-bindings|" AnswerCount="1" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9366" PostTypeId="1" AcceptedAnswerId="9367" CreationDate="2016-08-26T21:55:27.873" Score="13" ViewCount="7424" Body="&lt;p&gt;Vim automatically continues a comment when I press Enter in Insert mode, which I find helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I do not want the comment continued after pressing 'o' from normal mode to insert a new line below the end of the comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read that I need to remove the option &lt;code&gt;o&lt;/code&gt; from my &lt;code&gt;formatoptions&lt;/code&gt;, so I put this line right at the end of my vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set formatoptions-=o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it has changed nothing, and when I execute &lt;code&gt;:set formatoptions&lt;/code&gt; from iside of vim it shows me my formatoptions are &lt;code&gt;croql&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get rid of the 'o'?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Edit:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I've followed some steps pointed out in the comments by Sato Katsura:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The solution starts with running &lt;code&gt;:verb set fo&lt;/code&gt; to see where formatoptions was last modified. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here's the output to &lt;code&gt;verb set fo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  formatoptions=croql&#xA;        Last set from /usr/share/vim/vim73/ftplugin/vim.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="9024" LastEditDate="2016-08-27T09:03:22.103" LastActivityDate="2020-04-27T07:47:50.787" Title="set formatoptions in vimrc is being ignored" Tags="|vimrc|formatting|" AnswerCount="5" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9367" PostTypeId="2" ParentId="9366" CreationDate="2016-08-26T22:14:05.647" Score="3" Body="&lt;p&gt;I found out that I can provide a makeshift solution using an autocommand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following line in your &lt;code&gt;.vimrc&lt;/code&gt; file should apply the new formatoptions everywhere:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType * set formatoptions-=o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this doesn't really get to solving the problem; I still don't understand why a simple &lt;code&gt;set&lt;/code&gt; wasn't enough, and as has been pointed out in the comments this solution is not ideal.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="9024" LastEditDate="2016-08-27T09:05:52.017" LastActivityDate="2016-08-27T09:05:52.017" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="9368" PostTypeId="1" AcceptedAnswerId="9371" CreationDate="2016-08-27T05:59:50.597" Score="0" ViewCount="104" Body="&lt;p&gt;In vim you can do &lt;code&gt;daw&lt;/code&gt; to delete the entire word, but it also removes the space after the word, (&lt;code&gt;caw&lt;/code&gt; too).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to operate on the entire word without effecting the space around it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a d c&#xA;  ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Performing &lt;code&gt;caw&lt;/code&gt; -&gt; &lt;code&gt;b&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gives us:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a bc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way spaces can be treated as other delimiters, brackets for eg, which would give us:&lt;br&gt; &lt;code&gt;a b c&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;While this isn't what you would do as a user, it makes writing macros more difficult, since surrounding delimiters aren't as predictable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, this is quite similar to this question, but not identical since the word may be surrounded by tabs or other delimiters.&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/1607904/vim-deleting-from-current-position-until-a-space&quot;&gt;https://stackoverflow.com/questions/1607904/vim-deleting-from-current-position-until-a-space&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-08-27T06:40:52.397" Title="How to operate on all of a word without its surrounding space?" Tags="|cut-copy-paste|cursor-motions|whitespace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9370" PostTypeId="2" ParentId="422" CreationDate="2016-08-27T06:14:11.233" Score="5" Body="&lt;p&gt;You may want to show tabs differently in a regular terminal and gvim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list!&#xA;if has('gui_running')&#xA;    set listchars=tab:▶\ ,trail:·,extends:\#,nbsp:.&#xA;else&#xA;    set listchars=tab:&amp;gt;.,trail:.,extends:\#,nbsp:.&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Adding for completeness, in case others find it useful).&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2016-08-27T06:14:11.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9371" PostTypeId="2" ParentId="9368" CreationDate="2016-08-27T06:37:18.443" Score="3" Body="&lt;p&gt;Yes, you can use the &lt;code&gt;iw&lt;/code&gt; object. For example, &lt;code&gt;diw&lt;/code&gt; or &lt;code&gt;ciw&lt;/code&gt; etc. You can read more about the various text objects available to you &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#object-select&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this particular case, rather than &lt;code&gt;ciw&lt;/code&gt;, you could just use &lt;code&gt;cw&lt;/code&gt;, since it happens to be equivalent to &lt;code&gt;ce&lt;/code&gt;. This is a special case, since for example &lt;code&gt;dw&lt;/code&gt; &lt;em&gt;would&lt;/em&gt; delete the extra space. You can read more about this behavior &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#WORD&quot; rel=&quot;nofollow&quot;&gt;here in the documentation&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-08-27T06:40:52.397" LastActivityDate="2016-08-27T06:40:52.397" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9372" PostTypeId="1" AcceptedAnswerId="9377" CreationDate="2016-08-27T16:50:32.420" Score="8" ViewCount="1079" Body="&lt;p&gt;For easy horizontal scrolling in long lines, I use these mappings that work well for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;m-[&amp;gt; 20zh&#xA;map &amp;lt;m-]&amp;gt; 20zl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Something that has always annoyed me is when the following use case happens (&lt;code&gt;|&lt;/code&gt; is the current cursor position):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some |short line&#xA;some other line&#xA;some other line&#xA;some other line&#xA;some other line&#xA;some other line&#xA;some veeeeeeeeeeeeeeeeeeeeeeeeery looooooooooooooooooooooooong liiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sometimes I want to scroll horizontally and have a quick peek at the very long line just to see if there is anything interesting in there. In GUI text editors, I would just horizontally scroll with my mouse, and scroll back. In Vim, if I try to scroll with &lt;code&gt;zl&lt;/code&gt;, here is what happens:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;..me short line|&#xA;..me other line&#xA;..me other line&#xA;..me other line&#xA;..me other line&#xA;..me other line&#xA;..me veeeeeeeeeeeeeeeeeeeeeeeeery looooooooooooooooooooooooong liiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can slightly scroll for a bit (as visually demonstrated by the &lt;code&gt;..&lt;/code&gt; above), but then the cursor is blocked at the end of the short line. I have to explicitly position my cursor on the very long line to be able to scroll again, which is very annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an interesting half-solution to my problem: &lt;code&gt;:set virtualedit=all&lt;/code&gt;. It frees the cursor of any line-limit. Hitting &lt;code&gt;zl&lt;/code&gt; a few times on the above example now works as I want (notice the &quot;free&quot; cursor below):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;..ine          |&#xA;..ine&#xA;..ine&#xA;..ine&#xA;..ine&#xA;..ine&#xA;..ooooooooooooooong liiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I only need &lt;code&gt;virtualedit=all&lt;/code&gt; for this specific use case though. Otherwise I want the cursor to behave normally and restore the option to the default &lt;code&gt;virtualedit=&lt;/code&gt;. And I do not want to do this manually, it should be automatic: when I start scrolling right, I want it on. When I scroll left, I still need it on &lt;strong&gt;except&lt;/strong&gt; when the first characters of the lines in the file become visible again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am thinking about something along those lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;m-[&amp;gt; :SOME_VOODOO_VIMSCRIPT_MAGIC&amp;lt;cr&amp;gt;20zh&#xA;map &amp;lt;m-]&amp;gt; :set virtualedit=all&amp;lt;cr&amp;gt;20zl&#xA;noremap ^ :set virtualedit=&amp;lt;cr&amp;gt;^&#xA;noremap $ :set virtualedit=&amp;lt;cr&amp;gt;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea about what to do for the &lt;code&gt;SOME_VOODOO_VIMSCRIPT_MAGIC&lt;/code&gt; part? Getting the absolute column position for the first visible left character could help, although I do not know how to do this in Vimscript (&lt;code&gt;col&lt;/code&gt; does not seem to do what I want). Alternate ways of solving my problems are welcome too (I just don't want any line-wrapping).&lt;/p&gt;&#xA;" OwnerUserId="7318" LastEditorUserId="7318" LastEditDate="2016-08-27T17:23:57.973" LastActivityDate="2020-07-03T03:54:48.393" Title="How to make horizontal scrolling easier when the cursor is not ideally located?" Tags="|vimrc|scrolling|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9374" PostTypeId="2" ParentId="5696" CreationDate="2016-08-27T21:48:02.093" Score="2" Body="&lt;p&gt;Based on the &lt;a href=&quot;https://vi.stackexchange.com/users/6324/pepper-chico&quot;&gt;discussion I've started&lt;/a&gt; in the comments section of the Christian Brabandt answer, I'll leave here this alternative solution for anyone interested in a filetype specific approach:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set conceallevel=2&#xA;au FileType purescript set concealcursor=vin&#xA;au WinEnter,BufEnter,BufRead,FileType,Colorscheme *&#xA;    \ if exists('w:lambda_conceal')                                                                  |&#xA;    \     call matchdelete(w:lambda_conceal)                                                         |&#xA;    \     unlet w:lambda_conceal                                                                     |&#xA;    \ endif                                                                                          |&#xA;    \ if &amp;amp;ft == 'purescript'                                                                         |&#xA;    \     let w:lambda_conceal = matchadd('Conceal', '\\\%([^\\]\+→\)\@=', 10, -1, {'conceal': 'λ'}) |&#xA;    \     hi! link Conceal Operator                                                                  |&#xA;    \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The previous sample will conceal &lt;code&gt;\&lt;/code&gt; with &lt;code&gt;λ&lt;/code&gt; in the Purescript filetype solely, constrained to anonymous lambdas and if there's a &lt;code&gt;→&lt;/code&gt; character present afterwards. It also links the &lt;code&gt;Conceal&lt;/code&gt; highlighting group with the &lt;code&gt;Operator&lt;/code&gt; group so that it looks like an operator.&lt;/p&gt;&#xA;" OwnerUserId="6324" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-09-14T19:28:33.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9375" PostTypeId="1" AcceptedAnswerId="9376" CreationDate="2016-08-28T00:27:19.867" Score="6" ViewCount="423" Body="&lt;p&gt;I have a file with the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I start a macro (&lt;kbd&gt;qq&lt;/kbd&gt;), yank this line (&lt;kbd&gt;Y&lt;/kbd&gt;), paste it (&lt;kbd&gt;p&lt;/kbd&gt;), increase the number by four (&lt;kbd&gt;4&lt;/kbd&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;), end the macro (&lt;kbd&gt;q&lt;/kbd&gt;), and execute this macro nine times (&lt;kbd&gt;9&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;), then I end up with following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;001&#xA;005&#xA;011&#xA;015&#xA;021&#xA;025&#xA;031&#xA;035&#xA;041&#xA;045&#xA;051&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How does this work? I mean why is the third number six (&lt;code&gt;001&lt;/code&gt; + &lt;code&gt;005&lt;/code&gt;) digits larger than second number? Or fifth number six digits larger than fourth number, etc.?&lt;/p&gt;&#xA;" OwnerUserId="8626" LastEditorUserId="927" LastEditDate="2016-08-28T12:18:18.263" LastActivityDate="2016-08-28T12:18:18.263" Title="Understand addition on numbers in Vim" Tags="|number-formatting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9376" PostTypeId="2" ParentId="9375" CreationDate="2016-08-28T01:08:47.570" Score="10" Body="&lt;p&gt;If the number starts with a &lt;code&gt;0&lt;/code&gt; it's interpreted as an octal number (base-8, instead of base-10). Vim also recognises hexadecimal numbers (base-16) if it starts with &lt;code&gt;0x&lt;/code&gt; and binary numbers (base-2) if it starts with &lt;code&gt;0b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27nrformats%27&quot;&gt;&lt;code&gt;'nrformats'&lt;/code&gt;&lt;/a&gt; setting to control which numbers Vim recognises; IMHO a value of &lt;code&gt;bin,hex&lt;/code&gt; makes the most sense, as it's not easy to confuse a hex or binary in those formats with a regular base-10 number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see the paragraphs below &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#v_g_CTRL%2dX&quot;&gt;&lt;code&gt;:help v_g_CTRL-X&lt;/code&gt;&lt;/a&gt; (no direct help tag).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-08-28T01:08:47.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9377" PostTypeId="2" ParentId="9372" CreationDate="2016-08-28T11:22:34.573" Score="2" Body="&lt;p&gt;I eventually came up with this solution (edited with @Rich's answer to remove an unnecessary former Python dependency).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;m-[&amp;gt; 20zh:call SetVirtualEdit()&amp;lt;cr&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;m-]&amp;gt; :set virtualedit=all&amp;lt;cr&amp;gt;20zl&#xA;noremap &amp;lt;silent&amp;gt; ^ :set virtualedit=&amp;lt;cr&amp;gt;^&#xA;noremap &amp;lt;silent&amp;gt; $ :set virtualedit=&amp;lt;cr&amp;gt;$&#xA;&#xA;function! SetVirtualEdit()&#xA;  let saved_view = winsaveview()&#xA;  keepjumps normal! g0&#xA;  let is_on_leftmost_screen = col('.') == 1&#xA;  call winrestview(saved_view)&#xA;&#xA;  if is_on_leftmost_screen&#xA;    set virtualedit=&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7318" LastEditorUserId="7318" LastEditDate="2020-07-03T03:54:48.393" LastActivityDate="2020-07-03T03:54:48.393" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9378" PostTypeId="2" ParentId="6879" CreationDate="2016-08-28T18:39:56.747" Score="4" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/vim-jp/vim-cpp/commits/master&quot; rel=&quot;nofollow&quot;&gt;vim-jp/vim-cpp&lt;/a&gt; repo included &lt;a href=&quot;https://github.com/vim-jp/vim-cpp/commit/fa51a85b963c1d200404d11899b3a740f857bb15&quot; rel=&quot;nofollow&quot;&gt;this change&lt;/a&gt; in July 2016:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match   cNumber     display contained &quot;\d\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\&amp;gt;&quot;&#xA;syn match   cNumber     display contained &quot;0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\&amp;gt;&quot;&#xA;syn match   cNumber     display contained &quot;0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't want to use this repo, you can add these lines to &lt;code&gt;~/.vim/syntax/cpp.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-08-30T10:02:16.430" LastActivityDate="2016-08-30T10:02:16.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9379" PostTypeId="2" ParentId="6691" CreationDate="2016-08-28T19:25:26.163" Score="2" Body="&lt;p&gt;You can automatically replace a space with &lt;code&gt;\_s&lt;/code&gt; when searching with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;Space&amp;gt; index(['/', '?'], getcmdtype()) &amp;gt; -1 ? '\_s' : ' '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because &lt;code&gt;cnoremap&lt;/code&gt; is applied to all the commandline (and not just search), we need an expression mapping to check if we're searching or in another commandline mode (e.g. &lt;code&gt;:&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Because you probably don't &lt;em&gt;always&lt;/em&gt; want to search like this, you can trigger this newline-insensitive mode with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! StartNewlineSearch()&#xA;    cnoremap &amp;lt;expr&amp;gt; &amp;lt;Space&amp;gt; index(['/', '?'], getcmdtype()) &amp;gt; -1 ? '\_s' : ' '&#xA;&#xA;    &quot; Unmap both &amp;lt;Space&amp;gt; and this same mapping when pressing &amp;lt;CR&amp;gt;&#xA;    cnoremap &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;:cunmap &amp;lt;lt&amp;gt;Space&amp;gt;&amp;lt;CR&amp;gt;:cunmap &amp;lt;lt&amp;gt;CR&amp;gt;&amp;lt;CR&amp;gt;:cunmap &amp;lt;lt&amp;gt;Esc&amp;gt;&amp;lt;CR&amp;gt;&#xA;&#xA;    &quot; And the same for &amp;lt;Esc&amp;gt;&#xA;    cnoremap &amp;lt;Esc&amp;gt; &amp;lt;Esc&amp;gt;:cunmap &amp;lt;lt&amp;gt;Space&amp;gt;&amp;lt;CR&amp;gt;:cunmap &amp;lt;lt&amp;gt;CR&amp;gt;&amp;lt;CR&amp;gt;:cunmap &amp;lt;lt&amp;gt;Esc&amp;gt;&amp;lt;CR&amp;gt;&#xA;endfun&#xA;&#xA;nnoremap // :call StartNewlineSearch()&amp;lt;CR&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When pressing &lt;code&gt;//&lt;/code&gt; it maps &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; to &lt;code&gt;\_s&lt;/code&gt;, and it unmaps it when pressing &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could also map this to a key to toggle the two &quot;modes&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:search_mode = 0&#xA;fun! ToggleMode()&#xA;    if g:search_mode == 0&#xA;        cnoremap &amp;lt;expr&amp;gt; &amp;lt;Space&amp;gt; index(['/', '?'], getcmdtype()) &amp;gt; -1 ? '\_s' : ' '&#xA;        let g:search_mode = 1&#xA;    else&#xA;        cunmap &amp;lt;Space&amp;gt;&#xA;        let g:search_mode = 0&#xA;    endif&#xA;    return getcmdline()&#xA;endfun&#xA;&#xA;cnoremap &amp;lt;C-@&amp;gt; &amp;lt;C-\&amp;gt;eToggleMode()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-08-28T19:25:26.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9380" PostTypeId="2" ParentId="4038" CreationDate="2016-08-28T19:53:26.133" Score="6" Body="&lt;p&gt;When writing a buffer Vim will create a temporary file which it will &lt;code&gt;fchown()&lt;/code&gt; to verify it has permission to create files in this directory; simplified version from &lt;code&gt;buf_write()&lt;/code&gt; in &lt;code&gt;src/fileio.c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * Check if we can create a file and set the owner/group to&#xA; * the ones from the original file.&#xA; * First find a file name that doesn't exist yet (use some&#xA; * arbitrary numbers).&#xA; */&#xA;STRCPY(IObuff, fname);&#xA;for (i = 4913; ; i += 123)&#xA;{&#xA;    sprintf((char *)gettail(IObuff), &quot;%d&quot;, i);&#xA;    if (mch_lstat((char *)IObuff, &amp;amp;st) &amp;lt; 0)&#xA;        break;&#xA;}&#xA;fd = mch_open((char *)IObuff,&#xA;                    O_CREAT|O_WRONLY|O_EXCL|O_NOFOLLOW, perm);&#xA;if (fd &amp;lt; 0)     /* can't write in directory */&#xA;    backup_copy = TRUE;&#xA;else&#xA;{&#xA;&#xA;    ignored = fchown(fd, st_old.st_uid, st_old.st_gid);&#xA;    if (mch_stat((char *)IObuff, &amp;amp;st) &amp;lt; 0&#xA;            || st.st_uid != st_old.st_uid&#xA;            || st.st_gid != st_old.st_gid&#xA;            || (long)st.st_mode != perm)&#xA;        backup_copy = TRUE;&#xA;    /* Close the file before removing it, on MS-Windows we&#xA;     * can't delete an open file. */&#xA;    close(fd);&#xA;    mch_remove(IObuff);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it will first try &lt;code&gt;4913&lt;/code&gt;, and it will keep increment it with &lt;code&gt;123&lt;/code&gt; until we find a filename that doesn't exist yet. Why &lt;code&gt;4913&lt;/code&gt; and not &lt;code&gt;4912&lt;/code&gt; or &lt;code&gt;4914&lt;/code&gt;? I have no idea. It could be that the number is truly arbitrary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code is only run if the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27backupcopy%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'backupcopy'&lt;/code&gt;&lt;/a&gt; setting is set to &lt;code&gt;auto&lt;/code&gt;; from the help page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The main values are:&#xA;&quot;yes&quot;   make a copy of the file and overwrite the original one&#xA;&quot;no&quot;    rename the file and write a new one&#xA;&quot;auto&quot;  one of the previous, what works best&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's used to help determine which value to use (hence the setting of &lt;code&gt;backup_copy = TRUE&lt;/code&gt; in the above code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;compatible&quot; vi default for &lt;code&gt;backupcopy&lt;/code&gt; is &lt;code&gt;yes&lt;/code&gt;, while the &quot;non-compatible&quot; Vim default is &lt;code&gt;auto&lt;/code&gt;; when setting &lt;code&gt;compatible&lt;/code&gt; Vim will reset various settings back to the Vi or Vim defaults:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set compatible&#xA;:set backupcopy?&#xA;  backupcopy=yes&#xA;&#xA;:set nocompatible&#xA;:set backupcopy?&#xA;  backupcopy=auto&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-08-28T19:53:26.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9381" PostTypeId="1" CreationDate="2016-08-28T20:23:40.777" Score="2" ViewCount="389" Body="&lt;p&gt;In my .vimrc i have added this line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it only displays the line number for the lines that exist in the buffer, and not beyond this; after this it just shows &lt;code&gt;~&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I show line numbers for the entire visual area?&lt;/p&gt;&#xA;" OwnerUserId="9004" LastEditorUserId="51" LastEditDate="2016-08-28T20:28:55.100" LastActivityDate="2016-08-29T07:08:40.307" Title="How to display all line numbers in Vim?" Tags="|line-numbers|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9382" PostTypeId="1" AcceptedAnswerId="9385" CreationDate="2016-08-28T20:27:50.883" Score="2" ViewCount="544" Body="&lt;p&gt;The arrow keys can easily be enhanced and I would like to add the &quot;bubble&quot; feature for all modes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to use the &lt;code&gt;&amp;lt;C-Up/Down&amp;gt;&lt;/code&gt; to take the line and move it along the text and preserve the cursor position. If possible I also would like the &lt;code&gt;cut&lt;/code&gt; with &lt;code&gt;dd&lt;/code&gt; to not alter the yank registers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following works great in normal and visual mode, but not in insertion where  I obviously need some help: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-Up&amp;gt; ddkP&#xA;nmap &amp;lt;C-Down&amp;gt; ddp&#xA;imap &amp;lt;C-Up&amp;gt;   &amp;lt;C-C&amp;gt;:call BubbleUp()&amp;lt;cr&amp;gt;&#xA;imap &amp;lt;C-Down&amp;gt; &amp;lt;C-C&amp;gt;:call BubbleDown()&amp;lt;cr&amp;gt;&#xA;vmap &amp;lt;C-Up&amp;gt; xkP`[V`]&#xA;vmap &amp;lt;C-Down&amp;gt; xp`[V`]&#xA;&#xA;function! BubbleUp()&#xA;        let l:col = virtcol('.') + 2&#xA;        normal! ddkP&#xA;        execute 'normal! '.l:col.'|i'&#xA;endfunction&#xA;&#xA;function! BubbleDown()&#xA;        let l:col = virtcol('.') + 2&#xA;        normal! ddp&#xA;        execute 'normal! '.l:col.'|i'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2548" LastActivityDate="2016-08-29T15:21:25.960" Title="Bubble line Up/Down in any modes" Tags="|key-bindings|vimscript|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9385" PostTypeId="2" ParentId="9382" CreationDate="2016-08-29T09:21:48.037" Score="4" Body="&lt;p&gt;Here's a trick I picked up a long time ago:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;M-c&amp;gt;  @='&quot;zyy&quot;zp'&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;M-c&amp;gt;  @='&quot;zy&quot;zPgv'&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;M-j&amp;gt;  @='&quot;zdd&quot;zp'&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;M-j&amp;gt;  @='&quot;zx&quot;zp`[V`]'&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;M-k&amp;gt;  @='k&quot;zdd&quot;zpk'&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;M-k&amp;gt;  @='&quot;zxk&quot;zP`[V`]'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The point of &lt;code&gt;@='...'&lt;/code&gt; is to allow these macros to be given &lt;em&gt;counts&lt;/em&gt;, so that I can f.i. mark a few lines, then press &lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;Alt-j&lt;/kbd&gt; and move the entire block 3 lines down.  The &lt;kbd&gt;Alt-c&lt;/kbd&gt; combinations copies lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;But these don't preserve cursor position&quot;.  Yes: adding that part would leave you with nothing to do. :)&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-08-29T09:21:48.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9386" PostTypeId="1" AcceptedAnswerId="9389" CreationDate="2016-08-29T12:06:35.807" Score="18" ViewCount="2434" Body="&lt;p&gt;We all know that, when searching, &lt;code&gt;\n&lt;/code&gt; is newline and &lt;code&gt;\r&lt;/code&gt; is carriage return (&lt;code&gt;^M&lt;/code&gt;), but when replacing &lt;code&gt;\r&lt;/code&gt; is newline while &lt;code&gt;\n&lt;/code&gt; is a null byte (&lt;code&gt;^@&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the origin of this asymmetry? Given that this behavior is... peculiar to say the least (and quite counterproductive when you get it wrong the first time) I expect there's some bizarre historical reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(incidentally, is there some way to &quot;fix&quot; this behavior and get something more intuitive?)&lt;/p&gt;&#xA;" OwnerUserId="794" LastEditorUserId="51" LastEditDate="2016-08-29T14:59:13.677" LastActivityDate="2016-10-10T00:44:53.977" Title="What is the rationale for \r and \n meaning different things in s command?" Tags="|regular-expression|substitute|whitespace|history-of|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9387" PostTypeId="1" AcceptedAnswerId="13801" CreationDate="2016-08-29T14:03:11.113" Score="21" ViewCount="1282" Body="&lt;p&gt;When I edit a PHP file and I define a string in a heredoc, syntax highlighting will be enabled inside the heredoc if it is JavaScript syntax or HTML syntax or SQL syntax. However it will not work for CSS syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example (if we create a new PHP file called &lt;code&gt;hello.php&lt;/code&gt; with the following code):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;?php&#xA;$foo = &amp;lt;&amp;lt;&amp;lt;&quot;JAVASCRIPT&quot;&#xA;var hello = &quot;hello&quot;;&#xA;JAVASCRIPT;&#xA;&#xA;$bar = &amp;lt;&amp;lt;&amp;lt;&quot;CSS&quot;&#xA;/* This code below should be syntax-highlighted. */&#xA;.hello {&#xA;  font-weight: bold;&#xA;}&#xA;CSS;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;JAVASCRIPT&lt;/code&gt; block is highlighted correctly, but the &lt;code&gt;CSS&lt;/code&gt; block is not. Also, if I run &lt;code&gt;SynStack&lt;/code&gt; on the &lt;code&gt;var&lt;/code&gt; keyword on the JavaScript code block, I get &lt;code&gt;['phpRegion', 'phpHereDoc', 'javaScriptIdentifier']&lt;/code&gt;, but if I do the same to any place in the CSS block, I only get &lt;code&gt;['phpRegion', 'phpHereDoc']&lt;/code&gt;, so I need to add some CSS syntax highlighting rules. Where are these syntax rules getting defined, and how do I add to them?&lt;/p&gt;&#xA;" OwnerUserId="9047" LastEditorUserId="9047" LastEditDate="2017-04-10T13:41:23.063" LastActivityDate="2017-10-05T10:41:01.787" Title="How do I enable language-specific syntax inside a heredoc?" Tags="|syntax-highlighting|filetype-php|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9388" PostTypeId="2" ParentId="9382" CreationDate="2016-08-29T15:21:25.960" Score="1" Body="&lt;p&gt;Both Tim Pope's &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1590&quot; rel=&quot;nofollow&quot;&gt;unimpaired plugin&lt;/a&gt; and my own &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4140&quot; rel=&quot;nofollow&quot;&gt;LineJuggler plugin&lt;/a&gt; offer normal and visual mode mappings for this (and many more); you may want to take a look at the implementations, or use one of the plugins for a robust solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason that neither offers insert mode mappings is that this undermines the very power of Vim; its modality. Shuffling lines around is not inserting, it's editing, so you should (briefly) leave insert mode for that. Create an environment that makes this comfortable and quick; many people remap the &lt;kbd&gt;Escape&lt;/kbd&gt; key. Don't work against the powerful Vim modes!&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-08-29T15:21:25.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9389" PostTypeId="2" ParentId="9386" CreationDate="2016-08-29T15:23:59.200" Score="15" Body="&lt;p&gt;At the most basic level, there's already an asymmetry between the search and replace portions of &lt;code&gt;:substitute&lt;/code&gt; because the former is a regular expression and the latter is text, with specific additional &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-special&quot; rel=&quot;noreferrer&quot;&gt;escape sequences&lt;/a&gt;.  This is just highlighted by the intuition you have about what &lt;code&gt;\n&lt;/code&gt; means.&lt;/p&gt;&#xA;&lt;p&gt;For example, consider that &lt;code&gt;\n&lt;/code&gt; in the search doesn't match a literal &lt;code&gt;\n&lt;/code&gt;.  It matches the end of line (EOL) byte sequence, which may be &lt;code&gt;\r&lt;/code&gt;, &lt;code&gt;\r\n&lt;/code&gt;, or just &lt;code&gt;\n&lt;/code&gt; depending on the &lt;code&gt;'fileformat'&lt;/code&gt; of the buffer.&lt;/p&gt;&#xA;&lt;p&gt;As far as why &lt;code&gt;\r&lt;/code&gt; is used to mean &amp;quot;insert an EOL&amp;quot;, there's some &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#NL-used-for-Nul&quot; rel=&quot;noreferrer&quot;&gt;history&lt;/a&gt; behind that.  Vi had no way to handle a NUL byte in a file.  Vim improved on that by replacing NUL bytes with an NL byte internally (since C strings are NUL delimited).&lt;/p&gt;&#xA;&lt;p&gt;This implementation detail leaked into the behavior of &lt;code&gt;:substitute&lt;/code&gt; since &lt;code&gt;\n&lt;/code&gt; in the replacement is simply inserted into the internal representation of that line, which is used to indicate a NUL byte.  &lt;code&gt;\r&lt;/code&gt; inserts an EOL, breaking the internal line in two.  Vim doesn't actually store the EOL bytes in memory, instead (de)serializing them when reading/writing the buffer.&lt;/p&gt;&#xA;&lt;p&gt;It can't be changed now without breaking the many scripts and the muscle memory of many users.  Thankfully, it's documented in &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-special&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help sub-replace-special&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-10-10T00:44:53.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9390" PostTypeId="2" ParentId="9365" CreationDate="2016-08-29T16:16:03.883" Score="3" Body="&lt;p&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; is not a modifier like &lt;kbd&gt;Shift&lt;/kbd&gt;. There's no &lt;code&gt;&amp;lt;Esc-9&amp;gt;&lt;/code&gt; keycode, only &lt;code&gt;&amp;lt;S-9&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you usually press Shift &lt;em&gt;before&lt;/em&gt; the other key, you could approach this via a set of sequential mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;Esc&amp;gt;9 (&#xA;:inoremap &amp;lt;Esc&amp;gt;0 )&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that would introduce a noticeable delay when you really just want to leave insert mode.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-08-29T16:16:03.883" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9391" PostTypeId="2" ParentId="9386" CreationDate="2016-08-29T16:39:12.017" Score="6" Body="&lt;p&gt;A &lt;code&gt;NUL&lt;/code&gt; byte is a string terminator in C, and for this reason Vim uses this convention, described in the manual at &lt;code&gt;:h NL-used-for-Nul&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&amp;lt;Nul&gt; characters in the file are stored as &amp;lt;NL&gt; in memory.  In the display they are shown as &quot;^@&quot;.  The translation is done when reading and writing files.  To match a &amp;lt;Nul&gt; with a search pattern you can just enter CTRL-@ or &quot;CTRL-V 000&quot;.  This is probably just what you expect.  Internally the character is replaced with a &amp;lt;NL&gt; in the search pattern.  What is unusual is that typing CTRL-V CTRL-J also inserts a &amp;lt;NL&gt;, thus also searches for a &amp;lt;Nul&gt; in the file. {Vi cannot handle &amp;lt;Nul&gt; characters in the file at all}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This convention has spilled over to the &lt;code&gt;:s/.../.../&lt;/code&gt; command, but not to the &lt;code&gt;substitute()&lt;/code&gt; function.  &lt;code&gt;\r&lt;/code&gt; and &lt;code&gt;\n&lt;/code&gt; in replacement strings in &lt;code&gt;substitute()&lt;/code&gt; calls keep their original meaning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think there are deeper reasons for either behaviour.  Vim has simply evolved organically from the original &lt;code&gt;vi&lt;/code&gt;.  There never was any big blueprint for it, features were just piled on top of each other, with relatively little effort to keep them organized.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-08-29T16:39:12.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9393" PostTypeId="1" AcceptedAnswerId="9395" CreationDate="2016-08-29T17:18:41.933" Score="1" ViewCount="984" Body="&lt;p&gt;I have a following very simple &lt;code&gt;.vimrc&lt;/code&gt; file based on an example in &lt;a href=&quot;https://pragprog.com/book/dnvim2/practical-vim-second-edition&quot; rel=&quot;nofollow&quot;&gt;Practical Vim&lt;/a&gt; book:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set hidden&#xA;if has(&quot;autocmd&quot;)&#xA;  filetype on&#xA;  autocmd FileType sh setlocal ts=2 sts=2 sw=2 expandtab&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As I understand, if file is a shell script file, then &lt;code&gt;FileType&lt;/code&gt; event happens, if condition is started and &lt;code&gt;setlocal ts=2 sts=2 sw=2 expandtab&lt;/code&gt; command is executed? However, what is the point of keeping the &lt;code&gt;filetype on&lt;/code&gt;(&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/filetype.html#filetypes&quot; rel=&quot;nofollow&quot;&gt;enables file type detection&lt;/a&gt;) inside the &lt;code&gt;if&lt;/code&gt; statement? Shouldn't this be outside and before the &lt;code&gt;if&lt;/code&gt; statement?&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2016-08-29T18:33:19.553" Title="understand the logic between Vim script &quot;if&quot; statement and filetype command" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9394" PostTypeId="2" ParentId="9386" CreationDate="2016-08-29T17:35:59.473" Score="1" Body="&lt;p&gt;Other Vi clones do not support &lt;code&gt;\r&lt;/code&gt; or &lt;code&gt;\n&lt;/code&gt; (as a real backslash and letter) in substitution, but the behaviour of a real &lt;code&gt;^M&lt;/code&gt; (&lt;kbd&gt;CTRL-V&lt;/kbd&gt; &lt;kbd&gt;Enter&lt;/kbd&gt;) meaning to split the line into two lines is &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html#tag_20_40_13_40&quot; rel=&quot;nofollow&quot;&gt;standard behavior&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Entering a &amp;lt;carriage-return&gt; in &lt;em&gt;repl&lt;/em&gt; (which requires an escaping &amp;lt;backslash&amp;gt; in &lt;em&gt;ex&lt;/em&gt; mode and an escaping &amp;lt;control&gt;-V in open or &lt;em&gt;vi&lt;/em&gt; mode) shall split the line at that point, creating a new line in the edit buffer. The &amp;lt;carriage-return&amp;gt; shall be discarded.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In the Unix History archive, the first version of BSD ex/vi it appears in is 4.1cBSD (&lt;a href=&quot;http://www.tuhs.org/cgi-bin/utree.pl?file=4.1cBSD/usr/src/ucb/ex/ex_re.c&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;@(#)ex_re.c 7.2 10/16/81&lt;/code&gt;&lt;/a&gt;, and is not present in 4BSD (&lt;a href=&quot;http://www.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/cmd/ex/ex_re.c&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;@(#)ex_re.c 6.2 10/23/80&lt;/code&gt;&lt;/a&gt;) [4.1a and 4.1b are not present in the archive].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* ^V &amp;lt;return&amp;gt; from vi to split lines */&#xA;if (c == '\r')&#xA;    c = '\n';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is also mentioned in the &lt;a href=&quot;http://www.tuhs.org/cgi-bin/utree.pl?file=4.1cBSD/usr/src/ucb/ex/ex.news&quot; rel=&quot;nofollow&quot;&gt;news file&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It is now possible to split lines with substitute commands from vi, by using ^V&amp;lt;return&amp;gt; in the rhs.  This takes care of the last good reason for using ex command mode.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The previously supported behavior in ex command mode was for backslash-enter (i.e. backslash followed by a real newline) to insert a newline.&lt;/p&gt;&#xA;" OwnerUserId="880" LastEditorUserId="880" LastEditDate="2016-08-29T17:41:23.083" LastActivityDate="2016-08-29T17:41:23.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9395" PostTypeId="2" ParentId="9393" CreationDate="2016-08-29T18:33:19.553" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;However, what is the point of keeping the filetype on(enables file type detection) inside the if statement? Shouldn't this be outside and before the if statement?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The point is to avoid parse errors if &lt;code&gt;filetype&lt;/code&gt; isn't available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;if(has(&quot;autocmd&quot;))&lt;/code&gt; is testing if the version of vim parsing the &lt;code&gt;.vimrc&lt;/code&gt; was &lt;em&gt;compiled with&lt;/em&gt; autocommand support. &lt;a href=&quot;https://github.com/vim/vim/blob/d29459baa61819e59961804ed258efac5733ec70/src/ex_docmd.c#L410&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:filetype&lt;/code&gt; isn't available unless autocommand support has been compiled in&lt;/a&gt;, so trying to call it outside the body of that if statement on those version of vim would produce errors.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastActivityDate="2016-08-29T18:33:19.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9396" PostTypeId="2" ParentId="9386" CreationDate="2016-08-29T19:46:57.563" Score="1" Body="&lt;p&gt;The origin of the asymmetry goes back a ways into computing history.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Short version:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;CR&amp;gt; &amp;amp; &amp;lt;LF&amp;gt;  (Carriage-Return and Linefeed) &#xA;== &#xA;\r &amp;amp; \n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Long version:&lt;br&gt;&#xA;The first screens were basically digital versions of teletypes (TTY) and used control codes to generate similar behavior to printers.  Carriage-return took the cursor (or print-head) to the start column.  Linefeed advanced to the next row (on a screen) and fed the paper forward one line.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For printers, you had to do a paired &lt;code&gt;&amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;&lt;/code&gt; or your output would not look right.  On early screens, the issue still held true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DOS (and sorta-Windows after) followed the old standard and saves text with &lt;code&gt;&amp;lt;CRLF&amp;gt;&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;*NIX text (as most vi users are familiar) only uses &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt; for efficiency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test in Windows, use Word/Wordpad and save a few lines of text &quot;as type: Text - MS-DOS format&quot;.  Then open that same file in Notepad.  It should look normal.  Then save the same file in Word/Wordpad &quot;as type: Text&quot;.  Notepad will ignore all newlines and run the lines together.  [Notepad's text format defaults to the &lt;code&gt;\r\n&lt;/code&gt; combination while Word/Wordpad default to &lt;code&gt;\n&lt;/code&gt;.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;\r is the code equivalent of &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;\n is the code equivalent of &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And in my (very limited) experience with vi, it would try to &quot;fix&quot; the &lt;code&gt;&amp;lt;CRLF&amp;gt;&lt;/code&gt; combination from my DOS text editor.  vi ended up removing one character, replacing with &lt;code&gt;&amp;lt;NUL&amp;gt;&lt;/code&gt;.  A big part of the reason I stopped using vi.&lt;/p&gt;&#xA;" OwnerUserId="9051" LastEditorUserId="9051" LastEditDate="2016-08-29T19:54:19.050" LastActivityDate="2016-08-29T19:54:19.050" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9397" PostTypeId="1" CreationDate="2016-08-30T00:18:57.503" Score="1" ViewCount="302" Body="&lt;p&gt;I would like to set the working directory for the process started with &lt;code&gt;job_start()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way I know how to do this is to change Vim's current working directory before calling &lt;code&gt;job_start()&lt;/code&gt;, and then change it back to what it was. That is a little bit of a hack, and I am afraid it could cause problems for some people. Does anyone know a better way?&lt;/p&gt;&#xA;" OwnerUserId="1410" LastEditorUserId="51" LastEditDate="2016-08-31T11:48:48.757" LastActivityDate="2016-08-31T11:48:48.757" Title="How can I set the working directory for only the job_start() process?" Tags="|working-directory|job-control|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9398" PostTypeId="1" CreationDate="2016-08-30T01:34:24.437" Score="1" ViewCount="215" Body="&lt;p&gt;When I exited Insert Mode I began to move around the file, these images began to appear. Does someone know how to fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/P8xsX.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/P8xsX.jpg&quot; alt=&quot;Vim running&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1319" LastActivityDate="2016-08-30T01:34:24.437" Title="Weird characters are appearing while i move in blank spaces" Tags="|filetype|plugin-devicons|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9399" PostTypeId="2" ParentId="9397" CreationDate="2016-08-30T06:51:39.580" Score="2" Body="&lt;p&gt;In Build-Tool-Wrapper, I've used &lt;code&gt;sh -c&lt;/code&gt; to actually run &lt;code&gt;cd compdir &amp;amp;&amp;amp; make args&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; the a:cmd is managed elsewhere in the plugin&#xA;&quot; it may contain many things, usually things like &#xA;&quot;    `cd build/dir &amp;amp;&amp;amp; make tgt -j 8 2&amp;gt;&amp;amp;1 | gSTLfilt.pl`&#xA;if lh#os#OnDOSWindows() &amp;amp;&amp;amp; &amp;amp;shell =~ 'cmd'&#xA;  let cmd = &amp;amp;shell . ' /C '.a:cmd&#xA;else&#xA;  let cmd = ['sh', '-c', a:cmd]&#xA;endif&#xA;let job = job_start(cmd,&#xA;      \ {&#xA;      \   'close_cb': ('CloseCB')&#xA;      \ , 'callback': ('CallbackCB')&#xA;      \ })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/LucHermitte/vim-build-tools-wrapper/blob/job-compile/autoload/lh/btw/job_build.vim#L156&quot; rel=&quot;nofollow&quot;&gt;https://github.com/LucHermitte/vim-build-tools-wrapper/blob/job-compile/autoload/lh/btw/job_build.vim#L156&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't fully tested it yet on windows though.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-08-30T06:51:39.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9400" PostTypeId="1" AcceptedAnswerId="9401" CreationDate="2016-08-16T12:24:53.870" Score="8" ViewCount="10797" Body="&lt;p&gt;Now I navigate from one tab to another tab in Vim using the &lt;code&gt;gt&lt;/code&gt; command, but it's little frustrating for me, because so far I've worked with editors that support mouse navigation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way that I can control Vim with mouse?&lt;/p&gt;&#xA;" OwnerUserId="8840" OwnerDisplayName="Charles Rajendran" LastEditorUserId="51" LastEditDate="2016-08-30T11:59:55.867" LastActivityDate="2016-08-30T12:01:36.033" Title="Mouse click navigation in vim tab" Tags="|tabbed-user-interface|mouse|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9401" PostTypeId="2" ParentId="9400" CreationDate="2016-08-16T12:35:43.747" Score="16" Body="&lt;p&gt;Give this a try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set mouse=a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think you'll find the keys a bit faster though, if you take the time to learn them.&lt;/p&gt;&#xA;" OwnerDisplayName="xulfir" LastActivityDate="2016-08-16T12:35:43.747" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9402" PostTypeId="2" ParentId="9400" CreationDate="2016-08-16T12:37:33.080" Score="3" Body="&lt;p&gt;If you are specifically interested in movement in Vim, then you can add &lt;code&gt;set mouse=a&lt;/code&gt; to your &lt;code&gt;~/.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;" OwnerDisplayName="anujjain0801" LastEditorUserId="51" LastEditDate="2016-08-30T12:01:36.033" LastActivityDate="2016-08-30T12:01:36.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9403" PostTypeId="1" CreationDate="2016-08-30T13:37:36.287" Score="1" ViewCount="117" Body="&lt;p&gt;In my &lt;code&gt;.vimrc&lt;/code&gt; I have this piece of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Gist it to bl.ocks.org {{{&#xA;let g:gist_clip_command = 'xclip -selection clipboard'&#xA;command! -range=% Blocks&#xA;    \ &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;Format format | f index.html | exe 'Gist! -p' | bd!                                    |&#xA;    \ let @+ = 'http://bl.ocks.org/oblitum/raw/' . matchstr(@+, 'https://gist.github.com/\zs\w\+\ze') . '/' |&#xA;    \ let @+ = bitly#shorten(@+).url | redraw | echomsg 'Done: ' . @+ | setlocal nomodified&#xA;&quot; }}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/oblitum/dotfiles/blob/86e15d31503649af6c24caba396a71158f5423a9/.vimrc#L708-L714&quot; rel=&quot;nofollow&quot;&gt;Source&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the top of the &lt;code&gt;.vimrc&lt;/code&gt; I set &lt;code&gt;clipboard=unnamedplus&lt;/code&gt; and add all the necessary plugins (frawor, formatvim, webapi-vim, gist-vim, bitly.vim). This command is to get buffer contents including highlighting and post it to a web page online.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command works when executed from Vim in the terminal, but it doesn't when executed from GVIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On GVIM it seems that &lt;code&gt;Gist! -p&lt;/code&gt; works for saving the gist url into the clipboard but then all the remaining command parts that are supposed to edit and transform this content in the clipboard seems to be doing nothing and in the end the &lt;code&gt;echomsg&lt;/code&gt; just displays what was created by the original &lt;code&gt;Gist! -p&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6324" LastEditorUserId="2920" LastEditDate="2016-08-30T15:18:32.850" LastActivityDate="2016-08-30T15:18:32.850" Title="Why does this clipboard manipulation that works on Vim not work on GVIM?" Tags="|vimrc|gvim|terminal|os-clipboard|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9404" PostTypeId="2" ParentId="9403" CreationDate="2016-08-30T14:19:36.150" Score="1" Body="&lt;p&gt;&lt;code&gt;let g:gist_clip_command = 'xclip -selection clipboard'&lt;/code&gt; configuration is not necessary on GVIM and it's the culprit.&lt;/p&gt;&#xA;" OwnerUserId="6324" LastActivityDate="2016-08-30T14:19:36.150" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9405" PostTypeId="1" CreationDate="2016-08-30T15:17:22.553" Score="4" ViewCount="5263" Body="&lt;p&gt;I'm using vim editor in linux and every time I type backspace it inserts a &quot;^?&quot; instead. I DID edit the .vimrc file to include &lt;code&gt;backspace=indent,eol,star&lt;/code&gt; but it did not help. I also tried &lt;code&gt;backspace=2&lt;/code&gt; and it doesn't work either. The strangest thing is that if I type &lt;code&gt;:fixdel&lt;/code&gt; it stops inserting the weird &lt;code&gt;^?&lt;/code&gt; but instead deletes the &lt;strong&gt;next&lt;/strong&gt; character instead of the previous.&lt;/p&gt;&#xA;" OwnerUserId="9063" LastActivityDate="2016-08-30T16:38:32.863" Title="Backspace inserts &quot;^?&quot; in vim" Tags="|key-bindings|vimrc|linux|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9406" PostTypeId="2" ParentId="9405" CreationDate="2016-08-30T16:38:32.863" Score="2" Body="&lt;p&gt;In &lt;code&gt;:h fixdel&lt;/code&gt; it mentions this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If the backspace key terminal code is wrong you can use this: &amp;gt;&#xA;            :if &amp;amp;term == &quot;termname&quot;&#xA;            :  set t_kb=^V&amp;lt;BS&amp;gt;&#xA;            :  fixdel&#xA;            :endif&#xA;Where &quot;^V&quot; is CTRL-V and &quot;&amp;lt;BS&amp;gt;&quot; is the backspace key&#xA;        (don't type four characters!).  Replace &quot;termname&quot;&#xA;        with your terminal name.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Have you tried that in your &lt;code&gt;vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-08-30T16:38:32.863" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9407" PostTypeId="1" CreationDate="2016-08-30T19:21:02.203" Score="1" ViewCount="1758" Body="&lt;p&gt;I know about &lt;code&gt;:map&lt;/code&gt; but I want to list the complete default mapping list with the associated help for each mapping. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise I need to test each command manually such as &lt;code&gt;:help CTRL-B&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any comprehensive list of all the Vim mappings that use the &lt;kbd&gt;CTRL&lt;/kbd&gt; key?&lt;/p&gt;&#xA;" OwnerUserId="2548" LastActivityDate="2016-08-30T19:21:02.203" Title="How to see the complete default mapping in Vim?" Tags="|key-bindings|help-system|" AnswerCount="0" CommentCount="1" ClosedDate="2016-08-30T19:23:41.260" ContentLicense="CC BY-SA 3.0" />
  <row Id="9408" PostTypeId="1" CreationDate="2016-08-31T08:33:22.213" Score="2" ViewCount="520" Body="&lt;p&gt;I have this in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;t_SI = &quot;\&amp;lt;Esc&amp;gt;[5 q&quot;&#xA;let &amp;amp;t_SR = &quot;\&amp;lt;Esc&amp;gt;[3 q&quot;&#xA;let &amp;amp;t_EI = &quot;\&amp;lt;Esc&amp;gt;[2 q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that I keep the block cursor shape when I exit vim. How can I easily restore the previous cursor shape when I quit or I stop vim?&lt;/p&gt;&#xA;" OwnerUserId="2548" LastActivityDate="2016-08-31T09:12:28.027" Title="How to restore cursor shape when exiting/stopping vim?" Tags="|cursor|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9410" PostTypeId="1" AcceptedAnswerId="9411" CreationDate="2016-08-31T12:54:03.800" Score="1" ViewCount="106" Body="&lt;p&gt;I want to craft a custom operator-pending motion &lt;code&gt;if&lt;/code&gt; for functions in R language that look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;doSomething &amp;lt;- function(arg1, arg2, ...) {&#xA;    doStuff(...)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to be able to press &lt;code&gt;yif&lt;/code&gt; while on the function body to copy it's contents &lt;code&gt;doStuff(...)&lt;/code&gt; in this case. I have something that works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap if :&amp;lt;c-u&amp;gt;execute &quot;normal! $?&amp;lt;-\\s*function\\s*(\r^/{\r%``j^v``kg_&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does the following: searches for the &lt;code&gt;&amp;lt;- function&lt;/code&gt; pattern backwards, then finds the first &lt;code&gt;{&lt;/code&gt;, jumps to it's match with &lt;code&gt;%&lt;/code&gt;, then goes back to the beginning, goes down one line, enters visual mode, jump to the end, goes up one line and finishes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works for me with one downside: it finds functions even when I am outside (below) the function body.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: how to make it fail when the cursor is not on a function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any other help/tips are appreciated as well.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Update&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Following advice from @Luc I wrote a simple function to check if the given line is inside the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! IsInsideRFunction(lnum)&#xA;  let currentline = a:lnum&#xA;  let savedpos = getpos(&quot;.&quot;)&#xA;  execute &quot;silent! normal! $&quot; . '?&amp;lt;-\s*function\s*(' . &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;  execute &quot;silent! normal! &quot; . '/{' . &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;  let startline = line(&quot;.&quot;)&#xA;  execute &quot;silent! normal! %&quot;&#xA;  let endline = line(&quot;.&quot;)&#xA;  if currentline &amp;gt;=# startline &amp;amp;&amp;amp; currentline &amp;lt;=# endline&#xA;    call setpos(&quot;.&quot;, savedpos)&#xA;    return 1&#xA;  endif&#xA;  call setpos(&quot;.&quot;, savedpos)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function works. However when I put it inside the expression map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;expr&amp;gt; aF IsInsideRFunction(line(&quot;.&quot;)) ? &quot;:echom 'yes'&amp;lt;cr&amp;gt;&quot; : &quot;:echom 'no'&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it stops working. More precisely - it always returns &quot;1&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="307" LastEditorUserId="307" LastEditDate="2016-08-31T21:48:23.740" LastActivityDate="2016-08-31T23:31:55.623" Title="onoremap: defining a bounded region" Tags="|regular-expression|range|object-motions|map-operator|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9411" PostTypeId="2" ParentId="9410" CreationDate="2016-08-31T13:30:52.903" Score="2" Body="&lt;p&gt;Have you looked at &lt;a href=&quot;https://vi.stackexchange.com/questions/7925/quick-search-limited-to-a-c-function/7942#7942&quot;&gt;Quick search, limited to a C++ function&lt;/a&gt; all the techniques presented in this discussion shall apply to your question. I'm not sure my solution is checking the cursor is within a function definition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check for improper uses, you have to define a function. There, first record the current line, and then check the first and last line you detect do surround the initial line. If not, throw an error or do whatever you wish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;For instance something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ftplugin/r.vim&#xA;onoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; if :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;Select_current_function()&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; if :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;Select_current_function()&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;gv&#xA;&#xA;function! s:Select_current_function() abort&#xA;  if 0&#xA;    &quot; V1 that doesn't work well when the cursor is on the function declaration&#xA;    &quot; The regex needs to be fixed&#xA;    let lin = line('.')&#xA;    let start = searchpos('&amp;lt;-\s*function\s*(.\{-})\s*{', 'bcenWz') &quot; may depend on your vim version&#xA;    if start[0] == 0 &#xA;      throw &quot;Not within a function&quot;&#xA;    endif&#xA;    call assert_true(start[0] &amp;lt;= lin) &quot; may not exist with old vim versions&#xA;    let end = searchpairpos('{', '', '}', 'nc')&#xA;    if end[0] == 0 || end[0] &amp;lt; lin&#xA;      throw &quot;Not within a function&quot;&#xA;    endif&#xA;    call cursor(start)&#xA;    normal! v&#xA;    call cursor(end)&#xA;  else&#xA;&#xA;    &quot; or, V2 that supposes that function end is always 0 indented&#xA;    &quot; I don't know if this is valid for R&#xA;    let p = getcurpos()&#xA;    normal! ][&#xA;    if getline('.')[col('.')-1] != '}'&#xA;      call setpos('.', p)&#xA;      throw &quot;Not within a function 1&quot;&#xA;    endif&#xA;    normal! v%&#xA;    if line('.') &amp;gt; p[1] &#xA;      call setpos('.', p)&#xA;      throw &quot;Not within a function&quot;&#xA;    endif&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-08-31T23:31:55.623" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="9412" PostTypeId="1" CreationDate="2016-08-31T15:02:36.277" Score="5" ViewCount="209" Body="&lt;p&gt;I like having netrw loaded for browsing directory contents when I open &lt;code&gt;'.'&lt;/code&gt; and for downloading webpages when I &lt;code&gt;split http://host/path&lt;/code&gt;, but it's really getting in the way of opening files with &lt;code&gt;gF&lt;/code&gt; or &lt;code&gt;^wf&lt;/code&gt; when netrw doesn't understand the protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm editing a sizable library of Salt statelists for a project, and they have a lot of Salt filesystem URLs in the configs (&lt;code&gt;salt://path/path/file&lt;/code&gt;) that I'd like to be able to split into with &lt;code&gt;gF&lt;/code&gt; and &lt;code&gt;^wf&lt;/code&gt;. There's no hope for netrw understanding these as built-ins, which is acceptable. Some local config would be required to explain to vim where the files really are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like a local config to teach netrw to open them or some other method of bypassing netrw so I can open them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set includeexpr=substitute(v:fname, &quot;salt://&quot;, &quot;location/of/file_root/&quot;).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It took me quite a while to figure out &lt;code&gt;includeexpr&lt;/code&gt; was never being applied. What seems to happen is that netrw handles the URL, decides it's a filename, and fails to execute &lt;code&gt;includeexpr&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are my options here? disable netrw in &lt;code&gt;BufEnter&lt;/code&gt; for files I'm likely to see the salt urls? preemptively fire &lt;code&gt;includeexpr&lt;/code&gt; before netrw can get to it? Also, where would you set events that happen before netrw fires?&lt;/p&gt;&#xA;" OwnerUserId="9079" LastEditorUserId="9079" LastEditDate="2016-09-04T11:27:13.407" LastActivityDate="2016-11-30T14:44:40.590" Title="open salt://whatever as somedir/whatever" Tags="|vimscript|netrw|" AnswerCount="1" CommentCount="3" ClosedDate="2016-11-30T15:19:56.927" ContentLicense="CC BY-SA 3.0" />
  <row Id="9413" PostTypeId="1" CreationDate="2016-08-31T17:16:15.020" Score="2" ViewCount="618" Body="&lt;p&gt;While reading through &lt;a href=&quot;https://vi.stackexchange.com/a/515/2920&quot;&gt;this answer&lt;/a&gt;, I found these useful commands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+W&lt;/kbd&gt; &lt;kbd&gt;+/-&lt;/kbd&gt;: increase/decrease height&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+W&lt;/kbd&gt; &lt;kbd&gt;&gt;/&amp;lt;&lt;/kbd&gt;: increase/decrease width&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These are super useful, but I hate how it defaults to resizing by a single column at a time. I'd like it to move 10 columns at a time. I could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-w&amp;gt;+ 10&amp;lt;C-w&amp;gt;+&#xA;nnoremap &amp;lt;C-w&amp;gt;- 10&amp;lt;C-w&amp;gt;-&#xA;nnoremap &amp;lt;C-w&amp;gt;&amp;lt; 10&amp;lt;C-w&amp;gt;&amp;lt;&#xA;nnoremap &amp;lt;C-w&amp;gt;&amp;gt; 10&amp;lt;C-w&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I dislike this solution. For one, it doesn't work well with counts. Sure, I could use &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;, but that just makes it more complicated. The other thing is, this just feels like the wrong way to do it. Is there any setting such as &lt;code&gt;:set resize_amount = 10&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="343" LastEditDate="2017-12-06T11:35:58.987" LastActivityDate="2017-12-06T11:35:58.987" Title="Can I make all &quot;resize split&quot; commands take a default count?" Tags="|vimscript|split|count|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9414" PostTypeId="2" ParentId="4612" CreationDate="2016-08-31T19:53:22.220" Score="0" Body="&lt;p&gt;Vim's paragraph formatting abilities can be extended by installing an old program called 'par'. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatprg=par\ -w12&#xA;&quot; (gq will now format using par. Does not affect gw)&#xA;&#xA;:map &amp;lt;A-q&amp;gt; {v}!par -w12&amp;lt;CR&amp;gt;&#xA;&quot; (maps alt-q to format selection using par)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;source: &lt;a href=&quot;http://vim.wikia.com/wiki/Par_text_reformatter&quot; rel=&quot;nofollow&quot;&gt;http://vim.wikia.com/wiki/Par_text_reformatter&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8214" LastActivityDate="2016-08-31T19:53:22.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9415" PostTypeId="2" ParentId="9413" CreationDate="2016-08-31T19:56:15.877" Score="2" Body="&lt;p&gt;There is not a setting that works as you've described, so you're probably on the best track already. Using &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; and &lt;code&gt;v:count&lt;/code&gt; can get you what you want: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-w&amp;gt;+ v:count1 * 10 . '&amp;lt;C-w&amp;gt;+'&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-w&amp;gt;- v:count1 * 10 . '&amp;lt;C-w&amp;gt;-'&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-w&amp;gt;&amp;lt; v:count1 * 10 . '&amp;lt;C-w&amp;gt;&amp;lt;'&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-w&amp;gt;&amp;gt; v:count1 * 10 . '&amp;lt;C-w&amp;gt;&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;v:count1&lt;/code&gt; returns 1 if there is no count, as opposed to &lt;code&gt;v:count&lt;/code&gt; which would return 0 if there is no count, which wouldn't be what we'd want here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you didn't want to move in increments of 10, but rather always just move at least 10 lines, just swap &lt;code&gt;*&lt;/code&gt; for &lt;code&gt;+&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In either case, if you need to resize by an amount that is either not multiple of 10 or is less than 10, &lt;code&gt;:resize&lt;/code&gt; and &lt;code&gt;:vertical resize&lt;/code&gt; will still cover that. See &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#window-resize&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help window-resize&lt;/code&gt;&lt;/a&gt; for more details on those. Alternately, see @Sato Katsura's comment for a method that works as stock with a count but uses a variable when no count is provided. &lt;/p&gt;&#xA;" OwnerUserId="1166" LastEditorUserId="1166" LastEditDate="2016-09-01T15:27:01.383" LastActivityDate="2016-09-01T15:27:01.383" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9416" PostTypeId="1" AcceptedAnswerId="9423" CreationDate="2016-09-01T08:52:39.350" Score="18" ViewCount="4796" Body="&lt;p&gt;I am trying to set &lt;code&gt;g:netrw_list_hide&lt;/code&gt; and it doesn't seem to work. No matter what I set it to in my &lt;code&gt;.vimrc&lt;/code&gt; it always has the value &lt;code&gt;,^\.\.\=/\=$&lt;/code&gt;. Only if I source my &lt;code&gt;vimrc&lt;/code&gt; file again, then it holds the correct value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I debug this? I guess there is some plugin that is setting that variable? Possibly after my &lt;code&gt;vimrc&lt;/code&gt; gets loaded, so I want to see where it's being set.&lt;/p&gt;&#xA;" OwnerUserId="7428" LastActivityDate="2016-09-02T13:11:02.420" Title="How do you find where a variable was last assigned?" Tags="|vimscript|vimrc|neovim|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9417" PostTypeId="2" ParentId="9416" CreationDate="2016-09-01T13:08:24.567" Score="26" Body="&lt;p&gt;If you were looking for the last point where an option was set (instead of a variable), you could use the &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#:verbose&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:verbose&lt;/code&gt;&lt;/a&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:4verbose set is?&#xA;  incsearch&#xA;        Last set from ~/.vim/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But currently there is no equivalent command for variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could inspect the code, or use search in the source, possibly using &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#:vimgrep&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:vimgrep&lt;/code&gt;&lt;/a&gt;, &lt;code&gt;:vim netrw_list_hide **/*&lt;/code&gt; (as mentioned in the comments).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another alternative is to use the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27verbose%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'verbose'&lt;/code&gt; option&lt;/a&gt; to echo everything that is executed after you set the variable. As it will be an large output echoed in the screen, &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#:redir&quot; rel=&quot;noreferrer&quot;&gt;you will need to save&lt;/a&gt; it (into a register, for example):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; in your .vimrc, after you set the variable&#xA;redir @b&#xA;set verbose=15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After the initialization ends, restore the verbose to the default value and stop the redirection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set vbs&amp;amp;&#xA;:redir end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may need to hit Ctrl-C some times, depending on the autocmds/plugins you are using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can paste contents of the register using &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#p&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;&quot;bp&lt;/code&gt;&lt;/a&gt; and analyze the &quot;&lt;strong&gt;initialization log&lt;/strong&gt;&quot;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-09-01T13:20:09.003" LastActivityDate="2016-09-01T13:20:09.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9418" PostTypeId="1" AcceptedAnswerId="9419" CreationDate="2016-09-01T15:23:53.017" Score="6" ViewCount="1804" Body="&lt;p&gt;I am using the &lt;a href=&quot;http://cmder.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;cmder&lt;/a&gt; under Windows 7.&lt;/p&gt;&#xA;&lt;p&gt;I am using Vim version 7.4; I'm using the airline plugin and I installed the powerline font/patch.&lt;/p&gt;&#xA;&lt;p&gt;I followed the instruction and also added the following to my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('g:airline_symbols')&#xA;    let g:airline_symbols = {}&#xA;endif&#xA;&#xA;&amp;quot; unicode symbols&#xA;let g:airline_left_sep = '»'&#xA;let g:airline_left_sep = '▶'&#xA;let g:airline_right_sep = '«'&#xA;let g:airline_right_sep = '◀'&#xA;let g:airline_symbols.linenr = '␊'&#xA;let g:airline_symbols.linenr = '␤'&#xA;let g:airline_symbols.linenr = '¶'&#xA;let g:airline_symbols.branch = '⎇'&#xA;let g:airline_symbols.paste = 'ρ'&#xA;let g:airline_symbols.paste = 'Þ'&#xA;let g:airline_symbols.paste = '∥'&#xA;let g:airline_symbols.whitespace = 'Ξ'&#xA;&#xA;&amp;quot; airline symbols&#xA;let g:airline_left_sep = ''&#xA;let g:airline_left_alt_sep = ''&#xA;let g:airline_right_sep = ''&#xA;let g:airline_right_alt_sep = ''&#xA;let g:airline_symbols.branch = ''&#xA;let g:airline_symbols.readonly = ''&#xA;let g:airline_symbols.linenr = ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But still the status bar shows funny characters. Does the airline for Vim even work on Windows (NOT using the cygwin) just using the cmder?&lt;/p&gt;&#xA;" OwnerUserId="9092" LastEditorUserId="23502" LastEditDate="2023-04-05T03:17:26.860" LastActivityDate="2023-04-05T03:17:26.860" Title="Does powerline and Vim work in Windows using Cmder shell terminal?" Tags="|microsoft-windows|plugin-airline|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9419" PostTypeId="2" ParentId="9418" CreationDate="2016-09-01T19:44:39.977" Score="3" Body="&lt;p&gt;From &lt;a href=&quot;https://github.com/cmderdev/cmder/issues/225&quot; rel=&quot;nofollow&quot;&gt;issue#225&lt;/a&gt; of cmder:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This not a specific problem of cmder, but rather of cmd in general,&#xA;  which does not use UTF-8 by default.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So just run &lt;code&gt;chcp 65001&lt;/code&gt; from cmder terminal to set unicode code page to &lt;em&gt;UTF8&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT this way you should run this code every time you are going to use cmder; To automate this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can just add a &quot;@chcp 65001 &gt;nul&quot; at the bottom of the&#xA;  vendor/init.bat.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This way unicode will set on cmder initiation.&lt;/p&gt;&#xA;" OwnerUserId="7976" LastActivityDate="2016-09-01T19:44:39.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9421" PostTypeId="1" AcceptedAnswerId="9422" CreationDate="2016-09-02T08:00:42.580" Score="1" ViewCount="905" Body="&lt;p&gt;I was interested in the &lt;code&gt;set formatoptions+=a&lt;/code&gt; option, but even if the idea of reformatting comment in my code or even markdown text is seducing, I cannot really use the feature because I cannot write something like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Heading&#xA;=======&#xA;Some Text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Immediately, Vim will reformat this as follow: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Heading ======= Some Text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I need to do is insert a blank line between each entry: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Heading&#xA;&#xA;=======&#xA;&#xA;Some Text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is not very convenient. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there another option that makes this &lt;code&gt;a&lt;/code&gt; option a bit smarter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA; * Heading.&#xA; * A function that does something&#xA; * @param foo Foo&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will be automatically reformatted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/** Heading. A function that does something @param foo Foo&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2548" LastEditorUserId="2548" LastEditDate="2016-09-02T08:25:36.620" LastActivityDate="2016-09-02T09:05:45.443" Title="How to make formatoptions+=a useful?" Tags="|formatting|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9422" PostTypeId="2" ParentId="9421" CreationDate="2016-09-02T09:05:45.443" Score="3" Body="&lt;p&gt;If you have &lt;code&gt;a&lt;/code&gt; in &lt;code&gt;'formatoptions'&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatoptions+=w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can help with the automatic formatting.&#xA;It means that lines ending with trailing space indicate that&#xA;the paragraph continues on the next line. The&#xA;trailing space is automatically added when the&#xA;line is broken while typing, editing, or when formatting with &lt;code&gt;gq&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A line without trailing space indicates that a&#xA;paragraph ends at that line, so hitting &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;&#xA;will end a paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this doesn't affect the operation of text objects.&#xA;Commands such as &lt;code&gt;gqap&lt;/code&gt; will format a regular paragraph, but&#xA;the formatting will respect the paragraph boundaries&#xA;determined by the rules for &lt;code&gt;w&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-09-02T09:05:45.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9423" PostTypeId="2" ParentId="9416" CreationDate="2016-09-02T13:11:02.420" Score="16" Body="&lt;p&gt;You can capture a full log of a Vim session with &lt;code&gt;vim -V20vimlog&lt;/code&gt;. After quitting Vim, examine (search, &lt;code&gt;grep&lt;/code&gt;) the &lt;code&gt;vimlog&lt;/code&gt; log file for &lt;code&gt;:let g:netrw_list_hide&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-02T13:11:02.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9424" PostTypeId="1" AcceptedAnswerId="9451" CreationDate="2016-09-02T14:59:21.857" Score="1" ViewCount="119" Body="&lt;p&gt;I keep my VIM folder under git version control. I use git submodules and Pathogen to keep my VIM plugins updated. The folder structure is .vim/bundle/$PLUGIN&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use git submodules for syntax files? With plugins this works because each plugin corresponds to the submodule repository in its own folder. As far as I can tell syntax files cannot be in sub-folders (arising from the cloned git submodule repository) within .vim/syntax  and this approach breaks down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to resolve this?&lt;/p&gt;&#xA;" OwnerUserId="9099" LastEditorUserId="9099" LastEditDate="2016-09-02T15:46:33.370" LastActivityDate="2016-09-05T09:16:29.160" Title="Git submodules for syntax files" Tags="|syntax-highlighting|git|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9425" PostTypeId="1" AcceptedAnswerId="9450" CreationDate="2016-09-02T23:56:20.790" Score="4" ViewCount="3270" Body="&lt;p&gt;Are this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noexpandtab&#xA;set shiftwidth=4&#xA;set tabstop=4&#xA;set softtabstop=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;..and this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noexpandtab&#xA;set shiftwidth=4&#xA;set tabstop=4&#xA;set softtabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;..exactly the same? I thought that if &lt;code&gt;softtabstop=0&lt;/code&gt;, then nothing happens if &lt;kbd&gt;Tab&lt;/kbd&gt; is pressed, but this does not seem to be the case.&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2016-09-07T07:43:48.943" Title="softtabstop == tabstop VS softtabstop=0" Tags="|tab-characters|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9426" PostTypeId="1" CreationDate="2016-09-03T00:12:28.843" Score="11" ViewCount="1221" Body="&lt;p&gt;I have been following the following two tutorials to try and set up &lt;code&gt;eslint&lt;/code&gt; and &lt;code&gt;Neomake&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gregjs.com/vim/2015/linting-code-with-neomake-and-neovim/&quot; rel=&quot;noreferrer&quot;&gt;Linting code with Neomake and Neovim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.gregjs.com/vim/2015/linting-code-with-neovim-and-neomake-eslint-edition/&quot; rel=&quot;noreferrer&quot;&gt;Linting code with Neovim and Neomake - ESLint edition&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So I have the following minimal &lt;code&gt;init.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'neomake/neomake'&#xA;&#xA;call plug#end()&#xA;&#xA;autocmd! BufWritePost,BufEnter * Neomake&#xA;let g:neomake_verbose=3&#xA;let g:neomake_open_list = 2&#xA;let g:neomake_javascript_enabled_makers = ['eslint']&#xA;&#xA;&quot; neomake&#xA;nmap &amp;lt;Leader&amp;gt;&amp;lt;Space&amp;gt;o :lopen&amp;lt;CR&amp;gt;      &quot; open location window&#xA;nmap &amp;lt;Leader&amp;gt;&amp;lt;Space&amp;gt;c :lclose&amp;lt;CR&amp;gt;     &quot; close location window&#xA;nmap &amp;lt;Leader&amp;gt;&amp;lt;Space&amp;gt;, :ll&amp;lt;CR&amp;gt;         &quot; go to current error/warning&#xA;nmap &amp;lt;Leader&amp;gt;&amp;lt;Space&amp;gt;n :lnext&amp;lt;CR&amp;gt;      &quot; next error/warning&#xA;nmap &amp;lt;Leader&amp;gt;&amp;lt;Space&amp;gt;p :lprev&amp;lt;CR&amp;gt;      &quot; previous error/warning&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is when I save &lt;code&gt;Neomake&lt;/code&gt; hangs with the following message:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Neomake: Starting: eslint -f compact /home/otis/Developer/test/index.js&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If i run that command manually outside of &lt;code&gt;nvim&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;eslint -f compact /home/otis/Developer/test/index.js&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I receive the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/otis/Developer/test/index.js: line 1, col 1, Error - Unexpected var, use let or const instead. (no-var)&#xA;/home/otis/Developer/test/index.js: line 1, col 5, Error - 'a' is defined but never used. (no-unused-vars)&#xA;/home/otis/Developer/test/index.js: line 1, col 9, Error - Strings must use singlequote. (quotes)&#xA;&#xA;3 problems&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is good it means &lt;code&gt;eslint&lt;/code&gt; is working but I am getting nothing back from &lt;code&gt;Neomake&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run &lt;code&gt;:lopen&lt;/code&gt; the window pops up and then instantly closes like below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Rmoyt.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Rmoyt.gif&quot; alt=&quot;Window open then close&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;vim&lt;/code&gt;/&lt;code&gt;nvim&lt;/code&gt; knowledge is somewhat basic so please be explicit in responses.&lt;/p&gt;&#xA;" OwnerUserId="7052" LastActivityDate="2019-12-11T23:00:28.670" Title="Neomake hanging when using eslint" Tags="|neovim|quickfix|plugin-neomake|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9427" PostTypeId="1" CreationDate="2016-09-03T04:23:28.877" Score="0" ViewCount="643" Body="&lt;p&gt;GVim supports special characters (&lt;code&gt;ñ÷åòôùõéïéðÛáóäæç&lt;/code&gt; ... etc), by holding &lt;code&gt;Alt&lt;/code&gt; in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I'm sure this is handy for languages that use these characters, I've bound some &lt;code&gt;Alt+Keys&lt;/code&gt; in insert mode, so whenever I use these special keys, its always by accident.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to disable this feature entirely? &lt;em&gt;(besides re-binding every &lt;code&gt;Alt-Key&lt;/code&gt;?)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In case it's important, using GVim on X11, compiled with GTK3.&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="301" LastEditDate="2016-09-03T04:34:05.993" LastActivityDate="2016-12-02T18:08:21.533" Title="How to disable special characters in insert mode?" Tags="|gvim|key-bindings|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9428" PostTypeId="1" AcceptedAnswerId="9429" CreationDate="2016-09-03T06:59:53.173" Score="1" ViewCount="137" Body="&lt;p&gt;For writing a text book I would like text expansion; on typing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|25,50,65|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it should expand this to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$25\ux,50\uy,65\uz$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to use simple text replacement with &lt;code&gt;:s%/TEXT/NEWTEXT/gc&lt;/code&gt;, but problem is my requirement with three arguments vim should wrap some text around three arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same problem exists with &lt;code&gt;iabbrev&lt;/code&gt;, plus &lt;code&gt;iabbrev&lt;/code&gt; requires typing TEXT and then a space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this in Vim?&lt;/p&gt;&#xA;" OwnerUserId="9104" LastEditorUserId="51" LastEditDate="2016-09-04T14:45:15.627" LastActivityDate="2016-09-04T14:45:15.627" Title="Text expansion for LaTeX editing" Tags="|substitute|replace|filetype-tex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9429" PostTypeId="2" ParentId="9428" CreationDate="2016-09-03T08:07:01.940" Score="3" Body="&lt;p&gt;You can change any set of numbers (e.g. 24,10,4 to &lt;code&gt;$24\ux,10uy,4uz$&lt;/code&gt;) with something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(\d+)(,\d+)(,\d+)/$\1\\ux\2\\uy\3\\uz$/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-09-03T14:03:49.063" LastActivityDate="2016-09-03T14:03:49.063" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9430" PostTypeId="2" ParentId="9427" CreationDate="2016-09-03T15:55:56.943" Score="1" Body="&lt;p&gt;I'm afraid you can't do any thing. For instance, &lt;code&gt;&amp;lt;m-i&amp;gt;&lt;/code&gt; is bound and always has been bound to &lt;code&gt;é&lt;/code&gt;. Which is a source of a recurrent question with vim-latex. The best you could do is to ask on vim mailings list IMO. But don't expect much. IIRC, this is hard wired.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-09-03T15:55:56.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9431" PostTypeId="1" CreationDate="2016-09-03T16:00:40.843" Score="2" ViewCount="7795" Body="&lt;p&gt;I get no syntax highlight now in Debian's Vim by the workflow which works in Ubuntu 16.04: installation of packages and activating syntax&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;installation &lt;code&gt;apt-get install vim texlive-full&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;activation in Vim, &lt;code&gt;:set syntax=latex&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I know that the Texlive is working because I get correct LaTeX syntax in Geany. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Debian: 8.5&lt;br&gt;&#xA;Vim: release of the year 2006     &lt;/p&gt;&#xA;" OwnerUserId="2923" LastActivityDate="2021-04-01T05:50:38.227" Title="How to Get syntax highlight of LaTeX in Debian's Vim?" Tags="|filetype-tex|linux-debian|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9432" PostTypeId="1" AcceptedAnswerId="9439" CreationDate="2016-09-03T17:11:12.037" Score="2" ViewCount="1482" Body="&lt;p&gt;Is there any way to have the confirm function place the choices on the same line as the msg prompt?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;confirm(&quot;Yes no question&quot;, &quot;&amp;amp;Yes\n&amp;amp;No&quot;, 2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Yes no question&#xA;(Y)es, [N]o: &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it would save a message area scroll if it was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Yes no question (Y)es, [N]o:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Docs mention adding &lt;code&gt;\n&lt;/code&gt; to msg for newlines in the prompt, but looking for a way to suppress the newline between &lt;code&gt;msg&lt;/code&gt; and &lt;code&gt;choices&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9087" LastActivityDate="2021-09-22T12:08:31.447" Title="confirm(msg, choices) without newline on msg?" Tags="|user-input|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9433" PostTypeId="1" AcceptedAnswerId="9435" CreationDate="2016-09-03T17:43:46.440" Score="24" ViewCount="17603" Body="&lt;p&gt;I have two buffers in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls&#xA;  1 %a   &quot;.vimrc&quot;                       line 1&#xA;  2 #h   &quot;script.sh&quot;                    line 1&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As seen above, I'm on the first buffer. Now if I execute the &lt;code&gt;:set softtabstop=16&lt;/code&gt; command, then I expect it to affect both buffers. However, this is not the case- while the &lt;code&gt;sts&lt;/code&gt; value for first buffer is indeed changed and &lt;kbd&gt;Tab&lt;/kbd&gt; key inserts four tab characters(&lt;code&gt;ts=4&lt;/code&gt;), then for second buffer the &lt;code&gt;sts&lt;/code&gt; value is still &lt;code&gt;4&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls&#xA;  1 #h + &quot;.vimrc&quot;                       line 1&#xA;  2 %a + &quot;script.sh&quot;                    line 1&#xA;  softtabstop=4&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is that so? I thought that &lt;code&gt;set&lt;/code&gt; affects all the buffers and &lt;code&gt;setlocal&lt;/code&gt; affects only the active buffer..&lt;/p&gt;&#xA;" OwnerUserId="8626" LastEditorUserId="51" LastEditDate="2016-09-04T14:39:37.497" LastActivityDate="2020-06-07T08:19:35.233" Title="Does &quot;set&quot; command affect only the active buffer?" Tags="|set|setlocal|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9434" PostTypeId="2" ParentId="9433" CreationDate="2016-09-03T18:14:45.897" Score="2" Body="&lt;p&gt;Not an expert, @Martin, but from reading &lt;code&gt;:help set&lt;/code&gt; you would need to &quot;unset&quot; the local value of &lt;code&gt;sts&lt;/code&gt; in each buffer to have that buffer pick up any new global value.  &lt;code&gt;setlocal sts=&lt;/code&gt;  (or for boolean flags, &lt;code&gt;setlocal flag&amp;lt;&lt;/code&gt;).  Kinda makes sense, local settings initialized to current global values on open, then keep local values until told otherwise. If there is no local setting in play, it &lt;em&gt;should&lt;/em&gt; pick up any new global values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, not being an expert, I'd hazard a guess that that second buffer had an explicit local setting before the later &lt;code&gt;set&lt;/code&gt;. &lt;em&gt;More than 50/50 that my understanding is wrong, as I'm still unclear on what the difference between &lt;code&gt;set&lt;/code&gt; and &lt;code&gt;setglobal&lt;/code&gt; is&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9087" LastActivityDate="2016-09-03T18:14:45.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9435" PostTypeId="2" ParentId="9433" CreationDate="2016-09-03T21:15:36.253" Score="40" Body="&lt;p&gt;Options can be &lt;em&gt;global&lt;/em&gt;, &lt;em&gt;window-local&lt;/em&gt;, or &lt;em&gt;buffer-local&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you &lt;code&gt;:set&lt;/code&gt; a &lt;em&gt;global&lt;/em&gt; option, the new value is &lt;em&gt;global&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you &lt;code&gt;:setlocal&lt;/code&gt; a &lt;em&gt;global&lt;/em&gt; option, the new value is &lt;em&gt;local&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you &lt;code&gt;:set&lt;/code&gt; a &lt;em&gt;local&lt;/em&gt; option, the new value is &lt;em&gt;local&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;softtabstop&lt;/code&gt; being a &lt;em&gt;buffer-local&lt;/em&gt; option, changing its value only affects the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;scope&quot; of an option is indicated in &lt;code&gt;:help option&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'softtabstop' 'sts'    number    (default 0)&#xA;                       local to buffer&#xA;                       {not in Vi}&#xA;Number of spaces that a &amp;lt;Tab&amp;gt; counts[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help local-options&lt;/code&gt;, &lt;code&gt;:help :setlocal&lt;/code&gt;, and &lt;code&gt;:help global-local&lt;/code&gt; explain all that in more details.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-09-04T07:56:29.290" LastActivityDate="2016-09-04T07:56:29.290" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9436" PostTypeId="1" AcceptedAnswerId="9440" CreationDate="2016-09-03T21:53:12.340" Score="5" ViewCount="1313" Body="&lt;p&gt;I would like to search for some pattern with &lt;code&gt;:vimgrep&lt;/code&gt; in the current directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /pattern/ *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However this returns the results by filenames ordered alphabetically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run &lt;code&gt;:vimgrepadd&lt;/code&gt; the results for the current file get duplicated:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /pattern/ %&#xA;:vimgrepadd /pattern/ *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I change this so that results from the current file are always on top and not duplicated?&lt;/p&gt;&#xA;" OwnerUserId="307" LastActivityDate="2016-09-04T14:48:56.550" Title="Calling vimgrep so that results from the current file are on top?" Tags="|quickfix|vimgrep|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9437" PostTypeId="2" ParentId="9431" CreationDate="2016-09-04T02:05:41.247" Score="1" Body="&lt;p&gt;There is no latex.vim syntax file that ships with Vim (as far as I know, and see on this Fedora 21 install).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try &lt;code&gt;:set syntax=context&lt;/code&gt; or &lt;code&gt;tex&lt;/code&gt; or &lt;code&gt;plaintex&lt;/code&gt; or &lt;code&gt;initex&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find &lt;code&gt;context&lt;/code&gt; a favourite, but that may be first exposure syndrome and the choice of colours.&lt;/p&gt;&#xA;" OwnerUserId="9087" LastActivityDate="2016-09-04T02:05:41.247" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9438" PostTypeId="1" AcceptedAnswerId="9449" CreationDate="2016-09-04T10:15:02.943" Score="1" ViewCount="74" Body="&lt;p&gt;Say I want to copy what &lt;code&gt;f&lt;/code&gt; does. f takes an &quot;argument&quot; keystroke and moves the cursor there. How do I create such a mapping?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to have a functionality that would require me to have a character as an argument. I'm not looking for the exact, or even close, functionality of &lt;code&gt;f&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2473" LastEditorUserId="2473" LastEditDate="2016-09-04T12:26:43.980" LastActivityDate="2016-09-05T08:59:24.110" Title="Create a mapping which depends on an &quot;argument keystroke&quot;" Tags="|key-bindings|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9439" PostTypeId="2" ParentId="9432" CreationDate="2016-09-04T14:32:10.700" Score="4" Body="&lt;p&gt;Unfortunately you can't; this format is &quot;hardcoded&quot; (in &lt;code&gt;msg_show_console_dialog()&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you can re-create a function which mostly behaves the same with&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getchar%28%29&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;getchar()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Confirm(msg)&#xA;    echo a:msg . ' '&#xA;    let l:answer = nr2char(getchar())&#xA;&#xA;    if l:answer ==? 'y'&#xA;        return 1&#xA;    elseif l:answer ==? 'n'&#xA;        return 0&#xA;    else&#xA;        echo 'Please enter &quot;y&quot; or &quot;n&quot;'&#xA;        return Confirm(a:msg)&#xA;    endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't implement all the features that &lt;code&gt;confirm()&lt;/code&gt; has, but it should show the basic idea.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-09-04T14:32:10.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9440" PostTypeId="2" ParentId="9436" CreationDate="2016-09-04T14:48:56.550" Score="5" Body="&lt;p&gt;You can sort the resulting &lt;code&gt;quickfix&lt;/code&gt; list to give priority to current buffer, then run &lt;code&gt;uniq()&lt;/code&gt; on it.  Sadly you need to handle sorting &lt;code&gt;quickfix&lt;/code&gt; items almost completely.  For example the following will sort the results by buffer, then by line, then column, then text.  If you need more precise sorting you can add more fields (see &lt;code&gt;:h getqflist()&lt;/code&gt; to see what's available):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:CmpQf(a, b) abort&#xA;    if a:a.bufnr == a:b.bufnr&#xA;        if a:a.lnum == a:b.lnum&#xA;            if a:a.col == a:b.col&#xA;                if a:a.text ==# a:b.text&#xA;                    return 0&#xA;                else&#xA;                    return a:a.text &amp;lt; a:b.text ? -1 : 1&#xA;                endif&#xA;            else&#xA;                return a:a.col &amp;lt; a:b.col ? -1 : 1&#xA;            endif&#xA;        else&#xA;            return a:a.lnum &amp;lt; a:b.lnum ? -1 : 1&#xA;        endif&#xA;    else&#xA;        return bufname(a:a.bufnr) &amp;lt;=# bufname(a:b.bufnr) ? -1 : 1&#xA;    endif&#xA;endfunction&#xA;&#xA;function! s:SortQf(a, b) abort&#xA;    let buf = bufnr('')&#xA;    if a:a.bufnr == buf&#xA;        return a:b.bufnr == buf ? s:CmpQf(a:a, a:b) : -1&#xA;    else&#xA;        return a:b.bufnr == buf ? 1 : s:CmpQf(a:a, a:b)&#xA;    endif&#xA;endfunction&#xA;&#xA;call setqflist(uniq(sort(getqflist(), '&amp;lt;SID&amp;gt;SortQf')), 'r')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Save this to a file, run your queries, and the source the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /pattern/ %&#xA;:vimgrepadd /pattern/ *&#xA;...&#xA;:so ~/qfdedupe.vim&#xA;:copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-09-04T14:48:56.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9441" PostTypeId="1" AcceptedAnswerId="9442" CreationDate="2016-09-04T17:13:09.580" Score="8" ViewCount="659" Body="&lt;p&gt;In browsing markdown files, I find the following search useful&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v^(\*|#)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I try to map it I get an error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;c-j&amp;gt; /\v^(\*|#)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;E488: Trailing characters: #)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the best way to make this work?&lt;/p&gt;&#xA;" OwnerUserId="9117" LastEditorUserId="51" LastEditDate="2016-09-04T17:38:58.933" LastActivityDate="2016-09-04T19:23:09.320" Title="store regex searches in vimrc as mappings" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9442" PostTypeId="2" ParentId="9441" CreationDate="2016-09-04T17:30:19.607" Score="12" Body="&lt;p&gt;You need to use &lt;code&gt;&amp;lt;Bar&amp;gt;&lt;/code&gt; instead of &lt;code&gt;|&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;c-j&amp;gt; /\v^(\*&amp;lt;Bar&amp;gt;#)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because the &lt;code&gt;|&lt;/code&gt; is used as a command separator, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-j&amp;gt; :echo &quot;Foo&quot; | echo &quot;bar&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is actually seen as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-j&amp;gt; :echo &quot;Foo&quot;&#xA;echo &quot;bar&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;|&lt;/code&gt; separates the &lt;code&gt;nmap&lt;/code&gt; command from the &lt;code&gt;echo&lt;/code&gt; command. In your case, Vim reads it as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;c-j&amp;gt; /\v^(\*&#xA;#)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hence the somewhat confusing error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#map_bar&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help map_bar&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-09-04T19:23:09.320" LastActivityDate="2016-09-04T19:23:09.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9443" PostTypeId="2" ParentId="9431" CreationDate="2016-09-04T18:36:26.493" Score="0" Body="&lt;p&gt;Add the following line in &lt;code&gt;$HOME/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output: syntax highlight works and their changes too, etc with &lt;code&gt;:set syntax=latex&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="2923" LastActivityDate="2016-09-04T18:36:26.493" CommentCount="0" CommunityOwnedDate="2016-09-04T18:36:26.493" ContentLicense="CC BY-SA 3.0" />
  <row Id="9444" PostTypeId="1" AcceptedAnswerId="10494" CreationDate="2016-09-04T21:04:08.150" Score="1" ViewCount="3988" Body="&lt;p&gt;I want to use Vim as a simple c++ editor in windows (I have no experience with Linux). Nothing fancy, just want to get things started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To compile a .cpp file from CMD I have to run a batch file in the CMD and then I can compile and run the program, i.e &lt;code&gt;g++ -o program program.cpp&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to do this directly from Vim, like a custom command that does both runs the specific batch file and the run command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am completely beginner in Vim and currently have no idea what to do next. Thanks for helping me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All i want is a way to open &lt;strong&gt;Windows CMD&lt;/strong&gt; then &lt;strong&gt;Run my batch file&lt;/strong&gt; and then &lt;strong&gt;run  &lt;code&gt;g++ -o program program.cpp&lt;/code&gt;&lt;/strong&gt;. How can i do that with single command in Vim. &lt;/p&gt;&#xA;" OwnerDisplayName="user9120" LastEditorDisplayName="user9120" LastEditDate="2016-09-04T21:33:25.003" LastActivityDate="2016-12-04T00:35:23.523" Title="How can I run a batch file in Vim's console?" Tags="|command-line|gvim|external-command|microsoft-windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9445" PostTypeId="2" ParentId="9444" CreationDate="2016-09-04T21:05:34.730" Score="0" Body="&lt;p&gt;&lt;code&gt;:!cmd&lt;/code&gt; runs &lt;code&gt;cmd&lt;/code&gt; as if you were running it from the terminal!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you want to build code, you can think of writing a &lt;code&gt;Makefile&lt;/code&gt; and using that. As above, you can run &lt;code&gt;:!make&lt;/code&gt; to call &lt;code&gt;make&lt;/code&gt;. vim has a &lt;code&gt;:make&lt;/code&gt; command that actually calls &lt;code&gt;make&lt;/code&gt; for you, so you might find it easier to use (as a bonus, &lt;code&gt;:mak&lt;/code&gt; does the same and is shorter).&lt;/p&gt;&#xA;" OwnerUserId="850" LastActivityDate="2016-09-04T21:05:34.730" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="9446" PostTypeId="1" AcceptedAnswerId="9447" CreationDate="2016-09-04T22:02:51.600" Score="1" ViewCount="954" Body="&lt;p&gt;I have to navigate through a large code base and it seems the thing that best suits me is the setting for scroll offset &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set scrolloff=50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However if I have to click on the random spot on the screen or move to a random spot on the screen using &lt;code&gt;/&lt;/code&gt; &lt;code&gt;scrolloff=50&lt;/code&gt; doesn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way for me to tell vim that set &lt;code&gt;scrolloff=50&lt;/code&gt; only when I press &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt;? After every &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; return scroll offset to 0 so it will be &lt;code&gt;scrolloff=0&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="51" LastEditDate="2016-09-04T22:40:48.347" LastActivityDate="2016-09-04T22:46:47.047" Title="Customizing the functionality of Ctrl-D is it possible - so=50 only with ctrl+d and ctrl+u" Tags="|key-bindings|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9447" PostTypeId="2" ParentId="9446" CreationDate="2016-09-04T22:46:47.047" Score="2" Body="&lt;p&gt;Yes, by simple making a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-d&amp;gt; :set scrolloff=50&amp;lt;CR&amp;gt;&amp;lt;C-d&amp;gt;:set scrolloff=0&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I understand your intention correct, then centring the screen with &lt;code&gt;zz&lt;/code&gt; may actually be more appropriate though:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-d&amp;gt; &amp;lt;C-d&amp;gt;zz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also see: &lt;a href=&quot;https://vi.stackexchange.com/q/40/51&quot;&gt;How do I center the current line in the screen?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend you read &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#key%2dmapping&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help key-mapping&lt;/code&gt;&lt;/a&gt; and/or &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/03.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;the appropriate chapters of Learn Vimscript the hard way&lt;/a&gt;, by the way.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-09-04T22:46:47.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9448" PostTypeId="1" CreationDate="2016-09-05T08:10:43.470" Score="1" ViewCount="62" Body="&lt;p&gt;I have a file containing lines in the following form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is line 1 and&#xA;this is line 2 and&#xA;this is line 4 and&#xA;this is line 8 and &#xA;23, and this 56 should not be yanked&#xA;this is line 9 and this is line 2 and this is line 1 &#xA;all numbers not followed 'line' should not copied like this one 23&#xA;and this is line 8 but it's duplicated so as the 2 and 1 above. &#xA;line 3&#xA;and so on ....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to find all numbers, unique the better, &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt;, &lt;code&gt;4&lt;/code&gt;, &lt;code&gt;8&lt;/code&gt;, &lt;code&gt;9&lt;/code&gt;, &lt;code&gt;3&lt;/code&gt; and store them in a register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:g/\vline (\d)/y B&lt;/code&gt;, which yanks all the whole lines which contain the pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s/\vline (\d)/\setreg('B', submatch(1))/n&lt;/code&gt;, which result in nothing except I change &lt;code&gt;1&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt; (and what is in the register is the same as the previous one)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am wondering if I can yank only what I want in lines and store them into the register? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this question is at least not duplicated, I want to edit it to get an answer. The requirements become 2:&lt;br&gt;&#xA;1. improvement to the second solution in this question, except or include the typo.&lt;br&gt;&#xA;2. add the unique feature. That's the matched strings in the register should be unique. I have raised a &lt;a href=&quot;https://vi.stackexchange.com/q/8906/1788&quot;&gt;related question&lt;/a&gt; on this point but I have not found an elegant solution. I mean a command is better than a multi-line script.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks very much. &lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-09-06T08:09:33.160" Title="Yank only matched unique strings of a pattern in lines to a register?" Tags="|cut-copy-paste|register|" AnswerCount="0" CommentCount="10" ClosedDate="2016-09-06T09:37:25.677" ContentLicense="CC BY-SA 3.0" />
  <row Id="9449" PostTypeId="2" ParentId="9438" CreationDate="2016-09-05T08:59:24.110" Score="2" Body="&lt;p&gt;You're looking for &lt;code&gt;getchar()&lt;/code&gt;. Since that usually returns a number, convert the result back to a String:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let char = nr2char(getchar())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not a full equivalent of what the built-in &lt;code&gt;f&lt;/code&gt; does; for example, it doesn't handle &lt;em&gt;digraphs&lt;/em&gt; (i.e. &lt;code&gt;&amp;lt;C-K&amp;gt;xy&lt;/code&gt; combinations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use this in a mapping, ensure that all keys from the mapping have been consumed, or wrap the &lt;code&gt;getchar()&lt;/code&gt; around &lt;code&gt;inputsave()&lt;/code&gt; / &lt;code&gt;inputrestore()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-05T08:59:24.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9450" PostTypeId="2" ParentId="9425" CreationDate="2016-09-05T09:12:45.667" Score="4" Body="&lt;p&gt;Think of &lt;code&gt;'softtabstop'&lt;/code&gt; as an additional control over &lt;code&gt;'tabstop'&lt;/code&gt;, allowing you to reach indents &quot;in between&quot; tab stops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With your indent setting, you don't actually need that, so the value of &lt;code&gt;'softtabstop'&lt;/code&gt; doesn't really matter: You can set it to &lt;code&gt;0&lt;/code&gt;, turning this off, set this equal to &lt;code&gt;'tabstop'&lt;/code&gt;, in which case the effect is the same as off, or &lt;code&gt;:set softtabstop=-1 shiftwidth=0&lt;/code&gt;, and both will follow the &lt;code&gt;'tabstop'&lt;/code&gt; setting.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-05T09:12:45.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9451" PostTypeId="2" ParentId="9424" CreationDate="2016-09-05T09:16:29.160" Score="2" Body="&lt;p&gt;Plugin managers like Pathogen add each subdirectory of &lt;code&gt;.vim/bundle/&lt;/code&gt; to the &lt;code&gt;'runtimepath'&lt;/code&gt;. If a syntax plugin has the proper &lt;code&gt;syntax/foo.vim&lt;/code&gt; (or &lt;code&gt;after/syntax/foo.vim&lt;/code&gt;) structure in its repository, it will work just like regular plugins (which need to use the &lt;code&gt;plugin/&lt;/code&gt; and &lt;code&gt;autoload/&lt;/code&gt; subdirs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;code&gt;:scriptnames&lt;/code&gt; command to see what Vim actually loaded, and check the runtimepath via &lt;code&gt;:set rtp?&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-05T09:16:29.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9452" PostTypeId="1" AcceptedAnswerId="9453" CreationDate="2016-09-05T13:45:29.423" Score="2" ViewCount="155" Body="&lt;p&gt;I'm trying to automate the creation of .vimrc using this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf &quot;\n# Funcionar como vim y no como vi\nset nocompatible\n\n# Colorear sintaxis\nsyntax on\ncolorscheme sienna\n\n# Otros seteos\n# Más info, desde vim poner: :help '&amp;lt;comando&amp;gt;'\nset backspace=2\nset wrapmargin=8\nset ruler\nset number\n&quot; &amp;gt; ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get this error: &lt;code&gt;E488&lt;/code&gt; in lines 2, 5 9 and 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The .vimrc file after the execution is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Funcionar como vim y no como vi&#xA;set nocompatible&#xA;&#xA;# Colorear sintaxis&#xA;syntax on&#xA;colorscheme sienna&#xA;&#xA;# Otros seteos&#xA;# Más info, desde vim poner: :help '&amp;lt;comando&amp;gt;'&#xA;set backspace=2&#xA;set wrapmargin=8&#xA;set ruler&#xA;set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;" OwnerUserId="9133" LastEditorUserId="51" LastEditDate="2016-09-05T13:48:39.733" LastActivityDate="2016-09-05T13:48:39.733" Title="Why do I get an E488 error when printf .vimrc?" Tags="|vimrc|error|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9453" PostTypeId="2" ParentId="9452" CreationDate="2016-09-05T13:48:08.687" Score="7" Body="&lt;p&gt;&lt;code&gt;#&lt;/code&gt; is not a comment character, &lt;code&gt;&quot;&lt;/code&gt; is. So it should read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Funcionar como vim y no como vi&#xA;set nocompatible&#xA;&#xA;&quot; Colorear sintaxis&#xA;syntax on&#xA;colorscheme sienna&#xA;&#xA;&quot; Otros seteos&#xA;&quot; Más info, desde vim poner: :help '&amp;lt;comando&amp;gt;'&#xA;set backspace=2&#xA;set wrapmargin=8&#xA;set ruler&#xA;set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yeah, it's a strange choice, but it is what it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way to fix this in your shell command is to switch the shell quotes to &lt;code&gt;'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf '\n&quot; Funcionar como [...]'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; is a good resource to start learning Vim. &lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-09-05T13:48:08.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9454" PostTypeId="1" CreationDate="2016-09-06T04:56:24.767" Score="1" ViewCount="3368" Body="&lt;p&gt;I am relatively new to programming, and I built a mobile computer with a Pi at its heart to learn on the go. Ideally, I would use Vim as my IDE for Python 3. However, every attempt at installation results in Python not being recognized by Vim (via &lt;code&gt;vim --version&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My best guess is that I need to compile VIM by hand. I have no idea how to do so, and I haven't found anything online that can help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My OS is the Raspbian version of Debian.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any suggestions? Please explain like I'm 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TLDR:&lt;/strong&gt; Vim will not recognize Python 3, and I do not know why.&lt;/p&gt;&#xA;" OwnerUserId="9138" LastEditorUserId="1841" LastEditDate="2016-09-06T08:04:43.637" LastActivityDate="2016-09-07T07:31:20.063" Title="Python integration in Vim on Raspberry Pi" Tags="|linux|vimscript-python|installing|linux-debian|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9455" PostTypeId="1" AcceptedAnswerId="9459" CreationDate="2016-09-06T05:01:51.883" Score="76" ViewCount="31249" Body="&lt;p&gt;I understand how &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html&quot; rel=&quot;noreferrer&quot;&gt;auto commands&lt;/a&gt; work, and how to use them, but I'm somewhat unsure of what augroup is for. I read in &lt;code&gt;:help augroup&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;                                                    *:aug* *:augroup*&#xA;:aug[roup] {name}               Define the autocmd group name for the&#xA;                                following &amp;quot;:autocmd&amp;quot; commands.  The name &amp;quot;end&amp;quot;&#xA;                                or &amp;quot;END&amp;quot; selects the default group.&#xA;                                To avoid confusion, the name should be&#xA;                                different from existing {event} names, as this&#xA;                                most likely will not do what you intended.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This doesn't really explain why they are useful, or why I would ever want to make an autocommand group name over just defining a bunch of autocommands next to each other.&lt;/p&gt;&#xA;&lt;p&gt;For example, if autocommands &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;bar&lt;/code&gt; are related, why would I want to do&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup spam&#xA;  au!&#xA;  au foo * foo&#xA;  au bar * bar&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;when I could just do&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;Autocommands for spam&#xA;au foo * foo&#xA;au bar * bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Unless I'm misunderstanding what augroups are really for. So why are they useful?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="1238" LastEditDate="2020-08-09T17:20:30.570" LastActivityDate="2022-03-28T06:56:20.797" Title="Why should I use augroup?" Tags="|autocmd|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9456" PostTypeId="5" CreationDate="2016-09-06T05:13:51.727" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-09-06T05:13:51.727" LastActivityDate="2016-09-06T05:13:51.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9457" PostTypeId="4" CreationDate="2016-09-06T05:13:51.727" Score="0" Body="For questions specific to using vim on the Debian operating system. Note that unless your question is specific to Debian, you should use the more general &quot;Linux&quot; tag" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-09-06T09:28:59.237" LastActivityDate="2016-09-06T09:28:59.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9458" PostTypeId="2" ParentId="9455" CreationDate="2016-09-06T06:26:08.037" Score="39" Body="&lt;p&gt;Autocommand groups give you the opportunity to organize your autocommands, which is a quite useful feature in and of itself.&lt;/p&gt;&#xA;&lt;p&gt;Say you are writing a plugin. Grouping your plugin's autocommands under your own namespace makes sense, if only because it lets you enable/disable your autocommands at will.&lt;/p&gt;&#xA;&lt;p&gt;Your &lt;code&gt;vimrc&lt;/code&gt; is not fundamentally different from a &lt;code&gt;plugin/foo.vim&lt;/code&gt; so, all you get with autocommand groups is basically more control over your setup.&lt;/p&gt;&#xA;&lt;p&gt;In practice…&lt;/p&gt;&#xA;&lt;p&gt;If you don't assign them to a group, autocommands are &amp;quot;installed&amp;quot; in the global group by default. Installing related autocommands in their own group not only makes things clearer but it allows you to prevent the dreaded &amp;quot;pile-up&amp;quot; effect very easily and with a single &lt;code&gt;!&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup spam             versus    autocmd! Foo * foo&#xA;    autocmd!                       autocmd! Bar * bar&#xA;    autocmd Foo * foo&#xA;    autocmd Bar * bar&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;On the left, the whole group is uninstalled at once, before each autocommand of that group is properly installed. Neat.&lt;/p&gt;&#xA;&lt;p&gt;On the right, Vim will wastefully run through the same &amp;quot;uninstall/install&amp;quot; routine for each autocommand. Dirty.&lt;/p&gt;&#xA;&lt;p&gt;But you don't have to write that whole block every time if you don't want to. Autocommands can be assigned &lt;em&gt;directly&lt;/em&gt; to a group so you can define a group somewhere:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup spam&#xA;    autocmd!&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and put your autocommands where you want, even in another script:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd spam Foo * foo&#xA;autocmd spam Bar * bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This would give you:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;namespacing&lt;/li&gt;&#xA;&lt;li&gt;pile-up prevention&lt;/li&gt;&#xA;&lt;li&gt;order&lt;/li&gt;&#xA;&lt;li&gt;flexibility&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;---  EDIT ---&lt;/p&gt;&#xA;&lt;p&gt;Grouping autocommands is not the only way to prevent the pile-up problem. If you don't like the &lt;code&gt;augroup&lt;/code&gt; ceremonial, you can simply append a &lt;code&gt;!&lt;/code&gt; to &lt;code&gt;:autocmd&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! Foo * foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to uninstall &lt;em&gt;any&lt;/em&gt; already installed autocommand on the &lt;code&gt;Foo&lt;/code&gt; event &lt;em&gt;and&lt;/em&gt; the &lt;code&gt;*&lt;/code&gt; pattern before adding a new one. It definitely works in the simplest cases but it doesn't scale up very well.&lt;/p&gt;&#xA;&lt;p&gt;It is too easy to fall into the habit of using that &lt;code&gt;!&lt;/code&gt; systematically, thinking it's a silver bullet, and create hard to debug problems down the line. For example, the snippet below installs two autocommands in the user's &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; line 23 of ~/.vimrc&#xA;autocmd! Syntax * echom 'hi_1'&#xA;&#xA;&amp;quot; line 414&#xA;autocmd! Syntax * echom 'hi_2' | echom 'hi_3'            &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But the second autocommand will uninstall the first one and only one will be executed in the end… an issue easily avoided with a group:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; line 10 of ~/.vimrc&#xA;augroup MyStuff&#xA;    autocmd!&#xA;augroup&#xA;&#xA;&amp;quot; line 26&#xA;autocmd MyStuff Syntax * echom 'hi_1'&#xA;&#xA;&amp;quot; line 417&#xA;autocmd MyStuff Syntax * echom 'hi_2' | echom 'hi_3'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2022-03-28T06:56:20.797" LastActivityDate="2022-03-28T06:56:20.797" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9459" PostTypeId="2" ParentId="9455" CreationDate="2016-09-06T06:31:27.180" Score="74" Body="&lt;p&gt;The main reason to use &lt;code&gt;augroup&lt;/code&gt;s is to allow greater control over ranges of autocommands, e.g. to delete a bunch of autocommands in one go. A common pattern is to use the &lt;code&gt;au!&lt;/code&gt; as the first part of a group. This removes all existing autocommands in the group, and allows one to start afresh. If you did not use a group, then &lt;code&gt;au!&lt;/code&gt; would remove all/many autocommands that you did not want to remove.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Deleting autocommands is actually quite common, for instance in plugins, because this allows one to source a plugin/ftplugin multiple times. If you did not delete the autocommands, then each time you sourced the plugin/ftplugin you would add a new copy of the same autocommand. This is also true for your &lt;code&gt;vimrc&lt;/code&gt; file. By using a group in your vimrc file, it becomes safe to reload it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info, see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_40.html#40.3&quot;&gt;&lt;code&gt;:h 40.3&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-09-06T06:31:27.180" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9460" PostTypeId="2" ParentId="9454" CreationDate="2016-09-06T07:53:42.787" Score="3" Body="&lt;p&gt;If you are looking for a terminal version of vim which supports python (alongs with Lua, Perl, Ruby, and Tcl) without a GUI. I'd recommend to use the &lt;a href=&quot;https://packages.debian.org/sid/vim-nox&quot; rel=&quot;nofollow&quot;&gt;vim-nox package&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can install it with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install vim-nox&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are looking for a GUI version &lt;a href=&quot;https://packages.debian.org/jessie/vim-gnome&quot; rel=&quot;nofollow&quot;&gt;vim-gnome&lt;/a&gt; is what you are looking for.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install vim-gnome&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Foot page note&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before using &lt;code&gt;apt-get install&lt;/code&gt; you should call &lt;code&gt;apt-get update&lt;/code&gt;, this will update the list of packages available. This is off topic for this site but &lt;a href=&quot;https://www.digitalocean.com/community/tutorials/how-to-manage-packages-in-ubuntu-and-debian-with-apt-get-apt-cache&quot; rel=&quot;nofollow&quot;&gt;digital ocean&lt;/a&gt; has a simple tutorial to get started with &lt;code&gt;apt-get&lt;/code&gt; commands and &lt;a href=&quot;https://help.ubuntu.com/community/AptGet/Howto&quot; rel=&quot;nofollow&quot;&gt;ubuntu.com&lt;/a&gt; provides a list of the useful commands. &lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-09-07T07:31:20.063" LastActivityDate="2016-09-07T07:31:20.063" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9462" PostTypeId="1" AcceptedAnswerId="9463" CreationDate="2016-09-06T08:39:01.363" Score="1" ViewCount="242" Body="&lt;p&gt;I would like to map &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; in select mode to indent my selection. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -u /dev/null&#xA;:set nocompatible&#xA;:behave mswin&#xA;:xnoremap &amp;lt;Tab&amp;gt;   &amp;gt;gv&#xA;:xnoremap &amp;lt;S-Tab&amp;gt; &amp;lt;gv&#xA;:snoremap &amp;lt;Tab&amp;gt; &amp;lt;C-g&amp;gt;&amp;gt;gvV&amp;lt;C-g&amp;gt;&#xA;:snoremap &amp;lt;S-Tab&amp;gt; &amp;lt;C-g&amp;gt;&amp;lt;gvV&amp;lt;C-g&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to switch to &lt;code&gt;S-LINE&lt;/code&gt; or &lt;code&gt;V-LINE&lt;/code&gt; when identing. The problem with the above mapping is the &lt;code&gt;V&lt;/code&gt; will toggle between &lt;code&gt;VISUAL&lt;/code&gt; -&gt; &lt;code&gt;V-LINE&lt;/code&gt; -&gt; &lt;code&gt;NORMAL&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I correct these mappings?&lt;/p&gt;&#xA;" OwnerUserId="2548" LastEditorUserId="2548" LastEditDate="2016-09-06T09:57:02.717" LastActivityDate="2016-09-06T09:57:02.717" Title="How to use &lt;Tab&gt; to indent code in select mode?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9463" PostTypeId="2" ParentId="9462" CreationDate="2016-09-06T09:00:54.997" Score="3" Body="&lt;p&gt;In visual mode, you only need one &lt;code&gt;&amp;gt;&lt;/code&gt; to indent. &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; is the normal mode command. Also, &lt;code&gt;V&lt;/code&gt; turns a non-linewise selection into a linewise one, but if the selection already is linewise, visual mode will end. Better drop that. These changes result in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snoremap &amp;lt;Tab&amp;gt; &amp;lt;Esc&amp;gt;gv&amp;gt;gv&amp;lt;C-g&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Actually, you can further simplify; there's no need to leave select mode and then restore the selection in visual mode via &lt;code&gt;&amp;lt;Esc&amp;gt;gv&lt;/code&gt;; just use &lt;code&gt;&amp;lt;C-g&amp;gt;&lt;/code&gt; to switch from select to visual mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snoremap &amp;lt;Tab&amp;gt; &amp;lt;C-g&amp;gt;&amp;gt;gv&amp;lt;C-g&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-06T09:00:54.997" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9464" PostTypeId="1" CreationDate="2016-09-06T09:16:37.700" Score="4" ViewCount="936" Body="&lt;p&gt;I would like to write a syntax highlighter for a language like this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;block1 {&#xA;   keyword1 value;&#xA;   keyword2 value;&#xA;&#xA;   sub_block1 {&#xA;      keyword3 value;&#xA;   }&#xA;}&#xA;block2 {&#xA;   keyword1 value;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A block starts with a name followed by an opening brace (e.g. &lt;code&gt;block1 {&lt;/code&gt;) and ends with a closing brace &lt;code&gt;}&lt;/code&gt;. The block names and the keywords are specified by the language (authorized keywords and block names).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like C language, this language is not sensitive to line break, multiple spaces or tabs and a line ends with a &lt;code&gt;;&lt;/code&gt;, except for block ends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A block contains authorized keywords followed by values. It may also contains authorized sub-blocks. Note that a sub-block can contain sub-sub-blocks with its own authorized keywords.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to highlight only authorized keywords or sub-blocks in a given block. I already wrote a syntax highlighter that highlight all the block names, but I am not able to tell vim to not highlight certain keywords or sub-blocks in a given block. By the way, I do not know how to detect if a given keyword or sub-block is in a given block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my current syntax highlighter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Vim syntax file&#xA;&quot; Language: Notus&#xA;&quot; Mantainer: Antoine Lemoine&#xA;&quot; Last Change: 13 June 2016&#xA;&#xA;if exists(&quot;b:current_syntax&quot;)&#xA;  finish&#xA;endif&#xA;&#xA;syn keyword notusTodo               contained TODO FIXME XXX&#xA;&#xA;syn keyword notusBooleanValues      true false&#xA;&#xA;syn keyword notusConditional        if else&#xA;syn keyword notusRepeat             while exit&#xA;&#xA;syn keyword notusMathKeyword        abs ceil floor cos sin tan acos asin atan atan2 cosh sinh tanh acosh asinh atanh erf erfc exp log sqrt i2s pow modulo&#xA;syn keyword notusDeclaration        double integer boolean string define&#xA;syn keyword notusInclude            include std&#xA;syn keyword notusOutput             print export&#xA;syn match   notusInternalLanguage   &quot;\k\@&amp;lt;!@\(double\|integer\|boolean\|return\|if\|else\|elseif\|exit\|while\|x\|y\|z\|t\)\&amp;gt;&quot;&#xA;&#xA;syn region  notusStringS            start=+'+ skip=+\\\\\|\\&quot;+ end=+'+&#xA;syn region  notusStringD            start=+&quot;+ skip=+\\\\\|\\&quot;+ end=+&quot;+&#xA;&#xA;syn match   notusOperator           &quot;\(+\|-\|/\|\*\)&quot;&#xA;syn match   notusOperator           &quot;\(\(&amp;gt;\|&amp;lt;\)=\=\|==\|!=\|=\||\|&amp;amp;\|!\)&quot;&#xA;syn match   notusOperator           &quot;\(?\|:\)&quot;&#xA;&#xA;syn match   notusComment            &quot;#.*&quot; contains=notusTodo&#xA;syn match   notusComment            &quot;\s#.*&quot; contains=notusTodo&#xA;&#xA;&quot; Integers&#xA;syn match   notusNumber             display &quot;\&amp;lt;\d\+\(_\a\w*\)\=\&amp;gt;&quot;&#xA;&quot; floating point number, without a decimal point&#xA;syn match   notusFloatIll           display &quot;\&amp;lt;\d\+[deDE][-+]\=\d\+\(_\a\w*\)\=\&amp;gt;&quot;&#xA;&quot; floating point number, starting with a decimal point&#xA;syn match   notusFloatIll           display &quot;\.\d\+\([deDE][-+]\=\d\+\)\=\(_\a\w*\)\=\&amp;gt;&quot;&#xA;&quot; floating point number, no digits after decimal&#xA;syn match   notusFloatIll           display &quot;\&amp;lt;\d\+\.\([deDE][-+]\=\d\+\)\=\(_\a\w*\)\=\&amp;gt;&quot;&#xA;&quot; floating point number, D or Q exponents&#xA;syn match   notusFloatIll           display &quot;\&amp;lt;\d\+\.\d\+\([dD][-+]\=\d\+\)\=\(_\a\w*\)\=\&amp;gt;&quot;&#xA;&quot; floating point number&#xA;syn match   notusFloat              display &quot;\&amp;lt;\d\+\.\d\+\([eE][-+]\=\d\+\)\=\(_\a\w*\)\=\&amp;gt;&quot;&#xA;&#xA;&quot;-------------------------------------------------------------&#xA;&quot; Keywords per block&#xA;&#xA;&quot; Initial condition block&#xA;syn keyword notusKwIni              circle rectangle polygon surface_mesh union intersection difference shape instructions shaped_instructions&#xA;&#xA;&quot; Solver block&#xA;syn keyword notusKwSolver           preconditioner&#xA;&#xA;&quot; Main block&#xA;syn keyword notusKwMain             domain grid modeling numerical_parameters post_processing&#xA;&#xA;&quot;&quot; Domain block&#xA;syn keyword notusKwDomain           immersed_boundary&#xA;&#xA;&quot;&quot; Domain immersed_boundary&#xA;syn keyword notusKwIBD              shape&#xA;&#xA;&quot;&quot; Grid block&#xA;syn keyword notusKwGrid             grid_x grid_y grid_z&#xA;&#xA;&quot;&quot; Modeling block&#xA;syn keyword notusKwMod              fluids species equations&#xA;&#xA;&quot;&quot;&quot; Fluids block&#xA;syn keyword notusKwFluids           fluid&#xA;&#xA;&quot;&quot;&quot; Species block&#xA;syn keyword notusKwSpecies          species&#xA;&#xA;&quot;&quot;&quot; Equations block&#xA;syn keyword notusKwEq               navier_stokes energy phase_advection species_transport&#xA;&#xA;&quot;&quot;&quot;&quot; Navier-Stokes block&#xA;syn keyword notusKwModNS            capilarity_term boundary_condition initial_condition_x initial_condition_y initial_condition_z immerserd_boundary_condition&#xA;&#xA;&quot;&quot;&quot;&quot; Energy block&#xA;syn keyword notusKwModEn            initial_condition boundary_condition immersed_boundary_condition phase_change linear_term source_term velocity_field&#xA;&#xA;&quot;&quot;&quot;&quot; Phase advection block&#xA;syn keyword notusKwModAdv           fluid velocity_field&#xA;&#xA;&quot;&quot;&quot;&quot;&quot; Fluid block&#xA;syn keyword notusKwModAdvFluid      boundary_condition initial_condition immersed_boundary_condition&#xA;&#xA;&quot;&quot;&quot;&quot; Species transport block&#xA;syn keyword notusKwModSpecies       species velocity_field&#xA;&#xA;&quot;&quot;&quot;&quot;&quot; Species block&#xA;syn keyword notusKwModAdvSpecies    boundary_condition initial_condition immersed_boundary_condition linear_term source_term&#xA;&#xA;&quot;&quot; Numerical parameters block&#xA;syn keyword notusKwNum              navier_stokes energy phase_advection species_transport stop_tests&#xA;&#xA;&quot;&quot;&quot; Navier-Stokes block&#xA;syn keyword notusKwNPNS             solver_pressure solver_momentum solver_ibd_extrapolation&#xA;&#xA;&quot;&quot;&quot; Energy block&#xA;syn keyword notusKwNPEnergy         solver&#xA;&#xA;&quot;&quot;&quot; Species transport block&#xA;syn keyword notusKwNPSpecies        species&#xA;&#xA;&quot;&quot;&quot;&quot; Species transport block&#xA;syn keyword notusKwNPSpeciesP       solver&#xA;&#xA;&quot;&quot;&quot; Phase advection block&#xA;syn keyword notusKwNPAdv            vof_plic mof level_set&#xA;&#xA;&quot;&quot; Post-processing block&#xA;syn keyword notusKwPostProc         validation&#xA;&#xA;hi def link notusComment            Comment&#xA;hi def link notusTodo               Todo&#xA;hi def link notusDeclaration        Type&#xA;hi def link notusOperator           Operator&#xA;hi def link notusNumber             Number&#xA;hi def link notusFloatIll           Number&#xA;hi def link notusBooleanValues      Number&#xA;hi def link notusFloat              Number&#xA;hi def link notusRepeat             Repeat&#xA;hi def link notusConditional        Conditional&#xA;hi def link notusInternalLanguage   Function&#xA;hi def link notusMathKeyword        Function&#xA;hi def link notusInclude            Function&#xA;hi def link notusOutput             Function&#xA;hi def link notusStringS            String&#xA;hi def link notusStringD            String&#xA;hi def link notusKwIni              Keyword&#xA;hi def link notusKwSolver           Keyword&#xA;hi def link notusKwMain             Keyword&#xA;hi def link notusKwDomain           Keyword&#xA;hi def link notusKwIBD              Keyword&#xA;hi def link notusKwGrid             Keyword&#xA;hi def link notusKwMod              Keyword&#xA;hi def link notusKwFluids           Keyword&#xA;hi def link notusKwSpecies          Keyword&#xA;hi def link notusKwEq               Keyword&#xA;hi def link notusKwModNS            Keyword&#xA;hi def link notusKwModEn            Keyword&#xA;hi def link notusKwModAdv           Keyword&#xA;hi def link notusKwModAdvFluid      Keyword&#xA;hi def link notusKwModSpecies       Keyword&#xA;hi def link notusKwModAdvSpecies    Keyword&#xA;hi def link notusKwNum              Keyword&#xA;hi def link notusKwNPNS             Keyword&#xA;hi def link notusKwNPEnergy         Keyword&#xA;hi def link notusKwNPSpecies        Keyword&#xA;hi def link notusKwNPSpeciesP       Keyword&#xA;hi def link notusKwNPAdv            Keyword&#xA;hi def link notusKwPostProc         Keyword&#xA;&#xA;let b:current_syntax=&quot;nts&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A pseudo documentation of the language can be found in &lt;a href=&quot;http://notus-cfd.org/doc/d5/dbc/user_ui.html&quot; rel=&quot;nofollow&quot;&gt;http://notus-cfd.org/doc/d5/dbc/user_ui.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any syntax file that do similar work in the vim files? Do you have any idea on how to create such a syntax highlighter?&lt;/p&gt;&#xA;" OwnerUserId="9143" LastEditorUserId="9143" LastEditDate="2016-09-06T15:47:12.780" LastActivityDate="2016-12-05T18:07:02.117" Title="Syntax highlighting with nested braces and forbidden keywords" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9465" PostTypeId="2" ParentId="9455" CreationDate="2016-09-06T10:01:53.673" Score="27" Body="&lt;p&gt;Aside from the other answers, I find that the most immediate practical benefit is that it makes it easy to reload vimscript files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example stick this in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufCreate * echom &quot;New buffer!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Quit, restart, make a new buffer. you see &lt;code&gt;New buffer!&lt;/code&gt;, which you can verify with &lt;code&gt;:messages&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now reload your vimrc: &lt;code&gt;:source $MYVIMRC&lt;/code&gt;, and again make a new buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do you see now?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Had I used this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup inform_new_buffer&#xA;    autocmd!&#xA;    autocmd BufCreate * echom &quot;New buffer!&quot;&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I would have been fine. I make a group of autocommands, the &lt;code&gt;autocmd!&lt;/code&gt; command clear all defined autocommands &lt;em&gt;in that group&lt;/em&gt;. That is important, because:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup inform_new_buffer&#xA;    autocmd BufCreate * echom &quot;New buffer!&quot;&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would just &lt;em&gt;add&lt;/em&gt; it to the same augroup.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In other words, it's the same reason we all type &lt;code&gt;fun!&lt;/code&gt; and &lt;code&gt;command!&lt;/code&gt;, rather than the versions without the &lt;code&gt;!&lt;/code&gt; that don't allow overriding.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="2920" LastEditDate="2016-09-12T19:11:08.563" LastActivityDate="2016-09-12T19:11:08.563" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9466" PostTypeId="1" AcceptedAnswerId="9467" CreationDate="2016-09-06T11:32:53.267" Score="1" ViewCount="37" Body="&lt;p&gt;If I am in the middle of the buffer and want to append external file data to the current buffer.&#xA;So far I move to end of the file with &lt;code&gt;G&lt;/code&gt; and reading the data &lt;code&gt;:r file&lt;/code&gt; so it is doing the work ...... &#xA;Is there any standard style of &lt;code&gt;vim&lt;/code&gt; reading &lt;/p&gt;&#xA;" OwnerUserId="8480" LastActivityDate="2016-09-06T11:41:41.383" Title="Reading external file data at the end of the buffer" Tags="|buffers|normal-mode|filesystem|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9467" PostTypeId="2" ParentId="9466" CreationDate="2016-09-06T11:41:41.383" Score="4" Body="&lt;p&gt;Are you looking for &lt;code&gt;:$r file&lt;/code&gt;? -- which will move the cursor. Don't forget to play with marks I often use &lt;code&gt;mx&lt;/code&gt; to mark and &lt;code&gt;'x&lt;/code&gt; to come back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use: &lt;code&gt;:call append('$', readfile('file'))&lt;/code&gt; -- which won't move the cursor. This is what we prefer to use when writing scripts nowadays.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-09-06T11:41:41.383" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9468" PostTypeId="1" AcceptedAnswerId="9470" CreationDate="2016-09-06T15:24:54.450" Score="4" ViewCount="2829" Body="&lt;p&gt;I have installed &lt;a href=&quot;https://github.com/Shougo/deoplete.nvim&quot; rel=&quot;nofollow&quot;&gt;deoplete&lt;/a&gt; plugin into my Neovim using &lt;a href=&quot;https://github.com/Shougo/dein.vim&quot; rel=&quot;nofollow&quot;&gt;dein&lt;/a&gt;. I have put &lt;code&gt;let g:deoplete#enable_at_startup = 1&lt;/code&gt; into my &lt;code&gt;init.vim&lt;/code&gt; and I can see the autocomplete list when I type in the insert mode - so far so good. However I am not able to autocomplete the word I am typing from the list which has appeared (I guess it should be done using Tab but none of the keys I tried worked). I am a Vim beginner so I am actually getting lost now. &lt;/p&gt;&#xA;" OwnerUserId="9149" LastActivityDate="2016-09-15T16:17:07.543" Title="Can't get deoplete plugin working in Neovim" Tags="|neovim|plugin-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9469" PostTypeId="2" ParentId="9464" CreationDate="2016-09-06T16:27:43.047" Score="2" Body="&lt;p&gt;If I understand you correctly, you only want detection of the &lt;code&gt;{...}&lt;/code&gt; blocks if they are preceded by certain authorized names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would approach this via keyword matches of the names, which then instruct Vim to try a match with a following block (the &lt;code&gt;skip...&lt;/code&gt; arguments allow for whitespace and new lines in between):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword myName block1 skipwhite skipnl skipempty nextgroup=myBlock&#xA;syn keyword myName sub_block1 skipwhite skipnl skipempty nextgroup=myBlock&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The block definition is a simple region; it is &lt;code&gt;contained&lt;/code&gt; so that it doesn't match on its own, only initiated by the &lt;code&gt;nextgroup=myBlock&lt;/code&gt; from above. It needs to &lt;code&gt;contains=&lt;/code&gt; all elements that can be nested; here, just the authorized names.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region myBlock start=&quot;{&quot; end=&quot;}&quot; contained contains=myName&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-06T16:27:43.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9470" PostTypeId="2" ParentId="9468" CreationDate="2016-09-06T17:19:54.993" Score="6" Body="&lt;p&gt;Vim uses &lt;code&gt;Ctrl-n&lt;/code&gt; (next item) and &lt;code&gt;Ctrl-p&lt;/code&gt; (previous item), &lt;code&gt;Ctrl-y&lt;/code&gt; (accept match) or &lt;code&gt;Ctrl-e&lt;/code&gt; (cancel) and so on for completion. See &lt;code&gt;:h ins-completion-menu&lt;/code&gt; and &lt;code&gt;:h popupmenu-keys&lt;/code&gt; for details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following &lt;code&gt;deoplete&lt;/code&gt; settings may help (they use &lt;code&gt;Tab&lt;/code&gt;, &lt;code&gt;Enter&lt;/code&gt; and &lt;code&gt;Esc&lt;/code&gt;) - see the comments for what they do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;use &amp;lt;tab&amp;gt; for completion&#xA;function! TabWrap()&#xA;    if pumvisible()&#xA;        return &quot;\&amp;lt;C-N&amp;gt;&quot;&#xA;    elseif strpart( getline('.'), 0, col('.') - 1 ) =~ '^\s*$'&#xA;        return &quot;\&amp;lt;tab&amp;gt;&quot;&#xA;    elseif &amp;amp;omnifunc !~ ''&#xA;        return &quot;\&amp;lt;C-X&amp;gt;\&amp;lt;C-O&amp;gt;&quot;&#xA;    else&#xA;        return &quot;\&amp;lt;C-N&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot; power tab&#xA;imap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt;&amp;lt;tab&amp;gt; TabWrap()&#xA;&#xA;&quot; Enter: complete&amp;amp;close popup if visible (so next Enter works); else: break undo&#xA;inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;Cr&amp;gt; pumvisible() ?&#xA;            \ deoplete#mappings#close_popup() : &quot;&amp;lt;C-g&amp;gt;u&amp;lt;Cr&amp;gt;&quot;&#xA;&#xA;&quot; Ctrl-Space: summon FULL (synced) autocompletion&#xA;inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;C-Space&amp;gt; deoplete#mappings#manual_complete()&#xA;&#xA;&quot; Escape: exit autocompletion, go to Normal mode&#xA;inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;Esc&amp;gt; pumvisible() ? &quot;&amp;lt;C-e&amp;gt;&amp;lt;Esc&amp;gt;&quot; : &quot;&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-09-06T17:19:54.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9471" PostTypeId="1" AcceptedAnswerId="9518" CreationDate="2016-09-06T20:44:07.807" Score="6" ViewCount="7301" Body="&lt;p&gt;I have bash script which Vim detects as a &lt;code&gt;sh&lt;/code&gt; according to &lt;code&gt;:set filetype?&lt;/code&gt;. In addition, Vim-script for auto-indention support for shell-scripts(&lt;code&gt;/usr/share/vim/vim74/indent/sh.vim&lt;/code&gt;) is also present. However, for example following while loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while read -ra line&quot;$line_id&quot;_fields; do&#xA;  line_id=$((line_id+1))&#xA;done &amp;lt; &quot;$1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;..is auto intended(&lt;code&gt;gg=G&lt;/code&gt;) to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  while read -ra line&quot;$line_id&quot;_fields; do&#xA;line_id=$((line_id+1))&#xA;  done &amp;lt; &quot;$1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What might cause this?&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2016-09-12T06:52:28.607" Title="incorrect auto-indent in bash code" Tags="|indentation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9472" PostTypeId="2" ParentId="106" CreationDate="2016-09-07T02:50:53.130" Score="6" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/farmergreg/vim-lastplace&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-lastplace&lt;/a&gt; plugin does exactly what you want (I am the author). It improves on the above code snippet by handling commit messages intelligently. If you have debian-testing you can apt-get install vim-lastplace to quickly try it out.&lt;/p&gt;&#xA;" OwnerUserId="9153" LastEditorUserId="9153" LastEditDate="2017-02-18T19:48:31.267" LastActivityDate="2017-02-18T19:48:31.267" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9473" PostTypeId="2" ParentId="9425" CreationDate="2016-09-07T03:05:37.693" Score="6" Body="&lt;p&gt;As mentioned in &lt;code&gt;:h softtabstop&lt;/code&gt;, the &lt;code&gt;softtabstop&lt;/code&gt; indicates how many columns vim uses when you enter &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; in &lt;strong&gt;insert mode&lt;/strong&gt;. Although it performs like &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; inserted, in fact, the vim mixes &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you hit &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; in insert mode, the vim will act like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if set expandtab&#xA;   always uses &amp;lt;BS&amp;gt;&#xA;else&#xA;   if softtabstop == 0&#xA;       always uses &amp;lt;Tab&amp;gt; // the number of columns is equal to tabstop&#xA;   else if softtabstop &amp;lt; 0&#xA;       the number of columns for &amp;lt;Tab&amp;gt; is equal to :shiftwidth&#xA;       &amp;amp;&amp;amp; uses a mix of &amp;lt;BS&amp;gt; and &amp;lt;Tab&amp;gt;&#xA;   else&#xA;       uses a mix of &amp;lt;BS&amp;gt; and &amp;lt;Tab&amp;gt;&#xA;   end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;:set noexpandtab shiftwidth=4 tabstop=4 softtabstop=2&lt;/code&gt; case, the value of &lt;code&gt;tabstop&lt;/code&gt; is large than the value of &lt;code&gt;softtabstop&lt;/code&gt;, the vim will use two &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; chars to represent one hit &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;:set noexpandtab shiftwidth=4 tabstop=2 softtabstop=2&lt;/code&gt; case, the value of &lt;code&gt;tabstop&lt;/code&gt; is equal to the value of &lt;code&gt;softtabstop&lt;/code&gt;, the vim will use one &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; char to perform one hit &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;:set noexpandtab shiftwidth=4 tabstop=2 softtabstop=3&lt;/code&gt; case, the value of &lt;code&gt;tabstop&lt;/code&gt; is less than the value of &lt;code&gt;softtabstop&lt;/code&gt;, the vim will use one &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; char and one &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; char to perform one hit &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;:set noexpandtab shiftwidth=4 tabstop=2 softtabstop=0&lt;/code&gt; case, the value of &lt;code&gt;softtabstop&lt;/code&gt; is zero, the vim always uses &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, &lt;strong&gt;in your case&lt;/strong&gt;, &lt;code&gt;:set noexpandtab shiftwidth=4 tabstop=4 softtabstop=0&lt;/code&gt; &lt;strong&gt;does&lt;/strong&gt; equal to &lt;code&gt;:set noexpandtab shiftwidth=4 tabstop=4 softtabstop=4&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion, it's better to use &lt;code&gt;tabstop == softtabstop&lt;/code&gt; if you want to handle with &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;. Because the vim will not use a mix solution.&lt;/p&gt;&#xA;" OwnerUserId="9127" LastEditorUserId="9127" LastEditDate="2016-09-07T07:43:48.943" LastActivityDate="2016-09-07T07:43:48.943" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9474" PostTypeId="1" AcceptedAnswerId="9477" CreationDate="2016-09-07T04:29:53.263" Score="1" ViewCount="77" Body="&lt;p&gt;I am trying to implement a custom folding function in a way that precomputes all the folds in a single pass and then reports the required foldlevels as needed. To do so, I use a single dictionary that keeps the state and provides functions to work with its internals (inspired by &lt;a href=&quot;http://bling.github.io/blog/2013/08/16/modularizing-vimscript/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;, &lt;a href=&quot;http://ujihisa.blogspot.cz/2010/11/something-like-closure-for-vim-script.html&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, unless I am constantly updating the foldexpr as the file changes, I don't get any folding done (foldexpr keeps the older version of the passed dictionary / function?..) (see ex. below)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if there is a good way to implement this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! foldclass#new()&#xA;  let obj = {}&#xA;  let obj.foldlist = []&#xA;&#xA;  function! obj.updatefolds()&#xA;    let self.foldlist = []&#xA;    let curline = 1&#xA;    let totlines = line('$')&#xA;    let curdepth = 0&#xA;    while curline &amp;lt;= totlines&#xA;      let theline = getline(curline)&#xA;      if theline =~? '\v.*function.*\(.*\)'&#xA;        let curdepth = curdepth + 1&#xA;      endif&#xA;      let self.foldlist = self.foldlist + [curdepth]&#xA;      if theline =~? '\v.*endfunction.*'&#xA;        let curdepth = curdepth - 1&#xA;      endif&#xA;      let curline = curline + 1&#xA;    endwhile&#xA;  endfunction&#xA;&#xA;  function! obj.folder(lnum)&#xA;    if len(self.foldlist) == 0&#xA;      echom 'Still empty...'&#xA;      return 0&#xA;    endif&#xA;    return self.foldlist[a:lnum - 1]&#xA;  endfunction&#xA;&#xA;  return obj&#xA;endfunction&#xA;&#xA;let b:bufobj=foldclass#new()&#xA;setlocal foldmethod=expr&#xA;setlocal foldexpr=b:bufobj.folder(v:lnum)&#xA;&#xA;augroup autocmds&#xA;  autocmd!&#xA;  autocmd BufWritePost *.vim call b:bufobj.updatefolds()&#xA;  &quot;autocmd BufWritePost *.vim setlocal foldexpr=b:bufobj.folder(v:lnum)&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If I source the file as is, I get &quot;Still empty...&quot; in messages, but&#xA;echo b:bufobj shows that the foldlist is indeed updated based on the&#xA;file changes. &lt;/li&gt;&#xA;&lt;li&gt;If I uncomment the second to last line, it works as intended.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7612" LastActivityDate="2016-09-07T16:19:36.020" Title="Saving object state between foldlevel calls" Tags="|buffers|folding|setlocal|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9475" PostTypeId="1" CreationDate="2016-09-07T04:37:56.563" Score="1" ViewCount="67" Body="&lt;p&gt;Im experiencing some problems running a command that reports paths based on the $PWD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To correctly parse its output I need it to run from a different directory, however, I would rather not have to &lt;code&gt;cd&lt;/code&gt; into that path in the current &lt;code&gt;vim&lt;/code&gt; instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is there a way to do this which doesn't manipulate the working directory history?&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2016-09-07T05:20:21.290" Title="Is it possible to define the pwd for an external command runs in without changing VIM's pwd?" Tags="|path|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9476" PostTypeId="2" ParentId="9475" CreationDate="2016-09-07T05:20:21.290" Score="3" Body="&lt;p&gt;Yes, it's possible. You can run the command in a sub-shell (assuming that you're running in Unix and not Windows) and include a &lt;code&gt;cd&lt;/code&gt; command at the start of the sub-shell. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!(cd /usr/local; ls)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even simpler,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!cd /usr/local; ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2016-09-07T05:20:21.290" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9477" PostTypeId="2" ParentId="9474" CreationDate="2016-09-07T08:56:13.053" Score="0" Body="&lt;p&gt;In my opinion, you don't need object-oriented features for this simple use case, and you're shooting yourself in the foot with its complexities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: My first hunch was wrong, the &lt;code&gt;dict&lt;/code&gt; attribute is not necessary here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try developing a procedural version first, and get that to work. Only then you may consider converting this to an OO version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code works for me, though. You could try setting a breakpoint in your functions (&lt;code&gt;:breakadd&lt;/code&gt;), or &lt;code&gt;:set verbose=20 | normal! zx&lt;/code&gt; and see what gets executed.&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2016-09-07T16:19:36.020" LastActivityDate="2016-09-07T16:19:36.020" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9478" PostTypeId="1" CreationDate="2016-09-07T14:04:06.097" Score="1" ViewCount="519" Body="&lt;p&gt;I have &lt;code&gt;xolox/vim-easytags&lt;/code&gt; and &lt;code&gt;xolox/vim-misc&lt;/code&gt; installed. I have following configuration in vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:easytags_dynamic_files = 1&#xA;let g:easytags_on_cursorhold = 1&#xA;let g:easytags_updatetime_min = 4000&#xA;let g:easytags_auto_update = 1&#xA;let g:easytags_async = 1&#xA;let g:easytags_by_filetype = '~/tagfiles'&#xA;let g:easytags_languages = {&#xA;\   'javascript': {&#xA;\     'cmd': 'jsctags',&#xA;\       'args': ['-f']&#xA;\   }&#xA;\}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and the &lt;code&gt;g:easytags_events&lt;/code&gt;'s value is &lt;code&gt;['BufWritePost', 'CursorHold', 'CursorHoldI']&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now I hold my cursor for more than 10 seconds, but the tags is not updated to &lt;code&gt;~/.vimtags&lt;/code&gt; or any other possible tag files, what's the problem here?&lt;/p&gt;&#xA;&lt;p&gt;But tags will be updated when I write the buffer to file.&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="9333" LastEditDate="2021-08-11T08:41:42.020" LastActivityDate="2021-08-11T08:41:42.020" Title="Why my easytags plugin not generating tags automatically?" Tags="|tags|ctags|plugin-easytags|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9479" PostTypeId="1" AcceptedAnswerId="9480" CreationDate="2016-09-07T15:28:33.030" Score="15" ViewCount="3059" Body="&lt;p&gt;In vim docs, the description is very similar:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:q[uit]&#xA;:{count}q[uit]&#xA;CTRL-W q                        *CTRL-W_q*&#xA;CTRL-W CTRL-Q                       *CTRL-W_CTRL-Q*&#xA;    Without {count}: Quit the current window.  If {count} is&#xA;    given quit the {count} window.&#xA;&#xA;    When quitting the last window (not counting a help window),&#xA;    exit Vim.&#xA;&#xA;    When 'hidden' is set, and there is only one window for the&#xA;    current buffer, it becomes hidden.  When 'hidden' is not set,&#xA;    and there is only one window for the current buffer, and the&#xA;    buffer was changed, the command fails.&#xA;&#xA;    (Note: CTRL-Q does not work on all terminals).&#xA;&#xA;    If [count] is greater than the last window number the last&#xA;    window will be closed: &amp;gt;&#xA;        :1quit  &quot; quit the first window&#xA;        :$quit  &quot; quit the last window&#xA;        :9quit  &quot; quit the last window&#xA;             &quot; if there are less than 9 windows opened&#xA;        :-quit  &quot; quit the previews window&#xA;        :+quit  &quot; quit the next window&#xA;        :+2quit &quot; quit the second next window&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Close:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:clo[se][!]&#xA;:{count}clo[se][!]&#xA;CTRL-W c                    *CTRL-W_c* *:clo* *:close*&#xA;    Without {count}: Close the current window.  If {count} is&#xA;    given close the {count} window.&#xA;&#xA;    When the 'hidden' option is set, or when the buffer was&#xA;    changed and the [!] is used, the buffer becomes hidden (unless&#xA;    there is another window editing it).&#xA;&#xA;    When there is only one window in the current tab page and&#xA;    there is another tab page, this closes the current tab page.&#xA;    |tab-page|.&#xA;&#xA;    This command fails when:            *E444*&#xA;    - There is only one window on the screen.&#xA;    - When 'hidden' is not set, [!] is not used, the buffer has&#xA;      changes, and there is no other window on this buffer.&#xA;    Changes to the buffer are not written and won't get lost, so&#xA;    this is a &quot;safe&quot; command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9169" LastActivityDate="2016-09-07T16:48:08.290" Title="What is the difference between :quit and :close commands?" Tags="|command-line|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9480" PostTypeId="2" ParentId="9479" CreationDate="2016-09-07T16:48:08.290" Score="17" Body="&lt;p&gt;Open Vim and enter &lt;code&gt;:close&lt;/code&gt;. You'll get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E444: Cannot close last window&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is the difference. We can also see this in the source implementation (from &lt;code&gt;ex_docmd.c&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * &quot;:quit&quot;: quit current window, quit Vim if the last window is closed.&#xA; */&#xA;    static void&#xA;ex_quit(exarg_T *eap)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * &quot;:close&quot;: close current window, unless it is the last one&#xA; */&#xA;    static void&#xA;ex_close(exarg_T *eap)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Furthermore, if you compile Vim without window support only &lt;code&gt;:quit&lt;/code&gt; is available (almost all − if not all − Vim builds are compiled with window support).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-09-07T16:48:08.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9481" PostTypeId="1" AcceptedAnswerId="9483" CreationDate="2016-09-07T17:08:09.280" Score="9" ViewCount="8901" Body="&lt;p&gt;I want to access &lt;a href=&quot;http://jupyter.org/&quot; rel=&quot;noreferrer&quot;&gt;Jupyter notebook&lt;/a&gt; from inside vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have compile vim with Python support, and try this plugin &lt;a href=&quot;http://github.com/ivanov/vim-ipython&quot; rel=&quot;noreferrer&quot;&gt;http://github.com/ivanov/vim-ipython&lt;/a&gt;. The documentation suggest me to run :IPython command. This seems to not working at all. Some thread on the internet give me a gist that probably the project has been abandoned and people use vim binding in jupyter notebook instead of accessing notebook from inside vim. &lt;a href=&quot;https://github.com/lambdalisue/jupyter-vim-binding&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/lambdalisue/jupyter-vim-binding&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, I also like to have some plugins as vim-jedi etc. Using the vim binding doesn't make any plugin I installed in vim accessible from inside Jupyter notebook. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I have try to search in google with no satisfying result, I really want to ensure, whether there is a way to access Jupyter notebook (editing Ipynb in the correct way by using vim) or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="9171" LastEditorUserId="6489" LastEditDate="2016-09-07T18:26:42.920" LastActivityDate="2023-01-27T14:49:17.243" Title="Is there any way to edit ipynb files by using vim?" Tags="|vim-windows|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9482" PostTypeId="1" AcceptedAnswerId="9484" CreationDate="2016-09-07T22:17:37.377" Score="2" ViewCount="456" Body="&lt;p&gt;What is best way to move cursor from the inside surrounds &lt;code&gt;'&quot;([{&lt;/code&gt; (and other types)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I'm typing &lt;code&gt;if (condition) { body }&lt;/code&gt;. I've typed the &lt;code&gt;condition&lt;/code&gt;, then I should go to &lt;code&gt;body&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For me it's very annoying to &lt;code&gt;esc&lt;/code&gt;, move cursor, go to insert &lt;code&gt;mode&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="8709" LastEditorUserId="1292" LastEditDate="2017-08-09T13:05:32.513" LastActivityDate="2017-08-09T13:05:32.513" Title="Move cursor from surrounds" Tags="|cursor-movement|insert-mode|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9483" PostTypeId="2" ParentId="9481" CreationDate="2016-09-08T08:08:14.303" Score="2" Body="&lt;p&gt;This maybe not the answer to your question, but perhaps an answer to your problem with vim-ipython: you could try &lt;a href=&quot;http://github.com/wilywampa/vim-ipython&quot; rel=&quot;nofollow&quot;&gt;http://github.com/wilywampa/vim-ipython&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't seem that it is too active either, but at least it works for me with Jupyter 5.0.0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure to read the help thoroughly as there are several actions to be done to make it work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a small convenience script to connect easier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import IPython&#xA;from IPython.lib import kernel&#xA;print 'Path to kernel:'&#xA;print IPython.lib.kernel.get_connection_file()&#xA;&#xA;def completion_metadata(ip):&#xA;    return [dict(word=m) for m in ip.Completer.matches]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then if you started your notebook as &lt;code&gt;-&amp;gt; python ~/.vim/plugged/vim-ipython/monitor.py &amp;amp; jupyter console&lt;/code&gt;, (or qtconsole) you could just execute &lt;code&gt;:IPython --existing path/to/kernel/printed&lt;/code&gt; to connect to a correct kernel. (although simple :IPython should also work with just the lastest kernel you started) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function provides (no) additional info that is shown when using omni-completion (if you don't have it you will see errors in the notebook).&lt;/p&gt;&#xA;" OwnerUserId="7612" LastActivityDate="2016-09-08T08:08:14.303" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9484" PostTypeId="2" ParentId="9482" CreationDate="2016-09-08T10:21:22.500" Score="3" Body="&lt;p&gt;You could start from this map (and improve it according to your taste):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-x&amp;gt;&amp;lt;C-x&amp;gt; &amp;lt;Esc&amp;gt;/[[({,]\_s*/e&amp;lt;CR&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.. which maps &lt;code&gt;Ctrl-x Ctrl-x&lt;/code&gt; in insert mode to jump after a set of characters (open brackets, I added comma since it could be useful also to jump over function arguments), skipping also any white spaces or newlines that follow. So, if the text is written, just hit &lt;code&gt;Ctrl-x Ctrl-x&lt;/code&gt; to move to the 'next' position, until the cursor is where you want it. How you then change the code that follows is your decision.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Nybyn.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Nybyn.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-09-08T13:16:51.600" LastActivityDate="2016-09-08T13:16:51.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9485" PostTypeId="1" AcceptedAnswerId="9487" CreationDate="2016-09-08T14:24:46.360" Score="2" ViewCount="231" Body="&lt;p&gt;When I enter insert mode and type &lt;code&gt;&amp;lt;C-SPACE&amp;gt;&lt;/code&gt;, vim inserts the last inserted text, then exits insert mode. My guess is it's using the &lt;code&gt;&quot;.&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;C-SPACE&amp;gt;&lt;/code&gt; prints a null character. However when I enter the command &lt;code&gt;:imap&lt;/code&gt;, it doesn't list any mappings. I was expecting there to be a mapping for the null character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone explain this behavior?&lt;/p&gt;&#xA;" OwnerUserId="6883" LastActivityDate="2016-09-08T15:10:12.700" Title="Why does the null character in insert mode insert the contents of the &quot;. register?" Tags="|insert-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9486" PostTypeId="1" AcceptedAnswerId="9499" CreationDate="2016-09-08T14:52:14.690" Score="14" ViewCount="15275" Body="&lt;p&gt;I have &lt;code&gt;Anaconda&lt;/code&gt; (including python3.5.2), &lt;code&gt;VIM&lt;/code&gt; (7.4) and &lt;code&gt;Jedi-VIM&lt;/code&gt; installed on my system. There was also a &lt;code&gt;python&lt;/code&gt; installed on the linux system by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The autocompletion is working on base packages, at least. But for packages like &lt;code&gt;numpy&lt;/code&gt; (which was included in &lt;code&gt;Anaconda&lt;/code&gt;) the completion is not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By using the following command in &lt;code&gt;VIM&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py3 import sys; print(sys.path)&#xA;&#xA;['/usr/lib/python35.zip', &#xA;'/usr/lib/python3.5', &#xA;'/usr/lib/python3.5/plat-x86_64-linux-gnu', &#xA;'/usr/lib/python3.5/lib-dynload', &#xA;'/usr/local/lib/python3.5/dist-packages', &#xA;'/usr/lib/python3/dist-packages', &#xA;'_vim_path_']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This indicates to me that the &lt;code&gt;Anaconda-python&lt;/code&gt; interpreter and the packages are never been used by &lt;code&gt;jedi-vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$which python&#xA;/home/user1/anaconda3/bin/python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get jedi-vim to use also the path of anaconda python for getting package autocompletion?&lt;/p&gt;&#xA;" OwnerUserId="9186" LastEditorUserId="6489" LastEditDate="2016-09-08T14:56:39.797" LastActivityDate="2020-06-09T08:09:27.653" Title="how to change python interpreter used by jedi-vim" Tags="|linux|vimscript-python|plugin-jedi-vim|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9487" PostTypeId="2" ParentId="9485" CreationDate="2016-09-08T15:10:12.700" Score="3" Body="&lt;p&gt;When you press &lt;code&gt;&amp;lt;C-Space&amp;gt;&lt;/code&gt; in insert mode, Vim understands &lt;code&gt;&amp;lt;C-@&amp;gt;&lt;/code&gt; which is a built-in command that inserts the previously inserted text and leaves insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't see &lt;code&gt;&amp;lt;C-@&amp;gt;&lt;/code&gt; in &lt;code&gt;:imap&lt;/code&gt; because it is not a mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you could have pieced all that together from the doc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help i_ctrl-a&#xA;:help &quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-09-08T15:10:12.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9488" PostTypeId="2" ParentId="9486" CreationDate="2016-09-08T15:18:58.490" Score="4" Body="&lt;p&gt;You can't.  The &lt;code&gt;:python&lt;/code&gt; and &lt;code&gt;:python3&lt;/code&gt; commands always use the compiled-in interpreters.  If you have a recent version of Vim with &lt;code&gt;python&lt;/code&gt; and / or &lt;code&gt;python3&lt;/code&gt; loaded dynamically (see &lt;code&gt;:h python-dynamic&lt;/code&gt;) you can use &lt;code&gt;pythondll&lt;/code&gt; and &lt;code&gt;pythonthreedll&lt;/code&gt; to load different interpreters, but replacing CPython by Anaconda is IMO asking for segfaults (provided that Vim accepts it at all, that is).&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-09-08T15:18:58.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9489" PostTypeId="1" AcceptedAnswerId="9490" CreationDate="2016-09-08T15:34:24.447" Score="1" ViewCount="12780" Body="&lt;p&gt;How can I substitute something with empty string? So far the best I can do seems to be substituting with a whitespace. If I write &lt;code&gt;:s/target//&lt;/code&gt; then it's deemed invalid.&lt;/p&gt;&#xA;" OwnerUserId="1315" LastActivityDate="2016-09-08T16:04:05.567" Title="Substituting something with empty string?" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="5" ClosedDate="2016-09-08T21:26:37.040" ContentLicense="CC BY-SA 3.0" />
  <row Id="9490" PostTypeId="2" ParentId="9489" CreationDate="2016-09-08T15:49:37.523" Score="7" Body="&lt;p&gt;Your command should work but you could also try this as an alternative: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/target/\=''/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\=&lt;/code&gt; tells vim to evaluate the replace string as an expression&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;''&lt;/code&gt; Is an empty string&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-09-08T16:04:05.567" LastActivityDate="2016-09-08T16:04:05.567" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9491" PostTypeId="2" ParentId="9486" CreationDate="2016-09-08T15:57:53.757" Score="1" Body="&lt;p&gt;You could compile vim with anaconda:&#xA;I did &lt;code&gt;./configure --with-features=huge --enable-pythoninterp --with-python-config-dir=~/anaconda/lib/python2.7/config/&lt;/code&gt;, I remember that I did similar tests afterwards and &lt;code&gt;:py import sys; print sys.path&lt;/code&gt; was giving me correct results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the &lt;a href=&quot;http://www.xorpd.net/blog/vim_python3_install.html&quot; rel=&quot;nofollow&quot;&gt;web search&lt;/a&gt; you could perhaps do something like this (ex. for 3.4):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;./configure --enable-python3interp --with-features=huge --with-python3-config-dir=~/anaconda/lib/python3.4/config-3.4m-x86_64-linux-gnu&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7612" LastActivityDate="2016-09-08T15:57:53.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9492" PostTypeId="2" ParentId="8510" CreationDate="2016-09-08T16:29:18.683" Score="1" Body="&lt;p&gt;So it turns out that it's a stupid Windows problem. The remedy to this is to simply use forward slashes in the path name. i.e. &lt;code&gt;:diffsplit Path/to/other/directory/%&lt;/code&gt; works just fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've remedied this on my system by using the option &lt;code&gt;set shellslash&lt;/code&gt; which defaults to using forward slashes even on Windows.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-09-08T16:29:18.683" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9494" PostTypeId="1" AcceptedAnswerId="9495" CreationDate="2016-09-09T07:06:56.473" Score="7" ViewCount="2919" Body="&lt;p&gt;I just recently learned how to use folds and I find it very useful. I have added a rule to automatically save the view with my folds when I'm editing the markdown files with the rule:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup QuickNotes&#xA;  au BufWinLeave *.md mkview&#xA;  au BufWinEnter *.md silent loadview&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I have saved it and copied a file somewhere the folds were there no more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question is:&lt;/strong&gt;&lt;br&gt;&#xA;Is it possible to save folds (the view) into the text file I'm editting?&lt;br&gt;&#xA;If not then maybe I can write a rule that will save the view into something like &lt;code&gt;.%.view&lt;/code&gt; (dot filename dot view) ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Extra curious:&lt;/strong&gt;&lt;br&gt;&#xA;If I save the views to the default location- where is that?&lt;/p&gt;&#xA;" OwnerUserId="3254" LastEditorUserId="3254" LastEditDate="2016-09-12T09:00:10.633" LastActivityDate="2016-09-12T09:00:10.633" Title="How to save a view (with folds) into the file?" Tags="|folding|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9495" PostTypeId="2" ParentId="9494" CreationDate="2016-09-09T07:51:24.553" Score="2" Body="&lt;p&gt;You can give &lt;code&gt;:mkview&lt;/code&gt; a filename as argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup QuickNotes&#xA;    autocmd!&#xA;    autocmd BufWinLeave *.md execute &quot;mkview! &quot; . expand('&amp;lt;afile&amp;gt;:p:h') . &quot;/.&quot; . expand('&amp;lt;afile&amp;gt;:t') . &quot;.view&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and use &lt;code&gt;:source&lt;/code&gt; instead of &lt;code&gt;:loadview&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    autocmd BufWinEnter *.md execute &quot;silent! source &quot; . expand('%:p:h') . &quot;/.&quot; . expand('%:t') . &quot;.view&quot;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-09-11T07:57:09.090" LastActivityDate="2016-09-11T07:57:09.090" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9496" PostTypeId="2" ParentId="9494" CreationDate="2016-09-09T07:54:14.447" Score="2" Body="&lt;p&gt;You'll find that information at &lt;code&gt;:help :mkview&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:mkvie[w][!] [file] Write a Vim script that restores the contents of the&#xA;                        current window.&#xA;                        When [!] is included an existing file is overwritten.&#xA;                        When [file] is omitted or is a number from 1 to 9, a&#xA;                        name is generated and 'viewdir' prepended.  [...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The generated filename has the full path of the original file encoded in it; that explains why it isn't loaded if you rename the original file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you either need to move / copy the corresponding view file (found inside &lt;code&gt;'viewdir'&lt;/code&gt;; default &lt;code&gt;~/.vim/view&lt;/code&gt;), or &lt;code&gt;:source&lt;/code&gt; it once to reapply the folds (then &lt;code&gt;:autocmd&lt;/code&gt;s will then ensure the view gets persisted under the new file name).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The view always is a separate file; I would not recommend putting it into the same directory as the original file.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-09T07:54:14.447" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9497" PostTypeId="1" AcceptedAnswerId="9498" CreationDate="2016-09-09T09:54:00.300" Score="2" ViewCount="160" Body="&lt;p&gt;Let's say that I have a file which contains numbers from 1 to 200. Each number is on a separate line. As I have a wide screen, then I view this file in a way that I vertically split the window(&lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;w&lt;/kbd&gt; + &lt;kbd&gt;v&lt;/kbd&gt;), &lt;code&gt;:set scb&lt;/code&gt; in first window, move to second window(&lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;w&lt;/kbd&gt; + &lt;kbd&gt;l&lt;/kbd&gt;), scroll down(&lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;d&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;e&lt;/kbd&gt;, etc) as much as first line in this second window is the last line + 1 of the first window and set the &lt;code&gt;scrollbind&lt;/code&gt; in this second window. As a last step I move back to first window(&lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;w&lt;/kbd&gt; + &lt;kbd&gt;h&lt;/kbd&gt;). This works beautifully, but it is inconvenient to set up. Is there an easier way to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2016-09-09T10:10:23.767" Title="continue buffer in new window" Tags="|vim-windows|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9498" PostTypeId="2" ParentId="9497" CreationDate="2016-09-09T10:10:23.767" Score="4" Body="&lt;p&gt;You're looking for DrChip's &lt;a href=&quot;http://www.drchip.org/astronaut/vim/#MPAGE&quot; rel=&quot;nofollow&quot;&gt;mpage.vim&lt;/a&gt; plugin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The mpage.vim plugin supports using multiple windows as separate pages to view a buffer (ie. file), with each window under mpage control sequentially showing lines of text.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-09T10:10:23.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9499" PostTypeId="2" ParentId="9486" CreationDate="2016-09-09T11:13:33.417" Score="8" Body="&lt;p&gt;I was able to fix it myself by providing &lt;code&gt;jedi-vim&lt;/code&gt; with the location of the packages in my &lt;code&gt;anaconda&lt;/code&gt; folder using the &lt;code&gt;$PYTHONPATH&lt;/code&gt; variable as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export PYTHONPATH=$PYTHONPATH:/home/user1/anaconda3/lib/python3.5/site-packages&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks to all!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or Add following line in ~/.bash_profile&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;export PYTHONPATH=$PYTHONPATH:/home/user1/anaconda3/lib/python3.5/site-packages&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9186" LastEditorUserId="11477" LastEditDate="2018-05-03T12:16:30.693" LastActivityDate="2018-05-03T12:16:30.693" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="9500" PostTypeId="1" AcceptedAnswerId="9501" CreationDate="2016-09-09T14:22:10.327" Score="4" ViewCount="1332" Body="&lt;p&gt;I'm trying to do something fairly simple. I'm writing latex and I have all these blocks of code, that I'm trying to comment out (and disregard the words in the word count). So I have to write these lines a bazillion times:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%TC:ignore&#xA;\iffalse&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\fi&#xA;%TC:endignore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to setup a shortcut, so if I type something along the lines of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:zlc[ENTER]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it then inserts one of the code-chunks? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I could setup my own kind of tailored standard clipboard in my VIMRC-file. So I shouldn't put it all into different registers every time I start Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Edit1&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just as I saw the answers, I knew what I had forgotten to search for, which is 'abbreviations'. I would just add it here, so this post would come up, if someone else Googled it. &lt;/p&gt;&#xA;" OwnerUserId="9194" LastEditorUserId="9194" LastEditDate="2016-09-09T15:48:53.477" LastActivityDate="2016-09-09T17:05:03.400" Title="Shortcut / abbreviation to insert text block" Tags="|vimrc|abbreviations|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9501" PostTypeId="2" ParentId="9500" CreationDate="2016-09-09T14:45:25.930" Score="2" Body="&lt;p&gt;Sure, you've got a couple options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use an abbreviation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev zlc %TC:ignore&amp;lt;CR&amp;gt;\iffalse&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you type zlc&lt;kbd&gt;Enter&lt;/kbd&gt; in insert mode it will fill in the text.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;iabbrev&lt;/code&gt; is an abbreviation that only works in insert mode&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Use a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Zlc call Ignore()&#xA;function! Ignore()&#xA;   normal! i%TC:ignore&#xA;   normal! o\iffalse&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you type &lt;code&gt;:Zlc&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; in normal mode it will fill in the text.&lt;/li&gt;&#xA;&lt;li&gt;Note the capital &lt;code&gt;Z&lt;/code&gt;; user commands cannot start with a lowercase letter.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Place either of these in your &lt;code&gt;vimrc&lt;/code&gt; to make them work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h abbrev&lt;/code&gt;, &lt;code&gt;:h command&lt;/code&gt;, and &lt;code&gt;:h normal&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-09-09T17:05:03.400" LastActivityDate="2016-09-09T17:05:03.400" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9502" PostTypeId="2" ParentId="9500" CreationDate="2016-09-09T14:50:31.337" Score="1" Body="&lt;p&gt;Not exactly what you were asking but as @Tumber41 already gave you a solution, here is a possible alternative just to show that you can achieve things in different ways with vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddCommentLines() range&#xA;    call append(a:firstline-1, &quot;%tc:ignore&quot;)&#xA;    call append(a:firstline, &quot;\iffalse&quot;)&#xA;&#xA;&#xA;    call append(a:lastline+2, &quot;\\fi&quot;)&#xA;    call append(a:lastline+3, &quot;%tc:endignore&quot;)&#xA;endfunction&#xA;&#xA;vnoremap &amp;lt;key&amp;gt; :call AddCommentLines()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function will add the lines around a visual selection. So you can visually select the text you want to comment, press the key combination you'll have defined in the &lt;code&gt;vnoremap&lt;/code&gt; line and your comments will appears around the selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also call it directly with a range: say you want to comment lines 100 to 110:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:100,110call AddCommentLines()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if you don't provide a range only the current line will be surrounded by the comments.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also I would recommend to try using some snippets &lt;a href=&quot;https://vi.stackexchange.com/q/7466/1841&quot;&gt;see this question to choose a snippet engine&lt;/a&gt;. For example with Ultisnips you could add theses lines in the latex snippets file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet com &quot;Add opening comment block&quot;&#xA;%TC:ignore&#xA;\iffalse&#xA;endsnippet&#xA;&#xA;snippet ccom &quot;Add closing comment block&quot;&#xA;\fi&#xA;%TC:endignore&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way when you'll type &lt;code&gt;com&lt;/code&gt; followed by the key you choose to trigger a comment the first comment block will be added. And when you type &lt;code&gt;ecom&lt;/code&gt; followed by the snippet trigger key the second block will be added.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-09-09T15:50:24.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9504" PostTypeId="1" AcceptedAnswerId="9505" CreationDate="2016-09-10T02:17:51.893" Score="1" ViewCount="186" Body="&lt;p&gt;I've remapped q to :bp, but to get an instant response, I have to press it twice. Otherwise there's a two second delay. What could be causing this and how can I fix it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NetrwMapping()&#xA;  noremap &amp;lt;buffer&amp;gt; q :bp&amp;lt;CR&amp;gt;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4901" LastEditorUserId="4901" LastEditDate="2016-09-10T22:18:27.407" LastActivityDate="2016-09-10T22:18:27.407" Title="Delay with remapped q" Tags="|key-bindings|error|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9505" PostTypeId="2" ParentId="9504" CreationDate="2016-09-10T11:14:50.687" Score="4" Body="&lt;p&gt;This happens because Vim waits to see if you want to do &lt;code&gt;q&amp;lt;letter&amp;gt;&lt;/code&gt; to start recording a macro (there are a couple other things too like &lt;code&gt;q:&lt;/code&gt;).&#xA;You can use the &lt;code&gt;tm&lt;/code&gt; option to change the amount it waits(will apply to all maps), or remap it to another unused letter.&lt;/p&gt;&#xA;" OwnerUserId="8412" LastActivityDate="2016-09-10T11:14:50.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9506" PostTypeId="2" ParentId="3300" CreationDate="2016-09-10T13:32:04.880" Score="0" Body="&lt;p&gt;Check your Python version. GVim seems to be built against Python &lt;code&gt;2.7.9&lt;/code&gt;, and the latest 2.x version is &lt;code&gt;2.7.11&lt;/code&gt;. Run &lt;code&gt;python --version&lt;/code&gt; to see which version you have. Also make sure that both your gvim and python installation are x86 or 64.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With Python &lt;code&gt;2.7.11&lt;/code&gt; &lt;em&gt;and&lt;/em&gt; some plugins, it'll crash silently. You can also try adding &lt;code&gt;finish&lt;/code&gt; to your vimrc (or rename it) to launch vim without plugins, it should start correctly (but as soon as you re-enable your plugins, it will fail again)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you used &lt;em&gt;chocolatey&lt;/em&gt; to install Python on Windows, it may auto-upgrade - use &lt;code&gt;pin&lt;/code&gt; to prevent upgrading (&lt;code&gt;choco pin add --name python2-x86_32 --version 2.7.9&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="8856" LastActivityDate="2016-09-10T13:32:04.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9507" PostTypeId="1" AcceptedAnswerId="9508" CreationDate="2016-09-10T16:46:00.700" Score="9" ViewCount="3055" Body="&lt;p&gt;I was remotely editing a new file: &lt;code&gt;man-01-Intro.txt&lt;/code&gt; but the machine went&#xA;down before I wrote it to disk so only the swp version was conserved. Is there anything that I can do to recover the work already done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim 7.4.273&lt;/p&gt;&#xA;" OwnerUserId="7868" LastEditorUserId="51" LastEditDate="2016-09-10T18:31:29.177" LastActivityDate="2016-09-10T18:31:29.177" Title="Can a text file be recovered only from the .*.swp file?" Tags="|swap-file|crash-recovery|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9508" PostTypeId="2" ParentId="9507" CreationDate="2016-09-10T16:57:31.093" Score="11" Body="&lt;p&gt;Edit the same file again.  Vim will prompt you with a few options; say you want to &lt;em&gt;Recover&lt;/em&gt;.  Then save the file, quit Vim, and remove the swap file (otherwise Vim will prompt you again the next time you edit the same file).  The result may or may not have your latest edits, but it's better than nothing.  Do check that everything is ok.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-09-10T16:57:31.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9509" PostTypeId="1" AcceptedAnswerId="9519" CreationDate="2016-09-10T18:17:45.217" Score="6" ViewCount="2298" Body="&lt;p&gt;When I'm executing an external command in silent mode in vim, when it returns the screen is blank and I need to redraw it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how I solve it in the &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :silent :make&amp;lt;CR&amp;gt;:redr!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;without the &lt;code&gt;redr!&lt;/code&gt; the screen is blank and I have to press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;l&lt;/kbd&gt;in order to continue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a bug, or a feature ?&lt;/p&gt;&#xA;" OwnerUserId="496" LastActivityDate="2021-05-22T06:43:43.370" Title="redraw problem after returning from external command" Tags="|silent-mode|redraw|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9510" PostTypeId="2" ParentId="2995" CreationDate="2016-09-10T19:09:56.623" Score="1" Body="&lt;p&gt;The other answers show the interactive way of showing what colorschemes are&#xA;available, but no one has mentioned a way of getting a list that can be used in&#xA;vimscript.  This is an adaptation of my answer for &lt;a href=&quot;https://vi.stackexchange.com/questions/5780/list-known-filetypes&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution uses the &lt;code&gt;'runtimepath'&lt;/code&gt; option to get all available colorscheme&#xA;directories, and then fetches a list of the vimscript files in those directories&#xA;with their extensions removed.  This may not be the safest way to do it, so&#xA;improvements are welcome:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetColorschemes()&#xA;    &quot; Get a list of all the runtime directories by taking the value of that&#xA;    &quot; option and splitting it using a comma as the separator.&#xA;    let rtps = split(&amp;amp;runtimepath, &quot;,&quot;)&#xA;    &quot; This will be the list of colorschemes that the function returns&#xA;    let colorschemes = []&#xA;&#xA;    &quot; Loop through each individual item in the list of runtime paths&#xA;    for rtp in rtps&#xA;        let colors_dir = rtp . &quot;/colors&quot;&#xA;        &quot; Check to see if there is a colorscheme directory in this runtimepath.&#xA;        if (isdirectory(colors_dir))&#xA;            &quot; Loop through each vimscript file in the colorscheme directory&#xA;            for color_scheme in split(glob(colors_dir . &quot;/*.vim&quot;), &quot;\n&quot;)&#xA;                &quot; Add this file to the colorscheme list with its everything&#xA;                &quot; except its name removed.&#xA;                call add(colorschemes, fnamemodify(color_scheme, &quot;:t:r&quot;))&#xA;            endfor&#xA;        endif&#xA;    endfor&#xA;&#xA;    &quot; This removes any duplicates and returns the resulting list.&#xA;    return uniq(sort(colorschemes))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use thie list returned by this function in vimscript.  For&#xA;instance, you could simply echo each colorscheme:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for c in GetColorschemes() | echo c | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I won't explain what each individual function or command does here, but here is&#xA;a list of the help pages for all of the ones I used:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'runtimepath'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :let&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :let-&amp;amp;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help split()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :for&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help expr-.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :if&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help isdirectory()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help glob()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help fnamemodify()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help add()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help uniq()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help sort()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="865" LastActivityDate="2016-09-10T19:09:56.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9511" PostTypeId="2" ParentId="8093" CreationDate="2016-09-10T19:59:57.003" Score="3" Body="&lt;p&gt;This is doable, though quite complicated.  Here's how.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 1. Having &lt;code&gt;^M&lt;/code&gt; in a mapping does not work, it is treated as if you hit &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, which would execute the &lt;code&gt;:call&lt;/code&gt; command which is not yet complete.  To make it work we need to replace it with something which is not interpreted as an Enter hit -- e.g. &lt;code&gt;\n&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;localleader&amp;gt;a :call &amp;lt;sid&amp;gt;Test({'cmd':&quot;Hello\nWorld&quot;})&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: the string has to be double-quoted, otherwise &lt;code&gt;\n&lt;/code&gt; is treated as two characters instead of one &lt;code&gt;^M&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 2. &lt;code&gt;s:Test&lt;/code&gt; tries to convert this to a string and pass on to another mapping command.  The mapping is successfully created, but when run -- has the same problem as in step 1 above -- object when converted to string has &lt;code&gt;^M&lt;/code&gt; in it, which is treated as a &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; hit, and executes the &lt;code&gt;:call&lt;/code&gt; command.  This time we have no luxury of replacing with &lt;code&gt;\n&lt;/code&gt;.  But we're within a function now and can do other tricks.  For example, we can now save this object to some script-variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:tab_argument = a:obj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can now be used instead of &lt;code&gt;a:obj&lt;/code&gt; in the mapping.  Also, since we don't have anything variable now, we can omit &lt;code&gt;execute&lt;/code&gt; and define mapping directly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;tab&amp;gt; &amp;lt;esc&amp;gt;:&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;Test2(&amp;lt;sid&amp;gt;tab_argument)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Step 3.  Unfortunately, &lt;code&gt;:map&lt;/code&gt; does not seem to be able to understand script-local variables.  Let's work around this by defining another function with no arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:tab_lambda()&#xA;  call s:Test2(s:tab_argument)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Step 4. &#xA;Now let's put this all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Test(obj)&#xA;    let s:tab_argument = a:obj&#xA;    function! s:tab_lambda()&#xA;        call s:Test2(s:tab_argument)&#xA;    endfunction&#xA;    inoremap &amp;lt;silent&amp;gt; &amp;lt;tab&amp;gt; &amp;lt;esc&amp;gt;:&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;tab_lambda()&amp;lt;cr&amp;gt;&#xA;endfunction&#xA;&#xA;function! s:Test2(obj)&#xA;    &quot; do something&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;localleader&amp;gt;a :call &amp;lt;sid&amp;gt;Test({'cmd':&quot;Hello\nWorld&quot;})&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I may be stating obvious, but make sure you don't have local &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; mappings.  If you do, &lt;code&gt;inoremap&lt;/code&gt; will succeed, but hitting &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; won't call the &lt;code&gt;Test2&lt;/code&gt; function.&lt;/p&gt;&#xA;" OwnerUserId="9204" LastEditorUserId="9204" LastEditDate="2016-09-10T20:09:58.393" LastActivityDate="2016-09-10T20:09:58.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9512" PostTypeId="2" ParentId="9486" CreationDate="2016-09-11T06:20:25.367" Score="3" Body="&lt;h1&gt;2018+ Jedi Versions&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You can just use &lt;code&gt;:let jedi#force_py_version=3.8&lt;/code&gt; if you want to switch to the latest Python version, for example. Unfortunately there is no environment listing in jedi-vim, yet. We need to build that (it is available in Jedi, though).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Old Answer&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Basically the only thing you can do currently is to compile VIM with Python 3.5 support. That's probably a stupid idea, but it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise there will be support for cross Python versions, with &lt;a href=&quot;https://github.com/davidhalter/jedi/issues/385&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/davidhalter/jedi/issues/385&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it might be possible to modify the Python PATH, but that might lead to a SEGFAULT and to other unwanted behavior, because you're basically allowing Jedi to run binary code from another Python version (Yes it actually happens).&lt;/p&gt;&#xA;" OwnerUserId="9205" LastEditorUserId="9205" LastEditDate="2019-07-09T08:10:25.800" LastActivityDate="2019-07-09T08:10:25.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9513" PostTypeId="1" AcceptedAnswerId="9514" CreationDate="2016-09-11T07:01:16.807" Score="5" ViewCount="1183" Body="&lt;p&gt;Today, I wanted to import a public GPG &lt;a href=&quot;https://pgp.mit.edu/pks/lookup?op=get&amp;amp;search=0x8C718D3B5072E1F5&quot;&gt;key&lt;/a&gt;. To do so, I have navigated to page, copied the key, opened up vim, entered insert mode by pressing &lt;kbd&gt;i&lt;/kbd&gt; and pasted the text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every line has been pasted fine except the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EgdlR1BHAAEBCRCMcY07UHLh9bDbAJ4mKWARqsvx4TJ8N1hPJF2oTjkeSgCeMVJljxmD+Jd4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That line appears as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gCeMVJljxmD+Jd4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this corresponds to trailing part of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I have exited from the insert mode and pressed &lt;kbd&gt;u&lt;/kbd&gt;. Now, the line has been turned into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EgdlR1BHAAEBCRCMcY07UHLh9bDbAJ4mKWARqsvx4TJ8N1hPJF2oT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this corresponds to the beginning portion of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All in all, the only characters not present in any of the two forms are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;jkeS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My speculation is, for some reason, when text is pasted, this character sequence acts like a command that says: 'Delete all characters in this line, up to this point'. I can reproduce the behavior with a line like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaaajkeSbbbb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, I have two questions regarding this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why exactly does this character sequence, &lt;code&gt;jkeS&lt;/code&gt;, causes this behavior? What is going on behind the scenes?&lt;/li&gt;&#xA;&lt;li&gt;What exactly is the use case for this behavior? I think there must be a use case for this because this is AFAIK a feature, not a bug. Even, there is a paste mode in vim which we activate by typing &lt;code&gt;:set paste&lt;/code&gt; for correct pasting, which is a fact that supports that this 'weird' pasting behavior is a feature, definitely not a bug.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4840" LastActivityDate="2016-09-11T10:33:04.223" Title="What is the use case for the weird paste behavior?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9514" PostTypeId="2" ParentId="9513" CreationDate="2016-09-11T07:31:11.483" Score="10" Body="&lt;p&gt;&lt;strong&gt;Why exactly does this character sequence, &lt;code&gt;jkeS&lt;/code&gt;, causes this behavior? What is going on behind the scenes?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your gpg key contains &lt;code&gt;jk&lt;/code&gt; which you likely mapped to &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; (it is very common) so:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Vim sees &lt;code&gt;jk&lt;/code&gt;, it executes your custom mapping and exists insert mode.&lt;/li&gt;&#xA;&lt;li&gt;The next character is &lt;code&gt;e&lt;/code&gt; so Vim jumps to the end of the current &lt;code&gt;word&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The next character is &lt;code&gt;S&lt;/code&gt; so Vim cuts the whole line and enters insert mode.&lt;/li&gt;&#xA;&lt;li&gt;The rest of your gpg key is typed in.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What exactly is the use case for this behavior?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pasting is handled as a series keystrokes, not as an actual paste.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the text you paste contains newlines, Vim will autoindent just like if you typed everything.&lt;/li&gt;&#xA;&lt;li&gt;If the text you paste contains character sequences that match with mappings those mappings are executed.&lt;/li&gt;&#xA;&lt;li&gt;And so on…&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This makes pasting using your system/terminal's tools a pretty hazardous affair. By setting the &lt;code&gt;paste&lt;/code&gt; option, you disable a bunch of features like autoindenting and insert mode mappings which allows pasting to work more like actual pasting. Don't forget to unset it afterwards!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can, I'd suggest you get a proper Vim, built with the &lt;code&gt;+clipboard&lt;/code&gt; feature, and use &lt;code&gt;p&lt;/code&gt; instead of relying on your system/terminal emulator tools.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-09-11T10:33:04.223" LastActivityDate="2016-09-11T10:33:04.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9516" PostTypeId="1" AcceptedAnswerId="9517" CreationDate="2016-09-11T22:32:56.033" Score="0" ViewCount="71" Body="&lt;p&gt;The default syntax highlighting for &lt;code&gt;bib&lt;/code&gt; files doesn't highlight comments inside entries, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@book{test,&#xA;    % title = {This isn't highlighted as a comment},&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's because &lt;code&gt;bibtex&lt;/code&gt; doesn't allow comments inside entries, but &lt;code&gt;biblatex&lt;/code&gt; does and I never use &lt;code&gt;bibtex&lt;/code&gt;, so I want to add the highlighting myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried adding this to &lt;code&gt;~/.vim/after/syntax/bib.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match testComment &quot;%.*$&quot;&#xA;highlight link testComment Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work. Any ideas on how I can make stuff after a &lt;code&gt;%&lt;/code&gt; count as a comment anywhere on the file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: Ideally the &lt;code&gt;%&lt;/code&gt; still wouldn't count as a comment if it's inside a field, like &lt;code&gt;url = {http://whatever.com%20whatever}&lt;/code&gt;… but I think I can figure out a regex pattern to account for that if I can get the highlighting to work inside entries at all.&lt;/p&gt;&#xA;" OwnerUserId="7642" LastActivityDate="2016-09-12T19:28:26.200" Title="Allow comment highlighting inside biblatex entries" Tags="|syntax-highlighting|filetype-tex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9517" PostTypeId="2" ParentId="9516" CreationDate="2016-09-12T06:11:53.033" Score="1" Body="&lt;p&gt;The reason it does not work is that the match is inside an &lt;code&gt;bibEntry&lt;/code&gt;. Thus you have to redefine the &lt;code&gt;bibEntry&lt;/code&gt; region so as to include (with the &lt;code&gt;contains=&lt;/code&gt; option a comment group. In this case, you should use a new comment group, not the existing &lt;code&gt;bibComment&lt;/code&gt; and &lt;code&gt;bibComment2&lt;/code&gt;, because these are reserved for standard bibtex comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the following should work if you put it in &lt;code&gt;.../after/syntax/bib.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region bibEntryData contained&#xA;  \ start=/[{(]/ms=e+1&#xA;  \ end=/[})]/me=e-1&#xA;  \ contains=bibKey,bibField,bibComment3&#xA;syn match bibComment3 &quot;^\s*%.*&quot;&#xA;highlight link bibComment3 Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: This assumes that all comments are &quot;full line&quot;-comments.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2016-09-12T19:28:26.200" LastActivityDate="2016-09-12T19:28:26.200" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9518" PostTypeId="2" ParentId="9471" CreationDate="2016-09-12T06:52:28.607" Score="5" Body="&lt;p&gt;As @Christian Brabandt mentioned in his comment, &lt;code&gt;filetype indent on&lt;/code&gt; was missing from my &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2016-09-12T06:52:28.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9519" PostTypeId="2" ParentId="9509" CreationDate="2016-09-12T13:40:43.867" Score="6" Body="&lt;p&gt;This is by design. The &lt;code&gt;:help :!&lt;/code&gt; (a closely related command) offers this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        Vim redraws the screen after the command is finished,&#xA;        because it may have printed any text.  This requires a&#xA;        hit-enter prompt, so that you can read any messages.&#xA;        To avoid this use:&#xA;            :silent !{cmd}&#xA;        The screen is not redrawn then, thus you have to use&#xA;        CTRL-L or &quot;:redraw!&quot; if the command did display&#xA;        something.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-12T13:40:43.867" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9520" PostTypeId="1" CreationDate="2016-09-12T15:44:02.423" Score="1" ViewCount="310" Body="&lt;p&gt;I'm looking for a way that will highlight lines (or part of lines) that don't adhere to current tabs settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say for instance, I have the following configuration in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tabstop=8 &#xA;softtabstop=8 &#xA;shiftwidth=8 &#xA;noexpandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to highlight lines that don't adhere to the above settings ?&lt;/p&gt;&#xA;" OwnerUserId="496" LastEditorUserId="51" LastEditDate="2016-09-12T22:56:18.853" LastActivityDate="2016-09-12T23:06:07.227" Title="How can I highlight misuse of tabs and spaces according to current configuration?" Tags="|indentation|tab-characters|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9521" PostTypeId="2" ParentId="9520" CreationDate="2016-09-12T16:00:50.913" Score="2" Body="&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1690&quot; rel=&quot;nofollow&quot;&gt;IndentConsistencyCop plugin&lt;/a&gt; checks the consistency of the used indent, and compares this with the buffer's indent settings. With a companion plugin, it can be triggered automatically for configured filetypes. (The plugin page has links to alternative plugins.)&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-12T16:00:50.913" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9522" PostTypeId="1" AcceptedAnswerId="9523" CreationDate="2016-09-12T16:22:24.503" Score="152" ViewCount="53685" Body="&lt;p&gt;Vim 8 was released &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.0.0000&quot; rel=&quot;noreferrer&quot;&gt;today&lt;/a&gt; and the &lt;a href=&quot;https://raw.githubusercontent.com/vim/vim/master/runtime/doc/version8.txt&quot; rel=&quot;noreferrer&quot;&gt;release notes&lt;/a&gt; mentions a new &quot;package&quot; feature. What is it and how should I use it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most importantly, does it replace the good old &lt;a href=&quot;https://vi.stackexchange.com/q/388/1841&quot;&gt;plugin managers&lt;/a&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="42263" LastEditDate="2022-10-06T17:51:38.753" LastActivityDate="2022-10-06T17:51:38.753" Title="What is the Vim8 package feature and how should I use it?" Tags="|plugin-system|vim8|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9523" PostTypeId="2" ParentId="9522" CreationDate="2016-09-12T16:22:24.503" Score="110" Body="&lt;p&gt;First of all, the relevant documentation can be found with &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#packages&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h packages&lt;/code&gt;&lt;/a&gt; on the newly compiled Vim8 version and &lt;a href=&quot;https://github.com/vim/vim/blob/856c1110c1cf0d6e44e387b70732/runtime/doc/repeat.txt#L525&quot; rel=&quot;noreferrer&quot;&gt;here on Github&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A first important note is about the vocabulary: In Vim8 a package is defined like this:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A Vim package is a directory that contains one or more plugins.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This means that the new package manager was created to help users manage all of their plugins in the same archive. The doc lists the following advantages:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;A package can be downloaded as an archive and unpacked in its own directory.&#xA;Thus the files are not mixed with files of other plugins.  That makes it&#xA;easy to update and remove.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A package can be a git, mercurial, etc. repository.  That makes it really&#xA;easy to update.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A package can contain multiple plugins that depend on each other.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A package can contain plugins that are automatically loaded on startup and&#xA;ones that are only loaded when needed with &lt;code&gt;:packadd&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So the idea is to create a folder containing all of the plugins with the following structure:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$HOME/.vim/pack/my-plugins/&#xA;                        start/&#xA;                            foo/&#xA;                                plugin/&#xA;                                    foo.vim&#xA;                                syntax/&#xA;                                    some.vim&#xA;                            bar/&#xA;                                plugin/&#xA;                                    bar.vim&#xA;                        opt/&#xA;                            buzz/&#xA;                                plugin/&#xA;                                    buzz.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The emplacement of the folder is defined by the option &lt;code&gt;packpath&lt;/code&gt; (See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27packpath%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'packpath'&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Note the importance of the structure of your folder:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;start&lt;/code&gt; folder contains plugins which will be loaded automatically on startup.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;opt&lt;/code&gt; folder contains &amp;quot;optional&amp;quot; plugins, loaded with the &lt;code&gt;packadd&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;li&gt;The subfolders (&lt;code&gt;plugin&lt;/code&gt;, &lt;code&gt;autoload&lt;/code&gt;, &lt;code&gt;doc&lt;/code&gt;,...) are the ones you're used to in the plugins.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here is a recap of the folders:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;start/foobar/plugin/foo.vim     &amp;quot; always loaded, defines commands&#xA;start/foobar/plugin/bar.vim     &amp;quot; always loaded, defines commands&#xA;start/foobar/autoload/foo.vim   &amp;quot; loaded when foo command used&#xA;start/foobar/doc/foo.txt        &amp;quot; help for foo.vim&#xA;start/foobar/doc/tags           &amp;quot; help tags&#xA;opt/fooextra/plugin/extra.vim   &amp;quot; optional plugin, defines commands&#xA;opt/fooextra/autoload/extra.vim &amp;quot; loaded when extra command used&#xA;opt/fooextra/doc/extra.txt      &amp;quot; help for extra.vim&#xA;opt/fooextra/doc/tags           &amp;quot; help tags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Once these files are in the right place, opening Vim will load the plugins in &lt;code&gt;start&lt;/code&gt; and make the ones in &lt;code&gt;opt&lt;/code&gt; available with &lt;code&gt;:packadd&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Now, can this feature replace the existing plugin managers?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; This part may be a little bit opinionated.&lt;/p&gt;&#xA;&lt;p&gt;I think the approach of this new package manager is really different than the one of the plugins managers we were used to because it is made to manage one (or several) archive(s) containing some plugins.&lt;/p&gt;&#xA;&lt;p&gt;Out of the box, the package manager doesn't provide features to update your plugins one-by-one, to fetch them automatically from a Github address or to select the plugins you want to enable/disable.&lt;/p&gt;&#xA;&lt;p&gt;I'm not sure it will be really convenient to use it out of the box (especially because handling nested version control repositories can be a painful task) but maybe this is the occasion to make plugin managers more efficient?&lt;/p&gt;&#xA;&lt;p&gt;Now it is also possible to imagine moving the existing plugins to adopt the structure required by the package manager and to manage them directly from the file system. Maybe some wrapper will be created to use this new feature.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; As suggested by @Sato Katsura here is a note about the &lt;code&gt;helptags&lt;/code&gt; command. The Vim8 commit introduced two line in the &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/doc/helphelp.txt#L200-L201&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;helptag&lt;/code&gt; doc&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;:helpt[ags] [++t] {dir}&#xA;&#xA;Generate the help tags file(s) for directory {dir}.&#xA;When {dir} is ALL then all &amp;quot;doc&amp;quot; directories in 'runtimepath' will be used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Which means that the new package manager ease the generation of the helptags put in the user archive. With the single command &lt;code&gt;:helptags ALL&lt;/code&gt; all the helptags are generated.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2020-07-21T15:54:24.783" LastActivityDate="2020-07-21T15:54:24.783" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="9524" PostTypeId="1" AcceptedAnswerId="9527" CreationDate="2016-09-12T16:54:36.877" Score="5" ViewCount="1476" Body="&lt;p&gt;&lt;a href=&quot;https://valloric.github.io/YouCompleteMe/&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouCompleteMe&lt;/a&gt; puts symbols in the &quot;gutter&quot; (left of the editor) for errors:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nw99l.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nw99l.png&quot; alt=&quot;gutter present&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the gutter shifts the whole editor over, and it is only present when there is at least one error. Compare:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gGE8N.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gGE8N.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Short of always writing code with at least one error, how can I keep the width constant?&lt;/p&gt;&#xA;" OwnerUserId="9223" LastEditorUserId="51" LastEditDate="2016-09-12T18:31:13.853" LastActivityDate="2016-09-12T18:31:13.853" Title="How can I keep the gutter width constant when using YouCompleteMe?" Tags="|plugin-you-complete-me|signs|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9525" PostTypeId="5" CreationDate="2016-09-12T16:57:32.797" Score="0" Body="&lt;p&gt;Vim 8.0 is the newest version of vim, first &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_dev/CmiGxtJ7fn4&quot; rel=&quot;nofollow&quot;&gt;officially released&lt;/a&gt; on September 12, 2006. This version provides:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Asynchronous I/O support, channels, JSON &lt;/li&gt;&#xA;&lt;li&gt;Jobs &lt;/li&gt;&#xA;&lt;li&gt;Timers &lt;/li&gt;&#xA;&lt;li&gt;Partials, Lambdas and Closures &lt;/li&gt;&#xA;&lt;li&gt;Packages &lt;/li&gt;&#xA;&lt;li&gt;New style testing &lt;/li&gt;&#xA;&lt;li&gt;Viminfo merged by timestamp &lt;/li&gt;&#xA;&lt;li&gt;GTK+ 3 support &lt;/li&gt;&#xA;&lt;li&gt;MS-Windows DirectX support &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A full list of changes can be &lt;a href=&quot;https://raw.githubusercontent.com/vim/vim/master/runtime/doc/version8.txt&quot; rel=&quot;nofollow&quot;&gt;seen here.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-09-12T19:06:49.500" LastActivityDate="2016-09-12T19:06:49.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9526" PostTypeId="4" CreationDate="2016-09-12T16:57:32.797" Score="0" Body="Use this tag if your question is related to version 8 of vim, the newest official version, released on September 12, 2006." OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-09-12T19:06:27.540" LastActivityDate="2016-09-12T19:06:27.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9527" PostTypeId="2" ParentId="9524" CreationDate="2016-09-12T17:51:01.263" Score="7" Body="&lt;p&gt;Install Vim 8 (released a few hours ago), and set &lt;code&gt;signcolumn&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set signcolumn=yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a actually available in Vim 7.4.2201 and later, but you really should go for the major release instead.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="2313" LastEditDate="2016-09-12T17:57:25.560" LastActivityDate="2016-09-12T17:57:25.560" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9528" PostTypeId="2" ParentId="8812" CreationDate="2016-09-12T18:33:44.800" Score="1" Body="&lt;p&gt;Most likely, I generate mine with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/dotfiles/bundles/YCM-Generator&#xA;./config_gen.py -v -b cmake \&#xA;   --qt-version 5           \&#xA;   --configure_opts='-DQT_DIR=/opt/Qt5.3.2/5.3/gcc_64' \&#xA;   ~/workspace/my_source_directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(QT is obviously unique to my needs, but I left it in as an example of how to add the CMake options)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will place &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt; file into your source directory.&lt;/p&gt;&#xA;" OwnerUserId="7658" LastActivityDate="2016-09-12T18:33:44.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9529" PostTypeId="2" ParentId="74" CreationDate="2016-09-12T20:09:25.877" Score="3" Body="&lt;p&gt;I make my Vim save everything every time focus is lost.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FocusLost &amp;lt;your-patterns-here&amp;gt; silent! wall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My patterns are pretty long and I use them in several autocmds but for completeness this is what it looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(':keeppatterns')&#xA;    let s:keeppatterns = 'keeppatterns '&#xA;else&#xA;    let s:keeppatterns = ''&#xA;endif&#xA;&#xA;augroup AutoSaveGroup&#xA;    &quot; :help file-pattern has some info,&#xA;    &quot; but some of it is is buried in the PATTERNS section of usr_40.txt&#xA;    let s:autoPattern = &quot;*.{c,h,[ch]pp,[acjt]s,inl,cg,cgfx,fx,py,bat,cmd,jam,vim,yml,yaml,vsprops,erb,rb,html,htm},SCons*,*vimrc&quot;&#xA;&#xA;    autocmd!&#xA;    execute &quot;autocmd FocusLost&quot;     s:autoPattern   &quot;silent! wall&quot;&#xA;    execute &quot;autocmd BufWritePre&quot;   s:autoPattern   s:keeppatterns . 'call FixFormatting(expand(&quot;&amp;lt;afile&amp;gt;&quot;))'&#xA;&#xA;    execute &quot;autocmd FileChangedRO&quot; s:autoPattern &quot;silent !p4 edit %:p&quot;&#xA;    execute &quot;autocmd FileChangedRO&quot; s:autoPattern &quot;write!&quot;&#xA;&#xA;    autocmd FocusLost   *.txt   silent! wall&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2016-09-12T20:09:25.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9530" PostTypeId="1" AcceptedAnswerId="9532" CreationDate="2016-09-12T22:38:46.050" Score="3" ViewCount="1431" Body="&lt;p&gt;I've been using paredit.vim for editing Clojure files. It's quite successful in managing all those parentheses in a sane way. I'm looking for a similar way for editing function calls in other programming languages. Specifically I'm looking for three capabilities : &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Changing order of function parameters by moving a parameter to left or right, &lt;/li&gt;&#xA;&lt;li&gt;Deleting a parameter, &lt;/li&gt;&#xA;&lt;li&gt;When one of the parameters is a function call (there is a nested list of parameters) ability to move one parameter up and down in nesting level. Or in other words, ability to move the parentheses of the inner function call left and right.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;An example to the third item with paredit.vim command adapted to function arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f(1, 2, g(3, 4), 5)&#xA;              ^&#xA;            cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;gt;&lt;/code&gt; turns this into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f(1, 2, g(3, 4, 5))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First two items I want can be provided by defining a function argument as a text object. &lt;a href=&quot;https://github.com/PeterRincker/vim-argumentative&quot; rel=&quot;nofollow&quot;&gt;vim-argumentative&lt;/a&gt; and a couple of other plugins I've came across provides these items by defining function parameters as text objects. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the third item is a bit tricky. I could not find any plugin that provides this. And I could not figure out how defining function &#xA;parameters as text objects might help achieving this at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using paredit.vim is not an option, since paredit knows only about S-expressions of Lisp family, not comma separated function syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody know how to achieve this, preferably with a plugin, or a way that can be put into a plugin?&lt;/p&gt;&#xA;" OwnerUserId="6997" LastEditorUserId="51" LastEditDate="2016-09-13T14:46:49.470" LastActivityDate="2016-09-13T14:46:49.470" Title="Function argument editing" Tags="|formatting|ide|filetype-clojure|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9531" PostTypeId="2" ParentId="9520" CreationDate="2016-09-12T23:06:07.227" Score="0" Body="&lt;p&gt;With those settings, a &quot;line that doesn't adhere to current tabs settings&quot; is basically &quot;a line with spaces as indentation&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can highlight such lines by searching:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v^\t* +\t*[^\s]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Broken down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; − &quot;very magic&quot; mode so we don't have to use too many &lt;code&gt;\&lt;/code&gt; later (see &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5cv&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help /\v&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; − anchor to the start of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\t*&lt;/code&gt; − match zero or more tab characters.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt; +&lt;/code&gt; − match one or more space characters.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\t*&lt;/code&gt; − match zero or more tab characters again.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^\s]&lt;/code&gt; − match anything &lt;em&gt;except&lt;/em&gt; a space character.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Or if you want to highlight the entire line, add &lt;code&gt;.*&lt;/code&gt; to the end to also match the rest of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v^\t* +\t*[^\s].*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't want to clobber your search history with this, you can use &lt;code&gt;:match&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:match Error /\v^\t* +\t*[^\s].*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%3amatch&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help :match&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-09-12T23:06:07.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9532" PostTypeId="2" ParentId="9530" CreationDate="2016-09-13T00:09:57.127" Score="4" Body="&lt;p&gt;What about &lt;code&gt;%%xvi,&amp;lt;esc&amp;gt;p&lt;/code&gt; from (almost (*)) anywhere within a function call, with my &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp/blob/master/plugin/omap-param.vim&quot; rel=&quot;nofollow&quot;&gt;omap-param.vim&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first &lt;code&gt;%&lt;/code&gt; goes to the embedded open parenthesis. The second &lt;code&gt;%&lt;/code&gt; to the closing &lt;code&gt;)&lt;/code&gt;. I delete it, then I ask to the &lt;code&gt;vi,&lt;/code&gt;mapping to find the current parameter, it'll select everything from the coma under the cursor to the end of the following parameter without the following &lt;code&gt;)&lt;/code&gt; or &lt;code&gt;,&lt;/code&gt;. Escape, and you'll be at the end of the parameter, here &lt;code&gt;5&lt;/code&gt;. Paste the closing &lt;code&gt;)&lt;/code&gt; and you're done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) If we start on the opening bracket, we must use only one &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: you could also program the movements, you'll need one of the two &lt;code&gt;searchpair*()&lt;/code&gt; function to do it. The pairs to be searched are &lt;code&gt;'(', ',', ')'&lt;/code&gt;. But beware of the corner cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As vim-argumentative seems to use the same mappings, depending on whether we handle corner cases in the same way, it should work as well.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-09-13T09:25:53.970" LastActivityDate="2016-09-13T09:25:53.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9533" PostTypeId="2" ParentId="74" CreationDate="2016-09-13T07:45:10.853" Score="10" Body="&lt;p&gt;I made a plugin &lt;a href=&quot;https://github.com/chrisbra/vim-autosave&quot; rel=&quot;noreferrer&quot;&gt;vim-autosave&lt;/a&gt; which uses Vim 8 feature of Timers to periodically save your buffers.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-09-13T07:45:10.853" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9534" PostTypeId="2" ParentId="9412" CreationDate="2016-09-13T18:39:25.583" Score="0" Body="&lt;p&gt;Like your other responders, I'm not at all sure exactly what it is that you're desirious of doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If  you're using &lt;code&gt;gf&lt;/code&gt; on a &lt;code&gt;&lt;a href=&quot;http://host/path&quot; rel=&quot;nofollow&quot;&gt;http://host/path&lt;/a&gt;&lt;/code&gt;, then you want to disable netrw responding to the &lt;code&gt;http://&lt;/code&gt; string.  To do that, I suggest writing your own plugin that is a copy of &lt;code&gt;augroup Network ... augroup END&lt;/code&gt; without the &lt;code&gt;http://&lt;/code&gt; support.  Include a &lt;code&gt;au BufReadCmd http://*&lt;/code&gt; to do whatever it is that you want done. You can find this code in netrwPlugin.vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use &lt;code&gt;gf&lt;/code&gt; on a &lt;code&gt;salt://&lt;/code&gt; path, then netrw shouldn't be involved at all, as &lt;code&gt;salt://&lt;/code&gt; isn't in the BufReadCmds (in &lt;code&gt;augroup&lt;/code&gt; Network).  In that case, please describe/give an example where this netrw interference occurs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In looking back at your new &amp;amp; improved question, it appears to me that netrw has nothing to do with your issue.  That's because the &quot;salt://*&quot; url is not one of those that netrw sets up with Buf(Read|Write)Cmds.  However, there's a clue in that: try setting up your own BufReadCmd!  As an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;au BufReadCmd salt://*  :exe &quot;r &quot;.substitute(expand(&quot;&quot;),'salt://\(.*\)',expand(&quot;$HOME&quot;).'/\1','')&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change the path to suit your needs, of course.  You may also wish to have a BufWriteCmd; I'll leave that as an exercise.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastEditorUserId="2377" LastEditDate="2016-10-31T13:56:31.177" LastActivityDate="2016-10-31T13:56:31.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9535" PostTypeId="2" ParentId="9287" CreationDate="2016-09-13T18:44:40.730" Score="0" Body="&lt;p&gt;You can also use &lt;code&gt;:Lexplore&lt;/code&gt; to get a vertically split window containing a directory listing with netrw, and use &lt;code&gt;:Rexplore&lt;/code&gt; to return from that or any netrw listing back to the file.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastEditorUserId="-1" LastEditDate="2016-10-02T11:28:58.607" LastActivityDate="2016-10-02T11:28:58.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9537" PostTypeId="1" AcceptedAnswerId="10324" CreationDate="2016-09-13T21:05:15.210" Score="2" ViewCount="266" Body="&lt;p&gt;I have a line that fits a &quot;template&quot;, and multiple pieces of &quot;data&quot;. For each piece of data, I want to copy the template and replace all occurrences of a pattern in that line with the data. I'm using the method below, but I want to know if there's a better (shorter, easier) way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given this buffer (cursor is at &lt;code&gt;|&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|Hello, world!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And these commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;ayy&#xA;:for data in ['one', 'two', 'three'] | exe 'norm! &quot;ap' | exe 's/world/' . data . '/' | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The buffer becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hello, world!&#xA;Hello, one!&#xA;Hello, two!&#xA;|Hello, three!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1176" LastEditorUserId="1176" LastEditDate="2016-09-14T17:51:43.937" LastActivityDate="2016-11-17T23:05:04.260" Title="How to replace pattern in multiple lines with different replacements?" Tags="|cut-copy-paste|substitute|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9538" PostTypeId="2" ParentId="9537" CreationDate="2016-09-13T22:01:29.380" Score="0" Body="&lt;p&gt;What about &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; untested&#xA;let res = map(copy(['a', 'b', 'c']), 'substitute(@a, &quot;evenmoreescapedpattern&quot;, v:val, &quot;g&quot;)')&#xA;&quot; or with vim8 lambdas&#xA;let res = map(copy(['a', 'b', 'c']), {idx,val -&amp;gt; substitute(@a, 'pattern', val, 'g')})&#xA;put=res &quot; or call append('.', res)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;?&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-09-13T22:01:29.380" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9539" PostTypeId="2" ParentId="6366" CreationDate="2016-09-13T22:46:58.857" Score="2" Body="&lt;p&gt;With some caveats, you can do this using Vim's binary mode. It seems you might want to use the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -b +'set list' somefile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can put the following in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set binary&#xA;:set list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The important thing is that binary mode must get set &lt;em&gt;before&lt;/em&gt; the file in question is read into a buffer. Once Vim has read the file in, it's too late; this trick relies on changing how Vim reads the file in. Specifically, what you need is for Vim to &lt;em&gt;not&lt;/em&gt; attempt to guess the file's particular type of &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Binary mode does what you want, disabling this automatic line-separator detection, but it does quite a few other things as well:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;sets &lt;code&gt;'textwidth'&lt;/code&gt; to 0&lt;/li&gt;&#xA;&lt;li&gt;sets &lt;code&gt;'wrapmargin'&lt;/code&gt; to 0&lt;/li&gt;&#xA;&lt;li&gt;unsets &lt;code&gt;'modeline'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;unsets &lt;code&gt;'expandtab'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So you might not want to have this in your &lt;code&gt;.vimrc&lt;/code&gt;; it might be better to use the command-line version, and only for those files where you need this special kind of display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'binary'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help edit-binary&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help file-read&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help file-formats&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'fileformat'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="527" LastActivityDate="2016-09-13T22:46:58.857" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9540" PostTypeId="2" ParentId="4298" CreationDate="2016-09-14T11:20:29.687" Score="0" Body="&lt;p&gt;This method works well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export LC_ALL=en_US.utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the Russian language, for example, then it is necessary to dial the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimtutor ru&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for Portuguese&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimtutor pt  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9249" LastEditorUserId="1841" LastEditDate="2016-09-14T11:33:19.190" LastActivityDate="2016-09-14T11:33:19.190" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9542" PostTypeId="1" CreationDate="2016-09-14T18:34:45.280" Score="0" ViewCount="1265" Body="&lt;p&gt;I'm trying to adapt this known-working snippet for installing &lt;code&gt;vim-plug&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if empty(glob('~/.vim/autoload/plug.vim'))&#xA;  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs&#xA;    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;  autocmd VimEnter * PlugInstall | source $MYVIMRC&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Seeing as I already have &lt;code&gt;set runtimepath=$XDG_CONFIG_HOME/vim&lt;/code&gt;, I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; BROKEN&#xA;let vimplug=$XDG_CONFIG_HOME.&quot;/vim/.vim/autoload/plug.vim&quot; &#xA;if empty(glob(vimplug))&#xA;    silent execute '!curl -fLo '.vimplug.' --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'&#xA;    autocmd VimEnter * PlugInstall | source $MYVIMRC &#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which errors on exit with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; You don't have permission to create /vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which suggests to me that it's evaluating &lt;code&gt;$XDG_CONFIG_HOME&lt;/code&gt; to an empty string, but it is set, so this is where I'm stuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added the &lt;code&gt;execute&lt;/code&gt; because I understood that to be the correct way to evaluate variables before executing a command; what have I missed?&lt;/p&gt;&#xA;" OwnerUserId="9256" LastActivityDate="2019-01-10T15:46:28.773" Title="Execute curl command with variable interpolation" Tags="|vimrc|variables|environment-variables|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9543" PostTypeId="1" CreationDate="2016-09-14T19:48:35.060" Score="11" ViewCount="9179" Body="&lt;p&gt;Looking at the &lt;a href=&quot;https://github.com/vim/vim/blob/89bcfda6834aba724d12554a34b9ed49f5789fd5/runtime/ftplugin/markdown.vim&quot; rel=&quot;noreferrer&quot;&gt;ftplugin file for markdown&lt;/a&gt; in Vim, it certainly appears that folding is supported, but I cannot get folding to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have some content like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# A heading&#xA;&#xA;Some content.&#xA;More content.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I fold up this heading and its content?&lt;/p&gt;&#xA;" OwnerUserId="9258" LastActivityDate="2018-07-06T17:48:47.603" Title="How to fold markdown using the built-in markdown mode?" Tags="|folding|filetype-markdown|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9544" PostTypeId="2" ParentId="9543" CreationDate="2016-09-14T20:04:54.523" Score="8" Body="&lt;h2&gt; Markdown folding: &lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As ana found out, for markdown specifically make sure that you have &lt;code&gt;let g:markdown_folding = 1&lt;/code&gt; or folding wont be &quot;turned on&quot;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;General folding tips:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Vim won't fold automatically, try putting your cursor over the text and doing &lt;code&gt;zc&lt;/code&gt;. This should close the fold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want some visual context even when it's not folded try the foldcolumn option!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldcolumn=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more info see &lt;code&gt;:h zo&lt;/code&gt; and &lt;code&gt;:h foldcolumn&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-09-15T14:45:27.820" LastActivityDate="2016-09-15T14:45:27.820" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9545" PostTypeId="1" CreationDate="2016-09-14T20:06:42.353" Score="1" ViewCount="112" Body="&lt;p&gt;I want to &lt;em&gt;Vim&lt;/em&gt; to behave like &lt;em&gt;nvi&lt;/em&gt; when opening a in an empty buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is an empty buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----------------------------------------&#xA;~&#xA;~&#xA;~&#xA;~&#xA;----------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After typing &lt;code&gt;oHello, world!&amp;lt;esc&amp;gt;&lt;/code&gt; I want to get this result (which is how it behaves in the original &lt;em&gt;Vi&lt;/em&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----------------------------------------&#xA;Hello, world!&#xA;~&#xA;~&#xA;~&#xA;----------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;em&gt;Vim&lt;/em&gt; i get this result instead (notice extra blank line):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----------------------------------------&#xA;&#xA;Hello, world!&#xA;~&#xA;~&#xA;----------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can get &lt;em&gt;Vim&lt;/em&gt; to behave like &lt;em&gt;nvi&lt;/em&gt; when opening new lines in an empty buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the &lt;em&gt;nvi&lt;/em&gt; behavior is much more useful when I want to type something like &lt;code&gt;8oEight long lines...&amp;lt;esc&amp;gt;&lt;/code&gt; in an empty buffer. Then I don't have to remove the extra blank line that &lt;em&gt;Vim&lt;/em&gt; always creates when doing that.&lt;/p&gt;&#xA;" OwnerUserId="3032" LastEditorUserId="51" LastEditDate="2016-09-15T20:00:01.727" LastActivityDate="2016-09-15T20:00:01.727" Title="Vim to behave like nvi when opening line in empty buffer" Tags="|buffers|nvi|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9546" PostTypeId="1" CreationDate="2016-09-14T23:05:54.423" Score="3" ViewCount="2945" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/junegunn/vim-easy-align&quot; rel=&quot;nofollow&quot;&gt;vim-easy-align plugin&lt;/a&gt; says to assign the following keymaps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xmap ga &amp;lt;Plug&amp;gt;(EasyAlign)&#xA;nmap ga &amp;lt;Plug&amp;gt;(EasyAlign)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought these would work equally well with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap ga &amp;lt;Plug&amp;gt;(EasyAlign)&#xA;nnoremap ga &amp;lt;Plug&amp;gt;(EasyAlign)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it doesn't. I thought &lt;code&gt;map&lt;/code&gt; is recursive and &lt;code&gt;noremap&lt;/code&gt; is non-recursive, and since there is no recursion, they should behave identically here. Why not?&lt;/p&gt;&#xA;" OwnerUserId="9262" LastEditorUserId="24" LastEditDate="2016-10-21T20:51:08.837" LastActivityDate="2016-10-21T20:51:08.837" Title="Why does nmap work but nnoremap not work to set up vim-easy-align shortcut?" Tags="|key-bindings|plugin-easy-align|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9547" PostTypeId="2" ParentId="9546" CreationDate="2016-09-15T06:23:28.503" Score="7" Body="&lt;p&gt;Let's start with the difference between recursive mapping and non-recursive mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a recursive mapping (&lt;code&gt;nmap&lt;/code&gt;, &lt;code&gt;xmap&lt;/code&gt;, etc.), the keys you use in the right hand side of your mapping are used &quot;as is&quot;. If they are already mapped at the time of execution those mappings are respected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; here we remap b to work like B&#xA;nmap b B&#xA;&#xA;&quot; &amp;lt;F5&amp;gt; thus works like dB instead of db because it uses the new meaning of b&#xA;nmap &amp;lt;F5&amp;gt; db&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a non-recursive mapping (&lt;code&gt;nnoremap&lt;/code&gt;, &lt;code&gt;xnoremap&lt;/code&gt;, etc.), the keys in the right hand side are used in their original meaning. If they are already mapped at the time of execution those mappings are &lt;em&gt;not&lt;/em&gt; respected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; here we remap b to work like B&#xA;nmap b B&#xA;&#xA;&quot; &amp;lt;F5&amp;gt; works like db because it uses the original meaning of b&#xA;nnoremap &amp;lt;F5&amp;gt; db&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;Plug&amp;gt;(EasyAlign)&lt;/code&gt; being a mapping, it is respected by recursive mappings and ignored by non-recursive ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The rules are:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a recursive mapping if you want to use another mapping in your mapping.&lt;/li&gt;&#xA;&lt;li&gt;Use a non-recursive mapping if you don't.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-09-15T12:41:57.647" LastActivityDate="2016-09-15T12:41:57.647" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9548" PostTypeId="1" AcceptedAnswerId="9549" CreationDate="2016-09-15T11:01:28.213" Score="3" ViewCount="374" Body="&lt;p&gt;I have the following setting in my .vimrc for highlight long lines (&gt;79) for python files&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc_autocmds&#xA;    autocmd!&#xA;    autocmd FileType python,rst highlight Excess ctermbg=DarkGrey  guibg=Black&#xA;    autocmd FileType python,rst match Excess /\%79v.*/&#xA;    autocmd FileType python,rst set nowrap&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By some reason Vim highlights also other files (like .robot).&#xA;&lt;a href=&quot;https://i.stack.imgur.com/kWuqt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kWuqt.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="9269" LastEditorUserId="51" LastEditDate="2016-09-15T12:30:04.730" LastActivityDate="2016-09-15T12:30:04.730" Title="Vim highlights long lines for all files" Tags="|vimrc|highlight|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9549" PostTypeId="2" ParentId="9548" CreationDate="2016-09-15T11:09:11.870" Score="5" Body="&lt;p&gt;According to &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#:match&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :match&lt;/code&gt;&lt;/a&gt;, it &lt;code&gt;Define a pattern to highlight in the current window.&lt;/code&gt;. Thus if you open any other buffer (file) on the same &lt;em&gt;window&lt;/em&gt; it will also display the highlight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would be better off by extending the syntax highlight for some languages, as explained at &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-24.11&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim FAQ 24.11. &quot;How do I add my own syntax extensions to the standard syntax files supplied with Vim?&quot;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to use the autocmd events &lt;code&gt;BufEnter&lt;/code&gt; to set the match and &lt;code&gt;BufLeave&lt;/code&gt; to clear it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, you could avoid cluttering your vimrc by using ftplugins, &lt;a href=&quot;https://vi.stackexchange.com/a/8373/1405&quot;&gt;as explained in here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2016-09-15T11:22:52.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9550" PostTypeId="1" AcceptedAnswerId="9552" CreationDate="2016-09-15T14:35:16.527" Score="-1" ViewCount="107" Body="&lt;p&gt;I have a unnamed buffer and a js buffer open in a vertical split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the unnamed buffer I'm trying to type an already existing function name. In the js buffer I typed two characters, but when I &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-n&amp;gt;&lt;/code&gt;, it shows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Keyword Local completion (^N^P) Pattern not found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;complete&lt;/code&gt; option is set like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; complete=.,w,b,u,t,i,U,k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="2313" LastEditDate="2016-09-15T15:16:11.520" LastActivityDate="2016-09-15T15:23:59.423" Title="Why vim can't find a word in a js buffer when autocompletting?" Tags="|autocompletion|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9551" PostTypeId="2" ParentId="8729" CreationDate="2016-09-15T14:37:39.487" Score="1" Body="&lt;p&gt;There's a nice option called background.&lt;/p&gt;&#xA;&lt;p&gt;From my .vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; sets dark background for terminal&#xA;set background=dark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will tell vim that you have a dark background, and therefore it should make the text light.&lt;/p&gt;&#xA;&lt;p&gt;In vim, type &lt;code&gt;:help 'background'&lt;/code&gt; to see the doc for this option.&lt;/p&gt;&#xA;" OwnerUserId="9272" LastEditorUserId="10604" LastEditDate="2021-10-04T23:16:03.910" LastActivityDate="2021-10-04T23:16:03.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9552" PostTypeId="2" ParentId="9550" CreationDate="2016-09-15T15:23:59.423" Score="2" Body="&lt;p&gt;First, the &lt;code&gt;complete&lt;/code&gt; option is ignored by &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; so its value is irrelevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; only completes from the current buffer, as explained in &lt;code&gt;:h ins-completion&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2. keywords in the current file             |i_CTRL-X_CTRL-N|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;:help compl-current&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Completing keywords in current file         *compl-current*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to complete from other buffers, use &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-09-15T15:23:59.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9553" PostTypeId="1" AcceptedAnswerId="9557" CreationDate="2016-09-15T16:13:01.650" Score="7" ViewCount="2160" Body="&lt;p&gt;When writing C/C++ code, vim defaults to forcing any pound sign (&quot;#&quot;) to the zero position column. This is fine for for C/C++, but it is very annoying for shell scripting and perl scripting, since the pound sign is used for comments. For example, if I try to type this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [ -e foo.txt ]&#xA;then&#xA;    # This is a comment&#xA;    # which I want to stay aligned here&#xA;    do_the_stuff&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I get instead is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [ -e foo.txt ]&#xA;then&#xA;# This is a comment&#xA;# which is no longer where I want it to be aligned!&#xA;    do_the_stuff&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and I have to go and correct this by hand (really slows me down!). Now if I make sure &lt;code&gt;cindent&lt;/code&gt; and &lt;code&gt;smartindent&lt;/code&gt; are turned off, and turn on &lt;code&gt;autoindent&lt;/code&gt;, the annoying &quot;comment-grab&quot; doesn't happen. However, the indentation is not very &quot;smart&quot; and does not respect the syntax as well as when &lt;code&gt;smartindent&lt;/code&gt; is turned on. However, &lt;code&gt;smartindent&lt;/code&gt; is better, but the auto-grabbing of '#' keeps happening. How can I turn off just the &quot;comment-grab&quot; without messing up the language-dependent indentation smarts? Is there a nifty switch I can just turn on in my &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT:&lt;/em&gt; I'm running Ubuntu Linux 16.04 x64 vim 7.4.1689&lt;/p&gt;&#xA;" OwnerUserId="9275" LastEditorUserId="9275" LastEditDate="2016-09-15T16:32:41.963" LastActivityDate="2016-09-15T18:52:03.540" Title="How do I turn off the &quot;feature&quot; where the pound sign &quot;#&quot; is forced to 0 position?" Tags="|bash|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9554" PostTypeId="2" ParentId="9468" CreationDate="2016-09-15T16:17:07.543" Score="0" Body="&lt;p&gt;I've found that the Supertab plugin (&lt;a href=&quot;https://github.com/ervandew/supertab&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ervandew/supertab&lt;/a&gt;) let me use tab for deoplete completions, without needing any additional configuration.&lt;/p&gt;&#xA;" OwnerUserId="9277" LastActivityDate="2016-09-15T16:17:07.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9555" PostTypeId="1" CreationDate="2016-09-15T17:26:44.710" Score="0" ViewCount="163" Body="&lt;p&gt;I am using Neocomplete and vdav/chef-vim plugin to write chef code using a snippet. I see the following snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; # Template resource&#xA;template &quot;/path/to/file&quot; do # Path to the file&#xA;  &amp;lt;`2:#`&amp;gt;cookbook &amp;lt;`3:nil`&amp;gt; # Specify the cookbook where the template is located, default is current cookbook&#xA;  &amp;lt;`4:#`&amp;gt;source &amp;lt;`5:nil`&amp;gt; # Template source file. Found in templates/default for the cookbook&#xA;  &amp;lt;`6:#`&amp;gt;variables &amp;lt;`7`&amp;gt; # Variables to use in the template&#xA;  &amp;lt;`8:#`&amp;gt;local &amp;lt;`9:false`&amp;gt; # Is the template already present on the node?&#xA;  &amp;lt;`10:#`&amp;gt;backup &amp;lt;`11:5`&amp;gt; # How many backups of this file to keep. Set to false if you want no backups.&#xA;  &amp;lt;`12:#`&amp;gt;owner &amp;lt;`13`&amp;gt; # The owner for the file&#xA;  &amp;lt;`14:#`&amp;gt;group &amp;lt;`15`&amp;gt; # The group owner of the file (string or id)&#xA;  &amp;lt;`16:#`&amp;gt;mode &amp;lt;`17`&amp;gt; # The octal mode of the file (4-digit format)&#xA;  &amp;lt;`18:#`&amp;gt;content &amp;lt;`19:nil`&amp;gt; # A string to write to the file. This will replace any previous content if set&#xA;&#xA;  &amp;lt;`20:#`&amp;gt;&amp;lt;`21:action :create`&amp;gt; # Create the file (Default)&#xA;  &amp;lt;`22:#`&amp;gt;&amp;lt;`23:action :delete`&amp;gt; # Delete this file&#xA;  &amp;lt;`24:#`&amp;gt;&amp;lt;`0:action :touch`&amp;gt; # Touch this file (update the mtime/atime)&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code snippet however should have been as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Template resource&#xA;template &quot;/path/to/file&quot; do # Path to the file&#xA;  cookbook nil # Specify the cookbook where the template is located, default is current cookbook&#xA;  source nil # Template source file. Found in templates/default for the cookbook&#xA;  variables  # Variables to use in the template&#xA;  local false # Is the template already present on the node?&#xA;  backup 5 # How many backups of this file to keep. Set to false if you want no backups.&#xA;  owner  # The owner for the file&#xA;  group  # The group owner of the file (string or id)&#xA;  mode  # The octal mode of the file (4-digit format)&#xA;  content nil # A string to write to the file. This will replace any previous content if set&#xA;&#xA;  action :create # Create the file (Default)&#xA;  action :delete # Delete this file&#xA;  action :touch # Touch this file (update the mtime/atime)&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I remove this additional symbolic &lt;em&gt;&amp;lt;&lt;code&gt;#&lt;/code&gt;&gt; text &amp;lt;&lt;code&gt;#:text&lt;/code&gt;&gt;&lt;/em&gt; text generated in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using &lt;em&gt;nnoremap  :let _s=@/:%s/\s+$//e:let @/=_s&lt;/em&gt; to remove it, however it did not help. May be I am not doing it correctly too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .vimrc and .vimrc.local can be found &lt;a href=&quot;http://pastebin.com/MN8XXD41&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9279" LastActivityDate="2016-10-15T18:04:09.613" Title="How to remove unnecessary tags generated by neocomplete plugin of vim in my code snippet?" Tags="|vimrc|plugin-neocomplete|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9556" PostTypeId="2" ParentId="9555" CreationDate="2016-09-15T17:50:48.647" Score="1" Body="&lt;p&gt;You can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;lt;[^&amp;gt;]*&amp;gt;//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to use it multiple times make a map for it like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap g&amp;lt;space&amp;gt; :%s/&amp;lt;[^&amp;gt;]*&amp;gt;//g&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can use it by pressing g (you can change that of course)&lt;/p&gt;&#xA;" OwnerUserId="710" LastActivityDate="2016-09-15T17:50:48.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9557" PostTypeId="2" ParentId="9553" CreationDate="2016-09-15T18:47:11.157" Score="8" Body="&lt;p&gt;As documented in &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27smartindent%27&quot;&gt;&lt;code&gt;:help 'smartindent'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When typing '#' as the first character in a new line, the indent for that line is removed, the '#' is put in the first column.  The indent is restored for the next line.  If you don't want this, use this mapping: &quot;:inoremap # X^H#&quot;, where ^H is entered with CTRL-V CTRL-H.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is, &lt;code&gt;'smartindent'&lt;/code&gt; causes this behavior and there's no way to disable it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'smartindent'&lt;/code&gt; itself should pretty much be considered deprecated in favor of &lt;code&gt;'cindent'&lt;/code&gt; or the filetype specific indent scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;'cindent'&lt;/code&gt;, this behavior &lt;strong&gt;can&lt;/strong&gt; be controlled by &lt;code&gt;'cinkeys'&lt;/code&gt;.  With filetype indent scripts, which you can enable by adding &lt;code&gt;filetype indent on&lt;/code&gt; to your vimrc, there are scripts (located in the &lt;code&gt;indent/&lt;/code&gt; directory in the runtime paths) that help determine how to perform indentation based on the buffer's contents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As implied by Carpetsmoker, an indent script for shell scripts comes with Vim already.  Enabling the use of that will likely resolve the issue you're seeing and probably give better overall indent results.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="51" LastEditDate="2016-09-15T18:52:03.540" LastActivityDate="2016-09-15T18:52:03.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9558" PostTypeId="1" AcceptedAnswerId="9563" CreationDate="2016-09-15T19:54:32.257" Score="3" ViewCount="12043" Body="&lt;p&gt;I'm pretty new to Vim and &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;junegunn/vim-plug: Minimalist Vim Plugin Manager&quot;&gt;vim-plug&lt;/a&gt; and I can't get the latter to install my plugins.&lt;/p&gt;&#xA;&lt;p&gt;I think I've set everything up—see my files below. But when I start Vim and enter &lt;code&gt;:PlugStatus&lt;/code&gt;, it shows a blank list. &lt;code&gt;:PlugInstall&lt;/code&gt; returns &lt;code&gt;No plugin to install&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Can somebody tell me what I'm doing wrong?&lt;/p&gt;&#xA;&lt;h2&gt;Context&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Mac OS X 10.11.6&lt;/li&gt;&#xA;&lt;li&gt;Vim 8.0.2&lt;/li&gt;&#xA;&lt;li&gt;I don't know how vim-plug is versioned, but &lt;code&gt;:PlugUpgrade&lt;/code&gt; returns &lt;code&gt;vim-plug is already up-to-date&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;git 2.7.4 (Apple Git-66)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:ruby puts RUBY_VERSION&lt;/code&gt;: &lt;code&gt;2.3.1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:python import platform; print(platform.python_version())&lt;/code&gt;: &lt;code&gt;2.7.12&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Files:&lt;/h2&gt;&#xA;&lt;h3&gt;&lt;code&gt;.vimrc&lt;/code&gt;:&lt;/h3&gt;&#xA;&lt;p&gt;(note the last line)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;filetype plugin indent on&#xA;set relativenumber&#xA;set number&#xA;&#xA;&amp;quot; searching&#xA;set incsearch&#xA;set hlsearch&#xA;set ignorecase&#xA;set smartcase&#xA;&#xA;&amp;quot; backspace over everything&#xA;set backspace=indent,eol,start&#xA;&#xA;&amp;quot; number of spaces inserted by tab&#xA;set shiftwidth=4&#xA;&#xA;&amp;quot; status line&#xA;hi User1 ctermbg=gray  ctermfg=black&#xA;hi User2 ctermbg=gray  ctermfg=red cterm=bold&#xA;&#xA;set laststatus=2&#xA;set statusline=     &amp;quot;reset statusline&#xA;set statusline+=%1* &amp;quot;black on gray&#xA;set statusline+=%F      &amp;quot;full filename&#xA;&amp;quot; set statusline+=[%{strlen(&amp;amp;fenc)?&amp;amp;fenc:'none'}, &amp;quot;file encoding&#xA;&amp;quot; set statusline+=%{&amp;amp;ff}] &amp;quot;file format&#xA;set statusline+=\ %y    &amp;quot;filetype&#xA;set statusline+=\ %h    &amp;quot;help file flag&#xA;set statusline+=\ %2*   &amp;quot;white on red&#xA;set statusline+=%m      &amp;quot;modified flag&#xA;set statusline+=%1* &amp;quot;black on gray&#xA;set statusline+=\ %r    &amp;quot;read only flag&#xA;set statusline+=%=      &amp;quot;left/right separator&#xA;set statusline+=%c,     &amp;quot;cursor column&#xA;set statusline+=%l/%L   &amp;quot;cursor line/total lines&#xA;set statusline+=\ \ %P  &amp;quot;percent through file&#xA;&#xA;&amp;quot; load vim-plug&#xA;source ~/.vim/.plug.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;&lt;code&gt;.vim.plug&lt;/code&gt;:&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; plug&#xA;&amp;quot; Config for vim-plug&#xA;&amp;quot; https://github.com/junegunn/vim-plug&#xA;&#xA;&amp;quot; install vim-plug if we don't already have it&#xA;if empty(glob('~/.vim/autoload/plug.vim'))&#xA;    &amp;quot; ensure directories exist&#xA;    execute '!mkdir -p ~/.vim/autoload'&#xA;    execute '!mkdir -p ~/.vim/plugged'&#xA;    &amp;quot; download vim-plug&#xA;    silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs&#xA;    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;    autocmd VimEnter * PlugInstall | source ~/.vim/.plug.vim&#xA;endif&#xA;&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;&amp;quot; Defaults everyone can agree on&#xA;Plug 'tpope/vim-sensible'&#xA;&#xA;&amp;quot; quoting/parenthesizing made simple&#xA;Plug 'tpope/vim-surround'&#xA;&#xA;&amp;quot; syntax highlighting&#xA;Plug 'tomvanderlee/vim-kerboscript', { 'for': 'kerboscript' }&#xA;&#xA;call plug#begin()&#xA;&amp;quot; ANSWER: ^^^^^  that should be `end`!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9267" LastEditorUserId="9267" LastEditDate="2022-10-07T18:28:02.853" LastActivityDate="2022-10-07T18:28:02.853" Title="Why won't vim-plug install my plugins? [typo]" Tags="|plugin-vim-plug|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ClosedDate="2016-09-16T11:39:16.843" ContentLicense="CC BY-SA 4.0" />
  <row Id="9559" PostTypeId="2" ParentId="6995" CreationDate="2016-09-15T20:07:34.750" Score="4" Body="&lt;p&gt;From the &lt;a href=&quot;https://github.com/junegunn/vim-plug/wiki/faq#conditional-activation&quot; rel=&quot;nofollow&quot;&gt;FAQ&lt;/a&gt; (prettier formatting there):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h3&gt;Conditional activation&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;Use plain &quot;if&quot; statement to conditionally activate plugins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('mac')&#xA;  Plug 'junegunn/vim-xmark'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;The caveat is that when the condition is not met, &lt;code&gt;PlugClean&lt;/code&gt; will try to remove the plugin. This can be problematic if you share the same configuration across terminal Vim, GVim, and Neovim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; When started with plain Vim, the plugin is not registered&#xA;&quot; and PlugClean will try to remove it&#xA;if has('nvim')&#xA;  Plug 'benekastah/neomake'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Alternatively, you can pass an empty &lt;code&gt;on&lt;/code&gt; or &lt;code&gt;for&lt;/code&gt; option so that the plugin is registered but not loaded by default depending on the condition.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'benekastah/neomake', has('nvim') ? {} : { 'on': [] }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;A helper function can improve the readability.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Cond(cond, ...)&#xA;  let opts = get(a:000, 0, {})&#xA;  return a:cond ? opts : extend(opts, { 'on': [], 'for': [] })&#xA;endfunction&#xA;&#xA;&quot; Looks better&#xA;Plug 'benekastah/neomake', Cond(has('nvim'))&#xA;&#xA;&quot; With other options&#xA;Plug 'benekastah/neomake', Cond(has('nvim'), { 'on': 'Neomake' })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="9267" LastActivityDate="2016-09-15T20:07:34.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9560" PostTypeId="1" CreationDate="2016-09-15T20:09:12.727" Score="3" ViewCount="240" Body="&lt;p&gt;This is probably easier to explain with an example. I prefer expressing things like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const array = { a: 1, b: 2, c: 3 }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;on a single line at first but eventually I might want to switch to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const array = {&#xA;  a: 1,&#xA;  b: 2,&#xA;  c: 3,&#xA;  d: 4,&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as the array gets longer. I realized that I'm not doing this very efficiently and I was wondering if there's some builtin way, or at least a more elegant way, to toggle between the two different styles.&lt;/p&gt;&#xA;" OwnerUserId="9283" LastActivityDate="2016-09-28T14:27:23.990" Title="How can I toggle between single and multi-line expressions of arrays?" Tags="|formatting|rearrangement|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9561" PostTypeId="2" ParentId="9560" CreationDate="2016-09-15T20:51:16.700" Score="1" Body="&lt;p&gt;Here is a slight workaround, which is interesting to learn new functionalities and can solve your problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you consider having a &lt;code&gt;,&lt;/code&gt; after each element in your array (which is valid, given the 2nd expression), you can use a substitution to do the job:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\({\|,\)/\1\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's break it down:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/                    create a substitution command&#xA;\(                     create a matching group for your regex&#xA;{\|,                   match a { OR a ,&#xA;\)                     end the matching group&#xA;/                      substitute the matched regex with &#xA;\1                     the element matched in the group: a { or a ,&#xA;\r                     a end of line character&#xA;/g                     apply for all matching of the line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you'll get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const array = {&#xA;  a: 1,&#xA;  b: 2,&#xA;  c: 3,&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With your cursor on the last &lt;code&gt;{&lt;/code&gt;, and from there &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; will de-indent the closing curly brace.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now if you want to do the other way around, select your array in linewise &lt;code&gt;V&lt;/code&gt;isual mode and simply press &lt;code&gt;J&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will &lt;code&gt;J&lt;/code&gt;oin the lines into one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or (as VanLaser) suggested, on the first or last line you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V%J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt; will enter linewise visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt; will go to the matching curly brace&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;J&lt;/code&gt; will join the lines&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some reading:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h \|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h \(&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h \1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h v_J&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h %&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-09-16T06:31:58.597" LastActivityDate="2016-09-16T06:31:58.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9562" PostTypeId="2" ParentId="9560" CreationDate="2016-09-15T20:59:31.477" Score="1" Body="&lt;p&gt;I think @nobe4's solution is more elegant, but I already wrote this :). So here's something I whipped up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :call ToggleArrayFormat()&amp;lt;CR&amp;gt;&#xA;&#xA;function! ToggleArrayFormat()&#xA;   let direction = search('}', 'cnp', line('.'))&#xA;   if (direction)&#xA;      normal! 0f{a^M&#xA;      while (search(',', 'cnp', line('.')))&#xA;         normal! f,a^M&#xA;      endwhile&#xA;      normal! f}i^M&#xA;   else&#xA;      echom &quot;stuff&quot;&#xA;      while !search('}', 'cnp', line('.'))&#xA;         normal! J&#xA;      endwhile&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^M&lt;/code&gt; is not a literal &quot;^M&quot; and needs to be retyped with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;, &lt;kbd&gt;Enter&lt;/kbd&gt; (All three).&lt;/li&gt;&#xA;&lt;li&gt;Replace &lt;code&gt;&amp;lt;key&amp;gt;&lt;/code&gt; with whaveter key sequence you want.&lt;/li&gt;&#xA;&lt;li&gt;Place your cursor anywhere on the first line of the array and press &lt;code&gt;&amp;lt;key&amp;gt;&lt;/code&gt; to toggle the formatting&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h search()&lt;/code&gt; and &lt;code&gt;:h normal&lt;/code&gt; for more info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps. &lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-09-15T21:06:36.597" LastActivityDate="2016-09-15T21:06:36.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9563" PostTypeId="2" ParentId="9558" CreationDate="2016-09-15T21:05:52.000" Score="2" Body="&lt;p&gt;@P1h3r1e3d13 Please try the following configuration&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;For .vim.plug:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; =============================================================================&#xA;&quot; Plugin Manager Setup&#xA;&quot; =============================================================================&#xA;&quot;&#xA;filetype off&#xA;&#xA;&quot; Install the plugin manager if it doesn't exist&#xA;let s:plugin_manager=expand('~/.vim/autoload/plug.vim')&#xA;let s:plugin_url='https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'&#xA;&#xA;if empty(glob(s:plugin_manager))&#xA;  echom 'vim-plug not found. Installing...'&#xA;  if executable('curl')&#xA;    silent exec '!curl -fLo ' . s:plugin_manager . ' --create-dirs ' .&#xA;          \ s:plugin_url&#xA;  elseif executable('wget')&#xA;    call mkdir(fnamemodify(s:plugin_manager, ':h'), 'p')&#xA;    silent exec '!wget --force-directories --no-check-certificate -O ' .&#xA;          \ expand(s:plugin_manager) . ' ' . s:plugin_url&#xA;  else&#xA;    echom 'Could not download plugin manager. No plugins were installed.'&#xA;    finish&#xA;  endif&#xA;  augroup vimplug&#xA;    autocmd!&#xA;    autocmd VimEnter * PlugInstall&#xA;  augroup END&#xA;endif&#xA;&#xA;&quot; Create a horizontal split at the bottom when installing plugins&#xA;let g:plug_window = 'botright new'&#xA;&#xA;let g:plug_dir = expand('~/.vim/bundle')&#xA;call plug#begin(g:plug_dir)&#xA;&#xA;&quot; Defaults everyone can agree on&#xA;Plug 'tpope/vim-sensible'&#xA;&#xA;&quot; quoting/parenthesizing made simple&#xA;Plug 'tpope/vim-surround'&#xA;&#xA;&quot; syntax highlighting&#xA;Plug 'tomvanderlee/vim-kerboscript', { 'for': 'kerboscript' }&#xA;&#xA;&quot;&quot;&quot; All of your Plugins must be added before the following line&#xA;&quot; Add plugins to &amp;amp;runtimepath&#xA;call plug#end()   &quot;required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then try the following for your&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;.vimrc:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; load vim-plug&#xA;source ~/.vim/.plug.vim&#xA;&#xA;syntax on&#xA;filetype plugin indent on&#xA;set relativenumber&#xA;set number&#xA;&#xA;&quot; searching&#xA;set incsearch&#xA;set hlsearch&#xA;set ignorecase&#xA;set smartcase&#xA;&#xA;&quot; backspace over everything&#xA;set backspace=indent,eol,start&#xA;&#xA;&quot; number of spaces inserted by tab&#xA;set shiftwidth=4&#xA;&#xA;&quot; status line&#xA;hi User1 ctermbg=gray  ctermfg=black&#xA;hi User2 ctermbg=gray  ctermfg=red cterm=bold&#xA;&#xA;set laststatus=2&#xA;set statusline=     &quot;reset statusline&#xA;set statusline+=%1* &quot;black on gray&#xA;set statusline+=%F      &quot;full filename&#xA;&quot; set statusline+=[%{strlen(&amp;amp;fenc)?&amp;amp;fenc:'none'}, &quot;file encoding&#xA;&quot; set statusline+=%{&amp;amp;ff}] &quot;file format&#xA;set statusline+=\ %y    &quot;filetype&#xA;set statusline+=\ %h    &quot;help file flag&#xA;set statusline+=\ %2*   &quot;white on red&#xA;set statusline+=%m      &quot;modified flag&#xA;set statusline+=%1* &quot;black on gray&#xA;set statusline+=\ %r    &quot;read only flag&#xA;set statusline+=%=      &quot;left/right separator&#xA;set statusline+=%c,     &quot;cursor column&#xA;set statusline+=%l/%L   &quot;cursor line/total lines&#xA;set statusline+=\ \ %P  &quot;percent through file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1691" LastEditorUserId="1691" LastEditDate="2016-09-15T21:12:54.787" LastActivityDate="2016-09-15T21:12:54.787" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9564" PostTypeId="1" CreationDate="2016-09-16T01:41:05.550" Score="1" ViewCount="65" Body="&lt;p&gt;How can I send all writable buffers to an external command? For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:wa ! wc -l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does not work (gives trailing characters error). (Also, wa will not work anyway because it does not write unchanged buffers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It needs to be writable buffers because I may have buffers like help open that are not writable that I do not want to include.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, bufdo does not work, both because it includes read only buffers and because it executes the commands separately and therefore hangs the interface.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="6952" LastEditDate="2016-09-16T03:08:32.673" LastActivityDate="2016-09-16T10:45:56.167" Title="Send all writable buffers to external command?" Tags="|external-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9566" PostTypeId="1" CreationDate="2016-09-16T08:24:01.123" Score="4" ViewCount="1976" Body="&lt;p&gt;If I execute a interactive command with &lt;code&gt;:terminal&lt;/code&gt;, buffername will be something like: &lt;code&gt;term://.//1234:command executed here with params&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to change it to something more meaningful to use with my fork for vim-vroom. Here is the snippet for reference: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:RunNeoTerminal(cmd)&#xA;  &quot; close previous openned buffer&#xA;  if exists('t:vroom_terminal_bufnr') &amp;amp;&amp;amp; bufexists(t:vroom_terminal_bufnr)&#xA;    exec &quot;:bd! &quot;.t:vroom_terminal_bufnr&#xA;  end&#xA;&#xA;  let height = winheight(0) * 1/4&#xA;  exec &quot;:belowright &quot; . height . &quot;split&quot;&#xA;&#xA;  exec &quot;:terminal &quot; . a:cmd&#xA;  &quot; terminal runs by default in insert mode which kills the buffer after exit,&#xA;  &quot; let's change to normal mode&#xA;  exec &quot;:stopinsert&quot;&#xA;  let t:vroom_terminal_bufnr = bufnr('%')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/brodock/vim-vroom/blob/neovim-terminal/autoload/vroom.vim#L253-L267&quot; rel=&quot;nofollow&quot;&gt;https://github.com/brodock/vim-vroom/blob/neovim-terminal/autoload/vroom.vim#L253-L267&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9288" LastActivityDate="2016-09-16T15:26:31.717" Title="How to change buffer name for NeoVim Terminal special buffer" Tags="|neovim|terminal|terminal-buffer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9567" PostTypeId="2" ParentId="9564" CreationDate="2016-09-16T10:45:56.167" Score="2" Body="&lt;p&gt;This is not easily doable. You need to script a little bit. Something like this should do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! CollectContent()&#xA;  let l=[]&#xA;  for i in range(1,bufnr('$'))&#xA;    if bufexists(i) &amp;amp;&amp;amp; getbufvar(i, '&amp;amp;modifiable')&#xA;        let l += getbufline(i, 1, '$')&#xA;    endif&#xA;  endfor&#xA;  return l&#xA;endfu&#xA;&#xA;func! GetOutput()&#xA;  let cnt=CollectContent()&#xA;  let cmd='wc -l'&#xA;  let out=system(cmd, join(cnt, &quot;\n&quot;).&quot;\n&quot;)&#xA;  echo out&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Error management left as excercise to the reader.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-09-16T10:45:56.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9569" PostTypeId="2" ParentId="9566" CreationDate="2016-09-16T15:26:31.717" Score="7" Body="&lt;p&gt;You can change the name of &lt;strong&gt;any&lt;/strong&gt; buffer by using the &lt;a href=&quot;https://vimhelp.appspot.com/editing.txt.html#%3Afile_f&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:file {name}&lt;/code&gt;&lt;/a&gt; command.  However, doing so changes that alternate-file to the previous name, which you may not want in this case.  The &lt;a href=&quot;https://vimhelp.appspot.com/editing.txt.html#%3Akeepalt&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:keepalt&lt;/code&gt;&lt;/a&gt; command avoids that issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together, this should do what you want&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;keepalt file meaningful&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2016-09-16T15:26:31.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9570" PostTypeId="1" AcceptedAnswerId="9571" CreationDate="2016-09-16T17:10:21.470" Score="13" ViewCount="4878" Body="&lt;p&gt;I really don't care about any of the &quot;value&quot; that viminfo or its replacement in neovim, ShaDa, provide. I couldn't care less about whether or not my cursor is in the exact place I left it when I open a file or whether my registers are restored, but I am very tired of seeing seemingly random ShaDa-related errors. Is there a way that I can just turn off shared data? &lt;code&gt;:help shada&lt;/code&gt; has not been very helpful in this endeavor. &lt;/p&gt;&#xA;" OwnerUserId="6883" LastActivityDate="2023-08-31T17:12:02.833" Title="How do I ShaDon't?" Tags="|neovim|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9571" PostTypeId="2" ParentId="9570" CreationDate="2016-09-16T17:28:12.907" Score="16" Body="&lt;p&gt;&lt;code&gt;set shada=&quot;NONE&quot;&lt;/code&gt; will prevent shada files from being generated or read in Neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For vim, &lt;code&gt;set viminfo=&quot;NONE&quot;&lt;/code&gt; will disable viminfo files.&lt;/p&gt;&#xA;" OwnerUserId="9297" LastActivityDate="2016-09-16T17:28:12.907" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9572" PostTypeId="2" ParentId="9570" CreationDate="2016-09-16T17:39:53.160" Score="6" Body="&lt;p&gt;According to &lt;a href=&quot;https://neovim.io/doc/user/starting.html#-i&quot; rel=&quot;noreferrer&quot;&gt;the neovim docs&lt;/a&gt;, if you invoke neovim with &lt;code&gt;-i NONE&lt;/code&gt;, it will ignore the ShaDa file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Insert the following into your bashrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias nvim='nvim -i NONE'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6883" LastEditorUserId="6883" LastEditDate="2016-09-17T18:21:40.560" LastActivityDate="2016-09-17T18:21:40.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9573" PostTypeId="1" AcceptedAnswerId="9575" CreationDate="2016-09-16T21:19:48.223" Score="7" ViewCount="4012" Body="&lt;p&gt;I'm had some trouble defining a mapping in my .vimrc. I want &lt;code&gt;&amp;lt;leader&amp;gt;sv&lt;/code&gt; to source my .vimrc, but first I want to write, if I'm currently editing it.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Goal&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The intention of the code is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if expand('%:p') ==? expand($MYVIMRC)&#xA;    write&#xA;endif&#xA;source $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Attempt 1&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I tried writing my commands inline with pipes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;sv :if expand('%:p') ==? expand($MYVIMRC) | write | endif | source $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get this error when I load it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /Users/jack/.vimrc:&#xA;E580: :endif without :if:  endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Attempt 2&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I also tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:source_vimrc='if expand('%:p') ==? expand($MYVIMRC) | write | endif | source $MYVIMRC'&#xA;nnoremap &amp;lt;leader&amp;gt;sv :exec(s:source_vimrc)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which got me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E15: Invalid expression: 'if expand('%:p') ==? expand($MYVIMRC) | write | endif | source $MYVIMRC'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Attempt 3 (working)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The only way I can get it to work is using &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to simulate typing the whole thing out across multiple lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;sv :if expand('%:p') ==? expand($MYVIMRC) &amp;lt;cr&amp;gt; :write &amp;lt;cr&amp;gt; :endif &amp;lt;cr&amp;gt; :source $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Attempt 4 (sort of?)&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;sv :if expand('%:p') ==? expand($MYVIMRC) &amp;lt;bar&amp;gt; write &amp;lt;bar&amp;gt; endif &amp;lt;bar&amp;gt; source $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That does it, but leaves me with &lt;code&gt;Press Enter or type command to continue&lt;/code&gt; instead of returning to normal mode.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Questions&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;del&gt;Do mappings not support pipes for multiple commands? Or do &lt;code&gt;if&lt;/code&gt;s not? Why didn't the first one work like I expected?&lt;/del&gt;&lt;br&gt;&#xA;A: Because the pipes are interpreted as new commands in the file. Use &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; to get them written to the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why doesn't #4 return me to normal mode? When I type in the command (with &lt;code&gt;|&lt;/code&gt;s), it does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I'm open to suggestions for better ways to accomplish this, too.&lt;/p&gt;&#xA;" OwnerUserId="9267" LastEditorUserId="9267" LastEditDate="2016-09-16T22:18:26.713" LastActivityDate="2016-09-17T06:17:11.897" Title="How to format a mapping to an if statement?" Tags="|key-bindings|vimscript|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9574" PostTypeId="2" ParentId="9573" CreationDate="2016-09-16T21:31:10.973" Score="0" Body="&lt;p&gt;You can use pipes for mappings, but I would recomend just wrapping it all in a function. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;sv :call SourceVimrc()&amp;lt;CR&amp;gt;&#xA;&#xA;function! SourceVimrc()&#xA;    if fnamemodify('%', ':p') ==? expand($MYVIMRC)&#xA;        write&#xA;    endif&#xA;    source $MYVIMRC&amp;lt;cr&amp;gt;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-09-16T22:20:29.990" LastActivityDate="2016-09-16T22:20:29.990" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="9575" PostTypeId="2" ParentId="9573" CreationDate="2016-09-17T01:10:05.760" Score="6" Body="&lt;p&gt;This is where &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mappings are useful. From &lt;code&gt;:h &amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *:map-&amp;lt;expr&amp;gt;* *:map-expression*&#xA;If the first argument to one of these commands is &quot;&amp;lt;expr&amp;gt;&quot; and it is used to&#xA;define a new mapping or abbreviation, the argument is an expression.  The&#xA;expression is evaluated to obtain the {rhs} that is used.  Example: &amp;gt;&#xA;    :inoremap &amp;lt;expr&amp;gt; . InsertDot()&#xA;The result of the InsertDot() function will be inserted.  It could check the&#xA;text before the cursor and start omni completion when some condition is met.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can just use &lt;code&gt;expand('%:p') ==? expand($MYVIMRC)&lt;/code&gt; in a ternary expression to find out if you want to write or not, and the concatenate that with &lt;code&gt;source ($MYVIMRC)&lt;/code&gt;. Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;sv (expand('%:p') ==? expand($MYVIMRC) ? &quot;:w \|&quot; : &quot;:&quot;).&quot;source $MYVIMRC&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you run this in your &lt;code&gt;.vimrc&lt;/code&gt;, it will evaluate to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w | source $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Otherwise, it will evaluate to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:source $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is assuming you want to source your vimrc either way (which I assume you do from the mappings you have shown). If not, you could just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;sv expand('%:p') ==? expand($MYVIMRC) ? &quot;:w \| source $MYVIMRC&amp;lt;cr&amp;gt;&quot; : &quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-09-17T01:10:05.760" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9576" PostTypeId="2" ParentId="9573" CreationDate="2016-09-17T04:52:42.183" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/9575/9267&quot;&gt;DJMcMayhem's answer&lt;/a&gt; is better than what I was trying to do, but for posterity's sake, here is the information I was asking for. Short answers:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; or &lt;code&gt;\|&lt;/code&gt; in lieu of &lt;code&gt;|&lt;/code&gt; in a map.&lt;/li&gt;&#xA;&lt;li&gt;Don't print overlong lines to the command line.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Mistake 1: hitting the bars&lt;/h3&gt;&#xA;&lt;p&gt;Pipes/bars (&lt;code&gt;|&lt;/code&gt;) separate multiple commands on one line on the command line, but they also separate multiple commands on one line in a script file. So my original attempt:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;sv :if expand('%:p') ==? expand($MYVIMRC) | write | endif | source $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;is parsed as these four separate commands:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;sv :if expand('%:p') ==? expand($MYVIMRC)&#xA;:write&#xA;:endif&#xA;:source $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The first two are valid, but not what I want. The third, &lt;code&gt;endif&lt;/code&gt;, is not valid without its &lt;code&gt;if&lt;/code&gt; buddy, and the fourth is a legal command, but points to a nonexistent file. Trying to parse those commands is what generates the errors I quoted.&lt;/p&gt;&#xA;&lt;p&gt;Swapping the &lt;code&gt;|&lt;/code&gt;s for &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;s works around this problem by making the map print out each line as if I'd entered them separately:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:if expand('%:p') ==? expand($MYVIMRC)&#xA;:  write&#xA;:endif&#xA;:source $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The direct solution is to use &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; or &lt;code&gt;\|&lt;/code&gt; in place of &lt;code&gt;|&lt;/code&gt; in the map. That causes it to print a &lt;code&gt;|&lt;/code&gt; at runtime, giving the expected behavior.&lt;/p&gt;&#xA;&lt;p&gt;Credit to &lt;a href=&quot;https://vi.stackexchange.com/questions/9573/how-to-format-a-mapping-to-an-if-statement/9574?noredirect=1#comment16702_9574&quot;&gt;@SatoKatsura&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Mistake 2: sesquipedalianism&lt;/h3&gt;&#xA;&lt;p&gt;With &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; in place of &lt;code&gt;|&lt;/code&gt; it's like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;sv :if expand('%:p') ==? expand($MYVIMRC) &amp;lt;bar&amp;gt; write &amp;lt;bar&amp;gt; endif &amp;lt;bar&amp;gt; source $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which works fine. However, it prints 71 characters to the command line, and I had my vim window squeezed to half width when I was testing. It turns out that entering a command longer than one line leaves the CLI on a &lt;code&gt;Press Enter or type command to continue&lt;/code&gt; prompt.&lt;/p&gt;&#xA;&lt;p&gt;There are a few ways to avoid this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use the &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; argument to suppress all output. However, I wouldn't see any errors &lt;del&gt;if&lt;/del&gt; when I mess up my .vimrc.&lt;/li&gt;&#xA;&lt;li&gt;Make the window wider.&lt;/li&gt;&#xA;&lt;li&gt;Increase the value of &lt;code&gt;cmdheight&lt;/code&gt; to handle the extra lines.&lt;/li&gt;&#xA;&lt;li&gt;Shorten the string. There are some spaces that could be removed.&lt;/li&gt;&#xA;&lt;li&gt;Separate commands with &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to print multiple shorter lines.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/9575/9267&quot;&gt;As DJMcMayhem showed&lt;/a&gt;, leave the logic to the script and print only the necessary commands, which are quite short.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Credit to &lt;a href=&quot;https://vi.stackexchange.com/questions/9573/how-to-format-a-mapping-to-an-if-statement/9574?noredirect=1#comment16707_9573&quot;&gt;@VanLaser&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9267" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-09-17T06:17:11.897" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9579" PostTypeId="1" AcceptedAnswerId="9580" CreationDate="2016-09-17T10:58:22.493" Score="4" ViewCount="1586" Body="&lt;p&gt;Let's say I have the following line in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap ge w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sometimes I want to unmap it locally to the current buffer, so I run:&#xA;&lt;code&gt;:unmap &amp;lt;buffer&amp;gt; ge&lt;/code&gt;. When I do this, I get an error message that the mapping doesn't exist. I understand that the mapping doesn't exist specifically for the current buffer only but it exist in all the buffers I will ever open in this session, I can see the mapping is active when I run &lt;code&gt;:verb map ge&lt;/code&gt; but not when I run &lt;code&gt;:verb map &amp;lt;buffer&amp;gt; ge&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like running &lt;code&gt;unmap &amp;lt;buffer&amp;gt;&lt;/code&gt; can only undo commands containing &lt;code&gt;map &amp;lt;buffer&amp;gt;&lt;/code&gt;. I don't want to &lt;code&gt;noremap ge &amp;lt;nop&amp;gt;&lt;/code&gt; because that will delete the original key-sequence's command. Is it possible to unmap a mapping from &lt;code&gt;.vimrc&lt;/code&gt; only in the current &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6411" LastActivityDate="2016-09-17T12:23:12.713" Title="Unmap locally a mapping from .vimrc" Tags="|key-bindings|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9580" PostTypeId="2" ParentId="9579" CreationDate="2016-09-17T12:23:12.713" Score="4" Body="&lt;p&gt;You can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;buffer&amp;gt; ge ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To map the command back to original for this buffer.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-09-17T12:23:12.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9581" PostTypeId="1" CreationDate="2016-09-17T14:43:06.960" Score="11" ViewCount="444" Body="&lt;p&gt;Vi very successfully minimises finger travel and speed with command mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Swapping &lt;kbd&gt;;&lt;/kbd&gt; and &lt;kbd&gt;:&lt;/kbd&gt; seems to save a lot of extra shift keystrokes for commands which are used more freqently than repititions of letter searches, but there are disadvantages to using a non standard key layout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the advantages of &lt;kbd&gt;:&lt;/kbd&gt; for commands? Compared to the effiency and elegance of Vi overall I feel like there must be some logic I'm missing.&lt;/p&gt;&#xA;" OwnerUserId="9308" LastEditorUserId="9308" LastEditDate="2016-09-18T16:15:19.763" LastActivityDate="2016-09-18T16:15:19.763" Title="What are the advantages of using colon for commands instead of semicolon?" Tags="|key-bindings|history-of|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9582" PostTypeId="2" ParentId="9581" CreationDate="2016-09-17T15:06:45.200" Score="11" Body="&lt;p&gt;You know the &lt;a href=&quot;http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/&quot;&gt;story&lt;/a&gt; behind the &lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt; keys in Vi?  Well, &lt;kbd&gt;:&lt;/kbd&gt; was &lt;a href=&quot;https://en.wikipedia.org/wiki/ADM-3A#/media/File:KB_Terminal_ADM3A.svg&quot;&gt;unshifted&lt;/a&gt; on &lt;a href=&quot;https://en.wikipedia.org/wiki/Bill_Joy&quot;&gt;Vi author&lt;/a&gt;'s &lt;a href=&quot;https://en.wikipedia.org/wiki/ADM-3A&quot;&gt;ADM-3A&lt;/a&gt; terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No idea if that's the real explanation in this particular case, but it seems at least as plausible as the &lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt; story.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-09-17T15:06:45.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9584" PostTypeId="1" AcceptedAnswerId="9592" CreationDate="2016-09-17T22:08:18.063" Score="1" ViewCount="247" Body="&lt;p&gt;I have put the following in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Up&amp;gt; &amp;lt;C-c&amp;gt;gka    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But sometime, instead of moving my cursor, &lt;code&gt;gka&lt;/code&gt; is inserted as text as I am in insert mode. It seems the &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; did not work as expected. This behavior appears also with mappings that use &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if could be related to this config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set timeoutlen=1000&#xA;set ttimeoutlen=0&#xA;set timeout&#xA;set nottimeout&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am running on Cygwin mintty&lt;/p&gt;&#xA;" OwnerUserId="2548" LastEditorUserId="2548" LastEditDate="2016-09-18T18:50:13.153" LastActivityDate="2016-09-19T13:20:49.993" Title="inoremap &lt;Up&gt; &lt;C-c&gt;gka sometime does not work" Tags="|key-bindings|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="9585" PostTypeId="1" AcceptedAnswerId="9586" CreationDate="2016-09-18T20:42:39.477" Score="0" ViewCount="834" Body="&lt;p&gt;I have lines like the following ones (actually function prototypes)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void ()&#xA;word ( word, another word, one_more word, ..., hello, ... )&#xA;one argument ( only )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to match each single argument and enclose it between &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before wasting time with the replacement string, I'm trying to devise the proper search pattern. The following command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(( \|, \)\(.\{-}\)\( )\|,\)/\1&amp;lt;\2&amp;gt;\3/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;only matches and replace odd-position arguments.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastActivityDate="2016-09-18T22:09:06.443" Title="Substitute words enclosed between comma or open-parenthesis and comma or closed parenthesis" Tags="|regular-expression|substitute|delimiter-matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9586" PostTypeId="2" ParentId="9585" CreationDate="2016-09-18T21:38:23.523" Score="3" Body="&lt;p&gt;It's because your matching groups have overlap! Exept for zero-width pattern items, every charachter in your string will be consumed in the matching. so here you can use &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; to confine your match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\%(( \|, \)\zs\(.\{-}\)\ze\%( )\|,\)/&amp;lt;\1&amp;gt;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here i also changed the first and third &lt;em&gt;captuting&lt;/em&gt; groups to &lt;em&gt;non-capturing&lt;/em&gt; as we don't need to capture them.&#xA;for a complete list of &lt;strong&gt;zero-width&lt;/strong&gt; pattern items, see: &lt;code&gt;:h pattern-overview&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7976" LastEditorUserId="7976" LastEditDate="2016-09-18T22:09:06.443" LastActivityDate="2016-09-18T22:09:06.443" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9587" PostTypeId="2" ParentId="6142" CreationDate="2016-09-19T03:00:43.963" Score="0" Body="&lt;p&gt;I get these with &lt;code&gt;CMakeList.txt&lt;/code&gt; files. It is part of the syntax highlight mechanism. I also get it in &quot;long&quot; (a few pages really) HTML where I have &lt;code&gt;JavaScript&lt;/code&gt; code. For these, I use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn sync fromstart&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in most cases it resolves the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the command will make vim very slow if you edit a really large file. In most cases, for me the &quot;slowness&quot; is more than bearable.&lt;/p&gt;&#xA;" OwnerUserId="9276" LastActivityDate="2016-09-19T03:00:43.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9589" PostTypeId="1" AcceptedAnswerId="9590" CreationDate="2016-09-19T06:36:36.617" Score="3" ViewCount="1029" Body="&lt;p&gt;One can open a file at tag with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -t &amp;lt;TAG&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if there are two tags with the same name, e.g. two variables of the same name in two different files, then the first one is opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to order vim to open second one?&lt;/p&gt;&#xA;" OwnerUserId="9330" LastEditorUserId="1841" LastEditDate="2016-09-19T07:45:44.320" LastActivityDate="2016-09-19T08:37:39.263" Title="How to select the tag to open when several tags have the same name?" Tags="|tags|ctags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9590" PostTypeId="2" ParentId="9589" CreationDate="2016-09-19T07:55:01.700" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;:tnext&lt;/code&gt; to jump to the next matching tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have four tags &lt;code&gt;foo&lt;/code&gt;, these commands will let you jump to each tag sequentially:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -t foo&#xA;:tn&#xA;:tn&#xA;:tn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:tp[revious]&lt;/code&gt; to jump to the previous tag, &lt;code&gt;:tl[ast]&lt;/code&gt; to jump to the last one, &lt;code&gt;:tf[irst]&lt;/code&gt; to jump to the first one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you can use &lt;code&gt;:ts[elect]&lt;/code&gt; to list all matching tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;:ts&lt;/code&gt; directly from your shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -c ':ts foo'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or &lt;code&gt;:[count]tag&lt;/code&gt; if you already know which one you want. Assuming you want the fourth tag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -c ':4tag foo'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help tag&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-09-19T08:37:39.263" LastActivityDate="2016-09-19T08:37:39.263" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9591" PostTypeId="1" AcceptedAnswerId="9593" CreationDate="2016-09-19T13:02:33.507" Score="7" ViewCount="1680" Body="&lt;p&gt;Let's say I've set a mark &lt;strong&gt;a&lt;/strong&gt; via &lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;. Then &lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; will bring me to the first non whitespace character of the line. However &lt;kbd&gt;`&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;  will bring me to the exact position of the mark &lt;strong&gt;a&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer the second behaviour and would like to create a map. So I always get the behaviour of the backtick command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First attempt:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map 'a `a&#xA;:map 'b `b&#xA;... etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems really bad to do this for every possible mark. How would I go about this?&lt;/p&gt;&#xA;" OwnerDisplayName="user9334" LastEditorDisplayName="user9334" LastEditDate="2016-09-19T19:58:02.160" LastActivityDate="2016-09-19T19:58:02.160" Title="Map 'Jump to mark line' to 'Jump to mark position'" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9592" PostTypeId="2" ParentId="9584" CreationDate="2016-09-19T13:14:01.013" Score="4" Body="&lt;p&gt;The following mapping works fine here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;up&amp;gt; &amp;lt;c-o&amp;gt;gk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-O&quot; rel=&quot;nofollow noreferrer&quot;&gt;using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;O&lt;/kbd&gt;&lt;/a&gt; you don't need the &lt;code&gt;a&lt;/code&gt; at the end of your mapping to get back to insert mode. And you should generally &lt;a href=&quot;https://stackoverflow.com/questions/80677/what-is-the-difference-between-c-c-and-c-in-vim&quot;&gt;avoid using using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; to exit insert mode&lt;/a&gt;, as it can break some functionality and plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try the following to debug your problem:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;1) Check if the problem happens in vanilla vim&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Start Vim with &lt;code&gt;vim -u NONE -U NONE -N -i NONE&lt;/code&gt;. If the problem doesn't happens, it means you have a problem related to some setting/plugin. In this case you could follow the steps at &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-2.5&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim-FAQ  2.5 - &lt;em&gt;I have a &quot;xyz&quot; (some) problem with Vim. How do I determine it is a problem with my setup or with Vim?  / Have I found a bug in Vim?&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;2) Try to map another key instead of the arrow keys&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Still with vanilla Vim, try mapping to a regular key:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap a &amp;lt;c-o&amp;gt;gk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the problem doesn't happens, check the instructions at &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-10.9&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim-FAQ  10.9 - &lt;em&gt;When I use my arrow keys, Vim changes modes, inserts weird characters      in my document but doesn't move the cursor properly. What's going on?&lt;/em&gt;&lt;/a&gt;, which references some relevant options such as &lt;code&gt;'ttimeoutlen'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;3) Try other terminals/gVim&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If nothing else solves the problem, the problem is probably related to your terminal. You could try using another terminal or, even better, gVim (Graphical Vim), which is available on Windows and thus would allow you to avoid Cygwin and any problem related to shell limitations.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-09-19T13:20:49.993" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9593" PostTypeId="2" ParentId="9591" CreationDate="2016-09-19T13:19:54.710" Score="9" Body="&lt;pre&gt;&lt;code&gt;'a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is a sentence: &quot;jump to &lt;em&gt;the line where mark &lt;code&gt;a&lt;/code&gt; is&lt;/em&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is also a sentence: &quot;jump to &lt;em&gt;where mark &lt;code&gt;a&lt;/code&gt; is&lt;/em&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you want &lt;em&gt;&quot;the line where a given mark is&quot;&lt;/em&gt; to mean &lt;em&gt;&quot;where the given mark is&quot;&lt;/em&gt;, mapping all the possible sentences would certainly be wasteful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you only need to swap those two elements:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ' `&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which reads: &lt;em&gt;&quot;the line where a given mark is&lt;/em&gt; now means &lt;em&gt;where the given mark is&quot;.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-09-19T13:19:54.710" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9594" PostTypeId="1" CreationDate="2016-09-19T13:27:38.290" Score="1" ViewCount="143" Body="&lt;p&gt;I primarily use Vim for text processing, so in order to lighten that process, I've set some parameters in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fo=ant&#xA;set tw=80&#xA;set ts=3&#xA;set nojoinspaces&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;nojoinspaces&lt;/code&gt; parameter is set in order for various movement operations to be sensitive to sentences without having to append two spaces after a period (which is not a common practice in my language).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm mostly happy with this setup, but it bothers me that I have to insert a blank line between any two paragraphs in order for Vim not to collapse them. This is especially bothersome when I'm writing a list. I found that setting &lt;code&gt;formatoptions&lt;/code&gt; to &lt;code&gt;antw&lt;/code&gt; eliminates this problem, while retaining most of the features I need for 'normal' paragraphs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, so good! But the problem is that whenever I have a line that is EXACTLY 80 characters long, Vim automatically inserts a blank line, i.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A major part of the scientific literature on consciousness consists of studies&#xA;that examine the relationship between the experiences reported by subjects and&#xA;the activity that simultaneously takes place in their brains—that is, studies of&#xA;&#xA;the neural correlates of consciousness.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would think this wouldn't happen all that often, but I find it to be a pretty big pain in the backside. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I guess my question is: &lt;strong&gt;Is there any set of &lt;code&gt;formatoptions&lt;/code&gt; parameters that would suit my requirements: automatic formatting of NORMAL paragraphs but no need for blank lines between items in, say, a list?&lt;/strong&gt; Or will I have to keep toggling between them? And why does &lt;code&gt;antw&lt;/code&gt; make Vim behave this way in the first place?&lt;/p&gt;&#xA;" OwnerUserId="5772" LastEditorUserId="1841" LastEditDate="2016-09-19T14:35:21.470" LastActivityDate="2016-09-19T19:13:02.607" Title="How to set formatoption so that a blank line isn't needed between two paragraphs?" Tags="|formatting|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9595" PostTypeId="1" CreationDate="2016-09-19T17:55:48.307" Score="0" ViewCount="2682" Body="&lt;p&gt;In addition to what was asked above, is there also a way for (neo)vim background colour to change when the terminal background colour is changed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's running in OSX in the default terminal app.&lt;/p&gt;&#xA;" OwnerUserId="3022" LastEditorUserId="3022" LastEditDate="2016-09-20T02:58:07.153" LastActivityDate="2017-03-19T16:55:57.267" Title="Make neovim background the same colour as the terminal background" Tags="|neovim|terminal|colorscheme|macos|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9596" PostTypeId="2" ParentId="9594" CreationDate="2016-09-19T19:13:02.607" Score="1" Body="&lt;p&gt;@VanLaser: Thanks, :set tw=79 did the trick!&lt;/p&gt;&#xA;" OwnerUserId="5772" LastActivityDate="2016-09-19T19:13:02.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9597" PostTypeId="1" AcceptedAnswerId="9603" CreationDate="2016-09-19T20:11:21.137" Score="2" ViewCount="370" Body="&lt;p&gt;I'm trying to add a plugin that will provide additional tags files to look up the documentation of a language: &lt;a href=&quot;https://github.com/DanielSiepmann/phpstorm-stubs/blob/feature/add-dynamic-tags-file/plugin/php.vim&quot; rel=&quot;nofollow&quot;&gt;https://github.com/DanielSiepmann/phpstorm-stubs/blob/feature/add-dynamic-tags-file/plugin/php.vim&lt;/a&gt;&#xA;But none of my tries worked out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;l:tags += expand('%:p:h:h') . &quot;/tags&quot;&#xA;let &amp;amp;tags = expand('%:p:h:h') . &quot;/tags&quot;&#xA;set tags += expand('%:p:h:h') . &quot;/tags&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first solution returns the following error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Error detected while processing&#xA;  /Users/siepmann/.dotfiles/.vim/bundle/phpstorm-stubs/plugin/php.vim:&#xA;  line    1: E734: Wrong variable type for += Press ENTER or type&#xA;  command to continue&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The second one will prevent all other defaults that would be set in addition. So &lt;code&gt;tags=./tags,tags&lt;/code&gt; will become &lt;code&gt;tags=~/Projects/typo3/tags&lt;/code&gt; where &lt;code&gt;~/Projects/typo3/&lt;/code&gt; is current working dir.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is that the plugin should ship with the tags file and as the plugin can be installed into multiple locations the include should be dynamic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what will be a working solution / approach?&lt;/p&gt;&#xA;" OwnerUserId="5749" LastActivityDate="2016-09-20T06:29:33.623" Title="How to add a tags file with expand" Tags="|tags|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9598" PostTypeId="1" AcceptedAnswerId="9601" CreationDate="2016-09-19T20:17:27.860" Score="1" ViewCount="757" Body="&lt;p&gt;I installed &lt;a href=&quot;https://github.com/amix/vimrc&quot; rel=&quot;nofollow&quot;&gt;this vimrc&lt;/a&gt; configuration (including plugins), and saw that vim-surround was included. With that, the surround-readme tells me I can use things like &lt;code&gt;ds&quot;&lt;/code&gt; to delete surrounding quotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;s&lt;/code&gt; triggers a substitute of the character under the cursor + placing me in insert mode (&lt;code&gt;:help s&lt;/code&gt; says &lt;code&gt;s&lt;/code&gt; is a synonym for &lt;code&gt;cl&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find this referenced in the config, so I'm wondering why I can't use surround? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry if this is very stupid, new to Vim...   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it matters, this is the output of &lt;code&gt;vim --version&lt;/code&gt; for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 12 2016 17:17:45)&#xA;MacOS X (unix) version&#xA;Included patches: 1-2&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     -tcl&#xA;-balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;-browse          -footer          +multi_byte      +terminfo&#xA;++builtin_terms  +fork()          +multi_lang      +termresponse&#xA;+byte_offset     -gettext         -mzscheme        +textobjects&#xA;+channel         -hangul_input    +netbeans_intg   +timers&#xA;+cindent         +iconv           +num64           +title&#xA;-clientserver    +insert_expand   +packages        -toolbar&#xA;+clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        +perl            +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       +python          +vreplace&#xA;+cscope          +lispindent      -python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con      -lua             +rightleft       +writebackup&#xA;+diff            +menu            +ruby            -X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;-dnd             +modify_fname    +signs           -xim&#xA;-ebcdic          +mouse           +smartindent     -xpm&#xA;+emacs_tags      -mouseshape      +startuptime     -xsmp&#xA;+eval            +mouse_dec       +statusline      -xterm_clipboard&#xA;+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save&#xA;+extra_search    -mouse_jsbterm   +syntax          &#xA;+farsi           +mouse_netterm   +tag_binary      &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework Cocoa   -mmacosx-version-min=10.11 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.24.0_1/lib/perl5/5.24.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/Cellar/python/2.7.12/Frameworks -framework Python   -lruby.2.3.0 -lobjc -L/usr/local/Cellar/ruby/2.3.1/lib    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9341" LastActivityDate="2016-09-20T02:22:23.463" Title="`s` doesn't trigger surrounding, but substitute (`cl`)" Tags="|vimrc|plugin-vim-surround|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9599" PostTypeId="1" AcceptedAnswerId="9641" CreationDate="2016-09-19T23:06:08.330" Score="4" ViewCount="658" Body="&lt;p&gt;I have a few custom LaTeX commands like this one, for instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\newcommand{\oeuvre}[1]{\textit{#1}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use this for titles of books and other works. Sometimes I want them to be italicized, sometimes I want them to be in quotes, so I just use this command and I can change it all at once when necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want Vim to highlight that command and its contents as it does with &lt;code&gt;\emph&lt;/code&gt; or &lt;code&gt;\textit&lt;/code&gt;, and I want to disable spelling inside it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(So in &lt;code&gt;\oeuvre{whatver}&lt;/code&gt; &quot;oeuvre&quot; should be highlighted the same way as &quot;emph&quot; or &quot;textit&quot;, and &quot;whatver&quot; should be in italics and it shouldn't count as a spelling mistake.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on Vim's default TeX highlighting file, I tried this in my &lt;code&gt;after/syntax/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match texTypeStyle      &quot;\\oeuvre\&amp;gt;&quot;&#xA;&#xA;syn region texOeuvreStyle   matchgroup=texTypeStyle start=&quot;\\oeuvre\s*{&quot; matchgroup=texTypeStyle  end=&quot;}&quot; concealends contains=@texItalGroup,@NoSpell&#xA;&#xA;hi texOeuvreStyle       gui=italic  cterm=italic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work. The command itself is highlighted properly, but not its contents, and spelling is still enabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I get that to work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I know there are similar questions here, but I couldn't adapt them to my needs, I find this syntax highlighting stuff really confusing, sorry.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: Ok, I figured out that if I use &lt;code&gt;syn region texItalStyle&lt;/code&gt; it'll work like I want it to… I'm still curious as to why I can't define my own &lt;code&gt;texOeuvreStyle&lt;/code&gt; in what seems to me is the same way it's done for &lt;code&gt;texItalStyle&lt;/code&gt; in the default syntax file though.&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="7642" LastEditDate="2016-09-23T02:45:40.213" LastActivityDate="2016-09-23T02:45:40.213" Title="Syntax highlighting for custom LaTeX commands" Tags="|syntax-highlighting|filetype-tex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9601" PostTypeId="2" ParentId="9598" CreationDate="2016-09-20T02:22:23.463" Score="5" Body="&lt;p&gt;Yes, &lt;code&gt;s&lt;/code&gt; &lt;em&gt;is&lt;/em&gt; a synonym for &lt;code&gt;cl&lt;/code&gt;. tpope/vim-surround does &lt;em&gt;not&lt;/em&gt; change this, it adds new operators. The full list of operators that vim-surround adds is&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;ds&amp;lt;foo&amp;gt;&lt;/code&gt; which the mnemonic is (D)elete (S)urrounding foo. For example, &lt;code&gt;ds&quot;&lt;/code&gt;, or &lt;code&gt;ds(&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;cs&amp;lt;foo&amp;gt;&amp;lt;bar&amp;gt;&lt;/code&gt; which the mnemonic is (C)hange (S)urrounding foo to bar. For example, to go from single to double quotes, use &lt;code&gt;cs&quot;'&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and lastly&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ys&amp;lt;motion&amp;gt;&amp;lt;foo&amp;gt;&lt;/code&gt; which doesn't have a great mnemonic. You can just think of it as &quot;surround&quot;. This one will surround the &lt;code&gt;&amp;lt;motion&amp;gt;&lt;/code&gt; with foo. For example, to surround 2 words with parenthesis, use &lt;code&gt;ys2w)&lt;/code&gt; (or use &lt;code&gt;(&lt;/code&gt;, both of them work, but subtly different)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As well as this, it provides the visual mode mapping &lt;code&gt;S&lt;/code&gt; which is just (S)urround the visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If pressing &lt;code&gt;ds&quot;&lt;/code&gt; doesn't work for you, you could be typing it too slowly. For example, &lt;code&gt;d&amp;lt;pause&amp;gt;s&amp;lt;pause&amp;gt;&quot;&lt;/code&gt; will be seen by vim as &lt;code&gt;d&amp;lt;timeout&amp;gt;&lt;/code&gt; which cancels the &lt;code&gt;d&lt;/code&gt; operator, followed by &lt;code&gt;s&quot;&lt;/code&gt; which deletes one character, puts you in insert mode and inserts a &lt;code&gt;&quot;&lt;/code&gt;. To fix this, you must type it faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to type it that quickly, or if you can't, you could also try adjusting &lt;code&gt;timeoutlen&lt;/code&gt; or &lt;code&gt;timeout&lt;/code&gt;. &lt;code&gt;timeoutlen&lt;/code&gt; changes how long vim waits before a command times out (in milliseconds). So you could set it to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set timeoutlen=2500&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for 2.5 seconds, or whatever you want. Or you could do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:se notimeout&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which makes it so no commands &lt;em&gt;ever&lt;/em&gt; time out, no matter how long you wait.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-09-20T02:22:23.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9602" PostTypeId="2" ParentId="9595" CreationDate="2016-09-20T03:42:41.977" Score="0" Body="&lt;p&gt;You can check &lt;a href=&quot;https://github.com/miyakogi/seiya.vim&quot; rel=&quot;nofollow&quot;&gt;Seiya&lt;/a&gt; plugin,  this one works for me. Check that for NeoVim &lt;a href=&quot;https://github.com/miyakogi/seiya.vim#change-highlight-groups-to-clear&quot; rel=&quot;nofollow&quot;&gt;one option is needed&lt;/a&gt; and in any case, install first and check with the command &lt;code&gt;SeiyaEnable&lt;/code&gt; first.&lt;/p&gt;&#xA;" OwnerUserId="8843" LastActivityDate="2016-09-20T03:42:41.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9603" PostTypeId="2" ParentId="9597" CreationDate="2016-09-20T06:29:33.623" Score="1" Body="&lt;p&gt;Thanks to @dNitro and @VanLaser the following is the working solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;ftplugin/php.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;l:tags == &quot;&quot;&#xA;    &quot; Gather information&#xA;    let s:additionalFile=expand('&amp;lt;sfile&amp;gt;:p:h:h').&quot;/tags&quot;&#xA;    let s:existingPath=&amp;amp;tags&#xA;    let s:newPath=s:existingPath.&quot;,&quot;.s:additionalFile&#xA;&#xA;    if s:existingPath[-1:] == &quot;&quot;&#xA;        let s:newPath=s:additionalFile&#xA;    endif&#xA;&#xA;    &quot; Set new path&#xA;    let &amp;amp;l:tags=s:newPath&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will first check if tags is set for current buffer. If not it will fetch the path relative to tags file in the current plugin.&#xA;Next it will concatenate the global &lt;code&gt;tags&lt;/code&gt; setting with the new file if global &lt;code&gt;tags&lt;/code&gt; contains something. This is due to the fact that &lt;code&gt;let &amp;amp;l:tags+=s:newPath&lt;/code&gt; will not work.&lt;/p&gt;&#xA;" OwnerUserId="5749" LastActivityDate="2016-09-20T06:29:33.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9604" PostTypeId="1" AcceptedAnswerId="9605" CreationDate="2016-09-20T06:36:17.813" Score="0" ViewCount="796" Body="&lt;p&gt;How can I make it so when in visual mode, pressing &lt;code&gt;b&lt;/code&gt; will toggle highlighted text to its bold unicode counterpart?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I mean by its Unicode counterpart:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://qaz.wtf/u/convert.cgi?text=Boat+Programming+should+be+a+valid+SE+Tag&quot; rel=&quot;nofollow&quot;&gt;http://qaz.wtf/u/convert.cgi?text=Boat+Programming+should+be+a+valid+SE+Tag&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Formatting done with markup&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SE bold&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;SE Italic&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Formatting done with unicode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt; &lt;/p&gt;&#xA;" OwnerUserId="7960" LastEditorUserId="7960" LastEditDate="2016-09-20T07:18:57.923" LastActivityDate="2016-09-20T10:54:56.567" Title="Use visual mode to convert text to unicode bold formats?" Tags="|visual-mode|formatting|unicode|font|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9605" PostTypeId="2" ParentId="9604" CreationDate="2016-09-20T08:50:02.620" Score="1" Body="&lt;p&gt;Create a mapping like this so that you can press a key and it will call the function which converts the text for you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      :vmap b :call MakeMeBold()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's create a function now.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     :function MakeMeBold()&#xA;     :normal! gv&quot;by&#xA;     :let @b=substitute (@b,&quot;a&quot;,&quot;A&quot;,&quot;g&quot;)&#xA;   . :normal! gv&quot;bp&#xA;     :endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above code with the substitute function substitutes all &lt;code&gt;a&lt;/code&gt; to &lt;code&gt;A&lt;/code&gt; for example. You can copy paste each normal and bold instead of &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;A&lt;/code&gt; in try code and use the same line multiple times with different values. A better approach will be to use arrays instead of multiple lines of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the above sentences in ~/.vimrc&lt;/p&gt;&#xA;" OwnerUserId="7161" LastActivityDate="2016-09-20T08:50:02.620" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9606" PostTypeId="1" AcceptedAnswerId="9607" CreationDate="2016-09-20T09:48:02.273" Score="15" ViewCount="14872" Body="&lt;p&gt;I just followed these instructions to compile vim with python 3: &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the install I checked to see if I have python3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version | grep &quot;python&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which returned: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+python3/dyn  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+python/dyn  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I start vim and type one of the followinf commands, I get a &lt;code&gt;0&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:echo has('python3/dyn')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:echo has('python3')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:echo has('python')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:echo has('python/dyn')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Has anyone had a similar problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Hey guys lots of helpful comments, I just wanted to say thanks and let you guys know what I did to solve this. I followed the instruction again from the first link I provided but this time I removed vim.tiny and instead of trying to get vim to support both python2 and python3, I just build with python3 support. This fixed it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python3 print(&quot;works&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in vim, shows &lt;code&gt;works&lt;/code&gt;. Typing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo has('python3')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives me an output of &lt;code&gt;1&lt;/code&gt; and finally&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version | grep python3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Gives me a value of &lt;code&gt;+python3&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks guys for all the help and suggestions!!&lt;/p&gt;&#xA;" OwnerUserId="9347" LastEditorUserId="9347" LastEditDate="2016-09-21T03:52:34.247" LastActivityDate="2021-09-19T20:56:38.943" Title="Vim compiled with python3 but has('python') returns 0" Tags="|installing|linux-ubuntu|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9607" PostTypeId="2" ParentId="9606" CreationDate="2016-09-20T10:08:00.003" Score="4" Body="&lt;p&gt;This is the expected result.  There are no tests &lt;code&gt;has('python/dyn')&lt;/code&gt; and &lt;code&gt;has('python3/dyn')&lt;/code&gt;, only &lt;code&gt;has('python')&lt;/code&gt; and &lt;code&gt;has('python3')&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-09-20T10:08:00.003" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="9608" PostTypeId="2" ParentId="9604" CreationDate="2016-09-20T10:54:56.567" Score="2" Body="&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4005&quot; rel=&quot;nofollow&quot;&gt;TextTransform plugin&lt;/a&gt; will handle the setup of a mapping; this will support normal mode command for lines and &lt;code&gt;{motion}&lt;/code&gt;, as well as visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example that only works with &lt;code&gt;A&lt;/code&gt;; you need to expand the &lt;code&gt;tr()&lt;/code&gt; accordingly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BoldToggle( text )&#xA;return tr(a:text, &quot;A\U0001D400&quot;, &quot;\U0001D400A&quot;)&#xA;endfunction&#xA;&#xA;call TextTransform#MakeMappings('', '&amp;lt;Leader&amp;gt;b', 'BoldToggle')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then transform a line with &lt;code&gt;&amp;lt;Leader&amp;gt;bb&lt;/code&gt;, or (any) selection with &lt;code&gt;&amp;lt;Leader&amp;gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-20T10:54:56.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9609" PostTypeId="1" AcceptedAnswerId="9628" CreationDate="2016-09-20T14:59:37.033" Score="0" ViewCount="718" Body="&lt;p&gt;I have installed plugins YouCompleteMe and python-mode so as to use the auto-completion when editing a python file. But when I open an &lt;code&gt;.py&lt;/code&gt; file and type &lt;kbd&gt;.&lt;/kbd&gt; in insert mode, the cursor does not move forward as it does in any other case. Then I type a letter and it appears &lt;strong&gt;before&lt;/strong&gt; the dot, which makes auto-completion unavailable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually this question &lt;a href=&quot;https://stackoverflow.com/questions/33432688/why-dot-is-not-working-properly-in-insert-mode-of-vim-editor&quot;&gt;https://stackoverflow.com/questions/33432688/why-dot-is-not-working-properly-in-insert-mode-of-vim-editor&lt;/a&gt; is the same as mine. However I don't know how to tell my situation in this question, neither do I know how to send an email to the user who answered the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By following the answer to the question mentioned above I can not fix the problem on my computer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I type the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it shows &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i  .           *@.&amp;lt;C-R&amp;gt;=pymode#rope#complete_on_dot()&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vim/bundle/python-mode/ftplugin/python/pymode.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iunmap .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it just says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E31: No such mapping&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anybody help me?&lt;/p&gt;&#xA;" OwnerUserId="9349" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-09-21T19:14:03.960" Title="Why my dot key doesn't work properly in insert mode?" Tags="|vimrc|autocompletion|plugin-you-complete-me|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9614" PostTypeId="1" AcceptedAnswerId="9615" CreationDate="2016-09-21T05:41:01.433" Score="1" ViewCount="546" Body="&lt;p&gt;I recently updated my vim to have Python3 support. I was having trouble with it, but I eventually solved the problem that I described &lt;a href=&quot;https://vi.stackexchange.com/q/9606/2313&quot;&gt;here&lt;/a&gt;. Now I am trying to make a vim plugin using python3 and I wrote a test file but when I try to do &lt;code&gt;source %&lt;/code&gt; I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/marv/Documents/vimPlugins/test/plugin/test.vim:&#xA;line    4:&#xA;E319: Sorry, the command is not available in this version: python import sys&#xA;line    5:&#xA;E319: Sorry, the command is not available in this version: python import vim&#xA;line    6:&#xA;E319: Sorry, the command is not available in this version: python sys.path.append(vim.eval('expand(&quot;&amp;lt;sfile&amp;gt;:h&quot;&#xA;)'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is all my code. &#xA;FILE: test.vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; --------------------------------&#xA;  &quot; Add our plugin to the path&#xA;  &quot; --------------------------------&#xA;  python import sys&#xA;  python import vim&#xA;  python sys.path.append(vim.eval('expand(&quot;&amp;lt;sfile&amp;gt;:h&quot;)'))&#xA;&#xA;  &quot; --------------------------------&#xA;  &quot;  Function(s)&#xA;  &quot; --------------------------------&#xA;  function! TemplateExample()&#xA;  python &amp;lt;&amp;lt; endOfPython&#xA;&#xA;  from test import test_example&#xA;&#xA;  for n in range(5):&#xA;      print(test_example())&#xA;&#xA;  endOfPython&#xA;  endfunction&#xA;&#xA;  &quot; --------------------------------&#xA;  &quot;  Expose our commands to the user&#xA;  &quot; --------------------------------&#xA;  command! Example call TemplateExample()       &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;FILE: test.py&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def test_example():&#xA;    return &quot;Happy Hacking!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;again I have python3 working on this in vim doing &lt;code&gt;echo has ('python3')&lt;/code&gt; returns a &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is part of the output for &lt;code&gt;version&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl             +dialog_con_gui  +job             +mouse_sgr       +rightleft       +user_commands&#xA;+arabic          +diff            +jumplist        -mouse_sysmouse  +ruby            +vertsplit&#xA;+autocmd         +digraphs        +keymap          +mouse_urxvt     +scrollbind      +virtualedit&#xA;+balloon_eval    +dnd             +lambda          +mouse_xterm     +signs           +visual&#xA;+browse          -ebcdic          +langmap         +multi_byte      +smartindent     +visualextra&#xA;++builtin_terms  +emacs_tags      +libcall         +multi_lang      +startuptime     +viminfo&#xA;+byte_offset     +eval            +linebreak       -mzscheme        +statusline      +vreplace&#xA;+channel         +ex_extra        +lispindent      +netbeans_intg   -sun_workshop    +wildignore&#xA;+cindent         +extra_search    +listcmds        +num64           +syntax          +wildmenu&#xA;+clientserver    +farsi           +localmap        +packages        +tag_binary      +windows&#xA;+clipboard       +file_in_path    +lua             +path_extra      +tag_old_static  +writebackup&#xA;+cmdline_compl   +find_in_path    +menu            +perl            -tag_any_white   +X11&#xA;+cmdline_hist    +float           +mksession       +persistent_undo -tcl             -xfontset&#xA;+cmdline_info    +folding         +modify_fname    +postscript      +termguicolors   +xim&#xA;+comments        -footer          +mouse           +printer         +terminfo        +xpm&#xA;+conceal         +fork()          +mouseshape      +profile         +termresponse    +xsmp_interact&#xA;+cryptv          +gettext         +mouse_dec       -python          +textobjects     +xterm_clipboard&#xA;+cscope          -hangul_input    +mouse_gpm       +python3         +timers          -xterm_save&#xA;+cursorbind      +iconv           -mouse_jsbterm   +quickfix        +title&#xA;+cursorshape     +insert_expand   +mouse_netterm   +reltime         +toolbar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;anyone know why I get this error of &quot;the command is not available in this version:&quot;?&lt;/p&gt;&#xA;" OwnerUserId="9347" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-09-21T07:19:32.660" Title="cannot source file when trying to make a vim pluggin with python3" Tags="|vimscript|plugin-system|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9615" PostTypeId="2" ParentId="9614" CreationDate="2016-09-21T07:19:32.660" Score="1" Body="&lt;ul&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:python foo&lt;/code&gt; if you have &lt;code&gt;+python&lt;/code&gt; and/or &lt;code&gt;+python/dyn&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:python3 foo&lt;/code&gt; if you have &lt;code&gt;+python3&lt;/code&gt; and/or &lt;code&gt;+python/dyn&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since you only have &lt;code&gt;+python3&lt;/code&gt; there's no reason whatsoever to expect &lt;code&gt;:python&lt;/code&gt; to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help python&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-09-21T07:19:32.660" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9616" PostTypeId="1" CreationDate="2016-09-21T09:49:54.453" Score="8" ViewCount="3004" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gssQ0.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gssQ0.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know why my gvim windows looks like this in linux. Is there anything I need to add to my vimrc file in addition to this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;syntax on&#xA;filetype plugin indent on&#xA;set nocompatible&#xA;set number&#xA;set numberwidth=1&#xA;set autoindent&#xA;set backspace=2&#xA;set backspace=indent,eol,start&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;set shellslash&#xA;set grepprg=grep\ -nH\ $*&#xA;filetype indent on&#xA;let g:tex_flavor='latex'&#xA;imap ^[OA &amp;lt;ESC&amp;gt;ki&#xA;imap ^[OB &amp;lt;ESC&amp;gt;ji&#xA;imap ^[OC &amp;lt;ESC&amp;gt;li&#xA;imap ^[OD &amp;lt;ESC&amp;gt;hi&#xA;augroup markdown&#xA;    au!&#xA;    au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown&#xA;augroup END&#xA;colorscheme koehler &#xA;set guifont=Consolas\ 12&#xA;set guioptions-=T &quot;remove toolbar&#xA;if !has(&quot;gui_running&quot;)&#xA;    set guioptions=icpM&#xA;    set term=xterm&#xA;    set t_Co=256&#xA;    let &amp;amp;t_AB=&quot;\e[48;5;%dm&quot;&#xA;    let &amp;amp;t_AF=&quot;\e[38;5;%dm&quot;&#xA;    inoremap &amp;lt;Char-0x07F&amp;gt; &amp;lt;BS&amp;gt;&#xA;    nnoremap &amp;lt;Char-0x07F&amp;gt; &amp;lt;BS&amp;gt;&#xA;    colorscheme koehler &#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qP1i7.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qP1i7.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;DIFFERENCE - left one is terminal and right side is gvim&lt;/strong&gt;&#xA;I didn't have this problem in windows 10&lt;/p&gt;&#xA;" OwnerUserId="6706" LastEditorUserId="51" LastEditDate="2016-09-21T11:49:10.053" LastActivityDate="2020-01-28T01:44:24.963" Title="gvim window looks bad" Tags="|gvim|linux|font|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9619" PostTypeId="2" ParentId="9616" CreationDate="2016-09-21T10:53:31.733" Score="10" Body="&lt;p&gt;The problem is probably that you don't have the Consolas font installed and that Vim defaults to an ugly default font.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try using a different font, for example this should work on most Linux systems:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Dejavu\ Sans\ Mono\ 12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want it to work on both Windows and Linux you can use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('gui_gtk')&#xA;    set guifont=Dejavu\ Sans\ Mono\ 12&#xA;else&#xA;    set guifont=Consolas:h12&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, if you want to use Consolas on Linux, &lt;a href=&quot;https://unix.stackexchange.com/q/310412/33645&quot;&gt;you can install it&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2016-09-21T10:53:31.733" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9620" PostTypeId="1" AcceptedAnswerId="9621" CreationDate="2016-09-21T11:31:32.803" Score="2" ViewCount="642" Body="&lt;p&gt;Vim's help says Mac users can map command-key with &lt;code&gt;&amp;lt;D-&lt;/code&gt;, so I wonder if PC users can map the Options key(between left ctrl&amp;amp;alt, hex code 0x66).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aBOgF.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aBOgF.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="7361" LastEditorUserId="7361" LastEditDate="2016-09-21T15:45:10.580" LastActivityDate="2016-09-21T15:45:10.580" Title="Is there a way to map PC &quot;Options&quot; key in vim?" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9621" PostTypeId="2" ParentId="9620" CreationDate="2016-09-21T12:28:16.327" Score="2" Body="&lt;p&gt;Here are the results from pressing &lt;code&gt;o&lt;/code&gt;, &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;M-o&amp;gt;&lt;/code&gt;, and &lt;code&gt;Windows + o&lt;/code&gt; (in that order):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[~]% cat &amp;lt; /dev/stdin&#xA;o&#xA;^O&#xA;^[o&#xA;o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, a regular &lt;code&gt;o&lt;/code&gt; and &lt;code&gt;Windows + o&lt;/code&gt; aren't distinguished here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As near as I can find, there is no way to fix this in either terminal Vim or Gvim :-( Many &quot;solutions&quot; simply remap the Windows key to Alt, but that is not a &quot;solution&quot; as far as I'm concerned...&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-09-21T12:28:16.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9622" PostTypeId="1" AcceptedAnswerId="9623" CreationDate="2016-09-21T12:35:14.000" Score="4" ViewCount="230" Body="&lt;p&gt;I would like to map &lt;kbd&gt;H&lt;/kbd&gt; to execute a function, which does the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;If cursor on first column:&lt;/strong&gt; Wrap around/Move cursor to end of the current line&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;If cursor before/on first non-whitespace character of line:&lt;/strong&gt; Move cursor to first column&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;If cursor after first non-whitespace character of line:&lt;/strong&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;If cursor less then five columns to the right of the first non-whitespace character of line:&lt;/strong&gt; Move cursor to first non-whitespace character of line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Otherwise:&lt;/strong&gt; Move cursor five columns to the left.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Sadly I never wrote a single function in vimscript and have no idea how to translate this idea into real code. Does anyone have an idea where I should look into to learn how to create this function?&lt;/p&gt;&#xA;" OwnerDisplayName="user9334" LastEditorUserId="1841" LastEditDate="2016-09-21T19:32:41.137" LastActivityDate="2016-09-21T19:32:41.137" Title="How to override the move left motion" Tags="|key-bindings|vimscript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9623" PostTypeId="2" ParentId="9622" CreationDate="2016-09-21T12:51:29.317" Score="4" Body="&lt;p&gt;You could try to add this to your &lt;code&gt;.vimrc&lt;/code&gt; I didn't tested it extensively but it looks like it is working.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyHMotion()&#xA;    &quot; Get the position of the cursor and of the first non white character&#xA;    let cursorPosition=getpos(&quot;.&quot;)&#xA;    normal! ^&#xA;    let firstChar=getpos(&quot;.&quot;)&#xA;&#xA;    if cursorPosition[2] == 1&#xA;        &quot; Cursor on first column : go to the end of line&#xA;        normal! $&#xA;    elseif cursorPosition[2] &amp;lt;= firstChar[2]&#xA;        &quot; Cursor before/on first non-whitespace character: go to first column&#xA;        normal! 0    &#xA;    elseif cursorPosition[2] &amp;lt;= firstChar[2]+5&#xA;        &quot; cursor less than five columns after the first non-whitespace character: go to first non-white character&#xA;        normal! ^&#xA;    else&#xA;        &quot; Move normally&#xA;        call setpos('.', cursorPosition)&#xA;        normal! h&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; h :call MyHMotion()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function is commented and its behavior should be pretty clear. Here are some additional information:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;!&lt;/code&gt; following &lt;code&gt;normal&lt;/code&gt; is here so that the command will not use user-defined mappings. More info at &lt;code&gt;:h normal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The last line &lt;code&gt;nnoremap &amp;lt;silent&amp;gt; h :call MyHMotion()&amp;lt;CR&amp;gt;&lt;/code&gt; is here to map &lt;kbd&gt;h&lt;/kbd&gt; so that the function &lt;code&gt;MyHMotion()&lt;/code&gt; is called each time you press the key.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; argument is here so that nothing is echoed on the command line when the function is called. See &lt;code&gt;:h :map-silent&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I used &lt;a href=&quot;https://github.com/statox/dotfiles/blob/master/vimrc#L365-L394&quot; rel=&quot;nofollow&quot;&gt;these functions of mine&lt;/a&gt; as inspiration. They override &lt;kbd&gt;h&lt;/kbd&gt; and &lt;kbd&gt;l&lt;/kbd&gt; to skip the whitespaces at the beginning of a line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; make h and l skip indentation white spaces {{{&#xA;    function! MyLMotion()&#xA;        let cursorPosition=getpos(&quot;.&quot;)&#xA;        normal! ^&#xA;        let firstChar=getpos(&quot;.&quot;)&#xA;&#xA;        if cursorPosition[2] &amp;lt; firstChar[2]&#xA;            normal! ^&#xA;        else&#xA;            call setpos('.', cursorPosition)&#xA;            normal! l&#xA;        endif&#xA;    endfunction&#xA;&#xA;    function! MyHMotion()&#xA;        let cursorPosition=getpos(&quot;.&quot;)&#xA;        normal! ^&#xA;        let firstChar=getpos(&quot;.&quot;)&#xA;&#xA;        if cursorPosition[2] &amp;lt;= firstChar[2]&#xA;            normal! 0&#xA;        else&#xA;            call setpos('.', cursorPosition)&#xA;            normal! h&#xA;        endif&#xA;    endfunction&#xA;&#xA;    nnoremap &amp;lt;silent&amp;gt; h :call MyHMotion()&amp;lt;CR&amp;gt;&#xA;    nnoremap &amp;lt;silent&amp;gt; l :call MyLMotion()&amp;lt;CR&amp;gt;&#xA;&quot;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-09-21T15:11:20.710" LastActivityDate="2016-09-21T15:11:20.710" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="9625" PostTypeId="2" ParentId="9609" CreationDate="2016-09-21T13:10:19.327" Score="0" Body="&lt;p&gt;I copied a &lt;code&gt;.vimrc&lt;/code&gt; file to my computer from another computer where the auto-completion works. It turned out that &lt;code&gt;.vimrc&lt;/code&gt; works on my computer, so the problem is fixed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I have lost my original &lt;code&gt;.vimrc&lt;/code&gt;, hence I can not give an explanation.&lt;/p&gt;&#xA;" OwnerUserId="9349" LastEditorUserId="9349" LastEditDate="2016-09-21T13:46:13.233" LastActivityDate="2016-09-21T13:46:13.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9626" PostTypeId="1" AcceptedAnswerId="18233" CreationDate="2016-09-21T18:10:31.757" Score="3" ViewCount="921" Body="&lt;p&gt;Giving these 2 substitution commands in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/}$/\r}\r/g&#xA;%s/^\s*([a-zA-Z\#\.\:\s\(\)-\[\]'=]*)\s*\{/$1 \{/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have 2 questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I join 2 substitution commands in a one line command ?&lt;/li&gt;&#xA;&lt;li&gt;Is there a better regex command to make this a oneliner ?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I know I could make a function with both commands, but I'm in Eclipse VRapper not in Vim itself. AFAIU I can't have functions in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That question suggested doesn't solve the problem, because these substitutions should be made one after the other. They convert a compiled sccs from nested to expanded output style. It's not just two occurences that can be substituted in text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would like in the first question is something like this PHP code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$w = &quot;Hi Planet!&quot;;&#xA;echo str_replace(&quot;Hi&quot;, &quot;Hello&quot;, str_replace(&quot;Planet&quot;, &quot;World&quot;, $w));&#xA;// result: Hello World!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5944" LastEditorUserId="23502" LastEditDate="2022-09-08T18:37:30.110" LastActivityDate="2022-09-08T18:37:30.110" Title="How can I make two substitution command in one line" Tags="|regular-expression|substitute|vrapper|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9627" PostTypeId="1" AcceptedAnswerId="9636" CreationDate="2016-09-21T19:01:17.130" Score="3" ViewCount="1484" Body="&lt;p&gt;In part of a plugin I'm slowly building, I use &lt;code&gt;&amp;lt;cfile&amp;gt;&lt;/code&gt; to get the file pointed by the word under the cursor and then do something if it points to a directory, or open the file pointed to otherwise (so unless the word under the cursors points to a directory, it's supposed to behave exactly like &lt;code&gt;gf&lt;/code&gt;). It all works fine, except for suffixes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;help &amp;lt;cfile&amp;gt;&lt;/code&gt; in vim says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;&amp;lt;cfile&amp;gt;&lt;/code&gt;    is replaced with the path name under the cursor (like what &lt;code&gt;gf&lt;/code&gt; uses)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;but while &lt;code&gt;gf&lt;/code&gt; will include a possibly auto-detected &lt;code&gt;suffix&lt;/code&gt;, this doesn't seem to be the case in &lt;code&gt;&amp;lt;cfile&amp;gt;&lt;/code&gt;. Is there some kind of workaround for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case it helps clarify my question, here's the relevant code excerpt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1 function! now#BufEnter() &quot;{{{                                          &#xA;  2 &quot; behaviour of &amp;lt;enter&amp;gt; while on now files (mapped on ftplugin)         &#xA;  3   execute &quot;silent! normal! :set suffixesadd=&quot; . g:NOW_suffix . &quot;\r&quot;    &#xA;  4   let l:dest = expand(&quot;&amp;lt;cfile&amp;gt;&quot;)                                       &#xA;  5   if isdirectory(l:dest)                                               &#xA;  6     &quot; if pointing to a directory, update and enter index file there    &#xA;  7     execute 'normal! :cd ' . l:dest . &quot;\r&quot;                             &#xA;  8     call now#MakeIndex()                                               &#xA;  9   else                                                                 &#xA; 10     &quot; otherwise edit the file, whether it exists or not                &#xA; 11     execute 'normal! :e ' . l:dest . &quot;\r&quot;                              &#xA; 12   endif                                                                &#xA; 13 endfunction &quot;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Line 3 was added for debugging purposes only, copied from elsewhere. The added suffix is flawlessly detected by &lt;code&gt;gf&lt;/code&gt;, but not with the keymap pointing towards the above function (as the comments in the code mention, it is the &lt;code&gt;&amp;lt;enter&amp;gt;&lt;/code&gt; key). When no suffix is needed, the code works as expected: do the directory stuff if need, or edit the  pointed file, creating it if necessary.&lt;/p&gt;&#xA;" OwnerUserId="2058" LastActivityDate="2016-09-22T11:57:19.460" Title="How can I get vim to include suffixes in &lt;cfile&gt;?" Tags="|vimscript|filesystem|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9628" PostTypeId="2" ParentId="9609" CreationDate="2016-09-21T19:14:03.960" Score="4" Body="&lt;p&gt;For anyone else stumbling upon this; the reason why &lt;code&gt;:iunmap&lt;/code&gt; didn't work is found in &lt;code&gt;:help E31&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- If the mapping is buffer-local you need to use &quot;:unmap &amp;lt;buffer&amp;gt;&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;YouCompleteMe seems to just set everything buffer-locally (after all, why shouldn't it?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When vim throws an error message like &lt;code&gt;E31: No such mapping&lt;/code&gt;, you should always take a peek at the relevant help number. They're extremely helpful.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2016-09-21T19:14:03.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9629" PostTypeId="1" AcceptedAnswerId="9630" CreationDate="2016-09-21T19:29:31.763" Score="3" ViewCount="1031" Body="&lt;p&gt;In one of my vim scripts I require the column of the last non-whitespace character of the current line and the column of the last character of the current line (when the current line is wrapped into two or more lines) I would like to get the column of the last character on the same visual line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I acquire these columns?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;thisis[o]nelonglineXXXXX&#xA;thisisstillthesameline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Cursor marked as&lt;/em&gt;: [ ]&lt;br&gt;&#xA;&lt;em&gt;Whitespace marked as&lt;/em&gt;: X&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Expected result:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Column of last &lt;strong&gt;e&lt;/strong&gt; in first line&lt;/li&gt;&#xA;&lt;li&gt;Column of last &lt;strong&gt;X&lt;/strong&gt; in first line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerDisplayName="user9334" LastEditorUserId="6489" LastEditDate="2016-09-21T21:56:46.117" LastActivityDate="2016-09-22T13:41:16.087" Title="Get column of last character in visual line - Vimscript" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9630" PostTypeId="2" ParentId="9629" CreationDate="2016-09-21T21:50:32.483" Score="2" Body="&lt;p&gt;Here's something I cooked up. It uses &lt;code&gt;g$&lt;/code&gt; to find the end of the visual line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetLastVisualColumn(nonBlankFlag)&#xA;   &quot; Save the original spot&#xA;   let originalPos = getpos('.')&#xA;&#xA;   &quot; Put cursor at last character on visual line&#xA;   normal! g$&#xA;&#xA;   &quot; If caller specified nonBank and the cursor is on whitespace then jump to the&#xA;   &quot;   most recent end of word&#xA;   if (a:nonBlankFlag)&#xA;      if matchstr(getline('.'), '\%' . col('.') . 'c.') =~ '\s'&#xA;         &quot; This black magic just finds out if the character under the cursor is whitespace.&#xA;         normal! ge&#xA;      endif&#xA;   endif&#xA;&#xA;   &quot; Save column&#xA;   let column = getpos('.')[2]&#xA;&#xA;   &quot; Go back to original position&#xA;   call setpos('.', originalPos)&#xA;&#xA;   return column&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It moves the cursor around (and then puts it back), but as longs as that's not an issue it should work for you. Pass it &lt;code&gt;0&lt;/code&gt; for end of visual line, or &lt;code&gt;1&lt;/code&gt; for last non-blank character on the visual line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info see: &lt;code&gt;:h normal&lt;/code&gt;, &lt;code&gt;:h g$&lt;/code&gt;, &lt;code&gt;:h matchstr&lt;/code&gt;, &lt;code&gt;:h getpos()&lt;/code&gt;, and &lt;code&gt;:h setpos()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-09-22T13:41:16.087" LastActivityDate="2016-09-22T13:41:16.087" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9631" PostTypeId="1" AcceptedAnswerId="9632" CreationDate="2016-09-21T22:28:35.390" Score="1" ViewCount="431" Body="&lt;p&gt;I have the following line in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype html setlocal tabstop=8 softtabstop=8 shiftwidth=8 expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doesn't count for anything when I open an html file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set expandtab? sts?&#xA;noexpandtab&#xA;softtabstop=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I go about figuring out what is resetting &lt;code&gt;expandtab&lt;/code&gt; and &lt;code&gt;softtabstop&lt;/code&gt;? In general, what &lt;em&gt;can&lt;/em&gt; I do to find out what is making a certain change, between vimrc, my own installed plugins, plugins in the distribution, &amp;amp;c&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried searching the files from &lt;code&gt;:scriptnames&lt;/code&gt; for references to &lt;code&gt;softtabstop&lt;/code&gt;. Some reference it or set it to 8, but none of these seem to be setting it to zero (or any other variable value).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If somebody is inclined, I'd welcome a glance at my vimrc and &lt;code&gt;:scriptnames&lt;/code&gt; output in case the problem is obvious from these. You can find them &lt;a href=&quot;https://gist.github.com/jpassaro/1da25ec59b3d9c4342c6fb58aa7e5e4a&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9376" LastActivityDate="2019-05-01T19:01:24.200" Title="What is resetting my softtabstop?" Tags="|vimrc|plugin-system|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9632" PostTypeId="2" ParentId="9631" CreationDate="2016-09-21T23:16:07.997" Score="5" Body="&lt;p&gt;Run &lt;code&gt;:verbose set &amp;lt;name&amp;gt;&lt;/code&gt;, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set tabstop&#xA;tabstop=4&#xA;      Last set from ~/.vim/settings.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:verbose&lt;/code&gt; also works with other commands (e.g. &lt;code&gt;:map&lt;/code&gt;). See &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3averbose&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :verbose&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-09-21T23:16:07.997" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9633" PostTypeId="2" ParentId="9631" CreationDate="2016-09-22T00:08:29.547" Score="2" Body="&lt;p&gt;Managed to figure it out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set filetype? &quot; expecting html here&#xA;jinja&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Makes sense because I do have a jinja plugin at work. Same autocmd for &quot;jinja&quot; filetype instead of html and I'm good to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Compiling a few things I learned along the way in case somebody else finds this answer:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:set filetype?&lt;/code&gt; as seen above tells you what filetype vim thinks you are in&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:verbose set &amp;lt;var&amp;gt;&lt;/code&gt; tells you where the variable was last set. If it does not, you either set it yourself, or it's at system default (as was the case with me). Thank you @Carpetsmoker!&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;This answer&lt;/a&gt; is a good resource. Thank you (again) @Carpetsmoker for making the resource, and @Tumbler41 for pointing me to it!&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Debug_unexpected_option_settings&quot; rel=&quot;nofollow noreferrer&quot;&gt;Another good resource at vim wikia&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help!&lt;/p&gt;&#xA;" OwnerUserId="9376" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-09-22T00:08:29.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9635" PostTypeId="1" CreationDate="2016-09-22T06:14:58.147" Score="7" ViewCount="1668" Body="&lt;p&gt;To have proper paragraph wrapping with indentation in vim (after vim7.4) we could use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Wrap the text with identation isntead of the old way &#xA;set breakindent&#xA;set showbreak=\ \\_  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/doc/version8.txt&quot; rel=&quot;noreferrer&quot;&gt;vim8&lt;/a&gt; has introduced new features about break-indent I want to know if there would be a better practice?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;p.s. the option name is the same and this &quot;new vim 8.0 features&quot; might not be that new!&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Edit (Provide an example for proper indentation):&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;here is a list in markdown and normal vim act like this:&#xA;    * first item&#xA;    * second item blah blah blah blah  blah blah blah blah blah&#xA;blah blah blah blah blah blah blah blah blah blah blah blah blah&#xA;blah blah blah blah blah blah blah blah blah blah&#xA;    * third time&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and here is the proper way which is famously called &quot;&lt;strong&gt;wrapping with indentation&lt;/strong&gt;&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;here is the base line:&#xA;    * first item&#xA;    * second item blah blah blah blah  blah blah blah blah blah&#xA;      blah blah blah blah blah blah blah blah blah blah blah blah&#xA;      blah blah blah blah blah &#xA;    * third time&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9382" LastEditorUserId="54" LastEditDate="2016-09-22T09:38:35.693" LastActivityDate="2021-09-08T10:08:35.837" Title="What is the best practice in vim8 for wrapping with indentation aka breakindent" Tags="|vimrc|indentation|wrapping|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9636" PostTypeId="2" ParentId="9627" CreationDate="2016-09-22T07:42:22.023" Score="2" Body="&lt;p&gt;Prompted by the comment fron @VanLaser, I thought it may be possible to somehow discriminate the behaviour with an &lt;code&gt;if filereadable()&lt;/code&gt; to decide whether invoking a regular &lt;code&gt;gf&lt;/code&gt; or an &lt;code&gt;:edit&lt;/code&gt; in order to work around the limitations of &lt;code&gt;&amp;lt;cfile&amp;gt;&lt;/code&gt;. However, there's a catch: I don't know which file to seek for readability before invoking &lt;code&gt;gf&lt;/code&gt;. So finally, after &lt;code&gt;try&lt;/code&gt;ing a bit, here's a solution... with a &lt;code&gt;catch&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1 function! now#BufEnter() &quot;{{{&#xA; 2 &quot; behaviour of &amp;lt;enter&amp;gt; while on now files (mapped on ftplugin)&#xA; 3   execute &quot;silent! normal! :set suffixesadd=&quot; . g:NOW_suffix . &quot;\r&quot;&#xA; 4   let l:dest = expand(&quot;&amp;lt;cfile&amp;gt;&quot;)&#xA; 5   if isdirectory(l:dest)&#xA; 6     &quot; if pointing to a directory, update and enter index file there&#xA; 7     execute 'normal! :cd ' . l:dest . &quot;\r&quot;&#xA; 8     call now#MakeIndex()&#xA; 9   else&#xA;10     &quot; otherwise edit the file, whether it exists or not&#xA;11     &quot; N.B: this is a bit tricky, because &amp;lt;cfile&amp;gt; does not detect an optional&#xA;12     &quot; suffix, as discussed in the following Q/A topic:&#xA;13     &quot; https://vi.stackexchange.com/q/9627/2058&#xA;14     try&#xA;15       &quot; if a file can be found, with optional suffix, open it&#xA;16       normal gf&#xA;17     catch&#xA;18       &quot; otherwise, create the file pointed to&#xA;19       execute 'normal! :e ' . l:dest . &quot;\r&quot;&#xA;20     endtry&#xA;21   endif&#xA;22 endfunction &quot;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A nice side-effect of this is being able to actually &lt;strong&gt;add&lt;/strong&gt; a specific suffix upon creation (not shown in above code, which, for reference, is only trying to modify the question's code enough to answer the actual question).&lt;/p&gt;&#xA;" OwnerUserId="2058" LastEditorUserId="2058" LastEditDate="2016-09-22T11:57:19.460" LastActivityDate="2016-09-22T11:57:19.460" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9637" PostTypeId="2" ParentId="7094" CreationDate="2016-09-22T08:14:00.533" Score="3" Body="&lt;p&gt;According to &lt;a href=&quot;https://github.com/vim-airline/vim-airline/issues/1172#issuecomment-219304788&quot; rel=&quot;nofollow&quot;&gt;Christian Brabandt&lt;/a&gt; this is how airline works. He created a solution that requires setting the variable&#xA;    &lt;code&gt;let g:airline_skip_empty_sections = 1&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9383" LastActivityDate="2016-09-22T08:14:00.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9639" PostTypeId="1" AcceptedAnswerId="9640" CreationDate="2016-09-22T10:05:18.047" Score="2" ViewCount="112" Body="&lt;p&gt;I would like to be able to easily create html-colored versions of a list of files (ex: &quot;all the files in this directory&quot;,  or &quot;this list of files&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can do this manually, one by one, by:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;opening the file (ex: &lt;code&gt;:e /path/to/Foo.bash&lt;/code&gt;) in vim (with syntax enabled)&lt;/li&gt;&#xA;&lt;li&gt;typing &lt;code&gt;:hardcopy&lt;/code&gt; to obtain a html-version of the file that also contains the syntax highlighting colors&lt;/li&gt;&#xA;&lt;li&gt;saving that file (ex: &lt;code&gt;:w /path/to/Foo.bash.htm&lt;/code&gt;) &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But how can I &quot;automate&quot; this, ie do it for either all files in a directory or for a list of comma separated file names ?&lt;/p&gt;&#xA;" OwnerUserId="1289" LastEditorUserId="1841" LastEditDate="2016-09-22T10:25:49.613" LastActivityDate="2016-09-22T10:25:52.950" Title="batch create html colored versions of a list of files reflecting syntax highlighting" Tags="|vimscript|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9640" PostTypeId="2" ParentId="9639" CreationDate="2016-09-22T10:25:52.950" Score="3" Body="&lt;p&gt;There is a script named &lt;code&gt;2html&lt;/code&gt; that comes with recent versions of Vim.  Its purpose is to convert files to HTML (see &lt;code&gt;:h 2html.vim&lt;/code&gt;).  You can run it in a batch like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;open all files you want to convert:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim *.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;run the script with a &lt;code&gt;bufdo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo runtime! syntax/2html.vim | wq&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This should create a file &lt;code&gt;foo.sh.html&lt;/code&gt; for each input file &lt;code&gt;foo.sh&lt;/code&gt;.  Beware that the script converts files in the exact state they are in Vim: the same color theme is used, closed folders are kept closed etc.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-09-22T10:25:52.950" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9641" PostTypeId="2" ParentId="9599" CreationDate="2016-09-22T12:07:18.113" Score="3" Body="&lt;p&gt;The problem is that the TeX syntax is hierarchical; the default &lt;code&gt;texItalStyle&lt;/code&gt; is &lt;em&gt;contained&lt;/em&gt; in two clusters, &lt;code&gt;texFoldGroup&lt;/code&gt; and &lt;code&gt;texItalGroup&lt;/code&gt;. The former cluster is contained in the top-level regions (&lt;code&gt;texDocZone&lt;/code&gt;, &lt;code&gt;texPartZone&lt;/code&gt;, and so on). Without that containment, your syntax rule never has a chance to match; the toplevel regions slice up your entire document, and they only allow &lt;em&gt;contained&lt;/em&gt; members to match subsets of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By choosing the same syntax group for your extension, you automatically fit in. If you absolutely want to define a custom syntax group, you'd have to add them into the clusters (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax cluster texFoldGroup add=texOeuvreStyle&#xA;syntax cluster texItalGroupGroup add=texOeuvreStyle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-22T12:07:18.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9642" PostTypeId="1" AcceptedAnswerId="9643" CreationDate="2016-09-22T15:46:26.330" Score="19" ViewCount="2740" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#E65&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h E65&lt;/code&gt;&lt;/a&gt; we can see that Vim doesn't allow more than 9 capture groups in a substitution command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example the following command will work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\v(a)(b)(c)(d)(e)(f)(g)(h)(i)/\9\8\7\6\5\4\3\2\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this one with one more capture group will fail:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\v(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)/\10\9\8\7\6\5\4\3\2\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is not about &lt;em&gt;why it fails&lt;/em&gt; (it's a Vim hard limit) but about &lt;strong&gt;why does Vim have this limit at all?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I'm aware that a real life regex with more than 9 capture group would probably be pretty monstrous to read and to maintain but I'm still curious.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-11-22T09:59:53.763" LastActivityDate="2016-11-22T09:59:53.763" Title="Why doesn't Vim regex allow more than 9 capture groups?" Tags="|regular-expression|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9643" PostTypeId="2" ParentId="9642" CreationDate="2016-09-22T16:09:40.853" Score="28" Body="&lt;p&gt;The obvious reason is that groups with two or more digits are ambiguous: should &lt;code&gt;\12&lt;/code&gt; be taken as group 12, or as group 1 followed by the string &lt;code&gt;2&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other reasons related to efficiency (exponential matching time and the like).  These were a show stopper when &lt;code&gt;ed&lt;/code&gt; was written.  Better algorithms have been discovered since then.&lt;/p&gt;&#xA;" OwnerUserId="2313" LastEditorUserId="2313" LastEditDate="2016-09-22T16:20:00.747" LastActivityDate="2016-09-22T16:20:00.747" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9644" PostTypeId="1" AcceptedAnswerId="9645" CreationDate="2016-09-22T19:34:51.607" Score="24" ViewCount="15484" Body="&lt;p&gt;How can one use a variable when executing something via &lt;code&gt;normal!&lt;/code&gt; in vimscript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction(someArg)&#xA;   normal! (a:someArg)l&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should move the cursor &lt;code&gt;someArg&lt;/code&gt; steps to the right.&lt;/p&gt;&#xA;" OwnerDisplayName="user9334" LastEditorUserId="1841" LastEditDate="2016-09-23T13:17:19.950" LastActivityDate="2022-02-15T11:29:12.400" Title="How to use a variable in the expression of a 'normal' command?" Tags="|vimscript|normal-mode|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9645" PostTypeId="2" ParentId="9644" CreationDate="2016-09-22T20:12:52.827" Score="35" Body="&lt;p&gt;The &lt;code&gt;execute&lt;/code&gt; function takes a string as argument, it expands the string and execute it a a regular ex command. Thus you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction(someArg) &#xA;    execute &quot;normal! &quot;. a:someArg. &quot;l&quot; &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;.&lt;/code&gt; is a standard vimscript operator to concatenate strings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;execute&lt;/code&gt; can be shortened to &lt;code&gt;exe&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h :execute&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; I'll add a point about the comment of @Christian Brabandt about the concatenation with a &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The doc says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Multiple arguments are concatenated, with a space in&#xA;  between.  To avoid the extra space use the &quot;.&quot;&#xA;  operator to concatenate strings into one argument.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So the command could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal!&quot; a:someArg . &quot;l&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The executed command will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! 2l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="343" LastEditDate="2019-10-08T14:31:21.690" LastActivityDate="2019-10-08T14:31:21.690" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9646" PostTypeId="1" CreationDate="2016-09-22T23:08:58.063" Score="6" ViewCount="381" Body="&lt;p&gt;I would like to know the proper substitution command in vi that would accomplish this. &lt;/p&gt;&#xA;" OwnerUserId="9395" LastEditorUserId="1841" LastEditDate="2016-09-23T07:22:02.140" LastActivityDate="2016-09-24T12:09:38.530" Title="How do I capitalize the first word after each period, question mark or exclamation point?" Tags="|substitute|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9647" PostTypeId="2" ParentId="9646" CreationDate="2016-09-22T23:49:25.777" Score="8" Body="&lt;pre&gt;&lt;code&gt;%s;[.?!]\_s*\zs\&amp;lt;\w\+\&amp;gt;;\U&amp;amp;;g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a normal vim substitute command with &lt;code&gt;;&lt;/code&gt; as &lt;em&gt;separation character&lt;/em&gt;; you can use other characters beside the default &lt;code&gt;/&lt;/code&gt; as separation character, as long as it does not appear in the expression.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s        : Do substitute command on the entire buffer&#xA;&#xA;[.?!]     : match every . or ? or ! and&#xA;\_s*      : match every whitespace including newline after it if there is any, and&#xA;\zs       : start the match from here and&#xA;\&amp;lt;\w\+\&amp;gt;  : select first word&#xA;&#xA;\U&amp;amp;       : then make it capitalize (or use \u&amp;amp; to only capitalize first character)&#xA;&#xA;g         : globally&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7976" LastEditorUserId="51" LastEditDate="2016-09-24T12:09:38.530" LastActivityDate="2016-09-24T12:09:38.530" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9648" PostTypeId="1" AcceptedAnswerId="9650" CreationDate="2016-09-23T03:46:39.947" Score="0" ViewCount="201" Body="&lt;p&gt;File &lt;code&gt;BATMAN&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-2-3-4-6-8-10-11-13-14-16-17-18-19-20-21-25-29-30-33-35-36-37-43-44-45-47-48-49-50-51-52-54-55-56-57-58-59-60-61-62-63-64-65-66-68-69-70-71-73-74-75-76-81-82-83-85-86-87-88-89-90-91-92-94-95-96-97-98-99-101-102-103-104-108-110-111-112-113-114-115-116-117-128-129-130-131-132-133-134-135-136-137-147-148-149-150-151-154-155-156-157-158-159-160-161-162-163-164-165-166-167-168-171-173-174-175-177-180-184-185-186-187-188-189-190-191&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;File &lt;code&gt;ROBIN&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-2-3-4-6-7-8-11-16-17-18-20-21-29-30-33-34-35-36-37-44-48-49-51-52-55-56-57-58-61-65-66-67-69-70-71-74-75-76-80-81-82-83-86-90-91-92-95-97-98-100-101-103-104-119-120-121-122-123-124-125-127-129-131-132-133-134-136-138-139-140-141-142-143-144-150-156-157-158-161-163-164-165-166-167-172-173-175-179-184-186-189-191&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;File &lt;code&gt;LOCUTOR&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-4-147&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I work in a translation company , and need to count the time that the actor speaks, and insert the count into the current file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my vimrc file I created this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Abb()&#xA;    exe &quot;:s/-//gn&quot;&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I insert the number of word count manually. Thanks for your help&lt;/p&gt;&#xA;" OwnerUserId="9354" LastEditorUserId="343" LastEditDate="2017-12-06T11:06:26.403" LastActivityDate="2017-12-06T11:06:26.403" Title="Vim Word count and insert into current text" Tags="|vimscript|counting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9649" PostTypeId="1" CreationDate="2016-09-23T06:23:19.060" Score="5" ViewCount="368" Body="&lt;p&gt;I'm trying to open and edit files with Mongolian text, written in Mongolian Cyrillic. In the cmd terminal and in powershell terminal if I choose Consolas font, everything is ok with Mongolian Cyrillic, letters Өө and Үү are displayed correctly. If I open any Mongolian files in terminal Vim or gVim window, it shows them as &lt;code&gt;?&lt;/code&gt; sign. I have such an option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set guifont?&#xA;  guifont=Consolas:h9:cRUSSIAN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I added to _vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=utf8&#xA;set termencoding=utf8&#xA;set guifont=Consolas:h11:cRUSSIAN          &quot;to get proper font for Cyrillic&#xA;set fileencodings=utf8,cp1251,cp866,koi8r&#xA;&quot;to get English menu instead of broken Russian&#xA;set langmenu=en_US                        &#xA;let $LANG = 'en_US'&#xA;source $VIMRUNTIME/delmenu.vim&#xA;source $VIMRUNTIME/menu.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code lets me see files properly. But I still can't type either search this letters straight in Vim. While typing, gVim turns them to &lt;code&gt;?&lt;/code&gt;-s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please, give me some advise, what should I do to fix that problem?&lt;/p&gt;&#xA;" OwnerUserId="9385" LastEditorUserId="1841" LastEditDate="2018-10-09T14:35:13.280" LastActivityDate="2018-10-09T14:35:13.280" Title="Vim and gVim in Windows doesn't recognize Mongolian letters Өө and Үү" Tags="|gvim|microsoft-windows|font|encoding|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9650" PostTypeId="2" ParentId="9648" CreationDate="2016-09-23T06:41:35.123" Score="1" Body="&lt;p&gt;Assuming for each actor, you only have a single line with the many hyphens and your cursor is on a line with the many hyphens, you can do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call append('.', &quot;Count: &quot;.len(split(getline('.'),'-')))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course you can now wrap it into a function, find the next line with hyphens in it, if the cursor is not on it or add some error management. That is left as an excercise to the reader :)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-09-23T06:41:35.123" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9651" PostTypeId="1" AcceptedAnswerId="9652" CreationDate="2016-09-24T08:27:30.330" Score="2" ViewCount="2542" Body="&lt;p&gt;I'm very new to vim and found bindings &lt;code&gt;Ctrl-F&lt;/code&gt; for page down and &lt;code&gt;Ctrl-B&lt;/code&gt; for page up kind of inconvenient. I intuitively try to page up with &lt;code&gt;Ctrl-F&lt;/code&gt; and page down with &lt;code&gt;Ctrl-B&lt;/code&gt; because &lt;code&gt;F&lt;/code&gt; is higher than &lt;code&gt;B&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;QUESTION:&lt;/em&gt;&lt;/strong&gt; Is there a way to swap this two combinations?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastEditorUserId="5481" LastEditDate="2018-02-21T14:26:21.867" LastActivityDate="2018-02-21T14:26:21.867" Title="Swap two shortcuts" Tags="|key-bindings|navigation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9652" PostTypeId="2" ParentId="9651" CreationDate="2016-09-24T08:33:22.570" Score="9" Body="&lt;p&gt;Yes. You can change just about anything you want to change in Vim. &#xA;Just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-f&amp;gt; &amp;lt;C-b&amp;gt;&#xA;nnoremap &amp;lt;C-b&amp;gt; &amp;lt;C-f&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add those two mappings in your &lt;code&gt;vimrc&lt;/code&gt; file and you've both of those commands swapped. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap&lt;/code&gt; - Maps new key combinations to existing commands without affecting any other commands that might be using the original command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mnemonic for me is, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f - forward&#xA;b - backward&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, whenever I want to go forward in the page, I press &lt;code&gt;Ctrl + F&lt;/code&gt; and &lt;code&gt;Ctrl + B&lt;/code&gt; for going backward. &lt;/p&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="5481" LastEditDate="2018-02-21T13:50:42.440" LastActivityDate="2018-02-21T13:50:42.440" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9653" PostTypeId="1" AcceptedAnswerId="9655" CreationDate="2016-09-24T08:39:45.083" Score="2" ViewCount="877" Body="&lt;p&gt;From &lt;strong&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/2002/4652&quot;&gt;How do I jump to the location of my last edit?&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can press:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to take my cursor to the position of last edit but:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't take me to the last position of my cursor, as it says it should in the question / answer linked above.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There is also `` which will bring you back to where the cursor was before you made your last jump. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://vgy.me/ZTEt6Q.gif&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4652" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-06-11T07:24:44.230" Title="Cursor to last edit works, last position doesn't" Tags="|cursor-movement|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9654" PostTypeId="2" ParentId="9653" CreationDate="2016-09-24T09:06:26.453" Score="3" Body="&lt;p&gt;As an alternative I found and downloaded the plugin &lt;a href=&quot;https://github.com/farmergreg/vim-lastplace/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;vim-lastplace&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apt-get install vim-lastplace&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works, but I'm curious as to why&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't seem to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I won't accept this answer because it's a workaround, hopefully someone can explain the question at hand.&lt;/p&gt;&#xA;" OwnerUserId="4652" LastEditorUserId="9153" LastEditDate="2017-06-11T07:24:44.230" LastActivityDate="2017-06-11T07:24:44.230" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9655" PostTypeId="2" ParentId="9653" CreationDate="2016-09-24T10:10:01.837" Score="6" Body="&lt;p&gt;That link addresses a different use case so it only &lt;em&gt;partially&lt;/em&gt; applies.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The &quot;single quote&quot; and &quot;single backtick&quot;  marks are not saved between sessions so there's no reason to expect &lt;code&gt;``&lt;/code&gt; to work its magic in your specific example.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;``&lt;/code&gt; moves the cursor to the position before the last &lt;strong&gt;&quot;jump&quot;&lt;/strong&gt;. Since you are moving your cursor with the arrows or hjkl there's no &quot;jump&quot; involved and thus no reason to expect &lt;code&gt;``&lt;/code&gt; to work its magic in the current session anyway.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Contrary to the &quot;single quote&quot; and &quot;single backtick&quot; marks, the &quot;dot&quot; mark &lt;em&gt;is&lt;/em&gt; saved between sessions so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will effectively work within the current session and in future session.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &quot;move to last position&quot; mark you are looking for is the &quot;double quote&quot;. Like the &quot;dot&quot; mark it is saved between sessions and can be used at any time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-09-24T10:10:01.837" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9656" PostTypeId="1" AcceptedAnswerId="9657" CreationDate="2016-09-24T12:40:58.427" Score="11" ViewCount="11599" Body="&lt;p&gt;I'm experimenting with vim and got a little stuck with the &lt;code&gt;p&lt;/code&gt; command and the way it works. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TEST Data to copy //copy from here&#xA;&#xA;test data to copy //line for experiments&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;RESULTS:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tTEST est data // cursor at the beginning, &quot;TEST &quot; pasted with p&#xA;TEST test data // cursor at the beginning, &quot;TEST &quot; pasted with P&#xA;&#xA;test data      // cursor at the begining, pasted the whole line with p&#xA;TEST Data to copy&#xA;&#xA;TEST Data to copy&#xA;test data     // cursot at the beginning, pasted the whole line with P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought, &lt;code&gt;p&lt;/code&gt; pastes after the current cursor position, but pasting a line with it does not work this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if we paste a word with &lt;code&gt;p&lt;/code&gt;, it will be pasted after the character, the cursor points to. But if we yank the whole line it will be pasted after the line the cursor was at when we pressed &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;QUESTION:&lt;/em&gt;&lt;/strong&gt; How does it actually work?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2016-09-24T13:47:56.293" Title="How does p command work in vim?" Tags="|normal-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9657" PostTypeId="2" ParentId="9656" CreationDate="2016-09-24T13:47:56.293" Score="15" Body="&lt;p&gt;&lt;code&gt;p&lt;/code&gt; and &lt;code&gt;P&lt;/code&gt; always work the same way:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; puts text &lt;em&gt;after&lt;/em&gt; the cursor,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt; puts text &lt;em&gt;before&lt;/em&gt; the cursor.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But what you put with &lt;code&gt;p&lt;/code&gt; and &lt;code&gt;P&lt;/code&gt; can be &quot;character-wise&quot;, &quot;line-wise&quot;, or &quot;block-wise&quot;. This means that the end result varies not because of &lt;code&gt;p&lt;/code&gt; and &lt;code&gt;P&lt;/code&gt; but because of the nature of what you put.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Character-wise text&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The text you put is &quot;character-wise&quot; if it was yanked with a character-wise motion or from character-wise visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples: &lt;code&gt;yiw&lt;/code&gt;, &lt;code&gt;y}&lt;/code&gt;, &lt;code&gt;vf)y&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you put &lt;em&gt;character-wise&lt;/em&gt; text with &lt;code&gt;p&lt;/code&gt;, the text is put &lt;em&gt;inline&lt;/em&gt;, after the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar baz              source line&#xA;   ^^^^                  you yanked &quot; bar&quot;&#xA;&#xA;lorem ipsum dolor        destination line&#xA;    ^                    the cursor is on the &quot;m&quot; of &quot;lorem&quot;&#xA;&#xA;lorem bar ipsum dolor    result&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;P&lt;/code&gt;, the text is put &lt;em&gt;inline&lt;/em&gt;, before the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lore barm ipsum dolor    result&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Line-wise text&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The text you put is &quot;line-wise&quot; if it was yanked with a line-wise motion or from line-wise visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples: &lt;code&gt;yip&lt;/code&gt;, &lt;code&gt;y3j&lt;/code&gt;, &lt;code&gt;V25jy&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you put &lt;em&gt;line-wise&lt;/em&gt; text with &lt;code&gt;p&lt;/code&gt;, the text is put &lt;em&gt;below&lt;/em&gt; the current line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar baz              source line&#xA;^^^^^^^^^^^              you yanked the whole line, including the newline character&#xA;&#xA;lorem ipsum dolor        destination line&#xA;    ^                    the cursor is on the &quot;m&quot; of &quot;lorem&quot;&#xA;&#xA;lorem ipsum dolor        result&#xA;foo bar baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;P&lt;/code&gt;, the text is put &lt;em&gt;above&lt;/em&gt; the current line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar baz              result&#xA;lorem ipsum dolor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Block-wise text&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The text you put is &quot;block-wise&quot; if it was yanked from block-wise visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;code&gt;&amp;lt;C-v&amp;gt;iw6jy&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you put &lt;em&gt;block-wise&lt;/em&gt; text with &lt;code&gt;p&lt;/code&gt;, the text is put &lt;em&gt;inline&lt;/em&gt;, after the cursor, and overwrites any character in his way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo 000 baz              source text&#xA;foo 000 bar              the yanked text is the column of zeroes&#xA;baz 000 bar&#xA;&#xA;lorem ipsum dolor        destination text&#xA;lorem ipsum dolor        the cursor is on the &quot;m&quot; of the first &quot;lorem&quot; &#xA;lorem ipsum dolor&#xA;&#xA;lorem000 ipsum dolor     result&#xA;lorem000 ipsum dolor&#xA;lorem000 ipsum dolor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;P&lt;/code&gt;, the text is put &lt;em&gt;inline&lt;/em&gt;, before the cursor, and overwrites any character in his way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lore000m ipsum dolor     result&#xA;lore000m ipsum dolor&#xA;lore000m ipsum dolor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-09-24T13:47:56.293" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9658" PostTypeId="2" ParentId="9653" CreationDate="2016-09-24T14:30:57.457" Score="6" Body="&lt;p&gt;(just for completness) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use this, adapted from Vim's help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; restore cursor position, if known, and unfold the area&#xA;autocmd BufReadPost *&#xA;            \ if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) |&#xA;            \   silent! exe 'normal! g`&quot;zzza' |&#xA;            \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.. so that everytime I open a file, the cursor will be placed at its last known position, the screen is centered, and the area is unfolded.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-09-24T14:30:57.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9659" PostTypeId="1" AcceptedAnswerId="9660" CreationDate="2016-09-24T16:23:46.080" Score="0" ViewCount="41" Body="&lt;p&gt;The only useful command I found was &lt;code&gt;:help index&lt;/code&gt; then navigate to a mode I  interested in. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it explains the whole command list. Is there a function or something else which could give me a simple answer &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt; for a given binding? Or the best I can do is to search through the whole section?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2016-09-24T17:07:11.630" Title="How to find out if the binding is used for a given mode?" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9660" PostTypeId="2" ParentId="9659" CreationDate="2016-09-24T17:07:11.630" Score="1" Body="&lt;p&gt;The commands for &lt;em&gt;creating&lt;/em&gt; a mapping, happen to also be the same commands for &lt;em&gt;listing&lt;/em&gt; a mapping. From &lt;code&gt;:help map-commands&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.1 MAP COMMANDS                    *:map-commands*&#xA;&#xA;There are commands to enter new mappings, remove mappings and list mappings.&#xA;See |map-overview| for the various forms of &quot;map&quot; and their relationships with&#xA;modes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you call it with both a left hand side, and a right hand side, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap i iHello&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &lt;em&gt;creates&lt;/em&gt; a new mapping. Now, if you call it with &lt;em&gt;just&lt;/em&gt; the left hand side, this will list all mappings that start with that left hand side. For example, if you ran&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will list &lt;em&gt;every&lt;/em&gt; normal mode mapping that starts with an &lt;code&gt;i&lt;/code&gt;. Relevant help section, &lt;code&gt;:h map_l&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map    {lhs}           |mapmode-nvo|       *:map_l*&#xA;:nm[ap] {lhs}           |mapmode-n|     *:nmap_l*&#xA;:vm[ap] {lhs}           |mapmode-v|     *:vmap_l*&#xA;:xm[ap] {lhs}           |mapmode-x|     *:xmap_l*&#xA;:sm[ap] {lhs}           |mapmode-s|     *:smap_l*&#xA;:om[ap] {lhs}           |mapmode-o|     *:omap_l*&#xA;:map!   {lhs}           |mapmode-ic|        *:map_l!*&#xA;:im[ap] {lhs}           |mapmode-i|     *:imap_l*&#xA;:lm[ap] {lhs}           |mapmode-l|     *:lmap_l*&#xA;:cm[ap] {lhs}           |mapmode-c|     *:cmap_l*&#xA;            List the key mappings for the key sequences starting&#xA;            with {lhs} in the modes where the map command applies.&#xA;            {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The other way to list mappings is if you do not provide a left hand &lt;em&gt;or&lt;/em&gt; a right hand side. For example, if you just type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this will list &lt;em&gt;every&lt;/em&gt; mapping that applies to normal mode. The relevant help section (Not sure how to get here. Just type &lt;code&gt;:h cmapc&lt;/code&gt; then scroll down a little):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map                |mapmode-nvo|&#xA;:nm[ap]             |mapmode-n|&#xA;:vm[ap]             |mapmode-v|&#xA;:xm[ap]             |mapmode-x|&#xA;:sm[ap]             |mapmode-s|&#xA;:om[ap]             |mapmode-o|&#xA;:map!               |mapmode-ic|&#xA;:im[ap]             |mapmode-i|&#xA;:lm[ap]             |mapmode-l|&#xA;:cm[ap]             |mapmode-c|&#xA;            List all key mappings for the modes where the map&#xA;            command applies.  Note that &quot;:map&quot; and &quot;:map!&quot; are&#xA;            used most often, because they include the other modes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-09-24T17:07:11.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9661" PostTypeId="1" CreationDate="2016-09-24T17:48:44.300" Score="8" ViewCount="126" Body="&lt;p&gt;I want to count the words in my buffers, but for TeX files, for instance, a lot of words (e.g., commands) shouldn't be counted. I'm aware that there are scripts that do this specifically for LaTeX, but I find them pretty inconvenient and they don't even work that well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, whoever wrote the syntax files for TeX already did a great job at tagging which words should be counted: the words for which Spell is enabled. Besides, using a method like this would be useful for every filetype, potentially ignoring comments and so on. And if you want to ignore more words you could just change it in your &lt;code&gt;after/syntax&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't figure out a way to do it, though. So, any ideas on how I could count only the words for which Spell is enabled?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think &lt;a href=&quot;https://vi.stackexchange.com/a/3742/7642&quot;&gt;this method&lt;/a&gt; (&lt;code&gt;:%s/\&amp;lt;\w\{-}\&amp;gt;//gn&lt;/code&gt;) of counting the words looks like a good start, but we'd have to skip some words depending on their highlighting group.&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="343" LastEditDate="2017-12-06T11:05:46.050" LastActivityDate="2017-12-06T11:05:46.050" Title="Count only words for which Spell is enabled?" Tags="|syntax-highlighting|filetype-tex|spell-checking|counting|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9662" PostTypeId="1" CreationDate="2016-09-24T18:25:44.273" Score="1" ViewCount="182" Body="&lt;p&gt;I do quite often use this mapping:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType cpp nnoremap &amp;lt;buffer&amp;gt; == :%!clang-format -style=file&amp;lt;cr&amp;gt;2g;zz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It reindents the whole file and returns the cursor to the last edit position.&lt;/p&gt;&#xA;&lt;p&gt;Problem is, if I have folds, they get closed. All of them.&lt;/p&gt;&#xA;&lt;p&gt;How do I keep each fold's state after this command? &lt;a href=&quot;https://vi.stackexchange.com/questions/9494/how-to-save-a-view-with-folds-into-the-file&quot;&gt;Some suggest&lt;/a&gt; saving a session, but this seems inefficient, and in my case I neither close the file nor leave vim.&lt;/p&gt;&#xA;" OwnerUserId="3280" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-09-24T20:22:30.647" Title="How do I keep folds when formatting (reindenting) the whole file?" Tags="|key-bindings|vimscript|indentation|external-command|folding|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9663" PostTypeId="2" ParentId="9662" CreationDate="2016-09-24T18:48:26.543" Score="1" Body="&lt;p&gt;EDIT: Here's something that might solve the issue.&#xA;It's really a template of a possible solution (not actually tested).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReindentMyCpp()&#xA;  mkview!&#xA;  execute 'normal! :nnoremap == :%!clang-format -style=file2g$' . &quot;\r&quot;&#xA;  execute 'normal zz'&#xA;  loadview&#xA;endfun&#xA;&#xA;autocmd FileType cpp ReindentMyCpp()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BEFORE EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some code that keeps the folds when you leave a buffer and restores it when you come back.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; save folds states in a file 'view'&#xA;set viewoptions=folds,cursor&#xA;autocmd BufWinLeave *.* mkview!&#xA;autocmd BufWinEnter *.* silent loadview &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works well, and might somehow be adapted to your situation. It works of course if you have some &lt;code&gt;autocmd&lt;/code&gt; that invokes &lt;code&gt;mkview&lt;/code&gt; to save the fold's state before your own &lt;code&gt;autocmd&lt;/code&gt; acts, and another that restores it afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking you might want to define a function that does all three in a row (save the &lt;em&gt;view&lt;/em&gt; in this way, do what your original &lt;code&gt;autocmd&lt;/code&gt; did, then restore the &lt;em&gt;view&lt;/em&gt; in this way), then have your &lt;code&gt;autocmd&lt;/code&gt; invoke that function (as to save folds, do the indentation stuff, restore folds). I don't know if this will work for your problem, but it's probably worth a shot.&lt;/p&gt;&#xA;" OwnerUserId="2058" LastEditorUserId="2058" LastEditDate="2016-09-24T19:04:29.287" LastActivityDate="2016-09-24T19:04:29.287" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9664" PostTypeId="2" ParentId="9662" CreationDate="2016-09-24T18:57:10.767" Score="2" Body="&lt;p&gt;Here is how I did it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType cpp nnoremap &amp;lt;buffer&amp;gt; == :mkview&amp;lt;cr&amp;gt;:%!clang-format -style=file&amp;lt;cr&amp;gt;:loadview&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3280" LastActivityDate="2016-09-24T18:57:10.767" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9667" PostTypeId="1" AcceptedAnswerId="9671" CreationDate="2016-09-25T05:56:19.413" Score="1" ViewCount="954" Body="&lt;p&gt;I have a line which contains the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'some text in the quotation mark' some other text goes here&#xA;             ^&#xA;       cursor is here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the fastest way to replace the text within a quotation mark with something else? I mean I want to type something completely different there. Is there a shortcut to remove all text within the quotation and enter to insert mode?&lt;/p&gt;&#xA;" OwnerUserId="9417" LastActivityDate="2016-09-25T14:36:04.327" Title="Editing text in a quotation mark" Tags="|normal-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9669" PostTypeId="1" AcceptedAnswerId="9670" CreationDate="2016-09-25T09:28:11.860" Score="9" ViewCount="2120" Body="&lt;p&gt;If I type:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:echoerr &quot;test error&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I simply get the message printed (with red background):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;test error&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, inside a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Printerror()&#xA;  echoerr &quot;test error&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get additional (and in this particular case) unwanted extra lines:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function Printerror:&#xA;line    1:&#xA;test error&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How can I supress the additional lines produced in a function?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2016-09-25T14:18:04.917" LastActivityDate="2016-09-25T14:18:04.917" Title="Print an error message without &quot;Error detected while processing function&quot;" Tags="|functions|error|errorformat|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9670" PostTypeId="2" ParentId="9669" CreationDate="2016-09-25T10:13:46.073" Score="7" Body="&lt;p&gt;The solution is described in the manual:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you just want a highlighted message use &lt;code&gt;:echohl&lt;/code&gt;.&#xA;  And to get a beep: &lt;code&gt;:exe &quot;normal \&amp;lt;Esc&amp;gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PrintError(msg) abort&#xA;    execute 'normal! \&amp;lt;Esc&amp;gt;'&#xA;    echohl ErrorMsg&#xA;    echomsg a:msg&#xA;    echohl None&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2313" LastActivityDate="2016-09-25T10:13:46.073" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9671" PostTypeId="2" ParentId="9667" CreationDate="2016-09-25T12:00:09.357" Score="6" Body="&lt;p&gt;You need to use &lt;code&gt;c&lt;/code&gt; operator, followed by the &lt;code&gt;i'&lt;/code&gt; text-object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ci'foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will turn:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'some text in the quotation mark' some other text goes here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'foo' some other text goes here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h navigation&lt;/code&gt; will blow your mind.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-09-25T12:00:09.357" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9672" PostTypeId="1" CreationDate="2016-09-25T12:27:12.170" Score="6" ViewCount="7328" Body="&lt;p&gt;I want to do the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I insert an HTML tag (which is a sequence of text that starts with &lt;code&gt;&amp;lt;tagname tag_attributes&lt;/code&gt; and ends with &lt;code&gt;&amp;gt;&lt;/code&gt;), as soon as I press &lt;kbd&gt;&gt;&lt;/kbd&gt; to insert the &lt;code&gt;&amp;gt;&lt;/code&gt; character, I want:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A text &lt;code&gt;&amp;lt;/tagname&amp;gt;&lt;/code&gt; to be inserted two lines under the current line.&lt;/li&gt;&#xA;&lt;li&gt;Put the cursor on the line which is between the opening and closing tags.&lt;/li&gt;&#xA;&lt;li&gt;Insert a tab.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, when I insert a text such as &lt;code&gt;&amp;lt;div possibly_attributes&lt;/code&gt; and insert &lt;code&gt;&amp;gt;&lt;/code&gt;, I want the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div possibly_attributes&amp;gt;&#xA;    [cursor here]&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="4840" LastEditorUserId="1841" LastEditDate="2016-09-26T08:21:34.707" LastActivityDate="2017-02-23T06:00:01.527" Title="How to generate closing tags for HTML?" Tags="|vimscript|filetype-html|text-generation|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9673" PostTypeId="2" ParentId="9672" CreationDate="2016-09-25T13:24:17.553" Score="13" Body="&lt;p&gt;Here is a simple &lt;em&gt;ad-hoc&lt;/em&gt; solution to put in &lt;code&gt;~/.vim/after/ftplugin/html.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;buffer&amp;gt; &amp;gt; &amp;gt;&amp;lt;/&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&amp;lt;C-y&amp;gt;&amp;lt;C-o&amp;gt;%&amp;lt;CR&amp;gt;&amp;lt;C-o&amp;gt;O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Breakdown:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;lt;/                insert '&amp;gt;&amp;lt;/'&#xA;&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&amp;lt;C-y&amp;gt;    use the built-in omni-completion to finish the closing tag&#xA;&amp;lt;C-o&amp;gt;%             move the cursor to the beginning of your closing tag&#xA;&amp;lt;CR&amp;gt;               insert a newline to push the closing tag on its own line&#xA;&amp;lt;C-o&amp;gt;O             open a new line above the current line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is how it looks like in practice:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ys9V0.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ys9V0.gif&quot; alt=&quot;imap&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you should definitely take a look at plugins like &lt;a href=&quot;https://github.com/rstacruz/sparkup&quot; rel=&quot;noreferrer&quot;&gt;Sparkup&lt;/a&gt;/&lt;a href=&quot;https://github.com/mattn/emmet-vim&quot; rel=&quot;noreferrer&quot;&gt;Emmet&lt;/a&gt;, that let you use a concise CSS-like notation to produce proper HTML, or &lt;a href=&quot;https://github.com/garbas/vim-snipmate&quot; rel=&quot;noreferrer&quot;&gt;Snipmate&lt;/a&gt;/&lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;noreferrer&quot;&gt;Ultisnips&lt;/a&gt; that let you create and expand very powerful snippets for any language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--- edit ---&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using Vim productively will be &lt;em&gt;very hard&lt;/em&gt; without the following lines in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set backspace=indent,eol,start&#xA;set hidden&#xA;filetype plugin indent on&#xA;syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The solution above is guaranteed to work with that minimal setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--- endedit ---&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-09-25T19:23:23.740" LastActivityDate="2016-09-25T19:23:23.740" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="9674" PostTypeId="1" CreationDate="2016-09-25T16:53:55.207" Score="4" ViewCount="11284" Body="&lt;p&gt;I'd like to bind some combinations to &lt;code&gt;Alt-_some-key_&lt;/code&gt;, but not quite sure about how to do it correctly. Here is one of my current setup (example):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;ESC&amp;gt;c &quot;+y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because my terminal accept &lt;code&gt;Alt-c&lt;/code&gt; as &lt;code&gt;&amp;lt;ESC&amp;gt;c&lt;/code&gt;. But I suppose it's not portable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to specify some alias (like &lt;code&gt;Alt&lt;/code&gt;) and set its meaning to &lt;code&gt;ESC&lt;/code&gt; so I could change it in case I moved to another terminal?&lt;/p&gt;&#xA;" OwnerUserId="9417" LastEditorUserId="1841" LastEditDate="2016-09-26T08:12:12.413" LastActivityDate="2016-09-26T08:12:12.413" Title="Mapping with the meta key" Tags="|key-bindings|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9675" PostTypeId="1" AcceptedAnswerId="9708" CreationDate="2016-09-25T18:12:58.647" Score="0" ViewCount="1093" Body="&lt;p&gt;I had to notice that this doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let test=128&#xA;&#xA;highlight Normal ctermbg=test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use variables in colorschemes?&lt;/p&gt;&#xA;" OwnerDisplayName="user9334" LastActivityDate="2016-09-27T15:35:28.610" Title="Use variables in colorscheme" Tags="|colorscheme|variables|" AnswerCount="1" CommentCount="2" ClosedDate="2016-09-28T01:06:45.170" ContentLicense="CC BY-SA 3.0" />
  <row Id="9676" PostTypeId="1" CreationDate="2016-09-25T19:11:21.183" Score="2" ViewCount="259" Body="&lt;p&gt;I would like to have a &lt;strong&gt;Paste + Override&lt;/strong&gt; shortcut, which should basically have the behaviour of going into &lt;strong&gt;Replace&lt;/strong&gt;-mode, typing everything currently in the clipboard, exiting &lt;strong&gt;Replace&lt;/strong&gt;-mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I approach this?&lt;/p&gt;&#xA;" OwnerDisplayName="user9334" LastActivityDate="2016-12-24T22:45:43.907" Title="Paste + Override Shortcut" Tags="|replace|key-bindings|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9677" PostTypeId="2" ParentId="9676" CreationDate="2016-09-25T19:58:02.733" Score="1" Body="&lt;p&gt;You could start with a maping, say, &lt;code&gt;RR&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; RR 'R' . substitute(@*, '&amp;lt;', '&amp;lt;lt&amp;gt;', 'g') . '&amp;lt;esc&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Handles basic scenarios well enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if it will behave as you would expect for complex stuff, e.g. block selection.  But for basics -- will work.&lt;/p&gt;&#xA;" OwnerUserId="9204" LastActivityDate="2016-09-25T19:58:02.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9678" PostTypeId="2" ParentId="9674" CreationDate="2016-09-26T06:57:03.580" Score="2" Body="&lt;p&gt;You could define a global variable containing the key that might change, and then use an &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/30.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;execute normal!&lt;/code&gt;&lt;/a&gt; construct to setup your mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your example, that could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:MyAltKey = &quot;&amp;lt;Esc&amp;gt;&quot;&#xA;execute 'normal! :vnoremap ' . g:MyAltKey . 'c &quot;+y' . &quot;\r&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, you might consider using the &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;localleader&amp;gt;&lt;/code&gt; constructs which serve a purpose similar to what you want (see &lt;code&gt;:help leader&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="2058" LastActivityDate="2016-09-26T06:57:03.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9679" PostTypeId="2" ParentId="9674" CreationDate="2016-09-26T08:11:02.490" Score="9" Body="&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/intro.html#keycodes&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h keycodes&lt;/code&gt;&lt;/a&gt; and more precisely &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/intro.html#meta&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h meta&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;&amp;lt;M-...&amp;gt;&lt;/code&gt;     alt-key or meta-key&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So on most system the mapping you're looking for is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;M-c&amp;gt;  &quot;+y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the behavior of &lt;code&gt;&amp;lt;M-...&amp;gt;&lt;/code&gt; may be dependent of your system and your terminal emulator if you use one.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-09-26T08:11:02.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9680" PostTypeId="2" ParentId="9672" CreationDate="2016-09-26T08:56:14.487" Score="2" Body="&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt; This is not directly what you want but I think it can be worth it to mention it here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are ready to use an additional plugin, you could try to use a &lt;a href=&quot;https://vi.stackexchange.com/q/7466/1841&quot;&gt;snippet engine&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, Utlisnips comes with a lot of &lt;a href=&quot;https://github.com/honza/vim-snippets/blob/master/UltiSnips/html.snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;html snippets&lt;/a&gt;. For example, you can simply write &lt;code&gt;div&lt;/code&gt;, press the key configured to trigger a snippet extension and you'll get the structure you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some (not all) of the snippets available. Note that you can easily add the ones you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- DocType XHTML 1.1&#xA;- HTML - 5.0 (doctype)&#xA;- IE Conditional Comment: Internet Explorer&#xA;- IE Conditional Comment: NOT Internet Explorer&#xA;- Input with Label&#xA;- Select Box&#xA;- XHTML   &amp;lt;textarea&amp;gt;&#xA;- XHTML &amp;lt;a mailto: &amp;gt;&#xA;- XHTML &amp;lt;base&amp;gt;&#xA;- &amp;lt;body&amp;gt;&#xA;- &amp;lt;div&amp;gt;&#xA;- &amp;lt;div&amp;gt; with class&#xA;- &amp;lt;div&amp;gt; with ID &amp;amp; class&#xA;- XHTML &amp;lt;form&amp;gt;&#xA;- XHTML &amp;lt;h1&amp;gt;&#xA;- XHTML &amp;lt;link&amp;gt;&#xA;- XHTML &amp;lt;meta&amp;gt;&#xA;- XHTML &amp;lt;script src...&amp;gt;&#xA;- XHTML &amp;lt;script&amp;gt;&#xA;- &amp;lt;span&amp;gt;&#xA;- &amp;lt;span&amp;gt; with class&#xA;- &amp;lt;span&amp;gt; with ID &amp;amp; class&#xA;- XHTML &amp;lt;style&amp;gt;&#xA;- XHTML &amp;lt;table&amp;gt;&#xA;- Link&#xA;- paragraph&#xA;- list item&#xA;- unordered list&#xA;- table cell&#xA;- table header&#xA;- table row&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If a snippet plugin is overkill but you are still okay to use a plugin you can also try the &lt;a href=&quot;http://mattn.github.io/emmet-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;emmet plugin&lt;/a&gt; which provides a syntax to shortcut your HTML/CSS and expand it easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see how it works &lt;a href=&quot;https://asciinema.org/api/asciicasts/4568?&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-09-26T08:56:14.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9681" PostTypeId="1" AcceptedAnswerId="9682" CreationDate="2016-09-26T09:25:49.483" Score="0" ViewCount="7034" Body="&lt;p&gt;Suppose I've got the following sentence:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This |is a sentence for testing purposes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want this sentence to be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This purposes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In fact I want to delete 5 words. Of course, I could do it just as &lt;code&gt;d5w&lt;/code&gt; but this is so inconvenient and painful. I have to count the words first and then execute the appropriate combination.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried it the other way. I pushed &lt;code&gt;d&lt;/code&gt; and then I tried to push &lt;code&gt;w&lt;/code&gt; 5 times. But it started deleting lines (and that's sensible, because &lt;code&gt;dd&lt;/code&gt; deletes a line). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to perform word deletion like we did in general editors (we keep pressing &lt;code&gt;Ctrl&lt;/code&gt; and then press &lt;code&gt;Del&lt;/code&gt; 5 times) but in Vim. I suppose this quite common operation and there must be a &quot;fast&quot; solution for it.&lt;/p&gt;&#xA;" OwnerUserId="9237" LastEditorUserId="1841" LastEditDate="2016-09-26T09:39:04.357" LastActivityDate="2016-09-26T09:48:38.063" Title="Deleting several words" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9682" PostTypeId="2" ParentId="9681" CreationDate="2016-09-26T09:30:57.713" Score="8" Body="&lt;p&gt;Meet your friend the dot command! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html#.&quot;&gt;&lt;code&gt;:h .&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Press &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; (or &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;) to delete a word and repeat the command with &lt;kbd&gt;.&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the doc:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;.          Repeat last change, with count replaced with [count].&#xA;           Also repeat a yank command, when the 'y' flag is&#xA;           included in 'cpoptions'.  Does not repeat a&#xA;           command-line command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that the dot command works amazingly with the undo workflow of Vim. You can repeat the last change as many time as you want with &lt;kbd&gt;.&lt;/kbd&gt; and if you realized you used it too many time simply use &lt;kbd&gt;u&lt;/kbd&gt; to undo the change. Want to finally redo the change? Use &lt;kbd&gt;Ctrl+r&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also as VanLaser noted in his comment there is other ways to delete several words. In addition to his &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; idea note that you can also do that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;d&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Begin a search &lt;kbd&gt;/&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Type the pattern matching the end of the deletion (here &lt;code&gt;purpose&lt;/code&gt; for example)&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-09-26T09:48:38.063" LastActivityDate="2016-09-26T09:48:38.063" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9683" PostTypeId="1" CreationDate="2016-09-26T13:41:05.457" Score="2" ViewCount="774" Body="&lt;p&gt;First, I'm &lt;strong&gt;not&lt;/strong&gt; asking how to include includes in a syntastic check.  I already have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_c_check_header = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I run &lt;code&gt;:SyntasticCheck&lt;/code&gt;, or save, a &lt;code&gt;.cpp&lt;/code&gt; file, it also checks relevant includes if they are in &lt;code&gt;syntastic_c_include_dirs&lt;/code&gt;.  It even opens an error location_list window in the buffer containing the &lt;code&gt;.hpp&lt;/code&gt; if I then jump to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's great, but what it won't do is check the header directly, whether I save it or use &lt;code&gt;:SyntasticCheck&lt;/code&gt; in the &lt;code&gt;.hpp&lt;/code&gt; buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means when working on template classes made only of an &lt;code&gt;.hpp&lt;/code&gt;, I have to load some file that uses it and run the check from there; sometimes the easiest way to do this is to just create a dummy &lt;code&gt;.cpp&lt;/code&gt; file with one line in it (&lt;code&gt;#include &quot;foo.hpp&quot;&lt;/code&gt;).  But this is still stupid and annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is anyone aware of a way to get Syntastic to check a C++ header directly, without having to run a check on file which uses the header?&lt;/p&gt;&#xA;" OwnerUserId="4913" LastActivityDate="2016-11-26T11:37:31.743" Title="SyntasticCheck C++ header" Tags="|plugin-syntastic|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9684" PostTypeId="1" AcceptedAnswerId="9685" CreationDate="2016-09-26T15:23:21.437" Score="0" ViewCount="308" Body="&lt;p&gt;Say in Gvim I have a line in the current buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.bashrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I access this file (&lt;code&gt;~/.bashrc&lt;/code&gt;) in the same, or a new, or a vertical-split window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;gx&lt;/code&gt;, which opens the file with &lt;code&gt;xdg-open&lt;/code&gt;. It opens the file in a new Gvim session / instance, rather than in the current one.&lt;/p&gt;&#xA;" OwnerUserId="9018" LastActivityDate="2016-11-03T17:02:28.563" Title="Gvim: gx to {the same, a new, a vertical-split} window" Tags="|gvim|netrw|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9685" PostTypeId="2" ParentId="9684" CreationDate="2016-09-26T15:41:12.377" Score="2" Body="&lt;p&gt;The whole point of &lt;code&gt;gx&lt;/code&gt; is to open the file under the cursor &lt;em&gt;in an external program.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;gf&lt;/code&gt; to open the file in a new buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;&amp;lt;C-w&amp;gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; to open it in a new horizontal window then use &lt;code&gt;&amp;lt;C-w&amp;gt;L&lt;/code&gt; to turn that window into a vertical one.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-09-26T16:04:17.980" LastActivityDate="2016-09-26T16:04:17.980" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9686" PostTypeId="1" CreationDate="2016-09-26T20:56:43.383" Score="3" ViewCount="2068" Body="&lt;p&gt;Given this small vimgrep wrapper, how would I forward multiple arguments to &lt;code&gt;vimgrep&lt;/code&gt;, so they are interpreted as a single argument to vimgrep?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 FIND call SimpleGrep(&amp;lt;f-args&amp;gt;)&#xA;nnoremap &amp;lt;M-f&amp;gt; :FIND&amp;lt;SPACE&amp;gt;&#xA;&#xA;function! SimpleGrep(exp)&#xA;    &quot; Depends on: https://github.com/dbakker/vim-projectroot&#xA;    let l:base = ProjectRootGuess()&#xA;    &quot; Find files with the current extension in project path.&#xA;    let l:root = l:base . &quot;/**/*.&quot; . expand('%:e')&#xA;    execute 'vimgrep' a:exp l:root&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently &lt;code&gt;FIND text&lt;/code&gt; works, but &lt;code&gt;FIND &quot;some text&quot;&lt;/code&gt; only works when quoted.&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2016-09-26T22:23:45.503" Title="How to forward multiple arguments from a command in a function?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9687" PostTypeId="2" ParentId="9686" CreationDate="2016-09-26T21:51:59.197" Score="6" Body="&lt;h3&gt;The simple case&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/dbakker/vim-projectroot&quot; rel=&quot;noreferrer&quot;&gt;Projectroot&lt;/a&gt; provides the &lt;code&gt;:ProjectRootExe&lt;/code&gt; command which can simplify this task greatly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ FIND ProjectRootExe execute &quot;vimgrep /&amp;lt;args&amp;gt;/ **/*.&quot; . expand('%:e')&#xA;nnoremap &amp;lt;M-f&amp;gt; :FIND&amp;lt;SPACE&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;args&amp;gt;&lt;/code&gt; expands to the arguments supplied to your &lt;code&gt;:FIND&lt;/code&gt; command. While &lt;code&gt;-nargs=+&lt;/code&gt; means this command can take at least 1 argument. Since you do not want to quote the search pattern we will add &lt;code&gt;/&lt;/code&gt;'s as suggested by &lt;code&gt;:h :vimgrep&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Using &lt;code&gt;&amp;lt;q-args&amp;gt;&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Since you wanted to use a function to do some extra logic, you can use &lt;code&gt;&amp;lt;q-args&amp;gt;&lt;/code&gt; to slurp up all the arguments into a &quot;quoted string&quot;. e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:simple_grep(pattern)&#xA;  let filetypes = {}&#xA;  let filetypes['c'] = '{c,cpp,h}'&#xA;  execute &quot;ProjectRootExe vimgrep /&quot; . a:pattern . &quot;/ *.&quot; . get(filetypes, &amp;amp;filetype, expand('%:e'))&#xA;endfunction&#xA;&#xA;command! -nargs=+ Find call &amp;lt;SID&amp;gt;simple_grep(&amp;lt;q-args&amp;gt;)&#xA;nnoremap &amp;lt;M-f&amp;gt; :FIND&amp;lt;SPACE&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have added some logic to search multiple extensions when using the &lt;code&gt;'filetype'&lt;/code&gt; is set to &lt;code&gt;c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Alternatives&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you use git and &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;noreferrer&quot;&gt;fugitive.vim&lt;/a&gt; you may want to look into using &lt;code&gt;:Ggrep&lt;/code&gt; as it much faster than &lt;code&gt;:vimgrep&lt;/code&gt; and automatically searching from the root of a git project by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also want to look into using a tool like &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;noreferrer&quot;&gt;Ag the silver searcher&lt;/a&gt; which searches recursively by default an can be supplied a file type, e.g. &lt;code&gt;ag --js 'pattern'&lt;/code&gt;. Note: &lt;code&gt;ag&lt;/code&gt; does not search from project root. Settings from &lt;code&gt;man ag&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set grepprg=ag\ --vimgrep\ $*&#xA;set grepformat=%f:%l:%c:%m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use &lt;code&gt;ag&lt;/code&gt; powered grep: &lt;code&gt;:grep 'pattern'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;For more help see&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :command-nargs&#xA;:h &amp;lt;args&amp;gt;&#xA;:h :vimgrep&#xA;:h :execute&#xA;:h expand()&#xA;:h &amp;lt;q-args&amp;gt;&#xA;:h get()&#xA;:h projectroot-:ProjectRootExe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I do not use projectroot nor have I tested any of the code above. Use as is.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2016-09-26T22:23:45.503" LastActivityDate="2016-09-26T22:23:45.503" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9688" PostTypeId="1" AcceptedAnswerId="9689" CreationDate="2016-09-26T22:11:39.540" Score="0" ViewCount="951" Body="&lt;p&gt;Say I have a function that takes multiple arguments, how would I pass them as a single string argument to another function?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function test(...)&#xA;    &quot; vimgrep is just an example&#xA;    vimgrep a:000 /some/path/**/*.txt&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When bound to a key, eg&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ FIND call SimpleGrep(&amp;lt;args&amp;gt;)&#xA;nnoremap &amp;lt;M-f&amp;gt; :FIND&amp;lt;SPACE&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the error that the input is an unknown variable, using &lt;code&gt;string(a:000)&lt;/code&gt; doesn't fix things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would &lt;code&gt;a:000&lt;/code&gt; be converted into a string so &lt;code&gt;FIND a b c&lt;/code&gt; could be evaluated as if &lt;code&gt;FIND &quot;a b c&quot;&lt;/code&gt; had been written?&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2016-09-26T22:38:55.620" Title="How to get varargs as a string?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9689" PostTypeId="2" ParentId="9688" CreationDate="2016-09-26T22:38:55.620" Score="2" Body="&lt;p&gt;Join the arguments together with &lt;code&gt;join()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function test(...)&#xA;    &quot; vimgrep is just an example&#xA;    execute 'vimgrep /'.join(a:000).'/ /some/path/**/*.txt'&#xA;endfunction&#xA;command! -nargs=+ FIND call SimpleGrep(&amp;lt;f-args&amp;gt;)&#xA;nnoremap &amp;lt;M-f&amp;gt; :FIND&amp;lt;SPACE&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;join()&lt;/code&gt; will join together with a single space and &lt;code&gt;&amp;lt;f-args&amp;gt;&lt;/code&gt; will ignore extra spaces, so &lt;code&gt;:FIND a b c&lt;/code&gt; is equivalent to &lt;code&gt;:FIND a     b    c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h join()&#xA;:h &amp;lt;f-args&amp;gt;&#xA;:h a:000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-09-26T22:38:55.620" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9690" PostTypeId="1" CreationDate="2016-09-27T00:21:07.913" Score="0" ViewCount="237" Body="&lt;p&gt;In VI I need to replace a pattern that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;seq- followed by exactly 24 chars (can be 0-9, a-z, A-Z only) followed by / followed by some number of (0-9, a-z, A-Z). So an example string would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;seq-BzFk78qrJBkbnv1KkxppsfG4/92191_A_B&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to replace the above string with a fixed string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;seq-ID/NUM_ID&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I do this in Vi or Vim? I tried a few things like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/seq-[a-zA-Z0-9]{24}\/[a-zA-Z0-9]{+}/seq-ID\/NUM_ID&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="9442" LastEditorUserId="2920" LastEditDate="2016-09-27T00:59:48.140" LastActivityDate="2016-09-27T01:11:46.510" Title="Globally replace a particular pattern with another string" Tags="|regular-expression|search|replace|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9691" PostTypeId="2" ParentId="9690" CreationDate="2016-09-27T01:11:46.510" Score="6" Body="&lt;p&gt;There are many problems with your regex.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;{24}&lt;/code&gt; will not match 24 of the previous atom, it will match the text &lt;code&gt;{24}&lt;/code&gt;. I doubt this is what you want. You need a backslash e.g. &lt;code&gt;\{24}&lt;/code&gt;. Additionally you could enable &quot;Very magic&quot;, e.g. &lt;code&gt;\v{24}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In your example, the text after the slash has underscores in it, e.g. &lt;code&gt;92191_A_B&lt;/code&gt;. Change &lt;code&gt;[a-zA-Z-0-9]&lt;/code&gt; to &lt;code&gt;[a-zA-Z-0-9_]&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;One or more&quot; is &lt;code&gt;\+&lt;/code&gt;, &lt;em&gt;not&lt;/em&gt; &lt;code&gt;{+}&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There are also some style problems.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If you are going to search for something containing slashes, you should use a different separator, e.g. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s;seq-[a-zA-Z0-9]{24}/[a-zA-Z0-9]{+};seq-ID/NUM_ID&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more readability.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't use &lt;code&gt;[a-zA-Z0-9_]&lt;/code&gt; when you could just use &lt;code&gt;\w&lt;/code&gt;. I would also use this in place of &lt;code&gt;[a-zA-Z0-9]&lt;/code&gt; unless it's possible that underscores will be in there, and you want to avoid matching this. In this case, &lt;code&gt;\c[a-z0-9]&lt;/code&gt; is also shorter&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Putting this all together, I would recommend going with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s;\vseq-\w{24}/\w+;seq-ID/NUM_ID&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would also highly recommend reading through &lt;a href=&quot;http://vimregex.com/&quot;&gt;vim regex&lt;/a&gt;. One of the best quick intros to vim's regex engine I have ever seen. I have it bookmarked in my browser at all times for quick reference.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-09-27T01:11:46.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9692" PostTypeId="1" CreationDate="2016-09-27T05:04:00.223" Score="9" ViewCount="1255" Body="&lt;p&gt;In an unusual state, I want to ensure that a user sees a warning message upon startup, and presses a key to continue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could use &lt;code&gt;sleep &amp;lt;seconds&amp;gt;&lt;/code&gt;, but I'm sure that &lt;code&gt;vim&lt;/code&gt; can do this. Go vim!&lt;/p&gt;&#xA;" OwnerUserId="5324" LastActivityDate="2016-09-27T11:46:11.407" Title="Add a &quot;Press any key to continue&quot; in VimL?" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9693" PostTypeId="1" CreationDate="2016-09-27T05:07:20.617" Score="3" ViewCount="2021" Body="&lt;p&gt;I've recently learned about Vim's omnicompletion and while attempting to make it work, I get the error &lt;code&gt;Pattern not found&lt;/code&gt;. To test it I used the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class C&#xA;  def hello&#xA;    puts &quot;Hello, World!&quot;&#xA;  end&#xA;  def goodbye&#xA;    puts &quot;Goodbye, cruel world!&quot;&#xA;  end&#xA;end&#xA;&#xA;x = C.new&#xA;&#xA;x.&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which gives the error &lt;code&gt;Pattern not found&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My version of Vim is compiled with +ruby/dyn, and it seems that the error is because the file Vim is trying to load doesn't match my version of Ruby, which seemed to be a problem for some other people using Ruby 1.9.x in another forum thread I saw. In &lt;code&gt;:h ruby-dynamic&lt;/code&gt; that you are able to change the library it uses with 'rubydll', but it must be the same version that Vim is compiled with. My version of Vim is 8.0.5 and I'm using Ruby 2.3.1. I also read in &lt;code&gt;:h 'rubydll'&lt;/code&gt; that the default library to use is &lt;code&gt;DYNAMIC_RUBY_DLL&lt;/code&gt; which is set at compile time, but I'm not sure how to check what this is set to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: &lt;code&gt;vim --version&lt;/code&gt; output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 15 2016 10:09:09)&#xA;Included patches: 1-5&#xA;Compiled by Arch Linux&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     +tcl/dyn&#xA;+balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;+browse          -footer          +multi_byte      +terminfo&#xA;++builtin_terms  +fork()          +multi_lang      +termresponse&#xA;+byte_offset     +gettext         -mzscheme        +textobjects&#xA;+channel         -hangul_input    +netbeans_intg   +timers&#xA;+cindent         +iconv           +num64           +title&#xA;+clientserver    +insert_expand   +packages        +toolbar&#xA;+clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        +perl/dyn        +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       +python/dyn      +vreplace&#xA;+cscope          +lispindent      +python3/dyn     +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con_gui  +lua/dyn         +rightleft       +writebackup&#xA;+diff            +menu            +ruby/dyn        +X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;+dnd             +modify_fname    +signs           +xim&#xA;-ebcdic          +mouse           +smartindent     -xpm&#xA;+emacs_tags      +mouseshape      +startuptime     +xsmp_interact&#xA;+eval            +mouse_dec       +statusline      +xterm_clipboard&#xA;+ex_extra        +mouse_gpm       -sun_workshop    -xterm_save&#xA;+extra_search    -mouse_jsbterm   +syntax          &#xA;+farsi           +mouse_netterm   +tag_binary      &#xA;   system vimrc file: &quot;/etc/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;/etc/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lncurses -lelf -lnsl    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lieee -lm  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8251" LastEditorUserId="8251" LastEditDate="2016-09-27T06:57:45.730" LastActivityDate="2016-12-26T11:19:51.523" Title="Vim omnicomplete with Ruby 2.3.1" Tags="|autocompletion|filetype-ruby|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9694" PostTypeId="1" CreationDate="2016-09-27T05:17:12.640" Score="1" ViewCount="160" Body="&lt;p&gt;I saw the so called &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; in my &lt;code&gt;vimrc&lt;/code&gt; quite often. But is there a way to define my own key in a similar manner? I mean I would like to define some sort of &lt;code&gt;&amp;lt;Mykey&amp;gt;&lt;/code&gt; and use it further in my &lt;code&gt;vimrc&lt;/code&gt; to define more complicated combinations. I mean something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Mykey&amp;gt;u &quot;some keystroke&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means that depending on how I define &lt;code&gt;&amp;lt;Mykey&amp;gt;&lt;/code&gt; I get different combinations with it.&lt;/p&gt;&#xA;" OwnerUserId="9237" LastActivityDate="2016-09-27T17:46:10.820" Title="Defining my own key" Tags="|key-bindings|vimrc|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9695" PostTypeId="2" ParentId="9694" CreationDate="2016-09-27T06:01:39.343" Score="6" Body="&lt;p&gt;You can define your own &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; key with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;something&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also hack the &lt;code&gt;&amp;lt;localleader&amp;gt;&lt;/code&gt; to get a second &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let localleader = &quot;something else&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;localleader&amp;gt;&lt;/code&gt; are not special keys &lt;em&gt;at all&lt;/em&gt;. Assuming your &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; is set to &lt;code&gt;,&lt;/code&gt; (the example in &lt;code&gt;:help mapleader&lt;/code&gt;) the two mappings below are &lt;em&gt;strictly&lt;/em&gt; equivalent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;f :find *&#xA;nnoremap ,f        :find *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, basically, you can use any normal key to &lt;em&gt;function&lt;/em&gt; as &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; without setting anything.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-09-27T06:01:39.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9696" PostTypeId="2" ParentId="9692" CreationDate="2016-09-27T06:02:48.457" Score="11" Body="&lt;p&gt;You can use the &lt;code&gt;input&lt;/code&gt; function, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call input('Press any key to continue')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#input()&quot;&gt;&lt;code&gt;:h input()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-09-27T06:02:48.457" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9697" PostTypeId="2" ParentId="9693" CreationDate="2016-09-27T08:32:26.103" Score="1" Body="&lt;p&gt;Are you using any kind of auto-completion plugin, like neocomplete/YouCompleteMe? I also use Arch Linux and for me it gives completions. I use &lt;a href=&quot;https://github.com/Shougo/neobundle.vim&quot; rel=&quot;nofollow&quot;&gt;neocomplete&lt;/a&gt; and &lt;a href=&quot;https://github.com/vim-ruby/vim-ruby&quot; rel=&quot;nofollow&quot;&gt;vim-ruby&lt;/a&gt; plugins, that probably add needed things to do the completion&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Relevant parts of my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete&#xA;autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1 &#xA;autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1&#xA;autocmd FileType ruby,eruby let g:rubycomplete_rails = 1&#xA;autocmd FileType ruby compiler ruby&#xA;&#xA;&quot; Enable heavy omni completion.&#xA;if !exists('g:neocomplete#sources#omni#input_patterns')&#xA;    let g:neocomplete#sources#omni#input_patterns = {}&#xA;endif&#xA;if !exists('g:neocomplete#sources#omni#force_omni_input_patterns')&#xA;    let g:neocomplete#sources#omni#force_omni_input_patterns = {}&#xA;endif&#xA;let g:neocomplete#sources#omni#input_patterns.ruby = '[^.[:digit:] *\t]\%(\.\|-&amp;gt;\)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="205" LastEditDate="2016-10-27T09:54:16.770" LastActivityDate="2016-10-27T09:54:16.770" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9698" PostTypeId="1" AcceptedAnswerId="9702" CreationDate="2016-09-27T08:35:21.373" Score="0" ViewCount="149" Body="&lt;p&gt;I'm trying to add a simple command to search of rails partials files inside my rails app.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can get the filename without the extension with &lt;code&gt;expand(&quot;%:r:r&quot;)&lt;/code&gt; but in my case because it's haml I always have double extensions like &lt;code&gt;app/views/partials/stores/_home.html.haml&lt;/code&gt;, so &lt;code&gt;:echo expand(&quot;%:t:r&quot;)&lt;/code&gt; give me &lt;code&gt;_home.html&lt;/code&gt; and would like &lt;code&gt;home&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems &lt;code&gt;split(expand('%:t'), '\.')[0]&lt;/code&gt; is good but now I need to remove the first char.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need to add regex to remove &lt;code&gt;_&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After I would like to do something like &lt;code&gt;:Ag! expand(&quot;%:t:r&quot;) app/views/&lt;/code&gt; but how to use expand result? For the moment I get &lt;code&gt;No matches for &quot;expand(&quot;_home.html&quot;) app/views/&quot;&lt;/code&gt;, expand result is properly &quot;echoed&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="3357" LastEditorUserId="3357" LastEditDate="2016-09-27T09:20:48.987" LastActivityDate="2016-09-27T11:21:20.060" Title="Search all mention of the current file's file name" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9699" PostTypeId="2" ParentId="9693" CreationDate="2016-09-27T09:24:45.977" Score="3" Body="&lt;p&gt;Just solved my problem. Not 100% sure how, but I'll do my best to explain all the steps I took: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Installed Vundle and configured it to manage vim-ruby and neocomplete, ran &lt;code&gt;:PluginInstall&lt;/code&gt; and &lt;code&gt;:PluginUpdate&lt;/code&gt; a few times, tried rebooting&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Added the following lines to my .vimrc, found in another thread:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1&#xA;autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1&#xA;autocmd FileType ruby,eruby let g:rubycomplete_rails = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It still wasn't working at this point, but after I ran &lt;code&gt;:PluginUpdate&lt;/code&gt; again, it seemed to work. It seems like those three lines were what fixed it. Thanks for your help.&lt;/p&gt;&#xA;" OwnerUserId="8251" LastEditorUserId="205" LastEditDate="2016-10-27T09:53:45.983" LastActivityDate="2016-10-27T09:53:45.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9700" PostTypeId="1" AcceptedAnswerId="9703" CreationDate="2016-09-27T10:09:37.903" Score="16" ViewCount="670" Body="&lt;p&gt;Normally, a substitute with the &lt;code&gt;c&lt;/code&gt; option gives me two options: (y)es or (n)o. Is it possible to have several numbered yes options to choose from?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;File&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;person: Alice&#xA;dog: Tobby&#xA;person: Bob&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pattern 1&lt;/strong&gt; &lt;code&gt;:%s/person:/woman:/c&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pattern 2&lt;/strong&gt; &lt;code&gt;:%s/person:/man:/c&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pattern 1 and 2 have the same search pattern but different replacement patterns. I want to unify them into one pattern with the option of pressing (1) for replacement 1, (2) for replacement 2 or (n) for no replacement.&lt;/p&gt;&#xA;" OwnerUserId="9449" LastEditorUserId="8136" LastEditDate="2022-11-16T06:04:08.103" LastActivityDate="2022-11-16T06:04:08.103" Title="Multiple choice substitute?" Tags="|substitute|user-input|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9701" PostTypeId="2" ParentId="9683" CreationDate="2016-09-27T10:28:23.087" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;But this is still stupid and annoying.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Or maybe that's just me.  I had not noticed there's separate but similar options for C and C++.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_cpp_check_header&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does the trick.  &lt;/p&gt;&#xA;" OwnerUserId="4913" LastActivityDate="2016-09-27T10:28:23.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9702" PostTypeId="2" ParentId="9698" CreationDate="2016-09-27T11:10:49.497" Score="2" Body="&lt;p&gt;To use &lt;code&gt;expand&lt;/code&gt; in such case you should use &lt;code&gt;:exe&lt;/code&gt; command. I'm not familiar with Rails nor Haml (yet), but if it's always &lt;code&gt;_&lt;/code&gt; in the begining, you can try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;Ag! &quot; . substitute(expand(&quot;%:t:r:r&quot;), &quot;^_&quot;, &quot;&quot;, &quot;&quot;) . &quot; app/views&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And eventually map it to some key binding.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2016-09-27T11:21:20.060" LastActivityDate="2016-09-27T11:21:20.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9703" PostTypeId="2" ParentId="9700" CreationDate="2016-09-27T11:33:26.100" Score="20" Body="&lt;p&gt;The implementation of &lt;code&gt;:s//c&lt;/code&gt; is fixed; what you're looking for is replacement with a Vimscript expression (&lt;code&gt;:help sub-replace-expr&lt;/code&gt;). You can query a single-digit via &lt;code&gt;getchar()&lt;/code&gt;, or prompt for longer numbers via &lt;code&gt;input()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/person:/\=get(['woman', 'man'], getchar() - char2nr(1), submatch(0)) . ':'/&#xA;:%s/person:/\=get(['woman', 'man'], input('Your choice: ') - 1, submatch(0)) . ':'/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can enter a higher number (&lt;code&gt;3&lt;/code&gt; in your example) to perform no replacement.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you need this often, it would make sense to define a custom &lt;code&gt;Query()&lt;/code&gt; function for that. In there, you could also add a &lt;code&gt;:redraw&lt;/code&gt;, so that you see the replacements that have already happened.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-27T11:33:26.100" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9704" PostTypeId="2" ParentId="9694" CreationDate="2016-09-27T11:40:12.850" Score="3" Body="&lt;p&gt;Vim has this abstraction, and it's &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; (and the &lt;code&gt;&amp;lt;LocalLeader&amp;gt;&lt;/code&gt; variant which is meant for buffer-local mappings). Unfortunately, there's only one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a common prefix for a set of custom mappings, and you want to be able to change this in a single location, you can define a variable, and then use &lt;code&gt;:execute&lt;/code&gt; to define the mappings.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:MyKey = '&amp;lt;Leader&amp;gt;x'&#xA;execute 'nnoremap' g:MyKey . 'u' &quot;some keystroke&#xA;execute 'nnoremap' g:MyKey . 'v' &quot;another keystroke&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-27T11:40:12.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9705" PostTypeId="2" ParentId="9692" CreationDate="2016-09-27T11:46:11.407" Score="11" Body="&lt;ul&gt;&#xA;&lt;li&gt;For a confirmation, I would use &lt;code&gt;:call confirm('My warning here')&lt;/code&gt;; this uses a popup window in GVIM.&lt;/li&gt;&#xA;&lt;li&gt;To wait for &lt;em&gt;any&lt;/em&gt; character, you can use &lt;code&gt;:call getchar()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For a confirmation with &lt;kbd&gt;Enter&lt;/kbd&gt;, the already mentioned &lt;code&gt;:call input('Press enter to continue')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Many people would consider such mandatory interrupt bad user experience. I don't know about your exact use case, but in general, I would just &lt;code&gt;:autocmd VimEnter * echoerr 'Houston, we have a problem'&lt;/code&gt;. If the user somehow didn't see the message, &lt;code&gt;:messages&lt;/code&gt; will recall them.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-27T11:46:11.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9706" PostTypeId="1" AcceptedAnswerId="9707" CreationDate="2016-09-27T13:48:20.773" Score="26" ViewCount="3931" Body="&lt;p&gt;What is the difference between single and double quoted strings?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get a variable expanded inside a string, or do they always need to be joined like: &lt;code&gt;'Hello, ' . s:name . '!'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2016-09-28T09:35:51.127" LastActivityDate="2023-01-09T19:06:01.593" Title="What is the difference between single and double quoted strings?" Tags="|vimscript|string-manipulation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9707" PostTypeId="2" ParentId="9706" CreationDate="2016-09-27T14:25:58.410" Score="33" Body="&lt;p&gt;The only difference between single and double quoted string is related to backslash. To &lt;em&gt;display&lt;/em&gt; special characters like newline, bells, tabs, etc, you need to use double-quotes -&gt; &lt;code&gt;&quot;\n&quot;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Within a single-quoted string, &lt;code&gt;'\'&lt;/code&gt; is itself =&gt; &lt;code&gt;'\n'&lt;/code&gt; is a two-characters string (a backslash + &lt;code&gt;n&lt;/code&gt;). Within double quotes, you have to double it -&gt; &lt;code&gt;&quot;\\&quot;&lt;/code&gt;, which makes them un-practical to define regexes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding string expansion, you have a few choices:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'Hello, ' . s:name . '!'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;join(['Hello, ', s:name, '!'], '')&lt;/code&gt; -- which we never use&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;printf('Hello %s!', s:name)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;lh#fmt#printf('Hello %1!', s:name)&lt;/code&gt; -- from lh-vim-lib, when we don't want to know about types, and when we don't need to format fields, but when we want to use formats like: &lt;code&gt;'Hello %1. How are you doing %1 this %2&lt;/code&gt;'.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-09-27T14:25:58.410" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9708" PostTypeId="2" ParentId="9675" CreationDate="2016-09-27T15:35:28.610" Score="2" Body="&lt;p&gt;Vimscript is evaluated exactly like the Ex commands typed in the &lt;code&gt;:&lt;/code&gt; command-line. There were no variables in &lt;code&gt;ex&lt;/code&gt;, so there's no way to specify them. When typing a command interactively, you'd probably use &lt;code&gt;&amp;lt;C-R&amp;gt;=&lt;/code&gt; to insert variable contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sleep &amp;lt;C-R&amp;gt;=timetowait&amp;lt;CR&amp;gt;m&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... but in a script, &lt;code&gt;:execute&lt;/code&gt; must be used. All the literal parts of the Ex command must be quoted (single or double quotes), and then concatenated with the variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'sleep' timetowait . 'm'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-27T15:35:28.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9709" PostTypeId="2" ParentId="9672" CreationDate="2016-09-27T15:41:03.423" Score="1" Body="&lt;p&gt;The old and venerable &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=12&quot; rel=&quot;nofollow&quot;&gt;closetag plugin&lt;/a&gt; automatically determines the current HTML / XML tag, and inserts a proper closing tag. It is triggered by &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;_&lt;/kbd&gt; by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would not recommend automatic insertion; that's probably causing more problems than it solves. But this insert-mode mapping might help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap &amp;gt; &amp;gt;&amp;lt;C-_&amp;gt;&amp;lt;C-o&amp;gt;F&amp;lt;lt&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-27T15:41:03.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9710" PostTypeId="2" ParentId="9672" CreationDate="2016-09-27T17:14:11.143" Score="1" Body="&lt;p&gt;This plugin &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1397&quot; rel=&quot;nofollow&quot; title=&quot;html.vim&quot;&gt;html.vim&lt;/a&gt; helps me a lot when editing html/xml files. The only thing you should do is save your currently edited file with .html extension.&lt;/p&gt;&#xA;" OwnerUserId="9385" LastActivityDate="2016-09-27T17:14:11.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9711" PostTypeId="2" ParentId="9694" CreationDate="2016-09-27T17:46:10.820" Score="1" Body="&lt;p&gt;Here's an interesting usage that I first saw (and wandered about) in &lt;a href=&quot;https://github.com/Shougo/unite.vim/blob/master/doc/unite.txt#L211&quot; rel=&quot;nofollow&quot;&gt;Shougo's Unite&lt;/a&gt; plugin, which creates an artificial leader key &quot;placeholder&quot; (I'm quoting directly from the Unite's help file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; The prefix key.&#xA;nnoremap    [unite]   &amp;lt;Nop&amp;gt;&#xA;nmap        f         [unite]&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; [unite]c  :&amp;lt;C-u&amp;gt;UniteWithCurrentDir&#xA;        \ -buffer-name=files buffer bookmark file&amp;lt;CR&amp;gt;&#xA;&#xA;... (etc.)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above example, the whole sequence of characters &lt;code&gt;[unite]&lt;/code&gt; is mapped non-recursively in normal mode to do nothing (and thus, it becomes a &quot;prefix&quot;!) Then, a &quot;leader&quot; key is assigned to this complicated &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt;; in this case, &lt;code&gt;f&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What follows are the actual maps, in which every time you type &lt;code&gt;f&lt;/code&gt; &lt;code&gt;&amp;lt;some other char(s)&amp;gt;&lt;/code&gt;, Vim translates it to &lt;code&gt;[unite]&lt;/code&gt; &lt;code&gt;&amp;lt;some other char(s)&amp;gt;&lt;/code&gt; -- if the combination is defined (and typed in time), the map gets executed, otherwise -- the prefix is cancelled (because it gets resolved by itself to &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt;, i.e. nothing) and it's like you didn't type it at all. Mind boggling. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't test, but I think the way the sequence itself is defined (here, &lt;code&gt;[unite]&lt;/code&gt;) is quite relevant -- if I got it right, it will create delays for any key combinations starting with &lt;code&gt;[&lt;/code&gt;, &lt;code&gt;[u&lt;/code&gt;, &lt;code&gt;[un&lt;/code&gt; and so on. So you would always want to use a leader placeholder &quot;string&quot; that starts with characters you don't &lt;em&gt;normally&lt;/em&gt; (pun) use by themselves.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-09-27T17:46:10.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9712" PostTypeId="2" ParentId="9649" CreationDate="2016-09-27T19:02:15.900" Score="1" Body="&lt;p&gt;Actually, the decision was to update gVim to 8.0 version, released just a few weeks ago. Then such settings were useful as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=utf8&#xA;set termencoding=utf8&#xA;set guifont=Consolas:h11:cRUSSIAN          &quot;to get proper font for Cyrillic&#xA;set fileencodings=utf8,cp1251,cp866,koi8r&#xA;&quot;to get English menu instead of broken Russian&#xA;set langmenu=en_US                        &#xA;let $LANG = 'en_US'&#xA;source $VIMRUNTIME/delmenu.vim&#xA;source $VIMRUNTIME/menu.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9385" LastActivityDate="2016-09-27T19:02:15.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9713" PostTypeId="1" AcceptedAnswerId="9714" CreationDate="2016-09-27T21:30:46.410" Score="11" ViewCount="619" Body="&lt;p&gt;Since I need to operate on a sequence of symbols between spaces I'd like to know which text object defines it. Here is an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;45908 Sep 24 21:31 [r].t3891993.tr some another text.&#xA;                            ^&#xA;                         cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In visual mode I'd like to mark &lt;code&gt;[r].t3891993.tr&lt;/code&gt;, but simply typing &lt;code&gt;i&amp;lt;SPACE&amp;gt;&lt;/code&gt; doesn't work. How to define such a text object?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPD: That's not just about visual mode. In normal mode it would be very useful for me as well.&lt;/p&gt;&#xA;" OwnerUserId="9237" LastEditorUserId="6489" LastEditDate="2016-09-27T21:49:13.527" LastActivityDate="2016-09-27T21:49:13.527" Title="Which text object defines text enclosed in space?" Tags="|cursor-motions|visual-mode|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9714" PostTypeId="2" ParentId="9713" CreationDate="2016-09-27T21:36:44.800" Score="15" Body="&lt;p&gt;I believe you are looking for the &lt;code&gt;WORD&lt;/code&gt; text object. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h WORD&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A WORD consists of a sequence of non-blank characters, separated with white&#xA;  space.  An empty line is also considered to be a WORD.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is signified by a capital &quot;W&quot;. I.E. use &lt;code&gt;viW&lt;/code&gt; to mark the text in visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal mode you could yank the text with &lt;code&gt;yiW&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info see &lt;code&gt;:h iW&lt;/code&gt; and &lt;code&gt;:h WORD&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-09-27T21:42:50.910" LastActivityDate="2016-09-27T21:42:50.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9715" PostTypeId="1" CreationDate="2016-09-28T00:14:38.693" Score="6" ViewCount="455" Body="&lt;p&gt;When refactoring I sometimes do too much at once—all little steps, but I forget to commit after each little change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course in many cases a commit after &lt;em&gt;each&lt;/em&gt; change would be too much, but if each individual change were initially made as a separate commit, it would be very easy to &lt;code&gt;git rebase&lt;/code&gt; them to combine them into logical, atomic changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to convert each point in Vim's multiple undo history into a separate git commit?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2022-04-06T16:49:20.020" Title="Turn Vim's multiple undo history into git commits?" Tags="|git|undo-redo|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9716" PostTypeId="2" ParentId="7879" CreationDate="2016-09-28T02:47:16.083" Score="1" Body="&lt;p&gt;An elegant one which shows the power of g command:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\v^(\-?\d\.\d+)(\r?\n\1)+$/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just replace the pattern in the first parentheses to meet your other needs. It works even if the duplicated lines are not of the same number. And the order will be preserved also.&lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="1788" LastEditDate="2016-09-28T23:16:53.780" LastActivityDate="2016-09-28T23:16:53.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9717" PostTypeId="1" AcceptedAnswerId="9744" CreationDate="2016-09-28T04:38:29.620" Score="7" ViewCount="1105" Body="&lt;p&gt;I'm trying to change the location of the &lt;code&gt;viminfo&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does the value of &lt;code&gt;&amp;amp;viminfo&lt;/code&gt; revert after it is set in &lt;code&gt;vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my &lt;code&gt;vimrc&lt;/code&gt; I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;exec &quot;set viminfo+=n&quot;.expand($XDG_DATA_HOME).&quot;/vim/viminfo&quot;&#xA;echom &amp;amp;viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've noticed that &lt;code&gt;echo &amp;amp;viminfo&lt;/code&gt; from command mode shows the &lt;em&gt;previous&lt;/em&gt; version of &lt;code&gt;&amp;amp;viminfo&lt;/code&gt; even though the &lt;code&gt;echom&lt;/code&gt; inside &lt;code&gt;vimrc&lt;/code&gt; shows that &lt;code&gt;&amp;amp;viminfo&lt;/code&gt; was correctly (but temporarily) updated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suspect &lt;code&gt;autocommand&lt;/code&gt;, but &lt;code&gt;ag -ul viminfo&lt;/code&gt; only shows my &lt;code&gt;vimrc&lt;/code&gt; and the &lt;code&gt;viminfo&lt;/code&gt; file itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does the value of &lt;code&gt;&amp;amp;viminfo&lt;/code&gt; change after I explicitly set it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Full description&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@ravi@boxy:~$ vim --version | head -1&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 05 2016 16:48:20)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I start &lt;code&gt;vim&lt;/code&gt; with VIMINIT set to honour the &lt;a href=&quot;https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html&quot; rel=&quot;noreferrer&quot;&gt;XDG Base Directory Specification&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@ravi@boxy:~$ echo $VIMINIT&#xA;let $MYVIMRC=&quot;$XDG_CONFIG_HOME/vim/vimrc&quot;|set nocp|exec &quot;set viminfo+=n&quot;.expand($XDG_DATA_HOME).&quot;/vim/viminfo&quot;|echom &amp;amp;viminfo|source $MYVIMRC&#xA;@ravi@boxy:~$ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For belts and braces, I also have in my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&quot; Location of the viminfo file&#xA;exec &quot;set viminfo+=n&quot;.expand($XDG_DATA_HOME).&quot;/vim/viminfo&quot;&#xA;echom &amp;amp;viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I remove the existing &lt;code&gt;~/.viminfo&lt;/code&gt;, start &lt;code&gt;vim&lt;/code&gt;, then exit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@ravi@boxy:~$ rm ~/.viminfo &#xA;@ravi@boxy:~$ vim&#xA;'100,&amp;lt;50,s10,h,n/home/ravi/.local/share/vim/viminfo&#xA;'100,&amp;lt;50,s10,h,n/home/ravi/.local/share/vim/viminfo&#xA;Press ENTER or type command to continue&#xA;@ravi@boxy:~$ file ~/.viminfo &#xA;/home/ravi/.viminfo: ASCII text&#xA;@ravi@boxy:~$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;amp;viminfo&lt;/code&gt; variable gets printed twice because of the belt and braces, but as you can see, the file is still created at the default location.&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2016-09-29T06:09:05.627" LastActivityDate="2022-11-28T13:47:04.447" Title="Can't move `viminfo` file - &amp;viminfo reverts upon loading vim" Tags="|vimrc|viminfo|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9718" PostTypeId="1" AcceptedAnswerId="9720" CreationDate="2016-09-28T05:34:49.037" Score="4" ViewCount="793" Body="&lt;p&gt;I tried to bind the following to insert a line after the line I'm currently on. Here it is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;CR&amp;gt; o&amp;lt;ESC&amp;gt;k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this works weird. After inserting a new line cursor is at the beginning of the line I was on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to insert a new line in normal mode and stay at the same position?&lt;/p&gt;&#xA;" OwnerUserId="9237" LastActivityDate="2016-09-29T08:20:34.340" Title="How to insert line in normal mode and stay at the same position" Tags="|key-bindings|vimrc|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9719" PostTypeId="2" ParentId="9718" CreationDate="2016-09-28T05:52:17.840" Score="4" Body="&lt;p&gt;Almost every time you move your cursor, the previous location is added to &quot;the jumplist&quot;. Using &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; will move you back to the previous location in the jump list. From &lt;code&gt;:h CTRL-o&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *CTRL-O*&#xA;CTRL-O          Go to [count] Older cursor position in jump list&#xA;            (not a motion command).&#xA;            {not in Vi}&#xA;            {not available without the |+jumplist| feature}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, binding to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;CR&amp;gt; o&amp;lt;ESC&amp;gt;&amp;lt;C-o&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does not work because &lt;code&gt;o&lt;/code&gt; is one of the movements that doesn't add the previous location. To manually add the current location, type &lt;code&gt;m`&lt;/code&gt;. From &lt;code&gt;:h m`&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *m'* *m`*&#xA;m'  or  m`      Set the previous context mark.  This can be jumped to&#xA;            with the &quot;''&quot; or &quot;``&quot; command (does not move the&#xA;            cursor, this is not a motion command).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the end mapping would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;CR&amp;gt; m`o&amp;lt;ESC&amp;gt;&amp;lt;C-o&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Actually, we can make this mapping even better! We can make it accept a count.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; &quot;m`&quot;.v:count1.&quot;o\&amp;lt;esc&amp;gt;\&amp;lt;C-o&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-09-28T05:52:17.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9720" PostTypeId="2" ParentId="9718" CreationDate="2016-09-28T07:48:30.243" Score="6" Body="&lt;p&gt;&lt;em&gt;That's odd, I was quite sure to have already answered this question twice. It may have been on &lt;a href=&quot;https://stackoverflow.com/a/3171023/15934&quot;&gt;SO&lt;/a&gt;...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway. Use &lt;code&gt;append()&lt;/code&gt;. It won't move the cursor or alter more registers than necessary.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This also supports counts. Try 3&amp;lt;cr&amp;gt;&#xA;:nnoremap &amp;lt;buffer&amp;gt; &amp;lt;cr&amp;gt; :&amp;lt;C-U&amp;gt;call append('.', repeat([''],v:count1))&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-09-29T08:20:34.340" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9721" PostTypeId="1" AcceptedAnswerId="9722" CreationDate="2016-09-28T10:19:03.087" Score="1" ViewCount="72" Body="&lt;p&gt;The text I want to process is like (after sorting regardless of the first column: &lt;code&gt;sort/^[^|]*/&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;236|c this is character ace|end but not the same&#xA;i24|f string f is different|this is the end &#xA;235|this is character c|end&#xA;235|this is character c|end but &#xA;235|this is character c|end but not the same&#xA;235|this is character c|end but not the same&#xA;422|this is string aa|end of the line&#xA;312|this is string af|end but maybe not the same&#xA;423|this is string af|end but not the same&#xA;123|this is string af|end of line one&#xA;422|this is string af|end of the line&#xA;422|this is string a|end of the line&#xA;51k|this is string e|end but not the same&#xA;13d|this is string e|end of the line&#xA;341|z string b is different|end of the line but not the same&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to move all lines duplicated in the middle column to the end of the file. That's, all unique lines appear in the beginning of the file, followed by the duplicated(only duplicated in the middle column) lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried   &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;g/\v\w{3}\|([^|]*)\|[^|]+$(\r?\n\w{3}\|\1\|[^|]+$)+/m$&lt;/code&gt;&lt;br&gt;&#xA;This will end with the first occurrence of the duplicated lines not moved, which works as expected considering I learn this from the method to delete the duplicated lines and leave only the first one.     &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;%s:\v^\w{3}\|(.*)\|[^\n]+(\n\w{3}\|\1[^\n]+)+::cg&lt;/code&gt;&lt;br&gt;&#xA;This time I can get only the unique lines but I lose what I want. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I thought both two approaches can lead to the result, but the questions left respectively are:   &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to move the matched lines &lt;strong&gt;in one go&lt;/strong&gt;, or move the first one after this step; and   &lt;/li&gt;&#xA;&lt;li&gt;How to delete all lines in file2 which are also in file2(file1 is the original text and file2 contains only unique lines). &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Or moving only the unique lines can also reach the goal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I in the right direction? Or any vim-ish/straightforward methods? Thanks. &lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="1788" LastEditDate="2016-09-28T11:47:00.460" LastActivityDate="2016-09-28T12:04:49.530" Title="Move the partly duplicated(repeated over lines in the middle part) lines to the end?" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9722" PostTypeId="2" ParentId="9721" CreationDate="2016-09-28T12:04:49.530" Score="1" Body="&lt;p&gt;Here is one solution. It first marks all duplicate lines (by appending a string to them). As your pattern starts a match on all but the last duplicate line, we need another pass with a modified pattern to also capture the last line. Then move the marked lines to the end of the buffer, and remove the mark(s) from them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a = ''&#xA;:%s/\v^\w{3}\|(.*)\|[^\n]+\ze(\n\w{3}\|\1[^\n]+)+/&amp;amp; SELECT/e&#xA;:%s/\v^\w{3}\|(.*)\|[^\n]+(\n\zs\w{3}\|\1[^\n]+)+/&amp;amp; SELECT/e&#xA;:global/ SELECT$/move $&#xA;:%s/\%( SELECT\)\+$//e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-28T12:04:49.530" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9723" PostTypeId="2" ParentId="9715" CreationDate="2016-09-28T12:12:33.847" Score="3" Body="&lt;p&gt;I would recommend one of the &lt;em&gt;undo tree visualizer plugins&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/mbbill/undotree&quot; rel=&quot;nofollow&quot;&gt;undotree&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://sjl.bitbucket.org/gundo.vim/&quot; rel=&quot;nofollow&quot;&gt;Gundo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With them, you can easily revisit previous editing states. You can them (temporarily) restore them (one by one, starting with the oldest relevant), and &lt;code&gt;git commit&lt;/code&gt; them, until you arrive back at the original.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-28T12:12:33.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9724" PostTypeId="2" ParentId="9560" CreationDate="2016-09-28T14:27:23.990" Score="2" Body="&lt;p&gt;There's a plugin called SplitJoin.vim that aims to address exactly your problem. Find it here: &lt;a href=&quot;https://github.com/AndrewRadev/splitjoin.vim&quot; rel=&quot;nofollow&quot;&gt;https://github.com/AndrewRadev/splitjoin.vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9469" LastActivityDate="2016-09-28T14:27:23.990" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9725" PostTypeId="5" CreationDate="2016-09-28T14:36:15.457" Score="0" Body="&lt;p&gt;If you exit &lt;code&gt;vim&lt;/code&gt; and later start it again, you would normally lose a lot of&#xA;information.  The &lt;code&gt;viminfo&lt;/code&gt; file can be used to remember that information, which&#xA;enables you to continue where you left off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;viminfo&lt;/code&gt; file is used to store:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The command line history.&lt;/li&gt;&#xA;&lt;li&gt;The search string history.&lt;/li&gt;&#xA;&lt;li&gt;The input-line history.&lt;/li&gt;&#xA;&lt;li&gt;Contents of non-empty registers.&lt;/li&gt;&#xA;&lt;li&gt;Marks for several files.&lt;/li&gt;&#xA;&lt;li&gt;File marks, pointing to locations in files.&lt;/li&gt;&#xA;&lt;li&gt;Last search/substitute pattern (for 'n' and '&amp;amp;').&lt;/li&gt;&#xA;&lt;li&gt;The buffer list.&lt;/li&gt;&#xA;&lt;li&gt;Global variables.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(From &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#viminfo-file&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help viminfo&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2016-09-28T18:02:01.703" LastActivityDate="2016-09-28T18:02:01.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9726" PostTypeId="4" CreationDate="2016-09-28T14:36:15.457" Score="0" Body="If you exit `vim` and later start it again, you would normally lose a lot of information.  The `viminfo` file can be used to remember that information, which enables you to continue where you left off." OwnerUserId="5324" LastEditorUserId="1841" LastEditDate="2016-09-28T18:03:47.293" LastActivityDate="2016-09-28T18:03:47.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9727" PostTypeId="2" ParentId="9715" CreationDate="2016-09-28T14:44:21.020" Score="6" Body="&lt;p&gt;Here's a quick and dirty function that does what you request:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! UndoCommits(steps)&#xA;    for i in range(a:steps)&#xA;        undo&#xA;    endfor&#xA;&#xA;    for i in range(a:steps)&#xA;        write&#xA;        execute printf('!silent git commit -am &quot;%s&quot;', &quot;undo-commit&quot; . i)&#xA;        redo&#xA;    endfor&#xA;    write&#xA;    execute printf('!silent git commit -am &quot;%s&quot;', &quot;final-undo-commit&quot;)&#xA;    redraw!&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Call with &lt;code&gt;:call UndoCommits({N})&lt;/code&gt; where {N} is the number of undo steps back you want to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function simply undoes the requested number of times, and then redoes the changes one at a time, making a commit between each change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I think I'd just do this manually&amp;thinsp;&amp;mdash;&amp;thinsp;I guess a compromise might be to create a mapping that just performs the save-and-commit, and then run this mapping by hand at the relevant parts of the undolist.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-09-28T15:06:49.610" LastActivityDate="2016-09-28T15:06:49.610" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9728" PostTypeId="2" ParentId="7918" CreationDate="2016-09-28T15:27:05.813" Score="1" Body="&lt;p&gt;I recommend following @SibiCoder's suggestion about creating a &lt;code&gt;.vim/after/ftplugin/erlang.vim&lt;/code&gt; file, and set the desired &lt;code&gt;shiftwidth&lt;/code&gt; there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal shiftwidth=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's the best place to customize file type specific settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, if you use a relatively new Vim version, you don't need the vim-erlang-runtime plugin, as the syntax and indentation provided by it are part of the Vim itself.&lt;/p&gt;&#xA;" OwnerUserId="5729" LastActivityDate="2016-09-28T15:27:05.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9729" PostTypeId="1" AcceptedAnswerId="9730" CreationDate="2016-09-28T17:05:25.587" Score="11" ViewCount="3470" Body="&lt;p&gt;In vi it's very helpful to be able to place the cursor on a '(' or '{' or '[' character, press the '%' key, and move to the matching ')', '}', or ']'. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this does not work for me with angle brackets ( '&amp;lt;' and '&gt;' ), even though page 130 of my &quot;Learning the vi Editor&quot; O'Reilly book (6th edition) says it should! I am using Centos 7.2 and my 'vi' editor is actually vim 7.4.160.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a version-specific thing? Or is there some switch that I can set/clear to make this work? It'd be handy for trying to make sense of HTML and Javascript.&lt;/p&gt;&#xA;" OwnerUserId="9472" LastActivityDate="2016-09-28T17:33:12.083" Title="Percent key ( % ) matching behavior for angle brackets ( &lt; &gt; )" Tags="|key-bindings|search|cursor-movement|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9730" PostTypeId="2" ParentId="9729" CreationDate="2016-09-28T17:24:45.013" Score="13" Body="&lt;p&gt;&lt;code&gt;'matchpairs'&lt;/code&gt; controls what characters form pairs which &lt;code&gt;%&lt;/code&gt; will work upon. You can add angle brackets by doing the following command as suggested by &lt;code&gt;:h 'matchpairs'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set matchpairs+=&amp;lt;:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;'matchpairs'&lt;/code&gt; is a buffer local setting it would be best do this for the filetype you want. An example of for &lt;code&gt;cpp&lt;/code&gt; filetype which can be added to your &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup AngleBrackets&#xA;    autocmd!&#xA;    autocmd FileType cpp set matchpairs+=&amp;lt;:&amp;gt;;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However my preferred method of setting filetype specific options is to use the &lt;code&gt;after-directory&lt;/code&gt;. Add the following to &lt;code&gt;~/.vim/after/ftplugin/cpp.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set matchpairs+=&amp;lt;:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: These examples use &lt;code&gt;cpp&lt;/code&gt; as the filetype. You can use a different filetype to fit your needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you truly want to make this a global change no matter the filetype add the following to your &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setglobal matchpairs+=&amp;lt;:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'matchpairs'&#xA;:h local-options&#xA;:h 'filetype'&#xA;:h :autocmd&#xA;:h after-directory&#xA;:h setglobal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2016-09-28T17:33:12.083" LastActivityDate="2016-09-28T17:33:12.083" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9732" PostTypeId="1" CreationDate="2016-09-28T18:50:51.823" Score="4" ViewCount="2901" Body="&lt;p&gt;I've been using vim for not that long and got stuck with marking when I'm in the insert mode. I do it as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;ESC&amp;gt;v&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Mark the text I need&lt;/li&gt;&#xA;&lt;li&gt;Do something with it&lt;/li&gt;&#xA;&lt;li&gt;Enter to the insert mode again&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now I think that the approach taken by classical editors (hold CTRL+SHIFT and then press &lt;code&gt;LEFT&lt;/code&gt; or &lt;code&gt;RIGHT&lt;/code&gt;) is a little bit convenient. Especially if we need to select just one word we just typed (I'm not talking here about compilicated visual blocks). I think so because we don't press &lt;code&gt;&amp;lt;ESC&amp;gt;v&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe there is a simpler way to mark while we are in insert mode?&lt;/p&gt;&#xA;" OwnerUserId="9237" LastActivityDate="2016-10-06T12:48:24.523" Title="What is the vim way to mark in insert mode?" Tags="|insert-mode|visual-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9733" PostTypeId="1" AcceptedAnswerId="9734" CreationDate="2016-09-28T19:05:29.820" Score="1" ViewCount="148" Body="&lt;p&gt;I would like to have an abbreviation (&lt;code&gt;xdate&lt;/code&gt; in this case) expanded when I use it in &lt;code&gt;nnoremap&lt;/code&gt;. Is this possible?  Here is what I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iab xdate &amp;lt;c-r&amp;gt;=strftime('%c')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;w i#xdate&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I use the above mapping (&lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;) I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#xdate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what I want is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#Wed 28 Sep 2016 12:03:18 PM MST &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is what I get if I type &lt;code&gt;#xdate&lt;/code&gt; in insert mode.&lt;/p&gt;&#xA;" OwnerUserId="9474" LastEditorUserId="1841" LastEditDate="2016-09-29T09:15:41.683" LastActivityDate="2016-09-29T09:15:41.683" Title="How to get abbreviations to work inside nnoremap" Tags="|key-bindings|abbreviations|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9734" PostTypeId="2" ParentId="9733" CreationDate="2016-09-28T19:09:01.077" Score="2" Body="&lt;p&gt;&lt;code&gt;nnoremap&lt;/code&gt; is a non-recursive mapping. This means that it will not take your abbreviation into account. Change it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iab xdate &amp;lt;c-r&amp;gt;=strftime('%c')&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;w i#xdate&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it should work.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-09-28T19:09:01.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9735" PostTypeId="1" AcceptedAnswerId="9736" CreationDate="2016-09-28T19:36:12.870" Score="4" ViewCount="234" Body="&lt;p&gt;I would like to not have vim copy items to the default register when I delete or change an item; for that, the following configuration seems to do the job perfectly. However I noticed that the only thing that is not working is when I visually select some lines then delete them, those lines get yanked to the default register. Is there any way that those visually selected lines don't get yanked to the default register when I delete them. I would like them to go to the black hole register. This is my current configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap d &quot;_d&#xA;nnoremap D &quot;_D&#xA;nnoremap C &quot;_C&#xA;nnoremap c &quot;_c&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;d &quot;*d&#xA;nnoremap &amp;lt;leader&amp;gt;D &quot;*D&quot;&#xA;&#xA;&quot;When you paste do not copy what you pasted over.&#xA;&quot;This happens when you paste over a visual selection&#xA;vnoremap p &quot;_dp&#xA;vnoremap P &quot;_dP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6877" LastEditorUserId="11357" LastEditDate="2017-11-27T20:12:09.433" LastActivityDate="2017-11-27T20:12:09.433" Title="Visually selecting a line and then deleting does not copy to black hole register" Tags="|vimrc|macvim|register|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9736" PostTypeId="2" ParentId="9735" CreationDate="2016-09-28T19:39:23.587" Score="7" Body="&lt;p&gt;&lt;code&gt;nnoremap&lt;/code&gt; only affects [n]ormal mode and will not affect [v]isual mode. You need &lt;code&gt;vnoremap&lt;/code&gt; for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap d &quot;_d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-09-28T19:39:23.587" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9737" PostTypeId="1" AcceptedAnswerId="9738" CreationDate="2016-09-29T01:40:36.410" Score="3" ViewCount="91" Body="&lt;p&gt;I have the following line in my config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;cr&amp;gt; G&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I can type &lt;code&gt;123&amp;lt;cr&amp;gt;&lt;/code&gt; and go to the line 123, but I don't really want to go to the end of file if I did not type any numbers. How do I map it so it only works with numbers typed ahead?&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="2920" LastEditDate="2016-09-29T02:24:19.580" LastActivityDate="2016-09-29T02:26:47.183" Title="Map &lt;number&gt;&lt;cr&gt; to go to the line" Tags="|key-bindings|cursor-movement|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9738" PostTypeId="2" ParentId="9737" CreationDate="2016-09-29T02:26:47.183" Score="8" Body="&lt;p&gt;You can use an expression mapping. From &lt;code&gt;:h &amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *:map-&amp;lt;expr&amp;gt;* *:map-expression*&#xA;If the first argument to one of these commands is &quot;&amp;lt;expr&amp;gt;&quot; and it is used to&#xA;define a new mapping or abbreviation, the argument is an expression.  The&#xA;expression is evaluated to obtain the {rhs} that is used.  Example: &amp;gt;&#xA;    :inoremap &amp;lt;expr&amp;gt; . InsertDot()&#xA;The result of the InsertDot() function will be inserted.  It could check the&#xA;text before the cursor and start omni completion when some condition is met.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the mapping you are looking for is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; v:count == 0 ? &quot;\&amp;lt;cr&amp;gt;&quot; : &quot;G&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-09-29T02:26:47.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9739" PostTypeId="1" AcceptedAnswerId="9741" CreationDate="2016-09-29T06:09:17.793" Score="9" ViewCount="6951" Body="&lt;p&gt;I'm reading vim help about the line function and here is an example I found:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let failed = append(line('$'), &quot;# THE END&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my vimrc I also found &lt;code&gt;line('.')&lt;/code&gt;. The documentation says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;line( {expr})&lt;/code&gt;           Number  line nr of cursor, last line or mark&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I tried to invoke it as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo :call line('$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this printed the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E121: Undefined variable: :call&#xA;E15: Invalid expression: :call line('$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does &lt;code&gt;'.'&lt;/code&gt; and &lt;code&gt;'$'&lt;/code&gt; mean here and how to invoke it correctly?&lt;/p&gt;&#xA;" OwnerUserId="9237" LastEditorUserId="1841" LastEditDate="2016-09-29T09:46:09.063" LastActivityDate="2016-09-29T09:46:09.063" Title="Understanding the line() built-in function" Tags="|vimscript|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9740" PostTypeId="1" CreationDate="2016-09-29T06:21:38.177" Score="2" ViewCount="1648" Body="&lt;p&gt;I set my mapleader to Space as &lt;code&gt;:let mapleader = &quot;\&amp;lt;Space&amp;gt;&quot;&lt;/code&gt; and use it in command mode quite often. But when I hold it it makes the cursor to move forward which is very annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;QUESTION:&lt;/em&gt;&lt;/strong&gt; Is there a way to unbind Space in normal mode?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2016-09-29T07:52:34.683" Title="Unbind Space in normal mode" Tags="|key-bindings|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9741" PostTypeId="2" ParentId="9739" CreationDate="2016-09-29T07:15:23.977" Score="14" Body="&lt;p&gt;In &lt;code&gt;:help line&lt;/code&gt; all possible values of &lt;code&gt;{expr}&lt;/code&gt; are explained:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.       the cursor position                                 &#xA;$       the last line in the current buffer                 &#xA;'x      position of mark x (if the mark is not set, 0 is returned)                                           &#xA;w0      first line visible in current window                &#xA;w$      last line visible in current window                 &#xA;v       In Visual mode: the start of the Visual area (the   &#xA;        cursor is the end).  When not in Visual mode        &#xA;        returns the cursor position.  Differs from '&amp;lt; in    &#xA;        that it's updated right away.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And to invoke that you just need:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo line('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;call&lt;/code&gt; is for running functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! func()&#xA;    echo line('.')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you would have something like that in your &lt;code&gt;.vimrc&lt;/code&gt;, then you could use &lt;code&gt;call&lt;/code&gt; like so: &lt;code&gt;:call func()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-09-29T07:15:23.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9742" PostTypeId="2" ParentId="9740" CreationDate="2016-09-29T07:52:34.683" Score="3" Body="&lt;p&gt;You can use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Space&amp;gt; &amp;lt;NOP&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also use &lt;code&gt;Space&lt;/code&gt; as my leader, it does not seem to conflict.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-09-29T07:52:34.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9744" PostTypeId="2" ParentId="9717" CreationDate="2016-09-29T09:16:09.297" Score="5" Body="&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to be a bug in &lt;code&gt;vim&lt;/code&gt; where &lt;code&gt;set nocompatible&lt;/code&gt; is not &lt;a href=&quot;https://en.wikipedia.org/wiki/Idempotence&quot; rel=&quot;nofollow noreferrer&quot;&gt;idempotent&lt;/a&gt; and doesn't follow the &lt;a href=&quot;https://en.wikipedia.org/wiki/Principle_of_least_astonishment&quot; rel=&quot;nofollow noreferrer&quot;&gt;principle of least astonishment&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a workaround, either:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Ensure that you &lt;code&gt;set nocompatible&lt;/code&gt; (or the equivalent &lt;code&gt;set nocp&lt;/code&gt;) only &lt;em&gt;once&lt;/em&gt;, and &lt;em&gt;at the top&lt;/em&gt; of your &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't set it if it's already set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;compatible | set nocompatible | endif &quot; Avoid side effects if `nocp` already set&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation and bug illustration&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27compatible%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help compatible&lt;/code&gt;&lt;/a&gt; (empahsis mine):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is a special kind of option, because when it's set or reset,&#xA;  other options are also changed as a side effect.  &lt;strong&gt;CAREFUL: Setting or&#xA;  resetting this option can have a lot of unexpected effects&lt;/strong&gt;: Mappings&#xA;  are interpreted in another way, undo behaves differently, etc.  If you&#xA;  set this option in your vimrc file, you should probably put it at the&#xA;  very start.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;&amp;amp;viminfo&lt;/code&gt; is &lt;strong&gt;not&lt;/strong&gt; listed in the side-effects, however the following lines clearly show the side effect upon &lt;code&gt;&amp;amp;viminfo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set viminfo+=nWatch-my-viminfo-file-location-be-ignored&#xA;echom &amp;amp;viminfo&#xA;set nocompatible &quot; do side effects even though nocomptible is already set&#xA;echom 'After 2nd &quot;set nocompatible&quot;:'&#xA;echom &amp;amp;viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;'100,&amp;lt;50,s10,h,nWatch-my-viminfo-file-location-be-ignored&#xA;After 2nd &quot;set nocompatible&quot;:&#xA;'100,&amp;lt;50,s10,h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim --version | head -1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 05 2016 16:48:20)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Resolution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have raised two GitHub issues regarding this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim/issues/1132&quot; rel=&quot;nofollow noreferrer&quot;&gt;Undocumented &quot;set nocompatible&quot; side effect upon &amp;amp;viminfo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim/issues/1131&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;set nocompatible&lt;/code&gt; not idempotent - setting produces side effects when already set&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See also StackExchange's question: &lt;a href=&quot;https://stackoverflow.com/questions/6286866/how-to-tell-vim-to-store-the-viminfo-file-somewhere-else&quot;&gt;How to tell VIM to store the viminfo file somewhere else?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-09-29T09:55:13.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9745" PostTypeId="2" ParentId="4056" CreationDate="2016-09-29T10:03:15.847" Score="0" Body="&lt;h1&gt;Jedi&lt;/h1&gt;&#xA;&lt;p&gt;&lt;em&gt;if not using with YCM&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:jedi#auto_close_doc = 0  &amp;quot; close preview window after completion&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8444" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-09-29T10:03:15.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9746" PostTypeId="2" ParentId="8451" CreationDate="2016-09-29T10:42:40.283" Score="5" Body="&lt;p&gt;This does exactly what my original question was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot; Ranger style marks command&#xA;&quot;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;function! Marks()&#xA;    marks&#xA;    echo('Mark: ')&#xA;&#xA;    &quot; getchar() - prompts user for a single character and returns the chars&#xA;    &quot; ascii representation&#xA;    &quot; nr2char() - converts ASCII `NUMBER TO CHAR'&#xA;&#xA;    let s:mark = nr2char(getchar())&#xA;    &quot; remove the `press any key prompt'&#xA;    redraw&#xA;&#xA;    &quot; build a string which uses the `normal' command plus the var holding the&#xA;    &quot; mark - then eval it.&#xA;    execute &quot;normal! '&quot; . s:mark&#xA;endfunction&#xA;&#xA;nnoremap ' :call Marks()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't change the usage of using marks, i.e. setting then jumping to a mark, it simply displays the &lt;code&gt;:marks&lt;/code&gt; listing when you hit the &lt;code&gt;'&lt;/code&gt; character for jumping to the mark.&lt;br&gt;&#xA;Most of the time you will ignore it because you don't need the visual aid and its slower to look at something visually, but when you want a reference its there and it doesn't cost you anything in terms of learning a new mapping, extra keystrokes etc.&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2016-09-29T10:42:40.283" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9747" PostTypeId="1" AcceptedAnswerId="13932" CreationDate="2016-09-29T18:31:16.573" Score="6" ViewCount="349" Body="&lt;p&gt;What command could I use to highlight the error in the location list for the line where the cursor is in normal mode? Ie, the inverse operation of selecting a line in the location list and hitting &lt;code&gt;[enter]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8846" LastActivityDate="2017-10-15T12:13:35.377" Title="How to highlight in location list error for current line" Tags="|neovim|plugin-syntastic|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9748" PostTypeId="1" AcceptedAnswerId="9749" CreationDate="2016-09-29T18:44:35.050" Score="7" ViewCount="210" Body="&lt;p&gt;I have a plugin (a unite sub-module) that filters extremely large textfiles down to generate a helpful 'table of contents'. I would like to provide the user with the ability to enable/disable many of the filters... and I would like that setting to persist through each vim invocation. (instant updates across concurrent sessions is not necessarily needed)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a mechanism for doing this built into vim? Or do I need to create and manage a &quot;dot file&quot; in the user's $HOME? Or is there an accepted standard way of handling this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I can't really just let the user set a global variable in the vimrc, because the list of options is currently several hundred entries long, and the current interface is simply &quot;type d with the index open&quot; to remove from the list.&lt;/p&gt;&#xA;" OwnerUserId="6659" LastEditorUserId="6659" LastEditDate="2016-09-29T19:50:58.260" LastActivityDate="2016-09-29T19:50:58.260" Title="What is the current 'best practice' for persistent preferences for a plugin?" Tags="|plugin-system|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9749" PostTypeId="2" ParentId="9748" CreationDate="2016-09-29T19:03:19.907" Score="6" Body="&lt;p&gt;One way to do it is to have your plugin define a global variable storing the path to that specific &quot;persistent settings/enabled filters&quot; file. This is similar to how various plugins that have to 'cache' some values work. So, the documentation could look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g:myplugin_enabled_filters_path     *g:myplugin_enabled_filters_path*&#xA;    This variable points to the file that stores enabled filters for&#xA;    &amp;lt;myplugin&amp;gt; etc.&#xA;&#xA;    Default value is &quot;$HOME/.myplugin.filters&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;code&gt;$HOME&lt;/code&gt; variable to build a default value for this path, and store your enabled filters there. The users can change the path by changing the above variable in their &lt;code&gt;vimrc&lt;/code&gt;. I assume you intend to offer some means (functions, commands, key maps) to conveniently enable/disable various filters on the fly, while using your plugin (filters which you remember in that file), so that the user doesn't have to deal with them directly. Otherwise, it's simpler to let the user modify a global variable that stores a list/dict etc. of enabled filters (that can &quot;persist&quot; by having the variable saved in &lt;code&gt;vimrc&lt;/code&gt;) and read that instead (as per &lt;a href=&quot;https://vi.stackexchange.com/users/6489/tumbler41&quot;&gt;Tumbler41&lt;/a&gt;'s comment above).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details, you can follow how &lt;a href=&quot;https://github.com/Shougo/neocomplcache.vim/blob/master/doc/neocomplcache.txt#L428&quot; rel=&quot;nofollow noreferrer&quot;&gt;g:neocomplcache_temporary_dir&lt;/a&gt; is defined and used in Shougo's &lt;code&gt;neocomplcache.vim&lt;/code&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you can easily serialize (save/restore) any vim variable (even a dictionary) in that file by using something like &lt;a href=&quot;https://stackoverflow.com/a/31350133/5000478&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-09-29T19:36:12.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9750" PostTypeId="1" CreationDate="2016-09-29T22:28:49.537" Score="0" ViewCount="663" Body="&lt;p&gt;When switching buffers with &lt;code&gt;:e#&lt;/code&gt; or &lt;code&gt;&amp;lt;ctrl&amp;gt;-^&lt;/code&gt;, I commonly see the line with the cursor (the current line) move to the middle of the window (maybe related to the &lt;code&gt;scroll_cursor_halfway&lt;/code&gt; function mentioned &lt;a href=&quot;https://vi.stackexchange.com/questions/8992&quot;&gt;in this question&lt;/a&gt;?).  I'm used to this, and it can be very convenient for visually comparing two slightly different versions of the same file by quickly alternating between them so that a visual &lt;em&gt;beat&lt;/em&gt; is created for any mismatching text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, sometimes it doesn't happen for some unknown reason; the line with the cursor is left on, say, the bottom row of the window, or wherever it was.  I understand why this would happen if I'm near the top or bottom of the buffer's contents.  But can happen even when the current line is in the middle of a large buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does this happen and how can I make it more consistent?&lt;/p&gt;&#xA;" OwnerUserId="9490" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-03-30T16:15:58.913" Title="Current line position when switching buffers" Tags="|cursor-movement|cursor|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9751" PostTypeId="1" AcceptedAnswerId="9752" CreationDate="2016-09-30T05:29:57.547" Score="31" ViewCount="11123" Body="&lt;p&gt;In &lt;a href=&quot;https://vi.stackexchange.com/a/9720/9237&quot;&gt;&lt;strong&gt;&lt;em&gt;this&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; answer I faced the &lt;code&gt;CTRL-U&lt;/code&gt; used in function call after &lt;code&gt;:&lt;/code&gt; and before the actual function name. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;buffer&amp;gt; &amp;lt;cr&amp;gt; :&amp;lt;C-U&amp;gt;call append('.', repeat([''],v:count1))&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is what help says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-U      Scroll window Upwards in the buffer.  The number of&#xA;            lines comes from the scroll option (default: half a&#xA;            screen).  If [count] given, first set the 'scroll'&#xA;            option to [count].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried it myself and it worked as I supposed. But I didn't quite understand the part about the &lt;code&gt;scroll&lt;/code&gt; option. What do they mean &lt;code&gt;'scroll'  option&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And besides it does some strange thing in insert mode. As far as I understood it deletes everything from the cursor to the beginning of the line and then joins the resulting line and the line above.&lt;/p&gt;&#xA;" OwnerUserId="9237" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-09-30T15:50:49.020" Title="Understanding CTRL-U combination" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9752" PostTypeId="2" ParentId="9751" CreationDate="2016-09-30T05:35:52.147" Score="40" Body="&lt;p&gt;Help, by default, returns any mappings that apply to normal mode. In normal mode, &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; &lt;em&gt;does&lt;/em&gt; scroll upwards, but that's not what we're interested in. To see what &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; does in command line mode, or &lt;em&gt;cmode&lt;/em&gt;, (the mode where you type commands starting with a colon) search &lt;code&gt;:h c_CTRL-u&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *c_CTRL-U*&#xA;CTRL-U      Remove all characters between the cursor position and&#xA;        the beginning of the line.  Previous versions of vim&#xA;        deleted all characters on the line.  If that is the&#xA;        preferred behavior, add the following to your .vimrc: &amp;gt;&#xA;            :cnoremap &amp;lt;C-U&amp;gt; &amp;lt;C-E&amp;gt;&amp;lt;C-U&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To understand why this is useful for a normal mode mapping, try removing it, try typing something like &lt;code&gt;5:&lt;/code&gt;, and see what comes up. You should see something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,.+4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a &lt;a href=&quot;https://vi.stackexchange.com/questions/tagged/range&quot;&gt;range&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now try typing &lt;code&gt;5:&amp;lt;C-u&amp;gt;&lt;/code&gt; and see what comes up. You should just see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly in visual mode, pressing &lt;code&gt;:&lt;/code&gt; inserts the range&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's why you'll very frequently see mappings like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap foo :&amp;lt;C-u&amp;gt;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap foo :&amp;lt;C-u&amp;gt;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-09-30T15:50:49.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9753" PostTypeId="1" AcceptedAnswerId="16105" CreationDate="2016-09-30T08:30:11.180" Score="7" ViewCount="1600" Body="&lt;p&gt;I want to wrap my text to 79 characters, I do that using the &lt;code&gt;gq&lt;/code&gt; command. For most filetypes this works just fine and indents following lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With Markdown, however, it does the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZSnvq.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZSnvq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sXhvM.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sXhvM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pattern seems to be that only the second line gets indented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not really nice as it then parses differently. For reStructuredText (&lt;code&gt;:set ft=rst&lt;/code&gt;) it works just fine with longer lines:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/46SYo.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/46SYo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would I have to do to get the same results in Markdown as in reStructuredText?&lt;/p&gt;&#xA;" OwnerUserId="5210" LastActivityDate="2018-05-01T13:16:17.873" Title="Line formatting (gq) does not correctly indent long list items" Tags="|line-breaks|filetype-markdown|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9754" PostTypeId="1" CreationDate="2016-09-30T09:42:52.717" Score="9" ViewCount="12713" Body="&lt;p&gt;I am using vim 7.4.52 in Ubuntu 14.04 LTS.My vim background color is darkblue.&#xA;I set this in .vimrc using &lt;code&gt;set background darkblue&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to set the background color with another color using hex code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any system to set this?&#xA;i.e.&lt;code&gt;set background=#300A24&lt;/code&gt;(this is my default terminal color)&lt;/p&gt;&#xA;" OwnerUserId="9498" LastEditorUserId="1841" LastEditDate="2016-09-30T11:07:54.370" LastActivityDate="2021-06-09T18:48:47.560" Title="how to change vim background color in hex code or rgb color code?" Tags="|vimrc|colorscheme|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9755" PostTypeId="2" ParentId="9754" CreationDate="2016-09-30T10:38:27.337" Score="8" Body="&lt;p&gt;To set the background (and foreground) to some explicit color, you probably want to use a &lt;code&gt;highlight&lt;/code&gt; command in your vimrc, such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; plain text&#xA;hi Normal     ctermfg=227 ctermbg=17&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(assuming you are indeed in a terminal and not a gvim window).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The color codes '227' and '17' are interpreted in the terminal, and, sadly, they are not simple hex codes. To find which colors they correspond to in a given terminal, you can use this little script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/bash   &#xA;for i in {0..255} ; do&#xA;  printf &quot;\x1b[38;5;${i}mcolour${i} &quot;&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2058" LastActivityDate="2016-09-30T10:38:27.337" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9756" PostTypeId="2" ParentId="9700" CreationDate="2016-09-30T11:18:50.313" Score="2" Body="&lt;p&gt;Thanks for all the upvotes to my original question! I've now incorporated a &lt;code&gt;:SubstituteChoices&lt;/code&gt; command into my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4602&quot; rel=&quot;nofollow&quot;&gt;PatternsOnText plugin&lt;/a&gt;, which provides a robust implementation. The example in the question would be solved via:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%SubstituteChoices/person:/woman:/man:/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-30T11:18:50.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9757" PostTypeId="1" AcceptedAnswerId="20170" CreationDate="2016-09-30T11:35:30.147" Score="2" ViewCount="2509" Body="&lt;p&gt;I am using Vundle on Windows gVim. I have a plugin that I am writing myself called hotdogstand that is stored in my local filesystem at &lt;code&gt;vimfiles\hotdogstand&lt;/code&gt;, and it is not tied to a Github repository. How do I load this plugin in Vundle? I tried using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'file:///Users/snrub/vimfiles/bundle/Vundle.vim/hotdogstand/colors'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the Vundle log gives the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[2016-09-30 11:50:22] Plugin file:///Users/snrub/vimfiles/bundle/Vundle.vim/hotdogstand&#xA;[2016-09-30 11:50:22] $ git clone --recursive &quot;file:///Users/snrub/vimfiles/bundle/Vundle.vim/hotdogstand&quot; &quot;C:\Users\snrub\vimfiles\bundle\Vundle.vim\hotdogstand&quot;&#xA;[2016-09-30 11:50:22] &amp;gt; Cloning into 'C:\Users\snrub\vimfiles\bundle\Vundle.vim\hotdogstand'...&#xA;[2016-09-30 11:50:22] &amp;gt; fatal: 'C:/Users/snrub/AppData/Local/Programs/Git/Users/snrub/vimfiles/bundle/Vundle.vim/hotdogstand' does not appear to be a git repository&#xA;[2016-09-30 11:50:22] &amp;gt; fatal: Could not read from remote repository.&#xA;[2016-09-30 11:50:22] &amp;gt; &#xA;[2016-09-30 11:50:22] &amp;gt; Please make sure you have the correct access rights&#xA;[2016-09-30 11:50:22] &amp;gt; and the repository exists.&#xA;[2016-09-30 11:50:22] &amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even if I go into File Explorer and create the &lt;code&gt;C:/Users/snrub/AppData/Local/Programs/Git/Users/snrub/vimfiles/bundle/Vundle.vim/hotdogstand&lt;/code&gt; folder and place my vim files in there, I still get the &quot;does not appear to be a Git repository&quot; error. &lt;/p&gt;&#xA;" OwnerUserId="9047" LastEditorUserId="51" LastEditDate="2016-10-07T01:15:40.020" LastActivityDate="2023-03-23T15:41:45.890" Title="How do you add a local plugin in Vundle on Windows?" Tags="|microsoft-windows|plugin-vundle|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9758" PostTypeId="2" ParentId="9757" CreationDate="2016-09-30T11:48:27.220" Score="3" Body="&lt;p&gt;From the Vundle &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow&quot;&gt;README&lt;/a&gt; and from &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim/blob/master/doc/vundle.txt#L92-L93&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h vundle-faq&lt;/code&gt;&lt;/a&gt; too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; git repos on your local machine (i.e. when working on your own plugin)&#xA;Plugin 'file:///home/gmarik/path/to/plugin'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add these lines to your vimrc and then manage the plugin as the other ones with &lt;code&gt;:PluginInstall&lt;/code&gt; and sisters commands.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-09-30T14:34:27.940" LastActivityDate="2016-09-30T14:34:27.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9759" PostTypeId="1" AcceptedAnswerId="9761" CreationDate="2016-09-30T12:20:08.483" Score="4" ViewCount="308" Body="&lt;p&gt;After I visually select the following area&#xA;&lt;a href=&quot;https://i.stack.imgur.com/lr2Mu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lr2Mu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And press Esc and move this position&#xA;&lt;a href=&quot;https://i.stack.imgur.com/QrKYr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QrKYr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to select the same shape in this manner&#xA;&lt;a href=&quot;https://i.stack.imgur.com/UwB1u.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UwB1u.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is no generic and direct way to do this, any tips on how to code a vimscript function for this will also be helpful.&lt;/p&gt;&#xA;" OwnerUserId="230" LastActivityDate="2016-09-30T12:38:49.633" Title="Is there a way in Vim to draw the visual area of the same size as the last visual selection, but at a new cursor position?" Tags="|visual-mode|visual-block|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9760" PostTypeId="1" CreationDate="2016-09-30T12:29:21.543" Score="31" ViewCount="39252" Body="&lt;p&gt;When I hit the arrow keys in insert mode I get characters instead of navigation:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TeW9I.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TeW9I.gif&quot; alt=&quot;Pressing arrow keys types characters&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'd like to be able to use the arrow keys to navigate.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;Things I've tried&lt;/h1&gt;&#xA;&lt;p&gt;I have &lt;code&gt;set nocompatible&lt;/code&gt; in my &lt;code&gt;~/.vimrc&lt;/code&gt; (&lt;a href=&quot;http://pastebin.com/Zuu5eRwg&quot; rel=&quot;noreferrer&quot;&gt;vimrc pastebin&lt;/a&gt;), I am using pathogen and here is my &lt;code&gt;~/.vim/bundle&lt;/code&gt; directory:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;YouCompleteMe/&#xA;emmet-vim/&#xA;nerdtree/&#xA;node/&#xA;vim-airline/&#xA;vim-markdown/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The problem only started recently, can't remember the cause.&lt;/p&gt;&#xA;&lt;p&gt;Some recommend &lt;code&gt;:set term=builtin_ansi&lt;/code&gt;, and this fixes the problem but removes all my colors.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 29 2016 12:51:13)&#xA;MacOS X (unix) version&#xA;Included patches: 1-2290&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;http://pastebin.com/5z1HbpqW&quot; rel=&quot;noreferrer&quot;&gt;http://pastebin.com/5z1HbpqW&lt;/a&gt; for the whole output.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ echo $TERM&#xA;xterm-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and in vim:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set compatible?&#xA;nocompatible&#xA;&#xA;:set term?&#xA;term=xterm-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2022-10-28T11:24:20.957" Title="arrow keys don't work in insert mode" Tags="|insert-mode|" AnswerCount="9" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="9761" PostTypeId="2" ParentId="9759" CreationDate="2016-09-30T12:38:49.633" Score="8" Body="&lt;p&gt;Yes, this feature is there, but it's a bit hidden. From &lt;code&gt;:help v&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[count]v            Start Visual mode per character.&#xA;                    With [count] select the same number of characters or&#xA;                    lines as used for the last Visual operation, but at&#xA;                    the current cursor position, multiplied by [count].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, if you specify a count of 1 (&lt;code&gt;1v&lt;/code&gt;), the same number of character as the last selection had is used, but at the current cursor position.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-09-30T12:38:49.633" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9762" PostTypeId="1" AcceptedAnswerId="9763" CreationDate="2016-09-30T13:01:07.740" Score="5" ViewCount="1398" Body="&lt;p&gt;I would like to map &lt;code&gt;&amp;lt;End&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Home&amp;gt;&lt;/code&gt; to go to the end or beginning of the current line (not the screen), even if the cursor is on a wrapped line: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|1 First line.      |&#xA;|2 This is some very| &amp;lt;- Wrapped line &#xA;|  long text        |&#xA;|3                  |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So here what should be the mappings: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Home&amp;gt;  Cursor go to the first letter of visible line (wrapped or not).&#xA;&amp;lt;End&amp;gt;   Cursor go beyond the last letter of visible line (wrapped or not).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An important thing is that I use &lt;code&gt;virtualedit&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set virtualedit=all&#xA;noremap &amp;lt;Up&amp;gt; gk&#xA;noremap &amp;lt;Down&amp;gt; gj&#xA;noremap k gk&#xA;noremap j gj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For a normal line, this can be solved using these mappings: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;End&amp;gt; $l&#xA;noremap &amp;lt;Home&amp;gt; 0&#xA;&quot;i_&amp;lt;End&amp;gt; already mapped&#xA;&quot;i_&amp;lt;Home&amp;gt; already mapped&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However on a wrapped line none of the above mappings work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here below the cases that must work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|1 First line.       | Initial                   &#xA;       ^&#xA;|1 First line.       | &amp;lt;Home&amp;gt;                    (1)&#xA;   ^      &#xA;|1 First line.       | &amp;lt;End&amp;gt;                     (2)&#xA;              ^&#xA;|1 First line.       | &amp;lt;Home&amp;gt;                    &#xA;   ^                   l&amp;lt;Down&amp;gt;&#xA;|2 This is some very |                           &#xA;    ^&#xA;|2 This is some very | &amp;lt;End&amp;gt;                    (3)&#xA;                    ^&#xA;|2 This is some very | &amp;lt;Home&amp;gt;                    (4)&#xA;   ^                   l&amp;lt;Down&amp;gt;&#xA;|  long text         |                           &#xA;    ^ &#xA;|  long text         | &amp;lt;Home&amp;gt;                    (5)&#xA;   ^&#xA;|  long text         | &amp;lt;End&amp;gt;                     (6)&#xA;            ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The solution proposed by &lt;a href=&quot;https://vi.stackexchange.com/users/1841/statox&quot;&gt;statox&lt;/a&gt; in his answer works for &lt;code&gt;&amp;lt;Home&amp;gt;&lt;/code&gt;, but not really for &lt;code&gt;&amp;lt;End&amp;gt;&lt;/code&gt;. So, I added a &lt;code&gt;l&lt;/code&gt; to the &lt;code&gt;&amp;lt;End&amp;gt;&lt;/code&gt; mapping. Then all the cases pass, but (3) that goes on the next line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt;  :set virtualedit=&amp;lt;CR&amp;gt;g$:set virtualedit=all&amp;lt;CR&amp;gt;l &#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; :set virtualedit=&amp;lt;CR&amp;gt;g0:set virtualedit=all&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Most editors solve case (3) by adding a virtual blank column at the end of the screen, so the cursor can be virtually placed here in this particular case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve the same behavior in Vim?&lt;/p&gt;&#xA;" OwnerUserId="2548" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-09-30T20:26:00.140" Title="How to go to the end of the line even in on a wrapped line?" Tags="|cursor-movement|wrapping|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9763" PostTypeId="2" ParentId="9762" CreationDate="2016-09-30T13:03:33.543" Score="10" Body="&lt;p&gt;You're looking for &lt;code&gt;g0&lt;/code&gt; and &lt;code&gt;g$&lt;/code&gt; which are the equivalent of &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt; for wrapped lines. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#g0&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h g0&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#g$&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h g$&lt;/code&gt;&lt;/a&gt; and even &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#g%5E&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h g^&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To quote the doc about &lt;code&gt;g$&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When lines wrap ('wrap' on): To the last character of&#xA;  the screen line and [count - 1] screen lines downward&#xA;  |inclusive|.  Differs from &quot;$&quot; when a line is wider&#xA;  than the screen.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When lines don't wrap ('wrap' off): To the rightmost&#xA;  character of the current line that is visible on the&#xA;  screen.  Differs from &quot;$&quot; when the last character of&#xA;  the line is not on the screen or when a count is used.&#xA;  Additionally, vertical movements keep the column,&#xA;  instead of going to the end of the line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About the &lt;code&gt;virtualedit&lt;/code&gt; option maybe you could try something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;end&amp;gt; :set virtualedit=&amp;lt;CR&amp;gt;g$:set virtualedit=all&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mapping can be explained like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap                   Create a normal mode mapping&#xA;&amp;lt;silent&amp;gt;                   Make the mapping silent to avoid messages in the command line&#xA;&amp;lt;end&amp;gt;                      The key to map&#xA;:set virtualedit=&amp;lt;CR&amp;gt;      Unset virtualedit&#xA;g$                         Use g$ normally&#xA;:set virtualedit=all&amp;lt;CR&amp;gt;   Set the virtualedit option again&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-09-30T13:37:51.897" LastActivityDate="2016-09-30T13:37:51.897" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9764" PostTypeId="1" CreationDate="2016-09-30T17:22:02.370" Score="1" ViewCount="262" Body="&lt;p&gt;When making a digraph, I can't seem use the &lt;code&gt;¨&lt;/code&gt; symbol without getting an &lt;code&gt;E39: Number expected&lt;/code&gt;. This error is there even when escaping it with a backslash. &lt;/p&gt;&#xA;" OwnerUserId="5285" LastActivityDate="2017-01-04T15:17:07.963" Title="How do you make a digraph containing a ¨?" Tags="|digraphs|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9765" PostTypeId="2" ParentId="9750" CreationDate="2016-09-30T17:41:32.350" Score="1" Body="&lt;p&gt;I can't answer why it happens, but the way I'm currently making it more consistent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;SPACE&amp;gt; :e#&amp;lt;CR&amp;gt;z.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This maps the spacebar to switch to the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#alternate-file&quot; rel=&quot;nofollow&quot;&gt;alternate file&lt;/a&gt;, then move the line with the cursor to the middle of the screen and finally move to the first position in the line.&lt;/p&gt;&#xA;" OwnerUserId="9490" LastActivityDate="2016-09-30T17:41:32.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9766" PostTypeId="1" AcceptedAnswerId="9768" CreationDate="2016-09-30T17:43:50.407" Score="3" ViewCount="623" Body="&lt;p&gt;I have three macros that I have created separately over time. &lt;code&gt;a&lt;/code&gt; performs a search and replace, &lt;code&gt;b&lt;/code&gt; adds tags to every line and &lt;code&gt;c&lt;/code&gt; appends text at the beginning and the end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I execute them like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;@a&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%norm! @b&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;@c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I execute them in this order without starting each one separately?&lt;/p&gt;&#xA;" OwnerUserId="1328" LastEditorUserId="2920" LastEditDate="2016-09-30T20:56:58.353" LastActivityDate="2016-09-30T20:56:58.353" Title="How to execute several macros with one command?" Tags="|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9767" PostTypeId="1" AcceptedAnswerId="9770" CreationDate="2016-09-30T17:44:19.740" Score="4" ViewCount="3010" Body="&lt;p&gt;I'm searching for a way to update all my vim plugins with pathogen. I see this is simple in other package managers like Neobundle or vundle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please share a way to update all my plugins without having to use some hacky script that I haven't thought of yet to accomplish this.&lt;/p&gt;&#xA;" OwnerUserId="6071" LastEditorUserId="10604" LastEditDate="2019-12-23T22:23:35.180" LastActivityDate="2019-12-23T22:23:35.180" Title="How to update vim plugins with pathogen package manager?" Tags="|plugin-system|plugin-pathogen|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9768" PostTypeId="2" ParentId="9766" CreationDate="2016-09-30T18:18:25.153" Score="4" Body="&lt;p&gt;Since you are using a macros why not use another macro to execute the other three!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @q = &quot;@a:norm! @b\&amp;lt;cr&amp;gt;@c&quot;&#xA;@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I am using &lt;code&gt;:let&lt;/code&gt; to set the &lt;code&gt;q&lt;/code&gt; register here, but you could just as easily record a macro with &lt;code&gt;q&lt;/code&gt;, e.g. &lt;code&gt;qq@a:norm! @b^M@cq&lt;/code&gt; (where &lt;code&gt;^M&lt;/code&gt; is pressing &lt;kbd&gt;return&lt;/kbd&gt;).&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-09-30T18:18:25.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9769" PostTypeId="2" ParentId="9766" CreationDate="2016-09-30T18:19:42.233" Score="4" Body="&lt;p&gt;You can execute all of them in a single normal command. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:normal @a:%norm! @b^M@c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;^M&lt;/code&gt; is a literal carriage return, and is typed by pressing &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt;, &lt;em&gt;not&lt;/em&gt; the literal text &lt;code&gt;^M&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-09-30T18:19:42.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9770" PostTypeId="2" ParentId="9767" CreationDate="2016-09-30T18:35:37.900" Score="7" Body="&lt;p&gt;pathogen manages the run time path of Vim.  It is not the same as vim-plug nor vundle.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers&quot;&gt;differences between the vim plugin managers&lt;/a&gt; has many good answers.  :-) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://gist.github.com/romainl/9970697&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to use Tim Pope's Pathogen&lt;/a&gt; was created by romainl who has a lot of reputation on this site.  I hope that helps.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-09-30T18:54:13.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9771" PostTypeId="2" ParentId="9767" CreationDate="2016-09-30T18:39:04.097" Score="6" Body="&lt;p&gt;Pathogen is not a plugin &lt;em&gt;manager&lt;/em&gt; at all. Updating your plugins is &lt;em&gt;your&lt;/em&gt; job and the best method depends entirely on how &lt;em&gt;you&lt;/em&gt; installed those plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want an actual plugin &lt;em&gt;manager&lt;/em&gt;, try Neobundle, Vundle, Plug, etc.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-09-30T18:39:04.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9772" PostTypeId="1" AcceptedAnswerId="9773" CreationDate="2016-09-30T21:17:47.503" Score="0" ViewCount="2333" Body="&lt;p&gt;In insert mode I want to delete all text from the cursor to the beginning of a line and stay in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the mapping I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap DD &amp;lt;ESC&amp;gt;c0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this &lt;em&gt;almost&lt;/em&gt; works. In the following line (in &lt;strong&gt;&lt;em&gt;insert mode&lt;/em&gt;&lt;/strong&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a test line &#xA;              ^&#xA;           cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in insert mode cursor goes 1 step further than just typed symbol (&lt;strong&gt;&lt;em&gt;t&lt;/em&gt;&lt;/strong&gt; in my case). And if I press &lt;strong&gt;&lt;em&gt;DD&lt;/em&gt;&lt;/strong&gt;, I will get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but want just&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; line&#xA;^&#xA;cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;with&lt;/em&gt;&lt;/strong&gt; the space the cursor pointed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this in vim?&lt;/p&gt;&#xA;" OwnerUserId="9237" LastActivityDate="2016-09-30T23:23:18.800" Title="Delete from cursor to the beginning of a line in insert mode" Tags="|key-bindings|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9773" PostTypeId="2" ParentId="9772" CreationDate="2016-09-30T23:23:18.800" Score="2" Body="&lt;p&gt;There's actually already a builtin for this. &lt;code&gt;:h i_&amp;lt;C-u&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                *i_CTRL-U*&#xA;CTRL-U          Delete all entered characters in the current line (see&#xA;    |i_backspacing| about joining lines).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could map this, e.g. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap DD &amp;lt;C-u&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this might interfere with typing. I would encourage you to just learn to use &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; instead. &lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-09-30T23:23:18.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9774" PostTypeId="1" CreationDate="2016-10-01T03:25:47.187" Score="2" ViewCount="623" Body="&lt;p&gt;I am a vim user looking for help for a problem with my vim colorscheme. When I start everything looks fine and is usable until I start scrolling down. Once I scroll the background takes on the color of the terminal background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The terminal I use is gnome-terminal on Fedora 24&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To show the clear difference I made my gnome terminal clear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim Before Scroll: &#xA;&lt;a href=&quot;https://i.stack.imgur.com/IXlgJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IXlgJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After Scroll: &#xA;&lt;a href=&quot;https://i.stack.imgur.com/5YyE7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5YyE7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my .vimrc and its setup to be simple hopefully :D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/TheGalacticNinja/vimrc/blob/master/.vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/TheGalacticNinja/vimrc/blob/master/.vimrc&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9512" LastEditorUserId="51" LastEditDate="2016-10-02T11:17:47.983" LastActivityDate="2018-05-24T20:19:18.057" Title="Problem With ColorScheme" Tags="|colorscheme|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9775" PostTypeId="1" AcceptedAnswerId="9779" CreationDate="2016-10-01T06:27:36.330" Score="1" ViewCount="58" Body="&lt;p&gt;I'm trying to write a mapping that will copy the text and automatically unwrap it at the same time. Here's what I got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CopyUnwrapped(type, ...)&#xA;    if a:0&#xA;        normal! gv&quot;ay&#xA;    else&#xA;        normal! `[v`]&quot;ay&#xA;    endif&#xA;    new&#xA;    setlocal buftype=nofile bufhidden=hide noswapfile nobuflisted&#xA;    normal! &quot;ap&#xA;    %normal! vipJ&#xA;    normal! ggvG$&quot;+y&#xA;    q&#xA;endfunction&#xA;&#xA;vnoremap &amp;lt;leader&amp;gt;y :call CopyUnwrapped(visualmode(), 1)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;y :set opfunc=CopyUnwrapped&amp;lt;CR&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works almost perfectly… works fine in visual mode as far as I can tell. But when I try &lt;code&gt;&amp;lt;leader&amp;gt;yip&lt;/code&gt;, for instance, the last line of the paragraph is cut off, I don't understand why. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="7642" LastActivityDate="2016-10-01T13:35:16.697" Title="Problem mapping operator" Tags="|key-bindings|vimscript|map-operator|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9776" PostTypeId="1" AcceptedAnswerId="9780" CreationDate="2016-10-01T09:05:42.070" Score="4" ViewCount="1532" Body="&lt;p&gt;Consider something like this&#xA;&lt;code&gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;( F(a&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;vi(:^Uexecute&quot;'&amp;lt;,'&amp;gt;s/,/,\r/gg&quot;&amp;lt;cr&amp;gt;=i(k$%i,&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;%:nohlsearch&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&#xA;It expands arguments of a function in lines. (You can run it on &lt;code&gt;(a, b, c, d)&lt;/code&gt; for example.)&#xA;The problem is things happen in front of my eyes while I expect it to happen in background and only show me the final result. I just thought maybe there's a way to make vim do some commands in background and just show the final result on screen.&lt;/p&gt;&#xA;" OwnerUserId="7153" LastEditorUserId="54" LastEditDate="2016-10-01T14:39:49.700" LastActivityDate="2016-10-01T14:39:49.700" Title="Ability to make vim run commands in background and only show the final result on screen" Tags="|vimscript|neovim|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9777" PostTypeId="2" ParentId="9776" CreationDate="2016-10-01T10:14:52.427" Score="0" Body="&lt;p&gt;AFAIK, we can't run vim commands in background. At best we can run external processes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or may be start another vim process and ask it to do thing through client-server mode. But if you want to transform the current text, it won't work very well IMO&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-10-01T10:14:52.427" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9778" PostTypeId="2" ParentId="9776" CreationDate="2016-10-01T10:47:37.587" Score="3" Body="&lt;p&gt;First, the right hand side of your mapping has errors so it can't do anything useful in its current state. Here is a fixed version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;( F(a&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;vi(:'&amp;lt;,'&amp;gt;s/,/,\r/g&amp;lt;cr&amp;gt;=i(k$%i,&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;%:nohlsearch&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second, that mapping is instantaneous so there's no need to run anything in the background at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Rjr7U.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Rjr7U.gif&quot; alt=&quot;seeing is believing&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-10-01T12:34:50.410" LastActivityDate="2016-10-01T12:34:50.410" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9779" PostTypeId="2" ParentId="9775" CreationDate="2016-10-01T13:35:16.697" Score="4" Body="&lt;p&gt;If you look at example in documentation for &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#g@&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;g@&lt;/code&gt;&lt;/a&gt;, you can notice that your function is missing handling of a linewise selection. &lt;code&gt;ip&lt;/code&gt; motion apparently acts as a linewise in this case and if you handle it as characterwise only first character of the last line is copied (because that's where &lt;code&gt;`]&lt;/code&gt; is positioned; do &lt;code&gt;vipv&lt;/code&gt; on a paragraph to see it for yourself).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus that &lt;code&gt;if&lt;/code&gt;-statement should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if a:0&#xA;    normal! gv&quot;ay&#xA;elseif a:type == 'line'&#xA;    normal! `[V`]&quot;ay&#xA;else&#xA;    normal! `[v`]&quot;ay&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that for linewise selection, &lt;code&gt;V&lt;/code&gt; is used to select by lines (which quotes are used is irrelevant for this kind of selection).&lt;/p&gt;&#xA;" OwnerUserId="860" LastActivityDate="2016-10-01T13:35:16.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9780" PostTypeId="2" ParentId="9776" CreationDate="2016-10-01T14:27:32.743" Score="5" Body="&lt;p&gt;To avoid &quot;seeing&quot; the effect of each command run from a map or macro, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set lazyredraw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.. so that the screen is only redrawn once at the end - which makes the whole process (much) faster (see &lt;code&gt;:h lz&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-10-01T14:27:32.743" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9781" PostTypeId="1" CreationDate="2016-10-01T16:47:56.853" Score="3" ViewCount="508" Body="&lt;p&gt;I'm on linux and I'm querying the list of files open in a gvim server so I can pull it up with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --servername &amp;lt;name&amp;gt; --remote &amp;lt;file&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To do so, I wrote a helper function that returns buffers&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! returnbufferlist()&#xA;    execute &quot;silent redir @m&quot;&#xA;    execute &quot;silent buffers&quot;&#xA;    execute &quot;silent redir END&quot;&#xA;    &quot;execute &quot;&amp;lt;ESC&amp;gt;&amp;lt;ESC&amp;gt;&quot;&#xA;    let a=@m&#xA;    return a&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My external script loops through all gvim servers, and runs&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --remote-expr 'returnbufferlist()'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I check my filename against the list of buffers, and if it's open in the server, I run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --servername &amp;lt;name&amp;gt; --remote &amp;lt;file&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as above. Is there a more efficient way of doing this? Is there a dbus interface that allows me to do the same thing more efficiently? Now I'm doing some regex matching that's trying to match my filename with the bufferlist, and this doesn't always work as intended since buffers are not listed with full paths.&lt;/p&gt;&#xA;" OwnerUserId="9514" LastActivityDate="2016-10-03T02:03:45.970" Title="Externally query a vim server to list the open buffers in it" Tags="|buffers|clientserver|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9782" PostTypeId="2" ParentId="4523" CreationDate="2016-10-01T18:00:47.080" Score="6" Body="&lt;p&gt;You can add your own syntax rules to e.g. &lt;code&gt;~/.vim/after/syntax/tex.vim&lt;/code&gt;. In order to prevent spell checking inside a command such as &lt;code&gt;\url&lt;/code&gt;, you can use the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match texStatement '\\command' nextgroup=texMyCommand&#xA;syntax region texMyCommand matchgroup=Delimiter start='{' end='}' contained contains=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;texStatement&lt;/code&gt; and &lt;code&gt;Delimiter&lt;/code&gt; are groups that are defined by the internal syntax plugin, see &lt;code&gt;:e $VIMRUNTIME/syntax/tex.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to understand the above commands, I can recommend the following help sections:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-match&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h syn-match&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-region&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h syn-region&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-spell&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h syn-spell&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/spell.html#spell-syntax&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h spell-syntax&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-10-01T18:00:47.080" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9783" PostTypeId="1" AcceptedAnswerId="9784" CreationDate="2016-10-01T19:25:07.497" Score="2" ViewCount="253" Body="&lt;p&gt;I have several useful search, search and replace and global commands written in my personal Vim reference. How can I easily turn &lt;em&gt;some&lt;/em&gt; of them into &lt;em&gt;one&lt;/em&gt; macro without recording (retyping everything)? &lt;/p&gt;&#xA;" OwnerUserId="1328" LastActivityDate="2016-10-05T01:49:46.837" Title="How to turn several commands into a macro without recording?" Tags="|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9784" PostTypeId="2" ParentId="9783" CreationDate="2016-10-01T20:17:17.590" Score="8" Body="&lt;p&gt;Well, if you want turn them into a &lt;em&gt;macro&lt;/em&gt; specifically, then this is pretty easy to do. The thing you need to know about macro registers is that they are exactly the same as text registers that you cut/copy/paste from. So if you had the following text on a line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iHello&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you wanted to turn this into a macro, you could just go to the beginning of the line, type &lt;code&gt;&quot;aD&lt;/code&gt; (delete line into register 'a'). Now, you can type &lt;code&gt;@a&lt;/code&gt; and this will run that text as a macro, exactly the same as if you had recorded it. There's an even easier way to do the same thing, which is to directly assign the register. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=&quot;iHello\&amp;lt;esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg('a', &quot;iHello\&amp;lt;esc&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'm guessing there is a simpler way to do what you want. If you just have some functions, or sets of keystrokes that you would like to be able to easily call, you could just make a new mapping. Preferably with &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; to avoid conflicting with other mappings. Like &lt;a href=&quot;https://vi.stackexchange.com/a/845/2920&quot;&gt;this answer said&lt;/a&gt;, leader is essentially a namespace for your own mappings. I would add something like this to your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;h iHello&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if you would really prefer a macro, you could simply add &lt;code&gt;let @a&lt;/code&gt; or &lt;code&gt;setreg&lt;/code&gt; like I demonstrated.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-10-05T01:49:46.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9786" PostTypeId="1" CreationDate="2016-10-01T21:11:52.733" Score="18" ViewCount="869" Body="&lt;p&gt;If I have a magic Vim regex in a string literal, is there a way to convert the whole regex into an alternative representation that uses a different magic mode, so I could paste that equivalent regex into source code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if I want to convert this magic-mode pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'\m-\=\&amp;lt;\d\+L\=\&amp;gt;\|0[xX][0-9a-fA-F]\+\&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to very-magic-mode to make it more readable, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'\v-=&amp;lt;\d+L=&amp;gt;|0[xX][0-9a-fA-F]+&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I often make mistakes trying to convert them by hand.&lt;/p&gt;&#xA;" OwnerUserId="824" LastEditorUserId="51" LastEditDate="2016-10-04T00:10:43.363" LastActivityDate="2022-04-02T15:10:49.000" Title="Is there a way to convert a Vim regex literal to different magic modes?" Tags="|regular-expression|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="9788" PostTypeId="2" ParentId="9781" CreationDate="2016-10-02T09:43:00.310" Score="2" Body="&lt;p&gt;You could use your own code to list the buffers, instead of &lt;code&gt;execute &quot;silent buffers&quot;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(1, bufnr('$'))&#xA;  if buflisted(i)&#xA;    echo i . ' ' . fnamemodify(bufname(i), ':p')&#xA;  endif&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;fnamemodify()&lt;/code&gt; with &lt;code&gt;':p'&lt;/code&gt; will give you the full path to each filename.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The check for &lt;code&gt;&amp;amp;buflisted&lt;/code&gt; will avoid listing buffers which have been closed, help buffers, and other buffers which have unlisted themselves, such as the MiniBufExplorer plugin.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2016-10-03T02:03:45.970" LastActivityDate="2016-10-03T02:03:45.970" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9789" PostTypeId="2" ParentId="9156" CreationDate="2016-10-03T04:25:36.877" Score="1" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;For a while I used nobe4's technique like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;b :set nomore&amp;lt;Bar&amp;gt;:ls&amp;lt;Bar&amp;gt;:set more&amp;lt;CR&amp;gt;:b&amp;lt;Space&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then I started using Tab-completion with that (as romainl suggests)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;But more recently I have found the fastest method with the &lt;strong&gt;fewest keystrokes&lt;/strong&gt; is to use:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#CTRL-%5E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;{count} CTRL-^&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is not so different from &lt;code&gt;:b#&amp;lt;Enter&amp;gt;&lt;/code&gt; but as you say, you &lt;em&gt;need to know&lt;/em&gt; the buffer number!&lt;/p&gt;&#xA;&lt;p&gt;So for that I run the &lt;a href=&quot;https://github.com/fholgado/minibufexpl.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;MiniBufExplorer&lt;/a&gt; plugin, which displays a list of filenames across the top (like almost every other editor).  I'm sure there are numerous alternatives.&lt;/p&gt;&#xA;&lt;p&gt;Finally, since &lt;kbd&gt;Ctrl-^&lt;/kbd&gt; is a bit of a stretch for my fingers, and this is a very common operation, I moved it over to &lt;kbd&gt;Ctrl-E&lt;/kbd&gt;. The &lt;a href=&quot;https://github.com/joeytwiddle/rc_files/blob/9313a52b14e02dffd264c9fad069adfdd1e94463/.vim/plugin/joeys_buffer_switcher.vim#L37:L41&quot; rel=&quot;nofollow noreferrer&quot;&gt;implementation for that&lt;/a&gt; is not too complex:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-E&amp;gt; :&amp;lt;C-U&amp;gt;call SwitchToBuffer()&amp;lt;CR&amp;gt;&#xA;&#xA;function! SwitchToBuffer()&#xA;  if v:count &amp;gt; 0&#xA;    exec v:count . &amp;quot;b&amp;quot;&#xA;    return&#xA;  endif&#xA;&#xA;  &amp;quot; Whatever you want to do if you didn't provide a count&#xA;  &amp;quot; In this case, fall back to nobe4's technique:&#xA;  call feedkeys(&amp;quot;:ls\n:b &amp;quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So my current buffer switching process goes something like this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Look at MiniBufExplorer&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;kbd&gt;3&lt;/kbd&gt; &lt;kbd&gt;Ctrl-E&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Sadly MBE and the script above are not Vim builtins, as you requested.  When I'm on a remote machine with no config, I just use &lt;code&gt;:b [partial]&lt;/code&gt; and Tab-completion.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-10-03T04:30:42.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9790" PostTypeId="1" AcceptedAnswerId="9792" CreationDate="2016-10-03T09:09:58.537" Score="0" ViewCount="622" Body="&lt;p&gt;I use vim-pandoc for markdown editing but it adds red backgrounds to almost every words. Is it an spellchecking issue ? how can I disable this ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[&lt;img src=&quot;https://i.stack.imgur.com/X2kaP.png&quot; alt=&quot;red background[1]&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4542" LastActivityDate="2016-10-04T09:37:08.117" Title="Vim pandoc red background" Tags="|spell-checking|plugin-vim-pandoc|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9791" PostTypeId="1" CreationDate="2016-10-03T18:41:27.530" Score="1" ViewCount="310" Body="&lt;p&gt;I have an issue where the signs in my sign column are cut off in the middle (screenshot below).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GukUg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GukUg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changing the Guifont or the font size doesn't seem to matter. It looks fine in terminal neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using neovim 0.1.5 and neovim-qt on macOS 10.10.5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="14" LastEditorUserId="23502" LastEditDate="2022-09-16T16:14:18.833" LastActivityDate="2022-09-16T16:14:18.833" Title="Sign column font is cut off" Tags="|neovim|macos|font|neovim-qt|signs|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9792" PostTypeId="2" ParentId="9790" CreationDate="2016-10-04T00:09:34.953" Score="1" Body="&lt;p&gt;You can disable spell checking with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nospell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-10-04T00:09:34.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9793" PostTypeId="1" CreationDate="2016-10-04T02:05:53.200" Score="3" ViewCount="91" Body="&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;QString QSSMLTools::heather(QString s)&#xA;{&#xA;    if (!m_Enable) {return s;}&#xA;&#xA;    s.insert(0,&quot;&amp;lt;voice name='Heather'&amp;gt;&quot;);&#xA;    s.append(&quot;&amp;lt;/voice&amp;gt;&quot;);&#xA;    return s;&#xA;}&#xA;QString QSSMLTools::isabella(QString s)&#xA;{&#xA;    if (!m_Enable) {return s;}&#xA;&#xA;    s.insert(0,&quot;&amp;lt;voice name='Isabella'&amp;gt;&quot;);&#xA;    s.append(&quot;&amp;lt;/voice&amp;gt;&quot;);&#xA;    return s;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Placing my cursor over &lt;code&gt;v&lt;/code&gt; on &lt;code&gt;s.insert(0,&quot;&amp;lt;oice name='Heather'&amp;gt;&quot;);&#xA;&lt;/code&gt; and pressing &lt;kbd&gt;*&lt;/kbd&gt; will give me &lt;code&gt;&lt;/code&gt;, highlighting 4 selections:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s.insert(0,&quot;&amp;lt; name='Heather'&amp;gt;&quot;);&#xA;s.append(&quot;&amp;lt;/&amp;gt;&quot;);&#xA;s.insert(0,&quot;&amp;lt; name='Isabella'&amp;gt;&quot;);&#xA;s.append(&quot;&amp;lt;/&amp;gt;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;**&lt;/kbd&gt; should give me &lt;code&gt;voice name&lt;/code&gt; highlighting two sections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;***&lt;/kbd&gt; should give me &lt;code&gt;voice name='&lt;/code&gt; highlighting two sections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;****&lt;/kbd&gt; should give me &lt;code&gt;voice name='Heather&lt;/code&gt; highlighting one section.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can this behaviour be achieved?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2016-10-04T08:58:20.930" Title="How do I map *, so after each recurrent press, it expands its selection one word over?" Tags="|key-bindings|vimrc|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9794" PostTypeId="2" ParentId="9793" CreationDate="2016-10-04T03:30:01.537" Score="4" Body="&lt;p&gt;You can do this with two mappings, a normal mode mapping, and a visual mode mapping. Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap * viw&#xA;xnoremap * wiw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one is pretty straightforward. It starts visual mode (&lt;code&gt;v&lt;/code&gt;), and selects (i)nside of the current (w)ord. Then, the second time you hit it, the other mapping applies since we will no longer be in normal mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So on the second press, it moves forward one word, (now the selection is &lt;code&gt;voice n&lt;/code&gt;) then again, selects (i)nside of the current (w)ord. Now the selection is &lt;code&gt;voice name&lt;/code&gt;. Hitting it the third and fourth times repeats the same concept, and can even extend across multiple lines.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-10-04T03:30:01.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9795" PostTypeId="1" CreationDate="2016-10-04T04:02:21.673" Score="5" ViewCount="111" Body="&lt;p&gt;Let's say I'd like to indent the current line 4 times. (Not 4 spaces, 4 indent commands). As far as I can tell, the shortest way to do this is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Indent once, repeat three times) This seems really inefficient to me. I'd rather do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But instead of repeatedly indenting the current line, this indents the next &lt;em&gt;4 lines 1 time&lt;/em&gt;. In my mind, this is a total waste, because if the count &lt;em&gt;before&lt;/em&gt; the operator was &quot;indent level&quot;, and the count after is for a repeated motion, this doesn't lose any ability. If I wanted to indent the next four lines one time, I could just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;4&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or even &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;3j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the first count were to work this way, you could even do a command like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2&amp;gt;4&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this would mean &quot;Two times, indent the following four lines&quot;. Instead it means &quot;One time, indent eight lines&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I configure vim to behave this way?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="343" LastEditDate="2017-12-06T11:28:02.533" LastActivityDate="2017-12-06T11:28:02.533" Title="Can I make the indent commands take an additional count that doesn't affect the motion?" Tags="|key-bindings|indentation|count|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9796" PostTypeId="2" ParentId="9795" CreationDate="2016-10-04T05:56:05.820" Score="6" Body="&lt;p&gt;You can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:&amp;gt;&amp;gt;&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to shift the current line 4 times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you could write a custom normal mode mapping that shifts the current line &lt;code&gt;{count}&lt;/code&gt; times:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;F5&amp;gt; &quot;:\&amp;lt;C-u&amp;gt;&quot; . repeat(&quot;&amp;gt;&quot;, v:count1) . &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;F6&amp;gt; &quot;:\&amp;lt;C-u&amp;gt;&quot; . repeat(&quot;&amp;lt;&quot;, v:count1) . &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and its visual mode counterpart:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;expr&amp;gt; &amp;lt;F5&amp;gt; &quot;:&quot; . repeat(&quot;&amp;gt;&quot;, v:count1) . &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;xnoremap &amp;lt;expr&amp;gt; &amp;lt;F6&amp;gt; &quot;:&quot; . repeat(&quot;&amp;lt;&quot;, v:count1) . &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Mixing &lt;code&gt;{count}&lt;/code&gt; and &lt;code&gt;{range}&lt;/code&gt; may be a bit more complicated.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-10-04T05:56:05.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9797" PostTypeId="2" ParentId="9795" CreationDate="2016-10-04T05:57:15.500" Score="4" Body="&lt;p&gt;alternate using visual mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V4&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or just&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v4&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as mentioned in the SO thread &lt;a href=&quot;https://stackoverflow.com/questions/3702581/how-do-i-indent-a-single-line-multiple-times-in-vi-or-vim&quot;&gt;How do I indent a single line multiple times in vi or vim?&#xA;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;For multiple lines, for example - current line and 3 lines down, indent twice:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v3j2&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1616" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-10-04T06:02:55.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9798" PostTypeId="1" CreationDate="2016-10-04T08:57:18.697" Score="1" ViewCount="1668" Body="&lt;p&gt;I am a vim newbie and some time ago I installed a plugin that enables previewing color schemes by repeatedly pressing a key. It is not the &lt;code&gt;colorscheme&lt;/code&gt; command which lists the schemes and switches to text in the editor after you select it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This one I am talking about actually switches the scheme in use when you press the cycling key, more like a live preview, and you press the &lt;kbd&gt;enter&lt;/kbd&gt; key if you find the one you want, or &lt;kbd&gt;escape&lt;/kbd&gt; to cancel to retain the current scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me the name of the plugin?&lt;/p&gt;&#xA;" OwnerUserId="9540" LastEditorUserId="1841" LastEditDate="2016-10-04T09:32:52.740" LastActivityDate="2016-10-04T09:32:52.740" Title="Plugin enabling live previewing of the colour schemes" Tags="|colorscheme|previewing|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9799" PostTypeId="2" ParentId="9793" CreationDate="2016-10-04T08:58:20.930" Score="2" Body="&lt;p&gt;If I understand correctly, you want to highlight every occurence of the selected words. You can easily expand DJMcMayhem answer to search for the selected words in the buffer like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap * viwy/&amp;lt;C-R&amp;gt;&quot;&amp;lt;CR&amp;gt;Ngn&#xA;:vnoremap * wiwy/&amp;lt;C-R&amp;gt;&quot;&amp;lt;CR&amp;gt;Ngn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After selecting the correct number of words, it searches the selection with &lt;code&gt;y/&amp;lt;C-R&amp;gt;&quot;&amp;lt;CR&amp;gt;&lt;/code&gt;, then reselect it with &lt;code&gt;Ngn&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5590" LastActivityDate="2016-10-04T08:58:20.930" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9800" PostTypeId="2" ParentId="9790" CreationDate="2016-10-04T09:37:08.117" Score="1" Body="&lt;p&gt;Another options is to add my langage with :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set spelllang=fr&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then add unrecognized words with &lt;code&gt;zg&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4542" LastActivityDate="2016-10-04T09:37:08.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9802" PostTypeId="2" ParentId="8406" CreationDate="2016-10-04T14:45:06.480" Score="3" Body="&lt;p&gt;The actual problem is that Vim does not know how to read the old title, because termcap/info is missing the control sequence to do that. But we can supply it ourselves for terminal types we know it for. Xterm and screen use the same sequence, so this will fix both:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has (&quot;title&quot;)&#xA;&#xA;    &quot; if there is no &amp;amp;t_ts sequence, is the terminal type known?&#xA;    if &amp;amp;t_ts == &quot;&quot; &amp;amp;&amp;amp; ( &amp;amp;term == &quot;screen&quot; || &amp;amp;term == &quot;xterm&quot; )&#xA;        &quot; add the missing control sequence for xterm or screen &#xA;        let &amp;amp;t_ts = &quot;\e]2;&quot;&#xA;    endif&#xA;&#xA;    &quot; enable setting the title only if vim can read the old one&#xA;    if &amp;amp;t_ts != &quot;&quot;&#xA;        set title&#xA;    endif&#xA;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9546" LastActivityDate="2016-10-04T14:45:06.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9803" PostTypeId="1" CreationDate="2016-10-04T14:46:36.383" Score="4" ViewCount="140" Body="&lt;p&gt;I'm referring to &lt;a href=&quot;https://github.com/vim-scripts&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there package managers that pull scripts from it by name? I ask because I notice that the version of my plugin contained in it is &lt;strong&gt;&lt;em&gt;extremely&lt;/em&gt;&lt;/strong&gt; old, and I'm wondering whether I should try to get it updated to the &lt;a href=&quot;https://github.com/bpstahlman/txtfmt&quot; rel=&quot;nofollow noreferrer&quot;&gt;latest version&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2281" LastEditorUserId="51" LastEditDate="2017-05-24T19:29:54.513" LastActivityDate="2017-05-24T19:29:54.513" Title="Who manages the vim-scripts project on Github, and how is it used?" Tags="|plugin-system|git|" AnswerCount="1" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9804" PostTypeId="1" AcceptedAnswerId="9805" CreationDate="2016-10-05T03:28:43.717" Score="5" ViewCount="1027" Body="&lt;p&gt;I want to execute some external program to format my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent execute &quot;!eslint --fix -o /dev/null %&quot; | redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the screen will jump to the shell output screen and shortly back to vim again. How I can avoid this short flash?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="205" LastEditDate="2016-10-05T12:21:01.023" LastActivityDate="2018-09-09T12:24:19.327" Title="How do I execute an external command without jumping out of vim?" Tags="|external-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9805" PostTypeId="2" ParentId="9804" CreationDate="2016-10-05T05:02:57.400" Score="5" Body="&lt;p&gt;Since the external command is executed via the shell, you need to append an ampersand (&lt;code&gt;&amp;amp;&lt;/code&gt;) to launch the process in the background:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent execute '!eslint --fix -o /dev/null % &amp;amp;' | execute ':redraw!'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also try the plugin &lt;a href=&quot;https://github.com/ruanyl/vim-fixmyjs&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-fixmyjs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, to format on save, just add the following to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWritePre *.js :Fixmyjs&#xA;au BufWritePre *.jsx :Fixmyjs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1691" LastEditorUserId="51" LastEditDate="2018-09-09T12:24:19.327" LastActivityDate="2018-09-09T12:24:19.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9806" PostTypeId="1" AcceptedAnswerId="9843" CreationDate="2016-10-05T05:03:45.773" Score="0" ViewCount="307" Body="&lt;p&gt;I'm using Vim and now I'm moving to NeoVim. I have configured my &lt;code&gt;.vimrc&lt;/code&gt; so that the hotkey &lt;code&gt;Control H/J/K/L&lt;/code&gt; moves between panels. (seamlessly between vim and tmux also).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now when I'm moving to NeoVim, I see that &lt;code&gt;Control H&lt;/code&gt; doesn't switch to left panel, but moves the cursor one character left. This makes me confused. I think the behavior of Neovim and vim should be the same with the same &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7078" LastEditorUserId="2920" LastEditDate="2016-10-05T05:27:41.013" LastActivityDate="2016-10-08T15:46:36.967" Title="Neovim: behavior different from vim with the same vimrc" Tags="|key-bindings|vimrc|neovim|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9809" PostTypeId="2" ParentId="3434" CreationDate="2016-10-05T11:49:04.070" Score="25" Body="&lt;p&gt;In new versions of Vim there's finally an option for this&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim 7.4.785 adds the 'fixeol' option that can be disabled to automatically preserve any missing EOL at the end of the file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(see wiki page: &lt;a href=&quot;http://vim.wikia.com/wiki/Do_not_auto-add_a_newline_at_EOF&quot; rel=&quot;noreferrer&quot;&gt;http://vim.wikia.com/wiki/Do_not_auto-add_a_newline_at_EOF&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;~/.vimrc&lt;/code&gt; add this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nofixeol&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Relaunch &lt;code&gt;vim&lt;/code&gt;, now it shouldn't add the newline at the end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(works only since vim version 7.4.785)&lt;/p&gt;&#xA;" OwnerUserId="9558" LastEditorUserId="9558" LastEditDate="2019-09-01T14:48:53.683" LastActivityDate="2019-09-01T14:48:53.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9810" PostTypeId="1" CreationDate="2016-10-05T13:29:50.297" Score="0" ViewCount="790" Body="&lt;p&gt;I'm building VIM from tag 8.0.0022 with this conf:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --with-features=huge \&#xA;--enable-pythoninterp \&#xA;--with-python-config-dir=/usr/lib/python2.7/config \&#xA;--with-features=huge \&#xA;--enable-perlinterp \&#xA;--enable-luainterp \&#xA;--enable-tclinterp \&#xA;--enable-rubyinterp \&#xA;--enable-cscope \&#xA;--with-tlib=ncursesw&#xA;--prefix=/usr \.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When executing it I got a linking error &lt;code&gt;cannot find -lieee&lt;/code&gt; whose option causing it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;./configure&lt;/code&gt; output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;configure: loading cache auto/config.cache&#xA;checking whether make sets $(MAKE)... (cached) yes&#xA;checking for gcc... (cached) gcc&#xA;checking whether the C compiler works... yes&#xA;checking for C compiler default output file name... a.out&#xA;checking for suffix of executables...&#xA;checking whether we are cross compiling... no&#xA;checking for suffix of object files... (cached) o&#xA;checking whether we are using the GNU C compiler... (cached) yes&#xA;checking whether gcc accepts -g... (cached) yes&#xA;checking for gcc option to accept ISO C89... (cached) none needed&#xA;checking how to run the C preprocessor... (cached) gcc -E&#xA;checking for grep that handles long lines and -e... (cached) /bin/grep&#xA;checking for egrep... (cached) /bin/grep -E&#xA;checking for fgrep... (cached) /bin/grep -F&#xA;checking for library containing strerror... (cached) none required&#xA;checking for gawk... (cached) gawk&#xA;checking for strip... (cached) strip&#xA;checking for ANSI C header files... (cached) yes&#xA;checking for sys/wait.h that is POSIX.1 compatible... (cached) yes&#xA;checking --enable-fail-if-missing argument... no&#xA;checking for recent clang version... no&#xA;configure: checking for buggy tools...&#xA;- sh is 'GNU bash, version 4.3.39(1)-release (aarch64-poky-linux-gnu)&#xA;Copyright (C) 2013 Free Software Foundation, Inc.&#xA;License GPLv3+: GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;&#xA;&#xA;This is free software; you are free to change and redistribute it.&#xA;There is NO WARRANTY, to the extent permitted by law.' - probably OK.&#xA;checking for BeOS... no&#xA;checking for QNX... no&#xA;checking for Darwin (Mac OS X)... no&#xA;checking for AvailabilityMacros.h... (cached) no&#xA;checking --with-local-dir argument... Defaulting to /usr/local&#xA;checking --with-vim-name argument... Defaulting to vim&#xA;checking --with-ex-name argument... Defaulting to ex&#xA;checking --with-view-name argument... Defaulting to view&#xA;checking --with-global-runtime argument... no&#xA;checking --with-modified-by argument... no&#xA;checking if character set is EBCDIC... no&#xA;checking --disable-smack argument... no&#xA;checking for linux/xattr.h... (cached) yes&#xA;checking for attr/xattr.h... (cached) yes&#xA;checking for XATTR_NAME_SMACKEXEC in linux/xattr.h... no&#xA;checking --disable-selinux argument... no&#xA;checking for is_selinux_enabled in -lselinux... (cached) no&#xA;checking --with-features argument... huge&#xA;checking --with-compiledby argument... no&#xA;checking --disable-xsmp argument... no&#xA;checking --disable-xsmp-interact argument... no&#xA;checking --enable-luainterp argument... yes&#xA;checking --with-lua-prefix argument... no&#xA;checking LUA_PREFIX environment var... not set, default to /usr&#xA;checking --with-luajit... no&#xA;checking for lua... no&#xA;checking if lua.h can be found in /usr/include... no&#xA;checking if lua.h can be found in /usr/include/lua... no&#xA;checking --enable-mzschemeinterp argument... no&#xA;checking --enable-perlinterp argument... yes&#xA;checking for perl... (cached) /usr/bin/perl&#xA;checking Perl version... OK&#xA;checking if compile and link flags for Perl are sane... no: PERL DISABLED&#xA;checking --enable-pythoninterp argument... yes&#xA;checking for python2... (cached) /usr/bin/python2&#xA;checking Python version... (cached) 2.7&#xA;checking Python is 2.3 or better... yep&#xA;checking Python's install prefix... (cached) /usr&#xA;checking Python's execution prefix... (cached) /usr&#xA;(cached) checking Python's configuration directory... (cached) /usr/lib/python2.7/config&#xA;(cached) checking Python's dll name... (cached) libpython2.7.so.1.0&#xA;checking if -pthread should be used... yes&#xA;checking if compile and link flags for Python are sane... yes&#xA;checking --enable-python3interp argument... no&#xA;checking if -fPIE can be added for Python... yes&#xA;checking --enable-tclinterp argument... yes&#xA;checking --with-tclsh argument... no&#xA;checking for tclsh8.5... (cached) /usr/bin/tclsh&#xA;checking Tcl version... 8.6 - OK&#xA;checking for location of Tcl include... /usr/include/tcl8.6/tcl.h&#xA;checking for location of tclConfig.sh script... /usr/lib/tclConfig.sh&#xA;checking --enable-rubyinterp argument... yes&#xA;checking --with-ruby-command argument... defaulting to ruby&#xA;checking for ruby... no&#xA;checking --enable-cscope argument... yes&#xA;checking --enable-workshop argument... no&#xA;checking --disable-netbeans argument... no&#xA;checking --disable-channel argument... no&#xA;checking for socket in -lsocket... (cached) no&#xA;checking for gethostbyname in -lnsl... (cached) yes&#xA;checking whether compiling with process communication is possible... yes&#xA;checking --enable-multibyte argument... no&#xA;checking --enable-hangulinput argument... no&#xA;checking --enable-xim argument... defaulting to auto&#xA;checking --enable-fontset argument... no&#xA;checking for xmkmf... no&#xA;checking for X... (cached) libraries , headers&#xA;checking for gethostbyname... (cached) yes&#xA;checking for connect... (cached) yes&#xA;checking for remove... (cached) yes&#xA;checking for shmat... (cached) yes&#xA;checking for IceConnectionNumber in -lICE... (cached) yes&#xA;checking if X11 header files can be found... yes&#xA;checking for _XdmcpAuthDoIt in -lXdmcp... (cached) yes&#xA;checking for IceOpenConnection in -lICE... (cached) yes&#xA;checking for XpmCreatePixmapFromData in -lXpm... (cached) no&#xA;checking if X11 header files implicitly declare return values... no&#xA;checking size of wchar_t is 2 bytes... (cached) no&#xA;checking --enable-gui argument... yes/auto - automatic GUI support&#xA;checking whether or not to look for GTK+ 2... yes&#xA;checking whether or not to look for GNOME... no&#xA;checking whether or not to look for Motif... yes&#xA;checking whether or not to look for Athena... yes&#xA;checking whether or not to look for neXtaw... yes&#xA;checking whether or not to look for Carbon... yes&#xA;checking --disable-gtktest argument... gtk test enabled&#xA;checking for pkg-config... (cached) /usr/bin/pkg-config&#xA;checking for GTK - version &amp;gt;= 2.2.0... yes; found version 2.24.29&#xA;checking version of Gdk-Pixbuf... OK.&#xA;checking for glib-compile-resources... (cached) /usr/bin/glib-compile-resources&#xA;checking glib-compile-resources... usable.&#xA;checking --disable-icon-cache-update argument... not set&#xA;checking for gtk-update-icon-cache... (cached) /usr/bin/gtk-update-icon-cache&#xA;checking --disable-desktop-database-update argument... not set&#xA;checking for update-desktop-database... (cached) no&#xA;not found in PATH.&#xA;checking for X11/SM/SMlib.h... (cached) yes&#xA;checking for X11/xpm.h... (cached) no&#xA;checking for X11/Sunkeysym.h... (cached) yes&#xA;checking for XIMText in X11/Xlib.h... yes&#xA;X GUI selected; xim has been enabled&#xA;checking for CYGWIN or MSYS environment... no&#xA;checking whether toupper is broken... (cached) no&#xA;checking whether __DATE__ and __TIME__ work... yes&#xA;checking whether __attribute__((unused)) is allowed... yes&#xA;checking for elf.h... (cached) yes&#xA;checking for main in -lelf... (cached) yes&#xA;checking for dirent.h that defines DIR... (cached) yes&#xA;checking for library containing opendir... (cached) none required&#xA;checking for stdint.h... (cached) yes&#xA;checking for stdlib.h... (cached) yes&#xA;checking for string.h... (cached) yes&#xA;checking for sys/select.h... (cached) yes&#xA;checking for sys/utsname.h... (cached) yes&#xA;checking for termcap.h... (cached) yes&#xA;checking for fcntl.h... (cached) yes&#xA;checking for sgtty.h... (cached) yes&#xA;checking for sys/ioctl.h... (cached) yes&#xA;checking for sys/time.h... (cached) yes&#xA;checking for sys/types.h... (cached) yes&#xA;checking for termio.h... (cached) yes&#xA;checking for iconv.h... (cached) yes&#xA;checking for inttypes.h... (cached) yes&#xA;checking for langinfo.h... (cached) yes&#xA;checking for math.h... (cached) yes&#xA;checking for unistd.h... (cached) yes&#xA;checking for stropts.h... (cached) yes&#xA;checking for errno.h... (cached) yes&#xA;checking for sys/resource.h... (cached) yes&#xA;checking for sys/systeminfo.h... (cached) no&#xA;checking for locale.h... (cached) yes&#xA;checking for sys/stream.h... (cached) no&#xA;checking for termios.h... (cached) yes&#xA;checking for libc.h... (cached) no&#xA;checking for sys/statfs.h... (cached) yes&#xA;checking for poll.h... (cached) yes&#xA;checking for sys/poll.h... (cached) yes&#xA;checking for pwd.h... (cached) yes&#xA;checking for utime.h... (cached) yes&#xA;checking for sys/param.h... (cached) yes&#xA;checking for libintl.h... (cached) yes&#xA;checking for libgen.h... (cached) yes&#xA;checking for util/debug.h... (cached) no&#xA;checking for util/msg18n.h... (cached) no&#xA;checking for frame.h... (cached) no&#xA;checking for sys/acl.h... (cached) yes&#xA;checking for sys/access.h... (cached) no&#xA;checking for sys/sysinfo.h... (cached) yes&#xA;checking for wchar.h... (cached) yes&#xA;checking for wctype.h... (cached) yes&#xA;checking for sys/ptem.h... (cached) no&#xA;checking for sys/sysctl.h... (cached) yes&#xA;checking for pthread_np.h... no&#xA;checking for strings.h... (cached) yes&#xA;checking if strings.h can be included after string.h... yes&#xA;checking whether gcc needs -traditional... (cached) no&#xA;checking for an ANSI C-conforming const... (cached) yes&#xA;checking for working volatile... (cached) yes&#xA;checking for mode_t... (cached) yes&#xA;checking for off_t... (cached) yes&#xA;checking for pid_t... (cached) yes&#xA;checking for size_t... (cached) yes&#xA;checking for uid_t in sys/types.h... (cached) yes&#xA;checking for uint32_t... (cached) yes&#xA;checking whether time.h and sys/time.h may both be included... (cached) yes&#xA;checking for ino_t... (cached) yes&#xA;checking for dev_t... (cached) yes&#xA;checking whether byte ordering is bigendian... (cached) no&#xA;checking for inline... (cached) inline&#xA;checking for rlim_t... (cached) yes&#xA;checking for stack_t... (cached) yes&#xA;checking whether stack_t has an ss_base field... no&#xA;checking --with-tlib argument... ncursesw&#xA;checking for linking with ncursesw library... OK&#xA;checking for tgetent()... yes&#xA;checking whether we talk terminfo... (cached) yes&#xA;checking whether termcap.h contains ospeed... yes&#xA;checking whether termcap.h contains UP, BC and PC... yes&#xA;checking whether tputs() uses outfuntype... no&#xA;checking whether sys/select.h and sys/time.h may both be included... yes&#xA;checking for /dev/ptc... no&#xA;checking for SVR4 ptys... yes&#xA;checking for ptyranges... p / 0123456789abcdef&#xA;checking default tty permissions/group... (cached) world&#xA;checking return type of signal handlers... (cached) void&#xA;checking for struct sigcontext... yes&#xA;checking getcwd implementation is broken... (cached) no&#xA;checking for bcmp... (cached) yes&#xA;checking for fchdir... (cached) yes&#xA;checking for fchown... (cached) yes&#xA;checking for fsync... (cached) yes&#xA;checking for getcwd... (cached) yes&#xA;checking for getpseudotty... (cached) no&#xA;checking for getpwent... (cached) yes&#xA;checking for getpwnam... (cached) yes&#xA;checking for getpwuid... (cached) yes&#xA;checking for getrlimit... (cached) yes&#xA;checking for gettimeofday... (cached) yes&#xA;checking for getwd... (cached) yes&#xA;checking for lstat... (cached) yes&#xA;checking for memcmp... (cached) yes&#xA;checking for memset... (cached) yes&#xA;checking for mkdtemp... (cached) yes&#xA;checking for nanosleep... (cached) yes&#xA;checking for opendir... (cached) yes&#xA;checking for putenv... (cached) yes&#xA;checking for qsort... (cached) yes&#xA;checking for readlink... (cached) yes&#xA;checking for select... (cached) yes&#xA;checking for setenv... (cached) yes&#xA;checking for setpgid... (cached) yes&#xA;checking for setsid... (cached) yes&#xA;checking for sigaltstack... (cached) yes&#xA;checking for sigstack... (cached) yes&#xA;checking for sigset... (cached) yes&#xA;checking for sigsetjmp... (cached) no&#xA;checking for sigaction... (cached) yes&#xA;checking for sigvec... (cached) no&#xA;checking for strcasecmp... (cached) yes&#xA;checking for strerror... (cached) yes&#xA;checking for strftime... (cached) yes&#xA;checking for stricmp... (cached) no&#xA;checking for strncasecmp... (cached) yes&#xA;checking for strnicmp... (cached) no&#xA;checking for strpbrk... (cached) yes&#xA;checking for strtol... (cached) yes&#xA;checking for tgetent... (cached) yes&#xA;checking for towlower... (cached) yes&#xA;checking for towupper... (cached) yes&#xA;checking for iswupper... (cached) yes&#xA;checking for usleep... (cached) yes&#xA;checking for utime... (cached) yes&#xA;checking for utimes... (cached) yes&#xA;checking for _LARGEFILE_SOURCE value needed for large files... (cached) no&#xA;checking for special C compiler options needed for large files... (cached) no&#xA;checking for _FILE_OFFSET_BITS value needed for large files... (cached) no&#xA;checking for st_blksize... yes&#xA;checking whether stat() ignores a trailing slash... (cached) no&#xA;checking for iconv_open()... yes&#xA;checking for nl_langinfo(CODESET)... yes&#xA;checking for strtod in -lm... (cached) yes&#xA;checking for strtod() and other floating point functions... yes&#xA;checking for isinf()... yes&#xA;checking for isnan()... yes&#xA;checking --disable-acl argument... no&#xA;checking for acl_get_file in -lposix1e... (cached) no&#xA;checking for acl_get_file in -lacl... (cached) yes&#xA;checking for fgetxattr in -lattr... (cached) yes&#xA;checking for POSIX ACL support... yes&#xA;checking for acl_get in -lsec... (cached) no&#xA;checking for Solaris ACL support... no&#xA;checking for AIX ACL support... no&#xA;checking for pango_shape_full... yes&#xA;checking --disable-gpm argument... no&#xA;checking for gpm... (cached) no&#xA;checking --disable-sysmouse argument... no&#xA;checking for sysmouse... (cached) no&#xA;checking for FD_CLOEXEC... yes&#xA;checking for rename... yes&#xA;checking for sysctl... not usable&#xA;checking for sysinfo... yes&#xA;checking for sysinfo.mem_unit... yes&#xA;checking for sysconf... yes&#xA;checking size of int... (cached) 4&#xA;checking size of long... (cached) 8&#xA;checking size of time_t... (cached) 8&#xA;checking size of off_t... (cached) 8&#xA;checking uint32_t is 32 bits... ok&#xA;checking whether memmove handles overlaps... (cached) yes&#xA;checking whether X_LOCALE needed... no&#xA;checking whether Xutf8SetWMProperties() can be used... yes&#xA;checking for _xpg4_setrunelocale in -lxpg4... (cached) no&#xA;checking how to create tags... ctags&#xA;checking how to run man with a section nr... man&#xA;checking --disable-nls argument... no&#xA;checking for msgfmt... (cached) msgfmt&#xA;checking for NLS... gettext() works&#xA;checking for bind_textdomain_codeset... (cached) yes&#xA;checking for _nl_msg_cat_cntr... yes&#xA;checking for dlfcn.h... (cached) yes&#xA;checking for dlopen()... no&#xA;checking for dlopen() in -ldl... yes&#xA;checking for dlsym()... yes&#xA;checking for setjmp.h... (cached) yes&#xA;checking for GCC 3 or later... yes&#xA;checking whether we need -D_FORTIFY_SOURCE=1... yes&#xA;checking linker --as-needed support... yes&#xA;configure: creating auto/config.status&#xA;config.status: creating auto/config.mk&#xA;config.status: creating auto/config.h&#xA;./my_inst_script: line 11: --prefix=/usr: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;make&lt;/code&gt; output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;root@imx8dvsabreauto:~/vim8/src# make&#xA;creating auto/pathdef.c&#xA;gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -DLINUX -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       -o objects/pathdef.o auto/pathdef.c&#xA;gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -DLINUX -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       version.c -o objects/version.o&#xA;link.sh: $LINK_AS_NEEDED set to 'yes': invoking linker directly.&#xA;  gcc   -L/usr/local/lib -Wl,--as-needed        -o vim objects/arabic.o objects/buffer.o objects/blowfish.o objects/charset.o objects/crypt.o objects/crypt_zip.o objects/dict.o objects/diff.o objects/digraph.o objects/edit.o objects/eval.o objects/evalfunc.o objects/ex_cmds.o objects/ex_cmds2.o objects/ex_docmd.o objects/ex_eval.o objects/ex_getln.o objects/farsi.o objects/fileio.o objects/fold.o objects/getchar.o objects/hardcopy.o objects/hashtab.o  objects/if_cscope.o objects/if_xcmdsrv.o objects/list.o objects/mark.o objects/memline.o objects/menu.o objects/misc1.o objects/misc2.o objects/move.o objects/mbyte.o objects/normal.o objects/ops.o objects/option.o objects/os_unix.o objects/pathdef.o objects/popupmnu.o objects/quickfix.o objects/regexp.o objects/screen.o objects/search.o objects/sha256.o objects/spell.o objects/spellfile.o objects/syntax.o objects/tag.o objects/term.o objects/ui.o objects/undo.o objects/userfunc.o objects/version.o objects/window.o objects/gui.o objects/gui_gtk.o objects/gui_gtk_x11.o objects/pty.o objects/gui_gtk_f.o objects/gui_beval.o objects/gui_gtk_gresources.o    objects/if_python.o  objects/if_tcl.o    objects/netbeans.o objects/channel.o  objects/json.o objects/main.o objects/memfile.o objects/message.o   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lelf -lnsl   -lncursesw -lacl -lattr -ldl    -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lpthread -lutil -lm -Xlinker -export-dynamic  -L=/usr/lib -ltcl8.6 -ldl -lz -lpthread -lieee -lm&#xA;/usr/lib/gcc/aarch64-poky-linux/5.3.0/../../../../aarch64-poky-linux/bin/ld: cannot find -lieee&#xA;collect2: error: ld returned 1 exit status&#xA;link.sh: Linking failed&#xA;Makefile:1867: recipe for target 'vim' failed&#xA;make: *** [vim] Error 1&#xA;root@imx8dvsabreauto:~/vim8/src#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9564" LastEditorUserId="9564" LastEditDate="2016-10-05T15:12:17.183" LastActivityDate="2016-10-05T17:14:02.740" Title="Error when building Vim from source: 'cannot find -lieee'" Tags="|installing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9814" PostTypeId="2" ParentId="9810" CreationDate="2016-10-05T16:46:47.870" Score="1" Body="&lt;p&gt;That trailing part of linking command is related to TCL interpreter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ grep ieee /usr/lib64/tclConfig.sh&#xA;TCL_LIBS='-ldl -lz  -lpthread -lieee -lm'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;whose option causing it?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's &lt;code&gt;--enable-tclinterp&lt;/code&gt;. If you want to keep it, try finding and installing development version of &lt;code&gt;libieee&lt;/code&gt; for your distribution.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;P.S.&#xA;You still have an error in the command (took comment too literally), last lines should be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--enable-cscope \&#xA;--with-tlib=ncursesw \&#xA;--prefix=/usr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="860" LastEditorUserId="15" LastEditDate="2016-10-05T17:14:02.740" LastActivityDate="2016-10-05T17:14:02.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9815" PostTypeId="1" AcceptedAnswerId="9816" CreationDate="2016-10-05T17:03:04.373" Score="3" ViewCount="662" Body="&lt;p&gt;Suppose I am on line &lt;code&gt;10&lt;/code&gt;, and I want to yank to line &lt;code&gt;20&lt;/code&gt;. Usually I will do &lt;code&gt;10y&lt;/code&gt;. Sometimes I do the subtraction wrong, and copy the wrong number of lines. Is there a way to copy directly from current line to line &lt;code&gt;20&lt;/code&gt; without doing the subtraction?&lt;/p&gt;&#xA;" OwnerUserId="9567" LastEditorUserId="2920" LastEditDate="2016-10-05T19:00:39.097" LastActivityDate="2016-10-05T19:00:39.097" Title="How to copy from current line to the `n`-th line?" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9816" PostTypeId="2" ParentId="9815" CreationDate="2016-10-05T17:13:08.670" Score="6" Body="&lt;p&gt;&lt;code&gt;V20Gy&lt;/code&gt;, if I understand your question correctly.&lt;/p&gt;&#xA;" OwnerUserId="9207" LastActivityDate="2016-10-05T17:13:08.670" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9817" PostTypeId="2" ParentId="9815" CreationDate="2016-10-05T17:21:38.197" Score="6" Body="&lt;p&gt;The &lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#%3Ayank&quot;&gt;&lt;code&gt;:[range]y[ank] [x]&lt;/code&gt;&lt;/a&gt; command allows specifying the range through the normal &lt;a href=&quot;https://vimhelp.appspot.com/cmdline.txt.html#cmdline-ranges&quot;&gt;cmdline range&lt;/a&gt; syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your example, you could use &lt;code&gt;:.,20y&lt;/code&gt; to yank from the current line through line 20 into the default register or &lt;code&gt;:.,20y a&lt;/code&gt; to yank into register &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2016-10-05T17:21:38.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9818" PostTypeId="2" ParentId="9786" CreationDate="2016-10-05T18:10:51.437" Score="4" Body="&lt;p&gt;The command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s\v\\(\W)/\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should suffice to transform most any pattern into &lt;code&gt;\v&lt;/code&gt; mode. It won't swap out the lil' &lt;code&gt;\m&lt;/code&gt; marker though - and to my knowledge that's impossible in a single replacement. It's short enough to type manually though, and then you can just do &lt;code&gt;:s/\\m/\\v&lt;/code&gt; for the mode marker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\W&lt;/code&gt; is shorthand for &lt;code&gt;[^a-zA-Z0-9_]&lt;/code&gt; which is the (negated) set of characters that very magic mode operates on. This just deletes any backslashes immediately preceding one of those characters.&#xA;&lt;strong&gt;Known issue:&lt;/strong&gt; This will replace &lt;code&gt;\\&lt;/code&gt; inside strings to &lt;code&gt;\&lt;/code&gt;. You could replace &lt;code&gt;\W&lt;/code&gt; with &lt;code&gt;\c[^a-z0-9\_]&lt;/code&gt; to mitigate this, but it'll still mess up your regex literal if you run it multiple times and also fail on longer escape strings (containing &lt;code&gt;\\\\&lt;/code&gt; for example)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; The original question makes it unclear if you need to transform &lt;code&gt;\v&lt;/code&gt; back to &lt;code&gt;\m&lt;/code&gt;, but the command there is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v(\\)@&amp;lt;!(\c[^a-z0-9\-\\\[\]\'_])/\\\2/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9182" LastEditorUserId="9182" LastEditDate="2016-10-07T14:43:07.487" LastActivityDate="2016-10-07T14:43:07.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9820" PostTypeId="2" ParentId="9764" CreationDate="2016-10-05T18:57:06.960" Score="1" Body="&lt;p&gt;You can make it output a ¨ by putting &lt;code&gt;168&lt;/code&gt; as the output symbol, i.e. with, say, &lt;code&gt;:dig um 168&lt;/code&gt;, but not use inside a digraph itself (&lt;code&gt;:dig a\168 228&lt;/code&gt; still wont make &lt;code&gt;&amp;lt;c-k&amp;gt;a¨&lt;/code&gt; output ä.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even the predefined digraphs use &lt;code&gt;:&lt;/code&gt; instead; e.g. &lt;code&gt;&amp;lt;c-k&amp;gt;a:&lt;/code&gt; give you ä.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2016-10-05T18:57:06.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9821" PostTypeId="1" AcceptedAnswerId="9824" CreationDate="2016-10-05T19:07:22.967" Score="1" ViewCount="227" Body="&lt;p&gt;I need to configure vim to add the shebang &lt;code&gt;#!/bin/bash&lt;/code&gt; if the edited file is in the directory &lt;code&gt;/usr/bin/&lt;/code&gt; and if it is empty (or even better if it doesn't exist)&lt;/p&gt;&#xA;" OwnerUserId="9549" LastEditorUserId="9207" LastEditDate="2016-10-05T22:51:46.950" LastActivityDate="2016-10-07T00:46:34.757" Title="How can I add a shebang to file in a specific directory" Tags="|vimrc|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9822" PostTypeId="2" ParentId="3434" CreationDate="2016-10-05T19:57:11.610" Score="2" Body="&lt;p&gt;Have you tried opening the file in binary mode? Try &lt;code&gt;vim -b file_name&lt;/code&gt;. It should not add the new line at end of file. &lt;/p&gt;&#xA;" OwnerUserId="9547" LastEditorUserId="2920" LastEditDate="2016-10-05T22:53:36.093" LastActivityDate="2016-10-05T22:53:36.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9823" PostTypeId="1" AcceptedAnswerId="9838" CreationDate="2016-10-05T21:11:58.813" Score="0" ViewCount="102" Body="&lt;p&gt;Visual Studio has a feature for C# that displays how many times a given method has been referenced. This information is displayed as tiny greyed out text above the method names. It is not possible to edit this text and it will be ignored by the cursor when you transition over it. &lt;em&gt;(I believe they are called adornments or glyphs, but I'm not entirely sure)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For illustration purpose, example images of the reference counters can be seen in the images at &lt;a href=&quot;http://www.axtools.com/products-codesmart-vsnet.php&quot; rel=&quot;nofollow&quot;&gt;http://www.axtools.com/products-codesmart-vsnet.php&lt;/a&gt; and &lt;a href=&quot;http://www.kunal-chowdhury.com/2013/08/reference-counter-in-visual-studio-2013.html#MYmS5iViRWPY3Lzm.97&quot; rel=&quot;nofollow&quot;&gt;http://www.kunal-chowdhury.com/2013/08/reference-counter-in-visual-studio-2013.html#MYmS5iViRWPY3Lzm.97&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is it possible to achieve the same in Vim?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I am curious because I dream about having a plugin in Vim that displays type signatures of F# code on top of the functions. And to be useful in Vim, the type signatures must be ignored by the cursor and Vim editing functionality. I have never developed a Vim plugin, so I guess this would be my first journey into Vim-scripting...&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user7592" LastActivityDate="2016-10-07T09:26:27.867" Title="Generate non editable glyphs/adornments on top of text in Vim?" Tags="|plugin-development|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9824" PostTypeId="2" ParentId="9821" CreationDate="2016-10-05T22:43:41.337" Score="2" Body="&lt;p&gt;Here's one way to add the shebang to any new file in &lt;code&gt;/usr/bin/&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func Shebang(path)&#xA;    echo a:path&#xA;    if a:path =~ &quot;/usr/bin/[^/]*&quot;&#xA;        normal i#!/bin/bash&#xA;    endif&#xA;endfunc&#xA;autocmd BufNewFile /usr/bin/* execute Shebang(expand('&amp;lt;amatch&amp;gt;'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will only execute on new files, and also ensures the file isn't in a subdirectory in &lt;code&gt;/usr/bin&lt;/code&gt;.  You could also modify it so the pattern of &lt;code&gt;*.sh&lt;/code&gt; (a new shell file created anywhere) also gets the shebang.  If you don't care about subdirectories and only want this to every work in &lt;code&gt;/usr/bin&lt;/code&gt;, you could also just do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile /usr/bin/* normal i#!/bin/bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9571" LastEditorUserId="6698" LastEditDate="2016-10-07T00:46:34.757" LastActivityDate="2016-10-07T00:46:34.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9825" PostTypeId="1" AcceptedAnswerId="9827" CreationDate="2016-10-06T00:06:20.093" Score="4" ViewCount="1637" Body="&lt;p&gt;I want one vimrc to work with both Vim and NeoVim. The vimrc of Vim seems to work well with NeoVim. But not the other way around, given that there are many special new settings in NeoVim, e.g., terminal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want not to manage two individual vimrc files needed to be sync'd periodically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way within .vimrc to let some statements work with NeoVim alone?&lt;/p&gt;&#xA;" OwnerUserId="4583" LastEditorUserId="205" LastEditDate="2016-10-06T04:45:36.283" LastActivityDate="2016-10-06T04:47:38.370" Title="Is there a conditional to distinguish NeoVim and Vim within vimrc?" Tags="|vimrc|neovim|" AnswerCount="1" CommentCount="0" ClosedDate="2016-10-06T06:35:34.347" ContentLicense="CC BY-SA 3.0" />
  <row Id="9826" PostTypeId="2" ParentId="6629" CreationDate="2016-10-06T00:53:54.310" Score="1" Body="&lt;p&gt;Vim &lt;em&gt;(though I cannot attest if this is true for every build and version)&lt;/em&gt; actually &lt;strong&gt;only&lt;/strong&gt; handles &lt;a href=&quot;http://academic.evergreen.edu/projects/biophysics/technotes/program/ascii_ctrl.htm&quot; rel=&quot;nofollow&quot;&gt;valid ASCII control codes&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is why when you press &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;M&lt;/kbd&gt;, Vim actually gets a special &quot;control code&quot; (&lt;code&gt;0D&lt;/code&gt; in this case), while there is no such code for &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;,&lt;/kbd&gt;, so it cannot be mapped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an interesting discussion on that very subject here: &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_dev/Ym6D-kWIsyo&quot; rel=&quot;nofollow&quot;&gt;https://groups.google.com/forum/#!topic/vim_dev/Ym6D-kWIsyo&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8856" LastActivityDate="2016-10-06T00:53:54.310" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9827" PostTypeId="2" ParentId="9825" CreationDate="2016-10-06T04:47:38.370" Score="11" Body="&lt;p&gt;From &lt;a href=&quot;https://github.com/neovim/neovim/issues/1931&quot; rel=&quot;noreferrer&quot;&gt;NeoVim's Github issue tracker&lt;/a&gt;, you can use &lt;code&gt;has('nvim')&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('nvim')&#xA;   &quot;something for neovim&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-10-06T04:47:38.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9828" PostTypeId="1" AcceptedAnswerId="9829" CreationDate="2016-10-06T07:19:53.687" Score="6" ViewCount="761" Body="&lt;p&gt;I'm writing a report in LaTeX that I keep in a Git repository. In order to make the most out of Git, I would like to keep each sentence on its own line. I.e. for each dot, exclamation mark and question mark - while I'm in insert mode - I would like vim automatically to insert a newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I only want this to happen in the body of the text and not between &lt;code&gt;{}&lt;/code&gt;, &lt;code&gt;[]&lt;/code&gt;, &lt;code&gt;()&lt;/code&gt;, &lt;code&gt;&quot;&quot;&lt;/code&gt; or &lt;code&gt;''&lt;/code&gt; because in LaTeX, I may want to write filenames or commands between these characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can achieve this with a key mapping in insert mode, or is there another preferred way of doing this?&lt;/p&gt;&#xA;" OwnerUserId="9578" LastEditorUserId="1841" LastEditDate="2016-10-06T09:35:22.727" LastActivityDate="2016-10-06T09:41:33.163" Title="Insert a newline after punctuations" Tags="|key-bindings|filetype-tex|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="9829" PostTypeId="2" ParentId="9828" CreationDate="2016-10-06T09:22:39.567" Score="3" Body="&lt;p&gt;Here is a solution which seems to be working &lt;em&gt;(note the word &lt;strong&gt;seems&lt;/strong&gt; I didn't test it extensively so it might not work in some cases)&lt;/em&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! InsertDot(char)&#xA;    &quot; Save the cursor position&#xA;    let save_pos=getpos('.')&#xA;&#xA;    &quot; Try to yank inner braces&#xA;    call setreg('z', &quot;&quot;)&#xA;    normal &quot;zyi(&#xA;    normal &quot;zyi[&#xA;    normal &quot;zyi&quot;&#xA;    normal &quot;zyi'&#xA;&#xA;    if ( getreg('z') == &quot;&quot; )&#xA;    &quot; If nothing was yanked insert the character and a new line&#xA;        execute &quot;normal! i&quot; . a:char . &quot;^M&quot;&#xA;        execute &quot;startinsert&quot;&#xA;    else&#xA;    &quot; If something was yanked insert the dot&#xA;    &quot; (messy workaround to get back to the correct position)&#xA;        call setpos('.', save_pos)&#xA;        execute &quot;normal! i&quot; . a:char&#xA;        execute &quot;startinsert&quot;&#xA;        let save_pos[2] = save_pos[2]+1&#xA;        call setpos('.', save_pos)&#xA;    endif&#xA;endfunction&#xA;&#xA;inoremap . &amp;lt;c-o&amp;gt;:call InsertDot('.')&amp;lt;CR&amp;gt;&#xA;inoremap ! &amp;lt;c-o&amp;gt;:call InsertDot('!')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The characters must be mapped in insert mode to call the function. The function will try to determine if the cursor is between braces and add the character and a new line or only the character accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the function uses a crappy workaround to preserve the cursor position. I'm pretty sure it can be improved.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Otherwise to follow your comment you can use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap . .^M&#xA;inoremap \. .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make &lt;kbd&gt;.&lt;/kbd&gt; insert a dot and a new line and &lt;kbd&gt;\ .&lt;/kbd&gt; insert only a dot.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important note&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the occurences of &lt;code&gt;^M&lt;/code&gt; in the code must be added with &lt;kbd&gt;CTRL+v&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-10-06T09:41:33.163" LastActivityDate="2016-10-06T09:41:33.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9830" PostTypeId="2" ParentId="9732" CreationDate="2016-10-06T12:22:07.763" Score="1" Body="&lt;p&gt;If you just want to copy the function &quot;use ctrl-[left/right] to select direction-wise until word bound you can bind&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;c-left&amp;gt; &amp;lt;esc&amp;gt;vb&#xA;:inoremap &amp;lt;c-right&amp;gt; &amp;lt;esc&amp;gt;ve&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;code&gt;&amp;lt;esc&amp;gt;viw&lt;/code&gt; to instead visual around the entire word you're currently inside (or right at the end of.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use a similar technique in my &lt;code&gt;.vimrc&lt;/code&gt; to be able to quickly uppercase my entire last word (e.g. if i wrote &lt;code&gt;max_timeout&lt;/code&gt; but wanted &lt;code&gt;MAX_TIMEOUT&lt;/code&gt;).&#xA;My binding for this is &lt;code&gt;:inoremap &amp;lt;c-u&amp;gt; &amp;lt;esc&amp;gt;vawUea&lt;/code&gt;. The idea is the same - you bind something(&lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt;) to exit insert mode(&lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;), go into visual(&lt;code&gt;v&lt;/code&gt;), do what you need to do(&lt;code&gt;U&lt;/code&gt;), and then jump back into insert mode again(&lt;code&gt;ea&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're worried about overwriting a predefined binding when you map on something like &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;c-left&amp;gt;&lt;/code&gt;, you can look it up with &lt;code&gt;:help &amp;lt;c-left&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastEditorUserId="9182" LastEditDate="2016-10-06T12:48:24.523" LastActivityDate="2016-10-06T12:48:24.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9831" PostTypeId="1" AcceptedAnswerId="9833" CreationDate="2016-10-06T12:30:43.553" Score="11" ViewCount="4915" Body="&lt;p&gt;If I press &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;z&lt;/kbd&gt; in normal mode, it makes my gVim &quot;minimized&quot; or in vim (not gVim ) it goes back to the shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to disable this feature but&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I can't unmap &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;z&lt;/kbd&gt;: &lt;code&gt;unmap &amp;lt;c-z&amp;gt;&lt;/code&gt; returns &lt;code&gt;no such mapping&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;There is no option called &lt;code&gt;suspend&lt;/code&gt;, allowing me to use &lt;code&gt;unset suspend&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I did &lt;code&gt;:help suspend&lt;/code&gt; but the document doesn't mention anything about disabling &quot;suspend&quot;.&lt;/p&gt;&#xA;" OwnerUserId="9582" LastEditorUserId="1841" LastEditDate="2016-10-06T14:00:54.857" LastActivityDate="2020-05-11T16:38:59.700" Title="Disable Ctrl-Z in normal mode" Tags="|gvim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9832" PostTypeId="2" ParentId="7835" CreationDate="2016-10-06T13:06:14.620" Score="2" Body="&lt;p&gt;You could simply do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap / /\&amp;lt;\&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make the search key &lt;code&gt;/&lt;/code&gt; naturally expand into &lt;code&gt;/\&amp;lt;\&amp;gt;&lt;/code&gt; and place the cursor within the search pattern.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2016-10-06T13:06:14.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9833" PostTypeId="2" ParentId="9831" CreationDate="2016-10-06T14:16:43.453" Score="15" Body="&lt;p&gt;So there are several things that you need to understand:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly you can't use &lt;code&gt;:unset suspend&lt;/code&gt; and that is normal. Suspending Vim is not controlled by an option (that you could unset) but by a command: &lt;code&gt;:suspend&lt;/code&gt;. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/starting.html#:suspend&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :suspend&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly you want to disable the suspension triggered by &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;z&lt;/kbd&gt;. This is a built-in command, thus you can not &quot;unmap&quot; this key combination. The only mappings that you can unmap are the one that you (or a plugin) created with a command &lt;code&gt;:map &amp;lt;key&amp;gt; &amp;lt;action&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is to say to Vim &quot;When I press &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;z&lt;/kbd&gt; do nothing instead of suspending as you usually do&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what this command does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-z&amp;gt; &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can understand it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n                      Do the following mapping only in normal mode&#xA; nore                  Don't make it recursive (This is not necessary here but strongly recommended in all your mappings)&#xA;     map               Create a mapping&#xA;         &amp;lt;c-z&amp;gt;         The keys that you want to remap&#xA;               &amp;lt;nop&amp;gt;   This is the short for &quot;no operation&quot; i.e. Do nothing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add the line to your vimrc or simply type in vim's command line &lt;code&gt;:nnoremap &amp;lt;c-z&amp;gt; &amp;lt;nop&amp;gt;&lt;/code&gt; so that the mapping will only exists in the current session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#&amp;lt;nop&amp;gt;&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h &amp;lt;nop&amp;gt;&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-11-14T17:03:18.753" LastActivityDate="2019-11-14T17:03:18.753" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9834" PostTypeId="1" AcceptedAnswerId="9836" CreationDate="2016-10-06T20:19:09.613" Score="-1" ViewCount="352" Body="&lt;p&gt;I can use &lt;kbd&gt;^&lt;/kbd&gt;, &lt;kbd&gt;i&lt;/kbd&gt; to get into insert mode from normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I was wondering if there's a shorter way to do it.&lt;/p&gt;&#xA;" OwnerUserId="5574" LastActivityDate="2016-10-06T20:27:05.550" Title="Is there a one-key command to insert before the first character of the line?" Tags="|key-bindings|insert-mode|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9836" PostTypeId="2" ParentId="9834" CreationDate="2016-10-06T20:27:04.087" Score="3" Body="&lt;p&gt;What you need is &lt;code&gt;I&lt;/code&gt; (uppercase letter &lt;code&gt;i&lt;/code&gt;). From &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#I&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help I&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I           Insert text before the first non-blank in the line&#xA;            [count] times.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6698" LastActivityDate="2016-10-06T20:27:04.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9837" PostTypeId="1" CreationDate="2016-10-06T20:48:47.693" Score="1" ViewCount="83" Body="&lt;p&gt;I recently tried vim for the (still in-dev!) Bash for Ubuntu on Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed this odd glyph appearing on the commandline in vim - but only when moving across it. It flashes for one screen update when moving the cursor... Sometimes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lnzhY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lnzhY.png&quot; alt=&quot;Something that looks like an O appears on the cursor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know of this? From my testing it happens only in vim. (I did try it on bash and nano as well).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone's curious, I'm fairly certain that's an uppercase O - my font has slashed zeroes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to see more, I uploaded a 105kb webm video of the issue here: &lt;a href=&quot;https://webmshare.com/play/NELvx&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://webmshare.com/play/NELvx&lt;/a&gt;, where I also show off the lack of a &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it vim? Is it the terminal? Does anyone have any ideas at all?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I know Stackexchange isn't a bug tracker and it most likely is a bug - but if there's some arcane vim setting that causes this I'm interested to know. If not, I'll just write it down as a bug in &lt;code&gt;conhost.exe&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastEditorUserId="9182" LastEditDate="2016-10-06T20:56:56.543" LastActivityDate="2016-10-06T20:56:56.543" Title="Strange glyph when moving commandline cursor" Tags="|command-line|microsoft-windows|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9838" PostTypeId="2" ParentId="9823" CreationDate="2016-10-07T00:45:51.493" Score="1" Body="&lt;p&gt;There are two parts to this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Getting the required information from a static analysis.&lt;/li&gt;&#xA;&lt;li&gt;Displaying this information in Vim.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Part 1. is best done &lt;em&gt;outside&lt;/em&gt; of Vim as Vim can't really do this sort of comprehensive static analysis. For example vim-go uses the &lt;code&gt;guru&lt;/code&gt; commandline tool, for Python there's jedi, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have the information, you'll need to display it. There isn't any way to display this as Visual Studio. Vim has &lt;em&gt;very&lt;/em&gt; limited graphics capabilities, but there are several other options for displaying it. The two most obvious &quot;Vim ways&quot; are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Add a command (and mapping) to display this information.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Display it in the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27statusline%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;'statusline'&lt;/code&gt;&lt;/a&gt; for the function that's currently active.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Other more exotic options might be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Display it in a (vertical) split. This is how things like &quot;sidebars&quot; are done in Vim.&lt;/li&gt;&#xA;&lt;li&gt;As a mouse-over &quot;balloon&quot; with &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27balloonexpr%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;'balloonexpr'&lt;/code&gt;&lt;/a&gt;. This only works in gVim.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-10-07T09:26:27.867" LastActivityDate="2016-10-07T09:26:27.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9839" PostTypeId="1" AcceptedAnswerId="9841" CreationDate="2016-10-07T07:33:32.857" Score="2" ViewCount="1219" Body="&lt;p&gt;On vim's help &lt;code&gt;:help jumplist&lt;/code&gt; I can read: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Jumps are remembered in a jump list.  With the &lt;code&gt;CTRL-O&lt;/code&gt; and &lt;code&gt;CTRL-I&lt;/code&gt; command you&#xA;  can go to cursor positions before older jumps, and back again.  Thus you can&#xA;  move up and down the list.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, on my terminal &lt;code&gt;mintty&lt;/code&gt;, Vim makes no differences between &lt;kbd&gt;Tab&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;i&lt;/kbd&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am wondering what is the magic to use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;i&lt;/kbd&gt; on Vim?&lt;/p&gt;&#xA;" OwnerUserId="2548" LastActivityDate="2020-05-01T01:36:49.700" Title="How to use jumplist's &lt;C-i&gt; which is seen as a &lt;Tab&gt;?" Tags="|key-bindings|jumplist|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9841" PostTypeId="2" ParentId="9839" CreationDate="2016-10-07T08:16:24.350" Score="8" Body="&lt;p&gt;&lt;kbd&gt;Control&lt;/kbd&gt;&lt;kbd&gt;I&lt;/kbd&gt; &lt;em&gt;is&lt;/em&gt; Tab (&lt;code&gt;I&lt;/code&gt; is character code 73 and control subtracts 64; this leaves us with 9, which is TAB).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every vim install I've tried this on (including &lt;code&gt;gvim&lt;/code&gt;) maps this to &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; - even &lt;code&gt;:help &amp;lt;ctrl-i&amp;gt;&lt;/code&gt; shows us that the feature you want is actually also bound to &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From my testing, it works fine on any vim install that doesn't map &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; to anything else. Use &lt;code&gt;:map &amp;lt;tab&amp;gt;&lt;/code&gt; to check if you've got any mappings set up for that key.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2016-10-07T08:16:24.350" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9842" PostTypeId="1" AcceptedAnswerId="9844" CreationDate="2016-10-07T09:24:06.173" Score="1" ViewCount="699" Body="&lt;p&gt;I'd like to create a keymapping with a conditional statement, so that it behaves differently when a given line is blank. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/34370260/&quot;&gt;This thread&lt;/a&gt; gave me the following snippet, which is great – except that it doesn't match lines that are blank-except-for-a-comment-marker. I'd like to capture those lines, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; [KEY SEQUENCE] getline(line(&quot;.&quot;)+1) =~ &quot;^$&quot; ? &quot;[COMMAND]&quot; : &quot;[COMMAND]&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I set out to build a regular expression. &lt;code&gt;'\v^(#|&quot;|*)?$'&lt;/code&gt; is what I came up with. I tested it in vim's command line, and it looks like it should work: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:echo getline(line(&quot;.&quot;)) =~ '\v^(#|&quot;|*)?$'&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;returns &lt;code&gt;1&lt;/code&gt; on the target lines, and returns &lt;code&gt;0&lt;/code&gt; on all others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then the same expression used in the following mapping throws an error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;o (getline(line(&quot;.&quot;)) =~ '\v^(#|&quot;|*)?$') ? (&quot;:echo '1'&quot;) : (&quot;:echo '0'&quot;)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E115: Missing quote: '\v^(#&#xA;E15: Invalid expression: (getline(line(&quot;.&quot;)) =~ '\v^(#`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I tried rewriting the regular expression without the &lt;code&gt;\v&lt;/code&gt; flag: &lt;code&gt;'^\(\#\|\&quot;\|\*\)\?$'&lt;/code&gt;. It still works in command-line testing, and eliminates the error, but still doesn't match as expected. (It matches blank lines, but not those beginning with a comment marker.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing? (Additionally, does Vimscript have a way to specify &quot;current-filetype's-comment-marker&quot;, so I don't have to lump all three of these together as one?)&lt;/p&gt;&#xA;" OwnerUserId="2593" LastActivityDate="2016-10-07T10:32:18.027" Title="How do I use regular expressions in ternary statements / keymappings?" Tags="|key-bindings|regular-expression|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9843" PostTypeId="2" ParentId="9806" CreationDate="2016-10-07T10:29:45.933" Score="1" Body="&lt;p&gt;This is a bug from &lt;code&gt;nvim&lt;/code&gt; and has officially discuss here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator#it-doesnt-work-in-neovim-specifically-c-h&quot; rel=&quot;nofollow&quot;&gt;nvim bug when pressing Control+H&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, that means you press Control+H, nvim will understand a backspace. So we must convert backspace again to open &lt;code&gt;TmuxNavigateLeft&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &amp;lt;silent&amp;gt; &amp;lt;BS&amp;gt; :TmuxNavigateLeft&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7078" LastEditorUserId="7078" LastEditDate="2016-10-08T15:46:36.967" LastActivityDate="2016-10-08T15:46:36.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9844" PostTypeId="2" ParentId="9842" CreationDate="2016-10-07T10:32:18.027" Score="4" Body="&lt;ol&gt;&#xA;&lt;li&gt;The parentheses are unnecessary.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The error is caused by the unescaped pipes in your pattern. Escape them to fix that error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;key&amp;gt; getline(line(&quot;.&quot;)) =~ '\v^(#\|&quot;\|*)?$' ? &quot;:echo 1\&amp;lt;CR&amp;gt;&quot; : &quot;:echo 0\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Additionally, does Vimscript have a way to specify &quot;current-filetype's-comment-marker&quot;, so I don't have to lump all three of these together as one?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, you can use &lt;code&gt;&amp;amp;commentstring&lt;/code&gt; but it may or may not be correctly set for &lt;em&gt;every&lt;/em&gt; filetype.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-10-07T10:32:18.027" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9845" PostTypeId="2" ParentId="807" CreationDate="2016-10-07T12:27:20.000" Score="13" Body="&lt;p&gt;Here is a &lt;strong&gt;pure vimscript&lt;/strong&gt; solution. I did not create it, it was developed by Charles E. Campbell. You can find a Github repo with his code &lt;a href=&quot;https://github.com/posva/Rndm&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The algorithm uses 3 seeds generated at Vim startup and generate a pseudo-random number based on calculations and permutations applied to the seeds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Randomization Variables&#xA;&quot; with a little extra randomized start from localtime()&#xA;let g:rndm_m1 = 32007779 + (localtime()%100 - 50)&#xA;let g:rndm_m2 = 23717810 + (localtime()/86400)%100&#xA;let g:rndm_m3 = 52636370 + (localtime()/3600)%100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The variables scope is declared as global because they are used by the generator function but it could be restricted to the script (&lt;code&gt;s:&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is the generator function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Rndm()&#xA;    let m4= g:rndm_m1 + g:rndm_m2 + g:rndm_m3&#xA;    if( g:rndm_m2 &amp;lt; 50000000 )&#xA;        let m4= m4 + 1357&#xA;    endif&#xA;    if( m4 &amp;gt;= 100000000 )&#xA;        let m4= m4 - 100000000&#xA;        if( m4 &amp;gt;= 100000000 )&#xA;            let m4= m4 - 100000000&#xA;        endif&#xA;    endif&#xA;    let g:rndm_m1 = g:rndm_m2&#xA;    let g:rndm_m2 = g:rndm_m3&#xA;    let g:rndm_m3 = m4&#xA;    return g:rndm_m3&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The repo includes the following functions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A &quot;randomish&quot; initialization of the seeds;&lt;/li&gt;&#xA;&lt;li&gt;A way to read some user-defined seed from a text file;&lt;/li&gt;&#xA;&lt;li&gt;A pseudo random generator&lt;/li&gt;&#xA;&lt;li&gt;Several random functions:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A function that generates a random number within a range&lt;/li&gt;&#xA;&lt;li&gt;A dice rolling function&lt;/li&gt;&#xA;&lt;li&gt;A function to randomly swap a list of sequential integers&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is a quick test I wrote to test the generator: I generated 1000000 numbers between 0 and 9 and counted the number of occurrences of each number here are the results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0 : 100409&#xA;1 : 99435&#xA;2 : 100433&#xA;3 : 99578&#xA;4 : 100484&#xA;5 : 99948&#xA;6 : 100394&#xA;7 : 99649&#xA;8 : 99803&#xA;9 : 99867&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see the generation seems to be well distributed. I'm aware that this is largely not enough to test a random generator so I'll try to make some extra analysis if I have some free time.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-10-07T12:27:20.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9846" PostTypeId="1" AcceptedAnswerId="9848" CreationDate="2016-10-07T13:36:09.933" Score="3" ViewCount="702" Body="&lt;p&gt;For example, if I execute the following command from the terminal: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c PluginList&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this command opens vim and lists my currently installed plugins.  How do I execute the above command but redirect the output to my terminal?&lt;/p&gt;&#xA;" OwnerUserId="7226" LastEditorUserId="205" LastEditDate="2016-10-09T03:38:24.683" LastActivityDate="2016-10-09T03:38:24.683" Title="How do I list my current vim plugins without opening vim?" Tags="|plugin-system|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9847" PostTypeId="2" ParentId="9846" CreationDate="2016-10-07T14:16:08.390" Score="0" Body="&lt;p&gt;EDIT: modified original answer to keep only the finished script version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For future reference to people browsing this question, here's a solution to the original question that will work even if &lt;code&gt;Vundle&lt;/code&gt; is not being used with &lt;code&gt;vim&lt;/code&gt; (longer than @romainl's answer that does require &lt;code&gt;Vundle&lt;/code&gt;, which seems to be fine for the OP).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following script assumes a standard unix-like environment with access to common utilities such as &lt;code&gt;sed&lt;/code&gt;, &lt;code&gt;sort&lt;/code&gt; and &lt;code&gt;mktemp&lt;/code&gt;. Just paste into &lt;code&gt;somefile&lt;/code&gt; in your &lt;code&gt;$path&lt;/code&gt;, then &lt;code&gt;chmod +x somefile&lt;/code&gt; and execute &lt;code&gt;somefile&lt;/code&gt; on the command line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;tmp=$(mktemp)&#xA;vim +&quot;help local-additions&quot; +&quot;sav! $tmp&quot; +&quot;qall&quot;&#xA;sed '1,/LOCAL ADDITIONS/d' $tmp | sed '/^$/,$d' | sortj&#xA;rm $tmp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's an example of output when invoking this script from the command-line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|bufkill.txt|  Manage buffer display upon removal of current buffer   &#xA;|fugitive.txt|  A Git wrapper so awesome, it should be illegal &#xA;|matchit.txt|   Extended &quot;%&quot; matching&#xA;|now.txt|           A pure vim minimalistic personal wiki &#xA;|recover.vim|   Show differences for recovered files&#xA;|sneak.txt|  motion improved - Version 1.7.2&#xA;|snipMate.txt|  Plugin for using TextMate-style snippets in Vim.&#xA;|startify.txt|  The fancy start screen.&#xA;|surround.txt|  Plugin for deleting, changing, and adding &quot;surroundings&quot;&#xA;|undotree.txt|  Display your undo history in a graph&#xA;|vimux.txt|   easily interact with tmux&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that it will miss any plugins that don't have a proper vim help file (in the &lt;code&gt;.doc/&lt;/code&gt; subdirectory of the plugin).&lt;/p&gt;&#xA;" OwnerUserId="2058" LastEditorUserId="2058" LastEditDate="2016-10-08T11:02:07.247" LastActivityDate="2016-10-08T11:02:07.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9848" PostTypeId="2" ParentId="9846" CreationDate="2016-10-07T14:59:02.553" Score="5" Body="&lt;p&gt;Since you appear to be using Vundle, you could simply grep your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ grep -c Plugin ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-10-07T14:59:02.553" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9849" PostTypeId="1" AcceptedAnswerId="9850" CreationDate="2016-10-07T18:34:40.023" Score="0" ViewCount="311" Body="&lt;p&gt;&lt;code&gt;:&lt;/code&gt; is set as keyword (&lt;code&gt;set iskeyword&lt;/code&gt;) for C++ source file by default, is there a way to just disable that in my .vimrc file instead of doing &lt;code&gt;set iskeyword-=:&lt;/code&gt; every time? It seems the plug-in set the keyword is loaded after loading .vimrc file.&lt;/p&gt;&#xA;" OwnerUserId="477" LastEditorUserId="2920" LastEditDate="2016-10-07T21:21:30.643" LastActivityDate="2016-10-07T21:21:30.643" Title="Remove colon from keyword in C++ file?" Tags="|vimrc|filetype|filetype-c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9850" PostTypeId="2" ParentId="9849" CreationDate="2016-10-07T18:39:20.960" Score="4" Body="&lt;p&gt;You could put&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal iskeyword-=:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;inside &lt;code&gt;~/.vim/after/ftplugin/cpp.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Loads automatically when you open files where the &lt;code&gt;filetype&lt;/code&gt; is &lt;code&gt;cpp&lt;/code&gt;. If it doesn't work, try setting &lt;code&gt;filetype plugin on&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType cpp :setlocal iskeyword-=:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;.vimrc&lt;/code&gt;, but I recommend you put it in a ftplugin - it keeps your &lt;code&gt;.vimrc&lt;/code&gt; clutter-free.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastEditorUserId="9182" LastEditDate="2016-10-07T20:00:15.533" LastActivityDate="2016-10-07T20:00:15.533" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9851" PostTypeId="1" AcceptedAnswerId="9852" CreationDate="2016-10-07T19:08:07.380" Score="0" ViewCount="1114" Body="&lt;p&gt;This is my &lt;code&gt;.vimrc&lt;/code&gt; located under &lt;code&gt;$HOME/.vimrc&lt;/code&gt;. I've installed Vundle.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;Plugin 'dracula/dracula-theme'&#xA;&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&#xA;&quot; Put your non-Plugin stuff after this line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm able to execute &lt;code&gt;:PluginInstall&lt;/code&gt; successfully installing &lt;code&gt;dracula-theme&lt;/code&gt;. Unfortunately the theme is not applied and the style remains unchanged? Any clues?&lt;/p&gt;&#xA;" OwnerUserId="9603" LastActivityDate="2016-10-07T19:58:55.197" Title="Vundle doesn't load the theme" Tags="|vimrc|plugin-vundle|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9852" PostTypeId="2" ParentId="9851" CreationDate="2016-10-07T19:58:55.197" Score="2" Body="&lt;p&gt;Please add the following to your .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;colorscheme dracula&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1691" LastActivityDate="2016-10-07T19:58:55.197" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9853" PostTypeId="1" AcceptedAnswerId="9854" CreationDate="2016-10-08T07:38:34.860" Score="5" ViewCount="1094" Body="&lt;p&gt;Hi I am relatively new to vim. I am fairly familiar with setting up my vimrc, installing colorschemes, and I have included a python file type plugin in my ~/.vim/ftplugin.&#xA;My question is as follows: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do I really need a plugin manager like vundle?&lt;/li&gt;&#xA;&lt;li&gt;What is the utility of such tools, how would it affect my vim ecosystem&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am concerned that installing and using a plugin manager will negatievely impact my understanding of vim and somehow reduce the amount of control I have over my work environment.&lt;/p&gt;&#xA;" OwnerUserId="9612" LastActivityDate="2020-10-01T14:31:57.280" Title="Why should I use a plugin manager" Tags="|plugin-managers|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9854" PostTypeId="2" ParentId="9853" CreationDate="2016-10-08T08:22:53.143" Score="10" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Do I really need a plugin manager like vundle?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. Plugin managers have always been and will always be optional.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What is the utility of such tools, how would it affect my vim ecosystem?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You don't have a &quot;vim ecosystem&quot;; you have a Vim &lt;em&gt;setup&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A plugin manager &lt;strong&gt;may&lt;/strong&gt; be useful if:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you use &lt;em&gt;too many&lt;/em&gt; plugins,&lt;/li&gt;&#xA;&lt;li&gt;you like to &lt;em&gt;try&lt;/em&gt; new plugins,&lt;/li&gt;&#xA;&lt;li&gt;you absolutely want your plugins to be always up-to-date.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you use too many plugins, the usual installation scheme will likely become too messy very quickly. This will make the process of updating/removing plugins quite a chore. Plugin managers usually keep track of what is installed and where, in order to make the whole thing easier for the user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you like to &lt;em&gt;try&lt;/em&gt; new plugins, plugin managers usually make it easier to install/remove individual plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you absolutely want your plugins to be always up-to-date, plugin managers usually give you commands for updating or even auto-updating individual plugins. This more or less guarantees an always up-to-date setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If none of the use cases above fits yours then you don't &lt;em&gt;need&lt;/em&gt; a plugin manager. But having one won't really hurt anything unless you fail to read &lt;strong&gt;and understand&lt;/strong&gt; its documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I don't use many plugins, don't like to try new plugins, and my few plugins are either written by me of very stable/dead, I have zero need for a plugin manager. But I like when my stuff is neat and tidy so I use a &lt;em&gt;runtimepath manager&lt;/em&gt;, &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot;&gt;Pathogen&lt;/a&gt;, that lets me keep my plugins in separate directories.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-10-08T08:32:14.187" LastActivityDate="2016-10-08T08:32:14.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9855" PostTypeId="2" ParentId="9853" CreationDate="2016-10-08T09:01:34.280" Score="2" Body="&lt;p&gt;I would like to recommend one like vundle for the following reasons:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;you'll have a lot plugins sooner than you think, once you get used to vim, it will make sense to do nearly 'everything' in it.&lt;/li&gt;&#xA;&lt;li&gt;it's not easy to manage all plugins and those configs.&lt;/li&gt;&#xA;&lt;li&gt;having a plugin to manage plugins makes it easier to migrate, say, deploy a new environment.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6731" LastActivityDate="2016-10-08T09:01:34.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9856" PostTypeId="1" AcceptedAnswerId="9857" CreationDate="2016-10-08T09:15:49.127" Score="1" ViewCount="206" Body="&lt;p&gt;Follow up to &lt;a href=&quot;https://vi.stackexchange.com/questions/9842/&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have code for a custom key mapping with conditional logic. My understanding is that in vimscript, that means:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;it has to be all on one line&lt;br&gt;&#xA;(since it's a key mapping), and&lt;/li&gt;&#xA;&lt;li&gt;I'm restricted to using nested ternary operators&lt;br&gt;&#xA;(since it's all on one line).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The code works, and is reproduced below. (I know there are extraneous parentheses, but it helps me see the code more clearly since it's already such a jumbled mess.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;o (getline(line(&quot;.&quot;)) =~ '\v^' . strpart(&amp;amp;commentstring,0,1) . '?$') ? ( (getline(line(&quot;.&quot;)-1) =~ '\v^' . strpart(&amp;amp;commentstring,0,1) . '?$') ? ( (getline(line(&quot;.&quot;)+1) =~ '\v^' . strpart(&amp;amp;commentstring,0,1) . '?$') ? (&quot;i&quot;) : (&quot;O&quot;) ) : ( (getline(line(&quot;.&quot;)+1) =~ '\v^' . strpart(&amp;amp;commentstring,0,1) . '?$') ? (&quot;o&quot;) : ( strlen(getline(line(&quot;.&quot;))) == 0 ? (&quot;O\&amp;lt;CR&amp;gt;&quot;) : (&quot;O\&amp;lt;CR&amp;gt;\&amp;lt;Space&amp;gt;&quot;) ) ) ) : ( (getline(line(&quot;.&quot;)+1) =~ '\v^' . strpart(&amp;amp;commentstring,0,1) . '?$') ? (&quot;o\&amp;lt;CR&amp;gt;&quot;) : ( strlen(getline(line(&quot;.&quot;))) == 0 ? (&quot;o\&amp;lt;CR&amp;gt;\&amp;lt;C-o&amp;gt;O&quot;) : (&quot;o\&amp;lt;CR&amp;gt;\&amp;lt;C-o&amp;gt;O\&amp;lt;Space&amp;gt;&quot;) ) )&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I (/what facilities does vimscript offer to) simplify, refactor, or otherwise clean up this code? &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Pseudocode for clarity&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1 if (current line is empty, or contains only a single comment marker)&#xA; 2   if (previous line is empty, or contains only a single comment marker) &#xA; 3     if (next line is empty, or contains only a single comment marker) &#xA; 4       (&quot;i&quot;) &#xA; 5     else&#xA; 6       (&quot;O&quot;) &#xA; 7   else&#xA; 8     if (next line is empty, or contains only a single comment marker) &#xA; 9       (&quot;o&quot;) &#xA;10     else&#xA;11       if (current line does not contain a comment marker)&#xA;12         (&quot;O\&amp;lt;CR&amp;gt;&quot;)  &#xA;13       else&#xA;14         (&quot;O\&amp;lt;CR&amp;gt;\&amp;lt;Space&amp;gt;&quot;)&#xA;15 else&#xA;16   if (previous line is empty, or contains only a single comment marker) &#xA;17     (&quot;o\&amp;lt;CR&amp;gt;&quot;) &#xA;18   else&#xA;19     if (current line does not contain a comment marker)&#xA;20       (&quot;o\&amp;lt;CR&amp;gt;\&amp;lt;C-o&amp;gt;O&quot;) &#xA;21     else&#xA;22       (&quot;o\&amp;lt;CR&amp;gt;\&amp;lt;C-o&amp;gt;O\&amp;lt;Space&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;The Background&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The mapping above facilitates creating new paragraphs by inserting the necessary carriage returns between two lines of text and placing the cursor halfway inbetween. That is to say that when executed here,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;CURSOR (NORMAL MODE)&lt;/code&gt; Morbi tincidunt elementum facilisis. Sed convallis, mi et vulputate vestibulum, mauris nulla maximus risus, sed sagittis augue arcu a risus. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Mauris porta mauris nisi, sed facilisis tortor volutpat vel. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;the mapping does &lt;code&gt;o&amp;lt;CR&amp;gt;&lt;/code&gt; to produce this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Morbi tincidunt elementum facilisis. Sed convallis, mi et vulputate vestibulum, mauris nulla maximus risus, sed sagittis augue arcu a risus. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;CURSOR (INSERT MODE)&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Mauris porta mauris nisi, sed facilisis tortor volutpat vel. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's also context-sensitive, which means it creates the appropriate spacing depending on whether the current, previous, and next line are blank. Thus, it will create the exact same end state shown above even for the following scenarios:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;CURSOR&lt;/code&gt; Morbi tincidunt elementum facilisis. Sed convallis, mi et vulputate vestibulum, mauris nulla maximus risus, sed sagittis augue arcu a risus.&lt;br&gt;&#xA;  Mauris porta mauris nisi, sed facilisis tortor volutpat vel. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(via &lt;code&gt;o&amp;lt;CR&amp;gt;&amp;lt;C-o&amp;gt;O&lt;/code&gt;),&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Morbi tincidunt elementum facilisis. Sed convallis, mi et vulputate vestibulum, mauris nulla maximus risus, sed sagittis augue arcu a risus.&lt;br&gt;&#xA;  &lt;code&gt;CURSOR&lt;/code&gt;&lt;br&gt;&#xA;  Mauris porta mauris nisi, sed facilisis tortor volutpat vel. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(via &lt;code&gt;O&amp;lt;CR&amp;gt;&lt;/code&gt;),&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Morbi tincidunt elementum facilisis. Sed convallis, mi et vulputate vestibulum, mauris nulla maximus risus, sed sagittis augue arcu a risus.&lt;br&gt;&#xA;  &lt;code&gt;CURSOR&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Mauris porta mauris nisi, sed facilisis tortor volutpat vel. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(via &lt;code&gt;O&lt;/code&gt;), etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are, on lines 11 and 19 of the pseudocode, conditions for auto-indenting comments. If anyone knows of a better way of doing this, I'd be glad to hear it, too.&lt;/p&gt;&#xA;" OwnerUserId="2593" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-10-10T06:55:14.030" Title="Alternatives (or ways to refactor) complex conditional logic in a key mapping?" Tags="|key-bindings|refactor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9857" PostTypeId="2" ParentId="9856" CreationDate="2016-10-08T09:48:44.567" Score="3" Body="&lt;p&gt;Nested ternaries are indeed very hard to write and maintain, in vimscript or any language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is your jumbled mess turned into a proper function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! O()&#xA;    if getline(line(&quot;.&quot;)) =~ &quot;\v^&quot; . strpart(&amp;amp;commentstring,0,1) . &quot;?$&quot;&#xA;        if getline(line(&quot;.&quot;)-1)) =~ '\v^' . strpart(&amp;amp;commentstring,0,1) . '?$'&#xA;            if getline(line(&quot;.&quot;)+1)) =~ '\v^' . strpart(&amp;amp;commentstring,0,1) . '?$'&#xA;                return &quot;i&quot;&#xA;            else&#xA;                return &quot;O&quot;&#xA;            endif&#xA;        else&#xA;            if getline(line(&quot;.&quot;)+1)) =~ '\v^' . strpart(&amp;amp;commentstring,0,1) . '?$'&#xA;                return &quot;o&quot;&#xA;            else&#xA;                if strlen(getline(line(&quot;.&quot;))) == 0&#xA;                    return &quot;O\&amp;lt;CR&amp;gt;&quot;&#xA;                else&#xA;                    return &quot;O\&amp;lt;CR&amp;gt;\&amp;lt;Space&amp;gt;&quot;&#xA;                endif&#xA;            endif&#xA;        endif&#xA;    else&#xA;        if getline(line(&quot;.&quot;)+1) =~ '\v^' . strpart(&amp;amp;commentstring,0,1) . '?$'&#xA;            return &quot;o\&amp;lt;CR&amp;gt;&quot;&#xA;        else&#xA;            if strlen(getline(line(&quot;.&quot;))) == 0&#xA;                return &quot;o\&amp;lt;CR&amp;gt;\&amp;lt;C-o&amp;gt;O&quot;&#xA;            else&#xA;                return &quot;o\&amp;lt;CR&amp;gt;\&amp;lt;C-o&amp;gt;O\&amp;lt;Space&amp;gt;&quot;&#xA;            endif&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;F5&amp;gt; O()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-10-10T06:55:14.030" LastActivityDate="2016-10-10T06:55:14.030" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9858" PostTypeId="2" ParentId="9853" CreationDate="2016-10-08T11:10:11.507" Score="4" Body="&lt;p&gt;A plugin management helper like &lt;code&gt;pathogen&lt;/code&gt; has the distinct advantage of keeping each of the plugins separate, on its own subdiroctery. In fact, you can also use it to keep parts of &lt;strong&gt;your own&lt;/strong&gt; configuration in separate subdirectories. That way it is easy to act on a single plugin or a single part of your configuration (remove, update, etc...) without touching the others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What &lt;code&gt;pathogen&lt;/code&gt; does amounts to &quot;blending&quot; all those subdirectories &quot;on-the-fly&quot; as you run &lt;code&gt;vim&lt;/code&gt;, so each follows the regular &lt;code&gt;.vim&lt;/code&gt; structure (with possible &lt;code&gt;plugin/&lt;/code&gt;, &lt;code&gt;ftplugin/&lt;/code&gt;, &lt;code&gt;autoload&lt;/code&gt;, etc... subdirectories), while helping make sense of what comes from where.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: &lt;code&gt;pathogen&lt;/code&gt; will not &quot;auto-update&quot; your plugins. However, having each on a separate subdirectory makes it easier to update them if/whenever needed, especially for those that are clones of a &lt;code&gt;git&lt;/code&gt; repository and can simply be maintained as such.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit2: replaced &lt;em&gt;plugin manager&lt;/em&gt; by &lt;em&gt;plugin management helper&lt;/em&gt;, based on discussion in the comments below (to clarify that &lt;code&gt;pathogen&lt;/code&gt; fits a niche somewhere between simply placing contents of plugins in a single instance of the &lt;code&gt;.vim&lt;/code&gt; directory and using an actual full-featured &quot;plugin manager&quot;).&lt;/p&gt;&#xA;" OwnerUserId="2058" LastEditorUserId="2058" LastEditDate="2016-10-12T09:22:23.703" LastActivityDate="2016-10-12T09:22:23.703" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9859" PostTypeId="1" AcceptedAnswerId="9860" CreationDate="2016-10-08T14:07:44.597" Score="0" ViewCount="601" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/Shougo/neosnippet.vim&quot; rel=&quot;nofollow&quot; title=&quot;neosnippet&quot;&gt;neosnippet&lt;/a&gt; to define and expand my snippets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following snippet defined for javascript development&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet fn&#xA;abbr () =&amp;gt; {}&#xA;    (${1}) =&amp;gt; {${2}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can insert this snippet when starting to type on a new line using &lt;code&gt;C-k&lt;/code&gt;. However I often find myself in the position where i wish to insert in in an existing line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let something = fn&#xA;test.then(fn)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I'm after &lt;code&gt;fn&lt;/code&gt; on either of these lines I would like to expand the snippet. Can this be achieved using neosnippet?&lt;/p&gt;&#xA;" OwnerUserId="9617" LastActivityDate="2016-10-08T17:27:37.963" Title="Expanding snippet in line using neosnippet" Tags="|snippets|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9860" PostTypeId="2" ParentId="9859" CreationDate="2016-10-08T17:27:37.963" Score="1" Body="&lt;p&gt;This should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet fn&#xA;option word&#xA;abbr () =&amp;gt; {}&#xA;    (${1}) =&amp;gt; {${2}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find the necessary information if you read &lt;code&gt;:h neosnippet-snippet-syntax&lt;/code&gt;, in particular the help under the snippet keyword &lt;code&gt;option&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- options [options] (Optional)&#xA;&#xA;    Options influence the snippet behavior. The possible values are:&#xA;&#xA;    + word  This snippet expands by a word boundary.&#xA;        Note: To complete the trigger with neosnippet, it must be a&#xA;        word character (digits, alphabetical characters or &quot;_&quot;).&#xA;&#xA;    snippet     date&#xA;    options     word&#xA;        `strftime(&quot;%d %b %Y&quot;)`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The help text continuous with more help text on more options, but &lt;code&gt;word&lt;/code&gt; is the relevant option here.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-10-08T17:27:37.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9861" PostTypeId="1" CreationDate="2016-10-08T19:17:55.880" Score="2" ViewCount="887" Body="&lt;p&gt;As I know, when we cut text using &lt;code&gt;d&lt;/code&gt; or &lt;code&gt;c&lt;/code&gt;, this text will go to register 1, and shift all registers from 2 -&gt; 9.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tested and I see two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;My text, after cutting, is not going to register 1.&lt;/li&gt;&#xA;&lt;li&gt;I have tested all other registers using &lt;code&gt;:register&lt;/code&gt; but no register contains my text.&lt;/li&gt;&#xA;&lt;li&gt;I paste text after cutting, but nothing happens (or it just pastes another text when I yank). I think this is obvious because my cut text is gone nowhere in register.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How do I re-config again my &lt;code&gt;vimrc&lt;/code&gt; for getting again this normal behavior? Moreover, I have tested both on &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;neo-vim&lt;/code&gt;, the problem still persists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;@edit:&lt;/strong&gt; I tested on vim 7.4, neovim 1.0.4 (all are latest version) on Mac environment. I also tested using short text and long text (text that expanded on multiple lines).&lt;/p&gt;&#xA;" OwnerUserId="7078" LastEditorUserId="7078" LastEditDate="2016-10-09T10:37:29.670" LastActivityDate="2016-10-09T11:12:17.177" Title="Text after cut not going to register 1" Tags="|cut-copy-paste|register|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="9862" PostTypeId="1" AcceptedAnswerId="9864" CreationDate="2016-10-08T20:01:50.323" Score="6" ViewCount="714" Body="&lt;p&gt;I have &lt;code&gt;relativenumber&lt;/code&gt; turned on and sometimes find it convenient to use ex copy/move/delete on certain lines. For instance, my cursor might be at the top of the screen and there are two lines I want to delete, but they're way down the page. So I run something like &lt;code&gt;:+43,+44d&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this &lt;em&gt;moves the cursor&lt;/em&gt; down 43 lines (along with deleting the specified lines), which means I have to waste keystrokes getting back where I started (with, e.g., &lt;code&gt;43gk&lt;/code&gt;). I could set a mark before entering the initial command, but that ends up using just as many keystrokes. Is there some kind of flag that could be used to run the command without moving the cursor position, or some way to implement such as a mapping or function?&lt;/p&gt;&#xA;" OwnerUserId="2036" LastEditorUserId="51" LastEditDate="2016-11-10T18:26:42.993" LastActivityDate="2016-11-10T18:26:42.993" Title="Is there a way to use an ex command without moving the cursor?" Tags="|command-line|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9863" PostTypeId="2" ParentId="9862" CreationDate="2016-10-08T20:48:28.493" Score="6" Body="&lt;p&gt;Ex commands have &lt;em&gt;always&lt;/em&gt; worked like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;move the cursor to the given line,&lt;/li&gt;&#xA;&lt;li&gt;perform the given command&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;and there's no way to change that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you don't have to set a mark manually or climb back to where you were: you only have to use the automatic marks &lt;code&gt;'&lt;/code&gt; or &lt;code&gt;`&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:+43,+44d&#xA;``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-10-08T20:48:28.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9864" PostTypeId="2" ParentId="9862" CreationDate="2016-10-08T20:52:43.897" Score="7" Body="&lt;p&gt;I don't believe there is a way to run an ex command without moving the cursor, but there is a much more convenient way to get back to where you were. When you run an ex command, the current location will be added to your &quot;jumplist&quot;. You can use &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; to move back in the jumplist. From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#CTRL-O&quot;&gt;&lt;code&gt;:h ctrl-o&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *CTRL-O*&#xA;CTRL-O          Go to [count] Older cursor position in jump list&#xA;            (not a motion command).  {not in Vi}&#xA;            {not available without the |+jumplist| feature}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should be more convenient than &lt;code&gt;43gk&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-10-08T20:52:43.897" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9865" PostTypeId="2" ParentId="9861" CreationDate="2016-10-09T08:32:08.923" Score="4" Body="&lt;p&gt;It &lt;em&gt;looks&lt;/em&gt; like you missed this part in :help quote_number (emphasis mine):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim fills these registers with text from yank and delete commands.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Numbered register 0 contains the text from the most recent yank command,&#xA;  unless the command specified another register with [&quot;x].&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Numbered register 1 contains the text deleted by the most recent delete or&#xA;  change command, &lt;strong&gt;unless the command specified another register or the text is&#xA;  less than one line (the small delete register is used then).&lt;/strong&gt;  An exception is&#xA;  made for the delete operator with these movement commands: %, (, ), `,&#xA;  /, ?, n, N, { and }.  Register &quot;1 is always used then (this is Vi&#xA;  compatible).  The &quot;- register is used as well if the delete is within a line.&#xA;  Note that these characters may be mapped.  E.g. % is mapped by the matchit&#xA;  plugin.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;With each successive deletion or change, Vim shifts the previous contents&#xA;  of register 1 into register 2, 2 into 3, and so forth, losing the previous contents of register 9.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-10-09T09:44:37.160" LastActivityDate="2016-10-09T09:44:37.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9866" PostTypeId="2" ParentId="9861" CreationDate="2016-10-09T11:12:17.177" Score="1" Body="&lt;p&gt;Since you said it does not appear under any register with &lt;code&gt;:register&lt;/code&gt;, it sounds like it's ending up in &lt;code&gt;&quot;_&lt;/code&gt;, the &lt;em&gt;&quot;black-hole register&quot;&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you run &lt;code&gt;:map d&lt;/code&gt; and notice that any mappings map &lt;code&gt;d&lt;/code&gt; to &lt;code&gt;&quot;_d&lt;/code&gt;, you could expand it via &lt;code&gt;:verbose map d&lt;/code&gt; and find from where the mapping was set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply append &lt;code&gt;:unmap d&lt;/code&gt; past the point in your &lt;code&gt;.vimrc&lt;/code&gt; where you source the plugin or file that made the mapping. (This is preferrable to editing said plugin or file, since any upstream changes would undo your edit. Of course, if the setting is in your &lt;code&gt;.vimrc&lt;/code&gt; this doesn't apply.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, if &lt;code&gt;d&lt;/code&gt; (or any other mapping you're having issues with) have multiple mappings (i.e. it's only mapped to &lt;code&gt;&quot;_d&lt;/code&gt; for a certain mode), you can delete just that mapping with &lt;code&gt;:[mode]unmap d&lt;/code&gt; (e.g. &lt;code&gt;:nunmap d&lt;/code&gt; for normal mode, &lt;code&gt;:vunmap d&lt;/code&gt; for visual mode or &lt;code&gt;:xunmap d&lt;/code&gt; for select mode.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2016-10-09T11:12:17.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9867" PostTypeId="1" AcceptedAnswerId="9950" CreationDate="2016-10-09T21:02:34.137" Score="3" ViewCount="1996" Body="&lt;p&gt;I've been trying to write a simple complete function for Vim that tries&#xA;multiple values for the &lt;code&gt;base&lt;/code&gt; argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a version that works but which I find unsatisfactory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CompleteFunc(findstart, base)&#xA;  if a:findstart&#xA;    let start = AmbitiousFindStart()&#xA;    &quot; -1 to exclude cursor, -1 again to convert column to index&#xA;    let fake_base = getline('.')[start:col('.')-2]&#xA;    if empty(GetCompletions(fake_base))&#xA;      let start = FallbackFindStart()&#xA;    endif&#xA;    return start&#xA;  else&#xA;    return GetCompletions(a:base)&#xA;  endif&#xA;endfunction&#xA;set completefunc=CompleteFunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Specifically in my case, &lt;code&gt;AmbitiousFindStart()&lt;/code&gt; tries to set &lt;code&gt;start&lt;/code&gt; so as to&#xA;consume all non-whitespace characters, but if this fails, I want to use&#xA;&lt;code&gt;FallbackFindStart()&lt;/code&gt;, which only tries to consume word characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the problems I see with this approach:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Even in the case when &lt;code&gt;AmbitiousFindStart()&lt;/code&gt; succeeds (i.e. produces matches&#xA;when calling &lt;code&gt;GetCompletions(fake_base)&lt;/code&gt;), &lt;code&gt;GetCompletions()&lt;/code&gt; is called&#xA;twice.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;fake_base&lt;/code&gt; approach seems inelegant to me; Vim is the one who is&#xA;suppose to provide me with &lt;code&gt;base&lt;/code&gt;, rather than me going out of my way to try&#xA;to calculate what &lt;code&gt;base&lt;/code&gt; would be. Additionally I'm not even sure if my&#xA;&lt;code&gt;base&lt;/code&gt; calculation is correct (it seems to work in the cases I've tried, but&#xA;there might be problems with e.g. multi-byte characters). I've therefore&#xA;called it the &quot;fake&quot; &lt;code&gt;base&lt;/code&gt; to distinguish it from the &quot;real&quot; &lt;code&gt;base&lt;/code&gt; that&#xA;Vim would provide.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My first approach to fix problem (1) was the following, which does not work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BadCompleteFunc(findstart, base)&#xA;  if a:findstart&#xA;    let start = AmbitiousFindStart()&#xA;    return start&#xA;  else&#xA;    let compl_lst = GetCompletions(a:base)&#xA;    if empty(compl_lst)&#xA;      let fake_base = getline('.')[start:col('.')-2]&#xA;      let compl_lst = GetCompletions(fake_base)&#xA;    endif&#xA;    return compl_lst&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with this is that Vim uses the &lt;code&gt;start&lt;/code&gt; value returned from the&#xA;first time &lt;code&gt;BadCompleteFunc()&lt;/code&gt; is called to decide what to replace the&#xA;completion with, rather than the string value of &lt;code&gt;base&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second approach I came up with is to use &lt;code&gt;complete()&lt;/code&gt;, which has problems&#xA;of its own:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Complete()&#xA;  let startidx = AmbitiousFindStart()&#xA;  let startcol = startidx + 1&#xA;  let currcol = col('.')&#xA;  let curridx = currcol - 1&#xA;  let fake_base = getline('.')[startidx:curridx-1]&#xA;  let matches = GetCompletions(fake_base)&#xA;  if !empty(matches)&#xA;    call complete(startcol, matches)&#xA;  else&#xA;    let startidx = FallbackFindStart()&#xA;    let startcol = startidx + 1&#xA;    let fake_base = getline('.')[startidx:curridx-1]&#xA;    let matches = GetCompletions(fake_base)&#xA;    call complete(startcol, matches)&#xA;  endif&#xA;  return ''&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem here is that this assumes a usage through a custom insert mode&#xA;mapping, such as &lt;code&gt;inoremap &amp;lt;C-X&amp;gt;&amp;lt;C-U&amp;gt; &amp;lt;C-R&amp;gt;=Complete()&amp;lt;CR&amp;gt;&lt;/code&gt;, rather than being&#xA;able to set &lt;code&gt;completefunc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the right way to approach this sort of complete function?&lt;/p&gt;&#xA;" OwnerUserId="9628" LastActivityDate="2016-10-18T14:00:04.807" Title="How to write a `completefunc`/`omnifunc` that tries multiple base values?" Tags="|vimscript|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9868" PostTypeId="2" ParentId="6697" CreationDate="2016-10-09T22:52:28.213" Score="7" Body="&lt;p&gt;First, thank you for this very comprehensive and thoughtful post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some testing, I have come to this conclusion:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Control characters are displayed using the caret notation: &lt;code&gt;^M&lt;/code&gt; for &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; (carriage return) and &lt;code&gt;^J&lt;/code&gt; for &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt; (line feed). In buffers, &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; (end-of-line) are displayed as new screen lines and are input with the enter key. &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; depend on the file format of the buffer: &lt;code&gt;&amp;lt;EOL&amp;gt; = &amp;lt;CR&amp;gt;|&amp;lt;LF&amp;gt;|&amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;&lt;/code&gt; for &lt;code&gt;mac|unix|dos&lt;/code&gt; respectively.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When editing a buffer, the file format is always set. To change the file format of an opened buffer, you can use the following command that converts &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set f[ile]f[ormat]=mac|unix|dos&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In addition to converting &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt;, this command converts &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; when changing the file format from &lt;code&gt;mac&lt;/code&gt; to &lt;code&gt;unix|dos&lt;/code&gt;, and conversely, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt; when changing the file format from &lt;code&gt;unix|dos&lt;/code&gt; to &lt;code&gt;mac&lt;/code&gt;. To see the real bytes of the buffer, you can use the following command that transforms the textual representation of the buffer into its hexadecimal representation using the convenient hexadecimal editor xxd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!xxd&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In registers (showed with the command &lt;code&gt;:reg[isters]&lt;/code&gt; or &lt;code&gt;:di[splay]&lt;/code&gt;), &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; are always &lt;em&gt;displayed&lt;/em&gt; as &lt;code&gt;^J&lt;/code&gt; (but not all &lt;code&gt;^J&lt;/code&gt; are &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt;), regardless of the file format of the buffer. However &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; are &lt;em&gt;stored&lt;/em&gt; as they should. To be able to distinguish visually real &lt;code&gt;^J&lt;/code&gt; (that is &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt;) from the others &lt;code&gt;^J&lt;/code&gt; (that is &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt;) in registers, you can use the following command that displays the hexadecimal values instead of the caret notation of control characters different from &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set d[ispla]y=uhex&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In search patterns and substitution strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\r = newline different from &amp;lt;EOL&amp;gt; (&amp;lt;CR&amp;gt; if &amp;lt;EOL&amp;gt; = &amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;|&amp;lt;LF&amp;gt;, &amp;lt;LF&amp;gt; if &amp;lt;EOL&amp;gt; = &amp;lt;CR&amp;gt;)&#xA;\n = &amp;lt;EOL&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Everywhere:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;C-M&amp;gt;|&amp;lt;C-V&amp;gt;&amp;lt;EOL&amp;gt; = newline different from &amp;lt;EOL&amp;gt;&#xA;&amp;lt;C-V&amp;gt;&amp;lt;C-J&amp;gt; = &amp;lt;NUL&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This shows that when the file format is &lt;code&gt;dos&lt;/code&gt;, it is impossible to input &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt;, since &lt;code&gt;&amp;lt;EOL&amp;gt; = &amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;C-M&amp;gt;|&amp;lt;C-V&amp;gt;&amp;lt;EOL&amp;gt; = &amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In substitution strings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;newline different from &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; are &lt;em&gt;interpreted&lt;/em&gt; as &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt;;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; are &lt;em&gt;interpreted&lt;/em&gt; as &lt;code&gt;&amp;lt;NUL&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, according to 4., &lt;code&gt;:%s[ubstitute]/\r/\r/g&lt;/code&gt; replaces every newline different from &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; in the buffer with &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt;, while &lt;code&gt;:%s[ubstitute]/\n/\n/g&lt;/code&gt; replaces every &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; in the buffer with &lt;code&gt;&amp;lt;NUL&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In the search register &lt;code&gt;/&lt;/code&gt; and command register &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; are &lt;em&gt;converted&lt;/em&gt; to&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;newline different from &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; when inserted from a register with &lt;code&gt;/&amp;lt;C-R&amp;gt;{register}&lt;/code&gt; or &lt;code&gt;:&amp;lt;C-R&amp;gt;{register}&lt;/code&gt; respectively;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;NUL&amp;gt;&lt;/code&gt; when inserted from a register with &lt;code&gt;:let @/=@{register}&lt;/code&gt; or &lt;code&gt;:let @:=@{register}&lt;/code&gt; respectively.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In buffers, newline different from &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; are &lt;em&gt;converted&lt;/em&gt; to &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; when inserted from a register using &lt;code&gt;i&amp;lt;C-R&amp;gt;{register}&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why is a Line Feed converted into a Null character inside the search&#xA;  register and into a Carriage Return on the command line?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Before copying &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt; from the unnamed register &lt;code&gt;&quot;&lt;/code&gt; to other registers, you need to input &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt; and put it in the register &lt;code&gt;&quot;&lt;/code&gt;. If the file format is &lt;code&gt;unix&lt;/code&gt;, you can do that by using &lt;code&gt;yy&lt;/code&gt; on an empty line; if the file format is &lt;code&gt;mac&lt;/code&gt;, you can do that by using &lt;code&gt;i&amp;lt;C-V&amp;gt;&amp;lt;C-M&amp;gt;&amp;lt;Esc&amp;gt;yl&lt;/code&gt;; if the file format is &lt;code&gt;dos&lt;/code&gt;, you cannot input &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt; (cf. 5.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now your statement is partially wrong, since&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;you do not use the same method for copying &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt; from the register &lt;code&gt;&quot;&lt;/code&gt; into the search register &lt;code&gt;/&lt;/code&gt; and command register &lt;code&gt;:&lt;/code&gt;. You use &lt;code&gt;:let @/=@&quot;&lt;/code&gt; for copying into the register &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;:&amp;lt;C-R&amp;gt;&quot;&lt;/code&gt; for copying into the register &lt;code&gt;:&lt;/code&gt;. Using &lt;code&gt;/&amp;lt;C-R&amp;gt;&quot;&lt;/code&gt; and &lt;code&gt;:&amp;lt;C-R&amp;gt;&quot;&lt;/code&gt; respectively will give you the same result (&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;) in both cases;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;the conversions of &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt; that take place with your two different copy methods happen only when the file format is &lt;code&gt;unix&lt;/code&gt;. If it is &lt;code&gt;mac&lt;/code&gt;, &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; converted when copied to the register &lt;code&gt;/&lt;/code&gt; or the register &lt;code&gt;:&lt;/code&gt;, and if it is &lt;code&gt;dos&lt;/code&gt; you cannot even input &lt;code&gt;&amp;lt;LF&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The right statement is given by 7. But I really do not the know the reasons behind it.&lt;/p&gt;&#xA;" OwnerUserId="9600" LastEditorUserId="9600" LastEditDate="2016-10-10T06:01:19.910" LastActivityDate="2016-10-10T06:01:19.910" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9869" PostTypeId="1" AcceptedAnswerId="9870" CreationDate="2016-10-10T01:51:39.003" Score="10" ViewCount="1208" Body="&lt;p&gt;I was recently aware of the filtering &lt;code&gt;!&lt;/code&gt; technique, and I love it. Unfortunately, I am not able to use it in a visual-block mode. Hope some experts here would help me out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I want to in-place sort a column such as the third below (just a MWE). &lt;strong&gt;And I don't want to disturb the other columns when I sort.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to filter (&lt;code&gt;!&lt;/code&gt;) the visually (block-mode) selected third column through &lt;code&gt;sort&lt;/code&gt; utility. But the sort rather extends beyond selection i.e. all of the rows are swapped, not just the selection, that too sorting based on the &lt;em&gt;first&lt;/em&gt; column!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.  LARGEST         40&#xA;2.  SECOND-LARGEST  168     &#xA;3.  MID             2.8     &#xA;4.  MID             540     &#xA;5.  MID             14.84   &#xA;6.  MID             40      &#xA;7.  SECOND-LEAST    64      &#xA;8.  LEAST           8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I selected last column using visual-block, and said &lt;code&gt;!sort --reverse&lt;/code&gt; which shows up as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;!sort --reverse&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the result is strange opposed to what I expected. The result has the entire rows sorted/swapped, not just one column, and that too, based on the &lt;em&gt;first&lt;/em&gt; column irrespective of my third-column selection! &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 8.  LEAST           8    &#xA; 7.  SECOND-LEAST    64      &#xA; 6.  MID             40      &#xA; 5.  MID             14.84   &#xA; 4.  MID             540     &#xA; 3.  MID             2.8     &#xA; 2.  SECOND-LARGEST  168     &#xA; 1.  LARGEST         40   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unless impossible otherwise, I would like a pure vim+sort solution, rather than the relatively advanced tools such as &lt;code&gt;sed&lt;/code&gt;/&lt;code&gt;awk&lt;/code&gt;. It is more importantly to know myself, how limited the visual-block mode is, compared to say, visual-mode.&lt;/p&gt;&#xA;" OwnerUserId="4583" LastEditorUserId="4583" LastEditDate="2016-10-10T05:54:02.547" LastActivityDate="2016-10-10T09:53:19.943" Title="Sorting a column without altering other columns" Tags="|visual-block|sort|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9870" PostTypeId="2" ParentId="9869" CreationDate="2016-10-10T08:05:50.847" Score="9" Body="&lt;p&gt;I think your best hope is the &lt;a href=&quot;https://github.com/vim-scripts/vis&quot;&gt;vis.vim&lt;/a&gt; plugin. This plugin provides a command &lt;code&gt;B&lt;/code&gt; which allows to apply a command to a block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here after installing the plugin, you'd select your block and then use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;B !sort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the command can be anything, so instead of &lt;code&gt;!sort&lt;/code&gt; you could do a lot of other processing on the block like saving it to another file (&lt;code&gt;:'&amp;lt;,'&amp;gt;B w foo.txt&lt;/code&gt;) or applying a substitution (&lt;code&gt;:'&amp;lt;,'&amp;gt;B s/foo/bar/g&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-10-10T09:53:19.943" LastActivityDate="2016-10-10T09:53:19.943" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9871" PostTypeId="1" AcceptedAnswerId="9872" CreationDate="2016-10-10T08:45:57.857" Score="1" ViewCount="197" Body="&lt;p&gt;I want to install my vim plugins in &lt;code&gt;~/.dotfiles/vim&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the proper way to install Pathogen in this case and keep it under version control?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I've tried is to install it in &lt;code&gt;~/.dotfiles/vim/autoload/pathogen.vim&lt;/code&gt; and create a symbolic link to this in &lt;code&gt;~./vim/autoload&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this way i would have to create symbolic links to all of my plugins, and pathogen itself is not under version control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do i do this correctly?&lt;/p&gt;&#xA;" OwnerUserId="9632" LastActivityDate="2016-10-10T10:50:49.510" Title="Installing pathogen inside .dotfiles" Tags="|plugin-pathogen|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9872" PostTypeId="2" ParentId="9871" CreationDate="2016-10-10T10:50:49.510" Score="1" Body="&lt;p&gt;You can setup whole Vim directory inside &lt;code&gt;~/.dotfiles/vim&lt;/code&gt; and do a symlink&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim -&amp;gt; ~/.dotfiles/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you will have all the plugins as submodules (including Pathogen) inside &lt;code&gt;~/.dotfiles/vim/bundle&lt;/code&gt;. To handle Pathogen, create a link&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.dotfiles/vim/autoload/pathogen.vim -&amp;gt; ~/.dotfiles/vim/bundle/&amp;lt;path to pathogen.vim&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-10-10T10:50:49.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9873" PostTypeId="1" AcceptedAnswerId="9874" CreationDate="2016-10-10T12:25:41.083" Score="11" ViewCount="8266" Body="&lt;p&gt;Is it possible, in one instance of VIM, to open one file in few buffers and edit them independently? &lt;/p&gt;&#xA;" OwnerUserId="9633" LastActivityDate="2016-10-10T13:03:08.693" Title="How to open same file in multiple buffers" Tags="|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9874" PostTypeId="2" ParentId="9873" CreationDate="2016-10-10T13:03:08.693" Score="19" Body="&lt;p&gt;I'm not sure about what you mean by buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim jargon, a buffer maps a file, or a file that could be saved later. If you really want independent buffers initialized with a same file, you'll need to fill each buffer with &lt;code&gt;:read path/to/filename&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, you'll have completely independent buffers. Saving them won't even update the initial file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim, we also have windows. A buffer may be displayed in one, or more, window(s), or even in none. If you split (horizontally) the current window with &lt;code&gt;:sp&lt;/code&gt; (or vertically with &lt;code&gt;:vsp&lt;/code&gt;), you'll have two (or more) windows to a same buffer. They don't need to display the same part of the buffer. Any modification to a buffer through a window will be visible in the other windows. Saving the buffer saves... the current buffer in one single file.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-10-10T13:03:08.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9875" PostTypeId="1" CreationDate="2016-10-10T13:10:10.923" Score="2" ViewCount="868" Body="&lt;p&gt;I'm running bash as shell, and, after runnning &lt;code&gt;set -o vi&lt;/code&gt; I would like to delete innner words to the cursor using &lt;code&gt;diw&lt;/code&gt;, but when I run &lt;code&gt;diw&lt;/code&gt; nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Im on Ubuntu 14.04&lt;/p&gt;&#xA;" OwnerUserId="6086" LastActivityDate="2016-10-11T11:07:44.123" Title="diw (delete inner word) in bash doesn't work" Tags="|key-bindings|" AnswerCount="1" CommentCount="5" ClosedDate="2016-10-11T09:09:52.547" ContentLicense="CC BY-SA 3.0" />
  <row Id="9876" PostTypeId="2" ParentId="9875" CreationDate="2016-10-10T13:20:45.340" Score="7" Body="&lt;p&gt;Readline's vi mode supports motions, but it does not support text objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's possible to hack in support for &lt;code&gt;diw&lt;/code&gt; and similar commands via your &lt;code&gt;.inputrc&lt;/code&gt; using something like (untested, stolen from &lt;a href=&quot;https://github.com/minos-org/bash-minos-settings/blob/master/etc%23%23inputrc&quot; rel=&quot;nofollow&quot;&gt;minos.org's bash settings&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$if mode=vi&#xA;set keymap vi-command&#xA;&quot;diw&quot;: &quot;lbdw&quot;&#xA;$endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that in bash, you can edit your current commandline in your $EDITOR by pressing &lt;code&gt;v&lt;/code&gt; whilst in Readline vi mode's command mode, enabling you to harness the full power of Vim for editing your shell commands. (Whilst in the default emacs-style mode, you can do the same via the key combination &lt;code&gt;&amp;lt;ctrl-x&amp;gt;&amp;lt;ctrl-e&amp;gt;&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-10-11T11:07:44.123" LastActivityDate="2016-10-11T11:07:44.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9877" PostTypeId="1" AcceptedAnswerId="9879" CreationDate="2016-10-10T13:22:06.767" Score="8" ViewCount="390" Body="&lt;p&gt;Lured in by the promise of evil-mode, I've been moonlighting in Emacs. It's a wild world with a mix of hairy lose-ends and astoundingly smart features. One feature I really like is a command called &lt;code&gt;bury-buffer&lt;/code&gt;, which puts the current buffer way down at the bottom of the buffer-list and displays the previously active buffer in its place. By burying a buffer, it becomes the least likely candidate for &lt;code&gt;other-buffer&lt;/code&gt; (like Vim's &lt;code&gt;alternate-file&lt;/code&gt; on &lt;code&gt;Ctrl-^&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I might be bouncing back and forth between buffer A and buffer B. Then, while I'm in B, I want check something in buffer C. I do, then I bury C, and I'm put back in B &lt;em&gt;with A as my alternate-file&lt;/em&gt;. The same is true if I had deleted buffer C rather than burying it. Either action would put me back in my A/B workflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do the same in Vim, alternating between A and B, then from B open C, the buffer list shows C as active (&lt;code&gt;%&lt;/code&gt;) and B as alternate (&lt;code&gt;#&lt;/code&gt;). When I delete C, Vim returns me to B. But C is &lt;em&gt;still&lt;/em&gt; the alternate-file, even though it no longer appears in the buffer list. If I hit &lt;code&gt;Ctrl-^&lt;/code&gt;, it reopens C rather than taking me back to A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can configure Vim so its alternate-file behavior would instead mark the most-recently used &lt;em&gt;open&lt;/em&gt; buffer as the alternate instead of reviving deleted buffers? Is there a way to manipulate its concept of the alternate-file?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2016-10-10T17:04:14.633" Title="Improving alternate-file behavior to avoid reopening deleted buffers?" Tags="|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9878" PostTypeId="1" AcceptedAnswerId="9883" CreationDate="2016-10-10T13:29:15.883" Score="9" ViewCount="638" Body="&lt;p&gt;From time to time I have to work with code that isn't indented to the level of indentation I have Vim set up to (4 spaces per level), usually after copy/pasting something in the file. I usually make do with &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;. The problem is they don't jump to the next indentation level, they just add or subtract 4 spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have code like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if condition:&#xA;    do this&#xA;   do that&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doing &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; on &lt;code&gt;do that&lt;/code&gt; will result in &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if condition:&#xA;    do this&#xA;       do that&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want it to go to this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if condition:&#xA;    do this&#xA;    do that&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Beside easily  matching the indentation of the line above, I want it to jump to the next level of indentation, not add 4 spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have in my .vimrc regarding indentation&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set tabstop=4 shiftwidth=4 expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1545" LastEditorUserId="1545" LastEditDate="2016-10-10T14:54:35.370" LastActivityDate="2016-10-10T20:11:41.823" Title="Indent to next indentation level with &gt;&gt;" Tags="|indentation|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9879" PostTypeId="2" ParentId="9877" CreationDate="2016-10-10T13:52:08.147" Score="7" Body="&lt;p&gt;I &lt;em&gt;think&lt;/em&gt; you are looking for &lt;code&gt;:help :keepalt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim a b       current buffer is 'a', no alternate file&#xA;:bn             current is 'b', alternate is 'a'&#xA;:b#             current is 'a', alternate is 'b'&#xA;:b#             current is 'b', alternate is 'a'&#xA;:keepalt e c    current is 'c', alternate is still 'a'&#xA;:keepalt bd     current is 'b', alternate is 'a'&#xA;:b#             current is 'a', alternate is 'b'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-10-10T17:04:14.633" LastActivityDate="2016-10-10T17:04:14.633" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9880" PostTypeId="1" CreationDate="2016-10-10T14:57:13.947" Score="5" ViewCount="1514" Body="&lt;p&gt;Context: I tend to use tabs to contain splits of files that are grouped around some purpose (e.g. in a typical MVC framework, I'll have the model/view/controller files for a given part of the app open in splits under the same tab). Since these groups tend to use the same filenames across different parts of my codebases (like &lt;code&gt;views.py&lt;/code&gt;, or &lt;code&gt;main.yml&lt;/code&gt;), the tab names are useless - I have to switch through the tabs and examine the file contents or full paths to see what they actually contain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I could either make the tab titles more useful in these situations automatically, or a way to manually change the tab title? I'm flexible in how exactly this would be done since I imagine it's an esoteric need.&lt;/p&gt;&#xA;" OwnerUserId="9634" LastActivityDate="2016-10-11T14:45:16.453" Title="Retitling tab labels" Tags="|tabbed-user-interface|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9881" PostTypeId="2" ParentId="9880" CreationDate="2016-10-10T15:59:56.567" Score="5" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27tabline%27&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;'tabline'&lt;/code&gt;&lt;/a&gt; setting for this. Here's an example adapted from &lt;a href=&quot;http://vimhelp.appspot.com/tabpage.txt.html#setting%2dtabline&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:help setting-tabline&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabline=%!MyTabLine()&#xA;&#xA;&quot; Set the entire tabline&#xA;function! MyTabLine()&#xA;    let s = ''&#xA;    for i in range(tabpagenr('$'))&#xA;        &quot; select the highlighting&#xA;        if i + 1 == tabpagenr()&#xA;            let s .= '%#TabLineSel#'&#xA;        else&#xA;            let s .= '%#TabLine#'&#xA;        endif&#xA;&#xA;        &quot; set the tab page number (for mouse clicks)&#xA;        let s .= '%' . (i + 1) . 'T'&#xA;&#xA;        &quot; the label is made by MyTabLabel()&#xA;        let s .= ' %{MyTabLabel(' . (i + 1) . ')} '&#xA;    endfor&#xA;&#xA;    &quot; after the last tab fill with TabLineFill and reset tab page nr&#xA;    let s .= '%#TabLineFill#%T'&#xA;&#xA;    &quot; right-align the label to close the current tab page&#xA;    if tabpagenr('$') &amp;gt; 1&#xA;        let s .= '%=%#TabLine#%999Xclose'&#xA;    endif&#xA;&#xA;    return s&#xA;endfunction&#xA;&#xA;&quot; Set the label for a single tab&#xA;function! MyTabLabel(n)&#xA;&#xA;    &quot; This is run in the scope of the active tab, so t:name&#xA;    &quot; won't work.&#xA;    let l:tabname = gettabvar(a:n, 'name', '')&#xA;&#xA;    &quot; This variable exists!&#xA;    if l:tabname != ''&#xA;        return l:tabname&#xA;    endif&#xA;&#xA;    &quot; If it's not found fall back to the buffer name&#xA;    let buflist = tabpagebuflist(a:n)&#xA;    let winnr = tabpagewinnr(a:n)&#xA;    let l:bname = bufname(buflist[winnr - 1])&#xA;&#xA;    &quot; Unnamed buffer, scratch buffer, etc. Could be more detailed.&#xA;    if l:bname == ''&#xA;        let l:bname = '[No Name]'&#xA;    endif&#xA;&#xA;    return l:bname&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key is in the &lt;code&gt;MyTabLabel()&lt;/code&gt; function. If the tab-local &lt;code&gt;t:name&lt;/code&gt; variable exists, we use that. Otherwise we default back to the currently active buffer name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To name the tab label, simple set the &lt;code&gt;t:name&lt;/code&gt; variable for that tab. For the currently active tab:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let t:name = 'Session one'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or for a specific tab nr:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call settabvar(3, 'name', 'Session four')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-10-11T14:45:16.453" LastActivityDate="2016-10-11T14:45:16.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9882" PostTypeId="2" ParentId="9878" CreationDate="2016-10-10T17:47:19.930" Score="2" Body="&lt;p&gt;If you always want &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; to indent to the next tabstop and &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; to delete to the last tabstop, you can rebind them like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;&amp;lt; ^i&amp;lt;BS&amp;gt;&amp;lt;esc&amp;gt;&#xA;:nnoremap &amp;gt;&amp;gt; ^i&amp;lt;tab&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will move the cursor, but you could probably do some mark trickery to move it back. &lt;code&gt;^&lt;/code&gt; doesn't leave a &lt;code&gt;m'&lt;/code&gt; mark, but you can leave one manually inside the binding.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2016-10-10T17:47:19.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9883" PostTypeId="2" ParentId="9878" CreationDate="2016-10-10T20:11:41.823" Score="12" Body="&lt;p&gt;When you use one of the commands &lt;code&gt;{count}&amp;gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;{count}&amp;lt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;gt;{motion}&lt;/code&gt; or &lt;code&gt;&amp;lt;{motion}&lt;/code&gt;, on some lines which have already been indented, and you want their new indentation level to be a multiple of your &lt;code&gt;'shiftwidth'&lt;/code&gt; option value, you can enable the &lt;code&gt;'shiftround'&lt;/code&gt; option, and add this line in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shiftround&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-10-10T20:11:41.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9884" PostTypeId="1" AcceptedAnswerId="9885" CreationDate="2016-10-11T13:59:28.177" Score="7" ViewCount="1091" Body="&lt;p&gt;The doc about the substitute function &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#substitute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h substitute()&lt;/code&gt;&lt;/a&gt; tells us:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[...] the matching with {pat} is &lt;strong&gt;always done like the 'magic' option is set&lt;/strong&gt; [...]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's cool but what if I need to use &lt;code&gt;substitute()&lt;/code&gt; with another mode like say, verymagic or verynomagic? Is there a way to modify this behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess a flag won't help me since the same doc topic says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[...] When {flags} is &quot;g&quot;, all matches of {pat} in {expr} are replaced.  Otherwise {flags} should be &quot;&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So here are my two questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is it possible to modify the magic mode used by &lt;code&gt;substitute()&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;If it is not possible, what is the most elegant/efficient way to perform a substitution on a string contained in a variable with another magic mode?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-11-22T09:57:30.863" LastActivityDate="2016-11-22T09:57:30.863" Title="How to make substitute() use another magic mode?" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9885" PostTypeId="2" ParentId="9884" CreationDate="2016-10-11T14:24:13.293" Score="9" Body="&lt;p&gt;You can do this by including escapes in the pattern that change the magic mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help pattern&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use of &quot;\m&quot; makes the pattern after it be interpreted as if 'magic' is set,&#xA;  ignoring the actual value of the 'magic' option.&#xA;  Use of &quot;\M&quot; makes the pattern after it be interpreted as if 'nomagic' is used.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Use of &quot;\v&quot; means that in the pattern after it all ASCII characters except&#xA;  '0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning.  &quot;very magic&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Use of &quot;\V&quot; means that in the pattern after it only the backslash and the&#xA;  terminating character (/ or ?) has a special meaning.  &quot;very nomagic&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1089" LastActivityDate="2016-10-11T14:24:13.293" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9886" PostTypeId="1" CreationDate="2016-10-11T16:50:39.117" Score="3" ViewCount="2529" Body="&lt;p&gt;I'd like to be able to conveniently navigate to the file where a Python value (function/class/constant) is defined. Most of the guides I can find for using ctags with Python suggest options that aren't supported by the various ctags-like programs that I've found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried using vanilla ctags (&lt;code&gt;/usr/bin/ctags&lt;/code&gt; on OS X), exuberant ctags (through brew), and etags (on OS X) to generate &lt;code&gt;tags&lt;/code&gt; files for a Python project and have been somewhat dissatisfied with the out of the box results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I navigate to the project root and run &lt;code&gt;ctags -R .&lt;/code&gt; I get a lot of lines like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;version_info    api-docs/venv/lib/python2.7/site-packages/pip/_vendor/requests/packages/chardet/__init__.py /^from sys import version_info$/;&quot;  i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A line like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from sys import version_info&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;appears literally in the Python source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The symbol &lt;code&gt;version_info&lt;/code&gt; is defined in the &lt;code&gt;sys&lt;/code&gt; module, which should be somewhere in the standard library in my virtualenv. When you do an unqualified import in Python, you really are copying the contents of the symbol to a new symbol in the current module, but most of the time I just want to jump to the place where the symbol was originally defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get that the actual place where a symbol is defined depends on information only available at runtime like the &lt;code&gt;PYTHONPATH&lt;/code&gt;, but a heuristic guess is better than nothing (there might also be a nice interface for cycling between symbols that are defined in multiple files built in to vim, I'm not sure).&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="51" LastEditDate="2016-11-10T18:26:02.453" LastActivityDate="2016-11-10T18:26:02.453" Title="Generating tags for python that follow imports" Tags="|ctags|filetype-python|" AnswerCount="0" CommentCount="2" ClosedDate="2016-10-12T16:29:59.543" ContentLicense="CC BY-SA 3.0" />
  <row Id="9887" PostTypeId="1" AcceptedAnswerId="9909" CreationDate="2016-10-11T19:49:02.883" Score="0" ViewCount="394" Body="&lt;p&gt;Can you please suggest any &lt;code&gt;latex&lt;/code&gt; plugin with livereload/preview support ? All of the plugins google suggested me does not support preview/reload, or use 3rd party tools that use another 3rd party tools and so on... Which one do you use or can suggest (if you sure it really work on linux). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you !&lt;/p&gt;&#xA;" OwnerUserId="9658" LastActivityDate="2016-10-14T09:40:28.060" Title="vim latex livereload/preview plugin" Tags="|filetype-tex|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="9888" PostTypeId="1" CreationDate="2016-10-11T23:00:38.810" Score="6" ViewCount="2287" Body="&lt;p&gt;It is possible to pipe visually selected &lt;em&gt;lines&lt;/em&gt; (i.e. selected with uppercase &lt;kbd&gt;V&lt;/kbd&gt;) using &lt;kbd&gt;:&lt;/kbd&gt;, after which I can enter a command in vim's command line,  e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!python -m base64 -d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to do the same for the selected &lt;em&gt;character range&lt;/em&gt; (i.e. selected with lowercase &lt;kbd&gt;v&lt;/kbd&gt;). Using &lt;kbd&gt;:&lt;/kbd&gt; still creates a linewise range (&lt;code&gt;:'&amp;lt;'&amp;gt;&lt;/code&gt;). Trying to manually provide a character range like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:`&amp;lt;,`&amp;gt;!python -m base64 -d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Still does not work; it outputs this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E492: Not an editor command: `&amp;lt;`&amp;gt;!python -m base64 -d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The question: &lt;strong&gt;How can I pipe visually selected characters to a system (cmd) program?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="8856" LastEditorUserId="8856" LastEditDate="2016-10-12T01:38:29.163" LastActivityDate="2016-10-12T12:50:12.030" Title="How to pipe *characters* to cmd ( `:!` )" Tags="|command-line|visual-mode|range|" AnswerCount="2" CommentCount="3" ClosedDate="2016-10-12T13:25:42.350" ContentLicense="CC BY-SA 3.0" />
  <row Id="9890" PostTypeId="2" ParentId="9888" CreationDate="2016-10-12T09:03:38.500" Score="3" Body="&lt;p&gt;You can define a function in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    function! GetVisualSelection()&#xA;    let [lnum1, col1] = getpos(&quot;'&amp;lt;&quot;)[1:2]&#xA;    let [lnum2, col2] = getpos(&quot;'&amp;gt;&quot;)[1:2]&#xA;    let lines = getline(lnum1, lnum2)&#xA;    let lines[-1] = lines[-1][: col2 - (&amp;amp;selection == 'inclusive' ? 1 : 2)]&#xA;    let lines[0] = lines[0][col1 - 1:]&#xA;    return join(lines, &quot;\\n&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then execute something like this:&#xA;&lt;code&gt;&amp;lt;C-u&amp;gt;exe &quot;!echo \&quot;&quot; . GetVisualSelection() . &quot;\&quot; | python -m base64 -d&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give credits I took function from &lt;a href=&quot;https://stackoverflow.com/a/6271254/1199156&quot;&gt;this SO answer&lt;/a&gt;, only change is last line to include double backslash to make it work in shell.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-10-12T09:03:38.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9891" PostTypeId="2" ParentId="9888" CreationDate="2016-10-12T12:50:12.030" Score="2" Body="&lt;p&gt;If someone looks for an answer, here is the one from &lt;a href=&quot;https://vi.stackexchange.com/questions/7388/replace-selection-with-output-of-external-command&quot;&gt;Replace selection with output of external command&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;c&lt;/kbd&gt; to put the visually selected text in the default (&lt;code&gt;&quot;&lt;/code&gt;&quot;) register&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt; to execute a Vim command&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;=&lt;/kbd&gt; to use the &lt;code&gt;execute&lt;/code&gt; register&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;system('whatever command', @&quot;)&lt;/code&gt; to pass the default register (&lt;code&gt;@&quot;&lt;/code&gt;) to the system command&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; to execute the command&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; to return to the normal mode&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This can be remapped to a shortcut&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;btoa c&amp;lt;c-r&amp;gt;=system('base64 --decode --wrap=0', @&quot;)&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8856" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-10-12T12:50:12.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9892" PostTypeId="1" CreationDate="2016-10-12T16:12:50.643" Score="8" ViewCount="3141" Body="&lt;p&gt;Problem:&#xA;I have &lt;code&gt;.glabels&lt;/code&gt; generated files, which are gzipped xml. When I rename file to have suffix &lt;code&gt;.xml.gz&lt;/code&gt;, then VIM properly recognizes file and it's editable, human readable xml. After edit I have to rename back to original name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I try to open e.g. &lt;code&gt;x.glabels&lt;/code&gt; file without renaming, what happens is that I see binary data. It does not ungzipped it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to force Vim from command like to treat given file like &lt;code&gt;.gz&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If possible please make answer more general, to address general problem : how to make Vim , treat file &lt;code&gt;.extension1&lt;/code&gt; as file &lt;code&gt;.another_extension&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use case:&#xA;&lt;a href=&quot;http://glabels.org/&quot; rel=&quot;noreferrer&quot;&gt;http://glabels.org/&lt;/a&gt; uses gzipped xml, so instead of &lt;code&gt;.glabels&lt;/code&gt; extension, they could use &lt;code&gt;.xml.gz&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I rename file by adding &lt;code&gt;.txt.gz&lt;/code&gt; or &lt;code&gt;.xml.gz&lt;/code&gt; extension, VIM properly picks it up.&#xA;However with &lt;code&gt;.glabels&lt;/code&gt; extension it treats files like binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question :&#xA;How to force VIM from commandline to open given file (e.g. &quot;x.glabels&quot;) like another type (e.g. &quot;x.xml.gz&quot;) ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No Answers:&#xA;I know I can make symlink or temporarily rename file. I wonder about VIM flags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus Addition to answer:&#xA;You are welcome to include in your answer nice way of configuring VIM to treat e.g. &lt;code&gt;.glabels&lt;/code&gt; as &lt;code&gt;.xml.gz&lt;/code&gt;, but this won't be accepted as full answer, as I look for onliner that I can use on any machine I will have to deal with. Still, information about config might be helpful for other readers (or my main machines;) ).&lt;/p&gt;&#xA;" OwnerUserId="7263" LastEditorUserId="1841" LastEditDate="2016-10-14T15:20:50.847" LastActivityDate="2016-10-14T15:20:50.847" Title="How to force Vim to open given file as another filetype? (e.g. .txt.gz?)" Tags="|filetype|binary-file|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9894" PostTypeId="1" CreationDate="2016-10-12T18:14:00.553" Score="0" ViewCount="178" Body="&lt;p&gt;Lets say I have a REPL ./repl, which reads a line from the user, evaluates it, prints it and then repeats.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a .vim file that does syntax highlighting for this language in my .vim/syntax directory and I want to use this file to highlight the repl input (and if possible output).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this using vim or a other programming knowing vim syntax files?&lt;/p&gt;&#xA;" OwnerUserId="9672" LastActivityDate="2016-10-13T11:12:26.060" Title="Use .vim syntax file in language REPL" Tags="|vimscript|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9896" PostTypeId="1" AcceptedAnswerId="9897" CreationDate="2016-10-13T03:59:41.350" Score="1" ViewCount="235" Body="&lt;p&gt;I have a large list of scores that looks likes this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Michelle&#xA;,46419&#xA;,32413&#xA;Frank&#xA;,46412&#xA;,33810&#xA;Steve&#xA;,28333&#xA;,17830&#xA;,37&#xA;Joe&#xA;,136&#xA;,93&#xA;Alicia&#xA;,121300&#xA;,84146&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I move my list in Vim so it is re-arranged like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Michelle,46419,32413&#xA;Frank,46412,33810&#xA;Steve,28333,17830,37&#xA;Joe,136,93&#xA;Alicia,121300,84146&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried altering the list with this formula&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^,/s/$\n//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this doesn't get the lines with commas to fall in line behind the one ones without.&lt;/p&gt;&#xA;" OwnerUserId="9679" LastEditorUserId="2920" LastEditDate="2016-10-13T04:16:01.943" LastActivityDate="2016-10-13T11:01:53.393" Title="Joining consecutive commas using ex-mode" Tags="|substitute|ex-mode|global-command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9897" PostTypeId="2" ParentId="9896" CreationDate="2016-10-13T04:13:56.217" Score="6" Body="&lt;p&gt;You can do this with a simple substitute command. Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\n,/,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This removes a newline from every line containing a newline followed by a comma.  You could also do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\n\ze,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The way this works is by marking the end of the selection to be removed, and the only text that will be removed is what matches before &lt;code&gt;\ze&lt;/code&gt;. From &lt;code&gt;:h /\ze&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        */\ze*&#xA;\ze Matches at any position, and sets the end of the match there: The&#xA;        previous char is the last char of the whole match. |/zero-width|&#xA;        Can be used multiple times, the last one encountered in a matching&#xA;        branch is used.&#xA;        Example: &quot;end\ze\(if\|for\)&quot; matches the &quot;end&quot; in &quot;endif&quot; and&#xA;        &quot;endfor&quot;.&#xA;        This cannot be followed by a multi. |E888|&#xA;        {not in Vi} {not available when compiled without the |+syntax| feature}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-10-13T04:13:56.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9898" PostTypeId="1" AcceptedAnswerId="9899" CreationDate="2016-10-13T06:48:09.657" Score="2" ViewCount="940" Body="&lt;p&gt;I am trying to run a command on every occurrence of a search match. &#xA;So, If i have some thing like this where a search match matches only these two anchor tags, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.................. &amp;lt;a src=&quot;****&quot; &amp;gt;&amp;lt;/a&amp;gt;&#xA;......... &amp;lt;a src=&quot;****&quot;&amp;gt;&amp;lt;/a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to run a command that changes it to, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.................. &amp;lt;a class = &quot;bodyclass&quot; src=&quot;****&quot; &amp;gt;&amp;lt;/a&amp;gt;&#xA;......... &amp;lt;a class=&quot;bodyclass&quot; src=&quot;****&quot;&amp;gt;&amp;lt;/a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, how can I run a command on all the search matches? The only way I can think of is to go to the search match and do a &lt;code&gt;:execute 'normal! Wiclass=&quot;bodyclass&quot; '&lt;/code&gt; to insert the &lt;code&gt;class&lt;/code&gt; in the tag. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not looking for &lt;code&gt;g&lt;/code&gt; command here as that operates on the lines and not on the matches directly unless there is a way I can get this functionality with &lt;code&gt;g&lt;/code&gt; itself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas ?&lt;/p&gt;&#xA;" OwnerUserId="5481" LastEditorUserId="5481" LastEditDate="2016-10-13T08:23:54.793" LastActivityDate="2016-10-13T08:23:54.793" Title="Run a command on every match of a search (not on the line)" Tags="|search|repeated-commands|global-command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9899" PostTypeId="2" ParentId="9898" CreationDate="2016-10-13T07:17:36.550" Score="4" Body="&lt;p&gt;You can use the expression register, see &lt;code&gt;:h sub-replace-expression&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/search/\=MyFunction(submatch(0))/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;submatch()&lt;/code&gt; function can also be used directly inside the function, which would make the syntax even simpler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/search/\=MyFunction()/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To give a concrete example of the latter variant, consider the following Vim function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction()&#xA;  return 'x' . submatch(0) . 'y'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is a test&#xA;this is a second test&#xA;this is a third test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/search/\=MyFunction()/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the text buffer, and the result should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is a xtesty&#xA;this is a second xtesty&#xA;this is a third xtesty&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2016-10-13T07:23:21.230" LastActivityDate="2016-10-13T07:23:21.230" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9900" PostTypeId="2" ParentId="9896" CreationDate="2016-10-13T07:54:59.497" Score="4" Body="&lt;p&gt;@DJMcMayhem's solution is pretty good but Vim is pretty powerful so here is an alternative with the global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^,/normal! kJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That you can translate as &quot;For every line which begins by a comma use the normal mode keys &lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt; i.e. to go the upper line and join it with the next one&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; As @Christian Brabandt said in the comments you can also use &lt;code&gt;gJ&lt;/code&gt; which doesn't insert or remove any spaces, while &lt;code&gt;J&lt;/code&gt; will remove indent and insert up to two spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^,/normal! kgJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally to avoid using normal mode and shorten the command you could use the &lt;code&gt;:join&lt;/code&gt; command (shortened to &lt;code&gt;:j&lt;/code&gt;) with the range &lt;code&gt;-1&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^,/-1j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#J&quot;&gt;&lt;code&gt;:h J&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#gJ&quot;&gt;&lt;code&gt;:h gJ&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:j&quot;&gt;&lt;code&gt;:h :j&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-10-13T11:01:53.393" LastActivityDate="2016-10-13T11:01:53.393" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9901" PostTypeId="2" ParentId="9894" CreationDate="2016-10-13T11:12:26.060" Score="1" Body="&lt;p&gt;As an interactive editor, Vim takes over the entire [terminal] screen. It is therefore not well suited to be used as a highlighting component (though there are ways inside Vim to access the rendered syntax highlighting, cp. the &lt;code&gt;:help 2html&lt;/code&gt; script that renders a Vim buffer as HTML).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion, going this route isn't worth the effort. Rather, I'd suggest you have a look at alternative syntax parsers; many are just as powerful (and designed to be integrated). Though I haven't used it myself, the &lt;a href=&quot;https://www.gnu.org/software/src-highlite/&quot; rel=&quot;nofollow&quot;&gt;GNU Source-highlight&lt;/a&gt; might be worth looking into.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-10-13T11:12:26.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9902" PostTypeId="2" ParentId="9892" CreationDate="2016-10-13T11:36:33.593" Score="5" Body="&lt;p&gt;There are two answers to your question:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;General&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;In order to open a file, overriding the default filetype detection, you can just specify a &lt;code&gt;:setf[iletype]&lt;/code&gt; command as part of &lt;code&gt;:edit&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit +setf\ java strange.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default filetype detection does not change an existing filetype, that's how this works. Of course, you can also do this retroactively via &lt;code&gt;:setl filetype=...&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Extending the gzip plugin&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;As a binary format, Vim cannot directly edit [GZIP] archives. The built-in &lt;code&gt;:help gzip&lt;/code&gt; plugin hooks into the filetype detection in order to transparently handle archives. This is done via &lt;code&gt;:autocmd&lt;/code&gt;s. If you want to support other file extensions, the default ones (cp. &lt;code&gt;:autocmd gzip&lt;/code&gt;) need to be extended with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufReadPre *.glabels setlocal binary&#xA;autocmd! BufRead *.glabels call gzip#read(&quot;gzip -S.glabels -dn&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;-S.glabels&lt;/code&gt; addition; without this, &lt;code&gt;gzip&lt;/code&gt; wouldn't know what to do with the file.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-10-13T11:36:33.593" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9903" PostTypeId="1" AcceptedAnswerId="9904" CreationDate="2016-10-13T16:38:11.793" Score="2" ViewCount="314" Body="&lt;p&gt;Pretty frequently while I'm using vim, I'll run into something like this. I want to edit a specific &lt;code&gt;.txt&lt;/code&gt; file, that is under &lt;code&gt;~/Documents/myProj&lt;/code&gt;, but I don't remember the name of the file. So I will do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e ~/Documents/myProj/&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;until the file I recognize comes up. This is OK-ish, but it can sometimes be inconvenient when I have a lot of other files with different extensions, or even subdirectories in the same directory. Is there any way I could do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e ~/Documents/myProj/*.txt&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and only have vim suggest the files that match the &lt;code&gt;.txt&lt;/code&gt; extension?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-10-13T16:56:55.573" Title="Can I iterate through files with a certain extension from the vim command line?" Tags="|command-line|filesystem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9904" PostTypeId="2" ParentId="9903" CreationDate="2016-10-13T16:56:55.573" Score="5" Body="&lt;p&gt;What you describe is exactly how Vim behaves.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e ~/Documents/myProj/*.txt&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may want to turn on &lt;code&gt;'wildmenu'&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt; so you can see the list or use &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmenu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'wildmenu'&#xA;:h c_CTRL-D&#xA;:h cmdline-completion&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-10-13T16:56:55.573" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9905" PostTypeId="1" AcceptedAnswerId="9919" CreationDate="2016-10-13T18:45:39.387" Score="1" ViewCount="1648" Body="&lt;p&gt;I (very) often write python, and I use Vim's python3 backend to test my code.  To perform my tests I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;localleader&amp;gt;p y:&amp;lt;c-r&amp;gt;&quot;&amp;lt;c-b&amp;gt;python3 &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It simply takes my visual selection and runs within Vim's python backend.  This is very practical because I can re-run only pieces of code (and I'm careful to remember the state the repl is in).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works fine even with installed libraries, for example &lt;a href=&quot;https://www.crummy.com/software/BeautifulSoup/&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;beautifulsoup4&lt;/code&gt;&lt;/a&gt; works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:python3 import bs4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But my issue starts when I try loading libraries that are not fully written in python.  For example trying &lt;a href=&quot;http://www.numpy.org/&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;numpy&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:python3 import numpy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get an error from the backend:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;  File &quot;/home/grochmal/.local/lib/python3.5/site-packages/numpy/__init__.py&quot;, line 180, in &amp;lt;module&amp;gt;&#xA;    from . import add_newdocs&#xA;  File &quot;/home/grochmal/.local/lib/python3.5/site-packages/numpy/add_newdocs.py&quot;, line 13, in &amp;lt;module&amp;gt;&#xA;    from numpy.lib import add_newdoc&#xA;  File &quot;/home/grochmal/.local/lib/python3.5/site-packages/numpy/lib/__init__.py&quot;, line 8, in &amp;lt;module&amp;gt;&#xA;    from .type_check import *&#xA;  File &quot;/home/grochmal/.local/lib/python3.5/site-packages/numpy/lib/type_check.py&quot;, line 11, in &amp;lt;module&amp;gt;&#xA;    import numpy.core.numeric as _nx&#xA;  File &quot;/home/grochmal/.local/lib/python3.5/site-packages/numpy/core/__init__.py&quot;, line 14, in &amp;lt;module&amp;gt;&#xA;    from . import multiarray&#xA;ImportError: /home/grochmal/.local/lib/python3.5/site-packages/numpy/core/multiarray.cpython-35m-x86_64-linux-gnu.so: undefine&#xA;d symbol: PyType_GenericNew&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After debugging it a good deal I got to the conclusion that the issue only happens in &lt;code&gt;/home/grochmal/.local&lt;/code&gt; and only to libraries that have components compiled from C.  In other words, if I install &lt;code&gt;numpy&lt;/code&gt; into &lt;code&gt;/usr/lib&lt;/code&gt; it works.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The question&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The python REPL has no issue with libraries at &lt;code&gt;~/.local&lt;/code&gt; but Vim's python backend does.  I tried with and without:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export PYTHONPATH=/home/grochmal/.local/lib/python3.5/site-packages&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the issue persists.  Is there a way to use locally installed shared libraries together with Vim's python backend?  i.e. Can I tell Vim's python backend to search both places (&lt;code&gt;/usr/lib&lt;/code&gt; and &lt;code&gt;~/.local&lt;/code&gt;) for symbols to load?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;Extra note: both &lt;code&gt;bs4&lt;/code&gt; and &lt;code&gt;numpy&lt;/code&gt; are in &lt;code&gt;~/.local&lt;/code&gt; in the tests above.  In other words libraries that are fully written in python do work in &lt;code&gt;~/.local&lt;/code&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-10-16T02:18:20.377" Title="Vim python backend, how to import user installed shared libraries?" Tags="|vimscript-python|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9907" PostTypeId="1" AcceptedAnswerId="9949" CreationDate="2016-10-14T02:30:38.967" Score="1" ViewCount="321" Body="&lt;p&gt;I am using neovim with &lt;code&gt;deoplete.nvim&lt;/code&gt; and &lt;code&gt;neosnippet.vim&lt;/code&gt;. I am trying to make &lt;code&gt;TAB&lt;/code&gt; key do both navigating through the popup menu and expand snippets when it's able to.&#xA;Here is my config.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; &amp;lt;TAB&amp;gt;: completion&#xA;inoremap &amp;lt;expr&amp;gt;&amp;lt;TAB&amp;gt; pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; : neosnippet#expandable_or_jumpable() ? &quot;\&amp;lt;Plug&amp;gt;(neosnippet_expand_or_jump)&quot; : &quot;\&amp;lt;TAB&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt;&amp;lt;CR&amp;gt; pumvisible() ? &quot;\&amp;lt;C-y&amp;gt;&quot; : &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt;&amp;lt;Esc&amp;gt; pumvisible() ? &quot;\&amp;lt;C-e&amp;gt;&quot; : &quot;\&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am successfully to make &lt;code&gt;Tab&lt;/code&gt; navigating through popup menu but I won't be able to expand the snippet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, when I have &lt;code&gt;function&lt;/code&gt; and press &lt;code&gt;Tab&lt;/code&gt;. Instead of expand the snippet. It became &lt;code&gt;function&amp;lt;Plug&amp;gt;(neosnippet_expand_or_jump)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step I went through:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:n test.js&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;func&lt;/code&gt; -&gt; &lt;code&gt;Tab&lt;/code&gt; -&gt; select &lt;code&gt;function&lt;/code&gt; and press &lt;code&gt;Enter&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;Tab&lt;/code&gt; again.&lt;/li&gt;&#xA;&lt;li&gt;Output &lt;code&gt;function&amp;lt;Plug&amp;gt;(neosnippet_expand_or_jump)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am not sure what goes wrong here. Please help.&lt;/p&gt;&#xA;" OwnerUserId="7440" LastActivityDate="2016-10-18T13:45:48.117" Title="&lt;Plug&gt; was printed to the buffer instead of execute" Tags="|key-bindings|vimscript|neovim|snippets|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9908" PostTypeId="2" ParentId="9166" CreationDate="2016-10-14T02:59:25.217" Score="2" Body="&lt;p&gt;Based on @SatoKatsura's comments, here is a shell script (for UNIX like systems) which will install &lt;a href=&quot;https://github.com/beautify-web/js-beautify&quot; rel=&quot;nofollow&quot;&gt;js-beautify&lt;/a&gt; and setup the python  executable as a command.&lt;br&gt;&#xA;Just to clarify, this will install the main &lt;code&gt;js-beautify&lt;/code&gt; repo which contains the &lt;code&gt;js-beautify&lt;/code&gt; program intended to be run on nodejs, but &lt;em&gt;this script will not link to the nodejs script&lt;/em&gt; - instead it links to the python executable which is contained in a subfolder. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally this would &lt;strong&gt;need to be run as root&lt;/strong&gt; - so it can write into &lt;code&gt;/usr/local/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#===================================&#xA;# setup js-beautify - python version&#xA;#===================================&#xA;&#xA;git clone &quot;https://github.com/beautify-web/js-beautify.git&quot; \&#xA;                                        /usr/local/src/js-beautify || exit 1&#xA;&#xA;# put a link somewhere in $PATH so js-beautify can be called as a command&#xA;if [[ ! -h /usr/local/bin/js-beautify ]]&#xA;then&#xA;    ln -vs /usr/local/src/js-beautify/python/js-beautify \&#xA;                                                  /usr/local/bin/js-beautify&#xA;else&#xA;    echo &quot;js-beautify link already exists, skipping...&quot;&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the script is successful, you can visually select a region in vim and run the ex command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!js-beautify&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: If you have come from the other js-beautify, you will notice the command api for this python version is quite different.&lt;br&gt;&#xA;For example, the python command is simpler to run the basic command &lt;code&gt;js-beautify&lt;/code&gt;. I believe the node version - at a minimum - has a required option or two to get basic functionality to work, e.g. to accept a stream on STDIN.&lt;br&gt;&#xA;But overall the python version seems like it might have less options..?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2016-10-14T03:18:41.370" LastActivityDate="2016-10-14T03:18:41.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9909" PostTypeId="2" ParentId="9887" CreationDate="2016-10-14T09:40:28.060" Score="1" Body="&lt;p&gt;I've created the function that compile &lt;code&gt;tex&lt;/code&gt; files, and can be mapped to any key binding. As @Dalker said &lt;code&gt;pdf viewer will automatically refresh when the file displayed changes&lt;/code&gt; , and it really do.  Am not exactly sure about &lt;code&gt;git&lt;/code&gt; related stuff @VanLaser said.. i think he meant that i have save the file changes first.. maybe not.. idk&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MKTex()&#xA;  if (&amp;amp;ft == 'tex')&#xA;    let s:dir = expand('%:p:h')&#xA;    let s:file = expand('%:p')&#xA;&#xA;    execute '!pdflatex -interaction=nonstopmode -output-directory ' . s:dir .' '. s:file&#xA;  else&#xA;    echo &quot;For .tex files only.&quot;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9658" LastActivityDate="2016-10-14T09:40:28.060" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9910" PostTypeId="1" AcceptedAnswerId="9948" CreationDate="2016-10-14T13:28:32.310" Score="3" ViewCount="527" Body="&lt;p&gt;I try to search for &lt;code&gt;{% amount&lt;/code&gt; in all files under the current directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;nofollow noreferrer&quot;&gt;ag&lt;/a&gt;, this works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ag -Q '{% amount'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;-Q&lt;/code&gt; specify to not use any regex, try to match text literally)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;grepprg=ag --nogroup --nocolor --column&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I use &lt;code&gt;:grep -Q '{% amount'&lt;/code&gt; I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E499: Empty file name for '%' or '#', only works with &quot;:p:h&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which (in my understanding) mean that Vim try to expand &lt;code&gt;%&lt;/code&gt; and fail (because I've not opened any file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: How to search for a litteral &lt;code&gt;%&lt;/code&gt; when using external grep program?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; thanks to &lt;a href=&quot;https://vi.stackexchange.com/users/1841/statox&quot;&gt;statox&lt;/a&gt; I know that the following works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /%/ *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-10-18T13:43:14.387" Title="Don't expand `%` in external grep call" Tags="|regular-expression|search|external-command|the-silver-searcher|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9911" PostTypeId="1" CreationDate="2016-10-14T14:29:12.437" Score="1" ViewCount="2483" Body="&lt;p&gt;I tried to edit a zip file and change its content using the following commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set modifiable&#xA;:%s/xxA/..\//g&#xA;:x!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it returned the following error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;W10: Warning: Changing a readonly file&#xA;55 substitutions on 10 lines&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After I pressed Enter nothing changed. Please guide me to solve this problem.&lt;/p&gt;&#xA;" OwnerUserId="7834" LastEditorUserId="1841" LastEditDate="2016-10-14T15:20:35.053" LastActivityDate="2016-10-18T13:41:21.113" Title="How to edit a readonly zip file?" Tags="|binary-file|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9913" PostTypeId="1" AcceptedAnswerId="9943" CreationDate="2016-10-14T16:50:46.267" Score="3" ViewCount="1747" Body="&lt;p&gt;I believe I am experiencing some weirdness in how YouCompleteMe is compiling my files to do its syntax checking. I suspect settings from my &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt; are not being applied the way I think they are, or YouCompleteMe is using a compiler I'm not expecting, or something along those lines. If I could just see the command line YouCompleteMe is using when it compiles the file, I think there's a good chance I could diagnose my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to show the command line YouCompleteMe is using?&lt;/p&gt;&#xA;" OwnerUserId="9702" LastActivityDate="2016-10-17T21:00:08.870" Title="How can I show the command line YouCompleteMe is using to compile my file?" Tags="|plugin-you-complete-me|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9914" PostTypeId="1" CreationDate="2016-10-15T01:31:44.280" Score="1" ViewCount="262" Body="&lt;p&gt;I want to make a custom search, accessible with operator-pending commands;&#xA;I use &lt;code&gt;onoremap&lt;/code&gt; to make it work in this mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's working well, and I can use my command (let's say it's mapped to &lt;code&gt;zz&lt;/code&gt;) with &lt;code&gt;czz&lt;/code&gt;, &lt;code&gt;yzz&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when the function called by the mapping does not match anything, I would like to make it react exactly like when I type the following normal mode command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;c/never\&amp;amp;match&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E486: Pattern not found: never\&amp;amp;match&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;An error is gently displayed, and &lt;em&gt;it goes back to normal mode&lt;/em&gt;, because an error happened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now, when my custom search fails with the example &lt;code&gt;czz&lt;/code&gt; command, it enters into insert mode, as if the search was successful. That's my problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I cancel the &lt;code&gt;czz&lt;/code&gt; command and go back to normal mode, when the search inside the &lt;code&gt;zz&lt;/code&gt; mapping fails?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve it I tried to put the following in the right place, but in vain: &lt;code&gt;exe &quot;normal! \&amp;lt;esc&amp;gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Create the o-mapping:&#xA;onoremap zz :&amp;lt;c-u&amp;gt;call MyQTest()&amp;lt;cr&amp;gt;&#xA;&#xA;function! MyQTest()&#xA;    &quot; Just below, performs a custom search that will set two &#xA;    &quot; vars, 'l:start' and 'l:end', the bounds of the area to&#xA;    &quot; work with:&#xA;&#xA;    &quot; [ ... ]&#xA;&#xA;    &quot; Finally we get some values, for example:&#xA;    &quot; let l:start = 5&#xA;    &quot; let l:end = 10&#xA;&#xA;    &quot; But if the search fails, instead of the two lines above,&#xA;    &quot; the values could be:&#xA;    let l:start = -1&#xA;    let l:end = -1&#xA;&#xA;    if l:start == -1 || l:end == -1&#xA;        &quot; HERE is the problem:&#xA;        &quot; If the search fails, how can I completely cancel the operator-pending &#xA;        &quot; command and return to normal mode, instead of start editing (with&#xA;        &quot; the 'c' normal command) ?&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; Make a selection, for operator-pending mode:&#xA;    call cursor(0, l:start)&#xA;    normal v&#xA;    call cursor(0, l:end)&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5516" LastActivityDate="2016-11-14T10:58:14.457" Title="How to cancel a custom operator-pending command" Tags="|map-operator|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9915" PostTypeId="2" ParentId="9914" CreationDate="2016-10-15T10:40:41.640" Score="1" Body="&lt;p&gt;It works by using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call feedkeys(&quot;\e&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;even if an error message is hard to display in all the cases.&lt;/p&gt;&#xA;" OwnerUserId="5516" LastActivityDate="2016-10-15T10:40:41.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9916" PostTypeId="1" CreationDate="2016-10-15T15:58:51.737" Score="12" ViewCount="565" Body="&lt;p&gt;I assume the only documentation that comes with Vim is about Vim.&lt;/p&gt;&#xA;&lt;p&gt;If I install plugins there will be documentation of the plugins as well.&lt;/p&gt;&#xA;&lt;p&gt;But is there documentation for other languages in Vim?&lt;/p&gt;&#xA;&lt;p&gt;An example would be, say I am coding in Python in Vim, and want to quickly look up list comprehensions in Python. It would be great if I can just type &lt;code&gt;:h python-doc&lt;/code&gt; in Vim and the Python documentation is brought up in Vim documentation.&lt;/p&gt;&#xA;&lt;p&gt;Other examples would be &lt;code&gt;:h markdown&lt;/code&gt; to bring up markdown syntax etc.&lt;/p&gt;&#xA;&lt;p&gt;Is this kind of thing already on the web? Are there such docs which I can download and &lt;code&gt;:helptags&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="9018" LastEditorUserId="4866" LastEditDate="2024-04-05T10:02:25.857" LastActivityDate="2024-04-06T20:38:26.747" Title="Accessing references or documentation from within Vim" Tags="|help-system|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9917" PostTypeId="2" ParentId="6731" CreationDate="2016-10-15T16:59:58.080" Score="3" Body="&lt;p&gt;The as-of-writing &lt;a href=&quot;https://vi.stackexchange.com/a/6732/9182&quot;&gt;accepted answer&lt;/a&gt; broke highlighting for strings inside function argument lists for me (by what alchemy I do not know), so here's a hopefully more safe version, based on &lt;a href=&quot;https://vi.stackexchange.com/a/6760/9182&quot;&gt;Statox' one&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match PythonArg &quot;\v[\(\,]\s{-}\zs\w+\ze\s{-}\=(\=)@!&quot;&#xA;hi PythonArg ctermfg = 214 guifg = #ffaf00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ctermfg&lt;/code&gt; is for console terminal, &lt;code&gt;guifg&lt;/code&gt; is for gui. Of course you're free to change the colors to whatever you find fancy. &lt;a href=&quot;http://vim.wikia.com/wiki/Xterm256_color_names_for_console_Vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here's a handy list&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As always, you do best putting this inside &lt;code&gt;~/.vim/after/syntax/python.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a regex breakdown, here you go:    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v      set to very magic mode&#xA;[\(\,]  capture either a ( or a ,&#xA;\s{-}   capture whitespace, nongreedy&#xA;\zs     start of the match (what to actually highlight)&#xA;\w+     one or more alphanumeric character, underscore included&#xA;\ze     stop matching; anything after this is delimiting only&#xA;\s{-}   once again, capture whitespace.&#xA;\=      one single equal sign&#xA;(\=)@!  ...not followed by another equal sign&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The final check stops the highlighting from coloring conditionals. You can remove if it you want.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-10-15T20:32:38.347" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9918" PostTypeId="2" ParentId="9905" CreationDate="2016-10-15T23:33:06.667" Score="0" Body="&lt;h3&gt;Workaround&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;After a good deal of debugging I found that forcing Vim to have the shared library in memory all the time sorts the problem.  i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vim='LD_PRELOAD=/usr/lib/libpython3.so vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yes, it is horrible, but works on most systems (tested on CentOS, Debian and Arch).  Another problem is that &lt;code&gt;LD_PRELOAD&lt;/code&gt; is Linux specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After this I can load a &lt;code&gt;numpy&lt;/code&gt; library from &lt;code&gt;~/.local/lib/python3.5/site-packages/&lt;/code&gt; with &lt;code&gt;:python3 import numpy&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Extra info&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I'm still baffled at the issue since in Vim code the library should come from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;src/option.h: EXTERN char_u *p_py3dll;  /* 'pythonthreedll' */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which in turn should come from &lt;code&gt;-DDYNAMIC_PYTHON3_DLL&lt;/code&gt;, which should be a static makefile argument.  Therefore, I believe that the issue lies somewhere in (&lt;code&gt;src/if_python3.c&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# ifndef WIN3264&#xA;#  include &amp;lt;dlfcn.h&amp;gt;&#xA;#  define FARPROC void*&#xA;#  define HINSTANCE void*&#xA;#  if defined(PY_NO_RTLD_GLOBAL) &amp;amp;&amp;amp; defined(PY3_NO_RTLD_GLOBAL)&#xA;#   define load_dll(n) dlopen((n), RTLD_LAZY)&#xA;#  else&#xA;#   define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)&#xA;#  endif&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that &lt;code&gt;RTLD_LOCAL&lt;/code&gt; (i.e. no &lt;code&gt;RTLD_GLOBAL&lt;/code&gt;) is possibly used.  But I never used &lt;code&gt;dlopen()&lt;/code&gt; and may be completely wrong about this.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2016-10-15T23:33:06.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9919" PostTypeId="2" ParentId="9905" CreationDate="2016-10-16T02:18:20.377" Score="2" Body="&lt;p&gt;This is because your numpy isn't linked against the Python 3 library (no &lt;code&gt;-lpython3&lt;/code&gt; used). This is fine for most applications that has the library loaded into global space, but Vim uses &lt;code&gt;RTLD_LOCAL&lt;/code&gt; so numpy's libraries don't see Python 3's symbols unless it's linked against it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;LD_PRELOAD&lt;/code&gt; is fine as long as you don't load Python 2 in the same Vim (or symbols may clash; that's why Vim doesn't use &lt;code&gt;RTLD_GLOBAL&lt;/code&gt;). You can also recompile your numpy with &lt;code&gt;-lpython3&lt;/code&gt; (from Arch's PKGBUILD it seems that &lt;code&gt;export LDFLAGS=-shared&lt;/code&gt; is enough to do that).&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2016-10-16T02:18:20.377" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9920" PostTypeId="1" AcceptedAnswerId="9923" CreationDate="2016-10-16T04:15:37.333" Score="0" ViewCount="78" Body="&lt;p&gt;What if I define keywords as combination of two list of strings?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;List1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['B', 'G96', 'TPSS', 'RevTPSS', 'BRx', PBE', 'PBEh', 'wPBEh']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;List2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['VWN', 'P86', 'PW91', 'TPSS']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and a keyword is a combination of a word in List1 + a word in List2, e.g. 'RevTPSSTPSS' is a keyword, but a single 'TPSS' is not. How do I write the Gaussian syntax file?&lt;/p&gt;&#xA;" OwnerUserId="8820" LastEditorUserId="205" LastEditDate="2016-10-16T04:32:38.450" LastActivityDate="2016-10-16T08:30:43.530" Title="vim syntax file: composite keywords" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9923" PostTypeId="2" ParentId="9920" CreationDate="2016-10-16T08:30:43.530" Score="2" Body="&lt;p&gt;The following should do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let list1 = ['B', 'G96', 'TPSS', 'RevTPSS', 'BRx', 'PBE', 'PBEh', 'wPBEh']&#xA;let list2 = ['VWN', 'P86', 'PW91', 'TPSS']&#xA;for a in list1&#xA;  for b in list2&#xA;    execute 'syntax keyword MyGroup' a . b&#xA;  endfor&#xA;endfor&#xA;&#xA;highlight link MyGroup Function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The most relevant help sections are &lt;code&gt;:h :execute&lt;/code&gt; and &lt;code&gt;:h syn-keyword&lt;/code&gt;, so you might want to read those.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-10-16T08:30:43.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9924" PostTypeId="1" CreationDate="2016-10-16T09:17:21.540" Score="1" ViewCount="1166" Body="&lt;p&gt;I want to create function that search for selection and then automatically replace selection with given text. Something like &lt;code&gt;*Ncgn&lt;/code&gt; but with custom movement (not exactly word only).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current function is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:VSetSearch(type, ...)&#xA;  let temp = @@&#xA;  if a:0&#xA;    silent exe &quot;norm! gvy&quot;&#xA;  elseif a:type == 'line'&#xA;    silent exe &quot;normal! '[V']y&quot;&#xA;  else&#xA;    silent exe &quot;normal! `[v`]y&quot;&#xA;  endif&#xA;&#xA;  let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')&#xA;  call histadd('/', substitute(@/, '[?/]', '\=&quot;\\%d&quot;.char2nr(submatch(0))', 'g'))&#xA;  let @@ = temp&#xA;endfunction&#xA;&#xA;xnoremap &amp;lt;Plug&amp;gt;(vsearch-change-selected-forward) :&amp;lt;C-u&amp;gt;call &amp;lt;SID&amp;gt;VSetSearch(visualmode(), 1)&amp;lt;CR&amp;gt;:set hlsearch&amp;lt;CR&amp;gt;cgn&#xA;xnoremap &amp;lt;Plug&amp;gt;(vsearch-change-selected-backward) :&amp;lt;C-u&amp;gt;call &amp;lt;SID&amp;gt;VSetSearch(visualmode(), 1)&amp;lt;CR&amp;gt;:set hlsearch&amp;lt;CR&amp;gt;cgN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I would like to have also mappings in normal mode that would work on operators, but I have no idea how to accomplish that.&lt;/p&gt;&#xA;" OwnerUserId="1259" LastActivityDate="2016-10-16T09:17:21.540" Title="Enter insert to insert mode from function" Tags="|vimscript|search|replace|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9925" PostTypeId="1" CreationDate="2016-10-16T09:23:16.433" Score="5" ViewCount="307" Body="&lt;p&gt;I can add a word to the local dictionary or &lt;code&gt;spellfile&lt;/code&gt; with &lt;code&gt;zg&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can use &lt;code&gt;zG&lt;/code&gt; to add a word to the internal spellfile, but this still affects all loaded files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I add spelling exceptions on a per-file or per-buffer basis, and have it still work when re-opening the file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some &lt;code&gt;.viminfo&lt;/code&gt; magic for this?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2016-10-18T06:53:59.323" LastActivityDate="2016-10-18T08:48:10.040" Title="Ignore word spelling on a per-file/buffer basis" Tags="|spell-checking|sessions|viminfo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9926" PostTypeId="1" AcceptedAnswerId="9931" CreationDate="2016-10-16T18:00:00.600" Score="7" ViewCount="436" Body="&lt;p&gt;I am confused about how the start visual commands work when you pass them a count. I checked the help page but I am still confused.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[count]V                Start Visual mode linewise.&#xA;                        With [count] select the same number of lines as used&#xA;                        for the last Visual operation, but at the current&#xA;                        cursor position, multiplied by [count].  When there&#xA;                        was no previous Visual operation [count] lines are&#xA;                        selected.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to know what &lt;code&gt;[count]v&lt;/code&gt;, &lt;code&gt;[count]V&lt;/code&gt; and &lt;code&gt;[count]CTRL-V&lt;/code&gt; does and when it is useful to pass &lt;code&gt;[count]&lt;/code&gt; to the &lt;em&gt;start visual selection&lt;/em&gt; commands.&lt;/p&gt;&#xA;" OwnerUserId="3032" LastEditorUserId="343" LastEditDate="2017-12-06T11:12:05.463" LastActivityDate="2017-12-06T11:12:05.463" Title="What does [count]v and [count]V do? How is it useful?" Tags="|visual-mode|visual-block|count|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9927" PostTypeId="1" AcceptedAnswerId="9930" CreationDate="2016-10-16T18:21:15.410" Score="1" ViewCount="303" Body="&lt;p&gt;I have a command defined in my &lt;code&gt;ftplugin/markdown.vim&lt;/code&gt; to maintain a consistent style, and check for any errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Lint !pandoc % -o % --columns=80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I run &lt;code&gt;:Lint&lt;/code&gt; I then need to hit &lt;code&gt;L&amp;lt;CR&amp;gt;&lt;/code&gt; followed by &lt;code&gt;:e&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way of defining this command such that it will reload automatically, with no further keypress?&lt;/p&gt;&#xA;" OwnerUserId="5778" LastActivityDate="2021-01-26T03:18:10.463" Title="Automate file reload after command that modifies it?" Tags="|vimrc|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9928" PostTypeId="2" ParentId="3093" CreationDate="2016-10-16T18:40:22.250" Score="62" Body="&lt;p&gt;If you want to simply change the font size in a running GVim instance, type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set guifont=*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A window should pop up letting you set font size as well as pick a new font if desired. You can then ask Vim to print the line you would need to add to your &lt;code&gt;~/.gvimrc&lt;/code&gt; to make the change permanent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set guifont?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Produces something like the following in the status line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;guifont=Hasklig-Light:h16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add that with the prefix &lt;code&gt;set&lt;/code&gt; to your &lt;code&gt;~/.gvimrc&lt;/code&gt; to persist.&lt;/p&gt;&#xA;" OwnerUserId="9722" LastEditorUserId="-1" LastEditDate="2019-04-25T13:59:24.953" LastActivityDate="2019-04-25T13:59:24.953" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9929" PostTypeId="1" AcceptedAnswerId="9933" CreationDate="2016-10-16T19:55:22.157" Score="3" ViewCount="537" Body="&lt;p&gt;I've been using Vim for 2 years now but most (basically all) of the advanced functionality I enjoy today is from the great community of plugins available from Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such I have plugins that drive code folding for php, javascript, html and css. I've been playing around with &lt;a href=&quot;https://github.com/NLKNguyen/pipe-mysql.vim&quot; rel=&quot;nofollow&quot;&gt;pipe-mysql&lt;/a&gt; for my local database development. So far its working great, but given the size of the files I am working in, I thought how nice it would be if I could define code folds in my SQL code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently when I try to manually fold I get this helpful error: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;E350: Cannot create fold with current 'foldmethod'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:set foldmethod?&lt;/code&gt; tells me &lt;code&gt;foldmethod=syntax&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd really like is some direction on the simplest path to enabling manual (if it will keep my folds after the file is closed) or marker as the foldmethod on just my &lt;code&gt;.sql&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if I need to use &lt;code&gt;foldmethod=marker&lt;/code&gt;, how do I define a custom marker syntax? I'd like to do something like &lt;code&gt;#--&lt;/code&gt; as that is valid sql comment syntax and shouldn't interfere with running the sql code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it helps, here is what I believe to be the relevant existing section from my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Automatic Code Folding&#xA;set foldmethod=syntax&#xA;set foldlevelstart=1&#xA;&#xA;let javaScript_fold=1         &quot; JavaScript&#xA;let perl_fold=1               &quot; Perl&#xA;let php_folding=1             &quot; PHP&#xA;let sh_fold_enabled=1         &quot; sh&#xA;let vimsyn_folding='af'       &quot; Vim script&#xA;let xml_syntax_folding=1      &quot; XML&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9724" LastEditorUserId="9724" LastEditDate="2016-10-16T20:49:29.983" LastActivityDate="2016-10-17T08:19:34.837" Title="Custom Folding for SQL Files" Tags="|folding|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9930" PostTypeId="2" ParentId="9927" CreationDate="2016-10-16T22:23:07.930" Score="8" Body="&lt;p&gt;Your command tells pandoc to filter your &lt;em&gt;file&lt;/em&gt; (&lt;code&gt;%&lt;/code&gt;) instead of your buffer. This is problematic because there's no guarantee that the content of the buffer and the content of the file are identical. What you need is a filter, not something that acts on actual files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default behavior of pandoc is to act as a filter, which happens to be exactly what you want: take text from &lt;code&gt;stdin&lt;/code&gt; and return a &lt;em&gt;filtered&lt;/em&gt; version of it to &lt;code&gt;stdout&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!pandoc --columns=80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But pandoc's default output format for markdown is HTML if you don't specify any so you should use &lt;code&gt;-t markdown&lt;/code&gt; to force markdown output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!pandoc -t markdown --columns=80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But even that is not enough to make a proper custom command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Lint !pandoc -t markdown --columns=80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first problem is that custom commands don't accept a range by default. This is easy to &quot;fix&quot; with &lt;code&gt;:help :command-range&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% Lint execute &amp;lt;line1&amp;gt; . &quot;,&quot; . &amp;lt;line2&amp;gt; . &quot;!pandoc -t markdown --columns=80&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At this stage, you can do &lt;code&gt;:Lint&lt;/code&gt; or &lt;code&gt;:24,67Lint&lt;/code&gt; or &lt;code&gt;vjjjjj:Lint&lt;/code&gt; and get exactly what you want… But we still have three problems to address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second problem is that this command will leave the cursor on the last line of the buffer. This is not really a showstopper but… oh well! We can fix it with &lt;code&gt;:help winsaveview()&lt;/code&gt; and &lt;code&gt;:help winrestview()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% Lint let myview = winsaveview() |&#xA;  \ execute &amp;lt;line1&amp;gt; . &quot;,&quot; . &amp;lt;line2&amp;gt; . &quot;!pandoc -t markdown --columns=80&quot; |&#xA;  \ call winrestview(myview)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The third problem is that this command will also be available in non-markdown buffers because all custom commands are global by default. This is another easy fix thanks to &lt;code&gt;:help :command-buffer&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -buffer -range=% Lint let myview = winsaveview() |&#xA;  \ execute &amp;lt;line1&amp;gt; . &quot;,&quot; . &amp;lt;line2&amp;gt; . &quot;!pandoc -t markdown --columns=80&quot; |&#xA;  \ call winrestview(myview)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The fourth and last problem is a lot less severe than the others. It's just that &lt;code&gt;ftplugin/markdown.vim&lt;/code&gt; is not really the right place for language-specific settings/mappings/commands due to the order in which filetype plugins are sourced:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#1 $HOME/.vim/ftplugin/markdown.vim&#xA;#2 $VIMRUNTIME/ftplugin/markdown.vim&#xA;#3 $HOME/after/ftplugin/markdown.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should use &lt;code&gt;$HOME/after/ftplugin/foo.vim&lt;/code&gt; for all &lt;em&gt;your&lt;/em&gt; filetype specific needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wow… What a ride!&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-10-16T22:23:07.930" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9931" PostTypeId="2" ParentId="9926" CreationDate="2016-10-17T04:33:19.470" Score="5" Body="&lt;p&gt;You can see what it does for yourself by &lt;em&gt;performing an operation&lt;/em&gt; on a 1 character selection.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vy3v&amp;lt;esc&amp;gt;5v&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In that command, you select 1 character and yanked it.  Typing &lt;code&gt;3v&lt;/code&gt; causes the 3 characters starting from the cursor to be selected.  Typing &lt;code&gt;&amp;lt;esc&amp;gt;5v&lt;/code&gt; causes the 5 characters starting from the cursor to be selected.  This visual selection operates per-character.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;c-v&amp;gt;y3v&amp;lt;esc&amp;gt;5v&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This one will help if you have a large block of text.  This works just like the previous one, but in visual-block mode.  You started by yanking a 1x1 grid of characters, then typed &lt;code&gt;3v&lt;/code&gt; which selected a 3x3 grid of characters (starting from the cursor), and then selected a 5x5 grid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explaining the line-wise &lt;code&gt;[count]V&lt;/code&gt; would be repetitive at this point.  However, using &lt;code&gt;[count]v&lt;/code&gt; where the last operation involved &lt;em&gt;multiple lines&lt;/em&gt; works a little bit differently than the first example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consetetur&#xA;sadipscing elitr, sed diam nonumy eirmod&#xA;tempor invidunt ut labore et dolore magna&#xA;aliquyam erat, sed diam voluptua.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Starting from 1,1, typing &lt;code&gt;vjey&lt;/code&gt; will yank from 1,1 to 2,10. Typing &lt;code&gt;w2v&lt;/code&gt; afterwards will select from 1,1 to 4,10.  Instead of selecting 2x the characters, it's 2x &lt;em&gt;lines&lt;/em&gt; except the last line will always end on the same column regardless of the starting line's column.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;when it is useful to pass [count] to the start visual selection commands.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I never needed to use a &lt;code&gt;[count]v&lt;/code&gt; in the past, but I imagine it has its uses when dealing with symmetrical text or in macros/scripting.  &lt;code&gt;[count]V&lt;/code&gt; and &lt;code&gt;[count]&amp;lt;c-v&amp;gt;&lt;/code&gt; seem to be the most useful from a user perspective, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a unit test for this feature in &lt;a href=&quot;https://github.com/vim/vim/blob/869e35270ecffd9024958880cb03f6f0bb01ea93/src/testdir/test94.in&quot;&gt;test94.in&lt;/a&gt;, but the tests don't look like something I would consider to be practical for daily use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find a useful workflow using &lt;code&gt;[count]v&lt;/code&gt; be sure to share it &lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-10-17T04:33:19.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9932" PostTypeId="1" CreationDate="2016-10-17T08:04:01.223" Score="1" ViewCount="297" Body="&lt;p&gt;In visual mode, the message display seems fixed:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;VISUAL&lt;/code&gt;: it contains either the number of characters selected or the number of lines;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;VISUAL LINE&lt;/code&gt;: contains the number of lines;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;VISUAL BLOCK&lt;/code&gt;: contains the dimensions of the selected area (rows × columns).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Can this be customized and how?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to run analysis functions on the selected&#xA;text targeting mainly &lt;code&gt;VISUAL&lt;/code&gt; mode: counting characters,&#xA;line widths etc. Of course, one could filter the selection&#xA;by running a function on it but I’d like the information&#xA;to be updated live and conveniently located in the message&#xA;line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT&lt;/em&gt;: &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/normal.c#L3775&quot; rel=&quot;nofollow&quot;&gt;The code that handles the behavior in question&lt;/a&gt;&#xA;doesn’t appear to be configurable.&lt;/p&gt;&#xA;" OwnerUserId="8282" LastEditorUserId="8282" LastEditDate="2016-10-17T13:23:11.537" LastActivityDate="2016-10-17T13:23:11.537" Title="message line in modes" Tags="|vimscript|visual-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9933" PostTypeId="2" ParentId="9929" CreationDate="2016-10-17T08:12:55.493" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;foldmethod=marker&lt;/code&gt; and use comments valid for SQL files with &lt;code&gt;{{{&lt;/code&gt; and &lt;code&gt;}}}&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#-- {{{1&#xA;#-- 1}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Numbers are optional. Here's how it could look like &lt;a href=&quot;https://i.stack.imgur.com/ojx9q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ojx9q.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/68BcO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/68BcO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And to get &lt;code&gt;foldmethod=marker&lt;/code&gt; in sql files you can use &lt;code&gt;au BufRead,BufNewFile *.sql setlocal foldmethod=marker&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2016-10-17T08:19:34.837" LastActivityDate="2016-10-17T08:19:34.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9934" PostTypeId="2" ParentId="9932" CreationDate="2016-10-17T09:10:07.973" Score="3" Body="&lt;p&gt;Yes this is possible. The starting point is &lt;code&gt;:h 'statusline'&lt;/code&gt;. However, I must point you towards vim-airline and powerline plugins. They already do many related things. If not what you're looking for, their (complicated) code should give you hints regarding what you what to achieve.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-10-17T09:10:07.973" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9935" PostTypeId="1" AcceptedAnswerId="9938" CreationDate="2016-10-17T10:32:10.907" Score="2" ViewCount="129" Body="&lt;p&gt;I have Bash file in which I have constructs that include &lt;code&gt;(@)_&lt;/code&gt; as part of the variable name.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(@)_VariableName&#xA;${(@)_VariableName[@]}&#xA;${#(@)_VariableName[@]}&#xA;${!(@)_VariableName[@]}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Bash files are pre-processed and the literal string &lt;code&gt;(@)_&lt;/code&gt; is replaced with characters so that the final result is valid Bash. The sequence &lt;code&gt;(@)_&lt;/code&gt;, if present, will always be at the beginning of a variable name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to modify the &lt;code&gt;sh.vim&lt;/code&gt; syntax file so that variable names are considered to be valid in identifier highlighting and not shown with &lt;code&gt;shDerefWordError&lt;/code&gt; highlighting.  I've tried modifying:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match shDerefVar contained &quot;{\@&amp;lt;=!\k\+&quot; nextgroup=@shDerefVarList&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match shDerefVar contained &quot;{\@&amp;lt;=\((@)_\)\?!\k\+&quot; nextgroup=@shDerefVarList&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this has not worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this allowance might reasonably be made conditional to a variable such as &lt;code&gt;b:is_eggsh&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone suggest a solution?&lt;/p&gt;&#xA;" OwnerUserId="9728" LastEditorUserId="9728" LastEditDate="2016-10-17T15:07:40.730" LastActivityDate="2016-10-18T12:55:10.593" Title="Modify sh.vim to accept (@)_ as part of a variable name for Bash highlighting" Tags="|syntax-highlighting|filetype-sh|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9936" PostTypeId="1" AcceptedAnswerId="9940" CreationDate="2016-10-17T12:48:03.163" Score="4" ViewCount="492" Body="&lt;p&gt;I need to respect a coding style with 4 spaces tabulations and I want to fit with the 80 columns rule. I get then the case where some function need their parameters written on several line :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int very_long_function_name (int long_param_name_1, int long_param_name_2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want it to be changed into &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int very_long_function_name (int long_param_name_1,&#xA;    int long_param_name_2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I press &lt;kbd&gt;=&lt;/kbd&gt; to autoindent, I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int very_long_function_name (int long_param_name_1,&#xA;        int long_param_name_2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I set these values in my .vimrc :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4&#xA;set shiftwidth=4&#xA;set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I missing ?&lt;/p&gt;&#xA;" OwnerUserId="9729" LastEditorUserId="1841" LastEditDate="2016-10-17T15:01:54.463" LastActivityDate="2016-10-17T15:01:54.463" Title="Set tabulation size when function's parameters are written on multiple lines" Tags="|vimrc|indentation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9938" PostTypeId="2" ParentId="9935" CreationDate="2016-10-17T14:19:50.263" Score="3" Body="&lt;p&gt;You are close. The problem is that you took the syntax definition for Bash's special &lt;code&gt;${!varname}&lt;/code&gt;, and that doesn't match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also define a separate syntax group, used exclusively for your placeholder variables. The sh.vim syntax script is extensive via syntax clusters, that's how you install it as an additional dereference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match shDerefPlaceholder contained &quot;{\@&amp;lt;=[!#]\?(@)_\k\+&quot; nextgroup=@shDerefVarList&#xA;syn cluster shDerefList add=shDerefPlaceholder&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Alternative&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Integrating with an existing syntax can be messy... especially with an advanced one like shell (which supports several sub-modes). An alternative would be using &lt;code&gt;:match Preproc /(@)_[a-zA-Z_][a-zA-Z0-9_]*/&lt;/code&gt;; this always applies over existing syntax highlighting. Only complication: this is window-local, so you'd need some &lt;code&gt;:autocmds&lt;/code&gt; to install it, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead * if &amp;amp;syntax == 'sh' | match Preproc /(@)_[a-zA-Z_][a-zA-Z0-9_]*/ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2016-10-18T12:55:10.593" LastActivityDate="2016-10-18T12:55:10.593" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="9939" PostTypeId="2" ParentId="9925" CreationDate="2016-10-17T14:26:29.900" Score="3" Body="&lt;p&gt;There's nothing built-in; I guess the reasoning is that spelling (at least for a certain language) is inherently global. Any differences should be reflected in the language / dialect chosen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can implement such buffer-local spelling exception yourself: Get a temp file via &lt;code&gt;tempname()&lt;/code&gt;, prepend it to &lt;code&gt;'spellfile'&lt;/code&gt;, and then &lt;code&gt;zg&lt;/code&gt; / &lt;code&gt;1zg&lt;/code&gt; will place the exception there. This would be local to a single Vim session (like &lt;code&gt;zG&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like persistent buffer-local spelling, instead of &lt;code&gt;tempname()&lt;/code&gt;, either put the spell file next to the file (&lt;code&gt;bufname('') . '.spl'&lt;/code&gt;), or place then all into a dedicated spell directory, encoding the original file path in a way that &lt;code&gt;:mkview&lt;/code&gt; does: replace the path separator with &lt;code&gt;=+&lt;/code&gt; and &lt;code&gt;=&lt;/code&gt; with &lt;code&gt;==&lt;/code&gt;. So, &lt;code&gt;~/foo/bar.txt&lt;/code&gt; would get a spellfile of &lt;code&gt;/path/to/spelldir/~=+foo=+bar.txt.spl&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2016-10-18T08:48:10.040" LastActivityDate="2016-10-18T08:48:10.040" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9940" PostTypeId="2" ParentId="9936" CreationDate="2016-10-17T14:59:12.047" Score="6" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27cinoptions%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h cinoptions&lt;/code&gt;&lt;/a&gt; you read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The 'cinoptions' affect the way 'cindent' reindents lines in a C program.&#xA;See cinoptions-values for the values of this option&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/indent.txt.html#cinoptions%2Dvalues&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h cinoptions-values&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The 'cinoptions' option sets how Vim performs indentation.  The value after&#xA;the option character can be one of these (N is any number):&#xA;    N   indent N spaces&#xA;    -N  indent N spaces to the left&#xA;    Ns  N times 'shiftwidth' spaces&#xA;    -Ns N times 'shiftwidth' spaces to the left&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And finally &lt;a href=&quot;http://vimhelp.appspot.com/indent.txt.html#cino%2D%28&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h cino-(&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/indent.txt.html#cino%2DW&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h cino-W&lt;/code&gt;&lt;/a&gt; tell us that &lt;code&gt;set cino=(&lt;/code&gt; defines the behavior that the indentation should follow when it handles text between some parentheses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;set cinoptions=(4,W4&lt;/code&gt; tells vim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When in unclosed parentheses, indent N characters from the with the unclosed parentheses.&lt;/li&gt;&#xA;&lt;li&gt;When in unclosed parentheses and the unclosed parentheses is the last non-white character in its line and it is not the closing parentheses, indent the following line N characters relative to the outer context (i.e. start of the line or the next unclosed parentheses).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Which does the trick as @Meinew noted in the comments.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-10-17T14:59:12.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9941" PostTypeId="1" CreationDate="2016-10-17T18:05:39.537" Score="20" ViewCount="19975" Body="&lt;p&gt;I can check vim's version by using &lt;code&gt;v:version&lt;/code&gt;, &#xA;and I can check if I am running in nvim by doing &lt;code&gt;has('nvim')&lt;/code&gt;.  Is there a variable like &lt;code&gt;v:version&lt;/code&gt; in neovim to let me know the nvim version, like &lt;code&gt;0.1.4&lt;/code&gt; or &lt;code&gt;0.1.6&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="9681" LastEditorUserId="865" LastEditDate="2016-10-18T01:58:08.107" LastActivityDate="2023-10-02T14:52:36.263" Title="How do I check the version of NeoVim in vimscript?" Tags="|vimscript|neovim|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9942" PostTypeId="2" ParentId="9941" CreationDate="2016-10-17T20:01:16.470" Score="9" Body="&lt;p&gt;There is probably a direct way (?); if not, here's a function that parses &lt;code&gt;:version&lt;/code&gt; to extract and return the actual value (as string):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetNVimVersion()&#xA;    redir =&amp;gt; s&#xA;    silent! version&#xA;    redir END&#xA;    return matchstr(s, 'NVIM v\zs[^\n]*')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.. so that you can show it with: &lt;code&gt;echo GetNVimVersion()&lt;/code&gt; or store it in some variable.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-10-17T20:01:16.470" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9943" PostTypeId="2" ParentId="9913" CreationDate="2016-10-17T21:00:08.870" Score="4" Body="&lt;p&gt;Digging through the &lt;a href=&quot;https://groups.google.com/forum/?hl=en#!forum/ycm-users&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;ycm-users&lt;/code&gt; Google group&lt;/a&gt;, I found a post by someone else who was trying to debug their &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt; flag settings and was using &lt;code&gt;:YcmDebugInfo&lt;/code&gt; to get information about the flags being used by YouCompleteMe to compile their file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As documented &lt;a href=&quot;https://valloric.github.io/YouCompleteMe/#commands&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, &lt;code&gt;:YcmDebugInfo&lt;/code&gt; &quot;...will print out various debug information for the current file. Useful to see what compile commands will be used for the file if you're using the semantic completion engine&quot;. So... clearly I did not RTFM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:YcmDebugInfo&lt;/code&gt; was enough for me to diagnose my problem and debug some changes I'd made to my &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9702" LastActivityDate="2016-10-17T21:00:08.870" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9945" PostTypeId="1" CreationDate="2016-10-18T09:55:22.743" Score="1" ViewCount="130" Body="&lt;p&gt;I have a vocalized Hebrew text; most letters are followed by one or more combining characters.  I would like to replace some of the base characters, leaving the combining characters intact.  It seems the only way to search by base character alone is to use &lt;code&gt;\Z&lt;/code&gt;, but when I include that in the search pattern, the combining characters are discarded in the substitution operation.  Also searching for the base char followed by a range of combining chars &lt;code&gt;\m\%ufb25[\u05b0-\u05bd]*&lt;/code&gt; doesn't seem to work.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;ﬥְמַֽעַן וְהֽוּא־ﬥָֽךְ כְּסֶֽגֶן בְּאֶרְאֶﬥֵּי־אֵשׁ&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This text has three occurrences of wide lamed (U+FB25) which I'd like to replace with regular lamed (U+05DC).  Each wide lamed is followed by different combining characters:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;lt;ﬥ‎&gt; 64293, Hex fb25, Octal 175445 &amp;lt; ְ&gt; 1456, Hex 05b0, Octal 2660&lt;/li&gt;&#xA;&lt;li&gt;&amp;lt;ﬥ‎&gt; 64293, Hex fb25, Octal 175445 &amp;lt; ָ&gt; 1464, ...5b8, Octal 2670 &amp;lt; ֽ&gt; 1469, Hex 05bd, Octal 2675&lt;/li&gt;&#xA;&lt;li&gt;&amp;lt;ﬥ‎&gt; 64293, Hex fb25, Octal 175445 &amp;lt; ֵ&gt; 1461, ...5b5, Octal 2665 &amp;lt; ּ&gt; 1468, Hex 05bc, Octal 2674&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The ideal solution would yield the following with a single substitution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;לְמַֽעַן וְהֽוּא־לָֽךְ כְּסֶֽגֶן בְּאֶרְאֶלֵּי־אֵשׁ׃&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I avoided formatting as code blocks, because the difference between wide lamed and its regular counterpart isn't apparent when using a monospace font.  (Also it isn't really code, in the conventional sense.)&lt;/p&gt;&#xA;" OwnerUserId="9746" LastEditorUserId="9746" LastEditDate="2016-10-18T12:46:43.033" LastActivityDate="2016-10-18T12:46:43.033" Title="Replace base character, retaining combining characters" Tags="|regular-expression|unicode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9946" PostTypeId="2" ParentId="9945" CreationDate="2016-10-18T11:31:45.347" Score="2" Body="&lt;p&gt;This search pattern seems to work on your sample:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\%ufb25\ze\(\%u05b0\|\%u05b8\|\%u05b5\)*\(\%u05bd\|\%u05bc\)*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That pattern will match every instance of &lt;code&gt;U+fb25&lt;/code&gt;, optionally followed by &lt;code&gt;U+05b0&lt;/code&gt;, &lt;code&gt;U+05b8&lt;/code&gt;, or &lt;code&gt;U+05b5&lt;/code&gt;, optionally followed by &lt;code&gt;U+05bd&lt;/code&gt; or &lt;code&gt;U+05bc&lt;/code&gt;. Only what precedes &lt;code&gt;\ze&lt;/code&gt; is matched so the replacement only affects &lt;code&gt;U+fb25&lt;/code&gt;, preserving the combining characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the substitution part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s//\=nr2char(1500)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or simply:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s//ל/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-10-18T12:44:05.383" LastActivityDate="2016-10-18T12:44:05.383" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9947" PostTypeId="2" ParentId="9911" CreationDate="2016-10-18T13:41:21.113" Score="3" Body="&lt;p&gt;Vim ships with the &lt;em&gt;zip plugin&lt;/em&gt; (&lt;code&gt;:help pi_zip&lt;/code&gt;) that lets you automatically browse and edit the &lt;em&gt;contents&lt;/em&gt; of the zip file. These browse buffers are read-only. In order to read the actual zip file, you need to use &lt;em&gt;binary mode&lt;/em&gt;: &lt;code&gt;$ vim -b archive.zip&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you did use binary mode, the readonly buffer originates from the zip file's file system permissions. Sometimes you can force a write with &lt;code&gt;:w!&lt;/code&gt;, else you have to first give your user write access (&lt;code&gt;$ chmod +w archive.zip&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-10-18T13:41:21.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9948" PostTypeId="2" ParentId="9910" CreationDate="2016-10-18T13:43:14.387" Score="4" Body="&lt;p&gt;In the Vim command line, the &lt;code&gt;%&lt;/code&gt; is a special placeholder for the current buffer name. See &lt;code&gt;:help cmdline-special&lt;/code&gt;. To avoid the expansion, just escape the character with a backslash: &lt;code&gt;:grep -Q '{\% amount'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-10-18T13:43:14.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9949" PostTypeId="2" ParentId="9907" CreationDate="2016-10-18T13:45:48.117" Score="3" Body="&lt;p&gt;The &lt;code&gt;inoremap &amp;lt;expr&amp;gt;&amp;lt;TAB&amp;gt; ...&lt;/code&gt; also has a &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt;-mapping on the right-hand side of the mapping. These mappings only get expanded when you use &lt;code&gt;:imap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, though &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/05.html&quot; rel=&quot;nofollow&quot;&gt;you should normally use &lt;code&gt;:noremap&lt;/code&gt;&lt;/a&gt;, this is one exceptional case where you need to allow recursive mappings.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-10-18T13:45:48.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9950" PostTypeId="2" ParentId="9867" CreationDate="2016-10-18T14:00:04.807" Score="1" Body="&lt;p&gt;&lt;code&gt;'completefunc'&lt;/code&gt; assumes that you can determine the base just by looking at the text before the cursor; then, the call sequence is just fine. In your case, you want a fallback with a different base in case the original base does not yield any completion candidates. For that, you have to call &lt;code&gt;GetCompletions()&lt;/code&gt; to find out. The only way you could optimize this is storing the result of that first call in a script-local variable, and reusing that when your completion function is invoked the second time around (with &lt;code&gt;findstart = 0&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way I've solved a similar problem is triggering the fallback only on a second invocation at the same cursor position. So, the user invokes completion, either gets a list of matches or a &quot;no matches&quot; error, and then retriggers the completion. It's both more work, but also offers more control to the user.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-10-18T14:00:04.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9951" PostTypeId="1" CreationDate="2016-10-18T15:17:11.327" Score="13" ViewCount="1263" Body="&lt;p&gt;Basically, I'd like to have long entries for bulleted / numbered lists that automatically indent like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. Congress shall make no law respecting an establishment of &#xA;   religion, or prohibiting the free exercise thereof; or &#xA;   abridging the freedom of speech, or of the press; or the &#xA;   right of the people peaceably to assemble, and to petition &#xA;   the government for a redress of grievances.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm aware that &lt;code&gt;formatoptions=n&lt;/code&gt; will do this for numbered lists and &lt;code&gt;formatoptions=c&lt;/code&gt; will do this for asterisks (provided they are defined as comment leaders with &lt;code&gt;comments=fb:*&lt;/code&gt;), but this only works by forcing an automatic hard wrap. I'd prefer to avoid this situation, since in order to edit the paragraph, I then have to manually &lt;code&gt;J&lt;/code&gt;oin the lines back into one, make the edits, and then &lt;code&gt;gqq&lt;/code&gt; to reformat. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;breakindent&lt;/code&gt; setting gets me halfway there, with automatic indentation for softwrapped paragraphs, but it only provides indentation identical to the first line. Is there any setting that combines &lt;code&gt;breakindent&lt;/code&gt;'s softwrap support with &lt;code&gt;formatoptions+=cn&lt;/code&gt;'s numbered- and bulleted-list recognition?&lt;/p&gt;&#xA;" OwnerUserId="2593" LastActivityDate="2021-03-02T00:28:19.447" Title="Is there a setting to force a hanging indent on bulleted/numbered lists WITHOUT hard wrapping?" Tags="|indentation|wrapping|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9952" PostTypeId="1" CreationDate="2016-10-18T18:45:05.173" Score="-2" ViewCount="276" Body="&lt;p&gt;I see a lot of interesting features released with vim 8. Is there a chance read unsaved buffer with timers or when i type something without writing buffer to the file and without shortcuts just with timers or, maybe async task ? I have to say that i'm new to vim..vimscript.&lt;/p&gt;&#xA;" OwnerUserId="9658" LastActivityDate="2016-10-19T05:05:40.837" Title="Read unsaved buffer, is it possible?" Tags="|vimscript|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9953" PostTypeId="1" CreationDate="2016-10-18T19:31:01.107" Score="1" ViewCount="2446" Body="&lt;p&gt;Is there a way I can perform a batch-regex-replace using a list of words?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simplified example: &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;List of words&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Apple  &#xA;Cabbage  &#xA;Turtle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Text to search&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bike 2  &#xA;Turtle 5  &#xA;Bike 3  &#xA;Bike 5  &#xA;Cabbage 2  &#xA;Bike 0  &#xA;Bike 0  &#xA;Apple 1  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Output&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Turtle = 5;  &#xA;Cabbage = 2;  &#xA;Apple = 1;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'd like to do is something like:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\\(\list\\).*\\(\d\\)/\1 = \2;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the actual list I'm using is quite long (~50 items).&lt;/p&gt;&#xA;" OwnerUserId="9755" LastEditorUserId="2920" LastEditDate="2016-10-18T21:02:57.193" LastActivityDate="2016-10-19T14:13:22.403" Title="How to batch replace a list of words in file?" Tags="|regular-expression|substitute|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9954" PostTypeId="2" ParentId="9953" CreationDate="2016-10-18T19:47:40.747" Score="1" Body="&lt;p&gt;You can make a list in regular expressions using the or operator: &lt;code&gt;\|&lt;/code&gt; So yours would look something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(Apple\|Cabbage\|Turtle\)\s\+\(\d\+\)/\1 = \2;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then if you wanted to delete the rest of the lines that didn't match you could use a global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g!/Apple\|Cabbage\|Turtle/ d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h /bar&lt;/code&gt; and &lt;code&gt;:h :global&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-10-18T19:54:02.437" LastActivityDate="2016-10-18T19:54:02.437" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9955" PostTypeId="2" ParentId="1937" CreationDate="2016-10-18T20:58:27.650" Score="1" Body="&lt;p&gt;In addition to the gVim-specific commands in the other answers, there are a couple standard Windows features to launch any application maximized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are staring gVim from a shortcut, such as from the Start Menu or Desktop, you can change the shortcut properties to start Vim maximized. Right-click the shortcut, choose Properties, and select Maximized from the Run drop-down list. However, this will only affect that shortcut, so gVim will still open in a small window if launched from another shortcut, the Run dialog box, or the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are starting gVim from the command line or a batch file, you can use CMD’s &lt;code&gt;start&lt;/code&gt; command: &lt;code&gt;start &quot;&quot; /max &quot;C:\Program Files (x86)\Vim\vim73\gvim.exe&quot;&lt;/code&gt;. (The &lt;code&gt;&quot;&quot;&lt;/code&gt; is required if the path to gvim.exe is quoted. If you use an unquoted path without spaces, you can omit it: &lt;code&gt;start /max C:\Progra~2\Vim\vim73\gvim.exe&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="2680" LastActivityDate="2016-10-18T20:58:27.650" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9956" PostTypeId="2" ParentId="9953" CreationDate="2016-10-18T21:45:16.373" Score="1" Body="&lt;p&gt;Assuming your list of words is in a buffer looking like this (one word per line. &quot;Words&quot; with spaces in them are fine.):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Apple  &#xA;Cabbage  &#xA;Turtle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Append &lt;code&gt;\|&lt;/code&gt; to each line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/./normal A\|&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;That should leave the cursor on the last character of the last line. Delete the &lt;code&gt;\|&lt;/code&gt; on the last line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hd$&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Merge all the lines into one (if you have more than 50 lines, you may need a larger number. It shouldn't hurt to use a larger number than necessary, so feel free to overestimate):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg50gJ&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;At this point, your buffer's contents should look an awful lot like a search pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apple\|banana\|cabbage&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Copy that line into a register (replace the &lt;code&gt;a&lt;/code&gt; with your preferred register):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0&quot;ay$&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Follow &lt;a href=&quot;https://vi.stackexchange.com/a/9954/2736&quot;&gt;Tumbler41'a&lt;/a&gt; instructions. When entering the search pattern, use the register's contents with &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;r&lt;/kbd&gt; &lt;kbd&gt;a&lt;/kbd&gt; (&lt;code&gt;a&lt;/code&gt; being which ever register you used).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2736" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-10-18T21:45:16.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9957" PostTypeId="1" AcceptedAnswerId="9958" CreationDate="2016-10-19T01:43:29.293" Score="3" ViewCount="265" Body="&lt;p&gt;I know I can &lt;code&gt;:set ignorecase smartcase&lt;/code&gt; to get autompletion to be case-insensitive &lt;strong&gt;but&lt;/strong&gt; this has the side-effect of making &lt;em&gt;all&lt;/em&gt; searches case-insensitive unless they contain an uppercase character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried the following to attempt a per-command setting of &lt;code&gt;ignorecase&lt;/code&gt;, but had no luck:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-N&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt;:let b:last_ic = &amp;amp;ignorecase \| set ignorecase&amp;lt;CR&amp;gt;&amp;lt;C-N&amp;gt;&amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt;:let &amp;amp;ignorecase=b:last_ic \| unlet b:last_ic&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8520" LastActivityDate="2016-10-20T05:29:45.813" Title="Is there a way to use ignore case only for autocompletion in insert mode?" Tags="|key-bindings|autocompletion|letter-case|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9958" PostTypeId="2" ParentId="9957" CreationDate="2016-10-19T03:34:57.160" Score="3" Body="&lt;p&gt;It's not straight-forward, but it's possible to do this with &lt;code&gt;:h map-&amp;lt;expr&amp;gt;&lt;/code&gt; and some script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup toggle_compl_ignorecase&#xA;  autocmd!&#xA;  autocmd CompleteDone,InsertLeave *&#xA;        \ if exists('s:ignorecase') |&#xA;        \   let &amp;amp;ignorecase = s:ignorecase |&#xA;        \   unlet! s:ignorecase |&#xA;        \ endif&#xA;augroup END&#xA;&#xA;function! s:before_complete(key) abort&#xA;  if !exists('s:ignorecase')&#xA;    let s:ignorecase = &amp;amp;ignorecase&#xA;    set ignorecase&#xA;  endif&#xA;  return a:key&#xA;endfunction&#xA;&#xA;for s:key in [&quot;\&amp;lt;c-n&amp;gt;&quot;, &quot;\&amp;lt;c-p&amp;gt;&quot;, &quot;\&amp;lt;c-x&amp;gt;&quot;]&#xA;  execute 'inoremap &amp;lt;expr&amp;gt; '.s:key.' &amp;lt;sid&amp;gt;before_complete(&quot;'.s:key.'&quot;)'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The double quotes and slashes are significant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The keys &lt;code&gt;&amp;lt;c-n&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; are mapped to an expression that returns the final keys to be interpreted by Vim.  In this case all you're doing is using &lt;code&gt;s:before_complete()&lt;/code&gt; as a passthrough to set &lt;code&gt;ignorecase&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To restore &lt;code&gt;ignorecase&lt;/code&gt;, the autocmd &lt;code&gt;CompleteDone&lt;/code&gt; is used.  If a menu isn't displayed when pressing any of those keys, &lt;code&gt;CompleteDone&lt;/code&gt; should still be triggered.  &lt;code&gt;InsertLeave&lt;/code&gt; is included since it's the ultimate indication that you're not doing anything with completions.  Sanity is always a good thing :&gt;&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-10-19T03:34:57.160" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9959" PostTypeId="1" AcceptedAnswerId="11223" CreationDate="2016-10-19T04:38:43.450" Score="1" ViewCount="574" Body="&lt;p&gt;To make the usage of vim in cygwin convenient, I've added the color scheme in &lt;a href=&quot;https://github.com/Marslo/VimConfig/blob/master/Configurations/vimrc_cygwin&quot; rel=&quot;nofollow noreferrer&quot;&gt;my cygwin .vimrc&lt;/a&gt;. But I found the color scheme doesn't work when vim is started. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I did some investigations:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;My Cygwin indeed support &lt;code&gt;xterm-256color&lt;/code&gt;. &lt;a href=&quot;https://raw.githubusercontent.com/incitat/eran-dotfiles/master/bin/terminalcolors.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;This is 256 color test script&lt;/a&gt;:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/9eOhd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9eOhd.png&quot; alt=&quot;xterm&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/GEygX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GEygX.png&quot; alt=&quot;xterm2&quot;&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;The Comment highlight style indeed setup in &lt;a href=&quot;https://github.com/Marslo/VimConfig/blob/master/Configurations/vimrc_cygwin#L110&quot; rel=&quot;nofollow noreferrer&quot;&gt;the .vimrc&lt;/a&gt;:&lt;br&gt;&#xA;&lt;code&gt;hi Comment ctermfg=239&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;But the final Comment color scheme was loaded from &lt;code&gt;/usr/share/vim/vim74/syntax/syncolor.vim&lt;/code&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/BIKxm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BIKxm.png&quot; alt=&quot;vim-verbose&quot;&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;My .vimrc was indeed sourced, but the color part was replaced by syncolor.vim. Because syncolor.vim is sourced twice, and it's sourced at the end of vim startup. I'm using the &lt;code&gt;# vim -u ~/.cygwin/.vimrc --startuptime startup.log&lt;/code&gt; to check the startup scripts as below:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;    times in msec&#xA;     clock   self+sourced   self:  sourced script&#xA;     clock   elapsed:              other lines&#xA;&#xA;    000.003  000.003: --- VIM STARTING ---&#xA;    000.076  000.073: Allocated generic buffers&#xA;    000.124  000.048: locale set&#xA;    000.127  000.003: clipboard setup&#xA;    000.130  000.003: window checked&#xA;    007.568  007.438: inits 1&#xA;    007.576  000.008: parsing arguments&#xA;    007.577  000.001: expanding arguments&#xA;    007.623  000.046: shell init&#xA;    008.543  000.920: Termcap init&#xA;    008.562  000.019: inits 2&#xA;    008.791  000.229: init highlight&#xA;    016.569  001.641  001.641: sourcing /usr/share/vim/vim74/syntax/syncolor.vim&#xA;    017.190  003.695  002.054: sourcing /usr/share/vim/vim74/syntax/synload.vim&#xA;    043.658  024.373  024.373: sourcing /usr/share/vim/vim74/filetype.vim&#xA;    044.007  032.170  004.102: sourcing /usr/share/vim/vim74/syntax/syntax.vim&#xA;    045.527  000.074  000.074: sourcing /usr/share/vim/vim74/filetype.vim&#xA;    047.319  000.182  000.182: sourcing /usr/share/vim/vim74/ftplugin.vim&#xA;    049.047  000.151  000.151: sourcing /usr/share/vim/vim74/indent.vim&#xA;    049.926  039.919  007.342: sourcing /cygdrive/c/Users/310258281/.cygwin/.vimrc&#xA;    049.947  001.237: sourcing vimrc file(s)&#xA;    053.216  001.338  001.338: sourcing /usr/share/vim/vimfiles/plugin/fzf.vim&#xA;    058.199  000.224  000.224: sourcing /usr/share/vim/vim74/plugin/getscriptPlugin.vim&#xA;    060.159  000.664  000.664: sourcing /usr/share/vim/vim74/plugin/gzip.vim&#xA;    061.716  000.449  000.449: sourcing /usr/share/vim/vim74/plugin/logiPat.vim&#xA;    062.920  000.166  000.166: sourcing /usr/share/vim/vim74/plugin/manpager.vim&#xA;    064.748  000.545  000.545: sourcing /usr/share/vim/vim74/plugin/matchparen.vim&#xA;    067.242  001.156  001.156: sourcing /usr/share/vim/vim74/plugin/netrwPlugin.vim&#xA;    068.456  000.122  000.122: sourcing /usr/share/vim/vim74/plugin/rrhelper.vim&#xA;    069.628  000.137  000.137: sourcing /usr/share/vim/vim74/plugin/spellfile.vim&#xA;    071.121  000.530  000.530: sourcing /usr/share/vim/vim74/plugin/tarPlugin.vim&#xA;    072.821  000.264  000.264: sourcing /usr/share/vim/vim74/plugin/tohtml.vim&#xA;    074.253  000.478  000.478: sourcing /usr/share/vim/vim74/plugin/vimballPlugin.vim&#xA;    075.695  000.465  000.465: sourcing /usr/share/vim/vim74/plugin/zipPlugin.vim&#xA;    075.716  019.231: loading plugins&#xA;    077.403  001.687: loading packages&#xA;    077.839  000.436: loading after plugins&#xA;    077.851  000.012: inits 3&#xA;    078.628  000.777: reading viminfo&#xA;    078.634  000.006: setting raw mode&#xA;    078.652  000.018: start termcap&#xA;    078.724  000.072: clearing screen&#xA;    090.187  011.463: opening buffers&#xA;    090.254  000.067: BufEnter autocommands&#xA;    090.263  000.009: editing files in windows&#xA;    092.323  000.474  000.474: sourcing /usr/share/vim/vim74/syntax/syncolor.vim&#xA;    094.458  003.721: VimEnter autocommands&#xA;    094.464  000.006: before starting main loop&#xA;    094.627  000.163: first screen update&#xA;    094.630  000.003: --- VIM STARTED ---&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So simply speaking, vim works as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA; 016.569  001.641  001.641: sourcing /usr/share/vim/vim74/syntax/syncolor.vim&#xA; 049.926  039.919  007.342: sourcing /cygdrive/c/Users/310258281/.cygwin/.vimrc&#xA; 092.323  000.474  000.474: sourcing /usr/share/vim/vim74/syntax/syncolor.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why's that? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, by the way, my environment:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OS: Win10 64bit&lt;/li&gt;&#xA;&lt;li&gt;Cygwin: mintty 2.6.2 (x86-64-pc-cygwin)&lt;/li&gt;&#xA;&lt;li&gt;Vim in Cygwin: version 7.4.2367,  Modified by &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7389" LastEditorUserId="1841" LastEditDate="2016-10-19T07:39:29.337" LastActivityDate="2017-02-02T07:53:18.260" Title="Why syncolor.vim is sourced at the end of cygwin vim started and replaced the specifed colorscheme" Tags="|vimrc|colorscheme|cygwin|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9960" PostTypeId="2" ParentId="9959" CreationDate="2016-10-19T04:58:39.110" Score="2" Body="&lt;p&gt;Okay, Okay, I found the reason. There's code shows in &lt;code&gt;/usr/share/vim/vim74/syntax/synload.vim&lt;/code&gt;:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/5eyBH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5eyBH.png&quot; alt=&quot;vim2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;$ cat -n /usr/share/vim/vim74/syntax/synload.vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;...&#xA;    17  &quot; Set the default highlighting colors.  Use a color scheme if specified.&#xA;    18  if exists(&quot;colors_name&quot;)&#xA;    19    exe &quot;colors &quot; . colors_name&#xA;    20  else&#xA;    21    runtime! syntax/syncolor.vim&#xA;    22  endif&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means, if there's no colorcheme defined in vimrc, so the syncolor.vim will be the default one.... No wonder the syncolor.vim are loaded twice. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, a simple workaround, add &lt;code&gt;colorscheme xxx&lt;/code&gt; in the vimrc, it will prevent syncolor.vim re-load, and also my colorscheme will replace the color name set in vimrc:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4ZU6N.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4ZU6N.png&quot; alt=&quot;vim3&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7389" LastActivityDate="2016-10-19T04:58:39.110" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9961" PostTypeId="2" ParentId="9952" CreationDate="2016-10-19T05:05:40.837" Score="2" Body="&lt;p&gt;&lt;code&gt;getline(1, '$')&lt;/code&gt; seems to work just fine with timers . Thanks to &lt;a href=&quot;https://vi.stackexchange.com/users/5229/tommy-a&quot;&gt;@Tommy A&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9658" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-10-19T05:05:40.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9962" PostTypeId="1" AcceptedAnswerId="9963" CreationDate="2016-10-19T05:56:13.247" Score="1" ViewCount="1548" Body="&lt;p&gt;Is there a way to get filetype for given extension or filename&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let my_f='text.rb'&#xA;let my_ft=GetFileType(my_f)&#xA;echo my_ft&#xA;&quot; should output ruby&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7820" LastActivityDate="2021-02-19T14:19:57.907" Title="Get filetype by extension or filename in vimscript" Tags="|vimscript|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9963" PostTypeId="2" ParentId="9962" CreationDate="2016-10-19T06:46:50.963" Score="3" Body="&lt;p&gt;As Christian said, parsing the expression won't be the easier way. I'd even say that's insufficient. Some filetypes share the same file extension. In that case, vim parses a few lines from the files to deduce exactly their filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you could indeed parse &lt;code&gt;filetype.vim&lt;/code&gt;, but instead, I'd parse the result of &lt;code&gt;execute('autocmd filetypedetect')&lt;/code&gt; with &lt;code&gt;filter()&lt;/code&gt;. If for your extension you get a &lt;code&gt;setf {filetype}&lt;/code&gt; then you have a direct hit. Otherwise, it means vim does some magic with lines of the file to disambiguate the information.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let ext = expand('%:e') &#xA;let matching = uniq(sort(filter(split(execute('autocmd filetypedetect'), &quot;\n&quot;), 'v:val =~ &quot;\*\.&quot;.ext')))&#xA;&#xA;if len(matching) == 1 &amp;amp;&amp;amp; matching[0]  =~ 'setf'&#xA;   return matchstr(matching[0], 'setf\s\+\zs\k\+')&#xA;endif&#xA;throw &quot;sorry, I can't know&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: &lt;code&gt;execute()&lt;/code&gt; requires vim7.4-2008. With earlier versions we have to play with &lt;code&gt;:redir&lt;/code&gt;. See &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/askvim.vim#L59&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;lh#askvim#exe()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-10-19T08:19:55.240" LastActivityDate="2016-10-19T08:19:55.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9965" PostTypeId="1" AcceptedAnswerId="9969" CreationDate="2016-10-19T08:24:23.823" Score="1" ViewCount="1316" Body="&lt;p&gt;Using atom I can &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; while a word is selected in order to start a multi file search for a matching string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to emulate this flow as much as possible with Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can yank the text, type: &lt;code&gt;:grep -F&lt;/code&gt; and then paste it using &lt;code&gt;&amp;lt;ctrl+r&amp;gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this in fewer keystrokes?&lt;/p&gt;&#xA;" OwnerUserId="9761" LastEditorUserId="1821" LastEditDate="2016-10-19T09:15:17.397" LastActivityDate="2020-12-16T14:21:36.337" Title="Multi file search for selected text" Tags="|search|multiple-files|vimgrep|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9966" PostTypeId="2" ParentId="9953" CreationDate="2016-10-19T08:49:25.763" Score="1" Body="&lt;p&gt;So let's see how over-engineered we can get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say that an easier way to communicate to vim the words to process is to get them in a vimscript list. We can then simply concatenate the list with the &lt;code&gt;\|&lt;/code&gt; operator to create the desired pattern and apply the substitution that @Tumbler41 suggested in his answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetWords()&#xA;    &quot; List the items to process&#xA;    let list = ['Apple', 'Cabbage', 'Turtle']&#xA;&#xA;    &quot; Concatenate the list to make a pattern&#xA;    let pattern = list[0]&#xA;    for index in range(1, len(list)-1)&#xA;        let pattern = pattern . '\|' . list[index]&#xA;    endfor&#xA;&#xA;    &quot; Ashamedly stealing @Tumbler41 solution&#xA;    execute '%s/\('.pattern.'\)\s\+\(\d\+\)/\1 = \2;/'&#xA;    execute 'v/'.pattern.'/d'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you can simply open the buffer containing the text to change and use &lt;code&gt;:call GetWords()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Cool, but can we make it even more over-complicated? Sure!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say that the ultimate easiest way to get the list of words to process is to simply write them in a buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have 2 buffer, the one you showed in the question and a second one containing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Apple&#xA;Cabbage&#xA;Turtle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetWords(bufList, bufModify)&#xA;    &quot; Go to the buffer containing the list&#xA;    execute 'b' . a:bufList&#xA;&#xA;    &quot; List the items to process&#xA;    let list = getline(1, '$')&#xA;&#xA;    &quot; Concatenate the list to make a pattern&#xA;    let pattern = list[0]&#xA;    for index in range(1, len(list)-1)&#xA;        let pattern = pattern . '\|' . list[index]&#xA;    endfor&#xA;&#xA;    &quot; Go to the buffer to modify&#xA;    execute 'b' . a:bufModify&#xA;&#xA;    &quot; Ashamedly stealing @Tumbler41 solution&#xA;    execute '%s/\('.pattern.'\)\s\+\(\d\+\)/\1 = \2;/'&#xA;    execute 'v/'.pattern.'/d'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can simply use &lt;code&gt;:call GetWords(3, 4)&lt;/code&gt; where &lt;code&gt;3&lt;/code&gt; and &lt;code&gt;4&lt;/code&gt; are the number of the buffers containing the list and containing the text to modify and the function will do the transformation.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Credits goes to @Tumbler41 for the substitution command :-)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-10-19T08:49:25.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9967" PostTypeId="1" AcceptedAnswerId="9968" CreationDate="2016-10-19T08:56:15.597" Score="52" ViewCount="89696" Body="&lt;p&gt;Sometimes in my workflow, I might want to open or search for a file on the go.&lt;/p&gt;&#xA;&lt;p&gt;I'd like to map a single key (say &lt;kbd&gt;F6&lt;/kbd&gt;) to open and close NERDTree (&lt;em&gt;i.e.&lt;/em&gt;, I want to toggle the NERDTree view). Also, I'd like NERDTree to display hidden files and folders in its toggled view, and I'd also like it to close automatically when I open a file for editing, if that is possible.&lt;/p&gt;&#xA;" OwnerUserId="9760" LastEditorUserId="10604" LastEditDate="2021-07-05T21:13:56.630" LastActivityDate="2023-02-14T20:07:48.497" Title="How do I open and close NERDTree (toggle NERDTree view) using a single keystroke?" Tags="|plugin-nerdtree|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9968" PostTypeId="2" ParentId="9967" CreationDate="2016-10-19T08:59:13.223" Score="58" Body="&lt;p&gt;In your &lt;code&gt;vimrc&lt;/code&gt; add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F6&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;&amp;lt;F6&amp;gt;&lt;/code&gt; is the key you want to map.&lt;/p&gt;&#xA;" OwnerUserId="9763" LastActivityDate="2016-10-19T08:59:13.223" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9969" PostTypeId="2" ParentId="9965" CreationDate="2016-10-19T09:19:18.853" Score="1" Body="&lt;p&gt;You can reference the word/WORD under the cursor with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;&#xA;&amp;lt;C-r&amp;gt;&amp;lt;C-a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So instead of yanking, you can directly have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:grep -F &amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even shorter with a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-f&amp;gt; :grep -F &quot;&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if you want to search for a visually selected part of your file you can automate the process also:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;C-f&amp;gt; &quot;ay:grep -F &quot;&amp;lt;C-r&amp;gt;a&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In those mapping I've not put a &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; at the end so you can see the result (and maybe change it) before starting the search. But if you want, adding a &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; at the end of the mapping will run the command automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;see &lt;code&gt;:h c_CTRL-R_CTRL-W&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-10-19T09:26:39.083" LastActivityDate="2016-10-19T09:26:39.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9970" PostTypeId="2" ParentId="9965" CreationDate="2016-10-19T09:27:23.053" Score="1" Body="&lt;p&gt;If you are on a *nix system you can use the &lt;a href=&quot;https://github.com/gabesoft/vim-ags&quot; rel=&quot;nofollow&quot;&gt;Ags&lt;/a&gt; plugin that uses the &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;nofollow&quot;&gt;Ag&lt;/a&gt; external program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calling &lt;code&gt;:Ags&lt;/code&gt; without arguments will search in all the files the word under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The downfall of Ags is that it search only in the path of the currently opened file, but, if you want to search all files in the directory root (like a &lt;code&gt;git&lt;/code&gt; repo) you can add the vim-rooter plugin.&lt;/p&gt;&#xA;" OwnerUserId="9763" LastActivityDate="2016-10-19T09:27:23.053" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9971" PostTypeId="1" CreationDate="2016-10-19T12:09:08.573" Score="1" ViewCount="1844" Body="&lt;p&gt;I know they have many topics about that, but i no one of them works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My configuration worked before to switch between split window, but my session has been re-init and i lost my osx config and it's not working anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my &lt;code&gt;.vimrc&lt;/code&gt; i have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;ESC&amp;gt;^[A &amp;lt;Nop&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;ESC&amp;gt;^[B &amp;lt;Nop&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;ESC&amp;gt;^[D &amp;lt;Nop&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;ESC&amp;gt;^[C &amp;lt;Nop&amp;gt;&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-Right&amp;gt; &amp;lt;c-w&amp;gt;l&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-Left&amp;gt; &amp;lt;c-w&amp;gt;h&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-Up&amp;gt; &amp;lt;c-w&amp;gt;k&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-Down&amp;gt; &amp;lt;c-w&amp;gt;j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On &lt;code&gt;iTerm&lt;/code&gt; i set my terminal as &lt;code&gt;Terminal App default&lt;/code&gt; (i tried with &lt;code&gt;xterm default&lt;/code&gt; too)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the system preference, i disable the mission control keys with &lt;code&gt;ctrl + arrow key&lt;/code&gt; in System preference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with &lt;code&gt;sed -n l&lt;/code&gt; i have&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LEFT: &lt;code&gt;^[[D&lt;/code&gt; | CTRL + LEFT:  &lt;code&gt;^[[5D&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="8935" LastActivityDate="2016-10-19T12:09:08.573" Title="Vim bind ctrl arrow key not working on osx" Tags="|key-bindings|cursor-movement|iterm2|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9972" PostTypeId="2" ParentId="5348" CreationDate="2016-10-19T13:05:30.767" Score="14" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/mhinz/neovim-remote&quot; rel=&quot;noreferrer&quot;&gt;Neovim remote&lt;/a&gt; is a python script for controlling neovim processes. It has the vim style --servername and --remote options. This is what I use now for my multiple-terminal work environment.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2016-10-19T13:05:30.767" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9974" PostTypeId="2" ParentId="9953" CreationDate="2016-10-19T14:13:22.403" Score="0" Body="&lt;p&gt;Like the other answers, I'm assuming the list is in a different buffer, one entry per line. This one is similar to @9bittree's solution, but it uses my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3355&quot; rel=&quot;nofollow&quot;&gt;UnconditionalPaste plugin&lt;/a&gt; to quickly build the substitution command.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Yank the list of words, e.g. &lt;code&gt;ggyG&lt;/code&gt; or &lt;code&gt;:%yank&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Build the substitution command: &lt;code&gt;:%s/\(&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Now, insert the yanked words, joined with a &lt;code&gt;\|&lt;/code&gt; pattern separator. With my plugin, that's &lt;code&gt;&amp;lt;C-R&amp;gt;&amp;lt;C-Q&amp;gt;&quot;\\|&amp;lt;Enter&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Complete the substitution command, and execute: &lt;code&gt;\)\s\+\(\d\+\)/\1 = \2;/&amp;lt;Enter&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-10-19T14:13:22.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9975" PostTypeId="1" AcceptedAnswerId="9976" CreationDate="2016-10-19T15:39:46.790" Score="2" ViewCount="63" Body="&lt;p&gt;Suppose I have an open buffer containing the following text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1111111111&#xA;1        1&#xA;1 222222 1&#xA;1 2    2 1&#xA;1 2 33 2 1&#xA;1 2 33 2 1&#xA;1 2 33 2 1&#xA;1 2    2 1&#xA;1 222222 1&#xA;1        1&#xA;1111111111&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can visually select and yank the 2-rectangle with the command &lt;code&gt;3gg2l&amp;lt;Ctrl-V&amp;gt;8jey&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I can immediately reselect and paste the yanked text (not changing the&#xA;buffer) with &lt;code&gt;gvp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it seems like as soon as I write to the &lt;code&gt;@@&lt;/code&gt; or &lt;code&gt;@&quot;&lt;/code&gt; register (even if&#xA;I don't change the value), something changes, and pasting doesn't work right&#xA;anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @@=@@&#xA;:normal! gvp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;changes the buffer to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1111111111&#xA;1        1&#xA;1 222222&#xA;2    2&#xA;2 33 2&#xA;2 33 2&#xA;2 33 2&#xA;2    2&#xA;222222 1&#xA;1  1&#xA;1  1&#xA;1  1&#xA;1  1&#xA;1  1&#xA;1  1&#xA;1        1&#xA;1111111111&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;inserting the contents of the register as new lines, rather than overlaying the&#xA;visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="361" LastActivityDate="2016-10-19T16:04:37.020" Title="extra newlines when pasting altered string in visual block mode" Tags="|visual-block|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9976" PostTypeId="2" ParentId="9975" CreationDate="2016-10-19T15:59:32.403" Score="5" Body="&lt;p&gt;The problem comes from the register type, you can use &lt;code&gt;echo getregtype('&quot;')&lt;/code&gt; before and after your &lt;code&gt;let @@=@@&lt;/code&gt; and you'll see that the type has changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getregtype%28%29&quot;&gt;&lt;code&gt;:h getregtype()&lt;/code&gt;&lt;/a&gt; tells us that a register can have different types:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;v&quot;           for characterwise text&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&quot;V&quot;           for linewise text&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&quot;{width}&quot; for blockwise-visual text&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&quot;&quot;            for an empty or unknown register&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So when you select your rectangle with &lt;kbd&gt;ctrl+v&lt;/kbd&gt; and then you yank it, you actually set the type of the &lt;code&gt;&quot;&lt;/code&gt; register to visual block (Here &lt;code&gt;^V6&lt;/code&gt; actually)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you do &lt;code&gt;let @@=@@&lt;/code&gt; you do no respect the register type. Thus you do not past in block wise mode anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The correct way to set a register is to use the function &lt;code&gt;setreg()&lt;/code&gt; which accepts as parameter the register type to set. See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#setreg%28%29&quot;&gt;&lt;code&gt;:h setreg()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-10-19T16:04:37.020" LastActivityDate="2016-10-19T16:04:37.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9977" PostTypeId="1" CreationDate="2016-10-19T18:23:07.780" Score="6" ViewCount="448" Body="&lt;p&gt;I'd like to make a plugin to display currently pending keys while in operator-pending mode. As the first part of that, how would I register an autocmd to run when operator-pending mode is entered? I'm using neovim, so I'm totally cool if it only works there.&lt;/p&gt;&#xA;" OwnerUserId="9767" LastActivityDate="2023-01-08T01:04:46.320" Title="Is there an autocmd-like event for when operator pending mode is entered?" Tags="|vimscript|neovim|autocmd|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9978" PostTypeId="1" AcceptedAnswerId="10069" CreationDate="2016-10-19T20:16:37.180" Score="3" ViewCount="307" Body="&lt;p&gt;&lt;a href=&quot;http://vimcasts.org/episodes/how-to-fold/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Inspired by Drew NEIL's&lt;/a&gt; course and the 'nested-folding' feature for Markdown files, I've installed the &lt;a href=&quot;https://github.com/msprev/vim-markdown-folding&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Vim-Markdown-Folding&lt;/code&gt; plugin&lt;/a&gt;, on my &lt;a href=&quot;http://pastebin.com/PY4fz1rC&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim (&lt;code&gt;:version&lt;/code&gt;)&lt;/a&gt;. The GitHub directory was copied into the &lt;code&gt;~/.vim/bundle&lt;/code&gt; directory (as required by the &lt;code&gt;pathogen&lt;/code&gt; plugin) with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ git clone https://github.com/msprev/vim-markdown-folding.git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I added the required &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:markdown_fold_style = 'nested'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;line into my &lt;code&gt;.vimrc&lt;/code&gt;-file as described in the &lt;a href=&quot;https://github.com/nelstrom/vim-markdown-folding/blob/master/doc/markdown-folding.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help markdown-folding-configuration&lt;/code&gt;&lt;/a&gt; file and got this wired error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing BufEnter Auto commands for &quot;&amp;lt;buffer=1&amp;gt;&quot;:&#xA;E117: Unknown function: mdfolding#foldtextupdate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when opening, saving, or even jumping into the (Vim-)window of any markdown file. Otherwise everything seems to work fine. However, every time the error occurs I have to confirm the reading and I really would like to settle any other potential complications.&lt;/p&gt;&#xA;" OwnerUserId="8839" LastEditorUserId="8839" LastEditDate="2016-11-01T12:57:13.993" LastActivityDate="2016-11-01T14:36:56.987" Title="Vim-Markdown-Folding plugin error BufEnter E117" Tags="|vimrc|folding|error|filetype-markdown|plugin-pathogen|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9979" PostTypeId="1" AcceptedAnswerId="9980" CreationDate="2016-10-19T20:37:04.243" Score="0" ViewCount="903" Body="&lt;p&gt;I installed vim 8.0 for Windows last week.  It seemed to work great the first few days, but now I have found that when I open a file in vim console mode, the editing window comes up without a menu bar (i.e. the bar at the top that has entries named File Edit Tools etc.).  I've been using vim for over 20 years and have never seen this before.  I think that I may have accidentally changed an option setting but I haven't been able to figure out what it is.  Is there an option to get the menu bar to display?  I've tried lots of things, like setting guioptions, but nothing helps.  Thank you.&lt;/p&gt;&#xA;" OwnerUserId="9769" LastEditorUserId="51" LastEditDate="2016-11-11T05:44:06.283" LastActivityDate="2016-11-11T05:44:06.283" Title="Vim 8.0 console on Windows 7 opens with no menu bar" Tags="|gvim|microsoft-windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9980" PostTypeId="2" ParentId="9979" CreationDate="2016-10-19T20:55:11.540" Score="5" Body="&lt;p&gt;I think you are confused about terminology. &lt;em&gt;&quot;Console vim&quot;&lt;/em&gt; has never had a menu bar. Here is a snapshot of windows' console vim with all the default settings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rQuFJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rQuFJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Pretty ugly IMO)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No menu bar. This is because it is running inside of windows' &lt;code&gt;cmd&lt;/code&gt; program, which does not have support for GUI features such as menu bars; it's &lt;em&gt;purely&lt;/em&gt; text based. You have probably been using &lt;em&gt;Gvim&lt;/em&gt; before. For reference, here is what Gvim looks like on windows with all default settings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9b8ET.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9b8ET.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This does have a menu, and it can be configured with &lt;code&gt;guioptions&lt;/code&gt;. I would recommend following &lt;a href=&quot;https://vi.stackexchange.com/questions/9979/vim-8-0-console-on-windows-7-opens-with-no-menu-bar#comment17463_9979&quot;&gt;VanLaser's&lt;/a&gt; advice, and sticking with gvim. In my experience it runs a lot better on windows than the console version, as well as having the menu bar you're looking for. If you installed vim in the default location, you can find &lt;code&gt;gvim&lt;/code&gt; at&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Program Files (x86)\Vim\vim80\gvim.exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-10-19T20:55:11.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9981" PostTypeId="2" ParentId="9957" CreationDate="2016-10-20T05:29:45.813" Score="0" Body="&lt;p&gt;What I actually used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; case insensitive auto-complete&#xA;function! BeforeComplete(key) abort&#xA;    if !exists('g:last_ic')&#xA;        let g:last_ic = &amp;amp;ignorecase&#xA;        set ignorecase&#xA;    endif&#xA;    return a:key&#xA;endfunction&#xA;for s:key in ['&amp;lt;c-n&amp;gt;', '&amp;lt;c-p&amp;gt;', '&amp;lt;c-x&amp;gt;']&#xA;    execute 'inoremap &amp;lt;expr&amp;gt; '.s:key.' BeforeComplete('''.s:key.''')'&#xA;endfor&#xA;autocmd CompleteDone,InsertLeave * if exists('g:last_ic') | let &amp;amp;ignorecase=g:last_ic | unlet g:last_ic | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Because I got a couple of errors and wanted the variable to use the same scope as the option's.)&lt;/p&gt;&#xA;" OwnerUserId="8520" LastActivityDate="2016-10-20T05:29:45.813" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9982" PostTypeId="1" AcceptedAnswerId="18742" CreationDate="2016-10-20T05:33:18.773" Score="1" ViewCount="1366" Body="&lt;p&gt;I have a very strange issue. I am running vim on my Centos 7 box and having issues getting it to load my .vimrc when I run &lt;code&gt;sudoedit&lt;/code&gt; or &lt;code&gt;ssh -e vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run sudoedit I end up with a few of my settings carrying over but none of my custom colors or any of my key mappings transfer over. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do see line numbers and I think my indentation settings are working, but not much else. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here you can see what it looks like normally:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yDj4F.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yDj4F.png&quot; alt=&quot;Called as vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what it looks like when using &lt;code&gt;sudoedit&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6KFyM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6KFyM.png&quot; alt=&quot;Called with sudoedit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I included my &lt;code&gt;:version&lt;/code&gt; output just to show it's not calling vi or some other version of the editor, and it clearly shows that both are calling the same .vimrc file. It's just that one is actually reading it and the other isn't...&lt;/p&gt;&#xA;" OwnerUserId="9772" LastEditorDisplayName="user5791" LastEditDate="2019-01-30T06:03:26.453" LastActivityDate="2019-01-30T06:32:38.530" Title=".vimrc is not properly loaded when running sudoedit or sudo -e vim" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9983" PostTypeId="1" AcceptedAnswerId="9984" CreationDate="2016-10-20T05:36:04.583" Score="7" ViewCount="428" Body="&lt;p&gt;I'm trying to make a Vim command which opens all modified files tracked by Git.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following command works if there is only one modified file (and fails if the current working directory is not a git repository).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers on how to e.g. loop the results of external command producing multiple lines?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command Git execute &quot;:e `git diff --name-only`&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9773" LastActivityDate="2016-10-20T06:23:00.173" Title="Open git tracked files inside editor" Tags="|git|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9984" PostTypeId="2" ParentId="9983" CreationDate="2016-10-20T06:01:45.917" Score="9" Body="&lt;p&gt;You could use the &lt;code&gt;args&lt;/code&gt; command instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command G execute &quot;:args `git diff --name-only`&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first file should be opened, and if you run &lt;code&gt;:ls&lt;/code&gt; after executing this, you should see other files listed as well. Or, as romainl notes, you don't need the &lt;code&gt;execute&lt;/code&gt; at all:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command G :args `git diff --name-only`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;argadd&lt;/code&gt; command could be useful too. From &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Aargs&quot;&gt;&lt;code&gt;:h args&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ar[gs] [++opt] [+cmd] {arglist}                        :args_f&#xA;                        Define {arglist} as the new argument list and edit&#xA;                        the first one.  This fails when changes have been made&#xA;                        and Vim does not want to abandon the current buffer.&#xA;                        Also see ++opt and +cmd.&#xA;                        {Vi: no ++opt}&#xA;&#xA;:ar[gs]! [++opt] [+cmd] {arglist}                       :args_f!&#xA;                        Define {arglist} as the new argument list and edit&#xA;                        the first one.  Discard any changes to the current&#xA;                        buffer.&#xA;                        Also see ++opt and +cmd.&#xA;                        {Vi: no ++opt}&#xA;&#xA;&#xA;:[count]arga[dd] {name} ..                      :arga :argadd E479&#xA;:[count]arga[dd]&#xA;                        Add the {name}s to the argument list.  When {name} is&#xA;                        omitted add the current buffer name to the argument&#xA;                        list.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-10-20T06:23:00.173" LastActivityDate="2016-10-20T06:23:00.173" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9986" PostTypeId="1" AcceptedAnswerId="9988" CreationDate="2016-10-20T07:53:18.653" Score="0" ViewCount="901" Body="&lt;p&gt;I recently discovered that vim can open archives like &lt;code&gt;.zip&lt;/code&gt; or &lt;code&gt;tar.gz&lt;/code&gt; and list all files in them. We can even open the files in vim by pressing enter on a filename we want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I want to extract some of the files from an archive to another directory. Is there a way to do it with vim? I mean this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/w9N6U.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/w9N6U.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//files list goes below&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2016-10-20T10:57:02.337" Title="Copy a file from an archive" Tags="|command-line|normal-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9987" PostTypeId="1" AcceptedAnswerId="9990" CreationDate="2016-10-20T10:14:44.257" Score="2" ViewCount="1290" Body="&lt;p&gt;My current &lt;code&gt;&amp;amp;viminfo&lt;/code&gt; contents are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set viminfo?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;viminfo=!,'100,&amp;lt;50,s10,h,n/home/ravi/.local/share/vim/viminfo&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I want to have a single &lt;code&gt;vimrc&lt;/code&gt; which works with both &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;neovim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What lines can I add to my &lt;code&gt;vimrc&lt;/code&gt; to set use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In &lt;code&gt;vim&lt;/code&gt;: &lt;code&gt;/home/ravi/.local/share/vim/viminfo&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;In &lt;code&gt;neovim&lt;/code&gt;: the &lt;a href=&quot;https://neovim.io/doc/user/starting.html#shada-file-name&quot; rel=&quot;nofollow&quot;&gt;default&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2016-10-25T01:44:07.450" LastActivityDate="2016-10-25T01:44:07.450" Title="Set &amp;viminfo differently in neovim and vim" Tags="|neovim|" AnswerCount="1" CommentCount="6" ClosedDate="2016-10-21T05:17:58.813" ContentLicense="CC BY-SA 3.0" />
  <row Id="9988" PostTypeId="2" ParentId="9986" CreationDate="2016-10-20T10:57:02.337" Score="4" Body="&lt;p&gt;For a single / few (text) files you can open them in Vim, and just use &lt;code&gt;:write path/to/other/location&lt;/code&gt; to copy them elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For non-text files, of if there are many of them, you'd better use the native archive commands (like &lt;code&gt;tar&lt;/code&gt; or &lt;code&gt;unzip&lt;/code&gt;) directly. The corresponding Vim plugins that enable the transparent archive access (&lt;code&gt;:help pi_tar&lt;/code&gt; and &lt;code&gt;:help pi_zip&lt;/code&gt;) use those commands internally, too, so you definitely have them on your system.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-10-20T10:57:02.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9990" PostTypeId="2" ParentId="9987" CreationDate="2016-10-20T16:32:57.303" Score="5" Body="&lt;p&gt;I would suggest appending your specific additions to the viminfo option rather than duplicating default information.  That is, &lt;code&gt;set viminfo+=!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, it seems like setting the &lt;code&gt;n&lt;/code&gt; option isn't necessary.  However, if you want to do that then you can simply do that in a non-nvim check.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !has('nvim')&#xA;  set viminfo+=n~/.local/share/vim/viminfo&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2016-10-20T16:32:57.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9991" PostTypeId="2" ParentId="3576" CreationDate="2016-10-20T17:46:49.303" Score="0" Body="&lt;p&gt;I had this issue recently with the solarized theme. The problem did come from the &lt;code&gt;TERM&lt;/code&gt; env variable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I fixed it by telling my terminal emulator (terminator in my case) to run &lt;code&gt;env TERM=xterm-256color zsh&lt;/code&gt; instead of just starting up zsh as normal.&lt;/p&gt;&#xA;" OwnerUserId="9785" LastActivityDate="2016-10-20T17:46:49.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9992" PostTypeId="1" AcceptedAnswerId="9994" CreationDate="2016-10-21T10:06:10.437" Score="1" ViewCount="3171" Body="&lt;p&gt;I know that I can paste the clipboard in by by typing &lt;kbd&gt;ctrl-shift-v&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that this is a very counterintuitive shortcut. It requires me to move my hand in a very uncomfortable way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to paste the clipboard with something better, such as &lt;code&gt;gcp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to put a line in my vimrc file that will accomplish this, but I am getting major headaches as it seems to be impossible to do. Instead I must resort to some buffers, which i have been looking at for a while without result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I place a line in the Vimrc which allows me to paste the clipboard content onto the file I'm in, upon a click of a shortcut of my choosing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;p.s.&#xA;Solution was to install vim-gtk&#xA;and after that i could do:&#xA;:put +&lt;/p&gt;&#xA;" OwnerUserId="605" LastEditorUserId="605" LastEditDate="2016-10-21T13:49:53.440" LastActivityDate="2016-10-21T13:49:53.440" Title="Paste clipboard shortcut in vimrc" Tags="|cut-copy-paste|os-clipboard|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9993" PostTypeId="2" ParentId="9992" CreationDate="2016-10-21T10:28:04.017" Score="4" Body="&lt;p&gt;Assuming Vim has access to the clipboard, you can insert the clipboard contents (in Vim register &lt;code&gt;+&lt;/code&gt;) via &lt;code&gt;&amp;lt;C-R&amp;gt;&amp;lt;C-R&amp;gt;+&lt;/code&gt; (in insert mode) and via &lt;code&gt;&quot;+p&lt;/code&gt; in other modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, some mappings could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap &amp;lt;F2&amp;gt; &quot;+p&#xA;:noremap! &amp;lt;F2&amp;gt; &amp;lt;C-R&amp;gt;&amp;lt;C-R&amp;gt;+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To paste as completely new lines, you can also use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put +&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2016-10-21T12:53:07.563" LastActivityDate="2016-10-21T12:53:07.563" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9994" PostTypeId="2" ParentId="9992" CreationDate="2016-10-21T11:32:15.220" Score="3" Body="&lt;p&gt;&lt;em&gt;Update: In order to access the system clipboard(s) Vim needs to be compiled with support for this. You can use the commands &lt;code&gt;:echo has('clipboard')&lt;/code&gt; and, on Unix, &lt;code&gt;:echo has('xterm_clipboard')&lt;/code&gt; to check for this. As it turns out, question asker did&lt;/em&gt; not &lt;em&gt;have these features compiled in. Their &lt;code&gt;ctrl-shift-v&lt;/code&gt; shortcut was pasting into the&lt;/em&gt; terminal &lt;em&gt;and Vim was receiving the text as if it were typed. &lt;a href=&quot;https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim&quot;&gt;This existing question&lt;/a&gt; describes how to get the system clipboard accessible from within Vim.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The standard method of pasting from the system clipboard is via the &lt;code&gt;+&lt;/code&gt; register, which you can access from normal mode with a command such as &lt;code&gt;&quot;+p&lt;/code&gt;. (Outside of X11 sytems, the &lt;code&gt;*&lt;/code&gt; register will also work. See &lt;code&gt;:help x11-selection&lt;/code&gt; for a discussion of the difference.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can therefore create your &lt;code&gt;gcp&lt;/code&gt; mapping for normal/visual/select modes with the commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap gcp &quot;+p&#xA;:noremap gcp &quot;+p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following works for insert mode (see &lt;code&gt;:help i_CTRL-O&lt;/code&gt;), but &lt;code&gt;gcp&lt;/code&gt; isn't the best choice of trigger in insert mode, for obvious reasons, so you're probably going to want to pick something else:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap gcp &amp;lt;c-o&amp;gt;&quot;+p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. &lt;code&gt;ctrl-shift-v&lt;/code&gt; is not a standard Vim shortcut, and as far as I'm aware, &lt;a href=&quot;https://stackoverflow.com/questions/1506764/how-to-map-ctrla-and-ctrlshifta-differently&quot;&gt;such a shortcut can only be set up &lt;em&gt;outside&lt;/em&gt; of Vim&lt;/a&gt;. Is there any chance you're on Windows, you have &lt;code&gt;clipboard=unnamed&lt;/code&gt; set, and you're actually just using &lt;code&gt;mswin.vim's&lt;/code&gt; &lt;code&gt;ctrl-v&lt;/code&gt; shortcut?&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-10-21T13:48:36.003" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="9997" PostTypeId="1" AcceptedAnswerId="9998" CreationDate="2016-10-21T14:36:26.323" Score="12" ViewCount="828" Body="&lt;p&gt;Hitting &lt;code&gt;&amp;gt;3j&lt;/code&gt; indents the current line and the three below it, and &lt;code&gt;&amp;gt;3k&lt;/code&gt; does the same but with the three lines above. However, when indenting down, my cursor is left on the same line as it started, but when indenting up, the cursor moves to the top most indented line. Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do Vim automatically move to the top most indented line, but that just happens to be the same as the starting line when indenting downwards, or is there something else behind it?&lt;/p&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2016-10-21T14:47:27.620" Title="Why does &gt;3k move the cursor up when &gt;3j does not move it down?" Tags="|cursor-movement|indentation|cursor-motions|" AnswerCount="1" CommentCount="0" ClosedDate="2016-10-22T14:02:05.013" ContentLicense="CC BY-SA 3.0" />
  <row Id="9998" PostTypeId="2" ParentId="9997" CreationDate="2016-10-21T14:47:27.620" Score="13" Body="&lt;p&gt;Yes, Vim automatically moves to the top most indented line. To see this, position the cursor in the middle of a paragraph and use &lt;code&gt;&amp;gt;ap&lt;/code&gt; to indent the whole paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this is not specific to indenting. If you use &lt;code&gt;!ipsort&lt;/code&gt; to sort all lines of the current paragraph, the cursor moves to the top of the sorted paragraph as well.&lt;/p&gt;&#xA;" OwnerUserId="2680" LastActivityDate="2016-10-21T14:47:27.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9999" PostTypeId="1" CreationDate="2016-10-21T17:04:05.527" Score="2" ViewCount="1543" Body="&lt;p&gt;Fo example, this piece of code in rails:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  t.string :receipt_number&#xA;  t.timestamp :transaction_timestamp&#xA;  t.string :transaction_type&#xA;  t.decimal :cash_amount&#xA;  t.decimal :card_amount&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I want new code should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  t.string      :receipt_number&#xA;  t.timestamp   :transaction_timestamp&#xA;  t.string      :transaction_type&#xA;  t.decimal     :cash_amount&#xA;  t.decimal     :card_amount&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried align left/right/center, but It seems not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;first case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  t.string:    receipt_number&#xA;  t.timestamp: transaction_timestamp&#xA;  t.string:    transaction_type&#xA;  t.decimal:   cash_amount&#xA;  t.decimal:   card_amount&#xA;  t.decimal:   voucher_amount&#xA;  t.decimal:   total_amount&#xA;  t.int:       sa_id&#xA;  t.string:    sa_name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     t.string: receipt_number&#xA;  t.timestamp: transaction_timestamp&#xA;     t.string: transaction_type&#xA;    t.decimal: cash_amount&#xA;    t.decimal: card_amount&#xA;    t.decimal: voucher_amount&#xA;    t.decimal: total_amount&#xA;        t.int: sa_id&#xA;     t.string: sa_name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I make alignment as expected code.&lt;/p&gt;&#xA;" OwnerUserId="7078" LastEditorUserId="24" LastEditDate="2016-10-21T20:36:42.033" LastActivityDate="2016-10-21T20:36:42.033" Title="Vim-easy-align: how to align delimeter on right" Tags="|alignment|plugin-easy-align|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10000" PostTypeId="2" ParentId="9999" CreationDate="2016-10-21T18:00:05.810" Score="1" Body="&lt;p&gt;Aligning delimiter is controlled by &lt;code&gt;stick-to-left&lt;/code&gt; option. Its a boolean controlling whether to position delimiter on the left-side. so your wanted result is achievable through selecting the desired lines with &lt;code&gt;V&lt;/code&gt;(visual linewise mode) and running the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;EasyAlign : { 'right-margin':0, 'left-margin':3, 'stick-to-left':0 }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course this is too much typing for a such simple aligment task! In practice you could use interesting &lt;strong&gt;Live interactive mode&lt;/strong&gt;. just type &lt;code&gt;:LiveEasyAlign&lt;/code&gt; command or even faster, map it to a key using &lt;code&gt;&amp;lt;Plug&amp;gt;(LiveEasyAlign)&lt;/code&gt;. now you can simply using key combinations to align items.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aligning delimiter is &lt;code&gt;&amp;lt;Left&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Right&amp;gt;&lt;/code&gt; keys and you can view your code alignment &lt;strong&gt;Live&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7976" LastEditorUserId="7976" LastEditDate="2016-10-21T18:25:39.210" LastActivityDate="2016-10-21T18:25:39.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10001" PostTypeId="2" ParentId="9999" CreationDate="2016-10-21T18:08:11.487" Score="2" Body="&lt;p&gt;Here's an admittedly hacky solution in pure vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm dt::left 17&amp;lt;C-v&amp;gt;&amp;lt;CR&amp;gt;0:exec &quot;norm R&quot;.getreg('&quot;')&amp;lt;C-v&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, you can changed &lt;code&gt;17&lt;/code&gt; to whatever value works best with your text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way this works is by deleting everything up to the first colon before aligning. Then after that, it uses replace mode (&lt;code&gt;R&lt;/code&gt;) to paste the deleted text over the extra spaces.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm                          &quot; On every line:&#xA;       dt:                      &quot; Delete until a colon&#xA;          :left 17&amp;lt;C-v&amp;gt;&amp;lt;CR&amp;gt;     &quot; Align to the 17'th column&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, we move back to the first column with &lt;code&gt;0&lt;/code&gt; and run the rest. We use &lt;code&gt;exec&lt;/code&gt; so that we can construct a normal command with the contents of the deleted text.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec                               &quot; Execute the following string&#xA;      &quot;norm                         &quot; Enter normal mode&#xA;            R&quot;                      &quot; Enter replace mode&#xA;              .                     &quot; Concatenate this string &#xA;               getreg('&quot;')          &quot; With the contents of the unnamed register&#xA;                          &amp;lt;C-v&amp;gt;&amp;lt;CR&amp;gt; &quot; Enter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We use &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt; so that it enters a literal newline rather than running the command right then.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-10-21T18:24:16.043" LastActivityDate="2016-10-21T18:24:16.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10002" PostTypeId="1" AcceptedAnswerId="10009" CreationDate="2016-10-21T18:31:11.123" Score="1" ViewCount="479" Body="&lt;p&gt;The way I compile now is by calling make. A batch window pops up. Instead, I want the output to be in shown directly in Vim, just like Syntastic does it. Also, the errors inside should be navigable. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="7816" LastActivityDate="2016-10-22T09:18:10.643" Title="Compilation window that shows errors" Tags="|external-command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10003" PostTypeId="2" ParentId="9999" CreationDate="2016-10-21T20:32:11.503" Score="0" Body="&lt;p&gt;I don't get what the difficulty is, unless you are &lt;em&gt;not&lt;/em&gt; aligning using &lt;code&gt;Space&lt;/code&gt; as delimiter, and/or you don't specify the region to align. Nobody forces you to use &lt;code&gt;:&lt;/code&gt; as delimiter. Steps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Visually select all lines you want (using &lt;code&gt;V&lt;/code&gt; etc.)&lt;/li&gt;&#xA;&lt;li&gt;call your &lt;code&gt;EasyAlign&lt;/code&gt; key map; the command-line should look like this: &lt;code&gt;:'&amp;lt;,'&amp;gt;EasyAlign(_)&lt;/code&gt; (if you type the command manually, you need to hit &lt;code&gt;Enter&lt;/code&gt; once)&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;Space&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;... That's it, the text is aligned as in your 2nd sample.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastActivityDate="2016-10-21T20:32:11.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10004" PostTypeId="5" CreationDate="2016-10-21T20:49:27.003" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/junegunn/vim-easy-align&quot; rel=&quot;nofollow&quot;&gt;vim-easy-align&lt;/a&gt; is a plugin to align text.  It can adjust whitespace based on predefined alignment rules, word breaks, or regular expressions.&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2016-10-22T00:50:27.570" LastActivityDate="2016-10-22T00:50:27.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10005" PostTypeId="4" CreationDate="2016-10-21T20:49:27.003" Score="0" Body="vim-easy-align is a plugin to align text" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2016-10-22T00:50:21.677" LastActivityDate="2016-10-22T00:50:21.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10006" PostTypeId="1" CreationDate="2016-10-21T20:47:48.593" Score="1" ViewCount="189" Body="&lt;p&gt;I need a readable colorscheme for &lt;em&gt;vim -d&lt;/em&gt; (or vimdiff). My problem is that some lines aren't readable (see picture), white text on yellow background:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/wN71S.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wN71S.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;I tried also the following in &lt;em&gt;~/.vimrc&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;diff&#xA;   set At_Co=16&#xA;   set syntax off&#xA;   colorscheme vcbc&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I like syntax on and the change of the color didn’t improve. &#xA;My Questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How can I get the key word of white text on yellow background so that I can change the colorscheme manually? I tried already ‘highlight’ in vi which shows the keyword and the settings but it didn’t work.&lt;/li&gt;&#xA;&lt;li&gt;An alternative is finding a good colorscheme for vimdiff. I found some who claimed to be optimized for vimdiff like ‘vcbc‘ but it produces the same unreadable text.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am on Ubuntu 16.04. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="9517" OwnerDisplayName="musbach" LastActivityDate="2016-10-21T20:59:26.920" Title="diff or vim -d colorscheme" Tags="|vimdiff|vimrc|" AnswerCount="0" CommentCount="3" FavoriteCount="0" ClosedDate="2017-01-09T17:36:26.147" ContentLicense="CC BY-SA 3.0" />
  <row Id="10007" PostTypeId="1" AcceptedAnswerId="10013" CreationDate="2016-10-22T08:17:56.657" Score="7" ViewCount="2344" Body="&lt;p&gt;I have a Bash script which sources variables from another file. It passes the &lt;code&gt;shellcheck -x&lt;/code&gt;, however Syntastic always complains:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Not following: sourced_file.sh was not specified as input (see shellcheck -x). [SC1091]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The script is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;&#xA;. sourced_file.sh&#xA;&#xA;echo ${variable1}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;sourced_file.sh&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable1=&quot;value1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to add a directive (although I understand directives are supposed to be used only in case of a filename not given explicitly and here it is a static include):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# shellcheck source=main_file.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it did not resolve the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to disable the check completely. How can I tell Syntastic to source the file?&lt;/p&gt;&#xA;" OwnerUserId="5334" LastActivityDate="2019-12-08T02:43:55.267" Title="How to make Syntastic include sourced files for Bash syntax (as `shellcheck -x` does)?" Tags="|plugin-syntastic|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10009" PostTypeId="2" ParentId="10002" CreationDate="2016-10-22T09:18:10.643" Score="3" Body="&lt;p&gt;try &lt;code&gt;:make | copen&lt;/code&gt; (for horizontal split)  or &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:make | vert copen&lt;/code&gt;for vertical split &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It opens a new window in vim to show the list of errors. &lt;/p&gt;&#xA;" OwnerUserId="9004" LastActivityDate="2016-10-22T09:18:10.643" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10011" PostTypeId="2" ParentId="3378" CreationDate="2016-10-22T21:18:17.307" Score="1" Body="&lt;p&gt;I use a custom map to refresh &lt;code&gt;NERDTree&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;Leader&amp;gt;r :NERDTreeFocus&amp;lt;cr&amp;gt; \| R \| &amp;lt;c-w&amp;gt;&amp;lt;c-p&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once set, &lt;kbd&gt;Leader&lt;/kbd&gt; + &lt;kbd&gt;r&lt;/kbd&gt; will do this for you:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Switch to &lt;code&gt;NERDTree&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Refresh the Root Node&lt;/li&gt;&#xA;&lt;li&gt;Switch back to the previous window&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;strong&gt;Note:&lt;/strong&gt; My key map has a last step where it &lt;a href=&quot;https://github.com/sheharyarn/dotfiles/blob/master/Vim/.vimrc#L43-L44&quot; rel=&quot;nofollow&quot;&gt;refreshes CtrlP after refreshing NERDTree&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="969" LastActivityDate="2016-10-22T21:18:17.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10012" PostTypeId="2" ParentId="6294" CreationDate="2016-10-23T01:06:43.897" Score="3" Body="&lt;p&gt;So I had a very similar problem on my Windows 10 but for 64 bit vim and python.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;TL;DR&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The problem has nothing to do with YouCompleteMe in my case. Suppose YCM is complied with python 3. &lt;strong&gt;To make python27 completely invisible to VIM&lt;/strong&gt; is what helps me solve the problem. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I had installed &lt;code&gt;TortoiseHg&lt;/code&gt; which has a python27.dll file and whose repository is in &lt;code&gt;Path&lt;/code&gt;, which means it is visible to vim. To make it invisible, simply remove TortoiseHg repository from &lt;code&gt;Path&lt;/code&gt; ( More generally, any non-python program which contains a python27.dll and whose path is in &lt;code&gt;Path&lt;/code&gt;. By doing &lt;code&gt;where python27.dll&lt;/code&gt; in windows console, you find all of them.) &lt;/li&gt;&#xA;&lt;li&gt;Another python27.dll in &lt;code&gt;C:\Windows\System32&lt;/code&gt; is also visible to vim. To make it also invisible, Move it to &lt;code&gt;C:\Python27&lt;/code&gt;. And remove &lt;code&gt;C:\Python27&lt;/code&gt; from &lt;code&gt;Path&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;li&gt;Leave &lt;code&gt;%PYTHONPATH%&lt;/code&gt; unset. Make sure Python 3.5 repository is in the &lt;code&gt;Path&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;My system&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Win 10 pro 64 bit.&lt;/li&gt;&#xA;&lt;li&gt;Vim 8.0.0045 64 bit huge features (+dyn/python +dyn/python3)&#xA;downloaded from &lt;a href=&quot;https://github.com/vim/vim-win32-installer/releases&quot; rel=&quot;nofollow noreferrer&quot;&gt;nightly vim windows build&lt;/a&gt; site.&lt;/li&gt;&#xA;&lt;li&gt;YouCompleteMe complied with python 3.5.2 64 bit&lt;/li&gt;&#xA;&lt;li&gt;Python 3.5.2 64 bit&lt;/li&gt;&#xA;&lt;li&gt;Python 2.7.12 64 bit&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%PYTHONHOME%&lt;/code&gt; is set to python 3 installation folder and included in&#xA;&lt;code&gt;Path&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;My problem&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Errors are detected when vim is launched as shown below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FWGVg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FWGVg.png&quot; alt=&quot;Vim launch errors&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Messages are&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function youcompleteme#Enable[5]..&amp;lt;SNR&amp;gt;124_SetUpPython:&#xA;line 39:&#xA;E887: Sorry, this command is disabled, the Python's site module could not be loaded.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Diagnostics&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Both &lt;code&gt;:echo has('python')&lt;/code&gt; and &lt;code&gt;:echo has('python3')&lt;/code&gt; output 1. But when I do &lt;code&gt;:py print 'test'&lt;/code&gt;, vim gives me the same E887 error message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I completely uninstall Python 2.7.12, but &lt;code&gt;:echo has('python')&lt;/code&gt; still outputs 1 and &lt;code&gt;:py print 'test'&lt;/code&gt; still gives E887 Error! Meanwhile &lt;code&gt;:py3 print('test')&lt;/code&gt; works always OK and output &lt;em&gt;test&lt;/em&gt; as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To ensure it is not a problem from YouCompleteMe, I launched vim by &lt;code&gt;gvim -u NONE&lt;/code&gt;. The print test gives the same error message. So problem is from vim itself, which it fails to do the staff related to python 2.7.x site module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some people suggest installing Python 2.7.9, but it doesn't work for me. Maybe this solution only works for 32 bit python 2.7. I didn't test so I cannot confirm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why all these happen:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First, by doing &lt;code&gt;where python27.dll&lt;/code&gt; I found under TortoiseHG&#xA;repository there is another python27.dll file. That is why &lt;code&gt;:echo has('python')&lt;/code&gt; still outputs 1 after I uninstalled Python 2.7.12.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then, to put it simple, the command &lt;code&gt;:has('python')&lt;/code&gt; output 1 if both of&#xA;the conditions are met:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Vim is compiled with +dyn/python feature (respectively +dyn/python3 when doing &lt;code&gt;:has('python3')&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The python27.dll file is found in your Path. (respectively python35.dll. see &lt;code&gt;:help-python-dynamic&lt;/code&gt; and &lt;code&gt;:help has-python&lt;/code&gt; for more information.) But it &lt;strong&gt;doesn't do further check&lt;/strong&gt;; that is why &lt;code&gt;has-python&lt;/code&gt; check gives 1 but still errors are detected.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Python 2.7.12 doesn't automatically set &lt;code&gt;%PYTHONPATH%&lt;/code&gt;, while Python&#xA;3.5.2 set this value to &lt;code&gt;&amp;lt;where_python_found&amp;gt;\Lib&lt;/code&gt; and&#xA;&lt;code&gt;&amp;lt;where_python_found&amp;gt;\Lib\site-packages&lt;/code&gt;at Windows starup if it find python executable in &lt;code&gt;Path&lt;/code&gt;. In my case where only python 3.5.2 installed and TortoiseHg's python27.dll is found by vim, When I run &lt;code&gt;:py print 'test'&lt;/code&gt;, vim will seek python 2.7 site module but in Python 3.5's &lt;code&gt;%PYTHONPATH%&lt;/code&gt;. That's why Error E887 are thrown. Consequently, if we set &lt;code&gt;%PYTHONPATH%&lt;/code&gt; explicitely to point to python 2.7, The E887 error will &lt;strong&gt;&lt;em&gt;DISAPPEAR&lt;/em&gt;&lt;/strong&gt;!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;Solution&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;See beginning TL:DR part.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Conclusion&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You once had both version of python and you uninstall one. You may happily think it's clean but vim tell you he finds the python you have deleted, you are astonished and me too. That is because often there is still some mysterious python dll left in your system and unfortunately can be detected by vim. So, Whether you conserve another version of python on your hard drive or not, make sure it is completely invisible to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fact that both version of python can be invoked by the same instance vim at run time is just all right. The real problem is both version of python shares &lt;strong&gt;ONE&lt;/strong&gt; &lt;code&gt;PYTHONPATH&lt;/code&gt;. If &lt;code&gt;PYTHONPATH&lt;/code&gt; does not match python version, python fails to find the right site-package and make vim complain. This makes most of us think it is a vim problem. But NO.&lt;/p&gt;&#xA;" OwnerUserId="9819" LastEditorUserId="9819" LastEditDate="2017-03-19T14:29:05.197" LastActivityDate="2017-03-19T14:29:05.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10013" PostTypeId="2" ParentId="10007" CreationDate="2016-10-23T02:55:17.503" Score="12" Body="&lt;p&gt;As noted, &lt;a href=&quot;https://github.com/scrooloose/syntastic#faqargs&quot; rel=&quot;noreferrer&quot;&gt;the FAQ says&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;4.5. Q. How can I pass additional arguments to a checker?&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A. In most cases a command line is constructed using an internal&#xA;  function named &lt;code&gt;makeprgBuild()&lt;/code&gt;, which provides a number of options&#xA;  that allow you to customise every part of the command that gets run.&#xA;  You can set these options using global variables.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The general form of the global &lt;code&gt;args&lt;/code&gt; variable is&#xA;  &lt;code&gt;syntastic_&amp;lt;filetype&amp;gt;_&amp;lt;checker&amp;gt;_args&lt;/code&gt;. Thus if you wanted to pass&#xA;  &lt;code&gt;--my --args --here&lt;/code&gt; to the Ruby &lt;code&gt;mri&lt;/code&gt; checker you would add this line&#xA;  to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_ruby_mri_args = &quot;--my --args --here&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;See &lt;code&gt;:help syntastic-checker-options&lt;/code&gt; for more information.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, I'd expect something like this to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_sh_shellcheck_args = &quot;-x&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-10-23T02:55:17.503" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10014" PostTypeId="1" CreationDate="2016-10-23T11:06:48.810" Score="4" ViewCount="926" Body="&lt;p&gt;What I expect from &quot;tab-tag&quot; navigation is the following behaviour: when need to jump to a tag:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if the corresponding file is already opened in a window, navigate to it&lt;/li&gt;&#xA;&lt;li&gt;if it is not, open the buffer in a new tab&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is the behaviour of this command I like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tab drop file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it is &lt;em&gt;not&lt;/em&gt; the behaviour of &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How may I get this navigation style?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I am aware that there already are &lt;a href=&quot;https://stackoverflow.com/questions/908269&quot;&gt;plenty&lt;/a&gt; of &lt;a href=&quot;https://stackoverflow.com/q/53y9231/3719101&quot;&gt;related&lt;/a&gt; &lt;a href=&quot;https://stackoverflow.com/q/6069279/3719101&quot;&gt;questions&lt;/a&gt; on the &lt;a href=&quot;https://stackoverflow.com/q/6536049/3719101&quot;&gt;topic&lt;/a&gt;, none of which provides the exact behaviour I am looking for.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is now the object of a &lt;a href=&quot;https://github.com/vim/vim/issues/1292&quot; rel=&quot;nofollow noreferrer&quot;&gt;feature request&lt;/a&gt; to vim, unless I have been missing something :\&lt;/p&gt;&#xA;" OwnerUserId="2978" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-11-30T16:41:41.180" Title="Navigate to tag in a new tab if not already opened, like `tab drop`?" Tags="|tabbed-user-interface|tags|navigation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10016" PostTypeId="1" CreationDate="2016-10-23T19:36:20.490" Score="10" ViewCount="1817" Body="&lt;p&gt;I use both &lt;code&gt;CtrlP&lt;/code&gt; and &lt;code&gt;NERDTree&lt;/code&gt; in my Vim. When I open a file using the &lt;code&gt;CtrlP&lt;/code&gt; search feature, it sometimes opens in the NERDTree window (and always if the NERD window is the active one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I stop &lt;code&gt;CtrlP&lt;/code&gt; from opening files in NERDTree, and force it to open them in the main window?&lt;/strong&gt; I've tried going through the &lt;code&gt;CtrlP&lt;/code&gt; docs in Vim, but couldn't figure out a way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are all the NERDTree and CtrlP related configs in my &lt;a href=&quot;https://github.com/sheharyarn/dotfiles/blob/master/Vim/.vimrc&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;.vimrc&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_liststyle    = 3&#xA;let NERDTreeShowHidden   = 1&#xA;let g:ctrlp_user_command = ['.git', 'cd %s &amp;amp;&amp;amp; git ls-files -co --exclude-standard']&#xA;&#xA;command E Ex&#xA;&#xA;map &amp;lt;C-t&amp;gt; :NERDTreeTabsToggle&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;Leader&amp;gt;r :NERDTreeFocus&amp;lt;cr&amp;gt;R&amp;lt;c-w&amp;gt;&amp;lt;c-p&amp;gt;:CtrlPClearCache&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="969" LastEditorUserId="969" LastEditDate="2017-01-06T09:53:35.067" LastActivityDate="2018-01-13T15:21:32.363" Title="Stop CtrlP from opening in NERDTree" Tags="|vim-windows|plugin-nerdtree|plugin-ctrlp|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10017" PostTypeId="1" CreationDate="2016-10-23T19:38:42.850" Score="2" ViewCount="1405" Body="&lt;p&gt;I have my &lt;code&gt;.vimrc&lt;/code&gt; as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible &#xA;filetype off&#xA;&#xA;syntax on&#xA;set nu&#xA;&#xA;&amp;quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&amp;quot; let Vundle manage Vundle, required&#xA;Plugin 'gmarik/Vundle.vim'&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;&#xA;&amp;quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &amp;quot; required&#xA;filetype plugin indent on    &amp;quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I want to select an AirlineTheme e.g.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:AirlineTheme molokai&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Unfortunately the theme is not applied and vim editor stays visually the same with no change. I use Ubuntu 14.04. I wonder what's wrong. Somehow GNOME terminal should be set prior to vim being used?&lt;/p&gt;&#xA;&lt;p&gt;Note:&#xA;VIM&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;r59400@Latitude:~$ vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:39:32)&#xA;Included patches: 1-52&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by buildd@&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;-clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   -perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python          +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            -ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            +mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Terminal&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;GNOME Terminal 3.6.2&#xA;A terminal emulator for the GNOME desktop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9564" LastEditorUserId="5298" LastEditDate="2020-07-04T16:10:13.380" LastActivityDate="2020-07-04T16:10:13.380" Title="vim-arline-themes can't set theme" Tags="|vimrc|plugin-airline|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10018" PostTypeId="2" ParentId="10017" CreationDate="2016-10-23T20:01:51.817" Score="1" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;I want to set AirlineTheme e.g.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:ArlineTheme molokai&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Seems you made a mistake, shouldn't it be &lt;code&gt;:AirlineTheme molokai&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also try setting it in vimrc and see if the problem persists. To set it in your .vimrc, use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_theme='&amp;lt;theme&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_theme='simple'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9004" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-10-24T08:15:15.977" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="10020" PostTypeId="1" AcceptedAnswerId="10021" CreationDate="2016-10-24T08:28:10.087" Score="1" ViewCount="2990" Body="&lt;p&gt;I'm trying to make a colorscheme configurable where I define the style in a variable defined in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:plugin_style='&amp;lt;vim-highlighting-style&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in the colorscheme I'm doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight! StyleName g:plugin_style&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't work, &lt;code&gt;hightlight!&lt;/code&gt; uses the literal &lt;code&gt;g:plugin_style&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried as well to use exec&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec 'highlight! StyleName ' . g:plugin_style&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't work neither, StyleName is not known afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to do this in vimscript?&lt;/p&gt;&#xA;" OwnerUserId="1542" LastEditorUserId="1841" LastEditDate="2016-10-24T09:04:58.263" LastActivityDate="2016-10-24T09:04:58.263" Title="How to use a variable value in a colorscheme" Tags="|colorscheme|highlight|variables|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10021" PostTypeId="2" ParentId="10020" CreationDate="2016-10-24T08:51:18.797" Score="2" Body="&lt;p&gt;As @Jamessan suggested in this &lt;a href=&quot;https://stackoverflow.com/a/2211738/4194289&quot;&gt;SO answer&lt;/a&gt;, using &lt;code&gt;execute&lt;/code&gt; should work properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firs the variable should be defined like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:plugin_style='term=bold ctermfg=Cyan guifg=#80a0ff gui=bold'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#highlight%2Dargs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h highlight-args&lt;/code&gt;&lt;/a&gt; for the values that this variable can take.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then simply use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'highlight [default] {group-name} ' . g:plugin_style&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally an important note is to define the variable before you call your colorscheme otherwise the colorscheme cannot know the value of the variable.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-10-24T08:51:18.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10022" PostTypeId="1" CreationDate="2016-10-24T13:09:54.710" Score="0" ViewCount="1831" Body="&lt;p&gt;I have an xml file with some text which is so long, that it does not fit into the normal line of my editor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an xml-specific way to insert a newline just for formatting, i.e. ignored by a correct xml parser? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="9835" LastEditorUserId="1841" LastEditDate="2016-10-24T13:21:08.993" LastActivityDate="2016-10-24T13:22:45.597" Title="How to break long line of xml files only on display not in the actual code" Tags="|formatting|wrapping|" AnswerCount="1" CommentCount="2" ClosedDate="2016-10-26T01:57:19.053" ContentLicense="CC BY-SA 3.0" />
  <row Id="10023" PostTypeId="2" ParentId="10022" CreationDate="2016-10-24T13:18:49.780" Score="4" Body="&lt;p&gt;You're looking for &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27wrap%27&quot;&gt;&lt;code&gt;:h 'wrap'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This option changes how text is displayed.  It doesn't change the text&#xA;  in the buffer, see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27textwidth%27&quot;&gt;'textwidth'&lt;/a&gt; for that.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When on, lines longer than the width of the window will wrap and&#xA;  displaying continues on the next line.  When off lines will not wrap&#xA;  and only part of long lines will be displayed.  When the cursor is&#xA;  moved to a part that is not shown, the screen will scroll&#xA;  horizontally.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Simply add this line to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wrap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or to use wrap only on xml buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocommand FileType xml setlocal wrap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%3Asetlocal&quot;&gt;&lt;code&gt;:h :setlocal&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-10-24T13:22:45.597" LastActivityDate="2016-10-24T13:22:45.597" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10025" PostTypeId="1" CreationDate="2016-10-24T17:14:00.503" Score="5" ViewCount="2557" Body="&lt;p&gt;I'm a longtime user of vim on Archlinux. I've been away from this system for a few months, so I can't be sure when this started (but I've made updates during this time, too).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every time I open the app, I get an error about the spelling file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim&#xA;Warning: Cannot find word list &quot;en.utf-8.spl&quot; or &quot;en.ascii.spl&quot;&#xA;Warning: Cannot find word list &quot;en.utf-8.spl&quot; or &quot;en.ascii.spl&quot;&#xA;Warning: Cannot find word list &quot;en.utf-8.spl&quot; or &quot;en.ascii.spl&quot;&#xA;Press ENTER or type command to continue&#xA;&#xA;$ vim --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 15 2016 10:11:05)&#xA;Included patches: 1-5&#xA;Compiled by Arch Linux&#xA;&#xA;$ sudo pacman -Ss vim | grep installed&#xA;extra/vim 8.0.0005-1 [installed]&#xA;extra/vim-runtime 8.0.0005-1 [installed]&#xA;community/ranger 1.7.2-1 [installed]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I reinstalled the app, but the problem persists. &#xA;The problem is for all users.&lt;/p&gt;&#xA;" OwnerUserId="1694" LastEditorUserId="1694" LastEditDate="2016-10-24T17:31:05.107" LastActivityDate="2017-11-15T13:06:45.230" Title="Error: &quot;Warning: Cannot find word list&quot; - Is this a user or package error?" Tags="|spell-checking|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10026" PostTypeId="1" AcceptedAnswerId="10042" CreationDate="2016-10-24T17:29:52.390" Score="3" ViewCount="87" Body="&lt;p&gt;I am running Windows 7 Professional.  I have used the context menu for each of several file types to specify vim in the &quot;open with&quot; field.  There are times I want to open the selected file with vim and times I want to open it with gvim.  So I have both vim and gvim in the context menu when I right-click a file.  The problem is that both vim and gvim have the same icon and the same program description -- &quot;Vi Improved - A Text Editor&quot;, so they are indistinguishable in the list of programs from which to choose in the &quot;open with&quot; field.  And whichever one I last used is the one that appears first, so I can't just select based on their relative position in the list.  Is there a way that I can edit the description on each executable to make it distinct?&lt;/p&gt;&#xA;" OwnerUserId="9769" LastActivityDate="2016-10-25T15:49:58.147" Title="Can the vim program description be modified?" Tags="|microsoft-windows|" AnswerCount="1" CommentCount="1" ClosedDate="2016-11-01T00:55:59.703" ContentLicense="CC BY-SA 3.0" />
  <row Id="10028" PostTypeId="1" CreationDate="2016-10-25T02:37:30.423" Score="5" ViewCount="1936" Body="&lt;p&gt;I'm switching from &lt;code&gt;vim&lt;/code&gt; to &lt;code&gt;neovim&lt;/code&gt;, but when starting &lt;code&gt;neovim&lt;/code&gt;, I get the following error on startup:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What does this mean, and how do I stop &lt;code&gt;neovim&lt;/code&gt; complaining about it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I want to be able to use both &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;neovim&lt;/code&gt; with the same &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5324" LastActivityDate="2024-02-03T11:04:14.020" Title="E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3" Tags="|neovim|startup|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10029" PostTypeId="2" ParentId="10028" CreationDate="2016-10-25T02:37:30.423" Score="7" Body="&lt;p&gt;TL;DR: skip to the &lt;code&gt;Resolution&lt;/code&gt; section.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Background&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The issue is that &lt;code&gt;neovim&lt;/code&gt; can't read/write &lt;code&gt;vim&lt;/code&gt;'s &lt;code&gt;viminfo&lt;/code&gt; file format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using &lt;code&gt;vim&lt;/code&gt;'s&lt;code&gt;viminfo&lt;/code&gt; format for storing editing session information, &lt;code&gt;neovim&lt;/code&gt; uses a &lt;a href=&quot;https://neovim.io/doc/user/starting.html#shada-file&quot; rel=&quot;noreferrer&quot;&gt;shada-file&lt;/a&gt; for &quot;SHAred DAta&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default &lt;a href=&quot;https://neovim.io/doc/user/starting.html#shada-file-name&quot; rel=&quot;noreferrer&quot;&gt;shada file name&lt;/a&gt; is &lt;code&gt;$XDG_DATA_HOME/nvim/shada/main.shada&lt;/code&gt;, and &lt;code&gt;$XDG_DATA_HOME&lt;/code&gt; is &lt;code&gt;~/.local/share&lt;/code&gt; by &lt;a href=&quot;https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html&quot; rel=&quot;noreferrer&quot;&gt;XDG default&lt;/a&gt;, giving a default &lt;code&gt;shada&lt;/code&gt; file named:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.local/share/nvim/shada/main.shada&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Cause&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;neovim&lt;/code&gt;, &lt;code&gt;&amp;amp;viminfo&lt;/code&gt; is a deprecated alias to the &lt;a href=&quot;https://neovim.io/doc/user/options.html#&amp;#39;shada&amp;#39;&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'shada'&lt;/code&gt;&lt;/a&gt; option, which configures the &lt;a href=&quot;https://neovim.io/doc/user/starting.html#shada-file&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;shada-file&lt;/code&gt;&lt;/a&gt;'s location and usage. This means that &lt;code&gt;neovim&lt;/code&gt; will look at the &lt;code&gt;viminfo&lt;/code&gt; variable for information about &lt;code&gt;shada&lt;/code&gt; data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is generally fine - it's good for backward compatibility to store/recover the same information that &lt;code&gt;vim&lt;/code&gt; would... except in the case where a file name is specified - a file which will probably contain &lt;code&gt;viminfo&lt;/code&gt; data, not &lt;code&gt;shada&lt;/code&gt; data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The culprit is your &lt;code&gt;viminfo&lt;/code&gt; variable (or possibly your &lt;code&gt;shada&lt;/code&gt; variable), where you've explicitly set a filename to be used for the &lt;code&gt;viminfo&lt;/code&gt; (or &lt;code&gt;shada&lt;/code&gt;) file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This file that you are referencing is in &lt;code&gt;viminfo&lt;/code&gt; format, not &lt;code&gt;shada&lt;/code&gt; format. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set viminfo?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;viminfo=!,'100,&amp;lt;50,s10,h,n~/vim/viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;vimrc&lt;/code&gt;, you probably have a line like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viminfo+=n~/vim/viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;n&amp;lt;name&amp;gt;&lt;/code&gt; sets the file to be &lt;code&gt;&amp;lt;name&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is that the file named &lt;code&gt;&amp;lt;name&amp;gt;&lt;/code&gt; contains data in &lt;code&gt;viminfo&lt;/code&gt; format.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Resolution&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can either:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Remove the line which explicitly sets the &lt;code&gt;viminfo&lt;/code&gt; file name, in which case:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vim&lt;/code&gt; will use &lt;code&gt;~/.viminfo&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;neovim&lt;/code&gt; will use &lt;code&gt;$XDG_DATA_HOME/nvim/shada/main.shada&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Keep the existing file name when running &lt;code&gt;vim&lt;/code&gt;, and use another when using &lt;code&gt;neovim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !has('nvim')&#xA;  set viminfo+=n~/vim/viminfo&#xA;else&#xA;  &quot; Do nothing here to use the neovim default&#xA;  &quot; or do soemething like:&#xA;  &quot; set viminfo+=n~/.shada&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2016-10-25T05:37:40.057" LastActivityDate="2016-10-25T05:37:40.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10030" PostTypeId="1" AcceptedAnswerId="10034" CreationDate="2016-10-25T05:48:54.600" Score="0" ViewCount="204" Body="&lt;p&gt;I believe that I once saw a plugin which allowed one to see the result of evaluating ruby expressions inside a buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eg, if I wrote a line like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3 + 2 # =&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and pressed the required magic keys, the line would change to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 3 + 2 # =&amp;gt; 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know that there are way to invoke &lt;code&gt;vim&lt;/code&gt; from &lt;code&gt;irb&lt;/code&gt;, but what I'm after is more like invoking &lt;code&gt;irb&lt;/code&gt; from inside &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find that plugin now - does such a thing indeed exist?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2016-10-25T09:16:37.663" LastActivityDate="2016-10-25T09:16:37.663" Title="How to evaluate a ruby expression in a buffer" Tags="|filetype-ruby|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10031" PostTypeId="1" AcceptedAnswerId="10033" CreationDate="2016-10-25T06:32:14.857" Score="24" ViewCount="14569" Body="&lt;p&gt;I often find scrolling a full page too disorienting, half a page too much, but a quarter page is just right. I currently do it just by holding down the arrow keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I scroll 25% of the page down and up easily?&lt;/p&gt;&#xA;" OwnerUserId="9536" LastEditorUserId="1841" LastEditDate="2016-10-25T09:36:56.560" LastActivityDate="2021-09-29T20:21:28.813" Title="Scroll a quarter (25%) of the screen up or down" Tags="|cursor-movement|scrolling|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10032" PostTypeId="2" ParentId="10031" CreationDate="2016-10-25T07:28:07.280" Score="6" Body="&lt;p&gt;You can use &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt; and &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt; to move the page by one line up and down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then if you want for +/- 25% to be moved you can use &lt;kbd&gt;20&lt;/kbd&gt;&lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt; and that will move you 20 lines down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is also a good explained question that is similiar to yours: &lt;a href=&quot;https://stackoverflow.com/questions/3458689/how-to-move-screen-without-moving-cursor-in-vim&quot;&gt;https://stackoverflow.com/questions/3458689/how-to-move-screen-without-moving-cursor-in-vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9294" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-10-25T07:58:04.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10033" PostTypeId="2" ParentId="10031" CreationDate="2016-10-25T08:09:56.853" Score="32" Body="&lt;p&gt;Maybe &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; and &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;u&lt;/kbd&gt; could be what you are looking for. By default they move half of the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/scroll.txt.html#CTRL%2DD&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h CTRL-D&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Scroll window Downwards in the buffer.  The number of&#xA;  lines comes from the 'scroll' option (default: half a&#xA;  screen).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If [count] given, first set 'scroll' option&#xA;  to [count].&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which means that the first time you want to scroll in a window you can do &lt;kbd&gt;XX&lt;/kbd&gt;&lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; where XX is the 25% of the number of lines in your window. As it sets &lt;code&gt;scroll&lt;/code&gt; to the XX value you can then use &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; and &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;u&lt;/kbd&gt; to move 25% of the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I think that &lt;a href=&quot;http://vimhelp.appspot.com/scroll.txt.html#scrolling&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h scrolling&lt;/code&gt;&lt;/a&gt; might be interesting for you.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is another solution with a function and some mappings to add to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ScrollQuarter(move)&#xA;    let height=winheight(0)&#xA;&#xA;    if a:move == 'up'&#xA;        let key=&quot;\&amp;lt;C-Y&amp;gt;&quot;&#xA;    else&#xA;        let key=&quot;\&amp;lt;C-E&amp;gt;&quot;&#xA;    endif&#xA;&#xA;    execute 'normal! ' . height/4 . key&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;up&amp;gt; :call ScrollQuarter('up')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;down&amp;gt; :call ScrollQuarter('down')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function will get the height of the current window, and accordingly to its parameter will scroll the screen up or down of a quarter of the height.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mappings will call the function, the first one to go up and the second one to go down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you can change &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;down&amp;gt;&lt;/code&gt; to some other keys if you want to keep the default behavior of your arrow keys.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-05-22T08:33:03.237" LastActivityDate="2018-05-22T08:33:03.237" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="10034" PostTypeId="2" ParentId="10030" CreationDate="2016-10-25T09:11:58.637" Score="3" Body="&lt;p&gt;There are actually several way to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first google result is the &lt;a href=&quot;https://github.com/kmdsbng/vim-ruby-eval&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-ruby-eval plugin&lt;/a&gt; which provides the &lt;code&gt;:RubyEval&lt;/code&gt; command. Here is a screen cast coming from the README page of the plugin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xk8in.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xk8in.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin requires &lt;code&gt;+ruby&lt;/code&gt; (&lt;code&gt;:echo has('ruby')&lt;/code&gt; should return &lt;code&gt;1&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also do this with the &lt;code&gt;xmpfilter&lt;/code&gt; command provided by the &lt;a href=&quot;https://github.com/rcodetools/rcodetools&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;rcodetools&lt;/code&gt;&lt;/a&gt; ruby gem. As &lt;a href=&quot;http://commandercoriander.net/blog/2012/10/10/evaluate-lines-of-ruby-in-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this blog post&lt;/a&gt; says, there is a vim plugin for &lt;code&gt;xpmfilter&lt;/code&gt;: &lt;a href=&quot;https://github.com/t9md/vim-ruby-xmpfilter&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-ruby-xmpfilter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the plugin doesn't provide default mappings you'll have to set them by yourself but the README as a good amount of example to help you.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-10-25T09:11:58.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10035" PostTypeId="1" AcceptedAnswerId="10039" CreationDate="2016-10-25T09:39:05.137" Score="17" ViewCount="12512" Body="&lt;p&gt;I have several &lt;code&gt;highlight&lt;/code&gt; commands in my &lt;code&gt;.vimrc&lt;/code&gt; file. In Vim 7.3, these took effect immediately after Vim had started. After updating to Vim 7.4, this is not the case anymore. Vim uses its default highlighting initially. When I load &lt;code&gt;.vimrc&lt;/code&gt; a second time by executing &lt;code&gt;source ~/.vimrc&lt;/code&gt;, highlighting works as I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be able to reproduce this problem using the following steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Make a copy of your &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Replace &lt;code&gt;~/.vimrc&lt;/code&gt; with a file that contains just the line &lt;code&gt;highlight Type ctermfg=28 cterm=bold&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run &lt;code&gt;vim dummy.c&lt;/code&gt; in a 256 color terminal (for example GNOME Terminal).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Type &lt;code&gt;int&lt;/code&gt; into the buffer. The &lt;code&gt;int&lt;/code&gt; should appear in regular font and be colored light green, which is not what I want.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Enter &lt;code&gt;:source ~/.vimrc&lt;/code&gt;. Now the &lt;code&gt;int&lt;/code&gt; should appear in bold font and be colored dark green.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;According to the article &lt;a href=&quot;http://alvinalexander.com/linux/vi-vim-editor-color-scheme-syntax&quot; rel=&quot;noreferrer&quot; title=&quot;How to control/configure vim colors&quot;&gt;&lt;em&gt;How to control/configure vim colors&lt;/em&gt;&lt;/a&gt;, it should be okay to just put the &lt;code&gt;highlight&lt;/code&gt; commands into &lt;code&gt;.vimrc&lt;/code&gt;. The article says that you should put &lt;code&gt;syntax enable&lt;/code&gt; after the &lt;code&gt;highlight&lt;/code&gt; commands, but this did not make any difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first fix was to prepend each &lt;code&gt;highlight&lt;/code&gt; command in &lt;code&gt;.vimrc&lt;/code&gt; with &lt;code&gt;autocmd VimEnter *&lt;/code&gt;. This worked for some file types, but not for others (C files are an example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the reason for this behavior? How can I have the &lt;code&gt;highlight&lt;/code&gt; commands executed when Vim is started such that they take effect for all buffers during the whole Vim session?&lt;/p&gt;&#xA;" OwnerUserId="9846" LastEditorUserId="9846" LastEditDate="2016-10-25T10:38:33.117" LastActivityDate="2023-01-07T08:19:31.747" Title="How can I make highlighting commands in .vimrc take effect immediately with Vim 7.4?" Tags="|vimrc|syntax-highlighting|filetype|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10036" PostTypeId="2" ParentId="10035" CreationDate="2016-10-25T09:49:49.457" Score="4" Body="&lt;p&gt;Actually you shouldn't put your custom highlights in your vimrc but in customs syntax files.&lt;/p&gt;&#xA;&lt;p&gt;These files should be located in &lt;code&gt;~/.vim/after/syntax/filetype.vim&lt;/code&gt; where &lt;code&gt;filetype&lt;/code&gt; is the expected filetype. If you are mostly satisfied with a syntax file but would like to add a few command you can follow these steps (taken from &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#mysyntaxfile%2Dadd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h mysyntaxfile-add&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Create a directory in there called &amp;quot;after/syntax&amp;quot;.  For Unix:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; mkdir ~/.vim/after&#xA; mkdir ~/.vim/after/syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Write a Vim script that contains the commands you want to use.  For&#xA;example, to change the colors for the C syntax:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; highlight cComment ctermfg=Green guifg=Green&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Write that file in the &amp;quot;after/syntax&amp;quot; directory.  Use the name of the&#xA;syntax, with &amp;quot;.vim&amp;quot; added.  For our C syntax:&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;    :w ~/.vim/after/syntax/c.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;That's it.  The next time you edit a C file the Comment color will be&#xA;different.  You don't even have to restart Vim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#mysyntaxfile&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h mysyntaxfile&lt;/code&gt;&lt;/a&gt; is a good place to get information about how to right your own syntax files. Also &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/45.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript The Hard Way&lt;/a&gt; has several chapters on this topic.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="6498" LastEditDate="2023-01-07T08:19:31.747" LastActivityDate="2023-01-07T08:19:31.747" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10037" PostTypeId="1" AcceptedAnswerId="10038" CreationDate="2016-10-25T10:19:43.583" Score="6" ViewCount="1222" Body="&lt;p&gt;This is a small thing, but it still annoys me. When I select at least 3 lines with &lt;code&gt;V&lt;/code&gt;isual line mode, and then &lt;code&gt;y&lt;/code&gt;ank them, I get a confirmation: n lines yanked appears at the bottom of my screen. However, if I yank just 1 or 2 lines, no such thing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same thing happens with &lt;code&gt;v&lt;/code&gt; and &lt;code&gt;Ctrl-v&lt;/code&gt;, or something lie &lt;code&gt;y}&lt;/code&gt; where these confirmations only appear if the selection is spread over at least 3 lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to turn on these confirmations, now matter how much I yank?&lt;/p&gt;&#xA;" OwnerUserId="9848" LastActivityDate="2016-10-25T11:45:21.697" Title="Get 2 lines yanked or 1 line yanked confirmation" Tags="|cut-copy-paste|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10038" PostTypeId="2" ParentId="10037" CreationDate="2016-10-25T10:24:59.930" Score="9" Body="&lt;p&gt;You are looking for the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27report%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'report'&lt;/code&gt;&lt;/a&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'report'        number  (default 2)&#xA;            global&#xA;    Threshold for reporting number of lines changed.  When the number of&#xA;    changed lines is more than 'report' a message will be given for most&#xA;    &quot;:&quot; commands.  If you want it always, set 'report' to 0.&#xA;    For the &quot;:substitute&quot; command the number of substitutions is used&#xA;    instead of the number of lines.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should solve your issue: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set report=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe there is no built-in option to issue messages for changes smaller than a line -- you could check the documentation or use the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#:options&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:options&lt;/code&gt; command&lt;/a&gt; (specially the &quot;messages and info&quot; section). Maybe issuing a message for every change would be distracting for most people.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will probably need to overwrite the &lt;code&gt;y&lt;/code&gt; operator to include your custom messages, similar &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#:map-operator&quot; rel=&quot;noreferrer&quot;&gt;to the example at &lt;code&gt;:help :map-operator&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-10-25T11:45:21.697" LastActivityDate="2016-10-25T11:45:21.697" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10039" PostTypeId="2" ParentId="10035" CreationDate="2016-10-25T12:14:20.530" Score="8" Body="&lt;p&gt;This is no definite answer and your problem sounds like issue &lt;a href=&quot;https://github.com/vim/vim/issues/542&quot; rel=&quot;noreferrer&quot;&gt;542&lt;/a&gt;. Apparently you can work around it, by writing your own basic colorscheme, instead of writing those &lt;code&gt;hi ...&lt;/code&gt; statements directly into your .vimrc.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-10-25T12:14:20.530" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10040" PostTypeId="1" CreationDate="2016-10-25T14:28:48.517" Score="2" ViewCount="816" Body="&lt;p&gt;I am using the &lt;a href=&quot;https://github.com/ntpeters/vim-better-whitespace&quot; rel=&quot;nofollow&quot;&gt;vim-better-whitespace plugin&lt;/a&gt; to highlight trailing whitespaces. For some buffers, I don't want this behavior and vim-better-whitespace usually provides an option to list the filetypes where it shouldn't apply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am also using &lt;a href=&quot;https://github.com/bfredl/nvim-ipy&quot; rel=&quot;nofollow&quot;&gt;nvim-ipy&lt;/a&gt; to integrate with ipython and this plugin opens a new buffer for console output, where &lt;code&gt;filetype&lt;/code&gt; is empty and &lt;code&gt;buftype&lt;/code&gt; is set to &lt;code&gt;nofile&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to construct an &lt;code&gt;autocmd&lt;/code&gt; to call &lt;code&gt;DisableWhitespace&lt;/code&gt; once the respective ipython buffer is created?&lt;/p&gt;&#xA;" OwnerUserId="8891" LastEditorUserId="1841" LastEditDate="2016-10-25T15:04:37.850" LastActivityDate="2017-11-30T03:56:49.243" Title="Disable vim-better-whitespace highlighting for nvim-ipy buffer" Tags="|neovim|whitespace|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10041" PostTypeId="2" ParentId="3576" CreationDate="2016-10-25T14:57:23.683" Score="12" Body="&lt;h2&gt;Main Issue&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The main problem you are experiencing is caused by the ordering of the&#xA;commands in your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You set the &lt;code&gt;g:impact_transbg&lt;/code&gt; variable &lt;em&gt;after&lt;/em&gt; you load the colorscheme, and&#xA;so the variable does &lt;em&gt;not&lt;/em&gt; exist when checked by the colorscheme's &lt;code&gt;if&lt;/code&gt; statement, and&#xA;the second version of the colorscheme (in the &lt;code&gt;else&lt;/code&gt; block) is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix, you simply need to move the line that sets the variable above the line&#xA;where you load the colorscheme:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:impact_transbg=1&#xA;colorscheme impact3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can (and should!) then remove the unnecessary lines from your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set term=xterm&#xA;set background=dark&#xA;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Other Issues&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I can also clear up a few other misconceptions/confusions you might have about&#xA;how this all works:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Explaining the behaviour of &lt;code&gt;'term'&lt;/code&gt; &amp;amp; &lt;code&gt;'t_Co'&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Your $TERM is set to &lt;code&gt;xterm256-color&lt;/code&gt;. Vim reads this, and queries terminfo (or&#xA;termcap) to find out how many colours the terminal supports, and then sets&#xA;&lt;code&gt;'t_Co'&lt;/code&gt; accordingly. Presuming your $TERM is correct (yours is) and your&#xA;terminfo database contains the correct information for that terminal (yours&#xA;does) you should &lt;em&gt;never&lt;/em&gt; need to manually reset &lt;code&gt;'t_Co'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you are then manually setting Vim's &lt;code&gt;'term'&lt;/code&gt; to xterm. Your terminfo tells&#xA;Vim that this terminal only supports 8 colours, so adding this will cause&#xA;&lt;code&gt;'t_Co'&lt;/code&gt; to be incorrectly set to 8. You are manually setting &lt;code&gt;'t_Co'&lt;/code&gt; &lt;em&gt;back&lt;/em&gt; to&#xA;256, but if you had left the &lt;code&gt;'term'&lt;/code&gt; setting at the correct value, you would&#xA;not have needed to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally, when you change &lt;code&gt;'t_Co'&lt;/code&gt; manually after setting &lt;code&gt;g:impact_transbg&lt;/code&gt;, it&#xA;causes the colorscheme to be reloaded (to allow the colorscheme to adapt to the&#xA;new number of colours), and because &lt;code&gt;g:impact_transbg&lt;/code&gt; &lt;em&gt;is&lt;/em&gt; now set, you get the&#xA;colours you desire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(With the line setting &lt;code&gt;'term'&lt;/code&gt; omitted, &lt;code&gt;'t_Co'&lt;/code&gt; is &lt;em&gt;already&lt;/em&gt; set to 256 when you get&#xA;to the latter line in your .vimrc, and so the colorscheme is not reloaded: hence&#xA;wrong colours.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to recap:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;term=xterm&#xA;colorscheme impact3&#xA;let g:impact_transbg=1&#xA;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Result: Colorscheme is reloaded when &lt;code&gt;'t_Co'&lt;/code&gt; is set to 256, colours are correct.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;term=xterm&#xA;colorscheme impact3&#xA;let g:impact_transbg=1&#xA;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Result: Colorscheme is loaded by &lt;code&gt;colorscheme&lt;/code&gt; command, variable does not exist,&#xA;colours are wrong.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;term=xterm&#xA;colorscheme impact3&#xA;let g:impact_transbg=1&#xA;&quot;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Result: Colorscheme is loaded by &lt;code&gt;colorscheme&lt;/code&gt; command, variable does not exist&#xA;and Vim only uses 8 colours, colours are wrong.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;term=xterm&#xA;colorscheme impact3&#xA;let g:impact_transbg=1&#xA;&quot;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Result: Colorscheme is loaded by &lt;code&gt;colorscheme&lt;/code&gt; command, variable does not exist,&#xA;colours are wrong.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:impact_transbg=1&#xA;colorscheme impact3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Result: Colorscheme is loaded by &lt;code&gt;colorscheme&lt;/code&gt; command, variable &lt;em&gt;does&lt;/em&gt; exist, so colours are correct. (And as a bonus &lt;code&gt;'term'&lt;/code&gt; and &lt;code&gt;'t_Co'&lt;/code&gt; are also correct!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behaviour is different in NeoVim simply because the call to set &lt;code&gt;'t_Co'&lt;/code&gt; is ignored, as other answerers have already mentioned.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;'background'&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;After setting the colorscheme, you also set &lt;code&gt;'background'&lt;/code&gt;. For this &lt;em&gt;particular&lt;/em&gt;&#xA;colorscheme, this is completely unnecessary, because the first thing the&#xA;colorscheme does is to set &lt;code&gt;'background'&lt;/code&gt; to &lt;code&gt;'dark'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I disagree with the other answerer who suggests that you should set&#xA;&lt;code&gt;'background'&lt;/code&gt; after loading your colorscheme. The colorscheme may use the value&#xA;of &lt;code&gt;'background'&lt;/code&gt; to adjust its colors, so setting &lt;code&gt;'background'&lt;/code&gt; before loading&#xA;the colorscheme is the more obvious ordering. (Although note that if you change&#xA;the &lt;code&gt;'background'&lt;/code&gt; setting, Vim will reload any loaded colorschemes, so setting&#xA;it &lt;code&gt;'background'&lt;/code&gt; afterwards would also work: it's just non-optimal.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-10-25T15:08:26.830" LastActivityDate="2016-10-25T15:08:26.830" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10042" PostTypeId="2" ParentId="10026" CreationDate="2016-10-25T15:49:58.147" Score="1" Body="&lt;p&gt;This requires you to edit the registry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run &lt;code&gt;regedit.exe&lt;/code&gt; and navigate to the file extension under &lt;code&gt;HKEY_CLASSES_ROOT&lt;/code&gt;. Text files for example would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HKEY_CLASSES_ROOT &amp;gt; .txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;(Default)&lt;/code&gt; data set will define the file type, &lt;code&gt;txtfile&lt;/code&gt; in this example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next step is to navigate to the shell section of file type entry under &lt;code&gt;HKEY_CLASSES_ROOT&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HKEY_CLASSES_ROOT &amp;gt; txtfile &amp;gt; shell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Create a new Key (right click on shell &gt; New &gt; Key) and name the key the text you'd like to see (Open Text with console vim). Make a new key under this and name it &lt;code&gt;command&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HKEY_CLASSES_ROOT &amp;gt; txtfile &amp;gt; shell &amp;gt; Open Text with console vim &amp;gt; command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set the &lt;code&gt;(Default)&lt;/code&gt; value to the command line string you'd like to execute. Use &lt;code&gt;%1&lt;/code&gt; to represent the file argument&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmd /K &quot;C:\Vim\vim.exe&quot; %1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to open a file in gvim you can ditch the &lt;code&gt;cmd /K&lt;/code&gt; stuff and just run the command directly&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\\Vim\\gvim.exe %1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when you right click on any .txt file you'll see a new menu option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately you'll have to create this entry under every file type you want a special menu for. If you are defining new extension types you can always group the file type together by setting the &lt;code&gt;(Default)&lt;/code&gt;. So &lt;code&gt;HKEY_CLASSES_ROOT &amp;gt; .txt&lt;/code&gt; contains the same &lt;code&gt;(Default)&lt;/code&gt; value as &lt;code&gt;HKEY_CLASSES_ROOT&amp;gt; .text&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-10-25T15:49:58.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10043" PostTypeId="1" AcceptedAnswerId="10044" CreationDate="2016-10-25T16:43:45.053" Score="21" ViewCount="22767" Body="&lt;p&gt;I'm wondering whether changing the space between lines is possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QZcZG.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QZcZG.png&quot; alt=&quot;line spacing&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I change &quot;Line spacing&quot;?&lt;/p&gt;&#xA;" OwnerUserId="9837" LastActivityDate="2023-05-22T01:57:42.357" Title="How to change the space between lines in vim?" Tags="|linux|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10044" PostTypeId="2" ParentId="10043" CreationDate="2016-10-25T17:01:52.080" Score="32" Body="&lt;p&gt;Didn't expect this to be possible, but there is actually an option for this. &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27linespace%27&quot;&gt;&lt;code&gt;'linespace'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;'linespace'&lt;/code&gt; &lt;code&gt;'lsp'&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Number of pixel lines inserted between characters.  Useful if the font&#xA;  uses the full character cell height, making lines touch each other.&#xA;  When non-zero there is room for underlining.&#xA;  With some fonts there can be too much room between lines (to have&#xA;  space for ascents and descents).  Then it makes sense to set&#xA;  'linespace' to a negative value.  This may cause display problems&#xA;  though!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It differs from your picture in that the option defines extra space added rather than distance between baselines, but should give you enough control anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to add something like this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set linespace=3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For obvious reasons it will work only in gvim and not in terminal vim.&lt;/p&gt;&#xA;" OwnerUserId="860" LastActivityDate="2016-10-25T17:01:52.080" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10045" PostTypeId="1" CreationDate="2016-10-25T19:31:56.180" Score="2" ViewCount="102" Body="&lt;p&gt;When I first started using Vim 10 years ago, I found myself typing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'a,'fs/target/replacement/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;a lot. I was used to using &lt;code&gt;'a&lt;/code&gt; and &lt;code&gt;'f&lt;/code&gt; as my go-to marks. So I also had this in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map qq :'a,'f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are there any special kinds of marks in Vim that act more like &quot;quick&quot; or &quot;temporary&quot; marks, accompanied by a shortcut or notation that means &quot;the last two quick-marks&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked through the documentation on marks but did not see any. Does anyone have a more elegant shortcut than mine?&lt;/p&gt;&#xA;" OwnerUserId="6547" LastActivityDate="2016-10-26T11:31:18.053" Title="Shortcut for applying a command between the last two marks" Tags="|mark|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10046" PostTypeId="2" ParentId="5388" CreationDate="2016-10-25T20:07:47.120" Score="1" Body="&lt;p&gt;If one inlines grammars from other languages in for example markdown files, then the settings of those languages seem to override the settings for markdown syntax. One can check if that is the case using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set iskeyword?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to fix this, one can define an auto command to be run each time one enters a markdown file (and probably other languages as well):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter,BufNewFile *.md set iskeyword=38,42,43,45,47-58,60-62,_,@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Putting this in my &lt;code&gt;.vimrc&lt;/code&gt; fixed the issue for me. I was using &lt;code&gt;vim-pandoc&lt;/code&gt; syntax and inlined languages including &lt;code&gt;racket&lt;/code&gt;, &lt;code&gt;python&lt;/code&gt;, &lt;code&gt;sh&lt;/code&gt; and some. I think it is not necessary to define an auto command for leaving markdown files, because when you enter files of other languages, their syntax files should set their keywords, if I understand correctly.&lt;/p&gt;&#xA;" OwnerUserId="9855" LastActivityDate="2016-10-25T20:07:47.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10048" PostTypeId="2" ParentId="300" CreationDate="2016-10-26T02:55:57.273" Score="7" Body="&lt;p&gt;You can map &lt;kbd&gt;Caps Lock&lt;/kbd&gt; to &lt;kbd&gt;Control&lt;/kbd&gt; without installing any extra software:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In &lt;a href=&quot;https://stackoverflow.com/a/162907/99777&quot;&gt;Mac OS X&lt;/a&gt; visit &lt;em&gt;System Preferences &amp;gt; Keyboard -&amp;gt; Modifier Keys&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;In &lt;a href=&quot;https://askubuntu.com/a/614664/133393&quot;&gt;Linux&lt;/a&gt; execute: &lt;code&gt;setxkbmap -option caps:ctrl_modifier&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;In &lt;a href=&quot;http://www.howtogeek.com/194705/how-to-disable-or-reassign-the-caps-lock-key-on-any-operating-system/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Windows&lt;/a&gt; edit your registry.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This brings &lt;kbd&gt;Control&lt;/kbd&gt; onto the middle row, making it easier to press &lt;em&gt;all&lt;/em&gt; Control modified strokes, including &lt;kbd&gt;Ctrl-[&lt;/kbd&gt; and &lt;kbd&gt;Ctrl-C&lt;/kbd&gt; which both exit Insert mode in Vim.&lt;/p&gt;&#xA;&lt;h3&gt;Make Caps Lock perform both Ctrl and Escape?&lt;/h3&gt;&#xA;&lt;p&gt;Alternatively, at the bottom of &lt;a href=&quot;https://vi.stackexchange.com/a/349/630&quot;&gt;his answer&lt;/a&gt; Giovanni suggests to map &lt;kbd&gt;Caps Lock&lt;/kbd&gt; to perform both &lt;kbd&gt;Control&lt;/kbd&gt; &lt;em&gt;and&lt;/em&gt; &lt;kbd&gt;Escape&lt;/kbd&gt; depending on the length of press, but this requires installing extra software.&lt;/p&gt;&#xA;&lt;p&gt;Some people love this.&lt;/p&gt;&#xA;&lt;p&gt;I did not. Because sometimes I press Ctrl, then change my mind, and release it. If I do that too quickly, within the configured timeout, then it sends an Escape stroke, which in some situations can be quite disruptive (for example closing the current dialog window).&lt;/p&gt;&#xA;&lt;h3&gt;Differences between Ctrl-[ and Ctrl-C&lt;/h3&gt;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl-[&lt;/kbd&gt; is probably what you want, since it always works like &lt;kbd&gt;Escape&lt;/kbd&gt;.&lt;/p&gt;&#xA;&lt;p&gt;One difference with &lt;kbd&gt;Ctrl-C&lt;/kbd&gt; is: When leaving an edit &lt;strong&gt;in blockwise visual mode&lt;/strong&gt;, &lt;kbd&gt;Ctrl-C&lt;/kbd&gt; will keep the changes you made on the current line, but &lt;strong&gt;will not repeat the changes&lt;/strong&gt; over the other lines in the block, which is the point of that mode.&lt;/p&gt;&#xA;&lt;p&gt;It also won't check for abbreviations, or trigger the InsertLeave event.  See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-C&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-C&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2022-02-15T06:22:33.067" LastActivityDate="2022-02-15T06:22:33.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10049" PostTypeId="1" CreationDate="2016-10-26T08:09:15.460" Score="10" ViewCount="1539" Body="&lt;h2&gt;Foreword&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I'm using the &quot;indent with tabs, align with spaces&quot; ideology for indentation. This means that each line in a file can be prefixed with an arbitrary amount of tabs and spaces (as opposed to &quot;only spaces&quot; or &quot;tabs when possible, then &lt;code&gt;0 ≤ x &amp;lt; tabstop&lt;/code&gt; spaces&quot;). For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;--&amp;gt;# use OLS (ordinary least squares) to find initial guesses&#xA;&amp;lt;--&amp;gt;if prefit or initial is None:&#xA;&amp;lt;--&amp;gt;&amp;lt;--&amp;gt;beta, cov = sp_opt.curve_fit(model,&#xA;&amp;lt;--&amp;gt;&amp;lt;--&amp;gt;.............................xdata = x,&#xA;&amp;lt;--&amp;gt;&amp;lt;--&amp;gt;.............................ydata = y,&#xA;&amp;lt;--&amp;gt;&amp;lt;--&amp;gt;.............................sigma = yerr,&#xA;&amp;lt;--&amp;gt;&amp;lt;--&amp;gt;.............................absolute_sigma = True,&#xA;&amp;lt;--&amp;gt;&amp;lt;--&amp;gt;.............................maxfev = int(1e6),&#xA;&amp;lt;--&amp;gt;&amp;lt;--&amp;gt;.............................p0 = initial)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, a &lt;code&gt;&amp;lt;--&amp;gt;&lt;/code&gt; represents a tab character and &lt;code&gt;.&lt;/code&gt; represents a whitespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To work in this mode, I have &lt;code&gt;noexpandtab&lt;/code&gt; set in my vimrc. Hence &lt;a href=&quot;https://vi.stackexchange.com/questions/4878/avoid-spaces-getting-converted-to-tabs-automatically-during-shift&quot;&gt;this question on Vim SE&lt;/a&gt; is not relevant for me.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;When I shift such a line left or right using &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; Vim operations, Vim replaces (almost) all existing spaces with tabs. How to avoid this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want Vim to only do exactly what's said — i. e. insert or remove a single tab character at position 0 of the line.&lt;/p&gt;&#xA;" OwnerUserId="7826" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2020-04-16T16:20:23.567" Title="Shift left or right (with `noet`) without converting existing spaces to tabs" Tags="|indentation|whitespace|tab-characters|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10050" PostTypeId="2" ParentId="10045" CreationDate="2016-10-26T10:59:49.423" Score="3" Body="&lt;p&gt;Using 2 marks to operate on the text between those lines is the 'vi'-compatible way of the more modern and (literally) visual way of operating in Vim (and probably why visual mode was invented in the 1st place): visually select a range with whatever means (motion, text-object), then start your ex command, which operates line-wise: when you hit &lt;code&gt;:&lt;/code&gt;, you will see those two quick marks automatically inserted before the &lt;code&gt;:&lt;/code&gt; (the start and the end marks of the visual selection).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quick access to &quot;the last two quick-marks&quot; in this case would translate to &quot;restoring the last visual selection&quot;, which can be accomplished with &lt;code&gt;gv&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And now for the funny part: if you really want it, you can &lt;em&gt;explicitly&lt;/em&gt; set those two marks (&lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt;), manually, using &lt;code&gt;m&amp;lt;&lt;/code&gt; and &lt;code&gt;m&amp;gt;&lt;/code&gt;, as with any letter-based mark. I.e. you don't need to go to visual mode for that; then, either use &lt;code&gt;gv&lt;/code&gt; to restore that selection and start your ex command, or manually insert &lt;code&gt;:'&amp;lt;,'&amp;gt;some-ex-command-here&lt;/code&gt; to (similarly) operate on that line range. In another words, visual marks can operate exactly as in your request (quick or temporary marks that can be set - a pair of them), with the advantage of also allowing a more visual way of assignation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, maybe this mapping, to &lt;code&gt;ex&lt;/code&gt;ecute on a selection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap g: gv:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-10-26T11:31:18.053" LastActivityDate="2016-10-26T11:31:18.053" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10051" PostTypeId="2" ParentId="10031" CreationDate="2016-10-26T21:44:09.933" Score="2" Body="&lt;p&gt;If your wanting a good general answer and not an exact 25% you could factor the normal line count on a page by divide by 25 and set some system mappings. For instance if you normally have about 100 line on a screen at a time then 25% of that is 25 lines so you could set a key mapping on something like your capital J and K for quickly moving up and down 25 lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap J 25j&#xA;noremap K 25k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your wanting to just jump to the quarter mark of the entire file then in normal mode just type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;25%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9675" LastActivityDate="2016-10-26T21:44:09.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10052" PostTypeId="1" AcceptedAnswerId="10053" CreationDate="2016-10-27T08:40:49.137" Score="2" ViewCount="1758" Body="&lt;p&gt;I am a tabs kind of guy, I do not like when my code contains leading whitespaces instead of leading tabs. I often exchange codes with colleagues and I first have to convert the leading whitespaces to tabs manually before doing anything else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to search for whitespaces but not tabs in vim? My end goal is to write a script that will convert leading whitespaces to tabs automatically, but an answer to the above question will put me in the right track.&lt;/p&gt;&#xA;" OwnerUserId="4562" LastEditorUserId="1841" LastEditDate="2016-10-27T11:04:31.233" LastActivityDate="2019-12-02T03:22:25.933" Title="Show leading whitespaces, but not including tabs" Tags="|search|whitespace|tab-characters|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10053" PostTypeId="2" ParentId="10052" CreationDate="2016-10-27T08:51:13.317" Score="2" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/ &lt;/code&gt; will search for single space (there's a space after slash)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/^ \+&lt;/code&gt; will search for leading whitespaces&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2016-10-27T11:10:58.600" LastActivityDate="2016-10-27T11:10:58.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10054" PostTypeId="1" AcceptedAnswerId="10055" CreationDate="2016-10-27T09:54:40.167" Score="1" ViewCount="139" Body="&lt;p&gt;In my syntax file I have something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match cleanReal &quot;[+-~]\?\&amp;lt;\d\+\.\d+\(E[+-~]\?\d+\)\?&quot; display&#xA;hi def link cleanReal Float&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get all strings that are matched as &lt;code&gt;cleanReal&lt;/code&gt; from vimscript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm asking because I would like to write a custom command completion function that completes all strings matched by some syntax group.&lt;/p&gt;&#xA;" OwnerDisplayName="user2598" LastActivityDate="2016-10-27T10:05:21.220" Title="Get all syntax elements with some group name from buffer" Tags="|vimscript|syntax-highlighting|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10055" PostTypeId="2" ParentId="10054" CreationDate="2016-10-27T10:05:21.220" Score="1" Body="&lt;p&gt;The last time I've tried something similar, it was to emulate &lt;code&gt;]s&lt;/code&gt; long before it existed. I proceeded by going from word to word until I find one with the right &lt;code&gt;synId*()&lt;/code&gt; value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could do that, but I'm afraid that it'll be very slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your syntax group it just a regex that you know, and with no context or whatever (like exclusion within comments or strings), may be the easier approach would be to get all matches from &lt;code&gt;getline(1,'$')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let text = join(getline(1,'$'), &quot;\n&quot;)&#xA;let matches = []&#xA;call substitute(text, yourregex, '\=add(res, submatch(0))', 'g')&#xA;let matches = uniq(sort(matches))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-10-27T10:05:21.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10056" PostTypeId="2" ParentId="10052" CreationDate="2016-10-27T11:02:56.053" Score="4" Body="&lt;p&gt;In addition to &lt;a href=&quot;https://vi.stackexchange.com/a/10053/16706&quot;&gt;@grodzik's answer&lt;/a&gt; here are two points that might interest you:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can have vim showing the tabs and spaces characters. If you use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list&#xA;set listchars+=tab:&amp;gt;-,space:.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll see lines like this (Here the line begins with 2 tab characters and 4 spaces characters):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BA7Ll.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BA7Ll.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27list%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'list'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27listchars%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'listchars'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also about the transformation of the tabs to spaces the &lt;code&gt;:retab&lt;/code&gt; command might interest you. From &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Aretab&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :retab&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;With &lt;code&gt;!&lt;/code&gt;, Vim also replaces strings of only normal&#xA;  spaces with tabs where appropriate.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus in a the buffer containing my previous example if I use &lt;code&gt;:retab!&lt;/code&gt; I'll get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ToUL1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ToUL1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can imagine using the command in an autocommand for example to automatically convert your new buffers.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="16706" LastEditDate="2019-12-02T03:22:25.933" LastActivityDate="2019-12-02T03:22:25.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10057" PostTypeId="1" CreationDate="2016-10-27T14:13:06.527" Score="2" ViewCount="878" Body="&lt;p&gt;Is there a way I can map a &lt;code&gt;digraph&lt;/code&gt; like &lt;kbd&gt; ` &lt;/kbd&gt;, with modifier key like &lt;kbd&gt; ctrl &lt;/kbd&gt; together in vim like this NERDTree bind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map &amp;lt;C-n&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems to be a tad bit more complicated when your trying map a digraph, and at first I thought I found my solution when I came across these&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/4855/how-to-enter-tilde-back-tick-and-special-chars-with-a-non-us-keyboard/&quot;&gt;How to enter tilde &amp;#40;~&amp;#41;, back tick &amp;#40;`&amp;#41; and special&#xA;chars with a  non-US keyboard ?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/intro.html#key-notation/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Documentation: Key Notations&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:h digraph-table&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I couldn't figure out how to get it syntatically correct. I want a map to open my &lt;code&gt;~/.vimrc&lt;/code&gt;, anyway I could do this ?&lt;/p&gt;&#xA;" OwnerUserId="9885" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-10-27T14:13:06.527" Title="How do you map the back tick character (`) with a modifier key like ctrl?" Tags="|vimrc|key-bindings|" AnswerCount="0" CommentCount="4" ClosedDate="2016-10-28T14:29:22.667" ContentLicense="CC BY-SA 3.0" />
  <row Id="10058" PostTypeId="1" AcceptedAnswerId="10059" CreationDate="2016-10-27T22:28:26.630" Score="3" ViewCount="390" Body="&lt;p&gt;Let's say i create a filename with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xb@dnxb:/tmp/test$ touch '&quot;i'&quot;'&quot;'m noob.mp4&quot;'&#xA;xb@dnxb:/tmp/test$ ls -1&#xA;&quot;i'm noob.mp4&quot;&#xA;xb@dnxb:/tmp/test$ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;vim .&lt;/code&gt; to go inside Netrw directory listing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ============================================================================&#xA;&quot; Netrw Directory Listing                                        (netrw v156)&#xA;&quot;   /tmp/test&#xA;&quot;   Sorted by      name&#xA;&quot;   Sort sequence: [\/]$,\&amp;lt;core\%(\.\d\+\)\=\&amp;gt;,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$&#xA;&quot;   Quick Help: &amp;lt;F1&amp;gt;:help  -:go up dir  D:delete  R:rename  s:sort-by  x:special&#xA;&quot; ==============================================================================&#xA;../&#xA;./&#xA;&quot;i'm noob.mp4&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then press &lt;kbd&gt;Enter&lt;/kbd&gt; to view the file. Type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!ls -l %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will shows error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xb@dnxb:/tmp/test$ vim .&#xA;&#xA;ls: cannot access '/tmp/test/i'\''m noob.mp4': No such file or directory&#xA;&#xA;shell returned 2&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also tried:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] &lt;code&gt;:!ls -l '%'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Press ENTER or type command to continue&#xA;/bin/bash: -c: line 0: unexpected EOF while looking for matching `&quot;'&#xA;/bin/bash: -c: line 1: syntax error: unexpected end of file&#xA;&#xA;shell returned 1&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[2] &lt;code&gt;:!ls -l &quot;%&quot;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Press ENTER or type command to continue&#xA;/bin/bash: -c: line 0: unexpected EOF while looking for matching `''&#xA;/bin/bash: -c: line 1: syntax error: unexpected end of file&#xA;&#xA;shell returned 1&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[3] &lt;code&gt;:!ls -l expand(&quot;%&quot;)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/bin/bash: -c: line 0: syntax error near unexpected token `('&#xA;/bin/bash: -c: line 0: `ls -l expand(&quot;&quot;i'm noob.mp4&quot;&quot;)'&#xA;&#xA;shell returned 1&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[4] &lt;code&gt;!ls -l shellescape(&quot;%&quot;)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/bin/bash: -c: line 0: syntax error near unexpected token `('&#xA;/bin/bash: -c: line 0: `ls -l shellescape(&quot;/tmp/test/&quot;i'm noob.mp4&quot;&quot;)'&#xA;&#xA;shell returned 1&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[5] &lt;code&gt;!ls -l shellescape(expand(&quot;%&quot;))&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/bin/bash: -c: line 0: syntax error near unexpected token `('&#xA;/bin/bash: -c: line 0: `ls -l shellescape(expand(&quot;/tmp/test/&quot;i'm noob.mp4&quot;&quot;))'&#xA;&#xA;shell returned 1&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My ultimate goal is perform &lt;code&gt;rsync&lt;/code&gt; by &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt;, e.g:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-c&amp;gt; :!eval `ssh-agent -s`; ssh-add; rsync -azvb --no-t % xiaobai@127.0.0.1:/home/xiaobai/storage/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My platform is Kali Linux's &lt;code&gt;vim.gtk3&lt;/code&gt;, bash. Fedora's &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;gvim&lt;/code&gt; also have the same problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the correct syntax to escape filename containing single and double quotes ? &lt;/p&gt;&#xA;" OwnerUserId="2670" LastEditorUserId="2670" LastEditDate="2016-10-27T23:05:52.140" LastActivityDate="2016-10-28T08:35:46.697" Title="How to escape filename containing single and double quotes mix?" Tags="|linux|bash|escape|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10059" PostTypeId="2" ParentId="10058" CreationDate="2016-10-28T05:09:46.917" Score="3" Body="&lt;p&gt;I got the answer from &lt;a href=&quot;https://unix.stackexchange.com/a/319449/64403&quot;&gt;Unix &amp;amp; Linux Stack Exchange&lt;/a&gt;, backslash-escape literally every character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-c&amp;gt; :!eval `ssh-agent -s`; ssh-add; rsync -azvb --no-t %:gs/./\\&amp;amp;/:p 'xiaobai@127.0.0.1:/tmp/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tested with chinese unicode characters and works fine, even in virtual console.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I  still welcome any alternative answers or more detailed explanation. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2670" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2016-10-28T08:35:46.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10060" PostTypeId="2" ParentId="467" CreationDate="2016-10-28T05:32:55.110" Score="10" Body="&lt;p&gt;For those wanting to remove the register name (say, &lt;code&gt;a&lt;/code&gt;) from the &lt;code&gt;:registers&lt;/code&gt; list, there &lt;em&gt;is&lt;/em&gt; a way to do it now. Run the command &lt;code&gt;:call setreg('a', [])&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this out from &lt;a href=&quot;https://stackoverflow.com/questions/19430200/how-to-clear-vim-registers-effectively&quot;&gt;this question&lt;/a&gt; on StackOverflow from user @LucHermitte. &lt;a href=&quot;https://stackoverflow.com/a/39348498/1199156&quot;&gt;His answer&lt;/a&gt; details how to clear multiple registers. If you want this task to be super easy, get creative with your &lt;code&gt;.vimrc&lt;/code&gt; :)&lt;/p&gt;&#xA;" OwnerUserId="9892" LastEditorUserId="5395" LastEditDate="2016-10-28T06:10:58.210" LastActivityDate="2016-10-28T06:10:58.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10061" PostTypeId="1" CreationDate="2016-10-28T06:53:43.403" Score="4" ViewCount="5258" Body="&lt;p&gt;&lt;strong&gt;I think this question of mine should be closed, since I do not have access to that computer anymore, so I can't check wheter the answers are effective solutions or not.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I never had this problem, but recently I &quot;lost&quot; my &lt;code&gt;.vimrc&lt;/code&gt; file of my Mac and had to use another one from a different computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The strange thing, is now that the &lt;code&gt;cursorline&lt;/code&gt;s are drawn and remain fixed when I move up with &lt;kbd&gt;k&lt;/kbd&gt; or &lt;kbd&gt;↑&lt;/kbd&gt;, whereas are removed when I move down with &lt;kbd&gt;j&lt;/kbd&gt; or &lt;kbd&gt;↓&lt;/kbd&gt;. (So, moving from downmost line to upmost line I can fill every line with the cursorline, whereas moving from upmost to downmost line I can erase all cursorlines.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Moving with &lt;kbd&gt;⇧&lt;/kbd&gt;&lt;kbd&gt;L&lt;/kbd&gt;, &lt;kbd&gt;⇧&lt;/kbd&gt;&lt;kbd&gt;M&lt;/kbd&gt; and &lt;kbd&gt;⇧&lt;/kbd&gt;&lt;kbd&gt;H&lt;/kbd&gt;, does not affect the behavior.&lt;/li&gt;&#xA;&lt;li&gt;Moving to another buffer with &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;W&lt;/kbd&gt;&lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;W&lt;/kbd&gt; or &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; or similars doesn't affect the behavior.&lt;/li&gt;&#xA;&lt;li&gt;Moving to another program with &lt;kbd&gt;⌘&lt;/kbd&gt;&lt;kbd&gt;↹&lt;/kbd&gt;, makes all cursorlines disappear, but those where the cursor is (cursors are, if more than one buffer is visible).&lt;/li&gt;&#xA;&lt;li&gt;Setting &lt;code&gt;cursor column&lt;/code&gt; option make the redraw happen only when the movements implies a change in the column of the cursor.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I launched Vim with &lt;code&gt;vim -u NONE -U NONE -N&lt;/code&gt; (&lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;as suggested here&lt;/a&gt;) and the problem is still present, so it's not about my &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I have not solved the problem yet, so I use &lt;code&gt;set nocul&lt;/code&gt; to avoid this persistent lines. I set the option manually, not in my &lt;code&gt;.vimrc&lt;/code&gt; file, since I hope I will solve the problem! With your help.) I have news! I noticed that the first time I open a file, no matter how much time I rest with my arms folded, when I start moving (doing some &lt;kbd&gt;j&lt;/kbd&gt; and then some &lt;kbd&gt;k&lt;/kbd&gt; I can fill some lines with cursorlines) a &quot;spontaneous&quot; refresh is done after a second (or not much more than a second), then no more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 3&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I ssh-connect to the machine on which I have the problem from another one I experience no problem; when I ssh-connect to another computer form the the machine on which I have the problem, I experience the same problem. Thus, it seems to be a problem of the terminal and not Vim.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="6498" LastEditDate="2018-05-12T07:11:32.970" LastActivityDate="2018-05-12T07:11:32.970" Title="Vim does not redraw screen and cursorlines remain drawn" Tags="|vimrc|cursorline|redraw|" AnswerCount="1" CommentCount="17" ClosedDate="2020-09-30T13:57:48.033" ContentLicense="CC BY-SA 4.0" />
  <row Id="10062" PostTypeId="1" CreationDate="2016-10-28T08:42:41.690" Score="6" ViewCount="385" Body="&lt;p&gt;When executing an ex command I can use the variable &lt;code&gt;v:count&lt;/code&gt; to get the count which was given to this command. From &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#v%3Acount&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h v:count&lt;/code&gt;&lt;/a&gt;, if I create this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map _x :&amp;lt;C-U&amp;gt;echo &quot;the count is &quot; . v:count&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And use &lt;kbd&gt;12&lt;/kbd&gt;&lt;kbd&gt;_&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt; I'll get a message&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;the count is 12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I do the same with a macro?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When calling a macro 12 times with &lt;kbd&gt;12&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; how can I know that the current execution is the &lt;em&gt;n&lt;/em&gt;th of the 12?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So far I tried to create a macro which show the count like like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qaa&amp;lt;C-r&amp;gt;=v:count&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I play it with &lt;kbd&gt;12&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;; I simply get 12 zeros:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;000000000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which makes me think that the variable &lt;code&gt;v:count&lt;/code&gt; is not used by macros.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="343" LastEditDate="2017-01-25T12:08:49.407" LastActivityDate="2017-01-25T20:20:01.883" Title="How to get the count given to a macro?" Tags="|macro|count|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10063" PostTypeId="1" AcceptedAnswerId="10064" CreationDate="2016-10-28T09:04:48.983" Score="3" ViewCount="312" Body="&lt;p&gt;What I usually do from bash/vim ... is&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;open file with vim&lt;/li&gt;&#xA;&lt;li&gt;go to line to comment&lt;/li&gt;&#xA;&lt;li&gt;comment a line&lt;/li&gt;&#xA;&lt;li&gt;save and quit&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My file is &lt;code&gt;/usr/local/etc/php/7.0/conf.d/ext-xdebug.ini&lt;/code&gt; and the initial content is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[xdebug]&#xA;zend_extension=&quot;/usr/local/opt/php70-xdebug/xdebug.so&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to run a command that in one statement adds &lt;code&gt;;&lt;/code&gt; at the beginning of the second line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[xdebug]&#xA;zend_extension=&quot;/usr/local/opt/php70-xdebug/xdebug.so&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do this directly from bash?&lt;/p&gt;&#xA;" OwnerUserId="2965" LastEditorUserId="1841" LastEditDate="2016-10-28T09:17:45.600" LastActivityDate="2016-10-28T09:17:45.600" Title="How to comment a line directly from bash using vim?" Tags="|comments|invocation|bash|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10064" PostTypeId="2" ParentId="10063" CreationDate="2016-10-28T09:12:08.887" Score="5" Body="&lt;p&gt;You can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +'normal! 2GI;' +'x' path/to/your/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;+&lt;/code&gt; parameter allows to execute a command after opening the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first command &lt;code&gt;normal! 2GI;&lt;/code&gt; goes to line 2 and add a &lt;code&gt;;&lt;/code&gt; at the beginning of the line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second command saves and exit.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Bonus point: To uncomment the same line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +'normal! 2G^x' +'x' path/to/your/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-10-28T09:12:08.887" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10065" PostTypeId="1" AcceptedAnswerId="10066" CreationDate="2016-10-28T09:47:29.100" Score="1" ViewCount="1692" Body="&lt;p&gt;I'm trying to customize my window title, which uses the same &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27statusline%27&quot; rel=&quot;nofollow&quot;&gt;format&lt;/a&gt; as the statusline. I know I can show the full path to the file with &lt;code&gt;%F&lt;/code&gt; (or &lt;code&gt;%-0.20F&lt;/code&gt; to restrict it to 20 characters). I'd prefer to show the file name separately (i.e. with &lt;code&gt;%t&lt;/code&gt;). In this case, is there a way to show the full path to the containing directory instead?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I don't set &lt;code&gt;titlestring&lt;/code&gt; at all, vim's window title seems to default to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;file.txt (/full/path/to/containing/directory) - VIM3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought I might pillage the code for this, but &lt;code&gt;set titlestring?&lt;/code&gt; doesn't show anything.&lt;/p&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="1841" LastEditDate="2016-10-28T11:40:54.867" LastActivityDate="2016-10-28T11:40:54.867" Title="How can I show the containing directory in the window title?" Tags="|vimrc|statusline|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10066" PostTypeId="2" ParentId="10065" CreationDate="2016-10-28T11:03:32.030" Score="2" Body="&lt;p&gt;I'm not sure I fully understood what you mean so feel free to correct me in the comment if I didn't understood.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If what you are trying to do is simply show the directory containing your file in your title bar you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set titlestring=%{expand(\&quot;%:p:h\&quot;)}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this configuration when I'm on the help file &lt;code&gt;options.txt&lt;/code&gt; my title bar looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Jdks5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Jdks5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the example I gave you uses &lt;code&gt;expand&lt;/code&gt; and the filename modifiers thus you can customize it the way you want with the help of &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#filename%2Dmodifiers&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h filename-modifiers&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-10-28T11:03:32.030" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10067" PostTypeId="1" CreationDate="2016-10-28T12:36:24.467" Score="2" ViewCount="1062" Body="&lt;p&gt;I have these two functions&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  void function_one(){&#xA;    return;&#xA;  }&#xA;&#xA;  void function_two()&#xA;  {&#xA;    return;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I use &lt;code&gt;zM&lt;/code&gt; to fold the functions I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  +--  3 lines: void function_one(){--&#xA;&#xA;  void function_two()&#xA;  +--  3 lines: {-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;function_two&lt;/code&gt; doesn't get a nice folding, How I can get the same folding as for &lt;code&gt;function_one&lt;/code&gt; in &lt;code&gt;function_two&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PD: I use two code styles, curly brackets on same line as function name and curly braces under the function name, because some projects use one code style and other projects use the other code style.&lt;/p&gt;&#xA;" OwnerUserId="9897" LastEditorUserId="51" LastEditDate="2016-11-11T01:23:43.873" LastActivityDate="2020-12-15T14:35:57.630" Title="folding, curly bracket under the function name" Tags="|folding|filetype-c++|filetype-c|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10068" PostTypeId="2" ParentId="10067" CreationDate="2016-10-28T12:42:19.807" Score="1" Body="&lt;p&gt;I did define &lt;a href=&quot;https://github.com/LucHermitte/VimFold4C&quot; rel=&quot;nofollow&quot;&gt;VimFold4C&lt;/a&gt; that tries its best to fold C &amp;amp; C++ codes. The caveat is when we are modifying the code: I'm using caches in order to speed up the fold processing, but alas it has quirks.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-10-28T12:42:19.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10069" PostTypeId="2" ParentId="9978" CreationDate="2016-10-28T13:19:37.910" Score="1" Body="&lt;h3&gt;A bit of investigation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;After finding the function in &lt;a href=&quot;https://github.com/msprev/vim-markdown-folding/blob/2cd611f75a1cdf57c16c761c5f61aa8c3a42f94d/autoload/mdfolding.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;source file&lt;/a&gt;, with these lines preceding it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !has('python')&#xA;    echo &quot;Error: Required vim compiled with +python&quot;&#xA;    finish&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And installing the plugin (my Vim is built without python), I can easily get the same error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing BufEnter Auto commands for &quot;&amp;lt;buffer=1&amp;gt;&quot;:&#xA;E117: Unknown function: mdfolding#foldtextupdate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;:echo has('python')&lt;/code&gt; probably returns 0 for you, because your Vim either doesn't have python support at all or has only python3 support.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, the authors of the plugins should use &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#%3Aechoerr&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:echoerr&lt;/code&gt;&lt;/a&gt; for such cases, or users might ignore important error messages.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Plugin version&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Please do keep in mind that &lt;strong&gt;you did not install the original version&lt;/strong&gt; of the plugin. What you installed is actually a fork of Drew Neil's plugin -- it seems to try to optimize performance of folding, but also requires Vim with python support.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;You can:&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;use &lt;a href=&quot;https://github.com/nelstrom/vim-markdown-folding&quot; rel=&quot;nofollow noreferrer&quot;&gt;original version&lt;/a&gt; of the plugin, which doesn't require python (your link to documentation points to this repository, actually):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/nelstrom/vim-markdown-folding.git&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;change your Vim setup (if you really need this plugin)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;report upstream about the issue, maybe fixing it requires only adding check for &lt;code&gt;python3&lt;/code&gt; feature (e.g., &lt;code&gt;if !has('python') &amp;amp;&amp;amp; !has('python3')&lt;/code&gt;), the author should know better anyway&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="860" LastEditorUserId="860" LastEditDate="2016-11-01T14:36:56.987" LastActivityDate="2016-11-01T14:36:56.987" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10070" PostTypeId="1" AcceptedAnswerId="10081" CreationDate="2016-10-28T14:50:55.690" Score="5" ViewCount="624" Body="&lt;p&gt;I work with lots of different servers and would like to unify my vimrc across them all. I see that vim has the source command, which I'm assuming works similar to bash. In bash, to source a file from a webpage you go &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;. &amp;lt;(curl -s domain.com)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do this with vim? I'm aware that I can instead apply each vim setting by adding an alias like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vim=&quot;vim +'colorscheme elflord'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I'd rather not pass thru all my settings like that. I don't want to have to create a file on the local server I'm on, hence the desire to instead source into the local session. Any ideas would be appreciated!&lt;/p&gt;&#xA;" OwnerUserId="8456" LastActivityDate="2022-09-08T01:49:46.240" Title="Source a vimrc from a webpage?" Tags="|vimrc|linux|bash|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10071" PostTypeId="1" AcceptedAnswerId="10075" CreationDate="2016-10-28T15:26:30.303" Score="0" ViewCount="1724" Body="&lt;p&gt;New to Vim here; did several searches on how to do this in Vim, but without any luck (maybe it's too simple). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm attempting to highlight words in sequence, in the same way that &lt;code&gt;SHIFT + OPTION + [Arrow Key]&lt;/code&gt; does for Macs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this doable in Vim? Would love to be able to in &quot;Insert&quot; mode and not be in &quot;Visual&quot; mode for that.&lt;/p&gt;&#xA;" OwnerUserId="9901" LastEditorUserId="1821" LastEditDate="2016-10-28T16:31:19.550" LastActivityDate="2016-10-28T16:51:37.630" Title="Highlighting word by word in &quot;insert&quot; mode?" Tags="|vimrc|macvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10072" PostTypeId="1" AcceptedAnswerId="10110" CreationDate="2016-10-28T15:32:45.083" Score="8" ViewCount="8127" Body="&lt;p&gt;Recently I decided to switch from Vundle to VimPlug, and I noticed that after installing it...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;putting the &lt;code&gt;plug.vim&lt;/code&gt; in my autoload directory &lt;code&gt;~/.vim/autoload/&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and making sure that my vim and neovim was symbol linked so I didn't have to create a whole new set of directories just for neovim with this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ln -s ~/.vim ~/.config/nvim&#xA; ln -s ~/.vimrc ~/.config/nvim/init.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&#xA;&#xA;&lt;p&gt;I was still getting errors. It works perfectly in vim, but soon as I start up nvim I get these list of errors. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Error detected while processing /home/username/.config/nvim/init.vim:&#xA; line   26:&#xA; E117: Unknown function: plug#begin&#xA; line   28:&#xA; E492: Not an editor command: Plug 'vim-airline/vim-airline'&#xA; line   29:&#xA; E492: Not an editor command: Plug 'vim-airline/vim-airline-themes'&#xA; line   30:&#xA; E492: Not an editor command: Plug 'scrooloose/nerdtree'&#xA; line   31:&#xA; E492: Not an editor command: Plug 'ctrlpvim/ctrlp.vim'&#xA; line   32:&#xA; E492: Not an editor command: Plug 'flazz/vim-colorschemes'&#xA; line   34:&#xA; E117: Unknown function: plug#end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the VimPlug section of my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;[VIMPLUG]&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'vim-airline/vim-airline'&#xA;Plug 'vim-airline/vim-airline-themes'&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'ctrlpvim/ctrlp.vim'&#xA;Plug 'flazz/vim-colorschemes'&#xA;&#xA;call plug#end()&#xA;&quot;[VIMPLUG_END]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong ?&lt;/p&gt;&#xA;" OwnerUserId="9885" LastActivityDate="2022-03-22T13:55:25.373" Title="VimPlug unknown function plug#begin in NeoVim" Tags="|vimrc|neovim|plugin-vim-plug|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10073" PostTypeId="2" ParentId="10070" CreationDate="2016-10-28T16:30:47.260" Score="4" Body="&lt;p&gt;AFAIK, &lt;code&gt;source&lt;/code&gt; doesn't let you source anything other than a file.&lt;/p&gt;&#xA;&lt;p&gt;This function is a little bit dirty but it works:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! GetAndSource(url)&#xA;&#xA;  execute '!curl ' . a:url . ' -o vimrc.vim'&#xA;  source vimrc.vim&#xA;  execute '!rm vimrc.vim'&#xA;&#xA;endfunction&#xA;&#xA;command! -nargs=1 GS call GetAndSource(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;This function will curl the file, source it and delete it afterwards.&#xA;&#xA;Obviously you can execute each element separately, and it'll work the same.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="35229" LastEditDate="2022-09-08T01:49:46.240" LastActivityDate="2022-09-08T01:49:46.240" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10075" PostTypeId="2" ParentId="10071" CreationDate="2016-10-28T16:51:37.630" Score="2" Body="&lt;p&gt;You can do this by running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:behave mswin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command will simultaneously change several commands, namely &quot;selectmode&quot;, &quot;mousemodel&quot;, &quot;keymodel&quot;, and &quot;selection&quot;. I would recommend reading the help page on each of these, since they're all related to what you want to do but affect it in slightly different ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/gui.txt.html#gui-mouse&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;:h behave&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3. Mouse Control                                        gui-mouse&#xA;&#xA;The mouse only works if the appropriate flag in the 'mouse' option is set.&#xA;When the GUI is switched on, and 'mouse' wasn't set yet, the 'mouse' option is&#xA;automatically set to &quot;a&quot;, enabling it for all modes except for the&#xA;hit-enter prompt.  If you don't want this, a good place to change the&#xA;'mouse' option is the &quot;gvimrc&quot; file.&#xA;&#xA;Other options that are relevant:&#xA;'mousefocus'    window focus follows mouse pointer gui-mouse-focus&#xA;'mousemodel'    what mouse button does which action&#xA;'mousehide'     hide mouse pointer while typing text&#xA;'selectmode'    whether to start Select mode or Visual mode&#xA;&#xA;A quick way to set these is with the &quot;:behave&quot; command.&#xA;                                                        :behave :be&#xA;:be[have] {model}       Set behavior for mouse and selection.  Valid&#xA;                        arguments are:&#xA;                           mswin        MS-Windows behavior&#xA;                           xterm        Xterm behavior&#xA;&#xA;                        Using &quot;:behave&quot; changes these options:&#xA;                        option          mswin                   xterm   &#xA;                        'selectmode'    &quot;mouse,key&quot;             &quot;&quot;&#xA;                        'mousemodel'    &quot;popup&quot;                 &quot;extend&quot;&#xA;                        'keymodel'      &quot;startsel,stopsel&quot;      &quot;&quot;&#xA;                        'selection'     &quot;exclusive&quot;             &quot;inclusive&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So after running &lt;code&gt;:behave mswin&lt;/code&gt;, you can select individual characters in insert mode with &lt;code&gt;&amp;lt;shift-cursor_keys&amp;gt;&lt;/code&gt;, and entire words with &lt;code&gt;&amp;lt;ctrl-shift-cursor_keys&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that even though what you want is definitely possible, I would recommend learning to use visual mode instead. Since it is more &quot;vim-like&quot;, it will be more compatible with other vim-idioms and make you much faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, it's your workflow, so in the end it's all up to you. :)&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-10-28T16:51:37.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10076" PostTypeId="1" AcceptedAnswerId="10105" CreationDate="2016-10-29T13:41:16.283" Score="1" ViewCount="374" Body="&lt;p&gt;I just started working with Jekyll, which uses Liquid. As a templating language, Liquid is embedded into files of other types (&lt;em&gt;e.g.,&lt;/em&gt; HTML, CSS, or Markdown). Vim handles this sort of dual syntax highlighting admirably – when &lt;code&gt;set filetype=liquid&lt;/code&gt; in, say, an HTML file, it &lt;em&gt;preserves&lt;/em&gt; the HTML highlighting while &lt;em&gt;additionally&lt;/em&gt; highlighting Liquid code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But Liquid also has its own comment markers, which are distinct from HTML's, CSS's, and Markdown's. And when I want to comment something out in a &lt;code&gt;.css.liquid&lt;/code&gt; file, more often than not, what I'm trying to do is make a &lt;code&gt;/* CSS comment */&lt;/code&gt;, &lt;em&gt;not&lt;/em&gt; a &lt;code&gt;{{ comment }}Liquid comment{{ endcomment }}&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I rely on tpope’s &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow&quot;&gt;vim-commentary&lt;/a&gt; to comment stuff out, and that plugin relies on the filetype-specific &lt;code&gt;commentstring&lt;/code&gt; setting to determine how to wrap comments. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is, is there any way to enable Liquid syntax highlighting while keeping the native &lt;code&gt;commentstring&lt;/code&gt; setting?&lt;/p&gt;&#xA;" OwnerUserId="2593" LastEditorUserId="2593" LastEditDate="2016-10-29T17:33:32.177" LastActivityDate="2016-10-31T20:27:49.490" Title="Enable templating language (e.g., Liquid) syntax highlighting but keep native (html/css) commenting?" Tags="|syntax-highlighting|filetype|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10077" PostTypeId="1" AcceptedAnswerId="10079" CreationDate="2016-10-29T16:08:26.243" Score="3" ViewCount="272" Body="&lt;p&gt;In a substitute command, is it possible to retrieve the 'index' of the search (i.e. for the &lt;code&gt;n&lt;/code&gt;-th match, the index is &lt;code&gt;n&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking to use this in this context: &lt;code&gt;:s/pattern/\=[SEARCH INDEX HERE]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked around in help &lt;code&gt;:search&lt;/code&gt;, etc. but could not find what I'm looking for.&lt;/p&gt;&#xA;" OwnerUserId="5179" LastActivityDate="2016-10-29T20:23:23.560" Title="Get index of search in substitute expression" Tags="|search|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10078" PostTypeId="1" AcceptedAnswerId="22518" CreationDate="2016-10-29T17:22:53.633" Score="3" ViewCount="1038" Body="&lt;p&gt;The below example, straight out of the VIM documentation, uses an &quot;at sign&quot; yet nowhere else in the entire document is it mentioned or explained.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Another example: Think of a Python interpreter that produces the&#xA;following error message (line numbers are not part of the actual&#xA;output):&#xA;&#xA;     1  ==============================================================&#xA;     2  FAIL: testGetTypeIdCachesResult (dbfacadeTest.DjsDBFacadeTest)&#xA;     3  --------------------------------------------------------------&#xA;     4  Traceback (most recent call last):&#xA;     5    File &quot;unittests/dbfacadeTest.py&quot;, line 89, in testFoo&#xA;     6      self.assertEquals(34, dtid)&#xA;     7    File &quot;/usr/lib/python2.2/unittest.py&quot;, line 286, in&#xA;     8   failUnlessEqual&#xA;     9      raise self.failureException, \&#xA;    10  AssertionError: 34 != 33&#xA;    11&#xA;    12  --------------------------------------------------------------&#xA;    13  Ran 27 tests in 0.063s&#xA;&#xA;Say you want |:clist| write the relevant information of this message&#xA;only, namely:&#xA;&#xA;   5 unittests/dbfacadeTest.py:89:  AssertionError: 34 != 33&#xA;&#xA;Then the error format string could be defined as follows:&#xA;&#xA;:set efm=%C\ %.%#,%A\ \ File\ \&quot;%f\&quot;\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m&#xA;&#xA;Note that the %C string is given before the %A here: since the&#xA;expression '' %.%#' (which stands for the regular expression '' .*')&#xA;matches every line starting with a space, followed by any characters&#xA;to the end of the line, it also hides line 7 which would trigger a&#xA;separate error message otherwise. Error format strings are always&#xA;parsed pattern by pattern until the first match occurs.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have spent quite a few hours pouring over the quickfix &amp;amp; errorformat documentation to trying to find an explanation of the at sign and what it represents.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I've also looked through the scanf documentation just in case it means something there&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I've also looked through VIM's regular expression documentation &lt;em&gt;but not so thoroughly&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;What I do understand:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%C\ %.%#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A continuation line that must start with a space, and then any text until the end of the line (via the .* equivalent)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%A\ \ File\ \&quot;%f\&quot;\\,\ line\ %l%.%#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A non-specified starting line that must start with &lt;em&gt;space&lt;/em&gt;, &lt;em&gt;space&lt;/em&gt;, 'File', &lt;em&gt;space&lt;/em&gt; - and then a quoted filename (extracted), followed by a comma some more literal text and a line number to be extracted.  Lastly any other text is matched and ignored (via the .* equivalent)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What I do &lt;em&gt;not&lt;/em&gt; understand:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%Z%[%^\ ]%\\@=%m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think i got this part: is a terminating line that must start with a &lt;em&gt;non-space&lt;/em&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This seems like an attempt to match line 10 which starts with an 'A'&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Then my understanding breaks down...&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%\\&lt;/code&gt;: is a literal slash (i have no idea the purpose, since the only '\' is at the end of line 9)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;@=&lt;/code&gt;: does the &lt;code&gt;@=&lt;/code&gt; mean something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%m&lt;/code&gt;: then extract the message&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;-OR-&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%\\@=&lt;/code&gt;: perhaps all this together means something I don't get?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%m&lt;/code&gt;: then extract the message&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone shed some light on the point of the &lt;code&gt;\@&lt;/code&gt; within the errorformat string?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or the &lt;code&gt;\@=&lt;/code&gt;, or the &lt;code&gt;=%m&lt;/code&gt; or the &lt;code&gt;=&lt;/code&gt; by itself, ...    I don't understand this last bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="9912" LastEditorUserId="54" LastEditDate="2016-10-29T18:54:35.987" LastActivityDate="2020-01-12T17:00:26.103" Title="What does an at sign (@) do in a VIM errorformat string - I can't figure out the example from VIM's docs" Tags="|errorformat|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10079" PostTypeId="2" ParentId="10077" CreationDate="2016-10-29T19:16:13.763" Score="4" Body="&lt;p&gt;Here's a way to do it (maybe not the simplest way), using a recent Vim8 feature: &lt;em&gt;closures&lt;/em&gt; (*):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;In your &lt;code&gt;vimrc&lt;/code&gt;, add the following (reusable) function - a function that returns a reference to another function, one that increments a counter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MakeSearchIndex()&#xA;    let counter = 0&#xA;    function! SearchIndex() closure&#xA;        let counter += 1&#xA;        return counter&#xA;    endfunction&#xA;    return funcref('SearchIndex')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Before every new search in which you need a search index, call &lt;code&gt;MakeSearchIndex()&lt;/code&gt; and use its result as your &lt;code&gt;\=[SEARCH INDEX]&lt;/code&gt; replacement part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let SI=MakeSearchIndex()&#xA;%s/pattern/\=SI()/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;or (one liner):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let SI=MakeSearchIndex()|%s/pattern/\=SI()/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, using a closure, you &quot;capture&quot; a new variable &lt;code&gt;counter&lt;/code&gt; (created and set to 0 by each call to &lt;code&gt;MakeSearchIndex&lt;/code&gt;), by making it visible and modifiable &lt;em&gt;only&lt;/em&gt; in the returned &lt;code&gt;funcref&lt;/code&gt;. So, while being local to &lt;code&gt;MakeSearchIndex&lt;/code&gt;, &lt;code&gt;counter&lt;/code&gt;'s life is actually bound to that of the returned object.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(*) I guess this makes the answer ... &lt;em&gt;emacs flavoured&lt;/em&gt; (LISP style) :)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The variation below works in exactly the same way, but also lets you create search index functions that receive an optional &lt;em&gt;increment&lt;/em&gt; argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MakeSearchIndex()&#xA;    let counter = 0&#xA;    function! SearchIndex(...) closure&#xA;        if (a:0 &amp;gt; 0)&#xA;            let counter += a:1&#xA;        else&#xA;            let counter += 1&#xA;        endif&#xA;        return counter&#xA;    endfunction&#xA;    return funcref('SearchIndex')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.. so that you could use for example &lt;code&gt;SI(3)&lt;/code&gt; to increment the current counter with 3 at every call, or &lt;code&gt;SI()&lt;/code&gt; (as before) to increment with 1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Well, I presume I just re-created the &quot;counters&quot; example from functional programming 101, or something like that :P)&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-10-29T20:23:23.560" LastActivityDate="2016-10-29T20:23:23.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10081" PostTypeId="2" ParentId="10070" CreationDate="2016-10-30T07:29:51.223" Score="6" Body="&lt;p&gt;From &lt;code&gt;:h -u&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-u {vimrc}  The file {vimrc} is read for initializations.  Most other&#xA;        initializations are skipped; see |initialization|.  This can&#xA;        be used to start Vim in a special mode, with special&#xA;        mappings and settings.  A shell alias can be used to make&#xA;        this easy to use.  For example:  &#xA;            alias vimc vim -u ~/.c_vimrc !*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, when you want to start Vim with a custom vimrc, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -u {custom_vimrc}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But starting Vim like this will enable the &lt;code&gt;'compatible'&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Using the &quot;-u&quot; argument has the side effect that the&#xA;    'compatible' option will be on by default.  This can have&#xA;    unexpected effects.  See |'compatible'|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… which is probably not what you want. To be sure &lt;code&gt;'compatible'&lt;/code&gt; is disabled, you can add the &lt;code&gt;-N&lt;/code&gt; argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -Nu {custom_vimrc}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, if your &lt;code&gt;{custom_vimrc}&lt;/code&gt; file is not on your local machine but on the web, you can use a &lt;a href=&quot;http://wiki.bash-hackers.org/syntax/expansion/proc_subst&quot; rel=&quot;noreferrer&quot;&gt;process substitution&lt;/a&gt;, which appears to be:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;a form of redirection where the input or output of a process (some&#xA;  sequence of commands) appear as a temporary file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;One of the possible syntax using process substitution seems to be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ shell_command &amp;lt;( &amp;lt;LIST&amp;gt; )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… where &lt;code&gt;&amp;lt;LIST&amp;gt;&lt;/code&gt; is a &lt;a href=&quot;http://wiki.bash-hackers.org/syntax/basicgrammar#lists&quot; rel=&quot;noreferrer&quot;&gt;command list&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use this to make the output of the shell command &lt;code&gt;curl url&lt;/code&gt; appear as a temporary file to &lt;code&gt;vim -Nu&lt;/code&gt;.&#xA;So, maybe you could start Vim from your shell with a command like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -Nu &amp;lt;(curl url)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -Nu &amp;lt;(curl https://raw.githubusercontent.com/tpope/vim-sensible/master/plugin/sensible.vim)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-10-30T07:29:51.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10082" PostTypeId="1" CreationDate="2016-10-30T11:01:24.363" Score="3" ViewCount="1979" Body="&lt;p&gt;I use the auto complete function from &lt;a href=&quot;https://vi.stackexchange.com/a/8902&quot;&gt;this stackoverflow page&lt;/a&gt;.&#xA;It works fine on my pc and notebook but it fails on my raspberry pi with this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line   28:&#xA;E474: Invalid argument: completeopt=menu,menuone,noinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why doesn't it work?&#xA;Whats the problem ?&lt;/p&gt;&#xA;" OwnerUserId="9917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-10-31T07:35:10.963" Title="set completeopt=noinsert fails" Tags="|autocompletion|set|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10083" PostTypeId="1" AcceptedAnswerId="10092" CreationDate="2016-10-30T12:03:24.953" Score="2" ViewCount="500" Body="&lt;p&gt;I have a file containing a list of words, e.g. &lt;code&gt;list.txt&lt;/code&gt; contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;carrot&#xA;apple&#xA;pen&#xA;ukulele&#xA;pen&#xA;cinnamon&#xA;carrot&#xA;carrot&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I sort this file so that the words which appear the most in it go to the top, and duplicates are removed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. I'd like &lt;code&gt;list.txt&lt;/code&gt; to contain this after sorting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;carrot&#xA;pen&#xA;apple&#xA;cinnamon&#xA;ukulele&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2016-10-30T20:21:11.910" Title="How can I sort a file by word frequency?" Tags="|sort|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10084" PostTypeId="1" AcceptedAnswerId="10192" CreationDate="2016-10-30T12:38:03.603" Score="4" ViewCount="1686" Body="&lt;p&gt;I am coding in LaTeX, and syntastic seems to come up with messages that don't actually flag up errors. One in particular is &lt;code&gt;possible unwanted space at &quot;{&quot;&lt;/code&gt; in this piece of code on lines 1 and 2. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\tikzset{&#xA;box/.style={&#xA;    regular polygon,&#xA;    regular polygon sides=6,&#xA;    minimum size=1cm,&#xA;    inner sep=0mm,&#xA;    outer sep=0mm,&#xA;    rotate=90,&#xA;    draw&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can supress certain syntastic messages such as this one?&lt;/p&gt;&#xA;" OwnerUserId="4962" LastActivityDate="2016-11-06T17:40:57.947" Title="Stop some messages from syntastic" Tags="|plugin-syntastic|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10086" PostTypeId="1" AcceptedAnswerId="10088" CreationDate="2016-10-30T14:33:21.780" Score="5" ViewCount="3141" Body="&lt;p&gt;I want to create a custom search in vimscript, using this line for searching:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;normal gg/[A-Z]\\+*.:\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it will tell me (correctly) that it searched for the pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/[A-Z]\+3a.*:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it will not highlight/search for anything. Pressing 'n' will continue the last search from before. Executing the exact same command directly in vim has the desired effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can somebody explain to me why this doesn't work and how to do it correctly?&lt;/p&gt;&#xA;" OwnerUserId="9919" LastActivityDate="2021-02-18T03:11:29.803" Title="Searching with vimscript function" Tags="|vimscript|search|" AnswerCount="1" CommentCount="4" ClosedDate="2020-10-15T13:13:01.717" ContentLicense="CC BY-SA 3.0" />
  <row Id="10087" PostTypeId="1" AcceptedAnswerId="10089" CreationDate="2016-10-30T15:40:02.630" Score="7" ViewCount="7700" Body="&lt;p&gt;Given this file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf 'hello\x19world\n' &amp;gt; hello.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can replace a hex character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex -sc '%s/\%x19/ /|x' hello.txt&#xA;$ od -c hello.txt&#xA;0000000   h   e   l   l   o       w   o   r   l   d  \n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I cannot replace with a hex character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex -sc '%s/ /\%x19/|x' hello.txt&#xA;$ od -c hello.txt&#xA;0000000   h   e   l   l   o   %   x   1   9   w   o   r   l   d  \n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-04-10T17:45:27.760" Title="Replace with hex character" Tags="|substitute|ex-mode|ex-command|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10088" PostTypeId="2" ParentId="10086" CreationDate="2016-10-30T16:11:13.633" Score="1" Body="&lt;p&gt;The reason why this is not working is stated in &lt;code&gt;:h function-search-undo&lt;/code&gt;. I worked around this by letting my function return the line and mapping it like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;KEY&amp;gt; :call function()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Credits to VanLaser.&lt;/p&gt;&#xA;" OwnerUserId="9919" LastEditorUserId="22375" LastEditDate="2021-02-18T03:11:29.803" LastActivityDate="2021-02-18T03:11:29.803" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10089" PostTypeId="2" ParentId="10087" CreationDate="2016-10-30T16:18:35.323" Score="7" Body="&lt;p&gt;From &lt;code&gt;:help todo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Substitute with hex/unicode number &quot;\%xff&quot; and &quot;\%uabcd&quot;.  Just like&#xA;      &quot;\%uabcd&quot; in search pattern.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In other words, this isn't implemented yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do it interactively, in Vim.  See &lt;code&gt;:help 24.8&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Type &lt;code&gt;:%s/ /&lt;/code&gt;, then type &lt;code&gt;Ctrl-V&lt;/code&gt;, then &lt;code&gt;x19&lt;/code&gt;, then press Enter.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2016-10-30T16:18:35.323" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10090" PostTypeId="1" AcceptedAnswerId="10120" CreationDate="2016-10-30T17:15:03.097" Score="1" ViewCount="255" Body="&lt;p&gt;I want to change the characters, spell checking considers to being separating words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already have the following line in my &lt;code&gt;~/.vimrc&lt;/code&gt; file, which makes &lt;code&gt;w&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; recognize words with a &lt;code&gt;-&lt;/code&gt; in between as one word:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; autocmd BufEnter,BufNewFile,TabEnter *.md set iskeyword=38,42,43,45,47-57,60-62,_,@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to ASCII the 45 is the &lt;code&gt;-&lt;/code&gt; character. However, spell checking seems to use another list of characters. When I write something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc-def&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want it to be considered one word only, so that I may add this word to my word list as a correct word, instead of one of the parts &lt;code&gt;abc&lt;/code&gt; or &lt;code&gt;def&lt;/code&gt; being marked as a spelling mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? If it is, how?&lt;/p&gt;&#xA;" OwnerUserId="9855" LastActivityDate="2016-11-02T17:20:30.280" Title="Change spell check word separator" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10091" PostTypeId="1" CreationDate="2016-10-30T17:55:50.367" Score="1" ViewCount="242" Body="&lt;p&gt;How can I change &lt;code&gt;vim&lt;/code&gt;'s spell checking, so that it does not mark words with capital letters, which were previously unknown to vim, but were added to a custom dictionary in lower case form, at the beginning of a phrase, where they suddenly have a capital letter as first letter, as wrong in general?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know it does this for known words already, but I added a custom word:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lern-didaktische&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I added it using the visual mode and selecting the whole word and then pressing &lt;code&gt;zg&lt;/code&gt; to my custom file &lt;code&gt;~/.vim/spell/custom.utf-8.add&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the next phrase there is the same word, but at the beginning of the phrase:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lern-didaktische&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Phrases are separated by &lt;code&gt;.&lt;/code&gt; and a space &lt;code&gt;&lt;/code&gt; in my document. Although the non-capitalized version is already known to vim and not marked as wrong anymore, this one is still marked as wrong. To be precise, the first part before the &lt;code&gt;-&lt;/code&gt; is marked as wrong. However, I cannot simply add it like the other version of the word, because I don't want to allow it to have capital &lt;code&gt;L&lt;/code&gt; where ever it stands. The capitalized version should &lt;em&gt;only&lt;/em&gt; be correct at the beginning of phrases, because it is an adjective and we don't give adjectives a capital letter at the beginning, except at the beginning of a phrase.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Return value of &lt;code&gt;:verbose set spellcapcheck&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;spellcapcheck=[.?!]\_[\])'&quot;^I ]\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9855" LastEditorUserId="9855" LastEditDate="2017-02-19T17:05:37.387" LastActivityDate="2017-02-19T17:05:37.387" Title="Spell checking beginning of phrase capital letters" Tags="|spell-checking|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10092" PostTypeId="2" ParentId="10083" CreationDate="2016-10-30T20:21:11.910" Score="3" Body="&lt;p&gt;Normaly, I would use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%! sort | uniq -c | sort -nr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this is a shell depended answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using only Vim language or ex-commands in Vim is a little bit more difficult and it is very nicely described on wikia in &lt;a href=&quot;http://vim.wikia.com/wiki/Word_frequency_statistics_for_a_file&quot; rel=&quot;nofollow&quot;&gt;Word frequency statistics for a file&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inspired by that article it is possible to replicate the output of &lt;code&gt;:%! sort | uniq -c | sort -nr&lt;/code&gt; with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\+/1\t/g&#xA;:sort&#xA;:g/^\c\(.\+\)\n\1$/norm! ^yiwj@&quot;^Akdd&#xA;:sort! n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;^A&lt;/code&gt; represents &lt;kbd&gt;Ctrl-A&lt;/kbd&gt; and is inserted as &lt;kbd&gt;CTRL-V&lt;/kbd&gt; + &lt;kbd&gt;CTRL-A&lt;/kbd&gt; (or if you use &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; for paste, press &lt;kbd&gt;Ctrl-Q&lt;/kbd&gt; then &lt;kbd&gt;Ctrl-A&lt;/kbd&gt;).&lt;/p&gt;&#xA;" OwnerUserId="2961" LastActivityDate="2016-10-30T20:21:11.910" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10093" PostTypeId="1" CreationDate="2016-10-31T06:02:23.037" Score="0" ViewCount="850" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8M1uc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8M1uc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;3rd block of code needs to go from &lt;code&gt;ipt1&lt;/code&gt; to &lt;code&gt;ipt4&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;4th block of code needs to go from &lt;code&gt;ipt1&lt;/code&gt; to &lt;code&gt;ipt5&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Because it is only 3 selections, creating a macro is probably slower than manually, but doing it manually is still tedious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the fastest way to be changing these? I come across situations like this a lot, and usually I try to use visual block mode with the change function, but these are not aligned so that is not an option.&lt;/p&gt;&#xA;" OwnerUserId="7960" LastEditorUserId="51" LastEditDate="2016-11-10T18:55:07.617" LastActivityDate="2016-11-23T13:48:01.173" Title="How to quickly replace a single character in a word search, but only for a block of code in Fakevim?" Tags="|search|visual-mode|replace|visual-block|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10094" PostTypeId="2" ParentId="10093" CreationDate="2016-10-31T07:22:52.367" Score="3" Body="&lt;p&gt;Using visual mode and substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v/}&amp;lt;CR&amp;gt;s/ipt1/ipt4&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using substitution only:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:,/}/s/ipt1/ipt5&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-10-31T07:22:52.367" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10095" PostTypeId="2" ParentId="10093" CreationDate="2016-10-31T07:33:08.587" Score="2" Body="&lt;p&gt;I would either &lt;a href=&quot;https://vi.stackexchange.com/a/10094/21&quot;&gt;do as @romainl&lt;/a&gt; suggests, or I would do a search, then use the &lt;code&gt;gn&lt;/code&gt; text object (see &lt;code&gt;:h gn&lt;/code&gt;). Specifically, I would do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/script\zs1&amp;lt;cr&amp;gt;&lt;/code&gt; (search for script1, but only match the 1)&lt;/li&gt;&#xA;&lt;li&gt;Make sure the cursor is on the first match that you want to change to 4, e.g. by repeating &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;N&lt;/code&gt; to search forward/backward.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cgn4...cgn5...&lt;/code&gt; (&lt;code&gt;cgn&lt;/code&gt; = change the search match, then repeat with &lt;code&gt;.&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="21" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-10-31T07:33:08.587" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10096" PostTypeId="2" ParentId="10082" CreationDate="2016-10-31T07:35:10.963" Score="8" Body="&lt;p&gt;The &lt;code&gt;noinsert&lt;/code&gt; option became available with Vim version 7.4.775. Your Vim on the raspberry pi is (probably) older. You can check with &lt;code&gt;:version&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-10-31T07:35:10.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10097" PostTypeId="1" AcceptedAnswerId="10101" CreationDate="2016-10-31T07:56:43.463" Score="2" ViewCount="64" Body="&lt;p&gt;I want to insert data from another file , especially particular lines[10-23] from the file. I tried the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r filename 10-23 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But It returns the following error&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E172: Only one file name allowed&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How to resolve this?&lt;/p&gt;&#xA;" OwnerUserId="7834" LastActivityDate="2016-10-31T09:52:41.223" Title="How to insert data from another file's particular lines" Tags="|insert-mode|ex-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10098" PostTypeId="1" AcceptedAnswerId="10109" CreationDate="2016-10-31T08:36:17.693" Score="10" ViewCount="7450" Body="&lt;p&gt;I saw an editor command which started like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%! sort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does that mean? Specifically, the &lt;code&gt;:%!&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2019-12-13T16:27:25.497" Title="What does :%! mean?" Tags="|command-line|" AnswerCount="2" CommentCount="0" ClosedDate="2016-11-01T00:40:18.620" ContentLicense="CC BY-SA 3.0" />
  <row Id="10099" PostTypeId="1" AcceptedAnswerId="10118" CreationDate="2016-10-31T09:01:35.473" Score="3" ViewCount="709" Body="&lt;p&gt;I start vanilla vim8 &lt;code&gt;$ vim -u NONE&lt;/code&gt; with these settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ft=python&#xA;:set smartindent&#xA;:set cinkeys-=0#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I enter in insertion mode the following: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Hello&#xA;    #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;#&lt;/code&gt; is automatically unindent as follow: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Hello&#xA;#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course if I enable &lt;code&gt;:set cindent&lt;/code&gt; everything works because &lt;code&gt;cinkeys&lt;/code&gt; is now taken in account. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is why is &lt;code&gt;#&lt;/code&gt; automatically moved left while &lt;code&gt;cindent&lt;/code&gt; is disabled? Is there any better solution other than using an auto command?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType python setlocal cindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2548" LastEditorUserId="51" LastEditDate="2016-11-10T18:25:47.770" LastActivityDate="2016-11-10T18:25:47.770" Title="How to disable automatic unindent of comments in Python?" Tags="|indentation|filetype-python|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10100" PostTypeId="2" ParentId="10098" CreationDate="2016-10-31T09:08:01.273" Score="11" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3a%25&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :%&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%       equal to 1,$ (the entire file)        *:%*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3arange%21&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :range!&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:{range}![!]{filter} [!][arg]               *:range!*&#xA;            Filter {range} lines through the external program&#xA;            {filter}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, &lt;code&gt;%! sort&lt;/code&gt; and &lt;code&gt;1,$! sort&lt;/code&gt; are equivalent and they pass the text in the current buffer, from line 1 to the last line (that's what &lt;code&gt;$&lt;/code&gt; stands for), through the external &lt;code&gt;sort&lt;/code&gt; command. After that, those lines are replaced by the command output. &lt;a href=&quot;https://vi.stackexchange.com/a/5428/6698&quot;&gt;This&lt;/a&gt; is another&#xA;explanation by @Carpetsmoker&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's useful not only for sorting a file. See some other examples here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/319/how-to-use-an-external-command-in-vim-to-modify-selected-words-and-lines&quot;&gt;How to use an external command in Vim to modify selected words and lines?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-10-31T20:55:45.237" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10101" PostTypeId="2" ParentId="10097" CreationDate="2016-10-31T09:52:41.223" Score="4" Body="&lt;p&gt;You can use &lt;code&gt;sed&lt;/code&gt; for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r! sed -n 10,23p filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-10-31T09:52:41.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10102" PostTypeId="2" ParentId="9357" CreationDate="2016-10-31T14:00:58.377" Score="3" Body="&lt;p&gt;You could use netrw's :Lexplore command (usually shortened to :Lex) to get a side pane.  As Tumbler41 said, you can change the sorting order with &lt;code&gt;s&lt;/code&gt;; you can also have netrw start up with that sorting method by putting &lt;code&gt;let g:netrw_sort_by= &quot;time&quot;&lt;/code&gt; in your .vimrc.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2016-10-31T14:00:58.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10103" PostTypeId="1" CreationDate="2016-10-31T14:55:00.093" Score="0" ViewCount="215" Body="&lt;p&gt;I haven't been coding too long, and I've recently switched over to MacVim. I'm starting to see why doing so has a high &quot;learning curve.&quot; I'm not familiar with hardcore &lt;code&gt;Vim&lt;/code&gt; commands, and I tried adding EasyGrep for searching my codebase:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2438&quot; rel=&quot;nofollow&quot;&gt;http://www.vim.org/scripts/script.php?script_id=2438&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I successfully installed EasyGrep, but I can't for the life of me figure out how to run a simple search for a string. My terminal freezes up, for example, when I run &lt;code&gt;:Grep searchThisWord&lt;/code&gt; with recursive search turned on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To me, the documentation above isn't too beginner-friendly; for instance, what does &lt;code&gt;&amp;lt;Leader&amp;gt;vv&lt;/code&gt; mean? Do I type that into the terminal exactly like &lt;code&gt;:Grep &amp;lt;Leader&amp;gt;vv&lt;/code&gt;? It'd be great to get some guidance or advice on how to begin understanding those instructions.&lt;/p&gt;&#xA;" OwnerUserId="9901" LastActivityDate="2016-11-04T15:54:50.373" Title="How do I approach understanding the EasyGrep documentation?" Tags="|macvim|plugin-easygrep|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10104" PostTypeId="1" AcceptedAnswerId="10121" CreationDate="2016-10-31T19:11:13.693" Score="0" ViewCount="432" Body="&lt;p&gt;I saved and closed a file I was editing.  When I opened it again a minute later, vim gave the warning that appears when a .swp file is present.  I selected the recover option, but the &quot;recovered&quot; file did not have any of my recent work.  Then I checked the dates.  Somehow, the .swp file was last changed two months ago.  Two questions:&#xA;How could a .swp file suddenly appear from so long ago?  I have been regularly editing that file ever since, and this is the first time that has appeared.&#xA;More importantly, is there any way I can recover the version that existed a few minutes ago?&lt;/p&gt;&#xA;" OwnerUserId="9928" LastActivityDate="2016-11-02T17:34:13.360" Title="recover file destroyed by old .swp file" Tags="|crash-recovery|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10105" PostTypeId="2" ParentId="10076" CreationDate="2016-10-31T20:27:49.490" Score="1" Body="&lt;p&gt;You can create file &lt;code&gt;~/.vim/after/ftplugin/liquid.vim&lt;/code&gt; containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if expand('%:e:e') == 'css.liquid'&#xA;    set commentstring=/*\ %s\ */&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will change style of comments to &lt;code&gt;/* ... */&lt;/code&gt; only for Liquid files with &lt;code&gt;.css.liquid&lt;/code&gt; extension.&lt;/p&gt;&#xA;" OwnerUserId="860" LastActivityDate="2016-10-31T20:27:49.490" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10107" PostTypeId="1" CreationDate="2016-10-31T22:21:10.887" Score="2" ViewCount="490" Body="&lt;p&gt;I often use &lt;code&gt;ex&lt;/code&gt; in scripted edits.  I can run several editing commands, and then save the changed file, with no danger of hanging if an &lt;code&gt;ex&lt;/code&gt; command encounters an error, by running commands like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf '%s\n' '%s/someregex/somereplacementtext/g' x | ex file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To test commands before overwriting the file, I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf '%s\n' '%s/someregex/somereplacementtext/g' %p 'q!' | ex file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I've just encountered a need to simply print a certain line number and then exit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the &lt;code&gt;ex&lt;/code&gt; command &quot;&lt;code&gt;.=&lt;/code&gt;&quot; will print the current line number when editing interactively.  Unfortunately, I've found that this doesn't print to stdout the way that &lt;code&gt;p&lt;/code&gt; does.  You can see this for yourself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf '%s\n' '8p' '8=' 'q!' | ex somefile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I make the &lt;code&gt;.=&lt;/code&gt; command print to stdout from a scripted &lt;code&gt;ex&lt;/code&gt; instance?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2016-11-02T15:55:25.607" Title="Print current line number to stdout using ex" Tags="|ex-command|posix|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10108" PostTypeId="1" AcceptedAnswerId="10116" CreationDate="2016-10-31T23:03:25.603" Score="1" ViewCount="2116" Body="&lt;p&gt;I have the following in my &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi clear SpellBad&#xA;hi SpellBad cterm=underline,bold ctermfg=196 ctermbg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make misspelled words red. Vim makes them only underlined and bold, but not colored. They remain white, no matter what color I use for &lt;code&gt;ctermfg&lt;/code&gt;. When I take away the bold or underlined, those disappear, showing that it does indeed read those values, but somehow simply doesn't want to make things colored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My complete &lt;code&gt;.vimrc&lt;/code&gt; file is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; automatically install vim-plug if git is available&#xA;if empty(glob('~/.vim/autoload/plug.vim'))&#xA;    silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs&#xA;                \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;    autocmd VimEnter * PlugInstall | source $MYVIMRC&#xA;endif&#xA;&#xA;&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;&quot; ===== FUNCTIONALITY =====&#xA;Plug 'wlangstroth/vim-racket'&#xA;Plug 'MicahElliott/vrod'&#xA;Plug 'klen/python-mode'&#xA;Plug 'tpope/vim-sensible'&#xA;&quot; Plug 'https://github.com/kovisoft/slimv.git'&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'ervandew/supertab'&#xA;Plug 'tpope/vim-obsession'&#xA;Plug 'terryma/vim-multiple-cursors'&#xA;&#xA;&quot; ===== LANGUAGE SUPPORT =====&#xA;&quot; Plug 'jtratner/vim-flavored-markdown'&#xA;&quot; Plug 'tpope/vim-markdown'&#xA;Plug 'vim-pandoc/vim-pandoc-syntax'&#xA;Plug 'vim-pandoc/vim-pandoc'&#xA;&#xA;Plug 'dhruvasagar/vim-table-mode'&#xA;&#xA;&quot; ===== SNIPPETS =====&#xA;Plug 'MarcWeber/vim-addon-mw-utils'&#xA;Plug 'tomtom/tlib_vim'&#xA;Plug 'garbas/vim-snipmate'&#xA;Plug 'honza/vim-snippets'&#xA;&#xA;&quot; ===== COLORSCHEMES =====&#xA;Plug 'chriskempson/vim-tomorrow-theme'&#xA;Plug 'tomasr/molokai'&#xA;Plug 'altercation/vim-colors-solarized'&#xA;Plug 'chriskempson/base16-vim'&#xA;Plug 'nickburlett/vim-colors-stylus'&#xA;Plug 'sickill/vim-monokai'&#xA;Plug 'tyrannicaltoucan/vim-quantum'&#xA;Plug 'hericks/vimicks'&#xA;Plug 'vim-scripts/kate.vim'&#xA;Plug 'AlessandroYorba/Despacio'&#xA;Plug 'josuegaleas/jay'&#xA;Plug 'mbbill/vim-seattle'&#xA;Plug 'jacoborus/tender.vim'&#xA;Plug 'NLKNguyen/papercolor-theme'&#xA;&#xA;&quot; ===== PARENS =====&#xA;Plug 'kien/rainbow_parentheses.vim'&#xA;&#xA;&quot; Add plugins to &amp;amp;runtimepath&#xA;call plug#end()&#xA;&#xA;&#xA;&quot; ===== MY FUNCTIONS =====&#xA;function ActivateSyntaxHighlighting()&#xA;    syntax on&#xA;    syntax enable&#xA;endfunction&#xA;&#xA;function SetTabWidth(width, softorhard)&#xA;    set expandtab&#xA;    set smarttab&#xA;    let &amp;amp;g:tabstop = a:width&#xA;    let &amp;amp;g:shiftwidth = a:width&#xA;    let &amp;amp;g:showtabline = a:width&#xA;    let &amp;amp;g:softtabstop = a:softorhard&#xA;endfunction&#xA;&#xA;function SetMarkdownOptions()&#xA;    &quot;&quot;&quot; COLORSCHEME&#xA;    colorscheme quantum&#xA;    set background=light&#xA;    &quot;&quot;&quot; SPELL CHECKING COLORS&#xA;    hi clear SpellBad&#xA;    hi SpellBad cterm=underline,bold ctermfg=196 ctermbg=NONE&#xA;    hi SpellCap cterm=underline,bold ctermfg=166 ctermbg=NONE&#xA;    syn match UrlNoSpell &quot;\w\+:\/\/[^[:space:]]\+&quot; contains=@NoSpell&#xA;    &quot;&quot;&quot; LANGUAGE&#xA;    set spelllang=de_de,en_us&#xA;    set spellfile=~/.vim/spell/master-thesis.utf-8.add&#xA;    &quot;&quot;&quot; KEYWORDS&#xA;    set iskeyword=38,42,43,45,47-57,60-62,_,@&#xA;    &quot;&quot;&quot; TABS&#xA;    call SetTabWidth(4, 1)&#xA;    &quot;syn match myExCapitalWords +\&amp;lt;\w*[A-Z]\K*\&amp;gt;\|'s+ contains=@NoSpell&#xA;endfunction&#xA;&#xA;function SetRacketOptions()&#xA;    colorscheme molokai&#xA;    call SetTabWidth(2, 1)&#xA;    hi MatchParen cterm=bold ctermbg=none ctermfg=magenta&#xA;endfunction&#xA;&#xA;function SetPythonOptions()&#xA;    set iskeyword=38,42,43,45,47-57,60-62,_,@&#xA;    call SetTabWidth(4, 1)&#xA;    hi MatchParen cterm=bold ctermbg=none ctermfg=magenta&#xA;endfunction&#xA;&#xA;function KeyComboOptions()&#xA;    map q &amp;lt;Nop&amp;gt;&#xA;    nnoremap &amp;lt;Up&amp;gt; gk&#xA;    nnoremap &amp;lt;Down&amp;gt; gj&#xA;    nnoremap &amp;lt;F3&amp;gt; :noh&amp;lt;CR&amp;gt;&#xA;    vnoremap &amp;lt;silent&amp;gt; # :s/^/#/&amp;lt;cr&amp;gt;:noh&amp;lt;cr&amp;gt;&#xA;    vnoremap &amp;lt;silent&amp;gt; -# :s/^#//&amp;lt;cr&amp;gt;:noh&amp;lt;cr&amp;gt;&#xA;    noremap &amp;lt;c-s-up&amp;gt; ddkP&#xA;    noremap &amp;lt;c-s-down&amp;gt; ddp&#xA;    map &amp;lt;F8&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;    noremap &amp;lt;c-t&amp;gt; :tabe&amp;lt;cr&amp;gt;&#xA;    noremap &amp;lt;c-s-i&amp;gt; G=gg&#xA;    inoremap &amp;lt;C-c&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;Esc&amp;gt;&#xA;endfunction&#xA;&#xA;&quot; ===== AUTOCOMMANDS =====&#xA;augroup pandoc_syntax&#xA;    au! BufNewFile,BufFilePRe,BufRead *.md set filetype=markdown.pandoc&#xA;augroup END&#xA;&#xA;autocmd BufEnter,BufNewFile,TabEnter *.md call SetMarkdownOptions()&#xA;autocmd BufEnter,BufNewFile,TabEnter *.rkt call SetRacketOptions()&#xA;autocmd BufEnter,BufNewFile,TabEnter *.py call SetPythonOptions()&#xA;&#xA;&#xA;&quot; ===== TABLES =====&#xA;let g:table_mode_corner_corner=&quot;+&quot;&#xA;let g:table_mode_header_fillchar=&quot;=&quot;&#xA;let g:table_mode_align_char=&quot;:&quot;&#xA;&#xA;&quot; ===== automatically change directory to the current file =====&#xA;set autochdir&#xA;&#xA;&quot; ===== LOCALE SETTINGS =====&#xA;set encoding=utf-8&#xA;&#xA;&quot; ===== WORD CHARACTERS =====&#xA;&quot; german stuff&#xA;set iskeyword=38,42,43,45,47-58,60-62,_,@&#xA;&#xA;&quot; ===== FONT SETTINGS =====&#xA;set guifont=Inconsolatas\ LGC:h10&#xA;&#xA;&quot; ===== LINE BREAKS =====&#xA;set wrap linebreak nolist&#xA;&#xA;&quot; ===== COLORSCHEMES =====&#xA;set term=xterm&#xA;set t_Co=256&#xA;call ActivateSyntaxHighlighting()&#xA;set termguicolors&#xA;colorscheme quantum&#xA;&#xA;&#xA;&quot; ===== RAINBOW PARENTHESES =====&#xA;&quot; activate rainbow parentheses&#xA;&quot;au VimEnter * RainbowParenthesesToggle&#xA;&quot;au Syntax * RainbowParenthesesLoadRound&#xA;&quot;au Syntax * RainbowParenthesesLoadSquare&#xA;&quot;au Syntax * RainbowParenthesesLoadBraces&#xA;&#xA;&quot; ===== NERD TREE =====&#xA;&quot; NerdTree automatically opened&#xA;&quot; autocmd bufenter * if (winnr(&quot;$&quot;) == 1 &amp;amp;&amp;amp; exists(&quot;b:NERDTree&quot;) &amp;amp;&amp;amp; b:NERDTree.isTabTree()) | q | endif&#xA;&#xA;&quot; ===== TABS =====&#xA;call SetTabWidth(4, 1)&#xA;&#xA;filetype plugin on&#xA;set omnifunc=syntaxcomplete#Complete&#xA;filetype indent on&#xA;&#xA;&#xA;call KeyComboOptions()&#xA;&#xA;&quot; ===== SEARCH =====&#xA;set hlsearch&#xA;&#xA;&quot; ===== LINE NUMBERS  =====&#xA;set number&#xA;&#xA;&quot; ===== CURSOR =====&#xA;autocmd InsertEnter * set cul&#xA;autocmd InsertLeave * set nocul&#xA;&#xA;&quot; ===== MOUSE =====&#xA;&quot;set mouse=n&#xA;&quot;set ttymouse=xterm2&#xA;&#xA;&quot; ===== FOLDING =====&#xA;set foldmethod=indent   &#xA;set foldnestmax=10&#xA;set nofoldenable&#xA;set foldlevel=2&#xA;&#xA;&quot; ===== LANGUAGE =====&#xA;set spelllang=en_us&#xA;&quot; set spelllang=de_de&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am only setting this when a markdown file is entered.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Additional Information&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;output of &lt;code&gt;echo $TERM&lt;/code&gt;: &lt;code&gt;xterm-256color&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;output of &lt;code&gt;echo &amp;amp;t_Co&lt;/code&gt;: &lt;code&gt;256&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;output of &lt;code&gt;:verbose :hi SpellBad&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SpellBad       xxx cterm=bold,underline ctermfg=196&#xA;    Last set from ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I figured something out when I disabled all the color settings in my vimrc and then checked for the value of &lt;code&gt;:verbose :hi SpellBad&lt;/code&gt;. The setting then contains &lt;code&gt;guifg&lt;/code&gt; and &lt;code&gt;guibg&lt;/code&gt; values! However, I am not using &lt;code&gt;gvim&lt;/code&gt;, but simply &lt;code&gt;vim&lt;/code&gt; in the terminal, so I have no idea how that can be. If I set &lt;code&gt;guifg&lt;/code&gt;, the setting is applied as it should have been with &lt;code&gt;ctermfg&lt;/code&gt;. However, not all colors seem to work. For example I can use &quot;words&quot; like &lt;code&gt;Red&lt;/code&gt; but not for example &lt;code&gt;196&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Why is Vim ignoring the color value, but does apply the bold and underline?&lt;/p&gt;&#xA;" OwnerUserId="9855" LastEditorUserId="9855" LastEditDate="2016-11-01T18:11:06.963" LastActivityDate="2016-11-02T15:47:37.803" Title="Vim ignoring ctermfg color value" Tags="|highlight|spell-checking|" AnswerCount="1" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10109" PostTypeId="2" ParentId="10098" CreationDate="2016-10-31T23:03:54.883" Score="13" Body="&lt;pre&gt;&lt;code&gt;:%! command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;pipes the current file's contents to &lt;code&gt;command&lt;/code&gt;'s stdin, and replaces the file's contents with &lt;code&gt;command&lt;/code&gt;'s stdout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;:%! sort&lt;/code&gt; is pretty much the same as (from a shell) &lt;code&gt;cat file | sort &amp;gt; tmp &amp;amp;&amp;amp; mv tmp file&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="9024" LastEditDate="2019-12-13T16:27:25.497" LastActivityDate="2019-12-13T16:27:25.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10110" PostTypeId="2" ParentId="10072" CreationDate="2016-11-01T13:14:55.003" Score="2" Body="&lt;p&gt;For whatever reason it doesn't seem to see VimPlug with the first symbolic link I had in my post. This is the only plugin I couldn't get to work in neovim with it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So instead of making a symbolic link of &lt;code&gt;~/.vim&lt;/code&gt; to &lt;code&gt;~/.config/nvim&lt;/code&gt;. I decided to make a symbolic link of &lt;code&gt;~/.vim&lt;/code&gt; to &lt;code&gt;~/.config/&lt;/code&gt; (&lt;em&gt;note that I'm truncating the&lt;/em&gt; &lt;code&gt;nvim&lt;/code&gt; &lt;em&gt;part&lt;/em&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in terminal that will be &lt;code&gt;ln -s ~/.vim ~/.config/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll see that it'll create a folder symbolic link called &lt;code&gt;.vim&lt;/code&gt; rename it &lt;code&gt;nvim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then run this command &lt;code&gt;ln -s ~/.vimrc ~/.config/nvim/init.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will create a symbolic link of your &lt;code&gt;.vimrc&lt;/code&gt; named &lt;code&gt;init.vim&lt;/code&gt; inside that symbol link folder. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you go to your vanilla &lt;code&gt;.vim&lt;/code&gt; folder in your home directory you'll notice a &lt;code&gt;init.vim&lt;/code&gt; there as well. &lt;strong&gt;DON'T&lt;/strong&gt; delete this. Deleting this would result in the one you just created to get deleted, since putting a file in the folder your linking is basically putting it in that folder as well. This is the only way I got it to work without putting &lt;code&gt;plug.vim&lt;/code&gt; in the nvim's system wide autoload folder.&lt;/p&gt;&#xA;" OwnerUserId="9885" LastActivityDate="2016-11-01T13:14:55.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10111" PostTypeId="1" AcceptedAnswerId="10113" CreationDate="2016-11-01T13:33:11.173" Score="2" ViewCount="6187" Body="&lt;p&gt;I am using Ubuntu 16.04. I installed Neovim using apt-get. I downloaded the plug.vim script &amp;amp; put it into the &lt;code&gt;autoload&lt;/code&gt; folder in &lt;code&gt;~/.config/nvim&lt;/code&gt;. I put the following in my &lt;code&gt;init.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin()&#xA;Plug 'https://github.com/luochen1990/rainbow.git'&#xA;Plug 'https://github.com/davisdude/vim-love-docs.git'&#xA;Plug 'https://github.com/morhetz/gruvbox.git'&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did &lt;code&gt;:PlugInstall&lt;/code&gt;. The plugins were installed &amp;amp; show OK in &lt;code&gt;:PlugStatus&lt;/code&gt;. But they are not working. As in nothing's changed at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am new to both Vim &amp;amp; Neovim. I tried googling for a solution but there is almost no information on Neovim. &lt;/p&gt;&#xA;" OwnerUserId="9938" LastEditorUserId="5395" LastEditDate="2016-11-01T21:49:17.630" LastActivityDate="2017-07-22T13:48:29.957" Title="Neovim: plugins installed but not working" Tags="|neovim|plugin-vim-plug|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10112" PostTypeId="2" ParentId="10111" CreationDate="2016-11-01T14:19:27.067" Score="0" Body="&lt;p&gt;From the &lt;a href=&quot;https://github.com/neovim/neovim/wiki/FAQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;NeoVim FAQ&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Can I use Lua-based Vim plugins (e.g. neocomplete)?&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Not yet. The legacy Vim if_lua interface is not (yet) supported.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim-love-docs&lt;/code&gt; is Lua-based, so that is likely why that plugin does not appear to be working. If something is failing in the loading of that plugin, it &lt;em&gt;may&lt;/em&gt; affect the loading of subsequent plugins (don't quote me on that though; I'm not intimately familiary with the inner workings of the plugin system).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, there are various parts of &lt;code&gt;vim&lt;/code&gt; that are &lt;a href=&quot;https://neovim.io/doc/user/vim_diff.html#nvim-features-changed&quot; rel=&quot;nofollow noreferrer&quot;&gt;changed&lt;/a&gt;, &lt;a href=&quot;https://neovim.io/doc/user/vim_diff.html#nvim-features-missing&quot; rel=&quot;nofollow noreferrer&quot;&gt;not yet implemented&lt;/a&gt; or &lt;a href=&quot;https://neovim.io/doc/user/vim_diff.html#nvim-features-removed&quot; rel=&quot;nofollow noreferrer&quot;&gt;removed&lt;/a&gt;. I did not examine the source of the plugins you are using, but if they utilize any of the features you may see undefined behavior as a result. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend uninstalling all of the plugins then reinstalling the two that are not Lua-based one at a time.&lt;/p&gt;&#xA;" OwnerUserId="1166" LastActivityDate="2016-11-01T14:19:27.067" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10113" PostTypeId="2" ParentId="10111" CreationDate="2016-11-01T16:28:48.893" Score="3" Body="&lt;p&gt;My guess is that you haven't activated the plug-ins. In the &lt;code&gt;rainbow&lt;/code&gt; case you should add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:rainbow_active = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your init file (Neovim's one is located in &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt;). In case of &lt;code&gt;gruvbox&lt;/code&gt; you should add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme gruvbox &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usually it's done after the &lt;code&gt;plug#end()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for &lt;code&gt;vim-love-docs&lt;/code&gt;, the GitHub code only includes the code for &lt;strong&gt;generating&lt;/strong&gt; the plugin. From the GitHub page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vundle: Clone the repo and follow the instructions below to generate the documentation (or download from vim.org). Then activate it using &lt;code&gt;Plugin 'file:///home/gmarik/path/to/plugin&lt;/code&gt;'. See &lt;code&gt;:h vundle&lt;/code&gt; for more.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="786" LastEditorUserId="13535" LastEditDate="2017-07-22T13:48:29.957" LastActivityDate="2017-07-22T13:48:29.957" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10114" PostTypeId="1" CreationDate="2016-11-01T19:28:54.383" Score="6" ViewCount="1695" Body="&lt;p&gt;I use syntastic and split windows heavily in my vim workflow.  Lately, syntax highlighting will vanish, seemingly at random, in one of my windows, usually after opening a new split.  This happens with the highlighting of js files, ruby files, even the highlighting on a vim documentation file opened through a &lt;code&gt;:help&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:syntax enable&lt;/code&gt; or &lt;code&gt;:syntax sync from start&lt;/code&gt; will, rather than solving the problem, cause it to spread, so that &lt;em&gt;all&lt;/em&gt; open windows lose syntax highlighting, rather than just the single window where the problem started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that this is may not be enough information to help me troubleshoot, but I don't even know where to begin to track down the root problem, since it happens sporadically -- once or twice a day I'd say, without any apparent pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any clues about what might be the cause, or how I should approach debugging the problem, would be helpful.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Additional Info About Plugins&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find ~/.vim -type d -name syntax&#xA;/Users/jg/.vim/bundle/neosnippet.vim/syntax&#xA;/Users/jg/.vim/bundle/scss-syntax.vim/syntax&#xA;/Users/jg/.vim/bundle/tagbar/syntax&#xA;/Users/jg/.vim/bundle/unite.vim/syntax&#xA;/Users/jg/.vim/bundle/vim-coloresque/after/syntax&#xA;/Users/jg/.vim/bundle/vim-css-color/after/syntax&#xA;/Users/jg/.vim/bundle/vim-javascript-syntax/syntax&#xA;/Users/jg/.vim/bundle/vim-slim/syntax&#xA;/Users/jg/.vim/bundle/Vundle.vim/syntax&#xA;/Users/jg/.vim/syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5373" LastEditorUserId="5373" LastEditDate="2016-11-28T03:51:31.600" LastActivityDate="2016-11-28T03:51:31.600" Title="Syntax highlighting randomly turns off" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10115" PostTypeId="1" AcceptedAnswerId="10119" CreationDate="2016-11-02T15:32:09.193" Score="4" ViewCount="1289" Body="&lt;p&gt;I am scripting a diff program between two longs paths and want one file to be read-only and the other to be read-write. e.g. I want to run something like &lt;code&gt;srcdiff test.c&lt;/code&gt; and my script will expand that to &lt;code&gt;vimdiff test.c /long/path/to/other/test.c&lt;/code&gt; I would like &lt;code&gt;/long/path/to/other/test.c&lt;/code&gt; to be read-only and &lt;code&gt;test.c&lt;/code&gt; to be read-write. I can accomplish this by doing &lt;code&gt;:set ro&lt;/code&gt; however I would have to do this every time I open a file. I tried &lt;code&gt;vimdiff test.c -R /long/path/to/other/test.c&lt;/code&gt; but that opened both files as read-only. Is it possible to accomplish this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using version &lt;code&gt;VIM - Vi IMproved 6.2 (2003 Jun 1, compiled Sep 16 2003 11:00:10)&lt;/code&gt; on EL3 so updates are not exactly possible.&lt;/p&gt;&#xA;" OwnerUserId="9958" LastActivityDate="2016-11-02T16:26:05.107" Title="vimdiff two files, one ro the other rw" Tags="|vimdiff|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10116" PostTypeId="2" ParentId="10108" CreationDate="2016-11-02T15:47:37.803" Score="3" Body="&lt;p&gt;If you use the &lt;code&gt;termguicolors&lt;/code&gt; option you want to use the guifg and guibg attributes of the highlighting definitions. Because that is what this option efectively does: use rgb coloring in the terminal.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-11-02T15:47:37.803" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10117" PostTypeId="2" ParentId="10107" CreationDate="2016-11-02T15:55:25.607" Score="1" Body="&lt;p&gt;You need to enable line numbering by calling &lt;code&gt;:set nu&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ printf '%s\n' 'set nu' '%s/Quux/Foo/g' %p 'q!' | ex file.txt&#xA;     1  Foo Bar&#xA;     2  Foo Foo Bar Bar&#xA;     4  Bar Bar Bar&#xA;     5  Foo Foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-11-02T15:55:25.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10118" PostTypeId="2" ParentId="10099" CreationDate="2016-11-02T16:18:18.817" Score="4" Body="&lt;p&gt;Typing the &lt;code&gt;#&lt;/code&gt; character causes an outdent because you have set &lt;code&gt;'smartindent'&lt;/code&gt;, which is designed for C-like languages (where &lt;code&gt;#&lt;/code&gt; indicates the start of a preprocessor directive).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quoting from the output of &lt;code&gt;:help 'smartindent'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When typing '#' as the first character in a new line, the indent for&#xA;      that line is removed, the '#' is put in the first column.  The indent&#xA;      is restored for the next line.  &lt;strong&gt;If you don't want this, use this&#xA;      mapping: &quot;:inoremap # X^H#&quot;, where ^H is entered with CTRL-V CTRL-H.&lt;/strong&gt;&#xA;      When using the &quot;&gt;&gt;&quot; command, lines starting with '#' are not shifted&#xA;      right.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(emphasis mine)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wish to continue using &lt;code&gt;'cindent'&lt;/code&gt; but want a better way of setting it than an autocommand, you can simply place a file containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal cindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the location: &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could simply turn off &lt;code&gt;'smartindent'&lt;/code&gt; and use &lt;code&gt;'autoindent'&lt;/code&gt;, or, perhaps best, look into obtaining a plugin that is designed specifically to implement Python indentation. &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=974&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here's one&lt;/a&gt;. &lt;a href=&quot;https://github.com/hynek/vim-python-pep8-indent&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here's another&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2016-11-02T16:18:18.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10119" PostTypeId="2" ParentId="10115" CreationDate="2016-11-02T16:26:05.107" Score="6" Body="&lt;p&gt;You can use startup commands to do this. From &lt;code&gt;:h -c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+{command}                      *-+c* *-c*&#xA;-c {command}    {command} will be executed after the first file has been&#xA;        read (and after autocommands and modelines for that file have&#xA;        been processed).  &quot;command&quot; is interpreted as an Ex command.&#xA;        If the &quot;command&quot; contains spaces, it must be enclosed in&#xA;        double quotes (this depends on the shell that is used).&#xA;        Example: &amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you could do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff file1 file2 -c &quot;wincmd l&quot; -c &quot;se ro&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this does is essentially running &lt;code&gt;:wincmd l&lt;/code&gt; (equivalent to &lt;code&gt;&amp;lt;C-w&amp;gt;l&lt;/code&gt;, i.e. move one split to the right) to move to your second file, and then running &lt;code&gt;:se ro&lt;/code&gt; on this secondary file.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-11-02T16:26:05.107" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10120" PostTypeId="2" ParentId="10090" CreationDate="2016-11-02T17:20:30.280" Score="2" Body="&lt;p&gt;Looks like you can't do this, see &lt;a href=&quot;http://vimhelp.appspot.com/spell.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h spell.txt&lt;/code&gt;&lt;/a&gt; (emphasis mine):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;WORDS&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Vim uses a fixed method to recognize a word&lt;/strong&gt;.  This is independent of&#xA;  &lt;code&gt;'iskeyword'&lt;/code&gt;, so that it also works in help files and for languages that&#xA;  include characters like &lt;code&gt;'-'&lt;/code&gt; in &lt;code&gt;'iskeyword'&lt;/code&gt;.  The word characters do depend on &lt;code&gt;'encoding'&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="860" LastActivityDate="2016-11-02T17:20:30.280" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10121" PostTypeId="2" ParentId="10104" CreationDate="2016-11-02T17:34:13.360" Score="0" Body="&lt;p&gt;Solution: search partition for fragments of the file using &lt;code&gt;strings&lt;/code&gt;, then pass the returned offset to &lt;code&gt;dd&lt;/code&gt; as described here: &lt;a href=&quot;https://unix.stackexchange.com/a/320150/176250&quot;&gt;https://unix.stackexchange.com/a/320150/176250&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9928" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2016-11-02T17:34:13.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10122" PostTypeId="1" AcceptedAnswerId="10134" CreationDate="2016-11-02T17:43:25.740" Score="1" ViewCount="176" Body="&lt;p&gt;The question is more or less in the title, until recently I have the feeling that I got a fairly large number of visible tabs in any window of MacVim. I either updated MacVim or my system or something and now I can only get 5 visible tabs in a 90 character wide window. Is there any way to increase this number? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using MacVim Custom Version 8.0 (113), if that helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To better explain what I mean I have attached a picture, I have opened six tabs but only five are visible (called one, two, three, and so on). The sixth and all subsequent tabs are inside the &gt;&gt;. I'd like to be able to have more than 5 tabs visible at any given time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1us5d.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1us5d.jpg&quot; alt=&quot;Picture of the problem&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9959" LastEditorUserId="9959" LastEditDate="2016-11-02T21:58:34.240" LastActivityDate="2016-11-02T23:17:52.273" Title="Is it possible to increase the number of visible tabs in MacVim (without changing the window width)?" Tags="|macvim|tabbed-user-interface|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10123" PostTypeId="1" CreationDate="2016-11-02T17:46:32.547" Score="0" ViewCount="349" Body="&lt;p&gt;Is it possible to generate ctags for QML? Except for writing the parser by my own? It is not in the list of supported languages on &lt;a href=&quot;http://ctags.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://ctags.sourceforge.net/&lt;/a&gt; but I still hope there is a chance to avoid writing my own parser.&lt;/p&gt;&#xA;" OwnerUserId="9960" LastActivityDate="2016-11-02T19:11:51.440" Title="Generate ctags for QML" Tags="|ctags|" AnswerCount="1" CommentCount="1" ClosedDate="2016-11-03T02:33:38.687" ContentLicense="CC BY-SA 3.0" />
  <row Id="10124" PostTypeId="1" AcceptedAnswerId="10125" CreationDate="2016-11-02T18:44:33.670" Score="77" ViewCount="48403" Body="&lt;p&gt;I see one of these two lines in &lt;code&gt;.vimrc&lt;/code&gt; files. This one seems to be most common:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how does it differ from this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've found &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/filetype.html#:filetype-indent-on&quot; rel=&quot;noreferrer&quot;&gt;documentation for the latter&lt;/a&gt;, but I'm still confused.&lt;/p&gt;&#xA;" OwnerUserId="7244" LastActivityDate="2016-11-07T10:50:38.747" Title="What is the difference between `filetype plugin indent on` and `filetype indent on`?" Tags="|indentation|filetype|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10125" PostTypeId="2" ParentId="10124" CreationDate="2016-11-02T18:58:42.343" Score="89" Body="&lt;p&gt;&lt;code&gt;filetype plugin indent on&lt;/code&gt; is like a combination of these commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype on&#xA;filetype plugin on&#xA;filetype indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It turns on &quot;detection&quot;, &quot;plugin&quot; and &quot;indent&quot; at once. You can check for yourself by reading &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/filetype.html#:filetype-overview&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :filetype-overview&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Detection&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;What does filetype &quot;detection&quot; do? From the docs:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Each time a new or existing file is edited, Vim will try to recognize the type&#xA;  of the file and set the 'filetype' option.  This will trigger the FileType&#xA;  event, which can be used to set the syntax highlighting, set options, etc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is less confusing if you realise that the &lt;code&gt;filetype&lt;/code&gt; command is distinct from the &lt;code&gt;filetype&lt;/code&gt; option. (The command &lt;code&gt;:filetype...&lt;/code&gt;, the option: &lt;code&gt;:set filetype...&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Plugin&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;What does the &quot;plugin&quot; part do? From the docs:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This actually loads the file &quot;ftplugin.vim&quot; in 'runtimepath'.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The result is that when a file is edited its plugin file is loaded (if there&#xA;  is one for the detected filetype).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The file being loaded is not necessarily named &lt;code&gt;ftplugin.vim&lt;/code&gt;, it could be &lt;code&gt;ftplugin/html_example.vim&lt;/code&gt; for instance.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Indent&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;What does the &quot;indent&quot; part do? From the docs:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This actually loads the file &quot;indent.vim&quot; in 'runtimepath'.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The result is that when a file is edited its indent file is loaded (if there&#xA;  is one for the detected filetype). indent-expression&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Again, the file may not be named &lt;code&gt;indent.vim&lt;/code&gt;, it could be named &lt;code&gt;indent/html_example.vim&lt;/code&gt; for instance.&lt;/p&gt;&#xA;" OwnerUserId="7244" LastEditorUserId="7244" LastEditDate="2016-11-07T10:50:38.747" LastActivityDate="2016-11-07T10:50:38.747" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10126" PostTypeId="2" ParentId="10123" CreationDate="2016-11-02T19:00:52.893" Score="1" Body="&lt;p&gt;You can add &lt;code&gt;ctags&lt;/code&gt; support for external languages not included on default parsing config. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ctags.sourceforge.net/EXTENDING.html&quot; rel=&quot;nofollow&quot;&gt;docs: extending ctags&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By using &lt;code&gt;--langdef=QML&lt;/code&gt; and then creating a regex to help define the types of patterns &lt;code&gt;ctags&lt;/code&gt; will parse as tags. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--langdef=QML&#xA;--langmap=QML:.QML,.qml&#xA;--regex-QML=/^qml tag definitions/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This extra config info needs to be stored in your home directory in file named &lt;code&gt;.ctags&lt;/code&gt;. (I don't know the Windows locations for this.)&lt;/p&gt;&#xA;" OwnerUserId="2303" LastEditorUserId="2303" LastEditDate="2016-11-02T19:11:51.440" LastActivityDate="2016-11-02T19:11:51.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10127" PostTypeId="1" AcceptedAnswerId="10130" CreationDate="2016-11-02T19:50:41.100" Score="5" ViewCount="2272" Body="&lt;p&gt;When I type &lt;code&gt;[[&lt;/code&gt; or &lt;code&gt;]]&lt;/code&gt; in normal mode, cursor is jumping previous / next &quot;class definition&quot; during editing python (.py) file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to map these shortcuts to &lt;code&gt;SHIFT + UP&lt;/code&gt; and &lt;code&gt;SHIFT + DOWN&lt;/code&gt;. And I added this to my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;S-Up&amp;gt; [[&#xA;nnoremap &amp;lt;S-Down&amp;gt; ]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I press &lt;code&gt;SHIFT + UP&lt;/code&gt;, cursor going beginning of the file, or if I press &lt;code&gt;SHIFT + DOWN&lt;/code&gt;, cursor going end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I map these keys?&lt;/p&gt;&#xA;" OwnerUserId="9965" LastEditorUserId="9965" LastEditDate="2016-11-02T20:10:59.090" LastActivityDate="2016-11-02T21:05:34.270" Title="How to map shortcut to double square brackets?" Tags="|key-bindings|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10128" PostTypeId="1" AcceptedAnswerId="10129" CreationDate="2016-11-02T20:15:35.757" Score="4" ViewCount="1747" Body="&lt;p&gt;I've created a blank &lt;code&gt;example.html&lt;/code&gt; file and I open it in Vim, and I add the following contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Still in insert mode, at the end of the line, if I press &lt;kbd&gt;enter&lt;/kbd&gt;, the new line will automatically be indented for when I type &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;        &amp;lt;p&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Clearly, something knows that &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; expects children, which should be indented, and is indenting the following line automatically for me. What is enabling this? How do I disable this, without disabling other automatic indentation features like &lt;code&gt;:set autoindent copyindent&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;:set smartindent?&lt;/code&gt; displays &lt;code&gt;nosmartindent&lt;/code&gt;, so it's not that.&lt;/p&gt;&#xA;" OwnerUserId="7244" LastActivityDate="2020-02-24T09:36:21.797" Title="How do I disable intelligent indentation in HTML files?" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10129" PostTypeId="2" ParentId="10128" CreationDate="2016-11-02T20:17:34.353" Score="8" Body="&lt;p&gt;It turns out that Vim ships with a bunch of &lt;code&gt;indent.vim&lt;/code&gt; files (enabled with &lt;code&gt;:filetype indent on&lt;/code&gt;), including one for HTML. You can read help for it at &lt;code&gt;:help html-indenting&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This HTML indent file sets &lt;code&gt;indentexpr&lt;/code&gt; option to a function that knows how to parse HTML. When &lt;code&gt;indentexpr&lt;/code&gt; is set, it overrules &lt;code&gt;cindent&lt;/code&gt; and &lt;code&gt;smartindent&lt;/code&gt;. If you want to disable it, run &lt;code&gt;:set indentexpr=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to always disable it, put this in your &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType html,htmldjango setlocal indentexpr=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7244" LastEditorUserId="7244" LastEditDate="2020-02-24T09:36:21.797" LastActivityDate="2020-02-24T09:36:21.797" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10130" PostTypeId="2" ParentId="10127" CreationDate="2016-11-02T21:05:34.270" Score="6" Body="&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;S-Up&amp;gt; [[&#xA;nnoremap &amp;lt;S-Down&amp;gt; ]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the non-recursive mappings above in your &lt;code&gt;vimrc&lt;/code&gt;, pressing &lt;code&gt;&amp;lt;S-Up&amp;gt;&lt;/code&gt; will be exactly like pressing &lt;code&gt;[[&lt;/code&gt; &lt;strong&gt;in its original meaning&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The original meaning of &lt;code&gt;[[&lt;/code&gt; is (quoting &lt;code&gt;:help [[&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[[    [count] sections backward or to the previous '{' in&#xA;      the first column.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which, usually, means &quot;jump to the first column of the first line&quot;. Same logic for &lt;code&gt;]]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are using non-recursive mappings, the original meaning of &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt; is used, not the remapped versions from the Python filetype plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need recursive mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;S-Up&amp;gt; [[&#xA;nmap &amp;lt;S-Down&amp;gt; ]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The rule is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use a recursive mapping only if you intend to use any other mapping in your mapping. Use non-recursive mappings if you don't.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-11-02T21:05:34.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10131" PostTypeId="2" ParentId="10122" CreationDate="2016-11-02T21:11:44.907" Score="0" Body="&lt;p&gt;There's the &lt;code&gt;tabpagemax&lt;/code&gt; option that limits the number of tab pages you can open with &lt;code&gt;$ vim -p *.txt&lt;/code&gt; to &lt;code&gt;10&lt;/code&gt; by default. But you can create as many tab pages as you want with &lt;code&gt;:tabnew&lt;/code&gt; or &lt;code&gt;:tabedit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which is one of the reasons why using tab pages as file proxy is a very bad idea.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-11-02T21:11:44.907" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10132" PostTypeId="1" AcceptedAnswerId="10144" CreationDate="2016-11-02T22:28:51.203" Score="6" ViewCount="2937" Body="&lt;p&gt;Lets say I have a line like the following in a vim syntax file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Emphasis &quot;\v\s+_\zs[^_\n]+\ze_\s+&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this line I'd like to create multiple capture groups:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the first underscore as &quot;EmphasisStartMarker&quot;&lt;/li&gt;&#xA;&lt;li&gt;the content between the two underscores as &quot;Emphasis&quot;&lt;/li&gt;&#xA;&lt;li&gt;the second underscore as &quot;EmphasisEndMarker&quot;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I know that &lt;code&gt;\zs&lt;/code&gt; starts matching and &lt;code&gt;\ze&lt;/code&gt; ends it. So I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match EmphasisStartMarker &quot;\v\s+\zs_\ze[^_\n]+_\s+&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match EmphasisEndMarker &quot;\v\s+_[^_\n]+\zs_\ze\s+&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this does not work, probably because somehow the start marker already consumes the content and the end marker text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could not find a description for matching capture groups and how to write that in a syntax file. I'd like to have something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match &quot;\v\s+(_)([^_\n]+)(_)\s+&quot;&#xA;1=EmphasisStartMarker&#xA;2=Emphasis&#xA;3=EmphasisEndMarker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know there is something with &lt;code&gt;region&lt;/code&gt; and &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt;, but that won't be useful if I have more than 3 capturing groups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is VIM's syntax for this? Is it possible? If not, how to workaround?&lt;/p&gt;&#xA;" OwnerUserId="9855" LastActivityDate="2016-11-04T08:11:37.277" Title="VIM syntax file, how to match capturing groups?" Tags="|syntax-highlighting|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10133" PostTypeId="1" AcceptedAnswerId="10135" CreationDate="2016-11-02T23:02:37.100" Score="2" ViewCount="193" Body="&lt;p&gt;I've started using vim for things besides programming, (taking notes, etc.) but something I haven't been able to replace final draft with vim yet just because there are so many things I need, so I was looking to see if any of you had taken a stab at this issue.Just to give you an idea of the features I am looking for: auto indention, different modes for different things like dialogue, character names, etc, changing my font to courier for specific. Another thing I'd like that I don't have in final draft is custom auto completion for commonly used words, names, and phrases. If something like this doesn't exist if you guys knew of any implementations of the features described above or resources to help me figure out how to implement them myself that would also be helpful. Also I use neovim if that matters.&lt;/p&gt;&#xA;" OwnerUserId="9966" LastActivityDate="2016-11-03T14:04:27.783" Title="Playwritting with vim" Tags="|neovim|" AnswerCount="1" CommentCount="2" ClosedDate="2016-11-03T02:33:23.313" ContentLicense="CC BY-SA 3.0" />
  <row Id="10134" PostTypeId="2" ParentId="10122" CreationDate="2016-11-02T23:17:52.273" Score="2" Body="&lt;p&gt;Apparently the minimum width of a tab is configurable, and set by default to 120 (pixels). It can be redefined by doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;defaults write org.vim.MacVim MMTabMinWidth 55&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where 55 is the minimum width of a tab in pixels. This allows me to get 11 tabs in a window of 90 characters, which solves my problem.&lt;/p&gt;&#xA;" OwnerUserId="9959" LastActivityDate="2016-11-02T23:17:52.273" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10135" PostTypeId="2" ParentId="10133" CreationDate="2016-11-03T01:00:54.740" Score="1" Body="&lt;p&gt;I think you could create your own filetype (.play?) and define custom indent and syntax for it. See &lt;code&gt;:help filetype&lt;/code&gt;, &lt;code&gt;:help indent&lt;/code&gt; and &lt;code&gt;:help syntax&lt;/code&gt;. You can also read the Steve Losh book &quot;Learn Vimscript the Hard Way&quot;. It has &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/44.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;some chapters on Vim filetypes&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim and Neovim inherit the font family and size from your terminal but you can use bold, italics and two types of underline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;ins-completion&lt;/code&gt; feature provides dictionary completion. You can add &lt;code&gt;k{dict}&lt;/code&gt; to your &lt;code&gt;$MYVIMRC&lt;/code&gt; file like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set complete=ken,kes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now, when you press Ctrl+N in insertion mode a pop-up with words from English and Spanish will appear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'complete'&lt;/code&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you are using Neovim I recomend you to try &lt;a href=&quot;https://github.com/Shougo/deoplete.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;deoplete&lt;/a&gt;, an asynchronous auto-completion engine. It provides dictionary completion among others an you can write your own sources. So, for dictionary completion you could declare something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:deoplete#sources={&#xA;  \ 'play': ['dictionary']&#xA;  \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="786" LastEditorUserId="786" LastEditDate="2016-11-03T14:04:27.783" LastActivityDate="2016-11-03T14:04:27.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10136" PostTypeId="1" AcceptedAnswerId="10142" CreationDate="2016-11-03T03:16:03.520" Score="4" ViewCount="1538" Body="&lt;p&gt;When using plain text I write bullet lists like this (second and further lines indented with two spaces):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* blah blah blah&#xA;  blah blah&#xA;&#xA;* yadda yadda yadda&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem is, when I start out a new bullet item:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* blah blah blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then press &lt;code&gt;Enter&lt;/code&gt;, the second line isn't automatically indented like I want it to be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* blah blah blah&#xA;blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since I have &lt;code&gt;autoindent&lt;/code&gt; set, once I correct the indentation of the second line the third and subsequent lines indent correctly.  Also, if I use &lt;code&gt;gq&lt;/code&gt; to format the bullet list item it will format it the way I want.  But I want vim to automatically handle it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I want the indentation mechanism to indent two spaces further if I hit &lt;code&gt;Enter&lt;/code&gt; when the first non-whitespace character on the line is a &lt;code&gt;*&lt;/code&gt;, to deal with nested bullet items.  For instance, if I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* blah blah&#xA;  * yadda yadda&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I hit &lt;code&gt;Enter&lt;/code&gt; at the end of the &quot;yadda&quot;s I want the indentation to be at 4 spaces instead of 2, so when I type more &quot;yadda&quot;s it comes out like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* blah blah&#xA;  * yadda yadda&#xA;    yadda yadda&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;formatexpr&lt;/code&gt; is unset and &lt;code&gt;formatoptions&lt;/code&gt; is &lt;code&gt;tcq&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9969" LastEditorUserId="9969" LastEditDate="2016-11-03T22:58:39.173" LastActivityDate="2016-11-03T22:58:39.173" Title="Autoindent second line of plain text bullet list item" Tags="|indentation|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10137" PostTypeId="1" AcceptedAnswerId="10139" CreationDate="2016-11-03T04:46:22.577" Score="1" ViewCount="2129" Body="&lt;p&gt;I'm having this characters '&gt;' when I'm tabbing using VIM. how can I remove this when tabbing? It's very annoying&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zKZUg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zKZUg.png&quot; alt=&quot;Screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9972" LastActivityDate="2016-11-03T05:41:24.860" Title="How to remove these characters when tabbing on VIM" Tags="|vimrc|macvim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10138" PostTypeId="1" AcceptedAnswerId="10140" CreationDate="2016-11-03T04:54:44.303" Score="0" ViewCount="564" Body="&lt;p&gt;I have a document containing these types of strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C(A,B)&#xA;&#xA;C(D,E)&#xA;&#xA;C(D,&#xA;E)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to replace every occurence of &lt;code&gt;C(...)&lt;/code&gt; with &lt;code&gt;\SC{...}&lt;/code&gt;, changing the &lt;code&gt;C&lt;/code&gt; in front of the bracket and the brackets themselves. The brackets can span multiple lines. How can this be done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: The document contained other types of brackets as well. They should not be replaced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea would be to iterate through occurences, and use the method described &lt;a href=&quot;https://stackoverflow.com/questions/25405072/quickest-way-to-change-a-pair-of-parenthesis-to-brackets-in-vim&quot;&gt;here&lt;/a&gt; to replace the brackets.&lt;/p&gt;&#xA;" OwnerUserId="8259" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-11-03T13:35:05.740" Title="Changing the type of brackets" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10139" PostTypeId="2" ParentId="10137" CreationDate="2016-11-03T05:41:24.860" Score="5" Body="&lt;p&gt;This is because of the &lt;code&gt;listchars&lt;/code&gt; option. The idea is that you can display certain whitespace characters (tab, space, newline, etc.) as a different character so you can see them better. I'm guessing if you type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set listchars?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you will see something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;listchars=tab:(that arrow)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as well as some other settings. To disable this, you can change what tabs are displayed as, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set listchars+=tab:\ \ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(note the trailing space)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or you may simply turn this off entirely by running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nolist&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Recommended reading: &lt;code&gt;:h 'list'&lt;/code&gt; and &lt;code&gt;:h listchars&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-11-03T05:41:24.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10140" PostTypeId="2" ParentId="10138" CreationDate="2016-11-03T08:22:53.767" Score="3" Body="&lt;p&gt;Based on the wording of your question, it seems like I can assume that &lt;code&gt;A&lt;/code&gt;, &lt;code&gt;B&lt;/code&gt;, &lt;code&gt;D&lt;/code&gt;, and &lt;code&gt;E&lt;/code&gt; are not expressions that themselves contain parantheses. Based on the comments, it might not be assumed. I therefore provide two answer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If there are not nested parantheses, then the following regular expression should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/C(\(\_[^)]\+\))/\\SC{\1}/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;\_&lt;/code&gt; allows the following atom to match across line boundaries, see &lt;code&gt;:h \_&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If there are nested parantheses, the substitution becomes very hard to do with a regular expression (at least in general). In this case, I would rather use a macro:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Put the cursor on a &lt;code&gt;C&lt;/code&gt;, then start recording with &lt;code&gt;qa&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Do: &lt;code&gt;s\SC&amp;lt;esc&amp;gt;&lt;/code&gt; to replace &lt;code&gt;C&lt;/code&gt; with &lt;code&gt;\SC&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Do: &lt;code&gt;l%r}&lt;/code&gt; to replace the last &lt;code&gt;)&lt;/code&gt; with &lt;code&gt;}&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Do: &lt;code&gt;&amp;lt;c-o&amp;gt;r{&lt;/code&gt; to replace the first &lt;code&gt;(&lt;/code&gt; with &lt;code&gt;{&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Search for next occurance: &lt;code&gt;/C(&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Stop recording: &lt;code&gt;q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now you may repeat the substitution with &lt;code&gt;@a&lt;/code&gt; and then &lt;code&gt;@@&lt;/code&gt; for the consecutive occurances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Here &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; is the literal escape character and &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; is &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;o&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2016-11-03T08:22:53.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10142" PostTypeId="2" ParentId="10136" CreationDate="2016-11-03T10:23:27.490" Score="4" Body="&lt;p&gt;You can get it to do so by adding &lt;code&gt;r&lt;/code&gt; to your &lt;code&gt;'formatoptions'&lt;/code&gt; and amending your &lt;code&gt;'comments'&lt;/code&gt; setting with the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set formatoptions+=r&#xA;set comments-=mb:*&#xA;set comments+=fb:*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(If you don't need to keep the rest of your &lt;code&gt;'comments'&lt;/code&gt; setting, you could of course just use the single command: &lt;code&gt;set comments=fb:*&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this alters the &lt;code&gt;*&lt;/code&gt; entry in your &lt;code&gt;comments&lt;/code&gt; to match the existing &lt;code&gt;-&lt;/code&gt; entry, which already indents in the manner you describe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some excerpts from &lt;code&gt;:help comments&lt;/code&gt; explain how this works:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim can automatically insert and format comments in a special way.  Vim&#xA;  recognizes a comment by a specific string at the start of the line (ignoring white space).  Three types of comments can be used:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;A comment string that repeats at the start of each line.  An example is the type of comment used in shell scripts, starting with &quot;#&quot;.&lt;/li&gt;&#xA;  &lt;li&gt;&lt;strong&gt;A comment string that occurs only in the first line, not in the following lines.  An example is this list with dashes.&lt;/strong&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The 'comments' option is a comma-separated list of parts.  Each part defines a type of comment string.  A part consists of:&#xA;    {flags}:{string}&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;{flags}:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;b Blank (,  or ) required after {string}.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;f Only the first line has the comment string.  Do not repeat comment on the next line, but preserve indentation &lt;strong&gt;(e.g., a bullet-list)&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(emphasis mine)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-11-03T10:28:44.530" LastActivityDate="2016-11-03T10:28:44.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10143" PostTypeId="2" ParentId="5110" CreationDate="2016-11-03T11:20:21.677" Score="0" Body="&lt;p&gt;Not an automatic method but the python Traceback states the line number --- 3 in your example --- and so invoking vim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$ vim +3 example.py&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;will open the &lt;code&gt;example.py&lt;/code&gt; with the cursor on the third line.&lt;/p&gt;&#xA;" OwnerUserId="9976" LastActivityDate="2016-11-03T11:20:21.677" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10144" PostTypeId="2" ParentId="10132" CreationDate="2016-11-03T12:34:47.577" Score="5" Body="&lt;p&gt;Yes, &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; cannot be used for this because the actual &lt;em&gt;match&lt;/em&gt; still is the full expression, as these special atoms just &quot;cut off&quot; parts of the result, but don't change the actual regular expression matching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use lookbehind / lookahead (&lt;code&gt;\@&amp;lt;=&lt;/code&gt; / &lt;code&gt;\@=&lt;/code&gt;) instead, but this usually is solved via syntax containment (&lt;code&gt;contains=&lt;/code&gt;), or priorization (&lt;code&gt;nextgroup=&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your example is pretty simple. Assuming you don't actually want different highlighting for the identical start and end markers, you can match the entire emphasis with your regexp and then contain the start and end markers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Emphasis &quot;\v\s+\zs_[^_\n]+_\ze\s+&quot; contains=EmphasisMarker&#xA;syntax match EmphasisMarker &quot;_&quot; contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works because the inner emphasis cannot include an &lt;code&gt;_&lt;/code&gt; character. If it could, I would have defined this the other way around:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match EmphasisMarker &quot;\v\s+\zs_[^_\n][^\n]+[^_\n]_\ze\s+&quot; contains=Emphasis&#xA;syntax match Emphasis &quot;\v[^_\n][^\n]+[^_\n]\ze_&quot; contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm still using &lt;code&gt;\z*&lt;/code&gt; to exclude the whitespace around it. Note that one usually uses &lt;code&gt;(^|\s)\zs...\ze(\s|$)&lt;/code&gt; (or &lt;code&gt;\&amp;lt;...\&amp;gt;&lt;/code&gt; if possible) to also allow matches at the start and end of the line. (But I don't know your exact syntax, so I kept this as it was.)&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2016-11-04T08:11:37.277" LastActivityDate="2016-11-04T08:11:37.277" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10146" PostTypeId="2" ParentId="9684" CreationDate="2016-11-03T17:02:28.563" Score="0" Body="&lt;p&gt;If you're using netrw to see the file you want opened: with the cursor atop the filename, press o (for a horizontal split window) or v (for a vertical split window).  See :help netrw-contents and  :help netrw-quickmaps .  (use p for a preview window)&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2016-11-03T17:02:28.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10147" PostTypeId="2" ParentId="5110" CreationDate="2016-11-03T18:08:23.750" Score="9" Body="&lt;p&gt;Vim comes with a set of &amp;quot;compiler&amp;quot; scripts, one of which is called &lt;a href=&quot;https://vimhelp.appspot.com/quickfix.txt.html#compiler-pyunit&quot; rel=&quot;noreferrer&quot;&gt;&amp;quot;pyunit&amp;quot;&lt;/a&gt;.  If you run &lt;code&gt;:compiler pyunit&lt;/code&gt; and then &lt;code&gt;:make&lt;/code&gt; (with your suggested value for &lt;code&gt;'makeprg'&lt;/code&gt;), quickfix is populated as you expect.  However, it only works well if there's one level to the stack trace.&lt;/p&gt;&#xA;&lt;p&gt;Improving that compiler script would be a useful exercise.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/mattboehm/vim-unstack&quot; rel=&quot;noreferrer&quot;&gt;unstack&lt;/a&gt; plugin may be of interest, as it provides a general mechanism to parse and view the locations reported in a stack trace and has Python support built in.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-11-03T18:08:23.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10148" PostTypeId="1" AcceptedAnswerId="10151" CreationDate="2016-11-03T20:16:46.317" Score="0" ViewCount="171" Body="&lt;p&gt;With the release of vim 8, I was wondering if there is a way to execute &lt;code&gt;:s&lt;/code&gt; or &lt;code&gt;:g&lt;/code&gt; asynchronously.&lt;/p&gt;&#xA;" OwnerUserId="7327" LastActivityDate="2016-11-03T23:09:49.057" Title="How to execute global/substitution command asynchronously?" Tags="|substitute|global-command|async|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10149" PostTypeId="1" CreationDate="2016-11-03T23:00:44.003" Score="0" ViewCount="42" Body="&lt;p&gt;I have tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight LineNr ctermbg=black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the problem is that apparently the color scheme I am using has changed the definition of &quot;black&quot;, so instead of being black the gutter is now some blue color.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2016-11-03T23:00:44.003" Title="Color line numbers part pitch black regardless of color scheme?" Tags="|command-line|colorscheme|" AnswerCount="0" CommentCount="4" ClosedDate="2016-11-08T22:21:35.347" ContentLicense="CC BY-SA 3.0" />
  <row Id="10150" PostTypeId="2" ParentId="10148" CreationDate="2016-11-03T23:09:37.923" Score="0" Body="&lt;p&gt;Vim 8 only permits to execute &lt;strong&gt;external&lt;/strong&gt; jobs asynchronously. Unfortunately, no vim ex command can be executed this way.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-11-03T23:09:37.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10151" PostTypeId="2" ParentId="10148" CreationDate="2016-11-03T23:09:49.057" Score="0" Body="&lt;p&gt;&lt;strong&gt;Short Answer:&lt;/strong&gt; No&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Long Answer:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Async supported add in vim 8 was for I/O. From &lt;code&gt;:h version8&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vim can now exchange messages with other processes in the background.  This&#xA;makes it possible to have servers do work and send back the results to Vim.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Theoretically the issue is that &lt;code&gt;:s&lt;/code&gt; and &lt;code&gt;:g&lt;/code&gt; operate on your current buffer. Doing work async would mean that the results would be overridden if you happened to modify the buffer before the &quot;async find-n-swap&quot; completed. You'd have to reload the buffer with &lt;code&gt;:e!&lt;/code&gt; and at that point you've lost the time gained by doing it async.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;s&gt;There is a function call &lt;code&gt;timer_start()&lt;/code&gt; which you could use to execute a viml function. Using a 0ms timeout would make the task execute immediately and in the background. While the theoretical issue still applies, you could write a function that takes a sequence of file names (from your args list or buffer list) and performs a &lt;code&gt;:s&lt;/code&gt; or &lt;code&gt;:g&lt;/code&gt; on them and then reload the files after it has completed.&lt;/s&gt; Rereading the documentation, it looks like if vim is &quot;busy&quot; the timeout might be longer, which makes it sound like the operation wouldn't be async and would stop you from inputting during the callback.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better option for that function would be to use &lt;code&gt;job_start()&lt;/code&gt; and call a system command to do the background file manipulation. Then use something like &lt;code&gt;sed&lt;/code&gt; or even better use &lt;code&gt;ex&lt;/code&gt; to perform the operations. Still have the issue with updating your current buffer since it will change in the background and now your buffer will be out of sync, but its an option.&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2016-11-03T23:09:49.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10152" PostTypeId="1" AcceptedAnswerId="10153" CreationDate="2016-11-04T00:48:09.240" Score="6" ViewCount="4206" Body="&lt;p&gt;If I try to indent a code using visual mode or &lt;code&gt;ggVG=&lt;/code&gt; vi automatically inserts 2 tabs instead of just 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// inside main&#xA;for (int i = 0; i &amp;lt; 10; i++) {&#xA;    test += i;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;changes to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        for (int i = 0; i &amp;lt; 10; i++) {&#xA;                int test = 2;&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are two tabs before &lt;code&gt;for&lt;/code&gt; and &lt;code&gt;int&lt;/code&gt;. I want a single tab. I have set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noexpandtab&#xA;set tabstop=4&#xA;set softtabstop=0&#xA;set smartindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is there any way to change the two tabs to one?&lt;/p&gt;&#xA;" OwnerUserId="9982" LastActivityDate="2016-11-04T01:16:26.813" Title="Vim indent using &quot;=&quot; inserts 2 tabs" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10153" PostTypeId="2" ParentId="10152" CreationDate="2016-11-04T01:16:26.813" Score="9" Body="&lt;p&gt;Your 'shiftwidth' appears to still be set to the default value of 8. Try changing that to 4 to match your 'tabstop' setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set shiftwidth=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'shiftwidth'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2016-11-04T01:16:26.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10155" PostTypeId="1" AcceptedAnswerId="10164" CreationDate="2016-11-04T07:32:28.027" Score="3" ViewCount="198" Body="&lt;p&gt;I want to execute two shell command at the same time in vim. So i use &lt;code&gt;|&lt;/code&gt; like below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   :!ls|!pwd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Its Returns the following error&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E34: No previous command&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But what happen ls output is forward to second command, because of the piping.&#xA;What this is the solution to solve this problem, How to execute two shell commands like this, to execute inside of vim&lt;/p&gt;&#xA;" OwnerUserId="7834" LastEditorUserId="7834" LastEditDate="2016-11-04T07:38:49.420" LastActivityDate="2016-11-04T10:04:37.937" Title="multiple shell command execution failed" Tags="|command-line|bash|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10156" PostTypeId="1" AcceptedAnswerId="10162" CreationDate="2016-11-04T07:39:02.170" Score="4" ViewCount="1891" Body="&lt;p&gt;Is there a plugin or way for me to alternate the background color for each line in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vmSqM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vmSqM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Previously I'd found &lt;a href=&quot;https://github.com/dahu/vim-zebra&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-zebra&lt;/a&gt; but this looks really ugly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/x1Q8r.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/x1Q8r.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd prefer the whole line to be colored, not just a part of it.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="205" LastEditDate="2017-03-08T14:22:49.147" LastActivityDate="2017-03-08T14:22:49.147" Title="Vim zebra line coloring?" Tags="|colorscheme|plugin-system|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10157" PostTypeId="1" AcceptedAnswerId="10160" CreationDate="2016-11-04T07:58:59.133" Score="0" ViewCount="366" Body="&lt;p&gt;My goal is to make a mapping, that depending on the value of &lt;code&gt;type&lt;/code&gt; in the yaml header, will run a command sourcing a file named the same as the value of &lt;code&gt;type&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have file containing a yaml header like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---&#xA;opt1: test&#xA;opt2: something else&#xA;type: mytemplate&#xA;--- &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I've made a mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;mp :w!&amp;lt;cr&amp;gt;:exe &quot;!command --template=/home/.../{}.ext -o &quot; . fnameescape(expand('%:p:r')) . &quot;.ext &quot; . fnameescape(expand('%:p'))&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the characters &lt;code&gt;{}&lt;/code&gt; should be replaced with the value of &lt;code&gt;type&lt;/code&gt;&#xA;I have succeeded in making a bashcript, that will get the value like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TYPE=$(egrep 'type:' filename.ext | awk -F 'type: ' '{print $2}')&#xA;command --template=/home/.../$TYPE.ext $@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'd like to do it purely in vim. I've tried using vim-grep, and got&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep 'type: ' % | %s=^\(type:\s\)\zs.*=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this is a substitution, and can't be used in the mapping.&#xA;Any help would be gratefully appreciated :-)&lt;/p&gt;&#xA;" OwnerDisplayName="user9985" LastEditorUserId="1841" LastEditDate="2016-11-04T08:35:38.213" LastActivityDate="2016-11-04T09:25:57.217" Title="vimscript parse yaml header and output to mapping" Tags="|key-bindings|vimscript|regular-expression|vimgrep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10158" PostTypeId="1" AcceptedAnswerId="10159" CreationDate="2016-11-04T08:02:28.067" Score="1" ViewCount="2069" Body="&lt;p&gt;I don't want &lt;code&gt;vim&lt;/code&gt; to be affected by my terminal's color scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, I want my &lt;code&gt;LineNr&lt;/code&gt; column to be colored black.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have seen it is possible because airline manages to do it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/USSjk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/USSjk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, my terminal seems to have changed the meanings of &lt;code&gt;black&lt;/code&gt;, &lt;code&gt;blue&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/b2QEz.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/b2QEz.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2016-11-04T08:55:43.443" Title="Vim ignore terminal color schemes when setting colors" Tags="|vimrc|colorscheme|line-numbers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10159" PostTypeId="2" ParentId="10158" CreationDate="2016-11-04T08:55:43.443" Score="3" Body="&lt;p&gt;By using color names like &lt;code&gt;cyan&lt;/code&gt; or &lt;code&gt;black&lt;/code&gt; or numbers below &lt;code&gt;16&lt;/code&gt; you are actively telling Vim to use your terminal color scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want Vim to use your terminal emulator color scheme you will have to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;make sure your &lt;code&gt;$TERM&lt;/code&gt; contains the string &lt;code&gt;-256color&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;use color numbers from 16 to 255.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For 1, possible values are &lt;code&gt;xterm-256color&lt;/code&gt;, &lt;code&gt;screen-256color&lt;/code&gt; (in screen and tmux), &lt;code&gt;rxvt-unicode-256color&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For 2, you can use &lt;a href=&quot;https://en.wikipedia.org/wiki/File:Xterm_256color_chart.svg&quot; rel=&quot;nofollow noreferrer&quot;&gt;this handy chart&lt;/a&gt; for reference.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-11-04T08:55:43.443" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10160" PostTypeId="2" ParentId="10157" CreationDate="2016-11-04T09:02:57.353" Score="1" Body="&lt;p&gt;What about using a function to do so?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SourceByType()&#xA;    &quot; save position&#xA;    let savePosition = getpos('.')&#xA;&#xA;    &quot; Get the line containing the type&#xA;    normal! gg&#xA;    let line = search('^type: .*\n---', 'W') &#xA;&#xA;    &quot; no type found: abort&#xA;    if (line == 0)&#xA;        echo &quot;no type found&quot;&#xA;        return 1&#xA;    endif&#xA;&#xA;    &quot; Get the type&#xA;    let type = matchlist(getline(line), 'type: \(.*\)')[1]&#xA;&#xA;    &quot; Execute the commands&#xA;    execute ':w!'&#xA;    execute '!command --template=/home/.../'. type . '.ext -o ' . fnameescape(expand('%:p:r')) . '.ext ' . fnameescape(expand('%:p'))&#xA;&#xA;    &quot; restore position&#xA;    call setpos('.', savePosition)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And a mapping calling the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;mp :call SourceByType()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What the function does:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Saves the position of the cursor&lt;/li&gt;&#xA;&lt;li&gt;Goes to the top of the file&lt;/li&gt;&#xA;&lt;li&gt;Searches for a line containing &lt;code&gt;type: something&lt;/code&gt; followed by a line containing &lt;code&gt;---&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;If no line was found, stop the execution&lt;/li&gt;&#xA;&lt;li&gt;Matches the &lt;code&gt;something&lt;/code&gt; in &lt;code&gt;type: something&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Executes your commands replacing &lt;code&gt;{}&lt;/code&gt; by the type found.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-11-04T09:25:57.217" LastActivityDate="2016-11-04T09:25:57.217" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10161" PostTypeId="1" AcceptedAnswerId="10163" CreationDate="2016-11-04T09:46:01.623" Score="25" ViewCount="5410" Body="&lt;p&gt;An editing pattern I frequently run into is the following: I want to yank a piece of text inside quotes or brackets, and replace that piece of text inside another pair of quotes/brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I want to copy the the class name &lt;code&gt;foo bar&lt;/code&gt; and paste that somewhere else:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;span class=&quot;foo bar&quot;&amp;gt;&#xA;&#xA;&amp;lt;div class=&quot;this-should-be-replaced-with-foo-and-bar&quot;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I know is this: If I move inside the span's class, I use &lt;code&gt;yi&quot;&lt;/code&gt; to yank the text inside the quotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I have this in my register, so I should be able to replace the class content of the div with it. But I can't find a handy way of doing this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use &lt;code&gt;ciw&lt;/code&gt; this ends up overwriting my register with content to change, so I loose my yanked text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best thing I can come up with is moving to the first quote of the div's class, hitting &lt;code&gt;p&lt;/code&gt;, then deleting to the next quote with &lt;code&gt;dt&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually I screw up my position though, and I paste it somewhere inside the quotes merging the two strings, and it is messing things up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm hoping there's some way to do a &quot;replace the inner text with my yanked content please&quot; combination to make this easier.&lt;/p&gt;&#xA;" OwnerUserId="8831" LastEditorUserId="927" LastEditDate="2016-11-05T16:09:02.183" LastActivityDate="2016-11-05T16:50:30.157" Title="How to replace inner text with yanked text" Tags="|cursor-movement|cut-copy-paste|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10162" PostTypeId="2" ParentId="10156" CreationDate="2016-11-04T09:46:42.553" Score="5" Body="&lt;p&gt;It is possible using my plugin &lt;a href=&quot;https://github.com/chrisbra/DynamicSigns&quot; rel=&quot;noreferrer&quot;&gt;DynamicSigns&lt;/a&gt;. Quoting from the README:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h2&gt;2.7 Alternating colors&lt;/h2&gt;&#xA;  &#xA;  &lt;p&gt;You can also set up the plugin to color the lines in your buffer in alternating colors. To do so, set the&#xA;  g:Signs_Alternate variable in your |.vimrc| like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:Signs_Alternate = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This will display each even line nummer in one color and each odd line&#xA;  number in a different color.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Run :UpdateSigns or :Signs to update displaying the signs in your&#xA;  buffer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-11-04T09:46:42.553" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="10163" PostTypeId="2" ParentId="10161" CreationDate="2016-11-04T09:53:23.247" Score="31" Body="&lt;p&gt;You can use &lt;code&gt;vi&quot;p&lt;/code&gt; when inside &lt;code&gt;&quot;&quot;&lt;/code&gt;. This can replace text in yank register, so it matters when you want to use original yanked text more than once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&#xA;Additional info from Octaviour comment regarding making it reusable more than once:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In order to do that I would yank to a named register, which makes the two commands: &lt;code&gt;&quot;ayi&quot;&lt;/code&gt; and and &lt;code&gt;vi&quot;&quot;ap&lt;/code&gt; if you use register &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2016-11-04T11:19:02.027" LastActivityDate="2016-11-04T11:19:02.027" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10164" PostTypeId="2" ParentId="10155" CreationDate="2016-11-04T10:04:37.937" Score="4" Body="&lt;p&gt;Quoting from the &lt;a href=&quot;https://vimhelp.appspot.com/various.txt.html#E34&quot; rel=&quot;nofollow noreferrer&quot;&gt;help&lt;/a&gt; (&lt;code&gt;:h E34&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Any '!' in {cmd} is replaced with the previous external command&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And further in the &lt;a href=&quot;https://vimhelp.appspot.com/cmdline.txt.html#:bar&quot; rel=&quot;nofollow noreferrer&quot;&gt;help&lt;/a&gt; (&lt;code&gt;:h :bar&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;These commands see the '|' as their argument, and can therefore not be&#xA;  followed by another Vim command:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[various other]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;:[range]!&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;To be able to use another command anyway, use the &quot;:execute&quot; command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So if you want to execute 2 shell commands in a row, you need to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;!ls&quot; | exe &quot;!pwd&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-11-04T10:04:37.937" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10165" PostTypeId="2" ParentId="10161" CreationDate="2016-11-04T10:15:42.303" Score="12" Body="&lt;p&gt;You can use the numbered register. First yank &quot;foo-bar&quot; with &lt;code&gt;yi&quot;&lt;/code&gt;, which will fill the &lt;code&gt;&quot;0&lt;/code&gt; register, see &lt;code&gt;:h &quot;0&lt;/code&gt;. Then do &lt;code&gt;ci&quot;&amp;lt;c-r&amp;gt;0&lt;/code&gt; to replace with the content of the register 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h i_CTRL-R&lt;/code&gt; for a description of the last part.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2016-11-04T10:48:25.513" LastActivityDate="2016-11-04T10:48:25.513" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10166" PostTypeId="2" ParentId="10161" CreationDate="2016-11-04T10:43:38.597" Score="9" Body="&lt;p&gt;Here is another solution. It's not the best in term of Vimgolf, but it uses the black hole register:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you're on the &lt;code&gt;foo bar&lt;/code&gt; string you can yank it normally using &lt;code&gt;yi&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then inside the brackets to change: &lt;code&gt;&quot;_di&quot;P&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;_       We will use the black hole register&#xA;di&quot;      Delete the inner brackets and put the deleted text in the black hole register&#xA;P        Put the previously yanked text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The advantage of the black hole register is that it will not mess your others registers. See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#quote_&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h quote_&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note that this answer is only here to talk about the black out register. I personally use visual selection as suggested by @grodzik.)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="927" LastEditDate="2016-11-05T16:08:51.757" LastActivityDate="2016-11-05T16:08:51.757" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10167" PostTypeId="1" AcceptedAnswerId="10173" CreationDate="2016-11-04T10:51:03.190" Score="7" ViewCount="3107" Body="&lt;p&gt;Is there way I can identify a window by a number in neovim and then jump to it with a macro ? Or better yet...Is there a way that I can identify which window is a terminal after calling the &lt;code&gt;:term&lt;/code&gt; command and then jump to it ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there's window number system in &lt;code&gt;tmux&lt;/code&gt; that's similar to that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is I wrote me a shell script that calls &lt;code&gt;cmake&lt;/code&gt; and &lt;code&gt;make&lt;/code&gt; and I plan on binding it to a key like &lt;kbd&gt;F5&lt;/kbd&gt; that runs it in the terminal. The problem is I want it where I'm able to automatically jump to the terminal window I called with &lt;code&gt;:term&lt;/code&gt; no matter which window I'm in or how my workspace looks like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible ?&lt;/p&gt;&#xA;" OwnerUserId="9885" LastActivityDate="2016-11-04T21:09:21.413" Title="Is there a way that I can identify which window is a terminal after calling the `:term` command in neovim?" Tags="|vimscript|neovim|terminal|macro|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10168" PostTypeId="2" ParentId="10103" CreationDate="2016-11-04T11:11:51.940" Score="5" Body="&lt;p&gt;Documentation of Vim plugins (rightfully) assumes that you know your way around Vim itself. I would therefore recommend that you start by finding your way around the Vim documentation and Vim itself. A good starting point for Vim itself is the Vim tutor which you can probably find by typing &quot;vimtutor&quot; (without the quotes) in a terminal. To understand what plugins are doing &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;this&quot;&gt;learning vimscript the hard way&lt;/a&gt; is a good starting point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer your direct question, &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; is a placeholder for your leader key. By default this is a backslash, so you would type \vv to execute the command (in normal mode). More info can be found if you type :help mapleader which tells you how to change it to whatever you like. You will find that the linked page treats leaders in chapter 6.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastEditorUserId="343" LastEditDate="2016-11-04T15:54:50.373" LastActivityDate="2016-11-04T15:54:50.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10169" PostTypeId="2" ParentId="10161" CreationDate="2016-11-04T13:03:44.353" Score="9" Body="&lt;p&gt;I need this so often, I wrote a plugin to simplify and allow maximum speed: &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2703&quot; rel=&quot;noreferrer&quot;&gt;ReplaceWithRegister&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin offers a two-in-one &lt;code&gt;gr&lt;/code&gt; command that replaces text covered by a {motion} / text object, entire line(s) or the current selection with the contents of a register; the old text is deleted into the black-hole register, i.e. it's gone. It transparently handles many corner cases and allows for a quick repeat via the standard &lt;code&gt;.&lt;/code&gt; command. Should you not like it, its page has links to alternatives.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-11-04T13:03:44.353" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10170" PostTypeId="2" ParentId="10167" CreationDate="2016-11-04T13:54:43.577" Score="2" Body="&lt;p&gt;You will need to write a function for that (&lt;a href=&quot;https://www.reddit.com/r/vim/comments/3aldvk/switch_to_a_split_depending_on_its_name/csdv7k8/&quot; rel=&quot;nofollow noreferrer&quot;&gt;taken from Reddit&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:win_by_bufname(bufname)&#xA;    let bufmap = map(range(1, winnr('$')), '[bufname(winbufnr(v:val)), v:val]')&#xA;    let thewindow = filter(bufmap, 'v:val[0] =~ a:bufname')[0][1]&#xA;    execute thewindow 'wincmd w'&#xA;endfunction&#xA;&#xA;command! -nargs=* WinGo call s:win_by_bufname(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The function in this script creates a list of [, ] entries by applying map() to the range of window numbers in the current tabpage. winnr('$') returns the number of windows in the tabpage. Then it finds the entry with the given buffer name, and extracts the associated window number. Then it jumps to that window.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need to modify it so it compares against the terminal buffer name (see below). Your key here will be the PID in that string. That PID corresponds to the process started along the terminal buffer and that's why it's the same during the terminal window lifetime.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Original answer&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Besides @statox's suggestion you also have the &lt;code&gt;:b&lt;/code&gt; command plus the terminal buffer name which is in the form &lt;code&gt;term://$CWD//$PID:$COMMAND&lt;/code&gt; (see &lt;code&gt;:h terminal-emulator&lt;/code&gt;) so you could call &lt;code&gt;:b {pid}&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="786" LastEditorUserId="786" LastEditDate="2016-11-04T16:18:36.833" LastActivityDate="2016-11-04T16:18:36.833" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10171" PostTypeId="1" CreationDate="2016-11-04T00:48:05.187" Score="0" ViewCount="604" Body="&lt;p&gt;I have installed python 3.5 from the official source, and everything was working.  I decided to try vim as a sort of command line IDE. Most plugins worked with vim, but when I tried &lt;code&gt;YouCompleteMe&lt;/code&gt; for text completion, vim had this import error in &lt;code&gt;messages&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 22, in &amp;lt;module&amp;gt;&#xA;  File &quot;/home/jack/.vim/bundle/YouCompleteMe/autoload/../python/ycm/base.py&quot;, line 27, in &amp;lt;module&amp;gt;&#xA;    from ycm import vimsupport&#xA;  File &quot;/home/jack/.vim/bundle/YouCompleteMe/autoload/../python/ycm/vimsupport.py&quot;, line 33, in &amp;lt;module&amp;gt;&#xA;    from ycmd.utils import ( GetCurrentDirectory, JoinLinesAsUnicode, ToBytes,&#xA;  File &quot;/home/jack/.vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd/ycmd/utils.py&quot;, line 30, in &amp;lt;module&amp;gt;&#xA;    import socket&#xA;  File &quot;/usr/local/lib/python3.5/socket.py&quot;, line 49, in &amp;lt;module&amp;gt;&#xA;    import _socket&#xA;ImportError: /usr/local/lib/python3.5/lib-dynload/_socket.cpython-35m-arm-linux-gnueabihf.so: undefined symbol: PyByteArray_Type&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/issues/2427&quot; rel=&quot;nofollow noreferrer&quot;&gt;This thread&lt;/a&gt; tells me that it isn't a problem with &lt;code&gt;vim&lt;/code&gt; or &lt;code&gt;YouCompleteMe&lt;/code&gt;, but a problem with the compatability between vim and my compilation of python 3.5.  What are the differences between the package for python 3.3 that is in &lt;code&gt;apt-get&lt;/code&gt; and the python 3.5 straight from python's website?  What are the additions that are made in the package that make it more compatible with vim?  Is there a special way to make python 3.5 compatible with vim and other linux features that I have not found yet?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, what would I have to do to make python 3.5 compatible with vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm on a raspberry pi running raspbian jessie.&lt;/p&gt;&#xA;" OwnerUserId="9994" OwnerDisplayName="Jack Hughes" LastEditorUserId="51" LastEditDate="2016-11-10T18:25:23.520" LastActivityDate="2016-11-10T18:25:23.520" Title="Vim problem installing python 3.5 from source" Tags="|plugin-you-complete-me|vimscript-python|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10172" PostTypeId="2" ParentId="10171" CreationDate="2016-11-04T01:34:28.900" Score="1" Body="&lt;p&gt;I don't have experience with Rasberry Pi but how about try to install python 3.5 using apt-get? I found that it's available in repository: &lt;a href=&quot;http://archive.raspbian.org/raspbian/pool/main/p/python3.5/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://archive.raspbian.org/raspbian/pool/main/p/python3.5/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="linevich" LastActivityDate="2016-11-04T01:34:28.900" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10173" PostTypeId="2" ParentId="10167" CreationDate="2016-11-04T21:09:21.413" Score="5" Body="&lt;p&gt;statox's comment works, but for what you want, it's not the best solution.  You can't simply check for &lt;code&gt;&amp;amp;buftype == 'terminal&lt;/code&gt;.  A terminal buffer could be created by a plugin such as &lt;a href=&quot;https://github.com/junegunn/fzf&quot; rel=&quot;noreferrer&quot;&gt;fzf&lt;/a&gt; and you could end up in a weird state if you blindly try to send text into it.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Plugin&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Probably the best option is to use the &lt;a href=&quot;https://github.com/kassio/neoterm&quot; rel=&quot;noreferrer&quot;&gt;neoterm&lt;/a&gt; plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;f5&amp;gt; :T make&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will run &lt;code&gt;make&lt;/code&gt; in the terminal buffer that's managed by &lt;code&gt;neoterm&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Manual method&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Although I think &lt;code&gt;neoterm&lt;/code&gt; will be best for your situation, I'm adding this for the sake of completeness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For you to be sure that a terminal is yours to do with as you please, you have a couple methods:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd TermOpen *:$SHELL,*:\$SHELL let b:my_term = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will set &lt;code&gt;b:my_term&lt;/code&gt; in a buffer that's created by &lt;code&gt;:term&lt;/code&gt; without arguments.  This isn't always reliable, since a plugin could run &lt;code&gt;:term&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=? MyTerm execute 'term &amp;lt;args&amp;gt;' | let b:my_term = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gives you a command that you can be 100% certain is yours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To find these buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let terms = filter(range(1, bufnr('$')),&#xA;      \ 'bufexists(v:val) &amp;amp;&amp;amp; getbufvar(v:val, &quot;my_term&quot;, 0)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gives you a list of buffers that have the &lt;code&gt;b:my_term&lt;/code&gt; variable set.  Also note that there are other terminal-specific variables that available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h terminal-emulator-status&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Terminal buffers maintain some information about the terminal in buffer-local&#xA;variables:&#xA;&#xA;- *b:term_title* The settable title of the terminal, typically displayed in&#xA;  the window title or tab title of a graphical terminal emulator. Programs&#xA;  running in the terminal can set this title via an escape sequence.&#xA;- *b:terminal_job_id* The nvim job ID of the job running in the terminal. See&#xA;  |job-control| for more information.&#xA;- *b:terminal_job_pid* The PID of the top-level process running in the&#xA;  terminal.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2016-11-04T21:09:21.413" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10174" PostTypeId="1" AcceptedAnswerId="10247" CreationDate="2016-11-04T21:42:53.337" Score="2" ViewCount="4205" Body="&lt;p&gt;I am using Vim version 7.4 from 2012-Dez-06 of Ubuntu 16.04, and I use PuTTY 0.67 on W10. I want to map the keys of the NUM pad in &lt;code&gt;.vimrc&lt;/code&gt;. This doesn't work:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;k1&amp;gt; COMMAND&#xA;map k1 COMMAND&#xA;map &amp;lt;C-k1&amp;gt; COMMAND&#xA;map &amp;lt;S-k1&amp;gt; COMMAND&#xA;map *keypad-1* COMMAND&#xA;map keypad-1 COMMAND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If I do for example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;map 1 dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;it works and the line is deleted if I hit &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If I hit in vi the NUM buttons I get q, r, s, t ... If I map &lt;code&gt;q&lt;/code&gt; to a command only the normal &lt;code&gt;q&lt;/code&gt; button will execute the command but not &lt;code&gt;1&lt;/code&gt; on the NUM pad.&#xA;My &lt;code&gt;.vimrc&lt;/code&gt; is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# cat ~/.vimrc&#xA;syntax on&#xA;set t_Co=256&#xA;colorscheme elflord&#xA;if &amp;amp;diff&#xA;    colorscheme apprentice&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The h keycodes (Thanks to Ashok) is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Notation        Bedeutung                   Äquivalent  Dezimale/r Wert/e   ~&#xA;-----------------------------------------------------------------------&#xA;&amp;lt;Nul&amp;gt;           Null                    CTRL-@    0 (gespeichert als 10) *&amp;lt;Nul&amp;gt;*&#xA;&amp;lt;BS&amp;gt;            Zeichenrückschritt      CTRL-H    8     *backspace*&#xA;&amp;lt;Tab&amp;gt;           Tabulator               CTRL-I    9     *tab* *Tab*&#xA;                                                        *linefeed*&#xA;&amp;lt;NL&amp;gt;            Zeilenvorschub          CTRL-J   10 (benutzt für &amp;lt;Nul&amp;gt;)&#xA;&amp;lt;FF&amp;gt;            Seitenvorschub          CTRL-L   12     *formfeed*&#xA;&amp;lt;CR&amp;gt;            Wagenrücklauf           CTRL-M   13     *carriage-return*&#xA;&amp;lt;Return&amp;gt;        dasselbe wie &amp;lt;CR&amp;gt;                               *&amp;lt;Return&amp;gt;*&#xA;&amp;lt;Enter&amp;gt;         dasselbe wie &amp;lt;CR&amp;gt;                               *&amp;lt;Enter&amp;gt;*&#xA;&amp;lt;Esc&amp;gt;           Fluchttaste             CTRL-[   27     *escape* *&amp;lt;Esc&amp;gt;*&#xA;&amp;lt;Space&amp;gt;         Leertaste                        32     *space*&#xA;&amp;lt;lt&amp;gt;            weniger-als             &amp;lt;        60     *&amp;lt;lt&amp;gt;*&#xA;&amp;lt;Bslash&amp;gt;        Backslash               \        92     *backslash* *&amp;lt;Bslash&amp;gt;*&#xA;&amp;lt;Bar&amp;gt;           vertikaler Strich       |       124     *&amp;lt;Bar&amp;gt;*&#xA;&amp;lt;Del&amp;gt;           Löschen                         127&#xA;&amp;lt;CSI&amp;gt;           Befehlsfolgeneinleiter  ALT-Esc 155     *&amp;lt;CSI&amp;gt;*&#xA;&amp;lt;xCSI&amp;gt;          CSI in der GUI getippt                  *&amp;lt;xCSI&amp;gt;*&#xA;&#xA;&amp;lt;EOL&amp;gt;           Zeilenende (kann &amp;lt;CR&amp;gt;, &amp;lt;LF&amp;gt; oder &amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt; sein, hängt ab vom&#xA;                System und 'fileformat')        *&amp;lt;EOL&amp;gt;*&#xA;&#xA;&amp;lt;Up&amp;gt;            Cursor rauf                     *cursor-up* *cursor_up*&#xA;&amp;lt;Down&amp;gt;          Cursor runter                   *cursor-down* *cursor_down*&#xA;&amp;lt;Left&amp;gt;          Cursor links                    *cursor-left* *cursor_left*&#xA;&amp;lt;Right&amp;gt;         Cursor rechts                   *cursor-right* *cursor_right*&#xA;&amp;lt;S-Up&amp;gt;          Umschalttaste Cursor rauf&#xA;&amp;lt;S-Down&amp;gt;        Umschalttaste Cursor runter&#xA;&amp;lt;S-Left&amp;gt;        Umschalttaste Cursor links&#xA;&amp;lt;S-Right&amp;gt;       Umschalttaste Cursor rechts&#xA;&amp;lt;C-Left&amp;gt;        Steuerung Cursor links&#xA;&amp;lt;C-Right&amp;gt;       Steuerung Cursor rechts&#xA;&amp;lt;F1&amp;gt; - &amp;lt;F12&amp;gt;    Funktionstaste 1 bis 12         *function_key* *function-key*&#xA;&amp;lt;S-F1&amp;gt; - &amp;lt;S-F12&amp;gt; Umschalttaste Funktionstaste 1 bis 12  *&amp;lt;S-F1&amp;gt;*&#xA;&amp;lt;Help&amp;gt;          Hilfetaste&#xA;&amp;lt;Undo&amp;gt;          Undo-Taste&#xA;&amp;lt;Insert&amp;gt;        Einfügetaste&#xA;&amp;lt;Home&amp;gt;          Anfang                          *home*&#xA;&amp;lt;End&amp;gt;           Ende                            *end*&#xA;&amp;lt;PageUp&amp;gt;        Bild rauf                               *page_up* *page-up*&#xA;&amp;lt;PageDown&amp;gt;      Bild runter                             *page_down* *page-down*&#xA;&amp;lt;kHome&amp;gt;         Anfang auf dem Ziffernblock (oben links)*keypad-home*&#xA;&amp;lt;kEnd&amp;gt;          Ende auf dem Ziffernblock (unten links) *keypad-end*&#xA;                                                        *keypad-page-up*&#xA;&amp;lt;kPageUp&amp;gt;       Bild rauf auf dem Ziffernblock (oben rechts)&#xA;                                                        *keypad-page-down*&#xA;&amp;lt;kPageDown&amp;gt;     Bild runter auf dem Ziffernblock (unten rechts)&#xA;&amp;lt;kPlus&amp;gt;         + auf dem Ziffernblock                  *keypad-plus*&#xA;&amp;lt;kMinus&amp;gt;        - auf dem Ziffernblock                  *keypad-minus*&#xA;&amp;lt;kMultiply&amp;gt;     * auf dem Ziffernblock                  *keypad-multiply*&#xA;&amp;lt;kDivide&amp;gt;       / auf dem Ziffernblock                  *keypad-divide*&#xA;&amp;lt;kEnter&amp;gt;        Enter auf dem Ziffernblock              *keypad-enter*&#xA;&amp;lt;kPoint&amp;gt;        Dezimalzeichen auf dem Ziffernblock     *keypad-point*&#xA;&amp;lt;k0&amp;gt; - &amp;lt;k9&amp;gt;     0 bis 9 auf dem Ziffernblock            *keypad-0* *keypad-9*&#xA;&amp;lt;S-...&amp;gt;         Umschalttaste                   *shift* *&amp;lt;S-*&#xA;&amp;lt;C-...&amp;gt;         Steuerungstaste                 *control* *ctrl* *&amp;lt;C-*&#xA;&amp;lt;M-...&amp;gt;         Alt-Taste oder Meta-Taste       *meta* *alt* *&amp;lt;M-*&#xA;&amp;lt;A-...&amp;gt;         dasselbe wie &amp;lt;M-...&amp;gt;            *&amp;lt;A-*&#xA;&amp;lt;D-...&amp;gt;         Befehlstaste (nur Macintosh)    *&amp;lt;D-*&#xA;&amp;lt;t_xx&amp;gt;          Taste mit dem Eintrag »xx« in der TermCap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am using Putty with ssh and the following keyboard setting:&#xA;. . .&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rN4nD.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rN4nD.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;How can I map the keys of the numeric key pad?&lt;/p&gt;&#xA;" OwnerUserId="9517" LastEditorUserId="9517" LastEditDate="2021-02-05T07:46:02.893" LastActivityDate="2021-02-05T07:46:02.893" Title="How to map NUM keys?" Tags="|key-bindings|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10175" PostTypeId="2" ParentId="10174" CreationDate="2016-11-04T22:08:43.920" Score="4" Body="&lt;p&gt;The keypad identifiers have a k* prefix.&#xA;Like mapping control + numkey 1 to :NerdTree would be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Map &amp;lt;C-k1&amp;gt; :NerdTree&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;AFAIK these mappings wont work when the NumLock is off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;also &lt;code&gt;:h keycodes&lt;/code&gt; in vim shows a lot more of these keybindings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT : OP uses PuTTY for ssh-ing into vim. PuTTY has numkeys disabled by default which is the reason why it shows alphabets instead of numericals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to solve this : PuTTY settings -&gt; Terminal -&gt; Features-&gt;put a check mark on &quot;Disable application keypad mode&quot;. -&gt; sessions -&gt; save !!&lt;/p&gt;&#xA;" OwnerUserId="9004" LastEditorUserId="9004" LastEditDate="2016-11-05T14:16:41.900" LastActivityDate="2016-11-05T14:16:41.900" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="10176" PostTypeId="1" CreationDate="2016-11-04T23:21:33.080" Score="2" ViewCount="5030" Body="&lt;p&gt;Currently I'm using this to open a file in an existing vim instance.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --remote-silent some_file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While it opens the file as expected, it &lt;em&gt;sometimes&lt;/em&gt; splits the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what logic it uses, but I'd like to be able to tell it &lt;em&gt;never&lt;/em&gt; to create a new split-window for the new buffer since it means I need to manually delete the new window - which gets annoying.&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2023-11-01T15:38:50.580" Title="How to open a file in the same window? (without creating a split)" Tags="|vim-windows|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10177" PostTypeId="1" CreationDate="2016-11-05T03:55:51.680" Score="5" ViewCount="798" Body="&lt;p&gt;I know that &lt;code&gt;gf&lt;/code&gt; will use &lt;code&gt;includeexpr&lt;/code&gt; to modify the name and make another attempt to find said file. However I need to make two modifications to the term being used to seed the search (i.e., the text under the cursor when &lt;code&gt;gf&lt;/code&gt; is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Chef DSL on top of Ruby lets you include recipes from the same cookbook using this statement:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;include_recipe ::foo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The underlying file is called &lt;code&gt;foo.rb&lt;/code&gt;. So I need to strip off the leading colons, and tack on a &lt;code&gt;.rb&lt;/code&gt;. One is easy, but I'm not sure how to do both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set includeexpr=substitute(v.fname,'::','','')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;will remove the leading colons. How do I add the &lt;code&gt;.rb&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2831" LastActivityDate="2017-01-05T11:55:29.857" Title="Use includeexpr to make multiple changes" Tags="|vimrc|set|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10178" PostTypeId="1" AcceptedAnswerId="10179" CreationDate="2016-11-05T05:22:59.840" Score="0" ViewCount="97" Body="&lt;p&gt;In the command minibuffer (Pardon my emacs, I don't know what it's actually called), &lt;code&gt;C-p&lt;/code&gt; and &lt;code&gt;C-n&lt;/code&gt; go to the previous and next command in my history. Is there a way to make them behave like &lt;code&gt;M-n&lt;/code&gt; and &lt;code&gt;M-p&lt;/code&gt; in &lt;code&gt;tcsh&lt;/code&gt;? Those will take you to the previous and next commands matching the current prefix. (The prefix being everything before the current cursor position). If that isn't possible, can vim emulate the &lt;code&gt;zsh&lt;/code&gt; behavior of scrolling through options beginning with the same command / word?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit ~/.vimrc&#xA;:read !ls&#xA;:e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then hit &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt;, I'd like it to complete &lt;code&gt;:edit ~/.vimrc&lt;/code&gt; not &lt;code&gt;:read !ls&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2016-11-05T06:57:43.593" Title="Tcsh-like history scrolling for commands?" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10179" PostTypeId="2" ParentId="10178" CreationDate="2016-11-05T06:57:43.593" Score="1" Body="&lt;p&gt;That would be &lt;code&gt;&amp;lt;UP&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Down&amp;gt;&lt;/code&gt; in cmdline-mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *c_&amp;lt;Up&amp;gt;* *c_Up*&#xA;&amp;lt;Up&amp;gt;  recall older command-line from history, whose beginning&#xA;      matches the current command-line (see below).&#xA;      {not available when compiled without the |+cmdline_hist|&#xA;      feature}&#xA;                            *c_&amp;lt;Down&amp;gt;* *c_Down*&#xA;&amp;lt;Down&amp;gt;  recall more recent command-line from history, whose beginning&#xA;        matches the current command-line (see below).&#xA;        {not available when compiled without the |+cmdline_hist|&#xA;        feature}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can remap those if you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;C-p&amp;gt; &amp;lt;UP&amp;gt;&#xA;cnoremap &amp;lt;C-n&amp;gt; &amp;lt;Down&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-11-05T06:57:43.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10180" PostTypeId="2" ParentId="10177" CreationDate="2016-11-05T07:07:52.210" Score="3" Body="&lt;p&gt;You can concatenate &lt;code&gt;v:fname&lt;/code&gt; with &lt;code&gt;'.rb'&lt;/code&gt; inside &lt;code&gt;substitute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set includeexpr=substitute(v:fname,'::\\(.*\\)','\\1.rb','')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've changed it a bit, it appears that whitespaces after coma is not allowed.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="205" LastEditDate="2017-01-05T11:55:29.857" LastActivityDate="2017-01-05T11:55:29.857" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10181" PostTypeId="1" AcceptedAnswerId="10182" CreationDate="2016-11-05T10:47:29.667" Score="1" ViewCount="1555" Body="&lt;p&gt;I'm making a program for taking statistics during sports, where I script the games. I'm would like to make a VIM shortcut/remap, so every time I press  that it does exactly what the ENTER-key normally does, but that it simply inserts a timestamp as well (and it should only be done in Insert-mode). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thinking was, that I then could go into my VIMRC-file and activate the shortcut, whenever I was doing statistics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; iabbrev &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;:put =strftime('%H%M%S')^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The '^' in the end is there in the end, because when you insert the timestamp with :put =strftime('....'), that the cursor then is a the beginning of the newly inserted timestamp. But nothing happens with this in my VIMRC-file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev &amp;lt;ENTER&amp;gt; &amp;lt;ENTER&amp;gt;:put =strftime('%H%M%S')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And still, nothing happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've even tried this, to try and see, if I could just make VIM insert any character, whenever I hit ENTER, but this doesn't do anything either:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; iabbrev &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I apologies, if this is a stupid question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EXAMPLE OF USE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say that I was typing this on the keyboard:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;upthrtwo&#xA;ussevfiv&#xA;tptwothr&#xA;uhsevtwo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I wanted VIM to have written this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;151852upthrtwo&#xA;151907ussevfiv&#xA;151917tptwothr&#xA;151949uhsevtwo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks for your time and assistance. &lt;/p&gt;&#xA;" OwnerUserId="9194" LastActivityDate="2016-11-10T20:47:32.383" Title="Remap &lt;ENTER&gt; so it makes new line and insert a datestamp" Tags="|key-bindings|insert-mode|abbreviations|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10182" PostTypeId="2" ParentId="10181" CreationDate="2016-11-05T11:03:12.167" Score="2" Body="&lt;p&gt;Try with the following&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:inoremap &amp;lt;CR&amp;gt; &amp;lt;Esc&amp;gt;:put =strftime('%H%M%S')&amp;lt;CR&amp;gt;A&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will map your enter key when in insert mode (&lt;code&gt;inoremap&lt;/code&gt;) so that&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It exits to command mode (&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;It runs &lt;code&gt;:put =strftime('%H%M%S')&lt;/code&gt;, which inserts a newline and writes your timestamp to the new line (also note the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; at the end to execut the comamnd)&lt;/li&gt;&#xA;&lt;li&gt;It puts you back in insert mode at the end of the new line with &lt;code&gt;A&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10001" LastEditorUserId="10001" LastEditDate="2016-11-10T20:47:32.383" LastActivityDate="2016-11-10T20:47:32.383" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10183" PostTypeId="1" AcceptedAnswerId="10191" CreationDate="2016-11-05T12:42:52.533" Score="1" ViewCount="3212" Body="&lt;p&gt;I want to use the Solarized Light theme in both my Terminal and VIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I seem to have got it working in Terminal, I downloaded the entire package from their website, &lt;code&gt;tree&lt;/code&gt; output, and then in my terminal preferences I imported the &lt;code&gt;Solarized Light xterm-256color&lt;/code&gt; profile from the download.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jl3H8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jl3H8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I set this as my default profile and it seems to look ok:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8qbLN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8qbLN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I proceeded to try to set VIM's color scheme to Solarized Light as well, so I git-cloned git://github.com/altercation/vim-colors-solarized.git into my &lt;code&gt;~/.vim/bundle&lt;/code&gt; (I use Pathogen).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See a paste bin of some &lt;code&gt;ls&lt;/code&gt; and &lt;code&gt;tree&lt;/code&gt; outputs in my &lt;code&gt;~/.vim/bundle&lt;/code&gt; &lt;a href=&quot;http://pastebin.com/5uQW7RwD&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But even after adding the correct information to &lt;a href=&quot;http://pastebin.com/NcXHJAKu&quot; rel=&quot;nofollow noreferrer&quot;&gt;my vimrc&lt;/a&gt; it looks really ugly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/P598h.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/P598h.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does it not seem to work? You can see around the edges of the terminal the colors it should be, why is the text so unreadable and the background color so ugly?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="205" LastEditDate="2017-03-08T13:32:02.757" LastActivityDate="2017-03-08T13:32:02.757" Title="Solarized color scheme doesn't work Mac Terminal.app" Tags="|vimrc|terminal|colorscheme|macos|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10184" PostTypeId="1" CreationDate="2016-11-05T13:57:41.073" Score="1" ViewCount="540" Body="&lt;p&gt;I'm using vim to do c++ projects on Mac OS X.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To auto complete, I use this plugin: &lt;a href=&quot;https://github.com/Rip-Rip/clang_complete&quot; rel=&quot;nofollow noreferrer&quot;&gt;clang_complete&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For most of cases, such as members of user-defined classes, members of namespaces, it works very well.&#xA;For example, when I type &lt;code&gt;std::&lt;/code&gt;, many things such as &lt;code&gt;cout&lt;/code&gt;, &lt;code&gt;cin&lt;/code&gt; will popup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I type &lt;code&gt;std::cin.&lt;/code&gt;, or &lt;code&gt;std::string str; str.&lt;/code&gt; nothing popups and I got an error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Pattern not found&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It seems that user-defined classes' members can popup automatically whereas C++ Library stuff's members can't. I don't know why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my .vimrc file:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/gTksT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gTksT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2016-11-05T14:22:43.853" LastActivityDate="2016-11-05T14:22:43.853" Title="vim c++ clang_complete doesn't work for std::cin.get()" Tags="|vimrc|autocompletion|filetype-c++|plugin-clang-complete|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10186" PostTypeId="2" ParentId="10183" CreationDate="2016-11-05T15:17:39.180" Score="1" Body="&lt;p&gt;According to &lt;a href=&quot;https://github.com/altercation/vim-colors-solarized#important-note-for-terminal-users&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt;, you should set &lt;code&gt;g:solarized_termcolors&lt;/code&gt; to &lt;code&gt;256&lt;/code&gt;, but you need to do that before calling &lt;code&gt;colorscheme solarized&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:solarized_termcolors=256&#xA;colorscheme solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-11-05T15:17:39.180" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10188" PostTypeId="1" AcceptedAnswerId="12373" CreationDate="2016-11-05T21:59:40.437" Score="2" ViewCount="192" Body="&lt;p&gt;I'm trying to create a list of 'rare' words as a supplementary spellfile so&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I have created &lt;code&gt;list.utf-8.add&lt;/code&gt; and used &lt;code&gt;mkspell!&lt;/code&gt; to create &lt;code&gt;list.utf-8.add.spl&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I included &lt;code&gt;list.utf-8.add&lt;/code&gt; in my spellfile setting&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I append &lt;code&gt;/!&lt;/code&gt; to every word to mark it as 'bad', the highlighting works as expected (every word is highlighted per &lt;code&gt;SpellBad&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I append &lt;code&gt;/?&lt;/code&gt; instead to every word to mark it as 'rare', the words are not highlighted at all. I verified that &lt;code&gt;SpellRare&lt;/code&gt; is correctly configured.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;===&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding more information:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am trying to do is use my tags file to create a spellfile that will highlight identifiers and such in comments as 'rare' words. Since these are identifiers and not natural language words, they have 'unusual' characteristics, such as embedded underscores.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After further experimentation, I have found that a few identifiers from the list do get highlighted with &lt;code&gt;SpellRare&lt;/code&gt;, but most don't get highlighted at all and others have parts highlighted as &lt;code&gt;SpellBad&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In detail:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the words in the list are marked as 'valid' (i.e., no flags), then the spell check considers them valid and they are not highlighted&lt;/li&gt;&#xA;&lt;li&gt;If the words in the list are marked as 'bad' (i.e., &lt;code&gt;/!&lt;/code&gt; flag), then the spell check considers them bad and they are highlighted with &lt;code&gt;SpellBad&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;If the words in the list are marked as 'rare' (i.e, &lt;code&gt;/?&lt;/code&gt; flag), then &quot;it depends&quot;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the first part of the word up to a '_' is not a valid natural language word then the whole word is marked as 'rare' and highlighted with &lt;code&gt;SpellRare&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Otherwise, each part of the word (delimited by '_') is considered valid or not on its own depending on whether it is a valid natural language word or not, and highlighted accordingly&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10008" LastEditorUserId="10008" LastEditDate="2016-11-06T12:41:10.980" LastActivityDate="2017-05-11T22:14:42.713" Title="Words marked as 'rare' in .add file are not always highlighted as such" Tags="|spell-checking|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10191" PostTypeId="2" ParentId="10183" CreationDate="2016-11-06T00:10:44.210" Score="2" Body="&lt;p&gt;I fixed the issue by setting &lt;code&gt;g:solarized_termcolors&lt;/code&gt; to &lt;code&gt;16&lt;/code&gt; instead of &lt;code&gt;256&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:solarized_termcolors=16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2016-11-06T00:10:44.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10192" PostTypeId="2" ParentId="10084" CreationDate="2016-11-06T10:13:06.537" Score="6" Body="&lt;p&gt;Yes, syntastic can filter out certain messages. Read &lt;code&gt;:help 'syntastic_quiet_messages'&lt;/code&gt; for details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you have to do is fill this dictionary in your vimrc with a regex like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_quiet_messages = { &quot;regex&quot;: [&#xA;        \ '\mpossible unwanted space at &quot;{&quot;',&#xA;        \ 'SOME OTHER SYNTASTIC MESSAGE',&#xA;        ...&#xA;        \ ] }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6495" LastEditorUserId="6495" LastEditDate="2016-11-06T17:40:57.947" LastActivityDate="2016-11-06T17:40:57.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10193" PostTypeId="1" CreationDate="2016-11-06T13:16:41.457" Score="2" ViewCount="171" Body="&lt;p&gt;I've written regexes for markdown for emphasis and bold as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match PandocEmphasisMarker &quot;\v(^|\s+)\zs_[^\n\t_ ]+([^_\n]|(\S_\S)|(\s_\S)|(\s+_\s+))+[^\n\t_ ]+_\ze($|\s+)&quot; contains=PandocEmphasis&#xA;syntax match PandocEmphasis &quot;\v\zs[^\n\t_ ]+([^_\n]|(\S_\S)|(\s_\S)|(\s+_\s+))+[^\n\t_ ]+\ze&quot; contained&#xA;&#xA;syntax match PandocStrongMarker &quot;\v\zs\*[^\n*]+\*\ze&quot; contains=PandocStrong&#xA;syntax match PandocStrong &quot;\v\zs[^\n*]+\ze&quot; contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This yields the following (in my opinion correct) highlighting:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gbbo7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gbbo7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in Markdown there could be emphasis &lt;em&gt;inside&lt;/em&gt; strong and strong &lt;em&gt;inside&lt;/em&gt; emphasis as well. Since I already have the regexes so far, I'd like to allow them to mutually include each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried with clusters as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax cluster PandocEmphasisCluster contains=PandocEmphasis,PandocStrongMarker&#xA;syntax cluster PandocStrongCluster contains=PandocStrong,PandocEmphasisMarker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then referenced those clusters from the &quot;Marker&quot; expressions using &lt;code&gt;contains&lt;/code&gt;, but that did not work, it messed up the strong highlighting in my test file and the strong part inside an emphasized part was not made bold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can / should I make them contain each other?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is also important for other things like &lt;code&gt;`&lt;/code&gt; inside emphasized or strong. Maybe I should use &lt;code&gt;region&lt;/code&gt; somehow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clarification:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;emphasis inside strong should still be strong, but also become emphasized.&lt;/li&gt;&#xA;&lt;li&gt;strong inside emphasis should still be emphasized, but also become strong&lt;/li&gt;&#xA;&lt;li&gt;effects should add up, that's what I want to achieve&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9855" LastEditorUserId="9855" LastEditDate="2016-11-11T13:05:35.723" LastActivityDate="2017-02-10T18:09:37.237" Title="How do I make regexes mutually contain each other?" Tags="|regular-expression|syntax-highlighting|filetype-markdown|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10194" PostTypeId="1" AcceptedAnswerId="10326" CreationDate="2016-11-06T15:47:11.190" Score="11" ViewCount="1278" Body="&lt;p&gt;I have these lines in my .vimrc to help with indentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost * set noexpandtab | retab! 4&#xA;autocmd BufWritePre * set expandtab | retab! 4&#xA;autocmd BufWritePost * set noexpandtab | retab! 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, they create a lot of noise in the undo history. Since they essentially do nothing from the user's perspective, I'd like to remove them from the history or at the very least squash them somehow (perhaps they cancel out if squashed together?). Is there a way to do so?&lt;/p&gt;&#xA;" OwnerDisplayName="user8048" LastActivityDate="2022-12-19T13:37:10.837" Title="Is it possible to remove an entry from the undo history?" Tags="|vimrc|undo-redo|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10195" PostTypeId="1" AcceptedAnswerId="10199" CreationDate="2016-11-06T17:08:03.643" Score="0" ViewCount="231" Body="&lt;p&gt;Sometimes I see examples of vimscript code, which uses &lt;code&gt;/&lt;/code&gt; instead of &lt;code&gt;&quot;&lt;/code&gt; to delimit strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any side effects to this, or is it always possible to do that? And what is the advantage of using slashes rather than double quotes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One example is here: &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#E849&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimhelp.appspot.com/syntax.txt.html#E849&lt;/a&gt; (scroll up a few lines)&lt;/p&gt;&#xA;" OwnerUserId="9855" LastEditorUserId="9855" LastEditDate="2016-11-07T09:30:31.953" LastActivityDate="2016-11-07T21:08:29.357" Title="Usage of slash instead of quotes to delimit strings" Tags="|vimscript|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10196" PostTypeId="2" ParentId="10195" CreationDate="2016-11-06T17:23:40.597" Score="2" Body="&lt;p&gt;I don't think there are side effects. Sometimes it can be useful  because you don't need to escape same sign that would be used inside. So if you have to search for &lt;code&gt;&quot;foo&quot;&lt;/code&gt;, using &lt;code&gt;&quot;&lt;/code&gt; as container, you would have to do it like this: &lt;code&gt;... start=&quot;\&quot;foo\&quot;&quot;&lt;/code&gt;, where with &lt;code&gt;/&lt;/code&gt; (or any other): &lt;code&gt;... start=/&quot;foo&quot;/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is explained in the same document but a bit lower: &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#E401&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-11-06T17:23:40.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10198" PostTypeId="1" CreationDate="2016-11-06T20:18:51.550" Score="0" ViewCount="94" Body="&lt;p&gt;I know that best way would be by doing and practice.&#xA;But sometimes you learn in a wrong way, so what courses on YouTube or other paid websites or books you would recommend for who is starting with vim?&#xA;I am just started studying for server administration and some one recommended vim to use it in terminal.&#xA;So I am hunger to learn but do not know which step to do now.&#xA;Your recommendations are highly much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="10012" LastActivityDate="2016-11-07T01:10:53.283" Title="Please recommend video course (paid or free) or books to use vim like professionals and save my time" Tags="|linux|" AnswerCount="1" CommentCount="4" ClosedDate="2016-11-07T06:18:38.957" ContentLicense="CC BY-SA 3.0" />
  <row Id="10199" PostTypeId="2" ParentId="10195" CreationDate="2016-11-06T20:56:27.400" Score="6" Body="&lt;p&gt;The examples you are referring to are not examples of strings, but of patterns. A pattern may be delimited by any character (except alphanumeric characters), although the most usual one is &lt;code&gt;/&lt;/code&gt;. This does not seem to be very well documented, but I found it described under &lt;code&gt;:h E146&lt;/code&gt;, which reads as follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Instead of the '/' which surrounds the pattern and replacement string, you&#xA;  can use any other single-byte character, but not an alphanumeric character,&#xA;  '\', '&quot;' or '|'.  This is useful if you want to include a '/' in the search&#xA;  pattern or replacement string.  Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  :s+/+//+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Strings, on the other hand, are either literal strings, e.g. &lt;code&gt;'this is a literal string'&lt;/code&gt;, or &quot;expression&quot; strings, e.g. &lt;code&gt;&quot;this is an expression string&quot;&lt;/code&gt;. See &lt;code&gt;:h expr-string&lt;/code&gt; and &lt;code&gt;:h literal-string&lt;/code&gt;. The difference is that the expression string accepts special characters that are parsed, e.g. special keys such as &lt;code&gt;&quot;\&amp;lt;cr&amp;gt;&quot;&lt;/code&gt;, while literal strings are taken as is, except that double quotes are treated as a single quote.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2016-11-07T21:08:29.357" LastActivityDate="2016-11-07T21:08:29.357" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10200" PostTypeId="1" CreationDate="2016-11-06T21:05:51.507" Score="-1" ViewCount="225" Body="&lt;p&gt;I would like to call my Vim function once when vimrc is sourced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could put some global variables in my vimrc file and set them to be 0 or 1 etc.. &#xA;In fact, that is what I'm doing for many functions. However, there are many global variables flying around in my vimrc file and it is painful to keep track of them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; let g:Myfun_var1 =  '0'&#xA;&#xA;    func! Myfun&#xA;        g:Myfun_var1 = '1'&#xA;    endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm wondering whether there is way to achieve the result without using any global variables inside my function   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, I don't want to put my function in autoload folder &lt;code&gt;~/.vim/autoload.&lt;/code&gt; (I try to keep all functions in my vimrc file.)&lt;/p&gt;&#xA;" OwnerUserId="7597" LastEditorUserId="1841" LastEditDate="2016-11-07T08:38:10.373" LastActivityDate="2016-11-07T08:38:10.373" Title="Call the function only once when Vimrc is loaded without using global variables" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10201" PostTypeId="2" ParentId="10200" CreationDate="2016-11-06T23:31:36.810" Score="3" Body="&lt;p&gt;As long as your function is called only from your &lt;code&gt;.vimrc&lt;/code&gt;, it should be called once -- unless you source it several times, which is an exceptional scenario which doesn't deserve to spend too many time on it -- note that if this is your problem, then you could use a single script local variable (a global with a special scope -- this is comparable to static variables in C) to be sure a particular initialization is done only once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're afraid to call it from plugins, well as long as you are responsible for the function name, and you know you call it from your &lt;code&gt;.vimrc&lt;/code&gt;, why would you want to call it from a plugin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I must admit I don't really see your problem, from your description I read that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you define a function&lt;/li&gt;&#xA;&lt;li&gt;you put it in your .vimrc&lt;/li&gt;&#xA;&lt;li&gt;you call it from your .vimrc&lt;/li&gt;&#xA;&lt;li&gt;you don't expect to call it several times&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then, don't call it several times. Doing so is a programming error. Trust yourself. You may add script global (&lt;code&gt;s:foobar_function_has_been_executed&lt;/code&gt;) and use the new &lt;code&gt;assert_true()&lt;/code&gt; functions to check what you're doing.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-11-06T23:31:36.810" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10202" PostTypeId="2" ParentId="10198" CreationDate="2016-11-07T01:10:53.283" Score="1" Body="&lt;p&gt;I got a lot out of &lt;a href=&quot;http://shop.oreilly.com/product/9780596529833.do&quot; rel=&quot;nofollow noreferrer&quot;&gt;the Robbins book&lt;/a&gt;, and I've been using &lt;code&gt;vi&lt;/code&gt; for about a quarter century now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://derekwyatt.org/vim/tutorials/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim videos by Derek Wyatt&lt;/a&gt; also proved somewhat enlightening, though for someone of my experience, it is more because they showed me how someone else works, which expanded my horizons. I can only guess how a true newbie will see them, but I suspect that at the least, they will do the same for you: that is, show you how &lt;em&gt;one person&lt;/em&gt; works, so you can at least have some basis for thinking about Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Realize that Mr. Wyatt's videos show you just one guy's idea of the right way to do things. I don't entirely agree with his opinions, but that doesn't make either of us a bad Vim user. His &quot;One Vim&quot; concept in particular doesn't work for me, but it may work for you, and if not, you will at least find it enlightening, if only because it forces you to confront your reasons for disagreeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also want to dismiss your concern about learning Vim the &quot;wrong&quot; way. I think the worst that can happen to you is that you end up not knowing about tools that could save you time. I think &lt;a href=&quot;https://en.wikipedia.org/wiki/Outliers_(book)&quot; rel=&quot;nofollow noreferrer&quot;&gt;10,000 hours of focused practice&lt;/a&gt; will have more effect on your efficiency with Vim than any number of books and tutorials.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want it all wrapped up in a bow, I recommend that you:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Order the Robbins book&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Watch all the Wyatt tutorials before the book arrives, at least up through the Intermediate series; and&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Slowly read through the book a piece at a time while you simultaneously use Vim to accomplish every text editing task you come across. &lt;em&gt;Using&lt;/em&gt; Vim is far more important than &lt;em&gt;reading&lt;/em&gt; about Vim.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Resolve not to use any other text editor for at least a year. Any time you find yourself spending more time than you think reasonable to accomplish your desired ends in Vim, find out if there is a workaround or an improved method. If you must use another text editor in this time (e.g. Visual Studio because you need to build some piece of Windows software) find out if it has a Vim/&lt;code&gt;vi&lt;/code&gt; plugin, and use it if there is one. Most powerful text editors &lt;em&gt;do&lt;/em&gt; have such a plugin or add-on available, and if your current favorite text editor does not, ask yourself if you really must use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't stress living solely in Vim enough. Any time you backslide and spend time in another editor, you are letting your Vim skills atrophy, and you are missing an opportunity to learn how to do the same task in Vim. You will never become more than a pidgin Vim speaker that way. It is just like learning another human language: total immersion works much better than classes an hour a week.&lt;/p&gt;&#xA;" OwnerUserId="6852" LastActivityDate="2016-11-07T01:10:53.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10203" PostTypeId="1" AcceptedAnswerId="10205" CreationDate="2016-11-07T03:07:07.757" Score="0" ViewCount="59" Body="&lt;p&gt;I'm working with CentOS 7, and Vim 7.4, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setl&#xA;--- Local option values ---&#xA;  autoindent          define=             include=            path=               softtabstop=4&#xA;--autoread            errorformat=        keywordprg=         readonly            syntax=cpp&#xA;  cindent             filetype=cpp        makeprg=            shiftwidth=4        tabstop=4&#xA;  cryptmethod=        grepprg=            number              smartindent         tags=&#xA;  comments=sO:* -,mO:*  ,exO:*/,s1:/*,mb:*,ex:*/,://&#xA;  fileencoding=utf-8&#xA;  formatoptions=croql&#xA;  omnifunc=ccomplete#Complete&#xA;  undolevels=-123456&#xA;:version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 10 2014 06:55:55)&#xA;Included patches: 1-160&#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;My main question:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;What does the &lt;code&gt;--&lt;/code&gt; prefix in front of the 'autoread' option mean?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Next question:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Since I could find no help on this anywhere, are there any other prefixes that I should know about?&lt;/p&gt;&#xA;" OwnerUserId="9912" LastActivityDate="2016-11-07T06:17:22.397" Title="When I view local options (i.e. :setlocal) - what do the &quot;odd&quot; prefixes (i.e. '--') mean?" Tags="|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10205" PostTypeId="2" ParentId="10203" CreationDate="2016-11-07T06:17:22.397" Score="4" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%3Asetlocal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :setlocal&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;                                                        :setl :setlocal&#xA;:setl[ocal] ...         Like &quot;:set&quot; but set only the value local to the&#xA;                        current buffer or window.  Not all options have a&#xA;                        local value.  If the option does not have a local&#xA;                        value the global value is set.&#xA;                        With the &quot;all&quot; argument: display local values for all&#xA;                        local options.&#xA;                        Without argument: Display local values for all local&#xA;                        options which are different from the default.&#xA;                        When displaying a specific local option, show the&#xA;                        local value.  &lt;strong&gt;For a global/local boolean option, when&#xA;                        the global value is being used, &quot;--&quot; is displayed&#xA;                        before the option name.&lt;/strong&gt;&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-11-07T06:17:22.397" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10206" PostTypeId="1" AcceptedAnswerId="10219" CreationDate="2016-11-07T10:24:48.380" Score="3" ViewCount="462" Body="&lt;p&gt;What is the best way to bind key, to go &quot;past the last delimiter. I want to bind, for example &lt;code&gt;&amp;lt;leader&amp;gt;,&lt;/code&gt; to behave like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;foo bar| baz&quot;&lt;/code&gt; -&gt; key press -&gt; &lt;code&gt;&quot;foo bar baz&quot;,|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(arg1, arg2, |arg3)&lt;/code&gt; -&gt; key press -&gt; &lt;code&gt;(arg1, arg2, arg3),|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And same for other delimiter i choose. Is there any plugin for this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now my solution is this function (well, key binding is easy):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    function! MovePastDelimiter()&#xA;        let parantheses = { '('  : ')', '['  : ']', '{'  : '}', '&amp;lt;'  : '&amp;gt;' }&#xA;        let quotes_and_etc = ['&quot;', '|', '`', '''']&#xA;        let regex = &quot;[&quot; . join(keys(parantheses),&quot;&quot;) . join(quotes_and_etc,&quot;&quot;) . &quot;]&quot;&#xA;        let match = searchpos(regex, 'bn')&#xA;        if match != [0, 0]&#xA;            let current_delimiter = getline(match[0])[match[1]-1]&#xA;            if has_key(parantheses, current_delimiter)&#xA;                if !searchpair(current_delimiter, '', parantheses[current_delimiter])&#xA;                    &quot; this is stupid, but searchpair will&#xA;                    &quot; work only with \[, not just [&#xA;                    call searchpair('\' . current_delimiter, '', '\' . parantheses[current_delimiter])&#xA;                endif&#xA;&#xA;            else&#xA;                call search(current_delimiter)&#xA;            endif&#xA;        endif&#xA;    endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But maybe there is a better way?&lt;/p&gt;&#xA;" OwnerUserId="10018" LastEditorUserId="51" LastEditDate="2016-11-10T18:50:26.877" LastActivityDate="2016-11-10T18:50:26.877" Title="How move cursore &quot;past the first paired delimiter&quot; (quote, parentheses, etc) - searchpair()?" Tags="|key-bindings|delimiter-matching|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10207" PostTypeId="2" ParentId="10206" CreationDate="2016-11-07T12:13:03.383" Score="4" Body="&lt;p&gt;&lt;strong&gt;I)&lt;/strong&gt; Don't create an insert mode mapping:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Insert mode is made to insert characters, when you need to move your cursor you should go back to normal mode or use &lt;kbd&gt;ctrl+o&lt;/kbd&gt; to go to normal mode for only one command. (&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL%2DO&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-O&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;II)&lt;/strong&gt; Use the built-in motion command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal mode &lt;kbd&gt;f+character&lt;/kbd&gt; goes to the next character (&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#f&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h f&lt;/code&gt;&lt;/a&gt;). For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;foo bar| baz&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In normal mode pressing &lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt; will put the cursor on the second &lt;code&gt;&quot;&lt;/code&gt; and &lt;kbd&gt;a&lt;/kbd&gt; will start insert mode after this character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus in the previous example from insert mode I would use &lt;kbd&gt;esc&lt;/kbd&gt;+&lt;kbd&gt;f&lt;/kbd&gt;+&lt;kbd&gt;&quot;&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt;. This has the benefit to seperate your edit in different undoable chunck of edits which is how you're supposed to use Vim.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now if you still want to what you asked I think you'll have to create a function which will try to detect in which text object the cursor is currently and then move to the end of this text object. In my opinion that is more trouble than simply using Vim as it is meant to be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be interested by the &lt;code&gt;%&lt;/code&gt; command which cycles through matching groups (&lt;a href=&quot;http://vimhelp.appspot.com/matchit.txt.html#matchit%2D%&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h matchit-%&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;leader&amp;gt;, &amp;lt;esc&amp;gt;%%a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would do the trick for the matching brackets (&lt;code&gt;(&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt;, &lt;code&gt;(&lt;/code&gt;) but not for the quotes.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-11-07T12:36:21.217" LastActivityDate="2016-11-07T12:36:21.217" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10208" PostTypeId="2" ParentId="10206" CreationDate="2016-11-07T12:34:38.353" Score="2" Body="&lt;p&gt;This is a simple one, you can add more delimiters in the &lt;code&gt;[ ]&lt;/code&gt; group, but it won't check for the &quot;inside&quot; of anything:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-x&amp;gt;&amp;lt;C-x&amp;gt; &amp;lt;Esc&amp;gt;/[\])}&quot;]/e&amp;lt;CR&amp;gt;a,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It just searches for the 1st delimiter in the list, goes after it and appends a comma. So it roughly goes out of the &quot;most inner&quot; delimited group. If I'd use such a map, I'd skip the comma addition and add some more delimiters, to keep it more generic, and repeatable - say I hit &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-x&amp;gt;&lt;/code&gt; and I don't like where I landed, I just repeat the combo and go &quot;out&quot; after the next delimiter.&lt;/p&gt;&#xA;" OwnerUserId="1800" LastEditorUserId="1800" LastEditDate="2016-11-07T12:40:17.830" LastActivityDate="2016-11-07T12:40:17.830" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10209" PostTypeId="1" AcceptedAnswerId="10211" CreationDate="2016-11-07T17:55:25.977" Score="34" ViewCount="21423" Body="&lt;p&gt;I use vim for bash scripting, and sometimes I write a one-time script. Usually, I don't want to create a new file, make it executable, execute it and then remove it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance I open vim and type this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;&#xA;ll | while read line&#xA;do&#xA;    echo $line&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did not save this file, I just use vim to simplify bash-scripting. I know I can execute a bash command via &lt;code&gt;!&lt;/code&gt; in vim. But what about executing everything that is in the buffer?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastEditorUserId="10604" LastEditDate="2020-04-02T14:56:35.460" LastActivityDate="2020-04-02T14:56:35.460" Title="Execute current buffer as bash script from vim" Tags="|command-line|external-command|bash|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10210" PostTypeId="1" CreationDate="2016-11-07T18:07:03.153" Score="0" ViewCount="1083" Body="&lt;p&gt;I want to create a command that will download a large file and save it to my local system. I am not interested in editing this file. I also would like to avoid a huge &lt;code&gt;if&lt;/code&gt; block to see what downloaders are available. This is specific to the thesaurus which is why the auto spell download is not going to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have thought the best thing to do would reuse the netrw logic since it was a trusted source for what system programs were available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I've tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! ThesaurusInstall call netrw#Obtain(0, &quot;http://www.gutenberg.org/files/3202/files/mthesaur.txt&quot;, &quot;$HOME/.vim/&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which crashes because I'm not using the function right. I just want a Vim command I can put in my &lt;code&gt;.vimrc&lt;/code&gt; which will download that thesaurus file to my &lt;code&gt;.vim/&lt;/code&gt; directory. How can I do this without making my own complicated conditions like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if `curl` … else if `wget` … else if …&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="544" LastEditorUserId="1841" LastEditDate="2016-11-08T09:12:44.470" LastActivityDate="2016-11-08T12:25:03.900" Title="How do I script Vim to download a thesaurus file and save it?" Tags="|vimrc|vimscript|netrw|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10211" PostTypeId="2" ParentId="10209" CreationDate="2016-11-07T18:07:48.917" Score="51" Body="&lt;p&gt;I wrote a pretty extensive answer about this &lt;a href=&quot;https://stackoverflow.com/a/40290101/3524982&quot;&gt;over on stack-overflow&lt;/a&gt;. The basic idea is that since the write command is about &lt;em&gt;writing&lt;/em&gt; not &lt;em&gt;saving&lt;/em&gt;, you can write the text in your buffer into an external program, such as python or bash. In your case, you would want to do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These commands literally just write the text in your buffer directly into the program you specify with &lt;code&gt;!&lt;/code&gt;, which is convenient because then you do not need to save a file. Of course, you may also do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w | !bash %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which saves your file and then runs it as a bash script. You can choose whichever one makes more sense for you.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-11-07T18:07:48.917" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10213" PostTypeId="1" AcceptedAnswerId="10214" CreationDate="2016-11-08T00:38:19.340" Score="5" ViewCount="309" Body="&lt;p&gt;I'm trying to get into more advanced features of vimscript, so I'm trying to figure out how to use the &lt;code&gt;map&lt;/code&gt; function, so I thought I'd write a function that returns every character with ASCII values between two numbers. For example, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CharRange(65, 90)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would give&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ABCDEFGHIJKLMNOPQRSTUVWXYZ&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo map(range(65, 90), function('nr2char'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I got some very strange results. Instead of giving ASCII 65-90, it gave ASCII 1-25.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^A ^B ^C ^D ^E ^F ^G ^H ^K ^L ^M ^N ^O ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(of course it gave unprintables rather than the carets followed by letters)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After this didn't work, I tried some other ways, but none of them worked right. For example, a lambda:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo join(map(range(50, 100), {arg1 -&amp;gt; nr2char(arg1)}))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gives the exact same results. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-11-08T10:46:24.280" Title="Strange behavior with &quot;map(range ...)&quot;" Tags="|vimscript|command-line|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10214" PostTypeId="2" ParentId="10213" CreationDate="2016-11-08T00:59:35.097" Score="7" Body="&lt;p&gt;Looking at &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#map%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h map&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;map({expr1}, {expr2})                                   map()&#xA;                {expr1} must be a List or a Dictionary.&#xA;                Replace each item in {expr1} with the result of evaluating&#xA;                {expr2}.  {expr2} must be a string or Funcref.             &#xA;...&#xA;                &lt;strong&gt;If {expr2} is a Funcref it is called with two arguments:&#xA;                        1. The key or the index of the current item.&#xA;                        2. the value of the current item.&lt;/strong&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Therefore, what &lt;code&gt;map&lt;/code&gt; does for &lt;code&gt;65&lt;/code&gt; in this case actually call &lt;code&gt;nr2char(0, 65)&lt;/code&gt;, and for &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#nr2char%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;nr2char&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nr2char({expr}[, {utf8}])                               nr2char()&#xA;                Return a string with a single character, which has the number&#xA;                value {expr}.  ...&#xA;               When {utf8} is omitted or zero, the current 'encoding' is used.&#xA;                Example for &quot;utf-8&quot;: &#xA;                        nr2char(300)            returns I with bow character&#xA;               With {utf8} set to 1, always return utf-8 characters.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, the &lt;code&gt;65&lt;/code&gt; is pretty much ignored, and you get the U+0 character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['', '^A', '^B', '^C', '^D', '^E', '^F', '^G', '^H', '  ', '&#xA;', '^N', '^O', '^P', '^Q', '^R', '^S', '^T', '^U', '^V', '^W', '^X', '^Y']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://manpages.ubuntu.com/manpages/trusty/en/man7/ascii.7.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;man 7 ascii&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The help does have an example of this problem, but it's in &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#lambda&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h lambda&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Examples for using a lambda expression with sort(), map() and filter(): &#xA;    :echo map([1, 2, 3], {idx, val -&amp;gt; val + 1})&#xA;   [2, 3, 4] &#xA;    :echo sort([3,7,2,1,4], {a, b -&amp;gt; a - b})&#xA;   [1, 2, 3, 4, 7]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first example shows that &lt;code&gt;map&lt;/code&gt; passes two arguments, and the second is the actual value.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2016-11-08T10:46:24.280" LastActivityDate="2016-11-08T10:46:24.280" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10215" PostTypeId="2" ParentId="10210" CreationDate="2016-11-08T09:09:50.960" Score="2" Body="&lt;p&gt;As @romainl and @Ian Emnace said in the comments you shouldn't do that with Vim. Here's why:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.tldp.org/LDP/GNU-Linux-Tools-Summary/html/c1089.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;unix tool philosophy&lt;/a&gt; is to have small programs to accomplish a particular task instead of trying to develop large monolithic programs to do a large number of tasks.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vim is a text editor, even if it includes netrw which has some network capabilities, it is not meant to automate file downloads.&lt;/li&gt;&#xA;&lt;li&gt;Furthermore downloading a thesaurus is not a task that you'll often do: You don't need to download it each time you source your &lt;code&gt;vimrc&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It is more likely that you'll need to download a thesaurus when you install your vimrc (probably along with your other dotfiles) on a new machine. Thus what I would recommend is to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Host your dotfiles on a git repository (&lt;a href=&quot;https://vi.stackexchange.com/a/581/1841&quot;&gt;this question&lt;/a&gt; mentions it and you can also google &lt;code&gt;dotfiles github&lt;/code&gt; you'll get a lot of examples but you can use &lt;a href=&quot;https://bitbucket.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;bitbucket&lt;/a&gt; or even a self hosted gitlab instead of github)&lt;/li&gt;&#xA;&lt;li&gt;In this repository also host a bash script (or python or maybe go or whatever scripting language you're familiar with) that you'll execute when you install your dotfiles and which will download the spell files you need in the correct destination. If you already manage your dotfiles on github maybe you already have such a script which symlink your files or do this kind of things, it would be easy to add a wget call to this script.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This will be much easier to handle for you because languages like bash are tools which were made to automate process like downloading a file.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-11-08T10:39:25.960" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10219" PostTypeId="2" ParentId="10206" CreationDate="2016-11-08T12:32:53.657" Score="3" Body="&lt;p&gt;This was a tough one as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I couldn't get &lt;code&gt;getpos('``&amp;lt;')&lt;/code&gt; to work&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;searchpair*()&lt;/code&gt; don't work when the opening and the closing signs are not identical. Here, two cases:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;with strings, &lt;code&gt;va'&lt;/code&gt; and &lt;code&gt;va&quot;&lt;/code&gt; can be used&lt;/li&gt;&#xA;&lt;li&gt;with other possible pairs like &lt;code&gt;_&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; in markdown, &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;|&lt;/code&gt; in vim help files, we have to use &lt;code&gt;search()&lt;/code&gt; twice&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;searchpairpos()&lt;/code&gt; returns a byte offset and not a column position, this means that we need to count characters in UTF-8 documents -- as I didn't want to use &lt;code&gt;setpos()&lt;/code&gt; but instead move the cursor in a redoable way&lt;/li&gt;&#xA;&lt;li&gt;sometimes we have pairs like angle-brackets that can be used for other things (like ordered comparisons), and they can introduce new jump points (I have no generic solution for this one).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that I've integrated your idea in &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-brackets&lt;/a&gt; where I'm maintaining the list of registered pairs automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've ended up with two functions: one that searches for the compatible pairs (used to define block), and one called from various mappings to actually move the cursor. NB: I won't reproduce the code from lh-vim-lib functions used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Function: s:outer_blocks() {{{2&#xA;function! s:outer_blocks() abort&#xA;  let crt_pairs = s:GetPairs(0) &quot; global pairs&#xA;  call extend(copy(crt_pairs), s:GetPairs(1), 'force') &quot; buffer-local ones&#xA;  let matches = {}&#xA;  for p in crt_pairs&#xA;    if p[0] != p[1] &quot; searchpos doesn't work in that case&#xA;      let pos = searchpairpos(p[0], '', p[1], 'cWn', &quot;lh#syntax#is_a_comment('.')&quot;)&#xA;      call s:Verbose('Testing searchpos(%1) -&amp;gt; %2', p, pos)&#xA;    elseif p[0] =~ '[&quot;'']'&#xA;      &quot; Stuff which can be checked with vi', vi&quot;&#xA;      let crt_pos = getpos('.')&#xA;      let cleanup = lh#on#exit()&#xA;            \.restore('@a')&#xA;            \.register('call setpos(&quot;.&quot;, '.string(crt_pos).')')&#xA;      try&#xA;        let @a = ''&#xA;        silent! exe 'normal! &quot;aya'.p[0]&#xA;        &quot; 2 chars are to be expected for open and close&#xA;        if lh#encoding#strlen(@a) &amp;gt;= lh#encoding#strlen(p[0].p[1])&#xA;          &quot; In two steps because it may fail&#xA;          &quot; -- it shouldn't though thanks to len(@a) &amp;gt;= 2 * len(open)&#xA;          exe 'normal! v'&#xA;          silent! exe 'normal! a'.p[0]&#xA;          silent! exe &quot;normal! \&amp;lt;esc&amp;gt;&quot;&#xA;          let pos = getpos('.')[1:2]&#xA;        else&#xA;          let pos = [0,0]&#xA;        endif&#xA;        if 0&#xA;          &quot; getpos doesn't seem to work...&#xA;          let pos = getpos('`&amp;gt;')[1:2]&#xA;          if getpos('`&amp;lt;')[1:2] == pos&#xA;            let pos = [0,0]&#xA;          endif&#xA;        endif&#xA;        call s:Verbose('Testing va%1 -&amp;gt; %2 - %3', p[0], pos, @a)&#xA;      finally&#xA;        call cleanup.finalize()&#xA;      endtry&#xA;    else&#xA;      let pos = searchpos(p[0], 'cWnb', 'lh#syntax#is_a_comment(&quot;.&quot;)')&#xA;      if  pos != [0,0]&#xA;        let pos = searchpos(p[1], 'cWn', 'lh#syntax#is_a_comment(&quot;.&quot;)')&#xA;      endif&#xA;      call s:Verbose('Testing /%1 -&amp;gt; %2', p[0], pos)&#xA;    endif&#xA;    if pos != [0,0]&#xA;      let matches[p[0]] = pos&#xA;    endif&#xA;  endfor&#xA;  call s:Verbose('Containing bracket pairs: %1', matches)&#xA;  return matches&#xA;endfunction&#xA;&#xA;&quot;------------------------------------------------------------------------&#xA;&quot; Function: lh#brackets#jump_outside(param) {{{2&#xA;&quot; In this flavour, we don't expect to be just before the current closing&#xA;&quot; character. Instead, search for the next character that closes the current&#xA;&quot; scope.&#xA;function! lh#brackets#jump_outside(param) abort&#xA;  let mode      = get(a:param, 'mode')&#xA;&#xA;  let matches = s:outer_blocks()&#xA;  if empty(matches)&#xA;    call s:Verbose('The cursor doesn''t belong to any block')&#xA;    return ''&#xA;  endif&#xA;  let m2 = map(values(matches), '[0]+v:val')&#xA;  call sort(m2, 'lh#position#compare')&#xA;  let crt_pos = getpos('.')&#xA;  let dest = m2[0]+[0]&#xA;  &quot; call assert_true(lh#position#is_before(crt_pos, dest))&#xA;  &quot; Insert mode, :map-&amp;lt;expr&amp;gt;&#xA;  if mode == 'i' &amp;amp;&amp;amp; crt_pos[1] == dest[1] &quot; same-line&#xA;    &quot; Need to know how many characters does this really represent, not the&#xA;    &quot; number of bytes!&#xA;    let text = lh#position#extract(crt_pos, dest)&#xA;    let offset = lh#encoding#strlen(text)+1&#xA;    &quot; produces a redo-able move sequence&#xA;    return lh#map#_move_cursor_on_the_current_line(offset)&#xA;  else&#xA;    call setpos('.', dest)&#xA;    return mode == 'i' ? &quot;\&amp;lt;Right&amp;gt;&quot; : &quot;a&quot;&#xA;  endif&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;MarkersJumpOutside &amp;lt;C-R&amp;gt;=lh#brackets#jump_outside({'mode': 'i'})&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;MarkersJumpOutside @=lh#brackets#jump_outside({'mode': 'n'})&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;MarkersJumpOutside &amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;@=lh#brackets#jump_outside({'mode': 'x'})&amp;lt;cr&amp;gt;&#xA;    smap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;MarkersJumpOutside &amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;a&amp;lt;Plug&amp;gt;MarkersJumpOutside&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-11-08T16:16:34.307" LastActivityDate="2016-11-08T16:16:34.307" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10220" PostTypeId="2" ParentId="10193" CreationDate="2016-11-08T14:29:17.820" Score="1" Body="&lt;p&gt;You can simply add the &lt;code&gt;contains=&amp;lt;...&amp;gt;&lt;/code&gt; option to both the &lt;code&gt;PandocEmphasis&lt;/code&gt; and &lt;code&gt;PandocStrong&lt;/code&gt; to allow for nested matches:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match PandocEmphasisMarker &quot;\v(^|\s+)\zs_[^\n\t_ ]+([^_\n]|(\S_\S)|(\s_\S)|(\s+_\s+))+[^\n\t_ ]+_\ze($|\s+)&quot; contains=PandocEmphasis&#xA;syntax match PandocEmphasis &quot;\v\zs[^\n\t_ ]+([^_\n]|(\S_\S)|(\s_\S)|(\s+_\s+))+[^\n\t_ ]+\ze&quot; contained contains=PandocStrongMarker&#xA;&#xA;syntax match PandocStrongMarker &quot;\v\zs\*[^\n*]+\*\ze&quot; contains=PandocStrong&#xA;syntax match PandocStrong &quot;\v\zs[^\n*]+\ze&quot; contained  contains=PandocEmphasisMarker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5590" LastActivityDate="2016-11-08T14:29:17.820" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10221" PostTypeId="1" CreationDate="2016-11-08T22:30:27.877" Score="1" ViewCount="262" Body="&lt;p&gt;I've been using Spacemacs recently and I am trying to reproduce one nice feature that I've seen there in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently: &lt;code&gt;ci&quot;&lt;/code&gt; will change everything inside double quotes (cursor does not have to be inside the quotes) but only on the same line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there is any option or plugin to do it on any line:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;&amp;lt;cursor here&amp;gt;&lt;/code&gt;some text here&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;new line &quot;text_to_be_replaced&quot; something&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;At the moment in Vim it is possible only to go down one line and only then do &lt;code&gt;ci&quot;&lt;/code&gt; (even while being outside of quotes). If anyone would know any specific action or plugin that could achieve that I would really appreciate assistance! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="10013" LastEditorUserId="1841" LastEditDate="2016-11-09T08:49:35.643" LastActivityDate="2016-11-09T10:39:05.727" Title="ci&quot; - change at the closest quotes (not on the same line)" Tags="|key-bindings|cursor-movement|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10224" PostTypeId="1" AcceptedAnswerId="10227" CreationDate="2016-11-09T05:13:55.960" Score="1" ViewCount="145" Body="&lt;p&gt;If I'm in normal mode and I accidentally press &lt;kbd&gt;d&lt;/kbd&gt; vim will then wait for a motion to choose what to delete. Is their a motion or cancel command to not delete anything? Is the only option to delete something and then undo it? &lt;/p&gt;&#xA;" OwnerUserId="10038" LastEditorUserId="1841" LastEditDate="2016-11-09T08:53:19.273" LastActivityDate="2016-11-09T09:49:19.057" Title="How to cancel a deletion after pressing 'd' in normal mode?" Tags="|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10225" PostTypeId="2" ParentId="10224" CreationDate="2016-11-09T05:26:14.177" Score="7" Body="&lt;p&gt;Just hit the 'ESC' key. It will cancel whatever command you are in the middle of typing.&lt;/p&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2016-11-09T05:26:14.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10226" PostTypeId="2" ParentId="10221" CreationDate="2016-11-09T07:35:45.820" Score="1" Body="&lt;p&gt;To define the operator mode mapping, first search for the next double quote. Go into visual mode and then search back. But for an unknown reason I cannot do it with a simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap i&quot; /&quot;&amp;lt;cr&amp;gt;vN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the following works&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test()&#xA; call search('\ze&quot;', &quot;W&quot;)&#xA; normal! v&#xA; call search('&quot;\zs', 'Wb')&#xA;endfunction&#xA;&#xA;onoremap i&quot; :&amp;lt;c-u&amp;gt;call Test()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-11-09T10:39:05.727" LastActivityDate="2016-11-09T10:39:05.727" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10227" PostTypeId="2" ParentId="10224" CreationDate="2016-11-09T09:49:19.057" Score="2" Body="&lt;p&gt;Any command can be interrupted either by &lt;kbd&gt;ESC&lt;/kbd&gt; (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt;) or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="9633" LastActivityDate="2016-11-09T09:49:19.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10228" PostTypeId="1" AcceptedAnswerId="10229" CreationDate="2016-11-09T13:19:33.620" Score="1" ViewCount="246" Body="&lt;p&gt;Working on a more lightweight vim-endwise replacement (endwise breaks &lt;code&gt;imap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt;&lt;/code&gt; mappings).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def name&amp;lt;-cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it adds a newline and another line with an &lt;code&gt;end&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def name&#xA;  &amp;lt;-cursor here&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping does the job:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType ruby inoremap &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; match(getline('.'), 'def') &amp;gt;= 0 ? '&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;end&amp;lt;Esc&amp;gt;-cc' : '&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I'd like to extend this to also understand &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;case&lt;/code&gt; and &lt;code&gt;do&lt;/code&gt;, but the following does not work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType ruby inoremap &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; match(getline('.'), 'def\|if\|case\|do') &amp;gt;= 0 ? '&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;end&amp;lt;Esc&amp;gt;-cc' : '&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even though &lt;code&gt;match(&quot;  case abc&quot;, 'def\|if\|case\|do') &amp;gt;= 0&lt;/code&gt; returns 1 (e.g. true).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="8699" LastEditorUserId="1821" LastEditDate="2016-11-09T13:30:06.100" LastActivityDate="2016-11-09T16:30:19.060" Title="Pattern in match in mapping in autocmd" Tags="|key-bindings|regular-expression|autocmd|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10229" PostTypeId="2" ParentId="10228" CreationDate="2016-11-09T13:31:45.410" Score="4" Body="&lt;p&gt;IIRC, it's related to the &lt;em&gt;bar&lt;/em&gt; character in command lines. You need to escape the bar twice, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ftplugin/ruby/myshortcuts.vim &#xA;inoremap &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; match(getline('.'), 'if\\|def\\|case\\|do') &amp;gt;= 0 ? '&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;end&amp;lt;Esc&amp;gt;-cc' : '&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW, you should make sure this is exactly &lt;code&gt;def&lt;/code&gt; (and not &lt;code&gt;define&lt;/code&gt;), that you aren't in string, nor comments.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-11-09T13:41:35.277" LastActivityDate="2016-11-09T13:41:35.277" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10230" PostTypeId="2" ParentId="10228" CreationDate="2016-11-09T16:30:19.060" Score="2" Body="&lt;p&gt;Alternatively, you can use &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; instead of &lt;code&gt;|&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType ruby inoremap &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; match(getline('.'), 'def\&amp;lt;bar&amp;gt;if\&amp;lt;bar&amp;gt;case\&amp;lt;bar&amp;gt;do') &amp;gt;= 0 ? '&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;end&amp;lt;Esc&amp;gt;-cc' : '&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;see: &lt;code&gt;:h &amp;lt;bar&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-11-09T16:30:19.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10231" PostTypeId="1" CreationDate="2016-11-09T17:33:14.387" Score="1" ViewCount="280" Body="&lt;p&gt;We are using a proprietary tool which uses Tcl and the C preprocessor to create input files.  Is there any way to get the Tcl syntax highlighting to also recognize the &lt;code&gt;#if&lt;/code&gt;, &lt;code&gt;#else&lt;/code&gt;, &lt;code&gt;#endif&lt;/code&gt; macro conditional from the C preprocessor.  The goal would be to be able to quickly jump between the macro blocks with the &lt;code&gt;%&lt;/code&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This kind of works if we set the language to c:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setf c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then placing the mouse of the relevant macro conditional and hitting the &lt;code&gt;%&lt;/code&gt; key&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if sldkfjlkj &#xA;set dog cat&#xA;set dog cat&#xA;set dog cat&#xA;#else&#xA;#if 0&#xA;set dog cat&#xA;#else&#xA;set dog cat&#xA;#endif&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10045" LastEditorUserId="5395" LastEditDate="2016-11-10T08:42:16.127" LastActivityDate="2016-11-17T15:11:57.467" Title="Mixing C-preprocessor and scripting language with highlighting?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10232" PostTypeId="2" ParentId="10209" CreationDate="2016-11-10T02:57:24.063" Score="6" Body="&lt;p&gt;Scenario: you are working in bash shell. First, make sure the local edit mode is vi:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ set -o vi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, when you find yourself working on a long command like the following, hit &lt;kbd&gt;Esc&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ fjhwfq this is my long command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;This will load your command into a temporary &lt;code&gt;vi&lt;/code&gt; session. Now you can edit it as you wish, and even add another command...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fjhwfq some long command&#xA;ls -l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&#xA;When you have finished editing, type &lt;kbd&gt;Esc&lt;/kbd&gt; &lt;code&gt;:wq&lt;/code&gt; and the command(s) will be executed, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ fjhwfq some long command&#xA;fjhwfq some long command&#xA;bash: fjhwfq: command not found&#xA;ls -l&#xA;total 44&#xA;-rw-r--r-- 1 ropata Domain Users 24073 Nov 10 14:17 _viminfo&#xA;drwxr-xr-x 1 ropata Domain Users     0 Jul 15 13:57 bin/&#xA;-rw-r--r-- 1 ropata Domain Users   956 Nov  7 10:43 custom_env&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="398" LastActivityDate="2016-11-10T02:57:24.063" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10233" PostTypeId="1" CreationDate="2016-11-10T08:34:27.070" Score="3" ViewCount="555" Body="&lt;p&gt;What I want to do is make &lt;code&gt;CursorMoved&lt;/code&gt; autocmd that would check if there is a search highlight is on and if it is it would start a timer that would deactivate it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS&#xA;I know about all available workarounds like &lt;a href=&quot;https://github.com/romainl/vim-cool&quot; rel=&quot;nofollow&quot;&gt;this plugin&lt;/a&gt; etc. They aren't good enough.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6634" LastEditDate="2016-11-10T08:41:44.383" LastActivityDate="2016-11-10T08:41:44.383" Title="Is there a way in vim to determine if something is highlighted after search?" Tags="|search|autocmd|highlight|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="10234" PostTypeId="1" CreationDate="2016-11-10T10:44:51.653" Score="9" ViewCount="9971" Body="&lt;p&gt;So, I installed the Airline plugin which is working quite nicely. But, I'd like it a bit sweeter. So I went to Powerline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I installed patched fonts from &lt;a href=&quot;https://github.com/powerline/fonts/tree/master/Hack&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/powerline/fonts/tree/master/Hack&lt;/a&gt; and modified my &lt;code&gt;.vimrc&lt;/code&gt; like so&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dL4yV.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dL4yV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;But, as you can see, it doesn't seem to work correctly... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a font issue or is it something else?&lt;/p&gt;&#xA;" OwnerUserId="10054" LastEditorUserId="6590" LastEditDate="2016-12-22T00:38:34.957" LastActivityDate="2017-02-12T10:53:04.910" Title="Powerline fonts not working on Airline" Tags="|plugin-airline|plugin-powerline|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10235" PostTypeId="1" CreationDate="2016-11-10T16:14:27.577" Score="7" ViewCount="1945" Body="&lt;p&gt;Say I have a bunch of files, ordered alphabetically: &lt;code&gt;1.txt&lt;/code&gt;, &lt;code&gt;2.txt&lt;/code&gt;, &lt;code&gt;3.txt&lt;/code&gt;, etc. (In a typical situation, I have hundreds of these, ordered by date.) If I open file 2, is there a quick way for me to open file 1? (Or, 3?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I'd like to be able to do this with a single keystroke. (Holding modifiers is ok.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: One thing I forgot to mention was that there are multiple folders that have these files in them. It's common for me to be in a directory (e.g. &lt;code&gt;/&lt;/code&gt;, and then need to edit files in &lt;code&gt;/tmp/a&lt;/code&gt; and &lt;code&gt;/tmp/b&lt;/code&gt;.) Although not a deal-breaker, it would be nice if I could change between &lt;code&gt;/tmp/a/2.txt&lt;/code&gt; and &lt;code&gt;/tmp/a/1.txt&lt;/code&gt; without having to reload vim.&lt;/p&gt;&#xA;" OwnerUserId="4748" LastEditorUserId="4748" LastEditDate="2016-11-11T14:23:06.507" LastActivityDate="2016-11-11T22:54:41.087" Title="How can I open the next/previous file alphabetically?" Tags="|multiple-files|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10236" PostTypeId="2" ParentId="10235" CreationDate="2016-11-10T16:55:36.783" Score="7" Body="&lt;p&gt;if all your files have a similar extension (.txt, .c, .py), place them in a folder and cd then &lt;code&gt;vim *.text&lt;/code&gt;, &lt;code&gt;vim *.c&lt;/code&gt;, &lt;code&gt;vim *.py&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the files will get added to args list, open the list by &lt;code&gt;:args&lt;/code&gt; to see the added files. These files can be navigated using &lt;code&gt;:n&lt;/code&gt; for next file and &lt;code&gt;:N&lt;/code&gt; for previous. &#xA;This could then be mapped to F7,F8 as so &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map &amp;lt;F7&amp;gt; :N&amp;lt;CR&amp;gt;&lt;/code&gt;, &lt;code&gt;map &amp;lt;F8&amp;gt; :n&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for single keystroke operation&lt;/p&gt;&#xA;" OwnerUserId="9004" LastEditorUserId="9004" LastEditDate="2016-11-11T07:41:13.063" LastActivityDate="2016-11-11T07:41:13.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10237" PostTypeId="2" ParentId="10235" CreationDate="2016-11-10T17:05:39.923" Score="8" Body="&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2544&quot; rel=&quot;noreferrer&quot;&gt;EditSimilar plugin&lt;/a&gt; has &lt;code&gt;:EditPrevious&lt;/code&gt; and &lt;code&gt;:EditNext&lt;/code&gt;, which go alphabetically through files in the current directory. There are also &lt;code&gt;:EditMinus&lt;/code&gt; / &lt;code&gt;:EditPlus&lt;/code&gt; for numbers in files, and other, generic &lt;code&gt;:EditSubstitute&lt;/code&gt;, &lt;code&gt;:EditRoot&lt;/code&gt;, as well as &lt;code&gt;:Split...&lt;/code&gt;, &lt;code&gt;:VSplit...&lt;/code&gt; variants. You can easily define mappings quick mappings to those commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1590&quot; rel=&quot;noreferrer&quot;&gt;unimpaired.vim plugin&lt;/a&gt; has (among many other, largely unrelated) &lt;code&gt;[f&lt;/code&gt; / &lt;code&gt;]f&lt;/code&gt; mappings that work like &lt;code&gt;:EditPrevious&lt;/code&gt; / &lt;code&gt;:EditNext&lt;/code&gt; (but aren't as robust last time I've checked).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-11-10T17:05:39.923" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10238" PostTypeId="2" ParentId="10235" CreationDate="2016-11-11T10:05:05.797" Score="5" Body="&lt;p&gt;Following up on my comment…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've created 1000 files named &lt;code&gt;1.txt&lt;/code&gt; to &lt;code&gt;1000.txt&lt;/code&gt; with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ touch {1..1000}.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Vim, I could use &lt;code&gt;:args *.txt&lt;/code&gt; to load each of them in the argument list but the order will be less than optimal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.txt&#xA;10.txt&#xA;100.txt&#xA;1000.txt&#xA;101.txt&#xA;102.txt&#xA;103.txt&#xA;104.txt&#xA;105.txt&#xA;106.txt&#xA;107.txt&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead, we could use &lt;code&gt;:help backtick-expansion&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args `ls\|sort -g`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which gives us a more usable order:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.txt&#xA;2.txt&#xA;3.txt&#xA;4.txt&#xA;5.txt&#xA;6.txt&#xA;7.txt&#xA;8.txt&#xA;9.txt&#xA;10.txt&#xA;11.txt&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From there, you can use argument-related commands to move around:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:n    &quot; next argument&#xA;:N    &quot; previous argument&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And map them if that's still too much typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Right&amp;gt; :n&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Left&amp;gt;  :N&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since we are at it, why not map our custom &lt;code&gt;:args&lt;/code&gt; command, too?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key&amp;gt; :args `ls\|sort -g`&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE: Feeding the argument list with hundreds of files (from plain &lt;code&gt;*.txt&lt;/code&gt; to structured &lt;code&gt;*.rb&lt;/code&gt; or whatever) is nearly instantaneous and Vim can perfectly handle thousands of buffers so you don't have to fear performance issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--- edit ---&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unlike the buffer list, argument lists can be local. This allows you to have different argument lists in different tab pages (or windows, but I find tab pages to be easier to reason about in such a scenario and… that's pretty much their intended use):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim&#xA;:arglocal `ls /tmp/a\|sort -g`&#xA;:tabnew&#xA;:arglocal `ls /tmp/b\|sort -g`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With such a setup, &lt;code&gt;:n&lt;/code&gt; and &lt;code&gt;:N&lt;/code&gt; will cycle through the first argument list in the first tab page and the second argument list in the second tab page.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-11-11T22:54:41.087" LastActivityDate="2016-11-11T22:54:41.087" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10239" PostTypeId="1" AcceptedAnswerId="11509" CreationDate="2016-11-11T13:39:10.877" Score="3" ViewCount="1778" Body="&lt;p&gt;When I set makeprg using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set makeprg=gcc\ -Wall\ -g\ %\ -o\ %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then invoke :make Vim does not pass proper filenames, because this command is translated as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gcc -Wall -g file.c -o file.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and executed. The compiler is then complaining that input and output files are the same, which is in fact dangerous. My question is how to change the second % in makeprg to have it without .c extension. The command exectuted should be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gcc -Wall -g file.c -o file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know what to put instead the second %.&lt;/p&gt;&#xA;" OwnerUserId="7370" LastActivityDate="2017-02-22T17:36:26.347" Title="How to customize % symbol in makeprg command" Tags="|command-line|replace|makeprg|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10240" PostTypeId="2" ParentId="10239" CreationDate="2016-11-11T14:00:25.127" Score="6" Body="&lt;p&gt;You can modify what is being expanded using so called filename modifiers. See the help at &lt;code&gt;:h filename-modifiers&lt;/code&gt; (&lt;a href=&quot;https://vimhelp.appspot.com/cmdline.txt.html#filename-modifiers&quot; rel=&quot;noreferrer&quot;&gt;link&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case you can e.g. use &lt;code&gt;:set makeprg=gcc\ -Wall\ -g\ %\ -o\ %&amp;lt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also the &lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-16.1&quot; rel=&quot;noreferrer&quot;&gt;faq&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-11-11T14:00:25.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10241" PostTypeId="2" ParentId="10093" CreationDate="2016-11-11T15:24:29.837" Score="2" Body="&lt;p&gt;As I have yet to internalise the regular expression &lt;a href=&quot;https://vi.stackexchange.com/a/10095/343&quot;&gt;Karl Yngve Lervåg uses&lt;/a&gt;, I'd probably just brute force this example (with not many substitutions to make) with the dot and &lt;code&gt;n&lt;/code&gt; commands:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Search for text to change, leaving cursor at end of match: &lt;code&gt;/ipt1/e&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Adjust cursor position if necessary with &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;N&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Make the first edit and repeat for the other search matches, then do the same for the second edit: &lt;code&gt;r4n.n.n.nr5n.n.n.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-11-14T13:20:31.307" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10242" PostTypeId="1" AcceptedAnswerId="11268" CreationDate="2016-11-11T16:50:27.767" Score="26" ViewCount="40232" Body="&lt;p&gt;I'm trying to upgrade my Vim installation to version 8.0, but it doesn't support both Python and Python 3 as the below image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(PS: Because of this problem, I cannot use the YCM (YouCompleteMe) plugin  now.)&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I installed Vim 8.0 as in the following commands.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I'm using Ubuntu&amp;nbsp;16.04 (Xenial Xerus).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How can I handle this problem?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo add-apt-repository ppa:jonathonf/vim&#xA;sudo apt update&#xA;sudo apt install vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/k6H3o.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/k6H3o.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10053" LastEditorUserId="927" LastEditDate="2017-07-22T13:48:00.533" LastActivityDate="2019-03-19T16:11:06.460" Title="Vim 8.0 Python support" Tags="|vimscript-python|installing|linux-ubuntu|" AnswerCount="7" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10243" PostTypeId="2" ParentId="10242" CreationDate="2016-11-11T18:50:57.357" Score="6" Body="&lt;p&gt;you should use&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sudo apt-get install vim-nox&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;instead, to get a &quot;huge-version&quot;.&lt;/p&gt;&#xA;" OwnerUserId="9681" LastEditorUserId="15" LastEditDate="2017-02-06T19:38:42.003" LastActivityDate="2017-02-06T19:38:42.003" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10244" PostTypeId="1" AcceptedAnswerId="10253" CreationDate="2016-11-11T19:25:46.997" Score="3" ViewCount="1558" Body="&lt;p&gt;What's the difference between &lt;code&gt;virtual column number&lt;/code&gt; and &lt;code&gt;column number&lt;/code&gt; (&lt;code&gt;%v&lt;/code&gt; and &lt;code&gt;%c&lt;/code&gt; respectively) in the &lt;code&gt;statusline&lt;/code&gt;?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it like &lt;code&gt;virtualedit&lt;/code&gt;, where the virtual column number counts the position of the cursor even if you're in a column that doesn't exist?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched in the &lt;code&gt;statusline&lt;/code&gt; help doc to see if the &lt;code&gt;virtual column number&lt;/code&gt; was ever mentioned again, and it isn't.&lt;/p&gt;&#xA;" OwnerUserId="9259" LastActivityDate="2016-11-12T09:51:29.227" Title="Difference between `virtual column number` and `column number` in statusline" Tags="|statusline|virtualedit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10245" PostTypeId="1" CreationDate="2016-11-11T20:30:19.967" Score="3" ViewCount="1110" Body="&lt;p&gt;&lt;code&gt;Netrw&lt;/code&gt; able to execute file with &lt;code&gt;xdg-open&lt;/code&gt; by pressing &lt;kbd&gt;x&lt;/kbd&gt;, how about &lt;code&gt;NERDTree&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[Response to downvote]&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;xdg-open&lt;/code&gt; can so easy/direct to work (which is the reason of downvote), then what's the point for this plugin (&lt;a href=&quot;https://github.com/aufgang001/vim-nerdtree_plugin_open&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/aufgang001/vim-nerdtree_plugin_open&lt;/a&gt;) exist ? Of course i do a quick try but it didn't work too.&lt;/p&gt;&#xA;" OwnerUserId="2670" LastEditorUserId="2670" LastEditDate="2016-11-11T23:25:46.437" LastActivityDate="2019-02-08T09:10:43.127" Title="How to execute xdg-open from NERDTree in Linux?" Tags="|external-command|linux|plugin-nerdtree|key-bindings|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10247" PostTypeId="2" ParentId="10174" CreationDate="2016-11-11T21:46:28.880" Score="1" Body="&lt;p&gt;The default settings of PuTTY are just fine. Do not change anything in &lt;code&gt;PuTTY-&amp;gt; Terminal -&amp;gt; Keyboard&lt;/code&gt; (see above) or disable in &lt;code&gt;PuTTY-&amp;gt; Terminal -&amp;gt; Features&lt;/code&gt; anything:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/is7Wh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/is7Wh.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can map in vi the NUM keys in the following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Esc&amp;gt;Oq 1&#xA;inoremap &amp;lt;Esc&amp;gt;Or 2&#xA;inoremap &amp;lt;Esc&amp;gt;Os 3&#xA;inoremap &amp;lt;Esc&amp;gt;Ot 4&#xA;inoremap &amp;lt;Esc&amp;gt;Ou 5&#xA;inoremap &amp;lt;Esc&amp;gt;Ov 6&#xA;inoremap &amp;lt;Esc&amp;gt;Ow 7&#xA;inoremap &amp;lt;Esc&amp;gt;Ox 8&#xA;inoremap &amp;lt;Esc&amp;gt;Oy 9&#xA;inoremap &amp;lt;Esc&amp;gt;Op 0&#xA;inoremap &amp;lt;Esc&amp;gt;On .&#xA;inoremap &amp;lt;Esc&amp;gt;OQ /&#xA;inoremap &amp;lt;Esc&amp;gt;OR *&#xA;inoremap &amp;lt;Esc&amp;gt;Ol +&#xA;inoremap &amp;lt;Esc&amp;gt;OS -&#xA;inoremap &amp;lt;Esc&amp;gt;OM &amp;lt;Enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This setting is an example for using the NUM key as they should be. Of course you can change the mappings as usual.&lt;/p&gt;&#xA;" OwnerUserId="9517" LastActivityDate="2016-11-11T21:46:28.880" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10248" PostTypeId="2" ParentId="3455" CreationDate="2016-11-11T21:55:42.470" Score="13" Body="&lt;p&gt;Add this to your .vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup NoModWhenReadOnly&#xA;    autocmd!&#xA;    autocmd BufRead * let &amp;amp;l:modifiable = !&amp;amp;readonly&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10083" LastEditorUserId="8520" LastEditDate="2023-05-01T12:55:12.030" LastActivityDate="2023-05-01T12:55:12.030" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10249" PostTypeId="1" AcceptedAnswerId="10284" CreationDate="2016-11-11T22:43:30.287" Score="26" ViewCount="3599" Body="&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27ttimeoutlen%27&quot; rel=&quot;noreferrer&quot;&gt;vim manual&lt;/a&gt; says we can use &lt;code&gt;timeoutlen&lt;/code&gt; to specify the timeout length of &lt;em&gt;mapped key sequences&lt;/em&gt; and can use &lt;code&gt;ttimeoutlen&lt;/code&gt; to specify the timeout length of &lt;em&gt;key codes&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A useful setting would be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set timeout timeoutlen=3000 ttimeoutlen=100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;(time out on mapping after three seconds, time out on key codes after&#xA;  a tenth of a second).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What are &lt;em&gt;key codes&lt;/em&gt;? How are they different from &lt;em&gt;mapped key sequences&lt;/em&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know an example of a mapped key sequence is &lt;code&gt;jk&lt;/code&gt; from the below mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap jk &amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this example, when I'm in insert mode and type &lt;code&gt;j&lt;/code&gt;, vim will wait &lt;code&gt;timeoutlen&lt;/code&gt; milliseconds for me to press &lt;code&gt;k&lt;/code&gt; before deciding what my intent is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what is a &lt;em&gt;key code&lt;/em&gt; and how does &lt;code&gt;ttimeoutlen&lt;/code&gt; affect it? Thanks you. &lt;/p&gt;&#xA;" OwnerUserId="7454" LastEditorUserId="1841" LastEditDate="2016-11-14T16:24:44.493" LastActivityDate="2023-04-21T10:50:49.367" Title="What is the difference between &quot;mapped key sequences&quot; and &quot;key codes&quot;? (timeoutlen v ttimeoutlen)" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10251" PostTypeId="2" ParentId="10245" CreationDate="2016-11-12T00:37:40.727" Score="3" Body="&lt;p&gt;I figure out the reason why &lt;a href=&quot;https://github.com/aufgang001/vim-nerdtree_plugin_open&quot; rel=&quot;nofollow noreferrer&quot;&gt;this plugin&lt;/a&gt; doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;git clone &lt;a href=&quot;https://github.com/aufgang001/vim-nerdtree_plugin_open.git&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/aufgang001/vim-nerdtree_plugin_open.git&lt;/a&gt; ~/.vim/vim-nerdtree_plugin_open.git&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The instruction is wrong, it should put inside &lt;code&gt;~/.vim/bundle&lt;/code&gt; (at least in my case):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/aufgang001/vim-nerdtree_plugin_open.git  ~/.vim/bundle/vim-nerdtree_plugin_open.git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2670" LastEditorUserId="2670" LastEditDate="2018-03-18T20:36:47.327" LastActivityDate="2018-03-18T20:36:47.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10253" PostTypeId="2" ParentId="10244" CreationDate="2016-11-12T09:51:29.227" Score="5" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%c&lt;/code&gt; -- column number, i.e. byte number.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%v&lt;/code&gt; and &lt;code&gt;%V&lt;/code&gt; -- virtual column number, i.e. column number on your screen.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So what is the difference between the actual and virtual column number? The answer is, that when using tabs, the virtual column number is an approximation of your current column number as if you were using spaces instead of tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*This answer is an excerpt from &lt;a href=&quot;https://stackoverflow.com/users/558647/hugo-ideler&quot;&gt;Hugo Ideler&lt;/a&gt;' &lt;a href=&quot;https://stackoverflow.com/questions/13544640/vim-how-does-the-statusline-v-work&quot;&gt;answer&lt;/a&gt; at stackoverflow&lt;/p&gt;&#xA;" OwnerUserId="9004" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-11-12T09:51:29.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10254" PostTypeId="1" AcceptedAnswerId="10255" CreationDate="2016-11-12T10:15:55.380" Score="1" ViewCount="523" Body="&lt;p&gt;I need to re-factor a line with a repeated pattern in a way to apply some math over numbers. For e.g. let's assume the following line of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;testpoints = [Point(1,2), Point(1,1), Point(1,2), Point(0,2), Point(2,2), Point(3,3), Point(1,3), Point(1,4), Point(2,3), Point(2,0), Point(2,1),]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and some function should be applied to all matches for e.g. (x, y) -&gt; (x*10, y*10). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;testpoints = [Point(10,20), Point(10,10), Point(10,20), Point(0,20), Point(20,20), Point(30,30), Point(10,30), Point(10,40), Point(20,30), Point(20,0), Point(20,10),]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The obvious solution is to add '*10' after both arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\(\d\+\)\(,\s*\)\(\d\+\)/\1*10\2\3*10/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, probably it will be better to do the math in the VIM. I tried with &lt;code&gt;:g&lt;/code&gt;&#xA;&lt;strong&gt;but with no success&lt;/strong&gt;:&#xA;&lt;s&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/(\s*\d\+\s*,/normal 10&amp;lt;cr&amp;gt;af,w10&amp;lt;cr&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;/s&gt; &#xA;The idea was to find the proper &lt;code&gt;(&lt;/code&gt; and then to do 10 &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;A&lt;/kbd&gt; , then move to next number with &lt;kbd&gt;w&lt;/kbd&gt; and again to increment ten times ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me wrap up:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is possible to be done this with &lt;code&gt;:g&lt;/code&gt; command ? &lt;/li&gt;&#xA;&lt;li&gt;Is there another more vim-native way for such substitution with math?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="9633" LastEditorUserId="9633" LastEditDate="2016-11-12T11:24:30.000" LastActivityDate="2016-11-12T11:24:30.000" Title="What is the vim native way to apply math over pattern?" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10255" PostTypeId="2" ParentId="10254" CreationDate="2016-11-12T10:28:06.433" Score="4" Body="&lt;p&gt;See &lt;code&gt;sub-replace-expression&lt;/code&gt; and &lt;code&gt;:help submatch()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\(\d\+\)/\=submatch(1)*10/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;FWIW, the &lt;code&gt;:global&lt;/code&gt; command is completely unrelated to the problem at hand.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-11-12T10:28:06.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10256" PostTypeId="1" CreationDate="2016-11-12T10:55:37.700" Score="4" ViewCount="2732" Body="&lt;p&gt;I mostly use Vim (or MacVim) to edit text, but occasionally (such as in writing this question), I use the Mac OS text editing keybindings built in to all text entry fields accessed through a Mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find these binding extremely intuitive for &lt;em&gt;writing&lt;/em&gt; text (whereas Vim bindings are better focused on &lt;em&gt;editing&lt;/em&gt; text.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Specifically, for those unfamiliar with a Mac:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option-left moves left a word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option-right moves right a word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Command-left moves to the &lt;em&gt;soft wrapped&lt;/em&gt; beginning of the line (akin to g0 in Vim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Command-right moves to the soft-wrapped end of the line, after the space (since soft-wrapped lines are broken between words in Mac text boxes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option or Command delete will delete to the beginning of the word or soft-wrapped line, respectively.  Adding the Fn key as well means deleting to the end of the word or soft-wrapped line.  (The delete key on the Mac is what PCs call backspace; Fn-delete on a Mac means to delete forward one character.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option up and down work on &lt;em&gt;actual&lt;/em&gt; lines, irrespective of the soft-wrapping positions, and additionally move to the start or end of the line moved to, respectively.  In other words they align to k0 and j$ in Vim.  In usual text documents this is considered moving to the start or end of a &lt;em&gt;paragraph.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Command up goes to the beginning of the entire text document, and Command down goes to the very end of the entire text document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shift can be combined with any of these motions to highlight text.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I emulate these behaviors in Vim, for &lt;em&gt;insert&lt;/em&gt; mode only?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note: While writing this question I discovered that in Vim, the shift key modifies left or right arrow key presses the way that the option key does in Mac text fields.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: MacVim specific answers are okay, but I do use Vim in the terminal a lot as well.  (More than I use MacVim, in fact.)&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2017-02-11T13:15:48.293" Title="Emulate Apple &quot;option&quot; and &quot;command&quot; key text motions?" Tags="|key-bindings|insert-mode|macos|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10257" PostTypeId="1" AcceptedAnswerId="10279" CreationDate="2016-11-12T11:44:02.390" Score="1" ViewCount="1314" Body="&lt;p&gt;I want to have some specific snippets for each file that I am editing. Like, I want to type &quot;ppp&quot; just for &quot;proper point groups&quot;, or &quot;iff&quot; for &quot;if and only if&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be more specific, I want &lt;strong&gt;an additional unique set of snippets for each file&lt;/strong&gt; I am editing. For example, when I write about group theory, I will want things like above to be shorthanded. But when I write about geometry, I will want &quot;hom&quot; stands for &quot;\operatorname{\mathcal{Hom}}&quot;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I succeeded to add a absolute path to UltiSnips search directory, like the following in my VIMRC:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsSnippetDirectories=['UltiSnips','C:\Users\xxx\Drafts\UltiSnips']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to add an relative path like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsSnippetDirectories=['UltiSnips','.\UltiSnips']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But UltiSnips just ignores it. Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, can I add a modeline to get the current directory, and then set the variable &lt;code&gt;g:UltiSnipsSnippetDirectories&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI.: I am on windows 10.&lt;/p&gt;&#xA;" OwnerUserId="8036" LastEditorUserId="8036" LastEditDate="2016-11-14T11:43:21.257" LastActivityDate="2016-11-14T13:39:22.340" Title="Add current directory to UltiSnips search directory" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10258" PostTypeId="2" ParentId="10256" CreationDate="2016-11-12T14:58:24.203" Score="3" Body="&lt;h2&gt;MacVim GUI&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Opt-Left and Opt-Right already do what you want by default, as well as Alt-Backspace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cmd-Left and Cmd-Right are mapped to &lt;code&gt;&amp;lt;Home&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;End&amp;gt;&lt;/code&gt; by default. You can remap them to do whatever you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;D-Left&amp;gt; &amp;lt;C-o&amp;gt;g0&#xA;inoremap &amp;lt;D-Right&amp;gt; &amp;lt;C-o&amp;gt;g$&#xA;nnoremap &amp;lt;D-Left&amp;gt; g0&#xA;nnoremap &amp;lt;D-Right&amp;gt; g$&#xA;xnoremap &amp;lt;D-Left&amp;gt; g0&#xA;xnoremap &amp;lt;D-Right&amp;gt; g$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alt-Backspace already works the way you want but you will need another mapping for Cmd-Backspace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;D-BS&amp;gt; &amp;lt;C-o&amp;gt;dg0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Fn-Alt-Backspace could be approximated with this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;A-Del&amp;gt; &amp;lt;C-o&amp;gt;dw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as I know, Fn-Cmd-Backspace has never done anything in Cocoa widgets (I am a bit behind, though) but you could create a Vim mapping if you really want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;D-Del&amp;gt; &amp;lt;C-o&amp;gt;dg$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Opt-Up and Opt-down are mapped to &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; by default, not &lt;code&gt;k0&lt;/code&gt; or &lt;code&gt;k$&lt;/code&gt;. The original Mac OS X behavior has always been a bit complex and non-deterministic, though, so I think you will need a bit of vimscript to reach your goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cmd-Up and Cmd-Down already do what you want but Shift-Cmd-Up and Shift-Cmd-Down don't do anything. Once again, custom mappings to the rescue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;S-D-Up&amp;gt; v&amp;lt;C-Home&amp;gt;0&#xA;nnoremap &amp;lt;S-D-Down&amp;gt; v&amp;lt;C-End&amp;gt;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;CLI Vim&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The Cmd key is only visible to the MacVim GUI so you won't be able to use it in CLI Vim &lt;em&gt;at all&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Alt key is usable but not very dependable. Some things will work directly in Vim, some things will require you to create shortcuts directly in your terminal emulator, some things won't ever work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, CLI Vim can't register multiple modifiers at all.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Conclusion&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;While it is relatively easy to make the MacVim GUI behave like standard Cocoa text editors, it is virtually impossible to reach that goal with CLI Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, Vim's command language being vastly more expressive than any &quot;native&quot; set of shortcuts makes it actually counter-productive to try to make it adhere to your platform's limited conventions. Vim is internally consistent and that's what makes it valuable. Dumbing it down will only deserve you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that your goal is simply not worth the hassle.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-11-12T14:58:24.203" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10259" PostTypeId="1" AcceptedAnswerId="10260" CreationDate="2016-11-12T15:10:39.063" Score="1" ViewCount="48" Body="&lt;p&gt;Of course, I could make a mapping, but I was wondering if there's a default binding.&lt;/p&gt;&#xA;" OwnerUserId="10087" LastActivityDate="2016-11-12T15:24:13.397" Title="Is there a default binding to go into command-line mode and append a '!'?" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10260" PostTypeId="2" ParentId="10259" CreationDate="2016-11-12T15:24:13.397" Score="1" Body="&lt;p&gt;No, there isn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check yourself by going to &lt;a href=&quot;http://vimhelp.appspot.com/index.txt.html#index&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help index&lt;/code&gt;&lt;/a&gt; and searching for &lt;code&gt;!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add such a mapping with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;: :&amp;lt;Up&amp;gt;!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-11-12T15:24:13.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10261" PostTypeId="2" ParentId="10093" CreationDate="2016-11-12T18:27:00.717" Score="1" Body="&lt;p&gt;I run into this often enough myself. My preferred way to handle it is manually with some slightly advance search and replace techniques.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, since you are going to be changing the last character of the block, and you can visually see what you want to work on, I might do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/ipt1/e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will search for the target text and put your cursor at the end (the 1) which is what you want to change.  Then I would do the following keystrokes in normal mode&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;r4     # replace the 1 with a 4&#xA;n      # goes to the next match, places you at the end&#xA;.      # does the same substitution of 1 to 4&#xA;       # repeat n and . until you've finished the block for 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you get to the next block where you want a 5, just do a &lt;code&gt;r5&lt;/code&gt; and then &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then are just bouncing between the 'n' and '.' and if you go too far, you can just use 'u' to undo.  Very fast and limited typing is required.&lt;/p&gt;&#xA;" OwnerUserId="9017" LastEditorUserId="9017" LastEditDate="2016-11-23T13:48:01.173" LastActivityDate="2016-11-23T13:48:01.173" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10262" PostTypeId="1" AcceptedAnswerId="10265" CreationDate="2016-11-12T20:10:14.360" Score="0" ViewCount="337" Body="&lt;p&gt;I'm trying to bind &lt;code&gt;&amp;lt;C-S-S&amp;gt;&lt;/code&gt; (Control + Shift + S) to send the selected test to a system command, and to then replace the selected text with the output of the system call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;C-S-S&amp;gt; :'&amp;lt;,'&amp;gt;!echo 'Output of system call'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it only seems to work in gvim (and with an annoying confirmation message from the vim console, making the user press Enter to get rid of it). In addition, even if this would work, it doesn't actually send the selected text as an input to &lt;code&gt;echo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to fix this so that it works in terminal vim as desired?&lt;/p&gt;&#xA;" OwnerUserId="6499" LastActivityDate="2016-11-12T20:34:02.927" Title="Bind Key to Replace Selected Text with Output of System Call (in Terminal Vim)" Tags="|key-bindings|visual-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10263" PostTypeId="1" CreationDate="2016-11-12T20:23:32.273" Score="0" ViewCount="155" Body="&lt;p&gt;Here is the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;C-S-S&amp;gt; :s/\v([.!?])\s+/\1\r\r/g&amp;lt;CR&amp;gt;`&amp;lt;i&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command takes a text selection and divides it into sentences separated by new lines. Why would this work in gvim and not vim?&lt;/p&gt;&#xA;" OwnerUserId="6499" LastActivityDate="2016-11-15T12:46:57.957" Title="Why does this command work in gvim but not in (terminal) vim?" Tags="|gvim|visual-mode|" AnswerCount="1" CommentCount="1" ClosedDate="2016-11-17T06:27:36.670" ContentLicense="CC BY-SA 3.0" />
  <row Id="10264" PostTypeId="2" ParentId="10262" CreationDate="2016-11-12T20:33:05.957" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You can't use multiple modifiers in CLI Vim mappings. Find another mapping.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;See &lt;code&gt;:help hit-enter&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-11-12T20:33:05.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10265" PostTypeId="2" ParentId="10262" CreationDate="2016-11-12T20:34:02.927" Score="1" Body="&lt;p&gt;There are a couple things I notice.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You can't map to &lt;code&gt;&amp;lt;C-S-S&amp;gt;&lt;/code&gt;. I wrote a more extensive answer on that &lt;a href=&quot;https://vi.stackexchange.com/questions/8856/mapping-ctrl-with-equal-sign&quot;&gt;here&lt;/a&gt;, but the basic problem is that &lt;code&gt;&amp;lt;C-S-S&amp;gt;&lt;/code&gt; does not produce an ASCII value different then &lt;code&gt;&amp;lt;C-s&amp;gt;&lt;/code&gt; so vim is unable to distinguish the difference between them.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It's quite possible mapping to &lt;code&gt;&amp;lt;C-s&amp;gt;&lt;/code&gt; will not work in your terminal. This is because the terminal receives and processes the command before it's ever sent to vim, so vim never gets to process the key. To verify that &lt;code&gt;&amp;lt;C-s&amp;gt;&lt;/code&gt; really is being processed by vim, try typing &lt;code&gt;i&amp;lt;C-v&amp;gt;&amp;lt;C-s&amp;gt;&lt;/code&gt;. If anything comes up, you're good to go. Otherwise, you'll be unable to map &lt;code&gt;&amp;lt;C-s&amp;gt;&lt;/code&gt; unless you configure your terminal to send a specific escape code. (IMO this is more trouble than it's worth) Gvim is better at handling control characters, so the easiest solution is to switch to gvim.&lt;/p&gt;&#xA;&lt;p&gt;Another easy solution is just to use a leader mapping instead of a &lt;code&gt;ctrl-x&lt;/code&gt; mapping.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This one is more of a style thing, but the &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; you included in the mapping is unnecessary. When you are in visual mode, typing &lt;code&gt;:&lt;/code&gt; will automatically fill it in for you. You could simplify your mapping if you take it out.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This one is also a style thing, but generally &lt;code&gt;xnoremap&lt;/code&gt; works better than &lt;code&gt;vnoremap&lt;/code&gt;. You can read more about the reasons why in &lt;code&gt;:h mapmode-x&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;All of this leads to the number one thing you're missing: You're not actually sending the selected command. To do this is actually pretty simply. You'll just need to yank your selection before running the command, and then use &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; to insert the yanked text.&lt;/p&gt;&#xA;&lt;p&gt;Putting all of these recommendations together, I would do the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;leader&amp;gt;s ygv:!&amp;lt;C-r&amp;gt;&amp;quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-11-12T20:34:02.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10266" PostTypeId="2" ParentId="10263" CreationDate="2016-11-12T20:34:47.370" Score="1" Body="&lt;p&gt;You can't use multiple modifiers in CLI Vim mappings. Find another mapping.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-11-12T20:34:47.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10267" PostTypeId="1" CreationDate="2016-11-12T22:27:18.363" Score="0" ViewCount="195" Body="&lt;p&gt;Is it possible to delete the current visual block selection and all other occurences from the current buffer?&lt;/p&gt;&#xA;" OwnerUserId="6878" LastActivityDate="2016-11-14T16:55:52.787" Title="Remove current (block) selection" Tags="|visual-block|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10268" PostTypeId="2" ParentId="10267" CreationDate="2016-11-13T01:12:17.213" Score="0" Body="&lt;p&gt;You could do something like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;visual&lt;/code&gt; around the block you want to delete, hit &lt;code&gt;y&lt;/code&gt; to yank, and then do &lt;code&gt;:%s/&amp;lt;C-R&amp;gt;&quot;//&lt;/code&gt; to replace all instances of it with empty text.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2016-11-13T01:12:17.213" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10269" PostTypeId="2" ParentId="7699" CreationDate="2016-11-13T03:02:51.513" Score="5" Body="&lt;p&gt;In your config you can add &lt;code&gt;zz&lt;/code&gt; to &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt;. It has the major side effect of centering your cursor. I don't mind and much prefer it to craning my neck. I tried &lt;code&gt;scrolloff&lt;/code&gt; and &lt;code&gt;CTRL-E&lt;/code&gt; is just uncomfortable to me.&lt;/p&gt;&#xA;&lt;p&gt;Type the following in &lt;code&gt;:&lt;/code&gt; or .vimrc&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;nnoremap j jzz&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;nnoremap k kzz&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Sourced: &lt;a href=&quot;http://vim.wikia.com/wiki/Keep_your_cursor_centered_vertically_on_the_screen&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Keep_your_cursor_centered_vertically_on_the_screen&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10093" LastEditorUserId="10093" LastEditDate="2023-02-26T20:12:22.197" LastActivityDate="2023-02-26T20:12:22.197" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10270" PostTypeId="1" AcceptedAnswerId="10271" CreationDate="2016-11-13T05:14:01.213" Score="0" ViewCount="405" Body="&lt;p&gt;I recently went through and cleaned up my vimrc. In so doing, I inadvertently removed some code or a plugin that inserted a bluish &lt;code&gt;&amp;gt;&lt;/code&gt; character at the end of lines that were truncated because they were wider than the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only option I have now related wrapping is &lt;code&gt;set nowrap&lt;/code&gt;. Which option is responsible for showing visual indication that a line has been truncated?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;mg&lt;/code&gt; editor shows a &lt;code&gt;$&lt;/code&gt; at the right edge of a truncated line, as well as the left edge (&lt;code&gt;mg&lt;/code&gt; always shows the leftmost part of &quot;inactive&quot; lines regardless of cursor position). Is there a way to mimic this behavior when scrolling horizontally?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2016-12-16T06:48:41.080" LastActivityDate="2016-12-16T06:48:41.080" Title="Visual indication that lines have been truncated" Tags="|wrapping|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10271" PostTypeId="2" ParentId="10270" CreationDate="2016-11-13T09:33:01.367" Score="3" Body="&lt;p&gt;From vim help (&lt;code&gt;:h listchars&lt;/code&gt;) :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;extends:c      Character to show in the last column, when 'wrap' is&#xA;               off and the line continues beyond the right of the&#xA;               screen.&#xA;precedes:c     Character to show in the first column, when 'wrap'&#xA;               is off and there is text preceding the character&#xA;               visible in the first column.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So the following will set this characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set listchars=extends:&amp;gt;,precedes:&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change them to your desired character and you could colorize them with following highlighting group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi NonText guifg=#ffffff ctermfg=gray&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7976" LastEditorUserId="7976" LastEditDate="2016-11-13T09:44:04.803" LastActivityDate="2016-11-13T09:44:04.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10272" PostTypeId="2" ParentId="10256" CreationDate="2016-11-13T11:53:23.737" Score="1" Body="&lt;p&gt;Have a look at Tim Pope &lt;a href=&quot;https://github.com/tpope/vim-rsi&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-rsi&lt;/a&gt;, a very useful Readline key bindings for Vim in insert mode. You can map cmd-key to meta-key easily in iTerm2. I would prefer it instead of Terminal.app. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;rsi-maps:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; Go to beginning of line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; Go to end of line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-b&amp;gt;&lt;/code&gt;  Go backwards one character&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;M-b&amp;gt;&lt;/code&gt;   Go backwards one word&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt;   Move forward one character&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;M-f&amp;gt;&lt;/code&gt;   Move forward one word&lt;/p&gt;&#xA;&#xA;&lt;p&gt;.... and so on ..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think, this is, what you are looking for!&lt;/p&gt;&#xA;" OwnerUserId="911" LastActivityDate="2016-11-13T11:53:23.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10274" PostTypeId="1" AcceptedAnswerId="10275" CreationDate="2016-11-13T12:54:10.600" Score="0" ViewCount="189" Body="&lt;pre&gt;&lt;code&gt;if (&amp;amp;filetype=='c' || &amp;amp;filetype=='cpp' || &amp;amp;filetype=='h')&#xA;  autocmd VimEnter * NERDTree&#xA;  autocmd VimEnter * wincmd p&#xA;&#xA;  &quot; class outline viewer : F8&#xA;  nmap &amp;lt;F8&amp;gt; :TagbarToggle&amp;lt;CR&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried this vimrc script, but it is not working.&lt;/p&gt;&#xA;" OwnerUserId="9074" LastActivityDate="2016-11-13T18:16:40.490" Title="enable NERDTree only when editing h/c/cpp files" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10275" PostTypeId="2" ParentId="10274" CreationDate="2016-11-13T13:34:24.527" Score="0" Body="&lt;p&gt;Not sure but I think &lt;code&gt;VimEnter&lt;/code&gt; is called before &lt;code&gt;&amp;amp;filetype&lt;/code&gt; is set so that &lt;code&gt;if&lt;/code&gt; is never executed. Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup C&#xA;    autocmd!&#xA;    autocmd FileType c,cpp NERDTree | wincmd p | nmap &amp;lt;F8&amp;gt; :TagbarToggle&amp;lt;CR&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Better to write an filetype plugin (see &lt;code&gt;:h ftplugin&lt;/code&gt;). For example I have a file in &lt;code&gt;~/.config/nvim/after/ftplugin/javascript.vim&lt;/code&gt; with this content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost,BufWritePost &amp;lt;buffer&amp;gt; Accio eslint&#xA;autocmd InsertLeave,TextChanged &amp;lt;buffer&amp;gt; call semhl#highlight()&#xA;autocmd FileType javascript call semhl#highlight()&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-]&amp;gt; :TernDef&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These auto-commands and the mapping are only available for JavaScript files. I don't know how to call an &lt;code&gt;ftplugin&lt;/code&gt; for both C and C++, but the content would be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType c,cpp NERDTree | wincmd p&#xA;nmap &amp;lt;buffer&amp;gt; &amp;lt;F8&amp;gt; :TagbarToggle&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use Vim the location of this file would be &lt;code&gt;~/.vim/after/ftplugin/c.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Edit&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;https://vi.stackexchange.com/a/3178/786&quot;&gt;this answer&lt;/a&gt; you can use symbolic links or source your &lt;code&gt;c.vim&lt;/code&gt; ftplugin from your &lt;code&gt;cpp.vim&lt;/code&gt; plugin (or vice versa).&lt;/p&gt;&#xA;" OwnerUserId="786" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-11-13T18:16:40.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10277" PostTypeId="1" CreationDate="2016-11-14T00:34:11.600" Score="3" ViewCount="81" Body="&lt;p&gt;I have an SQL file that I have to work on from the command line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- Query 1&#xA;select 1;&#xA;-- Query 2&#xA;select *&#xA;from metadata;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've marked line &lt;code&gt;4&lt;/code&gt; as &lt;code&gt;a&lt;/code&gt; (&lt;code&gt;4Gma&lt;/code&gt;) and line &lt;code&gt;5&lt;/code&gt; as &lt;code&gt;b&lt;/code&gt; (&lt;code&gt;5Gmb&lt;/code&gt;), then execute &lt;code&gt;:'a,'b w !mysql -u root db \| less&lt;/code&gt; to view the contents. I've mapped this snippet to &lt;code&gt;F5&lt;/code&gt; so that I can simply reset marks &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; and press &lt;code&gt;F5&lt;/code&gt; to see the result. This works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to do now is insert the results of the query into the document, much like what &lt;code&gt;:r !cmd&lt;/code&gt; provides. I know I can replace &lt;code&gt;%s&lt;/code&gt; in &lt;code&gt;r !cmd&lt;/code&gt;, but &lt;code&gt;%s&lt;/code&gt; is replaced with the filename, and I only want to execute the SQL query in the current range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible, and if so, how?&lt;/p&gt;&#xA;" OwnerUserId="10101" LastEditorUserId="10101" LastEditDate="2016-11-14T01:46:35.897" LastActivityDate="2016-11-14T10:44:45.210" Title="How can I write a range to a command, and then read the resulting output?" Tags="|command-line|external-command|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10278" PostTypeId="2" ParentId="10267" CreationDate="2016-11-14T00:45:35.470" Score="1" Body="&lt;p&gt;It's probably not completely reliable, but you could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xno &amp;lt;silent&amp;gt; mbc :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;move_blocks(1)&amp;lt;CR&amp;gt;&#xA;xno &amp;lt;silent&amp;gt; mbd :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;move_blocks(0)&amp;lt;CR&amp;gt;&#xA;&#xA;fu! s:move_blocks(clean_them_only) abort&#xA;    let view  = winsaveview()&#xA;    let block = s:get_its_text()&#xA;&#xA;    call cursor(1,1)&#xA;    while s:you_find_a(block)&#xA;        let orig_pos = getpos('.')&#xA;        call s:remove_it(block, a:clean_them_only)&#xA;        call setpos('.', orig_pos)&#xA;    endwhile&#xA;&#xA;    if !a:clean_them_only&#xA;        sil! exe &quot;keepj keepp %s/\&amp;lt;C-A&amp;gt;//g&quot;&#xA;    endif&#xA;&#xA;    call winrestview(view)&#xA;endfu&#xA;&#xA;fu! s:get_its_text() abort&#xA;&#xA;    let unnamed_reg_contents = getreg('&quot;')&#xA;    let unnamed_reg_type     = getregtype('&quot;')&#xA;&#xA;    sil norm! gvy&#xA;    let block = split(@&quot;, &quot;\n&quot;)&#xA;&#xA;    call setreg('&quot;', unnamed_reg_contents, unnamed_reg_type)&#xA;&#xA;    return block&#xA;endfu&#xA;&#xA;fu! s:you_find_a(block) abort&#xA;    let block                = a:block&#xA;    let pattern_first_line   = '\V'.escape(block[0],'\')&#xA;    let found_its_first_line = search(pattern_first_line, 'cW')&#xA;&#xA;    while found_its_first_line&#xA;&#xA;        let orig_pos      = getpos('.')&#xA;        let idx_line      = line('.')+1&#xA;        let start_col     = col('.')&#xA;        let rest_of_block = block[1:]&#xA;&#xA;        if !s:is_complete(rest_of_block, idx_line, start_col)&#xA;            let found_its_first_line = search(pattern_first_line, 'W')&#xA;            continue&#xA;        endif&#xA;&#xA;        call setpos('.', orig_pos)&#xA;        return 1&#xA;    endwhile&#xA;&#xA;    return 0&#xA;endfu&#xA;&#xA;fu! s:is_complete(rest_of_block, idx_line, start_col) abort&#xA;    let orig_pos          = getpos('.')&#xA;    let idx_line          = a:idx_line&#xA;    let start_col         = a:start_col&#xA;    let rest_of_block     = a:rest_of_block&#xA;    let rest_is_there_too = 1&#xA;&#xA;    for text in rest_of_block&#xA;        let pattern_subsequent_line = '\V\%'.idx_line.'l\%'.start_col.'c'.&#xA;                                    \ escape(text,'\')&#xA;&#xA;        if !search(pattern_subsequent_line, 'W')&#xA;            let rest_is_there_too = 0&#xA;            break&#xA;        endif&#xA;&#xA;        let idx_line += 1&#xA;    endfor&#xA;&#xA;    call setpos('.', orig_pos)&#xA;    return rest_is_there_too&#xA;endfu&#xA;&#xA;fu! s:remove_it(block, clean_them_only) abort&#xA;    let block     = a:block&#xA;    let idx_line  = line('.')&#xA;    let start_col = col('.')&#xA;&#xA;    for text in block&#xA;        let pattern_block_line = '\V\%'.idx_line.'l\%'.start_col.'c'.escape(text,'\')&#xA;        let replacement        = '\=repeat(&quot;'.&#xA;                                            \ (a:clean_them_only?' ':&quot;\&amp;lt;C-A&amp;gt;&quot;).&#xA;                                            \ '&quot;,'.len(text).')'&#xA;&#xA;        sil! exe 'keepj keepp '.idx_line.&#xA;                 \ 's/'.pattern_block_line.'/'.replacement.'/'&#xA;&#xA;        let idx_line += 1&#xA;    endfor&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It installs 2 mappings in visual mode triggered by the &lt;code&gt;mbc&lt;/code&gt; and &lt;code&gt;mbd&lt;/code&gt; key sequences.&#xA;To use it, you would have to visually select the block you want to remove and hit &lt;code&gt;mbc&lt;/code&gt; to replace all occurrences with spaces, or hit &lt;code&gt;mbd&lt;/code&gt; to remove them entirely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't test it very long, and only on this sample text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;debitis  Elit  sit distinctio  saepe debitis  voluptatibus eveniet.  Pariatur accusantium&#xA;Eius     cumque hic eligendi magnam? Eius     ducimus  maxime fugiat sed eum. Earum at cumque&#xA;quisquam at quia nulla Nihil porro   quisquam impedit est?&#xA;&#xA;Elit  sit distinctio  saepe debitis  voluptatibus eveniet.  Pariatur accusantium&#xA;cumque hic eligendi magnam? Eius     ducimus  maxime fugiat sed eum. Earum at cumque&#xA;at quia nulla Nihil porro   quisquam impedit est?&#xA;&#xA;Elit  sit distinctio  saepe debitis  voluptatibus eveniet.  Pariatur accusantium&#xA;cumque hic eligendi magnam?          ducimus  maxime fugiat debitis sed eum. Earum at cumque&#xA;debitis  at quia nulla Nihi quisquam impedit est?           Eius    &#xA;Eius                                                        quisquam&#xA;quisquam Elit  sit distinctio  saepe  debitis  voluptatibus eveniet.  Pariatur accusantium&#xA;cumque hic eligendi debitis   magnam? Eius     ducimus  maxime fugiat sed eum. Earum at cumque&#xA;at quia nulla Nihil Eius      porro   quisquam impedit est?&#xA;                    quisquam&#xA;Elit  sit distinctio  saepe debitis  voluptatibus eveniet.  Pariatur accusantium     debitis &#xA;cumque hic eligendi magnam? Eius     ducimus  maxime fugiat sed eum. Earum at cumque Eius    &#xA;at quia nulla Nihil porro   quisquam impedit est?                                    quisquam&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to remove this block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;debitis &#xA;Eius    &#xA;quisquam&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seemed to work:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/IRjRx.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IRjRx.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there may be cases where it won't, I don't know.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-11-14T16:55:52.787" LastActivityDate="2016-11-14T16:55:52.787" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10279" PostTypeId="2" ParentId="10257" CreationDate="2016-11-14T09:29:03.713" Score="3" Body="&lt;p&gt;First of all &lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt#L372-L374&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h UltiSnips-snippet-search-path&lt;/code&gt;&lt;/a&gt; tells us:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Snippet definition files are stored in snippet directories. A snippet&#xA;  directory must be a subdirectory of a directory defined in the 'runtimepath'&#xA;  option.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which makes me think that you can not create snippets directories anywhere since that would mean constantly add your current path to &lt;code&gt;runtimepath&lt;/code&gt; which doesn't sound like a good idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus I would advise the following solution: Use one directory containing your customs snippets, in this directory create snippets for &quot;custom&quot; filetype and add these files types to the files you want to edit (As both Vim and Ultisnips handle &lt;a href=&quot;https://vi.stackexchange.com/q/4940/1841&quot;&gt;multiple filetypes&lt;/a&gt; that shouldn't cause a problem).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use your current snippets directory &lt;code&gt;'C:\Users\xxx\Drafts\UltiSnips'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;In it, put files named &lt;code&gt;custom1.snippets&lt;/code&gt; containing the snippets you want to use in the files which will use the &lt;code&gt;ppp&lt;/code&gt; snippets.&lt;/li&gt;&#xA;&lt;li&gt;Then you can use &lt;code&gt;:UltiSnipsAddFiletypes&lt;/code&gt; (&lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt#L223&quot; rel=&quot;nofollow noreferrer&quot;&gt;here is the doc&lt;/a&gt;) to select the snippets used in your file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; (After the answer was accepted)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option could be the following: I didn't test it and it is based on my understanding of the doc so it may not work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same doc topic also says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you keep your snippets in a .vim subdirectory called&#xA;  &quot;mycoolsnippets&quot; and you want to make use of the default snippets that come&#xA;  with UltiSnips, add the following to your vimrc file. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsSnippetDirectories=[&quot;UltiSnips&quot;, &quot;mycoolsnippets&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;If you do not want to use the third party snippets that come with plugins,&#xA;  define the variable accordingly: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsSnippetDirectories=[&quot;mycoolsnippets&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;You can also redefine the search path on a buffer by buffer basis by setting&#xA;  the variable &lt;code&gt;b:UltiSnipsSnippetDirectories&lt;/code&gt;. This variable takes precedence&#xA;  over the global variable.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So maybe (emphasis on maybe) you could:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Create several snippets directories &lt;code&gt;project1&lt;/code&gt;, &lt;code&gt;project2&lt;/code&gt; at the same level as the &lt;code&gt;UltiSnips&lt;/code&gt; directory.&lt;/li&gt;&#xA;&lt;li&gt;Each of these directories would contain differents snippets files for different filetypes in different projects.&lt;/li&gt;&#xA;&lt;li&gt;Then based on the project your file belongs to you could &lt;code&gt;let b:UltiSnipsSnippetDirectories=[&quot;project1&quot;]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think that this way you wouldn't need to play with the filetypes nor the &lt;code&gt;runtimepath&lt;/code&gt; You simply would need to modify &lt;code&gt;b:UltiSnipsSnippetDirectories&lt;/code&gt; which should be done manually for each buffer because &lt;code&gt;let&lt;/code&gt; is prohibited on modelines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; That as I said previously I didn't test that so I may be missing something.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-11-14T13:39:22.340" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10281" PostTypeId="2" ParentId="10277" CreationDate="2016-11-14T10:44:45.210" Score="3" Body="&lt;p&gt;There is a &lt;code&gt;:h range!&lt;/code&gt; which I think will do the trick here.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'a,'b!mysql -u root db&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tested it with &lt;code&gt;sed&lt;/code&gt; on file with content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1&#xA;line2&#xA;line3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1Gma&#xA;3Gmb&#xA;:'a,'b!sed -n '/1/p'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-11-14T10:44:45.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10282" PostTypeId="2" ParentId="10242" CreationDate="2016-11-14T14:44:12.940" Score="8" Body="&lt;p&gt;From your question it appears that you have installed vim-tiny 8.0 that is a very minimal Vim runtime without plugins. You can confirm this using this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dpkg -l | grep vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can have several Vim runtimes, but the version running when you do &lt;code&gt;vim&lt;/code&gt; will be the version that you can see indicated here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;update-alternatives --list vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can check other versions. My suggestion is that you decide between full versions with support for GUI, and you can choose between &lt;code&gt;vim-gtk2/vim-gtk3&lt;/code&gt; packages or &lt;code&gt;vim-nox&lt;/code&gt; that is a full version, but without a GUI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, IIRC, the Vim full version in Debian/Ubuntu doesn't come with Python&amp;nbsp;2 AND Python&amp;nbsp;3 at the same time in 7.x versions. I don't know how the case is with Vim&amp;nbsp;8, because I use &lt;code&gt;neovim&lt;/code&gt; now. If this is the case for you and you are going to need BOTH Python engines supported by Vim&amp;nbsp;8 (this will not be your case for use &lt;code&gt;YouCompleteMe&lt;/code&gt;; this one works with Python 2 support only) then you will need to compile from sources your own Vim 8.0.&lt;/p&gt;&#xA;" OwnerUserId="8843" LastEditorUserId="927" LastEditDate="2017-07-22T13:47:32.690" LastActivityDate="2017-07-22T13:47:32.690" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10284" PostTypeId="2" ParentId="10249" CreationDate="2016-11-14T16:21:03.127" Score="32" Body="&lt;p&gt;In short:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;keycodes is a way to represent a key&lt;/li&gt;&#xA;&lt;li&gt;A mapped key sequence is a succession of keycodes triggering an action&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Now I think that your question is more about the difference between &lt;code&gt;timeoutlen&lt;/code&gt; and &lt;code&gt;ttimeoutlen&lt;/code&gt; instead of the difference between a mapped key sequence and a key code.&lt;/p&gt;&#xA;&lt;p&gt;My answer is based on &lt;a href=&quot;http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;this wikia article&lt;/a&gt; that you really should read because it addresses some points that I didn't mention here to keep the answer as short and clear as possible.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;First let's talk about key codes. The article defines two types of keycodes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Terminal keycodes:&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;They are how the terminal represents a key.&lt;/p&gt;&#xA;&lt;p&gt;These codes that are sent by the terminal to Vim.&lt;/p&gt;&#xA;&lt;p&gt;To get a list of these keycodes you should use your terminal documentation. You can also see them by typing the command &lt;code&gt;cat&lt;/code&gt; in your terminal and typing the key you want to know the keycode of. For example on my terminal the key code for &lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;F1&lt;/kbd&gt; looks like:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;^[[23~&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Vim keycodes:&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;They are how vim represents a key.&lt;/p&gt;&#xA;&lt;p&gt;Vim needs a consistent way to represent the keys because terminal's keycodes change from a terminal to another. A list of Vim keycodes is accessible at &lt;a href=&quot;http://vimhelp.appspot.com/term.txt.html#t_ku&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h t_ku&lt;/code&gt;&lt;/a&gt;. The Vim keycode for &lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;F1&lt;/kbd&gt; looks like:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;S-F1&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Thus when I press &lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;F1&lt;/kbd&gt; on my keyboard, the drivers and OS will let the terminal know that I pressed these keys that it will interpret as &lt;code&gt;^[[23~&lt;/code&gt;. The terminal will send that to Vim which will understand that it means &lt;code&gt;&amp;lt;S-F1&amp;gt;&lt;/code&gt; and will trigger the action mapped to this key code.&lt;/p&gt;&#xA;&lt;p&gt;We can set Vim keycodes, so if your terminal sends a keycode that Vim doesn't understand like &lt;code&gt;&amp;lt;S-F1&amp;gt;&lt;/code&gt; for example you could use the following command. This will tell Vim when you receive the keycode &lt;code&gt;^[[24~&lt;/code&gt;, translate it as &lt;code&gt;&amp;lt;S-F1&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;S-F1&amp;gt;=^[[24~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;So what is a mapped key sequence?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;A mapped key sequence will be a lhs of a mapping and can be Vim key codes or Terminal key codes. For example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:nmap ^[[24~ :bn&amp;lt;CR&amp;gt;&#xA;:nmap &amp;lt;S-F1&amp;gt; :bn&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The first mapping will map the terminal keycode while the second maps the Vim keycode.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Now for the difference between &lt;code&gt;timeoutlen&lt;/code&gt; and &lt;code&gt;ttimeoutlen&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ttimeoutlen&lt;/code&gt; is the time Vim will wait for the different parts of a terminal key code (in our previous example that would be &lt;code&gt;^[&lt;/code&gt; then &lt;code&gt;[&lt;/code&gt; then &lt;code&gt;2&lt;/code&gt;, etc...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As these keycodes are sent by the terminal there should not be a delay between these inputs (since they are sent 'all at once' by the terminal). This is why the doc recommends a really small value for this setting.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;timeoutlen&lt;/code&gt; is the time Vim will wait for the successive Vim keycodes which are entered manually by a user and thus is longer to input than a terminal keycode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To use an example let's say that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You mapped &lt;code&gt;^[[1;6B&lt;/code&gt; to an action&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^[1;6B&lt;/code&gt; is your terminal's keycode for &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;shift&lt;/kbd&gt;&lt;kbd&gt;down&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^[&lt;/code&gt; is your terminal's keycode for &lt;kbd&gt;Escape&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The behavior that you should expect:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you set a large &lt;code&gt;ttimeoutlen&lt;/code&gt;, each time you type on &lt;kbd&gt;Escape&lt;/kbd&gt;, Vim will wait to see if you meant &lt;code&gt;^[&lt;/code&gt; (i.e. &lt;kbd&gt;Escape&lt;/kbd&gt;) or &lt;code&gt;^[1;6B&lt;/code&gt; (i.e. &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;shift&lt;/kbd&gt;&lt;kbd&gt;down&lt;/kbd&gt;)&lt;/li&gt;&#xA;&lt;li&gt;If you set a small &lt;code&gt;ttimeoutlen&lt;/code&gt;, you will not have a delay when you type &lt;kbd&gt;Escape&lt;/kbd&gt; because Vim will know that it is a complete keycode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;And &lt;code&gt;timeoutlen&lt;/code&gt; will act on a 'higher level', if you have the following mappings:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap jj &amp;lt;Esc&amp;gt;&#xA;inoremap jk &amp;lt;Esc&amp;gt;:nohl&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When you type &lt;kbd&gt;j&lt;/kbd&gt; vim will wait &lt;code&gt;timeoutlen&lt;/code&gt; not because the beginning of the terminal keycode for &lt;kbd&gt;j&lt;/kbd&gt; is not complete but because it is waiting for the next Vim keycode.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I hope my explanation makes sense, note that some of the mappings I used don't make sense in a functional point of view but are here for the convenience the explanation.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2023-04-21T10:50:49.367" LastActivityDate="2023-04-21T10:50:49.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10285" PostTypeId="1" AcceptedAnswerId="10286" CreationDate="2016-11-14T19:03:11.537" Score="3" ViewCount="381" Body="&lt;p&gt;I have a Python project where there are lots of functions with the same name in different files. Some symbols are reasonably unique and &lt;code&gt;C-]&lt;/code&gt; will jump to the right definition. However, others are very common. Right now I look at the word and if it's something generic like &lt;code&gt;upload&lt;/code&gt; I hit &lt;code&gt;g]&lt;/code&gt; to be prompted for a list of possible definition sites. Is there a way to get the number of possible ctag matches for the word currently under the cursor so I can make &lt;code&gt;C-]&lt;/code&gt; do &lt;code&gt;g]&lt;/code&gt; when the symbol is ambiguous?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2016-11-14T20:42:08.940" Title="Ctags force prompt on ambiguous tag" Tags="|ctags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10286" PostTypeId="2" ParentId="10285" CreationDate="2016-11-14T20:42:08.940" Score="5" Body="&lt;p&gt;&lt;code&gt;g&amp;lt;C-]&amp;gt;&lt;/code&gt; will display a list of tags only when there is more than one, so you could just train yourself to type &lt;code&gt;g&amp;lt;C-]&amp;gt;&lt;/code&gt; instead of &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;. But having to type two characters instead of one, especially when one takes a modifier, is a pain, so what I would do is put this mapping in your ~/.vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-]&amp;gt; g&amp;lt;C-]&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2016-11-14T20:42:08.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10287" PostTypeId="1" AcceptedAnswerId="10291" CreationDate="2016-11-14T23:41:57.167" Score="4" ViewCount="1160" Body="&lt;p&gt;I'd like to test the range pattern, same as Vim highlights the text while searching (e.g. &lt;code&gt;:/&lt;/code&gt;), but for the range command instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in other words, instead of executing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/&amp;lt;head/,/\/head&amp;gt;/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to test only &lt;code&gt;/&amp;lt;head/,/\/head&amp;gt;/&lt;/code&gt; range pattern in form of highlight to check whether the pattern is correct, before I'm going to run any command on that range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample text to play with can be retrieved by: &lt;code&gt;vim http://www.example.com/&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2016-11-15T13:37:39.077" Title="How to highlight a search range?" Tags="|search|highlight|range|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10288" PostTypeId="2" ParentId="10287" CreationDate="2016-11-14T23:41:57.167" Score="1" Body="&lt;p&gt;Currently I only know the following way by using multi-line match (&lt;code&gt;\_.\{-}&lt;/code&gt;), e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&amp;lt;head\_.\{-}\/head&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So basically the syntax is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/pattern1\_.\{-}pattern2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The disadvantage of above method is that the range needs to be rewritten into search pattern, especially it's a trouble for more complex range patterns, as you've to change the syntax.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2016-11-15T13:37:39.077" LastActivityDate="2016-11-15T13:37:39.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10289" PostTypeId="1" AcceptedAnswerId="10290" CreationDate="2016-11-15T00:00:16.293" Score="4" ViewCount="1123" Body="&lt;p&gt;I've got the following sample HTML code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&#xA;&amp;lt;table class=&quot;foo&quot;&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;/table&amp;gt;&#xA;&amp;lt;table class=&quot;bar&quot;&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;3&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;/table&amp;gt;&#xA;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'd like to sort the second table in reverse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However whenever I run this command at the beginning of the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/&amp;lt;table class=.bar\_.\{-}\zs&amp;lt;tr/,/table&amp;gt;/sort! n /.\{-}&amp;lt;td/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've got the user interactive warning saying:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Backwards range given, OK to swap (y/n)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I select &lt;code&gt;n&lt;/code&gt; - nothing happens, when I select &lt;code&gt;y&lt;/code&gt;, then the results are not what I would expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although it works as expected, when I run command by having cursor after the 1st table.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How I can perform the above sorting operation non-interactively without being worried where my cursor is?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2016-11-15T00:57:51.310" LastActivityDate="2016-11-15T06:42:20.273" Title="How to avoid 'Backwards range given' warning when invoking search range?" Tags="|search|range|sort|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10290" PostTypeId="2" ParentId="10289" CreationDate="2016-11-15T06:30:53.660" Score="8" Body="&lt;p&gt;In &lt;code&gt;:&amp;lt;from&amp;gt;,&amp;lt;to&amp;gt;command&lt;/code&gt;, both &lt;code&gt;&amp;lt;from&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;to&amp;gt;&lt;/code&gt; are relative to the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you want is to make &lt;code&gt;&amp;lt;to&amp;gt;&lt;/code&gt; relative to &lt;code&gt;&amp;lt;from&amp;gt;&lt;/code&gt;. For this you need &lt;code&gt;:help :;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/foo/;,/bar/command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the cursor is moved to &lt;code&gt;/foo/&lt;/code&gt; first, which becomes the current line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/&amp;lt;table class=.bar\_.\{-}\zs&amp;lt;tr/;,/table&amp;gt;/sort! n /.\{-}&amp;lt;td/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-11-15T06:42:20.273" LastActivityDate="2016-11-15T06:42:20.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10291" PostTypeId="2" ParentId="10287" CreationDate="2016-11-15T10:44:07.140" Score="7" Body="&lt;h3&gt;A&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you just want to quickly confirm the validity of the range (and it isn't too long), you can use the built-in &lt;code&gt;:print&lt;/code&gt; or &lt;code&gt;:number&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/&amp;lt;head/,/\/head&amp;gt;/print&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;B&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Another idea would be (mis-)using the visual selection. The following custom command creates a linewise selection of the passed range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;:[range]SelectRange    Create a linewise visual selection of [range].&#xA;command! -bar -range SelectRange execute &quot;normal! m'&quot; | call cursor(&amp;lt;line1&amp;gt;, 1) | execute 'normal! V' | call cursor(&amp;lt;line2&amp;gt;, 1)&#xA;&#xA;:/&amp;lt;head/,/\/head&amp;gt;/SelectRange&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;C&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you really want some (semi-permanent) highlighting, you can use &lt;code&gt;:match&lt;/code&gt; with one of the following custom commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi link Match Search&#xA;&#xA;&quot;:[range]MatchLines [{group}]&#xA;&quot;           Highlight the lines in [range] with the &quot;Match&quot; group /&#xA;&quot;           {group}. This only considers the line numbers, not their&#xA;&quot;           contents.&#xA;command! -bar -range -nargs=? MatchLines execute 'match' (empty(&amp;lt;q-args&amp;gt;) ? 'Match' : &amp;lt;q-args&amp;gt;) printf('/\%%&amp;gt;%dl\%%&amp;lt;%dl/', (&amp;lt;line1&amp;gt; - 1), (&amp;lt;line2&amp;gt; + 1))&#xA;&#xA;&quot;:[range]MatchRange [{group}]&#xA;&quot;           Highlight the content of the lines in [range] with the&#xA;&quot;           &quot;Match&quot; group / {group}. This considers the current&#xA;&quot;           content of the lines (also elsewhere in the buffer).&#xA;command! -bar -range -nargs=? MatchRange execute 'match' (empty(&amp;lt;q-args&amp;gt;) ? 'Match' : &amp;lt;q-args&amp;gt;) '/\V\^' . join(map(getline(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;), 'escape(v:val, &quot;\\/&quot;)'), '\n') . '\$/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Clear with &lt;code&gt;:match&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2016-11-15T12:38:16.627" LastActivityDate="2016-11-15T12:38:16.627" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10292" PostTypeId="1" CreationDate="2016-11-15T11:05:00.363" Score="10" ViewCount="5189" Body="&lt;p&gt;I'm trying to modify test runner plugin to do the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;When running test show a window with them (that part is already covered by the plugin)&lt;/li&gt;&#xA;&lt;li&gt;After all tests are done if there is no errors hide window.&lt;/li&gt;&#xA;&lt;li&gt;If there were errors leave the window open.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I've written a shell script that exits if the exit code of the test runner is 0. But neovim still shows the buffer and waits for me to press any key to close it. How can I tell neovim to close buffer if the the shell session within it have ended?&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="51" LastEditDate="2016-11-17T05:29:31.477" LastActivityDate="2022-05-03T13:56:44.183" Title="How to close and and delete terminal buffer if programs exited?" Tags="|neovim|terminal-buffer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10294" PostTypeId="1" AcceptedAnswerId="10295" CreationDate="2016-11-15T13:15:30.640" Score="5" ViewCount="546" Body="&lt;p&gt;I am wondering if it possible to short circuit the check for the existence of a key in a dict and an immediatly following assignment to a variable with that key if it exists.&#xA;That is, if the following code can be abbreviated to something like &lt;code&gt;let s:val = s:tq84_dict['foo'] || 'default'&lt;/code&gt; (which won't work in vim script)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has_key(s:tq84_dict, 'foo')&#xA;  let s:val = s:tq84_dict['foo']&#xA;else&#xA;  let s:val = 'default'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="985" LastActivityDate="2016-11-15T13:25:56.417" Title="Can a check with has_key(d, k) and an immediate assignment be short circuited in vim script?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10295" PostTypeId="2" ParentId="10294" CreationDate="2016-11-15T13:25:56.417" Score="9" Body="&lt;p&gt;Use the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#get%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;get()&lt;/code&gt;&lt;/a&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo get({}, 'foo', 'default')&#xA;default&#xA;&#xA;:echo get({'foo': 'it is set'}, 'foo', 'default')&#xA;it is set&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're familiar with Python, this is the same as &lt;code&gt;{}.get('foo', 'default')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way would be to use the ternary if: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let dict = {}&#xA;:let val = has_key({}, 'foo') ? dict['foo'] : 'default'&#xA;:echo val&#xA;default&#xA;&#xA;:let dict = {'foo': 'it is set'}&#xA;:let val = has_key(dict, 'foo') ? dict['foo'] : 'default'&#xA;:echo val&#xA;it is set&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in this case &lt;code&gt;get()&lt;/code&gt; is clearly the better way to do it.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-11-15T13:25:56.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10296" PostTypeId="1" AcceptedAnswerId="10297" CreationDate="2016-11-15T18:15:45.777" Score="58" ViewCount="50896" Body="&lt;p&gt;I finally decided to ditch the arrow keys for navigation in favor of &lt;code&gt;hjkl&lt;/code&gt;.&#xA;I used the &lt;code&gt;Vim hardmode&lt;/code&gt; plugin to disable the arrow keys.&lt;/p&gt;&#xA;&lt;p&gt;I got used to navigation pretty fast, but it turns out that navigation in insert mode suddenly is impossible.&lt;/p&gt;&#xA;&lt;p&gt;Is there any solution for this? (exiting insert mode is not a solution).&lt;/p&gt;&#xA;&#xA;" OwnerUserId="496" LastEditorUserId="1238" LastEditDate="2020-08-10T21:09:29.100" LastActivityDate="2024-03-19T19:17:58.380" Title="Navigation in insert mode" Tags="|insert-mode|navigation|" AnswerCount="6" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10297" PostTypeId="2" ParentId="10296" CreationDate="2016-11-15T18:53:07.233" Score="58" Body="&lt;p&gt;There are many options you have. One option, and IMO the sanest and easiest is to just stop disabling the arrow keys. I understand why many hardcore vimmers say things like&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;You should never ever use the arrow keys again! Every time you use the arrow keys, you waste 3 minutes of time, a puppy dies and somebody switches to Emacs!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;(Obviously I'm kidding) However, there is a purpose for the arrow keys. They're extremely useful for navigating:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;In insert mode&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In the command line&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Generally when people tell you not to use the arrow keys, it's because they want you to relearn navigation in a more vim-like way. If you are comfortable with &lt;code&gt;hjkl&lt;/code&gt;, and you mostly use the arrow keys in insert mode, there's no good reason to force yourself not to use them.&lt;/p&gt;&#xA;&lt;p&gt;Option #2 is to remap &lt;code&gt;ctrl-hjkl&lt;/code&gt; to act like cursor keys. This is nice because you can stay on the homerow, and it fits well with the muscle memory you have already learned using &lt;code&gt;hjkl&lt;/code&gt; in normal mode. In fact, &lt;a href=&quot;https://github.com/DJMcMayhem/dotFiles/blob/2f91270f2e88ddd9a916c8d81702dcb2e043f5c7/.vimrc#L283&quot; rel=&quot;noreferrer&quot;&gt;this is what I do&lt;/a&gt;. The major downside to this approach is that in can be a pain to setup in terminal vim because &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; produces a &lt;code&gt;NUL&lt;/code&gt; byte. I get around this by using Gvim. I am not aware if there is an easy fix for console vim or not.&lt;/p&gt;&#xA;&lt;p&gt;Option #3 is to use &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; to make small normal mode movements. For example, if you are typing&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Hello world!&#xA;     cursor^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and you realize you forgot a comma, rather than doing &lt;kbd&gt;left&lt;/kbd&gt;&lt;kbd&gt;left&lt;/kbd&gt;&lt;kbd&gt;left&lt;/kbd&gt;&lt;kbd&gt;left&lt;/kbd&gt;&lt;kbd&gt;left&lt;/kbd&gt;&lt;kbd&gt;left&lt;/kbd&gt;, you could simply do &lt;code&gt;&amp;lt;C-o&amp;gt;b&amp;lt;C-o&amp;gt;h&lt;/code&gt; or &lt;code&gt;&amp;lt;C-o&amp;gt;2Fo&lt;/code&gt;, or any other combination of normal mode movements you like.&lt;/p&gt;&#xA;&lt;p&gt;Of course, another option, and one I like very much is to just use &lt;kbd&gt;Esc&lt;/kbd&gt;, make a few small movements before jumping back in to insert mode. You mentioned that you'd rather not do that, but sometimes this really is the most efficient way.&lt;/p&gt;&#xA;&lt;p&gt;There are probably some other approaches too, but these are the ones I like that have worked for me.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="29264" LastEditDate="2020-11-10T14:37:14.077" LastActivityDate="2020-11-10T14:37:14.077" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="10298" PostTypeId="2" ParentId="10296" CreationDate="2016-11-16T00:36:58.733" Score="24" Body="&lt;p&gt;I like to use the Control key to turn the &lt;code&gt;hjkl&lt;/code&gt; movement keys into &quot;universal&quot; movement keys. Here's the relevant bit of my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; In insert or command mode, move normally by using Ctrl&#xA;inoremap &amp;lt;C-h&amp;gt; &amp;lt;Left&amp;gt;&#xA;inoremap &amp;lt;C-j&amp;gt; &amp;lt;Down&amp;gt;&#xA;inoremap &amp;lt;C-k&amp;gt; &amp;lt;Up&amp;gt;&#xA;inoremap &amp;lt;C-l&amp;gt; &amp;lt;Right&amp;gt;&#xA;cnoremap &amp;lt;C-h&amp;gt; &amp;lt;Left&amp;gt;&#xA;cnoremap &amp;lt;C-j&amp;gt; &amp;lt;Down&amp;gt;&#xA;cnoremap &amp;lt;C-k&amp;gt; &amp;lt;Up&amp;gt;&#xA;cnoremap &amp;lt;C-l&amp;gt; &amp;lt;Right&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;inoremap&lt;/code&gt; statements apply to insert mode, while the &lt;code&gt;cnoremap&lt;/code&gt; ones apply to command mode. (I've been using this mapping for so long that I have forgotten whether there's any way to navigate command-mode history without it.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Edit: I see the other answer has already mentioned this possibility. Still, it may be helpful to see the actual mapping commands.)&lt;/p&gt;&#xA;" OwnerUserId="1060" LastActivityDate="2016-11-16T00:36:58.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10299" PostTypeId="2" ParentId="3386" CreationDate="2016-11-16T12:25:20.157" Score="2" Body="&lt;p&gt;If it's a &lt;em&gt;file&lt;/em&gt; buffer (won't work for &lt;em&gt;scratch&lt;/em&gt; buffers etc.), you can:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;:let @f=@%&lt;/code&gt;&lt;kbd&gt;ENTER&lt;/kbd&gt;&lt;/strong&gt; &amp;mdash; in the source window;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This replaces contents of regular register &lt;em&gt;f&lt;/em&gt; with contents of special register &lt;em&gt;%&lt;/em&gt;, which contains current file name.&lt;/li&gt;&#xA;&lt;li&gt;Note: I chose register &lt;em&gt;f&lt;/em&gt; as in &lt;em&gt;file&lt;/em&gt;, but you can use any other register you like.&lt;/li&gt;&#xA;&lt;li&gt;You can verify that the register contains correct path with: &lt;code&gt;:echo @f&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Optionally: &lt;kbd&gt;Ctrl-W&lt;/kbd&gt;&lt;kbd&gt;Ctrl-Q&lt;/kbd&gt; &amp;mdash; to close the old window;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt; / &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;T&lt;/kbd&gt; &amp;mdash; navigate to the target tab (and window);&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-W&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt; &amp;mdash; split the tab any way you like, to open a new window;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;:e␣&lt;/code&gt;&lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;ENTER&lt;/kbd&gt;&lt;/strong&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;in the newly opened window, loads a file from the path stored in register &lt;em&gt;f&lt;/em&gt;;&lt;/li&gt;&#xA;&lt;li&gt;Note: the ␣ character here marks a regular space.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important note:&lt;/strong&gt; the final step &lt;strong&gt;won't work correctly&lt;/strong&gt; if the &lt;strong&gt;path contains spaces&lt;/strong&gt; or some special characters! :-( As a workaround, the following, slightly longer command should work for paths with spaces (though it may still fail for some other special characters):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;:e␣&quot;&lt;/code&gt;&lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;code&gt;&quot;&lt;/code&gt;&lt;kbd&gt;ENTER&lt;/kbd&gt;&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(that is, quoting the result of &lt;em&gt;Ctrl-R, f&lt;/em&gt; )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&lt;em&gt;Inspired by answers from &lt;a href=&quot;https://vi.stackexchange.com/a/3475/1500&quot;&gt;lkraav&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/a/3394/1500&quot;&gt;ingo-karkat&lt;/a&gt;&lt;/em&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="1500" LastEditorUserId="1500" LastEditDate="2018-05-25T09:56:06.187" LastActivityDate="2018-05-25T09:56:06.187" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10300" PostTypeId="2" ParentId="9061" CreationDate="2016-11-16T13:05:44.407" Score="5" Body="&lt;p&gt;I did a little research and it seems that the only option right now is the one mentioned by @grodzik: you need to configure &lt;code&gt;gpg-agent&lt;/code&gt;. &lt;a href=&quot;https://github.com/jamessan/vim-gnupg/issues/32#issuecomment-155081600&quot; rel=&quot;noreferrer&quot;&gt;Quoting Thiago de Arruda&lt;/a&gt; (Neovim lead developer):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm a long time vim-gnupg user and have been using it with neovim since day 1. I never had problems because I use gpg-agent which by defaults displays a x11 prompt to get the password (the GPG_TTY warning can be safely ignored).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In the same thread the vim-pgp author has shared his progress on making the plug-in compatible with Neovim. I think it will take a while but lately he has been contributing to Neovim (in fact &lt;a href=&quot;https://github.com/neovim/neovim/commit/108d54bbd455635fc29541eb4bae4b9f3318aafb&quot; rel=&quot;noreferrer&quot;&gt;the last Neovim commit is authored by him&lt;/a&gt;) so it's just matter of time.&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2016-11-16T13:05:44.407" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10301" PostTypeId="1" CreationDate="2016-11-16T13:19:18.893" Score="6" ViewCount="1681" Body="&lt;p&gt;Vim's documentation lists &lt;code&gt;t_vi&lt;/code&gt; as &quot;cursor invisible&quot; and &lt;code&gt;t_ve&lt;/code&gt; as &quot;cursor visible&quot;, but provides no hints on usage. Naively, I would have guessed that Vim would send the &lt;code&gt;t_vi&lt;/code&gt; sequence when you somehow indicated cursor should be hidden (e.g., using something analogous to &lt;code&gt;guicursor&lt;/code&gt;, or even the &lt;code&gt;'Cursor'&lt;/code&gt; syntax group), but the only way I've been able to hide the cursor in a terminal is to make the &quot;cursor visible&quot; option empty: e.g.,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set t_ve=&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, telling Vim there's no way to make the cursor visible causes Vim immediately to use the t_vi option value to make it &lt;strong&gt;&lt;em&gt;invisible&lt;/em&gt;&lt;/strong&gt;. The seems a little odd and unintuitive to me. I couldn't find any information in Vim's docs on this. Is it well-defined behavior? Can anyone give a better explanation of what's happening here?&lt;/p&gt;&#xA;" OwnerUserId="2281" LastEditorUserId="21062" LastEditDate="2019-08-08T15:38:25.160" LastActivityDate="2023-08-16T21:46:41.707" Title="Why does `set t_ve=' hide cursor in terminal" Tags="|terminal|cursor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10302" PostTypeId="2" ParentId="9240" CreationDate="2016-11-16T17:53:57.657" Score="0" Body="&lt;p&gt;If you are editing your .vimrc file and want to load/ attempt to load it you can just run &lt;code&gt;:so %&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a link to another &lt;a href=&quot;https://superuser.com/a/132030/237154&quot;&gt;answer&lt;/a&gt; that explains this further.&lt;/p&gt;&#xA;" OwnerUserId="7254" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2016-11-16T17:53:57.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10303" PostTypeId="2" ParentId="9240" CreationDate="2016-11-16T18:14:26.053" Score="1" Body="&lt;p&gt;That command from the plugin is not available, until sourcing the vimrc is actually done. So either explicitly set the theme using &lt;code&gt;let g:airline_theme = 'luna'&lt;/code&gt; which is the documented way to set your airline theme, or wrap your command into an VimEnter autocommand.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-11-16T18:14:26.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10304" PostTypeId="1" AcceptedAnswerId="10306" CreationDate="2016-11-16T20:35:29.227" Score="0" ViewCount="200" Body="&lt;p&gt;I use Vim to edit Ruby code, and the one issue that I keep having trouble with is the comment indenting. It seems that Vim really wants all &lt;code&gt;#&lt;/code&gt; comment marks that begin a line to indent all the way to the left. If I type a &lt;code&gt;#&lt;/code&gt; at the beginning of a line, no matter what my indent currently is, it always drops the whole line to zero indent, no matter whether there is already code on the line or not. None of the normal indent commands work from here either. The only way to move the line is to manually insert spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like it to do is to just leave the indent where it is when I add a comment mark to a line. I've spent what seems like forever messing with various comment settings and checking the &lt;code&gt;indent/ruby.vim&lt;/code&gt; file, and I still can't find anything that has any effect on this behavior. Can anybody point me at something that works?&lt;/p&gt;&#xA;" OwnerUserId="10149" LastActivityDate="2016-11-17T00:53:29.933" Title="Control indenting of Ruby Comments" Tags="|indentation|comments|filetype-ruby|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10305" PostTypeId="2" ParentId="10296" CreationDate="2016-11-16T21:15:37.320" Score="7" Body="&lt;p&gt;Hit &lt;kbd&gt;esc&lt;/kbd&gt; then use &lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt; and &lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;W&lt;/kbd&gt;&lt;kbd&gt;b&lt;/kbd&gt;&lt;kbd&gt;B&lt;/kbd&gt; and any other navigations you would like to make. The whole point of hard mode is to get you to learn to navigate with more complex vim motions. Make small edits then move to a new location, using normal mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wan't to learn how to navigate faster with hardmode enabled, check out my &lt;a href=&quot;https://vi.stackexchange.com/a/7382/7254&quot;&gt;answer&lt;/a&gt; from another question on the same topic.&lt;/p&gt;&#xA;" OwnerUserId="7254" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-11-16T21:15:37.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10306" PostTypeId="2" ParentId="10304" CreationDate="2016-11-17T00:37:01.487" Score="2" Body="&lt;p&gt;Thanks to the comment's help, I was able to muck around with my .vimrc some more and isolate the issue to the commented-out line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;filetype indent on&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure how I missed that before, but it works now, so thanks!&lt;/p&gt;&#xA;" OwnerUserId="10149" LastEditorUserId="51" LastEditDate="2016-11-17T00:53:29.933" LastActivityDate="2016-11-17T00:53:29.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10307" PostTypeId="2" ParentId="613" CreationDate="2016-11-17T00:52:37.420" Score="2" Body="&lt;p&gt;Most likely, your plugin will be a single .vim file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is the case, I searched the help and experimented and figured out the following. From within vim (command mode), type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set runtimepath&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will show you a series of directories.&#xA;Some of these directories will have a &lt;code&gt;plugin&lt;/code&gt; subdirectory.  Putting any .vim file in one of these &lt;code&gt;plugin&lt;/code&gt; subdirectories will get it automatically loaded when you start vim from anywhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For me, on Ubuntu linux, I found that &lt;code&gt;/usr/share/vim/vim74/plugin&lt;/code&gt; worked well, to install for all users. You may need root permission to copy a file to here (prefix your &lt;code&gt;cp&lt;/code&gt; or &lt;code&gt;mv&lt;/code&gt; command with &lt;code&gt;sudo&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="10155" LastEditorUserId="5395" LastEditDate="2016-11-17T09:41:49.760" LastActivityDate="2016-11-17T09:41:49.760" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10308" PostTypeId="1" AcceptedAnswerId="10309" CreationDate="2016-11-17T01:27:43.843" Score="2" ViewCount="287" Body="&lt;p&gt;Running vim with the following settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expandtab&#xA;tabstop=4&#xA;softtabstop=4&#xA;shiftwidth=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And no other user plugins.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In insert mode...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I enter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&amp;lt;Tab&amp;gt;b&amp;lt;Tab&amp;gt;c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;all tabs are replaced by 4 spaces as expected.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT, if I enter: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&amp;lt;space&amp;gt;b&amp;lt;Tab&amp;gt;c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; is only replaced by a single space.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's causing this seeming 'context-based' replacement of &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;?   How can I debug this sort of thing (I tried &lt;code&gt;vim -V15 vim.log&lt;/code&gt;, but nothing obvious showed up in the log)?  &lt;/p&gt;&#xA;" OwnerUserId="10156" LastEditorUserId="51" LastEditDate="2016-11-17T02:01:11.127" LastActivityDate="2016-11-17T02:27:30.907" Title="expandtab not replacing tabs after space separated characters" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10309" PostTypeId="2" ParentId="10308" CreationDate="2016-11-17T02:19:56.393" Score="9" Body="&lt;p&gt;This is how tabs work. Pressing the Tab doesn't mean &quot;insert &lt;em&gt;n&lt;/em&gt; spaces&quot;, but rather &quot;go to the next tabstop&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every line is divided in &quot;cells&quot; of &lt;em&gt;n&lt;/em&gt; spaces, for example four:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----&amp;gt;---&amp;gt;---&amp;gt;---&amp;gt;---&amp;gt;---&amp;gt;---&amp;gt;---&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing the Tab key will make it go to the start of the next cell (indicated by the &lt;code&gt;&amp;gt;&lt;/code&gt;). In your example there is just one space left to the next tabstop, so only one space is inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason it works like this is because the tab key is intended to align data. Consider text like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Quote               | Author          |&#xA;--------------------+-----------------|&#xA;Hello, world        | Brian Kernighan |&#xA;It's an Aardvark!   | Black Adder     |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see the two columns are neatly aligned. &lt;em&gt;One&lt;/em&gt; way to achieve this is to repeatedly mash the space key until it lines up, but just pressing the tab key once or twice to align it is much easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You've chosen to expand tabs with spaces, but that won't change the actual behaviour of how the tab key works; it will still work the same, but instead of inserting a tab character (0x09) it will insert the correct number of spaces. As far as I know, it works like this in all editors and IDEs (at least those that I've used).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want Vim to always just insert four spaces you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;Tab&amp;gt; &amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-11-17T02:27:30.907" LastActivityDate="2016-11-17T02:27:30.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10310" PostTypeId="2" ParentId="2776" CreationDate="2016-11-17T02:52:33.440" Score="97" Body="&lt;p&gt;Let's say we have a simple project structure like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Y6YLy.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Y6YLy.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;greeting.txt&lt;/code&gt; looks like&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ECh3r.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ECh3r.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;and &lt;code&gt;info/age.txt&lt;/code&gt; looks like&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UudPD.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UudPD.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let's say we want to replace all occurrences of &lt;code&gt;Sam&lt;/code&gt; with &lt;code&gt;Bob&lt;/code&gt;. Here's what we would do:&lt;/p&gt;&#xA;&lt;h1&gt;1. &lt;strong&gt;Set working directory&lt;/strong&gt;&lt;/h1&gt;&#xA;&lt;p&gt;Make sure Vim's current working directory is the root of the project:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;     :cd {path to root directory}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can use &lt;code&gt;:pwd&lt;/code&gt; to print the current working directory and ensure that it is&#xA;correct.&lt;/p&gt;&#xA;&lt;h1&gt;2. &lt;strong&gt;Find files that contain 'Sam'&lt;/strong&gt;&lt;/h1&gt;&#xA;&lt;p&gt;Use Vim's &lt;code&gt;:vimgrep&lt;/code&gt; command to search for all occurrences of &lt;code&gt;Sam&lt;/code&gt; within the project:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    :vimgrep /Sam/gj **/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Notes:&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Sam&lt;/code&gt; is the search &amp;quot;pattern&amp;quot; sandwiched between two forward slashes&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;**/*&lt;/code&gt; says to search in all files recursively&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;g&lt;/code&gt; flag says to search for all occurrences in each line (this is actually overkill here, but it does not hurt either)&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;j&lt;/code&gt; flag prevents vim from automatically jumping to the first match&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This will populate the quickfix list with all instances of &lt;code&gt;Sam&lt;/code&gt;.  If you want to view  the quickfix list, you can use the Vim command &lt;code&gt;:copen&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4t4JT.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4t4JT.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h1&gt;3. &lt;strong&gt;Substitute within all files that contain 'Sam'&lt;/strong&gt;&lt;/h1&gt;&#xA;&lt;p&gt;Now we want to run Vim's &lt;code&gt;:substitute&lt;/code&gt; command inside every file in the quickfix list. We can do this using the &lt;code&gt;:cfdo {cmd}&lt;/code&gt; command which executes &lt;code&gt;{cmd}&lt;/code&gt; in each file in the quickfix list. The specific &lt;code&gt;{cmd}&lt;/code&gt; we want to use is &lt;code&gt;:substitute&lt;/code&gt; or &lt;code&gt;:s&lt;/code&gt; for short. Adding the &lt;code&gt;update&lt;/code&gt; command at the end ensures that each file is saved before moving on to the next one (this is necessary if you don't &lt;code&gt;:set hidden&lt;/code&gt;). The full line would look like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    :cfdo %s/Sam/Bob/gc | update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you do &lt;code&gt;:set hidden&lt;/code&gt;, you can optionally leave off &lt;code&gt;| update&lt;/code&gt;, and then do &lt;code&gt;:cfdo update&lt;/code&gt; or &lt;code&gt;:wall&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Notes:&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;%&lt;/code&gt; is a line range that specifies &lt;em&gt;every&lt;/em&gt; line&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;g&lt;/code&gt; flag says to substitute &lt;em&gt;all&lt;/em&gt; occurrences in each line&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;c&lt;/code&gt; flag causes vim to ask you to confirm each replacement individually&#xA;(you might want to leave this out)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7454" LastEditorUserId="10604" LastEditDate="2021-10-25T21:07:43.273" LastActivityDate="2021-10-25T21:07:43.273" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10311" PostTypeId="2" ParentId="10292" CreationDate="2016-11-17T05:44:29.943" Score="8" Body="&lt;p&gt;From &lt;code&gt;vim/src/eval.c&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;static void eval_job_process_exit_cb(Process *proc, int status, void *d) {&#xA;    [..]&#xA;    if (data-&amp;gt;term &amp;amp;&amp;amp; !data-&amp;gt;exited) {&#xA;      data-&amp;gt;exited = true;&#xA;      char msg[sizeof(&amp;quot;\r\n[Process exited ]&amp;quot;) + NUMBUFLEN];&#xA;      snprintf(msg, sizeof msg, &amp;quot;\r\n[Process exited %d]&amp;quot;, proc-&amp;gt;status);&#xA;      terminal_close(data-&amp;gt;term, msg);&#xA;    }&#xA;    [..]&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There is no setting or something else to disable this message here. It is always displayed. The only other place where &lt;code&gt;terminal_close()&lt;/code&gt; is called is from the &lt;code&gt;close_buffer()&lt;/code&gt; function, which is the &lt;code&gt;:close&lt;/code&gt; command (among others). I'm not sure if you can send the &lt;code&gt;:close&lt;/code&gt; command from a script within the terminal to Neovim; I don't think so.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The first way to fix this is to modify the way you open the terminal:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fun! TermTest(cmd)&#xA;    call termopen(a:cmd, {'on_exit': 's:OnExit', 'win': win_getid()})&#xA;endfun&#xA;&#xA;fun! s:OnExit(job_id, code, event) dict&#xA;    if a:code == 0&#xA;        call nvim_win_close(self.win, 0)&#xA;    endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;code&gt;on_exit&lt;/code&gt; callback gets run before the message is displayed, so we can use that to close this buffer. The parameters seem undocumented (&lt;code&gt;:help jobstart&lt;/code&gt; merely mentions &amp;quot;exit event handler&amp;quot;), but found some information on a &lt;a href=&quot;https://www.reddit.com/r/neovim/comments/46g5wy/how_could_i_get_exit_code_of_process_inside/&quot; rel=&quot;nofollow noreferrer&quot;&gt;random internet page&lt;/a&gt; where a Neovim developer posted it.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If you can't modify the way the terminal gets opened you can still sort-of do the same by (ab)using the &lt;code&gt;TermClose&lt;/code&gt; autocommand:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup terminal&#xA;        autocmd!&#xA;        autocmd TermClose * if getline('$') == 'Exit 0' | close | endif&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This requires you to modify your test script to output the text &lt;code&gt;Exit 0&lt;/code&gt; or &lt;code&gt;Exit 1&lt;/code&gt;. As far as I can find there is no way to get the exit code of the process from the autocommand.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="17510" LastEditDate="2022-05-03T13:56:44.183" LastActivityDate="2022-05-03T13:56:44.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10312" PostTypeId="2" ParentId="10087" CreationDate="2016-11-17T07:03:23.180" Score="1" Body="&lt;p&gt;You can pass it from the shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc $'%s/\031/\027/|x' hello.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will pass the literal &lt;code&gt;^Y&lt;/code&gt; and &lt;code&gt;^[&lt;/code&gt; characters to &lt;code&gt;ex&lt;/code&gt;, which seems to work fine. You can also enter a literal character as &lt;code&gt;^V^Y&lt;/code&gt; (control+v control+y) in most shells.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-11-17T07:03:23.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10314" PostTypeId="2" ParentId="10087" CreationDate="2016-11-17T08:44:13.393" Score="2" Body="&lt;p&gt;Yes you can do this easily. You just have to use an expression in the replacement part (see the help at &lt;code&gt;:h sub-replace-expression&lt;/code&gt; &lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you would do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '%s/ /\=&quot;\x19&quot;/g|x' hello.txt&#xA; od -c hello.txt&#xA; 0000000   h   e   l   l   o 031   w   o   r   l   d  \n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See the help at &lt;code&gt;:h expr-quote&lt;/code&gt; &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#expr-quote&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-11-17T08:44:13.393" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10315" PostTypeId="1" AcceptedAnswerId="10316" CreationDate="2016-11-17T13:02:25.533" Score="2" ViewCount="1325" Body="&lt;p&gt;I'm currently reading &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt;. I did the following experiments as an exercise in the book.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let &amp;amp;wrap=&quot;1.5&quot;&#xA;:let &amp;amp;wrap=&quot;0.5&quot;&#xA;:let &amp;amp;wrap=str2nr(&quot;0.5&quot;,8)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one ran normally, but the second one complains &lt;code&gt;E521: Number required: &amp;amp;wrap = '0.5'&lt;/code&gt;. I thought it was the leading zero that cause the error, perhaps it makes Vim regard it as a octal number. So I tested the third hoping it would produce the same error, but it executed normally. What's the reason of these scenarios?&lt;/p&gt;&#xA;" OwnerUserId="10162" LastActivityDate="2016-11-17T13:32:57.290" Title="Problem converting the string &quot;0.5&quot; to a number" Tags="|vimscript|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10316" PostTypeId="2" ParentId="10315" CreationDate="2016-11-17T13:32:57.290" Score="2" Body="&lt;p&gt;Actually, it is treating it as octal number. From &lt;code&gt;:help E521&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Set string or number option to {value}.&#xA;For numeric options the value can be given in decimal,&#xA;hex (preceded with 0x) or octal (preceded with '0').&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Trying without &lt;code&gt;.&lt;/code&gt; - &lt;code&gt;let &amp;amp;wrap=&quot;05&quot;&lt;/code&gt; - Vim won't complain, so it has a problem with the &lt;code&gt;.&lt;/code&gt; itself. If you try to run &lt;code&gt;:echo str2nr(&quot;.5&quot;,8)&lt;/code&gt; it also won't fail and print &lt;code&gt;0&lt;/code&gt;. Seems like a bug a bit, and lack of consistency.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-11-17T13:32:57.290" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10318" PostTypeId="2" ParentId="10231" CreationDate="2016-11-17T15:11:57.467" Score="1" Body="&lt;p&gt;Motions between the macro blocks should already be covered by the built-in &lt;code&gt;%&lt;/code&gt; motion; it expressly handles &lt;code&gt;#if, #ifdef, #else, #elif, #endif&lt;/code&gt;; cp. &lt;code&gt;:help %&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've extracted the preprocessor-related syntax elements from the built-in C syntax file, and put them into a separate syntax extension script, now published as the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=5484&quot; rel=&quot;nofollow noreferrer&quot;&gt;syn-preproc plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that, it should be sufficient to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setf tcl.preproc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you enjoy highlighting and folding of &lt;code&gt;#ifdef&lt;/code&gt; and so on in addition to the normal Tcl highlighting.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-11-17T15:11:57.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10319" PostTypeId="2" ParentId="8949" CreationDate="2016-11-17T17:20:04.247" Score="2" Body="&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: Really you are after dictionary completion; you don't necessarily need insert mode (Ctrl + X mode) to do this. As you discovered, it makes working with macros a real pain. The below script can be used to do the dictionary completion without insert mode, so that you can easily repeat it inside of a macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the below code to your &lt;code&gt;.vimrc&lt;/code&gt; file, close and reopen any vim windows to source the new function, and then record yourself alternately pressing &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; to do the completion and &lt;code&gt;j&lt;/code&gt; to move down to the next line. I added a check for the &lt;code&gt;longest&lt;/code&gt; option and if it is disabled, it picks a random entry using system random time. If it finds the &lt;code&gt;longest&lt;/code&gt; option, it manually searches for the longest matching entry from the dictionary, and inserts that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't like the &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; mapping, feel free to change it as you see fit. It should work with any mapping you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the command to return the expression for the mapping to evaluate adds an &lt;code&gt;\&amp;lt;esc&amp;gt;&lt;/code&gt; character to the end so that we leave insert mode automatically after each insertion, and an &lt;code&gt;0cw&lt;/code&gt; at the front to enter insert mode to begin with and make sure we overwrite the entire word correctly. Depending on the exact behavior you want (if your words aren't nicely at the front of each line) you could use &lt;code&gt;bcw&lt;/code&gt; instead to find the actual word start. However, then you will see some oddities when going back to words that do begin the line. There's probably a more advanced command to ignore the line ending and do both at once, but I couldn't find one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;expr&amp;gt; &amp;lt;C-k&amp;gt; CompleteDictionary()&#xA;fun! CompleteDictionary()&#xA;    let cword = expand(“&amp;lt;cword&amp;gt;”)&#xA;    let res = []&#xA;    for m in readfile(&amp;amp;dictionary)&#xA;        if m =~ '^' . cword&#xA;            call add(res, m)&#xA;        endif&#xA;    endfor&#xA;    if &amp;amp;completeopt =~ 'longest'&#xA;        let max = 0&#xA;        let maxindex = 0&#xA;        let index = 0&#xA;        for item in res&#xA;            if strlen(item) &amp;gt; max&#xA;                let max = strlen(item)&#xA;                let maxindex = index&#xA;            endif&#xA;            let index = index + 1&#xA;        endfor&#xA;        return &quot;0cw&quot; . res[maxindex] . &quot;\&amp;lt;esc&amp;gt;&quot;&#xA;    else&#xA;        return &quot;0cw&quot; . res[system('@echo %RANDOM%') % len(res)] . &quot;\&amp;lt;esc&amp;gt;&quot;&#xA;    endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In addition, it would not be difficult to extend the logic here to create alternate mappings (using, for example, function parameters) that perform any function the insert mode provides. I'll be happy to assist with any such requirements and update this script as I have time.&lt;/p&gt;&#xA;" OwnerUserId="10168" LastEditorUserId="10168" LastEditDate="2017-11-14T16:53:28.907" LastActivityDate="2017-11-14T16:53:28.907" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10320" PostTypeId="2" ParentId="10014" CreationDate="2016-11-17T17:57:26.847" Score="5" Body="&lt;p&gt;Put this in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-]&amp;gt; :TabExpand 1&amp;lt;CR&amp;gt;&#xA;&#xA;command -nargs=1 TabExpand call HandleTabTagExpand( &amp;lt;f-args&amp;gt; )&#xA;&#xA;let s:commentchar = &quot;&quot;&quot;&#xA;&#xA;function HandleTabTagExpand(tagnumber)&#xA;    let tagident = expand(&quot;&amp;lt;cword&amp;gt;&quot;)&#xA;    redir @a&#xA;    try&#xA;        sil exe &quot;tselect &quot;.tagident&#xA;    catch /^Vim(\a\+):E433:/ &quot; no tag file&#xA;        echom &quot;No tag file found.&quot;&#xA;        return&#xA;    catch /^Vim(\a\+):E426:/ &quot; tag not found&#xA;        echom &quot;Tag not found.&quot;&#xA;        return&#xA;    endtry&#xA;    redir END&#xA;    let tagresults = split(@a, &quot;\n&quot;)&#xA;    let tagmatches = []&#xA;    let linenum = 0&#xA;    for line in tagresults&#xA;        if linenum % 3 != 1&#xA;            &quot; every third line contains the file names&#xA;            let linenum = linenum + 1&#xA;            continue&#xA;        endif&#xA;        &quot; figure out where the filename actually starts&#xA;        &quot; (it's usually column 32, but it might be farther)&#xA;        &quot; one before 32 is 31, but index is 30 since arrays begin at zero&#xA;        let filestart = 30&#xA;        let c = line[filestart]&#xA;        while (filestart &amp;lt; strlen(line))&#xA;            let filestart = filestart + 1&#xA;            if c == &quot; &quot;&#xA;                break&#xA;            endif&#xA;            let c = line[filestart]&#xA;        endwhile&#xA;        &quot; store the parsed match in an array&#xA;        call add(tagmatches, strpart(line, filestart))&#xA;        let linenum = linenum + 1&#xA;    endfor&#xA;    &quot; navigate to the match specified by tagnumber&#xA;    try&#xA;        exe &quot;tab drop &quot;.tagmatches[a:tagnumber-1]&#xA;    catch /^Vim(\a\+):E471:/ &quot; argument required (means no tag found)&#xA;        echom &quot;Tag not found.&quot;&#xA;    endtry&#xA;    let done = 0&#xA;    let matchcount = 0&#xA;    let f_line = &quot;&quot;&#xA;    while done &amp;lt; 1 &amp;amp;&amp;amp; matchcount &amp;lt; 1000&#xA;        sil exe &quot;/&quot;.tagident&#xA;        let f_line = getline(&quot;.&quot;)&#xA;        let matchcount = matchcount + 1&#xA;        if match(f_line, &quot;^\s+&quot;.s:commentchar) &amp;lt; 0&#xA;            let done = 1&#xA;        endif&#xA;    endwhile&#xA;    let f_index = stridx( f_line, tagident )&#xA;    sil exe &quot;normal 0&quot;&#xA;    sil exe &quot;normal &quot;.f_index.&quot;l&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this does is silently execute tselect, redirecting its output to register &lt;code&gt;a&lt;/code&gt;. Tselect does the same thing as tag or tjump but it doesn't actually perform the jump, only the lookup, and returns a list of results. Without using &lt;code&gt;:redir&lt;/code&gt; those results wouldn't be stored anywhere that we can get at them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, it pulls from register &lt;code&gt;a&lt;/code&gt; the tag output returned from tselect and parses it into a line by line array. The output contains other stuff we don't care about. All we need to know is that every second line (mod 3) has a matching file name starting (normally) at column 32, except where the other stuff in front is longer, so we have to account for that by finding the first space beginning at column 31. The character after the first space is where the file will always begin, regardless of what preceeds it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally we parse the file names one by one, and pass one of those filenames to tab drop, which should open a new tab if one isn't already open, or jump over to the already-open tab if there is one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can just type&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:TabExpand n&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(where n is an integer) and it will open existing tab if there is one, or a new tab, for the &lt;em&gt;n&lt;/em&gt;th matching tag. The -1 in the array address gives us more user-friendly behavior: when we give it a 1, meaning the first match, it results in zero which is the actual first index in the array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to jump immediately to the first tag match, you can use the default mapping for tag jump (&lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;) because we have remapped it to call &lt;code&gt;:TabExpand 1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last part of the code ignores commented lines (based on the specified comment character), and jumps to the exact line and cursor location of the next tag match. You can press &lt;code&gt;n&lt;/code&gt; to cycle through further matches in the same file.&lt;/p&gt;&#xA;" OwnerUserId="10168" LastEditorUserId="10168" LastEditDate="2016-11-30T16:41:41.180" LastActivityDate="2016-11-30T16:41:41.180" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="10321" PostTypeId="2" ParentId="9218" CreationDate="2016-11-17T19:44:22.493" Score="2" Body="&lt;p&gt;Personally I very much dislike having to type out the entire word &quot;close&quot; - its smallest abbreviation is still &lt;code&gt;:clo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve this, I created the following command in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;command -nargs=0 C :close&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means I have a nice, quick command &lt;code&gt;:C&lt;/code&gt; which is very similar to &lt;code&gt;:q&lt;/code&gt; but it only closes the current window, rather than quits. I use it all the time.&lt;/p&gt;&#xA;" OwnerUserId="10168" LastActivityDate="2016-11-17T19:44:22.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10322" PostTypeId="1" CreationDate="2016-11-17T20:15:25.983" Score="2" ViewCount="95" Body="&lt;p&gt;I've never in 5+ years of vim usage and writing all kinds of custom plugins been able to properly figure out how to use the &lt;code&gt;gvim -P windowname&lt;/code&gt; command line option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to vim's own documentation, it's used to pop a gvim window into an MDI environment. Perhaps the main problem is that MDI sort of died with the introduction of things like Silverlight, WPF (Windows Presentation Foundation) and later HTML5. So there are very few programs still even using MDI. For example, Eclipse uses a tabbed environment (although there is a fantastic Vim pop-in solution for that called Eclim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every time I've tried to use it, it's failed, even with programs that have an MDI environment. MDI meaning multiple document interface - almost like a remote desktop session - where you can move windows around, resize them, collapse and tile, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever I try it, it just dies as if I didn't do anything, spitting out an error about an invalid window name. I've been totally unable to figure out how to use it, or what the correct &quot;window name&quot; is that it's looking for. I've tried the name of the program, the window title, and even the raw process name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to correctly use the -P command line parameter for gvim?&lt;/p&gt;&#xA;" OwnerUserId="10168" LastEditorUserId="10168" LastEditDate="2016-12-30T22:10:32.443" LastActivityDate="2016-12-30T22:10:32.443" Title="How to properly use the MDI window pop-in (-P parameter)" Tags="|gvim|microsoft-windows|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10323" PostTypeId="1" AcceptedAnswerId="10328" CreationDate="2016-11-17T22:07:46.197" Score="1" ViewCount="403" Body="&lt;p&gt;Sometimes I browse around the directory of the current buffer by using &lt;code&gt;:Ex&lt;/code&gt;. On one of my development machines, this results in a &lt;code&gt;.swp&lt;/code&gt; file being created in every directory I visit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've checked the directory variable other machines where this doesn't seem to be the issue, and they match (&lt;code&gt;directory=.,~/tmp,/var/tmp,/tmp&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that &lt;code&gt;.filename.swp&lt;/code&gt; files are useful for recovery and I would not like to disable swap files globally. The &lt;code&gt;.filename.swp&lt;/code&gt; files are correctly cleaned up when buffers are closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be OK with this behavior for directories if the files were cleaned afterwords, but they linger... eventually I run &lt;code&gt;find -name &quot;.swp&quot; -delete&lt;/code&gt; to clean them up.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:39:32)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8327" LastEditorUserId="5395" LastEditDate="2016-11-17T22:43:43.680" LastActivityDate="2016-12-29T20:18:00.973" Title=".swp swap files for directories while browsing with netrw" Tags="|netrw|swap-file|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10324" PostTypeId="2" ParentId="9537" CreationDate="2016-11-17T22:56:27.760" Score="0" Body="&lt;p&gt;If I am correct in thinking you are after a way to do the same thing, but to make it easier to do or to execute over and over?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is exactly what custom commands are for, but yours is a little tricky to make into a single command. Instead we can build a command that chains to a function, and put the meat of the code in that function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function HandleMultiReplace(...)&#xA;    exe 'normal! &quot;ayy'&#xA;    for data in a:000 &#xA;        exe 'norm! &quot;ap'&#xA;        exe 's/world/' . data . '/'&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function does exactly the same thing as your long line of code, but now it is parameterized with var args and is easy to call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't get too hung up on &lt;code&gt;a:000&lt;/code&gt; - it is basically the list of all variable arguments that were passed into the function. It only works if we specify varargs (...) in the parameter list, as we've done here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next we will add a command that calls our new function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=* MultiReplace :call HandleMultiReplace( &amp;lt;f-args&amp;gt; )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use the new command, put the above lines of code into your vimrc. Once you've done that, and have reloaded any vim windows that were open, you can just type the following and hit enter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:MultiReplace 'a', 'b', 'c'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The nice thing is that with var args, we can pass a list of any size we want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now let's say you wanted to improve your function and make the first argument the part you want to search for (to replace). This can be done by changing only the function as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function HandleMultiReplace(text, ...)&#xA;    exe 'normal! &quot;ayy'&#xA;    for data in a:000&#xA;        exe 'norm! &quot;ap'&#xA;        exe 's/' . a:text . '/' . data . '/'&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, when using your command, pass the replace text as the first parameter, and the list that follows it can still be as long as we want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:MultiReplace 'world', 'a', 'b', 'c'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10168" LastEditorUserId="10168" LastEditDate="2016-11-17T23:05:04.260" LastActivityDate="2016-11-17T23:05:04.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10325" PostTypeId="1" CreationDate="2016-11-17T23:18:37.723" Score="3" ViewCount="1246" Body="&lt;p&gt;Wondering if it is possible to check C++ header files in vim with Syntastic running clang-tidy as checker?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:SyntasticCheck on .hpp files does nothing, though running the same command on the .cpp file that includes the header does check that header, but I'd rather check the header while I am editing it, not while I am editing the source file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The gcc checker works on .hpp files, but clang tidy does not as far as I can tell.&#xA;I am aware of the clang-tidy arg -header-filter, but I'm somewhat lost on how to use that, if it is even the right place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;relevant .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_cpp_checkers = ['clang_tidy'] &#xA;let g:syntastic_cpp_check_header = 1&#xA;let g:syntastic_cpp_auto_refresh_includes = 1&#xA;let g:syntastic_cpp_clang_tidy_args = '-checks=*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10125" LastActivityDate="2016-11-17T23:18:37.723" Title="Syntastic Header Checking with Clang Tidy" Tags="|plugin-syntastic|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10326" PostTypeId="2" ParentId="10194" CreationDate="2016-11-18T03:43:18.447" Score="4" Body="&lt;p&gt;Using &lt;code&gt;undojoin&lt;/code&gt; actually works pretty well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost *  undojoin | set noexpandtab | retab! 4&#xA;autocmd BufWritePre *  undojoin | set expandtab   | retab! 4&#xA;autocmd BufWritePost * undojoin | set noexpandtab | retab! 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if you execute &lt;code&gt;:w&lt;/code&gt; right after undoing an action, you'll get an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing BufWritePre Auto commands for &quot;*&quot;:&#xA;E790: undojoin is not allowed after undo&#xA;Error detected while processing BufWritePost Auto commands for &quot;*&quot;:&#xA;E790: undojoin is not allowed after undo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This error can be silenced using &lt;code&gt;silent!&lt;/code&gt; as mentioned &lt;a href=&quot;https://vi.stackexchange.com/questions/10194/is-it-possible-to-remove-an-entry-from-the-undo-history/10326#comment18177_10326&quot;&gt;in the comments&lt;/a&gt;, but may have some unintentional side effects:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost *  silent! undojoin | set noexpandtab | retab! 4&#xA;autocmd BufWritePre *  silent! undojoin | set expandtab   | retab! 4&#xA;autocmd BufWritePost * silent! undojoin | set noexpandtab | retab! 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user8048" LastEditorDisplayName="user8048" LastEditDate="2016-11-19T02:52:01.863" LastActivityDate="2016-11-19T02:52:01.863" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10327" PostTypeId="2" ParentId="5867" CreationDate="2016-11-18T05:26:53.207" Score="2" Body="&lt;p&gt;I've had great luck recently with &lt;a href=&quot;http://eclim.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Eclim&lt;/a&gt;, an Eclipse plugin that gives you vim windows. I sometimes find myself still just using Vim by itself, but it does give you the best of both worlds, sort of. I've never used Vrapper, but I imagine it would also work well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's possible an Eclipse environment might require additional setup on the vim side; mine certainly did. Once the IDE is able to load a vim window, it's a matter of getting rid of any strange behavior the new environment creates, such as additional ENTER prompts. I had to fix a couple such annoyances but it works great now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yes, you should definitely consider Eclipse an alternative to NetBeans for vim integration. At least give it a try, and if you don't like it, then no harm done.&lt;/p&gt;&#xA;" OwnerUserId="10168" LastActivityDate="2016-11-18T05:26:53.207" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10328" PostTypeId="2" ParentId="10323" CreationDate="2016-11-18T07:06:14.007" Score="2" Body="&lt;p&gt;This is probably a netrw bug. You might be able to work around by creating a file &lt;code&gt;~/.vim/after/ftplugin/netrw.vim&lt;/code&gt; (create non-existent directories) and put in there &lt;code&gt;:set noswapfile&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-11-18T07:06:14.007" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10329" PostTypeId="1" AcceptedAnswerId="10330" CreationDate="2016-11-18T12:14:44.643" Score="5" ViewCount="4821" Body="&lt;p&gt;I'm testing NeoVim and would like to put in my vimrc universal mapping for either vim and nvim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've sketch sth like below so far, but it doesn't work and it's &lt;em&gt;very&lt;/em&gt; rough.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Meta(key) &quot; define if using alt(it works in neovim) or leader key. Used below for mapping only.&#xA;    &quot; for neovim testing and changing habits&#xA;    if has('nvim')&#xA;        let meta = &quot;&amp;lt;A-&quot; . a:key . &quot;&amp;gt;&quot;&#xA;    else&#xA;        let meta = &quot;&amp;lt;leader&amp;gt;&quot; . a:key&#xA;    endif&#xA;    &quot; return meta&#xA;endfunction&#xA;&#xA;call Meta('j')&#xA;nnoremap &amp;lt;silent&amp;gt;meta :set paste&amp;lt;CR&amp;gt;m`o&amp;lt;Esc&amp;gt;``:set nopaste&amp;lt;CR&amp;gt;&#xA;call Meta('k')&#xA;nnoremap &amp;lt;silent&amp;gt;meta :set paste&amp;lt;CR&amp;gt;m`O&amp;lt;Esc&amp;gt;``:set nopaste&amp;lt;CR&amp;gt;&#xA;(...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to solve it in a smart way?&lt;/p&gt;&#xA;" OwnerUserId="8444" LastEditorUserId="8444" LastEditDate="2019-01-31T12:38:47.217" LastActivityDate="2019-01-31T12:38:47.217" Title="Use variable for mapping inside vimrc" Tags="|key-bindings|vimrc|neovim|functions|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10330" PostTypeId="2" ParentId="10329" CreationDate="2016-11-18T13:25:39.900" Score="10" Body="&lt;p&gt;The &lt;code&gt;:map&lt;/code&gt; command takes &lt;code&gt;:help key-notation&lt;/code&gt;, but not variables. Vimscript is evaluated exactly like the Ex commands typed in the &lt;code&gt;:&lt;/code&gt; command-line. There were no variables in &lt;code&gt;ex&lt;/code&gt;, so there's no way to specify them. When typing a command interactively, you'd probably use &lt;code&gt;&amp;lt;C-R&amp;gt;=&lt;/code&gt; to insert variable contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sleep &amp;lt;C-R&amp;gt;=timetowait&amp;lt;CR&amp;gt;m&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... but in a script, &lt;code&gt;:execute&lt;/code&gt; must be used. All the literal parts of the Ex command must be quoted (single or double quotes), and then concatenated with the variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'sleep' timetowait . 'm'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Your example&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Here's the variable interpolation applied to your example (using a script-local variable):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Meta(key) &quot; define if using alt(it works in neovim) or leader key. Used below for mapping only.&#xA;    if has('nvim')&#xA;        let s:meta = &quot;&amp;lt;A-&quot; . a:key . &quot;&amp;gt;&quot;&#xA;    else&#xA;        let s:meta = &quot;&amp;lt;leader&amp;gt;&quot; . a:key&#xA;    endif&#xA;endfunction&#xA;&#xA;call Meta('j')&#xA;execute 'nnoremap &amp;lt;silent&amp;gt;' . s:meta . ' :set paste&amp;lt;CR&amp;gt;m`o&amp;lt;Esc&amp;gt;``:set nopaste&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I would change your function to &lt;em&gt;return&lt;/em&gt; the resulting key, so that you save the separate function invocation and variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Meta(key) &quot; define if using alt(it works in neovim) or leader key.&#xA;    &quot; for neovim testing and changing habits&#xA;    if has('nvim')&#xA;        return &quot;&amp;lt;A-&quot; . a:key . &quot;&amp;gt;&quot;&#xA;    else&#xA;        return &quot;&amp;lt;leader&amp;gt;&quot; . a:key&#xA;    endif&#xA;endfunction&#xA;&#xA;execute 'nnoremap &amp;lt;silent&amp;gt;' . Meta('j') . ' :set paste&amp;lt;CR&amp;gt;m`o&amp;lt;Esc&amp;gt;``:set nopaste&amp;lt;CR&amp;gt;'&#xA;execute 'nnoremap &amp;lt;silent&amp;gt;' . Meta('k') . ' :set paste&amp;lt;CR&amp;gt;m`O&amp;lt;Esc&amp;gt;``:set nopaste&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-11-18T13:25:39.900" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10331" PostTypeId="2" ParentId="10329" CreationDate="2016-11-18T14:15:23.653" Score="3" Body="&lt;p&gt;On complement to @Ingo's &lt;a href=&quot;https://vi.stackexchange.com/a/10330/626&quot;&gt;answer&lt;/a&gt; which explains very well how it could be done. If you need to define many mappings, I'd go with defining a dedicated command to write things like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Meta nnoremap &amp;lt;silent&amp;gt; j :set paste&amp;lt;cr&amp;gt;m`o&amp;lt;esc&amp;gt;``:set nopaste&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which could be &lt;a href=&quot;https://github.com/LucHermitte/lh-misc/blob/master/plugin/meta-map.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;defined thanks to&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; TODO: add support for command line completion...&#xA;command! -nargs=+&#xA;      \ Meta&#xA;      \ call s:Map(&amp;lt;f-args&amp;gt;)&#xA;&#xA;let s:is_meta_supported = has('nvim') || has('gui_running')&#xA;&#xA;function! s:Map(how, ...)&#xA;  let cmd = a:how&#xA;  let is_key_known = 0&#xA;  for a in a:000&#xA;    if ! is_key_known &amp;amp;&amp;amp; a !~ '^&amp;lt;\k\+&amp;gt;$'&#xA;      let cmd .= s:is_meta_supported ? ' &amp;lt;M-'.a.'&amp;gt;' : ' &amp;lt;leader&amp;gt;'.a&#xA;      let is_key_known = 1&#xA;    else&#xA;      let cmd .= ' '.a&#xA;    endif&#xA;  endfor&#xA;  exe cmd&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Side note: meta keys (usually bound to &lt;code&gt;&amp;lt;M-&lt;/code&gt;) works well (enough) with gvim as well -- it's just that gvim doesn't make any difference between &lt;code&gt;&amp;lt;m-i&amp;gt;&lt;/code&gt; and &lt;code&gt;é&lt;/code&gt;, and many other diacritics.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-11-18T14:15:23.653" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10332" PostTypeId="1" CreationDate="2016-11-18T22:47:34.337" Score="2" ViewCount="1226" Body="&lt;p&gt;&lt;code&gt;ci(&lt;/code&gt;, &lt;code&gt;ci{&lt;/code&gt;, &lt;code&gt;ci&amp;lt;&lt;/code&gt;, etc. work but &lt;code&gt;ci&quot;&lt;/code&gt; and &lt;code&gt;ci'&lt;/code&gt; do nothing. The text inside the speech marks is not deleted and I am not put into insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a Dell laptop running Ubuntu OS with the standard British English key mapping. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: I think the problem may have been that I was trying to edit curly quotation marks aka smart quotes rather than regular quotation marks. The text I was practising on was copy&amp;amp;pasted from the internet whereas when I type the quotes for myself the commands do then work when I want to edit what's inside. &lt;/p&gt;&#xA;" OwnerUserId="10183" LastEditorUserId="10183" LastEditDate="2016-11-22T15:20:14.290" LastActivityDate="2016-11-23T12:45:28.223" Title="ci&quot; and ci' not working" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10333" PostTypeId="1" AcceptedAnswerId="10339" CreationDate="2016-11-18T22:53:46.817" Score="1" ViewCount="647" Body="&lt;p&gt;I would like to be able to search through the previous commands starting with &lt;code&gt;:&lt;/code&gt; that I entered, using an interactive incremental search, as it is possible in some shells (example: with Ctrl-r in bash).&lt;/p&gt;&#xA;" OwnerUserId="8409" LastEditorUserId="135" LastEditDate="2016-12-23T13:10:09.223" LastActivityDate="2016-12-23T13:10:09.223" Title="reverse-i-search à la Bash Ctrl-r" Tags="|search|command-history|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10334" PostTypeId="2" ParentId="10333" CreationDate="2016-11-18T23:44:10.533" Score="0" Body="&lt;p&gt;You can use &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Down&amp;gt;&lt;/code&gt; at any time to recall previous commands starting with what you already typed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help history&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-11-18T23:44:10.533" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10335" PostTypeId="1" AcceptedAnswerId="10340" CreationDate="2016-11-19T03:33:24.223" Score="2" ViewCount="698" Body="&lt;p&gt;The fact that Vim highlights the strings matched by a search expression can be useful if you are searching for visual patterns in a text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to now if it was possible to quickly cycle throught the last searches? By that I mean faster that hitting &lt;code&gt;/&lt;/code&gt; then &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt; a given number of time, because the number of time you have to hit &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt; grows quadratically with the length of the cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give an example:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/MGzJP.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MGzJP.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;There is a loop in this gif, but it would be fine if having to go back was necessary.&lt;/p&gt;&#xA;" OwnerUserId="8409" LastActivityDate="2016-11-19T16:31:03.610" Title="How to quickly cycle through the search history?" Tags="|search|highlight|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10336" PostTypeId="2" ParentId="343" CreationDate="2016-11-19T08:24:42.053" Score="9" Body="&lt;p&gt;Use the &quot;bvi&quot; editor.  &lt;a href=&quot;http://bvi.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;http://bvi.sourceforge.net/&lt;/a&gt;  (It's in every Linux repository.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ apt-cache show bvi&#xA;[snip]&#xA;Description-en: binary file editor&#xA; The bvi is a display-oriented editor for binary files, based on the vi&#xA; text editor. If you are familiar with vi, just start the editor and begin to&#xA; edit! If you never heard about vi, maybe bvi is not the best choice for you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10187" LastActivityDate="2016-11-19T08:24:42.053" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10338" PostTypeId="1" AcceptedAnswerId="10342" CreationDate="2016-11-19T12:50:41.463" Score="6" ViewCount="7726" Body="&lt;p&gt;In Vim, how to change the vimrc so that I could keep files' \t characters while I don't want \t characters appear in the newline generated by auto-indentation and tab-button I pressed.&lt;/p&gt;&#xA;&lt;p&gt;Is this achievable?&lt;/p&gt;&#xA;&lt;p&gt;Here is what I have appended to the tail of _vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set nu &#xA;set noexpandtab &amp;quot; I want to read \t, not to translate them as spaces.&#xA;set tabstop=8 &amp;quot; I want to read \t as 8-space-width.&#xA;&#xA;set softtabstop=4 &amp;quot; This makes the &amp;lt;BS&amp;gt; and &amp;lt;Tab&amp;gt; always 4-space-long.&#xA;set autoindent&#xA;set colorcolumn=100&#xA;set shiftwidth=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Why I have this question: In Python, you can't mix both \t and spaces while indenting.&lt;/p&gt;&#xA;" OwnerUserId="10189" LastEditorUserId="10189" LastEditDate="2021-01-03T18:39:37.317" LastActivityDate="2021-01-03T18:39:37.317" Title="Keep \t Characters, While Don't Transform Spaces to Tabs?" Tags="|vimrc|indentation|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10339" PostTypeId="2" ParentId="10333" CreationDate="2016-11-19T14:28:22.957" Score="3" Body="&lt;p&gt;There is no direct equivalent of such behaviour of libreadline, but since Vim 7.4.2268 you can navigate through search matches when &lt;code&gt;'incsearch'&lt;/code&gt; option is on &lt;em&gt;without&lt;/em&gt; leaving search mode via &lt;a href=&quot;https://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-G&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;kbd&gt;Ctrl-G&lt;/kbd&gt;/&lt;kbd&gt;Ctrl-T&lt;/kbd&gt; keys&lt;/a&gt;, which combined with &lt;a href=&quot;https://vimhelp.appspot.com/cmdline.txt.html#cmdline-window&quot; rel=&quot;nofollow noreferrer&quot;&gt;command-line window&lt;/a&gt; can give you experience similar to what you seek.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's very easy if you know that you're going to use search right from the start:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5TXnf.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5TXnf.gif&quot; alt=&quot;start in cmdline-window&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And requires several additional keystrokes to lift your input into search pattern if you realize you want to search in the middle of typing your command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FNdx6.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FNdx6.gif&quot; alt=&quot;start in command-line&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="860" LastActivityDate="2016-11-19T14:28:22.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10340" PostTypeId="2" ParentId="10335" CreationDate="2016-11-19T16:31:03.610" Score="4" Body="&lt;p&gt;When you are entering the search pattern, press &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt; to cycle backwards through your search history or press &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;N&lt;/kbd&gt; to cycle forwards again. This is explained at the help at &lt;code&gt;:h c_CTRL-N&lt;/code&gt; (&lt;a href=&quot;https://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-N&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-11-19T16:31:03.610" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10341" PostTypeId="2" ParentId="10338" CreationDate="2016-11-19T16:42:37.820" Score="2" Body="&lt;p&gt;Vim doesn't translate tabs (&lt;code&gt;\t&lt;/code&gt; characters) to spaces unless you edit the line containing tabs in certain ways or use the &lt;code&gt;:retab&lt;/code&gt; command. If you don't want tabs in lines you add, even if you type a tab, then you need to set &lt;code&gt;expandtab&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2016-11-19T16:42:37.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10342" PostTypeId="2" ParentId="10338" CreationDate="2016-11-19T16:56:20.927" Score="4" Body="&lt;p&gt;Replace&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set noexpandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This will make both auto-indentation and Tabs you manually typed to only spaces.&lt;/p&gt;&#xA;&lt;p&gt;Now you can type a line containing mixture of both spaces and Tabs with length greater than which tabstop is set,&lt;/p&gt;&#xA;&lt;p&gt;without worrying some spaces become \t. And actually,&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;&lt;code&gt;set expandtab&lt;/code&gt;&lt;/strong&gt;&#xA;does &lt;strong&gt;NOT&lt;/strong&gt; means your files don't contains \t any more,&lt;/p&gt;&#xA;&lt;p&gt;by typing &amp;lt;Ctrl-Q&amp;gt; + &amp;lt;Tab&amp;gt; you can insert the real \t in your program.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;before I solve this problem I think the opposite is true.&lt;/p&gt;&#xA;" OwnerUserId="10189" LastEditorUserId="10189" LastEditDate="2021-01-03T18:38:21.983" LastActivityDate="2021-01-03T18:38:21.983" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10343" PostTypeId="2" ParentId="4580" CreationDate="2016-11-19T19:17:22.930" Score="3" Body="&lt;p&gt;I've recently looked for a way, how to put the clipboard content into a new buffer in vim. I think, it is worth to share it here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;put! *&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;br&gt;&#xA;This will &lt;code&gt;put&lt;/code&gt; the text from register &lt;code&gt;*&lt;/code&gt; before &lt;code&gt;!&lt;/code&gt; the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;+&lt;/code&gt; registers refers to clipboard in windows. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On linux &lt;code&gt;+&lt;/code&gt; has the content of the clipboard and &lt;code&gt;*&lt;/code&gt; contains the selected text.&lt;/p&gt;&#xA;" OwnerUserId="8559" LastEditorUserId="8559" LastEditDate="2017-01-20T06:40:41.577" LastActivityDate="2017-01-20T06:40:41.577" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10345" PostTypeId="2" ParentId="343" CreationDate="2016-11-20T05:30:27.993" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/katonori/binedit.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; looks like a handy little vim plugin that does the job using a temporary file which it writes back and forth for you automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some years ago I found a similar plugin which I adapted and improved for my own use. I've included the relevant code for that here, in case anyone wants it. It too is based on the xxd tool. I'm sure the GitHub version I linked above works better, but I haven't actually used it myself, so I figured I'd also post this one which I know for sure works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The source for this other version was the vim wikia, specifically &lt;a href=&quot;http://vim.wikia.com/wiki/Improved_Hex_editing&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;-------------------------------------------------------------------------------  &#xA;&quot; Hexmode  &#xA;&quot;-------------------------------------------------------------------------------  &#xA;&quot; Creates an automatic hex viewing mode for vim by converting between hex dump  &#xA;&quot; and binary formats. Makes editing binary files a breeze.  &#xA;&quot;-------------------------------------------------------------------------------  &#xA;&quot; Source: vim.wikia.com/wiki/Improved_Hex_editing  &#xA;&quot; Author: Fritzophrenic, Tim Baker  &#xA;&quot; Version: 7.1  &#xA;&quot;-------------------------------------------------------------------------------  &#xA;&quot; Configurable Options {{{1  &#xA;&quot;-------------------------------------------------------------------------------  &#xA;&#xA;&quot; Automatically recognized extensions  &#xA;let s:hexmode_extensions = &quot;*.bin,*.exe,*.hex&quot;  &#xA;&#xA;&quot;-------------------------------------------------------------------------------&#xA;&quot; Commands and Mappings {{{1&#xA;&quot;-------------------------------------------------------------------------------&#xA;&#xA;&quot; ex command for toggling hex mode - define mapping if desired&#xA;command! -bar Hexmode call ToggleHex()&#xA;command! -nargs=0 Hexconfig edit $VIM\vimfiles\plugin\hexmode.vim | exe &quot;normal 11G&quot; | exe &quot;normal zo&quot;&#xA;&#xA;nnoremap &amp;lt;C-H&amp;gt; :Hexmode&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;C-H&amp;gt; &amp;lt;Esc&amp;gt;:Hexmode&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;C-H&amp;gt; :&amp;lt;C-U&amp;gt;Hexmode&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;-------------------------------------------------------------------------------    &#xA;&quot; Autocommands {{{1  &#xA;&quot;-------------------------------------------------------------------------------  &#xA;&#xA;if exists(&quot;loaded_hexmode&quot;)  &#xA;    finish  &#xA;endif  &#xA;let loaded_hexmode = 1  &#xA;&#xA;&quot; Automatically enter hex mode and handle file writes properly  &#xA;if has(&quot;autocmd&quot;)  &#xA;  &quot; vim -b : edit binary using xxd-format  &#xA;  augroup Binary  &#xA;    au!  &#xA;&#xA;    &quot; set binary option for all binary files before reading them  &#xA;    exe &quot;au! BufReadPre &quot; . s:hexmode_extensions . &quot; setlocal binary&quot;&#xA;&#xA;    &quot; if on a fresh read the buffer variable is already set, it's wrong&#xA;    au BufReadPost *&#xA;          \ if exists('b:editHex') &amp;amp;&amp;amp; b:editHex |&#xA;          \   let b:editHex = 0 |&#xA;          \ endif&#xA;&#xA;    &quot; convert to hex on startup for binary files automatically&#xA;    au BufReadPost *&#xA;          \ if &amp;amp;binary | Hexmode | endif&#xA;&#xA;    &quot; When the text is freed, the next time the buffer is made active it will&#xA;    &quot; re-read the text and thus not match the correct mode, we will need to&#xA;    &quot; convert it again if the buffer is again loaded.&#xA;    au BufUnload *&#xA;          \ if getbufvar(expand(&quot;&amp;lt;afile&amp;gt;&quot;), 'editHex') == 1 |&#xA;          \   call setbufvar(expand(&quot;&amp;lt;afile&amp;gt;&quot;), 'editHex', 0) |&#xA;          \ endif&#xA;&#xA;    &quot; before writing a file when editing in hex mode, convert back to non-hex&#xA;    au BufWritePre *&#xA;          \ if exists(&quot;b:editHex&quot;) &amp;amp;&amp;amp; b:editHex &amp;amp;&amp;amp; &amp;amp;binary |&#xA;          \  let oldro=&amp;amp;ro | let &amp;amp;ro=0 |&#xA;          \  let oldma=&amp;amp;ma | let &amp;amp;ma=1 |&#xA;          \  silent exe &quot;%!xxd -r&quot; |&#xA;          \  let &amp;amp;ma=oldma | let &amp;amp;ro=oldro |&#xA;          \  unlet oldma | unlet oldro |&#xA;          \ endif&#xA;&#xA;    &quot; after writing a binary file, if we're in hex mode, restore hex mode&#xA;    au BufWritePost *&#xA;          \ if exists(&quot;b:editHex&quot;) &amp;amp;&amp;amp; b:editHex &amp;amp;&amp;amp; &amp;amp;binary |&#xA;          \  let oldro=&amp;amp;ro | let &amp;amp;ro=0 |&#xA;          \  let oldma=&amp;amp;ma | let &amp;amp;ma=1 |&#xA;          \  silent exe &quot;%!xxd&quot; |&#xA;          \  exe &quot;set nomod&quot; |&#xA;          \  let &amp;amp;ma=oldma | let &amp;amp;ro=oldro |&#xA;          \  unlet oldma | unlet oldro |&#xA;          \ endif&#xA;  augroup END  &#xA;endif  &#xA;&#xA;&quot;-------------------------------------------------------------------------------&#xA;&quot; Functions {{{1&#xA;&quot;-------------------------------------------------------------------------------&#xA;&#xA;&quot; helper function to toggle hex mode&#xA;function! ToggleHex()&#xA;  &quot; hex mode should be considered a read-only operation&#xA;  &quot; save values for modified and read-only for restoration later,&#xA;  &quot; and clear the read-only flag for now&#xA;  let l:modified=&amp;amp;mod&#xA;  let l:oldreadonly=&amp;amp;readonly&#xA;  let &amp;amp;readonly=0&#xA;  let l:oldmodifiable=&amp;amp;modifiable&#xA;  let &amp;amp;modifiable=1&#xA;  if !exists(&quot;b:editHex&quot;) || !b:editHex&#xA;    &quot; save old options&#xA;    let b:oldft=&amp;amp;ft&#xA;    let b:oldbin=&amp;amp;bin&#xA;    &quot; set new options&#xA;    setlocal binary &quot; make sure it overrides any textwidth, etc.&#xA;    let &amp;amp;ft=&quot;xxd&quot;&#xA;    &quot; set status&#xA;    let b:editHex=1&#xA;    &quot; switch to hex editor&#xA;    set sh=C:/cygwin/bin/bash&#xA;    %!xxd&#xA;  else&#xA;    &quot; restore old options&#xA;    let &amp;amp;ft=b:oldft&#xA;    if !b:oldbin&#xA;      setlocal nobinary&#xA;    endif&#xA;    &quot; set status&#xA;    let b:editHex=0&#xA;    &quot; return to normal editing&#xA;    %!xxd -r&#xA;  endif&#xA;  &quot; restore values for modified and read only state&#xA;  let &amp;amp;mod=l:modified&#xA;  let &amp;amp;readonly=l:oldreadonly&#xA;  let &amp;amp;modifiable=l:oldmodifiable&#xA;endfunction&#xA;&#xA;&quot; vim: ft=vim:fdc=2:fdm=marker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10168" LastEditorUserId="10168" LastEditDate="2017-01-20T15:01:18.827" LastActivityDate="2017-01-20T15:01:18.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10348" PostTypeId="1" CreationDate="2016-11-20T14:52:52.783" Score="1" ViewCount="350" Body="&lt;p&gt;When I start gvim without rc file (&lt;code&gt;gvim -i NONE -u NONE -U NONE&lt;/code&gt;), gvim still reads &lt;code&gt;$VIMRUNTIME/menu.vim&lt;/code&gt;. I am looking for a way to prevent gvim from doing exactly that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, &lt;code&gt;:help -U&lt;/code&gt; explicitely states&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-U {gvimrc} [...]&#xA;        Exception: Reading the system-wide menu file is always done.&#xA;        [...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do I have to interpret this &lt;em&gt;exception&lt;/em&gt; such that there is really no way to start gvim without the menu.vim?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="985" LastEditDate="2016-11-20T15:19:32.263" LastActivityDate="2016-12-20T15:54:02.307" Title="Is there no way to prevent gvim from reading the system wide menu file?" Tags="|vimrc|startup|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10349" PostTypeId="2" ParentId="10348" CreationDate="2016-11-20T15:40:22.733" Score="1" Body="&lt;p&gt;You can prevent loading the menu by setting the &lt;code&gt;'go'&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Excerpt from my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; don't want any menus, just an term like gvim&#xA;&quot; needs to come first, because :syn on and :filetype&#xA;&quot; would else load the system menu&#xA;set go=M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-11-20T15:40:22.733" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10350" PostTypeId="1" AcceptedAnswerId="10351" CreationDate="2016-11-20T18:59:42.230" Score="6" ViewCount="10985" Body="&lt;p&gt;One of my project folders has a file &lt;code&gt;$MYVIMRC&lt;/code&gt;. I didn't create it. &#xA;I have a .vimrc file I created in my home folder. What is the difference and what is &lt;code&gt;$MYVIMRC&lt;/code&gt; and when/how is it created. &lt;/p&gt;&#xA;" OwnerUserId="10183" LastEditorUserId="1841" LastEditDate="2016-11-20T23:31:40.517" LastActivityDate="2016-11-20T23:31:40.517" Title="What is the variable $MYVIMRC?" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10351" PostTypeId="2" ParentId="10350" CreationDate="2016-11-20T23:29:36.777" Score="5" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#%24MYVIMRC&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h $MYVIMRC&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;VIMINIT&lt;/em&gt; &lt;em&gt;.vimrc&lt;/em&gt; &lt;em&gt;_vimrc&lt;/em&gt; &lt;em&gt;EXINIT&lt;/em&gt; &lt;em&gt;.exrc&lt;/em&gt; &lt;em&gt;_exrc&lt;/em&gt; &lt;em&gt;$MYVIMRC&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;c. Four places are searched for initializations.  The first that exists&#xA;  is used, the others are ignored.  &lt;strong&gt;The $MYVIMRC environment variable is&#xA;  set to the file that was first found, unless $MYVIMRC was already set&#xA;  and when using VIMINIT.&lt;/strong&gt;&lt;br/&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;The environment variable VIMINIT (see also |compatible-default|) (*)&lt;br/&gt;&#xA;  The value of $VIMINIT is used as an Ex command line.&lt;br/&gt;&lt;/li&gt;&#xA;  &lt;li&gt;The environment variable VIMINIT (see also |compatible-default|) (*)&lt;br/&gt;&#xA;  The value of $VIMINIT is used as an Ex command line.&lt;br/&gt;&lt;/li&gt;&#xA;  &lt;li&gt;The user vimrc file(s):&lt;br/&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&quot;$HOME/.vimrc&quot;    (for Unix and OS/2) (*)&lt;br/&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&quot;$HOME/.vim/vimrc&quot;    (for Unix and OS/2) (*)&lt;br/&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&quot;s:.vimrc&quot;        (for Amiga) (*)&lt;br/&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&quot;home:.vimrc&quot;     (for Amiga) (*)&lt;br/&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&quot;home:vimfiles:vimrc&quot;  (for Amiga) (*)&lt;br/&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&quot;$VIM/.vimrc&quot;     (for OS/2 and Amiga) (*)&lt;br/&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&quot;$HOME/_vimrc&quot;    (for MS-DOS and Win32) (*)&lt;br/&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&quot;$HOME/vimfiles/vimrc&quot; (for MS-DOS and Win32) (*)&lt;br/&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&quot;$VIM/_vimrc&quot;     (for MS-DOS and Win32) (*)&lt;br/&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So basically &lt;code&gt;$MYVIMRC&lt;/code&gt; contains the location of the file which as used as your configuration file&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-11-20T23:29:36.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10353" PostTypeId="1" AcceptedAnswerId="10354" CreationDate="2016-11-21T08:59:08.700" Score="4" ViewCount="4177" Body="&lt;p&gt;I wonder if there is an elegant way to determine if a specific file exists in/under one of the entries of &lt;code&gt;&amp;amp;rtp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I use the following construct:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:found_ = 0&#xA;for s:dir_ in split(&amp;amp;rtp, ',')&#xA;  let s:file_ = s:dir_ . '/autoload/FooBarBaz.vim'&#xA;  if filereadable(s:file_)&#xA;     let s:found_ = 1&#xA;     break&#xA;  endif&#xA;endfor&#xA;&#xA;if s:found_&#xA;   call FooBarBaz#func()&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am under the impression that vim could offer a function or something that does it more elegantly, such as &lt;code&gt;exists('*FooBarBaz#func')&lt;/code&gt; which unfortunately didn't work as I intended.&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2016-11-21T11:40:45.850" Title="Is there an elegant way to determine if a file exists in/under runtimepath?" Tags="|filesystem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10354" PostTypeId="2" ParentId="10353" CreationDate="2016-11-21T09:45:48.177" Score="11" Body="&lt;p&gt;You're looking for &lt;code&gt;globpath()&lt;/code&gt;. If it returns a non empty string, then there is at least a match.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !empty((globpath(&amp;amp;rtp, '/autoload/FooBarBaz.vim'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may also want to check &lt;code&gt;filereadable()&lt;/code&gt; if you suspect you may not be able to open the file. BTW, I'd have used &lt;code&gt;filter()&lt;/code&gt; in your solution (I hate debugging vim loops) -&gt; &lt;code&gt;if !empty(filter(split(&amp;amp;rtp,','), 'filereable(v:val.&quot;autoload/FooBarBaz.vim&quot;)')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in that case, I often simply run a:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime autoload/FooBarBaz.vim&#xA;if !exists('*FooBarBaz#func')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(See my convoluted &lt;a href=&quot;https://github.com/LucHermitte/lh-dev/blob/master/autoload/lh/dev/option.vim#L73&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;lh#dev#option#call()&lt;/code&gt;&lt;/a&gt; which searches the first function that matches &lt;code&gt;prefix#{filetype}#postfix(args)&lt;/code&gt; among a list of filetypes.)&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-11-21T11:40:45.850" LastActivityDate="2016-11-21T11:40:45.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10356" PostTypeId="1" AcceptedAnswerId="10359" CreationDate="2016-11-21T12:23:22.637" Score="5" ViewCount="2293" Body="&lt;p&gt;Is it possible using &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERD-commenter&lt;/a&gt; to uncomment a multiline block under the cursor without selecting the entire block visually first?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If no, are there any better plugins, that can do the job?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;dependencies&amp;gt;&#xA;    &amp;lt;dependency&amp;gt;&#xA;        &amp;lt;groupId&amp;gt;org.apache.httpcomponents&amp;lt;/groupId&amp;gt;&#xA;        &amp;lt;artifactId&amp;gt;httpclient&amp;lt;/artifactId&amp;gt;&#xA;        &amp;lt;version&amp;gt;4.4.1&amp;lt;/version&amp;gt;&#xA;    &amp;lt;/dependency&amp;gt;&#xA;    &amp;lt;dependency&amp;gt;&#xA;        &amp;lt;groupId&amp;gt;org.apache.httpcomponents&amp;lt;/groupId&amp;gt;&#xA;        &amp;lt;artifactId&amp;gt;httpcore&amp;lt;/artifactId&amp;gt;&#xA;        &amp;lt;version&amp;gt;4.4.1&amp;lt;/version&amp;gt;&#xA;    &amp;lt;/dependency&amp;gt;&#xA;&amp;lt;/dependencies&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Commenting out first &lt;code&gt;dependency&lt;/code&gt; tag using &lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;cm&lt;/kbd&gt; I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;dependencies&amp;gt;&#xA;    &amp;lt;!--&amp;lt;dependency&amp;gt;&#xA;        &amp;lt;groupId&amp;gt;org.jboss.logmanager&amp;lt;/groupId&amp;gt;&#xA;    |   &amp;lt;artifactId&amp;gt;log4j-jboss-logmanager&amp;lt;/artifactId&amp;gt;&#xA;        &amp;lt;version&amp;gt;1.1.1.Final-redhat-1&amp;lt;/version&amp;gt;&#xA;        &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;&#xA;    &amp;lt;/dependency&amp;gt;--&amp;gt;&#xA;    &amp;lt;dependency&amp;gt;&#xA;        &amp;lt;groupId&amp;gt;org.apache.httpcomponents&amp;lt;/groupId&amp;gt;&#xA;        &amp;lt;artifactId&amp;gt;httpcore&amp;lt;/artifactId&amp;gt;&#xA;        &amp;lt;version&amp;gt;4.4.1&amp;lt;/version&amp;gt;&#xA;    &amp;lt;/dependency&amp;gt;&#xA;&amp;lt;/dependencies&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I place the cursor inside the commented out tag (like showed above) and want to uncomment the tag.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;cu&lt;/kbd&gt; - does nothing&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;space&lt;/kbd&gt; - comments out the current line breaking XML format.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3230" LastEditorUserId="1841" LastEditDate="2016-11-21T16:06:07.283" LastActivityDate="2016-11-21T16:06:07.283" Title="Uncomment multiline block with NERDCommenter" Tags="|comments|plugin-nerdcommenter|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10357" PostTypeId="1" CreationDate="2016-11-21T14:40:15.207" Score="7" ViewCount="5668" Body="&lt;p&gt;In vim I can use for instance &lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; to go 10 lines down. And I can use &lt;code&gt;.&lt;/code&gt; to repeat the last deletion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, in bash script I have many commented lines like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# ...&#xA;# ...&#xA;# ...&#xA;# ...&#xA;# ...&#xA;# ...&#xA;# ...&#xA;# ...&#xA;# ...&#xA;etc...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Say, there are 52 such lines. Is there a way to combine moving &lt;code&gt;52j&lt;/code&gt; and repeating the deletion of the &lt;code&gt;#&lt;/code&gt; via &lt;code&gt;x&lt;/code&gt; and delete 52 lines at once?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastEditorUserId="1841" LastEditDate="2016-11-21T15:48:59.700" LastActivityDate="2021-05-08T19:44:49.803" Title="Uncomment multiple lines" Tags="|normal-mode|comments|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10358" PostTypeId="2" ParentId="10357" CreationDate="2016-11-21T15:41:28.693" Score="11" Body="&lt;p&gt;I do approve @mMontu comment suggesting to use a comment plugin (&lt;a href=&quot;https://github.com/tpope/vim-commentary/&quot; rel=&quot;noreferrer&quot;&gt;vim-commentary&lt;/a&gt; is an option but &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;noreferrer&quot;&gt;NERDCommenter&lt;/a&gt; has my preference over vim-commentary).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you could do it in other ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First if all your &lt;code&gt;#&lt;/code&gt; are aligned on the same column you can block select them with &lt;kbd&gt;ctrl+v&lt;/kbd&gt;&lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; and then delete your selection with &lt;kbd&gt;x&lt;/kbd&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If they are not aligned you could use a macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq^xjq&#xA;&#xA;qq        Record a macro in the register q&#xA;^         Go to beginning of line&#xA;x         Suppress the first character&#xA;j         Go one line down&#xA;q         Stop recording&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then repeat your macro as many time as necessary with &lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;And with NERDCommenter:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Select your 52 lines with &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;52&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use the NERDCommenter mapping to uncomment your lines: &lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;u&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more details:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#blockwise%2Dvisual&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h blockwise-visual&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#recording&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h recording&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-11-21T16:00:21.763" LastActivityDate="2016-11-21T16:00:21.763" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10359" PostTypeId="2" ParentId="10356" CreationDate="2016-11-21T15:59:14.623" Score="3" Body="&lt;p&gt;So the problem here is to easily select the commented text. Vim doesn't have a built-in way to select a portion of commented text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possible solution is to create a new text object which will represent a chunck of commented code. To do so you can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Define it manually which can be a pretty laborious work if you're not used to vimscript (even if you are actually)&lt;/li&gt;&#xA;&lt;li&gt;Or you can use the plugin &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-user&lt;/a&gt; which allows the user to easily create new text objects. With the plugin you can install the &lt;a href=&quot;https://github.com/glts/vim-textobj-comment&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-comment&lt;/a&gt; plugin which uses vim-textobj-user to create the text object we need.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Once it is installed you can simply use &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt; to select the commented text and then use the NERDCommenter command &lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;u&lt;/kbd&gt; to uncomment your text.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-11-21T15:59:14.623" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10360" PostTypeId="1" AcceptedAnswerId="10362" CreationDate="2016-11-21T18:23:38.240" Score="5" ViewCount="1574" Body="&lt;p&gt;I have the following line in my .vimrc to open &lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDTree&lt;/a&gt; on startup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NERDTreeToggle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, if I start vim, I have NERDTree on the left and the file I opened on the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The left window is focused on startup. How can I put the focus on the right window on startup?&lt;/p&gt;&#xA;" OwnerUserId="6542" LastEditorUserId="6542" LastEditDate="2016-11-22T00:06:32.240" LastActivityDate="2016-11-22T00:06:32.240" Title="Define active window for startup in .vimrc" Tags="|vimrc|vim-windows|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10361" PostTypeId="2" ParentId="10357" CreationDate="2016-11-21T18:27:34.393" Score="10" Body="&lt;p&gt;I like the approaches statox suggested. Here's another one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;52:norm x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This only works if the &lt;code&gt;#&lt;/code&gt; is the first character on each line. Otherwise, I would do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;52:s/#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These two work very similarly. Essentially, what &lt;code&gt;&amp;lt;count&amp;gt;:&lt;/code&gt; is doing, is setting up a range so that the next ex command is applied to the next &lt;code&gt;&amp;lt;count&amp;gt;&lt;/code&gt; lines. &lt;code&gt;norm x&lt;/code&gt; means&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Press 'x' as if it was in normal mode&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;which would obviously remove the first character on that line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s/#&lt;/code&gt; is just shorthand for &lt;code&gt;:substitute/#//&lt;/code&gt; which will remove the first &lt;code&gt;#&lt;/code&gt; character on each line. &lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-11-21T18:27:34.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10362" PostTypeId="2" ParentId="10360" CreationDate="2016-11-21T18:33:15.167" Score="9" Body="&lt;p&gt;You can do this with a simple autocommand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au VimEnter * wincmd l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This tells vim anytime you open a new vim window (&lt;code&gt;VimEnter&lt;/code&gt;) on any file type &lt;code&gt;*&lt;/code&gt; to run the ex command &lt;code&gt;:wincmd l&lt;/code&gt;. &lt;code&gt;wincmd l&lt;/code&gt; is effectively the same thing as pressing &lt;code&gt;&amp;lt;C-w&amp;gt;l&lt;/code&gt; in normal mode, which moves you one split to the right. From &lt;code&gt;:h ctrl_w-l&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-W CTRL-L                   *CTRL-W_CTRL-L* *CTRL-W_l*&#xA;CTRL-W l    Move cursor to Nth window right of current one.  Uses the&#xA;        cursor position to select between alternatives.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-11-21T18:33:15.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10363" PostTypeId="1" CreationDate="2016-11-22T10:07:14.607" Score="1" ViewCount="483" Body="&lt;p&gt;The following screenshot displays the &lt;a href=&quot;https://github.com/vim-scripts/Sorcerer&quot; rel=&quot;nofollow noreferrer&quot;&gt;sorcerer&lt;/a&gt; colorscheme displayed in mintty  on cygwin windows with the following minttyrc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/otQXf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/otQXf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# CursorColour=191,191,191&#xA;# ForegroundColour=220,220,204&#xA;# BackgroundColour=63,63,63&#xA;Black=63,63,63&#xA;Red=112,80,80&#xA;Green=96,180,138&#xA;Yellow=223,175,143&#xA;Blue=80,96,112&#xA;Magenta=220,140,195&#xA;Cyan=140,208,211&#xA;White=220,220,204&#xA;BoldBlack=112,144,128&#xA;BoldRed=220,163,163&#xA;BoldGreen=195,191,159&#xA;BoldYellow=240,223,175&#xA;BoldBlue=148,191,243&#xA;BoldMagenta=236,147,211&#xA;BoldCyan=147,224,227&#xA;BoldWhite=255,255,255&#xA;BoldAsFont=-1&#xA;Locale=en_US&#xA;Charset=UTF-8&#xA;FontHeight=14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This looks good and correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I uncomment the first lines this and other colorschemes look bad:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/i9UKw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/i9UKw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CursorColour=191,191,191&#xA;ForegroundColour=220,220,204&#xA;BackgroundColour=63,63,63&#xA;Black=63,63,63&#xA;Red=112,80,80&#xA;Green=96,180,138&#xA;Yellow=223,175,143&#xA;Blue=80,96,112&#xA;Magenta=220,140,195&#xA;Cyan=140,208,211&#xA;White=220,220,204&#xA;BoldBlack=112,144,128&#xA;BoldRed=220,163,163&#xA;BoldGreen=195,191,159&#xA;BoldYellow=240,223,175&#xA;BoldBlue=148,191,243&#xA;BoldMagenta=236,147,211&#xA;BoldCyan=147,224,227&#xA;BoldWhite=255,255,255&#xA;BoldAsFont=-1&#xA;Locale=en_US&#xA;Charset=UTF-8&#xA;FontHeight=14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The same thing happens with the same vimrc on my ubuntu using terminator. If I unset its color options then some colorschemes improve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both machines share the same vimrc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co?&#xA;t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In terminal: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~ » echo $TERM&#xA;xterm-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to either disable their colors when vim is running or to use another workaround?&lt;/p&gt;&#xA;" OwnerUserId="10216" LastEditorUserId="1841" LastEditDate="2016-11-22T11:09:57.877" LastActivityDate="2016-11-22T11:09:57.877" Title="terminal color interferes with vim colors" Tags="|terminal|colorscheme|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10364" PostTypeId="2" ParentId="10062" CreationDate="2016-11-22T11:02:32.953" Score="4" Body="&lt;p&gt;It seems that there is no built-in way to do what I want. So I came up with this small chunk of code following @DjMcMayhem comment. It is not extensively tested but it seems to be working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First let's remap &lt;code&gt;@&lt;/code&gt; to call our custom function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; @ :&amp;lt;C-U&amp;gt;call MacroWithCount()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MacroWithCount()&#xA;    # Get the content of a register given by the user&#xA;    let registerContent = getreg(nr2char(getchar()))&#xA;    let macroCount = v:count1&#xA;&#xA;    for i in range(macroCount)&#xA;        execute &quot;normal! &quot; . registerContent&#xA;        let macroCount = macroCount - 1&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First we use &lt;code&gt;getreg()&lt;/code&gt; combined with &lt;code&gt;getchar()&lt;/code&gt; to get the content of a register given by the user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we create the &lt;code&gt;macroCount&lt;/code&gt; variable which will be the variable to use in the macro to get the current count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally we execute the macro and update &lt;code&gt;macroCount&lt;/code&gt; each time the macro has been executed once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if I record this macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qaa&amp;lt;C-r&amp;gt;=macroCount&amp;lt;CR&amp;gt; &amp;lt;Esc&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 12 11 10 9 8 7 6 5 4 3 2 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; that the function still needs a major improvement: it doesn't understand &lt;code&gt;@@&lt;/code&gt; as &lt;code&gt;execute the last executed macro&lt;/code&gt;. so far I haven't found a way to get the content of the last executed macro (I thought that it was what &lt;code&gt;v:register&lt;/code&gt; was for but it seems that I was wrong)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The related help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#v%3Acount1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h v:count1&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getchar%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getchar()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getreg%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getreg()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#v%3Aregister&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h v:register&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-11-22T11:02:32.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10365" PostTypeId="2" ParentId="8674" CreationDate="2016-11-22T11:09:31.740" Score="2" Body="&lt;p&gt;In &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-vim-lib&lt;/a&gt;, I provide a &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/on.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;lh#on#exit()&lt;/code&gt;&lt;/a&gt; function that permits to restore various things to their previous value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding options, in essence, it just registers (for later) a &lt;code&gt;exe 'let &amp;amp;opt='.&amp;amp;opt&lt;/code&gt;. I use it this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let cleanup = lh#on#exit()&#xA;      \.restore('&amp;amp;efm')&#xA;try&#xA;   ... change &amp;amp;efm here ...&#xA;   do stuff that may fail&#xA;finally&#xA;   call cleanup.finalize()&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We can register as many restorations as we wish. We can explicitly target a buffer local option with for instance: &lt;code&gt;l:&amp;amp;efm&lt;/code&gt;. However I'm not aware of any way to say: &quot;fall-back to the global option value&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the &lt;code&gt;finally&lt;/code&gt; clause is important. If any operation may fail, without it, the option won't be restored to end-user's setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't provided a way to restore any possible option -- see @MS.Kim's answer to see how we can obtain their list. Or we could listen the option changed event, or play with the old &lt;code&gt;c_CTRL-A_HOME&lt;/code&gt; trick (1). &#xA;But, honestly, I really don't see the point. When, locally (in a function), I change option values, I exactly know which options I'll tweak.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I can also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;restore plugin options (variables) that can be global or buffer local -&gt; &lt;code&gt;.restore_option(varname)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;register actions -&gt; &lt;code&gt;.register(':q')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;restore buffer local mapping (or undefine them) -&gt; &lt;code&gt;.restore_buffer_mapping('&amp;lt;c-y&amp;gt;', 'i')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(1) That I've factorized in lh-vim-lib (as usual) -&gt; &lt;code&gt;echo lh#command#matching_askvim('option', '')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Function: lh#command#matching_askvim(what, lead) {{{3&#xA;function! lh#command#matching_askvim(what, lead) abort&#xA;  let cleanup = lh#on#exit()&#xA;        \.register('delcom LHAskVimMatchingCompletion')&#xA;  try&#xA;    exe 'command! -complete='.a:what.' -nargs=* LHAskVimMatchingCompletion :echo &quot;&amp;lt;args&amp;gt;&quot;'&#xA;    silent! exe &quot;norm! :LHAskVimMatchingCompletion &quot;.a:lead.&quot;\&amp;lt;c-a&amp;gt;\&quot;\&amp;lt;home&amp;gt;let\ cmds=\&quot;\&amp;lt;cr&amp;gt;&quot;&#xA;    return split(cmds, ' ')[1:]&#xA;  finally&#xA;    call cleanup.finalize()&#xA;  endtry&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-11-22T11:19:49.770" LastActivityDate="2016-11-22T11:19:49.770" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10366" PostTypeId="1" CreationDate="2016-11-22T13:17:23.523" Score="1" ViewCount="357" Body="&lt;p&gt;I have a strange issue with &lt;code&gt;TypeScript&lt;/code&gt; or &lt;code&gt;.ts&lt;/code&gt; files in terminal vim. I tried opening it from &lt;code&gt;NERDTree&lt;/code&gt; or &lt;code&gt;Control+P&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It finds the file but for some strange reason after I hit the &lt;code&gt;Enter&lt;/code&gt; key from &lt;code&gt;Control P&lt;/code&gt; it doesn't open, I tried hitting &lt;code&gt;Enter&lt;/code&gt; multiple times it only adds lines to the status line at the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if I press &lt;code&gt;Ctrl + C&lt;/code&gt; it terminates and brings up the &lt;code&gt;.ts&lt;/code&gt; content. It only happened &lt;strong&gt;recently&lt;/strong&gt; but I don't know what I've done to cause this. It used to open fine, even though it took more than a second or two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OS: Mac OSX Sierra&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim in the terminal&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following plugins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vim-typescript&lt;/li&gt;&#xA;&lt;li&gt;tsuquyomi&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All I remember doing recently was &lt;code&gt;npm install -g typescript tsc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2129" LastEditorUserId="1841" LastEditDate="2016-11-22T13:44:49.633" LastActivityDate="2017-02-20T16:14:33.917" Title="Vim typescript files doesn't open first time" Tags="|terminal|filetype|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10367" PostTypeId="2" ParentId="10366" CreationDate="2016-11-22T14:33:47.883" Score="2" Body="&lt;p&gt;So following fronm @statox suggestion to a previous debug thread.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used the following command to trace my issue:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Ensure it wasn't something in my &lt;code&gt;.vimrc&lt;/code&gt;. FAILED - so it was my something in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the following command to trace the &lt;code&gt;.vimrc&lt;/code&gt; file&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Command&lt;/strong&gt;: &lt;code&gt;vim --noplugin -D&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;It detected error with the &lt;code&gt;Tsuquyomi&lt;/code&gt; plugin.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I don't know how I fixed bit but I re-downloaded the plugin and added the appropriate &lt;code&gt;ts&lt;/code&gt; checker. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;It seems to have fixed my current issue.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect it was me doing the &lt;code&gt;npm install -g typescript and tsc&lt;/code&gt; recently which would have overwritten something or add new binary.&lt;/p&gt;&#xA;" OwnerUserId="2129" LastActivityDate="2016-11-22T14:33:47.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10368" PostTypeId="1" AcceptedAnswerId="10369" CreationDate="2016-11-22T14:40:32.747" Score="36" ViewCount="17211" Body="&lt;p&gt;I would like to know if i could select some code in visual mode and &lt;code&gt;git add&lt;/code&gt; it ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked with fugitive.vim but i didn't find how to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible ? Or is there any other plugin to do it ?&lt;/p&gt;&#xA;" OwnerUserId="8935" LastEditorUserId="1841" LastEditDate="2016-11-22T15:02:03.833" LastActivityDate="2020-12-03T06:29:29.630" Title="Git Fugitive how to git add a visually selected chunk of code" Tags="|visual-mode|git|plugin-fugitive|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10369" PostTypeId="2" ParentId="10368" CreationDate="2016-11-22T15:29:41.840" Score="31" Body="&lt;p&gt;There might be other ways, but this approach lets you to do more than adding a chunk, which is why I tend to use it quite a lot.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Run &lt;code&gt;:Gdiff&lt;/code&gt; command. It will open a split with version of current file that's currently in the index to the left/top of the original window.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;While in original window (right or bottom one), perform visual selection of changes you'd like to &lt;code&gt;git add&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run &lt;code&gt;:diffput&lt;/code&gt; command, which can operate on a range. (&lt;code&gt;dp&lt;/code&gt; key doesn't work in Visual mode.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Close that second window saving changes to update file in the index. Here you can edit it the way you like before saving, it doesn't have to exactly match original or new version of the file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Mind that &lt;code&gt;:diffput&lt;/code&gt; might not always give you what you would expect depending on the structure of changes (especially if you're committing only part of contiguous block of changes). So don't forget to validate commit. In most practical situations it works fine though.&lt;/p&gt;&#xA;" OwnerUserId="860" LastActivityDate="2016-11-22T15:29:41.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10370" PostTypeId="2" ParentId="10368" CreationDate="2016-11-22T15:29:42.533" Score="13" Body="&lt;p&gt;&lt;a href=&quot;http://vimcasts.org/&quot; rel=&quot;noreferrer&quot;&gt;Vimcasts&lt;/a&gt; has a &lt;a href=&quot;http://vimcasts.org/blog/2011/05/the-fugitive-series/&quot; rel=&quot;noreferrer&quot;&gt;great series&lt;/a&gt; on &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;noreferrer&quot;&gt;Fugitive.vim&lt;/a&gt;. The episode &lt;a href=&quot;http://vimcasts.org/episodes/fugitive-vim-working-with-the-git-index/&quot; rel=&quot;noreferrer&quot;&gt;Fugitive.vim - working with the git index&lt;/a&gt; would be the the most helpful for your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:Gdiff&lt;/code&gt; to stage only portions of a file. Running &lt;code&gt;:Gdiff&lt;/code&gt; will show you the current file &quot;diff-ed&quot; with the stage/index. You can simply use Vim's diff commands (&lt;code&gt;dp&lt;/code&gt;, &lt;code&gt;do&lt;/code&gt;, &lt;code&gt;:diffput&lt;/code&gt;, and &lt;code&gt;:diffget&lt;/code&gt;) to move the hunk to the stage/index. Then you write the stage/index file like you would any other buffer, &lt;code&gt;:w&lt;/code&gt;/&lt;code&gt;:x&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="-1" LastEditDate="2019-03-13T09:11:37.657" LastActivityDate="2019-03-13T09:11:37.657" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10371" PostTypeId="1" AcceptedAnswerId="10387" CreationDate="2016-11-22T15:35:38.380" Score="1" ViewCount="694" Body="&lt;p&gt;I have a problem with Vim Autocompletion behavior for buffer names. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Target Soft/OS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using gVim without plugins on Windows 10&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I would like to do&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming we have a file tree like :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+---- a &#xA;+---- b&#xA;|     +---- c&#xA;|     +---- d&#xA;|     +---- e0&#xA;|     +---- e&#xA;|           +----f&#xA;|           +----g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I'm searching for a buffer name, here is the behavior I would like :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:b &amp;lt;Tab&amp;gt;&lt;/code&gt;   =&gt; List &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b/&lt;/code&gt; or every files in the cwd, not all buffers names if possible&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:b b&amp;lt;Tab&amp;gt;&lt;/code&gt;  =&gt; &lt;code&gt;:b b/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:b b/&amp;lt;Tab&amp;gt;&lt;/code&gt; =&gt; List &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;e0&lt;/code&gt;, &lt;code&gt;e/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:b a/e&amp;lt;Tab&amp;gt;&lt;/code&gt; =&gt; List &lt;code&gt;e0&lt;/code&gt;, &lt;code&gt;e/&lt;/code&gt; so I can chose the right path&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:b a/e/&amp;lt;Tab&amp;gt;&lt;/code&gt; =&gt; List &lt;code&gt;f/&lt;/code&gt;, &lt;code&gt;g/&lt;/code&gt;&#xA;and so on&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I have tried&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmode=longest:list, full&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I want to find the file &quot;Core/types.h&quot;, and I have the file &quot;Care/file.h&quot; :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:b C&amp;lt;Tab&amp;gt;&lt;/code&gt; =&gt; it prints every files when I would prefer to have only one level of information, like &lt;code&gt;Core/&lt;/code&gt; and &lt;code&gt;Care/&lt;/code&gt;, not &lt;code&gt;Core/types.h&lt;/code&gt; and &lt;code&gt;Care/files.h&lt;/code&gt;, but this is the less important issue&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:b Co&amp;lt;Tab&amp;gt;&lt;/code&gt; =&gt; &lt;code&gt;:b Core/&lt;/code&gt; (This is nice !)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:b Core/t&amp;lt;Tab&amp;gt;&lt;/code&gt; =&gt; does nothing ! (Why it's not taking &lt;code&gt;Core/t&lt;/code&gt; as a wildcard ?)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:b ty&lt;/code&gt; =&gt; &lt;code&gt;:b Core/types.h&lt;/code&gt;  (This is nice !)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Could it be because of the way I'm opening all my buffers ? I'm doing &lt;code&gt;gvim **/*&lt;/code&gt; to load all my source files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Basically the problem is that the autocompletion doesn't work after a directory, as &lt;code&gt;:b ty&amp;lt;Tab&amp;gt;&lt;/code&gt; works but not &lt;code&gt;:b Core/ty&amp;lt;Tab&amp;gt;&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope I was clear and a solution exist for this problem :)&lt;/p&gt;&#xA;" OwnerUserId="10222" LastEditorUserId="1841" LastEditDate="2016-11-22T16:48:44.897" LastActivityDate="2016-11-24T14:37:35.043" Title="Vim buffer name autocompletion not working after first directory" Tags="|autocompletion|gvim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10372" PostTypeId="1" AcceptedAnswerId="10466" CreationDate="2016-11-22T15:50:13.303" Score="1" ViewCount="915" Body="&lt;p&gt;I have set my &lt;code&gt;.vimrc&lt;/code&gt; to open NERDTree on startup and whenever I open vim at the default location (~) I get this warning prompt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NERDTree: Please wait, caching a large dir ... DONE (134 nodes cached).&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can immediately skip the message with ENTER. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know if I can set the trigger for the warning to something larger than &quot;134 nodes&quot;. Or how else I could suppress this annoying prompt?&lt;/p&gt;&#xA;" OwnerUserId="6542" LastEditorUserId="1841" LastEditDate="2016-11-22T16:50:10.300" LastActivityDate="2016-12-01T13:25:13.517" Title="Suppress warning in vim startup: NERDTree: Please wait, caching a large dir ... Press Enter" Tags="|vimrc|plugin-nerdtree|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10373" PostTypeId="2" ParentId="10371" CreationDate="2016-11-22T15:58:46.350" Score="3" Body="&lt;p&gt;I believe that &lt;code&gt;:b&lt;/code&gt; is only going to select from the buffers you have open. It sounds to me like you want the edit command: &lt;code&gt;:e&lt;/code&gt;. That should complete on directories and filenames.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are looking for a better way to browse your current open buffers try &lt;code&gt;:ls&lt;/code&gt;. It will list all open buffers making it easy to use &lt;code&gt;:b x&lt;/code&gt; to go to another. (&quot;x&quot; is a filename or buffer number)&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-11-22T18:42:34.740" LastActivityDate="2016-11-22T18:42:34.740" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10374" PostTypeId="1" AcceptedAnswerId="10431" CreationDate="2016-11-22T16:57:40.790" Score="3" ViewCount="287" Body="&lt;p&gt;I would like to compare&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;File1-v1.txt&lt;/code&gt; with &lt;code&gt;File1-v2.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;File2-v1.txt&lt;/code&gt; with &lt;code&gt;File2-v2.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;at the same time. I tried to create the following layout:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+------------------+------------------+&#xA;|                  |                  |&#xA;|   File1-v1.txt  &amp;lt;=&amp;gt;  File1-v2.txt   |  // scroll synchronized diff&#xA;|                  |                  |&#xA;+------------------+------------------+&#xA;|                  |                  |&#xA;|   File2-v1.txt  &amp;lt;=&amp;gt;  File2-v2.txt   |  // *another* scroll synchronized diff&#xA;|                  |                  |&#xA;+------------------+------------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I get is a 4-way diff, where all four buffers were scroll-synchronozed and compared. That's cool, but it's not what I want in my special case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure vim to show me two separate &quot;2-way diff sessions&quot; instead of the one 4-way diff?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS&lt;br&gt;&#xA;This would be particular useful when analysing Git history of two (or more) files.&lt;/p&gt;&#xA;" OwnerUserId="3230" LastEditorUserId="24" LastEditDate="2016-11-22T17:28:11.577" LastActivityDate="2016-11-28T15:29:14.610" Title="Two seperate diff sessions on one screen" Tags="|split|vimdiff|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10375" PostTypeId="2" ParentId="4056" CreationDate="2016-11-22T19:16:45.240" Score="6" Body="&lt;p&gt;another nice option, which is relevant also in other cases, is using &lt;code&gt;:only&lt;/code&gt; to close all other windows, including the preview:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:on[ly][!]&#xA;:{count}on[ly][!]&#xA;CTRL-W o                        *CTRL-W_o* *E445*&#xA;CTRL-W CTRL-O                   *CTRL-W_CTRL-O* *:on* *:only*&#xA;    Make the current window the only one on the screen. All other&#xA;    windows are closed. For {count} see |:quit|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3188" LastActivityDate="2016-11-22T19:16:45.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10376" PostTypeId="1" AcceptedAnswerId="10384" CreationDate="2016-11-22T19:23:07.230" Score="5" ViewCount="244" Body="&lt;p&gt;I've googled around but can't find anything about this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a case: when I navigate deep down through large blocks of code in (for example) python, it would be useful to see which method, function, or loop I am currently in, when the start is not on screen (because it runs off the top of the screen).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, consider such block of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def large_ugly_function():&#xA;    ... many lines of code ...&#xA;    for i in list_of_items:&#xA;        one_action(i)&#xA;        i.method()&#xA;        event_trigger()&#xA;        ... bla-bla-bla around 20-30 lines of code&#xA;        ... another for loop or function&#xA;        ... &amp;lt;current line&amp;gt;: screen goes down and I can't see the current line part of what loop &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I need to see something like header of current fold in &quot;sticky&quot; way: while I navigate through code deep down. It can be written in status line or somewhere else.&#xA;For this example for  in status-line it would be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;large_ugly_function-&amp;gt;[for i in list_of_items:]-&amp;gt;[another for loop or function]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anybody know how it can be achieved? Maybe some extensions? How it can be googled?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&#xA;Just wrote this question and found close to what I need but not fully:&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/13634826/vim-show-function-name-in-status-line&quot;&gt;https://stackoverflow.com/questions/13634826/vim-show-function-name-in-status-line&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want something closer to folding: so function or loop or other logical block of code&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 2&lt;/strong&gt;&#xA;Also close to this thing can be achieved with TagBar status line integration.&lt;/p&gt;&#xA;" OwnerUserId="10223" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-11-24T08:22:38.270" Title="Keep beginning of current fold on top of the screen" Tags="|indentation|folding|statusline|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="10378" PostTypeId="1" AcceptedAnswerId="10379" CreationDate="2016-11-23T04:44:35.150" Score="-1" ViewCount="47" Body="&lt;p&gt;I want to do substitution in a partial of a line.&lt;br&gt;&#xA;But when I type &lt;code&gt;:'&amp;lt;,'&amp;gt;s/xx/yy/g&lt;/code&gt;, it always do it in the whole line.&lt;br&gt;&#xA;How can I tell vim to do it in the exact selection area??&lt;/p&gt;&#xA;" OwnerUserId="1276" LastActivityDate="2016-11-23T04:56:00.827" Title="How to do substitution in the selected part of a line instead of the whole line?" Tags="|substitute|visual-mode|" AnswerCount="1" CommentCount="0" ClosedDate="2016-11-23T11:14:17.033" ContentLicense="CC BY-SA 3.0" />
  <row Id="10379" PostTypeId="2" ParentId="10378" CreationDate="2016-11-23T04:56:00.827" Score="1" Body="&lt;p&gt;Add &lt;code&gt;\%V&lt;/code&gt; to your search. From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5C%V&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\%V&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        */\%V*&#xA;\%V Match inside the Visual area.  When Visual mode has already been&#xA;    stopped match in the area that |gv| would reselect.&#xA;    This is a |/zero-width| match.  To make sure the whole pattern is&#xA;    inside the Visual area put it at the start and end of the pattern,&#xA;    e.g.: &amp;gt;&#xA;        /\%Vfoo.*bar\%V&#xA;&amp;lt;   Only works for the current buffer.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you want to do &lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%Vxx/yy/g&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-11-23T04:56:00.827" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10380" PostTypeId="2" ParentId="10374" CreationDate="2016-11-23T10:05:00.263" Score="1" Body="&lt;p&gt;I'd split the terminal, for instance in konsole: &lt;code&gt;Ctrl-Shift-)&lt;/code&gt;&#xA;Then in each terminal I'd make the corresponding diff.&lt;/p&gt;&#xA;" OwnerUserId="10237" LastActivityDate="2016-11-23T10:05:00.263" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10381" PostTypeId="2" ParentId="10332" CreationDate="2016-11-23T12:45:28.223" Score="3" Body="&lt;p&gt;There are two things to watch out for:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Make sure you're not using a keyboard layout with &amp;quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Dead_key&quot; rel=&quot;nofollow noreferrer&quot;&gt;dead keys&lt;/a&gt;&amp;quot;; i.e. does pressing a single &lt;code&gt;'&lt;/code&gt; or &lt;code&gt;&amp;quot;&lt;/code&gt; actually insert that character, or do you need to use &lt;code&gt;&amp;quot;&amp;lt;Space&amp;gt;&lt;/code&gt;? If it's the latter, your keyboard layout has dead keys, and you must use &lt;code&gt;ci&amp;quot;&amp;lt;Space&amp;gt;&lt;/code&gt; for Vim normal mode commands as well.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Make sure that the characters are actually &lt;code&gt;'&lt;/code&gt; (0x27) and &lt;code&gt;&amp;quot;&lt;/code&gt; (0x22) and not &lt;code&gt;“&lt;/code&gt; (U+201C or 0xe2 0x80 0x9c in UTF-8) or &lt;code&gt;‘&lt;/code&gt; (U+2018, 0xe2 0x80 0x98) or any other quote variant.&lt;/p&gt;&#xA;&lt;p&gt;Check it by using the &lt;code&gt;g8&lt;/code&gt; or &lt;code&gt;ga&lt;/code&gt; command, or for more information use the &lt;a href=&quot;https://github.com/chrisbra/unicode.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;unicode.vim&lt;/a&gt; plugin (also see &lt;a href=&quot;https://vi.stackexchange.com/q/555/51&quot;&gt;See the Unicode code point of the current character&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-11-23T12:45:28.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10382" PostTypeId="1" AcceptedAnswerId="10682" CreationDate="2016-11-23T15:44:18.907" Score="4" ViewCount="856" Body="&lt;p&gt;This has been plaguing me for a while now, but I've only just recently been able to come up with an MCVE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that when &lt;code&gt;autochdir&lt;/code&gt; is on and I use &lt;code&gt;:Explore&lt;/code&gt; to open netrw sometimes it will set the &lt;code&gt;buftype&lt;/code&gt; of the original buffer to &lt;code&gt;nofile&lt;/code&gt;. This is very annoying as if I come back to the buffer later and try to save it, I get the error &lt;code&gt;E382: Cannot write, 'buftype' option is set&lt;/code&gt;. I then have to &lt;code&gt;set buftype=&lt;/code&gt; to save. I know I'm not the only one who has &lt;a href=&quot;https://vi.stackexchange.com/questions/3671/buftype-nofile-when-switching-buffers-with-vexplore&quot;&gt;seen this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MCVE: &lt;code&gt;set autochdir&lt;/code&gt;. Open an already existing file and make an edit (don't save). Use &lt;code&gt;:Explore&lt;/code&gt; to open netrw. Close the netrw window. Use &lt;code&gt;:Explore&lt;/code&gt; to open netrw again. Return to the original file and note: &lt;code&gt;set buftype?&lt;/code&gt;. It should be set to &lt;code&gt;nofile&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vim 8.0.69 on Win7. It happens on both vim and Gvim. Can anyone else reproduce this, and do you have any suggestions on how to get it to stop? (Other than unsetting &lt;code&gt;autochdir&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-12-20T21:11:02.550" Title="Strange behavior between autochdir and netrw" Tags="|buffers|netrw|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10383" PostTypeId="1" AcceptedAnswerId="10400" CreationDate="2016-11-23T15:45:46.190" Score="5" ViewCount="109" Body="&lt;p&gt;I'm creating a session with &lt;code&gt;mksession&lt;/code&gt;, and when I restore the session, if the first tab was empty (&lt;code&gt;[No Name]&lt;/code&gt;), it's gone in the restored session. Other empty tabs are restored fine; it seems to only be the first tab that's lost. If there are multiple &amp;quot;leading&amp;quot; empty tabs, it's still only the first one that disappears.&lt;/p&gt;&#xA;&lt;p&gt;I'm using this with &lt;code&gt;vim -u NONE&lt;/code&gt; so there is zero config and no plugins, but I get the same behavior with my normal config. Affects versions 7.3 and 8.0.52.&lt;/p&gt;&#xA;&lt;p&gt;I'm using the default &lt;code&gt;sessionoptions&lt;/code&gt; in all cases: &lt;code&gt;blank,buffers,curdir,folds,options,tabpages,winsize&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Steps to reproduce:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;$ vim -u NONE&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabnew&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:e foo.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:w&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabnew&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:mksession&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:qa&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$ vim -u NONE -S Session.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The tabline now shows &lt;code&gt;foo.txt | [No Name]&lt;/code&gt;. Expected &lt;code&gt;[No Name] | foo.txt | [No Name]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is this a known issue? Is there a workaround?&lt;/p&gt;&#xA;" OwnerUserId="8233" LastEditorUserId="8233" LastEditDate="2020-09-01T09:36:31.007" LastActivityDate="2020-09-01T09:36:31.007" Title="Empty first tab lost when using sessions" Tags="|tabbed-user-interface|sessions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10384" PostTypeId="2" ParentId="10376" CreationDate="2016-11-23T17:20:39.923" Score="6" Body="&lt;p&gt;So following the idea I suggested in comments here is what I've come up with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First let's demonstrate it with a gif (I'm not sure why the cursor leaves this ugly mark):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oB9tB.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oB9tB.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Set the foldmethod to &lt;code&gt;indent&lt;/code&gt; because it works well with python. (But I guess using &lt;code&gt;marker&lt;/code&gt; or &lt;code&gt;manual&lt;/code&gt; would work too)&lt;/li&gt;&#xA;&lt;li&gt;Open a split which will contain the &quot;context information&quot; i.e. the beginning of the fold the cursor is currently on.&lt;/li&gt;&#xA;&lt;li&gt;Each time the cursor is moved, the upper split is updated to show the correct context information.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The code is in two parts, first the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PinFold()&#xA;    &quot; save current position&#xA;    let saveCursor =  getcurpos()&#xA;&#xA;    &quot; Go to upper split, open all folds and go to the same line as bottom split&#xA;    wincmd k&#xA;    normal! zR&#xA;    execute &quot;normal! &quot; . saveCursor[1] . &quot;G&quot;&#xA;    &quot; Go to the beginning of the fold and put the line top of the upper split&#xA;    normal! [zk&#xA;    normal! zt&#xA;&#xA;    &quot; Go back to bottom split and restore position&#xA;    wincmd j&#xA;    call setpos('.', saveCursor)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is pretty self-explained:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Save the position of the cursor&lt;/li&gt;&#xA;&lt;li&gt;Go on the upper split, at the same line as the bottom split&lt;/li&gt;&#xA;&lt;li&gt;Go to the beginning of the fold and put the line in the top of the split&lt;/li&gt;&#xA;&lt;li&gt;Go back to bottom split&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And to make it work automatically, an augroup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup pythonFold&#xA;    autocmd BufReadPre *.py setlocal foldmethod=indent&#xA;    autocmd BufReadPost *.py wincmd k | resize 3 | wincmd j&#xA;    autocmd CursorMovedI *.py call PinFold()&#xA;    autocmd CursorMoved *.py call PinFold()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will set the correct foldmethod and open the upper split when opening a new python buffer. And then each time the cursor is moved in normal or in insert mode, the previous function is called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; The while process can probably be improved (better handling of already open buffer, multiple splits in a tab, etc) but this is left as an exercise to the reader ;-)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Related help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#%3Aaugroup&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :augroup&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#%3Aautocmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :autocmd&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd%2Devents&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h autocmd-events&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getcurpos%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getcurpos()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Awincmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :wincmd&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/fold.txt.html#folding&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h folding&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/fold.txt.html#%5Bz&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h [z&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/scroll.txt.html#z.&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h z.&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-11-24T08:22:38.270" LastActivityDate="2016-11-24T08:22:38.270" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10385" PostTypeId="1" AcceptedAnswerId="10386" CreationDate="2016-11-24T00:08:38.093" Score="8" ViewCount="22723" Body="&lt;p&gt;Is there a command to find and replace all instances of a number in a file with 0 (including decimal numbers like &lt;code&gt;1.7&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="6499" LastEditorUserId="15" LastEditDate="2019-04-05T17:37:21.870" LastActivityDate="2019-04-05T17:37:21.870" Title="Find and replace all numbers with 0?" Tags="|substitute|number-formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10386" PostTypeId="2" ParentId="10385" CreationDate="2016-11-24T01:20:50.133" Score="13" Body="&lt;p&gt;Based on the help file, and the &lt;a href=&quot;http://vim.wikia.com/wiki/Search_and_replace&quot; rel=&quot;noreferrer&quot;&gt;Vim Wikia page on Search and replace&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/[0-9]\+\.[0-9]\+\|[0-9]\+/0/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s&lt;/code&gt; - start a command with the range of the entire file, &lt;code&gt;%&lt;/code&gt;, to substitute, the following patterns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[0-9]\+\.[0-9]\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This must come first, it's the pattern that covers decimals like 1.7. In addition it will only match a number followed by a period, without replacing the period. &lt;code&gt;[0-9]&lt;/code&gt; is the collection for any digit. The &lt;code&gt;\&lt;/code&gt; is required to escape the special characters, &lt;code&gt;+&lt;/code&gt;, which means match one or more occurrences. The &lt;code&gt;.&lt;/code&gt; needs to be escaped, so that it doesn't take on it's normal meaning of match any character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;|&lt;/code&gt; means or, as in match the first pattern or the second, and must be escaped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the pattern for any digit, one or more times, &lt;code&gt;[0-9]\+&lt;/code&gt; again. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/0/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, replace every occurrence of the pattern on the line with 0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;123&#xA;1.7&#xA;8&#xA;99&#xA;2.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0&#xA;0&#xA;0&#xA;0&#xA;0.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2016-11-24T01:20:50.133" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10387" PostTypeId="2" ParentId="10371" CreationDate="2016-11-24T14:37:35.043" Score="0" Body="&lt;p&gt;This is a bug from vim when using backslash on windows, it can be fixed by using &lt;code&gt;set shellslash&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've reported the bug, but setting shellslash is easy and sufficient enough for everyday use.&lt;/p&gt;&#xA;" OwnerUserId="10222" LastActivityDate="2016-11-24T14:37:35.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10388" PostTypeId="1" AcceptedAnswerId="10391" CreationDate="2016-11-24T14:42:18.090" Score="2" ViewCount="1117" Body="&lt;p&gt;I want &lt;code&gt;colocolumn&lt;/code&gt; to be 80 by default for all buffers, but if &lt;code&gt;textwidth&lt;/code&gt; is set (and not 0) for a buffer, then I want &lt;code&gt;colorcolumn&lt;/code&gt; to be &lt;code&gt;+0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this could be done by just setting &lt;code&gt;tw&lt;/code&gt; to 80 in my &lt;code&gt;.vimrc&lt;/code&gt; but I do not want a max line length because the auto line breaks can easily lead to syntax errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried using an autocmd to set the colorcolumn option whenever the &lt;code&gt;tw&lt;/code&gt; changes but the problem with this is that the &lt;code&gt;OptionSet&lt;/code&gt; event does not fire when vim starts up, so any &lt;code&gt;tw&lt;/code&gt; settings by some file-type plugin would not change the &lt;code&gt;colorcolumn&lt;/code&gt; setting.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! OptionSet textwidth call s:SetColorColumn()&#xA;function! s:SetColorColumn()&#xA;    if &amp;amp;textwidth == 0&#xA;        setlocal colorcolumn=80&#xA;    else&#xA;        setlocal colorcolumn=+0&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When using the &lt;code&gt;FileType&lt;/code&gt; event, the problem is similar. Although it fires on startup it fires when the &lt;code&gt;filetype&lt;/code&gt; is set but before the &lt;code&gt;ftplugin&lt;/code&gt; files were sourced so the &lt;code&gt;tw&lt;/code&gt; was not yet set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can accomplish this or will I just have to set &lt;code&gt;textwidth&lt;/code&gt; or just live with &lt;code&gt;colorcolumn&lt;/code&gt; being 80 all the time?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'm using vim 8.0.0086 from the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is the output of &lt;code&gt;vim --version&lt;/code&gt; (just in case):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 15 2016 18:04:06)&#xA;Included patches: 1-86&#xA;Compiled by Arch Linux&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     +tcl/dyn&#xA;+balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;+browse          -footer          +multi_byte      +terminfo&#xA;++builtin_terms  +fork()          +multi_lang      +termresponse&#xA;+byte_offset     +gettext         -mzscheme        +textobjects&#xA;+channel         -hangul_input    +netbeans_intg   +timers&#xA;+cindent         +iconv           +num64           +title&#xA;+clientserver    +insert_expand   +packages        +toolbar&#xA;+clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        +perl/dyn        +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       +python/dyn      +vreplace&#xA;+cscope          +lispindent      +python3/dyn     +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con_gui  +lua/dyn         +rightleft       +writebackup&#xA;+diff            +menu            +ruby/dyn        +X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;+dnd             +modify_fname    +signs           +xim&#xA;-ebcdic          +mouse           +smartindent     -xpm&#xA;+emacs_tags      +mouseshape      +startuptime     +xsmp_interact&#xA;+eval            +mouse_dec       +statusline      +xterm_clipboard&#xA;+ex_extra        +mouse_gpm       -sun_workshop    -xterm_save&#xA;+extra_search    -mouse_jsbterm   +syntax          &#xA;+farsi           +mouse_netterm   +tag_binary      &#xA;   system vimrc file: &quot;/etc/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;/etc/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lncurses -lelf -lnsl    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lieee -lm     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10246" LastActivityDate="2016-11-24T16:47:13.233" Title="Set colorcolumn to textwidth only when textwidth is set" Tags="|colorcolumn|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10389" PostTypeId="1" AcceptedAnswerId="10390" CreationDate="2016-11-24T14:54:56.937" Score="10" ViewCount="1214" Body="&lt;p&gt;&lt;code&gt;vim proj.dia&lt;/code&gt; gives binary data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If renamed, vim opens it by unzipping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ mv proj.dia proj.dia.gz&#xA;$ vim proj.dia.gz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to make the &lt;code&gt;.dia&lt;/code&gt; act the same as &lt;code&gt;.gz&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2727" LastEditorUserId="4472" LastEditDate="2017-06-08T22:45:40.557" LastActivityDate="2017-06-08T22:45:40.557" Title="How to open *.dia files as *.gz files?" Tags="|binary-file|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10390" PostTypeId="2" ParentId="10389" CreationDate="2016-11-24T16:31:35.013" Score="10" Body="&lt;p&gt;If we look at &lt;code&gt;/usr/share/vim/vim80/plugin/gzip.vim&lt;/code&gt; we can see how the plugin does this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup gzip&#xA;  &quot; Remove all gzip autocommands&#xA;  au!&#xA;&#xA;  &quot; Enable editing of gzipped files.&#xA;  &quot; The functions are defined in autoload/gzip.vim.&#xA;  &quot;&#xA;  &quot; Set binary mode before reading the file.&#xA;  &quot; Use &quot;gzip -d&quot;, gunzip isn't always available.&#xA;  autocmd BufReadPre,FileReadPre      *.gz,*.bz2,*.Z,*.lzma,*.xz,*.lz setlocal bin&#xA;  autocmd BufReadPost,FileReadPost    *.gz  call gzip#read(&quot;gzip -dn&quot;)&#xA;  autocmd BufWritePost,FileWritePost  *.gz  call gzip#write(&quot;gzip&quot;)&#xA;  autocmd FileAppendPre               *.gz  call gzip#appre(&quot;gzip -dn&quot;)&#xA;  autocmd FileAppendPost              *.gz  call gzip#write(&quot;gzip&quot;)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are other file extensions here as well (bzip2, xz, etc.) but I removed those for brevity's sake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To add your own commands to this, you can add this to your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup gzip_local&#xA;    autocmd!&#xA;    autocmd BufReadPre,FileReadPre     *.dia setlocal bin&#xA;    autocmd BufReadPost,FileReadPost   *.dia call gzip#read(&quot;gzip -dn -S .dia&quot;)&#xA;    autocmd BufWritePost,FileWritePost *.dia call gzip#write(&quot;gzip -S .dia&quot;)&#xA;    autocmd FileAppendPre              *.dia call gzip#appre(&quot;gzip -dn -S .dia&quot;)&#xA;    autocmd FileAppendPost             *.dia call gzip#write(&quot;gzip -S .dia&quot;)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We need to add the &lt;code&gt;-S .dia&lt;/code&gt; option to get &lt;code&gt;gzip&lt;/code&gt; to read and write to &lt;code&gt;*.dia&lt;/code&gt; files, rather than &lt;code&gt;*.gz&lt;/code&gt; files. As near as I can see most common platforms (Linux, {Free,Open}BSD, OSX) support this option, but some may not (in which case you'll have to write a wrapper script to move the file before decompressing and after compressing).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-11-24T16:37:06.453" LastActivityDate="2016-11-24T16:37:06.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10391" PostTypeId="2" ParentId="10388" CreationDate="2016-11-24T16:47:13.233" Score="4" Body="&lt;p&gt;You're on the right track, you just need to add the same function to the &lt;code&gt;BufEnter&lt;/code&gt; autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=0&#xA;&#xA;function! s:SetColorColumn()&#xA;    if &amp;amp;textwidth == 0&#xA;        setlocal colorcolumn=80&#xA;    else&#xA;        setlocal colorcolumn=+0&#xA;    endif&#xA;endfunction&#xA;&#xA;augroup colorcolumn&#xA;    autocmd!&#xA;    autocmd OptionSet textwidth call s:SetColorColumn()&#xA;    autocmd BufEnter * call s:SetColorColumn()&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#BufEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help BufEnter&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BufEnter                        After entering a buffer.  Useful for setting&#xA;                                options for a file type.  Also executed when&#xA;                                starting to edit a buffer, after the&#xA;                                BufReadPost autocommands.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-11-24T16:47:13.233" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10392" PostTypeId="2" ParentId="9676" CreationDate="2016-11-24T22:30:10.040" Score="1" Body="&lt;p&gt;After searching the help, one option is described at&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help put-Visual-mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this would require you to do the work of selecting what text gets replaced.  For many cases, this is quick, easy, and reliable, but your question specifically wants something to just replace exactly that many characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea is to write a function that calculates the length of what's in the unnamed register &quot;&quot; (which is always the last yank, unless you used the &quot;_ register to skip this rule), and first deletes that many characters (without modifying the unnamed register), and then does a put of &quot;&quot; into that spot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you treat a tab character as one character, we will use strwidth(). If you want the equivalent spaces, you should use strdisplaywidth() instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyReplace()&#xA;  let y=strwidth(@&quot;)&#xA;  exec &quot;normal \&quot;_&quot; . y . &quot;x&quot;&#xA;  exec &quot;normal P&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then bring your cursor to the right spot and&#xA;:call MyReplace()&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be replaced with a more convenient key combination through mapping or similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Limitations:  This doesn't work if you are trying to replace up to the end of the current line (or past it).&#xA;This is because of how the cursor moves after &quot;x&quot; if you just bump up against the last character.  An easy hack for this would be to add a dummy character to the end of the line first, then remove it after.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you are starting closer to the end of line than the # of characters in your buffer, you will replace some characters BEFORE The cursor, because of how x works.  If you wanted to delete newline characters just the same as normal characters, and you can find a version of the x command that deletes the next character no matter what, comment it here.&lt;/p&gt;&#xA;" OwnerUserId="10155" LastActivityDate="2016-11-24T22:30:10.040" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10393" PostTypeId="1" CreationDate="2016-11-24T22:40:15.857" Score="3" ViewCount="506" Body="&lt;p&gt;On large projects, there might be many definitions over many different files and folders for a given symbol.  Usually the one you want is the one that is unique to the local area you are working in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. if there is a &lt;code&gt;magic_answer()&lt;/code&gt; in &lt;code&gt;/proj/foo/bar/utils.c&lt;/code&gt; &#xA;and a &lt;code&gt;magic_answer()&lt;/code&gt; in &lt;code&gt;/proj/xyz/abc/utils.c&lt;/code&gt;&#xA;and you are editing a file in &lt;code&gt;/proj/xyz/def/&lt;/code&gt;&#xA;you probably want the definition under &lt;code&gt;/proj/xyz/...&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to use ctags, and created tags files in nested folders depending on which folders I worked on frequently.  I set up the &lt;code&gt;tags=&lt;/code&gt; variable in &lt;code&gt;.vimrc&lt;/code&gt; to try to find a tags file as deep in the directory structure that I was in as possible, and then working its way up to the top of the project if necessary, and this worked really well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to use cscope now, and it's not working as well.  I use the standard &lt;code&gt;cscope_maps.vim&lt;/code&gt; with minor changes.  So in my large project, I'm getting many many hits for some definitions.  I have to look through them all and visually select the one in the folder nearest to me, which is slow.  In some cases it's really even more obvious than my example above - I obviously want the one near me in the tree compared to having to go up 6 directory levels and descend again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to tell cscope or Vim to give me the one that is closer to me in the directory tree?&lt;/p&gt;&#xA;" OwnerUserId="10155" LastEditorUserId="5395" LastEditDate="2016-11-25T08:29:29.840" LastActivityDate="2016-11-25T08:29:29.840" Title="How to configure cscope to select the BEST definition" Tags="|ctags|cscope|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10394" PostTypeId="1" AcceptedAnswerId="10395" CreationDate="2016-11-25T08:16:57.550" Score="6" ViewCount="5761" Body="&lt;p&gt;I have a following line in one script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cp &quot;$uploaddir&quot;/&quot;$file&quot; &quot;$cvsdir&quot;/&quot;$device&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to search if this exact line is present elsewhere in the script. Usually I would do &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt; and then &lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;. However, this time the line contains forward slashes. I also tried to specify &quot;very nomagic&quot;(&lt;code&gt;\V&lt;/code&gt;) after the forward slash, but this didn't help. I could obviously do &lt;code&gt;/cp &quot;$uploaddir&quot;\/&quot;$file&quot; &quot;$cvsdir&quot;\/&quot;$device&quot;&lt;/code&gt;, but this is bit clunky. Is there a better way to search line from text which contains forward slashes without escaping each forward slash?&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2016-11-26T14:41:24.757" Title="search line which contains forward slashes" Tags="|search|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10395" PostTypeId="2" ParentId="10394" CreationDate="2016-11-25T08:26:58.210" Score="11" Body="&lt;p&gt;Use backward search &lt;code&gt;:h ?&lt;/code&gt;. This way you type &lt;code&gt;?&lt;/code&gt; instead of &lt;code&gt;/&lt;/code&gt; to start search, but this also allows to use &lt;code&gt;/&lt;/code&gt; in search pattern.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-11-25T08:26:58.210" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10396" PostTypeId="1" AcceptedAnswerId="10397" CreationDate="2016-11-25T10:07:53.637" Score="10" ViewCount="3327" Body="&lt;p&gt;Within a function, is there a way to determine if vim is in insert mode (or was in insert mode prior to calling the function)?&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2019-05-14T14:54:20.630" Title="Within a function, Is there a way to determine if vim is in insert mode?" Tags="|vimscript|insert-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10397" PostTypeId="2" ParentId="10396" CreationDate="2016-11-25T10:29:23.683" Score="10" Body="&lt;p&gt;&lt;em&gt;Something&lt;/em&gt; must have invoked your function. Setting the (new in Vim 8.0) asyncronous timers aside, this will be either&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a custom command, which cannot be invoked from insert mode, only command-line mode&lt;/li&gt;&#xA;&lt;li&gt;a mapping&lt;/li&gt;&#xA;&lt;li&gt;an &lt;code&gt;:autocmd&lt;/code&gt; event&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For the latter, you can split into two separate &lt;code&gt;:autocmd&lt;/code&gt;s, and pass an &lt;code&gt;isInsertMode&lt;/code&gt; flag into your function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorHold,CursorHoldI * call MyFunc()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;turns into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorHold  * call MyFunc(0)&#xA;autocmd CursorHoldI * call MyFunc(1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For mappings, you can pass a similar flag, or a character representing the mode (to also handle visual mode and so on):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;F2&amp;gt; :call MyFunc('n')&amp;lt;CR&amp;gt;&#xA;:vnoremap &amp;lt;F2&amp;gt; :&amp;lt;C-u&amp;gt;call MyFunc('v')&amp;lt;CR&amp;gt;&#xA;:inoremap &amp;lt;F2&amp;gt; &amp;lt;C-o&amp;gt;:call MyFunc('i')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is the canonical approach, and should work for most use cases. If you have a really special need, please elaborate in your question.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-11-25T10:29:23.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10398" PostTypeId="2" ParentId="10396" CreationDate="2016-11-25T10:30:23.940" Score="7" Body="&lt;p&gt;There is &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#mode()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;mode()&lt;/code&gt;&lt;/a&gt; function which can be used in some contexts (not thoroughly documented) with the following description:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mode([expr])    Return a string that indicates the current mode.&#xA;...&#xA;                  i       Insert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, when it works, check for insert mode in your function can look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if mode() == 'i'&#xA;    &quot; in insert mode&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="860" LastEditorUserId="860" LastEditDate="2016-11-25T11:32:44.453" LastActivityDate="2016-11-25T11:32:44.453" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10399" PostTypeId="2" ParentId="10394" CreationDate="2016-11-25T10:37:20.097" Score="1" Body="&lt;p&gt;You need to escape the forward slashes, too, not just the backslashes that are the only regular expression pieces requiring escaping when &lt;code&gt;\V&lt;/code&gt; is used. This can be done with the &lt;code&gt;escape()&lt;/code&gt; function, and inserting the register via the expression register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y$/&amp;lt;C-r&amp;gt;='\V' . escape(@@, '/\')&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's still an issue with newlines (that's why I used &lt;code&gt;y$&lt;/code&gt; instead of &lt;code&gt;yy&lt;/code&gt;), and the expression already is too long to type regularly. And it clobbers a register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why I would recommend to use one of several available &lt;strong&gt;plugin&lt;/strong&gt;s that implement such a &lt;strong&gt;literal search of the visual selection&lt;/strong&gt;. The &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2944&quot; rel=&quot;nofollow noreferrer&quot;&gt;visualstar plugin&lt;/a&gt; does this, and my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4320&quot; rel=&quot;nofollow noreferrer&quot;&gt;SearchHighlighting plugin&lt;/a&gt; includes such functionality as well. (The plugin page has links to additional alternative plugins.)&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-11-25T10:37:20.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10400" PostTypeId="2" ParentId="10383" CreationDate="2016-11-25T20:44:11.537" Score="3" Body="&lt;p&gt;This is indeed a bug in Vim. I filed a &lt;a href=&quot;https://github.com/vim/vim/issues/1282&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub issue&lt;/a&gt;, and someone on the vim-dev mailing list addressed it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a patch that fixes it in Vim 8.0.52:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diff --git a/src/ex_docmd.c b/src/ex_docmd.c&#xA;index 439467c..ca4133a 100644&#xA;--- a/src/ex_docmd.c&#xA;+++ b/src/ex_docmd.c&#xA;@@ -11091,6 +11091,8 @@ makeopens(&#xA;        }&#xA;        if (tabnr &amp;gt; 1)&#xA;        need_tabnew = TRUE;&#xA;+       else if (put_line(fd, &quot;new&quot;) == FAIL)&#xA;+       return FAIL;&#xA;    }&#xA;&#xA;    /*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Patch courtesy Hirohito Higashi on the vim-dev mailing list. I imagine it will make its way into the official distribution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This was fixed in Vim 8.1.0149 (see &lt;a href=&quot;https://github.com/vim/vim/pull/3152&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub PR&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="8233" LastEditorUserId="8233" LastEditDate="2018-08-22T20:59:51.550" LastActivityDate="2018-08-22T20:59:51.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10401" PostTypeId="2" ParentId="5536" CreationDate="2016-11-25T21:52:18.373" Score="1" Body="&lt;p&gt;The Num Keys are different (for normale mode):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;Esc&amp;gt;Oq 1&#xA;nmap &amp;lt;Esc&amp;gt;Or 2&#xA;nmap &amp;lt;Esc&amp;gt;Os 3&#xA;nmap &amp;lt;Esc&amp;gt;Ot 4&#xA;nmap &amp;lt;Esc&amp;gt;Ou 5&#xA;nmap &amp;lt;Esc&amp;gt;Ov 6&#xA;nmap &amp;lt;Esc&amp;gt;Ow 7&#xA;nmap &amp;lt;Esc&amp;gt;Ox 8&#xA;nmap &amp;lt;Esc&amp;gt;Oy 9&#xA;nmap &amp;lt;Esc&amp;gt;Op 0&#xA;nmap &amp;lt;Esc&amp;gt;On .&#xA;nmap &amp;lt;Esc&amp;gt;OQ /&#xA;nmap &amp;lt;Esc&amp;gt;OR *&#xA;nmap &amp;lt;Esc&amp;gt;Ol +&#xA;nmap &amp;lt;Esc&amp;gt;OS -&#xA;nmap &amp;lt;Esc&amp;gt;OM &amp;lt;Enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;inoremap&lt;/code&gt; for insert mode.&lt;/p&gt;&#xA;" OwnerUserId="9922" LastActivityDate="2016-11-25T21:52:18.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10402" PostTypeId="1" CreationDate="2016-11-26T02:34:47.577" Score="1" ViewCount="2366" Body="&lt;p&gt;I want to be editing a file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---------------&#xA;|             |&#xA;|             |&#xA;|    DOC      |&#xA;|             |&#xA;|             |&#xA;|             |&#xA;---------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then press &lt;kbd&gt;F5&lt;/kbd&gt; and open NERDTree and Tagbar like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---------------&#xA;|    |        |&#xA;|NERD|   DOC  |&#xA;|TREE|        |&#xA;|----|        |&#xA;|TAG |        |&#xA;| BAR|        |&#xA;---------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The commands I use to open NERDTree and Tagbar are &lt;code&gt;:NERDTreeTabsToggle&lt;/code&gt; and &lt;code&gt;:TagbarToggle&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this can't be done, then how can I just open tagbar below or above NERDTree?&lt;/p&gt;&#xA;" OwnerUserId="10260" LastEditorUserId="205" LastEditDate="2016-11-26T05:14:51.057" LastActivityDate="2016-12-11T12:30:15.327" Title="map a key to open Tagbar and NERDTree at the same time" Tags="|key-bindings|split|plugin-nerdtree|plugin-tagbar|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10403" PostTypeId="1" AcceptedAnswerId="10406" CreationDate="2016-11-26T08:09:06.663" Score="4" ViewCount="121" Body="&lt;p&gt;I want to paste particular date format (&lt;code&gt;mm--dd-yyyy&lt;/code&gt;) using following terminal command in ex command mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r !echo $(date +&quot;%d-%m-%Y&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Its print the current file name instead of printing date,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that I try another command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r date+&quot;%d-%m-%Y&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Its also failed , It returns following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;**/bin/bash: /tmp/vptQGvY/8: No such file or directory&#xA;shell returned 1&#xA;E485: Can't read file /tmp/vptQGvY/8&#xA;Press ENTER or type command to continue**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7834" LastEditorUserId="7834" LastEditDate="2016-11-28T07:16:28.187" LastActivityDate="2016-11-28T07:16:28.187" Title="How to get particular time format inside the text file" Tags="|ex-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10404" PostTypeId="1" AcceptedAnswerId="10405" CreationDate="2016-11-26T10:00:20.453" Score="5" ViewCount="648" Body="&lt;p&gt;Say, I defined a command in my &lt;code&gt;~/.bash_profile&lt;/code&gt;, (MacOS Sierra, Macbook Air, if it's relevant)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function sayHello(){&#xA;   echo Hello world!&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and while using vim, intend to call&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! sayHello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does not recognize, and tells me&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/bin/bash: sayHello: command not found&#xA;shell returned 127&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The actual situation is that I want compile something, so it would be handy to use external command. If not, then fine, I can open up another terminal, &lt;code&gt;cd&lt;/code&gt;-ed on the same directory.&lt;/p&gt;&#xA;" OwnerUserId="10241" LastActivityDate="2016-11-26T13:20:08.800" Title="Why doesn't vim recognize bash self-made functions" Tags="|external-command|bash|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10405" PostTypeId="2" ParentId="10404" CreationDate="2016-11-26T10:22:04.587" Score="5" Body="&lt;p&gt;External commands are not executed in an interactive shell so your &lt;code&gt;.bash_profile&lt;/code&gt; is not read. To make your custom command available you must turn it into an actual shell script, put it in your &lt;code&gt;$PATH&lt;/code&gt;, and make it executable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env bash&#xA;&#xA;echo &quot;Hello world!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But there's a much better way to &quot;compile something&quot;: &lt;code&gt;:help :make&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-11-26T13:20:08.800" LastActivityDate="2016-11-26T13:20:08.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10406" PostTypeId="2" ParentId="10403" CreationDate="2016-11-26T12:42:28.923" Score="6" Body="&lt;p&gt;This should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r !date +&quot;\%d-\%m-\%Y&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But preferred way to do this would be to use &lt;code&gt;strftime()&lt;/code&gt;. Here's a &lt;a href=&quot;http://vim.wikia.com/wiki/Insert_current_date_or_time&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt; for more info&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2016-11-27T19:53:30.243" LastActivityDate="2016-11-27T19:53:30.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10407" PostTypeId="1" AcceptedAnswerId="10426" CreationDate="2016-11-26T14:05:06.840" Score="5" ViewCount="2746" Body="&lt;p&gt;I would like Vim to stop highlighting matches when entering Insert mode. And not to highlight them again until a new search is performed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A first thought would be to add the following line to my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * nohlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But from &lt;code&gt;:help :nohlsearch&lt;/code&gt; we know that &lt;code&gt;nohlsearch&lt;/code&gt; does not work in automatic commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One alternative would be this line, which clears the last search pattern. Having nothing to match, Vim will have nothing to highlight.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * let @/ = &quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This stops the highlighting as intended. Nonetheless, it has side effects: because the last search pattern is cleared, commands such as &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;/&amp;lt;CR&amp;gt;&lt;/code&gt; will not behave as intended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is: how can one stop highlighting when entering Insert mode in an efficient way and with no major side effects or no side effects at all?&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="356" LastEditDate="2016-11-26T14:35:22.713" LastActivityDate="2023-02-12T05:24:22.097" Title="Stop highlighting when entering Insert mode" Tags="|insert-mode|autocmd|highlight|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10408" PostTypeId="2" ParentId="10394" CreationDate="2016-11-26T14:41:24.757" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;grep -F&lt;/code&gt; to search for literal fixed strings. If you run &lt;code&gt;grep&lt;/code&gt; from vim, the matching lines are placed in the quickfix list. You can use &lt;code&gt;:cnext&lt;/code&gt; and &lt;code&gt;:cprevious&lt;/code&gt; to navigate the results.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:gr -F 'cp &quot;$uploaddir&quot;/&quot;$file&quot; &quot;$cvsdir&quot;/&quot;$device&quot;' %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2674" LastActivityDate="2016-11-26T14:41:24.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10409" PostTypeId="1" CreationDate="2016-11-26T15:49:21.490" Score="1" ViewCount="116" Body="&lt;p&gt;Executing&lt;code&gt;:3,7y&lt;/code&gt; does not change the line which contains the cursor (&lt;code&gt;line('.')&lt;/code&gt;). This is what I expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I execute &lt;code&gt;:3,7call XYZ()&lt;/code&gt;, the current line goes to the third line. I didn't expect this behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is that? Can I change the behavior so that the current line does not change?&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2016-11-28T10:17:37.983" Title="Current line after :3,7call XYZ()" Tags="|command-line|range|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10410" PostTypeId="2" ParentId="10407" CreationDate="2016-11-26T21:04:16.887" Score="1" Body="&lt;p&gt;You can try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * setlocal nohlsearch&#xA;autocmd InsertLeave * setlocal hlsearch lz&#xA;inoremap &amp;lt;silent&amp;gt;&amp;lt;Esc&amp;gt; &amp;lt;Esc&amp;gt;:nohl&amp;lt;bar&amp;gt;set nolz&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;silent&amp;gt;&amp;lt;C-c&amp;gt; &amp;lt;C-c&amp;gt;:nohl&amp;lt;bar&amp;gt;set nolz&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I added &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27lazyredraw%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;lazyredraw&lt;/a&gt;, because I did not like the short blink of the highlighted areas, when leaving the Insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you could be probably interested in &lt;a href=&quot;https://github.com/haya14busa/incsearch.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;incsearch.vim&lt;/a&gt;, especially in this &lt;a href=&quot;https://github.com/haya14busa/incsearch.vim#automatic-nohlsearch&quot; rel=&quot;nofollow noreferrer&quot;&gt;part&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2961" LastEditorUserId="2961" LastEditDate="2016-11-27T13:25:57.250" LastActivityDate="2016-11-27T13:25:57.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10411" PostTypeId="1" AcceptedAnswerId="10414" CreationDate="2016-11-27T03:25:53.503" Score="3" ViewCount="945" Body="&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My development team decided to move to typescript and one of the style guidelines was to remove all semi-colons and they will probably do so in newer JavaScript files (I know its a bit petty) but yeah, that's what the team has decided.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, they don't use vim and I do because I love it. They don't fuss about what editors you use as long as you keep to the guidelines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Issues&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After years of programming and hitting &lt;code&gt;;&lt;/code&gt; at the end of each line, it's hard to break this habit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know if there is a nice way in vim to allow me to remove semicolons at the end of each line when I hit save?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I want to have a way to bind keys to trim all semicolons or when I hit &lt;code&gt;:wq&lt;/code&gt; to save a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there already a plugin that does this?&lt;/p&gt;&#xA;" OwnerUserId="2129" LastEditorUserId="2920" LastEditDate="2016-11-27T15:30:04.837" LastActivityDate="2016-11-27T15:30:04.837" Title="Is there a nice way to remove semicolon in files using Vim?" Tags="|key-bindings|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10412" PostTypeId="1" AcceptedAnswerId="10418" CreationDate="2016-11-27T05:33:16.123" Score="2" ViewCount="2069" Body="&lt;p&gt;How can I write a function to get the content between &lt;code&gt;mark 1&lt;/code&gt; and &lt;code&gt;mark 2&lt;/code&gt; for further processing? &lt;code&gt;mark&lt;/code&gt; can be a string, or a function call, it doesn't matter.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mark 1&#xA;&#xA;foo1&#xA;foo2&#xA;foo3&#xA;&#xA;mark 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10269" LastEditorUserId="1841" LastEditDate="2016-11-27T18:50:44.387" LastActivityDate="2024-01-14T11:07:10.850" Title="How to get the content between two specific lines in vimscript?" Tags="|vimscript|search|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10413" PostTypeId="2" ParentId="2010" CreationDate="2016-11-27T05:39:18.160" Score="0" Body="&lt;p&gt;I had this problem too with &lt;code&gt;xfce-terminal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a bit of research, I discovered &lt;a href=&quot;https://bugs.launchpad.net/xfce4-terminal/+bug/778801&quot; rel=&quot;nofollow noreferrer&quot;&gt;this bug&lt;/a&gt;: anything you set as &lt;code&gt;$TERM&lt;/code&gt; in your XFCE terminal is silently ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this is really a bug of the underlying (and unmaintained) &lt;a href=&quot;https://developer.gnome.org/vte/0.28/&quot; rel=&quot;nofollow noreferrer&quot;&gt;old VTE library&lt;/a&gt; that XFCE terminal (still GTK+2 based) uses. Switching to a GTK+3 terminal, that implicitely uses the &lt;a href=&quot;https://developer.gnome.org/vte/0.44/&quot; rel=&quot;nofollow noreferrer&quot;&gt;new VTE library&lt;/a&gt;, solved the issue.&lt;/p&gt;&#xA;" OwnerUserId="10270" LastActivityDate="2016-11-27T05:39:18.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10414" PostTypeId="2" ParentId="10411" CreationDate="2016-11-27T05:50:12.580" Score="7" Body="&lt;p&gt;Doing a search/replace on save is not too difficult, but ... is it also a good idea? Personally, I'm not a big fan of doing search-replace operations on save, as there almost always tend to be exceptions and unexpected behaviour. e.g. consider having a &lt;code&gt;;&lt;/code&gt; in a comment (possibly at the end of the line)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My recommendation is to just highlight semicolons as errors. You'll get out of the habit of adding them soon enough anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup typescript&#xA;    autocmd!&#xA;    autocmd FileType typescript&#xA;        \  syn match semicolonError /;$/ display&#xA;        \| hi def link semicolonError Error&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, if you prefer, you can put it in &lt;code&gt;~/.vim/after/syntax/typescript.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help syntax&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/a/8773/51&quot;&gt;this answer&lt;/a&gt; for more information on how syntax highlighting works.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you really want to search/replace them on save, you can use the answer in &lt;a href=&quot;https://vi.stackexchange.com/a/456/51&quot;&gt;What's the simplest way to strip trailing whitespace from all lines in a file?&lt;/a&gt; with a slightly different regexp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! TrimSemicolon()&#xA;    let l:save = winsaveview()&#xA;    %s/;$//e&#xA;    call winrestview(l:save)&#xA;endfun&#xA;&#xA;&quot; Automatically run on save&#xA;augroup typescript&#xA;    autocmd!&#xA;    autocmd BufWritePre * :call TrimSemicolon()&#xA;augroup end&#xA;&#xA;&quot; Map it to a key&#xA;nnorenamap &amp;lt;Leader&amp;gt;s call :TrimSemicolon()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See my other answer for a more detailed explanation. &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help autocmd.txt&lt;/code&gt;&lt;/a&gt; and the &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/12.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Autocommands chapter of Learn Vimscript the Hard Way&lt;/a&gt; are also recommended reading :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-11-27T05:50:12.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10415" PostTypeId="2" ParentId="10407" CreationDate="2016-11-27T06:06:18.217" Score="5" Body="&lt;p&gt;You could remap &lt;code&gt;i&lt;/code&gt; to run &lt;code&gt;:nohlsearch&lt;/code&gt; first and then &lt;code&gt;i&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap i :nohlsearch&amp;lt;CR&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll probably want to remap more than just &lt;code&gt;i&lt;/code&gt;. For all insert mode commands (from &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#inserting&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help inserting&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for s:c in ['a', 'A', '&amp;lt;Insert&amp;gt;', 'i', 'I', 'gI', 'gi', 'o', 'O']&#xA;    exe 'nnoremap ' . s:c . ' :nohlsearch&amp;lt;CR&amp;gt;' . s:c&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This won't cover &lt;code&gt;:startinsert&lt;/code&gt; though, but that isn't used a lot so that's probably okay.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-11-27T06:06:18.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10417" PostTypeId="2" ParentId="10409" CreationDate="2016-11-27T08:56:15.470" Score="1" Body="&lt;p&gt;One way to do this would be to pass current line as function argument. But &lt;code&gt;line('.')&lt;/code&gt; is evaluated for first line of range, thus this needs to be done earlier. My solution to this would be to use user command. Below complete sample code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function XYZ(curline) range&#xA;  [normal body]&#xA;  exe &quot;normal &quot; . a:curline . &quot;gg&quot;&#xA;endfunction&#xA;&#xA;command -range XYZ :let l=line('.') | &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call XYZ(l)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way you need to do &lt;code&gt;:3,7XYZ&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2016-11-27T19:47:31.617" LastActivityDate="2016-11-27T19:47:31.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10418" PostTypeId="2" ParentId="10412" CreationDate="2016-11-27T11:41:04.053" Score="4" Body="&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/builtin.txt.html#getbufline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getbufline()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;getbufline({expr}, {lnum} [, {end}])&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Return a List with the lines starting from {lnum} to {end}&#xA;(inclusive) in the buffer {expr}.  If {end} is omitted, a&#xA;List with only the line {lnum} is returned.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;To get the line numbers you're looking for you can use &lt;code&gt;:search()&lt;/code&gt; for example. See &lt;a href=&quot;https://vimhelp.org/builtin.txt.html#search%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h search()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For example in this file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mark 1&#xA;&#xA;foo1&#xA;foo2&#xA;foo3&#xA;&#xA;mark 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;echo getbufline(bufnr('%'), 1, 7)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Will return the following list:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;['mark 1', '', 'foo1', 'foo2', 'foo3', '', 'mark 2']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You might even want to wrap it in a function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! SearchForLines(pattern1, pattern2)&#xA;    let line1 = search(a:pattern1)&#xA;    let line2 = search(a:pattern2)&#xA;&#xA;    return getbufline(bufnr('%'), line1, line2)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This way to get the list of the lines between &lt;code&gt;mark 1&lt;/code&gt; and &lt;code&gt;mark 2&lt;/code&gt; you can simply do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:echo SearchForLines('mark 1', 'mark 2')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; Note that as @Christian Brabandt noted in the comments, the function &lt;code&gt;getline()&lt;/code&gt; can also be used and in some circumstances may be easier to use. See &lt;a href=&quot;https://vimhelp.org/builtin.txt.html#getline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getline()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="22549" LastEditDate="2024-01-14T11:07:10.850" LastActivityDate="2024-01-14T11:07:10.850" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10419" PostTypeId="2" ParentId="2877" CreationDate="2016-11-27T12:25:32.423" Score="5" Body="&lt;p&gt;No plugin required! You can run node with the shell command &lt;code&gt;:!&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run the entire file with &lt;code&gt;:!/usr/local/bin/node %&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run the current line with &lt;code&gt;:exec '!/usr/local/bin/node' '-e'  shellescape(getline('.'))&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9420" LastEditorUserId="9420" LastEditDate="2017-04-15T18:11:46.090" LastActivityDate="2017-04-15T18:11:46.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10420" PostTypeId="2" ParentId="2877" CreationDate="2016-11-27T14:49:48.927" Score="7" Body="&lt;p&gt;I think &lt;a href=&quot;https://github.com/metakirby5/codi.vim&quot; rel=&quot;noreferrer&quot;&gt;Codi&lt;/a&gt; is what you are looking for. It supports JavaScript and some other languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/q1FEY.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/q1FEY.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2016-11-27T14:49:48.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10421" PostTypeId="2" ParentId="10402" CreationDate="2016-11-27T15:19:18.960" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;|&lt;/code&gt;. See &lt;code&gt;:help :bar&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'|' can be used to separate commands, so you can give multiple commands in one line. If you want to use '|' in an argument, precede it with '\'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your case it would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;f5&amp;gt; :NERDTreeTabsToggle | :TagbarToggle&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="786" LastActivityDate="2016-11-27T15:19:18.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10422" PostTypeId="2" ParentId="10407" CreationDate="2016-11-27T18:20:50.947" Score="3" Body="&lt;p&gt;Here is how to do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * call EndHighlight()&#xA;&#xA;map n :call RepeatLastSearch()&amp;lt;CR&amp;gt;&#xA;&#xA;function EndHighlight()&#xA;    match&#xA;    let s:lastsearch = @/&#xA;    nohlsearch&#xA;    redraw&#xA;endfunction&#xA;&#xA;function RepeatLastSearch()&#xA;    exe &quot;match Search /&quot;.s:lastsearch.&quot;/&quot;&#xA;    call search(s:lastsearch, &quot;W&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will find that this solution removes search highlighting, even after leaving insert mode, and yet the &lt;code&gt;n&lt;/code&gt; command still behaves as expected, with highlighting returning if it is executed again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What this does is totally disable search highlighting, which is somewhat automated and can be difficult to work with. Match highlighting is far more customizable, and in this case, we've asked it to act just like search highlighting, except as it applies to insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because &lt;code&gt;hlsearch&lt;/code&gt; is turned off, &lt;code&gt;/&amp;lt;CR&amp;gt;&lt;/code&gt; navigates to the next match, but it doesn't highlight anymore. I don't know of a way to piggyback an autocommand when executing &lt;code&gt;/&amp;lt;CR&amp;gt;&lt;/code&gt; so that it calls RepeatLastSearch() and executes the match highlight instead. If there was a way to monitor the &lt;code&gt;@/&lt;/code&gt; register for changes, that would be one way to do it, but as far as I know, that isn't possible. Any direct mapping of &lt;code&gt;/&lt;/code&gt; would of course screw up your normal search functionality, assuming Vim allows the mapping (I haven't tried it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I tried to think of a way to call RepeatLastSearch silently, but I don't know of one. That would make it a little nicer when using the mapping for &lt;code&gt;n&lt;/code&gt; (the user doesn't have to see the plumbing command underneath the mapping show up on the screen).&lt;/p&gt;&#xA;" OwnerUserId="10168" LastEditorUserId="10168" LastEditDate="2016-11-27T21:11:26.630" LastActivityDate="2016-11-27T21:11:26.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10423" PostTypeId="1" AcceptedAnswerId="10424" CreationDate="2016-11-27T23:57:17.777" Score="2" ViewCount="279" Body="&lt;p&gt;When editing email, I have &quot;hard wrap&quot; enabled most of the time. However, I sometimes want to turn it off (or back on), which I do with the following commands in &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; turn off&#xA;command HardWrapOff :set formatoptions-=t&#xA;&quot; turn on&#xA;command HardWrapOn :set formatoptions+=t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to use a single command to toggle it depending on the current state?&lt;/p&gt;&#xA;" OwnerUserId="1278" LastActivityDate="2016-11-28T00:11:29.603" Title="Can I toggle formatoptions?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10424" PostTypeId="2" ParentId="10423" CreationDate="2016-11-28T00:06:00.073" Score="4" Body="&lt;p&gt;There's no builtin way of doing this that I'm aware of, but you could use a conditional like so:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;command HardWrapToggle if &amp;amp;fo =~ 't' | set fo-=t | else | set fo+=t | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastEditorUserId="88" LastEditDate="2016-11-28T00:11:29.603" LastActivityDate="2016-11-28T00:11:29.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10425" PostTypeId="2" ParentId="10409" CreationDate="2016-11-28T10:17:37.983" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3800&quot; rel=&quot;nofollow noreferrer&quot;&gt;anwolib plugin&lt;/a&gt; provides (among others) a &lt;code&gt;:KeepView&lt;/code&gt; command. With it, you can wrap any other command invocation, and it will maintain the current position in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:KeepView 3,7call XYZ()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-11-28T10:17:37.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10426" PostTypeId="2" ParentId="10407" CreationDate="2016-11-28T10:25:43.020" Score="5" Body="&lt;p&gt;You can use &lt;code&gt;feedkeys()&lt;/code&gt; to execute &lt;code&gt;:nohlsearch&lt;/code&gt;. A small challenge is to avoid the recursion, as the &lt;code&gt;:call&lt;/code&gt; temporarily leaves (and then re-enters) insert mode. I've used a simple boolean flag for that here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let didit = 0&#xA;autocmd! InsertEnter * if ! didit | call feedkeys(&quot;\&amp;lt;C-\&amp;gt;\&amp;lt;C-o&amp;gt;:nohlsearch|let didit = 1\&amp;lt;CR&amp;gt;&quot;, 'n') | endif&#xA;autocmd! InsertLeave * let didit = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-11-28T10:25:43.020" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10427" PostTypeId="1" CreationDate="2016-11-28T10:56:54.663" Score="16" ViewCount="6461" Body="&lt;p&gt;I'm a NeoVim user and would like to be able to collaborate in real time with users, preferably also across other editors. Are there any open source plugins that enable remote Neovim←→Neovim pair programming?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware of &lt;a href=&quot;https://floobits.com/&quot; rel=&quot;noreferrer&quot;&gt;Floobits&lt;/a&gt; which is a proprietary system that includes plugins for various editors including NeoVim, but the server component is closed source and not an option for my projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, if there was a way to join other editors into the mix that would be ideal. The closest Open Source alternative I've run across is the MIT licensed &lt;a href=&quot;https://firepad.io/#1&quot; rel=&quot;noreferrer&quot;&gt;Firepad&lt;/a&gt; which uses a Firebase backend to synchronize edits between users. There is a &lt;a href=&quot;https://github.com/Fankserver/atom-firepad&quot; rel=&quot;noreferrer&quot;&gt;plugin for Atom&lt;/a&gt; which seems to enable those guys to work on the same file in real time but I don't see any plugins for NeoVim users like myself to join the party.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Any vim plugin interfacing with the &lt;a href=&quot;https://github.com/atom/teletype-client&quot; rel=&quot;noreferrer&quot;&gt;teletype-client&lt;/a&gt; so team up with &lt;a href=&quot;https://teletype.atom.io/&quot; rel=&quot;noreferrer&quot;&gt;Atom's Teletype&lt;/a&gt; system would be of particular interest!&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="91" LastEditDate="2020-05-07T08:06:52.903" LastActivityDate="2021-08-31T06:38:07.907" Title="Remote pair programming in NeoVim?" Tags="|neovim|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10428" PostTypeId="1" AcceptedAnswerId="10429" CreationDate="2016-11-28T11:05:33.580" Score="1" ViewCount="104" Body="&lt;p&gt;Under &lt;code&gt;:help [range]&lt;/code&gt; it states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Some Ex commands accept a line range in front of them.  This is noted as&#xA;  [range].  It consists of one or more line specifiers, separated with ',' or&#xA;  ';'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I am wondering if there is actually a command that takes more than two line specifiers. I can think of at most two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to use more than two line specifiers, all but the final two seem to be disregarded:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:8,10,20,11,5,9,13 #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;lists lines 9 through 13.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there actually a scenario when using more than two line specifiers are useful?&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2016-11-28T13:01:19.800" Title="Using more than two line specifiers in an ex-range" Tags="|ex-command|range|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10429" PostTypeId="2" ParentId="10428" CreationDate="2016-11-28T11:19:58.793" Score="2" Body="&lt;p&gt;Almost right below your quote from documentation it also says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When separated with ';' the cursor position will be set to that line&#xA;  before interpreting the next line specifier.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So while there seems to be no commands that are able to accept more than two specifiers, they still can be useful to adjust starting position of other specifiers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider a buffer like this with cursor positioned on the first line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a1&#xA;b1&#xA;a2&#xA;b2&#xA;a1'&#xA;b2'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/2/,/a/,/1/ #&lt;/code&gt; finds this reversed range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b1 # &amp;lt;-- match of /1/&#xA;a2 # &amp;lt;-- match of /a/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but &lt;code&gt;/2/;/a/,/1/ #&lt;/code&gt; outputs&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a1' # &amp;lt;-- match of both /1/ and /b/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;because &lt;code&gt;/2/;&lt;/code&gt; moved the cursor to the third line (&lt;code&gt;a2&lt;/code&gt;) before running two other searches.&lt;/p&gt;&#xA;" OwnerUserId="860" LastActivityDate="2016-11-28T11:19:58.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10430" PostTypeId="2" ParentId="10428" CreationDate="2016-11-28T11:20:15.093" Score="2" Body="&lt;p&gt;In the following range, the offset is calculated from &quot;the current line&quot; which may or may not be a match for &lt;code&gt;/foo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/foo/,+23#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;;&lt;/code&gt; to make the first line matching &lt;code&gt;foo&lt;/code&gt; the first line specifier of your range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/foo/;.,+23#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which gives you three &lt;em&gt;line&lt;/em&gt; specifiers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use more semicolons to refine your range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/foo/;/bar/;/baz/#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-11-28T13:01:19.800" LastActivityDate="2016-11-28T13:01:19.800" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10431" PostTypeId="2" ParentId="10374" CreationDate="2016-11-28T15:29:14.610" Score="1" Body="&lt;p&gt;You can use tabpages to view different sets of diffs, as diff are local to the current tab page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h diff.txt&#xA;:h tabpage&#xA;:h gt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2016-11-28T15:29:14.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10432" PostTypeId="1" AcceptedAnswerId="10440" CreationDate="2016-11-28T21:41:51.520" Score="2" ViewCount="1200" Body="&lt;p&gt;I have found this very useful function to turn on and off relative number lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NumberToggle()&#xA;  if(&amp;amp;relativenumber == 1)&#xA;    set number&#xA;  else&#xA;    set relativenumber&#xA;  endif&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it doesn't work, when I launch it&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call NumberToggle()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I see no changes, even when I close and reopen vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The source of the function is &lt;a href=&quot;http://jeffkreeftmeijer.com/2012/relative-line-numbers-in-vim-for-super-fast-movement/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; with other useful related tricks.&lt;/p&gt;&#xA;" OwnerUserId="6854" LastActivityDate="2016-11-29T17:24:41.153" Title="Why this function to change relative number in lines is not working?" Tags="|line-numbers|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10433" PostTypeId="2" ParentId="10432" CreationDate="2016-11-28T21:47:18.493" Score="7" Body="&lt;p&gt;Why won't you use Vim's builtin feature to toggle that? Just use: &lt;code&gt;set relativenumber!&lt;/code&gt; - this will cycle between on and off.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-11-28T21:47:18.493" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10434" PostTypeId="1" CreationDate="2016-11-28T22:34:59.360" Score="1" ViewCount="2025" Body="&lt;h2&gt;Background&lt;/h2&gt;&#xA;&lt;p&gt;I've been using Linux for years now and my daily driver is Debian Jessie. I have been using vim for about 2 years but my vim skills are sub-optimal (I still really only use the basics).&lt;/p&gt;&#xA;&lt;p&gt;I've decided that I want to improve my vim usage and I recently read a suggestion that before you start with anything too advanced, get to know the vimtutor inside out (complete it daily for at least a week).&lt;/p&gt;&#xA;&lt;p&gt;However vim tutor doesn't work. I recall this issue when I first started with vim and just manually copied the tutor file. My guess is that it's to do with something I &amp;quot;configured&amp;quot; before I knew what I was doing. But I'd like to fix it now if I'm going to be doing it daily.&lt;/p&gt;&#xA;&lt;h2&gt;The Problem&lt;/h2&gt;&#xA;&lt;p&gt;Here's the error I get (within vim) when I run &lt;code&gt;vimtutor&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;$VIMRUNTIME/tutor/tutor.vim&amp;quot; [New DIRECTORY]&#xA;Error detected while processing command line:&#xA;E471: Argument required&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Pressing enter just leaves me editing an empty file. If I try to quit out of that (&lt;code&gt;:q&lt;/code&gt;) I get:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;nocp&amp;quot; [New File]&#xA;--- Options ---&#xA;noloadplugins         scroll=16&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Again enter leaves me in an empty file. Quit again gives me:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;E173: 1 more file to edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And quit a 3rd time takes me back to the command line...!?&lt;/p&gt;&#xA;&lt;h2&gt;What I've tried:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;checking out ln 471 of &lt;code&gt;/usr/share/vim/vim74/tutor/tutor.vim&lt;/code&gt;:&#xA;only goes to line 200 so the offending line must be somewhere else?!&lt;/li&gt;&#xA;&lt;li&gt;reinstalling vim &amp;amp; vim-gtk (&lt;code&gt;apt-get install --reinstall vim vim-gtk&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;purging &lt;code&gt;vim-tiny&lt;/code&gt; (it wasn't installed).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Further info&lt;/h2&gt;&#xA;&lt;p&gt;The last few lines of the vimtutor script (&lt;code&gt;/usr/bin/vimtutor&lt;/code&gt;) are:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Use Vim to copy the tutor, it knows the value of $VIMRUNTIME&#xA;# The script tutor.vim tells Vim which file to copy&#xA;$VIM -f -u NONE -c 'so $VIMRUNTIME/tutor/tutor.vim'&#xA;&#xA;# Start vim without any .vimrc, set 'nocompatible'&#xA;$VIM -f -u NONE -c &amp;quot;set nocp&amp;quot; $TUTORCOPY&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10289" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-11-29T21:12:07.477" Title="vimtutor not working as expected - how to fix?" Tags="|linux-debian|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10435" PostTypeId="1" AcceptedAnswerId="10437" CreationDate="2016-11-28T23:30:41.807" Score="31" ViewCount="7388" Body="&lt;p&gt;Let's say that I have a code like this (&lt;em&gt;&lt;code&gt;|&lt;/code&gt; represents the cursor position&lt;/em&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func1(x|, func2(), y); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func1(x|);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to &lt;em&gt;delete the code from the position of the cursor to the position preceding the right end of the current inner block&lt;/em&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can go with &lt;code&gt;dt).&lt;/code&gt; but I wonder if there is a way to mix it with what &lt;code&gt;di)&lt;/code&gt; does.&lt;/p&gt;&#xA;" OwnerUserId="6043" LastActivityDate="2016-11-30T09:34:50.300" Title="Delete until the right end of the current inner block" Tags="|cursor-movement|cursor-motions|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10436" PostTypeId="2" ParentId="10435" CreationDate="2016-11-29T05:14:47.810" Score="4" Body="&lt;p&gt;For this specific case I would &lt;code&gt;dfy&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the general case:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;dT(&lt;/code&gt; delete from the cursor to the start of the block&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vib&lt;/code&gt; select the rest of the inner block&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt;  replace the inner block with what you just deleted&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could make it into a mapping.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :map K dt(vibp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2674" LastActivityDate="2016-11-29T05:14:47.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10437" PostTypeId="2" ParentId="10435" CreationDate="2016-11-29T05:24:13.883" Score="45" Body="&lt;p&gt;I would use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which means delete (&lt;code&gt;d&lt;/code&gt;) to the next unmatched ')' (&lt;code&gt;])&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%5D%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help ])&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2961" LastActivityDate="2016-11-29T05:24:13.883" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10438" PostTypeId="2" ParentId="10434" CreationDate="2016-11-29T05:34:28.103" Score="2" Body="&lt;p&gt;As noted as a comment, the problem was that I had a &lt;code&gt;/usr/local/bin/vim&lt;/code&gt; script which was calling vim without quoting the arguments. So as pointed out by @garyjohn the bash expanded &lt;code&gt;$VIMRUNTIME&lt;/code&gt; would have been empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Random local vim script removed and all is now well.&lt;/p&gt;&#xA;" OwnerUserId="10289" LastEditorUserId="10289" LastEditDate="2016-11-29T21:12:07.477" LastActivityDate="2016-11-29T21:12:07.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10439" PostTypeId="2" ParentId="10435" CreationDate="2016-11-29T06:58:34.010" Score="5" Body="&lt;p&gt;Motions go &lt;em&gt;only&lt;/em&gt; in one direction while text-objects go &lt;em&gt;only&lt;/em&gt; in two directions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that you can't have half of a text-object unless you create a custom operator pending motion that uses that text-object under the hood or mimics its behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your example, the text covered by &lt;code&gt;i)&lt;/code&gt; is pretty easy to visualize:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func1(x, func2(), y);&#xA;      ^^^^^^^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but how would you tell Vim to operate from the cursor to the end of that text? One would need to create custom operators like &lt;code&gt;obi)&lt;/code&gt; and &lt;code&gt;oei)&lt;/code&gt; (semi-random examples).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ()&#xA;onoremap oei) :normal! vi)o``&amp;lt;CR&amp;gt;&#xA;onoremap obi) :normal! vi)``&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; []&#xA;onoremap oei] :normal! vi]o``&amp;lt;CR&amp;gt;&#xA;onoremap obi] :normal! vi]``&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; {}&#xA;onoremap oei} :normal! vi}o``&amp;lt;CR&amp;gt;&#xA;onoremap obi} :normal! vi}``&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; &quot;&quot;&#xA;onoremap oei&quot; :normal! vi&quot;o``&amp;lt;CR&amp;gt;&#xA;onoremap obi&quot; :normal! vi&quot;``&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; ''&#xA;onoremap oei&quot; :normal! vi'o``&amp;lt;CR&amp;gt;&#xA;onoremap obi&quot; :normal! vi'``&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-11-29T12:21:44.803" LastActivityDate="2016-11-29T12:21:44.803" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10440" PostTypeId="2" ParentId="10432" CreationDate="2016-11-29T14:14:01.633" Score="4" Body="&lt;p&gt;The intention of the function as described in the blog post is &lt;em&gt;not&lt;/em&gt; to toggle &lt;code&gt;relativenumber&lt;/code&gt; but to switch between the &lt;code&gt;number&lt;/code&gt; and &lt;code&gt;relativenumber&lt;/code&gt; settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim 7.3, the &lt;code&gt;number&lt;/code&gt; and &lt;code&gt;relativenumber&lt;/code&gt; settings could not be used at the same time, and I believe setting one automatically unset the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as of Vim 7.4, you can enable both settings at the same time. Doing so will use the absolute line number for the current line, and relative line numbers for all other lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't wish to do this, and do in fact want to switch between using relative line numbers everywhere or absolute line numbers everywhere, you can amend the function accordingly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NumberToggle()&#xA;  if(&amp;amp;relativenumber == 1)&#xA;    set number&#xA;    set norelativenumber&#xA;  else&#xA;    set nonumber&#xA;    set relativenumber&#xA;  endif&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could just leave &lt;code&gt;number&lt;/code&gt; on at all times, and just toggle &lt;code&gt;relativenumber&lt;/code&gt;, which, as &lt;a href=&quot;https://vi.stackexchange.com/a/10433/343&quot;&gt;grodzik has explained&lt;/a&gt;, you can do with a simple: &lt;code&gt;set relativenumber!&lt;/code&gt;. This will switch between displaying absolute line numbers everywhere, and displaying it only on the current line (with relative numbers elsewere).&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-11-29T17:24:41.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10441" PostTypeId="2" ParentId="7899" CreationDate="2016-11-29T16:01:42.603" Score="0" Body="&lt;p&gt;In &lt;code&gt;:help i_ctrl-n&lt;/code&gt; it shows that Vim uses the &lt;code&gt;complete&lt;/code&gt; option to complete words. The help on &lt;code&gt;complete&lt;/code&gt; goes on to show that the only real option to use something that is not local to the Vim instance is to use a dictionary file. The question then boils down to generating such a dictionary file using all vim instances. You could do this by parsing all open files every now and then. I have no idea of the impact this would have on performance though. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option would be to use an entirely different mechanic (ctags etc) but this might break functionality elsewhere as these were not really intended for simple autocompletion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a more general note, you could also change your workflow a bit to stick more to the way Vim was envisioned to be used. This would mean using one or a few windows to look at stuff simultaneously and switch buffers often. A plugin that does the switching part very nicely is ctrlP. After activating it by pressing a button it allows you to do a fuzzy search for files in various places, thereby allowing quick switching. As long as you remember the filename that is.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastEditorUserId="5395" LastEditDate="2017-04-28T19:34:05.060" LastActivityDate="2017-04-28T19:34:05.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10442" PostTypeId="2" ParentId="10435" CreationDate="2016-11-29T21:32:04.937" Score="3" Body="&lt;p&gt;The other existing answers are all dependent on vim's definition and detection of a block. My strategy for this kind of deletions is to use the &lt;code&gt;c&lt;/code&gt; command combined with with the &lt;code&gt;f&lt;/code&gt; motion and the actual character to stop at. This will then actually delete the stop character, but since it also was the last key you pressed repeating it twice has next to zero cost, and that will insert it again since &lt;code&gt;c&lt;/code&gt; changes to insert mode.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To explain with examples, for&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func1(x|, func2(), y); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the command &lt;code&gt;c2f))&lt;/code&gt; will give&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func1(x)|;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which might at first seem less elegant than some of the other answers, however notice that this strategy is &lt;strong&gt;universal&lt;/strong&gt; and does not depend on any block definition.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For instance with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div| class=&quot;some-class&quot;&amp;gt;text&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the command &lt;code&gt;cf&amp;gt;&amp;gt;&lt;/code&gt; will give&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;|text&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Or when editing csv files like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2016-11-29,question,vi|.stackexchange.com,10435&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the command &lt;code&gt;cf,,&lt;/code&gt; will give&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2016-11-29,question,vi,|10435&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Often I use this to delete the rest of a string, from &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf(&quot;Hello world| - a boring example\n&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf(&quot;Hello world\|n&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;code&gt;cf\\&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or from &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print(&quot;Hello world| - a boring example&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print(&quot;Hello world&quot;|);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;code&gt;cf&quot;&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This does change the current position to a slightly different place than asked for, and also changes into insert mode. But I wanted to share my go-to-solution for deleting the rest of anything.&lt;/p&gt;&#xA;" OwnerUserId="843" LastActivityDate="2016-11-29T21:32:04.937" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10443" PostTypeId="1" CreationDate="2016-11-29T22:57:38.780" Score="3" ViewCount="263" Body="&lt;p&gt;Is it possible to change the back-gound color of the gutter for the function that I am working on?  I keep loosing my place, but it would be awesome to highlight a section like below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OzMEN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OzMEN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3050" LastActivityDate="2016-11-30T14:21:18.383" Title="Hightlight Gutter of Function Being Edited" Tags="|colorscheme|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10444" PostTypeId="2" ParentId="10443" CreationDate="2016-11-29T23:29:47.217" Score="2" Body="&lt;p&gt;I don't know of a way to highlight the gutter (and the fact that the only highlight groups for that region are &lt;code&gt;LineNr&lt;/code&gt; and &lt;code&gt;CursorLineNr&lt;/code&gt; makes me think that's not possible), but you could use &lt;code&gt;:match&lt;/code&gt; the given function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight WorkInProgress ctermbg=DarkGray&#xA;:match WorkInProgress /^TEST_F(CborEncoder, write32bit_uint) {\_.\{-}\n}/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you're done, you can use &lt;code&gt;:match none&lt;/code&gt; to clear it.&lt;/p&gt;&#xA;" OwnerUserId="361" LastEditorUserId="361" LastEditDate="2016-11-29T23:39:23.003" LastActivityDate="2016-11-29T23:39:23.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10445" PostTypeId="1" AcceptedAnswerId="10446" CreationDate="2016-11-30T01:20:59.113" Score="0" ViewCount="148" Body="&lt;p&gt;I have &lt;code&gt;au BufNewFile *.cpp 0r /Users/&amp;lt;my_username&amp;gt;/.vim/template/cpp.template&lt;/code&gt; in my .vimrc which was such that every .cpp file I created would have the template from the cpp.template file. But now for some reason it has stopped working. My .vimrc is short too, so I'm hoping someone could figure that out?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set cul&#xA;filetype off&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'bling/vim-airline'&#xA;Plugin 'vim-syntastic/syntastic'&#xA;Plugin 'jiangmiao/auto-pairs'&#xA;Plugin 'bogado/file-line'&#xA;Plugin 'scrooloose/nerdcommenter'&#xA;&#xA;call vundle#end()&#xA;&#xA;set laststatus=2 &quot;for airline&#xA;filetype plugin indent on &quot;all kinds of indentation&#xA;syntax enable &quot;syntax higlighting&#xA;set mouse=a &quot;mouse as cursor too&#xA;set backspace=indent,eol,start &quot;backspacing on empty lines&#xA;set nu &quot;number lines&#xA;set ignorecase &quot; ignore case when searching&#xA;set smartcase &quot; ignore case if search pattern is all lowercase&#xA;&#xA;&quot;Tabs&#xA;set expandtab &quot;for use in vim insert mode&#xA;set tabstop=4 &quot;tab = 4 columns&#xA;set shiftwidth=4 &quot;for use with &amp;gt;&amp;gt; or &amp;lt;&amp;lt; operators&#xA;set softtabstop=4 &quot;weird stuff&#xA;&#xA;&quot;Moving cursor to other windows with shift up/down/right/left&#xA;nnoremap &amp;lt;s-down&amp;gt; &amp;lt;c-w&amp;gt;w&#xA;nnoremap &amp;lt;s-up&amp;gt; &amp;lt;c-w&amp;gt;W&#xA;nnoremap &amp;lt;s-right&amp;gt; &amp;lt;c-w&amp;gt;h&#xA;nnoremap &amp;lt;s-left&amp;gt; &amp;lt;c-w&amp;gt;l&#xA;&#xA;&quot;For the Solarized theme in Vim&#xA;set background=dark&#xA;colorscheme solarized&#xA;&#xA;&quot;For Syntastic&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;&quot;&#xA;&quot;For Syntastic again&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;let g:syntastic_cpp_compiler = &quot;g++&quot;&#xA;&#xA;&quot;Add any future templates here&#xA;au BufNewFile *.cpp 0r /Users/&amp;lt;my_username&amp;gt;/.vim/template/cpp.template&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: Okay I managed to find out that &lt;code&gt;bogado/file-line&lt;/code&gt; was the reason the template wasn't working. Any clue of why?&lt;/p&gt;&#xA;" OwnerUserId="10312" LastEditorUserId="10312" LastEditDate="2016-11-30T01:43:38.810" LastActivityDate="2016-11-30T08:47:28.323" Title="Predetermined template for every file of an extension ceased working" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10446" PostTypeId="2" ParentId="10445" CreationDate="2016-11-30T07:34:18.023" Score="1" Body="&lt;p&gt;EDIT: I though that it was likely that this plugin incorrectly registers autocommands, as you did or starts with an un-scoped &lt;code&gt;:au !&lt;/code&gt;. Indeed &lt;code&gt;:au!&lt;/code&gt; clears all autocommands in the context of the current group. If there are none, it'll clear everything in the global unnamed context. As you haven't defined your autocommand in a group, it means it's global, and that unscoped use of &lt;code&gt;:au!&lt;/code&gt; will remove it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, after reading the plugin code, I indeed see registration of unscoped autocommands, but I see none is cleared. However &lt;code&gt;nested&lt;/code&gt; autocommands are used. I don't know why it conflicted with your declaration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The good practice is to always register autocommands in autocommand groups. This should prevent name conflicts&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aug SomeGroupWithAnUniqueName&#xA;  au!&#xA;  au whatever you wish&#xA;aug END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-11-30T08:47:28.323" LastActivityDate="2016-11-30T08:47:28.323" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10447" PostTypeId="2" ParentId="10435" CreationDate="2016-11-30T09:34:50.300" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/tommcdo/vim-ninja-feet&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-ninja-feet&lt;/a&gt; plugin might be what you're looking for. From what I understand, it makes &lt;code&gt;d[&lt;/code&gt; and &lt;code&gt;d]&lt;/code&gt; into &quot;delete from cursor to start/end of text object&quot;, so &lt;code&gt;d]i)&lt;/code&gt; should be &quot;delete until end of surrounding parentheses&quot;.&lt;/p&gt;&#xA;" OwnerUserId="10315" LastActivityDate="2016-11-30T09:34:50.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10448" PostTypeId="2" ParentId="10443" CreationDate="2016-11-30T10:52:43.110" Score="2" Body="&lt;p&gt;I was really surprised by the existence of &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27signcolumn%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;SignColumn&lt;/code&gt;&lt;/a&gt;, so I decided to use it in this strange way. The whole function is not highlighted &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;if a change in a text, call SetSign() function&#xA;au TextChanged,TextChangedI * :cal SetSign()&#xA;&#xA;function! SetSign()&#xA;   &quot;remove signs &#xA;   sign unplace *&#xA;   &quot;define a sign&#xA;   sign define lastMod text=* texthl=Search&#xA;   &quot;place a sign&#xA;   exe &quot;:sign place 1 line=&quot; . line(&quot;'.&quot;) . &quot; name=lastMod file=&quot; . expand(&quot;%:p&quot;)&#xA;endfunction&#xA;&#xA;&quot;remove the signs manually&#xA;nnoremap &amp;lt;leader&amp;gt;u :sign unplace *&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but at least the last changed line in code is highlighted at the side. If you want to remove the sign, just press &lt;code&gt;&amp;lt;leader&amp;gt;+u&lt;/code&gt; in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nevertheless, this solution is not so great, so it is probably better to use &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%60.&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;`.&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#g%3B&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g;&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#g%2C&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g,&lt;/code&gt;&lt;/a&gt;, or &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#gi&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;gi&lt;/code&gt;&lt;/a&gt; to get to the position where the last change was made (and which I presumed was the position of the function you working on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read more in &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h motion.txt&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/sign.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h sign.txt&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2961" LastActivityDate="2016-11-30T10:52:43.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10449" PostTypeId="2" ParentId="10443" CreationDate="2016-11-30T10:53:42.650" Score="5" Body="&lt;p&gt;One could (ab)use &lt;code&gt;:help sign&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; define an highlight group&#xA;highlight CurrentBlock ctermbg=red ctermfg=red cterm=NONE&#xA;&#xA;&quot; define a sign&#xA;sign define currentblock text=&amp;gt;&amp;gt; texthl=CurrentBlock&#xA;&#xA;&quot; place the signs&#xA;for range(30, 40)&#xA;    execute &quot;sign place &quot; . i . &quot; line=&quot; . i . &quot; name=currentblock file=&quot; . expand(&quot;%:p&quot;)&#xA;endfor&#xA;&#xA;&quot; remove the signs&#xA;for range(30, 40)&#xA;    execute &quot;sign unplace&quot; . i&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and wrap all that in a &lt;code&gt;CursorMoved&lt;/code&gt; autocommand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hardest part being to actually determine where the current block starts and ends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VXS0X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VXS0X.png&quot; alt=&quot;signs&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="54" LastEditDate="2016-11-30T10:55:45.853" LastActivityDate="2016-11-30T10:55:45.853" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10450" PostTypeId="1" AcceptedAnswerId="10451" CreationDate="2016-11-30T11:09:17.980" Score="3" ViewCount="166" Body="&lt;p&gt;Suppose I want to get from this &lt;code&gt;a,b&lt;/code&gt; to this &lt;code&gt;'a','b'&lt;/code&gt;&#xA;Yeah, yeah, yeah, I know about surround plugin. The cursor is on the start of line&#xA;I'm doing &lt;code&gt;cw&amp;lt;bsp&amp;gt;'&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt;. I have delimitMate plugin, so this would end in &lt;code&gt;'a',b&lt;/code&gt;.&#xA;Now all I need is to repeat the same action on b. But if I'll do that I'll end up with &lt;code&gt;'a','a'&lt;/code&gt;.&#xA;Can't find anything on this in docs. Is this a bug?&lt;/p&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2020-06-22T16:56:05.703" Title="Repeat works reuses unnamed register. Bug or a feature?" Tags="|register|repeated-commands|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10451" PostTypeId="2" ParentId="10450" CreationDate="2016-11-30T12:36:15.860" Score="3" Body="&lt;p&gt;There are 4 ways to insert the contents of a register.&lt;/p&gt;&#xA;&lt;p&gt;The first one is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;C-r {register name}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This inserts the contents of the register, and replaces the control characters inside.&lt;br /&gt;&#xA;For example, if the register &lt;code&gt;&amp;quot;a&lt;/code&gt; contains the string &lt;code&gt;ab^Hc&lt;/code&gt; (&lt;code&gt;^H&lt;/code&gt; is the caret notation for a backspace), and you type &lt;code&gt;C-r a&lt;/code&gt;, &lt;code&gt;ac&lt;/code&gt; will be inserted; that's because the backspace is interpreted as a command and deletes the previous character, which here is &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The contents of the dot register is also replaced with what was actually inserted. Here &lt;code&gt;ac&lt;/code&gt;. So, there's a double replacement. One for the control characters, and another for the dot register.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The second one is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;C-r C-r {register name}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This time, the contents of the register is inserted literally. With the previous register, hitting &lt;code&gt;C-r C-r a&lt;/code&gt; would insert &lt;code&gt;ab^Hc&lt;/code&gt;. The dot register is still replaced with whatever was inserted. So, here you have a single replacement, the one of the dot register.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The third one is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;C-r C-o {register name}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This time, nothing is replaced. Neither the control characters, nor the dot register.&lt;/p&gt;&#xA;&lt;p&gt;In your case, I think you want to use the third variant: &lt;code&gt;C-r C-o&lt;/code&gt;, so that the dot register contains the keys typed during the last insertion, and not the contents which was inserted.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eXfiK.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eXfiK.gif&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The fourth one is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;C-r C-p {register name}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;According to the help, the difference between &lt;code&gt;C-r C-p&lt;/code&gt; and &lt;code&gt;C-r C-o&lt;/code&gt; is that the latter doesn't auto-indent, whereas the former fixes the indent.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If you think you will use &lt;code&gt;C-r C-o&lt;/code&gt; more often than &lt;code&gt;C-r&lt;/code&gt;, to save a keystroke, you could invert the default mappings, by adding in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ino &amp;lt;C-r&amp;gt;      &amp;lt;C-r&amp;gt;&amp;lt;C-o&amp;gt;&#xA;ino &amp;lt;C-r&amp;gt;&amp;lt;C-o&amp;gt; &amp;lt;C-r&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="17449" LastEditDate="2020-06-22T16:56:05.703" LastActivityDate="2020-06-22T16:56:05.703" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10452" PostTypeId="1" CreationDate="2016-11-30T13:40:32.890" Score="2" ViewCount="3140" Body="&lt;p&gt;I have only one plugin at the moment (CtrlP) and I don't want to polute my environment with additional stuff that I'll have to depend on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I tried installing NERDTree directly (cloned from git in &lt;code&gt;.vim/bundle&lt;/code&gt;), but I get error after error, for example I added:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * NERDTree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;code&gt;.vimrc&lt;/code&gt; and I got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing VimEnter Auto commands for &quot;*&quot;:&#xA;E492: Not an editor command: NERDTree`.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I gave up at the end and now I'm using the simple &lt;code&gt;:edit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is - can I manually install NERDTree - or any plugin at all - directly?&lt;/p&gt;&#xA;" OwnerUserId="10319" LastEditorUserId="51" LastEditDate="2016-12-05T12:36:01.773" LastActivityDate="2016-12-05T12:36:01.773" Title="How can I install NERDTree without pathogen?" Tags="|vimrc|plugin-system|plugin-nerdtree|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10453" PostTypeId="2" ParentId="10443" CreationDate="2016-11-30T14:21:18.383" Score="3" Body="&lt;p&gt;You can use my &lt;a href=&quot;https://github.com/chrisbra/DynamicSigns&quot; rel=&quot;nofollow noreferrer&quot;&gt;DynamicSigns&lt;/a&gt; plugin like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, define after what rules to higlight the gutter. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! CustomSignExpression(lnum)&#xA;    if a:lnum &amp;lt; line('w0') || a:lnum &amp;gt; line ('w$')&#xA;        return 0&#xA;    endif&#xA;    if !exists(&quot;#CustomSignExpression#CursorMoved&quot;)&#xA;        augroup CustomSignExpression&#xA;            au!&#xA;            au VimResized,CursorMoved * :unlet! s:min s:max | :UpdateSigns&#xA;        augroup end&#xA;    endif&#xA;    if !exists(&quot;s:min&quot;)&#xA;        let s:min=search('^{', 'bn')&#xA;        let s:max=search('^}', 'n')&#xA;    endif&#xA;    if a:lnum &amp;lt; s:min || a:lnum &amp;gt; s:max&#xA;        return 0&#xA;    else&#xA;        return 'Gutter2'&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function is a slight adjustment, to what is documented in the help at &lt;code&gt;:h :SignExpression&lt;/code&gt;. You most likely want to adjust the search patterns, e.g. according to your screenshot you probably want something like &lt;code&gt;^\w\+(.*)\s*{&lt;/code&gt; as the search pattern for the start of a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can use &lt;code&gt;:SignExpression CustomSignExpression(v:lnum)&lt;/code&gt; and it should highlight your gutter column with red. If you want a different highlighting, Adjust the 'Gutter' line inside the function. See the help at  &lt;code&gt;:h Signs-Highlight&lt;/code&gt; for what is predefined and how you can change that.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-11-30T14:21:18.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10454" PostTypeId="1" CreationDate="2016-11-30T16:07:24.530" Score="5" ViewCount="2088" Body="&lt;p&gt;Does anyone know a way to highlight only comments in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Requirements:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For any colour scheme.&lt;/li&gt;&#xA;&lt;li&gt;Without having to clear and re-add only the comment syntax group in each language's ftplugin.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I suppose I want something that loops over the syntax groups and removes them if it doesn't equal &quot;Comment&quot;. Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="10321" LastActivityDate="2017-01-25T16:41:05.060" Title="Only highlight comments" Tags="|syntax-highlighting|" AnswerCount="3" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10455" PostTypeId="2" ParentId="10454" CreationDate="2016-11-30T16:25:27.453" Score="1" Body="&lt;p&gt;Not sure exactly what you mean by highlight, but a simple approach would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi clear Comment&#xA;hi link Comment Search&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes it so that whatever the color scheme, it highlights comments the same way it would highlight a search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could put this in a function and bind it to a key if you didn't want to &lt;em&gt;always&lt;/em&gt; have comments like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a function that toggles between hilighted and regular comments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:origComment = ''&#xA;&quot; Save away the original Comment&#xA;redir =&amp;gt;&amp;gt; g:origComment&#xA;silent hi Comment&#xA;redir END&#xA;&quot; Strip out the part we want&#xA;let g:origComment = matchstr(g:origComment, '\(\_.*Comment.*xxx\s*\)\@&amp;lt;=.*')&#xA;&#xA;let g:commentsHighlighted = 0&#xA;function ToggleCommentHilight()&#xA;   if g:commentsHighlighted&#xA;      hi clear Comment&#xA;      exe &quot;hi Comment &quot; . g:origComment&#xA;      let g:commentsHighlighted = 0&#xA;   else&#xA;      hi clear Comment&#xA;      hi link Comment Search&#xA;      let g:commentsHighlighted = 1&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-11-30T16:50:40.327" LastActivityDate="2016-11-30T16:50:40.327" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10456" PostTypeId="2" ParentId="10454" CreationDate="2016-11-30T16:50:26.690" Score="3" Body="&lt;p&gt;Something like this perhaps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! ClearSyntax()&#xA;    let syn=split(execute('syn list'), &quot;\n&quot;)[1:]&#xA;    call filter(syn, {idx, val -&amp;gt; match(val, '^\w') &amp;gt; -1})&#xA;    call map(syn, {idx, val -&amp;gt; split(val)[0]})&#xA;    for item in syn&#xA;        if match(item, '\c\mcomment') == -1&#xA;            try&#xA;                exe 'syn clear' item&#xA;                &quot; ignore E28 (no such highlight group)&#xA;            catch /^Vim\%((\a\+)\)\=:E28/&#xA;            endtry&#xA;        endif&#xA;    endfor&#xA;endfu&#xA;&#xA;com! ClearSyntaxExceptComments :call ClearSyntax()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This loops over the currently defined syntax items and undefines them, if they do not match &lt;code&gt;comment&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: only barely tested and needs Vim8&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-11-30T16:50:26.690" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10457" PostTypeId="1" AcceptedAnswerId="10469" CreationDate="2016-11-30T18:57:55.143" Score="0" ViewCount="110" Body="&lt;p&gt;Taken from here: &lt;a href=&quot;https://stackoverflow.com/a/171558&quot;&gt;https://stackoverflow.com/a/171558&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does &lt;code&gt;let g:clipbrdDefaultReg = '+'&lt;/code&gt; mean?&lt;/p&gt;&#xA;" OwnerUserId="10325" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-12-01T16:57:14.847" Title="What is clipbrdDefaultReg" Tags="|linux|os-clipboard|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10458" PostTypeId="1" AcceptedAnswerId="10459" CreationDate="2016-11-30T23:49:28.357" Score="3" ViewCount="1483" Body="&lt;p&gt;As a simple example, let's say I want to show the line number only when &lt;code&gt;:spell&lt;/code&gt; is set. I would assume the following would work, but does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%{&amp;amp;spell ? %l : &quot;&quot;}&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1039" LastActivityDate="2016-12-01T02:30:36.643" Title="How do I conditionally add items to the statusline?" Tags="|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10459" PostTypeId="2" ParentId="10458" CreationDate="2016-12-01T01:38:09.673" Score="8" Body="&lt;p&gt;There are 2 ways to change the value of an option, with the &lt;code&gt;:set&lt;/code&gt; or &lt;code&gt;:let&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set myoption=myvalue&#xA;:setlocal mylocaloption=mylocalvalue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let &amp;amp;myoption = 'myvalue'&#xA;:let &amp;amp;l:mylocaloption = 'mylocalvalue'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;When you use the &lt;code&gt;:set&lt;/code&gt; command, the value you assign to the option can contain characters which have a special meaning on the command-line. To avoid errors, you should tell Vim they are regular characters, by escaping them. Among these special characters, there are &lt;code&gt;&quot;&lt;/code&gt; (beginning of a comment), and &lt;code&gt;Space&lt;/code&gt; (separation between 2 option names).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get back to your issue, you want to display the current line number. I don't think you can use the item &lt;code&gt;%l&lt;/code&gt; inside the curly braces, because inside them Vim expects an expression, and &lt;code&gt;%l&lt;/code&gt; is not an expression.&#xA;However, it can be retrieved with the &lt;code&gt;line()&lt;/code&gt; function: &lt;code&gt;line('.')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to show the current line number in the status line, only when &lt;code&gt;'spell'&lt;/code&gt; is enabled, you could write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set stl+=%{&amp;amp;spell\ ?\ line(\&quot;.\&quot;)\ :\ \&quot;\&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the backslashes make the expression difficult to read, so you could avoid using spaces and double quotes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set stl+=%{&amp;amp;spell?line('.'):''}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can use the &lt;code&gt;:let&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;stl .= '%{&amp;amp;spell ? line(&quot;.&quot;) : &quot;&quot;}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This time, you don't need to escape anything. But to add this value to the &lt;code&gt;'statusline'&lt;/code&gt; option, you have to use the &lt;code&gt;.=&lt;/code&gt; operator instead of &lt;code&gt;+=&lt;/code&gt;, because you're concatenating strings.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As your last &lt;a href=&quot;https://vi.stackexchange.com/questions/10458/how-do-i-conditionally-add-items-to-the-statusline#comment18396_10459&quot;&gt;comment&lt;/a&gt; says it, with these syntaxes, you lose the ability to include &lt;code&gt;'%'&lt;/code&gt; items inside the expression in the curly braces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, you could consider another syntax, described in &lt;code&gt;:h 'stl&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When the option starts with &quot;%!&quot; then it is used as an expression,&#xA;evaluated and the result is used as the option value.  Example: &amp;gt;&#xA;    :set statusline=%!MyStatusLine()&#xA;The result can contain %{} items that will be evaluated too.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, maybe you could add something like this in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%!MyStatusLine()&#xA;&#xA;fu! MyStatusLine() abort&#xA;    if &amp;amp;spell&#xA;        &quot; return the items when `'spell'` is enabled&#xA;        return '%P %m %l'&#xA;    else&#xA;        &quot; return the items when `'spell'` is disabled&#xA;        return '%P %m'&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or shorter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%!MyStatusLine()&#xA;fu! MyStatusLine() abort&#xA;    return '%P %m ' . (&amp;amp;spell ? '%l ' : '')&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-01T02:30:36.643" LastActivityDate="2016-12-01T02:30:36.643" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10460" PostTypeId="1" CreationDate="2016-12-01T06:35:30.303" Score="11" ViewCount="1158" Body="&lt;p&gt;Consider:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apple&#xA;pear&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put your cursor on the first line and type &lt;code&gt;Yp&lt;/code&gt;, producing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apple&#xA;apple&#xA;pear&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put your cursor on the &lt;code&gt;pear&lt;/code&gt; line and type &lt;code&gt;.&lt;/code&gt; to repeat the last command.  This repeats only the &lt;code&gt;p&lt;/code&gt; (rather than the combination &lt;code&gt;Yp&lt;/code&gt;), producing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apple&#xA;apple&#xA;pear&#xA;apple&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like a way to tell &lt;code&gt;.&lt;/code&gt; to repeat the last N commands.  Something like &lt;code&gt;2.&lt;/code&gt; to repeat the combination &lt;code&gt;Yp&lt;/code&gt; to produce:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apple&#xA;apple&#xA;pear&#xA;pear&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ofc that won't work -- it repeats the &lt;code&gt;p&lt;/code&gt; twice.  But the idea would be &quot;repeat the &lt;em&gt;sequence&lt;/em&gt; of the last 2 commands&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can &lt;code&gt;q&lt;/code&gt;-record command sequences and the repeat them with &lt;code&gt;@@&lt;/code&gt;, but this solution isn't ideal, as it requires you to have been planning ahead all along, whereas in practice you often don't realize you need to repeat something until after you've done it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to achieve what I want?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consolation prize: If the above is not possible, is there a way to repeat the last macro playback?  Eg, if I typed &lt;code&gt;@@&lt;/code&gt; to playback my last macro, I'd like for the subsequent &lt;code&gt;.&lt;/code&gt; to be equivalent to typing &lt;code&gt;@@&lt;/code&gt; again -- which it is not (eg, if the result of &lt;code&gt;@@&lt;/code&gt; depends on the line you're on)&lt;/p&gt;&#xA;" OwnerUserId="5373" LastEditorUserId="5373" LastEditDate="2016-12-01T07:32:56.080" LastActivityDate="2017-09-11T14:00:58.583" Title="Bundling command sequences together for repeat (.)" Tags="|key-bindings|repeated-commands|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10461" PostTypeId="2" ParentId="10460" CreationDate="2016-12-01T08:55:03.727" Score="2" Body="&lt;p&gt;In &lt;code&gt;Yp&lt;/code&gt;, the only &quot;change&quot; to repeat is &lt;code&gt;p&lt;/code&gt;. The only way I know to alter the behavior of &lt;code&gt;.&lt;/code&gt; in normal mode is to add &lt;code&gt;y&lt;/code&gt; to the &lt;code&gt;cpoptions&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cpoptions+=y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which lets you repeat the last yank as well as the last change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that doesn't change anything to your problem because &lt;code&gt;Yp&lt;/code&gt; is still two commands: a yank followed by a change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think you can get what you want without some non-trivial scripting. Did you take a look at &lt;a href=&quot;http://www.vim.org/scripts/script_search_results.php?keywords=repeat&amp;amp;script_type=&amp;amp;order_by=creation_date&amp;amp;direction=descending&amp;amp;search=search&quot; rel=&quot;nofollow noreferrer&quot;&gt;the scripts section of vim.org&lt;/a&gt;?&lt;/p&gt;&#xA;" OwnerUserId="54" LastActivityDate="2016-12-01T08:55:03.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10462" PostTypeId="1" CreationDate="2016-12-01T09:47:26.127" Score="7" ViewCount="773" Body="&lt;p&gt;Is there a way to have mixed indenting more like Sublime Text (left) than Vim does it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like the nested UL to follow the (line 10) to follow along the (main indentation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/C8hiQ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/C8hiQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10338" LastActivityDate="2016-12-01T09:47:26.127" Title="Mixed PHP and HTML indenting" Tags="|indentation|filetype-html|filetype-php|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10464" PostTypeId="1" AcceptedAnswerId="10465" CreationDate="2016-12-01T11:04:10.767" Score="17" ViewCount="2896" Body="&lt;p&gt;By pressing &lt;code&gt;gg&lt;/code&gt; and &lt;code&gt;G&lt;/code&gt; you can jump to both ends of a buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;42G&lt;/code&gt; jumps to the line 42.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any quick &lt;code&gt;g&lt;/code&gt; shortcut to jump to the middle of buffer. Something like roughly &lt;code&gt;round(number of lines/2)G&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="1551" LastEditorUserId="1841" LastEditDate="2016-12-01T12:01:35.857" LastActivityDate="2016-12-02T09:11:37.373" Title="How to jump to middle of buffer" Tags="|cursor-motions|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10465" PostTypeId="2" ParentId="10464" CreationDate="2016-12-01T11:08:15.083" Score="34" Body="&lt;p&gt;You can use &lt;code&gt;N%&lt;/code&gt; to jump to the Nth percent of the file. So e.g. &lt;code&gt;50%&lt;/code&gt; jumps roughly to the middle of the buffer. See the help at &lt;code&gt;:h N%&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-12-01T11:08:15.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10466" PostTypeId="2" ParentId="10372" CreationDate="2016-12-01T13:25:13.517" Score="2" Body="&lt;p&gt;It seems like the (undocumented) variable &lt;code&gt;g:NERDTreeNotificationThreshold&lt;/code&gt; might be what you are looking for (I have not tested this myself, but it is used in the plugin code for exactly your situation and nowhere else).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus setting it to a value higher than &lt;code&gt;134&lt;/code&gt;, e.g. &lt;code&gt;let g:NERDTreeNotificationThreshold = 500&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt; should hopefully solve your problem.&lt;/p&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2016-12-01T13:25:13.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10467" PostTypeId="2" ParentId="10464" CreationDate="2016-12-01T15:51:54.810" Score="3" Body="&lt;p&gt;I use these mappings in my own settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; M (line('$')/2).'G'&#xA;xnoremap &amp;lt;expr&amp;gt; M (line('$')/2).'G'&#xA;onoremap &amp;lt;expr&amp;gt; M (line('$')/2).'G'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's pretty simple, it simply evaluates the expression &lt;code&gt;(line('$')/2).'G'&lt;/code&gt; before running the mapping. &lt;code&gt;line('$')&lt;/code&gt; is the number of the last line in the buffer, which we divide by two. Then the &lt;code&gt;.'G'&lt;/code&gt; just appends 'G' to the resulting string. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you like using the default &lt;code&gt;M&lt;/code&gt; (Middle of visible screen), you could make this a leader mapping so that you don't overwrite it. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;m (line('$')/2).'G'&#xA;xnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;m (line('$')/2).'G'&#xA;onoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;m (line('$')/2).'G'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-12-01T15:51:54.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10468" PostTypeId="2" ParentId="10460" CreationDate="2016-12-01T16:51:37.883" Score="4" Body="&lt;p&gt;Vim only stores the &lt;em&gt;last&lt;/em&gt; executed command, and only that gets repeated by &lt;code&gt;.&lt;/code&gt;; in my opinion, anything else would be difficult to handle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you feel the need to repeat the &lt;code&gt;Yp&lt;/code&gt; combo as a single entity, you have to make it one single command. Tim Pope's &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2136&quot; rel=&quot;nofollow noreferrer&quot;&gt;repeat.vim plugin&lt;/a&gt; allows to do that easily for custom mappings. Of course, if you choose a short key [sequence] for the mapping, you can just quickly retype that (instead of &lt;code&gt;.&lt;/code&gt;), and even avoid the repeat.vim integration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4140&quot; rel=&quot;nofollow noreferrer&quot;&gt;LineJuggler plugin&lt;/a&gt; provides a &lt;code&gt;]d&lt;/code&gt; mapping to duplicate the current line, and it does support repeating via repeat.vim.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-01T16:51:37.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10469" PostTypeId="2" ParentId="10457" CreationDate="2016-12-01T16:56:50.137" Score="2" Body="&lt;p&gt;Plugins are configured via &lt;em&gt;global variables&lt;/em&gt;, defined in your &lt;code&gt;~/.vimrc&lt;/code&gt;. As this file is read &lt;em&gt;before&lt;/em&gt; any plugins are loaded, this is a convenient way to configure plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most plugins prefix those variables with their name (&lt;code&gt;g:PluginName_ConfigVar&lt;/code&gt;); this plugin is old and does not, but @mMontu found it nonetheless: &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1014&quot; rel=&quot;nofollow noreferrer&quot;&gt;clipbrd&lt;/a&gt;. Usually the plugin page (or the initial comment block at the top of the script) has an explanation of the config variables and possible values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have a &lt;code&gt;plugin/clipbrd.vim&lt;/code&gt; file in your &lt;code&gt;~/.vim/&lt;/code&gt; folder, you can safely drop this line.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-01T16:56:50.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10471" PostTypeId="1" AcceptedAnswerId="10474" CreationDate="2016-12-01T20:10:01.380" Score="3" ViewCount="2877" Body="&lt;p&gt;I use &lt;a href=&quot;https://github.com/francoiscabrol/ranger.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;the ranger plugin&lt;/a&gt; wich I can trigger with a shortcut. But when I open a directory I would like to use the plugin instead of netrw.&#xA;So I have found that the filetype of directories is &lt;code&gt;netrw&lt;/code&gt;, using &lt;code&gt;set filetype&lt;/code&gt;on a directory, and decided to put an autocommand in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType netrw :Ranger&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work. I can't find anything on the web on autocmds on directory.&#xA;Anyone has an idea on how to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="6078" LastEditorUserId="6078" LastEditDate="2016-12-02T11:03:34.293" LastActivityDate="2017-07-03T04:03:38.410" Title="Autocmd on directory to replace netrw" Tags="|vimrc|autocmd|netrw|filetype|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10472" PostTypeId="2" ParentId="5729" CreationDate="2016-12-01T20:17:09.000" Score="28" Body="&lt;p&gt;Vim 8 has a &lt;code&gt;execute()&lt;/code&gt; command the allows you to get the output of a command. To see it to the current buffer do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put =execute('let')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For Vim 7 you can use &lt;a href=&quot;https://github.com/AmaiSaeta/capture.vim&quot;&gt;capture.vim&lt;/a&gt;. It is a plugin that wraps the commands from @romainl's answer and lets you use it as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Capture let&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2016-12-01T20:17:09.000" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10473" PostTypeId="2" ParentId="10471" CreationDate="2016-12-01T21:20:01.963" Score="1" Body="&lt;ul&gt;&#xA;&lt;li&gt;Vim's default file explorer, the one you get when you do &lt;code&gt;$ vim .&lt;/code&gt;, is Netrw. See &lt;code&gt;:help netrw&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Netrw is written as a plugin but it is very tightly integrated into Vim. Forcing another plugin in place of netrw won't be as simple as an autocommand. If you are curious you can take a look at how some popular alternative file explorers do that: &lt;a href=&quot;https://github.com/justinmk/vim-dirvish/blob/4ae4303748221543aaa37030f209da11de817270/plugin/dirvish.vim#L15&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dirvish&lt;/a&gt; and &lt;a href=&quot;https://github.com/scrooloose/nerdtree/blob/f26eaf83551631e683e339f00e2c97bd6e8356d7/plugin/NERD_tree.vim#L168&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDTree&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As a very lightweight alternative, you could create a simple alias:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ alias vim.='vim +Ranger'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which allows you to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim.&#xA;$ vim. path/to/some/dir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But at this point… why not simply press &lt;code&gt;E&lt;/code&gt; in ranger?&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="51" LastEditDate="2017-06-23T16:08:13.060" LastActivityDate="2017-06-23T16:08:13.060" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10474" PostTypeId="2" ParentId="10471" CreationDate="2016-12-01T23:03:51.267" Score="5" Body="&lt;p&gt;I had a look at &lt;a href=&quot;https://github.com/justinmk/vim-dirvish/blob/4ae4303748221543aaa37030f209da11de817270/plugin/dirvish.vim#L8-L20&quot; rel=&quot;noreferrer&quot;&gt;how&lt;/a&gt; &lt;code&gt;Dirvish&lt;/code&gt; did it, and tested this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup ranger&#xA;    au!&#xA;    au VimEnter * sil! au! FileExplorer *&#xA;    au BufEnter * if s:isdir(expand('%')) | bd | exe 'Ranger' | endif&#xA;augroup END&#xA;&#xA;fu! s:isdir(dir) abort&#xA;    return !empty(a:dir) &amp;amp;&amp;amp; (isdirectory(a:dir) ||&#xA;                \ (!empty($SYSTEMDRIVE) &amp;amp;&amp;amp; isdirectory('/'.tolower($SYSTEMDRIVE[0]).a:dir)))&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to work but I don't know how reliable it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s:isdir()&lt;/code&gt; is a function which tests whether the path of the current buffer matches a directory.&lt;br&gt;&#xA;The &lt;code&gt;VimEnter&lt;/code&gt; autocmd seems to get rid of &lt;code&gt;netrw&lt;/code&gt;.&lt;br&gt;&#xA;The &lt;code&gt;BufEnter&lt;/code&gt; autocmd deletes the buffer (if you want to wipe it completely, replace &lt;code&gt;bd&lt;/code&gt; with &lt;code&gt;bw&lt;/code&gt;), then calls the &lt;code&gt;ranger&lt;/code&gt; file manager.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &lt;code&gt;Dirvish&lt;/code&gt; plugin, before calling the &lt;code&gt;:Dirvish&lt;/code&gt; command, the &lt;code&gt;BufEnter&lt;/code&gt; autocmd redraws the screen and echo an empty string (&lt;code&gt;redraw | echo ''&lt;/code&gt;). I don't know why it does this, so I didn't copied it, but if you have some issue (maybe with rendering artifacts, sometimes &lt;code&gt;:redraw!&lt;/code&gt; is used to get rid of them), try to add these commands back:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufEnter * if s:isdir(expand('%'))&#xA;                  \| bd | redraw | echo '' | exe 'Ranger' | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-01T23:40:48.517" LastActivityDate="2016-12-01T23:40:48.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10475" PostTypeId="2" ParentId="10464" CreationDate="2016-12-02T05:21:39.543" Score="-1" Body="&lt;p&gt;You can use &lt;code&gt;N%&lt;/code&gt; to jump to the Nth percent of the file. So e.g. &lt;code&gt;50%&lt;/code&gt; jumps roughly to the middle of the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the help at &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#N%25&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h N%&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10351" LastEditorUserId="1841" LastEditDate="2016-12-02T09:11:37.373" LastActivityDate="2016-12-02T09:11:37.373" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10476" PostTypeId="1" CreationDate="2016-12-02T10:07:55.440" Score="1" ViewCount="207" Body="&lt;p&gt;I don't understand the purpose of options that are &quot;local to a window&quot;, such as for example &lt;code&gt;colorcolumn&lt;/code&gt; and how they behave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a sequence to demonstrate what I mean:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I start gvim. An empty, unnamed buffer appears.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I open an inexsting file without a file type associated with it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e c:\temp\abc.foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;write some text and set colorcolumn to 1&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cc=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and write the buffer to disk&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I split the window&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:split&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and edit another inexsting file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e c:\temp\def.foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When writing some text, I see that the color column is set to 1. Which is what I expected, since vim copies the value from the currently active buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set the color column to 2&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cc=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and write this buffer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and start to edit yet another new file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e c:\temp\ghi.foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, the color column option value is copied from the currently active windows and set to &lt;code&gt;2&lt;/code&gt;. This is still what I expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I switch the buffer to the buffer below &lt;code&gt;&amp;lt;Ctrl-W&amp;gt;+j&lt;/code&gt; so that I am in &lt;code&gt;c:\temp\abc.foo&lt;/code&gt;, the color column option value of which is &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I start editing &lt;code&gt;def.foo&lt;/code&gt; in that window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bu def.foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, the color column option value is &lt;code&gt;2&lt;/code&gt;, which I have previously set for that buffer, but not for that window. Here, I'd have expected the value to be &lt;code&gt;1&lt;/code&gt; because it is an option &quot;local to a window&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone explain the rational of this behavior?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="985" LastEditDate="2016-12-02T10:21:09.430" LastActivityDate="2019-06-17T13:34:03.417" Title="I don't understand the purpose and behavior of options &quot;local to a window&quot;" Tags="|buffers|vim-windows|options|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10477" PostTypeId="1" AcceptedAnswerId="10478" CreationDate="2016-12-02T10:22:37.587" Score="15" ViewCount="4932" Body="&lt;p&gt;How can I iterate over the current open buffers and say, load the buffer numbers into an array in vimscript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there exists arrays or similar data structures in vimscript.&lt;br&gt;&#xA;I know that every buffer gets assigned a unique number.&lt;br&gt;&#xA;My goal is to put each of those numbers into an array of the same length as   the number of buffers i.e   &lt;code&gt;for i in number of open buffers: array[i] = #buffer&lt;/code&gt;&lt;br&gt;&#xA;I would like to let &lt;code&gt;array&lt;/code&gt; be a variable in my vimscript file.&lt;/p&gt;&#xA;" OwnerUserId="10357" LastEditorUserId="10357" LastEditDate="2016-12-02T11:08:14.460" LastActivityDate="2018-02-25T19:54:32.087" Title="How to iterate over buffers in Vimscript" Tags="|vimscript|buffers|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10478" PostTypeId="2" ParentId="10477" CreationDate="2016-12-02T11:00:48.980" Score="22" Body="&lt;p&gt;You can iterate over buffers if you use &lt;code&gt;:bnext&lt;/code&gt; and all. I highly advice against this method. It'll trigger autocommands, and you'll have to remember where you were. In other words, it can be damn slow, and with plenty side effects. Stay away if you can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Until now my preferred approach was to use &lt;code&gt;filter()&lt;/code&gt; on &lt;code&gt;range(1, bufnr('$'))&lt;/code&gt; to keep the buffers I'm interested in (&lt;code&gt;bufloaded()&lt;/code&gt;, &lt;code&gt;bufexists()&lt;/code&gt; or &lt;code&gt;buflisted()&lt;/code&gt;). Which gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let buffers = filter(range(1, bufnr('$')), 'bufexists(v:val)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We can even go further and use other ways to filter the buffer list: according to their name, or buffer-variables (.e.g &lt;code&gt;getbufvar(v:val, 'foo', sentinelvalue) =~ &quot;regex for b:foo&quot;)&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you see, there are plenty options. The entry points are &lt;code&gt;filter()&lt;/code&gt; and functions with &lt;code&gt;buf&lt;/code&gt; in their name -&gt; &lt;code&gt;:h *buf*()^D&lt;/code&gt; (&lt;code&gt;^D&lt;/code&gt; as in &lt;em&gt;hit ctrl+D&lt;/em&gt; to see the list of functions)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also that recent versions of vim provide a new &lt;code&gt;getbufinfo()&lt;/code&gt; function that'll return a list dictionaries: each dictionary is filled with plenty information for each existing buffer. Another way to obtain existing buffers is with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let buffers = map(copy(getbufinfo()), 'v:val.bufnr')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or listed buffers with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let buffers = map(filter(copy(getbufinfo()), 'v:val.listed'), 'v:val.bufnr')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2016-12-02T13:01:11.977" LastActivityDate="2016-12-02T13:01:11.977" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10480" PostTypeId="2" ParentId="10460" CreationDate="2016-12-02T19:33:07.070" Score="1" Body="&lt;p&gt;I frequently use &lt;code&gt;map&lt;/code&gt; to achieve this effect.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F12&amp;gt; Yp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then pressing &lt;code&gt;F12&lt;/code&gt; repeatedly will execute &lt;code&gt;YpYpYp&lt;/code&gt; etc.  If you want to move to the next line after every paste, map a key to &lt;code&gt;Yp+&lt;/code&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="10366" LastEditorUserId="51" LastEditDate="2016-12-03T10:20:49.297" LastActivityDate="2016-12-03T10:20:49.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10482" PostTypeId="1" AcceptedAnswerId="10560" CreationDate="2016-12-03T01:32:37.757" Score="3" ViewCount="338" Body="&lt;p&gt;Can this be done by editing the .vimrc file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I need is that after closing all tabs, a new tab is there like notepad++ does.&lt;/p&gt;&#xA;" OwnerUserId="10189" LastEditorUserId="24" LastEditDate="2016-12-08T17:36:38.480" LastActivityDate="2016-12-09T02:27:54.443" Title="How to not close MacVim after the last tab is closed?" Tags="|macvim|tabbed-user-interface|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10483" PostTypeId="1" CreationDate="2016-12-03T10:26:11.237" Score="2" ViewCount="3162" Body="&lt;p&gt;I have book length prose content in Markdown files that is mostly in Turkish. I've done a lot of work to get Turkish spell checking working decently in vim, so &lt;code&gt;:set spelllang=tr spell&lt;/code&gt; works well enough. However my prose contains lots of excerpts in other languages (English, Greek, Hebrew, German, Latin, French, etc.). These are tagged with some inline markup (and later typeset with correct language handling by &lt;a href=&quot;http://pandoc.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pandoc&lt;/a&gt; with some inline extensions similar to the ones allowing &lt;a href=&quot;http://pandoc.org/MANUAL.html#raw-tex&quot; rel=&quot;nofollow noreferrer&quot;&gt;inline LaTeX&lt;/a&gt; but modified to work with &lt;a href=&quot;http://sile-typesetter.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SILE&lt;/a&gt;. This markup looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... adına başka bir şey de deseydik gül (\lang:en{a rose by any other name}) ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;These have predictable tags such as &lt;code&gt;en&lt;/code&gt;, &lt;code&gt;el&lt;/code&gt;, &lt;code&gt;he&lt;/code&gt;, &lt;code&gt;de&lt;/code&gt;, &lt;code&gt;la&lt;/code&gt;, &lt;code&gt;fr&lt;/code&gt;, etc. that correspond to &lt;a href=&quot;http://www.loc.gov/standards/iso639-2/php/code_list.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;ISO-639-2 language codes&lt;/a&gt;, the same  as vim would need to be told to spellcheck these languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally I have some words that are transliterations or deliberately gibberish that are tagged &lt;code&gt;\lang:und{}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is would it be possible to ask VIM to spellcheck these regions based on the syntax? Right now I am manually skipping over them. I realize I can probably setup a syntax highlighter to ignore the regions altogether, but can vim spellcheck different regions as different languages?&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="267" LastEditDate="2016-12-03T10:41:22.647" LastActivityDate="2016-12-03T21:22:19.707" Title="Change spellcheck language via syntax" Tags="|syntax-highlighting|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10486" PostTypeId="1" AcceptedAnswerId="10487" CreationDate="2016-12-03T12:11:36.977" Score="3" ViewCount="505" Body="&lt;p&gt;I'm struggling with strange case. I've read many help pages and search through net but found nothing.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:rename(name)&#xA;    try&#xA;        echom a:name&#xA;        saveas a:name&#xA;        &quot; bd #&#xA;        &quot; silent !rm #&#xA;    endtry&#xA;endfunction&#xA;command! -nargs=1 Ren call s:rename(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Ren newname&#xA;:messages&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;newname&lt;br&gt;&#xA;  &quot;a:name&quot; 4L, 9C written&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Why &lt;code&gt;a:name&lt;/code&gt; is not recognized as a variable!?&lt;/p&gt;&#xA;" OwnerUserId="8444" LastEditorUserId="8444" LastEditDate="2016-12-03T13:22:50.120" LastActivityDate="2016-12-03T13:22:50.120" Title="Function-argument a:var not recognized as variable?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10487" PostTypeId="2" ParentId="10486" CreationDate="2016-12-03T12:36:57.477" Score="4" Body="&lt;p&gt;&lt;code&gt;:saveas&lt;/code&gt; expects a filename as an argument (see &lt;code&gt;:h :saveas&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, inside your function, when you pass &lt;code&gt;a:name&lt;/code&gt; to &lt;code&gt;:saveas&lt;/code&gt;, it treats it as a filename.&lt;br&gt;&#xA;If you want to pass the contents of the variable &lt;code&gt;a:name&lt;/code&gt;, you can write this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'saveas ' . a:name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The difference is that &lt;code&gt;:execute&lt;/code&gt; expects an expression (see &lt;code&gt;:h :execute&lt;/code&gt;).&lt;br&gt;&#xA;&lt;code&gt;'saveas '&lt;/code&gt; is a string, which is a type of expression.&lt;br&gt;&#xA;&lt;code&gt;a:name&lt;/code&gt; is a variable, which here is replaced with its contents.&lt;br&gt;&#xA;It's the same kind of evaluation you see when you type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let myvar = 'hello'&#xA;:echo myvar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;myvar&lt;/code&gt; is automatically evaluated into its value after &lt;code&gt;:echo&lt;/code&gt;, just like after &lt;code&gt;:execute&lt;/code&gt;, but not after &lt;code&gt;:saveas&lt;/code&gt;. Because, again, the first 2 commands expect expressions as arguments, whereas the latter expects a filename.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The evaluation of &lt;code&gt;a:name&lt;/code&gt; is a string which contains your filename, and the dot between &lt;code&gt;saveas&lt;/code&gt; and &lt;code&gt;a:name&lt;/code&gt; is the concatenation operator (see &lt;code&gt;:h expr-.&lt;/code&gt;). The result of the concatenation is again a string which is still a kind of expression.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;:execute&lt;/code&gt; receives an expression as an argument, which is what it expects, and executes it as an Ex command.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-12-03T12:36:57.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10490" PostTypeId="1" AcceptedAnswerId="10492" CreationDate="2016-12-03T17:59:33.633" Score="0" ViewCount="2249" Body="&lt;p&gt;Sometimes I need to press &lt;kbd&gt;TAB&lt;/kbd&gt;, but instead of getting actual the tab key, a suggestion pops up and &lt;kbd&gt;TAB&lt;/kbd&gt; cycles through the suggestions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I insert &lt;kbd&gt;TAB&lt;/kbd&gt; without invoking the auto-completion ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem occurrs both in YouCompleteMe and SuperTab plugins.&lt;/p&gt;&#xA;" OwnerUserId="496" LastEditorUserId="496" LastEditDate="2016-12-03T18:16:53.323" LastActivityDate="2016-12-03T21:16:53.757" Title="bypassing TAB auto-complete" Tags="|autocompletion|plugin-you-complete-me|tab-characters|plugin-supertab|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10491" PostTypeId="2" ParentId="10490" CreationDate="2016-12-03T19:43:38.590" Score="3" Body="&lt;p&gt;You can always bypass the effects of a keypress by preceding it with a &lt;kbd&gt;ctrl-v&lt;/kbd&gt;. For example, if you'd like to insert a literal escape character without returning to normal mode, you can do from insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also works on the command line. I don't have YouCompleteMe, or SuperTab installed so I haven't tested this solution, but it should work fine to do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let me know if this works for you!&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-12-03T19:43:38.590" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10492" PostTypeId="2" ParentId="10490" CreationDate="2016-12-03T21:16:53.757" Score="1" Body="&lt;p&gt;I would just use a different key mapping for completion instead of hijacking the Tab key. Having one key to preform two actions and &quot;guess&quot; which one it should do is just a misguided approach IMHO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For SuperTab see &lt;code&gt;:help supertab-forwardbackward&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g:SuperTabMappingForward  (default value: '&amp;lt;tab&amp;gt;')&#xA;g:SuperTabMappingBackward (default value: '&amp;lt;s-tab&amp;gt;')&#xA;&#xA;These two variables allow you to set the keys used to kick off the current&#xA;completion. By default this is &amp;lt;tab&amp;gt; and &amp;lt;s-tab&amp;gt;. To change to something&#xA;like &amp;lt;c-space&amp;gt; and &amp;lt;s-c-space&amp;gt;, you can add the following to your |vimrc|.&#xA;&#xA;    let g:SuperTabMappingForward = '&amp;lt;c-space&amp;gt;'&#xA;    let g:SuperTabMappingBackward = '&amp;lt;s-c-space&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And for YouCompleteMe see &lt;code&gt;:help g:ycm_key_list_select_completion&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The *g:ycm_key_list_select_completion* option&#xA;&#xA;This option controls the key mappings used to select the first completion&#xA;string. Invoking any of them repeatedly cycles forward through the completion&#xA;list.&#xA;&#xA;Some users like adding '&amp;lt;Enter&amp;gt;' to this list.&#xA;&#xA;Default: &quot;['&amp;lt;TAB&amp;gt;', '&amp;lt;Down&amp;gt;']&quot;&#xA;&#xA;    let g:ycm_key_list_select_completion = ['&amp;lt;TAB&amp;gt;', '&amp;lt;Down&amp;gt;']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another alternative is mapping another key combination to &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;; e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inorenap &amp;lt;Leader&amp;gt;&amp;lt;Tab&amp;gt; &amp;lt;Tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then use &lt;code&gt;\&amp;lt;Tab&amp;gt;&lt;/code&gt; to get the default tab behaviour.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-12-03T21:16:53.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10493" PostTypeId="2" ParentId="10483" CreationDate="2016-12-03T21:22:19.707" Score="6" Body="&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/q/40833281/660921&quot;&gt;I answered pretty much the same question on Stack Overflow last week&lt;/a&gt;, and the short of it is that you can't do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best you can do is to use &lt;code&gt;:set spelllang=en_gb,tr&lt;/code&gt;, so it checks both languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry :-(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for ignore these regions, this can be done by adding a new syntax group with &lt;code&gt;contains=@NoSpell&lt;/code&gt;. See &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3asyn%2dspell&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :syn-spell&lt;/code&gt;&lt;/a&gt;. Also see &lt;a href=&quot;https://vi.stackexchange.com/a/5856/51&quot;&gt;Is it possible to turn on spell-checking for only parts of buffers?&lt;/a&gt; as well as &lt;a href=&quot;https://vi.stackexchange.com/a/4003/51&quot;&gt;this answer&lt;/a&gt; for some examples.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-12-03T21:22:19.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10494" PostTypeId="2" ParentId="9444" CreationDate="2016-12-04T00:35:23.523" Score="1" Body="&lt;p&gt;Why do you need to run that batch file? To set &lt;code&gt;PATH&lt;/code&gt; to include &lt;code&gt;g++&lt;/code&gt; and all? If so, you should consider opening a console, running that script from the console and eventually launching Vim from that same console. Or you could make sure the &lt;em&gt;&quot;environment variables&quot;&lt;/em&gt; set in that script are defined to be always set on your windows system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, depending on what provides you gcc, it could be very simple to compile single file programs from vim. Typing &lt;code&gt;:make %&amp;lt;&lt;/code&gt; is enough with a correctly configured programming environment. On Windows, this means installing g++ through cygwin distribution. Mingw is very badly configured. With this one, you'll have to set &lt;code&gt;:set makeprg=g++\ -o\ $*\ $*.cpp&lt;/code&gt; (typed from memory -- I stay away from mingw and thus, I never need to do this) -- or if you really want to run vim from the window explorer: &lt;code&gt;:let &amp;amp;makeprg = 'c:/path/to/that/script.bat &amp;amp;&amp;amp; g++ -o $* $*.cpp'&lt;/code&gt;. Or you can define a Makefile as others have explained you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details about what is possible with a correctly configure programming environment on the big sister/brother site: &lt;a href=&quot;https://stackoverflow.com/a/35702919/15934&quot;&gt;https://stackoverflow.com/a/35702919/15934&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2016-12-04T00:35:23.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10495" PostTypeId="1" CreationDate="2016-12-04T09:14:28.573" Score="10" ViewCount="7482" Body="&lt;p&gt;I am a happy user of VIM, except for some bits which I really want vim to improve on. One main issue is frequent slowdown of VIM spoiling the amazingly productive text-editing experience on a fastest desktop PC that one can find and a fresh linux installation. This is more with after start-up than during start-up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finding the causes of slowdown is a big headache: it could be .vimrc or plugins or too many syntax highlighting or number of buffers etc. None of these reasons make sense to me given a gaming PC that runs multiple graphics engines. After all, I am working with plain text not 3D graphics! At least vim must not be any slower than the basic utilities gedit or notepad!! I will proceed with these reasons anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To highlight, two of the main reasons that I find for this popular slow down are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Syntax highlighting (this is surprising, given the fastest processors these days)&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Too many redraw (refresh) operations by any means&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2a. I actually assume having any number of buffers open must not cause vim to slow down. But this also has been a case where I notice a significant slow down. We deal with one buffer at a time after all!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Some specific solutions that I found so far are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Removing &lt;code&gt;:set relativenumber&lt;/code&gt; and also &lt;code&gt;:set cursorline&lt;/code&gt; since they cause too many redraws. &#xA;(yes it is a silly reason, given fastest processors and GPUs these days! But rest of the reasons are no less. And brace yourselves, you have too many of them.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add &lt;code&gt;:set regexpengine=1&lt;/code&gt;&#xA;According to this &lt;a href=&quot;https://stackoverflow.com/a/38521226/1270953&quot;&gt;answer&lt;/a&gt;, Vim 7.4 has introduced a weaker regex engine and setting this option will revert it to older, causing a significant speed up.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add &lt;code&gt;:set lazyredraw&lt;/code&gt; and &lt;code&gt;:set ttyfast&lt;/code&gt;&#xA;Instructs the vim engine to try redrawing as fewer times as possible.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add &lt;code&gt;:syntax off&lt;/code&gt; -- remove so that vim doesn't need to work on colouring keywords etc! (its indeed a radical solution, but at least will tell you how serious the syntax is and also whether it is actually the reason)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Current folding method could be a cause of the slow-down, especially if it is &lt;code&gt;syntax&lt;/code&gt; or &lt;code&gt;expr&lt;/code&gt;. (i.e. change &lt;code&gt;:set foldmethod=syntax&lt;/code&gt; or &lt;code&gt;:set foldmethod=expr&lt;/code&gt; to something else)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;Autocommands&lt;/em&gt;. Disable everyone of them in your vimrc and see if it improved the speed. Having too many parallel processes like autocommands, on a single-thread machine like Vim can cause a significant slow down.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Try &lt;code&gt;:set synmaxcol=xxxx&lt;/code&gt; (as per romainl's answer) with xxx a number less than the default value of 3000. e.g. 200.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You might be having too many plugins, with unknown lags. So go for a trial-and-error to find out the culprit plugin and remove it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You might be having a number of buffers open, try removing some using &lt;code&gt;bd&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Like many older systems, ageing might be a problem, especially when dealing with multiple buffers open. Agreed on having no clue about the root cause of the problem, simply &lt;strong&gt;restart VIM&lt;/strong&gt; and one often sees a significant improvement.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Try &lt;strong&gt;restarting vim with no plugins and vimrc&lt;/strong&gt;  using &lt;code&gt;&amp;gt;&amp;gt; vim -u NONE -U NONE -N&lt;/code&gt;, see if it solved the problem. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finally, start a &lt;em&gt;profiler&lt;/em&gt; (many ways to do this!) as mentioned in one of the answers below and &lt;em&gt;break your head&lt;/em&gt; until you find the reason.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In a nutshell, My main question is this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can somebody tell me how can a &lt;em&gt;willing&lt;/em&gt; practitioner actively avoid the most annoying vim's slowdown? (Hopefully in a user friendly non-geeky way) -- All I want is a simple, ready-to-use, fast &lt;em&gt;plain-text&lt;/em&gt; editor!!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For the recent NeoVim alternative, I am not fully satisfied while I tried using it. I am not sure if it solves any existing problems but as I notice it does create new problems of interfacing and transition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there are a number of questions on this, I paste them below. Hope this post serves as a starting point Wiki for all these problems. It is unfortunate that none of them are a single point of resource useful for this most popular problem within vim community. Hope this question becomes one!&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;How do I debug my vimrc file?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/2875/vim-slows-down-over-time-with-syntax-on&quot;&gt;Vim slows down over time with syntax on&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/3327/improve-performance-of-syntax-highlighting-in-vim&quot;&gt;Improve performance of syntax highlighting in Vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/9341768/vim-response-quite-slow&quot;&gt;Vim response quite slow&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/19030290/syntax-highlighting-causes-terrible-lag-in-vim&quot;&gt;Syntax highlighting causes terrible lag in Vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/12213597/how-to-see-which-plugins-are-making-vim-slow&quot;&gt;How to see which plugins are making Vim slow?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/16902317/vim-slow-with-ruby-syntax-highlighting&quot;&gt;Vim slow with ruby syntax highlighting&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/2916887/enabling-syntax-and-syntax-folding-in-vim-with-large-c-file-makes-completion-slo&quot;&gt;Enabling syntax and syntax folding in vim with large C file makes completion slow&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/19030290/syntax-highlighting-causes-terrible-lag-in-vim&quot;&gt;Syntax highlighting causes terrible lag in Vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;PS:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To claim some final words, it is a pity. Especially given the popularity and the number of fan-boys within the tech community, plus the number of active projects at any point of time ever since Unix. Vim, while being arguably the most useful programmable text editor on earth, lies down in an old-age single-threaded implementation with minimal configurable teletype appearance and many other rusty functionalities as I hear from techie friends. I wish to know that I am wrong with some of these understandings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have never contributed to Open source, but I am an enthusiastic basic programmer with love for open source. Once I learn how to, I will make sure vim will bear at least one of my contributions to ail these problems.&lt;/p&gt;&#xA;" OwnerUserId="4583" LastEditorUserId="2920" LastEditDate="2017-06-06T20:04:13.390" LastActivityDate="2017-06-06T20:04:13.390" Title="Most annoying slow-down of a plain-text editor!" Tags="|vimrc|vimscript|startup|performance|" AnswerCount="1" CommentCount="3" ClosedDate="2016-12-07T11:59:11.117" ContentLicense="CC BY-SA 3.0" />
  <row Id="10496" PostTypeId="2" ParentId="10495" CreationDate="2016-12-04T10:19:42.107" Score="20" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can somebody tell me how to avoid the very annoying vim's slowdown? Hopefully in a user friendly non-geeky way?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I run Vim on a company-provided 2013 15&quot; Retina MacBook with a 2.3 GHz i7 processor, 16 GB of RAM, and a measly GT 750M with 2 GB dedicated memory. That machine is very far from a &quot;gaming PC&quot; and &lt;strong&gt;I've never experienced any slow down. Ever.&lt;/strong&gt; Even on my own older and very limited Mac Mini, Vim is quite possibly the most responsive app.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, Vim is an old program with an old single-threaded architecture. This obviously comes with a few limitations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The biggest performance hits come from the syntax highlighting mechanism which is based on regular expressions. Unfortunately, regular expressions are quite hard to get right and are not really the best tool for the job anyway. Some built-in syntax scripts like PHP, YML, and Ruby are notoriously slow. Whether that slowness is due to sloppy programming on the maintainer side, a bad regex engine, or the very idea of using regular expressions in the first place is up for the debate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some common workarounds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax off                      &quot; radical&#xA;:set synmaxcol=200               &quot; arbitrary number &amp;lt; 3000 (default value)&#xA;:set foldmethod=manual           &quot; anything other than 'syntax'&#xA;:set foldmethod=indent           &#xA;:set noshowmatch                 &quot; it's off by default but well&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another performance hit comes with a general misunderstanding of autocommands. It's very easy to have them pile up and end up with tens or hundreds of them executed before and/or after any operation (remember Vim is single-threaded), resulting in a progressive slow down. It's also very easy to read the documentation and write your autocommands properly. No workaround needed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup myautocommands&#xA;    autocmd!&#xA;    autocmd SomeEvent,AnotherEvent pattern command&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The third biggest performance hit is caused by redrawing, which happens in the main thread, &lt;em&gt;like everything else&lt;/em&gt;. Redrawing often is not a problem if you don't have much to redraw (try &lt;code&gt;$ vim -Nu NONE file.rb&lt;/code&gt;) but people want a fancy statusline, fancy &lt;a href=&quot;https://github.com/airblade/vim-gitgutter&quot; rel=&quot;noreferrer&quot;&gt;gutter&lt;/a&gt; signs, more colors, side panels and all kinds of pointless gadgets and they insist on scrolling with &lt;code&gt;jk&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, did I mention that Vim is single-threaded? The more you ask it to do &quot;automatically&quot;, the slower it gets.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;All I want is a simple, ready-to-use, fast plain-text editor!!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then contribute code or use nano.&lt;/p&gt;&#xA;" OwnerUserId="54" LastEditorUserId="2314" LastEditDate="2017-01-11T12:12:53.207" LastActivityDate="2017-01-11T12:12:53.207" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="10497" PostTypeId="1" AcceptedAnswerId="10542" CreationDate="2016-12-04T14:11:51.707" Score="7" ViewCount="1075" Body="&lt;p&gt;I like the ability to show trailing whitespaces, so I have this setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set list listchars=tab:\ \ ,trail:·&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I never use tabs (although I don't think tabs are bad, it's just a convention), but sometimes I'm reading someone else code and they use tabs. I don't want to see tabs as some special characters in that cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But with the settings above vim would show tabs with different background colour. I don't want this. Can it just show trailing whitespaces and leave everything else alone?&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="24" LastEditDate="2016-12-08T17:31:35.907" LastActivityDate="2016-12-08T17:31:35.907" Title="How to show trailing spaces, while leaving tabs as they are?" Tags="|indentation|options|whitespace|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10500" PostTypeId="1" AcceptedAnswerId="10501" CreationDate="2016-12-05T00:03:35.957" Score="4" ViewCount="1953" Body="&lt;p&gt;I'd like to define a vim command with the following functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;60&amp;lt;F7&amp;gt;=&lt;/code&gt; insert &lt;code&gt;=&lt;/code&gt; at the end of the line until the line become 60 characters long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;F7&amp;gt;*&lt;/code&gt; insert &lt;code&gt;*&lt;/code&gt; until the line becomes as long as the value of &lt;code&gt;colorcolumn&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The preexisting text on the line should be separated from the inserted characters by a space.&lt;/p&gt;&#xA;" OwnerUserId="10391" LastEditorUserId="1841" LastEditDate="2016-12-05T13:26:39.813" LastActivityDate="2016-12-05T13:26:39.813" Title="Insert character until column number" Tags="|text-generation|colorcolumn|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10501" PostTypeId="2" ParentId="10500" CreationDate="2016-12-05T00:53:41.257" Score="4" Body="&lt;p&gt;Well, doing this in vimscript is not that hard. For example, the following command will do what you describe to the line your cursor is on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec 'norm '.(&amp;amp;cc - strlen(getline('.'))).'A='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The way this works is it determines the length of the current line and subtracts that from the current value of &lt;code&gt;'colorcolumn'&lt;/code&gt;. This evaluates to a string, and is executed as if you had typed it. For example, on a line with 10 characters, and with &lt;code&gt;'colorcolumn'&lt;/code&gt; set to 80 this is equivalent to typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;70A=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also be more specific about which line to do this to. For example, to do this to line 3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec 'norm '.(&amp;amp;cc - strlen(getline(3))).'A='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or the line that mark &lt;code&gt;a&lt;/code&gt; is on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec 'norm '.(&amp;amp;cc - strlen(getline(&quot;'a&quot;))).'A='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To wrap this up in a convenient mapping, I would recommend this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Append(c)&#xA;  exec 'norm '.(&amp;amp;cc - strlen(getline('.'))).'A'.nr2char(a:c)&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt; m ':call Append('.getchar().&quot;)\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2016-12-05T01:15:43.817" LastActivityDate="2016-12-05T01:15:43.817" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10502" PostTypeId="2" ParentId="10452" CreationDate="2016-12-05T04:40:52.430" Score="2" Body="&lt;p&gt;You can either manually do what Pathogen does for you: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath+=~/.vim/bundle/nerdtree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, you can go back to the Stone Age and copy everything in that folder to &lt;code&gt;~/.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-12-05T04:40:52.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10503" PostTypeId="1" AcceptedAnswerId="10504" CreationDate="2016-12-05T12:07:14.500" Score="1" ViewCount="193" Body="&lt;p&gt;I am copy pasting a big chunk of code from an article in PDF format. The issue is that the operation is replacing every &lt;code&gt;*&lt;/code&gt; character (the multiply operator in Fortran) by some sort of slash character, which isn't the generic slach character in Vim (used for division in Fortran).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, consider the expressions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s2 = exp(-w * t)&#xA;s3 = 1.0_wp / s2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When copy pasting, I get the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wxKxl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wxKxl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, the regular slash is highlighted in yellow while the asterisk character was changed to some other kind of slash. I could very well go over every character and replace them, but that's not very reliable and would take quite a while (few thousand lines of code...). Ideally, I'd like to change them all in the following manner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/[wierd-slash]/\*/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've found how to search and replace unprintable characters. &lt;code&gt;ga&lt;/code&gt; or &lt;code&gt;:ascii&lt;/code&gt; prints the hexa/octa value of the character under the cursor (in my case hexa 2044). However, when running &lt;code&gt;:%s/\%x2044/\*/g&lt;/code&gt;, I can the error &lt;code&gt;Err: pattern not found: \%x2044&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I've tried typing &lt;code&gt;*&lt;/code&gt; when the character is under the cursor (then I could search and replace last searched character) but it searched for the next word instead. In the example above, it would search for &lt;code&gt;t&lt;/code&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="4562" LastEditorUserId="51" LastEditDate="2016-12-05T12:22:42.813" LastActivityDate="2016-12-05T12:30:52.237" Title="Unfamiliar character when copy pasting from PDF file" Tags="|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10504" PostTypeId="2" ParentId="10503" CreationDate="2016-12-05T12:28:32.070" Score="4" Body="&lt;p&gt;Excerpt from &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5c%25x&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\%x&lt;/code&gt;&lt;/a&gt; (emphasis mine):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;\%x2a &amp;nbsp; &amp;nbsp; &amp;nbsp; Matches the character specified with up to &lt;strong&gt;two&lt;/strong&gt; hexadecimal characters.&#xA;  \%u20AC &amp;nbsp;Matches the character specified with up to &lt;strong&gt;four&lt;/strong&gt; hexadecimal&#xA;      characters.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you need to use &lt;code&gt;\%u2044&lt;/code&gt;, rather than &lt;code&gt;\%x2044&lt;/code&gt;, which will search for &lt;code&gt;&amp;lt;Space&amp;gt;44&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also copy-paste it to the commandline or type &lt;code&gt;&amp;lt;C-v&amp;gt;u2044&lt;/code&gt; in the commandline to get a literal &lt;code&gt;⁄&lt;/code&gt;; you don't &lt;em&gt;need&lt;/em&gt; to escape it with &lt;code&gt;\%u&lt;/code&gt; to use it in the &lt;code&gt;:s&lt;/code&gt; command (or most other commands).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I find &lt;a href=&quot;https://github.com/chrisbra/unicode.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;unicode.vim&lt;/a&gt; a very useful plugin. Using &lt;code&gt;:UnicodeName&lt;/code&gt; on the character gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'⁄' U+2044 Dec:8260 FRACTION SLASH (/f) &amp;amp;frasl; /\%u2044&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note how this includes the &lt;code&gt;/\%u2044&lt;/code&gt; ready for copy/pasting :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2016-12-05T12:30:52.237" LastActivityDate="2016-12-05T12:30:52.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10505" PostTypeId="2" ParentId="7729" CreationDate="2016-12-05T12:46:15.457" Score="1" Body="&lt;p&gt;For the Mac (pre Sierra) you can install &lt;a href=&quot;https://pqrs.org/osx/karabiner/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Karabiner&lt;/a&gt; which lets you do that and more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look for Option_R to Escape.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you already have Sierra you need to wait for the Karabiner update.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2016-12-05T12:46:15.457" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10506" PostTypeId="2" ParentId="2350" CreationDate="2016-12-05T12:49:09.843" Score="4" Body="&lt;p&gt;If &lt;code&gt;Control+V&lt;/code&gt; followed by &lt;code&gt;ALT-x&lt;/code&gt; shows &lt;code&gt;^[x&lt;/code&gt; (type in terminal) you can fix it with this small script from &lt;a href=&quot;http://vim.wikia.com/wiki/Fix_meta-keys_that_break_out_of_Insert_mode&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim.wikia.com&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(97,122)&#xA;  let c = nr2char(i)&#xA;  exec &quot;map \e&quot;.c.&quot; &amp;lt;M-&quot;.c.&quot;&amp;gt;&quot;&#xA;  exec &quot;map! \e&quot;.c.&quot; &amp;lt;M-&quot;.c.&quot;&amp;gt;&quot;&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add to .vimrc for all alt key mappings.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="10337" LastEditDate="2016-12-05T17:09:14.717" LastActivityDate="2016-12-05T17:09:14.717" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10510" PostTypeId="1" AcceptedAnswerId="10522" CreationDate="2016-12-05T19:43:09.673" Score="1" ViewCount="244" Body="&lt;p&gt;Beginner Vim user here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already learned about automating deleting with commands, which happens this way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;[number]d[j/k/h/l] [OR] d[number][j/k/h/l]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;number&lt;/code&gt; stands for the amount of the action repeated.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Can I use it for simply moving the cursor? Like &lt;code&gt;5l&lt;/code&gt; - or &lt;code&gt;3w&lt;/code&gt; to jump words.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it good practice at all? Or can/should I find better ways of automatic cursor movement in Vim?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10284" LastEditorUserId="10284" LastEditDate="2016-12-06T19:35:13.937" LastActivityDate="2016-12-06T19:35:13.937" Title="Automatizing cursor movement in normal mode" Tags="|cursor-movement|normal-mode|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="10511" PostTypeId="1" AcceptedAnswerId="10512" CreationDate="2016-12-05T22:28:11.340" Score="4" ViewCount="738" Body="&lt;p&gt;if I have a list of indented text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;test test&#xA;    test test&#xA;    test test&#xA;test test&#xA;     test test&#xA;          test test&#xA;     test test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I wanted to convert it to a markdown list&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- test test&#xA;    - test test&#xA;    - test test&#xA;- test test&#xA;     - test test&#xA;          - test test&#xA;     - test test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what would be the best way to do this if vim?&lt;/p&gt;&#xA;" OwnerUserId="10038" LastEditorUserId="2314" LastEditDate="2016-12-22T12:22:11.987" LastActivityDate="2016-12-22T12:22:11.987" Title="multi-line insert after indentation whitespace" Tags="|indentation|multiple-lines|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10512" PostTypeId="2" ParentId="10511" CreationDate="2016-12-05T22:38:43.583" Score="5" Body="&lt;p&gt;There are a few ways you could do this. The way &lt;em&gt;I&lt;/em&gt; would probably do it is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm I-&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; should be a literal space, not the text &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt;. This simply applies the set of keystrokes &lt;code&gt;I-&amp;lt;space&amp;gt;&lt;/code&gt; to every line in the buffer. Uppercase &lt;code&gt;I&lt;/code&gt; enters insert mode on the first non-whitespace character of the current line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if you don't want it on &lt;em&gt;every&lt;/em&gt; line, and instead on a few lines, you could visually select the lines and do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm I-&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the most straightforward approach. The other thing you could do is a substitute command. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^ */&amp;amp;- /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just as with the last command, if you visually select the lines you would like to do this to, you can run &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/^ */&amp;amp;- /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead to only do this to certain lines.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-12-05T22:38:43.583" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10513" PostTypeId="1" AcceptedAnswerId="10532" CreationDate="2016-12-06T05:45:49.250" Score="0" ViewCount="276" Body="&lt;p&gt;Question on &lt;a href=&quot;http://vim-latex.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim latex suite&lt;/a&gt; (the link is provided to avoid confusion).&#xA;When I see the compiled &lt;code&gt;pdf&lt;/code&gt; using &lt;code&gt;\lv&lt;/code&gt; command, it sometimes show error message spitted out by the viewer on top of the editing screen (shown on the picture).&lt;br&gt;&#xA;Is there any way to suppress this error message perhaps by adding some simple line to &lt;code&gt;.vimrc&lt;/code&gt;?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;ubuntu 16.04&lt;br&gt;&#xA;vim latex suite&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0SvlF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0SvlF.png&quot; alt=&quot;The picture of error being superposed to the editing screen&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1819" LastActivityDate="2016-12-07T00:54:17.267" Title="Vim Latex Suite, suppress viewer errors" Tags="|vimrc|error|plugin-vim-latex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10514" PostTypeId="2" ParentId="3174" CreationDate="2016-12-06T08:31:37.557" Score="2" Body="&lt;p&gt;You can disable folding before doing &lt;code&gt;:m+1&lt;/code&gt; by using &lt;code&gt;zi&lt;/code&gt;. And then enable it again with &lt;code&gt;zi&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also add a special mapping for that in your .vimrc :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;move line up/down with Shift+up/down&#xA;nnoremap &amp;lt;S-Up&amp;gt; zi:m-2&amp;lt;CR&amp;gt;zi&#xA;nnoremap &amp;lt;S-Down&amp;gt; zi:m+&amp;lt;CR&amp;gt;zi&#xA;inoremap &amp;lt;S-Up&amp;gt; &amp;lt;Esc&amp;gt;zi:m-2&amp;lt;CR&amp;gt;zia&#xA;inoremap &amp;lt;S-Down&amp;gt; &amp;lt;Esc&amp;gt;zi:m+&amp;lt;CR&amp;gt;zia&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10401" LastEditorUserId="1841" LastEditDate="2016-12-06T09:40:54.763" LastActivityDate="2016-12-06T09:40:54.763" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10515" PostTypeId="1" CreationDate="2016-12-06T08:40:33.407" Score="3" ViewCount="1678" Body="&lt;p&gt;I want to have fixed current directory equals to the directory where vim was opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note I am using tabs and splits, so I want to have the same current directory in all tabs and splits. How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="10402" LastEditorUserId="1841" LastEditDate="2016-12-06T09:41:51.207" LastActivityDate="2019-10-17T03:01:46.957" Title="Do not change current directory" Tags="|working-directory|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10516" PostTypeId="2" ParentId="10515" CreationDate="2016-12-06T09:50:48.063" Score="1" Body="&lt;p&gt;To change the current directory with the file opened at start up you can add this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; cd %:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By default vim doesn't change the current directory when opening other files so your tabs and splits should not change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you might be interested by &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#current%2Ddirectory&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h current-directory&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-12-06T09:50:48.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10518" PostTypeId="1" AcceptedAnswerId="10519" CreationDate="2016-12-06T10:28:06.307" Score="4" ViewCount="747" Body="&lt;p&gt;I just discovered you can't search and replace within a block selection without adding the ugly and unintuitive &lt;code&gt;\%V&lt;/code&gt; to the search term. The default behaviour seems to be to ignore the fact that you've done a columnular highlight and operate on whatever lines the highlight touches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would it not have made more sense to have &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; default to &quot;operate on the highlighted text&quot; - whether columnular or not - , and to allow the user to specify some hack to operate on the whole lines instead of the highlighted block if that is what is desired?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the current behaviour there for historical reasons, or is there a rational reason for it?  I'm assuming there's no way of getting the behaviour I'm after without a plugin?&lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastEditorDisplayName="user859" LastEditDate="2016-12-06T17:02:19.887" LastActivityDate="2016-12-07T10:30:03.387" Title="Search and Replace inside block-selected text" Tags="|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10519" PostTypeId="2" ParentId="10518" CreationDate="2016-12-06T10:56:18.800" Score="3" Body="&lt;p&gt;The current behavior is probably due to historical reason: the visual block seems to have introduced in version 5, and the notes for this version 5 also mentions an update on the marks &lt;code&gt;'&amp;lt;&lt;/code&gt;/&lt;code&gt;'&amp;gt;&lt;/code&gt; behavior, so visual block is newer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Despite you find the behavior unintuitive, the current implementation allows you to work on both the visual block or the selected lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You wouldn't need a plugin to avoid that notation; a simple mapping or abbreviation can be used instead.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How might I use a mapping or abbreviation to get the desired&#xA;  behaviour?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Vim documentation is very comprehensive and well written; you can find a good explanation in &lt;a href=&quot;http://vimhelp.appspot.com/usr_05.txt.html#05.3&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 05.3&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/usr_24.txt.html#24.7&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 24.7&lt;/code&gt;&lt;/a&gt;. One possibility in this case is to include the following in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap : :s/\%V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vnoremap :&lt;/code&gt;: override the default action of &lt;code&gt;:&lt;/code&gt; when in visual mode; doesn't trigger any additional mapping after insert the alternative keys (the alternative would be &lt;code&gt;vmap&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:s/\%V&lt;/code&gt;: insert your preferred default for &lt;code&gt;:&lt;/code&gt; in visual selection, so the command line will end up with &lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-12-07T10:30:03.387" LastActivityDate="2016-12-07T10:30:03.387" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10520" PostTypeId="2" ParentId="10518" CreationDate="2016-12-06T12:42:00.240" Score="3" Body="&lt;p&gt;This indeed has something to do with history: The &lt;em&gt;command ranges&lt;/em&gt; are always defined in terms of &lt;em&gt;entire lines&lt;/em&gt; (because that's what the Ex editor could handle, and vi was based on that). So, even though marks record both line and column numbers, when passed to an Ex command (like &lt;code&gt;:s&lt;/code&gt;), only the line number information is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, one could implement extensions around that (for example, use &lt;code&gt;&amp;#96;&amp;lt;,&amp;#96;&amp;gt;&lt;/code&gt; to denote block ranges). But as the internal implementations of Ex commands are based on lines, and there are quite a few of them, and there's still the question how to deal with commands that don't apply [well] to blocks, this huge change hasn't been done yet, and may never be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, the &lt;code&gt;\%V&lt;/code&gt; special atom is one workaround. I would recommend the (almost as old as Vim) &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1195&quot; rel=&quot;nofollow noreferrer&quot;&gt;vis.vim plugin&lt;/a&gt;, though. It offers a simple drop-in replacement &lt;code&gt;:'&amp;lt;,'&amp;gt;S&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-06T12:42:00.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10522" PostTypeId="2" ParentId="10510" CreationDate="2016-12-06T12:50:02.607" Score="2" Body="&lt;p&gt;To reword my comment:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I use it for simply moving the cursor? Like &lt;code&gt;5l&lt;/code&gt; - or &lt;code&gt;3w&lt;/code&gt; to jump words.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. Every motion command can be prefixed by a count.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it good practice at all? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There can be exceptions/personal preferences mitigating what will follow but the general rule is to use the motion corresponding to the amplitude of the move you want to make.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has an &lt;em&gt;enormous&lt;/em&gt; amount of motion commands which allows you to travel in your buffer at different speeds: you can have motions to go from the beginning of the buffer to the end or from one character to the next one. I will not make an explicit list here because it's a lot of work and this work has already been done very well in &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#motion.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h motion.txt&lt;/code&gt;&lt;/a&gt;. Still here are some common example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For up-down motions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Search commands allow you to travel your buffer pretty fast: &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;?&lt;/code&gt; allow you to search for occurrences of a pattern and &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; repeat this search forward or backward&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Absolute commands like &lt;code&gt;gg&lt;/code&gt;, &lt;code&gt;G&lt;/code&gt;, &lt;code&gt;[count]G&lt;/code&gt; allows you to move to first line, last line or line &lt;code&gt;[count]&lt;/code&gt; in your buffer. So does &lt;code&gt;:[count]&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For large up-down motions marks (like &lt;code&gt;'a&lt;/code&gt; or &lt;code&gt;''&lt;/code&gt;) can also be used and &lt;code&gt;%&lt;/code&gt; is useful to go to the matching character (like matching &lt;code&gt;)&lt;/code&gt; when cursor is on &lt;code&gt;(&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Text objects can also be used for that: use &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; to switch to the beginning or end of a paragraph.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For motions within a line you also have a lot of options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to beginning, first character or end of the line with &lt;code&gt;0&lt;/code&gt;,  &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Target a character with &lt;code&gt;f&lt;/code&gt; or &lt;code&gt;t&lt;/code&gt; and backward with &lt;code&gt;F&lt;/code&gt; and &lt;code&gt;T&lt;/code&gt;. Repeat these motions with &lt;code&gt;;&lt;/code&gt; or &lt;code&gt;,&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Move word wise with &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;e&lt;/code&gt;, &lt;code&gt;ge&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Move from one character to another with &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt;. *(Yeah I do recommend to use &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt;. See my note at the end)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think that it is important to make a note about &lt;code&gt;h&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some Vimmers will tell you to never use them because it's slow and repetitive and yada yada... The whole point of Vim is to use the available motions &lt;strong&gt;efficiently&lt;/strong&gt; if you need to move 3 words forward yeah that's not a good idea to press 20 times on &lt;code&gt;l&lt;/code&gt; when you could use &lt;code&gt;3w&lt;/code&gt;. &lt;strong&gt;But&lt;/strong&gt; when you need a precise motion of two or three letter &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt; are the way to go, just like &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; for moving two or three lines up or down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why I believe that plugins like &lt;a href=&quot;https://github.com/wikitopian/hardmode&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim hardmode&lt;/a&gt; are &lt;s&gt;stupid&lt;/s&gt; not the correct solution to a problem which might not even exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In conclusion read &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#motion.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h motion.txt&lt;/code&gt;&lt;/a&gt;, grok it, get used to the motions commands one by one. When you use a motion which feel inefficient, go read the page again and find the correct motion to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I often did on this site I'd also recommend to read the amazing &lt;a href=&quot;https://pragprog.com/book/dnvim/practical-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;practical vim by Drew Neil&lt;/a&gt; which has a very good chapter on motions. And &lt;a href=&quot;http://vimcasts.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimcasts&lt;/a&gt; probably also has a good reference about that (I'll let you find it ;-) )&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2016-12-06T12:50:02.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10523" PostTypeId="1" CreationDate="2016-12-06T14:22:32.940" Score="1" ViewCount="1793" Body="&lt;p&gt;I want to do some edits on each match during a global substitution operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this answer &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:% s/re\(ge\)xp/\= myfunction(submatch(1))/gc. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I don't have a function, just some keystrokes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I wrap a macro into myfunction to call during substitute?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample use: rot13(vselection) is g?, but rot13 is not a function in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s,(re)(ge)(xp),\1\=rot13(submatch(2))\3,gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found a workaround by using the bash utils without using macros &lt;a href=&quot;https://superuser.com/questions/541628/replace-a-regular-expression-within-vim-with-an-output-produced-by-a-console-com&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/m\(atm\)ul/\=substitute(':' . system('echo '.submatch(1).'|tr A-Za-z N-ZA-Mn-za-m'),'\n','','g')/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;interactively changes 'matmul' to ':ngz:'&lt;/p&gt;&#xA;" OwnerUserId="7817" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2016-12-07T15:09:26.287" Title="How to call a macro as a function in a search replace %s/regex/\=call-macro-as-function/gc" Tags="|substitute|macro|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10524" PostTypeId="2" ParentId="10523" CreationDate="2016-12-06T14:30:22.257" Score="5" Body="&lt;p&gt;I would suggest the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Record your keystrokes as a macro (here in the register &lt;code&gt;q&lt;/code&gt;) and call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/regex/normal @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will apply the macro on each found regex in your document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Content of your file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function A(){}&#xA;function B(){}&#xA;function C(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/function&amp;lt;CR&amp;gt;           &quot; search for function&#xA;qqg?gnq                 &quot; in a macro, rot13 the matched `function`&#xA;:%g//normal@q&amp;lt;CR&amp;gt;       &quot; repeat for all `function` in the file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :normal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h g?&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h gn&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2016-12-06T17:11:11.990" LastActivityDate="2016-12-06T17:11:11.990" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10525" PostTypeId="1" CreationDate="2016-12-06T14:55:23.687" Score="2" ViewCount="252" Body="&lt;p&gt;In Vim 7.4, I used to effectively deploy the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=670&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;visincr.vim&lt;/code&gt;&lt;/a&gt; plugin for such a task. However, I have recently moved to neovim and this won't work anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The errors produced by &lt;code&gt;:so %&lt;/code&gt; fills up the whole screen. Every line in the vimball raises the standard error: &lt;code&gt;Not an editor command.&lt;/code&gt;, followed by insanely long lines of cryptic characters and control sequences such as &lt;code&gt;&amp;lt;e4&amp;gt;&amp;lt;ab&amp;gt;͔&amp;lt;f8&amp;gt;&amp;lt;94&amp;gt;&amp;lt;99&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone advise on the compatibility of this vimball plugin and neovim ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have unzipped the file and tried again. Now, it gives the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E492: Not an editor command : UseVimball&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Update 2:&#xA;This has now been solved. I had to run :packadd vimball before attempting :so %.  The vimball also had to be moved to one of the $VIMRUNTIME directories.  Thanks to all who helped :) &lt;/p&gt;&#xA;" OwnerUserId="8408" LastEditorUserId="8408" LastEditDate="2016-12-06T15:21:43.577" LastActivityDate="2016-12-06T15:21:43.577" Title="visincr.vim compatibility with Neovim" Tags="|neovim|plugin-system|vimball|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="10526" PostTypeId="2" ParentId="10523" CreationDate="2016-12-06T15:26:57.830" Score="0" Body="&lt;p&gt;With &lt;code&gt;:substitute&lt;/code&gt; (especially the &lt;em&gt;replace with expression&lt;/em&gt;), you get the exact match (or any submatches), and you can transform / reorder / invoke functions on that easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normal mode commands (like &lt;code&gt;g?&lt;/code&gt;) can directly edit text, but they usually work on lines or text covered by &lt;code&gt;{motion}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you're asking for is a cross between the two. Since there is not &lt;code&gt;rot13()&lt;/code&gt; built-in function, you either have to provide that yourself (and then use &lt;code&gt;:s//\=rot13(submatch(0))&lt;/code&gt;), &lt;strong&gt;or&lt;/strong&gt; relinquish the regexp matching of &lt;code&gt;:s&lt;/code&gt; and use &lt;code&gt;:global&lt;/code&gt; (and / or &lt;code&gt;:call search()&lt;/code&gt;) in combination with &lt;code&gt;:normal! g?&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-06T15:26:57.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10527" PostTypeId="1" AcceptedAnswerId="10529" CreationDate="2016-12-06T17:58:31.470" Score="1" ViewCount="414" Body="&lt;p&gt;I have a Fedora COPR (&lt;a href=&quot;https://copr.fedorainfracloud.org/coprs/dperson/neovim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;personal repo link&lt;/a&gt;). It's in the NeoVim wiki Fedora installation section. There's been interest in getting it into the main Fedora repo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Koji (the Fedora build tool for all official packages) doesn't allow internet access during a build, though. And I can't figure out how to bundle the LuaRocks modules into the SRPM, or even exactly what I should bundle... any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My spec file can be found &lt;a href=&quot;https://au2pb.org/srpms/neovim-stable.spec&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, if it helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="10406" LastActivityDate="2016-12-06T19:43:49.073" Title="NeoVim: how to build luarocks (and it's modules) without internet access?" Tags="|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10528" PostTypeId="2" ParentId="467" CreationDate="2016-12-06T19:24:27.217" Score="6" Body="&lt;p&gt;Put this in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! WipeReg for i in range(34,122) | silent! call setreg(nr2char(i), []) | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and clear every register with &lt;code&gt;:WipeReg&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like that to happen every time you start Vim also add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * WipeReg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2016-12-06T19:24:27.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10529" PostTypeId="2" ParentId="10527" CreationDate="2016-12-06T19:43:49.073" Score="1" Body="&lt;p&gt;If you build with &lt;code&gt;make USE_BUNDLED_DEPS=OFF&lt;/code&gt; (or &lt;code&gt;cmake -DUSE_BUNDLED=OFF&lt;/code&gt; if you're directly running cmake), then none of the 3rd-party dependencies will be built.  It will use whatever is available on the system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case, you don't need LuaRocks at all.  You just need to have the required lua modules packaged.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2016-12-06T19:43:49.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10530" PostTypeId="1" CreationDate="2016-12-06T19:45:33.413" Score="2" ViewCount="395" Body="&lt;p&gt;I'm a tabs kind of guy, so I highlight leading and trailing white spaces with the following commands in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight whiteSpace_trailing ctermbg=red guibg=red&#xA;highlight whiteSpace_leading  ctermbg=red guibg=red&#xA;match  whiteSpace_trailing /\s\+$/&#xA;2match whiteSpace_leading /^ \+/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine when I have only one window open. However, when opening a second window with visual splits for example, these specs are not taken into account. Any idea why and how to fix it?&lt;/p&gt;&#xA;" OwnerUserId="4562" LastEditorUserId="1841" LastEditDate="2016-12-07T13:06:48.017" LastActivityDate="2016-12-07T13:06:48.017" Title="Custom highlights not working in visual splits" Tags="|vimrc|syntax-highlighting|whitespace|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10532" PostTypeId="2" ParentId="10513" CreationDate="2016-12-07T00:54:17.267" Score="2" Body="&lt;p&gt;This is a shell command run with &lt;code&gt;:silent! !okular [..]&lt;/code&gt; in the &lt;code&gt;Tex_ForwardSearchLaTeX()&lt;/code&gt; function (&lt;code&gt;ftplugin/latex-suite/compiler.vim&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like &lt;code&gt;okular&lt;/code&gt; is printing some text to stdout or stderr – the &lt;code&gt;silent!&lt;/code&gt; command only silences Vim &lt;code&gt;:echo&lt;/code&gt; and &lt;code&gt;:echoerr&lt;/code&gt; messages, not stdout from external programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this you'll need to add something like &lt;code&gt;&amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;/code&gt; to the end of the shell command. As far as I can see this plugin provides no such facility, but you could modify the source yourself. For example change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute execString&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute execString . '&amp;gt;/ dev/null 2&amp;gt;&amp;amp;1'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also consider writing to the maintainer (listed at the top of &lt;code&gt;:help latex-suite.txt&lt;/code&gt;) of the plugin to implement this as an option.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-12-07T00:54:17.267" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10533" PostTypeId="1" CreationDate="2016-12-07T06:49:05.983" Score="0" ViewCount="20" Body="&lt;p&gt;If I have a really long line, vim truncates it with &lt;code&gt;set nowrap&lt;/code&gt;. If I &lt;code&gt;set wrap&lt;/code&gt;, I can see all of the text, unless (after wrapping) it is too long to show all of it on the screen. For example, if the second line of my file is very long, none of it is shown at all. Instead, vim shows &lt;code&gt;@&lt;/code&gt; on each line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text on line 1&#xA;@&#xA;@&#xA;@&#xA;@&#xA;@&#xA;@&#xA;@&#xA;&amp;lt;status line&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While using &lt;code&gt;set wrap&lt;/code&gt;, s there a way to get vim to show what it can of this long line, even if it wraps off the bottom of the window?&lt;/p&gt;&#xA;" OwnerUserId="1278" LastActivityDate="2016-12-07T06:49:05.983" Title="How can I show all of a long line, even if it wraps off the bottom of the screen?" Tags="|wrapping|" AnswerCount="0" CommentCount="3" ClosedDate="2016-12-07T10:36:04.313" ContentLicense="CC BY-SA 3.0" />
  <row Id="10534" PostTypeId="1" AcceptedAnswerId="10535" CreationDate="2016-12-07T09:12:34.653" Score="16" ViewCount="7000" Body="&lt;p&gt;I'm using Vim as a 3-way merge too with Git and sometimes need to take changes from both local and remote branches. &lt;code&gt;kdiff3&lt;/code&gt; can do this with a couple of key presses, is there a way to do this in Vim?&lt;/p&gt;&#xA;" OwnerUserId="5528" LastActivityDate="2022-03-03T20:07:39.080" Title="Is there a way to &quot;take both&quot; when using Vim as merge tool?" Tags="|vimdiff|merge|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10535" PostTypeId="2" ParentId="10534" CreationDate="2016-12-07T10:46:07.317" Score="8" Body="&lt;p&gt;Not exactly what you asked, but may find this useful: &lt;a href=&quot;http://vimawesome.com/plugin/splice&quot; rel=&quot;noreferrer&quot;&gt;Splice plugin: a Vim plugin for resolving conflicts during three-way merge&lt;/a&gt;. &#xA;It has a nice &lt;a href=&quot;https://vimeo.com/25764692&quot; rel=&quot;noreferrer&quot;&gt;demo screencast on Vimeo&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are going to stick with the default vimdiff you could create a function to retrieve the buffer number for the surronding windows and use them to call &lt;code&gt;:diffget&lt;/code&gt; twice:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *:diffg* *:diffget*&#xA;:[range]diffg[et] [bufspec]&#xA;        Modify the current buffer to undo difference with another&#xA;        buffer.  If [bufspec] is given, that buffer is used.  If&#xA;        [bufspec] refers to the current buffer then nothing happens.&#xA;        Otherwise this only works if there is one other buffer in diff&#xA;&#xA;(...)&#xA;&#xA;The [bufspec] argument above can be a buffer number, a pattern for a buffer&#xA;name or a part of a buffer name.  Examples:&#xA;&#xA;    :diffget        Use the other buffer which is in diff mode&#xA;    :diffget 3      Use buffer 3&#xA;    :diffget v2     Use the buffer which matches &quot;v2&quot; and is in&#xA;                diff mode (e.g., &quot;file.c.v2&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could them use a mapping to assign a call to this function to the keys you were used in &lt;code&gt;kdiff3&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find further information &lt;a href=&quot;http://vimcasts.org/episodes/fugitive-vim-resolving-merge-conflicts-with-vimdiff/&quot; rel=&quot;noreferrer&quot;&gt;on this vimcast&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="24" LastEditDate="2016-12-08T17:33:24.163" LastActivityDate="2016-12-08T17:33:24.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10536" PostTypeId="2" ParentId="6716" CreationDate="2016-12-07T14:04:53.120" Score="6" Body="&lt;p&gt;Although there is no specific syntax for aliases you can achieve the same effect by using &lt;code&gt;post_jump&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# c.snippets&#xA;global !p&#xA;def expand(snip):&#xA;    if snip.tabstop != 1:&#xA;        return&#xA;    vim.eval('feedkeys(&quot;\&amp;lt;C-R&amp;gt;=UltiSnips#ExpandSnippet()\&amp;lt;CR&amp;gt;&quot;)')&#xA;endglobal&#xA;&#xA;snippet incstdlib &quot;#include &amp;lt;stdlib.h&amp;gt;&quot; !b&#xA;#include &amp;lt;stdlib.h&amp;gt; /* exit(), malloc(), free() */&#xA;$0&#xA;endsnippet&#xA;&#xA;post_jump &quot;expand(snip)&quot;&#xA;snippet incexit &quot;#include &amp;lt;stdlib.h&amp;gt;&quot; !b&#xA;incstdlib$1&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this snippets file the trigger &lt;code&gt;incexit&lt;/code&gt; is an &quot;alias&quot; of trigger &lt;code&gt;incstdlib&lt;/code&gt;. In reality &lt;code&gt;incexit&lt;/code&gt; expands to &lt;code&gt;incstdlib&lt;/code&gt; and the &lt;code&gt;expand(snip)&lt;/code&gt; is called when UltiSnips moves to the tabstop &lt;code&gt;$1&lt;/code&gt;. The &lt;code&gt;expand(snip)&lt;/code&gt; just executes the VimScript function &lt;code&gt;UltiSnips#ExpandSnippet&lt;/code&gt; which will expand &lt;code&gt;incstdlib&lt;/code&gt; into it's final expanded form &lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another options is to use UltiSnips regular expression support instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet &quot;inc(true|false|bool)&quot; &quot;#include &amp;lt;stdbool.h&amp;gt;&quot; r&#xA;#include &amp;lt;stdbool.h&amp;gt; /* true, false */&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here you will have three triggers &lt;code&gt;inctrue&lt;/code&gt;, &lt;code&gt;incfalse&lt;/code&gt; and &lt;code&gt;incbool&lt;/code&gt; that are effectively the same. The only drawback is that autocompletion plugins like YouCompleteMe will not autocomplete those.&lt;/p&gt;&#xA;" OwnerUserId="2766" LastActivityDate="2016-12-07T14:04:53.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10537" PostTypeId="2" ParentId="10534" CreationDate="2016-12-07T16:33:24.677" Score="7" Body="&lt;p&gt;&lt;kbd&gt;y&lt;/kbd&gt;ank and &lt;kbd&gt;p&lt;/kbd&gt;ut can work without any plugins or extra functions, though it is, perhaps, a bit less convenient than &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt; or &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;p&gt;Just copy the needed bits from the parent buffers and paste them into the correct spot in the merged buffer. This is also useful if you want just part of a diff block, rather than the whole thing.&lt;/p&gt;&#xA;&lt;p&gt;You may, at times, need to force Vim to update the diff highlighting with &lt;code&gt;:diffupdate&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastEditorUserId="2736" LastEditDate="2020-07-01T20:32:08.993" LastActivityDate="2020-07-01T20:32:08.993" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10538" PostTypeId="1" AcceptedAnswerId="10540" CreationDate="2016-12-07T16:43:28.790" Score="1" ViewCount="1099" Body="&lt;p&gt;I'm using &lt;code&gt;vim&lt;/code&gt; 8.0.94.  In a TeX file (specifically LaTeX), the three occurrences of &lt;code&gt;\(\)&lt;/code&gt; in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(\)&#xA;{\(\)}&#xA;{\(\)}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be highlighted in the same way, but they are not.  Curiously, in the second, but &lt;em&gt;not&lt;/em&gt; the third, the &lt;code&gt;\(&lt;/code&gt; is marked as plain text, and the &lt;code&gt;\)&lt;/code&gt; is marked as an error.  I used to be able to find my way around &lt;code&gt;syntax.vim&lt;/code&gt; files, but the TeX one is too complicated for me to figure out what's causing this.  (I don't even know whether to look in the command section or the math-mode section.)&lt;/p&gt;&#xA;" OwnerUserId="2108" LastActivityDate="2016-12-07T20:25:34.987" Title="Fix syntax highlighting in LaTeX" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10539" PostTypeId="1" CreationDate="2016-12-07T19:19:10.690" Score="8" ViewCount="1364" Body="&lt;p&gt;I have a lot of files that have spaces in their names, and this is giving me problems. If I try to do command line completion for the find command, and one of these files come up, Vim will find it, but it won't load because the spaces aren't escaped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: I'm in vim already, and I type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:find fo&amp;lt;Tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To complete &lt;code&gt;foo bar.txt&lt;/code&gt;,&#xA;Vim then finds it and throws an error because it expects only one filename.&#xA;Meaning it now reads&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:find foo bar.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which doesn't load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to work around this, and have Vim automatically escape the spaces?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using VimTouch, which runs Vim 7.3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I recently realized that Vim will escape path names for me, but mysteriously won't do so for filenames.&lt;/p&gt;&#xA;" OwnerUserId="10421" LastEditorUserId="10421" LastEditDate="2016-12-25T04:46:19.783" LastActivityDate="2016-12-25T18:47:12.400" Title="Filename Completion with Spaces" Tags="|autocompletion|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10540" PostTypeId="2" ParentId="10538" CreationDate="2016-12-07T20:25:34.987" Score="2" Body="&lt;p&gt;You can get the name of the syntax item under the cursor with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo synIDattr(synID(line('.'), col('.'), 1), 'name')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, it's apparently &lt;code&gt;texBadMath&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at &lt;code&gt;/usr/share/vim/vim80/syntax/tex.vim&lt;/code&gt; I see there are three &lt;code&gt;syn match&lt;/code&gt; commands for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Bad Math (mismatched): {{{1&#xA;if !exists(&quot;g:tex_no_math&quot;) &amp;amp;&amp;amp; !s:tex_no_error&#xA; syn match texBadMath           &quot;\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|subequations\|smallmatrix\|xxalignat\)\s*}&quot;&#xA; syn match texBadMath           &quot;\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}&quot;&#xA; syn match texBadMath           &quot;\\[\])]&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;s:tex_no_error&lt;/code&gt; is set from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;g:tex_no_error&quot;) &amp;amp;&amp;amp; g:tex_no_error&#xA; let s:tex_no_error= 1&#xA;else&#xA; let s:tex_no_error= 0&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And is documented:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; 5. If you have the variable &quot;g:tex_no_error&quot; defined then none of the&#xA;&quot;    lexical error-checking will be done.&#xA;&quot;&#xA;&quot;    ie. let g:tex_no_error=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So adding this to your vimrc is the easiest option. This should result in:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AUSMD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AUSMD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A more difficult route is to fix this syntax file. The line that causes this error is the last one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match texBadMath          &quot;\\[\])]&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\&lt;/code&gt;s make it a bit confusing, but a literal &lt;code&gt;\&lt;/code&gt; followed by a &lt;code&gt;]&lt;/code&gt; or &lt;code&gt;)&lt;/code&gt; is considered an error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not really familiar with TeX, but this should be comprativly easy to fix. You could contact the author of the file, which is listed at the top.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-12-07T20:25:34.987" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10541" PostTypeId="2" ParentId="12" CreationDate="2016-12-07T20:47:09.990" Score="4" Body="&lt;p&gt;I know this question is really old, but there's another way you can do it also. Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;99o&amp;lt;esc&amp;gt;:%s/^/\=line('.')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;99o&amp;lt;esc&amp;gt;&lt;/code&gt; will just open up 100 blank lines. Then, we run a substitute command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%                  &quot; On every line&#xA;  s/                &quot; substitute&#xA;    ^/              &quot; the start of the line. (This will always match no matter what)&#xA;      \=            &quot; Evaluate:&#xA;        line('.')   &quot; The current line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2016-12-07T20:47:09.990" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10542" PostTypeId="2" ParentId="10497" CreationDate="2016-12-07T22:16:58.930" Score="8" Body="&lt;p&gt;You can omit &lt;code&gt;tab&lt;/code&gt; from &lt;code&gt;listchars&lt;/code&gt;, but that will cause vim to fall back on the default (showing tabs as &lt;code&gt;^I&lt;/code&gt;). So using &lt;code&gt;tab:\ \&lt;/code&gt; as you have is a reasonable way to keep them &quot;invisible&quot; when &lt;code&gt;list&lt;/code&gt; is set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The characters shown with &lt;code&gt;list&lt;/code&gt; are highlighted with the &lt;code&gt;SpecialKey&lt;/code&gt; or &lt;code&gt;NonText&lt;/code&gt; groups, depending. Tabs, in particular, use &lt;code&gt;SpecialKey&lt;/code&gt;, so it sounds like your color scheme has a background color for that particular group (see: &lt;code&gt;:help listchars&lt;/code&gt; for more).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately &lt;code&gt;SpecialKey&lt;/code&gt; is used for &lt;code&gt;trail&lt;/code&gt; as well, so whatever changes you make there for &lt;code&gt;tab&lt;/code&gt; will apply to &lt;code&gt;trail&lt;/code&gt; as well. If you go this route, you will only be able to change the foreground color of &lt;code&gt;SpecialKey&lt;/code&gt;, really, without visibly impacting the tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One alternative might be to avoid using &lt;code&gt;list&lt;/code&gt; at all; in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match TrailingSpace /\s\+$/&#xA;hi TrailingSpace guibg=red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for example, will highlight trailing whitespace with a red background independent of whatever you have going on with &lt;code&gt;list&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user72" LastEditorDisplayName="user72" LastEditDate="2016-12-07T22:25:13.327" LastActivityDate="2016-12-07T22:25:13.327" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10543" PostTypeId="1" AcceptedAnswerId="10546" CreationDate="2016-12-08T01:32:29.080" Score="1" ViewCount="187" Body="&lt;p&gt;The &lt;code&gt;sign&lt;/code&gt; help says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;linehl={group}&#xA;        Highlighting group used for the whole line the sign is placed&#xA;        in.  Most useful is defining a background color.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a special group I can use (like &lt;code&gt;SignRow&lt;/code&gt;)? Maybe there is a way to provide a specific colour instead of a highlight group? I tried &lt;code&gt;sign define wholeline linehl=162&lt;/code&gt; but it doesn't work. I'd like to use special colour for &lt;code&gt;linehl&lt;/code&gt; so I want to avoid reusing any unrelated highlight group for this purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only highlight group related to &lt;code&gt;sign&lt;/code&gt; I was able to find is &lt;code&gt;SignColumn&lt;/code&gt; which is not what I am looking for.&lt;/p&gt;&#xA;" OwnerUserId="6043" LastEditorUserId="205" LastEditDate="2016-12-08T04:17:57.923" LastActivityDate="2016-12-08T11:24:21.527" Title="Which highlight-group should I use for :sign define x linehl?" Tags="|highlight|signs|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10544" PostTypeId="1" AcceptedAnswerId="10548" CreationDate="2016-12-08T02:20:42.220" Score="5" ViewCount="2830" Body="&lt;p&gt;I need to transform the full-width characters(&lt;code&gt;ＮＢＡ&lt;/code&gt;) in the following sentence to half-width ones.  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ＮＢＡ中曾有“怒吼天尊”之称的已退役球员是谁? 拉希德·华莱士&lt;br&gt;&#xA;  Ｈ５Ｎ２疫苗可对抗Ｈ５禽流感病毒&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I know I can realize it in Python using &lt;code&gt;unicodedata.normalize&lt;/code&gt; module(with a parameter &quot;NFKC&quot;). But is there any method to do it directly in Vim? I have tried &lt;code&gt;char2nr&lt;/code&gt; and &lt;code&gt;eval&lt;/code&gt; and found that they don't work. &lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="1788" LastEditDate="2016-12-08T07:57:08.967" LastActivityDate="2016-12-11T20:42:34.413" Title="(How) can I convert full-width characters to half-width ones?" Tags="|unicode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10546" PostTypeId="2" ParentId="10543" CreationDate="2016-12-08T11:24:21.527" Score="3" Body="&lt;p&gt;Highlight groups are an abstraction over the colors and styles that are available in the terminal or GUI. Vim has default groups built-in (and these are referenced by the syntax plugins), and a &lt;em&gt;colorscheme&lt;/em&gt; provides corresponding color / style definitions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is perfectly fine to define your own, custom highlight group, and then use that for commands like &lt;code&gt;:sign&lt;/code&gt; and &lt;code&gt;:match&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight MySign ctermbg=162&#xA;:sign define wholeline linehl=MySign&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you switch colorschemes often, or already have found a proper highlighting in your colorscheme, you can also just &lt;em&gt;link&lt;/em&gt; your new group to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight link MySign Identifier&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-08T11:24:21.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10547" PostTypeId="1" CreationDate="2016-12-08T11:35:51.393" Score="1" ViewCount="1908" Body="&lt;p&gt;I use the following settings to hide the netrw banner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_banner=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know that this also displays the current directory, but it also displays a bunch of other things I'm not interested in. I just want to see the current place I'm in while using netrw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an option to reconfigure the banner? Or other alternative to display only the path I'm in netrw?&lt;/p&gt;&#xA;" OwnerUserId="2710" LastActivityDate="2016-12-14T00:17:36.133" Title="How to display netrw's current path? The default banner is to stuffed" Tags="|netrw|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10548" PostTypeId="2" ParentId="10544" CreationDate="2016-12-08T12:09:24.550" Score="6" Body="&lt;p&gt;There you go:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/[\uff01-\uff5e]/\=nr2char(char2nr(submatch(0))-65248)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This matches the range of full-width characters, and via &lt;code&gt;:help sub-replace-expr&lt;/code&gt; and &lt;code&gt;char2nr()&lt;/code&gt; converts this to a number, subtracts to get this into the ASCII range for &lt;code&gt;!&lt;/code&gt; - &lt;code&gt;~&lt;/code&gt;, and converts it back to characters.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Addendum&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you need to support other (non-contiguous) characters, you can define a Map and check that first. For example, for the arrow symbols mentioned in your comment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:fullToHalf = { &quot;\u2190&quot;: &quot;\uFFE9&quot;, &quot;\u2192&quot;: &quot;\uFFEB&quot;, &quot;\u2191&quot;: &quot;\uFFEA&quot;, &quot;\u2193&quot;: &quot;\uFFEC&quot; }&#xA;:execute '%s/[\uff01-\uff5e' . join(keys(g:fullToHalf), ''). ']/\=get(g:fullToHalf, submatch(0), nr2char(char2nr(submatch(0))-65248))/g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: As a one-liner, this gets really ugly. I would strongly recommend to put this into a function.&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2016-12-11T20:42:34.413" LastActivityDate="2016-12-11T20:42:34.413" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10549" PostTypeId="1" AcceptedAnswerId="10551" CreationDate="2016-12-08T13:50:25.080" Score="2" ViewCount="1107" Body="&lt;p&gt;How can I match the outest bracket and replace it with &lt;code&gt;$$&lt;/code&gt; in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{a+b&amp;gt;c} --&amp;gt; $a+b&amp;gt;c$&#xA;&#xA;{a+{\int_a^bf(x)dx=\set{a+c}}} --&amp;gt; $a+{\int_a^bf(x)dx=\set{a+c}}$&#xA;&#xA;{a+{b+c}+d} and {e+{f}+g} --&amp;gt; $a+{b+c}+d$ and $a+{f}+g$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;UPDATE&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;By @Ingo Karkat's  fascinating answer, I can search and replace correctly on each file. I would like to make this more easy to operate by:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;All my file are with filetype &lt;code&gt;tex&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;I would like to define a shortcut key to make the search and replace though out the file with &lt;code&gt;ft=tex&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How can I do that? (I know this is maybe off topic, and I should solve it by reading vim's doc, but it will take me a lot of time since I am just a begginer user of vim...)&lt;/p&gt;&#xA;" OwnerUserId="10430" LastEditorUserId="10430" LastEditDate="2016-12-09T01:37:20.887" LastActivityDate="2016-12-09T01:37:20.887" Title="vim match the outest bracket" Tags="|regular-expression|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10550" PostTypeId="2" ParentId="10549" CreationDate="2016-12-08T14:41:54.553" Score="2" Body="&lt;p&gt;As long as there's only one such construct on each line, a simple greedy match (&lt;code&gt;.*&lt;/code&gt;) will do. Capture the inner parts (including any &lt;code&gt;{...}&lt;/code&gt; inside, up to the last available) in a &lt;em&gt;named capture&lt;/em&gt;, and replace with &lt;code&gt;$&lt;/code&gt;, captured text, &lt;code&gt;$&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/{\(.*\)}/$\1$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now, if there can be multiple constructs on a single line (e.g. &lt;code&gt;{a+b&amp;gt;c} and {a+{\int_a^bf(x)dx=\set{a+c}}}&lt;/code&gt;), and you want to replace each (i.e. &lt;code&gt;$a+b&amp;gt;c$ and $a+{\int_a^bf(x)dx=\set{a+c}}$&lt;/code&gt;, not &lt;code&gt;$a+b&amp;gt;c} and {a+{\int_a^bf(x)dx=\set{a+c}}$&lt;/code&gt;, that's a whole different dimension. You would need to match opening and closing curly braces, something which cannot be done with Vim's regular expressions at all.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-08T14:41:54.553" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10551" PostTypeId="2" ParentId="10549" CreationDate="2016-12-08T15:15:41.993" Score="3" Body="&lt;p&gt;Here's a macro approach that uses the &lt;code&gt;%&lt;/code&gt; command to jump to matching curly braces. In contrast to my regular expression solution, this one handles multiple constructs in a line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Preparation: Don't let search wrap around, the recursive macro would not end and eat into inner braces, too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nowrapscan&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Search for and go to the first opening brace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg/{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Clear register &lt;code&gt;q&lt;/code&gt; and start recording:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqqqq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Go to matching closing brace, back to front, replace, back to end, replace, go to next match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%``r$``r$n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Recursively invoke macro, end macro recording, invoke macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@qq@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-08T15:15:41.993" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10552" PostTypeId="2" ParentId="10549" CreationDate="2016-12-08T15:44:50.497" Score="2" Body="&lt;p&gt;Also, if you like plugins, you can use &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-surround&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{a+b&amp;gt;c}&#xA;^&#xA;cursor here, type: cs{$   (Change Surrounding { by $ )&#xA;v&#xA;{a+{\int_a^bf(x)dx=\set{a+c}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have to move yourself to the outer &lt;em&gt;context&lt;/em&gt; but once you're there, it's straightforward.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-12-08T15:44:50.497" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10556" PostTypeId="2" ParentId="10471" CreationDate="2016-12-08T21:13:52.343" Score="1" Body="&lt;p&gt;Disabling netrw is easy: put &lt;code&gt;let g:loaded_netrw= 1&lt;/code&gt;  and &lt;code&gt;let g:netrw_loaded_netrwPlugin= 1&lt;/code&gt; into your .vimrc.  That way netrw won't be loaded, none of its maps installed, etc.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2016-12-08T21:13:52.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10557" PostTypeId="1" CreationDate="2016-11-30T20:59:17.993" Score="2" ViewCount="92" Body="&lt;p&gt;I've been doing edit-save-run-bugfix-repeat on a Python test script, using &lt;code&gt;vim&lt;/code&gt; as my editor. My directory now looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-rwxrwxr-x 1 james james   458 Nov 29 23:02 test.pr~*&#xA;-rwxrwxr-x 1 james james   504 Nov 29 22:53 test.ps~*&#xA;-rwxrwxr-x 1 james james   485 Nov 29 22:51 test.pt~*&#xA;-rwxrwxr-x 1 james james   503 Nov 29 22:48 test.pu~*&#xA;-rwxrwxr-x 1 james james   504 Nov 29 22:48 test.pv~*&#xA;-rwxrwxr-x 1 james james   485 Nov 29 22:40 test.pw~*&#xA;-rwxrwxr-x 1 james james   262 Nov 29 22:36 test.px~*&#xA;-rwxrwxr-x 1 james james   456 Nov 29 23:04 test.py*&#xA;-rwxrwxr-x 1 james james    96 Nov 28 22:29 test.py~*&#xA;-rwxrwxr-x 1 james james   109 Nov 29 22:20 test.pz~*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was only expecting to see &lt;code&gt;test.py&lt;/code&gt;. I'm guessing it was &lt;code&gt;vim&lt;/code&gt; that did this, as they appear to be backups of the file taken at various stages of editing. But why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: here is my &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; My Vim config file&#xA;&quot; The directory setting is a comma separated list of directories where&#xA;&quot; vim should place swapfiles. Each path is tried in order and the first&#xA;&quot; one that doesn’t fail (because it doesn’t exist or for permissions&#xA;&quot; reasons) is where vim will create swapfiles. By default on unix&#xA;&quot; systems, it it set to “.,~/tmp,/var/tmp,/tmp” which means it first&#xA;&quot; tries “.” or the same directory as the file being edited. By using ^=,&#xA;&quot; we tell vim to prepend the given value to those already set (the&#xA;&quot; defaults). This allows vim to fall back to other directories should&#xA;&quot; the specified one fail for some reason (directory doesn’t exist or&#xA;&quot; disk is full for example). The double slash at the end tells vim to&#xA;&quot; form swap file names using the full path of the edited file, replacing&#xA;&quot; / with %, avoiding name conflicts. See :help directory for more&#xA;&quot; details.&#xA;set directory^=$HOME/.vim_swap//&#xA;set background=dark&#xA;&#xA;set tw=120&#xA;au BufRead *.sh,*.py set tw=0&#xA;au BufRead *.txt set tw=80&#xA;syntax on&#xA;filetype on&#xA;filetype plugin on&#xA;filetype indent on&#xA;inoremap &amp;lt;F5&amp;gt; &amp;lt;C-R&amp;gt;=strftime(&quot;%Y-%m-%d %H:%M&quot;)&amp;lt;CR&amp;gt;&#xA;set hlsearch&#xA;set incsearch&#xA;set expandtab&#xA;set softtabstop=4&#xA;set shiftwidth=4&#xA;&quot;highlight OverLength ctermbg=red ctermfg=white guibg=#592929&#xA;&quot;match OverLength /\%81v.*/&#xA;&#xA;&quot;Tell vim to remember certain things when we exit&#xA;&quot;  '10  :  marks will be remembered for up to 10 previously edited files&#xA;&quot;  &quot;100 :  will save up to 100 lines for each register&#xA;&quot;  :20  :  up to 20 lines of command-line history will be remembered&#xA;&quot;  %    :  saves and restores the buffer list&#xA;&quot;  n... :  where to save the viminfo files&#xA;set viminfo='10,\&quot;100,:20,%,n~/.viminfo&#xA;function! ResCur()&#xA;  if line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;)&#xA;    normal! g`&quot;&#xA;    return 1&#xA;  endif&#xA;endfunction&#xA;&#xA;augroup resCur&#xA;  autocmd!&#xA;  autocmd BufWinEnter * call ResCur()&#xA;augroup END&#xA;&#xA;set cm=blowfish &quot; default is zip; insecure.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="49524" OwnerDisplayName="jl6" LastEditorUserId="51" LastEditDate="2017-01-05T18:18:25.943" LastActivityDate="2017-01-05T18:18:25.943" Title="What generates .pz~ backup files from .py files?" Tags="|save|" AnswerCount="0" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10558" PostTypeId="2" ParentId="1889" CreationDate="2016-12-09T00:36:04.373" Score="0" Body="&lt;p&gt;Segmentation faults may also be connected to interacting servers like netbeans and an &lt;code&gt;autocmd&lt;/code&gt; that invalidates a buffer (e.g. &lt;code&gt;BufNewFile&lt;/code&gt; operations) that another program (plugin, ...) expects (or similar) in the &lt;code&gt;.vim&lt;/code&gt; configuration, try commenting those lines in e.g. the &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typical error message is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;missing ! or / in &amp;lt;number&amp;gt;:&amp;lt;command&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where&#xA;&lt;code&gt;command&lt;/code&gt; can be e.g. &lt;code&gt;editFile&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10437" LastActivityDate="2016-12-09T00:36:04.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10560" PostTypeId="2" ParentId="10482" CreationDate="2016-12-09T02:27:54.443" Score="5" Body="&lt;p&gt;You seem to be looking for MacVim Preferences, and they are under the MenuBar entitled &quot;MacVim&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;MacVim -&gt; Preferences -&gt; General&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There you'll find settings for what to do on startup, and after the last MacVim window closes. You can decide to automatically open a blank window on startup, and also for when &quot;the last window closes&quot; you can check &quot;Leave MacVim Running&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There doesn't seem to be a setting to &lt;em&gt;automatically&lt;/em&gt; open a new blank window when the last MacVim window closes, but you can easily hit &lt;kbd&gt;&amp;#8984;&lt;/kbd&gt;+&lt;kbd&gt;N&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10441" LastActivityDate="2016-12-09T02:27:54.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10562" PostTypeId="1" AcceptedAnswerId="10563" CreationDate="2016-12-09T10:42:16.137" Score="64" ViewCount="20131" Body="&lt;p&gt;I have a large JSON file. It is not easy to work on all file at a time.&#xA;I want to fold some content so that I can work on a section of JSON file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g.: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  obj: {+}, // folded section&#xA;  obj:{&#xA;        // unfolded section&#xA;     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to fold JSON structure in Vim?&lt;/p&gt;&#xA;" OwnerUserId="5890" LastEditorUserId="467" LastEditDate="2017-01-20T14:54:42.630" LastActivityDate="2023-06-12T16:10:27.687" Title="How to fold text in a JSON file?" Tags="|gvim|folding|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10563" PostTypeId="2" ParentId="10562" CreationDate="2016-12-09T11:03:12.280" Score="96" Body="&lt;p&gt;Yes, it is possible. A minimal setup would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set filetype=json&#xA;:syntax on&#xA;:set foldmethod=syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="14340" LastEditDate="2018-08-30T09:18:29.707" LastActivityDate="2018-08-30T09:18:29.707" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="10564" PostTypeId="1" AcceptedAnswerId="10565" CreationDate="2016-12-09T11:59:22.010" Score="2" ViewCount="271" Body="&lt;p&gt;I use &lt;code&gt;foldmethod=marker&lt;/code&gt; in vim with default &lt;code&gt;{{{&lt;/code&gt; and &lt;code&gt;}}}&lt;/code&gt; markers and &lt;code&gt;zf&lt;/code&gt;command to fold/unfold visually selected blocks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works fine in most file types, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*{{{*/&#xA;console.log(&quot;this is a javascript file&quot;)&#xA;/*}}}*/&#xA;&#xA;&amp;lt;!--{{{--&amp;gt;&#xA;&amp;lt;p&amp;gt;This is a HTML file&amp;lt;/p&amp;gt;&#xA;&amp;lt;!--}}}--&amp;gt;&#xA;&#xA;/*{{{*/&#xA;/* This is a css file */&#xA;/*}}}*/&#xA;&#xA;#{{{&#xA;echo &quot;this is a bash script&quot;&#xA;#}}}&#xA;&#xA;Etc...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in SQL files, it uses common &lt;code&gt;/*&lt;/code&gt; ... &lt;code&gt;*/&lt;/code&gt; syntax which, at least for PostgreSQL is invalid.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//{{{&#xA;select 'This is a SQL file'&#xA;//}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also use &lt;a href=&quot;https://github.com/vim-scripts/tComment&quot; rel=&quot;nofollow noreferrer&quot;&gt;tcomment&lt;/a&gt; pluggin to comment in and out things with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;-&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;-&lt;/kbd&gt; and it works well with SQL files too so I think it should be an issue with &lt;code&gt;zf&lt;/code&gt; command itself or some configuration parameter which I doesn't know. But I don't know where to look for...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- select 'This is a commented out query'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any clue or suggestion will be welcomed.&lt;/p&gt;&#xA;" OwnerUserId="9576" LastEditorUserId="51" LastEditDate="2016-12-09T16:35:22.397" LastActivityDate="2016-12-09T16:35:22.397" Title="Comment out characters for zf" Tags="|folding|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10565" PostTypeId="2" ParentId="10564" CreationDate="2016-12-09T12:57:18.400" Score="2" Body="&lt;p&gt;As worked out in comments, solution is to set proper &lt;code&gt;commentstring&lt;/code&gt;. The default is for &lt;code&gt;sql&lt;/code&gt; file to &lt;code&gt;commentstring=/*%s*/&lt;/code&gt;. So in this case you need to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set commentstring=--%s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can automate it via autocmmand or by modeline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- vim:set commentstring=--%s:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType sql set commentstring=--%s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-12-09T12:57:18.400" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10566" PostTypeId="1" AcceptedAnswerId="10569" CreationDate="2016-12-09T13:27:35.230" Score="3" ViewCount="776" Body="&lt;p&gt;I have a file formatted like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+---------------------------------+&#xA;| Text text text                  |&#xA;| Text text text                  |&#xA;| Text text text                  |&#xA;+---------------------------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Within the ASCII box I would like to remap the standard VIM keys, like &lt;kbd&gt;$&lt;/kbd&gt;, &lt;kbd&gt;_&lt;/kbd&gt;, ... to ignore the ASCII box during editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;kbd&gt;$&lt;/kbd&gt; should place the cursor on the last letter of the text and not on the '|'. I can make it with the simple&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; $ f\|ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works great, but when I try to combine the new &lt;kbd&gt;$&lt;/kbd&gt; with other VIM commands, this doesn't work any more. For example, &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt; deletes the entire like including the last '|' char.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my understanding, I have to use &lt;code&gt;onoremap&lt;/code&gt; somehow to support motions, and then &lt;code&gt;vnoremap&lt;/code&gt; to support visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How should I remap &lt;kbd&gt;$&lt;/kbd&gt; so that it nicely integrates with all VIM-aspects? (visual mode, motions, objects, ...)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3230" LastActivityDate="2016-12-09T15:27:33.370" Title="Remap standard motions" Tags="|cursor-motions|object-motions|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10567" PostTypeId="1" AcceptedAnswerId="10568" CreationDate="2016-12-09T13:39:44.657" Score="3" ViewCount="681" Body="&lt;p&gt;I'd like to put all my custom functions into &lt;code&gt;autoload&lt;/code&gt; folder, but I have functions with the same name. How should I organize them?&lt;/p&gt;&#xA;" OwnerUserId="10448" LastActivityDate="2016-12-09T14:27:44.877" Title="How to organize autoload functions?" Tags="|functions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10568" PostTypeId="2" ParentId="10567" CreationDate="2016-12-09T14:27:44.877" Score="6" Body="&lt;p&gt;Especially with autoload, there should be no same-name clashes. The first part of the autoload function is determined (and enforced) to be the autoload script name, and you're free to choose any function name yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for organizing, this is a very broad question, so here's a broad answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Put related stuff together. Many small modules are better than fewer larger ones.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have some Vim plugins installed, have a look at how they are organized. Also, there are thousands of personal &lt;code&gt;~/.vimrc&lt;/code&gt; files shared on Github; that might give you a clue, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally distinguish between generic stuff, things that I may one day publish as a plugin, and purely personal shortcuts, macros, helpers. The latter, I lump together in larger files, separated into mappings, commands, environment tweaks, plugin customizations, and so on. The former, I keep neatly separated by functionality. I usually start with one &lt;code&gt;autoload/{pluginname}.vim&lt;/code&gt; module. If there are parts that are only needed by parts of the plugin, I might separate further into &lt;code&gt;autoload/{pluginname}/commands.vim&lt;/code&gt; and &lt;code&gt;autoload/{pluginname}/visualmode.vim&lt;/code&gt;, for example. After all, &lt;em&gt;the main purpose of autoload is delaying load until its first use.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-09T14:27:44.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10569" PostTypeId="2" ParentId="10566" CreationDate="2016-12-09T15:27:33.370" Score="6" Body="&lt;p&gt;If you start with this normal mode mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; $ f\|ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The visual-mode mapping is identical:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;buffer&amp;gt; $ f\|ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, for &lt;em&gt;operator-pending mode&lt;/em&gt; (like after &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, and so on), you need a different kind of mapping. &lt;code&gt;:help omap-info&lt;/code&gt; tells us:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To ignore the starting cursor position and select different text, you can have&#xA;  the omap start Visual mode to select the text to be operated upon.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Apparently, you need to use &lt;code&gt;:normal&lt;/code&gt; to trigger the selection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;buffer&amp;gt; $ :&amp;lt;C-u&amp;gt;normal! vf\|ge&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, we could avoid the duplication of the motion, and delegate to the already defined visual mode mapping (note how &lt;code&gt;:normal!&lt;/code&gt; changed to &lt;code&gt;:normal&lt;/code&gt; to invoke mappings):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;buffer&amp;gt; $ :&amp;lt;C-u&amp;gt;normal v$&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Caveat&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;To implement this consistently for all built-in motions will be quite a challenge. I would not recommend to actually use something like that. Best to get rid of such high-ceremony formatting. If that's not possible, I'd rather temporarily copy the text into a scratch buffer, do the modifications (without borders) there, and then paste back.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-09T15:27:33.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10570" PostTypeId="1" AcceptedAnswerId="10571" CreationDate="2016-12-09T15:30:20.580" Score="6" ViewCount="3265" Body="&lt;p&gt;I have some code structure e.g&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  {&#xA;    // Some content goes here&#xA;  }&#xA;  [&#xA;    // Some content goes here&#xA;  ]&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to select the content inside &lt;code&gt;{ }&lt;/code&gt; in some case and also content inside with opening and closing brackets included in some case.&#xA;How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="5890" LastEditorUserId="6489" LastEditDate="2016-12-09T17:12:38.440" LastActivityDate="2016-12-09T17:13:07.490" Title="How to select the content within brackets including brackets and without including brackets?" Tags="|cut-copy-paste|cursor-motions|delimiter-matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10571" PostTypeId="2" ParentId="10570" CreationDate="2016-12-09T15:34:32.347" Score="10" Body="&lt;p&gt;You can use text objects to accomplish this. Start a selection with &lt;code&gt;v&lt;/code&gt; and then:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For selecting inside use: &lt;code&gt;i{&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For selecting the whole block including braces use: &lt;code&gt;a{&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also do this with any type of parenthesis by changing &lt;code&gt;{&lt;/code&gt; to &lt;code&gt;[&lt;/code&gt; or whatever. It's worth taking a little time to learn text objects as they make vim a lot more powerful!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h text-objects&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-12-09T17:13:07.490" LastActivityDate="2016-12-09T17:13:07.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10572" PostTypeId="1" CreationDate="2016-12-09T19:32:36.583" Score="9" ViewCount="694" Body="&lt;pre&gt;&lt;code&gt;let b:some = {&#xA;            \ 'some',&#xA;            \ 'array',&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes code ugly IMHO, how can I change that and should I change that? Is that some coding style or something in vimscript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, is there a plugin that would (I think I had one, but I don't know which one) would expand &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; like delimitMate with inserting appropriate number of spaces and &lt;code&gt;\&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="51" LastEditDate="2016-12-09T19:37:02.150" LastActivityDate="2016-12-10T01:42:24.543" Title="Why is line continuation is indented with 12 spaces in vimscript?" Tags="|indentation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10573" PostTypeId="1" AcceptedAnswerId="10574" CreationDate="2016-12-09T22:43:12.400" Score="7" ViewCount="1225" Body="&lt;p&gt;The 'write-plugin' section of the help recommends the following &#xA;3-level map approach: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map ,c  &amp;lt;Plug&amp;gt;TypecorrAdd &#xA;noremap &amp;lt;unique&amp;gt; &amp;lt;script&amp;gt; &amp;lt;Plug&amp;gt;TypecorrAdd  &amp;lt;SID&amp;gt;Add &#xA;noremap &amp;lt;SID&amp;gt;Add  :call &amp;lt;SID&amp;gt;Add(expand(&quot;&amp;lt;cword&amp;gt;&quot;), 1)&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand how it works, but it wasn't immediately clear to me what &#xA;was being gained by the middle level of indirection: specifically the &#xA;map to Add. What is the advantage of this strategy over the &#xA;following 2-level approach? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map ,c  &amp;lt;Plug&amp;gt;TypecorrAdd &#xA;noremap &amp;lt;unique&amp;gt; &amp;lt;script&amp;gt; &amp;lt;Plug&amp;gt;TypecorrAdd :call &amp;lt;SID&amp;gt;Add(expand(&quot;&amp;lt;cword&amp;gt;&quot;), 1)&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The help says... &#xA;&quot;If another script would also map Add, it would get another &#xA;script ID and thus define another mapping.&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While this is true, isn't this sort of script-uniqueness already &#xA;guaranteed by the use of  in the rhs of the 3rd mapping? I.e., &lt;/p&gt;&#xA;&#xA;&lt;p&gt;:call Add(...) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/em&gt;: After much discussion with a patient and helpful @Peter Rincker, I now think the reason for the extra map level has become clear, but in the simple example I presented above, there's no need for it. The full example in the Vim help, however, had another map, which I neglected to copy into my question. The complete example looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map ,c  &amp;lt;Plug&amp;gt;TypecorrAdd &#xA;noremap &amp;lt;SID&amp;gt;Add  :call &amp;lt;SID&amp;gt;Add(expand(&quot;&amp;lt;cword&amp;gt;&quot;), 1)&amp;lt;CR&amp;gt; &#xA;noremap &amp;lt;unique&amp;gt; &amp;lt;script&amp;gt; &amp;lt;Plug&amp;gt;TypecorrAdd  &amp;lt;SID&amp;gt;Add &#xA;noremenu &amp;lt;script&amp;gt; Plugin.Add\ Correction      &amp;lt;SID&amp;gt;Add&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that, in this full example, 2 distinct maps use &lt;code&gt;&amp;lt;SID&amp;gt;Add&lt;/code&gt; in their rhs. The only purpose (AFAICT) of creating the map from &lt;code&gt;&amp;lt;SID&amp;gt;Add&lt;/code&gt; is to avoid duplicating the code in its rhs in those 2 maps (normal map &lt;code&gt;&amp;lt;Plug&amp;gt;TypecorrAdd&lt;/code&gt; and menu command &lt;code&gt;Plugin.Add Correction&lt;/code&gt;). IOW, the extra (3rd) level of indirection seems to be more about code reuse than about hygiene or script insulation.&lt;/p&gt;&#xA;" OwnerUserId="2281" LastEditorUserId="2281" LastEditDate="2016-12-11T13:47:17.290" LastActivityDate="2016-12-11T22:54:37.743" Title="What is gained by the extra &lt;SID&gt; level of map indirection recommended in help?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10574" PostTypeId="2" ParentId="10573" CreationDate="2016-12-09T23:20:03.803" Score="5" Body="&lt;p&gt;There are two things going on here: an &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; mapping and the use of &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; is used to make &quot;local&quot; mappings or menus. It does via name mangling.  These &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; mappings are often created for the purpose of code reuse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h &amp;lt;SID&amp;gt;&lt;/code&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; only allows remaps of &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; so it is more hygienic.  The idea is to use &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; to make mappings more resistant to recursive mappings or being polluted by unintended mappings. See &lt;code&gt;:h :map-script&lt;/code&gt; for more.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Your example&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;So this code is doing the following things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Creating an &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; mappings to some function (for reuse)&lt;/li&gt;&#xA;&lt;li&gt;Creating a &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mapping that will be available outside the current script. This uses &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; to be my hygienic.&lt;/li&gt;&#xA;&lt;li&gt;Creates a &lt;code&gt;map&lt;/code&gt; to a &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mapping. This the kind of mapping that you would often find in your &lt;code&gt;vimrc&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Contrived example&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A contrived example below to show the issues with not using &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt;. In our case we are going to reuse the &lt;code&gt;yiw&lt;/code&gt; mapping (&lt;code&gt;&amp;lt;Plug&amp;gt;(foo)&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Plug&amp;gt;(foo) yiw&#xA;nmap &amp;lt;Plug&amp;gt;(bar) &amp;lt;Plug&amp;gt;(foo)&amp;lt;cr&amp;gt;p&#xA;nmap &amp;lt;down&amp;gt; &amp;lt;Plug&amp;gt;(bar)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This all works fine until &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; or &lt;code&gt;p&lt;/code&gt; is mapped. e.g. &lt;code&gt;nnoremap &amp;lt;cr&amp;gt; *&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid this we can add another level of indirection via &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;SID&amp;gt;(foo) yiw&#xA;nnoremap &amp;lt;Plug&amp;gt;(foo) &amp;lt;SID&amp;gt;(foo)&#xA;nmap &amp;lt;script&amp;gt; &amp;lt;Plug&amp;gt;(bar) &amp;lt;SID&amp;gt;(foo)&amp;lt;cr&amp;gt;p&#xA;nmap &amp;lt;down&amp;gt; &amp;lt;Plug&amp;gt;(bar)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This example both &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; or &lt;code&gt;*&lt;/code&gt; can be mapped and the &lt;code&gt;&amp;lt;Plug&amp;gt;(bar)&lt;/code&gt; mapping is resistant to these side-effects.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Conclusions&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you need to reuse a mapping or menu then using &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; and script is a great option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However many plugin developers do not bother with this much indirection as they do not need to reuse a mapping and therefore using &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; as it is not needed. Alternatively many plugins also avoid this by refactoring the common mapping(s) into part of a function call. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will also notice that most newer script use the &lt;code&gt;&amp;lt;Plug&amp;gt;(plugin-name-function)&lt;/code&gt; pattern instead of &lt;code&gt;&amp;lt;Plug&amp;gt;PlugNameFunction&lt;/code&gt;. The parens make it easier to extend the plugin without coming up with weird names due to a common prefix.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2016-12-11T22:54:37.743" LastActivityDate="2016-12-11T22:54:37.743" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10575" PostTypeId="1" CreationDate="2016-12-09T23:30:51.977" Score="6" ViewCount="858" Body="&lt;p&gt;I am editing a file which lives in a directory that is a symlink to another directory, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% ls -alh ~/www/experiments &#xA;total 0&#xA;drwxr-xr-x 3 ubuntu ubuntu  80 Dec  5 19:52 .&#xA;drwxr-xr-x 3 ubuntu ubuntu  60 Dec  8 16:25 ..&#xA;lrwxrwxrwx 1 ubuntu ubuntu   8 Dec  5 19:52 tmp -&amp;gt; /tmp/web&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so when I am editing the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/www/experiments/tmp/webpage.php&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because the parent folder of &lt;code&gt;webpage.php&lt;/code&gt; ( &lt;code&gt;tmp&lt;/code&gt; ) is pointing to &lt;code&gt;/tmp/web&lt;/code&gt;&#xA;when I run the vimscript command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo expand('%:p')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim will echo the real file path, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/tmp/web/webpage.php&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;how can I make vim expand the symlinked path in vimscript? i.e. the desired output would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/ubuntu/www/experiments/tmp/webpage.php    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've looked in &lt;code&gt;:h filename-modifiers&lt;/code&gt; and there doesn't seem to be anything about symlinks. Also looked at functions like &lt;code&gt;resolve()&lt;/code&gt; - unfortunately I think &lt;code&gt;resolve()&lt;/code&gt; does the opposite of what I want, it produces the real file path. &lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2019-04-11T22:02:40.530" Title="How can I expand a symlinked file path instead of the real file path?" Tags="|vimscript|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10576" PostTypeId="2" ParentId="10572" CreationDate="2016-12-10T01:42:24.543" Score="8" Body="&lt;p&gt;You can change the amount of that indentation by setting the variable &lt;code&gt;g:vim_indent_cont&lt;/code&gt;, e.g.,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:vim_indent_cont = &amp;amp;sw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help ft-vim-indent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2016-12-10T01:42:24.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10577" PostTypeId="1" CreationDate="2016-12-10T09:26:20.937" Score="2" ViewCount="525" Body="&lt;p&gt;There is a function within a plug-in which I would like to have some of my own code run afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it were a general fix/improvement I'd submit the change, however its just a personal preference which &lt;em&gt;must&lt;/em&gt; run after the plug-in's function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to have my own code run after a plug-ins vimscript &lt;code&gt;function!&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In case it helps, &lt;a href=&quot;https://github.com/nathanaelkane/vim-indent-guides/blob/master/autoload/indent_guides.vim#L33&quot; rel=&quot;nofollow noreferrer&quot;&gt;this is the function&lt;/a&gt; (&lt;code&gt;indent_guides#enable&lt;/code&gt;) to give some context.&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2016-12-10T11:15:24.370" Title="Possible to 'monkeypatch' functions in vimscript?" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10578" PostTypeId="2" ParentId="10577" CreationDate="2016-12-10T09:42:26.480" Score="8" Body="&lt;p&gt;I don't know whether the author of the plugin will agree, but instead of asking them to add your own code, you could ask them to add the ability for the user to run any code after their function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do so, you would create a pull request in which you add a small patch at the end of the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! indent_guides#enable()&#xA;    ...&#xA;&#xA;    &quot; beginning of the patch&#xA;    if exists('#User#IndentGuidesEnablePost')&#xA;        doautocmd &amp;lt;nomodeline&amp;gt; User IndentGuidesEnablePost&#xA;    endif&#xA;    &quot; end of the patch&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, any user of the plugin, including you, should be able to run arbitrary code after the plugin's function has been processed. As a user, you would write in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup IndentGuidesPlugin&#xA;    autocmd!&#xA;    autocmd User IndentGuidesEnablePost call YourFunction()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whenever the plugin's function &lt;code&gt;indent_guides#enable()&lt;/code&gt; will be executed, &lt;code&gt;YourFunction()&lt;/code&gt; will also be executed at the end of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't use this particular plugin, so you should probably test the patch locally to make sure it's working as intended.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to better understand how this small patch work, here's an explanation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:doautocmd&lt;/code&gt; command allows you to run any autocmd, at any time you want, not just when its event occurs. Its syntax is described in &lt;code&gt;:h :do&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:do[autocmd] [&amp;lt;nomodeline&amp;gt;] [group] {event} [fname]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The optional arguments allow you to fine-tune which autocmds you want to execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the patch, you pass to &lt;code&gt;:doautocmd&lt;/code&gt; the argument &lt;code&gt;User&lt;/code&gt;, as well as the pattern &lt;code&gt;IndentGuidesEnablePost&lt;/code&gt;. The latter is an ad-hoc event name. As for &lt;code&gt;User&lt;/code&gt;, it's a special kind of event, because it only occurs when you execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;doautocmd User {MadeUpEvent}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you add the previous line in a function or a script, it's as if you were creating and triggering a new event whose name is &lt;code&gt;{MadeUpEvent}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there's a problem, because if the user doesn't install any autocmd in their &lt;code&gt;vimrc&lt;/code&gt; which uses this new event, they will have the following message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;No matching autocommands&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get around this issue, the plugin author could prefix &lt;code&gt;:doautocmd&lt;/code&gt; with &lt;code&gt;:silent&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent doautocmd User MadeUpEvent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then, the user's autocmd will run silently, which can be a problem if it wants to echo a message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd User MadeUpEvent echo 'your message'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It won't work. The user will have to use &lt;code&gt;:unsilent&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd User MadeUpEvent unsilent echo 'your message'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be annoying. So, to make things work properly without &lt;code&gt;unsilent&lt;/code&gt;, before running &lt;code&gt;:doautocmd&lt;/code&gt;, the plugin author could check whether the user installed an autocmd watching the &lt;code&gt;MadeUpEvent&lt;/code&gt; event:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('#User#MadeUpEvent')&#xA;    doautocmd User MadeUpEvent&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, the &lt;code&gt;&amp;lt;nomodeline&amp;gt;&lt;/code&gt; argument is recommended in this case. From &lt;code&gt;:h :do&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        After applying the autocommands the modelines are&#xA;        processed, so that their settings overrule the&#xA;        settings from autocommands, like what happens when&#xA;        editing a file. This is skipped when the &amp;lt;nomodeline&amp;gt;&#xA;        argument is present. You probably want to use&#xA;        &amp;lt;nomodeline&amp;gt; for events that are not used when loading&#xA;        a buffer, such as |User|.&#xA;        Processing modelines is also skipped when no&#xA;        matching autocommands were executed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For an example where &lt;code&gt;&amp;lt;nomodeline&amp;gt;&lt;/code&gt; can be useful, see this &lt;a href=&quot;https://github.com/tpope/vim-commentary/issues/26&quot; rel=&quot;noreferrer&quot;&gt;issue&lt;/a&gt; on the bug tracker of the &lt;code&gt;vim-commentary&lt;/code&gt; plugin.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-10T11:15:24.370" LastActivityDate="2016-12-10T11:15:24.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10580" PostTypeId="1" CreationDate="2016-12-10T13:04:20.887" Score="1" ViewCount="907" Body="&lt;p&gt;I like the syntax rules and don't need to change them, but what bugs me is that for some reason the author decided to highlight keywords with &lt;code&gt;Structure&lt;/code&gt; group and function names with &lt;code&gt;Comment&lt;/code&gt; (or something else). I don't like such inconsistencies. I like keywords, comments and functions highlighted with the same color in every language I work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that I can't find the source of this syntax.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2016-12-19T16:49:25.800" Title="How to change vimscript syntax highlighting?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10581" PostTypeId="1" CreationDate="2016-12-10T14:42:56.543" Score="7" ViewCount="896" Body="&lt;p&gt;Sometimes I mis-spell the name of a file. So let's say I have a file called &lt;code&gt;ThisIsAFileName&lt;/code&gt; and I start typing &lt;code&gt;ThisS...&lt;/code&gt; The moment I misspell the filename (and there are no hits whatsoever), CTRL-P becomes incredibly slow. It displays each next letter at a speed of about 1 character every 5 seconds. So if I accidentally type 6 extra characters I am waiting half a minute for CTRL-P to finish displaying these characters before I can undo this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this something that happens regularly? Any idea how to fix this? &lt;/p&gt;&#xA;" OwnerUserId="10466" LastActivityDate="2019-07-28T18:02:00.263" Title="CTRL-P very slow when files are not found" Tags="|plugin-ctrlp|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10582" PostTypeId="1" AcceptedAnswerId="10640" CreationDate="2016-12-10T18:07:48.533" Score="2" ViewCount="200" Body="&lt;p&gt;I've got automatic folding enabled in my file with the following &lt;code&gt;modeline&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim:foldmethod=marker:foldlevel=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also have an autocmd like this to place the cursor where I left it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;autocmd&quot;)&#xA;    au BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 0 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;)&#xA;          \| exe &quot;normal! g'\&quot;&quot; | endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that if I left the cursor in the middle of a fold then my auto command will not work as desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do to unfold the fold under the cursor on read, preferably using &lt;code&gt;modeline&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried adding &lt;code&gt;normal zv&lt;/code&gt; to my autocmd but it didn't work. &lt;/p&gt;&#xA;" OwnerUserId="6043" LastEditorUserId="51" LastEditDate="2016-12-17T02:00:40.783" LastActivityDate="2016-12-17T02:00:40.783" Title="How to unfold a fold the cursor is in using modeline?" Tags="|autocmd|folding|modeline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10583" PostTypeId="1" CreationDate="2016-12-11T03:22:23.103" Score="4" ViewCount="829" Body="&lt;p&gt;I've got a program that spits out multi-line messages separated with something other than a newline. I want these messages to show in the quickfix and location lists spanning multiple lines as intended. What character can I replace the separator with to get that result? For example, &lt;code&gt;setqflist([{'text': &quot;1\r2&quot;}])&lt;/code&gt; prints &lt;code&gt;1^M2&lt;/code&gt; on a single line. What character can I use to get two lines?&lt;/p&gt;&#xA;" OwnerUserId="1176" LastActivityDate="2017-03-12T05:56:27.570" Title="How do I write a multi-line message to the quickfix or location list?" Tags="|vimscript|functions|quickfix|encoding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10584" PostTypeId="1" AcceptedAnswerId="10587" CreationDate="2016-12-11T07:40:19.023" Score="2" ViewCount="197" Body="&lt;p&gt;I'm new to Vim editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used Sublime Text before using Vim. In Sublime Text, there was a plugin named &lt;a href=&quot;https://github.com/wuub/SublimeREPL&quot; rel=&quot;nofollow noreferrer&quot;&gt;SublimeREPL&lt;/a&gt;, which is optimized for using REPL such as &lt;code&gt;irb&lt;/code&gt;, &lt;code&gt;python&lt;/code&gt;, and &lt;code&gt;scala&lt;/code&gt;. The plugin highlighted the code I type and provide a simple code completion like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VExQo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VExQo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any plugin similar to this in Vim?&lt;/p&gt;&#xA;" OwnerUserId="10072" LastEditorUserId="10072" LastEditDate="2016-12-11T08:04:37.633" LastActivityDate="2016-12-11T14:31:34.093" Title="Vim plugin like SublimeREPL" Tags="|plugin-system|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10585" PostTypeId="2" ParentId="10402" CreationDate="2016-12-11T12:30:15.327" Score="1" Body="&lt;p&gt;Consulting the documentation of these plugins, you can find out how to tweak the position of their buffers. I achieved what you want as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tagbar_left = 1&#xA;let g:tagbar_vertical = 25&#xA;let NERDTreeWinPos = 'left'&#xA;nnoremap &amp;lt;f5&amp;gt; :NERDTreeToggle &amp;lt;CR&amp;gt; :TagbarToggle &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;:NERDTreeTabsToggle&lt;/code&gt; is not part of NERDTree itself, as it seems. Are you using &lt;a href=&quot;https://github.com/jistr/vim-nerdtree-tabs&quot; rel=&quot;nofollow noreferrer&quot;&gt;this plugin&lt;/a&gt;? I don't know if it works the same.&lt;/p&gt;&#xA;" OwnerUserId="6495" LastActivityDate="2016-12-11T12:30:15.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10586" PostTypeId="1" CreationDate="2016-12-11T13:44:12.517" Score="1" ViewCount="108" Body="&lt;p&gt;Say I am writing confidential document on &lt;code&gt;vim&lt;/code&gt;. I want another text to appear instead of the real document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each time a key of the real confidential text is pressed, the next letter of the fake text appear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I want the &quot;Return&quot; carriage to be replaced by another letter of the fake text. &lt;/p&gt;&#xA;" OwnerUserId="10471" LastEditorUserId="2920" LastEditDate="2016-12-12T01:27:56.620" LastActivityDate="2016-12-12T01:27:56.620" Title="How to display a fake text instead of what is being written on the keyboard" Tags="|vimscript|security|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10587" PostTypeId="2" ParentId="10584" CreationDate="2016-12-11T14:31:34.093" Score="3" Body="&lt;p&gt;You might find &lt;a href=&quot;https://github.com/Shougo/vimshell.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Shougo's VimShell&lt;/a&gt; similar. It gives you a terminal session in a Vim buffer, which is quite neat! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in my experience, I've found it to be a little buggy. YMMV. Also, three days ago, development on it officially stopped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it's fair to say that things like this have been on vimmers' wishlists for some time now. Unfortunately, I don't know that it'll ever happen. Vim's strength is that it's a terrific editor -- but the price for that is that Vim's buffers don't lend themselves too well to the sort of interaction a CLI needs. So we &lt;em&gt;can&lt;/em&gt; run a terminal in a Vim buffer, but I don't know that it'll ever be quite right; it's not what Vim's designed to do. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, I offer you two alternatives I use after experimenting with VimShell and finding it wasn't for me -- but they'll only work with Vim in a terminal, not something like gvim:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Using something to do terminal multiplexing, like tmux. Using this you can break a shell out at the side of your vim window, or have a shell in another tmux panel, or what have you. I use this every day, and seriously recommend getting into tmux as a part of your development environment. &lt;/li&gt;&#xA;&lt;li&gt;CTRL-z is your friend. Really, the shell that you launched Vim from is only a key command away. CTRL-z will pause Vim, background it, and bring you back to your shell. You can launch your repl from there, and when you're done, the &lt;code&gt;fg&lt;/code&gt; command will bring Vim back to the foreground. Experiment with it! It's really simple in practice. I use this every day also.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Hope that helps!&lt;/p&gt;&#xA;" OwnerUserId="10472" LastActivityDate="2016-12-11T14:31:34.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10588" PostTypeId="2" ParentId="6378" CreationDate="2016-12-11T14:45:50.163" Score="0" Body="&lt;p&gt;You could also define custom operators&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could map them to the key sequences &lt;code&gt;'*&lt;/code&gt; and &lt;code&gt;'#&lt;/code&gt;. The marks &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; don't exist, so you won't override any default functionality.&#xA;The reason to choose &lt;code&gt;'&lt;/code&gt; as a prefix is to get some kind of mnemonics. You're adding a sign/mark in front of some lines. And usually to go to a mark you use the prefix &lt;code&gt;'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:op_list_bullet(...) abort range&#xA;&#xA;    if a:0&#xA;        let [lnum1, lnum2] = [line(&quot;'[&quot;), line(&quot;']&quot;)]&#xA;    else&#xA;        let [lnum1, lnum2] = [line(&quot;'&amp;lt;&quot;), line(&quot;'&amp;gt;&quot;)]&#xA;    endif&#xA;&#xA;    if !empty(matchstr(getline(lnum1), '^\s*\d\s*\.'))&#xA;        let pattern     = '\d\s*\.\s\?'&#xA;        let replacement = '* '&#xA;&#xA;    elseif count(['-', '*'], matchstr(getline(lnum1), '\S'))&#xA;        let pattern     = '\v\S\s*'&#xA;        let replacement = ''&#xA;&#xA;    else&#xA;        let pattern     = '\v\ze\S'&#xA;        let replacement = '* '&#xA;    endif&#xA;&#xA;    let cmd = 'keepj keepp %s,%s s/%s/%s'&#xA;&#xA;    sil exe printf(cmd, lnum1, lnum2, pattern, replacement)&#xA;endfu&#xA;&#xA;fu! s:op_list_digit(...) abort range&#xA;    let l:c = 0&#xA;&#xA;    if a:0&#xA;        let [lnum1, lnum2] = [line(&quot;'[&quot;), line(&quot;']&quot;)]&#xA;    else&#xA;        let [lnum1, lnum2] = [a:firstline, a:lastline]&#xA;    endif&#xA;&#xA;    if count(['-', '*'], matchstr(getline(lnum1), '\S'))&#xA;        let pattern     = '\S\s*'&#xA;        let replacement = '\=l:c.&quot;. &quot;'&#xA;&#xA;    elseif !empty(matchstr(getline(lnum1), '^\s*\d\s*\.'))&#xA;        let pattern     = '\d\s*\.\s\?'&#xA;        let replacement = ''&#xA;&#xA;    else&#xA;        let pattern     = '\v^\s*\zs\ze\S'&#xA;        let replacement = '\=l:c.&quot;. &quot;'&#xA;    endif&#xA;&#xA;    let cmd = 'keepj keepp %s,%s g/%s/let l:c = line(&quot;.&quot;) == line(&quot;'']&quot;)+1 ?&#xA;                                                \ l:c+1 : 1 |&#xA;                                                \ keepj keepp s/%s/%s'&#xA;&#xA;    sil exe printf(cmd, lnum1, lnum2, pattern, pattern, replacement)&#xA;endfu&#xA;&#xA;nno &amp;lt;silent&amp;gt; '*     :&amp;lt;C-U&amp;gt;set opfunc=&amp;lt;SID&amp;gt;op_list_bullet&amp;lt;CR&amp;gt;g@&#xA;nno &amp;lt;silent&amp;gt; '**    :&amp;lt;C-U&amp;gt;set opfunc=&amp;lt;SID&amp;gt;op_list_bullet&#xA;                    \&amp;lt;Bar&amp;gt;exe 'norm! ' . v:count1 . 'g@_'&amp;lt;CR&amp;gt;&#xA;xno &amp;lt;silent&amp;gt; '*     :call &amp;lt;SID&amp;gt;op_list_bullet()&amp;lt;CR&amp;gt;&#xA;&#xA;nno &amp;lt;silent&amp;gt; '#     :&amp;lt;C-U&amp;gt;set opfunc=&amp;lt;SID&amp;gt;op_list_digit&amp;lt;CR&amp;gt;g@&#xA;nno &amp;lt;silent&amp;gt; '##    :&amp;lt;C-U&amp;gt;set opfunc=&amp;lt;SID&amp;gt;op_list_digit&#xA;                    \&amp;lt;Bar&amp;gt;exe 'norm! ' . v:count1 . 'g@_'&amp;lt;CR&amp;gt;&#xA;xno &amp;lt;silent&amp;gt; '#     :call &amp;lt;SID&amp;gt;op_list_digit()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It also works from visual mode.&lt;br&gt;&#xA;Ex commands are good for scripting, but for an interactive use, a normal operator is probably better, because you can combine it with any motion or text-object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you could toggle a list prefixed with asterisks or minus signs inside the current paragraph by hitting &lt;code&gt;'*ip&lt;/code&gt;. Here, &lt;code&gt;'*&lt;/code&gt; is an operator and &lt;code&gt;ip&lt;/code&gt; is the text-object on which it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And do the same thing for a list prefixed with numbers across the next 10 lines by hitting &lt;code&gt;'#10j&lt;/code&gt;. Here, &lt;code&gt;'#&lt;/code&gt; is another operator and &lt;code&gt;10j&lt;/code&gt; is a motion covering the lines on which the operator works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other benefit of using a custom operator, is that you can repeat your last edition with the dot command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hPN9B.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hPN9B.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-11T14:58:32.773" LastActivityDate="2016-12-11T14:58:32.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10589" PostTypeId="1" CreationDate="2016-12-11T17:24:25.693" Score="5" ViewCount="165" Body="&lt;p&gt;In &lt;code&gt;$VIMRUNTIME/ftplugin/vim.vim&lt;/code&gt;, some mappings are installed to move the cursor to the previous/next comment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Move around comments&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;buffer&amp;gt; ]&quot; :call search('^\(\s*&quot;.*\n\)\@&amp;lt;!\(\s*&quot;\)', &quot;W&quot;)&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt;&amp;lt;buffer&amp;gt; ]&quot; :&amp;lt;C-U&amp;gt;exe &quot;normal! gv&quot;&amp;lt;Bar&amp;gt;call search('^\(\s*&quot;.*\n\)\@&amp;lt;!\(\s*&quot;\)', &quot;W&quot;)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;buffer&amp;gt; [&quot; :call search('\%(^\s*&quot;.*\n\)\%(^\s*&quot;\)\@!', &quot;bW&quot;)&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt;&amp;lt;buffer&amp;gt; [&quot; :&amp;lt;C-U&amp;gt;exe &quot;normal! gv&quot;&amp;lt;Bar&amp;gt;call search('\%(^\s*&quot;.*\n\)\%(^\s*&quot;\)\@!', &quot;bW&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They use the key sequences &lt;code&gt;[&quot;&lt;/code&gt; and &lt;code&gt;]&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there similar mappings for other filetypes, or can we modify these mappings so that they work not only in Vim files but in other filetypes (shell, python, …)?&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-11T18:30:08.227" LastActivityDate="2017-11-14T10:35:43.593" Title="How to move around comments in any type of file?" Tags="|key-bindings|vimscript|cursor-movement|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10591" PostTypeId="2" ParentId="10583" CreationDate="2016-12-12T03:58:08.937" Score="1" Body="&lt;p&gt;It can depend on your system. Some characters may be right on one system and not work at all on another. Between Macintosh, Windows, and Unix/Linux, there are three different types of carriage returns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\n&lt;/code&gt; may work for you. You could also try them both together: &lt;code&gt;\n\r&lt;/code&gt; (I think that's the right way, but you could also try it reversed)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternately, you can instruct Vim to use a particular kind of carriage return, no matter what system you are on, by playing with the &lt;code&gt;fileformat&lt;/code&gt; (abbreviated as &lt;code&gt;ff&lt;/code&gt;) option:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set ff=dos&lt;/code&gt; for example switches to the Windows formatting when it reads the file or buffer. You can re-read a file you already have open in a different format by using this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e ++ff=unix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may have to play around with it and see what works best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For far more detail, see &lt;a href=&quot;http://vim.wikia.com/wiki/File_format&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt; on the Vim wiki.&lt;/p&gt;&#xA;" OwnerUserId="10168" LastActivityDate="2016-12-12T03:58:08.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10592" PostTypeId="1" AcceptedAnswerId="10641" CreationDate="2016-12-12T04:45:35.250" Score="6" ViewCount="1680" Body="&lt;p&gt;How can I define a syntax to highlight the python class name &lt;code&gt;MyClass&lt;/code&gt; in vim? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyClass(object):&#xA;    ......&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim has already highlighted the class name. However, it seemingly highlights it with the function name in a same way. Can I have a better way to highlight the two categories?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a right way via &lt;code&gt;syn match ...&lt;/code&gt;? In the default &lt;code&gt;syntax/python.vim&lt;/code&gt;, I found this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match   pythonFunction  &quot;\h\w*&quot; display contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried, but my &lt;code&gt;syn&lt;/code&gt; definition must be wrong, it does not work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match pythonClassName &quot;^class \(*\):&quot; display contained&#xA;call HI('pythonClassName',         124, '', 'bold', 'bold')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;HI()&lt;/code&gt; is a self-defined function, I have used it to modify &lt;code&gt;pythonStatement&lt;/code&gt; successfully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a matter of fact, I do not know what it really does. It's just a try. Could someone give me some tips? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="10269" LastEditorUserId="51" LastEditDate="2016-12-17T02:23:38.563" LastActivityDate="2016-12-19T23:37:27.820" Title="How can I change the highlighting of python class name?" Tags="|syntax-highlighting|filetype-python|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10593" PostTypeId="1" CreationDate="2016-12-12T07:06:28.900" Score="2" ViewCount="719" Body="&lt;p&gt;I'm working on some shell scripts with a lot of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Parameter: images.0.created_at&#xA;if [ -z &quot;$images.0.created_at&quot; ]&#xA;then&#xA;        echo &quot;images.0.created_at is empty&quot;&#xA;else&#xA;        woostring=&quot;$woostring&quot;&quot;--images.0.created_at=$images.0.created_at &quot;&#xA;fi&#xA;images.0.created_at=&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it would be really nice if I could get some folding here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking that at a bare minimum &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;fi&lt;/code&gt; should be folded, but there must be more that would make sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I be folding, do any plugins exist for this, and if not; how should I get started?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastEditorUserId="1841" LastEditDate="2016-12-12T14:45:42.443" LastActivityDate="2016-12-12T14:45:42.443" Title="How should I fold a shell script in vim? Is there an existing script or function for this?" Tags="|folding|bash|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10594" PostTypeId="1" AcceptedAnswerId="10595" CreationDate="2016-12-12T09:15:10.190" Score="2" ViewCount="883" Body="&lt;p&gt;I'm trying to fix a csv file but the regex expression won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to jump to lines that have a number of commas that is different than 5. I first select lines with less than 5 so I press &lt;code&gt;/&lt;/code&gt; and type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[^,\r\n]*(?:,[^,\r\n]*){0,4}$`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it won't match anything. It's not the first time that I can't match a regex that is otherwise working on other engines, what is happening ?&lt;/p&gt;&#xA;" OwnerUserId="7005" LastEditorUserId="1841" LastEditDate="2016-12-12T09:29:21.910" LastActivityDate="2016-12-12T14:59:47.663" Title="Why this regex expression matching lines with (not N) number of comma doesn't work with vim?" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10595" PostTypeId="2" ParentId="10594" CreationDate="2016-12-12T09:28:03.713" Score="3" Body="&lt;p&gt;Vim regex engine doesn't work exactly like other engines. It includes different 'magic modes' which change the characters that you have to escape.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2Fmagic&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /magic&lt;/code&gt;&lt;/a&gt; for a list of the characters to escape and more generally &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#pattern.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h pattern.txt&lt;/code&gt;&lt;/a&gt; to learn how to use regexes on Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make your search work you should use:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[^,\r\n]*\(,[^,\r\n]*\)\{0,4}$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-12-12T14:59:47.663" LastActivityDate="2016-12-12T14:59:47.663" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10597" PostTypeId="1" AcceptedAnswerId="10599" CreationDate="2016-12-12T16:56:08.193" Score="6" ViewCount="1201" Body="&lt;p&gt;I have two windows open in &lt;code&gt;tmux&lt;/code&gt;(version 2.3). In first &lt;code&gt;tmux&lt;/code&gt; window I have a SSH session to &lt;code&gt;server1&lt;/code&gt; and in second &lt;code&gt;tmux&lt;/code&gt; window I have a SSH session to &lt;code&gt;server2&lt;/code&gt;. In &lt;code&gt;server1&lt;/code&gt; I opened a shell script with &lt;code&gt;vim script.sh&lt;/code&gt; and selected a part of the script with mouse and paste it to &lt;code&gt;vim&lt;/code&gt; open in &lt;code&gt;server2&lt;/code&gt; with middle mouse button. This caused lot of trailing spaces for each line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iQYn2.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iQYn2.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I open &lt;code&gt;script.sh&lt;/code&gt; in &lt;code&gt;server1&lt;/code&gt; with &lt;code&gt;vim -u NONE script.sh&lt;/code&gt;(or with &lt;code&gt;cat script.sh&lt;/code&gt; or &lt;code&gt;less script.sh&lt;/code&gt;) and select the same text area and past it to &lt;code&gt;vim&lt;/code&gt; in &lt;code&gt;server2&lt;/code&gt;, then trailing spaces are not added:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Zqgga.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Zqgga.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This made me think that something in my &lt;code&gt;.vimrc&lt;/code&gt; causes this behavior. My &lt;code&gt;.vimrc&lt;/code&gt; is following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set relativenumber&#xA;set number&#xA;syntax on&#xA;set hls&#xA;set background=dark&#xA;set hidden&#xA;set listchars=tab:▸\ ,eol:↲,trail:·&#xA;highlight NonText guifg=#054a59&#xA;highlight SpecialKey guifg=#4a4a59&#xA;set noexpandtab&#xA;set shiftwidth=4&#xA;set tabstop=4&#xA;set softtabstop=4&#xA;set colorcolumn=81&#xA;  filetype on&#xA;  filetype plugin on&#xA;  filetype indent on&#xA;  autocmd FileType cpp setlocal ts=8 sts=8 sw=8 noexpandtab&#xA;  autocmd FileType * set formatoptions-=c formatoptions-=r formatoptions-=o&#xA;  autocmd BufNewFile,BufReadPost *.bash set filetype=sh&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to turn every possible option off(for example &lt;code&gt;set syntax=&lt;/code&gt;, &lt;code&gt;set hidden!&lt;/code&gt;, &lt;code&gt;set colorcolumn=&lt;/code&gt;, etc), but this did not help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that copying and pasting from terminal screen is not reliable, but is there some clever workaround for this?&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2021-02-13T19:38:00.420" Title="trailing spaces when copying text from vim session in one server to vim session in another server" Tags="|cut-copy-paste|ssh|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10598" PostTypeId="1" AcceptedAnswerId="17757" CreationDate="2016-12-12T18:05:33.290" Score="11" ViewCount="3373" Body="&lt;p&gt;I know that vim had the client/server divide that allowed register sharing between different vim clients, but how do you achieve the same thing in neovim? It doesn't support the client/server flags. I saw &lt;a href=&quot;https://vi.stackexchange.com/questions/5348/how-can-i-use-servername-and-remote-in-neovim&quot;&gt;this question&lt;/a&gt;, but my goal is specifically sharing registers, not imitating the rest of client/server. Is something like &lt;a href=&quot;https://github.com/mhinz/neovim-remote&quot; rel=&quot;noreferrer&quot;&gt;neovim remote&lt;/a&gt; the only way, or is there something simpler I can do?&lt;/p&gt;&#xA;" OwnerUserId="10016" LastActivityDate="2020-04-12T21:59:00.580" Title="In neovim, how can I share registers between editor instances?" Tags="|neovim|register|clientserver|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10599" PostTypeId="2" ParentId="10597" CreationDate="2016-12-12T19:36:25.803" Score="4" Body="&lt;p&gt;This behavior was caused by &lt;code&gt;colorcolumn&lt;/code&gt; option. I started to use &lt;a href=&quot;http://vimcasts.org/episodes/accessing-the-system-clipboard-from-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;quoteplus register&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2016-12-12T19:36:25.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10600" PostTypeId="1" CreationDate="2016-12-12T20:51:01.633" Score="1" ViewCount="735" Body="&lt;p&gt;I know I can set user-defined commands using the &lt;code&gt;:command Foo bar&lt;/code&gt; syntax, but I want a way to set a command without using capitals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to save all open buffers, the command is &lt;code&gt;:wa&lt;/code&gt;, but that's slightly too inconvenient. I'd really like to be able to just do &lt;code&gt;:ww&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's with this seemingly arbitrary limitation? Why do I have to use capital letters?&lt;/p&gt;&#xA;" OwnerUserId="10484" LastEditorUserId="1841" LastEditDate="2016-12-13T11:15:14.247" LastActivityDate="2016-12-24T21:33:29.047" Title="How to create user command without a capital letter as first letter?" Tags="|linux|user-commands|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10602" PostTypeId="1" CreationDate="2016-12-13T05:19:20.757" Score="5" ViewCount="8286" Body="&lt;p&gt;In normal mode, &lt;kbd&gt;b&lt;/kbd&gt; and &lt;kbd&gt;w&lt;/kbd&gt; are jumping between words,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I would like to stop at the end of line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The cursor is right over here&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zDd4M.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zDd4M.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I press &lt;kbd&gt;w&lt;/kbd&gt;, what I expect is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/paImG.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/paImG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, the cursor jump to beginning of next line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I &lt;code&gt;set iskeyword&lt;/code&gt; or something? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="10488" LastEditorUserId="5395" LastEditDate="2016-12-13T07:22:17.593" LastActivityDate="2016-12-13T13:42:04.643" Title="Vim jump between words and stop at end of line" Tags="|cursor-movement|gvim|cursor-motions|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10603" PostTypeId="2" ParentId="10602" CreationDate="2016-12-13T07:04:01.060" Score="6" Body="&lt;p&gt;Use &lt;kbd&gt;e&lt;/kbd&gt; key - it moves cursor to the &lt;code&gt;end&lt;/code&gt; of a word-object. See &lt;code&gt;:h word-motions&lt;/code&gt; for more movement keys.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2016-12-13T07:10:01.313" LastActivityDate="2016-12-13T07:10:01.313" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10604" PostTypeId="1" AcceptedAnswerId="10606" CreationDate="2016-12-13T08:43:51.727" Score="1" ViewCount="116" Body="&lt;p&gt;I'm having trouble understanding the cursor in the context of Vim commands, e.g. insertion, deletion, movement, etc:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When the cursor is hovering over a character and I want to delete until the end of the line, or to the beginning of the line, should I expect that the character it's pointing to will also be deleted? &lt;/li&gt;&#xA;&lt;li&gt;When I enter &lt;code&gt;insert&lt;/code&gt; mode, should I expect that the insertion will take place before or after the current character?&lt;/li&gt;&#xA;&lt;li&gt;What about when pasting with &lt;code&gt;p&lt;/code&gt;? &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm not looking for specific answers to these examples, I'm looking for a general explanation or rules to understand the &quot;current position&quot; so I don't keep executing commands that end up being off by 1 character because I misinterpreted it.  In GUI editors the caret usually sits between instead of on top of characters, so it's never been a source of confusion.&lt;/p&gt;&#xA;" OwnerUserId="10490" LastEditorUserId="1841" LastEditDate="2016-12-13T08:57:41.850" LastActivityDate="2016-12-13T09:26:15.797" Title="How to correctly interpret the cursor's position?" Tags="|cut-copy-paste|insert-mode|cursor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10605" PostTypeId="2" ParentId="10602" CreationDate="2016-12-13T09:09:31.290" Score="4" Body="&lt;p&gt;While I deeply agree with @grodzik comment (&lt;em&gt;it's better to learn how to use motions as they are, because later you will forget that you have custom motion mapping&lt;/em&gt;) here is a custom funciton and mapping to do what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Override w motion&#xA;function! MyWMotion()&#xA;    &quot; Save the initial position&#xA;    let initialLine=line('.')&#xA;&#xA;    &quot; Execute the builtin word motion and get the new position&#xA;    normal! w&#xA;    let newLine=line('.')&#xA;&#xA;    &quot; If the line as changed go back to the previous line&#xA;    if initialLine != newLine&#xA;        normal k$&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot; Override b motion&#xA;function! MyBMotion()&#xA;    &quot; Save the initial position&#xA;    let initialLine=line('.')&#xA;&#xA;    &quot; Execute the builtin word motion and get the new position&#xA;    normal! b&#xA;    let newLine=line('.')&#xA;&#xA;    &quot; If the line as changed go back to the previous line&#xA;    if initialLine != newLine&#xA;        normal j^&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; w :call MyWMotion()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; b :call MyBMotion()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't tested it extensively so maybe some corner cases will create problems but that should be a good start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also as I mentioned before this code is only to show that it is possible to do that I wouldn't recommend to use it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-12-13T13:42:04.643" LastActivityDate="2016-12-13T13:42:04.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10606" PostTypeId="2" ParentId="10604" CreationDate="2016-12-13T09:26:15.797" Score="3" Body="&lt;p&gt;The right mental model is that the cursor is &lt;em&gt;before&lt;/em&gt; the current character. So, any &lt;code&gt;{motion}&lt;/code&gt; that moves to the right (e.g. &lt;code&gt;$&lt;/code&gt;, &lt;code&gt;w&lt;/code&gt;) includes the character under the cursor, whereas any motion to the left (e.g. &lt;code&gt;^&lt;/code&gt;) excludes it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Likewise, &lt;code&gt;i&lt;/code&gt; inserts before the current character, whereas &lt;code&gt;a&lt;/code&gt; appends after it. Same for pasting with &lt;code&gt;P&lt;/code&gt; (before) / &lt;code&gt;p&lt;/code&gt; (after).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-13T09:26:15.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10607" PostTypeId="1" AcceptedAnswerId="10608" CreationDate="2016-12-13T09:59:11.607" Score="12" ViewCount="1770" Body="&lt;p&gt;It took me very long time to realize that putting (pasting) something with &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;P&lt;/code&gt; which visual-block selects with &lt;code&gt;ctrl+v&lt;/code&gt; and yanked (copied) with &lt;code&gt;y&lt;/code&gt;, preserves the manner before, so that, when the copied text was being in the middle of lines, it will then be copied among middle of other text whenever possible. &#xA;On the contrary, select-line with &lt;code&gt;V&lt;/code&gt; does not paste the copied line among other text, but starting on another line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, suppose I have by now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12/12: Avocado. Apple.&#xA;12/13: Bean.    Banana.&#xA;12/14: Cherry.  Citron.&#xA;12/15:&#xA;12/16:&#xA;12/17:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I want to cut &lt;code&gt;Avocado&lt;/code&gt; and &lt;code&gt;Bean&lt;/code&gt; and &lt;code&gt;Cherry&lt;/code&gt;, by selecting (selection represented as &lt;code&gt;_&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12/12: ________ Apple.&#xA;12/13: ________ Banana.&#xA;12/14: ________ Citron.&#xA;12/15:&#xA;12/16:&#xA;12/17:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and pressing &lt;code&gt;y&lt;/code&gt;, and move cursor to the following line (cursor represented as &lt;code&gt;_&lt;/code&gt;), &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12/12: Avocado. Apple.&#xA;12/13: Bean.    Banana.&#xA;12/14: Cherry.  Citron.&#xA;_2/15:&#xA;12/16:&#xA;12/17:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and press &lt;code&gt;P&lt;/code&gt;. It results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12/12: Avocado. Apple.&#xA;12/13: Bean.    Banana.&#xA;12/14: Cherry.  Citron.&#xA;Avocado.12/15:&#xA;Bean.   12/16:&#xA;Cherry. 12/17:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what I wished was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12/12: Avocado. Apple.&#xA;12/13: Bean.    Banana.&#xA;12/14: Cherry.  Citron.&#xA;Avocado.&#xA;Bean.   &#xA;Cherry. &#xA;12/15:&#xA;12/16:&#xA;12/17:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This confused me every time, until I realized that because they were copied in the middle of line, they were thus pasted in the middle of line, mimicking the way they were. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems the best way to paste something starting on another line, is moving cursor to the beginning with &lt;code&gt;0&lt;/code&gt;, and down 3 lines, to the new place; &#xA;and entering insert mode with &lt;code&gt;i&lt;/code&gt;, and pressing &lt;code&gt;&amp;lt;return&amp;gt;&lt;/code&gt; 3 times, and move cursor back 6 lines, and right, back to the original place; &#xA;and copying, and again move to the new place, and paste, as I did above. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I save a few strokes? Or what do you usually do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Edit: What's said above was how I understood it the moment I asked this. See those answers for correct explanation : )&lt;/p&gt;&#xA;" OwnerUserId="10241" LastEditorUserId="10241" LastEditDate="2016-12-13T16:53:47.420" LastActivityDate="2016-12-13T16:53:47.420" Title="How to paste visual block starting with another line" Tags="|cut-copy-paste|visual-block|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10608" PostTypeId="2" ParentId="10607" CreationDate="2016-12-13T10:17:43.717" Score="13" Body="&lt;p&gt;When you copy some text, it goes into a register. The text inside a register has a type: &lt;code&gt;characterwise&lt;/code&gt;, &lt;code&gt;linewise&lt;/code&gt; or &lt;code&gt;blockwise&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This type determines in which way the text will be put.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your example, you copied some text from visual block mode. So, the text had the type &lt;code&gt;blockwise&lt;/code&gt; and was stored in the unnamed register &lt;code&gt;&quot;&lt;/code&gt;.&lt;br&gt;&#xA;Because of this type, when you will paste it back inside your buffer, it will be pasted as a block.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to paste it as a sequence of lines, instead of a block, there are 3 ways.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;From insert mode, you can insert it by hitting &lt;code&gt;C-r &quot;&lt;/code&gt;.&lt;br&gt;&#xA;It should insert the contents of the unnamed register as if its type was linewise.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;From the command line, you can use the &lt;code&gt;:put&lt;/code&gt; command.&lt;br&gt;&#xA;&lt;code&gt;:put&lt;/code&gt; should paste the text inside a register as if its type was linewise, no matter its original type.&#xA;Note that you can pass the name of a register as an argument, as well as a line address to specifiy below which line you want the register to be pasted.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:42put a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... should put the contents of the register &lt;code&gt;a&lt;/code&gt;, below the &lt;code&gt;42&lt;/code&gt;th line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without a register name, Vim will assume you want to paste the unnamed register (or the &lt;code&gt;+&lt;/code&gt; register if you tweaked &lt;code&gt;'clipboard'&lt;/code&gt;).&lt;br&gt;&#xA;And without an address, Vim will assume you want to paste it below the current line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;From the command line, you can change the type of the unnamed register with the &lt;code&gt;setreg()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:call setreg('&quot;', '', 'al')&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;code&gt;setreg()&lt;/code&gt; should append an empty string to the unnamed register (thanks to the &lt;code&gt;a&lt;/code&gt; flag passed as a third argument) and change its type to linewise (thanks to the &lt;code&gt;l&lt;/code&gt; flag).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, from normal mode, you should be able to paste the register, with the &lt;code&gt;p&lt;/code&gt; normal command, as if its type was linewise.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It's not directly linked to your issue, but when you copy some text, it also goes into the &lt;code&gt;0&lt;/code&gt; register. And if you prepended the value &lt;code&gt;unnamedplus&lt;/code&gt; to the option &lt;code&gt;'clipboard'&lt;/code&gt;, it also goes into the &lt;code&gt;+&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check what's the type of a register, using the &lt;code&gt;getregtype()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo getregtype('&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it returns a lowercase &lt;code&gt;v&lt;/code&gt;, it means the type is characterwise.&lt;br&gt;&#xA;If it returns an uppercase &lt;code&gt;V&lt;/code&gt;, it means the type is linewise.&lt;br&gt;&#xA;If it returns &lt;code&gt;^V{some number}&lt;/code&gt;, it means the type is blockwise, and the width of the block is &lt;code&gt;{some number}&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-13T10:45:06.360" LastActivityDate="2016-12-13T10:45:06.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10609" PostTypeId="2" ParentId="10607" CreationDate="2016-12-13T10:46:42.710" Score="3" Body="&lt;p&gt;I needed to &quot;cast&quot; register contents into a certain (characterwise / linewise / blockwise) mode so often, I wrote the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3355&quot; rel=&quot;nofollow noreferrer&quot;&gt;UnconditionalPaste plugin&lt;/a&gt; for it. It provides &lt;code&gt;gcp&lt;/code&gt;, &lt;code&gt;glp&lt;/code&gt;, etc. alternatives to the built-in paste commands that force a certain mode (and by now several more variations on this theme, like pasting with joined by commas or queried characters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With it, you can just use &lt;code&gt;glp&lt;/code&gt; / &lt;code&gt;glP&lt;/code&gt; to paste after / before the current line (as new lines), regardless of how you've yanked the text.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-13T10:46:42.710" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10610" PostTypeId="2" ParentId="10600" CreationDate="2016-12-13T12:06:15.987" Score="4" Body="&lt;h3&gt;Why&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Commands (custom as well as built-in) are used in mappings, scripts, plugins. If you could override them, it would be very easy to break functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a mechanism for customization that doesn't suffer from this (command-line mode abbreviations); unfortunately, they don't differentiate (between commands and arguments, or commands and searches), so they are too coarse, especially for short tweaks (like &lt;code&gt;:W&lt;/code&gt; &amp;rarr; &lt;code&gt;:w&lt;/code&gt;). Try that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Alias ww wa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Plugin&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.vim.org/script.php?script_id=746&quot; rel=&quot;nofollow noreferrer&quot;&gt;cmdalias.vim - Create aliases for Vim commands&lt;/a&gt; plugin attempts to solve this problem, by defining mappings that only apply in command positions.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-13T12:06:15.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10611" PostTypeId="2" ParentId="9170" CreationDate="2016-12-13T14:10:20.687" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;as soon as I attempt to use netrw by calling vim on a directory all of the sudden things start misbehaving.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;had a similar a problem here, and at least over here, it seemed that the problem was that Netrw was also in the buffer list. In order to avoid that, I'm opening Netrw with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;ff :20Lexplore&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, Netrw won't be added to the buffer list that I'm actually making use of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also added this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_browse_split = 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will make sure that the files won't be opened in the same split where Netrw is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should also add that I haven't had problem with the tree style you mentioned. In fact, here is whole block (used in init.vim):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; nnoremap &amp;lt;leader&amp;gt;ff :20Lexplore&amp;lt;CR&amp;gt;&#xA; let g:netrw_liststyle = 3&#xA; let g:netrw_banner = 0&#xA; let g:netrw_browse_split = 4&#xA; let g:netrw_altv = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since you've mentioned &quot;behavior&quot;, you are probably looking for a better workflow. One thing that I had problem with was the fact that closing a buffer and/or a split would destroy how the layout (of splits and vertical splits, each one with its own buffers). So far, the problem was solved with to two mappings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 - for ':q' (which is used to quit splits, but mainly to quit Netrw when I'm done with it)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-S&amp;gt;a :q&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2 - and another one to delete the buffer, but still keeping the layout. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-A&amp;gt;s :bp&amp;lt;CR&amp;gt;:bd#&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This last mapping will change to the previous buffer (':bp') and close the alternate buffer (':bd#') which - in this case - is the one that I really need to close.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I did these changes to my workflow, I haven't experienced the problem you have. But I'm not sure what exactely was responsible for that change.&lt;/p&gt;&#xA;" OwnerUserId="10493" LastEditorUserId="10493" LastEditDate="2019-10-31T20:22:53.953" LastActivityDate="2019-10-31T20:22:53.953" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10612" PostTypeId="2" ParentId="10547" CreationDate="2016-12-14T00:17:36.133" Score="3" Body="&lt;p&gt;Considering that you have:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;let g:netrw_banner=0&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use 'I', 'i', 'qf' :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;I&lt;/strong&gt; - Toggle the banner (in order to see the path).     (&lt;em&gt;:h netrw-I&lt;/em&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;i&lt;/strong&gt; - &quot;The &quot;i&quot; map cycles between the thin, long, wide, and tree listing formats...&quot;, &quot;The tree listing format has a top directory followed by files and directories preceded by one or more &quot;|&quot;s, which indicate the directory depth.  One may open and close directories by pressing the  key while atop the directoryname. |     (&lt;em&gt;h: netrw-i&lt;/em&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;qf&lt;/strong&gt; - will show information about the file or directory (and also the path). | (&lt;em&gt;:h netrw-qf&lt;/em&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10493" LastActivityDate="2016-12-14T00:17:36.133" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10613" PostTypeId="1" AcceptedAnswerId="10620" CreationDate="2016-12-14T06:49:24.733" Score="0" ViewCount="356" Body="&lt;p&gt;I want to hide the buffer list from the command area - the list doesn't need to be always visible as it can be viewed with a command eg &lt;code&gt;:ls&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior would be similar to &lt;code&gt;set nobl&lt;/code&gt; but global and without affecting &lt;code&gt;:bn&lt;/code&gt; / &lt;code&gt;:bp&lt;/code&gt;. So like &lt;code&gt;set noshowmode&lt;/code&gt; for the buffer list. &lt;code&gt;:silent&lt;/code&gt; looked promising but doesn't seem to persist when switching buffers. The buffer list is also suppressed for a few seconds after executing a &lt;code&gt;:&lt;/code&gt; command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What setting can be added to &lt;code&gt;.vimrc&lt;/code&gt; to permanently hide the buffer list?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Wct7f.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wct7f.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iurzn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iurzn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8685" LastEditorUserId="8685" LastEditDate="2016-12-14T23:12:07.363" LastActivityDate="2018-09-20T00:22:07.300" Title="remove buffer list from command area - VIM 7.4" Tags="|vimrc|statusline|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10614" PostTypeId="1" CreationDate="2016-12-14T09:02:13.783" Score="4" ViewCount="936" Body="&lt;p&gt;I use the mapping below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;C-]&amp;gt; &amp;lt;C-w&amp;gt;&amp;lt;C-]&amp;gt;&amp;lt;C-w&amp;gt;T&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it will open duplicate file in multiple tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Has vim built-in functions which can return a list of tab files? like &lt;code&gt;:tabs&lt;/code&gt; command&lt;/li&gt;&#xA;&lt;li&gt;How to get tag's filename under the cursor?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10500" LastEditorUserId="1841" LastEditDate="2016-12-14T09:51:48.670" LastActivityDate="2016-12-15T19:38:56.370" Title="How to tag jump in new tab, if target file not in active tabs, else switch to exists tab?" Tags="|tags|navigation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10615" PostTypeId="1" AcceptedAnswerId="10624" CreationDate="2016-12-14T12:29:57.937" Score="5" ViewCount="115" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/aloiscochard/codex&quot; rel=&quot;nofollow noreferrer&quot;&gt;codex&lt;/a&gt; for generating tags file but vim does not follow&#xA;tags such as&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$ &amp;lt;$&amp;gt; . &amp;lt;*&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;with &lt;code&gt;ctrl-]&lt;/code&gt; it only works if I manually call tag&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:tag $&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a bug? or there is something that I don't know&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks&lt;/p&gt;&#xA;" OwnerUserId="8851" LastActivityDate="2016-12-15T14:59:40.113" Title="ctrl-] does not work for tags consist of special character ( operators in haskell )" Tags="|tags|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10616" PostTypeId="1" CreationDate="2016-12-14T14:39:08.350" Score="10" ViewCount="1736" Body="&lt;p&gt;Quite often I find myself in need of performing a substitution that will have matches sparsed all over a large file and with non-trivial search and replacement expressions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, say I have some function calls like &lt;code&gt;okFunction(arg1, arg2 arg3)&lt;/code&gt;. The args will differ with every function call, of course. Now say I have discovered a better function that doesn't need &lt;code&gt;arg2&lt;/code&gt;. I can easily adjust the entire file with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\&amp;lt;okFunction(\(\w\+\), \(\w\+\), \(\w\+\))/betterFunction(\1, \3)/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although conceptually simple, I'm not sure I have got the syntax right in this rather long pattern. The &lt;code&gt;c&lt;/code&gt; flag really helps here, but the problem is that when asking for confirmation, vim will not show what the match will be replaced with. I mean, it will show the replacement expression, but not the evaluated result. If I confirm the substitution with &lt;code&gt;y&lt;/code&gt;, vim will immediately jump to the next match and I won't be abe to see if I made any mistakes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found the &lt;a href=&quot;https://github.com/osyo-manga/vim-over&quot; rel=&quot;noreferrer&quot;&gt;vim-over&lt;/a&gt; plugin that partially solves the problem, but only if all mathes are visible on the screen when you are typing the command. Once you hit enter, the behavior is the exact same I described above and I don't get a preview.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there a way to get vim to evaluate the replacement expression when asking for confirmation on substitute commands?&lt;/p&gt;&#xA;" OwnerUserId="5374" LastActivityDate="2016-12-14T15:40:09.683" Title="How to get a preview for the substitution command?" Tags="|substitute|replace|previewing|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10617" PostTypeId="2" ParentId="10616" CreationDate="2016-12-14T15:40:09.683" Score="3" Body="&lt;p&gt;One workaround is macros. Highlight all problem areas and do the substitution on one line at a time. Then decide if you want it or not. Once your done &lt;code&gt;n&lt;/code&gt; to the next area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your case specifically:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Search for areas: &lt;code&gt;/\&amp;lt;okFunction(\(\w\+\), \(\w\+\), \(\w\+\))&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Start recording a macro &lt;code&gt;qq&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Apply &lt;code&gt;:s/\&amp;lt;okFunction(\(\w\+\), \(\w\+\), \(\w\+\))/betterFunction(\1, \3)/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Stop recording macro &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Either undo (&lt;code&gt;u&lt;/code&gt;) or go to next search result (&lt;code&gt;n&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Apply macro &lt;code&gt;@q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Repeat steps 5 and 6 as needed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Obviously not quite what you were looking for, but this usually what I do.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-12-14T15:40:09.683" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10618" PostTypeId="1" CreationDate="2016-12-14T17:30:50.780" Score="5" ViewCount="398" Body="&lt;p&gt;This might be a newbie question but I can't seem to find an answer anywhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've created a custom colorscheme, but I don't know how to stop the character behind the cursor from becoming bold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the &lt;code&gt;Cursor&lt;/code&gt; line from my theme file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/H2xhT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/H2xhT.png&quot; alt=&quot;Vim theme&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be hard to see on the image but the &lt;code&gt;g&lt;/code&gt; after the cursor is bold, or just darker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually &lt;code&gt;gui=NONE&lt;/code&gt; removes any effects from other elements. But this doesn't seem to work with the cursor.&lt;/p&gt;&#xA;" OwnerUserId="10505" LastEditorUserId="1841" LastEditDate="2016-12-15T09:25:09.953" LastActivityDate="2019-07-19T02:10:45.097" Title="Disable bold character under cursor" Tags="|gvim|colorscheme|cursor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10619" PostTypeId="1" CreationDate="2016-12-14T22:53:45.080" Score="6" ViewCount="509" Body="&lt;p&gt;I write my email in &lt;code&gt;vim&lt;/code&gt;, which dynamically inserts newlines after 72 characters.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;formatoptions=awtcql&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works nicely, breaking at spaces. However, is there a way to make it break at hyphens as well?&lt;/p&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="1278" LastEditDate="2019-08-28T11:54:28.290" LastActivityDate="2019-08-28T11:54:28.290" Title="Can auto-format break at hyphens?" Tags="|vimrc|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10620" PostTypeId="2" ParentId="10613" CreationDate="2016-12-15T00:09:33.140" Score="2" Body="&lt;p&gt;I had accidentally copy-pasted an unwanted plugin into my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;bling/vim-bufferline&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Removing this plugin fixed the problem.&lt;/p&gt;&#xA;" OwnerUserId="8685" LastActivityDate="2016-12-15T00:09:33.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10622" PostTypeId="1" CreationDate="2016-12-15T03:35:54.953" Score="0" ViewCount="64" Body="&lt;p&gt;Some recent plugin or Vim upgrade appears to have enabled a new feature:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When moving up/down or clicking, the cursor can now rest anywhere in the window, including over character cells far to the right of where the line has ended.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What is this feature called, and how do I turn it off?&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2016-12-15T03:35:54.953" Title="Cursor can sit in unreachable columns" Tags="|virtualedit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10623" PostTypeId="2" ParentId="10622" CreationDate="2016-12-15T03:35:54.953" Score="4" Body="&lt;p&gt;It turns out a plugin I had recently installed was doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set virtualedit=all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could easily return to the normal behaviour by running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set virtualedit=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can read the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;virtualedit&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation for the &lt;code&gt;virtualedit&lt;/code&gt; option here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2016-12-15T03:35:54.953" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10624" PostTypeId="2" ParentId="10615" CreationDate="2016-12-15T14:59:40.113" Score="7" Body="&lt;p&gt;&lt;code&gt;ctrl-]&lt;/code&gt; uses the &lt;code&gt;word&lt;/code&gt; under the cursor, (as opposed to a &lt;code&gt;WORD&lt;/code&gt;) which means that any punctuation is excluded. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h word&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A word consists of a sequence of letters, digits and underscores, or a&#xA;  sequence of other non-blank characters, separated with white space (spaces,&#xA;  tabs, ).  This can be changed with the 'iskeyword' option.  An empty line&#xA;  is also considered to be a word.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So your options are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Select it with visual mode first to tell it explicitly what you want to search for, or &lt;/li&gt;&#xA;&lt;li&gt;Change the mapping to use a &lt;code&gt;WORD&lt;/code&gt; (which is any white space separated characters).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can do so with the following mapping in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;C-]&amp;gt; :exe &quot;tag &quot;.expand('&amp;lt;cWORD&amp;gt;')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap&lt;/code&gt;: create a non-recursive, normal mode mapping&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;silent&amp;gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;: map CTRL + ] and do it without echoing anything&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:exe&lt;/code&gt;: execute the following string as a command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;tag &quot;&lt;/code&gt;: use the tag command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.expand('&amp;lt;cWORD&amp;gt;')&lt;/code&gt;: append the &lt;code&gt;WORD&lt;/code&gt; under the cursor to the tag command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;: a carriage return. Simply executes the command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Please note that doing this will not allow you to use tags in the vim help files as they surround their tags with &lt;code&gt;||&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h word&lt;/code&gt;, &lt;code&gt;:h WORD&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-12-15T14:59:40.113" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10625" PostTypeId="1" CreationDate="2016-12-15T16:01:51.417" Score="1" ViewCount="422" Body="&lt;p&gt;I'm using CTags and the vim-easytags plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a Python project and a C project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the root of the Python project, I did&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctags -R .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And all was good.  I could jump back and forth with tags in the Python project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there's some keywords that exist in my other project (for instance, the variable &lt;code&gt;mode&lt;/code&gt; exists in both).  If i &lt;code&gt;C-]&lt;/code&gt; those tags, it opens a source file from the C project and finds that tag, erroneously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is CTags getting the idea to include that project in it's searches and how do I tell ctags to only pay attention to python files for python projects and C source/header files for C projects?&lt;/p&gt;&#xA;" OwnerUserId="7051" LastActivityDate="2016-12-15T16:01:51.417" Title="CTags Jumping to Different Project" Tags="|tags|ctags|plugin-easytags|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10626" PostTypeId="1" AcceptedAnswerId="10629" CreationDate="2016-12-15T18:43:52.487" Score="3" ViewCount="444" Body="&lt;p&gt;I know there is a possibility to run a macro in multiple buffers using &lt;code&gt;bufdo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, what I'm not aware, if there is somehow to use a &quot;intercommunicated macro&quot;, e.g:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;File 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar&#xA;bun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;File 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some pseudo macro: &lt;code&gt;ggD(move to buffer 2)o  &quot;^R&quot;&quot;: &quot;^R&quot;&quot;,(move back to buffer 1)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result of such macro would be (after 3 iterations would be):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;File 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  &quot;bun&quot;: &quot;bun&quot;,&#xA;  &quot;bar&quot;: &quot;bar&quot;,&#xA;  &quot;foo&quot;: &quot;foo&quot;,&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10518" LastActivityDate="2016-12-15T21:23:38.813" Title="Run macro between buffers" Tags="|buffers|macro|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10627" PostTypeId="2" ParentId="10614" CreationDate="2016-12-15T19:38:56.370" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Has vim built-in functions which can return a list of tab files? like :tabs command&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You'll have to do some parsing, but you can use &lt;code&gt;let myVar = execute('tabs')&lt;/code&gt; for this.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How to get tag's filename under the cursor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't think there's a built in way to do this but here's a quick and dirty first stab at a function that will do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReturnTagFileUnderCursor()&#xA;   try&#xA;      let tag = expand('&amp;lt;cword&amp;gt;')&#xA;      let tagString = split(execute(&quot;tselect &quot;.tag), &quot;\n&quot;)[1]&#xA;      let tagString = matchstr(tagString, '[^/\\]*$')&#xA;      return tagString&#xA;   catch /^Vim\%((\a\+)\)\=:E426/&#xA;      echohl ERROR&#xA;      echo &quot;Tag not found!&quot;&#xA;      echohl NORMAL&#xA;      return &quot;&quot;&#xA;   endtry&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: This will always take the first result if there are duplicate tags. Also it returns just the filename, but you can adjust the regex to get the whole path if desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h execute()&lt;/code&gt; and &lt;code&gt;:h tselect&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-12-15T19:38:56.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10628" PostTypeId="1" AcceptedAnswerId="10634" CreationDate="2016-12-15T20:14:55.093" Score="5" ViewCount="728" Body="&lt;p&gt;There are times I know I just want to paste the content of the register inline where my cursor is, so the initial and trailing whitespace (newline, tab, etc) is not wanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because selecting contents on a web browser does not always reflect what's being copied, I am forced to just clean up after pasting or paste in another line then copy the contents without whitespace to a proper place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I paste without the whitespace?&lt;/p&gt;&#xA;" OwnerUserId="10520" LastActivityDate="2016-12-16T15:30:38.483" Title="Is there a way to strip the contents of register before pasting" Tags="|register|whitespace|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10629" PostTypeId="2" ParentId="10626" CreationDate="2016-12-15T20:47:43.457" Score="7" Body="&lt;p&gt;Just for completeness's sake (and so that this doesn't get bumped in six months by Community):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can put a buffer command (&lt;code&gt;:b&lt;/code&gt;) in macros. For your case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqggD:b#^Mo^R&quot;:b#^Mq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &quot;#&quot; is the number of the buffer you want to switch to, &lt;code&gt;^M&lt;/code&gt; is pressing &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;, and &lt;code&gt;^R&lt;/code&gt; is pressing &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h buffer&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-12-15T21:23:38.813" LastActivityDate="2016-12-15T21:23:38.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10630" PostTypeId="2" ParentId="10580" CreationDate="2016-12-15T21:42:24.457" Score="2" Body="&lt;p&gt;As per Carpetsmoker's comment you can put just these &lt;code&gt;hi&lt;/code&gt; commands in the &lt;code&gt;syntax&lt;/code&gt; folder per file type, or use an autocmd in your &lt;code&gt;vimrc&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype * call CustomHighlight()&#xA;&#xA;function! CustomHighlight()&#xA;    hi clear Keyword&#xA;    hi clear Comment&#xA;    hi link Keyword Function&#xA;    hi link Comment Function&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can choose whichever color you like best of the three, but I think this should do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h hi-link&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2016-12-19T16:49:25.800" LastActivityDate="2016-12-19T16:49:25.800" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10631" PostTypeId="1" AcceptedAnswerId="10639" CreationDate="2016-12-16T06:30:50.790" Score="2" ViewCount="472" Body="&lt;p&gt;I'm using vim version 8.0 on OS X (installed through Homebrew) and it keeps indenting object literals wrong. The first key and only the first key is flush with the previous line. All subsequent keys are indented four spaces.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var object = {&#xA;    key1: &quot;value1&quot;,&#xA;    key2: &quot;value2&quot;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var object = {&#xA;key1: &quot;value1&quot;,&#xA;    key2: &quot;value2&quot;,&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The javascript indentation file is here.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/local/share/vim/vim80/indent/javascript.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is pretty clearly the pangloss/vim-javascript plugin.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat /usr/local/share/vim/vim80/indent/javascript.vim  | head -n 5&#xA;&quot; Vim indent file&#xA;&quot; Language: Javascript&#xA;&quot; Maintainer: Chris Paul ( https://github.com/bounceme )&#xA;&quot; URL: https://github.com/pangloss/vim-javascript&#xA;&quot; Last Change: August 25, 2016&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;STR:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% touch awesome.js&#xA;% vim -u NONE awesome.js&#xA;&#xA;:set filetype=javascript&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;type out javascript example&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YvAqV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YvAqV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg=G&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;voilà incorrectly indented code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MXA5K.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MXA5K.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there isn't some hidden configuration setting that's causing the bundled indenter for javascript to act up, is there a way to completely shadow &lt;code&gt;&amp;lt;...&amp;gt;/indent/javascript.vim&lt;/code&gt; and &lt;code&gt;&amp;lt;...&amp;gt;/syntax/javascript.vim&lt;/code&gt; so I can start writing a replacement?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="51" LastEditDate="2016-12-17T01:00:01.147" LastActivityDate="2016-12-17T01:51:59.247" Title="Configure JavaScript indentation to indent keys object literals" Tags="|indentation|filetype-javascript|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10632" PostTypeId="2" ParentId="10628" CreationDate="2016-12-16T06:40:59.710" Score="2" Body="&lt;p&gt;If you want to paste where your cursor is, you could try pasting &lt;strong&gt;in insert&lt;/strong&gt; mode with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-R&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command above (- ctrl-r + &quot; - ) will not add a new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have more than one line of text to paste, and want to get rid any empty space that might come along, you could create a macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq&#xA;:e testtext&#xA;^d0&#xA;dG&#xA;:bd!&#xA;pq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This macro ('@q') will open a new buffer called testtext (':e testtext'), go to the first non-empty character on the line ('^') and delete until the beginning of the line ('d0'), close the buffer without saving (':bd!'), and paste the text on the original file without the initial blank spaces. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just out of curiosity, could you give an example of a real situation? All situation I could think of, could be solved with a macro and/or a mapping. But I'm not sure what you are looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additional information about the topic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many tips on &lt;a href=&quot;http://vim.wikia.com/wiki/Remove_unwanted_spaces&quot; rel=&quot;nofollow noreferrer&quot;&gt;how to remove unwanted whitespaces&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A script that &lt;a href=&quot;https://github.com/vim-scripts/DeleteTrailingWhitespace&quot; rel=&quot;nofollow noreferrer&quot;&gt;deletes white spaces&lt;/a&gt; at the end of lines.&lt;/p&gt;&#xA;" OwnerUserId="10493" LastEditorUserId="343" LastEditDate="2016-12-16T15:30:38.483" LastActivityDate="2016-12-16T15:30:38.483" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10633" PostTypeId="1" AcceptedAnswerId="10637" CreationDate="2016-12-16T08:03:58.497" Score="3" ViewCount="2073" Body="&lt;p&gt;I think noticing a slow redrawing and slow cursor movement on a fastest PC, is one of the popular frustrations with Vim. Here I am as a yet another instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a fresh installation of VIM, with the &lt;code&gt;$MYVIMRC&lt;/code&gt; at the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is basically a painful slowdown of cursor movements and screen redraws, which are seen often after a while when&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;lot many buffers parallelly open&lt;/li&gt;&#xA;&lt;li&gt;a longer sessions with multiple buffers used&#xA;but not immediately after I start vim. They may not be the only cases though.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is frustrating because, the problem is not easily reproducible. I cannot debug by line by line in $VIMRC, because I don't know how long should I wait to see slow down. All that I could do over the time is to observe the two above cases. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can some of the vim-monks quickly see where the problem is in the vimrc below? (I copied all except a heap of &lt;code&gt;:nnoremap&lt;/code&gt; commands that I often use)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nocompatible&#xA;:set regexpengine=1     &quot;The new engine replaced with old (suggested on vi.SE)&#xA;:set foldmethod=marker   &quot;fold based on default-markers &#xA;:set foldnestmax=10      &quot;deepest fold is 10 levels&#xA;:set nofoldenable        &quot;dont fold by default&#xA;:set noswapfile     &quot;Realized that swap troubles much more than it helps &#xA;:set number&#xA;:set wildmenu&#xA;:set guifont=Monospace\ 12&#xA;:colorscheme industry&#xA;&#xA;&quot;Make search more user-friendly&#xA;:set incsearch  &quot;Search as you go&#xA;:set hlsearch   &quot;Highlight matches&#xA;:set ignorecase &quot;Case-insensitive searches&#xA;&#xA;:set showmatch  &quot;Quickly jump to matching bracket/brace etc&#xA;&#xA; %for highlighting in red all exceedingly longer lines&#xA;:au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%&amp;gt;85v.\+', -1)&#xA;                      &quot;==&amp;gt; This seems to be the potential culprit..&#xA;&#xA;:filetype plugin on&#xA;:runtime macros/matchit.vim&#xA;&#xA;:set formatoptions=tcroqlj&#xA;&#xA;:au VimLeave * :mapclear &#xA;:au VimLeave * :mksession! ~/.hari_vim_session&#xA;:au VimLeave * :%normal g_lD&#xA;&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'tpope/vim-surround'&#xA;Plugin 'tpope/vim-repeat'&#xA;Plugin 'vim-scripts/tComment'   &quot; Toggle Comments -- comment/uncomment&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'vim-airline/vim-airline'        &#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;Plugin 'bling/vim-bufferline'&#xA;                 &quot;Is this bufferline the culprit? Thought it was nice!!&#xA;Plugin 'vim-scripts/vis'    &quot;Vertically selection to filters&#xA;call vundle#end()&#xA;&#xA;:set lazyredraw   &quot;Don't redraw unnecessarily too many times&#xA;:set ttyfast &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW, following &#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file?noredirect=1&amp;amp;lq=1&quot;&gt;How do I debug my vimrc file?&lt;/a&gt; when I started vim in no-plugin no-vimrc mode, I see no slow down, but the default interface is not usable to me. I need some modifications as I did in above &lt;code&gt;$MYVIMRC&lt;/code&gt;. Hope you don't ask me to withdraw the whole &lt;code&gt;$MYVIMRC&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4583" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2022-05-29T00:49:37.720" Title="Vim slows down with multiple buffers etc" Tags="|vimrc|performance|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="10634" PostTypeId="2" ParentId="10628" CreationDate="2016-12-16T09:48:53.500" Score="2" Body="&lt;p&gt;I needed to &quot;cast&quot; register contents into a certain (characterwise / linewise / blockwise) mode so often, I wrote the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3355&quot; rel=&quot;nofollow noreferrer&quot;&gt;UnconditionalPaste plugin&lt;/a&gt; for it. It provides &lt;code&gt;gcp&lt;/code&gt;, &lt;code&gt;glp&lt;/code&gt;, etc. alternatives to the built-in paste commands that force a certain mode (and by now several more variations on this theme, like pasting with joined by commas or queried characters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;gcp&lt;/code&gt; mapping pastes characterwise (inner newline characters and indent are flattened to a single space, leading and trailing removed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just want to remove leading and trailing whitespace, you can use &lt;code&gt;g=p&lt;/code&gt; with this expression: &lt;code&gt;ingo#str#Trim(v:val)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-16T09:48:53.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10635" PostTypeId="1" AcceptedAnswerId="10645" CreationDate="2016-12-16T20:40:55.067" Score="2" ViewCount="192" Body="&lt;p&gt;I have &lt;kbd&gt;@@&lt;/kbd&gt; mapped to &lt;kbd&gt;Space&lt;/kbd&gt;. This can be really convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes I want to combine a macro with another. So maybe I need to record &lt;code&gt;q&lt;/code&gt; as &lt;code&gt;@:/jump&lt;/code&gt; to run my last regex substitution and move to the next place I probably want to run it. Then &lt;kbd&gt;@q&lt;/kbd&gt; and press &lt;kbd&gt;Space&lt;/kbd&gt; until I'm happy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately if you run &lt;kbd&gt;@q&lt;/kbd&gt;, during the macro the &lt;kbd&gt;@@&lt;/kbd&gt; repeat will be set to &lt;kbd&gt;@:&lt;/kbd&gt;. Is there a way to run &lt;kbd&gt;@:&lt;/kbd&gt; without setting it to &lt;kbd&gt;@@&lt;/kbd&gt; while recording the macro for &lt;code&gt;q&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this toy example, instead of combining macros I could copy the substitution into a register and paste it during the &lt;code&gt;q&lt;/code&gt; recording, but that requires more foresight, and a bit of fiddling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess as far as combining &lt;kbd&gt;@:&lt;/kbd&gt; goes, I can always use &lt;code&gt;:%s/\v//gc...&lt;/code&gt; There are situations I've wanted to combine macros that have nothing to do with regex though. Only option I can think of so far to do what I want is remap &lt;kbd&gt;Space&lt;/kbd&gt; to always be &lt;kbd&gt;@q&lt;/kbd&gt;, instead of the last macro, which might be okay since that's 80% of the time what I mean.&lt;/p&gt;&#xA;" OwnerUserId="8483" LastEditorUserId="5395" LastEditDate="2016-12-16T21:31:17.577" LastActivityDate="2016-12-17T20:37:03.883" Title="Run a macro without having it set as last macro (@@)" Tags="|macro|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10637" PostTypeId="2" ParentId="10633" CreationDate="2016-12-17T01:20:54.347" Score="3" Body="&lt;p&gt;I have no idea if any of the following will help, but here are a few things you could try.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have the following autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%&amp;gt;85v.\+', -1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't read your whole &lt;code&gt;vimrc&lt;/code&gt; file, so maybe you already did it in the missing part, but in case you didn't, you should probably wrap this autocmd (and the other ones) inside an augroup.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup long_lines&#xA;    au!&#xA;    au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%&amp;gt;85v.\+', -1)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The line &lt;code&gt;au!&lt;/code&gt; makes sure to delete all the autocmds inside the current augroup every time you source your &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without this augroup and the &lt;code&gt;au!&lt;/code&gt; line, each time you source your &lt;code&gt;vimrc&lt;/code&gt;, a new identical autocmd is added, and you should be able to reproduce some slowdown by sourcing your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:so $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... then repeating this command enough time.&lt;br&gt;&#xA;For example, to repeat it &lt;code&gt;40&lt;/code&gt; times, you could type, in normal mode, &lt;code&gt;40@:&lt;/code&gt;.&lt;br&gt;&#xA;&lt;code&gt;@:&lt;/code&gt; will reexecute the last Ex command, the number of times you asked (here &lt;code&gt;40&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/14.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/9455/why-should-i-use-augroup&quot;&gt;here&lt;/a&gt; for more info.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Currently, the autocmd adds a new identical match every time a buffer is displayed in a window, which is probably unnecessary.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you reload your current buffer, by typing &lt;code&gt;:e&lt;/code&gt;, you should see that a new identical match has been created. You can see it with the &lt;code&gt;getmatches()&lt;/code&gt; function, by typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo getmatches()&#xA;&quot; info about the current matches&#xA;&#xA;:echo len(getmatches())&#xA;&quot; number of matches&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you reload your buffer enough times, by typing for example &lt;code&gt;40@:&lt;/code&gt; (to reexecute the last Ex command, which here is &lt;code&gt;:e&lt;/code&gt;, fourty times), you should see a big list of identical matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there, if you load one of your usual files, you should probably experience some slowdown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The previous augroup and the &lt;code&gt;au!&lt;/code&gt; command won't protect you from these duplications. You need a second protection on top of the augroup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you could ask Vim to check whether you already created a match with the &lt;code&gt;exists()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('w:m2')&#xA;    &quot; create your match and store its identifier inside the variable `w:m2`&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The exclamation mark before &lt;code&gt;exists()&lt;/code&gt; is there to invert the test. You don't want to create the match when one already exists. You want to create a match when one does NOT already exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, all in all, you could try this autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup long_lines&#xA;    au!&#xA;    au BufWinEnter * if !exists('w:m2') | let w:m2=matchadd('ErrorMsg', '\%&amp;gt;85v.\+', -1) | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You don't need to disable the &lt;code&gt;'compatible'&lt;/code&gt; option, because it should be done automatically by Vim if it finds a &lt;code&gt;vimrc&lt;/code&gt;. From &lt;code&gt;:h 'cp&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When a |vimrc| or |gvimrc| file is found while Vim is starting up,&#xA;this option is switched off, and all options that have not been&#xA;modified will be set to the Vim defaults.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It's not linked to your issue, but you don't need to prefix your commands with a colon &lt;code&gt;:&lt;/code&gt;, because when Vim sources your &lt;code&gt;vimrc&lt;/code&gt; it interprets the lines as Ex commands (and not normal commands).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't need to prefix your autocmds with a colon either. Because an autocmd executes Ex commands by default. It doesn't execute normal commands, like &lt;code&gt;dd&lt;/code&gt; (you would have to write &lt;code&gt;normal! dd&lt;/code&gt;, but &lt;code&gt;normal&lt;/code&gt; is still an Ex command).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, as an example, you could rewrite this part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au VimLeave * :mapclear &#xA;:au VimLeave * :mksession! ~/.hari_vim_session&#xA;:au VimLeave * :%normal g_lD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup my_augroup&#xA;    au!&#xA;    au VimLeave * mapclear &#xA;    au VimLeave * mksession! ~/.hari_vim_session&#xA;    au VimLeave * %normal g_lD&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could also try to avoid writing comments right after an Ex command.&lt;br&gt;&#xA;Try to write your comments on their own dedicated lines.&lt;br&gt;&#xA;In particular avoid adding a comment right after a mapping.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If Vim is still slow, and you suspect something in your &lt;code&gt;vimrc&lt;/code&gt; is the cause, you could write the line &lt;code&gt;finish&lt;/code&gt; somewhere in the middle of it. But don't write &lt;code&gt;finish&lt;/code&gt; between the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call vundle#begin()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call vundle#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Anything after &lt;code&gt;finish&lt;/code&gt; won't be executed by Vim. If the problem persists, it means the cause is somewhere before &lt;code&gt;finish&lt;/code&gt;, otherwise after.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, you repeat the process.&lt;br&gt;&#xA;If you know that the cause is in the first half of your &lt;code&gt;vimrc&lt;/code&gt;, you move &lt;code&gt;finish&lt;/code&gt; in the middle of it (that is after &lt;code&gt;1/4&lt;/code&gt; of the file), otherwise in the middle of the second half (that is after &lt;code&gt;3/4&lt;/code&gt; of the file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in the first step, you write &lt;code&gt;finish&lt;/code&gt; after half of the file.&lt;br&gt;&#xA;In the second step, you write it after &lt;code&gt;1/4&lt;/code&gt; or &lt;code&gt;3/4&lt;/code&gt; of the file (depending on the result of the previous step).&lt;br&gt;&#xA;In the third step, you write it after &lt;code&gt;1/8&lt;/code&gt;, &lt;code&gt;3/8&lt;/code&gt;, &lt;code&gt;5/8&lt;/code&gt; or &lt;code&gt;7/8&lt;/code&gt; of the file.&lt;br&gt;&#xA;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After each step, you should be able to eliminate half of the remaining lines as possible suspects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To move your cursor right after the first half of your file, from normal mode, you can type &lt;code&gt;50%&lt;/code&gt;.&lt;br&gt;&#xA;To move it after &lt;code&gt;1/4&lt;/code&gt; of the file, you can type &lt;code&gt;25%&lt;/code&gt;.&lt;br&gt;&#xA;After &lt;code&gt;1/8&lt;/code&gt;, &lt;code&gt;12%&lt;/code&gt; or &lt;code&gt;13%&lt;/code&gt;, etc.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-12-17T13:10:17.450" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10638" PostTypeId="2" ParentId="10619" CreationDate="2016-12-17T01:37:50.203" Score="3" Body="&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27textwidth%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'textwidth'&lt;/code&gt;&lt;/a&gt; is documented as:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Maximum width of text that is being inserted.  A longer line will be broken&#xA;  after white space to get this width.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Reading &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#fo%2dtable&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help fo-table&lt;/code&gt;&lt;/a&gt;, it seems&#xA;there is only one option to change this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;m       Also break at a multi-byte character above 255.  This is useful for&#xA;        Asian text where every character is a word on its own.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which brings us to a possible workaround – you can use the en dash (U+2013) or&#xA;another non-ascii character instead of a normal hyphen (U+002D):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatoptions+=m&#xA;:inoremap - –&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's a bit ugly, but may work in your case.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A second – more complicated – solution can also be found in &lt;code&gt;:help&#xA;textwidth&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When 'formatexpr' is set it will be used to break the line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27formatexpr%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'formatexpr'&lt;/code&gt;&lt;/a&gt; for&#xA;some details. Personally, I've never been able to get this to work quite right&#xA;for &quot;live formatting&quot; (as opposed to &lt;code&gt;gq&lt;/code&gt; formatting), but it should be possible&#xA;(I never tried very hard).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And lastly, you can use &lt;code&gt;:%!&lt;/code&gt; or &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27formatprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'formatprg'&lt;/code&gt;&lt;/a&gt;&#xA;to run an external command over the text. This is not ideal as you'll have to&#xA;run this manually every time, but it's an option (you could also just write a&#xA;Vimscript command for this though).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-12-17T01:37:50.203" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10639" PostTypeId="2" ParentId="10631" CreationDate="2016-12-17T01:51:59.247" Score="1" Body="&lt;p&gt;As of 2016-12-16, the javascript.vim indenter will break if you &lt;code&gt;set nomagic&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current workaround is to &lt;em&gt;not&lt;/em&gt; use &lt;code&gt;set nomagic&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2016-12-17T01:51:59.247" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10640" PostTypeId="2" ParentId="10582" CreationDate="2016-12-17T02:00:24.653" Score="3" Body="&lt;p&gt;You can only set options with the modeline. You can't run Vimscript with it. This is for security reasons, because running code from random text files is not very good security.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason that running &lt;code&gt;normal zv&lt;/code&gt; from the autocommand doesn't work is that the &lt;code&gt;BufReadPost&lt;/code&gt; autocommand is run &lt;em&gt;before&lt;/em&gt; the modeline is processed. From &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#BufReadPost&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help BufReadPost&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BufRead or BufReadPost          When starting to edit a new buffer, after&#xA;                                reading the file into the buffer, before&#xA;                                executing the modelines.  See BufWinEnter&#xA;                                for when you need to do something after&#xA;                                processing the modelines.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Luckily, it also provides a hint on how to proceed :-) Adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWinEnter * normal! zv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Seems to work well.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-12-17T02:00:24.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10641" PostTypeId="2" ParentId="10592" CreationDate="2016-12-17T02:21:11.353" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;However, it seemingly highlights it with the function name in a same way.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;:echo synIDattr(synID(line('.'), col('.'), 1), 'name')&lt;/code&gt; we can get the&#xA;name of the syntax group, which is indeed &lt;code&gt;pythonFunction&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at &lt;code&gt;/usr/share/vim/vim80/syntax/python.vim&lt;/code&gt; we can see this is&#xA;highlighted with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword pythonStatement     class def nextgroup=pythonFunction skipwhite&#xA;syn match   pythonFunction  &quot;\h\w*&quot; display contained&#xA;hi def link pythonFunction      Function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no facility to highlight classes separately. If you want to add this,&#xA;you can use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Clear default&#xA;syn clear pythonStatement&#xA;&#xA;&quot; Set it to what's in the Python file, minus the class.&#xA;syn keyword pythonStatement    False None True&#xA;syn keyword pythonStatement    as assert break continue del exec global&#xA;syn keyword pythonStatement    lambda nonlocal pass print return with yield&#xA;syn keyword pythonStatement    def nextgroup=pythonFunction skipwhite&#xA;&#xA;&quot; Now make seperate syntax groups for the class.&#xA;syn keyword pythonClassStmt class nextgroup=pythonClass skipwhite&#xA;syn match   pythonClass &quot;\h\w*&quot; display contained&#xA;&#xA;&quot; Avoid highlighting attributes as builtins – just added &quot;pythonClass&quot; here.&#xA;syn clear pythonAttribute&#xA;syn match   pythonAttribute /\.\h\w*/hs=s+1&#xA;    \ contains=ALLBUT,pythonBuiltin,pythonFunction,pythonClass,pythonAsync&#xA;    \ transparent&#xA;&#xA;&quot; Highlight the class statement and the class name.&#xA;hi def link pythonClassStmt Statement&#xA;hi pythonClass ctermfg=darkgreen guifg=darkgreen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used darkgreen because this is what Ruby uses, but feel free to use any colour&#xA;you like. You could highlight the &lt;code&gt;class&lt;/code&gt; keyword any way you'd like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make this loads &lt;em&gt;after&lt;/em&gt; the built-in Python syntax file add this to&#xA;&lt;code&gt;~/.vim/after/syntax/python.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see: &lt;a href=&quot;https://vi.stackexchange.com/a/8773/51&quot;&gt;Fixing “missing” syntax highlighting for python&lt;/a&gt;&#xA;for a general primer on syntax highlighting and some more details.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2016-12-19T23:37:27.820" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="10642" PostTypeId="1" AcceptedAnswerId="10643" CreationDate="2016-12-17T03:47:31.573" Score="11" ViewCount="4075" Body="&lt;p&gt;Say I have a comment like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//This is a comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to make it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//*****************&#xA;//This is a comment&#xA;//*****************&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there an easy way to insert a character repeatedly until even with the next/previous line?&lt;/p&gt;&#xA;" OwnerUserId="10038" LastEditorUserId="28" LastEditDate="2017-12-31T00:22:53.187" LastActivityDate="2022-03-08T01:43:12.923" Title="How can I insert a character repeatedly until even with next line?" Tags="|insert-mode|repeated-commands|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10643" PostTypeId="2" ParentId="10642" CreationDate="2016-12-17T03:57:00.870" Score="12" Body="&lt;h1&gt;Short answer&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;v&#xA;&lt;/kbd&gt; &lt;kbd&gt;&#xA;$&#xA;&lt;/kbd&gt; &lt;kbd&gt;&#xA;r&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;&lt;code&gt;*&lt;/code&gt;&#xA;&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#v_r&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help v_r&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Longer answer&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;y&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;y&#xA;&lt;/kbd&gt;&#xA;&lt;kbd&gt;&#xA;p&#xA;&lt;/kbd&gt;/&lt;kbd&gt;&#xA;P&#xA;&lt;/kbd&gt;     Duplicate line to below/above&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;2&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;l&#xA;&lt;/kbd&gt;                    Move to position from where to overwrite (in this case 3rd column ← 2 to the right)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;v&#xA;&lt;/kbd&gt; &lt;kbd&gt;&#xA;$&#xA;&lt;/kbd&gt;                  Select till end of line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;r&#xA;&lt;/kbd&gt;                          &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#v_r&quot; rel=&quot;nofollow noreferrer&quot;&gt;Replace all selected characters by char…&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;*&#xA;&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="2314" LastEditorUserId="22375" LastEditDate="2020-05-03T21:04:13.517" LastActivityDate="2020-05-03T21:04:13.517" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10644" PostTypeId="2" ParentId="10642" CreationDate="2016-12-17T04:22:15.820" Score="3" Body="&lt;p&gt;At the occasion°:&lt;/p&gt;&#xA;&lt;h1&gt;Insert mode mappings to replicate the remainder of adjacent line&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Insert the rest of the line below the cursor.&#xA;&amp;quot; Mnemonic: Elevate characters from below line&#xA;:inoremap &amp;lt;A-e&amp;gt; &#xA;    \&amp;lt;Esc&amp;gt;&#xA;    \jl&#xA;        \y$&#xA;    \hk&#xA;        \p&#xA;        \a&#xA;&amp;quot; Insert the rest of the line above the cursor.&#xA;&amp;quot; Mnemonic:  Y depicts a funnel, through which the above line's characters pour onto the current line.&#xA;:inoremap &amp;lt;A-y&amp;gt; &#xA;    \&amp;lt;Esc&amp;gt;&#xA;    \kl&#xA;        \y$&#xA;    \hj&#xA;        \p&#xA;        \a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;Copying single characters from neighboring lines in Insert mode&lt;/h1&gt;&#xA;&lt;p&gt;… is built-in: &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-E&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-E   Insert the character which is below the cursor.&#xA;CTRL-Y   Insert the character which is above the cursor.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sub&gt;° Not what the question text was about, but what other users might be looking for here, going from the current question title &amp;quot;insert until even with next line&amp;quot;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="2314" LastEditorUserId="2314" LastEditDate="2022-03-08T01:43:12.923" LastActivityDate="2022-03-08T01:43:12.923" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10645" PostTypeId="2" ParentId="10635" CreationDate="2016-12-17T04:37:13.537" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a way to run @: without setting it to @@ while recording the macro for q?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For normal 'character' registers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call feedkeys(@a)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;&#xA;&lt;code&gt;&quot;:&lt;/code&gt; needs special handling:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call feedkeys(':' . @: . &quot;\&amp;lt;CR&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;&#xA;If you use this often, you may want to map it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; for @:&#xA;:noremap @- :&amp;lt;C-u&amp;gt;call feedkeys(':' . @: . &quot;&amp;lt;Bslash&amp;gt;&amp;lt;lt&amp;gt;CR&amp;gt;&quot;)&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; for normal char registers&#xA;:noremap @_ :&amp;lt;C-u&amp;gt;call feedkeys(@)&amp;lt;Left&amp;gt;&#xA;&#xA;&quot; more complex version of the latter, improved to not need a final &amp;lt;CR&amp;gt;&#xA;noremap @_ :&amp;lt;C-u&amp;gt;call FeedReg()&amp;lt;CR&amp;gt;&#xA;function! FeedReg()&#xA;  echo 'Enter register name character:'&#xA;  let reg=nr2char(getchar())&#xA;  call feedkeys(getreg(reg))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2314" LastEditorUserId="2314" LastEditDate="2016-12-17T20:37:03.883" LastActivityDate="2016-12-17T20:37:03.883" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10646" PostTypeId="2" ParentId="10635" CreationDate="2016-12-17T05:26:43.013" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a way to run @: without setting it to @@ while recording the macro for q?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:&amp;lt;C-p&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(or equivalently&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:&amp;lt;Up&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="2314" LastEditorUserId="2314" LastEditDate="2016-12-17T19:48:08.537" LastActivityDate="2016-12-17T19:48:08.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10647" PostTypeId="2" ParentId="2003" CreationDate="2016-12-17T07:12:31.860" Score="12" Body="&lt;p&gt;One thing that I've found helps is keeping a collection of variables that toggle parts of your &lt;code&gt;.vimrc&lt;/code&gt; so you can disable or enable portions of it without having to comment stuff out. It also has the pleasant side effect of forcing you to think about the organization of your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; feature toggles in vimrc&#xA;let g:vimrc_feat_pathogen               = 1&#xA;let g:vimrc_feat_core_minimal           = 1&#xA;let g:vimrc_feat_matchit                = 1&#xA;let g:vimrc_feat_options                = 1&#xA;let g:vimrc_feat_colors_and_highlight   = 1&#xA;let g:vimrc_feat_key_rebinding_arpeggio = 1&#xA;let g:vimrc_feat_key_rebinding          = 1&#xA;let g:vimrc_feat_autocommand_group      = 1&#xA;let g:vimrc_feat_custom_definitions     = 1&#xA;let g:vimrc_feat_load_opam              = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's an example of a section guarded by an &lt;code&gt;if&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if g:vimrc_feat_core_minimal&#xA;    set nocompatible&#xA;    filetype plugin indent on&#xA;    syntax on&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2016-12-17T07:12:31.860" CommentCount="0" CommunityOwnedDate="2016-12-17T07:12:31.860" ContentLicense="CC BY-SA 3.0" />
  <row Id="10648" PostTypeId="2" ParentId="6142" CreationDate="2016-12-18T09:33:09.257" Score="1" Body="&lt;p&gt;This could be an issue with vim's system for recognising and then highlighting syntactic &quot;keywords&quot; not getting enough context to recognise keywords.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic concepts of vim's syntax system (finding and tagging basic syntax elements) is explained in &lt;code&gt;:h usr_44&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically vim uses regex to recognise syntactic elements in a file, once these are identified, then highlighting rules are applied to colorise those code constructs, (i.e. to do &quot;syntax highlighting&quot;), but as explained in &lt;code&gt;:h 44.10&lt;/code&gt; vim doesn't start parsing from the beginning of the file, it starts some number of lines (e.g. 10 or 100 lines) upward from the top of your current viewport.&lt;br&gt;&#xA;If a syntactic construct, e.g. an opening HTML tag or a function definition etc starts higher than the point vim starts parsing, vims syntax regex breaks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually to fix this you increase the point that vim starts parsing.&lt;br&gt;&#xA;To find out how many lines above the top line of the viewport vim is starting its parsing use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax sync&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my output when viewing an HTML file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax sync&#xA;--- Syntax sync items ---&#xA;syncing on items; minimal 10, maximal 100 lines before top line&#xA;[lots of other output here...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if I had a problem with syncing - just for that file - I would increase&#xA;minlines with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax sync minlines=200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you repeatedly get this problem fixing it is a bit harder. This is because the sync value is often set in a syntax file dedicated to the filetype you are editing, e.g. for me &lt;code&gt;syntax sync minlines&lt;/code&gt; for html filetypes is set in the syntax file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/vim/vim74/syntax/html.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;syntax parsing and config values for css files is in &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/vim/vim74/syntax/css.vim &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;shell is in &lt;code&gt;sh.vim&lt;/code&gt; and so on.&lt;br&gt;&#xA;These syntax scripts only run at the time you open a file of the type &lt;code&gt;foo.css&lt;/code&gt;, &lt;code&gt;bar.html&lt;/code&gt;, &lt;code&gt;baz.sh&lt;/code&gt; etc, so setting a line in your vimrc won't work because these scripts would blow your settings away, one solution is to use an autocmd which triggers when you enter the file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter *.html :syntax sync minlines=200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2016-12-18T23:39:01.807" LastActivityDate="2016-12-18T23:39:01.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10649" PostTypeId="1" AcceptedAnswerId="10651" CreationDate="2016-12-18T14:04:25.687" Score="3" ViewCount="161" Body="&lt;p&gt;I've got the following mappings and abbreviations in my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;,&quot;&#xA;inoremap &amp;lt;leader&amp;gt;( ()&amp;lt;ESC&amp;gt;i&#xA;iabbrev pirnt print&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now abbreviations won't expand if the following character is an open parenthesis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pirnt,(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it won't correct my spelling mistake, and it leaves me with &lt;code&gt;pirnt()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to be the case for all mappings, for example I've got &lt;code&gt;jj&lt;/code&gt; mapped to &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;, and if I type &lt;code&gt;pirntjj&lt;/code&gt; it simply puts me in normal mode, leaving my spelling mistake there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not using a leader has no effect, either.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap ( ()&amp;lt;ESC&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;produces the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make Vim expand abbreviations if the following character is mapped to something else?&lt;/p&gt;&#xA;" OwnerUserId="10545" LastActivityDate="2016-12-22T14:54:34.640" Title="Expand abbreviation when the following non-keyword character is mapped to something else" Tags="|key-bindings|abbreviations|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10650" PostTypeId="1" AcceptedAnswerId="10653" CreationDate="2016-12-18T16:30:10.320" Score="6" ViewCount="982" Body="&lt;p&gt;I can complete functions with omnicomplete using &lt;code&gt;c-x c-o&lt;/code&gt; but it only adds the opening parenthesis, is it possible to make it add the closing parenthesis and put my cursor between them? Seems unaffected by auto-pairs and delimitmate, which work fine when I type the opening parenthesis, but not when it's inserted during completion. &lt;/p&gt;&#xA;" OwnerUserId="10548" LastActivityDate="2016-12-19T04:22:20.960" Title="Add closing parenthesis when completing function (omnicomplete)" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10651" PostTypeId="2" ParentId="10649" CreationDate="2016-12-18T20:39:21.180" Score="1" Body="&lt;p&gt;I don't know why the abbreviation is not automatically expanded when you use your mapping, but you can manually trigger its expansion by hitting &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h i^]&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-]      Trigger abbreviation, without inserting a character.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, maybe you could use this key at the beginning of the &lt;code&gt;{rhs}&lt;/code&gt; of your insert-mode mapping, to trigger the expansion of a possible abbreviation before inserting the parentheses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;leader&amp;gt;( &amp;lt;C-]&amp;gt;()&amp;lt;Esc&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2016-12-18T20:39:21.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10652" PostTypeId="1" CreationDate="2016-12-18T21:41:12.670" Score="5" ViewCount="1355" Body="&lt;p&gt;&lt;code&gt;Ctrl-]&lt;/code&gt; is how one is supposed to move around interactively in Vim on &quot;linkable&quot; text, for instance in the help files. On US layouts, this is simply a two finger combo. Unfortunately the &quot;]&quot; character is a bit awkward to type on Norwegian keyboard layouts (AltGr+9), so I was simply wondering what other fellow Vim-users with non-English layouts do to efficiently move about?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2VukW.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2VukW.jpg&quot; alt=&quot;norwegian keyboard&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1087" LastEditorUserId="1087" LastEditDate="2019-06-03T19:23:25.557" LastActivityDate="2019-06-03T19:23:25.557" Title="How do international users use Ctrl-] efficiently? Remapping?" Tags="|key-bindings|keyboard-layout|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="10653" PostTypeId="2" ParentId="10650" CreationDate="2016-12-18T22:52:24.220" Score="4" Body="&lt;p&gt;You could try the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt; &amp;lt;C-r&amp;gt;=&amp;lt;SID&amp;gt;close_paren()&amp;lt;CR&amp;gt;&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&#xA;&#xA;function! s:close_paren() abort&#xA;    augroup close_paren&#xA;        autocmd!&#xA;        autocmd CompleteDone &amp;lt;buffer&amp;gt; if v:completed_item.word =~# '($'&#xA;                                   \|     call feedkeys(&quot;)\&amp;lt;Left&amp;gt;&quot;, 'in')&#xA;                                   \| endif&#xA;                                   \| autocmd! close_paren&#xA;                                   \| augroup! close_paren&#xA;    augroup END&#xA;    return ''&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should remap the key sequence &lt;code&gt;C-x C-o&lt;/code&gt;, so that the custom function &lt;code&gt;s:close_paren()&lt;/code&gt; is evaluated before invoking omni completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function installs a fire-once autocmd, watching the &lt;code&gt;CompleteDone&lt;/code&gt; event, described in &lt;code&gt;:h completedone&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CompleteDone    After Insert mode completion is done.  Either&#xA;                when something was completed or abandoning&#xA;                completion. |ins-completion|&#xA;                The |v:completed_item| variable contains&#xA;                information about the completed item.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The autocmd inserts the keys:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;)&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... in the typeahead buffer. That is a closing parenthesis, then the &lt;code&gt;Left&lt;/code&gt; key to position the cursor between the 2 parentheses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to change the inserted keys, you can do so by changing them inside the first argument passed to the &lt;code&gt;feedkeys()&lt;/code&gt; function, whose usage is explained in &lt;code&gt;:h feedkeys()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;feedkeys({string} [, {mode}])               *feedkeys()*&#xA;&#xA;    Characters in {string} are queued for processing as if they&#xA;    come from a mapping or were typed by the user.&#xA;    By default the string is added to the end of the typeahead&#xA;    buffer, thus if a mapping is still being executed the&#xA;    characters come after them.  Use the 'i' flag to insert before&#xA;    other characters, they will be executed next, before any&#xA;    characters from a mapping.&#xA;    The function does not wait for processing of keys contained in&#xA;    {string}.&#xA;    To include special keys into {string}, use double-quotes&#xA;    and &quot;\...&quot; notation |expr-quote|. For example,&#xA;    feedkeys(&quot;\&amp;lt;CR&amp;gt;&quot;) simulates pressing of the &amp;lt;Enter&amp;gt; key. But&#xA;    feedkeys('\&amp;lt;CR&amp;gt;') pushes 5 characters.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The 2nd argument (&lt;code&gt;'in'&lt;/code&gt;) contains 2 flags whose meaning is explained like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    'n' Do not remap keys.&#xA;&#xA;    'i' Insert the string instead of appending (see above).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The autocmd should be local to the buffer because of the pattern &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;, and delete itself once the completion has been performed, because of these commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! close_paren&#xA;augroup! close_paren&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one removes the autocmd from the augroup, the 2nd one removes the augroup. You can't remove an augroup if it's not empty, as explained in &lt;code&gt;:h augroup-delete&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:aug[roup]! {name}      Delete the autocmd group {name}.  Don't use&#xA;                        this if there is still an autocommand using&#xA;                        this group!  You will get a warning if doing&#xA;                        it anyway. when the group is the current group&#xA;                        you will get error E936.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason why the autocmd removes itself is because even though you want to close a parenthesis when invoking omni completion, you may not want this behavior for every other kind of completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use the mapping, don't like any suggestion in the popup menu, and exit the latter by hitting &lt;code&gt;C-e&lt;/code&gt;, or if you don't complete a function name but another kind of syntax element, the autocmd shouldn't insert anything, because it checks whether the last character is an open parenthesis:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if v:completed_item.word =~# '($'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;v:completed_item&lt;/code&gt; is an internal variable containing a dictionary with various information related to the last text you completed. Here, you only use the key &lt;code&gt;word&lt;/code&gt; to be sure the last character is an open parenthesis, but if you wanted more info, maybe to build a more complex condition before deciding to call &lt;code&gt;feedkeys()&lt;/code&gt;, you could use other keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently there seems to be 5 of them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;word&#xA;menu&#xA;info&#xA;kind&#xA;abbr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The meaning of their values is given in &lt;code&gt;:h complete-items&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;word        the text that will be inserted, mandatory&#xA;&#xA;abbr        abbreviation of &quot;word&quot;; when not empty it is used in&#xA;            the menu instead of &quot;word&quot;&#xA;&#xA;menu        extra text for the popup menu, displayed after &quot;word&quot;&#xA;            or &quot;abbr&quot;&#xA;&#xA;info        more information about the item, can be displayed in a&#xA;            preview window&#xA;&#xA;kind        single letter indicating the type of completion&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-19T04:22:20.960" LastActivityDate="2016-12-19T04:22:20.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10654" PostTypeId="1" CreationDate="2016-12-19T13:00:00.527" Score="3" ViewCount="538" Body="&lt;p&gt;The output of certain compilers (e.g., LaTeX) is incredibly difficult to parse using an error format string.  There are always edge cases that leave out the context of errors.  So, is there any way I can see the context of the error in the quickfix window?  By more context, I mean the ability to jump to the position &lt;em&gt;in the error log&lt;/em&gt; corresponding to an error.&lt;/p&gt;&#xA;" OwnerUserId="10551" LastActivityDate="2016-12-20T11:52:56.930" Title="More error context in the QuickFix window?" Tags="|quickfix|errorformat|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10655" PostTypeId="2" ParentId="10652" CreationDate="2016-12-19T13:16:41.767" Score="2" Body="&lt;p&gt;I use a customized us layout and access ligatures by vim mappings and&#xA;OS option key mappings instead of spending a whole key on them.&#xA;For instance, I use &lt;code&gt;aeo&lt;/code&gt;, which are adjacent on qgmlwb (&lt;code&gt;jkl&lt;/code&gt;), to get æ.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap! aeo æ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By default you can also use &lt;code&gt;&amp;lt;c-k&amp;gt;ae&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2016-12-19T13:27:39.157" LastActivityDate="2016-12-19T13:27:39.157" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10656" PostTypeId="1" AcceptedAnswerId="10660" CreationDate="2016-12-19T17:21:54.980" Score="3" ViewCount="306" Body="&lt;p&gt;I have a file full of expressions like this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0.100000000000000000000*10^(1) 0.000000000000000000000*10^(0)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;0.911403977421716024142*10^(-15) 0.983917614423065751378*10^(-15)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and I would like to evaluate each term and round the value to 2 decimal points to get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;1.00 0.00&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;0.00 0.00&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Using &quot;bc -l&quot; on each token seperated by white space would accomplish the first step, but I don't know how to do this. Moreover, there is the issue with rounding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions are welcome!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI: There are three types of lines in the file. Those which are empty, those which contain a single integer and those which are of the form demonstrated above.&lt;/p&gt;&#xA;" OwnerUserId="2882" LastActivityDate="2016-12-19T21:39:34.730" Title="Evaluating and rounding a file of numbers in scientific form" Tags="|regular-expression|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10660" PostTypeId="2" ParentId="10656" CreationDate="2016-12-19T21:39:34.730" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;substitute&lt;/code&gt; feature with a &lt;code&gt;submatch&lt;/code&gt; and &lt;code&gt;system&lt;/code&gt; function like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\([^ ]\+\)/\=system('printf &quot;%.2f&quot; $(echo &quot;scale=2; ' . submatch(1) . '&quot; | bc -l)')/g   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;this performs a &lt;code&gt;s&lt;/code&gt;ubstitute on whole file (&lt;code&gt;%&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\([^ ]\+\)&lt;/code&gt; - matches every string stream which doesn't contain &lt;code&gt;space&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Then we replace all occurrences with an expression &lt;code&gt;\=&lt;/code&gt; that's after it.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;system()&lt;/code&gt; runs shell script/command and returns it's output.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;printf &quot;%.2f&quot; $(echo &quot;scale=2; ' . submatch(1) . '&quot; | bc -l)&lt;/code&gt; - &lt;code&gt;submatch(1)&lt;/code&gt; returns result of our match - so every math expression and whole is processed as a shell command.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-12-19T21:39:34.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10661" PostTypeId="1" AcceptedAnswerId="10662" CreationDate="2016-12-19T22:45:01.963" Score="3" ViewCount="925" Body="&lt;p&gt;I'm using Latex a lot lately and I find myself having to leave vim so I can execute the command &lt;code&gt;pdflatex *filename*&lt;/code&gt; too often (compile the code and create a pdf file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to make a command &lt;code&gt;command! Latex execute &quot;pdflatex %&quot;&lt;/code&gt; something like that to be able to compile the code directly from vim but I don't know how to expand the filename since &quot;pdflatex %&quot; is a string and the terminal understands it as so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I have the filename expand to what I want?&lt;/p&gt;&#xA;" OwnerUserId="5081" LastActivityDate="2016-12-19T22:57:37.930" Title="Insert filename in external-command" Tags="|external-command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10662" PostTypeId="2" ParentId="10661" CreationDate="2016-12-19T22:57:37.930" Score="5" Body="&lt;p&gt;&lt;code&gt;expand()&lt;/code&gt; is what you need.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Latex execute &quot;!pdflatex &quot; . expand('%')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-12-19T22:57:37.930" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10663" PostTypeId="2" ParentId="10652" CreationDate="2016-12-20T02:36:21.050" Score="4" Body="&lt;p&gt;In the place where ANSI US has &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; Nordic keyboards have &lt;code&gt;å&lt;/code&gt; and &lt;code&gt;¨&lt;/code&gt;, of which the latter is really not bindable, since it sends &quot;half a character&quot; and waits for the character to be accented. For example, pressing &lt;code&gt;¨a&lt;/code&gt; outputs &lt;code&gt;ä&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution would be to &quot;left-shift&quot; the binding to &lt;code&gt;CTRL-å&lt;/code&gt; (the key to the right of P).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally switch between US and Finnish/Nordic layouts quite often and write code almost exclusively in US layout.&lt;/p&gt;&#xA;" OwnerUserId="10558" LastActivityDate="2016-12-20T02:36:21.050" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10664" PostTypeId="1" AcceptedAnswerId="10666" CreationDate="2016-12-20T04:25:02.473" Score="28" ViewCount="21010" Body="&lt;p&gt;I'm trying to setup mappings for &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; that, depending on the buffer's file type, trigger different functions. For example, if I'm in a Javascript buffer, I want &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; to trigger &lt;code&gt;:TernDef&lt;/code&gt;. If I'm in a C buffer, I want it to trigger &lt;code&gt;:YcmCompleter GoTo&lt;/code&gt;. I tried &lt;code&gt;autocmd FileType c nnoremap &amp;lt;C-]&amp;gt; :YcmCompleter GoTo&amp;lt;CR&amp;gt;&lt;/code&gt; but it just seems to ignore that. &lt;/p&gt;&#xA;" OwnerUserId="4901" LastEditorUserId="4901" LastEditDate="2016-12-20T05:06:05.187" LastActivityDate="2016-12-20T08:59:59.413" Title="File Type dependent key mapping" Tags="|key-bindings|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10665" PostTypeId="2" ParentId="10664" CreationDate="2016-12-20T08:40:28.273" Score="0" Body="&lt;p&gt;For me that line does work (using commands that my Vim recognizes and including a colon at the start of the command). You could try to start Vim without plugins and see whether the line is recognized properly then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option would be to put the commands you want to run in the c.vim file in the ftplugin directory. This way they will be run when you open a file of that type. More info can be found in &lt;code&gt;:help ftplugin&amp;lt;cr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2016-12-20T08:40:28.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10666" PostTypeId="2" ParentId="10664" CreationDate="2016-12-20T08:59:59.413" Score="62" Body="&lt;p&gt;That autocmd looks fine; however, you should define &lt;em&gt;buffer-local&lt;/em&gt; mappings (with &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;); else, editing one type of file will override the other type's (global) mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType c          nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-]&amp;gt; :YcmCompleter GoTo&amp;lt;CR&amp;gt;&#xA;autocmd FileType javascript nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-]&amp;gt; :TernDef&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Critique of the autocmd approach&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can define mappings for certain filetypes by prepending &lt;code&gt;:autocmd Filetype {filetype} ...&lt;/code&gt;, and put that into your &lt;code&gt;~/.vimrc&lt;/code&gt;. But that gets unwieldy as you add mappings and other settings for various filetypes. Better put the &lt;code&gt;:map&lt;/code&gt; commands into &lt;code&gt;~/.vim/ftplugin/{filetype}_mappings.vim&lt;/code&gt;. (This requires that you have &lt;code&gt;:filetype plugin on&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-20T08:59:59.413" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10667" PostTypeId="2" ParentId="10654" CreationDate="2016-12-20T10:35:59.787" Score="2" Body="&lt;p&gt;I'm not aware of any built-in mechanism of jumping to the location of an error in the error log.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the default behaviour of &lt;code&gt;errorformat&lt;/code&gt; is to &lt;em&gt;include&lt;/em&gt; all of the &lt;code&gt;makeprg&lt;/code&gt; output, so context can be seen in the quickfix window itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;errorformat&lt;/code&gt; described in &lt;code&gt;:help errorformat-LaTeX&lt;/code&gt; includes a number of patterns specifically intended to hide matching lines from the quickfix window (see &lt;code&gt;:help efm-ignore&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%-GSee\ the\ LaTeX%m,&#xA;\%-GType\ \ H\ &amp;lt;return&amp;gt;%m,&#xA;\%-G\ ...%.%#,&#xA;\%-G%.%#\ (C)\ %.%#,&#xA;\%-G(see\ the\ transcript%.%#),&#xA;\%-G\\s%#,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Removing these should result in the entire log being displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't work, you could also try adding a catch-all pattern to the very end of your &lt;code&gt;errorformat&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set efm+=%+G%.%#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will match ALL lines which have not already been matched by an earlier pattern in your &lt;code&gt;errorformat&lt;/code&gt;. The disadvantage of doing this is that commands like &lt;code&gt;:cnext&lt;/code&gt; and &lt;code&gt;:cprevious&lt;/code&gt; will no longer skip over these lines, as they would do if you left them unmatched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(It's more usual to use the negative analogue of this: &lt;code&gt;%-G%.%#&lt;/code&gt; as a catch-all to &lt;em&gt;remove&lt;/em&gt; all previously unmatched lines from the output.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2016-12-20T11:52:56.930" LastActivityDate="2016-12-20T11:52:56.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10668" PostTypeId="2" ParentId="5157" CreationDate="2016-12-20T12:43:33.530" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What other common 'minimal' vi's exist?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is also xvi.sf.net mantained at github.com/martinwguy/xvi which is a different implementation based on STEVIE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's the smallest full-featured vi clone but has not been checked for POSIX compliant. Bug reports of variations from the standard would be welcome.&lt;/p&gt;&#xA;" OwnerUserId="10565" LastActivityDate="2016-12-20T12:43:33.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10671" PostTypeId="1" AcceptedAnswerId="10672" CreationDate="2016-12-20T16:23:00.670" Score="26" ViewCount="50677" Body="&lt;p&gt;I was wondering what's the purpose of .viminfo and .netrwhist files?&lt;/p&gt;&#xA;" OwnerUserId="10524" LastActivityDate="2016-12-20T16:48:38.400" Title="What are the .viminfo and .netrwhist files?" Tags="|viminfo|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10672" PostTypeId="2" ParentId="10671" CreationDate="2016-12-20T16:31:15.733" Score="19" Body="&lt;p&gt;You can see that here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#viminfo&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h viminfo&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you exit Vim and later start it again, you would normally lose a lot of information.  The viminfo file can be used to remember that information, which enables you to continue where you left off.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pi_netrw.txt.html#.netrwhist&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h .netrwhist&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The file &quot;.netrwhist&quot; holds history when netrw (and vim) is not&#xA;  active. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1841" LastEditDate="2016-12-20T16:48:38.400" LastActivityDate="2016-12-20T16:48:38.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10673" PostTypeId="1" AcceptedAnswerId="10674" CreationDate="2016-12-20T17:12:12.617" Score="4" ViewCount="52" Body="&lt;p&gt;I want to define a command that jumps to the next closest Chinese period or Chinese comma and perhaps other punctuations, and another command that does the same but for the previous closest punctuation.&lt;/p&gt;&#xA;&lt;p&gt;To simplify the situation, let us say I want to jump to the next/previous closest &lt;code&gt;x&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, or &lt;code&gt;z&lt;/code&gt;.&#xA;So I defined in &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; &amp;lt;C-k&amp;gt; ?[xyz]&amp;lt;CR&amp;gt; :noh&amp;lt;CR&amp;gt;&#xA;map &amp;lt;silent&amp;gt; &amp;lt;C-j&amp;gt; /[xyz]&amp;lt;CR&amp;gt; :noh&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And try this in such line:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;abcx1y2z3def abcx1y2z3def abcx1y2z3def&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But when I place my cursor at &lt;code&gt;a&lt;/code&gt;, press &lt;code&gt;ctrl-j&lt;/code&gt;, the cursor jumps to &lt;code&gt;1&lt;/code&gt;; again press &lt;code&gt;ctrl-j&lt;/code&gt;, then to &lt;code&gt;2&lt;/code&gt;; again press &lt;code&gt;ctrl-j&lt;/code&gt;, then to &lt;code&gt;3&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It always jumps to the character on the right of the next match.&lt;/p&gt;&#xA;&lt;p&gt;And when I place my cursor at &lt;code&gt;f&lt;/code&gt;, and press &lt;code&gt;ctrl-k&lt;/code&gt;, the cursor jumps to &lt;code&gt;3&lt;/code&gt;; again press &lt;code&gt;ctrl-k&lt;/code&gt; many times, but no use. It only jumps to the character on the right of the previous match.&lt;/p&gt;&#xA;&lt;p&gt;Despite that, when I press &lt;code&gt;/[xyz]&amp;lt;CR&amp;gt; :noh&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;?[xyz]&amp;lt;CR&amp;gt; :noh&amp;lt;CR&amp;gt;&lt;/code&gt; explicitly, I get desired behavior.&lt;/p&gt;&#xA;&lt;p&gt;Why? Have I made some syntax errors?&lt;/p&gt;&#xA;" OwnerUserId="10241" LastEditorUserId="36863" LastEditDate="2023-03-13T15:04:23.493" LastActivityDate="2023-03-13T15:04:23.493" Title="Self-define command to search a certain symbol" Tags="|key-bindings|vimrc|search|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10674" PostTypeId="2" ParentId="10673" CreationDate="2016-12-20T17:41:53.387" Score="3" Body="&lt;p&gt;You problem is at the center of your mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; &amp;lt;C-k&amp;gt; ?[xyz]&amp;lt;CR&amp;gt; :noh&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Indeed, the problem is &lt;code&gt;&lt;/code&gt; ! It moves one char right in normal mode. You can fix your mapping with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; &amp;lt;C-k&amp;gt; ?[xyz]&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;&#xA;map &amp;lt;silent&amp;gt; &amp;lt;C-j&amp;gt; /[xyz]&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Have a look at &lt;code&gt;:h &amp;lt;Space&amp;gt;&lt;/code&gt;. As well as this post: &lt;a href=&quot;https://vi.stackexchange.com/a/7723&quot;&gt;https://vi.stackexchange.com/a/7723&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also highly recommend using the &lt;code&gt;noremap&lt;/code&gt; form, to prevent recursive mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-j&amp;gt; /[xyz]&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-12-20T17:41:53.387" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10675" PostTypeId="1" AcceptedAnswerId="10676" CreationDate="2016-12-20T18:02:35.050" Score="3" ViewCount="108" Body="&lt;p&gt;My cursor is on the &lt;code&gt;f&lt;/code&gt; of the first line. I'd like to move the word so that it aligns with the word below it. I know I could &lt;code&gt;b i spaces&lt;/code&gt; until they align. I'd like to avoid getting in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zfT65.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zfT65.png&quot; alt=&quot;Vim_word_align&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1132" LastActivityDate="2016-12-26T07:48:20.657" Title="How to move word under current cursor to begin at current cursor?" Tags="|alignment|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10676" PostTypeId="2" ParentId="10675" CreationDate="2016-12-20T18:33:47.030" Score="5" Body="&lt;p&gt;Without entering insert mode (not sure if it's better though):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example text (cursor on &lt;code&gt;C&lt;/code&gt; of the first line):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A  BBCBB&#xA;A    BBCBB&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bjywkP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bj     go back to the start of the word, one line down (below the first B)&#xA;yw     yank the next word (being the whitespaces)&#xA;k      move up&#xA;P      past before the cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: Thanks to &lt;a href=&quot;https://vi.stackexchange.com/users/7878/antony&quot;&gt;antony&lt;/a&gt; for suggesting using &lt;code&gt;yw&lt;/code&gt; instead of &lt;code&gt;vtBy&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2016-12-22T11:12:03.210" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10677" PostTypeId="1" AcceptedAnswerId="10679" CreationDate="2016-12-20T20:06:28.080" Score="2" ViewCount="320" Body="&lt;p&gt;I've the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;group1&#xA;  item1&#xA;  item2&#xA;  item3&#xA;group2&#xA;  item4&#xA;  item5&#xA;group3&#xA;  item6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where I'd like to select all items which belong to &lt;code&gt;group2&lt;/code&gt; using a search range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my approach:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/group2\n\zs/;,/^\ze\S/p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however it seems the &lt;code&gt;\ze&lt;/code&gt; doesn't take any effect, because this is what is printed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  item4&#xA;  item5&#xA;group3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I expect only &lt;code&gt;item4&lt;/code&gt; and &lt;code&gt;item5&lt;/code&gt; to be printed, without ending pattern (&lt;code&gt;group3&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I exclude the ending pattern then?&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2016-12-21T23:34:03.743" Title="How to exclude the ending pattern in a search range?" Tags="|search|range|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10678" PostTypeId="1" AcceptedAnswerId="13163" CreationDate="2016-12-20T20:15:59.280" Score="1" ViewCount="47" Body="&lt;p&gt;I'd like to assign the result of search range selection into a register, instead of printing it, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/pattern1/;,/pattern2/p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What syntax I can use to achieve that?&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2017-08-07T11:41:45.840" Title="How to assign a search range selection into a register?" Tags="|search|register|range|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10679" PostTypeId="2" ParentId="10677" CreationDate="2016-12-20T20:28:43.567" Score="3" Body="&lt;p&gt;I could be wrong but I think the atom &lt;code&gt;\ze&lt;/code&gt; does take effect, it just doesn't prevent Vim to find a match on the &lt;code&gt;group3&lt;/code&gt; line.&lt;br&gt;&#xA;It's an empty match since you write &lt;code&gt;\ze&lt;/code&gt; just after the anchor &lt;code&gt;^&lt;/code&gt; which excludes everything afterwards. But even if it's empty, it's still something, the beginning of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe you could use an offset:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/group2\n\zs/;,/^\ze\S/- p&#xA;                        ^&#xA;                        |___ minus sign, to decrease the line address by one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-20T20:38:01.470" LastActivityDate="2016-12-20T20:38:01.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10680" PostTypeId="1" AcceptedAnswerId="10707" CreationDate="2016-12-20T20:33:40.590" Score="5" ViewCount="170" Body="&lt;p&gt;I'd like to replace the entire buffer (file) with the current search range selection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/pattern1/;,/pattern2/p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How this can be achieved?&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2016-12-22T12:30:19.467" Title="How to replace buffer with a search range selection?" Tags="|search|buffers|replace|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10682" PostTypeId="2" ParentId="10382" CreationDate="2016-12-20T21:11:02.550" Score="3" Body="&lt;p&gt;I contacted Dr. Chip and he confirmed that it was indeed a bug. He has since fixed the bug. The most recent version (162g as of this writing) is available on his &lt;a href=&quot;http://www.drchip.org/astronaut/vim/#NETRW&quot; rel=&quot;nofollow noreferrer&quot;&gt;website&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-12-20T21:11:02.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10684" PostTypeId="2" ParentId="3671" CreationDate="2016-12-20T22:15:51.743" Score="1" Body="&lt;p&gt;This was a bug but has been fixed as of version 162g, which you can find &lt;a href=&quot;http://www.drchip.org/astronaut/vim/#NETRW&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-12-20T22:15:51.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10685" PostTypeId="1" CreationDate="2016-12-20T22:34:47.463" Score="5" ViewCount="2715" Body="&lt;p&gt;I was trying to remap some keys to switch to the next buffer, but something doesn't work, I have these lines on my .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Cambia tecla lider a &amp;lt;Space&amp;gt;&#xA;let mapleader=&quot;&amp;lt;Space&amp;gt;&quot;&#xA;&#xA;&quot; Switch to next buffer&#xA;nnoremap &amp;lt;Leader&amp;gt;l :bn&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Switch to previous buffer&#xA;nnoremap &amp;lt;Leader&amp;gt;h :bp&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Split the window&#xA;nnoremap &amp;lt;Leader&amp;gt;k :split&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are those lines okay? or Is there something wrong?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An observation: when I change &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; it works.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10524" LastEditorUserId="10524" LastEditDate="2016-12-20T23:07:40.080" LastActivityDate="2016-12-21T09:31:50.213" Title="Remap &lt;Space&gt; key doesn't work" Tags="|key-bindings|vimrc|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10686" PostTypeId="2" ParentId="10685" CreationDate="2016-12-21T00:42:19.920" Score="1" Body="&lt;p&gt;The problem was a missing &lt;code&gt;\&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let mapleader = &quot;\&amp;lt;Space&amp;gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10524" LastActivityDate="2016-12-21T00:42:19.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10688" PostTypeId="1" CreationDate="2016-12-21T06:22:29.523" Score="1" ViewCount="573" Body="&lt;p&gt;We can read some information about the current buffer, by hitting &lt;code&gt;g C-g&lt;/code&gt;; for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Col 3 of 2; Line 28 of 106; Word 144 of 474; Byte 916 of 3396&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And we can capture the same information in a dictionary using the &lt;code&gt;wordcount()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo wordcount()&#xA;&#xA;{'chars': 3396, 'cursor_chars': 916, 'words': 474, 'cursor_words': 144, 'bytes': 3396, 'cursor_bytes': 916}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In both cases, we read/get the number of characters, words and bytes, as well as the position of the cursor expressed with these 3 units. It allows to get an idea of the amount of text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But to get an idea of the amount of code in a file, where there may be a lot of comments and/or blank lines, could we also read/get the number of the latter as well as the number of lines of code?&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-21T06:25:36.723" LastActivityDate="2016-12-21T14:39:26.750" Title="How to read/get the number of lines of code in the buffer or a directory?" Tags="|key-bindings|vimscript|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10689" PostTypeId="2" ParentId="10688" CreationDate="2016-12-21T06:22:48.550" Score="2" Body="&lt;p&gt;Here's a way of getting the information:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! -range=% -nargs=? -complete=file CLOC call s:cloc(&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;,&amp;lt;q-args&amp;gt;)&#xA;&#xA;nno &amp;lt;silent&amp;gt; g&amp;lt;C-l&amp;gt; :CLOC&amp;lt;CR&amp;gt;&#xA;xno &amp;lt;silent&amp;gt; g&amp;lt;C-l&amp;gt; :CLOC&amp;lt;CR&amp;gt;&#xA;&#xA;fu! s:cloc(lnum1,lnum2,path) abort&#xA;&#xA;    if !empty(a:path)&#xA;        let to_scan = a:path&#xA;    else&#xA;        let file    = tempname()&#xA;        let to_scan = file.'.'.&amp;amp;ft&#xA;        let lines   = getline(a:lnum1, a:lnum2)&#xA;        call writefile(lines, to_scan)&#xA;    endif&#xA;&#xA;    let cloc_output = matchstr(system('cloc '.to_scan), 'http.\{-}\n\zs.*\ze\n')&#xA;&#xA;    if empty(a:path)&#xA;        call delete(to_scan)&#xA;    endif&#xA;&#xA;    let to_display = cloc_output&#xA;&#xA;    let cloc_output = map(filter(split(cloc_output, &quot;\n&quot;), 'v:val =~# ''\d\+'''),&#xA;                     \ 'split(v:val, ''\s\{2,}\ze\d'')')&#xA;&#xA;    let g:cloc_results = {}&#xA;    let keys           = ['files', 'blank', 'comment', 'code']&#xA;&#xA;    for values_on_line in cloc_output&#xA;        let i    = 0&#xA;        let dict = {}&#xA;&#xA;        for value in values_on_line[1:]&#xA;            let dict[keys[i]] = eval(value)&#xA;            let i += 1&#xA;        endfor&#xA;&#xA;        let g:cloc_results[values_on_line[0]] = dict&#xA;    endfor&#xA;&#xA;    echo to_display&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It relies on the &lt;code&gt;cloc&lt;/code&gt; shell command, which, on debian based distributions, can be installed with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install cloc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It can also be downloaded from &lt;a href=&quot;https://github.com/AlDanial/cloc/releases&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It installs normal and visual mode mappings, both using the key sequence &lt;code&gt;g C-l&lt;/code&gt; (&lt;code&gt;l&lt;/code&gt; for lines).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The normal mapping allows to read the number of lines of code, comments and blank lines in the current buffer. The visual mapping allows to get the same info for the visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also installs the Ex command &lt;code&gt;:CLOC&lt;/code&gt;, which accepts a range (matching the whole buffer by default), and a path to a file or a folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When passed a path, &lt;code&gt;:CLOC&lt;/code&gt; should scan all the files under the latter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both the mappings and the Ex command should populate the global variable &lt;code&gt;g:cloc_results&lt;/code&gt; with a dictionary.&#xA;Each key of this dictionary should be a programming language (except one named &lt;code&gt;SUM:&lt;/code&gt;).&lt;br&gt;&#xA;Each value should be another dictionary. This sub-dictionary should contain the 4 following keys:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;files      &quot; number of files under the path whose language is the name of the dictionary&#xA;code       &quot;           total lines of code for this language&#xA;comment    &quot;           total comment lines &quot;&#xA;blank      &quot;           total blank lines   &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XY4UD.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XY4UD.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside a script, where the only thing desired is the global variable (no message) &lt;code&gt;:CLOC&lt;/code&gt; could be executed silently:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent CLOC /path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, one could access the data for a given language, let's say python, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let yourvar = g:cloc_results.Python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should give something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{'comment': 2213, 'files': 93, 'code': 10970, 'blank': 2630}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if the language contains a space, like &lt;code&gt;Bourne Shell&lt;/code&gt;, you could use this other syntax, where the space is protected in a string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let yourvar = g:cloc_results['Bourne Shell']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-21T14:39:26.750" LastActivityDate="2016-12-21T14:39:26.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10690" PostTypeId="2" ParentId="10685" CreationDate="2016-12-21T09:31:50.213" Score="6" Body="&lt;p&gt;Inside &lt;code&gt;:map&lt;/code&gt; commands, the special &lt;code&gt;:help key-notation&lt;/code&gt; needs to be used, especially for space, because whitespace separates the arguments of &lt;code&gt;:map&lt;/code&gt;. The &lt;code&gt;mapleader&lt;/code&gt; is a built-in variable, and as such requires no escaping. You can simply use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let mapleader = ' '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if you'd like to stick to the same notation, the keyword needs to be escaped and put in double quotes (cp. &lt;code&gt;:help expr-quote&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let mapleader = &quot;\&amp;lt;Space&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2016-12-21T09:31:50.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10691" PostTypeId="2" ParentId="10680" CreationDate="2016-12-21T10:14:04.443" Score="2" Body="&lt;p&gt;I couldn't find a straightforward solution, but a possible workaround is the following. Consider that you have the following buffer and you want to keep the lines &lt;code&gt;dolor&lt;/code&gt; to &lt;code&gt;amet&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem&#xA;ipsum&#xA;dolor&#xA;sit&#xA;amet&#xA;consectetur&#xA;adipiscing&#xA;elit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First, mark the lines you want to keep:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/pattern1/,/pattern2/norm! AXXX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here that would be &lt;code&gt;/dolor/,/amet/norm! AXXX&lt;/code&gt; and you would get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem&#xA;ipsum&#xA;dolorXXX&#xA;sitXXX&#xA;ametXXX&#xA;consectetur&#xA;adipiscing&#xA;elit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Delete the lines which wasn't marked:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g!/XXX/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dolorXXX&#xA;sitXXX&#xA;ametXXX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you have only the lines you wanted, remove the marks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/XXX$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dolor&#xA;sit&#xA;amet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Of course it is possible to wrap that into a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RemoveOtherLines(pattern1, pattern2)&#xA;    execute '/' . a:pattern1 . '/,/' . a:pattern2 . '/norm! AXXX'&#xA;    execute 'g!/XXX/d'&#xA;    execute '%s/XXX$//'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But maybe you'll get some problems with some escaped patterns.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-12-21T10:21:15.610" LastActivityDate="2016-12-21T10:21:15.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10692" PostTypeId="1" AcceptedAnswerId="10693" CreationDate="2016-12-21T10:18:12.613" Score="16" ViewCount="5499" Body="&lt;p&gt;Is there any way to configure VIM to interactively search inside every file for an entire project?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By &lt;em&gt;interactive&lt;/em&gt;, I mean updating each keystroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like Emacs &lt;a href=&quot;https://github.com/abo-abo/swiper&quot; rel=&quot;noreferrer&quot;&gt;counsel-git-grep&lt;/a&gt;, see: &lt;a href=&quot;https://www.youtube.com/watch?v=OEmXQNS7ofo&quot; rel=&quot;noreferrer&quot;&gt;example demo&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="301" LastEditDate="2016-12-21T12:09:23.030" LastActivityDate="2017-01-12T18:27:05.170" Title="How to interactively search/grep with VIM?" Tags="|search|vimgrep|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10693" PostTypeId="2" ParentId="10692" CreationDate="2016-12-21T10:56:22.007" Score="15" Body="&lt;p&gt;I'm not sure this is what you're looking for, but maybe you could try &lt;a href=&quot;https://github.com/junegunn/fzf&quot; rel=&quot;noreferrer&quot;&gt;fzf&lt;/a&gt; and &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;noreferrer&quot;&gt;fzf.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;noreferrer&quot;&gt;vim-plug&lt;/a&gt; as a plugin manager, all you should have to do to install them, is to add these lines in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }&#xA;Plug 'junegunn/fzf.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... somewhere between the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then execute &lt;code&gt;:PlugInstall&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Among various commands and mappings provided by &lt;code&gt;fzf.vim&lt;/code&gt; (whose only purpose seems to be to install mappings and commands asking &lt;code&gt;fzf&lt;/code&gt; to fuzzy search through predefined sources), there is the command &lt;code&gt;:Ag&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be able to use it, you need to install the shell command &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;noreferrer&quot;&gt;ag&lt;/a&gt;. On debian based distributions, it can be done with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apt-get install silversearcher-ag&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The project on github explains how to install it on MacOS:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;brew install the_silver_searcher&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:Ag&lt;/code&gt; is a wrapper around &lt;code&gt;$ ag&lt;/code&gt;, and allows you to fuzzy search a pattern in the files of the current directory (the one displayed when you type &lt;code&gt;:pwd&lt;/code&gt;). The matches are updated after every keystroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;cycle forward and backward through the matches with &lt;code&gt;C-n&lt;/code&gt; and &lt;code&gt;C-p&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;select the current match and move to the next/previous one with &lt;code&gt;Tab&lt;/code&gt;/&lt;code&gt;S-Tab&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;select or deselect all the matches with &lt;code&gt;M-a&lt;/code&gt; or &lt;code&gt;M-d&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you select one or several matches, after hitting Enter, they will populate the quickfix list. From there you'll be able to navigate through them with default Vim commands / mappings, such as &lt;code&gt;:cnext&lt;/code&gt; and &lt;code&gt;:cprevious&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XlTIQ.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XlTIQ.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to add a prefix to all the commands installed by &lt;code&gt;fzf.vim&lt;/code&gt;, and avoid overriding existing commands, you can add this in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:fzf_command_prefix = 'your_prefix'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;Fzf&lt;/code&gt; as a prefix, that's why I didn't type &lt;code&gt;:Ag&lt;/code&gt; but &lt;code&gt;:FzfAg&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you prefer to use &lt;code&gt;git grep&lt;/code&gt; instead of &lt;code&gt;ag&lt;/code&gt;, it seems you could install your own custom wrapper around it, &lt;code&gt;:GGrep&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bang -nargs=* GGrep&#xA;  \ call fzf#vim#grep('git grep --line-number '.shellescape(&amp;lt;q-args&amp;gt;), 0, &amp;lt;bang&amp;gt;0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's explained in &lt;code&gt;:h fzf-vim-customization&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if &lt;code&gt;fzf&lt;/code&gt; opens a pane in tmux, and you would prefer it takes the whole screen instead, you can append a bang to all the commands (&lt;code&gt;:Ag!&lt;/code&gt;, &lt;code&gt;:GGrep!&lt;/code&gt;, ...).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As you said in your last &lt;a href=&quot;https://vi.stackexchange.com/questions/10692/how-to-interactively-search-grep-with-vim/10693?noredirect=1#comment19232_10693&quot;&gt;comment&lt;/a&gt;, by default &lt;code&gt;fzf&lt;/code&gt; changes the configuration of your shell. For example, if you use &lt;code&gt;bash&lt;/code&gt;, it will add the following line in your &lt;code&gt;~/.bashrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ -f ~/.fzf.bash ] &amp;amp;&amp;amp; source ~/.fzf.bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will source the file &lt;code&gt;~/.fzf.bash&lt;/code&gt;. The latter contains some code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Setup fzf&#xA;# ---------&#xA;if [[ ! &quot;$PATH&quot; == */home/user/.fzf/bin* ]]; then&#xA;  export PATH=&quot;$PATH:/home/user/.fzf/bin&quot;&#xA;fi&#xA;&#xA;# Auto-completion&#xA;# ---------------&#xA;[[ $- == *i* ]] &amp;amp;&amp;amp; source &quot;/home/user/.fzf/shell/completion.bash&quot; 2&amp;gt; /dev/null&#xA;&#xA;# Key bindings&#xA;# ------------&#xA;source &quot;/home/user/.fzf/shell/key-bindings.bash&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code appends a path to the environment variable &lt;code&gt;$PATH&lt;/code&gt;: &lt;code&gt;/home/user/.fzf/bin&lt;/code&gt; ; which is the folder containing the &lt;code&gt;fzf&lt;/code&gt; program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also sources 2 other files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/user/.fzf/shell/completion.bash&#xA;/home/user/.fzf/shell/key-bindings.bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one seems to define completion functions, while the second installs key bindings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the key bindings may override default &lt;code&gt;readline&lt;/code&gt; functions.&lt;br&gt;&#xA;For example, &lt;code&gt;fzf&lt;/code&gt; binds the function &lt;code&gt;fzf-file-widget&lt;/code&gt; to &lt;code&gt;C-t&lt;/code&gt;. This key is usually used by readline to execute the &lt;code&gt;transpose-chars&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want this, one possible solution would be to restore the key bindings inside your &lt;code&gt;~/.bashrc&lt;/code&gt;, after &lt;code&gt;fzf&lt;/code&gt; has sourced its configuration. For example, if you wanted &lt;code&gt;C-t&lt;/code&gt; to keep its old behavior, that is transposing the 2 characters around the cursor, and bind &lt;code&gt;fzf-file-widget&lt;/code&gt; to another key, let's say &lt;code&gt;C-x C-t&lt;/code&gt;, you could add these lines at the end of &lt;code&gt;~/.bashrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bind -x '&quot;\C-x\C-t&quot;: fzf-file-widget'&#xA;bind '&quot;\C-t&quot;: transpose-chars'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The same thing applies to the &lt;code&gt;zsh&lt;/code&gt; shell, but the syntax to install a key binding is a little different:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bindkey '^X^T' fzf-file-widget&#xA;bindkey '^T' transpose-chars&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If one of the shell key binding you were used to has been overridden by &lt;code&gt;fzf&lt;/code&gt;, you want to restore it, but don't know what's the exact name of the function which was executed, you could try the following thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, inside your &lt;code&gt;~/.bashrc&lt;/code&gt;, temporarily comment out the line which sources the &lt;code&gt;fzf&lt;/code&gt; configuration. Then, reopen a terminal, and have a look at the output of the &lt;code&gt;bind -P&lt;/code&gt; command, which you can read in a Vim buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bind -P | vim -R -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure, but I think it should display most or all the &lt;code&gt;readline&lt;/code&gt; key bindings. If you're looking for the name of the readline function bound to the &lt;code&gt;C-t&lt;/code&gt; key, in the Vim buffer, you would search &lt;code&gt;\\C-t&lt;/code&gt;. And if you were looking for the one bound to &lt;code&gt;M-c&lt;/code&gt; (meta / alt key), you would search &lt;code&gt;\\ec&lt;/code&gt; (&lt;code&gt;\e&lt;/code&gt; stands for the escape key and it seems &lt;code&gt;M-c&lt;/code&gt; produces the same keycodes as &lt;code&gt;escape + c&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do the same thing in &lt;code&gt;zsh&lt;/code&gt; by looking at the output of the &lt;code&gt;bindkey&lt;/code&gt; command. But this time, &lt;code&gt;^[&lt;/code&gt; stands for the meta/alt modifier key, while a single caret (&lt;code&gt;^&lt;/code&gt;) character stands for the control key.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Currently, I found 4 key bindings executing functions containing the &lt;code&gt;fzf&lt;/code&gt; keyword in their name. They use the key sequences &lt;code&gt;C-i&lt;/code&gt; (same as &lt;code&gt;Tab&lt;/code&gt;), &lt;code&gt;C-r&lt;/code&gt;, &lt;code&gt;C-t&lt;/code&gt; and &lt;code&gt;M-c&lt;/code&gt;. They are bound to the following functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C-i    fzf-completion&#xA;C-r    fzf-history-widget&#xA;C-t    fzf-file-widget&#xA;M-c    fzf-cd-widget&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On my system, originally, &lt;code&gt;readline&lt;/code&gt; (the library used by &lt;code&gt;bash&lt;/code&gt; to edit the command line) bound those keys to these functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C-i     complete&#xA;C-r     reverse-search-history&#xA;C-t     transpose-chars&#xA;M-c     capitalize-word&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;zle&lt;/code&gt; (the line editor used by &lt;code&gt;zsh&lt;/code&gt;), bound them to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C-i     expand-or-complete&#xA;C-r     history-incremental-search-backward&#xA;C-t     transpose-chars&#xA;M-c     capitalize-word&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-01-12T18:27:05.170" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10694" PostTypeId="1" AcceptedAnswerId="10696" CreationDate="2016-12-21T13:28:08.867" Score="1" ViewCount="308" Body="&lt;p&gt;Is it possible to view the help in Vim at a text width greater than 77 characters? Can Vim reflow the help text?&lt;/p&gt;&#xA;" OwnerUserId="2932" LastEditorUserId="51" LastEditDate="2016-12-24T18:03:42.883" LastActivityDate="2016-12-24T18:03:42.883" Title="Full width Vim help text" Tags="|wrapping|help-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10695" PostTypeId="2" ParentId="10694" CreationDate="2016-12-21T13:38:09.800" Score="2" Body="&lt;p&gt;I don't think it's possible. Vim just displays a text file in a help window with proper highlighting. All help files are available at &lt;code&gt;$VIMRUNTIME/doc/&lt;/code&gt; and they are already formatted with that width.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-12-21T13:38:09.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10696" PostTypeId="2" ParentId="10694" CreationDate="2016-12-21T14:32:12.140" Score="2" Body="&lt;p&gt;A &quot;help page&quot; is nothing more than a buffer with &lt;code&gt;filetype=help&lt;/code&gt; and &lt;code&gt;nomodifiable&lt;/code&gt; set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can make it modifiable with &lt;code&gt;:set modifiable&lt;/code&gt;, and then edit it like you would any buffer, e.g. by setting the &lt;code&gt;textwidth&lt;/code&gt; to what you like and using &lt;code&gt;gq&lt;/code&gt; to re-format text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like to do this automatically, you can do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup help&#xA;    autocmd!&#xA;    autocmd Filetype help&#xA;        \ set modifiable noreadonly textwidth=120&#xA;        \| normal! gqG&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, a quick test reveals that this doesn't work very well for many help pages, so I wouldn't recommend doing this. You'll have to make a custom &lt;code&gt;formatprg&lt;/code&gt; or &lt;code&gt;equalprg&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-12-21T14:32:12.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10697" PostTypeId="1" CreationDate="2016-12-21T15:11:15.067" Score="2" ViewCount="104" Body="&lt;p&gt;First, sorry for the cross-posting. I have posted it in &lt;a href=&quot;https://tex.stackexchange.com/q/345060&quot;&gt;https://tex.stackexchange.com/q/345060&lt;/a&gt; as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to enable forward search in &lt;code&gt;vim-latex&lt;/code&gt;. Since it is not working, I tried a vanilla &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Vundle Plugins&quot; {{{&#xA;filetype off&#xA;set rtp+=~/.vim/bundle/Vundle.vim/&#xA;call vundle#begin()&#xA;Plugin 'gmarik/Vundle.vim'&#xA;Plugin 'vim-latex/vim-latex'          &quot;  Latex IDE&#xA;call vundle#end()&#xA;filetype plugin indent on&#xA;&quot; Vundle done&#xA;&quot; &quot;}}}&#xA;&#xA;&quot;language specific staffs:&#xA;&#xA;&quot;LaTeX: {{{&#xA;let g:tex_flavor = 'latex'&#xA;let g:Tex_DefaultTargetFormat = 'pdf'&#xA;let g:Tex_ViewRule_pdf = 'evince'&#xA;let g:syntastic_tex_checkers = ['lacheck']&#xA;&quot;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and a few line of latex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\documentclass[a4paper]{article}&#xA;\synctex=1&#xA;\begin{document}&#xA;Lorem ipsum dolor sit amet, consetetur sadipscing elitr,  sed diam nonumy eirmod tempor invidunt ut &#xA;labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores &#xA;et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem &#xA;ipsum dolor sit amet, consetetur sadipscing elitr,  sed diam nonumy eirmod tempor invidunt ut labore et &#xA;dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. &#xA;Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit &#xA;amet, consetetur sadipscing elitr,  sed diam nonumy eirmod tempor invidunt ut labore et dolore magna &#xA;aliquyam erat, sed diam voluptua. &#xA;&#xA;At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus&#xA;est Lorem ipsum dolor sit amet.&#xA;Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, &#xA;vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent &#xA;luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, &#xA;consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.&#xA;&#xA;Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis &#xA;nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in &#xA;vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at &#xA;vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit&#xA;augue duis dolore te feugait nulla facilisi.&#xA;Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim &#xA;placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam &#xA;nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. &#xA;Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl &#xA;ut aliquip ex ea commodo consequat.&#xA;Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, &#xA;vel illum dolore eu feugiat nulla facilisis.&#xA;hell&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, it compiles fine, but, when I put cursor on a line, and do &lt;code&gt;\ls&lt;/code&gt;, it prompts an evince window with error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This file does not exists: /tmp/&amp;lt;line number where my cursor is&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have also tried: &lt;a href=&quot;https://tex.stackexchange.com/questions/2941/how-to-setup-synctex-with-vim-pdflatex-and-an-open-source-pdf-viewer-under-linu&quot;&gt;https://tex.stackexchange.com/questions/2941/how-to-setup-synctex-with-vim-pdflatex-and-an-open-source-pdf-viewer-under-linu&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but with now change.&lt;/p&gt;&#xA;" OwnerUserId="2738" LastEditorUserId="-1" LastEditDate="2017-04-13T12:34:32.317" LastActivityDate="2016-12-21T16:24:45.117" Title="vim-latex suit forward search" Tags="|search|plugin-vim-latex|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10698" PostTypeId="1" AcceptedAnswerId="10743" CreationDate="2016-12-21T19:28:40.357" Score="2" ViewCount="150" Body="&lt;p&gt;I'm having problems with latex-suite (some research indicates that many people are). The issue at hand is that they have a nifty python script that gives you a nice outline of your document and reference labels present therein. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running VimTouch for Android, which runs vim 7.3. It is compiled without python support. However, I have python on my system, so it uses a few lines of code like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function TexStartOutline()&#xA;. . . &#xA;let retval = system(latex_path.&quot;/outline.py&quot;. ' ' .shellescape(fname) . ' ' .shellescape (leader))&#xA;0put!=retval&#xA;&#xA;&quot;not an exact replica, but it's the same idea. It gets called from another &#xA;&quot;function which is called from a mapping&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In any case, when I run the same script myself (say with &lt;code&gt;:! ~/vim/ftplugin/latex-suite/outline.py myfile.tex&lt;/code&gt; I do get the correct output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that for some reason, python won't return anything when it's called from a function. Is there any way around this? It would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="10421" LastEditorUserId="10421" LastEditDate="2016-12-22T18:30:49.117" LastActivityDate="2016-12-25T04:44:01.633" Title="Running python code in a function" Tags="|functions|plugin-vim-latex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10699" PostTypeId="2" ParentId="10698" CreationDate="2016-12-21T20:59:00.717" Score="2" Body="&lt;p&gt;I am not quite sure, however there is something strange with your &lt;code&gt;system()&lt;/code&gt; call. You do:&#xA;&lt;code&gt;&#xA;let retval = system(latex_path.&quot;/outline.py&quot;. shellescape(fname) . shellescape (leader)&#xA;&lt;/code&gt;&#xA;Note, that you do concat the filename to the python script &lt;strong&gt;without&lt;/strong&gt; spaces, so you call &lt;code&gt;~/vim/ftplugin/latex-suite/outline.pymyfile.texleader&lt;/code&gt; which most likely does not make sense. Also I don't know, what leader is, so not sure, if it should be added as argument to your python script. Also note, that you function most likely won't handle path with spaces appropriately. &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-12-21T20:59:00.717" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10700" PostTypeId="2" ParentId="7761" CreationDate="2016-12-21T22:48:38.233" Score="5" Body="&lt;p&gt;This function keeps also your search register. So you can pass your command as argument on it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('*Preserve')&#xA;    function! Preserve(command)&#xA;        try&#xA;            &quot; Preparation: save last search, and cursor position.&#xA;            let l:win_view = winsaveview()&#xA;            let l:old_query = getreg('/')&#xA;            silent! execute 'keepjumps' . a:command&#xA;        finally&#xA;            &quot; try restore / reg and cursor position&#xA;            call winrestview(l:win_view)&#xA;            call setreg('/', l:old_query)&#xA;        endtry&#xA;    endfunction&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some explanation&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let .......... used to set a variable&#xA;l:somevar .... local variable&#xA;winsaveview()  get information about window view&#xA;winrestview(lwinview) restores window view to its last status&#xA;getreg('/')    used to store the last search in a variable&#xA;keepjumps      used to performe any change without change jumplis&#xA;. a:command    concatenates any given command with keepjumps&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Reident file without moving cursor position&#xA;:call Preserve('normal! gg=G')&#xA;&#xA;&quot;Reindent command using 'Preserve()'&#xA;command! -nargs=0 Reindent :call Preserve('exec &quot;normal! gg=G&quot;')&#xA;&#xA;&quot;If you have any change log at your file header&#xA;:call Preserve('1,5s/Last Change: \zs.*/\=strftime(&quot;%c&quot;)/e')&#xA;&#xA;&quot;Close all buffers but current one&#xA;&quot; https://bitbucket.org/snippets/sergio/9nbyGy&#xA;command! BufOnly silent! call Preserve(&quot;exec '%bd|e#|bd#'&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;source:&#xA;&lt;a href=&quot;https://technotales.wordpress.com/2010/03/31/preserve-a-vim-function-that-keeps-your-state/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://technotales.wordpress.com/2010/03/31/preserve-a-vim-function-that-keeps-your-state/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2019-12-22T13:00:12.270" LastActivityDate="2019-12-22T13:00:12.270" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="10701" PostTypeId="2" ParentId="10677" CreationDate="2016-12-21T23:34:03.743" Score="2" Body="&lt;p&gt;My approach&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/group2/+1,/group3/-1p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2016-12-21T23:34:03.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10703" PostTypeId="1" CreationDate="2016-12-22T03:13:21.973" Score="0" ViewCount="353" Body="&lt;p&gt;So, when running vim under gnu screen and using a color scheme, some of the color sequences bleed into the prompt after I close the program. This only happens under gnu screen, and not when I'm not running a terminal multiplexer. It also doesn't happen under tmux FWIW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure whether GNU screen or vim is the culprit here. Other editors that use colors like jed, joe and gnu emacs do not leave stray colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I configure either screen or vim to not do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps to reproduce and visual proof:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry if the screenshots take up a lot of space, I can cut it down, but I think this makes the problem obvious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) start gnu screen&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xtSbz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xtSbz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) start vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cbkY1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cbkY1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) this is vim without any color scheme turned on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2UmEY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2UmEY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) turn on the industry color scheme (note that the filetype plugin is not on, so the whole thing is bright white).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mRD2C.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mRD2C.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5) exit vim and hit enter a couple of times&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oHEam.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oHEam.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="51" LastEditDate="2017-01-01T22:27:58.027" LastActivityDate="2018-06-07T18:23:41.453" Title="Ansi color sequences from vim bleeding into prompt in GNU Screen" Tags="|colorscheme|gnu-screen|" AnswerCount="1" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10705" PostTypeId="1" AcceptedAnswerId="10706" CreationDate="2016-12-22T09:41:45.610" Score="12" ViewCount="2972" Body="&lt;p&gt;Usually insert mode completion (&lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt;) inserts the right word the first time I press &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt;, but not always. Therefore, I would like Vim to insert the match it deems best when I press &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt;, but still allow me to cancel this insertion afterwards should the correct match not show up or be a long way down the list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course I could code this behavior, but I have a feeling there should be a standard key(-combination) to do this. Could someone point me in the right direction?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus question: is there another key I can use to get the longest match (as it was before I hit &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For what it's worth, I'm using &lt;code&gt;completeopt=menu&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="8061" LastEditorUserId="51" LastEditDate="2017-01-07T13:04:25.630" LastActivityDate="2017-01-07T13:04:56.820" Title="cancel complete" Tags="|autocompletion|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10706" PostTypeId="2" ParentId="10705" CreationDate="2016-12-22T10:50:23.830" Score="18" Body="&lt;p&gt;From &lt;code&gt;:h complete_CTRL-E&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;                                                        *complete_CTRL-E*&#xA;When completion is active you can use CTRL-E to stop it and go back to the&#xA;originally typed text.  The CTRL-E will not be inserted.&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also if you, say, type &lt;code&gt;a&lt;/code&gt; then &lt;code&gt;^P&lt;/code&gt;and you get a very long list, you can hit &lt;code&gt;^N&lt;/code&gt;&#xA;to return to your original text with the completion popup still active. You can then type extra characters to narrow the completion list.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="51" LastEditDate="2017-01-07T13:04:56.820" LastActivityDate="2017-01-07T13:04:56.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10707" PostTypeId="2" ParentId="10680" CreationDate="2016-12-22T10:54:48.640" Score="6" Body="&lt;p&gt;One way to do this is to delete the range you are interested in, delete the remainder of the buffer into the black hole register, then put the text you want to keep into the empty buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/pat1/;/pat2/d | %d_ | put | 1d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The final &lt;code&gt;1d&lt;/code&gt; is to tidy up the empty line at the top, and handily leaves&#xA;the cursor at the start of the buffer.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-12-22T12:30:19.467" LastActivityDate="2016-12-22T12:30:19.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10708" PostTypeId="1" AcceptedAnswerId="11062" CreationDate="2016-12-22T14:13:05.810" Score="22" ViewCount="16061" Body="&lt;p&gt;I installed &lt;code&gt;tmux&lt;/code&gt; in iTerm 2.(Build 3.0.13) When I execute &lt;code&gt;vim&lt;/code&gt; in &lt;code&gt;tmux&lt;/code&gt;, syntax highlighting looks like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zlKpP.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zlKpP.png&quot; alt=&quot;no syntax highlighting&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But outside tmux, syntax highlighting looks fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8vizB.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8vizB.png&quot; alt=&quot;ordinary syntax highlighting&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;$TERM&lt;/code&gt; inside and outside tmux is &lt;code&gt;xterm-256color&lt;/code&gt;. I also added &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set -g default-terminal &quot;screen-256color&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;.tmux.conf&lt;/code&gt; and added this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co=256&#xA;set t_AB=m&#xA;set t_AF=m&#xA;if &amp;amp;term =~ '256color'&#xA;    set t_ut=&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried &lt;code&gt;tmux -2&lt;/code&gt; command and read these questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/10158508/lose-vim-colorscheme-in-tmux-mode&quot;&gt;lose vim colorscheme in tmux mode&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/7278267/incorrect-colors-with-vim-in-iterm2-using-solarized&quot;&gt;Incorrect colors with vim in iTerm2 using Solarized&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a problem of &lt;code&gt;tmux&lt;/code&gt;, &lt;code&gt;vim&lt;/code&gt;, or my configuration?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; in GitHub Gist&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://gist.github.com/sohnryang/3c63397f332f2e30c7d7b2a83c3c9f52&quot; rel=&quot;noreferrer&quot;&gt;https://gist.github.com/sohnryang/3c63397f332f2e30c7d7b2a83c3c9f52&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10072" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2021-05-29T16:40:47.413" Title="No syntax highlighting in tmux" Tags="|syntax-highlighting|tmux|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="10709" PostTypeId="2" ParentId="10649" CreationDate="2016-12-22T14:47:00.910" Score="1" Body="&lt;p&gt;It's because you are using &lt;code&gt;inoremap&lt;/code&gt;. Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap ( ()&amp;lt;ESC&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the documentation at &lt;code&gt;:h recursive_mapping&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;[...] If the {rhs} starts with {lhs}, the first character is not mapped&#xA;again (this is Vi compatible).&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-12-22T14:54:34.640" LastActivityDate="2016-12-22T14:54:34.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10710" PostTypeId="1" CreationDate="2016-12-22T16:15:51.553" Score="4" ViewCount="2272" Body="&lt;p&gt;I tried to remap my split navigation like &lt;a href=&quot;https://robots.thoughtbot.com/vim-splits-move-faster-and-more-naturally#easier-split-navigations&quot; rel=&quot;nofollow noreferrer&quot;&gt;explained here&lt;/a&gt;. Moving to the top  or right split  works but ther other two just do nothing. I tried the same without a .vimrc which led to the same result. Later i tried the same in GVim where all of them worked so i guessed it has something to do with vim running in the terminal. Then i figured out that pressing  in my terminal doesn't act like backspace as it should.&lt;br&gt;&#xA;What can i do to fix this?&lt;/p&gt;&#xA;" OwnerUserId="10586" LastActivityDate="2016-12-23T09:08:08.600" Title="Having issues maping &lt;C-j&gt; and &lt;C-h&gt; in vim" Tags="|key-bindings|split|" AnswerCount="1" CommentCount="2" ClosedDate="2016-12-31T03:45:40.513" ContentLicense="CC BY-SA 3.0" />
  <row Id="10711" PostTypeId="1" CreationDate="2016-12-22T22:29:40.160" Score="4" ViewCount="659" Body="&lt;p&gt;After watching Damian Conway's &lt;a href=&quot;http://radar.oreilly.com/2013/10/more-instantly-better-vim.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;talk&lt;/a&gt;, I added the following two lines to my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight ColorColumn ctermbg=magenta&#xA;call matchadd('ColorColumn', '\%81v', 100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My objective is to get the 81st column to be highlighted whenever a line goes beyond 80 characters. Unfortunately, if I open a new file and type &lt;code&gt;80i-&lt;/code&gt;, then I get highlighting on the 81st column even though there is no character there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I manually delete the 80th character and type it again, I sometimes get highlighting on the 81st column and sometimes don't. When I have 80 characters, I'd prefer not to have the 81st column highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this behavior?&lt;/p&gt;&#xA;" OwnerUserId="1750" LastEditorUserId="1750" LastEditDate="2016-12-22T22:40:47.227" LastActivityDate="2016-12-23T05:58:32.620" Title="How do I get consistent behavior with matchadd color column?" Tags="|highlight|colorcolumn|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10712" PostTypeId="2" ParentId="10711" CreationDate="2016-12-22T23:27:11.707" Score="4" Body="&lt;p&gt;After digging around a bit on the internet, I found &lt;a href=&quot;http://vim.wikia.com/wiki/Highlight_long_lines&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt; which achieves a similar effect but is more specific in the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fix is to add a &lt;code&gt;.&lt;/code&gt; after the &lt;code&gt;v&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call matchadd('ColorColumn', '\%81v.', 100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1750" LastActivityDate="2016-12-22T23:27:11.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10714" PostTypeId="1" AcceptedAnswerId="10718" CreationDate="2016-12-23T05:36:43.843" Score="2" ViewCount="90" Body="&lt;p&gt;For learning purpose, I'm trying to reimplement a small subset of the features provided by the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=40&quot; rel=&quot;nofollow noreferrer&quot;&gt;DrawIt&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, here's what I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; data &quot;{{{&#xA;&#xA;let s:draw_state = 'disabled'&#xA;&#xA;let s:draw_chars = {&#xA;                   \ 'minus'     : '-',&#xA;                   \ 'pipe'      : '|',&#xA;                   \ 'plus'      : '+',&#xA;                   \ 'backslash' : '\',&#xA;                   \ 'slash'     : '/',&#xA;                   \ 'X'         : 'X',&#xA;                   \ }&#xA;&#xA;&quot;}}}&#xA;&quot; mappings &quot;{{{&#xA;&#xA;nno &amp;lt;silent&amp;gt; m_        :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;draw_change_state(0)&amp;lt;CR&amp;gt;&#xA;nno &amp;lt;silent&amp;gt; m&amp;lt;space&amp;gt;  :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;draw_change_state(1)&amp;lt;CR&amp;gt;&#xA;nno &amp;lt;silent&amp;gt; m&amp;lt;Bar&amp;gt;    :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;draw_stop()&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;}}}&#xA;&quot; beyond_last_line&quot;{{{&#xA;&#xA;fu! s:draw_beyond_last_line(key) abort&#xA;    return (a:key ==? '&amp;lt;Down&amp;gt;' || a:key ==? '&amp;lt;PageDown&amp;gt;' || a:key ==? '&amp;lt;End&amp;gt;' || a:key ==# 'v' )&#xA;            \ &amp;amp;&amp;amp; s:draw_state ==# 'drawing' &amp;amp;&amp;amp; line('.') == line('$')&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; change_state &quot;{{{&#xA;&#xA;fu! s:draw_change_state(erasing_mode) abort&#xA;&#xA;    if s:draw_state ==# 'disabled'&#xA;        let s:ve_save = &amp;amp;ve&#xA;        let s:draw_original_mappings = s:save_mappings([&#xA;                                                       \ '&amp;lt;Left&amp;gt;',&#xA;                                                       \ '&amp;lt;Right&amp;gt;',&#xA;                                                       \ '&amp;lt;Down&amp;gt;',&#xA;                                                       \ '&amp;lt;Up&amp;gt;',&#xA;                                                       \ '&amp;lt;S-Left&amp;gt;',&#xA;                                                       \ '&amp;lt;S-Right&amp;gt;',&#xA;                                                       \ '&amp;lt;S-Down&amp;gt;',&#xA;                                                       \ '&amp;lt;S-Up&amp;gt;',&#xA;                                                       \ '&amp;lt;',&#xA;                                                       \ '&amp;gt;',&#xA;                                                       \ 'v',&#xA;                                                       \ '^',&#xA;                                                       \ ],&#xA;                                                       \&#xA;                                                       \   'n',&#xA;                                                       \       1)&#xA;&#xA;        &quot; The last argument passed to `s:save_mappings()` is 1. &quot;{{{&#xA;        &quot; This is very important. It means that we save global mappings.&#xA;        &quot; We aren't interested in buffer-local ones.&#xA;        &quot; Why?&#xA;        &quot; It would be difficult to restore them, we would need to first restore&#xA;        &quot; the focus to the buffer where they were initially saved.&#xA;        &quot; And they could only be used in the current buffer, not in others.&#xA;        &quot;&#xA;        &quot; I prefer to not bother.&#xA;        &quot; If the user mapped the keys locally, our global mapping will work&#xA;        &quot; everywhere except in the current buffer and buffers where they&#xA;        &quot; installed similar buffer-local mappings.&#xA;        &quot;&#xA;        &quot; Trying to support this case would create too much complexity.&#xA;        &quot; We would need to override the buffer-local mappings from the user in&#xA;        &quot; every buffer where they exist. It would probably require an autocmd,&#xA;        &quot; watching some event, like `BufEnter,BufNewFile`.&#xA;        &quot; It would have to check whether the user did install a buffer-local&#xA;        &quot; mapping using the keys we're interested in, and in that case,&#xA;        &quot; save the info about the mapping as well as the position of the buffer&#xA;        &quot; in the buffer list.&#xA;        &quot;&#xA;        &quot; Once the user stops drawing, we would then need to parse all this&#xA;        &quot; info, to give the focus to various buffers and restore the mappings&#xA;        &quot; in them.&#xA;        &quot; Then, we would need to restore the layout… FUBAR&#xA;        &quot;&#xA;        &quot; }}}&#xA;&#xA;    endif&#xA;&#xA;    let s:draw_state = {&#xA;                       \ 'disabled' : a:erasing_mode ? 'erasing'  : 'drawing' ,&#xA;                       \ 'drawing'  : a:erasing_mode ? 'erasing'  : 'disabled',&#xA;                       \ 'erasing'  : a:erasing_mode ? 'disabled' : 'drawing' ,&#xA;                       \ }[s:draw_state]&#xA;&#xA;    call s:draw_update_mappings()&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; install_mappings &quot;{{{&#xA;&#xA;fu! s:draw_install_mappings() abort&#xA;    let args = ' &amp;lt;nowait&amp;gt; &amp;lt;silent&amp;gt; '&#xA;&#xA;    for l:key in ['Left&amp;gt;', 'Right&amp;gt;', 'Down&amp;gt;', 'Up&amp;gt;', 'PageDown&amp;gt;', 'PageUp&amp;gt;', 'Home&amp;gt;', 'End&amp;gt;']&#xA;        exe 'nno '.args.' &amp;lt;'.l:key.' :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;draw_it('.string('&amp;lt;lt&amp;gt;'.l:key).')&amp;lt;CR&amp;gt;'&#xA;    endfor&#xA;&#xA;    for l:key in ['S-Left&amp;gt;', 'S-Right&amp;gt;', 'S-Down&amp;gt;', 'S-Up&amp;gt;']&#xA;        exe 'nno '.args.' &amp;lt;'.l:key.' :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;draw_shift_arrow_motion(&quot;&amp;lt;lt&amp;gt;'.l:key.'&quot;)&amp;lt;CR&amp;gt;'&#xA;    endfor&#xA;&#xA;    for l:key in ['&amp;lt;', '&amp;gt;', 'v', '^']&#xA;        exe 'nno '.args.l:key.' :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;draw_it('.string(l:key).')&amp;lt;CR&amp;gt;'&#xA;    endfor&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; intersection &quot;{{{&#xA;&#xA;fu! s:draw_intersection(key) abort&#xA;    if count(['&amp;lt;Left&amp;gt;', '&amp;lt;Right&amp;gt;', '&amp;lt;Down&amp;gt;', '&amp;lt;Up&amp;gt;'], a:key)&#xA;        return '+'&#xA;&#xA;    elseif count(['&amp;lt;End&amp;gt;', '&amp;lt;Home&amp;gt;', '&amp;lt;PageDown&amp;gt;', '&amp;lt;PageUp&amp;gt;'], a:key)&#xA;        return 'X'&#xA;    endif&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; is_changing_dir &quot;{{{&#xA;&#xA;fu! s:draw_is_changing_dir(key) abort&#xA;    return getline('.')[col('.')-1] ==# s:draw_chars[s:draw_opposite(a:key)]&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; it &quot;{{{&#xA;&#xA;fu! s:draw_it(key) abort&#xA;&#xA;    if s:draw_beyond_last_line(a:key)&#xA;        call append('.', '')&#xA;    endif&#xA;&#xA;    if count([&#xA;             \ '&amp;lt;Left&amp;gt;',&#xA;             \ '&amp;lt;Right&amp;gt;',&#xA;             \ '&amp;lt;Down&amp;gt;',&#xA;             \ '&amp;lt;Up&amp;gt;',&#xA;             \ '&amp;lt;PageDown&amp;gt;',&#xA;             \ '&amp;lt;PageUp&amp;gt;',&#xA;             \ '&amp;lt;End&amp;gt;',&#xA;             \ '&amp;lt;Home&amp;gt;'&#xA;             \ ],&#xA;             \     a:key)&#xA;&#xA;        let keys = (&#xA;                 \   s:draw_is_changing_dir(a:key)&#xA;                 \     ? s:draw_replace_char(s:draw_intersection(a:key))&#xA;                 \     : ''&#xA;                 \ )&#xA;                 \ .s:draw_motion(a:key)&#xA;                 \ .s:draw_replace_char(a:key)&#xA;&#xA;    elseif count(['^', 'v', '&amp;lt;', '&amp;gt;'], a:key)&#xA;&#xA;        let keys = 'r'.a:key.s:draw_motion(a:key).'r'.a:key&#xA;&#xA;    endif&#xA;&#xA;    call feedkeys(keys, 'in')&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; key2name &quot;{{{&#xA;&#xA;fu! s:draw_key2name(key) abort&#xA;    if a:key ==? '&amp;lt;Left&amp;gt;' || a:key ==? '&amp;lt;Right&amp;gt;'&#xA;        return 'minus'&#xA;&#xA;    elseif a:key ==? '&amp;lt;Down&amp;gt;' || a:key ==? '&amp;lt;Up&amp;gt;'&#xA;        return 'pipe'&#xA;&#xA;    elseif a:key ==? '&amp;lt;End&amp;gt;' || a:key ==? '&amp;lt;PageUp&amp;gt;'&#xA;        return 'slash'&#xA;&#xA;    elseif a:key ==? '&amp;lt;Home&amp;gt;' || a:key ==? '&amp;lt;PageDown&amp;gt;'&#xA;        return 'backslash'&#xA;&#xA;    elseif a:key ==? '+'&#xA;        return 'plus'&#xA;&#xA;    elseif a:key ==# 'X'&#xA;        return 'X'&#xA;&#xA;    endif&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; motion &quot;{{{&#xA;&#xA;fu! s:draw_motion(key) abort&#xA;    if a:key ==? '&amp;lt;Left&amp;gt;'&#xA;        return &quot;\&amp;lt;Left&amp;gt;&quot;&#xA;&#xA;    elseif a:key ==? '&amp;lt;Right&amp;gt;'&#xA;        return &quot;\&amp;lt;Right&amp;gt;&quot;&#xA;&#xA;    elseif a:key ==? '&amp;lt;Down&amp;gt;'&#xA;        return &quot;\&amp;lt;Down&amp;gt;&quot;&#xA;&#xA;    elseif a:key ==? '&amp;lt;Up&amp;gt;'&#xA;        return &quot;\&amp;lt;Up&amp;gt;&quot;&#xA;&#xA;    elseif a:key ==? '&amp;lt;PageDown&amp;gt;'&#xA;        return &quot;\&amp;lt;Right&amp;gt;\&amp;lt;Down&amp;gt;&quot;&#xA;&#xA;    elseif a:key ==? '&amp;lt;PageUp&amp;gt;'&#xA;        return &quot;\&amp;lt;Right&amp;gt;\&amp;lt;Up&amp;gt;&quot;&#xA;&#xA;    elseif a:key ==? '&amp;lt;Home&amp;gt;'&#xA;        return &quot;\&amp;lt;Left&amp;gt;\&amp;lt;Up&amp;gt;&quot;&#xA;&#xA;    elseif a:key ==? '&amp;lt;End&amp;gt;'&#xA;        return &quot;\&amp;lt;Left&amp;gt;\&amp;lt;Down&amp;gt;&quot;&#xA;&#xA;    elseif a:key ==# 'v'&#xA;        return &quot;\&amp;lt;Down&amp;gt;&quot;&#xA;&#xA;    elseif a:key ==# '^'&#xA;        return &quot;\&amp;lt;Up&amp;gt;&quot;&#xA;&#xA;    elseif a:key ==# '&amp;lt;'&#xA;        return &quot;\&amp;lt;Left&amp;gt;&quot;&#xA;&#xA;    elseif a:key ==# '&amp;gt;'&#xA;        return &quot;\&amp;lt;Right&amp;gt;&quot;&#xA;&#xA;    endif&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; opposite &quot;{{{&#xA;&#xA;fu! s:draw_opposite(key) abort&#xA;    if a:key ==? '&amp;lt;Down&amp;gt;' || a:key ==? '&amp;lt;Up&amp;gt;'&#xA;        return 'minus'&#xA;&#xA;    elseif a:key ==? '&amp;lt;Left&amp;gt;' || a:key ==? '&amp;lt;Right&amp;gt;'&#xA;        return 'pipe'&#xA;&#xA;    elseif a:key ==? '&amp;lt;Home&amp;gt;' || a:key ==? '&amp;lt;PageDown&amp;gt;'&#xA;        return 'slash'&#xA;&#xA;    elseif a:key ==? '&amp;lt;End&amp;gt;' || a:key ==? '&amp;lt;PageUp&amp;gt;'&#xA;        return 'backslash'&#xA;    endif&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; remove_mappings &quot;{{{&#xA;&#xA;fu! s:draw_remove_mappings() abort&#xA;    for l:key in [&#xA;                 \ '&amp;lt;Left&amp;gt;',&#xA;                 \ '&amp;lt;Right&amp;gt;',&#xA;                 \ '&amp;lt;Down&amp;gt;',&#xA;                 \ '&amp;lt;Up&amp;gt;',&#xA;                 \ '&amp;lt;S-Left&amp;gt;',&#xA;                 \ '&amp;lt;S-Right&amp;gt;',&#xA;                 \ '&amp;lt;S-Down&amp;gt;',&#xA;                 \ '&amp;lt;S-Up&amp;gt;',&#xA;                 \ '&amp;lt;PageDown&amp;gt;',&#xA;                 \ '&amp;lt;PageUp&amp;gt;',&#xA;                 \ '^',&#xA;                 \ 'v',&#xA;                 \ '&amp;lt;',&#xA;                 \ '&amp;gt;',&#xA;                 \ ]&#xA;&#xA;        &quot; Why unmap silently?&#xA;        &quot;&#xA;        &quot; Because we could be dumb and ask to disable the drawing mode manually&#xA;        &quot; (`m|`), even though it's already disabled.&#xA;        &quot; It could raise errors, if the keys are already unmapped (the user didn't&#xA;        &quot; map them to anything by default).&#xA;&#xA;        sil! exe 'nunmap '.l:key&#xA;    endfor&#xA;&#xA;        call s:restore_mappings(s:draw_original_mappings)&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; replace_char&quot;{{{&#xA;&#xA;fu! s:draw_replace_char(key) abort&#xA;    &quot; This function is called before and then after a motion (left, up, …).&#xA;    &quot; It must return the character to draw.&#xA;    &quot;&#xA;    &quot; When it's called AFTER a motion, and we're erasing, the character HAS TO&#xA;    &quot; be a space.&#xA;    &quot; When it's called BEFORE a motion, and we're erasing, we COULD (should?)&#xA;    &quot; return nothing.&#xA;    &quot;&#xA;    &quot; Nevertheless, we let the function return a space.&#xA;    &quot; It doesn't seem to cause an issue.&#xA;    &quot; This way, we don't have to pass a 2nd argument to know when it's called&#xA;    &quot; (before or after a motion).&#xA;&#xA;    return 'r'&#xA;         \ .(&#xA;         \   s:draw_state ==# 'erasing'&#xA;         \   ? ' '&#xA;         \   : s:draw_chars[s:draw_key2name(a:key)]&#xA;         \  )&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; restore_mappings &quot;{{{&#xA;&#xA;&quot; Warning:&#xA;&quot; Don't try to restore a buffer local mapping unless you're sure that, when&#xA;&quot; `s:restore_mappings()` is called, you're in the same buffer where&#xA;&quot; `s:save_mappings()` was originally called.&#xA;&quot;&#xA;&quot; If you aren't in the same buffer, you could install a buffer-local mapping&#xA;&quot; inside a buffer where this mapping didn't exist before.&#xA;&quot; It could cause unexpected behavior on the user's system.&#xA;&quot;&#xA;&quot; Usage:&#xA;&quot; call s:restore_mappings(my_saved_mappings)&#xA;&quot;&#xA;&quot; `my_saved_mappings` is a dictionary obtained earlier by calling&#xA;&quot; `s:save_mappings()`.&#xA;&quot; Its keys are the keys used in the mappings.&#xA;&quot; Its values are the info about those mappings stored in sub-dictionaries.&#xA;&quot;&#xA;&quot; There's nothing special to pass to `s:restore_mappings()`, no other&#xA;&quot; argument, no wrapping inside a 3rd dictionary, or anything. Just this dictionary.&#xA;&#xA;fu! s:restore_mappings(mappings) abort&#xA;&#xA;    for mapping in values(a:mappings)&#xA;        if !empty(mapping)&#xA;            exe    (mapping.noremap ? ' nnoremap ' : ' nmap ')&#xA;               \ . (mapping.buffer  ? ' &amp;lt;buffer&amp;gt; ' : '')&#xA;               \ . (mapping.expr    ? ' &amp;lt;expr&amp;gt;   ' : '')&#xA;               \ . (mapping.nowait  ? ' &amp;lt;nowait&amp;gt; ' : '')&#xA;               \ . (mapping.silent  ? ' &amp;lt;silent&amp;gt; ' : '')&#xA;               \ .  mapping.lhs&#xA;               \ . ' '&#xA;               \ . substitute(mapping.rhs, '&amp;lt;SID&amp;gt;', '&amp;lt;SNR&amp;gt;'.mapping.sid.'_', 'g')&#xA;        endif&#xA;    endfor&#xA;&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; save_mappings &quot;{{{&#xA;&#xA;&quot; Usage:&#xA;&quot;&#xA;&quot;     let my_global_mappings = s:save_mappings(['key1', 'key2', …], 'n', 1)&#xA;&quot;     let my_local_mappings  = s:save_mappings(['key1', 'key2', …], 'n', 0)&#xA;&quot;&#xA;&#xA;&quot; Output example: &quot;{{{&#xA;&quot;&#xA;&quot;     { '&amp;lt;left&amp;gt;' :&#xA;&quot;                \&#xA;&quot;                \ {'silent': 0,&#xA;&quot;                \ 'noremap': 1,&#xA;&quot;                \ 'lhs': '&amp;lt;Left&amp;gt;',&#xA;&quot;                \ 'mode': 'n',&#xA;&quot;                \ 'nowait': 0,&#xA;&quot;                \ 'expr': 0,&#xA;&quot;                \ 'sid': 7,&#xA;&quot;                \ 'rhs': ':echo ''foo''&amp;lt;CR&amp;gt;',&#xA;&quot;                \ 'buffer': 1},&#xA;&quot;                \&#xA;&quot;     \ '&amp;lt;right&amp;gt;':&#xA;&quot;                \&#xA;&quot;                \ { 'silent': 0,&#xA;&quot;                \ 'noremap': 1,&#xA;&quot;                \ 'lhs': '&amp;lt;Right&amp;gt;',&#xA;&quot;                \ 'mode': 'n',&#xA;&quot;                \ 'nowait': 0,&#xA;&quot;                \ 'expr': 0,&#xA;&quot;                \ 'sid': 7,&#xA;&quot;                \ 'rhs': ':echo ''bar''&amp;lt;CR&amp;gt;',&#xA;&quot;                \ 'buffer': 1,&#xA;&quot;                \ },&#xA;&quot;                \}&#xA;&quot;&#xA;&quot; }}}&#xA;&#xA;fu! s:save_mappings(keys, mode, global) abort&#xA;    let mappings = {}&#xA;&#xA;    &quot; If a key is used in a global mapping and a local one, by default,&#xA;    &quot; `maparg()` only returns information about the local one.&#xA;    &quot; We want to be able to get info about a global mapping even if a local&#xA;    &quot; one shadows it.&#xA;    &quot; To do that, we will temporarily unmap the local mapping.&#xA;&#xA;    if a:global&#xA;        for l:key in a:keys&#xA;            let buf_local_map = maparg(l:key, a:mode, 0, 1)&#xA;&#xA;            &quot; temporarily unmap the local mapping&#xA;            sil! exe a:mode.'unmap &amp;lt;buffer&amp;gt; '.l:key&#xA;&#xA;            &quot; save info about the global one&#xA;            let mappings[l:key] = maparg(l:key, a:mode, 0, 1)&#xA;&#xA;            &quot; restore the local one&#xA;            call s:restore_mappings({l:key : buf_local_map})&#xA;        endfor&#xA;&#xA;    &quot; TRY to return info local mappings.&#xA;    &quot; If they exist it will work, otherwise it will return info about global&#xA;    &quot; mappings.&#xA;    else&#xA;        for l:key in a:keys&#xA;            let mappings[l:key] = maparg(l:key, a:mode, 0, 1)&#xA;        endfor&#xA;    endif&#xA;&#xA;    return mappings&#xA;endfu&#xA;&#xA;&#xA;&quot;}}}&#xA;&quot; shift_arrow_motion &quot;{{{&#xA;&#xA;fu! s:draw_shift_arrow_motion(key) abort&#xA;    if a:key ==? '&amp;lt;S-Down&amp;gt;' &amp;amp;&amp;amp; line('.') == line('$')&#xA;        call append('.', '')&#xA;    endif&#xA;    call feedkeys(eval('&quot;'.'\'.substitute(a:key, '\cs-', '', '').'&quot;'), 'in')&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; stop &quot;{{{&#xA;&#xA;fu! s:draw_stop() abort&#xA;    let s:draw_state = 'disabled'&#xA;    call s:draw_remove_mappings()&#xA;    let &amp;amp;ve = s:ve_save&#xA;    echom '[Drawing/Erasing] disabled'&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&quot; update_mappings&quot;{{{&#xA;&#xA;fu! s:draw_update_mappings() abort&#xA;    if s:draw_state ==# 'disabled'&#xA;        call s:draw_stop()&#xA;&#xA;    else&#xA;        call s:draw_install_mappings()&#xA;        set ve=all&#xA;        echom '['.substitute(s:draw_state, '.', '\u&amp;amp;', '').'] '.'enabled'&#xA;&#xA;    endif&#xA;endfu&#xA;&#xA;&quot;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are the mappings I'm currently using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;m_            start/toggle drawing&#xA;m&amp;lt;space&amp;gt;      start/toggle erasing&#xA;m|            stop everything&#xA;&#xA;&amp;lt;left&amp;gt;        insert `-` and move left&#xA;&amp;lt;right&amp;gt;       insert `-` and move right&#xA;&amp;lt;down&amp;gt;        insert `|` and move down&#xA;&amp;lt;up&amp;gt;          insert `|` and move up&#xA;&#xA;&amp;lt;s-left&amp;gt;      move left&#xA;&amp;lt;s-right&amp;gt;     move right&#xA;&amp;lt;s-down&amp;gt;      move down&#xA;&amp;lt;s-up&amp;gt;        move up&#xA;&#xA;&amp;lt;Home&amp;gt;        insert `\` and move up&#xA;&amp;lt;PageUp&amp;gt;      insert `/` and move up&#xA;&amp;lt;End&amp;gt;         insert `/` and move down&#xA;&amp;lt;PageDown&amp;gt;    insert `\` and move down&#xA;v             insert `v` and move down&#xA;^             insert `^` and move up&#xA;&amp;lt;             insert `&amp;lt;` and move left&#xA;&amp;gt;             insert `&amp;gt;` and move right&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But I don't know how to handle intersections. What I would like to achieve is the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If the character I'm inserting is not parallel to the one where I was just before, replace the latter with an intersection. For example, if I'm on a &lt;code&gt;-&lt;/code&gt; and I hit &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;Down&amp;gt;&lt;/code&gt;, it should insert a &lt;code&gt;|&lt;/code&gt; which is not parallel to &lt;code&gt;-&lt;/code&gt;. So, &lt;code&gt;-&lt;/code&gt; should be replaced with &lt;code&gt;+&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the character I'm inserting is replacing an existing character which is not parallel, do the same thing. For example, if I hit &lt;code&gt;&amp;lt;PageDown&amp;gt;&lt;/code&gt; to move down and insert a &lt;code&gt;\&lt;/code&gt;, but the character on which I land after the &lt;code&gt;Down&lt;/code&gt; motion is a &lt;code&gt;/&lt;/code&gt;, then instead of inserting &lt;code&gt;\&lt;/code&gt; like it's supposed to, insert a &lt;code&gt;X&lt;/code&gt; instead.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I think the current code handles the first condition, but not the second one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;a href=&quot;https://i.stack.imgur.com/wbQ02.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wbQ02.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The corners of the drawings on the left are correctly drawn using the &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;X&lt;/code&gt; characters, but the ones on the right don't handle the intersection at all.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what the upper drawing on the right does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;             |              &#xA;       |     |              &#xA;       |     |       |      &#xA;       |     |       |      &#xA;       |     |       |      &#xA;-------|-----|-------|------&#xA;       |     |       |      &#xA;       |     |       |      &#xA;       |             |      &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's what I want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;             |              &#xA;       |     |              &#xA;       |     |       |      &#xA;       |     |       |      &#xA;       |     |       |      &#xA;-------+-----+-------+------&#xA;       |     |       |      &#xA;       |     |       |      &#xA;       |             |  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's what the lower drawing on the right does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\           &#xA; \          &#xA;  \         &#xA;   \      / &#xA;    \    / /&#xA;     \  /// &#xA;      \///  &#xA;      ///   &#xA;     ///\   &#xA;    ///  \  &#xA;    //    \ &#xA;           \&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's what I want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\           &#xA; \          &#xA;  \         &#xA;   \      / &#xA;    \    / /&#xA;     \  /// &#xA;      \///  &#xA;      /X/   &#xA;     ///\   &#xA;    ///  \  &#xA;    //    \ &#xA;           \&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The problem comes from this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:draw_it(key) abort&#xA;&#xA;    if s:draw_beyond_last_line(a:key)&#xA;        call append('.', '')&#xA;    endif&#xA;&#xA;    if count([&#xA;             \ '&amp;lt;Left&amp;gt;',&#xA;             \ '&amp;lt;Right&amp;gt;',&#xA;             \ '&amp;lt;Down&amp;gt;',&#xA;             \ '&amp;lt;Up&amp;gt;',&#xA;             \ '&amp;lt;PageDown&amp;gt;',&#xA;             \ '&amp;lt;PageUp&amp;gt;',&#xA;             \ '&amp;lt;End&amp;gt;',&#xA;             \ '&amp;lt;Home&amp;gt;'&#xA;             \ ],&#xA;             \     a:key)&#xA;&#xA;        let keys = (&#xA;                 \   s:draw_is_changing_dir(a:key)&#xA;                 \     ? s:draw_replace_char(s:draw_intersection(a:key))&#xA;                 \     : ''&#xA;                 \ )&#xA;                 \ .s:draw_motion(a:key)&#xA;                 \ .s:draw_replace_char(a:key)&#xA;&#xA;    elseif count(['^', 'v', '&amp;lt;', '&amp;gt;'], a:key)&#xA;&#xA;        let keys = 'r'.a:key.s:draw_motion(a:key).'r'.a:key&#xA;&#xA;    endif&#xA;&#xA;    call feedkeys(keys, 'in')&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And more specifically from this part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let keys = (&#xA;             \   s:draw_is_changing_dir(a:key)&#xA;             \     ? s:draw_replace_char(s:draw_intersection(a:key))&#xA;             \     : ''&#xA;             \ )&#xA;             \ .s:draw_motion(a:key)&#xA;             \ .s:draw_replace_char(a:key)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The purpose of this part is to assign the right value to the variable &lt;code&gt;keys&lt;/code&gt;. It's supposed to contain the keys to type. They are written in the typeahead buffer at the end of the function, using &lt;code&gt;feedkeys()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Currently, it can be divided into 3 parts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;           (&#xA;             \   s:draw_is_changing_dir(a:key)&#xA;             \     ? s:draw_replace_char(s:draw_intersection(a:key))&#xA;             \     : ''&#xA;             \ )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace the current character with an intersection if the direction is changing, or do nothing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;             \ .s:draw_motion(a:key)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Move the cursor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;             \ .s:draw_replace_char(a:key)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace the character under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The value of &lt;code&gt;a:key&lt;/code&gt; contains the key that was typed. For example, if I hit &lt;code&gt;&amp;lt;Down&amp;gt;&lt;/code&gt;, it should contain the string &lt;code&gt;'&amp;lt;Down&amp;gt;'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;s:draw_replace_char()&lt;/code&gt; should return 2 keys to replace the character under the cursor. The first key is always &lt;code&gt;r&lt;/code&gt;, the replace command. The second one should be the character to draw (&lt;code&gt;-&lt;/code&gt;, &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;\&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, ...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;s:draw_is_changing_dir()&lt;/code&gt; returns &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt;. It returns &lt;code&gt;1&lt;/code&gt; if the character to draw is not parallel to the one under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before moving the cursor, I test the output of this function to decide whether I should first replace the current character with an intersection or do nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;s:draw_intersection()&lt;/code&gt; returns the character standing for an intersection, &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;X&lt;/code&gt;, depending on the key which was hit. For example, if I hit &lt;code&gt;&amp;lt;Down&amp;gt;&lt;/code&gt;, the function should return the string &lt;code&gt;'+'&lt;/code&gt;. And if I hit &lt;code&gt;&amp;lt;PageDown&amp;gt;&lt;/code&gt;, it should return &lt;code&gt;'X'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;s:draw_motion()&lt;/code&gt; returns the keys to move the cursor in a direction. For example, If I hit &lt;code&gt;&amp;lt;PageDown&amp;gt;&lt;/code&gt;, it should return &lt;code&gt;&quot;\&amp;lt;Right&amp;gt;\&amp;lt;Down&amp;gt;&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I rewrite the assignment of &lt;code&gt;keys&lt;/code&gt; so that it handles the 2 conditions described earlier, regarding intersections?&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-23T06:04:42.883" LastActivityDate="2016-12-23T15:05:33.350" Title="How to handle intersections in an algorithm trying to draw ascii diagrams?" Tags="|key-bindings|vimscript|cursor-movement|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10715" PostTypeId="2" ParentId="10711" CreationDate="2016-12-23T05:58:32.620" Score="5" Body="&lt;p&gt;The solution I'm using nowadays is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matchadd('ColorColumn', '\%81v\s*\zs\S', 100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That version highlights the first non-space character after column 80, which I find more useful.&lt;/p&gt;&#xA;" OwnerUserId="10596" LastActivityDate="2016-12-23T05:58:32.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10716" PostTypeId="2" ParentId="10710" CreationDate="2016-12-23T09:08:08.600" Score="4" Body="&lt;p&gt;Your comment indicates that this problem exists only with certain terminal emulators like gnome-terminal &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;No I'm on Linux Mint. Just installed terminator and there it works. Seems to be some issue with Gnome Terminal&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Gnome-terminal is known to have trouble with mapping modifier keys in vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: The problem is that in a terminal, a Tab character is ^I (Control-I). This means that pressing control while pressing tab is not something the terminal even bothers to pass through to Vim. It just sends a regular tab character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GVim can support this because it doesn't have to rely on the terminal to tell it what keys are being pressed in what combination--it has more direct access to keyboard events, so it has no trouble seeing modified special keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While it's possible for X to recognize such combinations, applications that run in a terminal (or, these days, a terminal emulator) cannot. This is because, historically, terminals could only send and receive seven- or eight-bit sequences of ASCII data across a serial connection (though this could include &quot;escape sequences&quot; that position the cursor, scroll or delete lines, change color and other helpful effects).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some workarounds for it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, we need to know what command your terminal sends when a certain key combination is pressed:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do so press &lt;code&gt;Control + Shift + v&lt;/code&gt;&#xA;Now press the key combination &lt;code&gt;Ctrl-j&lt;/code&gt; and &lt;code&gt;Ctrl-h&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ex: I am running headless server and for me &lt;code&gt;Shift+Enter&lt;/code&gt; or &lt;code&gt;Control+Enter&lt;/code&gt; or &lt;code&gt;Enter&lt;/code&gt; shows the same output &lt;code&gt;^M&lt;/code&gt; but &lt;code&gt;Alt+Enter&lt;/code&gt; shows &lt;code&gt;^[&lt;/code&gt; This means that shift+enter and control+enter and enter are taken similarly by the terminal.&#xA;So mapping &lt;code&gt;shift+enter&lt;/code&gt; combination would also affect &lt;code&gt;enter&lt;/code&gt; combinations.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Record your output&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;enter gives me &lt;code&gt;^M&lt;/code&gt; and &lt;code&gt;\r&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;man ascii&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Look in the manpages of ascii and you will see that &lt;code&gt;\r&lt;/code&gt; is for &lt;code&gt;CR&lt;/code&gt; &#xA;so now mapping &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; will map enter keys &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following these methods you might be able to find the specific &lt;code&gt;char&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though it should solve the problem, YMMV&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated  &lt;a href=&quot;http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8&quot; rel=&quot;nofollow noreferrer&quot;&gt;various proposals&lt;/a&gt;..&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim's keyboard input system revolves centrally around a queue of bytes.&#xA;  This worked well when all the world was serial terminals. In this new&#xA;  world of GUIs this model doesn't work so well. I advocate changing it to&#xA;  a queue of keypress events. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="9004" LastActivityDate="2016-12-23T09:08:08.600" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10718" PostTypeId="2" ParentId="10714" CreationDate="2016-12-23T11:46:21.667" Score="2" Body="&lt;p&gt;Sorry, that's too much code to read through. It looks complicated though.&#xA;Just check the character under the cursor and draw appropriately.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ve=all&#xA;&#xA;fun! Drawchar(dir)&#xA;    let c = {'h':'-', 'l':'-', 'j':'|', 'k':'|'}[a:dir]&#xA;    norm!yl&#xA;    if @&quot; =~ '[-|+]' &amp;amp;&amp;amp; @&quot; != c&#xA;        let c = '+'&#xA;    endif&#xA;    exe 'norm!r' . c&#xA;endfun&#xA;&#xA;fun! Draw(dir)&#xA;    call Drawchar(a:dir)&#xA;    exe 'norm!' . a:dir&#xA;    call Drawchar(a:dir)&#xA;endfun&#xA;&#xA;nno &amp;lt;s-right&amp;gt; :call Draw('l')&amp;lt;cr&amp;gt;&#xA;nno &amp;lt;s-left&amp;gt; :call Draw('h')&amp;lt;cr&amp;gt;&#xA;nno &amp;lt;s-down&amp;gt; :call Draw('j')&amp;lt;cr&amp;gt;&#xA;nno &amp;lt;s-up&amp;gt; :call Draw('k')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2016-12-23T15:05:33.350" LastActivityDate="2016-12-23T15:05:33.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10719" PostTypeId="1" CreationDate="2016-12-23T13:21:40.960" Score="0" ViewCount="438" Body="&lt;p&gt;My DoxygenToolkit.vim was installed this way.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.To open `Root Terminal`  with root password&#xA;2.mkdir -p   /usr/share/vim/vim74/bundle&#xA;3.git clone https://github.com/gmarik/Vundle.vim.git /usr/share/vim/vim74/bundle&#xA;4.vim  /etc/vim/vimrc&#xA;set nocompatible              &#xA;filetype off                  &#xA;set rtp+=/usr/share/vim/vim74/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'L9'&#xA;Plugin 'git://git.wincent.com/command-t.git'&#xA;Plugin 'file:///home/gmarik/path/to/plugin'&#xA;Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}&#xA;Plugin 'ascenator/L9', {'name': 'newL9'}&#xA;call vundle#end()            &#xA;filetype plugin indent on    &#xA;5.vim  /etc/vim/vimrc&#xA;Bundle 'DoxygenToolkit.vim'&#xA;6.To open vim &#xA;:BundleInstall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now DoxygenToolkit.vim was installed.&lt;br&gt;&#xA;I find that two problems remain here.&lt;br&gt;&#xA;1. To open vim   with root user&lt;br&gt;&#xA;Some error messages occur.     &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim&#xA;Error detected while processing /root/.vim/bundle/newL9/plugin/l9.vim:&#xA;line   40:&#xA;E174: Command already exists: add ! to replace it&#xA;line   89:&#xA;E174: Command already exists: add ! to replace it&#xA;line  100:&#xA;E174: Command already exists: add ! to replace it&#xA;line  104:&#xA;E174: Command already exists: add ! to replace it&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2.To open vim with regular user.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:DoxLic&#xA;E492: Not an editor command: DoxLic &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to fix them all?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="5181" LastEditDate="2016-12-24T01:16:18.500" LastActivityDate="2017-02-22T15:22:17.953" Title="What is wrong with my DoxygenToolkit.vim?" Tags="|plugin-vundle|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10720" PostTypeId="1" AcceptedAnswerId="10722" CreationDate="2016-12-23T13:39:35.960" Score="6" ViewCount="2466" Body="&lt;p&gt;I am cleaning up some minified css. I found &lt;a href=&quot;http://vim.wikia.com/wiki/Add_a_newline_after_given_patterns&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt; helpful for adding a newline before/after a search match. This &lt;a href=&quot;https://stackoverflow.com/questions/235839/indent-multipe-lines-quickly-in-vi&quot;&gt;SO thread&lt;/a&gt; has a pretty exhaustive list of ways to indent with VIM, but it DOES NOT include a command-line pattern that will indent, like &lt;code&gt;\r&lt;/code&gt; for ading a newline.&lt;br&gt; The answers in this &lt;a href=&quot;https://stackoverflow.com/questions/2732618/auto-indent-in-vim-string-replacement-new-line&quot;&gt;SO thread&lt;/a&gt; rely on surrounding formatting with the &lt;code&gt;]p&lt;/code&gt; pattern or using macros, neither of which serve my purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;Here's my command to add a new line before and two new lines after all matches for &lt;code&gt;}&lt;/code&gt;:&lt;br&gt;&lt;br&gt;&lt;code&gt;:/[}]&lt;/code&gt; &lt;br&gt; &lt;br&gt;then &lt;br&gt;&lt;br&gt; &lt;code&gt;:%s//\r&amp;amp;\r\r/g&lt;/code&gt;&lt;br&gt;&lt;br&gt;I do something similar for &lt;code&gt;{&lt;/code&gt;. However, for all matches to &lt;code&gt;;&lt;/code&gt; I need to add a &lt;code&gt;\r&lt;/code&gt; (newline) and indent a determined number of spaces. I don't want to rely on vim's auto indent settings. I want to indent a number of times that i set manually in the command string.&lt;/p&gt;&#xA;" OwnerUserId="10600" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-01-10T13:42:39.717" Title="Search and replace, special pattern for indent (ex: newline = '\r')" Tags="|command-line|regular-expression|indentation|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10721" PostTypeId="2" ParentId="10719" CreationDate="2016-12-23T14:19:16.763" Score="2" Body="&lt;p&gt;The problem seems to lie in ascenator/l9 plugin. Open it at the lines incriminated and add a &lt;code&gt;!&lt;/code&gt; on all command definitions. The best is to contact its author to have him fix the plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fact you're using using the official plugin and a fork of it certainly doesn't help. Why are you doing this? It gives me the impression you have copy-pasted stuff from other people configuration without really knowing why they have these lines in their configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm under the impression there is something fishy about the way you use Vundle. As I use VAM, I can't tell if this is correct, I'll let other people using these plugin managers help you with these lines. The fact the configuration is done at root level (/etc) may not simplify things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: In lh-cpp I provide Doxygen snippets and a &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp/blob/master/doc/Doxygen.md#dox&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:DOX&lt;/code&gt;&lt;/a&gt; command that analyses function signatures (it tries to deduces in and out parameters, (deprecated) throw specifications, trivial preconditions, and so on -- I still have to extract template parameters). But to be perfectly honest your problem seems to be completely unrelated to doxygentoolkit.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-02-22T15:22:17.953" LastActivityDate="2017-02-22T15:22:17.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10722" PostTypeId="2" ParentId="10720" CreationDate="2016-12-23T15:30:36.310" Score="4" Body="&lt;p&gt;Two ways of doing this sort of thing are:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;With a &lt;code&gt;:substitute&lt;/code&gt; command&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(foo\)/\r    \1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will add a newline and four spaces of &quot;indent&quot; before every matched &lt;code&gt;foo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; around the search expression &lt;code&gt;/foo/&lt;/code&gt; capture the match into a group, and then the &lt;code&gt;\1&lt;/code&gt; uses the captured group in the replacement. This obviously isn't necessary for simple values of &lt;code&gt;/foo/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;With a &lt;code&gt;:global&lt;/code&gt; command&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can also do this with the &lt;code&gt;:normal&lt;/code&gt; and &lt;code&gt;:global&lt;/code&gt; commands. For example the following command will indent all lines that match the regexp &lt;code&gt;/foo/&lt;/code&gt; and add a line above them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/foo/normal &amp;gt;&amp;gt;O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works similar to a &lt;code&gt;:substitute&lt;/code&gt; command, but instead of making a substitution, it applies the normal mode operations indent (&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;) followed by add a line above (&lt;code&gt;O&lt;/code&gt;) to each matching line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can adjust the normal mode commands to perform different operations as necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :global&#xA;:help :normal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Using &lt;code&gt;:s&lt;/code&gt; and &lt;code&gt;:g&lt;/code&gt; to Unminify CSS&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I'm a little unclear on &lt;em&gt;precisely&lt;/em&gt; what you're trying to achieve, but if the goal is to e.g. turn this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;margin:0;padding:0;font-family:verdana;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    margin:0;&#xA;    padding:0;&#xA;    font-family:verdana;&#xA;&#xA;^^^^ &amp;lt;- one level of indent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd do so with the following two commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/;/;\r/g&#xA;:g/;/normal &amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If, for some reason, you need to add a specific number of spaces that doesn't match your shiftwidth settings, you could instead do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/;/;\r/g&#xA;:g/;/normal i    &#xA;             ^^^^ &amp;lt;- type four spaces after the `i`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Macros&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In practice, for the specific case mentioned above, I'd probably have used a recursive macro:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qqq&lt;/code&gt;: Clear out the &lt;code&gt;q&lt;/code&gt; register. Necessary for recursive macros,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt;: Start recording in the &lt;code&gt;q&lt;/code&gt; register,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/;[^$]&amp;lt;cr&amp;gt;&lt;/code&gt;: Find the first semi-colon not followed by a newline,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:left&amp;lt;cr&amp;gt;&lt;/code&gt;: Remove any existing indentation (to remove automatic indentation),&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;: Add one level of indent,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;na&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;&lt;/code&gt;: Jump back to the semi-colon,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@q&lt;/code&gt;: Recurse,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: Finish recording,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@q&lt;/code&gt;: Run the macro.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could also record a macro that runs on a single line and then apply it to every line with the global command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqqqq:left&amp;lt;cr&amp;gt;&amp;gt;&amp;gt;f;a&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;@qq@q&#xA;:g/;/norm @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The macro versions &lt;em&gt;look&lt;/em&gt; complicated written down, but because they just use normal editing commands recording them comes naturally (with a bit of practice) and using them is a lot faster than it looks.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-01-10T13:42:39.717" LastActivityDate="2017-01-10T13:42:39.717" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10724" PostTypeId="1" CreationDate="2016-12-23T15:39:33.127" Score="7" ViewCount="1108" Body="&lt;p&gt;I'm running ArchLinux using the xfce4 terminal with vim-latex. Using this setup, I tried to follow the instructions &lt;a href=&quot;https://web.archive.org/web/20150926153104/https://b4winckler.wordpress.com/2010/08/07/using-the-conceal-vim-feature-with-latex/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; to conceal latex commands with unicode. However, after much effort, I still cannot get any concealing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed all the directions from above, namely put&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cole=2&#xA;let g:tex_conceal=&quot;adgm&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;~/.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there is no difference even when I try type &lt;code&gt;:set cole=2&lt;/code&gt; manually in vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first, I thought it might be because xfce4-terminal is having trouble with utf-8, but I then tried to edit .tex files in rxvt-unicode which definitely supports utf-8. Still, there wasn't any change. I also checked that indeed my vim is compiled with the &lt;code&gt;+conceal&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something that I'm doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="10602" LastEditorUserId="343" LastEditDate="2020-02-03T14:56:07.810" LastActivityDate="2020-02-03T14:56:07.810" Title="Unable to Enable Vim Conceal" Tags="|vimrc|plugin-vim-latex|" AnswerCount="0" CommentCount="3" FavoriteCount="0" ClosedDate="2020-02-05T18:50:03.320" ContentLicense="CC BY-SA 4.0" />
  <row Id="10725" PostTypeId="1" AcceptedAnswerId="10727" CreationDate="2016-12-23T18:26:01.360" Score="7" ViewCount="462" Body="&lt;p&gt;We can execute bash command from vim like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! shuf -i1-123124 -n1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which generates random number in the given range. Is there a way to append the output to vim buffer?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2017-02-09T21:07:12.073" Title="Append bash output to vim buffer" Tags="|normal-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10726" PostTypeId="2" ParentId="10725" CreationDate="2016-12-23T18:33:28.893" Score="8" Body="&lt;p&gt;You can use filtering through an external program.&#xA;That's not the same as appending though.&#xA;In the simplest case, you could replace the current line with the output of &lt;code&gt;shuf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in normal mode, type &lt;code&gt;!!&lt;/code&gt;, and then &lt;code&gt;shuf -i1-123124 -n1&lt;/code&gt;. That will replace the current line with the output of &lt;code&gt;shuf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could replace a specific line with the output of &lt;code&gt;shuf&lt;/code&gt; with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:123!shuf -i1-123124 -n1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where 123 is the line you want to replace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details and similar operations, see &lt;code&gt;:help !!&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="135" LastActivityDate="2016-12-23T18:33:28.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10727" PostTypeId="2" ParentId="10725" CreationDate="2016-12-23T18:39:01.627" Score="9" Body="&lt;p&gt;&lt;code&gt;:read ! shuf -i1-123124 -n1&lt;/code&gt; &#xA;Appending read before the command outputs it to the current buffer &lt;/p&gt;&#xA;" OwnerUserId="9004" LastActivityDate="2016-12-23T18:39:01.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10728" PostTypeId="1" AcceptedAnswerId="10729" CreationDate="2016-12-23T18:56:43.323" Score="11" ViewCount="6045" Body="&lt;p&gt;We can make from two lines a single with &lt;code&gt;J&lt;/code&gt;. It looks as the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 1&#xA;line 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after &lt;code&gt;J&lt;/code&gt; pressed on line 1 we've got this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 1 line 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But is there a combination which what do the opposite (not &lt;code&gt;u&lt;/code&gt;)? I mean to split &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 1 line 2&#xA;      ^&#xA;   cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 1&#xA;line 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;i&amp;lt;ENTER&amp;gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; is too messy. Is there a one button shortcut for this in vim already?&lt;/p&gt;&#xA;" OwnerUserId="9417" LastEditorUserId="205" LastEditDate="2016-12-24T06:16:27.103" LastActivityDate="2020-06-15T16:50:30.667" Title="Splitting a line into two" Tags="|normal-mode|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10729" PostTypeId="2" ParentId="10728" CreationDate="2016-12-23T19:06:32.167" Score="7" Body="&lt;p&gt;As far as I know, vim doesn't have a command for this. But vim is also all about customization. Easy enough to make your own mapping!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap s i&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2016-12-23T19:06:32.167" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10731" PostTypeId="2" ParentId="10728" CreationDate="2016-12-23T20:32:14.530" Score="31" Body="&lt;p&gt;For your specific case, when you have a space, that you also like to get rid of, I usually use &lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-12-23T20:32:14.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10732" PostTypeId="1" AcceptedAnswerId="10741" CreationDate="2016-12-23T22:13:53.450" Score="2" ViewCount="1612" Body="&lt;p&gt;How can I reliably print a message and pause during processing of .vimrc?  I'm using vim 7.4 (not gvim) on Linux Mint.  The input() function behaves erratically as shown below.  The redraw function doesn't seem to help.  I'd like to print a message and wait for the user to press a key to proceed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any tips?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, with my .vimrc set to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;redraw!&#xA;echo &quot;xa&quot;&#xA;redraw!&#xA;call input(&quot;y123456&quot;)&#xA;redraw!&#xA;echo &quot;xb&quot;&#xA;redraw!&#xA;call input(&quot;z123456&quot;)&#xA;redraw!&#xA;echo &quot;xc&quot;&#xA;redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;code&gt;vim -u .vimrc --noplugin no-such-file&lt;/code&gt;, I see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;xay123456&lt;/code&gt;, on the bottom line (~ on the other lines), with cursor on the digit 5&lt;/li&gt;&#xA;&lt;li&gt;press ENTER&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;xbz123456&lt;/code&gt;,  with cursor about 6 or 7 characters after the digit 6&lt;/li&gt;&#xA;&lt;li&gt;press ENTER&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;xcPress ENTER or type command to continue&lt;/code&gt;, with cursor immediately after &quot;continue&quot;&lt;/li&gt;&#xA;&lt;li&gt;press ENTER&lt;/li&gt;&#xA;&lt;li&gt;`&quot;no-such-file&quot; [New File]&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;with &lt;code&gt;vim -u .vimrc --noplugin&lt;/code&gt; I see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;screen 2/3 full of ~ down the left side, with &lt;code&gt;y123456&lt;/code&gt; towards the right side, about 15 lines above the bottom line, with cursor on the (empty) bottom line about 8 characters from the left&lt;/li&gt;&#xA;&lt;li&gt;press ENTER&lt;/li&gt;&#xA;&lt;li&gt;screen unchanged except for bottom line now says &lt;code&gt;xbz123456&lt;/code&gt; with cursor about 6 characters to the right of the digit 6&lt;/li&gt;&#xA;&lt;li&gt;press ENTER&lt;/li&gt;&#xA;&lt;li&gt;last line now says &lt;code&gt;xcPress ENTER or type command to continue&lt;/code&gt; with cursor just after &lt;code&gt;continue&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;press ENTER&lt;/li&gt;&#xA;&lt;li&gt;normal screen with nothing on the bottom line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9490" LastEditorUserId="9490" LastEditDate="2016-12-24T15:50:06.740" LastActivityDate="2016-12-25T16:42:52.920" Title="How to pause (with message) during .vimrc startup?" Tags="|vimrc|linux|startup|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10733" PostTypeId="1" AcceptedAnswerId="10740" CreationDate="2016-12-24T08:06:14.903" Score="4" ViewCount="267" Body="&lt;p&gt;I've installed macvim on OSX 10.11.6 using &lt;code&gt;brew install macvim --with-override-system-vim&lt;/code&gt;. This worked fine. I now have some new aliases/symlinks (I'm not too familiar with the differences):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.&#xA;#in usr/local/bin&#xA;vim -&amp;gt; ../Cellar/macvim/8.0-119_1/bin/vim&#xA;mvim -&amp;gt; ../Cellar/macvim/8.0-119_1/bin/mvim&#xA;.&#xA;#in usr/local/Cellar/macvim/8.0-119_1/bin/&#xA;vim -&amp;gt; mvim&#xA;mvim                                            #executable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim&lt;/code&gt; opens vim in the terminal window (the updated version of vim, not OSX's). &lt;code&gt;mvim&lt;/code&gt; opens macvim with its own window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If vim is an alias for mvim, how does the machine know to run plain old vim when I type &lt;code&gt;vim&lt;/code&gt;? Is it changing my command to &lt;code&gt;mvim -v&lt;/code&gt; behind the scenes? If so, is this &lt;code&gt;-v&lt;/code&gt; in the alias/symlink somewhere?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any insight you all have be would be great. &lt;/p&gt;&#xA;" OwnerUserId="10609" LastActivityDate="2016-12-24T13:15:49.780" Title="When using macvim with symlinks, is opening vim just calling mvim -v?" Tags="|macvim|macos|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10734" PostTypeId="2" ParentId="10675" CreationDate="2016-12-24T08:30:10.870" Score="1" Body="&lt;p&gt;The following approach is ~3 keystrokes longer than @nobe4's solution, but it answers the question in the title&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How to move word under current cursor to begin at current cursor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;more generally: It doesn't depend on another line to yank the whitespace from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;h&#xA;&lt;/kbd&gt;&#xA;                                         Move one char to the left.  &lt;strong&gt;Skip this step if you have &lt;code&gt;:set selection=exclusive&lt;/code&gt;; &lt;code&gt;:behave mswin&lt;/code&gt; in &lt;code&gt;mswin.vim&lt;/code&gt; does this.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;v&#xA;&lt;/kbd&gt;&#xA;&lt;kbd&gt;&#xA;b&#xA;&lt;/kbd&gt;&#xA;             'Take measure' of the distance you want to shift your text with spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;y&#xA;&lt;/kbd&gt;&#xA;&lt;kbd&gt;&#xA;P&#xA;&lt;/kbd&gt;&#xA;             Duplicate that area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;g&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;v&#xA;&lt;/kbd&gt;&#xA;                  (Re-)select the duplicate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#v_r&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;kbd&gt;&#xA;r&#xA;&lt;/kbd&gt;&#xA;                                           Replace all selected characters by char…&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;Space&#xA;&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&#xA;(You cannot shorten the   &lt;kbd&gt;&#xA;v&#xA;&lt;/kbd&gt; &lt;em&gt;‹measurement movement›&lt;/em&gt;  &lt;kbd&gt;&#xA;y&#xA;&lt;/kbd&gt;  part   to   &lt;kbd&gt;&#xA;y&#xA;&lt;/kbd&gt;&lt;em&gt;‹measurement motion›&lt;/em&gt;   because you need the prior selection for re-selecting it afterwards.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's a different example where you can apply the above introduced pattern&lt;br&gt;&#xA;&lt;kbd&gt;&#xA;v&#xA;&lt;/kbd&gt; &#xA;&lt;em&gt;‹measurement movement›&lt;/em&gt;&#xA;&lt;kbd&gt;&#xA;y&#xA;&lt;/kbd&gt; &lt;kbd&gt;&#xA;P&#xA;&lt;/kbd&gt; &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; &lt;kbd&gt;&#xA;r&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;Space&#xA;&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you've got&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ↓ Normal mode command(s) go here&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;A-b&amp;gt; &amp;amp;cedit. 'b' .'&amp;lt;C-c&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you want to align the &lt;code&gt;↓&lt;/code&gt; over the &lt;code&gt;b&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;                              ↓ Normal mode command(s) go here&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;A-b&amp;gt; &amp;amp;cedit. 'b' .'&amp;lt;C-c&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Steps:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, move the cursor below the &lt;code&gt;↓&lt;/code&gt; (on the &lt;code&gt;o&lt;/code&gt;).  Then:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;v&#xA;&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;2&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;t&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;&lt;code&gt;b&lt;/code&gt;&#xA;&lt;/kbd&gt;&#xA;or &#xA;&lt;kbd&gt;&#xA;f&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;&lt;code&gt;'&lt;/code&gt;&#xA;&lt;/kbd&gt;&#xA;                                            'Measure' the shifting distance by selecting the area to shift over.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;y&#xA;&lt;/kbd&gt; &lt;kbd&gt;&#xA;P&#xA;&lt;/kbd&gt; &lt;kbd&gt;&#xA;g&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;v&#xA;&lt;/kbd&gt; &lt;kbd&gt;&#xA;r&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;Space&#xA;&lt;/kbd&gt;&#xA;                      Duplicate this area, then whiten the duplicate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;g&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;v&#xA;&lt;/kbd&gt;&#xA;                                                                                                                                                        Re-select the whitened area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;d&#xA;&lt;/kbd&gt; &lt;kbd&gt;&#xA;k&#xA;&lt;/kbd&gt; &lt;kbd&gt;&#xA;P&#xA;&lt;/kbd&gt;&#xA;                                                                                                                       Move it where you need it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;&#xA;(&lt;br&gt;&#xA;In the case of this example, you could save &lt;br&gt;&#xA;first moving into the lower line to take measure there and finally moving the whitespace  &lt;br&gt;&#xA;by taking measure 'by eye' directly on the upper line, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;^&#xA;&lt;/kbd&gt; &lt;kbd&gt;&#xA;w&#xA;&lt;/kbd&gt;&#xA;                                                                                                                                                 Move to the start of the text you want to shift.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;v&#xA;&lt;/kbd&gt;&#xA;                                                                                                                                                                             Select…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;2&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;t&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;&lt;code&gt;e&lt;/code&gt;&#xA;&lt;/kbd&gt; or &lt;kbd&gt;&#xA;f&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;&lt;code&gt;h&lt;/code&gt;&#xA;&lt;/kbd&gt;&#xA;                                          …till before the char  till (before) which you want to shift.  That's the one above the &lt;code&gt;b&lt;/code&gt; (which is the line's second &lt;code&gt;e&lt;/code&gt;.  (Before that  is the line's first &lt;code&gt;h&lt;/code&gt;.))&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&#xA;y&#xA;&lt;/kbd&gt; &lt;kbd&gt;&#xA;P&#xA;&lt;/kbd&gt; &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; &lt;kbd&gt;&#xA;r&#xA;&lt;/kbd&gt;&lt;kbd&gt;&#xA;Space&#xA;&lt;/kbd&gt;&#xA;                      &lt;sub&gt;(As usual: Duplicate and whiten the selected text area.)&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2314" LastEditorUserId="2314" LastEditDate="2016-12-26T07:48:20.657" LastActivityDate="2016-12-26T07:48:20.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10737" PostTypeId="5" CreationDate="2016-12-24T09:20:12.150" Score="0" Body="&lt;p&gt;Related: &lt;a href=&quot;/questions/tagged/repeated-commands&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;repeated-commands&amp;#39;&quot; rel=&quot;tag&quot;&gt;repeated-commands&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Questions where  (potentially) working on multiple lines  is not a &lt;em&gt;relevant&lt;/em&gt; aspect  should not be tagged &lt;a href=&quot;/questions/tagged/multiple-lines&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;multiple-lines&amp;#39;&quot; rel=&quot;tag&quot;&gt;multiple-lines&lt;/a&gt;, even if they relate to line multiplicity in some way.  An example would be  counting the number of occurrences of a word in a file:  In this case it doesn't matter whether the file has one or multiple lines.&lt;/p&gt;&#xA;" OwnerUserId="2314" LastEditorUserId="2314" LastEditDate="2016-12-24T18:03:17.540" LastActivityDate="2016-12-24T18:03:17.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10738" PostTypeId="4" CreationDate="2016-12-24T09:20:12.150" Score="0" Body="Questions where working on more than one line is a relevant aspect.  In most cases that means repeating the same command(s) over several lines. – Related: the [repeated-commands] tag" OwnerUserId="2314" LastEditorUserId="11357" LastEditDate="2020-01-03T08:24:43.957" LastActivityDate="2020-01-03T08:24:43.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10739" PostTypeId="2" ParentId="3514" CreationDate="2016-12-24T11:33:36.177" Score="1" Body="&lt;p&gt;I haven't tried it for your situation, but likely you're looking for 'doautocmd'. Here's the relevant info from :h doauto&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;                    *:do* *:doau* *:doautocmd* *E217*&#xA;:do[autocmd] [group] {event} [fname]&#xA;            Apply the autocommands matching [fname] (default:&#xA;            current file name) for {event} to the current buffer.&#xA;            You can use this when the current file name does not&#xA;            match the right pattern, after changing settings, or&#xA;            to execute autocommands for a certain event.&#xA;            It's possible to use this inside an autocommand too,&#xA;            so you can base the autocommands for one extension on&#xA;            another extension.  Example:&#xA;                :au Bufenter *.cpp so ~/.vimrc_cpp&#xA;                :au Bufenter *.cpp doau BufEnter x.c&#xA;            Be careful to avoid endless loops.  See&#xA;            |autocmd-nested|.&#xA;&#xA;            When the [group] argument is not given, Vim executes&#xA;            the autocommands for all groups.  When the [group]&#xA;            argument is included, Vim executes only the matching&#xA;            autocommands for that group.  Note: if you use an&#xA;            undefined group name, Vim gives you an error message.&#xA;&#xA;            After applying the autocommands the modelines are&#xA;            processed, so that their settings overrule the&#xA;            settings from autocommands, like what happens when&#xA;            editing a file.&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="10612" LastActivityDate="2016-12-24T11:33:36.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10740" PostTypeId="2" ParentId="10733" CreationDate="2016-12-24T12:10:08.790" Score="3" Body="&lt;p&gt;&lt;code&gt;mvim&lt;/code&gt; is a shell script which uses the name it's run as to decide what to do:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;# Next, peek at the name used to invoke this script, and set options&#xA;# accordingly.&#xA;&#xA;name=&quot;`basename &quot;$0&quot;`&quot;&#xA;gui=&#xA;opts=&#xA;&#xA;# GUI mode, implies forking&#xA;case &quot;$name&quot; in m*|g*|rm*|rg*) gui=true ;; esac&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not uncommon. Vim itself reacts differently on whether it is invoked as &lt;code&gt;vim&lt;/code&gt;, &lt;code&gt;vi&lt;/code&gt;, &lt;code&gt;vimdiff&lt;/code&gt;, &lt;code&gt;gvim&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, running &lt;code&gt;mvim&lt;/code&gt; as &lt;code&gt;vim&lt;/code&gt; just runs &lt;code&gt;&quot;$VIM_APP_DIR/MacVim.app/Contents/MacOS/Vim&quot;&lt;/code&gt; as it is, whereas running as &lt;code&gt;mvim&lt;/code&gt; runs &lt;code&gt;&quot;$VIM_APP_DIR/MacVim.app/Contents/MacOS/Vim&quot; -g&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/q/315812/70524&quot;&gt;Why does argv include the program name?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2016-12-24T13:15:49.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10741" PostTypeId="2" ParentId="10732" CreationDate="2016-12-25T02:18:32.030" Score="2" Body="&lt;h3&gt;Problem description&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You're trying something that Vim was not really meant to do.  Although your VimScript does work, I've modified it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;redraw!&#xA;echo &quot;xa&quot;&#xA;redraw!&#xA;let i1 = input(&quot;y123456&quot;)&#xA;redraw!&#xA;echo &quot;xb&quot;&#xA;redraw!&#xA;let i2 = input(&quot;z123456&quot;)&#xA;redraw!&#xA;echo &quot;xc&quot;&#xA;redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And checked that &lt;code&gt;i1&lt;/code&gt; and &lt;code&gt;i2&lt;/code&gt; variables are correctly setup.  For this purpose I've run Vim as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -u the_above_vimrc_file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On &lt;code&gt;urvxt&lt;/code&gt; and on &lt;code&gt;xterm&lt;/code&gt;.  And the behaviour on both terminals is considerably different.  Using the GUI is even a worse idea since &lt;code&gt;:h input&lt;/code&gt; has:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NOTE: This function must not be used in a startup file, for&#xA;the versions that only run in GUI mode (e.g., the Win32 GUI).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You probably can get the right terminfo configuration to make Vim work like a prompt program on startup, but even then, it is unlikely to be portable across different terminal emulators.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Correct approach&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You should not really try to pause during Vim startup.  Even if you would like to select between different environments it can be better done with a shell (or even bat) script.  And moreover, pausing during the startup would annoy anyone trying to use the editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you should really use &lt;code&gt;:echom&lt;/code&gt; to output messages during startup, and then use &lt;code&gt;:messages&lt;/code&gt; to check what happened during the startup.  It does not only allow you to check the messages several times (until you clear them), but logs together your debug messages with error messages from Vim in chronological order (which is very useful for debugging).&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2016-12-25T16:42:52.920" LastActivityDate="2016-12-25T16:42:52.920" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10742" PostTypeId="1" AcceptedAnswerId="10760" CreationDate="2016-12-25T03:52:47.830" Score="1" ViewCount="262" Body="&lt;pre&gt;&lt;code&gt;colorscheme leya&#xA;set background=light&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;whole &lt;code&gt;.vimrc&lt;/code&gt; &#xA;&lt;a href=&quot;https://gist.github.com/francium/e29aa1600abd158fe08b34218e1f3bd6&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gist.github.com/francium/e29aa1600abd158fe08b34218e1f3bd6&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only happens when you scroll down using &lt;code&gt;j&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tried it with another light theme, wikipedia -- Same issue&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Leya -- &lt;a href=&quot;https://github.com/marlun/vim-starwars&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/marlun/vim-starwars&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wikipedia -- &lt;a href=&quot;https://github.com/mtglsk/wikipedia.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/mtglsk/wikipedia.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Just tried without any .vimrc, same result.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Toggling NERDTree fixes the issue&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xXOLW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xXOLW.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10619" LastEditorUserId="10619" LastEditDate="2016-12-26T07:22:20.617" LastActivityDate="2016-12-26T22:29:14.053" Title="Light colorscheme issue causing black background when scrolling down using J" Tags="|colorscheme|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10743" PostTypeId="2" ParentId="10698" CreationDate="2016-12-25T04:44:01.633" Score="0" Body="&lt;p&gt;I figured out the problem. Turns out, it WAS because of spaces in filenames. My python setup is that I have a shell script in /system/bin which calls python from where it is in my system. This resulted in escape characters being stripped twice. I changed the python code to run python from its actual location on my box. Thanks for the direction, at least.&lt;/p&gt;&#xA;" OwnerUserId="10421" LastActivityDate="2016-12-25T04:44:01.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10744" PostTypeId="1" CreationDate="2016-12-25T08:11:01.567" Score="3" ViewCount="1192" Body="&lt;p&gt;I am writing python 3 code from within vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a function within my file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def seconds_to_text(seconds):&#xA;    return str(datetime.timedelta(seconds=seconds))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way for me to see what it outputs for certain input values from within vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I see what &lt;code&gt;seconds_to_text(30)&lt;/code&gt; would output without leaving vim?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="51" LastEditDate="2016-12-30T16:14:10.650" LastActivityDate="2017-01-01T23:47:05.277" Title="Test python function from within editor" Tags="|ide|filetype-python|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10746" PostTypeId="2" ParentId="10744" CreationDate="2016-12-25T11:09:42.977" Score="0" Body="&lt;p&gt;I'm not sure if this is the intended solution, because you technically don't leave vim, ie you are still in the vim window, but you use a shell command to run the script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a sample python3 script I created&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def b(a):&#xA;  return str(a)&#xA;&#xA;print(b(123))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This creates a function that returns the string representation of the parameter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I save the file using &lt;code&gt;:w&lt;/code&gt; and then run the script by calling executing a terminal command &lt;code&gt;:!python3 file_name.py&lt;/code&gt; and this outputs &lt;code&gt;123&lt;/code&gt;. So this is a way you can call a Python function. Sure, you can replace the &lt;code&gt;b(a)&lt;/code&gt; function with your own function &lt;code&gt;seconds_to_text(seconds)&lt;/code&gt; and do the same process.&lt;/p&gt;&#xA;" OwnerUserId="10378" LastEditorUserId="10378" LastEditDate="2016-12-25T11:21:07.020" LastActivityDate="2016-12-25T11:21:07.020" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10747" PostTypeId="1" AcceptedAnswerId="10749" CreationDate="2016-12-25T12:06:16.683" Score="0" ViewCount="299" Body="&lt;p&gt;When loading a session file from another machine I&#xA;get errors of the form&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E518: Unknown option: balloonexpr=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is one of the more obscure features of Vim that I&#xA;don’t seem to have compiled in. However, grepping the&#xA;output of Vim’s &lt;code&gt;configure&lt;/code&gt; script doesn’t show any&#xA;directly related compile flag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does one have to do to enable the &lt;code&gt;balloonexpr&lt;/code&gt;&#xA;option? This is on Vim version &lt;em&gt;patch 8.0.0134&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10621" LastEditorUserId="51" LastEditDate="2016-12-31T03:35:13.373" LastActivityDate="2016-12-31T03:35:13.373" Title="Which compile flag enables “balloonexpr”?" Tags="|installing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10748" PostTypeId="2" ParentId="10539" CreationDate="2016-12-25T12:37:53.710" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;:find foo bar.txt &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This command will search for &lt;strong&gt;2&lt;/strong&gt; files at once which is not possible in vim. &#xA;This is the cause of your error. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When dealing with files that have space in them,&#xA;you can &lt;strong&gt;append &lt;code&gt;\&lt;/code&gt;&lt;/strong&gt; after every word &lt;/p&gt;&#xA;&#xA;&lt;p&gt;like so &lt;code&gt;:find foo\ bar.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this method is a bit awkward since you have a lot of files &lt;/p&gt;&#xA;&#xA;&lt;p&gt;so I have modified a command to suit your needs &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it works&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add it to your .vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and use &lt;code&gt;:Find&lt;/code&gt; to search and open files with spaces &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; :Find will escape a file name and open it&#xA;command! -bang -nargs=* Find :call Find(&amp;lt;q-bang&amp;gt;, &amp;lt;q-args&amp;gt;) &#xA;function! Find(bang, filename) &#xA;    :exe &quot;find&quot;.a:bang.&quot; &quot;. fnameescape(a:filename) &#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Not related to the asked question but might be of some help&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem is also faced when saving files with space in them &lt;/p&gt;&#xA;&#xA;&lt;p&gt;like &lt;code&gt;:w foo bar.txt&lt;/code&gt; gives error&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve that &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; :W and :Save will escape a file name and write it&#xA;command! -bang -nargs=* W :call W(&amp;lt;q-bang&amp;gt;, &amp;lt;q-args&amp;gt;) &#xA;command! -bang -nargs=* Save :call Save(&amp;lt;q-bang&amp;gt;, &amp;lt;q-args&amp;gt;)&#xA;&#xA;function! W(bang, filename) &#xA;    :exe &quot;w&quot;.a:bang.&quot; &quot;. fnameescape(a:filename) &#xA;endfu&#xA;&#xA;function! Save(bang, filename) &#xA;    :exe &quot;save&quot;.a:bang.&quot; &quot;. fnameescape(a:filename) &#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add this to .vimrc to use &lt;code&gt;:W&lt;/code&gt; or &lt;code&gt;:Save&lt;/code&gt; for saving files with spaces. &lt;/p&gt;&#xA;" OwnerUserId="9004" LastEditorUserId="9004" LastEditDate="2016-12-25T18:47:12.400" LastActivityDate="2016-12-25T18:47:12.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10749" PostTypeId="2" ParentId="10747" CreationDate="2016-12-25T20:17:17.270" Score="2" Body="&lt;p&gt;That feature is shown by the 'balloon-eval' flag in the &lt;code&gt;:version&lt;/code&gt; output. See &lt;code&gt;:h +feature-list&lt;/code&gt; for the description of all flags and specifically &lt;code&gt;:h balloon-eval&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to feature.h it is enabled for the following conditions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #if (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \&#xA;          || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32)) \&#xA;          &amp;amp;&amp;amp; (   ((defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE)) \&#xA;                  &amp;amp;&amp;amp; !defined(FEAT_GUI_GTK) &amp;amp;&amp;amp; !defined(FEAT_GUI_W32)) \&#xA;              || defined(FEAT_SUN_WORKSHOP) \&#xA;              || defined(FEAT_NETBEANS_INTG) || defined(FEAT_EVAL))&#xA;  # define FEAT_BEVAL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i.e. basically when you use a supported Gui + the eval feature. &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2016-12-25T20:17:17.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10750" PostTypeId="1" AcceptedAnswerId="10765" CreationDate="2016-12-25T20:48:35.353" Score="1" ViewCount="2364" Body="&lt;p&gt;Gvim is odd and ugly. It provides only a minimal GUI wrapper for Vim. Like has been done for Neovim, has anyone made an nicer alternative GUI front-end for Vim? &lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-12-26T12:26:46.190" LastActivityDate="2016-12-28T02:53:40.473" Title="Are there alternatives to Gvim for a GUI for Vim?" Tags="|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10751" PostTypeId="1" CreationDate="2016-12-26T04:37:13.587" Score="2" ViewCount="89" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BVpVp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BVpVp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use arrow keys, I will get the text in the above picture.&lt;/p&gt;&#xA;" OwnerUserId="2573" LastEditorUserId="205" LastEditDate="2016-12-26T06:10:48.203" LastActivityDate="2016-12-26T06:10:48.203" Title="How should I move the cursor when running shell by using :sh?" Tags="|macvim|bash|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10752" PostTypeId="2" ParentId="10751" CreationDate="2016-12-26T06:10:41.617" Score="3" Body="&lt;p&gt;Looks like you're using Macvim/GVim. GVim isn't a full terminal emulator, so don't expect everything to work. You can't use arrows, but you can &lt;kbd&gt;Delete&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2016-12-26T06:10:41.617" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10753" PostTypeId="1" AcceptedAnswerId="10975" CreationDate="2016-12-26T11:08:12.643" Score="7" ViewCount="922" Body="&lt;p&gt;I'm running Vim 8.0 on a Windows 7 system and I'm having this issue whenever I open gvim (the one that runs in a window as opposed to running in &lt;code&gt;cmd&lt;/code&gt;) the default path in &lt;code&gt;:pwd&lt;/code&gt; is &lt;code&gt;c:\users\&quot;user&quot;&lt;/code&gt;. If I use the &lt;code&gt;:Explore&lt;/code&gt; command it brings up the file explorer showing all the files in there but I can only go up in file paths up to &lt;code&gt;c:\users&lt;/code&gt; and that's it, I can't go any upper than that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More than that if I use the &lt;code&gt;:cd&lt;/code&gt; command to go to a different drive (&lt;code&gt;d:&lt;/code&gt;), it does change the directory successfully and it does show it if i use &lt;code&gt;:pwd&lt;/code&gt;. But if I use &lt;code&gt;:Explore&lt;/code&gt;, it doesn't show anything, instead it just does a split screen of the same file containing the same text i have in the initial file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, if I create an &lt;code&gt;asdasd.txt&lt;/code&gt; file in &lt;code&gt;d:\&lt;/code&gt; and open it with Vim and then use &lt;code&gt;:Explore&lt;/code&gt;, again it does nothing, just goes back to the same line of text I was on in command mode, almost as if the program is looking for access to that directory or cancelling the command because of something like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I used Vim 7.4 before this and the commands mentioned worked as expected. Any ideas what the problem might be? Does it need any special configuration?&lt;/p&gt;&#xA;" OwnerUserId="10628" LastEditorUserId="205" LastEditDate="2016-12-27T09:18:45.260" LastActivityDate="2017-01-13T19:34:30.743" Title="vim 8.0 file explorer only allows specific locations" Tags="|gvim|microsoft-windows|netrw|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10754" PostTypeId="1" AcceptedAnswerId="10758" CreationDate="2016-12-26T11:58:03.527" Score="2" ViewCount="262" Body="&lt;p&gt;Now, I am starting to use vim to edit &quot;normal text&quot;, that is, other than programming code. &#xA;Thus, a &quot;line&quot; is really a paragraph, and is usually &quot;long&quot;. &#xA;In the very end of the current GUI window, there are some more space, but if it is shorter than the next line, that is not shown and space is wasted. &#xA;This effectively makes my window (already being split) quite small. &#xA;In such case, how to make vim to split the next line, partly shown in the current window, leaving the rest displayed in next window, so that I see the latter half when I press &lt;code&gt;ctrl-F&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shown is a part of an essay I wrote in Chinese, with screenshot cropped at the lower half of the GUI window. &#xA;As you can see, there is plenty of space between line 14 and the display of current filename, but line 15 is too long to be fit in such space. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bet someone has asked this, but I don't know the name of this action, nor the keyword to find this information. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3MVeB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3MVeB.png&quot; alt=&quot;still plenty space&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10241" LastActivityDate="2016-12-31T03:30:34.613" Title="To split long paragraph to next window" Tags="|vim-windows|navigation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10755" PostTypeId="1" AcceptedAnswerId="10759" CreationDate="2016-12-26T14:59:44.113" Score="5" ViewCount="229" Body="&lt;p&gt;When I scroll a whole page up by &lt;code&gt;ctrl-f&lt;/code&gt;, and down by &lt;code&gt;ctrl-b&lt;/code&gt;, vim reserves 2 lines, and repeats them both in the previous GUI window and the present one. &#xA;But I expect it not to repeat lines, because now that the &quot;turning&quot; of pages is not a really &quot;turning&quot; but with a small shift, this makes me harder to visualize the new position which it is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is to say, if line 1 to line 30 is shown in present window, and to simplify matters suppose none is wrapped, then when I press &lt;code&gt;ctrl-f&lt;/code&gt;, the subsequent GUI window will display line 29 to 58. &#xA;But I want it to show line 31 to 60, and so on. What should I set in &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10241" LastActivityDate="2016-12-27T02:10:07.010" Title="To pageup and pagedown without reserved lines" Tags="|scrolling|navigation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10756" PostTypeId="1" CreationDate="2016-12-26T17:06:14.753" Score="6" ViewCount="418" Body="&lt;p&gt;If we load the built-in &lt;code&gt;man.vim&lt;/code&gt; filetype plugin by writing in our &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime ftplugin/man.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We can read a man page inside a Vim buffer, using the &lt;code&gt;:Man&lt;/code&gt; command described in &lt;code&gt;:h :Man&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MAN                 *ft-man-plugin* *:Man* *man.vim*&#xA;&#xA;Displays a manual page in a nice way.  Also see the user manual&#xA;|find-manpage|.&#xA;&#xA;To start using the &quot;:Man&quot; command before any manual page was loaded, source&#xA;this script from your startup vimrc file: &amp;gt;&#xA;&#xA;    runtime ftplugin/man.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, similar to this &lt;a href=&quot;https://vi.stackexchange.com/questions/7944/jump-to-next-identifier-in-vim-help-files&quot;&gt;question&lt;/a&gt;, when reading a man page, is there a way to move the cursor to the description of the next option, reference and section?&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-06-21T08:31:50.213" Title="How to move the cursor to the next reference, option, heading in man pages?" Tags="|key-bindings|vimscript|search|cursor-movement|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10758" PostTypeId="2" ParentId="10754" CreationDate="2016-12-26T17:42:46.983" Score="3" Body="&lt;p&gt;I found myself that it is &lt;code&gt;:set display=lastline&lt;/code&gt; (where &lt;code&gt;@@@&lt;/code&gt; at the end of the last line indicates that line is unfinished), or &lt;code&gt;:set display=truncate&lt;/code&gt; (where &lt;code&gt;@@@&lt;/code&gt;, starting on a new line, displayed as the last line, indicates the same). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To quote &lt;code&gt;:help 'display'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'display' 'dy'      string   (default &quot;&quot;, set to &quot;truncate&quot; in&#xA;                            |defaults.vim|)&#xA;         global&#xA;         {not in Vi}&#xA;   Change the way text is displayed.  This is comma separated list of&#xA;   flags:&#xA;   lastline   When included, as much as possible of the last line&#xA;         in a window will be displayed.  &quot;@@@&quot; is put in the&#xA;         last columns of the last screen line to indicate the&#xA;         rest of the line is not displayed.&#xA;   truncate   Like &quot;lastline&quot;, but &quot;@@@&quot; is displayed in the first&#xA;         column of the last screen line.  Overrules &quot;lastline&quot;.&#xA;   uhex      Show unprintable characters hexadecimal as &amp;lt;xx&amp;gt;&#xA;         instead of using ^C and ~C.&#xA;&#xA;   When neither &quot;lastline&quot; nor &quot;truncate&quot; is included, a last line that&#xA;   doesn't fit is replaced with &quot;@&quot; lines.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I add this line shown and wrote a function, in order to toggle, using &lt;code&gt;ctrl-d&lt;/code&gt;, between &lt;code&gt;display=truncate&lt;/code&gt; (when I am writing prose and dealing with long lines) &lt;code&gt;display=&lt;/code&gt; (when I am writing anything consisting of short lines, such as code). &#xA;In &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Display, as much as possible, the next line not able to be fully shown&#xA;set display=&#xA;noremap &amp;lt;leader&amp;gt;d :call DisplayLastLine()&amp;lt;CR&amp;gt;&#xA;&#xA;function! DisplayLastLine()&#xA;    if &amp;amp;display == ''&#xA;        let &amp;amp;display = 'truncate'&#xA;    else&#xA;        let &amp;amp;display = ''&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Quicker than all of you this time, maybe because Americans are sleeping.)&lt;/p&gt;&#xA;" OwnerUserId="10241" LastEditorUserId="51" LastEditDate="2016-12-31T03:30:34.613" LastActivityDate="2016-12-31T03:30:34.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10759" PostTypeId="2" ParentId="10755" CreationDate="2016-12-26T17:52:10.020" Score="3" Body="&lt;p&gt;It dawned on me that why do I not move page down and further scroll two lines, and same can be said on page up.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Scroll a page with no repeated lines,&#xA;&quot; while default shows two lines in both present and next window&#xA;nnoremap &amp;lt;C-f&amp;gt; &amp;lt;C-f&amp;gt;&amp;lt;C-e&amp;gt;&amp;lt;C-e&amp;gt;&#xA;nnoremap &amp;lt;C-b&amp;gt; &amp;lt;C-b&amp;gt;&amp;lt;C-y&amp;gt;&amp;lt;C-y&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am finding myself on the right track of being a vim master.&lt;/p&gt;&#xA;" OwnerUserId="10241" LastActivityDate="2016-12-26T17:52:10.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10760" PostTypeId="2" ParentId="10742" CreationDate="2016-12-26T22:29:14.053" Score="4" Body="&lt;p&gt;The following configuration fixed OP's issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_ut=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This says to Vim to use the current background's color to clear the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related answer: &lt;a href=&quot;https://stackoverflow.com/a/15095377/2558252&quot;&gt;https://stackoverflow.com/a/15095377/2558252&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2016-12-26T22:29:14.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10761" PostTypeId="1" AcceptedAnswerId="10762" CreationDate="2016-12-26T23:41:56.323" Score="12" ViewCount="1937" Body="&lt;p&gt;I frequently want to temporarily maximize a buffer in a tab page and then go back to the old buffer configuration that I was looking at. My current workflow for doing something like this is either to close all the other buffers using &lt;code&gt;&amp;lt;c-w&amp;gt;o&lt;/code&gt; or to move the buffer I am currently looking at to its own tab &lt;code&gt;&amp;lt;c-w&amp;gt;T&lt;/code&gt;. The problem with the second approach is that it removes the buffer from the original tab page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I populate three files &lt;code&gt;a.txt&lt;/code&gt;, &lt;code&gt;b.txt&lt;/code&gt;, and &lt;code&gt;c.txt&lt;/code&gt; with &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, and &lt;code&gt;c&lt;/code&gt; respectively.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% echo a &amp;gt; a.txt&#xA;% echo b &amp;gt; b.txt&#xA;% echo c &amp;gt; c.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open all three of these files in one tab page, I get the following. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dCVPE.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dCVPE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I can move &lt;code&gt;a.txt&lt;/code&gt; to a tab by itself. When I do, however, &lt;code&gt;a.txt&lt;/code&gt; is removed from the original tab page. (So this would be after a &lt;code&gt;&amp;lt;c-w&amp;gt;Tgt&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Xo4MC.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Xo4MC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like the ability to choose at the time that I would have pressed &lt;code&gt;&amp;lt;c-w&amp;gt;T&lt;/code&gt; to preserve the contents of the original buffer, create a new tab page containing only the buffer that is currently focused, and then focus the new tab page I've just created. In other words, a command almost exactly like &lt;code&gt;&amp;lt;c-w&amp;gt;T&lt;/code&gt; except that the original tab page is preserved and now &lt;code&gt;a.txt&lt;/code&gt; is in two tab pages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2017-09-02T06:55:27.370" LastActivityDate="2018-12-10T17:35:31.070" Title="Duplicate buffer into new tab instead of moving it" Tags="|tabbed-user-interface|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10762" PostTypeId="2" ParentId="10761" CreationDate="2016-12-26T23:55:52.263" Score="14" Body="&lt;p&gt;I'm not sure but you could try &lt;code&gt;:tab split&lt;/code&gt; (or the shorter version &lt;code&gt;:tab sp&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:split&lt;/code&gt; command should duplicate the viewport displaying &lt;code&gt;a.txt&lt;/code&gt;, while the &lt;code&gt;:tab&lt;/code&gt; modifier should move this viewport into a dedicated tab page.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to change the behavior of &lt;code&gt;C-w T&lt;/code&gt;, you could remap it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-w&amp;gt;T :tab split&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;More generally, every time you find a command which splits the window, and you would rather it creates a new tab page instead, you can prefix it with &lt;code&gt;:tab&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be used, for example, to read a help buffer in a new tab page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tab help {your_topic}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;By default, the new tab page will appear after the current one. But if you want to make it appear somewhere else, you can prefix &lt;code&gt;:tab&lt;/code&gt; with a count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to duplicate the current viewport in a tab page after the 3rd one, you could type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:3tab split&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And to make it appear as the first one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:0tab split&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, you can read &lt;code&gt;:h :tab&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[count]tab {cmd}                   *:tab*&#xA;        Execute {cmd} and when it opens a new window open a new tab&#xA;        page instead.  Doesn't work for |:diffsplit|, |:diffpatch|,&#xA;        |:execute| and |:normal|.&#xA;        If [count] is given the new tab page appears after the tab&#xA;        page [count] otherwise the new tab page will appear after the&#xA;        current one.&#xA;        Examples:&#xA;&#xA;            :tab split      &quot; opens current buffer in new tab page&#xA;            :tab help gt    &quot; opens tab page with help for &quot;gt&quot;&#xA;            :.tab help gt   &quot; as above&#xA;            :+tab help      &quot; opens tab page with help after the next&#xA;                            &quot; tab page&#xA;            :-tab help      &quot; opens tab page with help before the&#xA;                            &quot; current one&#xA;            :0tab help      &quot; opens tab page with help before the&#xA;                            &quot; first one&#xA;            :$tab help      &quot; opens tab page with help after the last&#xA;                            &quot; one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2016-12-27T01:16:39.970" LastActivityDate="2016-12-27T01:16:39.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10763" PostTypeId="2" ParentId="10755" CreationDate="2016-12-27T02:10:07.010" Score="4" Body="&lt;p&gt;I like to use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-f&amp;gt; z+&#xA;nnoremap &amp;lt;c-b&amp;gt; z^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2016-12-27T02:10:07.010" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10765" PostTypeId="2" ParentId="10750" CreationDate="2016-12-27T08:59:53.033" Score="4" Body="&lt;p&gt;No.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim and NeoVim don't share the same structure and Vim doesn't have the possibility to have a separate GUI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it is not necessarily ugly: it all depends on your configuration.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="205" LastEditDate="2016-12-28T02:53:40.473" LastActivityDate="2016-12-28T02:53:40.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10766" PostTypeId="1" CreationDate="2016-12-27T09:21:10.603" Score="3" ViewCount="1024" Body="&lt;p&gt;I am trying to write a vim function to toggle the &lt;code&gt;fzf&lt;/code&gt; window if it is already open using &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;fzf.vim&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use case is if I am in the &lt;code&gt;:Buffers&lt;/code&gt; view and I want to change to the &lt;code&gt;:Files&lt;/code&gt; view if I try to execute &lt;code&gt;:Files&lt;/code&gt; before closing &lt;code&gt;:Buffers&lt;/code&gt; then &lt;code&gt;fzf.vim&lt;/code&gt; complains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function FzfRunning()&#xA;    let buffers = filter(range(1, bufnr('$')), 'bufname(v:val) =~# &quot;;#FZF&quot;')&#xA;    for i in buffers&#xA;        &quot; Delete buffer by ID&#xA;        execute &quot;bw!&quot; . i&#xA;    endfor&#xA;endfunction&#xA;&#xA;command! -nargs=* ToggleFiles call FzfRunning| Files&#xA;command! -nargs=* ToggleBuffers call FzfRunning| Buffers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works except for the fact that the &lt;code&gt;fzf&lt;/code&gt; buffer loses focus. I would like it to focus the &lt;code&gt;fzf&lt;/code&gt; buffer when &lt;code&gt;ToggleFiles&lt;/code&gt; or &lt;code&gt;ToggleBuffers&lt;/code&gt; is called.&lt;/p&gt;&#xA;" OwnerUserId="7052" LastEditorUserId="51" LastEditDate="2017-01-01T23:53:29.560" LastActivityDate="2024-03-13T22:03:45.440" Title="Toggle fzf.vim if already open" Tags="|buffers|functions|plugin-fzf|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10767" PostTypeId="1" AcceptedAnswerId="10768" CreationDate="2016-12-27T09:36:47.207" Score="3" ViewCount="481" Body="&lt;p&gt;I'm using the Fugitive plugin. It has the &lt;code&gt;:Ggrep&lt;/code&gt; command which is very useful for searching the repo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One annoying thing is that I have huge &lt;code&gt;.map&lt;/code&gt; files and I want to omit them from my search. I cannot modify the &lt;code&gt;.gitignore&lt;/code&gt; and other files, I &lt;strong&gt;can only modify what's related to vim&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Ggrep foobar -- './*' ':(exclude)*.map'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I tell vim to always append &lt;code&gt;-- './*' ':(exclude)*.map'&lt;/code&gt; and just write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Ggrep foobar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;every time I'm searching for foobar?&lt;/p&gt;&#xA;" OwnerUserId="10575" LastEditorUserId="1841" LastEditDate="2016-12-29T13:26:11.190" LastActivityDate="2016-12-29T13:26:11.190" Title="How to always append parameters for a Ggrep command?" Tags="|search|plugin-fugitive|vimgrep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10768" PostTypeId="2" ParentId="10767" CreationDate="2016-12-27T11:07:13.647" Score="3" Body="&lt;p&gt;While I don't think it's possible out of the box, you can work your way around this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 GGrep Ggrep &amp;lt;q-args&amp;gt; -- './*' ':(exclude)*.map'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then use the &lt;code&gt;GGrep&lt;/code&gt; command instead of &lt;code&gt;Ggrep&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:GGrep foobar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h command&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h nargs&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h &amp;lt;q-args&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-12-27T11:07:13.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10769" PostTypeId="2" ParentId="10744" CreationDate="2016-12-27T11:33:50.873" Score="0" Body="&lt;p&gt;Here is a command that &lt;em&gt;should&lt;/em&gt; work (but it's not pretty):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Pt echomsg system(&quot;python -c 'from &quot; . expand(&quot;%:r&quot;) . &quot; import *;print &quot;. &amp;lt;f-args&amp;gt; . &quot;'&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Pt            &quot; Define a command named Pt that takes 1 argument.&#xA;echomsg system(&quot;                &quot; The command echo the result of a system call.&#xA;python -c '                     &quot; Execute a python string as the whole program.&#xA;from &quot; . expand(&quot;%:r&quot;)          &quot; Build a `from X import *` statement where X ..&#xA;. &quot; import *;                   &quot; .. is the current filename without extension&#xA;print &quot;. &amp;lt;f-args&amp;gt;               &quot; Print the command argument (see below)&#xA;. &quot;'&quot;)                          &quot; Close everything&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use the command like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# test.py&#xA;def test(a):&#xA;   return a*2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And run:     &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Pt test(21)&#xA;42&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h command&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h nargs&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h echomsg&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h system&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h expand&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h f-args&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2016-12-27T11:33:50.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10770" PostTypeId="2" ParentId="10725" CreationDate="2016-12-27T11:34:42.490" Score="4" Body="&lt;p&gt;&lt;code&gt;:.! shuf -i1-123124 -n1&lt;/code&gt; (with a dot) does the trick replacing the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:r! shuf -i1-123124 -n1&lt;/code&gt; creates a new line under cursor position.&lt;/p&gt;&#xA;" OwnerUserId="7913" LastEditorUserId="7913" LastEditDate="2017-02-09T21:07:12.073" LastActivityDate="2017-02-09T21:07:12.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10771" PostTypeId="2" ParentId="317" CreationDate="2016-12-27T15:26:32.460" Score="7" Body="&lt;p&gt;While @craigp's answer is correct, I found it most convenient to simply add &lt;code&gt;--remote-silent&lt;/code&gt; without worrying about server names,&lt;br&gt;&lt;em&gt;(this assumes you don't want to address named vim instances)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will start the server, or use one if its not already started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be called like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --remote-silent '+cal cursor(line,col)' some_file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --remote-silent '+cal cursor(102,4)' src/code.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I ended up needing to use a different method of moving the cursor because of this remote initialization.&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="301" LastEditDate="2016-12-29T06:35:47.963" LastActivityDate="2016-12-29T06:35:47.963" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10772" PostTypeId="1" AcceptedAnswerId="10773" CreationDate="2016-12-27T16:21:52.543" Score="0" ViewCount="419" Body="&lt;p&gt;In reading other's &lt;code&gt;.vimrc&lt;/code&gt;, I find many percent signs. &#xA;For instance in the portion concerning the status line, I know &lt;code&gt;%F%m%r%h&lt;/code&gt; must stands for something like the current filename being edited. &#xA;But because Google does not take special characters as literal, nor allow us to escape them, I find it very difficult to search for the exact meaning of theirs. &#xA;I don't know the official name of this class of variables, so neither do I know how to ask &lt;code&gt;help&lt;/code&gt;. &#xA;Can you list for me a table of all percent-prefixed variables? &#xA;If I get a list, I can play with them myself.&lt;/p&gt;&#xA;" OwnerUserId="10241" LastActivityDate="2016-12-27T17:58:24.727" Title="Ask a list of all percent-prefixed variables" Tags="|statusline|variables|escape|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10773" PostTypeId="2" ParentId="10772" CreationDate="2016-12-27T17:58:24.727" Score="3" Body="&lt;p&gt;If it is from &lt;code&gt;statusline&lt;/code&gt;, then &lt;code&gt;:h statusline&lt;/code&gt; is what you need. Vim has help for every single variable that you can set in &lt;code&gt;.vimrc&lt;/code&gt; (at least the ones that come with pure Vim, plugins usually also have good docs), thus &lt;code&gt;:h &amp;lt;variable name&amp;gt;&lt;/code&gt; should be your friend.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is from &lt;code&gt;:h statusline&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;F S   Full path to the file in the buffer.&#xA;m F   Modified flag, text is &quot;[+]&quot;; &quot;[-]&quot; if 'modifiable' is off.&#xA;r F   Readonly flag, text is &quot;[RO]&quot;.&#xA;h F   Help buffer flag, text is &quot;[help]&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are a lot more flags for status line in the doc.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2016-12-27T17:58:24.727" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10775" PostTypeId="1" AcceptedAnswerId="10776" CreationDate="2016-12-28T09:02:48.020" Score="10" ViewCount="852" Body="&lt;p&gt;I want to have the very first search result centered on the screen. I know about &lt;code&gt;:nnoremap n nzz&lt;/code&gt; mapping, but it only works for centering &lt;em&gt;next&lt;/em&gt; matches, not the first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought that maybe I could use some AutoCmd, but I haven't found an appropriate event.&lt;/p&gt;&#xA;" OwnerUserId="836" LastActivityDate="2021-08-15T02:26:41.310" Title="How can I automatically center first search result?" Tags="|search|autocmd|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10776" PostTypeId="2" ParentId="10775" CreationDate="2016-12-28T11:07:33.947" Score="17" Body="&lt;p&gt;You can use the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; getcmdtype() == '/' ? '&amp;lt;CR&amp;gt;zz' : '&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be explained like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;cnoremap&lt;/code&gt;        Create a mapping in the command line mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;          The mapping will evaluate an expression (allowing to use conditions)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;            The key to remap (&lt;kbd&gt;Enter&lt;/kbd&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;getcmdtype()&lt;/code&gt;    Return a character indicating which command line mode is used&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;== '/'&lt;/code&gt;          Did &lt;code&gt;getcmdtype()&lt;/code&gt; returned a &lt;code&gt;/&lt;/code&gt; which means we are in search mode?&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;lt;CR&amp;gt;zz'&lt;/code&gt;        If we are in search mode execute &lt;code&gt;zz&lt;/code&gt; after pressing &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;lt;CR&amp;gt;'&lt;/code&gt;          Else execute only &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Related help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr1&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h expr1&lt;/code&gt;&lt;/a&gt; for the &lt;code&gt;X ? Y : Z&lt;/code&gt; syntax&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Acnoremap&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :cnoremap&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap%2D%3Cexpr%3E&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :map-&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getcmdtype%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h getcmdtype()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Note that it would be interesting to create a mapping which would work with both forward and backward search i.e. when &lt;code&gt;getcmdtype()&lt;/code&gt; return &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;. Here is the mapping to do that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; (getcmdtype() == '?' \|\| getcmdtype() == '/') ? '&amp;lt;CR&amp;gt;zz' : '&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the escaping of the &lt;code&gt;|&lt;/code&gt; characters: if they are not escapes vim will understand &lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; (getcmdtype() == '?'&lt;/code&gt; as the first command to execute followed by &lt;code&gt;getcmdtype() == '/') ? '&amp;lt;CR&amp;gt;zz' : '&amp;lt;CR&amp;gt;'&lt;/code&gt; which doesn't make sense and create an error.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2&lt;/strong&gt; @Antony suggested a more readable solution, thanks to him:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; getcmdtype() =~ '[/?]' ? '&amp;lt;CR&amp;gt;zz' : '&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-12-28T13:52:44.303" LastActivityDate="2016-12-28T13:52:44.303" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10777" PostTypeId="1" AcceptedAnswerId="10782" CreationDate="2016-12-28T14:29:45.910" Score="7" ViewCount="637" Body="&lt;p&gt;Due to performance, I disable the &lt;code&gt;cursorline&lt;/code&gt; and &lt;code&gt;cursorcolumn&lt;/code&gt; in Vim. However, in the case jumping through a &lt;code&gt;Quickfix&lt;/code&gt; window, it is hard to locate the cursor in the file. So I would like to enable &lt;code&gt;cursorline&lt;/code&gt; and &lt;code&gt;cursorcolumn&lt;/code&gt; automatically after a &lt;code&gt;Quickfix&lt;/code&gt; window is opened (by whatever actions).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I have the solution using the &lt;code&gt;Autocmd&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufferEnter quickfix :bufdo set cursorline cursorcolumn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this the proper solution? Any better idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks very much!&lt;/p&gt;&#xA;" OwnerUserId="4754" LastActivityDate="2016-12-30T10:41:08.583" Title="Enable cursorline and cursorcolumn after Quickfix window is opened" Tags="|vimrc|autocmd|quickfix|cursorline|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10779" PostTypeId="1" CreationDate="2016-12-28T17:53:39.123" Score="3" ViewCount="2781" Body="&lt;p&gt;I use vim to edit a lot of latex files using vim 7.4. Some trick of the syntax&#xA;indenting annoys me and interferes with my intentions. Particularly, the automatic indentation during the addition of a line. I tried to remove this by &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set noautoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it produces no effect. Which of the many options is working against my desires?&lt;/p&gt;&#xA;" OwnerUserId="7868" LastEditorUserId="1841" LastEditDate="2016-12-29T13:24:34.113" LastActivityDate="2021-10-04T19:21:47.553" Title="How to prevent Vim from automatically indenting new lines?" Tags="|vimrc|indentation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10780" PostTypeId="2" ParentId="10779" CreationDate="2016-12-28T18:07:41.740" Score="2" Body="&lt;p&gt;After examining similar questions, I've found the solution is to &lt;code&gt;:set nosmartindent&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7868" LastEditorUserId="10604" LastEditDate="2020-04-27T21:06:53.310" LastActivityDate="2020-04-27T21:06:53.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10781" PostTypeId="1" AcceptedAnswerId="10813" CreationDate="2016-12-28T22:47:18.453" Score="4" ViewCount="116" Body="&lt;p&gt;There is a Haskell program called &lt;a href=&quot;https://hackage.haskell.org/package/inline-c&quot; rel=&quot;nofollow noreferrer&quot;&gt;inline-C&lt;/a&gt; which allows C code snippets to placed inline Haskell code, as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;main :: IO ()&#xA;main = do&#xA;  x &amp;lt;- [C.block| int {&#xA;      // Read and sum 5 integers&#xA;      int i, sum = 0, tmp;&#xA;      for (i = 0; i &amp;lt; 5; i++) {&#xA;        scanf(&quot;%d&quot;, &amp;amp;tmp);&#xA;        sum += tmp;&#xA;      }&#xA;      return sum;&#xA;    } |]&#xA;  print x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, there is a C code snippet above in between the &lt;code&gt;[C.block|&lt;/code&gt; and &lt;code&gt;|]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make it so that portions of code in between these are highlighted as C code?&lt;/p&gt;&#xA;" OwnerUserId="6499" LastEditorUserId="51" LastEditDate="2017-01-02T00:47:47.203" LastActivityDate="2017-01-02T00:47:47.203" Title="Extending Haskell syntax highlighting to allow for inline C snippets" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10782" PostTypeId="2" ParentId="10777" CreationDate="2016-12-29T10:27:04.367" Score="2" Body="&lt;p&gt;Create the file in &lt;code&gt;~/.vim/ftplugin/qf.vim&lt;/code&gt; (or &lt;code&gt;$HOME/vimfiles/ftplugin/qf.vim&lt;/code&gt; if you are on Windows) with the following contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Only do this when not done yet for this buffer&#xA;if exists(&quot;b:did_ftplugin&quot;)&#xA;   finish&#xA;endif&#xA;&#xA;wincmd p &quot; go to original window&#xA;set cursorline&#xA;set cursorcolumn&#xA;wincmd p &quot; back to quickfix window&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The ftplugin files are executed whenever the filetype is set for a given file buffer (quickfix and location window has the filetyp &lt;code&gt;qf&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the filetype plugin files instead of autocmds avoids cluttering your vimrc.&#xA;You can find more details at &lt;a href=&quot;http://vimhelp.appspot.com/usr_05.txt.html#ftplugin-name&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ftplugin-name&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/usr_43.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 43&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-26.8&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim FAQ 26.8&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The check on &lt;code&gt;b:did_ftplugin&lt;/code&gt; is necessary to allow disabling it if necessary and to avoid loading it twice (see &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#ftplugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ftplugin&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;let b:did_ftplugin = 1&lt;/code&gt; is omitted from this file because the intent of this file is to increment the default filetype plugin for quickfix, and not override. If this line was added then the settings at &lt;code&gt;$VIMRUNTIME/ftplugin/qf.vim&lt;/code&gt; would be skipped, as explained at &lt;a href=&quot;http://vimhelp.appspot.com/filetype.txt.html#ftplugin%2doverrule&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ftplugin-overrule&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2016-12-30T10:41:08.583" LastActivityDate="2016-12-30T10:41:08.583" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10784" PostTypeId="2" ParentId="7734" CreationDate="2016-12-29T11:20:17.690" Score="2" Body="&lt;p&gt;In my plugins, when I have temporary mappings, they are always buffer local -- I really don't care about saving global mappings nor about anything complex that involve them. Hence my &lt;code&gt;lh#on#exit().restore_buffer_mapping()&lt;/code&gt; helper function -- from &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-vim-lib&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end, what happens is the following: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; excerpt from autoload/lh/on.vim&#xA;function! s:restore_buffer_mapping(key, mode) dict abort &quot; {{{4&#xA;  let keybinding = maparg(a:key, a:mode, 0, 1)&#xA;  if get(keybinding, 'buffer', 0)&#xA;    let self.actions += [ 'silent! call lh#mapping#define('.string(keybinding).')']&#xA;  else&#xA;    let self.actions += [ 'silent! '.a:mode.'unmap &amp;lt;buffer&amp;gt; '.a:key ]&#xA;  endif&#xA;  return self&#xA;endfunction&#xA;&#xA;&quot; The action will be executed later on with:&#xA;&quot; # finalizer methods {{{2&#xA;function! s:finalize() dict &quot; {{{4&#xA;  &quot; This function shall not fail!&#xA;  for l:Action in self.actions&#xA;    try&#xA;      if type(l:Action) == type(function('has'))&#xA;        call l:Action()&#xA;      elseif !empty(l:Action)&#xA;        exe l:Action&#xA;      endif&#xA;    catch /.*/&#xA;      call lh#log#this('Error occured when running action (%1)', l:Action)&#xA;      call lh#log#exception()&#xA;    finally&#xA;      unlet l:Action&#xA;    endtry&#xA;  endfor&#xA;endfunction&#xA;&#xA;&#xA;&quot; excerpt from autoload/lh/mapping.vim&#xA;&quot; Function: lh#mapping#_build_command(mapping_definition) {{{2&#xA;&quot; @param mapping_definition is a dictionary witch the same keys than the ones&#xA;&quot; filled by maparg()&#xA;function! lh#mapping#_build_command(mapping_definition)&#xA;  let cmd = a:mapping_definition.mode&#xA;  if has_key(a:mapping_definition, 'noremap') &amp;amp;&amp;amp; a:mapping_definition.noremap&#xA;    let cmd .= 'nore'&#xA;  endif&#xA;  let cmd .= 'map'&#xA;  let specifiers = ['silent', 'expr', 'buffer']&#xA;  for specifier in specifiers&#xA;    if has_key(a:mapping_definition, specifier) &amp;amp;&amp;amp; a:mapping_definition[specifier]&#xA;      let cmd .= ' &amp;lt;'.specifier.'&amp;gt;'&#xA;    endif&#xA;  endfor&#xA;  let cmd .= ' '.(a:mapping_definition.lhs)&#xA;  let rhs = substitute(a:mapping_definition.rhs, '&amp;lt;SID&amp;gt;', &quot;\&amp;lt;SNR&amp;gt;&quot;.(a:mapping_definition.sid).'_', 'g')&#xA;  let cmd .= ' '.rhs&#xA;  return cmd&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2016-12-29T11:20:17.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10785" PostTypeId="1" AcceptedAnswerId="10786" CreationDate="2016-12-29T15:17:37.397" Score="5" ViewCount="375" Body="&lt;p&gt;&lt;strong&gt;How can you replace one match with multiple instances of a character (like &lt;code&gt;\t&lt;/code&gt;)?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's no problem to replace multiple characters with one.&#xA;But I did not find the answer for the opposite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: I want to change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Items: item1 item2 item3 item4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Items:&#xA;                item1&#xA;                item2&#xA;                ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and for the whitespace I want to use &lt;code&gt;\t&lt;/code&gt; tabstop (for example).&#xA;Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\s\(item.\)/\r\t{5}\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does not work. &lt;/p&gt;&#xA;" OwnerUserId="2239" LastEditorUserId="2314" LastEditDate="2016-12-29T20:08:27.180" LastActivityDate="2016-12-31T10:47:08.760" Title="Replace ONE occurrence of something with MULTIPLE instances of something" Tags="|substitute|replace|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10786" PostTypeId="2" ParentId="10785" CreationDate="2016-12-29T15:39:44.230" Score="9" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You are probably best off just hitting dat &lt;kbd&gt;Tab&lt;/kbd&gt; key 5 times in your example:&lt;sub&gt;&lt;/sub&gt;&lt;br&gt;&#xA;&lt;code&gt;:%s/\s\(item.\)/\r&lt;/code&gt;    &lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;    &lt;code&gt;\1/g&lt;/code&gt;&lt;br&gt;&#xA;&lt;sub&gt;(The tabs display as &lt;code&gt;^I&lt;/code&gt; in the Command-line.)&lt;/sub&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;More elegantly, you can have vim repeat that typing for you. But with its ≥7 keystrokes and a bit of thinking effort, this technique is only economical for a bigger number of repetitions or characters to be repeated:&lt;sub&gt;&lt;/sub&gt;&lt;br&gt;&#xA;&lt;code&gt;:%s/\s\(item.\)/\r&lt;/code&gt;    &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;f&lt;/kbd&gt; &lt;kbd&gt;&lt;code&gt;5&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; &lt;code&gt;\t&lt;/code&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;c&lt;/kbd&gt;    &lt;code&gt;\1/g&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The most literal and technical answer to your question is – at the cost of even much more verbose syntax – using &lt;code&gt;\=&lt;/code&gt; for substituting by an expression [&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help sub-replace-expression&lt;/code&gt;&lt;/a&gt;], in which you could then employ the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#repeat()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;repeat()&lt;/code&gt;&lt;/a&gt; function:&lt;sub&gt;&lt;/sub&gt;&lt;br&gt;&#xA;&lt;code&gt;:%s/\s\(item.\)/\= &quot;\n&quot; . repeat(&quot;\t&quot;, 5) . submatch(1)/g&lt;/code&gt;  &lt;sub&gt;  (Readability spaces not required.)&lt;/sub&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, vim does not provide syntactic sugar for repetition (&lt;code&gt;\{5}&lt;/code&gt; or otherwise) in the replacement part of the &lt;code&gt;:substitute&lt;/code&gt; command;  almost none of the special regex syntax for pattern matching [&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#pattern-overview&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h pattern-overview&lt;/code&gt;&lt;/a&gt;] is available for the replacement: &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-special&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h sub-replace-special&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;&#xA;&lt;sub&gt;(PS: &lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;)&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="2314" LastEditorUserId="2314" LastEditDate="2016-12-31T10:47:08.760" LastActivityDate="2016-12-31T10:47:08.760" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10787" PostTypeId="1" AcceptedAnswerId="10788" CreationDate="2016-12-29T15:45:07.400" Score="10" ViewCount="4338" Body="&lt;p&gt;I'm using the vimwiki plugin and trying to figure out tagging with vimwiki-syntax-tags.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can add a tag &lt;code&gt;:tag-example:&lt;/code&gt; to a vimwiki .wiki file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can search &lt;code&gt;:VimwikiSearchTags tag-example&lt;/code&gt; and it will find the tag properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there are two instances of this tag, the search returns the first instance and displays &lt;code&gt;(1 of 2): :tag-example:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to go to the next tag instance found by the search?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any other suggestions related to tagging / vimwiki would be appreciated as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="10652" LastActivityDate="2020-04-17T16:28:17.930" Title="How to search multiple occurences of a vimwiki tag?" Tags="|tags|plugin-vimwiki|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10788" PostTypeId="2" ParentId="10787" CreationDate="2016-12-29T16:03:14.613" Score="10" Body="&lt;p&gt;The results from &lt;code&gt;:VimwikiSearchTags&lt;/code&gt; are populated in the &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#location%2dlist&quot;&gt;&lt;code&gt;location-list&lt;/code&gt;&lt;/a&gt; window, so you can navigate using &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3alnext&quot;&gt;&lt;code&gt;:lnext&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3alprevious&quot;&gt;&lt;code&gt;:lprevious&lt;/code&gt;&lt;/a&gt;, or you can check all the results using &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3alopen&quot;&gt;&lt;code&gt;:lopen&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be honest, despite I have been using Vimwiki for several years, I didn't know about the tags. Maybe it is because my wikis are not that large (~2 MB at most), but I find it easier to simple &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3agrep&quot;&gt;&lt;code&gt;:grep&lt;/code&gt;&lt;/a&gt; (or &lt;a href=&quot;https://github.com/mileszs/ack.vim&quot;&gt;&lt;code&gt;:Ack&lt;/code&gt;&lt;/a&gt;) everything, which is quite fast, instead of writing the tags in advance.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2016-12-29T16:03:14.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10789" PostTypeId="1" AcceptedAnswerId="10790" CreationDate="2016-12-29T19:33:30.253" Score="0" ViewCount="231" Body="&lt;pre&gt;&lt;code&gt;    set sessionoptions+=globals &#xA;    if !exists('g:EGbufs')&#xA;        if exists('g:EGbufsstring')&#xA;            exe &quot;let g:EGbufs=&quot;.g:EGbufsstring&#xA;        else&#xA;            let g:EGbufs = {}&#xA;        endif&#xA;    endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have this in my .vimrc.&#xA;When I load a session, I can &lt;code&gt;:echo g:EGbufsstring&lt;/code&gt; for the right result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for some reason, my second exists conditional fails, and so &lt;code&gt;g:EGbufs&lt;/code&gt; is set to a empty dictionary. There might be another bug, but I've used echo and echoerr around this code to check the value of the string and it tells me the variable doesn't exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does a vimsession get loaded AFTER the .vimrc? The only work around I can think of is writing to a file the string I want to load, and reading it in the vimrc. I'm already trying to work around lack of support for saving dictionaries in a session. I guess my other option is to run this load conditional in the function that I need it, but that's just a little ugly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ah, I thought I had it with &lt;code&gt;autocmd SessionLoadPost call LoadBufsString()&lt;/code&gt; but I can't seem to make it work. Thought it might be because it only triggers on manual &lt;code&gt;:mks&lt;/code&gt; but that is not the case either. Probably I just need to sort out the syntax.&lt;/p&gt;&#xA;" OwnerUserId="8483" LastEditorUserId="8483" LastEditDate="2016-12-29T20:38:02.700" LastActivityDate="2016-12-29T21:06:20.167" Title="Do sessions get loaded after vimrc, and is there a block to specify loading code AFTER a session is loaded?" Tags="|sessions|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10790" PostTypeId="2" ParentId="10789" CreationDate="2016-12-29T20:17:22.643" Score="0" Body="&lt;p&gt;I think I found my answer. autocommand with the&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;|SessionLoadPost|  after loading a session file&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;event. It hit me when I realised I want something to trigger this code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd SessionLoadPost * call LoadBufsString()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;does it. I needed to specify * for the filematcher, for some reason. Not sure if that is mandatory for all autocommands.&lt;/p&gt;&#xA;" OwnerUserId="8483" LastEditorUserId="8483" LastEditDate="2016-12-29T21:06:20.167" LastActivityDate="2016-12-29T21:06:20.167" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10791" PostTypeId="2" ParentId="10323" CreationDate="2016-12-29T20:18:00.973" Score="0" Body="&lt;p&gt;Netrw normally sets noswf, which is a buffer-local option, for its own buffers.  However, if you have &lt;code&gt;let g:netrw_use_noswf= 0&lt;/code&gt; in your .vimrc, then netrw won't set noswf, which may cause your problem.  What does &lt;code&gt;:verbose set swf?&lt;/code&gt; show?&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2016-12-29T20:18:00.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10792" PostTypeId="1" AcceptedAnswerId="10798" CreationDate="2016-12-30T00:36:46.387" Score="11" ViewCount="3357" Body="&lt;p&gt;I recently found out that &lt;code&gt;YouCompleteMe&lt;/code&gt; has an  &lt;code&gt;g:ycm_autoclose_preview_window_after_insertion&lt;/code&gt; option that automatically hides the documentation preview window after exiting insert mode, and I also recently started out using vim, so this was the first time I set an option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I wondered if other plugins I crammed in my vim environment have options available, without searching for them manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are they registered globally when vim starts, in order for a command that lists them to be available, or this can't be done?&lt;/p&gt;&#xA;" OwnerUserId="10649" LastEditorUserId="1841" LastEditDate="2016-12-30T09:30:42.327" LastActivityDate="2016-12-30T14:18:31.723" Title="How to list the available options of a plugin?" Tags="|options|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10793" PostTypeId="1" AcceptedAnswerId="10800" CreationDate="2016-12-30T08:08:58.377" Score="2" ViewCount="215" Body="&lt;p&gt;I'm using vim (actually, neovim) on macOS and whenever I run a command which outputs text (e.g. &lt;code&gt;:version&lt;/code&gt;) and switch to another Desktop (so iTerm looses focus) and get back to it, the output window/pane is gone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I stop it from automatically closing, even when the &lt;code&gt;Press ENTER or type command to continue&lt;/code&gt; is shown? (which is actually a lie, as it continues without me pressing ENTER or typing a command)&lt;/p&gt;&#xA;" OwnerUserId="10649" LastEditorUserId="51" LastEditDate="2016-12-31T03:17:24.870" LastActivityDate="2016-12-31T03:24:09.023" Title="Command output window disappears on blur" Tags="|neovim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10794" PostTypeId="2" ParentId="10792" CreationDate="2016-12-30T08:49:38.530" Score="2" Body="&lt;p&gt;Vim doesn't have a referential of the available options. the best you can do is to see what have been initialized. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Vim's built-in options there is the command &lt;code&gt;:set&lt;/code&gt;. From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%3Aset&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :set&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;:se[t]           Show all options that differ from their default value.&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You will not see all the available options, only the ones you modified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;:let&lt;/code&gt; to list the value of all the declared variables and &lt;code&gt;:let g:&lt;/code&gt; for a list of the global variables. (See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#E121&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h E121&lt;/code&gt;&lt;/a&gt; for a list of the variable you can show).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that these lists are not always easy to read/parse. For the plugins, your best option is to read the documentation and find the option you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also be interested by this wikia tip &lt;a href=&quot;http://vim.wikia.com/wiki/Displaying_the_current_Vim_environment&quot; rel=&quot;nofollow noreferrer&quot;&gt;how to display vim environment&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2016-12-30T08:55:17.393" LastActivityDate="2016-12-30T08:55:17.393" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10795" PostTypeId="2" ParentId="10775" CreationDate="2016-12-30T09:05:55.827" Score="5" Body="&lt;p&gt;Statox's answer is definitely the best so far, but as an alternative, I've just found out about &lt;a href=&quot;https://github.com/junegunn/vim-slash&quot; rel=&quot;noreferrer&quot;&gt;Vim-slash&lt;/a&gt;, a plugin aiming to &quot;enhance the in-buffer search experience.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And from it's readme:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Customization&lt;/strong&gt; &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;zz after search&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Places the current match at the center of the window.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;plug&amp;gt;(slash-after) zz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Just tried it out and it is working smoothly in both directions (&lt;code&gt;/&lt;/code&gt; and &lt;code&gt;?&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="10493" LastActivityDate="2016-12-30T09:05:55.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10796" PostTypeId="2" ParentId="3725" CreationDate="2016-12-30T09:32:41.003" Score="113" Body="&lt;p&gt;To swap the two parts of a split window simply do: &lt;code&gt;&amp;lt;C-w&amp;gt; &amp;lt;C-r&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10660" LastActivityDate="2016-12-30T09:32:41.003" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10797" PostTypeId="1" AcceptedAnswerId="10802" CreationDate="2016-12-30T10:13:09.727" Score="4" ViewCount="1238" Body="&lt;p&gt;Recently I've started up with &lt;a href=&quot;https://vuejs.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vuejs&lt;/a&gt; and I'm currently trying to set up my editor for using it. Vue uses a similar approach with React - keeping the HTML,  Javascript &amp;amp; CSS in the same file - it does so by marking the various chunks of code with some XML tags. I'd like to change the filetype based on area of the file that I'm currently editing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long story short, given the anatomy of a .vue, file what I'd like to do is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;template&amp;gt;&#xA;  &amp;lt;!-- &#xA;    when the cursor is here, execute &#xA;    :set ft=html&#xA;  --&amp;gt;&#xA;&amp;lt;/template&amp;gt;&#xA;&#xA;&amp;lt;script&amp;gt;&#xA;  /**&#xA;   * when the cursor is here, execute&#xA;   * :set ft=javascript&#xA;   */&#xA;&amp;lt;/script&amp;gt;&#xA;&#xA;&amp;lt;style&amp;gt;&#xA;  /**&#xA;   * when the cursor is here, execute&#xA;   * :set ft=css&#xA;   */&#xA;&amp;lt;/style&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know there's a plugin called &lt;a href=&quot;https://github.com/posva/vim-vue%20vim-vue&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-vue&lt;/a&gt;, which is awesome, but it only changes the syntax for correct highlighting, and I would like to change the filetype, so all other plugins (autocomplete with ternjs for javascript, linters, multi-line commenters, etc.) to work correctly in their respective areas. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to avenues of attacking this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;using the aforementioned plugin and somehow monitor for changes of the syntax and update the filetype accordingly. AFAIK vim does not trigger an event when the syntax is changed.&lt;/li&gt;&#xA;&lt;li&gt;have something similar with &lt;code&gt;syntax region&lt;/code&gt; but for filetype&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But so far I could not find a solution. Any suggestions are welcome. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I use neovim in CLI mode, but I don't think that's particularly relevant. &lt;/p&gt;&#xA;" OwnerUserId="10661" LastEditorUserId="24" LastEditDate="2017-01-05T00:02:22.363" LastActivityDate="2017-01-05T00:02:22.363" Title="Change the filetype based on tags / regions in the file" Tags="|neovim|filetype|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10798" PostTypeId="2" ParentId="10792" CreationDate="2016-12-30T14:18:31.723" Score="7" Body="&lt;p&gt;Vim doesn't provide any way to know all possible plugin options.&lt;/p&gt;&#xA;&lt;p&gt;As a plugin writer I can tell you this is quite complex as there are many different ways to proceed. For instance either we consider that if the end-user hasn't provided a value for an option in its &lt;code&gt;.vimrc&lt;/code&gt; then we force this option to exist and to be equal to a default value, or we can say: &amp;quot;either take the value set by the end-user, or use an hard-coded default value&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;With that first approach, the end-user can see the list of available options with a &lt;code&gt;c_CTRL-D&lt;/code&gt;, or &lt;code&gt;c_TAB&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&lt;p&gt;More and more plugins choose to organize all their options into dictionaries. i.e., instead of having &lt;code&gt;g:plugin_foo_option&lt;/code&gt; and &lt;code&gt;g:plugin_bar_option&lt;/code&gt;, we have &lt;code&gt;g:plugin.foo_option&lt;/code&gt; and &lt;code&gt;g:plugin.bar_option&lt;/code&gt;. This avoids polluting the list &lt;code&gt;g:&lt;/code&gt; of global options, but we lose command-line autocompletion (I may eventually open an issue of the subject, on vim github).&lt;/p&gt;&#xA;&lt;p&gt;So far I have only talked about global options. Most plugins don't try to support more specific options even if they should have done it. For instance, I regret that neither &lt;em&gt;YouCompleteMe&lt;/em&gt; nor &lt;em&gt;alternate&lt;/em&gt;, nor many other plugins, use project specific options instead of global options. Indeed, depending on the project I'm working on I want to set their respective options to different values. Unfortunately, this is not a work-flow they have considered. In my plugins, many options can be specialized on project basis, or on buffer basis. Lately I've come up with an &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/Project.md&quot; rel=&quot;noreferrer&quot;&gt;experiment&lt;/a&gt; on the subject. But even with the usual and simple &lt;code&gt;g:plugin_option&lt;/code&gt; + &lt;code&gt;b:plugin_option&lt;/code&gt; pair, it's next to impossible to know all available options.&lt;/p&gt;&#xA;&lt;p&gt;Sometimes I try to offer commands that help setting options as I've done with build-tools-wrappers, or even to display some options in the menu (when using gvim), but it's really far from being perfect.&lt;/p&gt;&#xA;&lt;p&gt;I'm afraid that the documentation is the best thing available. You can even try a &lt;code&gt;:h pluginname^D&lt;/code&gt;. It's probably the best approach available.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2016-12-30T14:18:31.723" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10799" PostTypeId="1" CreationDate="2016-12-30T18:18:59.493" Score="0" ViewCount="542" Body="&lt;p&gt;How can I add syntax highlight for &lt;code&gt;windows.h&lt;/code&gt; C/C++ apis and types?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I've found is a tiny winapi syntax file &lt;a href=&quot;https://github.com/fishman/vim_files/blob/master/after/syntax/c/winapi.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10664" LastEditorUserId="51" LastEditDate="2017-01-02T09:01:59.123" LastActivityDate="2017-01-02T09:27:01.953" Title="How can I highlight WinAPI functions in C++?" Tags="|syntax-highlighting|microsoft-windows|filetype-c++|filetype-c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10800" PostTypeId="2" ParentId="10793" CreationDate="2016-12-31T03:24:09.023" Score="3" Body="&lt;p&gt;It's a known Neovim bug: &lt;a href=&quot;https://github.com/neovim/neovim/issues/4840&quot; rel=&quot;nofollow noreferrer&quot;&gt;Focus events make messages disappear (as if Enter was pressed)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The workaround is either using Vim (which doesn't have this bug) or using a terminal emulator which doesn't send focus events (or disable sending focus events for your terminal emulator, if possible).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2016-12-31T03:24:09.023" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10802" PostTypeId="2" ParentId="10797" CreationDate="2016-12-31T16:44:16.613" Score="6" Body="&lt;p&gt;Regarding the proposal and links provided in comments you could define a function as follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:setFileType()&#xA;  if searchpair('&amp;lt;script', '', '&amp;lt;/script&amp;gt;', 'bnW')&#xA;    set ft=javascript&#xA;  elseif searchpair('&amp;lt;style', '', '&amp;lt;/style&amp;gt;', 'bnW')&#xA;    set ft=css&#xA;  else&#xA;    set ft=html&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and bind it to &lt;em&gt;CursorMoved&lt;/em&gt; autocommand in &lt;em&gt;vue&lt;/em&gt; files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vueBinds&#xA;  au!&#xA;  au CursorMoved,CursorMovedI *.vue call s:setFileType()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now every time you cursor is moving in &lt;em&gt;vue&lt;/em&gt; files base on where it is ( in between (&lt;code&gt;&amp;lt;script,&amp;lt;/script&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;style,&amp;lt;/style&amp;gt;&lt;/code&gt; and ...) it sets the desired filetype and act as it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this approach has some major drawbacks:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;syntax highlighting get disrupted every time you change the filetype&lt;/li&gt;&#xA;&lt;li&gt;You missed your linters because linters normally check against the entire buffer&lt;/li&gt;&#xA;&lt;li&gt;buffer local configurations remains active when you change filetype so you'll face some editing problems&lt;/li&gt;&#xA;&lt;li&gt;and ...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Well, we can use a vue-linter(Does this ever exist?), confine beautifiers to regions, use more and more plugins But wait! Doesn't we done all of this for html, css, js and ... and all we're going to write is html, css, js code?!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what's the solution. &lt;strong&gt;How can someone edit a filetype in another filetype with all the features of that filetype include: ftplugins, completions, linters, beautifiers and ...&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All we need is a syntax-highlighting plugin and a feature called &lt;strong&gt;Narrowing&lt;/strong&gt; the buffer!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/posva/vim-vue&quot; rel=&quot;noreferrer&quot;&gt;vim-vue&lt;/a&gt; does highlighting But what about Narrowing?! Fortunately @Christian Brabandt has gracefully brings this emacs feature to vim throught: &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;NrrwRgn plugin&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this plugin and &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn/blob/5dce84324bfd443983388bd4535a811c4785c88c/doc/NarrowRegion.txt#L459-L470&quot; rel=&quot;noreferrer&quot;&gt;this tip from it's documentation&lt;/a&gt; you could choose to open region with desired filetype.&#xA;for example in &lt;em&gt;vue&lt;/em&gt; files you could visual select your script region and type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;NN javascript&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;command. it will open region and you could edit it with full javascript filetypes power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read Its &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn/blob/master/doc/NarrowRegion.txt&quot; rel=&quot;noreferrer&quot;&gt;Documentation&lt;/a&gt; and fine tune it to your needs.&lt;/p&gt;&#xA;" OwnerUserId="7976" LastActivityDate="2016-12-31T16:44:16.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10803" PostTypeId="2" ParentId="464" CreationDate="2016-12-31T21:41:41.340" Score="18" Body="&lt;p&gt;&lt;em&gt;&quot;the buffer numbers get crazy&quot;&lt;/em&gt; Tell me about it! By the end of the day I'm easy over 100 buffers. But luckily, as you can see in this animation, you have &lt;kbd&gt;tab&lt;/kbd&gt; completion for buffer names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SbQXI.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SbQXI.gif&quot; alt=&quot;Hit :b se&amp;lt;Tab&amp;gt;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, even though you can't renumber the buffers, you can still jump around easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if it's clear from the animation but, the &quot;tab completion&quot; is unlike command line tab completion. It's more like a &quot;ambiguity resolving tab replacer&quot;. Meaning that at the command line I would have had to type &lt;code&gt;sc&lt;/code&gt;&lt;kbd&gt;tab&lt;/kbd&gt; then &lt;code&gt;se&lt;/code&gt;&lt;kbd&gt;tab&lt;/kbd&gt; but here vim does an 'se' search and replaces it with the first (and only) match. If I had typed &lt;code&gt;test&lt;/code&gt;&lt;kbd&gt;tab&lt;/kbd&gt; it would have matched 'generate_test_data.py' and then &lt;kbd&gt;tab&lt;/kbd&gt; again would have matched 'scripts/setup_test_data.sh' and then &lt;kbd&gt;tab&lt;/kbd&gt; again would have cycled back around, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point being that you can get in the habit of typing merely &lt;code&gt;:b &amp;lt;minimum amount of unambiguous characters&amp;gt;&lt;/code&gt;&lt;kbd&gt;tab&lt;/kbd&gt; to jump to the document you want. I think this is even better than remembering &quot;My buffers are 1:foo 2:bar 3:etc&quot; which is how I used to do it when I was a newbie.&lt;/p&gt;&#xA;" OwnerUserId="10672" LastEditorUserId="10672" LastEditDate="2017-01-11T16:27:37.683" LastActivityDate="2017-01-11T16:27:37.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10804" PostTypeId="2" ParentId="7624" CreationDate="2016-12-31T23:36:42.010" Score="8" Body="&lt;p&gt;There is a nice implementation of NeoVim GUI for macOS named &lt;a href=&quot;http://vimr.org&quot; rel=&quot;noreferrer&quot;&gt;VimR&lt;/a&gt; (R = Refined). It has a native file manager and works fine and fast with mouse gestures and macOS UI. VimR comes with a command line tool &lt;code&gt;vimr&lt;/code&gt;. VimR &lt;a href=&quot;https://github.com/qvacua/vimr&quot; rel=&quot;noreferrer&quot;&gt;repository&lt;/a&gt; is more active and has more stars comparing to &lt;a href=&quot;https://github.com/rogual/neovim-dot-app&quot; rel=&quot;noreferrer&quot;&gt;neovim-dot-app&lt;/a&gt;.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/TTko5.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TTko5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7357" LastActivityDate="2016-12-31T23:36:42.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10805" PostTypeId="1" CreationDate="2017-01-01T15:34:05.417" Score="4" ViewCount="371" Body="&lt;p&gt;How I can launch gvim with servername for filetype tex?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am looking for is something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au filetype tex vim --servername &quot;SERVERNAME&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand that it directly not possible, as vimrc is not loaded.&#xA;But is there any other way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I'm using a shell alias to do this, but I'd like to get it working as a Vim plugin.&lt;/p&gt;&#xA;" OwnerUserId="2738" LastEditorUserId="51" LastEditDate="2017-01-01T22:40:17.500" LastActivityDate="2017-01-01T22:57:40.650" Title="vim with servername for a filetype" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10806" PostTypeId="1" CreationDate="2017-01-01T15:58:42.883" Score="2" ViewCount="260" Body="&lt;p&gt;I'm trying to configure line splitting which I want to make available only if the current symbol is space. I currently configured it as so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;r&amp;lt;ENTER&amp;gt;k$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this does the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1 line2&#xA;     ^&#xA;   cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1&#xA;line2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1line2&#xA;    ^&#xA;  cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line          &amp;lt;---------- 1 is missing&#xA;line2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is not desirable. So I want to allow to split the line only if the current symbol is space. Is it possible to do?&lt;/p&gt;&#xA;" OwnerUserId="9417" LastActivityDate="2017-01-01T22:20:25.687" Title="Do nothing if the current symbol is not space" Tags="|vimrc|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10807" PostTypeId="1" CreationDate="2017-01-01T17:17:46.640" Score="1" ViewCount="254" Body="&lt;p&gt;I'm writing a syntax file. To highlight strings, I'm defining a region just like it says in the help file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;syn region m2String start=/&quot;/ skip=/\\&quot;/ end=/&quot;/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and later I have:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let b:current_syntax = &quot;m2&quot;&#xA; hi def link m2String String&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this isn't behaving the way I want it to. After some experimenting, I figured out that vim is only highlighting strings if the character before the first quotation mark is a letter. Here's a screen shot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wfonu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wfonu.png&quot; alt=&quot;example of my wonky syntax highlighting&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know why this is happening and how to fix it? If it helps, I'm using vim version 7.4.1689 in the terminal. My terminal is xterm-256color.&lt;/p&gt;&#xA;" OwnerUserId="10678" LastActivityDate="2017-01-31T19:11:57.683" Title="Syntax highlighting only matches strings if the character before the opening quotation mark is a letter" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10808" PostTypeId="2" ParentId="10807" CreationDate="2017-01-01T18:48:28.503" Score="1" Body="&lt;p&gt;I found the culprit: the original author of this syntax file included the line&#xA;&lt;code&gt;syn match m2Keyword /\A\+/&lt;/code&gt;. I guess this matched the first quotation mark before the string region did. &lt;/p&gt;&#xA;" OwnerUserId="10678" LastActivityDate="2017-01-01T18:48:28.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10809" PostTypeId="1" AcceptedAnswerId="10818" CreationDate="2017-01-01T22:05:52.660" Score="4" ViewCount="94" Body="&lt;p&gt;I'm trying to multiply two numbers using the Expression Register, but the numbers are pretty big (&lt;code&gt;22,000,001&lt;/code&gt; and &lt;code&gt;10,000,022&lt;/code&gt;), and instead of the correct result (&lt;code&gt;220,000,494,000,022&lt;/code&gt;) I get &lt;code&gt;-615802986&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i&amp;lt;C-r&amp;gt;=22000001*10000022&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a result, &lt;code&gt;-615802986&lt;/code&gt; was appended to my buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to avoid the overflow and get the correct result?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; I'd like to do this in pure vim; I cannot use external commands (for example call python or bc).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'm using VIM 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48), installed with the &lt;em&gt;vim-gnome&lt;/em&gt; package on Ubuntu.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)&#xA;Included patches: 1-1689&#xA;Extra patches: 8.0.0056&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Huge version with GTK2-GNOME GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +tag_binary&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_old_static&#xA;+autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+balloon_eval    +float           +mouse_urxvt     +tcl&#xA;+browse          +folding         +mouse_xterm     +terminfo&#xA;++builtin_terms  -footer          +multi_byte      +termresponse&#xA;+byte_offset     +fork()          +multi_lang      +textobjects&#xA;+channel         +gettext         -mzscheme        +timers&#xA;+cindent         -hangul_input    +netbeans_intg   +title&#xA;+clientserver    +iconv           +packages        +toolbar&#xA;+clipboard       +insert_expand   +path_extra      +user_commands&#xA;+cmdline_compl   +job             +perl            +vertsplit&#xA;+cmdline_hist    +jumplist        +persistent_undo +virtualedit&#xA;+cmdline_info    +keymap          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       -python          +vreplace&#xA;+cscope          +lispindent      +python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con_gui  +lua             +rightleft       +writebackup&#xA;+diff            +menu            +ruby            +X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;+dnd             +modify_fname    +signs           +xim&#xA;-ebcdic          +mouse           +smartindent     +xsmp_interact&#xA;+emacs_tags      +mouseshape      +startuptime     +xterm_clipboard&#xA;+eval            +mouse_dec       +statusline      -xterm_save&#xA;+ex_extra        +mouse_gpm       -sun_workshop    +xpm&#xA;+extra_search    -mouse_jsbterm   +syntax          &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -D_REENTRANT -DORBIT2=1 -pthread -I/usr/include/libgnomeui-2.0 -I/usr/include/gnome-keyring-1 -I/usr/include/libbonoboui-2.0 -I/usr/include/libxml2 -I/usr/include/libgnome-2.0 -I/usr/include/libbonobo-2.0 -I/usr/include/bonobo-activation-2.0 -I/usr/include/orbit-2.0 -I/usr/include/libgnomecanvas-2.0 -I/usr/include/gail-1.0 -I/usr/include/libart-2.0 -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/gnome-vfs-2.0 -I/usr/lib/x86_64-linux-gnu/gnome-vfs-2.0/include -I/usr/include/gconf/2 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time  -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype  -lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnome-2 -lpopt -lbonobo-2 -lbonobo-activation -lORBit-2 -lgnomecanvas-2 -lart_lgpl_2 -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lfontconfig -lfreetype -lgdk_pixbuf-2.0 -lgnomevfs-2 -lgconf-2 -lgthread-2.0 -lgmodule-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.22/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5036" LastEditorUserId="51" LastEditDate="2017-01-02T06:53:37.007" LastActivityDate="2017-01-02T07:30:36.227" Title="Integer overflow when using large numbers with the expression register" Tags="|expression-register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10810" PostTypeId="2" ParentId="10806" CreationDate="2017-01-01T22:20:25.687" Score="3" Body="&lt;p&gt;You can use an expression mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;s getline('.')[col('.')-1] =~ &quot;\\s&quot; ? &quot;r&amp;lt;Enter&amp;gt;k$&quot; : &quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; will make Vim evaluate a Vimscript expression, instead of just a &quot;static&quot; list of keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, we use &lt;code&gt;getline('.')[col('.')-1]&lt;/code&gt; to get the character under the cursor, we check if this is whitespace with &lt;code&gt;=~ &quot;\\s&quot;&lt;/code&gt; (this will also match tabs etc.) and run &lt;code&gt;r&amp;lt;Enter&amp;gt;k$&lt;/code&gt; if it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it doesn't match, we do nothing.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Perhaps a more useful mapping is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;q getline('.')[col('.')-1] =~ &quot;\\s&quot; ? &quot;r&amp;lt;Enter&amp;gt;k$&quot; : &quot;i&amp;lt;Enter&amp;gt;&amp;lt;Esc&amp;gt;k$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will split the line without deleting whitespace.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-01-01T22:20:25.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10811" PostTypeId="2" ParentId="10805" CreationDate="2017-01-01T22:39:01.547" Score="2" Body="&lt;p&gt;Unfortunately this isn't really possible; not without some hackery anyway.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;--servername&lt;/code&gt; has to be given as a commandline parameter, it can't be set later (&lt;code&gt;v:servername&lt;/code&gt; is read-only).&lt;/li&gt;&#xA;&lt;li&gt;Vim has no facility to restart itself with different parameters (e.g. like &lt;code&gt;exec()&lt;/code&gt; function family in C).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The best you can do it to start Gvim from within Gvim with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute ':!gvim --servername xxx ' . join(argv())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has the problem of having two Gvim processes though (and thus Gvim windows); you'll will have to &lt;code&gt;:q&lt;/code&gt; twice and the second Gvim will complain about swap files if the files are open in the first Gvim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can somewhat work around with with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! RestartVim()&#xA;    &quot; Only run this if servername is empty or the default&#xA;    if v:servername == '' || v:servername =~ '^gvim'&#xA;        &quot; Only run for gvim, since this version doesn't work well with Vim&#xA;        if !has(&quot;gui_running&quot;)&#xA;            return&#xA;        endif&#xA;&#xA;        &quot; Close all buffers; prevents swap warnings&#xA;        bufdo bdelete&#xA;&#xA;        &quot; Run the second gvim&#xA;        execute ':!gvim --servername xxx ' . join(argv()) . ' &amp;amp;'&#xA;&#xA;        &quot; Quit the first Vim instance&#xA;        quit&#xA;    endif&#xA;endfun&#xA;&#xA;augroup tex_restart&#xA;    autocmd!&#xA;    autocmd Filetype tex call RestartVim()&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I didn't extensively test this, and will probably have a caveat or two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This version also won't work very well with regular Vim inside a terminal. Running &lt;code&gt;vim&lt;/code&gt; with &lt;code&gt;&amp;amp;&lt;/code&gt; won't work well since it won't be attached to the terminal, and I can't really think of a solution to prevent two &lt;code&gt;vim&lt;/code&gt; processes.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-01-01T22:57:40.650" LastActivityDate="2017-01-01T22:57:40.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10812" PostTypeId="2" ParentId="10744" CreationDate="2017-01-01T23:47:05.277" Score="5" Body="&lt;p&gt;Not really a &quot;Vim answer&quot;, but writing a unit test and running the unit test(s) for the current file is probably the best way to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically for Python you can use &lt;a href=&quot;https://docs.python.org/3/library/doctest.html&quot; rel=&quot;noreferrer&quot;&gt;doctests&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import datetime&#xA;&#xA;def seconds_to_text(seconds):&#xA;    &quot;&quot;&quot;Convert number of seconds to a textual representation.&#xA;&#xA;    &amp;gt;&amp;gt;&amp;gt; seconds_to_text(42)&#xA;    '0:00:42'&#xA;    &amp;gt;&amp;gt;&amp;gt; str(datetime.timedelta(seconds=666))&#xA;    '0:11:06'&#xA;    &quot;&quot;&quot;&#xA;    return str(datetime.timedelta(seconds=seconds))&#xA;&#xA;if __name__ == '__main__':&#xA;    import doctest&#xA;    doctest.testmod()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then just use &lt;code&gt;:!python %&lt;/code&gt; to run this file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or if you don't want to modify the Python files, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!python -m doctest %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or as a more convenient mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup python_test&#xA;    autocmd!&#xA;    autocmd Filetype python nnoremap &amp;lt;Leader&amp;gt;t :execute ':!python -m doctest %'&amp;lt;CR&amp;gt;&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you only want to run the current function, you can use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if __name__ == '__main__':&#xA;    import doctest, sys&#xA;    if len(sys.argv) &amp;lt; 2:&#xA;        doctest.testmod()&#xA;    else:&#xA;        for f in sys.argv[1:]:&#xA;            doctest.run_docstring_examples(globals()[f], globals())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then use &lt;code&gt;:!python % seconds_to_text&lt;/code&gt;; a useful mapping might be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! TestFunction()&#xA;    &quot; Find function under cursor&#xA;    let l:save = winsaveview()&#xA;    normal [[&#xA;    let l:fun = substitute(getline('.'), 'def \(\w*\)(.*', '\1', '')&#xA;    execute ':!python % ' . l:fun&#xA;    call winrestview(l:save)&#xA;endfun&#xA;&#xA;augroup python_test&#xA;    autocmd!&#xA;    autocmd Filetype python nnoremap &amp;lt;Leader&amp;gt;t :call TestFunction()&amp;lt;CR&amp;gt;&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will run the tests for the current function. Typically you shouldn't &lt;em&gt;really&lt;/em&gt; need this though, since typically unit tests are be fast enough to not notice any meaningful difference between running just one vs. running all tests for a single file.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-01-01T23:47:05.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10813" PostTypeId="2" ParentId="10781" CreationDate="2017-01-02T00:41:14.883" Score="5" Body="&lt;p&gt;You can include syntax files with &lt;code&gt;syn include&lt;/code&gt;. Putting this in &lt;code&gt;~/.vim/after/syntax/haskell.vim&lt;/code&gt; seems to work fairly well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; C syntax file won't load if this is set&#xA;unlet b:current_syntax&#xA;&#xA;&quot; Load C syntax&#xA;syn include @C syntax/c.vim&#xA;&#xA;&quot; Define a syntax region which can contain C syntax&#xA;syn region haskellC keepend&#xA;    \ start=/\v(\[C\.block\|)@&amp;lt;= \w+ \{/&#xA;    \ end=/} \|]/&#xA;    \ contains=@C&#xA;&#xA;&quot; Re-set the current syntax&#xA;let b:current_syntax = 'haskell'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SGYQR.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SGYQR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-01-02T00:41:14.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10814" PostTypeId="1" CreationDate="2017-01-02T03:01:39.640" Score="6" ViewCount="267" Body="&lt;p&gt;I use a &lt;code&gt;autocmd&lt;/code&gt; to display current tag via &lt;code&gt;Tabgar&lt;/code&gt; plugin like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorHold * call TagbarCurrentTag&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, after I open &lt;code&gt;CtrlP&lt;/code&gt; with &lt;code&gt;:CtrlP&lt;/code&gt; for a while, the &lt;code&gt;Tagbar&lt;/code&gt;'s output &lt;code&gt;No current tag&lt;/code&gt; will overwrite the input area of &lt;code&gt;CtrlP&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I need to identify if I am in a &lt;code&gt;CtrlP&lt;/code&gt; buffer to avoid displaying current tag. Maybe use &lt;code&gt;filetype&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas? Thanks very much!&lt;/p&gt;&#xA;" OwnerUserId="4754" LastActivityDate="2018-08-31T16:01:13.743" Title="Identify if a buffer is CtrlP or not" Tags="|vimrc|filetype|plugin-ctrlp|plugin-tagbar|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10815" PostTypeId="2" ParentId="4975" CreationDate="2017-01-02T05:01:59.163" Score="24" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;However after adding these lines into the .vimrc, it didn't work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The reason for this is that Vim clears existing syntax items when setting the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27syntax%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'syntax'&lt;/code&gt;&lt;/a&gt; option. This is done because keeping the old syntax items would lead to some strange situations; if you have a buffer which has &lt;code&gt;syntax=foo&lt;/code&gt; and use &lt;code&gt;set syntax=bar&lt;/code&gt; then you'll end up with a buffer which has syntax highlighting for &lt;em&gt;both&lt;/em&gt; &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;bar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When Vim starts it loads your &lt;code&gt;vimrc&lt;/code&gt; once (on startup), but it loads the filetype and syntax files every time the &lt;code&gt;filetype&lt;/code&gt; or &lt;code&gt;syntax&lt;/code&gt; options are set, which will reset the values you've set in your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if it wouldn't reset it, it wouldn't be a good idea to just add it to your vimrc, since it would apply to &lt;em&gt;all&lt;/em&gt; buffers, and not just buffers with &lt;code&gt;syntax=c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The below text assumes Vim on a Unix-y system, but it will work for Neovim and Windows users as well:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;Neovim&lt;/em&gt; users should replace &lt;code&gt;~/.vim/&lt;/code&gt; with &lt;code&gt;~/.config/nvim/&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Windows&lt;/em&gt; users should replace &lt;code&gt;~/.vim/&lt;/code&gt; with &lt;code&gt;%USERPROFILE%\vimfiles\&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Overriding an entire file&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The easiest way to change something is to &lt;em&gt;just override it&lt;/em&gt;. To do so create a file in &lt;code&gt;~/.vim/&amp;lt;file&amp;gt;.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;file.vim&amp;gt;&lt;/code&gt; is the path relative to &lt;code&gt;$VIMRUNTIME&lt;/code&gt; (including subdirectories). In your example, it should be &lt;code&gt;syntax/c.vim&lt;/code&gt;. It will be loaded instead of the file in &lt;code&gt;$VIMRUNTIME&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The upshot of this is that it's easier to make changes – amending exiting syntax files can be a bit tricky sometimes. The downside is that you won't get any future updates made to the system-wide file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often use this as a &lt;em&gt;starting point&lt;/em&gt; to experiment with syntax files, and then later extract my local changes to a local addition using one of the methods described below.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Local additions&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are two ways to add local additions to syntax files, they are functionally identical, and you can use the method you prefer.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;Syntax&lt;/code&gt; autocmd&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;Syntax&lt;/code&gt; autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup ft_c&#xA;    autocmd!&#xA;    autocmd Syntax c syn match cFunction &quot;\&amp;lt;[a-zA-Z_][a-zA-Z_0-9]*\&amp;gt;[^()]*)(&quot;me=e-2 &#xA;    autocmd Syntax c syn match cFunction &quot;\&amp;lt;[a-zA-Z_][a-zA-Z_0-9]*\&amp;gt;\s*(&quot;me=e-1 &#xA;    autocmd Syntax c hi cFunction gui=NONE guifg=#B5A1FF&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that chaining several commands with &lt;code&gt;|&lt;/code&gt; is problematic here, since they tend to get interpreted as part of the &lt;code&gt;:syn&lt;/code&gt; command, which is why I've repeated the &lt;code&gt;autocmd Syntax c&lt;/code&gt; several times. An alternative would be to use a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun s:c()&#xA;    syn match cFunction &quot;\&amp;lt;[a-zA-Z_][a-zA-Z_0-9]*\&amp;gt;[^()]*)(&quot;me=e-2 &#xA;    syn match cFunction &quot;\&amp;lt;[a-zA-Z_][a-zA-Z_0-9]*\&amp;gt;\s*(&quot;me=e-1 &#xA;    hi cFunction gui=NONE guifg=#B5A1FF&#xA;endfun&#xA;&#xA;augroup ft_c&#xA;  autocmd!&#xA;  autocmd Syntax c call s:c()&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The advantage is that all changes can be contained to a single file. The disadvantage is that it's a bit ugly, especially if you have a lot of changes.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;after directory&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Use the after-directory: &lt;code&gt;~/.vim/after/&amp;lt;file&amp;gt;.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will be loaded after &lt;code&gt;&amp;lt;file&amp;gt;.vim&lt;/code&gt; has, where &lt;code&gt;&amp;lt;file.vim&amp;gt;&lt;/code&gt; is the path relative to &lt;code&gt;$VIMRUNTIME&lt;/code&gt; (including subdirectories). In your example, it should be &lt;code&gt;syntax/c.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#after%2ddirectory&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help after-directory&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage is that it's a bit more readable than the autocmd, especially if you have many changes. The disadvantage is that you'll need to copy over an additional file if you want to mirror your Vim setup to different machines (this is an important reason many people keep their Vim files in a GitHub repo, so it can be easily mirrored across machines).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2018-08-22T10:47:54.917" LastActivityDate="2018-08-22T10:47:54.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10816" PostTypeId="2" ParentId="5348" CreationDate="2017-01-02T05:38:51.613" Score="10" Body="&lt;p&gt;As mentioned, all of the clientserver features were removed in Neovim. This is because they use the X11 shared memory and Neovim removed X11 support.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I use &lt;code&gt;:help --servername&lt;/code&gt; in Neovim I end up in the documentation for &#xA;the &lt;code&gt;serverstart()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;serverstart([{address}])                                serverstart()&#xA;                Opens a named pipe or TCP socket at {address} for clients to&#xA;                connect to and returns {address}. If no address is given, it&#xA;                is equivalent to:&#xA;                        :call serverstart(tempname())&#xA;                $NVIM_LISTEN_ADDRESS is set to {address} if not already set.&#xA;                                                        --servername&#xA;                The Vim command-line option --servername can be imitated:&#xA;                        nvim --cmd &quot;let g:server_addr = serverstart('foo')&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will make a socket in &lt;code&gt;/tmp/&lt;/code&gt;; see &lt;code&gt;:echo v:servername&lt;/code&gt; for the path. It's probably more useful to use a more deterministic address (e.g. &lt;code&gt;serverstart('/tmp/nvim-remote')&lt;/code&gt;; although you'll probably want to wrap this in a function, as it won't append a number like Vim's &lt;code&gt;--serverstart&lt;/code&gt; does if this already exists).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can send commands with the RPC API. As far as I can find there is no way to send commands to this with just Neovim (meh). You'll need to install &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Related-projects#api-clients&quot; rel=&quot;noreferrer&quot;&gt;one of the API clients&lt;/a&gt;. For example with the reference Python API client (which is also what Neovim remote uses):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import neovim&#xA;nvim = neovim.attach('socket', path='/tmp/nvim-remote')&#xA;try:&#xA;    nvim.command(':e foo')&#xA;finally:&#xA;    nvim.quit()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can probably send the same bytes with a &lt;code&gt;echo ... &amp;gt;&amp;gt; /tmp/nvim-remove&lt;/code&gt; shell command, but the RPC API uses a somewhat non-trivial non-text protocol (&quot;MessagePack RPC&quot;) and figuring out which bytes to send exactly was a bit too much effort for this post ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help rpc&lt;/code&gt; for the full details on Neovim's RPC API.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;N.B. &lt;code&gt;:help remote.txt&lt;/code&gt; as well as many other help items (such as &lt;code&gt;help server2client()&lt;/code&gt; and many more) still exists in Neovim, but none of that works. It looks like whoever removed this feature did a pretty sloppy job.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-01-02T05:38:51.613" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10817" PostTypeId="1" AcceptedAnswerId="10827" CreationDate="2017-01-02T06:52:08.617" Score="66" ViewCount="47743" Body="&lt;p&gt;Ubuntu's packages can be pretty old, but for some desktop programs (like Vim) I'd much rather have the latest version, as newer versions often fix various bugs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get a reasonably recent Vim version on Ubuntu?&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-12-14T06:08:49.457" Title="How can I get a newer version of Vim on Ubuntu?" Tags="|installing|linux-ubuntu|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10818" PostTypeId="2" ParentId="10809" CreationDate="2017-01-02T06:52:41.930" Score="4" Body="&lt;p&gt;This works correctly for me with Vim 8.0.86, but I also get the broken behaviour if I compile Vim 7.4.1689 on my system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;git bisect&lt;/code&gt; I found that this problem is fixed with &lt;a href=&quot;https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12&quot; rel=&quot;nofollow noreferrer&quot;&gt;version 7.4.1976&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Problem:    Number variables are not 64 bits while they could be.&#xA;Solution:   Add the num64 feature. (Ken Takata)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So to get this to work you'll need at least version 7.4.1976 compiled with the &lt;code&gt;num64&lt;/code&gt; feature (always enabled on 64 bit systems).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Honestly, I'm not an Ubuntu expert and don't have an Ubuntu system available to test. Whenever I've wanted a newer version I just compiled it from source, but I think there are easier ways.&lt;br&gt;&#xA;I asked a new question on &lt;a href=&quot;https://vi.stackexchange.com/q/10817/51&quot;&gt;How to get a newer version of Vim on Ubuntu&lt;/a&gt;; I suggest you use one of the answers that will (hopefully) be posted there, but as a &quot;preview&quot;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can try installing Vim from the &lt;a href=&quot;https://packages.debian.org/sid/vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Debian unstable repo&lt;/a&gt;, which is much more up-to-date. According to &lt;a href=&quot;https://askubuntu.com/q/264764/255332&quot;&gt;this Ask Ubuntu question&lt;/a&gt; it can be dangerous though, so proceed with caution.&lt;/li&gt;&#xA;&lt;li&gt;There also seem to be some ppa's with newer Vim versions. It's up to you if you want to trust random people though (I personally wouldn't). &lt;a href=&quot;https://encrypted.google.com/search?hl=en&amp;amp;q=Ubuntu%20how%20can%20I%20get%20a%20newer%20Vim%20version&quot; rel=&quot;nofollow noreferrer&quot;&gt;See Google to find some of them&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Installing and compiling Vim from source is also pretty easy. It's just the basic &lt;code&gt;./configure; make; sudo make install&lt;/code&gt; routine (you will have to install a C compiler and various &lt;code&gt;*-dev&lt;/code&gt; packages though). The &lt;a href=&quot;http://vim.wikia.com/wiki/Building_Vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim wiki&lt;/a&gt; has some instructions for that (I didn't test it and it may be incorrect/outdated), and there is a &lt;a href=&quot;https://vi.stackexchange.com/a/8979/51&quot;&gt;question with some instructions for Debian&lt;/a&gt; which will &lt;em&gt;probably&lt;/em&gt; also work for Ubuntu.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-01-02T07:30:36.227" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10820" PostTypeId="2" ParentId="10799" CreationDate="2017-01-02T09:27:01.953" Score="3" Body="&lt;p&gt;You've already found how to highlight these types from the link you've posted in your question; by adding these lines to &lt;code&gt;after/syntax/c/winapi.vim&lt;/code&gt; (see &lt;a href=&quot;https://vi.stackexchange.com/a/10815/51&quot;&gt;How can I add additional syntax highlighting rules in my local vimrc?&lt;/a&gt; for more details on that):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword cppWINAPI SetWindowLong&#xA;syn keyword cppWINAPIConst WM_CREATE&#xA;syn keyword cppWINAPItype HGLOBAL&#xA;&#xA;hi def link cppWINAPI Identifier&#xA;hi def link cppWINAPItype Type&#xA;hi def link cppWINAPIConst Constant&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So all we need to do now is to populate this list with additional function, constants, and types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I found this &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/windows/apps/dn424765.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;Alphabetical list of Win32 and COM API in Windows 8.x apps&lt;/a&gt;. With some JS-fu in my console I got a space-separated list of all the functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$('#mainSection li a strong')&#xA;    .map(function() { return $(this).html() })&#xA;    .toArray()&#xA;    .join(' ')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which I then copied &amp;amp; pasted in the &lt;code&gt;after/syntax/c/winapi.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword cppWINAPI _IRDPSessionEvents AcquireSRWLockExclusive [..etc..]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't separate out functions, constants, and types though; and I have no idea how complete it is. But this is the basic procedure to make such a file. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want a more complete list then you can perhaps try using one of the answers in &lt;a href=&quot;https://stackoverflow.com/q/1128150/660921&quot;&gt;Win32 API to enumerate dll export functions?&lt;/a&gt; to export the information from the WinAPI libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also the &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/ff818516(v=vs.85).aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;Windows API Index&lt;/a&gt;. It's split over a whole bunch of pages, but the layout seems fairly consistent. Extracting that would require a script and some work, but is probably doable.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-01-02T09:27:01.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10821" PostTypeId="1" AcceptedAnswerId="10822" CreationDate="2017-01-02T09:37:33.433" Score="10" ViewCount="2030" Body="&lt;p&gt;I am comparing a couple of files with &lt;code&gt;vimdiff&lt;/code&gt;. There are some differences which I expect and which I'd like to get rid of. I know I can use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s#from1#to1#g | %s#from2#to2#g | ...&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to replace multiple expected differences at the same time. However, the 2nd substitution is only executed if the first succeeds; i.e. &lt;code&gt;from1&lt;/code&gt; must be present in the file in order to replace &lt;code&gt;from2&lt;/code&gt;, too (I get &lt;code&gt;E486: Pattern not found: from1&lt;/code&gt; and &lt;code&gt;from2&lt;/code&gt; still exits). Can I specify multiple optional substitutions that all should be executed? I imagine some option for &lt;code&gt;|&lt;/code&gt; to behave like an &lt;code&gt;or&lt;/code&gt; instead of an &lt;code&gt;and&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to do this interactively because the expected differences differ among various files and I don't exactly know them in advance.&lt;/p&gt;&#xA;" OwnerUserId="6357" LastEditorUserId="755" LastEditDate="2017-01-02T16:17:27.340" LastActivityDate="2017-01-02T16:17:27.340" Title="How can I execute multiple optional substitute commands in one line?" Tags="|substitute|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10822" PostTypeId="2" ParentId="10821" CreationDate="2017-01-02T09:40:47.990" Score="12" Body="&lt;p&gt;Add the &lt;code&gt;e&lt;/code&gt; flag to your &lt;code&gt;:s&lt;/code&gt; commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s#from1#to1#ge | %s#from2#to2#ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the flag's entry at &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3as_flags&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :s_flags&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[e]     When the search pattern fails, do not issue an error message and, in&#xA;        particular, continue in maps as if no error occurred.  This is most&#xA;        useful to prevent the &quot;No match&quot; error from breaking a mapping.  Vim&#xA;        does not suppress the following error messages, however:&#xA;                Regular expressions can't be delimited by letters&#xA;                \ should be followed by /, ? or &amp;amp;&#xA;                No previous substitute regular expression&#xA;                Trailing characters&#xA;                Interrupted&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A second option would be to use &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3asilent%21&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:silent!&lt;/code&gt;&lt;/a&gt; to suppress error messages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent! %s#from1#to1#g | :silent! %s#from2#to2#g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will suppress &lt;em&gt;all&lt;/em&gt; output and errors though, so the &lt;code&gt;e&lt;/code&gt; flag is probably better for &lt;code&gt;:substitute&lt;/code&gt; commands, but using &lt;code&gt;:silent!&lt;/code&gt; is useful if you want to suppress &lt;em&gt;all&lt;/em&gt; errors and for other commands.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-01-02T10:54:56.833" LastActivityDate="2017-01-02T10:54:56.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10823" PostTypeId="1" AcceptedAnswerId="10831" CreationDate="2017-01-02T16:02:30.393" Score="2" ViewCount="521" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ebU1J.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ebU1J.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;echo ${2:-&quot;-l -p&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Having some bash parameter-substitution fun and (Neo) Vim complains about it, while the code is perfectly fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can suppress errors totally by doing sort of like &lt;code&gt;hi Error ctermbg=None&lt;/code&gt;, but that's quick and dirty. (I can live with the red background, but it's ugly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did &lt;code&gt;:h error&lt;/code&gt; [[ press Tab 20 times ]], but didn't find anything interesting about the topic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I fix (or should I report) such misbehaviour?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pure Vim highlights the same way, running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -c &quot;set nocp | set filetype=sh | syn on&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 15 2016 18:06:04)&#xA;Included patches: 1-86&#xA;Compiled by Arch Linux&#xA;Huge version without GUI.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doesn't work in urxvt. Neither in neo nor pure Vim.&lt;br&gt;&#xA;Doesn't work in NeoVim. Neither in urxvt nor xterm.&lt;br&gt;&#xA;Works only in xterm, pure Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;works == no red background, I mean&lt;br&gt;&#xA;All of the above happens with &lt;code&gt;-u NONE&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3280" LastEditorUserId="51" LastEditDate="2017-01-03T18:49:54.827" LastActivityDate="2017-06-06T15:20:19.940" Title="Vim highlights valid shell parameter expansion syntax as an error" Tags="|syntax-highlighting|neovim|filetype-sh|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10824" PostTypeId="1" CreationDate="2017-01-03T08:55:41.620" Score="5" ViewCount="3639" Body="&lt;p&gt;I don't understand the &lt;code&gt;findfile()&lt;/code&gt; function in Vim-Script, what am i doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding = utf-8&#xA;cd %:p:h&#xA;let b:gitiginorfiles = findfile('.gitignore', system('git rev-parse --show-toplevel'), -1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My variable &lt;code&gt;b:gitignorefiles&lt;/code&gt; is always empty.&lt;/p&gt;&#xA;" OwnerUserId="9527" LastEditorUserId="1841" LastEditDate="2017-01-03T08:58:00.823" LastActivityDate="2017-01-03T12:33:13.093" Title="How does the findfile() function work?" Tags="|vimscript|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10825" PostTypeId="2" ParentId="10824" CreationDate="2017-01-03T10:26:02.773" Score="2" Body="&lt;p&gt;Vim documentation is the best point to start. &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#findfile%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help findfile()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;findfile({name}[, {path}[, {count}]])               *findfile()*&#xA;        Just like |finddir()|, but find a file instead of a directory.&#xA;        Uses 'suffixesadd'.&#xA;        Example: &amp;gt;&#xA;            :echo findfile(&quot;tags.vim&quot;, &quot;.;&quot;)&#xA;        Searches from the directory of the current file upwards until&#xA;        it finds the file &quot;tags.vim&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;]&lt;/kbd&gt; to navigate into links, such as &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#finddir%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;|finddir()|&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;finddir({name}[, {path}[, {count}]])                *finddir()*&#xA;        Find directory {name} in {path}.  Supports both downwards and&#xA;        upwards recursive directory searches.  See |file-searching|&#xA;        for the syntax of {path}.&#xA;        Returns the path of the first found match.  When the found&#xA;        directory is below the current directory a relative path is&#xA;        returned.  Otherwise a full path is returned.&#xA;        (...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can debug that call using this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo findfile('.gitignore', system('git rev-parse --show-toplevel'), -1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will run the &lt;code&gt;findfile()&lt;/code&gt; and echo the result in the screen.&#xA;You can &lt;a href=&quot;http://vimhelp.appspot.com/usr_20.txt.html#20.5&quot; rel=&quot;nofollow noreferrer&quot;&gt;use &lt;code&gt;q:&lt;/code&gt;&lt;/a&gt; to edit the call and test again.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try to understand it better by using simple examples. For instance, try to search for a nonexistent file in the current direct, then create the file and repeat:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo findfile('bla', .)   &quot; empty result, no file&#xA;!touch bla                &quot; create the file (this works in *nix systems)&#xA;echo findfile('bla', &quot;.&quot;) &quot; now it returns a non-empty result&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can check that you are in the directory you expect by using &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3apwd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:pwd&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getcwd%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getcwd()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2017-01-03T10:46:59.023" LastActivityDate="2017-01-03T10:46:59.023" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10826" PostTypeId="2" ParentId="10824" CreationDate="2017-01-03T10:45:39.850" Score="5" Body="&lt;p&gt;I need to chomp the trailing newline to see the line work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo findfile('.gitignore', system('git rev-parse --show-toplevel')[:-2], -1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a recurring problem with &lt;code&gt;system()&lt;/code&gt;. I did rapidly end-up with a first version of &lt;code&gt;system()&lt;/code&gt; in my library plugin that always chomps these unwanted characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Otherwise, don't hesitate to extract intermediary result into variables that you'll be able to investigate. Often, I check what I really compute with a &lt;code&gt;:echo .'##'.myvar.'##'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-01-03T12:33:13.093" LastActivityDate="2017-01-03T12:33:13.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10827" PostTypeId="2" ParentId="10817" CreationDate="2017-01-03T10:46:01.047" Score="85" Body="&lt;p&gt;You have three different options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Wait for the newest versions to be added to the distribution packages. Note that you might want to learn a new language or build a ship with your bare hands while you wait. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If waiting several years is not good for you then you have the following two options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a PPA containing the latest version:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pros:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Easy to do.&lt;/li&gt;&#xA;&lt;li&gt;Totally automated.&lt;/li&gt;&#xA;&lt;li&gt;Let you install Vim as any other software.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Cons:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You basically grant root privileges to a complete stranger.&lt;/li&gt;&#xA;&lt;li&gt;This method only works on Ubuntu and the derived distributions using PPA system.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Build Vim from sources:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pros:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You get a fine tuning of the options you enable (gui, Python/Lua support, etc.).&lt;/li&gt;&#xA;&lt;li&gt;You get the bleeding edge version and don't need any third party maintainer to get it.&lt;/li&gt;&#xA;&lt;li&gt;It's always useful to learn how to compile a software from sources.&lt;/li&gt;&#xA;&lt;li&gt;This is a distribution agnostic method.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Cons:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Not as automated as the PPA option.&lt;/li&gt;&#xA;&lt;li&gt;Can be frightening for a new user.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In two latter cases, here is a procedure for these options:&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;PPA&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here is an online tutorial on &lt;a href=&quot;http://tipsonubuntu.com/2016/09/13/vim-8-0-released-install-ubuntu-16-04/&quot; rel=&quot;noreferrer&quot;&gt;tipsonubuntu.com&lt;/a&gt; (Thanks @joeytwiddle who suggested it in the comments).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First open a terminal and use the following command. This will add the Personal Packet Archive (PPA) maintained by joathonf to you repos and let Ubuntu know where to look for Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo add-apt-repository ppa:jonathonf/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I'll repeat here that doing this give the root privileges to the scripts in this PPA, do it only if you trust it&lt;/em&gt;. You may want to read &lt;a href=&quot;https://askubuntu.com/q/35629/255332&quot;&gt;are PPA's safe to add to my system and what are some “red flags” to watch out for?&lt;/a&gt; and &lt;a href=&quot;https://askubuntu.com/q/7662/255332&quot;&gt;is there any guarantee that software from Launchpad PPAs is free from viruses and backdoor threats?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update the packet list so Ubuntu will look in the PPA to find the Vim files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally install vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt install vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And tada! Vim is installed. Note that you can also do that from the GUI package manager.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this is not the only PPA available with newer Vim versions, you can use your favourite search engine to find more (and &lt;em&gt;do&lt;/em&gt; remember you are trusting some stranger from the internet with root access to your system).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Building from sources&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A second option is to build Vim from sources. This implies some additional manipulation and can be frightening for a new user, but it is the best way to get the lasted build.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several online resources to guide you through this procedure:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/git.php&quot; rel=&quot;noreferrer&quot;&gt;The official Vim's website&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;The plugin YouCompleteMe has &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&quot; rel=&quot;noreferrer&quot;&gt;a really complete wiki page&lt;/a&gt; with a detailed installation procedure which can be interesting from some corner cases.&lt;/li&gt;&#xA;&lt;li&gt;Wikia also &lt;a href=&quot;http://vim.wikia.com/wiki/Building_Vim&quot; rel=&quot;noreferrer&quot;&gt;has a page about that&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A general procedure is the following, you might need to tweak it to fit your needs but the main idea is here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you might need to install some dependencies. For example use this command (suggested by YouCompleteMe wiki):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get update&#xA;sudo apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \&#xA;    libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \&#xA;    libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \&#xA;    python3-dev ruby-dev lua5.1 lua5.1-dev libperl-dev git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note that you maybe won't need everything: for example if you won't use Lua, do not include &lt;code&gt;lua5.1-dev&lt;/code&gt; to the list&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; Instead of using the previous &lt;code&gt;apt-get install&lt;/code&gt; command you can use the following. It has the advantage of automatically handling the dependencies you need:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get build-dep vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then get the sources on your computer (you'll need the &lt;code&gt;git&lt;/code&gt; command installed with &lt;code&gt;apt-get install git&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/vim/vim.git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Go to this directory and 'pull' the last changes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd vim&#xA;git pull&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;If you have an error on &lt;code&gt;git pull&lt;/code&gt; because you already made changes you can 'stash' your modifications (i.e. remove them temporarily), pull the changes and then restore your modifications. If you did so I'll assume that you are familiar with git and won't provide the procedure to follow (it is detailed in the vim.org doc).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then build Vim as you would build any other software from sources. The file &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/INSTALL&quot; rel=&quot;noreferrer&quot;&gt;src/INSTALL&lt;/a&gt; should provide you with the information you need to compile Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A regular workflow would begin with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --with-features=huge --enable-gui=auto&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Remove &lt;code&gt;--enable-gui&lt;/code&gt; if you don't want gVim&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have root access on the machine you're installing Vim, you might want to add the &lt;code&gt;--prefix&lt;/code&gt; option which allows you to use a directory where you have access rights. For example you could use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --with-features=huge --enable-gui=auto --prefix=$HOME/local/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;configure&lt;/code&gt; script can take a lot of arguments to tune which features you want to enable. Running it takes a while.  While running, it prints messages telling which features it is checking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once it is configured, you can compile the program with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An optional command exists to run some self-checks (&lt;em&gt;don't ask me what they do exactly I always skip them :-)&lt;/em&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make check&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally install Vim to &lt;code&gt;/usr/local/&lt;/code&gt; (this command requires the root privileges):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo make install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To remove the now useless files which were created for the compilation you can then run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make clean&#xA;make distclean&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here you are with a fresh Vim install.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will probably want to remove any Vim you've installed from the Ubuntu repo, but you don't &lt;em&gt;need&lt;/em&gt; to. By default, Vim will install to &lt;code&gt;/usr/local/&lt;/code&gt;, rather than &lt;code&gt;/usr/&lt;/code&gt;. Just make sure you're running the correct Vim version (i.e. &lt;code&gt;/usr/local/bin/vim&lt;/code&gt;, and not &lt;code&gt;/usr/bin/vim&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="16789" LastEditDate="2018-03-20T08:02:47.227" LastActivityDate="2018-03-20T08:02:47.227" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10828" PostTypeId="1" AcceptedAnswerId="10830" CreationDate="2017-01-03T14:29:03.010" Score="16" ViewCount="11111" Body="&lt;p&gt;How does one select from the current line to the next empty line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware of &lt;kbd&gt;SHIFT&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; but then I have to either jump to the next empty line or press the down key a bunch of times.  I know how to do this well when there's a matching character like a &lt;code&gt;}&lt;/code&gt; but I have no idea how to do this for an empty line.&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="10693" LastEditDate="2017-01-03T15:47:55.663" LastActivityDate="2019-01-22T20:26:02.727" Title="Visual select from cursor to next empty line?" Tags="|visual-mode|visual-block|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10829" PostTypeId="2" ParentId="10828" CreationDate="2017-01-03T15:05:49.543" Score="16" Body="&lt;p&gt;A shortcut for next empty line is &lt;kbd&gt;}&lt;/kbd&gt;.&#xA;So you just might want to use &lt;kbd&gt;SHIFT&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;}&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="10693" LastEditorUserId="10693" LastEditDate="2017-01-03T15:14:33.103" LastActivityDate="2017-01-03T15:14:33.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10830" PostTypeId="2" ParentId="10828" CreationDate="2017-01-03T15:27:00.957" Score="27" Body="&lt;p&gt;Vim understands the concept of a &quot;paragraph&quot;. Vim's definition of a paragraph is a block of text surrounded by blank lines&lt;sup&gt;*&lt;/sup&gt;. There are several motions and text objects to work with this.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[count]}&lt;/code&gt; – Move &lt;code&gt;[count]&lt;/code&gt; paragraphs forward. You can use &lt;code&gt;&amp;lt;S-v&amp;gt;}&lt;/code&gt; to select all lines from the current line to the next blank line. This will include the blank line, so you may want to use &lt;code&gt;&amp;lt;S-v&amp;gt;}k&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[count]ip&lt;/code&gt; – Select &lt;code&gt;[count]&lt;/code&gt; paragraphs. It's like &lt;code&gt;iw&lt;/code&gt; (inner word) except for, well, paragraphs. Using &lt;code&gt;vip&lt;/code&gt; will select &lt;em&gt;all&lt;/em&gt; of the paragraph though, rather than from the current line to the end of the paragraph.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[count]ap&lt;/code&gt; – like &lt;code&gt;ip&lt;/code&gt;, except that this will include the blank lines surrounding the paragraph.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;One caveat here is that Vim &lt;em&gt;doesn't&lt;/em&gt; consider a line with only whitespace as a &quot;blank line&quot;. So make sure to check this (e.g. with &lt;code&gt;:set list&lt;/code&gt;) if it doesn't appear to work.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also remember you can always &lt;em&gt;search&lt;/em&gt; for the pattern you want. You can get an empty line with &lt;code&gt;/^$&lt;/code&gt;; or if you don't want to select the empty line itself you can use &lt;code&gt;\n\n&lt;/code&gt; to put the cursor at the end of the line before the first blank line:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;S-v&amp;gt;/^$&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;S-v&amp;gt;/\n\n&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;*&lt;/sup&gt; There are some exceptions, see &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#paragraph&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help paragraph&lt;/code&gt;&lt;/a&gt; for the full logic. But for most intents and purposes this definition works fine.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-01-03T15:27:00.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10831" PostTypeId="2" ParentId="10823" CreationDate="2017-01-03T18:29:10.073" Score="3" Body="&lt;p&gt;Vim also &lt;em&gt;used&lt;/em&gt; to display this as an error, but the latest version no longer does. It looks like the syntax file for Vim has been updated in a fairly recent version Vim, which isn't in Neovim yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I downloaded the Vim source and did:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git checkout v7.4.1900&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get an older Vim version. We're only interested in the syntax file (&lt;code&gt;runtime/syntax/sh.vim&lt;/code&gt;) so we don't need to re-compile Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After opening a simple &lt;code&gt;a.sh&lt;/code&gt; file which contains &lt;code&gt;echo ${2:-&quot;-l -p&quot;}&lt;/code&gt; I did:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:unlet b:current_syntax&#xA;:source /home/martin/src/vim/runtime/syntax/sh.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to load the Vim 7.4.1900 syntax file from the source tree, and now I have the same red text as you do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now we need to isolate the patch that fixes this. Unfortunately the git commits for runtime directories don't contain a helpful description (just &quot;update runtime directory&quot;) but we know that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;v8.0.0142 does &lt;em&gt;not&lt;/em&gt; have this problem;&lt;/li&gt;&#xA;&lt;li&gt;v7.4.1900 &lt;em&gt;does&lt;/em&gt; have this problem;&lt;/li&gt;&#xA;&lt;li&gt;that the fix is in &lt;code&gt;runtime/syntax/sh.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Checking the &lt;a href=&quot;https://github.com/vim/vim/commits/master/runtime/syntax/sh.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;history for that file&lt;/a&gt; we see there aren't that many recent changes, so I simply did &lt;code&gt;git checkout &amp;lt;commit-id&amp;gt;&lt;/code&gt; until I managed to reproduce the problem. The commit after that one will have fixed the problem, which is &lt;a href=&quot;https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5#diff-3684eb3d10603a1e201bf60108720b02&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;e4a3bcf&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if you look at the diff, we see a number of changes to the &lt;code&gt;shDeref*&lt;/code&gt; syntax groups, which seem fix the error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two things you can do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Copy the latest &lt;code&gt;syntax/sh.vim&lt;/code&gt; from the Vim source to to &lt;code&gt;~/.config/nvim/syntax/sh.vim&lt;/code&gt; (Neovim) or &lt;code&gt;~/.vim/syntax/sh.vim&lt;/code&gt; (Vim) so it will override the default. Neovim doesn't seem to have &lt;a href=&quot;https://github.com/neovim/neovim/commits/master/runtime/syntax/sh.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;made any changes to this file&lt;/a&gt;, so you won't lose anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The downside of this is that you won't get any future updates made to the system-wide &lt;code&gt;syntax/sh.vim&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can also try to locally amend the &lt;code&gt;syntax/sh.vim&lt;/code&gt; file with just the fixes &lt;a href=&quot;https://vi.stackexchange.com/q/4975/51&quot;&gt;using the after directory&lt;/a&gt;. This will take more time, but you will get future updates made to the system-wide &lt;code&gt;syntax/sh.vim&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-01-03T18:40:01.550" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10832" PostTypeId="1" CreationDate="2017-01-03T19:26:44.690" Score="5" ViewCount="460" Body="&lt;p&gt;I have this in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function HeaderTpl(fchar, boxchar, width)&#xA;    let sfile = expand(&quot;%:p&quot;)&#xA;    return a:fchar . &quot; &quot; . repeat(a:boxchar, a:width) . &quot;\n&quot;&#xA;            \ . a:fchar . &quot; &quot; . sfile . &quot;\n&quot;&#xA;            \ . a:fchar . &quot;\n&quot;&#xA;            \ . a:fchar . &quot; &quot; . strftime(&quot;%FT%T %z&quot;) . &quot;\n&quot;&#xA;            \ . a:fchar . &quot; &quot; . repeat(a:boxchar, a:width) . &quot;\n&quot;&#xA;endfunction&#xA;&#xA;imap &amp;lt;silent&amp;gt;  ###  &amp;lt;C-R&amp;gt;=HeaderTpl('#', '-', 71)&amp;lt;CR&amp;gt;&#xA;imap &amp;lt;silent&amp;gt;  ///  &amp;lt;C-R&amp;gt;=HeaderTpl('//', '-', 70)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works almost perfectly as if I type &lt;code&gt;###&lt;/code&gt; in blank file I get this header&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# -----------------------------------------------------------------------&#xA;# /path/to/current/file.conf&#xA;#&#xA;# 2017-01-03T20:02:50 +0100&#xA;# -----------------------------------------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but if the file type is defined (something like &lt;code&gt;vim python_script.py&lt;/code&gt;) then I get something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# -----------------------------------------------------------------------&#xA;# # /path/to/current/file.conf&#xA;# #&#xA;# # 2017-01-03T20:02:50 +0100&#xA;# # -----------------------------------------------------------------------&#xA;#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think that additional &lt;code&gt;#&lt;/code&gt; is caused by the &lt;code&gt;autoindent&lt;/code&gt; or &lt;code&gt;smartindent&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question: how do I prevent this additional &lt;code&gt;#&lt;/code&gt; to be inserted? One of my ideas was to temporary switch off &lt;code&gt;autoindent&lt;/code&gt; and &lt;code&gt;smartindent&lt;/code&gt; but how to do it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)&#xA;Included patches: 1-1689&#xA;Extra patches: 8.0.0056&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10699" LastEditorUserId="51" LastEditDate="2017-01-03T22:36:53.407" LastActivityDate="2017-01-03T22:36:53.407" Title="How can I insert text from a function without triggering autoinsertion of comments?" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10833" PostTypeId="2" ParentId="10832" CreationDate="2017-01-03T20:08:48.160" Score="4" Body="&lt;p&gt;This is caused by the &lt;code&gt;r&lt;/code&gt; flag in &lt;code&gt;formatoptions&lt;/code&gt;. See &lt;a href=&quot;https://vi.stackexchange.com/q/1983/51&quot;&gt;How can I get vim to stop putting comments in front of new lines?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to fix it is to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Check if &lt;code&gt;r&lt;/code&gt; is in &lt;code&gt;formatoptions&lt;/code&gt; (with &lt;code&gt;stridx(&amp;amp;formatoptions, 'r')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Remove it from &lt;code&gt;formatoptions&lt;/code&gt; if it is with &lt;code&gt;set formatoptions-=r&lt;/code&gt; and storing a local variable to track if it was set.&lt;/li&gt;&#xA;&lt;li&gt;Add it back with &lt;code&gt;set formatoptions+=r&lt;/code&gt; at the end if it was set.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As mentioned in the comments, you can also use the &lt;code&gt;paste&lt;/code&gt; option to avoid some other side-effects that may occur.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this method won't work very well with your insert mode mapping, since that relies on the return value of the function. It &lt;em&gt;can&lt;/em&gt; be done, but a better way is probably to use &lt;code&gt;setline()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HeaderTpl(fchar, boxchar, width)&#xA;    let sfile = expand(&quot;%:p&quot;)&#xA;    call setline('.', [a:fchar . &quot; &quot; . repeat(a:boxchar, a:width),&#xA;        \ a:fchar . &quot; &quot; . sfile,&#xA;        \ a:fchar,&#xA;        \ a:fchar . &quot; &quot; . strftime(&quot;%FT%T %z&quot;),&#xA;        \ a:fchar . &quot; &quot; . repeat(a:boxchar, a:width)&#xA;    \ ])&#xA;&#xA;    return ''&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;silent&amp;gt; ### &amp;lt;C-R&amp;gt;=HeaderTpl('#', '-', 71)&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;silent&amp;gt; /// &amp;lt;C-R&amp;gt;=HeaderTpl('//', '-', 70)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;setline()&lt;/code&gt; will set the line in the first argument to the text in the second argument. &lt;code&gt;.&lt;/code&gt; refers to the current line. You can set multiple lines by passing a list (using &lt;code&gt;\n&lt;/code&gt; won't work).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-01-03T20:08:48.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10834" PostTypeId="1" CreationDate="2017-01-03T21:49:33.313" Score="3" ViewCount="529" Body="&lt;p&gt;I'm thinking about exchanging some keys while in non insert-mode so that the bindings that I use most are easier to reach (i.e. on the home row).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I swap two keys without breaking the behaviors of my plugins' bindings ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tim Pope's surround plugin&lt;/a&gt; uses the &lt;code&gt;s&lt;/code&gt; key so that the following is a valid command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cs&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I exchange &lt;code&gt;s&lt;/code&gt; with &lt;code&gt;a&lt;/code&gt; so that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;s&lt;/code&gt; in normal mode enters insert mode in the same manner that &lt;code&gt;a&lt;/code&gt; did before the exchange, and&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ca&quot;'&lt;/code&gt; performs the same action as &lt;code&gt;cs&quot;'&lt;/code&gt; did before the exchange?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I googled about &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;noremap&lt;/code&gt;, &lt;code&gt;after&lt;/code&gt; and &lt;code&gt;autocmd VimEnter *&lt;/code&gt; but still don't understand which one is appropriate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In other words, how can I have a second keyboard layout, valid in normal (visual) mode but not in insert mode ?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="10700" LastActivityDate="2017-01-04T16:20:03.870" Title="How do I swap key bindings without breaking plugins?" Tags="|vimrc|key-bindings|keyboard-layout|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10835" PostTypeId="2" ParentId="7116" CreationDate="2017-01-03T23:55:57.917" Score="2" Body="&lt;p&gt;This is actually pretty tricky to do. I've been using the vim-go plugin for a while&lt;sup&gt;*&lt;/sup&gt;, which has the same problems as described in the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, looking at &lt;a href=&quot;https://github.com/fatih/vim-go/blob/master/autoload/go/fmt.vim#L28&quot; rel=&quot;nofollow noreferrer&quot;&gt;the source&lt;/a&gt; I found that I can set a &lt;code&gt;g:go_fmt_experimental&lt;/code&gt; to enable some code which attempts to fix this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a modified version which removes some of the Go specific stuff and vim-go utility functions, so it can be reused for other formatters and such. It also avoids having to use a temporary file for the unsaved buffer by using &lt;code&gt;stdin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the comments for details as to how this works. It's also not perfect, since not everything is always restored (again, see the comments). But it looks like this is the best that's possible at the moment.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Adapted from vim-go: https://github.com/fatih/vim-go/blob/master/LICENSE&#xA;&quot;&#xA;&quot;  we have those problems :&#xA;&quot;  http://stackoverflow.com/questions/12741977/prevent-vim-from-updating-its-undo-tree&#xA;&quot;  http://stackoverflow.com/questions/18532692/golang-formatter-and-vim-how-to-destroy-history-record?rq=1&#xA;&quot;&#xA;&quot;  The below function is an improved version that aims to fix all problems.&#xA;&quot;  it doesn't undo changes and break undo history.  If you are here reading&#xA;&quot;  this and have VimL experience, please look at the function for&#xA;&quot;  improvements, patches are welcome :)&#xA;function! s:write_cmd(cmd) abort&#xA;    &quot; Using winsaveview to save/restore cursor state has the problem of&#xA;    &quot; closing folds on save:&#xA;    &quot;   https://github.com/fatih/vim-go/issues/502&#xA;    &quot; One fix is to use mkview instead. Unfortunately, this sometimes causes&#xA;    &quot; other bad side effects:&#xA;    &quot;   https://github.com/fatih/vim-go/issues/728&#xA;    &quot; and still closes all folds if foldlevel&amp;gt;0:&#xA;    &quot;   https://github.com/fatih/vim-go/issues/732&#xA;    let l:curw = {}&#xA;    try&#xA;        mkview!&#xA;    catch&#xA;        let l:curw = winsaveview()&#xA;    endtry&#xA;&#xA;    &quot; save our undo file to be restored after we are done. This is needed to&#xA;    &quot; prevent an additional undo jump due to BufWritePre auto command and also&#xA;    &quot; restore 'redo' history because it's getting being destroyed every&#xA;    &quot; BufWritePre&#xA;    let tmpundofile = tempname()&#xA;    exe 'wundo! ' . tmpundofile&#xA;&#xA;    &quot; Write current unsaved buffer to a temp file&#xA;    let l:tmpname = tempname()&#xA;    call writefile(getline(1, '$'), l:tmpname)&#xA;    if s:isWindows()&#xA;        let l:tmpname = tr(l:tmpname, '\', '/')&#xA;    endif&#xA;&#xA;    let out = system(a:cmd, getline(1, '$'))[:-2]&#xA;&#xA;    if v:shell_error &amp;gt; 0&#xA;        echoerr out&#xA;        return&#xA;    end&#xA;&#xA;    try&#xA;        silent undojoin&#xA;    catch&#xA;        &quot; Silently ignore&#xA;    endtry&#xA;&#xA;&#xA;    &quot; set buffer text&#xA;    silent 0,$delete&#xA;    call setline(1, split(out, '\n'))&#xA;&#xA;    &quot; restore our undo history&#xA;    silent! exe 'rundo ' . tmpundofile&#xA;    call delete(tmpundofile)&#xA;&#xA;    &quot; Restore our cursor/windows positions, folds, etc.&#xA;    if empty(l:curw)&#xA;        silent! loadview&#xA;    else&#xA;        call winrestview(l:curw)&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot; IsWin returns 1 if current OS is Windows or 0 otherwise&#xA;function! s:isWindows() abort&#xA;    let win = ['win16', 'win32', 'win64', 'win95']&#xA;    for w in win&#xA;        if (has(w))&#xA;            return 1&#xA;        endif&#xA;    endfor&#xA;&#xA;    return 0&#xA;endfunction&#xA;&#xA;augroup write_Cmd&#xA;    autocmd BufWritePre *.go call s:write_cmd('goimports')&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;*&lt;/sup&gt;: I was apprehensive about using it at first due to bad experiences with some other language plugins, but vim-go is much more sane.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-01-03T23:55:57.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10836" PostTypeId="2" ParentId="839" CreationDate="2017-01-04T00:07:54.183" Score="1" Body="&lt;p&gt;Parsing and formatting code is hard, especially for dynamic languages such as Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of trying to parse Python in Vimscript, I recommend you can use an external formatter such as &lt;a href=&quot;https://github.com/google/yapf&quot; rel=&quot;nofollow noreferrer&quot;&gt;yapf&lt;/a&gt;. With &lt;a href=&quot;https://vi.stackexchange.com/a/10835/51&quot;&gt;my answer here&lt;/a&gt; you can write this automatically on write with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup write_cmd&#xA;    autocmd BufWritePre *.py call s:write_cmd('yapf')&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;s:write_cmd()&lt;/code&gt; function is in the other answer – I won't add it here so I won't have to update it in two places if I find a bug :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also set &lt;code&gt;formatprg&lt;/code&gt; to &lt;code&gt;yapf&lt;/code&gt; and manually format it with &lt;code&gt;gq&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-01-04T02:01:43.267" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10837" PostTypeId="1" AcceptedAnswerId="10839" CreationDate="2017-01-04T01:03:20.523" Score="1" ViewCount="603" Body="&lt;p&gt;Is there a way to use a vimscript function to pass arguments to an external command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetJobLines(argA)&#xA;&#xA;    &quot; 1. Create a new buffer for the output&#xA;    enew&#xA;&#xA;    &quot; 2. Change directory to location of said script&#xA;    cd /home/leeand00/src&#xA;&#xA;    &quot; 3. Run said script with argument (not really but for example)&#xA;    read!echo a:argA&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;read!&quot;echo&quot; . a:argA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="51" LastEditDate="2017-01-04T15:12:17.090" LastActivityDate="2017-01-04T16:07:51.890" Title="Concatination of arguments in vimscript when reading the output of a command to a buffer?" Tags="|vimscript|external-command|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10839" PostTypeId="2" ParentId="10837" CreationDate="2017-01-04T05:59:40.150" Score="4" Body="&lt;p&gt;The usual way to incorporate the value of a variable into an Ex command is to use the &lt;code&gt;:execute&lt;/code&gt; command, which concatenates its arguments into a string, then executes that string, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;read!echo&quot; a:argA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or even better, like this, which includes the use of &lt;code&gt;shellescape()&lt;/code&gt; to make sure that the characters of &lt;code&gt;a:argA&lt;/code&gt; are properly quoted for use by the shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;read!echo&quot; shellescape(a:argA)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :execute&#xA;:help shellescape()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="51" LastEditDate="2017-01-04T16:07:51.890" LastActivityDate="2017-01-04T16:07:51.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10840" PostTypeId="2" ParentId="10834" CreationDate="2017-01-04T09:46:07.310" Score="4" Body="&lt;p&gt;I think your best bet would be to remap everything that uses &lt;code&gt;s&lt;/code&gt; in all modes. You are already aware of the command for normal mode I think, &lt;code&gt;nnoremap&lt;/code&gt;. This changes the normal mode mapping only. Once you press a key like &lt;code&gt;c&lt;/code&gt; you normally enter operator pending mode. Since you are not in normal mode anymore, the &lt;code&gt;nnoremap&lt;/code&gt; has no effect here. Instead you should use &lt;code&gt;onoremap&lt;/code&gt; to define the behavior in this mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tim Pope's surround uses a slightly different way of defining the surround command which can be found in surround.vim in the plugin folder of this plugin. The relevant code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(&quot;g:surround_no_mappings&quot;) || ! g:surround_no_mappings&#xA;  nmap ds  &amp;lt;Plug&amp;gt;Dsurround&#xA;  nmap cs  &amp;lt;Plug&amp;gt;Csurround&#xA;  nmap cS  &amp;lt;Plug&amp;gt;CSurround&#xA;  nmap ys  &amp;lt;Plug&amp;gt;Ysurround&#xA;  nmap yS  &amp;lt;Plug&amp;gt;YSurround&#xA;  nmap yss &amp;lt;Plug&amp;gt;Yssurround&#xA;  nmap ySs &amp;lt;Plug&amp;gt;YSsurround&#xA;  nmap ySS &amp;lt;Plug&amp;gt;YSsurround&#xA;  xmap S   &amp;lt;Plug&amp;gt;VSurround&#xA;  xmap gS  &amp;lt;Plug&amp;gt;VgSurround&#xA;  if !exists(&quot;g:surround_no_insert_mappings&quot;) || ! g:surround_no_insert_mappings&#xA;    if !hasmapto(&quot;&amp;lt;Plug&amp;gt;Isurround&quot;,&quot;i&quot;) &amp;amp;&amp;amp; &quot;&quot; == mapcheck(&quot;&amp;lt;C-S&amp;gt;&quot;,&quot;i&quot;)&#xA;      imap    &amp;lt;C-S&amp;gt; &amp;lt;Plug&amp;gt;Isurround&#xA;    endif&#xA;    imap      &amp;lt;C-G&amp;gt;s &amp;lt;Plug&amp;gt;Isurround&#xA;    imap      &amp;lt;C-G&amp;gt;S &amp;lt;Plug&amp;gt;ISurround&#xA;  endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From this it is clear that this plugin uses ordinary &lt;code&gt;nmap&lt;/code&gt;s to create the mappings. If you put the code below in your &lt;code&gt;.vimrc&lt;/code&gt; you should be good to go. This first tells the plugin to not define any mappings and then goes on to define the custom mappings.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:surround_no_mappings=1&#xA;nmap da  &amp;lt;Plug&amp;gt;Dsurround&#xA;nmap ca  &amp;lt;Plug&amp;gt;Csurround&#xA;nmap cA  &amp;lt;Plug&amp;gt;CSurround&#xA;nmap ya  &amp;lt;Plug&amp;gt;Ysurround&#xA;nmap yA  &amp;lt;Plug&amp;gt;YSurround&#xA;nmap yaa &amp;lt;Plug&amp;gt;Yssurround&#xA;nmap yAa &amp;lt;Plug&amp;gt;YSsurround&#xA;nmap yAA &amp;lt;Plug&amp;gt;YSsurround&#xA;xmap A   &amp;lt;Plug&amp;gt;VSurround&#xA;xmap gA  &amp;lt;Plug&amp;gt;VgSurround&#xA;if !exists(&quot;g:surround_no_insert_mappings&quot;) || ! g:surround_no_insert_mappings&#xA;  if !hasmapto(&quot;&amp;lt;Plug&amp;gt;Isurround&quot;,&quot;i&quot;) &amp;amp;&amp;amp; &quot;&quot; == mapcheck(&quot;&amp;lt;C-A&amp;gt;&quot;,&quot;i&quot;)&#xA;    imap    &amp;lt;C-A&amp;gt; &amp;lt;Plug&amp;gt;Isurround&#xA;  endif&#xA;  imap      &amp;lt;C-G&amp;gt;a &amp;lt;Plug&amp;gt;Isurround&#xA;  imap      &amp;lt;C-G&amp;gt;A &amp;lt;Plug&amp;gt;ISurround&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2017-01-04T09:46:07.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10841" PostTypeId="2" ParentId="10834" CreationDate="2017-01-04T09:47:13.317" Score="4" Body="&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; &lt;em&gt;@Octaviour's solution is way smarter, you should use it :-) Nonetheless I'll leave this answer here because I worked on it and because it contains some interesting part about the usage of &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; which can still be interesting to read&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I believe that actually your problem is more complex than you could think:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you want is not a second layout: if you want &lt;code&gt;ca&lt;/code&gt; to behave like &lt;code&gt;cs&lt;/code&gt;, it means that you want to remap &lt;code&gt;ca&lt;/code&gt; to call the function that &lt;code&gt;cs&lt;/code&gt; usually calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here it is tricky because the &lt;code&gt;cs&lt;/code&gt; mapping is done by the vim surround script and this plugin doesn't provide a mapping override mechanism. Thus you'll need to use several tricks.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;First let's check surround.vim code, especially the part &lt;a href=&quot;https://github.com/tpope/vim-surround/blob/master/plugin/surround.vim#L566&quot; rel=&quot;nofollow noreferrer&quot;&gt;where the mapping is done&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap cs  &amp;lt;Plug&amp;gt;Csurround&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;Csurround  :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;changesurround()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first line shows that &lt;code&gt;cs&lt;/code&gt; is mapped to an expression which is local to the plugin: &lt;code&gt;&amp;lt;Plug&amp;gt;Csurround&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second line show what &lt;code&gt;&amp;lt;Plug&amp;gt;Csurround&lt;/code&gt; (and thus &lt;code&gt;cs&lt;/code&gt;) is mapped to &lt;code&gt;:&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;changesurround()&amp;lt;CR&amp;gt;&lt;/code&gt;. It means that it is mapped to call the plugin local function &lt;code&gt;changesurround()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that if we want to map &lt;code&gt;ca&lt;/code&gt; to &lt;code&gt;changesurround()&lt;/code&gt; we will need to get the &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; of the surround.vim script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3CSID%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h &amp;lt;SID&amp;gt;&lt;/code&gt;&lt;/a&gt; for more details about the &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; variables.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To get the &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; of a script we can use the following function (largely inspired by &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#scriptnames%2Ddictionary&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h scriptnames-dictionary&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetScriptSID(scriptName)&#xA;    &quot; Get the output of &quot;:scriptnames&quot; in the scriptnames_output variable.&#xA;    let scriptnames_output = ''&#xA;    redir =&amp;gt; scriptnames_output&#xA;    silent scriptnames&#xA;    redir END&#xA;&#xA;    &quot; Split the output into lines and parse each line&#xA;    &quot; Looking for vimsurround&#xA;    let scripts = {}&#xA;    for line in split(scriptnames_output, &quot;\n&quot;)&#xA;        &quot; Only do non-blank lines.&#xA;        if line =~ '\S'&#xA;            &quot; Get the first number in the line.&#xA;            let nr = matchstr(line, '\d\+')&#xA;            &quot; Get the file name&#xA;            let name = split(substitute(line, '.\+:\s*', '', ''), '\')[-1]&#xA;&#xA;            if name == a:scriptName&#xA;                return nr&#xA;            endif&#xA;        endif&#xA;    endfor&#xA;    unlet scriptnames_output&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That we should call with &lt;code&gt;call GetScritpSID('surround.vim')&lt;/code&gt;. On my system it returns &lt;code&gt;31&lt;/code&gt; because this plugin was the 31st script to be sourced at vim startup.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now you should be able to enter the following command in the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; ca :&amp;lt;C-U&amp;gt;call &amp;lt;SNR&amp;gt;31_changesurround()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Replace 31 by the result of your call to &lt;code&gt;GetScriptSID&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you'll have &lt;code&gt;ca&lt;/code&gt; behaving like &lt;code&gt;cs&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That's nice but we are only half way through what we want to do. The next step is to put this mapping in your vimrc. We are have 2 problems:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could put the command with the hard coded SID in your vimrc like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; ca :&amp;lt;C-U&amp;gt;call &amp;lt;SNR&amp;gt;31_changesurround()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if you install/remove a script the SID might change and your mapping won't work anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you could use &lt;code&gt;execute&lt;/code&gt; to get the SID dynamically: you need to add the &lt;code&gt;GetScriptSID()&lt;/code&gt; function to your vimrc along with this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'nnoremap &amp;lt;silent&amp;gt; ca :&amp;lt;C-U&amp;gt;call &amp;lt;SNR&amp;gt;' . GetScriptSID('surround.vim') . '_changesurround()&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But here when you'll use the mapping Vim will yell at you that &lt;code&gt;0_changesurround()&lt;/code&gt; doesn't exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is because the vimrc is sourced before the other scripts so your execution of &lt;code&gt;scriptname&lt;/code&gt; in your vimrc will return 0 scripts.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To solve this problem you'll have to do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RemapVimSurround()&#xA;    let surroundSID = GetScriptSID('surround.vim')&#xA;&#xA;    execute 'nnoremap &amp;lt;silent&amp;gt; ca :&amp;lt;C-U&amp;gt;call &amp;lt;SNR&amp;gt;' . surroundSID . '_changesurround()&amp;lt;CR&amp;gt;'&#xA;    unmap cs&#xA;endfunction&#xA;&#xA;autocmd VimEnter * call RemapVimSurround()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The autocommand will execute the function &lt;code&gt;RemapVimSurround()&lt;/code&gt; once all the scripts are sourced. This way the &lt;code&gt;scriptname&lt;/code&gt; execution in the function will return the correct SID and your mapping will be valid. Also we unmap &lt;code&gt;cs&lt;/code&gt; which was mapped by the plugin.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Finally you also wanted to have &lt;code&gt;s&lt;/code&gt; behave like &lt;code&gt;a&lt;/code&gt; in normal mode so you should be able to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap s a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To sum up you should add the following to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetScriptSID(scriptName)&#xA;    &quot; Get the output of &quot;:scriptnames&quot; in the scriptnames_output variable.&#xA;    let scriptnames_output = ''&#xA;    redir =&amp;gt; scriptnames_output&#xA;    silent scriptnames&#xA;    redir END&#xA;&#xA;    &quot; Split the output into lines and parse each line&#xA;    &quot; Looking for vimsurround&#xA;    let scripts = {}&#xA;    for line in split(scriptnames_output, &quot;\n&quot;)&#xA;        &quot; Only do non-blank lines.&#xA;        if line =~ '\S'&#xA;            &quot; Get the first number in the line.&#xA;            let nr = matchstr(line, '\d\+')&#xA;            &quot; Get the file name&#xA;            let name = split(substitute(line, '.\+:\s*', '', ''), '\')[-1]&#xA;&#xA;            if name == a:scriptName&#xA;                return nr&#xA;            endif&#xA;        endif&#xA;    endfor&#xA;    unlet scriptnames_output&#xA;endfunction&#xA;&#xA;&#xA;function! RemapVimSurround()&#xA;    let surroundSID = GetScriptSID('surround.vim')&#xA;&#xA;    execute 'nnoremap &amp;lt;silent&amp;gt; ca :&amp;lt;C-U&amp;gt;call &amp;lt;SNR&amp;gt;' . surroundSID . '_changesurround()&amp;lt;CR&amp;gt;'&#xA;    unmap cs&#xA;    nnoremap s a&#xA;endfunction&#xA;&#xA;autocmd VimEnter * call RemapVimSurround()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-01-04T16:20:03.870" LastActivityDate="2017-01-04T16:20:03.870" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10842" PostTypeId="1" AcceptedAnswerId="10843" CreationDate="2017-01-04T10:00:44.657" Score="2" ViewCount="148" Body="&lt;p&gt;When trying to swap characters in certain modes, it struck me that I could not swap the character used after pressing &lt;code&gt;f&lt;/code&gt;, such that &lt;code&gt;fa&lt;/code&gt; actually jumps to the next &lt;code&gt;b&lt;/code&gt; on the line. According to the vim documentation at &lt;code&gt;:h f&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f{char}         To [count]'th occurrence of {char} to the right.  The&#xA;    cursor is placed on {char} |inclusive|.&#xA;    {char} can be entered as a digraph |digraph-arg|.&#xA;    When 'encoding' is set to Unicode, composing&#xA;    characters may be used, see |utf-8-char-arg|.&#xA;    |:lmap| mappings apply to {char}.  The CTRL-^ command&#xA;    in Insert mode can be used to switch this on/off&#xA;    |i_CTRL-^|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This made me think that &lt;code&gt;:lmap a b&lt;/code&gt; should solve my problem. &lt;code&gt;fa&lt;/code&gt; still jumps to the next &lt;code&gt;a&lt;/code&gt; however, even after starting vim with &lt;code&gt;vim -u NONE&lt;/code&gt;. Am I missing something here?&lt;/p&gt;&#xA;" OwnerUserId="8061" LastEditorUserId="51" LastEditDate="2017-01-04T15:09:16.797" LastActivityDate="2017-01-04T15:09:16.797" Title="f does not seem to respect :lmap" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10843" PostTypeId="2" ParentId="10842" CreationDate="2017-01-04T11:22:02.747" Score="3" Body="&lt;p&gt;You need to enable the language mapping with either &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; in Insert mode or with &lt;code&gt;:set iminsert=1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;References&lt;/em&gt;&lt;br&gt;&#xA;&lt;code&gt;:h f&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;:h i_CTRL-^&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;:h 'iminsert'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2017-01-04T12:02:06.940" LastActivityDate="2017-01-04T12:02:06.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10845" PostTypeId="1" CreationDate="2017-01-04T13:50:46.900" Score="6" ViewCount="16977" Body="&lt;p&gt;I have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;012-0738-32&quot;],[ &quot;4&quot;, &quot;Beacon&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;012-0738-32&quot;&#xA;&quot;4&quot;, &quot;Beacon&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;],[&lt;/code&gt;+ &lt;code&gt;space&lt;/code&gt; replaced with &lt;code&gt;\r&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9498" LastEditorUserId="24" LastEditDate="2017-01-04T23:53:39.427" LastActivityDate="2017-01-04T23:53:39.427" Title="How to replace bracket in vim?" Tags="|substitute|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10846" PostTypeId="2" ParentId="10845" CreationDate="2017-01-04T13:53:19.940" Score="9" Body="&lt;p&gt;You need to escape the opening square bracket: &lt;code&gt;:s/],\[ /\r&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-01-04T13:53:19.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10847" PostTypeId="2" ParentId="10845" CreationDate="2017-01-04T14:45:08.603" Score="3" Body="&lt;p&gt;A visual way to handle this is to &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1) search&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt;&lt;kbd&gt;space&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2) select the matched text&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3) substitute text&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;s &lt;/kbd&gt; and insert the text you want&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;4) Repeat if needed&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can advance to next match using &lt;kbd&gt; n &lt;/kbd&gt; then &lt;kbd&gt; . &lt;/kbd&gt; to repeat your last substitution.&lt;/p&gt;&#xA;" OwnerUserId="2710" LastEditorUserId="2710" LastEditDate="2017-01-04T14:51:32.380" LastActivityDate="2017-01-04T14:51:32.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10848" PostTypeId="2" ParentId="9764" CreationDate="2017-01-04T15:17:07.963" Score="1" Body="&lt;p&gt;If the digraph has a code point (usually found by a web search for &lt;code&gt;unicode &amp;lt;character description&amp;gt;&lt;/code&gt;), you can just use &lt;code&gt;&amp;lt;c-v&amp;gt;u####&lt;/code&gt; to directly enter it.  For example &lt;code&gt;&amp;lt;c-v&amp;gt;u00e4&lt;/code&gt; yields ä.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This does assume your editor can interpret the UTF-8 encoding.&lt;/p&gt;&#xA;" OwnerUserId="5353" LastActivityDate="2017-01-04T15:17:07.963" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10849" PostTypeId="1" AcceptedAnswerId="15465" CreationDate="2017-01-04T15:25:06.750" Score="6" ViewCount="227" Body="&lt;p&gt;I have swapped my number keys with their symbols, because the symbols occur much more frequently than numbers in many programming languages, like C or Haskell. You can see my key-swap function &lt;a href=&quot;https://gist.github.com/ShabbyX/3691170#file-vimrc-L102&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;in my .vimrc file&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the sake of examples, say &lt;code&gt;9&lt;/code&gt; and &lt;code&gt;(&lt;/code&gt; are swapped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is one part I'm stumped in though. I currently use &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;imap&lt;/code&gt; and &lt;code&gt;cmap&lt;/code&gt; to cover most cases. However, some commands, like &lt;code&gt;f&lt;/code&gt; aren't covered. For example, &lt;kbd&gt;f&lt;/kbd&gt; followed by &lt;kbd&gt;9&lt;/kbd&gt; doesn't do &lt;code&gt;f(&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that &lt;code&gt;lmap&lt;/code&gt; takes care of this, and that's true. However, using &lt;code&gt;lmap&lt;/code&gt; (in conjunction with &lt;code&gt;iminsert=1&lt;/code&gt;) creates another problem: macros stop working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, take the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Stuff 9 other ( things&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the following key strokes: &lt;kbd&gt;q&lt;/kbd&gt; &lt;kbd&gt;q&lt;/kbd&gt; &lt;kbd&gt;f&lt;/kbd&gt; &lt;kbd&gt;9&lt;/kbd&gt; &lt;kbd&gt;x&lt;/kbd&gt; &lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While recording this macro, effectively &lt;code&gt;f(x&lt;/code&gt; is executed, which is the intended behavior. However, if I run this macro again (for example undo and rerun on same line, or just on another similar line), then what actually gets executed is &lt;code&gt;f9x&lt;/code&gt;. Using &lt;code&gt;&quot;qp&lt;/code&gt; I can see that the macro has recorded &lt;code&gt;f9x&lt;/code&gt;, which is fine, but it means that when playing the macro, the mapping is not taking into effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I don't have this problem with &lt;code&gt;/&lt;/code&gt; for example. As in, I can do (in a macro) &lt;kbd&gt;/&lt;/kbd&gt; &lt;kbd&gt;9&lt;/kbd&gt; to get &lt;code&gt;/(&lt;/code&gt; with the macro recording &lt;code&gt;/9&lt;/code&gt; and when I replay the macro I correctly see &lt;code&gt;/(&lt;/code&gt; being executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what's wrong here? Why do macros respect the mapping with &lt;code&gt;/&lt;/code&gt; but not with &lt;code&gt;f&lt;/code&gt;, and how can I get them to work correctly?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;P.S. Possibly relevant information: I use &lt;code&gt;*noremap&lt;/code&gt; not &lt;code&gt;*map&lt;/code&gt; themselves.&lt;/p&gt;&#xA;" OwnerUserId="850" LastEditorUserId="850" LastEditDate="2017-01-04T16:33:33.187" LastActivityDate="2018-03-07T03:04:53.933" Title="Swap two keys in such a way that works with both `f` and macros" Tags="|key-bindings|macro|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10851" PostTypeId="1" AcceptedAnswerId="10852" CreationDate="2017-01-04T16:48:24.203" Score="3" ViewCount="592" Body="&lt;p&gt;In my &lt;a href=&quot;https://vi.stackexchange.com/questions/10837/concatination-of-arguments-in-vimscript-when-reading-the-output-of-a-command-to&quot;&gt;previous question&lt;/a&gt;, I passed an argument into a Vimscript function and concatenated it into the command line.  This works great, but when you pass a string that contains the &lt;code&gt;#&lt;/code&gt; character, it balks with an error about the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E499: Empty file name for '%' or '#', only works with `:p:h`: read!&amp;lt;shellcmd&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The vimscript function looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetJobLines(a:argA)&#xA;&#xA;    &quot; 1. Create a new buffer for the output&#xA;    enew&#xA;&#xA;    &quot; 2. Change directory to location of said script&#xA;    cd /home/leeand00/src&#xA;&#xA;    execute &quot;read!echo&quot; shellescape(a:argA)&#xA;&#xA;functionend&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running the command itself looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call GetJobLines(&quot;C#&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Myself I thought that including &lt;code&gt;shellescape()&lt;/code&gt; would have taken care of this, however this is not the case.  I also tried adding &lt;code&gt;\#&lt;/code&gt; to escape the &lt;code&gt;#&lt;/code&gt; character, but that does not work either...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run the same command from the command line directly it does not cause an issue, and clearly this is a problem to be corrected in vimscript, I just don't know how.&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-01-04T23:50:50.647" Title="Passing a # character to the shell in vimscript?" Tags="|vimscript|external-command|argument-list|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10852" PostTypeId="2" ParentId="10851" CreationDate="2017-01-04T17:05:03.707" Score="4" Body="&lt;p&gt;The problem is that some characters are considered special by the Vim commandline. In your case, &lt;code&gt;#&lt;/code&gt; refers to the alternate file name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find the documentation with a full list at &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#cmdline%2dspecial&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help cmdline-special&lt;/code&gt;&lt;/a&gt;. This also includes the two possible ways to prevent this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Prefix it with a backslash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;:read !echo &quot; . shellescape('C\#')&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the &lt;code&gt;fnameescape()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;:read !echo &quot; . shellescape(fnameescape('C#'))&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-01-04T17:05:03.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10853" PostTypeId="1" CreationDate="2017-01-04T18:56:22.457" Score="4" ViewCount="434" Body="&lt;p&gt;Assume I have a syntax as exemplified below and that I want to create a syntax folding definition for the nested &lt;code&gt;begin..end&lt;/code&gt; pairs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;begin : label&#xA;  a = 0;&#xA;  begin&#xA;    b = 1;&#xA;  end&#xA;  c = 2;&#xA;  begin&#xA;    d = 3;&#xA;  end&#xA;end&#xA;&#xA;if (a) begin&#xA;  w = 0;&#xA;end else begin&#xA;  if (b) begin&#xA;    y = 0;&#xA;  end else if (c) begin : another_label&#xA;    y = 1;&#xA;  end else begin&#xA;    y = 2;&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the moment I have the following syntax defined, which has the obvious issue with the highlight of the &lt;code&gt;end&lt;/code&gt; keyword and it also folds one line less when &lt;code&gt;end&lt;/code&gt; is at column 1.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region blockContainer&#xA;    \ start=&quot;\&amp;lt;begin\&amp;gt;&quot;&#xA;    \ end=&quot;\&amp;lt;end\&amp;gt;&quot;&#xA;    \ skip=&quot;/[*/].*&quot;&#xA;    \ transparent&#xA;    \ keepend extend&#xA;    \ containedin=ALLBUT,Comment&#xA;    \ contains=block&#xA;syn region block&#xA;    \ matchgroup=Statement&#xA;    \ start=&quot;\&amp;lt;begin\&amp;gt;&quot;&#xA;    \ end=&quot;\&amp;lt;end\&amp;gt;&quot;me=s-1&#xA;    \ transparent&#xA;    \ fold&#xA;    \ contained containedin=blockContainer&#xA;    \ contains=TOP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideally I would also like a second set of regions where folding only occurs for &lt;code&gt;begin..end&lt;/code&gt; pairs where the &lt;code&gt;begin&lt;/code&gt; has a label (&lt;code&gt;: something&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got to a point where I simply wasn't able to advance further with this syntax, so I started playing around with fold-expr. Unfortunately, the syntax is rather complex and the slowdown is quite noticeable when opening the files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is any Vim syntax expert available to help me? :)&lt;/p&gt;&#xA;" OwnerUserId="599" LastActivityDate="2017-01-04T18:56:22.457" Title="Nested syntax folding" Tags="|syntax-highlighting|folding|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10854" PostTypeId="2" ParentId="10851" CreationDate="2017-01-04T20:54:52.653" Score="6" Body="&lt;p&gt;&lt;code&gt;shellescape({string}[, {special}])&lt;/code&gt; has an extra, optional argument &lt;code&gt;{special}&lt;/code&gt; which exists exactly for this purpose.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the &lt;code&gt;{special}&lt;/code&gt; argument is present and it's a non-zero Number or a non-empty String (non-zero-arg), then special items such as &quot;!&quot;, &quot;%&quot;, and &quot;&lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;&quot; will be preceded by a backslash.  This backslash will be removed again by the &lt;code&gt;:!&lt;/code&gt; command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Therefore, what you want to use is &lt;code&gt;:execute ':read !echo' shellescape(a:argA, 1)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-01-04T20:54:52.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10855" PostTypeId="1" AcceptedAnswerId="10856" CreationDate="2017-01-04T22:10:44.373" Score="8" ViewCount="219" Body="&lt;p&gt;I think there is a distinct possibility this question has already been asked, but I can't find it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I am doing something like &lt;code&gt;:s/foo/bar/g&lt;/code&gt; and then I want to call that again on the next line but with &lt;code&gt;baz&lt;/code&gt; instead of &lt;code&gt;bar&lt;/code&gt;, is there a faster way to do that? I feel like &lt;code&gt;&amp;amp;baz&lt;/code&gt; should work, but it does not.&lt;/p&gt;&#xA;" OwnerUserId="9841" LastEditorUserId="24" LastEditDate="2017-01-04T23:52:22.010" LastActivityDate="2017-01-05T09:44:51.673" Title="Is there a shortcut to reuse the search term of the find and replace?" Tags="|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10856" PostTypeId="2" ParentId="10855" CreationDate="2017-01-04T22:16:40.593" Score="11" Body="&lt;p&gt;Not exactly what you ask for, but you can do that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/foo/bar/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s//baz/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use that because when you use &lt;code&gt;:s&lt;/code&gt; the searched pattern is saved in the search register. Which you can see with &lt;code&gt;:reg /&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Work in progress: You can speed up your workflow with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;amp;&amp;amp; :s&amp;lt;UP&amp;gt;&amp;lt;C-F&amp;gt;F/cT/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And use it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/foo/bar/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;amp;&amp;amp;baz&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decomposing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;amp;&amp;amp;         &quot; define a new mapping&#xA;:s&amp;lt;UP&amp;gt;              &quot; get the last :s command in the history&#xA;&amp;lt;C-F&amp;gt;               &quot; use this command in the cmdline window&#xA;F/                  &quot; go back to the last /&#xA;cT/                 &quot; change back up to the last /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This won't work if you don't have any flag&lt;/li&gt;&#xA;&lt;li&gt;This won't work if you don't have a substitute string&lt;/li&gt;&#xA;&lt;li&gt;It &lt;em&gt;should&lt;/em&gt; work otherwise&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(let me know if I can improve it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some reading:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h cmdline-window&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h c_CTRL-F&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2017-01-04T22:31:13.930" LastActivityDate="2017-01-04T22:31:13.930" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10857" PostTypeId="1" AcceptedAnswerId="10858" CreationDate="2017-01-04T22:48:06.430" Score="3" ViewCount="1004" Body="&lt;p&gt;Given the document&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&#xA;^&#xA;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(where &lt;code&gt;^&lt;/code&gt; denotes the cursor position), the forward search &lt;code&gt;/a\?&lt;/code&gt; succeeds, but the backward search &lt;code&gt;?a\?&lt;/code&gt; fails.  Why?&lt;/p&gt;&#xA;" OwnerUserId="2108" LastActivityDate="2017-02-20T09:16:15.863" Title="Zero-or-one in backwards regex search" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10858" PostTypeId="2" ParentId="10857" CreationDate="2017-01-04T23:02:19.780" Score="4" Body="&lt;p&gt;This is documented:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\?      Just like \=.  Cannot be used when searching backwards with the &quot;?&quot;&#xA;        command. {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;\?&lt;/code&gt; is &quot;Just like \=&quot;, so you can&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?a\= &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2017-01-04T23:02:19.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10859" PostTypeId="2" ParentId="10857" CreationDate="2017-01-04T23:03:08.670" Score="5" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5c%3f&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\?&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\?      Just like \=.  Cannot be used when searching backwards with the &quot;?&quot;&#xA;        command. {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's confusing behaviour, but the reason for this is that you can use the command with an offset to go &lt;code&gt;n&lt;/code&gt; lines up or down after the match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/a/1&#xA;?a?1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no easy way to disambiguate between regular &lt;code&gt;?&lt;/code&gt;s and the &lt;code&gt;?&lt;/code&gt; to separate the pattern from the offset. This is why &lt;code&gt;\?&lt;/code&gt; behaves as a literal &lt;code&gt;?&lt;/code&gt;, and not as the special atom you expect it to.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-02-20T09:16:15.863" LastActivityDate="2017-02-20T09:16:15.863" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10860" PostTypeId="1" CreationDate="2017-01-05T00:18:31.853" Score="2" ViewCount="1410" Body="&lt;p&gt;I have a log file full of arbitrary lines, interspersed with some lines which are a proper xml sequence, with all the tags on a single line (for each sequence).  I want to simply process this so that all the xml lines become broken out in easy to read format.  There is a utility in linux called xmllint that looks useful here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to do this easily manually in vim, by searching for &#xA;&#xA;&lt;pre&gt;&lt;code&gt;!! xmllint --format --recover - &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Interestingly, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! cmd &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't work here, but&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.! cmd &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does.  I'm not sure if that's because the first one is legacy &quot;Ex&quot; mode, while adding the range (.) makes the second one a Vim filter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want is to be able to do it automatically, not by saving manual commands in a recorded register and replaying it possibly tens or hundreds of times, but O(1) commands to simply find all the lines with &quot;xml&quot; and filter them through this external command, replacing their text in the buffer with the nicely formatted version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should definitely be possible given the power and style of vim, but I've tried for hours and can't do it.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%g/xml/normal!!:$xmllint --format --recover -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried with and without normal, and all the variations of : and ! to try to filter through an external command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the time, it does absolutely nothing to the buffer, nothing even to undo, even though the :g part is definitely matching.&#xA;Other times, like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%g/xml/!xmllint --format --recover -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it waits forever until I send a Ctrl-C for each match.  Basically it seems to be waiting for xmllint which is stuck waiting at STDIN.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I take a working :%g/pattern/ command and make it replace the matching lines with the output of an external command (a command which itself takes the aforementioned matching line as its input) ?&lt;/p&gt;&#xA;" OwnerUserId="10155" LastActivityDate="2017-01-09T09:02:26.103" Title="How to filter text matched by global command?" Tags="|external-command|linux|global-command|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10861" PostTypeId="2" ParentId="373" CreationDate="2017-01-05T08:30:05.843" Score="14" Body="&lt;p&gt;My favorite interactive substitution is to &lt;strong&gt;search&lt;/strong&gt; using &lt;kbd&gt;/&lt;/kbd&gt; and go through the matches using &lt;kbd&gt;n&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then &lt;strong&gt;select&lt;/strong&gt; match using &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt; and then &lt;kbd&gt;s&lt;/kbd&gt; to &lt;strong&gt;substitute&lt;/strong&gt; the text with whatever I like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;strong&gt;repeat&lt;/strong&gt; by moving to next match and pressing &lt;kbd&gt;.&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="2710" LastActivityDate="2017-01-05T08:30:05.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10862" PostTypeId="2" ParentId="10855" CreationDate="2017-01-05T09:44:51.673" Score="5" Body="&lt;p&gt;In addition to @nobe4's answer, Damian Conway has two pretty interesting mappings to speed up search and replace actions. They come from &lt;a href=&quot;http://howivim.com/2016/damian-conway/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this how i vim interview&lt;/a&gt; which is totally worth reading completely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To quote him:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[...] I found I was forever doing global search-and-replaces (i.e.&#xA;  &lt;code&gt;:%s/X/Y/g&amp;lt;CR&amp;gt;&lt;/code&gt;), so I eliminated the repetitious typing by stealing the&#xA;  never-used (by me) &lt;code&gt;S&lt;/code&gt; command:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap  S  :%s//g&amp;lt;LEFT&amp;gt;&amp;lt;LEFT&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Now I just need to type: SX/Y&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;But then I started noticing how often I did a /-search for some pattern and,&#xA;  having looked through the matches, then wanted to globally substitute all of&#xA;  them. Even with the S mapping that was more annoying repetition: first do the&#xA;  search: /pattern then do the replace: Spattern/replacement So I stole&#xA;  the (also never used by me) M command for that:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;expr&amp;gt;  M  ':%s/' . @/ . '//g&amp;lt;LEFT&amp;gt;&amp;lt;LEFT&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Now it’s just: do the search: /pattern then replace all the matches:&#xA;  Mreplacement&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To answer your question, I guess you could slightly modify the first mapping for&#xA;something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap  S  :s///g&amp;lt;LEFT&amp;gt;&amp;lt;LEFT&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you can first make your substitution &lt;code&gt;:s/foo/bar/g&lt;/code&gt;, go to the next line, hit &lt;code&gt;S&lt;/code&gt; and you'll get: &lt;code&gt;:s//|/g&lt;/code&gt; where &lt;code&gt;|&lt;/code&gt; is the cursor, you can now type your new subsitution.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-01-05T09:44:51.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10863" PostTypeId="1" AcceptedAnswerId="10865" CreationDate="2017-01-05T10:01:03.900" Score="5" ViewCount="729" Body="&lt;p&gt;I would like to modify the behavior of one of my mapping but only when Vim is reading data which were piped to it by &lt;code&gt;$ vipe&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mapping closes/quits the current window/session depending on certain conditions. When Vim is reading data which were piped to it, I would like the mapping to execute &lt;code&gt;:cquit&lt;/code&gt;, so that it reports an error to the shell and the output of the shell command is not displayed in the terminal when I quit (or the rest of the pipeline is not processed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$ vipe&lt;/code&gt; is a shell utility, included in the &lt;code&gt;moreutils&lt;/code&gt; package, whose man page contains this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NAME&#xA;       vipe - edit pipe&#xA;&#xA;SYNOPSIS&#xA;       command1 | vipe | command2&#xA;&#xA;DESCRIPTION&#xA;       vipe allows you to run your editor in the middle of a unix pipeline and edit the data that is being piped&#xA;       between programs. Your editor will have the full data being piped from command1 loaded into it, and when you&#xA;       save, that data will be piped into command2.&#xA;&#xA;ENVIRONMENT VARIABLES&#xA;       EDITOR&#xA;           Editor to use.&#xA;&#xA;       VISUAL&#xA;           Also supported to determine what editor to use.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As an example, one could use it to count the number of files/directories in the current working directory with &lt;code&gt;$ ls&lt;/code&gt; and &lt;code&gt;$ wc -l&lt;/code&gt;, using Vim in the middle to interactively remove some entries:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls | vipe | wc -l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, I don't know how to detect that Vim has been invoked by &lt;code&gt;$ vipe&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use the &lt;code&gt;StdinReadPre&lt;/code&gt; and &lt;code&gt;StdinReadPost&lt;/code&gt; event like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup standard_input&#xA;    autocmd!&#xA;    autocmd StdinReadPre * nno cd :echo 'hello'&amp;lt;cr&amp;gt;&#xA;    autocmd StdinReadPost * nno cd :echo 'hello'&amp;lt;cr&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it didn't work, when hitting &lt;code&gt;cd&lt;/code&gt;, &lt;code&gt;hello&lt;/code&gt; was not displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason why it didn't worked is probably because Vim wasn't invoked with the &lt;code&gt;-&lt;/code&gt; argument, because this works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;:h StdinReadPre&lt;/code&gt; and &lt;code&gt;:h StdinReadPost&lt;/code&gt; seems to confirm this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *StdinReadPost*&#xA;StdinReadPost           After reading from the stdin into the buffer,&#xA;                before executing the modelines.  Only used&#xA;                when the &quot;-&quot; argument was used when Vim was&#xA;                started |--|.&#xA;                            *StdinReadPre*&#xA;StdinReadPre            Before reading from stdin into the buffer.&#xA;                Only used when the &quot;-&quot; argument was used when&#xA;                Vim was started |--|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also tried to check the contents of the internal variables &lt;code&gt;v:progname&lt;/code&gt; and &lt;code&gt;v:progpath&lt;/code&gt; but they both report &lt;code&gt;vim&lt;/code&gt;, not &lt;code&gt;vipe&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to detect whether Vim has been invoked by another shell command (&lt;code&gt;vipe&lt;/code&gt;, &lt;code&gt;git commit&lt;/code&gt;, ...)?&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-01-05T10:38:43.657" LastActivityDate="2017-01-05T11:11:12.953" Title="How to detect whether Vim has been invoked by another shell command?" Tags="|autocmd|invocation|startup|quit|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10864" PostTypeId="2" ParentId="10863" CreationDate="2017-01-05T11:11:02.023" Score="5" Body="&lt;p&gt;I don't know how reliable it is but I found how to get the PID of the parent of a process &lt;a href=&quot;https://superuser.com/questions/150117/how-to-get-parent-pid-of-a-given-process-in-gnu-linux-from-command-line&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ps -o ppid= -p &amp;lt;pid of the process&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And how to get the name of a process from its PID &lt;a href=&quot;https://superuser.com/questions/632979/if-i-know-the-pid-number-of-a-process-how-can-i-get-its-name&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ps -p 1337 -o comm=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One can get the pid of the Vim's process with the &lt;code&gt;getpid()&lt;/code&gt; function, so combining the previous 2 commands, maybe this expression could get the name of the parent of Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expand('`ps -p $(ps -o ppid= -p '.getpid().') -o comm=`')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried to use it in my mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if expand('`ps -p $(ps -o ppid= -p '.getpid().') -o comm=`') ==# 'vipe'&#xA;    cquit&#xA;else&#xA;    ...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to work.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2017-01-05T11:11:02.023" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10865" PostTypeId="2" ParentId="10863" CreationDate="2017-01-05T11:11:12.953" Score="5" Body="&lt;p&gt;Since &lt;code&gt;vipe&lt;/code&gt;, &lt;code&gt;git commit&lt;/code&gt; (and many other programs which invoke an editor) use the &lt;code&gt;VISUAL&lt;/code&gt; and &lt;code&gt;EDITOR&lt;/code&gt; variables (unless you specify an editor for &lt;code&gt;git&lt;/code&gt; with &lt;code&gt;git config core.editor&lt;/code&gt;), you can use that variable to invoke Vim in such a way that you can detect it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export EDITOR='env called=1 vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, in Vim, &lt;code&gt;$called&lt;/code&gt; will have a value of 1, which you can use to detect whether it was called by a command.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-01-05T11:11:12.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10866" PostTypeId="2" ParentId="10016" CreationDate="2017-01-05T15:57:02.613" Score="4" Body="&lt;p&gt;I've tripped on this one too many times too:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've solved it by remapping the &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt; to closing NERDTree (if open) and then opening CtrlP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put this in your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_map = ''                      &#xA;nnoremap &amp;lt;c-p&amp;gt; :NERDTreeClose\|CtrlP&amp;lt;CR&amp;gt;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&#xA;The first line makes CtrlP not overwrite your custom mapping.&#xA;And the second one runs close on NERDTree before opening CtrlP.&lt;/p&gt;&#xA;" OwnerUserId="10725" LastActivityDate="2017-01-05T15:57:02.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10867" PostTypeId="2" ParentId="10860" CreationDate="2017-01-05T16:25:49.043" Score="0" Body="&lt;p&gt;I have something that works in O(1) time, but I don't think it's the best solution, and it especially bothers me that I have to type out a long sequence of characters without simply being able to cut-paste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Feel free to submit an answer that simply refines this one, teaching me how to cut paste better in Ubuntu)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa0!$xmllint --format --recover -^M&#xA;:g/xml/normal @a &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works in one pass.  Note that ^M is actually a literal &quot;enter&quot; key press, inserted by typing , not by typing caret (^) or M.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See how ridiculous this is?  I CAN use a :g command, but can only specify the action command by sucking the commands (that should go in the suffix of the :g/pat/cmd) into a named register, and then executing that using &quot;normal @&quot;.  I don't understand why it doesn't work if I cut and paste the stuff in the @ to the end of the &quot;normal&quot; command on the :g line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am still hoping for a proper answer using a one-line :g command, or something similar.  Maybe some compile flag or other setting needs to change to allow the one-line :g command?&lt;/p&gt;&#xA;" OwnerUserId="10155" LastActivityDate="2017-01-05T16:25:49.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10868" PostTypeId="1" CreationDate="2017-01-05T19:14:31.773" Score="0" ViewCount="503" Body="&lt;p&gt;I work on a remote server and would like to yank stuff to the server's clipboard. However &lt;code&gt;&quot;+y&lt;/code&gt; gives me an error flash (visual terminal bell) and when quitting vim, I can't paste in the terminal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe this is an issue with ssh not correctly transmitting &lt;code&gt;Ctrl-Shift-V&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastEditorUserId="1066" LastEditDate="2017-01-05T21:52:06.567" LastActivityDate="2017-01-05T21:52:06.567" Title="System clipboard not working via ssh" Tags="|os-clipboard|ssh|" AnswerCount="0" CommentCount="9" ClosedDate="2017-01-06T11:36:19.810" ContentLicense="CC BY-SA 3.0" />
  <row Id="10869" PostTypeId="1" AcceptedAnswerId="22746" CreationDate="2017-01-06T02:38:25.263" Score="8" ViewCount="899" Body="&lt;p&gt;I'm using the latest vim/gvim (8.0.118), but have noticed this problem in the past, with other versions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created a file named &lt;code&gt;fizzbuzz.java&lt;/code&gt; (outside of gvim), and opened it in a new tab in gvim on my Windows 7 PC at work, using the context menu of my file manager. After closing the tab, using &lt;code&gt;:x&lt;/code&gt;, I discovered that I had to rename the file to &lt;code&gt;FizzBuzz.java&lt;/code&gt;, to match the name of the class I wrote,  which I did outside of gvim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I went to reopen it in the same instance of gvim, again using the context menu of my file manager, it reverts to the original casing, and when I close it with &lt;code&gt;:x&lt;/code&gt;, it saves it as such, so that I had to rename the file again. It was only after deleting the buffer, and refreshing the buffer list in the menu that I was able to get gvim to correctly recognize the new casing of the filename.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This does not happen in gvim 7.4 on Linux (PCLinuxOS)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an easier way to get gvim to recognize, and retain the change in casing of a filename on Windows, without restarting gvim?&lt;/p&gt;&#xA;" OwnerUserId="5298" LastEditorUserId="1238" LastEditDate="2019-12-17T21:12:04.843" LastActivityDate="2020-02-03T14:29:34.793" Title="Dealing with case insensitive filenames on Windows" Tags="|gvim|microsoft-windows|" AnswerCount="2" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10870" PostTypeId="1" CreationDate="2017-01-06T03:51:13.220" Score="1" ViewCount="508" Body="&lt;p&gt;When I do a global search and replace with confirm (e.g.,&#xA;&lt;code&gt;:s/t/s/gc&lt;/code&gt;) I have a lot of trouble seeing which of many occurrences is currently under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried the usual tricks, e.g., &lt;code&gt;hi IncSearch ctermfg=Black  ctermbg=lightyellow cterm=bold,underline,reverse&lt;/code&gt; but still have trouble. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it would help some if I could make the cursor blink aggressively in addition to the other settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've read &lt;a href=&quot;https://vi.stackexchange.com/questions/8851/interrupting-blink-highlighting-function-if-mapping-is-invoked-again&quot;&gt;this posting&lt;/a&gt; and tried to understand &lt;a href=&quot;https://youtu.be/aHm36-na4-4&quot; rel=&quot;nofollow noreferrer&quot;&gt;this video&lt;/a&gt; but they are way too complicated for me. Is there any way to get a blink simply by adding another attribute to &lt;code&gt;cterm&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks very much for any suggestions!&lt;/p&gt;&#xA;" OwnerUserId="4667" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-01-06T14:09:19.407" Title="Set highlighted token to blink during search and replace" Tags="|search|highlight|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10871" PostTypeId="2" ParentId="10860" CreationDate="2017-01-06T08:54:47.517" Score="2" Body="&lt;p&gt;I do not have xmllint or your file handy, but the following works for me. My VIM buffer is filled with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar&#xA;test&#xA;foo&#xA;bar&#xA;test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then run the command &lt;code&gt;:g/foo/.! cat -n&lt;/code&gt; which produces&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     1  foo&#xA;bar&#xA;test&#xA;     1  foo&#xA;bar&#xA;test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as expected.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastEditorUserId="8061" LastEditDate="2017-01-09T09:02:26.103" LastActivityDate="2017-01-09T09:02:26.103" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10874" PostTypeId="2" ParentId="10242" CreationDate="2017-01-06T12:37:53.463" Score="5" Body="&lt;p&gt;You should install vim from source. That way, you have control over what is included. See the following for more info and a step by step walkthrough. It is relatively easy.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&#xA;https://github.com/vim/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9612" LastActivityDate="2017-01-06T12:37:53.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10875" PostTypeId="1" CreationDate="2017-01-06T12:56:04.800" Score="3" ViewCount="2513" Body="&lt;p&gt;I use vim via the console.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following line in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight LineNr ctermfg=5 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't do anything, but when I type this in as a command, it correctly changes the line numbers' colors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight LineNr ctermfg=5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:verbose highlight LineNr&lt;/code&gt; gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LineNr xxx term=underline ctermfg=11 guifg=Yellow Last set from /usr/share/vim/vim74/colors/elflord.vim &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've been looking all over for some clue about something I'm missing, but I can't see what it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also tried using highlight with various other things, like CursorLine, and I can't get it to work with those either.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the verbose output for LineNr:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oD3Ye.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oD3Ye.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its odd that the colorscheme is the only thing changing the color-I added the highlight line after the colorscheme in the vimrc.&lt;/p&gt;&#xA;" OwnerUserId="10589" LastEditorUserId="51" LastEditDate="2017-01-06T13:55:03.250" LastActivityDate="2018-01-13T07:19:07.330" Title="Why is vim not obeying the LineNr highlighting in my vimrc?" Tags="|vimrc|highlight|" AnswerCount="1" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10876" PostTypeId="2" ParentId="10875" CreationDate="2017-01-06T14:23:15.690" Score="4" Body="&lt;p&gt;If you have anything later in the .vimrc file that changes the same thing as the highlight line, the highlight line will be overridden.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, my &quot;syntax on&quot; line was after the highlight line.  Syntax on changes the Line number colors and was blowing away the highlight line changes.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I had before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight LineNr ctermfg=5 &#xA;syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the correct order to allow the highlight line to override the &quot;syntax on&quot; line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;highlight LineNr ctermfg=5 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10589" LastActivityDate="2017-01-06T14:23:15.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10877" PostTypeId="2" ParentId="6507" CreationDate="2017-01-06T15:21:46.483" Score="2" Body="&lt;p&gt;If you are using vim 8 / neovim, maybe you can try asyncrun: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/skywind3000/asyncrun.vim&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;as a replacement to vim-dispatch/quickrun with better user experience and expansibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iCY9E.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iCY9E.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Easy to use, just start your background command by :AsyncRun (just like old &quot;!&quot; cmd).&lt;/li&gt;&#xA;&lt;li&gt;Command is done in the background, no need to wait for the entire process to finish.&lt;/li&gt;&#xA;&lt;li&gt;Output are displayed in the quickfix window, errors are matched with errorformat.&lt;/li&gt;&#xA;&lt;li&gt;You can explore the error output immediately or keep working in vim while executing.&lt;/li&gt;&#xA;&lt;li&gt;Ring the bell or play a sound to notify you job finished while you're focusing on editing.&lt;/li&gt;&#xA;&lt;li&gt;Fast and lightweight, just a single self-contained asyncrun.vim source file.&lt;/li&gt;&#xA;&lt;li&gt;Provide corresponding user experience in vim, neovim, gvim and macvim.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9681" LastActivityDate="2017-01-06T15:21:46.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10878" PostTypeId="1" AcceptedAnswerId="10880" CreationDate="2017-01-06T17:53:51.487" Score="6" ViewCount="5456" Body="&lt;p&gt;I'm using Vim 8, and my status line is missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I type in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and hit Enter, and nothing seems to happen. Once I do some moving or editing, what I just typed in disappears, and still no statusline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I had a statusline at one point... how do I get it back?&lt;/p&gt;&#xA;" OwnerUserId="8496" LastActivityDate="2017-01-06T18:03:22.427" Title="My statusline is missing. How do I get it back?" Tags="|statusline|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10879" PostTypeId="1" AcceptedAnswerId="10881" CreationDate="2017-01-06T18:03:05.973" Score="1" ViewCount="198" Body="&lt;p&gt;I am using &lt;code&gt;vim-tinyline&lt;/code&gt; and it doesn't seem to have an option for this and I have no idea how to write a function to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example function from tinyline that checks whether the file has been modified:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TlModified() &quot; {{{                                        &#xA;  &quot; Make sure we ignore &amp;amp;modified when choosewin is active          &#xA;&#xA;  let choosewin = exists('g:choosewin_active') &amp;amp;&amp;amp; g:choosewin_active&#xA;  return &amp;amp;modified &amp;amp;&amp;amp; ! choosewin ? ' ⚫' : ''                      &#xA;endfunction     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This one returns a &lt;code&gt;⚫&lt;/code&gt; if the file has been modified. How would I do something similar if &lt;code&gt;spell&lt;/code&gt; is set?&lt;/p&gt;&#xA;" OwnerUserId="10548" LastEditorUserId="51" LastEditDate="2017-01-06T18:10:04.533" LastActivityDate="2017-01-06T19:57:59.557" Title="I want to indicate in the status line whether or not `spell` is set" Tags="|vimscript|spell-checking|statusline|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10880" PostTypeId="2" ParentId="10878" CreationDate="2017-01-06T18:03:22.427" Score="9" Body="&lt;p&gt;Your statusline depends on &lt;code&gt;statusline&lt;/code&gt; for &quot;what&quot; to display on the status line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h statusline&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you also have an option to control &quot;when&quot; to display the status line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h laststatus&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The value of this option influences when the last window will have a&#xA;status line:&#xA;    0: never&#xA;    1: only if there are at least two windows&#xA;    2: always&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in your case you had the setting equal to &lt;code&gt;1&lt;/code&gt;, so the status bar would be displayed only when two or more windows are on screen.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2017-01-06T18:03:22.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10881" PostTypeId="2" ParentId="10879" CreationDate="2017-01-06T19:57:59.557" Score="1" Body="&lt;p&gt;Thanks to user Carpetsmoker above in the comments it was really simple, this is what I ended up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TlSpell() &quot; {{{ &#xA;  &quot; Returns spell state   &#xA;  return &amp;amp;spell ? '⚫' : ''&#xA;endfunction    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10548" LastActivityDate="2017-01-06T19:57:59.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10882" PostTypeId="1" CreationDate="2017-01-07T21:24:28.293" Score="1" ViewCount="479" Body="&lt;p&gt;Let's get directly to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was working with some python code and realized I had written a bunch of &lt;code&gt;elif&lt;/code&gt; blocks as &lt;code&gt;else if&lt;/code&gt; after working too much in Javascript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My natural thought was &quot;cool, I can make an abbreviation to fix those for me so I don't have to think much about it&quot;. Then I realized {lhs} of abbreviations can't contain spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could of course abbrev &lt;code&gt;elif&lt;/code&gt; to &lt;code&gt;else if&lt;/code&gt; and &lt;code&gt;:iunab&lt;/code&gt; it for python, but I was wondering if there's a way to fix it if I ever &lt;em&gt;do&lt;/em&gt; happen to write an &lt;code&gt;else if&lt;/code&gt; in python. I dug through the &lt;code&gt;:h ab&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:inoreabbreviate &amp;lt;expr&amp;gt; if f&lt;/code&gt; where f steps back one word and checks if it's an else-if block could work, but I'm wondering if there's any other way that I just don't know of?&lt;/p&gt;&#xA;" OwnerUserId="9182" LastEditorUserId="9182" LastEditDate="2017-01-08T00:06:47.993" LastActivityDate="2017-01-08T14:32:51.290" Title="Abbreviation-likes containing spaces" Tags="|vimscript|abbreviations|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10883" PostTypeId="2" ParentId="10882" CreationDate="2017-01-07T22:09:57.093" Score="2" Body="&lt;p&gt;You'll have to analyse the context of the text you've typed to know what you want to insert. For instance, you could have a &lt;code&gt;if&lt;/code&gt; abbreviation that detects there is a &lt;code&gt;else&lt;/code&gt; just before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: don't remove abbreviations/mappings for a specific filetype context. Instead define your abbreviations only in a given context with the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; specification. And define your abbreviation in filetype plugins (you could play with autocommands, but this doesn't scale).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you're looking for is something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoreab &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; if repeat(&quot;\&amp;lt;bs&amp;gt;&quot;, strlen(matchstr(getline('.'), 'else\zs\s*if'))).'if'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that it doesn't take the current context into account (comments, strings), nor characters other than a space to end the abbreviation. Beside, we can do more like automatically adding semi-colons and jumping to the next line &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets/blob/master/ftplugin/python/python_snippets.vim#L42&quot; rel=&quot;nofollow noreferrer&quot;&gt;as I do in lh-brackets&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-01-08T00:52:41.210" LastActivityDate="2017-01-08T00:52:41.210" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="10884" PostTypeId="2" ParentId="10882" CreationDate="2017-01-07T22:19:56.523" Score="3" Body="&lt;p&gt;This might not be the perfect answer, but I kind of solved the problem by creating the following &lt;code&gt;augroup&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetype_python&#xA;autocmd!&#xA;autocmd BufRead,BufWrite *.py :%s/else if/elif/g&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, it will substitute &quot;&lt;strong&gt;else if&lt;/strong&gt;&quot; with &quot;&lt;strong&gt;elif&lt;/strong&gt;&quot; (&lt;code&gt;:%s/else if/elif/g&lt;/code&gt;) whenever a *.&lt;em&gt;py&lt;/em&gt; file is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;read    (&lt;code&gt;BufRead&lt;/code&gt;, e.g &lt;code&gt;:split testfile.py&lt;/code&gt;) or&lt;/li&gt;&#xA;&lt;li&gt;written (&lt;code&gt;BufWrite&lt;/code&gt;, e.g &lt;code&gt;:wq&lt;/code&gt; to close save and close the current file)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, it means that if you suddenly find out that you have been writing &quot;&lt;strong&gt;else if&lt;/strong&gt;&quot; you could either write the file with &lt;code&gt;:w&lt;/code&gt;, or just let it be; whenever you save and close it will be substituted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, this might not be the perfect solution for &lt;em&gt;you&lt;/em&gt;. It does seems useful for me (I have &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; remapped to &lt;code&gt;:w&lt;/code&gt;, in order to execute the substitution I just hit space).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway thanks for the exercise! (:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe, you could also check Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-abolish&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim-abolish&lt;/a&gt;, a plugin that: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;easily search for, substitute, and abbreviate multiple variants of a&#xA;  word&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10493" LastEditorUserId="10493" LastEditDate="2017-01-08T14:32:51.290" LastActivityDate="2017-01-08T14:32:51.290" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10885" PostTypeId="1" CreationDate="2017-01-08T00:08:34.867" Score="2" ViewCount="659" Body="&lt;p&gt;You are probably wondering what I could possibly need this for? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, my program will sometimes deal with erroneous strings that need to be manually fixed. So what I do, is I create a process which opens up a Vim, and suspends my program until a signal is emitted in which the file is changed (i.e. saved). I don't want to accidentally save without quitting; that would cause issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is it possible to launch vim in which it is not possible to save without quitting?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastEditorUserId="9004" LastEditDate="2017-01-08T20:14:14.943" LastActivityDate="2017-01-09T13:50:24.943" Title="How do you disable saving in vim unless you quit as well?" Tags="|save|quit|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10886" PostTypeId="2" ParentId="10885" CreationDate="2017-01-08T00:16:44.690" Score="3" Body="&lt;p&gt;You could key an event to an &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Autocommand&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufWritePost :q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will quit if you ever try to write the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Got it the wrong way around, thought you wanted to not be able to quit without saving. Also BufWritePost rather than BufWrite will wait with quitting Vim until it's made sure the entire file is saved. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: A complete list of the autocommand events can be found on &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocmd-events&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h autocmd-events&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9182" LastEditorUserId="1841" LastEditDate="2017-01-09T13:50:24.943" LastActivityDate="2017-01-09T13:50:24.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10888" PostTypeId="1" AcceptedAnswerId="10909" CreationDate="2017-01-08T21:01:53.543" Score="5" ViewCount="5284" Body="&lt;p&gt;Without being in insert mode, from a certain line, I'd like to create a blank line above and below that line in staying on the same line. Could anyone have an idea how to do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify what I'm looking for, if I have three glued lines and I'm on the second line, I want to insert a blank line between the first and second line and another blank line between the second and the third line. I want to do that in staying on the second line and in interactive mode (not insert mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerDisplayName="user10766" LastEditorDisplayName="user10766" LastEditDate="2017-01-08T22:01:39.300" LastActivityDate="2017-01-22T10:05:33.230" Title="Insert blank line above and bellow a certain line" Tags="|command-line|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10889" PostTypeId="2" ParentId="10888" CreationDate="2017-01-08T21:07:30.753" Score="4" Body="&lt;p&gt;To create blank line below current one use &lt;kbd&gt;o&lt;/kbd&gt;, for line above &lt;kbd&gt;O&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-01-08T21:07:30.753" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10891" PostTypeId="1" AcceptedAnswerId="10893" CreationDate="2017-01-08T22:35:54.000" Score="6" ViewCount="742" Body="&lt;p&gt;I'd like to have NERDTree shown everytime I start gvim &lt;em&gt;empty&lt;/em&gt;, that is without passing any argument to it, starting simply to load files rather than to create a new one, such as just by issuing &lt;code&gt;gvim&lt;/code&gt; (and not &lt;code&gt;gvim myfile.txt&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerDisplayName="user10767" LastEditorUserId="51" LastEditDate="2017-01-08T23:01:35.050" LastActivityDate="2017-01-10T14:44:48.867" Title="Start NERDTree when gVim starts empty" Tags="|vimrc|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10892" PostTypeId="2" ParentId="10888" CreationDate="2017-01-09T00:04:54.457" Score="4" Body="&lt;p&gt;Your question looks like an almost duplicate of this question on SO: &lt;a href=&quot;https://stackoverflow.com/questions/3170348/insert-empty-lines-without-entering-insert-mode/3171023&quot;&gt;https://stackoverflow.com/questions/3170348/insert-empty-lines-without-entering-insert-mode/3171023&lt;/a&gt; and of this one on SU: &lt;a href=&quot;https://superuser.com/questions/147715/vim-insert-empty-line-above-current-line-not-open-i-e-without-entering-inser&quot;&gt;https://superuser.com/questions/147715/vim-insert-empty-line-above-current-line-not-open-i-e-without-entering-inser&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I though it was also answered here, but I cannot find any trace of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way, &lt;code&gt;append()&lt;/code&gt; is the best way to insert line(s) without moving the cursor nor altering any thing but the current buffer. It's indeed cumbersome to use on the fly, but for scripting it's the right tool.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap µ :&amp;lt;c-u&amp;gt;call append('.', '')&amp;lt;cr&amp;gt;:call append(line('.')-1, '')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that I don't see a solution that doesn't require to leave the NORMAL mode to enter the COMMAND mode. It respects the requirement of not entering the INSERT mode though)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that when there is no objective of writing a plugin with no side effect, and if the &quot;no insert mode&quot; is just a useless requirement imposed for no good reason, we usually sacrifice a &lt;em&gt;mark&lt;/em&gt; (as in &lt;code&gt;:h mark&lt;/code&gt;) -&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mxO&amp;lt;esc&amp;gt;`xo&amp;lt;esc&amp;gt;`x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We can, of course, put this in a mapping, but it will alter the &lt;code&gt;x&lt;/code&gt; mark, which can be problematic if we use it to bookmark a position in the text/code we're editing. I use marks a lot when I'm editing texts, that's why I avoid them as much as possible in mappings. I don't want the mappings I use to mess with what I'm doing.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-01-09T09:26:41.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10893" PostTypeId="2" ParentId="10891" CreationDate="2017-01-09T04:59:59.930" Score="7" Body="&lt;p&gt;The list of filename arguments can be obtained by calling argv(), so you could put something like this in your ~/.vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if empty(argv())&#xA;    NERDTree&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that putting a command in your ~/.vimrc, whose contents are executed before any plugins are normally loaded, requires that the source for that command be sourced first. Alternatively, you could put this in your ~/.vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if empty(argv())&#xA;    au VimEnter * NERDTree&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will delay the execution of the NERDTree command until after all the plugins have been loaded.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="2055" LastEditDate="2017-01-10T14:44:48.867" LastActivityDate="2017-01-10T14:44:48.867" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10894" PostTypeId="2" ParentId="10885" CreationDate="2017-01-09T09:22:32.087" Score="6" Body="&lt;p&gt;You could play with the &lt;code&gt;write&lt;/code&gt; option. From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27write%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'write'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'write'         boolean (default on)&#xA;            global&#xA;            {not in Vi}&#xA;    Allows writing files.  When not set, writing a file is not allowed.&#xA;    Can be used for a view-only mode, where modifications to the text are&#xA;    still allowed.  Can be reset with the |-m| or |-M| command line&#xA;    argument.  Filtering text is still possible, even though this requires&#xA;    writing a temporary file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So maybe you could use &lt;code&gt;set nowrite&lt;/code&gt; in your vimrc: this will prevent any saving command to work &lt;em&gt;(using autocommands to set &lt;code&gt;nowrite&lt;/code&gt; on specific files would be even more efficient)&lt;/em&gt;. And you can create a mapping to allow writing, something like &lt;code&gt;nnoremap &amp;lt;key&amp;gt; :set write&amp;lt;CR&amp;gt;&lt;/code&gt; to enable &lt;code&gt;write&lt;/code&gt; when to press the key or &lt;code&gt;nnoremap &amp;lt;key&amp;gt; :set write!&amp;lt;CR&amp;gt;&lt;/code&gt; to toggle &lt;code&gt;write&lt;/code&gt;/&lt;code&gt;nowrite&lt;/code&gt; on each keypress.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-01-09T12:30:12.607" LastActivityDate="2017-01-09T12:30:12.607" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10895" PostTypeId="2" ParentId="10885" CreationDate="2017-01-09T09:59:38.810" Score="4" Body="&lt;p&gt;As you have stated in the comments that you need to prevent the automatic saves you perform under muscle memory, you could just remap the particular combination(s) that you perform without thinking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap :w&amp;lt;cr&amp;gt; &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can start Vim with this mapping in place by using the &quot;-c&quot; command line option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;nnoremap :w&amp;lt;cr&amp;gt; &amp;lt;nop&amp;gt;&quot; no_saves_allowed.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-01-09T09:59:38.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10896" PostTypeId="1" AcceptedAnswerId="10899" CreationDate="2017-01-09T16:06:30.183" Score="3" ViewCount="189" Body="&lt;p&gt;I often start editing my code at the top of a deep call chain, and use tags to jump deeper into the call chain.  But when going back to where I was before, I often (out of habit) close vim, meaning to open the last file.  Except where I wanted to go was actually back to the previous entry in the tag stack, so I have to start over at the top of the call chain and work my way down with tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make vim warn before existing if the tag stack is not empty?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking something like the warning that you opened multiple files and haven't viewed them all yet: If you try to exit, you get a warning about there being files that you've not viewed, but if you exit again then vim will actually exit.&lt;/p&gt;&#xA;" OwnerUserId="10776" LastActivityDate="2017-01-09T17:03:18.397" Title="Warn before exiting if tag stack not empty?" Tags="|tags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10897" PostTypeId="1" AcceptedAnswerId="10898" CreationDate="2017-01-09T16:08:52.573" Score="66" ViewCount="41084" Body="&lt;p&gt;I am trying to use vimdiff as my git merge tool, but the colors used are making it unbearable (at least on Windows/Mingw): the background color and the foreground color is the same for some of the conflicting lines, making it needlessly hard to figure out what is going on (see the lines below containing &lt;code&gt;include=&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Plnff.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Plnff.png&quot; alt=&quot;example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1087" LastEditorUserId="21817" LastEditDate="2021-05-26T16:54:24.463" LastActivityDate="2023-06-25T06:44:38.363" Title="How do I customize vimdiff colors?" Tags="|colorscheme|vimdiff|color|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10898" PostTypeId="2" ParentId="10897" CreationDate="2017-01-09T16:55:32.567" Score="45" Body="&lt;p&gt;The colors are controlled by these four highlight groups (&lt;code&gt;:help hl-DiffAdd&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DiffAdd     diff mode: Added line&#xA;DiffChange  diff mode: Changed line&#xA;DiffDelete  diff mode: Deleted line&#xA;DiffText    diff mode: Changed text within a changed line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These are typically defined by a &lt;em&gt;color scheme&lt;/em&gt;, but you can customize them in your &lt;code&gt;~/.vimrc&lt;/code&gt; (after the &lt;code&gt;:colorscheme&lt;/code&gt; command) if you like you scheme overall, just not its diff highlighting. Just redefine using &lt;code&gt;:highlight&lt;/code&gt;. Here are my personal customizations (for GVIM; for the terminal you need the appropriate &lt;code&gt;ctermfg/bg=...&lt;/code&gt; attributes instead / in addition):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi DiffAdd      gui=none    guifg=NONE          guibg=#bada9f&#xA;hi DiffChange   gui=none    guifg=NONE          guibg=#e5d5ac&#xA;hi DiffDelete   gui=bold    guifg=#ff8080       guibg=#ffb0b0&#xA;hi DiffText     gui=none    guifg=NONE          guibg=#8cbee2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're switching colorschemes on the fly, you need to re-invoke those &lt;code&gt;:hi&lt;/code&gt; commands via &lt;code&gt;:autocmd ColorScheme * hi ...&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2017-01-09T16:55:32.567" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10899" PostTypeId="2" ParentId="10896" CreationDate="2017-01-09T17:03:18.397" Score="3" Body="&lt;p&gt;There's no built-in option, but you can implement a custom command that either &lt;code&gt;:quit&lt;/code&gt;s or &lt;code&gt;:pop&lt;/code&gt;s the last item from the tag stack.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! QuitOrPop try | pop |  catch /^Vim\%((\a\+)\)\=:E\%(73\|555\):/ | quit | endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This attempts to &lt;code&gt;:pop&lt;/code&gt; and only &lt;code&gt;:quit&lt;/code&gt;s if there's a &lt;code&gt;tag stack empty&lt;/code&gt; or &lt;code&gt;at bottom of tag stack&lt;/code&gt; error message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could then use the &lt;a href=&quot;http://www.vim.org/script.php?script_id=746&quot; rel=&quot;nofollow noreferrer&quot;&gt;cmdalias.vim - Create aliases for Vim commands&lt;/a&gt; plugin to override the built-in &lt;code&gt;:q&lt;/code&gt; (and variants like &lt;code&gt;:wq&lt;/code&gt;) with the new &lt;code&gt;:QuitOrPop&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2017-01-09T17:03:18.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10901" PostTypeId="1" AcceptedAnswerId="14681" CreationDate="2017-01-10T00:23:17.057" Score="3" ViewCount="503" Body="&lt;p&gt;When I run &lt;code&gt;shopt -s globstar; ls -1 tests/**/Helpers/**/*.php&lt;/code&gt; in &lt;code&gt;bash&lt;/code&gt; I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tests/Helpers/Layout.php&#xA;tests/Helpers/Link.php&#xA;tests/Helpers/LinksPage.php&#xA;tests/Helpers/LiqpayRedirect.php&#xA;tests/Helpers/LoginPage.php&#xA;tests/Helpers/Project.php&#xA;tests/Helpers/ProjectsPage.php&#xA;tests/Helpers/QueriesPage.php&#xA;tests/Helpers/Query.php&#xA;tests/Helpers/User.php&#xA;tests/Selenium/Helpers/Layout.php&#xA;tests/Selenium/Helpers/LinksPage.php&#xA;tests/Selenium/Helpers/ProjectsPage.php&#xA;tests/Selenium/Helpers/QueriesPage.php&#xA;tests/Selenium/Helpers/RegisterPage.php&#xA;tests/Selenium/Helpers/User.php&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But doing &lt;code&gt;args tests/**/Helpers/**/*.php&lt;/code&gt; in &lt;code&gt;vim&lt;/code&gt; defines argument list consisting only of files with &lt;code&gt;Selenium&lt;/code&gt; in path. Am I doing it wrong? What exactly are the rules? From the docs it sounds like it should work.&lt;/p&gt;&#xA;" OwnerUserId="1553" LastEditorUserId="1553" LastEditDate="2019-12-13T15:44:00.137" LastActivityDate="2019-12-13T15:44:00.137" Title="How does double star work in vim?" Tags="|argument-list|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10904" PostTypeId="2" ParentId="10901" CreationDate="2017-01-10T08:50:27.663" Score="5" Body="&lt;p&gt;You can check with &lt;code&gt;echo glob2regpat('tests/**/Helpers/**/*.php')&lt;/code&gt; to what regular expression this will be translated. This returns: &lt;code&gt;^tests[\/].*[\/]Helpers[\/].*[\/].*\.php$&lt;/code&gt;, so it will look only for a Helpers directory which is located below any directory underneath the tests directory.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2017-01-10T14:02:09.713" LastActivityDate="2017-01-10T14:02:09.713" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="10905" PostTypeId="1" AcceptedAnswerId="10907" CreationDate="2017-01-10T10:41:27.583" Score="4" ViewCount="10574" Body="&lt;p&gt;I have a file that looks as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aa,bb,cc,dd,ee,ff,gg&#xA;aa,bb,cc,dd,hh&#xA;aa,bb,cc,dd,ii,jj&#xA;etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to (preferably using one command) change occurrences of a &lt;code&gt;,&lt;/code&gt; by a &lt;code&gt;:&lt;/code&gt; from the 5th &lt;code&gt;,&lt;/code&gt; until the last one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would thus get: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aa,bb,cc,dd,ee:ff:gg&#xA;aa,bb,cc,dd,hh&#xA;aa,bb,cc,dd,ii:jj&#xA;etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, is there a way in vim to skip the first 4 (or n) occurrences of a pattern match and replace all other pattern matches (with the substitute command for example)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1,$s/\(\([^,]*,\)\{4\}\)\([^,]*\),/\1\3:/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this only changes the 5th occurrence...&lt;/p&gt;&#xA;" OwnerUserId="10786" LastEditorUserId="1841" LastEditDate="2017-01-10T11:42:20.213" LastActivityDate="2017-01-10T11:51:47.200" Title="Substitution: how to ignore the Nth first occurrences of a pattern?" Tags="|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10906" PostTypeId="2" ParentId="10905" CreationDate="2017-01-10T10:51:50.453" Score="4" Body="&lt;p&gt;You'll have to play with &lt;code&gt;/\=&lt;/code&gt;+&lt;code&gt;submatch()&lt;/code&gt; and &lt;code&gt;substitute()&lt;/code&gt;. First &lt;code&gt;:s&lt;/code&gt; will select what is before the 5th coma (to ignore it until the zone start &lt;code&gt;:h /\zs&lt;/code&gt;), then &lt;code&gt;substitute()&lt;/code&gt; will replace the remaining comas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like (untested)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v([^,]*,){4}\zs([^,]*),/\=substitute(submatch(0), ',', '::', 'g')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-01-10T10:51:50.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10907" PostTypeId="2" ParentId="10905" CreationDate="2017-01-10T11:00:33.397" Score="4" Body="&lt;p&gt;You could also try the following substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v(^(.{-},){4}.*)@&amp;lt;=,/:/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pattern is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v(^(.{-},){4}.*)@&amp;lt;=,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be broken down like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v(^(.{-},){4}.*)@&amp;lt;=,&#xA;| |||  |   |  |  |  |&#xA;| |||  |   |  |  |  +--- a comma&#xA;| |||  |   |  |  +--- the previous subpattern must be matched before what follows&#xA;| |||  |   |  +--- `.*` any text&#xA;| |||  |   +--- repeat the previous subpattern `.{-},` 4 times&#xA;| |||  |&#xA;| |||  |&#xA;| |||  +--- `.{-},` a minimum of text before a comma&#xA;| ||+--- capture the `.{-},` subpattern to apply the multi `{4}` to it&#xA;| |+--- beginning of a line (anchor)&#xA;| +--- capture the `^(.{-},){4}.*` subpattern to apply the multi `@&amp;lt;=` to it&#xA;+--- very magic mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;@&amp;lt;=&lt;/code&gt; multi doesn't add anything to the pattern, it just asks the regex engine to make sure that at least 4 commas are found before the commas you want to substitute with a colon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, there are 2 subpatterns you're capturing but you don't use any backreference to them (&lt;code&gt;\1&lt;/code&gt;, &lt;code&gt;\2&lt;/code&gt;, ..., &lt;code&gt;\9&lt;/code&gt;), so you could tell Vim that you don't want it to count them as sub-expressions by prefixing a &lt;code&gt;%&lt;/code&gt; sign before each open parenthesis:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v%(^%(.{-},){4}.*)@&amp;lt;=,/:/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to the help (&lt;code&gt;:h /\%(&lt;/code&gt;), it makes the pattern a little bit faster.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'm not sure, but more generally, it should work for other patterns too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose you wanted to replace all the occurrences of &lt;code&gt;foobar&lt;/code&gt;, but ignoring the first &lt;code&gt;N&lt;/code&gt; ones on any given line. Then, you could adapt the previous substitution command like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v(^(.{-}foobar){N}.*)@&amp;lt;=foobar/replacement/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-01-10T11:51:47.200" LastActivityDate="2017-01-10T11:51:47.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10909" PostTypeId="2" ParentId="10888" CreationDate="2017-01-10T12:27:27.240" Score="1" Body="&lt;p&gt;Use marks. For example put this into your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;A-j&amp;gt; :set paste&amp;lt;CR&amp;gt;m`o&amp;lt;Esc&amp;gt;``:set nopaste&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;A-k&amp;gt; :set paste&amp;lt;CR&amp;gt;m`O&amp;lt;Esc&amp;gt;``:set nopaste&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt; and &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;k&lt;/kbd&gt; &lt;strong&gt;inserts blank line above and below current line in normal mode&lt;/strong&gt; respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here a nice addition for &lt;strong&gt;deleting a blank line below/above only if any exists&lt;/strong&gt; (using regular expressions).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;A-S-j&amp;gt; m`:silent +g/\m^\s*$/d&amp;lt;CR&amp;gt;``:noh&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;A-S-k&amp;gt; m`:silent -g/\m^\s*$/d&amp;lt;CR&amp;gt;``:noh&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt; deletes empty line below and &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;k&lt;/kbd&gt; deletes empty line above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find these mappings intuitive and confortable. Enjoy :) *Sometimes there problems with alt/meta key, so use what works fine for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read more (inter alia code explanation) in the source: &lt;a href=&quot;http://vim.wikia.com/wiki/Quickly_adding_and_deleting_empty_lines&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Quickly_adding_and_deleting_empty_lines&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8444" LastEditorUserId="8444" LastEditDate="2017-01-22T10:05:33.230" LastActivityDate="2017-01-22T10:05:33.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10911" PostTypeId="2" ParentId="340" CreationDate="2017-01-10T17:27:18.373" Score="4" Body="&lt;p&gt;I figured out a way to do that with &lt;a href=&quot;http://www.hammerspoon.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hammerspoon&lt;/a&gt;&#xA;and clever usage of mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first part is configuring &lt;kbd&gt;Shift&lt;/kbd&gt; + &lt;kbd&gt;ScrollUp&lt;/kbd&gt; and&#xA;&lt;kbd&gt;Shift&lt;/kbd&gt; + &lt;kbd&gt;ScrollDown&lt;/kbd&gt; to scroll horizontally. In&#xA;order to do that, you have put the following code snippet in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;nnoremap &amp;lt;S-ScrollWheelUp&amp;gt; &amp;lt;ScrollWheelLeft&amp;gt;&#xA;nnoremap &amp;lt;S-2-ScrollWheelUp&amp;gt; &amp;lt;2-ScrollWheelLeft&amp;gt;&#xA;nnoremap &amp;lt;S-3-ScrollWheelUp&amp;gt; &amp;lt;3-ScrollWheelLeft&amp;gt;&#xA;nnoremap &amp;lt;S-4-ScrollWheelUp&amp;gt; &amp;lt;4-ScrollWheelLeft&amp;gt;&#xA;nnoremap &amp;lt;S-ScrollWheelDown&amp;gt; &amp;lt;ScrollWheelRight&amp;gt;&#xA;nnoremap &amp;lt;S-2-ScrollWheelDown&amp;gt; &amp;lt;2-ScrollWheelRight&amp;gt;&#xA;nnoremap &amp;lt;S-3-ScrollWheelDown&amp;gt; &amp;lt;3-ScrollWheelRight&amp;gt;&#xA;nnoremap &amp;lt;S-4-ScrollWheelDown&amp;gt; &amp;lt;4-ScrollWheelRight&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that we have to use &lt;code&gt;&amp;lt;S-2-ScrollWheelUp&amp;gt;&lt;/code&gt; and the like&#xA;because they are sent as keys to the terminal as well. I found no&#xA;documentation about this (I figured this out by using&#xA;&lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;V&lt;/kbd&gt; while scrolling in insert mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, we have to remap horizontal scrolls to &lt;kbd&gt;Shift&lt;/kbd&gt; + vertical scrolls. To do so, we place the following snippet in Hammerspoon's &lt;code&gt;init.lua&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-lua prettyprint-override&quot;&gt;&lt;code&gt;scrollBind = hs.eventtap.new({hs.eventtap.event.types.scrollWheel}, function(e)&#xA;  if is_active('iTerm2') then&#xA;    local horizontalOffset = e:getProperty(hs.eventtap.event.properties.scrollWheelEventDeltaAxis2)&#xA;&#xA;    if horizontalOffset ~= 0 then&#xA;      hs.eventtap.scrollWheel({ 0, horizontalOffset }, {&quot;shift&quot;}, 'pixel')&#xA;      return true&#xA;    end&#xA;  end&#xA;&#xA;  return false&#xA;end):start()&#xA;&#xA;function is_active(program_name)&#xA;  local active_window_name = hs.window.focusedWindow():application():name()&#xA;  return active_window_name == program_name&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We create the &lt;code&gt;scrollBind&lt;/code&gt; variable just so the keystroke watcher isn't erased by the Lua's garbage collector.&lt;/p&gt;&#xA;" OwnerUserId="6640" LastEditorUserId="6640" LastEditDate="2017-09-20T20:22:18.003" LastActivityDate="2017-09-20T20:22:18.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10912" PostTypeId="1" CreationDate="2017-01-10T20:46:36.167" Score="1" ViewCount="1129" Body="&lt;p&gt;According to the documentation for &lt;code&gt;shellescape&lt;/code&gt; in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;shellescape({string}, [, {special}])      shell escape()&#xA;&#xA;Escape {string} for use as a shell command argument.&#xA;...&#xA;For other systems, it will enclose {string} in single quotes and replace all &quot;'&quot; with &quot;'\''&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a function that will escape the same characters for the shell without enclosing {string} in single quotes?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="9004" LastEditDate="2017-01-11T07:33:56.353" LastActivityDate="2017-02-10T10:41:34.010" Title="Alternative to shellescape that doesn't add quotes in Linux?" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10913" PostTypeId="1" CreationDate="2017-01-10T23:17:28.990" Score="9" ViewCount="2306" Body="&lt;p&gt;I recently received a pull request to change my vim plugin to make it support python3. But these changes break the plugin for the vim on my Mac which seems to listen to python.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python import sys&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;versus&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python3 import sys&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there an elegant method to make the script in my plugin detect which statement it should use? Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('python')&#xA;   python import ...&#xA;elseif if has('python3')&#xA;   python3 import ...&#xA;else&#xA;   finish&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2165" LastEditorUserId="1841" LastEditDate="2017-01-11T09:52:41.587" LastActivityDate="2018-01-27T07:06:00.863" Title="Elegant way to support both python and python3 in vim plugin" Tags="|plugin-system|vimscript-python|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10914" PostTypeId="1" AcceptedAnswerId="10925" CreationDate="2017-01-11T02:22:57.010" Score="1" ViewCount="72" Body="&lt;p&gt;I'm using the easymotion plugin and mapping my arrow keys to do calls to easymotion. Concretely:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;down&amp;gt; &amp;lt;Plug&amp;gt;(easymotion-w)&#xA;map &amp;lt;left&amp;gt; &amp;lt;Plug&amp;gt;(easymotion-F)&#xA;map &amp;lt;right&amp;gt; &amp;lt;Plug&amp;gt;(easymotion-bd-f)&#xA;map &amp;lt;up&amp;gt; &amp;lt;Plug&amp;gt;(easymotion-B)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works as intended. Now I want it to work also in insert mode so I added:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;down&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;down&amp;gt;&#xA;imap &amp;lt;left&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;left&amp;gt;&#xA;imap &amp;lt;right&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;right&amp;gt;&#xA;imap &amp;lt;up&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;up&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now in insert mode &lt;em&gt;down&lt;/em&gt; and &lt;em&gt;up&lt;/em&gt; work like the default keys (moving up and down) whereas &lt;em&gt;right&lt;/em&gt; &lt;em&gt;left&lt;/em&gt; have the intended behaviour. However, to me they seem equivalent mappings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried changing to &lt;code&gt;imap &amp;lt;down&amp;gt; &amp;lt;Esc&amp;gt;dd&lt;/code&gt;, still does the default behaviour. If I put &lt;code&gt;imap &amp;lt;left&amp;gt; &amp;lt;Esc&amp;gt;dd&lt;/code&gt; it deletes the line. So it may not be related to easymotion in particular.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question 1&lt;/strong&gt; What is happening and how can I solve it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question 2&lt;/strong&gt;: is this the most elegant/correct way to do mappings?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; at first I thought it may be affected by the time it  takes to go from Insert to Normal mode, so I added the following piece of code that solves it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set timeout &quot; Do time out on mappings and others&#xA;set timeoutlen=2000 &quot; Wait {num} ms before timing out a mapping&#xA;   &quot;when press Esc to leave Ins mode it no longer takes a second&#xA;   &quot;or another keystroke to leave Ins mode completely and update&#xA;   &quot;the satus line.&#xA;set ttimeoutlen=0&#xA;augroup FastEscape:&#xA;    autocmd!&#xA;    au InsertEnter * set timeoutlen=0&#xA;    au InsertLeave * set timeoutlen=1000&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10764" LastActivityDate="2017-01-11T14:42:52.423" Title="Two apparently equivalent mappings, one works the other doesn't" Tags="|key-bindings|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10915" PostTypeId="2" ParentId="10913" CreationDate="2017-01-11T02:52:53.037" Score="5" Body="&lt;p&gt;If you want to avoid rewriting the Python script, put it in a separate file and use &lt;code&gt;:pyfile&lt;/code&gt; or &lt;code&gt;:py3file&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let script_path = expand('&amp;lt;sfile&amp;gt;:p:h') . '/script.py'&#xA;&#xA;if !has('python') and !has('python3')&#xA;   finish&#xA;endif&#xA;&#xA;execute (has('python3') ? 'py3file' : 'pyfile') script_path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will load &lt;code&gt;script.py&lt;/code&gt; that's in the same directory.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-01-11T02:52:53.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10916" PostTypeId="1" CreationDate="2017-01-11T04:17:54.157" Score="0" ViewCount="940" Body="&lt;p&gt;Running &lt;code&gt;execute g:xx&lt;/code&gt; doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:str=&quot;move to right win\t&amp;lt;C-w&amp;gt;h&quot;&#xA;let g:temp=escape(matchstr(g:str,'\(\t\)\@&amp;lt;=.*$'),'&amp;lt;')&#xA;let g:xx= &quot;normal &quot;.g:temp&#xA;&#xA;execute g:xx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain why?&lt;/p&gt;&#xA;" OwnerUserId="10798" LastEditorUserId="51" LastEditDate="2017-01-11T09:49:17.550" LastActivityDate="2017-01-11T10:27:05.960" Title="execute normal command doesn't work" Tags="|vimscript|normal-mode|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10918" PostTypeId="2" ParentId="10916" CreationDate="2017-01-11T05:44:22.487" Score="-1" Body="&lt;p&gt;In your first line, the &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; is not escaped, so it appears to be matched as a literal string, and the &lt;code&gt;escape&lt;/code&gt; function doesn't convert it to the ^W character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to get what you want, the first line should actually read&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:str=&quot;move to right win\t\&amp;lt;C-w&amp;gt;h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In addition, according to the documentation &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#escape()&quot; rel=&quot;nofollow noreferrer&quot;&gt;here at sourceforge&lt;/a&gt;, the escape command doesn't work how you appear to think. It's going to escape just the '&amp;lt;' character, which does nothing.&lt;/p&gt;&#xA;" OwnerUserId="5298" LastEditorUserId="5298" LastEditDate="2017-01-11T06:31:03.940" LastActivityDate="2017-01-11T06:31:03.940" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10919" PostTypeId="2" ParentId="862" CreationDate="2017-01-11T05:49:16.943" Score="1" Body="&lt;p&gt;This is perhaps less preferable than using a pure-vim solution, however, if you use a snippet manager such as &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ultisnips&lt;/a&gt; then you could try &lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt#L568&quot; rel=&quot;nofollow noreferrer&quot;&gt;adding a snippet&lt;/a&gt; such as the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet uuid &quot;insert new uuid&quot; w&#xA;`uuidgen`&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you can type &lt;code&gt;uuid&lt;/code&gt; and hit your expand trigger in insert-mode and &lt;code&gt;uuid&lt;/code&gt; will be replaced with the output of the relevant shell command.  This, of course, can be easily adapted for other commands and expanded upon in powerful ways as outlined in the Ultisnips docs.&lt;/p&gt;&#xA;" OwnerUserId="10800" LastActivityDate="2017-01-11T05:49:16.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10920" PostTypeId="2" ParentId="10916" CreationDate="2017-01-11T08:59:54.063" Score="1" Body="&lt;pre&gt;&lt;code&gt;let g:temp=eval('&quot;'. g:temp .'&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:temp=escape(matchstr(g:str,'\(\t\)\@&amp;lt;=.*$'),'&amp;lt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Extracting this into a &lt;code&gt;:function&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Literalize(string)&#xA;    &quot; get already properly escaped sequences out of the way, so we don't double-escape them&#xA;    let s = eval('&quot;'. a:string .'&quot;')&#xA;    &quot; escape remaining special key sequences&#xA;    let s = escape(s, '&amp;lt;')&#xA;    let s = eval('&quot;'.   s      .'&quot;')&#xA;    return s&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Explanation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The problem was that &lt;code&gt;escape()&lt;/code&gt; handles its input° and output &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#expr-string&quot; rel=&quot;nofollow noreferrer&quot;&gt;strings&lt;/a&gt; as a literal-string (as in single quotes &lt;code&gt;''&lt;/code&gt;).  So escaping the &lt;code&gt;&amp;lt;&lt;/code&gt; in &lt;code&gt;&quot;&amp;lt;C-w&amp;gt;&quot;&lt;/code&gt; results in &lt;code&gt;'\&amp;lt;C-w&amp;gt;'&lt;/code&gt;, not the desired &lt;code&gt;&quot;\&amp;lt;C-w&amp;gt;&quot;&lt;/code&gt;/&lt;code&gt;'^W'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;° If the input is given as a double quoted &lt;code&gt;&quot;string&quot;&lt;/code&gt;, its escape sequences are evaluated by the vimscript parser, before it is passed to &lt;code&gt;escape()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2314" LastEditorUserId="2314" LastEditDate="2017-01-11T10:27:05.960" LastActivityDate="2017-01-11T10:27:05.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10921" PostTypeId="2" ParentId="10912" CreationDate="2017-01-11T09:55:33.860" Score="1" Body="&lt;p&gt;A very long time ago, long before &lt;code&gt;shellescape()&lt;/code&gt;, and I don't remember if &lt;code&gt;escape()&lt;/code&gt; existed at that time, I wrote a function with the aim of running external commands from vim. Now it's shipped with my &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-vim-lib&lt;/a&gt; library, on vim.org we may find a trace of it in my system-tools set of scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way, I copy-paste its documentation and its code, I can't tell whether it'll be of any help to you, you'll have to check.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The doc.&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                *lh#path#fix()*                   {{{3&#xA;lh#path#fix({pathname} [,{shellslash} [,{quote-char}]]~&#xA;Discl.: This function is the old |system-tools|' |FixPathName| moved to lh-vim-lib.&#xA;&#xA;This function corrects the {a:pathname} passed in parameter and, returns the&#xA;newly fixed pathname that will be usable will external tools.&#xA;&#xA;Under Windows boxes, it will build the new path according to the value of&#xA;{shellslash}. Under other systems, the new path will be exclusively composed of&#xA;forward slashes. According to {quote-char}, quote characters may be added around&#xA;the returned pathname.&#xA;&#xA;For instance, paths like &quot;`c:\Program Files/alongpath/some\ spaces/foo`&quot; will be&#xA;changed into: &amp;gt;&#xA;    c:\Program Files\alongpath\some spaces\foo   + {quote-char} around&#xA; or c:/Program\ Files/alongpath/some\ spaces/foo + {quote-char} around&#xA;according to {shellslash} value.&#xA;&#xA;Internal considerations~&#xA;    {quote-char} will value the character:&#xA;        1- {a:quote-char} if given,&#xA;        2- &quot;&quot; (empty string) otherwise.&#xA;    {shellslash} will value the boolean:&#xA;        1- {a:shellslash} if given&#xA;        2- 'shellslash' if win16, win32, dos16 or dos32&#xA;                    and if |SystemDetected()| != &quot;msdos&quot;&#xA;        3- 1 if |SystemDetected()| == &quot;unix&quot;&#xA;    if {quote-char}==&quot;&quot; &amp;amp;&amp;amp; !{shellslash} &amp;amp;&amp;amp; |SystemDetected()|==&quot;`msdos`&quot;&#xA;        if 'shell' == &quot;`command.com`&quot; =&amp;gt; {quote-char} &amp;lt;- ''&#xA;        else                        =&amp;gt; {quote-char} &amp;lt;- '&quot;'&#xA;&#xA;Note: If you are using &quot;`command.com`&quot; (and not cmd.exe which is available on&#xA;MsWindows NT series), you may run into troubles if the {a:pathname} contains&#xA;spaces.&#xA;&#xA;Exemples~&#xA;    This mapping opens the current file in MsWindows's files explorer&#xA;    [Note: this works if the 'shell' is bash or $COMSPEC]: &amp;gt;&#xA;        nmap ,view :exe '!start explorer '.lh#path#fix(expand('%:p'),0)&amp;lt;cr&amp;gt;&#xA;&#xA;Note: Unlike |fnameescape()|, |lh#path#fix()| will work even under the Windows native flavour of gvim, whichever the |'shellslash'| is, and whichever the |'shell'| is.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Function: lh#path#fix(pathname [, shellslash [, quote_char ]]) {{{3&#xA;&quot; This function was FixEnsurePath from system_tools&#xA;function! lh#path#fix(pathname, ...) abort&#xA;  &quot; Parameters       {{{4&#xA;  &quot; Ignore the last slash or backslash character, if any&#xA;  let pathname   = matchstr(a:pathname, '^.*[^/\\]')&#xA;  &quot; Default value for the quote character&#xA;  let quote_char = ''&#xA;  &quot; Determine if 'shellslash' exists (dos-like platforms)&#xA;  if lh#os#OnDOSWindows()&#xA;    if lh#os#system_detected() == 'msdos'&#xA;      let shellslash = 0&#xA;    else&#xA;      let shellslash = &amp;amp;shellslash&#xA;    endif&#xA;  else &quot;unix&#xA;    let shellslash = 1&#xA;  endif&#xA;  &quot; Determine if we will use slashes or backslashes to distinguish directories&#xA;  if a:0 &amp;gt;= 1   &quot;&#xA;    let shellslash = a:1&#xA;    if a:0 &amp;gt;= 2&#xA;      let quote_char = a:2&#xA;    endif&#xA;  endif&#xA;&#xA;  &quot; Smart definition of quote chars for $COMSPEC&#xA;  if (lh#os#system_detected() == 'msdos') &amp;amp;&amp;amp; !shellslash &amp;amp;&amp;amp; (''==quote_char)&#xA;    if (&amp;amp;shell =~ 'command\.com')&#xA;      if pathname =~ ' '&#xA;        &quot; should also test long directory-names...&#xA;        &quot; Best: AVOID command.com !!!&#xA;        if &amp;amp;verbose &amp;gt;= 1&#xA;          call lh#common#error_msg('lh#path#fix: '.&#xA;                \ 'Problem expected because of the space in &amp;lt;'.pathname.'&amp;gt;')&#xA;        endif&#xA;      else&#xA;        let quote_char = ''&#xA;      endif&#xA;    else&#xA;      let quote_char = '&quot;'&#xA;    endif&#xA;  endif&#xA;&#xA;  &quot; Fix the pathname {{{4&#xA;  if shellslash&#xA;    &quot; return substitute(dname, '\\\([^ ]\|$\)', '/\1', 'g')&#xA;    let res = substitute(&#xA;          \ substitute(pathname, '\\\([^ ]\|$\)', '/\1', 'g'),&#xA;          \ '\(^\|[^\\]\) ', '\1\\ ', 'g')&#xA;  else&#xA;    &quot; return substitute(&#xA;          &quot; \ substitute(pathname, '\([^\\]\) ', '\1\\ ', 'g'),&#xA;          &quot; \ '/', '\\', 'g')&#xA;    let res = substitute(&#xA;          \ substitute(pathname, '\\ ', ' ', 'g'),&#xA;          \ '/', '\\', 'g')&#xA;  endif&#xA;  &quot; Note: problem to take care (that explains the complex substition schemes):&#xA;  &quot; sometimes the path passed to the function mix the two writtings, e.g.:&#xA;  &quot; &quot;c:\Program Files/longpath/some\ spaces/foo&quot;&#xA;  &quot; }}}4&#xA;  return quote_char . res . quote_char&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-01-11T09:55:33.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10922" PostTypeId="1" AcceptedAnswerId="10923" CreationDate="2017-01-11T10:14:29.780" Score="14" ViewCount="1331" Body="&lt;p&gt;Is it somehow possible to have different search patterns per window or buffer, ie. I want to search for term A in window/buffer A and term B in window/buffer B so that using &lt;code&gt;hlsearch&lt;/code&gt;, highlights different things in e.g. a split in parallel.&lt;/p&gt;&#xA;" OwnerUserId="8891" LastActivityDate="2023-03-09T05:45:19.043" Title="different search patterns per window / buffer" Tags="|search|buffers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10923" PostTypeId="2" ParentId="10922" CreationDate="2017-01-11T11:55:52.727" Score="13" Body="&lt;p&gt;You can use &lt;code&gt;:autocmd&lt;/code&gt;s to switch the current search pattern (register &lt;code&gt;/&lt;/code&gt;) as you move along windows and buffers, but Vim will never highlight different patterns at the same time, as this still is a single global register, just being multiplexed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from searching, you can highlight different patterns (also with different colors) via the built-in &lt;code&gt;:match&lt;/code&gt;, &lt;code&gt;:2match&lt;/code&gt;, &lt;code&gt;:3match&lt;/code&gt;, and &lt;code&gt;:call matchadd()&lt;/code&gt;. These are window-local.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, there are plugins like my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2666&quot; rel=&quot;noreferrer&quot;&gt;Mark plugin&lt;/a&gt; that offer highlighting, searching, jumping to next match (similar to the built-in search), for multiple patterns. (The plugin page has links to alternative plugins.)&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2017-01-11T11:55:52.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10924" PostTypeId="1" CreationDate="2017-01-11T12:17:01.067" Score="0" ViewCount="984" Body="&lt;p&gt;For a few days now I always getting the following error when pressing any key in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing &quot;function &amp;lt;SNR&amp;gt;53_OnCursorMovedNormalMode[5]..&amp;lt;SNR&amp;gt;53_OnFileReadyToParse&quot;:&#xA;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;  File &quot;/usr/share/vim-youcompleteme/python/ycm/youcompleteme.py&quot;, line 508, in HandleFileParseRequest&#xA;    self.NativeFiletypeCompletionUsable() ):&#xA;  File &quot;/usr/share/vim-youcompleteme/python/ycm/youcompleteme.py&quot;, line 255, in NativeFiletypeCompletionUsable&#xA;    self.NativeFiletypeCompletionAvailable() )&#xA;  File &quot;/usr/share/vim-youcompleteme/python/ycm/youcompleteme.py&quot;, line 250, in NativeFiletypeCompletionAvailable&#xA;    vimsupport.CurrentFiletypes() ] )&#xA;  File &quot;/usr/share/vim-youcompleteme/python/ycm/youcompleteme.py&quot;, line 249, in &amp;lt;listcomp&amp;gt;&#xA;    return any( [ self.FiletypeCompleterExistsForFiletype( x ) for x in&#xA;  File &quot;/usr/share/vim-youcompleteme/python/ycm/youcompleteme.py&quot;, line 240, in FiletypeCompleterExistsForFiletype&#xA;    exists_completer = SendCompleterAvailableRequest( filetype )&#xA;  File &quot;/usr/share/vim-youcompleteme/python/ycm/client/completer_available_request.py&quot;, line 57, in SendCompleterAvailableRequest&#xA;    request.Start()&#xA;  File &quot;/usr/share/vim-youcompleteme/python/ycm/client/completer_available_request.py&quot;, line 45, in Start&#xA;    'semantic_completion_available' )&#xA;  File &quot;/usr/share/vim-youcompleteme/python/ycm/client/base_request.py&quot;, line 81, in PostDataToHandler&#xA;    timeout ) )&#xA;  File &quot;/usr/share/vim-youcompleteme/python/ycm/client/base_request.py&quot;, line 174, in JsonFromFuture&#xA;    _ValidateResponseObject( response )&#xA;  File &quot;/usr/share/vim-youcompleteme/python/ycm/client/base_request.py&quot;, line 203, in _ValidateResponseObject&#xA;    their_hmac = ToBytes( b64decode( response.headers[ _HMAC_HEADER ] ) )&#xA;  File &quot;/usr/lib/python3/dist-packages/requests/structures.py&quot;, line 54, in __getitem__&#xA;    return self._store[key.lower()][1]&#xA;KeyError: 'x-ycm-hmac'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using vim on Ubuntu 16.04 with the official vim-youcompleteme package.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are questions with the same problem on stackoverflow &lt;a href=&quot;https://stackoverflow.com/q/41532399/6552284&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://stackoverflow.com/q/41510573/6552284&quot;&gt;here&lt;/a&gt;, unfortunately without answers.&lt;/p&gt;&#xA;" OwnerUserId="10166" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-02-24T00:12:33.150" Title="youcompleteme key error when using vim" Tags="|plugin-you-complete-me|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10925" PostTypeId="2" ParentId="10914" CreationDate="2017-01-11T14:42:52.423" Score="2" Body="&lt;p&gt;As @TommyA pointed out in the comments, a plugin was changing &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;down&amp;gt;&lt;/code&gt;. Turned out to be 'youcompleteme', in /autoload/youcompleteme.vim. There &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt; &lt;code&gt;&amp;lt;down&amp;gt;&lt;/code&gt; aren't explicitely mentioned, but they are called because they are part of the &lt;code&gt;g:ycm_key_list_select_completion&lt;/code&gt; and &lt;code&gt;g:ycm_key_list_previous_completion&lt;/code&gt; lists. Those lists were defined in youcompleteme/plugin/youcompleteme.vim, editing them solved the issue.&lt;/p&gt;&#xA;" OwnerUserId="10764" LastActivityDate="2017-01-11T14:42:52.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10926" PostTypeId="2" ParentId="10913" CreationDate="2017-01-11T16:17:17.920" Score="3" Body="&lt;p&gt;My technique for distinction of the python versions is to create a separate command (although this is in my &lt;code&gt;.vimrc&lt;/code&gt; startup files, you can modify as needed for the plugin code.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PyImports()&#xA;Py &amp;lt;&amp;lt; EOF&#xA;import sys, os, .....&#xA;EOF&#xA;endfunction&#xA;&#xA;if has('python')&#xA;  command! -nargs=* Py python &amp;lt;args&amp;gt;&#xA;  call PyImports()&#xA;elseif has('python3')&#xA;  command! -nargs=* Py python3 &amp;lt;args&amp;gt;&#xA;  call PyImports()&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2303" LastActivityDate="2017-01-11T16:17:17.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10927" PostTypeId="1" AcceptedAnswerId="10928" CreationDate="2017-01-11T19:13:50.710" Score="1" ViewCount="1125" Body="&lt;p&gt;I've been fiddling with neovim color schemes for a while now, and cannot make them look same as on previews.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using terminal.app on osx, and thought it was 256 color cap problem, so I moved to iterm2 which has true color support - while it improved some things, color schemes are nowhere near to screenshots I see!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NfrT1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NfrT1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is how solarized theme looks in iterm2 + neovim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iUaef.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iUaef.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is nothing close to &lt;a href=&quot;https://github.com/altercation/vim-colors-solarized&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/altercation/vim-colors-solarized&lt;/a&gt; screenshots!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used google foo but without success, surely there is a way to get colors right. Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &quot;*****************************************************************************&#xA;&quot;&quot; Plug install packages&#xA;&quot;*****************************************************************************&#xA;&#xA;&quot; Specify a directory for plugins&#xA;call plug#begin('~/.config/nvim/plugged')&#xA;&#xA;Plug 'tomasr/molokai'&#xA;Plug 'dracula/vim'&#xA;Plug 'justb3a/vim-smarties'&#xA;Plug 'tyrannicaltoucan/vim-quantum' &quot; let g:quantum_black = 1&#xA;Plug 'mhartington/oceanic-next'&#xA;Plug 'altercation/vim-colors-solarized'&#xA;&quot; Plug 'vim-scripts/CSApprox'&#xA;Plug 'ctrlpvim/ctrlp.vim'&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'airblade/vim-gitgutter'&#xA;Plug 'bronson/vim-trailing-whitespace'&#xA;Plug 'editorconfig/editorconfig-vim'&#xA;Plug 'Raimondi/delimitMate'&#xA;Plug 'scrooloose/syntastic'&#xA;Plug 'Yggdroot/indentLine'&#xA;Plug 'tpope/vim-commentary'&#xA;Plug 'sheerun/vim-polyglot'&#xA;Plug 'valloric/matchtagalways'&#xA;&#xA;&quot; Initialize plugin system&#xA;call plug#end()&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Visual Settings&#xA;&quot;*****************************************************************************&#xA;set number&#xA;set ruler&#xA;set nowrap&#xA;&#xA;let $NVIM_TUI_ENABLE_TRUE_COLOR=1 &#xA;set termguicolors &quot; unfortunately doesn't work in terminal.app - needs true color support, like iterm2 but it lags and diff in visuals is not that much so sticking to terminal.app for now&#xA;&#xA;set background=dark&#xA;colorscheme solarized&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; NERDTree config&#xA;&quot;*****************************************************************************&#xA;&#xA;&quot; open NERDTree automatically when vim starts up on opening a directory&#xA;autocmd StdinReadPre * let s:std_in=1&#xA;autocmd VimEnter * if argc() == 1 &amp;amp;&amp;amp; isdirectory(argv()[0]) &amp;amp;&amp;amp; !exists(&quot;s:std_in&quot;) | exe 'NERDTree' argv()[0] | wincmd p | ene | endif&#xA;&#xA;&quot; keep focus on NERDTree when opening a directory&#xA;autocmd VimEnter * wincmd p&#xA;&#xA;&quot; close vim if the only window left open is a NERDTree&#xA;autocmd bufenter * if (winnr(&quot;$&quot;) == 1 &amp;amp;&amp;amp; exists(&quot;b:NERDTree&quot;) &amp;amp;&amp;amp; b:NERDTree.isTabTree()) | q | endif&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Optimizations&#xA;&quot;*****************************************************************************&#xA;&#xA;set lazyredraw&#xA;&#xA;let g:python_host_skip_check = 1&#xA;let g:python3_host_skip_check = 1&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; syntastic&#xA;&quot;*****************************************************************************&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; yank and cut to osx clipboard&#xA;&quot;*****************************************************************************&#xA;&#xA;noremap YY &quot;+y&amp;lt;CR&amp;gt;&#xA;noremap XX &quot;+x&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; indent&#xA;&quot;*****************************************************************************&#xA;&#xA;&quot; tabs&#xA;set listchars=tab:˗\ ,eol:¬&#xA;set list&#xA;&#xA;&quot; spaces&#xA;let g:indentLine_enabled = 1&#xA;let g:indentLine_concealcursor = 0&#xA;let g:indentLine_char = '·'&#xA;let g:indentLine_faster = 1&#xA;&#xA;set tabstop=2&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; matchtagalways&#xA;&quot;*****************************************************************************&#xA;&#xA;let g:mta_filetypes = { 'html' : 1, 'xhtml' : 1, 'xml' : 1, 'jinja' : 1, 'php': 1 }&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; ctrlp&#xA;&quot;*****************************************************************************&#xA;&#xA;set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__&#xA;let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist)|(\.(swp|tox|ico|git|hg|svn))$'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user10804" LastEditorUserId="7267" LastEditDate="2017-04-21T15:32:25.080" LastActivityDate="2017-04-21T15:32:25.080" Title="cannot get color schemes to display correctly in neovim" Tags="|neovim|plugin-solarized|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10928" PostTypeId="2" ParentId="10927" CreationDate="2017-01-11T19:51:07.500" Score="0" Body="&lt;p&gt;The only solution I've found is to set iTerm2's colorscheme to &lt;code&gt;Solarized Dark&lt;/code&gt;. This only really helps if you want solarized &lt;em&gt;everywhere&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open iTerm2&lt;/li&gt;&#xA;&lt;li&gt;Go to Settings(&gt;iTerm2&gt;Preferences or Cmd-,)&lt;/li&gt;&#xA;&lt;li&gt;Go to Profiles tab&lt;/li&gt;&#xA;&lt;li&gt;Go to Colors sub-tab&lt;/li&gt;&#xA;&lt;li&gt;Click &lt;code&gt;Color presets...&lt;/code&gt; in the bottom right and choose &lt;code&gt;Solarized Dark&lt;/code&gt;(or light)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2851" LastActivityDate="2017-01-11T19:51:07.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10929" PostTypeId="1" AcceptedAnswerId="10930" CreationDate="2017-01-11T21:31:25.073" Score="1" ViewCount="370" Body="&lt;p&gt;I've tried this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWinEnter * if &amp;amp;l:buftype != 'nofile' | map &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; &amp;lt;Plug&amp;gt;(easymotion-prefix) | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but somehow this isn't working (easymotion isn't working). While this works&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWinEnter * map &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; &amp;lt;Plug&amp;gt;(easymotion-prefix)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2017-01-12T09:03:01.810" Title="How to add buffer-local mapping only if not in command-line-window" Tags="|key-bindings|autocmd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10930" PostTypeId="2" ParentId="10929" CreationDate="2017-01-11T21:47:10.720" Score="3" Body="&lt;p&gt;I'm not sure, but I think that &lt;code&gt;| endif&lt;/code&gt; is in the &lt;code&gt;{rhs}&lt;/code&gt; of the mapping command &lt;code&gt;:map&lt;/code&gt;. To remove it, you could wrap the mapping in a chain and execute it, maybe like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWinEnter * if &amp;amp;l:buftype != 'nofile' | exe &quot;map &amp;lt;buffer&amp;gt; \&amp;lt;CR&amp;gt; \&amp;lt;Plug&amp;gt;(easymotion-prefix)&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2017-01-11T21:47:10.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10931" PostTypeId="1" CreationDate="2017-01-11T22:35:49.413" Score="1" ViewCount="678" Body="&lt;p&gt;I'd like to add the file to the buffer list without changing the currently active netrw window. I'd also love to make this the default behaviour for netrw. Any advice? I've searched around and looked through the netrw help but can't find a solution.&lt;/p&gt;&#xA;" OwnerUserId="10810" LastEditorUserId="1841" LastEditDate="2017-01-12T08:47:41.590" LastActivityDate="2017-01-13T16:31:13.830" Title="How can I open a file from netrw into a new buffer without making it active?" Tags="|buffers|vim-windows|netrw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10932" PostTypeId="2" ParentId="10929" CreationDate="2017-01-12T09:03:01.810" Score="1" Body="&lt;p&gt;Instead of toggling the global mapping, you could also define a (command-line window) buffer-local mapping for &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; that restores the original functionality:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd CmdwinEnter * noremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, you can leave the plugin mapping alone, and do not need to duplicate its definition.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2017-01-12T09:03:01.810" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10933" PostTypeId="1" CreationDate="2017-01-12T09:53:35.347" Score="3" ViewCount="1606" Body="&lt;p&gt;I can directly use the following approach to get the git branch information:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;let l:git = &quot;%6*%{exists('g:loaded_fugitive')?fugitive#statusline():''}%*&quot;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If so, it can cause a delay to the startup of vim, I guess tens to a hundred milliseconds. With the async feature in Vim8, can I get this asynchronously? I am not conversant with this feature, could someone give me some tips? A mini example would be better, thanks!&lt;/p&gt;&#xA;" OwnerUserId="10269" LastActivityDate="2017-01-13T05:05:11.947" Title="How to get git branch information supplied by vim-fugitive asynchronously for my statusline?" Tags="|vimrc|vimscript|statusline|async|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10934" PostTypeId="1" AcceptedAnswerId="10948" CreationDate="2017-01-12T10:18:54.100" Score="5" ViewCount="641" Body="&lt;p&gt;To use &lt;code&gt;NERDComToggleComment&lt;/code&gt;, I need to type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;c&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(in my case, Leader is &lt;kbd&gt;,&lt;/kbd&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to map this to a &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; (or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;any key&lt;/kbd&gt; if &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; is reserved/unavailable for any reason).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I write in &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I naively tried those two different approaches. None of which gave satisfaction.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Call existing mapping&#xA;vmap &amp;lt;silent&amp;gt;&amp;lt;C-c&amp;gt; : &amp;lt;Leader&amp;gt;c&amp;lt;Space&amp;gt;&#xA;&quot; Call function directly&#xA;vmap &amp;lt;silent&amp;gt;&amp;lt;C-c&amp;gt; :NERDComToggleComment&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10813" LastActivityDate="2017-11-16T08:33:29.780" Title="Map NERDComToggleComment to a keyboard shortcut" Tags="|vimrc|plugin-nerdcommenter|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10935" PostTypeId="1" AcceptedAnswerId="10938" CreationDate="2017-01-12T10:19:38.543" Score="1" ViewCount="416" Body="&lt;p&gt;I am trying to match a block of fortran, say,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo i()&#xA;...&#xA;End foo i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorMovedI *.f90  :call FixName(&quot;foo&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;FixName&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; FixName: Change Subprogram name {{{1&#xA;function! FixName(arg)&#xA;    let [buf, l, c, off] = getpos('.')&#xA;    call cursor([1, 1, 0])&#xA;&#xA;    let lnum = search('\v\c^\s*' . a:arg . '\s+', 'cnW')&#xA;    if !lnum&#xA;        call cursor(l, c, off)&#xA;        return&#xA;    endif&#xA;&#xA;    let parts = matchlist(getline(lnum), '\v\c^\s*' . a:arg . '\s+(\S*)\s*$')&#xA;    if len(parts) &amp;lt; 2&#xA;        call cursor(l, c, off)&#xA;        return&#xA;    endif&#xA;&#xA;    let lnum = search('\v\c^\s*End\s*' . a:arg . '\s+', 'cnW')&#xA;    call cursor(l, c, off)&#xA;    if !lnum&#xA;        return&#xA;    endif&#xA;&#xA;    call setline(lnum, substitute(getline(lnum), '\v\c^\s*End\s*' . a:arg . '\s+\zs.*', parts[1], ''))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is, with this FixName, I am getting anything after the foo. So, if I have, &lt;code&gt;foo bar(anything)&lt;/code&gt;, I am ending up with &lt;code&gt;End foo bar(anything)&lt;/code&gt;. But, I want only the bar (i.e. before the &quot;&lt;strong&gt;(&lt;/strong&gt;&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to change the last line as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; call setline(lnum, substitute(getline(lnum), '\v\c^\s*End\s*' . a:arg . '\s+\zs.*[?=\(]', parts[1], ''))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but obviously that's not the correct way.&#xA;How should I correct it?&lt;/p&gt;&#xA;" OwnerUserId="2738" LastActivityDate="2017-01-12T11:32:38.007" Title="vim script replace until match" Tags="|vimscript|regular-expression|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10936" PostTypeId="2" ParentId="10933" CreationDate="2017-01-12T11:00:02.137" Score="3" Body="&lt;p&gt;If you want to perform asynchronous tasks from Vim, people generally recommend using the &lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-dispatch&lt;/code&gt;&lt;/a&gt; plugin to run external processes in the background and call back later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But since I don't have an example for that, I'm going to offer some dirty synchronous tricks instead...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could consider only doing the work when the user has gone idle, by waiting for the &lt;code&gt;CursorHold&lt;/code&gt; event.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:git_status = &quot;...&quot;&#xA;&#xA;let &amp;amp;statusline = &quot;blah blah %{g:git_status} blah blah&quot;&#xA;&#xA;augroup Get_Git_Status&#xA;  autocmd!&#xA;  autocmd CursorHold * let g:git_status = fugitive#statusline()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add an identical &lt;code&gt;CursorHoldI&lt;/code&gt; line, if you also want the updates to happen when you are idle in Insert mode.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, but slightly longer, I call a function to &lt;a href=&quot;https://github.com/joeytwiddle/rc_files/blob/7502887c0e3a995a6971fcfe0b8cac6acaf6e50d/.vim/plugin/vimbuddy.vim#L46-L134&quot; rel=&quot;nofollow noreferrer&quot;&gt;cache the value&lt;/a&gt; and only update it once every 10 seconds.  You could adapt that to call &lt;code&gt;fugitive#statusline()&lt;/code&gt;.  And you could, by storing a timestamp at startup, only allow polling after Vim has been open for a few seconds.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I do not recall right now when and why &lt;code&gt;statusline&lt;/code&gt; gets evaluated, or how frequently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A combination of &lt;code&gt;CursorHold&lt;/code&gt; &lt;em&gt;and&lt;/em&gt; caching would probably have the least noticeable impact on Vim's performance.  Although just fetching the git branch is not that heavy a task anyway, especially after the first time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For heavier work, for example checking the status of the entire working tree, I really would recommend a separate &quot;dispatched&quot; process.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2017-01-13T05:05:11.947" LastActivityDate="2017-01-13T05:05:11.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10937" PostTypeId="1" CreationDate="2017-01-12T11:04:32.210" Score="9" ViewCount="967" Body="&lt;p&gt;I'm programming mostly in Python/Cython and use &lt;code&gt;foldmethod=syntax&lt;/code&gt; (and &lt;code&gt;foldclose=&lt;/code&gt;). Overall, this works fairly well, i.e. functions/classes/methods are folded reliably  mostly. However, I have one problem: folds are often opend/closed while I'm typing. Specifically,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;While working on an indented block (usually a long multiline argument list or a long list/dict/... initialization spanning multiple lines), that very &lt;strong&gt;block I'm in is folded&lt;/strong&gt; when I hit return;&lt;/li&gt;&#xA;&lt;li&gt;When starting a string at the end of a block, the &lt;strong&gt;block below is unfolded&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is all very annoying and distracting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to completely disable any auto-folding while I type?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Functionalities I want to retain:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Fold/unfold blocks I'm in&lt;/strong&gt; with a command/keystroke (I'm usually using &lt;code&gt;z-a&lt;/code&gt; for both).&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Fold the whole document&lt;/strong&gt; with a single keystroke/command.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Open new buffers fully folded&lt;/strong&gt; (though it's not a deal-breaker if I have to do this manually).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2100" LastEditorUserId="21062" LastEditDate="2019-08-09T15:36:34.433" LastActivityDate="2020-01-07T22:12:19.637" Title="How to disable folding while typing?" Tags="|insert-mode|folding|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10938" PostTypeId="2" ParentId="10935" CreationDate="2017-01-12T11:32:38.007" Score="2" Body="&lt;p&gt;Instead of &lt;code&gt;'\s+(\S*)\s*$'&lt;/code&gt; in matching for &lt;code&gt;parts&lt;/code&gt;, you could use &lt;code&gt;'\s+(\S*)\(.*\)\s*$'&lt;/code&gt;. &lt;code&gt;()&lt;/code&gt; in a magic regex (&lt;code&gt;\v&lt;/code&gt;) is, of course, used for grouping, so to match for literal parentheses, you need to use &lt;code&gt;\(\)&lt;/code&gt;. &lt;code&gt;'\s+(\S*)\(.*\)\s*$'&lt;/code&gt; thus matches whitespace, followed by non-whitespace, then a pair of parentheses containing anything. So, the grouped part only matches the text before the opening parenthesis.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-01-12T11:32:38.007" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10939" PostTypeId="1" AcceptedAnswerId="10945" CreationDate="2017-01-12T11:58:43.883" Score="23" ViewCount="28262" Body="&lt;p&gt;How can I determine if a filetype plugin (such as &lt;code&gt;vim-latexsuite&lt;/code&gt;) has been installed and activated when I open the appropriate file? Another popular editor would indicate that the relevant &quot;minor mode&quot; is active. What's the vim equivalent?&lt;/p&gt;&#xA;" OwnerUserId="2932" LastActivityDate="2019-12-20T17:42:38.713" Title="How to see if a plugin is active" Tags="|plugin-system|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10942" PostTypeId="2" ParentId="6148" CreationDate="2017-01-12T12:49:58.270" Score="2" Body="&lt;p&gt;I think this is an issue with Vim itself. When exploring the popup menu with Ctrl-N or Ctrl-P, Vim replaces your text with the highlighted item, which implies switching back-and-forth between the menu and the window behind it. You can bypass the issue by using the up and down arrows instead of Ctrl-P and Ctr-N, because in that case Vim does not perform text replacement (but then you'll need to press Enter to accept the highlighted item). Personally, I dislike the arrow keys so I use remappings to avoid them; for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; n pumvisible() ? &quot;\&amp;lt;Down&amp;gt;&quot; : &quot;n&quot;&#xA;inoremap &amp;lt;expr&amp;gt; p pumvisible() ? &quot;\&amp;lt;Up&amp;gt;&quot; : &quot;p&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10817" LastActivityDate="2017-01-12T12:49:58.270" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10943" PostTypeId="1" CreationDate="2017-01-12T12:54:55.503" Score="1" ViewCount="161" Body="&lt;p&gt;Ctrlp provides a way to ignore some files or folders:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ctrlp configuraation&#xA;let g:ctrlp_custom_ignore = {&#xA;   \ 'dir': '\v[\/](\.git|\.sql|\.hg|\.svn|vendor|var|sass|bin|app|web)$',&#xA;   \ 'file': '\v\.(exe|so|dll)$',&#xA;   \ 'doc': '\v\.(md|rst)$',&#xA;   \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, there is a &lt;code&gt;vendor&lt;/code&gt; folder in my ignore list. I usually keep it out from ctrlp because makes it really slow down the plugin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nonetheless, I need to add just two or three folders contained in the &lt;code&gt;vendor&lt;/code&gt; one. Can I configure ctrlp to exclude all folders inside vendor, but accept (for example) &lt;code&gt;Symfony&lt;/code&gt; and &lt;code&gt;Doctrine&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2965" LastEditorUserId="1841" LastEditDate="2017-01-12T16:48:21.300" LastActivityDate="2017-01-12T16:48:21.300" Title="Can ctrlp work in white list mode?" Tags="|plugin-ctrlp|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10944" PostTypeId="2" ParentId="10939" CreationDate="2017-01-12T13:20:36.990" Score="7" Body="&lt;p&gt;Vim plugins don't come with any activation indication, and in a proper setup, this isn't necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can quickly check whether a plugin is active by querying for its side effects, typically mappings. So, for example, I know that NERDCommenter mappings start with &lt;code&gt;&amp;lt;Leader&amp;gt;c&lt;/code&gt;, so a query for its activation would be &lt;code&gt;:nmap &amp;lt;Leader&amp;gt;c&lt;/code&gt;. If the mappings are listed, the plugin is active. The same can be achieved for custom commands and &lt;code&gt;:autocmd&lt;/code&gt; in the plugin's group. Most plugins also define an inclusion guard variable &lt;code&gt;g:loaded_pluginname&lt;/code&gt; that can be checked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same applies to filetype plugins (and the effects should then all be buffer-scoped). The most important factor in determining the active plugins is the correct detection of the filetype. You can query that via &lt;code&gt;:setlocal filetype?&lt;/code&gt;, or even put this into your &lt;code&gt;'statusline'&lt;/code&gt; via the &lt;code&gt;%y&lt;/code&gt; / &lt;code&gt;%Y&lt;/code&gt; item.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2017-01-12T13:20:36.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10945" PostTypeId="2" ParentId="10939" CreationDate="2017-01-12T13:26:54.237" Score="24" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I determine if a filetype plugin (such as vim-latexsuite) has been installed&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could use &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%3ascriptnames&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:scriptnames&lt;/code&gt;&lt;/a&gt; which list all sourced files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to check for the variable indicating if the plugin was loaded, as it is &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#use%2dcpo%2dsave&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;recommended practice to allow the user to disable the loading of a given plugin.&lt;/code&gt;&lt;/a&gt;. You usually can find &lt;code&gt;g:loaded_...&lt;/code&gt; variable inside the &lt;code&gt;&amp;lt;plugin_name&amp;gt;/plugin&lt;/code&gt; folder. For the &lt;a href=&quot;https://github.com/wchargin/vim-latexsuite/blob/master/plugin/libList.vim#L65&quot; rel=&quot;noreferrer&quot;&gt;plugin you mentioned&lt;/a&gt; you could use &lt;code&gt;echo exists(&quot;loaded_libList&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and activated when I open the appropriate file?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If it is a filetype plugin it should be activated automatically when the &lt;code&gt;'filetype'&lt;/code&gt; option is set. You can check if the option is correct for the current buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set filetype?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Another popular editor would indicate that the relevant &quot;minor mode&quot; is active. What's the vim equivalent?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could customize your statusline to show such indication, either using plugins or directly through options, as explained in &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27statusline%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'statusline'&lt;/code&gt;&lt;/a&gt; and at &lt;a href=&quot;https://www.vi-improved.org/recommendations/&quot; rel=&quot;noreferrer&quot;&gt;vi-improved.org&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2017-01-12T13:26:54.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10946" PostTypeId="2" ParentId="10939" CreationDate="2017-01-12T13:52:01.530" Score="3" Body="&lt;p&gt;If you activate filetype plugins by autocommands, you may set the verbose=9 so that Vim echo the autocommands as it executes them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set verbose=9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10816" LastEditorUserId="205" LastEditDate="2017-01-12T14:03:38.360" LastActivityDate="2017-01-12T14:03:38.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10947" PostTypeId="2" ParentId="10939" CreationDate="2017-01-12T13:54:11.953" Score="6" Body="&lt;p&gt;In that particular case, I'd only play with &lt;code&gt;:scriptnames&lt;/code&gt;. We can't expect to use a &lt;strong&gt;global&lt;/strong&gt; variable to check whether a &lt;strong&gt;ft&lt;/strong&gt;plugin has been loaded -- LaTeXSuite may have plugins, I don't remember, what is certain is that is has plenty ftplugin scripts. Many ftplugins use &lt;code&gt;b:did_ftplugin&lt;/code&gt; (the ones shipped with Vim at least), but this approach definitely does not scale: in consequence, not all ftplugins use this pointless variable, and we can't check for a generic variable name to know whether a given ftplugin has been loaded -- for instance, for C alone I have 22 ftplugins, they're definitively not using the same anti-reinclusion guard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;:scriptname&lt;/code&gt;. Alas &lt;code&gt;:scriptname&lt;/code&gt; gives a lot of unordered results, for our human eyes. Fortunately &lt;code&gt;execute()&lt;/code&gt; (a very recent function), and &lt;code&gt;filter()&lt;/code&gt; come to the rescue. In that case, I would look for latex related vim scripts with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo filter(split(execute(':scriptname'), &quot;\n&quot;), 'v:val =~? &quot;tex&quot;') &#xA;&quot; or even &quot;latex&quot; instead of &quot;tex&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also if you're using a plugin manager, it's likely that the plugin manager is using &lt;code&gt;'runtimepath'&lt;/code&gt; option. You can display its value with &lt;code&gt;:echo &amp;amp;rtp&lt;/code&gt;. You may even filter its value with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo filter(split(&amp;amp;rtp), ','), 'v:val =~? &quot;tex&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(This will tell you whether your plugin manager has activated your plugin, LaTeX-suite in your case. This won't tell you whether the related ftplugins have correctly been loaded. &lt;code&gt;:scriptname&lt;/code&gt; will give you this information.)&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-01-12T14:22:20.210" LastActivityDate="2017-01-12T14:22:20.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10948" PostTypeId="2" ParentId="10934" CreationDate="2017-01-12T13:54:51.453" Score="4" Body="&lt;p&gt;While &lt;code&gt;&amp;lt;C-C&amp;gt;&lt;/code&gt; might not be the best key combination, you can use the auxiliary mappings provided by the plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;silent&amp;gt;&amp;lt;C-C&amp;gt; &amp;lt;Plug&amp;gt;NERDCommenterToggle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also &lt;code&gt;:help NERDComMappings&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2017-01-12T13:54:51.453" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10951" PostTypeId="1" AcceptedAnswerId="10966" CreationDate="2017-01-12T18:41:30.223" Score="4" ViewCount="691" Body="&lt;p&gt;I use vim for editing everything. Occasionally while I have vim open someone else will want to write something for me. (My coworkers explaining code, friends helping me write something/leaving notes for me, etc.) As I'm sure you all know, vim isn't exactly, uhm &lt;em&gt;Intuitive&lt;/em&gt; to people who have never used it before. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As soon as they start typing, I watch the visible panic on their face as they realize my text editor is the text editing equivalent of &lt;a href=&quot;https://en.wikipedia.org/wiki/Sonic_screwdriver&quot;&gt;the sonic screwdriver&lt;/a&gt;. They have no idea what's happening, and it's flashing, my text is deleted and they've accidentally opened 2 help buffers and the command line history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I make vim act like every other boring text editor for a little while? I know about vim's &lt;em&gt;easy mode&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *-y* *easy*&#xA;-y      Easy mode.  Implied for |evim| and |eview|.  Starts with&#xA;        'insertmode' set and behaves like a click-and-type editor.&#xA;        This sources the script $VIMRUNTIME/evim.vim.  Mappings are&#xA;        set up to work like most click-and-type editors, see&#xA;        |evim-keys|.  The GUI is started when available.&#xA;        {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this doesn't help me because it's only a startup option. I'd love to have a way to keep all my old files open, press a key-combination, and have all vim-like bindings disappear until I press it a second time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any existing plugin for this? If not, what settings/features should I look into if I were to write my own?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-01-13T12:42:39.237" Title="Can I temporarily disable all vim-like keybinding?" Tags="|insert-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10952" PostTypeId="1" AcceptedAnswerId="10953" CreationDate="2017-01-12T18:57:34.403" Score="9" ViewCount="1267" Body="&lt;p&gt;When I open a new buffer I usually just do &lt;code&gt;:vsp something&lt;/code&gt; which allows me to open a new buffer with a vertical split. However, when I don't control how the buffer should be opened (e.g. when typing &lt;code&gt;:help&lt;/code&gt;) the new buffer is always opened with a horizontal split, which really annoys me. Is there anyway to change the default split direction?&lt;/p&gt;&#xA;" OwnerUserId="10823" LastActivityDate="2017-01-12T23:15:11.973" Title="Force buffers to always open with vertical split" Tags="|buffers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10953" PostTypeId="2" ParentId="10952" CreationDate="2017-01-12T20:40:02.150" Score="6" Body="&lt;p&gt;Vim provides &lt;code&gt;:vert&lt;/code&gt; to split vertically. &#xA;There isn't any option to change the default horizontal split but you can add &lt;code&gt;:vert&lt;/code&gt; before file to open it &#xA;like &lt;code&gt;:vert help&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vert[ical] {cmd}&#xA;    Execute {cmd}.  If it contains a command that splits a window,&#xA;    it will be split vertically.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9004" LastActivityDate="2017-01-12T20:40:02.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10954" PostTypeId="1" AcceptedAnswerId="10956" CreationDate="2017-01-12T20:49:20.513" Score="1" ViewCount="76" Body="&lt;h1&gt;Preface:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I first encountered this with a Node.js script I was trying to simulate a REPL with. I cooked up this demo to prove that is also happens with bash.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Please explain:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Why is it that on subsequent runs of step 9, you get more than just 5 comments?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Note:&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The lines that begin with &lt;code&gt;:&lt;/code&gt; like are intended to be copy-pasted&lt;/li&gt;&#xA;&lt;li&gt;You can download a copy of the code below via:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;curl -O https://gist.githubusercontent.com/RichardBronosky/6f936021ed77e77377729d9ed2d1a1f4/raw/vimception.sh&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Code&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env bash&#xA;&#xA;echo '##  1. Save this file as vimception.sh                                                                 '&#xA;echo '##       :w vimception.sh                                                                              '&#xA;echo '##  2. Make it executable                                                                              '&#xA;echo '##       :!chmod +x %                                                                                  '&#xA;echo '##  3. At the EOF ($), read (r) the result of executing (!) the path (./) to this file (%)             '&#xA;echo '##       :$r!./%                                                                                       '&#xA;echo '##  4. Run that a few times and watch the comments stack up (colon followed by up arrow is your friend)'&#xA;echo &quot;##  5. See the time $(date '+%Y/%m/%d-%H:%M.%S') and [Sub-]Process ID $(sh -c 'echo $PPID') of each run&quot;&#xA;      ##  (Okay, enough with echoing the comments!)&#xA;      ##  6. Now we'll make this script clean up after itself&#xA;      ## 7a. At the EOF ($), put (put) 2 # chars (='##') (This prevents errors by insuring at least 1 match for...)&#xA;      ## 7b. separate command (|) globally (g), where pattern (/^##/) matches, delete the line (d)&#xA;      ##       :$put ='##'|g/^##/d&#xA;      ##  8. Run that a few times to confirm it is idempotent&#xA;      ##  9. Combine steps 7 &amp;amp; 3 to get a fresh set of comments rather an seeing them stack up&#xA;      ##       :$put ='##'|g/^##/d|$r!./%&#xA;      ## 10. Run that one more time&#xA;      ## 11. Explain to me what happened&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10672" LastEditorUserId="10672" LastEditDate="2017-01-12T21:10:12.683" LastActivityDate="2017-01-12T21:42:25.130" Title="Vimception: Why does reading the output of executing the current file cause recursion?" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10956" PostTypeId="2" ParentId="10954" CreationDate="2017-01-12T21:09:41.400" Score="2" Body="&lt;p&gt;I'm not sure to understand, but maybe your issue comes from the global command which doesn't interpret the pipe character as command termination but as a part of its argument. So, when you execute this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$put ='##'|g/^##/d|$r!./%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe you think it does 3 things:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$put ='##'&#xA;g/^##/d&#xA;$r!./%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in fact, it does only 2 things:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$put='##'&#xA;g/^##/d|$r!./%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the last command, whenever the global command &lt;code&gt;:g&lt;/code&gt; finds a line which begins with 2 number sign characters (&lt;code&gt;#&lt;/code&gt;), it executes this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d|$r!./%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means, it deletes the line and it inserts the output of the shell commands (&lt;code&gt;echo&lt;/code&gt;) contained in your current script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want &lt;code&gt;:g&lt;/code&gt; to interpret the pipe as a part of its argument, you could hide it, wrapping the command in a string and executing it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$put ='##'|exe 'g/^##/d'|$r!./%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This time, &lt;code&gt;:g&lt;/code&gt; will only see what's inside the string (&lt;code&gt;d&lt;/code&gt;), it won't execute your shell script every time it finds a line beginning with &lt;code&gt;##&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I could be wrong, but I think most Ex commands interpret the pipe as command termination. However there are some exceptions, &lt;code&gt;:g&lt;/code&gt; is only one of them. I think the following ones also interpret the pipe as a part of their argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdo, :bufdo, :tabdo, :windo&#xA;:autocmd&#xA;:command&#xA;:function&#xA;:[v]global&#xA;:make&#xA;:normal&#xA;:!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't remember where I found this list, maybe in the help or in a blog post. There may be other commands which I missed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way of executing a new Ex command after one of these commands, is to type &lt;code&gt;C-v C-j&lt;/code&gt;, which should insert a newline or a null character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you have 2 choices:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:{1st command} C-v C-j {2nd command}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute '{1st command}' | {2nd command}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: I think I found the complete list of commands, it's in &lt;code&gt;:h :bar&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *:bar* *:\bar*&#xA;'|' can be used to separate commands, so you can give multiple commands in one&#xA;line.  If you want to use '|' in an argument, precede it with '\'.&#xA;&#xA;These commands see the '|' as their argument, and can therefore not be&#xA;followed by another Vim command:&#xA;    :argdo&#xA;    :autocmd&#xA;    :bufdo&#xA;    :cdo&#xA;    :cfdo&#xA;    :command&#xA;    :cscope&#xA;    :debug&#xA;    :folddoopen&#xA;    :folddoclosed&#xA;    :function&#xA;    :global&#xA;    :help&#xA;    :helpfind&#xA;    :lcscope&#xA;    :ldo&#xA;    :lfdo&#xA;    :make&#xA;    :normal&#xA;    :perl&#xA;    :perldo&#xA;    :promptfind&#xA;    :promptrepl&#xA;    :pyfile&#xA;    :python&#xA;    :registers&#xA;    :read !&#xA;    :scscope&#xA;    :sign&#xA;    :tcl&#xA;    :tcldo&#xA;    :tclfile&#xA;    :vglobal&#xA;    :windo&#xA;    :write !&#xA;    :[range]!&#xA;    a user defined command without the &quot;-bar&quot; argument |:command|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-01-12T21:42:25.130" LastActivityDate="2017-01-12T21:42:25.130" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10957" PostTypeId="2" ParentId="10952" CreationDate="2017-01-12T23:15:11.973" Score="6" Body="&lt;p&gt;@Ashok's answer is good but if you do this often you may want to use &lt;code&gt;cabbrev&lt;/code&gt; to do it for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add this to your &lt;code&gt;.vimrc&lt;/code&gt; to have vim automatically put in &lt;code&gt;:vert help&lt;/code&gt; whenever you type &lt;code&gt;:help&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cabbrev help vert help&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-01-12T23:15:11.973" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10958" PostTypeId="1" AcceptedAnswerId="10959" CreationDate="2017-01-12T23:55:33.187" Score="5" ViewCount="344" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/m9kyT.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/m9kyT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reason: &#xA;I've swapped my semi-colon and colon commands so that entering the command-line takes one less key-stroke:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ; :&#xA;nnoremap : ;&#xA;vnoremap ; :&#xA;vnoremap : ;&#xA;nnoremap q; q:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in the command-line prompt, the colon character still shows up. I would like this character to be a semi-colon instead so my brain doesn't have to deal with cognitive dissonance.&lt;/p&gt;&#xA;" OwnerUserId="7454" LastEditorUserId="7454" LastEditDate="2017-01-13T00:59:12.820" LastActivityDate="2017-01-13T03:39:57.080" Title="Change command-line prompt leading character?" Tags="|command-line|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10959" PostTypeId="2" ParentId="10958" CreationDate="2017-01-13T03:39:57.080" Score="5" Body="&lt;p&gt;There is no configuration option that does this; change the ':' into ';' you need to change the vim source code (which lives on github).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant line (as of the most recent commit on github) is found &lt;a href=&quot;https://github.com/vim/vim/blob/70bcd7336f9f19304f32c52a86ed5b4b3de852c2/src/ex_docmd.c#L1011&quot; rel=&quot;noreferrer&quot; title=&quot;here&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to change &lt;code&gt;fgetline(':', cookie,&lt;/code&gt; into &lt;code&gt;fgetline(';', cookie,&lt;/code&gt;.&#xA;(Other characters that do not clash with existing characters used for the command line such as &lt;code&gt;=&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;?&lt;/code&gt; should work as well, but I am not familiar enough with the source code to be sure.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;Personal interjection&lt;/em&gt;: In general, this procedure is fragile and expose your vim installation to bugs. I wouldn't recommend it.)&lt;/p&gt;&#xA;" OwnerUserId="5179" LastActivityDate="2017-01-13T03:39:57.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10960" PostTypeId="1" CreationDate="2017-01-13T07:05:47.793" Score="3" ViewCount="736" Body="&lt;p&gt;Does VIM have a way to show symbols as characters?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;lambda&lt;/code&gt; can be displayed as &lt;code&gt;λ&lt;/code&gt; (yet keep its underlying ascii text) for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like emacs &lt;a href=&quot;https://www.emacswiki.org/emacs/PrettySymbol&quot; rel=&quot;nofollow noreferrer&quot;&gt;pretty-symbols&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2017-01-13T13:50:14.717" Title="Displaying terms as single character unicode symbols in VIM?" Tags="|unicode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10961" PostTypeId="2" ParentId="10888" CreationDate="2017-01-13T08:03:33.430" Score="0" Body="&lt;p&gt;I call it &quot;isolate the line&quot; - and this mapping does it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;i O&amp;lt;c-o&amp;gt;j&amp;lt;c-o&amp;gt;o&amp;lt;c-o&amp;gt;k&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It leaves the cursor in the current line. Ctrl-o means &quot;switch to normal mode for one command&quot;&lt;/p&gt;&#xA;" OwnerUserId="6059" LastActivityDate="2017-01-13T08:03:33.430" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10962" PostTypeId="1" AcceptedAnswerId="10963" CreationDate="2017-01-13T08:16:17.310" Score="5" ViewCount="2038" Body="&lt;p&gt;Here is what my tab-bar in GVim looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xz9On.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xz9On.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm having a hard time to identify which of the tabs is the active one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure the color of the tab-bar, for example I'd like to use a different color for the highlighted one, or for the others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found similar questions on the StackExchange-network:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/65401/changing-color-of-tabs-titles-in-vim-color-files&quot;&gt;https://unix.stackexchange.com/questions/65401/changing-color-of-tabs-titles-in-vim-color-files&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the following code (from the question's answer)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi TabLineFill ctermfg=LightGreen ctermbg=DarkGreen&#xA;:hi TabLine ctermfg=Blue ctermbg=Yellow&#xA;:hi TabLineSel ctermfg=Red ctermbg=Yellow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;changes nothing for me.&lt;/p&gt;&#xA;" OwnerUserId="1542" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2022-07-23T02:45:24.083" Title="How to change color of tabs in the tab-bar in gvim?" Tags="|gvim|colorscheme|tabbed-user-interface|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10963" PostTypeId="2" ParentId="10962" CreationDate="2017-01-13T08:59:43.467" Score="3" Body="&lt;p&gt;The colors of the tabs follow the general color scheme configured on your system. The tabs should look similar to tabs in other programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try changing the GTK theme on your system, for example using the &lt;code&gt;gnome-tweak-tool&lt;/code&gt;. Or on Ubuntu, using &lt;code&gt;ubuntu-tweak&lt;/code&gt;. See also: &lt;a href=&quot;https://askubuntu.com/q/361422/255332&quot;&gt;How can you change the GTK Theme and Window Decorations separately in Unity?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10830" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.647" LastActivityDate="2017-01-13T12:25:33.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10964" PostTypeId="2" ParentId="10960" CreationDate="2017-01-13T09:35:00.113" Score="3" Body="&lt;p&gt;You can do this with Vim syntax's &lt;code&gt;conceal&lt;/code&gt; feature, which allows you to hide matched text or replace it with a single character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match keyword &quot;\&amp;lt;lambda\&amp;gt;&quot; conceal cchar=λ&#xA;:set conceallevel=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more details, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help conceal&#xA;:help conceallevel&#xA;:help concealcursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-01-13T13:50:14.717" LastActivityDate="2017-01-13T13:50:14.717" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10965" PostTypeId="1" AcceptedAnswerId="11067" CreationDate="2017-01-13T12:18:05.903" Score="6" ViewCount="1288" Body="&lt;p&gt;I often use &lt;code&gt;da{dd&lt;/code&gt; to delete a whole block of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/50mIN.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/50mIN.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if a block of code is within paragraph, &lt;code&gt;dap&lt;/code&gt; works really nicely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried some function text objects plugins for Javascript but didn't have much success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way of making this work like a text object?&lt;/p&gt;&#xA;" OwnerUserId="10836" LastEditorUserId="25" LastEditDate="2021-11-16T23:47:48.840" LastActivityDate="2021-11-17T12:03:06.203" Title="is there a better way of deleting a block of code?" Tags="|cut-copy-paste|normal-mode|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10966" PostTypeId="2" ParentId="10951" CreationDate="2017-01-13T12:42:39.237" Score="3" Body="&lt;p&gt;If if has to be the same editor, I would go with &lt;code&gt;:set insertmode&lt;/code&gt;. This basically switches to the mentioned &lt;em&gt;easy mode&lt;/em&gt;, even &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; won't do harm. Leave again with &lt;code&gt;&amp;lt;C-O&amp;gt;:set noinsertmode&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would instead allow your colleague to open the text file in a different editor of his choosing. Just &lt;code&gt;:write&lt;/code&gt; any unpersisted changes, and open it elsewhere in parallel. Settings like &lt;code&gt;:set autoread&lt;/code&gt; make this even more comfortable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally often edit / browse the same files in GVIM and an IDE (IntelliJ IDEA). You could even facilitate this with a custom &lt;code&gt;:OpenWith&lt;/code&gt; command within Vim. In a graphical environment, it's easy to open another editor; it's only clumsy if you only have a single SSH terminal connection; you'd block your Vim unless you open another connection or use a terminal multiplexer like &lt;code&gt;screen&lt;/code&gt; or &lt;code&gt;tmux&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2017-01-13T12:42:39.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10967" PostTypeId="2" ParentId="10965" CreationDate="2017-01-13T12:48:36.153" Score="8" Body="&lt;p&gt;You can turn the &lt;em&gt;characterwise&lt;/em&gt; &lt;code&gt;a{&lt;/code&gt; text object into a &lt;em&gt;linewise&lt;/em&gt; by prepending a &lt;code&gt;V&lt;/code&gt;, as in &lt;code&gt;dVa{&lt;/code&gt;. This way, the stuff with the block is removed as well, and you don't need to issue another &lt;code&gt;dd&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can easily turn this into your own custom text object, e.g.: &lt;code&gt;ab&lt;/code&gt;, and then use this as &lt;code&gt;dab&lt;/code&gt;, &lt;code&gt;cab&lt;/code&gt;, and so on:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;onoremap ab Va{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="22375" LastEditDate="2021-11-17T12:03:06.203" LastActivityDate="2021-11-17T12:03:06.203" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="10968" PostTypeId="1" CreationDate="2017-01-13T12:48:42.550" Score="4" ViewCount="161" Body="&lt;p&gt;Looking at the documentation I found this piece:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a}                          *v_a}* *a}* *a{*&#xA;a{                          *v_aB* *v_a{* *aB*&#xA;aB          &quot;a Block&quot;, select [count] Blocks, from &quot;[count] [{&quot; to&#xA;            the matching '}', including the '{' and '}' (see&#xA;            |[{|).&#xA;            When used in Visual mode it is made characterwise.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The part interesting here is &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When used in Visual mode it is made characterwise.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's the behavior for all the &lt;code&gt;i&lt;/code&gt;/&lt;code&gt;a&lt;/code&gt; text objects (except for &lt;code&gt;p&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know why is the visual selection changed ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why can't you select a block linewise? (e.g. &lt;code&gt;Va{&lt;/code&gt; will jump back to characterwise).&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2017-01-14T07:09:37.393" Title="Why is block selection characterwise?" Tags="|cursor-motions|visual-mode|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10969" PostTypeId="1" AcceptedAnswerId="10971" CreationDate="2017-01-13T13:58:26.723" Score="1" ViewCount="2780" Body="&lt;p&gt;I've added this script to my vimrc file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! EnableMouse :call EnableMouseFunction()&#xA;function! EnableMouseFunction()&#xA;    let command = &quot;:set mouse=a&quot;&#xA;    exe command&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, ... what is the method to unset mouse in vim?&lt;/p&gt;&#xA;" OwnerUserId="2965" LastActivityDate="2017-01-13T14:09:19.933" Title="disable previously enabled mouse with Vim script" Tags="|mouse|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10970" PostTypeId="2" ParentId="10969" CreationDate="2017-01-13T14:06:55.377" Score="1" Body="&lt;p&gt;The use of the mouse is controlled (as you find out) with the &lt;code&gt;mouse&lt;/code&gt; setting. It is activated only if &lt;code&gt;mouse&lt;/code&gt; is equal to &quot;something&quot;. This something determines when is the mouse used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To disable the mouse you can simply:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also in your function, you can call the &lt;code&gt;set&lt;/code&gt; command directly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EnableMouseFunction()&#xA;    set mouse=a&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2017-01-13T14:06:55.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10971" PostTypeId="2" ParentId="10969" CreationDate="2017-01-13T14:09:19.933" Score="6" Body="&lt;p&gt;You don't need anything that complex&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=a&#xA;&quot; and&#xA;set mouse=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;are enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can even define your command to be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! ToggleMouse exe 'set mouse='.(empty(&amp;amp;mouse)?'a':'')&#xA;&quot; Here I use `:exe` because I didn't want to use `:if` in a command definition which would look like:&#xA;:command! ToggleMouse if empty(&amp;amp;mouse) | set mouse=a | else | set mouse= | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-01-13T14:09:19.933" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10973" PostTypeId="2" ParentId="10931" CreationDate="2017-01-13T16:31:13.830" Score="2" Body="&lt;p&gt;The &lt;em&gt;netrw plugin&lt;/em&gt; provides functionality to set up user-specific mappings, cp. &lt;code&gt;:help netrw-usermaps&lt;/code&gt;. Unfortunately, when I tried this, I found the mentioned &lt;code&gt;netrw#Call()&lt;/code&gt; function defective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've sent the following patch to its author:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- autoload/netrw.vim.orig 2016-11-18 14:28:34.647159594 +0100&#xA;+++ autoload/netrw.vim  2017-01-12 10:42:07.097512428 +0100&#xA;@@ -11013,11 +11015,7 @@ fun! netrw#Access(ilist)&#xA;&quot; netrw#Call: allows user-specified mappings to call internal netrw functions {{{2&#xA;fun! netrw#Call(funcname,...)&#xA;&quot;  call Dfunc(&quot;netrw#Call(funcname&amp;lt;&quot;.a:funcname.&quot;&amp;gt;,&quot;.string(a:000).&quot;)&quot;)&#xA;-  if a:0 &amp;gt; 0&#xA;-   exe &quot;call s:&quot;.a:funcname.&quot;(&quot;.string(a:000).&quot;)&quot;&#xA;-  else&#xA;-   exe &quot;call s:&quot;.a:funcname.&quot;()&quot;&#xA;-  endif&#xA;+  return call(&quot;s:&quot;.a:funcname, a:000)&#xA;&quot;  call Dret(&quot;netrw#Call&quot;)&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With that fix, I was able to implement a &lt;code&gt;+&lt;/code&gt; user mapping to do what you've asked for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; +                     Add the current file to the buffer list, and go to the&#xA;&quot;                       next file entry.&#xA;function! NetrwBufAdd( isLocal )&#xA;    let l:filespec = netrw#Call('NetrwFile', netrw#Call('NetrwGetWord'))&#xA;    if filereadable(l:filespec)&#xA;        execute 'badd' ingo#compat#fnameescape(l:filespec)&#xA;    endif&#xA;    execute 'normal!' (b:netrw_liststyle == netrw#Expose('WIDELIST') ? 'W' : 'j')&#xA;    return ''&#xA;endfunction&#xA;let g:Netrw_UserMaps = [&#xA;\   ['+', 'NetrwBufAdd']&#xA;\]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Overriding the default behavior should be a simple addition of &lt;code&gt;['&amp;lt;CR&amp;gt;', 'NetrwBufAdd']&lt;/code&gt; to the above list.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2017-01-13T16:31:13.830" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10974" PostTypeId="1" CreationDate="2017-01-13T16:40:37.227" Score="2" ViewCount="335" Body="&lt;p&gt;I wanted to install YouCompleteMe plugin for vim - however failed miserably at every step of the way. The problem was I had to compile everything by hand (remote machine - no root): started with vim v8.0, then it turned out I needed to add python to this mix (3.5.3) and finally I could download Ycm. I had some troubles in the begining but when python started to click with vim I thought I'm almost there. Unfortunately I'm stuck at a error message I can't decipher or get to the bottom of: when I run vim i get the message &quot;YouCompleteMe unavailable: PROTOCOL_TLS&quot; - anyone knows what this could mean or where the problem lies?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All help would be greatly appreciated,&#xA;drinker&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I checked vims' logs and the failure seem to come from this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;File &quot;~/py-353/lib/python3.5/ssl.py&quot;, line 135, in &amp;lt;module&amp;gt;&#xA;  PROTOCOL_SSLv23 = _SSLMethod.PROTOCOL_SSLv23 = _SSLMethod.PROTOCOL_TLS_CLIENT&#xA;File &quot;~/py-353/lib/python3.5/enum.py&quot;, line 274, in __getattr__&#xA;  raise AttributeError(name) from None&#xA;AttributeError: PROTOCOL_TLS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Still - no idea what that means...&lt;/p&gt;&#xA;" OwnerUserId="10837" LastEditorUserId="10837" LastEditDate="2017-01-13T19:04:59.023" LastActivityDate="2017-09-13T18:24:46.620" Title="Vim and YouCompleteMe troubles (PROTOCOL_TLS)" Tags="|plugin-you-complete-me|plugin-python-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10975" PostTypeId="2" ParentId="10753" CreationDate="2017-01-13T19:34:30.743" Score="4" Body="&lt;p&gt;Its generally best to try the latest netrw when one has a problem, because that problem may have already been addressed.  You can get the latest netrw (v162i) from &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#NETRW&lt;/a&gt; .  I think this problem, in particular, has been addressed already, although I don't have a windows box handy to try it out at the moment.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2017-01-13T19:34:30.743" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10976" PostTypeId="1" AcceptedAnswerId="11019" CreationDate="2017-01-13T22:12:08.677" Score="2" ViewCount="1062" Body="&lt;p&gt;I'm at a loss at how to get rid of this jarring purple background surrounding any text that isn't visible when vim initially loads the file and displays the text.  It appears when I scroll past the initially displayed text, but not when I jump to an entirely different area or resize the window.  This happens for all file types I've tried so far.&lt;a href=&quot;https://i.stack.imgur.com/80YuT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/80YuT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've even replaced my &lt;code&gt;.vimrc&lt;/code&gt; file with this extremely minimal version, and the issue still occurs (I used this &lt;code&gt;.vimrc&lt;/code&gt; file for the above screenshot)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;highlight Normal ctermfg=grey ctermbg=darkblue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4940" LastEditorUserId="4940" LastEditDate="2017-01-15T23:47:37.517" LastActivityDate="2017-01-17T07:52:57.867" Title="Vim with non-default background on Ubuntu shows purple color for non-text space after scrolling the screen" Tags="|vimrc|colorscheme|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10979" PostTypeId="1" CreationDate="2017-01-14T02:58:17.097" Score="1" ViewCount="381" Body="&lt;p&gt;I met a weird problem: Vim is still in insert mode after executing the code below, it's weird because the redraw command did work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:startinsert&#xA;execute 'silent !ls'&#xA;execute 'normal &quot;\&amp;lt;esc&amp;gt;&quot;'&#xA;:redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10798" LastEditorUserId="1821" LastEditDate="2017-01-14T11:09:18.953" LastActivityDate="2017-02-13T16:58:33.297" Title="how to reenter normal mode after startinsert" Tags="|insert-mode|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10980" PostTypeId="2" ParentId="10979" CreationDate="2017-01-14T03:13:29.820" Score="1" Body="&lt;p&gt;You should use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call feedkeys(&quot;\&amp;lt;esc&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7942" LastEditorUserId="51" LastEditDate="2017-01-14T16:05:11.557" LastActivityDate="2017-01-14T16:05:11.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10981" PostTypeId="2" ParentId="10968" CreationDate="2017-01-14T07:09:37.393" Score="2" Body="&lt;p&gt;From my observation: Because there isn't a linewise version of &lt;code&gt;di{&lt;/code&gt;.  In the same vein, there isn't a characterwise version of &lt;code&gt;dip&lt;/code&gt;.  Not to mention that &lt;code&gt;Viw&lt;/code&gt; would seemingly do nothing if &lt;code&gt;iw&lt;/code&gt; didn't cause it to become characterwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I can tell, text objects are basically macros for selecting text.  When you use an operator command, the text is &quot;selected&quot; before being operated on.  In visual mode, the text objects simply become visible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems reasonable that using text objects in visual mode would replace the selection since they can't be used to extend the selection.  That is, if you selected a few characters then press &lt;code&gt;i{&lt;/code&gt;, the initial selection is lost since it would otherwise &lt;em&gt;not&lt;/em&gt; be &quot;text that's between two curly braces&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (1) {&#xA;   // &amp;lt;- start selection in here&#xA;}&#xA;&#xA;// &amp;lt;- end the selection here and press `i{`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-01-14T07:09:37.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10982" PostTypeId="1" CreationDate="2017-01-14T07:34:12.677" Score="0" ViewCount="183" Body="&lt;p&gt;Currently I have this binding to copy current file name, path, or dir.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Copy current buffer path relative to root of VIM session to system clipboard&#xA;nnoremap &amp;lt;Leader&amp;gt;yp :let @*=expand(&quot;%&quot;)&amp;lt;cr&amp;gt;:echo &quot;Copied file path to clipboard&quot;&amp;lt;cr&amp;gt;&#xA;&quot; Copy current filename to system clipboard&#xA;nnoremap &amp;lt;Leader&amp;gt;yf :let @*=expand(&quot;%:t&quot;)&amp;lt;cr&amp;gt;:echo &quot;Copied file name to clipboard&quot;&amp;lt;cr&amp;gt;&#xA;&quot; Copy current buffer path without filename to system clipboard&#xA;nnoremap &amp;lt;Leader&amp;gt;yd :let @*=expand(&quot;%:h&quot;)&amp;lt;cr&amp;gt;:echo &quot;Copied file directory to clipboard&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to create binding to copy current php file class name with or without namespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I have php file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;&#xA;namespace CRMFoundation\Infrastructures\Contracts;&#xA;&#xA;interface PersistenceStorageRepositoryInterface&#xA;{ &#xA;  ....&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would should give me &lt;code&gt;PersistenceStorageRepositoryInterface&lt;/code&gt; as classname and &lt;code&gt;CRMFoundation\Infrastructures\Contracts\PersistenceStorageRepositoryInterface&lt;/code&gt; with namespace.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;&#xA;namespace CRMFoundation\Infrastructures;&#xA;&#xA;use Illuminate\Database\Eloquent\Model;&#xA;use Illuminate\Database\Eloquent\SoftDeletes;&#xA;use CRMFoundation\Infrastructures\Traits\SyncHasManyTrait;&#xA;&#xA;abstract class EloquentAbstract extends Model&#xA;{&#xA;  .....&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would should give me &lt;code&gt;EloquentAbstract&lt;/code&gt; as classname and &lt;code&gt;CRMFoundation\Infrastructures\EloquentAbstract&lt;/code&gt; with namespace.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;&#xA;namespace CRMFoundation\Domains\Company;&#xA;&#xA;use CRMFoundation\Domains\Company\Contracts\CompanyRepositoryInterface;&#xA;use CRMFoundation\Infrastructures\Company\Contracts\PersistenceCompanyRepositoryInterface;&#xA;use CRMFoundation\Domains\Company\Contracts\CompanyInterface;&#xA;use CRMFoundation\Domains\RepositoryAbstract;&#xA;&#xA;class CompanyRepository extends RepositoryAbstract implements CompanyRepositoryInterface&#xA;{&#xA;  ....&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would should give me &lt;code&gt;CompanyRepository&lt;/code&gt; as classname and &lt;code&gt;CRMFoundation\Domains\Company\CompanyRepository&lt;/code&gt; with namespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let say I want to bind it to &lt;code&gt;&amp;lt;leader&amp;gt;yc&lt;/code&gt; to get current class name and &lt;code&gt;&amp;lt;leader&amp;gt;ycn&lt;/code&gt; to get current class name with namespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to do that?&lt;/p&gt;&#xA;" OwnerUserId="10848" LastActivityDate="2017-01-14T11:07:59.753" Title="Copy current php file classname with namespace?" Tags="|vimscript|filetype-php|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10983" PostTypeId="1" CreationDate="2017-01-14T10:22:23.723" Score="2" ViewCount="3630" Body="&lt;p&gt;I have a problem with my deoplete plugin.&#xA;When I write code, I don't have automatic completion on dot. I need to manually press &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; to make it work.&lt;/p&gt;&#xA;&lt;p&gt;Here is my deoplete configuration:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:deoplete#enable_at_startup = 1&#xA;let g:deoplete#delimiters = ['/','.']&#xA;let g:deoplete#sources#go = 'vim-go'&#xA;let g:deoplete#keyword_patterns = {}&#xA;let g:deoplete#keyword_patterns._ = '[a-zA-Z_]\k*\(?'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here an exemple on &amp;quot;automatic&amp;quot; completion:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/5Yfma.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5Yfma.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then, when I press &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; :&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SIdkK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SIdkK.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I really don't know how to get the second case.&lt;/p&gt;&#xA;&lt;p&gt;p.s: I read so many tutorials on the web and I have already searching on the stackexchange without finding.&lt;/p&gt;&#xA;" OwnerUserId="10849" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-12-09T07:02:20.540" Title="Deoplete with Neovim doesn't work" Tags="|autocompletion|neovim|plugin-deoplete|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10984" PostTypeId="2" ParentId="10982" CreationDate="2017-01-14T11:07:59.753" Score="2" Body="&lt;p&gt;Here's a start, it's definitely not perfect but should gives you enough to increment on&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetNamespaceAndClassFn()&#xA;  &quot; Save some registers&#xA;  let l:r_a = @a&#xA;  let l:r_b = @b&#xA;&#xA;  &quot; Start at the top of the file&#xA;  :0&#xA;  &quot; Search for the first &quot;namespace&quot; occurence&#xA;  /namespace&#xA;  &quot; Get the namespace string into the regsiter a&#xA;  normal! f l&quot;ayt;&#xA;&#xA;  &quot; Search for the class definition&#xA;  /class&#xA;  &quot; Get the class string into the regsiter b&#xA;  normal! f l&quot;bye&#xA;&#xA;  &quot; Print the result&#xA;  echo @a . '\' . @b&#xA;&#xA;  &quot; Restore registers&#xA;  let @a = l:r_a&#xA;  let @b = l:r_b&#xA;endfunction&#xA;&#xA;command! GetNamespaceAndClass call GetNamespaceAndClassFn()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've commented the code, but feel free to ask if you want more info.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2017-01-14T11:07:59.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10985" PostTypeId="1" AcceptedAnswerId="10990" CreationDate="2017-01-14T12:30:46.313" Score="2" ViewCount="2723" Body="&lt;pre&gt;&lt;code&gt;OSX - sierra&#xA;iterm2 3.0.13&#xA;tmux 2.3&#xA;vim 8.0.176&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;colors work fine in bare iterm2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/O586h.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/O586h.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but under tmux:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/076xs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/076xs.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;iterm2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo $TERM&#xA;xterm-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;tmux:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo $TERM&#xA;screen-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;tmux config&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TWwDq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TWwDq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/07vKD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/07vKD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running out of ideas. and google foo is not helping.&lt;/p&gt;&#xA;" OwnerDisplayName="user10804" LastActivityDate="2017-02-13T18:58:38.347" Title="vim under tmux looses color scheme in iterm2" Tags="|vimrc|colorscheme|tmux|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10986" PostTypeId="1" AcceptedAnswerId="10987" CreationDate="2017-01-14T15:02:11.593" Score="16" ViewCount="3223" Body="&lt;p&gt;We have a few modes in Vim. The most commonly used are: &lt;code&gt;Normal&lt;/code&gt; (=Command), &lt;code&gt;Insert&lt;/code&gt;, and &lt;code&gt;Command-line&lt;/code&gt;, but also some &lt;em&gt;sub-modes&lt;/em&gt;, like: &lt;code&gt;Replace&lt;/code&gt;, &lt;code&gt;Visual-line&lt;/code&gt; (&lt;kbd&gt;V&lt;/kbd&gt;) or &lt;code&gt;Visual-block&lt;/code&gt; (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Does Vim support the creation of some user-defined &lt;em&gt;submode&lt;/em&gt;? How to make a simple mode that inherits from the existing one?&lt;/p&gt;&#xA;&lt;p&gt;Let's consider &amp;quot;&lt;strong&gt;Insert-snake mode&lt;/strong&gt;&amp;quot; which inherits from Insert mode and has some specific rules. One of these rules should be to replace &lt;code&gt;space&lt;/code&gt; with &lt;code&gt;_&lt;/code&gt; character.&lt;/p&gt;&#xA;" OwnerUserId="8444" LastEditorUserId="36876" LastEditDate="2023-11-03T11:51:05.380" LastActivityDate="2023-11-03T11:51:05.380" Title="Can I create my own mode in Vim?" Tags="|insert-mode|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10987" PostTypeId="2" ParentId="10986" CreationDate="2017-01-14T15:59:03.540" Score="10" Body="&lt;p&gt;The best you can do is something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ToggleW00tMode()&#xA;    if !exists('b:w00t')&#xA;        let b:w00t=1&#xA;    else&#xA;        unlet b:w00t&#xA;    endif&#xA;&#xA;    return &quot;&quot;&#xA;endfun&#xA;&#xA;inoremap &amp;lt;C-w&amp;gt; &amp;lt;C-r&amp;gt;=ToggleW00tMode()&amp;lt;Cr&amp;gt;&#xA;&#xA;&quot; Do something different depending on the value of b:w00t&#xA;inoremap &amp;lt;expr&amp;gt; o exists('b:w00t') ? '0' : 'o'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will simple toggle the &lt;code&gt;b:w00t&lt;/code&gt; variable to go into w00tmode, and remaps &lt;code&gt;o&lt;/code&gt; to change the behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also add something to the statusline to indicate if w00tmode is enabled (but you &lt;a href=&quot;https://vi.stackexchange.com/q/6860/51&quot;&gt;can't change the INSERT text&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In my vimrc I &lt;a href=&quot;https://github.com/Carpetsmoker/dotfiles/blob/66e7c38/modules/vim/commands.vim#L87&quot; rel=&quot;noreferrer&quot;&gt;do something similar to make typing &quot;smart quotes&quot; a bit easier&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-01-14T15:59:03.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10988" PostTypeId="1" AcceptedAnswerId="11012" CreationDate="2017-01-14T16:03:10.127" Score="9" ViewCount="11066" Body="&lt;p&gt;neovim 0.2-dev&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:Lexplore&lt;/code&gt; opens up explorer window and entering &lt;code&gt;:Lexplore&lt;/code&gt; again toggles it. However, if I interact with the explorer window(i.e. expand a directory), then typing &lt;code&gt;:Lexplore&lt;/code&gt; opens up another explorer window instead of closing the existing one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uyakp.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uyakp.png&quot; alt=&quot;Lexplore opens up a new explorer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this the expected behavior? Is there any command/function that will toggle explorer even if the window had interaction?&lt;/p&gt;&#xA;" OwnerUserId="10853" LastEditorUserId="51" LastEditDate="2017-01-14T16:12:22.293" LastActivityDate="2023-12-19T20:29:27.090" Title="Toggle explorer window" Tags="|netrw|" AnswerCount="10" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10989" PostTypeId="2" ParentId="10985" CreationDate="2017-01-14T16:16:21.083" Score="0" Body="&lt;p&gt;A search for 'tmux vim colors wrong' turned up &lt;a href=&quot;https://askubuntu.com/questions/125526/vim-in-tmux-display-wrong-colors&quot;&gt;this answer&lt;/a&gt;.  Start tmux with the -2 option to force 256 colors. &lt;/p&gt;&#xA;" OwnerUserId="5353" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.647" LastActivityDate="2017-01-14T16:16:21.083" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10990" PostTypeId="2" ParentId="10985" CreationDate="2017-01-14T16:54:49.237" Score="0" Body="&lt;p&gt;&lt;code&gt;t_*&lt;/code&gt; is needed because these are not set automatically by vim for anything but &lt;code&gt;xterm&lt;/code&gt;. But tmux only supports &lt;code&gt;screen-256&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h xterm-true-color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Moving &lt;code&gt;t_8f&lt;/code&gt; and &lt;code&gt;t_8b&lt;/code&gt; below &lt;code&gt;set termguicolors&lt;/code&gt; fixed my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;long version: &lt;a href=&quot;https://github.com/vim/vim/issues/993&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/issues/993&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user10804" LastEditorDisplayName="user10804" LastEditDate="2017-01-14T17:56:19.037" LastActivityDate="2017-01-14T17:56:19.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10991" PostTypeId="2" ParentId="3518" CreationDate="2017-01-14T17:47:23.663" Score="1" Body="&lt;p&gt;I was looking for the same ability and ended up on these solutions. I ended up modifying what I have learned from the answers I found here and decided to share what I learned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks jjaderberg for showing me about the $VIMRUNTIME/doc/tags file as this made jumping to a random help file very easy using a bash shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following function and mapping to your vimrc file for a simple way to generate  a random help entry:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HelpRandom()&#xA;    &quot; Using the shell, produce a list of all help tags and select one (based on $VIMRUNTIM/doc/tags)&#xA;    execute &quot;normal! :help &quot; . system(&quot;cat $VIMRUNTIME/doc/tags | shuf -n1 | awk '{print $1;}'&quot;)&#xA;endfunction&#xA;&#xA;&quot; Display a random help entry&#xA;nnoremap &amp;lt;leader&amp;gt;?? :call HelpRandom()&amp;lt;CR&amp;gt;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note that the &quot;system&quot; command is for a *nix system and will need to be adjusted for Windows.&lt;/p&gt;&#xA;" OwnerUserId="10854" LastEditorUserId="10854" LastEditDate="2017-01-14T17:52:39.833" LastActivityDate="2017-01-14T17:52:39.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10992" PostTypeId="2" ParentId="10016" CreationDate="2017-01-15T01:39:51.160" Score="3" Body="&lt;p&gt;From @jonasl answer, you could also do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_cmd = ':NERDTreeClose\|CtrlP'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6103" LastActivityDate="2017-01-15T01:39:51.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10993" PostTypeId="2" ParentId="10988" CreationDate="2017-01-15T03:33:59.493" Score="2" Body="&lt;p&gt;I tried several times and it seems once you have interacted with the content, it opens a new window when &lt;code&gt;:Lexplore&lt;/code&gt; is called again like you stated above, however, it could be a desired behavior when you just want to explore multiple directories at once, why not use &#xA;&lt;code&gt;:NERDTree&lt;/code&gt; instead if you just want to keep a single &amp;amp;&amp;amp; browser?&lt;/p&gt;&#xA;" OwnerUserId="6731" LastActivityDate="2017-01-15T03:33:59.493" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10994" PostTypeId="2" ParentId="10976" CreationDate="2017-01-15T05:09:05.240" Score="-1" Body="&lt;p&gt;You need to add to your .vimrc file &lt;code&gt;set t_Co=256&lt;/code&gt; that allow the terminal to use colors solarized.&lt;/p&gt;&#xA;" OwnerUserId="10731" LastEditorUserId="1821" LastEditDate="2017-01-16T08:58:09.083" LastActivityDate="2017-01-16T08:58:09.083" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10995" PostTypeId="1" AcceptedAnswerId="10997" CreationDate="2017-01-15T08:34:02.943" Score="1" ViewCount="226" Body="&lt;p&gt;I'm using &lt;code&gt;vim&lt;/code&gt; to write &lt;code&gt;Jenkinsfile&lt;/code&gt; which has a groovy synatx. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;node {&#xA;  // Jenkins stuff to do&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to force groovy syntax on a file without &lt;code&gt;.groovy&lt;/code&gt; extension I added &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vi: ft=groovy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To the top of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While this works in &lt;code&gt;vim&lt;/code&gt; - &lt;code&gt;Jenkins&lt;/code&gt; has issues treating this as groovy script and throws a &lt;code&gt;syntax error&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to work around this?&lt;/p&gt;&#xA;" OwnerUserId="7125" LastActivityDate="2017-01-15T12:31:58.267" Title="Add vi: ft without breaking the code" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10996" PostTypeId="1" AcceptedAnswerId="11060" CreationDate="2017-01-15T09:10:25.270" Score="0" ViewCount="2144" Body="&lt;p&gt;Today when I open my computer and enter &lt;code&gt;vi&lt;/code&gt;, strange things happened: backspace not working(solved), and &lt;kbd&gt;Tab&lt;/kbd&gt; brings up keyword completion in insert mode, which is what I'm worrying about. Before, I can use &lt;kbd&gt;Tab&lt;/kbd&gt; in insert mode to insert 4 spaces as &lt;code&gt;expandtab&lt;/code&gt; is set. But now, when I press &lt;kbd&gt;Tab&lt;/kbd&gt;, a long list of words show up just like when you hit &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;N&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought that was a problem in my &lt;code&gt;.vimrc&lt;/code&gt; and other plugins, but after disabling all the plugins and checking my &lt;code&gt;.vimrc&lt;/code&gt;, I found no problem. I also tried to do researches in the help files, but still found nothing. I've also tried to recompile my &lt;code&gt;vim&lt;/code&gt;, but still got nothing. Can anyone help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; The situation also occurs in normal text files, where pressing &lt;kbd&gt;Tab&lt;/kbd&gt; will just bring up all the words in the text file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT2:&lt;/strong&gt; My &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;set rtp+=~/.vim/bundle/vundle/&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&quot; Plugin 'vim-scripts/android.vim'&#xA;Plugin 'davidhalter/jedi-vim'&#xA;Plugin 'Valloric/YouCompleteMe'&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}&#xA;Plugin 'scrooloose/nerdtree'&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;execute pathogen#infect()&#xA;syntax on&#xA;set laststatus=2&#xA;set shiftwidth=4&#xA;set expandtab&#xA;set hlsearch&#xA;set incsearch&#xA;set tabstop=4&#xA;set scrolloff=3&#xA;set number&#xA;set showcmd&#xA;set lines=24 columns=80&#xA;set splitright&#xA;set backspace=indent,eol,start&#xA;colorscheme slate&#xA;map Y y$&#xA;&#xA;&quot; Jedi displays function call signatures in insert mode in real-time&#xA;&quot; highlighting the current argument. The call signatures can be displayed as&#xA;&quot; a pop-up in the buffer (set to 1, the default), which has the advantage of&#xA;&quot; being easier to refer to, or in Vim's command line aligned with&#xA;&quot; the function call (set to 2), which can improve the integrity of Vim's&#xA;&quot; undo history.&#xA;let g:jedi#show_call_signatures = &quot;1&quot;&#xA;let g:jedi#show_call_signatures_delay = &quot;0&quot;&#xA;let g:jedi#goto_command = &quot;&amp;lt;leader&amp;gt;g&quot;&#xA;let g:jedi#goto_assignments_command = &quot;&quot;&#xA;let g:jedi#goto_definitions_command = &quot;&quot;&#xA;let g:jedi#documentation_command = &quot;K&quot;&#xA;let g:jedi#usages_command = &quot;&amp;lt;leader&amp;gt;u&quot;&#xA;let g:jedi#completions_command = &quot;&amp;lt;C-Space&amp;gt;&quot;&#xA;let g:jedi#rename_command = &quot;&amp;lt;leader&amp;gt;r&quot;&#xA;let g:jedi#completions_enabled = &quot;1&quot;&#xA;&#xA;&quot; YouCompleteMe settings&#xA;let g:ycm_confirm_extra_conf = 0&#xA;let g:ycm_server_log_level = 'warning'&#xA;let g:ycm_server_use_vim_stdout = 0&#xA;let g:ycm_server_keep_logfiles = 1&#xA;let g:ycm_path_to_python_interpreter = '/usr/bin/python3'&#xA;let g:ycm_enable_diagnostic_signs = 0&#xA;let g:ycm_enable_diagnostic_highlighting = 0&#xA;let g:ycm_key_list_select_completion = ['&amp;lt;Down&amp;gt;']&#xA;let g:ycm_key_list_previous_completion = ['&amp;lt;Up&amp;gt;']&#xA;&quot; let g:ycm_show_diagnostics_ui = 0&#xA;&#xA;&quot; NERDTree&#xA;let NERDTreeIgnore = ['\.o', '\~$']&#xA;&#xA;&quot; hy&#xA;let g:hy_enable_conceal = 1&#xA;setlocal concealcursor=n&#xA;&#xA;&quot; avoid mispress of &amp;lt;SHIFT&amp;gt; when writing and quiting&#xA;com -nargs=0 Q q&#xA;com -nargs=0 W w&#xA;com -nargs=0 Wq wq&#xA;com -nargs=0 Wqa wqa&#xA;&#xA;&quot; copy every thing in the file into clipboard&#xA;com -nargs=0 CpAll :norm ggVG&quot;+y&#xA;&#xA;&quot; Clear done items in TODO&#xA;com -nargs=0 TODOClear :g/\[x\]/ norm dd&#xA;com -nargs=0 TODODown :g/\[x\]/ norm ddGp&#xA;&#xA;&quot; Remove trailing space&#xA;com -nargs=0 Rmspace :%s/\s*$// | norm &#xA;&#xA;&quot; mksession command&#xA;com -nargs=1 Mks :mksession! ~/.vim/&amp;lt;args&amp;gt;.vim&#xA;com -nargs=1 Delsession :!rm ~/.vim/&amp;lt;args&amp;gt;.vim&#xA;&#xA;&quot; edit this file command&#xA;com -nargs=0 Vimrc :split ~/.vimrc&#xA;&#xA;&quot; Goto the TODO file&#xA;com -nargs=0 TODO :split ~/Desktop/TODO&#xA;&#xA;&quot; ConqueTerm shortened&#xA;com -nargs=0 Shell :ConqueTerm bash&#xA;com -nargs=0 Python :ConqueTerm python3&#xA;&#xA;&quot; Jedi command&#xA;com -nargs=0 Jedi :call Jedi()&#xA;&#xA;autocmd BufRead * call Answer()&#xA;autocmd BufRead TODO set syntax=TODO&#xA;autocmd BufRead *.ss set filetype=ss&#xA;autocmd FileType python call Jedi()&#xA;&#xA;function Jedi()&#xA;    set omnifunc=jedi#completions&#xA;    set completefunc=jedi#completions&#xA;endfunction&#xA;&#xA;function Answer()&#xA;    if getline(1) =~? '.*answer.*'&#xA;        &quot; || expand(&quot;%:t&quot;) =~? '.*answer[^.]*\&amp;gt;'&#xA;        set syntax=answer&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6380" LastEditorUserId="6380" LastEditDate="2017-01-21T08:41:02.463" LastActivityDate="2017-01-21T09:02:43.643" Title="&lt;Tab&gt; in insert mode brings up completion" Tags="|autocompletion|tab-characters|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10997" PostTypeId="2" ParentId="10995" CreationDate="2017-01-15T12:31:58.267" Score="3" Body="&lt;p&gt;&lt;code&gt;#&lt;/code&gt; isn't how you write a comment in Groovy, so you've created a file with incorrect syntax.  Change it to a proper Groovy comment and you should be fine.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// vi: ft=groovy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-01-15T12:31:58.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10998" PostTypeId="2" ParentId="7581" CreationDate="2017-01-15T14:30:56.187" Score="1" Body="&lt;p&gt;For autoload plugins i proceed in two steps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First i test whether the function exists. If not i execute &lt;code&gt;:runtime autoload/path/pluginname.vim&lt;/code&gt; and i test again whether the function exists. &lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-01-15T14:30:56.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10999" PostTypeId="1" AcceptedAnswerId="11000" CreationDate="2017-01-15T15:45:57.280" Score="0" ViewCount="88" Body="&lt;p&gt;Can vim substitute automatically depending on the case ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;like : &lt;code&gt;s/foo/bar/&lt;/code&gt; turns &lt;code&gt;Foo&lt;/code&gt; to &lt;code&gt;Bar&lt;/code&gt; and &lt;code&gt;foo&lt;/code&gt; to &lt;code&gt;bar&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="8935" LastEditorUserId="1841" LastEditDate="2017-01-15T17:49:11.060" LastActivityDate="2017-01-18T13:21:50.360" Title="How to make substitute command respect different cases" Tags="|substitute|" AnswerCount="1" CommentCount="0" ClosedDate="2017-01-16T10:41:59.960" ContentLicense="CC BY-SA 3.0" />
  <row Id="11000" PostTypeId="2" ParentId="10999" CreationDate="2017-01-15T17:47:39.270" Score="1" Body="&lt;p&gt;I think the easier solution to that is to use the &lt;a href=&quot;https://github.com/tpope/vim-abolish&quot; rel=&quot;nofollow noreferrer&quot;&gt;abolish plugin&lt;/a&gt; by Tim Pope. Once it is installed you can use the &lt;code&gt;:S&lt;/code&gt; command. For example if you have this file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;Foo&#xA;FOO&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And run &lt;code&gt;:%S/foo/bar/&lt;/code&gt; you'll get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bar&#xA;Bar&#xA;BAR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It also provides a lot of command to play with different cases.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; As @LucHermitte said, if you already have the &lt;code&gt;:S&lt;/code&gt; command used for something else, you might want to use the complete name of abolish's function: &lt;code&gt;:Subvert&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-01-18T13:21:50.360" LastActivityDate="2017-01-18T13:21:50.360" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11001" PostTypeId="2" ParentId="10986" CreationDate="2017-01-15T18:00:09.190" Score="11" Body="&lt;p&gt;While I deeply agree with @garyjohn comment, the solution could interest some other users.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the plugin &lt;a href=&quot;https://github.com/kana/vim-submode&quot;&gt;vim-submode&lt;/a&gt;: it allows to create a mode that you enter by a keypress, where some keys execute some commands and that you can leave with another keypress.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example for a while I've been using the following code to handle navigation, resize, moving and splitting windows. &lt;em&gt;(Then I realized that &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; is pretty good and I don't need a submode)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I'm not sure it is possible to have a mode inheriting the settings of another one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Create a submode to handle windows&#xA;&quot; The submode is entered whith &amp;lt;Leader&amp;gt;k and exited with &amp;lt;Leader&amp;gt;&#xA;call submode#enter_with('WindowsMode', 'n', '', '&amp;lt;Leader&amp;gt;k', ':echo &quot;windows mode&quot;&amp;lt;CR&amp;gt;')&#xA;call submode#leave_with('WindowsMode', 'n', '', '&amp;lt;Leader&amp;gt;')&#xA;&quot; Change of windows with hjkl&#xA;call submode#map('WindowsMode', 'n', '', 'j', '&amp;lt;C-w&amp;gt;j')&#xA;call submode#map('WindowsMode', 'n', '', 'k', '&amp;lt;C-w&amp;gt;k')&#xA;call submode#map('WindowsMode', 'n', '', 'h', '&amp;lt;C-w&amp;gt;h')&#xA;call submode#map('WindowsMode', 'n', '', 'l', '&amp;lt;C-w&amp;gt;l')&#xA;&quot; Resize windows with &amp;lt;C-yuio&amp;gt; (interesting on azerty keyboards)&#xA;call submode#map('WindowsMode', 'n', '', 'u', '&amp;lt;C-w&amp;gt;-')&#xA;call submode#map('WindowsMode', 'n', '', 'i', '&amp;lt;C-w&amp;gt;+')&#xA;call submode#map('WindowsMode', 'n', '', 'y', '&amp;lt;C-w&amp;gt;&amp;lt;')&#xA;call submode#map('WindowsMode', 'n', '', 'o', '&amp;lt;C-w&amp;gt;&amp;gt;')&#xA;&quot; Move windows with &amp;lt;C-hjkl&amp;gt;&#xA;call submode#map('WindowsMode', 'n', '', '&amp;lt;C-j&amp;gt;', '&amp;lt;C-w&amp;gt;J')&#xA;call submode#map('WindowsMode', 'n', '', '&amp;lt;C-k&amp;gt;', '&amp;lt;C-w&amp;gt;K')&#xA;call submode#map('WindowsMode', 'n', '', '&amp;lt;C-h&amp;gt;', '&amp;lt;C-w&amp;gt;H')&#xA;call submode#map('WindowsMode', 'n', '', '&amp;lt;C-l&amp;gt;', '&amp;lt;C-w&amp;gt;L')&#xA;&quot; close a window with c&#xA;call submode#map('WindowsMode', 'n', '', 'c', '&amp;lt;C-w&amp;gt;c')&#xA;&quot; split windows with / and !&#xA;call submode#map('WindowsMode', 'n', '', '/', '&amp;lt;C-w&amp;gt;s')&#xA;call submode#map('WindowsMode', 'n', '', '!', '&amp;lt;C-w&amp;gt;v')&#xA;&#xA;let g:submode_keep_leaving_key = 0&#xA;let g:submode_timeout = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-01-15T18:00:09.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11002" PostTypeId="1" AcceptedAnswerId="22623" CreationDate="2017-01-15T18:02:43.630" Score="8" ViewCount="425" Body="&lt;p&gt;I want to check file before quitinq &lt;code&gt;vim&lt;/code&gt; with custom functions, everything seems fine with &lt;code&gt;QuitPre&lt;/code&gt; autocommand except using &lt;code&gt;ZZ&lt;/code&gt; to exit. In this case the output is missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider following function declaration and autocommand in file &lt;code&gt;function.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au QuitPre * call CheckBeforeQuit()&#xA;&#xA;function CheckBeforeQuit()&#xA;  echo 'Hello'&#xA;  echo 'World'&#xA;  call input('Press enter')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now when I open file &lt;code&gt;tmp&lt;/code&gt; with this command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim tmp -u NONE -c 'source function.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then type &lt;code&gt;:x&lt;/code&gt;, the output &lt;code&gt;Hello\nWord&lt;/code&gt; along with prompt message is visible. If I use &lt;code&gt;ZZ&lt;/code&gt; instead, the message from &lt;code&gt;echo&lt;/code&gt; is missing. According to help &lt;code&gt;ZZ&lt;/code&gt; is the same as &lt;code&gt;:x&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course I could remap &lt;code&gt;ZZ&lt;/code&gt; to &lt;code&gt;:x&lt;/code&gt; and everything is fine now. But anyway I would like to know what is causing this difference and how I could deal with that in my function.&lt;/p&gt;&#xA;" OwnerUserId="10863" LastEditorUserId="10863" LastEditDate="2017-01-17T11:06:46.090" LastActivityDate="2020-01-21T13:57:40.733" Title="vim ZZ lost output with autocommand" Tags="|autocmd|functions|quit|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11003" PostTypeId="1" CreationDate="2017-01-15T20:40:34.093" Score="2" ViewCount="212" Body="&lt;p&gt;I found &lt;a href=&quot;https://autohotkey.com/board/topic/100293-autocorrect-anything/&quot; rel=&quot;nofollow noreferrer&quot;&gt;an automation script&lt;/a&gt; written in AutoHotKey very inspiring. It relies on the search result from Google to correct the wrongly spelled words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;; Ctrl+Alt+c autocorrect selected text&#xA;^!c::&#xA;clipback := ClipboardAll&#xA;clipboard=&#xA;Send ^c&#xA;ClipWait, 0&#xA;UrlDownloadToFile % &quot;https://www.google.com/search?q=&quot; . clipboard, temp&#xA;FileRead, contents, temp&#xA;FileDelete temp&#xA;if (RegExMatch(contents, &quot;(Showing results for|Did you mean:)&amp;lt;/span&amp;gt;.*?&amp;gt;(.*?)&amp;lt;/a&amp;gt;&quot;, match)) {&#xA;   StringReplace, clipboard, match2, &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;,, All&#xA;   StringReplace, clipboard, clipboard, &amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;,, All&#xA;}&#xA;Send ^v&#xA;Sleep 500&#xA;clipboard := clipback&#xA;return&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to construct a similar function in Vim?&lt;/p&gt;&#xA;" OwnerUserId="2398" LastEditorUserId="205" LastEditDate="2017-01-16T06:28:19.263" LastActivityDate="2017-01-16T06:28:19.263" Title="Autocorrect spelling mistakes using Google?" Tags="|vimscript|spell-checking|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11004" PostTypeId="1" CreationDate="2017-01-15T22:28:47.770" Score="7" ViewCount="7691" Body="&lt;p&gt;I've installed the latest version of Vim to date (8.0) for Windows. But the version of Vim I've got does not have Python support. I've downloaded the .exe version directly from &lt;a href=&quot;http://www.vim.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim.org&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo has('python') &#xA;&quot; returns 0. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I remember correctly, Vim used to come with Python support in the default build. Is this no longer true?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have to compile Vim with Python support myself (and how to do that on MS Windows) or is there another way?&lt;/p&gt;&#xA;" OwnerUserId="2689" LastEditorUserId="51" LastEditDate="2018-08-30T10:37:11.097" LastActivityDate="2020-09-02T09:48:45.770" Title="How to get Python support on MS Windows?" Tags="|microsoft-windows|vimscript-python|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11005" PostTypeId="1" CreationDate="2017-01-15T22:33:40.037" Score="2" ViewCount="7502" Body="&lt;p&gt;I have a number of files with a syntax almost&#xA;identical to C, though the files have suffixes&#xA;such as &lt;code&gt;.t&lt;/code&gt;, &lt;code&gt;.sc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to have the same syntax highlighting&#xA;that I have for standard C files ending with the&#xA;suffix &lt;code&gt;.c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For any one file I know I can execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set filetype=c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it is cumbersome to have to execute that&#xA;command every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something I can add to my .vimrc file&#xA;so that some files with specific suffixes&#xA;can have &quot;C&quot; syntax highlighting?&lt;/p&gt;&#xA;" OwnerUserId="10865" LastEditorUserId="205" LastEditDate="2017-01-16T01:30:15.637" LastActivityDate="2017-01-16T01:30:15.637" Title="Syntax highlighting for &quot;C like&quot; files" Tags="|syntax-highlighting|" AnswerCount="2" CommentCount="0" ClosedDate="2017-01-27T00:53:04.827" ContentLicense="CC BY-SA 3.0" />
  <row Id="11006" PostTypeId="2" ParentId="11005" CreationDate="2017-01-15T23:00:30.273" Score="2" Body="&lt;p&gt;You can put this in your ~/.vimrc, or in a file in ~/.vim/ftdetect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.t,*.sc set filetype=c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help new-filetype&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-01-15T23:00:30.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11007" PostTypeId="2" ParentId="11005" CreationDate="2017-01-15T23:01:47.810" Score="5" Body="&lt;p&gt;Yes, you can add the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetypedetect&#xA;    au! BufRead,BufNewFile *.t, *.sc setfiletype c&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, to help keep your .vimrc tidy, you could also put that in a separate file called filetypes.vim in your .vim directory.&lt;/p&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2017-01-15T23:01:47.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11008" PostTypeId="2" ParentId="11004" CreationDate="2017-01-15T23:53:49.413" Score="10" Body="&lt;p&gt;You need to install Python yourself on Windows.&lt;/p&gt;&#xA;&lt;p&gt;If you type &lt;code&gt;:version&lt;/code&gt;, you should see &lt;code&gt;+python/dyn&lt;/code&gt; and &lt;code&gt;+python3/dyn&lt;/code&gt;.  On Windows, this means that Vim is compiled to dynamically load the Python DLL.  You can read about this in &lt;a href=&quot;https://vimhelp.org/if_pyth.txt.html#python-dynamic&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h python-dynamic&lt;/code&gt;&lt;/a&gt;.  Depending on the versions you install, you may want to look at &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27pythondll%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h pythondll&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27pythonthreedll%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h pythonthreedll&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you install Python 3, keep in mind that you will need to verify it with &lt;code&gt;:echo has('python3')&lt;/code&gt;.  Additionally, if you want to install both Python 2 and 3, you will want to read &lt;a href=&quot;https://vimhelp.org/if_pyth.txt.html#has-python&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h has-python&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="343" LastEditDate="2020-09-02T09:48:45.770" LastActivityDate="2020-09-02T09:48:45.770" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11011" PostTypeId="2" ParentId="10974" CreationDate="2017-01-16T14:37:42.560" Score="1" Body="&lt;p&gt;I have had problems installing vim and YouCompleteMe as well. You might want to try managing your installations with &lt;a href=&quot;http://linuxbrew.sh/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linuxbrew&lt;/a&gt;.&#xA;Linuxbrew installs programs from source or tarballs, and manages all dependencies for you. It does not need root (some setting up the environment might require it though) and can install the needed libraries for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A note on installing YouCompleteMe:&lt;br&gt;&#xA;Since YouCompleteMe is depending on Python being the same as the one vim was installed with, it is important that you first install Python (&lt;code&gt;brew install python&lt;/code&gt;), then vim (&lt;code&gt;brew install vim&lt;/code&gt;) and then run the make script in the YouCompleteMe directory (&lt;code&gt;~/.vim/bundle/YouCompleteMe/install.py&lt;/code&gt;).&#xA;This means that if you update Python you have to &lt;code&gt;brew reinstall&lt;/code&gt; their dependents again.&lt;/p&gt;&#xA;" OwnerUserId="10869" LastActivityDate="2017-01-16T14:37:42.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11012" PostTypeId="2" ParentId="10988" CreationDate="2017-01-16T15:19:06.037" Score="5" Body="&lt;p&gt;Please try v162j of netrw which may have fixed this problem: &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;noreferrer&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#NETRW&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2017-01-16T15:19:06.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11013" PostTypeId="1" AcceptedAnswerId="11014" CreationDate="2017-01-16T20:10:07.003" Score="1" ViewCount="138" Body="&lt;p&gt;I'm a beginner at Vim. I have downloaded the latest version of Vim on my Windows 7 system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I attempted to open and save an existing .txt file after making a minor change and got some interesting behavior which I would like help understanding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a file named &quot;Python_Link.txt&quot; on my desktop. I opened Vim and typed the following on Normal Mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e C:\Users\Joe\Desktop\Python_Link.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press Enter the file opens as I would expect in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in Normal Mode. This works as expected. I then type in some lines of text. I then press:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;esc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm back in Normal Mode. I then enter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then manually close Vim by terminating it by clicking on the X in the upper right hand corner of the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I check back on my desktop I now have 3 files instead of the one I originally started with. The one I started with appears unchanged when I open it in Windows Notepad. When I open one of the other files I see the changes I made in Vim exactly as I made them. The 3rd file looks like it contains Binary data, but the first 3 characters are &quot;Vim&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open a Console and navigate to the desktop and use the&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;command I see the following 3 files listed:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Python_Link.txt&#xA;Python_Link.txt~&#xA;.Python_Link.txt.un~&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The .txt~ file contains my original data.&#xA;The .txt file contains the original data and the changes I added in Vim.&#xA;The .un~ file contains the data which looks like Binary data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was under the impression that the :w Command in Normal Mode in Vim merely saved the file. That's what I was trying to do. Can someone please explain what is happening? Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="10876" LastActivityDate="2017-01-16T21:20:29.343" Title="Understanding File Saving Behavior in Windows" Tags="|normal-mode|save|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11014" PostTypeId="2" ParentId="11013" CreationDate="2017-01-16T21:20:29.343" Score="0" Body="&lt;p&gt;The .txt~ file is a standard vim backup file. To stop vim from creating one, add the following to your _vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nobackup&#xA;set nowritebackup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;https://stackoverflow.com/q/15660669/4748017&quot;&gt;this question on SO&lt;/a&gt;, the .un~ is an undo file. It can be turned off by the following command in your _vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noundofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5298" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-01-16T21:20:29.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11015" PostTypeId="1" AcceptedAnswerId="11016" CreationDate="2017-01-16T23:42:54.050" Score="2" ViewCount="406" Body="&lt;p&gt;I have previously asked this in StackOverflow (May 2015), but without getting any replies that I was completely happy with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This ought to be simple:  I want to configure Vim to &lt;code&gt;set number&lt;/code&gt; whenever the editor is in Ex mode (to get visible line numbers), but never have that option set in visual mode.  How?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the solution involves having to start &lt;code&gt;ex&lt;/code&gt; instead of &lt;code&gt;vim&lt;/code&gt;, that's fine, but the solution should ideally also cover the case of entering Ex mode from visual mode (using &lt;kbd&gt;Q&lt;/kbd&gt; in Vim visual mode, for example), and the case where I switch back to visual mode (using &lt;code&gt;:vi&lt;/code&gt; in Ex mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest I've come is the following suggestion (which I would be happy if someone could explain to me, because I don't fully understand it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;number = mode(1) ==# 'ce'&#xA;nnoremap &amp;lt;silent&amp;gt; Q :set number&amp;lt;CR&amp;gt;Q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works for turning &lt;code&gt;number&lt;/code&gt; on when entering Ex mode, but will leave it activated upon entering Vim visual mode again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A solution that also works in &lt;code&gt;nvi&lt;/code&gt; would be nice, but not necessary. &lt;/p&gt;&#xA;" OwnerUserId="2252" LastActivityDate="2017-01-17T17:50:49.790" Title="Automatically set the 'number' option in Vim when entering Ex mode, set 'nonumber' in visual mode" Tags="|visual-mode|ex-mode|line-numbers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11016" PostTypeId="2" ParentId="11015" CreationDate="2017-01-17T00:29:37.477" Score="3" Body="&lt;p&gt;For Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Create a mapping to enter Ex mode and turn on numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap Q Qset number&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2) Create a function to turn numbering off:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! NoNumber()&#xA;    set nonumber&#xA;    return ''&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;3) Arrange for numbers to be turned off when in Normal mode. If you use the statusline or ruler, you can add a function&#xA;there (this is why the above function returns an empty&#xA;string) since the statusline and ruler aren't updated in Ex mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you've already customised your statusline, you can prepend to it&#xA;with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline^=%{NoNumber()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you haven't, there are example statusline formats under &lt;code&gt;:h 'statusline'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly for the ruler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rulerformat^=%{NoNumber()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will need both if you have &lt;code&gt;set laststatus=1&lt;/code&gt;. Adding the&#xA;function to &lt;code&gt;'titlestring'&lt;/code&gt; might also be an option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bear in mind that functions added to the statusline, ruler, or title will be called frequently. I haven't noticed a performance hit in this case, but beware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bit of extra information. The mapping for &lt;code&gt;Q&lt;/code&gt; issues &lt;code&gt;set number&lt;/code&gt; in Ex mode,&#xA;leaving that text on the screen. If this bothers you, you could enable numbering before&#xA;entering Ex mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap Q :set number&amp;lt;CR&amp;gt;Q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However you must have &lt;code&gt;'lazyredraw'&lt;/code&gt; set or the screen will be updated before&#xA;entering Ex mode, firing off &lt;code&gt;NoNumber()&lt;/code&gt; from e.g. the statusline, and negating&#xA;the effect of &lt;code&gt;set number&lt;/code&gt; in the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're probably out of luck with Nvi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I nearly forgot: to have line numbers active if you start Vim in Ex mode, e.g. with &lt;code&gt;vim -E&lt;/code&gt;, just add &lt;code&gt;set number&lt;/code&gt; to your &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.P.S. The question states that numbering should never be on in Normal mode. This is just as well, because with this approach you literally can't turn numbering on without removing the &lt;code&gt;NoNumber&lt;/code&gt; function from the statusline, ruler, or title.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2017-01-17T17:50:49.790" LastActivityDate="2017-01-17T17:50:49.790" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11017" PostTypeId="1" AcceptedAnswerId="11090" CreationDate="2017-01-17T03:15:06.093" Score="0" ViewCount="307" Body="&lt;p&gt;I wrote the following in my .vimrc file in order to automate getting an HTML file set up.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap html&amp;lt;tab&amp;gt;&#xA;\&amp;lt;html&amp;gt;&amp;lt;enter&amp;gt;&#xA;    \&amp;lt;tab&amp;gt;&amp;lt;head&amp;gt;&amp;lt;enter&amp;gt;&#xA;....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on.  However, when I use this in an .html file the tabs are very off, seemingly because tabs in HTML files are treated like sequences of spaces rather than single characters.  I'm open to any kind of suggestions, either about how to deal with this issue or more broadly if there's a better way to be accomplishing what I'm trying to do.&lt;/p&gt;&#xA;" OwnerUserId="6225" LastActivityDate="2017-01-24T13:14:22.173" Title="How to insert tabs in key remapping?" Tags="|vimrc|filetype-html|key-bindings|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11018" PostTypeId="1" CreationDate="2017-01-17T03:50:10.593" Score="3" ViewCount="5290" Body="&lt;p&gt;I installed the powerline patched fonts by following the wiki at &lt;a href=&quot;https://powerline.readthedocs.io/en/master/installation/linux.html#patched-font-installation&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://powerline.readthedocs.io/en/master/installation/linux.html#patched-font-installation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I selected the patched font and added:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_powerline_fonts = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I still see wrong symbols. How can I fix this?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/YIwRx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YIwRx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6766" LastActivityDate="2018-02-07T11:01:29.670" Title="Airline fancy symbols missing" Tags="|vimrc|plugin-airline|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11019" PostTypeId="2" ParentId="10976" CreationDate="2017-01-17T07:52:57.867" Score="3" Body="&lt;p&gt;The following configuration fixed OP's issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_ut=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This says to Vim to use the current background's color to clear the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related answer: &lt;a href=&quot;https://stackoverflow.com/a/15095377/2558252&quot;&gt;https://stackoverflow.com/a/15095377/2558252&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-01-17T07:52:57.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11020" PostTypeId="2" ParentId="7058" CreationDate="2017-01-17T14:31:11.620" Score="0" Body="&lt;p&gt;Since I discovered that my comment for the airline issue does not quite work, here's an expanded (and hopefully correct) answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup my_autocmd_name&#xA;  ...&#xA;  autocmd SourceCmd .vimrc execute &quot;source&quot; expand(&quot;&amp;lt;afile&amp;gt;&quot;) | AirlineRefresh&#xA;&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd SourceCmd&lt;/code&gt; will actually prevent vim from sourcing the file so we have to call it ourselves before doing the refresh.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-01-17T14:31:11.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11021" PostTypeId="2" ParentId="11018" CreationDate="2017-01-17T14:32:28.667" Score="3" Body="&lt;p&gt;I remember having a similar problem. I never really solved it but worked my way around it by installing the &lt;a href=&quot;http://sourcefoundry.org/hack/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hack&lt;/a&gt; font and by putting the following in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Hack:h10:cANSI&#xA;&#xA;&quot; Airline&#xA;let g:airline_powerline_fonts = 1&#xA;&#xA;if !exists('g:airline_symbols')&#xA;    let g:airline_symbols = {}&#xA;endif&#xA;&#xA;&quot; unicode symbols&#xA;let g:airline_left_sep = '»'&#xA;let g:airline_left_sep = '▶'&#xA;let g:airline_right_sep = '«'&#xA;let g:airline_right_sep = '◀'&#xA;let g:airline_symbols.linenr = '␊'&#xA;let g:airline_symbols.linenr = '␤'&#xA;let g:airline_symbols.linenr = '¶'&#xA;let g:airline_symbols.branch = '⎇'&#xA;let g:airline_symbols.paste = 'ρ'&#xA;let g:airline_symbols.paste = 'Þ'&#xA;let g:airline_symbols.paste = '∥'&#xA;let g:airline_symbols.whitespace = 'Ξ'&#xA;&#xA;&quot; airline symbols&#xA;let g:airline_left_sep = ''&#xA;let g:airline_left_alt_sep = ''&#xA;let g:airline_right_sep = ''&#xA;let g:airline_right_alt_sep = ''&#xA;let g:airline_symbols.branch = ''&#xA;let g:airline_symbols.readonly = ''&#xA;let g:airline_symbols.linenr = ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some of the unicode characters are not recognized by my browser, but vim will know what to do if you copy paste it.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2017-01-17T14:32:28.667" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11022" PostTypeId="2" ParentId="11017" CreationDate="2017-01-17T15:27:07.523" Score="2" Body="&lt;p&gt;I think this has to do with the way indenting is handled. If this is true &lt;code&gt;expandtab&lt;/code&gt; should be set in your HTML buffer (you can check with &lt;code&gt;:set expandtab?&lt;/code&gt;). If you &lt;code&gt;:set noexpandtab&lt;/code&gt; and then use your command, the tabs should be in the file and you should get the expected behavior. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many people actually prefer to use spaces instead of tabs. This option allows them to use the tab key to insert the correct number of spaces (derived from &lt;code&gt;shiftwidth&lt;/code&gt;). You do not seem to think this desirable, so you can safely set &lt;code&gt;noexpandtab&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2017-01-17T15:27:07.523" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11023" PostTypeId="1" AcceptedAnswerId="11024" CreationDate="2017-01-17T21:13:23.197" Score="2" ViewCount="1499" Body="&lt;p&gt;I don't get it, my vimrc has &lt;code&gt;set ai&lt;/code&gt;, but when editing project files (php), &lt;code&gt;:set ai?&lt;/code&gt; always returns &lt;code&gt;noautoindent&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;inside .vimrc &lt;code&gt;:set ai?&lt;/code&gt; returns true. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;my rc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim-plug (https://github.com/junegunn/vim-plug)&#xA;&quot; Automatically install vim-plug and run PlugInstall if vim-plug not found&#xA;&#xA;if empty(glob('~/.vim/autoload/plug.vim'))&#xA;  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs&#xA;    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;  autocmd VimEnter * PlugInstall | source $MYVIMRC&#xA;endif&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Plug install packages&#xA;&quot;*****************************************************************************&#xA;&#xA;&quot; Specify a directory for plugins&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'tyrannicaltoucan/vim-quantum' &quot; let g:quantum_black = 1&#xA;Plug 'ctrlpvim/ctrlp.vim'&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'Xuyuanp/nerdtree-git-plugin'&#xA;Plug 'airblade/vim-gitgutter'&#xA;Plug 'bronson/vim-trailing-whitespace'&#xA;Plug 'editorconfig/editorconfig-vim'&#xA;Plug 'Raimondi/delimitMate'&#xA;Plug 'scrooloose/syntastic'&#xA;Plug 'Yggdroot/indentLine'&#xA;Plug 'tpope/vim-commentary'&#xA;Plug 'sheerun/vim-polyglot'&#xA;Plug 'valloric/matchtagalways' &quot; doesn't work properly in neovim, cursor jumps about&#xA;Plug 'ap/vim-buftabline'&#xA;Plug 'ConradIrwin/vim-bracketed-paste'&#xA;&#xA;&quot; Initialize plugin system&#xA;call plug#end()&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Visual Settings&#xA;&quot;*****************************************************************************&#xA;&#xA;set number&#xA;set ruler&#xA;set nowrap&#xA;&#xA;if $TERM_PROGRAM =~ &quot;iTerm&quot;&#xA;  set termguicolors&#xA;endif&#xA;&#xA;let &amp;amp;t_8f = &quot;\&amp;lt;Esc&amp;gt;[38;2;%lu;%lu;%lum&quot;&#xA;let &amp;amp;t_8b = &quot;\&amp;lt;Esc&amp;gt;[48;2;%lu;%lu;%lum&quot;&#xA;&#xA;let g:quantum_black = 1&#xA;colorscheme quantum&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; NERDTree config&#xA;&quot;*****************************************************************************&#xA;&#xA;let NERDTreeShowHidden = 1&#xA;let NERDTreeIgnore=['.git$[[dir]]', '.swp']&#xA;&#xA;map &amp;lt;C-n&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Optimizations&#xA;&quot;*****************************************************************************&#xA;&#xA;set lazyredraw&#xA;&#xA;let g:python_host_skip_check = 1&#xA;let g:python3_host_skip_check = 1&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; syntastic&#xA;&quot;*****************************************************************************&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; yank and cut to osx clipboard&#xA;&quot;*****************************************************************************&#xA;&#xA;noremap YY &quot;+y&amp;lt;CR&amp;gt;&#xA;noremap XX &quot;+x&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; indent&#xA;&quot;*****************************************************************************&#xA;&#xA;&quot; tabs&#xA;set listchars=tab:˗\ ,eol:¬&#xA;set list&#xA;&#xA;&quot; spaces&#xA;let g:indentLine_enabled = 1&#xA;let g:indentLine_concealcursor = 0&#xA;let g:indentLine_char = '·'&#xA;let g:indentLine_faster = 1&#xA;&#xA;set tabstop=2&#xA;set softtabstop=2&#xA;set shiftwidth=2&#xA;&#xA;set ai&#xA;&#xA;filetype plugin indent on&#xA;&#xA;&quot; make &amp;lt; &amp;gt; indents keep selection&#xA;vnoremap &amp;lt; &amp;lt;gv&#xA;vnoremap &amp;gt; &amp;gt;gv&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; matchtagalways&#xA;&quot;*****************************************************************************&#xA;&#xA;let g:mta_filetypes = { 'html' : 1, 'xhtml' : 1, 'xml' : 1, 'jinja' : 1, 'php': 1 }&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; ctrlp&#xA;&quot;*****************************************************************************&#xA;&#xA;set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__&#xA;let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist)|(\.(swp|tox|ico|git|hg|svn))$'&#xA;&#xA;&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; buffers&#xA;&quot;*****************************************************************************&#xA;&#xA;noremap &amp;lt;Tab&amp;gt; :bnext&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;S-Tab&amp;gt; :bprevious&amp;lt;CR&amp;gt;&#xA;&#xA;noremap &amp;lt;C-w&amp;gt; :bd&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; general&#xA;&quot;*****************************************************************************&#xA;&#xA;set autoread&#xA;set backspace=indent,eol,start&#xA;&#xA;&quot; :h last-position-jump&#xA;au BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) | exe &quot;normal! g`\&quot;&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user10804" LastEditorUserId="1841" LastEditDate="2017-01-18T07:47:34.000" LastActivityDate="2017-01-18T10:03:45.577" Title="Auto indent turns off itself automatically on php files" Tags="|indentation|filetype-php|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11024" PostTypeId="2" ParentId="11023" CreationDate="2017-01-17T21:56:46.327" Score="5" Body="&lt;p&gt;This is because of vim's internal php settings. If you look in &lt;code&gt;vim##/indent/php.vim&lt;/code&gt;, there's the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal noautoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to override this feature, you'll need to use an autocmd in your &lt;code&gt;vimrc&lt;/code&gt;. Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType php setlocal autoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will turn on auto indenting whenever vim detects it's editing a php file. Alternatively if you want to &lt;em&gt;always&lt;/em&gt; have autoindenting, you could also do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost * setlocal autoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will turn on auto indenting whenever vim open &lt;em&gt;any&lt;/em&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's probably worth noting that if they specifcally turned off &lt;code&gt;autoindent&lt;/code&gt; they may have a good reason for it. But this is how you would change it if you wanted to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info see &lt;code&gt;:h autocmd&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-01-17T22:05:51.263" LastActivityDate="2017-01-17T22:05:51.263" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11025" PostTypeId="1" AcceptedAnswerId="11028" CreationDate="2017-01-18T07:59:32.723" Score="9" ViewCount="7794" Body="&lt;p&gt;I have a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 TmuxSession !tmux.session &quot;&amp;lt;args&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to run it in visual mode so that selected text will be passed as argument.&lt;br&gt;&#xA;By selected text I mean selected in visual mode in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried running &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=1 -range -register TmuxSession !tmux.session &quot;&amp;lt;args&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it keeps saying &lt;code&gt;E471: Argument required&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;br&gt;&#xA;I know about using &lt;code&gt;&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt; to paste an argument and that is how I use the upper command at the moment, but I don't want to copy selection and paste it every time to the command, because this can be done faster using range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following solution does not work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PrintRange() range&#xA;    echo getline(a:firstline, a:lastline)&#xA;endfunction&#xA;&#xA;command! -range PassRange &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call PrintRange()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;because when I want to select second and third word from line containing &lt;code&gt;one two three&lt;/code&gt; - I get the whole line (obviously).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to pass only the selected part of the text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="3254" LastEditorUserId="3254" LastEditDate="2017-01-19T08:07:28.697" LastActivityDate="2020-03-28T17:34:25.887" Title="Passing visual range to a :command as its argument" Tags="|visual-mode|range|user-commands|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11026" PostTypeId="1" CreationDate="2017-01-18T09:14:45.503" Score="2" ViewCount="490" Body="&lt;p&gt;I am new to vim, so I installed the plugin DelimitMate to my vim. But it is not working in my vim -version  7.4.1689.My plugin manager in pathogen.I searched on everywhere to solve this problem but nothing worked. I used the following commands in vim to install it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd ~/.vim &#xA;$ git submodule add git://github.com/Raimondi/delimitMate.git bundle/delmitmate &#xA;$ git submodule init &amp;amp;&amp;amp; git submodule update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not only this, the help commands are not working either: &lt;code&gt;:h delimitmate&lt;/code&gt; and &lt;code&gt;:help DelimitMate&lt;/code&gt; like commands are not working &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also my other plugins are working well in my vim , so thats not the fault of with my vim. So please anybody can tell me what wrong am I doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also in my .vimrc file &lt;code&gt;filetype plugin indent on&lt;/code&gt; has been added . &#xA;So please somebody help me sort out this problem.&lt;/p&gt;&#xA;" OwnerUserId="10897" LastEditorUserId="10897" LastEditDate="2017-01-18T13:39:27.213" LastActivityDate="2017-01-18T13:39:27.213" Title="DelimitMate plugin for vim not working" Tags="|vimrc|delimiter-matching|plugin-pathogen|plugin-delimitmate|" AnswerCount="0" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11027" PostTypeId="2" ParentId="11023" CreationDate="2017-01-18T10:03:45.577" Score="2" Body="&lt;p&gt;The general mechanism for discovering where a particular Vim option was set is the &lt;code&gt;:verbose&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set autoindent?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above will inform you that autoindent was most recently unset by the script in location &lt;code&gt;$VIMRUNTIME/indent/php.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Tumbler41 has already described &lt;a href=&quot;https://vi.stackexchange.com/a/11024/343&quot;&gt;how to overrule this with an autocommand&lt;/a&gt;, but I'll note that Vim also has more specific mechanisms for altering settings made by a global filetype plugin, which are described in &lt;code&gt;:help ftplugin-overrule&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, the third method is the the best one to use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a file in the location &lt;code&gt;~/.vim/after/indent/php.vim&lt;/code&gt; with the contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal autoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-01-18T10:03:45.577" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11028" PostTypeId="2" ParentId="11025" CreationDate="2017-01-18T11:08:39.243" Score="14" Body="&lt;p&gt;See &lt;a href=&quot;https://stackoverflow.com/a/10573044&quot;&gt;this answer on stackoverflow&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example given is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; function! PrintGivenRange() range&#xA;     echo &quot;firstline &quot;.a:firstline.&quot; lastline &quot;.a:lastline&#xA;     &quot; Do some more things&#xA; endfunction&#xA;&#xA; command! -range PassRange &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call PrintGivenRange()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus you might want to create a function which would use the range and do the tmux call you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your function, to get the text in the range you can use the &lt;code&gt;getline()&lt;/code&gt; function which will take &lt;code&gt;a:firstline&lt;/code&gt; and &lt;code&gt;a:lastline&lt;/code&gt; as parameters and return the text in the buffer between theses lines. You can have a look at &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getline%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h getline()&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getbufline%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h getbufline()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; If you want to get the text characterwise and not linewise you'll have to play with the marks. This edit is inspired from &lt;a href=&quot;https://stackoverflow.com/a/6271254&quot;&gt;this SO answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when you call you command with &lt;code&gt;:'&amp;lt;,'&amp;gt;PassRange&lt;/code&gt; the marks &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; are set. The doc &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%27%3C&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h '&amp;lt;&lt;/code&gt;&lt;/a&gt; tells us that these marks are used to describe the last visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your function would need to look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PrintGivenRange() range&#xA;    &quot; Get the line and column of the visual selection marks&#xA;    let [lnum1, col1] = getpos(&quot;'&amp;lt;&quot;)[1:2]&#xA;    let [lnum2, col2] = getpos(&quot;'&amp;gt;&quot;)[1:2]&#xA;&#xA;    &quot; Get all the lines represented by this range&#xA;    let lines = getline(lnum1, lnum2)         &#xA;&#xA;    &quot; The last line might need to be cut if the visual selection didn't end on the last column&#xA;    let lines[-1] = lines[-1][: col2 - (&amp;amp;selection == 'inclusive' ? 1 : 2)]&#xA;    &quot; The first line might need to be trimmed if the visual selection didn't start on the first column&#xA;    let lines[0] = lines[0][col1 - 1:]&#xA;&#xA;    &quot; Get the desired text&#xA;    let selectedText = join(lines, &quot;\n&quot;)         &#xA;&#xA;    &quot; Do the call to tmux&#xA;    execute &quot;!tmux.session &quot; . selectedText &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-01-18T16:56:29.753" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11029" PostTypeId="1" AcceptedAnswerId="11031" CreationDate="2017-01-18T11:41:54.470" Score="3" ViewCount="440" Body="&lt;p&gt;I have a number of multi million line sets of data to edit before using a program to analyse them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a set of regexp (23 of them) which do the work. Things like &lt;code&gt;:%s/\n\n/\r&lt;/code&gt; to get rid of multiple blank lines&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I turn this set of commands into a script?&lt;/p&gt;&#xA;" OwnerUserId="10843" LastEditorUserId="1841" LastEditDate="2017-01-18T12:38:20.020" LastActivityDate="2017-01-23T16:38:40.030" Title="Turning a set of vi regexp into a script" Tags="|vimscript|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11031" PostTypeId="2" ParentId="11029" CreationDate="2017-01-18T12:42:38.587" Score="3" Body="&lt;p&gt;You can add the following lines to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyRegex()&#xA;    execute '%s/\n\n/\r'&#xA;    &quot; Add other regexes here&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can then open your buffer and use &lt;code&gt;:call MyRegex()&lt;/code&gt; to apply your regexes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;execute&lt;/code&gt; allows you to execute a command from a script (See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :execute&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also want to have a look at &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#substitute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h substitute()&lt;/code&gt;&lt;/a&gt; which you can use from a script too.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-01-18T12:42:38.587" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="11032" PostTypeId="1" CreationDate="2017-01-18T13:54:24.247" Score="1" ViewCount="935" Body="&lt;p&gt;In relation to this question: &lt;a href=&quot;https://vi.stackexchange.com/questions/11023/auto-indent-turns-off-itself-automatically-on-php-files&quot;&gt;Auto indent turns off itself automatically on php files&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has a php auto indent script; it behaves in following way: When &lt;code&gt;autoindent&lt;/code&gt; is ON - if you open a php script, it disables default &lt;code&gt;autoindent&lt;/code&gt; and uses its own logic. But I noticed that if the php file contains escaped html this script stops working. And auto indentation and autocomplete is not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you confirm that this is indeed so? Is there any way to fix this?&lt;/p&gt;&#xA;" OwnerDisplayName="user10804" LastEditorUserId="23663" LastEditDate="2020-02-08T07:43:06.947" LastActivityDate="2020-02-08T07:43:06.947" Title="vim doesn't auto indent php files with html in it" Tags="|indentation|filetype-php|" AnswerCount="0" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11033" PostTypeId="2" ParentId="9595" CreationDate="2017-01-18T14:08:55.697" Score="1" Body="&lt;p&gt;The simplest answer is to use &lt;code&gt;colorscheme=default&lt;/code&gt;.  This assumes changing the other colors is acceptable.&lt;/p&gt;&#xA;" OwnerUserId="5353" LastActivityDate="2017-01-18T14:08:55.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11034" PostTypeId="1" AcceptedAnswerId="11038" CreationDate="2017-01-18T19:09:28.497" Score="0" ViewCount="136" Body="&lt;p&gt;Is there way to prevent Vim from clearing history after exiting Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to see the changes I made, while I am using &lt;a href=&quot;http://sjl.bitbucket.org/gundo.vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gundo&lt;/a&gt; (or &lt;a href=&quot;https://github.com/mbbill/undotree&quot; rel=&quot;nofollow noreferrer&quot;&gt;UndoTree&lt;/a&gt;), even though I quit vim and the terminal and come back to the same file later on?&lt;/p&gt;&#xA;" OwnerUserId="7621" LastEditorUserId="1841" LastEditDate="2017-01-19T12:14:59.420" LastActivityDate="2017-01-19T12:14:59.420" Title="How to prevent Vim from clearing history?" Tags="|buffers|undo-redo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11035" PostTypeId="2" ParentId="11025" CreationDate="2017-01-18T19:21:07.347" Score="3" Body="&lt;p&gt;you can also adapt this one liner&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -range TmuxSession execute &quot;!tmux.session &quot; . @*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or if you do need multiline visual selection change &lt;code&gt;@*&lt;/code&gt; to &lt;code&gt;substitute(@*,&quot;\n&quot;,&quot; &quot;,&quot;g&quot;)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;@*&lt;/code&gt; register stores current selection (for linux, on windows there could be different naming convention).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-range&lt;/code&gt; is only to avoid an error if you want to execute this command with range marks, i.e. &lt;code&gt;'&amp;lt;,'&amp;gt;TmuxSession&lt;/code&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="10863" LastEditorUserId="10863" LastEditDate="2017-01-18T19:38:20.997" LastActivityDate="2017-01-18T19:38:20.997" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11037" PostTypeId="1" CreationDate="2017-01-18T22:27:38.620" Score="1" ViewCount="424" Body="&lt;p&gt;If pressing &lt;code&gt;CTRL-]&lt;/code&gt; matches multiple tags in Vim, it'll say &quot;tag 1 of x or more&quot;. Typing &lt;code&gt;:ts&lt;/code&gt; now shows you the list of x tags and allows you to choose which tag you want to jump to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I am in this list of tags screen, I have ~100 results and I'd like to search for a particular word that the result (tag) I want has. How can I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I want to search through the &lt;code&gt;:ts&lt;/code&gt; page as if it were text.&lt;/p&gt;&#xA;" OwnerUserId="10902" LastEditorUserId="1841" LastEditDate="2017-01-19T12:14:02.303" LastActivityDate="2017-01-19T12:14:02.303" Title="How to search through tag results from :ts?" Tags="|tags|ctags|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11038" PostTypeId="2" ParentId="11034" CreationDate="2017-01-18T23:19:43.263" Score="1" Body="&lt;p&gt;Use &lt;code&gt;undotree&lt;/code&gt; setting for this - &lt;code&gt;:h undotree.txt&lt;/code&gt;, &lt;code&gt;:h undodir&lt;/code&gt; and &lt;code&gt;:h presistent_undo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('persistent_undo')&#xA;  if exists('$SUDO_USER')&#xA;    &quot; don't create root-owned files&#xA;    set noundofile&#xA;  else&#xA;    set undodir=~/.local/tmp/vim/undo//&#xA;    &quot; keep undo files out of the way&#xA;    set undodir+=~/.vim/tmp/undo//&#xA;    set undodir+=.    &#xA;    &quot; actually use undo files&#xA;    set undofile&#xA;  endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Despite the check for sudo user to not create a undo file owned by root, this sets few dirs for Vim to create undofile (first available will be used). Also this has &lt;code&gt;set undofile&lt;/code&gt; to make sure undofile will be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just checked on some config file with UndoTree and there are changes made 11 days ago and I'm sure I did reboot my laptop in between at least 4 times.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-01-18T23:19:43.263" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11039" PostTypeId="2" ParentId="439" CreationDate="2017-01-19T00:06:45.617" Score="4" Body="&lt;p&gt;Create a macro and reuse it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now replay the macro, &lt;code&gt;a&lt;/code&gt; by using &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; wherever you want to join two lines with no space. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt; will repeat the previous macro. So you can just hold &lt;kbd&gt;@&lt;/kbd&gt; to join multiple lines.&lt;/p&gt;&#xA;" OwnerUserId="918" LastEditorUserId="51" LastEditDate="2017-06-22T22:02:02.293" LastActivityDate="2017-06-22T22:02:02.293" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11040" PostTypeId="1" AcceptedAnswerId="11046" CreationDate="2017-01-19T01:54:07.390" Score="0" ViewCount="1049" Body="&lt;p&gt;Aloha,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I took the plunge to start using vim as my main editor. I'm a week in, and beginning to see the beauty of it. It's now the only editor I use already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyhoot - I found a very useful mapping on &lt;a href=&quot;https://stackoverflow.com/questions/18948491/running-python-code-in-vim&quot;&gt;stackoverflow&lt;/a&gt; that lets me run python files within vim. The only issue is that it only works on the first file I open. If I use &lt;code&gt;:tabe myfile.py&lt;/code&gt; to open another python file, pressing the F7 key binding doesn't work on the newly opened tab. Any way to make F7 work for all open tabs?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: &#xA;And just in case it's needed, here is my complete .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;' VUNDLE SETTINGS AND PLUGINS '&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;            &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&#xA;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;Plugin 'davidhalter/jedi-vim'&#xA;&#xA;Plugin 'scrooloose/nerdtree'&#xA;&#xA;Plugin 'tpope/vim-fugitive'&#xA;&#xA;Plugin 'jmcantrell/vim-virtualenv'&#xA;&#xA;call vundle#end()&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;' COLOR SCHEME SETTINGS '&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;        &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;syntax on&#xA;colorscheme skittles_autumn&#xA;&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;' PYTHON SETTINGS '&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;            &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;let python_highlight_all=1&#xA;syntax on&#xA;&#xA;&quot;Run python script with F7&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F7&amp;gt; :exec '!python' shellescape(@%, 1)&amp;lt;cr&amp;gt;&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;' KEY BINDINGS VANILLA VIM '&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;            &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot;split screen navigations&#xA;nnoremap &amp;lt;C-J&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-J&amp;gt;&#xA;nnoremap &amp;lt;C-K&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-K&amp;gt;&#xA;nnoremap &amp;lt;C-L&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-L&amp;gt;&#xA;nnoremap &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-H&amp;gt;&#xA;inoremap jj &amp;lt;ESC&amp;gt;&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;' SETTINGS VANILLA VIM '&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;            &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;set number&#xA;set undofile&#xA;let mapleader=&quot; &quot;&#xA;&#xA;&quot; Set tabs to 4 spaces and stuff&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;set softtabstop=4&#xA;set expandtab&#xA;&#xA;set wrap&#xA;set textwidth=79&#xA;set formatoptions=qrn1&#xA;set colorcolumn=79&#xA;&#xA;set list&#xA;&quot;Use the same symbols as TextMate for tabstops and EOLs&#xA;set listchars=tab:▸\ ,eol:¬&#xA;&#xA;&quot; Disable arrow keys&#xA;nnoremap &amp;lt;up&amp;gt; &amp;lt;nop&amp;gt;&#xA;nnoremap &amp;lt;down&amp;gt; &amp;lt;nop&amp;gt;&#xA;nnoremap &amp;lt;left&amp;gt; &amp;lt;nop&amp;gt;&#xA;nnoremap &amp;lt;right&amp;gt; &amp;lt;nop&amp;gt;&#xA;inoremap &amp;lt;up&amp;gt; &amp;lt;nop&amp;gt;&#xA;inoremap &amp;lt;down&amp;gt; &amp;lt;nop&amp;gt;&#xA;inoremap &amp;lt;left&amp;gt; &amp;lt;nop&amp;gt;&#xA;inoremap &amp;lt;right&amp;gt; &amp;lt;nop&amp;gt;&#xA;&#xA;&quot; j,k move by screen line instead of file line&#xA;nnoremap j gj&#xA;nnoremap k gk&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;F3&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;Show hidden files in NerdTree&#xA;let NERDTreeShowHidden=1&#xA;&#xA;&quot; Open up current file in web browsers&#xA;nnoremap &amp;lt;C-g&amp;gt; :!google-chrome %&amp;lt;CR&amp;gt; &quot; browser preview with ctrl-p&#xA;nnoremap &amp;lt;C-f&amp;gt; :!firefox %&amp;lt;CR&amp;gt; &quot; browser preview with ctrl-o&#xA;nnoremap &amp;lt;C-c&amp;gt; :!chromium-browser %&amp;lt;CR&amp;gt; &quot; browser preview with ctrl-c&#xA;&#xA;&quot; Go to tab by number&#xA;noremap &amp;lt;leader&amp;gt;1 1gt&#xA;noremap &amp;lt;leader&amp;gt;2 2gt&#xA;noremap &amp;lt;leader&amp;gt;3 3gt&#xA;noremap &amp;lt;leader&amp;gt;4 4gt&#xA;noremap &amp;lt;leader&amp;gt;5 5gt&#xA;noremap &amp;lt;leader&amp;gt;6 6gt&#xA;noremap &amp;lt;leader&amp;gt;7 7gt&#xA;noremap &amp;lt;leader&amp;gt;8 8gt&#xA;noremap &amp;lt;leader&amp;gt;9 9gt&#xA;noremap &amp;lt;leader&amp;gt;0 :tablast&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10879" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-01-20T07:54:37.120" Title="Mapping to execute python file only works on first buffer" Tags="|key-bindings|filetype-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11042" PostTypeId="1" AcceptedAnswerId="11047" CreationDate="2017-01-19T04:01:21.933" Score="2" ViewCount="338" Body="&lt;p&gt;My problem is to search all expressions in a file containing: (Scenario in converting from fortran to C)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arr1 = Arr2[4:10]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and replace with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(i = 0 ;i &amp;lt; 6; i++) Arr1[ i ] = Arr2[ i+3 ]&#xA;&#xA;//comment i + 3 because i + &quot;4-1&quot;. i&amp;lt; 6 because 6 = &quot;10 - 4&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried this in vi but this is not working:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/(\&amp;lt;\w+&amp;gt;)\s+=\s+(\&amp;lt;\w+&amp;gt;)[([0-9]):([0-9])]/\='for(i=0;i&amp;lt;'.(submatch(4) - submatch(3)).' ;i++) \1[i] = \2[i+'.(submatc h(3) - 1).']'/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Kindly help. The names of arrays used in file are not same. The array indices are not same for all arrays too. Hope the question is clear. I tried using &lt;code&gt;\=&lt;/code&gt; and &lt;code&gt;submatch()&lt;/code&gt; as in another answer but, that is not allowing separate strings containing arithmetic evaluation expressions to be concatenated. I am missing something.&lt;/p&gt;&#xA;" OwnerUserId="10903" LastEditorUserId="1841" LastEditDate="2017-01-19T12:12:52.250" LastActivityDate="2017-01-19T14:04:56.713" Title="Replace pattern containing more than one arithmetic expressions" Tags="|vimrc|regular-expression|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11043" PostTypeId="1" AcceptedAnswerId="11044" CreationDate="2017-01-19T05:25:02.577" Score="11" ViewCount="2799" Body="&lt;p&gt;For example, easy clip has this mapping when you run &lt;code&gt;smap k&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s  k     * &amp;lt;C-o&amp;gt;&quot;_ck&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The asterisk and &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; are highlighted.&lt;/p&gt;&#xA;" OwnerUserId="10905" LastEditorUserId="2920" LastEditDate="2017-01-19T07:01:53.360" LastActivityDate="2017-01-19T09:59:40.890" Title="What does asterisk mean in vim mappings?" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11044" PostTypeId="2" ParentId="11043" CreationDate="2017-01-19T09:59:40.890" Score="11" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#map-listing&quot;&gt;&lt;code&gt;:h map-listing&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When listing mappings the characters in the first two columns are:&#xA;&#xA;      CHAR      MODE    &#xA;     &amp;lt;Space&amp;gt;    Normal, Visual, Select and Operator-pending&#xA;        n       Normal&#xA;        v       Visual and Select&#xA;        s       Select&#xA;        x       Visual&#xA;        o       Operator-pending&#xA;        !       Insert and Command-line&#xA;        i       Insert&#xA;        l       &quot;:lmap&quot; mappings for Insert, Command-line and Lang-Arg&#xA;        c       Command-line&#xA;&#xA;Just before the {rhs} a special character can appear:&#xA;        *       indicates that it is not remappable&#xA;        &amp;amp;       indicates that only script-local mappings are remappable&#xA;        @       indicates a buffer-local mapping&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So they were created using &lt;code&gt;?noremap&lt;/code&gt; commands.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-01-19T09:59:40.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11046" PostTypeId="2" ParentId="11040" CreationDate="2017-01-19T12:26:30.467" Score="3" Body="&lt;p&gt;Your mapping use &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; which means that it creates a mapping which is local to a buffer (and thus doesn't exists in other buffers). As the command is in your vimrc the mapping only exists on the first opened buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to solve your problem you have two solutions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first one is to remove &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; this way the mapping will work on all buffers. The problem with this method is that the mapping will be available also for non python buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second solution is to use an autocommand to create the mapping on all python buffers like this &lt;em&gt;(Actually that's what @Kent suggested on the answer of the question you linked)&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! FileType python nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F7&amp;gt; :exec '!python' shellescape(@%, 1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might want to read the following help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap%2D%3Cbuffer%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :map-&amp;lt;buffer&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocommand&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h autocommand&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#FileType&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h FileType&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; AS @Octaviour pointed it out in the comment there is a better alternative to the autocommand: using the ftplugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The filetype plugins are files which are sourced when the filetype of a buffer is set. Here the ftplugin to modify would be the file &lt;code&gt;~/.vim/ftplugin/python.vim&lt;/code&gt;. One would simply need to add the line to this file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F7&amp;gt; :exec '!python' shellescape(@%, 1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For reference see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_41.html#ftplugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ftplugin&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-01-20T07:54:37.120" LastActivityDate="2017-01-20T07:54:37.120" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11047" PostTypeId="2" ParentId="11042" CreationDate="2017-01-19T14:04:56.713" Score="2" Body="&lt;p&gt;I'm not sure this is what you want, but you could try this substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v(&amp;lt;\w+&amp;gt;)\s+\=\s+(&amp;lt;\w+&amp;gt;)\[(\d+):(\d+)\]/\='for(i=0;i&amp;lt;'.(submatch(4) - submatch(3)).' ;i++) '.submatch(1).'[i] = '.submatch(2).'[i+'.(submatch(3) - 1).']'/gc&#xA;      |              |        |     |         |            |                                    |            |   |   |            |                          |&#xA;      |              |        |     |         |            |                                    |            |   |   |            |                          +-- flags&#xA;      |              |        |     |         |            |                                    |            |   |   |            +-- index of the second array item&#xA;      |              |        |     |         |            |                                    |            |   |   +-- name of the second array&#xA;      |              |        |     |         |            |                                    |            |   +-- assignment 1st array item = 2nd array item&#xA;      |              |        |     |         |            |                                    |            +-- index of the first array item&#xA;      |              |        |     |         |            |                                    +-- name of the first array&#xA;      |              |        |     |         |            +-- upper limit of the for loop&#xA;      |              |        |     |         +-- beginning of the replacement (for loop)&#xA;      |              |        |     +-- capture the number 10 inside `Arr2[4:10]`&#xA;      |              |        +-- capture the number 4 inside `Arr2[4:10]`&#xA;      |              +-- capture the name of the 2nd array&#xA;      +-- capture the name of the 1st array&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2017-01-19T14:04:56.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11048" PostTypeId="2" ParentId="7378" CreationDate="2017-01-19T14:55:00.093" Score="3" Body="&lt;p&gt;Alternatively use &lt;a href=&quot;https://github.com/kbarrette/mediummode&quot; rel=&quot;nofollow noreferrer&quot;&gt;Medium Mode&lt;/a&gt; which still tries to learn you &quot;right moves&quot;, but is less strict in doing that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Medium mode is a Vim plugin that limits character-wise motions, but&#xA;  does not disable them completely. By default, medium mode will only&#xA;  allow two consecutive character-wise motions.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10893" LastActivityDate="2017-01-19T14:55:00.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11049" PostTypeId="1" CreationDate="2017-01-19T17:47:27.200" Score="0" ViewCount="2013" Body="&lt;p&gt;I was wondering if someone could assist me in installing a color scheme for VIM? I literally have spent all day yesterday and this morning trying to figure it out. I am using a shell-client (ubuntu) to access my school's unix server. I have a very general idea of how to work in a shell but it is still new to me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will post a link to what I am trying to install and thank you in advance for your assistance:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/whatyouhide/vim-gotham&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/whatyouhide/vim-gotham&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10918" LastEditorUserId="1841" LastEditDate="2017-01-20T09:00:18.567" LastActivityDate="2017-01-20T09:00:18.567" Title="How to install a colorscheme with a plugin manager" Tags="|plugin-system|installing|" AnswerCount="1" CommentCount="2" ClosedDate="2017-01-23T15:36:20.430" ContentLicense="CC BY-SA 3.0" />
  <row Id="11050" PostTypeId="2" ParentId="11049" CreationDate="2017-01-19T19:24:20.720" Score="1" Body="&lt;p&gt;Colors are easy to customize in VIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Download your file into the folder in the vim hierarchy &lt;code&gt;colors&lt;/code&gt;&#xA;as (using your example)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim-gotham.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add an entry in your vimrc or gvimrc file similar to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIM\vimfiles\colors\vim-gotham.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I placed the source command as the last entry in mine.&lt;/p&gt;&#xA;" OwnerUserId="10509" LastEditorUserId="1821" LastEditDate="2017-01-19T21:36:45.973" LastActivityDate="2017-01-19T21:36:45.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11051" PostTypeId="2" ParentId="11029" CreationDate="2017-01-19T20:51:26.793" Score="3" Body="&lt;p&gt;Sed stands for stream editor and it can execute regexes over files, line by line. A sed script would probably serve you better than trying to do something in vi, if vim is not an option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just put your regex lines (without the :% which is specific to vi) in a file, call it myscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\n\n/\r&#xA;s/other/example&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then run that file as a sed script over your target files like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sed -n -f myscript myfiles/*.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Statox's answer works better if you can use vim. If you're stuck with vi then try this.&lt;/p&gt;&#xA;" OwnerUserId="10168" LastEditorUserId="10168" LastEditDate="2017-01-23T16:38:40.030" LastActivityDate="2017-01-23T16:38:40.030" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11052" PostTypeId="1" AcceptedAnswerId="11053" CreationDate="2017-01-19T22:08:02.260" Score="3" ViewCount="389" Body="&lt;p&gt;Given a dictionary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:dict = {&#xA;    \ 'FOO/BAR': 'BAZ',&#xA;    \ 'FIZZ': 'BUZZ'&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim is fine with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo g:dict.FIZZ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But chokes on this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo g:dict.FOO/BAR&#xA;&#xA;E716: Key not present in Dictionary: HCL/HCL_0127&#xA;E15: Invalid expression: g:dict.FOO/BAR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also tried escaping the forward slash as &lt;code&gt;\/&lt;/code&gt;, which doesn't work. However, it has no problem with &lt;code&gt;g:dict['FOO/BAR']&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to access these entries using the dot syntax? Are there other characters I have to watch out for?&lt;/p&gt;&#xA;" OwnerUserId="6883" LastActivityDate="2017-01-20T14:39:07.467" Title="Dictionary keys with non-alphanumeric characters" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11053" PostTypeId="2" ParentId="11052" CreationDate="2017-01-20T14:39:07.467" Score="3" Body="&lt;p&gt;You cannot use the dot form in your case because your key has something other than a letter, number, underscore:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help dict&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Accessing entries&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The normal way to access an entry is by putting the key in square&#xA;  brackets:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;:let val = mydict[&quot;one&quot;]&lt;/code&gt;&lt;br&gt;&#xA;  &lt;code&gt;:let mydict[&quot;four&quot;] = 4&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You can add new entries to an existing Dictionary this way, unlike&#xA;  Lists.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;For keys that consist entirely of &lt;em&gt;letters, digits and underscore&lt;/em&gt; the following&#xA;  form can be used |expr-entry|:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;:let val = mydict.one&lt;/code&gt;&lt;br&gt;&#xA;  &lt;code&gt;:let mydict.four = 4&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10155" LastActivityDate="2017-01-20T14:39:07.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11054" PostTypeId="1" AcceptedAnswerId="11055" CreationDate="2017-01-20T15:21:25.033" Score="4" ViewCount="270" Body="&lt;p&gt;How can I make Neovim automatically return to the tabpage that was active before running &lt;code&gt;:Git diff %&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before I commit my work in git, I often run &lt;code&gt;:Git diff&lt;/code&gt; to review changes (the &lt;code&gt;:Git&lt;/code&gt; command is supplied by &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot;&gt;fugitive&lt;/a&gt;). The &lt;code&gt;:Git diff&lt;/code&gt; command runs in a new instance of Neovim's terminal, which seems to open in a new tabpage of its own. I press &lt;code&gt;q&lt;/code&gt; to abort the process, and the new tabpage disappears. Neovim then activates the &lt;em&gt;next available tabpage&lt;/em&gt;, instead of returning to the tabpage that was active before I ran &lt;code&gt;:Git diff&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, suppose that I've got Neovim running with three tabpages. If I run &lt;code&gt;1gt&lt;/code&gt; to activate the first tabpage, then after running &lt;code&gt;:Git diff&lt;/code&gt; I'll finish up on the second tabpage (I'll then press &lt;code&gt;gT&lt;/code&gt; to go back to the tab I was working on). If I run &lt;code&gt;2gt&lt;/code&gt; to activate the second tabpage, then after running &lt;code&gt;:Git diff&lt;/code&gt; I'll finish up on the third tabpage (again, &lt;code&gt;gT&lt;/code&gt; gets me back to where I was). If I run &lt;code&gt;3gt&lt;/code&gt;, then I can run &lt;code&gt;:Git diff&lt;/code&gt; and remain on the third tabpage, because it's the last one that's open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to run &lt;code&gt;1gt&lt;/code&gt;, then &lt;code&gt;:Git diff&lt;/code&gt;, and to be automatically returned to the first tabpage when the terminal process exits. How can I make that happen?&lt;/p&gt;&#xA;" OwnerUserId="10929" LastActivityDate="2017-01-20T21:25:56.330" Title="How can I make Neovim return to the tab that was active before running `:Git diff`?" Tags="|neovim|tabbed-user-interface|plugin-fugitive|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11055" PostTypeId="2" ParentId="11054" CreationDate="2017-01-20T15:53:39.523" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-fugitive/commit/bdd216827ae53cdf70d933bb30762da9bf42cad4&quot; rel=&quot;nofollow noreferrer&quot;&gt;This patch&lt;/a&gt; on fugitive fixes this issue (and here's &lt;a href=&quot;https://github.com/tpope/vim-fugitive/pull/784&quot; rel=&quot;nofollow noreferrer&quot;&gt;the PR&lt;/a&gt;). It looks like I was running an old version of fugitive. Upgrading to the latest fugitive fixed this issue for me.&lt;/p&gt;&#xA;" OwnerUserId="10929" LastEditorUserId="10929" LastEditDate="2017-01-20T21:25:56.330" LastActivityDate="2017-01-20T21:25:56.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11056" PostTypeId="1" AcceptedAnswerId="11169" CreationDate="2017-01-20T20:18:24.600" Score="7" ViewCount="2518" Body="&lt;p&gt;I am using vim to view XML files created by a Windows app.  It is probably a malformed XML file because vim thinks it's opening a Unix file format.  So I end up seeing &lt;code&gt;^M&lt;/code&gt; at the end of almost every line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to mess with the file, as vim is the only viewer.  It is going to be used by other apps, and in fact, may even be in the middle of being written to.  I just want vim to interpret &lt;code&gt;&amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;&lt;/code&gt; as a Unix carriage return.  In case it matters, I typically open files with either&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :e path/to/file&#xA; :split path/to/file&#xA; :vsplit path/to/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or I might use the netrw plugin.  I am using vim 7.4, patches 1-729, built for Cygwin.  It is not easy to upgrade in my environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. Sorry if the tag is not quite.  The posting web page suggested original-vim, but that tag doesn't seem to exist.  No other tags in the suggestion list seemed any more appropriate.  I am open to suggestions as to a better tag.&lt;/p&gt;&#xA;" OwnerUserId="7970" LastEditorUserId="51" LastEditDate="2017-01-21T16:16:09.130" LastActivityDate="2020-12-02T16:29:45.797" Title="How to force vim to interpret file as dos-format" Tags="|gvim|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11057" PostTypeId="1" CreationDate="2017-01-20T21:13:13.597" Score="2" ViewCount="347" Body="&lt;p&gt;I have a setting &lt;a href=&quot;https://vi.stackexchange.com/questions/10711/how-do-i-get-consistent-behavior-with-matchadd-color-column/10712#10712&quot;&gt;(namely highlight the 81st character on the line)&lt;/a&gt; that I would like to turn off when there is a diff. This is easy enough as a search through the autocmds results in:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;|FilterWritePre|  starting to write a file for a filter command or diff&lt;/p&gt;&#xA;&lt;p&gt;|FilterWritePost| after writing a file for a filter command or diff&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So I end up with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Highlight the 81st character on the line if it's not the quickfix.&#xA;autocmd BufReadPost * if (&amp;amp;filetype != 'qf') |&#xA;                    \    let b:ColorColumnID = matchadd('ColorColumn', '\%81v.') |&#xA;                    \ endif&#xA;&#xA;&amp;quot; When diffing take out the coloring because it looks like diff highlighting.&#xA;autocmd FilterWritePost * if (&amp;amp;diff &amp;amp;&amp;amp; exists('b:ColorColumnID')) |&#xA;                        \    call matchdelete(b:ColorColumnID) |&#xA;                        \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, I would also like to turn the setting back on when I leave diff mode. As far as I can tell, there's no autocmd to detect this, and I can't think of any other robust ways to do it. Obviously I could check &lt;code&gt;&amp;amp;diff&lt;/code&gt; on every cursor move or something like that, but I'm hoping for something a little less hacky. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-01-20T21:13:13.597" Title="How to execute a function when a diff closes" Tags="|autocmd|vimdiff|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11058" PostTypeId="1" AcceptedAnswerId="11059" CreationDate="2017-01-21T02:55:01.053" Score="8" ViewCount="10496" Body="&lt;p&gt;I have recently upgraded to Vim 8 using Homebrew, but my &lt;code&gt;vi&lt;/code&gt; commands still load the OS-provided version 7.4 of Vim. I could add an alias to &lt;code&gt;vi&lt;/code&gt;, but is there another way?&lt;/p&gt;&#xA;" OwnerUserId="10836" LastEditorUserId="6852" LastEditDate="2017-07-23T07:19:23.337" LastActivityDate="2020-06-03T11:29:35.343" Title="How do I run Homebrew vi on macOS instead of the older version Apple provided?" Tags="|command-line|macos|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11059" PostTypeId="2" ParentId="11058" CreationDate="2017-01-21T05:39:10.207" Score="16" Body="&lt;p&gt;This is happening because the OS's &lt;code&gt;vi&lt;/code&gt; is ahead of Homebrew &lt;code&gt;vi&lt;/code&gt; in the &lt;code&gt;PATH&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While you could fix it by putting &lt;code&gt;/usr/local/bin&lt;/code&gt; ahead of &lt;code&gt;/usr/bin&lt;/code&gt; in the &lt;code&gt;PATH&lt;/code&gt;, that would be a security hole since Homebrew gives ownership of that directory to your user. That permission change from the macOS default means that even an extremely unsophisticated malware could use this hole to get root privileges. All they'd have to do is add some other common command here like &lt;code&gt;ls&lt;/code&gt;, then pass the commands through to &lt;code&gt;/bin/ls&lt;/code&gt; until they see you've run it through &lt;code&gt;sudo&lt;/code&gt;, then they take over.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a general principle, not specific to Vi, Macs, or Homebrew at all: never place user-writeable &lt;code&gt;PATH&lt;/code&gt; elements ahead of those that can only be modified by &lt;code&gt;root&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several ways to solve this problem:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Replace the OS's &lt;code&gt;vi&lt;/code&gt; and &lt;code&gt;vim&lt;/code&gt; binaries with symlinks to the Homebrew versions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd /bin&#xA;$ sudo mv vi vi-7.4&#xA;$ sudo ln -s /usr/local/bin/vi .&#xA;$ cd /usr/bin&#xA;$ sudo mv vim vim-7.4&#xA;$ sudo ln -s /usr/local/bin/vim .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do not recommend this solution, but it is what the original version of the question asked for, so there it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that this doesn't delete the OS-provided versions, just renames them so you still have access to them by appending &lt;code&gt;-7.4&lt;/code&gt; if you need to later.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Since all three of the directories in the prior solution are in the default user &lt;code&gt;PATH&lt;/code&gt; on macOS, you don't actually need the symlinks unless you have local software that has hardcoded &lt;code&gt;/bin&lt;/code&gt; or &lt;code&gt;/usr/bin&lt;/code&gt; paths to &lt;code&gt;vi&lt;/code&gt; or &lt;code&gt;vim&lt;/code&gt;. Just move the system versions shadowing Homebrew's versions out of the way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sudo mv /bin/vi /bin/vi-7.4&#xA;$ sudo mv /usr/bin/vim /usr/bin/vim-7.4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That causes &lt;code&gt;vi&lt;/code&gt; and &lt;code&gt;vim&lt;/code&gt; commands to fall through to the Homebrew versions in &lt;code&gt;/usr/local/bin&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Both solutions above will break the next time you upgrade macOS because the OS installer will put the Apple-provided versions back in &lt;code&gt;/bin&lt;/code&gt; and &lt;code&gt;/usr/bin&lt;/code&gt;, so the solution I actually recommend is to add aliases to your &lt;code&gt;~/.bashrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vi=/usr/local/bin/vim&#xA;alias vim=/usr/local/bin/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This lets you switch back to the OS-provided version of Vim easily by quoting the alias:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ 'vi' somefile.txt         # forces use of /bin/vi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might also want to add this to &lt;code&gt;~/.bash_profile&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export EDITOR=/usr/local/bin/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Several commands use &lt;code&gt;$EDITOR&lt;/code&gt; instead of hard-coding a call to &lt;code&gt;vi&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another option you have is to remove the Homebrew build of Vim and install &lt;a href=&quot;https://macvim-dev.github.io/macvim/&quot; rel=&quot;noreferrer&quot;&gt;MacVim&lt;/a&gt; instead. It also installs to &lt;code&gt;/usr/local/bin&lt;/code&gt;, but unlike Homebrew Vim, it installs a command that isn't shadowed by the OS version, &lt;code&gt;mvim&lt;/code&gt;. By default, that command launches the GUI MacVim editor, but with this alias, you can have your &lt;code&gt;vi&lt;/code&gt; and your Terminal editor, too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vi='mvim -v'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-v&lt;/code&gt; flag tells it not to launch the GUI, but to edit in the Terminal instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you choose this option, make a similar change to the &lt;code&gt;EDITOR&lt;/code&gt; definition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Among the many nice features you get with MacVim is integration with the OS clipboard: pasting from the OS clipboard into Terminal.app running stock or Homebrew Vim you already have, but I find it nice to go the other direction as well: &quot;yank&quot; commands in &lt;code&gt;mvim -v&lt;/code&gt; under Terminal.app also sends the yanked text to the OS clipboard so I can paste it into some other program.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6852" LastEditorUserId="6852" LastEditDate="2017-10-26T23:26:54.147" LastActivityDate="2017-10-26T23:26:54.147" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11060" PostTypeId="2" ParentId="10996" CreationDate="2017-01-21T09:02:43.643" Score="0" Body="&lt;p&gt;Thanks to @SibiCoder's hints, I now know where the problem is. After changing the directories name under my &lt;code&gt;~/.vim&lt;/code&gt; directory, I finally tracked down to which &lt;code&gt;plugin&lt;/code&gt; directory is doing the job, which is in the &lt;code&gt;after/plugin&lt;/code&gt; directory in which the &lt;code&gt;snipMate.vim&lt;/code&gt; has mapped &lt;kbd&gt;Tab&lt;/kbd&gt; in a quite strange way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ino &amp;lt;silent&amp;gt; &amp;lt;tab&amp;gt; &amp;lt;c-r&amp;gt;=TriggerSnippet()&amp;lt;cr&amp;gt;&#xA;snor &amp;lt;silent&amp;gt; &amp;lt;tab&amp;gt; &amp;lt;esc&amp;gt;i&amp;lt;right&amp;gt;&amp;lt;c-r&amp;gt;=TriggerSnippet()&amp;lt;cr&amp;gt;&#xA;ino &amp;lt;silent&amp;gt; &amp;lt;s-tab&amp;gt; &amp;lt;c-r&amp;gt;=BackwardsSnippet()&amp;lt;cr&amp;gt;&#xA;snor &amp;lt;silent&amp;gt; &amp;lt;s-tab&amp;gt; &amp;lt;esc&amp;gt;i&amp;lt;right&amp;gt;&amp;lt;c-r&amp;gt;=BackwardsSnippet()&amp;lt;cr&amp;gt;&#xA;ino &amp;lt;silent&amp;gt; &amp;lt;c-r&amp;gt;&amp;lt;tab&amp;gt; &amp;lt;c-r&amp;gt;=ShowAvailableSnips()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But anyway, the ultimate solution to this kind of problem is just to look one by one and experiment the problem, which in my case is &lt;kbd&gt;Tab&lt;/kbd&gt;, to find the problem. My method to check is to change the directories name one by one, for example append a &lt;code&gt;_&lt;/code&gt; to it and delete it. Hope this can help others.&lt;/p&gt;&#xA;" OwnerUserId="6380" LastActivityDate="2017-01-21T09:02:43.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11061" PostTypeId="1" CreationDate="2017-01-21T13:44:01.863" Score="0" ViewCount="2505" Body="&lt;p&gt;Installing plugins through vim-plug involves putting the following code inside the vimrc file.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'user/repository'&#xA;&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I install a lot of plugins, and I don't want to put all the code inside the main configuration file. I'd instead like to source it from a separate file dedicated to plugins.&lt;/p&gt;&#xA;&lt;p&gt;I name that file as &lt;code&gt;Plugins.vim&lt;/code&gt; and source it inside the main &lt;code&gt;vimrc&lt;/code&gt; file putting the following in the first line.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;source $HOME/.vim/Plugins.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Unfortunately, the plugins don't get loaded, and even though Vim reads the file, it outputs error messages relating to that line where it is being asked to source.&lt;/p&gt;&#xA;&lt;p&gt;I tried to fix it by changing the path and file permissions but with no results.&lt;/p&gt;&#xA;&lt;p&gt;Note:&#xA;The vimrc file may be located inside the home directory as &lt;code&gt;.vimrc&lt;/code&gt; or in &lt;code&gt;.vim&lt;/code&gt; directory as &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The error is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;E471: Argument required&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It is either related to &lt;code&gt;source&lt;/code&gt; or the file itself (I set file's permission to &lt;code&gt;777&lt;/code&gt;, but I remember sometimes it did not open the file and issued file is unreadable error as well.)&lt;/p&gt;&#xA;&lt;p&gt;Currently, I am using one file the &lt;code&gt;.vimrc&lt;/code&gt; as sourcing doesn't work for me.&lt;/p&gt;&#xA;" OwnerDisplayName="user10767" LastEditorUserId="21251" LastEditorDisplayName="user10767" LastEditDate="2021-06-09T12:30:53.790" LastActivityDate="2021-07-09T13:00:40.130" Title="Sourcing Vimplug plugins in a separate file" Tags="|vimrc|plugin-system|plugin-vim-plug|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="11062" PostTypeId="2" ParentId="10708" CreationDate="2017-01-22T01:49:48.380" Score="15" Body="&lt;p&gt;Well, I solved the problem by myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as @Carpetsmoker♦ commented, I started to suspect that my &lt;code&gt;.vimrc&lt;/code&gt; is a problem. I read &lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;this question&lt;/a&gt; and started vim with this command inside tmux.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After starting vim with command above, I ran this command inside vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn on&#xA;:colorscheme solarized8_dark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These highlighted my &lt;code&gt;.vimrc&lt;/code&gt; file. So, I started to debug my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long story short, &lt;code&gt;set termguicolors&lt;/code&gt; was the problem. If I ran vim with &lt;code&gt;set termguicolors&lt;/code&gt; commented in &lt;code&gt;.vimrc&lt;/code&gt;, I could see corrected syntax highlighting in tmux.&lt;/p&gt;&#xA;" OwnerUserId="10072" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-01-22T01:49:48.380" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11064" PostTypeId="1" AcceptedAnswerId="11065" CreationDate="2017-01-22T02:28:32.950" Score="2" ViewCount="266" Body="&lt;p&gt;I search some words so that there are many highlight results in the current window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;n&lt;/code&gt; to move cursor to a matching result, how to know its index of match results easily？&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried &lt;a href=&quot;https://github.com/vim-scripts/SearchPosition&quot; rel=&quot;nofollow noreferrer&quot;&gt;SearchPosition&lt;/a&gt;, but it does not work in my Vim.&lt;/p&gt;&#xA;" OwnerUserId="5663" LastEditorUserId="5663" LastEditDate="2017-01-22T03:11:16.283" LastActivityDate="2017-01-22T03:11:16.283" Title="How to show the index of the current match?" Tags="|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11065" PostTypeId="2" ParentId="11064" CreationDate="2017-01-22T02:46:06.627" Score="2" Body="&lt;p&gt;I don't know if it's exactly what you want, but to get the number of matches and the index of the current match, I'm using a modified version of this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno n n@=Search_and_index()&amp;lt;CR&amp;gt;&#xA;nno N N@=Search_and_index()&amp;lt;CR&amp;gt;&#xA;&#xA;fu! Search_and_index() abort&#xA;    let winview     = winsaveview()&#xA;    let [line, col] = [winview.lnum, winview.col]&#xA;&#xA;    call cursor(1, 1)&#xA;    let [idx, total]          = [1, 0]&#xA;    let [matchline, matchcol] = searchpos(@/, 'cW')&#xA;    while matchline &amp;amp;&amp;amp; total &amp;lt;= 999&#xA;        let total += 1&#xA;        if matchline &amp;lt; line || (matchline == line &amp;amp;&amp;amp; matchcol &amp;lt;= col)&#xA;            let idx += 1&#xA;        endif&#xA;        let [matchline, matchcol] = searchpos(@/, 'W')&#xA;    endwhile&#xA;&#xA;    call winrestview(winview)&#xA;    echo @/ . '(' . idx . '/' . total . ')'&#xA;    return ''&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It remaps &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; to call the function &lt;code&gt;Search_and_index()&lt;/code&gt; which should echo a message such as &lt;code&gt;pattern(3/4)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The while loop is responsible for incrementing the variables &lt;code&gt;total&lt;/code&gt; and &lt;code&gt;idx&lt;/code&gt;. And at the end of the loop, their values should be respectively the total number of matches of your last search pattern, and the index of the current match (the one under the cursor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the loop stops at &lt;code&gt;999&lt;/code&gt; to avoid taking too much time. You could increase this number if you feel it's too low. &lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-01-22T02:54:59.713" LastActivityDate="2017-01-22T02:54:59.713" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11066" PostTypeId="1" AcceptedAnswerId="11079" CreationDate="2017-01-22T12:36:24.913" Score="2" ViewCount="344" Body="&lt;p&gt;I've done some searching with various keywords, but unsuccessfully. Sorry for my English, I'm not a native speaker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm new to VIM and to Python, and I'm learning both on the go as much as I can, but sometimes I hit a brick wall and land here. Though SE already answered most of my questions, hence this is my first one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I'm not sure if it's even possible (why am I the only junior Python programmer searching/asking for that?), I'd like to know for sure without learning the whole scripting language beforehand and discovering it's not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To the point:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I'm writing a new class in Python I have to write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class TestClass(object):&#xA;    def __init__(self, arg1, ..., argn, namedarg1 = defaultvalue, namedarg2 = &quot;default string value&quot;, namedarg3, ... namedargn):&#xA;    self.arg1 = arg1&#xA;    ...        &#xA;    self.argn = argn&#xA;    self.namedarg1 = namedarg1&#xA;    self.namedarg2 = namedarg2&#xA;    self.namedarg3 = namedarg3&#xA;    ...&#xA;    self.namedargn = namedargn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... which seems a terrible waste of time, especially once I've heard about vim macros, snippets, autocorrect, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What would be the best way to automate change from, let's say, this:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Testclass(arg1, ..., argn, namedarg1 = defaultvalue, namedarg2 = &quot;default string value&quot;, namedarg3, ... namedargn)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;to the first example I showed?&lt;/strong&gt; How would it work (i.e. &lt;em&gt;how do I use it&lt;/em&gt;; bonus points for explaining how would the macro/script/snippet work)?&lt;/p&gt;&#xA;" OwnerUserId="10952" LastEditorUserId="1841" LastEditDate="2017-01-23T07:41:54.150" LastActivityDate="2017-01-23T15:49:18.027" Title="How to automate populating Python's class constructor?" Tags="|macro|vimscript-python|text-generation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11067" PostTypeId="2" ParentId="10965" CreationDate="2017-01-23T02:18:02.067" Score="0" Body="&lt;p&gt;The &lt;code&gt;onoremap&lt;/code&gt; suggested by Ingo works, but, ultimately what I wanted was to create a custom text object. The downside to the &lt;code&gt;onoremap&lt;/code&gt; is that I can't use it for visual selection.  I ended up installing a custom text object plugin called &lt;a href=&quot;https://github.com/Chun-Yang/vim-textobj-chunk&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-chunk&lt;/a&gt; for this and really happy with it.&lt;/p&gt;&#xA;" OwnerUserId="10836" LastEditorUserId="10836" LastEditDate="2021-11-16T21:46:21.513" LastActivityDate="2021-11-16T21:46:21.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11068" PostTypeId="1" CreationDate="2017-01-23T04:13:10.480" Score="0" ViewCount="585" Body="&lt;p&gt;To make functions local, you prefix it with 's:'. But then it can't be called with mappings. Given this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ScriptFunction()&#xA;  ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What convention or keywords do I add to precent name conflicts while still allowing the user to add a mapping?&lt;/p&gt;&#xA;" OwnerUserId="10905" LastActivityDate="2017-01-23T07:27:39.063" Title="How to make vim functions local to script but callable by mapping?" Tags="|key-bindings|vimscript|functions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11069" PostTypeId="2" ParentId="11068" CreationDate="2017-01-23T06:30:38.187" Score="0" Body="&lt;p&gt;One way is to make a command. I did that in my plugin like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;command! -buffer -nargs=0 PikeDocOpen :call pikedoc#open()&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use a prefix for the function name (i.e. your plugin name):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FOO_ScriptFunction()&#xA;    ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I think that in both cases prefix is a way to go.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-01-23T06:30:38.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11070" PostTypeId="2" ParentId="11068" CreationDate="2017-01-23T07:27:39.063" Score="1" Body="&lt;p&gt;In mappings, script-local functions are called with &lt;code&gt;&amp;lt;sid&amp;gt;&lt;/code&gt; instead of &lt;code&gt;s:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But as indirectly suggested in the other answer, you'd better have the mapping in a plugin and the function in an autoload plugin. It's much better for starting times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, There is an extensive documentation in 2 parts about mappings on vim.wikia.com&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-01-23T07:27:39.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11071" PostTypeId="1" CreationDate="2017-01-23T07:59:37.823" Score="2" ViewCount="985" Body="&lt;p&gt;I've disabled pair completion because it doesn't really save any key presses. I have to press right arrow to get out of a quote after completing the string. Am I missing something here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have to enter &lt;code&gt;func(&quot;hello&quot;)&lt;/code&gt;, after some typing I will get &lt;code&gt;func(&quot;hello|&quot;)&lt;/code&gt; with cursor at |, and I will have to press at least two more keys(esc-o/A) to get out of declaration and continue editing, which could very well be used to enters &lt;code&gt;&quot;&lt;/code&gt; and a &lt;code&gt;)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10265" LastEditorUserId="10265" LastEditDate="2017-01-23T12:18:33.750" LastActivityDate="2017-01-24T09:49:51.660" Title="What's the correct way to use pair completion?" Tags="|autocompletion|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11072" PostTypeId="1" AcceptedAnswerId="11073" CreationDate="2017-01-23T08:31:32.513" Score="11" ViewCount="2462" Body="&lt;p&gt;The question in short: &lt;strong&gt;Is it possible to open a tab in a window and not a window in a tab?&lt;/strong&gt;. Like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Mdyai.png&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Mdyai.png&quot; alt=&quot;vim the tabs in the windows&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E4lNv.png&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E4lNv.png&quot; alt=&quot;vim the windows in the tabs, the windows visible&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/xOkcF.png&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xOkcF.png&quot; alt=&quot;vim the windows in the tabs, the windows hidden&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Some background related to the question:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm used to the interface like the one on the first screen shot above, where the tabs are in the windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially I was able to achieve this in Vim with the help of a console app's functionality, because I was very new to Vim and didn't want to remember even more commands to work with windows. But this approach has some inconveniences to me:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;no sharing of registers&lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;.viminfo&lt;/code&gt; file is opened separately for each instance of vim, and therefore some important information can be lost, if the instance of vim, where it was present was closed first (because each instance of the editor overwrites the &lt;code&gt;.viminfo&lt;/code&gt; file).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've managed some workarounds for each of these problems, listed below in case anyone other will face this issue:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;for the sharing of registers between windows of a terminal, I installed the &lt;code&gt;xclip&lt;/code&gt; application and copy registers with ex-commands like: &lt;code&gt;call system('xclip', @&quot;)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;for the &lt;code&gt;.viminfo&lt;/code&gt; rewrite issues I just try to pay attention to the order of closing Vim instances.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But the other day I got tired of this, and decided to try the windows in Vim, and the first thing I found was that the tabs are sort of &quot;above&quot; the windows, what I personally do not like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked &lt;a href=&quot;http://vim.wikia.com/wiki/Using_tab_pages&quot;&gt;some Vim docs&lt;/a&gt; about this, and it seems that it is not possible to open a tab in a window. Can anyone answer to this by either explaining how it is possible, or affirming that it is not possible?&lt;/p&gt;&#xA;" OwnerUserId="2798" LastActivityDate="2017-01-23T09:31:04.653" Title="Is it possible to open a tab in a window and not a window in a tab?" Tags="|tabbed-user-interface|window-management|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11073" PostTypeId="2" ParentId="11072" CreationDate="2017-01-23T09:18:54.563" Score="11" Body="&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/tabpage.html#tab-page-intro&quot;&gt;&lt;code&gt;:h tab-page-intro&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A tab page holds one or more windows.  You can easily switch between tab&#xA;  pages, so that you have several collections of windows to work on different&#xA;  things.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Usually you will see a list of labels at the top of the Vim window, one for&#xA;  each tab page.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Tabs containing windows is the way Vim was designed to work. I think you should get used to this workflow because trying to use Vim in a different way will introduce more problems than it solves.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-01-23T09:18:54.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11074" PostTypeId="2" ParentId="11072" CreationDate="2017-01-23T09:19:08.957" Score="7" Body="&lt;p&gt;No you can't, here's why:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim use multiple concepts to handle text files:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Buffer&lt;/strong&gt;: An in-memory version of a file. Editing a file will in fact edit the buffer before writing (i.e. saving) anything to the file on your filesystem.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Window&lt;/strong&gt;: A view into a buffer, a representation of the buffer content. A window can switch buffer and split to display multiple buffer at the same time. You can display the same buffer in different window, but a window can only display one buffer at a time.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tab&lt;/strong&gt;: A collection of windows, and their display on the screen. This is the layout of windows that you currently have.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the Vim world, tabs &lt;strong&gt;contains&lt;/strong&gt; windows, not the other way around.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastEditorUserId="1821" LastEditDate="2017-01-23T09:31:04.653" LastActivityDate="2017-01-23T09:31:04.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11075" PostTypeId="1" AcceptedAnswerId="11077" CreationDate="2017-01-23T12:29:09.167" Score="5" ViewCount="135" Body="&lt;p&gt;Many times I find my self running &lt;code&gt;ciw&lt;/code&gt; or &lt;code&gt;c2W&lt;/code&gt; but with different text. Like &lt;code&gt;ciwnewtext&amp;lt;esc&amp;gt;&lt;/code&gt; and then &lt;code&gt;ciwanothertext&amp;lt;esc&amp;gt;&lt;/code&gt;. The dot command &lt;code&gt;.&lt;/code&gt; will repeat the whole change (it does not allow me to specify the text).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For simple motions like &lt;code&gt;iw&lt;/code&gt; it does not bother my much but sometimes I use more complex motion that I would like to reuse right away. Is there any way to accomplish that?&lt;/p&gt;&#xA;" OwnerUserId="2766" LastActivityDate="2017-01-23T12:55:40.613" Title="Is there a shortcut to reuse the last operator+motion without repeating the whole change?" Tags="|cursor-motions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11076" PostTypeId="2" ParentId="11071" CreationDate="2017-01-23T12:45:23.527" Score="2" Body="&lt;p&gt;If you're using a plugin such as &lt;a href=&quot;https://github.com/Raimondi/delimitMate&quot; rel=&quot;nofollow noreferrer&quot;&gt;delimitMate&lt;/a&gt; or &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;auto-pairs&lt;/a&gt;, they have options that allow you to skip over the closed pair by pressing the closing key.  If you press &lt;code&gt;[&lt;/code&gt;, then you press &lt;code&gt;]&lt;/code&gt;.  &lt;code&gt;(&lt;/code&gt; then &lt;code&gt;)&lt;/code&gt;. &lt;code&gt;&quot;&lt;/code&gt; then &lt;code&gt;&quot;&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, you're still typing the closing character.  The point of using these plugins is that the closing character will be in the &lt;em&gt;right place&lt;/em&gt; when you're done editing.  They also remove the closing pair if you press &lt;code&gt;&amp;lt;bs&amp;gt;&lt;/code&gt; to delete the opening pair.  Whether or not these features are advantages is up to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMO, typing speed isn't always improved with less keystrokes.  There's times where it's improved by predictable reactions to keystrokes.  These plugins allow you to forego the need to balance delimiters yourself in most cases.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-01-23T12:45:23.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11077" PostTypeId="2" ParentId="11075" CreationDate="2017-01-23T12:55:40.613" Score="3" Body="&lt;p&gt;If you movement involves searches on the current line (&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#f&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help f&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#t&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help t&lt;/code&gt;&lt;/a&gt;) you could repeat that movements with &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%3b&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;;&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%2c&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;,&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cfxnewtext&#xA;c;anothertext&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For regular searches you could use &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#n&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;n&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;c/xyz&amp;lt;enter&amp;gt;newtext&#xA;cnanothertext&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are using a combination of searches and movements, like search for &lt;code&gt;pattern1&lt;/code&gt; and then jump some sentences/words, you could record a macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq&amp;lt;complex movements&amp;gt;c2w&amp;lt;c-o&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL%2dO&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;i_CTRL-O&lt;/code&gt;&lt;/a&gt; allows you to finish the macro while in insert mode. Then you can play the macro using &lt;code&gt;@q&lt;/code&gt; (or &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%40%40&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;@@&lt;/code&gt;&lt;/a&gt;) and you will end in insert mode with the old text already removed.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2017-01-23T12:55:40.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11078" PostTypeId="2" ParentId="7545" CreationDate="2017-01-23T14:33:22.640" Score="0" Body="&lt;p&gt;I marked @statox answer correct because it works nicely with regular vim. However if you are using NeoVim then there is &lt;a href=&quot;https://github.com/SpaceVim/SpaceVim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;SpaceVim&lt;/strong&gt;&lt;/a&gt; which is exceedingly impressive.&lt;/p&gt;&#xA;" OwnerUserId="10930" LastActivityDate="2017-01-23T14:33:22.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11079" PostTypeId="2" ParentId="11066" CreationDate="2017-01-23T15:49:18.027" Score="0" Body="&lt;p&gt;I'm going to go with &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;ultisnips&quot;&gt;ultisnips&lt;/a&gt;, whose &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;ultisnips&quot;&gt;git page&lt;/a&gt; actually has a gif of it in action, doing almost exactly what I want (I guess I'm in for a bit of tweaking):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://camo.githubusercontent.com/296aecf30e1607233814196db6bd3f5f47e70c73/68747470733a2f2f7261772e6769746875622e636f6d2f5369725665722f756c7469736e6970732f6d61737465722f646f632f64656d6f2e676966&quot; alt=&quot;ultisnips&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the interest! Cheers.&lt;/p&gt;&#xA;" OwnerUserId="10952" LastActivityDate="2017-01-23T15:49:18.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11080" PostTypeId="1" AcceptedAnswerId="11081" CreationDate="2017-01-23T16:24:40.200" Score="2" ViewCount="159" Body="&lt;p&gt;I have this remap in my vimrc which makes the cooperation between vim and bash a lot easier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LoadRegisters()&#xA;  let $y = @0&#xA;  let $r = @&quot;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; : :call LoadRegisters()&amp;lt;enter&amp;gt;:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically I can just and use my internal registers in external commands without thinking about it.&#xA;However, now, whenever I use the colon I'm confused because the colon doesn't appear at the bottom, well, because it's silent.&#xA;Can I somehow make the function call silent, and then go unsilent again?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how to tag this...&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2017-01-24T10:07:37.933" Title="Make colon appear even though you execute a silent command" Tags="|command-line|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11081" PostTypeId="2" ParentId="11080" CreationDate="2017-01-23T18:23:53.140" Score="2" Body="&lt;p&gt;The &lt;code&gt;LoadRegisters()&lt;/code&gt; function doesn't output anything, so you could remove the &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt;, which causes the last colon to be displayed immediately:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap : :call LoadRegisters()&amp;lt;enter&amp;gt;:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If for some reason you see any output from this function, you could try the &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3asilent&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:silent&lt;/code&gt;&lt;/a&gt; command on the function call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap : :silent call LoadRegisters()&amp;lt;enter&amp;gt;:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The thing is that I see it being typed, whenever I use the colon&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For some reason I only see the last colon. Maybe you have some configuration that changes the behavior; try testing it in vanilla Vim: &lt;code&gt;vim -u NONE -U NONE -N -i NONE&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2017-01-24T10:07:37.933" LastActivityDate="2017-01-24T10:07:37.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11082" PostTypeId="2" ParentId="11071" CreationDate="2017-01-23T20:59:46.207" Score="0" Body="&lt;p&gt;As it has been pointed out, this feature doesn't really save any keystrokes, however it helps keeping these pairs balanced. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note however that &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-brackets&lt;/a&gt; has two ways to close all current bracket pairs. The first is bound to the semi colon in C and C++. The second is bound to an tunable keybindind. This is (one of the?) the only case where keystrokes can be saved. I can't tell whether the more popular alternative have (yet?) implemented this feature. &lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-01-24T09:49:51.660" LastActivityDate="2017-01-24T09:49:51.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11083" PostTypeId="1" CreationDate="2017-01-24T04:09:33.197" Score="1" ViewCount="53" Body="&lt;p&gt;I'm trying to improve my vim-abilities. I'm writing a command and a function to find the current &lt;strong&gt;W&lt;/strong&gt;ord under the cursor. What I want to be able to do is type &lt;code&gt;:FindFile&lt;/code&gt; and have the word under the current cursor open.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Find the file under the current W word.&#xA;function! FindFile()&#xA;    let l:contents = @&quot;&#xA;    normal viWy&#xA;    find l:contents&#xA;    set @&quot; = l:contents&#xA;endfunction&#xA;command! FindFile :call FindFile()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10101" LastActivityDate="2017-02-23T04:51:39.123" Title="How can I use a register with :find?" Tags="|normal-mode|register|functions|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11084" PostTypeId="2" ParentId="11083" CreationDate="2017-01-24T04:13:09.237" Score="1" Body="&lt;p&gt;I'm still a n00b at vimscript, but I figured out the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FindFile()&#xA;    find &amp;lt;cWORD&amp;gt;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10101" LastActivityDate="2017-01-24T04:13:09.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11085" PostTypeId="1" CreationDate="2017-01-24T08:17:56.577" Score="1" ViewCount="168" Body="&lt;p&gt;I got some output code that has random backslashes, followed by a new line. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;( 1-z+z^11-z^12+z^22-z^23+z^33-z^34+z^37-z^38+z^40-z^41+z^43-&#xA;z^45+2*z^46-2*z^47+z^49-z^50+z^52-z^53+2*z^55-2*z^56+z^57\&#xA;-z^59+z^61-z^62+z^64-z^65+z^66-z^67+z^68-z^69+z^74-z^76+2*z^77-2*z^78+z^79-z^82+z^83-z^84+2*z^86-2*z^87+z^88-z^91+2*z^\&#xA;92-2*z^93+z^95-z^96+z^97-z^100+2*z^101-2*z^102+z^103-z^105+z^107-z^109+2*z^110-z^111+z^114-2*z^115+2*z^116-z^117-z^118\&#xA;+2*z^119-z^120+z^123-2*z^124+2*z^125-z^126-z^131+2*z^132-2*z^133+z^134-z^137+2*z^138-z^139-z^140+2*z^141-2*z^142+z^143\&#xA;-z^146+2*z^147-z^148+z^150-z^152+z^154-2*z^155+2*z^156-z^157+z^160&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to remove all the backslashes and newlines so that it's all on one continuous line. I was thinking the way to do this would be to move the cursor to before each backslash occurrence, and then hit delete twice. Is there a way to automate this on Vim so it searches the entire document and does it for all cases? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="10971" LastActivityDate="2017-01-24T08:38:41.000" Title="Finding all occurences of backslash and deleting twice before every occurence of them" Tags="|regular-expression|search|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11086" PostTypeId="2" ParentId="11085" CreationDate="2017-01-24T08:38:41.000" Score="2" Body="&lt;p&gt;You can substitute nothing for &lt;em&gt;backslash-followed-by-newline&lt;/em&gt; throughout your buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\\\n//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:substitute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :substitute&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2017-01-24T08:38:41.000" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11087" PostTypeId="1" CreationDate="2017-01-24T08:45:03.173" Score="0" ViewCount="1368" Body="&lt;p&gt;I am currently using &lt;a href=&quot;https://github.com/kana/vim-altr&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-altr&lt;/a&gt; to switch between head and source file in c++. I use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F2&amp;gt; &amp;lt;Plug&amp;gt;(altr-forward)&#xA;nmap &amp;lt;F3&amp;gt; &amp;lt;Plug&amp;gt;(altr-back)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to move between buffer. However, this opens two buffers. I would like it to be in one (and only one) buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this cannot be done by &lt;a href=&quot;https://github.com/kana/vim-altr&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-altr&lt;/a&gt;, is there another way?&lt;/p&gt;&#xA;" OwnerUserId="622" LastEditorUserId="343" LastEditDate="2017-01-24T13:33:14.303" LastActivityDate="2017-01-24T13:33:14.303" Title="Switch between header and source files in one buffer" Tags="|buffers|neovim|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11088" PostTypeId="2" ParentId="11087" CreationDate="2017-01-24T09:49:04.573" Score="0" Body="&lt;p&gt;The venerable alternate plugin (&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=31&quot; rel=&quot;nofollow noreferrer&quot;&gt;a.vim&lt;/a&gt;), has a &lt;code&gt;:A&lt;/code&gt; command that seems to be exactly what you're looking for -- changing the buffer currently displayed in the current window, however you'll see several buffers with &lt;code&gt;:ls&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its API is a little bit cumbersome though and it doesn't provide a neat way to have different settings for different projects -- I guess this is why several other similar plugins have emerged since then.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-01-24T09:49:04.573" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11089" PostTypeId="1" CreationDate="2017-01-24T10:13:59.997" Score="1" ViewCount="278" Body="&lt;p&gt;I want to use the plugin neocomplete only for a few filetypes.&#xA;For example for Go programming language. So I have the following entries in my &lt;em&gt;~/.vimrc/ftplugin/go.vim&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;let g:neocomplete#enable_at_startup = 1&#xA;let g:neocomplete#enable_smart_case = 1&#xA;let g:neocomplete#sources#syntax#min_keyword_length = 3&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(My plugins are managed through VimPlug which works flawless.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I have one problem and one question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&#xA;Is it bad practice to set global variables in an ftplugin? And why? They seem to work with the exception of the &lt;em&gt;neocomplete#enable_at_startup&lt;/em&gt; variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here it comes to the problem:&lt;/strong&gt;&#xA;neocomplete doesn't do auto-completion until I enable it manually:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:NeoCompleteEnable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to add the following line in my &lt;em&gt;go.vim&lt;/em&gt; to enable it automatically at startup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * NeoCompleteEnable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question and my problem seem to affect each other. Is there a better way to enable neocomplete plugin only for specific filetypes and to set also different values to the variables for each type?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Greetings&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Philipp&lt;/p&gt;&#xA;" OwnerUserId="10974" LastActivityDate="2017-01-24T10:13:59.997" Title="How to use neocomplete in ftplugin" Tags="|vimrc|plugin-neocomplete|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11090" PostTypeId="2" ParentId="11017" CreationDate="2017-01-24T13:14:22.173" Score="0" Body="&lt;p&gt;So it turns out that, for whatever reason, the settings I used caused the delete command to only delete four spaces at a time, while the file-type-specific settings cause the tab command to produce eight--thus, a mis-match in how things get tabbed and un-tabbed.  The resolution I now use that seems to be working is, in the vimrc file, to include the file-specific setting &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType html setlocal shiftwidth=4 tabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in order to override the default HTML settings.  I'm fine with this solution but it might be better (or better practice?) to find the file that controls all file-specific settings and edit that file directly ... but that'll be a project for another day.&lt;/p&gt;&#xA;" OwnerUserId="6225" LastActivityDate="2017-01-24T13:14:22.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11091" PostTypeId="2" ParentId="11087" CreationDate="2017-01-24T13:18:38.277" Score="1" Body="&lt;p&gt;I think you're misunderstanding the terminology slightly, here. Essentially, a Vim buffer &lt;em&gt;is&lt;/em&gt; a file, so loading two files into a single buffer isn't a concept that really makes sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems from your comments that the real issue is that you don't want to have both files in the &lt;em&gt;buffer list&lt;/em&gt; (as displayed by vim-airline) at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't recommend that you do this (I think it's better to just get used to the way that Vim works), but if you &lt;em&gt;really&lt;/em&gt; want to, you can achieve this by altering the mappings you use to call the altr plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MySwitchForward()&#xA;  let b = bufnr(&quot;%&quot;)&#xA;  call altr#forward()&#xA;  execute &quot;bdelete &quot; . b&#xA;endfunction&#xA;function! MySwitchBack()&#xA;  let b = bufnr(&quot;%&quot;)&#xA;  call altr#back()&#xA;  execute &quot;bdelete &quot; . b&#xA;endfunction&#xA;&#xA;nmap &amp;lt;F2&amp;gt; :call MySwitchForward()&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;F3&amp;gt; :call MySwitchBack()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These mappings use &lt;code&gt;altr&lt;/code&gt; to switch buffers, and then delete the buffer you just switched away from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.B. In my testing with the &lt;code&gt;a.vim&lt;/code&gt; plugin, this approach didn't work well, because of the method &lt;code&gt;a.vim&lt;/code&gt; uses for opening the buffer. I'm pretty sure it &lt;em&gt;will&lt;/em&gt; work with the altr plugin you are using, but if not, you will need to replace &quot;bdelete&quot; with &quot;bwipeout&quot; (although make sure you are aware of &lt;a href=&quot;https://vi.stackexchange.com/questions/2212/&quot;&gt;the consequences&lt;/a&gt; before doing so).&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-01-24T13:18:38.277" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="11092" PostTypeId="1" AcceptedAnswerId="11093" CreationDate="2017-01-24T15:09:58.200" Score="2" ViewCount="13274" Body="&lt;p&gt;In a fortran code for example, there are lines like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;c   write(6,*) &quot;some text&quot;&#xA;&#xA;    write(6,*) &quot;some other text&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How would I search for lines having a &lt;code&gt;write&lt;/code&gt; but exclude all lines starting with &lt;code&gt;c&lt;/code&gt; or &lt;code&gt;C.&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10566" LastEditorUserId="1821" LastEditDate="2017-01-24T16:23:03.030" LastActivityDate="2017-10-06T15:46:17.897" Title="Search a string excluding the lines starting with another string" Tags="|regular-expression|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11093" PostTypeId="2" ParentId="11092" CreationDate="2017-01-24T15:25:22.917" Score="5" Body="&lt;p&gt;You can use the regular expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^\([^cC].*\)\?write&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, using &quot;very magic&quot; to simplify a little:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v^([^cC].*)?write&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt;: turns on &quot;very magic&quot; so we don't have to use as many escape characters,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt;: matches a start of the line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;([^cC].*)?&lt;/code&gt;: matches either nothing, or any character that is &lt;em&gt;not&lt;/em&gt; a c/C followed by zero or more characters:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[^cC]&lt;/code&gt;: matches any character that is not a c/C&amp;thinsp;&amp;mdash;&amp;thinsp;this is the part that ignores lines that start with c/C,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*&lt;/code&gt;: matches a string of any characters of any length (including zero-length)&amp;thinsp;&amp;mdash;&amp;thinsp;this part matches the rest of the line preceding the &quot;write&quot;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(...)?&lt;/code&gt; : makes the entire expression inside the parentheses optional&amp;thinsp;&amp;mdash;&amp;thinsp;this part means that lines that &lt;em&gt;start&lt;/em&gt; with &quot;write&quot; will still be matched,&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;write&lt;/code&gt;: matches &quot;write&quot;!&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: As &lt;a href=&quot;https://vi.stackexchange.com/questions/11092/search-a-string-excluding-the-lines-starting-with-another-string/11093#comment19463_11093&quot;&gt;@KarlYngveLervåg points out in the comments&lt;/a&gt;, the instances of &lt;code&gt;write&lt;/code&gt; that you want to search for will be (almost) always be the first thing on the line, so you could probably get away with using a &lt;em&gt;much&lt;/em&gt; simpler regular expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^\s*write&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt;: matches the start of the line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s*&lt;/code&gt;: if any whitespace follows, this matches it,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;write&lt;/code&gt;: matches &quot;write&quot;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 2&lt;/strong&gt;: If you're actually carrying out a &lt;code&gt;:substitute&lt;/code&gt; operation, you can use another method, which is to use &lt;code&gt;:vglobal&lt;/code&gt; to only perform the &lt;code&gt;:substitute&lt;/code&gt; command on lines which don't match a pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:v/^c/s/write/changed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:v/^c/&lt;/code&gt; On all lines that &lt;em&gt;don't&lt;/em&gt; match the regular expression &lt;code&gt;^c&lt;/code&gt; i.e. all lines that don't begin with a &quot;c&quot;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s/write/changed&lt;/code&gt; Replace &quot;write&quot; with &quot;changed&quot;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The same technique also works with &lt;code&gt;:global&lt;/code&gt;, to perform replacements only on lines that &lt;em&gt;do&lt;/em&gt; match a regular expression.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-10-06T15:46:17.897" LastActivityDate="2017-10-06T15:46:17.897" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11094" PostTypeId="1" AcceptedAnswerId="11103" CreationDate="2017-01-24T17:07:10.480" Score="2" ViewCount="228" Body="&lt;p&gt;In Vim, I find each of &lt;code&gt;ü&lt;/code&gt; and &lt;code&gt;ß&lt;/code&gt; takes up fullwidth, i.e. twice as fat as ASCII characters. &#xA;I am writing some German-learning notes, and find this to be very confusing, since I have been mistaken that there were a whitespace following that character.&#xA;How can I make them shown as halfwidth?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Afterwards, out of curiosity, I tried some extended Latin characters (umlauts, accented vowels, currency symbols, etc.), and find some other characters looking like halfwidth but be shown as fullwidth. They include (but I suppose are not restricted to)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ßüŒœø€§¶&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is true for Vim inside iTerm2, MacVim inside iTerm2, Vim inside Terminal.app, MacVim inside Terminal.app, and even for standalone GUI of MacVim. I have tried several monospace fonts, including Monaco and Menlo. I use Mac Sierra.&lt;/p&gt;&#xA;" OwnerUserId="10241" LastEditorUserId="2920" LastEditDate="2017-01-24T17:54:50.747" LastActivityDate="2017-01-25T06:21:27.047" Title="Some umlauts and extended Latin characters are shown as fullwidth" Tags="|macvim|unicode|macos|font|iterm2|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11096" PostTypeId="1" AcceptedAnswerId="11097" CreationDate="2017-01-24T19:50:36.060" Score="7" ViewCount="2888" Body="&lt;p&gt;I want to copy different strings from different lines of the file and then paste them together at once. In other words, I want to collect different words in a basket and then paste them at once. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="10987" LastEditorUserId="2920" LastEditDate="2017-01-24T20:54:09.023" LastActivityDate="2017-01-25T00:20:25.353" Title="Copying multiple words (from different lines) and paste them at once" Tags="|cut-copy-paste|register|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11097" PostTypeId="2" ParentId="11096" CreationDate="2017-01-24T20:14:44.663" Score="16" Body="&lt;p&gt;Use an uppercase register when yanking (copying):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Ay&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;A&lt;/code&gt; says to &lt;em&gt;append&lt;/em&gt; to the &lt;code&gt;a&lt;/code&gt; register, as opposed to &lt;code&gt;&quot;a&lt;/code&gt; which would &lt;em&gt;replace&lt;/em&gt; the contents of the &lt;code&gt;a&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you've copied everything into the register, you can then paste it all at once with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;ap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2017-01-24T20:14:44.663" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11098" PostTypeId="2" ParentId="11096" CreationDate="2017-01-25T00:14:45.000" Score="7" Body="&lt;p&gt;You could also define your own custom operator which would yank incrementally any text-object or text covered by a motion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! Incremental_yank(type, ...) abort&#xA;    if a:type ==# 'char'&#xA;        norm! `[v`]y&#xA;    elseif a:type ==# 'line'&#xA;        norm! '[V']y&#xA;    elseif a:0&#xA;        norm! gvy&#xA;    endif&#xA;&#xA;    call setreg('z', @&quot;.(a:type ==# 'char' ? ' ' : ''), 'a' . getregtype('&quot;'))&#xA;    call setreg('&quot;', @z, getregtype('z'))&#xA;endfu&#xA;&#xA;nno &amp;lt;silent&amp;gt; zy  :&amp;lt;C-U&amp;gt;set opfunc=Incremental_yank&amp;lt;CR&amp;gt;g@&#xA;xno &amp;lt;silent&amp;gt; zy  :&amp;lt;C-U&amp;gt;call Incremental_yank(visualmode(), 1)&amp;lt;CR&amp;gt;&#xA;nno &amp;lt;silent&amp;gt; zyy :&amp;lt;C-U&amp;gt;set opfunc=Incremental_yank&amp;lt;Bar&amp;gt;exe 'norm! '.v:count1.'g@_'&amp;lt;CR&amp;gt;&#xA;&#xA;nno &amp;lt;silent&amp;gt; zyc :&amp;lt;C-U&amp;gt;let [@&quot;, @z] = ['', '']&amp;lt;CR&amp;gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In this example, 4 key bindings are installed:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;zy&lt;/code&gt; normal operator to incrementally yank a text-object or motion&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;zyy&lt;/code&gt; similar operator which works on lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;zy&lt;/code&gt;  similar operator which works on visual selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;zyc&lt;/code&gt; normal command to empty the registers &lt;code&gt;&quot;&lt;/code&gt; and &lt;code&gt;z&lt;/code&gt;; useful before beginning to yank a sequence of texts&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With it, you could:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;copy some words hitting &lt;code&gt;zyiw&lt;/code&gt; on the first word, then repeat the operation with the dot command on the next ones&lt;/li&gt;&#xA;&lt;li&gt;copy some lines hitting &lt;code&gt;zyy&lt;/code&gt; on the first one, then repeat the operation with the dot command on the next ones&lt;/li&gt;&#xA;&lt;li&gt;copy some visual selections, hitting &lt;code&gt;zy&lt;/code&gt; on each of them&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The current code clutters the &lt;code&gt;z&lt;/code&gt; register, if you prefer using another register, like &lt;code&gt;x&lt;/code&gt; for example, you could change the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setreg('z', @&quot;, 'a' . getregtype('&quot;'))                call setreg('x', @&quot;, 'a' . getregtype('&quot;'))&#xA;             ^                                                          ^&#xA;call setreg('&quot;', @z, getregtype('z'))                 →    call setreg('&quot;', @x, getregtype('x'))&#xA;                  ^              ^                                           ^              ^&#xA;nno &amp;lt;silent&amp;gt; zyc :&amp;lt;C-U&amp;gt;let [@&quot;, @z] = ['', '']&amp;lt;CR&amp;gt;p        nno &amp;lt;silent&amp;gt; zyc :&amp;lt;C-U&amp;gt;let [@&quot;, @x] = ['', '']&amp;lt;CR&amp;gt;p&#xA;                                 ^                                                          ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h g@&#xA;:h getregtype()&#xA;:h setreg()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wf36c.gif&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wf36c.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-01-25T00:20:25.353" LastActivityDate="2017-01-25T00:20:25.353" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11100" PostTypeId="2" ParentId="7545" CreationDate="2017-01-25T04:14:23.427" Score="2" Body="&lt;p&gt;You could also try &lt;a href=&quot;https://github.com/liuchengxu/space-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;space-vim&lt;/a&gt;, which is intended for those who using vim and spacemacs at the same time. Its goal is to switch from spacemacs to vim painlessly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's more, &lt;a href=&quot;https://github.com/ctjhoa/spacevim&quot; rel=&quot;nofollow noreferrer&quot;&gt;spacevim&lt;/a&gt; is also a good choice. It can be seen as a full vim distribution or a set of key bindings similar to spacemacs. You can pick out one that suits you best.&lt;/p&gt;&#xA;" OwnerUserId="10269" LastEditorUserId="10269" LastEditDate="2017-01-25T04:25:33.703" LastActivityDate="2017-01-25T04:25:33.703" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11101" PostTypeId="1" AcceptedAnswerId="11102" CreationDate="2017-01-25T04:56:45.970" Score="15" ViewCount="3067" Body="&lt;p&gt;I'm familiar with the &quot;dd&quot; and &quot;d{motion}&quot; commands, but can't find &quot;dap&quot; in vim's help.txt. What does &quot;dap&quot; do in normal mode and why? (Alternatively, how can I find out this sort of thing for myself?)&lt;/p&gt;&#xA;" OwnerUserId="10997" LastEditorUserId="7566" LastEditDate="2017-01-25T10:01:00.720" LastActivityDate="2017-01-25T10:01:00.720" Title="Does &quot;dap&quot; delete everything?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11102" PostTypeId="2" ParentId="11101" CreationDate="2017-01-25T05:25:40.723" Score="28" Body="&lt;p&gt;&quot;dap&quot; does not actually delete everything. For example, try putting this into your buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;1&#xA;&#xA;2&#xA;2&#xA;&#xA;3&#xA;3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then put your cursor on either '2' and type &quot;dap&quot;. It'll leave the '1's and '3's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is because &quot;dap&quot; deletes a &lt;em&gt;paragraph&lt;/em&gt;. In fact, that's actually the mnemonic: &quot;(D)elete (A) (P)aragraph&quot;. You can see it in the help under &lt;code&gt;:h ap&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *v_ap* *ap*&#xA;ap          &quot;a paragraph&quot;, select [count] paragraphs (see&#xA;            |paragraph|).&#xA;            Exception: a blank line (only containing white space)&#xA;            is also a paragraph boundary.&#xA;            When used in Visual mode it is made linewise.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is called a &quot;text object&quot;. You can read about these under: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects&quot;&gt;&lt;code&gt;:h text-objects&lt;/code&gt;&lt;/a&gt;, or you can read &lt;a href=&quot;http://blog.carbonfive.com/2011/10/17/vim-text-objects-the-definitive-guide/&quot;&gt;this awesome article on text objects.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either way, the basic idea of text-objects is that you are defining the boundaries of an &lt;em&gt;object&lt;/em&gt; and then apply commands to that whole object even when you're in the middle of it. For example, I'm sure you know you can use &lt;code&gt;dw&lt;/code&gt; to delete a word. But what if you're in this scenario?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hello world&#xA;Cursor: ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you type &lt;code&gt;dw&lt;/code&gt;, you'll still have the &lt;code&gt;wo&lt;/code&gt; left. If you type &lt;code&gt;diw&lt;/code&gt;, that will delete &lt;em&gt;inside of the word&lt;/em&gt;, so for the most part it's equivalent to typing &lt;code&gt;bdw&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I find out this sort of thing for myself?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You had the basic idea down! Checking the help is always a good start. In this case, you could have realized that &lt;code&gt;d&lt;/code&gt; is an operator, so the help you were really looking for was the argument to the operator, in this case &lt;code&gt;ap&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-01-25T05:25:40.723" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11103" PostTypeId="2" ParentId="11094" CreationDate="2017-01-25T06:21:27.047" Score="2" Body="&lt;p&gt;Sorry, it's because I set &lt;code&gt;:set ambiwidth=double&lt;/code&gt;. It makes some characters twice as wide as usual. I set &lt;code&gt;:set ambiwidth=single&lt;/code&gt;, and all is fine. This line, I must have copied from some stranger's vimrc and did not examine closely. It's my fault, not Vim's fault.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea what &lt;code&gt;ambiwidth&lt;/code&gt; is for. Maybe there is some font that need it to display right (see &lt;code&gt;:help 'ambiwidth'&lt;/code&gt;). But as I cancelled it and set to &lt;code&gt;single&lt;/code&gt;, everything still seems fine, Chinese or English. This question is kept for future reader's convenience.&lt;/p&gt;&#xA;" OwnerUserId="10241" LastActivityDate="2017-01-25T06:21:27.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11104" PostTypeId="1" AcceptedAnswerId="11106" CreationDate="2017-01-25T07:06:12.293" Score="2" ViewCount="1438" Body="&lt;p&gt;Auto-comments are the most annoying &quot;feature&quot; of text editors and IDEs for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've searched -- nay, &lt;em&gt;scavenged&lt;/em&gt; -- high and low to figure out how to get rid of &lt;em&gt;literally any semblance of automatic comment continuation&lt;/em&gt;, and for whatever reason it's proving impossible and incredibly annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, I have tried the following three lines, which works for most languages.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead,FileType * set formatoptions-=cro&#xA;autocmd BufNewFile,BufRead,FileType * setlocal formatoptions-=cro&#xA;au FileType c,cpp setlocal comments-=:// comments+=f://&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But whenever I open a file that isn't considered C++ at first (i.e. not the correct extension) and use &lt;code&gt;setf cpp&lt;/code&gt;, all auto-comments seem to come back to haunt me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even sometimes opening a known-to-be-C++ file, this still happens. I'm not sure what the cause is, but it's aggravating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How on Earth can I tell vim that I &lt;em&gt;really truly&lt;/em&gt; do not want auto-comments, ever, under any circumstances?&lt;/strong&gt; I feel like I've been plagued by this for &lt;em&gt;years&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3164" LastEditorUserId="3164" LastEditDate="2017-01-25T07:13:36.223" LastActivityDate="2017-01-25T09:24:53.303" Title="Disable absolutely all auto-comments, for real" Tags="|vimrc|neovim|autocmd|comments|" AnswerCount="1" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11105" PostTypeId="1" CreationDate="2017-01-25T09:19:41.930" Score="2" ViewCount="280" Body="&lt;p&gt;I have an issue where in MacVim, I don't get any syntastic/eslint related functionality.  When I run &lt;code&gt;!which eslint&lt;/code&gt; in macvim, I get &quot;eslint not found&quot; - eslint is definitely installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Bdiqj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Bdiqj.png&quot; alt=&quot;eslint not found on macvim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run &lt;code&gt;!which eslint&lt;/code&gt; on iTerm, I get the correct location of eslint (&lt;code&gt;/Users/fpe/.nvm/versions/node/v4.4.5/bin/eslint&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like MacVim is not aware of my &lt;code&gt;$PATH&lt;/code&gt;. I didn't set anything specifically.  I am also using zsh, if that makes a difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I fix this?&lt;/p&gt;&#xA;" OwnerUserId="10836" LastActivityDate="2017-01-25T09:19:41.930" Title="syntastic not working on macvim, but works perfectly fine on the terminal" Tags="|macvim|plugin-syntastic|path|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="11106" PostTypeId="2" ParentId="11104" CreationDate="2017-01-25T09:24:53.303" Score="6" Body="&lt;p&gt;The culprit is &lt;code&gt;$VIMRUNTIME/ftplugin/c.vim&lt;/code&gt;, and likely all other standard ft plugins. If you want everything they define but the setting for &lt;code&gt;'formatoptions'&lt;/code&gt;, I don't see any simple solution. (Just in case, &lt;code&gt;$VIMRUNTIME&lt;/code&gt; is set within vim)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;May be, you could listen for &lt;code&gt;OptionSet&lt;/code&gt; to prevent inserting &lt;code&gt;cro&lt;/code&gt; in &lt;code&gt;&amp;amp;fo&lt;/code&gt;. But beware of possible infinite loops. I've never tried it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I would have left &lt;code&gt;'comments'&lt;/code&gt; alone. This option could be used by plugins that toggle comments on blocks, or that generate documentation -- I actually use it in mu-template to insert license captions as comments, which ever the current language is.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-01-25T09:24:53.303" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11107" PostTypeId="1" AcceptedAnswerId="11109" CreationDate="2017-01-25T09:25:15.973" Score="6" ViewCount="1517" Body="&lt;p&gt;Is there a way to set Negate in the substitution command? In other words how to substitute any character except &lt;code&gt;|&lt;/code&gt; to &lt;code&gt;-&lt;/code&gt; and all &lt;code&gt;|&lt;/code&gt; to &lt;code&gt;+&lt;/code&gt;. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;| some text | other text |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+-----------+------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a shortest way than &lt;code&gt;:s/[^|]/-/g | s/|/+/g&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="9633" LastActivityDate="2017-01-25T16:52:25.650" Title="Conditional substitution in VIM" Tags="|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11109" PostTypeId="2" ParentId="11107" CreationDate="2017-01-25T09:39:23.053" Score="10" Body="&lt;p&gt;You can use the replace special substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/./\= submatch(0) == '|' ? '+' : '-'/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;\=&lt;/code&gt; says to use the following expression to use as the result string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And it's checking for &lt;code&gt;submatch(0)&lt;/code&gt; (the char matched by the &lt;code&gt;/./&lt;/code&gt; pattern) and do a condition on that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h sub-replace-special&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h submatch()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2017-01-25T09:39:23.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11110" PostTypeId="2" ParentId="11092" CreationDate="2017-01-25T11:36:04.620" Score="3" Body="&lt;p&gt;If you're going to use this pattern for substitution, you could also use zero-width lookarounds, in particular &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%40%3C%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\@&amp;lt;!&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        /\@&amp;lt;!&#xA;\@&amp;lt;!    Matches with zero width if the preceding atom does NOT match just&#xA;        before what follows.  Thus this matches if there is no position in the&#xA;        current or previous line where the atom matches such that it ends just&#xA;        before what follows.  /zero-width {not in Vi}&#xA;        Like &quot;(?&amp;lt;!pattern)&quot; in Perl, but Vim allows non-fixed-width patterns.&#xA;        The match with the preceding atom is made to end just before the match&#xA;        with what follows, thus an atom that ends in &quot;.*&quot; will work.&#xA;        Warning: This can be slow (because many positions need to be checked&#xA;        for a match).  Use a limit if you can, see below.&#xA;        Example                 matches &#xA;        \(foo\)\@&amp;lt;!bar          any &quot;bar&quot; that's not in &quot;foobar&quot;&#xA;        \(\/\/.*\)\@&amp;lt;!in        &quot;in&quot; which is not after &quot;//&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(^[cC].*\)\@&amp;lt;!write&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-01-25T11:36:04.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11111" PostTypeId="2" ParentId="10368" CreationDate="2017-01-25T12:18:55.980" Score="8" Body="&lt;p&gt;As you specifically asked about solutions that use other plugins, I'll note that you can also stage visual selections using &lt;a href=&quot;https://github.com/jreybert/vimagit&quot; rel=&quot;noreferrer&quot;&gt;vimagit&lt;/a&gt;, which is a Git plugin (based on the other editor's popular &lt;a href=&quot;https://github.com/magit/magit&quot; rel=&quot;noreferrer&quot;&gt;Magit plugin&lt;/a&gt;) centered around viewing, staging, and commiting changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To stage a visual selection using Vimagit:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Run the &lt;code&gt;:Magit&lt;/code&gt; command to open a new buffer that displays all the changed hunks in your &lt;em&gt;repository&lt;/em&gt; (not just in one file),&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Locate the lines you want to stage and perform your &lt;code&gt;visual&lt;/code&gt; selection,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press the &quot;stage&quot; mapping: &lt;code&gt;S&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-01-25T12:18:55.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11112" PostTypeId="1" AcceptedAnswerId="11131" CreationDate="2017-01-25T12:39:44.867" Score="0" ViewCount="817" Body="&lt;p&gt;When you open a CSV file with the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2830&quot; rel=&quot;nofollow noreferrer&quot;&gt;CSV.vim&lt;/a&gt; plugin the separators, such as semicolons, do not visually divide the columns in a format like the screenshot below. How can I visually separate the columns like tabstop with CSV.vim plugin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/K72Vn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/K72Vn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/j4MFf.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/j4MFf.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10986" LastEditorUserId="1841" LastEditDate="2017-01-25T12:57:21.900" LastActivityDate="2017-01-26T08:55:17.043" Title="CSV columns visually divided in the separators to equal spaces like tabstops with CSV.vim?" Tags="|insert-mode|visual-mode|formatting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11113" PostTypeId="1" AcceptedAnswerId="11114" CreationDate="2017-01-25T13:52:20.997" Score="0" ViewCount="420" Body="&lt;p&gt;CSV.vim plugin has an ability to change the column deliminator/separator. I would like to find a plugin by which I can change all decimal points (such as comma) to dot, does there exist plugin to do such conversion?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;P.s. This is the command that does this, &lt;code&gt;:%s/\([0-9]\)\.\([0-9]\)/\1,\2/g&lt;/code&gt;, but I would like to find a plugin that brings this kind of common conversions as scripts.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="10986" LastActivityDate="2017-01-25T22:12:53.023" Title="Vim: plugin to change all decimal points?" Tags="|formatting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11114" PostTypeId="2" ParentId="11113" CreationDate="2017-01-25T14:18:29.383" Score="5" Body="&lt;p&gt;Why don't you define a command from this line? Drop it in &lt;code&gt;$HOME/.vim/plugin/yourpluginname.vim&lt;/code&gt;, and you're done. (at least, this is enough for something that simple)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% ChangeDotToComa &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;s/\d\zs\.\ze\d/,/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: Honestly, in that case, I'd rather change the locale of my machine to tell it that I want to use &lt;code&gt;.&lt;/code&gt; as the decimal point and not &lt;code&gt;,&lt;/code&gt;. (But then I've troubles with CSV files produced by excel running with unmodified French locale. They are fortunately rare enough)&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-01-25T22:12:53.023" LastActivityDate="2017-01-25T22:12:53.023" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11115" PostTypeId="1" AcceptedAnswerId="11119" CreationDate="2017-01-25T15:57:56.647" Score="2" ViewCount="1272" Body="&lt;p&gt;I have explictly said in my &lt;code&gt;vimrc&lt;/code&gt; that I want &lt;code&gt;nohidden&lt;/code&gt; behaviour (I am jumping between files a lot, with long lasting session, and after some time buffers list is very polluted). However when I jump to other file and I run &lt;code&gt;:ls&lt;/code&gt; I still see old files listed. Is there a way to prevent such behaviour?&lt;/p&gt;&#xA;" OwnerUserId="1259" LastActivityDate="2017-01-25T19:36:57.357" Title="Buffers are left even when `nohidden` is set" Tags="|buffers|neovim|hidden-buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11116" PostTypeId="1" AcceptedAnswerId="17384" CreationDate="2017-01-25T16:11:15.407" Score="5" ViewCount="650" Body="&lt;p&gt;I would like to adapt &lt;a href=&quot;https://github.com/tpope/vim-markdown/tree/master/syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;this syntax file&lt;/a&gt; so that the formatting in VIM matches more closely &lt;a href=&quot;https://jbt.github.io/markdown-editor/#NcsxCoAwDAXQPaf4c4cews1jlBpsoCbFJoi3F0Tf/lYvXepEms2ib1RNXTQ4wdtpsTcoX+iiPDPREo4kX/kGqTn+hlGmoyj4GH6/Lz8=&quot; rel=&quot;nofollow noreferrer&quot;&gt;what this online Markdown editor (GitLab-flavor)&lt;/a&gt; displays (the output on the right is relevant, this is how I want the text to look in VIM). In particular, I am looking at the detection of italics triggered by framing text with asterisks.&lt;/p&gt;&#xA;&lt;p&gt;I made some progress by simplifying the start and end patterns and by adding &amp;quot;oneline&amp;quot;. But actually I would like the region to extend beyond a single line to an entire paragraph. In other words, the region should include subsequent lines until an empty line is encountered. If I omit the &amp;quot;oneline&amp;quot; attribute, the region just goes on and does not stop on an empty line. How can I make this region include subsequent non-empty lines but stop at the first empty line (or, obviously, the end pattern, whatever comes first)?&lt;/p&gt;&#xA;&lt;p&gt;Note that a piece of text that contains the start pattern, but no end pattern and that is terminated by an empty line should NOT be detected as a region. The empty line is not an alternative end, it should just be interpreted as &amp;quot;stop looking here for the end pattern&amp;quot;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start=&amp;quot;\*\S\@=&amp;quot; end=&amp;quot;\S\@&amp;lt;=\*&amp;quot; keepend oneline contains=markdownLineStart' . s:concealends&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Update 2023-09-05&lt;/h2&gt;&#xA;&lt;p&gt;Here is how the relevant section of my &lt;code&gt;markdown.vim&lt;/code&gt; file looks now. It does italics and bold in a style that corresponds more closely to the way Markdown is rendered on Github. I personally don't use markdownBoldItalic or markdownStrike, so I did not bother to change those.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let s:conceal = ''&#xA;let s:concealends = ''&#xA;if has('conceal') &amp;amp;&amp;amp; get(g:, 'markdown_syntax_conceal', 1) == 1&#xA;  let s:conceal = ' conceal'&#xA;  let s:concealends = ' concealends'&#xA;endif&#xA;exe 'syn match markdownItalicDelimiterStart &amp;quot;\*\ze\S\(\([^\n]\|\n[^\n]\)\{-}\)\S\*&amp;quot;' s:conceal&#xA;exe 'syn match markdownItalicDelimiterEnd &amp;quot;\(\*\S\(\([^\n]\|\n[^\n]\)\{-}\)\S\)\@&amp;lt;=\*&amp;quot;' s:conceal&#xA;syn match markdownItalic &amp;quot;\*\S\(\([^\n]\|\n[^\n]\)\{-}\)\S\*&amp;quot; contains=markdownItalicDelimiterStart,markdownItalicDelimiterEnd&#xA;exe 'syn match markdownItalicDelimiterStart &amp;quot;_\ze\S\(\([^\n]\|\n[^\n]\)\{-}\)\S_&amp;quot;' s:conceal&#xA;exe 'syn match markdownItalicDelimiterEnd &amp;quot;\(_\S\(\([^\n]\|\n[^\n]\)\{-}\)\S\)\@&amp;lt;=_&amp;quot;' s:conceal&#xA;syn match markdownItalic &amp;quot;_\S\(\([^\n]\|\n[^\n]\)\{-}\)\S_&amp;quot; contains=markdownItalicDelimiterStart,markdownItalicDelimiterEnd&#xA;exe 'syn match markdownBoldDelimiterStart &amp;quot;\*\*\ze\S\(\([^\n]\|\n[^\n]\)\{-}\)\S\*\*&amp;quot;' s:conceal&#xA;exe 'syn match markdownBoldDelimiterEnd &amp;quot;\(\*\*\S\(\([^\n]\|\n[^\n]\)\{-}\)\S\)\@&amp;lt;=\*\*&amp;quot;' s:conceal&#xA;syn match markdownBold &amp;quot;\*\*\S\(\([^\n]\|\n[^\n]\)\{-}\)\S\*\*&amp;quot; contains=markdownBoldDelimiterStart,markdownBoldDelimiterEnd&#xA;exe 'syn match markdownBoldDelimiterStart &amp;quot;__\ze\S\(\([^\n]\|\n[^\n]\)\{-}\)\S__&amp;quot;' s:conceal&#xA;exe 'syn match markdownBoldDelimiterEnd &amp;quot;\(__\S\(\([^\n]\|\n[^\n]\)\{-}\)\S\)\@&amp;lt;=__&amp;quot;' s:conceal&#xA;syn match markdownBold &amp;quot;__\S\(\([^\n]\|\n[^\n]\)\{-}\)\S__&amp;quot; contains=markdownBoldDelimiterStart,markdownBoldDelimiterEnd&#xA;exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start=&amp;quot;\*\*\*\S\@=&amp;quot; end=&amp;quot;\S\@&amp;lt;=\*\*\*\|^$&amp;quot; skip=&amp;quot;\\\*&amp;quot; contains=markdownLineStart,@Spell' . s:concealends&#xA;exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start=&amp;quot;\w\@&amp;lt;!___\S\@=&amp;quot; end=&amp;quot;\S\@&amp;lt;=___\w\@!\|^$&amp;quot; skip=&amp;quot;\\_&amp;quot; contains=markdownLineStart,@Spell' . s:concealends&#xA;exe 'syn region markdownStrike matchgroup=markdownStrikeDelimiter start=&amp;quot;\~\~\S\@=&amp;quot; end=&amp;quot;\S\@&amp;lt;=\~\~\|^$&amp;quot; contains=markdownLineStart,@Spell' . s:concealends&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11009" LastEditorUserId="11009" LastEditDate="2023-09-05T17:49:53.860" LastActivityDate="2023-09-05T17:49:53.860" Title="How to make a syntax region stop on empty lines?" Tags="|syntax-highlighting|line-breaks|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11117" PostTypeId="2" ParentId="10454" CreationDate="2017-01-25T16:29:36.917" Score="2" Body="&lt;p&gt;If you can live with an imperfect solution, there is a simple way of achieving&#xA;this effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to syntax highlighting, Vim has a second mechanism for colouring text: Match Highlighting. We&#xA;can use this to colour comments with the &lt;code&gt;Comment&lt;/code&gt; colouring, and then switch off&#xA;syntax highlighting entirely:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. for Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ClearSyntax()&#xA;  match Comment /#.*$/&#xA;  syntax off&#xA;endfunction&#xA;&#xA;command! ClearSyntax :call ClearSyntax()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problems with this approach are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The code as pasted above only deals with a single language.&#xA;If you need the function to work in different languages, you're going to need&#xA;to change the match expression depending on the language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. to support Python and HTML:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ClearSyntax()&#xA;  if &amp;amp;ft ==? &quot;python&quot;&#xA;    match Comment /#.*$/&#xA;  elseif &amp;amp;ft ==? &quot;html&quot;&#xA;    match Comment /&amp;lt;!--\_.\{-}--&amp;gt;/&#xA;  endif&#xA;&#xA;  syntax off&#xA;endfunction&#xA;&#xA;command! ClearSyntax :call ClearSyntax()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on how many languages you need it to support, this ranges from &quot;a&#xA;little clunky&quot; to &quot;completely untenable&quot;, but really, the bigger problem is:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It requires matching the comments with a regular expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a few languages, this is trivial, but for most, a complete solution&#xA;can be difficult or even impossible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, the sample regular expression I've used to match Python&#xA;comments will erroneously find comments in lines that include a &lt;code&gt;#&lt;/code&gt; character&#xA;within a string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s = &quot;This is not a comment: #&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Single regular expressions are not a great tool for parsing source code,&#xA;and hacking together something that works even most of the time can be&#xA;fiddly, but there's no shortage of people trying online, so if your regex-fu&#xA;isn't up to the task, it's fairly easy to find examples that handle most&#xA;cases for most languages.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-01-25T16:41:05.060" LastActivityDate="2017-01-25T16:41:05.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11118" PostTypeId="2" ParentId="11107" CreationDate="2017-01-25T16:52:25.650" Score="3" Body="&lt;p&gt;As an alternative you can use the system's &lt;code&gt;tr&lt;/code&gt; program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.!tr '| -z' '+-'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-01-25T16:52:25.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11119" PostTypeId="2" ParentId="11115" CreationDate="2017-01-25T18:33:39.593" Score="4" Body="&lt;h3&gt;The &lt;code&gt;'hidden'&lt;/code&gt; setting&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;'hidden'&lt;/code&gt;/&lt;code&gt;'nohidden'&lt;/code&gt; setting tells Vim what to do about buffers that are &quot;abandoned&quot;. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'hidden'&lt;/code&gt; means an abandoned buffer becomes hidden (similar &lt;code&gt;:hide&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'nohidden'&lt;/code&gt; (the default) means the buffer is unloaded (&lt;code&gt;:bunload&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Both &lt;code&gt;:bunload&lt;/code&gt; and &lt;code&gt;:hide&lt;/code&gt; do not remove a buffer from the buffer list. Therefore &lt;code&gt;'hidden'&lt;/code&gt; setting will &lt;em&gt;not&lt;/em&gt; affect if a buffer shows up in the buffer list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h abandon&#xA;:h 'hidden'&#xA;:h hidden-buffer&#xA;:h :bunload&#xA;:h :ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Removing hidden buffers from the buffer list&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;To remove a buffer from the buffer list by doing &lt;code&gt;:bdelete&lt;/code&gt; (unload buffer and delete from buffer list) or &lt;code&gt;:bwipeout&lt;/code&gt; (really &lt;em&gt;really&lt;/em&gt; get rid of the buffer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Buffers can &quot;automatically&quot; be removed when they become hidden by changing the &lt;code&gt;'bufhidden'&lt;/code&gt; setting on each buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost * set bufhidden=wipe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would &lt;em&gt;not&lt;/em&gt; recommend this method a it can ruin the following commands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Switch to the alternative buffer, &lt;code&gt;&amp;lt;c-^&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;c-6&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Popping back from a tag, &lt;code&gt;&amp;lt;c-t&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Moving through the jump list across buffers with &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Not to mention it may interfere with some plugins which uses a temporary buffer.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Switching buffers&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I imagine the root problem is how you navigate between buffers. I am guessing you use buffer numbers or cycle through via &lt;code&gt;:bnext&lt;/code&gt;/&lt;code&gt;:bprev&lt;/code&gt;. There are some alternatives to these methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Behold the power of &lt;code&gt;:b&lt;/code&gt;&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Uses &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; completion&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; to list out completion&lt;/li&gt;&#xA;&lt;li&gt;Use partial file name. e.g. &lt;code&gt;:b foo&lt;/code&gt;. Works great with &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Globbing. e.g. &lt;code&gt;:b foo*bar&lt;/code&gt; or &lt;code&gt;:b foo/**/bar&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Might want to use &lt;code&gt;'hidden'&lt;/code&gt; via &lt;code&gt;set hidden&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Split variant of &lt;code&gt;:b&lt;/code&gt; is &lt;code&gt;:sb&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Also accepts a buffer number&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A common mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :ls&amp;lt;cr&amp;gt;:b&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you like plugins you may want to check out something like &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;CtrlP&lt;/a&gt; to switch between buffers. For more advanced file navigation use tags, cscope, &lt;a href=&quot;https://www.gnu.org/software/global/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GNU global&lt;/a&gt;, or plugin like &lt;a href=&quot;https://github.com/tpope/vim-projectionist&quot; rel=&quot;nofollow noreferrer&quot;&gt;projectionist.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :ls&#xA;:h :b&#xA;:h 'hidden'&#xA;:h wildcard&#xA;:h c_CTRL-D&#xA;:h starstar&#xA;:h tags&#xA;:h cscope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Conclusion&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Personally I would change how you switch buffers. I typically have 50+ buffers open and switch between without any issue. You can remove the occasional buffer via &lt;code&gt;:bd&lt;/code&gt; or &lt;code&gt;:bw&lt;/code&gt; when the need arises.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-01-25T19:36:57.357" LastActivityDate="2017-01-25T19:36:57.357" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11121" PostTypeId="2" ParentId="10062" CreationDate="2017-01-25T20:20:01.883" Score="0" Body="&lt;p&gt;This is a bit of a hack but does what you asked :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y3w:exec 'norm!' getreg('&quot;') == &quot;the count is &quot; ? &quot;3w\&amp;lt;c-a&amp;gt;`[3b&quot; : &quot;ithe count is 1\&amp;lt;esc&amp;gt;3b&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Save this to register &lt;code&gt;a&lt;/code&gt; and when you &lt;kbd&gt;12&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; it will print&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;the count is 12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since there is no way to pass the count to the macro (that I know of), the macro is still run &lt;code&gt;n&lt;/code&gt; times but it will only increment the number after the first run.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-01-25T20:20:01.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11122" PostTypeId="1" CreationDate="2017-01-26T01:58:58.277" Score="3" ViewCount="231" Body="&lt;p&gt;I found the following description of a command which sets up which items must appear in the status line, &lt;a href=&quot;https://www.vi-improved.org/recommendations/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%F%m%r%h%w[%L][%{&amp;amp;ff}]%y[%p%%][%04l,%04v]&#xA;&quot;              | | | | |  |   |      |  |     |    |&#xA;&quot;              | | | | |  |   |      |  |     |    +-- current column&#xA;&quot;              | | | | |  |   |      |  |     +-- current line&#xA;&quot;              | | | | |  |   |      |  +-- current % into file&#xA;&quot;              | | | | |  |   |      +-- current syntax&#xA;&quot;              | | | | |  |   +-- current fileformat&#xA;&quot;              | | | | |  +-- number of lines&#xA;&quot;              | | | | +-- preview flag in square brackets&#xA;&quot;              | | | +-- help flag in square brackets&#xA;&quot;              | | +-- readonly flag in square brackets&#xA;&quot;              | +-- modified flag in square brackets&#xA;&quot;              +-- full path to file in the buffer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I would like to reproduce the same sort of diagram which is used here to break down the description of other commands that I could find in the future. But drawing the &lt;code&gt;|&lt;/code&gt;, &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt; characters can take some time.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to automate the process, so that I can focus on the contents of the description, rather than the diagram?&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-01-26T02:55:08.270" LastActivityDate="2017-01-26T23:20:24.330" Title="How to automatically break down the description of a command?" Tags="|key-bindings|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11123" PostTypeId="2" ParentId="11122" CreationDate="2017-01-26T01:59:13.980" Score="6" Body="&lt;p&gt;Here's what I'm currently using to do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno &amp;lt;silent&amp;gt; m&amp;lt;cr&amp;gt;   :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;break_down_mark()&amp;lt;cr&amp;gt;&#xA;nno &amp;lt;silent&amp;gt; m&amp;lt;bs&amp;gt;   :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;break_down_clear()&amp;lt;cr&amp;gt;&#xA;nno &amp;lt;silent&amp;gt; m&amp;lt;tab&amp;gt;  :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;break_down_draw()&amp;lt;cr&amp;gt;&#xA;&#xA;fu! s:break_down_clear() abort&#xA;    if exists('s:bd_marks')&#xA;        call matchdelete(s:bd_marks.id)&#xA;        unlet s:bd_marks&#xA;    endif&#xA;endfu&#xA;&#xA;fu! s:sort_coords(x,y) abort&#xA;    return a:x.col - a:y.col&#xA;endfu&#xA;&#xA;fu! s:break_down_draw() abort&#xA;    if !exists('s:bd_marks.coords')&#xA;        return&#xA;    endif&#xA;&#xA;    let ve_save = &amp;amp;ve&#xA;    set ve=all&#xA;&#xA;    let coords   = s:bd_marks.coords&#xA;    let nr_lines = len(coords)&#xA;&#xA;    call append(line('.'), repeat([''], nr_lines + 1))&#xA;&#xA;    if exists(':Commentary')&#xA;        for j in range(0, nr_lines)&#xA;            +&#xA;            call setline(line('.'), &quot;\&amp;lt;c-a&amp;gt;&quot;)&#xA;            Commentary&#xA;            call setline(line('.'), substitute(getline('.'), &quot;\&amp;lt;c-a&amp;gt;&quot;, '', ''))&#xA;        endfor&#xA;    endif&#xA;&#xA;    let loclist = []&#xA;    for i in sort(coords, 's:sort_coords')&#xA;        exe 'norm! '. i.line .'G'&#xA;        exe 'norm! '. i.col . '|j'&#xA;        for j in range(1, nr_lines)&#xA;            norm! r|j&#xA;        endfor&#xA;        exe 'norm! R+-- '&#xA;&#xA;        call add(loclist, {&#xA;                          \ 'bufnr': bufnr('%'),&#xA;                          \ 'lnum' : i.line + nr_lines + 1,&#xA;                          \ 'col'  : i.col + 4,&#xA;                          \ })&#xA;        let nr_lines -= 1&#xA;    endfor&#xA;&#xA;    call setloclist(0, loclist)&#xA;    lfirst&#xA;&#xA;    call s:break_down_clear()&#xA;    let &amp;amp;ve = ve_save&#xA;endfu&#xA;&#xA;fu! s:break_down_mark() abort&#xA;    if !exists('s:bd_marks')&#xA;        let s:bd_marks = {&#xA;                         \ 'coords'  : [],&#xA;                         \ 'pattern' : '',&#xA;                         \ 'id'      :  0,&#xA;                         \ }&#xA;    else&#xA;        if s:bd_marks.id&#xA;            call matchdelete(s:bd_marks.id)&#xA;            let s:bd_marks.pattern .= '|'&#xA;        endif&#xA;    endif&#xA;&#xA;    if !empty(s:bd_marks.coords) &amp;amp;&amp;amp; line('.') == s:bd_marks.coords[-1].line&#xA;&#xA;        if count(s:bd_marks.coords, {&#xA;                                    \ 'line' : line('.'),&#xA;                                    \ 'col' : virtcol('.'),&#xA;                                    \ })&#xA;            call filter(s:bd_marks.coords, &quot;v:val != {&#xA;                                                     \ 'line' : line('.'),&#xA;                                                     \ 'col' : virtcol('.'),&#xA;                                                     \ }&quot;)&#xA;        else&#xA;            let s:bd_marks.coords += [{&#xA;                                      \ 'line' : line('.'),&#xA;                                      \ 'col'  : virtcol('.'),&#xA;                                      \ }]&#xA;        endif&#xA;&#xA;    else&#xA;        let s:bd_marks.coords  = [{&#xA;                                  \ 'line' : line('.'),&#xA;                                  \ 'col'  : virtcol('.'),&#xA;                                  \ }]&#xA;    endif&#xA;&#xA;    let s:bd_marks.pattern = '\v'&#xA;                           \ .join(&#xA;                           \       map(&#xA;                           \           deepcopy(s:bd_marks.coords),&#xA;                           \           &quot;'%'.v:val.line.'l%'.v:val.col.'v.'&quot;&#xA;                           \          ),&#xA;                           \       '|'&#xA;                           \      )&#xA;&#xA;    let s:bd_marks.id = !empty(s:bd_marks.coords)&#xA;                        \   ? matchadd('SpellBad', s:bd_marks.pattern)&#xA;                        \   : 0&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How to use it&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The previous code installs 3 key bindings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;m Enter        mark the current character as the starting point of something&#xA;               you want to describe&#xA;&#xA;m Backspace    delete all the marks&#xA;&#xA;m Tab          draw the diagram (`|`, `+`, `-`) for all the characters which&#xA;               were marked; also, populate the location list of the current&#xA;               window with their positions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After you hit &lt;code&gt;m Tab&lt;/code&gt; to draw the diagram, you can navigate between the different parts of your description with &lt;code&gt;:lnext&lt;/code&gt; and &lt;code&gt;:lprevious&lt;/code&gt;, or any key bindings bound to these commands. As an example, &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;unimpaired&lt;/a&gt; binds them to &lt;code&gt;[l&lt;/code&gt; and &lt;code&gt;]l&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A typical workflow would be to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;mark the characters in which you're interested on a given line, hitting &lt;code&gt;m Enter&lt;/code&gt; on each of them&lt;/li&gt;&#xA;&lt;li&gt;hit &lt;code&gt;m Tab&lt;/code&gt; to draw the diagram&lt;/li&gt;&#xA;&lt;li&gt;navigate between the different parts of your command with &lt;code&gt;:lnext&lt;/code&gt;/&lt;code&gt;:lprevious&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How it works&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno &amp;lt;silent&amp;gt; m&amp;lt;cr&amp;gt;   :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;break_down_mark()&amp;lt;cr&amp;gt;&#xA;nno &amp;lt;silent&amp;gt; m&amp;lt;bs&amp;gt;   :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;break_down_clear()&amp;lt;cr&amp;gt;&#xA;nno &amp;lt;silent&amp;gt; m&amp;lt;tab&amp;gt;  :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;break_down_draw()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These lines install the 3 key bindings described earlier. They call the 3 functions &lt;code&gt;s:break_down_mark()&lt;/code&gt;, &lt;code&gt;s:break_down_clear()&lt;/code&gt; and &lt;code&gt;s:break_down_draw()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:break_down_clear() abort&#xA;    if exists('s:bd_marks')&#xA;        call matchdelete(s:bd_marks.id)&#xA;        unlet s:bd_marks&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function is responsible for deleting all the information which were stored concerning the characters marked so far (&lt;code&gt;unlet s:bd_marks&lt;/code&gt;). It also removes the highlighting which was applied on them (&lt;code&gt;call matchdelete(s:bd_marks.id)&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:sort_coords(x,y) abort&#xA;    return a:x.col - a:y.col&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function will be needed to sort the coordinates of the characters you mark, because it's possible that sometimes you go back on the line, to mark a character you forgot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have the lambda feature (&lt;code&gt;:echo has('lambda')&lt;/code&gt; returns 1), then you could get rid of it. But in this case, you will have to replace the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in sort(coords, 's:sort_coords')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in sort(coords, {x,y -&amp;gt; x.col - y.col})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:break_down_mark() abort&#xA;    ...&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function is responsible for marking the current character as the start of an item in your future description.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('s:bd_marks')&#xA;    let s:bd_marks = {&#xA;                     \ 'coords'  : [],&#xA;                     \ 'pattern' : '',&#xA;                     \ 'id'      :  0,&#xA;                     \ }&#xA;else&#xA;    if s:bd_marks.id&#xA;        call matchdelete(s:bd_marks.id)&#xA;        let s:bd_marks.pattern .= '|'&#xA;    endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This checks whether the script-local variable &lt;code&gt;s:bd_marks&lt;/code&gt; exists. If it doesn't, it means you're marking the first character in a line. So, it initializes the dictionary &lt;code&gt;s:bd_marks&lt;/code&gt; with 3 keys:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;coords&lt;/code&gt;,  initial value = empty list&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;pattern&lt;/code&gt;, initial value = empty pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;id&lt;/code&gt;,      initial value = zero number&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;coords&lt;/code&gt; will store the coordinates of your marks inside dictionaries. Each of them will contain 2 keys: &lt;code&gt;line&lt;/code&gt; and &lt;code&gt;col&lt;/code&gt;. Their values being the line address and the column number of the character which is being marked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;pattern&lt;/code&gt; will store the pattern describing all the characters you've marked. It will be used by the &lt;code&gt;matchadd()&lt;/code&gt; function to highlight them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;id&lt;/code&gt; is the identifier of the match created by &lt;code&gt;matchadd()&lt;/code&gt;. It's necessary to be able to delete it, either when when you've finished or when the match must be updated because you've just marked a new character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;s:bd_marks&lt;/code&gt; does exist, then it means you're not marking the first character in a line. You're marking a subsequent one.&lt;br&gt;&#xA;So, &lt;code&gt;s:break_down_mark()&lt;/code&gt; removes the match (&lt;code&gt;call matchdelete(s:bd_marks.id)&lt;/code&gt;), and it adds a bar character (&lt;code&gt;|&lt;/code&gt;) at the end of the pattern, to prepare the next branch (&lt;code&gt;let s:bd_marks.pattern .= '|'&lt;/code&gt;).&lt;br&gt;&#xA;The latter will describe the position of the current character, which is being marked.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !empty(s:bd_marks.coords) &amp;amp;&amp;amp; line('.') == s:bd_marks.coords[-1].line&#xA;...&#xA;else&#xA;...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &lt;code&gt;if&lt;/code&gt; block checks whether you're marking a character which is on the same line as the one containing the previous marked characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're marking a character on a different line, then the function resets the list of coordinates, with the ones of the current character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let s:bd_marks.coords  = [{&#xA;                              \ 'line' : line('.'),&#xA;                              \ 'col'  : virtcol('.'),&#xA;                              \ }]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because it can't draw the diagram for characters across different lines. They must all be on the same line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, if you're marking a character on the same line, the function processes this sub-block &lt;code&gt;if&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if count(s:bd_marks.coords, {&#xA;                                \ 'line' : line('.'),&#xA;                                \ 'col' : virtcol('.'),&#xA;                                \ })&#xA;        call filter(s:bd_marks.coords, &quot;v:val != {&#xA;                                                 \ 'line' : line('.'),&#xA;                                                 \ 'col' : virtcol('.'),&#xA;                                                 \ }&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This checks whether you're marking a character which was already marked. If it was, then the function removes its coordinates from the list &lt;code&gt;s:bd_marks.coords&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way, you can toggle the status of a mark, by hitting the same key binding &lt;code&gt;m Enter&lt;/code&gt; multiple times on the same character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the character was not already marked, then the function adds its coordinates to &lt;code&gt;s:bd_marks.coords&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        let s:bd_marks.coords += [{&#xA;                                  \ 'line' : line('.'),&#xA;                                  \ 'col'  : virtcol('.'),&#xA;                                  \ }]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, the function creates the pattern describing all the characters which were marked so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:bd_marks.pattern = '\v'&#xA;                       \ .join(&#xA;                       \       map(&#xA;                       \           deepcopy(s:bd_marks.coords),&#xA;                       \           &quot;'%'.v:val.line.'l%'.v:val.col.'v.'&quot;&#xA;                       \          ),&#xA;                       \       '|'&#xA;                       \      )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it creates a match to highlight them all:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:bd_marks.id = !empty(s:bd_marks.coords)&#xA;                    \   ? matchadd('SpellBad', s:bd_marks.pattern)&#xA;                    \   : 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It colors the characters with the &lt;code&gt;SpellBad&lt;/code&gt; highlighting group. If you don't like the color, you could replace &lt;code&gt;SpellBad&lt;/code&gt; with the name of another group, after looking at the output of the &lt;code&gt;:hi&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:break_down_draw() abort&#xA;    …&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function draws the diagram.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('s:bd_marks.coords')&#xA;    return&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First, it checks whether &lt;code&gt;s:bd_marks.coords&lt;/code&gt; exists. If the latter doesn't exist, the function doesn't do anything and returns, because without coordinates, it can't draw anything.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let ve_save = &amp;amp;ve&#xA;set ve=all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It saves the value of your &lt;code&gt;'virtualedit'&lt;/code&gt; option, and gives it the value &lt;code&gt;all&lt;/code&gt; so that it can draw freely.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let coords   = s:bd_marks.coords&#xA;let nr_lines = len(coords)&#xA;&#xA;call append(line('.'), repeat([''], nr_lines + 1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It opens some new lines. The number should be just enough to draw the diagram without overwriting existing lines which were just below the long command you want to break down.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(':Commentary')&#xA;    for j in range(0, nr_lines)&#xA;        +&#xA;        call setline(line('.'), &quot;\&amp;lt;c-a&amp;gt;&quot;)&#xA;        Commentary&#xA;        call setline(line('.'), substitute(getline('.'), &quot;\&amp;lt;c-a&amp;gt;&quot;, '', ''))&#xA;    endfor&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This part comments the new lines which have just been opened. It relies on the custom command &lt;code&gt;:Commentary&lt;/code&gt;, which is similar to the one defined in the &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-commentary&lt;/a&gt; plugin. However, by default &lt;code&gt;:Commentary&lt;/code&gt; doesn't comment an empty line, so the function temporarily inserts a random character (here &lt;code&gt;C-a&lt;/code&gt;) before &lt;code&gt;:Commentary&lt;/code&gt; is invoked, then it removes it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't use the &lt;code&gt;vim-commentary&lt;/code&gt; plugin, but another one, check out its documentation to find the name of the Ex command which comments a line from a script. I could be wrong, but I think in &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;nerdcommenter&lt;/a&gt; it's &lt;code&gt;:NERDComComment&lt;/code&gt;, and in &lt;a href=&quot;https://github.com/tomtom/tcomment_vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;tcomment_vim&lt;/a&gt; it's &lt;code&gt;:TComment&lt;/code&gt;.&lt;br&gt;&#xA;Then replace &lt;code&gt;:Commentary&lt;/code&gt; accordingly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let loclist = []&#xA;for i in sort(coords, 's:sort_coords')&#xA;    exe 'norm! '. i.line .'G'&#xA;    exe 'norm! '. i.col . '|j'&#xA;    for j in range(1, nr_lines)&#xA;        norm! r|j&#xA;    endfor&#xA;    exe 'norm! R+-- '&#xA;&#xA;    call add(loclist, {&#xA;                      \ 'bufnr': bufnr('%'),&#xA;                      \ 'lnum' : i.line + nr_lines + 1,&#xA;                      \ 'col'  : i.col + 4,&#xA;                      \ })&#xA;    let nr_lines -= 1&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This part is responsible for the creation of the list &lt;code&gt;loclist&lt;/code&gt; which will be used to populate the location list of your current window. It also draws the diagram with these 4 commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe 'norm! '. i.line .'G'    position the cursor on the line to break down&#xA;&#xA;exe 'norm! '. i.col . '|j'   position the cursor on the column of a character&#xA;                             from which a branch of the diagram must be drawn&#xA;&#xA;norm! r|j                    draw the bar characters inside the vertical part of the branch&#xA;&#xA;exe 'norm! R+-- '            draw the `+--` horizontal part of the branch &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't like the &lt;code&gt;|&lt;/code&gt;, &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt; characters, and you prefer using different ones, you could change the last 2 commands.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setloclist(0, loclist)&#xA;lfirst&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This part populates the location list with &lt;code&gt;loclist&lt;/code&gt; and positions the cursor on its first entry, so that you are automatically positioned below the first character that you marked.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call s:break_down_clear()&#xA;let &amp;amp;ve = ve_save&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, the function removes the highlighting which was applied on the marked characters, and restore the value of your &lt;code&gt;'virtualedit'&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How it looks&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bJz4d.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bJz4d.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-01-26T23:20:24.330" LastActivityDate="2017-01-26T23:20:24.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11124" PostTypeId="1" AcceptedAnswerId="11127" CreationDate="2017-01-26T02:59:21.140" Score="6" ViewCount="9798" Body="&lt;p&gt;There are a few questions intertwined -- I hope I convey my intentions well enough so that someone understands where I'm confused and what I'm trying to do. I apologize ahead of time for the chaotic state of this post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;strong&gt;neovim&lt;/strong&gt; installed via homebrew (OSX/macOS).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I plan to use &lt;code&gt;nvim&lt;/code&gt; exclusively as a replacement for &lt;code&gt;vim&lt;/code&gt;, and I plan to utilise &lt;code&gt;gvim&lt;/code&gt; once I sort out this confusion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The directory &lt;code&gt;/usr/local/Cellar/neovim/0.1.7/share/nvim/runtime&lt;/code&gt; contains an &lt;code&gt;autoload&lt;/code&gt; directory amongst much more:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;├── autoload/&lt;br /&gt;&#xA;├── bugreport.vim&lt;br /&gt;&#xA;├── colors/&lt;br /&gt;&#xA;├── compiler/&lt;br /&gt;&#xA;├── delmenu.vim&lt;br /&gt;&#xA;├── doc/&lt;br /&gt;&#xA;├── filetype.vim&lt;br /&gt;&#xA;├── ftoff.vim&lt;br /&gt;&#xA;├── ftplugin/&lt;br /&gt;&#xA;├── ftplugin.vim&lt;br /&gt;&#xA;├── ftplugof.vim&lt;br /&gt;&#xA;├── indent/&lt;br /&gt;&#xA;├── indent.vim&lt;br /&gt;&#xA;├── indoff.vim&lt;br /&gt;&#xA;├── keymap/&lt;br /&gt;&#xA;├── macmap.vim&lt;br /&gt;&#xA;├── macros/&lt;br /&gt;&#xA;├── makemenu.vim&lt;br /&gt;&#xA;├── menu.vim&lt;br /&gt;&#xA;├── mswin.vim&lt;br /&gt;&#xA;├── optwin.vim&lt;br /&gt;&#xA;├── pack/&lt;br /&gt;&#xA;├── plugin/&lt;br /&gt;&#xA;├── print/&lt;br /&gt;&#xA;├── scripts.vim&lt;br /&gt;&#xA;├── synmenu.vim&lt;br /&gt;&#xA;├── syntax/&lt;br /&gt;&#xA;├── tutor/&lt;br /&gt;&#xA;└── vimrc_example.vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When installing &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;noreferrer&quot;&gt;vim-pathogen&lt;/a&gt;, the installation leads you to create the directories &lt;code&gt;autoload&lt;/code&gt; and &lt;code&gt;bundle&lt;/code&gt; within the &lt;code&gt;~/.vim&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see that there are many important vim files in the &lt;code&gt;runtime&lt;/code&gt; directory. I want to avoid redundancy as much as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would it be more efficient to symlink one/more of the directories in &lt;code&gt;~&lt;/code&gt; to the &lt;code&gt;runtime&lt;/code&gt; directory - or perhaps one/more of its subdirectories?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When installing vim plugins and other vim files to the config directory in my home directory, should I ensure that the same plugin files aren't located in both homebrew's &lt;code&gt;autoload&lt;/code&gt; directory and &lt;code&gt;~/.vim/autoload&lt;/code&gt;? In other words, do I need to verify beforehand that a particular vim file isn't already located in homebrew's &lt;code&gt;runtime&lt;/code&gt; directory for &lt;code&gt;nvim&lt;/code&gt; before installing said vim file in &lt;code&gt;~/.vim/&lt;/code&gt;? Would it be more efficient to install all files in &lt;code&gt;~/.config/nvim&lt;/code&gt; instead of &lt;code&gt;~/.vim&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I modify the &lt;code&gt;execute pathogen#infect()&lt;/code&gt; line in my &lt;code&gt;.vimrc&lt;/code&gt; to reflect the runtime (or some other) directory?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;code&gt;/usr/bin/vim&lt;/code&gt; but not &lt;code&gt;vim&lt;/code&gt; from homebrew. Would it make things easier if I installed homebrew's &lt;code&gt;vim&lt;/code&gt; installed? This is something I eventually plan to do.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;syntax on&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; I receive this error every time I launch &lt;code&gt;vim&lt;/code&gt; or &lt;code&gt;nvim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Can't open file /usr/bin/vim/syntax/syntax.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet &lt;code&gt;syntax.vim&lt;/code&gt; exists within the &lt;code&gt;runtime&lt;/code&gt; directory for &lt;code&gt;nvim&lt;/code&gt; mentioned above.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What I have done so far:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Per &lt;a href=&quot;https://neovim.io/doc/user/nvim.html#nvim-from-vim&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; I have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir ~/.config&#xA;ln -s ~/.vim ~/.config/nvim&#xA;ln -s ~/.vimrc ~/.config/nvim/init.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In attempt to troubleshoot, I've started with a new &lt;code&gt;.vimrc&lt;/code&gt; that contains&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;syntax on&#xA;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;pathogen.vim&lt;/code&gt; is the only file located within &lt;code&gt;~/.vim/autoload&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Variable &lt;code&gt;EDITOR&lt;/code&gt; is set to &lt;code&gt;nvim&lt;/code&gt; in &lt;code&gt;.bash_profile&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I've reviewed &lt;a href=&quot;https://vi.stackexchange.com/questions/4969/is-the-vim-directory-used-for-anything-other-than-plugins&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;.vimrc&lt;/code&gt; containing only the three lines above, I get the following errors when I run &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;nvim&lt;/code&gt;, respectively:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;vim&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Error detected while processing /Users/user/.vimrc:&#xA;    line    2:&#xA;    E484: Can't open file /usr/bin/vim/syntax/syntax.vim&#xA;    Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;nvim&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Error detected while processing /Users/user/.config/nvim/init.vim:&#xA;    line    1:&#xA;    E117: Unknown function: pathogen#infect&#xA;    E15: Invalid expression: pathogen#infect()&#xA;    line    2:&#xA;    E484: Cannot open file /usr/bin/vim/syntax/syntax.vim&#xA;    Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;&lt;strong&gt;ultimate&lt;/strong&gt;&lt;/em&gt; question isn't necessarily surrounding &lt;code&gt;vim-pathogen&lt;/code&gt;, but rather trying to find a sound way to understand and manage all configurations (including directories) between &lt;code&gt;vim&lt;/code&gt;, &lt;code&gt;nvim&lt;/code&gt;, &lt;code&gt;gvim&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I sincerely appreciate any help.&lt;/p&gt;&#xA;" OwnerUserId="7602" LastEditorUserId="7602" LastEditDate="2017-01-26T04:58:17.573" LastActivityDate="2017-01-26T06:08:02.017" Title="Managing autoload directories efficiently" Tags="|neovim|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11125" PostTypeId="2" ParentId="4185" CreationDate="2017-01-26T03:32:02.637" Score="2" Body="&lt;p&gt;I don't know what setting &lt;code&gt;g:UltiSnipsSnippetsDir&lt;/code&gt; actually does either UltiSnip's documentation is misleading or this is a bug. However, adding your directory to &lt;code&gt;rtp&lt;/code&gt; by itself does what you want.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp+=/newfolder/snippets&#xA;let g:UltiSnipsSnippetDirectories=[&quot;UltiSnipsNewDir&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7939" LastActivityDate="2017-01-26T03:32:02.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11126" PostTypeId="1" AcceptedAnswerId="11128" CreationDate="2017-01-26T05:27:38.833" Score="5" ViewCount="951" Body="&lt;p&gt;I frequently use gvim on a windows 7 computer with a touch screen. If I flick up or down with the touch screen, it creates a selection (in &lt;em&gt;S&lt;/em&gt; mode, not &lt;em&gt;V&lt;/em&gt; mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not really a fan of this default behavior. It's seems pointless and unintuitive to me. Can I configure flicking to vertically scroll instead of creating a selection? Vertical scrolling is much more important, but if there is a solution that also works with horizontal scrolling, that would be awesome.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Side note:&lt;/em&gt; I'm aware the answer might just be &lt;strong&gt;no.&lt;/strong&gt; If you can give a definitive answer about why this is not an option, I'd accept that too (And be a little disappointed) .&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2022-06-16T11:24:48.500" Title="Can I scroll in vim with my touch screen?" Tags="|gvim|scrolling|mouse|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11127" PostTypeId="2" ParentId="11124" CreationDate="2017-01-26T06:08:02.017" Score="13" Body="&lt;p&gt;You're looking at this all wrong.  Read &lt;code&gt;:h 'runtimepath'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'runtimepath'&lt;/code&gt; or &lt;code&gt;'rtp'&lt;/code&gt; is analogous to &lt;code&gt;$PATH&lt;/code&gt; in the shell.  The files you see in &lt;code&gt;/usr/local/Cellar/neovim/0.1.7/share/nvim/runtime&lt;/code&gt; is the &lt;strong&gt;pristine&lt;/strong&gt; runtime files that come with Neovim.  You &lt;strong&gt;should not&lt;/strong&gt; add files to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to see where scripts will be loaded from by default, run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim -u NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo &amp;amp;rtp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For Neovim, the default location is &lt;code&gt;$HOME/.config/nvim&lt;/code&gt;.  The directory structure there is expected to be the same as what's described in &lt;code&gt;:h 'rtp'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specific plugin managers aside, all they do is help you manage &lt;code&gt;'rtp'&lt;/code&gt;.  As an example, say you want to use one of my plugins: &lt;a href=&quot;https://github.com/tweekmonster/django-plus.vim&quot; rel=&quot;noreferrer&quot;&gt;django-plus.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will note that it has an &lt;code&gt;autoload&lt;/code&gt;, &lt;code&gt;after&lt;/code&gt;, and &lt;code&gt;doc&lt;/code&gt; directory.  These aren't meant to be merged into a monolithic directory.  The entire repository is meant to be taken as-is in its own directory.  If you decided to download it and place it into &lt;code&gt;~/vim-plugins&lt;/code&gt;, without a plugin manager, you would need to add it to &lt;code&gt;'rtp'&lt;/code&gt; in your &lt;code&gt;init.vim&lt;/code&gt; script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp+=~/vim-plugins/django-plus.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the plugin is &quot;installed&quot;.  But, this is not the best method since it's being &lt;em&gt;appended&lt;/em&gt; to the list.  Ideally it should be &lt;em&gt;prepended&lt;/em&gt; because &lt;code&gt;django-plus.vim&lt;/code&gt; has a script &lt;code&gt;filetype.vim&lt;/code&gt; that should run &lt;em&gt;before&lt;/em&gt; &lt;code&gt;$VIMRUNTIME/filetype.vim&lt;/code&gt; (like how &lt;code&gt;$PATH&lt;/code&gt; is searched).  All plugins will want to be prepended to the &lt;code&gt;'rtp'&lt;/code&gt; since the whole point is to override defaults.  This is where plugin managers help you manage all of this.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I plan to use nvim exclusively as a replacement for vim, and I plan to utilise gvim once I sort out this confusion.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/neovim/neovim/wiki/Related-projects&quot; rel=&quot;noreferrer&quot;&gt;Neovim has GUIs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;With syntax on in my .vimrc I receive this error every time I launch vim or nvim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Can't open file /usr/bin/vim/syntax/syntax.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You somehow changed &lt;code&gt;'rtp'&lt;/code&gt; or broke the runtime directories.  Again, confirm with &lt;code&gt;:echo &amp;amp;rtp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On the topic of plugin managers, just use &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;noreferrer&quot;&gt;vim-plug&lt;/a&gt;.  Everyone has their opinion about what the best plugin manager is, but I've &lt;em&gt;never&lt;/em&gt; heard anyone say that &lt;code&gt;vim-plug&lt;/code&gt; was hard to use.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.local/share/nvim/plugged')&#xA;Plug 'tweekmonster/django-plus.vim'&#xA;&quot; ...and so on...&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you run &lt;code&gt;:PlugUpdate&lt;/code&gt; every now and then to keep things up to date.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pathogen is minimalistic and leaves you still managing the plugins yourself.  There's people that like this, but I'm not among them.  I use &lt;em&gt;a lot&lt;/em&gt; of plugins and I don't want to spend my time checking in on each one to see if they've been updated.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-01-26T06:08:02.017" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11128" PostTypeId="2" ParentId="11126" CreationDate="2017-01-26T07:43:24.983" Score="6" Body="&lt;p&gt;&lt;em&gt;Note: I have not tested this with gvim, only with normal vim&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;This piece of code allows me to scroll instead of selecting text when I drag using my mouse.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;function! MouseScroll()&#xA;  &amp;quot;mark b is the current cursor position&#xA;  &amp;quot;mark a is the previous cursor position&#xA;  norm mb&#xA;  let currPos=line('.')&#xA;  norm `a&#xA;  let prevPos=line('.')&#xA;  if currPos&amp;gt;prevPos&#xA;    norm `bma&#xA;    &amp;quot; norm ^E  (This is hard to typeset)&#xA;    &amp;quot; Adopting the following exe command to achieve the same motion.&#xA;    exe &amp;quot;normal! \&amp;lt;C-e&amp;gt;&amp;quot;&#xA;  elseif currPos&amp;lt;prevPos&#xA;    norm `bma&#xA;    &amp;quot; norm ^Y&#xA;    exe &amp;quot;normal! \&amp;lt;C-y&amp;gt;&amp;quot;&#xA;  endif&#xA;&#xA;  &amp;quot; Need this additional line to &amp;quot;scroll&amp;quot; continuously.&#xA;  &amp;quot; Otherwise, I was prompted &amp;quot;marker not set&amp;quot; warnings when dragging &#xA;  &amp;quot; for more than 1 line.&#xA;  norm ma&#xA;endfunction&#xA;&#xA;map &amp;lt;LeftDrag&amp;gt; ma&amp;lt;LeftMouse&amp;gt;:call MouseScroll()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and add this for insert mode:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;imap &amp;lt;LeftDrag&amp;gt; &amp;lt;ESC&amp;gt;ma&amp;lt;LeftMouse&amp;gt;:call MouseScroll()&amp;lt;cr&amp;gt;:norm gi&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Note: &lt;code&gt;^E&lt;/code&gt; and &lt;code&gt;^Y&lt;/code&gt; are not 2 characters each, they are each one character literals&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I am using marks to check if I'm dragging up or down. Then accordingly I either scroll up or down.&lt;/p&gt;&#xA;&lt;h3&gt;Explanation&lt;/h3&gt;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;map &amp;lt;LeftDrag&amp;gt; ma&amp;lt;LeftMouse&amp;gt;:call MouseScroll()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The first thing we do when we map &lt;code&gt;LeftDrag&lt;/code&gt; is that we set the cursor's mark (this will be our previous mark) to mark &lt;code&gt;a&lt;/code&gt;. Mark &lt;code&gt;a&lt;/code&gt; contains the previous position of the cursor to compare with the current position and scroll accordingly. Then we click. This is because we want to get the current position of the mouse in the buffer (because mouse drags don't usually move the mouse to the updated position). Then we call the &lt;code&gt;MouseScroll&lt;/code&gt; function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Inside the function&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;norm mb&#xA;let currPos=line('.')&#xA;norm `a&#xA;let prevPos=line('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now we get the current position of the cursor using &lt;code&gt;norm mb&lt;/code&gt;. Mark &lt;code&gt;b&lt;/code&gt; will contain the mark of the current cursor position.&lt;/p&gt;&#xA;&lt;p&gt;We store the positions of the position of these marks in variables &lt;code&gt;currPos&lt;/code&gt; and &lt;code&gt;prevPos&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then inside the if-elseif statement, we compare the &lt;code&gt;currPos&lt;/code&gt; with the &lt;code&gt;prevPos&lt;/code&gt;. If the current position is more than the previous position, ie the mouse is dragged downwards, we change mark &lt;code&gt;b&lt;/code&gt; into mark &lt;code&gt;a&lt;/code&gt; and then scroll down using &lt;code&gt;norm ^E&lt;/code&gt;. We do a similar thing for the other case when the current position is below the previous position (the mouse is dragged upwards), except that we scroll up.&lt;/p&gt;&#xA;&lt;p&gt;And that's it :)&lt;/p&gt;&#xA;&lt;h3&gt;Additional Configurations&lt;/h3&gt;&#xA;&lt;p&gt;Sometimes dragging the mouse still enters visual mode (at least for me it does), so I have a &lt;code&gt;set mouse=nic&lt;/code&gt;. It's your choice on what you want to set the mouse to. Also, you can swap the &lt;code&gt;^E&lt;/code&gt; and the &lt;code&gt;^Y&lt;/code&gt; depending on your scroll preferences.&lt;/p&gt;&#xA;" OwnerUserId="10378" LastEditorUserId="2398" LastEditDate="2022-06-16T11:24:48.500" LastActivityDate="2022-06-16T11:24:48.500" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11130" PostTypeId="1" CreationDate="2017-01-26T08:18:49.997" Score="1" ViewCount="3625" Body="&lt;p&gt;I'm on my 4th clean install of YouCompleteMe.  I am trying to get  to work with a Python file after a &lt;code&gt;.&lt;/code&gt; (such as &lt;code&gt;foo.&lt;/code&gt;...Then I hit &lt;code&gt;&amp;lt;C-space&amp;gt;&lt;/code&gt; and would hope to see a list of options to complete with), but so far, nothing seems to be getting through.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the situation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i  &amp;lt;C-Space&amp;gt;   * &amp;lt;C-X&amp;gt;&amp;lt;C-O&amp;gt;&amp;lt;C-P&amp;gt;&#xA;    Last set from ~/dotfiles/vim/.vim/bundle/youcompleteme/autoload/youcompleteme.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_python_binary_path = '/usr/bin/python'&#xA;let g:ycm_server_python_interpreter = '/usr/bin/python2'&#xA;let g:ycm_min_num_of_chars_for_completion = 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I've got no errors or warnings from the &lt;code&gt;YcmDiags&lt;/code&gt; or any other YCM logs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I go ahead and type 2 characters (assuming they match a possible completion), the completions appear very quickly, so I believe the call is being made and serviced properly in that context.  It's just calling it up manually with the key-binding is unresponsive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running xfce4-terminal and using &lt;code&gt;zsh&lt;/code&gt; with &lt;code&gt;oh-my-zsh&lt;/code&gt;, but I hope nothing there would be the culprit, like for example the terminal is blocking &lt;code&gt;&amp;lt;C-space&amp;gt;&lt;/code&gt; from getting to Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and I'm running Vim 8.0 on Arch Linux.&lt;/p&gt;&#xA;" OwnerUserId="7051" LastActivityDate="2017-03-27T14:57:21.007" Title="&lt;C-space&gt; does nothing in YouCompleteMe" Tags="|key-bindings|vimrc|autocompletion|plugin-you-complete-me|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11131" PostTypeId="2" ParentId="11112" CreationDate="2017-01-26T08:55:17.043" Score="3" Body="&lt;p&gt;You can use the &lt;code&gt;:ArrangeColumn&lt;/code&gt; for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;https://github.com/chrisbra/csv.vim/blob/b64fb6895f90721fedb861d56ebcbbb70d80069e/doc/ft-csv.txt#L207&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If you would like all columns to be visually arranged, you can use the &#xA;`:ArrangeColumn` or `:CSVArrangeColumn` command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;e.g.:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xYK5v.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xYK5v.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Result:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FrpGl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FrpGl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2017-01-26T08:55:17.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11132" PostTypeId="2" ParentId="11122" CreationDate="2017-01-26T10:35:01.943" Score="1" Body="&lt;p&gt;One way of avoiding this is to simply build your statusline incrementally:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; filename (relative path)&#xA;set statusline=%1*%f\ &#xA;&quot; file format&#xA;set statusline+=%2*[%{&amp;amp;ff}]&#xA;&quot; file type&#xA;set statusline+=%3*%y&#xA;&quot; modified flag&#xA;set statusline+=%4*%m&#xA;&quot; read only flag&#xA;set statusline+=%9*%r&#xA;&quot; help file flag&#xA;set statusline+=%5*%h&#xA;&quot; preview window flag&#xA;set statusline+=%5*%w&#xA;&quot; buffer number (note trailing space)&#xA;set statusline+=%6*\ buf:%n\ &#xA;&quot; col number,line number / number of lines (note trailing space)&#xA;set statusline+=%7*[%v,%l/%L]\ &#xA;&quot; percentage through file&#xA;set statusline+=%8*[%p%%]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user859" LastActivityDate="2017-01-26T10:35:01.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11135" PostTypeId="2" ParentId="11130" CreationDate="2017-01-26T13:49:53.357" Score="1" Body="&lt;p&gt;You actaully need to map to &lt;code&gt;&amp;lt;Nul&amp;gt;&lt;/code&gt;, not to &lt;code&gt;&amp;lt;C-Space&amp;gt;&lt;/code&gt; - looks strange I know, but I learned that recently trying to map to &lt;code&gt;&amp;lt;C-Space&amp;gt;&lt;/code&gt;. I looked how it's done in CtrlSpace plugin, and it's using &lt;code&gt;&amp;lt;Nul&amp;gt;&lt;/code&gt; for that. The reason is that your terminal probably send's &lt;code&gt;^@&lt;/code&gt; (Nul character/sign) on &lt;kbd&gt;Ctrl-Space&lt;/kbd&gt; - you can check that in &lt;code&gt;Insert Mode&lt;/code&gt; by pressing &lt;kbd&gt;Ctrl-v&lt;/kbd&gt; &lt;kbd&gt;Ctrl-Space&lt;/kbd&gt;. The downside is that &lt;code&gt;&amp;lt;Nul&amp;gt;&lt;/code&gt; can be triggered from other key sequences, not only &lt;kbd&gt;Ctrl-Space&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;&lt;a href=&quot;https://stackoverflow.com/a/12344382/1199156&quot;&gt;Here's&lt;/a&gt; a related SO answer with a bit different approach. It maps &lt;code&gt;&amp;lt;Nul&amp;gt;&lt;/code&gt; directly to &lt;code&gt;&amp;lt;C-Space&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-01-26T13:58:06.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11136" PostTypeId="2" ParentId="319" CreationDate="2017-01-26T14:29:20.333" Score="1" Body="&lt;p&gt;Note that it can be done with:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;visually select whatever you wish&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s^R=system('tr a-z A-Z', @&quot;)[:-2]^M&lt;/code&gt; (with &lt;code&gt;^R&lt;/code&gt; being CTRL+R, and ^M being ENTER)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It could also work with anything that does selection + replace like &lt;code&gt;ci&quot;^R=...&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-01-26T14:29:20.333" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11137" PostTypeId="1" AcceptedAnswerId="11139" CreationDate="2017-01-26T15:07:44.327" Score="3" ViewCount="1160" Body="&lt;p&gt;This is for C coding, but would apply to editing many languages.&#xA;I often use ctags or lately cscope to jump around, and find I often need to quickly check or learn what function I am in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A great tool that seems well suited to this is &lt;code&gt;[[&lt;/code&gt; (which goes to next &lt;code&gt;{&lt;/code&gt; in column 1)&#xA;Then you instantly jump back to where you were with &lt;code&gt;''&lt;/code&gt; (two single quotes)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you need some customizations to make this work for my purpose.  Depending on the size of the function, and where you are on the screen, vim has some rules (that I don't know much about) about when to centre your cursor depending on how far you moved with your last jump or search type of thing.  In many cases, I found &lt;code&gt;[[&lt;/code&gt; would end up on the very first line of the screen, with the function name I so desired being just one hidden line above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last place I worked, the coding style was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return_type function_name ( type arg1, type arg2, type arg3, ... )&#xA;{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the meat of it always on one line.  So I :set scrolloff=1 and this system worked super-well.  Barely noticeable in situations where I didn't need scrolloff set at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return_type function_name ( type arg1,&#xA;                            type arg2,&#xA;                            type arg3,&#xA;                            ... )&#xA;{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I don't really want to set scrolloff=5 which would catch most situations, because in all the situations with only 1 or 2 arguments, and all the times I'm not searching for functions, I don't really want to necessarily waste that much screen real estate where my cursor could go without forcing VIM to scroll automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?  I'd prefer a straight command or setting modification, but if script or function stuff is needed, so be it.&lt;/p&gt;&#xA;" OwnerUserId="10155" LastActivityDate="2017-01-28T17:59:26.450" Title="How to [[ to top of function and see function name on first line of screen" Tags="|scrolling|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11138" PostTypeId="2" ParentId="11137" CreationDate="2017-01-26T15:22:55.107" Score="2" Body="&lt;p&gt;Here are some ideas to explore as I don't see any simple and perfect solution.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you're already using ctags, you could use it on-the-fly on the current file to obtain the line numbers where functions start. From there, knowing the name of the current function will be quite easy -- I've already written the related logic in lh-dev&lt;/li&gt;&#xA;&lt;li&gt;Once you've jumped to the open curly bracket, you could search for the closing parenthesis associated, and then jump to its opening one. i.e. &lt;code&gt;[[/)\_s*\%#{&amp;lt;cr&amp;gt;%&lt;/code&gt; -- &lt;code&gt;\%#&lt;/code&gt; matches the cursor position. This still won't manage the case where the name of the function or its return type are on another line, nor whether the function is annotated with things like &lt;code&gt;const&lt;/code&gt;, &lt;code&gt;final&lt;/code&gt;.. as it's possible in C++ -- but &lt;a href=&quot;https://vi.stackexchange.com/a/7942/626&quot;&gt;&lt;code&gt;[[&lt;/code&gt; doesn't work well in C++ either&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-01-26T15:22:55.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11139" PostTypeId="2" ParentId="11137" CreationDate="2017-01-26T15:58:26.113" Score="3" Body="&lt;p&gt;How well this works will depend on the coding styles you encounter. It seems to work for the styles used where I work and in the Vim source.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; [[ :call search('^{', 'bsW')&amp;lt;CR&amp;gt;:call search('^\K', 'bW')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It assumes that the opening braces of your C functions are always in the first column and that the next line above containing an initial keyword character (&lt;code&gt;\K&lt;/code&gt;) in the first column is the first line of the function definition. The search patterns are easily modified to suit different styles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could use the original &lt;code&gt;[[&lt;/code&gt; command instead of the first &lt;code&gt;search()&lt;/code&gt; above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; [[ [[:call search('^\K', 'bW')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mapping can be put in your &lt;code&gt;~/.vim/after/ftplugin/c.vim&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that by using &lt;code&gt;search()&lt;/code&gt;, the current search pattern is not disturbed and that the &lt;code&gt;s&lt;/code&gt; flag preserves your desired ability to go back to the previous line with &lt;code&gt;''&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="2055" LastEditDate="2017-01-26T16:14:12.900" LastActivityDate="2017-01-26T16:14:12.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11140" PostTypeId="2" ParentId="11137" CreationDate="2017-01-26T16:52:13.843" Score="3" Body="&lt;p&gt;&lt;code&gt;zz&lt;/code&gt; will center the view on the current line (with some exceptions, it won't do much if you're on the top line), without affecting &lt;code&gt;''&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could remap &lt;code&gt;[[&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap [[ [[zz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or simply type &lt;code&gt;zz&lt;/code&gt; manually whenever &lt;code&gt;[[&lt;/code&gt; alone is insufficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case centering is not enough, &lt;code&gt;zb&lt;/code&gt; will adjust the view to put the current line at the bottom, &lt;code&gt;zt&lt;/code&gt; will do the same for the top.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As mentioned &lt;a href=&quot;https://vi.stackexchange.com/a/49/2736&quot;&gt;here&lt;/a&gt; and in the docs, do be aware that &lt;code&gt;ZZ&lt;/code&gt; will save the buffer and quit, so be mindful of capslock and shift. In practice, I haven't had much trouble, but YMMV.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-01-28T17:59:26.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11142" PostTypeId="1" AcceptedAnswerId="11143" CreationDate="2017-01-26T22:21:26.423" Score="8" ViewCount="1043" Body="&lt;p&gt;I have a file that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bunch of text      trailing...&#xA;Bunch of text      trailing... &#xA;Bunch of text      trailing...&#xA;Bunch of text      trailing...&#xA;Bunch of text      trailing...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can use &lt;kbd&gt;C&lt;/kbd&gt; to remove the &lt;code&gt;trailing...&lt;/code&gt; text, but that puts me into &lt;strong&gt;insert mode&lt;/strong&gt;; Is there a way to delete to the end of the line without leaving &lt;strong&gt;normal mode&lt;/strong&gt;?&lt;/p&gt;&#xA;" OwnerUserId="9259" LastEditorUserId="2920" LastEditDate="2017-01-26T22:42:11.667" LastActivityDate="2017-01-26T22:42:11.667" Title="Delete to EOL without entering insert mode" Tags="|cut-copy-paste|normal-mode|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11143" PostTypeId="2" ParentId="11142" CreationDate="2017-01-26T22:29:20.023" Score="20" Body="&lt;p&gt;Yes. You want to use the &quot;delete&quot; operator instead of the &quot;Change&quot; operator. The delete operator is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d&amp;lt;motion&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it deletes everything that &lt;code&gt;&amp;lt;motion&amp;gt;&lt;/code&gt; moves over.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, the motion you want is &lt;code&gt;$&lt;/code&gt; which moves to the end of the current line. Of course, you may also use &lt;code&gt;D&lt;/code&gt; which is simply a shortcut for &lt;code&gt;d$&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-01-26T22:29:20.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11144" PostTypeId="1" AcceptedAnswerId="11147" CreationDate="2017-01-27T00:14:05.540" Score="4" ViewCount="992" Body="&lt;p&gt;My question is related to &lt;a href=&quot;https://askubuntu.com/questions/849693/moving-cursor-with-the-arrow-keys-in-vim-normal-mode-inserts-abcd-charactershttps://askubuntu.com/questions/849693/moving-cursor-with-the-arrow-keys-in-vim-normal-mode-inserts-abcd-characters&quot;&gt;this post&lt;/a&gt; which for some reason was closed. Here's my &lt;code&gt;.vimrc&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cpoptions=BceFs$    &quot;:compatibility flags with /usr/ucb/vi&#xA;set hlsearch&#xA;hi Search ctermfg=white  ctermbg=black cterm=NONE&#xA;hi IncSearch ctermfg=Black  ctermbg=lightyellow cterm=bold,underline,reverse&#xA;nnoremap &amp;lt;esc&amp;gt; :noh&amp;lt;return&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I search, for a pattern it is highlighted; when I hit &lt;code&gt;esc&lt;/code&gt;, the highlighting is removed, however the arrow keys insert &lt;code&gt;ABCD&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I remove the line &lt;code&gt;nnoremap &amp;lt;esc&amp;gt; :noh&amp;lt;return&amp;gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, I recover the default behavior of the arrow keys, but I lose the desired property of the &lt;code&gt;esc&lt;/code&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could somebody please explain how I can maintain the property that I want from the &lt;code&gt;esc&lt;/code&gt; key while preserving the default behavior of the arrow keys?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some posts suggest that adding the line &lt;code&gt;set nocompatible&lt;/code&gt;&#xA;to my &lt;code&gt;.vimrc&lt;/code&gt; file will fix the problem, but in my configuration, it doesn't.    Still others suggest &lt;code&gt;set term=cons25&lt;/code&gt;, which doesn't work for me either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any suggestions!&lt;/p&gt;&#xA;" OwnerUserId="4667" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.647" LastActivityDate="2017-02-11T14:45:02.480" Title="recover default behavior of arrow keys rather than having them produce ABCD, when I map &lt;esc&gt;" Tags="|key-bindings|escape|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11145" PostTypeId="1" AcceptedAnswerId="11146" CreationDate="2017-01-27T00:33:30.267" Score="3" ViewCount="1750" Body="&lt;p&gt;I'd like to construct a mapping that would replace &lt;code&gt;a   b&lt;/code&gt; with &lt;code&gt;c&lt;/code&gt; where the gap between a and b could be zero or more spaces or zero or more tabs, but not zero of both.    There have been several related postings: &lt;a href=&quot;https://stackoverflow.com/questions/4972089/how-to-create-a-regex-that-will-match-an-arbitrary-sequence-of-spaces-and-tabs&quot;&gt;This is the most promising of several postings&lt;/a&gt;, which addresses the problem in terms of regexp, but I can't get their syntax to work in vim.   Thanks for any suggestions.&lt;/p&gt;&#xA;" OwnerUserId="4667" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-01-27T01:24:11.160" Title="vim search for arbitrary combination of spaces and tabs" Tags="|regular-expression|replace|whitespace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11146" PostTypeId="2" ParentId="11145" CreationDate="2017-01-27T00:55:55.623" Score="9" Body="&lt;p&gt;If you're looking for a &lt;code&gt;substitute&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/a[ \t]\+b/c/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default regex mode doesn't see &lt;code&gt;+&lt;/code&gt; as an operator. You have to escape it to make it special.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/a\s\+b/c/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5Cs&quot;&gt;&lt;code&gt;\s&lt;/code&gt;&lt;/a&gt; is Vim's shortcut for space and tabs in regex.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2017-01-27T01:24:11.160" LastActivityDate="2017-01-27T01:24:11.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11147" PostTypeId="2" ParentId="11144" CreationDate="2017-01-27T14:20:25.523" Score="5" Body="&lt;p&gt;I'm not sure of the solution (or if there is one) but I can explain roughly what's causing the problem to occur.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you press an arrow key on your keyboard, what your terminal actually passes to Vim is a ANSI escape code, which is, literally, an &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; character followed by a sequence of other characters. The sequences for the arrow keys are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;up&lt;/kbd&gt;: &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt;&lt;kbd&gt;A&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;down&lt;/kbd&gt;: &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt;&lt;kbd&gt;B&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;right&lt;/kbd&gt;: &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;left&lt;/kbd&gt;: &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt;&lt;kbd&gt;D&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can test this out by typing the sequences quickly and watching the cursor move around (without your mapping in place).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But because of your mapping, the &lt;kbd&gt;Esc&lt;/kbd&gt; at the beginning of the escape sequence is transformed into something else, and the escape sequence is broken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not 100% sure precisely how this results in Vim entering insert mode and then inserting the final character of the escape sequence as text, but, unfortunately, this is the result. (You end up in insert mode via the &lt;code&gt;o&lt;/code&gt; in &lt;code&gt;:noh&lt;/code&gt;, but I'm not sure what happens to the rest of the sequence/mapping. hopefully someone else can explain in detail.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FWIW: This problem does not occur in GUI Vim: it's specifically a terminal issue.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-01-27T14:34:45.833" LastActivityDate="2017-01-27T14:34:45.833" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11148" PostTypeId="1" AcceptedAnswerId="11160" CreationDate="2017-01-27T18:03:20.427" Score="6" ViewCount="918" Body="&lt;p&gt;How can I set up a keybinding to delete up to the end of a sentence that ends with a period, but keep the period? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The commands &lt;code&gt;df.&lt;/code&gt;, &lt;code&gt;d)&lt;/code&gt;, and &lt;code&gt;D&lt;/code&gt; all truncate the sentence but don't keep the period. Manually, I can type &lt;code&gt;d/\.&amp;lt;ENTER&amp;gt;:noh&amp;lt;ENTER&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: I have this sentence and the cursor is at the position marked by the caret:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Scholar X's monograph is a groundbreaking study but I don't like it.&#xA;                                               ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to type one command (say, &lt;code&gt;Ds&lt;/code&gt;) and get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Scholar X's monograph is a groundbreaking study.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11041" LastEditorUserId="2920" LastEditDate="2017-01-27T18:09:33.597" LastActivityDate="2017-01-27T23:49:42.680" Title="truncate sentence: delete up to, but not including period" Tags="|key-bindings|search|cut-copy-paste|cursor-motions|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11149" PostTypeId="2" ParentId="11148" CreationDate="2017-01-27T18:07:17.827" Score="7" Body="&lt;p&gt;You had the right idea with &lt;code&gt;df.&lt;/code&gt;. Of course, &lt;code&gt;f&lt;/code&gt; goes up to the period like you noticed. If you use &lt;code&gt;t&lt;/code&gt; (mnemonic un&lt;strong&gt;t&lt;/strong&gt;il) instead, it will go forward until the period, but not to it. From &lt;code&gt;:h t&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *t*&#xA;t{char}         Till before [count]'th occurrence of {char} to the&#xA;            right.  The cursor is placed on the character left of&#xA;            {char} |inclusive|.&#xA;            {char} can be entered like with the |f| command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if your buffer is like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Scholar X's monograph is a groundbreaking study but I don't like it.&#xA;                                               ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you type &lt;code&gt;t.&lt;/code&gt;, you will be here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Scholar X's monograph is a groundbreaking study but I don't like it.&#xA;                                                                  ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt; commands mirror eachother very nicely. In fact they're pretty much identical other than &lt;code&gt;f&lt;/code&gt; moving one further.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;They can both be repeated with &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;They both have uppercase variants that move backwards instead of forwards&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-01-27T18:07:17.827" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11150" PostTypeId="2" ParentId="11148" CreationDate="2017-01-27T18:39:40.133" Score="8" Body="&lt;p&gt;&lt;code&gt;t&lt;/code&gt; and &lt;code&gt;f&lt;/code&gt; are nice when we are on the same line. If the period is on another line, we're back to &lt;code&gt;/\.&lt;/code&gt;. If you want to type &lt;code&gt;ds&lt;/code&gt;, or &lt;code&gt;cs&lt;/code&gt;, or &lt;code&gt;ys&lt;/code&gt;, ... it can be done thanks to an operator-pending mode mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:onoremap s /\./&amp;lt;cr&amp;gt;&#xA;&quot; and for visual mode, with e-1 to exclude the period.&#xA;:vnoremap s /\./e-1&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But honestly, I'll bind this to &lt;code&gt;.&lt;/code&gt; instead of &lt;code&gt;s&lt;/code&gt; as &lt;code&gt;s&lt;/code&gt; already does something in visual mode. &lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-01-27T18:39:40.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11151" PostTypeId="2" ParentId="11148" CreationDate="2017-01-27T19:00:59.740" Score="0" Body="&lt;p&gt;In your case I would do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ma)bd`a&#xA;^^^^^^^&#xA;||||||+ mark a&#xA;|||||+  line position&#xA;||||+   delete&#xA;|||+    go to end of last word&#xA;||+     start of next sentence&#xA;|+      mark a&#xA;+       set a mark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although not one command as you ask, this does if you're used to using marks roll off the fingers with reasonable ease.&lt;/p&gt;&#xA;" OwnerUserId="9020" LastActivityDate="2017-01-27T19:00:59.740" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11152" PostTypeId="2" ParentId="11148" CreationDate="2017-01-27T19:16:07.297" Score="0" Body="&lt;p&gt;After reviewing the other answers I thought of this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map ds v)2hx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Enter visual mode, go to the end of the sentence (even if on subsequent line), back up two characters to exclude the period, and delete.&lt;/p&gt;&#xA;" OwnerUserId="11041" LastActivityDate="2017-01-27T19:16:07.297" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11153" PostTypeId="2" ParentId="3740" CreationDate="2017-01-27T19:43:27.827" Score="1" Body="&lt;p&gt;For words use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,+4 s/\i\+/&amp;amp;/gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.&lt;/code&gt; denotes the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I put the following in my .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cabbrev zzcc   s/./&amp;amp;/gn&#xA;&#xA;:cabbrev zzcw   s/\i\+/&amp;amp;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,+6 zzcw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the &lt;code&gt;zzcw&lt;/code&gt; will expand to &lt;code&gt;s/\i\+/&amp;amp;/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;zzcw&lt;/code&gt; is just an odd name that won't&#xA;match anything (for me).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A side effect is the entire file is selected&#xA;and highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to be able to type multi-line tweets &#xA;in a file, make sure there weren't too many &#xA;characters, and paste the tweet in twitter.&lt;/p&gt;&#xA;" OwnerUserId="11050" LastEditorUserId="205" LastEditDate="2017-01-28T09:39:17.307" LastActivityDate="2017-01-28T09:39:17.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11154" PostTypeId="2" ParentId="4541" CreationDate="2017-01-27T21:21:17.013" Score="4" Body="&lt;p&gt;The indentation problem comes from the ftplugin, which loads a .vim file from &lt;code&gt;/usr/share/vim/vim-version-/ftplugin/-filetype-.vim&lt;/code&gt; that overrides whatever you have in your &lt;code&gt;.vimrc&lt;/code&gt; file. you can find out where that file is by running the following command inside vim &lt;code&gt;:verbose set tabstop?&lt;/code&gt;. The output will point you to the file that is overriding your configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case I was having problems with my python indentation configuration.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An easy way to solve this is to do the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a .vim folder in your home folder (if you don't have it)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim&#xA;mkdir -p after/ftplugin/&#xA;cd ~/.vim/after/ftplugin/&#xA;vim python.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add the following: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal noexpandtab shiftwidth=4 softtabstop=4 tabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Modify whatever you want in the command. Mine looks like that because I work with tabs instead of whitespaces.&lt;/p&gt;&#xA;" OwnerUserId="11051" LastEditorUserId="2920" LastEditDate="2017-01-27T23:32:38.537" LastActivityDate="2017-01-27T23:32:38.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11155" PostTypeId="1" AcceptedAnswerId="11158" CreationDate="2017-01-27T22:11:56.747" Score="2" ViewCount="1261" Body="&lt;p&gt;I like the functionality of &lt;code&gt;gf&lt;/code&gt; but for certain files I would like to run some (non-Vim) code on the file prior to displaying it in my window.  Is there a way to capture the filename under the cursor so it can be used in a shortcut?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I want to create a shortcut that would run &lt;code&gt;&amp;lt;custom_unix_script&amp;gt; &amp;lt;file&amp;gt;&lt;/code&gt; (where  is under the cursor) and display those results in a new buffer or tab.&lt;/p&gt;&#xA;" OwnerUserId="11053" LastEditorUserId="6489" LastEditDate="2017-01-27T22:59:09.360" LastActivityDate="2017-01-27T23:17:02.270" Title="How do I run a command on the file name under the cursor" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11156" PostTypeId="2" ParentId="11155" CreationDate="2017-01-27T22:28:25.890" Score="3" Body="&lt;p&gt;The filename under the cursor can be obtained with &lt;code&gt;expand(&amp;lt;cfile&amp;gt;)&lt;/code&gt;. From there you can do whatever you wish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want more precisions, you'll need to provide us more precisions.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-01-27T22:28:25.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11157" PostTypeId="1" AcceptedAnswerId="11159" CreationDate="2017-01-27T22:56:20.113" Score="1" ViewCount="464" Body="&lt;p&gt;I use different colorschemes depending on the color of my xterm.    Some of them (in particular &lt;code&gt;torte&lt;/code&gt;) set the background color to black, others leave the background color the same as the xterm color. The colorscheme is specified as an environment variable for each xterm.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also use the lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set hlsearch&#xA;hi Search ctermfg=white  ctermbg=black cterm=NONE&#xA;hi IncSearch ctermfg=Black  ctermbg=lightyellow cterm=bold,underline,reverse&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which highlight with a black background my search term.   Obviously this doesn't help me when the background is already black.    So I'd like to condition the above lines (specifically &lt;code&gt;ctermfg&lt;/code&gt;) on the value of the environment variable which specifies my color scheme.  (Specifically, whether this value is &lt;code&gt;torte&lt;/code&gt;)      Should be easy but I'm hopeless with vim syntax.    Thanks!&lt;/p&gt;&#xA;" OwnerUserId="4667" LastEditorUserId="51" LastEditDate="2017-02-11T14:44:30.503" LastActivityDate="2017-02-11T14:44:30.503" Title="how can I condition a variable on my colorscheme?" Tags="|vimscript|colorscheme|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11158" PostTypeId="2" ParentId="11155" CreationDate="2017-01-27T23:11:49.767" Score="4" Body="&lt;p&gt;In addition to @Luc Hermitte's answer of using &lt;code&gt;expand(&amp;lt;cfile&amp;gt;)&lt;/code&gt;, you can also use the &lt;code&gt;:!&lt;/code&gt; command to run a shell command. You could do something like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gf :execute &quot;!&amp;lt;custom_unix_script&amp;gt; &quot; . expand(&amp;lt;cfile&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap&lt;/code&gt;: Creates a normal mode non-recursive mapping&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:execute&lt;/code&gt;: Allows us to build the command on the fly&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:!...&lt;/code&gt;: Runs the following command in your shell&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;expand(&amp;lt;cfile&amp;gt;)&lt;/code&gt;: Uses the file-like word under your cursor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that this will do this for ALL files. If you want to filter by certain files you'll need to get a little bit more fancy. I'd recommend calling a function and doing a conditional on the output of &lt;code&gt;expand(&amp;lt;cfile&amp;gt;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h expand&lt;/code&gt;, &lt;code&gt;:h &amp;lt;cword&amp;gt;&lt;/code&gt;, &lt;code&gt;:h execute&lt;/code&gt;, and &lt;code&gt;:h !cmd&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-01-27T23:17:02.270" LastActivityDate="2017-01-27T23:17:02.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11159" PostTypeId="2" ParentId="11157" CreationDate="2017-01-27T23:30:50.160" Score="3" Body="&lt;p&gt;My advice to you is make your own color schemes that incorporate your versions of &lt;code&gt;Search&lt;/code&gt; and &lt;code&gt;IncSearch&lt;/code&gt;. But you if you really don't want to do that you could probably do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if g:colors_name == &quot;torte&quot;&#xA;...&#xA;else&#xA;...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note that this is not guarenteed to work as &lt;a href=&quot;https://stackoverflow.com/a/2419692/1924583&quot;&gt;this is only a standard&lt;/a&gt; and not a sure fire way to see your color scheme.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-01-27T23:30:50.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11160" PostTypeId="2" ParentId="11148" CreationDate="2017-01-27T23:49:42.680" Score="3" Body="&lt;p&gt;With no extra configuration involved, I would just use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;c).&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Bonus: It's repeatable with the dot command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also bonus: It works on &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;any POSIX &lt;code&gt;vi&lt;/code&gt;&lt;/a&gt; and is not Vim-specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And actually, I would use &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; (or &quot;Ctrl+[&quot; if you speak Windows) rather than actually pressing the &quot;Escape&quot; key.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2017-01-27T23:49:42.680" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11161" PostTypeId="1" AcceptedAnswerId="11166" CreationDate="2017-01-28T01:43:29.090" Score="5" ViewCount="843" Body="&lt;p&gt;I recently started looking at completions, and it says in the help if I am in insert mode and press CTRL+X CTRL+T I should be able to bring up a thesaurus of other words in a drop-down completion, but it just says &lt;code&gt;thesaurus option is empty&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I set my &lt;code&gt;thesaurus option&lt;/code&gt;, and can I do the same thing for the dictionary?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="9004" LastEditDate="2017-01-28T15:29:56.593" LastActivityDate="2017-01-28T15:29:56.593" Title="Thesaurus Option is empty?" Tags="|autocompletion|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11162" PostTypeId="1" AcceptedAnswerId="11215" CreationDate="2017-01-28T02:02:49.603" Score="8" ViewCount="275" Body="&lt;p&gt;The dictionary feature in vim allows you to use a file (for instance &lt;code&gt;/usr/share/dict/words&lt;/code&gt;) and set multiple paths within the &lt;code&gt;dict&lt;/code&gt; option to search on.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the file I'm searching on has several words with &lt;code&gt;-&lt;/code&gt; in them, and I still wish to match after the &lt;code&gt;-&lt;/code&gt; after activating autocomplete, so is there a way to make the &lt;code&gt;-&lt;/code&gt; a matched character within the &lt;code&gt;dict&lt;/code&gt; feature?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2017-02-01T07:38:49.043" Title="When using the dictionary feature in vim, can you make dashes a matching part of a word?" Tags="|autocompletion|dictionary|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11163" PostTypeId="1" CreationDate="2017-01-28T02:03:29.697" Score="2" ViewCount="154" Body="&lt;pre&gt;&lt;code&gt;:set lcs=precedes:^,eol:#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to insert a character &lt;strong&gt;^&lt;/strong&gt;  at the beginning of each line.&lt;br&gt;&#xA;Here is the result of &lt;strong&gt;:set lcs=precedes:^,eol:#&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4AbO0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4AbO0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why &lt;strong&gt;lcs=precedes:^&lt;/strong&gt; can't add a character &lt;strong&gt;^&lt;/strong&gt; in the article such as the following?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pyUuM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pyUuM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="51" LastEditDate="2017-02-11T14:42:43.907" LastActivityDate="2017-02-11T14:42:43.907" Title="Why can't add a character at the beginning of each line in the edited article?" Tags="|substitute|replace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11164" PostTypeId="2" ParentId="11163" CreationDate="2017-01-28T06:37:56.003" Score="4" Body="&lt;p&gt;To add &lt;code&gt;^&lt;/code&gt; at the beginning of each line use &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/^/^ /&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a range of lines use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ex. Lines 10-20    -   &lt;code&gt;:10,20s/^/^ /&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="9004" LastActivityDate="2017-01-28T06:37:56.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11165" PostTypeId="2" ParentId="11163" CreationDate="2017-01-28T07:00:26.410" Score="2" Body="&lt;p&gt;As per VIM Help on &lt;code&gt;listchars&lt;/code&gt;, &lt;code&gt;precedes:^&lt;/code&gt; only results in &lt;code&gt;^&lt;/code&gt; showing at the beginning of the line if &quot;&lt;code&gt;'wrap'&lt;/code&gt; is off and there is text preceding the character visible in the first column.&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;precedes&lt;/code&gt; provides an indication that the first character shown on the screen is not the first character in the line. In terms of &lt;code&gt;listchars&lt;/code&gt; options, it is the start-of-line equivalent of &lt;code&gt;extends&lt;/code&gt;, which indicates that the line continues beyond the right of the screen when &lt;code&gt;wrap&lt;/code&gt; is off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no start-of-line equivalent of &lt;code&gt;eol&lt;/code&gt; – that is, an option that would show a virtual character preceding the first character in the line. There is no need for that as you always know where the line starts (at the left edge of the screen, unless &lt;code&gt;precedes&lt;/code&gt; indicates otherwise), while you don't always know where the line ends if you have trailing whitespace.&lt;/p&gt;&#xA;" OwnerUserId="9430" LastActivityDate="2017-01-28T07:00:26.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11166" PostTypeId="2" ParentId="11161" CreationDate="2017-01-28T07:10:24.137" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;it just says &lt;code&gt;thesaurus option&lt;/code&gt; is empty. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To use the thesaurus in vim, option thesaurus has to be defined in .vimrc, pointing to the location of the thesaurus text file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set thesaurus+=&amp;lt;file&amp;gt;.txt&lt;/code&gt;   * &lt;em&gt;Replace &lt;code&gt;&amp;lt;file&amp;gt;&lt;/code&gt; with the file location&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can define your own thesaurus using &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps :  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;touch thesaurus.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;write &lt;code&gt;important,valuable,substantial,significant&lt;/code&gt; inside it and &lt;code&gt;:wq&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;link to the file in .vimrc using &lt;code&gt;set thesaurus+=/home/thesaurus.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;enjoy&lt;/strong&gt; your newly created thesaurus using &lt;code&gt;Ctrl+x Ctrl+t&lt;/code&gt; &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But...but...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Making thesaurus for every word is so laborious which is why you can download a thesaurus like &lt;a href=&quot;http://moby-thesaurus.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Moby thesaurus&lt;/a&gt; which has about 20 synonyms for every word! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/zeke/moby/blob/master/words.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;Alternate link to moby&lt;/a&gt; word.txt&lt;/p&gt;&#xA;&#xA;&lt;p&gt;link it to .vimrc and &lt;strong&gt;enjoy&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="9004" LastEditorUserId="9004" LastEditDate="2017-01-28T07:29:36.130" LastActivityDate="2017-01-28T07:29:36.130" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11167" PostTypeId="1" CreationDate="2017-01-28T13:21:04.867" Score="4" ViewCount="700" Body="&lt;p&gt;E.g., it I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!echo a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or any other &lt;code&gt;!&lt;/code&gt;, it first prints:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax error near unexpected token (&#xA;  ls() ( /* my alias */ )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then the actual command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem only happens in GVIM, not in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ubuntu 16.10, vim 7.4.1829.&lt;/p&gt;&#xA;" OwnerUserId="2038" LastEditorUserId="205" LastEditDate="2017-01-29T16:00:46.617" LastActivityDate="2017-01-30T00:29:01.153" Title="Why do exclamation ! shell commands in GVIM show error: &quot;syntax error near unexpected token (&quot; for &quot;ls() (&quot;?" Tags="|external-command|bash|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11168" PostTypeId="2" ParentId="11167" CreationDate="2017-01-28T13:21:04.867" Score="1" Body="&lt;p&gt;The default bashrc for Ubuntu, contains the following lines at the beginning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if $TERM_IS_COLOR ...&#xA;  ... &#xA;else&#xA;  alias ls=&quot;ls -F&quot;&#xA;  alias ll=&quot;ls -lF&quot;&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which I had kept.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then at some point I added:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;shellcmdflag=-ic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;code&gt;i&lt;/code&gt; to have access to my aliases from vim commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the GVIM shell cannot show colors, and only in that case the default &lt;code&gt;alias&lt;/code&gt; comes before my command, and messes things up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now, I will just remove the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias ls=&quot;ls -F&quot;&#xA;alias ll=&quot;ls -lF&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and see some raw shell color commands from time to time on GVIM.&lt;/p&gt;&#xA;" OwnerUserId="2038" LastActivityDate="2017-01-28T13:21:04.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11169" PostTypeId="2" ParentId="11056" CreationDate="2017-01-28T17:46:59.883" Score="6" Body="&lt;p&gt;Thanks to Christan Brabandt for the solution:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:e ++ff=dos filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If the file is already opened in unix file format:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:e ++ff=dos %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or just:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:e ++ff=dos&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If I change the file format option, the buffer/file is marked as modified.  This makes sense since the changes include things like using different characters in the electronic file to represent a newline.&lt;/p&gt;&#xA;" OwnerUserId="7970" LastEditorUserId="7970" LastEditDate="2020-12-02T16:29:45.797" LastActivityDate="2020-12-02T16:29:45.797" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11170" PostTypeId="1" CreationDate="2017-01-29T14:18:44.273" Score="0" ViewCount="443" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BtBVo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BtBVo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following content is extracted from &lt;a href=&quot;https://github.com/morhetz/gruvbox/blob/master/colors/gruvbox.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;gruvbox.vim&lt;/a&gt;. It indicates that green and yellow have been set for different levels of markdown header. However, I can not see the difference from the above picture.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi! link markdownH1 GruvboxGreenBold&#xA;hi! link markdownH2 GruvboxGreenBold&#xA;hi! link markdownH3 GruvboxYellowBold&#xA;hi! link markdownH4 GruvboxYellowBold&#xA;hi! link markdownH5 GruvboxYellow&#xA;hi! link markdownH6 GruvboxYellow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: Thanks for the comments below! I have confirmed that &lt;a href=&quot;https://github.com/plasticboy/vim-markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-markdown&lt;/a&gt; caused this, what should I do next?&lt;/p&gt;&#xA;" OwnerUserId="10269" LastEditorUserId="10269" LastEditDate="2017-01-30T09:35:57.530" LastActivityDate="2017-01-30T09:35:57.530" Title="Why the language-specific optimization in the vim colorscheme is seemingly of no effect?" Tags="|colorscheme|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11171" PostTypeId="1" AcceptedAnswerId="11172" CreationDate="2017-01-29T15:51:55.330" Score="2" ViewCount="1344" Body="&lt;p&gt;I'd like to add commands in my &lt;code&gt;.vimrc&lt;/code&gt; programmatically in a function. For example, instead of hardcoding commands like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! MyCommand echom &quot;My command&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd prefer to add them in a simple function like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddCommands()&#xA;&#xA;  for commandName in [&quot;One&quot;, &quot;Two&quot;, &quot;Three&quot;]&#xA;    &quot; TODO: Add a command with the given name that prints something&#xA;  endfor&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I add the commands &lt;code&gt;One&lt;/code&gt;, &lt;code&gt;Two&lt;/code&gt;, and &lt;code&gt;Three&lt;/code&gt; using the for loop above?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Once I got that working, I want to read a file containing file paths and automatically create commands that open those files. I call that file &quot;bookmarks file&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A line in the bookmarks file looks like this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;BookmarkName: /path/to/bookmarked/file.txt&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here's what I got so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Read file paths from our bookmark file &#xA;&quot; and create a command for each bookmark that, when executed, opens the&#xA;&quot; file in a new tab.&#xA;function! ReadBookmarks()&#xA;  let bookmarks = readfile(fnameescape($BOOKMARKS_FILE))&#xA;  let bookmarkSeparator = &quot;: &quot;&#xA;  for bookmark in bookmarks&#xA;    let nameAndPath = split(bookmark, bookmarkSeparator)&#xA;    let name = nameAndPath[0]&#xA;    let path = nameAndPath[1]&#xA;&#xA;    &quot; TODO: Add a command that opens the file in a new tab&#xA;  endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8558" LastEditorUserId="8558" LastEditDate="2017-01-30T17:20:22.913" LastActivityDate="2017-01-31T10:12:03.557" Title="Define commands programmatically" Tags="|vimscript|" AnswerCount="1" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11172" PostTypeId="2" ParentId="11171" CreationDate="2017-01-29T15:51:55.330" Score="7" Body="&lt;h1&gt;With &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/28.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;execute&lt;/code&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This does the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddCommands()&#xA;&#xA;  for commandName in [&quot;One&quot;, &quot;Two&quot;, &quot;Three&quot;]&#xA;    &quot; Adds a command that, when executed, prints its own name&#xA;    execute &quot;command! &quot; . commandName . &quot; echom \&quot;&quot; . commandName . &quot;\&quot;&quot;&#xA;  endfor&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I can call, for example, &lt;code&gt;:Three&lt;/code&gt; which will print &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Three&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The missing lines in the example involving the bookmarks file are thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let openFileCommand = &quot;command! &quot; . name . &quot; :tabe &quot; . path&#xA;execute openFileCommand&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The whole example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReadBookmarks()&#xA;  let bookmarks = readfile(fnameescape($BOOKMARKS_FILE))&#xA;  let bookmarkSeparator = &quot;: &quot;&#xA;  for bookmark in bookmarks&#xA;    let nameAndPath = split(bookmark, bookmarkSeparator)&#xA;    let name = nameAndPath[0]&#xA;    let path = nameAndPath[1]&#xA;&#xA;    &quot; This adds a command that opens the file in a new tab&#xA;    let openFileCommand = &quot;command! &quot; . name . &quot; :tabe &quot; . path&#xA;    execute openFileCommand&#xA;  endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8558" LastEditorUserId="8558" LastEditDate="2017-01-31T10:12:03.557" LastActivityDate="2017-01-31T10:12:03.557" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11173" PostTypeId="2" ParentId="11167" CreationDate="2017-01-29T15:59:43.797" Score="9" Body="&lt;p&gt;Instead of adding &lt;code&gt;-i&lt;/code&gt; to &lt;code&gt;shellcmdflags&lt;/code&gt; and reading your entire &lt;code&gt;.bashrc&lt;/code&gt; just for loading aliases, keep your aliases in a separate file, like &lt;code&gt;~/.bash_aliases&lt;/code&gt; for Ubuntu, and add to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $BASH_ENV = &quot;~/.bash_aliases&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Invoked-non_002dinteractively&quot; rel=&quot;noreferrer&quot;&gt;the bash manual&lt;/a&gt;, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h3&gt;Invoked non-interactively&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;When Bash is started non-interactively, to run a shell script, for&#xA;  example, it looks for the variable &lt;code&gt;BASH_ENV&lt;/code&gt; in the environment,&#xA;  expands its value if it appears there, and uses the expanded value as&#xA;  the name of a file to read and execute. Bash behaves as if the&#xA;  following command were executed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [ -n &quot;$BASH_ENV&quot; ]; then . &quot;$BASH_ENV&quot;; fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;but the value of the &lt;code&gt;PATH&lt;/code&gt; variable is not used to search for the&#xA;  filename.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since Vim still invokes bash non-interactively, bash doesn't enable aliases. You can do so by &lt;a href=&quot;https://unix.stackexchange.com/a/1498/70524&quot;&gt;adding&lt;/a&gt; to the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;shopt -s expand_aliases&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is harmless in an interactive shell, so adding it won't cause problems.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2017-01-30T00:29:01.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11174" PostTypeId="1" AcceptedAnswerId="11176" CreationDate="2017-01-29T17:35:03.007" Score="3" ViewCount="1438" Body="&lt;p&gt;I am trying to make a function that creates a new line and hits the tab key (aka 2 spaces / 4 spaces; what ever is set).  I can do it easily with a keybinding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;leader&amp;gt;ind &amp;lt;esc&amp;gt;o&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I try to execute this from a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Indent_New_Line()&#xA;  execute &quot;normal! o&amp;lt;tab&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;:inoremap &amp;lt;leader&amp;gt;ind &amp;lt;esc&amp;gt;:call Indent_New_Line()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; gets printed literally instead of a tab char:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|def foo&#xA;|&amp;lt;tab&amp;gt;&#xA;|end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas as to why this is happening?  I couldn't find very much about this..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated, Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11072" LastActivityDate="2017-01-29T17:43:58.333" Title="Execute normal is inserting &quot;&lt;tab&gt;&quot; instead of hitting tab key" Tags="|vimscript|snippets|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11176" PostTypeId="2" ParentId="11174" CreationDate="2017-01-29T17:43:58.333" Score="4" Body="&lt;p&gt;All you need to do is to insert a &lt;code&gt;\&lt;/code&gt; before the &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the code will look like this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal! o\&amp;lt;tab&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10378" LastActivityDate="2017-01-29T17:43:58.333" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11177" PostTypeId="1" CreationDate="2017-01-30T04:24:58.150" Score="2" ViewCount="1627" Body="&lt;p&gt;I have tried several things to set the keybinding &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Q&lt;/kbd&gt; to exit Vim without saving any changes (i.e., what is normally bound to &lt;code&gt;:qa!&lt;/code&gt;). I have tried adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-q&amp;gt; &amp;lt;esc&amp;gt;:qa!&amp;lt;cr&amp;gt;               &quot; quit discarding changes&#xA;nnoremap &amp;lt;C-q&amp;gt; :qa!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to my &lt;code&gt;~/.vimrc&lt;/code&gt; based on &lt;a href=&quot;https://unix.stackexchange.com/a/241784/27613&quot;&gt;this answer&lt;/a&gt; on Unix &amp;amp; Linux StackExchange. This failed as when I pressed &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Q&lt;/kbd&gt; nothing happened. I have also tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-Q&amp;gt; :qa!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-Q&amp;gt; &quot;:qa!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;neither worked. Any ideas what I need to do to set this keybinding? If it is at all relevant my platform is Fedora 25 and I installed the latest Vim from my own Open Build Service repository &amp;mdash; &lt;a href=&quot;https://build.opensuse.org/package/show/home:fusion809/vim-redhat&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://build.opensuse.org/package/show/home:fusion809/vim-redhat&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11076" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2017-03-01T06:32:31.167" Title="How to exit Vim, without saving changes using the shortcut Ctrl-Q?" Tags="|key-bindings|vimrc|quit|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11178" PostTypeId="2" ParentId="11177" CreationDate="2017-01-30T05:33:29.443" Score="2" Body="&lt;p&gt;This is what fixed this problem for me, I unknowingly had  bound to something else in my &lt;code&gt;~/.vimrc&lt;/code&gt;, when I removed it and added:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent !stty -ixon &amp;gt; /dev/null 2&amp;gt;/dev/null&#xA;map &amp;lt;C-Q&amp;gt; :qa!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to my &lt;code&gt;~/.vimrc&lt;/code&gt; file this keybinding worked properly.&lt;/p&gt;&#xA;" OwnerUserId="11076" LastActivityDate="2017-01-30T05:33:29.443" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11179" PostTypeId="1" AcceptedAnswerId="11184" CreationDate="2017-01-30T06:48:48.807" Score="6" ViewCount="732" Body="&lt;p&gt;I want to comment out a piece of code. For instance this snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar&#xA;foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should become this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!--foo&#xA;bar&#xA;foo--&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I type the following sequence:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vap:norm '&amp;lt;i&amp;lt;!--&amp;lt;C-v&amp;gt;&amp;lt;Esc&amp;gt;'&amp;gt;A--&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This give me the following result, which is unexpected for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!--&amp;lt;!--&amp;lt;!--foo&#xA;bar&#xA;foo--&amp;gt;--&amp;gt;--&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand that a Normal mode command on a range is executed on each line of this range, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: is it possible to execute the Normal mode command only on the first/last line of a range and if so, how can I do this?&lt;/p&gt;&#xA;" OwnerUserId="11077" LastEditorUserId="1841" LastEditDate="2017-01-30T07:33:57.460" LastActivityDate="2017-02-05T18:05:49.020" Title="Is it possible to execute a Normal mode command only on the first/last line of a range?" Tags="|command-line|normal-mode|range|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11180" PostTypeId="2" ParentId="11179" CreationDate="2017-01-30T07:25:20.790" Score="2" Body="&lt;p&gt;When surrounding with this trick, always start by appending, then you can insert the head.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover, I'd play with visual mode for this, no range, no &lt;code&gt;:normal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &quot; untested&#xA; vnoremap &amp;lt;buffer&amp;gt; µ `&amp;gt;a--&amp;gt;&amp;lt;esc&amp;gt;`&amp;lt;i&amp;lt;!--&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another approach (that needs to modify one register) is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; vnoremap &amp;lt;buffer&amp;gt; µ s&amp;lt;!--&amp;lt;c-r&amp;gt;=&quot;--&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-01-30T10:02:04.053" LastActivityDate="2017-01-30T10:02:04.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11182" PostTypeId="2" ParentId="11170" CreationDate="2017-01-30T08:12:50.853" Score="2" Body="&lt;p&gt;It looks like one of your plugins ships a modified markdown syntax file that defines different highlighting groups. Here is a snippet that shows you the highlighting group(s) that the word under the cursor falls under. Find out which highlighting group it is and overwrite that one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure, but the order also might be important. You might want to make sure you call the &lt;code&gt;hi&lt;/code&gt; commands after your colorscheme.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Show highlighting group for current word&#xA;nmap &amp;lt;leader&amp;gt;h :call &amp;lt;SID&amp;gt;SynStack()&amp;lt;CR&amp;gt;&#xA;function! &amp;lt;SID&amp;gt;SynStack()&#xA;    if !exists(&quot;*synstack&quot;)&#xA;        return&#xA;    endif&#xA;    echo map(synstack(line('.'), col('.')), 'synIDattr(v:val,&quot;name&quot;)')&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11079" LastActivityDate="2017-01-30T08:12:50.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11183" PostTypeId="1" AcceptedAnswerId="11185" CreationDate="2017-01-30T10:35:20.460" Score="4" ViewCount="214" Body="&lt;p&gt;I have a set of 10 line numbers, n1, n2 ,..., n10 in a code of 1000+ lines.&#xA;I need to jump from one line to another.&#xA;My normal practice is to do &lt;code&gt;n1G&lt;/code&gt;, &lt;code&gt;n2G&lt;/code&gt;... till the set is complete.&#xA;It takes about 5 seconds to see if the specific line is error free.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to automate this by jumping into the lines one after the other after 5 seconds stay on each line. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible for vim to jump to a series of predefined line numbers after x seconds?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10566" LastActivityDate="2017-01-30T12:43:57.997" Title="Jump to a series of line numbers one by one after a stay of x seconds at each line" Tags="|cursor-movement|autocmd|jumplist|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11184" PostTypeId="2" ParentId="11179" CreationDate="2017-01-30T10:56:34.643" Score="4" Body="&lt;p&gt;As I said in the comments I strongly recommend a plugin like &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;nerdcommenter&lt;/a&gt; or &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-commentary&lt;/a&gt; to do stuff like this because they are well tested and handle a lot of corner cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you want to do it by yourself a solution could be the following. First create a function which takes two numbers as arguments and uses these numbers as the lines on which it should make the substitutions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HTMLCommentFunction(line1, line2)&#xA;    execute &quot;normal! &quot; . a:line1 . &quot;GI&amp;lt;!--&quot;&#xA;    execute &quot;normal! &quot; . a:line2 . &quot;GA--&amp;gt;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then create a command accepting a range and which will send the lines of this range to your function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range HTMLComment call HTMLCommentFunction(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you're done you can then use &lt;code&gt;:'&amp;lt;,'&amp;gt;HTMLComment&lt;/code&gt; to get your result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And to make all of it easier to use you can create the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;key&amp;gt; :HTMLComment&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can just press you key in visual mode to get your comment.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-01-30T10:56:34.643" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11185" PostTypeId="2" ParentId="11183" CreationDate="2017-01-30T11:33:10.297" Score="5" Body="&lt;p&gt;There is &lt;code&gt;:sleep&lt;/code&gt; command (&lt;code&gt;:h sleep&lt;/code&gt; or &lt;code&gt;:h gs&lt;/code&gt;). Using that command it's possible to loop over given array of line numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:line_list = [ 5, 10, 15 ]&#xA;let g:line_list_sleep = 5 &quot; in seconds, add m suffix to go miliseconds&#xA;&#xA;function LinePlaylist()&#xA;  for x in g:line_list&#xA;    execute &quot;normal &quot; . x . &quot;G&quot;&#xA;    redraw!&#xA;    echom getline('.')&#xA;    execute &quot;sleep &quot; . g:line_list_sleep&#xA;  endfor&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will go through all lines defined in &lt;code&gt;g:line_list&lt;/code&gt; array. You can also set the interval using &lt;code&gt;g:line_list_sleep&lt;/code&gt;. Line should be visible both by cursor position and it will be echo'ed (you can remove echo if you don't like/need it). You can always break the loop with &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;.&#xA;Adding above excerpt to your &lt;code&gt;.vimrc&lt;/code&gt; makes it possible to use &lt;code&gt;:call LinePlaylist()&lt;/code&gt; to run it.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2017-01-30T11:56:15.070" LastActivityDate="2017-01-30T11:56:15.070" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11186" PostTypeId="2" ParentId="11183" CreationDate="2017-01-30T12:43:57.997" Score="4" Body="&lt;p&gt;If you have vim8 you might want to play with the new timers feature. The difference with @grodzik solution is that timers are asynchronous meaning that you can still use Vim will the cursor is moving. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to add the following to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GoToLines()&#xA;    &quot; Indexes of the lines to read&#xA;    let lines = [1, 2, 3, 4, 5, 10]&#xA;    &quot; Time between to changes of lines in miliseconds&#xA;    let delay = 5000&#xA;    &quot; Will be used to delay each line change&#xA;    let repeat = 0&#xA;&#xA;    &quot; Go to each lines&#xA;    for line in lines&#xA;        call timer_start(repeat * delay, function('GoToLineTimer', [line]))&#xA;        let repeat += 1&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First a function which contains the list of the lines to visit (you can modify that so it take the list as an argument). For each line contained in the list the function will create a timer with a delay. This timer will call the following function which only changes the line of the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GoToLineTimer(line, timer)&#xA;    execute 'normal! ' .a:line . 'G'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then simply use &lt;code&gt;:call GoToLines()&lt;/code&gt; or create a mapping which will call the function for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to stop the timers and keep your cursor on the current line you can use &lt;code&gt;:call timer_stopall()&lt;/code&gt; to stop all of the timers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Of course this solution will only work with &lt;code&gt;vim8&lt;/code&gt; and the &lt;code&gt;+timers&lt;/code&gt; feature&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-01-30T12:43:57.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11187" PostTypeId="1" CreationDate="2017-01-30T13:20:35.547" Score="0" ViewCount="727" Body="&lt;p&gt;I installed gvim 8.0 on Windows 10. And I find that there's no item about vim in the list of environment variables. Look at the pictures below. But I can still run &quot;vim&quot; and &quot;gvim&quot; in cmd and powershell &lt;strong&gt;without&lt;/strong&gt; entering the Fully Qualified Name of vim or gvim. Why can I do this? How does Windows know where to find vim.exe and launch it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kFluV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kFluV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/g0yeq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/g0yeq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11082" LastEditorUserId="205" LastEditDate="2017-01-30T13:52:18.153" LastActivityDate="2017-01-30T13:52:18.153" Title="Why can I still run &quot;vim&quot; in cmd and powershell without put the directory of vim in the list of environment variables on windows 10?" Tags="|microsoft-windows|startup|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11188" PostTypeId="2" ParentId="11187" CreationDate="2017-01-30T13:50:18.540" Score="1" Body="&lt;p&gt;I get the answer! When I installed gvim80.exe, it created several *.bat files(such as vim.bat, gvim.bat ...) in C:\Windows. Since C:\Windows is in the list of PATH, I can run vim without its FQN.&lt;/p&gt;&#xA;" OwnerUserId="11082" LastActivityDate="2017-01-30T13:50:18.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11189" PostTypeId="1" CreationDate="2017-01-30T14:50:20.373" Score="0" ViewCount="337" Body="&lt;p&gt;I am searching a pattern with &lt;code&gt;/pattern&lt;/code&gt; starting from a random line number &lt;code&gt;ln1&lt;/code&gt;. Sometimes I kept on going with &lt;kbd&gt;n&lt;/kbd&gt; without realizing that I completed searching the whole file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the premise, I would like vim to print a message similar to something like &lt;code&gt;search 1 loop completed&lt;/code&gt;, once I reach &lt;code&gt;ln1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I edit my &lt;code&gt;.vimrc&lt;/code&gt; to add this feature?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10566" LastActivityDate="2017-01-30T14:53:56.923" Title="Notify when one search loop is complete" Tags="|vimrc|search|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11190" PostTypeId="2" ParentId="11189" CreationDate="2017-01-30T14:53:56.923" Score="2" Body="&lt;p&gt;Check if you have &lt;code&gt;s&lt;/code&gt; in &lt;code&gt;:set shortmess?&lt;/code&gt;. By default it shouldn't be there I think. If you happen to have it there, then add to &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shortmess-=s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;code&gt;:h 'shortmess'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-01-30T14:53:56.923" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11191" PostTypeId="2" ParentId="6615" CreationDate="2017-01-30T15:58:34.923" Score="-1" Body="&lt;p&gt;Petrie's answer is only partially true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By partially I mean, take for example, &lt;code&gt;bdelete&lt;/code&gt;. Supposedly, as stated by vim's manual, it states that by providing a number &lt;code&gt;N&lt;/code&gt; identifying a buffer (as in using the number provided by &lt;code&gt;ls&lt;/code&gt; or &lt;code&gt;ls!&lt;/code&gt;), you can delete a buffer in vimscript. Well that is only true, if you provide a literal number, like &lt;code&gt;bdelete 6&lt;/code&gt;, you will delete buffer 6. However, if you pass a variable to &lt;code&gt;bdelete&lt;/code&gt; that contains the buffer number to delete like, &lt;code&gt;bdelete g:buffer_to_delete&lt;/code&gt; (where &lt;code&gt;g:buffer_to_delete=6&lt;/code&gt;), it will not work! In fact in vimscript you can not write &lt;code&gt;:bdelete g:buffer_to_delete&lt;/code&gt; or &lt;code&gt;call bdelete g:buffer_t_delete&lt;/code&gt;. However, you can treat the command as a string and execute it like so, &lt;code&gt;exec &quot;bdelete&quot;.g:buff_to_delete&lt;/code&gt;, that will work!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus vimscript &lt;code&gt;call&lt;/code&gt; DOES NOT invoke user-defined or internal functions all the time. There are situations where &lt;code&gt;exec&lt;/code&gt; must be used because &lt;code&gt;call&lt;/code&gt; doesn't function as it is supposed to. This situation has been around for many years and still lingers today with vim 8.0. So be aware and follow the rule:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can't make the &lt;code&gt;call&lt;/code&gt; try &lt;code&gt;exec&lt;/code&gt;uting instead. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not clear when you can use &lt;code&gt;call&lt;/code&gt; and when you must use &lt;code&gt;exec&lt;/code&gt; for I have found the above situation occurring erratically. So start with &lt;code&gt;call&lt;/code&gt; then if it fails, &lt;code&gt;exec&lt;/code&gt; will work, as of yet I haven't found an instance when it doesn't, fortunately!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note to Vimscript World: there are other nuances like the above that should be spelled out clearly in the vim documentation, or at least fixed in the vim code! I and many others I know have spent many many hours in years passed wasting time figuring out these nuances. I thought Emacs was truly terrible in this regard, but Vim too has its own undisclosed idiosyncrasies.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And before you say it....yes I have provided these issues years ago. I am only writing this now, because I feel a lot of sympathy for Yossi for going through this problem, because I had the same problem many years ago. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yossi: keep an open mind with Vimscript it lacks quite a bit of common-sense, but if you keep your wits about yourself you can get much for your time spent on vim, than you would with say with Emacs! Trust me, I've been using Emacs and (G)Vi(m) for 30 years now. (G)Vi(m) is the way to go...Emacs is fast dying, and rightly so :-( {Hey Stallman, don't you think its time to admit Emacs sux? Why go to all the trouble and create Evil, when Vim is free?}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep pushing Yossi! It will pay off!&#xA;(Yes everybody, I know this reply is a year late, but I can bet you there are many other Yossi's out there)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's hope, Vim 9.0, will do a better job than Vim 8.0. (I hope I will be still alive to see 9.0!)&lt;/p&gt;&#xA;" OwnerUserId="11087" LastEditorUserId="1841" LastEditDate="2017-01-30T17:42:10.857" LastActivityDate="2017-01-30T17:42:10.857" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11192" PostTypeId="2" ParentId="7464" CreationDate="2017-01-30T16:44:55.897" Score="2" Body="&lt;p&gt;I added this to my .vimrc and now it works as desired:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Automatically set current directory to browsing directory.                                                      &#xA;let g:netrw_keepdir=0 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#g:netrw_keepdir&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#g:netrw_keepdir&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11088" LastActivityDate="2017-01-30T16:44:55.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11193" PostTypeId="1" CreationDate="2017-01-30T17:35:23.150" Score="1" ViewCount="239" Body="&lt;p&gt;Currently I am using GVim on Cygwin 64-Bit Windows 7 with Pyclewn plugin for debugging C/C++ Application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever the balloon eval tooltip pops-up the Color difference between the balloon background the underlying text content is too small to be easily readable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried setting the:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight Tooltip guibg=white&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as mentioned in the gvim help&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help gui-resources&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But to no-avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Kindly find the screenshot below of the balloon eval(marked in &lt;strong&gt;Red&lt;/strong&gt; Circle):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/TKwrs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TKwrs.png&quot; alt=&quot;GVim Balloon Eval&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11089" LastEditorUserId="11089" LastEditDate="2017-02-01T06:25:45.930" LastActivityDate="2017-02-01T06:25:45.930" Title="GVim Cygwin Ballooneval color scheme" Tags="|colorscheme|cygwin|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11194" PostTypeId="1" CreationDate="2017-01-30T18:50:27.990" Score="6" ViewCount="3430" Body="&lt;p&gt;I recently restored my computer to a clean install and copied over my dot files. MacVim behaves quite a bit differently than my previous install.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One main thing is that NerdTree no longer collapses all the sub directories and sets the cursor to the current root. After opening a few files, it makes it a huge pain to navigate NerdTree as there are several sub directories open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have scoured the backup of my computer for any additional config files for vim and NerdTree and haven't found anything. I've also searched extensively through the web to try and solve my issue but it seems impossible to find anything other than the most popular NerdTree questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I have been able to find the NerdTree commands that do what I want, but I don't know how to automate it for when I open NerdTree.&lt;/strong&gt; Also, I open NerdTree using the vim &lt;code&gt;e[edit]&lt;/code&gt; command to the current directory. Something like &lt;code&gt;:e.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is what I would like to happen when I open up NerdTree &lt;code&gt;:e.&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt; - go to root&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;X&lt;/code&gt; - close all children recurs­ively&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;R&lt;/code&gt; - refresh current root (Not sure if this is necessary)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I haven't installed any additional plugins since my previous install. The only one that I have that I could think would have an affect on the behaviour of NerdTree is &lt;code&gt;airblade/vim-rooter&lt;/code&gt;, which keeps my root directory at the root of a git repo I am in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using MacVim v8.0.237&lt;/li&gt;&#xA;&lt;li&gt;Mac OS Sierra&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11091" LastActivityDate="2017-01-31T00:39:05.207" Title="Collapse all directories in NerdTree by default" Tags="|macvim|plugin-nerdtree|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11195" PostTypeId="1" AcceptedAnswerId="11196" CreationDate="2017-01-30T23:01:51.863" Score="3" ViewCount="2474" Body="&lt;p&gt;I'd like to set some file-type dependent mappings to quickly run files. For example, I have some mappings like these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;z :w&amp;lt;CR&amp;gt; :!clear; gcc %; ./a.out&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;z :w&amp;lt;CR&amp;gt; :!clear; g++ %; ./a.out&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;z :w&amp;lt;CR&amp;gt; :!clear; ruby %&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I set each mapping to its corresponding file type?&lt;/p&gt;&#xA;" OwnerUserId="4901" LastEditorUserId="1841" LastEditDate="2017-01-31T08:20:15.893" LastActivityDate="2017-01-31T08:20:15.893" Title="Set mappings depending on file type" Tags="|key-bindings|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11196" PostTypeId="2" ParentId="11195" CreationDate="2017-01-30T23:10:45.063" Score="4" Body="&lt;p&gt;You can use the FileType autocmd.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType c    nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;z :w&amp;lt;CR&amp;gt; :!clear; gcc %; ./a.out&amp;lt;cr&amp;gt;&#xA;autocmd FileType cpp  nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;z :w&amp;lt;CR&amp;gt; :!clear; g++ %; ./a.out&amp;lt;cr&amp;gt;&#xA;autocmd FileType ruby nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;z :w&amp;lt;CR&amp;gt; :!clear; ruby %&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h autocmd&lt;/code&gt; and &lt;code&gt;:h FileType&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-01-30T23:10:45.063" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11198" PostTypeId="1" CreationDate="2017-01-30T23:46:43.720" Score="2" ViewCount="299" Body="&lt;p&gt;In IntellijIDEA, if my cursor is at the start of a line, instead of backspace deleting one indent or whitespace at a time, it deletes all tabs and whitespace and moves the cursor to the end of the previous line. How can I setup this behaviour in Vim?&lt;/p&gt;&#xA;" OwnerUserId="4901" LastActivityDate="2017-01-31T08:17:20.843" Title="If cursor is at start of line, make backspace delete any indents or whitespace and move cursor to end of previous line" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11199" PostTypeId="1" AcceptedAnswerId="11202" CreationDate="2017-01-30T23:57:23.657" Score="4" ViewCount="2434" Body="&lt;p&gt;My &lt;code&gt;:set tags?&lt;/code&gt; option says: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./tags;,tags,./vimtags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does the semicolon after the &lt;code&gt;./tags&lt;/code&gt; mean?&#xA;When I use &lt;code&gt;vim -u NONE&lt;/code&gt; it is set to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./tags,tags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I grep my packages to see what plugins set it to include the semicolon I see that two do it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim-sensible&lt;/code&gt; by tpope does this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('path_extra')&#xA;  setglobal tags-=./tags tags-=./tags; tags^=./tags;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;vim-easytags&lt;/code&gt; also seems to set it to &lt;code&gt;./tags;&lt;/code&gt; by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this? I reckon the authors of these libraries know what they are doing. However &lt;code&gt;:h 'tags'&lt;/code&gt; doesn't help me at all.&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2017-01-31T01:01:11.090" Title="What does a semicolon mean in the tags option" Tags="|tags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11200" PostTypeId="1" AcceptedAnswerId="11208" CreationDate="2017-01-31T00:10:00.047" Score="5" ViewCount="2250" Body="&lt;p&gt;I'm having a problem with pasting on MacOS Sierra.&#xA;When I copy text with newlines, I can paste it in a terminal without issue.&#xA;e.g.:&#xA;Text to be copied:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo 'Foo'&#xA;echo 'Bar'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;result from terminal (same in iTerm, Term using both bash and zsh):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[23:38:29] ~ $ echo 'Foo'&#xA;echo 'Bar'&#xA;Foo&#xA;Bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;result from vim within terminal&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo 'Foo'^Mecho 'Bar'^MFoo^MBar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you see, the carriage return is interpreted as a literal string.&#xA;I have tried in &lt;code&gt;pastemode&lt;/code&gt; and &lt;code&gt;fileformat=unix&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; can be found at &lt;a href=&quot;https://github.com/zsoobhan/configs/blob/feature/osx/vimrc&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/zsoobhan/configs/blob/feature/osx/vimrc&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan 24 2017 14:45:56)&#xA;MacOS X (unix) version&#xA;Included patches: 1-225&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     -tcl&#xA;-balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;-browse          -footer          +multi_byte      +terminfo&#xA;++builtin_terms  +fork()          +multi_lang      +termresponse&#xA;+byte_offset     -gettext         -mzscheme        +textobjects&#xA;+channel         -hangul_input    +netbeans_intg   +timers&#xA;+cindent         +iconv           +num64           +title&#xA;-clientserver    +insert_expand   +packages        -toolbar&#xA;+clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        +perl            +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       +python          +vreplace&#xA;+cscope          +lispindent      -python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con      -lua             +rightleft       +writebackup&#xA;+diff            +menu            +ruby            -X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;-dnd             +modify_fname    +signs           -xim&#xA;-ebcdic          +mouse           +smartindent     -xpm&#xA;+emacs_tags      -mouseshape      +startuptime     -xsmp&#xA;+eval            +mouse_dec       +statusline      -xterm_clipboard&#xA;+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save&#xA;+extra_search    -mouse_jsbterm   +syntax&#xA;+farsi           +mouse_netterm   +tag_binary&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework Cocoa   -mmacosx-version-min=10.12 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.24.0_1/lib/perl5/5.24.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/opt/python/Frameworks -framework Python   -lruby.2.4.0 -lobjc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated &lt;/p&gt;&#xA;" OwnerUserId="5653" LastActivityDate="2017-01-31T14:54:10.820" Title="Pasting from cliboard in osx returns ^M instead of newline" Tags="|cut-copy-paste|macos|iterm2|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11202" PostTypeId="2" ParentId="11199" CreationDate="2017-01-31T01:01:11.090" Score="7" Body="&lt;p&gt;The answer for this is &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#file-searching&quot;&gt;&lt;code&gt;:h file-searching&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;11. File Searching                                      file-searching&#xA;&#xA;{not available when compiled without the |+path_extra| feature}&#xA;&#xA;The file searching is currently used for the 'path', 'cdpath' and 'tags'&#xA;options, for finddir() and findfile().  Other commands use wildcards&#xA;which is slightly different.&#xA;&#xA;There are three different types of searching:&#xA;&#xA;1) Downward search:                                     starstar&#xA;   Downward search uses the wildcards '*', '**' and possibly others&#xA;   supported by your operating system.  '*' and '**' are handled inside Vim,&#xA;   so they work on all operating systems.&#xA;&#xA;...&#xA;&#xA;2) Upward search:&#xA;   Here you can give a directory and then search the directory tree upward for&#xA;   a file.  &lt;strong&gt;You could give stop-directories to limit the upward search&lt;/strong&gt;.  &lt;strong&gt;The&#xA;   stop-directories are appended&lt;/strong&gt; to the path (for the 'path' option) or &lt;strong&gt;to&#xA;   the filename (for the 'tags' option) with a ';'&lt;/strong&gt;.  If you want several&#xA;   stop-directories separate them with ';'.  If you want no stop-directory&#xA;   (&quot;search upward till the root directory) just use ';'. &#xA;        /usr/include/sys;/usr&#xA;   will search in: &#xA;           /usr/include/sys&#xA;           /usr/include&#xA;           /usr&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, with this &lt;code&gt;./tags;&lt;/code&gt;, if Vim finds a tags file in the directory of the current file, it won't look any further.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-01-31T01:01:11.090" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11205" PostTypeId="2" ParentId="11198" CreationDate="2017-01-31T08:10:35.520" Score="2" Body="&lt;p&gt;This should do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyDeleteAction()&#xA;    &quot; Get the current position and the position of the first char&#xA;    let cursorPosition=getpos(&quot;.&quot;)&#xA;    normal ^&#xA;    let firstChar=getpos(&quot;.&quot;)&#xA;&#xA;    &quot; If the cursor is before the first char, go to the upper line&#xA;    if cursorPosition[2] &amp;lt; firstChar[2]&#xA;        normal! y$0Dk$&#xA;        let cursorPosition=getpos(&quot;.&quot;)&#xA;        normal! p&#xA;    endif&#xA;&#xA;    &quot; Go back to the correct position&#xA;    call setpos('.', cursorPosition)&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;backspace&amp;gt; &amp;lt;backspace&amp;gt;&amp;lt;Esc&amp;gt;:call MyDeleteAction()&amp;lt;CR&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last line remaps &lt;kbd&gt;backspace&lt;/kbd&gt; in insert mode so that it will first delete a character as usual and then call &lt;code&gt;MyDeleteAction()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;MyDeleteAction()&lt;/code&gt; tests if the cursor is on the first character of the line:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If it is not the cursor stays at the same position&lt;/li&gt;&#xA;&lt;li&gt;If it is we yank the end of the current line, delete the current line, paste the yanked end of the line to the upper line and put the cursor before the pasted text.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The main drawback here is that the function will change your unnamed register when it yanks the line so you might want to add a mechanism to save the state of this register and restore it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-01-31T08:17:20.843" LastActivityDate="2017-01-31T08:17:20.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11206" PostTypeId="1" AcceptedAnswerId="11207" CreationDate="2017-01-31T10:22:59.623" Score="1" ViewCount="287" Body="&lt;p&gt;I'm trying to make a mapping that inserts an empty line below without moving the cursor and to make this repeatable with &lt;code&gt;repeat.vim&lt;/code&gt;. I have modeled this from &lt;a href=&quot;http://vimcasts.org/episodes/creating-repeatable-mappings-with-repeat-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimcasts&lt;/a&gt;. To get back to the original position after the &lt;code&gt;O&lt;/code&gt;/&lt;code&gt;o&lt;/code&gt; operation I use mark &lt;code&gt;e&lt;/code&gt;. I have the code below in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why doesn't the code below work?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Insert empty line above, repeatable&#xA; nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;EmptyLineAbove meO&amp;lt;ESC&amp;gt;`e :call repeat#set(&quot;\                      &#xA; &amp;lt;Plug&amp;gt;EmptyLineAbove&quot;)&amp;lt;CR&amp;gt;&#xA; nnoremap gO &amp;lt;Plug&amp;gt;EmptyLineAbove&#xA; &quot;Insert empty line below, repeatable&#xA; nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;EmptyLineBelow meo&amp;lt;ESC&amp;gt;`e :call repeat#set(&quot;\         &#xA; &amp;lt;Plug&amp;gt;EmptyLineBelow&quot;)&amp;lt;CR&amp;gt;&#xA; nnoremap go &amp;lt;Plug&amp;gt;EmptyLineBelow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3316" LastEditorUserId="3316" LastEditDate="2017-01-31T11:25:50.253" LastActivityDate="2017-01-31T11:31:43.940" Title="Make mapping repeatable with repeat.vim" Tags="|repeated-commands|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11207" PostTypeId="2" ParentId="11206" CreationDate="2017-01-31T11:31:43.940" Score="2" Body="&lt;p&gt;&lt;kbd&gt;gO&lt;/kbd&gt; and &lt;kbd&gt;go&lt;/kbd&gt; mappings should be made with &lt;code&gt;nmap&lt;/code&gt; instead of &lt;code&gt;nnoremap&lt;/code&gt;. &lt;code&gt;nnoremap&lt;/code&gt; disallows recursion in mappings or nesting, it's usefull for redefining commands. With &lt;code&gt;nmap&lt;/code&gt; Vim scans right side of the mapping further for possible mappings. Read more with &lt;code&gt;:h :nmap&lt;/code&gt; and &lt;code&gt;:h :nnoremap&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-01-31T11:31:43.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11208" PostTypeId="2" ParentId="11200" CreationDate="2017-01-31T13:00:56.367" Score="5" Body="&lt;p&gt;Basically when you paste using &lt;kbd&gt;cmd&lt;/kbd&gt; + &lt;kbd&gt;V&lt;/kbd&gt;, it is just &lt;em&gt;throwing&lt;/em&gt; the content of the macOS clipboard at vim. It is just like typing each character that is in the clipboard literally into vim. That sometimes works, but often it doesn't. So the use is discouraged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this purpose there is the &lt;code&gt;&quot;*&lt;/code&gt; and &lt;code&gt;&quot;+&lt;/code&gt; registers which use the system clipboard and paste the content of that into a native vim register. These are &lt;a href=&quot;https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard&quot; rel=&quot;noreferrer&quot;&gt;buggy&lt;/a&gt; on macOS, but well they seem to work in your case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;code&gt;help quotestart&lt;/code&gt;, &lt;code&gt;help quoteplus&lt;/code&gt; and &lt;code&gt;help clipboard&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other alternative is using &lt;code&gt;pbpaste&lt;/code&gt; and &lt;code&gt;pbcopy&lt;/code&gt; and use line filtering. When you &lt;code&gt;.!pbpaste&lt;/code&gt;, the current line  is the input and the output (that's signaled by the dot) of the external following command (that's signaled by the exclamation mark) used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can use &lt;code&gt;:.!pbpaste&lt;/code&gt; to paste the content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you can use &lt;code&gt;:.!pbcopy&lt;/code&gt; to copy a single line. But the line vanishes if you do this, because pbcopy has no output. However you can do this: &lt;code&gt;.!tee &amp;gt;(pbcopy)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2017-01-31T13:00:56.367" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11209" PostTypeId="2" ParentId="11200" CreationDate="2017-01-31T14:54:10.820" Score="2" Body="&lt;p&gt;Quoting from &lt;a href=&quot;https://groups.google.com/d/msg/vim_use/GuYDsQTlRLA/f53p29nXAQAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bram&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I assume you are talking about the command line, or entering search.&#xA;  Yes, it's intentional that the line break does not work like pressing&#xA;  Enter.  The idea is that you are pasting text, not a command. You are&#xA;  supposed to view the text before deciding to execute it. The thread&#xA;  that started it mentioned that the source of the text may give you&#xA;  something else than what you expected.  In practice, what often&#xA;  happens is that you accidentally copy the wrong text and include the&#xA;  line break when that is not intended.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This has been recently been changed when bracketed paste support was added. You can disable bracketed paste mode by &lt;code&gt;:set t_BE=&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-01-31T14:54:10.820" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11210" PostTypeId="1" AcceptedAnswerId="12590" CreationDate="2017-01-31T19:00:45.260" Score="23" ViewCount="6872" Body="&lt;p&gt;Can I repeat a macro with the &lt;code&gt;.&lt;/code&gt; command? For example, I'd like to be able to type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@q...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and have it effectively call &lt;code&gt;@q&lt;/code&gt; 4 times. With the default behavior, this works only if 'q' holds a single command, for example &lt;code&gt;dw&lt;/code&gt;, &lt;code&gt;x&lt;/code&gt;, or &lt;code&gt;iHello&amp;lt;esc&amp;gt;&lt;/code&gt;. (This makes sense though, since '.' repeats the last &lt;em&gt;change&lt;/em&gt;, not the last keystrokes/command)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd also love to have this work with counts. For example, typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3@q.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would be effectively the same as running &lt;code&gt;@q&lt;/code&gt; 6 times. How can I configure this behavior?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-05-10T23:09:36.390" Title="Can I repeat a macro with the &quot;dot operator&quot;?" Tags="|macro|count|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11211" PostTypeId="1" AcceptedAnswerId="11216" CreationDate="2017-01-31T19:30:08.080" Score="3" ViewCount="604" Body="&lt;p&gt;&lt;strong&gt;Description:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my &lt;a href=&quot;https://konsole.kde.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Konsole&lt;/a&gt; the key mappings for changing tabs to left and right are &lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;left&lt;/kbd&gt; and &lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;right&lt;/kbd&gt; (where left/right are the arrow keys).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm trying to do is to map &lt;kbd&gt;F2&lt;/kbd&gt; in vim to issue &lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;right&lt;/kbd&gt;, and thus change to the next tab in Konsole (in case of Clojure files, but probably this is not relevant). So, it would send keys &quot;outside&quot; of vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried with the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType clojure map &amp;lt;F2&amp;gt; &amp;lt;S-Right&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I press &lt;kbd&gt;F2&lt;/kbd&gt;, nothing happens. I'm fairly sure that the mapping syntax in general is right, since the following works as expected (inserts &quot;Hello&quot; at the current position):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType clojure map &amp;lt;F2&amp;gt; iHello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is &lt;code&gt;&amp;lt;S-Right&amp;gt;&lt;/code&gt; really the correct combination for &lt;kbd&gt;shift&lt;/kbd&gt;-&lt;kbd&gt;right&lt;/kbd&gt;? (Based on the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt;, I suspect yes, but a confirmation would be nice.)&lt;/li&gt;&#xA;&lt;li&gt;Is it possible at all to achieve what I want? (I.e. send keys &quot;outside&quot; vim.) I'm beginning to suspect that this is not possible...&lt;/li&gt;&#xA;&lt;li&gt;If this can be done, then why does my command not work, and what is the way?&lt;/li&gt;&#xA;&lt;li&gt;Is there a way to &quot;debug&quot; in vim, what is going on when I press a certain key? (I.e. lookup of mappings, and then the keys that are sent as a result.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm developing Clojure and doing TDD. &lt;kbd&gt;F2&lt;/kbd&gt; was previously mapped to execute &lt;code&gt;lein test&lt;/code&gt; and show the results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType clojure map &amp;lt;F2&amp;gt; :wa&amp;lt;LF&amp;gt;:! clear &amp;amp;&amp;amp; echo -en &quot;\e[3J&quot; &amp;amp;&amp;amp; lein test&amp;lt;LF&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I got very used to just press &lt;kbd&gt;F2&lt;/kbd&gt; to show the test results, but today I found a &lt;a href=&quot;https://github.com/jakemcc/lein-test-refresh&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt; that can do continuous testing in the background, so I would like to keep my workflow with the new &quot;implementation&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Remark:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I could just remap &lt;kbd&gt;F2&lt;/kbd&gt; in Konsole, but I was curious if there is a way to achieve what I want in vim. This would have the additional advantage of not affecting all the other usages of console.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT: (work-around)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, I found a way by running &lt;a href=&quot;http://www.semicomplete.com/projects/xdotool&quot; rel=&quot;nofollow noreferrer&quot;&gt;xdotool&lt;/a&gt; as an external command, which does what I want. Still I would be interested to the answers of the above questions, to deepen my knowledge about vim ;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType clojure map &amp;lt;F2&amp;gt; :silent exec &quot;!xdotool key shift+Right&quot;&amp;lt;LF&amp;gt;:redraw!&amp;lt;LF&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9602" LastEditorUserId="1841" LastEditDate="2017-06-30T06:59:18.467" LastActivityDate="2017-06-30T06:59:18.467" Title="Mapping vim key to change to next tab in Konsole" Tags="|key-bindings|vimrc|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11213" PostTypeId="1" CreationDate="2017-02-01T03:45:04.100" Score="0" ViewCount="285" Body="&lt;p&gt;I want to map &lt;code&gt;vv&lt;/code&gt; to paste my highlighted text clipboard as opposed to vim's clipboard or the copy clipboard. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2017-02-01T04:36:44.567" Title="How do you paste what is in your highlight clipboard?" Tags="|key-bindings|os-clipboard|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11214" PostTypeId="2" ParentId="11213" CreationDate="2017-02-01T04:36:44.567" Score="6" Body="&lt;p&gt;Note: This only applies in unix with X11 environments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;highlighted text&quot; clipboard is known as the PRIMARY X selection (vs SECONDARY or CLIPBOARD X selections). Vim, when built with X support, provides access to the PRIMARY and CLIPBOARD selections via the registers &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;+&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(you can find more information in &lt;code&gt;:help quoteplus&lt;/code&gt; and &lt;code&gt;:help quotestar&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to map pasting highlighted text, you might do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap vv &quot;*p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;though, that mapping only saves one keystroke at the expense of toggling visual mode. You could just type &lt;code&gt;&quot;*p&lt;/code&gt; or &lt;code&gt;&quot;*P&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2017-02-01T04:36:44.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11215" PostTypeId="2" ParentId="11162" CreationDate="2017-02-01T07:38:49.043" Score="8" Body="&lt;p&gt;The option &lt;code&gt;iskeyword&lt;/code&gt; defines which characters should be considered as part of a word. This option uses the &lt;code&gt;+=&lt;/code&gt; and &lt;code&gt;-=&lt;/code&gt; syntax to add or remove some characters. Thus the following line will add the character &lt;code&gt;-&lt;/code&gt; in the option and will allow you to complete words containing a &lt;code&gt;-&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword+=-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-02-01T07:38:49.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11216" PostTypeId="2" ParentId="11211" CreationDate="2017-02-01T09:09:16.937" Score="4" Body="&lt;p&gt;To answer your several important points here:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is &lt;code&gt;&amp;lt;S-Right&amp;gt;&lt;/code&gt; really the correct combination for shift-right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes &lt;code&gt;&amp;lt;S-Right&amp;gt;&lt;/code&gt; indeed is the correct way to represent &lt;kbd&gt;shift&lt;/kbd&gt;&lt;kbd&gt;right arrow&lt;/kbd&gt; in vimscript.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible at all to achieve what I want? (I.e. send keys &quot;outside&quot; vim.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As you figured it out in your edit, yes it is possible. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If this can be done, then why does my command not work, and what is the way?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here is the interesting part! When you do &lt;code&gt;nnoremap &amp;lt;F2&amp;gt; &amp;lt;S-Right&amp;gt;&lt;/code&gt; you tell &lt;strong&gt;to Vim&lt;/strong&gt; &lt;em&gt;&quot;When you see &lt;kbd&gt;F2&lt;/kbd&gt; behave as if you had seen &lt;kbd&gt;shift&lt;/kbd&gt;&lt;kbd&gt;right arrow&lt;/kbd&gt;&quot;&lt;/em&gt;. You are not telling to your terminal emulator (i.e. Konsole) to do anything, the instructions are only internal to Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is why you had to use &lt;code&gt;xdotool&lt;/code&gt;. With your current mapping you are telling &lt;strong&gt;to Vim&lt;/strong&gt; &lt;em&gt;&quot;When you see &lt;kbd&gt;F2&lt;/kbd&gt;, call an external command (&lt;code&gt;xdotool&lt;/code&gt;) which will tell &lt;strong&gt;to Konsole&lt;/strong&gt; that I pressed &lt;kbd&gt;shift&lt;/kbd&gt;&lt;kbd&gt;right arrow&lt;/kbd&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a way to &quot;debug&quot; in vim, what is going on when I press a certain key? (I.e. lookup of mappings, and then the keys that are sent as a result.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To avoid repetition I create a pretty complete answer here : &lt;a href=&quot;https://vi.stackexchange.com/q/7722/1841&quot;&gt;How to debug a mapping&lt;/a&gt; I think that might be worth reading it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-02-01T09:09:16.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11217" PostTypeId="1" AcceptedAnswerId="11218" CreationDate="2017-02-01T10:50:01.303" Score="10" ViewCount="4231" Body="&lt;p&gt;I need to (visual) select a range of lines from command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example the following command &lt;code&gt;:?^\s*for?+,/^\s*end/- p&lt;/code&gt; prints all lines contained between a &lt;code&gt;for&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; (exclusive way). Instead of performing the printing operation I would like to switch to visual mode with those lines highlighted. I searched in the manual but I couldn't find such an ex-command.&lt;/p&gt;&#xA;" OwnerUserId="11117" LastEditorUserId="11117" LastEditDate="2017-02-01T14:14:59.020" LastActivityDate="2020-01-01T20:11:06.257" Title="selecting a range of lines from command line" Tags="|command-line|visual-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11218" PostTypeId="2" ParentId="11217" CreationDate="2017-02-01T11:19:33.537" Score="9" Body="&lt;p&gt;The boundaries of a visual mode selection are defined by the &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; marks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, the following command will enter visual mode with lines 5 through 10 (inclusive) selected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :5mark &amp;lt; | 10mark &amp;gt; | normal gvV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:5mark &amp;lt;&lt;/code&gt; sets the start of the selection to line 5,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:10mark &amp;gt;&lt;/code&gt; sets the end of the selection to line 10,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gv&lt;/code&gt; enters visual mode with the area defined above selected,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt; makes the selection linewise.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can pass any Vim range into the &lt;code&gt;:mark&lt;/code&gt; command: the following will enter visual mode using the regular expressions &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;bar&lt;/code&gt; to define the boundaries of the selection area:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute search(&quot;foo&quot;) . &quot;mark &amp;lt;&quot; | execute search(&quot;bar&quot;) . &quot;mark &amp;gt;&quot; | normal gvV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following command is a simpler version of the above, but is dependent on cursor position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/foo/mark &amp;lt; | /bar/mark &amp;gt; | normal gvV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more explanation, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#mark-motions&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help mark-motions&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#:mark&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :mark&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#cmdline-ranges&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ranges&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html#gv&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help gv&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html#v_V&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help v_V&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#:execute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :execute&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#search()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help search()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#expr-.&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;help expr-.&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="7706" LastEditDate="2020-01-01T20:11:06.257" LastActivityDate="2020-01-01T20:11:06.257" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11219" PostTypeId="2" ParentId="11210" CreationDate="2017-02-01T17:15:03.000" Score="10" Body="&lt;p&gt;To repeat your last macro you can use &lt;code&gt;@@&lt;/code&gt; so &lt;code&gt;3@@&lt;/code&gt; would essentially run @q 3 times. However the @ keystrokes can be unwieldy, so in my .vimrc I have the lines: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &quot;- Lazy macro repeat&#xA;  nmap &amp;lt;leader&amp;gt;m @@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows me to use my leader key (,) plus m to run the last macro. Then you can precede this with a number to repeat the macro. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;3,m&lt;/code&gt; is equivalent of &lt;code&gt;3@@&lt;/code&gt;. Same total keys and no need to hold shift.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:  Upon rethinking this I came up with a new macro.&#xA;  &lt;code&gt;nmap &amp;lt;leader&amp;gt;. @@&lt;/code&gt;&#xA;This also works when preceded by a number so &lt;code&gt;3,.&lt;/code&gt; is now &lt;code&gt;3@@&lt;/code&gt; Would love to see this work so that I could pass in a macro letter and have that macro repeat instead of the last macro.&lt;/p&gt;&#xA;" OwnerUserId="8493" LastEditorUserId="8493" LastEditDate="2017-06-08T21:06:54.340" LastActivityDate="2017-06-08T21:06:54.340" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11220" PostTypeId="2" ParentId="11210" CreationDate="2017-02-01T23:57:56.607" Score="6" Body="&lt;p&gt;You can record the use of a macro in another macro, and repeat that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqdwq&#xA;qr2@qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;3@r&lt;/code&gt; is like running &lt;code&gt;@q&lt;/code&gt; six times.&lt;/p&gt;&#xA;" OwnerUserId="1306" LastActivityDate="2017-02-01T23:57:56.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11221" PostTypeId="1" AcceptedAnswerId="11222" CreationDate="2017-02-02T00:24:16.167" Score="14" ViewCount="1668" Body="&lt;p&gt;I really enjoy Vim's &lt;code&gt;incsearch&lt;/code&gt; functionality. Is there a way to have it, or something similar to it, working while I do a replacement?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if in normal mode I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/potato/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I get all the &lt;code&gt;potato&lt;/code&gt;s highlighted on my file, just like they are highlighted by &lt;code&gt;incsearch&lt;/code&gt; when I write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/potato&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would already help me a lot when using regular expressions. A very very nice-to-have would be that when I write this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/potato/banana/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would replace the &lt;code&gt;potato&lt;/code&gt;s with &lt;code&gt;banana&lt;/code&gt;s, and highlight them - maybe the replacements should be in a different color. It sould not &quot;commit&quot; the change until I pressed enter though).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using neovim at the moment, in case it helps.&lt;/p&gt;&#xA;" OwnerUserId="11131" LastEditorUserId="11131" LastEditDate="2017-02-02T00:49:52.637" LastActivityDate="2017-02-02T01:00:14.760" Title="Is there an incsearch for the replace command?" Tags="|search|neovim|highlight|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11222" PostTypeId="2" ParentId="11221" CreationDate="2017-02-02T01:00:14.760" Score="12" Body="&lt;p&gt;After a bit of searching, I found &lt;a href=&quot;https://github.com/neovim/neovim/issues/4794&quot; rel=&quot;noreferrer&quot;&gt;this NeoVim issue&lt;/a&gt;, which in turn was closed by &lt;a href=&quot;https://github.com/neovim/neovim/pull/5561&quot; rel=&quot;noreferrer&quot;&gt;this PR&lt;/a&gt;, which brought me to the &lt;code&gt;inccommand&lt;/code&gt; setting. Adding this to my config file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set inccommand=nosplit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;makes NeoVim behave almost exactly as I requested in my question. I did not find something equivalent for regular Vim, but I didn't look for it very energetically.&lt;/p&gt;&#xA;" OwnerUserId="11131" LastActivityDate="2017-02-02T01:00:14.760" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11223" PostTypeId="2" ParentId="9959" CreationDate="2017-02-02T03:49:46.653" Score="3" Body="&lt;p&gt;There's a simpler workaround.  Just add &lt;code&gt;let g:syntax_cmd = &quot;skip&quot;&lt;/code&gt; to your .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#syntax_cmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h syntax_cmd&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The &quot;syntax_cmd&quot; variable is set to one of these values when the&#xA;syntax/syncolor.vim files are loaded:&#xA;   &quot;on&quot;     &quot;:syntax on&quot; command.  Highlight colors are overruled but&#xA;        links are kept&#xA;   &quot;enable&quot; &quot;:syntax enable&quot; command.  Only define colors for groups that&#xA;        don't have highlighting yet.  Use &quot;:syntax default&quot;.&#xA;   &quot;reset&quot;  &quot;:syntax reset&quot; command or loading a color scheme.  Define all&#xA;        the colors.&#xA;   &quot;skip&quot;   Don't define colors.  Used to skip the default settings when a&#xA;        syncolor.vim file earlier in 'runtimepath' has already set&#xA;        them.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;syncolors.vim checks if syntax_cmd is set.  If it's set to &quot;skip&quot;, it exits without changing any of your settings.&lt;/p&gt;&#xA;" OwnerUserId="10995" LastEditorUserId="1841" LastEditDate="2017-02-02T07:53:18.260" LastActivityDate="2017-02-02T07:53:18.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11224" PostTypeId="1" AcceptedAnswerId="11225" CreationDate="2017-02-02T05:12:25.280" Score="1" ViewCount="1106" Body="&lt;p&gt;With the following command, I'd like to glob for all .cpp files so that I can compile and run simple programs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType cpp nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt;&amp;lt;localleader&amp;gt;cr :execute '!clear; g++ ' . expand(glob('*.cpp')) . '; ./a.out&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Right now, the expand function outputs extra characters after each file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E492: Not an editor command: Account.cpp^@CreditCard.cpp^@w3_in_lab.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="4901" LastEditorUserId="1841" LastEditDate="2017-02-02T08:02:39.870" LastActivityDate="2017-02-02T08:02:39.870" Title="Get list of files using glob in command mode" Tags="|key-bindings|command-line|filetype-c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11225" PostTypeId="2" ParentId="11224" CreationDate="2017-02-02T05:54:55.823" Score="2" Body="&lt;p&gt;I'm not sure but you could try this autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType cpp nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt;&amp;lt;localleader&amp;gt;cr :execute '!clear; g++ ' . join(map(glob('*.cpp', 0, 1), 'shellescape(v:val, 1)')) . '; ./a.out'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you don't pass a third argument to &lt;code&gt;glob()&lt;/code&gt;, which evaluates to &lt;code&gt;TRUE&lt;/code&gt;, the output is a string where the matches are separated by newline characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid this, you could pass &lt;code&gt;1&lt;/code&gt; as a third argument, so that the output is a list. Then, call &lt;code&gt;join()&lt;/code&gt; to concatenate all the matches found by &lt;code&gt;glob()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second argument passed to &lt;code&gt;glob()&lt;/code&gt; is &lt;code&gt;0&lt;/code&gt;. It means that your &lt;code&gt;'suffixes'&lt;/code&gt; and &lt;code&gt;'wildignore'&lt;/code&gt; options will apply during the expansion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, since there could be characters inside your filenames, which have a special meaning to the shell or to Vim, you could call &lt;code&gt;map()&lt;/code&gt; and &lt;code&gt;shellescape()&lt;/code&gt; to protect them (passing &lt;code&gt;1&lt;/code&gt;, as a 2nd argument, to the latter).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It's not linked to your issue, but you could move this autocmd inside a filetype plugin, for example inside &lt;code&gt;~/.vim/after/ftplugin/cpp.vim&lt;/code&gt;, you would write something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt; &amp;lt;key&amp;gt; :execute '!clear; g++ ' . join(map(glob('*.cpp', 0, 1), 'shellescape(v:val, 1)')) . '; ./a.out'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-02-02T06:55:22.533" LastActivityDate="2017-02-02T06:55:22.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11226" PostTypeId="1" AcceptedAnswerId="11227" CreationDate="2017-02-02T06:13:13.483" Score="6" ViewCount="1835" Body="&lt;p&gt;I have an abbrevation for running &lt;code&gt;git blame&lt;/code&gt; on the current file, but it fails in the presence of symlinks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the abbreviation&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev gbl ! ( cd %:h ; exec git blame %:t )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; is a symlink to &lt;code&gt;~/config/vim/vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls -l .vimrc | cut -d' ' -f8-&#xA;16 Jan 29 20:54 .vimrc -&amp;gt; config/vim/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open my &lt;code&gt;.vimrc&lt;/code&gt; from the home directory, it doesn't show me the git blame because I'm not inside the project root.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something kind of like &lt;code&gt;realpath(3)&lt;/code&gt; that I can use from the vim side to get a canonical path to the current file? I'd like to replace &lt;code&gt;%:h&lt;/code&gt; with a canonical path to the directory containing the current file and &lt;code&gt;%:t&lt;/code&gt; the corresponding file name.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2017-02-02T16:57:54.383" LastActivityDate="2017-02-02T16:57:54.383" Title="Resolve path to current file" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11227" PostTypeId="2" ParentId="11226" CreationDate="2017-02-02T06:30:29.577" Score="3" Body="&lt;p&gt;You could try this abbreviation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev &amp;lt;expr&amp;gt; gbl getcmdtype() == ':' &amp;amp;&amp;amp; getcmdpos() == 4 ? '! ( cd '.fnamemodify(resolve(expand('%')), ':h').' ; git blame '.fnamemodify(resolve(expand('%')), ':t').' )' : 'gbl'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It uses the &lt;code&gt;resolve()&lt;/code&gt; function to resolve the symbolic links, and &lt;code&gt;fnamemodify()&lt;/code&gt; to extract the head of the path as well as the filename component:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fnamemodify(resolve(expand('%')), ':h')    → head of the path&#xA;fnamemodify(resolve(expand('%')), ':t')    → tail of the path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, it makes sure that your abbreviation is only expanded on a regular Ex command line (&lt;code&gt;getcmdtype() == ':'&lt;/code&gt;), and only if you're at the very beginning of the line (&lt;code&gt;getcmdpos() == 4&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted the abbreviation to be expanded anywhere on the command line, you could remove the 2nd condition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev &amp;lt;expr&amp;gt; gbl getcmdtype() == ':' ? '! ( cd '.fnamemodify(resolve(expand('%')), ':h').' ; git blame '.fnamemodify(resolve(expand('%')), ':t').' )' : 'gbl'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-02-02T07:55:59.057" LastActivityDate="2017-02-02T07:55:59.057" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11228" PostTypeId="1" CreationDate="2017-02-02T06:31:44.297" Score="1" ViewCount="602" Body="&lt;p&gt;How can I merge OS clipboard and Vim's one? I want them to be the same, so &lt;strong&gt;that I don't have to use&lt;/strong&gt; &lt;code&gt;&quot;*y&lt;/code&gt; or &lt;code&gt;&quot;*p&lt;/code&gt; or &lt;code&gt;&quot;*d&lt;/code&gt;, instead just &lt;code&gt;y&lt;/code&gt;, or &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;d&lt;/code&gt;. How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="11134" LastEditorUserId="11134" LastEditDate="2017-02-02T07:01:57.900" LastActivityDate="2017-02-02T07:01:57.900" Title="How to merge OS'es clipboard with Vim's one?" Tags="|buffers|os-clipboard|" AnswerCount="1" CommentCount="3" ClosedDate="2017-02-02T06:40:00.373" ContentLicense="CC BY-SA 3.0" />
  <row Id="11229" PostTypeId="2" ParentId="11228" CreationDate="2017-02-02T06:36:29.273" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#clipboard-unnamed&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'cb&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                    *clipboard-unnamed*&#xA;unnamed     When included, Vim will use the clipboard register '*'&#xA;        for all yank, delete, change and put operations which&#xA;        would normally go to the unnamed register.  When a&#xA;        register is explicitly specified, it will always be&#xA;        used regardless of whether &quot;unnamed&quot; is in 'clipboard'&#xA;        or not.  The clipboard register can always be&#xA;        explicitly accessed using the &quot;* notation.  Also see&#xA;        |gui-clipboard|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, maybe you could try to prepend the value &lt;code&gt;'unnamed'&lt;/code&gt; to the option &lt;code&gt;'clipboard'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard^=unnamed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As the help explains, this should tell Vim to use the &lt;code&gt;*&lt;/code&gt; register for all yank, delete, change and put operations.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="205" LastEditDate="2017-02-02T06:43:12.710" LastActivityDate="2017-02-02T06:43:12.710" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11230" PostTypeId="2" ParentId="6916" CreationDate="2017-02-02T07:33:53.217" Score="1" Body="&lt;p&gt;I was like you, trying to figure out a way to get a list of all available key bindings, which wouldn't override any preexisting function, and tried to write a plugin to get the info. It's not finished, and will probably never be.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By trying to find all the syntaxes which would produce &quot;free&quot; key sequences, I found way too many exceptions, and edge-cases where I wasn't sure whether a key sequence could be considered as free or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, in case you're interested, you could have a look at it, it's on &lt;a href=&quot;https://github.com/lacygoill/my-freekeys&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It installs the custom command &lt;code&gt;:FK&lt;/code&gt;. I haven't used it for a long time, but IIRC, it accepts some optional arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:FK -nomapcheck    don't check whether the key sequences would override one of your&#xA;                   custom mapping, or cause lag (timeout)&#xA;&#xA;:FK -noleader      don't suggest key sequences using the leader key&#xA;&#xA;:FK -nospecial     don't suggest key sequences using special characters&#xA;&#xA;:FK -mode normal   suggest key sequences for normal mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inside a &lt;code&gt;freekeys&lt;/code&gt; buffer, it installs a few buffer-local mappings, which you can find by typing &lt;code&gt;g?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's only (somewhat) good for normal mode. The other modes haven't been really considered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, it's not finished, and the code is a mess, so I suggest you remove the plugin once you've read and copied the information in which you're interested.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-02-02T07:39:37.473" LastActivityDate="2017-02-02T07:39:37.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11231" PostTypeId="1" AcceptedAnswerId="11234" CreationDate="2017-02-02T07:45:38.873" Score="5" ViewCount="1218" Body="&lt;p&gt;Is it possible to create several functions with the same name whose implementation depends on the file type?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I could imagine a function named &lt;code&gt;CurrentFunctionName&lt;/code&gt; that returns the name of the function in which the cursor of the current buffer is. Since the determination of a function name depends on the file type, I need to create multiple implementations for &lt;code&gt;CurrentFunctionName&lt;/code&gt; (Perl, C++, JavaScript etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This function could then be called in another (global) function with only one implementation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu Log(text)&#xA;   call WriteToLog(CurrentFunctionName() . ': ' . a:text)&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which &lt;code&gt;CurrentFunctionName&lt;/code&gt; is now called within &lt;code&gt;Log&lt;/code&gt; is then dependent on the file type of the buffer that was active when &lt;code&gt;Log&lt;/code&gt; was called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something like that?&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2018-05-22T10:53:41.893" Title="Is it possible to create a function with the same name for different filetypes (and different implementations)?" Tags="|vimscript|filetype|functions|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11232" PostTypeId="1" AcceptedAnswerId="11233" CreationDate="2017-02-02T08:21:37.927" Score="2" ViewCount="4576" Body="&lt;p&gt;I am writing a little hack for vim session that will save and load sessions more conveniently - I am aiming for more project-style sessions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you are in directory &lt;code&gt;my-proj&lt;/code&gt; and call &lt;code&gt;vim&lt;/code&gt;, it should automatically open the session associated with the current directory. (This is 'almost' working so far - the problem is with getting the current directory). Saving the 'project' (i.e. a session) can be done with &lt;code&gt;SaveSession&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have done this so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:session_autosave = 'yes'&#xA;let g:session_autoload = 'yes'&#xA;let g:session_default_name = getcwd()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The minor problem is, if I call &lt;code&gt;vim ~/x.txt&lt;/code&gt;, &lt;code&gt;getcwd()&lt;/code&gt; will not return &lt;code&gt;~/x.txt&lt;/code&gt;. It will return the current directory in bash (which could be almost anything). How can I get the directory that vim was called on in the command line (i.e. &lt;code&gt;~&lt;/code&gt; in this case)? And if vim was opened with just &lt;code&gt;vim&lt;/code&gt; then it should get the current working directory.&lt;/p&gt;&#xA;" OwnerUserId="11136" LastEditorUserId="9004" LastEditDate="2017-02-03T01:50:32.120" LastActivityDate="2017-02-06T01:37:20.583" Title="VimScript - How do you get file/directory vim was called on from the command line?" Tags="|working-directory|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11233" PostTypeId="2" ParentId="11232" CreationDate="2017-02-02T08:36:19.357" Score="5" Body="&lt;p&gt;If you want to get the directory of the first file in &lt;code&gt;:argv&lt;/code&gt; (the filename arguments when vim was opened): &lt;code&gt;let g:session_default_name = fnamemodify(argv()[0], ':p:h')&lt;/code&gt;. This will fail if vim was opened with no arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fallback on &lt;code&gt;getcwd()&lt;/code&gt; where there were no arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Returns the directory of the first file in `argv` or `cwd` if it's empty&#xA;function FindSessionDirectory() abort&#xA;  if len(argv()) &amp;gt; 0&#xA;    return fnamemodify(argv()[0], ':p:h')&#xA;  endif&#xA;  return getcwd()&#xA;endfunction!&#xA;let g:session_default_name = FindSessionDirectory()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11135" LastEditorUserId="11135" LastEditDate="2017-02-06T01:37:20.583" LastActivityDate="2017-02-06T01:37:20.583" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11234" PostTypeId="2" ParentId="11231" CreationDate="2017-02-02T08:50:31.817" Score="5" Body="&lt;p&gt;Inside &lt;code&gt;ftplugin/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; you could set a buffer local variable to point to the correct function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:CurrentFunctionName() abort&#xA;  &quot; Implement the function here&#xA;endfunction&#xA;&#xA;let b:CurrentFunctionName = function('&amp;lt;SID&amp;gt;CurrentFunctionName')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other scripts you can &lt;code&gt;call b:CurrentFunctionName()&lt;/code&gt; and it will call the appropriate one based on what was set for the buffer in the ftplugin. This will fail if you try to call it when for a filetype which did not set this variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a fallback you could define it like this (not in ftplugin):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:CurrentFunctionNameFallback() abort&#xA;  &quot; Implement the fallback here&#xA;endfunction&#xA;&#xA;autocmd BufRead,BufNewFile *&#xA;    \ if !exists('b:CurrentFunctionName') |&#xA;    \   let b:CurrentFunctionName = function('&amp;lt;SID&amp;gt;CurrenFunctionNameFallback') |&#xA;    \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11135" LastEditorUserId="11135" LastEditDate="2017-02-02T08:55:36.050" LastActivityDate="2017-02-02T08:55:36.050" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11235" PostTypeId="2" ParentId="11231" CreationDate="2017-02-02T10:16:39.277" Score="0" Body="&lt;p&gt;You could just define the function in a &lt;code&gt;ftplugin&lt;/code&gt; file. For example create the two files with content below them:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:~/.vim/ftplugin/a.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test()&#xA;    echom 'a'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;~/.vim/ftplugin/b.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test()&#xA;    echom 'b'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now make sure you have set &lt;code&gt;:filetype plugin on&lt;/code&gt;. If you now open a &lt;code&gt;.a&lt;/code&gt; file (or run &lt;code&gt;:setf a&lt;/code&gt;) the &lt;code&gt;a.vim&lt;/code&gt; file will be sourced and the function will be defined to echo &lt;code&gt;a&lt;/code&gt;. If you open a &lt;code&gt;.b&lt;/code&gt; file the other file will be sourced, the function will be redefined and a call to it will echo &lt;code&gt;b&lt;/code&gt;, demonstrating that a function can do different things depending on the filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be noted that if you open any other filetype, the function is not redefined and will therefore be dependent on the filetype that was last loaded. As you would probably not be calling the function for a filetype that does not define it, this would probably not be a problem. If it is you could &lt;code&gt;:delfunction&lt;/code&gt; the function when the filetype changes to something else with an &lt;code&gt;autocmd&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2017-02-02T10:16:39.277" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11236" PostTypeId="1" AcceptedAnswerId="11237" CreationDate="2017-02-02T10:21:55.003" Score="9" ViewCount="4654" Body="&lt;p&gt;Is there a standard way to compare two strings in vim so that I can quickly determine which string is sorted before the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strcmp(str1, str2) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to return 0 if &lt;code&gt;str1 == str2&lt;/code&gt;, 1 if &lt;code&gt;str1 &amp;gt; str2&lt;/code&gt; and -1 if &lt;code&gt;str1 &amp;lt; str2&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="51" LastEditDate="2017-02-11T14:41:17.187" LastActivityDate="2017-02-11T14:41:17.187" Title="How do I alphabetically compare two strings" Tags="|vimscript|string-manipulation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11237" PostTypeId="2" ParentId="11236" CreationDate="2017-02-02T10:46:09.163" Score="13" Body="&lt;p&gt;&lt;code&gt;str1 &amp;lt; str2&lt;/code&gt; should be enough. From &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-%3C&quot;&gt;&lt;code&gt;:h expr-&amp;lt;&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                use 'ignorecase'    match case     ignore case &#xA;equal                   ==              ==#             ==?&#xA;not equal               !=              !=#             !=?&#xA;greater than            &amp;gt;               &amp;gt;#              &amp;gt;?&#xA;greater than or equal   &amp;gt;=              &amp;gt;=#             &amp;gt;=?&#xA;smaller than            &amp;lt;               &amp;lt;#              &amp;lt;?&#xA;smaller than or equal   &amp;lt;=              &amp;lt;=#             &amp;lt;=?&#xA;regexp matches          =~              =~#             =~?&#xA;regexp doesn't match    !~              !~#             !~?&#xA;same instance           is              is#             is?&#xA;different instance      isnot           isnot#          isnot?&#xA;&#xA;Examples:&#xA;&quot;abc&quot; ==# &quot;Abc&quot;   evaluates to 0&#xA;&quot;abc&quot; ==? &quot;Abc&quot;   evaluates to 1&#xA;&quot;abc&quot; == &quot;Abc&quot;    evaluates to 1 if 'ignorecase' is set, 0 otherwise&#xA;&#xA;...&#xA;&#xA;When comparing two Strings, this is done with strcmp() or stricmp().  This&#xA;results in the mathematical difference (comparing byte values), not&#xA;necessarily the alphabetical difference in the local language.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;-1&lt;/code&gt;, you can wrap this in a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Strcmp(str1, str2)&#xA;    if a:str1 &amp;lt; a:str2&#xA;        return -1&#xA;    elseif a:str1 == a:str2&#xA;        return 0&#xA;    else&#xA;        return 1&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-02-02T10:46:09.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11238" PostTypeId="1" AcceptedAnswerId="11239" CreationDate="2017-02-02T12:56:19.670" Score="1" ViewCount="2368" Body="&lt;p&gt;I have 2 data files &lt;code&gt;f1.dat&lt;/code&gt; and &lt;code&gt;f2.dat&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;f1.dat&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0  a0  b0&lt;br&gt;&#xA;   1  a1  b1&lt;br&gt;&#xA;   2  a2  b2   &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;f2.dat&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0  c0  d0  e0&lt;br&gt;&#xA;   1  c1  d1   e1&lt;br&gt;&#xA;   2  c2  d2   e2  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I wish to copy all columns of &lt;code&gt;f2&lt;/code&gt; except the fist column to &lt;code&gt;f1&lt;/code&gt;.&#xA;&lt;code&gt;f1&lt;/code&gt; after merging will look like  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;f1.dat&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0  a0  b0   c0  d0  e0&lt;br&gt;&#xA;   1  a1  b1   c1  d1   e1&lt;br&gt;&#xA;   2  a2  b2   c2  d2   e2  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How would I instruct vim to accomplish this task?&lt;/p&gt;&#xA;" OwnerUserId="10566" LastEditorUserId="10566" LastEditDate="2017-02-02T13:37:31.683" LastActivityDate="2017-02-02T13:37:31.683" Title="Copy and paste by columns from one file to another excluding the common first column" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ClosedDate="2017-02-02T13:51:21.030" ContentLicense="CC BY-SA 3.0" />
  <row Id="11239" PostTypeId="2" ParentId="11238" CreationDate="2017-02-02T13:11:59.470" Score="3" Body="&lt;p&gt;You can do it with the following sequence of keystrokes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;in f2.dat file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg0w&amp;lt;C-v&amp;gt;G$y&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;in f1.dat file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg0$&amp;lt;C-v&amp;gt;G$A&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt;$p&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Explanations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;first sequence:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;gg0&lt;/kbd&gt; - move to the beginig of the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;w&lt;/kbd&gt; - jump to second word&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;C-v&lt;/kbd&gt; - start blockwise visual selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;G&lt;/kbd&gt; - jump to last line of file&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;$&lt;/kbd&gt; - jump to end of that line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;y&lt;/kbd&gt; - copy selection&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;second sequence:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;gg0&lt;/kbd&gt; - move to the beginig of the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;$&lt;/kbd&gt; - jump to end of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;C-v&lt;/kbd&gt; - start blockwise visual selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;G&lt;/kbd&gt; - jump to last line of file&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;$&lt;/kbd&gt; - jump to end of that line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;A&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; - append one space at the end of line. After pressing &lt;kbd&gt;Esc&lt;/kbd&gt; this will be repeated on all lines of visual block.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;$&lt;/kbd&gt; - jump to end of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;p&lt;/kbd&gt; - paste content&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="343" LastEditDate="2017-02-02T13:18:43.343" LastActivityDate="2017-02-02T13:18:43.343" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11240" PostTypeId="1" AcceptedAnswerId="15000" CreationDate="2017-02-02T14:36:33.467" Score="3" ViewCount="1219" Body="&lt;p&gt;In &lt;a href=&quot;https://www.youtube.com/watch?v=Zik6u0klD40&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; video (at 1:14) UltiSnips is used to insert a snippet with optional arguments. In this case if the default text of the placeholder is deleted not just the placeholder disappears, but the whole line. Afterwards it is possible to jump back to that placeholder and enter text such that also the rest of the line reappears. I cannot recreate this behavior. The closest I got was with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet t&#xA;`!p&#xA;if t[1] == '':&#xA;    snip.rv = ''&#xA;else:&#xA;    snip.rv = 'test: '&#xA;`${1:default}`!p&#xA;if t[1] == '':&#xA;    snip.rv = ''&#xA;else:&#xA;    snip.rv = '\n'&#xA;`foobar: $0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This basically puts a placeholder and depending on whether it is filled, it get surrounded by some text. It does seem quite clunky to me as I'm checking twice and it's a lot of code for a seemingly easy task so I feel like I'm missing an option of UltiSnips. Does anyone have the code used for the screencast or can otherwise shine some light on this feature?&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2018-01-27T05:22:08.890" Title="UltiSnips: optional line" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11241" PostTypeId="1" CreationDate="2017-02-02T17:09:37.877" Score="2" ViewCount="1219" Body="&lt;p&gt;I was using Vim 7.4 with YCM quite successfully (thank you for YCM!) and just today noticed that Vim 8.0 was out. I downloaded, installed, started and now it complains that &quot;YouCompleteMe unavailable: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;requires VIM compiled with Python (2.6+ or 3.3+) support&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:version&lt;/code&gt; shows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+python/dyn &#xA;+python3/dyn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am on Windows 10 and used the &lt;code&gt;.exe&lt;/code&gt; installer.  This was working before with 7.4, but not for 8.0.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nothing else has changed. Python is on my path, and reports version 3.5.1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11142" LastEditorUserId="51" LastEditDate="2017-05-04T16:31:42.167" LastActivityDate="2018-01-29T21:47:23.240" Title="Vim 8.0 breaks YCM on Windows 10" Tags="|microsoft-windows|plugin-you-complete-me|vimscript-python|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11242" PostTypeId="2" ParentId="11231" CreationDate="2017-02-02T17:38:19.117" Score="0" Body="&lt;p&gt;I have implemented a mecanism for this in lh-dev (a library plugin dedicated to this kind of issues -- generic functions for generic plugins that can be specialized on filetype basis, which I abusively call &quot;ft-polymorphism&quot;). I use it in my generic refactoring plugin, and to automate the insertion of &lt;code&gt;import&lt;/code&gt;/&lt;code&gt;#include&lt;/code&gt; in mu-template snippets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does it works ?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I usually have a generic front-end function, let's say &lt;code&gt;lh#dev#domain#verb()&lt;/code&gt; when I follow something like the &lt;em&gt;NVI&lt;/em&gt; pattern (from C++), but I may also not have this function and directly call the variation point from an unrelated function as I would do with the &lt;em&gt;template method&lt;/em&gt; design pattern.&lt;/li&gt;&#xA;&lt;li&gt;I may have a default implementation (I don't remember the name I've chosen)&lt;/li&gt;&#xA;&lt;li&gt;and I have a few specialisations, for instance: &lt;code&gt;lh#dev#cpp#domain#verb()&lt;/code&gt;, &lt;code&gt;lh#dev#vim#domain#verb()&lt;/code&gt;, and so on.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then I call the right function, from &lt;code&gt;lh#dev#domain#verb()&lt;/code&gt;, thank to &lt;code&gt;lh#dev#options#call('domain#verb', &amp;amp;ft, param1, param2...)&lt;/code&gt; that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Function: lh#dev#option#call(name, filetype, [, parameters])  {{{2&#xA;&quot; @return lh#dev#{ft}#{name}({parameters}) if it exists, or&#xA;&quot; lh#dev#{name}({parameters}) otherwise&#xA;&quot; If {name} is a |List|, then the function name used is: {name}[0]#{ft}#{name}[1]&#xA;function! lh#dev#option#call(name, ft, ...) abort&#xA;  if type(a:name) == type([])&#xA;    let prefix = a:name[0]&#xA;    let name   = a:name[1]&#xA;  elseif type(a:name) == type('string')&#xA;    let prefix = 'lh#dev'&#xA;    let name   = a:name&#xA;  else&#xA;    throw &quot;Unexpected type (&quot;.type(a:name).&quot;) for name parameter&quot;&#xA;  endif&#xA;&#xA;  let fts = lh#dev#option#inherited_filetypes(a:ft)&#xA;  call map(fts, 'v:val.&quot;#&quot;')&#xA;  let fts += ['']&#xA;  for ft in fts&#xA;    let fname = prefix.'#'.ft.name&#xA;    if !exists('*'.fname)&#xA;      let file = substitute(fname, '#', '/', 'g')&#xA;      let file = substitute(file, '.*\zs/.*', '.vim', '')&#xA;      exe 'runtime autoload/'.file&#xA;    endif&#xA;    if exists('*'.fname) | break | endif&#xA;  endfor&#xA;&#xA;  call s:Verbose('Calling: %1(%2)', fname, a:000)&#xA;  if s:verbose &amp;gt;= 2&#xA;    debug return call (function(fname), a:000)&#xA;  else&#xA;    return call (function(fname), a:000)&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The caveat? The &lt;code&gt;:for&lt;/code&gt; loop is a nightmare when I'm debugging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more explanations on the topic, see it's related documentation: &lt;a href=&quot;https://github.com/LucHermitte/lh-dev#filetype-polymorphism&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/LucHermitte/lh-dev#filetype-polymorphism&lt;/a&gt; . Notes: &lt;code&gt;lh#def#option#get()&lt;/code&gt; has been moved to &lt;code&gt;lh#ft#option#get()&lt;/code&gt; for dependency issues, it also supports my new project variables &lt;code&gt;p:foobar&lt;/code&gt; (which act as shared &lt;code&gt;b:variables&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that if &lt;code&gt;namespace#cpp#domain#funcname()&lt;/code&gt; doesn't exist, this function will try to execute &lt;code&gt;namespace#c#domain#funcname()&lt;/code&gt;. A feature I've named &lt;em&gt;filetype inheritance&lt;/em&gt; (I wasn't inspired ^^').&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-05-22T10:53:41.893" LastActivityDate="2018-05-22T10:53:41.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11244" PostTypeId="2" ParentId="11241" CreationDate="2017-02-03T09:42:40.847" Score="1" Body="&lt;p&gt;If your output from &lt;code&gt;:version&lt;/code&gt; is to be believed you have vim build with both python2 and python3 support (dynamic).  This will always trigger YCM to use the python 2 code paths. See the &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/blob/master/autoload/youcompleteme.vim#L32&quot; rel=&quot;nofollow noreferrer&quot;&gt;s:UsingPython2()&lt;/a&gt; function here which decides the path.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:UsingPython2()&#xA;  &quot; I'm willing to bet quite a bit that sooner or later, somebody will ask us to&#xA;  &quot; make it configurable which version of Python we use.&#xA;  if has('python')&#xA;    return 1&#xA;  endif&#xA;  return 0&#xA;endfunction&#xA;&#xA;&#xA;let s:using_python2 = s:UsingPython2()&#xA;let s:python_until_eof = s:using_python2 ? &quot;python &amp;lt;&amp;lt; EOF&quot; : &quot;python3 &amp;lt;&amp;lt; EOF&quot;&#xA;let s:python_command = s:using_python2 ? &quot;py &quot; : &quot;py3 &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Removing the python 2 support should allow YCM to choose the correct version on its own.&lt;/p&gt;&#xA;" OwnerUserId="20" LastActivityDate="2017-02-03T09:42:40.847" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11245" PostTypeId="1" AcceptedAnswerId="11247" CreationDate="2017-02-03T10:10:08.790" Score="2" ViewCount="695" Body="&lt;p&gt;In a fortran code, I have lines like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;c    write(6,*) &quot;something&quot;&#xA;     write(6,*) &quot;something_else&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to insert the first character of the previous line when I open a new line with &lt;kbd&gt;o&lt;/kbd&gt; in normal mode or &lt;kbd&gt;enter&lt;/kbd&gt; in insert mode.&lt;br&gt;&#xA;In the example given, if I open a new line under the &lt;code&gt;1st&lt;/code&gt; line, the line should open with a &lt;code&gt;c&lt;/code&gt; and when I open new line under the &lt;code&gt;2nd&lt;/code&gt;, the new line should start with a whitespace. How would I do that in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. Kindly add appropriate tags if you find any. I could only find &lt;code&gt;vimscript&lt;/code&gt; and &lt;code&gt;vimrc&lt;/code&gt; which might even be not so appropriate.&lt;/p&gt;&#xA;" OwnerUserId="10566" LastEditorUserId="5395" LastEditDate="2017-02-03T10:13:17.037" LastActivityDate="2017-02-03T11:16:33.737" Title="Automatically insert first character of previous line" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11246" PostTypeId="2" ParentId="11245" CreationDate="2017-02-03T10:54:49.793" Score="1" Body="&lt;p&gt;Try adding this to your vimrc:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;nnoremap o 0ylo^OP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;^O&lt;/code&gt; is the character literal for &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing that happens in the mapping is that you go to the beginning of the line &lt;code&gt;0&lt;/code&gt; and yank the first character &lt;code&gt;yl&lt;/code&gt;. Then you go ahead and create a newline below the current line &lt;code&gt;o&lt;/code&gt;. All that's left now is to paste that character, so we execute &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; (which allows us to execute one normal mode command while in insert mode) and we paste that register to the left of our cursor &lt;code&gt;P&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10378" LastEditorUserId="10378" LastEditDate="2017-02-03T11:11:11.563" LastActivityDate="2017-02-03T11:11:11.563" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11247" PostTypeId="2" ParentId="11245" CreationDate="2017-02-03T11:16:33.737" Score="2" Body="&lt;p&gt;One possible approach is to use custom function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction()&#xA;  let curline = getline(line('.'))&#xA;  let char = &quot; &quot;&#xA;  if len(curline)&#xA;    let char = curline[0]&#xA;  endif&#xA;  let l:r = append(line('.'), char)&#xA;  let l:r = setpos('.', [0, line('.')+1, 3, 1])&#xA;endfunction&#xA;&#xA;nnoremap o :call MyFunction()&amp;lt;CR&amp;gt;A&#xA;inoremap &amp;lt;CR&amp;gt; &amp;lt;Esc&amp;gt;:call MyFunction()&amp;lt;CR&amp;gt;A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using above mapping will make it work both in normal and insert mode.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-02-03T11:16:33.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11250" PostTypeId="1" CreationDate="2017-02-03T17:23:58.203" Score="2" ViewCount="568" Body="&lt;p&gt;When typing LaTeX one often needs to type a &lt;code&gt;\&lt;/code&gt; to invoke a command such as &lt;code&gt;\omega&lt;/code&gt;. One of the nicer features of LaTeX is the ability to define your own commands, which can then be detected by Vim if &lt;code&gt;'define'&lt;/code&gt; is properly set. This will allow completion of these commands with &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-d&amp;gt;&lt;/code&gt;. I would like to avoid typing the &lt;code&gt;\&lt;/code&gt; too often as it is located rather awkwardly on my keyboard. Therefore I would like to be able to type &lt;code&gt;ome&amp;lt;c-x&amp;gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; and have vim complete that to &lt;code&gt;\omega&lt;/code&gt;. In other words, I want to be able to complete a word of which I never typed the first character. Is this even possible using the vim completion function or do I need something more capable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to be clear, I will of course be remapping &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; in this case, as this is still an awkward combination.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2017-03-08T23:50:36.143" Title="autocomplete without typing first character" Tags="|autocompletion|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11251" PostTypeId="1" AcceptedAnswerId="11254" CreationDate="2017-02-04T00:23:16.240" Score="1" ViewCount="635" Body="&lt;p&gt;I have notorious problems finding the right autocommand events for various settings. Usually, my choices seem to be okay, but then there are situations where the settings are reset to default values. In particular, I would like to know the events to use for the following activities:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;setting &lt;code&gt;formatoptions&lt;/code&gt; to a value of my choice such that any file-type-specific settings are overwritten&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;choosing a specific file type for files with a particular file name extension&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;setting the syntax highlighting synchronization mode&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9846" LastActivityDate="2017-02-04T05:02:41.107" Title="What are the correct autocommand events for various settings?" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11252" PostTypeId="1" AcceptedAnswerId="11253" CreationDate="2017-02-04T01:38:22.280" Score="0" ViewCount="907" Body="&lt;p&gt;I've switched from NeoComplete to YouCompleteMe because it has much better intellisense, though I had NeoComplete working much better with Omnicompletion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;NeoComplete was able to automatically provide a popup with the right completions without me having to enter a specific mapping (&lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; for Vim commands, &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; for directories, etc.). If I typed &lt;code&gt;colorscheme&lt;/code&gt; for example, it would provide completions for all my schemes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get YouCompleteMe to do the same? At the moment, it overrides the &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; command, but if I want Vimscript or directory completion I have to enter the default key bindings.&lt;/p&gt;&#xA;" OwnerUserId="4901" LastActivityDate="2017-07-16T01:59:23.593" Title="How to get Youcompleteme to work with Vimscript?" Tags="|key-bindings|vimscript|autocompletion|plugin-you-complete-me|plugin-neocomplete|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11253" PostTypeId="2" ParentId="11252" CreationDate="2017-02-04T02:33:24.690" Score="1" Body="&lt;p&gt;Ycm can cooperate with &lt;a href=&quot;https://github.com/Shougo/neco-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Shougo/neco-vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType vim setlocal omnifunc=te#complete#vim_complete&#xA;&#xA;&#xA;function! te#complete#vim_complete( findstart, base ) abort&#xA;   let line_prefix = s:get_input()&#xA;   if a:findstart&#xA;   let ret = necovim#get_complete_position( line_prefix )&#xA;   if ret &amp;lt; 0&#xA;    return col( '.' ) &quot; default to current&#xA;  endif&#xA;   return ret&#xA;  else&#xA;   return necovim#gather_candidates( line_prefix . a:base, a:base )&#xA;  endif&#xA; endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My vim config: &lt;a href=&quot;https://github.com/tracyone/t-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;t-vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10798" LastEditorUserId="10798" LastEditDate="2017-07-16T01:59:23.593" LastActivityDate="2017-07-16T01:59:23.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11254" PostTypeId="2" ParentId="11251" CreationDate="2017-02-04T05:02:41.107" Score="2" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The solution for the first issue depends on whether you want to set particular &lt;code&gt;formatoptions&lt;/code&gt; values for each filetype, or set certain &lt;code&gt;formatoptions&lt;/code&gt; values for all filetypes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the former, simply put your &lt;code&gt;formatoptions&lt;/code&gt; settings in a file named &lt;code&gt;~/.vim/after/ftplugin/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; on Unix, or &lt;code&gt;~\vimfiles\after\ftplugin\&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; on Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the latter, simply put a &lt;code&gt;FileType&lt;/code&gt; autocommand in your &lt;code&gt;~/.vimrc&lt;/code&gt; file, e.g.,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;pre&gt;&lt;code&gt;au FileType * setlocal formatoptions-=o&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;:help ftplugin-overrule&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There are a number of ways to do this. The simplest is to put a command like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.&amp;lt;extension&gt; set filetype=&amp;lt;filetype&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in a file named &lt;code&gt;~/.vim/ftdetect/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; (on Unix).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;:help ftdetect&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There are a number of ways to do this as well. I usually put the syntax sync command, e.g.,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax sync fromstart&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in a file named &lt;code&gt;~/.vim/after/syntax/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; (on Unix).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;:help mysyntaxfile-add&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find more examples with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;:helpgrep after/syntax&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-02-04T05:02:41.107" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="11255" PostTypeId="1" CreationDate="2017-02-04T11:00:41.490" Score="4" ViewCount="70" Body="&lt;p&gt;Sublime Text has a killer feature I'd really like to get working in Vim. It's pretty much the only reason why I can't drop it in favor of Vim yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The feature is that Sublime remembers unsaved changes to files as well as untitled buffers after you quit and reopen the application. So I can pretty much close Sublime without saving anything, and when I reopen it the unsaved changes will still be there as I left them. It automatically makes regular session snapshots, which protects me against system crashes and other types of minor accidents. I've also found it a useful way of storing temporary notes without needing to save them and trash them later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried replicating this functionality in Vim, but the persisting of unsaved changes to untitled buffers seems particularly tricky. The closest I've gotten is using the &lt;a href=&quot;https://github.com/xolox/vim-session&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-session&lt;/a&gt; plugin, which doesn't track contents of untitled buffers. Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit: some community members have pointed out a similar issue (although  my question is more specific), but it doesn't seem to address the issue with untitled buffers not being preserved.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11165" LastEditorUserId="11165" LastEditDate="2017-02-04T16:11:04.237" LastActivityDate="2017-02-04T16:11:04.237" Title="Persisting unsaved changes to untitled buffers in a session" Tags="|buffers|save|sessions|" AnswerCount="0" CommentCount="2" ClosedDate="2017-02-06T19:37:04.950" ContentLicense="CC BY-SA 3.0" />
  <row Id="11256" PostTypeId="2" ParentId="3580" CreationDate="2017-02-04T11:41:59.683" Score="5" Body="&lt;p&gt;Quick command to tell if it's vi or vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi -h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this will display the help info in my case :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vi -h&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug  7 2016 16:03:11)&#xA;[... skip other info ...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So here i'm with VIM.&lt;/p&gt;&#xA;" OwnerUserId="11166" LastActivityDate="2017-02-04T11:41:59.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11257" PostTypeId="1" CreationDate="2017-02-04T12:15:44.730" Score="5" ViewCount="1488" Body="&lt;p&gt;This may seem a little nit-picky, but I like using the wildmenu to switch between buffers: I do &lt;code&gt;:b&lt;/code&gt; and then hit tab until I get to the file I want. The problem is that sometimes, vim shows the entire file path instead of just the file. So instead of getting something nice like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;foo.cpp bar.cpp foobar.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;foo.cpp ~/Documents/programming/projects/my_project/src/bar.cpp foobar.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Which ANNOYS THE HELL out of me. Sometimes it happens, sometimes it doesn't. Deleting the buffer and reopening the file doesn't do anything; I have to restart vim in order for it to go away.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone know why Vim does this?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: So, I haven't experienced this problem since I last created this post; however, just now the problem happened again, and I now know the situation in which it manifests. The situation is as follows:&lt;/p&gt;&#xA;&lt;p&gt;I use the 'quickfix' window for viewing compile errors. When I build my project (via &lt;code&gt;:make&lt;/code&gt;) and there are errors, if the files that contain the errors are not currently buffered within vim, then the absolute path of the file is shown in the quickfix window and everywhere else for the rest of the vim session; even if I do &lt;code&gt;:edit foo.cpp&lt;/code&gt; after the &lt;code&gt;:make&lt;/code&gt;, it will still show the full path for the buffer.&lt;/p&gt;&#xA;&lt;p&gt;Deleting the buffer and doing another &lt;code&gt;:edit&lt;/code&gt; doesn't fix it; Vim shows the full path no matter what. The only remedy is to kill Vim, open a new process, and to open the files containing the errors before calling &lt;code&gt;:make&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Very strange. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="9483" LastEditorUserId="23502" LastEditDate="2024-02-02T12:38:41.270" LastActivityDate="2024-02-02T12:38:41.270" Title="Vim sometimes displays full path of file instead of just the filename?" Tags="|buffers|path|wildmenu|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11258" PostTypeId="2" ParentId="11257" CreationDate="2017-02-04T14:16:49.937" Score="1" Body="&lt;p&gt;The files in the current working folder will be shortened whereas the rest will show the full path. &lt;code&gt;:cd %:p:h&lt;/code&gt; in a buffer will change the directory to that of the file, but then every file in other folders will show their full path.&lt;/p&gt;&#xA;" OwnerUserId="11171" LastActivityDate="2017-02-04T14:16:49.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11259" PostTypeId="1" AcceptedAnswerId="11266" CreationDate="2017-02-04T21:44:16.483" Score="3" ViewCount="1232" Body="&lt;p&gt;I've the following sample INI file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Foo=1&#xA;Bar=1&#xA;Baz=1&#xA;Qux=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and my goal is to set all options to 0 except &lt;code&gt;Foo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To disable one selected line, I know that I can run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/Foo=\zs.*$/0/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Test command in shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +&quot;%s/Foo=\zs.*$/0/p&quot; -scwq file.ini&#xA;Foo=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I negate substitution pattern, for example disabling every other option apart of &lt;code&gt;Foo&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also open for suggestions to use different commands instead to achieve the same result.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2017-02-05T01:55:53.963" LastActivityDate="2017-02-05T15:06:40.450" Title="How to negate substitution pattern?" Tags="|regular-expression|substitute|ex-command|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11260" PostTypeId="1" CreationDate="2017-02-05T03:16:22.363" Score="2" ViewCount="58" Body="&lt;p&gt;Is it possible to have the CtrlP plugin call out to grep? &lt;em&gt;(git-grep in this case, although I don't expect it makes a big difference)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it searches the file contents instead of simply listing the files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like Emacs &lt;a href=&quot;https://github.com/abo-abo/swiper&quot; rel=&quot;nofollow noreferrer&quot;&gt;counsel-git-grep&lt;/a&gt;, see: &lt;a href=&quot;https://www.youtube.com/watch?v=OEmXQNS7ofo&quot; rel=&quot;nofollow noreferrer&quot;&gt;example demo&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I've seen some hints that this is possible, but couldn't manage to get it &#xA;working.&lt;/li&gt;&#xA;&lt;li&gt;I'm aware of &lt;code&gt;fzf&lt;/code&gt; but it seems this depends on external tools that aren't portable across Linux/OSX/Win32.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="301" LastEditorUserId="301" LastEditDate="2017-02-05T03:25:17.600" LastActivityDate="2017-02-05T03:25:17.600" Title="Possible to use CtrlP to interactively search file contents?" Tags="|plugin-ctrlp|" AnswerCount="0" CommentCount="0" ClosedDate="2017-02-08T03:49:57.900" ContentLicense="CC BY-SA 3.0" />
  <row Id="11263" PostTypeId="1" CreationDate="2017-02-05T11:49:31.657" Score="6" ViewCount="2394" Body="&lt;p&gt;I want Vim's sign column displayed to the &lt;em&gt;right&lt;/em&gt; side of the line number column, I have it by default on the &lt;em&gt;left&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a screenshot showing the sign column enabled and showing a &lt;code&gt;+&lt;/code&gt; to indicate a line added (I use the &lt;strong&gt;vim-gitgutter&lt;/strong&gt; plugin)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Hy6M1.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Hy6M1.png&quot; alt=&quot;Original&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I am after (photoshopped):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u5tXB.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u5tXB.png&quot; alt=&quot;Desired&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(how) Can this be done?&lt;/p&gt;&#xA;" OwnerUserId="11179" LastActivityDate="2023-02-06T03:23:03.073" Title="How to show the sign column to the right side of the line number column?" Tags="|line-numbers|signs|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11264" PostTypeId="1" AcceptedAnswerId="11265" CreationDate="2017-02-05T13:52:04.473" Score="3" ViewCount="286" Body="&lt;p&gt;What is the name of the line you enter commands on after hitting escape?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. When you hit escape and start typing a colon command you are typing in/on the _____ .&lt;/p&gt;&#xA;" OwnerUserId="6838" LastEditorUserId="205" LastEditDate="2017-02-05T15:03:38.427" LastActivityDate="2017-02-05T15:03:38.427" Title="What is the name of the line you enter commands on after hitting escape?" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11265" PostTypeId="2" ParentId="11264" CreationDate="2017-02-05T14:15:30.110" Score="6" Body="&lt;p&gt;I would say it's the &quot;command line&quot; based on &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#Command-line&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#Command-line&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11180" LastActivityDate="2017-02-05T14:15:30.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11266" PostTypeId="2" ParentId="11259" CreationDate="2017-02-05T15:06:40.450" Score="5" Body="&lt;p&gt;You can use &lt;code&gt;:v&lt;/code&gt;, e.g. something like this should work:&#xA;&lt;code&gt;&#xA;:v/^Foo/s/.*=\zs\d$/0/g&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-02-05T15:06:40.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11267" PostTypeId="2" ParentId="11179" CreationDate="2017-02-05T15:23:30.570" Score="1" Body="&lt;p&gt;You can use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vapk&amp;lt;Esc&amp;gt;A--&amp;gt;&amp;lt;Esc&amp;gt;vapo&amp;lt;Esc&amp;gt;I&amp;lt;!--&amp;lt;Esc&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation: &#xA;&lt;code&gt;vap&lt;/code&gt; visually selects a paragraph, &lt;code&gt;k&lt;/code&gt; move cursor one like up, &#xA;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; escape from visual to normal mode, &lt;code&gt;A&lt;/code&gt; jump to end of line and go into insert mode, &lt;code&gt;--&amp;gt;&lt;/code&gt; type in text --&gt;, &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; escape from insert to normal mode, &lt;code&gt;vap&lt;/code&gt; visually select a paragraph, &lt;code&gt;o&lt;/code&gt; jump to other end of visual selection, &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; escape from visual to normal mode, &lt;code&gt;I&lt;/code&gt; jump to beginning of line and go into insert mode, &lt;code&gt;&amp;lt;!--&lt;/code&gt; type in text &amp;lt;Esc&amp;gt; escape from insert mode to normal mode, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; carriage return to end the whole command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Above it is not really simple to type. Maybe you should create a keyboard mapping like for example to map spacebar (you can use any other key combination if you like) to comment out current paragraph and save this setting in your .vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;space&amp;gt; vapk&amp;lt;Esc&amp;gt;A--&amp;gt;&amp;lt;Esc&amp;gt;vapo&amp;lt;Esc&amp;gt;I&amp;lt;!--&amp;lt;Esc&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11181" LastEditorUserId="11181" LastEditDate="2017-02-05T18:05:49.020" LastActivityDate="2017-02-05T18:05:49.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11268" PostTypeId="2" ParentId="10242" CreationDate="2017-02-05T16:26:21.913" Score="15" Body="&lt;p&gt;The &lt;a href=&quot;https://launchpad.net/~pi-rho/+archive/ubuntu/dev&quot; rel=&quot;noreferrer&quot;&gt;pi-rho/dev PPA&lt;/a&gt; now supports Vim 8, and like it always has, includes support for Python/Python3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version | grep python&#xA;+cryptv          +linebreak       +python/dyn      +vreplace&#xA;+cscope          +lispindent      +python3/dyn     +wildignore&#xA;$ apt-cache policy vim   &#xA;vim:&#xA;  Installed: 2:8.0.0134-1ubuntu1~ppa1~x&#xA;  Candidate: 2:8.0.0134-1ubuntu1~ppa1~x&#xA;  Version table:&#xA; *** 2:8.0.0134-1ubuntu1~ppa1~x 500&#xA;        500 http://ppa.launchpad.net/pi-rho/dev/ubuntu xenial/main amd64 Packages&#xA;        100 /var/lib/dpkg/status&#xA;     2:7.4.1689-3ubuntu1.2 500&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of late, the &lt;code&gt;pi-rho/dev&lt;/code&gt; PPA hasn't had updated Vim builds. I use the &lt;a href=&quot;https://launchpad.net/~jonathonf/+archive/ubuntu/backports&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;jonathonf/backports&lt;/code&gt;&lt;/a&gt; PPA now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version | grep python&#xA;+comments          +libcall           -python            +vreplace&#xA;+conceal           +linebreak         +python3           +wildignore&#xA;$ apt-cache policy vim-gnome&#xA;vim-gnome:&#xA;  Installed: 2:8.0.1542-0york1~16.04&#xA;  Candidate: 2:8.0.1542-0york1~16.04&#xA;  Version table:&#xA; *** 2:8.0.1542-0york1~16.04 500&#xA;        500 http://ppa.launchpad.net/jonathonf/vim/ubuntu xenial/main amd64 Packages&#xA;        500 http://ppa.launchpad.net/jonathonf/vim/ubuntu xenial/main i386 Packages&#xA;        100 /var/lib/dpkg/status&#xA;     2:7.4.1689-3ubuntu1.2 500&#xA;        500 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages&#xA;        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages&#xA;     2:7.4.1689-3ubuntu1 500&#xA;        500 http://jp.archive.ubuntu.com/ubuntu xenial/main amd64 Packages&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The PPA also contains newer versions of several other packages.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2018-03-05T01:25:08.267" LastActivityDate="2018-03-05T01:25:08.267" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11270" PostTypeId="1" CreationDate="2017-02-05T21:16:47.980" Score="0" ViewCount="372" Body="&lt;p&gt;I have 5000 text files in a folder with different names.&#xA;I just need to add one more line to the end in all files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HELLO HELLO &#xA;HELLO HELLO &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need make it&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HELLO HELLO &#xA;HELLO HELLO &#xA;abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just need to add &quot;abc&quot; to the last line.&lt;/p&gt;&#xA;" OwnerUserId="11183" LastEditorUserId="1841" LastEditDate="2017-02-06T08:02:14.633" LastActivityDate="2017-02-06T10:12:17.207" Title="Add line at the end of text" Tags="|cursor-motions|text-generation|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11271" PostTypeId="2" ParentId="11270" CreationDate="2017-02-05T22:11:06.907" Score="3" Body="&lt;p&gt;I would probably use the &lt;code&gt;argument-list&lt;/code&gt; for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you have to add all files to the argument list and then you can use &lt;code&gt;argdo&lt;/code&gt; to operate on all of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So first let's populate the argument list. There's two ways to do this. The first is to go to your directory and open vim with &lt;code&gt;vim *&lt;/code&gt;. This will open vim with all of the files in the directory open on the argument list. If you can't do that, you can do this (admittedly more complex solution) instead. Open the first file and do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:for file in split(glob('*'), '\n')&#xA;:   exe &quot;argadd &quot;. file&#xA;: endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;split()&lt;/code&gt;: Splits a string into a list&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;glob()&lt;/code&gt;: Expands wildcards (This is what gets all the file names for us)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;argadd&lt;/code&gt;: Adds the file to the argument list.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now that the argument list is populated we can use &lt;code&gt;argdo&lt;/code&gt; to do an operation on &lt;em&gt;ALL&lt;/em&gt; of them at once.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdo execute &quot;normal! Goabc\&amp;lt;Esc&amp;gt;:w\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;execute&lt;/code&gt;: Allows us to use the keys &lt;code&gt;Escape&lt;/code&gt; and &lt;code&gt;Enter&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal!&lt;/code&gt;: Does the following normal mode commands on the buffer&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;G&lt;/code&gt;: Go to the end of the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&lt;/code&gt;: Open a new line and go into insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;abc&lt;/code&gt;: Inserts &lt;code&gt;abc&lt;/code&gt; into the text. Change this to whatever you need&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\&amp;lt;Esc&amp;gt;&lt;/code&gt;: Hits the Escape key to get us out of insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:w\&amp;lt;CR&amp;gt;&lt;/code&gt;: Saves the file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h argdo&lt;/code&gt;, &lt;code&gt;:h execute&lt;/code&gt;, &lt;code&gt;:h normal&lt;/code&gt;, &lt;code&gt;:h argadd&lt;/code&gt;, &lt;code&gt;:h split&lt;/code&gt;, and &lt;code&gt;:h glob&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-02-05T22:11:06.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11272" PostTypeId="2" ParentId="11270" CreationDate="2017-02-06T06:25:13.973" Score="3" Body="&lt;p&gt;Here is a different version. Call Vim from the directory with all files:&#xA;&lt;code&gt;vim *.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can do &lt;code&gt;:bufdo call append('$', 'abc') | upd&lt;/code&gt;, which will run through your buffer list and add a single line 'abc' at the end and write the file before changing the next file.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-02-06T06:25:13.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11273" PostTypeId="2" ParentId="666" CreationDate="2017-02-06T08:04:02.290" Score="4" Body="&lt;p&gt;The indentLine plugin tends to be fairly slow on non-small files, observable when clicking enter as it lags by a second or so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found &lt;a href=&quot;https://github.com/thaerkh/vim-indentguides&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-indentguides&lt;/a&gt; to be a faster and visually similar plugin, that also visually distinguishes tab indents versus space indents.&lt;/p&gt;&#xA;" OwnerUserId="10829" LastEditorUserId="10829" LastEditDate="2017-02-14T01:53:40.167" LastActivityDate="2017-02-14T01:53:40.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11274" PostTypeId="2" ParentId="11250" CreationDate="2017-02-06T09:29:38.487" Score="1" Body="&lt;h1&gt;Mapping&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;As recommended by @statox in the comments of the question, this mapping seems to solve your problem&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-x&amp;gt;&amp;lt;c-d&amp;gt; &amp;lt;esc&amp;gt;bi\&amp;lt;esc&amp;gt;ea&amp;lt;c-x&amp;gt;&amp;lt;c-d&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tested this mapping. It adds the backslash to the beginning of the word, and then shows you recommended completions (you would then need to select the desired completion manually).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a frequent LaTeX user myself, I would opt for the following instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-x&amp;gt;&amp;lt;c-d&amp;gt; &amp;lt;esc&amp;gt;bi\&amp;lt;esc&amp;gt;ea&amp;lt;C-n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does the same thing as the original mapping but automatically selects the first completion. I like this solution the best and have added this particular mapping to my own &lt;code&gt;ftplugin/tex.vim&lt;/code&gt; file. (I have, however, replaced &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; with &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;UltiSnips&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I would recommend you check out &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt;. This plugin is overkill if you are only looking to use one or two mappings, but if you're open to a small time investment in exchange for a much more powerful solution, this is probably what your looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have to refer to the official &lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; for all of the nitty-gritty details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, after you install the plugin, create a file called &lt;code&gt;~/.vim/my-snippets/UltiSnips/tex.snippet&lt;/code&gt; containing the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet ome &quot;\omega&quot;&#xA;\omega&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, when editing a .tex file, you should be able to type &lt;code&gt;ome&lt;/code&gt; followed by a &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; and it will expand to &lt;code&gt;\omega&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that it only saves you two keystrokes, this is a waste of a mapping if you ask me. But to each his own I guess.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Alternative Snippet: (as mentioned in the comments)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet cmd &quot;\&amp;lt;command&amp;gt;&quot;&#xA;\\${1:command}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11189" LastEditorUserId="11189" LastEditDate="2017-02-06T23:42:28.733" LastActivityDate="2017-02-06T23:42:28.733" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11275" PostTypeId="2" ParentId="11270" CreationDate="2017-02-06T10:12:17.207" Score="1" Body="&lt;p&gt;I prefer not to leave the command-line if I don't have to. The following command run from the terminal should do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;abc&quot; | tee -a *.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11189" LastActivityDate="2017-02-06T10:12:17.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11276" PostTypeId="1" AcceptedAnswerId="11278" CreationDate="2017-02-06T10:20:52.150" Score="0" ViewCount="1632" Body="&lt;p&gt;I use Vim 8.0 (homebrew) from iTerm 3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I use full filenames instead of these abominations that Vim seems to print by default? &lt;a href=&quot;https://i.stack.imgur.com/70sPR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/70sPR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some context as filenames: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;sidebar.php &lt;/li&gt;&#xA;&lt;li&gt;sponsors.php&lt;/li&gt;&#xA;&lt;li&gt;donate.php&lt;/li&gt;&#xA;&lt;li&gt;sort-bar.php&lt;/li&gt;&#xA;&lt;li&gt;single-product.php&lt;/li&gt;&#xA;&lt;li&gt;archive-product.php&lt;/li&gt;&#xA;&lt;li&gt;product-box.php&lt;/li&gt;&#xA;&lt;li&gt;templates.js &lt;/li&gt;&#xA;&lt;li&gt;card-page.php&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So yeah, these serve basically no value. I can't guess which &quot;uct.php&quot; is what I want. How do I make Vim print the full filenames (leave folders and path out)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I researched before asking the question, and none of the answers provided in these worked for me: &#xA;&lt;a href=&quot;https://stackoverflow.com/questions/20256380/show-filename-only-in-tabs-terminal-vim&quot;&gt;https://stackoverflow.com/questions/20256380/show-filename-only-in-tabs-terminal-vim&lt;/a&gt;&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/2468939/how-to-let-tab-display-only-file-name-rather-than-the-full-path-in-vim&quot;&gt;https://stackoverflow.com/questions/2468939/how-to-let-tab-display-only-file-name-rather-than-the-full-path-in-vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11015" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-02-06T11:17:21.430" Title="Print full filename in tabs when using terminal Vim" Tags="|terminal|tabbed-user-interface|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11278" PostTypeId="2" ParentId="11276" CreationDate="2017-02-06T11:17:21.430" Score="3" Body="&lt;p&gt;For the terminal, you want to check the 'tabline' option. For the gui version, check the 'guitablabel' setting. Since you seem to be using a terminal vim, here is what I would do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The help page for &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27tabline%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;'tabline'&lt;/a&gt; the help already mentions how to set it, so follow the link &lt;a href=&quot;http://vimhelp.appspot.com/tabpage.txt.html#setting-tabline&quot; rel=&quot;nofollow noreferrer&quot;&gt;setting-tabline&lt;/a&gt; and copy the function found there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  function MyTabLine()&#xA;      let s = ''&#xA;      for i in range(tabpagenr('$'))&#xA;        &quot; select the highlighting&#xA;        if i + 1 == tabpagenr()&#xA;          let s .= '%#TabLineSel#'&#xA;        else&#xA;          let s .= '%#TabLine#'&#xA;        endif&#xA;&#xA;        &quot; set the tab page number (for mouse clicks)&#xA;        let s .= '%' . (i + 1) . 'T'&#xA;&#xA;        &quot; the label is made by MyTabLabel()&#xA;        let s .= ' %{MyTabLabel(' . (i + 1) . ')} '&#xA;      endfor&#xA;&#xA;      &quot; after the last tab fill with TabLineFill and reset tab page nr&#xA;      let s .= '%#TabLineFill#%T'&#xA;&#xA;      &quot; right-align the label to close the current tab page&#xA;      if tabpagenr('$') &amp;gt; 1&#xA;        let s .= '%=%#TabLine#%999Xclose'&#xA;      endif&#xA;&#xA;      return s&#xA;    endfunction&#xA;&#xA;    function MyTabLabel(n)&#xA;      let buflist = tabpagebuflist(a:n)&#xA;      let winnr = tabpagewinnr(a:n)&#xA;      return bufname(buflist[winnr - 1])&#xA;    endfunction&#xA;&#xA;    :set tabline=%!MyTabLine()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, since you want to have the fullname, make the second last line of the &lt;code&gt;MyTabLabel()&lt;/code&gt; function this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;return fnamemodify(bufname(buflist[winnr - 1]), ':t')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or if you want to see the whole path:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;return fnamemodify(bufname(buflist[winnr - 1]), ':p')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read more about the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#fnamemodify%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;fnamemodify() function&lt;/a&gt;&#xA;and the various arguments it accepts at &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#filename-modifiers&quot; rel=&quot;nofollow noreferrer&quot;&gt;filename-modifiers&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-02-06T11:17:21.430" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11279" PostTypeId="2" ParentId="3175" CreationDate="2017-02-06T12:26:29.473" Score="1" Body="&lt;p&gt;You should use thoses plugins &lt;a href=&quot;https://github.com/ddrscott/vim-side-search&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sidesearch&lt;/a&gt; or &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both allow to search in recursive directories using silversearch-ag&lt;/p&gt;&#xA;&#xA;&lt;p&gt;fzf allow to search on the listed files which include your string.&lt;/p&gt;&#xA;" OwnerUserId="11195" LastActivityDate="2017-02-06T12:26:29.473" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11281" PostTypeId="2" ParentId="8381" CreationDate="2017-02-06T15:08:42.593" Score="13" Body="&lt;p&gt;As mentioned in the comments be aware of the consequences this modification has to you work environment (know exactly which eslint rules you use to &quot;fix&quot; things).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer your question: adding the option to the eslint execution with syntactic is &lt;a href=&quot;https://github.com/vim-syntastic/syntastic#faqargs&quot; rel=&quot;noreferrer&quot;&gt;straight forward&lt;/a&gt;. Simply add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; execute eslint with --fix flag&#xA;let g:syntastic_javascript_eslint_args = ['--fix']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But as eslint is executed on the file after vim writes its buffer to the file, vim doesn't know about the fixes eslint does. So somehow vim has to load the file again (the manual way would be to simply type &lt;code&gt;:e&lt;/code&gt; in normal/command mode). To do that, we can use the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;autoread&amp;#39;&quot; rel=&quot;noreferrer&quot;&gt;autoread&lt;/a&gt; option together with &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#:checktime&quot; rel=&quot;noreferrer&quot;&gt;checktime&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; enable autoread to reload any files from files when checktime is called and&#xA;&quot; the file is changed&#xA;set autoread&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To call checktime we can use an &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html&quot; rel=&quot;noreferrer&quot;&gt;autocmd&lt;/a&gt; which gets executed every time a buffer is written to a file. But as syntactic is using its own autocmd on same event &lt;code&gt;BufWritePost&lt;/code&gt; we have to add our autocmd after syntactic adds its own. I found that this is the case when we add our autocmd on &lt;code&gt;VimEnter&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; add an autocmd after vim started to execute checktime for *.js files on write&#xA;au VimEnter *.js au BufWritePost *.js checktime&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So after adding all three parts to your &lt;code&gt;.vimrc&lt;/code&gt; vim should behave as expected (lint and autocorrect on file save &lt;code&gt;:w&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="11201" LastActivityDate="2017-02-06T15:08:42.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11282" PostTypeId="1" CreationDate="2017-02-06T16:08:44.557" Score="1" ViewCount="36" Body="&lt;p&gt;I wanted to replace Tab character with the following, depending on what is on either side of the tab. This is for quickly converting pasted in text (to vim 7.4) from a spreadsheet (xls/xlsx) that has update requests. Some fields are obviously text. Others could be text or numeric.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This function (if/when it works) allows quick conversion of the spreadsheet spec into part of a SQL command. So, the user must look at the metadata and determine if the field is character or numeric. There are 4 case for each Tab and what is on either side of it: CC (char, char), CN (char, num), NC (num, char), and NN (num, num). I had no problem mapping each of these, but getting it into a function to perform these operations runs into trouble. I get a &quot;trailing characters&quot; error. Here is my script (including control characters so you can see):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$&#xA;:map &amp;lt;F1&amp;gt; :%s/^I/,/^M$&#xA;:map &amp;lt;F2&amp;gt; :%s/^I/,'/^M$&#xA;:map &amp;lt;F3&amp;gt; :%s/^I/',/^M$&#xA;:map &amp;lt;F4&amp;gt; :%s/^I/','/^M$&#xA;:map nn :%s/^I/,/^M$&#xA;:map nc :%s/^I/,'/^M$&#xA;:map cn :%s/^I/',/^M$&#xA;:map cc :%s/^I/','/^M$&#xA;:map qb :%s/^/'/^M$&#xA;:map qe :%s/$/'/^M$&#xA;:map sp :%s/''/' '/^M$&#xA;:map ac :%s/^I/','/g^M:%s/^/'/g^M:%s/$/'/g^M$&#xA;:map pr :%s/^.*$/(&amp;amp;),/g^MG$x^[$&#xA;$&#xA;:function! QuoteSQL(...)$&#xA;:   let parsed = split(a:000[0], '\zs')$&#xA;:   let i = 1$&#xA;:   while i &amp;lt; len(a:000[0])$&#xA;:      if parsed[i-1] == 'C' &amp;amp;&amp;amp; parsed[i] == 'C'$&#xA;:normal %s/^I/','/^M$&#xA;:      elseif parsed[i-1] == 'C' &amp;amp;&amp;amp; parsed[i] == 'N'$&#xA;:normal %s/^I/',/^M$&#xA;:      elseif parsed[i-1] == 'N' &amp;amp;&amp;amp; parsed[i] == 'C'$&#xA;:normal %s/^I/,'/^M$&#xA;:      else$&#xA;:normal %s/^I/,/^M$&#xA;:      endif$&#xA;:      let i=i+1$&#xA;:   endwhile$&#xA;:endfunction$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The call looks like this:&#xA;&lt;code&gt;:call QuoteSQL(&quot;NNCCCCNCCNN&quot;)&lt;/code&gt; - Each N or C refers to the fields in order. Numeric fields get no quotes and character fields get single quotes. Like I said I had no problem mapping such commands a cc, cn, nc, and nn. Inside the function I could in fact echo things successfully like echo &quot;CC&quot; etc. When I tried to put the operation I want based on each condition it fails. If the 1st 2 in the comparison are C and C, then the Tab is replaced by &lt;code&gt;,&lt;/code&gt;, etc. I will add steps to put needed quotes at the beginning and end of the lines as well. Then the parenthesis and commas. Imagine if you will that a char field will contain a 'C' and a numeric field will contain and 'N' (not a number I know - this is just for example to show output). Output looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;('C','C',N,'C',N,N,'C'),&#xA;('C','C',N,'C',N,N,'C'),&#xA;.&#xA;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get my function to take the CNNNCNNCNCNCNNC type argument and apply it to the file I have opened in vim?&#xA;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="11204" LastEditorUserId="205" LastEditDate="2017-02-07T00:17:09.837" LastActivityDate="2017-02-07T14:25:48.207" Title="How do I use function to effect editing a file?" Tags="|functions|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11283" PostTypeId="2" ParentId="11282" CreationDate="2017-02-06T16:32:26.437" Score="1" Body="&lt;p&gt;You don't need &lt;code&gt;:normal&lt;/code&gt; here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using special characters use their stringified form -&gt; CTRL-I becomes &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: My mistake, if you want to search for tab, search for &lt;code&gt;\t&lt;/code&gt;. The transformations will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! QuoteSQL(...) abort&#xA;:   let parsed = a:1&#xA;:   let i = 1&#xA;:   let len = strlen(a:1)&#xA;:   while i &amp;lt; len&#xA;:      if parsed[i-1 : i] == 'CC'&#xA;:        %s/\t/','/&#xA;:      elseif parsed[i-1 : i] == 'CN'&#xA;:        %s/\t/',/&#xA;:      elseif parsed[i-1 : i ] == 'NC'&#xA;:        %s/\t/,'/&#xA;:      else&#xA;:        %s/\t/,/&#xA;:      endif&#xA;:      let i += 1&#xA;:   endwhile&#xA;:endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-02-07T14:25:48.207" LastActivityDate="2017-02-07T14:25:48.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11284" PostTypeId="1" AcceptedAnswerId="11287" CreationDate="2017-02-06T20:11:20.637" Score="4" ViewCount="1617" Body="&lt;p&gt;I want to yank text from a window and search for it but the text contains characters not interpreted literally by the search command, e.g. a file path. Is there an easy way I can quote the yanked text when entering the search command?&lt;/p&gt;&#xA;" OwnerUserId="2629" LastActivityDate="2017-02-06T20:56:14.563" Title="How can I quote text in a search regex?" Tags="|regular-expression|search|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11285" PostTypeId="2" ParentId="11284" CreationDate="2017-02-06T20:41:04.033" Score="4" Body="&lt;p&gt;There is unfortunately no option to have search input interpreted as raw text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is something close to it though: the &lt;code&gt;nomagic&lt;/code&gt; option causes most characters (but not all) to be interpreted literally. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To activate &lt;code&gt;nomagic&lt;/code&gt; for a single search, prefix the search pattern with &lt;code&gt;\M&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also activate &lt;code&gt;nomagic&lt;/code&gt; globally (&lt;code&gt;:set nomagic&lt;/code&gt;). Vim's help warns that this might break plugins (though many plugin writers take care to explicitly set the desired magic mode for their patterns). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following characters still won't be interpreted literally in nomagic mode and will need to be escaped with a &lt;code&gt;\&lt;/code&gt; (backslash):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt; end of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\&lt;/code&gt; escape character&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt; (depending on whether you are searching forward or backward) or any other separator that you have chosen if you are searching on the command line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h nomagic&lt;/code&gt; or &lt;code&gt;:h \m&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9430" LastEditorUserId="9430" LastEditDate="2017-02-06T20:53:46.767" LastActivityDate="2017-02-06T20:53:46.767" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11286" PostTypeId="2" ParentId="11284" CreationDate="2017-02-06T20:51:32.170" Score="1" Body="&lt;p&gt;An easy way to 'cheat', particularly for paths or other text containing forward slashes, is to use &lt;code&gt;?&lt;/code&gt; instead of &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Search_without_need_to_escape_slash&quot; rel=&quot;nofollow noreferrer&quot;&gt;Search without need to escape slash | Vim Tips Wiki | Fandom powered by Wikia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2629" LastActivityDate="2017-02-06T20:51:32.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11287" PostTypeId="2" ParentId="11284" CreationDate="2017-02-06T20:56:14.563" Score="2" Body="&lt;p&gt;You can search for literal text by using the &lt;code&gt;\V&lt;/code&gt; &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#/%5CV&quot; rel=&quot;nofollow noreferrer&quot;&gt;modifier&lt;/a&gt;, which means &lt;strong&gt;very nomagic&lt;/strong&gt; after which only the backslash keeps it special meaning. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my .vimrc I have this command to search for text literally:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:com! -nargs=1 Search :let @/='\V'.escape(&amp;lt;q-args&amp;gt;, '\\')| norm! n&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-02-06T20:56:14.563" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11288" PostTypeId="1" CreationDate="2017-02-06T21:40:22.097" Score="2" ViewCount="492" Body="&lt;p&gt;In default vim, whenever &lt;code&gt;foldenable&lt;/code&gt; is set to false, the left-hand fold column becomes blank but continues to take up valuable screen real estate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be better instead if the fold column automatically disappeared or became hidden whenever &lt;code&gt;foldenable&lt;/code&gt; is set to false. And then become visible whenever it is set back to true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an easy way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting up mappings that change &lt;code&gt;foldcolumn=0&lt;/code&gt; and then back to &lt;code&gt;foldcolumn=4&lt;/code&gt; or something like that I think would be a little complicated because the &lt;code&gt;foldenable&lt;/code&gt; option is auto-changed with several different normal-mode commands (&lt;code&gt;zi&lt;/code&gt;, &lt;code&gt;zm&lt;/code&gt;, &lt;code&gt;zM&lt;/code&gt;, etc.).&lt;/p&gt;&#xA;" OwnerUserId="7454" LastActivityDate="2017-02-08T16:37:21.353" Title="Hide fold column whenever `foldenable` becomes false?" Tags="|folding|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11290" PostTypeId="2" ParentId="74" CreationDate="2017-02-07T14:08:18.940" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/thaerkh/vim-workspace&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-workspace&lt;/a&gt; plugin has a fairly customizable auto-save feature that may suit your needs. By default, it enables autosave when in a workspace session (its main feature), but you can set it to always autosave if that's all you're looking for (&lt;code&gt;let g:workspace_autosave_always = 1&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="10829" LastActivityDate="2017-02-07T14:08:18.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11291" PostTypeId="2" ParentId="287" CreationDate="2017-02-07T15:04:12.103" Score="3" Body="&lt;p&gt;You can try the &lt;a href=&quot;https://github.com/thaerkh/vim-workspace&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-workspace&lt;/a&gt; plugin, its session management features are automated, scoped for your current working directory, and is pretty simple (only need to run &lt;code&gt;ToggleWorkspace&lt;/code&gt; once).&lt;/p&gt;&#xA;" OwnerUserId="10829" LastActivityDate="2017-02-07T15:04:12.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11292" PostTypeId="1" CreationDate="2017-02-07T15:59:19.607" Score="2" ViewCount="522" Body="&lt;p&gt;I need to confirm I have not created duplicate variables in a c file, while converting code from another language which is case insensitive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, a file's content (below 2 lines) is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  x = data1;&#xA;  data2 = Data1+ X;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Above text has x and X, data1 and Data1 and I want to know all such variables in the file.&lt;/p&gt;&#xA;" OwnerUserId="10903" LastActivityDate="2017-02-08T13:28:26.447" Title="Find out duplicate words with differing case" Tags="|vimscript|word-processing|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11293" PostTypeId="1" AcceptedAnswerId="11294" CreationDate="2017-02-07T16:34:26.233" Score="7" ViewCount="2300" Body="&lt;p&gt;I usually work with php projects and phpunit. I've mapped &lt;code&gt;&amp;lt;leader&amp;gt;T&lt;/code&gt; thus I can run tests.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# my .vimrc file portion&#xA;nnoremap &amp;lt;Leader&amp;gt;T :!vendor/bin/phpunit --filter&#xA;function! RunFilteredTests()&#xA;    let l:filter = input('Filter test with ... ')&#xA;    exec ':!php ./bin/phpunit --filter ' . l:filter . &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Lately, I've started to play with &lt;code&gt;golang&lt;/code&gt;. Can I use same shortcut with different behavior depending on the current open file?&lt;/p&gt;&#xA;" OwnerUserId="2965" LastActivityDate="2017-02-07T20:24:07.730" Title="Change command depending on file extension/type" Tags="|vimrc|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11294" PostTypeId="2" ParentId="11293" CreationDate="2017-02-07T16:39:15.380" Score="8" Body="&lt;p&gt;Sure, you can use the &lt;code&gt;FileType&lt;/code&gt; autocmd.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set the default behavior&#xA;nnoremap &amp;lt;Leader&amp;gt;T :!vendor/bin/phpunit --filter&#xA;&#xA;&quot; Now set it if we open a go file&#xA;autocmd FileType go nnoremap&amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;T :call GoFunction()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can, of course, change &lt;code&gt;go&lt;/code&gt; to whatever filetype you want. If you're not sure what filetype to use, open the file that you want it to work in and type &lt;code&gt;:set ft?&lt;/code&gt;. This will tell you what filetype your file is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#%3aautocmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :autocmd&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#FileType&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help FileType&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap-%3Cbuffer%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help &amp;lt;buffer&amp;gt;&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-02-07T20:24:07.730" LastActivityDate="2017-02-07T20:24:07.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11296" PostTypeId="1" CreationDate="2017-02-07T16:58:20.617" Score="0" ViewCount="228" Body="&lt;p&gt;I have created some indentation commands like &lt;code&gt;set shiftwidth=4&lt;/code&gt;, &lt;code&gt;set autoindent&lt;/code&gt; and so on.... in my .vimrc file in my home folder and I'm able to get new files auto-indented happily. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to know is if there is some script or way to indent existing file as per a particular indentation (say indentation script written by me (.vimrc) or default indentation standard for a particular extension that vim is intelligent enough to do.... ) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The existing file has no consistent indentation used. Hope the question is clear. &lt;/p&gt;&#xA;" OwnerUserId="10903" LastEditorUserId="1821" LastEditDate="2017-02-07T18:39:42.767" LastActivityDate="2017-02-07T21:16:01.143" Title="indent an existing unindented file as per some indentation commands supposedly written for autoindenting new files" Tags="|vimscript|indentation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11297" PostTypeId="1" CreationDate="2017-02-07T17:29:48.717" Score="1" ViewCount="195" Body="&lt;p&gt;I am using Vim on multiple operating systems (OS X, Windows, Linux Mint) on a daily basis, and I chose to have those directory-free and/or distribution-independent settings synced across the machines through a shared Dropbox folder. Ideally, the following line in &lt;code&gt;.vimrc&lt;/code&gt; shall do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source ~/Dropbox/Tool_Private/Vim-Spelling/general_setting.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, while things are working well across my two Windows machines, I am getting the following errors from my MacBook Air:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /Users/{user}/Dropbox/Tool_Private/Vim-Spelling/general_setting.vim:&#xA;line    8:&#xA;E474: Invalid argument: iskeyword+='^M&#xA;line   10:&#xA;E492: Not an editor command: ^M&#xA;line   11:&#xA;E492: Not an editor command: ^M&#xA;line   15:&#xA;E15: Invalid expression: 1^M&#xA;line   16:&#xA;E15: Invalid expression: '~/Dropbox/Tool_Private/Vim-Spelling/Views'^M&#xA;line   18:&#xA;E492: Not an editor command: ^M&#xA;line   24:&#xA;E488: Trailing characters&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does this have to do with character encoding? I have set the following lines in all my &lt;code&gt;.vimrc&lt;/code&gt;(or &lt;code&gt;_vimrc&lt;/code&gt; for Windows) across all my machines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fileencoding=utf-8&#xA;set encoding=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet, I shall still have those trailing &lt;code&gt;^M&lt;/code&gt; characters, which might have caused the error.&lt;/p&gt;&#xA;" OwnerUserId="2398" LastActivityDate="2017-02-08T15:26:30.140" Title="How to let Gvim and Mvim source the same file, shared through Dropbox?" Tags="|vimrc|gvim|macvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11298" PostTypeId="2" ParentId="11297" CreationDate="2017-02-07T18:10:08.757" Score="4" Body="&lt;p&gt;&lt;code&gt;^M&lt;/code&gt; is a carriage return character. It's plain old ASCII (0x0D) and thus perfectly valid UTF-8 encoded Unicode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim on windows defaults to using Windows-style line endings: &lt;code&gt;CRLF&lt;/code&gt; (Carriage Return, Line Feed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a Unix-based system, including macOS (X, not classic) and Linux, Vim will default to Unix-style line endings: &lt;code&gt;LF&lt;/code&gt;. Thus, when reading a Windows formatted vimrc, Vim on a Unix-style system is going to see an extra character at the end of every line and wonder what the heck is going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The good news is that Vim on Windows is able to read Unix-style line endings just fine. So rather than saving your vimrc with &lt;code&gt;CRLF&lt;/code&gt; line endings, just use &lt;code&gt;LF&lt;/code&gt; line endings. &lt;strong&gt;An easy way to convert is to open it in Vim on Windows, and run &lt;code&gt;:set fileformat=unix&lt;/code&gt;, then save it with &lt;code&gt;:w&lt;/code&gt;. &lt;a href=&quot;https://vi.stackexchange.com/questions/11297/how-to-let-gvim-and-mvim-source-the-same-file-shared-through-dropbox/11298?noredirect=1#comment19817_11298&quot;&gt;Christian Brabandt&lt;/a&gt; pointed out that this can be done in fewer steps with &lt;code&gt;:w ++ff=unix&lt;/code&gt;&lt;/strong&gt;. You might be able to make the same change on a different OS, but I have vague recollections of ending up with &lt;code&gt;CRCRLF&lt;/code&gt;, which doesn't make anyone happy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an alternative, you could use a version control system instead of Dropbox to share your vim files between computers. Git can automatically check files out with the correct line endings depending on which OS it's currently on, and I would be quite surprised if other modern VCSs lacked the same functionality. Places like Bitbucket and Github can provide free hosting. As an extra benefit, you can get great history tracking, potentially useful if you want to experiment with new settings for a while and still be able to easily roll back. As a downside, syncing is rather less automatic, at least without some extra up front effort.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-02-08T15:26:30.140" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="11299" PostTypeId="2" ParentId="11296" CreationDate="2017-02-07T21:02:07.643" Score="1" Body="&lt;p&gt;I don't find that I'm able to get away with a single &lt;code&gt;ts&lt;/code&gt; and &lt;code&gt;sw&lt;/code&gt; setting. The proper values depend on the file type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, I use the following functions in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function SpaceTabs(spaces)&#xA;    exe &quot;set sw=&quot; . a:spaces&#xA;    exe &quot;set ts=&quot; . a:spaces&#xA;    exe &quot;set expandtab&quot;&#xA;    exe &quot;set smarttab&quot;&#xA;    exe &quot;retab&quot;&#xA;endfunction&#xA;&#xA;function TabTabs(stops)&#xA;    exe &quot;set ts=&quot; . a:stops&#xA;    exe &quot;set sw=&quot; . a:stops&#xA;    exe &quot;set noexpandtab&quot;&#xA;    exe &quot;set nosmarttab&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then below that, I have the following to enforce my local choices:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufEnter *.dbx call SpaceTabs(2)&#xA;au BufEnter *.docbook call SpaceTabs(2)&#xA;au BufEnter *.html call SpaceTabs(2)&#xA;au BufEnter *.md call SpaceTabs(4)&#xA;au BufEnter *.pal call TabTabs(8)&#xA;au BufEnter *.xml call SpaceTabs(2)&#xA;au BufEnter *.xsl call SpaceTabs(2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've edited that down to common file extensions, except for &lt;code&gt;*.pal&lt;/code&gt; (the common PDP-8 assembly language form) which I've left as an example of one of that rare cases where I really do want hard tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then below that, my defaults, which keeps the file type specific listing above as short as possible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufLeave * call SpaceTabs(4)&#xA;call SpaceTabs(4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may then ask, why do I need the &lt;code&gt;*.md&lt;/code&gt; rule? It's in case I run into a Markdown file not produced under these same rules, because I &lt;em&gt;always&lt;/em&gt; want to retab them when I open them. I'm careful adding such things; I don't do it on purpose for C and C++ files, because that's just as likely to wreck the formatting as fix the formatting of a free-form language, unlike with Markdown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you run across a file that doesn't get &quot;fixed&quot; the way you like this way and you can't be bothered to add one of these &lt;code&gt;BufEnter&lt;/code&gt; rules, you can say&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :call SpaceTabs(4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With Vim's command completion, this is quick to type.&lt;/p&gt;&#xA;" OwnerUserId="6852" LastEditorUserId="6852" LastEditDate="2017-02-07T21:16:01.143" LastActivityDate="2017-02-07T21:16:01.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11300" PostTypeId="2" ParentId="10016" CreationDate="2017-02-07T21:22:58.143" Score="8" Body="&lt;p&gt;Finally found a way to do this that doesn't involve closing NERDTree all the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a function that cycles through the open windows until it finds a writable buffer, then runs ctrl-p there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CtrlPCommand()&#xA;    let c = 0&#xA;    let wincount = winnr('$')&#xA;    &quot; Don't open it here if current buffer is not writable (e.g. NERDTree)&#xA;    while !empty(getbufvar(+expand(&quot;&amp;lt;abuf&amp;gt;&quot;), &quot;&amp;amp;buftype&quot;)) &amp;amp;&amp;amp; c &amp;lt; wincount&#xA;        exec 'wincmd w'&#xA;        let c = c + 1&#xA;    endwhile&#xA;    exec 'CtrlP'&#xA;endfunction&#xA;&#xA;let g:ctrlp_cmd = 'call CtrlPCommand()'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should work for any panel, for example MiniBufferExplorer.&lt;/p&gt;&#xA;" OwnerUserId="11221" LastActivityDate="2017-02-07T21:22:58.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11301" PostTypeId="1" AcceptedAnswerId="11303" CreationDate="2017-02-07T23:25:40.527" Score="4" ViewCount="730" Body="&lt;p&gt;I have installed a tiny vim version without the clipboard feature. Can I load this feature for the current version or do I have to install another version of vim?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vi --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)&#xA;Included patches: 1-1689&#xA;Extra patches: 8.0.0056&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Small version without GUI.  Features included (+) or not (-):&#xA;+acl             -farsi           -mouse_sgr       -tag_any_white&#xA;-arabic          -file_in_path    -mouse_sysmouse  -tcl&#xA;-autocmd         -find_in_path    -mouse_urxvt     +terminfo&#xA;-balloon_eval    -float           -mouse_xterm     -termresponse&#xA;-browse          -folding         +multi_byte      -textobjects&#xA;+builtin_terms   -footer          -multi_lang      -timers&#xA;-byte_offset     +fork()          -mzscheme        -title&#xA;-channel         -gettext         -netbeans_intg   -toolbar&#xA;-cindent         -hangul_input    +packages        -user_commands&#xA;-clientserver    +iconv           -path_extra      +vertsplit&#xA;-clipboard       -insert_expand   -perl            -virtualedit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10706" LastEditorUserId="1111" LastEditDate="2018-04-18T17:48:55.390" LastActivityDate="2018-04-18T18:09:45.373" Title="Install vim features" Tags="|os-clipboard|installing|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11302" PostTypeId="1" AcceptedAnswerId="14091" CreationDate="2017-02-07T23:36:11.537" Score="1" ViewCount="2017" Body="&lt;p&gt;Whenever I use vim, sometimes I make a single-touch touchpad on vim screen and it makes a highlight like the picture below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is this I cannot cancel this highlight.&#xA;right click doesn't work, left click just override highlight to that clicked point again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only way to get rid of this is to quit vim.&lt;br&gt;&#xA;Anyone else have this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently considering disabling mouse click on vim but i am looking for a better solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JGCX0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JGCX0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CkWbF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CkWbF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11137" LastEditorUserId="51" LastEditDate="2017-02-11T14:38:06.887" LastActivityDate="2017-11-02T06:09:26.390" Title="Cancel mouse highlight on mac" Tags="|terminal|macos|mouse|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11303" PostTypeId="2" ParentId="11301" CreationDate="2017-02-07T23:51:48.283" Score="2" Body="&lt;p&gt;I'm pretty sure that the only way to change which features are enabled is to recompile vim. So, yes; you need to re-install.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-02-07T23:51:48.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11305" PostTypeId="1" AcceptedAnswerId="11309" CreationDate="2017-02-08T01:48:47.050" Score="2" ViewCount="1472" Body="&lt;p&gt;I'm using MS Windows shortcuts for vim by editing my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/mswin.vim&#xA;behave mswin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm missing key bindings for Control+F to access find functionality and Control+S to save a file. I know there is the possibility to define those mappings manually e.g. &lt;code&gt;:imap &amp;lt;C-f&amp;gt; &amp;lt;C-o&amp;gt;/&lt;/code&gt; for insert mode. Why those mappings have been left out?&lt;/p&gt;&#xA;" OwnerUserId="10706" LastEditorUserId="10706" LastEditDate="2017-02-08T01:58:48.340" LastActivityDate="2017-02-08T06:15:33.243" Title="mswin.vim key bindings" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11306" PostTypeId="1" AcceptedAnswerId="11308" CreationDate="2017-02-08T02:36:18.620" Score="2" ViewCount="91" Body="&lt;p&gt;Sometimes &lt;code&gt;n&lt;/code&gt; (next instance of a search) starts moving me up in the file instead of down. Could this be caused by a bug in a plugin?&lt;/p&gt;&#xA;" OwnerUserId="10391" LastActivityDate="2017-02-08T06:13:01.500" Title="Key n moves up in the file instead of down" Tags="|search|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11307" PostTypeId="2" ParentId="11292" CreationDate="2017-02-08T03:37:58.833" Score="4" Body="&lt;p&gt;The following script provides the &lt;code&gt;:Ambiguous&lt;/code&gt; command.  It displays keywords (read &lt;code&gt;:h 'iskeyword'&lt;/code&gt;) that are the same but have different letter case in the &lt;code&gt;location-list&lt;/code&gt; window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The script is explained through its comments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:display_ambiguous() abort&#xA;  let buckets = {}&#xA;&#xA;  &quot; Split all text in the buffer by non-keywords.&#xA;  for word in split(join(getline(1, '$')), '\%(\k\@!.\)\+')&#xA;    &quot; Words are collected into a bucket, keyed by the lowercased word.&#xA;    let key = tolower(word)&#xA;    if !has_key(buckets, key)&#xA;      let buckets[key] = []&#xA;    endif&#xA;&#xA;    &quot; Only add words that haven't been seen before.&#xA;    if index(buckets[key], word) == -1&#xA;      call add(buckets[key], word)&#xA;    endif&#xA;  endfor&#xA;&#xA;  let ambiguous = []&#xA;  for [key, items] in items(buckets)&#xA;    &quot; If a bucket has more than one item, add it to the results.&#xA;    if len(items) &amp;gt; 1&#xA;      call add(ambiguous, {&#xA;            \ 'text': join(items, ', '),&#xA;            \ 'bufnr': bufnr('%'),&#xA;            \ })&#xA;    endif&#xA;  endfor&#xA;&#xA;  if !empty(ambiguous)&#xA;    &quot; Set the contents of the location-list window.&#xA;    call setloclist(0, ambiguous, 'r')&#xA;    &quot; Display the location-list window.&#xA;    lopen&#xA;  endif&#xA;endfunction&#xA;&#xA;&#xA;command! Ambiguous call s:display_ambiguous()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2017-02-08T13:28:26.447" LastActivityDate="2017-02-08T13:28:26.447" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11308" PostTypeId="2" ParentId="11306" CreationDate="2017-02-08T06:13:01.500" Score="6" Body="&lt;p&gt;'n' by default moves in the same direction as the last normal mode search command. So if you used &lt;code&gt;?&lt;/code&gt; to search backwards, &lt;code&gt;n&lt;/code&gt; will also search backwards. Until you use &lt;code&gt;/&lt;/code&gt; again to search forward, in which case &lt;code&gt;n&lt;/code&gt; will then again also move forward again. The same is true for &lt;code&gt;N&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a mapping that I use to have &lt;code&gt;n&lt;/code&gt; always search forwards and &lt;code&gt;N&lt;/code&gt; always continue searching backwards:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; n (v:searchforward ? 'n' : 'N')&#xA;nnoremap &amp;lt;expr&amp;gt; N (v:searchforward ? 'N' : 'n')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://vi.stackexchange.com/a/2366/71&quot;&gt;this&lt;/a&gt; answer where I explain that in more detail and also how those maps work.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-02-08T06:13:01.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11309" PostTypeId="2" ParentId="11305" CreationDate="2017-02-08T06:15:33.243" Score="5" Body="&lt;p&gt;Because either nobody uses mswin.vim and uses the usual/standard vi commands or nobody has complained that those maps are missing. If you want to have those maps included in mswin.vim you might want to open an issue at the vim/vim repository and mention that. Even better would be, to directly contribute those maps by creating a pull request.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-02-08T06:15:33.243" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11310" PostTypeId="1" AcceptedAnswerId="11311" CreationDate="2017-02-08T13:24:46.280" Score="24" ViewCount="21692" Body="&lt;p&gt;Sometimes I see a window open with name &lt;code&gt;scratch&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I know it is some kind of temporary buffer/window.&lt;/p&gt;&#xA;&lt;p&gt;How can I create one?&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:h scratch&lt;/code&gt; returns nothing.&lt;/p&gt;&#xA;" OwnerUserId="7247" LastEditorUserId="51" LastEditDate="2020-12-07T09:28:33.323" LastActivityDate="2024-03-28T10:58:00.633" Title="What is a scratch window?" Tags="|buffers|vim-windows|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11311" PostTypeId="2" ParentId="11310" CreationDate="2017-02-08T13:30:29.283" Score="20" Body="&lt;p&gt;It is probably a scratch buffer, which can be named. From the help:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;scratch&lt;/p&gt;&#xA;&lt;p&gt;Contains text that can be discarded at any time.  It is kept when closing the window, it must be deleted explicitly. Settings:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;      :setlocal buftype=nofile&#xA;      :setlocal bufhidden=hide&#xA;      :setlocal noswapfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The buffer name can be used to identify the buffer, if you give it a meaningful name.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This can be found in &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#special-buffers&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help special-buffers&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10509" LastEditorUserId="34332" LastEditDate="2021-10-26T15:10:05.240" LastActivityDate="2021-10-26T15:10:05.240" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11312" PostTypeId="2" ParentId="11310" CreationDate="2017-02-08T13:45:27.080" Score="4" Body="&lt;p&gt;I remember a vim tip (which has been migrated to vim.wikia) on the subject.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The latest version of the function I use to create scratch buffers also sets:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'buflisted'&lt;/code&gt; to false&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'readonly'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(From my VimL library plugin: lh-vim-lib)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! lh#buffer#scratch(bname, where) abort&#xA;  try&#xA;    set modifiable&#xA;    &quot; The next function takes care of working around this damn E36&#xA;    call lh#window#create_window_with(a:where.' sp '.escape(substitute(a:bname, '\*', '...', 'g'), '#%'))&#xA;  catch /.*/&#xA;    throw &quot;Can't open a buffer named '&quot;.a:bname.&quot;'!&quot;&#xA;  endtry&#xA;  setlocal bt=nofile bh=wipe nobl noswf ro&#xA;  return bufnr('%')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-02-08T16:11:29.827" LastActivityDate="2017-02-08T16:11:29.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11313" PostTypeId="2" ParentId="11288" CreationDate="2017-02-08T16:37:21.353" Score="1" Body="&lt;p&gt;I don't know of a way to actively monitor a vim setting like foldenable for changes, and therein lies your main problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can achieve a partial solution using autocommands. I don't know how often you change your foldenable setting, but normally I would think it to be either file or buffer specific. Often it is set in the file itself by a modeline at the end. This is pretty common and allows files to look nicely formatted and self-consistent, more or less independently of any user settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create an autocommand for WinEnter and WinLeave which checks the foldenable setting and sets the foldcolumn accordingly (the following would go in your vimrc):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au! WinEnter,WinLeave * call CheckFoldColumnSetting()&#xA;&#xA;function! CheckFoldColumnSetting()&#xA;    if foldenable == 1&#xA;        set foldcolumn = 4&#xA;    else&#xA;        set foldcolumn = 0&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then add more events if you want to monitor more often, such as file reads and writes, by changing the autocommand like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au! WinEnter,WinLeave,BufRead,BufWrite * call CheckFoldColumnSetting()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10168" LastActivityDate="2017-02-08T16:37:21.353" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11315" PostTypeId="1" AcceptedAnswerId="11383" CreationDate="2017-02-08T20:45:02.027" Score="10" ViewCount="2266" Body="&lt;p&gt;This has been &lt;a href=&quot;https://stackoverflow.com/questions/8369021/in-vim-how-to-scroll-continuously-by-screen-lines-when-wrapping-is-enabled&quot;&gt;asked on stackoverflow before&lt;/a&gt;, but it seems it still has no solution. Perhaps that has changed with Vim 8.0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to scroll (i.e. scroll-wheel, or &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; in normal mode) by &lt;strong&gt;visual lines&lt;/strong&gt; when line-wrapping is enabled, rather than by line number. This can come in handy for text documents (in my case, LaTeX files).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any chance Vim 8.0 allows this somehow? Or can anyone suggest a vimscript &lt;code&gt;function&lt;/code&gt; hack that might accomplish the same thing?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2023-05-25T09:37:22.197" Title="Visual scrolling/visual &lt;C-e&gt; and &lt;C-y&gt; across wrapped lines?" Tags="|vimrc|vimscript|scrolling|multiple-lines|mouse|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11319" PostTypeId="2" ParentId="3231" CreationDate="2017-02-09T04:57:52.393" Score="1" Body="&lt;p&gt;You can do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:10y &amp;lt;Enter&amp;gt; (to copy the line 10)&#xA;p (paste line 10 where the cursor is)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setting up relative number helps in moving between lines of code as well.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set relativenumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can copy the 5th line above the cursor with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:-5y &amp;lt;Enter&amp;gt;&#xA;:p (to paste)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9092" LastActivityDate="2017-02-09T04:57:52.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11320" PostTypeId="1" CreationDate="2017-02-09T09:46:01.100" Score="9" ViewCount="293" Body="&lt;p&gt;I'm using &lt;code&gt;set matchpairs+=&amp;lt;:&amp;gt;&lt;/code&gt; with my C++ code, and it works great. But there are some cases where it is not quite there, like this C++ code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;type_traits&amp;gt;&#xA;template&amp;lt;int X&amp;gt; typename std::enable_if&amp;lt;(X&amp;gt;9),int&amp;gt;::type func() { return 5; }&#xA;int main() { func&amp;lt;10&amp;gt;(); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, if you put the cursor on the &lt;code&gt;&amp;lt;&lt;/code&gt; after &lt;code&gt;enable_if&lt;/code&gt;, the &lt;code&gt;&amp;gt;&lt;/code&gt; in &lt;code&gt;X&amp;gt;9&lt;/code&gt; will be highlighted. Of course it makes sense from the perspective of Vim, which isn't a C++ compiler nor an IDE. But is there any easy way to make it not match pairs broken by non-closed parentheses? I.e. I'd like &lt;code&gt;&amp;lt;()&amp;gt;&lt;/code&gt; to match the closing angle bracket, and &lt;code&gt;&amp;lt;(&amp;gt;)&lt;/code&gt; not to.&lt;/p&gt;&#xA;" OwnerUserId="1081" LastActivityDate="2018-10-26T13:59:27.687" Title="How to make matchpairs not match closing '&gt;' in &quot;&lt;(&gt;)&quot; while still matching it in &quot;&lt;()&gt;&quot;?" Tags="|delimiter-matching|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11321" PostTypeId="1" CreationDate="2017-02-09T09:53:44.413" Score="-2" ViewCount="205" Body="&lt;p&gt;I want to know the basics of vi editor because I am new to linux  and currently I am using ubuntu 16.04.&lt;/p&gt;&#xA;" OwnerUserId="11242" LastActivityDate="2017-02-09T12:39:21.573" Title="What are the basics of vi editor?" Tags="|unix|" AnswerCount="1" CommentCount="2" ClosedDate="2017-02-09T15:44:58.217" ContentLicense="CC BY-SA 3.0" />
  <row Id="11322" PostTypeId="1" CreationDate="2017-02-09T10:20:17.277" Score="1" ViewCount="54" Body="&lt;p&gt;Is there any good outliner for SCSS files in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or alternatively, is it possible to fold SCSS classes such that the inner classes would be visible as well?&lt;/p&gt;&#xA;" OwnerUserId="10575" LastEditorUserId="51" LastEditDate="2017-02-11T14:37:04.970" LastActivityDate="2017-02-11T14:37:04.970" Title="How to show a list of SCSS rules in vim?" Tags="|folding|filetype-scss|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11323" PostTypeId="2" ParentId="11321" CreationDate="2017-02-09T10:24:37.237" Score="1" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;esc&amp;gt;:q!&lt;/code&gt; To close the file without saving.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;esc&amp;gt;:wq&lt;/code&gt; To close the file with saving.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Those are the &lt;strong&gt;first two commands&lt;/strong&gt; that I teach people who need to use VIM in a pinch. They are useful, and provide a base for understanding the use of the &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; key and &lt;code&gt;:&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Christian mentioned in his comment, &lt;a href=&quot;https://superuser.com/questions/246487/how-to-use-vimtutor&quot;&gt;VimTutor&lt;/a&gt; is probably the best way to learn VIM. Just type &lt;code&gt;vimtutor&lt;/code&gt; at the CLI and follow the instructions on the screen.&lt;/p&gt;&#xA;" OwnerUserId="989" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:03.723" LastActivityDate="2017-02-09T12:39:21.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11324" PostTypeId="1" AcceptedAnswerId="11325" CreationDate="2017-02-09T10:33:34.717" Score="2" ViewCount="904" Body="&lt;p&gt;I need to annotate a text file, so I would like to add a &lt;code&gt;|&lt;/code&gt; pipe character to the end of each line to put my annotations relatively close to the original text. Each line is &lt;em&gt;up to&lt;/em&gt; 72 characters in length. How might I move to the 74th character of the line, even if the line itself is shorter (i.e. add spaces if needed)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current solution is to simply add 72 spaces to the line, then to move to position 74 and delete the remaining spaces. Is there not a more elegant method in VIM?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current (inelegant) macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq$74a&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;74|i|&amp;lt;esc&amp;gt;lDjq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm currently using VIM 8.0.133 on CentOS 7.3.&lt;/p&gt;&#xA;" OwnerUserId="989" LastActivityDate="2017-02-09T13:00:26.243" Title="Add a pipe character to the nth character of a line, which is after the end of the line" Tags="|cursor-movement|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11325" PostTypeId="2" ParentId="11324" CreationDate="2017-02-09T10:51:09.593" Score="5" Body="&lt;p&gt;You could also enable &lt;code&gt;'virtualedit'&lt;/code&gt; option and directly jump to the column you're interested in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A very similar question as been asked lately on SO: &lt;a href=&quot;https://stackoverflow.com/questions/41964261/how-do-i-put-the-character-in-6th-column-and-80th-column-in-vi/41964372#41964372&quot;&gt;https://stackoverflow.com/questions/41964261/how-do-i-put-the-character-in-6th-column-and-80th-column-in-vi/41964372#41964372&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-02-09T10:51:09.593" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11326" PostTypeId="2" ParentId="11324" CreationDate="2017-02-09T11:30:21.280" Score="2" Body="&lt;p&gt;Here's one way to do it without having to edit and restore &lt;code&gt;'virtualedit'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;normal &quot; . string(73 - strwidth(getline('.'))) . &quot;A &quot; | normal A|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This runs two commands:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The part &lt;em&gt;before&lt;/em&gt; the bar &lt;code&gt;|&lt;/code&gt; calculates the number of spaces required (&lt;code&gt;73 - strwidth(getline('.'))&lt;/code&gt;) and then uses that as a count to a normal mode command that appends a single space, thus appending the correct number of spaces,.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The part &lt;em&gt;after&lt;/em&gt; the bar simply appends a pipe character &lt;code&gt;|&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-02-09T13:00:26.243" LastActivityDate="2017-02-09T13:00:26.243" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11328" PostTypeId="1" CreationDate="2017-02-09T15:53:58.177" Score="3" ViewCount="398" Body="&lt;p&gt;I do a lot of low level programming at work. As such I often found myself pulling up an &lt;a href=&quot;http://www.mathsisfun.com/binary-decimal-hexadecimal-converter.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;online base converter&lt;/a&gt; to check my conversions. I relized that I wanted a way that I could do this from vim and thus I wrote this plugin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most notably it finds possible numbers as you type and gives you a completion list for the most common conversions. However, there are also command line commands to simply convert one base to another (Any base 2-16), and a mapping &lt;code&gt;&amp;lt;A-f&amp;gt;&lt;/code&gt; to pull up common conversions for the number under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure there are many things that could be optimized which is the reason I'm posting it here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Up until now I was only using this for myself and so I haven't bothered with any of the &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; stuff yet. I've never used them before so I need to research best practices etc. If any of you have any advice on anything regarding that I will happily take it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running vim 8.0.69 and usually use gVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And so without further ado, baseConverter.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; @Tracked&#xA;&quot; Base Conversion Plugin&#xA;&quot; Author: Tumbler Terrall&#xA;&quot; Last Edited: 02/03/2017 03:07 PM&#xA;&quot; Version: 1.2&#xA;&#xA;let g:vimBaseConversion = 1&#xA;&#xA;command! -nargs=1 Hexcon call HexConverter('&amp;lt;args&amp;gt;')&#xA;&quot; Automatically detect base and convert into 4 most common bases&#xA;command! -nargs=+ Base2Base echo BaseConversion(&amp;lt;f-args&amp;gt;)&#xA;&quot; Convert any base to any other (2-16)&#xA;command! ASCII call PrintASCIIChart()&#xA;&quot; Prints out a staic table for quick number to ASCII conversions&#xA;&#xA;nnoremap &amp;lt;A-f&amp;gt; :call HexConverter(expand('&amp;lt;cword&amp;gt;'))&amp;lt;CR&amp;gt;&#xA;&quot; Brings up the hex converter on number under cursor&#xA;&#xA;if has(&quot;autocmd&quot;)&#xA;augroup BaseConversion&#xA;   au!&#xA;   autocmd CursorMovedI * call CheckConversions()&#xA;augroup END&#xA;endif&#xA;&#xA;&quot; CheckConversions &amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Takes word under cursor and determines if it's a number. If it is it&#xA;&quot;         will pull up a conversion list, either in the completion list or in&#xA;&quot;         a command line print out. (This function is called automatically&#xA;&quot;         from a CursorMovedI event)&#xA;&quot;    input   - void&#xA;&quot;    returns - void&#xA;function! CheckConversions()&#xA;   let column = col('.')&#xA;   let wordBeforeCursor = matchstr(getline('.'), '\c\&amp;lt;[0-9a-fx]\+\.\=\x\+\%'.column.'c')&#xA;   let wordAfterCursor = matchstr(getline('.'), '\c\%'.(column-1).'c[0-9a-fx]\+\.\=\x\+')&#xA;   if (strlen(wordAfterCursor) == 0)&#xA;      &quot; None of the word is after the cursor&#xA;      let base = FindBase(wordBeforeCursor)&#xA;      let rawNumber = StripLeader(wordBeforeCursor, base)&#xA;      let beginingColumn = col('.') - strlen(wordBeforeCursor)&#xA;&#xA;      if (base != 0 &amp;amp;&amp;amp; IsNumber(rawNumber, base) &amp;amp;&amp;amp; rawNumber =~ '\S\{2,}')&#xA;         call ListConversions(base, rawNumber, beginingColumn, wordBeforeCursor)&#xA;      endif&#xA;   else&#xA;      &quot; Some of the number resides after the cursor... completing not possible&#xA;&#xA;      &quot; This section used to pull up the conversions in a command line print&#xA;      &quot; out as you typed, but it wasn't very useful and had some annoying bugs,&#xA;      &quot; so I've removed it for now.&#xA;   endif&#xA;endfunction&#xA;&#xA;&quot; ListConversions &amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Calls up a completion popup with conversion suggestions.&#xA;&quot;    input   - base: [int] base The base that the original number is in&#xA;&quot;              rawNumber: [int] The number that needs to be converted&#xA;&quot;              column: [int] The starting point of the number we're completing&#xA;&quot;              origWord: [string] The text that we're completing against&#xA;&quot;    returns - void&#xA;function! ListConversions(base, rawNumber, column, origWord)&#xA;   let label = '   ' . {2: 'BIN', 8: 'OCT', 10: 'DEC', 16: 'HEX'}[a:base]&#xA;   let decNumber = BaseConversion(a:rawNumber, a:base, 10)&#xA;   call complete(a:column, [&#xA;        \ {'word':a:origWord, 'menu':label},&#xA;        \ {'word':BaseConversion(a:rawNumber, a:base,  2, 1), 'menu': '   BIN'},&#xA;        \ {'word':BaseConversion(a:rawNumber, a:base,  8, 1), 'menu': '   OCT'},&#xA;        \ {'word':BaseConversion(a:rawNumber, a:base, 10, 1), 'menu': '   DEC'},&#xA;        \ {'word':BaseConversion(a:rawNumber, a:base, 16, 1), 'menu': '   HEX'},&#xA;        \ (decNumber &amp;gt; 31 &amp;amp;&amp;amp; decNumber &amp;lt; 127)?&#xA;        \ {'word':nr2char(BaseConversion(a:rawNumber, a:base, 10, 1)), 'menu': ' ASCII'} : {}])&#xA;endfunction&#xA;&#xA;&quot; HexConverter &amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Brings up a command line print out of conversion suggestions.&#xA;&quot;    input   - wordUnderCursor: [string] The number to try to convert&#xA;&quot;              optional: [bool] If present won't shift window&#xA;&quot;    returns - void&#xA;function! HexConverter(wordUnderCursor, ...)&#xA;   if !exists('t:inConvertMode')&#xA;      let t:inConvertMode = 0&#xA;   endif&#xA;   if !exists('t:lastCheck')&#xA;      let t:lastCheck = ''&#xA;   endif&#xA;   let base = FindBase(a:wordUnderCursor)&#xA;   let rawNumber = StripLeader(a:wordUnderCursor, base)&#xA;   if (strlen(a:wordUnderCursor) &amp;gt; 0)&#xA;      let N = strlen(BaseConversion(rawNumber, base, 2, 1))&#xA;   endif&#xA;   let shift = 0&#xA;   if (a:0 &amp;gt; 0)&#xA;      let winPercent = (winline()*100)/winheight(0)&#xA;      if (winPercent &amp;lt;= 10)&#xA;         let shift = 0&#xA;      elseif (winPercent &amp;lt; 36)&#xA;         let shift = 1&#xA;      elseif (winPercent &amp;lt; 65)&#xA;         let shift = 2&#xA;      elseif (winPercent &amp;lt; 89)&#xA;         let shift = 3&#xA;      else&#xA;         let shift = 4&#xA;      endif&#xA;   endif&#xA;&#xA;   if (base != 0 &amp;amp;&amp;amp; IsNumber(rawNumber, base) &amp;amp;&amp;amp; a:wordUnderCursor =~ '\S\{2,}' &amp;amp;&amp;amp; (a:0 || (t:lastCheck != a:wordUnderCursor)) &amp;amp;&amp;amp; strlen(a:wordUnderCursor) &amp;gt; 0)&#xA;      if (!t:inConvertMode)&#xA;         set cmdheight=5&#xA;         if (shift)&#xA;            execute 'call feedkeys(&quot;\&amp;lt;C-o&amp;gt;'.shift.'\&amp;lt;C-y&amp;gt;&quot;)'&#xA;         endif&#xA;         let t:inConvertMode = 1&#xA;      endif&#xA;      exe &quot;echo '  BIN: ' . printf('%&quot;.N.&quot;s', BaseConversion(rawNumber, base, 2, 1)) .'\n'.&quot; .&#xA;          \    &quot;'  OCT: ' . printf('%&quot;.N.&quot;s', BaseConversion(rawNumber, base, 8, 1)) .'\n'.&quot; .&#xA;          \    &quot;'  DEC: ' . printf('%&quot;.N.&quot;s', BaseConversion(rawNumber, base, 10, 1)).'\n'.&quot; .&#xA;          \    &quot;'  HEX: ' . printf('%&quot;.N.&quot;s', BaseConversion(rawNumber, base, 16, 1))&quot;&#xA;   else&#xA;      if (t:inConvertMode)&#xA;         set cmdheight=1&#xA;         if (shift)&#xA;            execute 'call feedkeys(&quot;\&amp;lt;C-o&amp;gt;'.shift.'\&amp;lt;C-e&amp;gt;&quot;)'&#xA;         endif&#xA;         let t:inConvertMode = 0&#xA;      endif&#xA;   endif&#xA;   if (t:lastCheck != a:wordUnderCursor)&#xA;      let t:lastCheck = a:wordUnderCursor&#xA;   else&#xA;      let t:lastCheck = ''&#xA;   endif&#xA;endfunction&#xA;&#xA;&quot; FindeBase &amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Does it's best to guess the base of the number.&#xA;&quot;    input   - number: [string] The number from which to determine the base&#xA;&quot;    returns - [int] The base number (2 for binary, 10 for decimal, etc...)&#xA;function! FindBase(number)&#xA;   if     (a:number[0:1] == '0b' &amp;amp;&amp;amp; IsNumber(a:number[2:], 2))&#xA;      return 2&#xA;   elseif (a:number[0:1] =~ '0[0-7]' &amp;amp;&amp;amp; IsNumber(a:number[2:], 8))&#xA;      return 8&#xA;   elseif (a:number[0:1] =~ '0x\c' &amp;amp;&amp;amp; IsNumber(a:number[2:], 16))&#xA;      return 16&#xA;   elseif (IsNumber(a:number, 10))&#xA;      return 10&#xA;   elseif (IsNumber(a:number, 16))&#xA;      return 16&#xA;   else&#xA;      return 0&#xA;   endif&#xA;endfunction&#xA;&#xA;&quot; IsNumber &amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Looks at all the digits of a given number and determines if it is a&#xA;&quot;            valid number for the given base.&#xA;&quot;    input   - number: [string] The number to check&#xA;&quot;              base: [int] The base to check for&#xA;&quot;    returns - [bool] True if valid, false if invalid&#xA;function! IsNumber(number, base)&#xA;   let digitList = {2: '[01.]', 8: '[0-7.]', 10: '[0-9.]', 16: '[0-9a-f.]'}&#xA;   for char in split(a:number, '\zs')&#xA;      if char !~ digitList[a:base]&#xA;         return 0&#xA;      endif&#xA;   endfor&#xA;   return 1&#xA;endfunction&#xA;&#xA;&quot; BaseConversion &amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Convert any base [2-16] to any other base [2-16].&#xA;&quot;    input   - num: [string] A string containing the number to convert&#xA;&quot;              inbase: [int] The base of the number to convert&#xA;&quot;              outbase: [int] The desired base&#xA;&quot;              optional: [bool] Whether or not to prepend a base leader (i.e. 0x)&#xA;&quot;    returns - void&#xA;function! BaseConversion(num, inBase, outBase, ...)&#xA;   let splitNum = split(a:num, '\.')&#xA;   let decNum = Base2Dec(splitNum[0], a:inBase)&#xA;   let decimalPrecision = 0&#xA;   if (len(splitNum) &amp;gt; 1)&#xA;      let decNum .= '.'.Frac2Dec(splitNum[1], a:inBase)&#xA;      let decimalPrecision = len(splitNum[1])&#xA;   endif&#xA;   if     (a:outBase == 2)&#xA;      return (a:0)?&quot;0b&quot;.Decimal2Base(decNum, 2, decimalPrecision):Decimal2Base(decNum, 2, decimalPrecision)&#xA;   elseif (a:outBase == 8)&#xA;      return (a:0)?&quot;0&quot; .Decimal2Base(decNum, 8, decimalPrecision):Decimal2Base(decNum, 8, decimalPrecision)&#xA;   elseif (a:outBase == 10)&#xA;      return Decimal2Base(decNum, 10, decimalPrecision)&#xA;   elseif (a:outBase == 16)&#xA;      return (a:0)?&quot;0x&quot;.Decimal2Base(decNum, 16, decimalPrecision):Decimal2Base(decNum, 16, decimalPrecision)&#xA;   else&#xA;      return Decimal2Base(decNum, a:outBase, decimalPrecision)&#xA;   endif&#xA;endfunction!&#xA;&#xA;&quot; Decimal2Base &amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Convert any decimal float to any base = [2-16]&#xA;&quot;   input   - number: [string] String representation of decimal float to convert&#xA;&quot;             base: [int] Desired base&#xA;&quot;             decimalPrecision: [int] If number has a radix portion, how many&#xA;&quot;                               places after the radix point before rounding&#xA;&quot;   returns - [string] String representation of base [base] number&#xA;function! Decimal2Base(number, base, decimalPrecision)&#xA;   let splitNum = split(a:number, '\.')&#xA;   let result = 0&#xA;   if (len(splitNum) &amp;gt; 1)&#xA;      let precision = (a:decimalPrecision &amp;gt; 4) ? (a:decimalPrecision) : 4&#xA;      let result = Frac2Base('.'.splitNum[1], a:base, a:decimalPrecision)&#xA;      if (result == 1)&#xA;         let result = Dec2Base(splitNum[0]+1, a:base)&#xA;      else&#xA;         let result = Dec2Base(splitNum[0], a:base) . result&#xA;      endif&#xA;      return substitute(result, '\..*\zs0\+$', '', '')&#xA;   else&#xA;      return Dec2Base(splitNum[0], a:base)&#xA;   endif&#xA;endfunction&#xA;&#xA;&quot; Base2Dec &amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Convert any base [2-16] to decimal.&#xA;&quot;    input   - number: [string] String representation of an int to convert&#xA;&quot;              base: [int] Base of input number&#xA;&quot;    returns - [int] Number converted to decimal&#xA;function! Base2Dec(number, base)&#xA;   let hexdig='0123456789abcdef'&#xA;   let result = 0&#xA;   let pos = 0&#xA;   let len = strlen(a:number)&#xA;   while pos &amp;lt; len&#xA;      let x = strpart(a:number, pos, 1)&#xA;      let d = match(hexdig, x.'\c')&#xA;      let result = result * a:base + d&#xA;      let pos = pos + 1&#xA;   endwhile&#xA;   return result&#xA;endfunction&#xA;&#xA;&quot; Dec2Base &amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Convert decimal integer to any base [2-16]&#xA;&quot;    input   - number: [string] String representation of a decimal number to&#xA;&quot;                      convert&#xA;&quot;              base: [int] Desired base&#xA;&quot;    returns - [int] Number converted to [base]&#xA;function! Dec2Base(number, base)&#xA;   let nr = str2float(a:number)&#xA;   let result = ''&#xA;   while (nr &amp;gt;= 1)&#xA;      let intresstr = printf(&quot;%f&quot;, nr / a:base)&#xA;      let intresstr = substitute(intresstr, '\.\d\+$', '', '')&#xA;      let intres = str2float(intresstr)&#xA;      let modres = float2nr(nr - intres * a:base)&#xA;      let result = printf(&quot;%x&quot;,modres) . result&#xA;      let nr = intres&#xA;   endwhile&#xA;   if (result == '')&#xA;      let result = '0'&#xA;   endif&#xA;   return toupper(result)&#xA;endfunction&#xA;&#xA;&quot; Frac2Base &amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Takes a decimal float less than one (a fraction) and converts it to a&#xA;&quot;            different base [2-16]&#xA;&quot;    input   - number: [string] String representation of a fraction (i.e. .25)&#xA;&quot;              base: [int] Desired base&#xA;&quot;              precision: [int] How many digits to compute before rounding&#xA;&quot;                 (min 4)&#xA;&quot;    returns - [string] String representation of fraction converted to new [base]&#xA;function! Frac2Base(number, base, precision)&#xA;   let hexdig='0123456789ABCDEF'&#xA;   let fraction = str2float(a:number)&#xA;   let loopCounter = 0&#xA;   let result = '.'&#xA;   let remainder = fraction&#xA;   while (remainder &amp;gt; 0 &amp;amp;&amp;amp; ((loopCounter &amp;lt; a:precision) || (loopCounter &amp;lt; 4)))&#xA;      let multiplied = remainder * a:base&#xA;      let digit = float2nr(multiplied)&#xA;      let remainder = multiplied - digit&#xA;      let result .= hexdig[digit]&#xA;      let loopCounter += 1&#xA;   endwhile&#xA;   if (remainder != 0)&#xA;      let multiplied = remainder * a:base&#xA;      let digit = float2nr(multiplied)&#xA;      if (digit &amp;gt;= (a:base+1)/2)&#xA;         &quot;Need to round&#xA;         let index = match(hexdig, result[loopCounter])+1&#xA;         let numOfTurnovers = 0&#xA;         let fullTurnover = 0&#xA;         while (index &amp;gt;= a:base)&#xA;            let result = result[:-2]&#xA;            let numOfTurnovers += 1&#xA;            if (numOfTurnovers == loopCounter)&#xA;               let fullTurnover = 1&#xA;               break&#xA;            endif&#xA;            let index = match(hexdig, result[loopCounter-numOfTurnovers])+1&#xA;         endwhile&#xA;         if (!fullTurnover)&#xA;            let result = result[:loopCounter-numOfTurnovers-1] . hexdig[index]&#xA;         else&#xA;            let result = 1&#xA;         endif&#xA;      endif&#xA;   endif&#xA;   return result&#xA;endfunction&#xA;&#xA;&quot; Frac2Dec &amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Takes a float less than one (a fraction) in any base [2-16] and&#xA;&quot;            converts it to a decimal fraction.&#xA;&quot;    input   - number: [string] String representation of fraction (i.e. .25)&#xA;&quot;              base: [int] Base of the input number [2-16]&#xA;&quot;    returns - [string] String representation of decimal fraction&#xA;function! Frac2Dec(number, base)&#xA;   if (a:base &amp;gt;= 2 &amp;amp;&amp;amp; a:base &amp;lt;= 16)&#xA;      let hexdig='0123456789abcdef'&#xA;      let result = 0.0&#xA;      let value  = 0.0&#xA;      let pos = 0&#xA;      let len = strlen(a:number)&#xA;      while pos &amp;lt; len&#xA;         let digit = a:number[pos]&#xA;         let value = match(hexdig, digit.'\c')&#xA;         let result += (value / pow(a:base, (pos+1.0)))&#xA;         let pos += 1&#xA;      endwhile&#xA;      let stringResult = substitute(printf('%.16f', result)[2:], '0\+$', '', '')&#xA;      return stringResult&#xA;   else&#xA;      return 0&#xA;   endif&#xA;endfunction&#xA;&#xA;&quot; StripLeader &amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Takes a string representation of a number and removes any header that&#xA;&quot;            isn't a valid digit. (i.e. 0x for hex)&#xA;&quot;    input   - number: [string] String representation of the number to strip&#xA;&quot;              base: [int] Base of input number&#xA;&quot;    returns - [string] String representation of the number without the header&#xA;function! StripLeader(number, base)&#xA;   if (a:base == 2)&#xA;      return substitute(a:number, '^0b\c', '', '')&#xA;   elseif (a:base == 8)&#xA;      return substitute(a:number, '^0', '', '')&#xA;   elseif (a:base == 10)&#xA;      return a:number&#xA;   elseif (a:base == 16)&#xA;      return substitute(a:number, '^0x\c', '', '')&#xA;   else&#xA;      return 0&#xA;   endif&#xA;endfunction&#xA;&#xA;&quot; PrintASCIIChart &amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&quot;  brief: Prints a static chart of ASCII values so I can stop looking it up&#xA;&quot;    input   - void&#xA;&quot;    returns - void&#xA;function! PrintASCIIChart()&#xA;   echo &quot;| DEC HEX OCT CHR | DEC HEX OCT CHR | DEC HEX OCT CHR | \n&quot;&#xA;   let start = 32&#xA;   while (start &amp;lt;= 63)&#xA;      for i in [0, 1, 2]&#xA;         let number = start + (i * 32)&#xA;         echon &quot;| &quot;&#xA;         echon repeat(&quot; &quot;, 3-len(number))&#xA;         echon number&#xA;         echon &quot;  &quot;&#xA;         echohl PREPROC&#xA;         echon BaseConversion(number, 10, 16) . &quot; &quot;&#xA;         echohl NONE&#xA;         let oct = BaseConversion(number, 10, 8)&#xA;         echon repeat(&quot; &quot;, 3-len(oct))&#xA;         echon oct . &quot;  &quot;&#xA;         echohl PREPROC&#xA;         echon nr2char(number)&#xA;         echohl NONE&#xA;         echon &quot;  &quot;&#xA;      endfor&#xA;      echon &quot;|\n&quot;&#xA;      let start += 1&#xA;   endwhile&#xA;endfunction&#xA;&quot;&amp;lt;&amp;lt; End of base Conversion plugin &amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-02-09T18:39:24.450" Title="Code review request: Base converter" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11329" PostTypeId="2" ParentId="11328" CreationDate="2017-02-09T18:10:03.310" Score="7" Body="&lt;p&gt;I'll report areas of improvements as I find them on-the-fly. There is nothing much to say -- except I remember there was a plugin on this topic published a decade ago may be.&lt;/p&gt;&#xA;&lt;h2&gt;Plugin architecture&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;Guards&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If this is meant to be a plugin, it's best to follow the naming convention for the anti-inclusion guard, i.e. it should be named &lt;code&gt;g:loaded_{pluginname}&lt;/code&gt;. On the subject I've gone 2 step furthers : all my plugins have a &lt;code&gt;s:k_version&lt;/code&gt; variable that stores the version number, and the following anti-inclusion guard:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Avoid global reinclusion {{{1&#xA;let s:k_version = '1.2'&#xA;if &amp;amp;cp || (exists(&amp;quot;g:loaded_baseconversion&amp;quot;)&#xA;      \ &amp;amp;&amp;amp; (g:loaded_baseconversion &amp;gt;= s:k_version)&#xA;      \ &amp;amp;&amp;amp; !exists('g:force_reload_baseconversion'))&#xA;  finish&#xA;endif&#xA;let g:loaded_baseconversion = s:k_version&#xA;let s:cpo_save=&amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;...code...&#xA;&amp;quot; }}}1&#xA;let &amp;amp;cpo=s:cpo_save&#xA;&amp;quot;=============================================================================&#xA;&amp;quot; vim600: set fdm=marker:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The advantage is that when I set &lt;code&gt;g:force_reload_baseconversion&lt;/code&gt; to 1, it stays put, and I can happily work on the plugin code and reload it as many times as I wish. Actually I have a &lt;code&gt;:Reload&lt;/code&gt; command hidden in &lt;a href=&quot;https://github.com/LucHermitte/lh-misc/&quot; rel=&quot;noreferrer&quot;&gt;my miscellaneous plugins&lt;/a&gt; that sets this &lt;code&gt;force&lt;/code&gt; variable on.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Functions&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;It's best to avoid global functions that anybody can access. If they're meant to be exposed to other users, put them into an autoload plugin. It avoids invading the global namespace, and it also brings much better starting times.&lt;/p&gt;&#xA;&lt;p&gt;Also, it's interesting to annotate functions with the &lt;code&gt;abort&lt;/code&gt; clause. This way in case of errors, VimL interpreter won't try to continue to interpret every following Ex command in the function. This point is addressed in google &amp;quot;stylistic&amp;quot; document for VimL.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Licence&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;State explicitly the licence under which you wish to distribute your code. Right now, unless explicitly authorized nobody can redistribute your plugin. I'm not even sure we are authorized to use it -- I should ask to my colleague with an expertise on the subject. As it has been published on vi.SE, SE licensing policy applies on this very code, but not on the plugin once distributed on github or wherever else.&lt;/p&gt;&#xA;&lt;h2&gt;Internal variables&lt;/h2&gt;&#xA;&lt;p&gt;I see variables like &lt;code&gt;t:lastCheck&lt;/code&gt;. Any plugin could decide to use a variable like this one for its own needs (don't hesitate to fix my English ^^'). As it has no prefix to say this variable belongs to Baseconversion plugin, we can't blame this other plugin. Beside, do we really need to save this variable on a tab basis? Couldn't it be a script-local, and thus global, variable?&lt;/p&gt;&#xA;&lt;h2&gt;Performances&lt;/h2&gt;&#xA;&lt;p&gt;The only places I see where there could be issues, is where there are loops and function static constants that could be extracted from function definitions (e.g. &lt;code&gt;digitList&lt;/code&gt; could become &lt;code&gt;s:digitList&lt;/code&gt; and be defined outside the function definition).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;IsNumber&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;May be a negated pattern would be faster. The only problem I see is that those patterns are not trivial, and quite unmaintenable when not initiated to them.&lt;/p&gt;&#xA;&lt;p&gt;But here, positive logic would be even more simple and efficient: &lt;code&gt;return a:number =~ '^'.s:digitList[a:base].'*$'&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;BaseConversion&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I suspect you could use a dictionary in order to avoid the switch and to duplicate code. I've no idea of the impact on performances.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let s:k_prefixes = { 2: '0b', 8: '0', 16: '0x' }&#xA;function! base_conversion#convert(num, inBase, outBase, ...) abort&#xA;   ...&#xA;   let prefix = get(s:k_prefixes, a:outBase, '')&#xA;   return prefix . base_conversion#Decimal2Base(decNum, 16, decimalPrecision)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Base2Dec&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If this function has for precondition that &lt;code&gt;input&lt;/code&gt; is a number in the expressed base, state it more clearly in the documentation of the function.&#xA;I even have a series of &lt;code&gt;lh#assert#*()&lt;/code&gt; functions on Design By contract in VimL topic, but unlike C, C++ and Python assertions they'll impact performances.&lt;/p&gt;&#xA;&lt;p&gt;I wouldn't have used &lt;code&gt;strpart&lt;/code&gt;, but simply &lt;code&gt;a:number[pos]&lt;/code&gt; out of habit. However, I've no idea of its impact on performances.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;misc ideas&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;When performances matters, I try to avoid &lt;code&gt;match()&lt;/code&gt; and prefer &lt;code&gt;stridx()&lt;/code&gt;. However, because of case sensitivity, it may not be that simple here.&lt;/p&gt;&#xA;&lt;p&gt;Most loops are quite usual and hard to express otherwise in VimL. I'm not inspired to propose any possible improvement.&lt;/p&gt;&#xA;&lt;p&gt;I would have tried to avoid &lt;code&gt;pow()&lt;/code&gt; out of reflex from the other languages I'm working with. However, I cannot really guarantee that manually hardcoding exponentiation to 2^n would improve anything, nor anything significantly,  once interpreted by Vim.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;l:variables&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that some may point out that local variables could be prefixed. google stylistic document even strongly encourage to prefix all local variables. I disagree completely on this topic. The problem is exactly the same with other languages: a same identifier may designate a global variable, a local variable, a parameter, a static variable (localized globals in C), an attribute, etc. While I, indeed, follow a different naming convention for globals, I don't follow any for local variables, except leaving them alone.&lt;/p&gt;&#xA;&lt;p&gt;There are indeed a few cases where a difference may be observed: In order to store a Funref in a simple variable (and not in behind a dictionary key), the variable name shall start with a capital letter. In those situations, I did need to prefix my variable with &lt;code&gt;l:&lt;/code&gt; to avoid confusion with global functions. Shall we always prefix all variables for consistency reasons with those rare case? Today, I don't buy it, &lt;code&gt;l:variables&lt;/code&gt; make my eyes bleed. This is just my personal opinion: as far as I'm concerned, there is no right nor wrong way on this subject: &lt;code&gt;l:&lt;/code&gt; fixes issues with funcref variables, but we loose the possibility to run &lt;code&gt;:echo/:exe getline('.')&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-02-09T18:39:24.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11330" PostTypeId="2" ParentId="6908" CreationDate="2017-02-09T23:08:56.253" Score="2" Body="&lt;p&gt;For what you've asked, there may be a simpler solution than employing alignment plugins. What you need is a text object for table cells:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference:&#xA;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/15.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://learnvimscriptthehardway.stevelosh.com/chapters/15.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap ic :&amp;lt;c-u&amp;gt;normal! T\|vt\|&amp;lt;cr&amp;gt;                                                                                                                                                                             &#xA;onoremap ac :&amp;lt;c-u&amp;gt;normal! F\|vf\|&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I noticed the &lt;code&gt;ic&lt;/code&gt;, &lt;code&gt;ac&lt;/code&gt; (mnemonic: inside cell, around cell) objects are free, but you can of course change them to &lt;code&gt;i|&lt;/code&gt; &lt;code&gt;a|&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then for changing the content of a cell, just press &lt;code&gt;cic&lt;/code&gt; or combine with whatever operator you need. (&lt;code&gt;dac&lt;/code&gt; : delete a cell)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For completeness, i found a mapping useful which creates a separator row:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap \|\| &amp;lt;Esc&amp;gt;kyyp:s/\v[^\|]/-/g&amp;lt;CR&amp;gt;:nohlsearch&amp;lt;CR&amp;gt;                                                                                                                                                           &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that you can press || while starting a new row to copy the line above and essentially replace anything but pipes with a dash.&lt;/p&gt;&#xA;" OwnerUserId="11258" LastEditorUserId="1841" LastEditDate="2017-02-10T07:33:44.077" LastActivityDate="2017-02-10T07:33:44.077" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11331" PostTypeId="2" ParentId="2920" CreationDate="2017-02-10T02:24:30.680" Score="-2" Body="&lt;p&gt;Add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;history &amp;lt; 1000&#xA;  set history=1000&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://github.com/tpope/vim-sensible/commit/f7bdc45c03083d61c3955e54a2ef610b21d2801e&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tpope/vim-sensible/commit/f7bdc45c03083d61c3955e54a2ef610b21d2801e&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11260" LastActivityDate="2017-02-10T02:24:30.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11332" PostTypeId="1" CreationDate="2017-02-10T04:20:21.893" Score="0" ViewCount="124" Body="&lt;p&gt;Classical replace command looks like &lt;code&gt;%s/old_pattern/new_pattern&lt;/code&gt; which is fine, but working with code or constructing complex search regular expression is not the best option. I'd like to present my own solution and looking for better options.&lt;/p&gt;&#xA;" OwnerUserId="179" LastActivityDate="2017-02-10T10:44:06.100" Title="Search and replace workflow" Tags="|search|replace|" AnswerCount="2" CommentCount="0" ClosedDate="2019-02-24T18:33:15.167" ContentLicense="CC BY-SA 3.0" />
  <row Id="11333" PostTypeId="2" ParentId="11332" CreationDate="2017-02-10T04:20:21.893" Score="0" Body="&lt;p&gt;My current workflow looks like:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Search for word using &lt;code&gt;#&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;?&lt;/code&gt; or &lt;code&gt;:s/search_pattern&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Replace first occurrence using &lt;code&gt;:s//new_pattern&lt;/code&gt; this works because empty search pattern in this command will use content of the search register &lt;code&gt;&quot;/&lt;/code&gt; which contains the last search pattern in our case &lt;code&gt;search_pattern&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Apply replace to all buffer using &lt;code&gt;g&amp;amp;&lt;/code&gt; which is a shortcut to the &lt;code&gt;:s//~/&amp;amp;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Suggestions are welcome.&lt;/p&gt;&#xA;" OwnerUserId="179" LastActivityDate="2017-02-10T04:20:21.893" CommentCount="0" CommunityOwnedDate="2017-02-10T04:20:21.893" ContentLicense="CC BY-SA 3.0" />
  <row Id="11334" PostTypeId="2" ParentId="11332" CreationDate="2017-02-10T10:44:06.100" Score="2" Body="&lt;p&gt;Another workflow you can consider:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Search for word using &lt;code&gt;#&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;?&lt;/code&gt; or &lt;code&gt;:s/search_pattern&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Make your change with &lt;code&gt;cgn&lt;/code&gt; which change the next matched pattern.&lt;/li&gt;&#xA;&lt;li&gt;Pressing &lt;code&gt;.&lt;/code&gt; will make the same change, for the next occurrence of the pattern. (so you can &lt;code&gt;.&lt;/code&gt; &lt;code&gt;.&lt;/code&gt; &lt;code&gt;.&lt;/code&gt; ... to see each change, one at a time)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2017-02-10T10:44:06.100" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11335" PostTypeId="1" AcceptedAnswerId="11345" CreationDate="2017-02-10T14:17:16.233" Score="10" ViewCount="4337" Body="&lt;p&gt;I opened up a document from 2015 I saved using the built in crypto in vim (&lt;code&gt;:X&lt;/code&gt;). That was saves using &lt;code&gt;blowfish&lt;/code&gt; at the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The message I got now (2017) was this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Warning: Using a weak encryption method; see :help 'cm'&#xA;Enter encryption key: *********************************************&#xA;Enter same key again: *********************************************&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That was weird, I thought, but I assumed it had to do with some flaw, and after reading up on the crypto methods I &lt;code&gt;set cryptomethod=blowfish2&lt;/code&gt;. This works after opening it, showing cryptomethod as blowfish 2. The problem is that I still get the message about using weak encryption! Why? Are there remnants of the old blowfish1 crypto signature? Do I have to export the text and resave it in order to fix it?&lt;/p&gt;&#xA;" OwnerUserId="1087" LastActivityDate="2017-02-11T14:24:23.267" Title="Why does vim complain about weak crypto when using blowfish2?" Tags="|encryption|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11336" PostTypeId="1" CreationDate="2017-02-10T14:37:49.353" Score="0" ViewCount="1259" Body="&lt;p&gt;I've just installed neovim and I have problem with RubyGem.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output of &lt;code&gt;:CheckHealth&lt;/code&gt; indicates missing neovim RubyGem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;## Ruby provider&#xA;  - ERROR: Missing Neovim RubyGem&#xA;      - SUGGESTIONS:&#xA;        - Install or upgrade the neovim RubyGem using `gem install neovim`.&#xA;  - INFO: Ruby Version: ruby 2.2.6p396 (2016-11-15 revision 56800) [x86_64-linux]&#xA;  - INFO: Host Executable: not found&#xA;  - INFO: Host Version: not found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After installing &lt;code&gt;sudo gem install neovim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Successfully installed neovim-0.3.1&#xA;Parsing documentation for neovim-0.3.1&#xA;Done installing documentation for neovim after 0 seconds&#xA;1 gem installed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;:CheckHealth&lt;/code&gt; is the same as before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;## Ruby provider&#xA;  - ERROR: Missing Neovim RubyGem&#xA;      - SUGGESTIONS:&#xA;        - Install or upgrade the neovim RubyGem using `gem install neovim`.&#xA;  - INFO: Ruby Version: ruby 2.2.6p396 (2016-11-15 revision 56800) [x86_64-linux]&#xA;  - INFO: Host Executable: not found&#xA;  - INFO: Host Version: not found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I missing something? How can I fix this problem? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo has('ruby') returns 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you very much.&lt;/p&gt;&#xA;" OwnerUserId="11271" LastEditorUserId="51" LastEditDate="2017-07-03T06:55:38.600" LastActivityDate="2017-11-13T16:28:13.773" Title="Missing Neovim RubyGem" Tags="|neovim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11337" PostTypeId="1" AcceptedAnswerId="13563" CreationDate="2017-02-10T16:22:00.260" Score="0" ViewCount="775" Body="&lt;p&gt;Archlinux, termite -&gt; tmux -&gt; neovim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to open ranger in new pane, and when it ended and pane was closed - open selected file/files. This flow is similar to Tim Pope`s dispatch behavior&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; inspired by francoiscabrol plugin&#xA;function! OpenRanger(dir)&#xA;  let currentPath = expand(a:dir)&#xA;  let tmp_file_path = tempname()&#xA;  exec 'silent !tmux splitw ranger --choosefiles=' . shellescape(tmp_file_path) . ' ' .currentPath&#xA;  call system('notify-send &quot;exec is ended&quot;') &quot; debug string, was fired&#xA;  if filereadable(tmp_file_path)&#xA;    call system('notify-send &quot;tmpfile was readable&quot;') &quot; debug string, wasnt fired&#xA;    for f in readfile(tmp_file_path)&#xA;      exec 'edit '. f&#xA;    endfor&#xA;    call delete(tmp_file_path)&#xA;  endif&#xA;  redraw!&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;f :call OpenRanger('%:p:h')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;F :call OpenRanger('')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I force to execute &lt;code&gt;if filereadable(tmp_file_path)&lt;/code&gt; after pane was closed (on neovim, &lt;a href=&quot;https://github.com/ranger/ranger/issues/279&quot; rel=&quot;nofollow noreferrer&quot;&gt;which have issues with that&lt;/a&gt; )?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This don't work either&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! OpenRanger(dir)&#xA;  let currentPath = expand(a:dir)&#xA;  let tmp_file_path = tempname()&#xA;  let rangerCallback = { 'name': 'ranger' , 'tmp_file_path': tmp_file_path}&#xA;  function! rangerCallback.on_exit(id, code)&#xA;    call system('notify-send callback') &quot; was fired before I close ranger&#xA;    &quot; bdelete!&#xA;    if filereadable(self.tmp_file_path)&#xA;      for f in readfile(self.tmp_file_path)&#xA;        exec 'edit '. f&#xA;      endfor&#xA;      call delete(self.tmp_file_path)&#xA;    endif&#xA;  endfunction&#xA;  tabnew&#xA;  call termopen('tmux splitw ranger --choosefiles=' . shellescape(tmp_file_path) . ' ' . currentPath, rangerCallback)&#xA;  startinsert&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11273" LastEditorUserId="4472" LastEditDate="2017-09-13T22:04:50.480" LastActivityDate="2017-09-14T00:49:50.930" Title="How to open ranger from neovim and tmux, like Tim Pope`s dispatch do" Tags="|neovim|tmux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11338" PostTypeId="1" CreationDate="2017-02-10T17:18:30.107" Score="3" ViewCount="290" Body="&lt;p&gt;Starting &lt;code&gt;vim&lt;/code&gt; (8.0) with an empty &lt;code&gt;.vimrc&lt;/code&gt;, or as &lt;code&gt;vim -u /dev/null&lt;/code&gt;.&#xA;Executing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nocompatible&#xA;:set wildmode=list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the screen:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e .config/█&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I always thought that what happens when you press &lt;code&gt;Tab&lt;/code&gt; is the result of my &lt;code&gt;statusline&lt;/code&gt; or &lt;code&gt;laststatus&lt;/code&gt;, but changing those do not affect the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e .config/&#xA;alot/&#xA;aurgetrc&#xA;aurvote&#xA;awesome/&#xA;compton.conf&#xA;:e .config/█&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice the duplicated &lt;code&gt;:e .config/&lt;/code&gt; at the top.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command line is still in the bottom, and what happens next when I type &lt;code&gt;a&lt;/code&gt; and press &lt;code&gt;Tab&lt;/code&gt; falls beyond by comprehension:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e .config/&#xA;alot/&#xA;aurgetrc&#xA;aurvote&#xA;awesome/&#xA;compton.conf&#xA;:e .config/a&#xA;alot/     aurgetrc  aurvote   awesome/&#xA;:e .config/a█&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It &lt;em&gt;keeps&lt;/em&gt; the whole command line completion history for each &lt;code&gt;Tab&lt;/code&gt; press. Further:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e .config/&#xA;alot/&#xA;aurgetrc&#xA;aurvote&#xA;awesome/&#xA;compton.conf&#xA;:e .config/a&#xA;alot/     aurgetrc  aurvote   awesome/&#xA;:e .config/au&#xA;aurgetrc  aurvote&#xA;:e .config/au█&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Needless to say that if I remove &lt;code&gt;au&lt;/code&gt; hitting &lt;code&gt;Backspace&lt;/code&gt;, and then press &lt;code&gt;Tab&lt;/code&gt; again, even more lines are added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I expect to see command line and wild menu displaying very recent list of completion options when &lt;code&gt;Tab&lt;/code&gt; is pressed. How can this be done?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aurgetrc  aurvote&#xA;:e .config/au█&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8699" LastActivityDate="2019-07-07T07:06:12.007" Title="Undesired command line completion history" Tags="|command-line|wildmenu|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11339" PostTypeId="2" ParentId="11338" CreationDate="2017-02-10T18:07:30.707" Score="1" Body="&lt;p&gt;Not an entire solution, but I haven't figured out the last part yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK there's no way to clear the screen except by finishing the command or cancelling it. So let's try with a mapping instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cnoremap &amp;lt;S-Tab&amp;gt; &amp;lt;C-c&amp;gt;:&amp;lt;Up&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will cancel the current command, clearing the screen, and loading it again in the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: I tried to also restart the completion with &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; but the tab char was inserted instead...&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2017-02-10T18:07:30.707" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11340" PostTypeId="2" ParentId="10193" CreationDate="2017-02-10T18:09:37.237" Score="3" Body="&lt;p&gt;If you have known start and end delimiters, you should use regions (&lt;code&gt;:h :syn-region&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region Emphasis start=&quot;\\\@&amp;lt;!\z(_\)&quot; skip=&quot;\%(\s\|\\\)\@&amp;lt;=\z1\|\z1\k&quot; end=&quot;\\\@&amp;lt;!\z1&quot; keepend contains=Strong,Strike&#xA;syntax region Strong start=&quot;\\\@&amp;lt;!\z(\*\)&quot; skip=&quot;\%(\s\|\\\)\@&amp;lt;=\z1\|\z1\k&quot; end=&quot;\\\@&amp;lt;!\z1&quot; keepend contains=Emphasis,Strike&#xA;syntax region Strike start=&quot;\\\@&amp;lt;!\z(\~\~\)&quot; skip=&quot;\%(\s\|\\\)\@&amp;lt;=\z1\|\z1\k&quot; end=&quot;\\\@&amp;lt;!\z1&quot; keepend contains=Emphasis,Strong&#xA;&#xA;highlight default link Emphasis WarningMsg&#xA;highlight default link Strong ErrorMsg&#xA;highlight default link Strike Conceal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The regions above use the syntax-specific capture group (&lt;code&gt;:h /\z(&lt;/code&gt;) which is great for broad patterns (e.g. &lt;code&gt;if..endif&lt;/code&gt;, &lt;code&gt;while..endwhile&lt;/code&gt;, etc.), but in this case, it's mainly for readability and avoiding some repetition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each region starts with the &lt;code&gt;\z(\)&lt;/code&gt; atom to define your delimiter and they must end with what was captured (&lt;code&gt;:h /\z1&lt;/code&gt;).  Additionally, the delimiters can't be preceded by a backslash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To skip the delimiters under certain circumstances, the &lt;code&gt;\%(\s\|\\\)\@&amp;lt;=\z1\|\z1\k&lt;/code&gt; pattern is used: If it's preceded by whitespace or a backslash, or if it's followed by a keyword character, it should not be considered the end of the region.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each region contains the others which allows nesting, giving us highlighting like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/k7jnb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/k7jnb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Existing plugins&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/search?utf8=%E2%9C%93&amp;amp;q=markdown+syntax+language%3A%22Vim+script%22&amp;amp;type=Repositories&amp;amp;ref=searchresults&quot; rel=&quot;nofollow noreferrer&quot;&gt;I would like to point out that there are already a number of markdown syntax plugins available for Vim&lt;/a&gt;.  There's nothing wrong with making your own, but there's plenty of reference material you could draw from, including one specifically made for &lt;a href=&quot;https://github.com/vim-pandoc/vim-pandoc-syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;pandoc&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-02-10T18:09:37.237" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11342" PostTypeId="1" CreationDate="2017-02-10T23:58:49.063" Score="1" ViewCount="53" Body="&lt;p&gt;&lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; jump to the previous location in the jump list. However, I often open a file, do some searching in it, and then have to press &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; a lot to get back to the original file. Is there a command that traverses back through the jump list until it gets to a different file, so I can get back with only one keypress?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(yes, I could just set a mark, but I can never remember to do that.)&lt;/p&gt;&#xA;" OwnerUserId="6701" LastActivityDate="2017-02-10T23:58:49.063" Title="How can I jump to the previous file?" Tags="|jumplist|" AnswerCount="0" CommentCount="2" ClosedDate="2017-02-11T03:49:31.863" ContentLicense="CC BY-SA 3.0" />
  <row Id="11343" PostTypeId="1" AcceptedAnswerId="11410" CreationDate="2017-02-11T06:57:19.503" Score="2" ViewCount="118" Body="&lt;p&gt;Currently, a colleague and I are working on a joint project written in LaTeX. I am using a plugin (VimTeX) which, in addition to calling a compiler tool (upon saving the file) offers some bindings for ease of use. Given my familiarity with the plugin and vim in general I would prefer not to switch to another option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently, we noticed that his editor (TeXStudio) will catch all the changes I make once I save (we are sharing via Dropbox) while we are simultaneously editing the .tex file. It also appears that after a few second delay (following a save on his end) gvim will let me know that changes have been made to the file and prompt me to either open the edited version or not -- however doing this I seem to lose my work as I can't save the file without overwriting the work he just completed. I appreciate that vim lets me know that he has recompiled the file, but could it just make the changes he saved and act as nothing I've done has changed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For clarity I am providing an example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Friend and I both have editor open to shared .tex file.&lt;/li&gt;&#xA;&lt;li&gt;Friend adds text to section 2.&lt;/li&gt;&#xA;&lt;li&gt;I add text to section 3.&lt;/li&gt;&#xA;&lt;li&gt;If my friend saves the file first I eventually get a message from vim as I described above. &lt;/li&gt;&#xA;&lt;li&gt;If I use his saved version then I lose the changes I made to section 3. If instead I keep going with my version and save, his changes are never seen by my editor, and so once I save it will overwrite the changes he just made.&lt;/li&gt;&#xA;&lt;li&gt;If I save the file first, he will see the changes I made to section 3 pop up in his editor and he gets to keep his work (in section 2). Then, he can save the file with both of our changes in place.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My preference would be for the work I'm doing and the work my friend has done to merge nicely similar to the way things work on his end. We don't work on the same sections of the document at the same time so there is no harm in this type of result being achieved. If this cannot be done, I am open to other suggestions.&lt;/p&gt;&#xA;" OwnerUserId="11279" LastActivityDate="2017-02-14T20:39:53.297" Title="Way to merge edits in a shared file during simultaneous editing" Tags="|gvim|filetype-tex|plugin-vimtex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11344" PostTypeId="1" CreationDate="2017-02-10T20:39:01.507" Score="0" ViewCount="271" Body="&lt;p&gt;In file whenever I am coming across (int or string)  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;id&quot;,&quot;type&quot;: &quot;int&quot;},&#xA;name&quot;,&quot;type&quot;:&quot;string&quot;}, &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to replace with  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;private int id&#xA;private String name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Need VI command which updates private [int | string] at beginning of line depending on end of the string.&lt;/p&gt;&#xA;" OwnerUserId="11283" OwnerDisplayName="doketan" LastEditorUserId="343" LastEditDate="2017-02-11T14:28:35.273" LastActivityDate="2017-02-11T14:28:35.273" Title="Modify beginning of the line based on pattern at end of line" Tags="|substitute|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11345" PostTypeId="2" ParentId="11335" CreationDate="2017-02-11T14:24:23.267" Score="13" Body="&lt;p&gt;The cryptmethod is stored in the file itself, and isn't automatically updated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see this with &lt;code&gt;less&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ less a&#xA;VimCrypt~02!!&amp;lt;C7&amp;gt;\&amp;lt;E1&amp;gt;wZzm&#xA;^E^X^Z&amp;lt;92&amp;gt;5&amp;lt;C9&amp;gt;I6&amp;lt;9C&amp;gt;S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;VimCrypt~01!&lt;/code&gt; is &lt;code&gt;cm=zip&lt;/code&gt;, &lt;code&gt;VimCrypt~02!&lt;/code&gt; is &lt;code&gt;cm=blowfish&lt;/code&gt;, and I think you can deduce what &lt;code&gt;VimCrypt~03!&lt;/code&gt; stands for :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To upgrade a file, open it, explicitly set &lt;code&gt;cm=blowfish2&lt;/code&gt;, and write it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim a&#xA;Need encryption key for &quot;a&quot;&#xA;Warning: Using a weak encryption method; see :help 'cm'&#xA;Enter encryption key: [enter-key]&#xA;&#xA;:set cm?&#xA;  cryptmethod=blowfish&#xA;:set cm=blowfish2&#xA;:w&#xA;&quot;a&quot; [blowfish2] 1L, 3C written&#xA;:q&#xA;&#xA;$ less a&#xA;VimCrypt~03!O[P&amp;lt;D5&amp;gt;1&amp;lt;D1&amp;gt;&amp;lt;DA&amp;gt;^Zis&amp;lt;88&amp;gt;q&amp;lt;AB&amp;gt;&amp;lt;99&amp;gt;&amp;lt;8C&amp;gt;&amp;lt;A6&amp;gt;&amp;lt;C4&amp;gt;&amp;lt;FB&amp;gt;6&#xA;a lines 1-1/1 (END)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-02-11T14:24:23.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11346" PostTypeId="2" ParentId="11344" CreationDate="2017-02-11T14:27:22.640" Score="1" Body="&lt;p&gt;You could do this with capture groups:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(.{-})&quot;.*(int|string)&quot;},$/private \2 \1&#xA;:g/^\Cprivate string/normal w~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The parentheses create two &quot;capture groups&quot;, the contents of which are then used in the replacement string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second line simply corrects the case of &quot;string&quot; to &quot;String&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first command, in detail:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%s/foo/bar&lt;/code&gt;: This is a substitute command that replaces &lt;code&gt;foo&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;In the command above, &lt;code&gt;foo&lt;/code&gt; is the pattern we search for. In our command, this is &lt;code&gt;\v(.{-})&quot;.*(int|string)&quot;},$&lt;/code&gt; This breaks down as:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt;: This turns on &quot;very-magic&quot; mode, which allows us to use more powerful regular-expression features without having to escape a lot of characters,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(.{-})&lt;/code&gt; This is the first capture group, and matches everything on the line up to the first &lt;code&gt;&quot;&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;&lt;/code&gt; This matches the first &lt;code&gt;&quot;&lt;/code&gt; on the line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*&lt;/code&gt; This matches everything up to the &lt;code&gt;int&lt;/code&gt; or &lt;code&gt;string&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(int|string)&lt;/code&gt; This is the second capture group, and matches &lt;em&gt;either&lt;/em&gt; int &lt;em&gt;or&lt;/em&gt; string&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;},$&lt;/code&gt; This matches the remainder of the line, to ensure the int/string was actually at the end of the line&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;bar&lt;/code&gt; is the replacement text we use. In our command, this is &lt;code&gt;private \2 \1&lt;/code&gt;. The &lt;code&gt;\1&lt;/code&gt; and &lt;code&gt;\2&lt;/code&gt; are replaced with the contents of the two captured groups.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You might need to tweak this if the contents of the lines you are searching for do not precisely match what you pasted in the question. e.g. If the lines really look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&quot;lots&quot;,&quot;of&quot;,&quot;other&quot;,&quot;stuff&quot;,&quot;id&quot;,&quot;type&quot;: &quot;int&quot;},&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'd could use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v.*&quot;([^&quot;]{-})&quot;,&quot;[^&quot;]{-}&quot;: &quot;(int|string)&quot;},$/private \2 \1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-02-11T14:27:22.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11347" PostTypeId="5" CreationDate="2017-02-11T14:43:27.773" Score="0" Body="" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-02-11T14:43:27.773" LastActivityDate="2017-02-11T14:43:27.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11348" PostTypeId="4" CreationDate="2017-02-11T14:43:27.773" Score="0" Body="Questions relating to the 'dictionary' or 'dict' setting." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-02-11T14:43:27.773" LastActivityDate="2017-02-11T14:43:27.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11349" PostTypeId="1" AcceptedAnswerId="11367" CreationDate="2017-02-11T15:51:50.820" Score="19" ViewCount="6029" Body="&lt;p&gt;I'm brushing up on my vim skills and fiddling with completion using the Ctrl-n command. I'm programming in Perl. When I am in insert mode and hit Ctrl-n, I get a message that it is &quot;Scanning included file&quot; down at the bottom of the terminal and it looks like it's scanning files in the perl distribution directories. This can take several seconds before it finishes. It looks like it does this with packages I include that are commented out:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;#use Moose;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have to delete these lines for this feature to be of any value. Am I missing something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the perl-support plugin.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-02-12T17:15:25.017" Title="Ctrl-n completion takes a long time for “scanning included file”" Tags="|autocompletion|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11350" PostTypeId="5" CreationDate="2017-02-11T16:29:25.437" Score="0" Body="&lt;p&gt;This tag is for questions concerning Vim's Encryption feature (which is documented in &lt;code&gt;:help encryption&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Questions about using the following commands and settings should use this tag:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:X&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'key'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'cryptmethod'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-02-11T18:40:42.003" LastActivityDate="2017-02-11T18:40:42.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11351" PostTypeId="4" CreationDate="2017-02-11T16:29:25.437" Score="0" Body="Vim is able to write files encrypted, and read them back. The encrypted text&#xD;&#xA;cannot be read without the right key." OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-02-11T17:58:21.313" LastActivityDate="2017-02-11T17:58:21.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11352" PostTypeId="1" AcceptedAnswerId="11361" CreationDate="2017-02-11T17:04:44.437" Score="2" ViewCount="184" Body="&lt;p&gt;Say I am writing a plugin and constantly editing scripts in &lt;code&gt;ftplugin&lt;/code&gt;. How do I efficiently test the changes? I can't simply &lt;code&gt;source&lt;/code&gt; the editted file because they are filetype-specific. For example, if there is a line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set buftype=nofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the script, and I &lt;code&gt;source&lt;/code&gt; it, then whatever buffer I'm in will no longer be writable into a file...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can open another vim instance to test the change, but that is not very efficient because I have to reopen one whenever I make changes to the ftplugin scripts.&lt;/p&gt;&#xA;" OwnerUserId="11047" LastEditorUserId="11047" LastEditDate="2017-02-11T17:40:29.440" LastActivityDate="2017-02-12T03:10:14.947" Title="How do I test ftplugin scripts efficiently" Tags="|vimscript|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11353" PostTypeId="1" AcceptedAnswerId="12489" CreationDate="2017-02-11T17:23:21.933" Score="0" ViewCount="61" Body="&lt;p&gt;I am using &lt;code&gt;MacVim&lt;/code&gt; on both work and home computers.  My colon commands are being saved in my home computers but not on my work computer.  My &lt;code&gt;.vimrc&lt;/code&gt; on both computers is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shell=/bin/bash&#xA;&#xA;execute pathogen#infect()&#xA;filetype plugin indent on&#xA;&#xA;autocmd ColorScheme * hi StatusLine guifg=#268bd2&#xA;colorscheme solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are slight differences in the versions.  Here's the working version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 31 2016 19:25:50)&#xA;MacOS X (unix) version&#xA;Included patches: 1-2196&#xA;Compiled by MacPorts&#xA;Huge version with MacVim GUI.  Features included (+) or not (-):&#xA;+acl             +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+arabic          +float           +mouse_urxvt     -tcl&#xA;+autocmd         +folding         +mouse_xterm     +termguicolors&#xA;+balloon_eval    -footer          +multi_byte      +terminfo&#xA;+browse          +fork()          +multi_lang      +termresponse&#xA;++builtin_terms  +fullscreen      -mzscheme        +textobjects&#xA;+byte_offset     +gettext         +netbeans_intg   +timers&#xA;+channel         -hangul_input    +num64           +title&#xA;+cindent         +iconv           +odbeditor       +toolbar&#xA;+clientserver    +insert_expand   +packages        +transparency&#xA;+clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        -perl            +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       -python          +vreplace&#xA;-cscope          +lispindent      -python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con_gui  -lua             +rightleft       +writebackup&#xA;+diff            +menu            -ruby            -X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;+dnd             +modify_fname    +signs           +xim&#xA;-ebcdic          +mouse           +smartindent     -xsmp&#xA;+emacs_tags      +mouseshape      +startuptime     -xterm_clipboard&#xA;+eval            +mouse_dec       +statusline      -xterm_save&#xA;+ex_extra        -mouse_gpm       -sun_workshop    -xpm&#xA;+extra_search    -mouse_jsbterm   +syntax          &#xA;+farsi           +mouse_netterm   +tag_binary      &#xA;+file_in_path    +mouse_sgr       +tag_old_static  &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/opt/local/MacVim.app/Contents/Resources/vim&quot;&#xA;Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -I/opt/local/include -DMACOS_X_UNIX  -pipe -Os -arch x86_64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: /usr/bin/clang   -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -lintl -framework Cocoa           &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the non-working version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan  5 2017 07:18:47)&#xA;MacOS X (unix) version&#xA;Included patches: 1-94&#xA;Compiled by MacPorts&#xA;Huge version with MacVim GUI.  Features included (+) or not (-):&#xA;+acl             +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+arabic          +float           +mouse_urxvt     -tcl&#xA;+autocmd         +folding         +mouse_xterm     +termguicolors&#xA;+balloon_eval    -footer          +multi_byte      +terminfo&#xA;+browse          +fork()          +multi_lang      +termresponse&#xA;++builtin_terms  +fullscreen      -mzscheme        +textobjects&#xA;+byte_offset     +gettext         +netbeans_intg   +timers&#xA;+channel         -hangul_input    +num64           +title&#xA;+cindent         +iconv           +odbeditor       +toolbar&#xA;+clientserver    +insert_expand   +packages        +transparency&#xA;+clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        -perl            +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       +python          +vreplace&#xA;-cscope          +lispindent      -python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con_gui  -lua             +rightleft       +writebackup&#xA;+diff            +menu            -ruby            -X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;+dnd             +modify_fname    +signs           +xim&#xA;-ebcdic          +mouse           +smartindent     -xpm&#xA;+emacs_tags      +mouseshape      +startuptime     -xsmp&#xA;+eval            +mouse_dec       +statusline      -xterm_clipboard&#xA;+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save&#xA;+extra_search    -mouse_jsbterm   +syntax          &#xA;+farsi           +mouse_netterm   +tag_binary      &#xA;+file_in_path    +mouse_sgr       +tag_old_static  &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/opt/local/MacVim.app/Contents/Resources/vim&quot;&#xA;Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -I/opt/local/include -DMACOS_X_UNIX  -pipe -Os -arch x86_64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: /usr/bin/clang   -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -lintl -framework Cocoa    -L/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -lpython2.7 -framework CoreFoundation -u _PyMac_Error /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python       &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2399" LastActivityDate="2017-05-25T15:00:33.097" Title="Not saving colon commands in MacVim" Tags="|macvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11354" PostTypeId="1" AcceptedAnswerId="11355" CreationDate="2017-02-11T19:19:18.650" Score="1" ViewCount="760" Body="&lt;p&gt;So I decided to to go through Damian Conway's (a well known Perl programmer) .vimrc setup as a way to get more familiar with vim and how it works. His first line is this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufNewFile,BufRead  *.t                     setfiletype perl&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there is no line like this in the file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufNewFile,BufRead  *.pl                     setfiletype perl&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the .vimrc file also does not have a &lt;code&gt;:filetype on&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm curious to know: is there is some other method to get vim to automatically recognize what kind of file is getting worked on? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="2021" LastEditDate="2017-02-11T19:56:50.333" LastActivityDate="2017-02-11T22:44:38.343" Title="Another way to detect filetype besides autocmd in .vimrc?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11355" PostTypeId="2" ParentId="11354" CreationDate="2017-02-11T22:44:38.343" Score="3" Body="&lt;p&gt;Vim recognises common file extensions by default, that's why you don't need to take care of &lt;code&gt;.*pl&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant code is in &lt;code&gt;filetype.vim&lt;/code&gt; in Vim's program folder – go take a look.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly, the code for &lt;code&gt;.pl&lt;/code&gt; is slightly more complicated than your line as it distinguishes between Prolog and Perl.&lt;/p&gt;&#xA;" OwnerUserId="9430" LastActivityDate="2017-02-11T22:44:38.343" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11356" PostTypeId="1" AcceptedAnswerId="11358" CreationDate="2017-02-11T23:53:08.777" Score="11" ViewCount="4491" Body="&lt;p&gt;I'm looking at a file that has this in the .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set iskeyword+=@-@&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assumed it would let me delete a word with a hypen surrounded by two letters such as &lt;code&gt;this-word&lt;/code&gt; with a &lt;code&gt;dw&lt;/code&gt; command but it doesn't seem to work.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2024-03-08T21:10:39.617" Title="What does &quot;set iskeyword+=@-@&quot; do?" Tags="|vimrc|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11357" PostTypeId="2" ParentId="9486" CreationDate="2017-02-12T00:05:02.683" Score="1" Body="&lt;p&gt;David has a valid point about intermingling Vim with different flavors of Python and if hard coding &lt;code&gt;PYTHONPATH&lt;/code&gt; to Anaconda Python in &lt;code&gt;.profile&lt;/code&gt;/&lt;code&gt;.bashrc&lt;/code&gt; really does lead to SEG 11 could one use a shell alias. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vim3='PYTHONPATH=/usr/lib/Anaonda/.../site-packages vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Perhaps this work-around will suffice.&lt;/p&gt;&#xA;" OwnerUserId="11292" LastEditorUserId="205" LastEditDate="2017-02-13T13:40:22.657" LastActivityDate="2017-02-13T13:40:22.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11358" PostTypeId="2" ParentId="11356" CreationDate="2017-02-12T00:23:09.243" Score="14" Body="&lt;p&gt;From &lt;code&gt;:h 'isk&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;See 'isfname' for a description of the format of this option.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then from &lt;code&gt;:h 'isf&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If the character is '@', all characters where isalpha() returns TRUE&#xA;are included.  Normally these are the characters a to z and A to Z,&#xA;plus accented characters.  To include '@' itself use &quot;@-@&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, as you said in your &lt;a href=&quot;https://vi.stackexchange.com/questions/11356/what-does-set-iskeyword-do#comment19906_11356&quot;&gt;comment&lt;/a&gt;, it seems that &lt;code&gt;@-@&lt;/code&gt; stands for the &lt;code&gt;@&lt;/code&gt; character itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to why this syntax is used, I suppose the reason is because a single &lt;code&gt;@&lt;/code&gt; is already used to denote &lt;code&gt;all characters where isalpha() returns TRUE&lt;/code&gt;, which usually are &lt;code&gt;the characters a to z and A to Z, plus accented characters&lt;/code&gt;. So, &lt;code&gt;@&lt;/code&gt; couldn't be used to denote itself.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a workaround, maybe the syntax used to express a range of characters was chosen instead.&lt;br&gt;&#xA;The same syntax which is used, for example, to stand for all the alphabetical characters written in lowercase: &lt;code&gt;a-z&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe &lt;code&gt;@-@&lt;/code&gt; could be interpreted as the range of characters between the &lt;code&gt;@&lt;/code&gt; character, and the &lt;code&gt;@&lt;/code&gt; character, that is only the &lt;code&gt;@&lt;/code&gt; character and nothing else.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2017-02-12T00:23:09.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11359" PostTypeId="1" CreationDate="2017-02-12T01:47:35.517" Score="1" ViewCount="659" Body="&lt;p&gt;Switching between panes is a pain on my Mac keyboard. There is only one CTRL key and it's on the same side as the W key. I want to map a new keystroke to make this super efficient, preferably without using the CTRL key at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering what other folks out there doing to switch between panes to make it as painless as possible. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-02-12T03:08:32.327" Title="Best way to move between panes?" Tags="|terminal|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11360" PostTypeId="2" ParentId="11359" CreationDate="2017-02-12T02:37:33.483" Score="2" Body="&lt;p&gt;FWIW, on linux I'm using &lt;code&gt;xmodmap&lt;/code&gt; and &lt;a href=&quot;https://github.com/alols/xcape&quot; rel=&quot;nofollow noreferrer&quot;&gt;xcape&lt;/a&gt; to use the &lt;code&gt;Enter&lt;/code&gt; key as the control modifier key when it's hold, and &lt;code&gt;Enter&lt;/code&gt; when it's pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do something similar with the capslock key: control when it's hold, and escape when it's pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know Mac well enough to tell you if you could do something similar, but if you did, you would have 2 symmetric control keys, one on the left, the other on the right of the keyboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you have 2 control keys easily accessible for your left and right little fingers, many key sequences involving the control modifier key become easier to type, imho.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a file sourced by &lt;code&gt;xmodmap&lt;/code&gt; (I think it could be &lt;code&gt;~/.Xmodmap&lt;/code&gt;), I have this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;keycode 36 = Hyper_L&#xA;remove mod4 = Hyper_L&#xA;add control = Hyper_L&#xA;keycode 255 = Return&#xA;keycode 66 = Control_L&#xA;clear lock&#xA;add control = Control_L&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These commands make the &lt;code&gt;Enter&lt;/code&gt; and capslock key produce the &lt;code&gt;Control_L&lt;/code&gt; keysym, when the keys are hold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a script executed after the machine has started, I have these commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xcape -e 'Control_L=Escape'&#xA;xcape -e 'Hyper_L=Return'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It restores the keysym &lt;code&gt;Return&lt;/code&gt; on the &lt;code&gt;Enter&lt;/code&gt; key, and the keysym &lt;code&gt;Escape&lt;/code&gt; on the capslock key, when the keys are pressed briefly (&amp;lt; 500ms).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you don't want to use external tools, you could remap the prefix &lt;code&gt;C-w&lt;/code&gt;, which is used to perform various actions on Vim windows, to &lt;code&gt;gw&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This idea is from &lt;a href=&quot;https://www.reddit.com/r/vim/comments/1x31ng/follow_my_leader/cf7obe5/&quot; rel=&quot;nofollow noreferrer&quot;&gt;justinmk&lt;/a&gt;.&#xA;By default, &lt;code&gt;gw&lt;/code&gt; is a normal operator to format a text-object, or a region of text covered by a motion. For example, you can format the current paragraph hitting &lt;code&gt;gwip&lt;/code&gt;.&lt;br&gt;&#xA;Even though you would lose this operator, you could still use &lt;code&gt;gq&lt;/code&gt; instead, which seems a more powerful alternative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gq&lt;/code&gt; also allows to format text, but, contrary to &lt;code&gt;gw&lt;/code&gt;, you can control its behavior with the options &lt;code&gt;'formatexpr'&lt;/code&gt; and &lt;code&gt;'formatprg'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea behind using &lt;code&gt;gw&lt;/code&gt; as a prefix for managing your windows, is to take &lt;code&gt;g&lt;/code&gt;, which Vim uses by default as a common prefix to build various commands / operators / motions (you can see most of them with &lt;code&gt;:echo map(taglist('^g.$'), 'v:val.name')&lt;/code&gt;), and add &lt;code&gt;w&lt;/code&gt; with the mnemonics &lt;code&gt;window&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to test this solution for a while, you could try this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gw &amp;lt;C-w&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From then, to switch from a window to another, instead of hitting &lt;code&gt;C-w w&lt;/code&gt;, you would hit &lt;code&gt;gww&lt;/code&gt;.&lt;br&gt;&#xA;To open the file under the cursor inside a horizontal split window, instead of hitting &lt;code&gt;C-w f&lt;/code&gt;, you would hit &lt;code&gt;gwf&lt;/code&gt;. And so on...&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-02-12T03:08:32.327" LastActivityDate="2017-02-12T03:08:32.327" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11361" PostTypeId="2" ParentId="11352" CreationDate="2017-02-12T03:10:14.947" Score="1" Body="&lt;p&gt;Add this to your script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:undo_ftplugin='setlocal buftype='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the &lt;code&gt;FileType&lt;/code&gt; autocmd is fired, that variable will &lt;code&gt;execute&lt;/code&gt;.  To trigger the &lt;code&gt;autocmd&lt;/code&gt;, you could run &lt;code&gt;:set ft=whatever&lt;/code&gt; to reload the &lt;code&gt;ftplugin&lt;/code&gt; and &lt;code&gt;syntax&lt;/code&gt; scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I'm tweaking an &lt;code&gt;ftplugin&lt;/code&gt;, I usually don't want to save the changes made in a buffer during testing.  So, I just use &lt;code&gt;:e!&lt;/code&gt; to reload the buffer since &lt;code&gt;:edit&lt;/code&gt; effectively sets the detected &lt;code&gt;filetype&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read more about this in &lt;code&gt;:h undo_ftplugin&lt;/code&gt;.  To see exactly how this works, you can look at the script that loads your &lt;code&gt;ftplugin&lt;/code&gt; script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e $VIMRUNTIME/ftplugin.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-02-12T03:10:14.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11362" PostTypeId="1" AcceptedAnswerId="11363" CreationDate="2017-02-12T04:07:11.617" Score="3" ViewCount="3291" Body="&lt;p&gt;I'm trying to reverse engineer how a .vimrc file works. One of the lines is this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufEnter *.p[lm]  nmap &amp;lt;buffer&amp;gt; ;t :call RunPerlTests()&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only part I'm unclear on is the &lt;code&gt;nmap &amp;lt;buffer&amp;gt; ;t&lt;/code&gt; bit. So I'm not sure what will trigger a call to the function.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-02-12T05:07:27.507" Title="Triggering a function with BufEnter" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11363" PostTypeId="2" ParentId="11362" CreationDate="2017-02-12T04:19:30.237" Score="4" Body="&lt;p&gt;It seems to be an autocmd listening to the &lt;code&gt;BufEnter&lt;/code&gt; event, and is only fired for a file whose extension is &lt;code&gt;.pl&lt;/code&gt; or &lt;code&gt;.pm&lt;/code&gt; (for more info about the syntax, see &lt;code&gt;:h file-pattern&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever this event occurs, the autocmd should install the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;buffer&amp;gt; ;t :call RunPerlTests()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping is not global, but local to the current buffer (the one where the autocmd was fired), thanks to the argument &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; which was passed to the &lt;code&gt;:nmap&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;{lhs}&lt;/code&gt; of the mapping is &lt;code&gt;;t&lt;/code&gt;, and the &lt;code&gt;{rhs}&lt;/code&gt; is &lt;code&gt;:call RunPerlTests()&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;br&gt;&#xA;It means that whenever you will hit &lt;code&gt;;t&lt;/code&gt; in normal mode, Vim should execute the Ex command &lt;code&gt;:call RunPerlTests()&amp;lt;CR&amp;gt;&lt;/code&gt;. This last command should call the custom function &lt;code&gt;RunPerlTests()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter *.p[lm]  nmap &amp;lt;buffer&amp;gt; ;t :call RunPerlTests()&amp;lt;CR&amp;gt;&#xA;&quot;       |        |        |     |       |  |&#xA;&quot;       |        |        |     |       |  +-- `{rhs}` of the mapping&#xA;&quot;       |        |        |     |       +-- `{lhs}` of the mapping&#xA;&quot;       |        |        |     +-- argument to pass to `:nmap`; limits the scope of the mapping to the current buffer&#xA;&quot;       |        |        +-- mapping command to execute&#xA;&quot;       |        +-- pattern to limit the scope of the autocmd to certain filetypes&#xA;&quot;       +-- event of the autocmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You probably want to replace the &lt;code&gt;:nmap&lt;/code&gt; command, which is recursive, with the non-recursive version &lt;code&gt;:nnoremap&lt;/code&gt;.&#xA;You only want the recursiveness, when you need all or a part of the &lt;code&gt;{rhs}&lt;/code&gt; to be replaced using another mapping, which doesn't seem to be the case here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you could prefix the Ex command &lt;code&gt;:call&lt;/code&gt; with the keycode &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt;, to delete a possible range which could be inserted by accident on the command-line if you hit a number before &lt;code&gt;;t&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter *.p[lm]  nnoremap &amp;lt;buffer&amp;gt; ;t :&amp;lt;C-U&amp;gt;call RunPerlTests()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To understand why &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; could be useful, in normal mode hit &lt;code&gt;3:&lt;/code&gt;. On the command-line you should see &lt;code&gt;:.,.+2&lt;/code&gt;. This is a range, which can be read as &lt;code&gt;from the current line down to the 2nd line after the current one&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you pass a range to the &lt;code&gt;:call&lt;/code&gt; command, by default Vim should call the function as many times as there are addresses inside the range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! MyFunc()&#xA;    echo 'hello'&#xA;endfu&#xA;&#xA;nno cd :call MyFunc()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, hit &lt;code&gt;3cd&lt;/code&gt;. Because you hit &lt;code&gt;3&lt;/code&gt; before the &lt;code&gt;{lhs}&lt;/code&gt; of your custom mapping &lt;code&gt;cd&lt;/code&gt;, Vim will automatically inserts the range &lt;code&gt;.,.+2&lt;/code&gt;, which will give on the command-line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,.+2call MyFunc()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will call &lt;code&gt;MyFunc()&lt;/code&gt; 3 times, because there are 3 addresses inside the range &lt;code&gt;.,.+2&lt;/code&gt;, and you should see &lt;code&gt;hello&lt;/code&gt; 3 times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As said earlier, if you want to avoid this, you could prefix the &lt;code&gt;:call&lt;/code&gt; command with the &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; keycode (see &lt;code&gt;:h c^u&lt;/code&gt;). It will make sure that nothing is inserted before &lt;code&gt;:call&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if your custom function &lt;code&gt;RunPerlTests()&lt;/code&gt; was defined with the &lt;code&gt;range&lt;/code&gt; attribute, then it probably expects a range. In this case, don't add &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you haven't done it already, you also probably want to wrap your autocmd inside an augroup and clear the latter with the &lt;code&gt;autocmd!&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup YourAugroup&#xA;    autocmd!&#xA;    autocmd BufEnter *.p[lm]  nnoremap &amp;lt;buffer&amp;gt; ;t :&amp;lt;C-U&amp;gt;call RunPerlTests()&amp;lt;CR&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason for this is to avoid that your autocmd is duplicated every time you source your &lt;code&gt;vimrc&lt;/code&gt; file. See this &lt;a href=&quot;https://vi.stackexchange.com/questions/9455/why-should-i-use-augroup/9465&quot;&gt;question&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-02-12T05:07:27.507" LastActivityDate="2017-02-12T05:07:27.507" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11364" PostTypeId="1" AcceptedAnswerId="11365" CreationDate="2017-02-12T05:14:35.857" Score="2" ViewCount="79" Body="&lt;p&gt;I'm learning .vim configuration and scripting by studying a real world .vimrc file used by Damian Conway (a well known Perl programmer). He has this bit in his file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup Perl_Setup&#xA;    autocmd!&#xA;    autocmd BufNewFile   *.p[lm65],*.t   0r !perl_file_template &amp;lt;afile&amp;gt;&#xA;    autocmd BufNewFile   *.p[lm65],*.t   /^[ \t]*[#].*implementation[ \t]\+here/&#xA;augroup END &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think I grok the first &lt;code&gt;autocmd&lt;/code&gt; line which looks like it runs a script he created, &lt;code&gt;perl_file_template&lt;/code&gt;, that gets passed the filename as an argument and which then inserts its output into the top of buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am at a loss as to what the second &lt;code&gt;autocmd&lt;/code&gt; line might do, though. It looks like a regex but I'm not sure what it might do in this context of a vim command.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-02-12T05:40:29.273" Title="Reverse engineering method of loading of a template file" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11365" PostTypeId="2" ParentId="11364" CreationDate="2017-02-12T05:35:24.700" Score="1" Body="&lt;p&gt;There are 7 seven types of Ex commands, which you can read about in &lt;code&gt;:h getcmdtype()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A forward search (&lt;code&gt;/pattern&lt;/code&gt;) is a type of Ex command, and its effect is to position the cursor on the first character of the next found occurrence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since a forward search is an Ex command, it can be automatically executed by an autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you said, it seems that the purpose of your first autocmd is to import the output of a shell command.&lt;br&gt;&#xA;As to the 2nd autocmd, its purpose seems to be to look for a pattern inside the text which was imported in the buffer, and position the cursor on its first character. The pattern is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[ \t]*[#].*implementation[ \t]\+here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which could be broken down like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  ^[ \t]*[#].*implementation[ \t]\+here&#xA;&quot; ||| | ||| |||             || |  ||&#xA;&quot; ||| | ||| |||             || |  |+-- word 'here' literally&#xA;&quot; ||| | ||| |||             || |  +-- the character inside the collection can be present 1 or several times&#xA;&quot; ||| | ||| |||             || +-- tab&#xA;&quot; ||| | ||| |||             |+-- space&#xA;&quot; ||| | ||| |||             +-- a collection&#xA;&quot; ||| | ||| ||+-- word 'implementation' literally&#xA;&quot; ||| | ||| |+-- quantifier to repeat the last character 0, 1, or several times&#xA;&quot; ||| | ||| +-- any character&#xA;&quot; ||| | ||+-- a number sign&#xA;&quot; ||| | |+-- another collection of characters&#xA;&quot; ||| | +-- any character inside the previous collection can be present 0, 1 or several times&#xA;&quot; ||| +-- tab character&#xA;&quot; ||+-- space&#xA;&quot; |+-- collection of (2) characters&#xA;&quot; +-- beginning of line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure why the number sign is inside a collection, maybe I misunderstood something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, I think it could match the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    # foobar implementation    here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-02-12T05:40:29.273" LastActivityDate="2017-02-12T05:40:29.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11366" PostTypeId="2" ParentId="10234" CreationDate="2017-02-12T10:53:04.910" Score="6" Body="&lt;p&gt;See &lt;a href=&quot;https://vi.stackexchange.com/questions/3359/how-to-fix-status-bar-symbols-in-airline-plugin&quot;&gt;this post&lt;/a&gt;. Specifically, paste this into your .vimrc.&lt;pre&gt;&lt;code&gt;&quot; air-line&#xA;let g:airline_powerline_fonts = 1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if !exists('g:airline_symbols')&#xA;    let g:airline_symbols = {}&#xA;endif&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot; unicode symbols&#xA;let g:airline_left_sep = '»'&#xA;let g:airline_left_sep = '▶'&#xA;let g:airline_right_sep = '«'&#xA;let g:airline_right_sep = '◀'&#xA;let g:airline_symbols.linenr = '␊'&#xA;let g:airline_symbols.linenr = '␤'&#xA;let g:airline_symbols.linenr = '¶'&#xA;let g:airline_symbols.branch = '⎇'&#xA;let g:airline_symbols.paste = 'ρ'&#xA;let g:airline_symbols.paste = 'Þ'&#xA;let g:airline_symbols.paste = '∥'&#xA;let g:airline_symbols.whitespace = 'Ξ'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot; airline symbols&#xA;let g:airline_left_sep = ''&#xA;let g:airline_left_alt_sep = ''&#xA;let g:airline_right_sep = ''&#xA;let g:airline_right_alt_sep = ''&#xA;let g:airline_symbols.branch = ''&#xA;let g:airline_symbols.readonly = ''&#xA;let g:airline_symbols.linenr = ''&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;&#xA;" OwnerUserId="11295" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-02-12T10:53:04.910" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11367" PostTypeId="2" ParentId="11349" CreationDate="2017-02-12T16:39:15.773" Score="19" Body="&lt;p&gt;By default, when you hit &lt;code&gt;C-n&lt;/code&gt; or &lt;code&gt;C-p&lt;/code&gt;, Vim looks inside various sources to find candidates which will populate the completion menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These sources can be configured with the buffer-local &lt;code&gt;'complete'&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The value of this option is a comma-separated list of flags. Each flag has its own meaning described in &lt;code&gt;:h 'cpt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.   scan the current buffer ('wrapscan' is ignored)&#xA;w   scan buffers from other windows&#xA;b   scan other loaded buffers that are in the buffer list&#xA;u   scan the unloaded buffers that are in the buffer list&#xA;U   scan the buffers that are not in the buffer list&#xA;k   scan the files given with the 'dictionary' option&#xA;kspell  use the currently active spell checking |spell|&#xA;k{dict} scan the file {dict}.  Several &quot;k&quot; flags can be given, patterns are valid too.  For example:  &#xA;        :set cpt=k/usr/dict/*,k~/spanish&#xA;s   scan the files given with the 'thesaurus' option&#xA;s{tsr}  scan the file {tsr}.  Several &quot;s&quot; flags can be given, patterns are valid too.&#xA;i   scan current and included files&#xA;d   scan current and included files for defined name or macro |i_CTRL-X_CTRL-D|&#xA;]   tag completion&#xA;t   same as &quot;]&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By default, its value is &lt;code&gt;.,w,b,u,t,i&lt;/code&gt;, which means:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   1. the current buffer&#xA;   2. buffers in other windows&#xA;   3. other loaded buffers&#xA;   4. unloaded buffers&#xA;   5. tags&#xA;   6. included files&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you find that scanning the included files takes too much time, you could try to remove the &lt;code&gt;i&lt;/code&gt; flag from the &lt;code&gt;'cpt'&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to remove it from the global value, to affect all the buffers by default, you would write in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setglobal complete-=i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you wanted to do the same thing, but only for &lt;code&gt;perl&lt;/code&gt; files, you could install an autocmd inside your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup PerlSettings&#xA;    autocmd!&#xA;    autocmd FileType perl setlocal complete-=i&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or better, you could create a filetype plugin, for example in &lt;code&gt;~/.vim/after/ftplugin/perl.vim&lt;/code&gt;, in which you would simply write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal complete-=i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To check out what's the current global and local values of your &lt;code&gt;'complete'&lt;/code&gt; option, and where they were last set, you could use these commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;verbose setglobal complete?&#xA;verbose setlocal complete?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or shorter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;verb setg cpt?&#xA;verb setl cpt?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If the only source in which you're interested is the current buffer, then, instead of using &lt;code&gt;C-n&lt;/code&gt;, you could use &lt;code&gt;C-x C-n&lt;/code&gt;. See &lt;code&gt;:h i_^x^n&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-02-12T17:15:25.017" LastActivityDate="2017-02-12T17:15:25.017" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11368" PostTypeId="1" CreationDate="2017-02-12T17:57:17.800" Score="4" ViewCount="262" Body="&lt;p&gt;How can I retrieve the syntax id under the cursor, in &lt;em&gt;all&lt;/em&gt; cases?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, the &lt;code&gt;synID()&lt;/code&gt; function doesn't take into account highlightings due to the &lt;code&gt;:match*&lt;/code&gt; commands or the &lt;code&gt;matchadd()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example, in a C source file:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void myfunc(char c)&#xA;{ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's say I run in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd('SpecialKey', '\&amp;lt;myfunc\&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, when the cursor is on the word &lt;code&gt;char&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo synID(line('.'), col('.'), 1)&#xA;235&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when the cursor is on the word &lt;code&gt;myfunc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo synID(line('.'), col('.'), 1)&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5516" LastEditorUserId="33130" LastEditDate="2021-08-11T16:40:42.643" LastActivityDate="2023-12-29T20:00:45.147" Title="Retrieve the match id under the cursor, in all cases" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="11371" PostTypeId="1" CreationDate="2017-02-12T21:22:30.217" Score="1" ViewCount="5293" Body="&lt;p&gt;&lt;code&gt;nvim -v&lt;/code&gt; output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NVIM 0.2.0-dev&#xA;Build type: RelWithDebInfo&#xA;Compilation: /usr/bin/x86_64-linux-gnu-gcc -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -D_GNU_SOURCE -I/build/neovim-gNtBZg/neovim-0.1.7ubuntu1+git201702111847+3127+23~ubuntu16.04.1/build/config -I/build/neovim-gNtBZg/neovim-0.1.7ubuntu1+git201702111847+3127+23~ubuntu16.04.1/src -I/build/neovim-gNtBZg/neovim-0.1.7ubuntu1+git201702111847+3127+23~ubuntu16.04.1/.deps/usr/include -I/build/neovim-gNtBZg/neovim-0.1.7ubuntu1+git201702111847+3127+23~ubuntu16.04.1/.deps/usr/include -I/build/neovim-gNtBZg/neovim-0.1.7ubuntu1+git201702111847+3127+23~ubuntu16.04.1/.deps/usr/include -I/build/neovim-gNtBZg/neovim-0.1.7ubuntu1+git201702111847+3127+23~ubuntu16.04.1/.deps/usr/include -I/build/neovim-gNtBZg/neovim-0.1.7ubuntu1+git201702111847+3127+23~ubuntu16.04.1/.deps/usr/include -I/build/neovim-gNtBZg/neovim-0.1.7ubuntu1+git201702111847+3127+23~ubuntu16.04.1/.deps/usr/include -I/usr/include -I/build/neovim-gNtBZg/neovim-0.1.7ubuntu1+git201702111847+3127+23~ubuntu16.04.1/build/src/nvim/auto -I/build/neovim-gNtBZg/neovim-0.1.7ubuntu1+git201702111847+3127+23~ubuntu16.04.1/build/include&#xA;Compiled by root@lgw01-10&#xA;&#xA;Optional features included (+) or not (-): +acl   +iconv    +jemalloc +tui      &#xA;For differences from Vim, see :help vim-differences&#xA;&#xA;   system vimrc file: &quot;$VIM/sysinit.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/nvim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;System: Ubuntu 16.04&lt;/li&gt;&#xA;&lt;li&gt;Terminal: GNOME Terminal 3.18.3&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$TERM&lt;/code&gt;: screen-256color&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When syntax is off and spell is on only misspelled and rare words should be highlighted. Some keywords highlight but in different way than misspelled words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did &lt;strong&gt;not&lt;/strong&gt; test it Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps to reproduce using &lt;code&gt;nvim -u NORC&lt;/code&gt; (without configuration file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax off&#xA;:set spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Photo: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lZ5yB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lZ5yB.png&quot; alt=&quot;wrong highlight&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is &lt;code&gt;function&lt;/code&gt;, &lt;code&gt;let&lt;/code&gt; higlighted blue? &lt;strong&gt;Can I turn it off so only misspelled words will be highlighted&lt;/strong&gt; (no matter what type)?&lt;/p&gt;&#xA;" OwnerUserId="11303" LastEditorUserId="205" LastEditDate="2017-02-13T04:48:22.797" LastActivityDate="2017-02-13T17:37:46.957" Title="Where does red highlighting come from with syntax off and spell on in Neovim?" Tags="|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11372" PostTypeId="1" CreationDate="2017-02-12T21:52:37.147" Score="1" ViewCount="176" Body="&lt;p&gt;I've played with git in the past and I know it's good practice but I never used it because it was just too much of a hassle for my little pet, hobbyist projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking to get back into git and I'm hoping vim can overcome my innate laziness and get me in the good habit of making and documenting my changes to the repository.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The project I have has three branches: &lt;code&gt;master&lt;/code&gt; (a forked copy of someone else's work that doesn't work on my machine), &lt;code&gt;working-copy&lt;/code&gt; (a version that will actually work on my machine), and &lt;code&gt;rev-engineer&lt;/code&gt; (a version where I can experiment and then merge stuff that I know works into the working-copy branch from time to time).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I won't be doing any heavy lifting with git. It's just my own project. All I'll be doing is mostly working in the &lt;code&gt;rev-engineer&lt;/code&gt; branch and then merging those changes back into the &lt;code&gt;working-copy&lt;/code&gt; once I'm sure it won't break anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also want to get more familiar with Vim so I thought it would be good experience to roll my own. So rather than some heavy plugin, what I'd like is just some basic shortcut keys that will help me make working with git as painless as possible. I don't need any power tools. I just want to be able to do some simple stuff like commit my branch changes, merge my two branches from time to time, and push them out to remote repository branches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But Vim has many ways to use hotkeys so I'm wondering what the best and easiest &lt;code&gt;.vimrc&lt;/code&gt; config commands are for accomplishing something like.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="1821" LastEditDate="2017-02-13T09:18:04.783" LastActivityDate="2017-02-13T09:18:04.783" Title="Good approach for running basic git commits?" Tags="|git|" AnswerCount="1" CommentCount="6" FavoriteCount="0" ClosedDate="2017-02-15T03:06:48.213" ContentLicense="CC BY-SA 3.0" />
  <row Id="11373" PostTypeId="1" CreationDate="2017-02-12T23:31:09.910" Score="10" ViewCount="3656" Body="&lt;p&gt;Like most programmers, I perform a lot of repetitive tasks. In optimising my workflow, I'm taking some of those repetitive tasks, and refactoring them into shell scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing that I'm trying to automate is the recreation of PostgreSQL views. I have the following view.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;create or replace view person as&#xA;select&#xA;    1 as person_id&#xA;    , 'John'::text as first_name,&#xA;    'Doe'::text as last_name;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can dump this view with &lt;code&gt;psql -c &quot;\\d+ person&quot;&lt;/code&gt; and the output is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                   View &quot;public.person&quot;&#xA;   Column   |  Type   | Modifiers | Storage  | Description &#xA;------------+---------+-----------+----------+-------------&#xA; person_id  | integer |           | plain    | &#xA; first_name | text    |           | extended | &#xA; last_name  | text    |           | extended | &#xA;View definition:&#xA; SELECT 1 AS person_id,&#xA;    'John'::text AS first_name,&#xA;    'Doe'::text AS last_name;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can reformat this text into a &lt;code&gt;CREATE OR REPLACE VIEW&lt;/code&gt; statement with the following keystrokes in vim: &lt;code&gt;gg0df&quot;iCREATE OR REPLACE VIEW &amp;lt;ESC&amp;gt;$cl AS&amp;lt;ESC&amp;gt;j0d/^View definition:&amp;lt;CR&amp;gt;ddG$:wq&lt;/code&gt; (I've reformatted &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;, etc, in the above).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got the above working perfectly, except for the screen &quot;flashes&quot; that occur. For example, if at the shell I type &lt;code&gt;a=$(psql -c &quot;\\d+ person&quot; | vim -s &amp;lt;vimscriptfile&amp;gt; -); echo &quot;$a&quot;&lt;/code&gt; then my screen &quot;flashes&quot; before outputting the nicely format SQL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to remove this flash? Or is there a better &lt;em&gt;using-vim-in-a-pipeline&lt;/em&gt; approach than what I'm employing?&lt;/p&gt;&#xA;" OwnerUserId="10101" LastEditorUserId="10101" LastEditDate="2017-02-13T21:49:56.227" LastActivityDate="2017-11-16T11:30:17.293" Title="How can you use vim as a stream editor?" Tags="|vimscript|bash|" AnswerCount="2" CommentCount="11" ClosedDate="2017-11-18T01:38:15.393" ContentLicense="CC BY-SA 3.0" />
  <row Id="11374" PostTypeId="2" ParentId="104" CreationDate="2017-02-13T00:31:27.250" Score="6" Body="&lt;p&gt;To show the full path for all files, including resolved symlinks, use the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo resolve(expand('%:p'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9202" LastActivityDate="2017-02-13T00:31:27.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11375" PostTypeId="1" CreationDate="2017-02-13T01:34:44.917" Score="2" ViewCount="3561" Body="&lt;p&gt;I'm trying to write an &lt;code&gt;autocmd&lt;/code&gt; to make a commit to a git repository. Here is some non-functional code that should illustrate what I'm trying to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g: CommMsg = ''&#xA;&#xA;augroup misc&#xA;  autocmd!&#xA;  autocmd nmap &amp;lt;buffer&amp;gt; gc :call GetCommMsg()&amp;lt;CR&amp;gt;!git commit -m '=CommMsg'&amp;lt;CR&amp;gt;&#xA;augroup END&#xA;&#xA;function! GetCommMsg()&#xA;  let curline = getline('.')&#xA;  call inputsave()&#xA;  let name = input('Enter message: ')&#xA;  call inputrestore()&#xA;  let CommMsg = call setline(',', curline . ' ' . name)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The intention here is to use the &lt;code&gt;GetCommMsg()&lt;/code&gt; function to get the message from the user, set a global variable to this value and then pass it to the &lt;code&gt;git commit&lt;/code&gt; command as the message argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="1841" LastEditDate="2019-02-15T08:41:34.100" LastActivityDate="2019-02-15T08:41:34.100" Title="How do you pass user input to a system command?" Tags="|vimscript|external-command|user-input|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11376" PostTypeId="2" ParentId="11375" CreationDate="2017-02-13T03:01:35.283" Score="6" Body="&lt;p&gt;Maybe this is what you're aiming for?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gc :execute '!git commit -m &quot;'.input('Enter message: ').'&quot;'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only parts of your script that would do anything useful is the first line and the &lt;code&gt;nmap&lt;/code&gt; line.  The rest of it would either do nothing or not run at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you're starting to learn VimL, here's a tip: Test simple ideas in the command line.  Every line in a VimL script is something that you can type verbatim in the command line.  You would've seen that the &lt;code&gt;'=CommMsg'&lt;/code&gt; part of your script would end up being your commit message.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2017-02-13T03:24:20.837" LastActivityDate="2017-02-13T03:24:20.837" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11377" PostTypeId="2" ParentId="11375" CreationDate="2017-02-13T03:21:16.147" Score="1" Body="&lt;p&gt;So this seems to work pretty well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup misc&#xA;  autocmd!&#xA;  autocmd BufEnter * nmap &amp;lt;buffer&amp;gt; gc :call GetCommMsg()&amp;lt;CR&amp;gt;&#xA;augroup END&#xA;&#xA;function! GetCommMsg()&#xA;  let curline = getline('.')&#xA;  call inputsave()&#xA;  let msg = input('Enter commit message: ')&#xA;  call inputrestore()&#xA;  call system(&quot;git commit -m '&quot; . msg . &quot;'&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not sure if there are any downsides to doing it this way or not.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-02-13T03:21:16.147" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11378" PostTypeId="2" ParentId="11372" CreationDate="2017-02-13T03:42:01.910" Score="0" Body="&lt;p&gt;So here's what I came up with so far, my first official VIM script. I'm not sure if there are any downsides to my approach. Maybe there's a more straightforward way than &lt;code&gt;autocmd&lt;/code&gt;s? If anyone has feedback, I'd appreciate it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup misc&#xA;  autocmd!&#xA;  autocmd BufEnter * nmap &amp;lt;buffer&amp;gt; ga :w&amp;lt;CR&amp;gt;:silent :!git add %&amp;lt;CR&amp;gt;:redraw!&amp;lt;CR&amp;gt;&#xA;  autocmd BufEnter * nmap &amp;lt;buffer&amp;gt; gs :!git status&amp;lt;CR&amp;gt;&#xA;  autocmd BufEnter * nmap &amp;lt;buffer&amp;gt; gp :!git push origin master&amp;lt;CR&amp;gt;&#xA;  autocmd BufEnter * nmap &amp;lt;buffer&amp;gt; gc :call GetCommMsg()&amp;lt;CR&amp;gt;&#xA;  autocmd BufEnter * nmap &amp;lt;buffer&amp;gt; gl :call PrintLog()&amp;lt;CR&amp;gt;&#xA;augroup END&#xA;&#xA;function! PrintLog()&#xA;  !echo '================================================================='&#xA;  !git log &#xA;endfunction&#xA;&#xA;function! GetCommMsg()&#xA;&quot;  let curline = getline('.')&#xA;  call inputsave()&#xA;  let msg = input('Enter commit message: ')&#xA;  call inputrestore()&#xA;  call system(&quot;git commit -m '&quot; . msg . &quot;'&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-02-13T03:42:01.910" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11380" PostTypeId="2" ParentId="11371" CreationDate="2017-02-13T03:48:56.103" Score="1" Body="&lt;p&gt;It's because syntax is required to recognize syntax-specific keywords.  Without syntax enabled, Vim has no idea if the text has special meaning or if you're just bad at spelling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h spell-syntax&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Files that use syntax highlighting can specify where spell checking should be&#xA;done:&#xA;&#xA;1.  everywhere             default&#xA;2.  in specific items          use &quot;contains=@Spell&quot;&#xA;3.  everywhere but specific items  use &quot;contains=@NoSpell&quot;&#xA;&#xA;For the second method adding the @NoSpell cluster will disable spell checking&#xA;again.  This can be used, for example, to add @Spell to the comments of a&#xA;program, and add @NoSpell for items that shouldn't be checked.&#xA;Also see |:syn-spell| for text that is not in a syntax item.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h :syn-spell&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sy[ntax] spell [toplevel | notoplevel | default]&#xA;  This defines where spell checking is to be done for text that is not&#xA;  in a syntax item:&#xA;&#xA;  toplevel: Text is spell checked.&#xA;  notoplevel:   Text is not spell checked.&#xA;  default:  When there is a @Spell cluster no spell checking.&#xA;&#xA;  For text in syntax items use the @Spell and @NoSpell clusters&#xA;  |spell-syntax|.  When there is no @Spell and no @NoSpell cluster then&#xA;  spell checking is done for &quot;default&quot; and &quot;toplevel&quot;.&#xA;&#xA;  To activate spell checking the 'spell' option must be set.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the &lt;code&gt;vim&lt;/code&gt; filetype, you can see strings and comments explicitly have &lt;code&gt;contains=@Spell&lt;/code&gt; in &lt;code&gt;$VIMRUNTIME/syntax/vim.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-02-13T03:48:56.103" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11382" PostTypeId="1" AcceptedAnswerId="11458" CreationDate="2017-02-13T10:04:05.133" Score="3" ViewCount="1538" Body="&lt;p&gt;If I&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;open (vanilla) &lt;code&gt;vim&lt;/code&gt; by running &lt;code&gt;$ vim [-u NONE]&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;switch to insert mode by pressing &lt;code&gt;a&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;add an 'a' by pressing &lt;code&gt;a&lt;/code&gt; again,&lt;/li&gt;&#xA;&lt;li&gt;switch back to normal mode by pressing &lt;code&gt;ESC&lt;/code&gt;, and&lt;/li&gt;&#xA;&lt;li&gt;repeat steps 2 and 4 several times,&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I see my cursor switching from on top of the 'a' (normal mode) to after the 'a' (insert mode) and back instantly as I press the corresponding keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I now &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;exit &lt;code&gt;vim&lt;/code&gt; by typing &lt;code&gt;:q!&lt;/code&gt; and confirming with &lt;code&gt;RETURN&lt;/code&gt;/&lt;code&gt;ENTER&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;start a (vannilla) &lt;code&gt;screen&lt;/code&gt; session by running &lt;code&gt;$ screen [-c /dev/null]&lt;/code&gt;, and&lt;/li&gt;&#xA;&lt;li&gt;repeat the above excercise,&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;the switch from normal to insert mode after pressing &lt;code&gt;a&lt;/code&gt; is still instantly but there is a notable delay between me pressing &lt;code&gt;ESC&lt;/code&gt; and &lt;code&gt;vim&lt;/code&gt; switching back to normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I observed this with &lt;code&gt;Screen version 4.01.00devel (GNU)&lt;/code&gt; and both, &lt;code&gt;VIM - Vi IMproved 7.4&lt;/code&gt; and &lt;code&gt;NVIM 0.2.0-dev&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure &lt;code&gt;[n]vim&lt;/code&gt;/&lt;code&gt;screen&lt;/code&gt; to avoid this delay?&lt;/p&gt;&#xA;" OwnerUserId="2489" LastActivityDate="2017-02-17T13:31:24.587" Title="delay between hitting `ESC` (in insert mode) and switching to normal mode within `screen`" Tags="|escape|gnu-screen|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11383" PostTypeId="2" ParentId="11315" CreationDate="2017-02-13T10:39:45.747" Score="5" Body="&lt;p&gt;I've released a &lt;a href=&quot;https://github.com/lukelbd/vim-scrollwrapped&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim plugin&lt;/a&gt; that pretty closely matches this behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of scrolling by exactly &lt;code&gt;N&lt;/code&gt; lines, this maps &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; (half window) and &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; (quarter window) to scroll &lt;em&gt;as close to &lt;code&gt;N&lt;/code&gt; lines as possible due to the wrapped lines&lt;/em&gt;, then moves the cursor back to the original relative line position in the Vim window. To match the vim behavior, if the top or bottom of the window are on line 1 or the final line, scrolling does &lt;em&gt;not&lt;/em&gt; preserve the original cursor location and the cursor starts moving up the window until reaching the boundary. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin also introduces a &lt;code&gt;:WrapToggle&lt;/code&gt; command (mapped to &lt;code&gt;&amp;lt;Leader&amp;gt;w&lt;/code&gt;) that toggles wrapping on and off, and swaps the various &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;gj&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, &lt;code&gt;gk&lt;/code&gt; maps so that the basic motion commands are &lt;em&gt;always&lt;/em&gt; with respect to visual lines, and the &lt;code&gt;g&lt;/code&gt; prefixed maps are with respect to actual lines when line wrapping is enabled.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2019-10-17T19:57:25.290" LastActivityDate="2019-10-17T19:57:25.290" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11384" PostTypeId="1" CreationDate="2017-02-13T11:18:47.067" Score="5" ViewCount="624" Body="&lt;p&gt;Simple question -- what is the difference between the two? When I try, for example, to highlight characters on every line after the 80th with &lt;code&gt;highlight link OverLength Error&lt;/code&gt; (OverLength being an arbitrary syntax name), using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match OverLength /\%80v.\+/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;highlights the characters as desired, but&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match OverLength /\%80v.\+/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does not. What's going on here? Is use of the syntax sub-commands restricted to files in the &lt;code&gt;.vim/syntax&lt;/code&gt; folder? What would even be the rationale for that?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2017-02-13T18:35:41.510" LastActivityDate="2017-02-13T18:35:41.510" Title="Syntax highlighting: what is the difference between :syntax match and :match?" Tags="|vimrc|vimscript|syntax-highlighting|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11385" PostTypeId="1" AcceptedAnswerId="11386" CreationDate="2017-02-13T14:10:54.610" Score="1" ViewCount="2199" Body="&lt;p&gt;Vim gives me this error :- &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/piggy/.vimrc:&#xA;line   23:&#xA;E185: Cannot find color scheme 'solarized'&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I can change to solorized color scheme inside the vim using &lt;code&gt;:colo&lt;/code&gt;, and it soes work perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Er1o6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Er1o6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My .vimrc (I don't know how to copy from vim to clipboard on linux)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1     &quot; Indent automatically depending on filetype&#xA;2     filetype indent on&#xA;3 &#xA;4     &quot; Turn on line numbering. Turn it off with &quot;set nonu&quot; &#xA;5     set number&#xA;6 &#xA;7     &quot; Set syntax on&#xA;8     syntax on&#xA;9 &#xA;10     &quot; Case insensitive search&#xA;11     set ic&#xA;12 &#xA;13     &quot; Higlhight search&#xA;14     set hls&#xA;15 &#xA;16     &quot; Wrap text instead of being on one line&#xA;17     set lbr&#xA;18 &#xA;19     &quot; Change colorscheme &#xA;20     let g:solarized_termcolors=256&#xA;21     set background=dark&#xA;22     set t_Co=256&#xA;23     colorscheme solarized&#xA;24     &quot; show existing tab with 4 spaces width&#xA;25     set tabstop=4&#xA;26 &#xA;27     &quot; when indenting with '&amp;gt;', use 4 spaces width&#xA;28     set shiftwidth=4&#xA;29 &#xA;30     &quot; On pressing tab, insert 4 spaces&#xA;31     set expandtab&#xA;32 &#xA;33     &quot; Setting wildmenu&#xA;34     set wildmenu&#xA;35 &#xA;36 &#xA;37     call plug#begin('~/.vim/plugged')&#xA;38 &#xA;39     Plug 'https://github.com/scrooloose/nerdtree.git'&#xA;40     Plug 'https://github.com/Valloric/YouCompleteMe.git'&#xA;41     Plug 'https://github.com/altercation/vim-colors-solarized.git'&#xA;43     call plug#end()&#xA;44 &#xA;45     let g:ycm_server_python_interpreter = '/usr/bin/python'&#xA;46     let g:ycm_global_ycm_extra_conf = &quot;~/.vim/plugged/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user9120" LastEditorUserId="5395" LastEditDate="2017-02-13T14:23:10.523" LastActivityDate="2017-02-13T14:23:10.523" Title="Vim says I don't have solarized colorscheme whereas I have that" Tags="|vimrc|cut-copy-paste|error|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11386" PostTypeId="2" ParentId="11385" CreationDate="2017-02-13T14:16:59.233" Score="1" Body="&lt;p&gt;Move lines 19-23 of your &lt;code&gt;.vimrc&lt;/code&gt; after calling &lt;code&gt;plug#end()&lt;/code&gt; (in the above &lt;code&gt;.vimrc&lt;/code&gt; excerpt after line 43).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general you want to configure plugins after they were loaded, not before that. Vim will complain in different ways if the order is wrong (i.e. first configured and later &lt;code&gt;loaded&lt;/code&gt;/&lt;code&gt;added to runtime path&lt;/code&gt; by plugin manager)&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-02-13T14:16:59.233" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11387" PostTypeId="1" CreationDate="2017-02-13T14:20:10.150" Score="1" ViewCount="116" Body="&lt;p&gt;Saw this in a .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;====[ Ensure autodoc'd plugins are supported ]===========&#xA;runtime plugin/_autodoc.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea on what autodoc'd docs are and how they work?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-02-13T22:10:36.887" Title="What are autodoc'd plugins?" Tags="|vimrc|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11388" PostTypeId="1" AcceptedAnswerId="11389" CreationDate="2017-02-13T14:47:21.880" Score="3" ViewCount="763" Body="&lt;p&gt;From the docs at &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/options.html#&lt;/a&gt;'cpoptions':&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    a   When included, a &quot;:read&quot; command with a file name&#xA;        argument will set the alternate file name for the&#xA;        current window.&#xA;&#xA;    A   When included, a &quot;:write&quot; command with a file name&#xA;        argument will set the alternate file name for the&#xA;        current window.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm confused by what an &quot;alternate file name&quot; is. And if these two options are unset with &lt;code&gt;cpo-=aA&lt;/code&gt;, how will VIM behave differently?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-02-13T16:16:49.227" Title="What do &quot;a&quot; and &quot;A&quot; cpoptions do, exactly?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11389" PostTypeId="2" ParentId="11388" CreationDate="2017-02-13T15:16:05.083" Score="7" Body="&lt;p&gt;The alternate file is the file you were previously editing in the current window. Each window has its own independent alternate file. Type &lt;code&gt;:h usr_07.txt&lt;/code&gt;, and look for the pattern &lt;code&gt;alternate&lt;/code&gt;. You should find this paragraph:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The file you were previously editing is called the &quot;alternate&quot; file.  When you&#xA;just started Vim CTRL-^ will not work, since there isn't a previous file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can toggle between the current and alternate files by typing on the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:buffer #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... or shorter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:b#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, from normal mode, you can press &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; (could be the same as &lt;code&gt;&amp;lt;C-6&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Suppose you have 3 files A, B, and C. And you launch Vim to edit A:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A is your current file, and there's no alternate file.&#xA;If you load B (&lt;code&gt;:edit B&lt;/code&gt;), then A becomes the alternate file, and B becomes the current file. You can toggle between A and B  as many times as you want by repeating &lt;code&gt;:b#&lt;/code&gt; or &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If at some point you stop toggling, while your current buffer is B, your alternate file is A, and you ask Vim to edit C (&lt;code&gt;:edit C&lt;/code&gt;), then the current file will become C, and the alternate file will become B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From then, &lt;code&gt;:b#&lt;/code&gt; and &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; won't make you cycle between A and B anymore, but between B and C.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The name of the alternate file is stored inside the &lt;code&gt;#&lt;/code&gt; register, so you can read it by typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo @#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also see it when you type &lt;code&gt;:ls&lt;/code&gt; or &lt;code&gt;:buffers&lt;/code&gt;. These commands list all the buffers which are loaded in your current session. Inside the listing, the alternate buffer is marked with the &lt;code&gt;#&lt;/code&gt; sign, while the current buffer is marked with the &lt;code&gt;%&lt;/code&gt; sign.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If the &lt;code&gt;aA&lt;/code&gt; flags are inside &lt;code&gt;'cpo'&lt;/code&gt;, then, whenever you execute a command such as &lt;code&gt;:read some_file&lt;/code&gt; or &lt;code&gt;:write some_file&lt;/code&gt;, &lt;code&gt;some_file&lt;/code&gt; will become the alternate file for the current window.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To understand what's the effect of the &lt;code&gt;aA&lt;/code&gt; flags inside &lt;code&gt;'cpo'&lt;/code&gt;, you could try the following experiment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create 2 files inside your &lt;code&gt;/tmp&lt;/code&gt; folder, named &lt;code&gt;foo1.txt&lt;/code&gt; and &lt;code&gt;foo2.txt&lt;/code&gt;. The first one containing the word &lt;code&gt;hello&lt;/code&gt;, the second one containing &lt;code&gt;world&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /tmp &amp;amp;&amp;amp; echo hello &amp;gt;&amp;gt; foo1.txt &amp;amp;&amp;amp; echo world &amp;gt;&amp;gt; foo2.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Open &lt;code&gt;foo1.txt&lt;/code&gt; with Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim foo1.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And make sure the &lt;code&gt;a&lt;/code&gt; flag is not inside the &lt;code&gt;'cpo'&lt;/code&gt; option, by typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cpo-=a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try to load the alternate file for the current window with &lt;code&gt;:b#&lt;/code&gt; or &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Ex command should have no effect, and the normal command should raise the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E23: No alternate file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In both cases, the buffer displayed in the current window should still be &lt;code&gt;foo1.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This result was expected, because there can't be any alternate file for this window, since you've just started Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, import the contents of the &lt;code&gt;foo2.txt&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:read foo2.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your buffer should now contain:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello&#xA;world&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, try to load the alternate file with &lt;code&gt;:b#&lt;/code&gt; or &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;. The result is still the same.&lt;br&gt;&#xA;The &lt;code&gt;:read&lt;/code&gt; command didn't change / set the alternate file of your current window, because the &lt;code&gt;a&lt;/code&gt; flag wasn't inside &lt;code&gt;'cpo'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the &lt;code&gt;a&lt;/code&gt; flag to &lt;code&gt;'cpo'&lt;/code&gt;, and re-import the contents of &lt;code&gt;foo2.txt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cpo+=a&#xA;:r foo2.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your buffer should now contain:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello&#xA;world&#xA;world&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, try to load the alternate file: &lt;code&gt;:b#&lt;/code&gt; or &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This time, &lt;code&gt;/tmp/foo2.txt&lt;/code&gt; should be displayed in the current window, because the &lt;code&gt;a&lt;/code&gt; flag is inside &lt;code&gt;'cpo'&lt;/code&gt;, and so the argument of the previous &lt;code&gt;:read&lt;/code&gt; command, &lt;code&gt;/tmp/foo2.txt&lt;/code&gt;, was set as the alternate file of your window.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The same thing happens with the &lt;code&gt;:write&lt;/code&gt; command, and the &lt;code&gt;A&lt;/code&gt; flag.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;code&gt;:write&lt;/code&gt; command to write a range of lines of the current buffer inside another file. For example, you could visually select a paragraph, then type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;write /tmp/foo3.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should write the visual selection inside &lt;code&gt;/tmp/foo3.txt&lt;/code&gt;. But if the &lt;code&gt;A&lt;/code&gt; flag is not inside &lt;code&gt;'cpo'&lt;/code&gt;, then the alternate file of your current window won't be changed. If &lt;code&gt;A&lt;/code&gt; is inside &lt;code&gt;'cpo'&lt;/code&gt;, then &lt;code&gt;/tmp/foo3.txt&lt;/code&gt; will become the alternate file of your current window.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-02-13T16:16:49.227" LastActivityDate="2017-02-13T16:16:49.227" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11391" PostTypeId="1" CreationDate="2017-02-13T20:27:19.243" Score="1" ViewCount="588" Body="&lt;p&gt;I am using Vim 8.0.0326 64-bit from the &lt;a href=&quot;https://tuxproject.de/projects/vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;tuxproject&lt;/a&gt; with pathogen. I have 64-bit versions of Python installed in three locations:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Python 2.7 (64) - C:\Python27&lt;/li&gt;&#xA;&lt;li&gt;Python 3.6 (64) - C:\Python36&lt;/li&gt;&#xA;&lt;li&gt;Conda with Python 3.6 (64) - %APPDATA%..\Local\Continuum\Miniconda3&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Only the Python 3.6 installed with conda is present in the path. If I check the python paths from within vim, I get the following for Python2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py import sys;print '\n'.join(sys.path)&#xA;C:\must&amp;gt;not&amp;amp;exist&#xA;C:\Windows\system32\python27.zip&#xA;C:\Python27\Lib&#xA;C:\Python27\DLLs&#xA;C:\Python27\Lib\lib-tk&#xA;C:\Program Files\Vim&#xA;C:\Python27&#xA;C:\Python27\lib\site-packages&#xA;_vim_path_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't understand how Vim is able to find Python27 since it is not in the path. I also don't understand where &lt;code&gt;C:\must&amp;gt;not&amp;amp;exist&lt;/code&gt; is coming from. If I do the same thing for Python3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py3 import sys;print('\n'.join(sys.path)&#xA;C:\Users\akottke\AppData\Local\Continuum\Miniconda3\python36.zip&#xA;C:\Python36\Lib&#xA;C:\Python36\DLLs&#xA;C:\Program Files\Vim&#xA;C:\Python36&#xA;C:\Python36\lib\site-packages&#xA;_vim_path_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now Vim is finding both &lt;code&gt;C:\Python36&lt;/code&gt; and the conda version. However, &lt;code&gt;C:\Users\akottke\AppData\Local\Continuum\Miniconda3\python36.zip&lt;/code&gt; doesn't actually exist, but &lt;code&gt;python36.dll&lt;/code&gt; does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that if I hide &lt;code&gt;C:\Python36&lt;/code&gt; then Vim cannot run python3 even though it is in the path (provided by conda). This causes problems with library completion using jedi-vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I fix my path issues so that I can use jedi-vim to use Python3 provided by conda?&lt;/p&gt;&#xA;" OwnerUserId="11325" LastActivityDate="2017-02-13T20:27:19.243" Title="Windows + Vim + Python2 + Python3 = Path nightmare" Tags="|microsoft-windows|plugin-jedi-vim|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11393" PostTypeId="1" AcceptedAnswerId="11413" CreationDate="2017-02-14T00:14:53.100" Score="4" ViewCount="1069" Body="&lt;p&gt;I like the behavior of &lt;code&gt;smartcase&lt;/code&gt; while searching, and I like Vim's auto-completion options, but I don't like them together. Is there any way to keep &lt;code&gt;smartcase&lt;/code&gt; enabled, but have auto-completion results (&lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt;, and all &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt; prefixed keys) always be completely case sensitive? Maybe some clever remap?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2017-02-14T08:42:14.413" LastActivityDate="2019-11-17T22:44:33.350" Title="Disable case sensitive auto-completion, while &quot;smartcase&quot; search is enabled?" Tags="|vimrc|vimscript|search|autocompletion|letter-case|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11394" PostTypeId="1" AcceptedAnswerId="11397" CreationDate="2017-02-14T02:19:04.410" Score="2" ViewCount="920" Body="&lt;p&gt;I'm trying to autoload &lt;code&gt;.vimrc&lt;/code&gt; if I'm not saving it to &lt;code&gt;.tmp/.vimrc&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost !*.tmp\/\.vimrc source %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't work, though.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="205" LastEditDate="2017-02-14T10:54:53.623" LastActivityDate="2017-02-14T10:54:53.623" Title="Possible to negate a pattern?" Tags="|vimrc|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11395" PostTypeId="1" CreationDate="2017-02-14T04:35:06.487" Score="1" ViewCount="885" Body="&lt;p&gt;I have the following in my .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('persistent_undo')&#xA;    &quot; Save all undo files in a single location (less messy, more risky)...&#xA;    set undodir=$HOME/.VIM_UNDO_FILES&#xA;&#xA;    &quot; Save a lot of back-history...&#xA;    set undolevels=5000&#xA;&#xA;    &quot; Actually switch on persistent undo&#xA;    set undofile&#xA;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've created the &lt;code&gt;.VIM_UNDO_FILES&lt;/code&gt; in my home directory and have verified VIM has persistent_undo compiled in. Yet, when I close out a vim file and reopen, I cannot undo anything I did before the file was closed. Maybe I misunderstand how this is supposed to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried commenting out the if/endif and that didn't help. I also tried changing &lt;code&gt;$HOME&lt;/code&gt; to &lt;code&gt;~&lt;/code&gt;. that did not work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the &lt;code&gt;.VIM_UNDO_FILES&lt;/code&gt; file size never grows. It's stuck at 0.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="205" LastEditDate="2017-02-14T10:55:40.303" LastActivityDate="2020-09-17T11:16:24.280" Title="Persistent undo not working" Tags="|undo-redo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11396" PostTypeId="2" ParentId="11395" CreationDate="2017-02-14T04:57:14.123" Score="3" Body="&lt;p&gt;OK, I'm a dummy. I needed to create &lt;code&gt;.VIM_UNDO_FILES&lt;/code&gt; as a dir not a file.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-02-14T04:57:14.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11397" PostTypeId="2" ParentId="11394" CreationDate="2017-02-14T07:59:27.093" Score="3" Body="&lt;p&gt;Not sure if you can negate a pattern. Take a look at &lt;code&gt;:h {pat}&lt;/code&gt;. Also, if you negate such pattern (if it's even possible), it will also match for &lt;code&gt;/path/to/a/file/foo.bar&lt;/code&gt; or &lt;code&gt;/anything/you/would/think/of/bar.baz&lt;/code&gt;. If you want to source only the &lt;code&gt;$HOME/.vimrc&lt;/code&gt; when written, then you can specify full path like &lt;code&gt;/home/&amp;lt;USER&amp;gt;/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eventually you could use a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AutoLoadVimrc()&#xA;  if match(expand('%'), &quot;.*\.tmp/\.vimrc&quot;) == -1&#xA;    source %&#xA;  endif&#xA;endfunc&#xA;&#xA;autocmd BufWritePost .vimrc :call AutoLoadVimrc()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will generally check if that pattern doesn't match and then source such file. And because it's called on all files with name &lt;code&gt;.vimrc&lt;/code&gt;, regardless of the directory, it will act as a negation you're looking for.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-02-14T07:59:27.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11398" PostTypeId="2" ParentId="11394" CreationDate="2017-02-14T10:06:51.300" Score="5" Body="&lt;p&gt;@grodniz has already shown you the solution where you simply add a test. I would have written this though&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup ReloadVimrc&#xA;  au!&#xA;  au BufWritePost .vimrc if expand('&amp;lt;afile&amp;gt;') !~ '/tmp' |  source &amp;lt;afile&amp;gt; | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is for the generic answer to your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, you're in the situation of reloading the &lt;code&gt;.vimrc&lt;/code&gt;. There aren't that many valid emplacements for this file. Actually, when you load your &lt;code&gt;.vimrc&lt;/code&gt; for the first time, vim sets automatically &lt;code&gt;$MYVIMRC&lt;/code&gt; environment variable to it. That means, that the autocommand could become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost $MYVIMRC nested source $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as written in &lt;a href=&quot;https://stackoverflow.com/documentation/vim/3382/tips-and-tricks-to-boost-productivity/20644/automatically-reload-vimrc-upon-save#t=201702141004219471273&quot;&gt;Vim documentation on SO&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-02-14T10:06:51.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11399" PostTypeId="1" CreationDate="2017-02-14T12:15:02.157" Score="1" ViewCount="91" Body="&lt;p&gt;I was editing the resume in latex I had downloaded from &lt;a href=&quot;http://www.latextemplates.com/template/awesome-resume-cv&quot; rel=&quot;nofollow noreferrer&quot;&gt;here.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim is most erratic when it comes to checking spelling. In the resume_cv.tex file, the spell checking works. When I open any of the linked files by opening them (using &lt;code&gt;Ctrl-W&lt;/code&gt;+&lt;code&gt;gf&lt;/code&gt; command), cv-sections/skills.tex, etc. spell checking does not work. The result is the same even if I open the files directly from the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Completely unable to understand what is happening. How do I get spell checking back?&lt;/p&gt;&#xA;" OwnerUserId="3095" LastEditorUserId="1821" LastEditDate="2017-02-14T13:35:21.370" LastActivityDate="2017-02-15T04:44:01.427" Title="Erratic spell checking" Tags="|filetype-tex|spell-checking|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11401" PostTypeId="2" ParentId="11399" CreationDate="2017-02-14T14:59:17.613" Score="1" Body="&lt;p&gt;Most likely, the problem is that the files in which spell checking isn't working are being detected as &lt;code&gt;filetype=plaintex&lt;/code&gt;, but the file where it works is detected as &lt;code&gt;filetype=tex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's the case, then you can give Vim a hint that your &lt;code&gt;*.tex&lt;/code&gt; files will always be LaTeX by adding &lt;code&gt;let g:tex_flavor = 'latex'&lt;/code&gt; in your vimrc, as described in &lt;code&gt;:help ft-tex-plugin&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-02-14T14:59:17.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11402" PostTypeId="1" AcceptedAnswerId="11404" CreationDate="2017-02-14T16:41:37.297" Score="6" ViewCount="36484" Body="&lt;p&gt;I've toying with someone else's &lt;code&gt;.vimrc&lt;/code&gt; file. I'm getting an error on a function call within the &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing &amp;lt;FILE&amp;gt;:&#xA;line 1500:&#xA;E492: Not an editor command: EQAS_Align('\S:',         '',   '\s')&#xA;line 1501:&#xA;E492: Not an editor command: EQAS_Align('[[:punct:]]', '',   '\s')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Lines 1500 and 1501 are as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EQAS_Align('\S:',         '',   '\s')&#xA;EQAS_Align('[[:punct:]]', '',   '\s')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a plugin in  &lt;code&gt;~/.vim/plugin&lt;/code&gt; directory that accompanied this &lt;code&gt;.vimrc&lt;/code&gt; configuration that has the following function in it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function EQAS_Align (mode, ...) range&#xA;  let option = a:0 ? a:1 : {}&#xA;&#xA;  &amp;lt;snip&amp;gt;&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what the problem is and I don't know enough about VIM scripting to fix this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This line is in the &lt;code&gt;.vimrc&lt;/code&gt; file before these functions are called: &lt;code&gt;runtime plugin/eqalignsimple.vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="2021" LastEditDate="2017-02-14T18:03:52.093" LastActivityDate="2017-02-14T18:03:52.093" Title="Fixing a &quot;not an editor command&quot; error" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11403" PostTypeId="2" ParentId="666" CreationDate="2017-02-14T17:22:51.047" Score="55" Body="&lt;p&gt;Another option I use, which isn't exactly what you asked for, but accomplishes the same purpose of making it easier to see what is in the same column, is to set the following in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cursorcolumn&#xA;set cursorline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TZmWT.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TZmWT.png&quot; alt=&quot;cursorcolumn illustration&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has the trade off that you have to move your cursor to the column you want to see, but you get less visual clutter.  Usually when I care about indentation levels, I'm keeping my place with the cursor anyway.  My way also isn't as awkward-looking in languages like python without closing braces.&lt;/p&gt;&#xA;" OwnerUserId="780" LastActivityDate="2017-02-14T17:22:51.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11404" PostTypeId="2" ParentId="11402" CreationDate="2017-02-14T17:44:28.533" Score="7" Body="&lt;p&gt;It seems that the following 2 lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EQAS_Align('\S:',         '',   '\s')&#xA;EQAS_Align('[[:punct:]]', '',   '\s')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... refer to a custom function named &lt;code&gt;EQAS_Align()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It depends on what you want to do with it, but if you want its code to be processed, you have to prefix its name with the &lt;code&gt;:call&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call EQAS_Align('\S:',         '',   '\s')&#xA;call EQAS_Align('[[:punct:]]', '',   '\s')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To read its return value, you can use the &lt;code&gt;:echo&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo EQAS_Align('\S:',         '',   '\s')&#xA;echo EQAS_Align('[[:punct:]]', '',   '\s')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To assign its value to a variable, you can use the &lt;code&gt;:let&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let your_var1 = EQAS_Align('\S:',         '',   '\s')&#xA;let your_var2 = EQAS_Align('[[:punct:]]', '',   '\s')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To bind it to some keys in normal mode, you can use the &lt;code&gt;:nnoremap&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;key1&amp;gt; :call EQAS_Align('\S:',         '',   '\s')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;key2&amp;gt; :call EQAS_Align('[[:punct:]]', '',   '\s')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To bind it to a custom command, you can use the &lt;code&gt;:command&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! YourCommand1 call EQAS_Align('\S:',         '',   '\s')&#xA;command! YourCommand2 call EQAS_Align('[[:punct:]]', '',   '\s')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Regarding the function itself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function EQAS_Align (mode, ...) range&#xA;  let option = a:0 ? a:1 : {}&#xA;&#xA;  &amp;lt;snip&amp;gt;&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You probably want to add a bang after the &lt;code&gt;function&lt;/code&gt; keyword, otherwise Vim will complain each time you re-source your &lt;code&gt;vimrc&lt;/code&gt; because it won't be able to overwrite the old definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/user/.vimrc:&#xA;line XXX:&#xA;E122: Function EQAS_Align already exists, add ! to replace it&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The function is defined with the &lt;code&gt;range&lt;/code&gt; attribute, which means that if you pass a range to the &lt;code&gt;:call&lt;/code&gt; command, the function will be called only once. Which probably means that it will handle the range itself, using the variables &lt;code&gt;a:firstline&lt;/code&gt; and &lt;code&gt;a:lastline&lt;/code&gt; (see &lt;code&gt;:h :func-range&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the named argument &lt;code&gt;mode&lt;/code&gt;, it accepts the argument &lt;code&gt;...&lt;/code&gt;, which means that you could pass up to 20 more optional arguments. If there are optional arguments, inside the function, you can access them with the variables &lt;code&gt;a:1&lt;/code&gt;, &lt;code&gt;a:2&lt;/code&gt;, and so on; or with the list &lt;code&gt;a:000&lt;/code&gt;.&lt;br&gt;&#xA;&lt;code&gt;a:0&lt;/code&gt; is the number of optional arguments (see &lt;code&gt;:h a:0&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let option = a:0 ? a:1 : {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… is an assignment which uses a conditional expression (see &lt;code&gt;:h expr1&lt;/code&gt;).&lt;br&gt;&#xA;The expression tests whether &lt;code&gt;a:0&lt;/code&gt; is different than &lt;code&gt;0&lt;/code&gt;. If it is, then the variable &lt;code&gt;option&lt;/code&gt; is assigned the value &lt;code&gt;a:1&lt;/code&gt;, otherwise the value &lt;code&gt;{}&lt;/code&gt;.&lt;br&gt;&#xA;It means that if there are optional arguments, then the value of &lt;code&gt;option&lt;/code&gt; should be the first optional argument, otherwise it should be an empty dictionary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could probably do something similar using the &lt;code&gt;get()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let option = get(a:, '1', {})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… which means: take the dictionary &lt;code&gt;a:&lt;/code&gt; (which contains all the arguments of the function), and look for the key &lt;code&gt;1&lt;/code&gt; (first argument of the function). If you find the key, then return its associated value. If you don't find it, then return &lt;code&gt;{}&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2017-02-14T17:44:28.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11405" PostTypeId="2" ParentId="11402" CreationDate="2017-02-14T17:45:23.683" Score="3" Body="&lt;p&gt;Based on &lt;code&gt;:help startup&lt;/code&gt;, &lt;code&gt;vimrc&lt;/code&gt; files (section 3) are loaded before plugins (section 4), so it makes sense that you wouldn't be able to use plugin-defined functions in your &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Section 4 does note that plugin loading is equivalent to &lt;code&gt;:runtime! plugin/**/*.vim&lt;/code&gt; You could call that in your &lt;code&gt;~/.vimrc&lt;/code&gt; before the lines calling your plugin's function, or you could use a narrower command such as &lt;code&gt;:runtime! plugin/my_plugin.vim&lt;/code&gt; to only load &lt;code&gt;my_plugin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that either of these may result in the plugin(s) being loaded twice; once while loading your &lt;code&gt;~/.vimrc&lt;/code&gt; and once during regular plugin loading. Off the top of my head, I know that can potentially cause problems with defining autocommands twice. &lt;code&gt;:help :autocmd&lt;/code&gt; provides some suggestions for how to deal with that, if your plugin uses autocommands, you may want to check and make sure it protects itself.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2017-02-14T17:45:23.683" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11406" PostTypeId="1" AcceptedAnswerId="11407" CreationDate="2017-02-14T18:22:37.870" Score="1" ViewCount="70" Body="&lt;p&gt;I have a blank &lt;code&gt;.vimrc&lt;/code&gt; file. I'm seeing some very strange behavior. Here's what happens:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I open a file in vim&lt;/li&gt;&#xA;&lt;li&gt;I do &lt;code&gt;:split .tmp/file&lt;/code&gt; and &lt;code&gt;:q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;I make a change to the open file and &lt;code&gt;:w&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;I run &lt;code&gt;:e #&lt;/code&gt; which brings up the alternate file opened in step 2 and then swap back to first file with &lt;code&gt;:e #&lt;/code&gt; without doing anything else.&lt;/li&gt;&#xA;&lt;li&gt;I run &lt;code&gt;gx&lt;/code&gt;, a command from plugin I wrote (see below) that gets input from the user from vim's status bar which then passes it to a perl script. The perl script appends and writes two lines and the message to the &lt;code&gt;.tmp/file&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;THE PROBLEM:&lt;/strong&gt; When I reopen the &lt;code&gt;.tmp/file&lt;/code&gt;, there are three newlines after the last message instead of two. So somehow, vim is slapping an extra newline character into my &lt;code&gt;.tmp/file&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note: This problem does not happen when I do not run steps 2, 3, and 4; everything works as expected with two lines appended after each message. Here is my plugin (yeah, it's poorly written, it's my first one):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gx  :call AddCommNote()&amp;lt;CR&amp;gt;&#xA;&#xA;let g:Msg = ''&#xA;&#xA;function! AddCommNote()&#xA;  call inputsave()&#xA;  let g:Msg = input('Make commit message: ')&#xA;  call inputrestore()&#xA;  let g:Msg = call substitute(g:Msg, '\n', '', '')&#xA;  let is_commit = 0&#xA;  call ProcessMsg(is_commit)&#xA;endfunction&#xA;&#xA;function! ProcessMsg(is_commit)&#xA;  let escaped = substitute(g:Msg, &quot;'&quot;, &quot;'\&quot;'\&quot;'&quot;, &quot;&quot;)&#xA;  let command_to_run = &quot;add_comm_note '&quot; . escaped . &quot;' &quot;&#xA;  let command_to_run = command_to_run . &quot;'&quot; . expand(&quot;%:p&quot;) . &quot;' &quot; . a:is_commit&#xA;  exec &quot;silent:!&quot; . command_to_run&#xA;  :redraw!&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've stripped all newlines from &lt;code&gt;g:Msg&lt;/code&gt; in the plugin and in the perl script. The newline is definitely coming from vim as far as I can tell. I have no idea how.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the simple perl script which is in my ~/bin directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl&#xA;&#xA;use strict;&#xA;use warnings;&#xA;use File::Util;&#xA;&#xA;my $f = File::Util-&amp;gt;new();&#xA;my $message = $ARGV[0];&#xA;$message =~ s/\n//g;&#xA;my $file = $ARGV[1];&#xA;my ($path) = $f-&amp;gt;return_path($file);&#xA;my ($name) = $f-&amp;gt;strip_path($file);&#xA;my $tmp_file = $path . '/.tmp/' . $name;&#xA;my $newlines = $f-&amp;gt;existent($tmp_file) ? &quot;\n\n&quot; : '';&#xA;&#xA;if ($ARGV[2] &amp;amp;&amp;amp; !$message &amp;amp;&amp;amp; !$newlines) {&#xA;   $message = 'this commit message is unhelpful';&#xA;}&#xA;&#xA;exit if (!$newlines &amp;amp;&amp;amp; !$message); #nothing to add to the commit message file&#xA;&#xA;$f-&amp;gt;write_file('file' =&amp;gt; $tmp_file, 'mode' =&amp;gt; 'append', 'content' =&amp;gt; $newlines . $message);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="2021" LastEditDate="2017-02-14T19:19:39.730" LastActivityDate="2017-02-14T20:29:51.957" Title="Swapping between files causes unwanted insertion of newline by vim" Tags="|vimscript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11407" PostTypeId="2" ParentId="11406" CreationDate="2017-02-14T19:42:34.643" Score="1" Body="&lt;p&gt;I know nothing about perl, so if the problem comes from the script, or an interaction between Vim and the script I can't help you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, for the Vim part, here's how I would do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno gx  :&amp;lt;C-U&amp;gt;call AddCommNote()&amp;lt;CR&amp;gt;&#xA;&#xA;let g:Msg = ''&#xA;&#xA;fu! AddCommNote() abort&#xA;    let g:Msg = substitute(input('Make commit message: '), '\n', '', 'g')&#xA;    let is_commit = 0&#xA;    call ProcessMsg(is_commit)&#xA;endfu&#xA;&#xA;fu! ProcessMsg(is_commit) abort&#xA;    echom printf('silent !add_comm_note %s %s %d',&#xA;                \   shellescape(g:Msg, 1),&#xA;                \   shellescape(expand('%:p'), 1),&#xA;                \   a:is_commit&#xA;                \ )&#xA;    redraw!&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There are 2 main differences between this version and yours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, it adds the &lt;code&gt;g&lt;/code&gt; flag to the &lt;code&gt;substitute()&lt;/code&gt; function, so that all newlines are stripped and not only the first one, and it removes the &lt;code&gt;:call&lt;/code&gt; token from the assignment (&lt;code&gt;:call&lt;/code&gt; is only needed when you want to run the code inside a function; it's an error if you use it inside an assignment). So, these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Msg = input('Make commit message: ')&#xA;let g:Msg = call substitute(g:Msg, '\n', '', '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… could be replaced with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Msg = substitute(input('Make commit message: '), '\n', '', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second difference is the use of &lt;code&gt;shellescape()&lt;/code&gt; and &lt;code&gt;printf()&lt;/code&gt;. This part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let escaped = substitute(g:Msg, &quot;'&quot;, &quot;'\&quot;'\&quot;'&quot;, &quot;&quot;)&#xA;let command_to_run = &quot;add_comm_note '&quot; . escaped . &quot;' &quot;&#xA;let command_to_run = command_to_run . &quot;'&quot; . expand(&quot;%:p&quot;) . &quot;' &quot; . a:is_commit&#xA;exec &quot;silent:!&quot; . command_to_run&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… could be replaced with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  exe printf('silent !add_comm_note %s %s %d',&#xA;          \   shellescape(g:Msg, 1),&#xA;          \   shellescape(expand('%:p'), 1),&#xA;          \   a:is_commit&#xA;          \ )&#xA;  redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:execute&lt;/code&gt; should execute the output of the &lt;code&gt;printf()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;printf()&lt;/code&gt; expects a string describing a template containing various items. Each item inside the template is preceded by a &lt;code&gt;%&lt;/code&gt; sign.&#xA;Here, the template passed to &lt;code&gt;printf()&lt;/code&gt; as a first argument is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent !add_comm_note %s %s %d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It contains 3 items &lt;code&gt;%s&lt;/code&gt;, &lt;code&gt;%s&lt;/code&gt;, &lt;code&gt;%d&lt;/code&gt;. Each item will be replaced with the next arguments passed to &lt;code&gt;printf()&lt;/code&gt;. &lt;code&gt;%s&lt;/code&gt; denotes a string, while &lt;code&gt;%d&lt;/code&gt; denotes a decimal number.&#xA;The next arguments passed to &lt;code&gt;printf()&lt;/code&gt; are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;shellescape(g:Msg, 1)            the value of this expression will replace the first `%s`&#xA;shellescape(expand('%:p'), 1)    the value of this expression will replace the second `%s`&#xA;a:is_commit                      the value of this expression will replace the last `%d`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The shell arguments that you pass to your perl script, could have special characters which have a special meaning to the shell or to Vim.&#xA;To protect them, &lt;code&gt;shellescape()&lt;/code&gt; is called (protection from the shell), and &lt;code&gt;1&lt;/code&gt; is passed as a second argument (protection from Vim). See &lt;code&gt;:h shellescape()&lt;/code&gt; for more info.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If this new version doesn't work, you could replace &lt;code&gt;:exe&lt;/code&gt; with &lt;code&gt;:echom&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! ProcessMsg(is_commit) abort&#xA;  echom printf('silent !add_comm_note %s %s %d',&#xA;           \    shellescape(g:Msg, 1),&#xA;           \    shellescape(expand('%:p'), 1),&#xA;           \    a:is_commit&#xA;           \ )&#xA;  redraw!&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After typing your mapping, &lt;code&gt;gx&lt;/code&gt;, the whole command should be logged inside the message-history (see &lt;code&gt;:h :echom&lt;/code&gt;). You could read it by typing &lt;code&gt;:messages&lt;/code&gt;, then hit &lt;code&gt;G&lt;/code&gt; to go to the bottom of the history. Maybe you could read what it looks like, and make some tweaks according to what you want the shell to execute.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If it doesn't help because the problem comes from an interaction between Vim and the perl script, I'll delete the answer. I just wrote this in case it have an effect on the issue.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To better understand where the bug comes from, you could also use the &lt;code&gt;system()&lt;/code&gt; function to capture the output of the shell command inside a global variable (e.g. &lt;code&gt;g:debug&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! ProcessMsg(is_commit) abort&#xA;    let g:debug = system(printf('add_comm_note %s %s %d',&#xA;                \   shellescape(g:Msg, 1),&#xA;                \   shellescape(expand('%:p'), 1),&#xA;                \   a:is_commit&#xA;                \ ))&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, read the output with &lt;code&gt;:echo g:debug&lt;/code&gt; (and maybe post it here in your question, if you think it's relevant to the issue).&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-02-14T20:29:51.957" LastActivityDate="2017-02-14T20:29:51.957" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="11409" PostTypeId="1" AcceptedAnswerId="11463" CreationDate="2017-02-14T20:27:17.910" Score="3" ViewCount="883" Body="&lt;p&gt;Is is possible to use &lt;code&gt;&amp;lt;ScrollWheelUp&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;ScrollWheelDown&amp;gt;&lt;/code&gt; while the auto-complete popup is open? I tried using the map&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;ScrollWheelUp&amp;gt; pumvisible() ? &quot;&amp;lt;Up&amp;gt;&quot; : &quot;&amp;lt;Esc&amp;gt;&amp;lt;ScrollWheelUp&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;ScrollWheelDown&amp;gt; pumvisible() ? &quot;&amp;lt;Down&amp;gt;&quot; : &quot;&amp;lt;Esc&amp;gt;&amp;lt;ScrollWheelDown&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or alternatively,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;ScrollWheelUp&amp;gt; pumvisible() ? &quot;&amp;lt;C-p&amp;gt;&quot; : &quot;&amp;lt;Esc&amp;gt;&amp;lt;ScrollWheelUp&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;ScrollWheelDown&amp;gt; pumvisible() ? &quot;&amp;lt;C-n&amp;gt;&quot; : &quot;&amp;lt;Esc&amp;gt;&amp;lt;ScrollWheelDown&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is supposed to conditionally change the insert-mode behavior of the scroll wheel, but instead some weird random text like &lt;code&gt;[&amp;lt;65;20;15M]&lt;/code&gt; is inserted when I use the scroll wheel on an open popup menu with either of the above maps.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2017-02-14T21:00:10.280" LastActivityDate="2017-02-18T07:03:10.100" Title="Can I use the mouse scroll wheel to browse the auto-completion popup menu?" Tags="|vimrc|vimscript|autocompletion|scrolling|mouse|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11410" PostTypeId="2" ParentId="11343" CreationDate="2017-02-14T20:39:53.297" Score="1" Body="&lt;p&gt;I don't really know a good solution that does things the way you want it to work. As far as I know, Vim is not really designed for this scenario, and as such, I would expect any solution to be rather hackish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I will dare to suggest that &quot;you are doing it wrong&quot;. That is, if you are collaborating with a LaTeX document, then you really should be using a version control system (VCS) such as &lt;a href=&quot;https://git-scm.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Git&lt;/a&gt; or &lt;a href=&quot;https://www.mercurial-scm.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mercurial&lt;/a&gt;. Heck, you should use VCS's even if you are working on personal documents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The workflow would be slightly more &quot;complicated&quot; than the one you are using now. First, both you and your friend would need to know/learn a VCS. In a typical VCS workflow, you would communicate with each other through a central repository where you both committed or pushed changes. Even though this would be more complicated, it would also provide a lot of benefits, such as a good version history, better handling of conflicting edits, and it would be &quot;trivial&quot; to work together on the same document, at the same time.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-02-14T20:39:53.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11411" PostTypeId="1" AcceptedAnswerId="11424" CreationDate="2017-02-14T23:33:41.817" Score="10" ViewCount="12213" Body="&lt;p&gt;I'm wanting to learn Vim, but think it's probably too daunting. I imagine learning enough to become powerful with it, then forgetting 99% after I'm on a computerless project for a while.  I know just enough right now to open a file and get stuck, or make a huge mess and exit.  If there is an autocomplete feature for commands, I might be able to remember more easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;QUESTION:  Is there a version of Vim (or a plugin) that features an AutoComplete for Command Mode for those who can't remember a lot?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;...and to avoid confusion, I don't mean an auto completion for a programming language functions and methods, but an autocomplete for Vim's command mode itself, with perhaps a command description too.&lt;/p&gt;&#xA;" OwnerUserId="2466" LastEditorUserId="1841" LastEditDate="2017-02-15T09:10:44.127" LastActivityDate="2022-07-30T15:19:59.467" Title="Is there a version of Vim or plugin with a Command Mode auto completion?" Tags="|command-line|autocompletion|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11412" PostTypeId="1" AcceptedAnswerId="11427" CreationDate="2017-02-15T01:04:53.463" Score="3" ViewCount="1115" Body="&lt;p&gt;Sometimes, when I'm using the torte colorscheme and editing latex files, my latex expressions inside of &lt;code&gt;$&lt;/code&gt; signs show up in yellow. When this happens, my underscores disappear, as the following figure illustrates (what's written here is actually &lt;code&gt;$a_1$&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/GV5iy.png&quot; alt=&quot;Example figure&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For other latex files (I haven't yet figured out what makes the difference) the same expression would show up in a different color and the underscore would be visible: so there's something wierd going on with yellow. All my other symbols show up fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to fix this, so that I can see the underscores, even in yellow? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="4667" LastEditorUserId="21" LastEditDate="2017-02-15T12:32:29.393" LastActivityDate="2017-02-15T12:35:31.223" Title="Underscores don't show up in some colorschemes" Tags="|colorscheme|filetype-tex|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11413" PostTypeId="2" ParentId="11393" CreationDate="2017-02-15T02:51:04.203" Score="7" Body="&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created a plugin named &lt;a href=&quot;https://github.com/lukelbd/vim-idetools&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-idetools&lt;/a&gt; that implements this feature along with a bunch of related refactoring tools. Feel free to try it out.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Original answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, I figured out a way to do this. Just put this in your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set smartcase&#xA;au InsertEnter * set noignorecase&#xA;au InsertLeave * set ignorecase&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, when the popup menu opens up, &lt;code&gt;noignorecase&lt;/code&gt; will be turned on and only case-sensitive completions will be listed. Don't know why I hadn't thought of this! Note smartcase only works when &lt;code&gt;ignorecase&lt;/code&gt; turned on by overriding case-insensitivity whenever a capital letter is included in the search string. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a somewhat related note, I also have in my &lt;code&gt;.vimrc&lt;/code&gt; the lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;  * :let @/='\C\&amp;lt;' . expand('&amp;lt;cword&amp;gt;') . '\&amp;gt;'&amp;lt;CR&amp;gt;:let v:searchforward=1&amp;lt;CR&amp;gt;n&#xA;nnoremap &amp;lt;silent&amp;gt;  # :let @/='\C\&amp;lt;' . expand('&amp;lt;cword&amp;gt;') . '\&amp;gt;'&amp;lt;CR&amp;gt;:let v:searchforward=0&amp;lt;CR&amp;gt;n&#xA;nnoremap &amp;lt;silent&amp;gt; g* :let @/='\C'   . expand('&amp;lt;cword&amp;gt;')       &amp;lt;CR&amp;gt;:let v:searchforward=1&amp;lt;CR&amp;gt;n&#xA;nnoremap &amp;lt;silent&amp;gt; g# :let @/='\C'   . expand('&amp;lt;cword&amp;gt;')       &amp;lt;CR&amp;gt;:let v:searchforward=0&amp;lt;CR&amp;gt;n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which make &quot;*&quot; or &quot;#&quot; searches for the word under the cursor &lt;em&gt;case-sensitive&lt;/em&gt;, whether or not ignorecase is on. This was from &lt;a href=&quot;https://vi.stackexchange.com/questions/4054/case-sensitive-with-ignorecase-on&quot;&gt;this vi stackexchange thread&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reasoning behind this setup is that I often use &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;?&lt;/code&gt; searches to quickly navigate through a file (easier to do if they are case insensitive), while I use &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; to perform word or WORD replacements with &lt;code&gt;ciw&lt;/code&gt; and the popup menu to complete case-sensitive variable names.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2019-11-17T22:44:33.350" LastActivityDate="2019-11-17T22:44:33.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11416" PostTypeId="2" ParentId="11399" CreationDate="2017-02-15T04:44:01.427" Score="1" Body="&lt;p&gt;I do not understand what exactly is happening under the hood. But &lt;a href=&quot;https://stackoverflow.com/a/39539203/3282596&quot;&gt;here&lt;/a&gt; is the remedy to the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that change in tex.vim, things work as expected.&lt;/p&gt;&#xA;" OwnerUserId="3095" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-02-15T04:44:01.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11417" PostTypeId="1" CreationDate="2017-02-15T05:21:14.123" Score="-1" ViewCount="704" Body="&lt;p&gt;I have taken the &lt;code&gt;.vimrc&lt;/code&gt; from another guy. However, is &lt;code&gt;Leader&lt;/code&gt; character is now &lt;code&gt;,&lt;/code&gt;, and I am no longer able to modify it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let mapleader = &quot;,&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to change it for the default leader with &lt;code&gt;let mapleader = &quot;\&quot;&lt;/code&gt;, but it didn't work. Could anyone be able to tell me how to obtain the default mapping?&lt;/p&gt;&#xA;" OwnerDisplayName="user11345" LastActivityDate="2017-02-15T09:21:36.543" Title="Mapping for the leader" Tags="|key-bindings|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11418" PostTypeId="1" AcceptedAnswerId="11419" CreationDate="2017-02-15T05:25:43.107" Score="4" ViewCount="2064" Body="&lt;p&gt;The contents of register &lt;code&gt;w&lt;/code&gt; are &lt;code&gt;xx&lt;/code&gt;. When I try to run the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:for i in range(1,10) | if i &amp;gt; 5 | @w | endif | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It throws an error saying that &lt;code&gt;E492: Not an editor command xx&lt;/code&gt;.&lt;br&gt;&#xA;How do I execute the macro? &lt;/p&gt;&#xA;" OwnerUserId="11044" LastActivityDate="2017-02-15T06:13:47.567" Title="How to execute a macro in command mode?" Tags="|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11419" PostTypeId="2" ParentId="11418" CreationDate="2017-02-15T06:13:47.567" Score="7" Body="&lt;p&gt;Use &lt;code&gt;:h execute&lt;/code&gt; combined with &lt;code&gt;:h normal&lt;/code&gt;, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:for i in range(1,10) | if i &amp;gt; 5 | exe &quot;normal @w&quot; | endif | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Short explanation: &lt;code&gt;execute&lt;/code&gt;/&lt;code&gt;exe&lt;/code&gt; runs it's argument as an &lt;code&gt;Ex&lt;/code&gt; command and &lt;code&gt;normal&lt;/code&gt; behaves as you would press given symbols/keys yourself.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-02-15T06:13:47.567" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11420" PostTypeId="2" ParentId="11417" CreationDate="2017-02-15T06:21:44.937" Score="3" Body="&lt;p&gt;To get the default behaviour, the best way would be simply remove that setting from &lt;code&gt;.vimrc&lt;/code&gt;. But it's also possible to set that in &lt;code&gt;.vimrc&lt;/code&gt; by any of the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;\\&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = '\'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using double quote requires escaping special characters. And because &lt;code&gt;\&lt;/code&gt; is a special character used to escape others, it has to be escaped as well.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-02-15T06:21:44.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11421" PostTypeId="1" CreationDate="2017-02-15T07:25:42.573" Score="2" ViewCount="1391" Body="&lt;p&gt;I want all redundant whitespaces to be removed on write/save. How can I do that?&#xA;By redundant I mean ones that exists after the last character or if there's an empty line and it contains a few whitespaces.&lt;/p&gt;&#xA;" OwnerUserId="11354" LastActivityDate="2017-02-15T08:16:09.917" Title="Removing redundant whitespaces on save/write" Tags="|whitespace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11422" PostTypeId="2" ParentId="11421" CreationDate="2017-02-15T07:31:13.897" Score="5" Body="&lt;p&gt;Probably something like that should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * :%s/\s\+$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The autocommand triggers &lt;code&gt;:%s/\s\+$//&lt;/code&gt; each time a buffer will be written. And the substitution command removes all of the whitespaces at the end of lines.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-02-15T07:31:13.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11423" PostTypeId="2" ParentId="11421" CreationDate="2017-02-15T07:40:33.983" Score="3" Body="&lt;p&gt;I have a function for this, which also saves the cursor position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! &amp;lt;SID&amp;gt;StripTrailingWhitespaces()&#xA;  &quot; save last search &amp;amp; cursor position&#xA;  let _s=@/&#xA;  let l = line(&quot;.&quot;)&#xA;  let c = col(&quot;.&quot;)&#xA;  %s/\s\+$//e&#xA;  let @/=_s&#xA;  call cursor(l, c)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function can be called on the writepre hook:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre *.rb,*.php,*.py,*.js,*.txt,*.hs,*.java,*.md call &amp;lt;SID&amp;gt;StripTrailingWhitespaces()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you want it on every file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * call &amp;lt;SID&amp;gt;StripTrailingWhitespaces()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I have not written this function, but copied it from somewhere. Unfortunaly i don't remember where i found it. As pointed out in the comments, the source is probably vimcast (&lt;a href=&quot;http://vimcasts.org/episodes/tidying-whitespace/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;). So even if it doesn't matter for you, i don't want to take credit for this function, and vimcast can't be mentioned enough, as it is a great source for vim related knowledge.&lt;/p&gt;&#xA;" OwnerUserId="11316" LastEditorUserId="11316" LastEditDate="2017-02-15T08:16:09.917" LastActivityDate="2017-02-15T08:16:09.917" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11424" PostTypeId="2" ParentId="11411" CreationDate="2017-02-15T09:09:01.620" Score="22" Body="&lt;p&gt;I really don't think that having autocompletion or not will help you learning how to use Vim. Your main problem in my opinion is to learn the basics of the editor and then learn more and more commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway Vim has a built-in auto completion feature for the command line it is controlled with the &lt;code&gt;wildmenu&lt;/code&gt; and &lt;code&gt;wildmode&lt;/code&gt; options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first step is to create your &lt;code&gt;vimrc&lt;/code&gt; file if it doesn't exists yet and to add the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmenu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See the doc &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27wildmenu%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'wildmenu'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When 'wildmenu' is on, command-line completion operates in an enhanced&#xA;mode.  On pressing 'wildchar' (usually &amp;lt;Tab&amp;gt;) to invoke completion,&#xA;the possible matches are shown just above the command line, with the&#xA;first match highlighted (overwriting the status line, if there is&#xA;one).  Keys that show the previous/next match, such as &amp;lt;Tab&amp;gt; or&#xA;CTRL-P/CTRL-N, cause the highlight to move to the appropriate match.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then add your &lt;code&gt;wildmode&lt;/code&gt; configuration. Personally I used the following line but you might want to modify it to fit your needs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmode=longest,list,full&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To see which options are the most relevant for you have a look at the doc &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27wildmode%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'wildmode'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Completion mode that is used for the character specified with&#xA;'wildchar'.  It is a comma separated list of up to four parts.  Each&#xA;part specifies what to do for each consecutive use of 'wildchar'.  The&#xA;first part specifies the behavior for the first use of 'wildchar',&#xA;The second part for the second use, etc.&#xA;These are the possible values for each part:&#xA;&quot;&quot;              Complete only the first match.&#xA;&quot;full&quot;          Complete the next full match.  After the last match,&#xA;                the original string is used and then the first match&#xA;                again.&#xA;&quot;longest&quot;       Complete till longest common string.  If this doesn't&#xA;                result in a longer string, use the next part.&#xA;&quot;longest:full&quot;  Like &quot;longest&quot;, but also start 'wildmenu' if it is&#xA;                enabled.&#xA;&quot;list&quot;          When more than one match, list all matches.&#xA;&quot;list:full&quot;     When more than one match, list all matches and&#xA;                complete first match.&#xA;&quot;list:longest&quot;  When more than one match, list all matches and&#xA;                complete till longest common string.&#xA;When there is only a single match, it is fully completed in all cases.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-02-15T09:09:01.620" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11425" PostTypeId="2" ParentId="11417" CreationDate="2017-02-15T09:21:36.543" Score="3" Body="&lt;p&gt;Make sure you set the leader before using any mappings which involve the leader. When you use the leader in a mapping you're not saying &quot;use whatever the leader is, which I might have defined now, or I might define later on in this vimrc file&quot; you're saying &quot;use whatever the leader is currently set to right now&quot;.&lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastActivityDate="2017-02-15T09:21:36.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11426" PostTypeId="1" CreationDate="2017-02-15T12:17:31.190" Score="6" ViewCount="5005" Body="&lt;p&gt;I like how nerdtree looks as a side-drawer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/V0HTT.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/V0HTT.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;but if I close current buffer using &lt;code&gt;:bd&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;nerdtree will become a fullscreen buffer&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8g51z.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8g51z.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;and all new buffers will simply take full screen, nerdtree won't toggle as drawer but as full screen all the time, untull its closed and reopened&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3OFCU.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3OFCU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is there any way to make nerdtree consistently open as a drawer and never go full screen?&lt;/p&gt;&#xA;" OwnerDisplayName="user10804" LastActivityDate="2018-11-08T09:02:30.497" Title="make nerdtree buffer consistent" Tags="|buffers|plugin-nerdtree|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="11427" PostTypeId="2" ParentId="11412" CreationDate="2017-02-15T12:35:31.223" Score="2" Body="&lt;p&gt;This is probably because the filetype is set to &lt;code&gt;plaintex&lt;/code&gt; instead of &lt;code&gt;tex&lt;/code&gt;. You can &quot;force&quot; Vim to always use the &lt;code&gt;tex&lt;/code&gt; filetype with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tex_flavor = 'latex'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h g:tex_flavor&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-02-15T12:35:31.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11428" PostTypeId="2" ParentId="341" CreationDate="2017-02-15T12:50:10.303" Score="5" Body="&lt;p&gt;The roots of the family trees of vi clones seem to be:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1977: &lt;a href=&quot;http://ex-vi.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Traditional vi&amp;quot;&lt;/a&gt;, Bill Joy's original source, ported and free to use since 2002.&lt;/li&gt;&#xA;&lt;li&gt;1985: &lt;a href=&quot;http://www.jamesie.de/microemacs/index.en.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;microEmacs&lt;/a&gt;, from which the vi-alike &lt;a href=&quot;https://invisible-island.net/vile/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;vile&amp;quot;&lt;/a&gt; was developed.&lt;/li&gt;&#xA;&lt;li&gt;1987: &lt;a href=&quot;https://timthompson.com/tjt/stevie/&quot; rel=&quot;nofollow noreferrer&quot;&gt;stevie&lt;/a&gt;, from which &lt;a href=&quot;https://www.vim.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim&lt;/a&gt; and &lt;a href=&quot;https://martinwguy.github.io/xvi/&quot; rel=&quot;nofollow noreferrer&quot;&gt;xvi&lt;/a&gt; were developed.&lt;/li&gt;&#xA;&lt;li&gt;1990: &lt;a href=&quot;http://elvis.the-little-red-haired-girl.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;elvis&lt;/a&gt;, from which &lt;a href=&quot;https://sites.google.com/a/bostic.com/keithbostic/vi/&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvi&lt;/a&gt; was developed.&lt;/li&gt;&#xA;&lt;li&gt;2000: busybox's &amp;quot;tiny vi&amp;quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10565" LastEditorUserId="51" LastEditDate="2022-07-01T14:31:36.433" LastActivityDate="2022-07-01T14:31:36.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11429" PostTypeId="1" AcceptedAnswerId="11430" CreationDate="2017-02-15T16:33:07.233" Score="2" ViewCount="119" Body="&lt;p&gt;I have the following in a .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vmap ; :Blockwise&amp;lt;SPACE&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what the &lt;code&gt;Blockwise&lt;/code&gt; key word does.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-02-15T17:11:14.400" Title="What does &quot;Blockwise&quot; in execute mode do?" Tags="|vimrc|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11430" PostTypeId="2" ParentId="11429" CreationDate="2017-02-15T16:53:34.883" Score="2" Body="&lt;p&gt;It's an Ex command, and since its first character is written in uppercase, it's probably a custom command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To see what it does, and where it was defined, you can use this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose command Blockwise&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… or shorter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verb com Blockwise&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;By default, an Ex command operates on whole lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for example, suppose you wanted to perform a substitution inside a column in a paragraph. You could visually select it, then type &lt;code&gt;:s/pattern/replacement/g&lt;/code&gt;. You could think that the substitution command would replace the occurrences of &lt;code&gt;pattern&lt;/code&gt; with &lt;code&gt;replacement&lt;/code&gt; only inside the block, but since Ex commands operates on whole lines, &lt;code&gt;:s&lt;/code&gt; would replace &lt;code&gt;pattern&lt;/code&gt; anywhere in the paragraph, not just inside the column you selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a workaround, inside the pattern, you could use the atom &lt;code&gt;\%V&lt;/code&gt; (see &lt;code&gt;:h /\%V&lt;/code&gt;), but it may not be always as simple for other commands (other than &lt;code&gt;:s&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With your mapping, if you hit &lt;code&gt;;&lt;/code&gt; in visual mode, Vim will write on the command line &lt;code&gt;:'&amp;lt;,'&amp;gt;Blockwise&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, it's just a guess, but your &lt;code&gt;:Blockwise&lt;/code&gt; command probably expects as an argument another command, and limits the effect of the latter on a visual blockwise selection. It may be a mechanism to enable all or most of Vim Ex commands to operate on blockwise selection, and not just whole lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With it, you could probably do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;Blockwise s/pattern/replacement/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… to replace &lt;code&gt;pattern&lt;/code&gt; with &lt;code&gt;replacement&lt;/code&gt;, only inside the visual block.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;When you find the name of a command which you don't know, you can try to look for it inside the help, with the &lt;code&gt;:helpgrep&lt;/code&gt; or &lt;code&gt;:lhelpgrep&lt;/code&gt; command. The latter can be shortened into &lt;code&gt;:lh&lt;/code&gt;. Currently, if I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:lh :Blockwise&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't have any results, so with this you would know it's not a default Vim command. However, if it has been installed with a plugin which has some documentation, then it's possible that the previous command returns some results.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You probably want to replace &lt;code&gt;:vmap&lt;/code&gt;, with &lt;code&gt;:xnoremap&lt;/code&gt;. In front of a &lt;code&gt;:map&lt;/code&gt; command, &lt;code&gt;v&lt;/code&gt; doesn't mean &lt;code&gt;visual mode&lt;/code&gt;, it means &lt;code&gt;visual mode&lt;/code&gt;+&lt;code&gt;select mode&lt;/code&gt;. &lt;code&gt;x&lt;/code&gt; stands for visual mode only. So, if you use &lt;code&gt;:vmap&lt;/code&gt;, you will bind a printable character (&lt;code&gt;;&lt;/code&gt;) in &lt;code&gt;select mode&lt;/code&gt;. And the help says that it could be confusing to a user (&lt;code&gt;:h mapmode-x&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NOTE: Mapping a printable character in Select mode may confuse the user.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could change your mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap ; :Blockwise&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-02-15T17:11:14.400" LastActivityDate="2017-02-15T17:11:14.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11431" PostTypeId="1" AcceptedAnswerId="11433" CreationDate="2017-02-15T18:27:27.757" Score="4" ViewCount="282" Body="&lt;p&gt;I have two files written in php, both with a bunch of functions. I need to compare these function names with the other file, so I'm trying to get a list of all lines that begin with &lt;code&gt;function&lt;/code&gt;. Preferably I would like to have these lines copy to a register. Is there an easy way to do this?&lt;/p&gt;&#xA;" OwnerUserId="11372" LastEditorUserId="2920" LastEditDate="2017-02-15T18:28:42.463" LastActivityDate="2017-02-15T18:38:28.837" Title="Get list of lines that begin with a pattern" Tags="|regular-expression|register|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11432" PostTypeId="1" AcceptedAnswerId="11435" CreationDate="2017-02-15T18:30:01.983" Score="3" ViewCount="2672" Body="&lt;p&gt;The old three lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;able&#xA;bee&#xA;must&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to change them to this in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;able /home/words/a/able&#xA;bee /home/words/b/bee&#xA;must /home/words/m/must&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I knew using &lt;code&gt;%s/^\(.*\)$/\1/home/wprds/\1&lt;/code&gt; can add some characters, but how can I get the first letter of each substitution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for my poor English.&lt;/p&gt;&#xA;" OwnerUserId="11373" LastEditorUserId="2920" LastEditDate="2017-02-15T19:07:36.740" LastActivityDate="2017-02-15T19:12:56.377" Title="How do I get the first letter of a captured group?" Tags="|regular-expression|substitute|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11433" PostTypeId="2" ParentId="11431" CreationDate="2017-02-15T18:32:23.597" Score="9" Body="&lt;p&gt;This can be done pretty easily with the &lt;code&gt;global&lt;/code&gt; command. I would try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=''&#xA;:g/^function/y A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First we must call &lt;code&gt;:let @a=''&lt;/code&gt; to make sure that the 'a' register is empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, the global command is used to apply a command to every line matching a certain regex. In this case, the regex is &lt;code&gt;^function&lt;/code&gt;, and the command is &lt;code&gt;y A&lt;/code&gt; (the &lt;em&gt;ex&lt;/em&gt; command, not the normal mode command). From &lt;code&gt;:h :y&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *:y* *:yank* *E850*&#xA;:[range]y[ank] [x]  Yank [range] lines [into register x]. Yanking to the&#xA;            &quot;* or &quot;+ registers is possible only when the&#xA;            |+clipboard| feature is included.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yanking into uppercase &lt;em&gt;A&lt;/em&gt; as opposed to lowercase &lt;em&gt;a&lt;/em&gt; means that the yanked text is &lt;em&gt;appended&lt;/em&gt; to the register. &lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-02-15T18:32:23.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11434" PostTypeId="2" ParentId="11431" CreationDate="2017-02-15T18:38:28.837" Score="3" Body="&lt;p&gt;You could also use &lt;code&gt;vimgrep&lt;/code&gt;. It wouldn't put them in a register but you'd get this list pretty easily.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /^function/ ./*.php&#xA;:cw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:cw&lt;/code&gt; Opens the quick fix so you can see the result of your search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3Avimgrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :vimgrep&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#quickfix&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help quickfix&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-02-15T18:38:28.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11435" PostTypeId="2" ParentId="11432" CreationDate="2017-02-15T18:42:56.133" Score="6" Body="&lt;p&gt;I'm not sure this is exactly what you ask for, but assuming you wanted to replace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;able&#xA;bee&#xA;must&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;able /home/words/a/able&#xA;bee /home/words/b/bee&#xA;must /home/words/m/must&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, you could try the following substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s:\v(.).*:&amp;amp; /home/words/\1/&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which could be broken down like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s:\v(.).*:&amp;amp; /home/words/\1/&amp;amp;&#xA;&quot;  |  |    | |           |  |&#xA;&quot;  |  |    | |           |  +-- old line&#xA;&quot;  |  |    | |           +-- first captured character&#xA;&quot;  |  |    | +-- `/home/words/` literally&#xA;&quot;  |  |    +-- beginning of the replacement: old line&#xA;&quot;  |  +-- capture first letter on the line&#xA;&quot;  +-- very magic mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the replacement part contains slash characters, to avoid having to escape them, this substitution uses a colon (&lt;code&gt;:&lt;/code&gt;) as a delimiter to separate the name of the command from the pattern, and the pattern from the replacement (instead of a usual slash).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the replacement part, you can refer to any text that you have captured in the pattern with the first group of parentheses through the expression &lt;code&gt;\1&lt;/code&gt;. Here the first group of parentheses is used to capture the first character on each line.&lt;br&gt;&#xA;And you can refer to the whole pattern with the metacharacter &lt;code&gt;&amp;amp;&lt;/code&gt; or &lt;code&gt;\0&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastEditorUserId="6960" LastEditDate="2017-02-15T18:54:29.413" LastActivityDate="2017-02-15T18:54:29.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11436" PostTypeId="2" ParentId="11432" CreationDate="2017-02-15T19:12:56.377" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/11435/2920&quot;&gt;User9433424's answer&lt;/a&gt; is a great solution, but you could also do this without any substitute or regex commands.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm ywA /home/words/&amp;lt;C-v&amp;gt;&amp;lt;esc&amp;gt;pblC/&amp;lt;C-v&amp;gt;&amp;lt;esc&amp;gt;&quot;0p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, if you have other lines in the buffer that you don't want to modify, you could visually select them an do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm ywA /home/words/&amp;lt;C-v&amp;gt;&amp;lt;esc&amp;gt;pblC/&amp;lt;C-v&amp;gt;&amp;lt;esc&amp;gt;&quot;0p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The same except for the &lt;code&gt;%&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This simply applies a set of keystrokes to each line as if you had manually typed them on each line. The &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; is &lt;kbd&gt;ctrl-v&lt;/kbd&gt;, and is needed so that you can insert a literal &lt;kbd&gt;esc&lt;/kbd&gt; character into the command.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-02-15T19:12:56.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11437" PostTypeId="2" ParentId="9977" CreationDate="2017-02-15T20:43:37.760" Score="1" Body="&lt;p&gt;Well, you could always poll Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:m = ''&#xA;&#xA;function! MyHandler(timer)&#xA;  let m = mode(1)&#xA;  if m != s:m&#xA;    if m == 'no'&#xA;      echo &quot;operator pending&quot;&#xA;    else&#xA;      echo &quot;-&quot;&#xA;    endif&#xA;    let s:m = m&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Start with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call timer_start(250, 'MyHandler', {'repeat': -1})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-02-15T20:43:37.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11445" PostTypeId="1" AcceptedAnswerId="11446" CreationDate="2017-02-16T09:56:15.307" Score="2" ViewCount="1280" Body="&lt;p&gt;I want to write an &lt;code&gt;autocmd&lt;/code&gt; &lt;code&gt;pat&lt;/code&gt; that matches more than one file, eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Source .vimrc after saving&#xA;autocmd! BufWritePost ($MYVIMRC,$MYGVIMRC) nested source % | echom &quot;Reloaded &quot; . expand('%') | redraw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help pat&lt;/code&gt; doesn't give examples around the usage of &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt;, &lt;code&gt;|&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I achieve the desired result?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastActivityDate="2017-02-16T10:05:35.197" Title="autocmd: match more than one pattern" Tags="|autocmd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11446" PostTypeId="2" ParentId="11445" CreationDate="2017-02-16T10:04:26.990" Score="4" Body="&lt;pre&gt;&lt;code&gt;autocmd! BufWritePost $MYVIMRC,$MYGVIMRC {cmd....}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1569" LastActivityDate="2017-02-16T10:04:26.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11447" PostTypeId="2" ParentId="11445" CreationDate="2017-02-16T10:05:35.197" Score="1" Body="&lt;p&gt;It should work if you use escaped parenthesis and escaped &lt;code&gt;|&lt;/code&gt; sign as a delimiter, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Source .vimrc after saving&#xA;autocmd! BufWritePost \($MYVIMRC\|$MYGVIMRC\) CMD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-02-16T10:05:35.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11450" PostTypeId="2" ParentId="3478" CreationDate="2017-02-16T16:38:41.427" Score="2" Body="&lt;p&gt;You may also want to check &lt;code&gt;:h :map-&amp;lt;expr&amp;gt;&lt;/code&gt;. While admittedly in this case it would be overkill, it enables mappings of the following type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PopulateFooMap(c)&#xA;  let dict = { &quot;r&quot;:&quot;bar&quot;, &quot;z&quot;:&quot;baz&quot; }&#xA;  return &quot;:e **/&quot; . get(dict, a:c, a:c)&#xA;endfunction&#xA;&#xA;&quot; very powerful&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;/ PopulateFooMap(nr2char(getchar()))&#xA;&#xA;&quot; but this would still take precedence&#xA;nnoremap &amp;lt;leader&amp;gt;/f :e **/foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4934" LastActivityDate="2017-02-16T16:38:41.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11452" PostTypeId="1" AcceptedAnswerId="11453" CreationDate="2017-02-16T19:04:07.603" Score="1" ViewCount="844" Body="&lt;p&gt;I have a function that I would like to run once and do nothing in subsequent calls to it. It handles lazy-loading of plugins. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LoadExpensivePlugins()&#xA;  call StuffToRunOnceOnly&#xA;  &quot; what do i do here?&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="390" LastActivityDate="2017-02-16T19:07:30.610" Title="How can I delete a vimscript function?" Tags="|vimscript|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11453" PostTypeId="2" ParentId="11452" CreationDate="2017-02-16T19:07:30.610" Score="2" Body="&lt;p&gt;The simplest solution is simply to set a variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:LoadExpensivePluginsHasBeenRun = 0&#xA;function! LoadExpensivePlugins()&#xA;   if !(s:LoadExpensivePluginsHasBeenRun)&#xA;      call StuffToRunOnceOnly&#xA;      let s:LoadExpensivePluginsHasBeenRun = 1&#xA;   endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-02-16T19:07:30.610" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11454" PostTypeId="1" AcceptedAnswerId="24608" CreationDate="2017-02-16T21:22:27.803" Score="2" ViewCount="6752" Body="&lt;p&gt;I'd like to write and edit files and add a padding, or frame the text with margin of blank space between the text and the terminal window's edge. I don't know if that's the correct terminology, but I don't want the text flush against the edges.  Is there a way to adjust the Vim screen padding margin? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the terminal program I use is called &quot;Konsole&quot;  Maybe there is a way to make adjustments for it, rather than Vim?&lt;/p&gt;&#xA;" OwnerUserId="2466" LastEditorUserId="2466" LastEditDate="2017-02-16T22:59:43.133" LastActivityDate="2020-04-15T14:19:48.533" Title="Is there a way to adjust the Vim screen padding margin, or Konsole's?" Tags="|margin|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11455" PostTypeId="1" CreationDate="2017-02-17T02:40:47.920" Score="0" ViewCount="619" Body="&lt;p&gt;I'm in the browsing directory mode how can I change the current directory to that one I'm browsing? At least manually. But &quot;:chdir .&quot; doesn't work&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover, in the config file I have &quot;set autochdir&quot; and it still doesn't change it always automatically&lt;/p&gt;&#xA;" OwnerUserId="11354" LastActivityDate="2017-02-17T15:38:32.233" Title="chdir doesn't work" Tags="|working-directory|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11456" PostTypeId="2" ParentId="11455" CreationDate="2017-02-17T10:10:52.100" Score="1" Body="&lt;p&gt;The &lt;code&gt;acd&lt;/code&gt; option should do what you want, you should describe, why and how it &lt;strong&gt;doesn't work&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want the path change to happen automatically, so in my vimrc file, I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Switch to current dir&#xA;nnoremap &amp;lt;Leader&amp;gt;cd :cd %:p:h&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1569" LastActivityDate="2017-02-17T10:10:52.100" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11457" PostTypeId="1" AcceptedAnswerId="11519" CreationDate="2017-02-17T10:28:32.517" Score="3" ViewCount="1173" Body="&lt;p&gt;I have the following file named &lt;code&gt;asterix&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0000000: 15 00 1f c1 13 31 49 80 02 64 01 08 42 48 ef 28             &#xA;0000010: 2d cd 0c 02 00 07 f1 e9 1b 04 63 30 c7 08 20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open this file in vim, I do &lt;code&gt;%!xxd -r&lt;/code&gt;, then &lt;code&gt;%!xxd -g1&lt;/code&gt;. I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0000000: 15 00 1f d0 b0 13 31 49 e2 94 80 02 64 01 08 42  ...1I...d..B&#xA;0000010: 48 d0 9e 28 2d d0 bc 0c 02 00 07 d0 af d0 98 1b  H..(-...&#xA;0000020: 04 63 30 d0 b3 08 20 0a                          .c0... .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if in &lt;code&gt;bash&lt;/code&gt; I do &lt;code&gt;xxd -r &amp;lt; asterix | xxd -g1&lt;/code&gt;, I get the expected result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0000000: 15 00 1f c1 13 31 49 80 02 64 01 08 42 48 ef 28  ...1I..d..BH.(&#xA;0000010: 2d cd 0c 02 00 07 f1 e9 1b 04 63 30 c7 08 20     -...c0..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried doing &lt;code&gt;e ++enc=c&lt;/code&gt; in vim to prevent possible interference of encoding, but this doesn't seem to change anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what's going on? How do I make vim work correctly with binary data (up to newline at the end, of course)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using VIM 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:59) on Ubuntu 14.04. When I run vim with &lt;code&gt;env -i vim asterix&lt;/code&gt;, it works as expected. But if I run it as usually, but logging in as a different user (the one without custom vim config, by e.g. &lt;code&gt;su -&lt;/code&gt;), the above described behavior persists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've now noticed that &lt;code&gt;env -i&lt;/code&gt; works because it resets locale. My default locale is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LANG=en_US&#xA;LC_CTYPE=ru_RU.UTF-8&#xA;LC_NUMERIC=&quot;en_US&quot;&#xA;LC_TIME=en_GB.UTF-8&#xA;LC_COLLATE=&quot;en_US&quot;&#xA;LC_MONETARY=&quot;en_US&quot;&#xA;LC_MESSAGES=&quot;en_US&quot;&#xA;LC_PAPER=&quot;en_US&quot;&#xA;LC_NAME=&quot;en_US&quot;&#xA;LC_ADDRESS=&quot;en_US&quot;&#xA;LC_TELEPHONE=&quot;en_US&quot;&#xA;LC_MEASUREMENT=&quot;en_US&quot;&#xA;LC_IDENTIFICATION=&quot;en_US&quot;&#xA;LC_ALL=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;LC_CTYPE=C&lt;/code&gt;, I get Vim to work correctly (it appends &lt;code&gt;0a&lt;/code&gt; to the end, but it's OK). Still I'd like to know why locale interferes with calling &lt;code&gt;xxd -r&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1081" LastEditorUserId="1081" LastEditDate="2017-02-18T16:59:25.467" LastActivityDate="2017-02-23T10:37:01.827" Title="Why is `%!xxd -r` result wrong while `xxd -r` from console with the same input works correctly?" Tags="|binary-file|xxd|" AnswerCount="1" CommentCount="11" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11458" PostTypeId="2" ParentId="11382" CreationDate="2017-02-17T13:31:24.587" Score="3" Body="&lt;p&gt;I found the solution on &lt;a href=&quot;http://vim.wikia.com/wiki/GNU_Screen_integration&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/GNU_Screen_integration&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h2&gt;Getting the Esc key to work&lt;/h2&gt;&#xA;  &#xA;  &lt;hr&gt;&#xA;  &#xA;  &lt;p&gt;If you use Vim under Screen, you might find that the &lt;code&gt;Esc&lt;/code&gt; key doesn't work.&#xA;  To fix this, add the following to your &lt;code&gt;.screenrc&lt;/code&gt;:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;&amp;gt; maptimeout 5&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This may be necessary so Screen will wait no more than 5 milliseconds between characters when detecting an input sequence.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2489" LastActivityDate="2017-02-17T13:31:24.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11460" PostTypeId="2" ParentId="11373" CreationDate="2017-02-17T14:59:23.930" Score="0" Body="&lt;p&gt;I was not able to reproduce your macro but here is a (far from ideal) approach to your problem: Register persistently your steps in a macro and then launch Vim and tell it to directly execute your macro and close again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ex:&#xA;In your &lt;code&gt;.vimrc&lt;/code&gt;, you register the macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; convert everything to uppercase&#xA;let @x = 'ggVGU'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Start Vim, call the macro from the cmd line and close Vim again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat test.txt&#xA;sdfas;dlfasdf&#xA;asdf&#xA;adf&#xA;&#xA;$ vim -c &quot;:norm! @x&quot; -c &quot;:x&quot; test.txt&#xA;&#xA;$ cat test.txt&#xA;SDFAS;DLFASDF&#xA;ASDF&#xA;ADF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will obviously start vim and close it right a way. I guess there are some optimizations possible. Make a shell &lt;code&gt;alias&lt;/code&gt; for the whole thing, start Vim without plugins/vimrc and only load your dummy vimrc (to make startup fast if that's a problem), probably other ideas as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;a href=&quot;https://stackoverflow.com/a/2024537/2923406&quot;&gt;answer&lt;/a&gt; explains how to record macros and add them to your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6357" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-02-17T14:59:23.930" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11461" PostTypeId="2" ParentId="11455" CreationDate="2017-02-17T15:38:32.233" Score="1" Body="&lt;p&gt;Just type &lt;code&gt;c&lt;/code&gt;. From &lt;code&gt;:help netrw-c&lt;/code&gt; (or just execute &lt;code&gt;:help netrw&lt;/code&gt; and search for &lt;code&gt;directory&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;By default, ... the current directory will not track the browsing directory.  ...  [I]n order to make the two directories the same, use the &quot;c&quot; map (just type c).  That map will set Vim's notion of the current directory to netrw's current browsing directory.&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;For an acknowledgement of the &lt;code&gt;'autochdir'&lt;/code&gt; (&lt;code&gt;'acd'&lt;/code&gt;) problem, see:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;netrw-incompatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-02-17T15:38:32.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11462" PostTypeId="1" CreationDate="2017-02-17T17:48:02.817" Score="1" ViewCount="102" Body="&lt;p&gt;I recently started using &lt;code&gt;:set termguicolors&lt;/code&gt; which enables 24 bit colors. However, this (along with the rest of my config) causes vim to display absolutely no colors whenever it is started in a different way: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;as &lt;code&gt;vimdiff&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;spawned by git for editing commit messages&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;EDITOR=vim crontab -e&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and so on...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to look for a change in environment variables and vim state but I'm not sure what are the right ways to dump those out so I can diff them.  &lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2017-02-17T17:48:02.817" Title="when vim isnt run as just vim, getting no colors" Tags="|vimrc|terminal|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11463" PostTypeId="2" ParentId="11409" CreationDate="2017-02-17T23:23:29.313" Score="5" Body="&lt;p&gt;Your examples work fine for me on Vim 7.4.1689 and Neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following didn't work at first:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I read the following in &lt;code&gt;:h 'mouse'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Enable the use of the mouse.  &lt;strong&gt;Only works for certain terminals&#xA;  (xterm, MS-DOS, Win32 |win32-mouse|, QNX pterm, *BSD console with&#xA;  sysmouse and Linux console with gpm).&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I use tmux a lot, so &lt;code&gt;$TERM&lt;/code&gt; is set to &lt;code&gt;tmux-256color&lt;/code&gt;.  Since Vim doesn't see &lt;code&gt;xterm&lt;/code&gt; in the name, I get no mouse support.  With the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set term=xterm-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was able to scroll in the popup menu with the mouse wheel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found an old server to test Vim 7.4.52.  It exhibited the problem you mentioned about it inserting text instead of scrolling.  It turns out that the issue was with an old map that I had setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;nowait&amp;gt; &amp;lt;esc&amp;gt; &amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Removing this map caused the mouse wheel to work correctly in insert mode and I was able to scroll through completions.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I can't tell you the exact reason this causes a problem, but I can offer some speculation.  If you run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo strtrans(expand(&quot;\&amp;lt;ScrollWheelDown&amp;gt;&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might see something like &lt;code&gt;&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;K&lt;/code&gt;.  The first two bytes identifies &lt;code&gt;&amp;lt;ScrollWheelDown&amp;gt;&lt;/code&gt; as &lt;code&gt;K_SPECIAL&lt;/code&gt; (0x80) + &lt;code&gt;KS_EXTRA&lt;/code&gt; (0xfd) + &lt;code&gt;K&lt;/code&gt; (I assume is the scroll direction).  In Vim, these are defined in &lt;code&gt;keymap.h&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * K_SPECIAL is the first byte of a special key code and is always followed by&#xA; * two bytes.&#xA; * The second byte can have any value. ASCII is used for normal termcap&#xA; * entries, 0x80 and higher for special keys, see below.&#xA; * The third byte is guaranteed to be between 0x02 and 0x7f.&#xA; */&#xA;&#xA;#define K_SPECIAL       (0x80)&#xA;&#xA;...&#xA;&#xA;/*&#xA; * KS_EXTRA is used for keys that have no termcap name&#xA; *  K_SPECIAL   KS_EXTRA    KE_xxx&#xA; */&#xA;#define KS_EXTRA        253&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;K&lt;/code&gt; is Vim's &lt;em&gt;internal&lt;/em&gt; representation of &lt;code&gt;&amp;lt;ScrollWheelDown&amp;gt;&lt;/code&gt;.  Your terminal is sending the mouse interactions to Vim as a CSI (&lt;code&gt;\x1b[&lt;/code&gt;) code.  My guess is that Vim eats the &lt;code&gt;\x1b&lt;/code&gt; and translates it to the &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; map, breaking the mouse sequence and in turn, causing the remainder of the sequence to be queued as regular keyboard input.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2017-02-18T07:03:10.100" LastActivityDate="2017-02-18T07:03:10.100" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11464" PostTypeId="1" AcceptedAnswerId="11466" CreationDate="2017-02-18T11:37:51.817" Score="1" ViewCount="2202" Body="&lt;p&gt;There are a few commands to use folding (amongst all):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;za      When on a closed fold: open it. [...]&#xA;        When on an open fold: close it [...]&#xA;&#xA;zA      When on a closed fold: open it recursively.&#xA;        When on an open fold: close it recursively [...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However my &quot;ideal&quot; keystroke (which would be most commonly used), would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        When on a closed fold: open it recursively.&#xA;        When on an open fold: close it (only one, like in `za` command)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to define such a mapping?&lt;/p&gt;&#xA;" OwnerUserId="11416" LastActivityDate="2017-02-18T13:54:35.170" Title="Folding - open all, close one" Tags="|folding|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11465" PostTypeId="2" ParentId="11464" CreationDate="2017-02-18T12:40:18.260" Score="0" Body="&lt;p&gt;You don't need to create a mapping, just use the &lt;code&gt;zc/zC&lt;/code&gt; and &lt;code&gt;zo/zO&lt;/code&gt; commands. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;zc&lt;/code&gt; will close the fold at the current line, and &lt;code&gt;zC&lt;/code&gt; will close all of the folds at the  current line, while &lt;code&gt;zo&lt;/code&gt; and &lt;code&gt;zO&lt;/code&gt; will open one level and all levels of folds at the current line,  respectively. &lt;/p&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2017-02-18T12:40:18.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11466" PostTypeId="2" ParentId="11464" CreationDate="2017-02-18T13:54:35.170" Score="1" Body="&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;z foldclosed('.') != -1 ? 'zO' : 'zc'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h :map-&amp;lt;expr&amp;gt;&lt;/code&gt;.  On a fold, use &lt;code&gt;zO&lt;/code&gt; to open it recursively, otherwise use &lt;code&gt;zc&lt;/code&gt; to close one fold.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-02-18T13:54:35.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11468" PostTypeId="1" CreationDate="2017-02-18T16:10:04.733" Score="1" ViewCount="73" Body="&lt;p&gt;I'm using vim with &lt;a href=&quot;http://vim-latex.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-latex&lt;/a&gt; to edit my LaTeX-files. I noticed that the &lt;code&gt;\begin{env}&lt;/code&gt; and &lt;code&gt;\end{env}&lt;/code&gt; are not colorized when they are in a macro parameter (the &lt;code&gt;\vary&lt;/code&gt; command and &lt;code&gt;question&lt;/code&gt; environment are part of the &lt;a href=&quot;http://ctan.org/pkg/exsheets&quot; rel=&quot;nofollow noreferrer&quot;&gt;exsheets package&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\vary{&#xA;  \begin{question}&#xA;  \end{question}&#xA;}{&#xA;  \begin{question}&#xA;  \end{question}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've attached a sample picture:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/6SuZs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6SuZs.png&quot; alt=&quot;explanation of my problem&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do to colorize the &lt;code&gt;\begin{question}&lt;/code&gt; inside &lt;code&gt;\vary&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. I've asked it on &lt;a href=&quot;https://tex.stackexchange.com/questions/306042/vim-latexsuite-syntax-highlight-in-macro-parameter&quot;&gt;tex.stackexchange&lt;/a&gt; but no answer.&lt;/p&gt;&#xA;" OwnerUserId="11418" LastEditorUserId="-1" LastEditDate="2017-04-13T12:34:32.317" LastActivityDate="2017-02-20T07:52:45.457" Title="vim-latexsuite syntax highlight in macro parameter" Tags="|syntax-highlighting|filetype-tex|plugin-vim-latex|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11470" PostTypeId="1" CreationDate="2017-02-19T02:58:49.547" Score="0" ViewCount="789" Body="&lt;p&gt;Many commands need the &lt;code&gt;Leader&lt;/code&gt; key, but I can't found out what is that key on my keyboard. How could I test it out?&lt;/p&gt;&#xA;" OwnerDisplayName="user11345" LastActivityDate="2017-02-19T03:20:50.440" Title="Leader key for many commands" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ClosedDate="2017-02-19T08:46:05.190" ContentLicense="CC BY-SA 3.0" />
  <row Id="11471" PostTypeId="2" ParentId="11470" CreationDate="2017-02-19T03:20:50.440" Score="2" Body="&lt;p&gt;If you don't set one, the default leader is the backslash &lt;code&gt;\&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can set your leader with &lt;code&gt;:let mapleader = &quot;x&quot;&lt;/code&gt;, for example to make x your leader. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's handy to set this at the top of your .vimrc to whatever your desired leader is (I use space as mine). See &lt;code&gt;:h leader&lt;/code&gt; for more info and examples. &lt;/p&gt;&#xA;" OwnerUserId="2757" LastActivityDate="2017-02-19T03:20:50.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11472" PostTypeId="2" ParentId="3359" CreationDate="2017-02-19T07:12:47.197" Score="5" Body="&lt;p&gt;I had the same issue after reinstalling Vim: my old patched fonts were not compatible with the new airline symbols.&lt;/p&gt;&#xA;&lt;p&gt;The old symbols are also mentioned in the help (&lt;code&gt;:help airline-customization&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; old vim-powerline symbols&#xA;let g:airline_left_sep      = '⮀'&#xA;let g:airline_left_alt_sep  = '⮁'&#xA;let g:airline_right_sep     = '⮂'&#xA;let g:airline_right_alt_sep = '⮃'&#xA;let g:airline_symbols       = #{branch: '⭠', readonly: '⭤', linenr: '⭡'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After I put these lines in my vimrc everything went fine.&lt;/p&gt;&#xA;" OwnerUserId="8559" LastEditorUserId="51" LastEditDate="2022-09-23T20:08:25.723" LastActivityDate="2022-09-23T20:08:25.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11475" PostTypeId="1" AcceptedAnswerId="11491" CreationDate="2017-02-19T15:18:51.733" Score="3" ViewCount="1097" Body="&lt;p&gt;I use vim for many different categories of projects, typically:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Writing code (3 languages, python, Matlab and C)&lt;/li&gt;&#xA;&lt;li&gt;Writing documentation ( .rst, .html)&lt;/li&gt;&#xA;&lt;li&gt;Writing reports (.tex)&lt;/li&gt;&#xA;&lt;li&gt;Readme file (.md)&lt;/li&gt;&#xA;&lt;li&gt;As a plain text scratchpad (quick notes, meeting minutes etc.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;While I understand why many experts here recommend against relying solely on plugins and instead encourage to leverage vim's power for many tasks, a plugin-based workflow suits my style (and there exist many plugins which simplify the task at hand greatly). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: Can we enable a specific &lt;strong&gt;subset&lt;/strong&gt; of plugins for specific projects (akin to a python virtualenv setup). Some plugins are very generic (eg. an auto-close plugin for {},(),&amp;lt;&gt; pairs) and is helpful in all kind of projects. However, others are more project-specific (eg. vim-jedi plugin would be useless when writing regular prose; any writing plugin will be useless for code and such).  I think there is a way selectively enable on-demand/lazy loading for individual plugins. But my question goes beyond this basic case, since it is inconvenient to manually enable a handful plugins (say 3 or 4) one by one as required by a project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, is there a way to define &quot;plugin-groups&quot; (say, we call them 'writer-tools', or 'matlab-plugins') so that only the plugins belonging to that group are auto-loaded depending on the specific project type/category.  Furthermore, it is also desirable to have a manual override feature to either enable individual plugins from other plugin-groups or disable any one plugin from the currently loaded plugin-group, while in the midst of vim workflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does such a meta-plugin to manage group-based plugin autoload feature already exist? (or maybe someone has put together a solution using a bunch of autocmds in their vimrc) &lt;/p&gt;&#xA;" OwnerUserId="8408" LastActivityDate="2017-02-21T10:49:43.110" Title="Selectively enable a subset of vim plugins for specific category of workflows (plugin virtualenv for vim projects)" Tags="|autocmd|plugin-system|filetype|load|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11476" PostTypeId="1" AcceptedAnswerId="11480" CreationDate="2017-02-19T15:54:52.917" Score="8" ViewCount="3878" Body="&lt;p&gt;Consider the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;€   €&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This file is encoded in UTF-8 and between the two Euro marks is a Tab character (the Stack Exchange software expands this to spaces). The byte value is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;e2 82 ac 09 e2 82 ac 0a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my script I would like to get the character under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has several useful functions for dealing with strings in a multibyte-aware fashion, but getting the cursor position seems difficult:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;col('.')&lt;/code&gt; will return the byte position. So for the tab it will return &lt;code&gt;4&lt;/code&gt; rather than &lt;code&gt;2&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;virtcol('.')&lt;/code&gt; &lt;em&gt;almost&lt;/em&gt; works, but will expand tabs, so this isn't a true character position either.&lt;/li&gt;&#xA;&lt;li&gt;All other functions behave as one of the two above.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What I have so far is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Getchar()&#xA;    let l:line = substitute(getline('.'), '\t', repeat(' ', &amp;amp;tabstop), 'g')&#xA;    return strcharpart(l:line, virtcol('.') - 1, 1)&#xA;endfun&#xA;nnoremap GG :echo Getchar()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which &lt;em&gt;almost&lt;/em&gt; works, but not for the above example since the displayed width is less than &lt;code&gt;&amp;amp;tabstop&lt;/code&gt; spaces long.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2021-03-16T00:19:43.163" Title="How can I get the character at the cursor position in a multibyte aware manner?" Tags="|vimscript|unicode|cursor|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11477" PostTypeId="1" AcceptedAnswerId="11482" CreationDate="2017-02-19T16:00:00.660" Score="0" ViewCount="253" Body="&lt;p&gt;I'm trying to deconstruct a &lt;code&gt;.vimrc&lt;/code&gt; file to learn. I'm at a loss to determine what this does. Typing the &lt;code&gt;]&lt;/code&gt; and &lt;code&gt;_$&lt;/code&gt; mapped keys in visual mode doesn't seem to do anything useful. Maybe I'm missing something.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;silent&amp;gt;       ]   $&quot;yygv_$&#xA;vmap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; _$  Under_dollar_visual()&#xA;&#xA;function! Under_dollar_visual ()&#xA;    &quot; Locate block being shifted...&#xA;    let maxcol = max(map(split(@y, &quot;\n&quot;), 'strlen(v:val)')) + getpos(&quot;'&amp;lt;&quot;)[2] - 2&#xA;&#xA;    &quot; Return the selction that does the job...&#xA;    return maxcol . '|'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-02-19T22:41:36.557" Title="What does this vim script do?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11478" PostTypeId="1" AcceptedAnswerId="11479" CreationDate="2017-02-19T21:25:25.170" Score="0" ViewCount="150" Body="&lt;p&gt;I found this in my help files. What does it mean? Why is it there?  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\&quot;:ts=8:ft=help:norl:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8149" LastEditorUserId="205" LastEditDate="2017-02-20T03:20:27.567" LastActivityDate="2017-02-20T03:20:27.567" Title="Weird text in Vim help files" Tags="|vim-windows|help-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11479" PostTypeId="2" ParentId="11478" CreationDate="2017-02-19T21:48:56.380" Score="2" Body="&lt;p&gt;That's a &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#modeline&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;modeline&quot;&lt;/a&gt;, a feature of Vim. If it encounters such a line in the first or last 2 lines of a file, Vim reads settings from it and applies them to the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: Forcing a file with extension &lt;code&gt;.rdf&lt;/code&gt; to be handled as file type &lt;code&gt;xml&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!--&#xA;vim: ft=xml&#xA;--&amp;gt;&#xA;&amp;lt;!-- rest of file --&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8149" LastActivityDate="2017-02-19T21:48:56.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11480" PostTypeId="2" ParentId="11476" CreationDate="2017-02-19T22:07:49.553" Score="8" Body="&lt;p&gt;We discussed it less then 10 days ago &lt;a href=&quot;https://www.reddit.com/r/vim/comments/5t08uo/vimscript_unicode/&quot; rel=&quot;noreferrer&quot;&gt;on reddit&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution is &lt;code&gt;matchstr(getline('.'), '\%'.col('.').'c.')&lt;/code&gt; which doesn't mess with any register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've put the &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/encoding.vim#L116&quot; rel=&quot;noreferrer&quot;&gt;resulting functions&lt;/a&gt; (we can ask for the characters before, or after the cursor) in my vimscript library along with other functions on the subject.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-02-19T22:07:49.553" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11481" PostTypeId="2" ParentId="11475" CreationDate="2017-02-19T22:13:21.463" Score="4" Body="&lt;p&gt;The exact same question had been asked recently on &lt;a href=&quot;https://www.reddit.com/r/vim/comments/5sdrrc/how_can_i_start_vim_with_different_vimrc_and/&quot; rel=&quot;nofollow noreferrer&quot;&gt;reddit&lt;/a&gt;. I copy-paste here my answer. I also recommend you read @romainl's answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the plugins you're using are correctly designed, you should not need to do anything specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since Vim 6 (yeah, 2 versions ago), we have ftplugins, for filetype-plugins. The idea is to load the C ftplugins on the fly when you're editing C files, go ftplugins when you're editing go files, and so on. Even better, we can work on C files and on go files simultaneously without improper interferences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;May be you don't want to load a generic (non-ft) plugin in some contexts. But once again, if the plugin is correctly designed (i.e. made of autoload plugins (that appeared in Vim 7)) starting times should not be a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMO, we don't need on-demand plugin loading based on filetype. Vim has been supporting this natively since 2001. Of course, ftplugins could be incorrectly written, this is another issue.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-02-21T10:49:43.110" LastActivityDate="2017-02-21T10:49:43.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11482" PostTypeId="2" ParentId="11477" CreationDate="2017-02-19T22:41:36.557" Score="1" Body="&lt;pre&gt;&lt;code&gt;vmap &amp;lt;silent&amp;gt;       ]   $&quot;yygv_$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This selects to the end of the line (&lt;code&gt;$&lt;/code&gt;), copies everything to the &lt;code&gt;@y&lt;/code&gt; register (&lt;code&gt;&quot;yy&lt;/code&gt;), visually selects the block (&lt;code&gt;gv&lt;/code&gt;) and then calls &lt;code&gt;_$&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; _$  Under_dollar_visual()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; means that the result of the expression is evaluated (see &lt;code&gt;help map-expression&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;Under_dollar_visual&lt;/code&gt;, &lt;code&gt;maxcol&lt;/code&gt; is set to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let maxcol = max(map(split(@y, &quot;\n&quot;), 'strlen(v:val)')) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the longest line of the text in the &lt;code&gt;@y&lt;/code&gt; register that was just copied&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+ getpos(&quot;'&amp;lt;&quot;)[2] - 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;plus the start column of the block minus two (without the last character).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return maxcol . '|'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally it returns the keys that will be evaluated by vim (&lt;code&gt;|&lt;/code&gt; = To screen column [count]).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example if you select a visual-block (indicated by X)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaaXXXyyy&#xA;aaaXXXyyyy&#xA;aaaXXXyyyyy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and press &lt;code&gt;]&lt;/code&gt;, you'll get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaaXXXXXX&#xA;aaaXXXXXXX&#xA;aaaXXXXXXXy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(if the cursor was on the last line) which is the same as if you had typed &lt;code&gt;10|&lt;/code&gt; with the initial selection.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-02-19T22:41:36.557" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11483" PostTypeId="1" AcceptedAnswerId="11524" CreationDate="2017-02-20T01:47:40.063" Score="1" ViewCount="2503" Body="&lt;p&gt;If I open a random file (in this case, say &lt;code&gt;.zshrc&lt;/code&gt;) in a blank vim with no rc file , but with vi compatibility forcing off&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -N -u NORC ~/.zshrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As expected vim will launch and display &lt;code&gt;.zshrc&lt;/code&gt; without syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;attempt to enable syntax highlighting&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I have a file containing a collection of &lt;code&gt;highlight&lt;/code&gt; commands called &lt;code&gt;darcula.vim&lt;/code&gt; in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/colors/darcula.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;contents of &lt;code&gt;~/.vim/colors/darcula.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&#xA;&quot; Darcula colorscheme for VIM.&#xA;&quot;&#xA;&#xA;set background=dark&#xA;highlight clear&#xA;&#xA;if exists(&quot;syntax_on&quot;)&#xA;  syntax reset&#xA;endif&#xA;&#xA;let g:colors_name = &quot;darcula&quot;&#xA;&#xA;hi Cursor ctermfg=188 ctermbg=250 cterm=NONE guifg=#2b2b2b guibg=#a9b7c6 gui=NONE&#xA;hi Visual ctermfg=NONE ctermbg=24 cterm=NONE guifg=NONE guibg=#214283 gui=NONE&#xA;hi CursorLine ctermfg=NONE ctermbg=236 cterm=NONE guifg=NONE guibg=#323232 gui=NONE&#xA;hi CursorColumn ctermfg=NONE ctermbg=236 cterm=NONE guifg=NONE guibg=#313335 gui=NONE&#xA;&#xA;[ ... plus many more highlight commands ...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;at vims command line I enter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:colorscheme darcula&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then, to check if the highlight commands have been loaded, I run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and yes vim is showing all the &lt;code&gt;hi&lt;/code&gt; commands from the above &lt;code&gt;darcula.vim&lt;/code&gt; file have been loaded.&lt;br&gt;&#xA;Then I run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax enable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and nothing happens&lt;/p&gt;&#xA;&#xA;&lt;p&gt;from reading &lt;code&gt;:h syntax-loading&lt;/code&gt; I thought the syntax enable command sets up filetype autocmd recognition, as verified with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype&#xA;filetype detection:ON  plugin:OFF  indent:OFF &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and also sets up autocommand which will run the vim function &lt;code&gt;SynSet()&lt;/code&gt; on the autocommand event &lt;code&gt;Syntax&lt;/code&gt;, from the file &lt;code&gt;$VIMRUNTIME/syntax/synload.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[...]&#xA;au Syntax *     call s:SynSet()&#xA;&#xA;fun! s:SynSet()&#xA;  &quot; clear syntax for :set syntax=OFF  and any syntax name that doesn't exist&#xA;  syn clear&#xA;  if exists(&quot;b:current_syntax&quot;)&#xA;    unlet b:current_syntax&#xA;  endif&#xA;&#xA;  let s = expand(&quot;&amp;lt;amatch&amp;gt;&quot;)&#xA;  if s == &quot;ON&quot;&#xA;    &quot; :set syntax=ON&#xA;    if &amp;amp;filetype == &quot;&quot;&#xA;      echohl ErrorMsg&#xA;      echo &quot;filetype unknown&quot;&#xA;      echohl None&#xA;    endif&#xA;    let s = &amp;amp;filetype&#xA;  elseif s == &quot;OFF&quot;&#xA;    let s = &quot;&quot;&#xA;  endif&#xA;&#xA;  if s != &quot;&quot;&#xA;    &quot; Load the syntax file(s).  When there are several, separated by dots,&#xA;    &quot; load each in sequence.&#xA;    for name in split(s, '\.')&#xA;      exe &quot;runtime! syntax/&quot; . name . &quot;.vim syntax/&quot; . name . &quot;/*.vim&quot;&#xA;    endfor&#xA;  endif&#xA;endfun&#xA;&#xA;[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which looks like it will use the filetype and run the appropriate syntax file.  &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;terminal&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I'm running vim inside tmux and its not detecting my terminal properly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set t_Co?&#xA;  t_Co=8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I set it to 256 color like it should be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To me this looks like Ive covered everything, but I obviously havent, why isn't syntax highlighting happening here? &lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="51" LastEditDate="2017-02-23T19:28:30.583" LastActivityDate="2017-02-23T20:21:30.843" Title="Why isn't vim applying syntax highlighting to this code?" Tags="|syntax-highlighting|terminal|tmux|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11484" PostTypeId="1" CreationDate="2017-02-20T01:58:27.177" Score="3" ViewCount="5532" Body="&lt;p&gt;I have gvim installed as well as vim. I want gvim and vim to share the same config file. How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="11354" LastEditorUserId="51" LastEditDate="2017-02-20T04:51:54.840" LastActivityDate="2018-12-09T00:48:49.860" Title="Sharing the config file for vim and gvim" Tags="|vimrc|gvim|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11485" PostTypeId="2" ParentId="11483" CreationDate="2017-02-20T02:12:28.550" Score="1" Body="&lt;p&gt;It turns out it was the tmux terminal detection - obviously beingis fundamental to everything else it seems the terminal state needs to be set right at launch, so launching with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -N -u NORC -c &quot;set t_Co=256&quot; ~/.zshrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;fixed the problem and the above steps did succeed in getting highlighting to work&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2017-02-20T02:12:28.550" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11487" PostTypeId="1" AcceptedAnswerId="11488" CreationDate="2017-02-20T04:59:59.617" Score="8" ViewCount="31606" Body="&lt;p&gt;I merely want to change a font in Vim/GVim. That's it. This doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;font=Monaco\ 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've done a google search and I wonder, why is for such a elementary task there's no simple answer which works, instead I've found a lot of ambiguous, complex solutions. And none of them worked.  How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="11354" LastEditorUserId="11354" LastEditDate="2017-02-20T05:24:37.783" LastActivityDate="2022-10-23T18:44:00.797" Title="Change a font in Vim/GVim in a simple way" Tags="|gvim|linux|font|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11488" PostTypeId="2" ParentId="11487" CreationDate="2017-02-20T05:15:15.043" Score="7" Body="&lt;p&gt;Reading the &lt;code&gt;'guifont'&lt;/code&gt; option is useful here. I do understand your frustrations with this option however. It seems that how you set the &lt;code&gt;'guifont'&lt;/code&gt; setting, is dependent on the OS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On macOS, you set 'guifont' the following way (which is noted in &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27guifont%27&quot; rel=&quot;noreferrer&quot;&gt;:help 'guifont'&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Monaco:h14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On other OSes (Linux, etc) you use the backslash instead to specify the font size:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Monaco\ 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another useful way to set the font is to use &lt;code&gt;:set guifont=*&lt;/code&gt; which will bring up the Font chooser for your OS. Selecting a font then will apply it for your Gvim instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why this distinction between the &quot;\&quot; and &quot;:&quot; to set the font size exists, however, is a separate question which I would like to know as well.&lt;/p&gt;&#xA;" OwnerUserId="246" LastActivityDate="2017-02-20T05:15:15.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11491" PostTypeId="2" ParentId="11475" CreationDate="2017-02-21T00:47:04.037" Score="4" Body="&lt;p&gt;The plugin manager &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt; supports this to some extent using a &lt;code&gt;for&lt;/code&gt; attribute for plugins. For example, here's part of my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin()&#xA;&quot; Common plugins&#xA;Plug 'vim-scripts/diffchar.vim'&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'ervandew/supertab'&#xA;Plug 'scrooloose/syntastic'&#xA;&quot;...&#xA;Plug 'ctrlpvim/ctrlp.vim'&#xA;Plug 'gabrielelana/vim-markdown', {'for': 'markdown'}&#xA;Plug 'majutsushi/tagbar', {'for': ['cpp', 'c', 'go', 'sh', 'javascript']}&#xA;Plug 'godlygeek/tabular'&#xA;&#xA;if executable('cmake')&#xA;        &quot; YCM command lifted from vim-plug readme&#xA;        Plug 'Valloric/YouCompleteMe', { 'do': YCMInstallCmd(), 'for': ['cpp', 'c', 'sh', 'javascript', 'vim', 'tex'] }&#xA;        autocmd! User YouCompleteMe if !has('vim_starting') | call youcompleteme#Enable() | endif&#xA;endif&#xA;if executable('go')&#xA;        Plug 'fatih/vim-go', {'for': 'go'}&#xA;        Plug 'Shougo/neocomplete.vim', {'for': 'go'}&#xA;        Plug 'Shougo/vimproc.vim', {'do': 'make'}&#xA;        Plug 'Shougo/echodoc.vim'&#xA;endif&#xA;if executable('latex')&#xA;        Plug 'lervag/vimtex', {'for': 'tex'}&#xA;endif&#xA;if executable('ghc')&#xA;        Plug 'dag/vim2hs', {'for': 'hs'}&#xA;endif&#xA;&quot;...&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I have a bunch of plugins loaded for everything, and then the 800lb YouCompleteMe which is only loaded for specific file types, and so on. I think vim-plug only supports filetypes with &lt;code&gt;for&lt;/code&gt;, however, so you can't do anything really complex like virtualenvs.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-02-21T00:47:04.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11492" PostTypeId="2" ParentId="2350" CreationDate="2017-02-21T05:12:42.867" Score="3" Body="&lt;p&gt;This works for me on Ubuntu 16.04 xfce terminal (and alacritty rust terminal)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set ultisnip snippet trigger to &lt;code&gt;Meta-/&lt;/code&gt; (just like emacs snippet)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsExpandTrigger=&quot;^[/&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's now I type &lt;code&gt;^[/&lt;/code&gt; in vim &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In insert mode &lt;code&gt;Ctrl-V Alt-/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;Meta&lt;/code&gt; is the &lt;code&gt;Alt&lt;/code&gt; key on my PC keyboard)&lt;/p&gt;&#xA;" OwnerUserId="11464" LastEditorUserId="205" LastEditDate="2017-02-21T05:28:47.527" LastActivityDate="2017-02-21T05:28:47.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11493" PostTypeId="1" CreationDate="2017-02-21T11:03:51.893" Score="1" ViewCount="1792" Body="&lt;p&gt;I would like to replace all floating point numbers within given block with white spaces so that the number of the latter corresponds to the  &quot;length&quot; of the floating point number. For instance, I want to change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$S_{1}$ &amp;amp;  2.3  &amp;amp; 3.14159 &amp;amp;  2.73 &amp;amp; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$S_{1}$ &amp;amp;       &amp;amp;         &amp;amp;       &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I go into block mode with &lt;code&gt;CTRL+v&lt;/code&gt; and enter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;s/[0-9]\{1,}\.[0-9]\{1,}/????&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and what should I provide in place of &lt;code&gt;????&lt;/code&gt; so that the number of white spaces fits the number of digits and decimal separator of my number, please?&lt;/p&gt;&#xA;" OwnerUserId="11472" LastActivityDate="2017-03-23T12:35:29.603" Title="Replace numbers with white spaces" Tags="|regular-expression|replace|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11495" PostTypeId="2" ParentId="11493" CreationDate="2017-02-21T11:35:27.840" Score="2" Body="&lt;p&gt;You'll probably have to do a double substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\v\d+\.\d+/\=substitute(submatch(0),'.',' ','g')/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses an expression for the replacement (&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h sub-replace-expression&lt;/code&gt;&lt;/a&gt;), which simply replaces every character in the matched string (&lt;code&gt;submatch(0)&lt;/code&gt;) with a space (&lt;code&gt;subtitute(..., '.', ' ', 'g')&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, repeat &lt;code&gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\v\d+\.\d+/\=repeat(' ', len(submatch(0)))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Perhaps simplest of all would be to use visual selection based on searching. First, search for &lt;code&gt;/\v\d+\.\d+&lt;/code&gt; to get the floating point numbers, then press &lt;code&gt;gn&lt;/code&gt; to visual select the next matching one. Then do &lt;code&gt;r &lt;/code&gt; (&lt;code&gt;r&lt;/code&gt;, then space) to replace all the selected characters with spaces. Use as a macro.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2017-02-21T11:42:31.887" LastActivityDate="2017-02-21T11:42:31.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11496" PostTypeId="1" CreationDate="2017-02-21T12:43:06.327" Score="3" ViewCount="214" Body="&lt;p&gt;While writing code it often happens that adding one parenthesis leaves another one orphaned somewhere. Many syntax color scheme color the parenthesis differently to signal it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, while writing LaTeX code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$\mathbb{E} something }$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the second } will be marked in red in my vim. If I want to remove it I would have to do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f}x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;assuming my cursor is located past the first }, otherwise I need to do some repositiong to reach it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the syntax highlights picks up on it, is there a way to bind a command to something like 'go to the next unmatched parens and delete it'? Bonus point if the cursor is left in its place and left in normal mode.&lt;/p&gt;&#xA;" OwnerUserId="6854" LastActivityDate="2017-02-23T18:51:03.850" Title="Shortcut to remove orphaned parenthesis" Tags="|key-bindings|syntax-highlighting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11497" PostTypeId="1" AcceptedAnswerId="11501" CreationDate="2017-02-21T14:44:35.467" Score="0" ViewCount="90" Body="&lt;p&gt;Is it legal to do &lt;code&gt;:r!vi&lt;/code&gt; in vi?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A friend asked me to try it and it jammed my terminal. What exactly causes this? Is there anyway to recover the terminal without closing it and opening a new one?&lt;/p&gt;&#xA;" OwnerUserId="11475" LastEditorUserId="2920" LastEditDate="2017-02-22T17:35:23.833" LastActivityDate="2017-02-22T17:35:23.833" Title="Why does :r!vi jam my terminal?" Tags="|external-command|terminal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11498" PostTypeId="1" AcceptedAnswerId="11500" CreationDate="2017-02-21T14:59:15.157" Score="1" ViewCount="1169" Body="&lt;p&gt;Which characters in a vimscript command are invalid?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there are blacklist or a whitelist of characters?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I've only come up with these characters that trigger the error&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Invalid command name&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;_&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="8558" LastActivityDate="2017-02-21T15:28:23.223" Title="Invalid characters in command" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11499" PostTypeId="2" ParentId="11484" CreationDate="2017-02-21T15:22:07.193" Score="6" Body="&lt;p&gt;Vim reads &lt;code&gt;~/.vimrc&lt;/code&gt;; gvim reads &lt;code&gt;~/.gvimrc&lt;/code&gt; as well as &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So simply put your commands into &lt;code&gt;~/.vimrc&lt;/code&gt; (and put the GUI-specific commands into &lt;code&gt;~/.gvimrc&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Newer Vims also look at &lt;code&gt;~/.vim/vimrc&lt;/code&gt; and &lt;code&gt;~/.vim/gvimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="205" LastEditDate="2017-02-22T01:09:08.257" LastActivityDate="2017-02-22T01:09:08.257" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11500" PostTypeId="2" ParentId="11498" CreationDate="2017-02-21T15:28:23.223" Score="6" Body="&lt;p&gt;See &lt;code&gt;:help user-commands&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;All user defined commands must start with an uppercase letter, to avoid&#xA;  confusion with builtin commands.  Exceptions are these builtin commands:&#xA;          :Next&#xA;          :X&#xA;  They cannot be used for a user defined command.  &quot;:Print&quot; is also an existing&#xA;  command, but it is deprecated and can be overruled.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The other characters of the user command can be uppercase letters, lowercase&#xA;  letters or digits.  When using digits, note that other commands that take a&#xA;  numeric argument may become ambiguous.  For example, the command &quot;:Cc2&quot; could&#xA;  be the user command &quot;:Cc2&quot; without an argument, or the command &quot;:Cc&quot; with&#xA;  argument &quot;2&quot;.  It is advised to put a space between the command name and the&#xA;  argument to avoid these problems.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When using a user-defined command, the command can be abbreviated.  However, if&#xA;  an abbreviation is not unique, an error will be issued.  Furthermore, a&#xA;  built-in command will always take precedence.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-02-21T15:28:23.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11501" PostTypeId="2" ParentId="11497" CreationDate="2017-02-21T21:41:05.750" Score="4" Body="&lt;p&gt;If you're looking for &lt;em&gt;why&lt;/em&gt; it jams your terminal it's because &lt;code&gt;:r!&lt;/code&gt; reads a command from your terminal and inserts it into the buffer. Since it's trying to insert the output of the &lt;code&gt;vi&lt;/code&gt; command, it's waiting for &lt;code&gt;vi&lt;/code&gt; to finish. But all it does is open another instance of vi, which never returns.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it legal?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Technically, yes. &lt;code&gt;:r!&lt;/code&gt; takes a valid shell command and &lt;code&gt;vi&lt;/code&gt; is a valid shell command. It's just not advised because of the aforementioned behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#%3Ar%21&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :r!&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-02-21T21:41:05.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11502" PostTypeId="1" AcceptedAnswerId="11505" CreationDate="2017-02-21T22:27:09.950" Score="1" ViewCount="268" Body="&lt;p&gt;When executing &lt;code&gt;:Gblame&lt;/code&gt;, it opens up a window for the blame information.  When close that window with &lt;code&gt;q&lt;/code&gt;, I want to execute &lt;code&gt;wincmd =&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried the following, they don't seem to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufLeave fugitiveblame wincmd =&#xA;autocmd BufLeave *.fugitiveblame wincmd =&#xA;autocmd WinLeave fugitiveblame wincmd =&#xA;autocmd WinLeave *.fugitiveblame wincmd =&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is also an issue with the &lt;code&gt;ctrlsf&lt;/code&gt; plugin.  I would like to do the same thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I guess what I'm after is the ability to re-equalize the window sizes after closing the blame or ctrlsf windows.&lt;/p&gt;&#xA;" OwnerUserId="11484" LastEditorUserId="51" LastEditDate="2017-02-22T07:18:54.133" LastActivityDate="2017-02-22T08:31:05.487" Title="How to execute a command when leaving the 'fugitiveblame' window?" Tags="|autocmd|plugin-fugitive|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11503" PostTypeId="1" AcceptedAnswerId="11504" CreationDate="2017-02-22T05:43:55.130" Score="0" ViewCount="346" Body="&lt;p&gt;This highlights the parts of the lines that are over 80 columns long:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup over_length&#xA;    autocmd!&#xA;    autocmd BufEnter * highlight OverLength ctermbg=darkgrey&#xA;    autocmd BufEnter * match OverLength /\%80v.*/&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I would like to modify it to use &lt;code&gt;&amp;amp;textwidth&lt;/code&gt;. Using &lt;code&gt;/\%.&amp;amp;textwidth.v.*/&lt;/code&gt; doesn't seem to work. Is there a way to substitute the value into the regular expression?&lt;/p&gt;&#xA;" OwnerDisplayName="user8048" LastActivityDate="2017-02-22T07:32:43.030" Title="Substitute variable into match" Tags="|regular-expression|variables|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11504" PostTypeId="2" ParentId="11503" CreationDate="2017-02-22T07:32:43.030" Score="2" Body="&lt;p&gt;Yes, you have to use execute and put it in a string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'match OverLength /\%'. &amp;amp;textwidth .'v.*/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11316" LastActivityDate="2017-02-22T07:32:43.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11505" PostTypeId="2" ParentId="11502" CreationDate="2017-02-22T08:31:05.487" Score="2" Body="&lt;p&gt;Maybe not exactly as requested, but it seems to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType fugitiveblame nnoremap &amp;lt;buffer&amp;gt; q :q&amp;lt;CR&amp;gt;wincmd =&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this will work only if you close Gblame buffer with &lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-02-22T08:31:05.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11506" PostTypeId="2" ParentId="376" CreationDate="2017-02-22T13:44:43.970" Score="6" Body="&lt;p&gt;I found a way to turn off caps lock in normal mode automatically (though it works only in Linux).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solutions that were made with plugins do not take into account that you can enter normal mode in more then one way (that is from insert to normal), for example from command mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is actually no autocommand event that activates upon entering normal mode, so the event I used instead was &lt;code&gt;CursorHold&lt;/code&gt; event, which activates when you're not typing in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au CursorHold * call TurnOffCaps()&#xA;set updatetime=10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You set the update time to a very small number, so it will always activate, before you have a chance to type anything.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function TurnOffCaps()  &#xA;    let capsState = matchstr(system('xset -q'), '00: Caps Lock:\s\+\zs\(on\|off\)\ze')&#xA;    if capsState == 'on'&#xA;        silent! execute ':!xdotool key Caps_Lock'&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11493" LastEditorUserId="19192" LastEditDate="2018-10-01T07:52:43.307" LastActivityDate="2018-10-01T07:52:43.307" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11507" PostTypeId="1" AcceptedAnswerId="11508" CreationDate="2017-02-22T15:21:35.897" Score="1" ViewCount="344" Body="&lt;p&gt;I'd like to pass through a text an replace &lt;code&gt;word1&lt;/code&gt; by &lt;code&gt;word2&lt;/code&gt;. However, I don't want to execute this task in one pass, but rather word by word. I know I could put the cursor on the word I want, execute &lt;code&gt;*&lt;/code&gt;, then &lt;code&gt;vw&lt;/code&gt; and finally &lt;code&gt;r words&lt;/code&gt;. The problem is located on this last step. If I want to look for the next &lt;code&gt;words&lt;/code&gt;, I can't with &lt;code&gt;*&lt;/code&gt;, because I'd replace &lt;code&gt;word1&lt;/code&gt; by &lt;code&gt;word2&lt;/code&gt;. Could anyone be able to help me at this point?&lt;/p&gt;&#xA;" OwnerDisplayName="user11452" LastEditorDisplayName="user11452" LastEditDate="2017-02-22T16:21:39.797" LastActivityDate="2017-02-23T17:19:52.907" Title="Pass word one-by-one and replace (Search and replace with confirmation)" Tags="|command-line|search|replace|" AnswerCount="1" CommentCount="2" ClosedDate="2017-02-23T17:21:00.493" ContentLicense="CC BY-SA 3.0" />
  <row Id="11508" PostTypeId="2" ParentId="11507" CreationDate="2017-02-22T15:39:50.013" Score="8" Body="&lt;p&gt;I think you're looking for the substitute command with confirmation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/word1/word2/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will substitute &lt;code&gt;word2&lt;/code&gt; for &lt;code&gt;word1&lt;/code&gt;, but every time it will take you to the match and let you decide what to do. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;g&lt;/code&gt; means global. It will find all matches on the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;c&lt;/code&gt; is for confirm. It applies the behavior described above.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Asubstitute&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :substitute&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3As_c&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :s_c&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-02-22T15:56:09.800" LastActivityDate="2017-02-22T15:56:09.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11509" PostTypeId="2" ParentId="10239" CreationDate="2017-02-22T16:23:34.893" Score="1" Body="&lt;p&gt;Unless you're using a non-properly configured version of gnumake (Solaris OS, or mingw distribution of gcc under windows), you don't need to modify &lt;code&gt;&amp;amp;makeprg&lt;/code&gt;. Its default value is already perfect for GNU compilation tools.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you need to do is to set &lt;code&gt;$CFLAGS&lt;/code&gt; with &lt;code&gt;:let $CFLAGS=&quot;-g -Wall&quot;&lt;/code&gt;, and compile with &lt;code&gt;:make %&amp;lt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-02-22T17:36:26.347" LastActivityDate="2017-02-22T17:36:26.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11510" PostTypeId="1" AcceptedAnswerId="11536" CreationDate="2017-02-22T19:56:23.647" Score="2" ViewCount="2306" Body="&lt;p&gt;I'm familiar with iskeyword to define word boundaries. But there's also WORD and I don't know what the setting is for that. My goal is this: to delete words in a comma-seperate list flexibly. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apple, banana, carrot, orange.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I place my cursor at carrot and type &lt;code&gt;daw&lt;/code&gt;, I expect it to remove &lt;code&gt;carrot,•&lt;/code&gt; (space represented by the &lt;code&gt;•&lt;/code&gt; symbol). If I type &lt;code&gt;diw&lt;/code&gt; instead, I expect it to remove just &lt;code&gt;carrot&lt;/code&gt;. Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently have &lt;code&gt;set iskeyword-=,&lt;/code&gt; but that makes both commands do the same thing, except one doesn't delete a space.&lt;/p&gt;&#xA;" OwnerUserId="10905" LastActivityDate="2017-02-24T22:55:33.873" Title="How to define word/WORD boundaries?" Tags="|vimrc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11512" PostTypeId="1" AcceptedAnswerId="11514" CreationDate="2017-02-22T22:24:28.327" Score="7" ViewCount="773" Body="&lt;p&gt;I'm familiar with &lt;code&gt;ngT&lt;/code&gt;, which will move n tabs backward. Is there an equivalent way to move forward? I know that if I have 5 tabs open and I'm on tab 3, I can use &lt;code&gt;3gT&lt;/code&gt; to move backwards to tab 5. However, this quickly becomes unwieldy as the number of tabs increases and I lose track of the exact number I'm on at a given time.&lt;/p&gt;&#xA;" OwnerUserId="6883" LastActivityDate="2017-02-22T22:49:12.817" Title="Is there a way to move n tabs forward?" Tags="|tabbed-user-interface|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11513" PostTypeId="1" CreationDate="2017-02-22T22:36:46.720" Score="1" ViewCount="87" Body="&lt;p&gt;If I do &lt;code&gt;:Perldoc version&lt;/code&gt; for documents longer than one page, I see output like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ESC[1mNAMEESC[0m&#xA;version - Perl extension for Version Objects&#xA;&#xA;ESC[1mSYNOPSISESC[0m&#xA;  # Parsing version strings (decimal or dotted-decimal)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the distracting &quot;ESC&quot; and other weird characters in there that make it difficult to read the headings. For shorter documents that fit in one page, everything looks fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any good way of fixing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is used in my .vimrc to look up the perldoc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set keywordprg=pd&#xA;&#xA;function! CallPerldoc ()&#xA;    &quot; When editing Vim files, revert to :help...&#xA;    if &amp;amp;filetype == 'vim' || &amp;amp;buftype == 'help'&#xA;        return &quot;:help &quot;&#xA;&#xA;    &quot; Otherwise use Perldoc...&#xA;    else &#xA;        let target = matchstr(expand('&amp;lt;cfile&amp;gt;'), '\w\+\(::\w\+\)*')&#xA;        set wildmode=list:full&#xA;        return &quot;:Perldoc &quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot;Complete perldoc requests with names of installed Perl modules&#xA;command! -nargs=? -complete=customlist,CompletePerlModuleNames Perldoc  call Perldoc_impl(&amp;lt;q-args&amp;gt;)&#xA;&quot;    &#xA;&quot;Undo the special wildmoding and then execute the requested perdoc lookup...&#xA;function! Perldoc_impl (args)&#xA;    set wildmode=list:longest,full&#xA;    if empty(a:args)&#xA;        exec '!pd %'&#xA;    else&#xA;        exec '!pd ' . a:args&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot; Compile the list of installed Perl modules (and include the name under the cursor)...&#xA;let s:module_files = readfile($HOME.'/.vim/perlmodules')&#xA;function! CompletePerlModuleNames(prefix, cmdline, curpos)&#xA;    let cfile = expand('&amp;lt;cfile&amp;gt;')&#xA;    let prefix = a:prefix&#xA;    if prefix == cfile&#xA;        let prefix = &quot;&quot;&#xA;    endif&#xA;    if empty(prefix) &amp;amp;&amp;amp; cfile =~ '^\w\+\(::\w\+\)*$'&#xA;        return [cfile] + filter(copy(s:module_files), 'v:val =~ ''\c\_^' . prefix. &quot;'&quot;)&#xA;    else&#xA;        return filter(copy(s:module_files), 'v:val =~ ''\c\_^' . prefix. &quot;'&quot;)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="51" LastEditDate="2017-02-23T18:17:48.487" LastActivityDate="2017-02-23T18:17:48.487" Title="Get rid of meta characters in vim's perldoc viewer" Tags="|vimscript|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11514" PostTypeId="2" ParentId="11512" CreationDate="2017-02-22T22:49:12.817" Score="7" Body="&lt;p&gt;As far as I'm aware, there is no default way to do this. I looked into the ex command &lt;code&gt;tabnext&lt;/code&gt;, which accepts a count, but functions exactly the same as &lt;code&gt;gt&lt;/code&gt; (that is, it moves to tab page {count}, not {count} pages forward):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabn[ext] {count}&#xA;{count}&amp;lt;C-PageDown&amp;gt;&#xA;{count}gt   Go to tab page {count}.  The first tab page has number one.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this isn't very hard to configure! This vimscript mapping does what you're looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;gt :&amp;lt;C-u&amp;gt;exec 'normal '.repeat(&quot;gt&quot;, v:count1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This literally just simulates pressing &lt;code&gt;gt&lt;/code&gt; over and over as many times as you need. With no count given, it will default to 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I picked &lt;code&gt;&amp;lt;leader&amp;gt;gt&lt;/code&gt; somewhat arbitrarily. Of course, you can remap this to whatever is easiest or most convenient for you, whether it's a separate binding, or you choose to override the default &lt;code&gt;gt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-02-22T22:49:12.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11516" PostTypeId="2" ParentId="10924" CreationDate="2017-02-23T03:22:16.050" Score="1" Body="&lt;p&gt;I had a similar problem with the same KeyError (although I don't know the exact error because I was not able to get the full traceback that you did)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I managed to fix it by adding the zesty repo and installing a newer version of youcompleteme&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# add zesty repo&#xA;echo deb http://archive.ubuntu.com/ubuntu/ zesty main restricted universe multiverse | sudo tee /etc/apt/sources.list.d/zesty.list&#xA;sudo apt update&#xA;&#xA;# update only vim-youcompleteme&#xA;sudo apt install -y vim-youcompleteme&#xA;&#xA;# remove new repository so there aren't 1000+ packages to upgrade&#xA;sudo rm /etc/apt/sources.list.d/zesty.list&#xA;sudo apt update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11502" LastEditorUserId="11502" LastEditDate="2017-02-24T00:12:33.150" LastActivityDate="2017-02-24T00:12:33.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11517" PostTypeId="2" ParentId="9672" CreationDate="2017-02-23T06:00:01.527" Score="5" Body="&lt;h1&gt;See &lt;a href=&quot;https://github.com/alvan/vim-closetag&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;vim-closetag&lt;/code&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;It's exactly what you're looking for. From it's README:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If this is the current content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;table|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Now you press &lt;kbd&gt;&gt;&lt;/kbd&gt;, the content will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;table&amp;gt;|&amp;lt;/table&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;And now if you press &lt;kbd&gt;&gt;&lt;/kbd&gt; again, the content will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;table&amp;gt;&#xA;   |&#xA;&amp;lt;/table&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: &lt;code&gt;|&lt;/code&gt; is the cursor here&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="969" LastActivityDate="2017-02-23T06:00:01.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11518" PostTypeId="2" ParentId="11484" CreationDate="2017-02-23T10:27:30.133" Score="5" Body="&lt;p&gt;You can also use something along the following lines in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('gui')&#xA;    set foo=bar&#xA;    ...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11507" LastActivityDate="2017-02-23T10:27:30.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11519" PostTypeId="2" ParentId="11457" CreationDate="2017-02-23T10:37:01.827" Score="3" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: notice after posting there's already this answer in the comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run &lt;code&gt;vim&lt;/code&gt; in binary mode as &lt;code&gt;vim -b asterix&lt;/code&gt;. I think the problem has something to do with conversions caused by &lt;code&gt;encoding&lt;/code&gt;/&lt;code&gt;fileencoding&lt;/code&gt; settings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your file is already loaded, you can switch to binary mode without leaving vim. Save the file, then do &lt;code&gt;:e ++bin&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11507" LastActivityDate="2017-02-23T10:37:01.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11520" PostTypeId="2" ParentId="4170" CreationDate="2017-02-23T15:21:52.137" Score="-1" Body="&lt;p&gt;If you want to delete duplicate lines throughout the whole file, just do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/any part of the string/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In command mode&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/I want to delete/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you just want a list of the string(s) initially:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/I want to delete/p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11509" LastEditorUserId="1821" LastEditDate="2017-02-23T15:39:08.970" LastActivityDate="2017-02-23T15:39:08.970" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11521" PostTypeId="2" ParentId="9120" CreationDate="2017-02-23T15:59:04.703" Score="2" Body="&lt;p&gt;I realize this is very late but I found this question long before I came across the answer so I'm leaving this here. By adding the following to your .vimrc file you can load in your python virtualenv and then set a few ycm settings.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; python with virtualenv support&#xA;py &amp;lt;&amp;lt; EOF&#xA;import os&#xA;import sys&#xA;if 'VIRTUAL_ENV' in os.environ:&#xA;    project_base_dir = os.environ['VIRTUAL_ENV']&#xA;    activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')&#xA;    execfile(activate_this, dict(__file__=activate_this))&#xA;EOF&#xA;&#xA;let g:ycm_server_python_interpreter='python3'&#xA;let g:ycm_autoclose_preview_window_after_completion=1&#xA;map &amp;lt;leader&amp;gt;g :YcmCompleter GoToDefinitionElseDeclaration&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11510" LastActivityDate="2017-02-23T15:59:04.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11523" PostTypeId="2" ParentId="11496" CreationDate="2017-02-23T18:51:03.850" Score="1" Body="&lt;p&gt;If you use &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-surround&lt;/a&gt; you can just delete &lt;em&gt;both&lt;/em&gt; the &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; with &lt;code&gt;ds{&lt;/code&gt; or &lt;code&gt;ds}&lt;/code&gt; (&quot;delete surrounding {&quot;), so you won't have these dangling &lt;code&gt;}&lt;/code&gt;s in the first place!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finding &quot;unmatched&quot; parens in a 100% generic way is difficult, as that would require a reasonably deep understanding of the language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, finding the next syntax group and deleting that is not so hard:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Find next error on the current line and remove it.&#xA;&quot; &#xA;&quot; There's no &quot;match syntax group atom&quot;, so move cursor forward one character&#xA;&quot; at the time, check for the syntax name, and repeat until we're at the end&#xA;&quot; of the time.&#xA;fun! RemoveError()&#xA;    &quot; Remove this group&#xA;    let l:rm = 'texMathError'&#xA;&#xA;    &quot; Save cursor position, folds, etc.&#xA;    let l:save = winsaveview()&#xA;&#xA;    while 1&#xA;        if synIDattr(synID(line('.'), col('.'), 1), 'name') == l:rm&#xA;            normal! x&#xA;        else&#xA;            normal! l&#xA;        endif&#xA;&#xA;        &quot; End of line&#xA;        if col('.') == col('$') - 1&#xA;            break&#xA;        endif&#xA;    endwhile&#xA;&#xA;    call winrestview(l:save)&#xA;endfun&#xA;nnoremap &amp;lt;Leader&amp;gt;x :call RemoveError()&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to remove multiple syntax groups you could make &lt;code&gt;l:rm&lt;/code&gt; a list or check against a regexp.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I would have to do f}x assuming my cursor is located past the first }, otherwise I need to do some repositiong to reach it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that you can use &lt;code&gt;2f}&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-02-23T18:51:03.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11524" PostTypeId="2" ParentId="11483" CreationDate="2017-02-23T19:03:44.267" Score="4" Body="&lt;p&gt;Adding &lt;code&gt;t_Co=256&lt;/code&gt; to your vimrc should never be necessarily, save for some highly unusual and archaic situations. It's typically a sign that something else is set up wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By far the most common problem is a wrong &lt;code&gt;TERM&lt;/code&gt; environment variable. You mentioned &lt;code&gt;tmux&lt;/code&gt;, try using &lt;code&gt;screen-256color&lt;/code&gt;, which should be the correct &lt;code&gt;TERM&lt;/code&gt; for tmux. This is typically set in your shell's startup file (&lt;code&gt;.zshrc&lt;/code&gt;, &lt;code&gt;.zprofile&lt;/code&gt;, or &lt;code&gt;.zshenv&lt;/code&gt;; different people use different files, and the &quot;correct&quot; one is a matter of religion).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try it first by just using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ export TERM=screen-256color&#xA;$ vim&#xA;:set t_Co?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also change the default for tmux in &lt;code&gt;~/.tmux.conf&lt;/code&gt; with &lt;code&gt;set -g default-terminal &quot;screen-256color&quot;&lt;/code&gt;. This is important for windows without shells (e.g. &lt;code&gt;new-window vim&lt;/code&gt;). The default is &lt;code&gt;screen&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-02-23T20:21:30.843" LastActivityDate="2017-02-23T20:21:30.843" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11525" PostTypeId="1" AcceptedAnswerId="11528" CreationDate="2017-02-24T02:14:41.373" Score="9" ViewCount="2345" Body="&lt;p&gt;I am writing a shell script to view a text file and search for a pattern. I want to specify this pattern in the command line when launching Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command is what I am currently using do accomplish this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim mylogfile.txt +&quot;/findthisvalue&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above command works great when the text file contains this pattern. However, if the pattern is not in the file, I want Vim to fail gracefully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, when it fails to find the pattern in the text file, Vim pops up an error saying the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Error detected while processing command line:&#xA;E486: Pattern not found: 01:50:37x&#xA;Press ENTER or type command to continue&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to tell Vim to just print in the status bar &lt;code&gt;&quot;E486: Pattern not found: findthisvalue&quot;&lt;/code&gt; and not display the &quot;Press ENTER to type command to continue&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the proper command-line to do that?&lt;/p&gt;&#xA;" OwnerUserId="11517" LastEditorUserId="246" LastEditDate="2017-02-24T03:59:28.503" LastActivityDate="2017-02-24T04:06:28.627" Title="Searching for text when launching Vim" Tags="|command-line|search|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11526" PostTypeId="1" AcceptedAnswerId="11527" CreationDate="2017-02-24T03:17:33.287" Score="42" ViewCount="107085" Body="&lt;p&gt;I want to install a vim plugin, this plugin needs a &lt;code&gt;+python&lt;/code&gt; feature, so when I open vim and type &lt;code&gt;:version&lt;/code&gt; it displays &lt;code&gt;-python&lt;/code&gt;. How can I make it enable?. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="11437" LastEditorUserId="246" LastEditDate="2017-02-24T03:36:06.150" LastActivityDate="2020-04-28T04:06:45.827" Title="How to enable +python feature in vim" Tags="|installing|" AnswerCount="10" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11527" PostTypeId="2" ParentId="11526" CreationDate="2017-02-24T03:43:44.340" Score="35" Body="&lt;p&gt;You need to compile Vim yourself or get a prebuilt Vim package that was compiled with Python support. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're on a Debian based system, the easiest way is to download the vim-gnome or vim-gtk package from &lt;code&gt;apt&lt;/code&gt; (&lt;code&gt;apt install vim-gtk&lt;/code&gt; for instance). Other distros might have a similar package with python support built in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you'd prefer to compile Vim yourself, download the Vim repository and pass in &lt;code&gt;--enable-pythoninterp&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /tmp &amp;amp;&amp;amp; git clone https://github.com/vim/vim.git &amp;amp;&amp;amp; cd vim&#xA;./configure --enable-pythoninterp --prefix=/usr&#xA;make &amp;amp;&amp;amp; sudo make install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On Windows, you can get the Gvim package from &lt;a href=&quot;https://github.com/vim/vim-win32-installer/releases/tag/v8.0.0003&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; which includes Python support.&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="246" LastEditDate="2017-02-24T04:11:49.653" LastActivityDate="2017-02-24T04:11:49.653" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11528" PostTypeId="2" ParentId="11525" CreationDate="2017-02-24T03:52:40.560" Score="6" Body="&lt;p&gt;You can leverage the &lt;code&gt;-c&lt;/code&gt; argument which runs a the given command after Vim has loaded. With this, you can search with &quot;:silent!&quot; which supresses all errors like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;silent! /foo&quot; file_to_search.txt  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If found, it will jump to the result. Otherwise, Vim just loads up the file without any errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would still like an error message but skip the &quot;Press ENTER&quot; prompt, you can increase the &lt;code&gt;'cmdheight'&lt;/code&gt; option to 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I came up with to accomplish this: (Warning: I admit this is really hacky because it sets the cmdheight to 3, searches for the word, and then sets back the &lt;code&gt;cmdheight&lt;/code&gt; to the default value of 1. Perhaps someone else can provide a better alternative):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;set cmdheight=3&quot; +/word_to_search -c &quot;set cmdheight=1&quot; file_to_search.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above case, it will give you exactly what you asked for, Vim will print &lt;code&gt;&quot;E486: Pattern not found: findthisvalue&quot;&lt;/code&gt; instead of the hit Enter prompt.&lt;/p&gt;&#xA;" OwnerUserId="246" LastEditorUserId="246" LastEditDate="2017-02-24T04:06:28.627" LastActivityDate="2017-02-24T04:06:28.627" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11531" PostTypeId="1" CreationDate="2017-02-24T17:20:27.353" Score="2" ViewCount="1432" Body="&lt;p&gt;This is what U wanted to do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! Spell(lang)&#xA;  if a:lang == &amp;quot;off&amp;quot;&#xA;    set nospell&#xA;  else&#xA;    set spell&#xA;    set spelllang=a:lang&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;unfortunately it does not work ;( it assigns the string &lt;code&gt;a:lang&lt;/code&gt; to &lt;code&gt;spelllang&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11524" LastEditorUserId="23502" LastEditDate="2022-10-25T04:37:28.837" LastActivityDate="2022-10-25T04:37:28.837" Title="How can I assign the content of a function variable to an option?" Tags="|vimscript|variables|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="11532" PostTypeId="1" AcceptedAnswerId="11535" CreationDate="2017-02-24T18:32:01.643" Score="0" ViewCount="632" Body="&lt;p&gt;Two questions related to the DelimitMate plugin here: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;How can I modify the set of auto-generated left and right delimiters? For example, in LaTeX it would be convenient to have &lt;code&gt;$&lt;/code&gt; as left-right delimiters, and if possible somehow, &lt;code&gt;\[&lt;/code&gt; and &lt;code&gt;\]&lt;/code&gt; (even though this includes the brackets, which the plugin seems to detect independent of the escape).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there any way to map some insert-mode keystroke to &quot;move to the right&quot; of the most recently generated right-delimeter? That would make editing certain types of files a lot easier. Something like &lt;code&gt;inoremap &amp;lt;C-l&amp;gt; &amp;lt;move to end of automatically-generated delimiter&amp;gt;&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8084" LastActivityDate="2017-03-01T17:13:06.480" Title="DelimitMate Plugin: How can I specify my own delimiters? Also, can I jump the cursor to the end of the generated right-delims with an insert-mode map?" Tags="|vimrc|key-bindings|insert-mode|delimiter-matching|plugin-delimitmate|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11533" PostTypeId="1" AcceptedAnswerId="11572" CreationDate="2017-02-24T20:08:19.960" Score="0" ViewCount="662" Body="&lt;p&gt;I'm trying to figure out what format to use to get filereadable to recognize a file with a space in the name.  This is in Ubuntu using version 7.4.1689.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following all return 0:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;filereadable('/home/user/file name')&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filereadable('/home/user/file\ name')&#xA;filereadable(&quot;/home/user/file\ name&quot;)&#xA;filereadable(&quot;\/home\/user\/file\ name&quot;)&#xA;filereadable(fnameescape('/home/user/file name'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get filereadable to recognize a space in the path on Linux systems?&lt;/p&gt;&#xA;" OwnerUserId="7673" LastEditorUserId="7673" LastEditDate="2017-02-28T02:29:03.783" LastActivityDate="2017-02-28T11:51:02.293" Title="How to get filereadable to recognize spaces in filenames/paths" Tags="|vimscript|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11534" PostTypeId="2" ParentId="11531" CreationDate="2017-02-24T20:50:28.893" Score="5" Body="&lt;p&gt;&lt;code&gt;:exe&lt;/code&gt; and &lt;code&gt;:let&lt;/code&gt; (and some other commands like &lt;code&gt;:echo&lt;/code&gt; or &lt;code&gt;:call&lt;/code&gt;) are basically the only ex commands that expect variables. Almost all other ex commands do not expect such things and therefore take it literally. Therefore you have to use &lt;code&gt;:exe &quot;set spelllang=&quot;.a:lang&lt;/code&gt; or even better, use &lt;code&gt;:let &amp;amp;spelllang=a:lang&lt;/code&gt; (see &lt;code&gt;:h :let-option&lt;/code&gt;). &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-02-24T20:50:28.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11535" PostTypeId="2" ParentId="11532" CreationDate="2017-02-24T21:37:26.503" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Look into the &lt;a href=&quot;https://github.com/Raimondi/delimitMate/blob/master/doc/delimitMate.txt#L169&quot; rel=&quot;nofollow noreferrer&quot;&gt;delimitMate_quotes&lt;/a&gt; variable. The following line in your vimrc should take care of the &lt;code&gt;$&lt;/code&gt; sign delimiter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;au FileType tex let b:delimitMate_quotes = &quot;\&quot; ' $&quot;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Not sure how you would go about setting a delimiter for &lt;code&gt;\[&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Checkout some of the answers to &lt;a href=&quot;https://stackoverflow.com/questions/14770836/vim-delimitmate/14771389&quot;&gt;this question&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11189" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-02-25T02:10:21.927" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11536" PostTypeId="2" ParentId="11510" CreationDate="2017-02-24T22:55:33.873" Score="3" Body="&lt;p&gt;There is no need to modify &lt;code&gt;iskeyword&lt;/code&gt;. You can just use a WORD instead. You can use a WORD (as opposed to a word) in a text object by using a capital W:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;daW&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#text-objects&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help text-objects&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#WORD&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help WORD&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-02-24T22:55:33.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11537" PostTypeId="1" AcceptedAnswerId="11538" CreationDate="2017-02-25T00:05:56.383" Score="19" ViewCount="750" Body="&lt;p&gt;&lt;code&gt;g-&lt;/code&gt; is &lt;em&gt;Return to older text state&lt;/em&gt;, and &lt;code&gt;u&lt;/code&gt; is &lt;em&gt;Undo change&lt;/em&gt;.&#xA;I don't get it.&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2017-02-25T18:54:43.480" Title="Difference between g- and u" Tags="|undo-redo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11538" PostTypeId="2" ParentId="11537" CreationDate="2017-02-25T03:27:58.490" Score="21" Body="&lt;p&gt;Check out vim's documentation on &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/undo.html#undo-branches&quot; rel=&quot;noreferrer&quot;&gt;undo branches&lt;/a&gt;. &lt;code&gt;u&lt;/code&gt; is essentially going to take you back to the parent of the current node, whereas &lt;code&gt;g-&lt;/code&gt; allows you to traverse the current node's siblings before traversing to the root of the branch. Each node represents a change in the file. The documentation's description is a bit obscure but that is how I understand it. You might find &lt;a href=&quot;http://vim.wikia.com/wiki/Using_undo_branches&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; explanation of undo branches to be easier to understand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example Scenario&lt;/strong&gt;&lt;br&gt;&#xA;I will use the following notation to explain the current structure of the undo tree:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[{parent} --&gt; ({child}, {sibling})]&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open a text file. [&lt;strong&gt;root&lt;/strong&gt;]&lt;/li&gt;&#xA;&lt;li&gt;Make a change A. [root --&gt; &lt;strong&gt;A&lt;/strong&gt;] &lt;/li&gt;&#xA;&lt;li&gt;Leave insert mode and make another change B. [root --&gt; A --&gt; &lt;strong&gt;B&lt;/strong&gt;]&lt;/li&gt;&#xA;&lt;li&gt;Undo B with the &lt;code&gt;u&lt;/code&gt; key. [root --&gt; &lt;strong&gt;A&lt;/strong&gt; --&gt; B]&lt;/li&gt;&#xA;&lt;li&gt;Make a new change C. [root --&gt; A --&gt; (B, &lt;strong&gt;C&lt;/strong&gt;)]&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;code&gt;u&lt;/code&gt; at this point would take you back to change A. Pressing &lt;code&gt;g-&lt;/code&gt;, on the other hand, would take you to change B.&lt;/p&gt;&#xA;" OwnerUserId="11189" LastEditorUserId="11189" LastEditDate="2017-02-25T18:54:43.480" LastActivityDate="2017-02-25T18:54:43.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11539" PostTypeId="1" AcceptedAnswerId="11543" CreationDate="2017-02-25T04:13:13.403" Score="2" ViewCount="530" Body="&lt;p&gt;I am looking for a way to highlight text on the line above a matched pattern. For example, my text may appear like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Some text&#xA;---------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I want is to match on the underline dashes and then highlight the 'Some text' based on that. I can match the dashes and highlight them by matching any set of three dashes like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match dashes &quot;\v^\-\-\-.*$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I am not sure how to also highlight the line above. Does anyone have any ideas on how to accomplish that?&lt;/p&gt;&#xA;" OwnerUserId="11530" LastEditorUserId="11530" LastEditDate="2017-02-25T05:13:15.503" LastActivityDate="2017-02-25T06:25:36.643" Title="Syntax Highlight line above matched pattern" Tags="|vimscript|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11540" PostTypeId="2" ParentId="11526" CreationDate="2017-02-25T05:24:14.177" Score="6" Body="&lt;p&gt;For Windows you can always grab the very latest patched version of Vim 8.x compiled against the latest external libraries here: &lt;a href=&quot;https://tuxproject.de/projects/vim/x64/&quot; rel=&quot;noreferrer&quot;&gt;Vim downloads&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the time of posting the most current versions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Latest compiled update: 2017-02-23&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim version: 8.0.0363 &lt;a href=&quot;ftp://ftp.vim.org/pub/vim/patches/8.0/README&quot; rel=&quot;noreferrer&quot;&gt;Official patch log&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Libraries used: Perl 5.24.1, Python 2.7.12, Python 3.6.0, Racket 6.7, Ruby 2.4.0, Lua 5.3.3, Tcl 8.6.4, and libXpm &lt;/p&gt;&#xA;" OwnerUserId="11532" LastActivityDate="2017-02-25T05:24:14.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11541" PostTypeId="2" ParentId="6097" CreationDate="2017-02-25T05:30:16.430" Score="0" Body="&lt;p&gt;UPDATED FOR VIM 8.x&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Windows you can always grab the very latest patched version of Vim 8.x compiled against the latest external libraries here: &lt;a href=&quot;https://tuxproject.de/projects/vim/x64/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim downloads&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the time of posting the most current versions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Latest compiled update: 2017-02-23&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim version: 8.0.0363 &lt;a href=&quot;ftp://ftp.vim.org/pub/vim/patches/8.0/README&quot; rel=&quot;nofollow noreferrer&quot;&gt;Official patch log&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Libraries used: Perl 5.24.1, Python 2.7.12, Python 3.6.0, Racket 6.7, Ruby 2.4.0, Lua 5.3.3, Tcl 8.6.4, and libXpm &lt;/p&gt;&#xA;" OwnerUserId="11532" LastActivityDate="2017-02-25T05:30:16.430" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11543" PostTypeId="2" ParentId="11539" CreationDate="2017-02-25T06:25:36.643" Score="5" Body="&lt;p&gt;This is fairly straightforward using the &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; atoms. I would do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match preDashes &quot;.*\n\ze---&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;code&gt;\ze&lt;/code&gt; atom here makes it so the matched text is &lt;em&gt;only&lt;/em&gt; what matches before the &lt;code&gt;\ze&lt;/code&gt;, but the whole pattern still must match. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for style, I'd would &lt;em&gt;highly&lt;/em&gt; recommend dropping the &lt;code&gt;\v&lt;/code&gt; setting. In general, it's only useful when it makes the whole regex shorter or more readable. Which is easier to understand at first glance?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v^\-\-\-.*$&#xA;^---.*$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For what it's worth, since &lt;code&gt;.*&lt;/code&gt; is greedy, it will match as much text as possible, so the EOL (&lt;code&gt;$&lt;/code&gt;) is not needed either. Putting all of this together, I would recommend:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match dashes &quot;^---.*&quot;&#xA;syn match preDashes &quot;.*\n\ze---&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Although I'm sure you can come up with a better name than &lt;em&gt;preDashes&lt;/em&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-02-25T06:25:36.643" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11545" PostTypeId="1" AcceptedAnswerId="11547" CreationDate="2017-02-26T00:18:01.590" Score="2" ViewCount="535" Body="&lt;p&gt;I have some keywords other than TODO used in comments that are common to all languages, things like 'NOTE'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to label these words under Todo syntax class, so that they have the same colour with TODO, but I don't know how to do it globally. Adding the following line to my vimrc doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax keyword Todo contained NOTE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to do it globally?&lt;/p&gt;&#xA;" OwnerUserId="10970" LastActivityDate="2017-02-26T03:54:14.180" Title="How do I add syntax keywords globally for any filetype?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11547" PostTypeId="2" ParentId="11545" CreationDate="2017-02-26T03:10:21.417" Score="3" Body="&lt;p&gt;You can add this to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Syntax * syntax keyword Todo contained NOTE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want this to work in comments for almost any syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Syntax * syntax keyword Todo NOTE containedin=.*Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't remember where it's documented, but &lt;code&gt;containedin=&lt;/code&gt; can be a pattern.  Most syntaxes use the &lt;code&gt;Comment&lt;/code&gt; suffix for comment groups.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2017-02-26T03:54:14.180" LastActivityDate="2017-02-26T03:54:14.180" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11548" PostTypeId="2" ParentId="2410" CreationDate="2017-02-26T09:53:20.120" Score="53" Body="&lt;p&gt;Late to the party a bit but I didn't see my favorite one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FunctionName(arg1,...)&#xA;    let arg2 = get(a:, 1, 0)&#xA;    let arg3 = get(a:, 2, 0)&#xA;&#xA;    if arg2&#xA;        &quot;Do stuff with arguments&quot;&#xA;    else&#xA;        &quot;Do stuff without arguments&quot;&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in which &lt;code&gt;get(a:, n, default)&lt;/code&gt; will get the &lt;code&gt;nth&lt;/code&gt; optional argument returning &lt;code&gt;default&lt;/code&gt; if it's not present.&lt;/p&gt;&#xA;" OwnerUserId="11151" LastEditorUserId="11151" LastEditDate="2019-02-22T22:29:52.997" LastActivityDate="2019-02-22T22:29:52.997" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11549" PostTypeId="1" CreationDate="2017-02-26T15:54:59.237" Score="3" ViewCount="1000" Body="&lt;p&gt;from some time now I'm using vim very intensively. I'm connecting to my server with different screen sessions, one for my main PC, another for netbooks or mobile phone, tablets, ... All this time working on the same files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My main screen session has vim spanning my dual screens in four vsplits. Opening that with a small screen device messes everything up :\&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I open vim in another screen session, but then i get the &lt;code&gt;.swp&lt;/code&gt; file message. For now I just edit these anyway and later clear up the &lt;code&gt;.swp&lt;/code&gt; and &lt;code&gt;.swo&lt;/code&gt; files but this is a bit hacky and messy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how to open the same file from different vim instances properly? Covim is a bit too much for me, something more basic would suffice. The basic of the basic I guess would be to have an option to automatically clear the swp files when I edit the file in another vim session and then have vim automatically refresh the file whenever it has the focus in a terminal.&lt;/p&gt;&#xA;" OwnerUserId="11543" LastActivityDate="2017-05-03T04:40:47.300" Title="How to have different vim sessions open the same file seamlessly" Tags="|sessions|gnu-screen|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11550" PostTypeId="1" AcceptedAnswerId="11635" CreationDate="2017-02-26T19:05:24.137" Score="2" ViewCount="230" Body="&lt;p&gt;I take part in some programming projects. I use &lt;code&gt;vim&lt;/code&gt; to code for these projects. &#xA;For each project I need a corresponding &lt;code&gt;.vimrc&lt;/code&gt; with appropriate plugins set and customization. I can use custom &lt;code&gt;.vimrc&lt;/code&gt; with command line options &lt;code&gt;-u&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -u /home/loom/.vimrc.custom&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I share &lt;code&gt;~/.vim/&lt;/code&gt; directory for all projects and each plugin I installed for some project is loaded for any vim start. Definitely, I don't want such behavior. So, is there a way to select preferable &lt;code&gt;.vim&lt;/code&gt; directory like I can select &lt;code&gt;.vimrc&lt;/code&gt; (or maybe to have several vim installation with corresponding &lt;code&gt;.vim&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="11516" LastEditorUserId="11516" LastEditDate="2017-02-26T19:11:37.340" LastActivityDate="2017-03-04T08:18:49.947" Title="Parallel vim installations" Tags="|plugin-system|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11551" PostTypeId="1" CreationDate="2017-02-26T20:31:57.633" Score="1" ViewCount="39" Body="&lt;p&gt;when pasting from a pdf document, words in the original document are being split up, and replaced by a &lt;code&gt;-&lt;/code&gt; and a line break.    For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alternative specifications. In con-&#xA;clusion, these findings &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to do a global search and replace to join up these lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many options that get me part way, for example, &lt;code&gt;g/-$/join!&lt;/code&gt; &#xA;will deliver &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;alternative specifications. In con-clusion,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;but I would also like to delete the &lt;code&gt;-&lt;/code&gt; in the same command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seems like it should be really easy, but...&lt;/p&gt;&#xA;" OwnerUserId="4667" LastActivityDate="2017-02-26T20:31:57.633" Title="substitute a join for a character that ends a line" Tags="|search|replace|join|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11552" PostTypeId="1" AcceptedAnswerId="11558" CreationDate="2017-02-26T20:35:13.657" Score="2" ViewCount="385" Body="&lt;p&gt;&lt;code&gt;:h modeline&lt;/code&gt; says the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;There are two forms of modelines.  The first form:&#xA;    [text]{white}{vi:|vim:|ex:}[white]{options}&#xA;&#xA;(...)&#xA;&#xA;   vi:noai:sw=3 ts=6 ~&#xA;   vim: tw=77 ~&#xA;&#xA;The second form (this is compatible with some versions of Vi):&#xA;&#xA;    [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]&#xA;&#xA;(...)&#xA;&#xA;   /* vim: set ai tw=75: */ ~&#xA;   /* Vim: set ai tw=75: */ ~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first form appears to be specific to Vim, whilst the second form appears to have some compatibility between different spin-offs of Vi.  I am writing coding standards for a package and trying to recommend one form over the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first form is much simpler because it does not need the ending colon but you cannot add text after it, for example if I add the following to a Haskell file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- vim: ft=haskell noai --&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get an error!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing modelines:&#xA;line    1:&#xA;E518: Unknown option: --&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So am inclined towards the second form.  Yet, given the two versions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Is the first from Vim (and NeoVim according to my tests) only?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What other spin-offs of Vi support the second form?  Does the original Vi support it?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2017-02-27T05:16:18.030" Title="What are the compatibility differences between the two modelines?" Tags="|original-vi|modeline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11553" PostTypeId="1" CreationDate="2017-02-26T20:43:39.097" Score="2" ViewCount="1015" Body="&lt;p&gt;I installed YouCompleteMe (&lt;code&gt;--clang-completer&lt;/code&gt;), but cannot use it. On start I see a message&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code -11. Use the ':YcmToggleLogs&#xA;' command to check the logs.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:YcmRestartServer&lt;/code&gt;. I've got a message &lt;code&gt;Restarting ycmd server...&lt;/code&gt; and nothing happens. The message is showed a long time and disappeared just when I input &lt;code&gt;:&lt;/code&gt;. YCM still doesn't work.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:YcmDiags&lt;/code&gt; shows message &lt;code&gt;Native filetype completion not supported for current file, cannot force recompilation.&lt;/code&gt; This is c++ &lt;code&gt;hello world&lt;/code&gt; application (&lt;code&gt;*.cpp&lt;/code&gt; or &lt;code&gt;*.cxx&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:YcmDebugInfo&lt;/code&gt; shows a message&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Printing YouCompleteMe debug information...&#xA; -- Client logfile: /tmp/ycm_642rzu.log&#xA; -- Server errored, no debug info from server&#xA; -- Server running at: http://127.0.0.1:56271&#xA; -- Server process ID: 10184&#xA; -- Server logfiles:&#xA; --   /tmp/ycmd_56271_stdout_6djrrG.log&#xA; --   /tmp/ycmd_56271_stderr_3G61Dj.log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last two logs are empty files. &lt;br/&gt;&#xA;File &lt;code&gt;/tmp/ycm_642rzu.log&lt;/code&gt; includes a lot of &lt;code&gt;ConnectTimeout&lt;/code&gt; errors similar to each other like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 2017-02-26 22:47:12,994 - ERROR - Unable to connect to server&#xA; Traceback (most recent call last):&#xA;   File &quot;/home/loom/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py&quot;, line 196, in HandleServerException&#xA;     yield&#xA;   File &quot;/home/loom/.vim/bundle/YouCompleteMe/autoload/../python/ycm/youcompleteme.py&quot;, line 350, in ServerBecomesReady&#xA;     'ready' )&#xA;   File &quot;/home/loom/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py&quot;, line 74, in GetDataFromHandler&#xA;     timeout ) )&#xA;   File &quot;/home/loom/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py&quot;, line 162, in JsonFromFuture&#xA;     response = future.result()&#xA;   File &quot;/home/loom/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py&quot;, line 404, in result&#xA;     return self.__get_result()&#xA;   File &quot;/home/loom/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py&quot;, line 356, in __get_result&#xA;     raise self._exception&#xA; ConnectTimeout: HTTPConnectionPool(host='127.0.0.1', port=56271): Max retries exceeded with url: /ready (Caused by ConnectTimeoutError(&amp;lt;requests.packages.urllib3.connection.HTTPConnection object at 0x6fffeef4810&amp;gt;, 'Connection to 127.0.0.1 timed out. (connect timeout=0.01)'))&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How can I fix YCM?&lt;/p&gt;&#xA;" OwnerUserId="11516" LastActivityDate="2017-02-26T20:43:39.097" Title="YouCompleteMe with cygwin" Tags="|plugin-you-complete-me|cygwin|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11554" PostTypeId="2" ParentId="11549" CreationDate="2017-02-26T21:35:31.163" Score="1" Body="&lt;p&gt;Vim developers and users have been debating on methods to deal with the swap file and multiple Vim processes &lt;a href=&quot;https://github.com/chrisbra/Recover.vim/issues/1&quot; rel=&quot;nofollow noreferrer&quot;&gt;for a long time&lt;/a&gt;.  Some plugins did come out of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin that I use for that is &lt;a href=&quot;https://github.com/gioele/vim-autoswap&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-autoswap&lt;/a&gt;, but I do make changes to its code.  When you do &lt;code&gt;:w&lt;/code&gt; Vim first updates the swap file and then the file, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo yay &amp;gt; dummy&#xA;$ vim dummy&#xA;:w&#xA;:!ls -a --fulltime *dummy&#xA;-rw-r--r-- 1 grochmal users     4 2017-02-26 21:19:52.995699920 +0000 dummy&#xA;-rw-r--r-- 1 grochmal users 12288 2017-02-26 21:19:47.819084930 +0000 .dummy.swp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Therefore the swap file is older than the file you're editing when you perform the write (&lt;code&gt;:w&lt;/code&gt;).  And the &lt;a href=&quot;https://github.com/gioele/vim-autoswap&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-autoswap&lt;/a&gt; plugin will delete a swap file older than the file itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, the plugin would not be able to figure out that the swap file is older in some cases.  For example, in a second test where I perform the &lt;code&gt;:w&lt;/code&gt; quickly after opening the file I get the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-rw-r--r-- 1 grochmal users     4 2017-02-26 21:22:14.144290852 +0000 dummy&#xA;-rw-r--r-- 1 grochmal users 12288 2017-02-26 21:22:14.104291252 +0000 .dummy.swp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The swap file is older alright, by 0.4 seconds.  But Vim's &lt;code&gt;getftime()&lt;/code&gt; can only deal with seconds, so &lt;a href=&quot;https://github.com/gioele/vim-autoswap&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-autoswap&lt;/a&gt; will fail to figure out that the swap is older.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I do to deal with that case is that I change &lt;a href=&quot;https://github.com/gioele/vim-autoswap/blob/master/plugin/autoswap.vim#L61&quot; rel=&quot;nofollow noreferrer&quot;&gt;line 61&lt;/a&gt; in the plugin from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;elseif getftime(v:swapname) &amp;lt; getftime(a:filename)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;elseif getftime(v:swapname) &amp;lt;= getftime(a:filename)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo yay &amp;gt; dummy&#xA;$ vim dummy&#xA;:w&#xA;&amp;lt;Ctrl+Z&amp;gt;&#xA;$ vim dummy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim (with the plugin) gives me a warning message saying:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Old swapfile detected... and deleted&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But if it takes me more than one second making changes to the file before giving the SIGSTOP (&lt;code&gt;Ctrl+Z&lt;/code&gt;) then the plugin discovers the that the swap was updates and tells me:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Swapfile detected, opening read-only&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I know that it is very likely that I have unwritten changes in the other process.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="6590" LastEditDate="2017-03-29T00:33:00.967" LastActivityDate="2017-03-29T00:33:00.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11555" PostTypeId="2" ParentId="11550" CreationDate="2017-02-26T23:02:42.623" Score="2" Body="&lt;p&gt;I read two problems expressed in your question.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;depending on the project you could activate different plugins&lt;/li&gt;&#xA;&lt;li&gt;depending on the project you could tune differently, different things.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;1- Being picky about plugins loaded&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;First, I have a question for you. What makes two projects that different that they would require totally different set of plugins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect, the filetype of the files you're manipulating is what discriminates your projects. I understand you may need different settings for a python project from a C++ project for instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lately, we've seen more and more people advocate a couple of plugin managers able to load different plugins depending on the filetype of the file edited -- vim-plug belongs to that category, there are a few others. IMO, this is a poor man's/pointless solution. First because we could edit files from different projects, or of different types within a same vim session, and because plugins are difficult, is not impossible, to unload. Once, loaded, the plugin is still loaded. If it doesn't play well when files of different types are loaded, then it's badly written. This is sad because we are able to define specialized filetype-plugins since Vim 6 (which is something like 15 years old).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course we could think about other situations like: what's the point of loading fugitive with a svn based project? What's the problem with it? Honestly. Yes, not all plugins are exploiting autoload plugins and might slow down starting times. Is this that terrible? Can't we ask their maintainers to improve these plugins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only real issue is related to conflicting behaviours and mappings. If it was your problem, I guess you would have made it explicit in your question, wouldn't you?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMO, this is the only case that might justify such plugin managers, on the condition that you have an extremely strict workflow where you never edit files of different natures. However, ff you start mixing files and if the plugins you're using are poorly made, these plugins managers won't be able to help you in any way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll be back on the subject of loading plugins depending on project (not filetypes) later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that loading plugins depending on the filetype of the files edited is addressed in this question: &lt;a href=&quot;https://vi.stackexchange.com/questions/11475/selectively-enable-a-subset-of-vim-plugins-for-specific-category-of-workflows-p&quot;&gt;Selectively enable a subset of vim plugins for specific category of workflows (plugin virtualenv for vim projects)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, &lt;a href=&quot;http://[%60:h%20packages%60](http://vimhelp.appspot.com/repeat.txt.html#packages)&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim 8 packages&lt;/a&gt; could be used to define contexts, and thus to load different things packaged together more easily. At this time there are commands to do it on demand, I don't doubt it could be done automatically based on filetypes, or on projects/directories (see below).&#xA;But again, this doesn't answer the case where files from different projects are loaded within the same vim instance as it doesn't provide any mean to unload/undefine.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;2. Project based settings.&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This is a subject on which I've spent time. I've developed two plugins that address the issue of tuning stuff based on projects. This topic would be a duplicate of other questions on &lt;a href=&quot;https://stackoverflow.com/questions/456792/vim-apply-settings-on-files-in-directory/456889#456889&quot;&gt;SO&lt;/a&gt;, and on &lt;a href=&quot;https://vi.stackexchange.com/questions/2094/how-to-make-vimrc-settings-applicable-for-a-directory-tree-only&quot;&gt;vi.SE&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say I have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/Project.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin library&lt;/a&gt; where I've introduced project based variables (as we have &lt;code&gt;b:uffer_variables&lt;/code&gt;) and simplified ways to detect projects depending on &lt;code&gt;.git&lt;/code&gt; and &lt;code&gt;.svn&lt;/code&gt; directories) -- these improvements are almost pointless if the plugins you're using don't depend on &lt;code&gt;p:variable&lt;/code&gt; from my library-plugin.&lt;/li&gt;&#xA;&lt;li&gt;a &lt;a href=&quot;https://github.com/LucHermitte/local_vimrc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin that permits to define local &lt;code&gt;.vimrc&lt;/code&gt;&lt;/a&gt; (which scales unlike modelines, &lt;code&gt;.exrc&lt;/code&gt;, autocommands...). It can be combined with my library-plugin for more complex settings. It's really handy to set &lt;code&gt;b:variables&lt;/code&gt;, and even &lt;code&gt;g:variables&lt;/code&gt; (and also vim options, mappings, commands...) depending on the current project. However, I've never ever considered if it could be used to load plugins at the last moment. First because the only thing I expect of a plugin manager is to support dependencies when installing plugins, then because this is not a need that I share (and yet I could edit, vim, C++, python, LaTeX, markdown... files from a same vim instance, and even files from different projects that are compiled differently).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-02-27T09:09:53.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11556" PostTypeId="1" AcceptedAnswerId="11740" CreationDate="2017-02-27T02:19:04.757" Score="4" ViewCount="515" Body="&lt;p&gt;I'm labeling my Tmux tabs with the current file in vim like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter * let &amp;amp;titlestring = ' ' . expand(&quot;%:t&quot;)&#xA;set title&#xA;set t_ts=k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I have a VimLeave autocmd to have tmux rename the tab when I exit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimLeave * call system(&quot;tmux setw automatic-rename&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I exit vim, the tab is renamed to &quot;Thanks for flying Vim&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas how to fix this?&lt;/p&gt;&#xA;" OwnerUserId="11547" LastActivityDate="2017-03-13T18:02:02.280" Title="Vim + Tmux: Resetting tmux tab name when exiting vim" Tags="|vimrc|autocmd|tmux|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11557" PostTypeId="2" ParentId="11526" CreationDate="2017-02-27T03:41:31.390" Score="2" Body="&lt;p&gt;On Mac OS X, you can use &lt;code&gt;homebrew&lt;/code&gt; to install first python and then vim, which vim will support python. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use MBP, the vim support &lt;code&gt;python/dyn&lt;/code&gt; installed by the above way, but not including &lt;code&gt;python3&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;# Delete wrong ans 2017.2.28 10:38AM #&lt;/p&gt;&#xA;" OwnerUserId="10816" LastEditorUserId="10816" LastEditDate="2017-02-28T02:43:12.940" LastActivityDate="2017-02-28T02:43:12.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11558" PostTypeId="2" ParentId="11552" CreationDate="2017-02-27T04:55:43.053" Score="3" Body="&#xA;&#xA;&lt;p&gt;The original Vi does support modelines of the second form, however, &lt;code&gt;modelines&lt;/code&gt; has to be set before the file is read. The &lt;a href=&quot;http://ex-vi.sourceforge.net/ex.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;manpage of &lt;code&gt;ex&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt; modelines, ml  default: nomodelines&#xA;        If modelines is set, then the first 5 lines and  the  last  five&#xA;        lines  of  the file will be checked for ex command lines and the&#xA;        comands issued.  To be recognized as a command  line,  the  line&#xA;        must  have the string ex: or vi: in it.  This string may be any-&#xA;        where in the line and anything after the : is interpeted as edi-&#xA;        tor commands.  This option defaults to off because of unexpected&#xA;        behavior when editting files such as /etc/passwd.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://ex-vi.cvs.sourceforge.net/ex-vi/ex-vi/Changes?view=markup&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Changes&lt;/code&gt; file&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Release 2/17/02&#xA;* POSIX.2: Backslash has no special meaning inside RE bracket expressions.&#xA;...&#xA;* Made modelines compatible to SVr4 ex: The option name is &quot;modelines&quot; or&#xA;  &quot;ml&quot; now; a space or tab preceeding &quot;ex:&quot; or &quot;vi:&quot; is not required.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This indicates that modelines support was present earlier, it was changed in 2002.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sven Guckes' &lt;a href=&quot;http://www.guckes.net/vi/options.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;list of vi options&lt;/a&gt; says modelines was supported by SVR3.1 vi, but not which format. I'd wager it would be the second form.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for other implementations, &lt;a href=&quot;https://www.freebsd.org/cgi/man.cgi?query=nvi&amp;amp;sektion=1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;nvi&lt;/code&gt;'s manpage&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;modelines, modeline [off]&#xA;  Read  the first and last few lines of each file for ex commands.&#xA;  &lt;em&gt;This option will never be implemented.&lt;/em&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Emphasis varies depending on the age of the manpage.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;a href=&quot;http://elvis.the-little-red-haired-girl.org/elvisman/elvisopt.html#modeline&quot; rel=&quot;nofollow noreferrer&quot;&gt;Elvis&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;modeline, ml (Boolean, global)&lt;br&gt;&#xA;  modelines, mls (Number, global)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The &lt;em&gt;modeline&lt;/em&gt; option controls whether Elvis will look for modelines&#xA;  in each buffer after it has been loaded from a file. If modelines is&#xA;  true, then Elvis will search through the first and last &lt;em&gt;modelines&lt;/em&gt;&#xA;  lines of the buffer for something that looks like &quot;ex:&lt;em&gt;commands&lt;/em&gt;:&quot; or&#xA;  &quot;vi:&lt;em&gt;commands&lt;/em&gt;:&quot; and if found, it executes the &lt;em&gt;commands&lt;/em&gt; as an ex&#xA;  command line. (This behavior is implemented in the elvis.arf file.)&#xA;  This is typically used for changing tabstops and the like. The&#xA;  modeline option is false by default, and modelines is 5.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It looks like the first is only for Vim (and descendants).&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2017-02-27T05:16:18.030" LastActivityDate="2017-02-27T05:16:18.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11559" PostTypeId="1" AcceptedAnswerId="11564" CreationDate="2017-02-27T09:50:44.303" Score="5" ViewCount="3010" Body="&lt;p&gt;I regularly find myself editing some code, encountering an error in a function and then changing the function call and the function itself to debug the problem. Once the problem in the function is solved, I then want to revert the call to what it was. Of course I always forget to save the call to a register beforehand, and I figured the most intuitive solution would be to undo the last change on the current line. I have not been able to find such functionality in Vim however. Is there something I overlooked? In my mind I see a mapping that branches the undo tree and replays all edits, except the last one on the current line.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2017-02-27T17:46:48.157" Title="undo last change on current line" Tags="|undo-redo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11560" PostTypeId="1" AcceptedAnswerId="11563" CreationDate="2017-02-27T11:41:20.887" Score="1" ViewCount="295" Body="&lt;p&gt;Copying this question over from &lt;a href=&quot;https://stackoverflow.com/q/42474604/262108I&quot;&gt;https://stackoverflow.com/q/42474604/262108I&lt;/a&gt; recently started working with django templates and was wondering whether there are any autocompletion plugins for template directives like &lt;code&gt;{% block|if|... %}&lt;/code&gt;etc that &lt;strong&gt;&lt;em&gt;do not&lt;/em&gt;&lt;/strong&gt; involve a snippets library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I specifically do not want a snippet plugin because I find them quite distracting when editing code. Most snippet plugins would require digging thru' the docs and to figure out configuration to disable (rather than enable) snippets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am thinking something along the lines of &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;auto-pairs&lt;/a&gt; and &lt;a href=&quot;https://github.com/sukima/xmledit&quot; rel=&quot;nofollow noreferrer&quot;&gt;xmledit&lt;/a&gt; which does something like (assuming &lt;code&gt;|&lt;/code&gt; is the cursor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{% block ... %}|   &amp;lt;-- recognize I entered a &quot;%}&quot;&#xA;&#xA;complete it to:&#xA;&#xA;{% block ... %}&#xA;    |   &amp;lt;------- place the cursor here&#xA;{% endblock %}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11553" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-03-03T10:49:36.680" Title="vim plugin to autocomplete blocks in django templates but *not* a generic snippets plugin?" Tags="|autocompletion|plugin-system|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11561" PostTypeId="1" CreationDate="2017-02-27T13:38:05.153" Score="3" ViewCount="527" Body="&lt;p&gt;I know that the buffer is the window you're currently working in (or at least that's what I think it is), but why should I use buffer when scripting :autocmd? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType cpp,javascript,java,php :iabbrev &amp;lt;buffer&amp;gt; iff if ()&amp;lt;left&amp;gt;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will turn 'iff' into if () for a few file types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tested it without buffer too and it still works. Is there any reason why I should include buffer?&lt;/p&gt;&#xA;" OwnerUserId="11540" LastActivityDate="2017-02-27T14:14:37.713" Title="What is the point of &lt;buffer&gt; in autocmds?" Tags="|vimrc|buffers|autocmd|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11562" PostTypeId="2" ParentId="11561" CreationDate="2017-02-27T14:14:37.713" Score="1" Body="&lt;p&gt;The buffer is the &lt;em&gt;what&lt;/em&gt; you're currently editing. It could be file, or not yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A window is the &lt;em&gt;where&lt;/em&gt; it's edited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; is mandatory for your mappings/&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3aabbreviate%2d%3cbuffer%3e&quot; rel=&quot;nofollow noreferrer&quot;&gt;abbreviations&lt;/a&gt;, command (with &lt;code&gt;-buffer&lt;/code&gt; this time), menus (with a &lt;a href=&quot;https://github.com/LucHermitte/lh-misc/blob/master/plugin/buffermenu.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt;) to exist only in the context of your current buffer. It's not directly related to &lt;code&gt;autocommands&lt;/code&gt;. autocommands only define the when the definition is done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, you certainly don't want your &lt;code&gt;if&lt;/code&gt; abbreviation to be expanded in the same fashion in C++, Python, Pascal, or in vim scripts language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: your abbreviation suffer of several issues:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it'll also be expanded in string or in comments&lt;/li&gt;&#xA;&lt;li&gt;it won't play well with bracketing plugins as it isn't &lt;code&gt;nore&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;it'll insert a trailing white space (search for &lt;code&gt;eatchar&lt;/code&gt;, in Vim context)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-02-27T14:14:37.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11563" PostTypeId="2" ParentId="11560" CreationDate="2017-02-27T14:31:25.293" Score="2" Body="&lt;p&gt;The principle:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;listen for &lt;code&gt;}&lt;/code&gt;, not &lt;code&gt;%}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;analyse the context to decide what to return from a &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3amap%2d%3cexpr%3e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :map-&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;the mapping shall be buffer local in order to avoid side-effects with other filetypes (&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3amap%2d%3cbuffer%3e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :map-&amp;lt;buffer&amp;gt;&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;The movements returned shall be in double-quoted string and escaped with a back-slash (otherwise, you'll see the text &lt;code&gt;&amp;lt;up&amp;gt;&amp;lt;c-f&amp;gt;&lt;/code&gt; inserted)&lt;/li&gt;&#xA;&lt;li&gt;I'm not sure whether autoindentation could be applied here (&lt;a href=&quot;http://vimhelp.appspot.com/indent.txt.html#i_CTRL%2dF&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-F&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;The result shall be put in a django ftplugin, and it'll even better to put the function into an autoload plugin, with its name changed to &lt;code&gt;django#_expand_block()&lt;/code&gt; for instance.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; EDIT: VA. Support if, for, block. And just copy the statement.&#xA;function! s:expand_block() abort&#xA;  &quot; Ignore what is after the cursor&#xA;  let ctx = getline('.')[:col('.')-1]&#xA;  &quot; get sure there is a '%' before the cursor&#xA;  let statement = matchstr(ctx, '^{%\s*\zs\(block\|if\|for\)\ze.*%')&#xA;  if !empty(statement)&#xA;    &quot; Avoid triggering InsertLeave events&#xA;    return &quot;}\n\n{% end&quot;.statement.&quot; %}\&amp;lt;up&amp;gt;\&amp;lt;c-f&amp;gt;&quot;&#xA;    &quot; Shorter&#xA;    return &quot;}\n{% end&quot;.statement.&quot; %}\&amp;lt;esc&amp;gt;O&quot;&#xA;  else&#xA;    return &quot;}&quot;&#xA;  endif&#xA;endfunction&#xA;&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; } &amp;lt;sid&amp;gt;expand_block()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-03-03T10:49:36.680" LastActivityDate="2017-03-03T10:49:36.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11564" PostTypeId="2" ParentId="11559" CreationDate="2017-02-27T17:33:14.283" Score="5" Body="&lt;p&gt;This will probably do what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Undoline()&#xA;  let pos = getpos(&quot;.&quot;)&#xA;  let current = getline(pos[1])&#xA;  let chg = changenr()&#xA;  while changenr() &amp;gt; 0 &amp;amp;&amp;amp; current ==# getline(pos[1])&#xA;    silent exec 'u'&#xA;  endwhile&#xA;  let old = getline(pos[1])&#xA;&#xA;  while changenr() &amp;lt; chg&#xA;    silent exec 'redo'&#xA;  endwhile&#xA;  &quot; undo if we jumped over a gap&#xA;  if changenr() &amp;gt; chg&#xA;    silent exec 'u'&#xA;  endif&#xA;  call setpos('.', pos)&#xA;  if old ==# current&#xA;    echo 'no change found'&#xA;  else&#xA;    call setline(pos[1], old)&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will &lt;code&gt;undo&lt;/code&gt; until the line you are on changes, take the old value, &lt;code&gt;redo&lt;/code&gt; to your current state and then replace the line with the old value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will obviously not work if a line above was added or removed, in that case take a look at one of the &lt;a href=&quot;http://vim.wikia.com/wiki/Using_undo_branches#Plugins&quot; rel=&quot;noreferrer&quot;&gt;undo browsing plugins&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="10337" LastEditDate="2017-02-27T17:46:48.157" LastActivityDate="2017-02-27T17:46:48.157" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11565" PostTypeId="2" ParentId="84" CreationDate="2017-02-27T19:18:58.140" Score="3" Body="&lt;p&gt;If your vim does not support &lt;code&gt;+clipboard&lt;/code&gt; you can use the &lt;a href=&quot;http://vimawesome.com/plugin/fakeclip&quot; rel=&quot;nofollow noreferrer&quot;&gt;fakeclip&lt;/a&gt; plugin for Linux, Mac, Windows, tmux, screen, ...&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-02-27T19:18:58.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11566" PostTypeId="1" CreationDate="2017-02-28T00:12:05.233" Score="4" ViewCount="263" Body="&lt;p&gt;I use &lt;a href=&quot;https://getnikola.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Static Site Generator | Nikola&lt;/a&gt;. Each post has  a header like as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!--&#xA;.. title: Some interesting title&#xA;.. slug: some-interesting-title&#xA;.. date: 2017-01-25 06:32:15 UTC-03:00&#xA;.. tags: tag1,tag2&#xA;.. category: Enlaces&#xA;.. link:&#xA;.. description: bla, bla, bla&#xA;.. type: text&#xA;--&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My idea is create a file with tags (tag1, tag2, ... tagn), and to use  insert mode completion, whith CTRL-X and CTRL-I.&#xA;But I have no idea about how to set an included file in order to vim find in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edited:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found in the documentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-X CTRL-I       Search for the first keyword in the current and&#xA;            included files that starts with the same characters&#xA;            as those before the cursor.  The matched keyword is&#xA;            inserted in front of the cursor.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't found how and/or where declare such a files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've even tried with the solution from &lt;a href=&quot;https://stackoverflow.com/questions/308258/vim-keyword-completion#308274&quot;&gt;c - vim keyword completion - Stack Overflow&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've created an empty file, and added:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path+=/tmp/tags/**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does not work. I use vim-enhanced-8.0.329-1.fc25.x86_64.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="6950" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-03-01T14:25:46.257" Title="How to populate a drop-down list for &lt;C-x&gt;&lt;C-i&gt; completion?" Tags="|autocompletion|include|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11568" PostTypeId="1" CreationDate="2017-02-28T03:34:23.427" Score="1" ViewCount="48" Body="&lt;p&gt;I'm using a plugin, &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1788&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;bexec&lt;/code&gt;&lt;/a&gt;, to execute a test script. The plugin opens up a new buffer to the right of my code and it displays the output of the test script:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nm2Op.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nm2Op.png&quot; alt=&quot;terminal screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to have syntax highlighting for the test script output. I'm using standard Perl testing modules (Test::More, etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please point me in the right direction for making this happen?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="205" LastEditDate="2017-02-28T04:21:37.570" LastActivityDate="2017-02-28T04:21:37.570" Title="Turning on syntax highlighting for test script output to new buffer" Tags="|syntax-highlighting|buffers|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11569" PostTypeId="1" AcceptedAnswerId="11570" CreationDate="2017-02-28T03:51:05.427" Score="2" ViewCount="333" Body="&lt;p&gt;While using Neovim, I love &lt;code&gt;:term&lt;/code&gt; very much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the time, I do the following steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;vsplit&lt;/code&gt; to open a vertical window.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:term&lt;/code&gt; in the new window to enter terminal.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$ cd CURRENT_PATH&lt;/code&gt; in the shell.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I was wondering if maybe I could combine them all in one vim command?&lt;/p&gt;&#xA;" OwnerUserId="11440" LastActivityDate="2017-02-28T07:23:25.160" Title="How to combine `vsplit` `term` and `cd` current directory?" Tags="|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11570" PostTypeId="2" ParentId="11569" CreationDate="2017-02-28T04:43:03.103" Score="2" Body="&lt;p&gt;In Vim, the &lt;code&gt;|&lt;/code&gt; character is used as a command separator, making it equivalent to the semicolon in the Unix shell.  Furthermore, the full syntax to the &lt;code&gt;:term&lt;/code&gt; command is as follows: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:te[rminal][!] {cmd}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Therefore, I believe the following command should do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let CP=expand('%:p:h') | vsplit | exec ':term &quot;cd ' .CP .'&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do not have Neovim installed, however, so am unable to test this command at the moment.&lt;/p&gt;&#xA;" OwnerUserId="11189" LastEditorUserId="11189" LastEditDate="2017-02-28T07:23:25.160" LastActivityDate="2017-02-28T07:23:25.160" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11572" PostTypeId="2" ParentId="11533" CreationDate="2017-02-28T11:51:02.293" Score="2" Body="&lt;p&gt;&lt;code&gt;filereadable('/home/user/file name')&lt;/code&gt; is the correct syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use wildcards as well you should use &lt;code&gt;glob&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if glob('~/file name')!=#&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;glob&lt;/code&gt; returns the full name if the file exists or &lt;code&gt;&quot;&quot;&lt;/code&gt; if it does not.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-02-28T11:51:02.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11573" PostTypeId="1" CreationDate="2017-02-28T15:02:53.753" Score="2" ViewCount="74" Body="&lt;p&gt;This would make my workflow immensely easier -- I have some simple maps for executing python &lt;code&gt;.py&lt;/code&gt; files, and sometimes it would be nice to open an interactive session after running them (for example, an IPython shell using &lt;code&gt;:!ipython -i %&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, if I want to run an interactive session, I am trapped there (as this is a process that has not &quot;finished&quot;) until I close the session and see the &lt;code&gt;press Enter to continue&lt;/code&gt; message. But I was wondering if there was a way to switch back and forth between files open in Vim and this active process.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastActivityDate="2017-02-28T15:54:50.030" Title="Is there any way to switch between Vim and a :! command passed to the shell, before it is finished executing?" Tags="|vimrc|vimscript|external-command|bash|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11574" PostTypeId="2" ParentId="9750" CreationDate="2017-02-28T15:19:44.687" Score="0" Body="&lt;p&gt;You are probably looking for &lt;a href=&quot;http://vim.wikia.com/wiki/Avoid_scrolling_when_switch_buffers&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Avoid scrolling when switch buffers&quot;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When switching buffers using the Ctrl-^ and :bp commands, Vim will keep the cursor on the line number where it was before switching the buffer but it might change the position of the current line relative to the screen. For example, the cursor may be in line 1234 of the file, with that line at the top of the screen. The user may switch to another buffer, then switch back (:bn :bp), and find that the current line has been repositioned to the middle of the screen. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-02-28T15:19:44.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11575" PostTypeId="2" ParentId="11573" CreationDate="2017-02-28T15:45:46.973" Score="2" Body="&lt;p&gt;You can do that and so much more with tmux&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=5r6yzFEXajQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim + tmux - OMG!Code - YouTube&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://teamgaslight.com/blog/vim-plus-tmux-a-perfect-match&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim + tmux: A Perfect Match&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can for example, split your screen, run your session and switch back whenever you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For better navigation also install &lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/christoomey/vim-tmux-navigator&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="10337" LastEditDate="2017-02-28T15:54:50.030" LastActivityDate="2017-02-28T15:54:50.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11576" PostTypeId="1" CreationDate="2017-02-28T19:30:26.247" Score="1" ViewCount="586" Body="&lt;p&gt;I'm new to Vim and I'm trying to include a line length marker, but only in Python files. As far as I know, this line length marker can be added to Vim by using &lt;code&gt;set colorcolumn=&amp;lt;number&amp;gt;&lt;/code&gt; in the &lt;code&gt;.vimrc&lt;/code&gt;. That code adds a column everywhere in Vim, like the Explorer. How can I restrict it only to Python files?&lt;/p&gt;&#xA;" OwnerUserId="11580" LastActivityDate="2017-02-28T19:35:31.353" Title="Line length mark in Python files" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ClosedDate="2017-03-02T12:27:10.017" ContentLicense="CC BY-SA 3.0" />
  <row Id="11577" PostTypeId="2" ParentId="11576" CreationDate="2017-02-28T19:35:31.353" Score="1" Body="&lt;p&gt;I've already find out how this is. I had to use &lt;code&gt;autocmd FileType python setlocal colorcolumn=79&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11580" LastActivityDate="2017-02-28T19:35:31.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11578" PostTypeId="1" AcceptedAnswerId="14339" CreationDate="2017-02-28T20:41:11.110" Score="4" ViewCount="3573" Body="&lt;p&gt;I've tried every tip I can find on this and none of them work. I've cleared my &lt;code&gt;.vimrc&lt;/code&gt; file. I have a syntax script in &lt;code&gt;./vim/syntax/test.vim.&lt;/code&gt; It consists of nothing but this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight clear&#xA;syn keyword syntaxElementKeyword ok&#xA;hi def link syntaxElementKeyword Todo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I first load a file with my text and enable and set the syntax file to test, it works. But if I do &lt;code&gt;:e&lt;/code&gt; on the text file, the syntax highlighting turns off then I have to run &lt;code&gt;:set syntax=test&lt;/code&gt; again. OK, fine. But then if I edit &lt;code&gt;test.vim,&lt;/code&gt; I cannot get the changes I make to take effect unless I close out my text file and then reenable syntax highlighting. This makes for painful slow going for someone trying to learn how to do syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how do I reload the syntax file so I can see the changes reflected in my text file instantly?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="2021" LastEditDate="2017-02-28T21:36:07.093" LastActivityDate="2017-11-26T17:25:28.703" Title="Reloading syntax file without restarting vim" Tags="|syntax-highlighting|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11580" PostTypeId="2" ParentId="11578" CreationDate="2017-02-28T23:17:07.853" Score="2" Body="&lt;p&gt;Changing my test file to something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax keyword Foo Foo &#xA;highlight Foo cterm=underline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;allowed me to change the colors after editing the test file. So there must be something special about the &quot;def&quot; keyword that gets treated differently. &lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-02-28T23:17:07.853" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11581" PostTypeId="1" AcceptedAnswerId="11582" CreationDate="2017-02-28T23:45:05.330" Score="16" ViewCount="10610" Body="&lt;p&gt;In several terminal programs, such as &lt;a href=&quot;http://www.chiark.greenend.org.uk/~sgtatham/putty/)&quot; rel=&quot;noreferrer&quot;&gt;PuTTY&lt;/a&gt;, &lt;a href=&quot;https://www.vandyke.com/products/securecrt/&quot; rel=&quot;noreferrer&quot;&gt;SecureCRT&lt;/a&gt;, &lt;a href=&quot;http://iterm.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;iTerm&lt;/a&gt;, and Mac OS Terminal,&#xA;if I have NumLock on and I press the number pad (numpad) keys &lt;code&gt;0123456789&lt;/code&gt; in insert mode, my vim looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y                                                                                                          &#xA;x&#xA;w&#xA;v&#xA;u&#xA;t&#xA;s&#xA;r&#xA;q&#xA;p&#xA;&#xA;~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I use the numpad on the command line, it enters the numbers I expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I make vim type the right characters from the numpad?&lt;/p&gt;&#xA;" OwnerUserId="9267" LastActivityDate="2022-08-09T18:13:35.430" Title="Why doesn't my numpad work right in my terminal?" Tags="|terminal|keyboard-layout|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11582" PostTypeId="2" ParentId="11581" CreationDate="2017-02-28T23:45:05.330" Score="29" Body="&lt;h3&gt;Short answer&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Turn off “application keypad mode switching.”&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Terminal-specific instructions&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/PuTTY_numeric_keypad_mappings#Using_the_numeric_keypad)&quot; rel=&quot;noreferrer&quot;&gt;PuTTY&lt;/a&gt; (also &lt;a href=&quot;https://stackoverflow.com/a/7284745/1144854&quot;&gt;here&lt;/a&gt;):&#xA;&lt;code&gt;Terminal &amp;gt; Features &amp;gt; uncheck Disable application keypad mode&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;SecureCRT:&#xA;&lt;code&gt;Session Options &amp;gt; Terminal &amp;gt; Emulation &amp;gt; Modes &amp;gt; Mode switching &amp;gt; uncheck Enable keypad mode switching&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;iTerm: Switch to iTerm2 or see general instructions below.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.twistermc.com/39930/use-number-pad-vim-iterm2/&quot; rel=&quot;noreferrer&quot;&gt;iTerm2&lt;/a&gt; (also &lt;a href=&quot;https://web.archive.org/web/20131110033808/https://code.google.com/p/iterm2/issues/detail?id=1357&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;):&#xA;&lt;code&gt;Preferences &amp;gt; Profiles &amp;gt; Keys &amp;gt; Load Preset… &amp;gt; xterm with Numeric Keypad&lt;/code&gt; or add the settings manually as shown &lt;a href=&quot;https://superuser.com/a/939832/163315&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://discussions.apple.com/thread/6613968&quot; rel=&quot;noreferrer&quot;&gt;Mac OS Terminal&lt;/a&gt; (also &lt;a href=&quot;https://apple.stackexchange.com/a/201341/201023&quot;&gt;here&lt;/a&gt;):&#xA;&lt;code&gt;Preferences &amp;gt; Profiles &amp;gt; Advanced &amp;gt; uncheck Allow VT100 application keypad mode&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Other: look for an option like &lt;code&gt;application keypad mode&lt;/code&gt; or see below.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;General instructions for .vimrc&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If the terminal-specific instructions don't work for you, you can fix it in vim by adding the following mappings to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;Esc&amp;gt;Oq 1&#xA;:inoremap &amp;lt;Esc&amp;gt;Or 2&#xA;:inoremap &amp;lt;Esc&amp;gt;Os 3&#xA;:inoremap &amp;lt;Esc&amp;gt;Ot 4&#xA;:inoremap &amp;lt;Esc&amp;gt;Ou 5&#xA;:inoremap &amp;lt;Esc&amp;gt;Ov 6&#xA;:inoremap &amp;lt;Esc&amp;gt;Ow 7&#xA;:inoremap &amp;lt;Esc&amp;gt;Ox 8&#xA;:inoremap &amp;lt;Esc&amp;gt;Oy 9&#xA;:inoremap &amp;lt;Esc&amp;gt;Op 0&#xA;:inoremap &amp;lt;Esc&amp;gt;On .&#xA;:inoremap &amp;lt;Esc&amp;gt;OQ /&#xA;:inoremap &amp;lt;Esc&amp;gt;OR *&#xA;:inoremap &amp;lt;Esc&amp;gt;Ol +&#xA;:inoremap &amp;lt;Esc&amp;gt;OS -&#xA;:inoremap &amp;lt;Esc&amp;gt;OM &amp;lt;Enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9267" LastEditorUserId="9267" LastEditDate="2017-03-30T17:37:11.170" LastActivityDate="2017-03-30T17:37:11.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11583" PostTypeId="1" AcceptedAnswerId="11588" CreationDate="2017-03-01T00:53:34.950" Score="3" ViewCount="1598" Body="&lt;p&gt;I do use the same &lt;code&gt;vimrc&lt;/code&gt; on my local machine and on a remote machine to which I connect through SSH.  I keep the &lt;code&gt;vimrc&lt;/code&gt; synced between the machines for commodity.  My issue starts when I set &lt;code&gt;mouse=a&lt;/code&gt;, I really like using it since I do have a lot of stuff in &lt;code&gt;listchars=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my local machine, to copy to the primary or clipboard buffers I let the mouse enter visual mode (&lt;code&gt;selectmode=&lt;/code&gt;) and do &lt;code&gt;&quot;+y&lt;/code&gt; or &lt;code&gt;&quot;*y&lt;/code&gt;.  That's all fine.  On the remote machine I force &lt;code&gt;mouse=&lt;/code&gt; to be empty and use the terminal's copy and paste functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I enable &lt;code&gt;mouse=a&lt;/code&gt; on the remote machine I can't copy and paste from it anymore because Vim takes over the mouse and the terminal never sees the selection.  For now I'm lucky that the remote machine have Vim 7.4, and since I use Vim 8.0 on my local machine the following works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if 800 &amp;gt;= v:version&#xA;  set mouse=a&#xA;else&#xA;  set mouse=&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it will break shortly since I'm about to update Vim on the remote machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried connecting with &lt;code&gt;ssh -X&lt;/code&gt; and &lt;code&gt;ssh -Y&lt;/code&gt; to check if I can make the mouse work but without success.  The selection works but the buffers (on the local machine) are not updated with the yank.  The Vim process on the remote machine has a GUI compiled in and there is a Xorg running there, but the Vim process runs on that side of the connection and the Xorg buffers used are on that side.  (Yes, this makes things more complicated.)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there a way to make Vim use the Xorg buffers on the connecting machine?&lt;/li&gt;&#xA;&lt;li&gt;Or, is there a way (in VimScript) to test whether Vim is running in an SSH session as opposed to a local PTY?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2017-03-01T09:11:01.440" Title="How can I use mouse=a for local and remote work?" Tags="|vimrc|mouse|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11584" PostTypeId="1" CreationDate="2017-03-01T01:55:49.063" Score="0" ViewCount="131" Body="&lt;p&gt;I'm writing a syntax highlighter for my test script output. I'm having problems figuring out how to find a match immediately after another match. In the screenshot, notice the $VAR1... is not highlighted at the bottom of the screenshot.&lt;a href=&quot;https://i.stack.imgur.com/CCaki.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CCaki.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;warning&lt;/code&gt; region overlaps the &lt;code&gt;dump&lt;/code&gt; region by one character so I try to back up the &lt;code&gt;warning&lt;/code&gt; region by one character but it doesn't work. Maybe I'm misunderstanding how that is supposed to work. Here is my script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match Good &quot;^ok &quot;&#xA;syn match Bad  &quot;^not ok &quot;&#xA;syn region okline contains=Good start=&quot;^ok&quot; end=&quot;\n&quot;&#xA;syn match comment &quot;^#.*\n&quot;&#xA;syn region dump start=&quot;^$VAR&quot; end=&quot;\s\+};\n\|;\n&quot;&#xA;syn region warning contains=Bad start=&quot;^not ok&quot; end=&quot;^[^#]&quot;re=e-1,he=e-1&#xA;syn match divider &quot;----*&quot;&#xA;hi Good cterm=bold ctermfg=Green&#xA;hi swear ctermbg=red&#xA;hi divider cterm=bold ctermfg=yellow ctermbg=black&#xA;hi dump ctermfg=LightBlue&#xA;hi okline ctermfg=Green&#xA;hi comment ctermfg=Cyan&#xA;hi warning cterm=bold ctermfg=Red&#xA;hi big_warning cterm=bold ctermfg=Red&#xA;hi Bad cterm=bold ctermfg=Red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="2021" LastEditDate="2017-03-01T02:05:55.967" LastActivityDate="2017-03-01T02:46:24.547" Title="Finding a match immediately after another match" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ClosedDate="2017-03-01T06:35:18.437" ContentLicense="CC BY-SA 3.0" />
  <row Id="11585" PostTypeId="2" ParentId="11584" CreationDate="2017-03-01T02:46:24.547" Score="0" Body="&lt;p&gt;Stumbled on the answer after some more searching:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;syn region warning contains=Bad start=&quot;^not ok&quot; end=&quot;^\ze[^#]&quot;re=e-1,he=e-1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Had to slap a &lt;code&gt;\ze&lt;/code&gt; in there. See &lt;a href=&quot;https://vi.stackexchange.com/questions/398/can-vim-syntax-regions-be-made-to-touch-overlap&quot;&gt;Can vim syntax regions be made to touch/overlap?&lt;/a&gt; for reference.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2017-03-01T02:46:24.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11586" PostTypeId="1" AcceptedAnswerId="11600" CreationDate="2017-03-01T08:08:51.653" Score="0" ViewCount="419" Body="&lt;p&gt;I know &lt;code&gt;User1&lt;/code&gt;... &lt;code&gt;User9&lt;/code&gt; colors the status line. I have applied several colors to the statusline to make it easy to recognize, but I wish this is only applied to active panes, not inactive panes. So that inactive panes has monocolor statusline, and is not too distracting. I suppose this is possible if there are two sets of &lt;code&gt;User1&lt;/code&gt;... &lt;code&gt;User9&lt;/code&gt;, one for active panes, one for inactive panes. Is there such function?&lt;/p&gt;&#xA;" OwnerUserId="10241" LastActivityDate="2017-03-10T08:59:21.340" Title="Can I use different User1... User9 colors for active and inactive panes?" Tags="|vim-windows|colorscheme|statusline|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11588" PostTypeId="2" ParentId="11583" CreationDate="2017-03-01T09:11:01.440" Score="3" Body="&lt;p&gt;It works for me. I have &lt;code&gt;ForwardX11 yes&lt;/code&gt; in my ~/.ssh/config file, which should have the same effect as running ssh with &lt;code&gt;-X&lt;/code&gt;, and I started vim on the remote machine as &lt;code&gt;vim -N -u NONE -i NONE&lt;/code&gt; to make sure my configuration wasn't affecting anything, then executed &lt;code&gt;:set mouse=a&lt;/code&gt;. I entered some text into vim, then selected some of it with the mouse, then pasted it into gvim running on the local machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way I test X11 forwarding over SSH is to run &lt;code&gt;xclock &amp;amp;&lt;/code&gt; on the remote machine and verify that the clock appears on the local machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test in a Vim script whether you are running over SSH, you can test for the presence of one of the variables ssh sets on the remote machine, e.g.,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;$SSH_CONNECTION&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-03-01T09:11:01.440" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11589" PostTypeId="1" AcceptedAnswerId="11590" CreationDate="2017-03-01T09:13:33.580" Score="5" ViewCount="1641" Body="&lt;p&gt;I'd like &lt;code&gt;vimdiff&lt;/code&gt; to start with &lt;em&gt;all&lt;/em&gt; the folded sections opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I have tried the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff -c &quot;set nofoldenable&quot; -R &amp;lt;(tree -d directory1) &amp;lt;(tree -d directory2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the &lt;code&gt;-c &quot;set nofoldenable&quot;&lt;/code&gt; being the attempt to achieve what I want. However, that doesn't work, because it only affects the left window, not the right one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to put this into a shell function for convenience, so the length of the actual invocation doesn't matter to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried &lt;code&gt;-c &quot;bufdo set nofoldenable&quot;&lt;/code&gt; which has the desired effect w.r.t. the folded sections, but leads &lt;code&gt;vimdiff&lt;/code&gt; to scroll out of sync and no longer highlights the differences either. So doing this kills all the utility &lt;code&gt;vimdiff&lt;/code&gt; offers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I start &lt;code&gt;vimdiff&lt;/code&gt; and then use the &lt;code&gt;zR&lt;/code&gt; command to open all folded sections.&lt;/p&gt;&#xA;" OwnerUserId="1109" LastActivityDate="2017-03-01T10:30:33.237" Title="How to start Vimdiff without equal sections folded?" Tags="|folding|vimdiff|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11590" PostTypeId="2" ParentId="11589" CreationDate="2017-03-01T10:26:18.080" Score="3" Body="&lt;p&gt;&lt;code&gt;zR&lt;/code&gt; sets &lt;code&gt;foldlevel&lt;/code&gt; to a high value, so try that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff -c &quot;set foldlevel=9999&quot; -R &amp;lt;(tree -d directory1) &amp;lt;(tree -d directory2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-03-01T10:26:18.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11591" PostTypeId="2" ParentId="11589" CreationDate="2017-03-01T10:30:33.237" Score="3" Body="&lt;p&gt;Try using &lt;code&gt;windo&lt;/code&gt; instead of &lt;code&gt;bufdo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff -c &quot;windo set nofoldenable&quot; -R &amp;lt;(tree -d directory1) &amp;lt;(tree -d directory2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-03-01T10:30:33.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11592" PostTypeId="2" ParentId="11566" CreationDate="2017-03-01T14:25:46.257" Score="3" Body="&lt;p&gt;You could use dictionary completion to do this. Basically it completes what you type from a file (as you want). By default it is mapped to &lt;code&gt;i_ctrl-x_ctrl-k&lt;/code&gt; and the dictionary file can be set using &lt;code&gt;set dictionary=fname&lt;/code&gt; where fname is the name of the file containing the words (either absolute or relative to the current directory). If you really want the mapping to be &lt;code&gt;i_ctrl-x_ctrl-i&lt;/code&gt; you could of course remap. Only problem is when you already use a dictionary (e.g. if you &lt;code&gt;set spell&lt;/code&gt;). In that case it would probably be possible to switch dictionaries temporarily, but I'm not sure how that would work. For more information check &lt;code&gt;:help ins-completion&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2017-03-01T14:25:46.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11593" PostTypeId="2" ParentId="11526" CreationDate="2017-03-01T14:35:08.997" Score="4" Body="&lt;p&gt;You need to install a Python version on your system with the same bitness (either 32-bit or 64-bit) as your vim. Python needs to be in your PATH. If you can run it by typing &lt;code&gt;python&lt;/code&gt; on a command prompt you should be good in this regard. Finally vim needs to be compiled to support python, but in my experience most are. Check with &lt;code&gt;:version&lt;/code&gt; and look for &lt;code&gt;python/dyn&lt;/code&gt;. It needs to have a plus in front of it.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2017-03-01T14:35:08.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11594" PostTypeId="1" CreationDate="2017-03-01T15:21:43.533" Score="7" ViewCount="493" Body="&lt;p&gt;The question arise from a problem using a huge remapped configuration so &lt;a href=&quot;https://en.wikipedia.org/wiki/Keyboard_layout#B.C3.89PO&quot; rel=&quot;nofollow noreferrer&quot;&gt;bépo&lt;/a&gt; layout is virtually the same as the qwerty in normal mode, at least for single key press commands. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Selecting text using visual selection mode, then pressing &lt;code&gt;i&lt;/code&gt; which is configured as &lt;code&gt;noremap i d&lt;/code&gt;, it would be expected that the text would be immediately deleted. But it isn't immediately triggered, instead it's waiting for a possible second key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;timeoutlen&lt;/code&gt; to zero will achieve the expected result in this context, but then a command like &lt;code&gt;,,&lt;/code&gt; which is configured as &lt;code&gt;noremap ,, gg&lt;/code&gt; won't work anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is it possible to set timeout specific to one command, or in certain context like in visual selection mode with an active selection?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe having &lt;code&gt;timeoutlen&lt;/code&gt; turned to zero might make things like &lt;code&gt;noremap ,, gg&lt;/code&gt; useless, so just removing this mapping might be enough to achieve the expected result. &lt;/p&gt;&#xA;" OwnerUserId="11597" LastEditorUserId="11597" LastEditDate="2017-03-03T09:15:37.047" LastActivityDate="2017-08-01T20:52:35.707" Title="How do you set no timeout for a specific remap?" Tags="|visual-mode|key-bindings|keyboard-layout|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11595" PostTypeId="1" CreationDate="2017-03-01T17:06:07.320" Score="3" ViewCount="164" Body="&lt;p&gt;I've set &lt;code&gt;switchbuf&lt;/code&gt; to &lt;code&gt;vsplit&lt;/code&gt; but when I use &lt;code&gt;:sbr&lt;/code&gt;, vim uses a horizontal split to open the new buffer. This seems directly contrary to what &lt;code&gt;:help sbr&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sbr[ewind] [+cmd]&#xA;    Split window and go to first buffer in buffer list.  If the&#xA;    buffer list is empty, go to the first unlisted buffer.&#xA;    Respects the 'switchbuf' option.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;:help switchbuf&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   split    If included, split the current window before loading&#xA;        a buffer for a |quickfix| command that display errors.&#xA;        Otherwise: do not split, use current window.&#xA;   vsplit   Just like &quot;split&quot; but split vertically.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;:version&lt;/code&gt; (I'm using Ubuntu 16.04's &lt;code&gt;vim-gtk3-py2&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)&#xA;Included patches: 1-1689&#xA;Extra patches: 8.0.0056&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know about &lt;code&gt;:vert sbr&lt;/code&gt;, and I can make an alias to make that more convenient, but I'd really like to figure out what's causing &lt;code&gt;switchbuf&lt;/code&gt; to not work as expected. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11599" LastEditorUserId="11599" LastEditDate="2017-03-01T17:43:47.537" LastActivityDate="2017-03-01T17:43:47.537" Title=":sbr opens buffers with horizontal split, even with switchbuf set to vsplit" Tags="|split|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11596" PostTypeId="2" ParentId="11532" CreationDate="2017-03-01T17:13:06.480" Score="0" Body="&lt;p&gt;For anyone reading this, I figured out that to move &quot;outside&quot; a set of (), [], or {} can be accomplished with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap ;; &amp;lt;Esc&amp;gt;l%%a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where I choose to use a double-semicolon, because I find in day-to-day typing that I &lt;em&gt;never&lt;/em&gt; use the semicolon unless followed by a space, and its in a really convenient location. Also, while you &lt;strong&gt;can't&lt;/strong&gt; really make arbitrary, multiple-character delimiters work inside of DelimitMate, you &lt;strong&gt;can&lt;/strong&gt; make simple remaps for adding them; an example is my series of maps for bolding text in TeX documents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType tex inoremap &amp;lt;buffer&amp;gt; ;t \textbf{}&amp;lt;Left&amp;gt;&#xA;au FileType tex nnoremap &amp;lt;buffer&amp;gt; ;t mAlbi\textbf{&amp;lt;Esc&amp;gt;ea}&amp;lt;Esc&amp;gt;`A&#xA;au FileType tex vnoremap &amp;lt;buffer&amp;gt; ;t mA&amp;lt;Esc&amp;gt;`&amp;gt;a}&amp;lt;Esc&amp;gt;`&amp;lt;i\textbf{&amp;lt;Esc&amp;gt;`AF\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which bolds the &lt;strong&gt;current word&lt;/strong&gt;, &lt;strong&gt;current selection&lt;/strong&gt;, or just &lt;strong&gt;adds&lt;/strong&gt; a &lt;code&gt;\textbf{}&lt;/code&gt; during insert mode and puts the cursor inside the curly braces. The &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; makes the above maps local to the file being edited, so they won't be carried over e.g. if you are working on a &lt;code&gt;.py&lt;/code&gt; file in another tab.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastActivityDate="2017-03-01T17:13:06.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11597" PostTypeId="1" AcceptedAnswerId="11598" CreationDate="2017-03-01T19:31:56.970" Score="19" ViewCount="18230" Body="&lt;p&gt;What is the syntax for inserting a comment or comments into the vimrc file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having trouble finding this on &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc&quot; rel=&quot;noreferrer&quot;&gt;vim documentation online&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8496" LastEditorUserId="51" LastEditDate="2017-03-02T12:06:58.747" LastActivityDate="2017-03-02T12:06:58.747" Title="How do I insert a comment into my vimrc fie?" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11598" PostTypeId="2" ParentId="11597" CreationDate="2017-03-01T19:47:47.820" Score="17" Body="&lt;p&gt;It's in a different help file (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#:comment&quot; rel=&quot;noreferrer&quot;&gt;cmdline&lt;/a&gt;, &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#:comment&quot; rel=&quot;noreferrer&quot;&gt;help :comment&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *:quote* *:comment*&#xA;'&quot;' at the start of a line causes the whole line to be ignored.  '&quot;'&#xA;after a command causes the rest of the line to be ignored.  This can be used&#xA;to add comments.  Example:&#xA;    :set ai     &quot;set 'autoindent' option&#xA;It is not possible to add a comment to a shell command &quot;:!cmd&quot; or to the&#xA;&quot;:map&quot; command and a few others, because they see the '&quot;' as part of their&#xA;argument.  This is mentioned where the command is explained.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason it's there is because &lt;code&gt;vimrc&lt;/code&gt; is nothing but a sequence of command-line commands. Pretty much everything that applies to command-line mode works in &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of whole-line comment in &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; show tab line always&#xA;set showtabline=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="860" LastActivityDate="2017-03-01T19:47:47.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11599" PostTypeId="2" ParentId="11597" CreationDate="2017-03-01T20:39:09.083" Score="9" Body="&lt;p&gt;You can use &lt;code&gt;&quot;&lt;/code&gt; at the start of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; A comment&#xA;set foo=bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also do this after commands, to ignore the rest of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foo=bar  &quot; A comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, you need to be careful when adding comments after commands. In mappings and &lt;code&gt;:!&lt;/code&gt; commands it's downright impossible: &lt;code&gt;inoremap a b  &quot; Map a to b&lt;/code&gt; won't work. The &quot;comment&quot; is seen as part of the command. The same applies when running shell commands with &lt;code&gt;:!ls  &quot; a comment&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In some other cases it may also cause unexpected behaviour. For example &lt;code&gt;normal! p &quot; A comment&lt;/code&gt; will have the space between the &lt;code&gt;p&lt;/code&gt; and &lt;code&gt;&quot;&lt;/code&gt; inserted, and the comment part &lt;em&gt;may&lt;/em&gt; also be evaluated if Vim guesses it as part of a command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another problem is adding comments in when running multiple commands, which is something I often do in autocommands. For example this won't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype go&#xA;    \  echom &quot;A message&quot;  &#xA;    \  &quot; echo a message&#xA;    \| echom &quot;A second message&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as I know, there is no sane way to get this to work :-/&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are probably other caveats; I chose to not remember them and only use &lt;code&gt;&quot;&lt;/code&gt; at the start of a line :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-03-01T20:39:09.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11600" PostTypeId="2" ParentId="11586" CreationDate="2017-03-01T21:10:47.643" Score="1" Body="&lt;p&gt;Unless I misunderstand the issue you should just use User1-5 for the active and the 6-9 for the inactive one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I use the following in my update function (not complete but you should get the idea):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; active&#xA;let s:a_statusline='%1* %&amp;lt;%f ' &quot; ... etc.&#xA;&quot; inactive&#xA;let s:na_statusline='%6* %&amp;lt;%f ' &quot; ... etc.&#xA;&#xA;function! s:RefreshStatus()&#xA;  for i in range(1, winnr('$'))&#xA;    call setwinvar(i, '&amp;amp;statusline', '%!LaktakGetStatus(' . i . ')')&#xA;  endfor&#xA;endfunction&#xA;&#xA;function! LaktakGetStatus(w)&#xA;  return a:w==winnr() ? s:a_statusline : s:na_statusline&#xA;endfunction&#xA;&#xA;autocmd VimEnter,WinEnter,BufWinEnter * call &amp;lt;SID&amp;gt;RefreshStatus()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-01T21:10:47.643" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11601" PostTypeId="1" CreationDate="2017-03-01T21:59:13.920" Score="12" ViewCount="5437" Body="&lt;p&gt;I am trying to rewrite adding a string to option with variable. The original string is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp+=~/.vim/bundle/Vundle.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following is the working &lt;code&gt;let&lt;/code&gt; way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let MYVIMDIR='/home/loom/foo'&#xA;let &amp;amp;rtp .= ','.expand(MYVIMDIR).'/bundle/Vundle.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am interested how rewrite it with &lt;code&gt;set&lt;/code&gt;. The following code (and some other variations) doesn't work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let MYVIMDIR='/home/loom/foo'&#xA;set rtp+=expand(MYVIMDIR).'/bundle/Vundle.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the right way to use variables in expression with &lt;code&gt;set&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="11516" LastActivityDate="2018-09-21T16:57:56.217" Title="`set` option with variables" Tags="|options|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11602" PostTypeId="1" AcceptedAnswerId="11618" CreationDate="2017-03-01T22:00:39.250" Score="6" ViewCount="1944" Body="&lt;p&gt;I've turned on vim's relative line numbers, it starts from 0 but doing somthing like &lt;code&gt;10dd&lt;/code&gt; means I only get up to line 9, leaving the last one behind (becuase it's 10 including the current line). Yes, I know, It's only a super simple equation (10 + 1) but it's time taken up when I just want to check the number in the gutter and instantly get the number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to change the number the relative numbers start on? From 0 to 1? I've googled but I can't find anything and I did check out VIM's help page on the 'relativenumber' and 'number_relativenumber' sections but I couldn't see anything on it (or I probably missed it if it's there).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there any way to do this or is just not possible?&lt;/p&gt;&#xA;" OwnerUserId="11603" LastActivityDate="2017-03-03T00:22:02.750" Title="In VIM, Change the number that relative lines numbers start from" Tags="|options|line-numbers|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11603" PostTypeId="2" ParentId="11601" CreationDate="2017-03-01T22:28:15.283" Score="16" Body="&lt;p&gt;You could use &lt;code&gt;:exe&lt;/code&gt;, but this is extremely cumbersome to use and you'll need to escape a few things. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to use my own path fixing function. It looked like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe 'set rtp+='.lh#path#fix(somevariable)&#xA;&quot; with standard tools, may be it'd be (untested)&#xA;exe 'set rtp+='.escape(somevariable, ' \|,')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let &amp;amp;rtp = expression&lt;/code&gt; is really our friend.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But indeed, it doesn't play well with &lt;code&gt;+=&lt;/code&gt;. That's why I've came up with &lt;code&gt;lh#path#munge()&lt;/code&gt; that relies on another function &lt;code&gt;lh#list#add_if_new()&lt;/code&gt;. Strictly speaking &lt;code&gt;set +=&lt;/code&gt; is emulated by &lt;code&gt;lh#list#add_if_new()&lt;/code&gt;. &lt;code&gt;munge()&lt;/code&gt; keeps pathnames that do exist, or actually globbing patterns that match things.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Function: lh#path#munge(pathlist, path) {{{3&#xA;function! lh#path#munge(pathlist, path) abort&#xA;  if type(a:pathlist) == type('str')&#xA;    let pathlist = split(a:pathlist, ',')&#xA;    return join(lh#path#munge(pathlist, a:path), ',')&#xA;  else&#xA;    &quot; if filereadable(a:path) || isdirectory(a:path)&#xA;    if ! empty(glob(a:path)) &quot; support '/**' for &amp;amp;tags&#xA;      call lh#list#push_if_new(a:pathlist, a:path)&#xA;    endif&#xA;    return a:pathlist&#xA;  endif&#xA;endfunction&#xA;&#xA;&quot; Function: lh#list#push_if_new(list, value) {{{3&#xA;function! lh#list#push_if_new(list, value) abort&#xA;  if index(a:list, a:value) &amp;lt; 0&#xA;    call add (a:list, a:value)&#xA;  endif&#xA;  return a:list&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They are defined and maintained in &lt;a href=&quot;http://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;noreferrer&quot;&gt;lh-vim-lib&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-03-01T14:33:18.337" LastActivityDate="2018-03-01T14:33:18.337" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11604" PostTypeId="1" AcceptedAnswerId="11608" CreationDate="2017-03-02T00:35:20.097" Score="8" ViewCount="827" Body="&lt;p&gt;I have installed &lt;a href=&quot;http://www.drchip.org/astronaut/vim/#NETRW%20&quot; rel=&quot;noreferrer&quot;&gt;Dr. Chip's &lt;code&gt;netrw&lt;/code&gt;&lt;/a&gt; from his homepage, since it is newer and more often updated than the files that are part of the main Vim distribution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before Vim 8 I always sued the Vimball install method, by opening the &lt;code&gt;.vba&lt;/code&gt; and running &lt;code&gt;:source %&lt;/code&gt;.  But, now that Vim 8 added the packages mechanism I decided to use that.  I have my packages under:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/pack/packages/start/&#xA;~/.vim/pack/packages/opt/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So to install NETRW as a package I did:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim/pack/packages/start/&#xA;wget  http://www.drchip.org/astronaut/vim/vbafiles/netrw.vba.gz&#xA;mkdir netrw.vim&#xA;gunzip netrw.vba.gz&#xA;vim netrw.vba&#xA;:UseVimball ~/.vim/pack/packages/start/netrw.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it installed correctly.  But now when I edit a file and use a &lt;code&gt;netrw&lt;/code&gt; command, say, &lt;code&gt;:Lexplore&lt;/code&gt; I'm not sure which &lt;code&gt;netrw&lt;/code&gt; is being used.  If I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim foo&#xA;:scriptnames&#xA;  1: /etc/vimrc&#xA;  2: /usr/share/vim/vimfiles/archlinux.vim&#xA;  3: ~/.vim/vimrc&#xA;  (...)&#xA; 20: /usr/share/vim/vim80/plugin/netrwPlugin.vim&#xA; 21: /usr/share/vim/vim80/plugin/rrhelper.vim&#xA; 22: /usr/share/vim/vim80/plugin/spellfile.vim&#xA; 23: /usr/share/vim/vim80/plugin/tarPlugin.vim&#xA; 24: /usr/share/vim/vim80/plugin/tohtml.vim&#xA; 25: /usr/share/vim/vim80/plugin/vimballPlugin.vim&#xA; 26: /usr/share/vim/vim80/plugin/zipPlugin.vim&#xA; 27: ~/.vim/pack/packages/start/csv.vim/plugin/csv.vim&#xA; 28: ~/.vim/pack/packages/start/csv.vim/ftdetect/csv.vim&#xA; 29: ~/.vim/pack/packages/start/netrw.vim/plugin/netrwPlugin.vim&#xA; 30: /usr/share/vim/vim80/scripts.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the distribution &lt;code&gt;netrw&lt;/code&gt; runs first (20) and then runs the installed one (29).  If I add &lt;code&gt;packloadall&lt;/code&gt; to my &lt;code&gt;vimrc&lt;/code&gt; the situation changes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: /etc/vimrc&#xA;  2: /usr/share/vim/vimfiles/archlinux.vim&#xA;  3: ~/.vim/vimrc&#xA;  4: ~/.vim/pack/packages/start/csv.vim/plugin/csv.vim&#xA;  5: ~/.vim/pack/packages/start/netrw.vim/plugin/netrwPlugin.vim&#xA;  (...)&#xA; 19: /usr/share/vim/vim80/plugin/gzip.vim&#xA; 20: /usr/share/vim/vim80/plugin/logiPat.vim&#xA; 21: /usr/share/vim/vim80/plugin/manpager.vim&#xA; 22: /usr/share/vim/vim80/plugin/matchparen.vim&#xA; 23: /usr/share/vim/vim80/plugin/netrwPlugin.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the installed &lt;code&gt;netrw&lt;/code&gt; in my directory runs first (5).  Yet, the Vim distribution &lt;code&gt;netrw&lt;/code&gt; still runs (23)!&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Which &lt;code&gt;netrw&lt;/code&gt; will Vim use when I do, say, &lt;code&gt;:Lexplore&lt;/code&gt;?  It appears to use the new (Vimball installed one) for &lt;code&gt;:Lexplore&lt;/code&gt; but I'm not sure since &lt;code&gt;:h pi_netrw&lt;/code&gt; gives me the new document, but &lt;code&gt;:h netrw&lt;/code&gt; gives me the old documentation (the one that comes with Vim).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Running &lt;code&gt;:helptags ~/.vim/pack/packages/start/netrw.vim/doc&lt;/code&gt; does not help with the documentation problem above (i.e. I get sometimes the new one and sometimes the old one).  Is there something I'm doing wrong with this?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Does Vim &lt;em&gt;always&lt;/em&gt; give preference to plugins/scripts/autoload commands that are in &lt;code&gt;$VIM&lt;/code&gt; (default &lt;code&gt;~/.vim&lt;/code&gt;) above the ones in &lt;code&gt;$VIMRUNTIME&lt;/code&gt;?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2017-03-02T16:05:36.393" Title="Vim 8 packages, how do I overwrite a default package?" Tags="|packages|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11605" PostTypeId="2" ParentId="11602" CreationDate="2017-03-02T04:41:00.403" Score="3" Body="&lt;p&gt;You seem to be confusing ranges with counts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;d&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt; &lt;code&gt;c&lt;/code&gt;, etc, take counts, not ranges, so will not work the way you expect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Commands that take a range, such as &lt;code&gt;:substitute&lt;/code&gt;, will work with relative line numbering, the way you seem to want. For example, &lt;code&gt;:.,+10s/^/1 /&lt;/code&gt; will insert a &lt;code&gt;1&lt;/code&gt; at the beginning of the current line, and the next 10 lines, inclusive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To change the start number for relative line numbering would cause problems with using them to calculate ranges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, after additional testing, I've solved your real problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To delete from the current line, to relative line 10, the command you would use is &lt;code&gt;d10j&lt;/code&gt;, &lt;code&gt;'d'&lt;/code&gt;elete, from the current line, for a count of &lt;code&gt;'10'&lt;/code&gt;, in the direction of &lt;code&gt;'j'&lt;/code&gt;, or down.&lt;/p&gt;&#xA;" OwnerUserId="5298" LastEditorUserId="5298" LastEditDate="2017-03-02T19:44:18.707" LastActivityDate="2017-03-02T19:44:18.707" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11607" PostTypeId="1" AcceptedAnswerId="11614" CreationDate="2017-03-02T11:47:02.340" Score="4" ViewCount="288" Body="&lt;p&gt;Whenever I have to do things like this: &lt;code&gt;closeparens = &amp;quot;)]}&amp;quot;&lt;/code&gt; or &lt;code&gt;/[)\]}]/&lt;/code&gt; it messes up the parenthesis tracking of the whole file. I could mitigate this with comments:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# complement to ([{ (this is not at all to help with vim's highlighting)&#xA;local closeparens=&amp;quot;}])&amp;quot;&#xA;&#xA;&#xA;# don't mind me, just gonna put these here: (((&#xA;case $X in&#xA;   a) echo 1 ;;&#xA;   b) echo 2 ;;&#xA;   c) echo 3 ;;&#xA;esac&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I'd rather not modify my code because of my text editor.&lt;/p&gt;&#xA;&lt;p&gt;How would I go about configuring this?&#xA;No need for an easy answer, if I have to modify the gosh darned source code of vim I will. Just any sort of pointer on where to start would be nice.&lt;/p&gt;&#xA;" OwnerUserId="11151" LastEditorUserId="11151" LastEditDate="2022-05-28T02:17:40.187" LastActivityDate="2022-05-28T02:17:40.187" Title="How can I stop [Neo]Vim from tracking parens in certain situations?" Tags="|delimiter-matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11608" PostTypeId="2" ParentId="11604" CreationDate="2017-03-02T12:08:45.277" Score="4" Body="&lt;p&gt;If you look at &lt;code&gt;netrwPlugin.vim&lt;/code&gt; you'll find:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;cp || exists(&quot;g:loaded_netrwPlugin&quot;)&#xA; finish&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So just set this in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:loaded_netrwPlugin = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If they both use the same variable (&lt;code&gt;g:loaded_netrwPlugin&lt;/code&gt;) then they only one can be loaded and it is sufficient to either use &lt;code&gt;packloadall&lt;/code&gt; or source &lt;code&gt;~/.vim/pack/packages/start/netrw.vim/plugin/netrwPlugin.vim&lt;/code&gt; at the end of your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="10337" LastEditDate="2017-03-02T16:05:36.393" LastActivityDate="2017-03-02T16:05:36.393" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11609" PostTypeId="1" AcceptedAnswerId="11611" CreationDate="2017-03-02T13:49:42.223" Score="18" ViewCount="6906" Body="&lt;p&gt;Very often, I write markdown in VIM, and there will be paragraphs in those markdown. To help my editing, I setup my Vim to wrap a line on 80 chars. It works nice if I just keep typing, but the problem is if I need to do some correction, it becomes very annoying. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;demo(taken from wikipedia first order logic):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The adjective &quot;first-order&quot; distinguishes first-order logic from higher-order logic &#xA;in which there are predicates having predicates or functions as arguments. In first-order &#xA;theories, predicates are often associated with sets. In interpreted higher-order &#xA;theories, predicates may be interpreted as sets of sets.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far so good. But when I revise the article, I might decide to add something in the middle, say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The adjective &quot;first-order&quot; distinguishes first-order logic from higher-order logic &#xA;in which there are predicates having predicates or functions as arguments,&#xA;or in which one or both of predicate quantifiers or function quantifiers are permitted.&#xA;In first-order theories, predicates are often associated with sets. In interpreted higher-order&#xA;theories, predicates may be interpreted as sets of sets.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;notice line 3 is the one I want to wrap. If I do it in VIM, I will need to manually join the lines and rewrap the whole paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone got idea how to make VIM do it automatically?&lt;/p&gt;&#xA;" OwnerUserId="1097" LastEditorUserId="51" LastEditDate="2017-03-02T17:05:26.613" LastActivityDate="2019-11-03T07:55:29.897" Title="automatically rewrap lines when writing markdown in VIM" Tags="|formatting|filetype-markdown|word-processing|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11610" PostTypeId="2" ParentId="11609" CreationDate="2017-03-02T15:11:18.433" Score="1" Body="&lt;p&gt;I would have a look at &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27textwidth%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'textwidth'&lt;/code&gt;&lt;/a&gt;. It will automatically break lines as you type. However this doesn't work if you're editing the middle of a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally prefer to leave &lt;code&gt;textwidth&lt;/code&gt; off so I created a function that will auto join and split a paragraph. (Basically auto format it to 80 characters) It looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ParagraphToEightyChars()&#xA;   while (len(getline(&quot;.&quot;)) &amp;gt; 80)&#xA;      normal! 0&#xA;      &quot; Find the first white-space character before the 81st character.&#xA;      call search('\(\%81v.*\)\@&amp;lt;!\s\(.*\s.\{-}\%81v\)\@!', 'c', line('.'))&#xA;      &quot; Replace it with a new line.&#xA;      exe &quot;normal! r\&amp;lt;CR&amp;gt;&quot;&#xA;      &quot; If the next line has words, join it to avoid weird paragraph breaks.&#xA;      if (getline(line('.')+1) =~ '\w')&#xA;         normal! J&#xA;      endif&#xA;   endwhile&#xA;   &quot; Trim any accidental trailing whitespace&#xA;   :s/\s\+$//e&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then have a mapping to call it whenever I need it: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;A-J&amp;gt; :call ParagraphToEightyChars()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function works great with &lt;code&gt;formatoptions+=jr&lt;/code&gt; for formatting comments in code too! Just put your cursor on the first line that's longer than 80 chars and call the function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;(Note: I've not made this function general to do lengths other than 80, but I think you only need to change the 80 and 81s if you want to make it something else)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27textwidth%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'textwidth'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27formatoptions%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'formatoptions'&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-03-02T15:11:18.433" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11611" PostTypeId="2" ParentId="11609" CreationDate="2017-03-02T16:47:15.150" Score="17" Body="&lt;p&gt;Even simpler: the &lt;code&gt;a&lt;/code&gt; flag for &lt;code&gt;'formatoptions'&lt;/code&gt; enables automatic formatting of paragraphs whenever text is inserted or deleted. See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#fo-table&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help fo-table&lt;/code&gt;&lt;/a&gt; for details on &lt;code&gt;'formatoptions'&lt;/code&gt; flags and &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#autoformat&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help autoformat&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatoptions+=a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#gq&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;gq&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#gw&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;gw&lt;/code&gt;&lt;/a&gt; will format the lines that the following motion moves over.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Formatting is done with one of three methods:&#xA;                1. If 'formatexpr' is not empty the expression is&#xA;                   evaluated.  This can differ for each buffer.&#xA;                2. If 'formatprg' is not empty an external program&#xA;                   is used.&#xA;                3. Otherwise formatting is done internally.&#xA;&#xA;                In the third case the 'textwidth' option controls the&#xA;                length of each formatted line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The difference between the two, is that &lt;code&gt;gq&lt;/code&gt; will leave the cursor on the first non-blank of the last formatted line. &lt;code&gt;gw&lt;/code&gt; will put the cursor back where it started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can easily manually rewrap the paragraph your cursor is currently in with &lt;code&gt;gwap&lt;/code&gt;, or the entire document with &lt;code&gt;gggwG&lt;/code&gt;, though that will move your cursor thanks to the leading &lt;code&gt;gg&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With an autocommand, you can have formatting happen automatically. Here's an example that formats the current paragraph when leaving insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup myformatting&#xA;    autocmd!&#xA;    autocmd InsertLeave * normal gwap&amp;lt;CR&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are other autocommand triggers that you may find work better for you. You can explore the options under &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-events&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help autocmd-events&lt;/code&gt;&lt;/a&gt;. The most relevant ones are probably under the &quot;various&quot; subheading.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastEditorUserId="2736" LastEditDate="2017-03-02T17:02:10.243" LastActivityDate="2017-03-02T17:02:10.243" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11612" PostTypeId="2" ParentId="11594" CreationDate="2017-03-02T18:50:55.863" Score="3" Body="&lt;p&gt;It sounds like you have something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap i d&#xA;noremap ix ... other mappings starting with i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you are asking that for &lt;code&gt;i&lt;/code&gt; the timeout is 0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case you would never be able to type any of the &lt;code&gt;ix&lt;/code&gt; mappings - so why not just remove them and solve the problem this way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is only for visual mode then avoid defining mappings that start with &lt;code&gt;i&lt;/code&gt; for that mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can remove the mappings you mentioned in the comments with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xunmap iM&#xA;xunmap im&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="10337" LastEditDate="2017-03-04T18:05:17.207" LastActivityDate="2017-03-04T18:05:17.207" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11614" PostTypeId="2" ParentId="11607" CreationDate="2017-03-02T21:42:15.853" Score="2" Body="&lt;p&gt;You are looking for &lt;a href=&quot;http://vimawesome.com/plugin/matchit-zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;matchit-zip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The matchit.vim script allows you to configure % to match more than just single characters.  You can match words and even regular expressions. &lt;strong&gt;Also, matching treats strings and comments (as recognized by the syntax highlighting mechanism) intelligently.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;also:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Since vim 6.0, matchit.vim has been included in the standard vim distribution, under the macros/ directory&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;but IMO it's easier to install the plugin linked above.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-02T21:42:15.853" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11616" PostTypeId="2" ParentId="11560" CreationDate="2017-03-03T00:09:17.807" Score="0" Body="&lt;p&gt;After a bit of fiddling around and reading a whole lot of vimscript docs/blog posts, this is what I came up with (starting with the accepted answer as the starting point):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! VimDjangoCompletion()&#xA;    let matches = matchlist(getline('.'), '{%\s\+\(block\|if\|for\)')&#xA;    return empty(matches) ? &quot;%}&quot; : &quot;%}\n{% end&quot; . matches[1] . &quot; %}\&amp;lt;ESC&amp;gt;O&quot;&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;buffer&amp;gt; %} &amp;lt;C-R&amp;gt;=VimDjangoCompletion()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: As @luc-hermitte points out in the comment below, mapping &lt;code&gt;%}&lt;/code&gt; is a false good idea, since vim introduces a delay waiting for the next character when &lt;code&gt;%&lt;/code&gt; is typed. I initially added that to avoid having the function being called for every instance of &lt;code&gt;}&lt;/code&gt; (including when typing &lt;code&gt;{{ ... }}&lt;/code&gt; which probably is more common than directives in django templates). However, trading off unnecessary function calls to avoid the delay appears to be a good thing because the delay can get slightly annoying. I'm leaving the code as is to give context for @luc-hermitte's comment.&lt;/p&gt;&#xA;" OwnerUserId="11553" LastEditorUserId="11553" LastEditDate="2017-03-03T09:16:17.603" LastActivityDate="2017-03-03T09:16:17.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11617" PostTypeId="1" CreationDate="2017-03-03T00:11:22.710" Score="4" ViewCount="2601" Body="&lt;p&gt;Im running terminal vim, and when a syntax highlighted file is loaded and I have a colorscheme active and I run this command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi Normal ctermbg=2 ctermfg=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ALL&lt;/strong&gt; text in the window changes, not just text belonging to the &lt;code&gt;Normal&lt;/code&gt; group changes. It looks like alot of it reverts back to the vim default 8 color terminal colors.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something special about &lt;code&gt;Normal&lt;/code&gt; does setting it trigger some autocommand that resets all syntax?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does modifying the &lt;code&gt;Normal&lt;/code&gt; highlight group colors affect all these other highlight groups?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2017-04-02T03:30:40.267" Title="Why does modifying the `Normal` highlight group affect syntax not belonging to the highlight group?" Tags="|syntax-highlighting|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11618" PostTypeId="2" ParentId="11602" CreationDate="2017-03-03T00:22:02.750" Score="2" Body="&lt;p&gt;Well, vim is open source.  If you clone it from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/vim/vim.git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can make the following changes to src/screen.c to do what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diff --git a/src/screen.c b/src/screen.c&#xA;index 20a778a68..38d4368a9 100644&#xA;--- a/src/screen.c&#xA;+++ b/src/screen.c&#xA;@@ -2521,8 +2521,8 @@ fold_line(&#xA;        else&#xA;        {&#xA;        /* 'relativenumber', don't use negative numbers */&#xA;-       num = labs((long)get_cursor_rel_lnum(wp, lnum));&#xA;-       if (num == 0 &amp;amp;&amp;amp; wp-&amp;gt;w_p_nu &amp;amp;&amp;amp; wp-&amp;gt;w_p_rnu)&#xA;+       num = labs((long)get_cursor_rel_lnum(wp, lnum)) + 1;&#xA;+       if (num == 1 &amp;amp;&amp;amp; wp-&amp;gt;w_p_nu &amp;amp;&amp;amp; wp-&amp;gt;w_p_rnu)&#xA;        {&#xA;            /* 'number' + 'relativenumber': cursor line shows absolute&#xA;             * line number */&#xA;@@ -3745,8 +3745,8 @@ win_line(&#xA;            else&#xA;            {&#xA;                /* 'relativenumber', don't use negative numbers */&#xA;-               num = labs((long)get_cursor_rel_lnum(wp, lnum));&#xA;-               if (num == 0 &amp;amp;&amp;amp; wp-&amp;gt;w_p_nu &amp;amp;&amp;amp; wp-&amp;gt;w_p_rnu)&#xA;+               num = labs((long)get_cursor_rel_lnum(wp, lnum)) + 1;&#xA;+               if (num == 1 &amp;amp;&amp;amp; wp-&amp;gt;w_p_nu &amp;amp;&amp;amp; wp-&amp;gt;w_p_rnu)&#xA;                {&#xA;                /* 'number' + 'relativenumber' */&#xA;                num = lnum;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But sorry, examining the source confirms there's no existing option available to do what you want.&lt;/p&gt;&#xA;" OwnerUserId="780" LastActivityDate="2017-03-03T00:22:02.750" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11619" PostTypeId="2" ParentId="11617" CreationDate="2017-03-03T02:59:19.893" Score="4" Body="&lt;p&gt;&lt;code&gt;:h :hi-normal-cterm&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When setting the &quot;ctermfg&quot; or &quot;ctermbg&quot; colors for the Normal group,&#xA;      these will become the colors used for the non-highlighted text.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is the same case for &lt;code&gt;guifg&lt;/code&gt; and &lt;code&gt;guibg&lt;/code&gt;, but, it's assumed you already know this in &lt;code&gt;:h :hi-normal&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you are running in the GUI, you can get white text on a black background&#xA;  with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight Normal guibg=Black guifg=White&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Normal&lt;/code&gt; is the base highlight group.  Any highlight that doesn't define a field inherits &lt;code&gt;Normal&lt;/code&gt;'s.  For example, run &lt;code&gt;:highlight&lt;/code&gt;, and you will see that not everything defines &lt;code&gt;ctermfg&lt;/code&gt; or &lt;code&gt;ctermbg&lt;/code&gt;.  For groups that don't define &lt;code&gt;ctermbg&lt;/code&gt;, they will take &lt;code&gt;Normal&lt;/code&gt;'s &lt;code&gt;ctermbg=2&lt;/code&gt;.  If &lt;code&gt;Normal&lt;/code&gt; doesn't define that field, it won't set a background color and your terminal's background will show through.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ALL text in the window changes, not just text belonging to the Normal group changes.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Normal&lt;/code&gt; is not defined by syntax.  It's a highlight for &lt;em&gt;normal&lt;/em&gt;, unstyled text.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-03-03T02:59:19.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11620" PostTypeId="1" AcceptedAnswerId="11625" CreationDate="2017-03-03T04:02:06.177" Score="5" ViewCount="138" Body="&lt;p&gt;In my &lt;code&gt;~/.vimrc&lt;/code&gt; if I write &lt;code&gt;set tabstop = 2&lt;/code&gt;, it will be a syntax error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop = 2 &quot; E521: Number required after =: tabstop =&#xA;set tabstop=2   &quot; no errors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I can write &lt;code&gt;let @/ = &quot;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @/ = &quot;&quot; &quot; no errors&#xA;let @/=&quot;&quot;   &quot; no errors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why are they different?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Reading the help menu for both &lt;code&gt;:h let&lt;/code&gt; and &lt;code&gt;:h set&lt;/code&gt; you can find examples using the proper syntax; however, I'm still curious why they are different.&lt;/p&gt;&#xA;" OwnerUserId="11605" LastEditorUserId="205" LastEditDate="2017-03-03T05:05:24.387" LastActivityDate="2017-03-03T08:31:25.230" Title="Why is it okay to have a space in a `let` statement?" Tags="|history-of|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11621" PostTypeId="1" AcceptedAnswerId="11622" CreationDate="2017-03-03T04:56:45.460" Score="7" ViewCount="447" Body="&lt;p&gt;When searching the help for &quot;count&quot;, &lt;code&gt;:h count&lt;/code&gt; I'm shown the help page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *count* *[count]*&#xA;[count] An optional number that may precede the command to multiply&#xA;        or iterate the command.  If no number is given, a count of one&#xA;        is used, unless otherwise noted.  Note that in this manual the&#xA;        [count] is not mentioned in the description of the command,&#xA;        but only in the explanation.  This was done to make the&#xA;        commands easier to look up.  If the 'showcmd' option is on,&#xA;        the (partially) entered count is shown at the bottom of the&#xA;        window.  You can use &amp;lt;Del&amp;gt; to erase the last digit (|N&amp;lt;Del&amp;gt;|).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm curious, what is the notation &lt;code&gt;*count* *[count]*&lt;/code&gt; telling me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More specifically:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What is the significance of the asterisk &lt;code&gt;*&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;What do the lack or presence of brackets &lt;code&gt;[]&lt;/code&gt; mean?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11605" LastEditorUserId="205" LastEditDate="2017-03-03T07:41:14.957" LastActivityDate="2017-03-03T07:41:14.957" Title="What does `*foo* *[foo]*` mean in the vim help system?" Tags="|help-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11622" PostTypeId="2" ParentId="11621" CreationDate="2017-03-03T06:53:41.297" Score="6" Body="&lt;p&gt;The meaning of the &lt;code&gt;*&lt;/code&gt; (or more specifically &lt;code&gt;*word*&lt;/code&gt;) is, that this defines a help tag you can jump to. So if you enter &lt;code&gt;:h count&lt;/code&gt; Vim knows where to get you to have you read about the count. This also matters for completion and highlighting (by default the &lt;code&gt;*&lt;/code&gt; will be concealed so it won't be visible). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you write a help document and you want to reference such a word, it is written within &lt;code&gt;|word|&lt;/code&gt; so that you can put your cursor on word and press &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt; and Vim will jump to the definition of the word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe the notation &lt;code&gt;[word]&lt;/code&gt; is just a denotion for the word being optionally for certain commands, e.g. look at &lt;code&gt;:h J&lt;/code&gt; and see how it talks about [count] (if it is not given a default of 1 is being assumed (except for joining lines where a default of 2 is used)).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-03-03T06:53:41.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11623" PostTypeId="1" CreationDate="2017-03-03T07:57:02.090" Score="4" ViewCount="707" Body="&lt;p&gt;I use netrw &lt;code&gt;:Lexplore&lt;/code&gt; as my file browser and I also use vim sessions. However, whenever I open a session file, &lt;code&gt;:Lexplore&lt;/code&gt; is closed and I have to re-open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to keep netrw &lt;code&gt;:Lexplore&lt;/code&gt; open on session save / restore?&lt;/p&gt;&#xA;" OwnerUserId="11633" LastEditorUserId="6698" LastEditDate="2017-08-07T04:35:17.703" LastActivityDate="2017-08-07T04:35:17.703" Title="How could I preserve netrw :Lexplore in Vim sessions?" Tags="|netrw|sessions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11624" PostTypeId="1" AcceptedAnswerId="11627" CreationDate="2017-03-03T08:19:47.807" Score="3" ViewCount="1521" Body="&lt;p&gt;I use Vim from this ppa&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ppa.launchpad.net/jonathonf/vim/ubuntu&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://ppa.launchpad.net/jonathonf/vim/ubuntu&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which includes netrw v156&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I update to a newer netrw&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--&gt; Do I have to remove netrw installed&lt;br&gt;&#xA;--&gt; Can I simply install a newer netrw in .vim/plugins and this will take precedence over the system-wide one?&lt;/p&gt;&#xA;" OwnerUserId="11633" LastActivityDate="2017-03-03T14:56:18.690" Title="Update netrw to newer version" Tags="|netrw|" AnswerCount="1" CommentCount="0" ClosedDate="2017-03-05T23:48:56.670" ContentLicense="CC BY-SA 3.0" />
  <row Id="11625" PostTypeId="2" ParentId="11620" CreationDate="2017-03-03T08:20:02.453" Score="2" Body="&lt;pre&gt;&lt;code&gt;                                                :set-args E487 E521&#xA;:se[t] {option}={value}         or&#xA;:se[t] {option}:{value}&#xA;                        Set string or number option to {value}.&#xA;                        For numeric options the value can be given in decimal,&#xA;                        hex (preceded with 0x) or octal (preceded with '0').&#xA;                        The old value can be inserted by typing 'wildchar' (by&#xA;                        default this is a &amp;lt;Tab&amp;gt; or CTRL-E if 'compatible' is&#xA;                        set).  See cmdline-completion.&#xA;                        White space between {option} and '=' is allowed and&#xA;                        will be ignored.  White space between '=' and {value}&#xA;                        is not allowed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See the last two sentences. &lt;code&gt;let&lt;/code&gt; does not have this limitation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you &lt;code&gt;set&lt;/code&gt; a string with &lt;code&gt;set option = value&lt;/code&gt;, Vim does not use quotes, so  how would it know if you mean &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;value&quot;&lt;/code&gt; or &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot; value&quot;&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="10337" LastEditDate="2017-03-03T08:31:25.230" LastActivityDate="2017-03-03T08:31:25.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11626" PostTypeId="1" AcceptedAnswerId="11650" CreationDate="2017-03-03T14:32:10.250" Score="0" ViewCount="45" Body="&lt;p&gt;Is there something similar in Vim? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://packagecontrol.io/packages/InstaGoogling&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://packagecontrol.io/packages/InstaGoogling&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerDisplayName="user11452" LastEditorDisplayName="user11452" LastEditDate="2017-03-04T15:06:49.277" LastActivityDate="2017-03-04T22:16:17.610" Title="InstaGoogling as plugin" Tags="|plugin-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11627" PostTypeId="2" ParentId="11624" CreationDate="2017-03-03T14:56:18.690" Score="5" Body="&lt;p&gt;Newrw is distributed as a Vimball. After you download the new version, move netrw.vba.gz to ~/.vim. Then open it with vim, e.g.,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim netrw.vba.gz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will see this message at the bottom of the screen:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;***vimball*** Source this file to extract it! (:so %)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Execute &lt;code&gt;:so %&lt;/code&gt; and the plugin files will be extracted into the autoload, doc, plugin and syntax subdirectories of your ~/.vim directory. The next time you start Vim, it will automatically use the new version of netrw. You don't have to do anything with old version of netrw.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-03-03T14:56:18.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11628" PostTypeId="1" AcceptedAnswerId="11630" CreationDate="2017-03-03T15:31:03.370" Score="5" ViewCount="5962" Body="&lt;p&gt;I occasionally open a file with vim and see something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&amp;lt;file name&amp;gt;&quot; [Incomplete last line][dos format] 71 lines, 2912 characters&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand all of that information except &lt;code&gt;Incomplete last line&lt;/code&gt;. I realize this just means that there isn't a line termination character on the last line, and I know if I resave the file and reopen it, that message goes away, which implies that vim automatically adds the line termination character if it isn't already present. My question is: why does this matter, and why does vim bother to tell me about it?&lt;/p&gt;&#xA;" OwnerUserId="3338" LastActivityDate="2017-03-03T15:58:34.597" Title="What is the significance of &quot;Incomplete last line&quot; when opening a file?" Tags="|formatting|line-breaks|load|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11629" PostTypeId="1" CreationDate="2017-03-03T15:51:20.683" Score="3" ViewCount="2732" Body="&lt;p&gt;I'm trying to understand and eventually fix the following behavior: when I save a file using VIM, it triggers the &lt;code&gt;change&lt;/code&gt;/&lt;code&gt;write&lt;/code&gt; event twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Ubuntu 16.10, and I created an empty &lt;code&gt;.vimrc&lt;/code&gt; file to make sure that no plugins create this behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I open the &lt;code&gt;foo.txt&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u .vimrc foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then using &lt;code&gt;inotify-tools&lt;/code&gt; (installed using &lt;code&gt;sudo apt install inotify-tools&lt;/code&gt;) I run the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inotifywait -m foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in VIM I do &lt;code&gt;:w&lt;/code&gt;, triggering the save. I can see the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ inotifywait -m foo.txt &#xA;Setting up watches.&#xA;Watches established.&#xA;foo.txt OPEN &#xA;foo.txt ACCESS &#xA;foo.txt CLOSE_NOWRITE,CLOSE &#xA;foo.txt MODIFY &#xA;foo.txt OPEN &#xA;foo.txt MODIFY &#xA;foo.txt CLOSE_WRITE,CLOSE &#xA;foo.txt ATTRIB &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After setting &lt;code&gt;backupcopy=yes&lt;/code&gt; I can see EXACTLY the same behavior. I tried to add it in the &lt;code&gt;vimrc&lt;/code&gt; and restart VIM, but there was no change at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everyone on the internet recommends using &lt;code&gt;backupcopy=yes&lt;/code&gt; which for some reason doesn't fix the issue on my machine. Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any other workaround?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In my original &lt;code&gt;~/.vimrc&lt;/code&gt; I do have this at the end of the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Node.js fs.watch&#xA;set backupdir=~/.vim/tmp,.&#xA;set directory=~/.vim/tmp,.&#xA;set backupcopy=yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doesn't seem to make any change (I do have the &lt;code&gt;~/.vim/tmp&lt;/code&gt; dir).&lt;/p&gt;&#xA;" OwnerUserId="449" LastEditorUserId="449" LastEditDate="2017-03-04T19:28:50.587" LastActivityDate="2020-02-23T00:12:56.583" Title="set backupcopy=yes doesn't still writes the file twice" Tags="|vimrc|buffers|save|backup|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11630" PostTypeId="2" ParentId="11628" CreationDate="2017-03-03T15:58:34.597" Score="8" Body="&lt;p&gt;The Unix convention is that a line is a sequence of zero or more characters ending with a newline character. A text file is a sequence of such lines. This is just a convention, but adhering to that convention allows text-processing tools to work together. It avoids problems of ambiguity in commands such as &lt;code&gt;cat foo bar&lt;/code&gt; when the last character of &lt;code&gt;foo&lt;/code&gt; is not a newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A sequence of characters that does not end with a newline is not a &quot;line&quot;, in this sense. It is incomplete and some tools will not process it as the user might expect. Vim warns you about it because it is a potential problem and fixes it because Vim attempts to write proper files.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-03-03T15:58:34.597" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11631" PostTypeId="1" AcceptedAnswerId="11632" CreationDate="2017-03-03T16:55:20.073" Score="1" ViewCount="933" Body="&lt;p&gt;vim 7.4 console mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When in insert mode, I would like to turn off the ugly yellow when I am in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My background is set to light, so vim should not use a light yellow for anything.&lt;/p&gt;&#xA;" OwnerUserId="11639" LastActivityDate="2017-03-03T17:20:20.813" Title="turn off &quot;-- INSERT --&quot; color" Tags="|insert-mode|colorscheme|statusline|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11632" PostTypeId="2" ParentId="11631" CreationDate="2017-03-03T17:20:20.813" Score="4" Body="&lt;p&gt;Put&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi clear ModeMsg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your &lt;code&gt;vimrc&lt;/code&gt; or color file.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-03-03T17:20:20.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11633" PostTypeId="1" AcceptedAnswerId="11634" CreationDate="2017-03-03T17:40:31.980" Score="1" ViewCount="2767" Body="&lt;p&gt;Everywhere the highlight shows bold, it has a color of light yellow on my white background. This is not bold. Its unreadable. Is there anywhere I can change this color? I can clear the highlight where it is set, but it may be easier to change its color entirely. &lt;/p&gt;&#xA;" OwnerUserId="11639" LastActivityDate="2017-03-03T18:47:21.823" Title="vim setting bold color hightlight" Tags="|highlight|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11634" PostTypeId="2" ParentId="11633" CreationDate="2017-03-03T18:47:21.823" Score="4" Body="&lt;p&gt;I assume you are running Vim in a terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every terminal can interpret &lt;em&gt;bold&lt;/em&gt; differently. For example on OS X there is a setting &quot;Use bright colors for bold text&quot;. So you should check the preferences of your terminal.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-03T18:47:21.823" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11635" PostTypeId="2" ParentId="11550" CreationDate="2017-03-03T20:03:18.047" Score="0" Body="&lt;p&gt;So, I decided to have original &lt;code&gt;~/.vim/&lt;/code&gt; directory empty and to create special &lt;code&gt;.vimrc.XXX&lt;/code&gt; and &lt;code&gt;.vim.XXX/&lt;/code&gt; for each project. For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/loom/&#xA;    ├── .vims/&#xA;    │   ├── .vim.foo/&#xA;    │   └── .vim.bar/&#xA;    ├── .vimrc.foo&#xA;    └── .vimrc.bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First lines of original &lt;code&gt;.vimrc&lt;/code&gt; looks like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;filetype off&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For original &lt;code&gt;~/.vimrc&lt;/code&gt; &lt;code&gt;:echo &amp;amp;rtp&lt;/code&gt; returns &lt;code&gt;/home/loom/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,/home/loom/.vim/after&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I need to redefine &lt;code&gt;rtp&lt;/code&gt;. The following is the first lines of new &lt;code&gt;~/.vimrc.foo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;filetype off&#xA;&#xA;let MYVIMDIR='/home/loom/.vims/.vim.foo'&#xA;let &amp;amp;rtp=expand(MYVIMDIR).','.expand($VIM).'/vimfiles,'.expand($VIMRUNTIME).','.expand($VIM).'/vimfiles/after'.expand(MYVIMDIR).'/after'&#xA;&#xA;let &amp;amp;rtp .= ','.expand(MYVIMDIR).'/bundle/Vundle.vim'&#xA;call vundle#begin(expand(MYVIMDIR).'/bundle')&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other lines was left unchanged, except possible minor paths fixes&lt;/p&gt;&#xA;" OwnerUserId="11516" LastEditorUserId="11516" LastEditDate="2017-03-04T08:18:49.947" LastActivityDate="2017-03-04T08:18:49.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11636" PostTypeId="1" AcceptedAnswerId="11728" CreationDate="2017-03-03T20:26:16.013" Score="3" ViewCount="605" Body="&lt;p&gt;I'm trying to set up Neomake to only use GCC as a checker, plus some options. Having looked at the documentation, I wrote this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:neomake_c_enabled_makers=['gcc']&#xA;&#xA;let g:neomake_gcc_args=[&#xA;      \ '-fsyntax-only',&#xA;      \ '-std=c99',&#xA;      \ '-Wall',&#xA;      \ '-Wextra',&#xA;      \ '-Wpedantic',&#xA;      \ '-fopenmp',&#xA;      \ '-I.'&#xA;      \ ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I open a &lt;code&gt;.c&lt;/code&gt; file and try to have it checked, I get no results, even if there are obvious syntactic errors. Did I miss something obvious here?&lt;/p&gt;&#xA;" OwnerUserId="11640" LastActivityDate="2017-07-10T21:51:37.133" Title="Setting GCC to be the only checker for Neomake" Tags="|plugin-neomake|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11637" PostTypeId="1" AcceptedAnswerId="11641" CreationDate="2017-03-03T21:40:03.233" Score="0" ViewCount="1136" Body="&lt;p&gt;I want to write a command that replaces all of a line's spaces with &lt;a href=&quot;https://en.wikipedia.org/wiki/Figure_space&quot; rel=&quot;nofollow noreferrer&quot;&gt;figure spaces&lt;/a&gt;, and I want the code to not use those literal characters so it is more legible than &lt;code&gt;:s/ / /g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, naturally, I try various iterations like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\x20/\u2007/g      &quot; matches a hex char then &quot;20&quot;, adds uppercase &quot;2007&quot;&#xA;:s/\%u20/\%u2007/g&#xA;:s/[\x20]/\\%u2007/g&#xA;:s/[\x20]/^Vu2007/g                &quot; that's a literal &amp;lt;Ctrl-V&amp;gt;&#xA;:s/\%u20/\=printf(&quot;%c&quot;, 0x2007)/g  &quot; gives me ^G instead&#xA;:s/\%u20/\=&quot;\&amp;lt;Char-0x2007&amp;gt;&quot;/g      &quot; gives me &amp;lt;e2&amp;gt;&amp;lt;80&amp;gt;&amp;lt;fe&amp;gt;X&amp;lt;87&amp;gt; instead&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;None of these work, though all of the patterns do indeed match spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see lots of tricks around for how to enter Unicode characters in Insert mode, but none about how to do so in a replacement string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In researching this question, I found &lt;a href=&quot;https://vi.stackexchange.com/questions/2299/how-to-translate-unicode-escape-sequences-to-the-unicode-character&quot;&gt;How to translate Unicode escape sequences to the Unicode character&lt;/a&gt;, which gives me the following functional solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\%u20/\=nr2char(0x2007)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there really no cleaner way to do this?  I assume that's unnecessarily costly.&lt;/p&gt;&#xA;" OwnerUserId="6505" LastEditorUserId="6505" LastEditDate="2017-03-03T23:52:24.707" LastActivityDate="2017-03-03T23:52:24.707" Title="How to replace a character with another character by character code" Tags="|substitute|unicode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11638" PostTypeId="1" AcceptedAnswerId="12067" CreationDate="2017-03-03T22:19:51.893" Score="2" ViewCount="7504" Body="&lt;p&gt;I want to have multiple lines of text appear in one cell (one row and one column).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vimwiki it looks adequate.  However, when I convert Vimwiki to HTML, each sentence gets its own row.  So I know I am not getting it right, but I have not yet been able to figure out what I am missing.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;MWE&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This vimwiki text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;= Test =&#xA;&#xA;Regular Text&#xA;&#xA;    Blockquote&#xA;&#xA;| Special Table               |&#xA;|-----------------------------|&#xA;| First Sentence              |&#xA;| Second Sentence, same cell. |&#xA;| Third Sentence, same cell.  |&#xA;|                             |&#xA;|                             |  &#xA;&#xA;Regular text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;produces this HTML:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;p&amp;gt;&#xA;Regular Text&#xA;&amp;lt;/p&amp;gt;&#xA;&amp;lt;blockquote&amp;gt;&#xA;Blockquote&#xA;&amp;lt;/blockquote&amp;gt;&#xA;&#xA;&amp;lt;table&amp;gt;&#xA;&amp;lt;tr&amp;gt;&#xA;&amp;lt;th&amp;gt;&#xA;Special Table&#xA;&amp;lt;/th&amp;gt;&#xA;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&#xA;&amp;lt;td&amp;gt;&#xA;First Sentence&#xA;&amp;lt;/td&amp;gt;&#xA;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&#xA;&amp;lt;td&amp;gt;&#xA;Second Sentence, same cell.&#xA;&amp;lt;/td&amp;gt;&#xA;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&#xA;&amp;lt;td&amp;gt;&#xA;Third Sentence, same cell.&#xA;&amp;lt;/td&amp;gt;&#xA;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&#xA;&amp;lt;td&amp;gt;&#xA;&amp;amp;nbsp;&#xA;&amp;lt;/td&amp;gt;&#xA;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&#xA;&amp;lt;td&amp;gt;&#xA;&amp;amp;nbsp;&#xA;&amp;lt;/td&amp;gt;&#xA;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;/table&amp;gt;&#xA;&#xA;&amp;lt;p&amp;gt;&#xA;Regular text&#xA;&amp;lt;/p&amp;gt;&#xA;&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want HTML to look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;p&amp;gt;&#xA;Regular Text&#xA;&amp;lt;/p&amp;gt;&#xA;&amp;lt;blockquote&amp;gt;&#xA;Blockquote&#xA;&amp;lt;/blockquote&amp;gt;&#xA;&#xA;&amp;lt;table&amp;gt;&#xA;&amp;lt;tr&amp;gt;&#xA;&amp;lt;th&amp;gt;&#xA;Special Table&#xA;&amp;lt;/th&amp;gt;&#xA;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;tr&amp;gt;&#xA;&amp;lt;td&amp;gt;&#xA;First Sentence&amp;lt;br&amp;gt;&#xA;Second Sentence, same cell.&amp;lt;br&amp;gt;&#xA;Third Sentence, same cell.&amp;lt;br&amp;gt;&#xA;&amp;amp;nbsp;&#xA;&amp;amp;nbsp;&#xA;&amp;lt;/td&amp;gt;&#xA;&amp;lt;/tr&amp;gt;&#xA;&amp;lt;/table&amp;gt;&#xA;&#xA;&amp;lt;p&amp;gt;&#xA;Regular text&#xA;&amp;lt;/p&amp;gt;&#xA;&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have read the help pages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If you set &amp;gt; in a cell, the cell spans the left column.&#xA;If you set \/ in a cell, the cell spans the above row&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have not been able to use those details to produce the output I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I tell Vimwiki to put all of those lines of text into one single table cell?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="51" LastEditDate="2017-03-08T01:41:09.700" LastActivityDate="2017-04-12T04:55:36.900" Title="How to place multiple lines of text in one single table cell in vimwiki?" Tags="|plugin-vimwiki|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11639" PostTypeId="2" ParentId="11638" CreationDate="2017-03-03T22:45:54.797" Score="2" Body="&lt;p&gt;The vimwiki syntax does not support what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use &lt;code&gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;\/&lt;/code&gt; you are giving the left/above column more space but the text has to be written there and may not span multiple lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/vimwiki/vimwiki/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;You could ask for this feature on GitHub&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-03T22:45:54.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11640" PostTypeId="2" ParentId="11626" CreationDate="2017-03-03T22:51:19.457" Score="1" Body="&lt;p&gt;Install &lt;a href=&quot;https://github.com/tyru/open-browser.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;'tyru/open-browser.vim'&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And add the map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F1&amp;gt; &amp;lt;Plug&amp;gt;(openbrowser-search)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will allow you to search the word under the cursor or your selection.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="10337" LastEditDate="2017-03-04T21:53:50.217" LastActivityDate="2017-03-04T21:53:50.217" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11641" PostTypeId="2" ParentId="11637" CreationDate="2017-03-03T23:11:30.427" Score="2" Body="&lt;p&gt;I'm surprised you didn't see an error message telling you that there was no match.  Your problem is &lt;code&gt;\x20&lt;/code&gt; which was matching nothing.  Your pattern was effectively:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[0-9A-Fa-f]20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\x&lt;/code&gt; matches a hex digit atom.  See &lt;code&gt;:h /\x&lt;/code&gt;.  What you're thinking of are string special characters (&lt;code&gt;:h expr-quote&lt;/code&gt;), which aren't expanded in patterns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;:s/ /\u2007/g&quot;&#xA;&#xA;or&#xA;&#xA;:s/ /\=&quot;\u2007&quot;/g&#xA;&#xA;or&#xA;&#xA;:s/\%u20/\=&quot;\u2007&quot;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just use a literal space as the pattern.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-03-03T23:11:30.427" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11644" PostTypeId="1" CreationDate="2017-03-04T03:28:56.547" Score="16" ViewCount="5270" Body="&lt;p&gt;I'm using the &lt;code&gt;:find&lt;/code&gt; command as my &quot;fuzzy file searcher&quot; in Vim. My setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path=,,**&#xA;nnoremap &amp;lt;leader&amp;gt;f :find *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I'm having trouble ignoring folders. Huge folders that contain dependencies, like node_modules, slow down the search a lot and of course pollute the results with things I don't want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried the following, with no luck:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildignore+=node_modules/*&#xA;set wildignore+=node_modules/**&#xA;set wildignore+=node_modules/**/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What do I need to do? Thanks&lt;/p&gt;&#xA;" OwnerUserId="7454" LastEditorUserId="7454" LastEditDate="2017-03-04T04:10:23.663" LastActivityDate="2018-06-01T14:53:40.097" Title="Ignore folders when performing :find command" Tags="|path|find|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11646" PostTypeId="1" AcceptedAnswerId="11651" CreationDate="2017-03-04T14:22:23.063" Score="0" ViewCount="1570" Body="&lt;p&gt;in insert mode, when i press &lt;kbd&gt;space&lt;/kbd&gt;, my neovim doesn't print out the space immediately. instead, it prints in the right corner &lt;code&gt;&amp;lt;20&amp;gt;&lt;/code&gt; and seems to wait for a mapping to complete. Although my mapleader is &lt;kbd&gt;space&lt;/kbd&gt;, i have no mappings using &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; for insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;update below&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:verbose imap &amp;lt;space&amp;gt;&lt;/code&gt; prints out that some plugins define  mappings. Disabling those temporarily results in the correct behavior when pressing .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My updated question is therefore: how can i prevent those insert-mode mapping of  ?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means, i want to know how i can forbid the use of (which is btw. my &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;) in &lt;em&gt;every&lt;/em&gt; insert-mode mapping. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lvjkK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lvjkK.png&quot; alt=&quot;pic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ nvim -v&#xA;NVIM v0.2.0-655-g0ef2b07d6&#xA;Build type: RelWithDebInfo&#xA;Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -Wconversion -O2 -g -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -D_GNU_SOURCE -I/tmp/yaourt-tmp-toogley/aur-neovim-git/src/neovim-git/build/config -I/tmp/yaourt-tmp-toogley/aur-neovim-git/src/neovim-git/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/tmp/yaourt-tmp-toogley/aur-neovim-git/src/neovim-git/build/src/nvim/auto -I/tmp/yaourt-tmp-toogley/aur-neovim-git/src/neovim-git/build/include&#xA;Compiled by toogley@arch-laptop&#xA;&#xA;Optional features included (+) or not (-): +acl   +iconv    +jemalloc +tui      &#xA;For differences from Vim, see :help vim-differences&#xA;&#xA;   system vimrc file: &quot;$VIM/sysinit.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/nvim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2354" LastEditorUserId="2354" LastEditDate="2017-03-05T00:21:01.323" LastActivityDate="2017-07-14T04:28:19.280" Title="how to prevent that &lt;space&gt; key is used inside insert-mode mappings?" Tags="|neovim|insert-mode|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11647" PostTypeId="1" AcceptedAnswerId="11648" CreationDate="2017-03-04T21:14:39.213" Score="1" ViewCount="213" Body="&lt;p&gt;I want to replace a number &lt;code&gt;n&lt;/code&gt;, with the number &lt;code&gt;n+1&lt;/code&gt;. Here's what's working:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\([0-9]\+\)/\=(submatch(0)+1)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this one doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/-c \([0-9]\+\)/-c \=(submatch(0)+1)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why?&lt;/p&gt;&#xA;" OwnerUserId="6154" LastActivityDate="2017-03-04T21:33:56.440" Title="Replace n with n+1" Tags="|search|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11648" PostTypeId="2" ParentId="11647" CreationDate="2017-03-04T21:33:56.440" Score="4" Body="&lt;p&gt;To use &lt;code&gt;\=&lt;/code&gt; in substitute it needs to start the replacement string (see &lt;code&gt;:h sub-replace-expression&lt;/code&gt;). Also &lt;code&gt;substitue(0)&lt;/code&gt; means whole matched string, so also including &lt;code&gt;-c&lt;/code&gt; prefix and that will always produce 0 when used in a arithmetic context. To use it correctly only on a number, you should use &lt;code&gt;submatch(1)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And now, to make it work, you need to include &lt;code&gt;-c&lt;/code&gt; inside the expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/-c \([0-9]\+\)/\=(&quot;-c &quot;.(submatch(1)+1))/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\(-c \)\([0-9]\+\)/\=((submatch(1)).(submatch(2)+1))/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-03-04T21:33:56.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11649" PostTypeId="2" ParentId="11629" CreationDate="2017-03-04T21:42:01.330" Score="3" Body="&lt;p&gt;If you have &lt;code&gt;backupcopy=no&lt;/code&gt; Vim will try to rename the file. If this fails it will work the same way as &lt;code&gt;backupcopy=yes&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example (with &lt;code&gt;strace&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rename(&quot;test.txt&quot;, &quot;/tmp/test.txt~&quot;) = -1 EXDEV (Invalid cross-device link)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in any case, Vim will only write to the file once:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set backupcopy=no&#xA;&#xA;rename(&quot;test.txt&quot;, &quot;test.txt~&quot;)   = 0&#xA;open(&quot;test.txt&quot;, O_WRONLY|O_CREAT|O_TRUNC, 0644) = 3&#xA;write(3, &quot;a\nbb\n\nccc\ndddd\n\neeeee\n&quot;, 22) = 22&#xA;close(3)                                = 0&#xA;&#xA;&#xA;set backupcopy=yes&#xA;&#xA;open(&quot;test.txt&quot;, O_RDONLY)           = 3&#xA;open(&quot;test.txt~&quot;, O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW, 0644) = 5&#xA;read(3, &quot;a\nbb\n\nccc\ndddd\n\neeeee\n&quot;, 8192) = 22&#xA;write(5, &quot;a\nbb\n\nccc\ndddd\n\neeeee\n&quot;, 22) = 22&#xA;read(3, &quot;&quot;, 8192)                       = 0&#xA;close(5)                                = 0&#xA;close(3)                                = 0&#xA;open(&quot;test.txt&quot;, O_WRONLY|O_CREAT|O_TRUNC, 0644) = 3&#xA;write(3, &quot;a\nbb\n\nccc\ndddd\n\neeeee\n&quot;, 22) = 22&#xA;close(3)                                = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe you have a plugin/autocmd that is responsible for the second write. Test with &lt;code&gt;vim -u NONE&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-04T21:42:01.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11650" PostTypeId="2" ParentId="11626" CreationDate="2017-03-04T22:16:17.610" Score="0" Body="&lt;p&gt;To complement @laktak's answer, the author of the 'tyru/open-browser' plugin recommends the following maps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap gx &amp;lt;Plug&amp;gt;(openbrowser-smart-search)&#xA;vmap gx &amp;lt;Plug&amp;gt;(openbrowser-smart-search)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;@laktak's suggestion of mapping &lt;code&gt;&amp;lt;F1&amp;gt;&lt;/code&gt; works, but why use a function key when you can keep your fingers on home row? :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After installing the plugin, and putting these maps in your .vimrc, you should be able to press &lt;code&gt;gx&lt;/code&gt; to automatically open your default browser and search Google for the either the word under the cursor (in normal mode) or all the text included in your visual selection (in visual mode). If you already have an instance of your default browser open, a new tab will be opened..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works great. There are even options to change the browser and search engine used.&lt;/p&gt;&#xA;" OwnerUserId="7454" LastActivityDate="2017-03-04T22:16:17.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11651" PostTypeId="2" ParentId="11646" CreationDate="2017-03-05T02:39:39.890" Score="2" Body="&lt;p&gt;If the plugin has some &lt;code&gt;&amp;lt;plug&amp;gt;mapping&lt;/code&gt; variation point that could be used to override the default one thar use &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;, well there will be a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, it's done on a per plugin basis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless listing all i-mappings starting with &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; thanks to &lt;code&gt;getcompletions()&lt;/code&gt; (IIRC) in an &lt;code&gt;after/&lt;/code&gt; plugin executed after all other plugins, I don't see any generic solution -- note that this won't solve ftplugins issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: there exist many forks of a.vim that have disabled the mappings that cause the disturbances in your case. (I even have a &lt;a href=&quot;https://github.com/LucHermitte/alternate-lite&quot; rel=&quot;nofollow noreferrer&quot;&gt;fork&lt;/a&gt;, for other reasons)&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-03-05T02:39:39.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11654" PostTypeId="1" CreationDate="2017-03-05T07:21:21.907" Score="1" ViewCount="472" Body="&lt;p&gt;Is there a way to stop PluginInstall while it's running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The typical scenario in which I need this is when installing a new plugin (basically one line added to the &lt;code&gt;.vimrc&lt;/code&gt;), and once PluginInstall passes that line in the list of plugins, it's not going to be doing anything useful any more. I'd rather stop it manually than wait 10-20 more seconds for it to finish going over the list.&lt;/p&gt;&#xA;" OwnerUserId="11576" LastActivityDate="2017-03-06T07:32:10.657" Title="Stopping :PluginInstall safely" Tags="|plugin-vundle|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11655" PostTypeId="2" ParentId="6637" CreationDate="2017-03-05T08:19:53.310" Score="0" Body="&lt;p&gt;For win7: Start &gt; Run &gt; Cmd (as Admin), and run these commands to make the dir tree writable by admin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd parent/folder&#xA;&#xA;:: /f file, /a admin,  /r recurse, /d y = nopromt&#xA;takeown /F . /A /R /D Y &amp;gt; nul:&#xA;&#xA;:: /t /q /c .. traverse quiet continue&#xA;icacls . /t /q /c /reset&#xA;icacls . /t /q /c /grant    :r Everyone:F&#xA;icacls . /t /q /c /setowner Administrators &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7817" LastEditorUserId="7817" LastEditDate="2017-03-21T15:03:25.113" LastActivityDate="2017-03-21T15:03:25.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11656" PostTypeId="1" CreationDate="2017-03-05T11:22:00.440" Score="3" ViewCount="120" Body="&lt;p&gt;I'd like to make a plugin with functionality that is similar to &lt;a href=&quot;https://github.com/ramele/agrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ramele/agrep&lt;/a&gt; and &lt;code&gt;grep-edit&lt;/code&gt; in emacs. That is get search results from &lt;code&gt;ag&lt;/code&gt; or some other tool that supports multiline matches (otherwise quickfix and &lt;code&gt;cdo&lt;/code&gt; is just as good choice I think), colorise them and group by file (&lt;code&gt;ag&lt;/code&gt; do this by default) and then basically mirror any changes made in this buffer to the actual files.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2017-03-05T11:22:00.440" Title="How to emulate vim job out_io buffer with neovim?" Tags="|neovim|job-control|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11657" PostTypeId="1" AcceptedAnswerId="11658" CreationDate="2017-03-05T21:42:53.440" Score="5" ViewCount="1337" Body="&lt;p&gt;from  the help: &lt;code&gt;:h syntax-reset&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you have changed the colors and messed them up, use this command to&#xA;  get the defaults back: &gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;:syntax reset&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;It is a bit of a wrong name, since it does not reset any syntax items,&#xA;  it only affects the highlighting.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This doesn't change the colors for the 'highlight' option.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;so this tells us: &lt;em&gt;it does not reset any syntax items&lt;/em&gt; and it doesnt&#xA; &lt;em&gt;change the &lt;code&gt;highlight&lt;/code&gt; option&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what does it do?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2017-03-05T22:54:50.877" Title="What does the command `:syntax reset` do?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11658" PostTypeId="2" ParentId="11657" CreationDate="2017-03-05T22:54:50.877" Score="6" Body="&lt;p&gt;It resets the colors for&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Comment&lt;/li&gt;&#xA;&lt;li&gt;Constant&lt;/li&gt;&#xA;&lt;li&gt;Special&lt;/li&gt;&#xA;&lt;li&gt;Identifier&lt;/li&gt;&#xA;&lt;li&gt;Statement&lt;/li&gt;&#xA;&lt;li&gt;PreProc&lt;/li&gt;&#xA;&lt;li&gt;Type&lt;/li&gt;&#xA;&lt;li&gt;Underline&lt;/li&gt;&#xA;&lt;li&gt;Ignore&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;according to the selected background (dark or light).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Links that point to these colors (&lt;code&gt;String&lt;/code&gt;, &lt;code&gt;Number&lt;/code&gt;, etc.) are also reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/syntax/syncolor.vim&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/vim/vim/blob/master/runtime/syntax/syncolor.vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-05T22:54:50.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11659" PostTypeId="1" AcceptedAnswerId="12832" CreationDate="2017-03-06T07:22:57.650" Score="1" ViewCount="2609" Body="&lt;p&gt;I'm trying to use the &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouCompleteMe&lt;/a&gt; auto completion plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have installed MacVim version 7.4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed the instructions on the linked page for Mac OS X  by making the symlink:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ln -s /usr/local/bin/mvim vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When installing the plugin with Vundle, I got some errors, which I unfortunately didn't copy or save. YCM however seems to be instaled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open vim from the Terminal however, I get this, and there is no auto completion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 19, in &amp;lt;module&amp;gt;&#xA;  File &quot;/Users/user/.vim/bundle/YouCompleteMe/autoload/../python/ycm/setup.py&quot;, line 37, in SetUpSystemPaths&#xA;    from ycmd import server_utils as su&#xA;  File &quot;/Users/user/.vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd/ycmd/server_utils.py&quot;, line 25, in &amp;lt;module&amp;gt;&#xA;    import io&#xA;  File &quot;/Users/user/anaconda/lib/python2.7/io.py&quot;, line 51, in &amp;lt;module&#xA;    import _io&#xA;ImportError: dlopen(/Users/user/anaconda/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder&#xA;  Referenced from: /Users/user/anaconda/lib/python2.7/lib-dynload/_io.so&#xA;  Expected in: flat namespace&#xA; in /Users/user/anaconda/lib/python2.7/lib-dynload/_io.so&#xA;YouCompleteMe unavailable: dlopen(/Users/user/anaconda/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder&#xA;  Referenced from: /Users/user/anaconda/lib/python2.7/lib-dynload/_io.so&#xA;  Expected in: flat namespace&#xA; in /Users/user/anaconda/lib/python2.7/lib-dynload/_io.so&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11660" LastActivityDate="2017-07-05T09:27:09.693" Title="Youcompleteme on Mac OS X" Tags="|macvim|plugin-you-complete-me|macos|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11660" PostTypeId="2" ParentId="11654" CreationDate="2017-03-06T07:32:10.657" Score="2" Body="&lt;p&gt;Vundle calls &lt;code&gt;system()&lt;/code&gt; to run &lt;code&gt;git&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;  The command will be executed in &quot;cooked&quot; mode, so that a&#xA;  CTRL-C will interrupt the command (on Unix at least).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you cancel Vundle, Vim will interrupt git. So the question is are you able to stop git safely? Since you can find posts about broken git repos the answer is probably no.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better alternative might be &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt; which is very quick on &lt;code&gt;:PlugInstall&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-06T07:32:10.657" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11661" PostTypeId="1" CreationDate="2017-03-06T12:04:12.203" Score="1" ViewCount="45" Body="&lt;p&gt;I'm often searching elements inside the buffer to have a visual indication where in lines the 'text' exists &lt;strong&gt;but&lt;/strong&gt; that overrides the search for &lt;em&gt;all&lt;/em&gt; buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an option to make it local to buffer? That I can have different search across multiple buffers?&lt;/p&gt;&#xA;" OwnerUserId="8609" LastEditorUserId="1821" LastEditDate="2017-03-06T14:02:13.713" LastActivityDate="2017-03-06T14:02:13.713" Title="Search local to buffer" Tags="|search|buffers|" AnswerCount="0" CommentCount="0" ClosedDate="2017-03-08T01:38:32.680" ContentLicense="CC BY-SA 3.0" />
  <row Id="11662" PostTypeId="2" ParentId="11659" CreationDate="2017-03-06T17:49:32.817" Score="0" Body="&lt;p&gt;I had a similar issue trying to get it set up and fixed it with this line in my .zshrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export DYLD_FORCE_FLAT_NAMESPACE=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;might give that a shot and see if it resolves.&lt;/p&gt;&#xA;" OwnerUserId="11665" LastActivityDate="2017-03-06T17:49:32.817" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11663" PostTypeId="2" ParentId="11257" CreationDate="2017-03-06T20:37:01.740" Score="2" Body="&lt;p&gt;That's not a nitpicky concern. You should expect an editor to behave consistently.&lt;/p&gt;&#xA;&lt;p&gt;As @Raziman points out, buffer names are relative to the current working directory, unless the associated file is NOT even a descendant of the current working directory. If this is not your problem, read on...&lt;/p&gt;&#xA;&lt;p&gt;If the associated file is definitely a descendant of the current working directory, then it is still possible to get full path buffer names because it depends on how you open the file. For instance, if your current working directory is &lt;code&gt;~/Documents/programming/projects/my_project/src&lt;/code&gt;, you could open &lt;code&gt;foo.cpp&lt;/code&gt; in that directory in one of two ways:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Using its relative path like &lt;code&gt;:edit foo.cpp&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The buffer name will just be &lt;code&gt;foo.cpp&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Using its full path like &lt;code&gt;:edit ~/Documents/programming/projects/my_project/src/foo.cpp&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The buffer name will be the full path.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;How are you opening your files? Are you using a file browser plugin?&lt;/p&gt;&#xA;" OwnerUserId="7454" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-03-06T20:42:37.007" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11665" PostTypeId="1" CreationDate="2017-03-07T15:13:29.283" Score="0" ViewCount="22" Body="&lt;p&gt;How do I invoke the vi &lt;code&gt;help&lt;/code&gt; while I am in bash without starting a vi session?&lt;/p&gt;&#xA;" OwnerUserId="10566" LastEditorUserId="51" LastEditDate="2017-03-07T15:46:57.370" LastActivityDate="2017-03-07T15:46:57.370" Title="Invoke vi help from bash without starting Vim" Tags="|help-system|bash|" AnswerCount="0" CommentCount="4" ClosedDate="2017-03-07T17:23:31.787" ContentLicense="CC BY-SA 3.0" />
  <row Id="11666" PostTypeId="1" AcceptedAnswerId="11684" CreationDate="2017-03-07T15:30:43.620" Score="0" ViewCount="922" Body="&lt;p&gt;I've been having a ridiculously hard time getting C/C++ code folding to work with &lt;code&gt;set foldmethod=syntax&lt;/code&gt;. To debug my issue I've stripped down my vimrc to &lt;strong&gt;only&lt;/strong&gt; this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=syntax&#xA;syntax on                &quot; also tried putting this first&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when I open a cpp file, nothing is folded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, doing &lt;code&gt;:syntax off&lt;/code&gt; followed by &lt;code&gt;:syntax on&lt;/code&gt; &lt;em&gt;will&lt;/em&gt; fold the cpp file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea why that does something not already done by the trivial vimrc?&lt;/p&gt;&#xA;" OwnerUserId="6107" LastActivityDate="2017-03-09T11:24:04.450" Title="Folding doesn't work for C/C++" Tags="|syntax-highlighting|folding|filetype-c++|filetype-c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11667" PostTypeId="1" CreationDate="2017-03-07T16:56:34.253" Score="4" ViewCount="4467" Body="&lt;p&gt;I have a Perl test script. I a) use &lt;a href=&quot;https://github.com/benmills/vimux&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Vimux&lt;/code&gt;&lt;/a&gt; to show the output of the script in a new pane. Once the script is done with its output, I want to b) immediately hide the pane in preparation for c) pulling up the output of the test script (saved in a file) in a new buffer where I can see it nicely syntaxed highlighted with vim just how I like it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the vim code for for parts a) and b) of my task:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;F7&amp;gt; :w&amp;lt;CR&amp;gt;:call VimuxRunCommand(&quot;prove --normalize -v -j 10 -a test.tgz &quot; . bufname('%'))&amp;lt;CR&amp;gt;&amp;lt;bar&amp;gt; :silent !tmux kill-pane -a -t 0&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the pane closes immediately before anything gets output to it. I want to wait for my &lt;code&gt;prove&lt;/code&gt; command to finish executing before I run the next vim command. Is there a way to do this?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-03-07T19:37:01.113" Title="Can you make vim wait for a command process to finish before executing the next command?" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11668" PostTypeId="1" AcceptedAnswerId="13840" CreationDate="2017-03-07T17:25:52.633" Score="4" ViewCount="4656" Body="&lt;p&gt;I am new to Vim, however I am learning to love it.  As a former/current Windows user, there is one shortcut that I depend on and would like to configure in Vim.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On windows I can use &lt;kbd&gt;ctrl&lt;/kbd&gt;-&lt;kbd&gt;arrow left&lt;/kbd&gt; and &lt;kbd&gt;ctrl&lt;/kbd&gt;-&lt;kbd&gt;arrow right&lt;/kbd&gt; to skip over words left and right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just don't want to press the over arrow a bunch of times when moving any text within the editor.  It can be really handy to just right over four words by pressing the arrow four times (with control held down).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example of functionality I want&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Let's say my cursor is represented by a pipe: |&#xA;&#xA;Sample text:&#xA;The brown |fox jumped over the lazy dog.  &quot; before pressing ctrl-[right arrow]&#xA;The brown fox |jumped over the lazy dog.  &quot; after  pressing ctrl-[right arrow]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Has anybody else had similar interests?&lt;/li&gt;&#xA;&lt;li&gt;Is there an easy way to get identical/similar functionality? &lt;/li&gt;&#xA;&lt;li&gt;Any help would be much appreciated!&lt;/li&gt;&#xA;&lt;li&gt;Sorry if I messed up any terminology (let me know and I will update anything that needs fixing).  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&#xA;Thanks for the responses.  It's good to know that this is possible with &lt;kbd&gt;w&lt;/kbd&gt; and &lt;kbd&gt;b&lt;/kbd&gt;.  I will settle for that if needed, however I would like to attempt this anyways for the sake of learning from the exercise, as well as for future vim users attempting this.  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I am currently using Bash on &lt;strong&gt;Ubuntu 14.04&lt;/strong&gt; server running in VirtualBox on Windows 10.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I edited my vimrc (found in &lt;code&gt;/etc/vim/vimrc&lt;/code&gt;) to show this at the end of the file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;set &amp;lt;xUp&amp;gt;=\e[1;*A&quot; &#xA;execute &quot;set &amp;lt;xDown&amp;gt;=\e[1;*B&quot;&#xA;execute &quot;set &amp;lt;xRight&amp;gt;=\e[1;*C&quot;&#xA;execute &quot;set &amp;lt;xLeft&amp;gt;=\e[1;*D&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11680" LastEditorUserId="4472" LastEditDate="2017-07-06T06:13:13.303" LastActivityDate="2018-10-11T16:29:34.357" Title="Control - Arrow to Skip Over Text" Tags="|vimrc|cursor-movement|cursor-motions|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="11669" PostTypeId="2" ParentId="11668" CreationDate="2017-03-07T19:26:35.527" Score="3" Body="&lt;p&gt;If Vim exits insert mode and appears to do nothing you may need to tell it to use xterm keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;set &amp;lt;xUp&amp;gt;=\e[1;*A&quot;&#xA;execute &quot;set &amp;lt;xDown&amp;gt;=\e[1;*B&quot;&#xA;execute &quot;set &amp;lt;xRight&amp;gt;=\e[1;*C&quot;&#xA;execute &quot;set &amp;lt;xLeft&amp;gt;=\e[1;*D&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this does not help let us know what OS/terminal you are using.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-07T19:26:35.527" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11670" PostTypeId="2" ParentId="11667" CreationDate="2017-03-07T19:37:01.113" Score="2" Body="&lt;p&gt;try &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F7&amp;gt; :w &amp;lt;bar&amp;gt;&#xA;  \ call VimuxRunCommand(&quot;prove --normalize -v -j 10 -a test.tgz &quot; . bufname('%')) &amp;lt;bar&amp;gt;&#xA;  \ echo 'press any key' &amp;lt;bar&amp;gt;&#xA;  \ call getchar() &amp;lt;bar&amp;gt;&#xA;  \ silent !tmux kill-pane -a -t 0&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-07T19:37:01.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11671" PostTypeId="1" CreationDate="2017-03-08T00:43:27.770" Score="0" ViewCount="68" Body="&lt;p&gt;I have the following in a bash file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;prove --merge --normalize -v $1 -a test.tgz&#xA;vim -nR -c ':silent 0read ! tar xfO test.tgz $1' -c ':set nonumber' -c ':set syntax=test' -c ':silent !tmux select-pane -L'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem bit is the &lt;code&gt;$1&lt;/code&gt; in the second line. The script runs, but it displays the entire archive, not just the file I want: &lt;code&gt;$1&lt;/code&gt;. If I hardcode the name of file into the script, it works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And my &lt;code&gt;tar xfO test.tgz filename&lt;/code&gt; command works find on the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get this to work?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="51" LastEditDate="2017-03-08T01:39:47.623" LastActivityDate="2017-03-08T01:39:47.623" Title="Inserting bash positional variable into vim command in a bash file" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11672" PostTypeId="2" ParentId="11671" CreationDate="2017-03-08T00:46:27.557" Score="1" Body="&lt;p&gt;I put in double quotes and it's now working. I swear I tried that before though. Must have had a stray character or something in there before. &lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-03-08T00:46:27.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11673" PostTypeId="1" AcceptedAnswerId="11674" CreationDate="2017-03-08T01:20:47.573" Score="0" ViewCount="141" Body="&lt;p&gt;Here are some sample strings, sorted by longest string to shortest sting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Bi(NO&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;·5H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&quot;,&quot;bismuth nitrate pentahydrate&quot;); &#xA;&quot;Be(C&amp;lt;sub&amp;gt;5&amp;lt;/sub&amp;gt;H&amp;lt;sub&amp;gt;7&amp;lt;/sub&amp;gt;O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&quot;,&quot;Be acetylacetonate&quot;); &#xA;&quot;O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;2&amp;amp;minus;&amp;lt;/sup&amp;gt;&quot;,&quot;Peroxide#Inorganic chemistry|peroxide ion&quot;); &#xA;&quot;Cu(BrO&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;·6H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&quot;,&quot;Cu bromate hexahydrate&quot;);&#xA;&quot;Mn(CHO&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;·2H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&quot;,&quot;Mn formate dihydrate&quot;); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If we use &lt;code&gt;&quot;,&quot;&lt;/code&gt; as a delimiter, the substrings would be this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Bi(NO&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;·5H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&#xA;&quot;Be(C&amp;lt;sub&amp;gt;5&amp;lt;/sub&amp;gt;H&amp;lt;sub&amp;gt;7&amp;lt;/sub&amp;gt;O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&#xA;&quot;O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;2&amp;amp;minus;&amp;lt;/sup&amp;gt;&#xA;&quot;Cu(BrO&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;·6H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&#xA;&quot;Mn(CHO&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;·2H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to sort the substrings by longest string to shortest sting. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2017-03-08T04:36:28.947" Title="How do you sort lines by longest substring to shortest substring?" Tags="|regular-expression|replace|delimiter-matching|string-manipulation|sort|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11674" PostTypeId="2" ParentId="11673" CreationDate="2017-03-08T04:36:28.947" Score="2" Body="&lt;p&gt;You could use external commands to do that. Take for example, giving that the buffer has only the content you share the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%!awk -F ',' '{print length($1) &quot;|&quot; $0}'&#xA;%!sort -nr&#xA;%norm df|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would result in this contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Be(C&amp;lt;sub&amp;gt;5&amp;lt;/sub&amp;gt;H&amp;lt;sub&amp;gt;7&amp;lt;/sub&amp;gt;O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&quot;,&quot;Be acetylacetonate&quot;); &#xA;&quot;Mn(CHO&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;·2H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&quot;,&quot;Mn formate dihydrate&quot;); &#xA;&quot;Cu(BrO&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;·6H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&quot;,&quot;Cu bromate hexahydrate&quot;);&#xA;&quot;Bi(NO&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;·5H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&quot;,&quot;bismuth nitrate pentahydrate&quot;); &#xA;&quot;O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;2&amp;amp;minus;&amp;lt;/sup&amp;gt;&quot;,&quot;Peroxide#Inorganic chemistry|peroxide ion&quot;); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;first, with awk, we can determine and prepend on each line the lenght of the first field, so after the first command (&lt;code&gt;%!awk -F ',' '{print length($1) &quot;|&quot; $0}'&lt;/code&gt;) your buffer will look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;48|&quot;Bi(NO&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;·5H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&quot;,&quot;bismuth nitrate pentahydrate&quot;); &#xA;57|&quot;Be(C&amp;lt;sub&amp;gt;5&amp;lt;/sub&amp;gt;H&amp;lt;sub&amp;gt;7&amp;lt;/sub&amp;gt;O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&quot;,&quot;Be acetylacetonate&quot;); &#xA;34|&quot;O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;2&amp;amp;minus;&amp;lt;/sup&amp;gt;&quot;,&quot;Peroxide#Inorganic chemistry|peroxide ion&quot;); &#xA;49|&quot;Cu(BrO&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;·6H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&quot;,&quot;Cu bromate hexahydrate&quot;);&#xA;49|&quot;Mn(CHO&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;·2H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&quot;,&quot;Mn formate dihydrate&quot;); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, we can sort it with the sort program, so, after the second command (&lt;code&gt;%!sort -nr&lt;/code&gt;), your buffer would look like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;57|&quot;Be(C&amp;lt;sub&amp;gt;5&amp;lt;/sub&amp;gt;H&amp;lt;sub&amp;gt;7&amp;lt;/sub&amp;gt;O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&quot;,&quot;Be acetylacetonate&quot;); &#xA;49|&quot;Mn(CHO&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;·2H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&quot;,&quot;Mn formate dihydrate&quot;); &#xA;49|&quot;Cu(BrO&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;·6H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&quot;,&quot;Cu bromate hexahydrate&quot;);&#xA;48|&quot;Bi(NO&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;)&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;·5H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;O&quot;,&quot;bismuth nitrate pentahydrate&quot;); &#xA;34|&quot;O&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;2&amp;amp;minus;&amp;lt;/sup&amp;gt;&quot;,&quot;Peroxide#Inorganic chemistry|peroxide ion&quot;); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you clean your lines with &lt;code&gt;%norm df|&lt;/code&gt; that way you end up with your lines sorted by first field length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is just part of a bigger file, you can use visual mode to select the lines you want to sort and then press colon and the same commands but without the percent symbol. The commands then would start with: &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt;. For example, the first command would look like &lt;code&gt;'&amp;lt;,'&amp;gt;!awk -F, '{print length($1) &quot;|&quot; $0}'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This probably won't work on windows though  &lt;/p&gt;&#xA;" OwnerUserId="11690" LastActivityDate="2017-03-08T04:36:28.947" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11675" PostTypeId="1" CreationDate="2017-03-08T07:22:10.767" Score="12" ViewCount="6258" Body="&lt;p&gt;When I save a file in Vim using &lt;code&gt;:update&lt;/code&gt; or &lt;code&gt;:w&lt;/code&gt;, Vim's entire UI blocks for about a second while it does something mysterious that (as a side effect) writes the buffer being edited to disk. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This takes way too much time. Sitting there like a chump for 1000ms waiting for Vim to finish the monumental task of flushing the buffer to disk is no fun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My source file is fairly large (100k), and smaller files don't suffer from this issue, but 100k is really not that large. I consider a ~2,000 line, 100KB source file to be a reasonably sized buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I speed this up?&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="51" LastEditDate="2017-03-10T01:47:24.720" LastActivityDate="2017-04-09T01:51:19.650" Title="Why is vim save so slow?" Tags="|save|performance|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11676" PostTypeId="2" ParentId="11675" CreationDate="2017-03-08T07:44:07.667" Score="10" Body="&lt;p&gt;The culprit in this particular situation was the Syntastic plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's forking eslint. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I load Syntastic on entering insert mode (using a vim-plug function loader).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim is plenty snappy on its own. &lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="390" LastEditDate="2017-03-08T08:40:31.223" LastActivityDate="2017-03-08T08:40:31.223" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11677" PostTypeId="1" CreationDate="2017-03-08T09:33:39.590" Score="10" ViewCount="6263" Body="&lt;p&gt;Sometimes I'll guess a count for a cursor movement, say &lt;code&gt;4b&lt;/code&gt; but it was actually 7 words away.  If I'd performed an edit I could press &lt;code&gt;.&lt;/code&gt; to repeat; I could have done &lt;code&gt;@:&lt;/code&gt; to repeat a command line.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be useful to repeat &lt;code&gt;4b&lt;/code&gt; again.  This functionality would also be useful, saving more keypresses,  if, having done &lt;code&gt;10&amp;lt;C-w&amp;gt;&amp;gt;&lt;/code&gt; I could repeat the window resize with a single key.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way of doing this I've overlooked?&lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastEditorUserId="1821" LastEditDate="2017-03-08T09:59:06.763" LastActivityDate="2023-10-20T08:41:43.217" Title="Repeat motion easily" Tags="|repeated-commands|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11678" PostTypeId="2" ParentId="11677" CreationDate="2017-03-08T12:27:24.707" Score="12" Body="&lt;p&gt;Since you mentioned cursor movement but not &lt;code&gt;;&lt;/code&gt; there is of course&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;;     Repeat latest f, t, F or T [count] times.&#xA;,     Repeat latest f, t, F or T in opposite direction [count] times. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is very helpful to get to the next occurrence of the character you just searched for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMHO I'm don't think repeating &lt;code&gt;4b&lt;/code&gt; would be worth it.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-08T12:27:24.707" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11679" PostTypeId="1" AcceptedAnswerId="11680" CreationDate="2017-03-08T15:00:20.597" Score="1" ViewCount="104" Body="&lt;p&gt;In particular, I noticed that the &lt;code&gt;w&lt;/code&gt; (words forward) behaves differently for &lt;code&gt;.clj&lt;/code&gt; files, which is pretty frustrating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume we are editing the following text and the cursor currently is placed at the first character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;abc.abc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we press press&lt;code&gt;w&lt;/code&gt; while editing a &lt;code&gt;.clj&lt;/code&gt; file, the cursor jumps to the last character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, if the text is in some file without the clojure extension, the cursor jumps to the &lt;code&gt;.&lt;/code&gt;-character, like expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I disabled all plugins and removed my &lt;code&gt;.vimrc&lt;/code&gt; to verify that this is a native behaviour. Can anybody reproduce and perhaps explain with a solution?&lt;/p&gt;&#xA;" OwnerUserId="10357" LastActivityDate="2017-03-08T15:34:19.137" Title="Vim has different behaviour for clojure files" Tags="|filetype-clojure|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11680" PostTypeId="2" ParentId="11679" CreationDate="2017-03-08T15:34:19.137" Score="2" Body="&lt;p&gt;see &lt;code&gt;:help iskeyword&lt;/code&gt; and check with &lt;code&gt;:verbose set iskeyword?&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  iskeyword=@,48-57,_,192-255,?,-,*,!,+,/,=,&amp;lt;,&amp;gt;,.,:,$&#xA;        Last set from /usr/share/vim/vim80/ftplugin/clojure.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To set your own options you need to create a file &lt;code&gt;~/.vim/after/ftplugin/clojure.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal iskeyword-=.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-08T15:34:19.137" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11681" PostTypeId="1" CreationDate="2017-03-08T20:37:10.333" Score="2" ViewCount="302" Body="&lt;p&gt;I recently discovered the &lt;code&gt;textwidth&lt;/code&gt; setting, which lets me configure vim to insert a &quot;smart&quot; whitespace-delimited carriage return as I'm typing when my line of text exceeds my specified limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can have this feature only apply when I'm typing in a non-commented block of text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g.:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set tw=20&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set formatoptions+=t&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set cino=(0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now as I typed the below, vim auto-inserted the carriage-return and indentation between &lt;code&gt;int&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;, which is nice:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1 int foo( int a, int                                                                                                                                                                                                                                                         &#xA;  2          b, int c )   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to configure vim to naturally allow lines 4 and 5 below?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1 int foo( int a, int                                                                                                                                                                                                                                                         &#xA;  2          b, int c )                                                                                                                                                                                                                                                          &#xA;  3 {                                                                                                                                                                                                                                                                           &#xA;  4   /* Can vim be made to allow this line even when textwidth is set to 20? */                                                                                                                                                                                                &#xA;  5   int i = 5; // Can vim also be made to allow this line even when textwidth is set to 20?                                                                                                                                                                                   &#xA;  6   return i;&#xA;  7 }                                                                                                                                                                                                                                                                           &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am specifically wondering whether the above &quot;exceptions&quot; to line-breaking can be done &quot;as I type&quot; as opposed to applying a formatting after text has been typed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE: What I have tried&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried adapting an answer to &lt;a href=&quot;https://vi.stackexchange.com/questions/9174/line-number-specific-text-width-setting&quot;&gt;this question&lt;/a&gt; by adding the following to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetypes&#xA;  autocmd!&#xA;&#xA;  autocmd FileType c call s:fubar()&#xA;augroup end&#xA;&#xA;&quot; Set up ft=c&#xA;fun! s:fubar()&#xA;  augroup ft_c&#xA;    autocmd!&#xA;    autocmd CursorMoved,CursorMovedI *&#xA;          \ if index([&quot;cCommentGroup&quot;], synIDattr(synID(line('.'), col('.'), 1), 'name')) &amp;gt;= 0&#xA;          \| setlocal textwidth=500&#xA;          \| else &#xA;            \| setlocal textwidth=80&#xA;            \|endif&#xA;  augroup end&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This did not affect runtime editing behavior in any way that I could tell. Following is a .cpp file I created after sourcing my updated &lt;code&gt;.vimrc&lt;/code&gt;. &lt;code&gt;textwidth&lt;/code&gt; is 80 in this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1 #include &amp;lt;iostream&amp;gt;                                                                                                                                                                                                                                                         &#xA;  2                                                                                                                                                                                                                                                                             &#xA;  3 int main( int argc, char* argv[], char* envz[] )                                                                                                                                                                                                                            &#xA;  4 {                                                                                                                                                                                                                                                                           &#xA;  5   std::cout &amp;lt;&amp;lt; &quot;aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&quot;                                                                                                                                                                                              &#xA;  6     &amp;lt;&amp;lt; std::endl;                                                                                                                                                                                                                                                           &#xA;  7   // This is a test of some funky new autocmd stuff in my .vimrc that makes use                                                                                                                                                                                             &#xA;  8   // of syntax information...                                                                                                                                                                                                                                               &#xA;  9                                                                                                                                                                                                                                                                             &#xA; 10   /* This is a test of some funky new autocmd stuff in my .vimrc that makes use                                                                                                                                                                                             &#xA; 11    * of syntax information...                                                                                                                                                                                                                                               &#xA; 12    */                                                                                                                                                                                                                                                                       &#xA; 13 } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code was hard-wrapped desirably, but both C and C++ comments were also hard-wrapped.&lt;/p&gt;&#xA;" OwnerUserId="11701" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2017-03-09T17:53:18.037" Title="Possible to exclude comments from textwidth?" Tags="|formatting|wrapping|comments|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11682" PostTypeId="2" ParentId="11623" CreationDate="2017-03-08T22:25:33.687" Score="1" Body="&lt;p&gt;As a partial solution: before saving the session, use  &lt;code&gt;:set bl&lt;/code&gt;  when in the netrw window, thus making it a listed buffer.  Your &lt;code&gt;sessionoptions&lt;/code&gt; should also have &lt;code&gt;buffers&lt;/code&gt; as one of its entries.  Then, save a session (ie. &lt;code&gt;:mksession somefilename&lt;/code&gt;).  Its only a partial solution because the restored window, although the window exists, is filled properly, and netrw works with it, its not named.&lt;/p&gt;&#xA;" OwnerUserId="2377" LastEditorUserId="6698" LastEditDate="2017-08-06T12:32:24.420" LastActivityDate="2017-08-06T12:32:24.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11684" PostTypeId="2" ParentId="11666" CreationDate="2017-03-09T11:24:04.450" Score="1" Body="&lt;p&gt;After some detective work I tracked down the cause of my issue being that I had a &lt;code&gt;.vim&lt;/code&gt; file in my plugin directory that redefined &lt;code&gt;OperatorChars&lt;/code&gt;, which broke the &lt;code&gt;syntax&lt;/code&gt; based folding for C and C++.&lt;/p&gt;&#xA;" OwnerUserId="6107" LastActivityDate="2017-03-09T11:24:04.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11685" PostTypeId="1" AcceptedAnswerId="11686" CreationDate="2017-03-09T15:59:36.357" Score="6" ViewCount="6410" Body="&lt;p&gt;I have what I thought was a pretty simple setup in my neovim init.vim file.  Basically all I wanted it to do was configure the tab settings when opening an HTML file.  My configuration is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.html, *.css&#xA;    \ set tabstop=2&#xA;    \ softtabstop=2&#xA;    \ shiftwidth=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open an HTML file I get the following error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing BufReadPost Auto commands for &quot;*.html&quot;:&#xA;E20: Mark not set&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't understand why this is throwing an error.  I have a similar line in my config file for &lt;code&gt;*.py&lt;/code&gt; yet I receive no errors when opening Python files.&lt;/p&gt;&#xA;" OwnerUserId="11712" LastEditorUserId="51" LastEditDate="2017-03-09T16:28:55.217" LastActivityDate="2019-02-01T08:14:55.873" Title="Error detected while processing BufReadPost Auto commands for &quot;*.html&quot;: E20: Mark not set" Tags="|autocmd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11686" PostTypeId="2" ParentId="11685" CreationDate="2017-03-09T16:26:52.720" Score="10" Body="&lt;p&gt;You need to use &lt;code&gt;|&lt;/code&gt; to run multiple commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=2 | softtabstop=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't matter if you're using multiple lines, you still need to use the &lt;code&gt;|&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.html, *.css&#xA;    \  set tabstop=2&#xA;    \| set softtabstop=2&#xA;    \| set shiftwidth=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can set multiple values with &lt;code&gt;set&lt;/code&gt;, so the same can be expressed as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.html, *.css&#xA;    \ set tabstop=2 softtabstop=2 shiftwidth=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You probably want to use &lt;code&gt;setlocal&lt;/code&gt;, rather than &lt;code&gt;set&lt;/code&gt;. &lt;code&gt;set&lt;/code&gt; will affect &lt;em&gt;all&lt;/em&gt; buffers, so your autocommand will also change the settings for a &lt;code&gt;.js&lt;/code&gt; buffer for example. &lt;code&gt;setlocal&lt;/code&gt; will only affect the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.html, *.css&#xA;    \ setlocal tabstop=2 softtabstop=2 shiftwidth=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;code&gt;Filetype&lt;/code&gt; autocommand is probably better too. There may be other cases where the &lt;code&gt;html&lt;/code&gt; or &lt;code&gt;css&lt;/code&gt; syntax is loaded (for example my setting it manually):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType html,css&#xA;    \ setlocal tabstop=2 softtabstop=2 shiftwidth=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Personally, I always want these three settings to have the same value, if you use &lt;code&gt;shiftwidth=0&lt;/code&gt; it will use the value of the &lt;code&gt;tabstop&lt;/code&gt; setting, and &lt;code&gt;softtabstop=-1&lt;/code&gt; will make that use the &lt;code&gt;shiftwidth&lt;/code&gt; setting, so then you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shiftwidth=0    &quot; Use tabstop&#xA;set softtabstop=-1  &quot; Use shiftwidth&#xA;&#xA;au FileType html,css setlocal tabstop=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-03-09T16:26:52.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11687" PostTypeId="1" CreationDate="2017-03-09T16:57:14.173" Score="1" ViewCount="537" Body="&lt;p&gt;I'm trying to make a mapping which does one thing on the first press of a key, and also does something else if I press the key again within &lt;code&gt;timeout&lt;/code&gt;. Specifically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;Esc&amp;gt; :set hls&amp;lt;CR&amp;gt;:let @/=&quot;\\&amp;lt;&amp;lt;C-R&amp;gt;=expand('&amp;lt;cword&amp;gt;')&amp;lt;CR&amp;gt;\\&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Esc&amp;gt; :noh&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;…I want pressing &lt;kbd&gt;Esc&lt;/kbd&gt; in normal mode to stop highlighting the current search (immediately, without waiting for &lt;code&gt;timeout&lt;/code&gt;), and pressing &lt;kbd&gt;Esc&lt;/kbd&gt; again to highlight the word under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things I've tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;These mappings as-is:&lt;/strong&gt; success, but there's a distracting delay when I press &lt;kbd&gt;Esc&lt;/kbd&gt; once.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Adding &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; to the second mapping:&lt;/strong&gt; it consumes the key press so the first mapping never happens.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Adding &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; to the second mapping, and &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; at the end&lt;/strong&gt;: &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; does not put Vim in &quot;waiting for another key&quot; mode (presumably because its a non-recursive mapping).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Adding &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; and &lt;code&gt;:call feedkeys(&quot;\&amp;lt;lt&amp;gt;esc&amp;gt;&quot;)&amp;lt;CR&amp;gt;&lt;/code&gt; (with various options) to the second mapping:&lt;/strong&gt; hang.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Solutions that seem plausible:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Temporarily remove the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; mapping, send &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, and re-add it.&lt;/li&gt;&#xA;&lt;li&gt;Have only one mapping which knows how to wait for a second &lt;kbd&gt;Esc&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Somehow put Vim into a &quot;waiting for more keys&quot; mode with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; in the buffer.&lt;/li&gt;&#xA;&lt;li&gt;Having a mapping which behaves like &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; but doesn't &quot;consume&quot; the key press.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="10083" LastEditorUserId="10083" LastEditDate="2017-03-09T18:53:11.240" LastActivityDate="2017-06-07T21:10:02.200" Title="Mapping one and two presses of the same key with no delay?" Tags="|key-bindings|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11688" PostTypeId="1" AcceptedAnswerId="11689" CreationDate="2017-03-09T17:16:09.677" Score="6" ViewCount="902" Body="&lt;p&gt;I use &lt;code&gt;{&lt;/code&gt;/&lt;code&gt;}&lt;/code&gt; a lot for navigating around, but when I do this I &lt;strong&gt;never&lt;/strong&gt; intend to open a fold and jump to blank lines &lt;em&gt;within&lt;/em&gt; the fold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I &lt;code&gt;nremap&lt;/code&gt; &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; to skip over folds?&lt;/p&gt;&#xA;" OwnerUserId="5778" LastActivityDate="2017-03-09T17:30:57.287" Title="Brace { } navigation without opening folds" Tags="|key-bindings|folding|navigation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11689" PostTypeId="2" ParentId="11688" CreationDate="2017-03-09T17:30:57.287" Score="9" Body="&lt;p&gt;&lt;em&gt;Thanks to @romainl for &lt;a href=&quot;https://superuser.com/a/836920/359608&quot;&gt;this answer on super user&lt;/a&gt;. I couldn't have written this without their help!&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;code&gt;foldopen&lt;/code&gt; option to determine which set of motions will or won't open a fold. From &lt;code&gt;:h 'foldopen'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *'foldopen'* *'fdo'*&#xA;'foldopen' 'fdo'    string (default: &quot;block,hor,mark,percent,quickfix,&#xA;                                 search,tag,undo&quot;)&#xA;            global&#xA;            {not in Vi}&#xA;            {not available when compiled without the |+folding|&#xA;            feature}&#xA;    Specifies for which type of commands folds will be opened, if the&#xA;    command moves the cursor into a closed fold.  It is a comma separated&#xA;    list of items.&#xA;    NOTE: When the command is part of a mapping this option is not used.&#xA;    Add the |zv| command to the mapping to get the same effect.&#xA;    (rationale: the mapping may want to control opening folds itself)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for which values are allowed, and which commands they affect, refer to this table:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;item        commands ~&#xA;all         any&#xA;block       &quot;(&quot;, &quot;{&quot;, &quot;[[&quot;, &quot;[{&quot;, etc.&#xA;hor         horizontal movements: &quot;l&quot;, &quot;w&quot;, &quot;fx&quot;, etc.&#xA;insert      any command in Insert mode&#xA;jump        far jumps: &quot;G&quot;, &quot;gg&quot;, etc.&#xA;mark        jumping to a mark: &quot;'m&quot;, CTRL-O, etc.&#xA;percent     &quot;%&quot;&#xA;quickfix    &quot;:cn&quot;, &quot;:crew&quot;, &quot;:make&quot;, etc.&#xA;search      search for a pattern: &quot;/&quot;, &quot;n&quot;, &quot;*&quot;, &quot;gd&quot;, etc.&#xA;                (not for a search pattern in a &quot;:&quot; command)&#xA;                Also for |[s| and |]s|.&#xA;tag         jumping to a tag: &quot;:ta&quot;, CTRL-T, etc.&#xA;undo        undo or redo: &quot;u&quot; and CTRL-R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, the &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; motions are in &lt;code&gt;block&lt;/code&gt;, so if you run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set foldopen-=block&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that should fix it for you.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-03-09T17:30:57.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11690" PostTypeId="2" ParentId="11687" CreationDate="2017-03-09T18:11:57.937" Score="0" Body="&lt;p&gt;You can try toggling on/off.&#xA;A sample vimscript like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func ToggleHLSearch()&#xA;  let hlsearch_opt = &amp;amp;hlsearch&#xA;  if(hlsearch_opt == 0)&#xA;     set hlsearch           &quot;Sets hlsearch on&#xA;  else&#xA;     set nohlsearch&#xA;  endif&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nw, map it to a key like &lt;kbd&gt;F9&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;F9&amp;gt; :call ToggleHLSearch()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Haven't tested the code Yet. Just a sample)&lt;/p&gt;&#xA;" OwnerUserId="7161" LastEditorUserId="1821" LastEditDate="2017-03-09T18:26:20.470" LastActivityDate="2017-03-09T18:26:20.470" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11691" PostTypeId="1" AcceptedAnswerId="11692" CreationDate="2017-03-09T18:34:24.047" Score="3" ViewCount="2176" Body="&lt;p&gt;I'm somewhat new to vim (read: really new). I'm used to vi-keys for moving and I understand the concept of operators vs motions vs commands and whatnot, but I'm still learning the commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I tried to open a file, my first instinct was &lt;code&gt;:open&lt;/code&gt;/&lt;code&gt;:o&lt;/code&gt;. This works, but doesn't support tab autocomplete.  &lt;code&gt;:edit&lt;/code&gt;/&lt;code&gt;:e&lt;/code&gt; works with tab autocomplete though. Furthermore, I've found &lt;code&gt;:visual&lt;/code&gt;, which appears to also have tab autocomplete. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the differences between these 3 commands? When do I use each of them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/2275/11389&quot;&gt;I've also found this, but that doesn't really explain the differences between &lt;code&gt;:open&lt;/code&gt; and the others.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation for the three says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vi[sual][!] [++opt] [+cmd] [file]&#xA;                When used in Ex mode: Leave |Ex-mode|, go back to&#xA;                Normal mode.  Otherwise same as |:edit|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e[dit] [++opt] [+cmd] {file}&#xA;                Edit {file}. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And lastly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]o[pen]          Works like |:visual|: end Ex mode.&#xA;                        {Vi: start editing in open mode}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... so they all just open a file? The other difference I can see is the 'end ex-mode', which I don't really get.&lt;/p&gt;&#xA;" OwnerDisplayName="user11389" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-03-09T18:59:27.923" Title="What's the difference between :open, :visual, and :edit?" Tags="|autocompletion|normal-mode|ex-mode|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11692" PostTypeId="2" ParentId="11691" CreationDate="2017-03-09T18:59:27.923" Score="5" Body="&lt;p&gt;So first things first, what is this &quot;ex-mode&quot;? &lt;a href=&quot;https://en.wikipedia.org/wiki/Ex_(text_editor)&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ex&lt;/a&gt; is an ancient text editor written by Bill Joy (the original author of vi). It is very primitive. Ex is a lot like vim, but without normal or insert modes. The only thing you can do is commands that start with a colon (known as &lt;em&gt;ex-commands&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;vi&lt;/code&gt; was written, a lot of people were used to &lt;code&gt;ex&lt;/code&gt; and didn't want to learn this fancy-shmancy new editor, so &lt;code&gt;vi&lt;/code&gt; was designed to be backwards compatible with &lt;code&gt;ex&lt;/code&gt;. Because of this, vi has an &lt;em&gt;ex-mode&lt;/em&gt;, where you can only use ex-commands. (Vim keeps it around for similar stupid reasons)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To enter ex-mode, type &lt;code&gt;Q&lt;/code&gt; in normal mode. To get out of this annoying mode, you can type the command &lt;code&gt;visual&lt;/code&gt; (or &lt;code&gt;vi&lt;/code&gt; as a shortcut). This will always put your cursor back where you started. &lt;code&gt;open&lt;/code&gt; is very similar to visual, except that it takes a number as an argument, and puts your cursor on that line. This makes sense since &lt;code&gt;ex&lt;/code&gt; was line-based and could only show a line at a time. So the idea behind the command was &quot;open line 'n' for me to look at/read&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, what is the difference between the three when you ignore ex-mode? Not really very much. As Josh explains in &lt;a href=&quot;https://vi.stackexchange.com/a/2277/2920&quot;&gt;this wonderful answer&lt;/a&gt;, &lt;code&gt;:visual&lt;/code&gt; and &lt;code&gt;:edit&lt;/code&gt; are implemented in the exact same place, so they're essentially the same (when you ignore &lt;code&gt;visual&lt;/code&gt; being used to leave ex-mode). This goes well with the help docs, where it states:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *:vi* *:visual*&#xA;:vi[sual][!] [++opt] [+cmd] [file]&#xA;            When used in Ex mode: Leave |Ex-mode|, go back to&#xA;            Normal mode.  Otherwise same as |:edit|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Otherwise same as :edit!&lt;/strong&gt; However, &lt;code&gt;:open&lt;/code&gt; is slightly different because 1) the ex-command is different (accepting a range) and 2) the normal command is different (accepting an optional pattern). So &lt;code&gt;:open&lt;/code&gt; has it's own separate implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now there's only one question remaining. Why does &lt;code&gt;:open&lt;/code&gt; not tab-complete? I'm not Bram Moolenaar, so I could be wrong, but it's probably because the open command takes a pattern as an argument. It makes sense for it to behave more like &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;:s/&lt;/code&gt; when the user could be typing a regex &lt;em&gt;or&lt;/em&gt; a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To summarize:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If you want to edit a file, use &lt;code&gt;:e&lt;/code&gt;. It's standard, well-supported, and convenient (because of tab-complete). You could use &lt;code&gt;:visual&lt;/code&gt; if you &lt;em&gt;really&lt;/em&gt; want too, but it's an unusual practice and confusing.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Generally avoid ex-mode. If you want to leave ex-mode, either &lt;code&gt;visual&lt;/code&gt; or &lt;code&gt;open&lt;/code&gt; are fine ways to exit it (depending on which behavior you want)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I have no idea why Bram chose to make it so that using the right command in the wrong context (e.g. &lt;code&gt;visual&lt;/code&gt; or &lt;code&gt;open&lt;/code&gt; from normal mode) defaults to pretending to be &lt;code&gt;:edit&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-03-09T18:59:27.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11693" PostTypeId="2" ParentId="11687" CreationDate="2017-03-09T20:02:25.567" Score="2" Body="&lt;p&gt;I found a way: use &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt;, an un-typeable &quot;key&quot; intended for mappings to call each other, to let the single-&lt;kbd&gt;Esc&lt;/kbd&gt; mapping prime the other one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;&amp;lt;Esc&amp;gt; :set hls&amp;lt;CR&amp;gt;:let @/=&quot;\\&amp;lt;&amp;lt;C-R&amp;gt;=expand('&amp;lt;cword&amp;gt;')&amp;lt;CR&amp;gt;\\&amp;gt;&quot;&amp;lt;CR&amp;gt;:call histadd(&quot;/&quot;, @/)&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;Esc&amp;gt; :noh&amp;lt;CR&amp;gt;&amp;lt;Plug&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This could be enhanced by adding a name (&lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; → &lt;code&gt;&amp;lt;Plug&amp;gt;HLSearch&lt;/code&gt;) and/or &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; to avoid a conflict with another mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;script&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;SID&amp;gt;&amp;lt;Plug&amp;gt;&amp;lt;Esc&amp;gt; :set hls&amp;lt;CR&amp;gt;:let @/=&quot;\\&amp;lt;&amp;lt;C-R&amp;gt;=expand('&amp;lt;cword&amp;gt;')&amp;lt;CR&amp;gt;\\&amp;gt;&quot;&amp;lt;CR&amp;gt;:call histadd(&quot;/&quot;, @/)&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;script&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;Esc&amp;gt; :noh&amp;lt;CR&amp;gt;&amp;lt;SID&amp;gt;&amp;lt;Plug&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10083" LastActivityDate="2017-03-09T20:02:25.567" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11695" PostTypeId="1" CreationDate="2017-03-10T01:08:55.403" Score="0" ViewCount="11" Body="&lt;p&gt;If my .vimrc file has this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=dark&#xA;highlight Comment term=bold ctermfg=white&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...comments are white as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I reverse the order of the statements:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight Comment term=bold ctermfg=white&#xA;set background=dark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...comments are light blue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what really has me confused is that I had &lt;code&gt;highlight&lt;/code&gt; directive before the &lt;code&gt;background&lt;/code&gt; directive for the longest time and comments were still white. Now all of a sudden I'm seeing this behavior. What can explain this?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="51" LastEditDate="2017-03-10T02:03:20.400" LastActivityDate="2017-03-10T02:03:20.400" Title="&quot;set background=dark&quot; masking highlight command" Tags="|vimrc|syntax-highlighting|" AnswerCount="0" CommentCount="2" ClosedDate="2017-03-10T02:05:05.307" ContentLicense="CC BY-SA 3.0" />
  <row Id="11696" PostTypeId="1" AcceptedAnswerId="11705" CreationDate="2017-03-10T01:16:31.930" Score="25" ViewCount="21735" Body="&lt;p&gt;I understand that it loads the &lt;code&gt;ftplugin.vim&lt;/code&gt; file, but what does it really do? Does it set options (depending on the filetype)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I were to include this line at the start of my vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then I set some options after this line (like autoindent, smartindent, etc.), would it mess with them? How can I know which options are affected by a filetype plugin or indent file?&lt;/p&gt;&#xA;" OwnerUserId="11717" LastActivityDate="2019-10-01T13:32:51.537" Title="What does &quot;filetype plugin on&quot; really do?" Tags="|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11697" PostTypeId="1" AcceptedAnswerId="11698" CreationDate="2017-03-10T03:59:45.533" Score="11" ViewCount="9807" Body="&lt;p&gt;I have a file with several lines like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&quot;latin&quot;: &quot;&quot;, &quot;french&quot;: &quot;&quot;, &quot;italian&quot;: &quot;&quot;, &quot;catalan&quot;: &quot;&quot;, &quot;portuguese&quot;: &quot;&quot;, &quot;romanian&quot;: &quot;&quot;, &quot;spanish&quot;: &quot;&quot;, &quot;english&quot;: &quot;&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to quickly move between the empty quotes to enter data. Is there a short-cut that could be used here?&lt;/p&gt;&#xA;" OwnerUserId="7783" LastActivityDate="2018-03-28T00:21:53.780" Title="Move inside next quotes?" Tags="|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11698" PostTypeId="2" ParentId="11697" CreationDate="2017-03-10T04:09:57.300" Score="15" Body="&lt;p&gt;&lt;code&gt;f&quot;&lt;/code&gt; jumps to the next quote, and &lt;code&gt;F&quot;&lt;/code&gt; jumps to the previous one. &lt;code&gt;3f&quot;&lt;/code&gt; jumps three more quotes, and so on. This seems enough to me. If the cursor is inside the quote, and you want to jump to the position just before the ending quote, &lt;code&gt;t&quot;&lt;/code&gt; may be used, and similar is said of &lt;code&gt;T&quot;&lt;/code&gt;. In your case, &lt;code&gt;e&lt;/code&gt; (jump to the last character of the current word) and &lt;code&gt;b&lt;/code&gt; (jump to the first character of the current word) also do the same thing.&lt;/p&gt;&#xA;" OwnerUserId="10241" LastActivityDate="2017-03-10T04:09:57.300" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11699" PostTypeId="1" CreationDate="2017-03-10T07:08:28.510" Score="3" ViewCount="1138" Body="&lt;p&gt;An example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Doe, John  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;John Doe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I cut &lt;code&gt;Doe&lt;/code&gt; with &lt;kbd&gt;D&lt;/kbd&gt;, and then &lt;kbd&gt;0&lt;/kbd&gt; and then &lt;kbd&gt;p&lt;/kbd&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what I get is this:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DJohn oe,  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to do this right?&lt;/p&gt;&#xA;" OwnerUserId="5346" LastEditorUserId="5395" LastEditDate="2017-03-10T12:07:57.970" LastActivityDate="2017-04-19T09:53:43.520" Title="Cut and then paste at the beginning of the line" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11700" PostTypeId="2" ParentId="11586" CreationDate="2017-03-10T08:59:21.340" Score="0" Body="&lt;p&gt;I will post my code as an answer to make it more visible. (Disclaimer: @laktak has included a &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; number, but it causes errors, and I have not understood its purpose.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; To set the statusline for all windowss.&#xA;function! RefreshStatusLine()&#xA;    for i in range(1, winnr('$'))&#xA;        call setwinvar(i, '&amp;amp;statusline', '%!GetStatusLine(' . i . ')')&#xA;    endfor&#xA;endfunction&#xA;&#xA;&quot; To choose the statusline for either active or inactive windowss.&#xA;function! GetStatusLine(num_active_window)&#xA;    return a:num_active_window==winnr() ? s:active_statusline : s:inactive_statusline&#xA;endfunction&#xA;&#xA;&quot; First to define that for the only active windows.&#xA;let s:active_statusline='%1* %F %*%2*%m%r%h%*%3* B:%n %*%4* L:%l/%L %*%5* C:%c%V %*'&#xA;&quot; Next to define those for other inactive windowss.&#xA;let s:inactive_statusline=' %F %m%r%h B:%n  L:%l/%L  C:%c%V '&#xA;&#xA;&quot; Set the statusline whenever the active windows changes.&#xA;autocmd VimEnter,WinEnter,BufWinEnter * call RefreshStatusLine()&#xA;&#xA;&quot; The following lines must come after colorscheme declaration&#xA;highlight User1 guifg=#ffffff  guibg=#660000&#xA;highlight User2 guifg=#ffffff  guibg=#990033&#xA;highlight User3 guifg=#ffffff  guibg=#666600&#xA;highlight User4 guifg=#ffffff  guibg=#336633&#xA;highlight User5 guifg=#ffffff  guibg=#336699&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10241" LastActivityDate="2017-03-10T08:59:21.340" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11701" PostTypeId="2" ParentId="11696" CreationDate="2017-03-10T09:52:38.343" Score="5" Body="&lt;p&gt;It defines autocommands that'll get executed when a file matching a given pattern is opened. These autocommands &lt;code&gt;source&lt;/code&gt; in turn the filetype plugin&lt;strong&gt;s&lt;/strong&gt; associated to the filetype recognized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In those filetype plugin scripts, you'll be able to find/write anything that you can put in a vim script. The good practice is no never define global things, but exclusively local things. i.e:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;local options with &lt;code&gt;:setlocal opt=value&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;local mappings with &lt;code&gt;:[cnivsxot](nore)map &amp;lt;buffer&amp;gt; ...&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;local abbreviations with &lt;code&gt;:iab-&amp;lt;buffer&amp;gt; ...&lt;/code&gt; &amp;amp; co&lt;/li&gt;&#xA;&lt;li&gt;local commands with &lt;code&gt;:command -b ...&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;local variables with &lt;code&gt;:let b:var = 42&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Regarding &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;menus, you'll have to use plugins that emulate local menus, see Michael Geddes' plugin or &lt;a href=&quot;https://github.com/LucHermitte/lh-misc/blob/master/plugin/buffermenu.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;my modernized fork&lt;/a&gt; ;&lt;/li&gt;&#xA;&lt;li&gt;functions, you can put them in ftplugins, but they are best defined in autoload plugins.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-10-07T11:30:10.247" LastActivityDate="2017-10-07T11:30:10.247" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11702" PostTypeId="1" CreationDate="2017-03-10T10:11:29.790" Score="0" ViewCount="59" Body="&lt;p&gt;I live most of my working hours inside vim.&#xA;My institution uses an email client server provided by &lt;a href=&quot;https://www.zimbra.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;zimbra&lt;/a&gt;. The email domain starts with &lt;code&gt;zimbra***inst.fr.&lt;/code&gt;&#xA;Is there a way to read, compose and send emails from vim?&lt;/p&gt;&#xA;" OwnerUserId="10566" LastActivityDate="2017-03-10T12:09:53.147" Title="Read, compose and send zimbra emails from vim" Tags="|plugin-system|clientserver|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11703" PostTypeId="2" ParentId="11702" CreationDate="2017-03-10T12:09:53.147" Score="1" Body="&lt;p&gt;Try &lt;a href=&quot;http://www.mutt.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;mutt&lt;/a&gt; which can open mails in vim. &lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-10T12:09:53.147" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11704" PostTypeId="1" CreationDate="2017-03-10T14:15:10.610" Score="2" ViewCount="1193" Body="&lt;p&gt;Most of my edits are done in .html files. However, I write a lot of jinja code and css in these html files.&lt;/p&gt;&#xA;&lt;h2&gt;Problem 1: Jinja Indentation&lt;/h2&gt;&#xA;&lt;p&gt;whenever I have a bloc such as this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{{ my_macro(arg1, arg2, arg3) }} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My ideal level of indentation will be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;previous line indents here&amp;gt; &#xA;{{ my_macro(arg1,&#xA;            arg2,&#xA;            arg3) }} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, right now I am seeing this level of indentation in my vim :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;previous line indents here&amp;gt; &#xA;{{ my_macro(arg1,&#xA;arg2,&#xA;arg3) }} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Problem 2: CSS indentation&lt;/h2&gt;&#xA;&lt;p&gt;I have the following style element:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div parent&amp;gt;&#xA;  &amp;lt;style&amp;gt;&#xA;  .indent-should-be-here {}&#xA;  &amp;lt;/style&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but in reality I am seeing:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div parent&amp;gt;&#xA;  &amp;lt;style&amp;gt;&#xA;.indent-on-the-left-most-why {}&#xA;  &amp;lt;/style&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I currently have Vim-Jinja2-Syntax installed. But it only calls the html indent. See .vim/bundle/Vim-Jinja-Syntax/indent/jinja.vim&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Vim indent file&#xA;&amp;quot; Language: Jinja HTML template&#xA;&amp;quot; Maintainer:   Evan Hammer &amp;lt;evan@evanhammer.com&amp;gt;&#xA;&amp;quot; Last Change:  2013 Jan 26&#xA;&#xA;&amp;quot; Only load this indent file when no other was loaded.&#xA;if exists(&amp;quot;b:did_indent&amp;quot;)&#xA;  finish&#xA;endif&#xA;&#xA;&amp;quot; Use HTML formatting rules.&#xA;runtime! indent/html.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Does anyone have a recommendation for me?&lt;/p&gt;&#xA;" OwnerUserId="11727" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-03-15T19:57:11.867" Title="Vim indentation for html files" Tags="|indentation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11705" PostTypeId="2" ParentId="11696" CreationDate="2017-03-10T14:33:08.127" Score="10" Body="&lt;p&gt;There is actually a good description in &lt;code&gt;help filetype&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any options that are defined for a filetype will be set with &lt;code&gt;setlocal&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setl[ocal] ...     Like &quot;:set&quot; but set only the value local to the&#xA;                    current buffer or window.  Not all options have [..]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example &lt;code&gt;/usr/share/vim/vim80/ftplugin/javascript.vim&lt;/code&gt; defines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal commentstring=//%s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because local options have priority over global ones your &lt;code&gt;.vimrc&lt;/code&gt; settings might be ignored. In that case you need to create a file &lt;code&gt;~/.vim/after/ftplugin/javascript.vim&lt;/code&gt; (with the name of the filetype you wish to change) and set your own &lt;code&gt;setlocal&lt;/code&gt; options in there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way to see which options are set is to just open the files for the filetype in &lt;code&gt;/usr/share/vim/vim80/ftplugin&lt;/code&gt;, &lt;code&gt;../indent&lt;/code&gt; and &lt;code&gt;../syntax&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="10337" LastEditDate="2019-10-01T13:32:51.537" LastActivityDate="2019-10-01T13:32:51.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11707" PostTypeId="1" CreationDate="2017-03-11T01:53:49.180" Score="2" ViewCount="298" Body="&lt;p&gt;I want something similar to what I get when I enter debug mode and type &quot;step&quot;, then enter and up, enter and up, ten thousand times... But without having to do all that work, allows it to be done programmatically and ideally with a cleaner output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. given this file, named &lt;code&gt;example.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! F()&#xA;  echo 1&#xA;  echo 2&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Today the best I can do is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ nvim --noplugin -u example.vim -E +'debug call F()'&#xA;Entering Debug mode.  Type &quot;cont&quot; to continue.&#xA;command line&#xA;cmd: call F()&#xA;&amp;gt;step&#xA;function F&#xA;line 1: echo 1&#xA;&amp;gt;step&#xA;1&#xA;function F&#xA;line 2: echo 2&#xA;&amp;gt;step&#xA;2&#xA;function F&#xA;line 2: End of function&#xA;&amp;gt;step&#xA;Entering Ex mode.  Type &quot;visual&quot; to go to Normal mode.&#xA;:q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wish I had this (or something at least close to it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ nvim_stepthrough example.vim 'call F()'&#xA;call F()&#xA;  line 1: echo 1&#xA;  1&#xA;  line 2: echo 2&#xA;  2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(or a &lt;code&gt;StepThrough call F()&lt;/code&gt; vimscript command that gave similar output)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been trying to be clever with the shell to achieve something like this with piping and fifos and redirection but so far the only thing I've accomplished was crashing my computer*.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a few ideas on how I could do this, but before I delve deep into it I wanted to know if there is anything that already exists that can accomplish something similar.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;*tip: don't &lt;code&gt;yes step&lt;/code&gt; to &lt;code&gt;nvim -D &amp;amp;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11151" LastActivityDate="2017-03-11T01:53:49.180" Title="How can I view all of the vimscript run by a command? (neovim)" Tags="|vimscript|command-line|neovim|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11708" PostTypeId="1" AcceptedAnswerId="11711" CreationDate="2017-03-11T04:18:47.633" Score="1" ViewCount="518" Body="&lt;p&gt;I want to use &lt;code&gt;get&lt;/code&gt; with the environment variable namespace, so instead of this in the &lt;em&gt;global&lt;/em&gt; namespace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let vim_data_dir = get(g:, 'vim_data_dir', &quot;default value if not set&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Something like this, in the &lt;code&gt;$&lt;/code&gt; or &lt;em&gt;environment variable&lt;/em&gt; namespace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $VIM_DATA_DIR = get($, 'VIM_DATA_DIR', &quot;default value if not set&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The help says that the first parameter to &lt;code&gt;get&lt;/code&gt; is a list. How do I get all environment variables as a list?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="205" LastEditDate="2017-03-11T07:18:38.177" LastActivityDate="2017-03-11T09:57:04.303" Title="Using get with environment variable namespace" Tags="|environment-variables|list|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11710" PostTypeId="2" ParentId="11708" CreationDate="2017-03-11T09:38:37.550" Score="1" Body="&lt;p&gt;&lt;code&gt;$VIM_DATA_DIR&lt;/code&gt; already gives you the environment variable, so you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $VIM_DATA_DIR = !empty($VIM_DATA_DIR) ? $VIM_DATA_DIR : &quot;default&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you really need all environment variables take a look at &lt;a href=&quot;https://stackoverflow.com/a/11192777/52817&quot;&gt;this answer on stackoverflow&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Env()&#xA;    redir =&amp;gt; s&#xA;    sil! exe &quot;norm!:ec$\&amp;lt;c-a&amp;gt;'\&amp;lt;c-b&amp;gt;\&amp;lt;right&amp;gt;\&amp;lt;right&amp;gt;\&amp;lt;del&amp;gt;'\&amp;lt;cr&amp;gt;&quot;&#xA;    redir END&#xA;    return split(s)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-03-11T09:38:37.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11711" PostTypeId="2" ParentId="11708" CreationDate="2017-03-11T09:57:04.303" Score="2" Body="&lt;p&gt;In that case, you could simply use the good old &lt;code&gt;exists()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let foo = exists('$FOO') ? $FOO : 'default'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;code&gt;empty()&lt;/code&gt;, IMO it only makes sense if you want to undefine environment variables from within Vim. Indeed, as &lt;code&gt;:unlet $FOO&lt;/code&gt; isn't possible, yet, we have to use &lt;code&gt;:let $FOO=''&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To obtain all environment variables, you could use &lt;code&gt;getcompletion()&lt;/code&gt; on recent vim versions. The latest version of my &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;obtain-whatever function&lt;/a&gt; looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Function: lh#command#matching_askvim(what, lead) {{{3&#xA;if exists('*getcompletion')&#xA;  function! lh#command#matching_askvim(what, lead) abort&#xA;    return getcompletion(a:lead, a:what)&#xA;  endfunction&#xA;else&#xA;  function! lh#command#matching_askvim(what, lead) abort&#xA;    let cleanup = lh#on#exit()&#xA;          \.register('delcom LHAskVimMatchingCompletion')&#xA;    try&#xA;      exe 'command! -complete='.a:what.' -nargs=* LHAskVimMatchingCompletion :echo &quot;&amp;lt;args&amp;gt;&quot;'&#xA;      if exists('*getcmdline')&#xA;        call cleanup&#xA;              \.restore('g:cmds')&#xA;              \.restore_buffer_mapping('?', 'c')&#xA;              \.restore_mapping_and_clear_now('&amp;lt;c-a&amp;gt;', 'c')&#xA;        cnoremap &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; ? s:register()&#xA;        function! s:register()&#xA;          let g:cmds = split(getcmdline(), ' ')[1:]&#xA;          return ''&#xA;        endfunction&#xA;        silent! exe &quot;norm :LHAskVimMatchingCompletion &quot;.a:lead.&quot;\&amp;lt;c-a&amp;gt;?&quot;&#xA;        return g:cmds&#xA;      else&#xA;        &quot; The following may lead to problem with unescaped quotes =&amp;gt; use&#xA;        &quot; getcmdline() when available&#xA;        silent! exe &quot;norm! :LHAskVimMatchingCompletion &quot;.a:lead.&quot;\&amp;lt;c-a&amp;gt;\&quot;\&amp;lt;home&amp;gt;let\ cmds=\&quot;\&amp;lt;cr&amp;gt;&quot;&#xA;        return split(cmds, ' ')[1:]&#xA;      endif&#xA;    finally&#xA;      call cleanup.finalize()&#xA;    endtry&#xA;  endfunction&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(It's complex in order to support mappings as well)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To obtain all environment variables, you can then use: &lt;code&gt;echo lh#command#matching_askvim('environment', '')&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-03-11T09:57:04.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11712" PostTypeId="1" AcceptedAnswerId="11720" CreationDate="2017-03-11T14:39:54.520" Score="2" ViewCount="115" Body="&lt;p&gt;To take a short cut in writing markdown files I need an abbreviation which can combine these abbreviations,    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType * iabbrev pythoncode ```python```&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;cr&amp;gt;jjO&amp;lt;C-R&amp;gt;=Eatchar('\s')&amp;lt;cr&amp;gt;    &#xA;autocmd FileType * iabbrev vimcode ```vim```&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;cr&amp;gt;jjO&amp;lt;C-R&amp;gt;=Eatchar('\s')&amp;lt;cr&amp;gt;    &#xA;autocmd FileType * iabbrev bashcode ```bash```&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;cr&amp;gt;jjO&amp;lt;C-R&amp;gt;=Eatchar('\s')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into one,    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType * iabbrev [aLanguage]code ```[aLanguage]```&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;cr&amp;gt;jjO&amp;lt;C-R&amp;gt;=Eatchar('\s')&amp;lt;cr&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know how to start with. In the input the &quot;code&quot; can be put ahead, resulting in the command being &lt;code&gt;code[aLanguage]&lt;/code&gt;, if it is more eligible. &lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="1788" LastEditDate="2017-03-12T04:38:22.760" LastActivityDate="2017-03-12T07:51:23.410" Title="One abbreviation for various commands with different prefix?" Tags="|abbreviations|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11713" PostTypeId="2" ParentId="5015" CreationDate="2017-03-11T18:37:49.890" Score="2" Body="&lt;p&gt;I love VIM, but the learning curve is steep. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any professional who hasn't adopted VIM yet is unlikely to be persuaged by &lt;strong&gt;&lt;em&gt;argument&lt;/em&gt;&lt;/strong&gt;. Only by necessity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Listening to people who say they use VIM on a regular basis, the largest use case are from admins managing multiple *NIX machines remotely with CLI via SSH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VIM is literally installed on nearly every *NIX machine on the planet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VIM is 25+ years old and unchanged since I started using it in 1998. &lt;/p&gt;&#xA;" OwnerUserId="1694" LastActivityDate="2017-03-11T18:37:49.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11715" PostTypeId="2" ParentId="5015" CreationDate="2017-03-11T21:19:10.857" Score="2" Body="&lt;p&gt;&lt;strong&gt;Ergonomics&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the right setup I can work for hours without getting any shoulder or back pains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The right setup is of course different for everyone, but using Vim in a terminal, mapping &lt;kbd&gt;Esc&lt;/kbd&gt; to &lt;kbd&gt;Capslock&lt;/kbd&gt; and disabling the mouse and the cursor keys is a good start.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="5395" LastEditDate="2018-09-26T08:41:20.340" LastActivityDate="2018-09-26T08:41:20.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11716" PostTypeId="1" CreationDate="2017-03-11T22:36:47.687" Score="1" ViewCount="94" Body="&lt;p&gt;Question says it all. Why does vim report no mapping exists when a mapping does exist?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2017-03-12T21:14:08.007" Title="Shift-k opens manual on keyword but &quot;:verbose map &lt;s-k&gt;&quot; shows no mapping" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11717" PostTypeId="1" AcceptedAnswerId="11718" CreationDate="2017-03-11T23:08:21.140" Score="-1" ViewCount="56" Body="&lt;p&gt;I would like to pass from one buffer to another as in this &lt;a href=&quot;https://camo.githubusercontent.com/ba79534309330accd776a8d2a0712f7c4037d7f9/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f3330363530322f313037323632332f34346332393261302d313439352d313165332d396365362d6463616461336631633533362e676966&quot; rel=&quot;nofollow noreferrer&quot;&gt;website&lt;/a&gt;. Could anyone have an idea how to do such thing? I fact, to open a new window, I use &lt;code&gt;vnew&lt;/code&gt;, and to change the buffer I use either &lt;code&gt;:bn&lt;/code&gt;, &lt;code&gt;:bp&lt;/code&gt; or &lt;code&gt;:b &amp;lt;file&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user11652" LastEditorUserId="205" LastEditDate="2017-03-12T03:14:19.627" LastActivityDate="2017-03-12T17:42:52.657" Title="Pass from one buffer to another quicly" Tags="|buffers|" AnswerCount="1" CommentCount="1" ClosedDate="2017-03-14T11:55:35.427" ContentLicense="CC BY-SA 3.0" />
  <row Id="11718" PostTypeId="2" ParentId="11717" CreationDate="2017-03-11T23:52:31.030" Score="0" Body="&lt;p&gt;If you are looking for a quick shortcut to change buffers, checkout &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-unimpaired&lt;/a&gt;, which provides a mapping to change buffers using &lt;code&gt;[b&lt;/code&gt; and &lt;code&gt;]b&lt;/code&gt; along with many other similarly handy and intuitive mappings.&lt;/p&gt;&#xA;" OwnerUserId="11189" LastEditorUserId="11189" LastEditDate="2017-03-12T17:42:52.657" LastActivityDate="2017-03-12T17:42:52.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11720" PostTypeId="2" ParentId="11712" CreationDate="2017-03-12T06:43:07.760" Score="3" Body="&lt;p&gt;You could use a loop and &lt;code&gt;exec&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for l in [&quot;python&quot;, &quot;vim&quot;, &quot;bash&quot;]&#xA;    exec 'autocmd FileType * iabbrev' l.&quot;code ```&quot; l.&quot;```&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;cr&amp;gt;jjO&amp;lt;C-R&amp;gt;=Eatchar('\s')&amp;lt;cr&amp;gt;&quot;&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="1788" LastEditDate="2017-03-12T07:51:23.410" LastActivityDate="2017-03-12T07:51:23.410" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11722" PostTypeId="2" ParentId="4682" CreationDate="2017-03-12T15:55:15.060" Score="11" Body="&lt;p&gt;Starting with Vim 8.0.1308 (Nov 2017), you can use the &quot;--not-a-term&quot; option&#xA;with &quot;quit&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo hello | vi - --not-a-term -esc '%p|q!'&#xA;hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or with &quot;exit&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo hello | vi - --not-a-term -esc 'x!/dev/stdout'&#xA;hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://github.com/vim/vim/issues/1552&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://github.com/vim/vim/issues/1552&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="7184" LastEditDate="2020-03-29T23:34:50.240" LastActivityDate="2020-03-29T23:34:50.240" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11726" PostTypeId="1" AcceptedAnswerId="11727" CreationDate="2017-03-12T17:13:44.133" Score="15" ViewCount="1980" Body="&lt;p&gt;Where did the name &lt;em&gt;vimrc&lt;/em&gt; come from? Is the &lt;code&gt;rc&lt;/code&gt; part an acronym? Are there historical reasons for picking this name? Where did the practice of using &lt;code&gt;rc&lt;/code&gt; for configuration files &lt;em&gt;first&lt;/em&gt; come from?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For what it's worth, I am aware that this is not unique to vim. That's why we have &lt;code&gt;.bashrc&lt;/code&gt;, &lt;code&gt;.hgrc&lt;/code&gt;, etc.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-03-12T17:30:57.237" Title="Why is it called a &quot;vimrc&quot; file?" Tags="|vimrc|history-of|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11727" PostTypeId="2" ParentId="11726" CreationDate="2017-03-12T17:30:57.237" Score="21" Body="&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Configuration_file#UNIX.2FLinux&quot; rel=&quot;noreferrer&quot;&gt;Unix section&lt;/a&gt; of the wiki page on &lt;a href=&quot;https://en.wikipedia.org/wiki/Configuration_file&quot; rel=&quot;noreferrer&quot;&gt;configuration files&lt;/a&gt;, leads to the wiki page on &lt;a href=&quot;https://en.wikipedia.org/wiki/Run_commands&quot; rel=&quot;noreferrer&quot;&gt;run commands&lt;/a&gt;, which is where the rc comes from. Quoting from the run commands page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In the context of Unix-like systems, the term rc stands for the phrase &quot;run commands&quot;. It is used for any file that contains startup information for a command. It is believed to have originated somewhere in 1965 from a runcom facility from the MIT Compatible Time-Sharing System (CTSS).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Additionally, they refer to vim with the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;While not historically precise, rc may also be expanded as &quot;run control&quot;, because an rc file controls how a program runs. For instance, the editor Vim looks for and reads the contents of the .vimrc file to determine its initial configuration. In The Art of Unix Programming, Eric S. Raymond consistently refers to rc files as &quot;run-control&quot; files.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2017-03-12T17:30:57.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11728" PostTypeId="2" ParentId="11636" CreationDate="2017-03-12T19:46:52.350" Score="3" Body="&lt;p&gt;Well, I finally found the answer myself, and figured I'd leave this as documentation for others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Problem:&lt;/em&gt; You want to use GCC as your only maker for C files. You set up Neomake and (Neo)vim the 'obvious' way, but it doesn't do any checking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Solution:&lt;/em&gt; There's a couple of things involved here. Firstly, you need to ensure that (Neo)vim doesn't decide arbitrarily that &lt;code&gt;.h&lt;/code&gt; files are C++ (which it does by default):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:c_syntax_for_h=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, disable all makers for C except for GCC:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:neomake_c_enabled_makers=['gcc']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, sprinkle in appropriate arguments (the following are examples) to get the most out of your maker:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:neomake_gcc_args=[&#xA;    \ '-fsyntax-only',&#xA;    \ '-std=gnu11',&#xA;    \ '-Wall',&#xA;    \ '-Wextra',&#xA;    \ '-fopenmp',&#xA;    \ '-I.'&#xA;    \ ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, you should have proper checking on both &lt;code&gt;.h&lt;/code&gt; and &lt;code&gt;.c&lt;/code&gt; files.&lt;/p&gt;&#xA;" OwnerUserId="11640" LastActivityDate="2017-03-12T19:46:52.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11729" PostTypeId="2" ParentId="11716" CreationDate="2017-03-12T21:14:08.007" Score="2" Body="&lt;p&gt;&lt;code&gt;:map&lt;/code&gt; will only show mappings that were defined by a plugin/vim script or by you in your &lt;code&gt;.vimrc&lt;/code&gt;. &lt;code&gt;K&lt;/code&gt; is not a mapping, it's a command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably did not find a help entry because you used the &lt;code&gt;&amp;lt;s-k&amp;gt;&lt;/code&gt; syntax. Try &lt;code&gt;:help K&lt;/code&gt; like Christian suggested.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-12T21:14:08.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11730" PostTypeId="1" AcceptedAnswerId="11731" CreationDate="2017-03-12T22:14:54.107" Score="2" ViewCount="990" Body="&lt;p&gt;I have a binding in my &lt;code&gt;.vimrc&lt;/code&gt; that reads the contents of the system clipboard to a line immediately below my cursor&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;f &amp;lt;esc&amp;gt; :read ! test -f /usr/bin/xsel &amp;amp;&amp;amp; /usr/bin/xsel -ob \|\| /usr/bin/pbpaste&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to change it to (1)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;f &amp;lt;esc&amp;gt; :read ! /usr/bin/xsel -ob \|\| /usr/bin/pbpaste&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or (2)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;f &amp;lt;esc&amp;gt; :read ! /usr/bin/xsel -ob ; /usr/bin/pbpaste&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for the sake of simplicity, even though it's more brittle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I change it to either of those, however, I get the contents of stderr in my buffer as well, as if &lt;code&gt;vim&lt;/code&gt; is reading from both &lt;code&gt;stdout&lt;/code&gt; and &lt;code&gt;stderr&lt;/code&gt; when executing the command. (this is after &lt;code&gt;echo clipboard_contents | pbcopy&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/bin/sh: /usr/bin/xsel: No such file or directory&#xA;clipboard_contents&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is vim doing that? Is there a way to tell it to silently drop stderr in this case or redirect it to &lt;code&gt;/dev/null&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2017-03-13T00:18:56.337" LastActivityDate="2017-03-13T02:06:39.327" Title="read from external command captures stderr as well" Tags="|external-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11731" PostTypeId="2" ParentId="11730" CreationDate="2017-03-13T02:06:39.327" Score="4" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#%3Ar%21&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :r!&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;                                                        :r! :read!&#xA;:[range]r[ead] [++opt] !{cmd}&#xA;                        Execute {cmd} and insert its standard output below&#xA;                        the cursor or the specified line.  A temporary file is&#xA;                        used to store the output of the command which is then&#xA;                        read into the buffer.  &lt;strong&gt;'shellredir' is used to save&#xA;                        the output of the command, which can be set to include&#xA;                        stderr or not.&lt;/strong&gt;&lt;/pre&gt; &#xA;&#xA;&lt;p&gt;And in &lt;code&gt;:h 'shellredir'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'shellredir' 'srr'      string  (default &quot;&amp;gt;&quot;, &quot;&amp;gt;&amp;amp;&quot; or &quot;&amp;gt;%s 2&amp;gt;&amp;amp;1&quot;)&#xA;                        global&#xA;                        {not in Vi}&#xA;        String to be used to put the output of a filter command in a temporary&#xA;        file.  ...&#xA;        The default is &quot;&amp;gt;&quot;.  For Unix, if the 'shell' option is &quot;csh&quot;, &quot;tcsh&quot;&#xA;        or &quot;zsh&quot; during initializations, the default becomes &quot;&amp;gt;&amp;amp;&quot;.  If the&#xA;        'shell' option is &quot;sh&quot;, &quot;ksh&quot; or &quot;bash&quot; the default becomes&#xA;        &quot;&amp;gt;%s 2&amp;gt;&amp;amp;1&quot;.  This means that stderr is also included.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, just do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shellredir=&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-03-13T02:06:39.327" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11732" PostTypeId="1" CreationDate="2017-03-13T03:31:05.687" Score="0" ViewCount="51" Body="&lt;p&gt;I use F12 on the Mac (10.11.6)  I've mapped F12 to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; map! ^[[24~ &amp;lt;ESC&amp;gt;:w&amp;lt;CR&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to write my file and return to adding text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use this mapping I see &quot;Insert&quot; on the status line.&#xA;Is there a way to delay before the insert begins so the&#xA;file name is visible as when one does a manual &lt;code&gt;&amp;lt;ESC&amp;gt;:w&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="11752" LastEditorUserId="205" LastEditDate="2017-03-13T06:32:26.660" LastActivityDate="2017-03-13T08:07:14.250" Title="Have filename show on status line in &quot;map! &lt;F12&gt; &lt;ESC&gt;:w&lt;CR&gt;a&quot; rather than Insert" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11733" PostTypeId="2" ParentId="9522" CreationDate="2017-03-13T07:32:31.240" Score="15" Body="&lt;p&gt;To expand on the &quot;can it replace plugin managers&quot;,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to use Vundle, which was fantastic, but now have replaced it with 18 or so lines of bash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find it useful to use subfolders in the pack directory to group related plugins. E.g. &quot;Syntax&quot; or &quot;Ruby&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant bash example is below. Place in a file and run it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additional discussion around the topic at: &lt;a href=&quot;https://stories.abletech.nz/get-rid-of-your-vim-plugin-manager-7c8ff742f643#.abnjauzgk&quot; rel=&quot;noreferrer&quot;&gt;https://stories.abletech.nz/get-rid-of-your-vim-plugin-manager-7c8ff742f643#.abnjauzgk&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env bash&#xA;# This file lives in ~/.vim/pack/install.sh&#xA;# Remember to add executable: chmod +x ~/.vim/pack/install.sh&#xA;#&#xA;# Create new folder in ~/.vim/pack that contains a start folder and cd into it.&#xA;#&#xA;# Arguments:&#xA;#   package_group, a string folder name to create and change into.&#xA;#&#xA;# Examples:&#xA;#   set_group syntax-highlighting&#xA;#&#xA;function set_group () {&#xA;  package_group=$1&#xA;  path=&quot;$HOME/.vim/pack/$package_group/start&quot;&#xA;  mkdir -p &quot;$path&quot;&#xA;  cd &quot;$path&quot; || exit&#xA;}&#xA;# Clone or update a git repo in the current directory.&#xA;#&#xA;# Arguments:&#xA;#   repo_url, a URL to the git repo.&#xA;#&#xA;# Examples:&#xA;#   package https://github.com/tpope/vim-endwise.git&#xA;#&#xA;function package () {&#xA;  repo_url=$1&#xA;  expected_repo=$(basename &quot;$repo_url&quot; .git)&#xA;  if [ -d &quot;$expected_repo&quot; ]; then&#xA;    cd &quot;$expected_repo&quot; || exit&#xA;    result=$(git pull --force)&#xA;    echo &quot;$expected_repo: $result&quot;&#xA;  else&#xA;    echo &quot;$expected_repo: Installing...&quot;&#xA;    git clone -q &quot;$repo_url&quot;&#xA;  fi&#xA;}&#xA;(&#xA;set_group ruby&#xA;package https://github.com/tpope/vim-rails.git &amp;amp;&#xA;package https://github.com/tpope/vim-rake.git &amp;amp;&#xA;package https://github.com/tpope/vim-bundler.git &amp;amp;&#xA;package https://github.com/tpope/vim-endwise.git &amp;amp;&#xA;wait&#xA;) &amp;amp;&#xA;(&#xA;set_group syntax&#xA;package https://github.com/kchmck/vim-coffee-script.git &amp;amp;&#xA;package https://github.com/tpope/vim-markdown.git &amp;amp;&#xA;package https://github.com/ap/vim-css-color.git &amp;amp;&#xA;wait&#xA;) &amp;amp;&#xA;(&#xA;set_group colorschemes&#xA;package https://github.com/altercation/vim-colors-solarized.git &amp;amp;&#xA;wait&#xA;) &amp;amp;&#xA;wait&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2017-03-13T07:32:31.240" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11734" PostTypeId="2" ParentId="11732" CreationDate="2017-03-13T08:07:14.250" Score="1" Body="&lt;p&gt;This is not really possible, because as soon as your map finishes, you are left in insert mode so you see the 'showmode' message. There are a couple of alternatives however.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) Fancy statusline plugins like &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-airline&lt;/a&gt; usually also display the mode, so one does not necessarily need the option 'showmode' anymore: &lt;code&gt;:set noshowmode&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) Increase your 'cmdheight' setting to 2: &lt;code&gt;:set cmdheight=2&lt;/code&gt; so that both messages can be displayed simultaneously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note you can use the keyname instead of the keycode for your mapping. So in your example, you might want to use &lt;code&gt;imap &amp;lt;f12&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-o&amp;gt;:w&amp;lt;cr&amp;gt;&lt;/code&gt; (note instead of using &lt;kbd&gt;esc&lt;/kbd&gt; to return from insert mode, I used the &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;O&lt;/kbd&gt; to temporarily switch for one command to normal mode.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-03-13T08:07:14.250" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11735" PostTypeId="1" CreationDate="2017-03-13T08:33:35.520" Score="1" ViewCount="439" Body="&lt;p&gt;Here is my html file already edited,there are two errors in it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&#xA;&amp;lt;html lang=&quot;zh-Hans&quot;&amp;gt;&#xA;&amp;lt;head&amp;gt;&#xA;    &amp;lt;meta charset=&quot;utf-8&quot;&amp;gt;&#xA;    &amp;lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;   &quot; /&amp;gt;&#xA;&amp;lt;/head&amp;gt;&#xA;&amp;lt;body&amp;gt;&#xA;    &amp;lt;nav&amp;gt;6 navs&amp;lt;/nav&#xA;    &amp;lt;div&amp;gt;intro&amp;lt;/div&amp;gt;&#xA;    &amp;lt;div&amp;gt;edu&amp;lt;/div&amp;gt;&#xA;    &amp;lt;div&amp;gt;specialization&amp;lt;/div&amp;gt;&#xA;    &amp;lt;div&amp;gt;work/div&amp;gt;&#xA;    &amp;lt;div&amp;gt;production&amp;lt;/div&amp;gt;&#xA;    &amp;lt;nav&amp;gt;contact&amp;lt;/nav&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;1.not &lt;strong&gt;&lt;code&gt;&amp;lt;nav&amp;gt;6 navs&amp;lt;/nav&lt;/code&gt;&lt;/strong&gt; but &lt;strong&gt;&lt;code&gt;&amp;lt;nav&amp;gt;6 navs&amp;lt;/nav&amp;gt;&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&#xA;2.not &lt;strong&gt;&lt;code&gt;&amp;lt;div&amp;gt;work/div&amp;gt;&lt;/code&gt;&lt;/strong&gt;   but &lt;strong&gt;&lt;code&gt;&amp;lt;div&amp;gt;work&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to choose the two errors automatically with vim command or some plugins?&lt;br&gt;&#xA;How to fix it ,enclosed it automatically after locating the position?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastActivityDate="2020-02-27T03:23:50.583" Title="How to select unclosed tag and close it automatically?" Tags="|tags|filetype-html|" AnswerCount="0" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11738" PostTypeId="2" ParentId="7014" CreationDate="2017-03-13T17:30:43.030" Score="3" Body="&lt;p&gt;This updates the cursor when entering/exiting operator pending mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While it is a bit of a hacky solution I don't think it has any performance problems.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This is esentially:&#xA;&quot;   exec 'silent !printf &quot;\e[&quot; . a:t . ' q'&#xA;&quot;   redraw!&#xA;&quot; but without the screen flash&#xA;function! s:setCursor(t)&#xA;    &quot; Save existing values.&#xA;    let [l:title, l:t_ts, l:t_fs, l:titlestring] = [&amp;amp;title, &amp;amp;t_ts, &amp;amp;t_fs, &amp;amp;titlestring]&#xA;&#xA;    try&#xA;        let &amp;amp;titleold = ''&#xA;        let &amp;amp;t_ts = &quot;\e[0;0&quot;&#xA;        let &amp;amp;t_fs = &quot;\e[&quot; . a:t . ' q'&#xA;        set title&#xA;        set titlestring=H&#xA;        redraw!&#xA;    finally&#xA;        let [&amp;amp;title, &amp;amp;t_ts, &amp;amp;t_fs, &amp;amp;titlestring] = [l:title, l:t_ts, l:t_fs, l:titlestring]&#xA;    endtry&#xA;endfunction&#xA;&#xA;let s:prevmode = ''&#xA;function! DetectPendingMode(timer)&#xA;    let l:mode = mode(1)&#xA;    if l:mode is# s:prevmode&#xA;        return&#xA;    endif&#xA;&#xA;    if l:mode is# 'no'&#xA;        call &amp;lt;SID&amp;gt;setCursor(4)&#xA;    elseif s:prevmode is# 'no'&#xA;        call &amp;lt;SID&amp;gt;setCursor(2)&#xA;    endif&#xA;    let s:prevmode = l:mode&#xA;endfunction&#xA;&#xA;call timer_start(250, 'DetectPendingMode', {'repeat': -1})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may need to change the style of the cursor in &lt;code&gt;SetCursor()&lt;/code&gt; to the one you prefer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0: blinking block.&#xA;1: blinking block.&#xA;2: steady block.&#xA;3: blinking underline.&#xA;4: steady underline.&#xA;5: blinking bar (xterm).&#xA;6: steady bar (xterm).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="51" LastEditDate="2019-08-03T17:16:32.740" LastActivityDate="2019-08-03T17:16:32.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="11739" PostTypeId="2" ParentId="9916" CreationDate="2017-03-13T17:43:28.910" Score="2" Body="&lt;p&gt;Take a look at either&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/powerman/vim-plugin-viewdoc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plugin-viewdoc&lt;/a&gt; to view help inside vim (it supports a lot of sources and can be extended)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or &lt;a href=&quot;https://github.com/keith/investigate.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;investigate.vim&lt;/a&gt; which can be used to look up documentation in your browser.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For python there is also &lt;a href=&quot;https://github.com/fs111/pydoc.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;pydoc.vim&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-13T17:43:28.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11740" PostTypeId="2" ParentId="11556" CreationDate="2017-03-13T18:02:02.280" Score="3" Body="&lt;pre&gt;&lt;code&gt;'titleold'      string  (default &quot;Thanks for flying Vim&quot;)&#xA;                global&#xA;&#xA;    This option will be used for the window title when exiting Vim if the&#xA;    original title cannot be restored.  Only happens if 'title' is on or&#xA;    'titlestring' is not empty.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimLeave * set notitle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should fix it.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-13T18:02:02.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11741" PostTypeId="1" AcceptedAnswerId="11742" CreationDate="2017-03-13T19:32:24.597" Score="0" ViewCount="994" Body="&lt;p&gt;Is there some shortcut to force ycm to re-run semantic analysis on the code. Eg. I get some error, I correct it and I want to check, but ycm on my machine refreshes only after about 5 secs. One way is to &lt;code&gt;:w&amp;lt;Cr&amp;gt; :e&amp;lt;CR&amp;gt;&lt;/code&gt; but it saves the edits which I might not want. Is there some key binding to just refresh the semantic analysis result?&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2017-03-13T21:19:57.057" Title="Is there a way to force vim youcompleteme plugin to do semantic analysis again?" Tags="|plugin-you-complete-me|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11742" PostTypeId="2" ParentId="11741" CreationDate="2017-03-13T21:19:57.057" Score="0" Body="&lt;p&gt;Did you try &lt;code&gt;:YcmForceCompileAndDiagnostics&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Calling this command will force YCM to immediately recompile your file and display any new diagnostics it encounters. Do note that recompilation with this command may take a while and during this time the Vim GUI will be blocked.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :YcmForceCompileAndDiagnostics&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-13T21:19:57.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11745" PostTypeId="1" AcceptedAnswerId="12392" CreationDate="2017-03-14T03:51:12.327" Score="4" ViewCount="131" Body="&lt;p&gt;An example HTML, with the cursor where the brackets are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;foo&amp;gt;&#xA;  &amp;lt;bar&amp;gt;&#xA;          baz&#xA;          quux&#xA;          []&#xA;  &amp;lt;/bar&amp;gt;&#xA;&amp;lt;/foo&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to outdent the text inside &lt;code&gt;&amp;lt;bar/&amp;gt;&lt;/code&gt;. Naturally, I try &lt;kbd&gt;&amp;lt;&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;, but it turns out that &lt;code&gt;it&lt;/code&gt; is everything inside &lt;code&gt;&amp;lt;bar/&amp;gt;&lt;/code&gt; - including the newline after &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt;, and indent before &lt;code&gt;&amp;lt;/bar&amp;gt;&lt;/code&gt;. Thus, &lt;kbd&gt;&amp;lt;&lt;/kbd&gt; pulls the entire &lt;code&gt;&amp;lt;bar/&amp;gt;&lt;/code&gt; tag, not just the contents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, &lt;kbd&gt;&amp;lt;&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;{&lt;/kbd&gt; does the right thing in pretty much the same circumstance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (foo) {&#xA;    baz();&#xA;    quux();&#xA;    []&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone have an idea how I can select just the three lines between, without the &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;/bar&amp;gt;&lt;/code&gt; lines, just like I can do inside the braces? The best I can come up with is &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;&amp;lt;&lt;/kbd&gt;; am I missing something obvious?&lt;/p&gt;&#xA;" OwnerUserId="4729" LastActivityDate="2017-05-14T15:47:38.253" Title="Linewise inner tag without the tag lines?" Tags="|cursor-motions|filetype-html|filetype-xml|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11746" PostTypeId="1" AcceptedAnswerId="11880" CreationDate="2017-03-14T03:55:16.307" Score="-2" ViewCount="726" Body="&lt;p&gt;To input &lt;code&gt;w100p&lt;/code&gt; and &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;y&lt;/kbd&gt;+&lt;kbd&gt;,&lt;/kbd&gt;   or  &lt;code&gt;w100p&lt;/code&gt; and &lt;kbd&gt;tab&lt;/kbd&gt;,&lt;code&gt;w100p&lt;/code&gt; can't expand into &lt;code&gt;width: 100%&lt;/code&gt;.&lt;br&gt;&#xA;No &lt;code&gt;snippets.json&lt;/code&gt; file found  with command &lt;code&gt;find /  -name  'snippets.json'&lt;/code&gt;,is it the reason?&lt;br&gt;&#xA;snippets.json can download from url.&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/emmetio/emmet/blob/master/lib/snippets.json&quot; rel=&quot;nofollow noreferrer&quot;&gt;snippets.json&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where to put snippets.json in my vim installed directory?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tree  -L 1  /usr/share/vim/vim74&#xA;/usr/share/vim/vim74&#xA;├── autoload&#xA;├── bugreport.vim&#xA;├── bundle&#xA;├── colors&#xA;├── compiler&#xA;├── debian.vim&#xA;├── delmenu.vim&#xA;├── doc&#xA;├── evim.vim&#xA;├── filetype.vim&#xA;├── ftoff.vim&#xA;├── ftplugin&#xA;├── ftplugin.vim&#xA;├── ftplugof.vim&#xA;├── gvimrc_example.vim&#xA;├── indent&#xA;├── indent.vim&#xA;├── indoff.vim&#xA;├── keymap&#xA;├── lang&#xA;├── macros&#xA;├── menu.vim&#xA;├── mswin.vim&#xA;├── optwin.vim&#xA;├── plugin&#xA;├── print&#xA;├── rgb.txt&#xA;├── scripts.vim&#xA;├── spell&#xA;├── synmenu.vim&#xA;├── syntax&#xA;├── tutor&#xA;└── vimrc_example.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the mannual ,&#xA;Create snippets.json file in extensions folder to add or override snippets.&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="5181" LastEditDate="2017-03-24T02:34:12.620" LastActivityDate="2022-02-17T16:10:58.710" Title="Why emmet.vim don't expand CSS abbreviation?" Tags="|plugin-emmet-vim|filetype-scss|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11747" PostTypeId="1" CreationDate="2017-03-14T11:30:54.863" Score="6" ViewCount="365" Body="&lt;p&gt;Often enough a text file is structured as a collection of blocks or cells of some kind. E.g., slides in a Tex Beamer presentation, bibtex items, function definitions, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if vim can facilitate highlighting of the current &quot;cell&quot; only, letting thereby the part I'm currently working on to stand out from the rest?&lt;/p&gt;&#xA;" OwnerUserId="11774" LastActivityDate="2023-12-09T09:02:55.307" Title="Interactive syntax-highligting: highlight the current region only" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11748" PostTypeId="2" ParentId="11747" CreationDate="2017-03-14T13:08:40.863" Score="0" Body="&lt;p&gt;I guess you need to &lt;a href=&quot;https://github.com/sindresorhus/focus&quot; rel=&quot;nofollow noreferrer&quot;&gt;focus&lt;/a&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/B2OFu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/B2OFu.png&quot; alt=&quot;sample&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-14T13:08:40.863" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11749" PostTypeId="2" ParentId="11745" CreationDate="2017-03-14T13:11:46.597" Score="2" Body="&lt;p&gt;You are right, vim treats tags differently. &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3037&quot; rel=&quot;nofollow noreferrer&quot;&gt;The plugin vim-indent-object&lt;/a&gt; will help you, you can do &lt;code&gt;&amp;lt;ii&lt;/code&gt; with it to chance the indent of all lines inside the same indent block.&lt;/p&gt;&#xA;" OwnerUserId="11771" LastEditorUserId="11771" LastEditDate="2017-03-14T13:57:13.320" LastActivityDate="2017-03-14T13:57:13.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11750" PostTypeId="1" AcceptedAnswerId="11751" CreationDate="2017-03-14T16:43:43.813" Score="3" ViewCount="3365" Body="&lt;p&gt;Vim always has 3 spaces for the line numbers on the left, in the gutter.  Since I &lt;code&gt;set relativenumber&lt;/code&gt;, and (unfortunately) don't have a monitor with the vertical space for 100 lines, I will never need more than 2 places for the line number.  The leftmost column is always an extra space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I reclaim that valuable screen real estate?&lt;/p&gt;&#xA;" OwnerUserId="11780" LastActivityDate="2017-03-14T16:50:39.547" Title="Get rid of extra gutter spacing" Tags="|line-numbers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11751" PostTypeId="2" ParentId="11750" CreationDate="2017-03-14T16:50:22.403" Score="5" Body="&lt;p&gt;Vim automatically sets the gutter spacing, but it has some constraints.  Notably, &lt;code&gt;numberwidth&lt;/code&gt; determines the minimum number of columns reserved for the gutter.  The default is 4, 3 for the numbers and 1 for the space separating the numbers from the text.  That's one too many in this case, so &lt;code&gt;set numberwidth=3&lt;/code&gt; in your vimrc, and you should be good to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, if you want 80 columns of text in your gvim windows, &lt;code&gt;set columns=83&lt;/code&gt; will give you 2 line numbers, 1 space, and 80 columns.&lt;/p&gt;&#xA;" OwnerUserId="11780" LastActivityDate="2017-03-14T16:50:22.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11753" PostTypeId="1" CreationDate="2017-03-14T19:13:32.850" Score="1" ViewCount="461" Body="&lt;p&gt;I started using &lt;a href=&quot;https://github.com/JoshCheek/seeing_is_believing&quot; rel=&quot;nofollow noreferrer&quot;&gt;Seeing is Believing&lt;/a&gt;&#xA; and updated my &lt;a href=&quot;https://github.com/ogirginc/dotfiles/blob/master/vimrc#L297-L298&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimrc&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;s A # =&amp;gt; &amp;lt;Esc&amp;gt;:%.!seeing_is_believing --timeout 12 --line-length 500 --number-of-captures 300 --alignment-strategy chunk --xmpfilter-style&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, after I run the command, my cursor moves to the top of the file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to keep my cursor in the original line &amp;amp; column that I ran the command?&lt;/p&gt;&#xA;" OwnerUserId="7621" LastEditorUserId="6590" LastEditDate="2017-03-15T18:25:34.617" LastActivityDate="2017-05-15T08:42:58.733" Title="Prevent the cursor from moving to the top of the file" Tags="|key-bindings|cursor-movement|cursor-motions|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11754" PostTypeId="1" AcceptedAnswerId="11761" CreationDate="2017-03-14T20:52:50.263" Score="2" ViewCount="445" Body="&lt;p&gt;When using the &lt;code&gt;:oldfiles&lt;/code&gt; command, I can easily exit the list with &lt;code&gt;q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use the &lt;code&gt;:registers&lt;/code&gt; command, it says &quot;Press ENTER or type command to continue&quot;. But I would like to exit the list with &lt;code&gt;q&lt;/code&gt;, without entering into macro recording which is annoying. I don't like pressing &lt;code&gt;enter&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a native Vim way to exit the register list with &lt;code&gt;q&lt;/code&gt;, just like the &lt;code&gt;:oldfiles&lt;/code&gt; &quot;pager&quot; does? It would be nice to have a bit of consistency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To display registers, I actually do &lt;code&gt;:reg &quot;0123456789&lt;/code&gt;, which is a short output, so that's why Vim's &quot;more-prompt pager&quot; is not used (cf. &lt;code&gt;:h more-prompt&lt;/code&gt;). I have a lot of &lt;code&gt;:oldfiles&lt;/code&gt;, so that's why Vim's &quot;more-prompt pager&quot; is used in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to always hit &lt;code&gt;q&lt;/code&gt; regardless of whether the output is short. Maybe there is a way to always force the &quot;more-prompt pager&quot;? Or to customize mappings for output windows? Worst case scenario I could pipe the output in a scratch buffer that has a custom &lt;code&gt;q&lt;/code&gt; mapping, if there is no simpler solution.&lt;/p&gt;&#xA;" OwnerUserId="7318" LastEditorUserId="7318" LastEditDate="2017-03-16T03:39:58.210" LastActivityDate="2017-03-17T18:29:42.790" Title="How to exit the registers list with q?" Tags="|register|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11755" PostTypeId="2" ParentId="11754" CreationDate="2017-03-14T21:20:42.723" Score="3" Body="&lt;p&gt;The difference is whether the whole list fits in the screen or not. If your screen is tall enough, the output of &lt;code&gt;:registers&lt;/code&gt; will fit in the screen, and you will see the message “Press ENTER or type command to continue”. If the output of &lt;code&gt;:oldfiles&lt;/code&gt; is long enough, you will need to scroll and will instead see the message “-- More --”.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you scroll to the end of the &lt;code&gt;:oldfiles&lt;/code&gt; output, you will see the same behavior as with &lt;code&gt;:registers&lt;/code&gt;, so Vim is being consistent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the output of &lt;code&gt;:registers&lt;/code&gt; (or any time “Press ENTER or type command to continue” is shown), pressing &lt;kbd&gt;b&lt;/kbd&gt;, &lt;kbd&gt;u&lt;/kbd&gt;, &lt;kbd&gt;k&lt;/kbd&gt;, or &lt;kbd&gt;↑&lt;/kbd&gt; will change the message to “-- More --” and you will be able to use &lt;kbd&gt;q&lt;/kbd&gt; to quit the list. It’s probably not the answer you’re looking for, but it does help to explain to explain the behavior.&lt;/p&gt;&#xA;" OwnerUserId="2680" LastActivityDate="2017-03-14T21:20:42.723" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11756" PostTypeId="2" ParentId="11754" CreationDate="2017-03-14T21:38:32.770" Score="2" Body="&lt;p&gt;I can press &lt;code&gt;q&lt;/code&gt; at &lt;code&gt;Press ENTER or type command to continue&lt;/code&gt; to quit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that does not work for you, look at &lt;code&gt;:help press-return&lt;/code&gt; - you can also use &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; to continue.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   Press ENTER or type command to continue&#xA;&#xA;This message is given when there is something on the screen for you to read,&#xA;and the screen is about to be redrawn:&#xA;[..]&#xA;&#xA;-&amp;gt; Press &amp;lt;Enter&amp;gt; or &amp;lt;Space&amp;gt; to redraw the screen and continue, without that&#xA;   key being used otherwise.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="10337" LastEditDate="2017-03-14T21:52:46.050" LastActivityDate="2017-03-14T21:52:46.050" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11759" PostTypeId="2" ParentId="11753" CreationDate="2017-03-15T09:45:33.747" Score="1" Body="&lt;p&gt;In theory:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could end your map with &lt;code&gt;''&lt;/code&gt; to jump back to the first non blank column on the line where you were: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;s A # =&amp;gt; &amp;lt;Esc&amp;gt;:%.!seeing_is_believing --timeout 12 --line-length 500 --number-of-captures 300 --alignment-strategy chunk --xmpfilter-style&amp;lt;CR&amp;gt;''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could use &lt;code&gt;``&lt;/code&gt; to jump back to the exact column on the line where you were:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;s A # =&amp;gt; &amp;lt;Esc&amp;gt;:%.!seeing_is_believing --timeout 12 --line-length 500 --number-of-captures 300 --alignment-strategy chunk --xmpfilter-style&amp;lt;CR&amp;gt;``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could just hit &lt;code&gt;&amp;lt;CTRL-o&lt;/code&gt;&gt; (&lt;code&gt;:h CTRL-o&lt;/code&gt;) to go to older cursor position on the jump list.&lt;/p&gt;&#xA;" OwnerUserId="10493" LastActivityDate="2017-03-15T09:45:33.747" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11760" PostTypeId="2" ParentId="11704" CreationDate="2017-03-15T19:57:11.867" Score="-2" Body="&lt;p&gt;Try using == to auto-indent one line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use =G when you're at the top of page, to auto-indent the whole file&lt;/p&gt;&#xA;" OwnerUserId="7377" LastActivityDate="2017-03-15T19:57:11.867" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11761" PostTypeId="2" ParentId="11754" CreationDate="2017-03-16T03:36:36.473" Score="1" Body="&lt;p&gt;I gave in to the dark side and used some hacky Vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; '' :call DisplayRegisters()&amp;lt;cr&amp;gt;&#xA;&#xA;function! DisplayRegisters()&#xA;  redir =&amp;gt; output&#xA;  silent exe 'reg &quot;0123456789'&#xA;  redir END&#xA;  new&#xA;  silent file [Registers]&#xA;  setlocal nonumber norelativenumber&#xA;  setlocal buftype=nofile bufhidden=wipe noswapfile nobuflisted nomodified&#xA;  silent put =output&#xA;  silent normal gg&quot;_d2j&#xA;  exe 'resize ' . line('$')&#xA;  map &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; q :q&amp;lt;cr&amp;gt;&#xA;  map &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;esc&amp;gt; q&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows me to see a short list of registers by typing &lt;code&gt;''&lt;/code&gt;, and close it by typing &lt;code&gt;q&lt;/code&gt;, just like I wanted.&lt;/p&gt;&#xA;" OwnerUserId="7318" LastEditorUserId="7318" LastEditDate="2017-03-17T18:29:42.790" LastActivityDate="2017-03-17T18:29:42.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11763" PostTypeId="1" AcceptedAnswerId="11764" CreationDate="2017-03-16T13:27:18.617" Score="3" ViewCount="442" Body="&lt;p&gt;It's sort-of a follow to a &lt;a href=&quot;https://xkcd.com/1806/&quot; rel=&quot;nofollow noreferrer&quot;&gt;recent XKCD&lt;/a&gt;. I want to know whether it's possible to map the scroll wheel to undo and redo, possibly &lt;em&gt;n&lt;/em&gt; undos/redos per scroll?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;mate-terminal&lt;/code&gt; in MATE 1.6.x, &lt;code&gt;bash&lt;/code&gt;, &lt;code&gt;vimx&lt;/code&gt; 7.4, full info:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ vimx --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 13 2014 08:56:33)&#xA;Included patches: 1-207, 209-475&#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;+balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;+browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;+clientserver    -hangul_input    +netbeans_intg   +title&#xA;+clipboard       +iconv           +path_extra      +toolbar&#xA;+cmdline_compl   +insert_expand   +perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python/dyn      +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con_gui  +lua/dyn         +rightleft       +windows&#xA;+diff            +menu            +ruby/dyn        +writebackup&#xA;+digraphs        +mksession       +scrollbind      +X11&#xA;+dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     +xim&#xA;+emacs_tags      +mouseshape      -sniff           +xsmp_interact&#xA;+eval            +mouse_dec       +startuptime     +xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    +xpm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="82" LastEditorUserId="51" LastEditDate="2017-04-04T13:46:20.940" LastActivityDate="2017-04-04T13:46:20.940" Title="Console vim(x): Can I map the scroll wheel to undo--redo?" Tags="|scrolling|undo-redo|mouse|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11764" PostTypeId="2" ParentId="11763" CreationDate="2017-03-16T13:44:00.400" Score="7" Body="&lt;p&gt;it works for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=a&#xA;map &amp;lt;ScrollWheelUp&amp;gt; u&#xA;map &amp;lt;ScrollWheelDown&amp;gt; &amp;lt;C-R&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But i hope this is just for fun. Must be horrible =)&lt;/p&gt;&#xA;" OwnerUserId="11316" LastActivityDate="2017-03-16T13:44:00.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11765" PostTypeId="1" CreationDate="2017-03-16T16:55:54.797" Score="4" ViewCount="3254" Body="&lt;p&gt;Here's a snippet that I'm working with (* denotes cursor location)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*&quot;First random string&quot;   ,&quot;Random string I want to remove&quot;           }&#xA;&quot;Random string number 2&quot; , &quot;Another random string I want to keep&quot;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*&quot;First random string&quot;   ,                                           }&#xA;&quot;Random string number 2&quot; , &quot;Another random string I want to keep&quot;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The brackets are aligned neatly with each other with spaces, and I want to remove the last argument from the first array (while maintaining the easy readability of the current bracket, and comma placement.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easy answer (the one I'm forced to do for now) would be to count the number of characters in the string and do&#xA;&lt;code&gt;&amp;lt;count&amp;gt;r&amp;lt;space&amp;gt;&lt;/code&gt; but that easily gets tedious with strings of the length I'm working with.&#xA;I'm sure there's a better way to directly replace the text. I'm sure that vim has a visual replace feature but &lt;code&gt;&amp;lt;select text&amp;gt;r&amp;lt;space&amp;gt;&lt;/code&gt; doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="11804" LastActivityDate="2017-09-15T17:44:17.350" Title="Replace text in visual mode in vim/vi" Tags="|visual-mode|replace|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11766" PostTypeId="1" AcceptedAnswerId="11767" CreationDate="2017-03-16T18:51:12.840" Score="2" ViewCount="204" Body="&lt;p&gt;In &lt;a href=&quot;http://vim.wikia.com/wiki/Remove_unwanted_spaces&quot; rel=&quot;nofollow noreferrer&quot;&gt;remove unwanted spaces page&lt;/a&gt; in vim wikia, it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;However, this is a very dangerous autocmd to have as it will always strip trailing whitespace from every file a user saves. Sometimes, trailing whitespace is desired, or even essential in a file so be careful when implementing this autocmd&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Why is it so? Is there a situation where it's necessary to have trailing spaces in the end of a line?&lt;/p&gt;&#xA;" OwnerUserId="11807" LastActivityDate="2017-03-16T19:03:43.523" Title="Dangerous trailing space" Tags="|whitespace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11767" PostTypeId="2" ParentId="11766" CreationDate="2017-03-16T19:03:43.523" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a situation where it's necessary to have trailing spaces in the end of a line?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The two most common that I encounter are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;In the original Markdown you need to use two spaces at the end of line to signal a hard newline (in &quot;GitHub flavoured Markdown&quot; this does nothing, though, since this always adds a newline).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For emails the marker for the start of a signature is &lt;code&gt;--&amp;lt;Space&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There may be other situations as well.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-03-16T19:03:43.523" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11768" PostTypeId="1" CreationDate="2017-03-16T20:01:33.963" Score="7" ViewCount="4924" Body="&lt;p&gt;When installing Vim for Windows 10 64-bit, it also installed an &quot;Edit with Vim&quot; context menu option. Annoyingly, this opens the file in gVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I change the &quot;Edit with Vim&quot; context menu option to open vim.exe instead of gVim.exe?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked in the registry and couldn't find it.&lt;/p&gt;&#xA;" OwnerUserId="11809" LastEditorUserId="475" LastEditDate="2017-03-18T00:50:10.130" LastActivityDate="2017-05-23T13:08:06.653" Title="How do I make &quot;Edit with Vim&quot; open Vim instead of gVim on windows?" Tags="|gvim|microsoft-windows|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="11769" PostTypeId="2" ParentId="11765" CreationDate="2017-03-16T22:12:20.780" Score="0" Body="&lt;p&gt;How about using a plugin, like &lt;strong&gt;Align&lt;/strong&gt; or &lt;strong&gt;Tabular&lt;/strong&gt;? Take a look at the suggestion given &lt;a href=&quot;https://stackoverflow.com/a/6154661/5095879&quot;&gt;here&lt;/a&gt;. There a demo shown at &lt;a href=&quot;http://vimcasts.org/episodes/aligning-text-with-tabular-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt; which is great for Tabular.&lt;/p&gt;&#xA;" OwnerUserId="9893" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-03-16T22:12:20.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11770" PostTypeId="1" AcceptedAnswerId="11771" CreationDate="2017-03-16T22:21:00.700" Score="1" ViewCount="140" Body="&lt;p&gt;From the &lt;a href=&quot;https://benmccormick.org/2014/07/02/learning-vim-in-2014-vim-as-language/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-as-language&lt;/a&gt; article:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim’s &quot;verbs&quot; mostly fall into 2 main categories. Some of them act on a single character, and others act on a &quot;motion&quot; or &quot;text object&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And from the vim wiki for &lt;a href=&quot;http://vim.wikia.com/wiki/Switching_case_of_characters&quot; rel=&quot;nofollow noreferrer&quot;&gt;switching the case of characters&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Toggle case &lt;code&gt;&quot;HellO&quot;&lt;/code&gt; to &lt;code&gt;&quot;hELLo&quot;&lt;/code&gt; with &lt;code&gt;g~&lt;/code&gt; then a movement.&lt;br&gt;&#xA;  Uppercase &lt;code&gt;&quot;HellO&quot;&lt;/code&gt; to &lt;code&gt;&quot;HELLO&quot;&lt;/code&gt; with &lt;code&gt;gU&lt;/code&gt; then a movement.&lt;br&gt;&#xA;  Lowercase &lt;code&gt;&quot;HellO&quot;&lt;/code&gt; to &lt;code&gt;&quot;hello&quot;&lt;/code&gt; with &lt;code&gt;gu&lt;/code&gt; then a movement.  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In this case, it seems like &lt;code&gt;Lowercase&lt;/code&gt; is the &lt;strong&gt;action&lt;/strong&gt;. Would &quot;the current line&quot; be considered a movement or text object?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example given the line (with my cursor at the &lt;code&gt;|&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pgp - Pretty Good Privac|y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm wondering use the action-movement pattern to &quot;downcase the current line&quot; works in this case. I used &lt;code&gt;gu0&lt;/code&gt; which worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what if the cursor is in the middle of the line like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pgp - Pretty Go|od Privacy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, &lt;code&gt;gu0&lt;/code&gt; followed by &lt;code&gt;gu$&lt;/code&gt; will work, but it seems &quot;the current line&quot; should be a text-object. I also used &lt;code&gt;guk&lt;/code&gt; or &lt;code&gt;guk&lt;/code&gt; which works but I'm not sure if I'm thinking about the pattern the right way.&lt;/p&gt;&#xA;" OwnerUserId="11605" LastActivityDate="2017-03-16T22:32:22.807" Title="How do I apply the Lowercase action to a line movement?" Tags="|cursor-motions|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11771" PostTypeId="2" ParentId="11770" CreationDate="2017-03-16T22:32:22.807" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;gugu&lt;/code&gt; or &lt;code&gt;guu&lt;/code&gt; for making current line lowercase. There's no a text object for current line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;guip&lt;/code&gt; or &lt;code&gt;guis&lt;/code&gt; which stand for paragraph and for sentence text objects&lt;/p&gt;&#xA;" OwnerUserId="11690" LastActivityDate="2017-03-16T22:32:22.807" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11772" PostTypeId="1" AcceptedAnswerId="11777" CreationDate="2017-03-16T23:29:15.847" Score="2" ViewCount="589" Body="&lt;p&gt;Plugins such as &lt;a href=&quot;https://github.com/garbas/vim-snipmate&quot; rel=&quot;nofollow noreferrer&quot;&gt;snipMate&lt;/a&gt;,  &lt;a href=&quot;https://github.com/mattn/emmet-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;emmet&lt;/a&gt; and many others allow me to quickly insert opening and closing html tags. For example by typing &lt;code&gt;span&lt;/code&gt; and hitting the correct key (TAB for snipMate, &lt;code&gt;&amp;lt;C-y&amp;gt;,&lt;/code&gt; for emmet) I can magically get &lt;code&gt;&amp;lt;span&amp;gt;_&amp;lt;/span&amp;gt;&lt;/code&gt; with my cursor positioned where I have placed the underscore. Now I type some content that should go inside the span. That leads to my question. How to efficiently leave the span and continue entering text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a block-level tag the best I have found is &lt;code&gt;&amp;lt;Esc&amp;gt;o&lt;/code&gt; because I almost always want to start on a new line with the next block-level tag. But for a &lt;code&gt;span&lt;/code&gt; or other inline tag, I'd like to skip the closing tag and continue typing. For example I might type &lt;code&gt;span&amp;lt;C-y&amp;gt;,&lt;/code&gt; and get &lt;code&gt;&amp;lt;span&amp;gt;_&amp;lt;/span&amp;gt;&lt;/code&gt; followed by some text leaving me with &lt;code&gt;&amp;lt;span&amp;gt;some text_&amp;lt;/span&amp;gt;&lt;/code&gt; where the cursor is shown by the underscore again. I'm in input mode. How to efficiently get to after the &lt;code&gt;&amp;lt;/span&amp;gt;&lt;/code&gt; and still be in input mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could use &lt;code&gt;&amp;lt;Esc&amp;gt;vat&amp;lt;Esc&amp;gt;a&lt;/code&gt; which seems like a ton of keys for a simple action though it does allow climbing the hierarchy in a nice way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could &lt;code&gt;&amp;lt;Esc&amp;gt;f&amp;gt;a&lt;/code&gt; which still seems heavy for something I use many times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some more efficient way that I am missing? &lt;/p&gt;&#xA;" OwnerUserId="6123" LastEditorUserId="6123" LastEditDate="2017-03-17T10:42:26.880" LastActivityDate="2017-03-17T20:52:32.190" Title="Skip over closing html tag?" Tags="|insert-mode|filetype-html|snippets|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11773" PostTypeId="1" AcceptedAnswerId="11774" CreationDate="2017-03-17T00:50:55.810" Score="3" ViewCount="200" Body="&lt;p&gt;I am using an interactive substitution that spans multiple lines. In order to determine whether each particular occurrence should be replaced, I need to see all lines that are included in the search criteria, but vim only displays the first line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know you can scroll the window with &lt;code&gt;zz&lt;/code&gt;, &lt;code&gt;zt&lt;/code&gt; and &lt;code&gt;zb&lt;/code&gt;, but this doesn't appear to work in interactive substitute mode. Is there an alternative approach?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example command, which replaces three newlines with two:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,$s/\n\n\n/^M^M/gce&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10101" LastActivityDate="2017-03-17T03:27:38.453" Title="Can you scroll the window in interactive substitute mode?" Tags="|substitute|scrolling|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11774" PostTypeId="2" ParentId="11773" CreationDate="2017-03-17T03:27:38.453" Score="4" Body="&lt;p&gt;To answer my own question (and if I read &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:s_flags&quot; rel=&quot;nofollow noreferrer&quot;&gt;the documentation on the [c] flag&lt;/a&gt; properly), I would have known that using &lt;code&gt;CTRL-E&lt;/code&gt; and &lt;code&gt;CTRL-Y&lt;/code&gt; scroll the screen up and down, respectively.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[c] Confirm each substitution.  Vim highlights the matching string with...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;CTRL-E  to scroll the screen up {not in Vi, not available when compiled without the |+insert_expand| feature}&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;CTRL-Y  to scroll the screen down {not in Vi, not available when compiled without the |+insert_expand| feature}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10101" LastActivityDate="2017-03-17T03:27:38.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11775" PostTypeId="1" AcceptedAnswerId="11783" CreationDate="2017-03-17T04:11:18.440" Score="0" ViewCount="417" Body="&lt;p&gt;Say I want to turn this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find(vec_a.begin(), vec_a.end(), c)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find(vec_b-&amp;gt;begin(), vec_b-&amp;gt;end(), c)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's what I just wanted to do, so I tried this (commands separated by commas):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/vec_a, e, rb, a, right, backspace, -&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it did what I wanted it to do which is replace vec_a. with vec_b-&gt;. Only problem is when i did &lt;code&gt;n ciw .&lt;/code&gt; the . only puts -&gt; and not vec_b-&gt;. How should I accomplish replacing individual instances of vec_a. with vec_b-&gt;?&lt;/p&gt;&#xA;" OwnerUserId="11809" LastActivityDate="2017-03-17T18:46:36.900" Title=". (dot) command and backspace" Tags="|replace|repeated-commands|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11776" PostTypeId="1" CreationDate="2017-03-17T05:17:16.963" Score="2" ViewCount="363" Body="&lt;p&gt;The documentation for &lt;code&gt;:put&lt;/code&gt; says that the command accepts a line. That is, it puts the content after the line specified. Is it possible to put the content at a particular mark?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, say I am in the middle of refactoring an anonymous JavaScript function into a named JavaScript function. I have the following in-process code (mid-refactoring), and I want to move the anonymous function to before the semi-colon on line 2.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function createClickListener(element) {&#xA;    return ;&#xA;}&#xA;&#xA;var listener = createClickListener(element);&#xA;element.addEventListener('click', function() {&#xA;    alert(&quot;You clicked the element!&quot;);&#xA;}, false);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In normal mode, I can place my cursor at the beginning of &lt;code&gt;f&lt;/code&gt; in the anonymous function, type &lt;code&gt;&quot;fc/}/e&lt;/code&gt; (followed by the &lt;code&gt;&amp;lt;enter&amp;gt;&lt;/code&gt; key) to cut the anonymous function into the named register &lt;code&gt;f&lt;/code&gt; and enter insert mode, and then type &lt;code&gt;listener&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in order to put the code on line 2, I have to move the cursor to the semi-colon then type &lt;code&gt;&quot;fp&lt;/code&gt;. If I were to do this with the &lt;code&gt;:put&lt;/code&gt; command (e.g., &lt;code&gt;:2put f&lt;/code&gt;) the anonymous function would be placed after line 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use the &lt;code&gt;:put&lt;/code&gt; command to put content mid-line or at a mark? Or is there an alternative (or better) way of doing this (I guess I could jump using marks more...)?&lt;/p&gt;&#xA;" OwnerUserId="10101" LastActivityDate="2019-12-03T02:20:35.780" Title="Is it possible to use the :put Ex command using column numbers?" Tags="|ex-mode|mark|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11777" PostTypeId="2" ParentId="11772" CreationDate="2017-03-17T05:30:48.980" Score="1" Body="&lt;p&gt;This answer was actually provided by the author himself. In his own words:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It seems like a common enough problem that someone should have addressed it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But apparently, not yet. It is necessary to map a solution, and here are a some of the possibilities:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-f&amp;gt; &amp;lt;esc&amp;gt;f&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;inoremap&lt;/code&gt; - create a map that works in insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; - bind the map to the keys CTRL+f&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; - leave insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f&amp;gt;&lt;/code&gt;    - look for the next occurrence of &lt;code&gt;&amp;gt;&lt;/code&gt; and move the cursor there&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&lt;/code&gt;     - append text after the cursor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note: this map overwrites the original function of  in insert mode. Take a look at &lt;code&gt;:h i_CTRL-f&lt;/code&gt; just to be sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap jk &amp;lt;Esc&amp;gt;vat&amp;lt;Esc&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;inoremap&lt;/code&gt; - create a map that works in insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;    - leave insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vat&lt;/code&gt;      - visually select around the &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;    - leave visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&lt;/code&gt;        - append text after the cursor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And yet another way could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;leader&amp;gt;zx &amp;lt;esc&amp;gt;%a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;inoremap&lt;/code&gt; - create a map that works in insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;leader&amp;gt;zx&lt;/code&gt; - bind the map to the keys +zx&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;    - leave insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt;        - Find the next item in this line after or under the cursor and jump to its match.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&lt;/code&gt;        - append text after the cursor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Original (and incorrect) answer&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use &lt;code&gt;&amp;lt;esc&amp;gt;A&lt;/code&gt; (uppercase &quot;A&quot;), it will leave you in insert mode at the end of the line. Check &lt;code&gt;:help A&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are dealing with HTML, it might be helpful to be aware of &lt;code&gt;%&lt;/code&gt; which will (according to &lt;code&gt;:help %&lt;/code&gt;): &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Find the next item in this line after or under the&#xA;  cursor and jump to its match. |inclusive| motion.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Or basically jump to the opposite (closing or opening) tag.&lt;/p&gt;&#xA;" OwnerUserId="10493" LastEditorUserId="6123" LastEditDate="2017-03-17T20:52:32.190" LastActivityDate="2017-03-17T20:52:32.190" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="11779" PostTypeId="2" ParentId="11776" CreationDate="2017-03-17T10:33:44.290" Score="1" Body="&lt;p&gt;No, it's not.&#xA;You'll have to use other means:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;go to the right position and use &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;P&lt;/code&gt; normal mode commands thanks to &lt;code&gt;:normal&lt;/code&gt; -&gt; &lt;code&gt;:normal! P&lt;/code&gt; for instance. You may need first to put your variable into a register.&lt;/li&gt;&#xA;&lt;li&gt;you could insert the new thing at cursor position also thanks to &lt;code&gt;:exe &quot;normal! i&quot;.the_string&lt;/code&gt;. But you may have to fight against automatic indentation.&lt;/li&gt;&#xA;&lt;li&gt;obtain the line with &lt;code&gt;getline(line_nr)&lt;/code&gt; do your computations and write it back with &lt;code&gt;:call setline(line_nr, new_line)&lt;/code&gt;. But that'll be extremely tricky to use if you want to move several lines, and if you have multi-bytes characters.&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;:substitute&lt;/code&gt; along with column specifications -&gt; &lt;code&gt;:2s/\%42c./\=a_string_variable.submatch(0)/&lt;/code&gt;. See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5c%25c&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\%c&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3as%5c%3d&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :s\=&lt;/code&gt;&lt;/a&gt;. I suspect, you'll have to reindent what have been modified afterwards as well.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-03-17T10:33:44.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11781" PostTypeId="1" CreationDate="2017-03-17T17:06:59.600" Score="24" ViewCount="7288" Body="&lt;p&gt;I'm using &lt;code&gt;gvim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ gvim --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 16 2017 06:36:51)&#xA;MacOS X (unix) version&#xA;Included patches: 1-329&#xA;Compiled by Homebrew&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was editing the following line of text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enable mouse scrolling, pane selection, pan reiszing and so on.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I noticed &quot;reiszing&quot; was misspelled so I used the following command to turn on spellcheck:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal spell spelllang=en_us&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;reiszing&quot; was highlighted as expected but then I accidently used the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/spell.html#zg&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;zg&lt;/code&gt;&lt;/a&gt; command which added the word to my dictionary. I grepped through &lt;code&gt;/usr/share/dict/words&lt;/code&gt; but didn't find &quot;reiszing&quot;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How do I remove this word from my dictionary?&lt;/li&gt;&#xA;&lt;li&gt;If the word isn't stored in &lt;code&gt;/usr/share/dict/words&lt;/code&gt;, then where is it?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I read in &lt;a href=&quot;https://stackoverflow.com/a/9239277/2909897&quot;&gt;another answer&lt;/a&gt; that the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can be used to find the paths that &lt;code&gt;vim&lt;/code&gt; uses:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim&#xA;/usr/local/Cellar/macvim/8.0-127/MacVim.app/Contents/Resources/vim/vimfiles&#xA;/usr/local/Cellar/macvim/8.0-127/MacVim.app/Contents/Resources/vim/runtime&#xA;/usr/local/Cellar/macvim/8.0-127&#xA;/MacVim.app/Contents/Resources/vim/vimfiles/after&#xA;~/.vim/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was able to fix my problem by blowing away the files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ rm /usr/local/Cellar/macvim/8.0-127/MacVim.app/Contents/Resources/vim/runtime/spell/en.utf-8.add&#xA;$ rm /usr/local/Cellar/macvim/8.0-127/MacVim.app/Contents/Resources/vim/runtime/spell/en.utf-8.add.spl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This worked fine for me now becuase it was the first time this happened but I'm curious if there is a simpler and less destructive way to remove a word from the dictionary after adding it with the &lt;code&gt;zg&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried &lt;code&gt;cmd + f&lt;/code&gt;ing the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/spell.html&quot; rel=&quot;noreferrer&quot;&gt;spell man page&lt;/a&gt; for &quot;remove word&quot; but found nothing.&lt;/p&gt;&#xA;" OwnerUserId="11605" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-04-04T13:43:23.877" Title="Remove word from dictionary" Tags="|spell-checking|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11782" PostTypeId="2" ParentId="11781" CreationDate="2017-03-17T17:13:34.660" Score="32" Body="&lt;p&gt;To remove a word, try &lt;code&gt;zuw&lt;/code&gt; and/or &lt;code&gt;zug&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I've tried cmd + fing the spell man page for &quot;remove word&quot; but found nothing.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For a &lt;code&gt;cmd+f&lt;/code&gt; search, I have had more success searching only on &quot;remove&quot; :-) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you turn on spelling with &lt;code&gt;setlocal spell spelllang=en_us&lt;/code&gt; then your long term dictionary is in your home directory.  Mine is at: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ~/.vim/spell/en.utf-8.add &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is where &lt;code&gt;zg&lt;/code&gt; adds words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While you can edit &lt;code&gt;~/.vim/spell/en.utf-8.add&lt;/code&gt; in vim under a different tab to remove erroneous entries, the &lt;code&gt;zug&lt;/code&gt; command is probably easier.  :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;zG&lt;/code&gt; command adds to a temporary file, under &lt;code&gt;/tmp&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;help spellfile&lt;/code&gt; (&lt;code&gt;help spf&lt;/code&gt;) can provide more details about the file's location and format.&lt;/p&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="6590" LastEditDate="2017-03-17T18:17:30.057" LastActivityDate="2017-03-17T18:17:30.057" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11783" PostTypeId="2" ParentId="11775" CreationDate="2017-03-17T18:46:36.900" Score="0" Body="&lt;p&gt;Search for the string you want to replace (&lt;code&gt;/vec_a\.&lt;/code&gt;), then use &lt;code&gt;cgn&lt;/code&gt; to replace the string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then replace other instances of &lt;code&gt;vec_a.&lt;/code&gt; by typing &lt;code&gt;.&lt;/code&gt; (or &lt;code&gt;n&lt;/code&gt; to skip).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you prefer, &lt;a href=&quot;https://github.com/bronson/vim-visual-star-search&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-visual-star-search&lt;/a&gt; let's you select &lt;code&gt;vec_a.&lt;/code&gt; visually.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-17T18:46:36.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11784" PostTypeId="1" CreationDate="2017-03-18T00:35:17.397" Score="1" ViewCount="828" Body="&lt;p&gt;I have a scenario where I have a local &lt;code&gt;.eslintrc&lt;/code&gt; and the local &lt;code&gt;eslint&lt;/code&gt; package installed. However, I notice that it does not populate a &lt;code&gt;loclist&lt;/code&gt; on a file called &lt;code&gt;app.js&lt;/code&gt; when I open the file and when I run &lt;code&gt;:SyntasticCheck&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have included the Syntastic config below. The complete &lt;a href=&quot;https://github.com/vamsiampolu/dotfiles/blob/master/.vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;.vimrc is hosted on github for more info.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can confirm that &lt;code&gt;./node_modules/.bin/eslint app.js&lt;/code&gt; works as expected.&#xA;The output from &lt;code&gt;:SyntasticInfo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Syntastic version: 3.8.0-26 (Vim 704, Linux, GUI)                                                                                                                                                           &#xA;Info for filetype: javascript.jsx                                                                                                                                                                           &#xA;Global mode: active                                                                                                                                                                                         &#xA;Filetype javascript.jsx is active                                                                                                                                                                           &#xA;The current file will be checked automatically                                                                                                                                                              &#xA;Available checkers: -                                                                                                                                                                                       &#xA;Currently enabled checkers: -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my &lt;code&gt;Syntastic&lt;/code&gt; config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0 &quot;skip checking on save and exit&#xA;&quot;use locally installed version of eslint with syntastic, extracted from mtscout6/syntastic-local-eslint.vim&#xA;let s:lcd = fnameescape(getcwd())&#xA;silent! exec &quot;lcd&quot; expand('%:p:h')&#xA;let s:eslint_path = system('PATH=$(npm bin):$PATH &amp;amp;&amp;amp; which eslint')&#xA;exec &quot;lcd&quot; s:lcd&#xA;let b:syntastic_javascript_eslint_exec = substitute(s:eslint_path, '^\n*\s*\(.\{-}\)\n*\s*$', '\1', '')&#xA;let g:syntastic_javascript_flowtype_exe = 'flow'&#xA;let g:syntastic_javascript_checkers = ['eslint', 'flow']&#xA;&#xA;&quot;aggregate errors from all checkers for a file type&#xA;let g:syntastic_aggregate_errors = 1&#xA;&quot;automatically open and close error list when an error is detected&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;&#xA;&quot;add rubocop to syntastic as a ruby checker&#xA;let g:syntastic_ruby_checkers = ['mri','rubocop']&#xA;&#xA;&quot;check if a file exists&#xA;function! HasConfig(file, dir)&#xA;  return findfile(a:file,escape(a:dir,' ') . ';') !=# ''&#xA;endfunction&#xA;&#xA;&quot; Merge commands into augroup vimrc&#xA;augroup vimrc&#xA;  &quot;checks for .eslintrc and .jshintrc before falling back to standard&#xA;  autocmd BufNewFile,BufReadPre *.js  let b:syntastic_checkers =&#xA;    \ HasConfig('.eslintrc', expand('&amp;lt;amatch&amp;gt;:h')) ? ['eslint'] :&#xA;    \ HasConfig('.jshintrc', expand('&amp;lt;amatch&amp;gt;:h')) ? ['jshint'] :&#xA;    \     ['standard']&#xA;&#xA;augroup end&#xA;&#xA;&quot; Typescript syntax checking using tsuqoyami&#xA;let g:tsuqoyami_disable_quickfix = 1&#xA;let g:syntastic_typescript_checkers = ['tslint', 'tsuquyomi']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10361" LastActivityDate="2017-03-18T00:35:17.397" Title="Syntastic not working with local eslint" Tags="|filetype|plugin-syntastic|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11785" PostTypeId="1" AcceptedAnswerId="11788" CreationDate="2017-03-18T00:35:30.973" Score="0" ViewCount="84" Body="&lt;p&gt;I have this idea of binding &lt;code&gt;b&lt;/code&gt; pressed after &lt;code&gt;control&lt;/code&gt; (which would preserve original &lt;code&gt;C-b&lt;/code&gt; behaviour to &lt;code&gt;Denite buffer&lt;/code&gt; and &lt;code&gt;C f&lt;/code&gt; to &lt;code&gt;Denite file_rec&lt;/code&gt;.&#xA;But &lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C&amp;gt;f :Denite file_rec&amp;lt;CR&amp;gt;&lt;/code&gt; doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and I know all about leader key. I don't need any workaround.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2017-03-18T12:14:44.990" Title="Can i map control &quot;b&quot; (b pressed after control not together with it)?" Tags="|key-bindings|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11786" PostTypeId="2" ParentId="11765" CreationDate="2017-03-18T01:13:46.697" Score="2" Body="&lt;p&gt;I'm confident that &lt;code&gt;&amp;lt;select text&amp;gt;r&amp;lt;space&amp;gt;&lt;/code&gt; as you say does work.  But you may be using a terminal in which the mouse selection is not passed to Vim (or Vim is not configured to understand the selection with the mouse; as in e.g. &lt;code&gt;set mouse=a&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet, instead of selecting with the mouse I'd use &lt;kbd&gt;f&lt;/kbd&gt; to perform the selection.  In other words assuming the cursor in the first line and first column in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;First random string&quot;    ,&quot;Random string I want to remove&quot;           }&#xA;&quot;Random string number 2&quot; , &quot;Another random string I want to keep&quot;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd do &lt;code&gt;f,f&quot;vf&quot;r 0&lt;/code&gt; and I'll end with the cursor in the same position and the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;First random string&quot;    ,                                           }&#xA;&quot;Random string number 2&quot; , &quot;Another random string I want to keep&quot;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;f,&lt;/code&gt; - moves to the comma in the middle&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f&quot;&lt;/code&gt; - moves to the next double quote (the next character, but use &lt;code&gt;f&quot;&lt;/code&gt; to account for possible spaces)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v&lt;/code&gt; - enters visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f&quot;&lt;/code&gt; - moves to the next double quote (at the other side of the string), making the visual mode select it all&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;r&amp;lt;space&amp;gt;&lt;/code&gt; - changes the entire visual selection to spaces&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; - returns to first column&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Yet, one thing I'd do would be to assign this command to a register and then reuse it, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a='0f,f&quot;vf&quot;r 0'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then I can use &lt;code&gt;@a&lt;/code&gt; as a command to &lt;em&gt;clean the second quoted string&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2017-03-18T01:13:46.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11787" PostTypeId="2" ParentId="2462" CreationDate="2017-03-18T01:55:03.623" Score="1" Body="&lt;p&gt;If you want to go to the middle of the text (not taking into account the whitespace in the beginning of the line), this will work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Gm()&#xA;  execute 'normal! ^'&#xA;  let first_col = virtcol('.')&#xA;  execute 'normal! g_'&#xA;  let last_col  = virtcol('.')&#xA;  execute 'normal! ' . (first_col + last_col) / 2 . '|'&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; gm :call &amp;lt;SID&amp;gt;Gm()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't think this will work in visual mode, however.&lt;/p&gt;&#xA;" OwnerUserId="11824" LastActivityDate="2017-03-18T01:55:03.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11788" PostTypeId="2" ParentId="11785" CreationDate="2017-03-18T08:00:05.260" Score="2" Body="&lt;p&gt;The answer is no, you can't. That is because &lt;kbd&gt;Ctrl&lt;/kbd&gt; on its own is not mappable. &lt;kbd&gt;Ctrl&lt;/kbd&gt; key works by substracting some value from the key code that is pressed with it, so for example &lt;kbd&gt;Esc&lt;/kbd&gt; has same value and meaning in Vim as &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2017-03-18T08:20:55.677" LastActivityDate="2017-03-18T08:20:55.677" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11789" PostTypeId="2" ParentId="678" CreationDate="2017-03-18T09:00:05.763" Score="4" Body="&lt;p&gt;Use &lt;code&gt;:W&lt;/code&gt; to create a file and its parent directories:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:WriteCreatingDirs()&#xA;  let l:file=expand(&quot;%&quot;)&#xA;  if empty(getbufvar(bufname(&quot;%&quot;), '&amp;amp;buftype')) &amp;amp;&amp;amp; l:file !~# '\v^\w+\:\/'&#xA;    let dir=fnamemodify(l:file, ':h')&#xA;    if !isdirectory(dir)&#xA;      call mkdir(dir, 'p')&#xA;    endif&#xA;  endif&#xA;  write&#xA;endfunction&#xA;command! W call s:WriteCreatingDirs()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Add to your &lt;code&gt;vimrc&lt;/code&gt;. Based on a combination of &lt;a href=&quot;https://stackoverflow.com/a/4294176/5353461&quot;&gt;Zyx's answer&lt;/a&gt; and &lt;a href=&quot;https://stackoverflow.com/a/4293538/5353461&quot;&gt;Damien Pollet's answers&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-03-18T09:00:05.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11791" PostTypeId="1" AcceptedAnswerId="11792" CreationDate="2017-03-18T11:25:51.553" Score="8" ViewCount="437" Body="&lt;p&gt;I'm not sure if I've failed at searching for the answer to this, but now I've worked it out I wanted to document it here. The problem is searching for a multiline pattern, and storing all such occurrences in a register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to look for calls to a particular function, e.g. &lt;code&gt;func(a, b, c);&lt;/code&gt;, so that I can extract them to a separate file. I'm doing this in Vim (rather than using, say, sed or awk), because I find Vim's searching over multiple lines syntax easiest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I search for a pattern, I know I can store the line(s) containing the results in a register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=''&#xA;:g/func\s*([^;]*;/y A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Stores all the single line calls to &lt;code&gt;func&lt;/code&gt; in &lt;code&gt;@a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this doesn't quite work if I adapt this search pattern to find multiple line calls:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/func\s*(\_.\{-\};&lt;/code&gt; matches multi-line calls such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(a, b,&#xA;c,&#xA;d);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;-- no matter how many new lines/parameters are in the way, but the corresponding global command &lt;code&gt;:g/func\s*(\_.\{-\};/y A&lt;/code&gt; just stores the first line of each match. I can sort of understand why this happens (&lt;code&gt;y&lt;/code&gt; yanks the line the result is on, and doesn't know it takes multiple lines).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I adapt the command to store all lines of each occurrence in a register?&lt;/p&gt;&#xA;" OwnerUserId="11827" LastActivityDate="2017-09-15T20:49:51.900" Title="How to store all occurrences of a multiline search in a register?" Tags="|search|register|multiple-lines|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11792" PostTypeId="2" ParentId="11791" CreationDate="2017-03-18T11:31:52.180" Score="6" Body="&lt;p&gt;It turns out something along these lines works (although there might well be better ways) -- using a substitute-without-substituting command instead of a global command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting with the answer here: &lt;a href=&quot;https://vi.stackexchange.com/questions/8906/how-to-show-all-unique-types-of-a-pattern#8914&quot;&gt;How to show all unique types of a pattern?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/[A-Za-z]*\&amp;gt;/\=add(b:types, submatch(0))/ng&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I went with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a=''&#xA;:%s/func\s*(\_[^;]\{-\};/\=setreg('A', submatch(0).&quot;\n&quot;)/ng&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which stores all the calls, even the entirety of multi-line ones. because the A is capitalised, it's appended, as before. The &quot;n&quot; means to not actually do a substitute, and for completeness &quot;g&quot; means all occurrences on each line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Previously I'd tried appending &lt;code&gt;'\n'&lt;/code&gt; or &lt;code&gt;'\r'&lt;/code&gt; to put each match on a new line -- but they came out literally. Instead appending &lt;code&gt;&quot;\n&quot;&lt;/code&gt; puts each match on a new line. Thanks to @Jair for the new line fix -- I didn't know single and double quotes were different, and didn't think to try the other!&lt;/p&gt;&#xA;" OwnerUserId="11827" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-03-18T12:59:52.393" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11793" PostTypeId="2" ParentId="11785" CreationDate="2017-03-18T12:14:44.990" Score="0" Body="&lt;p&gt;While Vim (or the Terminal) do not support this, you can get this effect by using something like &lt;a href=&quot;https://pqrs.org/osx/karabiner/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Karabiner&lt;/a&gt; (Mac) or &lt;a href=&quot;https://www.autohotkey.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Autohotkey&lt;/a&gt; (Windows).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would use it to map a single &lt;code&gt;control&lt;/code&gt; press to some key you are not using (like F12) and then use that for the mapping in Vim.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-18T12:14:44.990" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11794" PostTypeId="1" CreationDate="2017-03-18T13:53:42.300" Score="14" ViewCount="19488" Body="&lt;p&gt;I really like how vim is very light-weight compared to other text editor out there. However, this last 3 month, I stumble upon spacemacs. While spacemacs trying it's best by supporting vim's key binding (via evil mode), I don't really like how it consumes my memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the main reason I use spacemacs is merely because of emacs plugin named orgmode (&lt;a href=&quot;http://orgmode.org/&quot; rel=&quot;noreferrer&quot;&gt;http://orgmode.org/&lt;/a&gt;). I use it for note-taking as well as agenda.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I use orgmode by only using vim/neovim + tmux? (Either by using vim plugin or independent program)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, I find &lt;a href=&quot;https://github.com/jceb/vim-orgmode&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/jceb/vim-orgmode&lt;/a&gt; as the best alternative. But it lacks some features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll let this question opened since it will let everyone share interesting answers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I find the best solution is just use tmux. Make two panels, let one of the panel run vim, while the other one run spacemacs with only minimal amount of layers (I only activate org-mode). The memory consumption is quite low (~ 27 MB). So, my biggest problem is already solved.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Dj01a.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Dj01a.png&quot; alt=&quot;tmux with spacemacs and spacevim side by side&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9171" LastEditorUserId="9171" LastEditDate="2017-03-19T10:08:07.130" LastActivityDate="2017-03-24T18:18:07.640" Title="Alternative of orgmode" Tags="|neovim|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11795" PostTypeId="1" CreationDate="2017-03-18T15:08:08.073" Score="-1" ViewCount="345" Body="&lt;p&gt;In the vim editor, the buffers look like &lt;code&gt;l/t/l/c/admin.py&lt;/code&gt; for &lt;code&gt;loanwolf/test/loanwolf/customers/admin.py&lt;/code&gt;. My point is I want to see something like &lt;code&gt;admin.py (cus)&lt;/code&gt;. How could I modify the &lt;code&gt;.vimrc&lt;/code&gt; config to obtain something similar?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rbSwl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rbSwl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11830" LastEditorUserId="11830" LastEditDate="2017-03-25T16:48:42.120" LastActivityDate="2017-03-26T03:28:14.827" Title="Modify the vim configuration" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11797" PostTypeId="2" ParentId="11018" CreationDate="2017-03-18T16:53:16.217" Score="2" Body="&lt;p&gt;Looking at the image you commented on Octaviour's answer, I realise it is similar to a problem that I had for setting up vim-airline. Sure, I installed the Powerline fonts, but those weird symbols still appeared.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this, I added the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export LANG=en_US.UTF-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;at the end of my &lt;code&gt;/etc/profile&lt;/code&gt; by editing it as root. I am not really sure as to how this works, but form what I can tell, it sets the encoding on your computer to UTF-8. (And you may want to change the &lt;code&gt;en_US&lt;/code&gt; to whatever language you prefer)&lt;/p&gt;&#xA;" OwnerUserId="10378" LastActivityDate="2017-03-18T16:53:16.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11798" PostTypeId="2" ParentId="11794" CreationDate="2017-03-18T18:02:41.453" Score="0" Body="&lt;p&gt;I think &lt;a href=&quot;https://github.com/vimoutliner/vimoutliner&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimoutliner&lt;/a&gt; would probably be a good option. I've also found &lt;a href=&quot;https://github.com/vimwiki/vimwiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimwiki&lt;/a&gt; helpful in the past. &lt;/p&gt;&#xA;" OwnerUserId="4560" LastActivityDate="2017-03-18T18:02:41.453" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11799" PostTypeId="2" ParentId="11794" CreationDate="2017-03-18T18:06:02.287" Score="3" Body="&lt;p&gt;For to-do items specifically, there's &lt;a href=&quot;http://todotxt.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Todo.txt&lt;/a&gt; (though that doesn't require vim, just any text editor).&lt;/p&gt;&#xA;" OwnerUserId="4560" LastActivityDate="2017-03-18T18:06:02.287" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11801" PostTypeId="1" CreationDate="2017-03-19T01:39:55.240" Score="2" ViewCount="696" Body="&lt;p&gt;I am trying to send a message to a running tmux window that is side by side, to tell it to run a script when I press a button. What I am trying to do is done by doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent !tmux send -t 0.1 ruby test.rb ENTER &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will silently run the script. However, the display goes blank or glitches whenever I run this, and I than need to run the redraw! command to display the buffer again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the best way to convert these commands into a function?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent !tmux send -t 0.1 'ruby test.rb ENTER' &#xA;:redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so far I have tried doing the following, but I seem to be messing up somewhere:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent !tmux send -t 0.1 ruby test.rb ENTER &amp;lt;CR&amp;gt; redraw! &amp;lt;CR&amp;gt; &#xA;silent exec &quot;tmux send -t 0.1 'ruby test.rb ENTER' | redraw!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Overall, I am wondering what the best way to achieve sending messages to a tmux window would be and if this is a somewhat correct method, what is the proper way to build a vim function peicing that together?&lt;/p&gt;&#xA;" OwnerUserId="11834" LastActivityDate="2017-05-18T09:20:25.030" Title="Send message to tmux properly" Tags="|vimscript|tmux|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11802" PostTypeId="2" ParentId="11699" CreationDate="2017-03-19T02:56:07.403" Score="4" Body="&lt;p&gt;Lowercase 'p' will paste AFTER the cursor. Use a capital 'P' and it will end up BEFORE the cursor. It will not, however, insert a space, so you will end up with  &quot;JohnDoe,&quot;. &lt;/p&gt;&#xA;" OwnerUserId="8251" LastActivityDate="2017-03-19T02:56:07.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11803" PostTypeId="2" ParentId="11801" CreationDate="2017-03-19T06:10:26.830" Score="4" Body="&lt;p&gt;After messing around a bit more and looking over some stuff I was able to get this to work by wrapping the external command and its parameters in an &lt;code&gt;execute&lt;/code&gt; command then using the bar to send the redraw command. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute  &quot;silent !tmux send -t 0.1 'ruby test.rb' Enter&quot; | :redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11834" LastEditorUserId="1841" LastEditDate="2017-05-18T09:20:25.030" LastActivityDate="2017-05-18T09:20:25.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11804" PostTypeId="1" AcceptedAnswerId="11805" CreationDate="2017-03-19T06:58:39.723" Score="1" ViewCount="2036" Body="&lt;p&gt;I'm in a process of completely switching to &lt;code&gt;vim&lt;/code&gt; for my development purposes. In order to make it more IDE-like I want to install a couple of plugins and I decided to use &lt;code&gt;vundle&lt;/code&gt; as a plugin manager.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I'm using Arch Linux the first thing I did was installing &lt;code&gt;vundle&lt;/code&gt; from AUR using &lt;code&gt;yaourt&lt;/code&gt;. The problem I encountered is that it installs all the &lt;code&gt;vundle&lt;/code&gt; stuff somewhere in &lt;code&gt;/usr/share/vim/&lt;/code&gt; folder (I run &lt;code&gt;sudo find / -name autoload&lt;/code&gt; to actually locate &lt;code&gt;vundle&lt;/code&gt; specific directories). But according to &lt;code&gt;vundle&lt;/code&gt; &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Git repo&lt;/a&gt; it should be located in &lt;code&gt;~/.vim/bundle/Vundle.vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then in &lt;code&gt;.vimrc&lt;/code&gt; file I have to add bunch of lines including &lt;code&gt;set rtp+=~/.vim/bundle/Vundle.vim&lt;/code&gt; to make &lt;code&gt;vundle&lt;/code&gt; work. But I can't locate this file at all and I have no idea how to make it work with a &lt;code&gt;vundle&lt;/code&gt; installed with &lt;code&gt;yaourt&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yep, and the reason I want to install &lt;code&gt;vundle&lt;/code&gt; in that particular way is in order to get this package automatically updated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thoughts on how to make things work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I searched this Stack site and did not managed to find any similar question so I do believe it's not a duplicate. &lt;/p&gt;&#xA;" OwnerUserId="10540" LastActivityDate="2017-03-19T07:48:12.597" Title="How to use vundle for vim installed from AUR" Tags="|plugin-vundle|linux-arch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11805" PostTypeId="2" ParentId="11804" CreationDate="2017-03-19T07:48:12.597" Score="1" Body="&lt;p&gt;Well, so after some investigation I finally located a &lt;code&gt;vundle&lt;/code&gt; file. It start from a lower-cased letter and that's why I did not find it at the first place. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's located in &lt;code&gt;/usr/share/vim/vimfiles/autoload/vundle.vim&lt;/code&gt; folder. To make &lt;code&gt;vundle&lt;/code&gt; work with such a setup, the following tweaks to a config from &lt;code&gt;vundle&lt;/code&gt; &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;repo&lt;/a&gt; are necessary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;set rtp+=/usr/share/vim/vimfiles/autoload/vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/vundle.vim'&#xA;...&#xA;call vundle#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then place your plugins in place of second three dots (&lt;code&gt;...&lt;/code&gt;). Then running &lt;code&gt;PluginInstall&lt;/code&gt; from &lt;code&gt;vim&lt;/code&gt; all the added plugins will be install in &lt;code&gt;~/.vim/bundle/&lt;/code&gt; folder.&lt;/p&gt;&#xA;" OwnerUserId="10540" LastActivityDate="2017-03-19T07:48:12.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11806" PostTypeId="1" AcceptedAnswerId="11807" CreationDate="2017-03-19T09:05:52.190" Score="4" ViewCount="772" Body="&lt;p&gt;I have some shortcuts for &lt;code&gt;LaTeX&lt;/code&gt; in &lt;code&gt;./vim/after/latex.vim&lt;/code&gt; but when I open a &lt;code&gt;LaTeX&lt;/code&gt; file, this shortcuts are not available, and I need to load the file manually. I guess this is related to the &lt;code&gt;Latex-vim&lt;/code&gt; plugin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I set these shortcuts to be loaded automatically? &lt;/p&gt;&#xA;" OwnerUserId="11837" LastEditorUserId="51" LastEditDate="2017-03-19T13:12:51.163" LastActivityDate="2017-03-19T13:12:51.163" Title="When are the files in ~.vim/after/ loaded?" Tags="|vimrc|startup|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11807" PostTypeId="2" ParentId="11806" CreationDate="2017-03-19T09:10:19.477" Score="3" Body="&lt;p&gt;Add them into &lt;code&gt;~/.vim/after/ftplugin/tex/&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h 'rtp'&lt;/code&gt; IIRC and &lt;code&gt;:h ftplugin&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-03-19T09:10:19.477" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11808" PostTypeId="1" AcceptedAnswerId="11809" CreationDate="2017-03-19T09:58:36.243" Score="0" ViewCount="917" Body="&lt;p&gt;A vimscript variable &lt;code&gt;longstring&lt;/code&gt; (for instance obtained by &lt;code&gt;let longstring = getline('.')&lt;/code&gt;) contains a long sequence of characters (numbers, letters, commas, spaces, ...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to replace a specific character, let it be &lt;code&gt;A&lt;/code&gt;, with a carriage return, so that when I use &lt;code&gt;call writefile(longstring, 'this.file', '')&lt;/code&gt; I obtain a file with several lines, each containing what was found between two consecutive &lt;code&gt;A&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried with &lt;code&gt;let longstring = substitute(longstring,'A','\r','g')&lt;/code&gt;, which only results (after &lt;code&gt;writefile&lt;/code&gt;) in a single long line file with &lt;code&gt;^M&lt;/code&gt; in place of &lt;code&gt;A&lt;/code&gt;. I guess I'm using the wrong replace string, but &lt;code&gt;\n&lt;/code&gt; doesn't work either.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastActivityDate="2017-03-19T12:12:20.267" Title="Insert carriage return in a vimscript variable" Tags="|vimscript|substitute|line-breaks|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11809" PostTypeId="2" ParentId="11808" CreationDate="2017-03-19T12:12:20.267" Score="1" Body="&lt;p&gt;The first argument of &lt;code&gt;writefile&lt;/code&gt; must be a list and each list item &#xA;represents a line in the new file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#split%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;split()&lt;/code&gt;&lt;/a&gt; you could make a pattern-separated list out of&#xA;&lt;code&gt;longstring&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call writefile(split(longstring, &quot;A&quot;), 'this.file', '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and obtain the intended result.&lt;/p&gt;&#xA;" OwnerUserId="6698" LastActivityDate="2017-03-19T12:12:20.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11810" PostTypeId="2" ParentId="4244" CreationDate="2017-03-19T13:32:38.753" Score="7" Body="&lt;p&gt;See the example below,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Start vim without loading your vimrc. set only tabstop=8 softtabstop=4.&#xA;// This makes &amp;lt;Tab&amp;gt; in insert mode equals to 4 &amp;lt;Space&amp;gt; length at max.&#xA;&#xA;// In insert mode, type 12, one &amp;lt;Tab&amp;gt;, 5. We get insertion below,&#xA;12··5&#xA;// Quit insert mode. Move cursor back, we find 2 &amp;lt;Space&amp;gt; inserted.&#xA;&#xA;// In insert mode, type 12, two &amp;lt;Tab&amp;gt;, 9. We get insertion below,&#xA;12······9&#xA;// Quit insert mode. Move cursor back, you find a &amp;lt;Tab&amp;gt; inserted.&#xA;&#xA;// In insert mode, type 12, three &amp;lt;Tab&amp;gt;, 3. We get insertion below,&#xA;12··········3&#xA;// Move the cursor back, you find a &amp;lt;Tab&amp;gt; and 4 &amp;lt;Space&amp;gt; inserted.&#xA;&#xA;// We can even set sotftabstop=12, but this time we only need type one &amp;lt;Tab&amp;gt;, then 3.&#xA;12··········3&#xA;// Move the cursor back, you find a &amp;lt;Tab&amp;gt; and 4 &amp;lt;Sapce&amp;gt; inserted.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;tabstop&lt;/code&gt; is about how wide a &lt;code&gt;Tab&lt;/code&gt; is defined, while &lt;code&gt;softtabstop&lt;/code&gt; is about how far cursor moves while &lt;strong&gt;typing&lt;/strong&gt; &lt;code&gt;Tab&lt;/code&gt;. When they are not set to be the same value, it means that if you hit the &lt;code&gt;Tab&lt;/code&gt; keystroke, it does not imply trivially a &lt;code&gt;Tab&lt;/code&gt;character. In whatever cases, It is vim who decide once you quit insert mode. Vim will first try to match the insertion by as many &lt;code&gt;tabstop&lt;/code&gt; as it can; if at last it cannot make a full &lt;code&gt;tabstop&lt;/code&gt;, vim simply compensates by &lt;code&gt;Space&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To speak a little bit more, if you set &lt;code&gt;expandtab&lt;/code&gt;, it is equal to say to vim:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Please do not bother to calculate how many &lt;code&gt;Tab&lt;/code&gt; and &lt;code&gt;Sapce&lt;/code&gt; is needed. Simply insert &lt;code&gt;Space&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="9819" LastEditorUserId="9819" LastEditDate="2018-01-13T07:07:58.183" LastActivityDate="2018-01-13T07:07:58.183" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11811" PostTypeId="1" CreationDate="2017-03-19T16:43:56.327" Score="0" ViewCount="258" Body="&lt;p&gt;My experience is that Vim is slow when searching in large XML files with syntax highlighting turned on. I find it to be very dissatisfactory. I have read about the issue elsewhere but I have not been able to locate a solution. Does someone know how to treat the issue?&lt;/p&gt;&#xA;" OwnerUserId="8435" LastActivityDate="2017-09-15T13:07:31.433" Title="Vim with syntax highlighting has slow searching in XML" Tags="|syntax-highlighting|search|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11812" PostTypeId="1" AcceptedAnswerId="11817" CreationDate="2017-03-19T17:09:44.080" Score="5" ViewCount="325" Body="&lt;p&gt;In Visual Mode, you can do this using the &lt;code&gt;o&lt;/code&gt; keystroke. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However with search highlighting, ie &lt;code&gt;?&lt;/code&gt; or &lt;code&gt;/&lt;/code&gt; -- I have a whole selection, but I want to move specifically to the last character of the highlight. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm assuming there is a keystroke out there that accomplishes this. Is this the case?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="7960" LastEditorUserId="7960" LastEditDate="2017-03-19T18:49:42.657" LastActivityDate="2017-03-19T19:29:15.243" Title="Keystroke to move cursor to the last character of a highlight?" Tags="|cursor-movement|highlight|find|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11813" PostTypeId="1" CreationDate="2017-03-19T18:04:23.447" Score="1" ViewCount="93" Body="&lt;p&gt;I'd like to map &lt;code&gt;0&lt;/code&gt; to whatever number of matches I currently have. For example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/P8qWO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/P8qWO.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This here has 5 matches. If I wanted to perform a macro on every instance, i'd like to be able to simply type:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;0Q&lt;/code&gt; (&lt;code&gt;Q&lt;/code&gt; is remapped as execute macro.)&lt;/p&gt;&#xA;&lt;p&gt;which would be interpreted as:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;5Q&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is this possible? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7960" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-03-20T18:58:30.060" Title="Can I map the number of search matches to a key?" Tags="|vimrc|key-bindings|highlight|functions|repeated-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11815" PostTypeId="1" CreationDate="2017-03-19T18:19:25.833" Score="1" ViewCount="40" Body="&lt;p&gt;I have written a &lt;code&gt;python&lt;/code&gt; script that is doing some checks for a &lt;code&gt;LaTeX&lt;/code&gt; file and then compiles it. I call it upon saving the file using the following line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd BufWritePost * !~/.vim/latex_compiler.py &amp;lt;afile&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;how can I close the terminal buffer upon certain condition? &lt;/p&gt;&#xA;" OwnerUserId="11837" LastActivityDate="2017-03-19T18:19:25.833" Title="how can I close the shell buffer? Prefferbly under a certain condition." Tags="|autocmd|terminal|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11816" PostTypeId="2" ParentId="11812" CreationDate="2017-03-19T18:45:40.477" Score="2" Body="&lt;p&gt;You can add various parameters or commands for the offset of where the cursor lands. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/test/e         on the last t of &quot;test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More info here:&#xA;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#search-offset&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/pattern.html#search-offset&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11834" LastActivityDate="2017-03-19T18:45:40.477" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11817" PostTypeId="2" ParentId="11812" CreationDate="2017-03-19T19:29:15.243" Score="5" Body="&lt;p&gt;&lt;code&gt;gn&lt;/code&gt; + &lt;code&gt;&amp;lt;Escape&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gn                      Search forward for the last used search pattern, like&#xA;                        with n, and start Visual mode to select the match.&#xA;                        If the cursor is on the match, visually selects it.&#xA;                        If an operator is pending, operates on the match.&#xA;                        E.g., &quot;dgn&quot; deletes the text of the next match.&#xA;                        If Visual mode is active, extends the selection&#xA;                        until the end of the next match.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will leave you already on the last character of the highlight so you only need to press &lt;code&gt;&amp;lt;Escape&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-19T19:29:15.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11818" PostTypeId="1" AcceptedAnswerId="11819" CreationDate="2017-03-19T20:58:58.040" Score="0" ViewCount="410" Body="&lt;p&gt;I'm trying to use ac to copy the whole contents to the system clipboard in gVim. Putting this in my .vimrc isn't working:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;ac ggvG$&amp;lt;C-Insert&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I manually press &lt;code&gt;ggvG$[Ctrl-Insert]&lt;/code&gt; from normal mode, it works as expected: goes to the top, selects to the bottom, copies it all, and drops me in normal mode at the top of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I set &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;ac ggvG$&amp;lt;C-Insert&amp;gt;&lt;/code&gt; in my .vimrc, and then activate it (with &lt;code&gt;[Space]ac&lt;/code&gt;), it selects from the top to the bottom, beeps an error, and then just sits there in visual mode with the whole file selected.&lt;br&gt;&#xA;If I manually press &lt;code&gt;[Ctrl-Insert]&lt;/code&gt; at that point, it finishes as expected. So I'm pretty sure vim's just not doing the &lt;code&gt;&amp;lt;C-Insert&amp;gt;&lt;/code&gt; part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I further tested by adding this &lt;code&gt;vnoremap &amp;lt;leader&amp;gt;ci &amp;lt;C-Insert&amp;gt;&lt;/code&gt;.&lt;br&gt;&#xA;I selected a word or a line in visual mode, activated that map, and got a beep and no copying. A manual &lt;code&gt;[Ctrl-Insert]&lt;/code&gt; works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;strong&gt;why can't I map to &lt;code&gt;&amp;lt;C-Insert&amp;gt;&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="9267" LastActivityDate="2017-03-19T21:23:26.097" Title="Can't map to &lt;C-Insert&gt;" Tags="|key-bindings|cut-copy-paste|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11819" PostTypeId="2" ParentId="11818" CreationDate="2017-03-19T21:23:26.097" Score="2" Body="&lt;p&gt;&lt;code&gt;help c-insert&lt;/code&gt; will tell you that &lt;code&gt;&quot;*y&lt;/code&gt; will do the same as &lt;code&gt;&amp;lt;C-Insert&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So try &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;ac ggVG&quot;*y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(using &lt;code&gt;V&lt;/code&gt; as it makes more sense)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I didn't check, Vim says it's a standard DOS mapping so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;ac ggVG&amp;lt;c-insert&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;may work as well.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-19T21:23:26.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11820" PostTypeId="1" AcceptedAnswerId="11821" CreationDate="2017-03-20T01:05:30.160" Score="2" ViewCount="259" Body="&lt;p&gt;Does anyone know what settings or package I can use to make vim autoindent html if it's wider that the screen. eg. it is displaying like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;main&amp;gt;&#xA;  &amp;lt;section&amp;gt;&#xA;    &amp;lt;form action=&quot;#&quot;&amp;gt;&#xA;      &amp;lt;input type=&quot;text&quot; class=&quot;someclassname&quot; id=&quot;someid&quot; value=&quot;foo&quot; &#xA;placeholder=&quot;&quot; data-foo=&quot;foo&quot; data-bar=&quot;bar&quot; /&amp;gt;&#xA;    &amp;lt;/form&amp;gt;&#xA;  &amp;lt;/section&amp;gt;&#xA;&amp;lt;/main&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like it to indent the broken line like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;main&amp;gt;&#xA;  &amp;lt;section&amp;gt;&#xA;    &amp;lt;form action=&quot;#&quot;&amp;gt;&#xA;      &amp;lt;input type=&quot;text&quot; class=&quot;someclassname&quot; id=&quot;someid&quot; value=&quot;foo&quot; &#xA;        placeholder=&quot;&quot; data-foo=&quot;foo&quot; data-bar=&quot;bar&quot; /&amp;gt;&#xA;    &amp;lt;/form&amp;gt;&#xA;  &amp;lt;/section&amp;gt;&#xA;&amp;lt;/main&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or even this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;main&amp;gt;&#xA;  &amp;lt;section&amp;gt;&#xA;    &amp;lt;form action=&quot;#&quot;&amp;gt;&#xA;      &amp;lt;input type=&quot;text&quot; &#xA;        class=&quot;someclassname&quot; &#xA;        id=&quot;someid&quot; value=&quot;foo&quot; &#xA;        placeholder=&quot;enter something&quot; &#xA;        data-foo=&quot;foo&quot; &#xA;        data-bar=&quot;bar&quot; /&amp;gt;&#xA;    &amp;lt;/form&amp;gt;&#xA;  &amp;lt;/section&amp;gt;&#xA;&amp;lt;/main&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;" OwnerUserId="11844" LastActivityDate="2017-03-20T06:30:27.907" Title="Auto indent broken lines in html" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11821" PostTypeId="2" ParentId="11820" CreationDate="2017-03-20T06:30:27.907" Score="3" Body="&lt;p&gt;Short Answer: &lt;code&gt;set breakindent&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long Answer: &lt;a href=&quot;https://stackoverflow.com/questions/1204149/smart-wrap-in-vim&quot;&gt;https://stackoverflow.com/questions/1204149/smart-wrap-in-vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11189" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-03-20T06:30:27.907" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11822" PostTypeId="1" AcceptedAnswerId="11823" CreationDate="2017-03-20T07:16:52.330" Score="2" ViewCount="527" Body="&lt;p&gt;I want to have a function that &lt;code&gt;vimgrep&lt;/code&gt; for the word under the cursor appended to a predefined string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have defined this &lt;code&gt;command&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;command! -nargs=0 GJL vimgrep &amp;lt;cword&amp;gt; *.tex | copen&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which does the job for only the current word. Now I want to grep for &lt;code&gt;ref{ + &amp;lt;cword&amp;gt;&lt;/code&gt;. That is, in the case that &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; is &lt;code&gt;eqn1&lt;/code&gt;, I want to grep for &lt;code&gt;ref{eqn1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how to set up this function in a &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8648" LastActivityDate="2017-03-20T08:25:04.240" Title="join string and &lt;cword&gt; for vimgrep in command" Tags="|vimrc|functions|vimgrep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11823" PostTypeId="2" ParentId="11822" CreationDate="2017-03-20T08:25:04.240" Score="2" Body="&lt;p&gt;Use &lt;code&gt;exec&lt;/code&gt; with &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-.&quot; rel=&quot;nofollow noreferrer&quot;&gt;string concatenation&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=0 GJL exec 'vimgrep ref{'.expand('&amp;lt;cword&amp;gt;').' *.tex | copen'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a function, you'd do something similar, but more neatly, I suppose:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Foo()&#xA;    let l:pattern = 'ref{' . expand('&amp;lt;cword&amp;gt;')&#xA;    exec 'vimgrep' l:pattern '*.tex | copen'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-03-20T08:25:04.240" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11824" PostTypeId="1" AcceptedAnswerId="11829" CreationDate="2017-03-20T17:50:17.910" Score="14" ViewCount="941" Body="&lt;p&gt;I use the &lt;code&gt;oldfiles&lt;/code&gt; and &lt;code&gt;browse oldfiles&lt;/code&gt; commands all the time. I find them extremely useful, because it's easier to hit my leader mapping, scan through the files really quickly, and hit&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;q&amp;lt;number&amp;gt;&amp;lt;enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;rather than typing out a really long directory path to a specific file. (Especially since sometimes I don't remember which directory it's in)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there's only one downside. Since I use vim so frequently, sometimes the file I'm looking for is dozens and dozens of rows down, so it takes a really long time to find. Is there any way I could filter the list of files given by &lt;code&gt;oldfiles&lt;/code&gt; to show only a certain extension?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, a command like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;browse oldfiles *.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that shows a list of &lt;code&gt;.py&lt;/code&gt; files I've recently opened, prompts for a number, and then opens that file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there's no way to do this, are there plugins with similar functionality?&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2021-11-16T17:19:37.803" Title="Can I search through 'oldfiles' with a specific name or extension?" Tags="|vimscript|command-line|filesystem|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11825" PostTypeId="1" CreationDate="2017-03-20T17:54:56.527" Score="0" ViewCount="47" Body="&lt;p&gt;I'm using Windows 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to view a 3.8 GB log file. I'd rather use Vim, not &lt;a href=&quot;//en.wikipedia.org/wiki/Less_(Unix)&quot; rel=&quot;nofollow noreferrer&quot;&gt;less(1)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked at &lt;a href=&quot;https://vi.stackexchange.com/questions/6097/&quot;&gt;this question&lt;/a&gt;, but it really only tells me how to download 64-bit Vim, not how to install it. (TuxProject's &quot;complete-x64.exe&quot; file is a self-extracting archive, not an installer.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want a simple way to install a full Vim on Windows, including an &quot;Edit with Vim&quot; context-menu item in Windows Explorer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do?&lt;/p&gt;&#xA;" OwnerUserId="11851" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-03-20T17:54:56.527" Title="How can I download and easily install 64-bit Vim for Windows?" Tags="|microsoft-windows|installing|" AnswerCount="0" CommentCount="1" FavoriteCount="0" ClosedDate="2017-03-20T18:13:07.103" ContentLicense="CC BY-SA 3.0" />
  <row Id="11826" PostTypeId="2" ParentId="6097" CreationDate="2017-03-20T17:54:56.527" Score="1" Body="&lt;p&gt;The other answers really only point you to .zip files or self-extracting archives, not to installers. (TuxProject's &quot;complete-x64.exe&quot; file is a self-extracting archive, not an installer.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an easy way to &lt;em&gt;install&lt;/em&gt; 64-bit Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following steps will install a full 64-bit Vim on Windows, including a working &quot;Edit with Vim&quot; context-menu item in Windows Explorer. I have no idea whether or not Python will work. Try it and see, then &lt;a href=&quot;https://vi.stackexchange.com/posts/11826/edit&quot;&gt;edit this answer&lt;/a&gt; to inform other people.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;To install Vim&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;A) Install &lt;a href=&quot;https://chocolatey.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chocolatey&lt;/a&gt;, which is a high-level package-management system for Windows. It's kind of like apt-get or yum for Linux, but perhaps not quite as elegant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;B) Open a command prompt. Make sure to launch it as Administrator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C) If you don't have &quot;vcruntime140.dll&quot; installed, or if you're not sure whether or not you have it, install it. You should use the &lt;code&gt;-y&lt;/code&gt; switch, or else Chocolatey will ask you a lot of questions. Enter this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;choco install vcredist2015 -y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;D) Install 64-bit Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;choco install vim-tux -y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Chocolatey will install Vim automatically, with no questions asked.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;To do an upgrade by entering just one command&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Run this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;choco upgrade all -y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will make Chocolatey upgrade everything that it's installed. This is automatic, with no questions asked. Please be patient.&lt;/p&gt;&#xA;" OwnerUserId="11851" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2017-03-20T18:51:45.233" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11827" PostTypeId="1" AcceptedAnswerId="13293" CreationDate="2017-03-20T18:07:30.727" Score="2" ViewCount="523" Body="&lt;p&gt;For files of a certain &lt;code&gt;filetype&lt;/code&gt;, specifying &quot;file-type-specific&quot; mappings is simple. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If Vim opens a fill and return &lt;code&gt;filetype=python&lt;/code&gt; after issuing command &lt;code&gt;:set filetype?&lt;/code&gt; through command-line (native to Vim), then python-specific mappings could be defined directly through &lt;code&gt;~/ftplugin/python.vim&lt;/code&gt;;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;However, where shall I specify the mappings for files that return &lt;code&gt;filetype=&lt;/code&gt; after issuing command &lt;code&gt;:set filetype?&lt;/code&gt;. This applies to cases where one does not give a file any extension.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2398" LastActivityDate="2020-06-01T14:22:10.443" Title="Defining mappings for files of the &quot;null&quot; type through /ftplugin" Tags="|vimrc|gvim|vim-windows|macvim|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11828" PostTypeId="2" ParentId="11813" CreationDate="2017-03-20T18:58:30.060" Score="3" Body="&lt;p&gt;You can use the global command to search for the pattern and then execute a command on the available pattern as such &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/pattern/command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which could be modified in your case as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/pattern/normal @Q &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where pattern is the word on which you will run the macro and @Q is the macro register.  &lt;/p&gt;&#xA;" OwnerUserId="9004" LastActivityDate="2017-03-20T18:58:30.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11829" PostTypeId="2" ParentId="11824" CreationDate="2017-03-20T19:15:11.950" Score="20" Body="&lt;p&gt;Assuming you have Vim 8 you can use &lt;code&gt;:filter&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:browse filter /pattern/ oldfiles&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :browse&#xA;:h :filter&#xA;:h oldfiles&#xA;:h new-items-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-03-20T19:15:11.950" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11830" PostTypeId="1" AcceptedAnswerId="11831" CreationDate="2017-03-20T21:04:11.780" Score="1" ViewCount="1043" Body="&lt;p&gt;I would like to add a new line in a certain line in a buffer. So far my starting position is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let newl = &quot;\n&quot;&#xA;&quot; set cursor to beginning of buffer&#xA;call cursor(1,1)&#xA;&quot; search up to 10 lines down&#xA;search(&quot;somestring&quot;,'',10)&#xA;&quot; get the line number of the match&#xA;let cursor_pos = getpos(&quot;.&quot;)&#xA;let cursor_line = cursor_pos[1]&#xA;&quot; put a newline directly behind it&#xA;(cursor_line+1)put =newl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I cannot combine a variable with &lt;code&gt;put&lt;/code&gt; like I would with a number: &lt;code&gt;11put&lt;/code&gt;. How can I accomplish that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second problem is rather of a aesthetic nature: When using something like &lt;code&gt;11put =&quot;\n&quot;&lt;/code&gt; Vim behaves weird, it somehow prints out a value of a variable that has nothing to do with a newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get the task done in an overall better way - putting a newline at a certain position?&lt;/p&gt;&#xA;" OwnerUserId="11853" LastActivityDate="2017-03-20T22:51:51.157" Title="Tell Vim's put to print a string at a position given by the value of a variable" Tags="|vimscript|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11831" PostTypeId="2" ParentId="11830" CreationDate="2017-03-20T21:11:32.140" Score="2" Body="&lt;p&gt;What about this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/somestring&#xA;normal! o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to have it dynamic, take a look at &lt;code&gt;:exe&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call append(cursor_line, '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2899" LastEditorUserId="2899" LastEditDate="2017-03-20T22:51:51.157" LastActivityDate="2017-03-20T22:51:51.157" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11832" PostTypeId="2" ParentId="9249" CreationDate="2017-03-20T21:25:00.120" Score="13" Body="&lt;p&gt;I had this issue as well because I had switched to the &quot;evening&quot; color scheme in my ~/.vimrc file so that my comments were easier to read on a dark background:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:colorscheme evening&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To restore visual mode highlighting I had to also add this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight Visual cterm=reverse ctermbg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11854" LastActivityDate="2017-03-20T21:25:00.120" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11833" PostTypeId="2" ParentId="11830" CreationDate="2017-03-20T21:43:55.547" Score="1" Body="&lt;p&gt;Use the blackhole register, &lt;code&gt;&quot;_&lt;/code&gt; with &lt;code&gt;:put&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:99put_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or use an expression register, &lt;code&gt;&quot;=&lt;/code&gt;, with an array of empty strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:99put=['']&#xA;:99put=repeat([''], 3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to put a specific string on a line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let str = 'hello world'&#xA;:99put=str&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-03-20T21:43:55.547" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11834" PostTypeId="2" ParentId="11827" CreationDate="2017-03-20T23:04:20.187" Score="0" Body="&lt;p&gt;I would define a autocommand for all buffers that'd test for the filetype. I'm afraid there is no other way. &lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-03-20T23:04:20.187" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11835" PostTypeId="1" CreationDate="2017-03-21T03:44:45.887" Score="2" ViewCount="827" Body="&lt;p&gt;The &lt;code&gt;line(&quot;.&quot;)&lt;/code&gt;, command gets the line in the current buffer. Whats the command to get line in an arbitrary buffer, using buffer numbers?&lt;/p&gt;&#xA;" OwnerUserId="11858" LastEditorUserId="71" LastEditDate="2017-03-21T11:20:13.517" LastActivityDate="2017-03-21T11:26:56.413" Title="Get cursor position in all buffers" Tags="|vimscript|buffers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11837" PostTypeId="2" ParentId="11835" CreationDate="2017-03-21T11:26:56.413" Score="2" Body="&lt;p&gt;The &lt;code&gt;getbufinfo()&lt;/code&gt; returns a list of dictionaries. One of the dictionary key is &lt;code&gt;lnum&lt;/code&gt; - line number. One other key is &lt;code&gt;bufn&lt;/code&gt; - buffer number.&lt;/p&gt;&#xA;" OwnerUserId="11858" LastActivityDate="2017-03-21T11:26:56.413" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11838" PostTypeId="1" AcceptedAnswerId="11840" CreationDate="2017-03-21T13:03:07.800" Score="1" ViewCount="443" Body="&lt;p&gt;i've got a mapping for iterating thru suggested pop up window of omni completion&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;TAB&amp;gt; pumvisible() ? &quot;\&amp;lt;C-y&amp;gt;&quot; : &quot;\&amp;lt;TAB&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but i also want a  to trigger while there is no suggestions menu but a &lt;a href=&quot;https://github.com/garbas/vim-snipmate/&quot; rel=&quot;nofollow noreferrer&quot;&gt;snipmate&lt;/a&gt; shortcut &lt;code&gt;&amp;lt;Plug&amp;gt;snipMateNextOrTrigger&lt;/code&gt; has been faced, but now only actual tab is inserted after an expression expected to be expanded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;TAB&amp;gt; pumvisible() ? &quot;\&amp;lt;C-y&amp;gt;&quot; : &quot;&amp;lt;c-r&amp;gt;=snipMate#TriggerSnippet()&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11110" LastEditorUserId="11110" LastEditDate="2017-03-22T14:45:58.103" LastActivityDate="2017-03-22T14:59:22.430" Title="Redefine &lt;TAB&gt; key for triggering plugin action" Tags="|key-bindings|plugin-snipmate|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11839" PostTypeId="1" AcceptedAnswerId="11842" CreationDate="2017-03-21T13:48:55.870" Score="4" ViewCount="1135" Body="&lt;p&gt;I'm trying to create a mapping to create a mapping such that pressing &lt;code&gt;&amp;lt;C-return&amp;gt;&lt;/code&gt; presents me with &lt;code&gt;:nnoremap &amp;lt;return&amp;gt; :&lt;/code&gt; to which I can then add a custom command. The following does not work because &lt;code&gt;&amp;lt;return&amp;gt;&lt;/code&gt; is replaced by the return key.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;c-return&amp;gt; :nnoremap &amp;lt;return&amp;gt; :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought I could escape &lt;code&gt;&amp;lt;return&amp;gt;&lt;/code&gt; as &lt;code&gt;\&amp;lt;return&amp;gt;&lt;/code&gt;, but this does not seem to be working. How do I escape (or otherwise prevent nnoremap from expanding) &lt;code&gt;&amp;lt;return&amp;gt;&lt;/code&gt; in the above statement?&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2017-03-21T15:31:07.077" Title="mapping to map &lt;return&gt;" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11840" PostTypeId="2" ParentId="11838" CreationDate="2017-03-21T13:51:13.027" Score="2" Body="&lt;p&gt;One way would be to call whatever &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; is normally calling instead of issuing the tab key press. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;TAB&amp;gt; pumvisible() ? &quot;\&amp;lt;C-y&amp;gt;&quot; : &quot;&amp;lt;esc&amp;gt;:call NormalTabFunction()&amp;lt;cr&amp;gt;a&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command that actually worked in this specific case was (resulting from the discussion in the comments):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;TAB&amp;gt; pumvisible() ? &quot;\&amp;lt;C-y&amp;gt;&quot; : &amp;lt;c-r&amp;gt;=snipMate#TriggerSnippet()&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8061" LastEditorUserId="8061" LastEditDate="2017-03-22T14:59:22.430" LastActivityDate="2017-03-22T14:59:22.430" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="11841" PostTypeId="2" ParentId="11839" CreationDate="2017-03-21T15:09:54.697" Score="1" Body="&lt;p&gt;Interesting I thought we could do this with an &lt;code&gt;exe&lt;/code&gt; command, but that fails too. I found a way to do it but it's pretty hacky:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;c-return&amp;gt; :nnoremap &amp;lt;return &amp;gt; :&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;BS&amp;gt;&amp;lt;c-right&amp;gt;&amp;lt;c-right&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-left&amp;gt;&lt;/code&gt;: executes &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;←&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-right&amp;gt;&lt;/code&gt;: executes &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;→&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt;: executes &lt;kbd&gt;Backspace&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;We're basically breaking up the &lt;code&gt;&amp;lt;return&amp;gt;&lt;/code&gt; so that it's not recognized and then we go back and delete the space. This works, but I'm curious if there is a better way of doing it. &lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-03-21T15:25:00.837" LastActivityDate="2017-03-21T15:25:00.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11842" PostTypeId="2" ParentId="11839" CreationDate="2017-03-21T15:31:07.077" Score="4" Body="&lt;p&gt;Escape &lt;code&gt;&amp;lt;&lt;/code&gt; as &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-return&amp;gt; :nnoremap &amp;lt;lt&amp;gt;return&amp;gt; :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h key-codes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-03-21T15:31:07.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11843" PostTypeId="2" ParentId="11827" CreationDate="2017-03-21T15:44:30.557" Score="0" Body="&lt;p&gt;Depending on your use case for such feature, if you just don't want to have that mapping in files with a type, then you can set normal mapping and autocommand for any filetype that will remove that mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;M :echo &quot;Example&quot;&amp;lt;CR&amp;gt;&#xA;&#xA;autocmd FileType * :nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;M &amp;lt;NOP&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can have side effects if you would like to reuse that mapping in a file with a type - I'm not sure if it will work then (race condintion)&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-03-21T15:44:30.557" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11844" PostTypeId="1" CreationDate="2017-03-21T17:38:33.470" Score="60" ViewCount="52700" Body="&lt;p&gt;Let's say I had a block of text...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum&#xA;Lorem ipsum dolor&#xA;Lorem ipsum dolor sit&#xA;Lorem ipsum dolor sit amet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and I wanted to insert a &lt;code&gt;.&lt;/code&gt; at the end of each line. What would the best approach be to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="11862" LastActivityDate="2020-08-18T17:38:16.337" Title="How can I insert text at the end of a group of lines?" Tags="|insert-mode|visual-block|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11845" PostTypeId="2" ParentId="11844" CreationDate="2017-03-21T17:54:26.767" Score="7" Body="&lt;p&gt;First you can visually select them using &lt;code&gt;V&lt;/code&gt; and then use the movement keys to select the entire text (or if the text were strictly a paragraph you could do [starting at the first line] &lt;code&gt;V}&lt;/code&gt;). And then type &lt;code&gt;:&lt;/code&gt;. This should bring up something like &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt; in the command-line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;'&amp;gt;normal A.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This executes &lt;code&gt;normal A.&lt;/code&gt; on the selected lines. &lt;code&gt;normal A.&lt;/code&gt; executes &lt;code&gt;A.&lt;/code&gt; as normal mode keystrokes. This &lt;code&gt;A&lt;/code&gt;ppends a &lt;code&gt;.&lt;/code&gt; at the end of each of the selected lines.&lt;/p&gt;&#xA;" OwnerUserId="10378" LastActivityDate="2017-03-21T17:54:26.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11846" PostTypeId="2" ParentId="11844" CreationDate="2017-03-21T20:58:14.227" Score="18" Body="&lt;p&gt;On first line just type:&#xA; &lt;code&gt;4:norm A.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;4&lt;/code&gt; and &lt;code&gt;:&lt;/code&gt; create a range for you and then &lt;code&gt;norm A.&lt;/code&gt; adds the dot to each line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution for longer paragraphs could be:&#xA;&lt;code&gt;Vip&amp;lt;C-v&amp;gt;$A.&amp;lt;Esc&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first step is to select the paragraph with &lt;code&gt;Vip&lt;/code&gt; then you change to visual block mode and move the cursor to the end of each line with &lt;code&gt;$&lt;/code&gt; then you add the &lt;code&gt;.&lt;/code&gt; to each line with &lt;code&gt;A.&lt;/code&gt; and got to normal mode with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to see the change be applied to each line.&lt;/p&gt;&#xA;" OwnerUserId="11690" LastEditorUserId="11690" LastEditDate="2017-03-22T00:37:25.243" LastActivityDate="2017-03-22T00:37:25.243" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11848" PostTypeId="2" ParentId="11844" CreationDate="2017-03-22T13:56:10.050" Score="6" Body="&lt;p&gt;If you want to add dot at the end of all lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm A.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or you can use search and replace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/$/./&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;% is whole file, $ is end of line&lt;/p&gt;&#xA;" OwnerUserId="11181" LastActivityDate="2017-03-22T13:56:10.050" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11849" PostTypeId="2" ParentId="11844" CreationDate="2017-03-22T14:54:11.457" Score="4" Body="&lt;p&gt;To make it a little more general, you can record a macro on a single line, and then play it back on each line in your visually selected range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Record a macro into a register (the q register in this example):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqA.&amp;lt;Esc&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then visually select the lines you want to operate on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then play back your macro on each line (the range will be auto-filled):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;norm @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1155" LastActivityDate="2017-03-22T14:54:11.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11850" PostTypeId="1" AcceptedAnswerId="11851" CreationDate="2017-03-22T17:47:19.187" Score="5" ViewCount="9281" Body="&lt;p&gt;I have been use vim since 1 year. But I don't know about all facilities in vim, although I know that vim is powerful text editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I want to learn vim in a sequential way by reading a book.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use vim in terminal on Ubuntu 14.04 and on Fedora 25.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for response.&lt;/p&gt;&#xA;" OwnerUserId="9498" LastActivityDate="2017-03-22T18:13:05.077" Title="what is the good book for learning vim?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ClosedDate="2017-03-22T18:11:31.047" ContentLicense="CC BY-SA 3.0" />
  <row Id="11851" PostTypeId="2" ParentId="11850" CreationDate="2017-03-22T17:58:38.440" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://www.swaroopch.com/notes/vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;A Byte of Vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;ftp://ftp.vim.org/pub/vim/doc/book/vimbook-OPL.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;The vim book&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;ftp://ftp.vim.org/pub/vim/doc/book/vimbook-OPL.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;O’Reilly’s Learning the vi and Vim Editors&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;recommended books in &lt;a href=&quot;http://vim.begin-site.org/books/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.begin-site.org/books/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also read &lt;em&gt;Practical vim&lt;/em&gt; by &lt;em&gt;Drew Neil&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="9498" LastEditorUserId="9498" LastEditDate="2017-03-22T18:13:05.077" LastActivityDate="2017-03-22T18:13:05.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11852" PostTypeId="1" AcceptedAnswerId="11855" CreationDate="2017-03-23T00:04:25.953" Score="14" ViewCount="8589" Body="&lt;p&gt;&lt;code&gt;xmap&lt;/code&gt; creates a mapping for just Visual mode whereas &lt;code&gt;vmap&lt;/code&gt; creates one for both Visual mode and Select mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I understand, the intent of Select mode was to make Vim behave just like every other non-modal editor when text is selected, i.e., typing anything immediately replaces the selection with the typed text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems to me that you would almost NEVER want to map anything in Select mode because in Select mode you would want your typed text to appear literally as if you were in Insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm leaning towards using &lt;code&gt;xmap&lt;/code&gt; instead of &lt;code&gt;vmap&lt;/code&gt; in all of my mappings. Is this a good/bad idea?&lt;/p&gt;&#xA;" OwnerUserId="7454" LastActivityDate="2017-07-19T15:23:26.653" Title="Should I use xmap or vmap in my mappings?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11853" PostTypeId="2" ParentId="625" CreationDate="2017-03-23T02:45:29.623" Score="5" Body="&lt;p&gt;You can place below mentioned setting in &lt;code&gt;.gitconfig&lt;/code&gt; file found in &lt;code&gt;%homepath%&lt;/code&gt; (or &lt;code&gt;%userprofile%&lt;/code&gt;) directory of the currently logged in user:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[diff]&#xA;    tool = vimdiff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will enable git bash tool to start using vimdiff as the external diff tool as well.&lt;/p&gt;&#xA;" OwnerUserId="11884" LastEditorUserId="11884" LastEditDate="2017-08-20T16:27:29.657" LastActivityDate="2017-08-20T16:27:29.657" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11854" PostTypeId="1" CreationDate="2017-03-23T06:45:58.300" Score="1" ViewCount="244" Body="&lt;p&gt;Trying to make it easier to comment out unused parameters in a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added the macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map C wbywcw/*&amp;lt;C-v&amp;gt;&amp;lt;Esc&amp;gt;pa*/&amp;lt;C-v&amp;gt;&amp;lt;Esc&amp;gt;/[,)]&amp;lt;C-v&amp;gt;&amp;lt;C-m&amp;gt;nb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So on hitting Cap-C it will comment out the current parameter under the cursor and move to the next parameter. Nice to get feedback on that as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what I really want to try and do is make it check to see if the current parameter is commented out. If it is then uncomment it otherwise comment it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Break down of the current command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map C wbywcw/*&amp;lt;C-v&amp;gt;&amp;lt;Esc&amp;gt;pa*/&amp;lt;C-v&amp;gt;&amp;lt;Esc&amp;gt;/[,)]&amp;lt;C-v&amp;gt;&amp;lt;C-m&amp;gt;nb&#xA;&#xA;wb    go the beginning of the current word.&#xA;      Need to use &quot;w&quot; first becuase if we are currently at the&#xA;      beginning of the word a single &quot;b&quot; would go to the previous word.&#xA;&#xA;yw    yank the parameter into the buffer.&#xA;&#xA;cw    Change the parameter.&#xA;      Into /*&#xA;&#xA;p     pull the yanked parameter so we now have&#xA;      /*param&#xA;&#xA;a     append more text&#xA;      /*param*/&#xA;&#xA;/[,)] Search for the closing ')' or the comma after this parameter&#xA;&#xA;n     Move to the comma after the next param&#xA;&#xA;b     Move back one word should be the next param&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="383" LastActivityDate="2017-09-19T17:15:46.173" Title="Comment out unused parameters" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11855" PostTypeId="2" ParentId="11852" CreationDate="2017-03-23T07:31:49.283" Score="16" Body="&lt;p&gt;Indeed prefer mappings to visual-mode only, in particular keys that could be displayed. Things like &lt;code&gt;&amp;lt;F1&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;m-left&amp;gt;&lt;/code&gt; could usually be mapped with &lt;code&gt;:vmap&lt;/code&gt; with no harm done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Select-mode is used when setting Vim in other-editor-like mode (see the infamous mswin.vim). Select-mode is also used by all snippet plugins. When we jump to a placeholder, we end up in select-mode. That's why it's important to not map things that could be legitimately inserted in insert-mode or in select-mode.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-07-19T15:23:26.653" LastActivityDate="2017-07-19T15:23:26.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11856" PostTypeId="2" ParentId="11844" CreationDate="2017-03-23T11:43:25.680" Score="65" Body="&lt;p&gt;I do the following to append text to multiple lines:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-V&amp;gt;&lt;/code&gt; - Enter Visual Block mode.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;j&lt;/code&gt;/&lt;code&gt;k&lt;/code&gt; to select the lines.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt; - Move cursor to last character.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A&lt;/code&gt; - Enter insert mode after last character.&lt;/li&gt;&#xA;&lt;li&gt;Insert desired text.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; - Exit insert mode and finish block append.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When compared to writing &lt;code&gt;:norm&lt;/code&gt; after selection there are even less key presses, but the real reason why I use this is because it's more instinctive for me to work on Visual Block mode for this type of changes.&lt;/p&gt;&#xA;" OwnerUserId="599" LastActivityDate="2017-03-23T11:43:25.680" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11857" PostTypeId="1" AcceptedAnswerId="12371" CreationDate="2017-03-23T14:21:14.177" Score="1" ViewCount="547" Body="&lt;p&gt;I run Ubuntu 14.04 and want to use YouCompleteMe with vim for python and c++ code completion. YouCompleteMe requires vim 7.4.143+, which is higher than what I get with apt-get, so I follow &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; tutorial to install newer vim from source. Before installation I do run &lt;code&gt;sudo apt-get remove --auto-remove vim vim-runtime gvim&lt;/code&gt; to get rid of everything that could depend on the previous vim version, and I also use &lt;em&gt;checkinstall&lt;/em&gt; instead of plain &lt;em&gt;make install&lt;/em&gt;. After this I run &lt;code&gt;sudo apt-get -f install &amp;amp;&amp;amp; sudo apt-get upgrade&lt;/code&gt; to make sure that new vim did not introduce any disturbances, and I still have the latest version of everything running. After that, I can use vim YouCompleteMe working smoothly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does not work smoothly though is Ubuntu's auto-update: the next time that I accept graphical offer from the operating system to upgrade my packages, the update process crashes going into some troubles, and I cannot run vim on from that point. &lt;code&gt;sudo apt-get -f install&lt;/code&gt; proposes me to install &lt;em&gt;vim-common&lt;/em&gt; and &lt;em&gt;vim-runtime&lt;/em&gt;, and when I do that I have the old version of vim once again without being able to use YouCompleteMe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I find which packages my new vim has conflict with? How could I resolve that conflict?&lt;/p&gt;&#xA;" OwnerUserId="11893" LastActivityDate="2017-05-11T17:33:36.813" Title="How to avoid dependency conflics when installing vim from source?" Tags="|plugin-you-complete-me|installing|linux-ubuntu|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11858" PostTypeId="2" ParentId="11854" CreationDate="2017-03-23T14:26:00.523" Score="1" Body="&lt;p&gt;Just the toggling of the comment (not yet turned into a macro and without proceeding to the next parameter):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;viw:s_\(/\*\)\=\(\%V\w*\)\(\*/\)\=_\=strpart(&quot;/*&quot;, strlen(submatch(1))).submatch(2).strpart(&quot;*/&quot;, strlen(submatch(3)))_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, if you prefer more &lt;code&gt;magic&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;viw:s_\v(/\*)=(%V\w*)(\*/)=_\=strpart(&quot;/*&quot;, strlen(submatch(1))).submatch(2).strpart(&quot;*/&quot;, strlen(submatch(3)))_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, the length of the submatches for &lt;code&gt;/*&lt;/code&gt; and &lt;code&gt;*/&lt;/code&gt; are used to cut characters from these strings (so their presence is inverted).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, if you trust in comment signs being pairwise, you could do it a little shorter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;viw:s_\v(/\*)=(%V\w*)(\*/)=_\=submatch(1)==&quot;&quot;?&quot;/*&quot;.submatch(2).&quot;*/&quot;:submatch(2)_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11771" LastEditorUserId="11771" LastEditDate="2017-03-23T14:37:15.607" LastActivityDate="2017-03-23T14:37:15.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11859" PostTypeId="1" CreationDate="2017-03-23T14:46:16.563" Score="1" ViewCount="542" Body="&lt;p&gt;I have these lines in top of .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;call pathogen#helptags()&#xA;filetype plugin indent on&#xA;syntax on&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I type &lt;code&gt;:help NERDTree&lt;/code&gt; I receive  &lt;code&gt;Sorry, help file &quot;/usr/share/vim/doc/help.txt&quot; not found&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;strong&gt;MobaXterm&lt;/strong&gt; on Windows.&#xA;I tried same &lt;code&gt;.vimrc&lt;/code&gt; file and &lt;code&gt;~./.vim&lt;/code&gt; folder structure on Linux and everything works fine.&lt;/p&gt;&#xA;" OwnerUserId="11457" LastEditorUserId="11457" LastEditDate="2017-03-24T10:02:23.923" LastActivityDate="2017-03-24T10:02:23.923" Title="Can't access documentation for pathogen plugins" Tags="|vimrc|plugin-pathogen|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11861" PostTypeId="1" AcceptedAnswerId="12051" CreationDate="2017-03-23T18:58:38.907" Score="3" ViewCount="205" Body="&lt;p&gt;The Vim documentation says the following under “quote_quote” about the unnamed register (&lt;code&gt;&quot;&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim fills this register with text deleted with the “d”, “c”, “s”, “x” commands or copied with the yank “y” command, regardless of whether or not a specific register was used (e.g.  &lt;code&gt;&quot;xdd&lt;/code&gt;). This is like the unnamed register is pointing to the last used register. Thus when appending using an uppercase register name, the unnamed register contains the same text as the named register.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, the part with uppercase register names does not work for me when deleting. I only get the last deleted text into the unnamed register. For example, when I enter &lt;code&gt;&quot;add&lt;/code&gt; and then &lt;code&gt;&quot;Add&lt;/code&gt;, register &lt;code&gt;a&lt;/code&gt; contains both deleted lines, but the unnamed register only contains the last one, although it should contain the same text as register &lt;code&gt;a&lt;/code&gt;. However, things work as expected with the yank (&lt;code&gt;y&lt;/code&gt;) command. Why is this?&lt;/p&gt;&#xA;" OwnerUserId="9846" LastEditorUserId="9846" LastEditDate="2017-03-23T19:08:54.357" LastActivityDate="2017-04-13T07:46:02.413" Title="Why does the unnamed register only contain the last deleted text when appending deleted text to a register?" Tags="|register|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11862" PostTypeId="2" ParentId="11859" CreationDate="2017-03-23T20:54:46.680" Score="1" Body="&lt;p&gt;Does &lt;code&gt;&quot;/usr/share/vim/doc/&quot;&lt;/code&gt; exist on your Windows system? Is Vim looking for a path that isn't there?&lt;/p&gt;&#xA;" OwnerUserId="4560" LastActivityDate="2017-03-23T20:54:46.680" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11863" PostTypeId="1" AcceptedAnswerId="11864" CreationDate="2017-03-23T21:06:26.180" Score="1" ViewCount="794" Body="&lt;p&gt;I'm working on a Python 3.6 project (with &lt;strong&gt;several friends&lt;/strong&gt; that are &lt;strong&gt;new to Unix&lt;/strong&gt;) using vim on a debian-based system I own. I'm wondering if there's a way I can setup a &lt;strong&gt;system-wide vim configuration using Vundle&lt;/strong&gt; so that we can all be on the same page and have the same tools available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can create &lt;code&gt;/etc/vim/vimrc.local&lt;/code&gt; in conjunction with installing plugins outside of my home directory and it will be sourced for all users, but for the future &lt;strong&gt;I'm curious of the ways I can make using this global configuration an &quot;opt-in&quot; process,&lt;/strong&gt; so that a user could choose whether to use the global vim setup or make their own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can think of a few ways to do this, but I wanted some input from others before I tunnel into one of my approaches. Ideally this would require as little as possible from the user-end, since most of the others are extremely new to Unix.&lt;/p&gt;&#xA;" OwnerUserId="11900" LastActivityDate="2017-03-23T22:07:02.823" Title="Setting up an opt-in system-wide vim config" Tags="|vimrc|plugin-system|plugin-vundle|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11864" PostTypeId="2" ParentId="11863" CreationDate="2017-03-23T22:07:02.823" Score="1" Body="&lt;p&gt;If you want to make it opt-in, do not use a config file that is searched for by Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The user should create a &lt;code&gt;.vimrc&lt;/code&gt; containing a single line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source /path_to_your_custom.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-23T22:07:02.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11865" PostTypeId="1" CreationDate="2017-03-24T02:17:30.850" Score="0" ViewCount="278" Body="&lt;p&gt;Syntax highlighting slowing my vim down.&#xA;I set  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax sync maxlines=100&#xA;syntax sync minlines=100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now i need to execute&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax off&#xA;:syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After every new file getting opened to save performance. How can i do it? May there is better solution?&lt;/p&gt;&#xA;" OwnerUserId="11904" LastActivityDate="2017-12-25T20:08:33.283" Title="How to execute multiple command on file open?" Tags="|vimrc|performance|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11866" PostTypeId="1" CreationDate="2017-03-24T07:26:12.847" Score="1" ViewCount="2650" Body="&lt;p&gt;I’m looking for comprehensive list of keys bindings for IdeaVim (vim emulator for PhpStorm and stuff like that). It looks like this plugin has lots of useful key binding which don’t exist in vim and aren’t standard.&#xA;I’ve this &lt;a href=&quot;http://ideavim.sourceforge.net/vim/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://ideavim.sourceforge.net/vim/index.html&lt;/a&gt; . However it’is 10 years old and yet this is exactly the place where I found useful staff which still works.&#xA;Is there anything more actual?&lt;/p&gt;&#xA;" OwnerUserId="11334" LastActivityDate="2017-09-03T17:56:25.000" Title="comprehensive list of keys bindings for IdeaVim (PhpStorm vim emulator)" Tags="|key-bindings|ide|" AnswerCount="1" CommentCount="4" ClosedDate="2017-09-03T17:58:21.353" ContentLicense="CC BY-SA 3.0" />
  <row Id="11867" PostTypeId="1" CreationDate="2017-03-24T12:26:45.857" Score="3" ViewCount="1032" Body="&lt;p&gt;I manually installed the &lt;a href=&quot;http://ethanschoonover.com/solarized&quot; rel=&quot;nofollow noreferrer&quot;&gt;Solarized&lt;/a&gt; colour scheme from the Vim-only &lt;a href=&quot;https://github.com/altercation/vim-colors-solarized&quot; rel=&quot;nofollow noreferrer&quot;&gt;repository&lt;/a&gt; and adjusted my ~/.vimrc as indicated in the documentation, including using &lt;code&gt;set background=dark&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GVim 7.4 (GTK3) under Kubuntu 16.04 correctly displays the dark solarized theme. However, changing the configuration to &lt;code&gt;set background=light&lt;/code&gt; as detailed in the documentation results in the same dark color scheme after calling &lt;code&gt;colourscheme solarized&lt;/code&gt; again or after restarting Vim with the new configuation. How do I use the light theme in GVim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I installed G/Vim (GTK3) 8.0 from the git source. It, too, does not display the light theme.&lt;/p&gt;&#xA;" OwnerUserId="2932" LastEditorUserId="2932" LastEditDate="2017-03-24T18:08:29.913" LastActivityDate="2019-12-11T04:04:35.490" Title="No Solarized Light in GVim (GTK3)" Tags="|gvim|colorscheme|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11869" PostTypeId="1" AcceptedAnswerId="11875" CreationDate="2017-03-24T13:17:04.780" Score="0" ViewCount="463" Body="&lt;p&gt;I'm trying to understand why my ftplugin isn't loaded. To get at least some understanding what's going on, I've tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strace -e file gvim test.cpp |&amp;amp; grep ftplugin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this gave me empty output, although &lt;code&gt;:set ft&lt;/code&gt; says &lt;code&gt;cpp&lt;/code&gt;. I do have lots of files in &lt;code&gt;/usr/share/vim/vim74/ftplugin&lt;/code&gt;, and &lt;code&gt;cpp.vim&lt;/code&gt; is among them. My &lt;code&gt;$VIMRUNTIME&lt;/code&gt; is &lt;code&gt;/usr/share/vim/vim74&lt;/code&gt;. So apparently Vim doesn't even try to load any &lt;code&gt;ftplugin&lt;/code&gt;, although it does load e.g. &lt;code&gt;tarPlugin.vim&lt;/code&gt; and others in the &lt;code&gt;plugin&lt;/code&gt; directory (not &lt;code&gt;ftplugin&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be wrong in my config that would make Vim not even consider any &lt;code&gt;ftplugin&lt;/code&gt;s?&lt;/p&gt;&#xA;" OwnerUserId="1081" LastActivityDate="2017-03-24T18:06:34.263" Title="Why are ftplugins ignored?" Tags="|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11871" PostTypeId="1" AcceptedAnswerId="11877" CreationDate="2017-03-24T15:51:25.670" Score="5" ViewCount="1080" Body="&lt;p&gt;I'm writing a VimL function that needs to behave differently for different filetypes. I know I can use &lt;code&gt;&amp;amp;filetype&lt;/code&gt; to detect that, but my issue is with files that have embedded languages. Let's say I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&#xA;&amp;lt;head&amp;gt;&#xA;  &amp;lt;style&amp;gt;&#xA;    div {&#xA;      text-color: red;&#xA;    }&#xA;  &amp;lt;/style&amp;gt;&#xA;&amp;lt;/head&amp;gt;&#xA;&amp;lt;body&amp;gt;&#xA;  &amp;lt;div&amp;gt;Some text&amp;lt;/div&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the cursor is inside the style tag, I want to know that I'm dealing with CSS. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="11911" LastActivityDate="2017-03-24T20:45:37.193" Title="Identify syntax region under cursor" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11872" PostTypeId="1" CreationDate="2017-03-24T16:58:45.903" Score="8" ViewCount="4124" Body="&lt;p&gt;I'd like to learn about using vim with multiple files without using external plugins.&lt;/p&gt;&#xA;&lt;p&gt;I read &lt;a href=&quot;https://stackoverflow.com/a/13043196/2909897&quot;&gt;another answer&lt;/a&gt; that recommends putting the following in our &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set wildmenu&#xA;set wildmode=longest:full,full&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now when I use &lt;code&gt;:e &amp;lt;Tab&amp;gt;&lt;/code&gt; I get the following output:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hUXZv.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hUXZv.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this case, there is a file at &lt;code&gt;some/path/to/bar.rb&lt;/code&gt; but vim is only showing me &lt;code&gt;some/&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Some questions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;From reading the &lt;a href=&quot;https://stackoverflow.com/a/13043196/2909897&quot;&gt;linked answer&lt;/a&gt; I thought the list was supposed to be vertical. Why is it still horizontal?&lt;/li&gt;&#xA;&lt;li&gt;Is it possible for &lt;code&gt;wildmenu&lt;/code&gt; to show the full path to &lt;code&gt;some/path/to/bar.rb&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Does my &lt;code&gt;vim .&lt;/code&gt; followed by &lt;code&gt;:e &amp;lt;Tab&amp;gt;&lt;/code&gt; pattern make sense? Is there a better way?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11605" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2023-01-11T13:12:14.407" Title="How do I use wildmenu effectively?" Tags="|multiple-files|wildmenu|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11873" PostTypeId="1" AcceptedAnswerId="11874" CreationDate="2017-03-24T17:26:18.647" Score="2" ViewCount="346" Body="&lt;p&gt;How to delete wrapped lines?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I imagined something like &lt;code&gt;gdd&lt;/code&gt; and &lt;code&gt;gD&lt;/code&gt; but they did not work as expected, in a similar fashion to &lt;code&gt;gj&lt;/code&gt; and &lt;code&gt;gk&lt;/code&gt; to move through wrapped lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be really useful to have a way to delete multi-lined wraps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;U&lt;/kbd&gt; in Insert Mode, doesn't help with that as well.&lt;/p&gt;&#xA;" OwnerDisplayName="user10767" LastEditorDisplayName="user10767" LastEditDate="2017-03-24T17:41:04.493" LastActivityDate="2017-03-24T18:00:01.250" Title="Delete wrapped lines?" Tags="|key-bindings|cut-copy-paste|wrapping|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11874" PostTypeId="2" ParentId="11873" CreationDate="2017-03-24T17:44:03.257" Score="2" Body="&lt;p&gt;AFAIK there's no default mapping for this. You could make one for yourself though. I would be careful about mapping &lt;code&gt;gdd&lt;/code&gt; or &lt;code&gt;gD&lt;/code&gt; because &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#gd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;gd&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#gD&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;gD&lt;/code&gt;&lt;/a&gt; already have functions that are really useful. I'm going to use &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;d&lt;/kbd&gt; just as a suggestion.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;A-d&amp;gt; g^dg$g^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-03-24T18:00:01.250" LastActivityDate="2017-03-24T18:00:01.250" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11875" PostTypeId="2" ParentId="11869" CreationDate="2017-03-24T18:06:34.263" Score="1" Body="&lt;p&gt;1) If you want to strace gvim, you need to make sure, that it does not fork.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) filetype plugins are only loaded if your .vimrc contains a line like &lt;code&gt;filetype plugin indent on&lt;/code&gt; (with or without indent, depending if you want indent plugins to be loaded as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the help at &lt;code&gt;:h filetype-plugin-on&lt;/code&gt; and the following paragraphs.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-03-24T18:06:34.263" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11876" PostTypeId="2" ParentId="11794" CreationDate="2017-03-24T18:18:07.640" Score="1" Body="&lt;p&gt;I just use &lt;a href=&quot;https://github.com/plasticboy/vim-markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-markdown&lt;/code&gt;&lt;/a&gt;. I have &lt;code&gt;vim-orgmode&lt;/code&gt; just for &lt;code&gt;.org&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And there is also &lt;a href=&quot;https://github.com/pelodelfuego/vim-swoop&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-swoop&lt;/a&gt; which maps &lt;kbd&gt;Leader&lt;/kbd&gt;+&lt;kbd&gt;l&lt;/kbd&gt; to &lt;strong&gt;l&lt;/strong&gt;ook up strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Spacemacs, has &lt;kbd&gt;SPC&lt;/kbd&gt;-&lt;kbd&gt;s&lt;/kbd&gt;-&lt;kbd&gt;s&lt;/kbd&gt; for &lt;code&gt;helm-swoop&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user10767" LastActivityDate="2017-03-24T18:18:07.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11877" PostTypeId="2" ParentId="11871" CreationDate="2017-03-24T20:45:37.193" Score="5" Body="&lt;p&gt;&lt;code&gt;synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 0), &quot;name&quot;)&lt;/code&gt; will return &lt;code&gt;css*&lt;/code&gt; (like &lt;code&gt;cssStyle&lt;/code&gt; or &lt;code&gt;cssDefinition&lt;/code&gt;) inside the style tag.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-24T20:45:37.193" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11878" PostTypeId="1" AcceptedAnswerId="11882" CreationDate="2017-03-24T23:18:36.013" Score="0" ViewCount="945" Body="&lt;p&gt;I have been using vim for a while on Arch Linux and decided to make a shift to Neovim. It's mostly working fine. The vimrc is sourced and thus all my configuration files and plugins are working fine, but neovim is not sourcing my ftplugin files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a screen shot of relevant info about neovim on my system:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://postimg.org/image/9zajtvidr/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://s19.postimg.org/v8y64pyoj/nvim.png&quot; alt=&quot;nvim.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ftplugins were working fine in regular vim - I have them in &lt;code&gt;~/.vim/after/ftplugin/&lt;/code&gt; but the custom keybindings and abbreviations I have in my filetype files (such as python.vim) are just not being sourced.&lt;/p&gt;&#xA;" OwnerUserId="10879" LastActivityDate="2017-03-25T04:27:54.077" Title="NeoVim ftplugins Not working - Arch Linux" Tags="|neovim|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11879" PostTypeId="1" AcceptedAnswerId="11881" CreationDate="2017-03-25T03:22:37.460" Score="20" ViewCount="16829" Body="&lt;p&gt;All the vim related files installed on /usr/share/vim/vim74.   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /home/debian8/&#xA;ls  .vim*&#xA;.viminfo  .vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To create .vim directory to install  some plugin for customization.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir  .vim&#xA;mkdir  .vim/plugin&#xA;mkdir  .vim/autoload&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If .viminfo and .vimrc are moved into .vim directory directly, then the configuration for vim can't be read.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can .vimrc and viminfo be relocated into the .vim directory?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="14302" LastEditDate="2019-05-23T22:46:04.980" LastActivityDate="2024-02-13T20:59:53.090" Title="How can put .vimrc and viminfo into .vim directory?" Tags="|vimrc|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11880" PostTypeId="2" ParentId="11746" CreationDate="2017-03-25T03:25:18.043" Score="0" Body="&lt;pre&gt;&lt;code&gt;mkdir -p ~/.vim/autoload ~/.vim/bundle &amp;amp;&amp;amp; \&#xA;curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;copy &lt;a href=&quot;https://github.com/emmetio/emmet/blob/master/lib/snippets.json&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/emmetio/emmet/blob/master/lib/snippets.json&lt;/a&gt; into ~./vim/snippets.json&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim .vimrc&#xA;let g:user_emmet_settings = webapi#json#decode(join(readfile(expand('~/.vim/snippets.json')), &quot;\n&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5181" LastActivityDate="2017-03-25T03:25:18.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11881" PostTypeId="2" ParentId="11879" CreationDate="2017-03-25T04:08:46.260" Score="11" Body="&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; @Rich's answer is more correct, but this is still a valid way to set a &quot;default&quot; arbitrary path for &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way to have a custom &lt;code&gt;vimrc&lt;/code&gt; location is to use the &lt;code&gt;VIMINIT&lt;/code&gt; environment variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export VIMINIT=&quot;source ~/.vim/vimrc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h VIMINIT&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's ignored when using &lt;code&gt;vim -u ~/some/other/vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for &lt;code&gt;viminfo&lt;/code&gt;, you need to add this to your &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viminfo+=n~/.vim/viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h 'viminfo'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="1841" LastEditDate="2017-11-28T19:34:21.153" LastActivityDate="2017-11-28T19:34:21.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11882" PostTypeId="2" ParentId="11878" CreationDate="2017-03-25T04:27:54.077" Score="3" Body="&lt;p&gt;&lt;code&gt;$HOME/.config/nvim&lt;/code&gt; is a &lt;code&gt;'runtimepath'&lt;/code&gt; in Neovim.  &lt;code&gt;$HOME/.vim&lt;/code&gt; is a &lt;code&gt;'runtimepath'&lt;/code&gt; in Vim.  You're making the mistake of thinking that their relative location to the &lt;code&gt;init.vim&lt;/code&gt; or &lt;code&gt;.vimrc&lt;/code&gt; matters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what you should do if you want the configs to work for Vim and Neovim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mv ~/.vim ~/.config/nvim&#xA;mv ~/.vimrc ~/.config/nvim/init.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, you should reconcile your files/links before doing the above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then create a new &lt;code&gt;~/.vimrc&lt;/code&gt; file and add this to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;rtp = '~/.config/nvim,'.&amp;amp;rtp&#xA;source ~/.config/nvim/init.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This turns &lt;code&gt;~/.vimrc&lt;/code&gt; into a shim for loading configs from &lt;code&gt;~/.config/nvim&lt;/code&gt;.  The bonus is that you have one less directory in your home.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The opposite can be done in &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;rtp = '~/.vim,'.&amp;amp;rtp&#xA;source ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also just use symlnks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ln -s ~/.vimrc ~/.vim/init.vim&#xA;ln -s ~/.vim ~/.config/nvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think using a shim script is cleaner, though.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-03-25T04:27:54.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11883" PostTypeId="1" CreationDate="2017-03-25T10:20:26.487" Score="2" ViewCount="252" Body="&lt;p&gt;I am confused about what is going on in this example and why spell checking is not working any help is appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While editing a markdown file with spell checking enabled the following happens:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* This line is spellchecked&#xA;    - This line is also spellchecked&#xA;        - This line is not spellchecked&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also noticed that this also doesn't work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* This line is really long but spellchecked&#xA;    continuation of text after linewrap from the previous line, this line is not spellchecked&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Indentation is 1 tab character per level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google has turned up nothing but since the &lt;code&gt;-&lt;/code&gt; is not bold on the third bullet as the rest are I assume this is some kind of markdown spec violation but I am not sure which. Is there a way to make this work?&lt;/p&gt;&#xA;" OwnerUserId="11918" LastEditorUserId="11918" LastEditDate="2017-03-25T10:26:03.147" LastActivityDate="2018-12-21T09:28:54.773" Title="markdown spell checking with triple nested bullet point" Tags="|spell-checking|filetype-markdown|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11885" PostTypeId="2" ParentId="11867" CreationDate="2017-03-25T13:37:32.283" Score="1" Body="&lt;p&gt;This is what works for me (GVim 7.4, Ubuntu 16.04.2):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;~/.vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=dark&#xA;set t_Co=16              &quot; fix for bg being too bright&#xA;colorscheme solarized&#xA;&#xA;&quot; gvim specific settings here                       &#xA;if has('gui_running')&#xA;    set background=light&#xA;    set guioptions-=T    &quot; no toolbar&#xA;    set linespace=5      &quot; to show underscores not as space&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11746" LastActivityDate="2017-03-25T13:37:32.283" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11886" PostTypeId="2" ParentId="11795" CreationDate="2017-03-25T18:28:21.663" Score="2" Body="&lt;h1&gt;Airline&lt;/h1&gt;&#xA;&lt;p&gt;This question relates more to the &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-airline&lt;/a&gt; plugin than to vim itself. I only mention that because it is easier to answer a question that is well-defined :P.&lt;/p&gt;&#xA;&lt;p&gt;The vim-airline docs describe &lt;a href=&quot;https://github.com/vim-airline/vim-airline/blob/master/doc/airline.txt#L642&quot; rel=&quot;nofollow noreferrer&quot;&gt;how to format buffer names&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h1&gt;Step by Step&lt;/h1&gt;&#xA;&lt;p&gt;Basically create a file named&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;vim-airline directory&amp;gt;/autoload/airline/extensions/tabline/formatters/foo.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;that contains the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! airline#extensions#tabline#formatters#foo#format(bufnr, buffers)&#xA;    return bufname(a:bufnr)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The function above would return the full file path I believe, but you can modify it to return any string you want. Once that is done, add this next line to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline#extensions#tabline#formatter = 'foo'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And you should be good to go from there.&lt;/p&gt;&#xA;" OwnerUserId="11189" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-03-26T03:28:14.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11887" PostTypeId="1" AcceptedAnswerId="11889" CreationDate="2017-03-26T00:07:09.670" Score="8" ViewCount="8645" Body="&lt;p&gt;In &lt;code&gt;vi&lt;/code&gt;/&lt;code&gt;vim&lt;/code&gt; I can throw &lt;code&gt;set list&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; file to show newline characters as &lt;code&gt;$&lt;/code&gt; which is very useful for my development needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though the same command in &lt;code&gt;neovim&lt;/code&gt; shows only &lt;code&gt;-&lt;/code&gt; for trailing spaces while newlines are still invisible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to show newline characters in &lt;code&gt;neovim&lt;/code&gt; as it's in &lt;code&gt;vi&lt;/code&gt;/&lt;code&gt;vim&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10540" LastActivityDate="2017-03-26T07:01:40.760" Title="Show newline characters in neovim" Tags="|vimrc|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11889" PostTypeId="2" ParentId="11887" CreationDate="2017-03-26T07:01:40.760" Score="7" Body="&lt;p&gt;Ok, so after looking up a documentation and a good portion of time figuring out how to make it work properly I found the solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I run &lt;code&gt;help 'list'&lt;/code&gt; from inside &lt;code&gt;neovim&lt;/code&gt; and found out that by default newline characters are not shown in &lt;code&gt;neovim&lt;/code&gt;s &lt;code&gt;list&lt;/code&gt; mode. To show them (as well as other characters you want) the following command can be used:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set list listchars=tab:&amp;gt;\ ,trail:-,eol:$&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice the backslash &lt;code&gt;\&lt;/code&gt; above as it's necessary to add it to include spaces in a particular character representation (like &lt;code&gt;tab&lt;/code&gt; character that would be shown as &lt;code&gt;&amp;gt;&lt;/code&gt; plus spaces). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For additional information you can read docs with &lt;code&gt;help 'listchars'&lt;/code&gt; from inside &lt;code&gt;neovim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10540" LastActivityDate="2017-03-26T07:01:40.760" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11890" PostTypeId="1" CreationDate="2017-03-26T21:01:34.647" Score="1" ViewCount="1146" Body="&lt;p&gt;I’m writing a syntax file for &lt;a href=&quot;https://github.com/sstephenson/bats&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bats&lt;/a&gt;.  I started my syntax file by loading the bash syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:is_bash=1&#xA;runtime! syntax/sh.vim&#xA;unlet b:current_syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then defined the Bats custom keywords:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match batsTestKeyword &quot;\v\@test&quot;&#xA;syntax keyword batsFunction load setup teardown run skip assert_success assert_failure assert_output&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, I’m trying to create a region that contains both the Bash syntax and the &lt;code&gt;batsFunction&lt;/code&gt; keywords:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region batsTestBlock start='{' end='}' contains=@bash, batsFunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However when looking at a &lt;a href=&quot;https://gist.github.com/aliou/3a27c3c736c7c0be7896498cc0459a79&quot; rel=&quot;nofollow noreferrer&quot;&gt;test file&lt;/a&gt; only the Bash syntax is highlighted and not my custom syntax. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea why my custom syntax is not included in the region?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: The keyword are linked as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight default link batsTestKeyword  Identifier&#xA;highlight default link batsFunction Function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="699" LastActivityDate="2017-04-06T18:30:04.187" Title="Adding multiple syntax group to a syntax region" Tags="|vimscript|syntax-highlighting|filetype|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11891" PostTypeId="1" AcceptedAnswerId="11898" CreationDate="2017-03-26T21:21:56.380" Score="2" ViewCount="2634" Body="&lt;p&gt;I have tried &lt;strong&gt;many&lt;/strong&gt; of the available online instructions on remapping my &lt;strong&gt;&lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;&lt;/strong&gt; key in my &lt;code&gt;vimrc&lt;/code&gt; file but none of them have any effect.  If I run &lt;code&gt;:map! &amp;lt;Tab&amp;gt; ᐅ&lt;/code&gt; directly from command entry it'll work, but not from &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;:verbose imap &amp;lt;Tab&amp;gt;&lt;/code&gt; I get the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i  &amp;lt;Tab&amp;gt;       * pumvisible() ? &quot;\&amp;lt;C-N&amp;gt;&quot; : &quot;\&amp;lt;Tab&amp;gt;&quot;&#xA;    Last set from ~/.vim/bundle/YouCompleteMe/autoload/youcompleteme.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Looking at the source code for YouCompleteMe I see a variable of &lt;code&gt;key&lt;/code&gt; is present which is mapped to &lt;strong&gt;&lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;&lt;/strong&gt; if it's not in completion mode.  &lt;strong&gt;How can I set what the &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; key is when not in completion mode for YouCompleteMe?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="11929" LastActivityDate="2017-03-27T19:56:55.310" Title="Alternative mapping for &lt;Tab&gt; key via YouCompleteMe" Tags="|key-bindings|plugin-you-complete-me|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11892" PostTypeId="1" AcceptedAnswerId="11900" CreationDate="2017-03-27T10:00:13.427" Score="5" ViewCount="4183" Body="&lt;p&gt;I've followed &lt;a href=&quot;https://csswizardry.com/2017/03/configuring-git-and-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt; to set up a nice git-commit-template and use it with Vim.&#xA;I would like to put this one step further and make possible to have in my template a preconfigured variable with my current branch name, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is my commit title [branch ${MY_BRANCH}]&#xA;&#xA;Commit Body&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is that possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="1765" LastEditorUserId="205" LastEditDate="2020-08-13T08:15:53.570" LastActivityDate="2020-08-13T08:15:53.570" Title="Populate a git-commit-template with variables" Tags="|git|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11893" PostTypeId="1" AcceptedAnswerId="11929" CreationDate="2017-03-27T10:23:01.840" Score="0" ViewCount="2319" Body="&lt;p&gt;&lt;code&gt;&amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; is working as (I'd) exepected, but not from a Vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to make a script that will:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;open Neovim's &lt;code&gt;:terminal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;run a python script&lt;/li&gt;&#xA;&lt;li&gt;exit from the terminal input mode&lt;/li&gt;&#xA;&lt;li&gt;manipulate the terminal buffer just as text&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I already do that manually everyday. That's why the script would help. (:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I can't find a way to give the &lt;code&gt;&amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; to the terminal buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the most 'consistent piece' achieved so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AFunction(...)&#xA;&#xA;let firstArg=a:0&#xA;let secondArg=a:1&#xA;let thirdArg=a:2&#xA;let fourthArg=a:3&#xA;let fifthArg=a:4&#xA;&#xA;command! -nargs=* AFunctionCommand call Fetching(&amp;lt;f-args&amp;gt;) &#xA;execute &quot;:terminal python a-python-script.py&quot; a:1 a:2 a:3 a:4&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does work, but I can't find a way to pass the exit key.&#xA;The first idea was to concatenate the strings, as &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/31.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;mentioned here&lt;/a&gt;. Perhaps something that would allow to stablish where is the &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; (after the arguments):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;:terminal python a-python-script.py&quot; a:1 a:2 a:3 a:4 &quot;\&amp;lt;cr&amp;gt;&quot; . '&amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If try to do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;:terminal python a-python-script.py&quot; a:1 a:2 a:3 a:4&#xA;&amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't work since terminal has 'nomodifiable' by the default. The same if trying to call a function with the escape keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, it is a horrible Vimscript art, and any comment on the code would be really appreciated, but since this is not Code Review, I would be happy with just the reason why  doesn't work, or where is my logic not working. (:&lt;/p&gt;&#xA;" OwnerUserId="10493" LastActivityDate="2017-03-30T12:01:50.160" Title="Exiting back to normal mode in terminal buffer from Vimscript" Tags="|vimscript|neovim|functions|escape|argument-list|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11894" PostTypeId="2" ParentId="5753" CreationDate="2017-03-27T11:29:30.530" Score="1" Body="&lt;p&gt;You want &lt;code&gt;normal!&lt;/code&gt; so you don't call your own mapping recursively:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm[al][!] {commands}                                 :norm :normal&#xA;                        Execute Normal mode commands {commands}.  This makes&#xA;                        it possible to execute Normal mode commands typed on&#xA;                        the command-line.  {commands} are executed like they&#xA;                        are typed.  For undo all commands are undone together.&#xA;                        Execution stops when an error is encountered.&#xA;&#xA;                        If the [!] is given, mappings will not be used.&#xA;                        Without it, when this command is called from a&#xA;                        non-remappable mapping (:noremap), the argument can&#xA;                        be mapped anyway.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So your function should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyScroll(key)&#xA;   exe 'normal!' a:key&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-27T11:29:30.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11895" PostTypeId="2" ParentId="5753" CreationDate="2017-03-27T13:18:49.167" Score="4" Body="&lt;p&gt;This is what you want to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;expr&amp;gt; &amp;lt;c-e&amp;gt; &amp;amp;buftype !=# 'terminal' ? &quot;\&amp;lt;c-e&amp;gt;&quot; : ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make this more convenient:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:terminal_ignore(key, ...) abort&#xA;  execute printf('nmap &amp;lt;expr&amp;gt; %s &amp;amp;buftype !=# &quot;terminal&quot; ? &quot;%s&quot; : &quot;%s&quot;',&#xA;        \ a:key, a:key, a:0 ? a:1 : '')&#xA;endfunction&#xA;&#xA;call s:terminal_ignore(&quot;\&amp;lt;c-e&amp;gt;&quot;)&#xA;call s:terminal_ignore(&quot;\&amp;lt;c-y&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses &lt;code&gt;:h map-&amp;lt;expr&amp;gt;&lt;/code&gt; to check &lt;code&gt;&amp;amp;buftype&lt;/code&gt;.  If it's &lt;code&gt;terminal&lt;/code&gt;, return an empty string, which is noop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few things to note:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is compatible with Vim.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nmap&lt;/code&gt; is used instead of &lt;code&gt;nnoremap&lt;/code&gt;.  It doesn't matter in the above script since it's returning the same key for non-terminal buffers. However, if you decide that the expression should return something else for the terminal, you will want it to be recursive.&lt;/li&gt;&#xA;&lt;li&gt;The returned string &lt;em&gt;must&lt;/em&gt; be a constant string (&lt;code&gt;:h expr-quote&lt;/code&gt;).  &lt;code&gt;&quot;\&amp;lt;c-e&amp;gt;&quot;&lt;/code&gt; is &lt;kbd&gt;CTRL-E&lt;/kbd&gt;/&lt;code&gt;^E&lt;/code&gt;, &lt;code&gt;'&amp;lt;c-e&amp;gt;'&lt;/code&gt; is literally &lt;code&gt;&amp;lt;c-e&amp;gt;&lt;/code&gt;.  In the &lt;code&gt;s:terminal_ignore()&lt;/code&gt; function, the constant string &lt;code&gt;&quot;\&amp;lt;c-e&amp;gt;&quot;&lt;/code&gt; is passed so that it can be used in &lt;code&gt;{lhs}&lt;/code&gt; and &lt;code&gt;{rhs}&lt;/code&gt;.  Only &lt;code&gt;{lhs}&lt;/code&gt; will evaluate &lt;code&gt;&amp;lt;c-e&amp;gt;&lt;/code&gt; as &lt;kbd&gt;CTRL-E&lt;/kbd&gt;, but it works fine with a constant string.  &lt;code&gt;{rhs}&lt;/code&gt; is used literally.&lt;/li&gt;&#xA;&lt;li&gt;You can pass an optional second argument that will be used if the current buffer is a terminal.  e.g. &lt;code&gt;call s:terminal_ignore(&quot;\&amp;lt;c-e&amp;gt;&quot;, &quot;A&amp;lt;c-e&amp;gt;&quot;)&lt;/code&gt; to put the terminal back into insert mode and type &lt;kbd&gt;CTRL-E&lt;/kbd&gt;.&lt;/li&gt;&#xA;&lt;li&gt;I'm using &lt;code&gt;&amp;lt;c-e&amp;gt;&lt;/code&gt; instead of the literal &lt;code&gt;^E&lt;/code&gt; because I want my scripts to be legible in non-vim programs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2017-03-27T13:24:05.560" LastActivityDate="2017-03-27T13:24:05.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11898" PostTypeId="2" ParentId="11891" CreationDate="2017-03-27T19:49:38.940" Score="2" Body="&lt;p&gt;Credit to: &lt;a href=&quot;https://github.com/micbou&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/micbou&lt;/a&gt; — &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/issues/2587#issuecomment-289555540&quot; rel=&quot;nofollow noreferrer&quot;&gt;answer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If what you want is inserting the ᐅ symbol when the completion menu is not visible, adding these lines to your vimrc should do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Remove &amp;lt;Tab&amp;gt; from the list of keys mapped by YCM.&#xA;let g:ycm_key_list_select_completion = ['&amp;lt;Down&amp;gt;']&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;ᐅ&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11929" LastEditorUserId="11929" LastEditDate="2017-03-27T19:56:55.310" LastActivityDate="2017-03-27T19:56:55.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11900" PostTypeId="2" ParentId="11892" CreationDate="2017-03-28T01:28:58.037" Score="8" Body="&lt;p&gt;It's possible with some scripting.  When editing a commit message, a temporary file &lt;code&gt;.git/COMMIT_EDITMSG&lt;/code&gt; is created with the contents of the &lt;code&gt;commit.template&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;autocmd&lt;/code&gt; we can execute a script that changes the content of the buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:expand_commit_template() abort&#xA;  let context = {&#xA;        \ 'MY_BRANCH': matchstr(system('git rev-parse --abbrev-ref HEAD'), '\p\+'),&#xA;        \ 'AUTHOR': 'Tommy A',&#xA;        \ }&#xA;&#xA;  let lnum = nextnonblank(1)&#xA;  while lnum &amp;amp;&amp;amp; lnum &amp;lt; line('$')&#xA;    call setline(lnum, substitute(getline(lnum), '\${\(\w\+\)}',&#xA;          \ '\=get(context, submatch(1), submatch(0))', 'g'))&#xA;    let lnum = nextnonblank(lnum + 1)&#xA;  endwhile&#xA;endfunction&#xA;&#xA;autocmd BufRead */.git/COMMIT_EDITMSG call s:expand_commit_template()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For filling the template, we use a &lt;code&gt;context&lt;/code&gt; dict that defines expandable placeholders.  For &lt;code&gt;MY_BRANCH&lt;/code&gt;, we get the current branch and use &lt;code&gt;matchstr()&lt;/code&gt; to get the first set of printable characters (otherwise, newline will be included as &lt;code&gt;^@&lt;/code&gt;).  I also included &lt;code&gt;AUTHOR&lt;/code&gt; to demonstrate that this can expand more than one placeholder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The lines are scanned for text &lt;em&gt;between&lt;/em&gt; &lt;code&gt;${&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;.  When found, the captured text in &lt;code&gt;submatch(1)&lt;/code&gt; is used as a key to get a value from &lt;code&gt;context&lt;/code&gt; to use as the substitution.  If the key doesn't exist in &lt;code&gt;context&lt;/code&gt;, the fully matched text in &lt;code&gt;submatch(0)&lt;/code&gt; is returned effectively &quot;ignoring&quot; the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the &lt;code&gt;context&lt;/code&gt; being &lt;code&gt;{'MY_BRANCH': 'master', 'AUTHOR': 'Tommy A'}&lt;/code&gt; and given the template:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is my commit title [branch ${MY_BRANCH}]&#xA;&#xA;Commit Body ${NON_EXISTENT}&#xA;&#xA;- ${AUTHOR}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;git commit&lt;/code&gt; will display a buffer with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is my commit title [branch master]&#xA;&#xA;Commit Body ${NON_EXISTENT}&#xA;&#xA;- Tommy A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will work with &lt;code&gt;git commit&lt;/code&gt; and &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;noreferrer&quot;&gt;vim-fugitive&lt;/a&gt;'s &lt;code&gt;:Gcommit&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-03-28T01:28:58.037" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11901" PostTypeId="1" AcceptedAnswerId="11919" CreationDate="2017-03-28T09:10:34.440" Score="8" ViewCount="2452" Body="&lt;p&gt;A lot of times, I end up accidentally closing a file with &lt;code&gt;:wq&lt;/code&gt; when I only want to do &lt;code&gt;:w&lt;/code&gt;. Since I work with multiple tabs and windows, the buffer is still there and I can open it with &lt;code&gt;:ls&lt;/code&gt; followed by &lt;code&gt;:b &amp;lt;number&amp;gt;&lt;/code&gt;. However, my previous changes are lost and I cannot undo anymore. Is there any way to set up vim so that it remembers the undo tree of unclosed buffers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that is not possible, a way to make vim confirm before quitting on &lt;code&gt;:wq&lt;/code&gt; is also OK.&lt;/p&gt;&#xA;" OwnerUserId="11951" LastActivityDate="2017-03-29T14:15:10.390" Title="Any way to retrieve lost undo tree after closing window (but buffer is still open)" Tags="|undo-redo|quit|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11902" PostTypeId="2" ParentId="11901" CreationDate="2017-03-28T09:51:12.980" Score="11" Body="&lt;p&gt;You can set a persistent undo with the following settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set undodir=~/.vim/undodir&#xA;set undofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is avaible in Vim 7.3 an above&lt;/p&gt;&#xA;" OwnerUserId="11316" LastActivityDate="2017-03-28T09:51:12.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11903" PostTypeId="1" CreationDate="2017-03-28T10:16:13.430" Score="2" ViewCount="1386" Body="&lt;p&gt;I saw something strange happen today.&#xA;I was in directory &lt;code&gt;/some/path/&lt;/code&gt; and opened a file with &lt;code&gt;vim file.html&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then did :pwd in vim and it gave me &lt;code&gt;/some/other/path&lt;/code&gt;. What could cause this to happen?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: &lt;code&gt;:verbose set autochdir?&lt;/code&gt; outputs &lt;code&gt;noautochdir&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT2: putting &lt;code&gt;set autochdir&lt;/code&gt; in &lt;code&gt;~/.vimrc&lt;/code&gt; doesn't solve it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;cd /dir1/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vim dir2/newfile&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:pwd&lt;/code&gt; -&gt; &lt;code&gt;/dir1/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cd /dir1/dir2/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vim newfile&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:pwd&lt;/code&gt; -&gt; &lt;code&gt;/dir1/dir2/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is the behavious I expect (&lt;code&gt;:pwd&lt;/code&gt; returning the directory in which I launched vim) so I don't understand why for one particular file it doesn't work like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;del&gt;I figured it must be somehow caused by&lt;/del&gt; It is definitely caused by these &lt;a href=&quot;http://vim.wikia.com/wiki/Make_views_automatic&quot; rel=&quot;nofollow noreferrer&quot;&gt;lines&lt;/a&gt; in &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWinLeave * mkview&#xA;autocmd BufWinEnter * silent loadview&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I deleted my &lt;code&gt;~/.vimrc&lt;/code&gt; and &lt;code&gt;:pwd&lt;/code&gt; returned the correct directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After I restored it, the situation reverted to the original problem.&#xA;I still don't understand how it happenned, I can't recreate the issue.&lt;/p&gt;&#xA;" OwnerUserId="11953" LastEditorUserId="11953" LastEditDate="2017-03-28T14:53:45.373" LastActivityDate="2020-01-27T23:08:58.843" Title="Working directory different than current file directory?" Tags="|working-directory|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11904" PostTypeId="2" ParentId="11903" CreationDate="2017-03-28T14:29:55.597" Score="2" Body="&lt;p&gt;In your &lt;code&gt;vimrc&lt;/code&gt; put &lt;code&gt;set autochdir&lt;/code&gt; and your path will always follow your current file. Otherwise vim will usually stay in either your home directory or in the first file you edited without you explicitly telling it to change with &lt;code&gt;cd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27autochdir%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'autochdir'&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-03-28T14:29:55.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11905" PostTypeId="2" ParentId="122" CreationDate="2017-03-28T18:29:17.327" Score="0" Body="&lt;h3&gt;Plugin ReplaceWithRegister&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2703&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.vim.org/scripts/script.php?script_id=2703&lt;/a&gt; (2009-2014)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It suggests the mapping &lt;code&gt;gr&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;yank&lt;/li&gt;&#xA;&lt;li&gt;visually select the text you want to replace and press &lt;code&gt;gr&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;move to next block you want to replace&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Alternatively, use &lt;code&gt;gr&amp;lt;text object&amp;gt;&lt;/code&gt; to do it without a visual selection.&#xA;dot-repeat is supported when the plugins &lt;code&gt;repeat.vim&lt;/code&gt; by Tim Pope and &lt;code&gt;visualrepeat.vim&lt;/code&gt; by Ingo Karkat are installed.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2017-03-28T18:29:17.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11906" PostTypeId="2" ParentId="343" CreationDate="2017-03-28T21:27:01.067" Score="13" Body="&lt;h1&gt;TL;DR Answer&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Open the file with Vim in binary mode:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -b &amp;lt;file_to_edit&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Vim, get into hex editing mode like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!xxd -p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To save:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!xxd -p -r&#xA;:w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first line will convert the buffer back from hex mode and the second line will save the file like normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;-p&lt;/code&gt; option. This avoids all the extra printable and address fluff and just shows you the hex. Just omit &lt;code&gt;-p&lt;/code&gt; if you want the extra context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be careful opening the file with Vim not in binary mode, as it will append a (usually unintended) LF character to the end of the file when you save it.&lt;/p&gt;&#xA;" OwnerUserId="11962" LastEditorUserId="11962" LastEditDate="2020-02-23T23:44:48.350" LastActivityDate="2020-02-23T23:44:48.350" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="11908" PostTypeId="1" AcceptedAnswerId="11927" CreationDate="2017-03-29T06:28:01.060" Score="0" ViewCount="938" Body="&lt;p&gt;I have the following lines in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * NERDTree&#xA;autocmd VimEnter * wincmd p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a result the nerdtree plugin always opens when I load vim. How can I change the behaviour to load nerdtree iff vim is invoked from a particular directory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, when open &lt;code&gt;$ vim file.py&lt;/code&gt; from inside &lt;code&gt;~/workspace/something/&lt;/code&gt; the loaded &lt;code&gt;vim&lt;/code&gt; must load with nerdtree as I want any instance of vim involked from inside &lt;code&gt;~/workspace&lt;/code&gt; to have nerdtree loaded by default.&lt;/p&gt;&#xA;" OwnerUserId="11044" LastActivityDate="2017-03-30T09:05:25.513" Title="Open vim with nerdtree if its open from inside a particular directory" Tags="|vimrc|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11909" PostTypeId="1" AcceptedAnswerId="11910" CreationDate="2017-03-29T06:42:17.253" Score="0" ViewCount="995" Body="&lt;p&gt;I am using this &lt;a href=&quot;https://stackoverflow.com/questions/6876850/how-to-highlight-all-occurrences-of-a-word-in-vim-on-double-clicking&quot;&gt;excellent solution by Peter Rinker&lt;/a&gt; to highlight all occurrences of a word on double clicking.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;2-LeftMouse&amp;gt; :let @/='\V\&amp;lt;'.escape(expand('&amp;lt;cword&amp;gt;'), '\').'\&amp;gt;'&amp;lt;cr&amp;gt;:set hls&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to modify this to  also copy this word into the clipboard, i.e. the &lt;code&gt;&quot;+&lt;/code&gt; register?&lt;/p&gt;&#xA;" OwnerUserId="11966" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-03-29T06:57:02.447" Title="Highlight word on double click and copy to clipboard" Tags="|key-bindings|highlight|os-clipboard|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11910" PostTypeId="2" ParentId="11909" CreationDate="2017-03-29T06:57:02.447" Score="2" Body="&lt;p&gt;The relevant part of that solution is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @/='\V\&amp;lt;'.escape(expand('&amp;lt;cword&amp;gt;'), '\').'\&amp;gt;'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;expand('&amp;lt;cword&amp;gt;')&lt;/code&gt; part will grab the text under the cursor, and the &lt;code&gt;escape&lt;/code&gt; function will make sure that it's literal text rather than a regex. However, we don't want to modify the text we copy, so we can just call the &lt;code&gt;expand('&amp;lt;cword&amp;gt;')&lt;/code&gt; part. So you want to add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @+=expand('&amp;lt;cword&amp;gt;')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to some part of the mapping. Since the order on those three ex calls don't really matter, you can put it wherever you'd like. One solution (adding it to the end) would give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;2-LeftMouse&amp;gt; :let @/='\V\&amp;lt;'.escape(expand('&amp;lt;cword&amp;gt;'), '\').'\&amp;gt;'&amp;lt;cr&amp;gt;:set hls&amp;lt;cr&amp;gt;:let @+=expand('&amp;lt;cword&amp;gt;')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-03-29T06:57:02.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11911" PostTypeId="1" AcceptedAnswerId="11918" CreationDate="2017-03-29T07:43:17.877" Score="3" ViewCount="2476" Body="&lt;p&gt;I have set Vim's default colorscheme to Monokai, and when I exit Vim the Monokai colors are still on the screen until I &lt;code&gt;clear&lt;/code&gt; it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can Vim be set to run &lt;code&gt;clear&lt;/code&gt; automatically on exit, or change the color scheme or at least the background color to what it was before it started?&lt;/p&gt;&#xA;" OwnerUserId="9540" LastActivityDate="2021-07-18T12:36:23.617" Title="How can Vim be configured to restore normal terminal color on exit?" Tags="|colorscheme|terminal|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11913" PostTypeId="1" AcceptedAnswerId="11915" CreationDate="2017-03-29T09:56:27.097" Score="30" ViewCount="21774" Body="&lt;p&gt;What is the intended use case for the &lt;kbd&gt;s&lt;/kbd&gt; command in normal mode? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been looking at it for some time, inadvertently pressing &lt;kbd&gt;s&lt;/kbd&gt;, but can't find any use case that would make sense for me.&lt;/p&gt;&#xA;" OwnerUserId="1545" LastActivityDate="2022-07-06T19:01:10.700" Title="What is the purpose of `s`?" Tags="|normal-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11914" PostTypeId="1" CreationDate="2017-03-29T10:03:45.373" Score="1" ViewCount="135" Body="&lt;p&gt;When I use braces &lt;code&gt;(&lt;/code&gt;, the indenting is screwed up. Filetype is not set (but it's the same if I set it to e.g. txt). Here's what I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&amp;lt;CR&amp;gt;bar&amp;lt;CR&amp;gt;foo (&amp;lt;CR&amp;gt;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's how it looks like in vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar&#xA;foo (&#xA;        bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does the second &lt;code&gt;bar&lt;/code&gt; get indented? I have auto indent and cindent in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the output of &lt;code&gt;:scriptnames&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: /etc/vimrc&#xA;  2: /usr/share/vim/vimfiles/archlinux.vim&#xA;  3: ~/.vimrc&#xA;  4: /usr/share/vim/vim80/filetype.vim&#xA;  5: /usr/share/vim/vimfiles/ftdetect/dockerfile.vim&#xA;  6: /usr/share/vim/vim80/ftplugin.vim                                                        &#xA;  7: /usr/share/vim/vim80/indent.vim                                                          &#xA;  8: ~/.vim/autoload/pathogen.vim                                                             &#xA;  9: /usr/share/vim/vim80/ftoff.vim                                                           &#xA; 10: /usr/share/vim/vim80/syntax/syntax.vim                                                   &#xA; 11: /usr/share/vim/vim80/syntax/synload.vim                                                  &#xA; 12: /usr/share/vim/vim80/syntax/syncolor.vim                                                 &#xA; 13: ~/.vim/colors/peaksea.vim                                                                &#xA; 14: ~/.vim/plugin/Bclose.vim                                                                 &#xA; 15: ~/.vim/plugin/NERD_tree.vim                                                              &#xA; 16: ~/.vim/plugin/a.vim                                                                      &#xA; 17: ~/.vim/plugin/conque_gdb.vim                                                             &#xA; 18: ~/.vim/autoload/conque_gdb.vim                                                           &#xA; 19: ~/.vim/autoload/conque_term.vim                                                          &#xA; 20: ~/.vim/plugin/conque_term.vim                                                            &#xA; 21: ~/.vim/plugin/toggle.vim                                                                 &#xA; 22: ~/.vim/plugin/yankstack.vim                                                              &#xA; 23: ~/.vim/autoload/yankstack.vim                                                            &#xA; 24: ~/.vim/bundle/gundo/plugin/gundo.vim                                                     &#xA; 25: ~/.vim/bundle/syntastic/plugin/syntastic/autoloclist.vim                                 &#xA; 26: ~/.vim/bundle/syntastic/plugin/syntastic/balloons.vim                                    &#xA; 27: ~/.vim/bundle/syntastic/plugin/syntastic/checker.vim                                     &#xA; 28: ~/.vim/bundle/syntastic/plugin/syntastic/cursor.vim                                      &#xA; 29: ~/.vim/bundle/syntastic/plugin/syntastic/highlighting.vim                                &#xA; 30: ~/.vim/bundle/syntastic/plugin/syntastic/loclist.vim                                     &#xA; 31: ~/.vim/bundle/syntastic/plugin/syntastic/modemap.vim                                     &#xA; 32: ~/.vim/bundle/syntastic/plugin/syntastic/notifiers.vim                                   &#xA; 33: ~/.vim/bundle/syntastic/plugin/syntastic/registry.vim                                    &#xA; 34: ~/.vim/bundle/syntastic/plugin/syntastic/signs.vim                                       &#xA; 35: ~/.vim/bundle/syntastic/plugin/syntastic.vim                                             &#xA; 36: ~/.vim/bundle/syntastic/autoload/syntastic/util.vim                                      &#xA; 37: /usr/share/vim/vimfiles/plugin/SyntaxFolds.vim                                           &#xA; 38: /usr/share/vim/vimfiles/plugin/a.vim                                                     &#xA; 39: /usr/share/vim/vimfiles/plugin/filebrowser.vim                                           &#xA; 40: /usr/share/vim/vimfiles/plugin/imaps.vim                                                 &#xA; 41: /usr/share/vim/vimfiles/plugin/remoteOpen.vim                                            &#xA; 42: /usr/share/vim/vim80/plugin/getscriptPlugin.vim                                          &#xA; 43: /usr/share/vim/vim80/plugin/gzip.vim                                                     &#xA; 44: /usr/share/vim/vim80/plugin/logiPat.vim                                                  &#xA; 45: /usr/share/vim/vim80/plugin/manpager.vim                                                 &#xA; 46: /usr/share/vim/vim80/plugin/matchparen.vim                                               &#xA; 47: /usr/share/vim/vim80/plugin/netrwPlugin.vim        &#xA; 48: /usr/share/vim/vim80/plugin/rrhelper.vim                                                 &#xA; 49: /usr/share/vim/vim80/plugin/spellfile.vim                                                &#xA; 50: /usr/share/vim/vim80/plugin/tarPlugin.vim                                                &#xA; 51: /usr/share/vim/vim80/plugin/tohtml.vim                                                   &#xA; 52: /usr/share/vim/vim80/plugin/vimballPlugin.vim                                            &#xA; 53: /usr/share/vim/vim80/plugin/zipPlugin.vim                                                &#xA; 54: ~/.vim/bundle/syntastic/autoload/syntastic/log.vim                                       &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6154" LastEditorUserId="6154" LastEditDate="2017-03-30T06:28:41.100" LastActivityDate="2017-03-30T16:04:31.483" Title="Indenting when using ()" Tags="|indentation|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11915" PostTypeId="2" ParentId="11913" CreationDate="2017-03-29T10:08:58.003" Score="22" Body="&lt;p&gt;I don't think there's a more specific use mode than to delete the character under the cursor and enter insert mode. By using a number modifier you can delete several characters before entering insert mode. E.g. if you want to change &lt;code&gt;foobar&lt;/code&gt; into &lt;code&gt;fubar&lt;/code&gt;, then I would set to cursor to &lt;code&gt;f&lt;/code&gt;, and press &lt;code&gt;3sfu&lt;/code&gt;. Of course, you don't need to use &lt;code&gt;s&lt;/code&gt;, you could also do e.g. &lt;code&gt;ctbu&lt;/code&gt;. I guess you can always get away without using &lt;code&gt;s&lt;/code&gt;. That being said, I use &lt;code&gt;s&lt;/code&gt; very often.&lt;/p&gt;&#xA;" OwnerUserId="6154" LastEditorUserId="6154" LastEditDate="2017-03-29T10:33:31.930" LastActivityDate="2017-03-29T10:33:31.930" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11917" PostTypeId="1" CreationDate="2017-03-29T13:00:31.187" Score="1" ViewCount="77" Body="&lt;p&gt;Sometimes I want to reformat a paragraph using &lt;code&gt;gq&lt;/code&gt; but with a different value than the one set in my configuration for this filetype. Since this happens only occasionally within a buffer of such type (pandoc markdown) I also do not want to change the default value of 80 characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, how do I reformat a paragraph using a different value for textwidth than the default one?&lt;/p&gt;&#xA;" OwnerUserId="10358" LastActivityDate="2017-03-29T13:00:31.187" Title="How do I reformat a paragraph using a different value for textwidth than the default one?" Tags="|formatting|wrapping|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11918" PostTypeId="2" ParentId="11911" CreationDate="2017-03-29T13:37:46.303" Score="7" Body="&lt;h1&gt;How to Clear the Screen When Exiting Vim&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;When Vim quits, it sends the escape sequence defined by the &lt;code&gt;t_te&lt;/code&gt; setting to the terminal in order to tell it what to do. This should be set automatically by Vim to do something sensible, but it looks like something's going wrong in your setup: the likely candidate seems to be that your terminal is configured incorrectly, but let's investigate:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clear the screen, we need to send the &lt;code&gt;clear&lt;/code&gt; escape sequence to our terminal. We can find out what sequence is required by querying our &lt;code&gt;terminfo&lt;/code&gt; database with the &lt;code&gt;infocmp&lt;/code&gt; command. By running &lt;code&gt;infocmp&lt;/code&gt; in my terminal (which happens, like yours, to be &lt;code&gt;xterm-256color&lt;/code&gt;), I see the following entry:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;clear=\E[H\E[2J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this output, the left hand side of the equation refers to a terminal &quot;capability&quot;, and the right-hand side to the escape sequence used to access it. In the displayed sequence, the &lt;code&gt;\E&lt;/code&gt; refers to an &lt;code&gt;Escape&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the escape sequence used by xterm to clear the screen is &lt;code&gt;&amp;lt;Esc&amp;gt;[H&amp;lt;Esc&amp;gt;[2J&lt;/code&gt;. If we want Vim to clear the screen on exit, we need to configure its &lt;code&gt;t_te&lt;/code&gt; setting to send this sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We do so with the following Vim command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set t_te=^[[H^[2J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. In the above, the two instances of &lt;code&gt;^[&lt;/code&gt; are Vim's representation of the escape character that was displayed as &lt;code&gt;\E&lt;/code&gt; above. You type them by pressing &lt;kbd&gt;Ctrl+V&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;: &lt;strong&gt;not&lt;/strong&gt; by typing a &lt;code&gt;^&lt;/code&gt; followed by a &lt;code&gt;[&lt;/code&gt; character.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After quitting Vim, the screen &lt;em&gt;should&lt;/em&gt; now be cleared.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;What Might Be Going Wrong For You&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This may or may not actually work for you, however. As already mentioned, Vim should set up &lt;code&gt;t_te&lt;/code&gt; sensibly &lt;em&gt;already&lt;/em&gt;. There are several places where the problem could be occurring:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Your &lt;code&gt;t_te&lt;/code&gt; might be set incorrectly by your &lt;code&gt;.vimrc&lt;/code&gt; or by a plugin. Setting &lt;code&gt;t_te&lt;/code&gt; as above should fix this,&lt;/li&gt;&#xA;&lt;li&gt;You have indicated your &lt;code&gt;$TERM&lt;/code&gt; is set to &lt;code&gt;xterm-256color&lt;/code&gt;. If you are actually using a &lt;em&gt;different&lt;/em&gt; terminal, the escape sequence described above may be wrong. The way to fix this is by setting &lt;code&gt;$TERM&lt;/code&gt; to match your actual terminal.&lt;/li&gt;&#xA;&lt;li&gt;It's possible (although less likely) that your terminfo database contains the incorrect info for &lt;code&gt;xterm-256color&lt;/code&gt;. You can test if this is the case by running the command &lt;code&gt;tput clear&lt;/code&gt; in your terminal. This queries the terminfo database for the &lt;code&gt;clear&lt;/code&gt; capability, which is output to the terminal, and &lt;em&gt;should&lt;/em&gt; result in the terminal clearing the screen. If this does not do so, then your &lt;code&gt;terminfo&lt;/code&gt; database is incorrect, and will need fixing. This is not really a Vim issue, so you may find more help &lt;a href=&quot;https://unix.stackexchange.com/&quot;&gt;elsewhere&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;Extra Credit&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I wrote earlier that Vim should set &lt;code&gt;t_te&lt;/code&gt; to &quot;something sensible&quot;. But for me, this is &lt;em&gt;not&lt;/em&gt; clearing the screen. So what does it actually set &lt;code&gt;t_te&lt;/code&gt; to?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;:set t_te?&lt;/code&gt;, for me, outputs: &lt;code&gt;t_te=^[[?1049l&lt;/code&gt;. By looking in the &lt;code&gt;infocmp&lt;/code&gt; output, I can see that this corresponds to a capability of &lt;code&gt;rmcup&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out that this, in conjunction with the related &lt;code&gt;t_ti&lt;/code&gt; setting (which is set to the &lt;code&gt;smcup&lt;/code&gt; capability) sets up Vim to use xterm's alternate screen buffer for rendering&amp;thinsp;&amp;mdash;&amp;thinsp;when Vim quits, the terminal state is reset to display whatever was displaying before I ran Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, you can try out this switching of screen buffers outside of Vim by running a sequence of commands in your terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls         # just to get something onscreen&#xA;tput smcup # The ls output disappears&#xA;tput rmcup # The ls output reappears&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-03-29T14:29:05.220" LastActivityDate="2017-03-29T14:29:05.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11919" PostTypeId="2" ParentId="11901" CreationDate="2017-03-29T14:15:10.390" Score="3" Body="&lt;p&gt;What is most likely happening in your case is that the buffer is automatically unloaded because you don't have the option &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27hidden%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'hidden'&lt;/code&gt;&lt;/a&gt; enabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This option not only resolves the issue you reported, but is also required when you want to navigate between buffers without being forced to write the changes before doing so. Personally, I can't imagine working in Vim without it.&lt;/p&gt;&#xA;" OwnerUserId="599" LastActivityDate="2017-03-29T14:15:10.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11920" PostTypeId="1" CreationDate="2017-03-29T15:01:00.490" Score="1" ViewCount="957" Body="&lt;p&gt;I would like to run &lt;code&gt;:make&lt;/code&gt; in Vim, while also allowing the user to edit a file while we're waiting for the compilation to finish, then when the compilation is finished open the result in a split window (which I know by itself would be done with &lt;code&gt;:make | copen&lt;/code&gt;) with how long it took for the make to run (preferably in a human-readable format, e.g., 5m 32s instead of 332s). Is this possible? I'm guessing using the UNIX time command I could edit my Makefile to do the time measurement, but does Vim have the ability to time the make command itself? &lt;/p&gt;&#xA;" OwnerUserId="11076" LastEditorUserId="11076" LastEditDate="2017-03-29T15:06:28.293" LastActivityDate="2017-03-30T06:47:44.740" Title="How to run make in Vim, open results in split window and show the compilation time?" Tags="|makeprg|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11921" PostTypeId="2" ParentId="11913" CreationDate="2017-03-29T15:09:44.200" Score="16" Body="&lt;p&gt;&lt;code&gt;s&lt;/code&gt; is short for &lt;code&gt;cl&lt;/code&gt; which is mentioned in &lt;code&gt;help s&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&quot;x]s                   Delete [count] characters [into register x] and start&#xA;                        insert (s stands for Substitute).  Synonym for &quot;cl&quot;&#xA;                        (not linewise).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've mapped &lt;code&gt;s&lt;/code&gt; to my own command and haven't missed the default 'substitute' so far.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-29T15:09:44.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11922" PostTypeId="1" AcceptedAnswerId="11925" CreationDate="2017-03-30T00:42:30.973" Score="3" ViewCount="109" Body="&lt;p&gt;This is related to this previous question: &lt;a href=&quot;https://vi.stackexchange.com/questions/4532/numbered-register-doesnt-record-most-deleted-text-within-a-line&quot;&gt;Numbered register doesn&amp;#39;t record most deleted text within a line?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know the rationale for this. I was writing an email and deleted a note in parenthesis (&lt;code&gt;da(&lt;/code&gt;), then deleted the extraneous whitespace character with &lt;code&gt;x&lt;/code&gt;. When I looked at my registers with &lt;code&gt;reg&lt;/code&gt;, the text in parenthesis was not there.&lt;/p&gt;&#xA;" OwnerUserId="10101" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2017-03-30T08:39:04.780" Title="What is the rationale behind not using the numbered registers for small deletes/yanks?" Tags="|cut-copy-paste|register|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11923" PostTypeId="1" AcceptedAnswerId="11924" CreationDate="2017-03-30T02:35:04.610" Score="2" ViewCount="69" Body="&lt;p&gt;To input vim and enter command mode ,then to input &lt;strong&gt;vs&lt;/strong&gt;,two windows created.&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/q5kpH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/q5kpH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to input &lt;strong&gt;w test.html&lt;/strong&gt;,why file names in left and right  windows  are  same--test.html?&lt;br&gt;&#xA;I just named the file in left window as test.html, why the file in right window named as test.html too?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="51" LastEditDate="2017-04-04T13:43:04.773" LastActivityDate="2017-04-04T13:43:04.773" Title="Why file names in left and right windows are same?" Tags="|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11924" PostTypeId="2" ParentId="11923" CreationDate="2017-03-30T03:44:07.713" Score="4" Body="&lt;p&gt;When you did &lt;code&gt;:vs&lt;/code&gt; you split the window on the current buffer, but did not create a new buffer; instead you have two windows viewing the same original buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you did &lt;code&gt;:w test.html&lt;/code&gt;, you caused the buffer to take a new name. Because both windows are showing the same buffer, both windows show the new name of the buffer, namely &lt;code&gt;test.html&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a good read at &lt;code&gt;:help windows-intro&lt;/code&gt;, which starts thusly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Summary:&#xA;   A buffer is the in-memory text of a file.&#xA;   A window is a viewport on a buffer.&#xA;   A tab page is a collection of windows.&#xA;&#xA;A window is a viewport onto a buffer.  You can use multiple windows on one&#xA;buffer, or several windows on different buffers.&#xA;&#xA;A buffer is a file loaded into memory for editing.  The original file remains&#xA;unchanged until you write the buffer to the file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd organize it a bit more in order: Vim has tabs. Tabs have windows. Windows are views of a buffer. A buffer is the file contents in memory, typically tied to a filename.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:vs&lt;/code&gt; command is the same as &lt;code&gt;:vertical split&lt;/code&gt;; and the documentation for &lt;code&gt;:split&lt;/code&gt; calls out that &quot;The result is two viewports on the same file&quot;, unless you also specify a new file name, in which case the new file is opened in the newly created window. (see &lt;code&gt;:help :vs&lt;/code&gt; and &lt;code&gt;:help :split&lt;/code&gt; for more details)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also notice that, when both windows' viewports show the same region of the buffer, you can see changes to both at the same time (try going into insert mode and type some text).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Creating a separate buffer when splitting&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I think what you expected was that, after splitting, you had 2 different buffers. You can either specify a filename after the &lt;code&gt;:vs&lt;/code&gt; command (like &lt;code&gt;:vs myfile.html&lt;/code&gt;). If the file exists, it will be opened. If not, you get a blank buffer that will create the file once saved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To create a new window with a new unnamed buffer, try &lt;code&gt;:vertical new&lt;/code&gt; (or &lt;code&gt;:vne&lt;/code&gt; for short) instead of &lt;code&gt;:vs&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2017-03-30T03:52:29.310" LastActivityDate="2017-03-30T03:52:29.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11925" PostTypeId="2" ParentId="11922" CreationDate="2017-03-30T06:02:41.820" Score="3" Body="&lt;p&gt;The rational is to avoid the deletes to be shifted out of the numbered registers too soon. Typically, if you intent to re-insert deleted text after a while, you put it into a named register you can remember. If you believe you will not need this piece of text anymore, you don't specify a register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you are like me, every once in a while you will regret having deleted some text. If it has been just a few words, the fastest solution is to re-type it. But if it has been a whole paragraph or a code block, I'm happy to find it in &lt;code&gt;&quot;1&lt;/code&gt; to &lt;code&gt;&quot;9&lt;/code&gt; somewhere. And I wouldn't want it to be kicked out of &lt;code&gt;&quot;9&lt;/code&gt; meanwhile by a couple of deleted single-words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And why one line, not something like &quot;40 characters&quot; which may be a border when it starts to hurt to lose text? Because you don't count characters. If you are doing deletions inside a line, you are aware: This will soon be gone forever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case you may still undo all changes until your delete, yank it and redo everything. There you have your deletion back.&lt;/p&gt;&#xA;" OwnerUserId="11771" LastEditorUserId="11771" LastEditDate="2017-03-30T06:08:34.063" LastActivityDate="2017-03-30T06:08:34.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11926" PostTypeId="2" ParentId="11920" CreationDate="2017-03-30T06:47:44.740" Score="1" Body="&lt;p&gt;It's possible, with Vim8. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First you'll need to register the current time with &lt;code&gt;reltime()&lt;/code&gt; function.&lt;/li&gt;&#xA;&lt;li&gt;Then, start a job that'll run the content of &lt;code&gt;&amp;amp;makeprg&lt;/code&gt; with &lt;code&gt;$*&lt;/code&gt; replaced with the target you wish to used (it may be an empty string). Don't forget to register a hook that'll listen for any line produced by the compilation. You'll certainly wish to add it to &lt;code&gt;:caddexpr&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;And also, you'll have to register the close callback. In this one you'll know whether the compilation has succeeded, and you'll compare the new &lt;code&gt;reltime()&lt;/code&gt; with the registered one.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note: that while I don't display the compilation time in &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-vim-lib&lt;/a&gt;+&lt;a href=&quot;https://github.com/LucHermitte/vim-build-tools-wrapper&quot; rel=&quot;nofollow noreferrer&quot;&gt;build-tools-wrapper&lt;/a&gt;, it's easy to add (actually I display it when we put the &lt;a href=&quot;https://github.com/LucHermitte/vim-build-tools-wrapper/blob/job-compile/autoload/lh/btw/job_build.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;lh/btw/job_build.vim&lt;/code&gt; autoload plugin&lt;/a&gt; in verbose mode).&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-03-30T06:47:44.740" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11927" PostTypeId="2" ParentId="11908" CreationDate="2017-03-30T09:05:25.513" Score="2" Body="&lt;p&gt;Editing the line to check for directory fixed my problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter */workspace/* NERDTree| wincmd p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11044" LastActivityDate="2017-03-30T09:05:25.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11928" PostTypeId="1" CreationDate="2017-03-30T10:59:01.137" Score="0" ViewCount="322" Body="&lt;p&gt;I'm making tentative steps into using tabs in Vim. It seems a bit ridiculous, I've been using tabs in everything for the last 18 years:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Visual Studio&lt;/li&gt;&#xA;&lt;li&gt;Every browser since Opera came up with them&lt;/li&gt;&#xA;&lt;li&gt;Notepad++&lt;/li&gt;&#xA;&lt;li&gt;Sublime Text&lt;/li&gt;&#xA;&lt;li&gt;Bash terminals&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As you can see it's mostly Windows, but I really want to switch to proper free and open tools for my dev work, so I want to switch off Sublime Text into Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also been a fairly basic user of Vim for 18 years. I only just realised that Vim does have tabs in it! Don't I feel clever...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So ok, great so Vim has tabs, but really they're not tabs, but they are, but they're not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Vim wiki on &lt;a href=&quot;http://vim.wikia.com/wiki/Using_tab_pages&quot; rel=&quot;nofollow noreferrer&quot;&gt;tab 'pages'&lt;/a&gt; has a mildly helpful start:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In Vim, each file is loaded into a buffer, which can be displayed in any number of windows, in any number of tabs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I can just about get that, they're really flexible, which I can imagine is great. You could split a single file across tabs I'd imagine, I've never felt the need to do that, but I'm sure there's a use case for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then the wiki falls off the edge of my knowledge whilst at the same time trying to claim they're making it easier for me:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The easiest way to think about tab pages in Vim is to consider them to be viewports, layouts, or workspaces. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h3&gt;My question:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Ok... so as it's so easy could someone explain to me what the following are in terms of Vim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;viewport&lt;/li&gt;&#xA;&lt;li&gt;layout&lt;/li&gt;&#xA;&lt;li&gt;workspace&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;P.S. I've been found a helpful answer on this SO question on &lt;a href=&quot;https://stackoverflow.com/a/8973705/327074&quot;&gt;Using Vim's tabs like buffers&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A buffer is the in-memory text of a file.&lt;br&gt;&#xA;   A window is a viewport&#xA;   on a buffer.&lt;br&gt;&#xA;  A tab page is a collection of windows.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But again that doesn't explain what a viewport is, or a layout or a workspace. None of which I've heard of in terms of an editor before. (Well actually Sublime Text has workspaces but I'm sure they mean something different there)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, I could keep googling down the rabbit hole, but I didn't expect the rabbit hole to be this deep.&lt;/p&gt;&#xA;" OwnerUserId="11986" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-03-30T15:09:04.967" Title="What are viewport, layout and workspace in relation to tabs" Tags="|buffers|vim-windows|tabbed-user-interface|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11929" PostTypeId="2" ParentId="11893" CreationDate="2017-03-30T12:01:50.160" Score="2" Body="&lt;p&gt;&lt;code&gt;:normal&lt;/code&gt; cannot be used while in terminal-mode (AKA &quot;insert-mode in a terminal buffer&quot;). Instead &lt;code&gt;feedkeys()&lt;/code&gt; can be used (the second &lt;code&gt;\&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; escaped--yet another Vimscript quirk):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call feedkeys(&quot;\&amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For your specific case, jamming a &lt;code&gt;feedkeys()&lt;/code&gt; call immediately after the &lt;code&gt;:execute&lt;/code&gt; doesn't seem to work (could be that &quot;typeahead&quot; is processed before &lt;code&gt;:terminal&lt;/code&gt; initializes). Instead, use &lt;code&gt;:stopinsert&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;:terminal python a-python-script.py&quot; a:1 a:2 a:3 a:4&#xA;stopinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the &lt;code&gt;TermOpen&lt;/code&gt; autocmd is also available for terminal initialization.&lt;/p&gt;&#xA;" OwnerUserId="578" LastActivityDate="2017-03-30T12:01:50.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11930" PostTypeId="2" ParentId="11928" CreationDate="2017-03-30T15:09:04.967" Score="1" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/11928/what-are-viewport-layout-and-workspace-in-relation-to-tabs?noredirect=1#comment20732_11928&quot;&gt;@Rich comments&lt;/a&gt;, I'm possibly over thinking this. But I've never heard of viewport or layout with regards to a text editor and I've only heard of 'workspace' referred to with regards to the list of files you have open for Sublime Text.&lt;/p&gt;&#xA;&lt;p&gt;However in responding to his question, actual computer science dictionary definitions of the words kind of make sense:&lt;/p&gt;&#xA;&lt;h3&gt;Workspace (computing):&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;quot;A memory storage facility for temporary use.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;-- &lt;a href=&quot;https://en.oxforddictionaries.com/definition/workspace&quot; rel=&quot;nofollow noreferrer&quot;&gt;ref&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h3&gt;Viewport (computing):&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A framed area on a display screen for viewing information.&lt;/p&gt;&#xA;&lt;p&gt;-- &lt;a href=&quot;https://en.oxforddictionaries.com/definition/viewport&quot; rel=&quot;nofollow noreferrer&quot;&gt;ref&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Both of those make sense.&lt;/p&gt;&#xA;&lt;h3&gt;Layout&lt;/h3&gt;&#xA;&lt;p&gt;Layout doesn't seem to make any sense as far as I can tell. You have page layout for web pages but tabs don't really position things on a screen, they just allow you to subdivide what your working on&lt;/p&gt;&#xA;&lt;p&gt;There's the &lt;a href=&quot;https://en.wikipedia.org/wiki/Layout_(computing)&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia definition&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In computing, layout is the process of calculating the position of objects in space subject to various constraints. This functionality can be part of an application or packaged as a reusable component or library.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I certainly understand now that viewport is equivalent to window.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.linux.com/learn/vim-tips-using-viewports&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Tips using Viewports article&lt;/a&gt; I found very helpful, in the simple sense that it explains just running &lt;code&gt;:help &amp;lt;command&amp;gt;&lt;/code&gt; e.g. &lt;code&gt;:help window&lt;/code&gt; will open that up in a 'window' / 'viewport'&lt;/p&gt;&#xA;&lt;p&gt;However in my head now, I think it makes sense that when coming from another editor I should just not bother with tab pages and stick to buffers. Open a new buffer as I would open a new tab. Then you can search the open buffers that you have and switch between them. Somewhat similar to running &lt;code&gt;Ctrl +P&lt;/code&gt; and searching for a new file with Sublime Text.&lt;/p&gt;&#xA;" OwnerUserId="11986" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-03-30T15:09:04.967" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11931" PostTypeId="2" ParentId="11865" CreationDate="2017-03-30T15:28:38.177" Score="2" Body="&lt;p&gt;My vim was slowing down because of &lt;code&gt;Plugin 'Yggdroot/indentLine'&lt;/code&gt;. @laktak you was right&lt;/p&gt;&#xA;" OwnerUserId="11904" LastActivityDate="2017-03-30T15:28:38.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11932" PostTypeId="2" ParentId="11914" CreationDate="2017-03-30T16:04:31.483" Score="2" Body="&lt;p&gt;Before I was using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;.vimrc&lt;/code&gt;. If I understand correctly, this turns on &lt;code&gt;cindent&lt;/code&gt; for all filetypes. If I do not specify, it will only be turned on for &lt;code&gt;cpp&lt;/code&gt; files, which is what I want. So removing &lt;code&gt;set cindent&lt;/code&gt; from my &lt;code&gt;.vimrc&lt;/code&gt; did the trick.&lt;/p&gt;&#xA;" OwnerUserId="6154" LastActivityDate="2017-03-30T16:04:31.483" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11933" PostTypeId="1" CreationDate="2017-03-30T22:07:39.660" Score="3" ViewCount="157" Body="&lt;p&gt;I would like to know how to add a space and then text at the end of a line.  For example, adding a space and then &lt;code&gt;/abc/aaa/abc/&lt;/code&gt;.  I am trying &lt;code&gt;:%s/$/ /abc/aaa/abc/&lt;/code&gt; but that does not work. I know I am missing something.&lt;/p&gt;&#xA;" OwnerUserId="11997" LastEditorUserId="11771" LastEditDate="2017-03-31T13:46:43.073" LastActivityDate="2017-04-03T20:34:15.760" Title="Add a space and then text at the end of a line" Tags="|search|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11934" PostTypeId="2" ParentId="11933" CreationDate="2017-03-30T22:37:51.613" Score="2" Body="&lt;p&gt;You are very close. The reason &lt;code&gt;:%s/$/ /abc/aaa/abc/&lt;/code&gt; does not work here is that you are not escaping the &lt;code&gt;/&lt;/code&gt; character in your output string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run it like this  &lt;code&gt;%s/$/ \/abc\/aaa\/abc/&lt;/code&gt; Leaving only the last / unescaped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vim.wikia.com/wiki/Search_and_replace&quot; rel=&quot;nofollow noreferrer&quot;&gt;substitute&lt;/a&gt; command has some serious power that you can play with once the nuances of the command are learned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:  All the escaping is not necessary.  By changing the &lt;a href=&quot;http://vim.wikia.com/wiki/Alternate_delimiters_for_the_replace_command&quot; rel=&quot;nofollow noreferrer&quot;&gt;substitute delimiter&lt;/a&gt; from the default &lt;code&gt;/&lt;/code&gt; to &lt;code&gt;_&lt;/code&gt;, &lt;code&gt;#&lt;/code&gt;, or most non-alphanumeric characters. Your substitution could read as:&#xA;&lt;code&gt;:%s_$_ /abc/aaa/abc_&lt;/code&gt; or &lt;code&gt;:%s#$# /abc/aaa/abc#&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you @Philippos for pointing this out in the comments.&lt;/p&gt;&#xA;" OwnerUserId="8493" LastEditorUserId="8493" LastEditDate="2017-04-03T20:34:15.760" LastActivityDate="2017-04-03T20:34:15.760" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11935" PostTypeId="1" CreationDate="2017-03-31T07:05:36.167" Score="1" ViewCount="4248" Body="&lt;p&gt;Id like to start using vim for quickly creating files (note taking, scratch files) and making small/quick changes to existing python scripts&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whats the best way to get Vim installed on Windows? Would it be to install gVim? Or to install Vim through Bash on Windows?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I currently have Bash on Windows setup and access it through ConEmu but I rarely use it)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do the gVim and Bash on Windows approaches have any significant differences or are there disadvantages to either method?&lt;/p&gt;&#xA;" OwnerUserId="5716" LastEditorUserId="205" LastEditDate="2017-04-03T02:05:43.980" LastActivityDate="2017-04-03T11:33:05.607" Title="Windows: gVim or bash" Tags="|gvim|microsoft-windows|" AnswerCount="3" CommentCount="1" ClosedDate="2017-04-04T13:31:19.003" ContentLicense="CC BY-SA 3.0" />
  <row Id="11937" PostTypeId="2" ParentId="11935" CreationDate="2017-03-31T09:53:13.473" Score="0" Body="&lt;p&gt;vim with Bash on Windows is great except you cannot use it to edit anything on a network share (local files only). Hopefully this will be fixed soon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer vim/tmux in a terminal so I did not try gVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim for Windows did not work for me (I'd like to share my dotfiles with Linux/Mac).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best option IMO is to use vim from cygwin in a cygwin terminal: the colors &amp;amp; plugins work and you can access network shares.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-03-31T09:53:13.473" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11938" PostTypeId="2" ParentId="11935" CreationDate="2017-03-31T14:42:52.527" Score="5" Body="&lt;p&gt;I use both gvim for Windows and Cygwin's terminal vim. I have them configured the same, so in most cases it doesn't matter which one I use. However, they handle file names differently. Gvim for Windows understands Windows path names while Cygwin's vim understands Cygwin path names. If you rarely use bash, then I assume you don't care about having a Unix-like environment and I would recommend that you use Windows gvim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One nice advantage to using Windows gvim is that the installer can add a context menu &quot;Edit with Vim&quot; entry, which lets you easily choose to edit a file with gvim rather than opening it with the default application.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-03-31T14:42:52.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11941" PostTypeId="1" CreationDate="2017-04-01T03:26:06.943" Score="1" ViewCount="1643" Body="&lt;p&gt;How can I convince Vim or Neovim to show the enclosing namespace, class, and function that the cursor is in?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some programming languages have no interesting namespaces or class names. In general, this question is about displaying whatever enclosing context exists for relevant programming language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there's no general solution then I'm also interested in C and C++ specifically.&lt;/p&gt;&#xA;" OwnerUserId="268" LastEditorUserId="268" LastEditDate="2017-04-01T12:03:05.433" LastActivityDate="2017-05-29T13:08:10.523" Title="Display enclosing namespace, class, and function" Tags="|neovim|filetype|statusline|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11942" PostTypeId="2" ParentId="11941" CreationDate="2017-04-01T09:11:14.800" Score="0" Body="&lt;p&gt;Discl: Not an answer that will help you much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A very long time ago, I wrote a ftplugin able to extract current scope and display it in the status line ; I have a trace of &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp/blob/master/ftplugin/c/c_stl.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;it somewhere in lh-cpp&lt;/a&gt;.&#xA;It was slow as hell, and thus I have never really used it. In order to &lt;strong&gt;continously display an up-to-date context in the status line&lt;/strong&gt;, we should be able to improve its performances a little bit thank to list functions (&lt;code&gt;map()&lt;/code&gt;...), but I'm not very confident. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is to display the information &lt;strong&gt;on-demand&lt;/strong&gt;. In that case performances aren't critical as they are regarding the statusline.&#xA;Yet, today I would rely on lh-cpp and lh-dev where I've already defined everything to extract the current scope namespace(s) + class(es) + function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It could look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; autoload/lh/cpp/analyse.vim (unpublished yet)&#xA;&quot; Function: lh#cpp#analyse#context([line]) {{{3&#xA;function! lh#cpp#analyse#context(...) abort&#xA;  let line = get(a:, 1, line('.'))&#xA;  let fn = lh#dev#find_function_boundaries(line)&#xA;  if fn.lines[0] &amp;lt;= line &amp;amp;&amp;amp; line &amp;lt;= fn.lines[1]&#xA;    &quot; This is a function&#xA;    call lh#assert#value(fn).has_key('fn')&#xA;    let kinds = filter(['struct', 'class', 'namespace'], 'has_key(fn.fn, v:val)')&#xA;    call lh#assert#value(kinds).not().empty()&#xA;    let scope = join(&#xA;          \ [ get({'public': '+', 'private': '-', 'protected': '#'}, get(fn.fn, 'access', ''), '')&#xA;          \ , substitute(get(fn.fn, 'typeref', ''), '^typename:', '', '')&#xA;          \ , fn.fn[kinds[0]] . '::' . fn.fn.name . get(fn.fn, 'signature')&#xA;          \ ], ' ')&#xA;  else&#xA;    &quot; classes, structs, namespaces&#xA;    let scope = lh#cpp#AnalysisLib_Class#CurrentScope(line, 'any')&#xA;  endif&#xA;  return scope&#xA;endfunction&#xA;&#xA;&quot; ftplugin/c/c_show_context.vim (unpublished yet)&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;localleader&amp;gt;sc :echo lh#cpp#analyse#context()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: this almost works correclty on code such as this one: &lt;a href=&quot;https://github.com/LucHermitte/NamedParameter/blob/master/include/named-parameters.hpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/LucHermitte/NamedParameter/blob/master/include/named-parameters.hpp&lt;/a&gt;. We are now restricted by (universal!) ctags ability to understand C++(98/11/14/17/...) constructs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Internally it extracts the current function boundaries (it launches ctags to do it correctly in C++), and the current scope (multiple and recursive calls to &lt;code&gt;searchpair ()&lt;/code&gt;). I use it in my &lt;code&gt;:GOTOIMPL&lt;/code&gt; feature. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;May be we could achieve something faster nowadays thanks to clang. I don't know if some people have explored this path.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-05-29T13:08:10.523" LastActivityDate="2017-05-29T13:08:10.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11943" PostTypeId="1" CreationDate="2017-04-01T20:22:27.477" Score="1" ViewCount="455" Body="&lt;p&gt;I want to edit a GPG encrypted file &lt;code&gt;file.asc&lt;/code&gt; without having to split the window to enter the recipient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The recipient can be set in the &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:GPGDefaultRecipients='&amp;lt;key ID&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How would you suggest to parametrize/modify the gnupg plugin to automatically set the right recipient?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="9549" LastActivityDate="2017-04-02T08:48:48.540" Title="How to open a GPG encrypted file without having to choose the GPG recipient with the gnupg plugin?" Tags="|variables|environment-variables|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11944" PostTypeId="2" ParentId="11943" CreationDate="2017-04-02T08:48:48.540" Score="1" Body="&lt;p&gt;I'd better create an &quot;empty&quot; GPG encrypted file with the proper recipient and open it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;&quot;  | gpg -a -e -r &amp;lt;GPG ID/mail&amp;gt; &amp;gt; doc.asc&#xA;vim doc.asc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9549" LastActivityDate="2017-04-02T08:48:48.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11945" PostTypeId="1" AcceptedAnswerId="11950" CreationDate="2017-04-02T15:37:09.663" Score="2" ViewCount="80" Body="&lt;p&gt;I want to write my own java syntax file for more customization, But can't find the definition of &lt;code&gt;javaParen&lt;/code&gt;, it certainly isn't defined in default &lt;code&gt;java.vim&lt;/code&gt; file.&#xA;I actually want to highlight all the braces, but when there is a square bracket inside normal &lt;code&gt;()&lt;/code&gt; pair, it won't be highlighted, so I wanted to redefine javaParen to include the &lt;code&gt;[]&lt;/code&gt; pair, so I want to find the definition of &lt;code&gt;javaParen&lt;/code&gt;, and include &lt;code&gt;[]&lt;/code&gt; pair in it.&lt;/p&gt;&#xA;" OwnerUserId="12025" LastActivityDate="2017-04-03T02:39:26.453" Title="Where is `javaParen` defined?" Tags="|vimscript|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11948" PostTypeId="2" ParentId="11935" CreationDate="2017-04-02T22:27:56.133" Score="2" Body="&lt;p&gt;Go the bash route, even if there are some growing pains.  You'll thank yourself later.  vim and bash are like hand and glove.  You will only want to use more of each the more you use one or the other; the same can be said for anything built on the Unix tradition, and they all speak the same language and follow the same forms.  Besides, it's great to execute commands from the shell and read the input right into a buffer!  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Addendum:  Below are some additional comments I thought I'd follow up with as some encouragement for OP, and anyone in a similar position.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's more, you can do this sort of thing with most any combination of traditional Unix (i.e., command-line) tools.  You can't chain output from one program (together as input) to another in a GUI, but this is done all the time on the command-line.  If you're not sure what this means, don't worry, it will become apparent later.  But at least now it's got you curious; curiosity may have killed the cat, but it's taken man to the stars.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, using gVim will keep you trapped in the &quot;windows&quot; paradigm.  I'm not trying to be derogatory, but speaking from personal experience:  this paradigm of everything in its own window needs to be overcome (it's going to take some getting used to, and you will initially resist); it's just not as productive.  bash (i.e., any command-line interpreter) is your friend, and just about any of the most powerful tools you could ever dream of are all free, all have been around probably longer than you've been alive, all &quot;live&quot; on the command-line, and are likely installed with any basic Unix-like distribution (and if they aren't installed by default, they aren't that hard to get--in your case, probably a &lt;code&gt;sudo apt-get&lt;/code&gt; away).  Don't shy away from them because they take some getting used to; keep digging (there's tons of information out there--if you're curious enough to ask this question, you'll be curious enough to continue your search).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Honestly, I think gVim only exists because some people loved vim so much that they wanted to make it available to &quot;noobs&quot; who would otherwise resort to a GUI-based editor, and they thought this might be a gateway for them to go &quot;full-vim&quot;.  But, it's not.  It's still going to trap the user in the &quot;windows&quot; mindset.  All other GUI-based editors exist only as cheap imitations to the real thing (which is vim or emacs) and/or to sell software, particularly those masquerading as IDEs; at least a basic text editor serves the purpose of providing a tool for the novice or someone not involved with any kind of programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've only been using vim for about a month, and I've only been basically aware of bash and the rest of the Unix-like suite for maybe 2 years.  I knew the very basics beforehand, such as how to write a file and quit the editor, and the absolute basics of navigation (hjkl, and w, though I was still in the habit of resorting to my cursor/arrow keys).  Finally, I was doing enough programming that I was already getting sick of the limitations I was experiencing with editors like Atom and Sublime (for example, multi-line editing).  Of course I wanted more power and flexibility, but most importantly, I wanted to break this vicious habit of relying on these modern (and not always portable) applications before it got any worse.  The more time I wasted learning how to customize and be more productive with these frauds, the more I'd become completely dependent on them.  I've fallen into this trap before:  the app-trap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was determined to start using vim (or emacs).  So, I did what anyone else would do these days:  as a consumer, I &lt;em&gt;watched&lt;/em&gt; videos (on YouTube), expecting some magic to happen; that, by osmosis, learning would take place; that by &lt;em&gt;in-action&lt;/em&gt; I'd somehow change and become more productive.  But then a funny thing happened:  I saw some pretty cool tricks on display.  I saw a solution for how to edit multiple lines at once.  I had to try this out myself ...and it worked!  Of course, it's been there, right under my nose all along: vim!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also a compulsive note-taker.  So I went back through these videos, pausing at every new trick to try and determine the sequence of key-strokes used to achieve the desired result.  Then, armed with this newfound wisdom, I'd take to my keyboard; I just had to try them out myself.  I learned things I hadn't even thought possible--because I was still trapped in the &quot;windows&quot; mindset; for instance:  I didn't know that the vim &quot;language&quot; (of commands, operators and motions) was basically a scripting language, that I could &quot;talk&quot; to my editor.  This was truly profound ...and completely logical!  Inevitable, even.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, from that moment forward, I forced myself to start using vim, and I haven't regretted it one bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It didn't take long, maybe 2 days, before I was comfortable and already seeing an increase in productivity.  Soon after, I was wondering how editing could be any other way?  Now I recommend it to anyone that does more than a casual amount of typing.  It really is amazing, and you won't regret taking the plunge.  If I have to name one regret, it's that I now find myself trying to use vim commands in other contexts (e.g., trying to navigate text in the browser, or my instant messaging client using hjkl, $, 0, or w); it's very much muscle memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's true:  there is a learning curve.  It takes some getting used to, to get into the habit of switching from NORMAL to INSERT (and VISUAL) mode(s) and to navigate with keys in the home-row, rather than reaching for your mouse or the cursor/arrow keys.  &lt;em&gt;But the learning curve isn't linear, it's more like exponential; once you overcome that initial phase, everything starts to build on top of what you already know, and you can start to &quot;guess&quot; or deduce how to do much more stuff that you never explicitly took the time to learn because everything follows a pattern.  And this goes back to what I said initially, why it's good to use bash in conjunction with vim:  because everything you learn with one or the other will help you improve with &lt;strong&gt;all&lt;/strong&gt; the tools for anything Unix-based, including other programs/commands you have never even heard of or realized you can make great use of.  There is a whole (amazing) world out there waiting for you to discover it, and it wants to make your life easier (it's the Unix way).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, &lt;strong&gt;here is something I found really helpful: &lt;a href=&quot;http://vim.spf13.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.spf13.com/&lt;/a&gt;&lt;/strong&gt;&#xA;That's a popular vim &quot;distribution&quot; that has all the bells and whistles, more than you can dream of, or will make use of for probably years to come.  I almost want to recommend against it, because it will retard your learning how to manage vim yourself (editing your vimrc file and installing plugins), but it's the lesser of two evils--it's got enough eye-candy to draw you in and keep you from defaulting to a GUI-based editor.  Anyway, just stick with it, even when you find yourself a little frustrated (the same can be said for anything concerning computers and programming) and you'll eventually figure it out and be happy that you stuck it out, and be better off because you developed a little discipline and resourcefulness along the way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, here's one of the videos that was a good source of inspiration:  &lt;a href=&quot;https://www.youtube.com/watch?v=MquaityA1SM&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=MquaityA1SM&lt;/a&gt;  It wasn't the best on relaying the keystrokes to the audience because IIRC he wasn't using a key-caster, but it was definitely an eye-opener, and the mentality he imparts is worth more than anything else.  Keep it in mind when you find yourself wanting to resort to the familiar and easy (e.g., the cursor keys, mouse, or opening a bunch of windows or tabs); it's a good remedy for that.  The rest of the videos or guides, you'll have to dig for on your own because that's how you learn!  Good luck!&lt;/p&gt;&#xA;" OwnerUserId="12030" LastEditorUserId="12030" LastEditDate="2017-04-03T11:33:05.607" LastActivityDate="2017-04-03T11:33:05.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11949" PostTypeId="1" CreationDate="2017-04-02T23:25:42.657" Score="1" ViewCount="674" Body="&lt;h1&gt;The problem:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I am getting nothing in return for the &lt;code&gt;tempname()&lt;/code&gt; function in Vim. More specifically, I kept getting only &quot;.do&quot; assigned to the variable &lt;code&gt;temp&lt;/code&gt; using the following statement.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; let temp = tempname() . &quot;.do&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The complete function that fails to get itself a &quot;temp name&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let selectedLines = getbufline('%', line(&quot;'&amp;lt;&quot;), line(&quot;'&amp;gt;&quot;))&#xA;if col(&quot;'&amp;gt;&quot;) &amp;lt; strlen(getline(line(&quot;'&amp;gt;&quot;)))&#xA;    let selectedLines[-1] = strpart(selectedLines[-1], 0, col(&quot;'&amp;gt;&quot;))&#xA;endif&#xA;if col(&quot;'&amp;lt;&quot;) != 1&#xA;    let selectedLines[0] = strpart(selectedLines[0], col(&quot;'&amp;lt;&quot;)-1)&#xA;endif&#xA;let temp = tempname() . &quot;.do&quot;&#xA;call writefile(selectedLines, temp)&#xA;&quot; *** CHANGE PATH AND NAME TO REFLECT YOUR SETUP. USE \\ INSTEAD OF \ ***&#xA;exec &quot;!start C:\\Vim\\vimfiles\\ftplugin\\Stata-Vim-Suite\\rundo.exe &quot; . temp&#xA;&quot; Delete the temp file after Vim closes&#xA;au VimLeave * exe &quot;!del -y&quot; temp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The above codeblock is supposed to be the body of function define with&lt;code&gt;fun! RunDoLines()&lt;/code&gt; on line-1, and &lt;code&gt;endfun&lt;/code&gt; on the last line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Remark&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This functions has been running very well for years, and it was only today that it should have failed on both of my Windows machines. (I use this function to send commands from Vim to the terminal of a statistical software.)&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Things that I tried, but did not work&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I followed the instruction on the &lt;a href=&quot;http://vim.wikia.com/wiki/Fix_errors_that_relate_to_reading_or_creating_files_in_the_temp_or_tmp_environment_on_an_MS_Windows_PC&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page (vim.wikia)&lt;/a&gt;, but &lt;code&gt;tempname()&lt;/code&gt; still gets me an empty string. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Related problems&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Additionally, here goes the error message I get when trying to run &lt;code&gt;PlugInstall&lt;/code&gt; through &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim-Plug&lt;/a&gt;. I think this should also be related with my setting for the TEMP files.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0MBNx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0MBNx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Minimal replication case:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Issuing the following set of commands does not get me any output.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let temp_file = tempname()&#xA;:echo temp_file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here goes a screenrecord demonstrating the problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kSjbE.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kSjbE.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2398" LastEditorUserId="205" LastEditDate="2017-04-04T05:37:17.367" LastActivityDate="2017-04-04T09:34:45.830" Title="How to fix the tempname() function on Windows 10?" Tags="|vimscript|gvim|microsoft-windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11950" PostTypeId="2" ParentId="11945" CreationDate="2017-04-03T02:39:26.453" Score="3" Body="&lt;p&gt;You can search the default syntax with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /javaParen/ $VIMRUNTIME/syntax/*.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will see that it is in &lt;code&gt;$VIMRUNTIME/syntax/java.vim&lt;/code&gt;, but it's a syntax region &lt;code&gt;matchgroup&lt;/code&gt;.  A &lt;code&gt;matchgroup&lt;/code&gt; allows you to use &lt;code&gt;highlight&lt;/code&gt; to only affect the matches for &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; on syntax regions, but not the text between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like there are actually three syntax regions for &lt;code&gt;()&lt;/code&gt; and &lt;code&gt;[]&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; catch errors caused by wrong parenthesis&#xA;syn region  javaParenT  transparent matchgroup=javaParen  start=&quot;(&quot; end=&quot;)&quot; contains=@javaTop,javaParenT1&#xA;syn region  javaParenT1 transparent matchgroup=javaParen1 start=&quot;(&quot; end=&quot;)&quot; contains=@javaTop,javaParenT2 contained&#xA;syn region  javaParenT2 transparent matchgroup=javaParen2 start=&quot;(&quot; end=&quot;)&quot; contains=@javaTop,javaParenT  contained&#xA;syn match   javaParenError   &quot;)&quot;&#xA;&quot; catch errors caused by wrong square parenthesis&#xA;syn region  javaParenT  transparent matchgroup=javaParen  start=&quot;\[&quot; end=&quot;\]&quot; contains=@javaTop,javaParenT1&#xA;syn region  javaParenT1 transparent matchgroup=javaParen1 start=&quot;\[&quot; end=&quot;\]&quot; contains=@javaTop,javaParenT2 contained&#xA;syn region  javaParenT2 transparent matchgroup=javaParen2 start=&quot;\[&quot; end=&quot;\]&quot; contains=@javaTop,javaParenT  contained&#xA;syn match   javaParenError   &quot;\]&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;javaParenT&lt;/code&gt;, &lt;code&gt;javaParenT1&lt;/code&gt;, and &lt;code&gt;javaParenT2&lt;/code&gt; are the syntax group names.  &lt;code&gt;javaParen&lt;/code&gt;, &lt;code&gt;javaParen1&lt;/code&gt;, and &lt;code&gt;javaParen2&lt;/code&gt; are the highlight &lt;code&gt;matchgroup&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each one contains the next, allowing you to highlight nested braces.  So, what you want is already covered.  You just need to add highlights for them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight link javaParen Special&#xA;highlight link javaParen1 Keyword&#xA;highlight link javaParen2 Type&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's a screenshot with the highlights above:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/O8xcO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/O8xcO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-04-03T02:39:26.453" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11951" PostTypeId="1" AcceptedAnswerId="11952" CreationDate="2017-04-03T06:29:14.243" Score="0" ViewCount="19499" Body="&lt;p&gt;I want to find the string enclosed by string1 and string2 and replace it with something else. I got a few lines that look something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some_string_and_string1_some_rndom_string_string2_and_more&#xA;sme_string_and_string1_some_random_string_string2_and_more&#xA;some_string_and_string1_some_random_string_string2_and_mre&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought the regex to match everything enclosed by string1 and string2 is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^string1.*string2$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the regex would match&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;string1_some_rndom_string_string2&#xA;string1_some_random_string_string2&#xA;string1_some_random_string_string2&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I select the lines and try &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/^string1.*string2$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Pattern not found: ^string1.*string2$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="12032" LastActivityDate="2017-04-03T07:24:40.843" Title="How to regex everything that is enclosed between two certain strings in visual selection" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11952" PostTypeId="2" ParentId="11951" CreationDate="2017-04-03T07:13:35.573" Score="4" Body="&lt;p&gt;Don't use &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt;. &lt;code&gt;^&lt;/code&gt; is &lt;code&gt;start of a line&lt;/code&gt; - which means that expression you're looking for needs to be at the very beginning of a line.&#xA;The same goes for &lt;code&gt;$&lt;/code&gt;, which means &lt;code&gt;end of a line&lt;/code&gt;. In you're case there is something between &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;string1&lt;/code&gt;/&lt;code&gt;$&lt;/code&gt; and &lt;code&gt;string2&lt;/code&gt;, and regex expects that &lt;code&gt;string1&lt;/code&gt; will be first, and it finds &lt;code&gt;some_string_and_&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;string1.*string2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be enough. &lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-04-03T07:13:35.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11953" PostTypeId="2" ParentId="11951" CreationDate="2017-04-03T07:24:40.843" Score="0" Body="&lt;p&gt;Another thing to look at is if you have &lt;code&gt;set nomagic&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;help magic&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Examples:&#xA;after:    \v       \m       \M       \V         matches&#xA;                'magic' 'nomagic'&#xA;          $        $        $        \$         matches end-of-line&#xA;          .        .        \.       \.         matches any character&#xA;          *        *        \*       \*         any number of the previous atom&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can temporarily change it with &lt;code&gt;\m&lt;/code&gt; (or &lt;code&gt;\v&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\mstring1.*string2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/string1\.\*string2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-04-03T07:24:40.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11954" PostTypeId="1" CreationDate="2017-04-03T09:31:39.470" Score="0" ViewCount="339" Body="&lt;p&gt;When I am doing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &quot;&quot; ``&quot;&amp;lt;++&amp;gt;&amp;lt;esc&amp;gt;4hi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it is working perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, what I actually want is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &quot;&quot; &quot;&quot;&amp;lt;++&amp;gt;&amp;lt;esc&amp;gt;4hi&#xA;au FileType *.tex inoremap &quot;&quot; ``&quot;&amp;lt;++&amp;gt;&amp;lt;esc&amp;gt;4hi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, with this setting, in foo.tex, I am still getting the inoremap, not the ``&quot;&quot;  for the tex file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am doing wrong here?&lt;/p&gt;&#xA;" OwnerUserId="2738" LastActivityDate="2017-04-03T09:39:56.193" Title="au filetype mapping is not working" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11955" PostTypeId="2" ParentId="11954" CreationDate="2017-04-03T09:37:09.690" Score="3" Body="&lt;p&gt;The &lt;code&gt;pat&lt;/code&gt; for the &lt;code&gt;FileType&lt;/code&gt; autocommand event should be a file &lt;em&gt;type&lt;/em&gt;, not a file &lt;em&gt;name&lt;/em&gt;. Try this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType tex inoremap &quot;&quot; ``&quot;&amp;lt;++&amp;gt;&amp;lt;esc&amp;gt;4hi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-04-03T09:39:56.193" LastActivityDate="2017-04-03T09:39:56.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11956" PostTypeId="1" AcceptedAnswerId="11958" CreationDate="2017-04-03T11:19:39.910" Score="5" ViewCount="577" Body="&lt;p&gt;I'm trying to understand how &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#packages&quot; rel=&quot;noreferrer&quot;&gt;the &lt;code&gt;packages&lt;/code&gt; feature in Vim 8&lt;/a&gt; works. The documentation suggests doing the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    % mkdir -p ~/.vim/pack/foo&#xA;    % cd ~/.vim/pack/foo&#xA;    % unzip /tmp/foopack.zip&#xA;&#xA; The directory name &quot;foo&quot; is arbitrary, you can pick anything you like.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this example, &lt;strong&gt;what is the point of the &lt;code&gt;foo&lt;/code&gt; directory&lt;/strong&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I plan to use the &lt;code&gt;packages&lt;/code&gt; feature in much the same way that I used &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;pathogen&lt;/code&gt;&lt;/a&gt;. For my purposes, I can install plugins like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ~/.vim/pack/bundle/opt&#xA;mkdir -p ~/.vim/pack/bundle/start&#xA;cd ~/.vim/pack/bundle/start&#xA;git clone git@github.com:tpope/vim-unimpaired.git&#xA;git clone git@github.com:tpope/vim-fugitive.git&#xA;git clone ...etc...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Following the convention in &lt;code&gt;pathogen&lt;/code&gt;, I've used the name &lt;code&gt;bundle&lt;/code&gt; for the directory. I can then install all of my plugins into the &lt;code&gt;~/.vim/pack/bundle/start&lt;/code&gt; directory. If for some reason I want to install a plugin that I use only occasionally, I can put it in the &lt;code&gt;~/.vim/pack/bundle/opt&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything to be gained from creating a sibling to the &lt;code&gt;bundle&lt;/code&gt; directory? It feels to me like this level in the directory tree is unnecessary, but I'm assuming that it's there for some reason.&lt;/p&gt;&#xA;" OwnerUserId="10929" LastActivityDate="2017-04-03T15:09:36.843" Title="Can I have multiple `pack` directories?" Tags="|packages|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11957" PostTypeId="2" ParentId="11933" CreationDate="2017-04-03T11:46:29.497" Score="4" Body="&lt;p&gt;Alternatively, since you're appending and repeating, you could use a macro:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Press &lt;code&gt;qqA /abc/aaa/abc/ESCq&lt;/code&gt;  Note: &quot;ESC&quot; means to press your escape key, don't literally type ESC.  Also, notice the literal space after &lt;code&gt;A&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;qq&lt;/code&gt; and &lt;code&gt;q&lt;/code&gt; are to start recording a macro to register q, and end the macro, respectively.  From there, just go to any single line you'd like to append this text to and type &lt;code&gt;@q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Macros can also be repeated, so if you had say 4 lines in a row that you wanted to make this change to, you could add a &lt;code&gt;j&lt;/code&gt; at the end of the macro like so: &lt;code&gt;qqA /abc/aaa/abc/ESCjq&lt;/code&gt;  Then, with the cursor on the first (top) of the four lines, you could do &lt;code&gt;4@q&lt;/code&gt; and all 4 lines will be appended to.&lt;/p&gt;&#xA;" OwnerUserId="12030" LastActivityDate="2017-04-03T11:46:29.497" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11958" PostTypeId="2" ParentId="11956" CreationDate="2017-04-03T12:12:46.913" Score="4" Body="&lt;h1&gt;Yes, you can have multiple &lt;code&gt;pack&lt;/code&gt; directories&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;In the example you quote from the documentation, &quot;foo&quot; is the name of the package.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your example, you've created a single package named &quot;bundle&quot;. You could indeed create other subdirectories of the &lt;code&gt;pack&lt;/code&gt; directory: each of these would be another package.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's not necessarily any benefit for &lt;em&gt;you&lt;/em&gt; to create any siblings to &lt;code&gt;bundle&lt;/code&gt;, but that doesn't mean the entire level is unnecessary. The idea is that a single Vim package can contain multiple plugins (which might depend on each other). The entire package can then easily be installed or removed with a single action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For what it's worth, I'm not personally aware of anyone actually exercising this aspect of the feature for anything useful, although like you I'd presume it was created to service an actual need some users have, and not just for the purposes of hypothetical flexibility. Maybe at some point in the future the de facto standard would be for even single plugins to be distributed as packages, making your &quot;bundle&quot; directory unnecessary.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-04-03T13:45:02.687" LastActivityDate="2017-04-03T13:45:02.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11959" PostTypeId="1" CreationDate="2017-04-03T13:06:39.453" Score="1" ViewCount="274" Body="&lt;p&gt;I use &lt;code&gt;vim&lt;/code&gt; as a pager with &lt;a href=&quot;http://github.com/rkitover/vimpager/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vimpager&lt;/code&gt;&lt;/a&gt; and a &lt;a href=&quot;https://github.com/rkitover/vimpager/issues/212#issuecomment-281179950&quot; rel=&quot;nofollow noreferrer&quot;&gt;script&lt;/a&gt; to change between pager and full &lt;code&gt;vim&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But pressing &lt;code&gt;i&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt;, etc change the mode while paging, which I want to prevent from happening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;map i &amp;lt;Nop&amp;gt;&lt;/code&gt; and it works, but then I cannot restore the original behaviour, when switching to full &lt;code&gt;vim&lt;/code&gt; mode.&lt;/p&gt;&#xA;" OwnerUserId="4432" LastActivityDate="2017-05-03T16:56:17.017" Title="disabling all mode changes" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11960" PostTypeId="1" CreationDate="2017-04-03T14:47:32.747" Score="3" ViewCount="386" Body="&lt;p&gt;I keep my passwords in PGP encrypted file. When I need to edit this file, then I first decrypt it(&lt;code&gt;gpg -d ...&lt;/code&gt;), open the plain-text file in &lt;code&gt;vim&lt;/code&gt; and make the changes, encrypt the plain-text file(&lt;code&gt;gpg --output data.gpg --encrypt --recipient ...&lt;/code&gt;) and finally remove the plain-text file. How can I be absolutely sure that &lt;code&gt;vim&lt;/code&gt; does not store any sensitive data anywhere else than in this plain-text file? I guess I need to disable &lt;code&gt;viminfo&lt;/code&gt; and it probably it makes sense to disable plugins as well? So if I use &lt;code&gt;vim -i NONE -u NONE plain-text-file&lt;/code&gt;, then I should be secure?&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2017-04-03T14:47:32.747" Title="How to execute vim when one needs to edit sensitive data?" Tags="|security|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11961" PostTypeId="2" ParentId="11956" CreationDate="2017-04-03T15:09:36.843" Score="2" Body="&lt;p&gt;&lt;em&gt;Having done a bit more reading and thinking about this, I'm posting an answer to my own question.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A plugin contains one or more &lt;code&gt;.vim&lt;/code&gt; files which add new functionality &lt;a href=&quot;http://vimhelp.appspot.com/usr_05.txt.html#standard-plugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;globally&lt;/a&gt; or for a &lt;a href=&quot;http://vimhelp.appspot.com/usr_05.txt.html#ftplugins&quot; rel=&quot;nofollow noreferrer&quot;&gt;particular filetype&lt;/a&gt;. Plugins are usually organised using one or more of these subdirectories:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;plugin    -  global commands/mappings (loaded on startup)&#xA;ftplugin  -  ftplugin functions (loaded for the specified filetype)&#xA;autoload  -  library functions (loaded lazily)&#xA;doc       -  documentation&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A package contains one or more plugins. &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#package-create&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h package-create&lt;/code&gt;&lt;/a&gt; shows how to create a package. Packages are organised using these subdirectories:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;start  -  for most plugins, loaded on startup&#xA;opt    -  for optional plugins, loaded when user runs `:packadd`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can have as many packages as you like. The only constraint being that each one has to have a different name (since sibling directories can't have the same name).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's possible to publish a package that contains a set of related plugins. I can't find any such packages on GitHub, but maybe these will emerge over time (the packages feature hasn't been around for long). At the same time, it's perfectly valid to build up a single monolithic &lt;code&gt;bundle&lt;/code&gt; package for personal use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've started to use &lt;a href=&quot;https://github.com/nelstrom/minpac&quot; rel=&quot;nofollow noreferrer&quot;&gt;minpac&lt;/a&gt; to manage the plugins in my package and I'm liking it.&lt;/p&gt;&#xA;" OwnerUserId="10929" LastActivityDate="2017-04-03T15:09:36.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11962" PostTypeId="1" CreationDate="2017-04-03T16:54:58.257" Score="4" ViewCount="177" Body="&lt;p&gt;Is there a way, if the 'number' option is enabled to show line numbers, to make YouCompleteMe show errors and warnings by changing the line number colours instead of adding extra width to the gutter to show &quot;&gt;&gt; &quot;?&lt;/p&gt;&#xA;" OwnerUserId="12044" LastActivityDate="2017-09-16T22:58:32.243" Title="Sharing gutter space between line numbers and YCM markers" Tags="|plugin-you-complete-me|line-numbers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11963" PostTypeId="2" ParentId="11959" CreationDate="2017-04-03T16:54:59.170" Score="1" Body="&lt;p&gt;For my configuration for using Vim as a MANPAGER, I &lt;a href=&quot;https://github.com/murukeshm/vim-manpager/blob/master/ftplugin/man.vim#L53&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;set nomodifiable&lt;/code&gt;&lt;/a&gt;. With that, Vim doesn't allow me to enter an editing mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E21: Cannot make changes, 'modifiable' is off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't block visual mode, of course, which makes it all the more convenient.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-04-03T16:54:59.170" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11964" PostTypeId="1" AcceptedAnswerId="12154" CreationDate="2017-04-03T17:35:52.773" Score="2" ViewCount="1756" Body="&lt;p&gt;Vim keeps a stack of tags (displayable with &lt;code&gt;:tags&lt;/code&gt;) that the user jumps to and from, similar to the jump list (displayable with &lt;code&gt;:jumps&lt;/code&gt;). The jump list can be cleared with the &lt;code&gt;:clearjumps&lt;/code&gt; command. This is convenient because I can jump to the “root” of where I'm working, clear the jump list, and if I ever need to return there I can simply hold CTRL-O to “unwind” all the way to where I started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In theory, one could do the same thing with tags: jump to the initial point of interest, clear the tag stack, navigate “more deeply” into the program by following tags with CTRL-], then hold CTRL-T to pop all the way back up to the tag that was initially jumped to. The problem is that there doesn't appear to be a corresponding &lt;code&gt;:cleartags&lt;/code&gt; command for step two, and it’s quite easy to accidentally jump past the first tag and end up somewhere I have no reason to be (usually the first line of whichever file happened to be the first argument to Vim). So my question is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Am I correct in thinking that there's nothing like a &lt;code&gt;:cleartags&lt;/code&gt; command?&lt;/li&gt;&#xA;&lt;li&gt;If so, is there a workaround? Could it be implemented as a Vimscript function? (A quick search through the builtin functions didn’t yield anything that could be used to manipulate or even access the tag stack.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I’m using Vim 8.0 with patches 1–427 and most optional features compiled in.&lt;/p&gt;&#xA;" OwnerUserId="1153" LastEditorUserId="1153" LastEditDate="2017-04-03T20:06:26.760" LastActivityDate="2017-05-19T16:08:41.540" Title="Is it possible to clear the tag stack without jumping anywhere?" Tags="|tags|jumplist|navigation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11965" PostTypeId="1" CreationDate="2017-04-03T19:24:41.017" Score="8" ViewCount="562" Body="&lt;p&gt;I wrote short macro that helps me grep for the word under the cursor. Here it is in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a=&quot;:! git grep ^R^W^M&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I open vim and run &lt;code&gt;:reg a&lt;/code&gt;, I see the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;a   :! git grep ^R^W^M^J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see an ^J has been added to the macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remove the ^M in my script, then the ^J disappears also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems the ^J acts similar to ^M. So, it's like I have two ^M. This isn't what I want, because I can't see the result of my command. The window just flashes before I can read it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have gotten my script to work by pasting and then copying it. The problem only arises when I try to load it using my .vimrc.&lt;/p&gt;&#xA;" OwnerUserId="12047" LastActivityDate="2017-04-04T01:42:39.550" Title="Why does vim add ^J to the end of my macros?" Tags="|vimrc|external-command|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11966" PostTypeId="1" CreationDate="2017-04-03T21:24:23.467" Score="1" ViewCount="264" Body="&lt;p&gt;Let's say I have ten splits as follows: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|0|1|2|3|4|&#xA;|5|6|7|8|9|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I now try to reduce the width of split 1 to be able to increase split 3 quite a bit (whoever wrote that particular file, used fairly long lines).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that when I attempt to change the size of split 1 with &lt;code&gt;Ctrl+w &amp;lt;&lt;/code&gt; , the extra space goes to split 0, and if I attempt to correct that by changing the size of split 0, the only split I can get to change is split 1.&#xA;Similarly, changing the size of splits 2 or 3 only also affects split 4; changing split 4 only affects split 3. &#xA;So in short, I fail in my attempts to move the divider located between splits 1 and 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get around this? I have not yet attempted to get the mouse involved (would like to try to avoid that, if possible).&lt;/p&gt;&#xA;" OwnerUserId="12049" LastEditorUserId="51" LastEditDate="2017-04-04T13:42:44.773" LastActivityDate="2018-03-31T12:46:41.453" Title="How to obtain fine-grained control over split sizes when using a large number of splits?" Tags="|vim-windows|split|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11967" PostTypeId="2" ParentId="11965" CreationDate="2017-04-04T01:42:39.550" Score="1" Body="&lt;p&gt;For whatever weird reason, it works fine if you replace the &lt;code&gt;^M^J&lt;/code&gt; with &lt;code&gt;^J&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=&quot;:! git grep \&amp;lt;c-r&amp;gt;\&amp;lt;c-w&amp;gt;\&amp;lt;c-j&amp;gt;&quot;&#xA;:reg a&#xA;&quot;a   :! git grep ^R^W^J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;@a&lt;/code&gt; works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I'm using &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-string&quot; rel=&quot;nofollow noreferrer&quot;&gt;the &lt;code&gt;\&amp;lt;...&amp;gt;&lt;/code&gt; notation&lt;/a&gt; since it is easier to copy paste.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Technically, &lt;code&gt;^M&lt;/code&gt; is the carriage return and &lt;code&gt;^J&lt;/code&gt; is the newline. I'm not sure how the difference matters in this case.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-04-04T01:42:39.550" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11968" PostTypeId="1" AcceptedAnswerId="11978" CreationDate="2017-04-04T06:47:10.413" Score="3" ViewCount="128" Body="&lt;p&gt;Is there any way to tell vim to use the NUL character as the end-of-line marker instead of LF, CR/LF, or CR?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More generally, is it possible to use any arbitrary character or sequence of characters as the EOL marker?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: I &lt;strong&gt;do not&lt;/strong&gt; want to convert line endings. I know how to do that, I've been doing it for years.  I have some pseudo-XML files that use NUL as the &quot;line&quot; separator and want to edit them as they are, without vim treating the file as one huge long line (which is difficult to read and painfully slow to navigate and edit) and without mangling the files by accidentally converting some or all NULs to LFs.&lt;/p&gt;&#xA;" OwnerUserId="4837" LastActivityDate="2017-04-04T13:41:04.433" Title="arbitrary line endings in vim?" Tags="|line-breaks|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11969" PostTypeId="1" CreationDate="2017-04-04T07:16:09.497" Score="1" ViewCount="187" Body="&lt;p&gt;When using curly braces navigation, &lt;code&gt;{&lt;/code&gt;, &lt;code&gt;}&lt;/code&gt;, to move between paragraph, overwrites the &quot;last jump&quot; mark (the one accessible via &lt;code&gt;''&lt;/code&gt;). I would find it more useful if it left this mark untouched. Is there any way to configure vim like this?&lt;/p&gt;&#xA;" OwnerUserId="12054" LastEditorUserId="12054" LastEditDate="2017-04-04T12:59:00.420" LastActivityDate="2017-04-12T09:16:48.523" Title="Stop curly braces navigation from leaving marks" Tags="|mark|navigation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11971" PostTypeId="2" ParentId="11949" CreationDate="2017-04-04T09:34:45.830" Score="2" Body="&lt;h2&gt;Simple and short solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;.vimrc&lt;/code&gt;, drop the following line; and create &lt;code&gt;temp_dir&lt;/code&gt; in the home directory.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $TMP=$HOME . &quot;/temp_dir&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2398" LastActivityDate="2017-04-04T09:34:45.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11972" PostTypeId="1" AcceptedAnswerId="12139" CreationDate="2017-04-04T10:04:24.223" Score="1" ViewCount="59" Body="&lt;p&gt;When I run the &lt;code&gt;tabs&lt;/code&gt; command the file &lt;code&gt;mix.exs&lt;/code&gt; in the same tab as &lt;code&gt;NERDTree&lt;/code&gt;, (i.e. tab 2), but I can't access it, as it seems to be in the background or hidden in some way. How can I bring &lt;code&gt;mix.exs&lt;/code&gt; to the front or even move it to its own tab?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabs                                    &#xA;Tab page 1                               &#xA;    myfuncs/funcs_router.ex              &#xA;Tab page 2                               &#xA;&amp;gt;   NERD_tree_2                          &#xA;    mix.exs                              &#xA;Tab page 3                               &#xA;    myfuncs/docsplug.ex                  &#xA;Press ENTER or type command to continue  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9540" LastEditorUserId="205" LastEditDate="2017-04-04T11:56:50.897" LastActivityDate="2017-04-18T20:02:40.780" Title="How do I select the other files in a tab?" Tags="|vim-windows|tabbed-user-interface|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11973" PostTypeId="2" ParentId="3789" CreationDate="2017-04-04T12:07:46.600" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;https://superuser.com/questions/537453/vim-copy-quoted-string-without-whitespace&quot;&gt;https://superuser.com/questions/537453/vim-copy-quoted-string-without-whitespace&lt;/a&gt; : use &lt;code&gt;2i&quot;&lt;/code&gt; instead of &lt;code&gt;a&quot;&lt;/code&gt;. Also see &lt;code&gt;:help i'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12059" LastActivityDate="2017-04-04T12:07:46.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11974" PostTypeId="1" CreationDate="2017-04-04T12:42:39.890" Score="4" ViewCount="4893" Body="&lt;p&gt;There is some way to &quot;extend&quot; autocomplete functionality (like that one supplied by &lt;a href=&quot;http:///github.com/ervandew/supertab&quot; rel=&quot;nofollow noreferrer&quot;&gt;SuperTab plugin&lt;/a&gt;) to be used in &lt;strong&gt;command line mode&lt;/strong&gt; so I would autocomplete when searching a text with &lt;code&gt;/&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When editing a text, in INSERT mode, I use now superTab plugin, so hitting TAB, a menu appear with possible completions items.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking for a similar feature when searching or editing in command mode (&lt;code&gt;:command&lt;/code&gt;) and/or in serach mode (&lt;code&gt;/searchedtext&lt;/code&gt;), with autocompletion, retrieving from file text words (ore previous commands!). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. if I have the word &lt;code&gt;validate_first&lt;/code&gt; and &lt;code&gt;validate_firstname&lt;/code&gt; inside the file, I would like to have an autocompletion menu when hitting &lt;code&gt;/validate&lt;/code&gt;, with items: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;validate_first&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;validate_firstname&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/U0JO8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/U0JO8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="983" LastEditDate="2017-04-06T19:55:17.677" LastActivityDate="2021-11-27T17:15:49.673" Title="autocompletion in command line/search" Tags="|search|autocompletion|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11975" PostTypeId="1" AcceptedAnswerId="11986" CreationDate="2017-04-04T12:46:08.190" Score="2" ViewCount="893" Body="&lt;p&gt;There is any solution to highlight the entire line where a mark has been inserted (e.g. with command &lt;code&gt;ma&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best could be to have marked each mark with a different color of choice. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;br&gt;&#xA;giorgio  &lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="983" LastEditDate="2017-04-04T14:18:42.743" LastActivityDate="2017-04-06T14:31:53.110" Title="marks with fullline visualization" Tags="|highlight|mark|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11976" PostTypeId="1" AcceptedAnswerId="11985" CreationDate="2017-04-04T13:03:15.360" Score="6" ViewCount="317" Body="&lt;p&gt;I am copying a word with: &lt;code&gt;viwy&lt;/code&gt; (visual, inner, word, yank)&#xA;Now I would like to replace some other word: &lt;code&gt;viwp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works only once, because each word is replaced by the last removed word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, so I use yanked register: &lt;code&gt;viw&quot;0p&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is only one problem: when I try to repeat that command using the dot operator, it does not work! I have to write &lt;code&gt;viw&quot;0p&lt;/code&gt; again which is cumbersome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does the shortcut not work? How to make it work?&lt;/p&gt;&#xA;" OwnerUserId="12060" LastEditorUserId="11771" LastEditDate="2017-04-06T08:15:31.210" LastActivityDate="2017-04-06T08:17:45.157" Title="Why copying from named register cannot be repeated using dot operator?" Tags="|cut-copy-paste|replace|repeated-commands|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11977" PostTypeId="1" AcceptedAnswerId="12007" CreationDate="2017-04-04T13:28:59.320" Score="2" ViewCount="1855" Body="&lt;p&gt;Given the following code in visual mode :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  {&#xA;    some text&#xA;    ^ cursor&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if I type &lt;code&gt;a{&lt;/code&gt; this will be selected : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  { &amp;lt; selection start&#xA;    some text&#xA;  } &amp;lt; selection end&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to repeat the last selection command to expand my selection to include the enclosing brackets with &lt;code&gt;.&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ &amp;lt; selection start&#xA;  { &#xA;    some text&#xA;  } &#xA;} &amp;lt; selection end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know I can do it by repeating &lt;code&gt;a{&lt;/code&gt; but I prefer to use &lt;code&gt;.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have installed &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-repeat&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4542" LastEditorUserId="1292" LastEditDate="2019-02-08T12:43:52.020" LastActivityDate="2019-02-08T12:43:52.020" Title="Expand visual selection of surrounding code blocks by the dot command" Tags="|visual-mode|repeated-commands|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11978" PostTypeId="2" ParentId="11968" CreationDate="2017-04-04T13:41:04.433" Score="2" Body="&lt;p&gt;If you look at the &lt;code&gt;buf_write()&lt;/code&gt; function in &lt;code&gt;fileio.c&lt;/code&gt; (&lt;em&gt;&quot;abandon all hope ye who enter here&quot;&lt;/em&gt;, we see (slightly simplified):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (fileformat == EOL_UNIX)&#xA;    *s++ = NL;&#xA;else&#xA;{&#xA;    *s++ = CAR;                 /* EOL_MAC or EOL_DOS: write CR */&#xA;    if (fileformat == EOL_DOS)  /* write CR-NL */&#xA;        *s++ = NL;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/master/src/fileio.c#L4585&quot; rel=&quot;nofollow noreferrer&quot;&gt;Full source here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While you could easily add a NULL byte to the end of lines with a &lt;code&gt;BufWritePre&lt;/code&gt; autocommand, I  see no functionality to &lt;em&gt;not&lt;/em&gt; write a &lt;code&gt;NL&lt;/code&gt; or &lt;code&gt;CRNL&lt;/code&gt; here, so you'd end up with NULL + NL.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-04-04T13:41:04.433" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11979" PostTypeId="1" CreationDate="2017-04-04T14:16:47.753" Score="2" ViewCount="257" Body="&lt;p&gt;In past I asked the question about how to create syntax specifications for ChatScript, a new programming language unforeseen in standard programming languages vim set (see: &lt;a href=&quot;https://vi.stackexchange.com/questions/8955/vim-syntax-highlighting-for-chatscript-language&quot;&gt;Vim syntax highlighting for ChatScript language?&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I eventually created myself the couple of (draft) files: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/syntax/ChatScript.vim&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/ftdetect/ChatScript.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What's the standard way to share a new language highlights files proposal ? &#xA;There is any vim guideline to how to share? With a github repo?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks&lt;br&gt;giorgio&lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.400" LastActivityDate="2017-04-05T16:39:39.800" Title="How to share syntax highlights files for a &quot;new&quot; language?" Tags="|syntax-highlighting|colorscheme|highlight|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11980" PostTypeId="1" AcceptedAnswerId="11983" CreationDate="2017-04-04T14:31:23.540" Score="4" ViewCount="1217" Body="&lt;p&gt;One can configure Vim to use temporary files(stored in &lt;code&gt;/tmp&lt;/code&gt; directory by default) when shell commands(for example &lt;code&gt;:%!ls&lt;/code&gt;) are executed. Those temporary files contain the output of an external command. With &lt;code&gt;set noshelltemp&lt;/code&gt; pipes are used instead. However, why is it necessary for Vim to use temporary file or pipe for shell commands in the first place?&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2017-04-04T17:48:00.700" Title="Why does vim use temporary file or pipe for shell commands?" Tags="|external-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11981" PostTypeId="1" CreationDate="2017-04-04T14:57:15.613" Score="3" ViewCount="1284" Body="&lt;p&gt;Of course I can just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let dir = globpath('path', '*', 0, 1)&#xA;for file in dir&#xA;   if (isdirectory(file))&#xA;       add(myDirList, file)&#xA;   endif&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this will have to go through all the files in the directory and when the list is large this can take quite a long time. Is there a more efficient way of doing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Response to @Luc Hermitte&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Testing &lt;code&gt;globpath()&lt;/code&gt; and &lt;code&gt;for&lt;/code&gt; loop together: 66.73 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Testing &lt;code&gt;globpath()&lt;/code&gt; and &lt;code&gt;filter&lt;/code&gt; together: 64.11 seconds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple things to note about my specific situation.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I'm trying to access a network drive.&lt;/li&gt;&#xA;&lt;li&gt;My first tests where done on wifi. I've connected with a hard wire and times have been reduced by about 25%.&lt;/li&gt;&#xA;&lt;li&gt;The directory I'm accessing has ~2500 files/directories on it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've now tested the individual times on a hard wire connection and got the following times:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;globpath()&lt;/code&gt;: 40.19 seconds&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;for&lt;/code&gt; loop: 4.96 seconds&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;filter&lt;/code&gt;: 4.91 seconds&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;system('dir &quot;path&quot;')&lt;/code&gt;: 0.17 seconds...  (I'm on Windows obviously)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Not sure why &lt;code&gt;for&lt;/code&gt; and &lt;code&gt;filter&lt;/code&gt; are so close when I got better results with &lt;code&gt;filter&lt;/code&gt; before...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yeah, the external is magnitudes faster. You think this deserves a bug report?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I used &lt;code&gt;globpath()&lt;/code&gt; because I didn't want to &lt;code&gt;cd&lt;/code&gt; to the directory, but now I know that's not necessary.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-04-07T17:17:32.913" LastActivityDate="2017-04-07T17:17:32.913" Title="How to obtain all directories from a path efficiently" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11982" PostTypeId="2" ParentId="11981" CreationDate="2017-04-04T16:57:38.723" Score="3" Body="&lt;p&gt;&lt;code&gt;:for&lt;/code&gt; loops are a performance nightmare.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Always prefer &lt;code&gt;map()&lt;/code&gt; and &lt;code&gt;filter()&lt;/code&gt; when you can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, it would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let dir = globpath('path', '*', 0, 1)&#xA;call filter(dir, 'isdirectory(v:val)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-04-04T16:57:38.723" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11983" PostTypeId="2" ParentId="11980" CreationDate="2017-04-04T17:48:00.700" Score="6" Body="&lt;p&gt;How else do you expect Vim to retrieve the output of the commands?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your &lt;code&gt;:%!ls&lt;/code&gt; writes the contents of the buffer to &lt;code&gt;ls&lt;/code&gt;'s stdin, reads the stdout from ls, and replaces the contents of the buffer with that data from stdout (see &lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#filter&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help filter&lt;/code&gt;&lt;/a&gt;).  In order to do that, Vim needs to be able to read the output, so it uses a pipe or temp file depending on how you have &lt;code&gt;'shelltemp'&lt;/code&gt; set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all you want to do is &lt;em&gt;run&lt;/em&gt; a command without feeding the data back into Vim, then that's a different matter&lt;sup&gt;1&lt;/sup&gt;.  Then Vim can just run the command and let the terminal show you the output, with no intermediate files or pipes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;: Well, it's a different matter if you're running in the terminal.  If you're running gvim, then it has to do the same thing so the output of the command can be displayed in gvim's window.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-04-04T17:48:00.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11984" PostTypeId="1" AcceptedAnswerId="12020" CreationDate="2017-04-04T19:36:03.853" Score="2" ViewCount="118" Body="&lt;p&gt;First off, I'm writing this for my setup at work, which is entirely on Windows. I'd imagine it would be quite a bit easier if I was able to use a proper terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've written a function in my vimrc that lets me run a syntax checker for the obscure programming language we use here. I'd like to read the output from that syntax checker into a variable in the function, which I can then use to set some linenumber marks or output to a temp buffer (like Syntastic).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I browsed through the helpfile and found redir =&gt;, but it doesn't seem to work like I'd expect it to.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; SYNTAX CHECK FOR PROGRESS&#xA;&quot; =========================&#xA;function! CheckSyntaxCustom()&#xA;  if (&amp;amp;ft=='progress')&#xA;  redir =&amp;gt; progress_output&#xA;    :execute '0read !c:\progress\openedge11_3\bin\_progres.exe -1 -b -Mm 16384 -pf c:\progress\openedge11_3\startup.pf -p c:\code\custom\syntax.p -param %:p'&#xA;  redir end&#xA;  :echom progress_output&#xA;  endif&#xA;endfunction &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Seems like I can't manipulate progress_output. Ideally I'd like it to return a string that I can then use with :execute, but right now it just pastes the command prompt output to the line below the cursor. I'm fairly new to vimscript so I could be completely wrong on what redir should be used for. Any advice on how to accomplish what I'm looking to do?&lt;/p&gt;&#xA;" OwnerUserId="12064" LastActivityDate="2017-04-07T16:13:37.020" Title="Reading command prompt output into variables - GVIM and Windows" Tags="|vimscript|gvim|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11985" PostTypeId="2" ParentId="11976" CreationDate="2017-04-04T23:03:21.710" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Why does the shortcut not work?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The dot operator '.' repeats the last change, not the last keystrokes/command, as mentioned in &lt;a href=&quot;https://vi.stackexchange.com/q/11210/6590&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The dot operator repeats the last simple change.  &lt;code&gt;viwp&lt;/code&gt; is no longer a simple change, because it's composed of a paste and a delete. From &lt;code&gt;:help put-Visual-mode&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;                                                put-Visual-mode v_p v_P&#xA;When using a put command like p or P in Visual mode, Vim will try to&#xA;replace the selected text with the contents of the register.  Whether this&#xA;works well depends on the type of selection and the type of the text in the&#xA;register.&#xA;...&#xA;(Implementation detail:&#xA;it actually works by first putting the register after the selection and then&#xA;deleting the selection.)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Your put &lt;code&gt;viwp&lt;/code&gt; actually works by first putting the register after the selection and then&#xA;deleting the selection.  So the dot operator saves the &amp;quot;delete the selection&amp;quot; command, and repeats that.  Not the put.&lt;/p&gt;&#xA;&lt;p&gt;You can see the contents of the registers at any time by passing a list of arguments to the &lt;code&gt;:register&lt;/code&gt; command.  For example, to see &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;0&lt;/code&gt;, &lt;code&gt;&amp;quot;1&lt;/code&gt;, &lt;code&gt;&amp;quot;-&lt;/code&gt; and &lt;code&gt;&amp;quot;.&lt;/code&gt; register contents:&#xA;&lt;code&gt;:register &amp;quot;01-.&lt;/code&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;How to make it work?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I would use a macro recording, not the dot operator&lt;/p&gt;&#xA;&lt;p&gt;If I understand your request correctly, you want to change these words&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;first&#xA;second&#xA;do not change&#xA;third&#xA;do not change&#xA;fourth&#xA;do not change&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to this&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;first&#xA;first &#xA;do not change&#xA;first&#xA;do not change&#xA;first&#xA;do not change&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To do that, I would&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;viw&amp;quot;ay&lt;/code&gt; to yank that word &amp;quot;first&amp;quot; to register &lt;code&gt;&amp;quot;a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;motion to the word to replace. In my example, this word is 'second'&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qqviw&amp;quot;apq&lt;/code&gt; to record to register &lt;code&gt;&amp;quot;q&lt;/code&gt; the keystrokes &lt;code&gt;viw&amp;quot;ap&lt;/code&gt;. This will:&#xA;&lt;ol&gt;&#xA;&lt;li&gt;visually select the word, then&lt;/li&gt;&#xA;&lt;li&gt;put the content of register &lt;code&gt;&amp;quot;a&lt;/code&gt; over that selected word, then&lt;/li&gt;&#xA;&lt;li&gt;stop recording&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;move to the next word to replace, type &lt;code&gt;@q&lt;/code&gt; to execute the contents of register &lt;code&gt;&amp;quot;q&lt;/code&gt; as an Ex command.&lt;/li&gt;&#xA;&lt;li&gt;move to the next word, type &lt;code&gt;@@&lt;/code&gt; to repeat the previous &lt;code&gt;@&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;code&gt;@@&lt;/code&gt; is not &lt;code&gt;.&lt;/code&gt;   Maybe someone else can come up with something that uses less keystrokes.  I look forward to learning what that is.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-04-06T08:17:45.157" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11986" PostTypeId="2" ParentId="11975" CreationDate="2017-04-04T23:46:05.597" Score="6" Body="&lt;p&gt;I &lt;a href=&quot;https://github.com/Tumbler/highlightMarks&quot; rel=&quot;nofollow noreferrer&quot;&gt;created a plugin&lt;/a&gt; that I think does what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to change the colors that it uses simply define &lt;code&gt;g:highlightMarks_colors&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt; as a list of colors (either names or RGB strings).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I welcome any feedback you have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screenshot as example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XOkuU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XOkuU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-04-06T14:31:53.110" LastActivityDate="2017-04-06T14:31:53.110" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11987" PostTypeId="1" CreationDate="2017-04-04T23:50:27.017" Score="2" ViewCount="203" Body="&lt;p&gt;What's the quickest (as far as anyone knows) way to change this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main()&#xA;{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main() {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;provided the cursor is on the &lt;code&gt;{&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="11809" LastEditorUserId="343" LastEditDate="2017-04-05T08:31:07.047" LastActivityDate="2017-04-05T08:31:07.047" Title="Quickest way to move bracket at beginning of line to end of above line" Tags="|rearrangement|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11988" PostTypeId="1" AcceptedAnswerId="12022" CreationDate="2017-04-05T00:36:31.360" Score="4" ViewCount="1466" Body="&lt;p&gt;We have &lt;a href=&quot;https://github.com/skammer/vim-css-color&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-css-color&lt;/a&gt; to display colors in .css files. Currently I'm editing my i3wm config to match colors to a new terminal theme and it would be quite handy to be able to actually &lt;em&gt;see colors&lt;/em&gt; I'm dealing with. &lt;strong&gt;Is there a plugin that would highlight colors in any file&lt;/strong&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use the above mentioned plugin by renaming a &lt;code&gt;config&lt;/code&gt; to &lt;code&gt;config.css&lt;/code&gt; but it still misses a couple of colors. Here is a comparison of what &lt;code&gt;atom&lt;/code&gt; (first picture) does and what &lt;code&gt;nvim&lt;/code&gt; (second picture) does:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tZlq6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tZlq6.png&quot; alt=&quot;atom color highlighting&quot;&gt;&lt;/a&gt; &#xA;&lt;a href=&quot;https://i.stack.imgur.com/o2Xvg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/o2Xvg.png&quot; alt=&quot;nvim with vim-css-color highligting&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10540" LastEditorUserId="51" LastEditDate="2017-04-06T18:54:09.033" LastActivityDate="2017-04-07T18:09:21.733" Title="Can I show a color from its hex value in *any* file?" Tags="|syntax-highlighting|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11989" PostTypeId="2" ParentId="11979" CreationDate="2017-04-05T01:43:21.533" Score="3" Body="&lt;p&gt;I'll take a tangent and answer the question that will arise when you start sharing more than a single set of syntax files (and attempt ot make the question more &quot;on-topic&quot; in the process :) ).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There is any vim guideline to how to share?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could say that with Vim 8 there is (although it can be debatable whether it is or it isn't a guideline).  In &lt;code&gt;:help packages&lt;/code&gt; (or &lt;code&gt;:help package-create&lt;/code&gt;) the Vim manual describes a method to disengage files in the directories in &lt;code&gt;.vim&lt;/code&gt; between different packages.  Therefore the first thing you should do before sharing the files is to place them inside such a package.  Instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/syntax/ChatScript.vim&#xA;~/.vim/ftdetect/ChatScript.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should really have something of the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/pack/mypackages/start/ChatScript/syntax/ChatScript.vim&#xA;~/.vim/pack/mypackages/start/ChatScript/ftdetect/ChatScript.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the directory &lt;code&gt;ChatScript&lt;/code&gt; becomes your package and can be distributed in any way you want.  Some examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;With &lt;code&gt;git clone&lt;/code&gt; from github&lt;/li&gt;&#xA;&lt;li&gt;By zipping it together (zip, tar, whatever) and unzipping at the desirable location&lt;/li&gt;&#xA;&lt;li&gt;Symlinks to other user's public folders&lt;/li&gt;&#xA;&lt;li&gt;Constructing a VimBall (but I'd recommend against it since it requires some extra knowledge to install in the right place in Vim 8).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Really, you can distribute it whichever way you find more convenient, and you do not need to distribute it in only a single way either.  On the other hand the first option (&lt;code&gt;git clone&lt;/code&gt;) is quite popular among Vim users.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Extra Notes&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The directory names &lt;code&gt;mypackages&lt;/code&gt; and &lt;code&gt;ChatScript&lt;/code&gt; in the above are completely up to you.  But the names of the other directories are important, and so is the number of subdirectories.  The final objective of Vim packages is to allow for several groups of packages.  For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/pack/mypackages/start/ChatScript/syntax/ChatScript.vim&#xA;~/.vim/pack/mypackages/start/ChatScript/ftdetect/ChatScript.vim&#xA;~/.vim/pack/third-party/start/csv.vim/...&#xA;~/.vim/pack/third-party/start/airline/...&#xA;~/.vim/pack/third-party/opt/django.vim/syntax/...&#xA;~/.vim/pack/third-party/opt/django.vim/plugin/...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;opt&lt;/code&gt; directory there (it is for optionally loaded packages), read the &lt;code&gt;:h packages&lt;/code&gt; or the &lt;a href=&quot;https://vi.stackexchange.com/questions/9522/what-is-the-vim8-package-feature-and-how-should-i-use-it&quot;&gt;relevant question here on vi.SE&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Before Vim 8&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The packages system is not present in Vim 7 and earlier, but it was not born from nothing.  Several plugins offered a very similar system of packaging a distibution of Vim files (syntax, autoloads, etc) into a single directory and align several such directories together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have a &lt;a href=&quot;https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers&quot;&gt;more-or-less complete list of these plugins&lt;/a&gt;, with their descriptions, advantages and disadvantages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From those I always used &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow noreferrer&quot;&gt;pathogen&lt;/a&gt;.  Which I dumped in my &lt;code&gt;~/.vim/autoload/pathogen.vim&lt;/code&gt; using the default &lt;code&gt;~/.vim/bundle&lt;/code&gt; for packages.  The difference from the Vim 8 packages above is that it does not have groups of packages, everything goes into &lt;code&gt;~/.vim/bundle&lt;/code&gt;.  So, the directory structure above would be (actually was):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/bundle/ChatScript/syntax/ChatScript.vim&#xA;~/.vim/bundle/ChatScript/ftdetect/ChatScript.vim&#xA;~/.vim/bundle/csv.vim/...&#xA;~/.vim/bundle/airline/...&#xA;~/.vim/bundle/django.vim/syntax/...&#xA;~/.vim/bundle/django.vim/plugin/...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, to distribute them, it is the same story.  Use any method(s) you like and tell the user to dump into a subdirectory of &lt;code&gt;bundle&lt;/code&gt;.  &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vundle&lt;/a&gt; does the same, just that by default it loads from gihub automatically.  Other plugins can do even more (e.g. check for updates).&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.303" LastActivityDate="2017-04-05T16:39:39.800" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11990" PostTypeId="1" CreationDate="2017-04-05T03:23:25.307" Score="1" ViewCount="45" Body="&lt;p&gt;Is there a way to make &lt;code&gt;gt&lt;/code&gt; work in the opposite way of &lt;code&gt;gT&lt;/code&gt; when given a count?  &lt;code&gt;2gT&lt;/code&gt; moves two tabs to the left.  &lt;code&gt;2gt&lt;/code&gt; moves to the second tab, but I would like to instead move two tabs to the right.  How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="10490" LastEditorUserId="6489" LastEditDate="2017-04-05T04:27:03.087" LastActivityDate="2017-04-05T04:27:03.087" Title="Vim - relative tab navigation" Tags="|key-bindings|tabbed-user-interface|" AnswerCount="0" CommentCount="1" ClosedDate="2017-04-05T04:36:14.697" ContentLicense="CC BY-SA 3.0" />
  <row Id="11991" PostTypeId="1" AcceptedAnswerId="12003" CreationDate="2017-04-05T04:21:44.453" Score="1" ViewCount="946" Body="&lt;p&gt;For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;import matplotlib.pyplot as plt&#xA;x = np.array([-1, 0, 1])&#xA;y = np.abs(x)&#xA;plt.plot(x, y)&#xA;plt.show()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to highlight all the occurrences of &lt;code&gt;np&lt;/code&gt; and &lt;code&gt;plt&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="11755" LastActivityDate="2017-04-06T00:14:39.930" Title="Highlight all imported modules in python" Tags="|syntax-highlighting|filetype-python|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11992" PostTypeId="2" ParentId="11987" CreationDate="2017-04-05T04:32:42.317" Score="1" Body="&lt;p&gt;It actually took me a little while to figure this out on my own, too: &lt;code&gt;dh&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I use a macro for &quot;merging&quot; lines like this: &lt;code&gt;let @m=' 0i ^[0wd0dhi ^['&lt;/code&gt;  This will take the current line, with the cursor positioned anywhere on that line and merge it with the previous line, while inserting a space, and leave you back in NORMAL mode.  Note: the &lt;code&gt;^[&lt;/code&gt; are escapes gotten by typing &lt;code&gt;ctrl-r&amp;lt;Esc&amp;gt;&lt;/code&gt; which is control-r then the esc key.  To be sure you've done it correctly, those two characters will behave as one if you try and move the cursor over them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the above line in your ~/.vimrc or ~/.vimrc.local and then either restart vim or do &lt;code&gt;:source ~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="12030" LastEditorUserId="12030" LastEditDate="2017-04-05T04:38:11.807" LastActivityDate="2017-04-05T04:38:11.807" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11994" PostTypeId="2" ParentId="11966" CreationDate="2017-04-05T04:55:51.457" Score="1" Body="&lt;p&gt;Prefix a number before the split command to reduce it to a desired number of rows or columns: e.g., &lt;code&gt;:10sp&lt;/code&gt; or &lt;code&gt;:20vsp&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;code&gt;:help sp&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="12030" LastActivityDate="2017-04-05T04:55:51.457" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11995" PostTypeId="2" ParentId="11977" CreationDate="2017-04-05T05:07:51.253" Score="0" Body="&lt;p&gt;&lt;code&gt;V4j&lt;/code&gt; (shift-v) works.  I'm not sure repeat will work for you here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, from the top brace, you can simply hit Enter/Return, which will visually select the inner block.  Then press Enter/Return again, and it'll expand to the outer braces as well.&lt;/p&gt;&#xA;" OwnerUserId="12030" LastActivityDate="2017-04-05T05:07:51.253" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11996" PostTypeId="2" ParentId="11987" CreationDate="2017-04-05T05:54:54.910" Score="1" Body="&lt;p&gt;Besides that I think that opening braces on a separate line is the better style, you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\s*{\s*$/-1j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to append all occurences in the whole file of opening braces in a separate line to the previous line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is your coding style (for some no good reason), you can add this to your &lt;code&gt;.vimrc&lt;/code&gt; to be executed automatically when opening source code files.&lt;/p&gt;&#xA;" OwnerUserId="11771" LastActivityDate="2017-04-05T05:54:54.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11997" PostTypeId="2" ParentId="11987" CreationDate="2017-04-05T07:17:13.283" Score="1" Body="&lt;p&gt;you can use the following command in normal mode if cursor is at bracket.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="10157" LastActivityDate="2017-04-05T07:17:13.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11998" PostTypeId="2" ParentId="11879" CreationDate="2017-04-05T07:44:23.890" Score="2" Body="&lt;p&gt;I use symbolic link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ln -s ~/.vim/vimrc ~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6859" LastActivityDate="2017-04-05T07:44:23.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11999" PostTypeId="2" ParentId="11879" CreationDate="2017-04-05T09:04:48.897" Score="22" Body="&lt;p&gt;You don't need any shell configuration to store your &lt;code&gt;.vimrc&lt;/code&gt; file in the &lt;code&gt;.vim&lt;/code&gt; directory. You just need to remove the &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;_&lt;/code&gt; from the filename.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim looks in the following locations by default on startup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Unix (including OS X/macOS):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On Windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%HOMEPATH%\vimfiles\vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See section &lt;strong&gt;II&lt;/strong&gt; of &lt;code&gt;:help .vimrc&lt;/code&gt; for the documentation on this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/a/11881/343&quot;&gt;@Tommy A has already explained&lt;/a&gt;, you can set the location of the &lt;code&gt;viminfo&lt;/code&gt; file by adding the following command to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viminfo+=n~/.vim/viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-04-05T09:45:11.610" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12000" PostTypeId="1" AcceptedAnswerId="12136" CreationDate="2017-04-05T13:06:21.540" Score="3" ViewCount="334" Body="&lt;p&gt;I have this markdown text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;actual result&lt;/strong&gt;: After pressing &lt;code&gt;gq&lt;/code&gt; on this bullet point, its reformatted into the following: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* Lorem Ipsum is simply dummy text of the printing and typesetting industry.&#xA;* Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,&#xA;* when an unknown printer took a galley of type and scrambled it to make a type&#xA;* specimen book.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;desired result&lt;/strong&gt;: But instead, i would like to have the following result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* Lorem Ipsum is simply dummy text of the printing and typesetting industry.&#xA;  Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,&#xA;  when an unknown printer took a galley of type and scrambled it to make a&#xA;  type specimen book. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can i achieve that? I have already played around with &lt;code&gt;:h fo-table&lt;/code&gt; and &lt;code&gt;: h formatexpr&lt;/code&gt; but i haven't found sth useful.&lt;/p&gt;&#xA;" OwnerUserId="2354" LastActivityDate="2017-04-18T18:46:33.297" Title="prevent neovim from breaking one markdown bullet point into multiple ones" Tags="|formatting|filetype-markdown|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12001" PostTypeId="1" CreationDate="2017-04-05T15:56:34.693" Score="2" ViewCount="571" Body="&lt;p&gt;I like using the &lt;a href=&quot;https://ss64.com/bash/syntax-keyboard.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bash shortcuts&lt;/a&gt; while at the command line to move around and edit text. A sample of some commands from the link can be seen below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ctrl + a   Go to the beginning of the line (Home)&#xA;Ctrl + w   Cut the Word before the cursor to the clipboard.&#xA;Ctrl + e   Go to the End of the line (End)&#xA;Ctrl + p   Previous command (Up arrow)&#xA;Ctrl + n   Next command (Down arrow)&#xA;Alt + b    Back (left) one word&#xA;Alt + f    Forward (right) one word&#xA;Ctrl + f   Forward one character&#xA;Ctrl + b   Backward one character&#xA;Alt + d    Delete the Word after the cursor.&#xA;Ctrl + d   Delete character under the cursor&#xA;Ctrl + y   Paste the last thing to be cut (yank)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems like some of these work while in Insert mode; for example &lt;code&gt;Ctrl + w&lt;/code&gt; or &lt;code&gt;Ctrl + u&lt;/code&gt;. However some don't; for example &lt;code&gt;Ctrl + y&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How do I enable Bash shortcuts while in insert mode?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm running macOS: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ProductName:    Mac OS X&#xA;ProductVersion: 10.12.1&#xA;BuildVersion:   16B2657&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 16 2017 06:36:51)&#xA;MacOS X (unix) version&#xA;Included patches: 1-329&#xA;Compiled by Homebrew&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11605" LastEditorUserId="23502" LastEditDate="2022-09-16T16:13:42.660" LastActivityDate="2022-09-16T16:13:42.660" Title="How do I enable Bash keyboard shortcuts while in Insert mode?" Tags="|cursor-movement|macvim|macos|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12002" PostTypeId="2" ParentId="12001" CreationDate="2017-04-05T21:28:14.217" Score="7" Body="&lt;p&gt;Type &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; to temporarily leave insert mode and use normal mode keys instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To create insert mode maps, read &lt;code&gt;:h normal-index&lt;/code&gt; and &lt;code&gt;:h insert-index&lt;/code&gt;.  Then create insert maps that does about the same thing you want.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-a&amp;gt; &amp;lt;c-o&amp;gt;0&#xA;inoremap &amp;lt;c-w&amp;gt; &amp;lt;c-o&amp;gt;db&#xA;inoremap &amp;lt;c-e&amp;gt; &amp;lt;c-o&amp;gt;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason why Vim doesn't have insert mode keys for those operations is simple: &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Vim is a modal editor&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Alternate reason: &lt;em&gt;Vim is not Emacs&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @grochmal pointed out, these are actually Emacs bindings.  In Emacs, you're in insert mode all the time.  Those keys make sense in that context.  In a terminal, you could say that you're in insert mode as well, so again, it makes sense there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim, you're either in insert mode, or not.  Inserting text in Vim is a &lt;strong&gt;transaction&lt;/strong&gt;.  You begin a transaction by entering insert mode and end it by leaving insert mode.  After a transaction is completed, the buffer's state is saved (undo, cursor position, etc).  To use Vim as intended, you insert some text, leave insert mode, then move the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The distinct advantage of a modal text editor is that there's no &quot;shortcuts&quot; or &quot;hotkeys&quot;.  Your entire keyboard is used for text manipulation.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-04-05T21:28:14.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12003" PostTypeId="2" ParentId="11991" CreationDate="2017-04-06T00:14:39.930" Score="2" Body="&lt;p&gt;I wrote a plugin for this: &lt;a href=&quot;https://github.com/tweekmonster/impsort.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;impsort.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UCvTE.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UCvTE.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It originally was only for sorting imports.  Since the imports were being parsed, I threw in highlighting as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not only does it highlight imported modules, it highlights imported classes and functions (if it can figure out their types).&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-04-06T00:14:39.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12004" PostTypeId="1" AcceptedAnswerId="12006" CreationDate="2017-04-06T08:46:13.077" Score="20" ViewCount="6889" Body="&lt;p&gt;I'd like to write a visually selected area to a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;prefix [sample text&#xA;more text] suffix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;[]&lt;/code&gt; is the selected block which should be taken, resulting in a new file containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sample text&#xA;more text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The normal &lt;code&gt;w&lt;/code&gt; command uses lines so &lt;code&gt;'&amp;lt;,'&amp;gt;w! /tmp/test&lt;/code&gt; would include the prefix/suffix (and &lt;code&gt;`&amp;lt;,`&amp;gt;w! /tmp/test&lt;/code&gt; is not allowed).&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2021-08-06T06:17:29.117" Title="Write selected area to file" Tags="|save|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12005" PostTypeId="1" AcceptedAnswerId="12091" CreationDate="2017-04-06T09:30:51.513" Score="3" ViewCount="2961" Body="&lt;p&gt;Let's say that I've got a package set up like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/pack/bundle/start/&#xA;                         vim-unimpaired/&#xA;                         vim-surround/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When Vim starts up, it automatically adds the &lt;code&gt;vim-surround&lt;/code&gt; and &lt;code&gt;vim-unimpaired&lt;/code&gt; directories to my &lt;code&gt;runtimepath&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I've got Vim running, let's say that I add the &lt;code&gt;vim-fugitive&lt;/code&gt; plugin to the &lt;code&gt;start&lt;/code&gt; directory, making my package look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/pack/bundle/start/&#xA;                         vim-unimpaired/&#xA;                         vim-surround/&#xA;                         vim-fugitive/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I make Vim check the &lt;code&gt;start&lt;/code&gt; directory again and add any paths to the &lt;code&gt;runtimepath&lt;/code&gt; that are not already present there?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that if I start a new Vim session, then my &lt;code&gt;runtimepath&lt;/code&gt; will contain all three plugins. I'm curious to know if there's a way of updating the &lt;code&gt;runtimepath&lt;/code&gt; without having to restart Vim.&lt;/p&gt;&#xA;" OwnerUserId="10929" LastActivityDate="2017-04-14T03:20:28.320" Title="Can I make Vim add `pack/*/start/*` directories to `runtimepath` without restarting?" Tags="|packages|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12006" PostTypeId="2" ParentId="12004" CreationDate="2017-04-06T09:34:23.850" Score="13" Body="&lt;p&gt;First, copy (also called 'yank' in vim parlance) your visual selection to the register of your choice. For example, to copy to register 'z', make your visual selection, and then type &lt;code&gt;&quot;zy&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case you give, you could do this without moving the cursor, by putting the cursor on the first square brace, and then typing &lt;code&gt;v%&quot;zy&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Breakdown: &lt;code&gt;v&lt;/code&gt; -&gt; start visual selection; &lt;code&gt;%&lt;/code&gt; -&gt; move to matching brace; &lt;code&gt;&quot;z&lt;/code&gt; -&gt; use register 'z'; &lt;code&gt;y&lt;/code&gt; -&gt; yank (copy) the selection (in this case, into register 'z'). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have copied your visual selection to register 'z', go to the command line, and type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call writefile(getreg('z', 1, 1), &quot;some-file&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to append the text, rather than overwrite, you can use the &quot;a&quot; flag as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call writefile(getreg('z', 1, 1), &quot;some-file&quot;, &quot;a&quot;) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="15" LastEditDate="2018-07-18T14:56:24.647" LastActivityDate="2018-07-18T14:56:24.647" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="12007" PostTypeId="2" ParentId="11977" CreationDate="2017-04-06T12:51:37.630" Score="2" Body="&lt;p&gt;You can fake it with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;expr&amp;gt; . expand('&amp;lt;cword&amp;gt;') =~# '[(){}\[\]]' ? 'a'.expand('&amp;lt;cword&amp;gt;') : ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The character under the cursor is used to expand the selection if it's one of the brace characters.  Since an expression map is being used, you never leave visual mode, which avoids breaking the normal mode &lt;code&gt;.&lt;/code&gt; repeat.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Visual repeat of all text objects&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This method gives you a much broader coverage of text objects:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:repeat_block(key) abort&#xA;  if a:key ==# '.'&#xA;    return get(s:, 'v_repeat_count', '').get(s:, 'v_repeat_key', '')&#xA;  endif&#xA;&#xA;  let s:v_repeat_count = v:count1&#xA;  let s:v_repeat_key = a:key&#xA;  return a:key&#xA;endfunction&#xA;&#xA;for k in ['w', 'W', 's', 'p', '[', ']', '(', ')', 'b', '&amp;lt;', '&amp;gt;', 't', '{', '}', 'B', '&quot;', &quot;'&quot;, '`']&#xA;  execute printf('vnoremap &amp;lt;expr&amp;gt; a%s &amp;lt;sid&amp;gt;repeat_block(''a%s'')', k, k)&#xA;  execute printf('vnoremap &amp;lt;expr&amp;gt; i%s &amp;lt;sid&amp;gt;repeat_block(''i%s'')', k, k)&#xA;endfor&#xA;&#xA;unlet! k&#xA;&#xA;vnoremap &amp;lt;expr&amp;gt; . &amp;lt;sid&amp;gt;repeat_block('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This very lightly uses the same method as &lt;code&gt;vim-repeat&lt;/code&gt; and covers both &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt; text object prefixes.  The side effect of this is that the visual repetition is remembered after you leave and re-enter visual mode.  Whether or not that's a good thing is up to you.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastEditorUserId="5229" LastEditDate="2017-04-10T13:40:03.247" LastActivityDate="2017-04-10T13:40:03.247" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12008" PostTypeId="2" ParentId="11890" CreationDate="2017-04-06T18:30:04.187" Score="2" Body="&lt;p&gt;From what I understand from your comments, the problem is that the &lt;code&gt;@test { }&lt;/code&gt; group to include bash syntax. One way I found to achieve this is by using &lt;code&gt;:syntax include&lt;/code&gt; (&lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3asyn%2dinclude&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :syn-include&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:is_bash=1&#xA;&#xA;syntax include @BASH syntax/sh.vim&#xA;unlet b:current_syntax&#xA;&#xA;runtime! syntax/sh.vim&#xA;unlet b:current_syntax&#xA;&#xA;syntax match batsTestKeyword &quot;\v\@test&quot;&#xA;syntax keyword batsFunction load setup teardown run skip assert_success assert_failure assert_output&#xA;&#xA;syntax region batsTestBlock start='{' end='}' contains=@BASH,batsFunction&#xA;&#xA;highlight default link batsTestKeyword Identifier&#xA;highlight default link batsFunction Function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the top, we include the bash syntax twice, once as the &lt;code&gt;@BASH&lt;/code&gt; group, and once in the global namespace. The contained group can be added to the &lt;code&gt;contains=&lt;/code&gt; list. You'd done that, actually, I assume from looking at some example, but you hadn't included the bash syntax group as that name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I admit that syntax highlighting is not my strong suite, so there may be a better way of doing this, but this seems to work, in my experiments.&lt;/p&gt;&#xA;" OwnerUserId="11994" LastActivityDate="2017-04-06T18:30:04.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12009" PostTypeId="1" AcceptedAnswerId="12014" CreationDate="2017-04-06T18:35:31.203" Score="24" ViewCount="4549" Body="&lt;p&gt;From time to time, let's say once a month, when I program, I introduce a &lt;a href=&quot;http://www.fontspace.com/unicode/char/00A0-no-break-space&quot; rel=&quot;nofollow noreferrer&quot;&gt;No-Break space&lt;/a&gt; instead of a regular space, before opening a curly brace.&lt;/p&gt;&#xA;&lt;p&gt;This happens let's say when I'm writing &lt;code&gt;() {&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;This leads to mysterious lint bugs. CSS clauses that don't apply. Until I remember this might be it.&lt;/p&gt;&#xA;&lt;p&gt;As far as I'm aware, this only happens in vim, but since it's my main editor it might just never have happened in other software. But none of my coworkers' in my last jobs ever had that problem, even though they use the same keyboard layout as me. I'm the only one to use vim regularly though, that's why I though of posting here...&lt;/p&gt;&#xA;&lt;p&gt;This happened to me at least in ubuntu 14.04, 16.04, and mac os x.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:set list&lt;/code&gt; doesn't reveal it.&lt;/p&gt;&#xA;&lt;p&gt;I'm using a french-canadien keyboard layout, meaning the brace character is done by pressing alt + `&lt;/p&gt;&#xA;&lt;p&gt;I'm very tired of this causing problems, it's infrequent enough I keep forgetting about it.&lt;/p&gt;&#xA;&lt;p&gt;If you cannot tell me why this keeps happening, some sort of config to highlight that character in some sort of obvious way would be a suitable answer and really help with this problem.&lt;/p&gt;&#xA;" OwnerUserId="12096" LastEditorUserId="28" LastEditDate="2020-08-11T21:01:05.447" LastActivityDate="2020-10-12T21:40:45.317" Title="How do I keep accidentally creating a no break space before opening curly brace?" Tags="|insert-mode|unicode|keyboard-layout|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="12010" PostTypeId="2" ParentId="12009" CreationDate="2017-04-06T19:32:51.457" Score="16" Body="&lt;p&gt;The &lt;code&gt;'listchars'&lt;/code&gt; option provides a means to make &lt;code&gt;'list'&lt;/code&gt; display non-breaking spaces.  It's not set by default, so you probably want to add it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set listchars+=nbsp:‗&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-04-06T19:32:51.457" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12011" PostTypeId="2" ParentId="12009" CreationDate="2017-04-06T20:34:07.373" Score="20" Body="&lt;p&gt;You can add an autocommand that replaces non-breaking spaces with regular ones upon saving particular file types, eg. by putting something like this in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup RemoveSpaces&#xA;  autocmd!&#xA;  autocmd BufWritePre *.css silent! :%s/\%u00A0/ /g&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can tweak it by adding more file types or setting a mark and returning to it after the replace operation as otherwise you will be propelled to the start of the last line where a replacement has been made.&lt;/p&gt;&#xA;" OwnerUserId="9430" LastActivityDate="2017-04-06T20:34:07.373" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12012" PostTypeId="2" ParentId="11974" CreationDate="2017-04-06T22:48:35.810" Score="2" Body="&lt;p&gt;I do not provide an &lt;strong&gt;autocompletion&lt;/strong&gt; solution, but a way of filling your history with terms and then cycling through the terms:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Previous commands can be retrieved with the &lt;code&gt;:his[tory]&lt;/code&gt; command &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Previous searches can be retrieved with the &lt;code&gt;:his[tory] /&lt;/code&gt; command &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have &lt;code&gt;incsearch&lt;/code&gt; enabled, you can search for (e.g.) &lt;code&gt;/valid&lt;/code&gt; which will take you to the first match (perhaps &lt;code&gt;validate_firstname&lt;/code&gt;).  Pressing &lt;code&gt;CTRL-L&lt;/code&gt; will add one character from after the current match to the command line. This is not the same as autocomplete with &lt;kbd&gt;TAB&lt;/kbd&gt; but it does &lt;em&gt;complete&lt;/em&gt; the search term.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then use &lt;code&gt;:his /&lt;/code&gt; to find and repeat previous searches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have &lt;code&gt;/validate_firstname&lt;/code&gt; and &lt;code&gt;/validate&lt;/code&gt; in the search history, you can type &lt;code&gt;/val&lt;/code&gt; followed by the &amp;lt;Up&gt; and &amp;lt;Down&gt; cursor keys to cycle through the search history.&lt;/p&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="6590" LastEditDate="2017-04-06T22:57:01.457" LastActivityDate="2017-04-06T22:57:01.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12013" PostTypeId="1" AcceptedAnswerId="12015" CreationDate="2017-04-06T23:00:03.937" Score="2" ViewCount="783" Body="&lt;p&gt;I have found a related question here:&lt;br&gt;&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/11015/automatically-set-the-number-option-in-vim-when-entering-ex-mode-set-nonumbe&quot;&gt;Automatically set the &amp;#39;number&amp;#39; option in Vim when entering Ex mode, set &amp;#39;nonumber&amp;#39; in visual mode&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still I am not sure that I can follow those explanations to achieve what I want.&lt;br&gt;&#xA;So here is what I want to achieve:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;strong&gt;normal (and visual) mode&lt;/strong&gt;, I've set up a color bar, for example here&#xA;I [ab]use the foldcolumn to indicate that I am in visual mode (&lt;em&gt;see on the left a blue vertical bar&lt;/em&gt;):  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ElKnH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ElKnH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if I go into &lt;strong&gt;insert mode&lt;/strong&gt; I want it to change the color (&lt;em&gt;now the bar is gray as if it is gone&lt;/em&gt;):  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GM9dP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GM9dP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want this to set up a strong visual feedback which helps &#xA;to always see in which mode I am currently.&lt;br&gt;&#xA;Sometimes I start to input text when I am in normal or visual &#xA;mode and this results in running a lot of Vim's commands.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I make that the color changes automatically in run-time when switching from insert to normal mode and back?&lt;br&gt;&#xA;Here I use is foldcolumn, but it can be something else with similar effect to this.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;VIM 7.4, Windows&lt;/p&gt;&#xA;" OwnerUserId="5243" LastEditorUserId="-1" LastEditDate="2017-04-13T12:51:57.623" LastActivityDate="2017-04-07T21:23:03.453" Title="Automatically change interface colors for normal(visual) vs input mode" Tags="|insert-mode|visual-mode|colorscheme|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12014" PostTypeId="2" ParentId="12009" CreationDate="2017-04-06T23:29:10.830" Score="28" Body="&lt;p&gt;Others have already provided work-arounds, but as for the reason why it happens, I bet you're accidentally pressing &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;Space&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Xubuntu with the 105-key Finnish keyboard layout myself, so for me, typing &lt;code&gt;{&lt;/code&gt; means pressing &lt;kbd&gt;AltGr&lt;/kbd&gt;+&lt;kbd&gt;7&lt;/kbd&gt;.  I just did a quick test in xfce4-terminal (on the bash command line), and pressing &lt;kbd&gt;AltGr&lt;/kbd&gt;+&lt;kbd&gt;Space&lt;/kbd&gt; indeed produces a no-break space (U+00A0).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bet what's happening is that you're pressing down the &lt;kbd&gt;Alt&lt;/kbd&gt; key in anticipation of typing the brace, and sometimes that happens &lt;em&gt;before&lt;/em&gt; you actually press the space bar, producing a non-breaking space.  And since it &lt;em&gt;looks&lt;/em&gt; identical to a normal space, you don't realize it has happened before something mysteriously breaks, making it hard for you to notice it happening and thus also hard to unlearn that habit.&lt;/p&gt;&#xA;" OwnerUserId="12100" LastActivityDate="2017-04-06T23:29:10.830" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12015" PostTypeId="2" ParentId="12013" CreationDate="2017-04-07T01:49:25.647" Score="3" Body="&lt;p&gt;Use the &lt;code&gt;InsertEnter&lt;/code&gt; and &lt;code&gt;InsertLeave&lt;/code&gt; autocmd events. For example, say I [ab]used the &lt;code&gt;cursorline&lt;/code&gt; setting instead of the foldcolumn:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * set cursorline&#xA;autocmd InsertLeave * set nocursorline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jB8kY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jB8kY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/k0zJC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/k0zJC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So whatever it is you do to change the colour of the foldcolumn (&lt;code&gt;hi FoldColumn ctermbg=blue&lt;/code&gt;?), put those as the commands after the &lt;code&gt;autocmd InsertEnter *&lt;/code&gt; and &lt;code&gt;autocmd InsertLeave *&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is easier for the insert mode than other modes, since there are autocmd events for entering and leaving insert mode, but not for normal, visual, etc.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-04-07T01:49:25.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12016" PostTypeId="1" AcceptedAnswerId="12017" CreationDate="2017-04-07T07:48:01.890" Score="2" ViewCount="793" Body="&lt;p&gt;I am trying to highlight a set of lines, between the line containing ULS at the top of the line, to the line containing star in the bottom. I have tried many combination but I have failed. If someone could kindly guide me the correct regex for that selection. (Note: I am working in Windows).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have unsuccessfully tried to use the following regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/ULS\p\+\n\(\n\p\+\{-\}\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4DMVi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4DMVi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12103" LastActivityDate="2017-04-07T12:08:39.910" Title="How to add quantifiers to group in a pattern in VIM?" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12017" PostTypeId="2" ParentId="12016" CreationDate="2017-04-07T10:52:25.683" Score="1" Body="&lt;p&gt;I'm a little unclear about precisely what you're trying to achieve, but this search finds the lines between ULS and the first line that follows that begins with a &quot;*&quot; character, and includes all the lines &lt;em&gt;between&lt;/em&gt; those lines within a capture group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/ULS\p\+\n\(\_p\{-}\)\n\*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Broken down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/ULS&lt;/code&gt;: &quot;ULS&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\p\+\n&lt;/code&gt;: Any number of printable characters, followed by a newline &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(&lt;/code&gt;: Start of capture group&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\_p\{-}&lt;/code&gt;: Any number of printable characters, including newlines. &lt;code&gt;\_p&lt;/code&gt; is a variant of &lt;code&gt;\p&lt;/code&gt; that also matches newlines (the underscore can be used in other character classes in the same way: see &lt;code&gt;:help 27.8&lt;/code&gt; for details). &lt;code&gt;\{-}&lt;/code&gt; is a non-greedy version of &lt;code&gt;*&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\)&lt;/code&gt;: End of capture group&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\n\*&lt;/code&gt;: A newline followed by a star.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-04-07T12:08:39.910" LastActivityDate="2017-04-07T12:08:39.910" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12018" PostTypeId="1" CreationDate="2017-04-07T14:55:51.720" Score="-1" ViewCount="1995" Body="&lt;p&gt;I'm using denite plugin and I have some intialization for it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call denite#custom#source(&#xA;    \ 'file_rec', 'matchers', ['matcher_fuzzy', 'matcher_project_files'])&#xA;call denite#custom#var('file_rec/git', 'command', ['git', 'ls-files', '-co', '--exclude-standard'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since I moved from external package manager into vim packages I moved this into a function that is executed inside &lt;code&gt;VimEnter&lt;/code&gt; autocmd. But now I want to open denite prompt when no files have been passed to vim as arguments.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au VimEnter * if argc() == 0 | exe &quot;:Denite `finddir('.git', ';') != '' ? 'file_rec/git' : 'file_rec'`&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is quite easy, but the problem is that at this point vim still doesn't know anything about my custom 'file_rec/git' command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to place initialization into &lt;code&gt;~/.vim/after/plugin/denite.vim&lt;/code&gt;, but that doesn't help. Vim is saying that he basically doesn't know what denite is at this point.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2017-05-22T07:28:41.113" Title="How to properly initialize plugins with new vim 8 packages feature?" Tags="|plugin-system|packages|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12019" PostTypeId="2" ParentId="9941" CreationDate="2017-04-07T15:45:41.403" Score="24" Body="&lt;p&gt;As mentioned in comments elsewhere, you can use &lt;code&gt;has&lt;/code&gt;. For generic &quot;is this neovim&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo has('nvim')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For at least minor version &lt;code&gt;0.1&lt;/code&gt; (latest as of this writing):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo has('nvim-0.1')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For at least patch version &lt;code&gt;0.1.6&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo has('nvim-0.1.6')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2152" LastActivityDate="2017-04-07T15:45:41.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12020" PostTypeId="2" ParentId="11984" CreationDate="2017-04-07T16:13:37.020" Score="2" Body="&lt;p&gt;Vim already includes everything you need to achieve what you are looking for, as long as it is properly configured for your environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at the following Vim help pages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27makeprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'makeprg'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:make&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27errorformat%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'errorformat'&lt;/code&gt;&lt;/a&gt; (you also need to read &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#errorformat&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;errorformat&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;quickfix.txt&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can also look at &lt;a href=&quot;https://github.com/vim-syntastic/syntastic&quot; rel=&quot;nofollow noreferrer&quot;&gt;Syntastic&lt;/a&gt; syntax plugins that include various examples for &lt;code&gt;'errorformat'&lt;/code&gt;. You can find a tool that you know (or that you have access to) and use those entries as an example for your development. While I don't personally use &lt;a href=&quot;https://github.com/vim-syntastic/syntastic&quot; rel=&quot;nofollow noreferrer&quot;&gt;Syntastic&lt;/a&gt;, do consider creating a Pull Request to have your language included in it.&lt;/p&gt;&#xA;" OwnerUserId="599" LastActivityDate="2017-04-07T16:13:37.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12021" PostTypeId="2" ParentId="12001" CreationDate="2017-04-07T16:16:07.937" Score="3" Body="&lt;p&gt;Tim Pope has made a plugin to do exactly that, the RSI shortcuts on insert mode:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-rsi&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tpope/vim-rsi&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11690" LastActivityDate="2017-04-07T16:16:07.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12022" PostTypeId="2" ParentId="11988" CreationDate="2017-04-07T18:09:21.733" Score="4" Body="&lt;p&gt;I made a plugin &lt;a href=&quot;https://github.com/chrisbra/Colorizer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Colorizer&lt;/a&gt; That should do what you want. Read the help for more information.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-04-07T18:09:21.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12023" PostTypeId="2" ParentId="12013" CreationDate="2017-04-07T21:23:03.453" Score="1" Body="&lt;p&gt;Based on Muru's answer, here is what I made:&lt;br&gt;&#xA;In colorscheme file set the default color for foldcolumn:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi FoldColumn  guifg=#C7C8B8  guibg=#DACBAD  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in &lt;strong&gt;vimrc&lt;/strong&gt; file enable foldcolumn (set foldcolumn=2) and add color settings on &lt;strong&gt;InsertEnter&lt;/strong&gt; and &lt;strong&gt;InsertLeave&lt;/strong&gt; events:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * hi FoldColumn guifg=#C7C8B8 guibg=#E6E5DC&#xA;autocmd InsertLeave * hi FoldColumn guifg=fg guibg=#DACBAD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;::&lt;br&gt;&#xA;Normal mode:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/03RnW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/03RnW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;::&lt;br&gt;&#xA;Insert mode:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AtTSJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AtTSJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5243" LastActivityDate="2017-04-07T21:23:03.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12024" PostTypeId="2" ParentId="12009" CreationDate="2017-04-07T21:51:10.143" Score="1" Body="&lt;p&gt;yes, that's probably alt+space, happens to me a lot when i use the pipe operator:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat xyz.txt | grep abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you hold the alt-key too long, it will create a non breaking space after the pipe and bash will try to find a command &quot; grep&quot; and then telling you that grep was not found ..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;on macos there was some trick to change the keymap, so every time you insert a non-breaking space, it will get converted/replaced by a regular. as far as i remember, the keymap is changed for the whole keyboard, so it fixes your problem in all applications.&lt;/p&gt;&#xA;" OwnerUserId="12120" LastActivityDate="2017-04-07T21:51:10.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12026" PostTypeId="1" AcceptedAnswerId="12027" CreationDate="2017-04-08T12:27:36.743" Score="2" ViewCount="345" Body="&lt;p&gt;As the title says. Is it possible?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Steps to reproduce:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Type in &lt;code&gt;sample(text)&lt;/code&gt; and put the cursor on the first character then press &lt;code&gt;w&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Expected behavior:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Cursor moves to beginning of next word - &lt;code&gt;text&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hOSVy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hOSVy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Current (and default) behavior:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The cursor moves to the first brace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fDnZY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fDnZY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The Same thing occurs when there is for example &lt;code&gt;aaa * bbb&lt;/code&gt; - cursor moves to &lt;code&gt;*&lt;/code&gt; first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried manipulating &lt;code&gt;iskeyword&lt;/code&gt; but without success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to tell Vim to ignore those operator and braces characters?&lt;/p&gt;&#xA;" OwnerUserId="11307" LastActivityDate="2017-04-09T14:28:59.747" Title="Ammend 'w' behavior - ignore operators and brackets - '(', '[' '{', '*', '+', '='" Tags="|cursor-motions|vi-words|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12027" PostTypeId="2" ParentId="12026" CreationDate="2017-04-08T17:42:24.227" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Anything is possible with some scripting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;w :call search('\&amp;lt;\w', 'W')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;e :call search('\w\&amp;gt;', 'W')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;b :call search('\&amp;lt;\w', 'bW')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gE :call search('\w\&amp;gt;', 'bW')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's not possible to change this behavior with &lt;code&gt;iskeyword&lt;/code&gt;, however.  Here's what &lt;code&gt;:h word&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A word consists of a sequence of letters, digits and underscores, or a&#xA;    sequence of other non-blank characters, separated with white space (spaces,&#xA;    tabs, ).  This can be changed with the 'iskeyword' option.  An empty line&#xA;    is also considered to be a word.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is, a word motion is an &lt;em&gt;alternating&lt;/em&gt; keyword or non-keyword sequence, that may be separated by whitespace.  A &lt;code&gt;word&lt;/code&gt; &lt;em&gt;motion&lt;/em&gt; should not be confused with a word &lt;em&gt;pattern&lt;/em&gt; (&lt;code&gt;\w&lt;/code&gt; which only includes &lt;code&gt;0-9A-Za-z_&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This illustrates where the cursor jumps when you press &lt;code&gt;w&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sample(text) { body }&#xA;^     ^^   ^ ^ ^    ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;iskeyword+=(&lt;/code&gt; would give you these cursor jump positions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sample(text) { body }&#xA;^          ^ ^ ^    ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because &lt;code&gt;sample(text&lt;/code&gt; is now considered a keyword.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be made clearer by using &lt;code&gt;iskeyword=x&lt;/code&gt; to simplify your notion of a word motion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xxxx xxxx xxabcxx def hijxxxlmn&#xA;^    ^    ^ ^  ^  ^   ^  ^  ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-04-08T17:42:24.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12029" PostTypeId="1" AcceptedAnswerId="12063" CreationDate="2017-04-08T21:11:50.907" Score="3" ViewCount="1944" Body="&lt;p&gt;I always prefer shebangs over extensions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A lot of times I make a new file without an extension in vim, which gets opened as plain text, since no extension is provided, which is completely normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing I write is a shebang, but the syntax doesn't get highlighted (even though the language is supported), closing and reopening the file is annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I'm new to vim, I'm asking you vim lovers if there is a command which I can use, or maybe some modifications to my .vimrc file I can make to fix this issue.&lt;/p&gt;&#xA;" OwnerUserId="12132" LastEditorUserId="12132" LastEditDate="2018-04-07T15:28:48.560" LastActivityDate="2018-04-07T15:28:48.560" Title="How to reload the current file to change syntax highlighting (ex: adding a shebang)?" Tags="|syntax-highlighting|filetype|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12030" PostTypeId="1" CreationDate="2017-04-08T22:11:16.537" Score="1" ViewCount="99" Body="&lt;p&gt;I need to repeat a certain operation across several lines of code spread through out the code base. For instance, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = y;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;needs to be replaced with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EQUATE(x,y);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However each instance needs to be assessed manually, because say this needs to be done only when &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; have been declared as &lt;code&gt;unit16_t&lt;/code&gt;. So the functionality I seek is to be able to browse through various files of interest and anytime I come across a line where I feel the above operation needs to run, I should be able to just press a certain sequence of keys that would substitute the given line of code with the desired change. So say if I come across a line somewhere else that looks like below &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct_x.var_x = struct_y.var_y;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I should just be able to replace it with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EQUATE(struct_x.var_x, struct_y.var_y);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with a simple set of keystrokes.&lt;/p&gt;&#xA;" OwnerUserId="12133" LastActivityDate="2017-04-14T08:22:40.963" Title="How to repeat a certain operation across lines of code?" Tags="|formatting|replace|repeated-commands|" AnswerCount="1" CommentCount="4" ClosedDate="2017-04-12T12:30:30.537" ContentLicense="CC BY-SA 3.0" />
  <row Id="12031" PostTypeId="1" AcceptedAnswerId="12032" CreationDate="2017-04-09T09:41:02.103" Score="3" ViewCount="737" Body="&lt;p&gt;My searches for plugins which enable a terminal inside a Vim windows indicate that the main one is &lt;a href=&quot;https://github.com/vim-scripts/Conque-Shell&quot; rel=&quot;nofollow noreferrer&quot;&gt;Conque&lt;/a&gt;, but the last update was 6 years ago. Are there some other better updated forks which are seen as the goto version?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any newer alternatives to it?&lt;/p&gt;&#xA;" OwnerUserId="9540" LastActivityDate="2019-03-16T01:12:13.763" Title="Is there an upgraded version of the Conque plugin?" Tags="|terminal|plugin-conque|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12032" PostTypeId="2" ParentId="12031" CreationDate="2017-04-09T11:19:42.853" Score="4" Body="&lt;p&gt;Since Conque's description states that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...In other words it is a terminal emulator which uses a Vim buffer to display the program output. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://neovim.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neovim&lt;/a&gt; with its &lt;a href=&quot;https://www.youtube.com/watch?v=xZbMVj9XSUo&quot; rel=&quot;nofollow noreferrer&quot;&gt;built-in terminal&lt;/a&gt; might be your best bet. Once in the terminal buffer, you can press &lt;code&gt;&amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;&lt;/code&gt; to &quot;exit&quot; the insert mode of the terminal and then edit the text as a normal buffer (searching, marks, registers, motions, visual-selection etc).&lt;/p&gt;&#xA;" OwnerUserId="10493" LastActivityDate="2017-04-09T11:19:42.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12035" PostTypeId="2" ParentId="12026" CreationDate="2017-04-09T14:28:59.747" Score="0" Body="&lt;p&gt;I understand the frustration, though there are other ways around it which might be better to use since you could find yourself using vim on a server or other environment that doesn't have your customized command changes (and accompanying muscle memory).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your specific example, you could do &lt;code&gt;f t&lt;/code&gt; to jump directly to the start of &lt;code&gt;text&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4560" LastActivityDate="2017-04-09T14:28:59.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12036" PostTypeId="1" AcceptedAnswerId="12425" CreationDate="2017-04-09T17:38:36.093" Score="3" ViewCount="453" Body="&lt;p&gt;I would like to replace instances of a single character variable, say &lt;code&gt;x&lt;/code&gt;, throughout all my equations in a latex file, say the replacement is &lt;code&gt;\x&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The equations are denoted by one of the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{equation} \end{equation}&#xA;\[ \]&#xA;$ $&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could use &lt;code&gt;:%s,x,\\x,gc&lt;/code&gt; but then I would have to confirm all instances of x that are not in math mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to bound the range to be inside math modes only?&lt;/p&gt;&#xA;" OwnerUserId="6854" LastEditorUserId="205" LastEditDate="2017-04-10T01:10:43.983" LastActivityDate="2017-05-17T14:02:28.293" Title="Character in math mode replacement" Tags="|search|replace|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12037" PostTypeId="1" AcceptedAnswerId="12038" CreationDate="2017-04-09T23:42:20.717" Score="3" ViewCount="2050" Body="&lt;p&gt;I am creating a &lt;code&gt;.vimrc&lt;/code&gt; that will be shared by all the users on the system, ie it will be set from &lt;code&gt;/etc/skel&lt;/code&gt;. However after starting it should be able to load the users own customizations, which normally go into &lt;code&gt;.vimrc&lt;/code&gt; itself.&#xA;The &lt;code&gt;~/.vimrc&lt;/code&gt; file its actually symlinked to the central file, which should then load the users own customisations, which could be a file named &lt;code&gt;~/.vimcustomrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What command, if there is one, should be used for that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is something like the Apache webserver looking in /etc/apache/conf.d and adding the vhosts the to the default &lt;code&gt;apache2.conf&lt;/code&gt; or additional repositories being loaded from the &lt;code&gt;/etc/apt/sources.list.d&lt;/code&gt; directory&lt;/p&gt;&#xA;" OwnerUserId="9540" LastEditorUserId="51" LastEditDate="2017-04-14T03:08:35.313" LastActivityDate="2017-04-14T03:08:35.313" Title="How can I share a vimrc file with all system users file still allowing customisation?" Tags="|vimrc|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12038" PostTypeId="2" ParentId="12037" CreationDate="2017-04-10T07:14:15.293" Score="3" Body="&lt;p&gt;You can add &lt;code&gt;source&lt;/code&gt; command at the end of the main &lt;code&gt;.vimrc&lt;/code&gt;, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if filereadable(expand(&quot;$HOME/.vimcustomrc&quot;))&#xA;   execute &quot;source &quot; . expand(&quot;$HOME/.vimcustomrc&quot;)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-04-10T07:14:15.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12039" PostTypeId="1" AcceptedAnswerId="12041" CreationDate="2017-04-10T09:45:55.090" Score="5" ViewCount="895" Body="&lt;p&gt;When a vim file is &lt;code&gt;source&lt;/code&gt;-ed is it like including the raw text of the file into the current script is it more like executing its contents and returning to the current file?&lt;/p&gt;&#xA;" OwnerUserId="9540" LastEditorUserId="205" LastEditDate="2017-04-10T11:09:37.920" LastActivityDate="2017-04-10T11:09:37.920" Title="Is 'source'-ing a vim file simlar to 'include' in other languages?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12041" PostTypeId="2" ParentId="12039" CreationDate="2017-04-10T11:09:09.360" Score="7" Body="&lt;p&gt;Different languages have different semantics for this, so I won't compare, but &lt;code&gt;source&lt;/code&gt; in Vim is not exactly like either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For one, Vim has script-local variables, which, in practice, mean file-local.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take these examples:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;foo.vim&lt;/code&gt; (practically lifted as-is from &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#script-variable&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h script-variable&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:counter = 0&#xA;function! StartCounting(incr)&#xA;    if a:incr&#xA;        function MyCounter()&#xA;            let s:counter = s:counter + 1&#xA;        endfunction&#xA;    else&#xA;        function MyCounter()&#xA;            let s:counter = s:counter - 1&#xA;        endfunction&#xA;    endif&#xA;endfunction&#xA;let b:bar=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;bar.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:bar=1&#xA;source foo.vim&#xA;call StartCounting(1)&#xA;echo s:counter&#xA;echo b:bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If it were simply including the raw text, I'd expect to see &lt;code&gt;s:counter&lt;/code&gt; have a non-zero value.&lt;/li&gt;&#xA;&lt;li&gt;If it were executing the contents and returning, I'd expect to see &lt;code&gt;b:bar&lt;/code&gt; unchanged.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Instead, the output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /tmp/bar.vim:&#xA;line    4:&#xA;E121: Undefined variable: s:counter&#xA;E15: Invalid expression: s:counter&#xA;2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;b:bar&lt;/code&gt; is changed by the sourced file, but a script-local variable defined in the sourced file is not directly accessible by the calling file.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-04-10T11:09:09.360" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12042" PostTypeId="1" AcceptedAnswerId="12043" CreationDate="2017-04-10T13:21:24.033" Score="2" ViewCount="895" Body="&lt;pre&gt;&lt;code&gt;adfa.ad.asdf.efa.saf mark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need to match the &lt;code&gt;saf mark&lt;/code&gt;, no more no less ahead. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find that if I use this,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v[,.;]\zs.{-}mark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It matches all along to the first &lt;code&gt;.&lt;/code&gt;. Any suggestions? Thanks. &lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="2920" LastEditDate="2017-04-10T17:27:25.660" LastActivityDate="2017-04-10T17:27:25.660" Title="Look ahead non greedily?" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12043" PostTypeId="2" ParentId="12042" CreationDate="2017-04-10T13:28:09.623" Score="4" Body="&lt;p&gt;If you make your collection negative, it should do what you want:&#xA;&lt;code&gt;/[^,.;]*mark&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-04-10T13:28:09.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12044" PostTypeId="2" ParentId="12042" CreationDate="2017-04-10T13:39:55.627" Score="2" Body="&lt;p&gt;To my knowledge when there is a race between two goals (in this case &quot;find the first match for the expression&quot; vs. &quot;find the match with the least characters&quot;), the first goal wins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So depending on what matches you need for which lines (always the part after the last punctuation before the &lt;code&gt;mark&lt;/code&gt;?) you could move the greedy part in front:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/.*[,.;]\zs.*mark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, the first goal wins, so the second &lt;code&gt;*&lt;/code&gt; only gets what the first one leaves&lt;/p&gt;&#xA;" OwnerUserId="11771" LastActivityDate="2017-04-10T13:39:55.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12045" PostTypeId="2" ParentId="12037" CreationDate="2017-04-10T13:51:39.593" Score="4" Body="&lt;p&gt;The right way to do this is to follow the explanation in &lt;code&gt;:help startup&lt;/code&gt; and to put customizations that are to be shared by all users into &lt;code&gt;$VIM/vimrc&lt;/code&gt; or &lt;code&gt;/etc/vimrc&lt;/code&gt;, depending on how Vim was built. Execute &lt;code&gt;:version&lt;/code&gt; and look for &lt;code&gt;system vimrc file&lt;/code&gt;. See also &lt;code&gt;:help system-vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The files in &lt;code&gt;/etc/skel&lt;/code&gt; are generally used to initialize a user's private customizations and not to be the system-wide customizations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then each user can customize Vim they way they want to by editing their &lt;code&gt;~/.vimrc&lt;/code&gt; file, which you've initialized in &lt;code&gt;/etc/skel&lt;/code&gt;, the way it's documented and the way everyone else does instead of having to discover and use some other file, in this case &lt;code&gt;~/.vimcustomrc&lt;/code&gt;, which no one else in the world uses. This will make maintaining Vim easier for you and for your users.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-04-10T13:51:39.593" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12046" PostTypeId="1" CreationDate="2017-04-10T14:04:17.753" Score="1" ViewCount="1556" Body="&lt;p&gt;I set a variable &lt;code&gt;b:aaa&lt;/code&gt; which has the value that I can see via &lt;code&gt;echo b:aaa&lt;/code&gt;, how can I copy that to text? I know I can do it by &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set @a = b:aaa&#xA;&quot;ap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to get it. But can I copy it to the an open file directly? &lt;/p&gt;&#xA;" OwnerUserId="1788" LastActivityDate="2017-04-11T22:27:12.297" Title="Copy the values from a variable?" Tags="|variables|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="12047" PostTypeId="2" ParentId="12046" CreationDate="2017-04-10T14:59:39.133" Score="1" Body="&lt;p&gt;Registers works like variables, so you are almost done. I think this would work for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a = b:aaa&#xA;&quot;ap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11690" LastActivityDate="2017-04-10T14:59:39.133" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12048" PostTypeId="1" AcceptedAnswerId="14252" CreationDate="2017-04-10T18:32:28.257" Score="3" ViewCount="730" Body="&lt;p&gt;I'm getting lag in vim when navigating relatively small text files if &lt;code&gt;filetype plugin indent on&lt;/code&gt; is uncommented in my vimrc file.  My full vimrc file is pasted below.  Any help on how I can get it enabled properly with no lag?  It's worked fine in the past. I only started having this issue lately.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible          &quot; We're running Vim, not Vi!&#xA;syntax on                 &quot; Enable syntax highlighting&#xA;&#xA;filetype off          &quot; Begin For Vundle&#xA;set rtp+=~/.vim/vundle.git/&#xA;call vundle#rc()&#xA;Bundle 'gmarik/vundle'    &#xA;Bundle 'scrooloose/nerdcommenter'&#xA;Bundle 'scrooloose/nerdtree'&#xA;&#xA;Bundle &quot;https://github.com/msanders/snipmate.vim&quot;&#xA;&quot; End Vundle code&#xA;&#xA;&quot; causing massive lag, disabled&#xA;&quot;filetype plugin indent on &quot; Enable filetype-specific indenting and plugins&#xA;&#xA;set number &quot;enable line numbers&#xA;set lines=40 columns=100&#xA;&#xA;set clipboard=unnamedplus&#xA;&#xA;&quot; Map ctrl-n to NerdTree&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;c-n&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; go to previous file with ,p&#xA;let mapleader = &quot;,&quot; &#xA;map &amp;lt;Leader&amp;gt;p &amp;lt;C-^&amp;gt; &#xA;&#xA;&quot; Load matchit (% to bounce from do to end, etc.)&#xA;runtime! macros/matchit.vim&#xA;&#xA;augroup myfiletypes&#xA;&quot; Clear old autocmds in group&#xA;autocmd!&#xA;&quot; autoindent with two spaces, always expand tabs&#xA;set ai sw=2 sts=2 et&#xA;&#xA;&quot; Move swp files to ~/.vim/tmp&#xA;set backupdir=~/.vim/tmp&#xA;set directory=~/.vim/tmp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12162" LastEditorUserId="4472" LastEditDate="2017-07-11T06:46:31.727" LastActivityDate="2017-11-18T08:55:08.077" Title="Lag from filetype plugin indent on" Tags="|indentation|performance|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12049" PostTypeId="1" AcceptedAnswerId="12052" CreationDate="2017-04-10T19:39:12.793" Score="1" ViewCount="2047" Body="&lt;p&gt;What is the best way of linking the Ctrl-V key combination to pasting the clipboard in insert mode? &#xA;I used &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-v&amp;gt; &quot;+gP&#xA;imap &amp;lt;C-v&amp;gt; &amp;lt;C-r&amp;gt;&amp;lt;C-p&amp;gt;+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;.vimrc&lt;/code&gt;. However in insert mode, this definition sometimes doesn't work, it pasts the inserted text in a new line above the current cursor position. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I have a more detailed bug description now: The problem seems to appear when the String in the clip board terminates with a new line. Here a receipt to reproduce: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I open &lt;code&gt;gvim&lt;/code&gt; and a &lt;code&gt;LibreOffice&lt;/code&gt; word processor window. In LibreOffice I type &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hello Test &#xA;Foo bar &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I select &quot;Hello Test&quot;+the line break (but not the 'F' of foo) and press &lt;code&gt;Ctrl-c&lt;/code&gt;. In Gvim I enter insertmode, Tyle Enter (new line), type 'some text', press &lt;code&gt;Ctrl-v&lt;/code&gt;. The Result will be that &quot;Hello Test&quot; is inserted in a new line above &quot;some text&quot; and the cursor is positioned at first char of the &quot;some text&quot; line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If in LibreOffice I copy only &quot;Hello Test&quot; without the linebreak, the behavor is normaL (&quot;Hello Test&quot; will be inserted after &quot;some text&quot; and the cursor is right of the inserted string). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem is not specific to LibreOffice, it also happens when I copy paste full lines from PDF Files with &lt;code&gt;okular&lt;/code&gt; or &lt;code&gt;acroread&lt;/code&gt;. Generally it happens always when the copy pasted string terminates in newline. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas? &lt;/p&gt;&#xA;" OwnerUserId="12163" LastEditorUserId="12163" LastEditDate="2017-04-11T15:55:14.427" LastActivityDate="2017-04-11T16:32:42.843" Title="How to set up Crtl-v map that works in insert mode?" Tags="|key-bindings|cut-copy-paste|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12050" PostTypeId="2" ParentId="7033" CreationDate="2017-04-10T21:32:36.417" Score="1" Body="&lt;p&gt;Starting vim using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;won't work because you need a vimrc file with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocp&#xA;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The two settings are needed because &quot;netrw&quot; is actually a plugin distributed with vim by default, but still a plugin.&#xA;I would reccomend you to create an alternative vimrc to confirm that the issue is due to some settings in your vimrc. You can do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;set nocp&quot; &amp;gt; test_vimrc&#xA;echo &quot;filetype plugin on&quot; &amp;gt;&amp;gt; test_vimrc&#xA;vim -u test_vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;than try to reproduce the issue. If starting vim with the &quot;test_vimrc&quot; the issue disappears, than post your vimrc file so that we can try to narrow down which script is causing the issue.  &lt;/p&gt;&#xA;" OwnerUserId="12164" LastEditorUserId="12164" LastEditDate="2017-04-10T23:37:37.737" LastActivityDate="2017-04-10T23:37:37.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12051" PostTypeId="2" ParentId="11861" CreationDate="2017-04-11T00:58:09.857" Score="4" Body="&lt;p&gt;This behavior is actually caused by a bug. This bug has been reported and discussed in the thread &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_dev/p-iHvlpVkCM&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Unnamed register only contains the last deleted text when appending deleted text to a register&quot;&gt;&lt;em&gt;Unnamed register only contains the last deleted text when appending deleted text to a register&lt;/em&gt;&lt;/a&gt; on the &lt;code&gt;vim-dev&lt;/code&gt; mailing list.&lt;/p&gt;&#xA;" OwnerUserId="9846" LastEditorUserId="9846" LastEditDate="2017-04-13T07:46:02.413" LastActivityDate="2017-04-13T07:46:02.413" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12052" PostTypeId="2" ParentId="12049" CreationDate="2017-04-11T02:42:46.917" Score="4" Body="&lt;p&gt;I think the problem is that the &lt;code&gt;+&lt;/code&gt; register contains &lt;code&gt;linewise&lt;/code&gt; text.  I can't say if that's a bug or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to give the same effect while ignoring the register type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-v&amp;gt; &amp;lt;esc&amp;gt;:set paste&amp;lt;cr&amp;gt;a&amp;lt;c-r&amp;gt;=getreg('+')&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;:set nopaste&amp;lt;cr&amp;gt;mi`[=`]`ia&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It temporarily enables the &lt;code&gt;paste&lt;/code&gt; option to enter text from the expression register literally.  By using &lt;code&gt;getreg('+')&lt;/code&gt; you're getting the text without consideration of the register type and placing it at the cursor.  &lt;code&gt;mi`[=`]`ia&lt;/code&gt; is used to save the cursor position, format the inserted text, and return the cursor.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-04-11T02:42:46.917" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12053" PostTypeId="1" AcceptedAnswerId="12054" CreationDate="2017-04-11T03:18:32.967" Score="1" ViewCount="2056" Body="&lt;p&gt;In the last weeks I'm trying &lt;code&gt;terminator&lt;/code&gt; as my terminal emulator (instead of the old and good &lt;code&gt;xterm&lt;/code&gt;), and even though the experience is better, there's an annoying detail: all mappings involving &lt;kbd&gt;alt&lt;/kbd&gt; don't work at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I took these mappings from &lt;a href=&quot;http://www.reddit.com/r/vim/comments/kz84u/what_are_some_simple_yet_mindblowing_tweaks_to/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this reddit&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;A-j&amp;gt; :m+&amp;lt;CR&amp;gt;==&#xA;nnoremap &amp;lt;A-k&amp;gt; :m-2&amp;lt;CR&amp;gt;==&#xA;nnoremap &amp;lt;A-h&amp;gt; &amp;lt;&amp;lt;&#xA;nnoremap &amp;lt;A-l&amp;gt; &amp;gt;&amp;gt;&#xA;inoremap &amp;lt;A-j&amp;gt; &amp;lt;Esc&amp;gt;:m+&amp;lt;CR&amp;gt;==gi&#xA;inoremap &amp;lt;A-k&amp;gt; &amp;lt;Esc&amp;gt;:m-2&amp;lt;CR&amp;gt;==gi&#xA;inoremap &amp;lt;A-h&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;&amp;lt;`]a&#xA;inoremap &amp;lt;A-l&amp;gt; &amp;lt;Esc&amp;gt;&amp;gt;&amp;gt;`]a&#xA;vnoremap &amp;lt;A-j&amp;gt; :m'&amp;gt;+&amp;lt;CR&amp;gt;gv=gv&#xA;vnoremap &amp;lt;A-k&amp;gt; :m-2&amp;lt;CR&amp;gt;gv=gv&#xA;vnoremap &amp;lt;A-h&amp;gt; &amp;lt;gv&#xA;vnoremap &amp;lt;A-l&amp;gt; &amp;gt;gv&#xA;nnoremap &amp;lt;A-S-l&amp;gt; viwxp`[v`]&#xA;nnoremap &amp;lt;A-S-h&amp;gt; viwxhhp`[v`]&#xA;inoremap &amp;lt;A-S-l&amp;gt; &amp;lt;Esc&amp;gt;viwxp`[v`]&#xA;inoremap &amp;lt;A-S-h&amp;gt; &amp;lt;Esc&amp;gt;viwxhhp`[v`]&#xA;vnoremap &amp;lt;A-S-l&amp;gt; xp`[v`]&#xA;vnoremap &amp;lt;A-S-h&amp;gt; xhhp`[v`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that allow to just &quot;drag&quot; the current line above or below, or indent it to the left or right with just &lt;kbd&gt;alt&lt;/kbd&gt; plus the usual keys for movement: &lt;kbd&gt;j&lt;/kbd&gt;, &lt;kbd&gt;k&lt;/kbd&gt;, &lt;kbd&gt;h&lt;/kbd&gt;, &lt;kbd&gt;l&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, all these mappings don't work if I use &lt;code&gt;terminator&lt;/code&gt; (but they do if I use &lt;code&gt;xterm&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a normal problem with &lt;code&gt;terminator&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1957" LastActivityDate="2017-04-11T05:06:53.250" Title="Mappings with &lt;alt&gt; don't work within Terminator" Tags="|key-bindings|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12054" PostTypeId="2" ParentId="12053" CreationDate="2017-04-11T04:56:52.977" Score="1" Body="&lt;p&gt;Experimenting with Ubuntu 16.04, terminator claims its TERM to be &lt;code&gt;xterm&lt;/code&gt;, but sends different codes than xterm. For example, alt+j in terminator is 0x1b 0x6a, but on xterm it is 0xc3 0xaa. I &lt;em&gt;think&lt;/em&gt; 0xc3 0xaa is utf-8 for &lt;code&gt;ê&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the man page for xterm, it looks like altSendsEscape defaults to false, so the alt key makes an 8-bit character by default (that is then getting encoded to utf-8 for some reason?), whereas if set to true, it sends the escape (0x1b) followed by the unmodified character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's &lt;code&gt;:help &amp;lt;A-&lt;/code&gt; indicates that Vim expects the 8-bit encoding for meta chars. This means it is compatible with the default settings in xterm, but not terminator (nor several others that behave the same way, like urxvt)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://vi.stackexchange.com/a/1928/227&quot;&gt;https://vi.stackexchange.com/a/1928/227&lt;/a&gt; where this behavior is taken advantage of, though this doesn't help your use-case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on &lt;a href=&quot;https://stackoverflow.com/a/15399297/4504704&quot;&gt;https://stackoverflow.com/a/15399297/4504704&lt;/a&gt;, you can re-write your mappings to rely on the escape, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;ESC&amp;gt;j :m+&amp;lt;CR&amp;gt;==&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This however has the downside that you'll have to wait a while after pressing escape before typing any characters mapped this way, because Vim won't be able to tell the difference between you hitting escape and then j (to move down) vs pressing alt+j.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2017-04-11T05:06:53.250" LastActivityDate="2017-04-11T05:06:53.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12055" PostTypeId="2" ParentId="12048" CreationDate="2017-04-11T11:21:09.863" Score="1" Body="&lt;p&gt;Most likely you have something in your actual syntax files causing the lag.&#xA;I'd reccomend running &lt;code&gt;:syntime on&lt;/code&gt;, moving about a little, then doing &lt;code&gt;:syntime report&lt;/code&gt;. This'll show you what patterns take the longest to check for matches. Consider disabling those, or looking them over if they're custom (usually stored in &lt;code&gt;~/.vim/after/&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2017-04-11T11:21:09.863" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12056" PostTypeId="1" AcceptedAnswerId="12066" CreationDate="2017-04-11T15:50:19.053" Score="5" ViewCount="245" Body="&lt;p&gt;Suppose I have a very long file, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class X {&#xA;    // ...&#xA;    void foo() {&#xA;        // ...&#xA;        if (something) {&#xA;            a00();&#xA;            a01();&#xA;            a02();&#xA;            // ...&#xA;            // ...&#xA;            a98();&#xA;            a99();&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When scrolling down to the bottom, all the context (ie., &lt;code&gt;class X&lt;/code&gt;, &lt;code&gt;void foo&lt;/code&gt;, &lt;code&gt;if (something)&lt;/code&gt;) is invisible simply because its outside the current view:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            a93();&#xA;            a94();&#xA;            a95();&#xA;            a96();&#xA;            a97();&#xA;            a98();&#xA;            a99();&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way to make vim keep the current context, ie, display something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class X {                    &amp;lt;C&amp;gt;&#xA;    void foo() {             &amp;lt;C&amp;gt;&#xA;        if (something) {     &amp;lt;C&amp;gt;&#xA;            a96();&#xA;            a97();&#xA;            a98();&#xA;            a99();&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with some markings (&lt;code&gt;&amp;lt;C&amp;gt;&lt;/code&gt; in my example) to denote that the lines above &lt;code&gt;a96&lt;/code&gt; are not directly preceding the next one?&lt;/p&gt;&#xA;" OwnerUserId="8108" LastActivityDate="2017-07-23T14:45:06.407" Title="Keeping context while scrolling" Tags="|scrolling|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12057" PostTypeId="2" ParentId="12049" CreationDate="2017-04-11T16:32:42.843" Score="4" Body="&lt;p&gt;It has to do with the &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt;. I know it's supposed to &quot;Insert the contents of a register litterally&quot;, but it's causing problems. I've reproduced your problem with Microsoft Word and gVim 8.0.69. But If I change the mapping to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;C-v&amp;gt; &amp;lt;C-r&amp;gt;+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it works as expected. It might be a bug, but I'm not sure.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-04-11T16:32:42.843" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12058" PostTypeId="1" CreationDate="2017-04-11T18:30:31.873" Score="3" ViewCount="1751" Body="&lt;p&gt;Is there a solution to printing unicode characters from &lt;code&gt;gvim&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vOwHt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vOwHt.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Results in this print result&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3XIZ2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3XIZ2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Using a Linux setup and Vim 8.0.) &lt;/p&gt;&#xA;" OwnerUserId="12163" LastActivityDate="2021-10-02T18:16:08.903" Title="Printing unicode chars?" Tags="|unicode|encoding|printing|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12059" PostTypeId="2" ParentId="2434" CreationDate="2017-04-11T18:35:24.707" Score="2" Body="&lt;p&gt;Just for the sake of completeness: If &lt;code&gt;kprinter4&lt;/code&gt; doesn't work, you can also make a parallel installation of (relevant components of) Trinity KDE (TDE) desktop, which is available in some distros such as Debian or Arch. Then you can use good old &lt;code&gt;kprinter&lt;/code&gt; instead of &lt;code&gt;kprinter4&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set popt=duplex:off &#xA;set printexpr=PrintFile(v:fname_in)&#xA;function PrintFile(fname)&#xA;  call system(&quot;/opt/trinity/bin/kprinter &quot; . a:fname)&#xA;  call delete(a:fname)&#xA;  return v:shell_error&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12163" LastActivityDate="2017-04-11T18:35:24.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12060" PostTypeId="2" ParentId="12046" CreationDate="2017-04-11T22:27:12.297" Score="4" Body="&lt;p&gt;To put the value of a variable into a buffer use the &lt;code&gt;:put&lt;/code&gt; command with the expression register, &lt;code&gt;@=&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;put=b:aaa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use a range with &lt;code&gt;:put&lt;/code&gt; to put it at a specific location. Put below the 9th line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;9put=b:aaa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: use &lt;code&gt;:put!&lt;/code&gt; to put above the current line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :put&#xA;:h @=&#xA;:h :range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-04-11T22:27:12.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12061" PostTypeId="1" AcceptedAnswerId="12062" CreationDate="2017-04-11T22:32:16.113" Score="34" ViewCount="5804" Body="&lt;p&gt;Is there an option to apply a setting in all tabs and windows, e.g. apply &lt;code&gt;:set number&lt;/code&gt; to all open tabs?&lt;/p&gt;&#xA;" OwnerUserId="9540" LastEditorUserId="14785" LastEditDate="2017-10-20T06:51:46.220" LastActivityDate="2023-01-10T22:21:43.590" Title="How to apply a setting in all open tabs and windows?" Tags="|vim-windows|options|set|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12062" PostTypeId="2" ParentId="12061" CreationDate="2017-04-11T22:37:41.807" Score="37" Body="&lt;p&gt;Yes, there is! You can accomplish this with &lt;code&gt;:tabdo&lt;/code&gt; and &lt;code&gt;:windo&lt;/code&gt;. For your case specifically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabdo windo set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/tabpage.txt.html#%3Atabdo&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :tabdo&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Awindo&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :windo&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="16967" LastEditDate="2018-09-06T18:47:10.197" LastActivityDate="2018-09-06T18:47:10.197" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="12063" PostTypeId="2" ParentId="12029" CreationDate="2017-04-11T23:12:02.123" Score="8" Body="&lt;p&gt;If the file has been saved the easiest way is simply to run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if the file has not been saved, this will result in an error. In this case a different command can be run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype detect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this seems like too much to type, a mapping can easily be made and placed in your &lt;code&gt;vimrc&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :filetype detect&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-04-11T23:12:02.123" CommentCount="0" CommunityOwnedDate="2017-04-11T23:12:02.123" ContentLicense="CC BY-SA 3.0" />
  <row Id="12064" PostTypeId="1" CreationDate="2017-04-12T01:20:22.470" Score="1" ViewCount="288" Body="&lt;p&gt;According to the Emacs tutorial:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Type M-x auto-fill-mode  now.  Then insert a line of &quot;asdf &quot;&#xA;     over again until you see it divide into two lines.  You must put in&#xA;     spaces between them because Auto Fill breaks lines only at spaces.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In other words, Emacs will automatically create a new line after a certain threshold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do the same in Vim, and how can I do this with already written text?&lt;/p&gt;&#xA;" OwnerUserId="12181" LastActivityDate="2017-04-12T01:51:37.450" Title="Emulate Emacs' &quot;auto-fill-mode&quot;" Tags="|autocompletion|" AnswerCount="0" CommentCount="1" ClosedDate="2017-04-12T02:18:10.217" ContentLicense="CC BY-SA 3.0" />
  <row Id="12066" PostTypeId="2" ParentId="12056" CreationDate="2017-04-12T02:22:03.567" Score="5" Body="&lt;p&gt;I would simply use &lt;code&gt;:rightbelow split&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="51" LastEditDate="2017-07-23T14:45:06.407" LastActivityDate="2017-07-23T14:45:06.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12067" PostTypeId="2" ParentId="11638" CreationDate="2017-04-12T04:25:29.843" Score="3" Body="&lt;p&gt;I added the functionality I wanted to vimwiki and &lt;a href=&quot;https://github.com/vimwiki/vimwiki/pull/331&quot; rel=&quot;nofollow noreferrer&quot;&gt;submitted a pull request&lt;/a&gt; to get it incorporated into the main body of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the process of doing this, I realized I can accomplish my larger goal using &lt;code&gt;blockquote&lt;/code&gt; and CSS that vimwiki also currently provides.&lt;/p&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="205" LastEditDate="2017-04-12T04:55:36.900" LastActivityDate="2017-04-12T04:55:36.900" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12068" PostTypeId="2" ParentId="12061" CreationDate="2017-04-12T05:34:04.500" Score="9" Body="&lt;p&gt;&lt;code&gt;:tabdo windo set number&lt;/code&gt; gets the job done, but I don't really like it since it actually switches to each tab and window before running the command.  After it finishes running, you'll end up on the last window of the last tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this is a cleaner way to set options in all windows without changing the current tab and window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:set_all(option, val, ...) abort&#xA;  let val = eval(a:val)&#xA;&#xA;  for t in range(1, tabpagenr('$'))&#xA;    for w in range(1, tabpagewinnr(t, '$'))&#xA;      if gettabwinvar(t, w, '&amp;amp;buftype') !=# ''&#xA;        continue&#xA;      endif&#xA;      call settabwinvar(t, w, '&amp;amp;'.a:option, val)&#xA;    endfor&#xA;  endfor&#xA;endfunction&#xA;&#xA;command! -complete=option -nargs=+ SetAll call s:set_all(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:SetAll number 1&lt;/code&gt; will enable the number column in all windows, except for the ones that have &lt;code&gt;buftype&lt;/code&gt; set, such as help windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the same as running: &lt;code&gt;:tabdo windo let &amp;amp;number = 1&lt;/code&gt;.  So, the second argument needs to be an assignable expression.  Instead of &lt;code&gt;:set filetype=ini&lt;/code&gt;, it would be &lt;code&gt;:SetAll filetype &quot;ini&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-04-12T05:34:04.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12069" PostTypeId="2" ParentId="12056" CreationDate="2017-04-12T06:11:27.290" Score="1" Body="&lt;p&gt;There is a plugin for that &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=208&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. I've checked it and it works with Vim8, although plugin was written for Vim6. It opens a window above and updates it on CursorHold event. It's supposed to work only with C files, but adding line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au CursorHold  *.[cC][pP][pP] call &amp;lt;SID&amp;gt;cursorhold()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;right after line &lt;code&gt;431&lt;/code&gt; makes it work with C++ files as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&#xA;I've managed to update the script to include C++ classes (and it should work with Pike programming language f.ex. as well). I'll update it a bit more later on. Updated version can be found &lt;a href=&quot;https://github.com/grodzik/vim-ctx&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2017-04-13T11:57:45.210" LastActivityDate="2017-04-13T11:57:45.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12070" PostTypeId="1" CreationDate="2017-04-12T08:54:36.567" Score="2" ViewCount="463" Body="&lt;p&gt;Trying to create a simple syntax highlighting for a special file type we use. &#xA;within this file there are simple functions defined which I match using keywords:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword Funcs foo bar baz&#xA;hi def link Func Special &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The functions can take arguments which are type-less: &#xA;    foo(arg1, arg2, arg3)&#xA;The keywords take care of coloring the function name + parentheses but not the arguments. &#xA;I would like to get those colored but cannot seem to get it to work.&#xA;Tried with :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword Funcs foo bar baz contains=arguments&#xA;syn match arguments &quot;(\s*\w\+,*)\+&quot; contained&#xA;hi def link Func Special &#xA;hi def link arguments Type&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I missing here? &lt;/p&gt;&#xA;" OwnerUserId="12188" LastActivityDate="2017-04-12T08:54:36.567" Title="syntax highlight function arguments" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12071" PostTypeId="2" ParentId="11969" CreationDate="2017-04-12T09:16:48.523" Score="1" Body="&lt;p&gt;I asked the same question over at &lt;a href=&quot;https://unix.stackexchange.com/questions/356354/vim-stop-curly-braces-navigation-from-leaving-marks&quot;&gt;unix.stackexchange.com&lt;/a&gt; where DJMcMayhem prvoided an excellent answer:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can use the &lt;code&gt;keepjumps&lt;/code&gt; command. From &lt;code&gt;:h :keepjumps&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *:keepj* *:keepjumps* :keepj[umps] {command}&#xA;        Moving around in {command} does not change the |''|,&#xA;        |'.| and |'^| marks, the |jumplist| or the&#xA;        |changelist|.&#xA;        Useful when making a change or inserting text&#xA;        automatically and the user doesn't want to go to this&#xA;        position.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;So in your case, you'd want&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap } :keepjumps normal! }&amp;lt;cr&amp;gt;&#xA;nnoremap { :keepjumps normal! {&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Or, if you want it to work for visual mode too (which your&#xA;  probably do):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap } :&amp;lt;C-u&amp;gt;keepjumps normal! gv}&amp;lt;cr&amp;gt;&#xA;xnoremap { :&amp;lt;C-u&amp;gt;keepjumps normal! gv{&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="12054" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.790" LastActivityDate="2017-04-12T09:16:48.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12072" PostTypeId="2" ParentId="12030" CreationDate="2017-04-12T10:16:26.827" Score="-1" Body="&lt;p&gt;For the first one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\(.*\)\s*=\s*\(.*\);/EQUATE(\1, \2);/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then on subsequent lines, just press &lt;code&gt;&amp;amp;&lt;/code&gt; and it will do the same replacement again.&lt;/p&gt;&#xA;" OwnerUserId="7710" LastEditorUserId="7710" LastEditDate="2017-04-14T08:22:40.963" LastActivityDate="2017-04-14T08:22:40.963" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12073" PostTypeId="1" CreationDate="2017-04-12T15:56:07.410" Score="2" ViewCount="306" Body="&lt;p&gt;Currently, I'm using &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Surround&lt;/a&gt; to make quoting easy on &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Multiple whole-lines&lt;/li&gt;&#xA;&lt;li&gt;Visual blocks&lt;/li&gt;&#xA;&lt;li&gt;Individual words&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, it doesn't seem to make the job easy on columns, for example. Take &lt;a href=&quot;https://stackoverflow.com/q/43328774/124486&quot;&gt;this question for example&lt;/a&gt;, I can get to this from the sample data&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'A', owner_from , 12/17/2016 8:57:00  , 12/19/2016 9:01:05 &#xA;'B', owner_to   , 12/17/2016 8:57:00  , 12/17/2016 12:03:10&#xA;'B', closed     , 12/17/2016 12:03:10             &#xA;'C', opened     , 12/18/2016 4:57:36  , 12/18/2016 4:57:36 &#xA;'C', owner_to   , 12/18/2016 4:57:36  , 12/18/2016 4:57:36 &#xA;'C', owner_from , 12/18/2016 4:57:36  , 12/18/2016 10:20:37&#xA;'C', owner_to   , 12/18/2016 10:20:37 , 12/18/2016 12:32:56&#xA;'D', owner_from , 12/18/2016 10:20:37 , 12/18/2016 10:36:53&#xA;'E', owner_from , 12/18/2016 10:36:53             &#xA;'D', owner_to   , 12/18/2016 10:36:53 , 12/20/2016 9:23:34 &#xA;'C', closed     , 12/18/2016 12:32:56 , 12/19/2016 4:48:33 &#xA;'C', opened     , 12/19/2016 4:48:33  , 12/19/2016 6:55:39 &#xA;'C', closed     , 12/19/2016 6:55:39              &#xA;'A', opened     , 12/19/2016 9:01:05  , 12/19/2016 9:01:05 &#xA;'A', owner_to   , 12/19/2016 9:01:05  , 12/19/2016 9:01:05 &#xA;'A', owner_from , 12/19/2016 9:01:05  , 12/19/2016 9:04:58 &#xA;'A', closed     , 12/19/2016 9:04:58  , 12/19/2016 9:08:21 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I can not continue and quote that second column whose first row has &lt;code&gt;owner_from&lt;/code&gt;. What I want to do is&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;select the &lt;code&gt;[o]wnerfrom&lt;/code&gt; and change all the inner words from the top to the bottom.&lt;/li&gt;&#xA;&lt;li&gt;or, select the entire word and have it quote just the word and note white space.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'd like to know if this can be done using vim-surround first, and if not if there is a better way to do it.&lt;/p&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-04-12T21:28:04.700" Title="How do I quote tabulated columns?" Tags="|visual-block|multiple-lines|plugin-vim-surround|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12074" PostTypeId="2" ParentId="12073" CreationDate="2017-04-12T16:11:50.970" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;:normal&lt;/code&gt; to run a series of normal commands on lines in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm Wysiw'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will skip to the second WORD and then use surround's &lt;code&gt;ys&lt;/code&gt; command to surround with &lt;code&gt;'&lt;/code&gt; on the current &lt;code&gt;iw&lt;/code&gt; text object. It does this for every line in the buffer, &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :norm&#xA;:h :range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-04-12T16:11:50.970" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12075" PostTypeId="1" AcceptedAnswerId="12077" CreationDate="2017-04-12T20:50:05.320" Score="1" ViewCount="420" Body="&lt;p&gt;Is there a way to do a forward (resp. backward) repeat search with &lt;code&gt;n&lt;/code&gt; (resp. &lt;code&gt;N&lt;/code&gt;) indifferently I start the research with &lt;code&gt;/&lt;/code&gt;/&lt;code&gt;*&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;/&lt;code&gt;#&lt;/code&gt;  ?&lt;/p&gt;&#xA;" OwnerUserId="63" LastActivityDate="2017-04-12T21:19:13.967" Title="Consistent repeat search" Tags="|search|" AnswerCount="1" CommentCount="1" ClosedDate="2017-04-12T22:43:00.473" ContentLicense="CC BY-SA 3.0" />
  <row Id="12076" PostTypeId="2" ParentId="12073" CreationDate="2017-04-12T21:07:59.290" Score="3" Body="&lt;p&gt;Seems like a great job for macros. Peter Rincker's may be fewer keystrokes, but I feel it's worth mentioning as if you need a more specific range than the whole file, it's a little easier to modify.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With your cursor on the first column of the first line do the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; to start a macro&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Wysiw'+&lt;/code&gt; Uses &lt;code&gt;ys&lt;/code&gt; on second WORD (Just like Peter's) and moves to the next line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt; to end the macro&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;#@q&lt;/code&gt; Replace &lt;code&gt;#&lt;/code&gt; with the actual number of lines you want to run the macro on. (&lt;code&gt;@q&lt;/code&gt; runs macro 'q')&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if you don't have the surround plugin, replace the second line with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Wi'&lt;/code&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;code&gt;ea'&lt;/code&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;code&gt;+&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#recording&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help recording&lt;/code&gt;&lt;/a&gt; for more info on macros.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-04-12T21:28:04.700" LastActivityDate="2017-04-12T21:28:04.700" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12077" PostTypeId="2" ParentId="12075" CreationDate="2017-04-12T21:19:13.967" Score="2" Body="&lt;p&gt;I am not sure where I copied these from, but they make &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; always go in the same direction&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; n 'Nn'[v:searchforward] . 'zv'&#xA;nnoremap &amp;lt;expr&amp;gt; N 'nN'[v:searchforward] . 'zv'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-04-12T21:19:13.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12078" PostTypeId="1" AcceptedAnswerId="12080" CreationDate="2017-04-12T21:30:35.063" Score="2" ViewCount="102" Body="&lt;p&gt;Instead of using &lt;code&gt;tabnext&lt;/code&gt; and &lt;code&gt;tabprevious&lt;/code&gt; is there a command or a plugin which can list your tabs vertically so you can navigate up and down and choose the one to switch to?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am thing along the lines of the &lt;code&gt;Ctrl-a &quot;&lt;/code&gt; command in &lt;code&gt;screen&lt;/code&gt; which lists your windows for you to select the one to switch to.&lt;/p&gt;&#xA;" OwnerUserId="9540" LastActivityDate="2017-04-13T04:20:02.280" Title="Rather than tabnext and tabprevious can I get a list of tabs and select the one to switch to?" Tags="|tabbed-user-interface|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12079" PostTypeId="1" CreationDate="2017-04-13T02:04:04.700" Score="2" ViewCount="578" Body="&lt;p&gt;How do I mimic the behavior of Doxygen comment highlighting for PC-lint comments? Comments are in the following formats:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/*lint ... */&#xA;//lint ...&#xA;/* LINTLIBRARY */&#xA;/* ARGUSED */&#xA;/* VARARGS[N] */ &amp;lt;--- N is a number&#xA;/* NOTREACHED */&#xA;/* NOSTRICT */&#xA;/* FALLTHROUGH */&#xA;/* FALLTHRU */&#xA;/* PRINTFLIKEN */ &amp;lt;--- N is a number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Ideally highlighting would mimic the behavior of Doxygen comment highlighting.&lt;/p&gt;&#xA;&lt;p&gt;EDIT: I want to make lint comments highlight like the Doxygen comment in the screenshot.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/JRHZ6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JRHZ6.png&quot; alt=&quot;like this&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8395" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-04-14T03:03:53.170" Title="How do I highlight pc-lint comments in C/C++" Tags="|syntax-highlighting|comments|filetype-c|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12080" PostTypeId="2" ParentId="12078" CreationDate="2017-04-13T04:20:02.280" Score="4" Body="&lt;p&gt;To expand on @Tumbler41's comment about &lt;code&gt;:tabs&lt;/code&gt;, it shows you a list of tabs like &lt;code&gt;:ls&lt;/code&gt; shows you buffers.  But, there isn't a command to go directly to a tab from this list like using &lt;code&gt;:b&lt;/code&gt; after &lt;code&gt;:ls&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can fake it by using &lt;code&gt;:&amp;lt;count&amp;gt;tabdo:&lt;/code&gt;.  The colon at the end is basically a no-op command that's considered a valid argument for &lt;code&gt;:tabdo&lt;/code&gt;.  To streamline this, you can turn it into a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! T tabs|execute input('Select Tab: ').'tabdo:'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After the tabs are listed, you enter a number and press &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to jump to the tab.  The same thing can be done with &lt;code&gt;:ls&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! L ls|execute input('Select Buffer: ').'b'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The caveat here is that if listing scrolls, you won't be able to scroll back up once the prompt is displayed.  Another problem is that this accepts any input which aren't a valid command count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a version that's a little safer but more verbose:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! T tabs|execute substitute(input('Select Tab: '), '^\d\+$', '\0tabdo:', '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The substitution only adds &lt;code&gt;tabdo:&lt;/code&gt; if the input is all digits.  Otherwise, the input is executed as-is.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-04-13T04:20:02.280" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12081" PostTypeId="1" AcceptedAnswerId="12088" CreationDate="2017-04-13T08:20:17.630" Score="3" ViewCount="776" Body="&lt;p&gt;On profiling, I found that &lt;code&gt;&amp;lt;SNR&amp;gt;101_parse_screen()&lt;/code&gt; is taking above 6 seconds. This problem goes away when I comment out the plugin &lt;a href=&quot;https://github.com/sheerun/vim-polyglot&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-polyglot&lt;/a&gt;.&#xA;This is most evident for vue files. Not sure if it's a bug, so posting this here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not using &lt;code&gt;vim-polyglot&lt;/code&gt; is a possible solution, but it seems to work best for me, and don't want to abandon it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;any workarounds?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will add more details if needed.&lt;/p&gt;&#xA;" OwnerUserId="5178" LastEditorUserId="51" LastEditDate="2017-04-14T03:03:08.253" LastActivityDate="2017-04-14T03:03:08.253" Title="neovim takes a long time to open files" Tags="|syntax-highlighting|performance|plugin-vim-polyglot|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12082" PostTypeId="1" AcceptedAnswerId="12085" CreationDate="2017-04-13T11:26:54.740" Score="1" ViewCount="198" Body="&lt;p&gt;In my .vimrc-file I have these commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Add normal cursor-behavior on screen&#xA;noremap  &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; k gk&#xA;noremap  &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; j gj&#xA;noremap  &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; 0 g0&#xA;noremap  &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; $ g$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when I press &lt;code&gt;j&lt;/code&gt;, then it goes down one &lt;em&gt;visual&lt;/em&gt; line on the screen. However... Sometimes when I load a document, then that doesn't always work. It's strange because sometimes it works and sometimes it doesn't. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, when I created a &lt;code&gt;temp.txt&lt;/code&gt;-file on my desktop, copied in a long line and made a &lt;code&gt;:vsplit&lt;/code&gt; (to make the screen more narrow)... Then it worked as it should.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I used &lt;code&gt;vim ftp://username@host//&lt;/code&gt;, opened a file in a tab, did a &lt;code&gt;:vsplit&lt;/code&gt;, then it &lt;em&gt;didn't&lt;/em&gt; work! ... Here comes the strange part. I then close that file, with the ftp-connection still open. Then I repeat the &lt;em&gt;exact same procedure&lt;/em&gt;, and then it works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing that &lt;em&gt;always&lt;/em&gt; fixes it, is to write &lt;code&gt;:so $MYVIMRC&lt;/code&gt;. Regardless of where I am (FTP-server, locally, whereever), - then writing that, fixes it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to move the four lines to the bottom of my &lt;code&gt;.vimrc&lt;/code&gt;-file, but with no luck. My best guess is that Vim loads some other &lt;code&gt;.vimrc&lt;/code&gt;-file after my &lt;code&gt;$MYVIMRC&lt;/code&gt;-file sometimes, which overwrites this command. So I checked, by writing &lt;code&gt;:version&lt;/code&gt;, which gave this output: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;system vimrc file: &quot;$VIM/vimrc&quot;&#xA;user vimrc file: &quot;$HOME/.vimrc&quot;&#xA;2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;user exrc file: &quot;$HOME/.exrc&quot;&#xA;defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are there a way, where I can ensure that Vim, in a way, always do a &lt;code&gt;:so $MYVIMRC&lt;/code&gt; as the last thing, after it has loaded? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have Vim-version 7.4, compiled by Homebrew and are working on a Mac.&lt;/p&gt;&#xA;" OwnerUserId="9194" LastEditorUserId="51" LastEditDate="2017-04-14T03:01:59.203" LastActivityDate="2017-04-14T03:01:59.203" Title="Mappings defined in vimrc file only work sometimes?" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12084" PostTypeId="1" CreationDate="2017-04-13T13:58:32.827" Score="2" ViewCount="194" Body="&lt;h2&gt;Background:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I can pipe a paragraph through an external command using &lt;code&gt;!ip&lt;/code&gt; and the cursor goes to the end of the following prompt:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:.,.+5!&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I want to use the built-in sort or center functions I could specify the line numbers manually, but I have relative numbers so I would need to count or use visual mode. So currently I use, for example, &lt;code&gt;!ip&amp;lt;backspace&amp;gt;sort&lt;/code&gt; or &lt;code&gt;!2}&amp;lt;backspace&amp;gt;center&lt;/code&gt;. This gives me the flexibility to use any kind of range for the command, and I can run it from anywhere inside the range.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Is there a way I could do something similar to &lt;code&gt;!&amp;lt;range&amp;gt;&lt;/code&gt; but ending up without the &lt;code&gt;!&lt;/code&gt; at the end of the prompt, that I then need to delete? Something like &lt;code&gt;&amp;lt;foo&amp;gt;ipsort&lt;/code&gt; to end up with &lt;code&gt;:.,.+6sort&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12209" LastEditorUserId="12209" LastEditDate="2017-04-13T14:16:13.937" LastActivityDate="2022-04-01T14:31:02.190" Title="Prepare a range for an ex command without visual mode or line numbers" Tags="|cursor-motions|ex-mode|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12085" PostTypeId="2" ParentId="12082" CreationDate="2017-04-13T16:11:37.340" Score="4" Body="&lt;p&gt;Remove &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; keyword. Adding it makes a mapping local to a buffer (&lt;code&gt;:h map-&amp;lt;buffer&amp;gt;&lt;/code&gt;), and if used in global scope in&lt;code&gt;.vimrc&lt;/code&gt; makes it valid for the first buffer only (or the one in which &lt;code&gt;.vimrc&lt;/code&gt; was sourced).&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-04-13T16:11:37.340" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12086" PostTypeId="2" ParentId="12079" CreationDate="2017-04-13T16:53:43.337" Score="3" Body="&lt;p&gt;Did you have a look at &lt;code&gt;syntax/doxygen.vim&lt;/code&gt;? This is where doxygen highlighting is defined. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to do then, is to add a file for pclint in &lt;code&gt;~/.vim/syntax/&lt;/code&gt;, and a syntax rule inspired from the one in &lt;code&gt;syntax/synload.vim&lt;/code&gt; which is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au Syntax c,cpp,cs,idl,java,php,datascript&#xA;    \ if (exists('b:load_doxygen_syntax') &amp;amp;&amp;amp; b:load_doxygen_syntax)&#xA;    \   || (exists('g:load_doxygen_syntax') &amp;amp;&amp;amp; g:load_doxygen_syntax)&#xA;    \   | runtime! syntax/doxygen.vim&#xA;    \ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#mysyntaxfile&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h mysyntaxfile&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-04-13T16:53:43.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12088" PostTypeId="2" ParentId="12081" CreationDate="2017-04-13T19:47:08.657" Score="3" Body="&lt;p&gt;I did a search on &lt;a href=&quot;https://github.com/search?q=language%3A%22Vim+Script%22+parse_screen&amp;amp;type=Code&amp;amp;utf8=%E2%9C%93&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub&lt;/a&gt; and &lt;a href=&quot;https://www.google.com/search?q=inurl:vim+%22parse_screen%22&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google&lt;/a&gt;.  From the results, it's pretty reasonable to assume that that function is from &lt;a href=&quot;https://github.com/ap/vim-css-color&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-css-color&lt;/a&gt;, which isn't in &lt;code&gt;vim-polyglot&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact it looks like it was removed in 2015 for &lt;a href=&quot;https://github.com/sheerun/vim-polyglot/commit/c154d82557a4a7642510ee9a4f0c1a8efb9af7e2&quot; rel=&quot;nofollow noreferrer&quot;&gt;performance reasons&lt;/a&gt;.  Are you sure you're using the most recent version of &lt;code&gt;vim-polyglot&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-04-13T19:47:08.657" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12089" PostTypeId="1" AcceptedAnswerId="12090" CreationDate="2017-04-14T00:49:06.270" Score="5" ViewCount="1695" Body="&lt;p&gt;When I enter visual mode, &lt;code&gt;:'&amp;lt;,'&amp;gt;sort&lt;/code&gt; allows me to sort alphabetically the lines I have selected, obviously starting from the left most characters on a line going to the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to reverse this, so I sort alphabetically with the right most characters to the left?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2017-04-14T18:10:08.447" Title="How to sort lines by the right most characters?" Tags="|visual-mode|alignment|sort|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12090" PostTypeId="2" ParentId="12089" CreationDate="2017-04-14T01:45:21.917" Score="10" Body="&lt;p&gt;If you can use the &lt;code&gt;rev&lt;/code&gt; command, you could reverse each line, sort and reverse again, using external commands in a pipe:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%!rev | sort | rev&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be done entirely in Vimscript, but it's way more verbose:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RTLSort() range&#xA;    &quot; reversing function for use with map()&#xA;    function! Rev(k, str)&#xA;        &quot; the first argument from map() is an index, so it's ignored.&#xA;        return join(reverse(split(a:str, '\zs')), '')&#xA;    endfunction&#xA;    let l:Rev = function(&quot;Rev&quot;)&#xA;    let l:lines = getline(a:firstline, a:lastline)&#xA;    call setline(a:firstline, map(sort(map(l:lines, l:Rev)), l:Rev))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%call RTLSort()&#xA;:3,9 call RTLSort()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-04-14T01:45:21.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12091" PostTypeId="2" ParentId="12005" CreationDate="2017-04-14T03:20:28.320" Score="6" Body="&lt;p&gt;You can use &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%3Apackloadall&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:packloadall!&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Load all packages in the &quot;start&quot; directory under each entry in &lt;code&gt;'packpath'&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[..]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This is normally done automatically during startup, after loading your .vimrc&#xA;  file.  With this command it can be done earlier.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[..]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Packages will be loaded only once.  After this command&#xA;  it won't happen again.  When the optional ! is added&#xA;  this command will load packages even when done before.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There's also the &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%3Apackadd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:packadd&lt;/code&gt;&lt;/a&gt; command, but that will only load from &lt;code&gt;pack/*/opt&lt;/code&gt;, not &lt;code&gt;pack/*/start&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-04-14T03:20:28.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12092" PostTypeId="1" AcceptedAnswerId="12094" CreationDate="2017-04-14T14:02:37.353" Score="3" ViewCount="1583" Body="&lt;p&gt;When using netrw with the tree style listing (&lt;code&gt;netrw_liststyle = 3&lt;/code&gt;), if I expand a directory, open a file in that directory, then try to open a file above that directory, it creates a new empty file in the lower directory with the same name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I have the following directory structure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.&#xA;├── baz.txt&#xA;└── foo&#xA;    ├── bar&#xA;    │   └── bar.txt&#xA;    └── foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I open the &lt;code&gt;bar&lt;/code&gt; directory, then &lt;code&gt;bar.txt&lt;/code&gt;. Then I attempt to open &lt;code&gt;baz.txt&lt;/code&gt; and instead of opening the file, vim creates an empty file &lt;code&gt;/foo/bar/baz.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way for netrw to know the full paths of the files listed, or does it simply run &lt;code&gt;:edit&lt;/code&gt; on the file name without the full path?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I'm using vim 8.0.427 and netrw v156.&lt;/p&gt;&#xA;" OwnerUserId="12224" LastEditorUserId="12224" LastEditDate="2017-04-14T19:35:04.943" LastActivityDate="2017-04-14T19:43:50.827" Title="Netrw tree listing style opening files in other directories creates new empty files in current directory" Tags="|netrw|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12094" PostTypeId="2" ParentId="12092" CreationDate="2017-04-14T19:43:50.827" Score="3" Body="&lt;p&gt;I was able to fix this issue by using &lt;code&gt;:Lexplore&lt;/code&gt; to open the netrw listing and removing the setting &lt;code&gt;netrw_browse_split = 4&lt;/code&gt; from my .vimrc.&lt;/p&gt;&#xA;" OwnerUserId="12224" LastActivityDate="2017-04-14T19:43:50.827" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12095" PostTypeId="1" CreationDate="2017-04-15T17:52:26.267" Score="2" ViewCount="708" Body="&lt;p&gt;When I mark a directory with &lt;code&gt;mf&lt;/code&gt;, then use &lt;code&gt;mc&lt;/code&gt; to copy into the target directory, it copies the contents only rather than the directory itself. I know I could make a new directory with &lt;code&gt;d&lt;/code&gt;, then copy the files into it, but I'd rather clone the directory in one step if possible.&lt;/p&gt;&#xA;" OwnerUserId="12235" LastEditorUserId="1841" LastEditDate="2017-04-16T15:01:41.897" LastActivityDate="2017-04-19T17:56:44.150" Title="Is it possible to clone a directory with netrw?" Tags="|netrw|filesystem|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12096" PostTypeId="1" AcceptedAnswerId="12112" CreationDate="2017-04-16T09:16:52.607" Score="0" ViewCount="1497" Body="&lt;p&gt;This is similar to &lt;a href=&quot;https://vi.stackexchange.com/questions/6134/mapping-ctrl-z-in-insert-mode&quot;&gt;a previous question re: Ctrl-Z&lt;/a&gt;. The context is different though: I use a bash shell window, in which I am in insert mode.&#xA;Hitting &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;^&lt;/kbd&gt; in this mode means that I probably meant to switch to my other buffer.&lt;/p&gt;&#xA;" OwnerUserId="5919" LastEditorUserId="6489" LastEditDate="2017-04-17T16:04:10.813" LastActivityDate="2017-09-06T07:47:54.363" Title="Mapping Ctrl-Caret in insert mode?" Tags="|key-bindings|plugin-conque|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12100" PostTypeId="1" AcceptedAnswerId="12102" CreationDate="2017-04-16T19:30:00.213" Score="2" ViewCount="999" Body="&lt;p&gt;In my .vimrc I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;Leader&amp;gt;c :GitGutterToggle&amp;lt;CR&amp;gt;&#xA;map &amp;lt;Leader&amp;gt;n :set invnumber&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can combine these two into one Leader entry?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;Leader&amp;gt;c :GitGutterToggle &amp;amp;&amp;amp; :set invnumber&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried the above, and variations thereof, to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="12243" LastActivityDate="2017-04-16T21:26:56.873" Title="In vimrc, how can I chain multiple instructions in one Leader command" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12101" PostTypeId="1" CreationDate="2017-04-16T19:46:30.227" Score="1" ViewCount="903" Body="&lt;p&gt;I am in the process of customizing my vim setup, and since I write a lot in C, I have a whole function dedicated just for those files, which I call with &lt;code&gt;autocmd filetype c,cpp,h,hpp call C_syntax()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue I'm having is that I want auto folding to occur on .c and .cpp files, but not .h and .hpp files. In order to do this, I have tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function C_syntax()&#xA;    autocmd filetype c,cpp setlocal foldmethod=syntax&#xA;    &quot;---snip---&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which disables folding for &lt;em&gt;all&lt;/em&gt; files (.c and .cpp included), as well as this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd filetype c,cpp,h,hpp call C_syntax()&#xA;autocmd filetype c,cpp setlocal foldmethod=syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which enables it for .h and .hpp files as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I go about enabling the folding for only .c and .cpp files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help&lt;/p&gt;&#xA;" OwnerUserId="12244" LastActivityDate="2017-05-17T17:37:29.873" Title="Set folding method for c and cpp files, but not h and hpp" Tags="|folding|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12102" PostTypeId="2" ParentId="12100" CreationDate="2017-04-16T21:21:23.997" Score="3" Body="&lt;p&gt;One way to do that is &lt;code&gt;map &amp;lt;leader&amp;gt;c :execute 'GitGutterToggle \| set invnumber'&amp;lt;cr&amp;gt;&lt;/code&gt;&#xA;I don't have gitgutter so I've tested it with &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;c :exe 'echom &quot;some&quot; \| echom &quot;other&quot;'&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact it's even simpler than that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;c :echo 'some' \| echo 'other'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6634" LastEditDate="2017-04-16T21:26:56.873" LastActivityDate="2017-04-16T21:26:56.873" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12104" PostTypeId="1" AcceptedAnswerId="13089" CreationDate="2017-04-17T06:56:15.163" Score="58" ViewCount="103661" Body="&lt;p&gt;I didn't put &lt;code&gt;color xxx&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;. So I see this when I first open my &lt;code&gt;.vimrc&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:color&lt;/code&gt; gives me &lt;code&gt;default&lt;/code&gt; here.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/oKvmE.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oKvmE.png&quot; alt=&quot;Before anything&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I type &lt;code&gt;:color darcula&lt;/code&gt;. And it changes to this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:color&lt;/code&gt; gives me &lt;code&gt;darcula&lt;/code&gt; here (naturally).&#xA;&lt;a href=&quot;https://i.stack.imgur.com/NCsEE.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NCsEE.png&quot; alt=&quot;Change colorscheme&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I type &lt;code&gt;:set background=dark&lt;/code&gt;. And it changes to this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:color&lt;/code&gt; gives me &lt;code&gt;default&lt;/code&gt; here (amazingly).&#xA;&lt;a href=&quot;https://i.stack.imgur.com/MNPSe.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MNPSe.png&quot; alt=&quot;Change background&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is, what exactly does &lt;code&gt;:set background=dark&lt;/code&gt; do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;:h background&lt;/code&gt; and didn't find anything helpful. I understand that this command doesn't actually change the background, only vim will change colors accordingly. But I still want to ask this question. Because I'm really happy with the color after &lt;code&gt;:color darcula&lt;/code&gt; and &lt;code&gt;:set background=dark&lt;/code&gt; so I wonder how to write my own color scheme without having to put &lt;code&gt;set background=dark&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I took advice from @statox and put &lt;code&gt;set background=dark&lt;/code&gt; at the last line of my &lt;code&gt;darcula.vim&lt;/code&gt;. Then &lt;code&gt;color darcula&lt;/code&gt; gives me the third screenshot. However when I put it at the first line, &lt;code&gt;color darcula&lt;/code&gt; gives me the second screenshot. Also &lt;code&gt;set bg=dark&lt;/code&gt; changes it to the third screenshot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assumed by putting it at the first line, I'm telling vim that this colorscheme is designed for a dark background. By putting it at the last line, on the contrast, I let vim assume that this colorscheme is designed for a light background and then make vim change some of it by itself (when it processes the last line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If what I assume happened is true, my question is still unanswered. What exactly did vim change, when I use &lt;code&gt;set bg=dark&lt;/code&gt; AFTER it has loaded a light colorscheme?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My entire vim configuration is available at &lt;a href=&quot;https://github.com/MichaelMa2014/.vim&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/MichaelMa2014/.vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11755" LastEditorUserId="11755" LastEditDate="2017-06-30T02:12:17.953" LastActivityDate="2022-10-18T10:09:31.697" Title="What does :set background=dark do?" Tags="|colorscheme|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12105" PostTypeId="2" ParentId="12101" CreationDate="2017-04-17T10:04:35.180" Score="2" Body="&lt;p&gt;In a c ftplugin, check (&lt;code&gt;:h :if&lt;/code&gt;) for the extension of the current buffer (with &lt;code&gt;: h expand ()&lt;/code&gt;). If you match a header file don't set the option. Otherwise do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can define the thing with autocommands, but it's easy to get it wrong, beside it doesn't scale well &lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-04-17T10:04:35.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12106" PostTypeId="2" ParentId="12104" CreationDate="2017-04-17T12:21:52.883" Score="7" Body="&lt;p&gt;The doc at &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27background%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'background'&lt;/code&gt;&lt;/a&gt;&#xA;should provide all the information you need:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When set to &quot;dark&quot;, Vim will try to use colors that look good on a&#xA;  dark background.  When set to &quot;light&quot;, Vim will try to use colors that&#xA;  look good on a light background.  Any other value is illegal.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your colorscheme defines 2 groups of colors: the ones used on a light background&#xA;and the ones used on a dark background. The &lt;code&gt;background&lt;/code&gt; option will tell vim&#xA;which group of colors defined by your colorscheme should be used.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Setting this option does not change the background color, it tells Vim&#xA;  what the background color looks like.  For changing the background&#xA;  color, see &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3ahi%2dnormal&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :hi-normal&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When 'background' is set Vim will adjust the default color groups for&#xA;  the new value.  But the colors used for syntax highlighting will not&#xA;  change.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's the follow up of the previous paragraph: It's the colorscheme which&#xA;defines the groups of colors and &lt;code&gt;background&lt;/code&gt; selects one of these groups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally if you want to write your own color scheme without having to put &lt;code&gt;set background=dark&lt;/code&gt; in your vimrc, remember that a colorscheme is nothing more than a program in vimscript, so nothing stops you from using the command directly in the code of your colorscheme like e.g. &lt;a href=&quot;https://github.com/nanotech/jellybeans.vim/blob/master/colors/jellybeans.vim#L58&quot; rel=&quot;noreferrer&quot;&gt;jellybeans&lt;/a&gt; or &lt;a href=&quot;https://github.com/romainl/Apprentice/blob/master/colors/apprentice.vim#L45&quot; rel=&quot;noreferrer&quot;&gt;apprentice&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="11054" LastEditDate="2018-04-17T09:54:17.303" LastActivityDate="2018-04-17T09:54:17.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12107" PostTypeId="2" ParentId="12004" CreationDate="2017-04-17T13:15:10.083" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;Vim help says (:h 10.3):&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Note:&#xA;&lt;strong&gt;When using Visual mode to select part of a line, or using CTRL-V to&#xA;select a block of text, the colon commands will still apply to whole&#xA;lines.&lt;/strong&gt;  This might change in a future version of Vim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;The plugin &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1195&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;vis&lt;/strong&gt; (#1195)&lt;/a&gt; by Charles Campbell offers the command &lt;code&gt;:B {cmd}&lt;/code&gt; to apply a &lt;code&gt;{cmd}&lt;/code&gt; only to the visual (block) selection.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2021-08-06T06:17:29.117" LastActivityDate="2021-08-06T06:17:29.117" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="12108" PostTypeId="2" ParentId="8955" CreationDate="2017-04-17T13:21:22.593" Score="3" Body="&lt;p&gt;I allow myself to answer myself, following my shared proposal:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/solyarisoftware/ChatScript.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/solyarisoftware/ChatScript.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not a vimL regex expert and any suggestion/update is very welcome.&lt;/p&gt;&#xA;" OwnerUserId="983" LastEditorUserId="983" LastEditDate="2018-06-29T15:00:28.433" LastActivityDate="2018-06-29T15:00:28.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12109" PostTypeId="1" AcceptedAnswerId="12111" CreationDate="2017-04-17T14:08:13.060" Score="1" ViewCount="727" Body="&lt;p&gt;I need to create regex in VIM (for plugin purpose) which would work as follows:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Expected behavior:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;||&lt;/code&gt; characters indicate current cursor position, bold words indicate matching words&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example nr 1:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;foo &lt;strong&gt;bar&lt;/strong&gt; foo &lt;strong&gt;bar&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;foo b|a|r foo &lt;strong&gt;bar&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;foo &lt;strong&gt;bar&lt;/strong&gt; foo &lt;strong&gt;bar&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Two &lt;code&gt;bar&lt;/code&gt;s from first line match. First &lt;code&gt;bar&lt;/code&gt; from the second line does not match because the cursor is currently placed on it. Second &lt;code&gt;bar&lt;/code&gt; in the second line do match. Two &lt;code&gt;bar&lt;/code&gt;s from third line match.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example nr 2:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;foo&lt;/strong&gt; bar &lt;strong&gt;foo&lt;/strong&gt; bar&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;foo&lt;/strong&gt; bar &lt;strong&gt;foo&lt;/strong&gt; bar&lt;/li&gt;&#xA;&lt;li&gt;fo|o| bar &lt;strong&gt;foo&lt;/strong&gt; bar&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Two &lt;code&gt;foo&lt;/code&gt;s from first line match. Two &lt;code&gt;foo&lt;/code&gt;s from the second line match. First &lt;code&gt;foo&lt;/code&gt; from the third line does no match as the cursor is currently placed on it. Second &lt;code&gt;foo&lt;/code&gt; from the third line do match.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So I was tinkering a bit with it and I managed to create the regex which will match all words like one under the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; putting word under cursor into variable&#xA;let current_word = expand('&amp;lt;cword&amp;gt;')&#xA;&quot; regex matching all words like one under cursor&#xA;'\k*\&amp;lt;\V'.current_word.'\m\&amp;gt;\k*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I can not figure out how to exclude word under cursor from matches.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this special character &lt;code&gt;\%#&lt;/code&gt; which according to VIM help &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Matches with the cursor position. (...)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yet I couldn't figure out how to use it in my case. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="11307" LastActivityDate="2017-04-17T15:19:31.747" Title="VIM regex - match all words equal to one under cursor, except one currently under the cursor" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12110" PostTypeId="1" AcceptedAnswerId="12115" CreationDate="2017-04-17T14:46:57.133" Score="4" ViewCount="10130" Body="&lt;p&gt;I am a new to Vim and know little about programming.&#xA;The situation is this: I have both Vim and Gvim installed. From within Vim I think I have been able to use the &lt;code&gt;:e $MYVIMRC&lt;/code&gt; command to do some edits I saw online. I was able to save it I think. I think so because the instructions I added show up when I open up Vim. &#xA;However, now I want to also change the Vimrc for things related to my GVim (in particular I want to use GVim to to take advantage of python support). Here's where the weirdness happens for me. I try and use &lt;code&gt;:e $MYVIMRC&lt;/code&gt; but when I open it up &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The vimrc file does not reflect any changes that I made from within Vim.&lt;/li&gt;&#xA;&lt;li&gt;The GVim program does not allow me to write to it.&#xA;In fact, when I search for my vimrc file in my computer, I see only one file and it looks like the one that opens  up in GVim only. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'd like to understand:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why it appears I have to vimrc files though both programs echo back the same location&lt;/li&gt;&#xA;&lt;li&gt;How I can make changes to the vimrc file from the vantage point of GVim.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have searched the site but couldn't resolve it myself. Thank you for any help/tips. &lt;/p&gt;&#xA;" OwnerUserId="12254" LastEditorUserId="12254" LastEditDate="2017-04-17T19:41:51.237" LastActivityDate="2017-07-15T18:54:35.883" Title="How can I find my true vimrc file?" Tags="|vimrc|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12111" PostTypeId="2" ParentId="12109" CreationDate="2017-04-17T15:19:31.747" Score="2" Body="&lt;p&gt;&lt;code&gt;\%#&lt;/code&gt; will always track the cursor's position, but it will only work when matching text &lt;strong&gt;in the window&lt;/strong&gt;.  If that's what you want, this is the pattern to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(\k*\%#\k*\)\@!\&amp;lt;bar\&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It matches any &lt;code&gt;bar&lt;/code&gt;, but excludes &lt;em&gt;any&lt;/em&gt; word that's under the cursor.  Using this in a &lt;code&gt;/&lt;/code&gt; search will jump to the first match, which will seem strange if the cursor is currently over &lt;code&gt;bar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use this pattern in &lt;code&gt;:match&lt;/code&gt; if you just want to highlight all occurrences of &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; that aren't under the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorMoved * execute 'match Error /\%(\k*\%#\k*\)\@!\&amp;lt;' . expand('&amp;lt;cword&amp;gt;') . '\&amp;gt;/' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to match &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; &lt;em&gt;at the time&lt;/em&gt; of the search, you will need to create a more complicated pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:search_allbut_cword() abort&#xA;  let p1 = searchpos('\&amp;lt;.', 'nbcW')&#xA;  let p2 = searchpos('.\&amp;gt;', 'ncW')&#xA;  return '/\%(\%' . p1[0] . 'l'&#xA;        \. '\%&amp;gt;' . (p1[1] - 1) . 'c'&#xA;        \. '\%&amp;lt;' . (p2[1] + 1) . 'c\)'&#xA;        \. '\@!\&amp;lt;' . expand('&amp;lt;cword&amp;gt;') . '\&amp;gt;' . &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;* &amp;lt;sid&amp;gt;search_allbut_cword()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;p1&lt;/code&gt; is the position at the beginning of &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; and &lt;code&gt;p2&lt;/code&gt; is the end.  With those, it creates a pattern that matches &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; &lt;em&gt;except&lt;/em&gt; on the current line between two columns.  This slightly flawed since it doesn't accurately account for changes made in the excluded region.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2017-04-17T15:19:31.747" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12112" PostTypeId="2" ParentId="12096" CreationDate="2017-04-17T16:03:08.050" Score="1" Body="&lt;p&gt;It should be very similar to the linked question:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-^&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;C-^&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This just makes it so that if you type &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; in insert mode it goes to normal mode and does the command there instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#map-overview&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help map-overview&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-04-17T16:03:08.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12113" PostTypeId="1" CreationDate="2017-04-17T16:10:19.047" Score="1" ViewCount="31" Body="&lt;p&gt;I've noticed a strange inconsistency in vim. I have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set confirm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;.vimrc&lt;/code&gt;, but I've noticed that the confirmation varies depending on whether I call &lt;code&gt;:qa&lt;/code&gt; or hit the &lt;em&gt;close window&lt;/em&gt; button on gvim. If I call &lt;code&gt;:qa&lt;/code&gt;, I'm faced with these choices:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Y]es, (N)o, (C)ancel:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I hit the close window button, I get more options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is this inconsistency there? Can I configure vim so that &lt;code&gt;:qa&lt;/code&gt; will show me more options?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(For completeness sake, I'm using gvim 8 on windows)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the purpose of an MVCE, I can recreate this problem with the following &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set confirm&#xA;set guioptions+=c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2017-04-17T16:29:59.790" LastActivityDate="2017-04-17T16:29:59.790" Title="Inconsistency with the &quot;Discard All&quot; command" Tags="|gvim|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12114" PostTypeId="2" ParentId="12101" CreationDate="2017-04-17T16:45:29.060" Score="1" Body="&lt;p&gt;You can define the autocommands using the file extension instead of the filetype as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.c,*.cpp,*.h,*.hpp call C_syntax()&#xA;autocmd BufNewFile,BufRead *.c,*.cpp setlocal foldmethod=syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="599" LastActivityDate="2017-04-17T16:45:29.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12115" PostTypeId="2" ParentId="12110" CreationDate="2017-04-17T18:02:22.170" Score="3" Body="&lt;p&gt;The &lt;code&gt;.vimrc&lt;/code&gt; is sourced from both Vim &amp;amp; Gvim. This file will allow you to set up a common set of CLI &amp;amp; GUI plugins in a single location (shared by both the CLI Vim &amp;amp; Gvim)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;.gvimrc&lt;/code&gt; is used by Gvim only and will be sourced by Gvim only &lt;em&gt;after&lt;/em&gt; the &lt;code&gt;.vimrc&lt;/code&gt;. Regular command line Vim won't read from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Within Gvim, you can edit the &lt;code&gt;.vimrc&lt;/code&gt; file if you want changes to appear to all instances of Vim, or if it's Gvim specific you should be able to edit the &lt;code&gt;.gvimrc&lt;/code&gt; file separately (to change menus or whatever else the GUI allows you to change)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help gvimrc&lt;/code&gt; should provide some more insight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related: &lt;a href=&quot;https://stackoverflow.com/a/38353317/2892779&quot;&gt;https://stackoverflow.com/a/38353317/2892779&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12256" LastEditorUserId="12256" LastEditDate="2017-07-15T18:54:35.883" LastActivityDate="2017-07-15T18:54:35.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12117" PostTypeId="1" CreationDate="2017-04-17T21:21:35.407" Score="7" ViewCount="496" Body="&lt;h2&gt;Context&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Currently, when I &lt;code&gt;set ft=tex&lt;/code&gt;, my &lt;code&gt;set isk?&lt;/code&gt; reads&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iskeyword=@,48-57,_,192-255&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that is, the default for vim.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;My &quot;issue&quot;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Currently, in a LaTeX string such as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$\abcde_\fgh$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;w&lt;/code&gt; jump would take me from the start to  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thus, the above setting does not feel very natural, nor optimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, it would probably be more reasonable to jump to &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;\&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;_&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;My attempt&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I'm thinking of something more like &lt;code&gt;set iskeyword=\,192-255&lt;/code&gt;&#xA;so as to have words consist of characters that would fit in &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;natural language words &lt;/li&gt;&#xA;&lt;li&gt;or LaTeX commands.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Questions&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is it supposed to be so ? &lt;em&gt;yes, since it is the default&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;What are better settings ?&lt;/li&gt;&#xA;&lt;li&gt;How to properly set this variable for this filetype ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Cheers,&lt;/p&gt;&#xA;" OwnerUserId="8748" LastEditorUserId="8748" LastEditDate="2017-04-17T22:25:50.727" LastActivityDate="2018-08-11T18:01:09.963" Title="iskeyword for latex" Tags="|filetype-tex|variables|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12118" PostTypeId="2" ParentId="12117" CreationDate="2017-04-18T01:37:21.573" Score="1" Body="&lt;p&gt;You can't get &lt;strong&gt;all&lt;/strong&gt; LaTeX strings right using &lt;code&gt;iskeyword&lt;/code&gt;, that is because the &lt;code&gt;iskeyword&lt;/code&gt; works on characters and some characters may have different meanings in different contexts.  A better way than &lt;kbd&gt;b&lt;/kbd&gt; and &lt;kbd&gt;w&lt;/kbd&gt; to test &lt;code&gt;iskeyword&lt;/code&gt; is &lt;kbd&gt;viw&lt;/kbd&gt; which should visually select all characters from the cursors in both directions until it hits a character that is not in &lt;code&gt;iskeyword&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On example of where this is useful are quoted strings, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;abc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;kbd&gt;viw&lt;/kbd&gt; will select &lt;code&gt;abc&lt;/code&gt; and not the double quotes.  But LaTeX can be ambiguous, how about this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Bj\{&quot;o}rn&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Therefore a way to finding all possible LaTeX commands that can be inside a natural language word would require you to set &lt;code&gt;iskeyword&lt;/code&gt; to everything but non-printables (space, tab, and special characters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;But Vim already does that for you!&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If instead of using &lt;kbd&gt;viw&lt;/kbd&gt;, &lt;kbd&gt;b&lt;/kbd&gt; and &lt;kbd&gt;w&lt;/kbd&gt;, you use &lt;kbd&gt;viW&lt;/kbd&gt;, &lt;kbd&gt;B&lt;/kbd&gt; and &lt;kbd&gt;W&lt;/kbd&gt; you are selecting Vim WORDs (not words).  Vim makes a distinction between WORDs and words.  See &lt;code&gt;:h WORD&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A WORD consists of a sequence of non-blank characters, separated with white&#xA;  space.  An empty line is also considered to be a WORD.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;(...)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Therefore:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Is it supposed to be so? &lt;em&gt;yes, since it is the default&lt;/em&gt;&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And moreover since the &lt;code&gt;tex.vim&lt;/code&gt; ftplugin did not overwrite it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;2&quot;&gt;&#xA;  &lt;li&gt;What are better settings?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You probably should not play with &lt;code&gt;iskeyword&lt;/code&gt;, different file types will have different ones but most use the defaults.  Messing with &lt;code&gt;iskeyword&lt;/code&gt; in vimrc may become a burden when you overwrite it for a filetype that needs it (you could write your own ftplugin for TeX but there is no real need here).  Instead use WORDs where you need them.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;3&quot;&gt;&#xA;  &lt;li&gt;How to properly set this variable for this filetype?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See above.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;P.S. I wrote my entire dissertation in LaTeX, and all in Vim.  I have been before where you are now :).&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="7700" LastActivityDate="2017-04-18T01:37:21.573" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12119" PostTypeId="1" CreationDate="2017-04-18T02:13:35.957" Score="5" ViewCount="353" Body="&lt;p&gt;I'd like to highlight sections of a document which are too long (measured in lines) so they will all print on a physical page. Sections are separated with &lt;code&gt;===&lt;/code&gt;. I tried to do it with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matchadd('ErrorMsg', '\%(^\|===\n\)\%(.*\n\)\{5}\zs\%(.*\n\)\+\ze', -1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything works hunky-dory. But when I increase the size:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matchadd('ErrorMsg', '\%(^\|===\n\)\%(.*\n\)\{80}\zs\%(.*\n\)\+\ze', -1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;matches don't highlight. From the documentation &lt;code&gt;:matchadd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Defines a pattern to be highlighted in the current window (a&#xA;    &quot;match&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Based on figuring out where exactly the problem happens, I think it's not using text outside the current window. What should I be doing instead? Sections are already associated with folds if that helps.&lt;/p&gt;&#xA;" OwnerUserId="12258" LastActivityDate="2021-08-26T21:07:55.673" Title="Highlighting after a line limit" Tags="|folding|delimiter-matching|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12120" PostTypeId="1" AcceptedAnswerId="12124" CreationDate="2017-04-18T03:55:17.910" Score="0" ViewCount="101" Body="&lt;p&gt;When I use the normal mode and output the search result using the following input,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/LOAD \d\{-}\_p\+\d\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it includes the first line,&#xA;&lt;a href=&quot;https://i.stack.imgur.com/r2Xjv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/r2Xjv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when I use the ex-command,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/LOAD \d\{-}\_p\+\d\n/z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output does not show the first line (line #504 is missing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9PCfb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9PCfb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My intention is to redirect the output of the ex-command to another file, using the :redir command. How to include the first line to the search output using the ex-command?&lt;/p&gt;&#xA;" OwnerUserId="12103" LastEditorUserId="12103" LastEditDate="2017-04-18T04:27:35.127" LastActivityDate="2017-04-18T18:35:06.263" Title="How to get command line :g to output pattern search result including the first line?" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12122" PostTypeId="1" AcceptedAnswerId="12123" CreationDate="2017-04-18T05:37:32.807" Score="1" ViewCount="1011" Body="&lt;p&gt;Both &lt;code&gt;:file&lt;/code&gt; and &lt;code&gt;:saveas&lt;/code&gt; seem to change the name of the buffer without writing.  What's the difference between them?  Also, in scratch buffers, &lt;code&gt;:saveas&lt;/code&gt; seems to cause an error while &lt;code&gt;:file&lt;/code&gt; does not.  I included the relevant help sections below, but need some help making sense of them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-G    or        *CTRL-G* *:f* *:fi* *:file*    &#xA;              *:file_f*&#xA;:f[ile][!] {name} Sets the current file name to {name}.  The optional !&#xA;      avoids truncating the message, as with |:file|.&#xA;      If the buffer did have a name, that name becomes the&#xA;      |alternate-file| name.  An unlisted buffer is created&#xA;      to hold the old name.&#xA;&#xA;:sav[eas][!] [++opt] {file}&#xA;      Save the current buffer under the name {file} and set&#xA;      the filename of the current buffer to {file}.  The&#xA;      previous name is used for the alternate file name.&#xA;      The [!] is needed to overwrite an existing file.&#xA;      When 'filetype' is empty filetype detection is done&#xA;      with the new name, before the file is written.&#xA;      When the write was successful 'readonly' is reset.&#xA;      {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10490" LastActivityDate="2017-04-18T20:47:18.020" Title="What is the difference between :file and :saveas" Tags="|save|scratch-buffer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12123" PostTypeId="2" ParentId="12122" CreationDate="2017-04-18T06:11:19.213" Score="6" Body="&lt;p&gt;&lt;code&gt;:saveas&lt;/code&gt; does write to files, after all the help says: &quot;&lt;em&gt;Save&lt;/em&gt; the current buffer under the name {file}&quot;. Note also how it says that &lt;code&gt;!&lt;/code&gt; is needed to overwrite an existing file. You wouldn't need to talk about overwriting if writing wasn't involved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, note the message from a successful &lt;code&gt;saveas&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;bar&quot; [New] 364L, 1060C written&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-04-18T06:11:19.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12124" PostTypeId="2" ParentId="12120" CreationDate="2017-04-18T06:15:21.343" Score="1" Body="&lt;p&gt;I think this is not caused by the &lt;code&gt;:g&lt;/code&gt; command or the matching, but by the &lt;code&gt;:z&lt;/code&gt; command. If you go to the &lt;code&gt;LOAD&lt;/code&gt; line and do &lt;code&gt;:z&lt;/code&gt;, the same thing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strange workaround: Do &lt;code&gt;:g/pattern/-0z&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11771" LastActivityDate="2017-04-18T06:15:21.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12125" PostTypeId="2" ParentId="12117" CreationDate="2017-04-18T09:46:13.267" Score="1" Body="&lt;p&gt;I think what I want is too complicated for &lt;code&gt;iskeyword&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is because &lt;code&gt;iskeyword&lt;/code&gt; does not use regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, in what I want, a backslash could only appear as the start of a word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now, I think the following lines in my &lt;code&gt;~/.vim/after/ftplugin/tex.vim&lt;/code&gt; may improve my quality of life when editing &lt;code&gt;tex&lt;/code&gt; files : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set isk-=_&#xA;nmap w /\\\\|\\\@&amp;lt;!\&amp;lt;\k\\|\(\&amp;gt;\\|\s\)\@&amp;lt;=\S&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;&#xA;nmap b ?\\\\|\\\@&amp;lt;!\&amp;lt;\k\\|\(\&amp;gt;\\|\s\)\@&amp;lt;=\S&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It enables to jump to next / previous&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;backslash&lt;/li&gt;&#xA;&lt;li&gt;or word not starting with a backslash&lt;/li&gt;&#xA;&lt;li&gt;or non-blank character preceded by the end of a word or some whitespace&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Basically, I use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\&amp;lt;\k&amp;lt;CR&amp;gt;:noh&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as an approximation for &lt;code&gt;w&lt;/code&gt; and patch from there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The obvious drawback is that it fills the search history with junk !&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers, &lt;/p&gt;&#xA;" OwnerUserId="8748" LastEditorUserId="8748" LastEditDate="2017-04-18T10:01:47.483" LastActivityDate="2017-04-18T10:01:47.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12126" PostTypeId="2" ParentId="376" CreationDate="2017-04-18T10:04:14.653" Score="5" Body="&lt;p&gt;In addition to Avian Y answer, actually there is an autocommand that activates leaving insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au InsertLeave * call TurnOffCaps()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That was also exactly what I was looking for...&lt;/p&gt;&#xA;" OwnerUserId="3308" LastEditorUserId="51" LastEditDate="2017-04-18T12:00:27.513" LastActivityDate="2017-04-18T12:00:27.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12127" PostTypeId="2" ParentId="376" CreationDate="2017-04-18T12:04:45.410" Score="1" Body="&lt;p&gt;On my Apple machine, I actually implemented this feature using &lt;a href=&quot;https://www.google.de/search?q=karabiner&amp;amp;oq=karabiner&amp;amp;aqs=chrome..69i57j0l5.1489j0j7&amp;amp;sourceid=chrome&amp;amp;ie=UTF-8#q=karabiner+mac&quot; rel=&quot;nofollow noreferrer&quot;&gt;Karabiner&lt;/a&gt;, which worked reasonably well. Unfortunately 10.12 broke Karabiner, and I haven't tried implementing it since.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had it so using the escape key or the enter key disabled caps lock, if it was enabled before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when you're using macOS on 10.11 or below, you can certainly do this (though don't ask me for the settings, I don't have them anymore).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise I would go with the suggested &lt;code&gt;gU&lt;/code&gt;. (Even though I can understand you grievances, about not being able to use the same method you would use in any other text editor)&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2017-04-18T12:04:45.410" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12128" PostTypeId="1" CreationDate="2017-04-18T12:16:05.293" Score="1" ViewCount="58" Body="&lt;p&gt;So I have quite some plug-ins installed and have set a lot of key combinations, and it seems like one of these key combinations makes me revert to insert mode, when I quickly press &lt;kbd&gt;d&lt;/kbd&gt; or &lt;kbd&gt;b&lt;/kbd&gt; after pressing &lt;kbd&gt;Esc&lt;/kbd&gt;. It will still execute the command (&lt;kbd&gt;b&lt;/kbd&gt; will take me back one word, &lt;kbd&gt;d&lt;/kbd&gt; is the equivalent to &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; curiously enough).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I stop this behavior. I can't even imagine what Vim feature causes this behavior. After a second or so leaving insert mode, none of this applies any more. It is only possible in the short time span after leaving insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can somebody tell what vim feature can cause this behavior and how to check for it?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="5395" LastEditDate="2017-04-18T12:51:28.500" LastActivityDate="2017-04-18T12:51:28.500" Title="Escaping and quickly pressing certain keys brings me back to insert mode" Tags="|key-bindings|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12129" PostTypeId="1" AcceptedAnswerId="12132" CreationDate="2017-04-18T13:21:35.467" Score="3" ViewCount="4229" Body="&lt;p&gt;I am working on a VIM plugin that will require a certain level of complexity for handling arguments passed to a command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:MyCommand -item=banana -command=ls\-ltra -pattern=./*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I am not sure how to handle this situation. I am aware of how arguments work in vimL, with the &lt;code&gt;a:0&lt;/code&gt; and &lt;code&gt;a:000&lt;/code&gt; and the &lt;code&gt;&amp;lt;f-args&amp;gt;&lt;/code&gt; bits. But not sure how to do the splitting and filtering of the strings etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I will be constructing a dictionary out of my arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    'item':'banana',&#xA;    'command':'ls -ltra',&#xA;    'pattern':'./*',&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, there are other plugins out there that I can peak into and see how they have solved this issue to certain extend, yet still, any suggestions would be at a great help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--- EDIT(1) ---&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a prototype:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyCommand(...) abort&#xA;    &quot; Total argument count.&#xA;    echo 'a:0 -&amp;gt; ' . a:0&#xA;&#xA;    &quot; Iterative lookup.&#xA;    &quot; echo 'a:1   -&amp;gt; ' . a:1&#xA;    &quot; echo 'a:2   -&amp;gt; ' . a:2&#xA;    &quot; ... etc.&#xA;    let l:limit = a:0&#xA;    let l:counter = 1&#xA;    while l:limit &amp;gt;= l:counter&#xA;        exec 'echo ' . '&quot;a:' . l:counter . '&quot;' . '&quot;-&amp;gt;&quot;' . 'a:' . l:counter&#xA;        let l:counter += 1&#xA;    endwhile&#xA;&#xA;    &quot; All arguments as a list.&#xA;    echo 'a:000:' &#xA;    echo a:000&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this when run as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:MyCommand -stage=build -task=do -command=ls\-ltr -pattern=./* -working-directory=/path/to/my/project&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Produces the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a:0 -&amp;gt; 5&#xA;a:1 -&amp;gt; -stage=build&#xA;a:2 -&amp;gt; -task=do&#xA;a:3 -&amp;gt; -command=ls\-ltr&#xA;a:4 -&amp;gt; -pattern=./*&#xA;a:5 -&amp;gt; -working-directory=/path/to/my/project&#xA;a:000:&#xA;['-stage=build', '-task=do', '-command=ls\-ltr', '-pattern=./*', 'working-directory=/path/to/my/project']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, I guess, the rest would be regex based checks and string processing to  extract the right bits of information. Anything more efficient that should be done on the function and arguments handling side?&lt;/p&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="5328" LastEditDate="2017-04-18T15:21:05.297" LastActivityDate="2017-04-18T17:47:40.987" Title="Handling Complex Arguments in a Vim Command" Tags="|vimscript|argument-list|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12130" PostTypeId="1" AcceptedAnswerId="12131" CreationDate="2017-04-18T14:33:43.860" Score="2" ViewCount="555" Body="&lt;p&gt;Given the string &lt;code&gt;&quot;hello.h&quot;&lt;/code&gt;, I want to obtain &lt;code&gt;&amp;lt;hello.h&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried vim-surround, but while it seems to be able to surround with matching&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;{ }&lt;/code&gt;: &lt;code&gt;cs&quot;{&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;( )&lt;/code&gt;: &lt;code&gt;cs&quot;(&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[ ]&lt;/code&gt;: &lt;code&gt;cs&quot;{&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;XML tags: &lt;code&gt;cs&quot;&amp;lt;mytag&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;cs&quot;&amp;lt;&lt;/code&gt; does not seem to work (presumably because it would clash with the XML tags).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I do this easily?&lt;/p&gt;&#xA;" OwnerUserId="12266" LastActivityDate="2017-04-18T14:37:14.940" Title="Replace surrounding quotes for &lt; &gt;" Tags="|replace|plugin-vim-surround|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12131" PostTypeId="2" ParentId="12130" CreationDate="2017-04-18T14:37:14.940" Score="4" Body="&lt;p&gt;The closing angle bracket works. Do &lt;code&gt;cs&quot;&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-04-18T14:37:14.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12132" PostTypeId="2" ParentId="12129" CreationDate="2017-04-18T15:24:04.663" Score="7" Body="&lt;p&gt;You should be able to do this simply by splitting the arg on an &lt;code&gt;=&lt;/code&gt; and going through a for loop. Something like the following should work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ MyCommand :call MyFunction(&amp;lt;f-args&amp;gt;)&#xA;let s:dictionary = {}&#xA;&#xA;function! MyFunction(...)&#xA;   for arg in a:000&#xA;      let myList = split(arg, '=')&#xA;      let s:dictionary[myList[0]] = myList[1]&#xA;   endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;-nargs=+&lt;/code&gt;: Function must have at least one argument&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;f-args&amp;gt;&lt;/code&gt;: Will pass white-space split arguments to  &lt;code&gt;MyFunction()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;split(arg, '=')&lt;/code&gt;: Splits each argument up on an = sign.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You also have some interesting substitution going on but I'll leave that as an exercise to the reader as I'm not sure exactly how you want it done. Suffice it to say you should be able to do these with the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#substitute%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;substitute()&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Acommand-nargs&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :command-nargs&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Cf-args%3E&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help &amp;lt;f-args&amp;gt;&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#split%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help split()&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#substitute%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help substitute()&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="5328" LastEditDate="2017-04-18T15:46:38.280" LastActivityDate="2017-04-18T15:46:38.280" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12133" PostTypeId="2" ParentId="4835" CreationDate="2017-04-18T16:19:35.587" Score="2" Body="&lt;p&gt;GNU Global's distribution already has a couple of vim scripts that are pretty handy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look for 'gtags.vim' and 'gtags-cscope.vim' (the most adequate probably for what you want) in Global's installation directory, and just copy the one you prefer to your 'plugins' dir inside vim's config. The second script will do a&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    set csprg=gtags-cscope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for you, which will route all normal cscope commands through the gtags provider and so will use GNU Global's DB when searching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer to simply use the :Gtags command directly though, which I find easier to use, but to each his/her own..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin &lt;a href=&quot;https://github.com/jsfaint/gen_tags.vim&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;gen_tags&quot;&gt;gen_tags&lt;/a&gt; can also help for easily rebuilding your source code DB directly from vim.&lt;/p&gt;&#xA;" OwnerUserId="12272" LastEditorUserId="12272" LastEditDate="2017-04-19T07:33:55.537" LastActivityDate="2017-04-19T07:33:55.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12134" PostTypeId="2" ParentId="12129" CreationDate="2017-04-18T17:47:40.987" Score="1" Body="&lt;p&gt;Merging back parameters like &lt;code&gt;--foo=&quot;foo bar&quot;&lt;/code&gt; requires manual work. Vim doesn't provide us anything to solve this issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I remember having started an experiment on the subject. Unfortunately, this is nothing more than that: an incomplete experiment: &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/command.vim#L64&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;lh#command#Fargs2String()&lt;/code&gt;&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-04-18T17:47:40.987" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12135" PostTypeId="2" ParentId="12120" CreationDate="2017-04-18T18:35:06.263" Score="1" Body="&lt;p&gt;What about &lt;code&gt;:% g/\vLOAD\_p+/&lt;/code&gt;, this uses &quot;magic&quot; and makes the regex more readable. You can read about it in more detail in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;magic&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /magic&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also solves the disappearing first line.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-18T18:35:06.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12136" PostTypeId="2" ParentId="12000" CreationDate="2017-04-18T18:39:10.513" Score="4" Body="&lt;p&gt;By default, the asterisk is one of the comment leaders, and the &lt;code&gt;formatoptions&lt;/code&gt; setting defaults to having &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;q&lt;/code&gt; in it. The &lt;code&gt;q&lt;/code&gt; and comments is what you are running into. You can remove &lt;code&gt;q&lt;/code&gt; from formatoptions like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fo-=q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or unset the comment leaders:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set comments=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(note: no space or anything after the equals)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can set up your vimrc (or equivalent in neovim) to apply one of those automatically when opening markdown. For example, if your markdown files end in '.md':&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.md set comments=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my Vim setup, opening '.md' files loads a filetype handler for markdown (written by Tim Pope) that sets some better options, which indents your example line like you'd expect for a list. These settings are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;formatoptions=tcqln&#xA;comments=fb:*,fb:-,fb:+,n:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which you can likewise load in your vimrc (if you don't want to get the markdown type stuff) like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.md set comments=fb:*,fb:-,fb:+,n:&amp;gt; formatoptions=tcqln&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The ftplugin does even more, and includes syntax highlighting. It can be had at &lt;a href=&quot;https://github.com/tpope/vim-markdown&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/tpope/vim-markdown&lt;/a&gt;. I have not tried to see if it works with neovim.&lt;/p&gt;&#xA;" OwnerUserId="227" LastEditorUserId="227" LastEditDate="2017-04-18T18:46:33.297" LastActivityDate="2017-04-18T18:46:33.297" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12137" PostTypeId="2" ParentId="12119" CreationDate="2017-04-18T19:28:11.277" Score="0" Body="&lt;p&gt;How about &lt;code&gt;:au BufWinEnter * let w:m1=matchadd('ErrorMsg', '\(^===\)\_p\{20,}\1', -1)&lt;/code&gt; ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works with my little lorem ipsum test case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution here is &lt;code&gt;\_p\{20,}&lt;/code&gt;, which matches at least 20 printable characters including newline (that is the _).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this with a little &quot;lorem ipsum&quot;, consecutive blocks are also highlighted, which makes the whole affair quite colorful...&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-18T19:28:11.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12138" PostTypeId="2" ParentId="12084" CreationDate="2017-04-18T19:48:40.173" Score="2" Body="&lt;p&gt;the vim range command supports relative ranges.&#xA;So if you are anywhere in your paragraph and you do not want to use visual mode, you can type i.e.:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:-1,+2!&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which would use the line above the current line and the following two lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like to know more about ranges &lt;code&gt;:h range&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-18T19:48:40.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12139" PostTypeId="2" ParentId="11972" CreationDate="2017-04-18T20:02:40.780" Score="1" Body="&lt;p&gt;You may want to read &lt;a href=&quot;http://joshldavis.com/2014/04/05/vim-tab-madness-buffers-vs-tabs/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim tab madness&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to use tabs too, but now I only use buffers, for me this is easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the screen above, you can directly enter commands.&#xA;If you use for example: &lt;code&gt;:tabfind&lt;/code&gt; followed by the filename, it will be opened in a new ... ah ... erm ... tab!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH!&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-18T20:02:40.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12140" PostTypeId="1" AcceptedAnswerId="12143" CreationDate="2017-04-18T20:43:33.110" Score="8" ViewCount="3948" Body="&lt;p&gt;I've been using Vim for decades (and Vi before it since around 1984.)  I use it now on Linux.  Somewhere along the line one behavior crept in that I'd like to disable: when I click in a window to move the focus, and the click happens to be in the body of the window, Vim moves the cursor to wherever the click landed.  If the window is large, it's sometimes not obvious where the cursor was, and that can be important for what I'm trying to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I could try to click on the window border somewhere, and this wouldn't happen.  But I'd rather not have to be that meticulous, especially when there are a lot of windows around.  I also know there are other ways to change focus, but I don't want to cycle through every window on my 3-monitor workspace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running Ubuntu and Xubuntu, and have loaded Vim-gtk because I sometimes want to run full graphical, where I could live with this behavior.  But I'm usually not in graphical mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see there's a Vim-tiny that probably does not have this behavior, but I don't know what else I would lose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked through the setup stuff for the window manager and don't see anything relevant.  The Vim man page doesn't have anything that jumped out at me either.  My &lt;code&gt;.vimrc&lt;/code&gt; doesn't seem to address the issue (but it's long and I may have forgotten/missed something.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="12277" LastEditorUserId="5395" LastEditDate="2017-04-19T08:17:59.277" LastActivityDate="2019-09-02T03:51:22.143" Title="How to disable moving the cursor with the mouse" Tags="|vim-windows|cursor|mouse|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12141" PostTypeId="2" ParentId="12122" CreationDate="2017-04-18T20:47:18.020" Score="1" Body="&lt;p&gt;&lt;code&gt;:saveas&lt;/code&gt; is not going to work in a scratch buffer. A scratch buffer is a temporary buffer, that is not associated with a file and therefore cannot be saved. Instead they are discarded without warning, when vim is exited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like to know more:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h special-buffers&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h buftype&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-18T20:47:18.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12143" PostTypeId="2" ParentId="12140" CreationDate="2017-04-18T21:08:33.860" Score="3" Body="&lt;p&gt;Here's a heavy solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;LeftMouse&amp;gt; ma&amp;lt;LeftMouse&amp;gt;`a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will let the click go through (thus changing the focus), but make sure the cursor always goes back to where it was before the click was initiated.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-04-18T21:08:33.860" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12144" PostTypeId="1" AcceptedAnswerId="12177" CreationDate="2017-04-19T07:49:28.287" Score="3" ViewCount="316" Body="&lt;p&gt;I use &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; to open &quot;filename.h&quot; from line like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;filename.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in some C\C++ file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes there is more than one &quot;filename.h&quot; that &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; command can find in &lt;em&gt;path&lt;/em&gt;. But &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; gets me to the first file it finds - sometimes that's not what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to open the next file matching that name?&lt;/p&gt;&#xA;" OwnerUserId="2710" LastActivityDate="2017-04-21T02:14:16.523" Title="gf: can I get next file that matches?" Tags="|filesystem|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12145" PostTypeId="2" ParentId="12110" CreationDate="2017-04-19T08:03:04.977" Score="8" Body="&lt;p&gt;The best way to find out, which files are loaded is to use the command&#xA;&lt;code&gt;:version&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also have secondary rc files, which are being sourced. They will be displayed here. You will also see, which version of vim you have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition &lt;code&gt;:scriptnames&lt;/code&gt; will list all scripts in the order they are loaded, this is probably not what you want and will also include plugin scripts, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What strikes me as odd, is that on windows, you usually have a &lt;code&gt;_vimrc&lt;/code&gt; or &lt;code&gt;_gvimrc&lt;/code&gt; (_ instead of .) and the default directory for these is &lt;code&gt;%USERPROFILE%\vimfiles&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-19T08:03:04.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12146" PostTypeId="1" AcceptedAnswerId="12148" CreationDate="2017-04-19T08:11:31.970" Score="1" ViewCount="298" Body="&lt;p&gt;Given the following text: &lt;code&gt;Hello Part1/Part2 Bye&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the cursor on top of any character in &lt;code&gt;Part1/Part2&lt;/code&gt; I would like to be able to refer to the whole &lt;code&gt;Part1/Part2&lt;/code&gt; (for visual selection, deletion, substitution, etc.). For simplicity, let's talk about deletion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; considers &lt;code&gt;/&lt;/code&gt; a delimiting character, so it will consider &lt;code&gt;Part1/Part2&lt;/code&gt; three different words: &lt;code&gt;Part1&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;Part2&lt;/code&gt;, and will delete only one of them (depending on where the cursor is).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt; (since using &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt; will delete everything inside quotes, and &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;(&lt;/kbd&gt; will delete everything inside matching brackets, etc.), but it does not seem to work with arbitrary delimiters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So two closely-related questions, the first one being a particular case of the second one:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I quickly refer the word under the cursor (word in this context meaning &quot;text delimited exclusively by blank spaces&quot;)?&lt;/li&gt;&#xA;&lt;li&gt;How can I quickly refer to the text between two arbitrary delimiters?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am aware of the answer to a &lt;a href=&quot;https://vi.stackexchange.com/questions/6938/copy-text-based-on-delimiting-strings&quot;&gt;similar question&lt;/a&gt;, but I'd like to keep the solution in line with the &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt; style (i.e. not visually selecting the text and then performing an operation; but instead first defining the operation and then specifying the text in which it needs to be performed). If no default command will cut it, I'd be happy with something I can map to a customized key binding.&lt;/p&gt;&#xA;" OwnerUserId="12266" LastEditorUserId="12266" LastEditDate="2017-04-19T08:20:47.410" LastActivityDate="2017-04-19T09:42:14.827" Title="Refer to text between arbitrary delimiting characters" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12147" PostTypeId="2" ParentId="12146" CreationDate="2017-04-19T08:53:49.890" Score="0" Body="&lt;p&gt;The question was answered in &lt;a href=&quot;https://stackoverflow.com/questions/25856240/can-you-substitute-or-delete-between-commas-or-any-arbitrary-character-in-vi-v&quot;&gt;substitute ... between ... arbitrary characters&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution employs the &lt;code&gt;t&lt;/code&gt;/ &lt;code&gt;T&lt;/code&gt; &quot;Till&quot; commands&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to mention the excellent &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-surround plugin&lt;/a&gt; here too, it will allow you to handle the delimiting characters...&lt;/p&gt;&#xA;" OwnerUserId="7267" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-04-19T08:53:49.890" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12148" PostTypeId="2" ParentId="12146" CreationDate="2017-04-19T09:42:14.827" Score="2" Body="&lt;p&gt;Taken from @romainl answer &lt;a href=&quot;https://stackoverflow.com/a/25856426/2891462&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I've had the following snippet in my &lt;code&gt;vimrc&lt;/code&gt; for quite a while and it&#xA;  never failed me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for char in [ '_', '.', ':', ',', ';', '&amp;lt;bar&amp;gt;', '/', '&amp;lt;bslash&amp;gt;', '*', '+', '%' ]&#xA;  execute 'xnoremap i' . char . ' :&amp;lt;C-u&amp;gt;normal! T' . char . 'vt' . char . '&amp;lt;CR&amp;gt;'&#xA;  execute 'onoremap i' . char . ' :normal vi' . char . '&amp;lt;CR&amp;gt;'&#xA;  execute 'xnoremap a' . char . ' :&amp;lt;C-u&amp;gt;normal! F' . char . 'vf' . char . '&amp;lt;CR&amp;gt;'&#xA;  execute 'onoremap a' . char . ' :normal va' . char . '&amp;lt;CR&amp;gt;'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It does not work for arbitrary characters out of the box (since they need to have been defined in the snippet) but it isn't hard to customize for the most common delimiters.&lt;/p&gt;&#xA;" OwnerUserId="12266" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-04-19T09:42:14.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12149" PostTypeId="2" ParentId="11699" CreationDate="2017-04-19T09:53:43.520" Score="0" Body="&lt;p&gt;Assuming you are on the &quot;D&quot;, you may also &lt;kbd&gt;dtJA&lt;/kbd&gt;,&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;R&lt;/kbd&gt;, &lt;kbd&gt;&quot;&lt;/kbd&gt;, which will leave you with &lt;code&gt;John Doe,&lt;/code&gt; with the cursor at the end, to delete the rest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative would also be &lt;code&gt;s/\v(\w+), (\w+)/\2 \1/&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-19T09:53:43.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12150" PostTypeId="1" CreationDate="2017-04-19T10:30:58.443" Score="2" ViewCount="265" Body="&lt;p&gt;So, here's my problem.&#xA;I want to be able to run &lt;code&gt;make build&lt;/code&gt; whenever I save a source code file and see it in a split pane.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I manually run &lt;code&gt;:split | :te! make build&lt;/code&gt;, I get a split pane, my makefile runs, it's focused and by just pressing &lt;kbd&gt;Enter&lt;/kbd&gt; I can close it. All fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, if I do &lt;code&gt;:autocmd BufWritePost src/*.elm :split | :te! make build&lt;/code&gt;, the command does run whenever I &quot;write&quot; the buffer ( so that part is fine ), and I get the terminal running in a split pane.  BUT the focus remains on the source code file pane, and it somehow also turns it into INSERT mode.&#xA;I cannot understand why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;( I use neovim, with some plugins, let me know if you need info on that )&lt;/p&gt;&#xA;" OwnerUserId="12280" LastEditorUserId="4472" LastEditDate="2017-09-19T06:21:04.783" LastActivityDate="2017-11-19T00:22:23.470" Title="Running autocmd somehow turns to insert mode" Tags="|neovim|autocmd|terminal|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12151" PostTypeId="1" CreationDate="2017-04-19T13:22:34.203" Score="3" ViewCount="7750" Body="&lt;p&gt;I'm using Ubuntu 17.04. I've decided to start using Vim, so I needed a plugin manager. I found vim-plug and I really liked it. But I can't make it work. I followed the installation guide:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;curl -fLo ~/.vim/autoload/plug.vim --create-dirs \&#xA;    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Created .vimrc and pasted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin()&#xA;Plug 'tpope/vim-sensible'&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But Vim gives me Errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/keltar/.vimrc:&#xA;line    1:&#xA;E117: Unknown function: plug#begin&#xA;line    2:&#xA;E492: Not an editor command: Plug 'tpope/vim-sensible'&#xA;line    3:&#xA;E117: Unknown function: plug#end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's wrong? Vim version is 8.0.95 .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:scriptames&lt;/code&gt; output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: /usr/share/vim/vimrc&#xA;  2: /usr/share/vim/vim80/debian.vim&#xA;  3: /usr/share/vim/vim80/syntax/syntax.vim&#xA;  4: /usr/share/vim/vim80/syntax/synload.vim&#xA;  5: /usr/share/vim/vim80/syntax/syncolor.vim&#xA;  6: /usr/share/vim/vim80/filetype.vim&#xA;  7: ~/.vimrc&#xA;  8: /usr/share/vim/vim80/plugin/getscriptPlugin.vim&#xA;  9: /usr/share/vim/vim80/plugin/gzip.vim&#xA; 10: /usr/share/vim/vim80/plugin/logiPat.vim&#xA; 11: /usr/share/vim/vim80/plugin/manpager.vim&#xA; 12: /usr/share/vim/vim80/plugin/matchparen.vim&#xA; 13: /usr/share/vim/vim80/plugin/netrwPlugin.vim&#xA; 14: /usr/share/vim/vim80/plugin/rrhelper.vim&#xA; 15: /usr/share/vim/vim80/plugin/spellfile.vim&#xA; 16: /usr/share/vim/vim80/plugin/tarPlugin.vim&#xA; 17: /usr/share/vim/vim80/plugin/tohtml.vim&#xA; 18: /usr/share/vim/vim80/plugin/vimballPlugin.vim&#xA; 19: /usr/share/vim/vim80/plugin/zipPlugin.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ls -la ~/.vim/autoload&lt;/code&gt; output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;total 80&#xA;drwxr-x--- 2 root root  4096 Apr 19 22:22 .&#xA;drwxr-x--- 3 root root  4096 Apr 19 22:22 ..&#xA;-rw-r--r-- 1 root root 71885 Apr 20 09:32 plug.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12285" LastEditorUserId="12285" LastEditDate="2017-04-20T10:46:53.927" LastActivityDate="2017-04-20T10:46:53.927" Title="Can't make vim-plug work" Tags="|vimrc|plugin-vim-plug|" AnswerCount="0" CommentCount="10" ClosedDate="2017-04-21T01:24:21.770" ContentLicense="CC BY-SA 3.0" />
  <row Id="12152" PostTypeId="2" ParentId="11061" CreationDate="2017-04-19T14:46:48.237" Score="0" Body="&lt;p&gt;I think, you have to call &lt;code&gt;call plug#begin('~/.vim/plugged')&lt;/code&gt;, only then you can source the plugin file. It is good practice to have the plugins in a separate file btw!&lt;/p&gt;&#xA;" OwnerUserId="7267" LastEditorUserId="5395" LastEditDate="2017-04-19T15:55:02.103" LastActivityDate="2017-04-19T15:55:02.103" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12154" PostTypeId="2" ParentId="11964" CreationDate="2017-04-19T15:41:54.847" Score="0" Body="&lt;p&gt;You are right, no, there is no &lt;code&gt;:cleartags&lt;/code&gt;. See &lt;code&gt;:h tagstack&lt;/code&gt;, but you could disable it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The excellent plugin &lt;a href=&quot;https://github.com/ludovicchabant/vim-gutentags&quot; rel=&quot;nofollow noreferrer&quot;&gt;gutentags&lt;/a&gt; is the best way to handle &lt;em&gt;ctags&lt;/em&gt;, in my opinion. There are many other tag plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;T&lt;/kbd&gt; takes you back to the last tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hitting it twice, will get you back to the start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are jumping, &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;O&lt;/kbd&gt; will work as expected, although it is using the jumplist an not the tagstack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There also are the &lt;code&gt;ex&lt;/code&gt; commands &lt;code&gt;tjump&lt;/code&gt; and &lt;code&gt;stjump&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-19T15:41:54.847" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12157" PostTypeId="2" ParentId="12095" CreationDate="2017-04-19T17:56:44.150" Score="2" Body="&lt;p&gt;Short answer: no&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long answer:&#xA;This discussion &lt;a href=&quot;https://stackoverflow.com/questions/26958059/vim-netrw-copy-commands&quot;&gt;netrw copy commands&lt;/a&gt; clearly states, how this is accomplished with netrw (the target directory needs to be created first).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also lamented, that this is easier to achieve in NerdTree.&#xA;( &lt;kbd&gt;m&lt;/kbd&gt; + &lt;kbd&gt;c&lt;/kbd&gt; according to this answer &lt;a href=&quot;https://stackoverflow.com/questions/3115404/how-to-copy-or-duplicate-an-entire-folder-in-vim-using-nerdtree&quot;&gt;...duplicate ...entire folder...&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above mentioned &lt;code&gt;dir-diff&lt;/code&gt; allows to sync directories.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.413" LastActivityDate="2017-04-19T17:56:44.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12158" PostTypeId="1" CreationDate="2017-04-19T18:01:58.693" Score="1" ViewCount="283" Body="&lt;p&gt;With this minimal &lt;code&gt;.vimrc&lt;/code&gt; I get a highlight conflict in several situations.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set runtimepath +=~/.vim/bundle/Vundle.vim&#xA;&#xA;filetype off&#xA;call vundle#begin()&#xA;    Plugin 'itchyny/vim-cursorword'&#xA;    Plugin 'lfv89/vim-interestingwords'&#xA;    Plugin 'w0ng/vim-hybrid'&#xA;call vundle#end()&#xA;&#xA;filetype plugin on&#xA;filetype indent on&#xA;syntax on&#xA;&#xA;set cursorcolumn&#xA;set termguicolors&#xA;&#xA;set background=dark&#xA;colorscheme hybrid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the cursor is on a brace, the matching brace is improperly highlighted (&lt;code&gt;showmatch&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MGkfu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MGkfu.png&quot; alt=&quot;brace&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the cursor is on &lt;code&gt;foo&lt;/code&gt; the other corresponding functions are improperly highlighted (&lt;code&gt;itchyny/vim-cursorword&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aXx3O.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aXx3O.png&quot; alt=&quot;foo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using the plugin &lt;code&gt;lfv89/vim-interestingwords&lt;/code&gt; and the cursor is on a highlighted word:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WR9da.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WR9da.png&quot; alt=&quot;highlight word&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As this issue appears with different plugins, I would like to understand the cause and find a way to solve it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The context about this issue is: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ uname -a&#xA;Linux 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux&#xA;&#xA;$ vi --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 22:32:42)&#xA;Included patches: 1-1829&#xA;Extra patches: 8.0.0056&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;&#xA;$ mintty --version&#xA;mintty 2.7.6 (x86_64-px-cygwin)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I encounter the same issue with &lt;code&gt;xterm&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LFT2A.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LFT2A.png&quot; alt=&quot;xterm&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2548" LastEditorUserId="2548" LastEditDate="2017-04-19T20:48:20.880" LastActivityDate="2017-04-21T01:36:12.303" Title="Improperly highlighted when used with cursorcolumn" Tags="|syntax-highlighting|cursorline|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12160" PostTypeId="2" ParentId="11962" CreationDate="2017-04-19T20:32:49.647" Score="3" Body="&lt;p&gt;You could try and use &lt;a href=&quot;https://github.com/chrisbra/DynamicSigns&quot; rel=&quot;nofollow noreferrer&quot;&gt;DynamicSigns&lt;/a&gt;. The documentation includes an example to show relative line numbers every 5 lines. Maybe you can adopt the example and use this plugin combined with YCM. &lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-19T20:32:49.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12161" PostTypeId="1" CreationDate="2017-04-20T00:03:58.607" Score="3" ViewCount="117" Body="&lt;p&gt;I have to do a lot of hopping in lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often times I want to hop to a &lt;code&gt;t&lt;/code&gt; in a line, and promptly press &lt;code&gt;ft&lt;/code&gt;, only to discover that I have to do it 7 times before I can actually make it to my destination.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to think of ways to eliminate this time waster. Is there a way to find a bigram instead, so &lt;code&gt;fts&lt;/code&gt; would hop to &lt;code&gt;ts&lt;/code&gt; in a line?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2017-04-20T05:26:10.157" Title="How to &quot;find&quot; or &quot;till&quot; a bigram?" Tags="|cursor-movement|find|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12162" PostTypeId="2" ParentId="12161" CreationDate="2017-04-20T03:44:32.437" Score="5" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/justinmk/vim-sneak&quot; rel=&quot;noreferrer&quot;&gt;sneak&lt;/a&gt; plugin provides that functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, it's bound to the &lt;code&gt;s&lt;/code&gt; key, so you would need to use &lt;code&gt;sts&lt;/code&gt; for your example.  The documentation also gives &lt;a href=&quot;https://github.com/justinmk/vim-sneak#how-can-i-replace-f-with-sneak&quot; rel=&quot;noreferrer&quot;&gt;example&lt;/a&gt; mappings to put sneak's functionality on the &lt;code&gt;f&lt;/code&gt; family of keys or to enhance the standard 1-character searches with some of sneak's other improvements.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-04-20T03:44:32.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12163" PostTypeId="2" ParentId="12161" CreationDate="2017-04-20T05:15:09.323" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/easymotion/vim-easymotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;easymotion&lt;/a&gt; plugin also provides functionality like that. &#xA;Easymotion is considered to be larger with more features, both come highly recommended. Maybe someone needs to write a review of both, while checking them out...&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-20T05:15:09.323" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12164" PostTypeId="2" ParentId="12161" CreationDate="2017-04-20T05:26:10.157" Score="3" Body="&lt;p&gt;Besides the plugins mentions, there are several other plugins available, that extend the &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt; motions. Among there are &lt;a href=&quot;https://github.com/rhysd/clever-f.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;clever-f&lt;/a&gt;, &lt;a href=&quot;https://github.com/dahu/vim-fanfingtastic&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-fanfingtastic&lt;/a&gt; and my own &lt;a href=&quot;https://github.com/chrisbra/improvedft&quot; rel=&quot;nofollow noreferrer&quot;&gt;ft-improved&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At least for my plugin I can tell you, that you can configure it, to check for several following characters. You have to set &lt;code&gt;:let g:ft_improved_multichars = 1&lt;/code&gt; in your vimrc for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you might be interested in this &lt;a href=&quot;https://vi.stackexchange.com/questions/4486/expand-f-and-t-motion-to-next-lines&quot;&gt;similar question&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-04-20T05:26:10.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12165" PostTypeId="1" AcceptedAnswerId="12166" CreationDate="2017-04-20T05:36:30.757" Score="0" ViewCount="2334" Body="&lt;p&gt;Maybe it's a stupid question, but I can't figure it out. I have installed the &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips plugin&lt;/a&gt;. I followed all the instructions on setting it up. I added this into my &lt;code&gt;.vimrc&lt;/code&gt; file but it's not working:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Track the engine.&#xA;Plugin 'SirVer/ultisnips'&#xA;&#xA;&quot; Snippets are separated from the engine. Add this if you want them:&#xA;Plugin 'honza/vim-snippets'&#xA;&#xA;&quot; Trigger configuration. Do not use &amp;lt;tab&amp;gt; if you use https://github.com/Valloric/YouCompleteMe.&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;c-b&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-z&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I checked that &lt;kbd&gt;Tab&lt;/kbd&gt; is not used anywhere in the rest of my &lt;code&gt;.vimrc&lt;/code&gt; file. When I type &lt;code&gt;cl&lt;/code&gt; and press &lt;kbd&gt;Tab&lt;/kbd&gt; nothing happens. However, I am expecting it to offer me insert snippet for the python class. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the list of plugin I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctrlp&#xA;jedi-vim&#xA;SumpylFold&#xA;ultisnips&#xA;vim-airline&#xA;vim-airline-themes&#xA;vim-fugitive&#xA;Vundle&#xA;indentpython&#xA;nerdtree&#xA;vim-nerdtree-tabs&#xA;syntastic&#xA;vim-flake8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I missing here? Can anyone help me?&lt;/p&gt;&#xA;" OwnerUserId="12297" LastEditorUserId="5395" LastEditDate="2017-04-20T06:45:04.693" LastActivityDate="2017-04-20T06:50:22.177" Title="Vim UltiSnips for python not working" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12166" PostTypeId="2" ParentId="12165" CreationDate="2017-04-20T06:50:22.177" Score="4" Body="&lt;p&gt;This is because of this line in UtliSnips documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;UltiSnips comes without snippets. The default snippets can be found here: &lt;a href=&quot;https://github.com/honza/vim-snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/honza/vim-snippets&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;UltiSnips is just an engine, you need to install/create own snippets. I use those recommended &lt;code&gt;vim-snippets&lt;/code&gt; and they work like a charm.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-04-20T06:50:22.177" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12167" PostTypeId="1" CreationDate="2017-04-20T08:11:14.393" Score="0" ViewCount="50" Body="&lt;p&gt;I have remapped &lt;kbd&gt;}&lt;/kbd&gt; as follows &lt;code&gt;noremap } }jz.&lt;/code&gt; so that as I go down paragraphs the cursor stays in the middle of the screen and to the first line of the next paragraph (usually).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That works fine. But I also use &lt;kbd&gt;}&lt;/kbd&gt; after &lt;kbd&gt;y&lt;/kbd&gt; to yank say the next 3 paragraphs to paste elsewhere. For example &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;}&lt;/kbd&gt;.  In this usage, I want Vim to ignore my mapping. (The rationale is that after a &lt;kbd&gt;y&lt;/kbd&gt; there is no movement, so my modification to the movement should also be ignored after a &lt;kbd&gt;y&lt;/kbd&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to map a movement key, but have a mapping be ignored after &lt;kbd&gt;y&lt;/kbd&gt;, &lt;kbd&gt;d&lt;/kbd&gt;, and perhaps even after number prefixes such as &lt;kbd&gt;2&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12298" LastEditorUserId="5395" LastEditDate="2017-04-20T08:26:31.567" LastActivityDate="2017-04-20T08:26:31.567" Title="map } but not after y" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12168" PostTypeId="2" ParentId="12167" CreationDate="2017-04-20T08:23:58.297" Score="3" Body="&lt;p&gt;Use &lt;code&gt;nnoremap&lt;/code&gt; instead of &lt;code&gt;noremap&lt;/code&gt;. Mode after pressing &lt;kbd&gt;y&lt;/kbd&gt; is &lt;code&gt;Operator-pending&lt;/code&gt; and that could be addressed by &lt;code&gt;onoremap&lt;/code&gt;. You can read more about modes in &lt;code&gt;:h map-modes&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-04-20T08:23:58.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12169" PostTypeId="1" AcceptedAnswerId="12192" CreationDate="2017-04-20T12:02:53.903" Score="3" ViewCount="128" Body="&lt;p&gt;As the title stated, &lt;strong&gt;remap ':' to maintain last command, and erase all char if any key other than &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; was pressed.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;possible use cases:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have typed a long command, and I may or may not modified it, then re-run it.&lt;/li&gt;&#xA;&lt;li&gt;I save a lot, so I want type &lt;code&gt;:&lt;/code&gt;, then visually verify &lt;code&gt;:w&lt;/code&gt; is there, then type &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to proceed. -- I have remapped &lt;code&gt;:saveas&amp;lt;CR&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;Leader&amp;gt;s&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;things that are not what I pursue:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I know about &lt;code&gt;q:&lt;/code&gt; or &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; in cmdline mode to open the mini buffer to edit command.&lt;/li&gt;&#xA;&lt;li&gt;I know type &lt;code&gt;@:&lt;/code&gt; then &lt;code&gt;@@&lt;/code&gt; to repeat command.&lt;/li&gt;&#xA;&lt;li&gt;I know type &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt; in cmdline mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;a little more on motivation:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Repeat with &lt;code&gt;register/macro&lt;/code&gt; is great and is really handy for some task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But here I want a more consistent and safer (visually verification/feedback) way to re-run last command, with fewer key stroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is that possible? or not trivially implementable at all??&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;======== EDIT ========&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on @Karl's comment, I think the problem could be implemented via a function definition and a &lt;code&gt;nnoremap&lt;/code&gt;. The function consist three parts:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;echo last command &lt;code&gt;getreg(':')&lt;/code&gt;, then get &lt;code&gt;char&lt;/code&gt; with &lt;code&gt;getchar&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if &lt;code&gt;char == '^M'&lt;/code&gt;, re-execute last command.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;otherwise, open command line and act accordingly.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My first attempt is as below: -- (based on @grodzik's  answer and @Karl's idea in the comment)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! Show_last_command_and_exec()&#xA;    echo ':'.getreg(':')&#xA;    try&#xA;        let char = getchar()&#xA;    catch /^Vim:Interrupt$/&#xA;        let char = &quot;\&amp;lt;Esc&amp;gt;&quot;&#xA;    endtry&#xA;    if char == &quot;^M&quot;&#xA;        exec getreg(':')&#xA;        &quot; not work, don't know why, tried with previous comand be `:pwd`&#xA;    else&#xA;        &quot; not work, don't know which function or command should be used.&#xA;        &quot; below are failed attempt.&#xA;        &quot; normal! :&#xA;        &quot; call feedkeys(char)&#xA;        &quot; exec ':'.char&#xA;    endif&#xA;endfunc&#xA;&#xA;nnore : :call Show_last_command_and_exec()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But unfortunately, except the trivial first echo part, neither work yet.&#xA;I post my attempt (though failed currently) here, hope someone interested may implement a better one that work nicely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. as @grodzik said in his answer, the &quot;^M&quot; should be replaced with real &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; sign.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="10254" LastEditDate="2017-04-21T13:45:59.333" LastActivityDate="2018-05-25T14:30:38.253" Title="remap ':' to maintain last command, and erase all char if any key other than &lt;CR&gt; was pressed" Tags="|command-line|functions|repeated-commands|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12170" PostTypeId="2" ParentId="12169" CreationDate="2017-04-20T13:43:46.117" Score="1" Body="&lt;p&gt;After a bit of hacking, I actually found a way to achive that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AutoErase()&#xA;  setlocal cursorline&#xA;  normal Gk&#xA;  redraw!&#xA;  try&#xA;    let char = getchar()&#xA;  catch /^Vim:Interrupt$/&#xA;    let char = &quot;\&amp;lt;Esc&amp;gt;&quot;&#xA;  endtry&#xA;  if char == '^\d\+$' || type(char) == 0&#xA;    let char = nr2char(char)&#xA;  endif &quot; It is the ascii code.&#xA;  if char == &quot;^M&quot;&#xA;    call feedkeys('^M')&#xA;  else&#xA;    execute &quot;normal Gi&quot; . char&#xA;    startinsert!&#xA;  endif&#xA;endfunction&#xA;&#xA;autocmd CmdwinEnter * call AutoErase()&#xA;nnoremap : q:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will show Command Window though and command to be executed when pressed &lt;kbd&gt;Enter&lt;/kbd&gt; is the one highlited. Also, it may be required to change in &lt;code&gt;.vimrc&lt;/code&gt; signs with &lt;code&gt;^M&lt;/code&gt; into real &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; signs with &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-04-20T13:43:46.117" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12171" PostTypeId="1" AcceptedAnswerId="12172" CreationDate="2017-04-20T14:10:10.987" Score="9" ViewCount="555" Body="&lt;p&gt;I am new to Vim and I want to be able to edit scripts with my keyboard bindings and other Vim settings while still working in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance I would like all most of my &lt;code&gt;set xx&lt;/code&gt; commands to be in one file and have the ability to update the file and reapply its settings while still in Vim. Is it a matter of &lt;code&gt;source&lt;/code&gt;-ing the file as I am editing it?&lt;/p&gt;&#xA;" OwnerUserId="9540" LastEditorUserId="6489" LastEditDate="2017-04-20T21:25:04.007" LastActivityDate="2017-04-25T19:26:07.317" Title="How can I edit my Vim configuration whilst working in Vim?" Tags="|vimrc|set|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12172" PostTypeId="2" ParentId="12171" CreationDate="2017-04-20T14:12:52.430" Score="12" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it a matter of &lt;code&gt;source&lt;/code&gt;-ing the file as I am editing it?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes! &lt;code&gt;:so %&lt;/code&gt; should do the trick when you're editing your &lt;code&gt;vimrc&lt;/code&gt;. Or you can also use the special variable &lt;code&gt;$MYVIMRC&lt;/code&gt; to access it from anywhere. I have a mapping like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :source $MYVIMRC&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Caveats:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few things you need to do to your &lt;code&gt;vimrc&lt;/code&gt; to make sure you can re-&lt;code&gt;source&lt;/code&gt; it safely. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make sure all your functions start with &lt;code&gt;function!&lt;/code&gt;. The &lt;code&gt;!&lt;/code&gt; makes a re-declaration of the function simply overwrite the function without a warning.&lt;/li&gt;&#xA;&lt;li&gt;If you have any &lt;code&gt;autocmd&lt;/code&gt;s, make sure you include them in a group and start the group with &lt;code&gt;au!&lt;/code&gt;. This will make sure that you don't set up your &lt;code&gt;autocmd&lt;/code&gt;s more than once. And if you edit one, it will delete the old instance.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyAutocmds&#xA;   au!&#xA;   autocmd...&#xA;   autocmd...&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-04-25T19:26:07.317" LastActivityDate="2017-04-25T19:26:07.317" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12175" PostTypeId="2" ParentId="12150" CreationDate="2017-04-20T20:52:47.270" Score="0" Body="&lt;p&gt;The correct way to do this in neovim is&#xA;&lt;code&gt;autocmd! BufWritePost src/*.elm make build&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So actually much simpler...&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-20T20:52:47.270" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12176" PostTypeId="1" CreationDate="2017-04-21T01:12:35.490" Score="1" ViewCount="100" Body="&lt;p&gt;I am trying to get the  unicode character '①' inserted in vim with the insert mode command but failed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;CTRL-Q&amp;gt;u2460 --&amp;gt; result:$`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I copied the unicode to vim and checked the hex value using &lt;code&gt;ga&lt;/code&gt; to find the value as '8740'. I re-entered the unicode codepoint using the determined hex value to get the character successfully.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;CTRL-Q&amp;gt;u8740 --&amp;gt; result:①&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I don't understand why the codepoint '2460' does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using windows 7. &lt;code&gt;set encoding?&lt;/code&gt; gives me &lt;code&gt;cp932&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12103" LastEditorUserId="51" LastEditDate="2017-04-22T15:26:48.213" LastActivityDate="2017-04-22T15:26:48.213" Title="Unicode character does not show when entered using &lt;C-q&gt; with cp932" Tags="|gvim|microsoft-windows|unicode|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12177" PostTypeId="2" ParentId="12144" CreationDate="2017-04-21T01:41:34.390" Score="3" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#gf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h gf&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                       gf E446 E447&#xA;[count]gf               Edit the file whose name is under or after the cursor.&#xA; ...&#xA;                        If a [count] is given, the count'th file that is found&#xA;                        in the 'path' is edited.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can do &lt;code&gt;2gf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To browse the list of matches is trickier. The only way I found was to use use &lt;code&gt;:find&lt;/code&gt; and Vim's command-line tab completion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;:find &amp;lt;cfile&amp;gt;&lt;kbd&gt;Tab&lt;/kbd&gt;&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will cycle through matches and &lt;code&gt;&amp;lt;cfile&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vpU2w.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vpU2w.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2017-04-21T02:14:16.523" LastActivityDate="2017-04-21T02:14:16.523" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12178" PostTypeId="1" CreationDate="2017-04-21T08:13:42.440" Score="1" ViewCount="1340" Body="&lt;p&gt;I have this issue where &lt;code&gt;noexpandtab&lt;/code&gt; turns itself on after a while. Tried to describe it here and in the &lt;a href=&quot;https://github.com/neovim/neovim/issues/6561&quot; rel=&quot;nofollow noreferrer&quot;&gt;Github Issue&lt;/a&gt; because I am not 100% sure this is a legit bug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a long time, I have disregarded this thinking it is some plugin acting up. But then a friend who uses fairly minimalistic Neovim setup shared his frustration for the same behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It goes like this — you go about your work day and at some point in time it starts using tabs instead of spaces in all files. So I have to issue&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set et&#xA;:retab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get the current file back on track, but the problem is the new &lt;code&gt;noexpandtab&lt;/code&gt; setting becomes  &quot;global&quot; after that, so in the end I just restart Neovim. It might, of course, be a faulty plugin, but if this is actually a bug then more people should have been experiencing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The list of plugins that are common between our configurations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AndrewRadev/splitjoin.vim&#xA;AndrewRadev/vim-eco&#xA;Shougo/deoplete.nvim&#xA;Xuyuanp/nerdtree-git-plugin&#xA;airblade/vim-gitgutter&#xA;junegunn/fzf&#xA;kana/vim-textobj-user&#xA;kchmck/vim-coffee-script&#xA;mtscout6/vim-cjsx&#xA;mxw/vim-jsx&#xA;scrooloose/nerdtree&#xA;tpope/vim-abolish&#xA;tpope/vim-dispatch&#xA;tpope/vim-fugitive&#xA;tpope/vim-repeat&#xA;tpope/vim-surround&#xA;vim-airline/vim-airline&#xA;vim-airline/vim-airline-themes&#xA;vim-ruby/vim-ruby&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="237" LastEditorUserId="237" LastEditDate="2017-04-21T10:20:13.350" LastActivityDate="2017-04-21T10:20:13.350" Title="expandtab / noexpandtab toggles by itself in Neovim" Tags="|neovim|tab-characters|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12179" PostTypeId="1" AcceptedAnswerId="12181" CreationDate="2017-04-21T09:17:33.117" Score="1" ViewCount="1336" Body="&lt;p&gt;Which commands can you use to take a paragraph from one file and insert it in a second file?&lt;/p&gt;&#xA;" OwnerUserId="12317" LastActivityDate="2017-04-21T09:32:27.850" Title="Paragraph transfer from one file to another" Tags="|cut-copy-paste|gvim|" AnswerCount="2" CommentCount="0" ClosedDate="2017-04-21T09:39:44.893" ContentLicense="CC BY-SA 3.0" />
  <row Id="12180" PostTypeId="2" ParentId="12179" CreationDate="2017-04-21T09:28:45.517" Score="2" Body="&lt;p&gt;You could get a better answer if you'd provided more information. Nonetheless:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;dap&lt;/code&gt; will delete (&lt;code&gt;d&lt;/code&gt;) around (&lt;code&gt;a&lt;/code&gt;) the current paragraph (&lt;code&gt;p&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;move to the next buffer (file). E.g. with &lt;code&gt;:bNext&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;go to where you wanna paste the paragraph. E.g. &lt;code&gt;21G&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;paste it with &lt;code&gt;p&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Just provide more information if it is not your usercase. (:&lt;/p&gt;&#xA;" OwnerUserId="10493" LastActivityDate="2017-04-21T09:28:45.517" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12181" PostTypeId="2" ParentId="12179" CreationDate="2017-04-21T09:32:27.850" Score="1" Body="&lt;p&gt;You can jump around paragraphs with &lt;code&gt;{&lt;/code&gt; &lt;code&gt;}&lt;/code&gt;. Yank a paragraph with &lt;code&gt;y}&lt;/code&gt;, if you are positioned above the paragraph you want. Then you use &lt;code&gt;:e file2&lt;/code&gt; to open the other file (or whichever method you use to switch between open files). Then &lt;code&gt;p&lt;/code&gt; for paste to paste the paragraph.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-21T09:32:27.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12182" PostTypeId="1" AcceptedAnswerId="12183" CreationDate="2017-04-21T09:46:00.707" Score="4" ViewCount="574" Body="&lt;p&gt;I understand that &lt;code&gt;f&lt;/code&gt; jumps to the first matching character, and &lt;code&gt;t&lt;/code&gt; jumps to one character just before the first matching character&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, given the string &lt;code&gt;VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL&lt;/code&gt;, I would like to change it to &lt;code&gt;VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL&lt;/code&gt;. with the caret on &lt;code&gt;V&lt;/code&gt; I should press &lt;code&gt;4f_lct_SRC&lt;/code&gt; to achieve that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'm wondering if there is a key that allows me to jump to one character just &lt;em&gt;after&lt;/em&gt; the first matching character, so I can omit the &lt;code&gt;l&lt;/code&gt; offset, (which frankly trips me up sometimes) and turn the sequence into &lt;code&gt;4  %SOMETHING%  _ct_SRC&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that this can be accomplished by macros (or in this specific example circumvented by a substitution), but I'm wondering if this functionality exists out of the box&lt;/p&gt;&#xA;" OwnerUserId="12318" LastEditorUserId="1169" LastEditDate="2019-05-30T02:33:36.537" LastActivityDate="2019-05-30T02:33:36.537" Title="Jumping to one character past the search" Tags="|search|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12183" PostTypeId="2" ParentId="12182" CreationDate="2017-04-21T09:55:37.113" Score="4" Body="&lt;p&gt;You can use search, e.g. &lt;code&gt;/_DST/s+&lt;/code&gt; to move the cursor to the &lt;code&gt;D&lt;/code&gt; of the DST part. The part after the search pattern is the offset, so &lt;code&gt;s+&lt;/code&gt; moves the cursor 1 character to the right of the &lt;strong&gt;s&lt;/strong&gt;tart of the pattern, while, e.g. &lt;code&gt;e-2&lt;/code&gt; would move the cursor 2 character to the left of the &lt;strong&gt;e&lt;/strong&gt;nd of the pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the help at &lt;code&gt;:h search-offset&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-04-21T09:55:37.113" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12184" PostTypeId="2" ParentId="12182" CreationDate="2017-04-21T13:03:03.513" Score="2" Body="&lt;p&gt;Maybe I don't understand your question, but why are you not using &lt;code&gt;fD&lt;/code&gt;? That puts you right on the D.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, you can define underline as a keyword via &lt;code&gt;set iskeyword-=_&lt;/code&gt;. In your situation, this allows the change via &lt;code&gt;cw&lt;/code&gt;. That is quite handy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in total just &lt;code&gt;fDcwSCR&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last but not least you can roll out the big guns and employ plugins like &lt;a href=&quot;https://github.com/bkad/CamelCaseMotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;CamelCaseMotion&lt;/a&gt; or &lt;a href=&quot;https://github.com/justinmk/vim-sneak&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sneak&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-21T13:03:03.513" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12185" PostTypeId="1" CreationDate="2017-04-21T13:36:00.540" Score="1" ViewCount="314" Body="&lt;p&gt;I am quite new to using vim so please forgive me if this has been asked else where.  I have tried Googling but am not really sure what to search for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my vimrc I have the follwing function that will search for &lt;code&gt;(&amp;lt;.&amp;gt;)&lt;/code&gt;, delete it and enter insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NextMark()&#xA;    execute &quot;normal! /(&amp;lt;.&amp;gt;)\&amp;lt;cr&amp;gt;da(&quot;&#xA;    execute &quot;startinsert&quot;&#xA;endfunction &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works as expected and I have the following mapping so that pressing double space in insert mode will run the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;space&amp;gt;&amp;lt;space&amp;gt; &amp;lt;Esc&amp;gt;:call NextMark()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works so I don't believe the problem is with the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I create a new HTML file (and in the future this will be extended for other files), I would like to read in a template file and run the above function.  Below is what I have so far but for some reason it isn't working:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup new_html&#xA;    autocmd!&#xA;    autocmd BufNew *.html execute &quot;read ~/Templates/html&quot;&#xA;    autocmd BufNew *.html execute &quot;normal! ggdd&quot;&#xA;    autocmd BufNew *.html execute NextMark()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This partly works, it reads my file and deletes the first (empty) line.  For some reason though, it doesn't take me to the first &lt;code&gt;(&amp;lt;.&amp;gt;)&lt;/code&gt; although it does put me into insert mode so I think the function is being run.  For some reason, it isn't doing the search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any help&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&#xA;I have just noticed that the first marker is being deleted, I am just being put in insert mode in the wrong place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do the &lt;code&gt;autocmd&lt;/code&gt;s I specify get run one after the other?  It is a bit like the second and third are being run at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt;&#xA;Thank you @Naumann and @Tumbler41 for your suggestions.  I now have a seperate function that reads in my template, deletes the first line then calls NextMark.  Here s the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NewHtml()&#xA;    read ~/Templates/html&#xA;    execute &quot;normal! ggdd&quot;&#xA;    call NextMark()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and here is my revised autocmd block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup new_html&#xA;    autocmd!&#xA;    autocmd BufNew *.html call NewHtml()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am still being left with the first mark deleted but in inset mode at the begining of the document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any more suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 3&lt;/strong&gt;&#xA;I have just added &lt;code&gt;BufNewFile&lt;/code&gt; to the autocmd so that it will work if i run &lt;code&gt;vim newFile.html&lt;/code&gt; from the command line.  This works.  If, however, I already have vim open and I run &lt;code&gt;:e newFile.html&lt;/code&gt;, it almost works but my cursor is at the begining of the file, not at the point of my first mark.&lt;/p&gt;&#xA;" OwnerUserId="12323" LastEditorUserId="12323" LastEditDate="2017-04-22T08:39:58.367" LastActivityDate="2017-04-22T08:39:58.367" Title="Search not working in function called from autocmd" Tags="|vimrc|autocmd|functions|" AnswerCount="0" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12187" PostTypeId="2" ParentId="12150" CreationDate="2017-04-21T15:45:59.070" Score="0" Body="&lt;p&gt;It sounds like you would benefit from a custom quickfix window. I too tried many different ways to use the built-in make command, and while it's a great feature, it can't do everything. It really isn't customizable like a normal window is, or even the preview window. I found the preview window far more effective at displaying output (though my solution doesn't have colored output). If the preview window doesn't give you the output you want, you could try just using a normal split pane.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code assumes the output file (in C at least) is a &lt;code&gt;*.cmp&lt;/code&gt; file in a directory like &lt;code&gt;C:\TEMP&lt;/code&gt; or some other directory indicated by your &lt;code&gt;$TMP&lt;/code&gt; environment variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can just call CompileModule in your autocommand. The provided code also maps double-click to the double click handler so that double-clicking in this custom window takes you to the exact file, line, and column where the compiler choked. I realize the quickfix window does this automatically for you, but as stated earlier, it is very difficult to customize.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:vimdbg_file = $VIMRUNTIME . &quot;\\vimdebug.out&quot;&#xA;let s:show_err_type = 0 &quot; set to 1 to include error indicator in output&#xA;let s:output_window_height = 12 &quot; maximum size of output window, uses less space if there is less output&#xA;&#xA;map &amp;lt;silent&amp;gt; &amp;lt;2-LeftMouse&amp;gt; :call HandleDoubleLeftClick()&amp;lt;CR&amp;gt;&#xA;&#xA;function! CompileModule()&#xA;    if expand('%:t') == 'vimdebug.out' | exe &quot;wincmd k&quot; | endif&#xA;&#xA;    &quot; adjust compile below to your actual command line build tool&#xA;    &quot; (this executes a shell command to change to the directory of the current file and then build)&#xA;    exe &quot;silent !( cd %:p:h ; compile %:r )&quot;&#xA;&#xA;    let s:last_built = tolower(expand('%:t'))&#xA;&#xA;    call ShowOutFile()&#xA;endf&#xA;&#xA;function! ShowOutFile()&#xA;    let tmp_dir = $TMPDIR&#xA;    if tmp_dir == &quot;&quot;&#xA;        let tmp_dir = $TEMP&#xA;    endif&#xA;    if tmp_dir == &quot;&quot;&#xA;        let tmp_dir = $TMP&#xA;    endif&#xA;    let outfile = tmp_dir . '/' . expand( '%:t:r' ) . '.cmp'&#xA;&#xA;    if getfsize( outfile ) == 0 || !filereadable( outfile )&#xA;        let outfile = expand( '%:r' ) . '.out'&#xA;        &quot; stash this in msg history and hide so it's not disruptive&#xA;        echom &quot;.cmp not found, using .out&quot;&#xA;        redraw&#xA;    endif&#xA;&#xA;    if getfsize( outfile ) &amp;gt; 0 &amp;amp;&amp;amp; filereadable( outfile )&#xA;        let outbuff = readfile( outfile )&#xA;        let dispbuff = []&#xA;        let index = 0&#xA;        let num_errors = 0&#xA;        for errline in outbuff&#xA;            if match( errline, ' error \| warning\|informational\|severe' ) &amp;gt;= 0&#xA;                if match( errline, ' error ' ) &amp;gt;= 0&#xA;                    let num_errors += 1&#xA;                endif&#xA;                let index = stridx( errline, &quot;(&quot; )&#xA;                let index2 = stridx( errline, &quot;)&quot;, index )&#xA;                let index3 = stridx( errline, &quot;:&quot;, index2 )&#xA;                let index4 = stridx( errline, &quot;:&quot;, index3 + 1 )&#xA;&#xA;                &quot; get the entire filename&#xA;                let search_idx = index&#xA;                while ( errline[search_idx] != '\' &amp;amp;&amp;amp; errline[search_idx] != '/' &amp;amp;&amp;amp; search_idx &amp;gt;= 0 )&#xA;                    let search_idx -= 1&#xA;                endw&#xA;&#xA;                &quot; if filename is different, include it in output&#xA;                if ( ( tolower(expand('%:t')) == strpart( errline, search_idx + 1, index - (search_idx + 1) ) ) || ( s:always_include_filename == 1 ) )&#xA;                    let startidx = index&#xA;                    let startlen = (index2 + 1) - index&#xA;                else&#xA;                    let startidx = search_idx + 1&#xA;                    let startlen = index2 - search_idx&#xA;                endif&#xA;&#xA;                &quot; include error type indicator in output&#xA;                if s:show_err_type == 1&#xA;                    if match( errline, 'error' ) &amp;gt;= 0&#xA;                        let c_err_ind = &quot; E&quot;&#xA;                    elseif match( errline, 'warning' ) &amp;gt;= 0&#xA;                        let c_err_ind = &quot; W&quot;&#xA;                    elseif match( errline, 'informational' ) &amp;gt;= 0&#xA;                        let c_err_ind = &quot; I&quot;&#xA;                    else&#xA;                        let c_err_ind = &quot; &quot;&#xA;                    endif&#xA;                else&#xA;                    let c_err_ind = &quot; &quot;&#xA;                endif&#xA;&#xA;                let startline = strpart( errline, startidx, startlen )&#xA;                let endline = strpart( errline, index4 )&#xA;&#xA;                if c_err_ind == &quot; &quot;&#xA;                    call add( dispbuff, startline . endline )&#xA;                else&#xA;                    call add( dispbuff, startline . c_err_ind . endline )&#xA;                endif&#xA;            endif&#xA;        endfor&#xA;&#xA;        if dispbuff == [] || len(dispbuff) == 0&#xA;            redraw &quot; Erase any existing messages - gets rid of ENTER prompt&#xA;            echom expand('%:t') . ' compiled successfully!'&#xA;&#xA;            &quot; Close preview window if it's open&#xA;            try&#xA;                sil exe &quot;pc&quot;&#xA;            catch /^Vim(\a\+):E441:/&#xA;            endtry&#xA;&#xA;            return&#xA;        else&#xA;            redraw &quot; Erase any existing messages - gets rid of ENTER prompt&#xA;&#xA;            if num_errors &amp;gt; 0&#xA;                echohl ErrorMsg&#xA;                echom num_errors . ' compile errors found!'&#xA;                echohl Normal&#xA;            else&#xA;                echohl WarningMsg&#xA;                echom 'Compile successful, see warnings...'&#xA;                echohl Normal&#xA;            endif&#xA;        endif&#xA;&#xA;        &quot; Write to a special output file&#xA;        call writefile( dispbuff, s:vimdbg_file )&#xA;&#xA;        &quot; Load (or re-load) the output file&#xA;        sil exe &quot;ped &quot; . s:vimdbg_file&#xA;&#xA;        &quot; Move preview window to the bottom&#xA;        try&#xA;            exe &quot;wincmd P&quot;&#xA;            exe &quot;wincmd J&quot;&#xA;        catch /^Vim(\a\+):E441:/ &quot; no preview window open&#xA;        endtry&#xA;&#xA;        &quot; Determine size of output (preview) window&#xA;        set previewheight=1&#xA;        let i = 1&#xA;        let owh = s:output_window_height&#xA;        let ph = ( owh &amp;lt; len(dispbuff) ) ? owh : len(dispbuff)&#xA;        while i &amp;lt; ph&#xA;            set previewheight+=1&#xA;            let i += 1&#xA;        endw&#xA;&#xA;        &quot; Resize window&#xA;        try&#xA;            exe &quot;wincmd P&quot;&#xA;        catch /^Vim(\a\+):E441:/&#xA;        endtry&#xA;        exe &quot;res &quot; ph&#xA;    else&#xA;        redraw &quot; Erase any existing messages - gets rid of ENTER prompt&#xA;        echohl WarningMsg&#xA;        &quot; (no way to tell a difference between the two)&#xA;        echom &quot;Build successful (or output file not found).&quot;&#xA;        echohl Normal&#xA;&#xA;        &quot; Close preview window if it's open&#xA;        try&#xA;            sil exe &quot;pc&quot;&#xA;        catch /^Vim(\a\+):E441:/&#xA;        endtry&#xA;    endif&#xA;endf&#xA;&#xA;function! HandleDoubleLeftClick()&#xA;    let err_line = 0&#xA;    let err_col = 0&#xA;&#xA;    if expand('%:t') == &quot;vimdebug.out&quot;&#xA;        let curr_line = getline('.')&#xA;        let index1 = stridx( curr_line, '(' )&#xA;        let index2 = stridx( curr_line, ':', index1 )&#xA;        let index1 += 1&#xA;        let int1len = index2 - index1&#xA;        let index3 = stridx( curr_line, ')', index2 )&#xA;        let index2 += 1&#xA;        let int2len = index3 - index2&#xA;&#xA;        let err_line = str2nr( strpart( curr_line, index1, int1len ) )&#xA;        let err_col = str2nr( strpart( curr_line, index2, int2len ) )&#xA;&#xA;        &quot; if there are characters in front of the first '(' then&#xA;        &quot; we have a filename to parse first&#xA;        if index1 &amp;gt; 1&#xA;            let buf_name = strpart( curr_line, 0, index1 - 1 )&#xA;        else&#xA;            if exists( s:last_built )&#xA;                let buf_name = s:last_built&#xA;            else&#xA;                &quot; set buf_name to buffer name of other file (upper window?)&#xA;                wincmd k&#xA;&#xA;                let buf_name = tolower(expand('%:t'))&#xA;            endif&#xA;        endif&#xA;        redraw&#xA;        &quot; switches to the appropriate file if open; if not, opens it&#xA;        exe &quot;dr &quot; . buf_name&#xA;&#xA;        &quot; now go to the located line and column&#xA;        exe &quot;normal &quot; . err_line . &quot;G&quot;&#xA;        exe &quot;normal 0&quot;&#xA;        if err_col &amp;gt; 1&#xA;            exe &quot;normal &quot; . (err_col - 1) . &quot;l&quot;&#xA;        endif&#xA;&#xA;        redraw&#xA;    else&#xA;        &quot; put code here to do whatever you'd like double click to normally do&#xA;    endif&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10168" LastActivityDate="2017-04-21T15:45:59.070" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12188" PostTypeId="1" AcceptedAnswerId="12189" CreationDate="2017-04-21T15:59:02.460" Score="8" ViewCount="3559" Body="&lt;p&gt;I'm creating a folder with common code snippets I use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to create a quick command in vim to insert them, for example something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:snippet codeblock1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideally it would be a single command and &lt;code&gt;codeblock1&lt;/code&gt; could be replaced by the file name of a code snippet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That way I could have a single command and add new snippets by creating new files in a set folder, likely in &lt;code&gt;~/.vim/snippets/&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7783" LastActivityDate="2017-04-25T20:01:35.923" Title="Insert code snippets?" Tags="|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12189" PostTypeId="2" ParentId="12188" CreationDate="2017-04-21T16:08:01.937" Score="9" Body="&lt;p&gt;The &lt;code&gt;:r&lt;/code&gt; command can read a file containing a code snippet and insert it to your active buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless I'm missing something, I believe this would address your request.&lt;/p&gt;&#xA;" OwnerUserId="6590" LastActivityDate="2017-04-21T16:08:01.937" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12192" PostTypeId="2" ParentId="12169" CreationDate="2017-04-21T18:09:29.220" Score="3" Body="&lt;p&gt;The following should solve your issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; : ShowLastCmd()&#xA;&#xA;function! ShowLastCmd()&#xA;  echohl ModeMsg&#xA;  echo ':' . getreg(':')&#xA;  echohl None&#xA;&#xA;  while 1&#xA;    try&#xA;      let char = getchar()&#xA;      if char == '^\d\+$' || type(char) == 0&#xA;        let char = nr2char(char)&#xA;      endif&#xA;    catch /^Vim:Interrupt$/&#xA;      return ''&#xA;    endtry&#xA;&#xA;    if char == &quot;\&amp;lt;cursorhold&amp;gt;&quot;&#xA;      continue&#xA;    elseif char == &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;      return ':' . getreg(':') . &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;    else&#xA;      return ':' . char&#xA;    endif&#xA;  endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;while&lt;/code&gt; loops is there to catch the &lt;code&gt;&amp;lt;cursorhold&amp;gt;&lt;/code&gt; key event.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2017-04-22T17:23:12.127" LastActivityDate="2017-04-22T17:23:12.127" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12194" PostTypeId="1" CreationDate="2017-04-21T19:33:20.647" Score="0" ViewCount="153" Body="&lt;p&gt;I am using somebody else's vim script that has a neat plugin that allows me type in something like &lt;code&gt;sub&amp;lt;tab&amp;gt;&lt;/code&gt; and it will generate the following for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sub ___ {&#xA;  ___&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The blank lines act like fields. After the code is generated, the cursor is placed at the beginning of the first blank line and I can immediately type in the name of the subroutine. Then I hit the right arrow key and it takes me to the beginning of the next field and I start entering code for the subroutine. I call this a &quot;mini template&quot; for lack of a better term.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is nice, but I would like the ability to generate different subroutine code for different kinds of subroutines. For example, sometimes I want a subroutine that starts like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Example 1:&#xA;sub ___ {&#xA;  my ( $self, ___, ___ ) = validated_list(&#xA;      \@_,&#xA;      ___ =&amp;gt; { isa =&amp;gt; '___' },&#xA;      ___ =&amp;gt; { isa =&amp;gt; '___' },&#xA;  );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other times I may want a subroutine that starts like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Example 2:&#xA;sub ___ {&#xA;  my $self = shift;&#xA;  my ( ___, ___ ) = pos_validated_list(&#xA;      \@_,&#xA;      { isa =&amp;gt; '___' },&#xA;      { isa =&amp;gt; '___' },&#xA;  );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I would like to have is something like abbreviations where I would type in &lt;code&gt;sub1&amp;lt;TAB&amp;gt;&lt;/code&gt; and it would generate the first example and &lt;code&gt;sub2&amp;lt;TAB&amp;gt;&lt;/code&gt; would generate the second example except it would provide these nice fields that I can fill out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any plugins that will help me easily generate these different mini templates?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="2021" LastEditDate="2017-04-21T19:46:08.123" LastActivityDate="2017-04-21T22:12:11.227" Title="Creating fillable &quot;mini templates&quot;" Tags="|abbreviations|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12195" PostTypeId="2" ParentId="12194" CreationDate="2017-04-21T22:12:11.227" Score="1" Body="&lt;p&gt;The keyword you're looking for is &lt;em&gt;snippet&lt;/em&gt;. There exist plenty snippet plugins. I'm maintaining mu-template (where snippets can use other snippets as functions call other functions), more popular plugins are snipmate &amp;amp; co.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-04-21T22:12:11.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12196" PostTypeId="1" AcceptedAnswerId="12200" CreationDate="2017-04-22T00:05:12.417" Score="2" ViewCount="4381" Body="&lt;p&gt;I want to put some customizations of mine in the .vim folder, actually a subdirectory because I don't want to many .files in my home directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that alright or is the .vim directory restricted to some kind of &lt;code&gt;approved&lt;/code&gt; plugins and other users?&lt;/p&gt;&#xA;" OwnerUserId="9540" LastActivityDate="2017-04-22T03:16:12.267" Title="What goes into the '.vim' folder, can I store my own stuff there?" Tags="|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12198" PostTypeId="2" ParentId="12196" CreationDate="2017-04-22T02:53:32.513" Score="1" Body="&lt;p&gt;you can put your files there at will.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you can also create your own directories there.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-04-22T02:53:32.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12200" PostTypeId="2" ParentId="12196" CreationDate="2017-04-22T03:16:12.267" Score="1" Body="&lt;p&gt;The &lt;code&gt;.vim&lt;/code&gt; directory under your home directory is used by Vim as the first place to search for vim scripts after starting up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's fine to add your own files, in fact a lot of plugins or plugin managers already do under their own subdirectory. Just be careful not to name your files or subdirectories anything that is already used by Vim. Take a look at the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27runtimepath%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;'runtimepath'&lt;/a&gt; documentation for a list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting from version 7.4 you can even put your &lt;code&gt;.vimrc&lt;/code&gt; file in the &lt;code&gt;.vim&lt;/code&gt; directory to declutter your home directory.&lt;/p&gt;&#xA;" OwnerUserId="2283" LastActivityDate="2017-04-22T03:16:12.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12201" PostTypeId="2" ParentId="12018" CreationDate="2017-04-22T07:04:01.643" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#startup&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help startup&lt;/code&gt;&lt;/a&gt; describes what Vim does on startup. I won't repeat the full details here, but you're correct that packages are loaded right after the initialization files (vimrc etc.) However, you can use the &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%3Apackloadall&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:packloadall&lt;/code&gt;&lt;/a&gt; to do this earlier if desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, the &lt;code&gt;VimEnter&lt;/code&gt; autocmd is run as the last step, and packages should have been loaded at this point, so that should work. Your autocommand does look funky though:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au VimEnter * if argc() == 0 | exe &quot;:Denite `finddir('.git', ';') != '' ? 'file_rec/git' : 'file_rec'`&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Why is there no &lt;code&gt;endif&lt;/code&gt;? That seems like an error.&lt;/li&gt;&#xA;&lt;li&gt;What are those &lt;code&gt;`&lt;/code&gt;s? Are you sure that's correct?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-04-22T07:04:01.643" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12202" PostTypeId="2" ParentId="10756" CreationDate="2017-04-22T07:52:12.273" Score="2" Body="&lt;p&gt;The headers and options are highlighted with syntax highlighting, so your question could be considered as a special case of &quot;how can I jump to the next syntax item?&quot; If we solve that problem, we've also solved this one, since we use it to get to the syntax item for the man page header.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a basic version of such a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! FindSyntax(name) abort&#xA;    &quot; Try to find this syntax item. Unfortunately this can't really be queried&#xA;    &quot; with a function, so this is a bit ugly.&#xA;    let l:syn_list = execute(':syntax list ' . a:name)&#xA;    let l:pattern = ''&#xA;    for l:line in split(l:syn_list, '\n')&#xA;        if l:line[:len(a:name)-1] == a:name&#xA;            let l:pattern = l:line&#xA;            break&#xA;        endif&#xA;    endfor&#xA;    if l:pattern == ''&#xA;        echoerr 'unable to find syntax pattern for ' . a:name&#xA;    endif&#xA;&#xA;    &quot; Find pattern. This is somewhat limited and only works for :syn match ..&#xA;    let l:pattern = substitute(l:pattern, a:name . '\s\+xxx match /\(.\+\)/', '\1', 0)[:-3]&#xA;&#xA;    &quot; Jump to next instance of this pattern&#xA;    call search(l:pattern)&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It only works stuff defined with &lt;code&gt;:syntax match&lt;/code&gt; for now (which is good enough for the purpose of this question), but this can be extended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get the name of the text under the cursor with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo synIDattr(synID(line('.'), col('.'), 1), 'name')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For man pages, this seems to be &lt;code&gt;manSectionHeading&lt;/code&gt; and &lt;code&gt;manOptionDesc&lt;/code&gt;. We can now use this in various ways:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call FindSyntax('manSectionHeading')&#xA;:call FindSyntax('manOptionDesc')&#xA;&#xA;&quot; Next section&#xA;nnoremap &amp;lt;Leader&amp;gt;ns :call FindSyntax('manSectionHeading')&amp;lt;CR&amp;gt;&#xA;&quot; Next option&#xA;nnoremap &amp;lt;Leader&amp;gt;no :call FindSyntax('manOptionDesc')&amp;lt;CR&amp;gt;&#xA;&#xA;:command NextSection :call FindSyntax('manSectionHeading')&#xA;:command NextOption :call FindSyntax('manOptionDesc')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I asked a somewhat related question over at Unix.SE last year, by the way: &lt;a href=&quot;https://unix.stackexchange.com/q/271550/33645&quot;&gt;how can I search for bolded or underlined text?&lt;/a&gt;, which also has some Vim-specific answers.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-04-22T07:52:12.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12203" PostTypeId="2" ParentId="8751" CreationDate="2017-04-22T18:30:29.973" Score="4" Body="&lt;p&gt;&lt;code&gt;set t_Co=0&lt;/code&gt; breaks certain Vim features, like &lt;code&gt;^X^O&lt;/code&gt; and still uses basic term highlighting (bold, underlined).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use something like &lt;a href=&quot;https://github.com/robertmeta/nofrils&quot; rel=&quot;nofollow noreferrer&quot;&gt;nofrils&lt;/a&gt; and adjust the &lt;code&gt;hi Normal cterm=none ctermfg=none ctermbg=none&lt;/code&gt;. Other than that I don't see any other way, without messing up your Vim experience.&lt;/p&gt;&#xA;" OwnerUserId="12341" LastEditorUserId="5395" LastEditDate="2017-04-22T20:24:02.097" LastActivityDate="2017-04-22T20:24:02.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12204" PostTypeId="1" AcceptedAnswerId="12213" CreationDate="2017-04-23T02:51:45.653" Score="0" ViewCount="237" Body="&lt;p&gt;Something I commonly do in files is add a modeline that says use this &lt;code&gt;{{{...}}}&lt;/code&gt; pattern to delimit regions to be folded:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: foldmethod=marker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When vim first opens the file, the text inside the &lt;code&gt;{{{...}}}&lt;/code&gt; will be folded and I will get an overview of the sections of the file.&lt;br&gt;&#xA;I can then use &quot;file wide&quot; commands to target all the folded sections, &lt;code&gt;zm&lt;/code&gt; and &lt;code&gt;zr&lt;/code&gt;, or just toggle a specific region with commands like &lt;code&gt;zc&lt;/code&gt; or &lt;code&gt;zo&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Something worth mentioning&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I am running the &lt;a href=&quot;https://github.com/sirver/UltiSnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;ultisnips&lt;/a&gt; plugin, with snipmate type snippet files in &lt;code&gt;~/.vim/snippets&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The problem&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;When I have a snippet file in &lt;code&gt;~/.vim/snippets&lt;/code&gt; whose filetype is snippets. e.g. something like this:&#xA;&lt;code&gt;filename: ~/.vim/snippets/html.snippets&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: foldmethod=marker&#xA;&#xA;# Global snippets&#xA;&#xA;# HTML {{{&#xA;snippet font_oswald&#xA;    &amp;lt;link href='https://fonts.googleapis.com/css?family=Oswald:700,400' rel='stylesheet' type='text/css'&amp;gt;&#xA;snippet font_oswald_style&#xA;    .oswald {&#xA;        font-family: 'Oswald', sans-serif;&#xA;        font-style: normal;&#xA;        font-weight: 700;&#xA;        text-transform: uppercase;&#xA;        text-decoration: none;&#xA;        letter-spacing: 0em;&#xA;        word-spacing: 0em;&#xA;        line-height: 1.4;&#xA;    }&#xA;snippet font_roboto&#xA;    &amp;lt;link href='https://fonts.googleapis.com/css?family=Roboto:400,700,900' rel='stylesheet' type='text/css'&amp;gt;&#xA;snippet font_roboto_style&#xA;    .roboto {&#xA;        font-family: 'Roboto', sans-serif;&#xA;        font-style: normal;&#xA;        font-weight: 900;&#xA;        text-transform: none;&#xA;        text-decoration: none;&#xA;        letter-spacing: 0em;&#xA;        word-spacing: 0em;&#xA;        line-height: 1.4;&#xA;    }&#xA;# }}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim is not automatically folding the text when I open this file and the &quot;file wide&quot; command &lt;code&gt;zm&lt;/code&gt; and &lt;code&gt;zr&lt;/code&gt; dont work, but the fold specific commands &lt;code&gt;zc&lt;/code&gt; or &lt;code&gt;zo&lt;/code&gt; do still work.&lt;br&gt;&#xA;The modeline setting is being recognised, i.e &lt;code&gt;:set foldmethod?&lt;/code&gt; returns&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foldmethod=marker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get the &quot;normal&quot; behaviour to work in &lt;code&gt;snippet&lt;/code&gt; files?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;update&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;well I know its something to do with the &lt;code&gt;ultisnips&lt;/code&gt; plugin as the problem goes away when I disable ultisnips.&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2017-04-23T03:20:33.300" LastActivityDate="2017-04-24T04:10:58.747" Title="Why is folding partial disabled in .snippets filetypes?" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12205" PostTypeId="1" AcceptedAnswerId="12206" CreationDate="2017-04-23T09:01:19.037" Score="4" ViewCount="2390" Body="&lt;p&gt;To move cursor on the 4th line,toggle into normal mode,input &lt;code&gt;8yy&lt;/code&gt;.&lt;br&gt;&#xA;To move cursor to 15th line,and toggle into normal mode,press &lt;code&gt;p&lt;/code&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the lines from 4th till 11th was pasted from 15th  till  22th line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can all the steps can be repalced with a command in ex mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it clear.&lt;br&gt;&#xA;primitive file&#xA;&lt;a href=&quot;https://i.stack.imgur.com/p0OyL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/p0OyL.png&quot; alt=&quot;from&quot;&gt;&lt;/a&gt;&#xA;target file&#xA;&lt;a href=&quot;https://i.stack.imgur.com/EjRS0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EjRS0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to change primitive file into target file with a command in ex mode?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="5181" LastEditDate="2017-04-23T09:58:09.820" LastActivityDate="2018-09-30T22:52:38.580" Title="How to copy lines from 4th till 11th and paste it from 15th till 22th line in ex mode?" Tags="|cut-copy-paste|normal-mode|ex-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12206" PostTypeId="2" ParentId="12205" CreationDate="2017-04-23T09:50:12.070" Score="12" Body="&lt;p&gt;I'm not sure if I understand you correctly but is this what you're looking for?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:4,11t 15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will copy lines from 4 to 11 and paste it on line 15.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h co&lt;/code&gt; for more.&lt;/p&gt;&#xA;" OwnerUserId="428" LastEditorUserId="428" LastEditDate="2018-09-30T22:52:38.580" LastActivityDate="2018-09-30T22:52:38.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12207" PostTypeId="1" AcceptedAnswerId="12210" CreationDate="2017-04-23T10:47:55.767" Score="2" ViewCount="945" Body="&lt;p&gt;I am trying to configure &lt;code&gt;prettier-eslint&lt;/code&gt; and &lt;code&gt;prettier-standard&lt;/code&gt; as the js formatter with neoformat:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; neoformat should try formatprg where available&#xA;let g:neoformat_try_formatprg = 1&#xA;augroup vimrc&#xA;  &quot; if eslint is found&#xA;  if HasEslint()&#xA;    &quot;get path of prettier-eslint&#xA;    let g:prettier_eslint_path =  system('PATH=$(npm bin):$PATH &amp;amp;&amp;amp; which prettier-eslint')&#xA;    echom g:prettier_eslint_path&#xA;&#xA;    if s:has_eslintrc_path&#xA;      &quot;get full path to eslintrc if eslintrc file exists&#xA;      let g:eslintrc_full_path = getcwd() + s:eslintrc_path&#xA;      echom g:eslintrc_full_path&#xA;&#xA;      autocmd FileType javascript set formatprg = g:prettier_eslint_path --filePath g:eslintrc_full_path&#xA;    elseif s:has_eslintConfig&#xA;      let g:eslintConfig = system(&quot;jq &amp;lt; package.json '.eslintConfig'&quot;)&#xA;      echom g:eslintConfig&#xA;      autocmd FileType javascript set formatprg = g:prettier_eslint_path --eslintConfig g:eslintConfig&#xA;    endif&#xA;  else&#xA;    &quot; just use prettier-standard&#xA;    autocmd FileType javascript set formatprg=prettier-standard&#xA;  endif&#xA;  autocmd BufWritePre *.js Neoformat&#xA;  &quot; autocmd BufWritePre,TextChanged,InsertLeave *.js Neoformat&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When opening a &lt;code&gt;js&lt;/code&gt; file, it gives me an error saying that it could not find &lt;code&gt;g:prettier_eslint_path&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure vim to use the local version of &lt;code&gt;prettier-eslint&lt;/code&gt; and pass the appropriate options to it. It seems to use the default settings if no options are provided.&lt;/p&gt;&#xA;" OwnerUserId="10361" LastActivityDate="2017-04-23T19:51:38.327" Title="vim cannot access variable in autocmd" Tags="|vimrc|autocmd|formatting|variables|path|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12210" PostTypeId="2" ParentId="12207" CreationDate="2017-04-23T19:51:38.327" Score="4" Body="&lt;p&gt;Would be nice to see the full error, on which line it complains. Nevertheless you have error in the script, the &lt;code&gt;set&lt;/code&gt; command requires no spaces around &lt;code&gt;=&lt;/code&gt;, or spaces at all after &lt;code&gt;=&lt;/code&gt; sign. You should also use &lt;code&gt;setlocal&lt;/code&gt;, since &lt;code&gt;set&lt;/code&gt; works globally (it will set for all buffers). And whole auto-command expression should be enclosed in &lt;code&gt;execute&lt;/code&gt; with concatenation with variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the &lt;code&gt;autocmd&lt;/code&gt;s should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType javascript execute &quot;setlocal formatprg=&quot;.g:prettier_eslint_path.&quot;\\ --filePath\\ &quot;.g:eslintrc_full_path&#xA;&#xA;autocmd FileType javascript execute &quot;setlocal formatprg=&quot;.g:prettier_eslint_path.&quot;\\ --eslintConfig\\ &quot;.g:eslintConfig&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, because you're enclosing this in a &lt;code&gt;augroup&lt;/code&gt;, would be usefull to add &lt;code&gt;au!&lt;/code&gt; on a first line to clear this group&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-04-23T19:51:38.327" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12212" PostTypeId="1" AcceptedAnswerId="12223" CreationDate="2017-04-23T21:31:24.910" Score="2" ViewCount="210" Body="&lt;p&gt;I would like to have a mapping based on the latex environment I am in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I currently have ;b mapped (in insert mode) to add &lt;code&gt;\textbf{}&lt;/code&gt; and put my cursor inside the curley brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment I have ;B mapped to do the same but with &lt;code&gt;\mathbf{}&lt;/code&gt;.  Unfortunately, I keep typing the wrong one.  I'm sure in time I could get used to it but was wondering if it were possible to have one mapping, say ;b, and have it normally add &lt;code&gt;\textbf{}&lt;/code&gt; but if I were in a maths environment it would add &lt;code&gt;\mathbf{}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To start with, if it added the maths version if it were between &lt;code&gt;$&lt;/code&gt; &lt;code&gt;$&lt;/code&gt; symbols on the same line or between &lt;code&gt;\begin{equation}&lt;/code&gt; and &lt;code&gt;\end{equation}&lt;/code&gt; on seperate lines, I should be able to extend it for other variations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to add that I work on a lot of different machines, often without internet access.  I keep a copy of my vimrc on me at all times but I try to do as much as possible without plugins.  It looks like vimtex might be an option but does anyone know how I could do it without a plugin?&lt;/p&gt;&#xA;" OwnerUserId="12323" LastEditorUserId="12323" LastEditDate="2017-04-27T12:42:13.430" LastActivityDate="2017-04-27T12:42:13.430" Title="Mapping based on latex environment" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12213" PostTypeId="2" ParentId="12204" CreationDate="2017-04-24T04:10:58.747" Score="0" Body="&lt;p&gt;Yes this is caused by this file in the ultisnips plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/bundle/UltiSnips/ftplugin/snippets.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;particularly this block of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set some sane defaults for snippet files&#xA;&#xA;if exists('b:did_ftplugin')&#xA;    finish&#xA;endif&#xA;let b:did_ftplugin = 1&#xA;&#xA;let s:save_cpo = &amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;&#xA;&quot; Fold by syntax, but open all folds by default&#xA;setlocal foldmethod=syntax&#xA;setlocal foldlevel=99&#xA;&#xA;setlocal commentstring=#%s&#xA;&#xA;setlocal noexpandtab&#xA;setlocal autoindent nosmartindent nocindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I considered trying to disable this code by adding something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:did_ftplugin = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;~/.vimrc&lt;/code&gt;, but I suspect this &lt;code&gt;did_ftplugin&lt;/code&gt; is scoped to a buffer?&lt;br&gt;&#xA;So my solution so far has been to add this modeline to any snippet files&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: foldmethod=marker foldlevel=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open the files the code is not folded, but I can fold it all with: &lt;code&gt;zM&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2017-04-24T04:10:58.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12214" PostTypeId="1" AcceptedAnswerId="12216" CreationDate="2017-04-24T07:15:04.093" Score="0" ViewCount="79" Body="&lt;p&gt;(I'm really not sure how I would google this. Sorry if this has already been asked and please just link me in the right direction in that case)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim in cygwin environment and marked a line in visual mode using &lt;kbd&gt;0&lt;/kbd&gt;,&lt;kbd&gt;v&lt;/kbd&gt;,&lt;kbd&gt;$&lt;/kbd&gt;.&#xA;When I then pressed &lt;kbd&gt;:&lt;/kbd&gt;, Vim automatically wrote &lt;code&gt;:'&amp;lt;, '&amp;gt;&lt;/code&gt; into the command line. I'm wondering what this does and what all the signs mean. The one thing I found using google is from the &lt;a href=&quot;http://vim.wikia.com/wiki/Using_the_Windows_clipboard_in_Cygwin_Vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim wiki&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;w !cat &amp;gt; /dev/clipboard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could you please explain this command step by step? I've been working with Vim for about a year now, but I still consider myself a complete newbie to it.&lt;/p&gt;&#xA;" OwnerUserId="12358" LastEditorUserId="5395" LastEditDate="2017-04-24T07:37:37.783" LastActivityDate="2017-04-24T07:46:36.313" Title="Explanation of command :'&lt;, '&gt;" Tags="|os-clipboard|cygwin|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12215" PostTypeId="2" ParentId="12214" CreationDate="2017-04-24T07:34:04.923" Score="1" Body="&lt;p&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; is not a command, but a &lt;strong&gt;range&lt;/strong&gt;.&#xA;You can &lt;strong&gt;prefix&lt;/strong&gt; any command with a range. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to know more: &lt;code&gt;:h ranges&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; is always displayed, when you &lt;strong&gt;select with visual mode&lt;/strong&gt; and it refers to the selected text. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, ranges allow you to &lt;strong&gt;narrow&lt;/strong&gt; an ex command to the range given. Ranges can be specified via a number of ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;relative line numbers&lt;/li&gt;&#xA;&lt;li&gt;absolute line numbers&lt;/li&gt;&#xA;&lt;li&gt;searches&lt;/li&gt;&#xA;&lt;li&gt;marks &lt;/li&gt;&#xA;&lt;li&gt;visual mode&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On a sidenote, you might be interested to know, that &lt;code&gt;V&lt;/code&gt; visually selects a whole line.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastEditorUserId="7267" LastEditDate="2017-04-24T07:46:36.313" LastActivityDate="2017-04-24T07:46:36.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12216" PostTypeId="2" ParentId="12214" CreationDate="2017-04-24T07:35:04.477" Score="3" Body="&lt;p&gt;Surprisingly, better than Google is to search in Vim's builtin help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h '&amp;lt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'&amp;lt;  `&amp;lt;&#xA;  To the first line or character of the last selected&#xA;  Visual area in the current buffer.  For block mode it&#xA;  may also be the last character in the first line (to&#xA;  be able to define the block).  {not in Vi}.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h '&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'&gt;  `&gt;            To the last line or character of the last selected&#xA;              Visual area in the current buffer.  For block mode it&#xA;              may also be the first character of the last line (to&#xA;              be able to define the block).  Note that 'selection'&#xA;              applies, the position may be just after the Visual&#xA;              area.  {not in Vi}.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So this represents selected region, and it will run given command on those lines only.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;lt;&lt;/code&gt; - first visually selected line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;,&lt;/code&gt; - till&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;gt;&lt;/code&gt; - last visually selected line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt; - write - will use only selected lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;!&lt;/code&gt; - use/run external command (instead of file in this context)&lt;/li&gt;&#xA;&lt;li&gt;rest is a shell command&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Additional reads: &lt;code&gt;:h v_:&lt;/code&gt;, &lt;code&gt;:h :range&lt;/code&gt;, &lt;code&gt;:h :w_c&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-04-24T07:35:04.477" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12218" PostTypeId="1" CreationDate="2017-04-24T14:07:06.673" Score="2" ViewCount="575" Body="&lt;p&gt;I want to be able to create a new buffer (and a new window with which to interact with it) to work with secret or sensitive info, e.g. passwords.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, none of the contents of the buffer would persist after it's closed or discarded. It'd probably be best if the contents are discarded too even when the last window for the buffer is closed. If possible, it'd be best if any in-memory copies of the buffer are 'wiped' when it's closed as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3645&quot; rel=&quot;nofollow noreferrer&quot;&gt;The gnupg.vim plugin&lt;/a&gt; claims:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The script turns off viminfo and swapfile to increase security.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So doing both seems necessary, tho perhaps not sufficient. What else should I do?&lt;/p&gt;&#xA;" OwnerUserId="2629" LastEditorUserId="2629" LastEditDate="2017-04-25T13:44:10.473" LastActivityDate="2017-04-25T13:44:10.473" Title="How to create a new 'secure scratchpad' buffer?" Tags="|buffers|security|scratch-buffer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12219" PostTypeId="1" AcceptedAnswerId="12220" CreationDate="2017-04-24T16:13:17.587" Score="0" ViewCount="253" Body="&lt;p&gt;I just started playing vimgolf and saw a solution that used this command to select a line and copy it to the line specified. I searched google and vim's documentation and couldn't find anything about what this command is. I was only able to find &lt;code&gt;:m&lt;/code&gt; which would move lines but this one seems to copy lines and paste them. What does the 't' stand for, is it still &quot;til&quot; because that doesn't make sense to me?&lt;/p&gt;&#xA;" OwnerUserId="3382" LastActivityDate="2017-04-24T16:16:50.160" Title="What does :[range]t &lt;line-number&gt; do?" Tags="|command-line|cut-copy-paste|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12220" PostTypeId="2" ParentId="12219" CreationDate="2017-04-24T16:16:50.160" Score="1" Body="&lt;p&gt;You probably just needed to include the colon in your help search. It's in there.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;:[range]co[py] {address}              *:co* *:copy*&#xA;        Copy the lines given by [range] to below the line&#xA;        given by {address}.&#xA;&#xA;                                      *:t*&#xA;:t      Synonym for copy.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As to &lt;em&gt;why&lt;/em&gt; it's a synonym for copy, it doesn't say. There may be a history reason but I don't know it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3At&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :t&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-04-24T16:16:50.160" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12221" PostTypeId="1" AcceptedAnswerId="12222" CreationDate="2017-04-24T16:34:22.033" Score="2" ViewCount="1158" Body="&lt;p&gt;I'd like to have the timestamp inserted on a new line every time I open a certain file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see that &lt;code&gt;put =strftime('%c')&lt;/code&gt; is the command that I want, and that putting that command into a file, say &lt;code&gt;pjf.vim&lt;/code&gt;  - and then into the folder &lt;code&gt;.vim/ftplugin/&lt;/code&gt; should do the trick. But unfortunately, it doesn't. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd&lt;/code&gt; almost does what I want - but with : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd VimEnter *.pjf pu=strftime('%c')&lt;/code&gt; - it puts the timestamp at the top of the file... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone have any clues? &lt;/p&gt;&#xA;" OwnerUserId="11231" LastEditorUserId="51" LastEditDate="2017-04-24T17:54:25.653" LastActivityDate="2017-04-24T17:54:25.653" Title="Automatically insert timestamp when opening certain file" Tags="|autocmd|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12222" PostTypeId="2" ParentId="12221" CreationDate="2017-04-24T16:55:44.160" Score="3" Body="&lt;p&gt;You were very close. You just need to add &lt;code&gt;$&lt;/code&gt; to your put command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter *.pjf $pu=strftime('%c')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;put&lt;/code&gt; can take a line argument. This can be a line number or &lt;code&gt;$&lt;/code&gt; for end of file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Aput&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :put&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-04-24T16:55:44.160" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12223" PostTypeId="2" ParentId="12212" CreationDate="2017-04-24T17:33:28.110" Score="3" Body="&lt;p&gt;One possibility is to use &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt;, which provides this possibility through the &lt;code&gt;imaps&lt;/code&gt; feature, see &lt;code&gt;:h vimtex-imaps&lt;/code&gt;, &lt;code&gt;:h vimtex#imaps#add_map&lt;/code&gt; and e.g. &lt;code&gt;:h vimtex#imaps#wrap_math&lt;/code&gt;. You could also use the internal API directly, if you know some vimscript, but I think the imaps feature might be easier to use. An example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call vimtex#imaps#add_map({&#xA;  \ 'lhs' : 'alph',&#xA;  \ 'rhs' : '\alpha',&#xA;  \ 'wrapper' : 'vimtex#imaps#wrap_math'&#xA;  \})&#xA;&#xA;call vimtex#imaps#add_map({&#xA;  \ 'lhs' : 'draw',&#xA;  \ 'rhs' : '\draw',&#xA;  \ 'wrapper' : 'vimtex#imaps#wrap_environment',&#xA;  \ 'context' : ['tikzpicture'],&#xA;  \})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-04-24T17:33:28.110" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12225" PostTypeId="1" CreationDate="2017-04-24T22:00:46.223" Score="1" ViewCount="199" Body="&lt;p&gt;can I display a list of the tabs in a side pane, so you can switch by selecting from it? Something similar to NERDTree's pane.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to toggle it into view, select the tab I want in switch to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it can expand show a list of windows in that pane that you can switch to directly, that will even be better.&lt;/p&gt;&#xA;" OwnerUserId="9540" LastEditorUserId="51" LastEditDate="2017-04-25T07:12:48.587" LastActivityDate="2017-04-25T07:32:25.913" Title="Can I display a list of the tabs in a side-pane?" Tags="|tabbed-user-interface|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12227" PostTypeId="1" CreationDate="2017-04-21T18:08:52.363" Score="4" ViewCount="10953" Body="&lt;p&gt;I am running Vim version 8.0.563 on Solaris and when I run Vim, the &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; block selection works as expected, I type &lt;code&gt;^V&lt;/code&gt; and move the cursor and a block of text is highlighted by columns.  So far, so good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meanwhile, for another user running Vim from my directory with my &lt;code&gt;.vimrc&lt;/code&gt; file, this does not work.  The &lt;code&gt;^V&lt;/code&gt; is ignored and moving the cursor, moves the cursor but nothing is highlighted.  Regular &lt;code&gt;v&lt;/code&gt;, block mode works but the &lt;code&gt;^V&lt;/code&gt; column block mode is broken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried entering:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --noplugin -u /dev/null&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it acts the same.  I checked the shared libraries and they are the same. I tried clearing out (almost) all the environment variables, still no joy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody have any good ideas of what is wrong or something else to try?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="6574" OwnerDisplayName="user1683793" LastEditorUserId="205" LastEditDate="2017-04-25T05:43:29.303" LastActivityDate="2020-10-20T19:49:36.763" Title="Vim ^V Visual Block mode not working" Tags="|visual-mode|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="12228" PostTypeId="2" ParentId="422" CreationDate="2017-04-25T06:52:34.060" Score="10" Body="&lt;p&gt;I personally like the use of the plugin &lt;a href=&quot;https://github.com/Yggdroot/indentLine&quot; rel=&quot;noreferrer&quot;&gt;indentLine&lt;/a&gt;, which displays a vertical line at indentation levels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is of great help especially in python, where the indentation is important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/v9gRE.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/v9gRE.png&quot; alt=&quot;(Image taken from the link above)&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Among other things, it provides a toggle command, that can be mapped to a key combination, so that you can turn it off, when you don't need it.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-25T06:52:34.060" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12229" PostTypeId="2" ParentId="12225" CreationDate="2017-04-25T07:32:25.913" Score="2" Body="&lt;p&gt;No, there is not. There are however a number of plugins to handle tabs and buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that you want to see tabs per window, my recommendation would be to have a look at &lt;a href=&quot;https://github.com/zefei/vim-wintabs&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-wintabs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XJ46n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XJ46n.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will also show buffers per window in a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a more general note, I would recommend reading &lt;a href=&quot;https://stackoverflow.com/questions/26708822/why-do-vim-experts-prefer-buffers-over-tabs&quot;&gt;this stackoverflow discussion&lt;/a&gt; for an excellent explanation of windows, tabs and buffers and their use in vim.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-04-25T07:32:25.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12230" PostTypeId="2" ParentId="12218" CreationDate="2017-04-25T07:44:43.047" Score="1" Body="&lt;p&gt;In this case i would&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new&#xA;:setlocal buftype=nofile&#xA;:setlocal bufhidden=hide&#xA;:setlocal noswapfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;buftype=nofile&lt;/code&gt; does not associate the buffer with a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;noswapfile&lt;/code&gt; does not create a swapfile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;bufhidden=hide&lt;/code&gt; hides the buffer, when its windows is closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim discards the content in the buffer on exit without warning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you like to clear it before, you can use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#:bwipeout&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:bw&lt;/code&gt;&lt;/a&gt; to wipe the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There also is a &lt;a href=&quot;https://vim.sourceforge.io/scripts/script.php?script_id=664&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt; for that, however, I haven't tried this one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also like to add, that I'm not a security expert, and there conceivably are a number of ways to access that information.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-04-25T07:44:43.047" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12231" PostTypeId="1" AcceptedAnswerId="12304" CreationDate="2017-04-25T15:17:50.883" Score="2" ViewCount="984" Body="&lt;ul&gt;&#xA;&lt;li&gt;Windows 8&lt;/li&gt;&#xA;&lt;li&gt;Vim 8.0.584, 32 bit from &lt;a href=&quot;https://tuxproject.de/projects/vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://tuxproject.de/projects/vim/&lt;/a&gt; .7z archives: x86&lt;/li&gt;&#xA;&lt;li&gt;python36.dll, 32 bit from &lt;a href=&quot;https://www.python.org/ftp/python/3.6.0/python-3.6.0-embed-win32.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.python.org/ftp/python/3.6.0/python-3.6.0-embed-win32.zip&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;copied python36.dll in the directory where vim.exe and gvim.exe are located&lt;/li&gt;&#xA;&lt;li&gt;starting gvim and then testing the python support with :py3 import sys; print(sys.version) gvim crashes without any further information.&lt;/li&gt;&#xA;&lt;li&gt;starting vim and then testing the python support with :py3 import sys; print(sys.version) vim crashes. I can read Fatal python error: Py_Initialize: unable to load the file system codec followed by some unicode chars...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any idea how to fix the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update [ 2017-04-25 - 17:46:07 ]&lt;br&gt;&#xA;also tested with python36.dll from:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;python-3.6.1-embed-win32.zip&lt;/li&gt;&#xA;&lt;li&gt;python-3.6.0b4-embed-win32.zip&lt;/li&gt;&#xA;&lt;li&gt;python-3.6.0b3-embed-win32.zip&lt;/li&gt;&#xA;&lt;li&gt;python-3.6.0b2-embed-win32.zip&lt;/li&gt;&#xA;&lt;li&gt;python-3.6.0b1-embed-win32.zip&lt;/li&gt;&#xA;&lt;li&gt;python-3.6.0a4-embed-win32.zip&lt;/li&gt;&#xA;&lt;li&gt;python-3.6.0a3-embed-win32.zip&lt;/li&gt;&#xA;&lt;li&gt;python-3.6.0a2-embed-win32.zip&lt;/li&gt;&#xA;&lt;li&gt;python-3.6.0a1-embed-win32.zip&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Version output from gvim gathered with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @a&#xA;:version&#xA;:redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and finally pasted with CTRl+r a into my document.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 23 2017 18:46:39)&#xA;MS-Windows 32 Bit GUI Version mit OLE-Unterstützung&#xA;Inklusive der Korrekturen: 1-584&#xA;Übersetzt von hp@HP-PC&#xA;Riesige Version mit GUI. Ein- (+) oder ausschließlich (-) der Eigenschaften:&#xA;+acl                +digraphs           +langmap            -postscript         -termresponse&#xA;+arabic             +directx            +libcall            +printer            +textobjects&#xA;+autocmd            -dnd                +linebreak          +profile            +timers&#xA;+balloon_eval       -ebcdic             +lispindent         +python/dyn         +title&#xA;+browse             +emacs_tags         +listcmds           +python3/dyn        +toolbar&#xA;++builtin_terms     +eval               +localmap           +quickfix           +user_commands&#xA;+byte_offset        +ex_extra           +lua/dyn            +reltime            +vertsplit&#xA;+channel            +extra_search       +menu               +rightleft          +virtualedit&#xA;+cindent            +farsi              +mksession          +ruby/dyn           +visual&#xA;+clientserver       +file_in_path       +modify_fname       +scrollbind         +visualextra&#xA;+clipboard          +find_in_path       +mouse              +signs              +viminfo&#xA;+cmdline_compl      +float              +mouseshape         +smartindent        +vreplace&#xA;+cmdline_hist       +folding            +multi_byte_ime/dyn +startuptime        +wildignore&#xA;+cmdline_info       -footer             +multi_lang         +statusline         +wildmenu&#xA;+comments           +gettext/dyn        +mzscheme/dyn       -sun_workshop       +windows&#xA;+conceal            -hangul_input       +netbeans_intg      +syntax             +writebackup&#xA;+cryptv             +iconv/dyn          +num64              +tag_binary         -xfontset&#xA;+cscope             +insert_expand      +ole                +tag_old_static     -xim&#xA;+cursorbind         +job                +packages           -tag_any_white      +xpm_w32&#xA;+cursorshape        +jumplist           +path_extra         +tcl/dyn            -xterm_save&#xA;+dialog_con_gui     +keymap             +perl/dyn           -termguicolors      &#xA;+diff               +lambda             +persistent_undo    -tgetent            &#xA;          System-vimrc-Datei: &quot;$VIM\vimrc&quot;&#xA;        Benutzer-vimrc-Datei: &quot;$HOME\_vimrc&quot;&#xA; zweite Benutzer-vimrc-Datei: &quot;$HOME\vimfiles\vimrc&quot;&#xA; dritte Benutzer-vimrc-Datei: &quot;$VIM\_vimrc&quot;&#xA;         Benutzer-exrc-Datei: &quot;$HOME\_exrc&quot;&#xA; zweite Benutzer-exrc-Datei: &quot;$VIM\_exrc&quot;&#xA;         System-gvimrc-Datei: &quot;$VIM\gvimrc&quot;&#xA;       Benutzer-gvimrc-Datei: &quot;$HOME\_gvimrc&quot;&#xA;zweite Benutzer-gvimrc-Datei: &quot;$HOME\vimfiles\gvimrc&quot;&#xA;dritte Benutzer-gvimrc-Datei: &quot;$VIM\_gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME\defaults.vim&quot;&#xA;           System-Menü-Datei: &quot;$VIMRUNTIME\menu.vim&quot;&#xA;Übersetzt: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG -DFEAT_JOB_CHANNEL   -DFEAT_XPM_W32   -DWINVER=0x0501 -D_WIN32_WINNT=0x0501  /Fo.\ObjGXOULYHTRZi386/ /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG  /MD -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DGLOBAL_IME -DFEAT_MBYTE -DFEAT_GUI_W32 -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\&quot;tcl86.dll\&quot; -DDYNAMIC_TCL_VER=\&quot;8.6\&quot; -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\&quot;lua53.dll\&quot; -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\&quot;python27.dll\&quot; -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\&quot;python36.dll\&quot; -DFEAT_MZSCHEME -I &quot;C:\Users\hp\Desktop\racket-x86\include&quot; -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\&quot;libracketxxxxxxx.dll\&quot; -DDYNAMIC_MZGC_DLL=\&quot;libmzgcxxxxxxx.dll\&quot; -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\&quot;perl524.dll\&quot; -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=24 -DDYNAMIC_RUBY_DLL=\&quot;msvcrt-ruby240.dll\&quot; -DFEAT_HUGE /Fd.\ObjGXOULYHTRZi386/ /Zi&#xA;Linken: link /RELEASE /nologo /subsystem:windows /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib uuid.lib /machine:i386 gdi32.lib version.lib   winspool.lib comctl32.lib advapi32.lib shell32.lib  /machine:i386  msvcrt.lib oleaut32.lib user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python36.lib   &quot;C:\TCL_x86\lib\tclstub86.lib&quot; WSock32.lib .\xpm\x86\lib-vc14\libXpm.lib /PDB:gvim.pdb -debug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1373" LastEditorUserId="5395" LastEditDate="2017-04-25T19:05:07.393" LastActivityDate="2017-05-04T12:54:12.620" Title="Vim crash with :py3 import sys; print(sys.version)" Tags="|gvim|microsoft-windows|vimscript-python|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12232" PostTypeId="2" ParentId="5864" CreationDate="2017-04-25T17:58:01.533" Score="0" Body="&lt;p&gt;Looks like this is the only solution so far is &lt;a href=&quot;https://github.com/glts/vim-textobj-comment&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-comment&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It conflicts with TComment's plugin which also defines &lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt; map for something useless, so I had to disable that mapping with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tcommentTextObjectInlineComment = ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to stop getting mysterious errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you want to reformat only part of comment (from cursor position to the end of comment or paragraph inside comment - like &lt;kbd&gt;Q&lt;/kbd&gt;&lt;kbd&gt;}&lt;/kbd&gt; does for normal text) you need a &quot;motion&quot; instead of &quot;text object&quot; provided by this plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've created the custom mapping for this. (It contains hardcoded comment marker &lt;code&gt;//&lt;/code&gt; and thus you may need several similar mappings - one per each comment marker you've in your file types.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType go nnoremap &amp;lt;buffer&amp;gt; Q}&#xA;    \ gq/\m\%#.*\(^\s*\/\/.*\)\@&amp;lt;=\(\n\s*\/\/.*\S.*\)*\(\n\s*\)*\ze/e+1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12377" LastEditorUserId="12377" LastEditDate="2017-04-26T09:35:19.673" LastActivityDate="2017-04-26T09:35:19.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12233" PostTypeId="1" CreationDate="2017-04-25T18:41:22.737" Score="3" ViewCount="2729" Body="&lt;p&gt;I'm playing around with &lt;a href=&quot;https://github.com/tonsky/FiraCode&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fira-Code&lt;/a&gt; and am having a weird issue with its ligatures. They seem to only work within the comments and not within my actual code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea what's causing this or how to fix it, suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FvD2g.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FvD2g.png&quot; alt=&quot;example of vim ligatures only working in comments and not code&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;results of &lt;code&gt;gvim --version&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 17 2017 12:13:35)&#xA;Included patches: 1-95&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Huge version with GTK3 GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     +tcl&#xA;+balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;+browse          -footer          +multi_byte      +terminfo&#xA;++builtin_terms  +fork()          +multi_lang      +termresponse&#xA;+byte_offset     +gettext         -mzscheme        +textobjects&#xA;+channel         -hangul_input    +netbeans_intg   +timers&#xA;+cindent         +iconv           +num64           +title&#xA;+clientserver    +insert_expand   +packages        +toolbar&#xA;+clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        +perl            +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       -python          +vreplace&#xA;+cscope          +lispindent      +python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con_gui  +lua             +rightleft       +writebackup&#xA;+diff            +menu            +ruby            +X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;+dnd             +modify_fname    +signs           +xim&#xA;-ebcdic          +mouse           +smartindent     +xpm&#xA;+emacs_tags      +mouseshape      +startuptime     +xsmp_interact&#xA;+eval            +mouse_dec       +statusline      +xterm_clipboard&#xA;+ex_extra        +mouse_gpm       -sun_workshop    -xterm_save&#xA;+extra_search    -mouse_jsbterm   +syntax          &#xA;+farsi           +mouse_netterm   +tag_binary      &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/mirclient -I/usr/include/mircore -I/usr/include/mircookie -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-8krYYf/vim-8.0.0095=. -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.24/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12380" LastActivityDate="2017-04-25T18:41:22.737" Title="Getting ligatures to work outside of comments" Tags="|font|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12234" PostTypeId="2" ParentId="12188" CreationDate="2017-04-25T20:01:35.923" Score="6" Body="&lt;p&gt;StandardEyre's &lt;a href=&quot;https://vi.stackexchange.com/a/12189/2736&quot;&gt;answer&lt;/a&gt; is the most direct answer for the body of your question, but you may also be interested in checking out one (or several) of the many snippet plugins for Vim, such as &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;noreferrer&quot;&gt;Ultisnips&lt;/a&gt;, &lt;a href=&quot;https://github.com/Shougo/neosnippet.vim&quot; rel=&quot;noreferrer&quot;&gt;Neosnippet&lt;/a&gt;, or &lt;a href=&quot;https://github.com/LucHermitte/mu-template&quot; rel=&quot;noreferrer&quot;&gt;muTemplate&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than a command line mode command, they're usually triggered by a short string in insert mode. For example, typing &lt;code&gt;fn&amp;lt;tab&amp;gt;&lt;/code&gt; may expand to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func _() -&amp;gt; void {&#xA;    return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;code&gt;_&lt;/code&gt; being the cursor, in place for the function's name. The snippets can usually be filetype specific and can often take advantage of Vim's auto-completion capabilities. There's a &lt;a href=&quot;https://vi.stackexchange.com/q/7466/2736&quot;&gt;question here&lt;/a&gt; that mentions a few more of these and has feature descriptions of some.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2017-04-25T20:01:35.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12235" PostTypeId="2" ParentId="300" CreationDate="2017-04-26T07:20:20.837" Score="9" Body="&lt;p&gt;I would suggest using my plugin &lt;a href=&quot;https://github.com/zhou13/vim-easyescape/&quot; rel=&quot;noreferrer&quot;&gt;vim-easyescape&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug &quot;zhou13/vim-easyescape&quot;&#xA;let g:easyescape_chars = { &quot;j&quot;: 1, &quot;k&quot;: 1 }&#xA;let g:easyescape_timeout = 100&#xA;cnoremap jk &amp;lt;ESC&amp;gt;&#xA;cnoremap kj &amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with a simple map sequence &lt;code&gt;inoremap jj &amp;lt;ESC&amp;gt;&lt;/code&gt; is that Vim will pause whenever you type &lt;kbd&gt;j&lt;/kbd&gt; or &lt;kbd&gt;k&lt;/kbd&gt; in insert mode (it is waiting for the next key to determine whether to apply the mapping). The pause causes visual distraction which you may or may not notice.  &lt;a href=&quot;https://github.com/zhou13/vim-easyescape/&quot; rel=&quot;noreferrer&quot;&gt;vim-easyescape&lt;/a&gt; does not have such problem and supports custom timeout.&lt;/p&gt;&#xA;" OwnerUserId="12386" LastEditorUserId="5395" LastEditDate="2017-04-26T08:13:38.853" LastActivityDate="2017-04-26T08:13:38.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12237" PostTypeId="1" AcceptedAnswerId="12240" CreationDate="2017-04-26T08:21:13.833" Score="0" ViewCount="325" Body="&lt;p&gt;I have function that prototype is  &lt;code&gt;void customer(void *unusedpointer, unsigned long customernum);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I want to call this function from another file. I write this &lt;code&gt;customer(&lt;/code&gt; but I forget the prototype. I can move the definition of a function using &lt;code&gt;ctags&lt;/code&gt; when it is called perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in this case what can I do when I don't call it yet?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess &lt;code&gt;ctags&lt;/code&gt; has a functionality to do this.&lt;/p&gt;&#xA;" OwnerUserId="9498" LastActivityDate="2017-08-25T02:35:11.283" Title="How can I know function definition in vim for C?" Tags="|ctags|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12238" PostTypeId="1" AcceptedAnswerId="12245" CreationDate="2017-04-26T08:37:47.350" Score="3" ViewCount="3950" Body="&lt;p&gt;I am learning Vim by typing some commands in full rather than using keyboard shortcuts. Is there a tool or plugin that can show me the equivalent shortcuts if they exist, whether they are built in defaults, set by plugins or are user configured?&lt;/p&gt;&#xA;" OwnerUserId="9540" LastActivityDate="2017-04-26T22:09:39.713" Title="Vim tool to show keyboard shortcuts for typed commands?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12239" PostTypeId="1" AcceptedAnswerId="12248" CreationDate="2017-04-26T08:53:25.427" Score="2" ViewCount="1322" Body="&lt;p&gt;I'm trying to improve the &lt;a href=&quot;https://github.com/pboettch/vim-cmake-syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;cmake-syntax-highlighting&lt;/a&gt; for vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm unable to have vim highlight a keyword which is inside a text which is already matching a region. I'm talking about variables:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example &lt;code&gt;CMAKE_SOURCE_DIR&lt;/code&gt; is a built-in variable which is listed in a &lt;code&gt;syn keyword cmakeVariable&lt;/code&gt;-list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When accessing values of a variable in cmake you use &lt;code&gt;${...}&lt;/code&gt;. Highlighting this is done with a region:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region cmakeVariableValue start=/\${/ end=/}/&#xA;        \ contained oneline contains=CONTAINED,cmakeTodo,cmakeVariable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both highlightings work, except when mixed together. Keywords listed in &lt;code&gt;cmakeVariable&lt;/code&gt; are not highlighted specially when being in a &lt;code&gt;${}&lt;/code&gt;-region.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I tell vim to apply special highlighting in a region when a keyword is used?&lt;/p&gt;&#xA;" OwnerUserId="1542" LastActivityDate="2017-04-26T15:59:11.967" Title="How to highlight keywords in a syntax region?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12240" PostTypeId="2" ParentId="12237" CreationDate="2017-04-26T09:01:35.050" Score="2" Body="&lt;p&gt;If you have &lt;code&gt;ctags&lt;/code&gt; installed then save the file(type &lt;code&gt;:w&lt;/code&gt;) and regenerate the ctags by &lt;code&gt;ctags -R filename&lt;/code&gt; then &lt;code&gt;&amp;lt;Ctrl-]&amp;gt;&lt;/code&gt; to go to the function definition.&lt;/p&gt;&#xA;" OwnerUserId="9498" LastEditorUserId="9498" LastEditDate="2017-08-25T02:35:11.283" LastActivityDate="2017-08-25T02:35:11.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12241" PostTypeId="1" AcceptedAnswerId="12243" CreationDate="2017-04-26T12:46:55.820" Score="1" ViewCount="376" Body="&lt;p&gt;I've already configured ctags to index css files like documented here: &lt;a href=&quot;https://github.com/mtscout6/vim-tagbar-css&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-tagbar-css&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also tagbar already works with configuration provided at: &lt;a href=&quot;https://github.com/mtscout6/vim-tagbar-css/blob/master/plugin/tagbar-css.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;tagbar-css.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still CtrlP doesn't show any tags inside of a css file in &quot;buffer tags&quot; mode.&#xA;Other files like PHP are working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where can I find more information to make it work, or how can I make it work?&lt;/p&gt;&#xA;" OwnerUserId="5749" LastEditorUserId="5395" LastEditDate="2017-04-26T13:10:11.693" LastActivityDate="2017-04-27T10:20:18.770" Title="How to use ctrlp in conjunction with css and ctags" Tags="|ctags|plugin-ctrlp|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12243" PostTypeId="2" ParentId="12241" CreationDate="2017-04-26T13:43:09.460" Score="1" Body="&lt;p&gt;All I had to do was to configure the css type for ctrlp to complete the ctags kinds, as mentioned in the docs, thanks @grodzik:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_buftag_types = {&#xA;\ 'css' : '--css-types=vcitm',&#xA;\ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This configures to complete the ctags kinds &quot;v&quot;, &quot;c&quot;, &quot;i&quot;, &quot;t&quot; and &quot;m&quot;,&#xA;They are configured in ctags:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--langmap=css:.css.less.scss&#xA;--regex-css=/^[ \t]*@([A-Za-z0-9_-]+)/@\1/v,var,variables/&#xA;--regex-css=/^[ \t]*\.([A-Za-z0-9_-]+)/.\1/c,class,classes/&#xA;--regex-css=/^[ \t]*#([A-Za-z0-9_-]+)/#\1/i,id,ids/&#xA;--regex-css=/^[ \t]*(([A-Za-z0-9_-]+[ \t\n,]+)+)\{/\1/t,tag,tags/&#xA;--regex-css=/^[ \t]*@media\s+([A-Za-z0-9_-]+)/\1/m,media,medias/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As already mentioned in the question.&lt;/p&gt;&#xA;" OwnerUserId="5749" LastEditorUserId="5749" LastEditDate="2017-04-27T10:20:18.770" LastActivityDate="2017-04-27T10:20:18.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12244" PostTypeId="1" AcceptedAnswerId="12246" CreationDate="2017-04-26T13:59:26.633" Score="3" ViewCount="415" Body="&lt;p&gt;I use abbreviations extensively to make writing in languages other than English easier. For example, I have something like this set up for when I'm writing in Italian:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoreabbrev perche' perché&#xA;inoreabbrev dopodiche' dopodiché&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way I can type the words above quickly without changing keyboard layout system-wide or using digraphs. Sadly these abbreviations don't work when the word is capitalized, like when it comes after a period.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to way to force an abbreviation to trigger regardless of the case? Do I have to set up 2 abbreviations for every word or is there another way, like regexes or a special option?&lt;/p&gt;&#xA;" OwnerUserId="3079" LastActivityDate="2017-04-26T15:25:27.030" Title="Case-insensitive abbreviations" Tags="|insert-mode|abbreviations|word-processing|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12245" PostTypeId="2" ParentId="12238" CreationDate="2017-04-26T14:02:15.333" Score="4" Body="&lt;p&gt;&lt;strong&gt;Shows built-in abbreviations for command &lt;em&gt;quit&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :quit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Outputs:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:q[uit]   Quit the current window.  Quit Vim if this is the last&#xA;          window.  This fails when changes have been made and&#xA;          ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The square brackets indicate the unnecessary characters for the command.  Any of the following are equivilant to &lt;code&gt;quit&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:q&#xA;:qu&#xA;:qui&#xA;:quit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can even abbreviate the command you are getting help for. For example &lt;code&gt;:h :q&lt;/code&gt; gets help for quit&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Shows mapped shortcuts&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Shows mapped shortcuts for a specific mode&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap&#xA;:nmap&#xA;:cmap&#xA;etc...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Shows abbreviations&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:abbr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Finds all mappings associated with a command&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to find all mappings that use &lt;code&gt;:call&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new&#xA;:redir @a&#xA;:map&#xA;:redir END&#xA;:put a&#xA;/:call&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Explanation:  create a new buffer, redirect output to register a, list all mappings, finish redirect, paste register a, search for your command&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Shows purely built-in mappings&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE&#xA;:map&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Shows user customizations&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Show plug-ins&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:scriptnames&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;anything not a built-in or user customization could be from one of the plugins.  You could grep the files in scriptnames for your command&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm by no means a vi expert. I'm certain there are many other ways to get the information you want.  This is just how I would go about it.&lt;/p&gt;&#xA;" OwnerUserId="12113" LastEditorUserId="12113" LastEditDate="2017-04-26T22:09:39.713" LastActivityDate="2017-04-26T22:09:39.713" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12246" PostTypeId="2" ParentId="12244" CreationDate="2017-04-26T14:17:07.893" Score="5" Body="&lt;p&gt;You could use the &lt;a href=&quot;https://github.com/tpope/vim-abolish/&quot; rel=&quot;noreferrer&quot;&gt;abolish plugin&lt;/a&gt;. For your example you could use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Abolish perche{'} perché&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It changes &lt;code&gt;perche'&lt;/code&gt; to &lt;code&gt;perché&lt;/code&gt;, &lt;code&gt;Perche'&lt;/code&gt; to &lt;code&gt;Perché&lt;/code&gt; and &lt;code&gt;PERCHE'&lt;/code&gt; to &lt;code&gt;PERCHÉ&lt;/code&gt;. For the second example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Abolish dopodiche{'} dopodiché&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2017-04-26T14:17:07.893" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12247" PostTypeId="2" ParentId="12244" CreationDate="2017-04-26T15:25:27.030" Score="0" Body="&lt;p&gt;I would have written an  &lt;code&gt;imap-&amp;lt;expr&amp;gt;&lt;/code&gt; on &lt;code&gt;'&lt;/code&gt; that tests the previous character, &lt;code&gt;e&lt;/code&gt; and &lt;code&gt;E&lt;/code&gt; would become &lt;code&gt;é&lt;/code&gt; and &lt;code&gt;É&lt;/code&gt;. And so on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The caveat being when writing source code where &lt;code&gt;'&lt;/code&gt; is a valid character on its own, and where we could have a single-quote after an &lt;code&gt;e&lt;/code&gt;. We could check the current syntax in that case.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:compose_if_match(accent, letters)&#xA;  let crt = getline('.')[col('.')-2]&#xA;  if crt =~? a:letters&#xA;    return &quot;\&amp;lt;bs&amp;gt;\&amp;lt;c-k&amp;gt;&quot;.a:accent.crt&#xA;  else&#xA;    return a:accent&#xA;  endif&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; ' &amp;lt;sid&amp;gt;compose_if_match(&quot;'&quot;, 'e')&#xA;inoremap &amp;lt;expr&amp;gt; ` &amp;lt;sid&amp;gt;compose_if_match(&quot;`&quot;, '[aeu]')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Honnestly, unless I don't have a French keyboard, instead of retro-actively fixing words automagically thanks to quotes and backticks, I'd rather hit backspace and fix the word by hitting the proper key which is also on the first row. I would understand that using &lt;code&gt;CTRL+K&lt;/code&gt; on non-French keyboards is tiresome.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-04-26T15:25:27.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12248" PostTypeId="2" ParentId="12239" CreationDate="2017-04-26T15:59:11.967" Score="2" Body="&lt;p&gt;You need to use the &lt;code&gt;contained&lt;/code&gt; argument in your keyword definition. Here's a random snippet that works for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax keyword toBeContained contained foo bar&#xA;syntax region fooRegion start=&quot;{&quot; end=&quot;}&quot; contains=toBeContained&#xA;&#xA;hi toBeContained ctermfg=51 guifg=cyan&#xA;hi fooRegion ctermfg=30 guifg=darkcyan&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: This will make keyword &lt;code&gt;toBeContained&lt;/code&gt; &lt;strong&gt;not&lt;/strong&gt; work when it's not in a region that contains it. So you might need to make two definitions, one with &lt;code&gt;contained&lt;/code&gt; and one without.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend &lt;a href=&quot;http://vim.wikia.com/wiki/Creating_your_own_syntax_files&quot; rel=&quot;nofollow noreferrer&quot;&gt;this great tutorial on creating syntax files&lt;/a&gt;, as well as &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-keyword&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :syn-keyword&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-04-26T15:59:11.967" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12249" PostTypeId="1" CreationDate="2017-04-26T18:52:02.607" Score="1" ViewCount="77" Body="&lt;p&gt;In general I can programmatically detect the active mode on a vim instance using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --remote-expr 'mode(1)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when vim is in debugger mode (i.e., it has hit a breakpoint placed via &lt;code&gt;:breakadd&lt;/code&gt;), it seems to just return &lt;code&gt;c&lt;/code&gt; (Command-line mode) instead of identifying the mode as a debug prompt. Is there some other way I can detect debug prompt?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Context: For software that instruments vim like &lt;a href=&quot;https://github.com/google/vroom&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/google/vroom&lt;/a&gt;, it would be useful to be able to handle debug mode specially instead of assuming vim is &quot;stuck&quot;.&lt;/p&gt;&#xA;" OwnerUserId="824" LastActivityDate="2017-04-26T18:52:02.607" Title="Can I detect vim is in debugger mode through --remote-expr?" Tags="|clientserver|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12250" PostTypeId="1" AcceptedAnswerId="12289" CreationDate="2017-04-26T20:09:10.773" Score="2" ViewCount="1136" Body="&lt;p&gt;Is there a tool or plugin for a learner which can display the keyboard shortcuts or abbreviated versions for commands after they are typed in?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If for instance I use &lt;code&gt;:&lt;/code&gt; to get the command line and execute &lt;code&gt;:tabnew&lt;/code&gt; the plugin should display whatever keyboard shortcut that is bound to that command for a few seconds or until the next command is typed in.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take this question - &lt;a href=&quot;https://stackoverflow.com/questions/6467634&quot;&gt;https://stackoverflow.com/questions/6467634&lt;/a&gt;, the author wants to set a shortcut for the &lt;code&gt;NERDTree&lt;/code&gt; command. I am not interested in using the shortcut itself. I want to type &lt;code&gt;:NERDTree&lt;/code&gt; itself and get a notification that &lt;code&gt;,ne&lt;/code&gt; has been mapped to it. I don't want to break my workflow to look up the shortcut, ie I don't want to lookup the key mapping before hand, just to know it and use it if I find it convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming I am sitting at someone else desktop with their own customizations, to get a job done. It is not really practical for me to lookup their shortcuts when I know the full commands. I just use the full command and if the notification shows me that their customization is convenient for me then I use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should work whether they are built in defaults, set by plugins or are user configured, or even if the commands have multiple alternatives.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question is about a plugin which displays keyboard equivalents of commands typed in the command line, in realtime. &lt;strong&gt;It is meant to show the keyboard shortcut for a command after it has been used.&lt;/strong&gt; It is not to lookup the keymapping for that command.&lt;/p&gt;&#xA;" OwnerUserId="9540" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-05-02T20:29:59.347" Title="Is there Vim plugin that can show keystroke maps or abbreviations for command after it is used?" Tags="|key-bindings|plugin-system|" AnswerCount="1" CommentCount="10" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12251" PostTypeId="1" AcceptedAnswerId="12254" CreationDate="2017-04-26T21:59:00.773" Score="3" ViewCount="570" Body="&lt;p&gt;I am editing a non-standard file of Vim settings and the file has no syntax highlighting because Vim is not aware that the file contains settngs for itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg - These lines are not highlighted by Vim because it doesn't know that they are vim settings although the man &lt;code&gt;.vimrc&lt;/code&gt; file is syntax-highlighted appropriately&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vimscript prettyprint-override&quot;&gt;&lt;code&gt;&quot; Highlight trailing spaces so/4617059&#xA;:highlight ExtraWhitespace ctermbg=red guibg=red&#xA;:match ExtraWhitespace /\s\+$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there some way to let Vim be aware that the file has Vim settings?&lt;/p&gt;&#xA;" OwnerUserId="9540" LastEditorUserId="9540" LastEditDate="2017-04-27T06:19:22.720" LastActivityDate="2017-04-27T07:31:48.460" Title="What options make Vim aware that the file editing is for vim settings?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12252" PostTypeId="1" AcceptedAnswerId="12253" CreationDate="2017-04-26T22:31:59.100" Score="2" ViewCount="2665" Body="&lt;p&gt;I want to create a file that has X number of entries where each entry has incremental numbers for Y. I tried recording a macro that would copy the 3 lines then edit the value but it ended up editing the wrong lines. Is a vim macro the correct way of doing this or is there another special way to duplicate lines and increment their numbers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize I could just write a simple programming script that would print out this but I was already editing the file in vim and thought vim is powerful I should figure this out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Values for&lt;br&gt;&#xA;Y = 1-30  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;entry 100/1/Y&#xA;  fields value Y&#xA;  other section Y is valid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results would be a multiline file that is as followed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;entry 100/1/1&#xA;  fields value 1&#xA;  other section 1 is valid&#xA;...&#xA;entry 100/1/30&#xA;  fields value 30&#xA;  other section 30 is valid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12402" LastActivityDate="2017-04-26T22:48:43.470" Title="Repeating multi-lines and increment numbers in specific sections?" Tags="|macro|multiple-lines|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12253" PostTypeId="2" ParentId="12252" CreationDate="2017-04-26T22:42:45.770" Score="5" Body="&lt;p&gt;A macro is certainly capable of doing this. Starting with the first three lines as a template&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;entry 100/1/1&#xA;  fields value 1&#xA;  other section 1 is valid &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Place your cursor on the first line and execute: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;qqy2&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;code&gt;jjo&lt;/code&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;code&gt;p$&lt;/code&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;code&gt;j&lt;/code&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;code&gt;j&lt;/code&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;code&gt;kk0q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; Start a macro in register &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;y2&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; Yank three lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;jjo&lt;/code&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;code&gt;p&lt;/code&gt; Copy the lines below inserting an extra blank line in-between.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;code&gt;j&lt;/code&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;code&gt;j&lt;/code&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; Using vim's auto-increment function, increment the three numbers.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;kk0&lt;/code&gt; Set up the cursor for the next macro.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; Stop recording the macro.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now you can symply do &lt;code&gt;@q&lt;/code&gt; however many times you want to repeat the macro. Or you can also do &lt;code&gt;30@q&lt;/code&gt; to repeat it 30 times.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-04-26T22:48:43.470" LastActivityDate="2017-04-26T22:48:43.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12254" PostTypeId="2" ParentId="12251" CreationDate="2017-04-27T06:35:38.750" Score="7" Body="&lt;p&gt;First, you need to enable syntax highlighting and filetype plugins. Ensure that you have these lines in your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With that, it should suffice to use the &lt;code&gt;.vim&lt;/code&gt; extension in the filename, e.g. &lt;code&gt;extra_settings.vim&lt;/code&gt;. Alternatively, you can name the file something that contains the word &lt;code&gt;vimrc&lt;/code&gt;, e.g. &lt;code&gt;extra_vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have &lt;code&gt;modeline&lt;/code&gt; enabled, then you can also use a comment at the top or bottom of the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim: ft=vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h modeline&lt;/code&gt;. Note that there are two forms. The one above is of the first form, which should not contain the keyword &lt;code&gt;set&lt;/code&gt;.implied to be &lt;code&gt;set&lt;/code&gt;able options.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2017-04-27T07:31:48.460" LastActivityDate="2017-04-27T07:31:48.460" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12255" PostTypeId="1" CreationDate="2017-04-27T07:21:31.727" Score="0" ViewCount="705" Body="&lt;p&gt;I'm just new to vim script, and I want to make gVim width auto adjust when open/close vimfiler or tagbar window.&lt;/p&gt;&#xA;&lt;p&gt;Here's my &lt;em&gt;not working&lt;/em&gt; Vim script:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:window_raw_width = 90&#xA;let g:window_width = g:window_raw_width&#xA;&#xA;function adjust_tagbar_width()&#xA;    if (g:window_width == g:window_raw_width)&#xA;        g:window_width = g:window_raw_width + 40&#xA;        &#xA;    else&#xA;        g:window_width = g:window_raw_width&#xA;    endif&#xA;    set lines=g:window_width&#xA;endfunction&#xA;&#xA;nmap &amp;lt;F9&amp;gt; :TagbarToggle&amp;lt;cr&amp;gt;&#xA;autocmd VimEnter,BufNewFile,BufRead * nested :TagbarToggle&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6600" LastEditorUserId="23502" LastEditDate="2023-07-04T14:13:26.223" LastActivityDate="2023-07-04T14:13:26.223" Title="How to change gVim width when open/close vimfiler or tagbar?" Tags="|plugin-tagbar|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="12256" PostTypeId="1" CreationDate="2017-04-27T11:59:40.660" Score="3" ViewCount="3878" Body="&lt;p&gt;I want to have a macro in my &lt;code&gt;.vimrc&lt;/code&gt; which when activated will enter a command and execute it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @r = ':e!' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but instead of it just being entered in the command line I want it executed.&lt;/p&gt;&#xA;" OwnerUserId="12407" LastEditorUserId="51" LastEditDate="2017-04-27T13:49:23.173" LastActivityDate="2022-10-03T16:19:38.837" Title="How to create a macro in .vimrc which automatically uses enter" Tags="|macro|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12257" PostTypeId="2" ParentId="12256" CreationDate="2017-04-27T12:28:31.193" Score="3" Body="&lt;p&gt;Before ending &lt;code&gt;'&lt;/code&gt; sign, press combination &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; followed by &lt;kbd&gt;Enter&lt;/kbd&gt;. This will insert Enter code represented by &lt;code&gt;^M&lt;/code&gt; sign, which will as you would have pressed &lt;kbd&gt;Enter&lt;/kbd&gt; yourself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should get something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @r = ':e!^M' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-04-27T12:28:31.193" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12258" PostTypeId="1" CreationDate="2017-04-27T15:37:14.293" Score="1" ViewCount="1019" Body="&lt;p&gt;In nerdtree as we go deeper filenames are hidden due to smaller width of tree window. Is there a fix to show full filename over the window which is currently highlighted in tree?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bV7gf.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bV7gf.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12411" LastActivityDate="2017-04-28T08:56:48.577" Title="Nerd tree show full filename" Tags="|plugin-nerdtree|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12259" PostTypeId="2" ParentId="12256" CreationDate="2017-04-27T22:41:16.040" Score="-1" Body="&lt;p&gt;&lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; (Carriage Return) inside a mapping or a command will expand to an Enter keystroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your mapping then would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @r = ':e!&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2017-04-27T22:41:16.040" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12260" PostTypeId="2" ParentId="12256" CreationDate="2017-04-28T07:43:19.970" Score="5" Body="&lt;p&gt;Your goal is to insert a literal &lt;code&gt;^M&lt;/code&gt; character. You have two options: You can use digraphs (&lt;code&gt;:h digraphs&lt;/code&gt;), or the &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; shortcut (&lt;code&gt;:h i_CTRL-v&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Digraphs&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Digraphs are a way to enter hard-to-reach characters, like accented letters or special keys. If you look at the listing in &lt;code&gt;:digraphs&lt;/code&gt;, you will see that &lt;strong&gt;CR&lt;/strong&gt; is the shortcut you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To enter a digraph, press &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; followed by the digraph letters. In this case, it would be &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; - &lt;kbd&gt;C&lt;/kbd&gt;&lt;kbd&gt;R&lt;/kbd&gt; (note the uppercase, it's significant).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Ctrl-v&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; will &quot;insert next non-digit literally&quot;. You can either press &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; - &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;m&lt;/kbd&gt;, or &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; - &lt;kbd&gt;Enter&lt;/kbd&gt; &amp;ndash; both will result in &lt;code&gt;^M&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12421" LastActivityDate="2017-04-28T07:43:19.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12262" PostTypeId="1" AcceptedAnswerId="12269" CreationDate="2017-04-28T09:33:16.410" Score="0" ViewCount="243" Body="&lt;p&gt;I have a mapping to remove trailing whitespace, defined like this: &lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;F6&amp;gt; :%s/\s\+$//&amp;lt;CR&amp;gt;''&lt;/code&gt;. It works fine, except that if I press &lt;kbd&gt;Esc&lt;/kbd&gt; before pressing &lt;kbd&gt;F6&lt;/kbd&gt;, instead of doing what it should it seems to do &lt;kbd&gt;~&lt;/kbd&gt;(switch case for character) for a bunch of characters where the cursor is placed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I prevent that from happening?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 1:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm on Arch Linux latest updates as of 2017-04-28 with Vim 8.0, running in gnome-terminal. It's the same on all systems I've tested, but it's worth noting that I'm on a Swedish keyboard layout (EDIT: Just tested, and it's the same on en_US layout for me).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've narrowed it down some. While F1–F4 are caught by my terminal (so can't say anything there), F5 produces 5 characters to switch case, F6 produces 7 characters to switch, F7 does 8 and F8 does 9. I've tried disabling my &lt;code&gt;.vimrc&lt;/code&gt;, and that fixes the problem. I'll search through the config and report back when I find what caused it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 3:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remove my .vimrc, Vi does it but Vim does not. What does that mean?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 4, major finding:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I've found the line in my config that causes it. It's &lt;code&gt;noremap &amp;lt;Esc&amp;gt;&amp;lt;Esc&amp;gt; :noh&amp;lt;CR&amp;gt;&lt;/code&gt;. Still don't understand why, though. :/&lt;/p&gt;&#xA;" OwnerUserId="2082" LastEditorUserId="2082" LastEditDate="2017-04-28T17:52:49.123" LastActivityDate="2017-04-28T18:30:16.470" Title="Prohibit unintentional ~ from F6 button" Tags="|key-bindings|letter-case|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12263" PostTypeId="1" CreationDate="2017-04-28T09:59:41.633" Score="2" ViewCount="238" Body="&lt;p&gt;I want a file that contain only 1 and 0 for my java networking program.&#xA;Writing a big file containing only 1 and 0 is boring. So, if vim do this, it is better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know that it is whether possible or not, but I guess it is possible in vim. &lt;/p&gt;&#xA;" OwnerUserId="9498" LastActivityDate="2017-04-28T15:14:28.613" Title="How to write 1 or 0(binary string) randomly in a file using vim?" Tags="|text-generation|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12264" PostTypeId="2" ParentId="12263" CreationDate="2017-04-28T10:21:17.070" Score="0" Body="&lt;p&gt;One way to do this is to use &lt;code&gt;system('echo $RANDOM')&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyGenerator(iter)&#xA;  let s = &quot;&quot;&#xA;  for k in range(a:iter)&#xA;    let s .= string(system('echo $RANDOM')%2)&#xA;  endfor&#xA;  execute &quot;normal! a&quot;.s&#xA;endfunc&#xA;&#xA;command -nargs=1 Generate01 :call MyGenerator(&amp;lt;args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this in your &lt;code&gt;.vimrc&lt;/code&gt; all you need to do is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Generate01 1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(or whatever value you want instead of 1000)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's quite time consuming for large values, though - but still much faster than typing by hand ;)&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2017-04-28T11:34:08.953" LastActivityDate="2017-04-28T11:34:08.953" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12265" PostTypeId="1" CreationDate="2017-04-28T11:10:06.520" Score="1" ViewCount="61" Body="&lt;p&gt;I want to know how to find the default copy register on any machine. I &lt;code&gt;ssh&lt;/code&gt; into different machines and use vi. But on some of them the &lt;code&gt;&quot;+&lt;/code&gt; and/or &lt;code&gt;&quot;*&lt;/code&gt; registers don't work. Also when I can use my mouse I can mark text and copy it with &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt; while that doesn't work in my own vi.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vi scp&lt;/code&gt; isn't ideal because I want to look around the machines and occasionally copy some details. I don't want to have to first &lt;code&gt;ssh&lt;/code&gt; into the machine find out the file's location and to then use &lt;code&gt;scp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also would it be possible to copy the remote machine's copy register onto my local machine's copy register?&lt;/p&gt;&#xA;" OwnerUserId="12408" LastEditorUserId="5395" LastEditDate="2017-04-28T11:26:40.230" LastActivityDate="2017-04-28T11:26:40.230" Title="How to find out the default system copy register?" Tags="|cut-copy-paste|register|linux|ssh|" AnswerCount="0" CommentCount="2" ClosedDate="2017-04-30T23:16:21.013" ContentLicense="CC BY-SA 3.0" />
  <row Id="12266" PostTypeId="2" ParentId="12263" CreationDate="2017-04-28T14:13:53.683" Score="1" Body="&lt;p&gt;Vim does not have built-in support for randomness. However, if you have Python support, you can use this quick one-liner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.pydo n=5; import random; return ''.join([random.choice(['0', '1']) for x in range(n)])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;It will replace the current line with &lt;em&gt;n&lt;/em&gt; 1s and 0s.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Change &lt;code&gt;n=5&lt;/code&gt; to the number of characters you want.&lt;/li&gt;&#xA;&lt;li&gt;Change &lt;code&gt;.&lt;/code&gt; to another line range if you want more than one line. Removing the dot will change &lt;em&gt;all&lt;/em&gt; lines.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help :pydo&lt;/code&gt; for details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See @grodzik's answer if you don't have Python support but are on a Unix-like system.&lt;/p&gt;&#xA;" OwnerUserId="12421" LastActivityDate="2017-04-28T14:13:53.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12267" PostTypeId="2" ParentId="12263" CreationDate="2017-04-28T15:14:28.613" Score="4" Body="&lt;p&gt;To use a purely vimscript solution you can use some functions I described in&#xA;&lt;a href=&quot;https://vi.stackexchange.com/a/9845/1841&quot;&gt;another answer&lt;/a&gt; of mine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Randomization Variables&#xA;&quot; with a little extra randomized start from localtime()&#xA;let g:rndm_m1 = 32007779 + (localtime()%100 - 50)&#xA;let g:rndm_m2 = 23717810 + (localtime()/86400)%100&#xA;let g:rndm_m3 = 52636370 + (localtime()/3600)%100&#xA;&#xA;function! Rndm()&#xA;    let m4= g:rndm_m1 + g:rndm_m2 + g:rndm_m3&#xA;    if( g:rndm_m2 &amp;lt; 50000000 )&#xA;        let m4= m4 + 1357&#xA;    endif&#xA;    if( m4 &amp;gt;= 100000000 )&#xA;        let m4= m4 - 100000000&#xA;        if( m4 &amp;gt;= 100000000 )&#xA;            let m4= m4 - 100000000&#xA;        endif&#xA;    endif&#xA;    let g:rndm_m1 = g:rndm_m2&#xA;    let g:rndm_m2 = g:rndm_m3&#xA;    let g:rndm_m3 = m4&#xA;    return g:rndm_m3&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once you added these function to your &lt;code&gt;.vimrc&lt;/code&gt; you can also add the following&#xA;one. It is take the length of the desired string as argument and put the string&#xA;in your unamed register. This way you can simply paste it whereever you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Random01(length)&#xA;    let s=''&#xA;    while len(s) &amp;lt; a:length&#xA;        let s .= Rndm()%2&#xA;    endwhile&#xA;&#xA;    call setreg('&quot;', s, 'v')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can do &lt;code&gt;:call Random01(30)&lt;/code&gt; to generate a string of 30 zeros and ones&#xA;and simply add it to your buffer with p. On my machine &lt;code&gt;:call Random01(100000)&lt;/code&gt; is almost instantaneous.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this function I put the string in a register but you can of course use it as in the other answers too.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-04-28T15:14:28.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12268" PostTypeId="2" ParentId="12262" CreationDate="2017-04-28T17:20:31.570" Score="0" Body="&lt;p&gt;Granted that I am running nvim and use Terminator, but for the very same purpose as described above I use: &lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;F5&amp;gt; :let _s=@/&amp;lt;Bar&amp;gt;:%s/\s\+$//e&amp;lt;Bar&amp;gt;:let @/=_s&amp;lt;Bar&amp;gt;:nohl&amp;lt;CR&amp;gt;&lt;/code&gt;. In order to isolate the matter I created a new .vimrc and added only the aforementioned line to the file. With both nvim (0.1.7) and Vim (8.0) I get the expected behavior (white space at end of line eliminated) and no characters changes case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I changed to gnome-terminal, and the same appears there (i.e. everything work as expected).&lt;/p&gt;&#xA;" OwnerUserId="12424" LastActivityDate="2017-04-28T17:20:31.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12269" PostTypeId="2" ParentId="12262" CreationDate="2017-04-28T17:57:16.940" Score="1" Body="&lt;p&gt;The issue is caused by the line &lt;code&gt;nnoremap &amp;lt;Esc&amp;gt;&amp;lt;Esc&amp;gt; :noh&amp;lt;CR&amp;gt;&lt;/code&gt;, and can be fixed by changing it to &lt;code&gt;nnoremap &amp;lt;Esc&amp;gt;a :noh&amp;lt;CR&amp;gt;&lt;/code&gt; or some other regular character instead of Esc. No idea why though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;code&gt;nvim&lt;/code&gt; seems to deal with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; in the correct way.&lt;/p&gt;&#xA;" OwnerUserId="2082" LastEditorUserId="2082" LastEditDate="2017-04-28T18:30:16.470" LastActivityDate="2017-04-28T18:30:16.470" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12271" PostTypeId="1" CreationDate="2017-04-29T11:27:36.123" Score="4" ViewCount="2270" Body="&lt;p&gt;I don't mind keeping the original mapping, I just want to bind it to something more convenient, so instead of typing &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;)&lt;/kbd&gt;, I could for example do it with &lt;kbd&gt;Alt&lt;/kbd&gt;&lt;kbd&gt;(&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried just adding &lt;code&gt;nnoremap &amp;lt;M-(&amp;gt; ysiw)&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt;, but that did nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use gVim 8,&#xA;thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="12435" LastEditorUserId="51" LastEditDate="2017-04-30T23:13:45.247" LastActivityDate="2017-05-01T14:15:58.750" Title="How can I change mapping for vim-surround plugin?" Tags="|key-bindings|plugin-vim-surround|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12272" PostTypeId="2" ParentId="12271" CreationDate="2017-04-29T20:06:28.367" Score="3" Body="&lt;p&gt;First of all, you need to use &lt;code&gt;nmap&lt;/code&gt;, not &lt;code&gt;nnoremap&lt;/code&gt;, since &lt;code&gt;s&lt;/code&gt; is already a mapping from &lt;code&gt;Surround&lt;/code&gt; plugin. &lt;code&gt;nmap&lt;/code&gt; scans right side for further mappings - see &lt;code&gt;:h :nmap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As of notation &lt;code&gt;&amp;lt;M-(&amp;gt;&lt;/code&gt; - I'm not sure if it's correct. I would do it as follows (and I actually tested it like so) - while editing your &lt;code&gt;.vimrc&lt;/code&gt; in gVim in place of &lt;code&gt;&amp;lt;M-(&amp;gt;&lt;/code&gt; press &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; and then your combination &lt;kbd&gt;Alt&lt;/kbd&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;9&lt;/kbd&gt; - this will insert actual key code. It should look like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap ¹ ysiw)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-04-29T20:06:28.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12274" PostTypeId="1" AcceptedAnswerId="12277" CreationDate="2017-04-30T18:47:44.347" Score="0" ViewCount="275" Body="&lt;p&gt;We know that pressing 'K' will trigger the manual page for the underlying language. I am writing a syntax file for a language, and the document is online only. So I would like to know&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How do I react to 'K'?&lt;/li&gt;&#xA;&lt;li&gt;How do I, rather than calling &quot;man&quot; on that keyword, pop up a new browser window and open the given page?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="8820" LastActivityDate="2017-04-30T21:43:35.273" Title="Use &quot;K&quot; on a custom language" Tags="|key-bindings|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12275" PostTypeId="1" AcceptedAnswerId="12278" CreationDate="2017-04-30T19:55:01.733" Score="9" ViewCount="1532" Body="&lt;p&gt;The standard &lt;code&gt;CTRL-E&lt;/code&gt; works to go to the end of the line but &lt;code&gt;CTRL-A&lt;/code&gt; doesn't seem to work to go to the beginnig.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would obviously be useful to quickly go to the beginning of line for example if one wanted to replace &lt;code&gt;w /path/to/file&lt;/code&gt; in with &lt;code&gt;w! /path/to/file&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a key to go to the beginning of the line in command mode and if so how does one map it to &lt;code&gt;CTRL-A&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10669" LastActivityDate="2017-04-30T22:55:27.533" Title="How to go back to beginning of the line in (ex) command mode?" Tags="|ex-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12276" PostTypeId="1" AcceptedAnswerId="12279" CreationDate="2017-04-30T20:32:08.317" Score="2" ViewCount="59" Body="&lt;p&gt;First of, I am sure there are plugins that will do what I am trying to achieve but I am using this as an exercise to learn vim as I am still quite new so I am not really interested in plugin suggestions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to build a command that will pope the current line of my buffer through Pandoc and replace the line with the output.  This would allow me to, for example, have the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Title&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;turn into &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Title&amp;lt;/h1&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in an html document.  In time I would like it to output different text based on the buffer's file type but for now I am focusing on html.  This is what I have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe &quot;read !echo &quot; . getline('.') &quot; | pandoc -t html&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am aware that at the moment this won't replace the current line but that is intentional whilst I'm debugging&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With my cursor on the line &lt;code&gt;#test&lt;/code&gt;, I got the following added to the line below it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;p&amp;gt;exetest&amp;lt;/p&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It appears to me that the &lt;code&gt;#&lt;/code&gt; is being converted to &lt;code&gt;exe&lt;/code&gt; before it is piped into pandoc.  Could you please tell me why this is and how to fix it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance &lt;/p&gt;&#xA;" OwnerUserId="12323" LastEditorUserId="51" LastEditDate="2017-04-30T23:08:02.230" LastActivityDate="2017-05-02T08:41:01.283" Title="# turning to exe when running terminal command" Tags="|command-line|external-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12277" PostTypeId="2" ParentId="12274" CreationDate="2017-04-30T21:43:35.273" Score="8" Body="&lt;p&gt;Pressing &lt;kbd&gt;K&lt;/kbd&gt; runs the program given by &lt;code&gt;keywordprg&lt;/code&gt; (kp).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do &lt;code&gt;:set keywordprg?&lt;/code&gt; it should reply &lt;code&gt;keywordprg=man&lt;/code&gt; by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So simply set &lt;code&gt;keywordprg&lt;/code&gt; to a program of choice, which will get the language name as input. Check if the language is the one you want and fire it up in the browser, otherwise call &lt;code&gt;man&lt;/code&gt; on the input as usual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help K&lt;/code&gt; tells you this and more&lt;/p&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2017-04-30T21:43:35.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12278" PostTypeId="2" ParentId="12275" CreationDate="2017-04-30T22:55:27.533" Score="12" Body="&lt;p&gt;You can use &lt;code&gt;&amp;lt;C-b&amp;gt;&lt;/code&gt; to go to the beginning of the line; from &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-B&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help c_CTRL-B&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-B or &amp;lt;Home&amp;gt;                                c_CTRL-B c_&amp;lt;Home&amp;gt; c_Home&#xA;                cursor to beginning of command-line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want, you can use this to map it to &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cnoremap &amp;lt;C-a&amp;gt; &amp;lt;C-b&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Related: &lt;a href=&quot;https://vi.stackexchange.com/q/6040/51&quot;&gt;How can I use Readline shortcuts in the vim command line?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-04-30T22:55:27.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12279" PostTypeId="2" ParentId="12276" CreationDate="2017-04-30T23:07:52.293" Score="5" Body="&lt;p&gt;The problem with your command is that you're constructing a piece of Vimscript with constructs a piece of shell script. Both require some careful handling to take care of &quot;special&quot; characters such as &lt;code&gt;#&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;read !echo &quot; . shellescape(escape(getline('.'), '#%')) &quot; | pandoc -t html&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This still won't cover all the cases, though, and I wouldn't recommend using it. If you want to add a new line with the output below the current one, then a better way is probably:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call append('.', systemlist('pandoc -t html', getline('.')))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This avoids having to escape Vimscript because you're not building the command with &lt;code&gt;exe&lt;/code&gt;, and the second argument to &lt;code&gt;systemlist()&lt;/code&gt; is passed as the command's stdin, so you avoid shell escaping with that as well!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also use a motion with &lt;code&gt;!&lt;/code&gt;; the &lt;code&gt;.&lt;/code&gt; motion is the current line so this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.!pandoc -t html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will replace the current line with the output of pandoc.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-05-02T08:41:01.283" LastActivityDate="2017-05-02T08:41:01.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12280" PostTypeId="1" AcceptedAnswerId="12282" CreationDate="2017-05-01T08:04:21.640" Score="1" ViewCount="113" Body="&lt;p&gt;I would like to do a check like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if system($(uname -m | sed 's/x86_//;s/i[3-6]86/32/') == 64&#xA;    Plug 'valloric/youcompleteme', { 'do': './install.py --all' }&#xA;else&#xA;    Plug 'valloric/youcompleteme', { 'do': './install.py --clang-complete --system-libclang --omnisharp-completer --gocode-completer --tern-completer --racer-completer' }&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user12460" LastActivityDate="2017-05-01T10:12:29.220" Title="Check if running in a 32 or 64 bit machine" Tags="|linux|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12281" PostTypeId="1" CreationDate="2017-05-01T08:49:13.190" Score="1" ViewCount="1250" Body="&lt;p&gt;I'm running vim on a Debian Jessie machine inside of a VirtualBox on my Mac. I'm trying to get &lt;code&gt;yy&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt; to work so I can copy and paste across different terminal windows by using the system clipboard. Please note the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) &lt;code&gt;echo has('clipboard')&lt;/code&gt; returns 1 (I have vim-gtk installed)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) My .vimrc file is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;set mouse=a&#xA;set clipboard=unnamedplus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;3) I've logged into the ssh session with &lt;code&gt;ssh -XY me@host&amp;gt;&lt;/code&gt;to allow x11 forwarding&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) The Debian machine is headless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5) When I'm logged into the machine directly instead of over ssh, I still can't copy to the system clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I do &lt;code&gt;yy&lt;/code&gt; or even &lt;code&gt;&quot;+yy&lt;/code&gt; and then do &lt;code&gt;:reg&lt;/code&gt; to look inside the registers, there is no listing for the &lt;code&gt;&quot;+&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure what else to try.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="51" LastEditDate="2017-05-01T15:49:31.973" LastActivityDate="2020-02-07T15:29:56.577" Title="Unable to copy to system clipboard" Tags="|os-clipboard|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12282" PostTypeId="2" ParentId="12280" CreationDate="2017-05-01T10:12:29.220" Score="0" Body="&lt;p&gt;The code you're looking for is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if system('uname -m | grep 64') == 0&#xA;    echo '64 bit system'&#xA;else&#xA;    echo '32 bit system'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your call to system &lt;code&gt;system($(uname -m | sed 's/x86_//;s/i[3-6]86/32/')&lt;/code&gt; doesn't have a matching number of brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you don't need to use the &lt;code&gt;$(...)&lt;/code&gt; syntax since &lt;code&gt;system()&lt;/code&gt; take a string to execute as parameter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally you don't need to use &lt;code&gt;sed&lt;/code&gt;, &lt;code&gt;grep&lt;/code&gt; is enough to detect the presence of a substring in a string.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-05-01T10:12:29.220" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12283" PostTypeId="2" ParentId="12271" CreationDate="2017-05-01T14:15:58.750" Score="5" Body="&lt;p&gt;As mentioned by grodzik, &lt;code&gt;nnoremap&lt;/code&gt; does not take any non-standard mappings into account. That includes mappings by plugins. Simply changing to &lt;code&gt;nmap&lt;/code&gt; is not the right way to go in my opinion. You will start to get used to &lt;code&gt;Alt (&lt;/code&gt; and not need &lt;code&gt;ysiw)&lt;/code&gt; anymore. With an &lt;code&gt;nmap&lt;/code&gt; you will never be able to map something else to &lt;code&gt;ysiw)&lt;/code&gt; (or &lt;code&gt;ys&lt;/code&gt;) because that will break the &lt;code&gt;Alt (&lt;/code&gt; mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you should map directly to the &lt;code&gt;vim-surround&lt;/code&gt; commands. In this case that would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;M-(&amp;gt; :execute &quot;normal \&amp;lt;Plug&amp;gt;Ysurroundiw)&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This calls &lt;code&gt;&amp;lt;Plug&amp;gt;Ysurround&lt;/code&gt; which is usually done using &lt;code&gt;ys&lt;/code&gt; and then does the &lt;code&gt;iw)&lt;/code&gt; part. Other commands can be found in the &lt;code&gt;surround.vim&lt;/code&gt; file that is part of the &lt;code&gt;vim-surround&lt;/code&gt; plugin.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2017-05-01T14:15:58.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12284" PostTypeId="1" CreationDate="2017-05-02T10:23:36.307" Score="1" ViewCount="357" Body="&lt;p&gt;I am looking for a way to fuzzy find C++ function/method definition in NeoVim.   A function definition can look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool Cls::func() {&#xA;bool func() {&#xA;bool Cls::func(unsigned some, bool argument) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would there be a solution where I can start typing something like &lt;code&gt;fnc&lt;/code&gt; and it would list all the lines that look like that pattern so I can choose which line to go to?  It would work similar to the CtrlP plugin but would only list the function definitions for the currently open buffer.&lt;/p&gt;&#xA;" OwnerUserId="3050" LastEditorUserId="1841" LastEditDate="2017-05-02T14:13:50.380" LastActivityDate="2017-10-13T07:19:06.120" Title="Fuzzy Find C++ function definition" Tags="|tags|filetype-c++|navigation|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12285" PostTypeId="1" AcceptedAnswerId="12286" CreationDate="2017-05-02T15:44:30.447" Score="1" ViewCount="179" Body="&lt;p&gt;My file contains ISBN-10 and ISBN-13, e.g.: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;isbn:0062316095, more text&#xA;isbn:1847922635, much more text&#xA;isbn:9780486406510, even more text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to convert every ISBN-10 to the according ISBN-13 (&lt;a href=&quot;https://www.isbn-information.com/convert-isbn-10-to-isbn-13.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;rules&lt;/a&gt;). How can I do that in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim version is MacVim 8.0.525 (130).&lt;/p&gt;&#xA;" OwnerUserId="1328" LastEditorUserId="6489" LastEditDate="2017-05-02T16:30:08.637" LastActivityDate="2017-05-02T16:50:43.347" Title="How to convert ISBN-10 to ISBN-13 in Vim?" Tags="|vimscript|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12286" PostTypeId="2" ParentId="12285" CreationDate="2017-05-02T16:19:41.253" Score="4" Body="&lt;p&gt;I believe this does what you want. I've made a function to do the conversion and a mapping that triggers it. Simply place your cursor on the ISBN-10 and press &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;i&lt;/kbd&gt; to replace it with its corresponding ISBN-13 number. (&lt;code&gt;&amp;lt;A-i&amp;gt;&lt;/code&gt; is just a suggestion, and you can, of course, change it to whatever works best for you.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;A-i&amp;gt; ciw&amp;lt;C-r&amp;gt;=ISBN10ToISBN13('&amp;lt;C-r&amp;gt;&quot;')&amp;lt;CR&amp;gt;&#xA;&#xA;function! ISBN10ToISBN13(ISBN10)&#xA;   let ISBN13 = ''&#xA;   if (strlen(a:ISBN10) == 10)&#xA;      &quot; Remove last number&#xA;      let ISBN13 = strpart(a:ISBN10, 0, 9)&#xA;      &quot; Prepend 978&#xA;      let ISBN13 = '978'.ISBN13&#xA;&#xA;      &quot; Calculate the check digit&#xA;      let i = 1&#xA;      let total = 0&#xA;      for digit in split(ISBN13, '\zs')&#xA;         let total += str2nr(digit)*i&#xA;         if (i == 1)&#xA;            let i = 3&#xA;         else&#xA;            let i = 1&#xA;         endif&#xA;      endfor&#xA;      let check = (10 - (total % 10)) % 10&#xA;&#xA;      &quot; Append the check digit&#xA;      let ISBN13 .= check&#xA;      return ISBN13&#xA;   else&#xA;      &quot; Return -1 if input digit is invalid.&#xA;      return -1&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And finally to replace ALL ISBN-10 in a file you can run a global command like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/isbn:\d\{10}\&amp;gt;/ exe &quot;normal!wwciw\&amp;lt;C-r&amp;gt;=ISBN10ToISBN13('\&amp;lt;C-r&amp;gt;\&quot;')\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:g&lt;/code&gt; run a command on every line that matches a pattern.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/isbn:\d\{10}\&amp;gt;/&lt;/code&gt; A pattern that matches only ISBN-10 numbers.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;exe ...&lt;/code&gt; Execute the following command (We need this so that we can use special characters like &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal!...&lt;/code&gt; A normal command that is identical to the &lt;code&gt;&amp;lt;A-i&amp;gt;&lt;/code&gt; mapping above.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#split%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help split()&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#str2nr%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help str2nr()&lt;/code&gt;&lt;/a&gt;,  &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_%3CC-R%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help c_&amp;lt;C-R&amp;gt;&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%3Aglobal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :global&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-05-02T16:50:43.347" LastActivityDate="2017-05-02T16:50:43.347" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12287" PostTypeId="1" AcceptedAnswerId="12288" CreationDate="2017-05-02T17:14:49.590" Score="3" ViewCount="3852" Body="&lt;p&gt;I'm trying to create a dynamic line to &lt;code&gt;execute&lt;/code&gt;, currently I have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute a:modes[i] .'noremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; '. l:key .' &amp;lt;Esc&amp;gt;:call HardModeEcho(g:HardMode_hardmodeMsg)&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like that to be something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute sprintf( &#xA;  &quot;%snoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; %s &amp;lt;ESC&amp;gt;:call HardModeEcho(g:HardMode_hardmodeMsg)&amp;lt;CR&amp;gt;&quot;,&#xA;  a:modes[i],&#xA;  l:key&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Actually it needs to get even more complex. But, I'd like to start with that. Is there any such functionality in vimscript?&lt;/p&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="51" LastEditDate="2017-05-02T17:24:12.703" LastActivityDate="2019-12-23T22:22:54.670" Title="What is the vimscript version of sprintf?" Tags="|vimscript|string-manipulation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12288" PostTypeId="2" ParentId="12287" CreationDate="2017-05-02T17:23:03.670" Score="8" Body="&lt;p&gt;Somewhat surprisingly, it's &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#printf%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;printf()&lt;/code&gt;&lt;/a&gt;, which behaves like &lt;code&gt;sprintf()&lt;/code&gt; in most other languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wasn't 100% sure what the name was from the top of my head; I found this by just entering &lt;code&gt;:help printf&lt;/code&gt; :-) I also find &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#function-list&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help function-list&lt;/code&gt;&lt;/a&gt; to be invaluable when VimScript-ing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see: &lt;a href=&quot;https://vi.stackexchange.com/q/2136/51&quot;&gt;How do I navigate to topics in Vim's documentation?&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="10604" LastEditDate="2019-12-23T22:22:54.670" LastActivityDate="2019-12-23T22:22:54.670" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="12289" PostTypeId="2" ParentId="12250" CreationDate="2017-05-02T20:29:59.347" Score="4" Body="&lt;p&gt;I came up with with a quick solution. It needs some improvements but you could&#xA;take it as a base.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your problem can be divided in two mains problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I get the mappings associated to a command?&lt;/li&gt;&#xA;&lt;li&gt;How can I execute a function after each command I use?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To start with the second one we can use a quick workaround: We can simply remap&#xA; &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in command mode, this way we can make it call a function each type we&#xA; press it to execute our command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This probably has some huge drawbacks that I don't know so far.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;:call ShowMappings()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this code we say to vim &quot;Call the function &lt;code&gt;ShowMappings()&lt;/code&gt; each time&#xA;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is pressed&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since we want to use the last executed command in our function, we can use&#xA;&lt;code&gt;getreg()&lt;/code&gt; to get the content of the &lt;code&gt;:&lt;/code&gt; register which contains our command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;ShowMappings()&lt;/code&gt; will look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ShowMappings()&#xA;    let cmd = getreg(':')&#xA;&#xA;    echo &quot;Mappings for &quot; . cmd&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the part where we want to get the mappings associated to our command:&#xA;The &lt;code&gt;map&lt;/code&gt; command gives all of the available mappings. The &lt;code&gt;filter&lt;/code&gt; command&#xA;allows us to filter the output of another command. So this code will show all of&#xA;the mappings including the command &lt;code&gt;CtrlP&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filter /CtrlP/ map&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now all we need to do is to use it in our function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ShowMappings()&#xA;    let cmd = getreg(':')&#xA;&#xA;    echo &quot;Mappings for &quot; . cmd&#xA;&#xA;    execute 'filter /' . cmd . '/ map'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you put everything together you get the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ShowMappings()&#xA;    let cmd = getreg(':')&#xA;&#xA;    echo &quot;Mappings for &quot; . cmd&#xA;&#xA;    execute 'filter /' . cmd . '/ map'&#xA;endfunction&#xA;&#xA;cnoremap &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;:call ShowMappings()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't hesitate to use it and improve it to make your own plugin. If I get some&#xA;time I'll try to make one.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-05-02T20:29:59.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12290" PostTypeId="1" CreationDate="2017-05-02T22:02:46.190" Score="2" ViewCount="241" Body="&lt;p&gt;I have this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let command = &quot;execute printf(\&quot;echo '%s'\&quot;, 'foo')&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works fine.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I prep it for INSERT-mode escaping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let command = &quot;execute &amp;lt;ESC&amp;gt; printf(\&quot;echo '%s'\&quot;, 'foo') &amp;lt;CR&amp;gt;&quot;&#xA;&#xA;imap . command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In insert mode, I hit &lt;code&gt;.&lt;/code&gt; VIM blows up. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="5078" LastActivityDate="2017-05-02T22:49:15.977" Title="Trying to wrap my head around exec and vim-escaping" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12291" PostTypeId="2" ParentId="12290" CreationDate="2017-05-02T22:18:44.813" Score="4" Body="&lt;p&gt;Mappings are basically the same as typing the right-hand side when they are executed. This means that when you type &lt;code&gt;.&lt;/code&gt;, it's the same as if you typed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;execute&lt;/code&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;code&gt;printf(\&quot;echo '%s'\&quot;, 'foo')&lt;/code&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what you'll get is the word &lt;code&gt;execute&lt;/code&gt; followed by whatever normal-mode commands come after the &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;, which obviously isn't what you're after.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you &lt;em&gt;actually&lt;/em&gt; want to do is go to command line mode before typing &lt;code&gt;execute&lt;/code&gt;. You can do so by using &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; to get out of insert mode, and then &lt;code&gt;:&lt;/code&gt; to get into command line mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're going to have problems with echoing to the command line because when you return to insert mode it will clear out the command line, but this technically works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let command = &quot;&amp;lt;C-o&amp;gt;:execute printf(\&quot;echom '%s'\&quot;, 'foo')&amp;lt;CR&amp;gt;&quot;&#xA;exe &quot;imap . &quot; . command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can tell it works because if you do &lt;code&gt;:mess&lt;/code&gt; after pressing &lt;code&gt;.&lt;/code&gt; in insert mode you'll see your message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One workaround is to set the &lt;code&gt;cmdheight&lt;/code&gt; larger than one. This way you'll still be able to see a few lines back even after insert mode has &quot;pushed&quot; the command line back with the message:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;-- INSERT --&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-O&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-O&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27cmdheight%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'cmdheight'&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-05-02T22:49:15.977" LastActivityDate="2017-05-02T22:49:15.977" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12292" PostTypeId="2" ParentId="11549" CreationDate="2017-05-03T04:40:47.300" Score="1" Body="&lt;p&gt;One convenient way is to use vim's built-in session files. Before exiting vim, use the command &lt;code&gt;:mksession project.vis&lt;/code&gt;, or &lt;code&gt;:mks!&lt;/code&gt; to save to the default &lt;code&gt;session.vim&lt;/code&gt; file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, to resume editing, start vim with the command &lt;code&gt;vim -S project.vis&lt;/code&gt;, or start vim and load the session file with the &lt;code&gt;:source&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/starting.html#:mksession&quot; rel=&quot;nofollow noreferrer&quot;&gt;online documentation:&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A Session keeps the Views for all windows, plus the global settings.  You can&#xA;save a Session and when you restore it later the window layout looks the same.&#xA;You can use a Session to quickly switch between different projects,&#xA;automatically loading the files you were last working on in that project.&#xA;&#xA;Views and Sessions are a nice addition to viminfo-files, which are used to&#xA;remember information for all Views and Sessions together.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additionally, there are several plugins available for working with sessions. &lt;/p&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2017-05-03T04:40:47.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12293" PostTypeId="1" AcceptedAnswerId="12294" CreationDate="2017-05-03T17:34:33.823" Score="8" ViewCount="2506" Body="&lt;p&gt;I can read a value from an option like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b = &amp;amp;background&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to read a value from a highlight group? Something like this pseudo-code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b = &amp;amp;StatusLine['ctermbg']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ultimately, what I want to do is define a new highlight group in terms of other highlight group colors (not a link, but picking specific values from more than one highlight group, namely &lt;code&gt;StatusLine&lt;/code&gt; and &lt;code&gt;StatusLineNC&lt;/code&gt; in my case)&lt;/p&gt;&#xA;" OwnerUserId="12489" LastEditorUserId="51" LastEditDate="2017-05-03T23:19:51.797" LastActivityDate="2017-05-04T13:41:05.440" Title="Read values from a highlight group" Tags="|vimscript|syntax-highlighting|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12294" PostTypeId="2" ParentId="12293" CreationDate="2017-05-03T18:46:38.383" Score="8" Body="&lt;p&gt;As far as I know, there's not a simple way to do this. Here's a function that should be able to return the value given the highlight group and term. If there is no such term, an empty string will be returned instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReturnHighlightTerm(group, term)&#xA;   &quot; Store output of group to variable&#xA;   let output = execute('hi ' . a:group)&#xA;&#xA;   &quot; Find the term we're looking for&#xA;   return matchstr(output, a:term.'=\zs\S*')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Given this function you should be able to do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b = ReturnHighlightTerm('StatusLine', 'ctermbg')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to get what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#execute%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help execute()&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Ahighlight&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :highlight&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#matchstr%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help matchstr()&lt;/code&gt;&lt;/a&gt; for more info on how this works.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="21" LastEditDate="2017-05-04T11:54:42.370" LastActivityDate="2017-05-04T11:54:42.370" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12295" PostTypeId="1" AcceptedAnswerId="12299" CreationDate="2017-05-03T20:06:31.973" Score="4" ViewCount="553" Body="&lt;p&gt;When I start a ruby block in the middle of a line, the next line is indented deeper than I'd like.  It's indented from the start of the block, not the start of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some_variable_name = begin&#xA;                       42&#xA;                     end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like line 2 to be indented one level deeper than 1.  3 should match 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GdFIm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Some more examples in this screenshot&lt;/a&gt;. Same logic applies to the case statement below.&lt;/p&gt;&#xA;" OwnerUserId="12491" LastEditorUserId="51" LastEditDate="2017-05-03T23:07:48.350" LastActivityDate="2017-05-03T23:07:48.350" Title="How do I control how vim indents ruby blocks?" Tags="|indentation|filetype-ruby|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12296" PostTypeId="1" AcceptedAnswerId="12297" CreationDate="2017-05-03T21:03:54.153" Score="1" ViewCount="44" Body="&lt;p&gt;I need to get the path and file name out of the open file.  Wrinkle .. The file is FTP'd to my Desktop and I need the Linux path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this on the web that prints the path file name&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;F4&amp;gt; :let @+=expand(&quot;%:p&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get this&#xA; &lt;code&gt;C:\Users\rr243319\AppData\Local\Temp\scp30622\bcs\lgnt\clientapp\etscmbn\scripts\combine-ctc.pl&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;C:/Users/rr243319/AppData/Local/Temp/scp30622/bcs/lgnt/clientapp/etscmbn/scripts/combine-ctc.pl&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question : How do I convert the path to a linux like path?&lt;/p&gt;&#xA;" OwnerUserId="11878" LastEditorUserId="51" LastEditDate="2017-05-03T22:39:45.543" LastActivityDate="2017-05-03T23:18:38.827" Title="Getting the path with a function key" Tags="|key-bindings|path|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12297" PostTypeId="2" ParentId="12296" CreationDate="2017-05-03T21:13:08.413" Score="2" Body="&lt;p&gt;This stores the current filename in the system clipboard with backslashes replaced with forward slashes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;F5&amp;gt; :let @+ = substitute(expand(&quot;%:p&quot;), '\', '/', 'g')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12113" LastEditorUserId="51" LastEditDate="2017-05-03T23:18:38.827" LastActivityDate="2017-05-03T23:18:38.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12298" PostTypeId="1" CreationDate="2017-05-03T22:53:53.467" Score="5" ViewCount="4062" Body="&lt;p&gt;I have installed the &lt;a href=&quot;https://github.com/sirver/UltiSnips&quot; rel=&quot;noreferrer&quot;&gt;vim-ultisnips&lt;/a&gt; plugin and added some files containing snippets to the &lt;code&gt;~/.vim/snippets/&lt;/code&gt; directory. (note: these files are in the snipmate format as I am in the process of switching to ultisnips from snipmate)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% ls -1 ~/.vim/snippets/                          &#xA;apache.snippets&#xA;awk.snippets&#xA;css.snippets&#xA;html.snippets&#xA;javascript&#xA;markdown.snippets&#xA;php.snippets&#xA;sh.snippets&#xA;_.snippets&#xA;snippets.snippets&#xA;sql.snippets&#xA;vim.snippets&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;say I am in a vim buffer and I type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun&amp;lt;TAB&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ultisnips will ask me to choose between the &lt;code&gt;fun&lt;/code&gt; snippets from &lt;code&gt;sh.snippets&lt;/code&gt; or the &lt;code&gt;fun&lt;/code&gt; snippet from &lt;code&gt;vim.snippets&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how does ultisnips decide which snippet files to load for a given filetype, and is it possible to get a list of which snippet files ultisnips has currently loaded?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2017-05-04T00:42:28.300" LastActivityDate="2017-05-04T17:10:24.133" Title="How does Ultisnips select snippet files for the file I'm currently editing?" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12299" PostTypeId="2" ParentId="12295" CreationDate="2017-05-03T23:05:30.257" Score="6" Body="&lt;p&gt;The file that controls this lives at &lt;code&gt;/usr/share/vim/vim80/indent/ruby.vim&lt;/code&gt;. Opening the file, I see it has two variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('g:ruby_indent_access_modifier_style')&#xA;  &quot; Possible values: &quot;normal&quot;, &quot;indent&quot;, &quot;outdent&quot;&#xA;  let g:ruby_indent_access_modifier_style = 'normal'&#xA;endif&#xA;&#xA;if !exists('g:ruby_indent_block_style')&#xA;  &quot; Possible values: &quot;expression&quot;, &quot;do&quot;&#xA;  let g:ruby_indent_block_style = 'expression'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately there is no documentation for this at all; either in &lt;code&gt;:help ft-ruby-syntax&lt;/code&gt; or in the file. I tried playing with both, to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, at the top of the file there is some author information:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Language:             Ruby&#xA;&quot; Maintainer:           Nikolai Weibull &amp;lt;now at bitwi.se&amp;gt;&#xA;&quot; URL:                  https://github.com/vim-ruby/vim-ruby&#xA;&quot; Release Coordinator:  Doug Kearns &amp;lt;dougkearns@gmail.com&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At that page GitHub, I see a &lt;a href=&quot;https://github.com/vim-ruby/vim-ruby/blob/master/indent/ruby.vim&quot; rel=&quot;noreferrer&quot;&gt;newer version of &lt;code&gt;indent/ruby.vim&lt;/code&gt;&lt;/a&gt; which has a new option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('g:ruby_indent_assignment_style')&#xA;  &quot; Possible values: &quot;variable&quot;, &quot;hanging&quot;&#xA;  let g:ruby_indent_assignment_style = 'hanging'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Aha! This looks promising! I saved that file to &lt;code&gt;~/.vim/indent/ruby.vim&lt;/code&gt;, added &lt;code&gt;let g:ruby_indent_assignment_style = 'variable'&lt;/code&gt; to my vimrc, restarted Vim, and now I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some_variable_name = begin&#xA;  42&#xA;end &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which seems to be what you want!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that instead of downloading this one file, you may want to clone the entire project and load it as a package with some package manager or Vim's package feature. Unfortunately Vim's runtime files tend to lag a bit behind upstream.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-05-03T23:05:30.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12301" PostTypeId="1" CreationDate="2017-05-04T03:31:10.940" Score="0" ViewCount="84" Body="&lt;p&gt;I’m using &lt;a href=&quot;https://github.com/davidoc/taskpaper.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;taskpaper.vim&lt;/a&gt; to work with projects and tasks and would like to display the hyphen that starts a tasks as the □ (unicode white square). I don't want to actually replace the character in the text, but simply display it this way.&lt;/p&gt;&#xA;" OwnerUserId="12495" LastEditorUserId="51" LastEditDate="2017-05-04T04:55:08.187" LastActivityDate="2017-05-04T05:46:52.203" Title="How to display hyphens as □ in taskpaper files?" Tags="|conceal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12302" PostTypeId="2" ParentId="12301" CreationDate="2017-05-04T05:46:52.203" Score="3" Body="&lt;p&gt;The conceal feature will let you do this. Following the example &lt;a href=&quot;https://vi.stackexchange.com/questions/5696/adding-conceal-to-already-existing-syntax-highlighting&quot;&gt;here&lt;/a&gt;, I came up with this solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd('Conceal', '^-', 10, -1, {'conceal': '□'})&#xA;:set conceallevel=2 concealcursor=nv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the pattern is a hyphen in column 1. If you want to allow whitespace before the hyphen, change the pattern to &lt;code&gt;'^\s*\zs-'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-05-04T05:46:52.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12303" PostTypeId="1" AcceptedAnswerId="12306" CreationDate="2017-05-04T12:29:24.810" Score="1" ViewCount="155" Body="&lt;h1&gt;Context&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Python integration in Vim 8.0 provides a handful of useful python objects in &lt;code&gt;vim&lt;/code&gt; module. In particular, there are &lt;a href=&quot;http://vimhelp.appspot.com/if_pyth.txt.html#python-buffer&quot; rel=&quot;nofollow noreferrer&quot;&gt;per-buffer objects&lt;/a&gt; accessible via &lt;code&gt;vim.buffers&lt;/code&gt; list and &lt;code&gt;vim.current.buffer&lt;/code&gt;. One can set or read per-buffer variables and options by accessing &lt;code&gt;b.vars&lt;/code&gt; and &lt;code&gt;b.options&lt;/code&gt; dict-like objects, where &lt;code&gt;b&lt;/code&gt; is that buffer object.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;However, Vim variables are necessarily strings and one cannot store arbitrary python objects in there. How do I store an arbitrary per-buffer python object?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Failed attempts&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I tried adding a custom attribute on the buffer object via &lt;code&gt;setattr(b, ...)&lt;/code&gt; or via assigning to &lt;code&gt;b.__dict__[...]&lt;/code&gt; but that does not work (these objects have no &lt;code&gt;__dict__&lt;/code&gt; or &lt;code&gt;__setattr__()&lt;/code&gt;), same for subobjects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also possible to have a global dictionary indexed by buffer number (&lt;code&gt;b.number&lt;/code&gt;) and hook into the BufDelete autocmd for cleanup. This is what I use right now, but that feels kludgy and I seek a better solution, if there is one.&lt;/p&gt;&#xA;" OwnerUserId="7826" LastEditorUserId="7826" LastEditDate="2017-05-04T14:12:02.840" LastActivityDate="2017-05-04T14:12:02.840" Title="Vim 8.0 python support: where to store a per-buffer python variable?" Tags="|vimscript-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12304" PostTypeId="2" ParentId="12231" CreationDate="2017-05-04T12:54:12.620" Score="1" Body="&lt;p&gt;Finally solved.&lt;br&gt;&#xA;The trouble was caused by one or both copied pythonxx.dll's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usally I work with my installed Anaconda Python (currently Python 3.5.2) environment.&#xA;No separate Python 2 or Python 3 installations exist.&#xA;As mentioned in one of my comments &lt;code&gt;gvim -u NONE&lt;/code&gt; results also in an crash of gvim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to fix it:&lt;br&gt;&#xA;I installed python-2.7.13.msi and python-3.6.1.msi both 32-bit corresponding to my vim/gvim 32-bit package.&#xA;Copied python27.dll and python36.dll from the installation folders to my vim/gvim install directory where the *.exe's are located.&#xA;Afterwards I uninstalled both msi packages to avoid getting confused with Anaconda installation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now everything works fine.&lt;/p&gt;&#xA;" OwnerUserId="1373" LastActivityDate="2017-05-04T12:54:12.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12305" PostTypeId="2" ParentId="12293" CreationDate="2017-05-04T13:41:05.440" Score="5" Body="&lt;p&gt;I ended up writing a generic function that turns a highlight group into a dictionary of &lt;code&gt;{key}={arg}&lt;/code&gt; pairs. Leaving it here for future reference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetHighlight(group)&#xA;  let output = execute('hi ' . a:group)&#xA;  let list = split(output, '\s\+')&#xA;  let dict = {}&#xA;  for item in list&#xA;    if match(item, '=') &amp;gt; 0&#xA;      let splited = split(item, '=')&#xA;      let dict[splited[0]] = splited[1]&#xA;    endif&#xA;  endfor&#xA;  return dict&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12489" LastActivityDate="2017-05-04T13:41:05.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12306" PostTypeId="2" ParentId="12303" CreationDate="2017-05-04T14:10:58.960" Score="2" Body="&lt;p&gt;I often use those global, but plugin-internal, dictionaries indexed by buffer number, even in pure vim scripts. &#xA;Sometimes, there is no better solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage, also, is that I'm sure the variable is completly encapsulated, and there is no risk of seing another plugin using a variable with the exact same name, or messing with my invariants.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, I wonder whether there isn't a way to turn a Python dictionary into a vim dictionary (as long as the Python dictionary only contains numbers, strings, dictionaries and arrays). I won't be surprised to see that someone has already implemented such a feature. BTW, a simple way would be to use json as a translation layer as Vim knows how to (de)serialize json data.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-05-04T14:10:58.960" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12307" PostTypeId="1" CreationDate="2017-05-04T14:28:33.187" Score="3" ViewCount="333" Body="&lt;p&gt;I have not found much use for &lt;code&gt;()[]{}&lt;/code&gt;, and so I want to map them so it does a find command, jumping to the previous instance of that particular character. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, &lt;code&gt;)&lt;/code&gt; will jump forward to the next &lt;code&gt;)&lt;/code&gt;, placing the cursor on top of it. &lt;code&gt;(&lt;/code&gt; will jump backward to the previous &lt;code&gt;(&lt;/code&gt;, again, placing the cursor on top of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem is, &lt;code&gt;f&lt;/code&gt; stops at linebreaks, and &lt;code&gt;?/&lt;/code&gt; would eliminate my highlight. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a solution for this issue? &lt;/p&gt;&#xA;" OwnerUserId="7960" LastEditorUserId="7960" LastEditDate="2017-05-04T18:07:47.500" LastActivityDate="2017-05-04T18:17:08.703" Title="How to jump to a next or previous specific character ignoring linebreaks and not destroying highlight or overwriting my registry?" Tags="|vimrc|key-bindings|search|line-breaks|find|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12308" PostTypeId="2" ParentId="12307" CreationDate="2017-05-04T14:56:37.253" Score="2" Body="&lt;p&gt;You can use the &lt;code&gt;search()&lt;/code&gt; command for this. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ) :call search(')')&amp;lt;CR&amp;gt;      &quot;Next&#xA;nnoremap ( :call search('(', 'b')&amp;lt;CR&amp;gt; &quot;Previous&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Origial response before edit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ) yl:call search('&amp;lt;C-r&amp;gt;&quot;\C')&amp;lt;CR&amp;gt;      &quot; Next instance&#xA;nnoremap ( yl:call search('&amp;lt;C-r&amp;gt;&quot;\C', 'b')&amp;lt;CR&amp;gt; &quot; Previous instance&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will yank the character under the cursor and then use the search command to go to the next instance.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap (&lt;/code&gt; Make a non-recursive normal mode mapping for &lt;code&gt;(&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yl&lt;/code&gt; Yank character under cursor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:call search('...')&lt;/code&gt; Calls the search command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt; Inserts the contents of register &lt;code&gt;&quot;&lt;/code&gt; (The character we just yanked)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\C&lt;/code&gt; Makes the search case sensitive&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'b'&lt;/code&gt; Search backwards&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; The &lt;kbd&gt;Enter&lt;/kbd&gt; key (Simply executes the call)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#search%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help search()&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-05-04T18:17:08.703" LastActivityDate="2017-05-04T18:17:08.703" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12309" PostTypeId="2" ParentId="7598" CreationDate="2017-05-04T15:41:04.533" Score="0" Body="&lt;p&gt;I believe the problem is vim's &lt;a href=&quot;https://github.com/vim/vim/blob/4475b623960671898dac6a72b13a8d140402afa6/runtime/filetype.vim#L2770&quot; rel=&quot;nofollow noreferrer&quot;&gt;filetype detection&lt;/a&gt; uses:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime! ftdetect/*.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The help for &lt;code&gt;runtime[!] [where] {file} ..&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Read Ex commands from {file} in each directory given by 'runtimepath' and/or 'packpath'.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[snip]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When [where] is omitted only 'runtimepath' is used. Other values:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;START  search under &quot;start&quot; in 'packpath'&lt;br&gt;&#xA;     OPT    search under &quot;opt&quot; in 'packpath'&lt;br&gt;&#xA;     PACK   search under &quot;start&quot; and &quot;opt&quot; in 'packpath'&lt;br&gt;&#xA;     ALL    first use 'runtimepath', then search under &quot;start&quot; and &quot;opt&quot; in 'packpath'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When I added &lt;code&gt;ALL&lt;/code&gt; to the filetype detection line quoted above, it picked up filetype files in the packages.  I.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime! ALL ftdetect/*.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2017-05-04T15:41:04.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12310" PostTypeId="1" CreationDate="2017-05-04T16:32:16.730" Score="1" ViewCount="1030" Body="&lt;p&gt;Can anyone explain to me why when writing python code, vim is auto indenting when entering carriage return after function call ie. f.write(name, r)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Before writing(:w) file&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import bs4 as bs&#xA;import urllib.request&#xA;sauce = urllib.request.urlopen('http://www.google.com').read()&#xA;&#xA;soup = bs.BeautifulSoup(sauce, 'lxml')&#xA;&#xA;path = &quot;~/Workspace/scraping/&quot;&#xA;filename = &quot;demo.html&quot;&#xA;fullname = path + filename&#xA;&#xA;f=open(fullname, 'w')&#xA;f.write(soup)&#xA;    print(f) #why auto indenting here?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;After writing (:w) file&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import bs4 as bs&#xA;import urllib.request&#xA;sauce = urllib.request.urlopen('http://www.google.com').read()&#xA;&#xA;soup = bs.BeautifulSoup(sauce, 'lxml')&#xA;&#xA;path = &quot;~/Workspace/scraping/&quot;&#xA;filename = &quot;demo.html&quot;&#xA;fullname = path + filename&#xA;&#xA;    f=open(fullname, 'w') #???&#xA;    f.write(soup)         #???&#xA;print(f)                  #???&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;.vimrc file setting for python file&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile, BufRead *.py &#xA;     \ set tabstop=4&#xA;     \ set softtabstop=4&#xA;     \ set shiftwidth=4&#xA;     \ set textwidth=80&#xA;autocmd BufWritePre *.py  :normal gg=G&#xA;&#xA;&quot;indent settings for all files&#xA;set cindent&#xA;set autoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Machine Details&lt;/h1&gt;&#xA;&#xA;&lt;h3&gt;VIM&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)&#xA;Included patches: 1-1689&#xA;Extra patches: 8.0.0056&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Features:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-python&#xA;+python3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Python&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Python 2.7.12&#xA;Python 3.5.2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any input at all would be greatly appreciated. Cheers!&lt;/p&gt;&#xA;" OwnerUserId="12505" LastEditorUserId="12505" LastEditDate="2017-05-04T18:35:13.577" LastActivityDate="2017-05-04T19:16:26.720" Title="Python: Strange auto indent behavior after function call" Tags="|indentation|filetype-python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12311" PostTypeId="1" AcceptedAnswerId="12319" CreationDate="2017-05-04T17:07:05.163" Score="9" ViewCount="3224" Body="&lt;p&gt;In vi, I can get a shell terminal with &lt;code&gt;:sh&lt;/code&gt; command. And later, I can return to vi by &lt;code&gt;exit&lt;/code&gt; shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, if I was using the shell terminal for a long time, and I forgot whether &lt;code&gt;exit&lt;/code&gt; will close anything or return me the vi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to check whether I will return to vi? &lt;code&gt;jobs&lt;/code&gt; or &lt;code&gt;fg&lt;/code&gt; is not working.&lt;/p&gt;&#xA;" OwnerUserId="9074" LastActivityDate="2017-05-05T21:34:35.403" Title="How do I know i am in a shell from vi command :sh?" Tags="|external-command|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12312" PostTypeId="2" ParentId="12298" CreationDate="2017-05-04T17:10:24.133" Score="6" Body="&lt;p&gt;From &lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help UltiSnips-adding-snippets&lt;/code&gt;&lt;/a&gt; (section 4.1):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;UltiSnips iterates over the snippet definition directories looking for&#xA;  files with names of the following patterns: &lt;code&gt;ft.snippets&lt;/code&gt;,&#xA;  &lt;code&gt;ft_*.snippets&lt;/code&gt;, or &lt;code&gt;ft/*&lt;/code&gt;, where &quot;&lt;code&gt;ft&lt;/code&gt;&quot; is the 'filetype' of the current&#xA;  document and &quot;&lt;code&gt;*&lt;/code&gt;&quot; is a shell-like wildcard matching any string&#xA;  including the empty string. The following table shows some typical&#xA;  snippet filenames and their associated filetype.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet filename         filetype ~&#xA;ruby.snippets            ruby&#xA;perl.snippets            perl&#xA;c.snippets               c&#xA;c_my.snippets            c&#xA;c/a                      c&#xA;c/b.snippets             c&#xA;all.snippets             *all&#xA;all/a.snippets           *all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, if your current buffer's filetype is &lt;code&gt;vim&lt;/code&gt;, you should only be seeing snippets from &lt;code&gt;vim.snippets&lt;/code&gt; (and an &lt;code&gt;all.snippets&lt;/code&gt;, if you had one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few reasons why UltiSnips would load snippets for multiple filetypes at the same time for a single buffer:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;UltiSnips supports Vim's dotted filetypes, so if your buffer's&#xA;filetype is set to &lt;code&gt;bash.sh&lt;/code&gt;, UltiSnips will load both bash snippets&#xA;and sh snippets.&lt;/li&gt;&#xA;&lt;li&gt;Snippet files can also extend each other using the &lt;code&gt;extends ft1, ft2,&#xA;ft3&lt;/code&gt; syntax. C++ snippet files usually start off with &lt;code&gt;extends c&lt;/code&gt;, so&#xA;&lt;code&gt;cpp&lt;/code&gt; files will load both &lt;code&gt;c.snippets&lt;/code&gt;, and &lt;code&gt;cpp.snippets&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Bugs. If your buffer's filetype does not include both &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;sh&lt;/code&gt;, and neither vim.snippets, nor sh.snippets extend the other (either directly, or indirectly through yet more filetypes), then it's quite possible you've found a bug.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Regarding listing all loaded files... I'm not sure if that's possible, but you might be able to get something similar. The description for the &lt;code&gt;UltiSnips#SnippetsInCurrentScope&lt;/code&gt; function says this (section 3.5.3 from above link):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This function simply returns a vim dictionary with the snippets whose&#xA;  trigger matches the current word.  If you need all snippets&#xA;  information of current buffer, you can simply pass 1 (which means all)&#xA;  as first argument of this function, and use a global variable&#xA;  &lt;code&gt;g:current_ulti_dict_info&lt;/code&gt; to get the result&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There's also a specific example of the latter usage further down the help page.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2017-05-04T17:10:24.133" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12313" PostTypeId="2" ParentId="12311" CreationDate="2017-05-04T17:33:44.480" Score="2" Body="&lt;p&gt;Execute &lt;code&gt;ps&lt;/code&gt;, or better, &lt;code&gt;ps -fH&lt;/code&gt;. Ex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ps -fH&#xA;UID        PID  PPID  C STIME TTY          TIME CMD&#xA;garyjohn 31140 31139  0 10:26 pts/11   00:00:00 bash&#xA;garyjohn 31267 31140  2 10:26 pts/11   00:00:00   vim hello.txt&#xA;garyjohn 31271 31267  0 10:26 pts/11   00:00:00     /bin/bash&#xA;garyjohn 31332 31271  0 10:26 pts/11   00:00:00       ps -fH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The advantage to using &lt;code&gt;ps -fH&lt;/code&gt; over just &lt;code&gt;ps&lt;/code&gt; is that it lets you see whether you are in a sub-shell of &lt;code&gt;vim&lt;/code&gt; or if you put &lt;code&gt;vim&lt;/code&gt; in the background. In that case, &lt;code&gt;ps -fH&lt;/code&gt; would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ps -fH&#xA;UID        PID  PPID  C STIME TTY          TIME CMD&#xA;garyjohn 31140 31139  0 10:26 pts/11   00:00:00 bash&#xA;garyjohn 31267 31140  0 10:26 pts/11   00:00:00   vim hello.txt&#xA;garyjohn 31924 31140  0 10:29 pts/11   00:00:00   ps -fH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-05-04T17:33:44.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12314" PostTypeId="2" ParentId="12310" CreationDate="2017-05-04T19:16:26.720" Score="1" Body="&lt;p&gt;Turns out trading autoindent for smartindent seems to get everything working as it should.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;turned autoindent off &lt;code&gt;:set noautoindent&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;turned on smart indent &lt;code&gt;:set smartindent&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="12505" LastActivityDate="2017-05-04T19:16:26.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12315" PostTypeId="2" ParentId="12311" CreationDate="2017-05-04T19:33:46.580" Score="3" Body="&lt;p&gt;I have my command prompt set up to add a red &quot;+&quot; symbol that indicates if I am in a vim &quot;:sh&quot; as opposed to a normal shell session. The cornerstone of it is that &quot;$$&quot; is the pid of the current process so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MY_PPID=$(ps --no-header -o ppid -p $$)          # Gets the pid of the parent&#xA;                                                 # process.&#xA;MY_PCMDLINE=$(ps --no-header -o cmd -p $MY_PPID) # Gets its command line.&#xA;MY_CMDDASH=$(awk '{print $1}' &amp;lt;&amp;lt;&amp;lt;$MY_PCMDLINE)   # Gets the command name, possibly&#xA;                                                 # with a preceding hyphen.&#xA;MY_CMD=${MY_CMDDASH#-}                           # Get the bare command name.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once you have this you can easily inline and construct something like I described to use in  your &quot;.bashrc&quot; or similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: The environment variable ($VIM) method described elsewhere seems better than this but I'll leave this as it works in identifying if you are a child process of anything (not just vim).&lt;/p&gt;&#xA;" OwnerUserId="12506" LastEditorUserId="12507" LastEditDate="2017-05-05T21:34:35.403" LastActivityDate="2017-05-05T21:34:35.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12316" PostTypeId="1" AcceptedAnswerId="12317" CreationDate="2017-05-04T19:36:15.703" Score="-2" ViewCount="119" Body="&lt;p&gt;These the output of the commands to check which version of Vim I am using on Devain Jessie and Debian Sid&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have checked my systems - &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Output of debian jessie&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:python import sys; print(sys.version)&#xA;&#xA;2.7.9 (default, Jun 29 2016, 13:11:10)&#xA;[GCC 4.9.2]&#xA;&#xA;   VIM - Vi IMproved    &#xA;&#xA;    version 7.4.576     &#xA;by Bram Moolenaar et al.&#xA;&#xA;apt-cache policy vim&#xA;&#xA;vim:                                                                      &#xA;  Installed: 2:7.4.488-7+deb8u2                                           &#xA;  Candidate: 2:7.4.488-7+deb8u2                                           &#xA;  Version table:                                                          &#xA; *** 2:7.4.488-7+deb8u2 0                                                 &#xA;        500 http://security.debian.org/ jessie/updates/main amd64 Packages&#xA;        100 /var/lib/dpkg/status                                          &#xA;     2:7.4.488-7+deb8u1 0                                                 &#xA;        500 http://ftp.uni-erlangen.de/debian/ jessie/main amd64 Packages &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Output of debian sid&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:python import sys; print(sys.version)&#xA;&#xA;E319: Sorry, the command is not available in this version&#xA;&#xA;apt-cache policy vim&#xA;&#xA;vim:&#xA;  Installed: 2:8.0.0197-3&#xA;  Candidate: 2:8.0.0197-4&#xA;  Version table:&#xA;     2:8.0.0197-4 500&#xA;        500 http://ftp.uni-erlangen.de/debian unstable/main amd64 Packages&#xA; *** 2:8.0.0197-3 100&#xA;        100 /var/lib/dpkg/status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;start up screen&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved   &#xA;&#xA; version 8.0.378    &#xA;by Bram Moolenaar et al.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does the &lt;code&gt;apt-cache&lt;/code&gt; policy output usually different from the version reported by Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a version Vim already built into Vim 8, or does it require an additional build with python?&lt;/p&gt;&#xA;" OwnerUserId="9540" LastEditorUserId="9540" LastEditDate="2017-05-05T04:40:37.990" LastActivityDate="2017-05-05T04:40:37.990" Title="Why is the version of Vim displayed by 'apt' different from the one displayed in Vim?" Tags="|version|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12317" PostTypeId="2" ParentId="12316" CreationDate="2017-05-04T21:05:29.897" Score="3" Body="&lt;p&gt;As described in &lt;code&gt;/usr/share/doc/vim/NEWS.Debian.gz&lt;/code&gt;, the Debian packages have switched to building against Python3 for Stretch.  If you upgraded a system to Stretch and didn't see this message, then I highly recommend installing the &lt;code&gt;apt-listchanges&lt;/code&gt; package, so you are informed of important changes like this in the future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you notice, when you ran &lt;code&gt;:python&lt;/code&gt; it said &lt;code&gt;E319: Sorry, the command is not available in this version&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your command would need to change to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:python3 import sys; print(sys.version)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, the &lt;code&gt;vim&lt;/code&gt; package itself doesn't have any of the language bindings enabled.  You need either &lt;code&gt;vim-nox&lt;/code&gt; or one of the packages providing &lt;code&gt;gvim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as why &lt;code&gt;:intro&lt;/code&gt; shows a larger version than the package version, I had backported some upstream patches to fix various bugs before Jessie was released.  You'll see these if you run &lt;code&gt;:version&lt;/code&gt;.  The version reported by &lt;code&gt;:intro&lt;/code&gt; is just the highest patch number that's been included.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-05-04T21:05:29.897" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12319" PostTypeId="2" ParentId="12311" CreationDate="2017-05-05T00:38:48.443" Score="8" Body="&lt;p&gt;In a regular shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ env | grep -i vim&#xA;EDITOR=vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After using &lt;code&gt;:shell&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ env | grep -i vim&#xA;EDITOR=vim&#xA;VIMRUNTIME=/usr/share/vim/vim80&#xA;VIM=/usr/share/vim&#xA;MYVIMRC=/home/martin/.vim/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it looks like Vim sets the &lt;code&gt;VIMRUNTIME&lt;/code&gt;, &lt;code&gt;VIM&lt;/code&gt;, and &lt;code&gt;MYVIMRC&lt;/code&gt; environment variables. Of those, &lt;code&gt;VIM&lt;/code&gt; seems the most reliable to me (you may not have a vimrc or even vim runtime).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also set your own environment variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let $HELLO = &quot;test&quot;&#xA;:shell&#xA;$ echo $HELLO&#xA;test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is especially useful to communicate info about the buffer you're editing; for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let $VIM_FILETYPE = &amp;amp;filetype&#xA;:let $VIM_FILENAME = expand('%:p')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will show up as something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM_FILETYPE=go&#xA;VIM_FILENAME=/home/martin/a.go&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-05-05T00:38:48.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12320" PostTypeId="1" CreationDate="2017-05-05T05:53:32.307" Score="1" ViewCount="43" Body="&lt;p&gt;This is an example script which is meant to print the keyboard shortcut for a command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Applying it clears the screen output. The result of commands like &lt;code&gt;intro&lt;/code&gt; or &lt;code&gt;version&lt;/code&gt; get cleared off the screen when it is enabled. Currently it only calls &lt;code&gt;echomsg&lt;/code&gt; when the last command is &lt;code&gt;tabnew&lt;/code&gt; yet the screen gets cleared when any other command is applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this happening?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;silent&amp;gt; &amp;lt;cr&amp;gt; &amp;lt;cr&amp;gt;:call &amp;lt;SID&amp;gt;CommandCallback()&amp;lt;cr&amp;gt;&#xA;&#xA;function! s:CommandCallback()&#xA;  let last_command = @:&#xA;&#xA;  if last_command =~ 'tabnew'&#xA;    echomsg &quot;Tabnew was called&quot;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: The question where this script came from -  &lt;a href=&quot;https://stackoverflow.com/questions/43691961&quot;&gt;https://stackoverflow.com/questions/43691961&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9540" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-05-05T05:53:32.307" Title="Why is this function clearing screen output?" Tags="|functions|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12321" PostTypeId="1" CreationDate="2017-05-05T06:49:57.833" Score="3" ViewCount="564" Body="&lt;p&gt;I am looking at a scenario where in order to keep track of changes to my setup, rather than delete functions and keymaps defined in &lt;code&gt;vimrc&lt;/code&gt; or other plugin I add commands which disable those functions and keymaps further down the execution sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example in the example below how would undo the mapping of the &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; key and &lt;code&gt;undefine&lt;/code&gt; the function like it was never created in the first place?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;silent&amp;gt; &amp;lt;cr&amp;gt; &amp;lt;cr&amp;gt;:call &amp;lt;SID&amp;gt;CommandCallback()&amp;lt;cr&amp;gt;&#xA;&#xA;function! s:CommandCallback()&#xA;  let last_command = @:&#xA;&#xA;  if last_command =~ 'tabnew'&#xA;    echomsg &quot;Tabnew was called&quot;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9540" LastEditorUserId="51" LastEditDate="2017-05-05T12:35:10.443" LastActivityDate="2017-05-05T12:35:10.443" Title="How do you undefine existing functions and key maps?" Tags="|key-bindings|vimscript|functions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12323" PostTypeId="2" ParentId="12321" CreationDate="2017-05-05T08:45:04.730" Score="7" Body="&lt;p&gt;To remove a command-line mapping, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cunmap {lhs}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similar commands exist for the other mapping modes. See &lt;code&gt;:help :unmap&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To remove a function, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:delfunction {name}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-05-05T08:45:04.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12324" PostTypeId="1" AcceptedAnswerId="12562" CreationDate="2017-05-05T11:57:30.280" Score="2" ViewCount="251" Body="&lt;p&gt;I cannot figure out the general rules for using &lt;code&gt;%&lt;/code&gt; to substitute the current file name/path into a command line mode command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are examples.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I create a file &lt;code&gt;te st.txt&lt;/code&gt;, open it in vim and try to save a copy named &lt;code&gt;te st.txt.backup&lt;/code&gt; with &lt;code&gt;:w %.backup&lt;/code&gt;.&#xA;This works as expected.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;From the same file, I try to print it to a PostScript file with &lt;code&gt;:ha &amp;gt; %.ps&lt;/code&gt;.&#xA;This time, instead of &lt;code&gt;te st.txt.ps&lt;/code&gt;, I get a PostScript file &lt;code&gt;te\ st.txt.ps&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I do &lt;code&gt;:exe &quot;ha &amp;gt; &quot; . expand(&quot;%&quot;) . &quot;.ps&quot;&lt;/code&gt;, I get &lt;code&gt;te st.txt.ps&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I do not follow the rules for using &lt;code&gt;%&lt;/code&gt; in command line.&#xA;Are they documented somewhere?&lt;/p&gt;&#xA;" OwnerUserId="1248" LastActivityDate="2017-06-04T20:13:38.200" Title="Using the current file name (%) in command line mode when the file name contains spaces (or other special characters)" Tags="|command-line|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12325" PostTypeId="1" AcceptedAnswerId="12437" CreationDate="2017-05-05T14:59:42.950" Score="5" ViewCount="480" Body="&lt;p&gt;I'm having some problems remapping my home key; it works when I run Vim from tmux but not when I run it from a regular xterm without tmux. It looks like they're sending different escape codes and Vim only picks up on tmux's one for some reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried mucking about with a lot of &lt;code&gt;TERM&lt;/code&gt; values, to no avail. So I figured I'd just hard-code this escape code in my vimrc and move on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&#xA;&quot; `^[` is the escape character.&#xA;set &amp;lt;Home&amp;gt;=^[OH&#xA;set t_kh=^[OH&#xA;&#xA;echo &amp;amp;t_kh&#xA;&#xA;noremap &amp;lt;Home&amp;gt; :echoerr &quot;home!&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Starting with &lt;code&gt;$ vim -u vimrc&lt;/code&gt; Vim outputs &lt;code&gt;^[OH&lt;/code&gt;, which is expected. But after I've started Vim the setting seems to be not set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set t_kh?&#xA;E846: Key code not set: t_kh?&#xA;:verbose set t_kh?&#xA;E846: Key code not set: t_kh?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the remapped home key doesn't work. Manually running &lt;code&gt;:set &amp;lt;Home&amp;gt;&lt;/code&gt; or &lt;code&gt;:set t_kh&lt;/code&gt; fixes the problem; I can now use my custom &lt;code&gt;&amp;lt;Home&amp;gt;&lt;/code&gt; mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why aren't these options taking effect? How can I make them take effect?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no plugins and am using Vim 8.0.586 on Arch Linux.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-05-19T11:49:54.770" LastActivityDate="2017-05-19T12:10:17.807" Title="Why can't I set &lt;Home&gt; or t_kh in my vimrc file?" Tags="|vimrc|key-bindings|terminal|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12326" PostTypeId="2" ParentId="4096" CreationDate="2017-05-05T18:15:42.620" Score="2" Body="&lt;p&gt;There are several solutions discussed here: &lt;a href=&quot;https://github.com/tpope/vim-vinegar/issues/13&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tpope/vim-vinegar/issues/13&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this command to work for my setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType netrw setl bufhidden=delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12516" LastActivityDate="2017-05-05T18:15:42.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12328" PostTypeId="1" CreationDate="2017-05-05T20:30:20.407" Score="3" ViewCount="1787" Body="&lt;p&gt;My university does not (quite understandably) provide administrative rights to users on their public machines (which run only MS Windows 7 OS). As a regular vim user, I use a lot of plugins (particularly latex plugins), and my vimrc uses Vim-Plug for managing plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have got around the problem of using vim partially by using the portable version of gvim from here: &lt;a href=&quot;https://portableapps.com/apps/development/gvim_portable&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://portableapps.com/apps/development/gvim_portable&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to clone and use my personal vimrc from github, and the machines have git installed. I was able to get my generic vim-customisations applied, so it's confirmed that gvim-portable indeed recognises my vimrc. However, vim-plug is not working, and throws up a ton of error messages. (I have manually downloaded vim_plug file and dropped it into &lt;code&gt;drive_letter\gVimPortable\Data\settings\vimfiles\autoload&lt;/code&gt; folder)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get around this issue?&lt;/p&gt;&#xA;" OwnerUserId="8408" LastEditorUserId="1841" LastEditDate="2018-10-09T14:27:59.620" LastActivityDate="2020-12-28T16:47:28.873" Title="Using Vim-Plug with portable version of gvim (windows)" Tags="|gvim|microsoft-windows|plugin-system|plugin-vim-plug|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12330" PostTypeId="1" AcceptedAnswerId="12347" CreationDate="2017-05-06T17:47:19.417" Score="2" ViewCount="123" Body="&lt;p&gt;I like using the CtrlP plugin's &lt;code&gt;CtrlPBuffer&lt;/code&gt; command for quickly switching between buffers, as well as using &lt;code&gt;CtrlP&lt;/code&gt; for navigating to files not yet opened. However, I have one annoyance I'd like to fix. When I use &lt;code&gt;CtrlPBuffer&lt;/code&gt;, it shows a list of files with the filename in the first column and the containing path in the second column. This means when I want to match a file, I need to enter the filename first and then the path. However, for the regular &lt;code&gt;CtrlP&lt;/code&gt; command, this is reversed. I'd like to have this consistent, i.e. that for &lt;code&gt;CtrlPBuffer&lt;/code&gt; I can enter parts of the path before entering parts of the filename. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if my directory tree contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;folder/file.py&#xA;folder2/file.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Entering &lt;code&gt;2f&lt;/code&gt; will match the second file when using &lt;code&gt;CtrlP&lt;/code&gt;, but not when using &lt;code&gt;CtrlPBuffer&lt;/code&gt;. Is there any way to make this work?&lt;/p&gt;&#xA;" OwnerUserId="12520" LastActivityDate="2017-05-09T12:42:57.927" Title="CtrlPBuffer path before filename" Tags="|plugin-ctrlp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12331" PostTypeId="1" CreationDate="2017-05-06T18:40:26.690" Score="0" ViewCount="98" Body="&lt;p&gt;I'm trying to remove instances of the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;add $t1, $zero, 9&#xA;sw $t1, 8($t4) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where 9 could be any number, however 8 is consistent. If I copy this expression in Vim I get: &lt;code&gt;^Iadd $t1, $zero, 9^M^Isw $t1, 8($t4)^M&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course if I want to search and replace (I do) I need to escape the $. I've also tried replacing ^I with \t and ^M with \r, but can't seem to match this expression. I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\tadd \$t1, \$zero, \d\r\tsw \$t1, 8(\$t4)//&#xA;%s/^Iadd \$t1, \$zero, 9^M^Isw \$t1, 8(\$t4)^M//&#xA;%s/\tadd $t1, $zero, 9\r\tsw $t1, 8($t4)//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I can't seem to get anything to match. What am I missing here? Pretty much everything in assembly (MIPS) looks the same, so solving this problem would be quite useful&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried the following:&lt;a href=&quot;https://i.stack.imgur.com/etjdd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/etjdd.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AIbHr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AIbHr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12448" LastEditorUserId="12448" LastEditDate="2017-05-07T15:38:15.480" LastActivityDate="2017-09-04T17:05:19.607" Title="Recognizing expression written in assembly containing $ and new line" Tags="|regular-expression|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12332" PostTypeId="2" ParentId="12331" CreationDate="2017-05-06T18:59:25.393" Score="1" Body="&lt;p&gt;I would recommend using &lt;code&gt;very magic&lt;/code&gt; mode for such searching. &lt;code&gt;^M&lt;/code&gt; is actually &lt;code&gt;\n&lt;/code&gt;, not &lt;code&gt;\r&lt;/code&gt;. I don't see tabs in the provided excerpt, but this seems to work (without tabs):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\vadd \$t1, \$zero, \d\nsw \$t1, 8\(\$t4\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add those &lt;code&gt;\t&lt;/code&gt; if they're present in your text.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-05-06T18:59:25.393" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12333" PostTypeId="2" ParentId="8884" CreationDate="2017-05-07T10:13:09.563" Score="0" Body="&lt;p&gt;Now it's partially possible (adapts to &lt;strong&gt;line&lt;/strong&gt; insertions and deletions &lt;strong&gt;only&lt;/strong&gt;) with NeoVim!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;em&gt;Neovim Newsletter #7 - Summer of Road&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;strong&gt;buffer-local highlighting&lt;/strong&gt; (&lt;code&gt;:help api-highlights&lt;/code&gt;) is similar to &lt;code&gt;matchaddpos()&lt;/code&gt;, with some key differences: it is associated with a buffer and &lt;strong&gt;adapts to line insertions and deletions&lt;/strong&gt;. Useful for linter or semantic highlighter plugins that monitor a buffer for changes and compute highlights in the background.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="8499" LastActivityDate="2017-05-07T10:13:09.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12334" PostTypeId="1" AcceptedAnswerId="12335" CreationDate="2017-05-07T18:44:45.257" Score="5" ViewCount="4085" Body="&lt;p&gt;I added &lt;code&gt;set foldmethod=syntax&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt;, but it automatically folds whenever a new file is opened. Is there a way to prevent auto-folding and just use &lt;code&gt;za&lt;/code&gt; to toggle?&lt;/p&gt;&#xA;" OwnerUserId="7621" LastActivityDate="2017-05-07T19:11:54.760" Title="How to prevent folding when Vim is launched?" Tags="|vimrc|folding|" AnswerCount="1" CommentCount="1" ClosedDate="2017-05-07T19:12:21.940" ContentLicense="CC BY-SA 3.0" />
  <row Id="12335" PostTypeId="2" ParentId="12334" CreationDate="2017-05-07T19:11:54.760" Score="2" Body="&lt;p&gt;As it turns out, I need &lt;code&gt;nofoldenable&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt; too: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=syntax&#xA;set nofoldenable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7621" LastActivityDate="2017-05-07T19:11:54.760" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12338" PostTypeId="2" ParentId="11677" CreationDate="2017-05-08T15:25:26.787" Score="4" Body="&lt;p&gt;As the comments to your post indicate, the best solution to this question is usually to find a different approach, like &lt;a href=&quot;https://github.com/easymotion/vim-easymotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-easymotion&lt;/a&gt;*.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, on the general topic of repeating a normal mode command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;You can execute the command with &lt;code&gt;:norm[al]&lt;/code&gt; and then use &lt;code&gt;@:&lt;/code&gt; to repeat the last command line.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example &lt;code&gt;:norm 4b&lt;/code&gt; and then &lt;code&gt;@:&lt;/code&gt; to keep jumping backwards. If &lt;code&gt;@:&lt;/code&gt; is hard to type on your keyboard, you can remap it to make it more practical:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;. @:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Using &lt;code&gt;&amp;lt;leader&amp;gt;.&lt;/code&gt; may not be a good idea, I haven't tried that particular combination myself.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that for &quot;special&quot; characters (&lt;kbd&gt;Ctrl+F&lt;/kbd&gt;, &lt;kbd&gt;PageUp&lt;/kbd&gt;, &lt;kbd&gt;Enter&lt;/kbd&gt;, etc.) &lt;code&gt;:normal&lt;/code&gt; does not accept keycodes (e.g. &lt;code&gt;&amp;lt;C-F&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;PageUp&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Return&amp;gt;&lt;/code&gt;) so the actual key presses must be inserted which is done by preceding them with &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;. But there is a way to use keycodes as described by &lt;code&gt;:help normal&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An alternative is to use :execute, which uses an expression as argument. This allows the use of printable characters to represent special characters.&#xA;  Example:&#xA;         :exe &quot;normal \&amp;lt;c-w&amp;gt;\&amp;lt;c-w&amp;gt;&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sub&gt;* Why vim-easymotion is called that and not &lt;em&gt;vim-kriskross&lt;/em&gt; will forever remain a mystery to me. After all, it lets you &quot;jump-jump&quot;.&lt;/sub&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="12421" LastEditorUserId="11054" LastEditDate="2017-10-20T00:33:33.353" LastActivityDate="2017-10-20T00:33:33.353" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12339" PostTypeId="2" ParentId="7811" CreationDate="2017-05-08T16:36:22.097" Score="4" Body="&lt;p&gt;If you're using Vim 8 or Neovim, you can use &lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;Asynchronous Lint Engine&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it doesn't work well with Syntastic (&lt;a href=&quot;https://github.com/w0rp/ale/blob/master/test/test_conflicting_plugin_warnings.vader#L30&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ALE conflicts with Syntastic. Uninstall it, or disable this warning with &lt;code&gt;let g:ale_emit_conflict_warnings = 0&lt;/code&gt; in your vimrc file, &lt;em&gt;before&lt;/em&gt; plugins are loaded.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="12540" LastEditorUserId="12540" LastEditDate="2017-06-01T08:19:45.817" LastActivityDate="2017-06-01T08:19:45.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12340" PostTypeId="1" CreationDate="2017-05-08T17:28:46.360" Score="2" ViewCount="114" Body="&lt;p&gt;So I got YouCompleteMe working for python autocompletion. Whenever I use a &lt;code&gt;.&lt;/code&gt; operator such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import sys&#xA;sys.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It shows the correct suggestions. Note that I didn't have to hit &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kn57X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kn57X.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I type the word 'import', it doesn't show any suggestion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cSr5d.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cSr5d.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to hit &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt; in order for it to show the correct suggestion. I want it to automatically suggest without me having to press &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;. Is there a way to fix it? &lt;/p&gt;&#xA;" OwnerDisplayName="user12541" LastEditorUserId="5395" LastEditDate="2017-05-08T19:26:56.337" LastActivityDate="2017-05-08T19:26:56.337" Title="No omnicompletion in Vim for python" Tags="|autocompletion|plugin-you-complete-me|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12342" PostTypeId="1" CreationDate="2017-05-08T22:23:27.973" Score="2" ViewCount="130" Body="&lt;p&gt;&lt;strong&gt;Objective&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want &lt;code&gt;vi file&lt;/code&gt; to act like &lt;code&gt;:find file&lt;/code&gt; if &lt;code&gt;file&lt;/code&gt; doesn't exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, I want to be able to edit a file by name, without giving a path to the file, from the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p a/b/c&#xA;touch a/b/c/foo.py&#xA;&#xA;vi foo.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When there is no file at all, I don't expect this to work. But when a file does exist, I'd like to be able to get there, just as I could with &lt;code&gt;:find foo.py&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have set up my path in a &lt;a href=&quot;https://github.com/thinca/vim-localrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;local vimrc&lt;/a&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let proj_dir = expand('&amp;lt;sfile&amp;gt;:p:h')&#xA;setlocal path=.&#xA;let &amp;amp;path .= ','.proj_dir.'/**'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I added a function in $MYVIMRC:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Find_if_not_exist(path)&#xA;    if ! filereadable(a:path)&#xA;        try&#xA;            execute &quot;:find! &quot;.a:path&#xA;        catch&#xA;        endtry&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And hooked that in with an autocmd in the same file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * call Find_if_not_exist(expand('&amp;lt;afile&amp;gt;'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This almost works. The file gets loaded if it exists. But when Vim opens, the filetype is unset, there is no syntax hilighting, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I just type &lt;code&gt;:e!&lt;/code&gt; again, the reload does get the correct filetype, syntax, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I type &lt;code&gt;:find! file&lt;/code&gt; directly from my keyboard, it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So why does the &lt;code&gt;:find!&lt;/code&gt; executed from inside my autocmd not get the correct behavior, and how can I fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a temporary fix, I've added &lt;code&gt;| do BufRead&lt;/code&gt; to the end of my function, which gets at least some of the problem resolved. But I'd still like to know what's going on, and if there's a smoother way to get the file loaded.&lt;/p&gt;&#xA;" OwnerUserId="6216" LastEditorUserId="6216" LastEditDate="2017-05-08T22:35:20.293" LastActivityDate="2017-05-08T22:35:20.293" Title="Why is filetype not set after :find from autocmd?" Tags="|autocmd|filetype|path|find|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12343" PostTypeId="1" AcceptedAnswerId="12345" CreationDate="2017-05-09T02:02:12.533" Score="1" ViewCount="991" Body="&lt;p&gt;I often want to move and indent code at the same time. Is it possible to do the following.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Original text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: var x = foo();&#xA;2: bar(x);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Desired text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: setTimeout(function(){&#xA;2:     var x = foo();&#xA;3:     bar(x);&#xA;4: });&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Working keystrokes:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Place the cursor on line 1.&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;O&lt;/code&gt; (insert text on the line above) and type the two lines &lt;code&gt;setTimeout(function(){&lt;/code&gt; and &lt;code&gt;});&lt;/code&gt;. Press escape to exit insert mode.&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;3,4&amp;gt; | 3,4m1&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is it possible to condense step 3 into something like the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;3,4&amp;gt;m1&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10101" LastActivityDate="2017-05-09T03:10:25.810" Title="Is it possible to chain multiple ex commands together with a single range?" Tags="|ex-mode|range|rearrangement|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12344" PostTypeId="1" AcceptedAnswerId="12346" CreationDate="2017-05-09T02:04:07.873" Score="2" ViewCount="103" Body="&lt;p&gt;I would like to use &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;H&lt;/kbd&gt; for two different commands, depending on the context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a split left to the currently focused split, focus it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-h&amp;gt; &amp;lt;C-w&amp;gt;h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Otherwise, focus the previous tab:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-h&amp;gt; gT&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I express this condition in my &lt;code&gt;~/.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="3255" LastEditorUserId="3255" LastEditDate="2017-05-09T16:55:10.173" LastActivityDate="2017-05-09T16:55:10.173" Title="Conditionally focus left split or previous tab" Tags="|vimrc|key-bindings|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12345" PostTypeId="2" ParentId="12343" CreationDate="2017-05-09T02:29:41.813" Score="3" Body="&lt;p&gt;Short answer: no.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;code&gt;:global&lt;/code&gt; command to pick some lines to operate&#xA;on, and then give a sequence of commands to operate on those&#xA;selected lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:3,4 g/^/ &amp;gt; | m1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We're only interested in the range, but &lt;code&gt;:g&lt;/code&gt; also wants a pattern.&#xA;So in this case we'll just use &lt;code&gt;/^/&lt;/code&gt; which will always match in a&#xA;line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This however moves each line in sequence which reverses the order&#xA;of the moved lines. A simple way to rectify this is to mark the&#xA;last inserted line (line 2 at this point) before you start the&#xA;&lt;code&gt;:global&lt;/code&gt; and move the indented lines &lt;em&gt;before&lt;/em&gt; it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:k x | 3,4 g/^/ &amp;gt; | m 'x-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could shift each line up by 2, provided you know you've&#xA;inserted exactly 2 new lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:3,4 g/^/ &amp;gt; | m-2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's hardly a condensing of the original command but shows the&#xA;general principle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to indent your lines, and then use the &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt;&#xA;marks, which delimit previously changed text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:3,4&amp;gt; | '[,']m1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This still isn't a condensing, but for more complicated ranges it may be worth&#xA;the effort, and might be your best bet. But maybe for simple edits do the simple thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally: I guess we're talking about general principles here. But in this&#xA;particular case, after your step #2, the Normal mode commands &lt;code&gt;dd&amp;gt;jjp&lt;/code&gt; would&#xA;also achieve the same result.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2017-05-09T03:10:25.810" LastActivityDate="2017-05-09T03:10:25.810" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12346" PostTypeId="2" ParentId="12344" CreationDate="2017-05-09T08:00:26.513" Score="2" Body="&lt;p&gt;One way is to check window number with &lt;code&gt;winnr()&lt;/code&gt;. If number didn't changed, there's nothing to the left any more and previous tab will be selected.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LeftOrPrevTab()&#xA;  let win_no = winnr()&#xA;  wincmd h&#xA;  if win_no == winnr()&#xA;    normal gT&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;C-h&amp;gt; :call LeftOrPrevTab()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-05-09T08:00:26.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12347" PostTypeId="2" ParentId="12330" CreationDate="2017-05-09T12:42:57.927" Score="2" Body="&lt;p&gt;Set &lt;code&gt;ctrlp_bufname_mod&lt;/code&gt; on your .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:ctrlp_bufname_mod = ':p'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can finetune this, check &lt;code&gt;filename-modifiers&lt;/code&gt; in CtrlP docs (&lt;code&gt;:help filename-modifiers&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="4518" LastActivityDate="2017-05-09T12:42:57.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12348" PostTypeId="1" AcceptedAnswerId="12351" CreationDate="2017-05-09T13:17:52.183" Score="2" ViewCount="2933" Body="&lt;p&gt;I am searching a Plugin for autocompletion which does not have any requirements to lua ruby or python. &#xA;I would love to use YouCompleteMe but it requires python, which is not availiable on my server. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At all vim there does not have lua, python or ruby support, which makes it really hard to find anything. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe there is something written in Go like for example fzf, which could be easily added to vim without sudo permission. &lt;/p&gt;&#xA;" OwnerUserId="12519" LastActivityDate="2017-05-09T16:06:36.890" Title="Autocompletion Plugin for VIM without external requirements" Tags="|autocompletion|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12349" PostTypeId="1" CreationDate="2017-05-09T13:20:23.453" Score="3" ViewCount="205" Body="&lt;p&gt;I want to automate certain text manipulation (essentially writing a plugin), but for easiness, I wish to minimize the use of Vim script whenever possible.&#xA;This is because, indeed it is much harder to look for a documentation for writing something in Vim script, than in a well-established script language in any sort, Python, Lua, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus I am not sure what the best method is, to call an external binary or script that modifies the current buffer.&#xA;For concreteness, let me say that I want to remove all newlines in the current buffer.&#xA;Surely this can be done by a simple replacement, but for sake of illustration let me implement it in Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;remove_newline.py&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python&#xA;&#xA;import os # to get path name&#xA;import sys # to get CLI arguments&#xA;&#xA;srcPath = os.path.realpath(__file__)&#xA;dirPath = os.path.dirname(srcPath)&#xA;dataPath = dirPath + &quot;/&quot; + sys.argv[1]&#xA;&#xA;myFile=open(dataPath,'r')&#xA;content = myFile.read()&#xA;myFile.close()&#xA;&#xA;content = content.replace(&quot;\n&quot;, &quot;&quot;)&#xA;&#xA;myFile=open(dataPath,'w')&#xA;myFile.write(content)&#xA;myFile.close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when editing, say, &lt;code&gt;test.txt&lt;/code&gt;, run this line in Vim: (of course I can choose a shorter name)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cabbrev remove_newline :! ./replace.py %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I can simply run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:remove_newline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I see several problems in this approach:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The buffer has to be saved in advance, otherwise there is a warning &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;W12: Warning: File &quot;test.txt&quot; has changed and the buffer was changed in Vim as well&#xA;See &quot;:help W12&quot; for more info.&#xA;[O]K, (L)oad File, Load (A)ll, (I)gnore All: &quot;test.txt&quot; &quot;test.txt&quot; [noeol] 1L, 5C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Such warning is understandable, but it is cumbersome to save file every time before I hit my shortcut. Calling an external script this way is not seamlessly integrated with the i/o action of buffer, but considered an alien action.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I want to open a new tab that temporary holds error message, but don't know how to connect the std i/o into a new Vim buffer.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I want to select text and, upon hitting my shortcut, only replace selected text. But I don't know how to specify location selected in Vim, into called script.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Or maybe my intention is not suitable to implement in Vim? I know very little about plugins. It seems Youcompleteme is written in Python, but it remains overwhelming of me to find where Vim &quot;communicates&quot; with Python in the Repo (which is all I have to know for present purpose).&lt;/p&gt;&#xA;" OwnerUserId="10241" LastActivityDate="2017-05-09T15:06:48.580" Title="Text manipulation by calling external binaries or scripts" Tags="|vimscript|external-command|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12350" PostTypeId="2" ParentId="12349" CreationDate="2017-05-09T15:06:48.580" Score="4" Body="&lt;p&gt;You can &lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#filter&quot; rel=&quot;nofollow noreferrer&quot;&gt;filter&lt;/a&gt; (part of) a buffer through an external command by using &lt;code&gt;:{range}!{command}&lt;/code&gt;.  The range of the buffer written to the external command is replaced by the output of the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you rewrote your Python script to read from stdin and write to stdout, then you would just run &lt;code&gt;:%!./replace.py&lt;/code&gt; or visually select a few lines and use &lt;code&gt;:'&amp;lt;,'&amp;gt;!./replace.py&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As far as your specific example, you can do this using standard tools.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%!tr -d '\n'&lt;/code&gt; will delete all newlines.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-05-09T15:06:48.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12351" PostTypeId="2" ParentId="12348" CreationDate="2017-05-09T16:01:32.193" Score="2" Body="&lt;p&gt;Try vim-µcomplete &lt;a href=&quot;https://github.com/lifepillar/vim-mucomplete&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/lifepillar/vim-mucomplete&lt;/a&gt;. It is a minimalistic autocompletion plugin, written in VimL.  &lt;/p&gt;&#xA;" OwnerUserId="11077" LastActivityDate="2017-05-09T16:01:32.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12352" PostTypeId="2" ParentId="12348" CreationDate="2017-05-09T16:06:36.890" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/prabirshrestha/asyncomplete.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Asyncomplete&lt;/a&gt; is a fork of &lt;a href=&quot;https://github.com/roxma/nvim-completion-manager&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neovim Completion Manager&lt;/a&gt; that works on Vim 8 and removed the Python dependency.&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2017-05-09T16:06:36.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12353" PostTypeId="1" CreationDate="2017-05-09T17:18:22.570" Score="2" ViewCount="123" Body="&lt;p&gt;I wanted vim to increase its &lt;code&gt;&amp;amp;columns&lt;/code&gt; automatically when I do a &lt;code&gt;:vsplit&lt;/code&gt;, so I implemented the advice found here: &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_use/R4gg-YdPHJM&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://groups.google.com/forum/#!topic/vim_use/R4gg-YdPHJM&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, you add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd WinEnter * if winwidth(0) &amp;lt; 80 | set columns+=80 | wincmd = | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in terminal vim, I opened 3 windows side-by-side, and the &lt;code&gt;&amp;amp;columns&lt;/code&gt; increased beyond the size of my terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;columns + 79 &amp;gt; $COLUMNS | set columns=$COLUMNS | else | set columns+=79 | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it didn't work, saying, &quot;&lt;code&gt;Number required after =: columns=$COLUMNS&lt;/code&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get &lt;code&gt;&amp;amp;columns&lt;/code&gt; to increase but only up to a maximum of the &lt;code&gt;$COLUMNS&lt;/code&gt; environment variable?&lt;/p&gt;&#xA;" OwnerUserId="2511" LastEditorUserId="1841" LastEditDate="2017-08-08T06:55:37.977" LastActivityDate="2017-08-08T19:44:23.510" Title="Automatically increase &amp;columns upon :vsplit, but not beyond maximum" Tags="|autocmd|terminal|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12354" PostTypeId="2" ParentId="12353" CreationDate="2017-05-09T18:29:55.997" Score="1" Body="&lt;p&gt;&lt;code&gt;COLUMNS&lt;/code&gt; is a shell variable, not an environmental variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This exports COLUMNS before invoking vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vim='export COLUMNS;vim $*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the value of the exported &lt;code&gt;COLUMNS&lt;/code&gt; variable won't be updated if you resize your terminal window while you are running vim.&lt;/p&gt;&#xA;" OwnerUserId="12113" LastActivityDate="2017-05-09T18:29:55.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12355" PostTypeId="2" ParentId="12353" CreationDate="2017-05-09T18:40:53.243" Score="1" Body="&lt;p&gt;&lt;strong&gt;Gets the terminal's columns directly without using an environmental variable&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let cols = system('tput cols')&#xA;if &amp;amp;columns + 79 &amp;gt; cols | set columns=cols | else | set columns+=79 | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12113" LastEditorUserId="12113" LastEditDate="2017-08-08T19:44:23.510" LastActivityDate="2017-08-08T19:44:23.510" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12356" PostTypeId="1" CreationDate="2017-05-09T20:34:26.083" Score="0" ViewCount="520" Body="&lt;p&gt;I recently started out with gVim 8 for windows and i noticed that the higher end plugins that provide more functionality require python support or something like that. But for some reason i am not able to make them work , for example i have recently installed MuComplete but when i try using it on a python file i am told : &quot;Sorry , this command is disabled , the Python's site module could not be loaded&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim version was compiled with +python and +python3 and i have tried installing only python 3 , then only python 2 and now i have both. I tried playing around trying to set the PythonThreedDll and the PythonDll options according to my python version , adding the folders to path and since i could not find the python27.dll i downloaded one of the internet and it still didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can i fix that ?&lt;/p&gt;&#xA;" OwnerUserId="12531" LastEditorUserId="5395" LastEditDate="2017-05-09T20:45:49.473" LastActivityDate="2017-05-11T14:34:39.490" Title="No python support" Tags="|microsoft-windows|vimscript-python|" AnswerCount="1" CommentCount="1" ClosedDate="2017-05-11T21:21:01.957" ContentLicense="CC BY-SA 3.0" />
  <row Id="12357" PostTypeId="1" AcceptedAnswerId="12361" CreationDate="2017-05-10T14:00:51.677" Score="1" ViewCount="85" Body="&lt;p&gt;I'm writing an XML document where I frequently produce markup like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;We can exit Terminal mode by pressing &amp;lt;keystroke&amp;gt;&amp;amp;lt;C-\&amp;amp;gt;&amp;amp;lt;C-n&amp;amp;gt;&amp;lt;/keystroke&amp;gt;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to define an UltiSnips snippet to help with producing &lt;code&gt;&amp;lt;keystroke&amp;gt;&lt;/code&gt; tags like this.&#xA;Ideally, I'd be able to type (where &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; expands the snippet, and &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; jumps to the next tabstop):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;keystroke&amp;lt;tab&amp;gt;&amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&amp;lt;C-j&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and have it output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;keystroke&amp;gt;&amp;amp;lt;C-\&amp;amp;gt;&amp;amp;lt;C-n&amp;amp;gt;&amp;lt;/keystroke&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to create a snippet for UltiSnips that behaves this way?&lt;/p&gt;&#xA;" OwnerUserId="10929" LastActivityDate="2017-05-11T14:08:11.267" Title="Make UltiSnips perform XML encoding on tabstop text" Tags="|plugin-ultisnips|filetype-xml|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12358" PostTypeId="1" CreationDate="2017-05-10T14:53:28.557" Score="7" ViewCount="152" Body="&lt;p&gt;When I prefix the J (&quot;join&quot;) command with a count, Vim is joining one fewer line than I expect. For example, with the cursor at the first column, first line of the following,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;one&#xA;two&#xA;three&#xA;four&#xA;five&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if I type &lt;kbd&gt;J&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt; (four J's), I get (as expected):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;one two three four five&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if instead I type &lt;kbd&gt;4&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt;, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;one two three four&#xA;five&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks like J=1J=2J, 3J=JJ, 4J=JJJ, and so on. Is this the expected behavior?&lt;/p&gt;&#xA;" OwnerUserId="12559" LastEditorUserId="343" LastEditDate="2017-12-06T11:25:06.823" LastActivityDate="2019-12-22T15:45:33.823" Title="Unexpected behavior using &quot;&lt;count&gt;J&quot; to join multiple lines" Tags="|repeated-commands|count|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12359" PostTypeId="2" ParentId="12358" CreationDate="2017-05-10T15:23:18.853" Score="7" Body="&lt;p&gt;After further research and office discussion, I realize this is indeed the expected behavior. According to the vim help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;J    Join [count] lines, with a minimum of two lines.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've always thought &lt;code&gt;[count][command]&lt;/code&gt; was literally another way to type &lt;code&gt;[command]&lt;/code&gt; repeated &lt;code&gt;[count]&lt;/code&gt; times. Turns out commands are free to interpret &lt;code&gt;[count]&lt;/code&gt; as they like, and &lt;code&gt;J&lt;/code&gt; takes it to mean the number of lines that will be joined; this explains why &lt;code&gt;1J&lt;/code&gt; and &lt;code&gt;2J&lt;/code&gt; have the same effect.&lt;/p&gt;&#xA;" OwnerUserId="12559" LastEditorUserId="10604" LastEditDate="2019-12-22T15:45:33.823" LastActivityDate="2019-12-22T15:45:33.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12360" PostTypeId="2" ParentId="12358" CreationDate="2017-05-10T15:26:47.003" Score="2" Body="&lt;p&gt;It is the described behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help J&lt;/code&gt; states&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Join [count] lines, with a minimum of two lines&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="2736" LastEditDate="2017-05-11T02:11:08.990" LastActivityDate="2017-05-11T02:11:08.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12361" PostTypeId="2" ParentId="12357" CreationDate="2017-05-10T21:17:54.453" Score="1" Body="&lt;p&gt;Using regular expression snippet it's possible to achieve this. Following snippet works almost ideally:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet &quot;keystroke([^&amp;gt;]\S+)?&quot; &quot;Adds keystroke&quot; r&#xA;&amp;lt;keystroke&amp;gt;`!p snip.rv = (match.group(1) or &quot;&quot;).replace(&quot;&amp;lt;&quot;, &quot;&amp;amp;lt;&quot;).replace(&quot;&amp;gt;&quot;, &quot;&amp;amp;gt;&quot;)`&amp;lt;/keystroke&amp;gt;$0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works after you enter all the key sequences, for example: &lt;code&gt;keystroke&amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&lt;/code&gt;&lt;kbd&gt;Tab&lt;/kbd&gt; will result in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;keystroke&amp;gt;&amp;amp;lt;C-\&amp;amp;gt;&amp;amp;lt;C-n&amp;amp;gt;&amp;lt;/keystroke&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the cursor position after &lt;code&gt;&amp;lt;/keystroke&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="10929" LastEditDate="2017-05-11T14:08:11.267" LastActivityDate="2017-05-11T14:08:11.267" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12362" PostTypeId="1" AcceptedAnswerId="12474" CreationDate="2017-05-10T23:53:59.317" Score="1" ViewCount="865" Body="&lt;p&gt;I recently switched to macvim, Everything work perfectly apart from the &lt;code&gt;:shell&lt;/code&gt; command, which produces weird output, I tried few solutions but noting seems to me working out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;:shell&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\n\w\n\u $ [72004h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Solutions that I already tried. I add this to my .zshrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [ $TERM == 'dumb' ]; then&#xA;   echo 'frrank MacVim'&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [ $TERM == 'dumb' ]; then&#xA;   # no colors&#xA;   export PS1=&quot;\n\w\n\u $ &quot;&#xA;else&#xA;   # colors&#xA;   export PS1=&quot;\n\[\033[32m\]\w\n\[\033[1;31m\]\[\033[1;36m\]\u\[\033[0m\] $ \[\033[0m\]&quot;&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6185" LastEditorUserId="51" LastEditDate="2017-05-24T15:05:05.550" LastActivityDate="2017-05-24T15:15:11.590" Title="Macvim shell command not working as expected" Tags="|gvim|terminal|macvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12363" PostTypeId="1" CreationDate="2017-05-11T07:06:24.967" Score="0" ViewCount="771" Body="&lt;p&gt;I am new to using plugins with Vim. I mostly work with rails, ruby, latex and html code. I have already installed &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt; and &lt;a href=&quot;https://github.com/honza/vim-snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-snippets&lt;/a&gt; plugins using pathogen. I would like corresponding snippets files to be available while I work with these file types. I have tried &lt;code&gt;:UltiSnipsAddFiletypes rails&lt;/code&gt; which works perfectly, and would like to place &lt;code&gt;:UltiSnipsAddFiletypes rails.ruby.latex.html&lt;/code&gt; in &lt;code&gt;ftplugin/rails.vim&lt;/code&gt; as ultisnips documentation mentions&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The UltiSnipsAddFiletypes command allows for explicit merging of other snippet filetypes for the current buffer. For example, if you edit a .rst file but also want the Lua snippets to be available you can issue the command &gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   :UltiSnipsAddFiletypes rst.lua&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;using the dotted filetype syntax. Order is important, the first filetype in this list will be the one used for UltiSnipsEdit and the list is&#xA;  ordered by evaluation priority. Consequently, you might add this to your&#xA;  &lt;code&gt;ftplugin/rails.vim&lt;/code&gt; &gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   :UltiSnipsAddFiletypes rails.ruby&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The problem is that I cannot find any file named &lt;code&gt;rails.vim&lt;/code&gt;.&lt;/strong&gt;&lt;br&gt;&#xA;&lt;strong&gt;Update:&lt;/strong&gt;&#xA;Since only some snippets are expanding while other are not I think the problem is with how I have setup plugins on my system. Here is how &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;vimrc&lt;/code&gt; have been setup:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call pathogen#infect()&#xA;set runtimepath+=~/.vim/bundle/ultisnips&#xA;set nocompatible&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsListSnippets=&quot;&amp;lt;s-tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;s-j&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;s-k&amp;gt;&quot;&#xA;let g:UltiSnipsEditSplit=&quot;vertical&quot;&#xA;let g:UltiSnipsSnippetDirectories=[&quot;vim-snippets&quot;, &quot;Ultisnips&quot;]  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.vim/bundle&lt;/code&gt; folder contains the cloned git repos &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;ultisnips&lt;/a&gt; and &lt;a href=&quot;https://github.com/honza/vim-snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-snippets&lt;/a&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also symlinked &lt;code&gt;ftdetect&lt;/code&gt; as suggested in the installation section of ultisnips documentation. I am using vim 7.4. I would be grateful to the community for their help. &lt;/p&gt;&#xA;" OwnerUserId="8537" LastEditorUserId="8537" LastEditDate="2017-05-11T12:23:41.687" LastActivityDate="2017-08-09T14:15:35.660" Title="tex and rails snippets do not expand in ultisnips?" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12364" PostTypeId="2" ParentId="12363" CreationDate="2017-05-11T09:23:52.473" Score="1" Body="&lt;p&gt;&lt;code&gt;UltiSnipsAddFiletypes&lt;/code&gt; is not creating any files. It just informs UltiSnips that when you edit for example a &lt;code&gt;rails&lt;/code&gt; file, you also want snippets from file type &lt;code&gt;html&lt;/code&gt; and/or &lt;code&gt;ruby&lt;/code&gt; and/or &lt;code&gt;javascript&lt;/code&gt; and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you run command &lt;code&gt;:UltiSnipsAddFiletypes rails.ruby.html.javascript&lt;/code&gt; then it's important what file type is first (&lt;code&gt;rails&lt;/code&gt; in this example) - this will be used in &lt;code&gt;UltiSnipsEdit&lt;/code&gt; command as a file type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can't find any file named &lt;code&gt;rails.vim&lt;/code&gt;, that's because UltiSnips creates and uses files with &lt;code&gt;.snippets&lt;/code&gt; file extension - check out what's inside &lt;a href=&quot;https://github.com/honza/vim-snippets/tree/master/UltiSnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnip folder of vim-snippets plugin&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update after OP edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you're using Pathogen, you don't need line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath+=~/.vim/bundle/ultisnips&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as well as that &lt;code&gt;ftdetect&lt;/code&gt; symlink.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsSnippetDirectories=[&quot;vim-snippets&quot;, &quot;Ultisnips&quot;] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This may be the problem. As described in &lt;code&gt;:h UltiSnips-snippet-search-path&lt;/code&gt;, this variable is used for subfolders that are contained in direcotries in &lt;code&gt;runtimepath&lt;/code&gt;, so &lt;code&gt;vim-snippets&lt;/code&gt; is actually a folder in &lt;code&gt;runtimepath&lt;/code&gt; that contains &lt;code&gt;snippets&lt;/code&gt; and &lt;code&gt;UltiSnips&lt;/code&gt; subfolders which have &lt;code&gt;snippet&lt;/code&gt; files. I think that you can remove that line, as it defaults to &lt;code&gt;[&quot;UltiSnips&quot;]&lt;/code&gt; (please also note the capital &lt;code&gt;S&lt;/code&gt; letter).&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2017-05-11T12:40:23.003" LastActivityDate="2017-05-11T12:40:23.003" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12365" PostTypeId="1" CreationDate="2017-05-11T12:00:13.470" Score="5" ViewCount="180" Body="&lt;p&gt;I regularly use Vim to write Ruby code, which allows &lt;code&gt;!&lt;/code&gt; as part of method identifiers and also uses it as logical negation. Currently, I configure &lt;code&gt;iskeyword&lt;/code&gt; to include &lt;code&gt;!&lt;/code&gt; (using &lt;code&gt;autocmd Filetype ruby set iskeyword+=\!&lt;/code&gt;) so that method name &quot;words&quot; include the &lt;code&gt;!&lt;/code&gt;. For example, in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo!&#xA;  puts &quot;foo was called&quot;&#xA;end&#xA;&#xA;foo!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if my cursor is on any part of &lt;code&gt;foo!&lt;/code&gt; on the first line, hitting &lt;kbd&gt;*&lt;/kbd&gt; will jump to the next occurrence (i.e. the call site). This works well, however, Ruby also uses &lt;code&gt;!&lt;/code&gt; for negation, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def some_condition&#xA;  true&#xA;end&#xA;&#xA;!some_condition ? 'it was false' : 'it was true'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and if I hit &lt;kbd&gt;*&lt;/kbd&gt; on the callsite (&lt;code&gt;!some_condition&lt;/code&gt;) then Vim searches for &lt;code&gt;!some_condition&lt;/code&gt; since &lt;code&gt;!&lt;/code&gt; is included in &lt;code&gt;iskeyword&lt;/code&gt; and thus doesn't find the method definition. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I'd like to able to tell Vim &quot;treat &lt;code&gt;!&lt;/code&gt; as part of a keyword, only if it appears at the &lt;em&gt;end&lt;/em&gt; of a word&quot; so that I can search for both of my examples: method names that end in &lt;code&gt;!&lt;/code&gt;, and methods that are negated with a leading &lt;code&gt;!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From searching the docs and Google, I don't think there is a way to this, but I'd appreciate any ideas!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it matters, I'm using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:42:57)&#xA;Included patches: 1-52&#xA;Extra patches: 8.0.0056&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12573" LastEditorUserId="5395" LastEditDate="2017-05-11T12:13:51.687" LastActivityDate="2019-10-24T07:31:47.760" Title="Possible to use `!` in `iskeyword`, but only at the end of a word?" Tags="|filetype-ruby|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12366" PostTypeId="1" AcceptedAnswerId="12372" CreationDate="2017-05-11T13:25:19.003" Score="6" ViewCount="303" Body="&lt;p&gt;I frequently use the &lt;kbd&gt;&amp;gt;&lt;/kbd&gt;&lt;kbd&gt;8&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; and &lt;kbd&gt;&amp;gt;&lt;/kbd&gt;&lt;kbd&gt;8&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; commands to indent several lines at once. Using &lt;kbd&gt;j&lt;/kbd&gt;, the lines are indented and my cursor stays at the first line.&lt;/p&gt;&#xA;&lt;p&gt;When I use &lt;kbd&gt;k&lt;/kbd&gt;, the lines are indented, but my cursor gets moved to the first line.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to use &lt;kbd&gt;&amp;gt;&lt;/kbd&gt;&lt;kbd&gt;8&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; without the cursor moving up?&lt;/p&gt;&#xA;&lt;h3&gt;EDIT&lt;/h3&gt;&#xA;&lt;p&gt;I've found this question&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/8059/why-does-operator-motion-behave-inconsistently&quot;&gt;Why does &amp;quot;Operator&amp;quot; + &amp;quot;Motion&amp;quot; behave inconsistently?&lt;/a&gt; which explains why this happens. Is there a way to automatically append an &lt;kbd&gt;8&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;?&lt;/p&gt;&#xA;" OwnerUserId="12576" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-05-11T18:45:40.657" Title="Indent Lines Up Without Moving" Tags="|indentation|cursor-movement|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12367" PostTypeId="1" CreationDate="2017-05-11T13:58:51.950" Score="2" ViewCount="369" Body="&lt;p&gt;Is there a &lt;code&gt;syntime&lt;/code&gt; equivalent &lt;strong&gt;global command&lt;/strong&gt; that can track the overall Vim performance? I am having trouble debugging the cause for a set of very-slow file-operations on a Windows machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since these operations are done in an active Vim session, the following syntax that tracks only file-opening events are not enough:&#xA;&lt;code&gt;gvim --startuptime d:\timelog.log the_file&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2398" LastEditorUserId="5395" LastEditDate="2017-05-11T14:01:26.750" LastActivityDate="2017-05-13T13:14:49.007" Title="How to track time-expenditure for Vim operations?" Tags="|vimscript|gvim|microsoft-windows|performance|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12368" PostTypeId="2" ParentId="12356" CreationDate="2017-05-11T14:17:15.730" Score="0" Body="&lt;p&gt;Are you using CMD or Power shell?  if you are using command prompt first switch to power shell and see if the problem is solved or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not check your .vim or \vim in windows directory if you can find vimrc or .vimrc files if both are there delete vimrc and keep .vimrc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last but not the least read this &lt;a href=&quot;https://realpython.com/blog/python/vim-and-python-a-match-made-in-heaven/&quot; rel=&quot;nofollow noreferrer&quot;&gt;blog&lt;/a&gt; for setting up vim for python.just change . with \ as windows directory structure is different. &lt;/p&gt;&#xA;" OwnerUserId="6185" LastEditorUserId="6185" LastEditDate="2017-05-11T14:34:39.490" LastActivityDate="2017-05-11T14:34:39.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12371" PostTypeId="2" ParentId="11857" CreationDate="2017-05-11T17:33:36.813" Score="0" Body="&lt;p&gt;I managed to solve the problem by using exactly &lt;em&gt;make install&lt;/em&gt; instead of &lt;em&gt;checkinstall&lt;/em&gt;, unlike it is advised in &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&quot; rel=&quot;nofollow noreferrer&quot;&gt;the tutorial&lt;/a&gt;. Though it is said there that &lt;em&gt;checkinstall&lt;/em&gt; is preferable as it allows for easier further deinstallation of the package, as for now I have not noticed any problems with package management - all updates run smoothly, and vim does not cause any troubles as well. &lt;/p&gt;&#xA;" OwnerUserId="11893" LastActivityDate="2017-05-11T17:33:36.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12372" PostTypeId="2" ParentId="12366" CreationDate="2017-05-11T18:45:40.657" Score="5" Body="&lt;p&gt;The biggest problem you're going to have is that apparently the &lt;code&gt;&amp;gt;&lt;/code&gt; command doesn't set the jumplist (although I'm not sure why). We can hack it so that it does, but this is a little heavy handed so take it with a grain of salt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically we can do this with a couple of remappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;gt; m'&amp;gt;&#xA;nnoremap &amp;lt; m'&amp;lt;&#xA;onoremap &amp;lt;expr&amp;gt; k v:operator =~ '&amp;gt;\\|&amp;lt;' ? 'k``' : 'k'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first two lines simply make the &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; commands set the jump list&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;onoremap&lt;/code&gt; Create a non-recursive &quot;&lt;a href=&quot;http://vimhelp.appspot.com/intro.txt.html#Operator-pending&quot; rel=&quot;noreferrer&quot;&gt;operator-pending&lt;/a&gt;&quot; mapping&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; Allow us to use an expression in the mapping&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;k&lt;/code&gt; Map k&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v:operator&lt;/code&gt; The command used to enter operator-pening mode. (In our case &lt;code&gt;&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;=~ '&amp;gt;\\|&amp;lt;'&lt;/code&gt; Only match if the operator is &lt;code&gt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'k``' : 'k'&lt;/code&gt; If the mapping was a &lt;code&gt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;gt;&lt;/code&gt;, then jump back one in the jump list after executing &lt;code&gt;k&lt;/code&gt;. Otherwise just execute &lt;code&gt;k&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/intro.txt.html#Operator-pending&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help Operator-pending&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap-%3Cexpr%3E&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :map-&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#v%3Aoperator&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help v:operator&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-05-11T18:45:40.657" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12373" PostTypeId="2" ParentId="10188" CreationDate="2017-05-11T22:14:42.713" Score="1" Body="&lt;p&gt;Coming back to this problem after a long hiatus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to switch from &quot;word list&quot; format to Myspell format, and define '_' as a mid-word character by putting the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MIDWORD _&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the .aff file, along with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RARE ?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to specify that (for example) '?' will be used to flag &quot;rare&quot; words in the .dic file.&lt;/p&gt;&#xA;" OwnerUserId="10008" LastActivityDate="2017-05-11T22:14:42.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12374" PostTypeId="1" CreationDate="2017-05-11T22:36:41.723" Score="8" ViewCount="2718" Body="&lt;p&gt;I use Vim 7.4.576 on debian8.&#xA;I don't grasp the concept of deleting words backwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some text. Cursor position is on &quot;that&quot; (the pipe symbol)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is a new text on th|at line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I delete the previous words, so as a result the sentence will look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is a line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this the best solution? &lt;kbd&gt;b&lt;/kbd&gt;&lt;kbd&gt;4&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;......or is there a shorter way, so that i can skip the first &lt;kbd&gt;b&lt;/kbd&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="12582" LastEditorUserId="5395" LastEditDate="2017-05-12T07:38:30.377" LastActivityDate="2017-05-12T19:29:25.927" Title="delete words backwards" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12375" PostTypeId="2" ParentId="12374" CreationDate="2017-05-11T22:44:30.103" Score="8" Body="&lt;p&gt;You can use &lt;code&gt;b&lt;/code&gt; as a motion for the delete instead of the &lt;code&gt;w&lt;/code&gt; to delete backwards.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;w4db&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/intro.txt.html#%7Bmotion%7D&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help {motion}&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-05-11T22:44:30.103" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12376" PostTypeId="1" CreationDate="2017-05-12T05:03:06.737" Score="15" ViewCount="9917" Body="&lt;p&gt;While using WSL/Bash for Windows I want to be able to use &lt;code&gt;y&lt;/code&gt; &lt;code&gt;yy&lt;/code&gt; &lt;code&gt;3y&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt; the same way they always work in vim, but connecting to the system clipboard shared by all apps, not to vim's internal clipboard... I already have ditto to manage clipboard history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that Vim already has a built in option to synchronize the copy/paste buffer with the system clipboard... Yet the problem when running WSL is that you actually need to use &lt;code&gt;/mnt/c/Windows/System32/clip.exe&lt;/code&gt; to access the clipboard... So even though I would like to be able to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard^=unnamed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't seem to have WSL support yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand the neovim does have this as an option, but I don't really want to experiment with neovim right now...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now, the closest thing to a workaround that I've found is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;y :call system('/mnt/c/Windows/System32/clip.exe', @0)&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;y :call system('/mnt/c/Windows/System32/clip.exe', @0)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this is a really horrible solution in my opinion... It makes copying a two-steps process...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course I can do some copy and paste with the mouse/shift+ins, yet I think there must be a way to get this synchronization to work properly in Vim.&lt;/p&gt;&#xA;" OwnerUserId="12587" LastEditorUserId="23502" LastEditDate="2023-04-04T05:44:44.360" LastActivityDate="2023-04-04T05:44:44.360" Title="Vim on WSL: synchronize system clipboard? (set clipboard^=unnamed)?" Tags="|cut-copy-paste|microsoft-windows|os-clipboard|wsl|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12377" PostTypeId="1" AcceptedAnswerId="12378" CreationDate="2017-05-12T05:23:19.143" Score="6" ViewCount="1762" Body="&lt;p&gt;I'm having trouble configuring Vim on Manjaro:&lt;/p&gt;&#xA;&lt;p&gt;After setting &lt;code&gt;syntax on&lt;/code&gt; at &lt;code&gt;.vimrc&lt;/code&gt; file, I make a Prolog program (&lt;code&gt;bug.pl&lt;/code&gt;) which shows no syntax highlight:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nhrxX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nhrxX.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But after I append &lt;code&gt;/**/&lt;/code&gt; to top of file (then quit and restart vim), highlighting somehow works:&lt;/p&gt;&#xA;&lt;p&gt;(&lt;code&gt;/**/&lt;/code&gt; is comment in Prolog, same like that of C)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/T29ch.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T29ch.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So how do I have highlight without that useless &lt;code&gt;/**/&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;DISTRIB_ID=ManjaroLinux&lt;/p&gt;&#xA;&lt;p&gt;DISTRIB_RELEASE=17.0.1&lt;/p&gt;&#xA;&lt;p&gt;DISTRIB_CODENAME=Gellivara&lt;/p&gt;&#xA;&lt;p&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar  6 2017 14:13:23)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&lt;p&gt;Suggested by grodzik, it's about filetype conflict.&lt;/p&gt;&#xA;&lt;p&gt;I fix it by adding &lt;code&gt;au FileType perl set filetype=prolog&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt;. (Make sure it's &lt;strong&gt;AFTER&lt;/strong&gt; &lt;code&gt;syntax on&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Now I see highlight.&lt;/p&gt;&#xA;" OwnerUserId="12588" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2023-03-31T08:17:32.023" Title="Syntax highlight fail for Prolog files" Tags="|syntax-highlighting|filetype|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12378" PostTypeId="2" ParentId="12377" CreationDate="2017-05-12T07:55:31.043" Score="3" Body="&lt;p&gt;This is because by default a file with extension &lt;code&gt;.pl&lt;/code&gt; is for Perl files.&#xA;If you open your file, when there is no &lt;code&gt;/**/&lt;/code&gt; on first line and run command &lt;code&gt;:set filetype?&lt;/code&gt;, it will show &lt;code&gt;perl&lt;/code&gt;, not &lt;code&gt;prolog&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you add &lt;code&gt;/**/&lt;/code&gt; on the first line, than there is probably some code inside Vim's standard distribution, that detects that and sets file type as &lt;code&gt;prolog&lt;/code&gt; - again, check it with &lt;code&gt;:set filetype?&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you know that you won't need &lt;code&gt;perl&lt;/code&gt; syntax highlighting, than you can add to &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType perl set filetype=prolog&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but rember, that this will disable &lt;code&gt;perl&lt;/code&gt; file type for good. I think that better way is to prepend a file with that &lt;code&gt;/**/&lt;/code&gt;, and let Vim detect the correct file type.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-05-12T07:55:31.043" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12379" PostTypeId="1" CreationDate="2017-05-12T08:29:56.093" Score="5" ViewCount="183" Body="&lt;p&gt;I edit R-markdown files a lot, and this entails writing inline code blocks, such as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`r sum(mylongvectorname)`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I usually have my text hard-wrapped at 80 chars, and this causes problems for the inline blocks, since they aren't allowed to split. I found the answer for &lt;a href=&quot;https://vi.stackexchange.com/questions/564/prevent-vim-from-breaking-up-links-mid-tag-in-markdown/649#649&quot;&gt;this question&lt;/a&gt; helpful in preventing the split from happening when writing in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I want to wrap a paragraph in normal mode with  &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;, the r inline code is split. Is there any solution that would allow me to wrap the paragraph by &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; and &lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) leave the lines with `r .* ` untouched &lt;/p&gt;&#xA;&#xA;&lt;p&gt;or (better)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) treat  `r .* ` as a single word so that if it is moved, the whole block is moved together&lt;/p&gt;&#xA;" OwnerUserId="7784" LastEditorUserId="1841" LastEditDate="2017-05-12T09:38:06.000" LastActivityDate="2017-05-12T09:38:06.000" Title="Prevent Vim from breaking up inline code blocks in (r)markdown" Tags="|wrapping|filetype-markdown|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12380" PostTypeId="1" AcceptedAnswerId="12391" CreationDate="2017-05-12T14:47:06.033" Score="0" ViewCount="1375" Body="&lt;p&gt;So, for example in &lt;code&gt;tmux&lt;/code&gt; you can hold &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;b&lt;/kbd&gt; and move the separation line with the arrow keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to do this with NERDTree without using a longer, somewhat discrete command every time?&lt;/p&gt;&#xA;" OwnerUserId="12525" LastEditorUserId="4472" LastEditDate="2017-09-14T18:44:00.780" LastActivityDate="2017-09-14T18:44:00.780" Title="How to change NERDTree plugin window continuously" Tags="|plugin-nerdtree|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12381" PostTypeId="2" ParentId="12374" CreationDate="2017-05-12T19:29:25.927" Score="1" Body="&lt;p&gt;You can also go to insert mode and type &lt;code&gt;ctrl + wwww&lt;/code&gt;. Not sure if it will work with gvim. Useful if you are already in insert mode&lt;/p&gt;&#xA;" OwnerUserId="166" LastActivityDate="2017-05-12T19:29:25.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12382" PostTypeId="1" AcceptedAnswerId="12383" CreationDate="2017-05-12T19:42:00.337" Score="2" ViewCount="781" Body="&lt;p&gt;From within an existing Vim session, I am looking for a technique to achieve the equivalent of &lt;code&gt;-o file1 file2 file3&lt;/code&gt;.  The &lt;code&gt;:sp[lit]&lt;/code&gt; command just seems to create a single new split--it doesn't allow for opening multiple splits simultaneously.  It seems like this should be possible, but I haven't been able to find a solution.&lt;/p&gt;&#xA;" OwnerUserId="11620" LastActivityDate="2017-05-12T20:01:10.020" Title="Open multiple files in split mode from within Vim (not command-line)" Tags="|split|multiple-files|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12383" PostTypeId="2" ParentId="12382" CreationDate="2017-05-12T20:01:10.020" Score="3" Body="&lt;p&gt;Try these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;args file1 file2 file3|vert all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;args file1 file2 file3|all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;all&lt;/code&gt; rearranges the screen to open one window for each argument. See help for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;|&lt;/code&gt; is not used like a pipe, in Vim it's the command separator.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-05-12T20:01:10.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12384" PostTypeId="2" ParentId="12376" CreationDate="2017-05-12T20:12:00.220" Score="2" Body="&lt;p&gt;I've made a PR for WSL support to &lt;a href=&quot;https://github.com/kana/vim-fakeclip&quot; rel=&quot;nofollow noreferrer&quot;&gt;fakeclip&lt;/a&gt; some time ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimawesome.com/plugin/fakeclip&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimawesome&lt;/a&gt; on how to install it; &lt;code&gt;help fakeclip&lt;/code&gt; for usage.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-05-12T20:12:00.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12385" PostTypeId="1" AcceptedAnswerId="12386" CreationDate="2017-05-13T06:46:51.377" Score="1" ViewCount="148" Body="&lt;p&gt;Let's say I want to edit the text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;blahblah WombatModeFunctor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;blahblah WombatModeFunctor::WombatModeFunctor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The way I know to do it is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Move the caret (cursor) until it is over the W&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;yw&lt;/code&gt; to yank the word&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Move the caret 1 position to the left of the W&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;p&lt;/code&gt; to paste the yanked word.  Now you have:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;blahblah WombatModeFunctorWombatModeFunctor&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;but the caret is over the first 'r', so you have to&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;5&quot;&gt;&#xA;&lt;li&gt;&lt;strong&gt;Move the caret 1 position to the right of the r&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Enter INSERT mode&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;::&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Why is step 3 necessary?  It seems silly that a &lt;code&gt;p&lt;/code&gt; right after a &lt;code&gt;yw&lt;/code&gt; would cause a pasting after the first letter of the word you just yanked.&lt;/li&gt;&#xA;&lt;li&gt;Why is step 5 necessary? It seems more intuitive that the caret would be after the final pasted character, not on top of it&lt;/li&gt;&#xA;&lt;li&gt;Is there a more efficient vim incantation for this action?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="12602" LastEditorUserId="12602" LastEditDate="2017-05-13T06:52:06.520" LastActivityDate="2017-05-13T10:12:54.400" Title="Why so many keystrokes to duplicate a word with an edit in between them?" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12386" PostTypeId="2" ParentId="12385" CreationDate="2017-05-13T07:11:14.520" Score="4" Body="&lt;ol&gt;&#xA;&lt;li&gt;Step 3 is not necessary, you can use &lt;code&gt;P&lt;/code&gt; instead of &lt;code&gt;p&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Step 5 is not necessary, you can use &lt;code&gt;a&lt;/code&gt; instead of &lt;code&gt;i&lt;/code&gt; to enter insert mode.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;An alternative approach is this, assuming cursor is on the first &lt;code&gt;W&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C&amp;lt;c-r&amp;gt;&quot;::&amp;lt;c-r&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;C&lt;/code&gt; will delete the text from the cursor to the end of line, then enter insert mode and &lt;code&gt;&amp;lt;c-r&amp;gt;&quot;&lt;/code&gt; (from insert mode) will paste the content of the last used register.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-05-13T07:11:14.520" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12387" PostTypeId="1" CreationDate="2017-05-13T09:06:51.303" Score="3" ViewCount="1394" Body="&lt;p&gt;I am having trouble figuring out how to use the text objects with the vimtex plugin. The mappings with leaders and the commands in normal and insert mode are fine. But to get environments, sections, etc.  there are some bindings which i cannot figure out how to use. Specifically, the ones like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ac               |(vimtex-ac)|                     &lt;code&gt;xo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ic               |(vimtex-ic)|                     &lt;code&gt;xo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mostly I think it is because I have no idea what modes x and o could be, (I assume n is normal, i insert) - I have not been able to find any explanatation of this elsewhere. I assume its something obvious that is just escaping me.&lt;/p&gt;&#xA;" OwnerUserId="12604" LastEditorUserId="1292" LastEditDate="2019-01-24T12:48:01.623" LastActivityDate="2019-01-24T12:48:01.623" Title="Using Text Objects with vimtex" Tags="|filetype-tex|key-bindings|custom-text-object|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12388" PostTypeId="1" CreationDate="2017-05-13T09:49:52.140" Score="1" ViewCount="1011" Body="&lt;p&gt;I'm getting very strange behaviour when I try to expand the listing of a folder by pressing enter. Take the following screenshot&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9Bmct.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9Bmct.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I have file &lt;code&gt;2.1&lt;/code&gt; open. But when I press &lt;code&gt;Enter&lt;/code&gt; on &lt;code&gt;1/&lt;/code&gt; to expand it, &lt;code&gt;2/&lt;/code&gt; first closes and then I have to press &lt;code&gt;Enter&lt;/code&gt; again to finally expand &lt;code&gt;1/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to avoid this so that &lt;code&gt;2/&lt;/code&gt; never closes in the first place?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Here are my netrw settings&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_liststyle = 3&#xA;let g:netrw_browse_split = 4&#xA;let g:netrw_altv = 1&#xA;let g:netrw_winsize = -28&#xA;let g:netrw_banner = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12605" LastEditorUserId="12605" LastEditDate="2017-05-13T17:07:20.387" LastActivityDate="2017-05-13T17:07:20.387" Title="netrw expand folders - strange behaviour" Tags="|netrw|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12389" PostTypeId="2" ParentId="12385" CreationDate="2017-05-13T10:12:54.400" Score="2" Body="&lt;p&gt;With caret at the beginning of the line: &lt;code&gt;wy$Pa::&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4426" LastActivityDate="2017-05-13T10:12:54.400" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12390" PostTypeId="2" ParentId="12367" CreationDate="2017-05-13T13:14:49.007" Score="2" Body="&lt;p&gt;You can profile and measure time Vim spends on executing functions and scripts. For more details, run &lt;code&gt;:h profile&lt;/code&gt; in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;profile start ~/vim-profile.log&#xA;profile file ~/.vim/*&#xA;profile func foo#*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will profile functions that start with &lt;code&gt;foo#&lt;/code&gt; under &lt;code&gt;~/.vim/&lt;/code&gt; and log the output in &lt;code&gt;~/vim-profile.log&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4426" LastActivityDate="2017-05-13T13:14:49.007" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12391" PostTypeId="2" ParentId="12380" CreationDate="2017-05-13T13:30:09.557" Score="3" Body="&lt;p&gt;In Vim you can press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;w&lt;/kbd&gt;, &lt;kbd&gt;&amp;lt;&lt;/kbd&gt; or &lt;kbd&gt;&gt;&lt;/kbd&gt; to decrease and increase window width, respectively. Add comfortable mappings for you, I use the arrow keys, as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Up&amp;gt;    :resize +2&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Down&amp;gt;  :resize -2&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Left&amp;gt;  :vertical resize +2&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Right&amp;gt; :vertical resize -2&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, I enjoy this little snippet to create a useful quick resize toggle shortcut within NERDTree:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:SID()&#xA;    if ! exists('s:sid')&#xA;        let s:sid = matchstr(expand('&amp;lt;sfile&amp;gt;'), '&amp;lt;SNR&amp;gt;\zs\d\+\ze_SID$')&#xA;    endif&#xA;    return s:sid&#xA;endfunction&#xA;let s:SNR = '&amp;lt;SNR&amp;gt;'.s:SID().'_'&#xA;&#xA;call NERDTreeAddKeyMap({&#xA;    \ 'key': 'w',&#xA;    \ 'callback': s:SNR.'toggle_width',&#xA;    \ 'quickhelpText': 'Toggle window width' })&#xA;&#xA;function! s:toggle_width()&#xA;    let l:max = 0&#xA;    for l:z in range(1, line('$'))&#xA;        let l:len = len(getline(l:z))&#xA;        if l:len &amp;gt; l:max&#xA;            let l:max = l:len&#xA;        endif&#xA;    endfor&#xA;    exe 'vertical resize '.(l:max == winwidth('.') ? g:NERDTreeWinSize : l:max)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this, you can press &lt;kbd&gt;w&lt;/kbd&gt; on NERDTree buffer to toggle width resize, I find it quite useful.&lt;/p&gt;&#xA;" OwnerUserId="4426" LastActivityDate="2017-05-13T13:30:09.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12392" PostTypeId="2" ParentId="11745" CreationDate="2017-05-13T20:15:06.737" Score="2" Body="&lt;p&gt;You can use Operator-pending mode to define new text objects by having&#xA;the mapping invoke Visual mode, and then select the text you want to&#xA;operate on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not entirely sure what semantics you want here; the devil is in the&#xA;details, as usual. But you could try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:onoremap iT :&amp;lt;C-U&amp;gt;normal! vitbowV&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then &lt;code&gt;&amp;lt;iT&lt;/code&gt; to unindent something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To define the text to operate on it does &lt;code&gt;vit&lt;/code&gt; to select the inner tag,&#xA;backs up a word, moves to the beginning of the selection, then moves on&#xA;a word, and then makes the selection linewise. This should suffice for most situations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details at &lt;code&gt;:help omap-info&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2017-05-14T15:47:38.253" LastActivityDate="2017-05-14T15:47:38.253" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12393" PostTypeId="1" CreationDate="2017-05-13T20:17:33.463" Score="3" ViewCount="788" Body="&lt;p&gt;Is there a way to limit the command area in vim? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When typing a long command, cmdheight is &quot;temporarily increased&quot;, but I like to limit it to one line. What I currently have is illustrated on the left, but I like the behavior on the right:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/l9KtV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/l9KtV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; ----&gt; &lt;a href=&quot;https://i.stack.imgur.com/Kb0TI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Kb0TI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12612" LastEditorUserId="51" LastEditDate="2017-05-13T21:10:00.057" LastActivityDate="2017-05-13T21:10:00.057" Title="Set maximum cmdheight" Tags="|command-line|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12394" PostTypeId="1" AcceptedAnswerId="12399" CreationDate="2017-05-14T11:16:30.013" Score="4" ViewCount="1412" Body="&lt;p&gt;I'm using &lt;code&gt;deoplete&lt;/code&gt; plugin for auto completion. In Vim, default keybinding for up and down when popup appears is &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;N&lt;/kbd&gt; / &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt;. I want to change to &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt; / &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;K&lt;/kbd&gt; for same behavior with &lt;code&gt;CtrlP&lt;/code&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I change this. thanks&lt;/p&gt;&#xA;" OwnerUserId="7078" LastEditorUserId="51" LastEditDate="2017-05-15T19:51:53.537" LastActivityDate="2017-05-15T19:51:53.537" Title="Change keybinding for up/down when in vim popup" Tags="|key-bindings|autocompletion|plugin-deoplete|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12395" PostTypeId="1" CreationDate="2017-05-14T17:33:06.067" Score="1" ViewCount="205" Body="&lt;p&gt;Is there a way to make Vim's messages stay longer on the screen?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Messages and error messages are currently shown for a very short time; for about half-second, if not mistaken.  &lt;/p&gt;&#xA;" OwnerUserId="12622" LastActivityDate="2017-05-14T18:37:02.667" Title="Change messages display duration" Tags="|statusline|error|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12396" PostTypeId="2" ParentId="12395" CreationDate="2017-05-14T18:37:02.667" Score="1" Body="&lt;p&gt;you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:messages&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to review the messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not exactly an answer to the question though.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-05-14T18:37:02.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12397" PostTypeId="1" AcceptedAnswerId="12398" CreationDate="2017-05-14T20:06:09.480" Score="0" ViewCount="348" Body="&lt;p&gt;I'm using Vim as a (debugger) frontend, but am bothered by the &quot;flickering&quot; screens when sending multiple commands at once. My current setup already uses &lt;code&gt;lazyredraw&lt;/code&gt; that &lt;a href=&quot;https://vi.stackexchange.com/a/6157/12612&quot;&gt;should work for functions&lt;/a&gt;. I communicate with a vim session using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; vim --server &quot;&amp;lt;servername&amp;gt;&quot; --remote-send &quot;&amp;lt;command&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I basically send a unique function every time and then execute it, such that I can take advantage of lazyredraw. A typical &lt;code&gt;&amp;lt;command&amp;gt;&lt;/code&gt; looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent execute &quot;function! Mycommands()\n \&#xA;vim test/src/main.cc\n                    \&#xA;execute &quot;sign place 5 line=5 name=&amp;lt;SOMESIGN&amp;gt; file=&quot; . expand(&quot;%:p&quot;)\n \&#xA;call cursor(5,1)\n                        \&#xA;redraw!\n                                 \&#xA;endfunction&quot; |                            \&#xA;call Mycommands()&amp;lt;Enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It (1) opens a file, (2) highlights line 5 using a vim &lt;code&gt;sign&lt;/code&gt;, and (3) moves the cursor to line 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I record my vim session and slow it down, I see how this &lt;code&gt;&amp;lt;command&amp;gt;&lt;/code&gt; is printed to the vim command line (It actually increase the cmd area for these long &lt;code&gt;&amp;lt;command&amp;gt;&lt;/code&gt;'s), I then see how the file is opened, and lastly how the sign is placed. My questions are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) can I stop redrawing, send my commands, and then redraw?&lt;br&gt;&#xA;2) can I disable the echoing of &lt;code&gt;&amp;lt;command&amp;gt;&lt;/code&gt; to the vim commandline, like possible with a mapping using &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt;?&lt;br&gt;&#xA;3) Is there a better way to achieve the frontend setup that avoids this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thx&lt;/p&gt;&#xA;" OwnerUserId="12612" LastActivityDate="2017-05-14T21:16:19.920" Title="Vim's remote-send, without intermediate redraws?" Tags="|clientserver|redraw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12398" PostTypeId="2" ParentId="12397" CreationDate="2017-05-14T21:16:19.920" Score="1" Body="&lt;p&gt;one workaround is to write an tempfile with the command(s) in them.&#xA;Then send a command to source this file. like in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; vim --server &quot;&amp;lt;servername&amp;gt;&quot; --remote-send &quot;so /path/to/tempfile&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-05-14T21:16:19.920" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12399" PostTypeId="2" ParentId="12394" CreationDate="2017-05-15T01:28:11.483" Score="7" Body="&lt;p&gt;You can't &quot;directly&quot; map keys in the pop-up menu, you'll have to use &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap-%3Cexpr%3E&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;expression mappings&lt;/code&gt;&lt;/a&gt; and the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#pumvisible%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;pumvisible()&lt;/code&gt;&lt;/a&gt; function to check if the popup menu is visible.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-j&amp;gt; pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;C-j&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-k&amp;gt; pumvisible() ? &quot;\&amp;lt;C-p&amp;gt;&quot; : &quot;\&amp;lt;C-k&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the popup menu is visible &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; is mapped to &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; to make it go to the next entry. If the menu isn't visible &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; is mapped to &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-05-15T01:28:11.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12400" PostTypeId="2" ParentId="12387" CreationDate="2017-05-15T06:55:54.203" Score="4" Body="&lt;p&gt;I think you do not really understand what a text object is. I therefore recommend that you read &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h text-objects&lt;/code&gt;&lt;/a&gt;. When you have read and understood this, you should be able to understand the vimtex text object mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The vimtex documentation does list all the default mappings with a mode indicator. The &lt;code&gt;ac&lt;/code&gt; and &lt;code&gt;ic&lt;/code&gt; mappings are indicated with &lt;code&gt;xo&lt;/code&gt;, which implies visual mode (&lt;code&gt;x&lt;/code&gt;) and operator pending mode (&lt;code&gt;o&lt;/code&gt;). This means the mapping is available in visual mode and in operator pending mode. An example: &lt;code&gt;vac&lt;/code&gt; will select the entire command under the cursor and &lt;code&gt;dac&lt;/code&gt; will delete it. In the first example, &lt;code&gt;v&lt;/code&gt; first starts visual mode, and in the latter example, &lt;code&gt;d&lt;/code&gt; is an operator and &quot;starts&quot; the operator pending mode.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-05-15T06:55:54.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12401" PostTypeId="2" ParentId="11753" CreationDate="2017-05-15T08:42:58.733" Score="0" Body="&lt;p&gt;Vim has a couple of functions to help with this, namely &lt;code&gt;winsaveview()&lt;/code&gt; and &lt;code&gt;winrestview()&lt;/code&gt;. Here's an example of how you might use them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Stayput(cmd)&#xA;    let v = winsaveview()&#xA;    exec a:cmd&#xA;    call winrestview(v)&#xA;endfun&#xA;nno &amp;lt;leader&amp;gt;s mmA # =&amp;gt; &amp;lt;Esc&amp;gt;`m:silent call Stayput('%!seeing_is_believing ...')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So save your view, do some stuff, then restore your view, including cursor and scroll positions, to exactly&#xA;how it was before. I've wrapped it up in a function for convenience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few other notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;consider using &lt;code&gt;:nnoremap&lt;/code&gt; rather than &lt;code&gt;:nmap&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;I've used a mark in the mapping to return the cursor to where it&#xA;was before the comment was appended;&lt;/li&gt;&#xA;&lt;li&gt;I've used &lt;code&gt;:silent&lt;/code&gt; to prevent editing messages appearing&#xA;in the last line of the screen; and&lt;/li&gt;&#xA;&lt;li&gt;I'm not sure what the &lt;code&gt;.&lt;/code&gt; in &lt;code&gt;%.!&lt;/code&gt; is meant to be doing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;More info. at &lt;code&gt;:help winsaveview()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2017-05-15T08:42:58.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12402" PostTypeId="1" CreationDate="2017-05-15T09:03:58.663" Score="1" ViewCount="66" Body="&lt;p&gt;The raw text is like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;words&amp;gt; command feed world &amp;lt;/words&amp;gt; tag=random      &#xA;&amp;lt;words&amp;gt; who is that ? &amp;lt;/words&amp;gt; tag=normal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need to substitute words for characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;words&amp;gt; c o m m a n d  f e e d  w o r l d &amp;lt;/words&amp;gt; tag=random&#xA;&amp;lt;words&amp;gt; w h o  i s  t h a t ? &amp;lt;/words&amp;gt; tag=normal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know how to do it if the range is over lines, but don't know how to do it if the range is in a line..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My solution: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s:&amp;lt;words&amp;gt;.*\zs(.)\ze.*&amp;lt;/words&amp;gt;:\1 :gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without any doubt it does not work. &lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="1788" LastEditDate="2017-05-15T12:15:50.023" LastActivityDate="2017-05-15T16:42:31.537" Title="Substitute words for characters between matches in a line?" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12403" PostTypeId="2" ParentId="12402" CreationDate="2017-05-15T13:13:49.007" Score="1" Body="&lt;p&gt;Are you sure you've formatted that example correctly? Some&#xA;of the spacing seems a bit arbitrary and doesn't seem&#xA;straightforward to get right:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s:\(&amp;lt;words&amp;gt; .*\)\@&amp;lt;=\a\( \A\)\@!\(.* &amp;lt;/words&amp;gt;\)\@=:&amp;amp; :g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In particular see &lt;code&gt;:h \@&amp;lt;=&lt;/code&gt; for checking for the existence of a preceding&#xA;item, and &lt;code&gt;:h \@!&lt;/code&gt; and &lt;code&gt;:h \@=&lt;/code&gt; for negative and positive assertions&#xA;at the cursor position.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2017-05-15T16:42:31.537" LastActivityDate="2017-05-15T16:42:31.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12405" PostTypeId="1" CreationDate="2017-05-15T16:54:36.357" Score="1" ViewCount="400" Body="&lt;p&gt;I have the following snippet of text and I want the &quot;blah&quot; lines to not wrap.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{itemize}&#xA;    \item&#xA;      Blah blah blah blah blah blah blah&#xA;      blah blah blah blah blah blah Blah&#xA;      blah blah blah blah blah blah blah&#xA;    \item&#xA;      Blah blah blah blah blah blah blah&#xA;      blah blah blah blah blah blah Blah&#xA;      blah blah blah blah blah blah blah&#xA;\end{itemize}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I issue &lt;code&gt;:set tw=9999&lt;/code&gt;, then the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\&amp;lt;item$/+1 norm gq/\&amp;lt;item/-1&#xA;:% g/\&amp;lt;item$/+1 norm gq/\&amp;lt;item/-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Neither seem to do anything, but simply putting the cursor on the first &quot;blah&quot; line and issuing &lt;code&gt;gq/\&amp;lt;item/-1&lt;/code&gt; works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{itemize}&#xA;    \item&#xA;      Blah blah blah blah blah blah blah blah blah blah blah blah blah Blah blah blah blah blah blah blah blah&#xA;    \item&#xA;      Blah blah blah blah blah blah blah&#xA;      blah blah blah blah blah blah Blah&#xA;      blah blah blah blah blah blah blah&#xA;\end{itemize}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, I'm doing something wrong.  Can anyone point out my error?&lt;/p&gt;&#xA;" OwnerUserId="7970" LastActivityDate="2017-05-16T18:41:46.733" Title="Vim `gq` rewrap doesn't work within `:&lt;range&gt; norm` command" Tags="|vimscript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12406" PostTypeId="1" CreationDate="2017-05-15T18:32:52.077" Score="2" ViewCount="1236" Body="&lt;p&gt;In a specific context, typing &lt;code&gt;:vsplit&lt;/code&gt; does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;:split&lt;/code&gt; still splits the screen horizontally. And if I open a new file e.g. &lt;code&gt;vi foo.txt&lt;/code&gt; then &lt;code&gt;:vsplit&lt;/code&gt; works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT: steps to reproduce&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Type &lt;code&gt;/bin/vi&lt;/code&gt; on the command-line&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;:vsplit&lt;/code&gt;. For me, nothing happens.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;(See answer below for more)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Context:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running this script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; cat fix.sh&#xA;I=0&#xA;for D in 2*; do&#xA;  vi ${D}/node_*;&#xA;  cp ${D}/node_input.txt samples.txt${I}&#xA;  cat ${D}/node_output.txt &amp;gt;&amp;gt; futen_output.txt&#xA;  I=$((${I} + 1))&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On this machine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; uname -a&#xA;Linux h3.karst.uits.iu.edu 2.6.32-696.1.1.el6.x86_64 #1 SMP Tue Mar 21 12:19:18 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In case it helps, here's my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ai&#xA;set background=dark&#xA;set expandtab&#xA;set list&#xA;set listchars=trail:.&#xA;set nowrap&#xA;set nu&#xA;set ruler&#xA;set shiftwidth=2&#xA;set tabstop=2&#xA;set nohlsearch&#xA;syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT: more details about &lt;code&gt;/bin/vi&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After typing &lt;code&gt;/bin/vi&lt;/code&gt;, then typing &lt;code&gt;:version&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 12 2016 09:48:07)&#xA;Included patches: 1-207, 209-629&#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Small version without GUI.  Features included (+) or not (-):&#xA;+acl             -cmdline_compl   -diff            -find_in_path    -keymap          -modify_fname    +multi_byte      -python3         -statusline      -title           -wildmenu&#xA;-arabic          +cmdline_hist    -digraphs        -float           -langmap         -mouse           -multi_lang      -quickfix        -sun_workshop    -toolbar         +windows&#xA;-autocmd         -cmdline_info    -dnd             -folding         -libcall         -mouse_dec       -mzscheme        -reltime         -syntax          -user_commands   +writebackup&#xA;-balloon_eval    -comments        -ebcdic          -footer          -linebreak       -mouse_gpm       -netbeans_intg   -rightleft       -tag_binary      -vertsplit       -X11&#xA;-browse          -conceal         -emacs_tags      +fork()          -lispindent      -mouse_jsbterm   -path_extra      -ruby            -tag_old_static  -virtualedit     -xfontset&#xA;+builtin_terms   -cryptv          -eval            -gettext         -listcmds        -mouse_netterm   -perl            -scrollbind      -tag_any_white   +visual          -xim&#xA;-byte_offset     -cscope          -ex_extra        -hangul_input    -localmap        -mouse_sgr       -persistent_undo -signs           -tcl             -visualextra     -xsmp&#xA;-cindent         -cursorbind      -extra_search    +iconv           -lua             -mouse_sysmouse  -printer         -smartindent     +terminfo        -viminfo         -xterm_clipboard&#xA;-clientserver    -cursorshape     -farsi           -insert_expand   -menu            -mouse_urxvt     -profile         -sniff           -termresponse    -vreplace        -xterm_save&#xA;-clipboard       -dialog          -file_in_path    +jumplist        -mksession       -mouse_xterm     -python          -startuptime     -textobjects     +wildignore      -xpm&#xA;   system vimrc file: &quot;/etc/virc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/etc&quot;&#xA; f-b for $VIMRUNTIME: &quot;/usr/share/vim/vim74&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTI&#xA;FY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim        -lm  -lselinux -ltinfo -lacl -lattr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After typing &lt;code&gt;/bin/vi&lt;/code&gt;, then &lt;code&gt;:vsplit&lt;/code&gt;, then &lt;code&gt;:messages&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Messages maintainer: Bram Moolenaar &amp;lt;Bram@vim.org&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12640" LastEditorUserId="12640" LastEditDate="2017-05-16T16:28:39.507" LastActivityDate="2017-09-13T21:24:46.737" Title=":vsplit does nothing, sometimes" Tags="|split|linux|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12407" PostTypeId="1" CreationDate="2017-05-15T19:27:27.617" Score="2" ViewCount="54" Body="&lt;p&gt;The first line of this section of LaTeX code breaks syntax highlighting and spell check whenever I scroll to the area of the document that contains it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{tabu} {*3{X[l$]}}&#xA;    col1    &amp;amp; col2  &amp;amp; col3&#xA;\end{tabu}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is what it looks like:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/NvFAf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NvFAf.png&quot; alt=&quot;Example of what the synax parsing problem looks like&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can tell I'm using the &lt;a href=&quot;http://ctan.org/pkg/tabu&quot; rel=&quot;nofollow noreferrer&quot;&gt;(excellent) packet tabu&lt;/a&gt;, and it's when I apply the column descriptor multiplier that things goes astray. It does not happen until I get that part of the document into the view port, so if I start at the end of the file it is fine until I get to that line (182 in my example image). The moment that line goes into view, everything bellow it is bogus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like there is some problem with the curly braces, which are marked... But I have no idea where to get from here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers.&lt;/p&gt;&#xA;" OwnerUserId="2082" LastActivityDate="2017-05-15T19:27:27.617" Title="LaTeX tabu package breaks Vim spell and syntax highlighting" Tags="|syntax-highlighting|filetype-tex|spell-checking|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12408" PostTypeId="1" CreationDate="2017-05-16T05:50:25.283" Score="1" ViewCount="81" Body="&lt;p&gt;From a given cursor position, how can I move &lt;em&gt;vertically&lt;/em&gt; to the next non-whitespace character (in the same column), whether up or down?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I highly doubt this is a built-in motion command (if it is then great!), how can I map Ctrl-K and Ctrl-J to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This is inspired by the Excel feature, oddly enough.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For a bonus: Make g followed by Ctrl-K and Ctrl-J work on soft-wrapped columns.  Far less critical but it would be cool.&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2017-05-16T16:54:28.357" Title="Column-based w command?" Tags="|key-bindings|cursor-movement|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12411" PostTypeId="1" AcceptedAnswerId="12412" CreationDate="2017-05-16T09:30:45.137" Score="1" ViewCount="300" Body="&lt;p&gt;Let's say I have two windows open, stacked one above the other (via &lt;code&gt;vim -o file1 file2&lt;/code&gt; or &lt;code&gt;:split&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command (sequence) which would allow me to turn this into two windows that are &lt;em&gt;side by side&lt;/em&gt; (as via &lt;code&gt;vim -O file1 file2&lt;/code&gt; or &lt;code&gt;:vsplit&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More generally speaking, is there a command (sequence) to turn the currently displayed windows on the side?&lt;/p&gt;&#xA;" OwnerUserId="1726" LastActivityDate="2017-05-16T09:59:17.227" Title="Turn Vim windows on the side" Tags="|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12412" PostTypeId="2" ParentId="12411" CreationDate="2017-05-16T09:59:17.227" Score="2" Body="&lt;p&gt;Move one of the windows to the side, with &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#CTRL-W_H&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;W&lt;/kbd&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;H&lt;/kbd&gt;&lt;/a&gt; or &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;W&lt;/kbd&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;L&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                CTRL-W_H&#xA;CTRL-W H        Move the current window to be at the far left, using the&#xA;                full height of the screen.  This works like closing the&#xA;                current window and then creating another one with&#xA;                &quot;:vert topleft split&quot;, except that the current window contents&#xA;                is used for the new window.&#xA;                {not available when compiled without the |+vertsplit| feature}&#xA;&#xA;                                                CTRL-W_L&#xA;CTRL-W L        Move the current window to be at the far right, using the full&#xA;                height of the screen.  This works like closing the&#xA;                current window and then creating another one with&#xA;                &quot;:vert botright split&quot;, except that the current window&#xA;                contents is used for the new window.&#xA;                {not available when compiled without the |+vertsplit| feature}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the &lt;code&gt;H&lt;/code&gt; is a capital here, the lowercase &lt;code&gt;h&lt;/code&gt; simply moves the cursor to the other window instead of moving the window itself.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-05-16T09:59:17.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12413" PostTypeId="1" AcceptedAnswerId="12414" CreationDate="2017-05-16T10:31:16.833" Score="1" ViewCount="314" Body="&lt;p&gt;I had asked a similar question previously (&lt;a href=&quot;https://vi.stackexchange.com/questions/6525/how-to-copy-each-line-11-times-incrementing-the-last-1-in-each-line-from-2-12&quot;&gt;How to copy each line 11 times, incrementing the last &amp;quot;1&amp;quot; in each line from 2-12&lt;/a&gt;). I wasn't sure if I should ask this follow-up question in that same thread or not, but I think it might have been confusing to do that, so I'll ask a new question instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to take a line that looks like*:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...?start=0&amp;amp;end=180&amp;amp;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and copy it 19 times such that each of the two numbers is incremented by 180, so it would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...?start=0&amp;amp;end=180&amp;amp;...&#xA;...?start=180&amp;amp;end=360&amp;amp;...&#xA;...?start=360&amp;amp;end=540&amp;amp;...&#xA;...&#xA;...?start=3420&amp;amp;end=3600&amp;amp;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do that (preferably with a one-line command, but a macro is fine too)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you all very much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*The &lt;code&gt;...&lt;/code&gt; represents other text in the line, before and after that particular segment. (Also, in case it's relevant, I'll note that the one &lt;code&gt;?&lt;/code&gt; character and the two &lt;code&gt;&amp;amp;&lt;/code&gt; characters shown in that segment of the line are the only occurrences of those characters in the entire line.)&lt;/p&gt;&#xA;" OwnerUserId="6195" LastActivityDate="2017-05-16T22:47:05.923" Title="How to copy each line 19 times, incrementing two different numbers by 180?" Tags="|cut-copy-paste|gvim|text-generation|enumerate|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12414" PostTypeId="2" ParentId="12413" CreationDate="2017-05-16T10:57:32.243" Score="3" Body="&lt;p&gt;You can record a macro, carry out your instructions, close the macro, then run it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case you may start with the cursor at the beginning of the line to copy.&lt;br&gt;&#xA;Press &lt;code&gt;qa&lt;/code&gt; to start recording macro 'a' (you can pick any letter, but beware these are the same registers as the copy-paste registers).&lt;br&gt;&#xA;Then carry out your actions: copy the line &lt;code&gt;yy&lt;/code&gt;, paste it &lt;code&gt;p&lt;/code&gt;, find a sure fire way to place your cursor in the right location, maybe &lt;code&gt;/?&lt;/code&gt;&lt;kbd&gt;ENTER&lt;/kbd&gt;, add 180 &lt;code&gt;180&lt;/code&gt;&lt;kbd&gt;CTRL-A&lt;/kbd&gt; (or whatever shortcut is defined for you to add a number), move the cursor, add again, then move the cursor to the beginning of the current line (not necessary in this particular case but good practice), finally, close the recording with &lt;code&gt;q&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now run the macro once or 18 times &lt;code&gt;@a&lt;/code&gt; / &lt;code&gt;18@a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;hr&gt;&#xA;&lt;strong&gt;EDIT&lt;/strong&gt;: alternative answer, using the answer to your similar question:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(.*start=\)\([0-9]\+\)\(.*end=\)\([0-9]\+\)\(.*\)/\=join(map(range(1, 20), 'submatch(1) . (submatch(2) + (v:val-1) * 180) . submatch(3) . (submatch(4) + (v:val-1) * 180) . submatch(5)'), &quot;\n&quot;)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5440" LastEditorUserId="5440" LastEditDate="2017-05-16T22:47:05.923" LastActivityDate="2017-05-16T22:47:05.923" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12416" PostTypeId="2" ParentId="12406" CreationDate="2017-05-16T16:12:22.127" Score="1" Body="&lt;p&gt;The problem is the line in my script that calls &lt;code&gt;vi&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  vi ${D}/node_*;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;&lt;code&gt;vi&lt;/code&gt;&quot; points to &lt;code&gt;/bin/vi&lt;/code&gt;, and for some reason &lt;code&gt;/bin/vi&lt;/code&gt; ignores the &#xA;&lt;code&gt;:vsplit&lt;/code&gt; command. I'll email the local sysadmin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: @Antony points out, &lt;code&gt;/bin/vi&lt;/code&gt; was compiled without the &lt;code&gt;vertsplit&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fix is easy, change &lt;code&gt;vi&lt;/code&gt; to &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12640" LastEditorUserId="12640" LastEditDate="2017-05-16T19:03:04.857" LastActivityDate="2017-05-16T19:03:04.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12417" PostTypeId="2" ParentId="12405" CreationDate="2017-05-16T18:41:46.733" Score="1" Body="&lt;p&gt;Thanks to antony for point out that the problem is solved by adding a &lt;code&gt;^M&lt;/code&gt; to the comand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\&amp;lt;item$/+1 norm gq/\&amp;lt;item/-1^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the ^M by first pressing &lt;code&gt;ctrl-V&lt;/code&gt;, then either &lt;code&gt;ctrl-M&lt;/code&gt; or the &lt;code&gt;Carriage Return&lt;/code&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Antony also pointed out the &lt;code&gt;gq&lt;/code&gt; command can be replaced by the &lt;code&gt;J&lt;/code&gt; command (for Join).  That works for this example.  In a more complex situation, where a body of text might have under-length and over-length lines due to extensive revision, &lt;code&gt;gq&lt;/code&gt; is needed. It formats the entire &quot;paragraph&quot;.&lt;/p&gt;&#xA;" OwnerUserId="7970" LastActivityDate="2017-05-16T18:41:46.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12418" PostTypeId="1" CreationDate="2017-05-16T18:45:52.377" Score="3" ViewCount="633" Body="&lt;p&gt;Like many people, I prefer a triangular or inverse-T navigation key format like IJKL instead of HJKL for ergonomic reasons. There's a &lt;a href=&quot;http://vim.wikia.com/wiki/Use_ijkl_to_move_the_cursor_and_h_to_insert&quot; rel=&quot;nofollow noreferrer&quot;&gt;pretty simple way to set this up in vim&lt;/a&gt; that I've used for years:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map h &amp;lt;insert&amp;gt;&#xA;map i &amp;lt;Up&amp;gt;&#xA;map j &amp;lt;Left&amp;gt;&#xA;map k &amp;lt;Down&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, using text objects in visual mode conflicts with these keys &amp;mdash; specifically &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#object-select&quot; rel=&quot;nofollow noreferrer&quot;&gt;inner objects&lt;/a&gt;, because they start with &lt;code&gt;i&lt;/code&gt;. Further, plugins that rely on these objects (such as &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt; and others) then also have conflicts with the remapped &lt;code&gt;i&lt;/code&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting up IJKL with &lt;code&gt;noremap h i&lt;/code&gt; instead of &lt;code&gt;map h &amp;lt;insert&amp;gt;&lt;/code&gt; changes the inner object key from &lt;code&gt;i&lt;/code&gt; to &lt;code&gt;h&lt;/code&gt; which helps to some degree, but if you have plugins that use the standard inner text objects then there's a delay in visual mode every time you press &lt;code&gt;i&lt;/code&gt; as vim waits to see if you're going to use the standard text objects as they're loaded from that plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to set up IJKL navigation without losing the functionality of inner text objects?&lt;/p&gt;&#xA;" OwnerUserId="12652" LastEditorUserId="51" LastEditDate="2017-05-16T19:16:30.360" LastActivityDate="2017-05-16T19:16:30.360" Title="Using text objects with IJKL navigation keys" Tags="|key-bindings|cursor-motions|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12419" PostTypeId="1" CreationDate="2017-05-17T00:31:56.607" Score="6" ViewCount="99" Body="&lt;p&gt;A while ago I used to use eclipse as my IDE, and I remember you could add &lt;code&gt;TODO: some task&lt;/code&gt;, &lt;code&gt;NOTE: some comment&lt;/code&gt;, &lt;code&gt;WARN: some warning&lt;/code&gt; to your code, and it would appear in a particular pane for the current buffer, so you could click and jump to that section of the code.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware of marks, and of the ability to search for such things in vim, but is there a way to open a similar pane to see an overview lines with this text in vim so that you can &quot;jump to them&quot;?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2017-05-17T00:31:56.607" Title="Comments pane for current buffer that you can jump to such as TODO:, WARN:, and NOTE:?" Tags="|comments|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12422" PostTypeId="1" CreationDate="2017-05-17T09:31:27.383" Score="2" ViewCount="1210" Body="&lt;p&gt;In &lt;code&gt;nerdcommenter&lt;/code&gt;, the default comment is &lt;code&gt;/* */&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to change it to &lt;code&gt;#&lt;/code&gt; for plain text as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;NerdCommenter {{{&#xA;&quot; Add spaces after comment delimiters by default&#xA;let g:NERDSpaceDelims = 1&#xA;&quot; Use compact syntax for prettified multi-line comments&#xA;let g:NERDCompactSexyComs = 1&#xA;let g:NERDCustomDelimiters = { 'text': { 'left': '#','right': '' } }&#xA;&quot;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this is still using default &lt;code&gt;/* */&lt;/code&gt; style.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;linux&lt;/code&gt;, the file output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; file POSCAR&#xA;POSCAR: ASCII text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, how I can change comment for such text file to &lt;code&gt;#&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2738" LastActivityDate="2019-07-25T19:48:20.310" Title="change default comment in nerd commenter" Tags="|plugin-nerdcommenter|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12423" PostTypeId="1" AcceptedAnswerId="12424" CreationDate="2017-05-17T13:35:36.320" Score="3" ViewCount="1779" Body="&lt;p&gt;I have a script which performs some action and then pipes the &lt;code&gt;stdout&lt;/code&gt; to Neovim so that I can look at it with syntax highlighting and do all the other nice things I can do with vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as this is a temporary file just used for inspecting the (possibly very long) output of the command, I almost never want to actually save the file. When I &lt;code&gt;:q&lt;/code&gt; to exit, I get &lt;code&gt;E37: No write since last change (add ! to override)&lt;/code&gt; as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried &lt;code&gt;:set ro&lt;/code&gt; but I still get &lt;code&gt;E37&lt;/code&gt; when exiting. I could of course train myself to just use &lt;code&gt;:q!&lt;/code&gt; for this particular scenario, but I'd rather come up with a better solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some argument I can pass to &lt;code&gt;nvim&lt;/code&gt; in my script that will prevent &lt;code&gt;E37&lt;/code&gt; when I &lt;code&gt;:q&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5288" LastEditorUserId="51" LastEditDate="2017-05-17T13:53:09.680" LastActivityDate="2017-05-17T13:53:09.680" Title="How can I open a temporary file so that I don't get E37: No write since last change?" Tags="|buffers|save|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12424" PostTypeId="2" ParentId="12423" CreationDate="2017-05-17T13:52:49.070" Score="4" Body="&lt;p&gt;You can use &lt;code&gt;:set buftype=nowrite&lt;/code&gt; or &lt;code&gt;:set buftype=nofile&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27buftype%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'buftype'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nofile        buffer which is not related to a file and will not be&#xA;                written&#xA;nowrite       buffer which will not be written&#xA;&#xA;[..]&#xA;&#xA;&#xA;&quot;nofile&quot; and &quot;nowrite&quot; buffers are similar:&#xA;both:           The buffer is not to be written to disk, &quot;:w&quot; doesn't&#xA;                work (&quot;:w filename&quot; does work though).&#xA;both:           The buffer is never considered to be 'modified'.&#xA;                There is no warning when the changes will be lost, for&#xA;                example when you quit Vim.&#xA;both:           A swap file is only created when using too much memory&#xA;                (when 'swapfile' has been reset there is never a swap&#xA;                file).&#xA;nofile only:    The buffer name is fixed, it is not handled like a&#xA;                file name.  It is not modified in response to a :cd&#xA;                command.&#xA;both:           When using &quot;:e bufname&quot; and already editing &quot;bufname&quot;&#xA;                the buffer is made empty and autocommands are&#xA;                triggered as usual for :edit.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your case, it doesn't matter all that much which one you use.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-05-17T13:52:49.070" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12425" PostTypeId="2" ParentId="12036" CreationDate="2017-05-17T13:56:27.060" Score="2" Body="&lt;p&gt;&lt;code&gt;:g/\\begin{equation}/,/\\end{equation}/s/x/\\x/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will look for &lt;code&gt;x&lt;/code&gt; between &lt;code&gt;\begin{equation}&lt;/code&gt; and &lt;code&gt;\end{equation}&lt;/code&gt; &#xA;and will substitute all instances of &lt;code&gt;x&lt;/code&gt; with &lt;code&gt;\x&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To look for the pattern &lt;code&gt;x&lt;/code&gt; inside &lt;code&gt;\[ \]&lt;/code&gt; and &lt;code&gt;$ $&lt;/code&gt;, replace the matching pattern and do a search replace again. If you want all the search instances in one line, use &lt;code&gt;|&lt;/code&gt; to separate two search expressions.&lt;/p&gt;&#xA;" OwnerUserId="11864" LastEditorUserId="11864" LastEditDate="2017-05-17T14:02:28.293" LastActivityDate="2017-05-17T14:02:28.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12426" PostTypeId="1" CreationDate="2017-05-17T17:45:59.237" Score="3" ViewCount="768" Body="&lt;p&gt;I found &lt;a href=&quot;https://stackoverflow.com/q/32973075/6342442&quot;&gt;this question&lt;/a&gt; on SO but it is not adequately answered there. I thought that re-posting it here would bring it to the attention of people with more specialized knowledge who can answer it adequately. The SO answer doesn't even come close and basically just writes it off as impossible. I posted the best answer I could, but my solution isn't ideal either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I edit the java.vim syntax file to highlight only the identifier of a Java function?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the best regex I came up with, but as you'll see, it has a side effect: it incorrectly highlights the closing parenthesis as an error (presumably because my regex makes it part of the highlighted region).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region javaFuncDef start=+^\s\+\(\(public\|protected\|private\|static\|abstract\|final\|native\|synchronized\)\s\+\)*\(\(void\|boolean\|char\|byte\|short\|int\|long\|float\|double\|\([A-Za-z_][A-Za-z0-9_$]*\.\)*[A-Z][A-Za-z0-9_$]*\)\(&amp;lt;[^&amp;gt;]*&amp;gt;\)\=\(\[\]\)*\s\+[a-z][A-Za-z0-9_$]*\|[A-Z][A-Za-z0-9_$]*\)\s*(+ end=+(+ contains=javaScopeDecl,javaType,javaStorageClass,javaComment,javaLineComment,@javaClasses&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I had a deeper knowledge of regex, or of Vim's syntax highlighting system, I might be able to fix it myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I discovered a construct called a zero-width assertion with lookahead, which matches something but does not actually include it as part of the match. Trouble is, I still can't get it working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the example here it would be &lt;code&gt;?=(&lt;/code&gt; right at the end of the regex, to match but not include the opening parameter list parenthesis. I've tried different uses of it (in the region start field, the region end field, and also as a standalone match rule rather than a region rule), all to no avail.&lt;/p&gt;&#xA;" OwnerUserId="10168" LastEditorUserId="-1" LastEditDate="2017-05-23T12:38:59.710" LastActivityDate="2017-08-06T17:37:25.050" Title="How can I highlight only the identifier of a function in Java?" Tags="|syntax-highlighting|filetype-java|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="12428" PostTypeId="2" ParentId="12426" CreationDate="2017-05-17T20:52:36.493" Score="1" Body="&lt;p&gt;I figured it out, mostly. Vim has a special version of the zero-width assertion. It doesn't recognize the standard regex &lt;code&gt;?=&lt;/code&gt; zero-width assertion. Thanks to Karl and user1685095 for pointing out the &lt;code&gt;\ze&lt;/code&gt; specifier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually you can use either &lt;code&gt;\ze&lt;/code&gt; or &lt;code&gt;\@=&lt;/code&gt; - though, as pointed out by user1685095, &lt;code&gt;\ze&lt;/code&gt; is the more efficient of the two. &lt;code&gt;\@=&lt;/code&gt; is a successor operation meaning the atom to which it should apply needs to come before it. &lt;code&gt;\ze&lt;/code&gt; operates on the atom that follows it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following regex sort of works, and highlights the function identifier along with any non-primitive return type. This is still isn't exactly right, but it's close.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region javaFuncDef start=+^\s\+\(\(public\|protected\|private\|static\|abstract\|final\|native\|synchronized\)\s\+\)*\(\(void\|boolean\|char\|byte\|short\|int\|long\|float\|double\|\([A-Za-z_][A-Za-z0-9_$]*\.\)*[A-Z][A-Za-z0-9_$]*\)\(&amp;lt;[^&amp;gt;]*&amp;gt;\)\=\(\[\]\)*\s\+[a-z][A-Za-z0-9_$]*\|[A-Z][A-Za-z0-9_$]*\)\s*\ze(+ end=+\ze(+ contains=javaScopeDecl,javaType,javaStorageClass,javaComment,javaLineComment,@javaClasses&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace this line in your &lt;code&gt;syntax/java.vim&lt;/code&gt; file, or create a new java.vim in &lt;code&gt;after/syntax&lt;/code&gt; and put it there. Either solution should work, but I have directly edited mine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately I want it to include &lt;strong&gt;only&lt;/strong&gt; the identifier and exclude the return type also. I had thought &lt;code&gt;\zs&lt;/code&gt; would achieve this, but it doesn't appear to work as stated in the Vim doc. When placed in front of the constructor regex, everything else is highlighted correctly except for constructors. When placed just after the return type regex, so as to omit the return type but include the non-constructor identifier regex, constructors are correctly highlighted but nothing else is!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought there was hope when I read that it can be used multiple times. However, when placed in both spots, it completely disables the entire syntax rule. (I am guessing this is because with multiple &lt;code&gt;\zs&lt;/code&gt; atoms, only the last matching instance is used. I haven't found a way to have it take the first instead, or an alternate specifier which does that.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region javaFuncDef start=+^\s\+\(\(public\|protected\|private\|static\|abstract\|final\|native\|synchronized\)\s\+\)*\(\(void\|boolean\|char\|byte\|short\|int\|long\|float\|double\|\([A-Za-z_][A-Za-z0-9_$]*\.\)*[A-Z][A-Za-z0-9_$]*\)\(&amp;lt;[^&amp;gt;]*&amp;gt;\)\=\(\[\]\)*\s\+\zs[a-z][A-Za-z0-9_$]*\|\zs[A-Z][A-Za-z0-9_$]*\)\s*\ze(+ end=+\ze(+ contains=javaScopeDecl,javaType,javaStorageClass,javaComment,javaLineComment,@javaClasses&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10168" LastEditorUserId="10168" LastEditDate="2017-08-06T17:37:25.050" LastActivityDate="2017-08-06T17:37:25.050" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12429" PostTypeId="2" ParentId="11941" CreationDate="2017-05-17T21:16:17.870" Score="2" Body="&lt;p&gt;The following snippet maps &lt;code&gt;CTRL-g&lt;/code&gt; to show the current &quot;context&quot; (usually the current function):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-g&amp;gt; :echo getline(search('\v^[[:alpha:]$_]', &quot;bn&quot;, 1, 100))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the same hack used by git uses to show context hints. Credit to &lt;a href=&quot;https://github.com/frioux/vim-lost&quot; rel=&quot;nofollow noreferrer&quot;&gt;lost.vim&lt;/a&gt; for the idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Tommy A mentioned, a tags-based solution like &lt;a href=&quot;https://github.com/majutsushi/tagbar&quot; rel=&quot;nofollow noreferrer&quot;&gt;tagbar&lt;/a&gt; is more robust. And the most robust solution would be to use a real code-inspection engine, e.g. &lt;a href=&quot;https://github.com/autozimu/LanguageClient-neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;LSP&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="578" LastEditorUserId="578" LastEditDate="2017-05-25T20:28:12.100" LastActivityDate="2017-05-25T20:28:12.100" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12430" PostTypeId="1" AcceptedAnswerId="12431" CreationDate="2017-05-18T07:19:26.457" Score="2" ViewCount="402" Body="&lt;p&gt;I am trying to make a little function that aims to extract a method from a piece of php code. The function works fine. Is not optipized but &quot;done is better than perfect&quot; and the purpose here is not perfectio but just, ... keep expandtab settings right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/N6c3n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/N6c3n.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here the incriminated code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ExtractMethod() range&#xA;    let g:selection = s:get_visual_selection()&#xA;    exec &quot;:set paste&quot;&#xA;    exec &quot;:normal! Gko\&amp;lt;esc&amp;gt;o\&amp;lt;esc&amp;gt;Spublic function xxxxxxx()\&amp;lt;esc&amp;gt;==&quot;&#xA;    exec &quot;:normal! o\t{\&amp;lt;esc&amp;gt;&quot;&#xA;    exec &quot;:normal! o&quot; . g:selection . &quot;\&amp;lt;esc&amp;gt;&quot;&#xA;    exec &quot;:normal! o\t}\&amp;lt;esc&amp;gt;%k2w&quot;&#xA;endfun&#xA;function! s:get_visual_selection()&#xA;    let [lnum1, col1] = getpos(&quot;'&amp;lt;&quot;)[1:2]&#xA;    let [lnum2, col2] = getpos(&quot;'&amp;gt;&quot;)[1:2]&#xA;    let lines = getline(lnum1, lnum2)&#xA;    let lines[-1] = lines[-1][: col2 - 2]&#xA;    let lines[0] = lines[0][col1 - 1:]&#xA;    return join(lines, &quot;\n&quot;)&#xA;endfunction&#xA;vnoremap &amp;lt;Leader&amp;gt;r :call ExtractMethod()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2965" LastActivityDate="2017-05-18T09:07:45.070" Title="Why this function disable expandtab?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12431" PostTypeId="2" ParentId="12430" CreationDate="2017-05-18T08:16:18.380" Score="5" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27paste%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h paste&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When the 'paste' option is switched on (also when it was already on):&#xA;        - mapping in Insert mode and Command-line mode is disabled&#xA;        - abbreviations are disabled&#xA;        - 'autoindent' is reset&#xA;        - 'expandtab' is reset&#xA;        - 'formatoptions' is used like it is empty&#xA;        - 'revins' is reset&#xA;        - 'ruler' is reset&#xA;        - 'showmatch' is reset&#xA;        - 'smartindent' is reset&#xA;        - 'smarttab' is reset&#xA;        - 'softtabstop' is set to 0&#xA;        - 'textwidth' is set to 0&#xA;        - 'wrapmargin' is set to 0&#xA;These options keep their value, but their effect is disabled:&#xA;        - 'cindent'&#xA;        - 'indentexpr'&#xA;        - 'lisp'&#xA;...&#xA;When the 'paste' option is reset the mentioned options are restored to&#xA;the value before the moment 'paste' was switched from off to on.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, reset &lt;code&gt;paste&lt;/code&gt; at the end of your function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ExtractMethod() range&#xA;    let g:selection = s:get_visual_selection()&#xA;    set paste&#xA;    exec &quot;:normal! Gko\&amp;lt;esc&amp;gt;o\&amp;lt;esc&amp;gt;Spublic function xxxxxxx()\&amp;lt;esc&amp;gt;==&quot;&#xA;    exec &quot;:normal! o\t{\&amp;lt;esc&amp;gt;&quot;&#xA;    exec &quot;:normal! o&quot; . g:selection . &quot;\&amp;lt;esc&amp;gt;&quot;&#xA;    exec &quot;:normal! o\t}\&amp;lt;esc&amp;gt;%k2w&quot;&#xA;    set nopaste&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2017-05-18T09:07:45.070" LastActivityDate="2017-05-18T09:07:45.070" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12432" PostTypeId="1" CreationDate="2017-05-18T13:17:34.743" Score="0" ViewCount="662" Body="&lt;p&gt;When I start vim (homebrew installation, &lt;code&gt;/usr/local/bin/vim&lt;/code&gt;), I get the error &quot;Python quit unexpectedly.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I make python work with my vim?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ which vim&#xA;/usr/local/bin/vim&#xA;&#xA;$ which python&#xA;/usr/local/bin/python&#xA;&#xA;$ which python3&#xA;/usr/local/bin/python3&#xA;&#xA;$ vim --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 17 2017 10:08:18)&#xA;MacOS X (unix) version&#xA;Included patches: 1-599&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     -tcl&#xA;-balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;-browse          -footer          +multi_byte      +terminfo&#xA;++builtin_terms  +fork()          +multi_lang      +termresponse&#xA;+byte_offset     -gettext         -mzscheme        +textobjects&#xA;+channel         -hangul_input    +netbeans_intg   +timers&#xA;+cindent         +iconv           +num64           +title&#xA;-clientserver    +insert_expand   +packages        -toolbar&#xA;+clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        +perl            +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       +python          +vreplace&#xA;+cscope          +lispindent      -python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con      -lua             +rightleft       +writebackup&#xA;+diff            +menu            +ruby            -X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;-dnd             +modify_fname    +signs           -xim&#xA;-ebcdic          +mouse           +smartindent     -xpm&#xA;+emacs_tags      -mouseshape      +startuptime     -xsmp&#xA;+eval            +mouse_dec       +statusline      -xterm_clipboard&#xA;+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save&#xA;+extra_search    -mouse_jsbterm   +syntax          &#xA;+farsi           +mouse_netterm   +tag_binary      &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: clang   -L. -L/usr/local/lib  -L/usr/local/lib -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -F/usr/local/opt/python/Frameworks -framework Python   -lruby.2.0.0 -lobjc    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="51" LastEditDate="2017-05-18T13:20:30.143" LastActivityDate="2017-09-15T15:40:16.063" Title="Python quit unexpectedly" Tags="|vimscript-python|macos|crash|" AnswerCount="1" CommentCount="7" ClosedDate="2017-09-18T08:04:24.647" ContentLicense="CC BY-SA 3.0" />
  <row Id="12433" PostTypeId="2" ParentId="12432" CreationDate="2017-05-18T13:52:58.103" Score="1" Body="&lt;p&gt;Running &lt;code&gt;brew unlink python&lt;/code&gt; fixed the problem for me, now vim runs with python fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it has caused my plugins like YCM to start crashing.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2017-05-18T13:52:58.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12434" PostTypeId="2" ParentId="3328" CreationDate="2017-05-18T17:19:47.010" Score="0" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;When the cursor is anywhere on the word,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;yiw&lt;/code&gt; - yank the word and store it in &lt;code&gt;0&lt;/code&gt; register.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to the target word to be replaced&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ciw&lt;/code&gt; will delete the word and put you in insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ctrl-r&lt;/code&gt;. A &lt;code&gt;&quot;&lt;/code&gt; will pop up asking the register to be invoked.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; will paste the yanked word.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Yanked words are (normally!) stored in &lt;code&gt;0&lt;/code&gt; register. See &lt;code&gt;:registers&lt;/code&gt; to view the  stored buffers.&#xA;This may seem a lengthy procedure, IMHO this opens the door to the much more sophisticated register tricks.&lt;/p&gt;&#xA;" OwnerUserId="11864" LastActivityDate="2017-05-18T17:19:47.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12435" PostTypeId="1" AcceptedAnswerId="12444" CreationDate="2017-05-19T10:31:25.290" Score="5" ViewCount="6316" Body="&lt;p&gt;I'm trying to use &lt;code&gt;:grep&lt;/code&gt; to search for one of several words. Since grep accepts regular expressions, I figured I could just use the pipe character &lt;code&gt;|&lt;/code&gt; to build a single expression for both words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:grep -E 'foo|baz' *.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim interprets the &lt;code&gt;|&lt;/code&gt; as a separator between two commands. &lt;code&gt;:help :bar&lt;/code&gt; suggests that I could escape it as &lt;code&gt;\|&lt;/code&gt;, but that doesn't work, either. It seems that the &lt;code&gt;:grep&lt;/code&gt; command does not handle backspaces and quotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help map-bar&lt;/code&gt; also offers the suggestion to use &lt;code&gt;^V|&lt;/code&gt;, which actually escapes the pipe character, but now the &lt;code&gt;^V&lt;/code&gt; is also in my pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, the only workaround I've found is using environment variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let $BAR = '|' | grep -E 'foo'$BAR'baz' *.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this is quite crazy in my opinion. Is there really no better way?&lt;/p&gt;&#xA;" OwnerUserId="12683" LastEditorUserId="1841" LastEditDate="2017-05-19T11:03:03.967" LastActivityDate="2017-05-19T23:07:45.747" Title="How to escape pipe character in `:make`, `:grep` and friends" Tags="|command-line|escape|makeprg|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12436" PostTypeId="1" CreationDate="2017-05-19T11:32:55.287" Score="3" ViewCount="1158" Body="&lt;p&gt;I noticed Vim will choose the correct syntax when I open a file that ends with &lt;code&gt;.c.in&lt;/code&gt; or &lt;code&gt;.pl.in&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to tell Vim to behave the same with extensions like &lt;code&gt;.c.mako&lt;/code&gt; or &lt;code&gt;.pl.mako&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How is it possible? &lt;/p&gt;&#xA;" OwnerUserId="2548" LastActivityDate="2022-12-06T05:32:48.063" Title="How to tell vim to behave the same for file extension .in and .mako" Tags="|syntax-highlighting|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12437" PostTypeId="2" ParentId="12325" CreationDate="2017-05-19T12:10:17.807" Score="3" Body="&lt;p&gt;I found this in &lt;a href=&quot;http://vimhelp.appspot.com/term.txt.html#xterm-function-keys&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help xterm-function-keys&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;An xterm can send function keys F1 to F4 in two modes: vt100 compatible or&#xA;not.  Because Vim may not know what the xterm is sending, both types of keys&#xA;are recognized.  The same happens for the &amp;lt;Home&amp;gt; and &amp;lt;End&amp;gt; keys.&#xA;                        normal                  vt100&#xA;        &amp;lt;F1&amp;gt;    t_k1    &amp;lt;Esc&amp;gt;[11~       &amp;lt;xF1&amp;gt;   &amp;lt;Esc&amp;gt;OP     &amp;lt;xF1&amp;gt;-xterm&#xA;        &amp;lt;F2&amp;gt;    t_k2    &amp;lt;Esc&amp;gt;[12~       &amp;lt;xF2&amp;gt;   &amp;lt;Esc&amp;gt;OQ     &amp;lt;xF2&amp;gt;-xterm&#xA;        &amp;lt;F3&amp;gt;    t_k3    &amp;lt;Esc&amp;gt;[13~       &amp;lt;xF3&amp;gt;   &amp;lt;Esc&amp;gt;OR     &amp;lt;xF3&amp;gt;-xterm&#xA;        &amp;lt;F4&amp;gt;    t_k4    &amp;lt;Esc&amp;gt;[14~       &amp;lt;xF4&amp;gt;   &amp;lt;Esc&amp;gt;OS     &amp;lt;xF4&amp;gt;-xterm&#xA;        &amp;lt;Home&amp;gt;  t_kh    &amp;lt;Esc&amp;gt;[7~        &amp;lt;xHome&amp;gt; &amp;lt;Esc&amp;gt;OH     &amp;lt;xHome&amp;gt;-xterm&#xA;        &amp;lt;End&amp;gt;   t_@7    &amp;lt;Esc&amp;gt;[4~        &amp;lt;xEnd&amp;gt;  &amp;lt;Esc&amp;gt;OF     &amp;lt;xEnd&amp;gt;-xterm&#xA;&#xA;When Vim starts, &amp;lt;xF1&amp;gt; is mapped to &amp;lt;F1&amp;gt;, &amp;lt;xF2&amp;gt; to &amp;lt;F2&amp;gt; etc.  This means that&#xA;by default both codes do the same thing.  If you make a mapping for &amp;lt;xF2&amp;gt;,&#xA;because your terminal does have two keys, the default mapping is overwritten,&#xA;thus you can use the &amp;lt;F2&amp;gt; and &amp;lt;xF2&amp;gt; keys for something different.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;em&gt;both&lt;/em&gt; &lt;code&gt;&amp;lt;Home&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;xHome&amp;gt;&lt;/code&gt; seems to work well! Because we &lt;em&gt;only&lt;/em&gt; want this to take effect inside xterm I added a &lt;code&gt;&amp;amp;term&lt;/code&gt; check (tmux is &lt;code&gt;screen-256color&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&#xA;if &amp;amp;term == &quot;xterm-256color&quot;&#xA;    &quot; `^[` is the escape character.&#xA;    set &amp;lt;Home&amp;gt;=^[OH&#xA;    set &amp;lt;xHome&amp;gt;=^[OH&#xA;endif&#xA;&#xA;noremap &amp;lt;Home&amp;gt; :echoerr &quot;home!&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd be lying if I'd say that I fully comprehend all of the above, but it seems to work well without ill effects in my testing.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-05-19T12:10:17.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12438" PostTypeId="2" ParentId="12436" CreationDate="2017-05-19T13:54:56.153" Score="2" Body="&lt;p&gt;You can use autocommands in your .vimrc like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;au BufNewFile,BufRead ?\+.c.mako setf c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will make all &lt;code&gt;*.c.mako&lt;/code&gt; files behave like &lt;code&gt;*.c&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make an analogous for &lt;code&gt;*.pl.mako&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you genenerally want &lt;code&gt;*.any.mako&lt;/code&gt; to behave like &lt;code&gt;*.any&lt;/code&gt; then you can use this autocommand:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;au BufNewFile,BufRead ?\+.mako exe &quot;doau filetypedetect BufRead &quot; . fnameescape(expand(&quot;&amp;lt;afile&amp;gt;:r&quot;))&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-05-19T13:54:56.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12440" PostTypeId="1" CreationDate="2017-05-19T14:48:08.830" Score="1" ViewCount="214" Body="&lt;p&gt;I was modifying an email template and I noticed that when moving the cursor over a piece of code it changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a screenshot from before:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Yr66z.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Yr66z.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and after:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CeDxy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CeDxy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim version is 7.4 on Ubuntu 16.04. Any idea what would make something like this happen?&lt;/p&gt;&#xA;" OwnerUserId="12688" LastEditorUserId="51" LastEditDate="2017-05-19T15:00:40.167" LastActivityDate="2017-07-18T16:15:49.643" Title="Text changes when moving cursor over" Tags="|terminal|cursor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12441" PostTypeId="2" ParentId="12440" CreationDate="2017-05-19T14:49:55.273" Score="1" Body="&lt;p&gt;Your terminal window isn't configured to display colors properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can test whether this is the case by disabling color in vim and see if the problem goes away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Disables color features in vim:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax off&#xA;:set nohlsearch&#xA;:set t_Co=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this fixes it but you want color support, the next step I suggest is to check your terminal emulator and shell configuration for ANSI support.&lt;/p&gt;&#xA;" OwnerUserId="12113" LastEditorUserId="12113" LastEditDate="2017-05-19T14:55:16.180" LastActivityDate="2017-05-19T14:55:16.180" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12444" PostTypeId="2" ParentId="12435" CreationDate="2017-05-19T23:07:45.747" Score="5" Body="&lt;p&gt;As stated on the question, &lt;code&gt;:h map-bar&lt;/code&gt; suggests escaping the pipe with with &lt;code&gt;\|&lt;/code&gt;.&#xA;However, grep apparently understands that as a literal bar, thus the backslash needs to be escaped as well. This should work for grep:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:grep -E 'foo\\|baz' *.c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: there's no need to escape the backslash with &lt;strong&gt;vimgrep&lt;/strong&gt; (&lt;code&gt;:h :vimgrep&lt;/code&gt;). The following seems to give the same results here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:vimgrep 'foo\|baz' *.c&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10493" LastActivityDate="2017-05-19T23:07:45.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12445" PostTypeId="1" AcceptedAnswerId="12447" CreationDate="2017-05-21T01:23:10.593" Score="16" ViewCount="11080" Body="&lt;p&gt;I'm currently trying to figure out vimscript and I stumbled upon the &lt;code&gt;append()&lt;/code&gt; function. The documentation states that you can specify the line to which an expression should be appended to, so I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call append(line('.'), Foo())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Foo()&lt;/code&gt; returns a string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The weird thing is that the string is appended to the next line after my current one. So I tried &lt;code&gt;line('.') - 1&lt;/code&gt;, just to see that it appends to the line above the current one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm amazed, confused and speechless at this moment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope someone can shed some light on this.&lt;/p&gt;&#xA;" OwnerUserId="5046" LastEditorUserId="51" LastEditDate="2017-05-21T17:24:15.097" LastActivityDate="2023-12-02T21:41:10.997" Title="How can I append text to the current line?" Tags="|vimscript|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12447" PostTypeId="2" ParentId="12445" CreationDate="2017-05-21T02:33:06.587" Score="11" Body="&lt;p&gt;&lt;code&gt;append()&lt;/code&gt; inserts &lt;em&gt;several lines&lt;/em&gt; of text below the line specified as the first argument.  This is in line with the &lt;code&gt;append&lt;/code&gt; ex command.  You can for example type &lt;code&gt;:append&lt;/code&gt; (and enter ex mode) then write several lines of text and exit ex mode (by pressing &lt;code&gt;&amp;lt;c-c&amp;gt;&lt;/code&gt; for example), the lines will appear after the line your cursor is on.  In other words, the &lt;code&gt;append&lt;/code&gt; command means: append the lines of text I'll write below the current one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The VimScript function &lt;code&gt;append()&lt;/code&gt; allows for line specifiers, which makes it more useful than the ex command.  Useful things that come often are ways of injecting pieces of text at the beginning and end of a file.  e.g. for LaTeX this may be useful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call append(line('^'), [ '\documentclass[12pt]{article}'&#xA;\                      , '\begin{document}'])&#xA;call append(line('$'), '\end{document}')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;line('$')&lt;/code&gt; is the last line in the file and &lt;code&gt;line('^')&lt;/code&gt; always returns &lt;code&gt;0&lt;/code&gt; (and I could have written that instead without problems).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the behaviour of Vim's &lt;code&gt;A&lt;/code&gt;, or any other Vim normal mode command you can use &lt;code&gt;normal&lt;/code&gt;.  To get the output of &lt;code&gt;Foo()&lt;/code&gt; to appear at the end of a line may be a little more complicated, one way is to use &lt;code&gt;execute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute ':normal! A' . Foo()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can use append and then perform &lt;code&gt;J&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call append(line('.'), Foo())&#xA;normal! Jx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that &lt;code&gt;x&lt;/code&gt; is needed to remove the space generated by &lt;code&gt;J&lt;/code&gt;, but this may not work as expected if the string generated by &lt;code&gt;Foo()&lt;/code&gt; starts with spaces).&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2017-05-21T02:50:18.140" LastActivityDate="2017-05-21T02:50:18.140" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12449" PostTypeId="2" ParentId="730" CreationDate="2017-05-21T13:42:56.480" Score="1" Body="&lt;p&gt;When you are on a server or system where you can't or don't want to change the configuration, the quickest way is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:i!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will enter insert mode with autoindent turned off, where you paste your text. When you are finished you need to type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;on its own line to end the insert.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-05-21T13:42:56.480" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12450" PostTypeId="2" ParentId="12445" CreationDate="2017-05-21T18:00:46.023" Score="17" Body="&lt;p&gt;The &lt;code&gt;append()&lt;/code&gt; function should perhaps have been named &lt;code&gt;appendline()&lt;/code&gt;: it only appends lines to the buffer. You can't change existing lines with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's like using the &lt;code&gt;a&lt;/code&gt; flag to &lt;code&gt;fopen()&lt;/code&gt;, or using &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; in the shell.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to &lt;em&gt;set&lt;/em&gt; the value of existing lines, then the easiest way to do that from VimScript is to use &lt;code&gt;setline()&lt;/code&gt;. For example to set the current line to &lt;code&gt;Coconuts&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setline('.', 'Coconuts')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;getline()&lt;/code&gt; to get the value of the current line, so to append &lt;code&gt;Coconuts&lt;/code&gt; to the line use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setline('.', getline('.') . 'Coconuts')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also set multiple lines by using a list (just like with &lt;code&gt;append()&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setline('.', ['Coconuts', 'Bananas'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To append text to multiple lines you'll have to use a &lt;code&gt;for&lt;/code&gt; loop.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that the above is not the &lt;em&gt;only&lt;/em&gt; way. Other ways would be to use &lt;code&gt;:substitute&lt;/code&gt; (e.g. &lt;code&gt;:s/$/\=Foo()/&lt;/code&gt;) or &lt;a href=&quot;https://vi.stackexchange.com/a/12447/51&quot;&gt;grochmal's answer&lt;/a&gt;. The &quot;best&quot; way depends on the context where you're using it as well as personal preference.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-05-21T18:00:46.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12452" PostTypeId="1" CreationDate="2017-05-22T09:20:01.150" Score="2" ViewCount="55" Body="&lt;p&gt;Is it possible to have vim highlight folds differently depending on whether every line in a fold is only comments or whitespace? In that case, how?&lt;/p&gt;&#xA;" OwnerUserId="12054" LastActivityDate="2017-05-22T09:20:01.150" Title="Syntax highlighting depending on whether whole line is commented" Tags="|syntax-highlighting|highlight|folding|comments|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12453" PostTypeId="2" ParentId="2082" CreationDate="2017-05-22T14:32:28.197" Score="0" Body="&lt;p&gt;What i've managed to send to Vim is:&#xA;&lt;code&gt;'&amp;lt;C-\\&amp;gt;&amp;lt;C-N&amp;gt;:1wincmd&amp;lt;C-q&amp;gt;x20w&amp;lt;CR&amp;gt;'&lt;/code&gt;&#xA;Where space is defined as x20 which means insert hex$20.&lt;/p&gt;&#xA;" OwnerUserId="12719" LastActivityDate="2017-05-22T14:32:28.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12454" PostTypeId="1" AcceptedAnswerId="12458" CreationDate="2017-05-22T20:32:16.830" Score="1" ViewCount="128" Body="&lt;p&gt;In order to switch between relative and absolute line numbering upon entering command-line, I &lt;code&gt;noremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt;&lt;/code&gt; to &lt;code&gt;&quot;someStuff&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately this breaks the &lt;code&gt;foldopen&lt;/code&gt;-ing feature for forward searches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It already happens with the following line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;MWE&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;entire &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=marker&#xA;&quot;default foldopen&#xA;set foldopen=block,hor,mark,percent,quickfix,search,tag,undo&#xA;cnoremap &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;text file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{{{&#xA;lkj&#xA;}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;maneuver : normal-mode-type &lt;code&gt;/lkj&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and the fold does not open&lt;/p&gt;&#xA;&#xA;&lt;p&gt;comment the &lt;code&gt;cnoremap&lt;/code&gt; reload and do the same, the fold does open&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Attempts&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I somewhat managed to walk around the issue with a silly hack such as :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;i&amp;lt;C-c&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;unfortunately this breaks the &lt;code&gt;repeat (.)&lt;/code&gt; history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following works : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;mf.u`f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;except at the opening of a vim session, when the &lt;code&gt;.&lt;/code&gt; repeat does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to achieve the &lt;code&gt;cnoremap&lt;/code&gt;ping &lt;code&gt;&amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;&lt;/code&gt; in a fully transparent way ?&lt;/p&gt;&#xA;" OwnerUserId="8748" LastEditorUserId="51" LastEditDate="2017-05-23T10:30:57.573" LastActivityDate="2017-05-23T10:30:57.573" Title="cnoremap &lt;CR&gt; &lt;CR&gt; breaks search fold opening" Tags="|key-bindings|search|folding|jumplist|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12455" PostTypeId="1" AcceptedAnswerId="12457" CreationDate="2017-05-22T20:50:11.627" Score="0" ViewCount="177" Body="&lt;p&gt;I would like to open all folds in a buffer recursively apart from folds which contain just text and no further folds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that &lt;code&gt;zO&lt;/code&gt; opens all folds in a buffer but as explained this is different from what I would like to achieve. Furthermore it will also not help to set a specific fold level because the depth in the fold hierarchy is very different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to achieve what I want?&lt;/p&gt;&#xA;" OwnerUserId="10358" LastActivityDate="2017-05-23T17:58:56.123" Title="How can I open all folds but the last one?" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12456" PostTypeId="1" CreationDate="2017-05-22T23:51:46.440" Score="1" ViewCount="755" Body="&lt;p&gt;My computer crashed while in the middle of editing several vim files. Upon reboot, two of the files getting edited showed a file size 0 bytes. I was able to recover one of the .swp files with the &lt;code&gt;:recover&lt;/code&gt; command. However, when I try to &lt;code&gt;:recover&lt;/code&gt; on the other file I get &lt;code&gt;so swap file found for .Organizer.pm.swp&lt;/code&gt; in the status line even though the file exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything else I can try? &lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="2021" LastEditDate="2017-05-22T23:57:51.003" LastActivityDate="2017-05-22T23:57:51.003" Title="Unable to recover .swp file" Tags="|swap-file|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12457" PostTypeId="2" ParentId="12455" CreationDate="2017-05-23T00:55:19.747" Score="0" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;zM&#xA;:folddoclosed if foldlevel('.') &amp;lt; foldlevel(line('.')+1) | exe 'norm! zo' | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Close all folds. Then, iterating over all lines in closed folds, check if the subsequent line has a greater foldlevel. If so, unfold the current line.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2017-05-23T17:58:56.123" LastActivityDate="2017-05-23T17:58:56.123" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12458" PostTypeId="2" ParentId="12454" CreationDate="2017-05-23T05:47:58.133" Score="3" Body="&lt;p&gt;As &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27foldopen%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'foldopen'&lt;/code&gt;&lt;/a&gt; states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;NOTE: When the command is part of a mapping this option is not used.&#xA;    Add the |zv| command to the mapping to get the same effect.&#xA;    (rationale: the mapping may want to control opening folds itself)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you should add the &lt;code&gt;zv&lt;/code&gt; to your mapping, e.g. &lt;code&gt;cnoremap &amp;lt;cr&amp;gt; &amp;lt;cr&amp;gt;zv&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-05-23T05:47:58.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12459" PostTypeId="2" ParentId="11768" CreationDate="2017-05-23T12:20:37.500" Score="7" Body="&lt;p&gt;I did this by changing the registry key in &lt;code&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Vim\Gvim]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Edit with Vim&quot; opens gVim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;path=C:\Program Files\Vim\vim74\gvim.exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;Edit with Vim&quot; opens Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;path=C:\Program Files\Vim\vim74\vim.exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12728" LastEditorUserId="51" LastEditDate="2017-05-23T13:08:06.653" LastActivityDate="2017-05-23T13:08:06.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12461" PostTypeId="1" CreationDate="2017-05-23T15:22:07.047" Score="2" ViewCount="724" Body="&lt;p&gt;Currently when I open files in org mode all the top level bullet points are folded.  I can see why this is an OK default for a lot of people, but I prefer all text unfolded initially.  Is there a simple configuration to make this happen? &lt;/p&gt;&#xA;" OwnerUserId="12731" LastActivityDate="2019-08-06T13:02:31.450" Title="vim-orgmode: unfold everything on file open by default" Tags="|folding|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12462" PostTypeId="2" ParentId="12461" CreationDate="2017-05-23T16:38:08.543" Score="1" Body="&lt;p&gt;Perhaps the easiest is to put this in your &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldlevelstart=99&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-05-23T16:38:08.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12463" PostTypeId="1" CreationDate="2017-05-23T19:55:48.083" Score="0" ViewCount="83" Body="&lt;p&gt;I have a permanent register &lt;code&gt;&quot;T&lt;/code&gt;  and it's filled with something already.  When I yank something else into it, it's appended to the register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to clear out just that one register so I can yank something fresh to it without appending to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My command for yanking is &lt;code&gt;&quot;Ty&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've already tried several things in ex mode like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:call setreg('T', [])&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let @T=''&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And it doesn't go away....&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2017-05-23T21:05:46.740" Title="Clear the contents of a permanent register or yank to it without appending to it?" Tags="|register|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12464" PostTypeId="2" ParentId="12463" CreationDate="2017-05-23T21:05:46.740" Score="2" Body="&lt;p&gt;As Philippos &lt;a href=&quot;https://vi.stackexchange.com/questions/12463/clear-the-contents-of-a-permanent-register-or-yank-to-it-without-appending-to-it#comment21646_12463&quot;&gt;pointed out in the comments&lt;/a&gt;, if you use the lowercase register, i.e. &lt;code&gt;&quot;t&lt;/code&gt;, it will overwrite instead of append.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You were close with your ex commands to clear the register. However these ones should also be lowercase too. Either of these should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg('t', [])&#xA;:let @t=''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although I would probably recommend doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg('t', '') &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of &lt;code&gt;[]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-05-23T21:05:46.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12467" PostTypeId="1" CreationDate="2017-05-24T01:18:54.720" Score="5" ViewCount="424" Body="&lt;p&gt;is there anyway to log vim keypresses (or keypresses in general activated by vim) and record it somewhere (STDOUT, file, etc) in real time? I want somthing similar to &lt;code&gt;vim -w file.log file&lt;/code&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/4634/how-to-record-my-keyboard-input-to-do-statistics-on-it&quot;&gt;this question&lt;/a&gt;, but in real-time (within 5 seconds updates) and without saving the file.&lt;/p&gt;&#xA;" OwnerUserId="12733" LastEditorUserId="205" LastEditDate="2017-05-24T09:42:59.553" LastActivityDate="2017-05-24T09:42:59.553" Title="real time vim keylogger" Tags="|bash|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12468" PostTypeId="2" ParentId="5601" CreationDate="2017-05-24T08:38:09.683" Score="9" Body="&lt;p&gt;As suggested by &lt;a href=&quot;https://vi.stackexchange.com/questions/5601/why-are-my-windows-scrolling-together#comment8656_5601&quot;&gt;Christian Brabandt&lt;/a&gt; in the comments, this was caused by the &lt;code&gt;'cursorbind'&lt;/code&gt; setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help 'cursorbind'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When this option is set, as the cursor in the current window moves other cursorbound windows (windows that also have this option set) move their cursors to the corresponding line and column.  This option is useful for viewing the differences between two versions of a file (see 'diff'); in diff mode, inserted and deleted lines (though not characters within a line) are taken into account.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-05-24T08:38:09.683" CommentCount="0" CommunityOwnedDate="2017-05-24T08:38:09.683" ContentLicense="CC BY-SA 3.0" />
  <row Id="12470" PostTypeId="1" CreationDate="2017-05-24T11:37:01.373" Score="0" ViewCount="372" Body="&lt;p&gt;Say I'm doing a grep for something and in the results I have a bunch of files? How can I quickly open one of those files in vim without using the mouse and without or typing the name by hand?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, with my mouse I can CMD-Click the name of the file and it opens in vim. But I would like to have the same speed without using the mouse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: grep is just one example, I would like to know if there's a universal way to would work for any command. Something like a bash variable that holds the last file name or whatever. And also, it should open just the one file that I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7428" LastEditorUserId="7428" LastEditDate="2017-05-25T13:11:19.263" LastActivityDate="2017-06-24T13:38:01.257" Title="How do you open a file in vim from the terminal (osx)" Tags="|terminal|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12471" PostTypeId="2" ParentId="12470" CreationDate="2017-05-24T12:36:16.043" Score="0" Body="&lt;p&gt;You can make grep print just the file names with &lt;code&gt;grep -l -H&lt;/code&gt;.  You could then pipe this to &lt;code&gt;sort&lt;/code&gt; and &lt;code&gt;uniq&lt;/code&gt; to get a list of files.  This could then be passed to vim with xargs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say you wanted to open all files in the current directory or sub directories that contain the word &lt;code&gt;mail&lt;/code&gt;, you would type something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;grep -r -l -H &quot;mail&quot; . | sort | uniq | xargs vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12323" LastActivityDate="2017-05-24T12:36:16.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12472" PostTypeId="1" AcceptedAnswerId="12473" CreationDate="2017-05-24T13:50:56.520" Score="-2" ViewCount="54" Body="&lt;p&gt;The basic format I need it in is this. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/search/replace/c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I want it to search the entire file and ask for confirmation for every match found.&lt;/p&gt;&#xA;" OwnerUserId="12741" LastEditorUserId="51" LastEditDate="2017-05-24T14:22:14.467" LastActivityDate="2017-05-24T14:22:14.467" Title="Search for &quot; and replace with '" Tags="|regular-expression|" AnswerCount="1" CommentCount="4" ClosedDate="2017-05-25T11:52:39.317" ContentLicense="CC BY-SA 3.0" />
  <row Id="12473" PostTypeId="2" ParentId="12472" CreationDate="2017-05-24T14:06:34.410" Score="1" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&quot;/'/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;g&lt;/code&gt; is important, because otherwise the command will only replace the first &lt;code&gt;&quot;&lt;/code&gt; on each line.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-05-24T14:06:34.410" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12474" PostTypeId="2" ParentId="12362" CreationDate="2017-05-24T15:04:53.410" Score="2" Body="&lt;p&gt;The problem is that MacVim only provides some bare-bones facilities for emulating a terminal, and doesn't support &quot;advanced&quot; features such as a wide range of common terminal escape characters. You'll get the same problem when running &lt;code&gt;:shell&lt;/code&gt; from Gvim on Windows or Linux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim doesn't change the &lt;code&gt;TERM&lt;/code&gt; when using &lt;code&gt;:shell&lt;/code&gt;. You can still set it yourself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let $TERM = 'dumb'&#xA;:shell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should make your workaround in the zshrc file work. You will probably run in to problems with other commands though. Also see &lt;a href=&quot;https://vi.stackexchange.com/q/12311/51&quot;&gt;How do I know I am in a shell from vi command :sh?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have to either run Vim from a terminal or use NeoVim – which includes a full terminal emulator – if you want to use a fully-functional &lt;code&gt;:shell&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-05-24T15:15:11.590" LastActivityDate="2017-05-24T15:15:11.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12475" PostTypeId="1" AcceptedAnswerId="12477" CreationDate="2017-05-24T16:06:33.110" Score="36" ViewCount="15425" Body="&lt;p&gt;I saw someone insert the result of an expression in vim, but I don't remember how it was done.&lt;/p&gt;&#xA;&lt;p&gt;For example, say I want to calculate and insert the result of &lt;code&gt;7 * 7&lt;/code&gt;, is there a calculator that I can use to insert the results of this expression in Vim?&lt;/p&gt;&#xA;" OwnerUserId="7783" LastEditorUserId="23502" LastEditDate="2022-02-26T02:14:40.183" LastActivityDate="2023-02-04T00:29:57.187" Title="Math calculations in Vim?" Tags="|normal-mode|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12476" PostTypeId="2" ParentId="12475" CreationDate="2017-05-24T16:11:02.833" Score="10" Body="&lt;p&gt;Sorry to answer my own question so quickly. I found the following works in insert mode:&lt;/p&gt;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt;, then type &lt;code&gt;=7*7&lt;/code&gt;, then press &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="7783" LastEditorUserId="7244" LastEditDate="2022-09-08T07:52:15.167" LastActivityDate="2022-09-08T07:52:15.167" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="12477" PostTypeId="2" ParentId="12475" CreationDate="2017-05-24T16:12:09.127" Score="38" Body="&lt;p&gt;For this to work, you need to use the expression register. Which allows you to execute arbitrary vimscript and do something about the result of the evaluation. To use the expression register on insert mode you type &lt;code&gt;&amp;lt;C-r&amp;gt;=&lt;/code&gt; and then you can write vimscript on the command line to be executed. For your specific example you'll be doing the following keystrokes on insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;=7*7&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you'll end up with 49 inserted on your buffer.&lt;/p&gt;&#xA;" OwnerUserId="11690" LastActivityDate="2017-05-24T16:12:09.127" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12478" PostTypeId="2" ParentId="12470" CreationDate="2017-05-24T16:22:51.113" Score="1" Body="&lt;p&gt;When you use &lt;code&gt;grep -l&lt;/code&gt;, file names won't be repeated, so you don't need &lt;code&gt;sort | uniq&lt;/code&gt; or &lt;code&gt;sort -u&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;-p&lt;/code&gt; to open all files in tabs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;grep -rlH &quot;mail&quot; . | xargs vim -p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2017-05-24T16:22:51.113" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12479" PostTypeId="1" AcceptedAnswerId="12480" CreationDate="2017-05-24T16:46:20.267" Score="2" ViewCount="1300" Body="&lt;p&gt;I'm running the following command, but the &lt;code&gt;\&amp;lt;CR&amp;gt;&lt;/code&gt; becomes part of the regular expression in feedkeys...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:call feedkeys(&quot;0v/\(,\|$\)\&amp;lt;CR&amp;gt;&quot;)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make it an enter keypress instead?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="51" LastEditDate="2017-05-24T16:57:40.900" LastActivityDate="2017-05-24T16:57:40.900" Title="Feed keys visual mode and pressing enter?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12480" PostTypeId="2" ParentId="12479" CreationDate="2017-05-24T16:56:48.450" Score="2" Body="&lt;p&gt;The problem is that the backslashes are picked up by the double-quoted string in the &lt;code&gt;feedkeys()&lt;/code&gt; command. You'll need to use &lt;code&gt;\\&lt;/code&gt; if you want to pass literal backslashes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call feedkeys(&quot;0v/\\(,\\|$\\)\&amp;lt;CR&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command suffers from a mild case of &lt;a href=&quot;https://en.wikipedia.org/wiki/Leaning_toothpick_syndrome&quot; rel=&quot;nofollow noreferrer&quot;&gt;leaning toothpick syndrome&lt;/a&gt;. You can make it a bit simpler by adding &lt;code&gt;\\v&lt;/code&gt; so that you don't need to add so many backslashes in the first place:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call feedkeys(&quot;0v/\\v(,|$)\&amp;lt;CR&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For single quotes strings no backslashes have a special meaning, so you could also use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call feedkeys('0v/\(,\|$\)' . &quot;\&amp;lt;CR&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call feedkeys('0v/\(,\|$\)^[')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;^[&lt;/code&gt; is the literal Enter character (you can enter this by pressing &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;, it should show up in a different colour).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-05-24T16:56:48.450" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12481" PostTypeId="2" ParentId="2792" CreationDate="2017-05-24T19:09:47.110" Score="1" Body="&lt;p&gt;In Vim the closest you can get is (as Ingo's answer and Christian's comment mentioned) is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup viminfo&#xA;    autocmd!&#xA;    autocmd FocusLost   * wviminfo&#xA;    autocmd FocusGained * rviminfo&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's important to realize that the &lt;code&gt;Focus*&lt;/code&gt; autocommands aren't always run when you use Vim from a terminal, especially not if you're using tmux or screen. You should test this first by using &lt;code&gt;:au FocusLost :echoerr &quot;Focus lost!&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know there is no good work-around if these autocommands don't work for you. Using other events (such as &lt;code&gt;CursorHold&lt;/code&gt;) seem problematic to me due to timing issues that will almost certainly crop up.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Neovim comes with &quot;ShaDa&quot;, which is a replacement for Vim's viminfo system. One aspect where it's better is merging files from different instances, and while it doesn't directly support syncing between multiple instances (&lt;a href=&quot;https://github.com/neovim/neovim/issues/999&quot; rel=&quot;nofollow noreferrer&quot;&gt;yet&lt;/a&gt;), this seems to &lt;a href=&quot;https://www.reddit.com/r/neovim/comments/3oyy7m/shada_has_landed/cw1vv9n/&quot; rel=&quot;nofollow noreferrer&quot;&gt;work well for at least one Neovim developer&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup shada&#xA;  autocmd!&#xA;  autocmd CursorHold * rshada | wshada&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help shada-merging&lt;/code&gt; for details on the merging process.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-05-24T19:09:47.110" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12482" PostTypeId="2" ParentId="9803" CreationDate="2017-05-24T19:29:29.363" Score="2" Body="&lt;p&gt;There are some technical problems which prevent the bot from running. See &lt;a href=&quot;https://github.com/vim-scraper/vim-scraper/issues/78&quot; rel=&quot;nofollow noreferrer&quot;&gt;#78&lt;/a&gt; for details on that. In addition in &lt;a href=&quot;https://github.com/vim-scraper/vim-scraper/issues/88&quot; rel=&quot;nofollow noreferrer&quot;&gt;#88&lt;/a&gt; one of the maintainers mentioned:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Due to a lack of interested maintainers, right now we're discussing how to shut this project down... Should we delete everything? If not, how do we warn people that everything is stale and to use something else? Hoping to figure out a plan soon.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The bot has been broken since January 2016; almost a year and a half. And in that time no one seems to have cared enough to fix it. I wouldn't expect it to be fixed any time soon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My way to fix this was to migrate everything from Mercurial/BitBucket to Github and then &lt;a href=&quot;https://arp242.net/weblog/i-dont-like-git-but-im-going-to-migrate-my-projects-to-it.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;write a rant about it&lt;/a&gt;. The fact is that for better or for worse, git/GitHub is the &quot;de-facto&quot; standard with some degree of &quot;vendor lock-in&quot;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-05-24T19:29:29.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12483" PostTypeId="2" ParentId="10016" CreationDate="2017-05-24T19:31:10.607" Score="2" Body="&lt;p&gt;To expand on @DJ Madeira's answer, I made this function reusable, since I am also using ctrl+l for MRU list&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; CtrlP&#xA;&quot; Use this function to prevent CtrlP opening files inside non-writeable &#xA;buffers, e.g. NERDTree&#xA;function! SwitchToWriteableBufferAndExec(command)&#xA;    let c = 0&#xA;    let wincount = winnr('$')&#xA;    &quot; Don't open it here if current buffer is not writable (e.g. NERDTree)&#xA;    while !empty(getbufvar(+expand(&quot;&amp;lt;abuf&amp;gt;&quot;), &quot;&amp;amp;buftype&quot;)) &amp;amp;&amp;amp; c &amp;lt; wincount&#xA;        exec 'wincmd w'&#xA;        let c = c + 1&#xA;    endwhile&#xA;    exec a:command&#xA;endfunction&#xA;&#xA;&quot; Disable default mapping since we are overriding it with our command&#xA;let g:ctrlp_map = ''&#xA;nnoremap &amp;lt;C-p&amp;gt; :call SwitchToWriteableBufferAndExec('CtrlP')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-l&amp;gt; :call SwitchToWriteableBufferAndExec('CtrlPMRUFiles')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12755" LastActivityDate="2017-05-24T19:31:10.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12484" PostTypeId="1" AcceptedAnswerId="14929" CreationDate="2017-04-01T01:54:02.407" Score="4" ViewCount="399" Body="&lt;p&gt;In Ultisnips, is there a way to create a snippet that will replace empty space in the snippet with a &lt;code&gt;*&lt;/code&gt; character upon exiting Insert mode (or as I type)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I have a snippet that looks like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet cch&#xA;/******************************/&#xA;/* ${1} */&#xA;/******************************/&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After expanding this snippet, I would like to fill the space around the input &lt;code&gt;${1}&lt;/code&gt; with &lt;code&gt;*&lt;/code&gt; characters after exiting Insert mode such that the width of this line will match the lines above and below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if I type &lt;code&gt;cch &amp;lt;tab&amp;gt;&lt;/code&gt; and then &lt;code&gt;Function Prototypes &amp;lt;Esc&amp;gt;&lt;/code&gt; it will look like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/******************************/&#xA;/***** Function Prototypes ****/&#xA;/******************************/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="12628" OwnerDisplayName="Jin" LastEditorUserId="51" LastEditDate="2017-05-24T20:23:56.097" LastActivityDate="2018-03-02T15:46:38.330" Title="Automatically insert characters with Ultisnips upon exiting Insert mode" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12486" PostTypeId="1" CreationDate="2017-05-25T01:49:58.313" Score="1" ViewCount="412" Body="&lt;p&gt;When I use &lt;code&gt;CTRL+]&lt;/code&gt; to jump to a tag, the cursor will be placed at the center of the window. How can I make it stop at the top of the window? Now I do this by pressing &lt;code&gt;CTRL+D&lt;/code&gt; after each jump. I was wondering whether vim can do this for me automatically.&lt;/p&gt;&#xA;" OwnerUserId="11755" LastActivityDate="2017-05-25T01:49:58.313" Title="How to make vim automatically do a CTRL+D after jumping to a tag?" Tags="|cursor-movement|tags|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12487" PostTypeId="1" AcceptedAnswerId="12509" CreationDate="2017-05-25T02:42:25.967" Score="0" ViewCount="74" Body="&lt;p&gt;I am implementing a custom text object in visual mode, but this text object uses regular expressions to find the beginning and ending of the selection. However, when I do this, other parts of the text are also hilighted. As an additional problem, the searches are added to my search history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can these two things be avoided?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to creating a visual-mode text object, determining the start and end position using the search backward (&lt;code&gt;?&lt;/code&gt;) and search forward (&lt;code&gt;/&lt;/code&gt;) operators, similar to the following (the regular expression is just a test for now).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap ue ?[^a-zA-Z0-9]\\|^&amp;lt;cr&amp;gt;v/[a-zA-Z0-9]\+/e&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;ue&lt;/code&gt; is pressed in visual mode:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The above searches backwards for a character that is not &lt;code&gt;a-z&lt;/code&gt;, &lt;code&gt;A-Z&lt;/code&gt; or &lt;code&gt;0-9&lt;/code&gt; or until the beginning of the line. This is the text &lt;code&gt;?[^a-zA-Z0-9]\\|^&amp;lt;cr&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;It then enters visual mode with &lt;code&gt;v&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;It then searches forward for the last character that is &lt;code&gt;a-z&lt;/code&gt;, &lt;code&gt;A-Z&lt;/code&gt; or &lt;code&gt;0-9&lt;/code&gt;. This is text &lt;code&gt;/[a-zA-Z0-9]\+/e&amp;lt;cr&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The above works fine, but ends up highlighting all characters in the last search expression (step 3). I've tried appending &lt;code&gt;:noh&amp;lt;cr&amp;gt;&lt;/code&gt; to the mapping, but this causes the selection to be lost. How can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="10101" LastEditorUserId="1292" LastEditDate="2019-01-24T13:13:49.597" LastActivityDate="2019-01-24T13:13:49.597" Title="How can you turn off text highlighting (hlsearch) with custom text objects?" Tags="|visual-mode|cursor-motions|custom-text-object|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12488" PostTypeId="1" AcceptedAnswerId="12491" CreationDate="2017-05-25T14:01:20.423" Score="3" ViewCount="99" Body="&lt;p&gt;I am trying to create a text object for consecutive lower-case letters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how I am setting up the inner text object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap in :&amp;lt;C-u&amp;gt;normal! ?[^a-z]?e+1&amp;lt;CR&amp;gt;v/[^a-z]/s-1&amp;lt;CR&amp;gt;&#xA;onoremap in :normal vin&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following shows what happens when I type &lt;code&gt;vin&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[text]               some important text&#xA;[cursor]                       |&#xA;[expected selection]      ^^^^^^^^^&#xA;[actual selection]             ^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then tried the following with the same text and cursor position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v:&amp;lt;C-u&amp;gt;normal! ?i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The cursor didn't move.  I expected it to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Searching forward doesn't work either:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v:&amp;lt;C-u&amp;gt;normal! /t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However all these work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v:&amp;lt;C-u&amp;gt;normal! b&#xA;v:&amp;lt;C-u&amp;gt;normal! e&#xA;v:&amp;lt;C-u&amp;gt;normal! Fi&#xA;v:&amp;lt;C-u&amp;gt;normal! ft&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I solve this?&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2017-05-25T16:08:51.373" Title="How to search in visual mapping?" Tags="|cursor-motions|visual-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12489" PostTypeId="2" ParentId="11353" CreationDate="2017-05-25T15:00:33.097" Score="0" Body="&lt;p&gt;It turns out my &lt;code&gt;.viminfo&lt;/code&gt; file was owned by &lt;code&gt;root&lt;/code&gt;.  Fixing the permissions on it solved this problem.&lt;/p&gt;&#xA;" OwnerUserId="2399" LastActivityDate="2017-05-25T15:00:33.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12490" PostTypeId="1" AcceptedAnswerId="12512" CreationDate="2017-05-25T15:38:35.417" Score="2" ViewCount="350" Body="&lt;p&gt;I'm using Vim to write LaTeX on my Mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could make a shortcut to execute &lt;code&gt;pdflatex&lt;/code&gt; (it should be possible right?) and see the result on Preview. But it steals the focus when it updates to the new pdf, so it's quite annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do you suggest?&lt;/p&gt;&#xA;" OwnerUserId="12771" LastEditorUserId="51" LastEditDate="2017-05-25T16:47:07.173" LastActivityDate="2017-06-15T14:30:31.550" Title="How can I show a preview of my LaTeX buffer without stealing focus from Vim?" Tags="|external-command|filetype-tex|macos|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12491" PostTypeId="2" ParentId="12488" CreationDate="2017-05-25T16:08:51.373" Score="2" Body="&lt;p&gt;This is because the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in your mapping signals to the &lt;em&gt;norm command&lt;/em&gt; to finish, not for the the &lt;code&gt;?&lt;/code&gt; command to finish. So when you get to the first &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, the command that vim runs is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! ?[^a-z]?e+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this command &lt;em&gt;does not do anything&lt;/em&gt;. Because you don't hit enter by the time the normal command is over, nothing actually happens. So here we have a dilemma. We need to tell vim to press enter &lt;em&gt;inside of&lt;/em&gt; the normal command, but we can't press enter (because that finishes the normal command). Here is where we use &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; to enter a literal carriage return.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to put a &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; before every &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; that is not the final &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in your command. This makes the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap in :&amp;lt;C-u&amp;gt;normal! ?[^a-z]?e+1&amp;lt;C-v&amp;gt;&amp;lt;CR&amp;gt;v/[^a-z]/s-1&amp;lt;C-v&amp;gt;&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;onoremap in :normal vin&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some unrelated side notes about your approach:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;This approach only works if you're in the middle of your object. If you're at the beginning of it, things break.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Using &lt;code&gt;\L&lt;/code&gt; is equivalent to &lt;code&gt;[^a-z]&lt;/code&gt;, and is faster and more readable.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-05-25T16:08:51.373" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12492" PostTypeId="1" CreationDate="2017-05-25T16:09:41.193" Score="-1" ViewCount="465" Body="&lt;p&gt;Given the following block of text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;title,tags&#xA;Run-ons - Comma Splices - Fused Sentences&#xA;Rule 1 - Run-ons - Comma Splices - Fused Sentences &#xA;Rule 2 - Run-ons - Comma Splices - Fused Sentences&#xA;Example 1 - Rule 1 - Run-ons - Comma Splices - Fused Sentences&#xA;Example 1 - Rule 2 - Run-ons - Comma Splices - Fused Sentences&#xA;Example 2 - Rule 2 - Run-ons - Comma Splices - Fused Sentences&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does the following code result in the same value twice instead of the contents of line 2 followed by the contents of line 3?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TempTest()&#xA;&#xA;    messages clear&#xA;&#xA;    call cursor(2, 1)&#xA;&#xA;    call feedkeys('0v/\(,\|$\)' . &quot;\&amp;lt;CR&amp;gt;&quot; . 'h&quot;ay')&#xA;    let l:v = '' . @a&#xA;    echom 'l:v ' . l:v&#xA;&#xA;    call cursor(3, 1)&#xA;&#xA;    call feedkeys('0v/\(,\|$\)' . &quot;\&amp;lt;CR&amp;gt;&quot; . 'h&quot;ay')&#xA;    let l:v = '' . @a&#xA;    echom 'l:v ' . l:v&#xA;&#xA;    messages&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;l:v Rule 1 - Run-ons - Comma Splices - Fused Sentences&#xA;l:v Rule 1 - Run-ons - Comma Splices - Fused Sentences&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Expected Results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; l:v Run-ons - Comma Splices - Fused Sentences&#xA; l:v Rule 1 - Run-ons - Comma Splices - Fused Sentences&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="51" LastEditDate="2017-05-26T16:10:56.253" LastActivityDate="2017-05-26T16:10:56.253" Title="Can't reassign local variable value from register?" Tags="|vimscript|register|variables|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12493" PostTypeId="2" ParentId="2119" CreationDate="2017-05-25T17:04:10.930" Score="0" Body="&lt;p&gt;I created bash script fixing syntax files. IT IS NOT PERFECT BUT IT IS GOOD. It can be reversed by running it again. It adds &lt;code&gt;contains=@Spell&lt;/code&gt; to &lt;code&gt;syn match&lt;/code&gt; and &lt;code&gt;syn region&lt;/code&gt; definitions in all files in given directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Save the script as fix_syntax_files.sh&lt;/li&gt;&#xA;&lt;li&gt;Give it permissions&lt;/li&gt;&#xA;&lt;li&gt;Change path at the bottom of the script to one corresponding to your vim plugins location&lt;/li&gt;&#xA;&lt;li&gt;Run the script&lt;/li&gt;&#xA;&lt;li&gt;(OPTIONAL) Run script again to revert the changes&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The script makes backup of all files before modification so you can assume it is safe to run it. I anyway do not take any responsibility for potential problems caused by the script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;You can leave feedback to the script in the following repository:&#xA;&lt;a href=&quot;https://github.com/dominikduda/config_files/blob/master/bin/fix_vim_syntax_files.sh&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/dominikduda/config_files/blob/master/bin/fix_vim_syntax_files.sh&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;&#xA;function fix_file {&#xA;  sed -i -e '/exe/! {s/contains=/contains=@Spell,/g}' $1&#xA;  sed -i -e 's/contains=@Spell,ALL/contains=ALL/g' $1&#xA;  sed -i -e 's/contains=@Spell,ALLBUT/contains=ALLBUT/g' $1&#xA;  sed -i -e 's/contains=@Spell,TOP/contains=TOP/g' $1&#xA;  sed -i -e 's/contains=@Spell,CONTAINED/contains=CONTAINED/g' $1&#xA;  sed -i -e 's/contains=@Spell,NONE/contains=@Spell/g' $1&#xA;  sed -i -e '/^ *syn match/ {/contains=/! s/$/ contains=@Spell/g}' $1&#xA;  sed -i -e '/^ *syn region/ {/contains=/! s/$/ contains=@Spell/g}' $1&#xA;  return 0&#xA;}&#xA;&#xA;function revert_file {&#xA;  mv &quot;$1/$2.spellfix-backup&quot; &quot;$1/$2&quot;&#xA;  return 0&#xA;}&#xA;&#xA;function fix_recursively_in_catalog {&#xA;  syntax_catalogs_paths=&quot;$(find $1 -type d ! -name '*.*' -not -path '*git*' -print)&quot;&#xA;  syntax_catalogs_count=&quot;$(echo &quot;${syntax_catalogs_paths}&quot; | wc -l)&quot;&#xA;&#xA;  echo &quot;${syntax_catalogs_count} syntax catalogs found and will be scanned for files&quot;&#xA;&#xA;  echo &quot;${syntax_catalogs_paths}&quot; | while read -r catalog_path ; do&#xA;      echo &quot;    Scanning $catalog_path&quot;&#xA;      ls -p &quot;${catalog_path}&quot; | grep -v / | grep -v .spellfix-backup | grep .vim | while read -r file_name ; do&#xA;          cp &quot;${catalog_path}/${file_name}&quot; &quot;${catalog_path}/${file_name}.spellfix-backup&quot;&#xA;          fix_file &quot;${catalog_path}/${file_name}&quot;&#xA;          echo &quot;        Fixing ${file_name} (backup created as ${file_name}.spellfix-backup)&quot;&#xA;      done&#xA;  done&#xA;  echo 'Fix done.'&#xA;  echo 'Remember to REVERT FIX before updating vim plugins'&#xA;  return 0&#xA;}&#xA;&#xA;function revert_recursively_in_catalog {&#xA;  syntax_catalogs_paths=&quot;$(find $1 -type d ! -name '*.*' -not -path '*git*' -print)&quot;&#xA;  syntax_catalogs_count=&quot;$(echo &quot;${syntax_catalogs_paths}&quot; | wc -l)&quot;&#xA;&#xA;  echo &quot;${syntax_catalogs_count} syntax catalogs found and will be scanned for spellfix-backup files&quot;&#xA;&#xA;  echo &quot;${syntax_catalogs_paths}&quot; | while read -r catalog_path ; do&#xA;      echo &quot;    Scanning $catalog_path&quot;&#xA;      ls -p &quot;${catalog_path}&quot; | grep -v / | grep -v .spellfix-backup | grep .vim | while read -r file_name ; do&#xA;          revert_file &quot;${catalog_path}&quot; &quot;${file_name}&quot;&#xA;          echo &quot;        Reverting ${file_name} (from file ${file_name}.spellfix-backup)&quot;&#xA;      done&#xA;  done&#xA;  echo 'Revert done.'&#xA;  echo 'Remember to FIX AGAIN after plugins update (or set it as a post update hook)'&#xA;  return 0&#xA;}&#xA;&#xA;function main {&#xA;  syntax_catalogs_paths=&quot;$(find $1 -type d ! -name '*.*' -not -path '*git*' -print)&quot;&#xA;  while read -r catalog_path ; do&#xA;      if ls -p &quot;${catalog_path}&quot; | grep -v / | grep .spellfix-backup; then&#xA;        echo &quot;.spellfix-backup files found, reverting fix!&quot;&#xA;        echo &quot;--------------------------------------------&quot;&#xA;        revert_recursively_in_catalog $1&#xA;        return 0&#xA;      fi&#xA;  done &amp;lt; &amp;lt;(echo &quot;${syntax_catalogs_paths}&quot;)&#xA;  echo &quot;.spellfix-backup files NOT found, fixing!&quot;&#xA;  echo &quot;-----------------------------------------&quot;&#xA;  fix_recursively_in_catalog $1&#xA;}&#xA;&#xA;main ~/PATH/TO/VIM/PLUGINS/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11307" LastEditorUserId="11307" LastEditDate="2017-05-26T06:55:22.027" LastActivityDate="2017-05-26T06:55:22.027" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12494" PostTypeId="2" ParentId="12492" CreationDate="2017-05-25T17:37:38.070" Score="1" Body="&lt;p&gt;&lt;strong&gt;From :help feedkeys&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Characters in {string} are queued for processing as if they come&#xA;  from a mapping or were typed by the user. They are added to the end&#xA;  of the typeahead buffer, thus if a mapping is still being executed&#xA;  these characters come after them. The function does not wait for&#xA;  processing of keys contained in {string}.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This means &lt;code&gt;feedkeys&lt;/code&gt; only queues up the keystrokes you passed to it. The keystrokes actually play back only after your function exits.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I suggest that instead of using a combination of simulated keystrokes and vimscript, just use one or the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This sets register &lt;code&gt;a&lt;/code&gt; to line 1, up to the first comma or end-or-line&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a = matchstr(getline(1),'[^,]*')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call feedkeys( '1Gv/\(,\|$\)' . &quot;\&amp;lt;CR&amp;gt;&quot; . 'h&quot;ay'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12113" LastEditorUserId="12113" LastEditDate="2017-05-26T15:00:44.907" LastActivityDate="2017-05-26T15:00:44.907" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12495" PostTypeId="1" CreationDate="2017-05-25T23:04:55.903" Score="4" ViewCount="263" Body="&lt;p&gt;If I use &lt;code&gt;gvim *.c&lt;/code&gt; in a directory with multiple C files, gvim opens the next one once I close the one I am looking at.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The warning message given is &lt;code&gt;E173: n more files to edit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I quit all subsequent files? Meaning I don't want gvim to open any more files.&lt;/p&gt;&#xA;" OwnerUserId="9796" LastEditorUserId="10604" LastEditorDisplayName="user5791" LastEditDate="2020-01-26T17:48:37.407" LastActivityDate="2020-02-13T23:18:13.317" Title="Quit subsequent files opened with gvim *.c?" Tags="|gvim|quit|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12496" PostTypeId="2" ParentId="12495" CreationDate="2017-05-25T23:30:33.960" Score="4" Body="&lt;p&gt;When I tried the same thing, I got this error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E173: 3 more files to edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I ran  &lt;code&gt;:help E173&lt;/code&gt; and read&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *E173*  &amp;gt;&#xA; {number} more files to edit&#xA;&#xA;You are trying to exit, while the last item in the argument list has not been&#xA;edited.  This protects you from accidentally exiting when you still have more&#xA;files to work on.  See |argument-list|.  If you do want to exit, just do it&#xA;again and it will work.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;:q!&lt;/code&gt; worked for me.  So did running &lt;code&gt;:q&lt;/code&gt; twice (like the help page indicated).&lt;/p&gt;&#xA;" OwnerUserId="6590" LastActivityDate="2017-05-25T23:30:33.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12498" PostTypeId="1" CreationDate="2017-05-26T07:45:10.063" Score="4" ViewCount="546" Body="&lt;p&gt;Suppose I want to create a macro that swaps two function parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I search for swap:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;swap(first, second);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And with the cursor pointing at the 's' in swap, I can search forward for the paren, move one to the right, delete everything up to the comma, move back to the (, use '%' to go to the ending ')', add another comma, paste the first parameter, then go back to the swap, and delete the comma that used to separate the first and second parameter.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/(&amp;lt;return&amp;gt;&#xA;ld/,&amp;lt;return&amp;gt;&#xA;h%i, &amp;lt;escape&amp;gt;&#xA;p?(,&amp;lt;return&amp;gt;&#xA;lx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(And I have made a quick-and-dirty macro for this.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works fine as long as the first parameter doesn't have parentheses in it.  For example, this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;swap(foo, func(2, 3));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;swap( func(2, 3), foo);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;swap(func(2, 3), foo);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;swap( 3, func(2), foo);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because the parens in the first argument confuse the macro; it doesn't realize it should ignore the first comma because it's inside parens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, my question is, is there a way to search for the next &quot;,&quot; that isn't inside of parens?  For example, one way would be to search for a regex [,(] that matches either a comma or opening paren; then if it found a paren, use % to skip forward to the matching closing paren, and then search forward again.  Of course, that would require being able to conditionally loop, which is not really available within a macro (right?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or possibly, is there a way to search for a &quot;,&quot; after a sequence containing equal numbers of right and left parens?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was just hoping that something like this exists, given that % exists.&lt;/p&gt;&#xA;" OwnerUserId="12524" LastActivityDate="2017-07-25T11:33:57.490" Title="find next comma, skipping anything in parens?" Tags="|regular-expression|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12499" PostTypeId="1" AcceptedAnswerId="12502" CreationDate="2017-05-26T09:07:26.930" Score="2" ViewCount="2026" Body="&lt;p&gt;I am trying to search backwards (using &lt;code&gt;?&lt;/code&gt;) for the beginning of a &quot;word&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't mean a word in the text object sense; I mean a series of lower-case letters optionally beginning with a capital letter.  The optional capital letter is stymying me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some examples showing where I want to jump to, assuming the cursor starts at the end of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;quick brown fox&#xA;^     ^     ^&#xA;&#xA;QuickBrownFox&#xA;^    ^    ^&#xA;&#xA;Quick Brown Fox&#xA;^     ^     ^&#xA;&#xA;quick_brown_fox&#xA;^     ^     ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The closest I've come up with is &lt;code&gt;?\(\U\u\)\|\L?e+&lt;/code&gt; – but that doesn't work with the capital letters.  I assume this is because \L matches before \U\u does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I solve this?&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2017-05-26T12:55:55.213" Title="Regexp for beginning of word?" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12500" PostTypeId="2" ParentId="12498" CreationDate="2017-05-26T09:38:04.343" Score="2" Body="&lt;p&gt;You'll need plugin assistance for this -- because correctly extracting parameter boundaries is not trivial and cannot be done (perfectly) only with regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I'm aware of two plugins. There is &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp/blob/master/tests/lh/omap-param.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;mine&lt;/a&gt; (shipped with lh-cpp), and I've no doubt link(s) to the other one(s) will be given to you as well.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-05-26T09:38:04.343" CommentCount="3" CommunityOwnedDate="2017-05-30T16:10:03.827" ContentLicense="CC BY-SA 3.0" />
  <row Id="12501" PostTypeId="2" ParentId="12499" CreationDate="2017-05-26T09:49:29.957" Score="0" Body="&lt;p&gt;Although ugly this does what you need. At least in your example.&#xA;I think it could be simplified, but wouldn't bother to do so.&#xA;&lt;code&gt;\(\&amp;lt;\|\([a-z0-9]\?\(\( \|_\)\zs\|\zs\u\)\)\)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;very magic&lt;/code&gt; &lt;code&gt;\v(&amp;lt;|([a-z0-9]?(( |_)\zs|\zs\u)))&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6634" LastEditDate="2017-05-26T10:13:57.190" LastActivityDate="2017-05-26T10:13:57.190" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12502" PostTypeId="2" ParentId="12499" CreationDate="2017-05-26T10:40:09.537" Score="3" Body="&lt;p&gt;This simple search works for all the examples you gave:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?\a\l\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It matches any alphabetic character (upper or lower case), followed by any non-zero number of lower case characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some examples of cases you didn't mention where I'm a little unclear what you want it to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match a lower case&#xA;MatchACapital&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want it to match the single letter word a/A in both of these, then use a &lt;code&gt;*&lt;/code&gt; instead of the &lt;code&gt;\+&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?\a\l*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-05-26T12:55:55.213" LastActivityDate="2017-05-26T12:55:55.213" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12504" PostTypeId="2" ParentId="12492" CreationDate="2017-05-26T16:00:42.003" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;call feedkeys('0v/\(,\|$\)' . &quot;\&amp;lt;CR&amp;gt;&quot; . 'h&quot;ay')&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There's no starting &lt;code&gt;:&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; runs &lt;code&gt;v&lt;/code&gt; in line 1 only.&lt;/li&gt;&#xA;&lt;li&gt;The pattern always matches, so the command given to &lt;code&gt;v&lt;/code&gt; will never&#xA;run, no matter which line you run it in.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v&lt;/code&gt; isn't given a command so it defaults to printing the line (or&#xA;it would if it ever ran) which seems somewhat pointless.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;h&lt;/code&gt; occurs with the cursor in column 1 and causes the rest of the&#xA;command sequence to fail.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;ay&lt;/code&gt; isn't a complete command, so nothing would be yanked even if you&#xA;got to this point.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, you probably see the same line in the messages twice because&#xA;it already happened to be in register &lt;code&gt;a&lt;/code&gt; anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;feedkeys()&lt;/code&gt; is rarely needed and you are usually better served with&#xA;&lt;code&gt;:normal&lt;/code&gt;. See @JimU's answer for some things to be aware of. Also you&#xA;can yank in this scenario with &lt;code&gt;y a&lt;/code&gt;; there's no need to even use&#xA;Normal mode..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't really want to make further suggestions for fixing this since it&#xA;isn't clear to me what you're trying to do.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2017-05-26T16:00:42.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12505" PostTypeId="1" AcceptedAnswerId="12507" CreationDate="2017-05-26T16:18:44.990" Score="2" ViewCount="360" Body="&lt;p&gt;I have two windows that I created with a &lt;code&gt;:vsplit&lt;/code&gt;. Window 1 displays a file with changes that have not been saved yet, Window 2 displays another file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to get rid of Window 1, so I type &lt;code&gt;:only&lt;/code&gt; in Window 2. However, vim complains that &lt;code&gt;E445: Other window contains changes&lt;/code&gt; and refuses to proceed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appreciate that it tells me this but I don't understand why it doesn't proceed. I'm not leaving, why should it care?&lt;/p&gt;&#xA;" OwnerUserId="6136" LastActivityDate="2017-05-26T16:47:54.373" Title="Why does :only care if &quot;Other window contains changes&quot;?" Tags="|vim-windows|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12506" PostTypeId="2" ParentId="12505" CreationDate="2017-05-26T16:20:39.483" Score="1" Body="&lt;p&gt;Vim generally has a policy of not getting rid of windows with changes unless you &lt;em&gt;force&lt;/em&gt; it with &lt;code&gt;!&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:only!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-05-26T16:20:39.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12507" PostTypeId="2" ParentId="12505" CreationDate="2017-05-26T16:41:46.347" Score="3" Body="&lt;p&gt;Vim doesn't close the windows because you don't have either of the &lt;code&gt;'hidden'&lt;/code&gt; or &lt;code&gt;'autowrite'&lt;/code&gt; options set (which indicates to Vim that you don't &lt;em&gt;want&lt;/em&gt; windows with unsaved changes to be easily closable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help :only&lt;/code&gt; (or &lt;code&gt;:help E445&lt;/code&gt;) gives more details:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the 'hidden' option is set, all buffers in closed windows become hidden.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When 'hidden' is not set, and the 'autowrite' option is set, modified buffers are written. Otherwise, windows that have buffers that are modified are not removed, unless the [!] is given, then they become hidden. But modified buffers are never abandoned, so changes cannot get lost.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also &lt;code&gt;:help hidden-buffers&lt;/code&gt; for more details of how Vim handles this.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-05-26T16:47:54.373" LastActivityDate="2017-05-26T16:47:54.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12508" PostTypeId="1" AcceptedAnswerId="12522" CreationDate="2017-05-26T17:34:07.333" Score="4" ViewCount="390" Body="&lt;p&gt;Is it possible to select the text of a command from a buffer in visual mode and then feed it to ex?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like so I can modify the text of the command in the buffer and then after I press some keys have it run as the ex command?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2017-05-29T11:30:28.770" Title="How to feed visual selection into ex?" Tags="|buffers|ex-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12509" PostTypeId="2" ParentId="12487" CreationDate="2017-05-27T08:35:06.890" Score="1" Body="&lt;p&gt;After you turn off search highlighting, use &lt;code&gt;gv&lt;/code&gt; to reselect the previous visual selection.&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2017-05-27T08:35:06.890" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12510" PostTypeId="1" AcceptedAnswerId="12511" CreationDate="2017-05-27T14:42:05.687" Score="0" ViewCount="436" Body="&lt;p&gt;I would like to remap = only when i've opened a by astyle supported filetype in vim else I don't want any remapping on = because other plugins probably want to do it automatically (by accessing vim = - i hope they work like that - will see soon)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;at the moment it simply looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set equalprg=astyle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6816" LastActivityDate="2017-05-27T16:36:58.407" Title="Vim with astyle remap =" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12511" PostTypeId="2" ParentId="12510" CreationDate="2017-05-27T16:36:58.407" Score="1" Body="&lt;p&gt;Putting something like this in you r &lt;code&gt;~/.vimrc&lt;/code&gt; should work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType c,cpp,java setlocal equalprg=astyle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will set &lt;code&gt;'equalprg'&lt;/code&gt; to &lt;code&gt;astyle&lt;/code&gt; for any buffer containing a C, C++ or Java file and the setting will be local to that buffer.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-05-27T16:36:58.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12512" PostTypeId="2" ParentId="12490" CreationDate="2017-05-27T17:32:17.587" Score="1" Body="&lt;p&gt;When I write my Latex Documents I use always this small Makefile i've written. You can execute it the same way Patrick proposed it. (:!make c or :!make C or :!make pdf or :!make clean)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EXTENSIONS:=aux bbl blg cut dvi log out pdfsync ps synctex.gz tdo toc tex~ backup xmpi fls fdb_latexmk lof lot&#xA;&#xA;MAIN:=main.tex&#xA;&#xA;PDF_NAME:=pdf_name&#xA;&#xA;default: pdf&#xA;&#xA;pdf:&#xA;    latexmk -pdf -jobname=&quot;$(PDF_NAME)&quot; -shell-escape $(MAIN)&#xA;&#xA;clean:&#xA;    latexmk -c $(MAIN)&#xA;    @for i in $(EXTENSIONS); \&#xA;    do \&#xA;        for file in `find . -name &quot;*.$$i&quot;`; do rm $$file; done; \&#xA;    done; \&#xA;    rm -rf _minted*&#xA;&#xA;C:&#xA;    make clean; \&#xA;    rm *.pdf&#xA;&#xA;c:&#xA;    make C; \&#xA;    make; \&#xA;    make clean;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6816" LastActivityDate="2017-05-27T17:32:17.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12513" PostTypeId="1" AcceptedAnswerId="12514" CreationDate="2017-05-27T19:18:41.837" Score="19" ViewCount="5718" Body="&lt;p&gt;Sometimes I create macros. Sometimes I create the same macro multiple times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes I get tired of creating the same macro over again. Can I store macros? Can I load a preset of macros? Can I make a macro and save it forever?&lt;/p&gt;&#xA;" OwnerUserId="2965" LastEditorUserId="1238" LastEditDate="2019-12-17T08:16:47.217" LastActivityDate="2020-04-18T05:39:50.473" Title="Save a macro just created in vimrc" Tags="|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12514" PostTypeId="2" ParentId="12513" CreationDate="2017-05-27T21:36:34.627" Score="19" Body="&lt;p&gt;Yes, you can! There are a couple ways to do this. By default, all registers will be saved into your &lt;em&gt;viminfo&lt;/em&gt; file, and loaded once you start vim. This is the easiest way. However, it's not foolproof. Each register will be lost if you accidentally record/yank over it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The better way to save a specific macro is to put it in your &lt;code&gt;.vimrc&lt;/code&gt;. For example, let's say you want &lt;code&gt;foo&lt;/code&gt; to be saved into macro &lt;code&gt;a&lt;/code&gt;. This could be achieved with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a='foo'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your vimrc. If you have your macros already made, you could type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ilet @a='&amp;lt;C-r&amp;gt;&amp;lt;C-r&amp;gt;a'&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to paste the current contents of the macro, if you don't feel like typing it all out again.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Thanks to Andrew Keeton for pointing out &lt;code&gt;&amp;lt;C-r&amp;gt;&amp;lt;C-r&amp;gt;&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2019-04-12T16:38:27.157" LastActivityDate="2019-04-12T16:38:27.157" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="12516" PostTypeId="2" ParentId="11252" CreationDate="2017-05-28T12:33:37.427" Score="3" Body="&lt;p&gt;Based on tracyone's vim configuration I have created a fork of &lt;a href=&quot;https://github.com/IngoHeimbach/neco-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;necovim&lt;/a&gt; that automatically registers as vim omnifunc. Just add the plugin with your favorite vim plugin manager and it will work out of the box with YouCompleteMe.&lt;/p&gt;&#xA;" OwnerUserId="12800" LastActivityDate="2017-05-28T12:33:37.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12517" PostTypeId="1" CreationDate="2017-05-28T20:27:00.953" Score="1" ViewCount="296" Body="&lt;p&gt;If I call &lt;code&gt;gvim main.py -c &quot;call cursor(41, 45)&quot; -c &quot;call pymode#rope#goto_definition()&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I get this error about parenthesis:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;main.py&quot; [unix] 54L, 1677C&#xA;Error detected while processing command line:&#xA;E107: Missing parentheses:pymodeC:\Users\me\key_state_manager.pyropeC:\Users\me\key_state_manager.pygoto_definition()&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to make a function for opening a definition in another gvim window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/python-mode/python-mode&quot; rel=&quot;nofollow noreferrer&quot;&gt;pymode link&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12803" LastEditorUserId="12803" LastEditDate="2017-05-29T19:30:39.493" LastActivityDate="2017-09-26T21:11:44.560" Title="Error when trying to call pymode#rope#goto_definition() with vim's -c arg" Tags="|vimscript|gvim|vimscript-python|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12518" PostTypeId="1" CreationDate="2017-05-28T21:26:25.510" Score="0" ViewCount="1502" Body="&lt;p&gt;I want the cursor line in the quickfix window to be more distinguishable, than in other windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially I thought that there has to be some different highlight group, it seemly turned out to be false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I had an idea to set the cursorline highlight on a per syntax basis, I added the &lt;code&gt;qf.vim&lt;/code&gt; file to the &lt;code&gt;after/syntax&lt;/code&gt; directory with a corresponding setting. But when I opened the quickfix window the cursor line changed its background not only in the quickfix but in all other windows too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I tried to use the &lt;code&gt;Search&lt;/code&gt; highlight group (the docs &lt;code&gt;:help hl-Search&lt;/code&gt; say that this group is used for highlighting the search matches and &lt;strong&gt;the current line in the quickfix window&lt;/strong&gt;). But it didn't work, the current line (cursor line) has remained the same, though the Search was enabled correctly (I checked it with the &lt;code&gt;:hi&lt;/code&gt; command and when I tried to search for a pattern it highlighted all matches in the current window as well as the quickfix one, but not the whole current line in the quickfix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this, without changing the source and compiling Vim myself?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="2798" LastEditorUserId="2798" LastEditDate="2017-05-28T22:37:29.990" LastActivityDate="2017-06-28T07:06:20.457" Title="How to change the cursor line higlighting only for one window (namely the quickfix one)?" Tags="|highlight|quickfix|cursorline|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12519" PostTypeId="2" ParentId="12518" CreationDate="2017-05-28T22:49:11.487" Score="1" Body="&lt;p&gt;currently I solved it this way (though I would be very grateful if someone suggested a better way).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created a syntax highlihgt file for the &lt;code&gt;qf&lt;/code&gt; syntax &lt;code&gt;~/.vim/after/syntax/qf.vim&lt;/code&gt;. There I defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal nocursorline&#xA;hi Search cterm=none ctermbg=226 guibg=#ffff00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This disabled the cursor line highlighting in the quickfix window (which is tolerable for me), and set the search match highlighting only in that window, which is perfect for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now pressing &lt;code&gt;:cn&lt;/code&gt; etc. from the main window I am able to see quickly, what an error message I'm currently on.&lt;/p&gt;&#xA;" OwnerUserId="2798" LastActivityDate="2017-05-28T22:49:11.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12520" PostTypeId="1" AcceptedAnswerId="12534" CreationDate="2017-05-29T08:41:35.800" Score="15" ViewCount="6643" Body="&lt;p&gt;I'm experiecing the most annoying thing ever: when I edit a markdown file, asterisk characters are hidden by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I set on an open buffer &lt;code&gt;:set conceallevel=0&lt;/code&gt;, asterisks shows up as they should, but if I put this conf in my &lt;code&gt;init.vim&lt;/code&gt; file, it does not work anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to solve that?&#xA;And more important, &lt;strong&gt;is there a way to know which plugin override my configuration&lt;/strong&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="1765" LastEditorUserId="1765" LastEditDate="2017-05-29T09:37:22.190" LastActivityDate="2021-10-28T12:33:14.890" Title="Markdown in Neovim: which plugin sets conceallevel=2?" Tags="|neovim|filetype-markdown|conceal|" AnswerCount="5" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="12521" PostTypeId="2" ParentId="12520" CreationDate="2017-05-29T10:46:27.937" Score="11" Body="&lt;p&gt;Ok, I found the plugin involved into this: is &lt;a href=&quot;https://github.com/Yggdroot/indentLine&quot; rel=&quot;noreferrer&quot;&gt;indentLine&lt;/a&gt;.&#xA;It is reported in its README: it does not work if &lt;code&gt;conceallevel&lt;/code&gt; is not set to 1 or 2, so it set this parameter to 2 by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The side effect is that markdown files are terribly displayed, and you cannot edit them confortably...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found it out debugging my &lt;code&gt;init.vim&lt;/code&gt; thanks to &lt;em&gt;lsrdg&lt;/em&gt; &lt;a href=&quot;https://github.com/mhinz/vim-galore#debugging-1&quot; rel=&quot;noreferrer&quot;&gt;link suggestion&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I solved my problem avoiding IndentLine to start for Markdown files, putting the following in my &lt;em&gt;init.vim&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown let g:indentLine_enabled=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1765" LastEditorUserId="1765" LastEditDate="2017-05-31T07:12:18.237" LastActivityDate="2017-05-31T07:12:18.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12522" PostTypeId="2" ParentId="12508" CreationDate="2017-05-29T11:11:44.167" Score="5" Body="&lt;p&gt;First select some text visually. Then yank it (&lt;code&gt;y&lt;/code&gt;). Then enter ex-mode (&lt;code&gt;:&lt;/code&gt;). Finally insert the yanked text (&lt;code&gt;&amp;lt;CTRL-R&amp;gt;0&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="12807" LastEditorUserId="51" LastEditDate="2017-05-29T11:30:28.770" LastActivityDate="2017-05-29T11:30:28.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12523" PostTypeId="1" AcceptedAnswerId="12529" CreationDate="2017-05-29T14:10:54.750" Score="1" ViewCount="117" Body="&lt;p&gt;How can I make a viml function that scans highlighted text for all occurrences of &lt;code&gt;[ &amp;lt;number&amp;gt; u ]&lt;/code&gt; and &lt;code&gt;[ &amp;lt;number&amp;gt;u ]&lt;/code&gt; and sums them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EXAMPLE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Here is some text. [0.1u]&#xA;Here is some more text [0.2 u]&#xA;And here is some noise: 0.2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should yield &lt;code&gt;0.3&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6499" LastActivityDate="2017-06-18T08:14:56.643" Title="Finding Numbers in Brackets Followed by a Letter and Summing Them" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12524" PostTypeId="2" ParentId="12490" CreationDate="2017-05-29T15:07:03.250" Score="1" Body="&lt;p&gt;On Ubuntu at least, &lt;code&gt;evince foo.pdf &amp;amp;&lt;/code&gt;, started from the terminal, refreshes its display when it notices that foo.pdf has changed, without stealing focus.  From within &lt;code&gt;vi&lt;/code&gt;, &lt;code&gt;:!make&lt;/code&gt; then does what you want.  I don't have a Mac to play with, but some Mac pdf viewer may behave like this too.&lt;/p&gt;&#xA;" OwnerUserId="12809" LastActivityDate="2017-05-29T15:07:03.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12525" PostTypeId="1" AcceptedAnswerId="12526" CreationDate="2017-05-29T17:11:24.530" Score="0" ViewCount="171" Body="&lt;p&gt;&lt;code&gt;zz&lt;/code&gt; moves current line &amp;amp; cursor at the middle of the screen.&lt;br&gt;&#xA;&lt;code&gt;zt&lt;/code&gt; moves current line &amp;amp; cursor at the top of the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do the same as &lt;code&gt;zz&lt;/code&gt; and &lt;code&gt;zt&lt;/code&gt;, but for a quarter (25%) from the screen top?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is what I came up with so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; zT &quot;zt&quot; . (&amp;amp;scroll / 2) . &quot;\&amp;lt;c-y&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it does not do exactly what I want, because if there are wrapped lines that take for example 10 visual lines, one stroke of &lt;code&gt;&amp;lt;c-y&amp;gt;&lt;/code&gt; will go over those 10 visual lines in one go.&lt;/p&gt;&#xA;" OwnerUserId="7318" LastActivityDate="2017-05-29T23:36:28.703" Title="How to bring current line &amp; cursor at 25% from top of screen?" Tags="|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12526" PostTypeId="2" ParentId="12525" CreationDate="2017-05-29T19:07:26.570" Score="1" Body="&lt;p&gt;I'm not sure if &lt;code&gt;zz&lt;/code&gt; and &lt;code&gt;zt&lt;/code&gt; have an special treatment that avoid the visual lines you mentioned in your solution. But if they do have you could try resizing the window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; zT 'zzz'.(&amp;amp;scroll).'&amp;lt;CR&amp;gt;Hz'.(&amp;amp;scroll*2).'&amp;lt;CR&amp;gt;&amp;lt;C-O&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that this expects that &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27scrolloff%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'scrolloff'&lt;/code&gt;&lt;/a&gt; is set to 0. If you use a different value you could write a function to save the original value and restore it at the end.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2017-05-29T19:07:26.570" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12527" PostTypeId="2" ParentId="12517" CreationDate="2017-05-29T19:34:01.640" Score="1" Body="&lt;p&gt;The problem was that I wasn't escaping &lt;code&gt;#&lt;/code&gt; symbols. Here's my final function which opens a new gvim window for a function under the cursor. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NewGvimGotoDefin()&#xA;    let loc = ' -c &quot;call cursor(' . line(&quot;.&quot;) . ', ' . getpos(&quot;.&quot;)[2] . ')&quot; '&#xA;    let goto_def = ' -c &quot;call pymode\#rope\#goto_definition()&quot; '&#xA;    execute '!start /b gvim % ' . loc . goto_def&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And more generically: &lt;code&gt;gvim main.py -c &quot;call cursor(41, 45)&quot; -c &quot;call pymode\#rope\#goto_definition()&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="12803" LastEditorUserId="12803" LastEditDate="2017-05-29T19:45:20.997" LastActivityDate="2017-05-29T19:45:20.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12528" PostTypeId="1" AcceptedAnswerId="14504" CreationDate="2017-05-29T20:31:27.433" Score="3" ViewCount="1952" Body="&lt;p&gt;When using Gvim on Linux I can use &lt;code&gt;:!ls&lt;/code&gt; to list files and directories 'in-line' in Gvim to navigate around the file structure and open files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, on Windows when using &lt;code&gt;:!dir&lt;/code&gt;, a cmd window opens listing the files there. This is fine, but not as convenient as the in-line &lt;code&gt;:!ls&lt;/code&gt; version. Is there a way to emulate this behavior with the Windows version of gvim?&lt;/p&gt;&#xA;" OwnerUserId="12804" LastEditorUserId="51" LastEditDate="2017-05-29T22:25:53.763" LastActivityDate="2018-03-11T19:17:41.723" Title="How can I run :! commands inline instead of in a new cmd.exe window?" Tags="|gvim|external-command|microsoft-windows|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12529" PostTypeId="2" ParentId="12523" CreationDate="2017-05-29T21:16:19.227" Score="2" Body="&lt;p&gt;The following solution works for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt; YankAndAnalyse()&#xA;nmap     &amp;lt;silent&amp;gt;       &amp;lt;c-x&amp;gt; vip&amp;lt;c-x&amp;gt;&amp;lt;esc&amp;gt;&#xA;&#xA;function! YankAndAnalyse()&#xA;  return 'y'&#xA;        \ . &quot;:call Analyse()\&amp;lt;CR&amp;gt;&quot;&#xA;        \ . &quot;:silent normal! gv\&amp;lt;CR&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;function! Analyse()&#xA;  let selection = split(getreg(''), '\n')&#xA;  let numbers = map(selection,&#xA;        \ 'matchstr(v:val, ''\[\s*\zs\d\+\%(\.\d\+\)\?\ze\s*u\s*]'')')&#xA;  call filter(numbers, '!empty(v:val)')&#xA;  call map(numbers, 'str2float(v:val)')&#xA;  if empty(numbers) | return | endif&#xA;&#xA;  echohl Identifier&#xA;  echon 'Sum: ' . printf('%g', eval(join(numbers, ' + ')))&#xA;  echohl None&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;YankAndAnalyse&lt;/code&gt; is a simple wrapper function that first fills the default register. &lt;code&gt;Analyse&lt;/code&gt; reads the default register and parses the numbers that match your critera. The &lt;code&gt;YankAndAnalyse&lt;/code&gt; function is mapped to &lt;code&gt;CTRL-x&lt;/code&gt; in visual mode (feel free to choose whatever you want), and the normal mode map simply applies the visual mode map to the current paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the documentation for more help, e.g. &lt;code&gt;:h matchstr()&lt;/code&gt; for help on the &lt;code&gt;matchstr&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: The above solution only sums the first matched number in each line. In order to sum all matched numbers, one may use the following version of the &lt;code&gt;Analyse&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Analyse()&#xA;  let input = getreg('')&#xA;  let sum = 0&#xA;  let n = 1&#xA;  let new = matchstr(input, '\[\s*\zs\d\+\%(\.\d\+\)\?\ze\s*u\s*]', 0, n)&#xA;  while !empty(new)&#xA;    let n += 1&#xA;    let sum += str2float(new)&#xA;    let new = matchstr(input, '\[\s*\zs\d\+\%(\.\d\+\)\?\ze\s*u\s*]', 0, n)&#xA;  endwhile&#xA;&#xA;  echohl Identifier&#xA;  echon 'Sum: ' . printf('%g', sum)&#xA;  echohl None&#xA;  return&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2017-06-16T22:25:53.633" LastActivityDate="2017-06-16T22:25:53.633" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12530" PostTypeId="1" AcceptedAnswerId="12532" CreationDate="2017-05-29T21:43:39.583" Score="3" ViewCount="1472" Body="&lt;p&gt;There are &lt;a href=&quot;https://en.wikipedia.org/wiki/ANSI_escape_code&quot; rel=&quot;nofollow noreferrer&quot;&gt;ANSI escape codes&lt;/a&gt; (namely 5 and 6) that make subsequent text blink and my terminal (rxvt-unicode-256color) does support this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to allow this to happen using &lt;code&gt;hi&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT:&lt;/em&gt; From the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#term-list&quot; rel=&quot;nofollow noreferrer&quot;&gt;manual&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;start={term-list} &lt;em&gt;highlight-start&lt;/em&gt; &lt;em&gt;E422&lt;/em&gt;&lt;br&gt;&#xA;  stop={term-list}  &lt;em&gt;term-list&lt;/em&gt; &lt;em&gt;highlight-stop&lt;/em&gt;    &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;These lists of terminal codes can be used to get non-standard attributes on a terminal.&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The escape sequence specified with the &quot;start&quot; argument     is written&#xA;  before the characters in the highlighted  area.  &lt;strong&gt;It can be anything&#xA;  that you want to send to the  terminal to highlight this area&lt;/strong&gt;.  The&#xA;  escape sequence   specified with the &quot;stop&quot; argument is written after&#xA;  the   highlighted area.  This should undo the &quot;start&quot; argument.&#xA;    Otherwise the screen will look messed up.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I supposed this could be what I was looking for therefore I tried the following: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi foo start=t_mb stop=&amp;lt;ESC&amp;gt;[0m`&amp;lt;br&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nothing happened however (and I did make sure &lt;code&gt;foo&lt;/code&gt; matches the &lt;code&gt;sy[ntax]&lt;/code&gt; rule)&lt;br&gt;&#xA;I tried making the text bold in similar fashion (by using &lt;code&gt;t_md&lt;/code&gt; instead of &lt;code&gt;t_mb&lt;/code&gt;) but it did not work (bold does work with &lt;code&gt;cterm=bold&lt;/code&gt; though). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I either misunderstood what &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;stop&lt;/code&gt; actually do or the line above simply shows incorrect usage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I make this work?&lt;/p&gt;&#xA;" OwnerUserId="12812" LastEditorUserId="12812" LastEditDate="2017-05-29T22:59:49.837" LastActivityDate="2017-05-31T09:22:38.400" Title="Is it possible to make text blink inside vim?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12532" PostTypeId="2" ParentId="12530" CreationDate="2017-05-30T09:06:36.607" Score="5" Body="&lt;p&gt;It's &lt;em&gt;possible&lt;/em&gt; to do this using the &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;stop&lt;/code&gt; arguments to the &lt;code&gt;:highlight&lt;/code&gt; command as you suggest, but you're probably not going to like the trade-off required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems those arguments only work if Vim believes it is running in a black and white terminal (i.e. if &lt;code&gt;t_Co&lt;/code&gt; is set to &lt;code&gt;1&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the following info &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_use/fc5h7N35H4o&quot; rel=&quot;nofollow noreferrer&quot;&gt;in a newsgroup posting&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Based on the &lt;a href=&quot;https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2FZyX-I%2Fvim%2Fblob%2F6b82591127b58b9ef03790cb51e867b4fd575622%2Fsrc%2Fscreen.c%23L7862&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNH331h_JPnBiY0qifuYP7wqBNL--g&quot; rel=&quot;nofollow noreferrer&quot;&gt;code&lt;/a&gt; I think it never supposed to work if t_Co is&#xA;  greater then 1. But for some reason I do not see this working when&#xA;  t_Co is 1 and setting start/stop for Normal highlight group. Other&#xA;  groups (tested on NonText only) seem to be fine. Though &lt;code&gt;hi Normal&#xA;  term=bold&lt;/code&gt; neither works with t_Co set to 1.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;So this feature is intended for black and white terminals and works&#xA;  there. And it is documented: open &lt;code&gt;:h highlight-start&lt;/code&gt; and scroll up&#xA;  to “1. highlight arguments for normal terminals”. Higher there is some&#xA;  explanation what is normal and color terminal, though I would say&#xA;  rather strange explanation (while vt100 may be black-and-white (at&#xA;  least its entry does not state it supports any colors) xterm termcap&#xA;  entry states it supports 8 colors (256 colors is supported by&#xA;  xterm-256colors)).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Indeed, I tried using the following command to use the ANSI blink escape sequence:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight Blinking start=&amp;lt;esc&amp;gt;[5m stop=&amp;lt;esc&amp;gt;[0m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It had no effect. However running the following resulted in blinking text, as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set t_Co=1&#xA;:highlight Blinking start=&amp;lt;esc&amp;gt;[5m stop=&amp;lt;esc&amp;gt;[0m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that if you are dead set on having blinking &lt;em&gt;and&lt;/em&gt; coloured text at the same time in Vim, you could also use the same highlight arguments to provide colouring even with &lt;code&gt;t_Co&lt;/code&gt; set to &lt;code&gt;1&lt;/code&gt;. e.g. the following results in blinking red text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight Blinking start=&amp;lt;esc&amp;gt;[31;5m stop=&amp;lt;esc&amp;gt;[0m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-05-31T09:22:38.400" LastActivityDate="2017-05-31T09:22:38.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12533" PostTypeId="1" CreationDate="2017-05-30T20:27:09.097" Score="0" ViewCount="361" Body="&lt;p&gt;this is my first steps in vim and I've started this from a config generated by vim-bootstrap service for neovim and c++ specific development. &#xA;so I'm currently studying enabled plugins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;could someone explain me why there is a different colouring depends I'm opening c++ source from nerdtree panel or via usual :e&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;opening from :e - set filetype is cpp; fileformat is unix&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;opening from nerdtree - filetype is cpp; fileformat is unix  &lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;so not difference in those values&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/h61kt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h61kt.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PhN2N.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PhN2N.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is a content of a config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim-bootstrap 3340bde&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Vim-PLug core&#xA;&quot;*****************************************************************************&#xA;if has('vim_starting')&#xA;  set nocompatible               &quot; Be iMproved&#xA;endif&#xA;&#xA;let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')&#xA;&#xA;if !filereadable(vimplug_exists)&#xA;  if !executable(&quot;curl&quot;)&#xA;    echoerr &quot;You have to install curl or first install vim-plug yourself!&quot;&#xA;    execute &quot;q!&quot;&#xA;  endif&#xA;  echo &quot;Installing Vim-Plug...&quot;&#xA;  echo &quot;&quot;&#xA;  silent !\curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;  let g:not_finish_vimplug = &quot;yes&quot;&#xA;&#xA;  autocmd VimEnter * PlugInstall&#xA;endif&#xA;&#xA;&quot; Required:&#xA;call plug#begin(expand('~/.config/nvim/plugged'))&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Plug install packages&#xA;&quot;*****************************************************************************&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'jistr/vim-nerdtree-tabs'&#xA;Plug 'tpope/vim-commentary'&#xA;Plug 'tpope/vim-fugitive'&#xA;Plug 'vim-airline/vim-airline'&#xA;Plug 'vim-airline/vim-airline-themes'&#xA;Plug 'airblade/vim-gitgutter'&#xA;Plug 'vim-scripts/grep.vim'&#xA;Plug 'vim-scripts/CSApprox'&#xA;Plug 'bronson/vim-trailing-whitespace'&#xA;Plug 'Raimondi/delimitMate'&#xA;Plug 'majutsushi/tagbar'&#xA;Plug 'scrooloose/syntastic'&#xA;Plug 'Yggdroot/indentLine'&#xA;Plug 'sheerun/vim-polyglot'&#xA;if isdirectory('/usr/local/opt/fzf')&#xA;  Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'&#xA;else&#xA;  Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }&#xA;  Plug 'junegunn/fzf.vim'&#xA;endif&#xA;let g:make = 'gmake'&#xA;if exists('make')&#xA;        let g:make = 'make'&#xA;endif&#xA;Plug 'Shougo/vimproc.vim', {'do': g:make}&#xA;&#xA;&quot;&quot; Vim-Session&#xA;Plug 'xolox/vim-misc'&#xA;Plug 'xolox/vim-session'&#xA;&#xA;if v:version &amp;gt;= 703&#xA;  Plug 'Shougo/vimshell.vim'&#xA;endif&#xA;&#xA;if v:version &amp;gt;= 704&#xA;  &quot;&quot; Snippets&#xA;  Plug 'SirVer/ultisnips'&#xA;endif&#xA;&#xA;Plug 'honza/vim-snippets'&#xA;&#xA;&quot;&quot; Color&#xA;Plug 'tomasr/molokai'&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Custom bundles&#xA;&quot;*****************************************************************************&#xA;&#xA;&quot; c&#xA;Plug 'vim-scripts/c.vim', {'for': ['c', 'cpp']}&#xA;Plug 'ludwig/split-manpage.vim'&#xA;&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;*****************************************************************************&#xA;&#xA;&quot;&quot; Include user's extra bundle&#xA;if filereadable(expand(&quot;~/.config/nvim/local_bundles.vim&quot;))&#xA;  source ~/.config/nvim/local_bundles.vim&#xA;endif&#xA;&#xA;call plug#end()&#xA;&#xA;&quot; Required:&#xA;filetype plugin indent on&#xA;&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Basic Setup&#xA;&quot;*****************************************************************************&quot;&#xA;&quot;&quot; Encoding&#xA;set encoding=utf-8&#xA;set fileencoding=utf-8&#xA;set fileencodings=utf-8&#xA;set bomb&#xA;set binary&#xA;&#xA;&#xA;&quot;&quot; Fix backspace indent&#xA;set backspace=indent,eol,start&#xA;&#xA;&quot;&quot; Tabs. May be overriten by autocmd rules&#xA;set tabstop=4&#xA;set softtabstop=0&#xA;set shiftwidth=4&#xA;set expandtab&#xA;&#xA;&quot;&quot; Map leader to ,&#xA;let mapleader=','&#xA;&#xA;&quot;&quot; Enable hidden buffers&#xA;set hidden&#xA;&#xA;&quot;&quot; Searching&#xA;set hlsearch&#xA;set incsearch&#xA;set ignorecase&#xA;set smartcase&#xA;&#xA;&quot;&quot; Directories for swp files&#xA;set nobackup&#xA;set noswapfile&#xA;&#xA;set fileformats=unix,dos,mac&#xA;set showcmd&#xA;&#xA;if exists('$SHELL')&#xA;    set shell=$SHELL&#xA;else&#xA;    set shell=/bin/sh&#xA;endif&#xA;&#xA;&quot; session management&#xA;let g:session_directory = &quot;~/.config/nvim/session&quot;&#xA;let g:session_autoload = &quot;no&quot;&#xA;let g:session_autosave = &quot;no&quot;&#xA;let g:session_command_aliases = 1&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Visual Settings&#xA;&quot;*****************************************************************************&#xA;syntax on&#xA;set ruler&#xA;set number&#xA;&#xA;let no_buffers_menu=1&#xA;if !exists('g:not_finish_vimplug')&#xA;  colorscheme molokai&#xA;endif&#xA;&#xA;set mousemodel=popup&#xA;set t_Co=256&#xA;set guioptions=egmrti&#xA;set gfn=Monospace\ 10&#xA;&#xA;if has(&quot;gui_running&quot;)&#xA;  if has(&quot;gui_mac&quot;) || has(&quot;gui_macvim&quot;)&#xA;    set guifont=Menlo:h12&#xA;    set transparency=7&#xA;  endif&#xA;else&#xA;  let g:CSApprox_loaded = 1&#xA;&#xA;  &quot; IndentLine&#xA;  let g:indentLine_enabled = 1&#xA;  let g:indentLine_concealcursor = 0&#xA;  let g:indentLine_char = '┆'&#xA;  let g:indentLine_faster = 1&#xA;&#xA;&#xA;endif&#xA;&#xA;&#xA;&#xA;&quot;&quot; Disable the blinking cursor.&#xA;set gcr=a:blinkon0&#xA;set scrolloff=3&#xA;&#xA;&quot;&quot; Status bar&#xA;set laststatus=2&#xA;&#xA;&quot;&quot; Use modeline overrides&#xA;set modeline&#xA;set modelines=10&#xA;&#xA;set title&#xA;set titleold=&quot;Terminal&quot;&#xA;set titlestring=%F&#xA;&#xA;set statusline=%F%m%r%h%w%=(%{&amp;amp;ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\&#xA;&#xA;&quot; Search mappings: These will make it so that going to the next one in a&#xA;&quot; search will center on the line it's found in.&#xA;nnoremap n nzzzv&#xA;nnoremap N Nzzzv&#xA;&#xA;if exists(&quot;*fugitive#statusline&quot;)&#xA;  set statusline+=%{fugitive#statusline()}&#xA;endif&#xA;&#xA;&quot; vim-airline&#xA;let g:airline_theme = 'powerlineish'&#xA;let g:airline#extensions#syntastic#enabled = 1&#xA;let g:airline#extensions#branch#enabled = 1&#xA;let g:airline#extensions#tabline#enabled = 1&#xA;let g:airline#extensions#tagbar#enabled = 1&#xA;let g:airline_skip_empty_sections = 1&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Abbreviations&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; no one is really happy until you have this shortcuts&#xA;cnoreabbrev W! w!&#xA;cnoreabbrev Q! q!&#xA;cnoreabbrev Qall! qall!&#xA;cnoreabbrev Wq wq&#xA;cnoreabbrev Wa wa&#xA;cnoreabbrev wQ wq&#xA;cnoreabbrev WQ wq&#xA;cnoreabbrev W w&#xA;cnoreabbrev Q q&#xA;cnoreabbrev Qall qall&#xA;&#xA;&quot;&quot; NERDTree configuration&#xA;let g:NERDTreeChDirMode=2&#xA;let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']&#xA;let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']&#xA;let g:NERDTreeShowBookmarks=1&#xA;let g:nerdtree_tabs_focus_on_files=1&#xA;let g:NERDTreeMapOpenInTabSilent = '&amp;lt;RightMouse&amp;gt;'&#xA;let g:NERDTreeWinPos = &quot;right&quot;&#xA;let g:NERDTreeWinSize = 30&#xA;set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;F2&amp;gt; :NERDTreeFind&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;F3&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; grep.vim&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;f :Rgrep&amp;lt;CR&amp;gt;&#xA;let Grep_Default_Options = '-IR'&#xA;let Grep_Skip_Files = '*.log *.db'&#xA;let Grep_Skip_Dirs = '.git node_modules'&#xA;&#xA;&quot; vimshell.vim&#xA;let g:vimshell_user_prompt = 'fnamemodify(getcwd(), &quot;:~&quot;)'&#xA;let g:vimshell_prompt =  '$ '&#xA;&#xA;&quot; terminal emulation&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;sh :terminal&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Functions&#xA;&quot;*****************************************************************************&#xA;if !exists('*s:setupWrapping')&#xA;  function s:setupWrapping()&#xA;    set wrap&#xA;    set wm=2&#xA;    set textwidth=79&#xA;  endfunction&#xA;endif&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Autocmd Rules&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; The PC is fast enough, do syntax highlight syncing from start unless 200 lines&#xA;augroup vimrc-sync-fromstart&#xA;  autocmd!&#xA;  autocmd BufEnter * :syntax sync maxlines=200&#xA;augroup END&#xA;&#xA;&quot;&quot; Remember cursor position&#xA;augroup vimrc-remember-cursor-position&#xA;  autocmd!&#xA;  autocmd BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) | exe &quot;normal! g`\&quot;&quot; | endif&#xA;augroup END&#xA;&#xA;&quot;&quot; txt&#xA;augroup vimrc-wrapping&#xA;  autocmd!&#xA;  autocmd BufRead,BufNewFile *.txt call s:setupWrapping()&#xA;augroup END&#xA;&#xA;&quot;&quot; make/cmake&#xA;augroup vimrc-make-cmake&#xA;  autocmd!&#xA;  autocmd FileType make setlocal noexpandtab&#xA;  autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake&#xA;augroup END&#xA;&#xA;set autoread&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Mappings&#xA;&quot;*****************************************************************************&#xA;&#xA;&quot;&quot; Split&#xA;noremap &amp;lt;Leader&amp;gt;h :&amp;lt;C-u&amp;gt;split&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;Leader&amp;gt;v :&amp;lt;C-u&amp;gt;vsplit&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;&quot; Git&#xA;noremap &amp;lt;Leader&amp;gt;ga :Gwrite&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;Leader&amp;gt;gc :Gcommit&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;Leader&amp;gt;gsh :Gpush&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;Leader&amp;gt;gll :Gpull&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;Leader&amp;gt;gs :Gstatus&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;Leader&amp;gt;gb :Gblame&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;Leader&amp;gt;gd :Gvdiff&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;Leader&amp;gt;gr :Gremove&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; session management&#xA;nnoremap &amp;lt;leader&amp;gt;so :OpenSession&amp;lt;Space&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;ss :SaveSession&amp;lt;Space&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;sd :DeleteSession&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;sc :CloseSession&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;&quot; Tabs&#xA;nnoremap &amp;lt;Tab&amp;gt; gt&#xA;nnoremap &amp;lt;S-Tab&amp;gt; gT&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;S-t&amp;gt; :tabnew&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;&quot; Set working directory&#xA;nnoremap &amp;lt;leader&amp;gt;. :lcd %:p:h&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;&quot; Opens an edit command with the path of the currently edited file filled in&#xA;noremap &amp;lt;Leader&amp;gt;e :e &amp;lt;C-R&amp;gt;=expand(&quot;%:p:h&quot;) . &quot;/&quot; &amp;lt;CR&amp;gt;&#xA;&#xA;&quot;&quot; Opens a tab edit command with the path of the currently edited file filled&#xA;noremap &amp;lt;Leader&amp;gt;te :tabe &amp;lt;C-R&amp;gt;=expand(&quot;%:p:h&quot;) . &quot;/&quot; &amp;lt;CR&amp;gt;&#xA;&#xA;&quot;&quot; fzf.vim&#xA;set wildmode=list:longest,list:full&#xA;set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__&#xA;let $FZF_DEFAULT_COMMAND =  &quot;find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o  -type f -print -o -type l -print 2&amp;gt; /dev/null&quot;&#xA;&#xA;&quot; The Silver Searcher&#xA;if executable('ag')&#xA;  let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g &quot;&quot;'&#xA;  set grepprg=ag\ --nogroup\ --nocolor&#xA;endif&#xA;&#xA;&quot; ripgrep&#xA;if executable('rg')&#xA;  let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob &quot;!.git/*&quot;'&#xA;  set grepprg=rg\ --vimgrep&#xA;  command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob &quot;!.git/*&quot; --color &quot;always&quot; '.shellescape(&amp;lt;q-args&amp;gt;).'| tr -d &quot;\017&quot;', 1, &amp;lt;bang&amp;gt;0)&#xA;endif&#xA;&#xA;cnoremap &amp;lt;C-P&amp;gt; &amp;lt;C-R&amp;gt;=expand(&quot;%:p:h&quot;) . &quot;/&quot; &amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;b :Buffers&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;e :FZF -m&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; snippets&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-b&amp;gt;&quot;&#xA;let g:UltiSnipsEditSplit=&quot;vertical&quot;&#xA;&#xA;&quot; syntastic&#xA;let g:syntastic_always_populate_loc_list=1&#xA;let g:syntastic_error_symbol='✗'&#xA;let g:syntastic_warning_symbol='⚠'&#xA;let g:syntastic_style_error_symbol = '✗'&#xA;let g:syntastic_style_warning_symbol = '⚠'&#xA;let g:syntastic_auto_loc_list=1&#xA;let g:syntastic_aggregate_errors = 1&#xA;&#xA;&quot; Tagbar&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;F4&amp;gt; :TagbarToggle&amp;lt;CR&amp;gt;&#xA;let g:tagbar_autofocus = 1&#xA;&#xA;&quot; Disable visualbell&#xA;set noerrorbells visualbell t_vb=&#xA;if has('autocmd')&#xA;  autocmd GUIEnter * set visualbell t_vb=&#xA;endif&#xA;&#xA;&quot;&quot; Copy/Paste/Cut&#xA;if has('unnamedplus')&#xA;  set clipboard=unnamed,unnamedplus&#xA;endif&#xA;&#xA;noremap YY &quot;+y&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;leader&amp;gt;p &quot;+gP&amp;lt;CR&amp;gt;&#xA;noremap XX &quot;+x&amp;lt;CR&amp;gt;&#xA;&#xA;if has('macunix')&#xA;  &quot; pbcopy for OSX copy/paste&#xA;  vmap &amp;lt;C-x&amp;gt; :!pbcopy&amp;lt;CR&amp;gt;&#xA;  vmap &amp;lt;C-c&amp;gt; :w !pbcopy&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;endif&#xA;&#xA;&quot;&quot; Buffer nav&#xA;noremap &amp;lt;leader&amp;gt;z :bp&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;leader&amp;gt;q :bp&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;leader&amp;gt;x :bn&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;leader&amp;gt;w :bn&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;&quot; Close buffer&#xA;noremap &amp;lt;leader&amp;gt;c :bd&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;&quot; Clean search (highlight)&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;&amp;lt;space&amp;gt; :noh&amp;lt;cr&amp;gt;&#xA;&#xA;&quot;&quot; Switching windows&#xA;noremap &amp;lt;C-j&amp;gt; &amp;lt;C-w&amp;gt;j&#xA;noremap &amp;lt;C-k&amp;gt; &amp;lt;C-w&amp;gt;k&#xA;noremap &amp;lt;C-l&amp;gt; &amp;lt;C-w&amp;gt;l&#xA;noremap &amp;lt;C-h&amp;gt; &amp;lt;C-w&amp;gt;h&#xA;&#xA;&quot;&quot; Vmap for maintain Visual Mode after shifting &amp;gt; and &amp;lt;&#xA;vmap &amp;lt; &amp;lt;gv&#xA;vmap &amp;gt; &amp;gt;gv&#xA;&#xA;&quot;&quot; Move visual block&#xA;vnoremap J :m '&amp;gt;+1&amp;lt;CR&amp;gt;gv=gv&#xA;vnoremap K :m '&amp;lt;-2&amp;lt;CR&amp;gt;gv=gv&#xA;&#xA;&quot;&quot; Open current line on GitHub&#xA;nnoremap &amp;lt;Leader&amp;gt;o :.Gbrowse&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Custom configs&#xA;&quot;*****************************************************************************&#xA;&#xA;&quot; c&#xA;autocmd FileType c setlocal tabstop=4 shiftwidth=4 expandtab&#xA;autocmd FileType cpp setlocal tabstop=4 shiftwidth=4 expandtab&#xA;&#xA;&quot; syntastic&#xA;let g:syntastic_python_checkers=['python', 'flake8']&#xA;&#xA;&quot; vim-airline&#xA;let g:airline#extensions#virtualenv#enabled = 1&#xA;&#xA;&quot; Syntax highlight&#xA;&quot; Default highlight is better than polyglot&#xA;let g:polyglot_disabled = ['python']&#xA;let python_highlight_all = 1&#xA;&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;*****************************************************************************&#xA;&#xA;&quot;&quot; Include user's local vim config&#xA;if filereadable(expand(&quot;~/.config/nvim/local_init.vim&quot;))&#xA;  source ~/.config/nvim/local_init.vim&#xA;endif&#xA;&#xA;&quot;*****************************************************************************&#xA;&quot;&quot; Convenience variables&#xA;&quot;*****************************************************************************&#xA;&#xA;&quot; vim-airline&#xA;if !exists('g:airline_symbols')&#xA;  let g:airline_symbols = {}&#xA;endif&#xA;&#xA;if !exists('g:airline_powerline_fonts')&#xA;  let g:airline#extensions#tabline#left_sep = ' '&#xA;  let g:airline#extensions#tabline#left_alt_sep = '|'&#xA;  let g:airline_left_sep          = '▶'&#xA;  let g:airline_left_alt_sep      = '»'&#xA;  let g:airline_right_sep         = '◀'&#xA;  let g:airline_right_alt_sep     = '«'&#xA;  let g:airline#extensions#branch#prefix     = '⤴' &quot;➔, ➥, ⎇&#xA;  let g:airline#extensions#readonly#symbol   = '⊘'&#xA;  let g:airline#extensions#linecolumn#prefix = '¶'&#xA;  let g:airline#extensions#paste#symbol      = 'ρ'&#xA;  let g:airline_symbols.linenr    = '␊'&#xA;  let g:airline_symbols.branch    = '⎇'&#xA;  let g:airline_symbols.paste     = 'ρ'&#xA;  let g:airline_symbols.paste     = 'Þ'&#xA;  let g:airline_symbols.paste     = '∥'&#xA;  let g:airline_symbols.whitespace = 'Ξ'&#xA;else&#xA;  let g:airline#extensions#tabline#left_sep = ''&#xA;  let g:airline#extensions#tabline#left_alt_sep = ''&#xA;&#xA;  &quot; powerline symbols&#xA;  let g:airline_left_sep = ''&#xA;  let g:airline_left_alt_sep = ''&#xA;  let g:airline_right_sep = ''&#xA;  let g:airline_right_alt_sep = ''&#xA;  let g:airline_symbols.branch = ''&#xA;  let g:airline_symbols.readonly = ''&#xA;  let g:airline_symbols.linenr = ''&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12828" LastEditorUserId="12828" LastEditDate="2017-06-01T11:47:02.337" LastActivityDate="2017-06-01T11:47:02.337" Title="different colour schemas depends how file is opened" Tags="|neovim|colorscheme|filetype-c++|" AnswerCount="1" CommentCount="12" ClosedDate="2017-06-04T03:48:46.213" ContentLicense="CC BY-SA 3.0" />
  <row Id="12534" PostTypeId="2" ParentId="12520" CreationDate="2017-05-31T06:20:08.897" Score="26" Body="&lt;p&gt;To help answer your original question, you can check where a setting was last set with the &lt;code&gt;:verbose&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set conceallevel&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will display a message similar to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;conceallevel=2&#xA;    Last set from ~/.vim/plugged/indentLine/after/plugin/indentLine.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;:verbose&lt;/code&gt; simply runs a command with a specified verbosity, so if you wish to check something like the &lt;code&gt;number&lt;/code&gt; setting, you'll need to run &lt;code&gt;:verbose set number?&lt;/code&gt; (with the &lt;code&gt;?&lt;/code&gt;, otherwise it will just turn the setting on). Check &lt;code&gt;:h :verbose&lt;/code&gt; for more.&lt;/p&gt;&#xA;" OwnerDisplayName="user4879" LastActivityDate="2017-05-31T06:20:08.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12535" PostTypeId="2" ParentId="12533" CreationDate="2017-05-31T13:56:25.063" Score="1" Body="&lt;p&gt;As far I can tell from the images there was no change in the colorscheme (which you change using the &lt;a href=&quot;http://vimhelp.appspot.com/usr_06.txt.html#06%2e3&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:colorscheme&lt;/code&gt;&lt;/a&gt; command). What you are seeing is probably a change on the syntax highlight and maybe different &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27fileformat%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'fileformat'&lt;/code&gt;&lt;/a&gt;, as the MS-Windows line endings (&lt;code&gt;^M&lt;/code&gt;) are displayed and highlighted in one of the images.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, I'd stay away from config generated by tools, such as vim-bootstrap service, as explained in this question about &lt;a href=&quot;https://stackoverflow.com/questions/31325442/vim-and-spf13-configuration&quot;&gt;VIM and SPF13 Configuration&lt;/a&gt;. The problem you are facing probably comes from the interaction of plugins and/or configurations, and I believe that you'd be far better using a simpler configuration and fewer plugins, which would make it far easier to debug problems as the one you found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check which plugin or setting that you are using is causing the problem you could follow the procedure described on &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-2.5&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim-FAQ  2.5&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2017-05-31T13:56:25.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12536" PostTypeId="1" CreationDate="2017-05-31T23:27:54.323" Score="4" ViewCount="3097" Body="&lt;p&gt;I've looked through the &lt;code&gt;vimwiki&lt;/code&gt; documentation and a few questions here on SO, but don't see how I can manage this. In &lt;code&gt;vim-notes&lt;/code&gt;, hitting &lt;code&gt;TAB&lt;/code&gt; within a list indents the entire list item. In &lt;code&gt;vimwiki&lt;/code&gt;, hitting &lt;code&gt;TAB&lt;/code&gt; within a list indents within the list item, leaving the list marker unmoved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I have written one list item and hit &lt;code&gt;ENTER&lt;/code&gt; to start a second. Both &lt;code&gt;vimwiki&lt;/code&gt; and &lt;code&gt;vim-notes&lt;/code&gt; treat this similarly: they both match the indentation and list marker of the preceding line. [Here &lt;code&gt;&amp;gt;---&lt;/code&gt; is a &lt;code&gt;TAB&lt;/code&gt; character, &lt;code&gt;*&lt;/code&gt; is the list marker, and &lt;code&gt;|&lt;/code&gt; is the curser position.]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 &amp;gt;--- * My list item&#xA;2 &amp;gt;--- * |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I'm using &lt;code&gt;vim-notes&lt;/code&gt;, hitting &lt;code&gt;TAB&lt;/code&gt; will achieve this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 &amp;gt;--- * My list item&#xA;2 &amp;gt;--- &amp;gt;--- * |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;vimwiki&lt;/code&gt;, hitting &lt;code&gt;TAB&lt;/code&gt; will achieve this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 &amp;gt;--- * My list item&#xA;2 &amp;gt;--- * &amp;gt;---|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously I can exit insert mode, navigate to the start of the line, hit &lt;code&gt;TAB&lt;/code&gt;, then hit &lt;code&gt;A&lt;/code&gt; to continue typing at the end of the line but that's not a good flow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a setting, &lt;code&gt;g:notes_tab_indents&lt;/code&gt;, that controls this behavior in &lt;code&gt;vim-notes&lt;/code&gt;, but I haven't found a corresponding control for &lt;code&gt;vimwiki&lt;/code&gt;. The closest reference I can find to the behavior &lt;code&gt;vimwiki&lt;/code&gt; anticipates supporting is in &lt;code&gt;g:vimwiki_folding&lt;/code&gt; where it discusses how &lt;code&gt;vimwiki&lt;/code&gt; expects lists to be &quot;nicely indented with &lt;code&gt;shiftwidth&lt;/code&gt;&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*g:vimwiki_folding*&#xA;&#xA;Enable/disable Vimwiki's folding (outline) functionality. Folding in&#xA;Vimwiki can uses either the 'expr' or the 'syntax' |foldmethod| of Vim.&#xA;&#xA;Value           Description~&#xA;&#xA;''              Disable folding    &#xA;'expr'          Folding based on expression (folds sections and code blocks)    &#xA;'syntax'        Folding based on syntax (folds sections; slower than 'expr')    &#xA;'list'          Folding based on expression (folds list subitems; much slower)    &#xA;'custom'        Leave the folding settings as they are (e.g. set by another&#xA;                plugin)&#xA;&#xA;Default: ''&#xA;&#xA;Limitations:    &#xA;  - Opening very large files may be slow when folding is enabled.    &#xA;  - 'list' folding is particularly slow with larger files.    &#xA;  - 'list' is intended to work with lists nicely indented with 'shiftwidth'.    &#xA;  - 'syntax' is only available for the default syntax so far.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;shiftwidth&lt;/code&gt; documentation describes functionality I'd never known about before: &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;. The former reduces the current line/selection's indent by one tab stop; the latter expands the indentation. This is obviously not available in insert mode, so not optimal, but it'll definitely do in a pinch (especially when I remap it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read through the &lt;code&gt;vim-notes&lt;/code&gt; code and short of replicating the functions in my own (first) project, I'm not sure if there is some &lt;code&gt;vim&lt;/code&gt; functionality, e.g., some keymapping, that can achieve at least the &lt;code&gt;TAB&lt;/code&gt; indentation behavior (much of the relevant &lt;code&gt;vim-notes&lt;/code&gt; functions use regex patterns to match bullet styles).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="12840" LastEditorUserId="343" LastEditDate="2017-06-01T09:08:47.193" LastActivityDate="2019-04-09T13:06:00.470" Title="Can vimwiki be made to treat list indentation the way vim-notes does?" Tags="|indentation|plugin-vimwiki|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12537" PostTypeId="1" AcceptedAnswerId="12540" CreationDate="2017-06-01T03:07:29.753" Score="0" ViewCount="357" Body="&lt;p&gt;I try to install &lt;a href=&quot;http://vim-latex.sourceforge.net/index.php?subject=download&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-latex&lt;/a&gt;, a plugin for vim to edit latex file,&#xA;According to the download page&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;blockquote&gt;&#xA;    &lt;p&gt;In step 3 of 4 :To install the included latex-suite.txt and latexhelp.txt files as vim help files, start vim and do the following:&lt;/p&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;helptags ~/.vim/doc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It promts&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E150: Not a directory: ~/.vim/doc &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I did&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;helptags ~/.vim/vim-latex-1.9.0/doc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;nothing happened&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;blockquote&gt;&#xA;    &lt;p&gt;Step 4 of 4: Done!&#xA;    Thats it! You are done! Now start editing a latex file in vim. Latex-Suite should start up automatically. You can do&lt;/p&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help latex-suite.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I got another error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E149: Sorry, no help for latex-suite.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I summarized the steps I did before&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;blockquote&gt;&#xA;    &lt;p&gt;Step 1 of 4: Download and extract the archives&lt;/p&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tar xvzf vim-latex-1.9.0.tar.gz -C ~/.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;nothing wrong, there is one more file  &lt;code&gt;vim-latex-1.9.0.tar&lt;/code&gt; under  &lt;code&gt;~/.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;blockquote&gt;&#xA;    &lt;p&gt;Step 2 of 4: Set a few things in &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I copied the contents to my &lt;code&gt;.vimrc&lt;/code&gt; file in a right way. &#xA;there is no file named &lt;code&gt;tex.vim&lt;/code&gt; under &lt;code&gt;~/.vim/ftplugin/&lt;/code&gt; so I created one and copy the contents to my &lt;code&gt;tex.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when I start editing &lt;code&gt;.tex&lt;/code&gt; file, nothing paticular happened, so I guess I didn'd have  &lt;code&gt;vim-latex&lt;/code&gt; installed. I don't know where I did wrong?&lt;/p&gt;&#xA;" OwnerUserId="11787" LastEditorUserId="11787" LastEditDate="2017-06-01T05:26:57.570" LastActivityDate="2017-06-01T09:25:34.723" Title="Problems in installing vim-latex" Tags="|plugin-vim-latex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12539" PostTypeId="2" ParentId="12536" CreationDate="2017-06-01T09:00:48.607" Score="11" Body="&lt;p&gt;I'm going to ignore the majority of your question (perhaps someone will be along later to provide more specifically what you're asking for) and instead suggest that you just use insert mode's indent command: &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;T&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help i_CTRL-T&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Insert one shiftwidth of indent at the start of the current line.  The indent is always rounded to a 'shiftwidth' (this is vi compatible).  {Vi: only when in indent}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;D&lt;/kbd&gt; for outdent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: If you're dead set on indenting with the &lt;kbd&gt;Tab&lt;/kbd&gt; key, a simple but inelegant method would be to map it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;tab&amp;gt; &amp;lt;c-t&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'd presumably only want this to apply to vimwiki files, so add the command to a new file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/after/ftplugin/vimwiki.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This approach could of course be refined to only perform indent when appropriate, or to perform more intelligent indent. You could of course take a look at &lt;a href=&quot;https://github.com/xolox/vim-notes/blob/master/autoload/xolox/notes.vim#L1045&quot; rel=&quot;noreferrer&quot;&gt;vim-notes's indent function&lt;/a&gt; for ideas/implementation tips.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-06-01T22:27:49.370" LastActivityDate="2017-06-01T22:27:49.370" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12540" PostTypeId="2" ParentId="12537" CreationDate="2017-06-01T09:20:12.307" Score="1" Body="&lt;p&gt;It sounds like you've added the &lt;code&gt;vim-latex-1.9.0&lt;/code&gt; directory as a subdirectory of your &lt;code&gt;.vim&lt;/code&gt; directory. For a traditional installation, you should be adding the &lt;em&gt;contents&lt;/em&gt; of the &lt;code&gt;vim-latex-1.9.0&lt;/code&gt; directory to your &lt;code&gt;.vim&lt;/code&gt; directory (merging the contents of any directories into the directories that already exist in &lt;code&gt;.vim&lt;/code&gt;, if necessary.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'd strongly recommend you look into the more recent methods of installation, either Vim 8's &lt;code&gt;package&lt;/code&gt; feature (or if you are still on Vim 7, &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow noreferrer&quot;&gt;pathogen&lt;/a&gt;), or one of the &lt;a href=&quot;https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers&quot;&gt;various plugin managers&lt;/a&gt; that are available, which offer various advantages over the old method.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-06-01T09:25:34.723" LastActivityDate="2017-06-01T09:25:34.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12542" PostTypeId="2" ParentId="8381" CreationDate="2017-06-01T16:37:25.983" Score="7" Body="&lt;p&gt;The solution given in Jepz's answer didn't completely work for me. &lt;code&gt;eslint&lt;/code&gt; was correctly called with the &lt;code&gt;--fix&lt;/code&gt; option. However, maybe it's because of internals that have changed, but it seems like &lt;code&gt;checktime&lt;/code&gt; was called before the end of &lt;code&gt;eslint --fix&lt;/code&gt;, so the file reloading didn't work properly, triggering a &lt;code&gt;file has changed, are you sure you want to write to it?&lt;/code&gt; on the next save.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, by digging into issues, I've discovered a hidden hook that seems to trigger after the Syntastic checks have completed, called &lt;code&gt;SyntasticCheckHook&lt;/code&gt; (&lt;a href=&quot;https://github.com/vim-syntastic/syntastic/issues/1678&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this, you can simply call &lt;code&gt;checktime&lt;/code&gt; after the Syntastic checks have run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my final code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoread&#xA;&#xA;let g:syntastic_javascript_checkers = ['eslint']&#xA;&#xA;&quot; autofix with eslint&#xA;let g:syntastic_javascript_eslint_args = ['--fix']&#xA;function! SyntasticCheckHook(errors)&#xA;  checktime&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit: I've personally switched to &lt;code&gt;ALE&lt;/code&gt; for linting, which supports autofixing natively.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="12851" LastEditorUserId="12851" LastEditDate="2019-05-14T12:36:07.263" LastActivityDate="2019-05-14T12:36:07.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12543" PostTypeId="2" ParentId="7924" CreationDate="2017-06-01T17:49:20.743" Score="0" Body="&lt;p&gt;There is yet another &quot;solution&quot;, actually sort of a kludge for this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have custom syntax groups for such thing as &quot;listchars&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi WhiteSpaceChar ctermfg=251 guifg=#999999&#xA;call matchadd(&quot;WhiteSpaceChar&quot;, &quot;[ \t]&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could do something like this (though I didn't test it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi TrailChar ctermfg=251 guifg=#999999&#xA;&quot; the \v in the regex is Vim's flag to use Perl-like regex syntax&#xA;call matchadd(&quot;TrailChar&quot;, &quot;\v +$&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But there are at least two problems with this approach:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;when you split a window, or create a new tab etc. the highlight becomes broken in the current window, like this:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/h19oF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h19oF.png&quot; alt=&quot;white space highlight becomes broken, when a new window opens&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this I have special functions like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ResetHiglightJS()&#xA;  set syntax=javascript&#xA;  &quot;these are for the IndentLine plugin&#xA;  &quot;IndentLinesDisable&#xA;  &quot;IndentLinesEnable&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for each syntax group, which I use often, to fix the highlighting manually. You can do this in other way like autocommands or manually setting the value for the syntax option. To make the syntax resetting work one also must have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call matchadd(&quot;WhiteSpaceChar&quot;, &quot;[ \t]&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in each corresponding syntax file, like &lt;code&gt;~/.vim/after/syntax/javascript.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;This approach does not work normally with at least one plugin — the IndentLine one, so I was forced to stick to an old version of it by setting manually &lt;code&gt;let g:indentLine_newVersion = 0&lt;/code&gt;, where the plugin worked normally.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But in other way this approach works normally without the IndentLine plugin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Np2rP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Np2rP.png&quot; alt=&quot;white spaces have a desired color in the cursor line&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And acceptable with it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HNfZ8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HNfZ8.png&quot; alt=&quot;indentLine color in the cursor line&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2798" LastEditorUserId="2798" LastEditDate="2017-06-01T18:12:05.637" LastActivityDate="2017-06-01T18:12:05.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12544" PostTypeId="2" ParentId="4134" CreationDate="2017-06-02T00:22:08.360" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;Open the great &lt;code&gt;vim&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Enter insert mode and add a python3 statement inside your text file buffer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;print(5*5)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to normal mode (ESC or CTRL+C)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;code&gt;!!&lt;/code&gt; making sure the cursor is above that line. Your command bar will be filled like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:.!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;fill the rest of command with &lt;code&gt;python&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:.!python &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;press enter end you line will be evaluated:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;25&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6684" LastActivityDate="2017-06-02T00:22:08.360" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12545" PostTypeId="1" CreationDate="2017-06-02T04:07:30.647" Score="1" ViewCount="515" Body="&lt;p&gt;On Vim 7.3 on Windows, if I use &lt;kbd&gt;Tab&lt;/kbd&gt; to autocomplete paths with nonstandard characters in many cases, it works fine. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:n 2016\ Posts\\feb\something.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;kbd&gt;Tab&lt;/kbd&gt; after '2' and 'f' and &quot;so&quot;, I get the above, and it correctly opens &quot;2016 Posts/feb/something.txt&quot;. The fact that Windows likes backslashes and the weirdness of escaping them (why does it use it for the space and the first slash, but not the second) does not appear to give Vim a problem. I can even type &lt;code&gt;/g&lt;/code&gt; instead of &lt;code&gt;\g&lt;/code&gt; and Vim properly replaces the forward slash with a backward one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I try to use run a shell command with &lt;code&gt;:!&lt;/code&gt; or &lt;code&gt;:r!&lt;/code&gt;, trouble ensues. For instance, say I want to read in the file listing of &quot;2016 Posts&quot;, and I tab after '2' as before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r!dir 2016\ Posts\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get &quot;shell returned 1&quot;, and the text I read in is &quot;The system cannot find the file specified.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This makes sense if I imagine Vim is sending the string exactly as I see it to an MS-DOS shell; if I start an actual shell and type &quot;dir 2016\ Posts\&quot; I get the exact same error (and I assume the command is returning error code 1). And if I carefully type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r!dir &quot;2016 Posts&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the file listing I expect. But I can't use auto-complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get Vim to recognize that I'm typing something that will get sent to a shell (with idiosyncratic parsing of slashes, nonstandard characters, and so on), and auto-complete correctly? Or is this an actual bug I should be submitting to Bram Moolenaar? Or, is there some reason this can never be fixed, due to something I hadn't thought of, where Vim can't reasonably tell what I will want? (It seems possible to assume that since I'm using auto-complete, that it's a path, and that since it's inside a &lt;code&gt;:!&lt;/code&gt; construction, that it ought to follow Windows' conventions.)&lt;/p&gt;&#xA;" OwnerUserId="12718" LastEditorUserId="1841" LastEditDate="2018-10-09T14:32:51.753" LastActivityDate="2018-10-09T14:32:51.753" Title="How do I get vim to autocomplete correctly for :! on Windows?" Tags="|command-line|autocompletion|microsoft-windows|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12546" PostTypeId="1" CreationDate="2017-06-02T09:50:19.513" Score="2" ViewCount="106" Body="&lt;p&gt;When I &lt;code&gt;set foldmethod=manual&lt;/code&gt; and then I'm typing &lt;code&gt;&amp;lt;zc&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E490: No fold found&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;is raising.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same story with &lt;code&gt;set foldmethod=marker&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior is the same on Mac Sierra and Ubuntu 16.04. I installed vim 8.0.606 instead 7.4.xxx but it doesn't help. Also I compiled 8.0 manually and expected to find a compilation option related to folding but a docs don't refer folding options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How to fix it?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="10942" LastEditorUserId="10942" LastEditDate="2017-06-04T08:01:42.173" LastActivityDate="2017-06-04T08:01:42.173" Title="Manual fold issue on both Mac &amp; Ubuntu" Tags="|folding|macvim|linux-ubuntu|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12547" PostTypeId="1" AcceptedAnswerId="12554" CreationDate="2017-06-02T14:45:19.953" Score="7" ViewCount="644" Body="&lt;p&gt;I'm running bash, and my &lt;code&gt;~/.inputrc&lt;/code&gt; contains &lt;code&gt;set editing-mode vi&lt;/code&gt;.  This allows me to edit my command line using vi-like behaviour.  And I can press &lt;code&gt;v&lt;/code&gt; in normal mode to enter the full-fledged vi-editor, if I need full power to edit the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only problem is that when I exit, the command executes right away.  I would rather continue editing on the command line so that I can take advantage of bash's completion features.  I can't do that when I'm in the vi editor.  Is there a way to avoid automatically executing the edited command upon exiting vi?&lt;/p&gt;&#xA;" OwnerUserId="7970" LastActivityDate="2017-06-03T13:37:38.477" Title="vi editing of bash command line: Avoid execution upon exit?" Tags="|bash|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12548" PostTypeId="2" ParentId="12547" CreationDate="2017-06-02T16:54:16.600" Score="2" Body="&lt;p&gt;I have the following command in my &lt;code&gt;.bashrc&lt;/code&gt; to do a similar thing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set -o vi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11878" LastEditorUserId="4472" LastEditDate="2017-06-02T19:24:45.607" LastActivityDate="2017-06-02T19:24:45.607" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12549" PostTypeId="2" ParentId="12547" CreationDate="2017-06-02T20:22:57.847" Score="4" Body="&lt;h3&gt;How to do it&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Bash doesn't seem to provide builtin support for this in form of a readline function like it does for editing and executing. However, there is &lt;code&gt;bind -x&lt;/code&gt; command to invoke arbitrary shell function and &lt;code&gt;$READLINE_*&lt;/code&gt; variables which can be combined to perform command-line editing, one just needs to call Vim to do the job:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;function _editcommandline() {&#xA;    local tmp_file=&quot;$(mktemp &quot;/tmp/bash-editinplace.XXXXXX&quot;)&quot;&#xA;    echo &quot;$READLINE_LINE&quot; &amp;gt;| &quot;$tmp_file&quot;&#xA;&#xA;    vim +&quot;call cursor(1, $READLINE_POINT + 1)&quot; &quot;$tmp_file&quot;&#xA;&#xA;    READLINE_LINE=&quot;$(&amp;lt; &quot;$tmp_file&quot;)&quot;&#xA;    READLINE_POINT=&quot;${#READLINE_LINE}&quot;&#xA;&#xA;    rm -f &quot;$tmp_file&quot;&#xA;}&#xA;# bind to Ctrl-X+e combination&#xA;bind -x '&quot;\C-Xe&quot;: _editcommandline'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;How it works&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Here we define function &lt;code&gt;_editcommandline()&lt;/code&gt; and use &lt;code&gt;bind&lt;/code&gt; to tell bash to invoke&#xA;it when &lt;kbd&gt;C-X&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt; combination is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside the function:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Temporary file is created.&lt;/li&gt;&#xA;&lt;li&gt;The file is filled with current input line.&lt;/li&gt;&#xA;&lt;li&gt;Vim is called to edit the line, positioning the cursor appropriately.&lt;/li&gt;&#xA;&lt;li&gt;Current line is replaced with contents of the temporary file, which is later removed.&lt;/li&gt;&#xA;&lt;li&gt;Cursor is positioned at the end of input line.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;Limitation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The limitation of this approach is that you can edit only current input line, not whole command-line, but this is important only for multi-line commands.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Possible improvements&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The function was written for demonstration purposes and can be further improved by:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Correctly positioning cursor in bash instead of moving it to the end.&lt;/li&gt;&#xA;&lt;li&gt;Checking exit code of Vim to be able to discard saved changes with &lt;code&gt;:cquit&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="860" LastActivityDate="2017-06-02T20:22:57.847" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12550" PostTypeId="1" AcceptedAnswerId="12693" CreationDate="2017-06-03T00:05:48.917" Score="1" ViewCount="1187" Body="&lt;p&gt;I use Google &lt;code&gt;closure-compiler&lt;/code&gt; to check syntax errors in a JS file, the problem is that if there is no error it gives the source of the file to its STDOUT and with the default settings this counts as an error and clutters the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Bash I can do this: &lt;code&gt;$closure-compiler foo.js 1&amp;gt;/dev/null&lt;/code&gt; and then it gives only errors, otherwise nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But is it possible to specify this command to the Vim &lt;code&gt;makeprg&lt;/code&gt; option? I tried many ways to no avail, for instance this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set makeprg = closure-compiler\ %\ 1&amp;gt;/dev/null&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't return STDERR as well as STDOUT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; set makeprg = closure-compiler\ %\ '1&amp;gt;/dev/null'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;treats &lt;code&gt;1&amp;gt;/dev/null&lt;/code&gt; as a file name, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can create a Bash-script but is it possible to do it only in &lt;code&gt;vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose there is no way for this without the bash-script, since errors are STDERR only for &lt;code&gt;closure-compiler&lt;/code&gt;, but Vim (I suppose) uses the terminal program and for it STDERR of &lt;code&gt;closure-compiler&lt;/code&gt; becomes STDOUT, so that Vim doesn't receive STDERR in this case but STDOUT from the terminal.&lt;/p&gt;&#xA;" OwnerUserId="2798" LastEditorUserId="2798" LastEditDate="2017-06-03T00:12:46.853" LastActivityDate="2017-06-25T00:21:11.940" Title="How to redirect a make program's stdout when using it in Vim?" Tags="|vimrc|makeprg|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12552" PostTypeId="2" ParentId="10040" CreationDate="2017-06-03T01:09:08.280" Score="1" Body="&lt;p&gt;Here is a solution using &lt;code&gt;BufFilePost&lt;/code&gt; based on the buffer name being &lt;code&gt;[jupyter]&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetype_jupyter&#xA;  autocmd!&#xA;  autocmd BufFilePost \[jupyter\]&#xA;  \ setlocal filetype=python |&#xA;  \ DisableWhitespace&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It also sets the &lt;code&gt;filetype&lt;/code&gt; to Python.&lt;/p&gt;&#xA;" OwnerUserId="6872" LastActivityDate="2017-06-03T01:09:08.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12553" PostTypeId="2" ParentId="11336" CreationDate="2017-06-03T03:12:44.600" Score="1" Body="&lt;p&gt;You may need to add the PATH of installed gems into your PATH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do it like below in your &lt;code&gt;.bashrc&lt;/code&gt; or &lt;code&gt;.bash_profile&lt;/code&gt; or other shells' rc/profile files.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ -d $HOME/.gem/ruby/2.4.0/bin ] &amp;amp;&amp;amp; PATH=$HOME/.gem/ruby/2.4.0/bin:$PATH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;export PATH&lt;/code&gt; together with all other PATH values.&lt;/p&gt;&#xA;" OwnerUserId="12877" LastEditorUserId="51" LastEditDate="2017-07-03T06:54:22.000" LastActivityDate="2017-07-03T06:54:22.000" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12554" PostTypeId="2" ParentId="12547" CreationDate="2017-06-03T13:37:38.477" Score="7" Body="&lt;p&gt;I often just prepend the command with &lt;code&gt;#&lt;/code&gt;. After exiting vim it's then in the bash history.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-06-03T13:37:38.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12555" PostTypeId="1" AcceptedAnswerId="12557" CreationDate="2017-06-04T00:22:30.773" Score="9" ViewCount="789" Body="&lt;p&gt;I'd like to define my own operator. Vim's builtin help has a nice little tutorial on it, where they show you can create your own operator with &lt;code&gt;opfunc&lt;/code&gt; and &lt;code&gt;g@&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;F4&amp;gt; :set opfunc=CountSpaces&amp;lt;CR&amp;gt;g@&#xA;vmap &amp;lt;silent&amp;gt; &amp;lt;F4&amp;gt; :&amp;lt;C-U&amp;gt;call CountSpaces(visualmode(), 1)&amp;lt;CR&amp;gt;&#xA;&#xA;function! CountSpaces(type, ...)&#xA;  ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's only one downside to this approach. Let's say for example, that I want to run &lt;code&gt;&amp;lt;F4&amp;gt;2j&lt;/code&gt;. That works fine, but &lt;code&gt;2&amp;lt;F4&amp;gt;j&lt;/code&gt; does not. This gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E481: No range allowed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes perfect sense because the range is applied to the &lt;code&gt;set opfunc&lt;/code&gt; command, not the &lt;code&gt;g@&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought that I would be able to get around it by doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;F4&amp;gt; &quot;:\&amp;lt;C-u&amp;gt;set opfunc=Test\&amp;lt;cr&amp;gt;&quot;.v:count1.'g@'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I run this, it causes some strange issues where &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt; are incorrectly defined in the function. (I'd be happy to go into more details in chat, but that's unrelated to my question. I've reproduced this bug in Vim 8.0 on Windows and Ubuntu and in Neovim 0.2.1 on Windows)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I define my operator so that a count works the same before or after the operator? I realize that this is a very minor difference, and that for most intents and purposes, I can simply get around it by always doing the count afterwards. But vim's default operators work this way, and I would really like mine too also.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="343" LastEditDate="2017-12-06T11:27:11.987" LastActivityDate="2017-12-06T11:27:11.987" Title="How to allow count *before* my custom operator?" Tags="|vimscript|count|map-operator|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12556" PostTypeId="1" CreationDate="2017-06-04T00:40:58.643" Score="5" ViewCount="2700" Body="&lt;p&gt;Once I run &lt;code&gt;vi a.out&lt;/code&gt;, I can type &lt;code&gt;:%!xxd&lt;/code&gt;, but I'm unable to automate the process like&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;start vi automatically in hex mode&lt;/li&gt;&#xA;&lt;li&gt;create a key mapping from &lt;kbd&gt;F1&lt;/kbd&gt; to &lt;code&gt;:%!xxd&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="12889" LastEditorUserId="4472" LastEditDate="2017-06-08T22:45:49.573" LastActivityDate="2017-06-08T22:45:49.573" Title="start vi automatically in hex mode" Tags="|startup|key-bindings|xxd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12557" PostTypeId="2" ParentId="12555" CreationDate="2017-06-04T01:18:45.640" Score="13" Body="&lt;p&gt;You can call a function transparently within a mapping, thus circumventing&#xA;mode changes (e.g. by pressing &lt;code&gt;:&lt;/code&gt;) or losing counts, by using &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mappings, similar to what you suggested. Just use them to call a function like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! SetOpFunc()&#xA;    set opfunc=CountSpaces&#xA;    return 'g@'&#xA;endfun&#xA;nno &amp;lt;expr&amp;gt; &amp;lt;F4&amp;gt; SetOpFunc()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This technique isn't limited to operator mappings either. For example&#xA;I've used it in Operator-pending mappings to call a function during the&#xA;mapping without disrupting modes or counts, returning &lt;code&gt;''&lt;/code&gt; at the end.&#xA;This way you can leverage Vim's native features rather than having to&#xA;recreate them yourself.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2017-06-05T13:57:29.420" LastActivityDate="2017-06-05T13:57:29.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12558" PostTypeId="1" CreationDate="2017-06-04T09:36:19.270" Score="4" ViewCount="379" Body="&lt;p&gt;I wonder if there is a way to have a ruler displayed between the 80th and the 81th character in vim. I know that one can highlight the 81th column, but that actually looks as ugly as something from the DOS era. Is there a way to display a pretty ruler like the one in sublime?&lt;/p&gt;&#xA;" OwnerUserId="12892" LastActivityDate="2017-06-08T12:24:55.483" Title="Change the looks of the character limit ruler" Tags="|options|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12559" PostTypeId="1" CreationDate="2017-06-04T10:45:27.453" Score="1" ViewCount="40" Body="&lt;p&gt;Say I have a file with the following contents (on a single line):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed augue ligula, venenatis et orci non, convallis congue nunc. Nam eleifend mauris vehicula enim facilisis, vitae commodo metus eleifend. Vivamus convallis vestibulum lorem, et mattis nisl iaculis nec. Nullam vitae egestas ipsum, in tempus augue. Suspendisse mattis odio in justo ultricies, ac aliquam odio efficitur. Nam libero arcu, mollis blandit sem id, accumsan mattis orci. Nam scelerisque, mi eget sollicitudin bibendum, dui tortor placerat mi, eget tempor arcu odio at lacus. Integer turpis eros, sollicitudin ac risus sit amet, viverra efficitur lectus. Nulla rhoncus nisl eget neque aliquam maximus.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I've &lt;code&gt;:set wrap linebreak&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;, so that it appears like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed augue ligula, venenatis et orci non, &#xA;convallis congue nunc. Nam eleifend mauris vehicula enim facilisis, vitae commodo metus eleifend. &#xA;Vivamus convallis vestibulum lorem, et mattis nisl iaculis nec. Nullam vitae egestas ipsum, in &#xA;tempus augue. Suspendisse mattis odio in justo ultricies, ac aliquam odio efficitur. Nam libero &#xA;arcu, mollis blandit sem id, accumsan mattis orci. Nam scelerisque, mi eget sollicitudin bibendum, &#xA;dui tortor placerat mi, eget tempor arcu odio at lacus. Integer turpis eros, sollicitudin ac risus &#xA;sit amet, viverra efficitur lectus. Nulla rhoncus nisl eget neque aliquam maximus.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I &lt;code&gt;:ye&lt;/code&gt; the first word of each (visual) line and paste it into a new file, I get what I'd expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem&#xA;convallis&#xA;Vivamus&#xA;tempus&#xA;arcu&#xA;dui&#xA;sit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I instead select the first word as a visual block (&lt;code&gt;ctrl + v + l&lt;/code&gt;), yank, and paste into a new file, the pasted result is shifted, and appears to include the spaces visually added to the previous line in order to avoid breaking words across lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem&#xA;   conval&#xA;d. V&#xA;m, in&#xA; Nam&#xA;itu&#xA;lic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this a bug, or intended behavior?  Is there a way to ensure that what I yank corresponds to what I've selected visually?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Ubuntu 16.04, and am using vim 8.0.606 (built from the &lt;a href=&quot;https://github.com/vim/vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;github repo&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="867" LastActivityDate="2017-06-04T10:45:27.453" Title="Yanking a visual block with word wrap enabled is shifted" Tags="|cut-copy-paste|visual-block|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12560" PostTypeId="1" CreationDate="2017-06-04T12:39:43.390" Score="0" ViewCount="164" Body="&lt;p&gt;I have these lines in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Remap movement &#xA;nnoremap j h                                                                                                      &#xA;nnoremap k j                                                                                                      &#xA;nnoremap l k                                                                                                      &#xA;nnoremap é l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to work properly for simple navigation, but utterly fails when I want to have movements combined with actions, eg. &lt;code&gt;d2k&lt;/code&gt; should delete 2 lines downwards, but it actually moves upwards (as if i did not remap the key &lt;code&gt;k&lt;/code&gt;. How do I correctly do the remapping, so that every command obeys it?&lt;/p&gt;&#xA;" OwnerUserId="12892" LastActivityDate="2017-06-04T12:48:59.630" Title="Remapped keys won't work when combined" Tags="|key-bindings|navigation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12561" PostTypeId="2" ParentId="12560" CreationDate="2017-06-04T12:48:59.630" Score="1" Body="&lt;p&gt;I've found the answer, I needed to add separate lines like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Remap movement keys for operations                                                                                  &#xA;onoremap j h                                                                                                          &#xA;onoremap k j                                                                                                          &#xA;onoremap l k                                                                                                          &#xA;onoremap é l   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12892" LastActivityDate="2017-06-04T12:48:59.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12562" PostTypeId="2" ParentId="12324" CreationDate="2017-06-04T20:13:38.200" Score="1" Body="&lt;p&gt;This was a bug, it must be fixed with &lt;a href=&quot;https://github.com/vim/vim/commit/bf15b8d78b22661db8b19d662b62bb9a061cdd37&quot; rel=&quot;nofollow noreferrer&quot;&gt;patch 8.0.0615&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1248" LastActivityDate="2017-06-04T20:13:38.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12564" PostTypeId="2" ParentId="12556" CreationDate="2017-06-05T07:03:35.723" Score="6" Body="&lt;p&gt;To start vim automatically in hex mode when editing a.out, put an autocommand like this one in your &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufReadPost a.out silent %!xxd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A more complete explanation with examples can be found at:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help using-xxd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use key mapping instead, mapping , for example, use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F3&amp;gt; :%!xxd&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-06-05T07:03:35.723" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12565" PostTypeId="1" AcceptedAnswerId="12567" CreationDate="2017-06-05T19:15:48.503" Score="3" ViewCount="5091" Body="&lt;p&gt;&lt;code&gt;:h shortmess&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;A    don't give the &quot;ATTENTION&quot; message when an existing swap file is found.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But then what does Vim do about the existing swap file? Some people say it's bad to use that option, why so?&lt;/p&gt;&#xA;" OwnerUserId="7642" LastActivityDate="2019-03-29T01:35:58.687" Title="What does shortmess+=A do about the swp file?" Tags="|swap-file|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12566" PostTypeId="2" ParentId="12558" CreationDate="2017-06-05T21:53:16.303" Score="4" Body="&lt;p&gt;Unfortunately not possible in vim; painting color on anything less than a full cell is not possible for (most?) terminals. There are several other options available, such as changing changing background color for text when it overflows the 80 character limit, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/235439/vim-80-column-layout-concerns&quot;&gt;This thread&lt;/a&gt;, while being about a different issue, provides several alternatives to a normal color column.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2017-06-05T21:53:16.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12567" PostTypeId="2" ParentId="12565" CreationDate="2017-06-05T22:54:04.170" Score="4" Body="&lt;p&gt;If you set &lt;code&gt;A&lt;/code&gt; option Vim will just forget about swap at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll stop getting messages about a swap file being found and if you're editing the same file in different terminals at the same time, it's your problem &amp;lt;3&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I mean is that Vim will not care about the swap file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's put a example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You open &lt;code&gt;main.c&lt;/code&gt; in terminal A, and you write something in it. &#xA;You save it with &lt;code&gt;:w&lt;/code&gt; without closing vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you open &lt;code&gt;main.c&lt;/code&gt; in terminal B and edit it again, &#xA;You save it with &lt;code&gt;wq&lt;/code&gt;.&#xA;(normally at this point the swap attention text would appear, but you have disabled it)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, in Terminal A, you edit it and save it  with &lt;code&gt;wq&lt;/code&gt;, exiting vim now.&#xA;Then a prompt will appear telling you that the file has been changed since you opened it, and if you really want to save it or no.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you say to save it anyway, result is that you'll lose all the stuff you wrote in the file in Terminal B, because Terminal A never &quot;saw&quot; it.&lt;/p&gt;&#xA;" OwnerUserId="12916" LastEditorUserId="12916" LastEditDate="2017-06-06T00:44:50.110" LastActivityDate="2017-06-06T00:44:50.110" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12568" PostTypeId="2" ParentId="12550" CreationDate="2017-06-06T00:05:06.253" Score="1" Body="&lt;p&gt;Vim includes a feature called &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;quickfix&lt;/code&gt;&lt;/a&gt; that consists of a way of compiling source code using an external program and processing its output. Any failures are loaded as an iterable list into the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix-window&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;quickfix-window&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also check the vim help pages for &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#errorformat&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;errorformat&lt;/code&gt;&lt;/a&gt;, which defines filtering expressions to identify error messages in the output of &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27makeprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'makeprg'&lt;/code&gt;&lt;/a&gt; (the option that determines what external program is used to process the code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, simply install &lt;a href=&quot;https://github.com/vim-syntastic/syntastic&quot; rel=&quot;nofollow noreferrer&quot;&gt;Syntastic&lt;/a&gt;. I can see a reference to Closure Compiler &lt;a href=&quot;https://github.com/vim-syntastic/syntastic/blob/master/doc/syntastic-checkers.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, so it should be supported.&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="599" LastEditDate="2017-06-25T00:21:11.940" LastActivityDate="2017-06-25T00:21:11.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12569" PostTypeId="2" ParentId="12377" CreationDate="2017-06-06T09:37:38.160" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/12378/343&quot;&gt;grodzik has already explained why this occurs&lt;/a&gt;, but I disagree with his suggested solution. As he explains, using his autocommand means that it will be impossible &lt;em&gt;ever&lt;/em&gt; to use the &lt;code&gt;perl&lt;/code&gt; file type. Even if you believe you will never want to view a Perl file, this still seems unnecessarily final.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A gentler solution is to just set the filetype directly for files with &lt;code&gt;.pl&lt;/code&gt; extensions. You can then still set the &lt;code&gt;perl&lt;/code&gt; filetype manually with the command &lt;code&gt;:set filetype=perl&lt;/code&gt; if necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Vim documentation describes how to do this in &lt;code&gt;:help new-filetype&lt;/code&gt;, section C. In short:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a file &lt;code&gt;~/.vim/filetype.vim&lt;/code&gt; with the contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; my filetype file&#xA;if exists(&quot;did_load_filetypes&quot;)&#xA;  finish&#xA;endif&#xA;augroup filetypedetect&#xA;  au! BufRead,BufNewFile *.pl setfiletype prolog&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-06-06T09:37:38.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12571" PostTypeId="1" AcceptedAnswerId="12575" CreationDate="2017-06-07T00:12:39.667" Score="5" ViewCount="417" Body="&lt;p&gt;Can I close all buffers by regex, for instance all buffers that hold open &lt;code&gt;.js&lt;/code&gt; files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Effectively what I want is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bd *.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But even with &lt;code&gt;!&lt;/code&gt; if more than one &lt;code&gt;.js&lt;/code&gt; is open I get,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E93: More than one match for *.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="5078" LastEditDate="2017-06-07T00:55:39.230" LastActivityDate="2021-09-03T22:13:32.477" Title="Closing all buffers that represent .js files?" Tags="|buffers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12572" PostTypeId="1" AcceptedAnswerId="12573" CreationDate="2017-06-07T02:43:01.387" Score="3" ViewCount="136" Body="&lt;p&gt;I know that the &lt;code&gt;:oldfiles&lt;/code&gt; command will show you a history of the files you last had open; but how do I open the last n files in one command...for instance, say I want to open files 0-n in the &lt;code&gt;:oldfiles&lt;/code&gt; list, is there a way to do that?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2017-06-07T04:51:08.117" Title="How do I open the last n files I was working on in vim?" Tags="|filesystem|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12573" PostTypeId="2" ParentId="12572" CreationDate="2017-06-07T04:51:08.117" Score="4" Body="&lt;p&gt;The files listed by &lt;code&gt;:oldfiles&lt;/code&gt; are also available as a list in &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#v%3Aoldfiles&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;v:oldfiles&lt;/code&gt;&lt;/a&gt;, so something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for f in v:oldfiles[:10]&#xA;    exec &quot;badd&quot; f&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using an appropriate value instead of 10, of course.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-06-07T04:51:08.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12574" PostTypeId="2" ParentId="12571" CreationDate="2017-06-07T05:00:38.613" Score="0" Body="&lt;p&gt;You could probably use a function to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CloseByRegex(re)&#xA;    for b in range(1, bufnr('$'))&#xA;        if bufname(b) =~ re&#xA;            exec &quot;bd&quot; b&#xA;        endif&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;bufnr('$')&lt;/code&gt; is the number of the last buffer.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2017-06-07T05:09:50.843" LastActivityDate="2017-06-07T05:09:50.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12575" PostTypeId="2" ParentId="12571" CreationDate="2017-06-07T05:06:20.147" Score="9" Body="&lt;p&gt;Your question is answered on a &lt;a href=&quot;https://stackoverflow.com/questions/3155461/how-to-delete-multiple-buffers-in-vim&quot;&gt;duplicate&lt;/a&gt; from one on StackOverflow:&lt;/p&gt;&#xA;&lt;p&gt;Use &lt;code&gt;&amp;lt;C-A&amp;gt;&lt;/code&gt; to expand the &lt;code&gt;*.js&lt;/code&gt; on the command line.&lt;/p&gt;&#xA;&lt;p&gt;This way &lt;code&gt;:bd *.js&lt;/code&gt; will become &lt;code&gt;:bd file1.js file2.js file42.js&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My loop-free answer (in case more control is required) was:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! s:BDExt(ext)&#xA;  let buffers = filter(range(1, bufnr('$')), 'buflisted(v:val) &amp;amp;&amp;amp; bufname(v:val) =~ &amp;quot;\.'.a:ext.'$&amp;quot;')&#xA;  if empty(buffers) |throw &amp;quot;no *.&amp;quot;.a:ext.&amp;quot; buffer&amp;quot; | endif&#xA;  exe 'bd '.join(buffers, ' ')&#xA;endfunction&#xA;&#xA;command! -nargs=1 BDExt :call s:BDExt(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="488" LastEditDate="2021-09-03T22:13:32.477" LastActivityDate="2021-09-03T22:13:32.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12576" PostTypeId="1" AcceptedAnswerId="12581" CreationDate="2017-06-07T05:24:18.363" Score="3" ViewCount="2477" Body="&lt;p&gt;I want to swap &lt;code&gt;'&lt;/code&gt; with &lt;code&gt;`&lt;/code&gt; for all combinations of commands in normal mode.&#xA;I have tried the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ' `&#xA;nnoremap ` '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works for commands like &lt;code&gt;''&lt;/code&gt;, &lt;code&gt;``&lt;/code&gt;, but failed for &lt;code&gt;d''&lt;/code&gt;, &lt;code&gt;y''&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;related question:&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/9591/map-jump-to-mark-line-to-jump-to-mark-position&quot;&gt;Map &amp;#39;Jump to mark line&amp;#39; to &amp;#39;Jump to mark position&amp;#39;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12932" LastEditorUserId="205" LastEditDate="2017-06-07T06:09:41.283" LastActivityDate="2017-06-08T12:05:04.543" Title="how to remap backtick mark with single-quote mark globally" Tags="|key-bindings|cursor-motions|mark|" AnswerCount="1" CommentCount="0" ClosedDate="2017-06-08T12:48:02.547" ContentLicense="CC BY-SA 3.0" />
  <row Id="12577" PostTypeId="2" ParentId="6171" CreationDate="2017-06-07T17:08:43.427" Score="1" Body="&lt;p&gt;I tried to figure this out and it turned out that using the below syntax works well for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;&quot;\UE000&quot;&lt;/code&gt; not &lt;code&gt;&quot;U+E000&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: after importing and generating the font, restart your terminal and Vim. Just so you know use the font that you are using for your terminal.&lt;/p&gt;&#xA;" OwnerUserId="12945" LastEditorUserId="2736" LastEditDate="2017-06-08T17:55:04.790" LastActivityDate="2017-06-08T17:55:04.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12578" PostTypeId="1" AcceptedAnswerId="12580" CreationDate="2017-06-07T18:49:09.033" Score="7" ViewCount="322" Body="&lt;p&gt;I want to use the spelling rule: &lt;code&gt;begin first word in a sentence with capital letter&lt;/code&gt;, but Vim faultily recognises the end of a sentence when I use shortcuts that end with a dot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem exists only with my native language. When using &lt;code&gt;en_gb&lt;/code&gt; this sentence is correct:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;He likes many pets, e.g. cats.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the Polish version is not correct (when using &lt;code&gt;pl&lt;/code&gt; as the spelling language):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;On lubi różne zwierzęta, np. koty.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The word &lt;code&gt;koty&lt;/code&gt; is marked with the capital letter error. Vim thinks that the dot that belongs to the shortcut &lt;code&gt;np.&lt;/code&gt; marks the end of sentence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to modify the &lt;code&gt;spellcapcheck&lt;/code&gt; setting by adding the &lt;code&gt;negative look behind&lt;/code&gt; to the regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set spellcapcheck=(?&amp;lt;!np)[.?!]\_[\])'&quot; \t]\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This modification broke the rule entirely (Vim stopped showing capital letter error everywhere). Maybe my regex is not correct. But I also think I look at the wrong place to configure it, as the &lt;code&gt;spellcapcheck&lt;/code&gt; setting is not modified when the I set &lt;code&gt;en_gb&lt;/code&gt; on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set spellcapcheck?&#xA;spellcapcheck=[.?!]\_[\])'&quot;^I ]\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10884" LastActivityDate="2017-06-08T08:25:04.143" Title="Ignore capital letter rule when word is preceded by a shortcut" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12579" PostTypeId="1" AcceptedAnswerId="12596" CreationDate="2017-06-08T08:24:18.070" Score="9" ViewCount="12330" Body="&lt;p&gt;I'm trying to switch from Gvim to Neovim. Most tutorials are about Linux and not how to setup Neovim on MS Windows?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Installing-Neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;document&lt;/a&gt; it's &lt;code&gt;%userprofile%\AppData\Local\nvim\init.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't want to put the vimrc file on C:\, it would be formatted when reinstalling the system. The old Gvim 8.0 can use a &lt;code&gt;.vimrc&lt;/code&gt; in the same directory. Does Neovim support this?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;vimfiles&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my previous directory structure looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; d:\vim\  &#xA;       |--- vim80\&#xA;            | --- gvim.exe&#xA;            | --- ...&#xA;       |--- vimfiles\    &amp;lt;--- where to put this folder now?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where do I have to put the &lt;code&gt;vimfiles&lt;/code&gt; folder for Neovim? I can't find any tutorial about this. From the &lt;code&gt;:h nvim-from-vim&lt;/code&gt;, there are some directories which I tried without any luck.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;~/vimfiles&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;~/.vim/vimfiles&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;~/AppData/vimfiles&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;~/AppData/Local/vimfiles&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;~/AppData/Local/nvim/vimfiles&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;~/AppData/Local/nvim-data/vimfiles&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6971" LastEditorUserId="1292" LastEditDate="2018-08-30T10:37:35.030" LastActivityDate="2018-08-30T10:37:35.030" Title="Neovim setup on MS Windows" Tags="|neovim|microsoft-windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12580" PostTypeId="2" ParentId="12578" CreationDate="2017-06-08T08:25:04.143" Score="7" Body="&lt;p&gt;I found the solution. You need to add the shortcut to the dictionary, including the dot. So I expect that in case of &lt;code&gt;en_gb&lt;/code&gt; the word &lt;code&gt;e.g.&lt;/code&gt; is included in the default dictionary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, you cannot use &lt;code&gt;zg&lt;/code&gt; to add the shortcut to the dictionary, because in this case only &lt;code&gt;np&lt;/code&gt; will be added, not &lt;code&gt;np.&lt;/code&gt;. You need to add the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;np.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the &lt;code&gt;$HOME/.vim/spell/pl.utf-8.add&lt;/code&gt; file manually. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please mind that the change will not take affect until the binary file &lt;code&gt;$HOME/.vim/spell/pl.utf-8.add.spl&lt;/code&gt; is recompiled. You can trigger its recompilation by adding another word to the dictionary, this time from Vim, using &lt;code&gt;zg&lt;/code&gt; (I don't know another way to do this). It does not have to be a word unknown to the default dictionary.&lt;/p&gt;&#xA;" OwnerUserId="10884" LastActivityDate="2017-06-08T08:25:04.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12581" PostTypeId="2" ParentId="12576" CreationDate="2017-06-08T12:05:04.543" Score="3" Body="&lt;p&gt;You used &lt;code&gt;nnoremap&lt;/code&gt; which means the mapping will only work in normal mode. &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; leave you in operator pending mode. Adding the following should solve these cases:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap ' `&#xA;onoremap ` '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not entirely sure whether this will have any undesired side effects though.&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2017-06-08T12:05:04.543" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12582" PostTypeId="2" ParentId="12558" CreationDate="2017-06-08T12:24:55.483" Score="1" Body="&lt;p&gt;As @Wolfie said, there is no way to make the 81st column look pretty. Personally I color column 81 and up. This looks decent and does not distract me too much. Try it with the following statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let &amp;amp;colorcolumn=join(range(81,999), ',')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2017-06-08T12:24:55.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12583" PostTypeId="2" ParentId="12579" CreationDate="2017-06-08T12:54:18.707" Score="6" Body="&lt;p&gt;Following the instructions in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h nvim-from-vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;may give you some ideas. For example, it details the new $XDG_CONFIG_HOME system of config management.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's worth considering putting your vim config files on github (other cloud services are available).  You'll never again worry about forgetting to update other vim installations with changes to your config.  &lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastEditorDisplayName="user859" LastEditDate="2017-06-08T13:21:47.783" LastActivityDate="2017-06-08T13:21:47.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12586" PostTypeId="1" CreationDate="2017-06-08T15:07:50.127" Score="2" ViewCount="297" Body="&lt;p&gt;I'm working on a large scale project with a lot of files, and &lt;code&gt;:find&lt;/code&gt; is extremely (several seconds) slow, much slower than &lt;code&gt;:lgrep&lt;/code&gt; backed by &lt;code&gt;ag&lt;/code&gt;, which skips directories mentioned in &lt;code&gt;.gitignore&lt;/code&gt;, e.g. &lt;code&gt;tmp&lt;/code&gt;, &lt;code&gt;log&lt;/code&gt;, &lt;code&gt;node_modules&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment I'm using &lt;code&gt;set path=.,**&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way exclude specific paths from &lt;code&gt;path&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any trick with &lt;code&gt;autocmd&lt;/code&gt; loading &lt;code&gt;.gitignore&lt;/code&gt; and setting &lt;code&gt;path&lt;/code&gt; on  &lt;code&gt;VimEnter&lt;/code&gt; will work.&lt;/p&gt;&#xA;" OwnerUserId="8699" LastActivityDate="2017-09-06T19:38:33.433" Title="Exclude some paths from :find path" Tags="|find|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12587" PostTypeId="1" CreationDate="2017-06-08T16:08:03.703" Score="2" ViewCount="175" Body="&lt;p&gt;While browsing &lt;code&gt;index.txt&lt;/code&gt; looking for space to fit some custom keymappings, I noticed something.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^       - First CHAR of current line&#xA;N-      - First CHAR N lines higher&#xA;N_      - First CHAR N-1 lines lower&#xA;N+      - First CHAR N lines lower&#xA;N&amp;lt;CR&amp;gt;   - First CHAR N lines lower&#xA;N$      - End of line N-1 lines lower&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why the inconsistencies here, and the lack of coverage? &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt; takes a number, while &lt;code&gt;^&lt;/code&gt; doesn't.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;_&lt;/code&gt; without a number is seemingly the same as &lt;code&gt;^&lt;/code&gt;, making &lt;code&gt;^&lt;/code&gt; redundant.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; and &lt;code&gt;+&lt;/code&gt; do the same thing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Why isn't it something more along the lines of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;N-      - First CHAR N lines higher&#xA;N^      - First CHAR N-1 lines lower&#xA;&amp;lt;CR&amp;gt;    - First CHAR N lines lower&#xA;&#xA;N+      - End of line N lines higher&#xA;N$      - End of line N-1 lines lower&#xA;N_      - End of line N lines lower&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vi backwards compatibility? &lt;/li&gt;&#xA;&lt;li&gt;implementation details, something regarding count/motions, or how vim reads input?&lt;/li&gt;&#xA;&lt;li&gt;antiquated keyboard layouts?&lt;/li&gt;&#xA;&lt;li&gt;I overlooked some default mappings?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="12960" LastActivityDate="2017-06-08T16:08:03.703" Title="Why are the vim line wise movement commands inconsistent?" Tags="|key-bindings|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12588" PostTypeId="2" ParentId="12586" CreationDate="2017-06-08T18:04:03.683" Score="3" Body="&lt;p&gt;&lt;code&gt;vim-rails&lt;/code&gt; and &lt;code&gt;vim-ruby&lt;/code&gt; are setting &lt;code&gt;path&lt;/code&gt;, and they don't really care that &lt;code&gt;path&lt;/code&gt; is limited to 1024 characters on some platforms throwing out what you set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solved with &lt;code&gt;autocmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:project_find_path = '.,' . system(&quot;git ls-tree -d HEAD --name-only | tr '\n' : | sed 's/:/**,/g'&quot;)&#xA;autocmd VimEnter let &amp;amp;path = g:project_find_path&#xA;autocmd BufReadPost * let &amp;amp;path = g:project_find_path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works in fractions of a second now.&lt;/p&gt;&#xA;" OwnerUserId="8699" LastActivityDate="2017-06-08T18:04:03.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12589" PostTypeId="2" ParentId="573" CreationDate="2017-06-08T22:33:15.967" Score="2" Body="&lt;p&gt;Fenrir does read cursor movements with j. if a j appears on the screen this is  handled as well. but still you should turn off the ruler. &#xA;Currently it just runs on linux. but this is just by the fact that i did not finish other drivers and will change in near future after bringing fenrir to an multiprocess  architecture. &#xA;&lt;a href=&quot;https://linux-a11y.org/index.php?page=fenrir-screenreader&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://linux-a11y.org/index.php?page=fenrir-screenreader&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;cheers chrys&lt;/p&gt;&#xA;" OwnerUserId="12969" LastActivityDate="2017-06-08T22:33:15.967" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12590" PostTypeId="2" ParentId="11210" CreationDate="2017-06-09T03:42:33.190" Score="11" Body="&lt;p&gt;Give this a try. It remaps &lt;code&gt;@&lt;/code&gt; so that &lt;code&gt;g@&lt;/code&gt; (plus a dummy motion &lt;code&gt;l&lt;/code&gt;) is used afterwards, thus becoming the last operator and subject to repeating with &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; When . repeats g@, repeat the last macro.&#xA;fun! AtRepeat(_)&#xA;    &quot; If no count is supplied use the one saved in s:atcount.&#xA;    &quot; Otherwise save the new count in s:atcount, so it will be&#xA;    &quot; applied to repeats.&#xA;    let s:atcount = v:count ? v:count : s:atcount&#xA;    &quot; feedkeys() rather than :normal allows finishing in Insert&#xA;    &quot; mode, should the macro do that. @@ is remapped, so 'opfunc'&#xA;    &quot; will be correct, even if the macro changes it.&#xA;    call feedkeys(s:atcount.'@@')&#xA;endfun&#xA;&#xA;fun! AtSetRepeat(_)&#xA;    set opfunc=AtRepeat&#xA;endfun&#xA;&#xA;&quot; Called by g@ being invoked directly for the first time. Sets&#xA;&quot; 'opfunc' ready for repeats with . by calling AtSetRepeat().&#xA;fun! AtInit()&#xA;    &quot; Make sure setting 'opfunc' happens here, after initial playback&#xA;    &quot; of the macro recording, in case 'opfunc' is set there.&#xA;    set opfunc=AtSetRepeat&#xA;    return 'g@l'&#xA;endfun&#xA;&#xA;&quot; Enable calling a function within the mapping for @&#xA;nno &amp;lt;expr&amp;gt; &amp;lt;plug&amp;gt;@init AtInit()&#xA;&quot; A macro could, albeit unusually, end in Insert mode.&#xA;ino &amp;lt;expr&amp;gt; &amp;lt;plug&amp;gt;@init &quot;\&amp;lt;c-o&amp;gt;&quot;.AtInit()&#xA;&#xA;fun! AtReg()&#xA;    let s:atcount = v:count1&#xA;    let c = nr2char(getchar())&#xA;    return '@'.c.&quot;\&amp;lt;plug&amp;gt;@init&quot;&#xA;endfun&#xA;&#xA;nmap &amp;lt;expr&amp;gt; @ AtReg()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried to handle as many corner cases as I can think of. You can&#xA;repeat &lt;code&gt;@:&lt;/code&gt; with &lt;code&gt;.&lt;/code&gt;. Counts to &lt;code&gt;@&lt;/code&gt; or &lt;code&gt;.&lt;/code&gt; are retained for subsequent&#xA;presses of &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is tricky, and I'm not convinced that something won't break&#xA;somewhere along the way. So no guarantees, warranties, or promises with&#xA;this one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I'm okay having a difference between the fine-grained&#xA;repeats of &lt;code&gt;.&lt;/code&gt; for the last change, and the macro repeats of &lt;code&gt;@@&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured, having gone this far, that I may as well add some additional code that will allow pressing &lt;code&gt;.&lt;/code&gt; immediately&#xA;after recording a macro to play it back.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! QRepeat(_)&#xA;    call feedkeys('@'.s:qreg)&#xA;endfun&#xA;&#xA;fun! QSetRepeat(_)&#xA;    set opfunc=QRepeat&#xA;endfun&#xA;&#xA;fun! QStop()&#xA;    set opfunc=QSetRepeat&#xA;    return 'g@l'&#xA;endfun&#xA;&#xA;nno &amp;lt;expr&amp;gt; &amp;lt;plug&amp;gt;qstop QStop()&#xA;ino &amp;lt;expr&amp;gt; &amp;lt;plug&amp;gt;qstop &quot;\&amp;lt;c-o&amp;gt;&quot;.QStop()&#xA;&#xA;let s:qrec = 0&#xA;fun! QStart()&#xA;    if s:qrec == 1&#xA;        let s:qrec = 0&#xA;        return &quot;q\&amp;lt;plug&amp;gt;qstop&quot;&#xA;    endif&#xA;    let s:qreg = nr2char(getchar())&#xA;    if s:qreg =~# '[0-9a-zA-Z&quot;]'&#xA;        let s:qrec = 1&#xA;    endif&#xA;    return 'q'.s:qreg&#xA;endfun&#xA;&#xA;nmap &amp;lt;expr&amp;gt; q QStart()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2017-06-12T13:39:50.323" LastActivityDate="2017-06-12T13:39:50.323" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12591" PostTypeId="1" AcceptedAnswerId="12592" CreationDate="2017-06-09T08:10:28.043" Score="2" ViewCount="260" Body="&lt;p&gt;I  am trying to create a vimL script where, among other things, I need to copy the text between two markers such as in &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'a,'by&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however, I want to copy between columns of the marker positions (characterwise). I have read several times I can use backticks as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:`a,`by&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But is returning &quot;Not an editor command&quot;. Even simple&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;returns &quot;Not an editor command&quot;, although &lt;code&gt;:'&lt;/code&gt; goes to the correct line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing anything?&lt;/p&gt;&#xA;" OwnerUserId="11944" LastActivityDate="2017-06-09T09:34:36.633" Title="backtick marker navigation &quot;not an editor command&quot;" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12592" PostTypeId="2" ParentId="12591" CreationDate="2017-06-09T09:34:36.633" Score="2" Body="&lt;p&gt;Yes, ex-commands always work linewise. There is an open issue in the todo list about it, however until now it has never been implemented. For &lt;code&gt;:s&lt;/code&gt; command you can make use of the &lt;code&gt;/%V&lt;/code&gt; and &lt;code&gt;/\%c&lt;/code&gt; regex atom to make sure it matches within a certain area. Other ex commands don't work on columns. In that case, simple use the normal mode command. That should work without problems.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-06-09T09:34:36.633" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12593" PostTypeId="1" CreationDate="2017-06-09T09:53:22.170" Score="0" ViewCount="243" Body="&lt;p&gt;How can Vim be configured to &lt;strong&gt;automatically centre&lt;/strong&gt; a specified line number (eg. without manually having to use the &lt;code&gt;zz&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So from the commandline I just want to issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim verylongfile.c +932&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and as soon as the file opens, the line is visible in the centre of the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I remember (fondly) this being a default setting on Fedora Core 4's shipped copy of vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my work PC, vim does it the way I want by default.  At home, my vim tends to put the line at the bottom of the screen, which gets annoying when wanting to view code and the context around it while flipping between files a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both machines have the same .vimrc file in the user's home directory.  Bothe systems have recent versions of vim (from up-to-date apt and yum repositories).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a magic incantation I can add to the .vimrc to for this apparently optional behaviour all the time by default?&lt;/p&gt;&#xA;" OwnerUserId="6461" LastEditorUserId="6461" LastEditDate="2017-06-09T12:44:00.480" LastActivityDate="2017-06-09T12:44:00.480" Title="Open file at specified line number and automatically put that line in the middle of the screen?" Tags="|vimrc|linux|line-numbers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12594" PostTypeId="2" ParentId="12593" CreationDate="2017-06-09T11:42:56.797" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a magic incantation I can add to the .vimrc?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Just add this to you vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Centrum Autem Gravitatis!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just kidding. ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter * normal! zz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will add an auto command that will execute &lt;code&gt;zz&lt;/code&gt; whenever vim enters a buffer.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-06-09T11:42:56.797" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12595" PostTypeId="2" ParentId="12593" CreationDate="2017-06-09T12:23:13.550" Score="1" Body="&lt;p&gt;I'm not sure why the default &lt;code&gt;+{num}&lt;/code&gt; isn't placing the line centre-screen on your home machine, but the &lt;code&gt;+&lt;/code&gt; command-line argument can also be used to run commands. Thus, the following invocation should do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim verylongfile.c +&quot;normal 932Gzz&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-06-09T12:23:13.550" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12596" PostTypeId="2" ParentId="12579" CreationDate="2017-06-09T14:52:32.360" Score="11" Body="&lt;p&gt;The user's runtime directory is &lt;code&gt;$XDG_CONFIG_HOME/nvim&lt;/code&gt;.  When &lt;code&gt;$XDG_CONFIG_HOME&lt;/code&gt; isn't set (which is the typical case), then the default directory is &lt;code&gt;~/AppData/Local&lt;/code&gt; on Windows and &lt;code&gt;~/.config&lt;/code&gt; elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OS         | Vim        | nvim&#xA;-----------|------------|---------------------&#xA;Windows    | ~/vimfiles | ~/AppData/Local/nvim&#xA;*nix/macOS | ~/.vim     | ~/.config/nvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help vimrc&lt;/code&gt;, &lt;code&gt;:help xdg&lt;/code&gt;, and &lt;code&gt;:help 'runtimepath'&lt;/code&gt; for more detailed information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you want to change where nvim's config is stored, then you should set &lt;code&gt;$XDG_CONFIG_HOME&lt;/code&gt; in your environment to where you want the &lt;code&gt;nvim&lt;/code&gt; directory to live.  If you wanted your nvim config to be at &lt;code&gt;D:\foo\nvim&lt;/code&gt;, you would set &lt;code&gt;$XDG_CONFIG_HOME&lt;/code&gt; to &lt;code&gt;D:\foo&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-06-09T14:52:32.360" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12597" PostTypeId="1" CreationDate="2017-06-09T15:58:49.200" Score="4" ViewCount="1169" Body="&lt;p&gt;Is it possible to setup vim to open all preview windows on a specific location. I want them to open on the right side.&lt;/p&gt;&#xA;" OwnerUserId="10265" LastActivityDate="2017-07-09T19:44:06.733" Title="A fixed position for preview windows" Tags="|vim-windows|split|previewing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12598" PostTypeId="2" ParentId="12597" CreationDate="2017-06-09T18:36:42.063" Score="1" Body="&lt;p&gt;You could try adding the following to your &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimrc&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup previewWindowPosition&#xA;   au!&#xA;   autocmd BufWinEnter * call PreviewWindowPosition()&#xA;augroup END&#xA;function! PreviewWindowPosition()&#xA;   if &amp;amp;previewwindow&#xA;      wincmd L&#xA;   endif&#xA;endfunction    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3awincmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:wincmd&lt;/code&gt;&lt;/a&gt; allows you to use the functionality available in normal mode in the &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt;. And &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#CTRL%2dW_L&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;CTRL-W_L&lt;/code&gt;&lt;/a&gt; moves the current window to the far right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately it is not possible to set the preview window size from the quickfix file type plugin -- probably because the cursor doesn't stay on that window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This approach will trigger for every window (see &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#BufWinEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;BufWinEnter&lt;/code&gt;&lt;/a&gt;), thus it will add a little overhead.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2017-06-09T19:24:39.967" LastActivityDate="2017-06-09T19:24:39.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12599" PostTypeId="1" AcceptedAnswerId="12600" CreationDate="2017-06-09T20:43:01.967" Score="3" ViewCount="136" Body="&lt;p&gt;I'm attempting to add some debugging functionality to a small vim plugin that I am working on. I'd like to wrap &lt;code&gt;echo&lt;/code&gt; / &lt;code&gt;echom&lt;/code&gt; in a way that allows me to turn off output if I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've attempted to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:log(...)&#xA;  if (get(g:, 'my_plugin_debug_setting', 0))&#xA;    echom a:000&#xA;  end&#xA;endfunction&#xA;&#xA;:call s:log('Debugging information')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that just logs the list &lt;code&gt;['Debugging information']&lt;/code&gt; (which makes sense, since i've just done the equivalent of &lt;code&gt;echo ['foo']&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also attempted to use &lt;code&gt;call&lt;/code&gt;: &lt;code&gt;:call call('echo', a:000)&lt;/code&gt; but this doesn't work because echo is not a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do what I want?&lt;/p&gt;&#xA;" OwnerUserId="12886" LastActivityDate="2017-06-09T23:16:32.767" Title="Wrapping echo for use in VimL" Tags="|plugin-system|echo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12600" PostTypeId="2" ParentId="12599" CreationDate="2017-06-09T21:28:44.263" Score="1" Body="&lt;p&gt;In my lh-vim-lib library plugin I provide a &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/Log.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;framework for logging&lt;/a&gt; (among many other things) .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unlike other frameworks (like maktaba) I don't try support several modes (error, warning, info, debug). Instead, I can choose to enable logs independently on each autoload plugin. Then, I can chose where the logs go (&lt;code&gt;:messages&lt;/code&gt;, quickfix/loclist window, file, nowhere).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you could have used &lt;code&gt;:echom string(a:000)&lt;/code&gt;, or even &lt;code&gt;join(a:000, ', ')&lt;/code&gt; as long as the list only contains strings -- I had to do some recursive voodoo magic to obtain a nice result on any type of variables in my library.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-06-09T23:16:32.767" LastActivityDate="2017-06-09T23:16:32.767" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12601" PostTypeId="2" ParentId="12436" CreationDate="2017-06-10T05:46:19.883" Score="2" Body="&lt;p&gt;You need to globally associate a filename extension with a setting for the 'filetype' option when the file is opened. There are a few ways to do this. One way is described by @Naumann in another answer. Let's look at two other ways. These don't involve your vimrc file and are the recommended approaches per &lt;code&gt;:help new-filetype&lt;/code&gt; (which I encourage you to read!)&lt;/p&gt;&#xA;&lt;p&gt;With the first option you create a file, let's call it &lt;code&gt;perlmako.vim&lt;/code&gt;, in &lt;code&gt;~/.vim/ftdetect&lt;/code&gt; (Unix) or &lt;code&gt;$USERPROFILE\vimfiles\ftdetect&lt;/code&gt; (Win) and add a line like either of these:&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Method A:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.pl.mako set filetype=perl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;em&gt;Method B:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.pl.mako setfiletype perl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The difference between the two is that Method A always overrides the filetype while Method B only works if no filetype has been detected yet for that extension.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For the second option, create a file named &lt;code&gt;filetype.vim&lt;/code&gt; in &lt;code&gt;~/.vim&lt;/code&gt; (Unix) or &lt;code&gt;$USERPROFILE\vimfiles&lt;/code&gt; (Win). Then add the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&amp;quot;did_load_filetypes&amp;quot;)&#xA;    finish&#xA;endif&#xA;augroup filetypedetect&#xA;    au! BufRead,BufNewFile *.pl.mako setfiletype perl&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can add multiple &lt;code&gt;setfiletype&lt;/code&gt; lines for whatever extensions you want. One important point about this method from Vim help:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Your filetype.vim will be sourced before the default FileType&#xA;autocommands have been installed. Your autocommands will match first,&#xA;and the &amp;quot;:setfiletype&amp;quot; command will make sure that no other&#xA;autocommands will set 'filetype' after this.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2022-12-06T05:32:48.063" LastActivityDate="2022-12-06T05:32:48.063" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12602" PostTypeId="1" CreationDate="2017-06-10T16:55:04.987" Score="7" ViewCount="6058" Body="&lt;p&gt;Is there a command to paste (&lt;code&gt;p&lt;/code&gt;) text with space inserted before that text like in &lt;code&gt;join&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to achieve that by mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally &lt;kbd&gt;p&lt;/kbd&gt; pastes text right &lt;strong&gt;in&lt;/strong&gt; the cursor's position in Normal Mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Switching modes, and inserting space manually everytime can be frustrating.&lt;/p&gt;&#xA;" OwnerDisplayName="user10767" LastActivityDate="2019-08-13T21:27:39.817" Title="Paste with space inserted before text" Tags="|cut-copy-paste|normal-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12603" PostTypeId="1" CreationDate="2017-06-10T19:04:28.247" Score="1" ViewCount="186" Body="&lt;p&gt;I want to separate my Vim Plugins to a separated file since I using more plugins in my &lt;code&gt;.vimrc&lt;/code&gt; file. it this possible?&lt;/p&gt;&#xA;" OwnerUserId="12945" LastActivityDate="2017-06-12T07:09:57.727" Title="Moving Vim Plugins to a separated file" Tags="|vimrc|vimscript|macvim|" AnswerCount="2" CommentCount="1" ClosedDate="2017-06-13T13:17:11.447" ContentLicense="CC BY-SA 3.0" />
  <row Id="12604" PostTypeId="2" ParentId="11977" CreationDate="2017-06-10T20:32:21.833" Score="1" Body="&lt;p&gt;There's also a handy plugin for that :  &lt;a href=&quot;https://github.com/gorkunov/smartpairs.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;smartpairs&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;hit &lt;code&gt;vav&lt;/code&gt; to select surroundings matching &lt;code&gt;'&lt;/code&gt; / &lt;code&gt;&quot;&lt;/code&gt; / &lt;code&gt;(&lt;/code&gt; / &lt;code&gt;{&lt;/code&gt; / tags etc.&lt;/li&gt;&#xA;&lt;li&gt;expand your selection by typing &lt;code&gt;vav&lt;/code&gt; again&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4542" LastActivityDate="2017-06-10T20:32:21.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12605" PostTypeId="2" ParentId="2286" CreationDate="2017-06-11T09:01:37.283" Score="5" Body="&lt;p&gt;I'd like to add that in normal mode, the &lt;code&gt;|&lt;/code&gt; command (which has to be substituted with &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt;, &lt;code&gt;\|&lt;/code&gt; or &lt;code&gt;^V|&lt;/code&gt; while remapping it, as mentioned in other answers) allows you to go to a specific screen column in the current line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, typing &lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;|&lt;/kbd&gt; will go to screen column 5, as in the image below:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/C7m4v.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/C7m4v.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's what the &lt;code&gt;|&lt;/code&gt; means by default in vim.&lt;/p&gt;&#xA;" OwnerUserId="12992" LastEditorUserId="205" LastEditDate="2017-06-11T14:04:55.280" LastActivityDate="2017-06-11T14:04:55.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12606" PostTypeId="2" ParentId="12603" CreationDate="2017-06-11T10:31:49.630" Score="0" Body="&lt;p&gt;&lt;code&gt;source&lt;/code&gt; command can do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can separate files, and source them in the main file ( vimrc )&lt;/p&gt;&#xA;" OwnerUserId="2514" LastActivityDate="2017-06-11T10:31:49.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12607" PostTypeId="1" AcceptedAnswerId="12612" CreationDate="2017-06-11T12:27:39.927" Score="14" ViewCount="2571" Body="&lt;p&gt;In the visual mode the &lt;kbd&gt;$&lt;/kbd&gt; extends selection until the end of the line including the new line character at the end, so I need to press an additional &lt;kbd&gt;h&lt;/kbd&gt; to exclud the new line character.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it possible to extend the visual selection until the last character on the line (excluding the new line character) easier as with &lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt;?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Are there some &lt;code&gt;set&lt;/code&gt; options controlling the behavior of the &lt;kbd&gt;$&lt;/kbd&gt;?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Bonus question: Is it possible to extend the selection (or jump) to the last non-whitespace character on the line?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3230" LastEditorUserId="3168" LastEditDate="2023-02-12T23:01:09.103" LastActivityDate="2023-02-12T23:01:09.103" Title="Extend visual selection until the last character on the line (excluding the new line character)" Tags="|cursor-movement|visual-mode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="12608" PostTypeId="1" AcceptedAnswerId="12609" CreationDate="2017-06-11T18:15:06.353" Score="4" ViewCount="722" Body="&lt;p&gt;Actually it may be offtopic, but I believe that vim users know the answer.&#xA;Earlier, in the proccess of using linux through years, I had noticed that some config files have something like &quot;vim comment&quot; in the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: ft-conf:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(It is from grub-legacy cfg file)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And much more commands in different config files.&#xA;Is it related to vim? And if so, which way?&lt;/p&gt;&#xA;" OwnerUserId="12349" LastActivityDate="2017-06-11T19:57:39.113" Title="vim command/comment in the end of config files" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12609" PostTypeId="2" ParentId="12608" CreationDate="2017-06-11T19:57:39.113" Score="7" Body="&lt;p&gt;This is called a modeline. It is used to define file specific settings. For more info, see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#auto-setting&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h auto-setting&lt;/code&gt;&lt;/a&gt; and the following parts about modelines. &lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-06-11T19:57:39.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12611" PostTypeId="2" ParentId="12603" CreationDate="2017-06-12T07:09:57.727" Score="0" Body="&lt;p&gt;I'm not sure to correctly understand your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually when the &lt;code&gt;.vimrc&lt;/code&gt; contains more and more functions, mappings, commands, abbreviations and so on, we split it into several files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the definitions should apply to any type of buffer (/file), they go in a vim script stored under &lt;code&gt;~/.vim/plugin/&lt;/code&gt; (I simplify, read &lt;code&gt;:h 'rtp'&lt;/code&gt; for more information).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the definitions are specifics to a type of buffer (/file), they go in filetype plugins, stored under &lt;code&gt;~/.vim/ftplugin/{filetype}/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Functions are best stored in autoload plugins. Syntax definitions in ~/.vim/syntax/` and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm quite sure I've already explained that somewhere. May be it was on SO, I don't remember.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-06-12T07:09:57.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12612" PostTypeId="2" ParentId="12607" CreationDate="2017-06-12T16:42:15.053" Score="12" Body="&lt;p&gt;Your first and third points are answered by &lt;code&gt;g_&lt;/code&gt;, which moves to the last non-whitespace character on the line. So, &lt;code&gt;vg_&lt;/code&gt; will visual select to the end of the line, excluding any whitespace and the newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no option to control the behavior of &lt;code&gt;$&lt;/code&gt; here, as far as I know. However, you can remap it in your &lt;code&gt;.vimrc&lt;/code&gt; if you prefer a different behavior:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap $ $h  &quot; if you prefer including trailing whitespace by default&#xA;vnoremap $ g_  &quot; if you prefer excluding trailing whitespace by default&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="88" LastActivityDate="2017-06-12T16:42:15.053" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12613" PostTypeId="1" AcceptedAnswerId="12622" CreationDate="2017-06-12T18:40:08.487" Score="4" ViewCount="4338" Body="&lt;p&gt;In my file containing LaTeX source code, I wish to comment out all the lines matching a pattern (specifically, the pattern that I am interested in is &lt;code&gt;\draw&lt;/code&gt;, including the &lt;code&gt;\&lt;/code&gt; character).&lt;/p&gt;&#xA;&lt;p&gt;I have &lt;code&gt;magic&lt;/code&gt; mode enabled.  I think a potential solution would be to use the &lt;code&gt;global&lt;/code&gt; command i.e. something along the lines of&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:g/\\draw/command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am unsure of the &lt;code&gt;command&lt;/code&gt; that achieves my task. I would like to seek your help through either of the methods below:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I have Tim Pope's &lt;code&gt;commentary&lt;/code&gt; plugin which provides the &lt;code&gt;gc&lt;/code&gt; mapping, which works in normal mode. However, this does not work in &lt;code&gt;ex&lt;/code&gt; mode.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Maybe use the normal mode &lt;code&gt;I&lt;/code&gt; command and use the comment character for LaTeX (the percent &lt;code&gt;%&lt;/code&gt; character) on those lines matched by the global command.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Please let me know if a simpler alternative exists in addition to the ones mentioned above, I am of course glad to learn about it too!&lt;/p&gt;&#xA;" OwnerUserId="8408" LastEditorUserId="30158" LastEditDate="2020-11-27T22:34:28.877" LastActivityDate="2020-11-28T02:12:04.287" Title="vim comment out every line of text containing a pattern using the 'global' command" Tags="|substitute|comments|global-command|plugin-vim-commentary|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12614" PostTypeId="1" AcceptedAnswerId="12617" CreationDate="2017-06-12T19:25:40.003" Score="2" ViewCount="956" Body="&lt;p&gt;Pressing &lt;kbd&gt;W&lt;/kbd&gt; (as in &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;w&lt;/kbd&gt;) when there is only one word in front of the cursor causes the cursor to immediately jump to the next line. This is unlike what happens when doing the reverse with &lt;kbd&gt;B&lt;/kbd&gt;, where the cursor stops at the beginning of the line before continuing to the previous line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to configure &lt;kbd&gt;W&lt;/kbd&gt; to act more like &lt;kbd&gt;B&lt;/kbd&gt;, in that it stops when it reaches the end of the line, then jumps to the next if pressed again?&lt;/p&gt;&#xA;" OwnerUserId="6079" LastEditorUserId="6489" LastEditDate="2017-06-12T19:36:54.547" LastActivityDate="2017-06-12T20:56:34.223" Title="Prevent W from jumping to next line" Tags="|cursor-movement|vi-words|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12615" PostTypeId="2" ParentId="12613" CreationDate="2017-06-12T19:33:42.857" Score="4" Body="&lt;p&gt;Try using &lt;code&gt;:g/\\draw/norm gcc&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;From &lt;code&gt;:help norm&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Execute Normal mode commands {commands}.  This makes      it possible&#xA;to execute Normal mode commands typed on the command-line.&#xA;{commands} are executed like they are typed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6079" LastEditorUserId="18609" LastEditDate="2020-11-28T02:12:04.287" LastActivityDate="2020-11-28T02:12:04.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12616" PostTypeId="2" ParentId="12602" CreationDate="2017-06-12T20:42:58.257" Score="4" Body="&lt;p&gt;Use &lt;code&gt;@p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Prerequisite: .vimrc needs to contain this line (add it):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let @p='i ^[p'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're saying: when I press &lt;code&gt;@p&lt;/code&gt; you &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;press &lt;code&gt;i&lt;/code&gt; for me so that you enter INSERT mode, then &lt;/li&gt;&#xA;&lt;li&gt;insert a space, then &lt;/li&gt;&#xA;&lt;li&gt;press ESC (&lt;code&gt;^[&lt;/code&gt; means ESC) to get back to NORMAL mode, then &lt;/li&gt;&#xA;&lt;li&gt;press &lt;code&gt;p&lt;/code&gt; to do the paste.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You're in NORMAL mode when it's done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In case you haven't worked with registers yet&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;p&lt;/code&gt; is a register. Think of a macro consisting of anything you could do with your hands using the basic vim commands, typing and switching modes included.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;q&lt;/code&gt; command to define register contents (the &lt;code&gt;recording&lt;/code&gt; status in the left bottom corner is for that).&lt;/p&gt;&#xA;" OwnerUserId="13008" LastActivityDate="2017-06-12T20:42:58.257" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12617" PostTypeId="2" ParentId="12614" CreationDate="2017-06-12T20:47:16.473" Score="2" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/12614/prevent-w-from-jumping-to-next-line#comment21820_12614&quot;&gt;Tumbler41 pointed out in the comments&lt;/a&gt;, the simpler solution would be to use &lt;kbd&gt;E&lt;/kbd&gt; instead of &lt;kbd&gt;W&lt;/kbd&gt;. However, if you would like to configure &lt;kbd&gt;W&lt;/kbd&gt; to behave this way, you could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; W getline('.')[col('.') - 1:] =~# '\s\S' ? 'W' : (col('.') + 1 == col('$') ? 'W' : '$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this solution is longer thank I'd like, and somewhat hacky, but it works. Here's a quick explanation of how it works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Use an 'expression mapping' on the key W. This means that we will evalue the&#xA;&quot;mapping as vimscript code to determine what keystrokes to press&#xA;nnoremap &amp;lt;expr&amp;gt; W&#xA;  &quot;Get everything after the cursors position&#xA;  getline('.')[col('.') - 1:]&#xA;  &quot;Does it contain a whitespace character followed by a non-whitespace character?&#xA;  =~# '\s\S'&#xA;  &quot;If it does, return 'W'&#xA;  ? 'W'&#xA;  &quot;Otherwise:&#xA;  :&#xA;    &quot;Are we on the last character?&#xA;    (col('.') + 1 == col('$')&#xA;    &quot;If we are. return 'W'&#xA;    ? 'W'&#xA;      &quot;Otherwise, return '$'&#xA;      : '$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2017-06-12T20:56:34.223" LastActivityDate="2017-06-12T20:56:34.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12618" PostTypeId="2" ParentId="12528" CreationDate="2017-06-13T02:57:16.103" Score="0" Body="&lt;p&gt;If you want to upgrade to Neovim, you can use &lt;code&gt;:term&lt;/code&gt;. It will open a new split that can run a terminal emulator. You can set up an alias in your &lt;code&gt;.vimrc&lt;/code&gt; so that it runs bash and thus has all of the basic commands that are native to a linux system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: Now as of vim 8 you can use a terminal emulator as well, so neovim isn't necessary.&lt;/p&gt;&#xA;" OwnerUserId="13009" LastEditorUserId="13009" LastEditDate="2017-09-12T16:59:17.067" LastActivityDate="2017-09-12T16:59:17.067" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12619" PostTypeId="1" CreationDate="2017-06-13T07:57:52.903" Score="0" ViewCount="295" Body="&lt;pre&gt;&lt;code&gt;&amp;lt;tspan x=&quot;0 0.54717 0.75472 1.32077 1.81134 2.35851 2.58493 3.13213.39625 3.96229 4.50947 &quot;&amp;gt;Lincoln 30%&amp;lt;/tspan&amp;gt;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to yank the text between the tspan tags 32 times in a XML document.  &lt;br&gt;&#xA;This is what I did: vsplit and enew to create a seperate window. &#xA;Key combination:&quot; vit and yy&quot; to select and copy text between tags.&#xA;Go to new window and paste and return to old window. This 32 times.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works but my question: do you know a more efficient way of doing this?&lt;/p&gt;&#xA;" OwnerUserId="5346" LastActivityDate="2017-06-13T10:57:13.803" Title="More efficient way of yanking text out of tags?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12620" PostTypeId="2" ParentId="12619" CreationDate="2017-06-13T09:01:36.357" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:vnew&lt;/code&gt; is more effcient than &lt;code&gt;:vsplit&lt;/code&gt; followed by &lt;code&gt;:enew&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;yit&lt;/code&gt; is more efficient than &lt;code&gt;vit&lt;/code&gt; followed by &lt;code&gt;y&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Okay I'm being facetious. Sorry. To actually answer your question, macros (&lt;code&gt;:help complex-repeats&lt;/code&gt;) can playback commands that move the cursor to other windows, so you can use them for this sort of task. You might need to tweak this to work with the contents of your file, but the basic steps are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/tspan&amp;lt;cr&amp;gt;&lt;/code&gt;: Search for the first tag.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f&amp;gt;l&lt;/code&gt;: Jump into the element contents.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt;: Start recording into the &lt;code&gt;q&lt;/code&gt; register.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yit&lt;/code&gt; : Yank the text.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ctrl-w w&lt;/code&gt;: Move cursor to your other window.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&amp;lt;cr&amp;gt;p&lt;/code&gt;: Paste the yanked text into a new line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ctrl-w p&lt;/code&gt;: Move cursor back into the first window.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt;: Jump to start of next tag.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: Stop recording and save the macro.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;You can then play the macro back 31 times with the command: &lt;code&gt;31@q&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You could probably also do it with a &lt;code&gt;:global&lt;/code&gt; command.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-06-13T10:57:13.803" LastActivityDate="2017-06-13T10:57:13.803" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12621" PostTypeId="1" AcceptedAnswerId="12629" CreationDate="2017-06-13T10:04:10.170" Score="2" ViewCount="128" Body="&lt;p&gt;I want to filter some text through an external command without replacing the text, but rather have some way of inserting it afterwards or wherever I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say I want to calculate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2^8 = &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I mark &lt;code&gt;2^8&lt;/code&gt; in visual mode and type &lt;code&gt;:! bc&lt;/code&gt;, this replaces &lt;code&gt;2^8&lt;/code&gt; with &lt;code&gt;256&lt;/code&gt;. However, I would rather just insert the result of the command after the &lt;code&gt;=&lt;/code&gt; sign. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="5410" LastActivityDate="2017-06-14T08:54:34.250" Title="Filter text and insert text after cursor or in register?" Tags="|visual-mode|external-command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12622" PostTypeId="2" ParentId="12613" CreationDate="2017-06-13T12:38:11.957" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;g/\\draw/s/^/%/&lt;/code&gt; to insert a percent sign at the start of every line containing the text &lt;code&gt;\draw&lt;/code&gt;. &lt;code&gt;s/^/%/&lt;/code&gt; means &lt;em&gt;replace the empty string at the start of the line with a percent sign&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to put the percent sign after any leading white space---which is more similar to how the normal command &lt;code&gt;I&lt;/code&gt; works---, use &lt;code&gt;g/\\draw/s/^\s*/&amp;amp;%/&lt;/code&gt; instead. &lt;code&gt;s/^\s*/&amp;amp;%/&lt;/code&gt; means &lt;em&gt;replace a possibly empty string of whitespace characters at the start of the line with the string itself, followed by a percent sign&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastActivityDate="2017-06-13T12:38:11.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12623" PostTypeId="2" ParentId="12621" CreationDate="2017-06-13T13:51:20.997" Score="1" Body="&lt;p&gt;What about &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(.*\)=\s*\zs$/\=system('bc -q &amp;lt;(echo '.shellescape(submatch(1)) . ')')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This replaces line-endings terminated with &lt;code&gt;=&lt;/code&gt; by &lt;code&gt;bc -q &amp;lt;(echo &quot;expression&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3asubstitute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :substitute&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub%2dreplace%2dspecial&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h sub-replace-special&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5czs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\zs&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#system%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h system()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#shellescape%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h shellescape()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-06-13T13:51:20.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12624" PostTypeId="2" ParentId="764" CreationDate="2017-06-13T13:51:22.827" Score="9" Body="&lt;p&gt;The easiest way I've found to split lines in Vim is the normal mode command &lt;code&gt;gq&lt;/code&gt; (type both letters in quick succession in normal or visual mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In visual mode, it will split whatever is selected, in normal mode, you follow &lt;code&gt;gq&lt;/code&gt; with a motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;code&gt;gql&lt;/code&gt; will split one line to the currently set width. To set the width of the split lines to be different from your current setting, you can use &lt;code&gt;:set textwidth=n&lt;/code&gt;, where &lt;code&gt;n&lt;/code&gt; is the number of characters you want in a line, e.g., &lt;code&gt;10&lt;/code&gt; and change back to your normal width when you're done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Got this information from a Youtube &lt;a href=&quot;https://youtu.be/MA9WFO_WUOM&quot; rel=&quot;noreferrer&quot;&gt;video&lt;/a&gt; by Kholidfu that shows how to join and split lines in normal mode using a motion.&lt;/p&gt;&#xA;" OwnerUserId="13018" LastEditorUserId="51" LastEditDate="2017-06-13T14:46:43.997" LastActivityDate="2017-06-13T14:46:43.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12625" PostTypeId="2" ParentId="10728" CreationDate="2017-06-13T14:17:37.227" Score="1" Body="&lt;p&gt;The easiest way I've found to split lines in Vim is the normal mode command &lt;code&gt;gq&lt;/code&gt; (type both letters in quick succession in normal or visual mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In visual mode, it will split whatever is selected, in normal mode, you follow &lt;code&gt;gq&lt;/code&gt; with a motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;code&gt;gql&lt;/code&gt; will split one line to the currently set width. To set the width of the split lines to be different from your current setting, you can use &lt;code&gt;:set textwidth=n&lt;/code&gt;, where &lt;code&gt;n&lt;/code&gt; is the number of characters you want in a line, e.g., &lt;code&gt;10&lt;/code&gt; and change back to your normal width when you're done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Got this information from a Youtube &lt;a href=&quot;https://youtu.be/MA9WFO_WUOM&quot; rel=&quot;nofollow noreferrer&quot;&gt;video&lt;/a&gt; by Kholidfu that shows how to join and split lines in normal mode using a motion.&lt;/p&gt;&#xA;" OwnerUserId="13018" LastEditorUserId="51" LastEditDate="2017-06-13T14:45:52.610" LastActivityDate="2017-06-13T14:45:52.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12626" PostTypeId="1" CreationDate="2017-06-13T20:56:09.390" Score="2" ViewCount="546" Body="&lt;p&gt;I asked a &lt;a href=&quot;https://unix.stackexchange.com/questions/370527/copy-a-block-of-text-to-a-specific-point-in-another-file&quot;&gt;question&lt;/a&gt; a few days ago in the Linux/Unix SE about how to copy a block of text from one file to another in a way that I could use for a script of many similar files. I thought I came up with a pretty simple solution, but I have run into a snag: my code seems to work only the first time I execute it. Any time after it won't seem to do. For an example, here is the gist of my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -c &quot;normal! 1gg19|^V48gg59|y&quot; -cq file1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This goes into file1, creates a visual block from the point (1,19) to (48,59) in the file, yanks it, and then closes the file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -c &quot;normal! 9gg21|p&quot; -cwq file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This goes into file2, moves the cursor to the point (9,21), pastes, and then closes the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run this once, it seems to work fine (minus any hiccups I cause by messing up the line numbers). But then if I run it again, neither line of code (in particular the first line) does anything. I have tried performing what each line of code is supposed to do in just plain vi, but then the other line will do nothing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One particular issue I've noticed is if I run the first line and then try to manually perform the second, I get an error message &quot;E353: Nothing in register&quot;&lt;/p&gt;&#xA;" OwnerUserId="13025" LastActivityDate="2017-06-18T08:45:53.187" Title="Issue with using ex commands" Tags="|command-line|cut-copy-paste|ex-mode|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12627" PostTypeId="1" AcceptedAnswerId="12628" CreationDate="2017-06-13T21:27:26.547" Score="0" ViewCount="438" Body="&lt;p&gt;What I want to do is jump to the first instance of character &amp;lt; X &gt; after the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already know &lt;a href=&quot;https://stackoverflow.com/questions/9402607/how-to-jump-to-a-specific-character-in-vim&quot;&gt;how to achieve this on the &lt;strong&gt;current line&lt;/strong&gt;&lt;/a&gt;, but I was wondering if there was a way to apply this to the whole buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize that this can be achieved using the search function &lt;code&gt;/&lt;/code&gt;, but that highlights all of the instances in the current buffer. Would I need to disable highlighting on the search in that case?&lt;/p&gt;&#xA;" OwnerUserId="3138" LastEditorUserId="3138" LastEditDate="2017-06-13T21:33:06.997" LastActivityDate="2017-06-13T21:38:53.313" Title="Jump to specific character after cursor" Tags="|buffers|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12628" PostTypeId="2" ParentId="12627" CreationDate="2017-06-13T21:30:44.980" Score="2" Body="&lt;p&gt;You can use the search feature to achieve this. I.e. if you wanted to find the first &lt;code&gt;f&lt;/code&gt; you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;followed by the enter key to confirm the search. You can use &lt;code&gt;:nohl&lt;/code&gt; to clear the highlighting once you've done that. Vim's search engine is very powerful and can do much more complex searches as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the easiest method of doing this. If you really don't want to highlight searches you can also use the &lt;code&gt;search()&lt;/code&gt; function like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call search('f')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course this is much more typing. If this is something you do a lot you can a create a &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#E174&quot; rel=&quot;nofollow noreferrer&quot;&gt;custom command&lt;/a&gt; to reduce the the amount of typing, but I feel like that's overthinking things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /&lt;/code&gt;&lt;/a&gt;  for more info on searching or &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#search%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help search()&lt;/code&gt;&lt;/a&gt; for more info on the search function.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-06-13T21:38:53.313" LastActivityDate="2017-06-13T21:38:53.313" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12629" PostTypeId="2" ParentId="12621" CreationDate="2017-06-13T23:09:11.067" Score="3" Body="&lt;p&gt;With:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2^8 =&#xA;1+1 = 3&#xA;2+4 =&#xA;4%8 =&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/=$/ t. | s/=// | exe '.!bc'  | -j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;produces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2^8 = 256&#xA;1+1 = 3&#xA;2+4 = 6&#xA;4%8 = 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It finds each line ending in &lt;code&gt;=&lt;/code&gt;, copies it below, trims off the &lt;code&gt;=&lt;/code&gt;,&#xA;filters it through &lt;code&gt;bc&lt;/code&gt;, then joins it to the line above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Notes&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :global&lt;/code&gt; -- short form: &lt;code&gt;:g&lt;/code&gt; -- executes the following commands on each line that matches.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :copy&lt;/code&gt; -- short synomym: &lt;code&gt;:t&lt;/code&gt; -- copy a range of lines elsewhere.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :substitute&lt;/code&gt; -- short form: &lt;code&gt;:s&lt;/code&gt; -- search and replace.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :execute&lt;/code&gt; -- short form: &lt;code&gt;:exe&lt;/code&gt; -- execute a string as a command, used here to allow another following command since otherwise &lt;code&gt;|&lt;/code&gt; would be passed to the shell.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h range!&lt;/code&gt; -- filter a range of lines through an external program.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :join&lt;/code&gt; -- short form: &lt;code&gt;:j&lt;/code&gt; -- join a range of lines.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7878" LastEditorUserId="7878" LastEditDate="2017-06-14T08:54:34.250" LastActivityDate="2017-06-14T08:54:34.250" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12630" PostTypeId="1" AcceptedAnswerId="12631" CreationDate="2017-06-14T07:33:41.963" Score="0" ViewCount="3170" Body="&lt;p&gt;My &lt;code&gt;vim-airline&lt;/code&gt; plugin looks like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tQgYq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tQgYq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But on all screenshots it might be like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/S3E66.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S3E66.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here my Vundle plugins list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'ctrlpvim/ctrlp.vim'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'rking/ag.vim'&#xA;Plugin 'skwp/greplace.vim'&#xA;Plugin 'MarcWeber/vim-addon-mw-utils'&#xA;Plugin 'tomtom/tlib_vim'&#xA;Plugin 'garbas/vim-snipmate'&#xA;Plugin 'tpope/vim-surround'&#xA;Plugin 'StanAngeloff/php.vim'&#xA;Plugin 'arnaud-lb/vim-php-namespace'&#xA;Plugin 'ervandew/supertab'&#xA;Plugin 'stephpy/vim-php-cs-fixer'&#xA;Plugin 'tobyS/vmustache'&#xA;Plugin 'tobyS/pdv'&#xA;Plugin 'SirVer/ultisnips'&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some config from my &lt;code&gt;.vimrc&lt;/code&gt; file, without plugins config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&#xA;syntax enable&#xA;set backspace=indent,eol,start&#xA;set number&#xA;let mapleader = ',' &#xA;set noerrorbells visualbell t_vb=           &#xA;set autowriteall                    &#xA;set complete=.,w,b,u                    &#xA;set tabstop=8&#xA;set expandtab&#xA;set softtabstop=4&#xA;set shiftwidth=4&#xA;&#xA;&quot;------------Visuals-------------&quot;&#xA;set background=dark&#xA;colorscheme material-theme&#xA;set t_CO=256                &#xA;set guifont=Operator\Mono\ weight=350\ 10&#xA;set linespace=10&#xA;set guioptions-=e           &#xA;&#xA;set guioptions-=l           &#xA;set guioptions-=L&#xA;set guioptions-=r&#xA;set guioptions-=R&#xA;&#xA;hi LineNr guibg=bg&#xA;set foldcolumn=2&#xA;hi foldcolumn guibg=bg&#xA;&#xA;hi vertsplit guifg=bg guibg=bg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I using Ubuntu 16.04, try to use gVim and terminal vim, the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I try to comment all visual config like theme, guifonr, but the same result.&lt;/p&gt;&#xA;" OwnerUserId="13015" LastEditorUserId="13015" LastEditDate="2017-06-14T07:39:02.100" LastActivityDate="2017-08-15T05:47:27.410" Title="vim-airline not displayed correctly" Tags="|vimrc|gvim|plugin-airline|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12631" PostTypeId="2" ParentId="12630" CreationDate="2017-06-14T07:58:29.380" Score="1" Body="&lt;p&gt;I installed &lt;a href=&quot;https://github.com/powerline/fonts&quot; rel=&quot;nofollow noreferrer&quot;&gt;powerline/fonts&lt;/a&gt; and after the commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# clone&#xA;git clone https://github.com/powerline/fonts.git&#xA;# install&#xA;cd fonts&#xA;./install.sh&#xA;# clean-up a bit&#xA;cd ..&#xA;rm -rf fonts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My status looks like better, but not ideal, I think it's because I didn't find my font in that repository, but it`s nit big problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now my panel look like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/7qomx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7qomx.png&quot; alt=&quot;sample&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13015" LastEditorUserId="51" LastEditDate="2017-06-16T03:57:47.580" LastActivityDate="2017-06-16T03:57:47.580" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12632" PostTypeId="1" CreationDate="2017-06-14T12:20:27.490" Score="1" ViewCount="67" Body="&lt;p&gt;Is there a way to bind the sequence of commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Tabularize /\/\/&#xA;:Tabularize /;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in that order to the command &lt;code&gt;:Command&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I attempted the solution and it failed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LineUp()&#xA;  normal :cabbrev Command Tabularize/\/\/&amp;lt;CR&amp;gt;:Tabularize /;&amp;lt;CR&amp;gt;&#xA;endfunction&#xA;&#xA;command! -nargs=0 -complete=buffer -range LineUp call LineUp()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that I can't get it to act on the visual selection.&lt;/p&gt;&#xA;" OwnerUserId="6499" LastEditorUserId="6499" LastEditDate="2017-06-14T16:00:58.210" LastActivityDate="2017-07-20T08:34:24.893" Title="Binding a Sequence of Tabularize Commands to One :Command" Tags="|plugin-tabular|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12633" PostTypeId="1" CreationDate="2017-06-14T12:30:57.010" Score="0" ViewCount="47" Body="&lt;p&gt;How do tabularize all commas after instances of &lt;code&gt;EST[&lt;/code&gt; so that text like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Item 1 //EST[5555m, 6666m]&#xA;Item 2 //EST[1m, 300m]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gets transformed into something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Item 1 //EST[5555m , 6666m]&#xA;Item 2 //EST[1m    , 300m]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The best starting command I know is &lt;code&gt;:Tabularize \,&lt;/code&gt;, but it's not quite specific enough because it tabularizes all commas and not just those proceeding &lt;code&gt;EST[&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6499" LastEditorUserId="51" LastEditDate="2017-06-16T03:53:18.167" LastActivityDate="2017-06-16T03:53:42.000" Title="Tabularizing all Commas after `EST[`?" Tags="|regular-expression|plugin-tabular|" AnswerCount="1" CommentCount="1" ClosedDate="2017-06-16T03:54:54.343" ContentLicense="CC BY-SA 3.0" />
  <row Id="12634" PostTypeId="1" CreationDate="2017-06-14T12:58:36.257" Score="2" ViewCount="127" Body="&lt;p&gt;Is there a way to make it so that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a header&#xA;=&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;converts into &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a header&#xA;================&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in all files who filetype is markdown?&lt;/p&gt;&#xA;" OwnerUserId="6499" LastActivityDate="2017-06-16T03:48:18.473" Title="Adding Atex Markdown Headers in Vim" Tags="|filetype-markdown|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12635" PostTypeId="2" ParentId="12634" CreationDate="2017-06-14T14:45:58.267" Score="2" Body="&lt;p&gt;Likely it can be done with &lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;TAB&lt;/kbd&gt;, but another approach is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;type your header, then &lt;kbd&gt;ESC&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;ESC&lt;/kbd&gt; (copy the whole line in Visual mode)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;p&lt;/kbd&gt;aste&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt; (move down, select whole line, replace it with &lt;code&gt;=&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then You can create a macro or an &lt;code&gt;imap&lt;/code&gt; or &lt;code&gt;nmap&lt;/code&gt; for it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is (after typing your header and getting back to normal mode is: &lt;code&gt;:t.|s/./=/g&lt;/code&gt; (ex mode copy line bellow and replace every character on it with &lt;code&gt;=&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="656" LastActivityDate="2017-06-14T14:45:58.267" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12636" PostTypeId="2" ParentId="12633" CreationDate="2017-06-14T15:08:54.613" Score="0" Body="&lt;p&gt;You could try installing the &lt;a href=&quot;https://github.com/godlygeek/tabular/blob/master/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;tabular plugin&lt;/a&gt;.  It looks like it will take a regular expression and tabularize the contents of your file.&#xA;There are examples in the documentation such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc,def,ghi&#xA;a,b&#xA;a,b,c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After running &lt;code&gt;:Tabularize /,/r1c1l0&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc , def, ghi&#xA;  a , b&#xA;  a , b  ,  c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and since you have an accessible expression of the comma after &lt;code&gt;EST[&lt;/code&gt; it looks like a good fit.&lt;/p&gt;&#xA;" OwnerUserId="5857" LastEditorUserId="51" LastEditDate="2017-06-16T03:53:42.000" LastActivityDate="2017-06-16T03:53:42.000" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12637" PostTypeId="2" ParentId="12632" CreationDate="2017-06-14T15:13:50.167" Score="1" Body="&lt;p&gt;Sure, try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cabbrev Command Tabularize/\/\/&amp;lt;CR&amp;gt;:Tabularize /;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="656" LastActivityDate="2017-06-14T15:13:50.167" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12638" PostTypeId="1" AcceptedAnswerId="19035" CreationDate="2017-06-14T18:02:22.767" Score="1" ViewCount="354" Body="&lt;p&gt;I start up vim using the following command:&#xA;&lt;code&gt;vim -u NONE -U NONE -c ':set columns=40 nu'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OxVvR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OxVvR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I push &lt;code&gt;vim&lt;/code&gt; to the foreground...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qfcKI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qfcKI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...and return.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yzMNn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yzMNn.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason, VIM has changed the columns variable to the width of the window without me telling it to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I did not manually resize the window after Ctrl+Z.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason that I tried to change the &lt;code&gt;:columns&lt;/code&gt; value was to &lt;em&gt;change the width of the VIM editor&lt;/em&gt;. If the &lt;code&gt;:columns&lt;/code&gt; variable is not the right solution, could you provide some better ideas for changing the width?&lt;/p&gt;&#xA;" OwnerUserId="5850" LastEditorUserId="5850" LastEditDate="2019-02-26T22:01:01.240" LastActivityDate="2019-02-26T22:01:01.240" Title="Why does VIM change the columns variable after Ctrl+z? (Setting the width of text in the VIM editor)" Tags="|bash|macos|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="12639" PostTypeId="1" CreationDate="2017-06-14T18:36:21.500" Score="1" ViewCount="345" Body="&lt;p&gt;How can I use the Tabular plugin to align by &quot;;&quot; after &quot;//&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line 1 ; B // Comment 1 ; Comment 2&#xA;Line 2 C // Comment 3    ; Comment 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After running &lt;code&gt;:Tabularize /;&lt;/code&gt; I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line 1                ; B // Comment 1 ; Comment 2&#xA;Line 2 C // Comment 3 ; Comment 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how do I tabularize so that I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line 1  ; B // Comment 1 ; Comment 2&#xA;Line 2 C   // Comment 3  ; Comment 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6499" LastEditorUserId="51" LastEditDate="2017-06-16T03:56:40.620" LastActivityDate="2017-08-15T06:47:27.100" Title="How do I use :Tabular only for delimiters after a certain pattern?" Tags="|regular-expression|plugin-tabular|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12640" PostTypeId="1" AcceptedAnswerId="12671" CreationDate="2017-06-14T19:12:30.333" Score="4" ViewCount="5815" Body="&lt;p&gt;I just don't undstand the VIM help for pattern matching and substitution. I've tried.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have many lines of code, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;G1 X139.164 Y115.348 E8.40357 ; perimeter&#xA;G1 X138.903 Y115.845 E8.57778 ; perimeter&#xA;G1 X136.919 Y119.355 E9.82896 ; perimeter&#xA;G1 X135.204 Y125.148     F250    &#xA;G1 X133.565 Y124.281 E11.75686     F250    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to remove uppercase &lt;strong&gt;E&lt;/strong&gt; &lt;em&gt;and everything following it on each line&lt;/em&gt; - or truncate each line, beginning with the &lt;strong&gt;E&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/E\&amp;gt;//g&#xA;:1,$/E\&amp;gt;\.//&#xA;:%s/E\&amp;gt;\zs.*//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please help.&lt;/p&gt;&#xA;" OwnerUserId="11454" LastActivityDate="2017-06-18T16:55:41.053" Title="How to truncate every line after pattern" Tags="|substitute|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12641" PostTypeId="1" CreationDate="2017-06-14T19:25:04.603" Score="2" ViewCount="287" Body="&lt;p&gt;Vim comes with some support (syntax highlighting) out of the box for the DOT language (graphviz) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, I found the plugin: &lt;a href=&quot;https://github.com/wannesm/wmgraphviz.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/wannesm/wmgraphviz.vim&lt;/a&gt;, which provides integrated compilation and interactive viewing. Furthermore, this is the only plugin that I could find providing graphviz support.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am coding up a complicated graph and ideally, I'd like to have a bit more advanced support, particularly &lt;strong&gt;linting, autocompletion  and snippets&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is anyone aware of tools that do this?&lt;/p&gt;&#xA;" OwnerUserId="8408" LastActivityDate="2017-06-14T19:25:04.603" Title="Comprehesive support for graphviz (linting/autocompletion/snippets)" Tags="|autocompletion|plugin-system|plugin-ultisnips|plugin-syntastic|snippets|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12642" PostTypeId="2" ParentId="12640" CreationDate="2017-06-14T20:04:14.903" Score="7" Body="&lt;p&gt;You can use this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,%s/E.*$//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11878" LastEditorUserId="51" LastEditDate="2017-06-14T22:50:19.080" LastActivityDate="2017-06-14T22:50:19.080" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12643" PostTypeId="2" ParentId="12634" CreationDate="2017-06-14T20:14:27.560" Score="0" Body="&lt;p&gt;You could do it this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a header&#xA;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the line with &lt;code&gt;=&lt;/code&gt; type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;ESC&amp;gt;Vly5p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt; puts vim into visual mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;l&lt;/code&gt; (letter l) moves the cursor to the left.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt; copies the &lt;code&gt;=&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;5&lt;/code&gt; is the number of &lt;code&gt;=&lt;/code&gt;s you want.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; inserts the &lt;code&gt;=&lt;/code&gt;s.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11878" LastEditorUserId="51" LastEditDate="2017-06-16T03:48:18.473" LastActivityDate="2017-06-16T03:48:18.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12644" PostTypeId="2" ParentId="12640" CreationDate="2017-06-14T20:22:01.730" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/12642/2920&quot;&gt;@Christopher Collins' solution&lt;/a&gt; is great. Here's one more way you could do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm fED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This tell vim to press &lt;code&gt;fED&lt;/code&gt; on each line as if you had typed it in normal mode. &lt;code&gt;fE&lt;/code&gt; will move the cursor forward to the first &lt;code&gt;E&lt;/code&gt;, and &lt;code&gt;D&lt;/code&gt; deletes everything until the end of the line.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-06-14T20:22:01.730" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12645" PostTypeId="1" AcceptedAnswerId="12653" CreationDate="2017-06-15T10:46:47.383" Score="2" ViewCount="1429" Body="&lt;p&gt;I want to get the whole buffer contents as a single string.  Currently I'm doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let line_ending = &quot;\n&quot;&#xA;let text = join(getline(1, '$'), line_ending).line_ending&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this assumes the line ending.  If this is the best approach, how can I find out what the line ending actually is?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is there a better way to get the actual buffer contents?&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2017-06-17T07:35:40.897" Title="How to get buffer contents including line endings?" Tags="|vimscript|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="12646" PostTypeId="2" ParentId="12490" CreationDate="2017-06-15T14:30:31.550" Score="1" Body="&lt;p&gt;The best way I've found so far is to type &lt;code&gt;:!pdflatex [insert rest of command here]&lt;/code&gt; within vim to compile it, then view it with &lt;a href=&quot;http://skim-app.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Skim&lt;/a&gt;. If you change the file while it is open in Skim, Skim will ask if you want to display the current file automatically once, so choose the affirmative option, and then you can watch it update in the background each time you compile. Also, don't forget that &lt;code&gt;:!!&lt;/code&gt; will repeat the last shell command, so you don't have to type out the compile command each time. &lt;/p&gt;&#xA;" OwnerUserId="13051" LastActivityDate="2017-06-15T14:30:31.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12647" PostTypeId="1" AcceptedAnswerId="12648" CreationDate="2017-06-15T21:29:05.403" Score="2" ViewCount="5647" Body="&lt;p&gt;I currently am using a command within a larger bash script to start an instance of NeoVim with some options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim -c &quot;terminal&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I would like to do is be able to execute a terminal command from the NeoVim terminal that is opened with this command. In particular, I want to execute a specific version of a Python interpreter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim -c &quot;terminal:~/environments/env1/bin/python&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can something like this be achieved with NeoVim?&lt;/p&gt;&#xA;" OwnerUserId="12804" LastActivityDate="2017-06-15T21:54:03.770" Title="Execute a command in the NeoVim terminal emulator on startup" Tags="|neovim|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12648" PostTypeId="2" ParentId="12647" CreationDate="2017-06-15T21:54:03.770" Score="3" Body="&lt;p&gt;As described in &lt;code&gt;:help :terminal&lt;/code&gt;, you can specify a command that will run in the terminal buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim -c 'terminal ~/environments/env1/bin/python'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;:terminal&lt;/code&gt; isn't given an explicit command to run, it runs the shell.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-06-15T21:54:03.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12649" PostTypeId="1" AcceptedAnswerId="12650" CreationDate="2017-06-15T23:23:08.370" Score="0" ViewCount="96" Body="&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; $ g$&#xA;noremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; 0 g0&#xA;noremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; j gj&#xA;noremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; k gk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've created a session of four windows for a particular project, and for some reason the remapping above isn't applied. The strange thing is that the above part of my &lt;code&gt;.vimrc&lt;/code&gt; file is &lt;strong&gt;in&lt;/strong&gt; the source file for the session. &lt;/p&gt;&#xA;" OwnerUserId="244" LastActivityDate="2017-06-16T00:46:08.340" Title="Remapping of j as gj etc in .vimrc is not applied in a session" Tags="|vimrc|sessions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12650" PostTypeId="2" ParentId="12649" CreationDate="2017-06-16T00:46:08.340" Score="5" Body="&lt;p&gt;Mappings defined with &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; are only effective in the buffer that's active when they are defined. Remove &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; to have them work more-or-less everywhere. See &lt;code&gt;:help map-&amp;lt;buffer&amp;gt;&lt;/code&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="7878" LastActivityDate="2017-06-16T00:46:08.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12651" PostTypeId="2" ParentId="12645" CreationDate="2017-06-16T03:26:27.170" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27fileformat%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'fileformat'&lt;/code&gt;&lt;/a&gt; setting control the end-of-line character that Vim uses. There are three possible values:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;unix&lt;/code&gt; – &lt;code&gt;\n&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dos&lt;/code&gt; – &lt;code&gt;\r\n&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;mac&lt;/code&gt; – &lt;code&gt;\r&lt;/code&gt; (this is very archaic and only applies to the pre-OSX &quot;classic&quot; MacOS&#xA;of the 80s and 90s).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In VimScript this would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;fileformat == 'unix'&#xA;    let line_ending = &quot;\n&quot;&#xA;elseif &amp;amp;fileformat == 'dos'&#xA;    let line_ending = &quot;\r\n&quot;&#xA;elseif &amp;amp;fileformat == 'mac'&#xA;    let line_ending = &quot;\r&quot;&#xA;else&#xA;    echoerr &quot;unknown value for the 'fileformat' setting: &quot; . &amp;amp;fileformat&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or a shorter version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let line_ending = {&quot;unix&quot;: &quot;\n&quot;, &quot;dos&quot;: &quot;\r\n&quot;, &quot;mac&quot;: &quot;\r&quot;}[&amp;amp;fileformat]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-06-17T07:35:40.897" LastActivityDate="2017-06-17T07:35:40.897" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12652" PostTypeId="2" ParentId="12639" CreationDate="2017-06-16T03:39:55.080" Score="2" Body="&lt;p&gt;You could use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Tabularize ///[^;]*\zs;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To break it down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;//&lt;/code&gt; – match literal &lt;code&gt;//&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^;]*&lt;/code&gt; – match zero or more characters except &lt;code&gt;;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs&lt;/code&gt; – set the start of the match. This is the &quot;magic&quot; in the regexp that makes it work; without it, the match would start at the first character (&lt;code&gt;/&lt;/code&gt; in this case) and Tabular would align on that, but with this it will match at the character after &lt;code&gt;\zs&lt;/code&gt; (the desired &lt;code&gt;;&lt;/code&gt;).&lt;br&gt;&#xA;These sort of advanced regular expression operators can be rather hard to grok, so don't worry if you didn't quite follow that. I would encourage you to experiment. Also see &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2Fzs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\zs&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;&lt;/code&gt; – match literal &lt;code&gt;;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-06-16T03:39:55.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12653" PostTypeId="2" ParentId="12645" CreationDate="2017-06-16T09:53:34.150" Score="4" Body="&lt;p&gt;It's possible to directly put the content of the current buffer into a register (and from here into a variable) thanks to &lt;code&gt;:%y&lt;/code&gt; (&lt;code&gt;:yank&lt;/code&gt; takes an optional register name).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, after a test on a file in dos format, I've seen that my register contained characters of code 10 for newlines. The test being done with &lt;code&gt;:echo map(split(@&quot;, '\zs'), 'char2nr(v:val)')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure why you want to extract the binary content of the buffer though -- IOW, I'm not sure to see why you want to keep the original line ending.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-06-16T09:53:34.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12654" PostTypeId="1" AcceptedAnswerId="12655" CreationDate="2017-06-16T11:40:01.557" Score="0" ViewCount="391" Body="&lt;p&gt;I want to replace all of the occurrences of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;armv7_format_strings&amp;lt;any_string&amp;gt; = {&amp;lt;str1&amp;gt;, &amp;lt;str2&amp;gt;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;armv7_format_strings&amp;lt;any_string&amp;gt;[0] = &amp;lt;str1&amp;gt; ;&#xA;armv7_format_strings&amp;lt;any_string&amp;gt;[1] = &amp;lt;str2&amp;gt; ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="1841" LastEditDate="2017-06-16T12:31:37.880" LastActivityDate="2017-06-16T21:24:29.787" Title="How to do the following replace in vim?" Tags="|regular-expression|substitute|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12655" PostTypeId="2" ParentId="12654" CreationDate="2017-06-16T11:55:20.267" Score="3" Body="&lt;p&gt;This one worked:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\(armv7_format_strings.*\) = {\(.*\), \(.*\)};/\1[0] = \2;\r\1[1] = \3;\r/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2017-06-16T11:55:20.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12657" PostTypeId="2" ParentId="12654" CreationDate="2017-06-16T14:35:02.227" Score="0" Body="&lt;p&gt;While I'd use the regex swap you could also do it with a macro.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq^vt=h&quot;ayf{lvt,&quot;byf,lvt}&quot;cydd&amp;lt;CTRL_r&amp;gt;a[0] = &amp;lt;CTRL_r&amp;gt;b;&amp;lt;Enter&amp;gt;&amp;lt;CTRL_r&amp;gt;a[1] = &amp;lt;CTRL_r&amp;gt;c;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Its basically the same as the regex. Yank the left side of the equals into register a, and the two strings in the array into registers b and c. Delete the line, and paste &lt;code&gt;RegA[0] = RegB;\nRegA[1] = RegC;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="895" LastActivityDate="2017-06-16T14:35:02.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12658" PostTypeId="2" ParentId="11765" CreationDate="2017-06-16T17:08:38.403" Score="1" Body="&lt;p&gt;Selecting text then &lt;code&gt;r&amp;lt;space&amp;gt;&lt;/code&gt; certainly works. Perhaps you are not selecting with vim itself (but for example with mouse over the terminal, which uses the terminal's &quot;select&quot; feature, something vim is completely unaware of).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following vim feature may come in handy when selecting text in this situation. Say you are in a &quot;block&quot; of something, for example (star shows cursor location):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;some* string&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(code *in (parentheses)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;{ something (in *curly) &quot;brackets&quot; }&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The first block is surrounded by &lt;code&gt;&quot;&quot;&lt;/code&gt;, the second with &lt;code&gt;()&lt;/code&gt; and the third with &lt;code&gt;{}&lt;/code&gt;. Let's call these delimiters &lt;code&gt;&amp;lt;delimeter&amp;gt;&lt;/code&gt; (doesn't matter if opening or closing). The following commands help interact with these blocks:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;action&amp;gt;a&amp;lt;delimiter&amp;gt;&lt;/code&gt; do something with a block (including the delimiters). &lt;code&gt;a&lt;/code&gt; as in &quot;a block&quot;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;action&amp;gt;i&amp;lt;delimiter&amp;gt;&lt;/code&gt; do something with what's inside the block (excluding the delimiters). &lt;code&gt;i&lt;/code&gt; for &quot;inner&quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The action could be anything, like &lt;code&gt;v&lt;/code&gt; or &lt;code&gt;d&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, as soon as you move the cursor inside the string you want to remove, you can do &lt;code&gt;va&quot;r&amp;lt;space&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;v&lt;/code&gt;: select&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&quot;&lt;/code&gt;: the string surrounding the cursor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;r&lt;/code&gt;: replace with&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt;: space&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help object-select&lt;/code&gt; for a list of these &quot;blocks&quot; (or objects, rather) that can be selected.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This command is wonderful, you can quickly select blocks of C code, strings, paragraphs or sentences in text. It's so wonderful, here is another demonstration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int func(int x, int y)&#xA;{&#xA;    x = do_something_with(x);&#xA;    y = do_something_with(y); &amp;lt;CURSOR SOMEWHERE ON THIS LINE&amp;gt;&#xA;    for (int i = 0; i &amp;lt; x; ++i)&#xA;    {&#xA;        for (int j = 0; j &amp;lt; y; ++j)&#xA;        {&#xA;            c += global_array[x][y];&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you want to change it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int func(int x, int y)&#xA;{&#xA;    return x + y;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All you need to do is: &lt;code&gt;vi{dO&amp;lt;your new code&amp;gt;&lt;/code&gt;. Neat!&lt;/p&gt;&#xA;" OwnerUserId="850" LastActivityDate="2017-06-16T17:08:38.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12661" PostTypeId="2" ParentId="12654" CreationDate="2017-06-16T19:02:17.643" Score="1" Body="&lt;p&gt;You can use a substation with a sub-replace-expression. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(\s*armv7_format_strings.*\) = {\([^}]*\)};/\=join(map(split(submatch(2), '\s*,\s*'), 'submatch(1).&quot;[&quot;.v:key.&quot;] = &quot;.v:val.&quot;;&quot;'),&quot;\r&quot;)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Overview&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Basically this captures the left hand side (&lt;code&gt;{lhs}&lt;/code&gt;) and the right hand side (&lt;code&gt;{rhs}&lt;/code&gt;) separately. Then splits the &lt;code&gt;{rhs}&lt;/code&gt; by &lt;code&gt;,&lt;/code&gt; (aka parameter) and concatenates the &lt;code&gt;{lhs}&lt;/code&gt; to each new parameter. Finish the substitution by joining each new line together with a new line, &lt;code&gt;&quot;\r&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: this will fail for tricky strings, e.g. &lt;code&gt;&quot;foo,bar&quot;&lt;/code&gt; as this method just assumes no &lt;code&gt;,&lt;/code&gt; or &lt;code&gt;}&lt;/code&gt; inside of strings.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Glory of Details&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%s:^\(\s*armv7_format_strings.*\) = {\([^}]*\)};/\={expr}/&lt;/code&gt; - Capture the &lt;code&gt;{lhs}&lt;/code&gt; and &lt;code&gt;{rhs}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;use an sub-replace-expression, &lt;code&gt;\={expr}&lt;/code&gt;, to use &lt;code&gt;{expr}&lt;/code&gt; as the replacement.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;submatch(1)&lt;/code&gt; is the &lt;code&gt;{lhs}&lt;/code&gt; aka &lt;code&gt;\1&lt;/code&gt; in normal regex speak&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;submatch(2)&lt;/code&gt; is the &lt;code&gt;{rhs}&lt;/code&gt; aka &lt;code&gt;\2&lt;/code&gt; in normal regex speak&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;split(submatch(2), '\s*,\s*')&lt;/code&gt; - split the &lt;code&gt;{rhs}&lt;/code&gt; by &lt;code&gt;,&lt;/code&gt;. Yields are parameters as a List&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;map({lst}, {expr})&lt;/code&gt; - &lt;code&gt;map()&lt;/code&gt; will update the list by evaluating &lt;code&gt;{expr}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;submatch(1).&quot;[&quot;.v:key.&quot;] = &quot;.v:val.&quot;;&quot;&lt;/code&gt; as our expression, &lt;code&gt;{expr}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v:val&lt;/code&gt; will the each single item in the List&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v:key&lt;/code&gt; will the the index of the List&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;join({lst}, &quot;\r&quot;)&lt;/code&gt; will join the list together as new lines&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;For more help&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h sub-replace-expression&#xA;:h join(&#xA;:h map(&#xA;:h split(&#xA;:h submatch(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-06-16T21:24:29.787" LastActivityDate="2017-06-16T21:24:29.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12662" PostTypeId="1" AcceptedAnswerId="12674" CreationDate="2017-06-16T18:34:03.967" Score="3" ViewCount="1857" Body="&lt;p&gt;I bought keyboard &lt;code&gt;SteelSeries Apex 350&lt;/code&gt; thinking that I can somehow bind  extra keys with vim. I am looking for answers in the Internet regarding this subject but I am not lucky so far. Have anyone tried to use gaming extra keys in vim?&lt;/p&gt;&#xA;" OwnerUserId="10900" OwnerDisplayName="Artur Gurgul" LastEditorUserId="51" LastEditDate="2017-06-16T20:38:03.243" LastActivityDate="2017-06-23T19:28:46.493" Title="Handling gaming keyboard with extra keys to be able to bind shortcuts" Tags="|key-bindings|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12663" PostTypeId="2" ParentId="12662" CreationDate="2017-06-16T21:12:45.463" Score="5" Body="&lt;p&gt;I assume you're talking about the special keys on the left-hand side? &#xA;&lt;a href=&quot;https://i.stack.imgur.com/6UxYz.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6UxYz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;Vim only sees ASCII text as input. This means that when you press &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;s&lt;/kbd&gt;, Vim only sees &lt;code&gt;S&lt;/code&gt; not the two individual keys. This is why you can't use a naked &lt;kbd&gt;Shift&lt;/kbd&gt; as a binding. That being said, if your new keys produce some kind of ASCII output you should be able to use them as bindings by doing the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;noremap&lt;/code&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;{your key} {your binding}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Place the resulting line in your &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If on the other hand doing this doesn't produce ASCII output, I don't think there is any way for Vim to access them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-V&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-V&lt;/code&gt;&lt;/a&gt; for more info on how &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; works.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-06-16T21:12:45.463" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12664" PostTypeId="1" AcceptedAnswerId="12665" CreationDate="2017-06-17T01:05:56.990" Score="43" ViewCount="20206" Body="&lt;p&gt;Is there any way to change the background color of the popup menu in gvim? The default background color is pink, which is a little weird to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/47WxD.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/47WxD.png&quot; alt=&quot;prompt menu&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5675" LastEditorUserId="51" LastEditDate="2017-06-17T01:47:35.853" LastActivityDate="2017-06-17T01:47:35.853" Title="Is there any way to change the popup menu color?" Tags="|autocompletion|gvim|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12665" PostTypeId="2" ParentId="12664" CreationDate="2017-06-17T01:47:27.177" Score="66" Body="&lt;p&gt;You can use the following highlight groups:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Pmenu&lt;/code&gt; – normal item&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;PmenuSel&lt;/code&gt; – selected item&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;PmenuSbar&lt;/code&gt; – scrollbar&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;PmenuThumb&lt;/code&gt; – thumb of the scrollbar&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For example to set a grey background:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight Pmenu ctermbg=gray guibg=gray&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For Gvim you only need the &lt;code&gt;guibg&lt;/code&gt; part (&lt;code&gt;ctermbg&lt;/code&gt; is used when Vim is run in a terminal), but I find it useful to always define both.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I didn't know this either; I used &lt;code&gt;:help i_ctrl-x&lt;/code&gt; to find the help page for that key, then followed the &lt;code&gt;ins-completion&lt;/code&gt; link mentioned in the entry, and searched for highlight with &lt;code&gt;/highlight&lt;/code&gt; ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to find this information would have been to use &lt;code&gt;:help highlight-groups&lt;/code&gt;, which lists all default highlight groups.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-06-17T01:47:27.177" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12666" PostTypeId="1" CreationDate="2017-06-17T16:18:55.920" Score="1" ViewCount="154" Body="&lt;p&gt;Is there a pattern for including helper libraries &lt;a href=&quot;https://github.com/haya14busa/underscore.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;underscore.vim&lt;/a&gt; in a Vim Plugin? Ideally I'd like to not ask a user to install additional plugins to use my own Plugin or clobber a user's installed plugins with a version of my own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've thought about doing some sort of build step on CI that adds dependencies inline and then pushes to &lt;code&gt;master&lt;/code&gt; but that seems heavy handed. I was hoping for an easier way :)&lt;/p&gt;&#xA;" OwnerUserId="12886" LastActivityDate="2017-06-18T00:31:43.790" Title="Including Utility Libraries in a vim plugin" Tags="|vimscript|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12667" PostTypeId="2" ParentId="12666" CreationDate="2017-06-17T19:47:39.963" Score="2" Body="&lt;p&gt;That's a very good question. Unfortunately, I've no definitive answer for you. I can only detail the main strengths and weaknesses of the different approaches.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;1. Standalone plugins&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is the dominant approach. Code from other plugins are copied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;pro&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The end-user won't have to install several plugins&lt;/li&gt;&#xA;&lt;li&gt;It's the friendliest approach with the plugin managers everybody use&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;cons&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Maintainability is catastrophic: you won't profit from bug fixes, performance improvements, or even added features&lt;/li&gt;&#xA;&lt;li&gt;If you're serious about licences, this could get ugly&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;2. Plugins that depend on other plugins&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Very few plugins follow this approach. End-users have to install the plugins we depend upon. Dare I say this is the most professional one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;pro&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Maintainability -- it's the exact opposite of the approach 1&lt;/li&gt;&#xA;&lt;li&gt;Copyright: it's easier to depend on plugins with different licences without having to use a licence different from the one we would have chosen, or to mix licences within a same plugin, or to violate original licences by changing it without the initial author knowledge/explicit authorization&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;cons&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Installing a plugin that depends on others may become very complicated without assistance: see &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp#installation&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-cpp requirements&lt;/a&gt; for instance. Without VAM or vim-flavor, this is a nightmare.&lt;/li&gt;&#xA;&lt;li&gt;Very few people use plugin managers that understand dependencies =&gt; this is a nightmare for maintainers to track dependencies (what if a plugin we depend upon introduce a new dependency?), and for end-users to know exactly what is required by each plugin, and to know when a plugin introduce a new dependency...&lt;/li&gt;&#xA;&lt;li&gt;If we depend on a specific version of a plugin, this could get ugly -- see the dependencies issues in ruby world. vim-flavor helps a little here &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;My choice on the subject&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I'm maintaining something like almost 20 different plugins. A long time ago I've chosen to define a &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin library&lt;/a&gt; that other plugins depend upon. This library contains a lot of things. I definitively not regret to have made this choice. Thanks to that I've a efficient solution to debug and log what happens in my plugins, many list related functions that should have been defined in vim, and so on. And I don't maintain it several times, but only once. When I've added DbC for lh-tags, I've been able to use it immediately in build-tools-wrappers, where I've introduced new assertions that were available in lh-tags without having to synchronize any file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding installation, every time somebody asks about plugin managers, I explain why I prefer &lt;a href=&quot;https://github.com/MarcWeber/vim-addon-manager&quot; rel=&quot;nofollow noreferrer&quot;&gt;VAM&lt;/a&gt; or &lt;a href=&quot;https://github.com/kana/vim-flavor&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-flavor&lt;/a&gt;: they've understood the importance of dependencies. Nobody would use a yum/dnf/apt-get that don't handle dependencies, and yet this is what most do in vim world. As trendy plugin managers don't understand dependencies, plugin avoid to have dependencies, as thus plugin managers don't need to support dependencies, and so on. This is a vicious circle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding CI, and more precisely tests, I do CI on travis. I've cooked &lt;a href=&quot;https://github.com/LucHermitte/vim-UT/blob/master/doc/rspec-integration.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;my own solution&lt;/a&gt; that use vim-flavor + vimrunner + rpsec + my UT framework. vim-flavor takes care of dependencies on travis. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use your plugin start-up to automatically fetch another plugin, but honestly, don't. What if 3 other plugins do the same thing with the same dependency? The end-user would see the dependency being fetched and activated at least 3 times. Explicitly or implicitly, dependencies should being handled by the plugin manager used by the end-user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The real question is: what burden are you ready to put on your end-users?&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-06-18T00:31:43.790" LastActivityDate="2017-06-18T00:31:43.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12668" PostTypeId="2" ParentId="12523" CreationDate="2017-06-17T20:16:20.933" Score="0" Body="&lt;p&gt;I've learned to avoid loop to speed-up processing times in vim scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given Karl's &lt;a href=&quot;https://vi.stackexchange.com/a/12529/626&quot;&gt;answer&lt;/a&gt;, my analyse function will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Analyse() abort&#xA;   let tab = []&#xA;   &quot; I fill the tab with all the matching numbers thanks to substitute + \= + add(...)[0]&#xA;   call substitute(@&quot;, '\v\[\zs(\d+(\.\d+)?|\.\d+)\ze\s*u\]', '\=add(t,submatch(0))[0]', 'g')&#xA;   &quot; I fix the numbers written as '.1' into '0.1'&#xA;   call map(tab, '(v:val[0]==&quot;.&quot; ? &quot;0&quot; :&quot;&quot;) . v:val')&#xA;   &quot; Now, I only need to reduce the tab&#xA;   return eval(join(tab, '+'))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-06-18T08:14:56.643" LastActivityDate="2017-06-18T08:14:56.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12670" PostTypeId="2" ParentId="12626" CreationDate="2017-06-18T08:45:53.187" Score="1" Body="&lt;p&gt;I'm not sure how your approach could work as it would mean the unnamed register is available between two separate 'ex' processes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can do a single invocation this works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -c 'normal! 1gg19|^V48gg59|y' -c 'edit file2' -c 'normal! 9gg21|p' -cwq file1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I tried your way except putting it in the star (*) register thinking the clipboard would persist it across ex calls but that didn't work for me.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2017-06-18T08:45:53.187" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12671" PostTypeId="2" ParentId="12640" CreationDate="2017-06-18T16:55:41.053" Score="4" Body="&lt;p&gt;Your last attempt is almost correct.  I would use this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/E.*//&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The OCD part of me would also want to remove any spaces before the &lt;code&gt;E&lt;/code&gt;.  That could be done with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/\s*E.*//&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\&amp;gt;&lt;/code&gt; was causing your attempts to fail because by default numbers are considered part of the word.  See &lt;code&gt;:help \&amp;gt;&lt;/code&gt; and &lt;code&gt;:help iskeyword&lt;/code&gt; for more info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\zs&lt;/code&gt; isn't necessary in this case since you are trying to replace the entire search pattern.  If you were to use it, you would want it in front of the &lt;code&gt;E&lt;/code&gt; since you want to remove the &lt;code&gt;E&lt;/code&gt; as well.  The &lt;code&gt;\zs&lt;/code&gt; would be useful if, for example, you only wanted to remove the &lt;code&gt;E&lt;/code&gt; and everything after on lines starting with &lt;code&gt;G2&lt;/code&gt;.  Then you could do something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/^G2.*\zs\s*E.*//&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2017-06-18T16:55:41.053" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12673" PostTypeId="2" ParentId="5243" CreationDate="2017-06-19T09:37:57.470" Score="17" Body="&lt;p&gt;You can do this by typing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;n&amp;gt;df&amp;lt;x&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;n&amp;gt; is the number of occurrence of particular character&#xA;df&amp;lt;x&amp;gt; means delete till you find the occurrence of character x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4745" LastEditorUserId="51" LastEditDate="2017-06-19T11:20:32.153" LastActivityDate="2017-06-19T11:20:32.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12674" PostTypeId="2" ParentId="12662" CreationDate="2017-06-19T12:19:45.290" Score="2" Body="&lt;p&gt;Because most terminals only support a limited set of key codes you need to solve your issue in two steps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use Karabiner/Elements (Mac), Autohotkey (Windows), xkb/Autokey (Linux) or something similar to map the key to a combination that is supported in your terminal (like &lt;kbd&gt;F1&lt;/kbd&gt;-&lt;kbd&gt;F12&lt;/kbd&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Map that key (e.g. &lt;kbd&gt;F1&lt;/kbd&gt;) in Vim&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Karabiner/Autohotkey let you set the mapping only for the terminal, not sure how to do that with Linux.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="4472" LastEditDate="2017-06-23T19:28:46.493" LastActivityDate="2017-06-23T19:28:46.493" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12675" PostTypeId="1" CreationDate="2017-06-19T13:21:56.227" Score="3" ViewCount="904" Body="&lt;p&gt;I apologize in advance for not knowing enough even to ask the question correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to implement something like the links in the help files (that you jump to using &lt;kbd&gt;ctl&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;) in my own file, but I'm not even sure what to call them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, I have a text file with a bunch of entries, each marked with a headword. I'd like to automatically generate a hyperlinked table of contents based on the headwords. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know it's possible, since Bram did it in the tutorial file (unless it's written in something other than Vim?). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="244" LastEditorUserId="1841" LastEditDate="2017-06-22T07:22:05.343" LastActivityDate="2017-06-22T07:22:05.343" Title="links/tags inside a file" Tags="|tags|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12676" PostTypeId="1" AcceptedAnswerId="13972" CreationDate="2017-06-19T13:56:27.463" Score="0" ViewCount="79" Body="&lt;p&gt;I have a parser which output this kind of messages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;||     Error: M:\workdir\MyFile.ja: line 38: &quot;Blablabla&quot; has no license declaration&#xA;||     Error: M:\workdir\MyFile.ja: unknown attribute &quot;blabla&quot;&#xA;||     Fatal: M:\workdir\MyFile.ja: not generating output because of 2 earlier errors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I try to parse it with the following errorformat: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;errorformat=&amp;amp;errorformat . ',' . 'Error: %f: line %l: %m'&#xA;let &amp;amp;errorformat=&amp;amp;errorformat . ',' . 'Error: %f: %m'&#xA;let &amp;amp;errorformat=&amp;amp;errorformat . ',' . 'Fatal: %f: line %l: %m'&#xA;let &amp;amp;errorformat=&amp;amp;errorformat . ',' . 'Fatal: %f: %m'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it matches nothing. Can someone help me to points out what am I doing wrong ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks. &lt;/p&gt;&#xA;" OwnerUserId="13084" LastActivityDate="2017-10-19T08:04:02.593" Title="errorformat: can't understand how to handle error for my parser" Tags="|errorformat|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12677" PostTypeId="1" CreationDate="2017-06-19T20:48:15.947" Score="1" ViewCount="4851" Body="&lt;p&gt;I am new to vim and am trying to set a colorscheme. However, for both pre-installed and new colorschemes, the only thing that happens when I change the colorscheme is the background color changes. For example, &lt;code&gt;:colo evening&lt;/code&gt; shows up with just a lighter gray background; &lt;code&gt;:colo pablo&lt;/code&gt; changes nothing at all. Regardless of if I change it in the vimrc file or manually in a file, the result is the same. I am using iTerm2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: changing colorscheme now changes the background color as well as other messages such as &quot;a .swp file exists&quot;... However, the text color of the actual program does not change. &lt;/p&gt;&#xA;" OwnerUserId="13091" LastEditorUserId="13091" LastEditDate="2017-06-26T19:51:50.993" LastActivityDate="2017-11-24T11:14:20.470" Title="Changing colorscheme does not change text color?" Tags="|vimrc|colorscheme|iterm2|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12678" PostTypeId="1" AcceptedAnswerId="12679" CreationDate="2017-06-19T22:28:32.327" Score="4" ViewCount="658" Body="&lt;p&gt;I'd like to map &lt;kbd&gt;Leader&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt; in normal mode to showing the auto completions of files to edit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;e :e&amp;lt;space&amp;gt;&amp;lt;tab&amp;gt;&lt;/code&gt;, but it shows &lt;code&gt;:e ^I&lt;/code&gt;, where the tab gets rendered as &lt;code&gt;^I&lt;/code&gt; rather than triggering the auto completions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;e :e&amp;lt;space&amp;gt;&lt;/code&gt; correctly prints &lt;code&gt;:e&lt;/code&gt; but I obviously have to hit &lt;kbd&gt;Tab&lt;/kbd&gt; manually in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can trigger the auto completions to show up in a key binding?&lt;/p&gt;&#xA;" OwnerUserId="3255" LastEditorUserId="3255" LastEditDate="2017-06-19T23:58:07.483" LastActivityDate="2018-02-08T11:37:40.803" Title="How to trigger &lt;tab&gt; auto completion in a key mapping?" Tags="|key-bindings|autocompletion|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12679" PostTypeId="2" ParentId="12678" CreationDate="2017-06-20T01:29:53.160" Score="5" Body="&lt;p&gt;you can use &lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;e :call feedkeys(':e&amp;lt;space&amp;gt;&amp;lt;tab&amp;gt;','t')&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;t&lt;/code&gt; indicates to use the keys as typed (as opposed to coming from a mapping)&lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="11477" LastEditDate="2018-02-07T19:34:45.393" LastActivityDate="2018-02-07T19:34:45.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12680" PostTypeId="1" AcceptedAnswerId="12682" CreationDate="2017-06-20T07:33:55.513" Score="22" ViewCount="69216" Body="&lt;p&gt;Is there a simple way to delete all white spaces on a line until the first character on that line is met?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;           #a list of comments&#xA;                # item 1&#xA;                # item 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I would like it to become: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#a list of comments&#xA;# item 1&#xA;# item 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know how to delete n characters (ex: &lt;code&gt;8x&lt;/code&gt;) and to repeat the command (&lt;code&gt;.&lt;/code&gt;), but how could I do without having to input the number of white spaces?&lt;/p&gt;&#xA;" OwnerUserId="12085" LastEditorUserId="25" LastEditDate="2022-01-21T04:22:05.347" LastActivityDate="2023-06-03T13:38:54.570" Title="How to delete all white spaces until first character?" Tags="|cut-copy-paste|" AnswerCount="10" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="12681" PostTypeId="2" ParentId="12632" CreationDate="2017-06-20T07:45:22.787" Score="1" Body="&lt;p&gt;You can use the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CombinedTabularize() range&#xA;    execute a:firstline . ',' . a:lastline . 'Tabularize /\/\/'&#xA;    execute a:firstline . ',' . a:lastline . 'Tabularize /;'&#xA;endfunction&#xA;&#xA;command! -range CT &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call CombinedTabularize()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;CombinedTabularize()&lt;/code&gt; takes a range thanks to the &lt;code&gt;range&lt;/code&gt; option. When using this option the lines in the range are available with &lt;code&gt;a:firstline&lt;/code&gt; and &lt;code&gt;a:lastline&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;CT&lt;/code&gt; also takes a range and pass the selected lines to the function with &lt;code&gt;&amp;lt;line1&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;line2&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;execute&lt;/code&gt; commands are used to concatenate the lines of the range and the &lt;code&gt;Tabularize&lt;/code&gt; calls.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;About the code you tried to use here are the different problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Your command uses the &lt;code&gt;range&lt;/code&gt; option but doesn't pass the lines to the function.&lt;/li&gt;&#xA;&lt;li&gt;Your function doesn't use the range neither&lt;/li&gt;&#xA;&lt;li&gt;Your function execute &lt;code&gt;normal :cabbrev&lt;/code&gt; which creates a new command line abbreviation but doesn't execute it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You might be interested in the following help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h func-range&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h command-range&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-06-20T07:45:22.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12682" PostTypeId="2" ParentId="12680" CreationDate="2017-06-20T07:48:33.953" Score="23" Body="&lt;p&gt;You can either visually select the lines and use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/^\s*//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means 'substitute all of the whitespaces following the first column of the line by nothing'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or go on the first line, use &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;0&lt;/kbd&gt; to go on the first column&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;d^&lt;/kbd&gt;  to delete until the first character of the line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And then go to the next line and use the dot command&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-06-20T07:48:33.953" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12683" PostTypeId="2" ParentId="12680" CreationDate="2017-06-20T08:02:18.413" Score="19" Body="&lt;p&gt;In addition to statox's methods, you can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Position the cursor at the beginning of the leading whitespace and type &lt;code&gt;dw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Position the cursor anywhere in the leading whitespace and type &lt;code&gt;diw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Position the cursor at the first non-space character of the line and type &lt;code&gt;d0&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Visually select all the lines you want to move left, e.g., by typing &lt;code&gt;V&lt;/code&gt; on the first line and moving the cursor to the last line, then executing &lt;code&gt;:left&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I actually usually do in such cases is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Visually select all the lines as above, type &lt;code&gt;&amp;lt;&lt;/code&gt; to move them left by one shiftwidth, then type &lt;code&gt;.&lt;/code&gt; until they're shifted all the way to the left margin.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="13113" LastEditDate="2017-06-21T10:09:47.730" LastActivityDate="2017-06-21T10:09:47.730" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12684" PostTypeId="2" ParentId="10471" CreationDate="2017-06-20T10:28:29.527" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/Mizuchi/vim-ranger&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-ranger&lt;/a&gt; plugin provides a similar integration with &lt;a href=&quot;https://github.com/ranger/ranger&quot; rel=&quot;nofollow noreferrer&quot;&gt;ranger&lt;/a&gt;, and accomplishes this out of the box. You can &lt;a href=&quot;https://github.com/Mizuchi/vim-ranger/blob/master/plugin/ranger.vim#L53&quot; rel=&quot;nofollow noreferrer&quot;&gt;look at the code&lt;/a&gt; to see how it does that if you're interesting in duplicating this behavior with the other plugin.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Update&lt;/em&gt;: I realized that disabling netrw as vim-ranger plugin disables &lt;code&gt;gx&lt;/code&gt; to view files (I hadn't realized that this was part of netrw).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a result, I've gone back to using &lt;a href=&quot;https://github.com/francoiscabrol/ranger.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;ranger.vim&lt;/a&gt; with the above accepted answer solution (the &lt;code&gt;Dirvish&lt;/code&gt; mimicry) to auto open directories with ranger. This keeps the useful netrw functionality intact and seems to be the best option.&lt;/p&gt;&#xA;" OwnerUserId="13098" LastEditorUserId="13098" LastEditDate="2017-07-03T04:03:38.410" LastActivityDate="2017-07-03T04:03:38.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12687" PostTypeId="1" AcceptedAnswerId="12688" CreationDate="2017-06-20T17:50:59.283" Score="3" ViewCount="164" Body="&lt;p&gt;I use Vim to write longer sequences of body text. It does automatic formatting, which generally works nicely. If I have a sentence that ends in a number, say a date or a year, and that number happens to be placed at the beginning of a line, Vim will indent the next line, as if it is part of a numbered list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am editing an &lt;code&gt;.rst&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have looked at &lt;code&gt;formatoptions&lt;/code&gt; and suspected the &lt;code&gt;n&lt;/code&gt; flag of being the problem, but &lt;code&gt;set fo-=n&lt;/code&gt; made no difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I am missing some obvious setting that could solve this, but I am unsure where to start looking. Obviously I looked at &lt;code&gt;formatoptions&lt;/code&gt;, &lt;code&gt;fo-table&lt;/code&gt;, &lt;code&gt;autoindent&lt;/code&gt; et. al., but as I see it I already unset the relevant option. What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="13104" LastEditorUserId="51" LastEditDate="2017-06-20T22:16:58.747" LastActivityDate="2017-06-20T22:26:16.203" Title="How to avoid indenting after a line that starts with a number?" Tags="|indentation|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12688" PostTypeId="2" ParentId="12687" CreationDate="2017-06-20T22:26:16.203" Score="2" Body="&lt;p&gt;It looks like the rst filetype has some custom indentation rules which &#xA;add this indentation. This works by setting the &lt;code&gt;indentexpr&lt;/code&gt; setting to &lt;code&gt;GetRSTIndent&lt;/code&gt; in &lt;code&gt;/usr/share/vim/vim80/indent/rst.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To completely disable the rst indentation you can use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup ftype_rst&#xA;    autocmd!&#xA;    autocmd Filetype rst setlocal indentexpr=&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will disable &lt;em&gt;all&lt;/em&gt; indent rules, which may not be what you want. To disable just these rules you can override the &lt;code&gt;GetRSTIndent()&lt;/code&gt; function in &lt;code&gt;~/.vim/after/indent/rst.vim&lt;/code&gt; (I've commented out the five lines that add indentation for lists):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:itemization_pattern = '^\s*[-*+]\s'&#xA;let s:enumeration_pattern = '^\s*\%(\d\+\|#\)\.\s\+'&#xA;&#xA;function! GetRSTIndent()&#xA;  let lnum = prevnonblank(v:lnum - 1)&#xA;  if lnum == 0&#xA;    return 0&#xA;  endif&#xA;&#xA;  let ind = indent(lnum)&#xA;  let line = getline(lnum)&#xA;&#xA;  &quot; if line =~ s:itemization_pattern&#xA;  &quot;   let ind += 2&#xA;  &quot; elseif line =~ s:enumeration_pattern&#xA;  &quot;   let ind += matchend(line, s:enumeration_pattern)&#xA;  &quot; endif&#xA;&#xA;  let line = getline(v:lnum - 1)&#xA;&#xA;  &quot; Indent :FIELD: lines.  Don’t match if there is no text after the field or&#xA;  &quot; if the text ends with a sent-ender.&#xA;   if line =~ '^:.\+:\s\{-1,\}\S.\+[^.!?:]$'&#xA;     return matchend(line, '^:.\{-1,}:\s\+')&#xA;   endif&#xA;&#xA;  if line =~ '^\s*$'&#xA;    execute lnum&#xA;    call search('^\s*\%([-*+]\s\|\%(\d\+\|#\)\.\s\|\.\.\|$\)', 'bW')&#xA;    let line = getline('.')&#xA;    if line =~ s:itemization_pattern&#xA;      let ind -= 2&#xA;    elseif line =~ s:enumeration_pattern&#xA;      let ind -= matchend(line, s:enumeration_pattern)&#xA;    elseif line =~ '^\s*\.\.'&#xA;      let ind -= 3&#xA;    endif&#xA;  endif&#xA;&#xA;  return ind&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also look at tweaking the &lt;code&gt;s:enumeration_pattern&lt;/code&gt; regexp. You didn't really mention which cases fail for you, so I can't really help you there.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-06-20T22:26:16.203" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12689" PostTypeId="2" ParentId="12680" CreationDate="2017-06-21T05:24:47.237" Score="7" Body="&lt;p&gt;A few variations on a theme:&lt;/p&gt;&#xA;&lt;h3&gt;Method(s) that will work in &lt;code&gt;vi&lt;/code&gt;:&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Go to the first line that you want to manipulate.&lt;/li&gt;&#xA;&lt;li&gt;Count the lines that you want to manipulate —&#xA;let’s say there are 17 of them. &#xA;Type &lt;code&gt;17&amp;lt;&amp;lt;&lt;/code&gt;. &#xA;This will shift each of the following seventeen lines&#xA;left by one shiftwidth (normally eight characters; i.e., one tab). &#xA;Assuming you still have lines with leading spaces,&#xA;type &lt;strong&gt;&lt;code&gt;.&lt;/code&gt;&lt;/strong&gt; to repeat the shift command. &#xA;Type &lt;strong&gt;&lt;code&gt;.&lt;/code&gt;&lt;/strong&gt; repeatedly until all the spaces are gone.&lt;/li&gt;&#xA;&lt;li&gt;If you want to remove the leading spaces from all lines&#xA;to the end of the buffer, use &lt;code&gt;&amp;lt;G&lt;/code&gt; and then &lt;strong&gt;&lt;code&gt;.&lt;/code&gt;&lt;/strong&gt; repeatedly.&lt;/li&gt;&#xA;&lt;li&gt;Any common technique for identifying the end of the range&#xA;will work similarly. &#xA;For example, with the text in your question,&#xA;you could use &lt;code&gt;&amp;lt;/2/&lt;/code&gt; (and then &lt;strong&gt;&lt;code&gt;.&lt;/code&gt;&lt;/strong&gt; repeatedly).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Method that will work only in &lt;code&gt;vim&lt;/code&gt;:&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Go to the first line that you want to manipulate.&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;kbd&gt;V&lt;/kbd&gt; or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt;&#xA;to go into visual selection mode (mark the beginning of the range).&lt;/li&gt;&#xA;&lt;li&gt;Move to the end of the range.&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;9&amp;lt;&lt;/code&gt;. &#xA;This will shift the selected lines left by nine shiftwidths. &#xA;As this will typically be 72 characters (9×8),&#xA;there’s a good chance that that will do the job. &#xA;If you still have lines with leading spaces,&#xA;type &lt;strong&gt;&lt;code&gt;.&lt;/code&gt;&lt;/strong&gt; to repeat the shift command (i.e., another72 characters).&lt;/li&gt;&#xA;&lt;li&gt;Or, if you know that you have lines&#xA;with more than 72 leading spaces (or nine tabs), just use &lt;code&gt;99&amp;lt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5458" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-06-21T05:24:47.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12690" PostTypeId="1" AcceptedAnswerId="12692" CreationDate="2017-06-21T09:53:00.503" Score="0" ViewCount="59" Body="&lt;p&gt;I created an example of text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dog cat worm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to replace everything but not the first word and without knowing what's there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first I tried this:&lt;code&gt;:%s/\(dog\)\(.*\)/\1/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works fine but when I change it to: &lt;code&gt;:%s/\(\w\)\(.*\)/\1/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it returns&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For second word regexp &lt;code&gt;:%s/.*\(cat\)\(.*\)/\1/g&lt;/code&gt; I get &lt;code&gt;cat&lt;/code&gt; so it's just as I wanted but with &lt;code&gt;:%s/\w\(\w\)\(.*\)/\1/g&lt;/code&gt; I get &lt;code&gt;c&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9294" LastEditorUserId="9294" LastEditDate="2017-06-21T09:59:51.567" LastActivityDate="2017-06-21T10:12:28.793" Title="How to use regular expressions with \w\d inside ()" Tags="|regular-expression|substitute|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12691" PostTypeId="2" ParentId="12680" CreationDate="2017-06-21T09:56:21.430" Score="8" Body="&lt;p&gt;Deleting a word at the beginning of the line will do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to repeat that for every line in the file that begins with whitespace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^ /norm dw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13115" LastActivityDate="2017-06-21T09:56:21.430" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12692" PostTypeId="2" ParentId="12690" CreationDate="2017-06-21T10:12:28.793" Score="3" Body="&lt;p&gt;&lt;code&gt;\w&lt;/code&gt; does not represent a word but merely a word-character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want &lt;code&gt;:%s/\(\w\+\)\(.*\)/\1/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in this simple example the &lt;code&gt;/g&lt;/code&gt; does nothing though&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-06-21T10:12:28.793" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12693" PostTypeId="2" ParentId="12550" CreationDate="2017-06-21T15:52:26.977" Score="1" Body="&lt;p&gt;Currently I did it with the help of the &lt;code&gt;eval&lt;/code&gt; bash program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set makeprg=eval\ 'closure-compiler\ %\ 1&amp;gt;/dev/null'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This approach doesn't require a separate bash script, so &lt;code&gt;make&lt;/code&gt; can be called independently of the cwd. The minus of this solution is that it can safely be used only in terminal with the bash shell.&lt;/p&gt;&#xA;" OwnerUserId="2798" LastActivityDate="2017-06-21T15:52:26.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12694" PostTypeId="1" CreationDate="2017-06-21T19:28:29.473" Score="0" ViewCount="136" Body="&lt;p&gt;I'm trying to configure &lt;a href=&quot;https://github.com/jalcine/cmake.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;cmake.vim&lt;/a&gt; for my c++ projects, but it doesn't work for me even on initial stage. The following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:CMakeCreateBuild &amp;lt;build_dir&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;just creates a build directory but it seems it doesn't invoke &lt;code&gt;cmake&lt;/code&gt; to configure the project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see something in vim command line, it looks like a log of cmake.vim execution but it shows just a last line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to open full log of last command there and not a one line only?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="12828" LastEditorUserId="1841" LastEditDate="2017-06-22T07:04:46.347" LastActivityDate="2017-09-20T20:44:50.277" Title="How to look at the command output?" Tags="|plugin-cmake.vim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12695" PostTypeId="2" ParentId="2702" CreationDate="2017-06-21T19:42:23.347" Score="3" Body="&lt;p&gt;I made a little plugin &lt;a href=&quot;https://github.com/chrisbra/vim-autoread/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-autoread&lt;/a&gt; that uses &lt;code&gt;tail -f&lt;/code&gt; to update the buffer in the background asynchronously. This needs obviously the job feature of Vim Version 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;:AutoRead&lt;/code&gt; to turn it on and &lt;code&gt;:AutoRead!&lt;/code&gt; to turn it off. &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-06-21T19:42:23.347" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12697" PostTypeId="2" ParentId="12694" CreationDate="2017-06-22T04:13:31.677" Score="0" Body="&lt;p&gt;You could run it again with the 'verbose' option set to 15 (you know, like &lt;code&gt;:set verbose=15&lt;/code&gt;) to trace every ex command called by the plugin.&lt;/p&gt;&#xA;" OwnerUserId="10421" LastActivityDate="2017-06-22T04:13:31.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12698" PostTypeId="2" ParentId="12694" CreationDate="2017-06-22T07:08:34.373" Score="1" Body="&lt;p&gt;According to their &lt;a href=&quot;https://github.com/jalcine/cmake.vim#getting-started&quot; rel=&quot;nofollow noreferrer&quot;&gt;README page&lt;/a&gt; &lt;code&gt;:CMakeCreateBuild &amp;lt;build-dir-name&amp;gt;&lt;/code&gt; only creates a new binary directory for your project so I think you are experiencing the expexted behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still according to the same page I think you need to run the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Create a new binary directory for your clean project.&#xA;:CMakeCreateBuild &amp;lt;build-dir-name&amp;gt;&#xA;&#xA;&quot; Build all of the targets.&#xA;:CMakeBuild&#xA;&#xA;&quot; Clean up bad builds.&#xA;:CMakeClean&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-06-22T07:08:34.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12699" PostTypeId="1" AcceptedAnswerId="12711" CreationDate="2017-06-22T07:08:52.187" Score="2" ViewCount="306" Body="&lt;p&gt;I ran into a problem when using the quickfix feature of vim. When I open up my source file in vim, a buffer of that file is created, and its name is shown on the status bar, let's say &lt;code&gt;main.cpp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I compile it with &lt;code&gt;:make&lt;/code&gt; and jump to next error with quickfix. Because the error message my compiler outputs is always absolute path, e.g. &lt;code&gt;c:\folder1\folder2\main.cpp&lt;/code&gt;. If I jump to that error location, then a new buffer of the same file will be opened, but with the absolute path filename.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then when I edit either of them and save it, the other buffer won't get updated and that's really annoying. I tried &lt;code&gt;set autoread&lt;/code&gt; but it doesn't help at all. Do you guys have any suggestions? Thanks a lot! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;I am running vim on windows. &lt;/p&gt;&#xA;" OwnerUserId="13131" LastEditorUserId="13131" LastEditDate="2017-06-22T19:36:30.897" LastActivityDate="2017-06-23T09:48:59.507" Title="Multiple buffers of the same file" Tags="|buffers|filesystem|quickfix|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12700" PostTypeId="1" AcceptedAnswerId="12701" CreationDate="2017-06-22T12:27:49.537" Score="4" ViewCount="94" Body="&lt;p&gt;I often use &lt;code&gt;*&lt;/code&gt; with &lt;code&gt;cgn&lt;/code&gt; and end up missing the first match (or doing &lt;code&gt;*N...&lt;/code&gt;). So I'd prefer for &lt;code&gt;*&lt;/code&gt; to stay where it is.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap * *N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does almost what I want except it recenters the cursor line. Is there a better way?&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-06-22T13:54:26.417" Title="Make * stay on current keyword" Tags="|search|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12701" PostTypeId="2" ParentId="12700" CreationDate="2017-06-22T13:54:26.417" Score="6" Body="&lt;p&gt;You can do that with this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; * :let @/=expand(&quot;&amp;lt;cword&amp;gt;&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That sets the search register, &lt;code&gt;@/&lt;/code&gt;, to the word under the cursor, &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;. See also&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help quote/&#xA;:help &amp;lt;cword&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-06-22T13:54:26.417" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12703" PostTypeId="1" CreationDate="2017-06-22T16:22:12.833" Score="0" ViewCount="139" Body="&lt;p&gt;I'm using the &lt;code&gt;byobu&lt;/code&gt; terminal so the keys &lt;code&gt;F2&lt;/code&gt;, &lt;code&gt;F3&lt;/code&gt;, and &lt;code&gt;F4&lt;/code&gt; (and others) are for the &lt;code&gt;byobu&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my &lt;code&gt;.vimrc&lt;/code&gt; I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! nmap &amp;lt;C-p&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;silent! map &amp;lt;F2&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;silent! map &amp;lt;F3&amp;gt; :NERDTreeFind&amp;lt;CR&amp;gt;&#xA;let g:NERDTreeToggle=&quot;&amp;lt;F2&amp;gt;&quot;&#xA;let g:NERDTreeMapActivateNode=&quot;&amp;lt;F3&amp;gt;&quot;&#xA;let g:NERDTreeMapPreview=&quot;&amp;lt;F4&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would that the keybindings would be &lt;code&gt;\q&lt;/code&gt;, &lt;code&gt;\w&lt;/code&gt;, and &lt;code&gt;\e&lt;/code&gt; respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="8228" LastActivityDate="2017-06-26T20:58:28.823" Title="How to reassign a keybinding to a function" Tags="|vimrc|key-bindings|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12704" PostTypeId="2" ParentId="12677" CreationDate="2017-06-22T19:06:06.937" Score="1" Body="&lt;p&gt;try adding &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co=256 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your .(g)vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;try opening vim from terminal as well and see if the colors are correct (if so you'll have to toggle the color settings in iTerm's profile settings) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;also download MacVim if you haven't already &lt;/p&gt;&#xA;" OwnerUserId="13146" LastEditorUserId="51" LastEditDate="2017-06-22T22:03:59.230" LastActivityDate="2017-06-22T22:03:59.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12705" PostTypeId="1" AcceptedAnswerId="12707" CreationDate="2017-06-22T20:05:53.243" Score="1" ViewCount="502" Body="&lt;p&gt;Generally, I only use split panes inside of a Tab when using plugins like NerdTree, TagBar, and Codi, or when opening up helptags with &lt;code&gt;:help&lt;/code&gt;. When I enter one of these panes, the Tab title text changes from the &quot;primary&quot; file name to &lt;code&gt;__TagBar__.1&lt;/code&gt;, &lt;code&gt;NERD_tree_1&lt;/code&gt;, or &lt;code&gt;No Name&lt;/code&gt;, for the respective plugins, or something like &lt;code&gt;map.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I force &lt;code&gt;Vim&lt;/code&gt; to &lt;strong&gt;freeze the original Tab title text&lt;/strong&gt;, so that entering one of these panels will not change it? This default behavior becomes very annoying when you have multiple tabs open, and it becomes hard to tell which document is where.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI I have &lt;strong&gt;&lt;a href=&quot;https://github.com/mkitt/tabline.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;TabLine&lt;/a&gt;&lt;/strong&gt; installed, but I believe this is also a problem without it.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="51" LastEditDate="2017-06-22T20:54:41.963" LastActivityDate="2017-08-22T02:12:04.747" Title="How can I keep the Tab title text fixed, during movement through separate split panes/panels?" Tags="|vim-windows|tabbed-user-interface|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12706" PostTypeId="1" CreationDate="2017-06-22T23:27:53.917" Score="3" ViewCount="669" Body="&lt;p&gt;If I have following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;2&#xA;3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I make a macro to insert a new line below current line and type 'x':&#xA;my macro is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ox^[j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;now I run this macro to the above three line by visual select the lines and type command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;normal @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it will give me the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;x&#xA;x&#xA;x&#xA;2&#xA;3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of the expected result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;x&#xA;2&#xA;x&#xA;3&#xA;x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I achieve the expected result?&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="1276" LastEditDate="2017-06-23T12:51:15.700" LastActivityDate="2017-06-23T13:12:37.043" Title="vim run macro multiple messed up" Tags="|macro|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12707" PostTypeId="2" ParentId="12705" CreationDate="2017-06-23T01:36:18.257" Score="1" Body="&lt;p&gt;So I figured out a method by hijacking the content of the &lt;strong&gt;&lt;a href=&quot;https://github.com/mkitt/tabline.vim/blob/master/plugin/tabline.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tabline&lt;/a&gt;&lt;/strong&gt; plugin. The function simply labels each tab by the first name in the list of open buffers with &lt;code&gt;filetype&lt;/code&gt;s not in the list &lt;code&gt;[&quot;nerdtree&quot;,&quot;tagbar&quot;,&quot;codi&quot;,&quot;help&quot;]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just place the lines below anywhere in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Tabline()&#xA;  let s = ''&#xA;  for i in range(tabpagenr('$'))&#xA;    let tab = i + 1&#xA;    let buflist = tabpagebuflist(tab)&#xA;    let bufignore = ['nerdtree', 'tagbar', 'codi', 'help']&#xA;    for b in buflist&#xA;      let buftype = getbufvar(b, &quot;&amp;amp;filetype&quot;)&#xA;      if index(bufignore, buftype)==-1 &quot;index returns -1 if the item is not contained in the list&#xA;        let bufnr = b&#xA;        break&#xA;      elseif b==buflist[-1]&#xA;        let bufnr = b&#xA;      endif&#xA;    endfor&#xA;    let bufname = bufname(bufnr)&#xA;    let bufmodified = getbufvar(bufnr, &quot;&amp;amp;mod&quot;)&#xA;    let s .= '%' . tab . 'T'&#xA;    let s .= (tab == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#')&#xA;    let s .= ' ' . tab .':'&#xA;    let s .= (bufname != '' ? '['. fnamemodify(bufname, ':t') . '] ' : '[No Name] ')&#xA;    if bufmodified&#xA;      let s .= '[+] '&#xA;    endif&#xA;  endfor&#xA;  let s .= '%#TabLineFill#'&#xA;  return s&#xA;endfunction&#xA;set tabline=%!Tabline()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8084" LastActivityDate="2017-06-23T01:36:18.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12708" PostTypeId="1" AcceptedAnswerId="12710" CreationDate="2017-06-23T02:55:16.803" Score="3" ViewCount="1479" Body="&lt;p&gt;I would like the html tag attribute id to be highlighted differently from the rest of the tag attributes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like the Atom editor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9ALRM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9ALRM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given this line from the html5.vim plugin&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;syn keyword htmlArg contained id&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match htmlArgId /id/ containedin=ALL&#xA;hi htmlArgId guifg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it doesn't work it only highlights &lt;code&gt;id&lt;/code&gt; outside of html tags.&lt;/p&gt;&#xA;" OwnerUserId="5090" LastEditorUserId="51" LastEditDate="2017-06-23T04:22:37.863" LastActivityDate="2017-06-23T09:29:39.493" Title="How can I override a syntax keyword match?" Tags="|syntax-highlighting|filetype-html|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12709" PostTypeId="2" ParentId="12708" CreationDate="2017-06-23T04:21:03.193" Score="3" Body="&lt;p&gt;You'll need to modify the &lt;code&gt;contains&lt;/code&gt; of &lt;code&gt;syn region htmlTag&lt;/code&gt; to include your new &lt;code&gt;htmlArgId&lt;/code&gt;. The full line would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region htmlTag start=+&amp;lt;[^/]+ end=+&amp;gt;+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster,htmlArgId&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just tacked on &lt;code&gt;,htmlArgId&lt;/code&gt; at the end; the rest is from &lt;code&gt;/usr/share/vim/vim80/syntax/html.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that you can just use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword htmlArgId contained id&#xA;hi htmlArgId ctermfg=blue guifg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add this in your vimrc with an autocmd (&lt;code&gt;autocmd Syntax html ...&lt;/code&gt;), or you can put it in &lt;code&gt;~/.vim/after/syntax/html.vim&lt;/code&gt;. See &lt;a href=&quot;https://vi.stackexchange.com/q/4975/51&quot;&gt;How can I add additional syntax highlighting rules in my local vimrc?&lt;/a&gt; for details on that.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-06-23T04:21:03.193" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12710" PostTypeId="2" ParentId="12708" CreationDate="2017-06-23T06:12:48.873" Score="3" Body="&lt;p&gt;Well you can of course dive into the complex syntax rules, see @Carpetsmoker's answer. However that might not always work correctly, depending on the order of the syntax rules and their priorities. Therefore, for such simple things it is usually better to use &lt;code&gt;matchadd()&lt;/code&gt; function for highlighting special items in addition to the syntax rule.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First define your highlighting group you want to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi htmlTagID ctermbg=blue guifg=blue&#xA;call matchadd('htmlTagID', '\&amp;lt;id\&amp;gt;\ze=')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This could be put into a filetype plugin, like &lt;code&gt;~/.vim/after/ftplugin/html.vim&lt;/code&gt; (create non-existing directories).&#xA;For a more complete solution, you would need to store the return value of matchadd, to be able to clear the match later with &lt;code&gt;matchdelete()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, matching is window-local so if you have the same buffer open in several windows, you might not see the highlighting in every window. For that you would also need to call the highlighting function on a WinEnter autocommand (or similar).&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2017-06-23T09:29:39.493" LastActivityDate="2017-06-23T09:29:39.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12711" PostTypeId="2" ParentId="12699" CreationDate="2017-06-23T09:48:59.507" Score="0" Body="&lt;p&gt;Check that &lt;code&gt;fileignorecase&lt;/code&gt; is set (&lt;code&gt;set fileignorecase?&lt;/code&gt;) even though it should be the default on Windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                'fileignorecase' 'fic' 'nofileignorecase' 'nofic'&#xA;'fileignorecase' 'fic'  boolean (default on for systems where case in file&#xA;                                 names is normally ignored)&#xA;                        global&#xA;                        {not in Vi}&#xA;        When set case is ignored when using file names and directories.&#xA;        See 'wildignorecase' for only ignoring case when doing completion.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are using the native Windows vim exe (not cygwin)?&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-06-23T09:48:59.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12712" PostTypeId="2" ParentId="12706" CreationDate="2017-06-23T10:51:28.043" Score="2" Body="&lt;p&gt;You probably forgot to have your macro move down a line. So it did add a new x always on the same line. However since you did not share what your macro actually looks like, one cannot tell for sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[update]&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You seem to be calling your macro from visual mode as you show in your updated article. However, note that it won't work as you expect. This is because your &lt;code&gt;'&amp;lt;,'&amp;gt;norm! @a&lt;/code&gt; will position the cursor after each invocation on each consecutive line of the visual mode. However, since each time you run the macro you add one line, the positioning will be off by at least one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best way would be to avoid visual mode in this case and call your macro by hand &lt;code&gt;3@q&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2017-06-23T13:12:37.043" LastActivityDate="2017-06-23T13:12:37.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12713" PostTypeId="2" ParentId="4056" CreationDate="2017-06-23T11:51:18.180" Score="0" Body="&lt;p&gt;You can use this plugin: &lt;a href=&quot;https://github.com/smitajit/bufutils.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;bufutils.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It closes scratch buffers, location list, error list, etc...&lt;/p&gt;&#xA;" OwnerUserId="13102" LastEditorUserId="1841" LastEditDate="2017-06-23T11:59:58.197" LastActivityDate="2017-06-23T11:59:58.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12714" PostTypeId="2" ParentId="12706" CreationDate="2017-06-23T13:11:56.963" Score="1" Body="&lt;p&gt;I find this &lt;a href=&quot;https://sanctum.geek.nz/arabesque/advanced-vim-macros/&quot; rel=&quot;nofollow noreferrer&quot;&gt;wonderful post&lt;/a&gt; about advanced macro.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turns out if you macro will add new lines, then simply run &lt;code&gt;:'&amp;lt;,'&amp;gt; norm @q&lt;/code&gt; won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve my problem, you need to take care of 2 things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;As Christian and Wouter suggested in the above answer, you must record your macro moving to the correct line to continue.&lt;/li&gt;&#xA;&lt;li&gt;prefix macro with number of times to run &lt;code&gt;:norm n@q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1276" LastActivityDate="2017-06-23T13:11:56.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12715" PostTypeId="2" ParentId="12706" CreationDate="2017-06-23T13:12:29.307" Score="0" Body="&lt;p&gt;With the macro &lt;code&gt;ox^]j&lt;/code&gt; I got the same result as you, I suppose this is because the cursor isn't moved when using a range commmand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The work around to still use the visual selection would be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;g/./norm @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way the macro is executed on each line of the selection.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also as I suggested on the comments, I would rather use a substitution to do what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/$/\rx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To substitute each end of line by a new line and an &lt;code&gt;x&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-06-23T13:12:29.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12717" PostTypeId="1" CreationDate="2017-06-23T16:57:55.043" Score="3" ViewCount="190" Body="&lt;p&gt;I have a file (filetype=javascript), this is how it looks without folds:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/S7F3G.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S7F3G.png&quot; alt=&quot;the file without folds&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and with folds:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/A8tEl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/A8tEl.png&quot; alt=&quot;the file with folds&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can move with the &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; motions skipping the empty lines inside the folds (thanks to these &lt;a href=&quot;https://superuser.com/questions/836781/make-vims-motions-skip-over-folds&quot;&gt;question&lt;/a&gt; and answer). But trying to delete a paragraph brings the problem of folds again: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My cursor is on line 1. I'm pressing &lt;code&gt;d}&lt;/code&gt; and expecting Vim to delete the fold below completely, like on the screen shot below (as it would do, if no empty lines were in the fold):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EoSOl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EoSOl.png&quot; alt=&quot;expected result of deletion of a fold&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead this happens (the last line of the fold has not been deleted):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SfUW1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SfUW1.png&quot; alt=&quot;the last line of the fold has not been deleted&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I'm doing the opposite motion to delete backwards (in this example the cursor is on the last line in the file), I'm expecting Vim to delete the previous fold (the one above), like here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QOjDz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QOjDz.png&quot; alt=&quot;delete the previous fold&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead this happens (the text has been deleted up to the first encountered empty line):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WgU8X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WgU8X.png&quot; alt=&quot;the fold has not been fully deleted&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked into the docs &lt;code&gt;:h 'foldopen'&lt;/code&gt; and haven't understood well what this means:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When a movement command is used for an operator (e.g., &quot;dl&quot; or &quot;y%&quot;)&#xA;  this option is not used.  This means the operator will include the&#xA;  whole closed fold.&#xA;  Note that vertical movements are not here, because it would make it&#xA;  very difficult to move onto a closed fold.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I thought that vertical motions are not supported with the operator commands, as this seemingly states, but, for instance, &lt;code&gt;d3j&lt;/code&gt; did the job. Isn't &lt;code&gt;j&lt;/code&gt; a vertical movement command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anyone tell me, please, how and if can I use the &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; motions with operator commands, especially &lt;code&gt;d&lt;/code&gt;? Thank you.&lt;/p&gt;&#xA;" OwnerUserId="2798" LastEditorUserId="2798" LastEditDate="2017-06-23T21:24:32.107" LastActivityDate="2017-06-23T21:24:32.107" Title="how to delete a paragraph respecting the folds?" Tags="|cut-copy-paste|cursor-motions|folding|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12718" PostTypeId="2" ParentId="12680" CreationDate="2017-06-23T23:33:39.830" Score="2" Body="&lt;p&gt;Here is a single command to do it (starting in Normal mode, on the line you want to modify):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I&amp;lt;c-w&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This switches to Insert mode and positions the cursor on the first non-whitespace character. Ctrl-w will then delete to the beginning of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can then be &lt;code&gt;.&lt;/code&gt; repeated on any other line, from any column.&lt;/p&gt;&#xA;" OwnerUserId="13164" LastActivityDate="2017-06-23T23:33:39.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12719" PostTypeId="1" AcceptedAnswerId="12720" CreationDate="2017-06-24T13:54:14.790" Score="3" ViewCount="3826" Body="&lt;p&gt;I know that to source my current file I need to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :so ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But is it possible to source the current file without mentioning its name?&lt;/p&gt;&#xA;" OwnerUserId="13172" LastEditorUserId="51" LastEditDate="2017-06-24T23:22:00.090" LastActivityDate="2017-06-24T23:22:00.090" Title="source the current file" Tags="|vimrc|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12720" PostTypeId="2" ParentId="12719" CreationDate="2017-06-24T14:11:35.853" Score="10" Body="&lt;p&gt;&lt;code&gt;:so %&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%&lt;/code&gt; refers the current buffer's filename. This works not just for &lt;code&gt;:source&lt;/code&gt;, but for all of the commandline; see &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#cmdline-special&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help cmdline-special&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="51" LastEditDate="2017-06-24T23:21:23.827" LastActivityDate="2017-06-24T23:21:23.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12721" PostTypeId="1" CreationDate="2017-06-24T16:07:57.853" Score="1" ViewCount="39" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/vim-syntastic/syntastic/blob/master/doc/syntastic.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;Syntastic Plugin&lt;/a&gt; populates the location list with syntax error locations. If navigating these with &lt;code&gt;:lnext&lt;/code&gt;, after reaching the end of the file, &lt;code&gt;Vim&lt;/code&gt; raises the error &lt;code&gt;E553: No more items&lt;/code&gt;. Instead, I would like it to continue at the &lt;strong&gt;top&lt;/strong&gt; of the file, like when navigating search matches, and jump to the syntax errors starting from the beginning. How can I make this happen?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastActivityDate="2017-06-24T16:07:57.853" Title="Can I make the :lnext, :lprev commands continue at TOP/BOTTOM after reaching the end/beginning of the location list?" Tags="|plugin-system|plugin-syntastic|" AnswerCount="0" CommentCount="0" ClosedDate="2017-06-26T15:28:53.847" ContentLicense="CC BY-SA 3.0" />
  <row Id="12722" PostTypeId="1" CreationDate="2017-06-25T13:19:47.410" Score="1" ViewCount="719" Body="&lt;p&gt;I have a text file with this format...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;011000 001i 1111&#xA;011001 001i 0001&#xA;011010 001i 1111&#xA;011011 001i 1011&#xA;011100 001i 1111&#xA;011101 001i 1111&#xA;011110 001i 1001&#xA;011111 001i 1111&#xA;100000 001i 1111&#xA;100001 001i 1110&#xA;100001 000i 1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Columns 1 and 3 are binary values which I would like to convert to hexadecimal (e.g. 011000 becomes 0x18, 1011 becomes 0xB).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This file will eventually be a C language header file (*.h) and the C language doesn't accept binary literals as far as I know without messing about with macros.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; and then use the arrow keys to highlight a column of binary values, is there a set of Vim commands that can automatically go through and convert them all to hexadecimal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The file isn't so large that I can't do it by hand but I'd love to know if there's a neat way to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: If possible, solutions for Vim version 7.4.160 or earlier would be preferred but of course not mandatory. :)&lt;/p&gt;&#xA;" OwnerUserId="6461" LastEditorUserId="51" LastEditDate="2017-06-25T21:08:33.437" LastActivityDate="2017-06-27T11:30:28.500" Title="Convert a column of binary integers to hexadecimal format?" Tags="|substitute|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12723" PostTypeId="2" ParentId="12722" CreationDate="2017-06-25T14:53:27.827" Score="1" Body="&lt;p&gt;Something like this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\(\d\+\)\s\+\(\S\+\)\s\+\(\d\+\)/\=printf(&quot;0x%X %s 0x%02X&quot;, str2nr(submatch(1),2), submatch(2), str2nr(submatch(3),2))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses a &lt;code&gt;:s&lt;/code&gt; command, captures each column and then converts column 1 and 3 to hexadecimal by using a &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;\= sub-replace-expression&lt;/a&gt; and the functions &lt;code&gt;str2nr()&lt;/code&gt; and &lt;code&gt;printf()&lt;/code&gt; are evaluated for each match.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-06-25T14:53:27.827" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12724" PostTypeId="1" CreationDate="2017-06-25T19:49:24.493" Score="0" ViewCount="151" Body="&lt;p&gt;In Ruby, and languages based on Ruby the style-guide recommends bool getter methods be named &lt;code&gt;empty?&lt;/code&gt; as opposed to &lt;code&gt;is_empty&lt;/code&gt;. Note the question mark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim however, does not complete the &lt;code&gt;?&lt;/code&gt; by default. Is there a setting to enable this? Or a plugin?&lt;/p&gt;&#xA;" OwnerUserId="13185" LastEditorUserId="51" LastEditDate="2017-06-25T21:52:42.993" LastActivityDate="2017-06-25T22:01:17.637" Title="Does vim have functionality for completetion of methods/variables with punctuation?" Tags="|autocompletion|filetype-ruby|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12725" PostTypeId="2" ParentId="12722" CreationDate="2017-06-25T21:50:20.647" Score="1" Body="&lt;p&gt;While this is certainly possible with Vim(Script), I would personally write a small external script for this. It's just easier. My poison of choice for this is usually Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python&#xA;import sys&#xA;&#xA;while True:&#xA;    line = sys.stdin.readline()&#xA;    if line == '':&#xA;        break&#xA;    l = line.split(' ')&#xA;    print('{} {} {}'.format(hex(int(l[0], 2)),&#xA;                            l[1],&#xA;                            hex(int(l[2], 2))))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We can use&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Arange%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:[range]!command&lt;/code&gt; &lt;/a&gt; because this script reads from stdin; for example for the entire buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!./a.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or for the visual selection (just select and press &lt;code&gt;:&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!./a.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can use Vim's &lt;a href=&quot;http://vimhelp.appspot.com/if_pyth.txt.html#python&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;python interface&lt;/code&gt;&lt;/a&gt; if you don't want to use an external script. I personally like external scripts because they don't require a special API and are easy to write, debug, and reuse (&quot;&lt;a href=&quot;http://catb.org/~esr/writings/taoup/html/ch01s06.html#id2877684&quot; rel=&quot;nofollow noreferrer&quot;&gt;Rule of Composition&lt;/a&gt;&quot;).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-06-25T21:50:20.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12726" PostTypeId="2" ParentId="12724" CreationDate="2017-06-25T22:01:17.637" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27iskeyword%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;iskeyword&lt;/code&gt;&lt;/a&gt; setting controls this. You can add &lt;code&gt;?&lt;/code&gt; and &lt;code&gt;!&lt;/code&gt; to it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setlocal iskeyword+=? iskeyword+=!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, for just Ruby from your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup ruby_settings&#xA;    autocmd!&#xA;    autocmd Filetype Ruby :setlocal iskeyword+=? iskeyword+=!&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do &lt;strong&gt;not&lt;/strong&gt; use &lt;code&gt;set iskeyword=..&lt;/code&gt; from your vimrc, as that will likely lead to problems with other filetypes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;iskeyword&lt;/code&gt; setting is used for many commands; for example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;dw&lt;/code&gt; would previously delete up to a &lt;code&gt;?&lt;/code&gt;, but now it will &lt;em&gt;also&lt;/em&gt; delete the &lt;code&gt;?&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gf&lt;/code&gt; will now also match &lt;code&gt;?&lt;/code&gt;, so &lt;code&gt;gf&lt;/code&gt; on &lt;code&gt;# is this file correct: a.rb?&lt;/code&gt; will try to open &lt;code&gt;a.rb?&lt;/code&gt; (which won't exist).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;*&lt;/code&gt; will match the word with question-mark.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are many more cases; the above list is not exhaustive. Some of these behaviours could be considered features, others might be considered bugs. Personally, I've learned to not frob with &lt;code&gt;iskeyword&lt;/code&gt; too much (in part because I like my &lt;code&gt;dw&lt;/code&gt; etc. to behave the same regardless of filetype), but others like to modify it extensively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just remember: if you run into &lt;em&gt;Weird Problems&lt;/em&gt;™ later on then your frobbery with the &lt;code&gt;iskeyword&lt;/code&gt; setting could very well be the cause!&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-06-25T22:01:17.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12727" PostTypeId="2" ParentId="2015" CreationDate="2017-06-26T12:56:19.517" Score="4" Body="&lt;p&gt;I usually end up using &lt;a href=&quot;https://linux.die.net/man/1/xsel&quot; rel=&quot;nofollow noreferrer&quot;&gt;xsel&lt;/a&gt; to copy to/from the system clipboard:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;leader&amp;gt;y !xsel -i -b &amp;amp;&amp;amp; xsel -b &amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;p :r !xsel -b &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13192" LastActivityDate="2017-06-26T12:56:19.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12729" PostTypeId="1" AcceptedAnswerId="12733" CreationDate="2017-06-26T18:59:35.447" Score="6" ViewCount="815" Body="&lt;p&gt;In Python3, &lt;code&gt;file&lt;/code&gt; is no longer a builtin. It's just a plain ol' name that isn't even associated with anything until you do. But all the syntax files that I've used have it as a builtin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simple way (I checked &lt;code&gt;:help syn&lt;/code&gt; to look for an antonym, but nothing jumped out at me) to remove &lt;code&gt;file&lt;/code&gt; from the syntax category, or do I pretty much just have to define my own?&lt;/p&gt;&#xA;" OwnerUserId="5574" LastActivityDate="2022-06-10T18:46:09.477" Title="How can I remove a syntax keyword?" Tags="|syntax-highlighting|filetype-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12730" PostTypeId="2" ParentId="12703" CreationDate="2017-06-26T20:58:28.823" Score="1" Body="&lt;p&gt;I think you just have to put the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:NERDTreeToggle=&quot;&amp;lt;leader&amp;gt;q&quot;&#xA;let g:NERDTreeMapActivateNode=&quot;&amp;lt;leader&amp;gt;w&quot;&#xA;let g:NERDTreeMapPreview=&quot;&amp;lt;leader&amp;gt;e&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;assuming that &lt;code&gt;\&lt;/code&gt; is your leader, which it is by default.&lt;/p&gt;&#xA;" OwnerUserId="13009" LastActivityDate="2017-06-26T20:58:28.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12731" PostTypeId="1" AcceptedAnswerId="12735" CreationDate="2017-06-26T22:30:41.017" Score="42" ViewCount="24758" Body="&lt;p&gt;I understand it's the place to put things that should have the final say and not be overridden by another source, but I'm unclear on how to decide when to put something in, say, &lt;code&gt;~/.vim/after/ftplugin/&lt;/code&gt; rather than &lt;code&gt;~/.vim/ftplugin/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do people generally use &lt;code&gt;~/.vim/ftplugin/&lt;/code&gt; and only move stuff into &lt;code&gt;~/.vim/after/ftplugin/&lt;/code&gt; if they observe unwanted behavior, or do they just put it all in the after-directory right away?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2021-06-18T15:51:00.893" Title="When to use the after/ directory?" Tags="|options|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12732" PostTypeId="2" ParentId="12731" CreationDate="2017-06-26T22:42:14.063" Score="3" Body="&lt;p&gt;if vanilla vim recognizes a certain filetype and you want to modify the shipped behavior then your own settings go into &lt;code&gt;~/.vim/after/ftplugin/&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-06-26T22:42:14.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12733" PostTypeId="2" ParentId="12729" CreationDate="2017-06-26T22:46:12.650" Score="5" Body="&lt;p&gt;(&lt;em&gt;Note: the Python 2 keywords were removed in February 2021 with Vim &lt;a href=&quot;https://github.com/vim/vim/commit/9faec4e3d#diff-70532bfa8e84bebf0348b1ca9c76559c4c5997dc1853cf3dbdb0944ac315adc5L212&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.2.2554&lt;/a&gt;&lt;/em&gt;).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;You'll have to look at the syntax file and undo what it's doing. You can find the syntax file with &lt;code&gt;:e $VIMRUNTIME/syntax/python.vim&lt;/code&gt;, and with &lt;code&gt;/file&lt;/code&gt; I found:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Python 2 only&#xA;syn keyword pythonBuiltin     basestring cmp execfile file&#xA;syn keyword pythonBuiltin     long raw_input reduce reload unichr&#xA;syn keyword pythonBuiltin     unicode xrange&#xA;&#xA;[..]&#xA;&#xA;&amp;quot; non-essential built-in functions; Python 2 only&#xA;syn keyword pythonBuiltin     apply buffer coerce intern&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As far as I know there is no way to remove keywords from the &lt;code&gt;syn keyword&lt;/code&gt; declaration, so you'll have to either:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Clear the &lt;code&gt;pythonBuiltin&lt;/code&gt; declarations with &lt;code&gt;:syn clear pythonBuiltin&lt;/code&gt; and define your own with just the Python 3 ones: &lt;code&gt;syn keyword pythonBuiltin abs all any [...]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Override the Python 3 ones; e.g. &lt;code&gt;:syn keyword pythonTwoBuiltin file&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The first method is arguably a bit &amp;quot;cleaner&amp;quot;, but with the second method you will retain future additions to &lt;code&gt;pythonBuiltin&lt;/code&gt; from the system's file. It will also allow you to do something like &lt;code&gt;:hi link pythonTwoBuiltin pythonBuiltin&lt;/code&gt; to highlight the Python 2 builtins in case you find yourself editing Python 2 code.&lt;/p&gt;&#xA;&lt;p&gt;I would personally opt for the second method, and added this to my vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Remove Python 2 keywords.&#xA;augroup angering_zed_shaw&#xA;    autocmd!&#xA;    autocmd Syntax python&#xA;        \ syn keyword pythonTwoBuiltin basestring cmp execfile file long&#xA;        \                              raw_input reduce reload unichr unicode&#xA;        \                              xrange apply buffer coerce intern&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note you can't just add this to your vimrc file; you'll have to use an autocmd or the &lt;code&gt;~/.vim/after/syntax/python.vim&lt;/code&gt; file. See &lt;a href=&quot;https://vi.stackexchange.com/q/4975/51&quot;&gt;How can I add additional syntax highlighting rules in my local vimrc?&lt;/a&gt; for details on that.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2022-06-10T18:46:09.477" LastActivityDate="2022-06-10T18:46:09.477" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="12734" PostTypeId="1" AcceptedAnswerId="12750" CreationDate="2017-06-27T00:35:50.230" Score="1" ViewCount="214" Body="&lt;p&gt;My attempt so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Essay mode&#xA;nnoremap &amp;lt;F5&amp;gt; :call Toggle_essay()&amp;lt;CR&amp;gt;&#xA;function Toggle_essay()&#xA;    if &amp;amp;linebreak&#xA;        setlocal columns=999&#xA;        setlocal nolinebreak&#xA;    else&#xA;        setlocal columns=60&#xA;        setlocal linebreak&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to map a single button to toggle between &lt;code&gt;columns=60&lt;/code&gt;, and &lt;code&gt;columns=[terminal width]&lt;/code&gt;, or whatever was the default when vim is first opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Issue is that &lt;code&gt;!tput cols&lt;/code&gt; &lt;a href=&quot;https://stackoverflow.com/questions/37950595/get-columns-in-terminal-in-vim&quot;&gt;always returns 80&lt;/a&gt;, &lt;code&gt;$COLUMNS&lt;/code&gt; &lt;a href=&quot;https://stackoverflow.com/questions/1780483/lines-and-columns-environmental-variables-lost-in-a-script&quot;&gt;are not exported to vim&lt;/a&gt;, and I'm uncertain about the behaviour for window splits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Surely there's a command equivalent to return columns to its default on-start behaviour?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="13201" LastEditorUserId="1841" LastEditDate="2017-06-27T07:02:56.980" LastActivityDate="2017-06-28T07:52:02.010" Title="How to toggle between columns=60 and columns=[terminal_width]?" Tags="|key-bindings|vimscript|terminal|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12735" PostTypeId="2" ParentId="12731" CreationDate="2017-06-27T00:53:57.213" Score="52" Body="&lt;p&gt;Generally, if you want to add your own plugin, or &lt;em&gt;replace&lt;/em&gt; a standard plugin with your own, it would go into &lt;code&gt;~/.vim/plugin&lt;/code&gt; or &lt;code&gt;~/.vim/ftplugin&lt;/code&gt;. If instead you want to keep the functionality of an existing plugin but add to it, or change just a few settings made by it, then your plugin would go into &lt;code&gt;~/.vim/after/plugin&lt;/code&gt; or &lt;code&gt;~/.vim/after/ftplugin&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-06-27T00:53:57.213" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12736" PostTypeId="2" ParentId="12734" CreationDate="2017-06-27T01:37:00.183" Score="1" Body="&lt;p&gt;It seems to me that explicitly storing the state in a buffer-local variable would be easiest. We also double this state variable to hold the previous value of &lt;code&gt;columns&lt;/code&gt;, so it can be restored later:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Toggle_essay()&#xA;        if !exists('b:essay_mode')&#xA;                let b:essay_mode = &amp;amp;columns&#xA;                setlocal columns=60 linebreak&#xA;        else&#xA;                setlocal nolinebreak&#xA;                let &amp;amp;l:columns =  b:essay_mode&#xA;                unlet b:essay_mode&#xA;        endif&#xA;endfun&#xA;&#xA;nnoremap &amp;lt;F5&amp;gt; :call Toggle_essay()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-06-27T01:37:00.183" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12737" PostTypeId="2" ParentId="12722" CreationDate="2017-06-27T08:18:24.310" Score="1" Body="&lt;p&gt;My reputation is too low to comment on Christian's answer, so I modified his answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\(\d\+\)\s\+\(\S\+\)\s\+\(\d\+\)/\=printf(&quot;0x%X %s 0x%02X&quot;, str2nr('0b' . submatch(1)), submatch(2), str2nr('0b' . submatch(3)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This version does not use the &lt;code&gt;base&lt;/code&gt; parameter to &lt;code&gt;str2nr()&lt;/code&gt;, but puts a &lt;code&gt;'0b'&lt;/code&gt; prefix in front of the binary values.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastEditorUserId="2636" LastEditDate="2017-06-27T11:30:28.500" LastActivityDate="2017-06-27T11:30:28.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12738" PostTypeId="1" AcceptedAnswerId="12786" CreationDate="2017-06-27T08:44:50.017" Score="3" ViewCount="191" Body="&lt;p&gt;From &lt;code&gt;:h Partial&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A Funcref optionally binds a Dictionary and/or arguments.  This is also called&#xA;a Partial.  This is created by passing the Dictionary and/or arguments to&#xA;function() or funcref().  When calling the function the Dictionary and/or&#xA;arguments will be passed to the function.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To which concept does the term &lt;code&gt;Partial&lt;/code&gt; refer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had some ideas, but I don't know which one, if any, is the right one:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;maybe it's called a &lt;code&gt;Partial&lt;/code&gt;, because it's &lt;strong&gt;partially&lt;/strong&gt; a function (the one to which the funcref refers), and &lt;strong&gt;partially&lt;/strong&gt; data (the list of arguments or the dictionary, which are bound to the funcref)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;the data are &lt;strong&gt;partially&lt;/strong&gt; linked to the function; maybe we could bind them to another function&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;the list of arguments that the partial binds could be only a subset of the arguments used by the function to which the funcref refers; therefore, they're only a &lt;strong&gt;part&lt;/strong&gt; of its arguments&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13032" LastActivityDate="2017-06-30T05:41:04.320" Title="To which concept does the term `partial` refer?" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12740" PostTypeId="1" AcceptedAnswerId="12741" CreationDate="2017-06-27T12:12:33.983" Score="7" ViewCount="1861" Body="&lt;p&gt;From the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable1 = 'example'&#xA;foo = 'foo'&#xA;barett = 'ver'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to yank (or visually select, if possible) the content of each line until the &lt;code&gt;=&lt;/code&gt; sign:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable1&#xA;foo&#xA;barett&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is: &quot;yank/visually select the contents of the following lines, stopping the yanking/selection in each line as soon as an &lt;code&gt;=&lt;/code&gt; character is found&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I were dealing with a single line it would be simple&gt; from the beginning of the line: &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I have no clue how to do this with multiple lines (and visual block won't help since I don't want the same number of characters from each line).&lt;/p&gt;&#xA;" OwnerUserId="12266" LastActivityDate="2022-06-13T22:10:20.353" Title="Yank/select until delimiter in different lines" Tags="|cut-copy-paste|visual-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12741" PostTypeId="2" ParentId="12740" CreationDate="2017-06-27T12:35:56.660" Score="4" Body="&lt;p&gt;I'm not sure this is what you want, but you could try this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xno my y'&amp;gt;pV']:s/=.*//&amp;lt;cr&amp;gt;gvd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use it, you would visually select your lines, then hit &lt;code&gt;my&lt;/code&gt;. It should write the text before the &lt;code&gt;=&lt;/code&gt; character on each line of your selection, inside the unnamed register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what it does:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt; yanks the selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;gt;&lt;/code&gt; moves the cursor to the last line of the selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; puts the unnamed register, where currently the last yanked text is&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt; goes into visual line mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;']&lt;/code&gt; moves the end of the selection down to the last line of the last text on which you performed an operation (here the yanking)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:s/=.*//&amp;lt;cr&amp;gt;&lt;/code&gt; removes everything after the &lt;code&gt;=&lt;/code&gt; character, on each line of the selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gv&lt;/code&gt; reselects the last selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d&lt;/code&gt; deletes it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13032" LastEditorUserId="13032" LastEditDate="2017-06-27T12:51:24.270" LastActivityDate="2017-06-27T12:51:24.270" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12742" PostTypeId="1" AcceptedAnswerId="12743" CreationDate="2017-06-27T13:10:39.810" Score="2" ViewCount="151" Body="&lt;p&gt;Following &lt;a href=&quot;https://vi.stackexchange.com/questions/12740/yank-select-until-delimiter-in-different-lines/12741#12741&quot;&gt;this question&lt;/a&gt;: the answer suggests to map a particular command to a key sequence. It assumes that the delimiter will always be &lt;code&gt;=&lt;/code&gt;, but I would like to make no assumptions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to add a useful remap which allows me to dynamically specify the delimiter: I'd like to remap (while in visual mode) &lt;kbd&gt;Leader&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;...&lt;kbd&gt;Enter&lt;/kbd&gt; to &lt;code&gt;y'&amp;gt;pV']:s/PATTERN.*//&amp;lt;cr&amp;gt;gvd&lt;/code&gt;, where PATTERN is whatever keys I pressed between &lt;kbd&gt;t&lt;/kbd&gt; and &lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is that I can use &lt;kbd&gt;Leader&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt; to deal with text like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;h:1&#xA;width:3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;kbd&gt;Leader&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt; to deal with text like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;h=1&#xA;width=3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What should be added to vimrc for this mapping to work?&lt;/p&gt;&#xA;" OwnerUserId="12266" LastActivityDate="2017-06-27T14:08:10.087" Title="Define keybinding which uses arbitrary keys" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12743" PostTypeId="2" ParentId="12742" CreationDate="2017-06-27T13:33:49.277" Score="2" Body="&lt;p&gt;Maybe you could try this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xno &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;yt &quot;y'&amp;gt;pV']:s/&quot;.input('pattern: ').&quot;.*//&amp;lt;cr&amp;gt;gvd&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses the &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; argument, which means that when you type &lt;code&gt;&amp;lt;leader&amp;gt;yt&lt;/code&gt;, Vim doesn't expand it into the &lt;code&gt;{rhs}&lt;/code&gt; directly, the latter is first evaluated as an expression, then the evaluation is used as the keys to type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, the &lt;code&gt;{rhs}&lt;/code&gt; is almost the same as the one in your question, with one difference. Instead of using the pattern &lt;code&gt;=.*&lt;/code&gt;, the &lt;code&gt;input()&lt;/code&gt; function is invoked to let you type an arbitrary pattern. It should return whatever you type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with this mapping, is that if your pattern isn't in the selection, it will duplicate it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, maybe you need a little more logic to test whether the pattern is found, and if so the expression should return the right keys, otherwise don't return anything:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xno &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;yt &amp;lt;sid&amp;gt;copy_before_pattern()&#xA;&#xA;fu! s:copy_before_pattern() abort&#xA;    let pattern = input('pattern: ')&#xA;    return search(pattern, 'cnW', line(&quot;'&amp;gt;&quot;))&#xA;                \ ? &quot;y'&amp;gt;pV']:s/&quot;.pattern.&quot;.*//\&amp;lt;cr&amp;gt;gvd&quot;&#xA;                \ : ''&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the logic is wrapped inside a function, which should test whether the pattern is somewhere in the selection, before returning the keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't test it very long, so it may not work all the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know why, but sometimes the key binding doesn't do anything on my machine. If you experience the same issue, here's an alternative, which seemed more reliable during the little time I tested it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xno &amp;lt;leader&amp;gt;yt &amp;lt;esc&amp;gt;:call &amp;lt;sid&amp;gt;copy_before_pattern()&amp;lt;cr&amp;gt;&#xA;&#xA;fu! s:copy_before_pattern() abort&#xA;    let pattern = input('pattern: ')&#xA;    norm! '&amp;lt;&#xA;    if search(pattern, 'cnW', line(&quot;'&amp;gt;&quot;))&#xA;        exe &quot;norm! y'&amp;gt;pV']:s/&quot;.pattern.&quot;.*//\&amp;lt;cr&amp;gt;gvd&quot;&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13032" LastEditorUserId="13032" LastEditDate="2017-06-27T14:08:10.087" LastActivityDate="2017-06-27T14:08:10.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12745" PostTypeId="1" AcceptedAnswerId="12747" CreationDate="2017-06-27T15:02:43.953" Score="3" ViewCount="315" Body="&lt;p&gt;If I source:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let Mydict = { 'data': [0, 1, 2, 3] }&#xA;fu! Mydict.mylen()&#xA;    return len(self.data)&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, I can execute &lt;code&gt;echo Mydict.mylen()&lt;/code&gt; which returns &lt;code&gt;4&lt;/code&gt; because it's the length of the list &lt;code&gt;[0,1,2,3]&lt;/code&gt;. I didn't have to give the &lt;code&gt;dict&lt;/code&gt; attribute to the function &lt;code&gt;Mydict.mylen()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If I source:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! MyFunc() dict&#xA;    return len(self.data)&#xA;endfu&#xA;let mydict = { 'data': [0, 1, 2, 3], 'mylen': function('MyFunc') }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, I can execute &lt;code&gt;echo mydict.mylen()&lt;/code&gt; which, again, returns &lt;code&gt;4&lt;/code&gt;, for the same reason as before. However, this time, I had to give the &lt;code&gt;dict&lt;/code&gt; attribute to the function &lt;code&gt;MyFunc()&lt;/code&gt;. Without &lt;code&gt;dict&lt;/code&gt;, it would have raised the errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E121: Undefined variable: self&#xA;E116: Invalid arguments for function len(self.data)&#xA;E15: Invalid expression: len(self.data)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If I source:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! Order() dict&#xA;    echo 'eat your ' . self.name&#xA;endfu&#xA;let food       = { 'name': 'vegetables' }&#xA;let BuildOrder = function('Order', food)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, I can execute &lt;code&gt;call BuildOrder()&lt;/code&gt;, which displays &lt;code&gt;eat your vegetables&lt;/code&gt;. I had to give the &lt;code&gt;dict&lt;/code&gt; attribute to the function &lt;code&gt;Order()&lt;/code&gt;, for the same reason as before.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If I source:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! Describe(count, adj) dict&#xA;    echo a:count.' '.a:adj.' '. self.name&#xA;endfu&#xA;let animal      = { 'name': 'piggies' }&#xA;let Description = function('Describe', [ 3 ], animal)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, I can execute &lt;code&gt;call Description('little')&lt;/code&gt;, which displays &lt;code&gt;3 little piggies&lt;/code&gt;. And again, I had to give the &lt;code&gt;dict&lt;/code&gt; attribute to the &lt;code&gt;Describe()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;dict&lt;/code&gt; is only needed in the last 3 of the 4 previous snippets. What does Vim do internally, which explains that &lt;code&gt;dict&lt;/code&gt; is not needed in the first one, but is in all the others?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And whatever it does, why doesn't it do it in the last 3 snippets? What would happen if it did it all the time, or never?&lt;/p&gt;&#xA;" OwnerUserId="13032" LastEditorUserId="13032" LastEditDate="2017-06-27T15:14:24.937" LastActivityDate="2017-06-27T16:13:39.437" Title="How is the `dict` attribute processed internally?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12746" PostTypeId="1" AcceptedAnswerId="12751" CreationDate="2017-06-27T16:12:42.617" Score="2" ViewCount="59" Body="&lt;p&gt;From &lt;code&gt;:h function(&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    {name} can also be a Funcref or a partial.  When it is a&#xA;    partial the dict stored in it will be used and the {dict}&#xA;    argument is not allowed. E.g.:&#xA;        let FuncWithArg = function(dict.Func, [arg])&#xA;        let Broken = function(dict.Func, [arg], dict)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The examples are incomplete, so I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let dict = { 'name': 'trees' }&#xA;fu! dict.Func(n)&#xA;    echo a:n.' '.self.name&#xA;endfu&#xA;let FuncWithArg = function(dict.Func, [3])&#xA;call FuncWithArg()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works as expected and displays &lt;code&gt;3 trees&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let Broken = function(dict.Func, [3], dict)&#xA;call Broken()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works too, and displays &lt;code&gt;3 trees&lt;/code&gt;. But if this example is really equivalent to the one given in the help, it shouldn't work, since the help says that &lt;code&gt;the {dict} argument is not allowed&lt;/code&gt;, when &lt;code&gt;{name}&lt;/code&gt; is a partial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the reason why it works, while it shouldn't, is because in my example, &lt;code&gt;dict.Func&lt;/code&gt; isn't a partial.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So, I tried to rewrite these 2 examples, so that &lt;code&gt;dict.Func&lt;/code&gt; is a partial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! MyFunc(i,j) dict&#xA;    echo (a:i + a:j).' '. self.name&#xA;endfu&#xA;&#xA;let dict = { 'name': 'trees', 'Func': function('MyFunc', [1]) }&#xA;&#xA;let FuncWithArg = function(dict.Func, [2])&#xA;call FuncWithArg()&#xA;&#xA;let Broken = function(dict.Func, [2], dict)&#xA;call Broken()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both commands, &lt;code&gt;call FuncWithArg()&lt;/code&gt; and &lt;code&gt;call Broken()&lt;/code&gt;, work and display &lt;code&gt;3 trees&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But again, the 2nd one shouldn't work according to &lt;code&gt;the {dict} argument is not allowed&lt;/code&gt;. So, I thought that maybe what the help meant was not:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let Broken = function(dict.Func, [arg], dict)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… but:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let Broken = function(dict.Func, [arg], other_dict)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, I tried to find another example where &lt;code&gt;dict&lt;/code&gt; is replaced with &lt;code&gt;other_dict&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! MyFunc(i,j) dict&#xA;    echo (a:i + a:j).' '. self.name&#xA;endfu&#xA;&#xA;let dict       = { 'name': 'trees', 'Func': function('MyFunc', [1]) }&#xA;let other_dict = { 'name': 'mountains', 'Func': function('MyFunc', [1]) }&#xA;&#xA;let FuncWithArg = function(dict.Func, [2])&#xA;call FuncWithArg()&#xA;&#xA;let Broken = function(dict.Func, [2], other_dict)&#xA;call Broken()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both commands, &lt;code&gt;call FuncWithArg()&lt;/code&gt; and &lt;code&gt;call Broken()&lt;/code&gt;, work and display &lt;code&gt;3 trees&lt;/code&gt; and &lt;code&gt;3 mountains&lt;/code&gt; respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't been able to come up with an example where &lt;code&gt;call Broken()&lt;/code&gt; would raise an error. Can someone provide one?&lt;/p&gt;&#xA;" OwnerUserId="13032" LastActivityDate="2017-06-28T04:01:02.017" Title="Which example shows that the `dict` argument is not allowed when `{name}` is a partial, inside a `function()` call?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12747" PostTypeId="2" ParentId="12745" CreationDate="2017-06-27T16:13:39.437" Score="6" Body="&lt;p&gt;This is described at &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#Dictionary-function&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help Dictionary-function&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                *Dictionary-function* *self* *E725* *E862*&#xA;When a function is defined with the &quot;dict&quot; attribute it can be used in a&#xA;special way with a dictionary.  Example: &amp;gt;&#xA;    :function Mylen() dict&#xA;    :   return len(self.data)&#xA;    :endfunction&#xA;    :let mydict = {'data': [0, 1, 2, 3], 'len': function(&quot;Mylen&quot;)}&#xA;    :echo mydict.len()&#xA;&#xA;This is like a method in object oriented programming.  The entry in the&#xA;Dictionary is a |Funcref|.  The local variable &quot;self&quot; refers to the dictionary&#xA;the function was invoked from.&#xA;&#xA;It is also possible to add a function without the &quot;dict&quot; attribute as a&#xA;Funcref to a Dictionary, but the &quot;self&quot; variable is not available then.&#xA;&#xA;                *numbered-function* *anonymous-function*&#xA;To avoid the extra name for the function it can be defined and directly&#xA;assigned to a Dictionary in this way: &amp;gt;&#xA;    :let mydict = {'data': [0, 1, 2, 3]}&#xA;    :function mydict.len()&#xA;    :   return len(self.data)&#xA;    :endfunction&#xA;    :echo mydict.len()&#xA;&#xA;The function will then get a number and the value of dict.len is a |Funcref|&#xA;that references this function.  The function can only be used through a&#xA;|Funcref|.  It will automatically be deleted when there is no |Funcref|&#xA;remaining that refers to it.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both approaches define a function which will have access to their containing dict via the name &lt;code&gt;self&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;function mydict.len&lt;/code&gt; approach is just syntactic sugar to define the functions directly in the dictionary.  You can still assign that function to other dictionaries:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let otherdict = { 'data': [0, 1], 'len': function(mydict.len) }&#xA;:echo otherdict.len()&#xA;2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-06-27T16:13:39.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12748" PostTypeId="2" ParentId="5989" CreationDate="2017-06-27T18:32:57.273" Score="4" Body="&lt;p&gt;I had the exact same desire as you: I wanted to write normal vim commands and have those edit a pipeline stream. I was disappointed by the difficulty of using normal vim in this way (so many flags!), as provided by the default vim options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, I wrote a small wrapper on vim to do it: &lt;a href=&quot;https://github.com/MilesCranmer/vim-stream/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/MilesCranmer/vim-stream/&lt;/a&gt;. It's called &lt;code&gt;vims&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The heart of the wrapper is the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim - -nes &quot;${vim_cmds[@]}&quot; -c ':q!' | tail -n +2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using this, with the command generation I do, it works out to be quite concise, and because vim is a modal editor, I made &lt;code&gt;vims&lt;/code&gt; a modal stream editor. There are three main modes which are useful for with pipeline-editing mentality:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[-t|--turn-off-mode] - (Default mode)&#xA;                       Every string is a vim command line, e.g., '%g/foo/d' deletes&#xA;                       all lines with foo.&#xA;[-e|--exe-mode] -      Translated to '%g/$1/exe &quot;norm $2&quot;', see examples below&#xA;[-s|--simple-mode] -   Like exe-mode, but runs on 1st line only&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Watch this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo &quot;Hello World&quot; | vims -s &quot;ea Beautiful&quot;&#xA;Hello Beautiful World&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;e&lt;/code&gt; goes to the end of &lt;code&gt;Hello&lt;/code&gt;, then &lt;code&gt;a&lt;/code&gt; starts appending.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something fancier, in exe-mode, to comment out lines containing &lt;code&gt;my_bad_var&lt;/code&gt;, and delete the preceding line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat my_script.cpp | vims -e 'my_bad_var' 'I//\&amp;lt;esc&amp;gt;kdd'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which translates to &lt;code&gt;vims '%g/my_bad_var/exe &quot;norm I//\&amp;lt;esc&amp;gt;kdd&quot;'&lt;/code&gt; - the &lt;code&gt;I&lt;/code&gt; being the command&#xA;to start insert at the start of the line, and &lt;code&gt;//&lt;/code&gt; being the comment sequence.&#xA;&lt;code&gt;\&amp;lt;esc&amp;gt;kdd&lt;/code&gt; pushes the escape key, moves up a line, then deletes the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have 11 total examples on the repo, I encourage you to check them out. Again, this is running on top of vim, it's just a way to make vim more like sed for stream input (but preserving all your beloved vim macros!)&lt;/p&gt;&#xA;" OwnerUserId="12989" LastEditorUserId="12989" LastEditDate="2017-06-27T18:39:50.257" LastActivityDate="2017-06-27T18:39:50.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12750" PostTypeId="2" ParentId="12734" CreationDate="2017-06-27T23:24:21.200" Score="1" Body="&lt;p&gt;Use &lt;code&gt;columns&amp;amp;vim&lt;/code&gt; to set &lt;code&gt;columns&lt;/code&gt; to its default value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as explained &lt;a href=&quot;https://vi.stackexchange.com/questions/12734/how-to-toggle-between-columns-60-and-columns-terminal-width#comment21967_12734&quot;&gt;in the comments above&lt;/a&gt;, one should avoid changing columns. Rather, a combination of &lt;code&gt;textwidth=60&lt;/code&gt;, &lt;code&gt;textwidth=999&lt;/code&gt;, and &lt;code&gt;gggqG&amp;lt;C-o&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;, where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;gg&lt;/code&gt; – go to start;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gq&lt;/code&gt; – apply current formatting to all;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;G&lt;/code&gt; – go to end;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; – return cursor to previous position).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13201" LastEditorUserId="51" LastEditDate="2017-06-28T07:52:02.010" LastActivityDate="2017-06-28T07:52:02.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12751" PostTypeId="2" ParentId="12746" CreationDate="2017-06-28T04:01:02.017" Score="3" Body="&lt;p&gt;I don't think there is such an example. The help for &lt;code&gt;function()&lt;/code&gt; is the same as the help for three errors: E700, E922 and E923. None of these refer to a situation like the one the text seems to describe:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;E700: Unknown function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call function('six',[1],[1])&#xA;E700: Unknown function: six&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;E922: expected a dict&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call function('sin',[1],[1])&#xA;E922: expected a dict&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;E923: Second argument of function() must be a list or a dict&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call function('sin',1)&#xA;E923: Second argument of function() must be a list or a dict&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since no other errors are listed for &lt;code&gt;function()&lt;/code&gt;, I think the help is probably describing something like C's undefined behaviour rather than an explicit error.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-06-28T04:01:02.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12752" PostTypeId="2" ParentId="12518" CreationDate="2017-06-28T07:06:20.457" Score="5" Body="&lt;p&gt;Patch 8.0.0641 introduced a separate highlight group for the quickfix line, called QuickFixLine. With patch 8.0.0653 this group is linked to the Search highlight by default, because for some color schemes the colors chosen for patch 8.0.0641 did not work well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you have a current version of Vim you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi QuickFixLine cterm=None ctermbg=256 guibg=#ffff00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to make the current line in the quickfix window more distinguishable.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastActivityDate="2017-06-28T07:06:20.457" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12754" PostTypeId="1" AcceptedAnswerId="12755" CreationDate="2017-06-28T08:09:04.590" Score="3" ViewCount="732" Body="&lt;p&gt;I have a file which has the following structure&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;From: foo@example.org&#xA;Subject: Bar&#xA;Date: 2017-06-27&#xA;Mailbox: /some/dire/ctory&#xA;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Such a block always contains of four lines followed by an empty line. I want to delete all blocks which contain &lt;code&gt;Subject: Bar&lt;/code&gt;. In the past I recorded keystrokes and replayed them. So I searched for the string (&lt;code&gt;/Subject: Bar&lt;/code&gt;), hit &lt;code&gt;dap&lt;/code&gt; and replayed it. This took quite a while for larger files. Thatswhy I'm looking for another approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I delete blocks of text in vim when they contain a search pattern?&lt;/p&gt;&#xA;" OwnerUserId="2885" LastActivityDate="2017-06-28T08:23:27.247" Title="How to delete blocks of text which contain a specific string?" Tags="|search|command-line|register|repeated-commands|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12755" PostTypeId="2" ParentId="12754" CreationDate="2017-06-28T08:23:27.247" Score="6" Body="&lt;p&gt;You can use a macro:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once your search register is set to &lt;code&gt;Subject: Bar&lt;/code&gt; you can empty a register (&lt;code&gt;q&lt;/code&gt; in this example) and record the following macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqq&#xA;qqndap@qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first line empties the &lt;code&gt;q&lt;/code&gt; register, the second creates a macro like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq           start recording&#xA;n            go to next match&#xA;dap          delete the paragraph&#xA;@q           call the macro recursively&#xA;q            stop recording&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you simply need to play the macro once: &lt;code&gt;@q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could use a global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/Subject: bar/norm! dap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means: for each line matching &lt;code&gt;Subject: bar&lt;/code&gt; execute the ex command &lt;code&gt;norm! dap&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-06-28T08:23:27.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12756" PostTypeId="1" AcceptedAnswerId="12760" CreationDate="2017-06-28T09:02:16.173" Score="1" ViewCount="779" Body="&lt;p&gt;I'm on a server, and the server-administrator are really conservative about what I put on that server. It took bottles of wine, just to be able to put a .vimrc-file on there - so in order to install a plugin, then I assume I will have to give him my first-born child. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm editting these files that has CRAAAZY indentation. Tabs, spaces - you name it. I was looking for at way in my .vimrc-file to set up the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make all tabs one color.&lt;/li&gt;&#xA;&lt;li&gt;If there is 3 spaces in a row, then make them another color&lt;/li&gt;&#xA;&lt;li&gt;If there is 6 spaces in a row, then make them a third color&lt;/li&gt;&#xA;&lt;li&gt;if there is 9 spaces in a row, then make them a a fourth color&#xA;... etc. etc. etc. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This way, then I can make some pseudo-indentation-guides, that I can have on the server, and keep all my babies to myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This answer has something that comes close, but no cigar:  &lt;a href=&quot;https://vi.stackexchange.com/questions/666/how-to-add-indentation-guides-lines&quot;&gt;How to add indentation guides/lines&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9194" LastEditorUserId="9194" LastEditDate="2017-06-28T09:27:19.183" LastActivityDate="2017-06-28T11:43:26.207" Title="Indentation-guides in vim with pure .vimrc-magic (no plugins allowed)" Tags="|vimrc|indentation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12757" PostTypeId="1" AcceptedAnswerId="12758" CreationDate="2017-06-28T09:32:28.710" Score="1" ViewCount="430" Body="&lt;p&gt;I save quite a few lines into a named register &lt;code&gt;&quot;iy100l&lt;/code&gt;. I can then paste from that register just fine, &lt;code&gt;&quot;ip&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I close and reopen Vim then try to paste from that register again &lt;code&gt;&quot;ip&lt;/code&gt; but it's truncated to only 50 lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm guessing &lt;code&gt;.viminfo&lt;/code&gt; has a limit on the length of registers it will save but I couldn't find it documented. Is there a setting to increase the limit?&lt;/p&gt;&#xA;" OwnerUserId="13221" LastActivityDate="2017-06-28T10:48:21.870" Title="Viminfo truncates named registers. Setting to increase limit?" Tags="|register|viminfo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12758" PostTypeId="2" ParentId="12757" CreationDate="2017-06-28T09:40:54.403" Score="2" Body="&lt;p&gt;it can be configured with the &lt;code&gt;&quot;&lt;/code&gt; character of the &lt;code&gt;viminfo&lt;/code&gt; option&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help 'viminfo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;   Maximum number of lines saved for each register.  Old name of&#xA;    the '&amp;lt;' item, with the disadvantage that you need to put a&#xA;    backslash before the &quot;, otherwise it will be recognized as the&#xA;    start of a comment!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="11477" LastEditDate="2017-06-28T10:48:21.870" LastActivityDate="2017-06-28T10:48:21.870" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12759" PostTypeId="2" ParentId="12757" CreationDate="2017-06-28T10:36:49.537" Score="3" Body="&lt;p&gt;&lt;code&gt;:help viminfo&lt;/code&gt; contains general information on the feature but not settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help 'viminfo'&lt;/code&gt; (note the apostrophes) is the documentation on the actual option settings. The key bit is &lt;code&gt;&amp;lt;&lt;/code&gt; which sets the max lines saved per register. You are also forced to set a value for &lt;code&gt;'&lt;/code&gt; (max files marks are saved for). While I was at it I increased &lt;code&gt;s&lt;/code&gt; (max Kbytes saved per register).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the bit you stick in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set viminfo='50,&amp;lt;200,s100&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13221" LastActivityDate="2017-06-28T10:36:49.537" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12760" PostTypeId="2" ParentId="12756" CreationDate="2017-06-28T11:28:17.600" Score="5" Body="&lt;p&gt;So you want a custom plugin, that you can copy paste into your .vimrc and be done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this should do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyPoorIndentGuide(clear)&#xA;    if !exists(&quot;w:ids&quot;)&#xA;        let w:ids=[]&#xA;    endif&#xA;    if a:clear&#xA;        call map(w:ids, 'matchdelete(v:val)')&#xA;        unlet! w:ids&#xA;        return&#xA;    endif&#xA;    hi HiTabs ctermfg=red guibg=red ctermbg=red&#xA;    hi HiSpaces3 ctermfg=blue guibg=blue ctermbg=blue&#xA;    hi HiSpaces6 ctermfg=yellow guibg=yellow ctermbg=yellow&#xA;    hi HiSpaces9 ctermfg=green guibg=green ctermbg=green&#xA;    call add(w:ids, matchadd('HiTabs', '\t'))&#xA;    for i in range(3, 9, 3)&#xA;        exe printf(&quot;call add(w:ids, matchadd('HiSpaces%d', '\\s\\{%d\\}', %d))&quot;, i, i, i+10)&#xA;    endfor&#xA;endfunction&#xA;&#xA;function! ToggleIndentGuides()&#xA;    if !exists('#MyIndentGuideGroup')&#xA;        augroup MyIndentGuideGroup&#xA;            au!&#xA;            au WinEnter * call MyPoorIndentGuide(0)&#xA;        augroup end&#xA;        call MyPoorIndentGuide(0)&#xA;    else&#xA;        augroup MyIndentGuideGroup&#xA;            au!&#xA;        augroup end&#xA;        augroup! MyIndentGuideGroup&#xA;        call MyPoorIndentGuide(1)&#xA;    endif&#xA;endfunction&#xA;&#xA;com! MyIndentGuideToggle :call ToggleIndentGuides()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: it uses the background color to highlight, since we are highlighting invisible things, we cannot use the foreground (unless one uses &lt;code&gt;:set list listchars=...&lt;/code&gt;), however that means, highlighting might be a little bit, well funky. You might want to customize the colors to your liking.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="51" LastEditDate="2017-06-28T11:43:26.207" LastActivityDate="2017-06-28T11:43:26.207" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12764" PostTypeId="1" CreationDate="2017-06-28T16:29:05.410" Score="0" ViewCount="247" Body="&lt;p&gt;I make a file called &lt;code&gt;run_gvim_thing.sh&lt;/code&gt; in my home dir. Inside of that is the command &lt;code&gt;gvim myfile.py &amp;amp;&amp;amp; echo &quot;yay&quot;&lt;/code&gt;. If I run that file from terminal it launches gvim with myfile.py. If I run that file from ex mode it does nothing but echos &quot;yay&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When logging gvim for errors I caught this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Fatal Python error: Py_Initialize: can't initialize sys standard streams&#xA;OSError: [Errno 9] Bad file descriptor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12803" LastEditorUserId="12803" LastEditDate="2017-07-01T06:14:25.750" LastActivityDate="2017-07-31T06:16:28.973" Title="(OSX) Can't run gvim from gvim" Tags="|vimscript|gvim|vimscript-python|macos|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12765" PostTypeId="1" CreationDate="2017-06-28T16:54:08.030" Score="1" ViewCount="243" Body="&lt;p&gt;I'm looking for something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabsplit file1 file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will open the two files in a new tab that is split with file1 in one split and file2 in another split&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really want something like &lt;code&gt;tabvsplit&lt;/code&gt;. Currently, I am using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabe file1&#xA;:vsp file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;not too bad, but could be better, and I am wondering if there is something built-in that is easier to type and faster.&lt;/p&gt;&#xA;" OwnerUserId="5108" LastActivityDate="2017-06-28T19:01:15.013" Title="vim split files in new tab" Tags="|split|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12767" PostTypeId="2" ParentId="12765" CreationDate="2017-06-28T18:49:16.363" Score="2" Body="&lt;p&gt;You can do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabedit +sp\ file1 file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can create a new command for that, but that will make the quoting ugly. Something like this might work (warning, this is really ugly, but seems to work from my basic tests):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! -nargs=+ -complete=file Tabsplit :let a=split(&amp;lt;q-args&amp;gt;) | if len(a) == 2 | exe ':tabedit +'. fnameescape('sp '. a[0]) fnameescape(a[1]) | else | echoerr &quot;too many arguments&quot; |endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It basically checks, that the supplied arguments are exactly 2 and if that is the case, runs the &lt;code&gt;:tabedit +sp&lt;/code&gt; command mentioned earlier and if not, will echo an error message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not quite sure, the &lt;code&gt;fnameescape()&lt;/code&gt; is needed for the file arguments. You need to test, if this is really required when using a filename that contains spaces.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2017-06-28T19:01:15.013" LastActivityDate="2017-06-28T19:01:15.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12770" PostTypeId="1" CreationDate="2017-06-29T08:26:14.917" Score="4" ViewCount="2416" Body="&lt;p&gt;Here is my document; the entire text is on a single line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XInW3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XInW3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would like it to be not so wide; for example by using &lt;code&gt;set textwidth=40&lt;/code&gt; and &lt;code&gt;gq&lt;/code&gt; I get my desired results:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YWsQ6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YWsQ6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with this is that it affects the actual contents of the buffer, whereas I want the changes to be just &lt;em&gt;visual&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked at changing &lt;code&gt;columns&lt;/code&gt;, but that changes the width of my terminal as well, and this seems like a hack in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any good way to add a margin to the right side? (The example is slightly exaggerated; in reality I'd want more like 4-5 characters)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-10-30T23:28:08.550" Title="How can I add a visual margin on the right of my window?" Tags="|alignment|margin|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12771" PostTypeId="1" AcceptedAnswerId="12772" CreationDate="2017-06-29T08:47:34.070" Score="5" ViewCount="2601" Body="&lt;p&gt;I am interested in mastering the art of using &lt;code&gt;ex&lt;/code&gt; from the command line (&lt;code&gt;vi -esc &amp;lt;commands&amp;gt;&lt;/code&gt; / &lt;code&gt;ex -sc &amp;lt;commands&amp;gt;&lt;/code&gt;). I got &lt;a href=&quot;https://vi.stackexchange.com/questions/5273/how-to-use-c-command-line-option&quot;&gt;the basics&lt;/a&gt; worked out, but one thing eludes me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I add text using insert mode?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say I want to add text at the end of the file. In interactive ex, I would do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex file.txt&#xA;:normal! G&#xA;$a&#xA;foo&#xA;.&#xA;x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I enter that same sequence as &lt;code&gt;-c&lt;/code&gt; command line option when invoking &lt;code&gt;ex&lt;/code&gt;, I get stuck on the interactive &lt;code&gt;ex&lt;/code&gt; command line, and if I enter &lt;code&gt;x&lt;/code&gt; from there, my file remains unchanged.&lt;/p&gt;&#xA;" OwnerUserId="1726" LastActivityDate="2020-07-05T09:10:42.923" Title="Using the ex mode command line (-c), how would I insert text?" Tags="|ex-mode|invocation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12772" PostTypeId="2" ParentId="12771" CreationDate="2017-06-29T09:58:38.217" Score="5" Body="&lt;p&gt;The documentation for &lt;code&gt;-s&lt;/code&gt; in Ex mode &lt;code&gt;:help -s-ex&lt;/code&gt; states:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;To be used when Vim is used to execute Ex commands from a file instead of a terminal.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So it seems the correct approach is to save your commands into a file and then run:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim -es &amp;lt; commands.ex file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;N.B. Note that you don't &lt;em&gt;need&lt;/em&gt; to use the Ex mode &lt;code&gt;-e&lt;/code&gt; argument to run Vim commands non-interactively: the commands you add with &lt;code&gt;-c&lt;/code&gt; are already interpreted as Ex commands, and you can have up to 10 of them (see &lt;code&gt;:help -c&lt;/code&gt;), so you could also do something like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &amp;quot;normal! G&amp;quot; -c &amp;quot;normal! ofoo&amp;quot; -c x file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or more concisely:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim &amp;quot;+norm! Gofoo&amp;quot; +x file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-07-05T09:10:42.923" LastActivityDate="2020-07-05T09:10:42.923" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="12773" PostTypeId="2" ParentId="12770" CreationDate="2017-06-29T10:15:09.727" Score="1" Body="&lt;p&gt;I would simply just &lt;code&gt;:rightbelow vnew&lt;/code&gt; together with &lt;code&gt;:set wrap&lt;/code&gt; and adjust the windows at will&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-06-29T10:15:09.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12774" PostTypeId="1" AcceptedAnswerId="12775" CreationDate="2017-06-29T10:41:58.083" Score="2" ViewCount="1967" Body="&lt;p&gt;I have an XML file with some invalid characters. Vim show them for example as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know that this is some special character and &lt;a href=&quot;https://stackoverflow.com/questions/3844311/how-do-i-replace-or-find-non-printable-characters-in-vim-regex&quot;&gt;how to replace them&lt;/a&gt;. Yet what is its meaning?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;^C&lt;/code&gt; is just one example, I would like to know all the possible non-printable chars meaning, including &lt;code&gt;^M&lt;/code&gt; or whatever there may be.&lt;/p&gt;&#xA;" OwnerUserId="5449" LastActivityDate="2017-06-29T13:40:54.797" Title="How to find out the meaning of certain non-printable characters?" Tags="|normal-mode|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12775" PostTypeId="2" ParentId="12774" CreationDate="2017-06-29T10:48:47.987" Score="4" Body="&lt;p&gt;I was looking for the &lt;a href=&quot;http://vimhelp.appspot.com/digraph.txt.html#digraph-table&quot; rel=&quot;nofollow noreferrer&quot;&gt;digraph table&lt;/a&gt;, also available in the help at:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h digraph-table&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the relevant part in terms of this questions, there are a lot more available chars:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char  digraph   hex dec official name &#xA;^@  NU  0x00      0 NULL (NUL)&#xA;^A  SH  0x01      1 START OF HEADING (SOH)&#xA;^B  SX  0x02      2 START OF TEXT (STX)&#xA;^C  EX  0x03      3 END OF TEXT (ETX)&#xA;^D  ET  0x04      4 END OF TRANSMISSION (EOT)&#xA;^E  EQ  0x05      5 ENQUIRY (ENQ)&#xA;^F  AK  0x06      6 ACKNOWLEDGE (ACK)&#xA;^G  BL  0x07      7 BELL (BEL)&#xA;^H  BS  0x08      8 BACKSPACE (BS)&#xA;^I  HT  0x09      9 CHARACTER TABULATION (HT)&#xA;^@  LF  0x0a     10 LINE FEED (LF)&#xA;^K  VT  0x0b     11 LINE TABULATION (VT)&#xA;^L  FF  0x0c     12 FORM FEED (FF)&#xA;^M  CR  0x0d     13 CARRIAGE RETURN (CR)&#xA;^N  SO  0x0e     14 SHIFT OUT (SO)&#xA;^O  SI  0x0f     15 SHIFT IN (SI)&#xA;^P  DL  0x10     16 DATALINK ESCAPE (DLE)&#xA;^Q  D1  0x11     17 DEVICE CONTROL ONE (DC1)&#xA;^R  D2  0x12     18 DEVICE CONTROL TWO (DC2)&#xA;^S  D3  0x13     19 DEVICE CONTROL THREE (DC3)&#xA;^T  D4  0x14     20 DEVICE CONTROL FOUR (DC4)&#xA;^U  NK  0x15     21 NEGATIVE ACKNOWLEDGE (NAK)&#xA;^V  SY  0x16     22 SYNCHRONOUS IDLE (SYN)&#xA;^W  EB  0x17     23 END OF TRANSMISSION BLOCK (ETB)&#xA;^X  CN  0x18     24 CANCEL (CAN)&#xA;^Y  EM  0x19     25 END OF MEDIUM (EM)&#xA;^Z  SB  0x1a     26 SUBSTITUTE (SUB)&#xA;^[  EC  0x1b     27 ESCAPE (ESC)&#xA;^\  FS  0x1c     28 FILE SEPARATOR (IS4)&#xA;^]  GS  0x1d     29 GROUP SEPARATOR (IS3)&#xA;^^  RS  0x1e     30 RECORD SEPARATOR (IS2)&#xA;^_  US  0x1f     31 UNIT SEPARATOR (IS1)&#xA;    SP  0x20     32 SPACE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5449" LastEditorUserId="6489" LastEditDate="2017-06-29T13:40:54.797" LastActivityDate="2017-06-29T13:40:54.797" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12776" PostTypeId="2" ParentId="12774" CreationDate="2017-06-29T11:07:03.377" Score="2" Body="&lt;p&gt;You can use my plugin &lt;a href=&quot;https://github.com/chrisbra/unicode.vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;unicode.vim&lt;/a&gt;. Put the cursor on top of the character and enter &lt;code&gt;:UnicodeName&lt;/code&gt;. It will return the name of the character, together with some additional information such as the html entity code, digraph to create that char if it exists in paranthesis, decimal and hex code of the character and the code you need to search for that char. You can even directly copy that into the search register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It provides some other possibilities like creating a unicode table, or omnicompletion of digraphs and unicode characters, so check it out.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="51" LastEditDate="2017-06-29T11:13:22.120" LastActivityDate="2017-06-29T11:13:22.120" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12777" PostTypeId="1" AcceptedAnswerId="12789" CreationDate="2017-06-29T13:55:41.600" Score="0" ViewCount="376" Body="&lt;p&gt;When Vim starts, it always opens buffers of last session too. That is to say, when I leave Vim by closing all windows, but do not explicitly close buffers (by &lt;code&gt;:bd&lt;/code&gt;), those buffers will be opened next time Vim starts. How can I not open these buffers?&lt;/p&gt;&#xA;" OwnerUserId="10241" LastActivityDate="2017-06-30T18:19:14.237" Title="Do not reopen buffers of last session" Tags="|buffers|vim-windows|sessions|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="12778" PostTypeId="1" AcceptedAnswerId="12780" CreationDate="2017-06-29T14:06:24.033" Score="0" ViewCount="472" Body="&lt;p&gt;I'd like to have search highlights (&lt;code&gt;set hlsearch&lt;/code&gt;) while the cursor is on a match and to turn it off automatically (&lt;code&gt;set nohlsearch&lt;/code&gt;) when I move the cursor away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar foo&#xA;text text bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After searching for bar: while the cursor is on &quot;bar&quot; the highlight is on, when the cursor moves away to &quot;foo&quot; or &quot;text&quot; the highlight is off and goes back on when I &lt;code&gt;n&lt;/code&gt;/&lt;code&gt;N&lt;/code&gt;/return to &quot;bar&quot;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I found a search &quot;hack&quot; in this &lt;a href=&quot;https://github.com/romainl/vim-cool/blob/master/plugin/cool.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt; and used it with @Tumbler41's idea:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd CursorMoved * if (search('\%#\zs'.@/,'cnW',line('.'))) | set hlsearch | else | set nohlsearch | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Only highlights when I'm on the first char but that's fine for me.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="10337" LastEditDate="2017-06-29T15:56:52.663" LastActivityDate="2017-06-29T15:56:52.663" Title="Toggle search highlight while on match" Tags="|search|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12779" PostTypeId="1" AcceptedAnswerId="12781" CreationDate="2017-06-29T14:07:01.637" Score="0" ViewCount="558" Body="&lt;p&gt;I defined these maps, to yank into system clipboard.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;leader&amp;gt;y &quot;*y&#xA;noremap &amp;lt;leader&amp;gt;Y &quot;*Y&#xA;noremap &amp;lt;leader&amp;gt;yy &quot;*yy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I use the first one (&lt;code&gt;&amp;lt;leader&amp;gt;y&lt;/code&gt;), I find it extremely slow (taking some 4 or 5 seconds, but functioning properly). Why? What are possible reasons? How can I find cause of problem?&lt;/p&gt;&#xA;" OwnerUserId="10241" LastEditorUserId="10241" LastEditDate="2017-06-29T16:03:48.823" LastActivityDate="2017-06-29T17:53:45.130" Title="Strangely slow key bindings" Tags="|key-bindings|cut-copy-paste|performance|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12780" PostTypeId="2" ParentId="12778" CreationDate="2017-06-29T14:30:26.010" Score="4" Body="&lt;p&gt;It's actually a lot simpler than I originally thought, try this &lt;code&gt;autocmd&lt;/code&gt; and see if it does what you're looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorMoved * if (expand('&amp;lt;cword&amp;gt;') =~ @/) | set hlsearch | else | set nohlsearch | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This looks at the current word under the cursor and compares it the the search register (&lt;code&gt;@/&lt;/code&gt;). If it matches, the command sets &lt;code&gt;hlsearch&lt;/code&gt;, otherwise it unsets it.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-06-29T14:30:26.010" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12781" PostTypeId="2" ParentId="12779" CreationDate="2017-06-29T16:16:30.123" Score="2" Body="&lt;p&gt;When you define a multi key mapping that starts with character that is itself a mapping, vim doesn't know which one you want after only the first character. It waits to see if you'll type another character indicating the longer mapping. If you don't type anything, after some time it will use the shorter mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change the amount of time it waits by changing the the &lt;code&gt;ttimeoutlen&lt;/code&gt; setting. It's given in milliseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27ttimeoutlen%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'ttimeoutlen'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-06-29T16:16:30.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12782" PostTypeId="1" CreationDate="2017-06-29T17:46:35.003" Score="1" ViewCount="622" Body="&lt;p&gt;I've recently started up a project using Typescript. When I start up Vim, open up a &lt;code&gt;.tsx&lt;/code&gt; file and open a new line, it fails to indent:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WVUmg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WVUmg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then open up a regular javascript file (&lt;code&gt;.js&lt;/code&gt;), and return to my Typescript file. I then open a new line and it indents correctly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xT8EY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xT8EY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried turning on / off &lt;code&gt;autoindent&lt;/code&gt; and &lt;code&gt;cindent&lt;/code&gt;, and I've removed my plugins (installed via Pathogen) and brought them back and the problem seems to be consistent. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I presume there is some auto indenting being triggered by the opening of the &lt;code&gt;.js&lt;/code&gt; file that persists to the typescript file, but I have no idea how to check / debug what is going on. Any thoughts on how to troubleshoot this?&lt;/p&gt;&#xA;" OwnerUserId="13249" LastEditorUserId="51" LastEditDate="2017-06-29T23:37:03.400" LastActivityDate="2017-09-28T00:21:26.797" Title="See what indenting style is being used in Vim" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12783" PostTypeId="2" ParentId="12782" CreationDate="2017-06-29T17:49:54.937" Score="1" Body="&lt;p&gt;Welp, this worked:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufEnter *.tsx :setlocal filetype=typescript&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That seemed to do the trick for me.&lt;/p&gt;&#xA;" OwnerUserId="13249" LastActivityDate="2017-06-29T17:49:54.937" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12784" PostTypeId="2" ParentId="12779" CreationDate="2017-06-29T17:53:45.130" Score="0" Body="&lt;p&gt;(Posting this as an answer to make it more visible) The &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; does not work, and I don't want to shorten the &lt;code&gt;timeoutlen&lt;/code&gt;. So, I redefined key bindings to rid the ambiguity. Now all commands are lightning fast.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;y &quot;*y&#xA;vnoremap &amp;lt;leader&amp;gt;y &quot;*y&#xA;nnoremap &amp;lt;leader&amp;gt;Y &quot;*y$&#xA;nnoremap &amp;lt;leader&amp;gt;yy &quot;*yy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10241" LastActivityDate="2017-06-29T17:53:45.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12786" PostTypeId="2" ParentId="12738" CreationDate="2017-06-30T05:41:04.320" Score="3" Body="&lt;p&gt;It sounds like the help file is referring to the concept of partial application, which is &lt;a href=&quot;https://en.wikipedia.org/wiki/Partial_application&quot; rel=&quot;nofollow noreferrer&quot;&gt;described in Wikipedia&lt;/a&gt; as:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;[...] the process of fixing a number of arguments to a function, producing another function of smaller arity.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="13157" LastActivityDate="2017-06-30T05:41:04.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12787" PostTypeId="1" AcceptedAnswerId="12885" CreationDate="2017-06-30T10:07:24.710" Score="8" ViewCount="394" Body="&lt;p&gt;I once was given these materials to enable this helper for &lt;code&gt;vim&lt;/code&gt; to show kind of a vertical line in order to help enforce PEP8 rules on line length limit at column 80:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;   Long lines highlighting.&#xA;nnoremap &amp;lt;Leader&amp;gt;H :call&amp;lt;SID&amp;gt;LongLineHLToggle()&amp;lt;cr&amp;gt;&#xA;hi OverLength ctermbg=none cterm=none&#xA;match OverLength /\%&amp;gt;80v/&#xA;fun! s:LongLineHLToggle()&#xA;    if !&amp;amp;diff&#xA;        if !exists('w:longlinehl')&#xA;            let w:longlinehl = matchadd('ErrorMsg', '.\%&amp;gt;80v', 0)&#xA;            echo &quot;Long lines highlighted&quot;&#xA;        else&#xA;            call matchdelete(w:longlinehl)&#xA;            unl w:longlinehl&#xA;            echo &quot;Long lines unhighlighted&quot;&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In action:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Pq3UR.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Pq3UR.png&quot; alt=&quot;long line highlighter toggler in action&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use all of this for marking the 80th column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given enough time and effort I very much could have a similar facility in &lt;code&gt;vim&lt;/code&gt; for marking text far beyond column 72 &lt;strong&gt;only when in comment.&lt;/strong&gt; I guess it has been already coded by somebody somewhere at some point. &lt;strong&gt;Do you already know where to find that snippet?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="13260" LastEditorUserId="1841" LastEditDate="2017-06-30T11:50:05.057" LastActivityDate="2017-07-13T02:19:37.480" Title="How to color comments after a defined column" Tags="|vimrc|vimscript|highlight|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12788" PostTypeId="2" ParentId="457" CreationDate="2017-06-30T15:23:44.513" Score="16" Body="&lt;p&gt;I was told by a person with partial sight who is going blind that he is switching to ex, so that's one use of it.  I myself am considerably older than vi, and I switched from ed to ex a long time ago (yes, I know, &quot;ed is the standard editor&quot;).  The only thing I do in vi mode is %-bouncing to match parens when writing Lisp code.&lt;/p&gt;&#xA;" OwnerUserId="13265" LastActivityDate="2017-06-30T15:23:44.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12789" PostTypeId="2" ParentId="12777" CreationDate="2017-06-30T18:19:14.237" Score="1" Body="&lt;p&gt;This might be caused by the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#viminfo-%&quot; rel=&quot;nofollow noreferrer&quot;&gt;'viminfo'&lt;/a&gt; setting containing the &quot;%&quot; item. If the &quot;%&quot; flag is included in your viminfo setting, this means:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When included, save and restore the buffer list.  If Vim is&#xA;   started with a file name argument, the buffer list is not&#xA;   restored.  If Vim is started without a file name argument, the&#xA;   buffer list is restored from the viminfo file.  Quickfix&#xA;   ('buftype'), unlisted ('buflisted'), unnamed and buffers on&#xA;   removable media (viminfo-r) are not saved.&#xA;   When followed by a number, the number specifies the maximum&#xA;   number of buffers that are stored.  Without a number all&#xA;   buffers are stored.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-06-30T18:19:14.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12791" PostTypeId="2" ParentId="5080" CreationDate="2017-07-01T06:00:02.587" Score="0" Body="&lt;p&gt;For the sake of completeness I thought I'd post an alternative. Vim has &lt;em&gt;multi-items&lt;/em&gt; some of which are similar to the more standard regular expression &lt;em&gt;lookaround assertions&lt;/em&gt; (negative/positive lookahead/lookbehind). &lt;a href=&quot;https://stackoverflow.com/questions/2973436/regex-lookahead-lookbehind-and-atomic-groups&quot;&gt;https://stackoverflow.com/questions/2973436/regex-lookahead-lookbehind-and-atomic-groups&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case we want a negative lookahead, &lt;code&gt;\@!&lt;/code&gt;, meaning we want to assert that the &lt;em&gt;atom&lt;/em&gt; that precedes the item does not occur after &lt;em&gt;pattern&lt;/em&gt;. In this case the atom is the pattern itself preceded by anything else:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/pattern\(.*pattern\)\@!/replacement/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The part inside the parentheses is &lt;em&gt;zero-width&lt;/em&gt; and not included in the match so is not replaced by the substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h \@!&lt;/code&gt; for more information or &lt;code&gt;:h pattern-multi-items&lt;/code&gt; for the whole section containing other lookaround variations.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2017-07-01T06:00:02.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12792" PostTypeId="2" ParentId="12764" CreationDate="2017-07-01T06:09:04.383" Score="1" Body="&lt;p&gt;I put this at the top of the &lt;code&gt;.vimrc&lt;/code&gt; to fix it. But instead of calling &lt;code&gt;:!gvim some_file.py&lt;/code&gt; you need to call &lt;code&gt;Runit('gvim some_file.py')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python3 &amp;lt;&amp;lt; EOF&#xA;from multiprocessing import Process&#xA;import os&#xA;&#xA;def worker(x):&#xA;  os.system(x) &#xA;&#xA;def do(x):&#xA;  Process(target=worker, args=(x,)).start()&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Runit(command)&#xA;python3 &amp;lt;&amp;lt; EOF&#xA;command = vim.eval('g:command')&#xA;do(command)&#xA;EOF&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After doing some error logging it was clear that the problem was something to do with python3 not releasing some file if called from a vim instance. So I thought maybe spawning a new python instance from vim and calling it from there would work, and it did. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully the MacVim people patch this up. &lt;/p&gt;&#xA;" OwnerUserId="12803" LastActivityDate="2017-07-01T06:09:04.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12793" PostTypeId="1" CreationDate="2017-07-01T08:47:41.143" Score="2" ViewCount="90" Body="&lt;p&gt;I'm trying to write a custom completion function for filenames and sometimes they can have whitespaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I've been using this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=customlist,MyComplete MyFunc execute MyFunc(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it only completes the last word even with &lt;code&gt;nargs=1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to complete arguments containing white spaces? &lt;/p&gt;&#xA;" OwnerUserId="10381" LastActivityDate="2017-07-01T08:47:41.143" Title="custom tab completion with whitespaces" Tags="|vimscript|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12794" PostTypeId="1" AcceptedAnswerId="12795" CreationDate="2017-07-01T10:03:12.130" Score="124" ViewCount="120259" Body="&lt;p&gt;I started using Neovim and moved my &lt;code&gt;.vimrc&lt;/code&gt; to &lt;code&gt;.config/nvim/init.vim&lt;/code&gt; and other stuff is located in &lt;code&gt;.local/share/nvim&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What is the best way to share configs or even plugins between Vim and Neovim?&#xA;Symlinks? Can I change the directories in the .vimrc to use only one symlink?&lt;/p&gt;&#xA;&lt;p&gt;After migrating my vim config to Neovim's default location, this seems to work almost:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ln -s ~/.local/share/nvim/site ~/.vim &#xA;ln -s .config/nvim/init.vim .vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Some plugins (using using &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;noreferrer&quot;&gt;vim-plug&lt;/a&gt;) don't seem to work correctly. I can't load custom colorschmes nor vim-airline.&lt;/p&gt;&#xA;" OwnerUserId="13270" LastEditorUserId="23502" LastEditDate="2023-09-11T11:46:36.897" LastActivityDate="2023-11-18T09:50:22.230" Title="How to share config between Vim and Neovim" Tags="|vimrc|neovim|" AnswerCount="8" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="12795" PostTypeId="2" ParentId="12794" CreationDate="2017-07-01T11:21:36.637" Score="18" Body="&lt;p&gt;Having your config in Neovim's default location, do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ~/.local/share/nvim/site&#xA;ln -s ~/.local/share/nvim/site ~/.vim &#xA;ln -s .config/nvim/init.vim .vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To fix the colorscheme I &lt;a href=&quot;https://stackoverflow.com/a/10778126/859591&quot;&gt;had to set to&lt;/a&gt; &lt;a href=&quot;http://vim.wikia.com/wiki/256_colors_in_vim&quot; rel=&quot;noreferrer&quot;&gt;256 terminal color mode&lt;/a&gt;, i.e. add this to your .vimrc (= init.vim) file, which &lt;a href=&quot;https://github.com/neovim/neovim/wiki/FAQ#colors-arent-displayed-correctly&quot; rel=&quot;noreferrer&quot;&gt;will be ignored by nvim&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co=256  &quot; Note: Neovim ignores t_Co and other terminal codes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get vim-airline I &lt;a href=&quot;https://github.com/vim-airline/vim-airline/wiki/FAQ#vim-airline-doesnt-appear-until-i-create-a-new-split&quot; rel=&quot;noreferrer&quot;&gt;added the following snippet&lt;/a&gt; to .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set laststatus=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't quite understand why this is necessary only in vim and not in Neovim, but I am not &lt;a href=&quot;https://github.com/vim-airline/vim-airline/issues/130&quot; rel=&quot;noreferrer&quot;&gt;the&lt;/a&gt; &lt;a href=&quot;https://github.com/vim-airline/vim-airline/issues/334&quot; rel=&quot;noreferrer&quot;&gt;only&lt;/a&gt; &lt;a href=&quot;https://github.com/vim-airline/vim-airline/issues/20&quot; rel=&quot;noreferrer&quot;&gt;one&lt;/a&gt; stumbling upon this thing.&lt;/p&gt;&#xA;" OwnerUserId="13270" LastEditorUserId="16653" LastEditDate="2018-03-14T20:21:43.847" LastActivityDate="2018-03-14T20:21:43.847" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12796" PostTypeId="1" CreationDate="2017-07-01T13:00:11.620" Score="3" ViewCount="915" Body="&lt;p&gt;I updated from 7.4 to 8.0 last night and vim stopped honoring the &lt;code&gt;highlight&lt;/code&gt; commands in my &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Minimal complete example: with a &lt;code&gt;.vimrc&lt;/code&gt; that contains only the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; a comment&#xA;sy enable&#xA;hi Comment ctermfg=darkCyan&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the comment on line 1 is still blue when I open that file. (However when I re-source it via &lt;code&gt;:so %&lt;/code&gt; it becomes cyan, so the file itself works).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried defining a user colorscheme (and even naming it &lt;code&gt;colors/default.vim&lt;/code&gt;) but it does not work any better.&lt;/p&gt;&#xA;" OwnerUserId="1940" LastActivityDate="2017-11-30T15:18:31.903" Title="vim 8.0 not honoring custom colors" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12797" PostTypeId="1" CreationDate="2017-07-01T15:11:18.950" Score="2" ViewCount="139" Body="&lt;p&gt;I want to use &lt;code&gt;yt&amp;lt;anyChar&amp;gt;&lt;/code&gt; for yanking and for jumping, so that cursor moves to the first char before &lt;code&gt;&amp;lt;anyChar&amp;gt;&lt;/code&gt;. For backward moving this is working by default (after &lt;code&gt;yT&amp;lt;anyChar&amp;gt;&lt;/code&gt; cursor moves to the first char after &lt;code&gt;&amp;lt;anyChar&amp;gt;&lt;/code&gt; and I even can use &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt; for additional jumps).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my Emacs+Evil config I've done it by simply advising evil-yank function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    (defun evil-yank-after (beg end type register yank-handler)&#xA;      (if (= (point) beg)&#xA;        (goto-char (1- end))&#xA;      (goto-char beg)))&#xA;&#xA;    (advice-add #'evil-yank :after #'evil-yank-after)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In vim I guess approach is totally different?&lt;/p&gt;&#xA;" OwnerUserId="13272" LastEditorUserId="13272" LastEditDate="2017-07-01T15:25:06.680" LastActivityDate="2017-07-31T20:21:21.413" Title="Move cursor after yank according to direction" Tags="|vimscript|cursor-movement|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12799" PostTypeId="2" ParentId="12797" CreationDate="2017-07-01T19:38:49.093" Score="3" Body="&lt;p&gt;This is not so easy, because you need to get one additional char after the &lt;code&gt;t&lt;/code&gt; command. However, I think you can map it using an expression mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;omap &amp;lt;expr&amp;gt; t 't'.nr2char(getchar()).&quot;`]&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This maps the &lt;code&gt;t&lt;/code&gt; command to the &lt;code&gt;t&lt;/code&gt;, gets one character from the user using &lt;code&gt;getchar()&lt;/code&gt; function and then moves the cursor to the &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%27]&quot; rel=&quot;nofollow noreferrer&quot;&gt;last character of the previously yanked or changed command&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, this is a very simple mapping, that might not work correctly in error cases or some special cases (and probably also brakes the &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt; command), so beware of some unexpected behaviour. (e.g. take a look at my ftimproved plugin for how many special cases you have to consider).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-01T19:38:49.093" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12800" PostTypeId="1" AcceptedAnswerId="12802" CreationDate="2017-07-01T21:04:13.990" Score="2" ViewCount="829" Body="&lt;p&gt;I finally took the step and started to create a colorscheme for myself. I'm using &lt;a href=&quot;https://www.iterm2.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;iTerm&lt;/a&gt; . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my iTerm-color-page:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Gm9BK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Gm9BK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim, there are both &lt;code&gt;darkblue&lt;/code&gt;, &lt;code&gt;blue&lt;/code&gt; and &lt;code&gt;lightblue&lt;/code&gt;. But in iTerm, I can only see the &lt;code&gt;normal&lt;/code&gt;-option and the &lt;code&gt;bright&lt;/code&gt;-option. I've read quite a lot on ANSI-colors, and can't really figure out, why Vim have more colors available, than my iTerm-color-palette offers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example of the corresponding colors from iTerm to Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iTerm color       Vim-color&#xA;----------------------------&#xA;Normal-red        darkred&#xA;Bright-red        red &#xA;&#xA;Normal-blue       blue&#xA;Bright-blue       lightblue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I figure out (and set), which colors I have available to use in my Vim colorscheme?&lt;/p&gt;&#xA;" OwnerUserId="9194" LastEditorUserId="9194" LastEditDate="2017-07-02T06:23:11.370" LastActivityDate="2017-09-30T14:05:38.093" Title="Corresponding colors from iTerm (terminal) to Vim" Tags="|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12802" PostTypeId="2" ParentId="12800" CreationDate="2017-07-02T12:00:35.133" Score="2" Body="&lt;p&gt;By writing &lt;code&gt;:help cterm-colors&lt;/code&gt; in Vim, then I got the left side of the following table. By trial-and-error, I tried out different colors from iTerm and figured out the following (ready to be copied into a &lt;code&gt;.vim&lt;/code&gt;-colorscheme to help remember what is what:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; AVAILABLE ANSI COLORS IN iTerm&#xA;&quot; &#xA;&quot; 0 =     Black                     - iTerm-ref: Black, normal&#xA;&quot; 1 =     DarkBlue                  - iTerm-ref: Blue, normal&#xA;&quot; 2 =     DarkGreen                 - iTerm-ref: Green, normal&#xA;&quot; 3 =     DarkCyan                  - iTerm-ref: Cyan, normal &#xA;&quot; 4 =     DarkRed                   - iTerm-ref: Red, normal&#xA;&quot; 5 =     DarkMagenta               - iTerm-ref: Magenta, normal&#xA;&quot; 6 =     Brown, DarkYellow         - iTerm-ref: ??&#xA;&quot; 7 =     Grey                      - iTerm-ref: ??&#xA;&quot; 8 =     DarkGrey                  - iTerm-ref: ??&#xA;&quot; 9 =     Blue, LightBlue           - iTerm-ref: Blue, bright&#xA;&quot; 10 =    Green, LightGreen         - iTerm-ref: Green, bright&#xA;&quot; 11 =    Cyan, LightCyan           - iTerm-ref: Cyan, bright&#xA;&quot; 12 =    Red, LightRed             - iTerm-ref: Red, bright&#xA;&quot; 13 =    Magenta, LightMagenta     - iTerm-ref: Magenta, bright&#xA;&quot; 14 =    Yellow, LightYellow       - iTerm-ref: Yellow, bright&#xA;&quot; 15 =    White                     - iTerm-ref: White, bright &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The colors with question-marks are unable to be changed (unless I'm blind or something). &lt;/p&gt;&#xA;" OwnerUserId="9194" LastActivityDate="2017-07-02T12:00:35.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12803" PostTypeId="1" CreationDate="2017-07-02T13:31:19.123" Score="1" ViewCount="323" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/mattn/emmet-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;emmet-vim&lt;/a&gt; which says that it can work in &lt;code&gt;xml&lt;/code&gt; files but I can't seem to navigate between tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say I have this structure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;&#xA;  &amp;lt;groupId&amp;gt;com.google&amp;lt;/groupId&amp;gt;&#xA;  &amp;lt;artifactId&amp;gt;slides&amp;lt;/artifactId&amp;gt;&#xA;  &amp;lt;version&amp;gt;1.0&amp;lt;/version&amp;gt;&#xA;  &amp;lt;scope&amp;gt;system&amp;lt;/scope&amp;gt;&#xA;  &amp;lt;systemPath&amp;gt;${basedir}/lib/lib.jar&amp;lt;/systemPath&amp;gt;&#xA;&amp;lt;/dependency&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I jump forwards to the next tag? E.g., with my cursor on the &lt;code&gt;1&lt;/code&gt; in the version tag how can I move to the second &lt;code&gt;s&lt;/code&gt; in the next line? (The first &lt;code&gt;s&lt;/code&gt; of &lt;code&gt;system&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already tried &lt;code&gt;&amp;lt;C-y&amp;gt; n&lt;/code&gt; which is the &quot;move to next edit point&quot; but it doesn't seem to work.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="51" LastEditDate="2018-08-22T16:59:03.010" LastActivityDate="2024-03-21T11:08:05.903" Title="Jump from tag-to-tag in xml?" Tags="|key-bindings|cursor-movement|filetype-xml|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12804" PostTypeId="2" ParentId="12796" CreationDate="2017-07-02T13:55:04.250" Score="2" Body="&lt;p&gt;Your question is similar to &lt;a href=&quot;https://vi.stackexchange.com/q/10035/860&quot;&gt;this one&lt;/a&gt;,&#xA;which refers to &lt;a href=&quot;https://github.com/vim/vim/issues/542&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue #542&lt;/a&gt; of Vim, where&#xA;Bram suggest to use &lt;code&gt;ColorScheme&lt;/code&gt; auto-command as the right way to customize&#xA;colors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup customhighlight&#xA;    autocmd!&#xA;    autocmd ColorScheme * hi Comment ctermfg=darkCyan&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, refer to answers of that previous question for a different approach that&#xA;involves making small custom colorscheme to tweak colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These two approaches seem to be the only reliable solutions. On multiple occasions Vim will drop all colors and reload colorscheme from the disk using &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#g:colors_name&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g:colors_name&lt;/code&gt;&lt;/a&gt; variable to pick the file. This wipes any customizations made in &lt;code&gt;vimrc&lt;/code&gt; unless they were in an auto-command or in the color scheme. Putting &lt;code&gt;:hi&lt;/code&gt; commands in &lt;code&gt;vimrc&lt;/code&gt; might make configuration dependent on the order of lines (for example, &lt;code&gt;set background=dark&lt;/code&gt; command can drop all color customizations that precede it).&lt;/p&gt;&#xA;" OwnerUserId="860" LastEditorUserId="860" LastEditDate="2017-11-30T15:18:31.903" LastActivityDate="2017-11-30T15:18:31.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12805" PostTypeId="2" ParentId="12770" CreationDate="2017-07-02T15:40:47.610" Score="1" Body="&lt;p&gt;If you can't find a decent solution that actually rearranges text perhaps you'll be in the market for a way to make the margin stand out visually. I use the &lt;em&gt;colorcolumn&lt;/em&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'colorcolumn'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'colorcolumn' is a comma separated list of screen columns that are&#xA;    highlighted with ColorColumn |hl-ColorColumn|.  Useful to align&#xA;    text.  Will make screen redrawing slower.   &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The screen column can be an absolute number, or a number preceded with&#xA;      '+' or '-', which is added to or subtracted from 'textwidth'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I take it to the extreme and color &quot;all&quot; columns right of my textwidth setting with this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;colorcolumn='+' . join(range(1,256), ',+')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I've not had any issues with slow screen redraws but this might not work well with slower gfx configurations.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example with a subtle color choice. Color can be changed by changing appropriate highlight: &lt;code&gt;:highlight ColorColumn ctermbg=4 ...&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xOj06.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xOj06.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-10-30T23:28:08.550" LastActivityDate="2017-10-30T23:28:08.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12806" PostTypeId="1" AcceptedAnswerId="13157" CreationDate="2017-07-03T05:17:16.690" Score="16" ViewCount="7797" Body="&lt;p&gt;By default, using &lt;code&gt;gq&lt;/code&gt; with a movement command hard-wraps the text described by the movement command to 79 columns. (I'm relatively new to &lt;code&gt;vi&lt;/code&gt;/&lt;code&gt;vim&lt;/code&gt; so I don't know the correct terminology.) How can I configure that column count so that instead it wraps at a different number of columns?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, suppose I have this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is text for illustration.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to configure the wrap column to 29 so that if my cursor is in the line and I run &lt;code&gt;gqip&lt;/code&gt; it is transformed to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is text for&#xA;illustration.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using gVim on Ubuntu GNOME 17.04, if that makes a difference.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I'm looking for a way to manually wrap certain sections of text to the given line length without affecting any others, because there are some cases where I'm OK with going past the limit. To expand on the previous example, if my document looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is text for illustration.&#xA;&#xA;This is some other text for illustration.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I run &lt;code&gt;gqip&lt;/code&gt; with my cursor in the first line, I'd like to get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is text for&#xA;illustration.&#xA;&#xA;This is some other text for illustration.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then if I start typing on a new line below that, I'd like that line to similarly be unaffected by the limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My use case is in writing LaTeX documents: I'd like to be able to wrap paragraphs of prose to a certain number of columns on demand, but in certain cases where I'm writing long equations, or tables, I want those lines to stay longer than the limit.&lt;/p&gt;&#xA;" OwnerUserId="13285" LastEditorUserId="13285" LastEditDate="2017-07-03T16:26:32.177" LastActivityDate="2017-08-06T22:17:29.053" Title="Configure which column `gq` wraps at?" Tags="|wrapping|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12807" PostTypeId="2" ParentId="12806" CreationDate="2017-07-03T05:30:30.587" Score="0" Body="&lt;p&gt;There are two ways to do this: setting &lt;code&gt;'textwidth'&lt;/code&gt; to the width of your text in characters or columns; setting &lt;code&gt;'wrapmargin'&lt;/code&gt; to the width of the right margin in characters or columns. For example, to wrap your text to a width of 29 characters or columns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=29&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'textwidth`&#xA;:help 'wrapmargin'&#xA;:help 10.7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="2055" LastEditDate="2017-07-03T05:35:53.420" LastActivityDate="2017-07-03T05:35:53.420" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12809" PostTypeId="1" AcceptedAnswerId="12822" CreationDate="2017-07-03T14:37:54.680" Score="1" ViewCount="1539" Body="&lt;p&gt;Under regular conditions, the tab key will insert a tab character and backspacing that tab deletes the whole tab character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have set up expandtab and softtabstop=4 so that when I hit tab it will insert 4 spaces and when I hit &quot;ctrl-v-tab&quot; it will insert a real tab. However, when I backspace real tabs, it will convert it to spaces and delete only 4 of those, leaving 4 behind (apparently backspace behavior is also affected by the softtabstop setup).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I set it up so that tab always deletes the whole tab character?&lt;/p&gt;&#xA;" OwnerUserId="13293" LastActivityDate="2021-05-12T21:27:35.727" Title="Have backspace delete whole tabs" Tags="|insert-mode|tab-characters|" AnswerCount="2" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12811" PostTypeId="2" ParentId="12809" CreationDate="2017-07-03T22:12:41.160" Score="1" Body="&lt;p&gt;This mapping will take you out of Insert mode briefly and delete the previous character with 'X' rather than backspace before re-entering Insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;BS&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt;X&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to do the trick for most cases though there may be some edge cases not yet discovered. If there are too many issues I imagine mapping backspace to a simple function that looks at the previous character before deciding whether to use X or BS. That's the only way, for example, that you could retain the ability of backspace to &quot;unwrap&quot; or delete from the beginning of a line to end of the previous line and such which folks often enable in their vimrc files with lines like &lt;code&gt;set backspace=eol,start,indent&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I first suggested something like this mapping in a comment but I hadn't accounted for the cursor movement wonkiness when entering Normal mode (in the middle of the line behaves differently from the end of the line). The &lt;code&gt;Ctrl-\&lt;/code&gt; should take care of it.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-07-03T22:30:24.173" LastActivityDate="2017-07-03T22:30:24.173" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12812" PostTypeId="1" AcceptedAnswerId="12816" CreationDate="2017-07-04T03:03:51.560" Score="16" ViewCount="1238" Body="&lt;p&gt;According to the documentation for &lt;code&gt;gs&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;go to sleep for N seconds (default 1)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Thus you can put Vim to sleep for 10 seconds using &lt;code&gt;10gs&lt;/code&gt;. What is a good use case for this command?&lt;/p&gt;&#xA;" OwnerUserId="1888" LastEditorUserId="4866" LastEditDate="2024-03-17T14:37:02.023" LastActivityDate="2024-03-17T14:37:02.023" Title="What is the use case for gs?" Tags="|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12813" PostTypeId="2" ParentId="8837" CreationDate="2017-07-04T03:34:08.003" Score="-2" Body="&lt;p&gt;I was having the exactly same problem Mac terminal + ssh + screen + nvim, solved by setting empty guicursor&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guicursor=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem and solution are explained here: &lt;a href=&quot;https://github.com/neovim/neovim/issues/6403&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neovim/neovim/issues/6403&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13300" LastActivityDate="2017-07-04T03:34:08.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12814" PostTypeId="1" CreationDate="2017-07-04T04:38:24.713" Score="-1" ViewCount="358" Body="&lt;p&gt;I use NeoBundle for plugin manager but I am not sure how to update plugins. Do I have to update one by one? Or there any command to update plugins?&lt;/p&gt;&#xA;" OwnerUserId="10580" LastActivityDate="2017-07-04T06:58:43.083" Title="How to update plugins in Neobundle" Tags="|plugin-managers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12815" PostTypeId="1" AcceptedAnswerId="12828" CreationDate="2017-07-04T06:10:25.647" Score="4" ViewCount="2241" Body="&lt;p&gt;I wanted to try vim 8.0's new job start feature with a simple &quot;hello world&quot; style example. I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let job = job_start('ls -alh')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but there is no output. I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo job_info(job)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and that output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{'status': 'dead', 'stoponexit': 'term', 'exitval': 0, 'exit_cb': 0, 'channel': channel 2 closed, 'process': 32415}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;not not the output of the job. how can I get this?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2019-11-18T08:16:02.330" Title="How do I get the output of a vim 8.0 job?" Tags="|job-control|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12816" PostTypeId="2" ParentId="12812" CreationDate="2017-07-04T06:50:58.260" Score="14" Body="&lt;p&gt;Short answer: None. That is, I believe it is a waste to map the easily accessible keys &lt;code&gt;gs&lt;/code&gt; to &lt;code&gt;sleep&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;With that said, I often use the the &lt;code&gt;:sleep&lt;/code&gt; command when I do testing and debugging of vimscript files. So the command itself is not useless. But when I do use it, I use it as part of a vimscript. After ~15 years of using Vim, I have never used &lt;code&gt;gs&lt;/code&gt; to make Vim sleep.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-07-04T06:50:58.260" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12817" PostTypeId="2" ParentId="12814" CreationDate="2017-07-04T06:58:43.083" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;https://github.com/Shougo/neobundle.vim/blob/master/doc/neobundle.txt#L73-L76&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h neobundle-usage&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Run this command to update your bundled plugins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:NeoBundleUpdate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-07-04T06:58:43.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12818" PostTypeId="1" CreationDate="2017-07-04T08:41:39.177" Score="3" ViewCount="2400" Body="&lt;p&gt;I have a vim script, which uses Unix type path separator as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Prg: Expand snippets {{{!&#xA;let s:plugin_dir=filter(split(&amp;amp;rtp, ','), 'v:val =~ &quot;/vimf90&quot;')[0]&#xA;let s:templatedir=s:plugin_dir . '/templates/'&#xA;function! Prog(arg)&#xA;  execute 'r ' . s:templatedir . a:arg . '.txt'&#xA;  %substitute#\[:EVAL:\]\(.\{-\}\)\[:END:\]#\=eval(submatch(1))#ge&#xA;endfunction&#xA;&quot;}}}&#xA;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have never used Windows, so I was not aware that it may break in Windows. One of my users reported this issue:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The script works very well on Linux system, but when I try it on&#xA;  Windows, it does not work with the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;================================================= &#xA;Error detected while processing&#xA;C:\User\Ki-Tae\vimfiles\plugged\vimf90\ftplugin\fortran_comp.vim: line&#xA;102: E684: list index out of range: 0 E15: Invalid expression:&#xA;filter(split(&amp;amp;rtp, ','), 'v:val =~ &quot;/vimf90&quot;')[0] line 103: E121:&#xA;Undefined variable: s:plugin_dir E15: Invalid expression: s:plugin_dir&#xA;. '/templates/'&#xA;=================================================&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Also, he was kind enough to send me back the solution as:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In Windows, forward slash should be backward slash, so the code should&#xA;  be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filter(split(&amp;amp;rtp, ','), 'v:val =~ &quot;\vimf90&quot;')[0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s:plugin_dir . '\templates\'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which he claims to work for him.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know, &lt;a href=&quot;http://vim.1045645.n5.nabble.com/OS-agnostic-path-separator-td1187176.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim should alter the path separators inherently&lt;/a&gt;. But, clearly, this is not the case here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The complete code in question is available &lt;a href=&quot;https://github.com/rudrab/vimf90/blob/master/ftplugin/fortran_comp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will be grateful if someone kindly check this. I can't do that since I don't have any access to Windows.&lt;/p&gt;&#xA;" OwnerUserId="2738" LastEditorUserId="205" LastEditDate="2017-07-10T03:22:27.983" LastActivityDate="2017-07-10T03:22:27.983" Title="path seperator in vim" Tags="|path|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12819" PostTypeId="2" ParentId="12818" CreationDate="2017-07-04T09:00:32.253" Score="2" Body="&lt;p&gt;I'd either make sure that neither &lt;code&gt;/&lt;/code&gt; nor &lt;code&gt;\&lt;/code&gt; are in the &lt;code&gt;&amp;amp;isk&lt;/code&gt;(momentarily), then match &lt;code&gt;\&amp;lt;vimf90\&amp;gt;&lt;/code&gt;, or I'd match &lt;code&gt;[/\\]&lt;/code&gt; (&lt;code&gt;[/\\\\]&lt;/code&gt; actually because of &lt;code&gt;filter()&lt;/code&gt;) -- I've plenty examples in &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/path.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;path.vim&lt;/a&gt; module from my lh-vim-lib library plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In mu-template, I didn't have your problem as I don't restrict my search for matching directories to &lt;code&gt;{rtp}/somethinghardcoded/templates&lt;/code&gt;, &lt;a href=&quot;https://github.com/LucHermitte/mu-template/blob/master/autoload/lh/mut/dirs.vim#L78&quot; rel=&quot;nofollow noreferrer&quot;&gt;but only to &lt;code&gt;{rtp}/templates&lt;/code&gt;&lt;/a&gt;. This way, overriding is possible, i.e., with &lt;code&gt;globpath(&amp;amp;rtp, 'templates')&lt;/code&gt; end-users will be able to override your templates in their &lt;code&gt;$HOME/.vim/templates&lt;/code&gt; directory.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-07-04T14:54:10.207" LastActivityDate="2017-07-04T14:54:10.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12820" PostTypeId="1" CreationDate="2017-07-04T09:39:19.550" Score="1" ViewCount="1754" Body="&lt;p&gt;In Neovim it's good to have a terminal window open amongst the other windows (which are displaying regular buffers).  Sometimes, in the terminal, I'll want to edit another file. Ordinarily you'd just &lt;code&gt;vim filename&lt;/code&gt; but I'd like that file to be opened as another window in the same tab.  Perhaps, for example, there some way of replacing the &lt;code&gt;vim&lt;/code&gt; in &lt;code&gt;vim filename&lt;/code&gt; so that this can be achieved? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be easier to do this than to use &lt;code&gt;:e filename&lt;/code&gt; because in the terminal I might have changed folder to somewhere rather tedious to type.&lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastEditorDisplayName="user859" LastEditDate="2017-07-04T12:26:07.830" LastActivityDate="2017-09-04T16:04:25.900" Title="Using terminal in tab to open a file in that same tab" Tags="|neovim|terminal|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12821" PostTypeId="1" AcceptedAnswerId="12825" CreationDate="2017-07-04T11:42:45.287" Score="1" ViewCount="838" Body="&lt;p&gt;I've tried the following syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo 123 &quot; comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it failed with E15 and E114 errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to put the inline comment right after the command, so it can be ignored?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2017-07-04T22:03:10.987" LastActivityDate="2017-07-05T07:53:44.350" Title="How to add inline comment for the echo command?" Tags="|command-line|comments|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12822" PostTypeId="2" ParentId="12809" CreationDate="2017-07-04T12:06:13.753" Score="2" Body="&lt;p&gt;&lt;em&gt;For kicks and because I'm trying to learn some Vim scripting here is a more elaborate solution.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;This will handle backspace the way you expect, even if cursor is in first column (in which case it will join with the preceding line).&lt;/p&gt;&#xA;&lt;p&gt;First add this to your vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Sends equivalent of backspace key in Insert mode unless preceding&#xA;&amp;quot; character is a Tab in which case a Normal mode 'X' is sent. Allows&#xA;&amp;quot; backspace to completely delete Tab even if 'softtabstop' is set to&#xA;&amp;quot; a value less than the 'tabstop' setting&#xA;function! SmartBackSpace()&#xA;  if getline('.')[col('.') - 2] == &amp;quot;\&amp;lt;Tab&amp;gt;&amp;quot;&#xA;    normal! X&#xA;  else&#xA;    call feedkeys(&amp;quot;\&amp;lt;C-H&amp;gt;&amp;quot;)&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then add this mapping:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;BS&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt;:call SmartBackSpace()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It's important that you use this because you need &lt;code&gt;&amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; instead of &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;. Otherwise the cursor may jump to undesirable places when transitioning from Insert mode to Normal mode.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2021-05-12T21:27:35.727" LastActivityDate="2021-05-12T21:27:35.727" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="12823" PostTypeId="2" ParentId="12821" CreationDate="2017-07-04T13:46:09.030" Score="1" Body="&lt;p&gt;from &lt;code&gt;:h :echo&lt;/code&gt; (note the last line):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        :ec :echo&#xA;:ec[ho] {expr1} ..      Echoes each {expr1}, with a space in between.  The&#xA;                        first {expr1} starts on a new line.&#xA;                        Also see :comment.&#xA;                        Use &quot;\n&quot; to start a new line.  Use &quot;\r&quot; to move the&#xA;                        cursor to the first column.&#xA;                        Uses the highlighting set by the :echohl command.&#xA;                        Cannot be followed by a comment.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also potentially of interest, from &lt;code&gt;:h comment&lt;/code&gt; (note the last paragraph):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        :quote :comment&#xA;'&quot;' at the start of a line causes the whole line to be ignored.  '&quot;'&#xA;after a command causes the rest of the line to be ignored.  This can be used&#xA;to add comments.  Example:&#xA;        :set ai         &quot;set 'autoindent' option&#xA;It is not possible to add a comment to a shell command &quot;:!cmd&quot; or to the&#xA;&quot;:map&quot; command and a few others, because they see the '&quot;' as part of their&#xA;argument.  This is mentioned where the command is explained.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2593" LastActivityDate="2017-07-04T13:46:09.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12824" PostTypeId="2" ParentId="12818" CreationDate="2017-07-04T14:04:20.773" Score="2" Body="&lt;p&gt;Rather than explicitly specifying paths to the files you have in mind, try using built-in file path handling functions like &lt;code&gt;expand()&lt;/code&gt; (potentially with &lt;code&gt;&amp;lt;sfile&amp;gt;&lt;/code&gt;) or &lt;code&gt;glob()&lt;/code&gt;/&lt;code&gt;globpath()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if you're looking for the root directory of your own plugin, you might try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:plugin_dir = expand(&quot;&amp;lt;sfile&amp;gt;:h:h&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how &lt;code&gt;glob&lt;/code&gt; will work, but you could try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:templatedir = glob(s:plugin_dir . '/templates')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;maybe ask your user to give it a shot and tell you how it works?&lt;/p&gt;&#xA;" OwnerUserId="2593" LastActivityDate="2017-07-04T14:04:20.773" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12825" PostTypeId="2" ParentId="12821" CreationDate="2017-07-04T14:39:34.067" Score="5" Body="&lt;p&gt;The problem with this is, &lt;code&gt;echo&lt;/code&gt; is expecting an expression. You can read what an expression is at &lt;code&gt;:h expression&lt;/code&gt; in great detail. In short this means, &lt;code&gt;:echo&lt;/code&gt; expects either a variable or a string (which is either single quoted or double quoted). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now look at your command, you are echoing the number 123 and start with a double-quoted string. However, &quot;&lt;strong&gt;forgot&lt;/strong&gt;&quot; the closing quotation marks, so Vim is complaining.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A workaround is, to actually start an empty command, e.g. this works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo 1234 | &quot; put your comment here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2017-07-05T07:53:44.350" LastActivityDate="2017-07-05T07:53:44.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12826" PostTypeId="2" ParentId="12820" CreationDate="2017-07-05T00:55:29.980" Score="1" Body="&lt;p&gt;I would just use a split, so it is effectively in the same &quot;tab&quot;. You just have to type &lt;code&gt;:split&lt;/code&gt; or &lt;code&gt;:vsplit&lt;/code&gt;, depending on whether you want it split vertically or horizontally. you can then specify the file you want to open like this (say you want a vertical split) &lt;code&gt;:vsplit e foo.txt&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="13009" LastActivityDate="2017-07-05T00:55:29.980" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12827" PostTypeId="1" AcceptedAnswerId="12830" CreationDate="2017-07-05T02:11:58.633" Score="16" ViewCount="17143" Body="&lt;p&gt;I installed debian strech two days ago. I installed vim and configured some plugins. I always encountered the following error while opening any file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim app.py&#xA;Error detected while processing /home/sathish/.vim/plugged/sbt-vim/plugin/sbt.vim:&#xA;line   20:&#xA;E319: Sorry, the command is not available in this version: pyfile /home/sathish/.vim/plugged/sbt-vim/plugin/../python/sbt-vim.py&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The vim version output is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 23 2017 12:10:29)&#xA;Included patches: 1-197, 322, 377-378, 550&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     +tcl&#xA;+balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;+browse          -footer          +multi_byte      +terminfo&#xA;++builtin_terms  +fork()          +multi_lang      +termresponse&#xA;+byte_offset     +gettext         -mzscheme        +textobjects&#xA;+channel         -hangul_input    +netbeans_intg   +timers&#xA;+cindent         +iconv           +num64           +title&#xA;+clientserver    +insert_expand   +packages        +toolbar&#xA;+clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        +perl            +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       -python          +vreplace&#xA;+cscope          +lispindent      +python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con_gui  +lua             +rightleft       +writebackup&#xA;+diff            +menu            +ruby            +X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;+dnd             +modify_fname    +signs           +xim&#xA;-ebcdic          +mouse           +smartindent     +xpm&#xA;+emacs_tags      +mouseshape      +startuptime     +xsmp_interact&#xA;+eval            +mouse_dec       +statusline      +xterm_clipboard&#xA;+ex_extra        +mouse_gpm       -sun_workshop    -xterm_save&#xA;+extra_search    -mouse_jsbterm   +syntax          &#xA;+farsi           +mouse_netterm   +tag_binary      &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-RY6vK3/vim-8.0.0197=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: gcc   -L. -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.24/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I added vim with python support from repository&#xA;&lt;a href=&quot;https://launchpad.net/~pi-rho/+archive/ubuntu/dev&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; but the error still occurs.&lt;/p&gt;&#xA;" OwnerUserId="13301" LastEditorUserId="1841" LastEditDate="2017-07-05T07:01:55.417" LastActivityDate="2019-08-04T05:23:30.500" Title="how to install vim with python support for debian strech" Tags="|gvim|installing|linux-debian|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12828" PostTypeId="2" ParentId="12815" CreationDate="2017-07-05T02:49:01.190" Score="5" Body="&lt;p&gt;Vim jobs start with a channel, you can use &lt;code&gt;job-options&lt;/code&gt; to redirect output to a buffer. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let job = job_start('ls -alh', {'out_io': 'buffer', 'out_name': 'mybuffer'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sbuf mybuffer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to read it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ref: &lt;a href=&quot;http://vimhelp.appspot.com/channel.txt.html#job-start&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h job-start&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Escaping issues (dependent on the platform) can be fixed with a list (&lt;a href=&quot;https://github.com/vim/vim/issues/1539#issuecomment-291433247&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue 1539&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let args = ['/bin/bash', '-c', cmd]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13316" LastEditorUserId="25708" LastEditDate="2019-11-18T08:16:02.330" LastActivityDate="2019-11-18T08:16:02.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12829" PostTypeId="2" ParentId="12827" CreationDate="2017-07-05T02:56:41.457" Score="2" Body="&lt;p&gt;In Stretch, the packages changed from supporting Python2 to Python3.  As mentioned in &lt;a href=&quot;https://vi.stackexchange.com/a/2231/15&quot;&gt;another answer&lt;/a&gt;, it's not possible to build Vim against both Python2 and Python3 in Debian.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest getting the plugin to support Python3, but if that's not possible then you would need to either build your own Vim against Python2 or use Neovim (which isn't compiled against Python, so is able to use either version).&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-07-05T02:56:41.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12830" PostTypeId="2" ParentId="12827" CreationDate="2017-07-05T03:08:17.880" Score="1" Body="&lt;p&gt;I tried many possible ways of adding repositories with python support for debian stretch but none of them worked out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally I build my own and then it solved my issue. Here is the &lt;a href=&quot;https://github.com/sathisz/Vim-8.0-debian&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt; for Vim with python 2 and python  support&lt;/p&gt;&#xA;" OwnerUserId="13301" LastEditorUserId="13301" LastEditDate="2018-02-05T06:01:26.773" LastActivityDate="2018-02-05T06:01:26.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12831" PostTypeId="2" ParentId="12827" CreationDate="2017-07-05T04:19:24.237" Score="20" Body="&lt;p&gt;It looks like I'm a bit late, but I'll leave this here for future visitors also struggling with this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sudo apt install vim-nox&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the Vim package in Debian Stretch that adds support for scripting languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should try to do it this way, as it is easier to update/remove.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Consider switching to Neovim&lt;/p&gt;&#xA;" OwnerUserId="13089" LastEditorUserId="13089" LastEditDate="2018-08-25T16:36:00.020" LastActivityDate="2018-08-25T16:36:00.020" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="12832" PostTypeId="2" ParentId="11659" CreationDate="2017-07-05T09:27:09.693" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/issues/1241&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouCompleteMe does not work with Anaconda Python.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disable Anaconda by commenting out the relevant line from your &lt;code&gt;~/.bash_profile&lt;/code&gt; and then try to install YouCompleteMe again. After that you can reenable Anaconda.&lt;/p&gt;&#xA;" OwnerUserId="11755" LastActivityDate="2017-07-05T09:27:09.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12833" PostTypeId="2" ParentId="11866" CreationDate="2017-07-05T16:55:03.893" Score="6" Body="&lt;p&gt;The documentation does suck. I have no idea why they would leave it languishing so much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than the links already posted, the other command to be aware of is &lt;code&gt;:actionlist&lt;/code&gt; which will list all of the action commands you can map. I've also found it useful to search Github for 'ideavimrc' to see what others are doing.&lt;/p&gt;&#xA;" OwnerUserId="19" LastActivityDate="2017-07-05T16:55:03.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12835" PostTypeId="1" AcceptedAnswerId="12870" CreationDate="2017-07-05T23:12:44.353" Score="9" ViewCount="3363" Body="&lt;p&gt;I have a space formatted (yaml) file like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;en:&#xA;  templates:&#xA;    template: &quot;VERYLONGTEXTHEREWITHHUNDREDSOFLINES&quot;&#xA;  destination: &quot;I want to jump here&quot;&#xA;    other: stuff&#xA;  further_destination:&#xA;    foo: bar&#xA;  yet_more_destinations:&#xA;    foo: bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any easy command to walk through from the beginning of &lt;code&gt;templates:&lt;/code&gt; to &lt;code&gt;destination:&lt;/code&gt; and ideally be able to continue on to &lt;code&gt;further_destination:&lt;/code&gt; and &lt;code&gt;yet_more_destinations:&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="13331" LastEditorUserId="1841" LastEditDate="2017-07-10T12:18:13.347" LastActivityDate="2017-07-10T12:18:13.347" Title="How do I jump to the next line with the same indent level?" Tags="|search|indentation|navigation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12837" PostTypeId="2" ParentId="12835" CreationDate="2017-07-06T04:13:17.483" Score="4" Body="&lt;p&gt;If your indenting is consistent, as shown above, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^  [^ ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/&lt;/code&gt;: search for the next occurrence of&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^  &lt;/code&gt;: the start of a line, followed by two spaces&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;[^ ]&lt;/code&gt;: followed by any character that's not a space&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since your file is space-formatted, this is sufficient to correctly jump to each of the tags you mentioned. This command will jump you to the first occurrence it finds, and then you can hit &lt;code&gt;n&lt;/code&gt; repeatedly to scan through all other occurrences.&lt;/p&gt;&#xA;" OwnerUserId="13333" LastActivityDate="2017-07-06T04:13:17.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12838" PostTypeId="1" AcceptedAnswerId="12839" CreationDate="2017-07-06T04:42:48.920" Score="2" ViewCount="308" Body="&lt;p&gt;Suppose I've copied a bunch of lines of boilerplate code that I need to copy multiple times over, and then change in two separate places, in the same way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  it 'includes sessions#new' do&#xA;    expect(get: '/sign_in').to route_to('devise/sessions#new')&#xA;  end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I'm gonna copy this seven or eight times, and I need to change &lt;code&gt;sessions#new&lt;/code&gt; on both lines. So if I go through and change the first line of each statement manually, I end up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  it 'includes sessions#new' do&#xA;    expect(get: '/sign_in').to route_to('devise/sessions#new')&#xA;  end&#xA;&#xA;  it 'includes sessions#destroy' do&#xA;    expect(get: '/sign_in').to route_to('devise/sessions#new')&#xA;  end&#xA;&#xA;  it 'includes passwords#new' do&#xA;    expect(get: '/sign_in').to route_to('devise/sessions#new')&#xA;  end&#xA;&#xA;  it 'includes passwords#create' do&#xA;    expect(get: '/sign_in').to route_to('devise/sessions#new')&#xA;  end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I'd like to change all the second-line instances of &lt;code&gt;sessions#new&lt;/code&gt; to the corresponding string from the previous line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can do this with a long, convoluted multi-line substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(  it 'include \)\(\w\+#\w\+\)\(.*' do\n.*'\)\(\w\+#\w\+\)\(.*\)$/\1\2\3\2\5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'd like to know is if it's possible to do something comparable and perhaps a little more compact with the &lt;code&gt;:global&lt;/code&gt; command, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/includes \(\w\+#\w\+\)/+1s/sessions#new/\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the above command doesn't work, because the &lt;code&gt;\1&lt;/code&gt; capture group isn't available to the &lt;code&gt;:g&lt;/code&gt; command (and anyway, the &lt;code&gt;:s&lt;/code&gt; command probably thinks it's for &lt;em&gt;it&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to get this done, or am I stuck with Option 1?&lt;/p&gt;&#xA;" OwnerUserId="2593" LastActivityDate="2017-07-06T07:02:27.737" Title="Substitute text on one line with capture group from previous line?" Tags="|regular-expression|substitute|global-command|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12839" PostTypeId="2" ParentId="12838" CreationDate="2017-07-06T06:09:39.693" Score="1" Body="&lt;p&gt;It is not possible, to capture groups in the &lt;code&gt;:g&lt;/code&gt; command and then run an &lt;code&gt;:s&lt;/code&gt; command, that uses those captured groups. You would have to do it manually, something like this perhaps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/includes/exe &quot;norm! yi'&quot;|+s/sessions#new/\=split(getreg('&quot;'))[1]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses the &lt;code&gt;:g&lt;/code&gt; command to mark all &quot;includes&quot; lines and on each include line, it will use the &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#i%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;i' textobject&lt;/a&gt; to capture the quoted string and copy it into the unnamed register. Then on the following line, it will execute an &lt;code&gt;:s&lt;/code&gt; command, search for &lt;code&gt;sessions#new&lt;/code&gt; and replaces it with the second word in the unnamed register. (using &lt;code&gt;split()&lt;/code&gt; to access only the second half of the whitespace separated part in the register)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-06T06:09:39.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12840" PostTypeId="2" ParentId="12838" CreationDate="2017-07-06T06:46:09.073" Score="2" Body="&lt;p&gt;Well, for given sample, the substitute command can be simplified&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s,\vincludes ([^']+).*\n.*/\zs[^']+,\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;,&lt;/code&gt; is used as delimiter here, so that &lt;code&gt;/&lt;/code&gt; doesn't need escaping&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; is very magic, so that capturing groups and &lt;code&gt;+&lt;/code&gt; don't need escaping&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs&lt;/code&gt; set start of match, so that string up to that need not be captured and back-referenced&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^']+&lt;/code&gt; will capture all non &lt;code&gt;'&lt;/code&gt; characters&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*/&lt;/code&gt; will consume everything up to last &lt;code&gt;/&lt;/code&gt; in the line as &lt;code&gt;*&lt;/code&gt; is greedy&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1616" LastEditorUserId="1616" LastEditDate="2017-07-06T07:02:27.737" LastActivityDate="2017-07-06T07:02:27.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12841" PostTypeId="2" ParentId="12820" CreationDate="2017-07-06T07:05:45.797" Score="0" Body="&lt;p&gt;I wrote a plugin some time ago for Vim to enable client server communications without &lt;code&gt;+clientserver&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/laktak/vim-please&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/laktak/vim-please&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;del&gt;You can try if it works for NeoVim:&lt;/del&gt; install the plugin and run &lt;code&gt;Please&lt;/code&gt;. In another terminal run &lt;code&gt;./please FILE&lt;/code&gt; (in the scripts folder). The FILE should be opened in the original Vim instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@justin suggested that &lt;a href=&quot;https://github.com/mhinz/neovim-remote&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvr&lt;/a&gt; does the same for neovim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;It basically does two things:&#xA;&#xA;    adds back the --remote family of options (see man vim)&#xA;    helps controlling the current nvim from within :terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10337" LastEditorUserId="10337" LastEditDate="2017-07-06T15:24:10.870" LastActivityDate="2017-07-06T15:24:10.870" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12843" PostTypeId="1" CreationDate="2017-07-06T17:52:41.717" Score="8" ViewCount="225" Body="&lt;p&gt;Say I do &lt;code&gt;d4b&lt;/code&gt;, then realize I only needed &lt;code&gt;d3b&lt;/code&gt;. If I hit &lt;code&gt;u&lt;/code&gt;, it'll only undo the &lt;code&gt;d&lt;/code&gt; part, and I'll still be 4 words back as if I just did &lt;code&gt;4b&lt;/code&gt;. I'd like to end up exactly where I was before I executed &lt;code&gt;d4b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make &lt;code&gt;u&lt;/code&gt; include the movements, or is there a better way to undo the entire command?&lt;/p&gt;&#xA;" OwnerUserId="12826" LastEditorUserId="12826" LastEditDate="2017-07-17T17:57:34.700" LastActivityDate="2017-08-31T08:35:12.067" Title="How can I undo an entire command (e.g. d4b), including the motions?" Tags="|cursor-movement|normal-mode|undo-redo|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12844" PostTypeId="1" AcceptedAnswerId="12846" CreationDate="2017-07-06T17:57:56.937" Score="2" ViewCount="328" Body="&lt;p&gt;Usually, in Vim, pressing &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; autocompletes a command. For example, typing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set &amp;lt;TAB&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will autocomplete to &lt;code&gt;:set all&lt;/code&gt;. Pressing &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; again will autocomplete to &lt;code&gt;:set termcap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, on one specific Kubuntu 17.04 machine I own, pressing tab shows something like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/D8BXL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/D8BXL.png&quot; alt=&quot;Gray bar with list of options and highlighted yellow selection.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I enable/disable this functionality in Vim? What is this feature called?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;vim --version&lt;/code&gt; is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 17 2017 12:13:35)&#xA;Included patches: 1-95&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     -tcl&#xA;-balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;-browse          -footer          +multi_byte      +terminfo&#xA;++builtin_terms  +fork()          +multi_lang      +termresponse&#xA;+byte_offset     +gettext         -mzscheme        +textobjects&#xA;+channel         -hangul_input    +netbeans_intg   +timers&#xA;+cindent         +iconv           +num64           +title&#xA;-clientserver    +insert_expand   +packages        -toolbar&#xA;-clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        -perl            +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       -python          +vreplace&#xA;+cscope          +lispindent      +python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con      -lua             +rightleft       +writebackup&#xA;+diff            +menu            -ruby            -X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;-dnd             +modify_fname    +signs           -xim&#xA;-ebcdic          +mouse           +smartindent     -xpm&#xA;+emacs_tags      -mouseshape      +startuptime     -xsmp&#xA;+eval            +mouse_dec       +statusline      -xterm_clipboard&#xA;+ex_extra        +mouse_gpm       -sun_workshop    -xterm_save&#xA;+extra_search    -mouse_jsbterm   +syntax&#xA;+farsi           +mouse_netterm   +tag_binary&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-8krYYf/vim-8.0.0095=. -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl     -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My system vimrc is this (comments removed for brevity):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime! debian.vim&#xA;if has(&quot;syntax&quot;)&#xA;  syntax on&#xA;endif&#xA;if filereadable(&quot;/etc/vim/vimrc.local&quot;)&#xA;  source /etc/vim/vimrc.local&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't have a user vimrc. As far as I know, this is the stock install of vim for Ubuntu 17.04 (&lt;code&gt;sudo apt-get install vim&lt;/code&gt;) with no extra options or added plugins. It's possible that Ubuntu ships Vim with plugins.&lt;/p&gt;&#xA;" OwnerUserId="13342" LastActivityDate="2017-07-06T20:13:06.407" Title="Unusual Vim Auto-completion Feature" Tags="|autocompletion|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12845" PostTypeId="2" ParentId="12844" CreationDate="2017-07-06T20:02:18.980" Score="2" Body="&lt;p&gt;I think this is enabled by the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27wildmenu%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;wildmenu setting&lt;/a&gt; which is enabled in the &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/defaults.vim#L41&quot; rel=&quot;nofollow noreferrer&quot;&gt;defaults.vim&lt;/a&gt; file. So if you &lt;strong&gt;do not&lt;/strong&gt; have a vimrc file, vim will automatically load the defaults.vim file, which sets some options to enable an easier Vim experience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the help at &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#defaults.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h defaults.vim&lt;/a&gt; for all the details.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-06T20:02:18.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12846" PostTypeId="2" ParentId="12844" CreationDate="2017-07-06T20:07:39.450" Score="3" Body="&lt;p&gt;It's the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27wildmenu%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;wildmenu&lt;/code&gt;&lt;/a&gt; setting that lists all the options. The &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27wildmode%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;wildmode&lt;/code&gt;&lt;/a&gt; setting can also affect the specific behavior of completion in command-line mode, including when the wildmenu will appear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;wildmenu&lt;/code&gt; requires that Vim was compiled with the &lt;code&gt;+wildmenu&lt;/code&gt; option, which appears to be the case for the particular version text you've provided. &lt;code&gt;wildmode&lt;/code&gt; does not appear to be dependent on any compilation flags, so there may be some builds of Vim that can do command-line completion, but cannot show the full menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:verbose set wildmenu?&lt;/code&gt; to see where &lt;code&gt;wildmenu&lt;/code&gt; was last set from.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastEditorUserId="2736" LastEditDate="2017-07-06T20:13:06.407" LastActivityDate="2017-07-06T20:13:06.407" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12847" PostTypeId="1" AcceptedAnswerId="12852" CreationDate="2017-07-07T08:56:54.047" Score="2" ViewCount="1220" Body="&lt;p&gt;I typically use &lt;code&gt;set cursorline&lt;/code&gt; by default and it works reasonably well with my preferred color schemes (molokai, vividchalk, moonfly). In normal mode. In diff mode, it almost always screws things up. In particular comment lines are almost always unreadable when highlighted by both the diff colors and the cursor line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to setup my config so that &lt;code&gt;set nocursorline&lt;/code&gt; gets run any time I enter diff mode (whether starting with &lt;code&gt;nvim -d&lt;/code&gt; or using vim-fugitive to run &lt;code&gt;:Gdiff&lt;/code&gt; or manually starting &lt;code&gt;:diffthis&lt;/code&gt;) and then have it turn back on when going into normal highlighting mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. It might matter that I'm running Neovim because I believe the startup order is different and setting GUI properties is available at a different point in the configuration process. However I'm hopping for something that works at both startup and when entering diff mode in an already running editor.&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="267" LastEditDate="2017-07-07T09:20:04.307" LastActivityDate="2017-07-07T15:06:35.800" Title="Automatically disable cursorline when in diff mode?" Tags="|neovim|colorscheme|vimdiff|cursorline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12848" PostTypeId="1" CreationDate="2017-07-07T09:03:18.450" Score="1" ViewCount="44" Body="&lt;p&gt;Is it possible to set up an external program as my clipboard?&#xA;I'd like vim to pipe into it whenever I yank something.&lt;/p&gt;&#xA;" OwnerUserId="4738" LastActivityDate="2017-07-07T09:03:18.450" Title="Make yanking pipe into an external program" Tags="|os-clipboard|" AnswerCount="0" CommentCount="3" ClosedDate="2017-07-08T10:44:11.823" ContentLicense="CC BY-SA 3.0" />
  <row Id="12849" PostTypeId="1" AcceptedAnswerId="12850" CreationDate="2017-07-07T12:28:43.623" Score="19" ViewCount="22885" Body="&lt;p&gt;I often use something like &lt;code&gt;:80&lt;/code&gt; to quickly go to a line (80 for example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm in a unique situation where I want to go to column 80, to see if lines are too long in files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any quick way to do this in vim?&lt;/p&gt;&#xA;" OwnerUserId="7783" LastActivityDate="2019-02-26T01:33:00.100" Title="Go to column number?" Tags="|cursor-movement|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12850" PostTypeId="2" ParentId="12849" CreationDate="2017-07-07T12:44:51.167" Score="28" Body="&lt;p&gt;Just type &lt;code&gt;80|&lt;/code&gt; -&gt; &lt;code&gt;:h |&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is perfect for interactive mode. When scripting, there are other ways.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-07-07T12:44:51.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12851" PostTypeId="1" AcceptedAnswerId="27748" CreationDate="2017-07-07T14:17:17.443" Score="3" ViewCount="393" Body="&lt;p&gt;I've written a short vim function that allows me to edit the contents of vim registers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! RegBuff()&#xA;    let vimstuff = &quot;/tmp/vimstuff&quot;&#xA;    if !isdirectory(vimstuff)&#xA;        call mkdir(vimstuff)&#xA;    endif&#xA;    let reg = getchar()&#xA;    let reg = nr2char(reg)&#xA;    exec 'au BufWrite vimreg-* exec &quot;normal gg0\&quot;'.reg.'yy&quot;'&#xA;    exec '1new '.vimstuff.'/vimreg-'.reg&#xA;    exec 'normal ggdG&quot;'.reg.'P'&#xA;endfun&#xA;nnoremap &amp;lt;leader&amp;gt;&amp;lt;F2&amp;gt; :call RegBuff()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I do, for instance, &lt;code&gt;qqi1234^[&lt;/code&gt; to record insert 1234 into the q register, and then call my function &lt;code&gt;:call RegBuff()&lt;/code&gt; or &lt;code&gt;&amp;lt;leader&amp;gt;&amp;lt;F2&amp;gt;&lt;/code&gt;, I get a nice little window at the top with the contents of the buffer. Cool. if I edit it to be &lt;code&gt;i12345678^[&lt;/code&gt;, save the file and exit, and then do &lt;code&gt;@q&lt;/code&gt;, it properly now enters insert mode and inserts 12345678. Also cool.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that I generally run vim in tmux, and for some reason after executing this macro it switches to the tmux pane below vim. This is as if the macro is additionally running &lt;code&gt;&amp;lt;Ctrl&amp;gt;j&lt;/code&gt; after the macro is run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I go back to the vim pane, and type &lt;code&gt;&quot;qp&lt;/code&gt; to see whats in the &lt;code&gt;q&lt;/code&gt; register it looks totally normal, it just contains what I expect to be in there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does there appear to be this extra key code sent after I call the macro?&lt;/p&gt;&#xA;" OwnerUserId="9353" LastActivityDate="2020-10-21T12:23:22.130" Title="Vim function somehow adds Ctrl-j to macro?" Tags="|macro|functions|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12852" PostTypeId="2" ParentId="12847" CreationDate="2017-07-07T14:59:07.040" Score="5" Body="&lt;p&gt;One would expect, that the &lt;code&gt;OptionSet&lt;/code&gt; autocommand is triggered when entering diff mode. Unfortunately that is currently not the case. So I created a &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/x8yHR_EujV4/z6Jvi9w0BgAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;patch&lt;/a&gt; that will enable this behavior. Once it is merged, you can basically do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au OptionSet diff let &amp;amp;cul=!v:option_new&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a workaround, currently you have to do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyCursorLine&#xA;  au!&#xA;  au FilterWritePost * if &amp;amp;diff | let &amp;amp;cul=0 |endif&#xA;  au BufEnter * if !&amp;amp;diff | let &amp;amp;cul=1 |endif&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2017-07-07T15:06:35.800" LastActivityDate="2017-07-07T15:06:35.800" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12853" PostTypeId="1" CreationDate="2017-07-07T15:47:57.280" Score="4" ViewCount="2543" Body="&lt;p&gt;Is there a way to get the following in Vim:&#xA;If I execute a command in Vim like &lt;code&gt;!make c&lt;/code&gt;, I would like to have a frame/split that pops up like in syntastic instead of switching to terminal view. That way, I would be able to go on writing or doing stuff in vim during compilation/command execution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remember right, they added some asynchronous feature to vim (how ever it is used) so there is probably a plugin can fulfill my wish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be also important, that when I execute another command I don't want to have a second window that pops up. It shall all be in the same window.&lt;/p&gt;&#xA;" OwnerUserId="6816" LastEditorUserId="2920" LastEditDate="2017-07-07T16:40:10.277" LastActivityDate="2022-05-26T14:19:42.020" Title="Execute external command in split window" Tags="|command-line|external-command|split|" AnswerCount="4" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12854" PostTypeId="2" ParentId="12853" CreationDate="2017-07-07T17:50:15.013" Score="1" Body="&lt;p&gt;You can use your shell in a split inside the vim session using this plugin :&#xA;&lt;a href=&quot;https://github.com/vim-scripts/Conque-Shell&quot; rel=&quot;nofollow noreferrer&quot;&gt;ConqueShell&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this opens in a split view, it would not disturb your currently working area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have mapped it as such on my Windows machine :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map cc :ConqueTermSplit cmd.exe&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note : &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; has been written twice to avoid a warning message at startup that goes away after pressing Enter. &lt;/p&gt;&#xA;" OwnerUserId="9004" LastActivityDate="2017-07-07T17:50:15.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12855" PostTypeId="2" ParentId="12853" CreationDate="2017-07-07T20:26:22.000" Score="1" Body="&lt;p&gt;Since you already have tmux, why don't you just split the window and run the command in a new pane?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to automate this with a Vim mapping take a look at &lt;a href=&quot;https://github.com/christoomey/vim-tmux-runner&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-tmux-runner&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-07-07T20:26:22.000" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12856" PostTypeId="2" ParentId="514" CreationDate="2017-07-08T01:41:39.097" Score="9" Body="&lt;p&gt;Seems no one mentioned &lt;code&gt;z{nr}&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;code&gt;:h ^w_&lt;/code&gt;, then will see &lt;code&gt;z{nr}&amp;lt;CR&amp;gt;&lt;/code&gt; just below it, which have same effect as &lt;kbd&gt;CTRL-W&lt;/kbd&gt;&lt;kbd&gt;_&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do not need &lt;kbd&gt;z=&lt;/kbd&gt; for spell check, and added below to &lt;code&gt;.vimrc&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vertical resize, z0&amp;lt;CR&amp;gt; minimize, z= equalize, z99&amp;lt;CR&amp;gt; maximize.&#xA;nnoremap z= &amp;lt;C-w&amp;gt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then for change window height:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;z0&amp;lt;CR&amp;gt;&lt;/kbd&gt; to minimize height of current window&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;z99&amp;lt;CR&amp;gt;&lt;/kbd&gt; to maxmize height of current window&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;z=&lt;/kbd&gt; to make them all equal&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2017-07-08T01:41:39.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12857" PostTypeId="1" CreationDate="2017-07-08T05:23:22.813" Score="0" ViewCount="65" Body="&lt;p&gt;I'm running &lt;code&gt;vim -u NONE -U NONE&lt;/code&gt;, then doing &lt;code&gt;:inoremap &amp;lt;c-c&amp;gt; &amp;lt;c-[&amp;gt;&lt;/code&gt; (or &lt;code&gt;:inoremap ^C ^[&lt;/code&gt;, which I understand to be equivalent), and set an abbreviation, &lt;code&gt;:abb dyca dynamic_cast&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that &lt;code&gt;idyca&amp;lt;ESC&amp;gt;&lt;/code&gt; correctly inserts &lt;code&gt;dynamic_cast&lt;/code&gt;, while &lt;code&gt;idyca&amp;lt;C-C&amp;gt;&lt;/code&gt; inserts &lt;code&gt;dyca&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm able to remap &lt;code&gt;&amp;lt;c-c&amp;gt;&lt;/code&gt; to the character 'O' to verify that you can correctly remap &lt;code&gt;&amp;lt;c-c&amp;gt;&lt;/code&gt; but it doesn't seem to allow for rebinding Ctrl-C to Escape.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="488" LastActivityDate="2017-07-14T11:49:04.770" Title="Why won't Ctrl-C complete abbreviations when mapped to Esc?" Tags="|key-bindings|abbreviations|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12859" PostTypeId="1" AcceptedAnswerId="12860" CreationDate="2017-07-08T17:18:21.080" Score="6" ViewCount="454" Body="&lt;p&gt;I knew you could scope a variable by prefixing it with &lt;code&gt;g:&lt;/code&gt; &lt;code&gt;b:&lt;/code&gt;, etc. but I only just discoverred that the prefix itself references a dictionary containing all the scoped variables. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo b:c_minlines&#xA;50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo b:&#xA;{'c_minlines': 50, 'did_indent': 1, 'current_syntax': 'c', ...}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this documented somewhere?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2017-07-08T17:27:34.153" Title="Are the internal g:, b:, w:, etc dictionaries documented?" Tags="|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12860" PostTypeId="2" ParentId="12859" CreationDate="2017-07-08T17:27:34.153" Score="9" Body="&lt;p&gt;Poking around with &lt;code&gt;:helpgrep \&amp;lt;g:\A&lt;/code&gt;, I found this is documented under &lt;code&gt;:help internal-variables&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;There are several name spaces for variables.  Which one is to be used is&#xA;specified by what is prepended:&#xA;&#xA;        (nothing) In a function: local to a function; otherwise: global&#xA;|buffer-variable|    b:   Local to the current buffer.&#xA;|window-variable|    w:   Local to the current window.&#xA;|tabpage-variable|   t:   Local to the current tab page.&#xA;|global-variable|    g:   Global.&#xA;|local-variable|     l:   Local to a function.&#xA;|script-variable|    s:   Local to a |:source|'ed Vim script.&#xA;|function-argument|  a:   Function argument (only inside a function).&#xA;|vim-variable|       v:   Global, predefined by Vim.&#xA;&#xA;The scope name by itself can be used as a |Dictionary|.  For example, to&#xA;delete all script-local variables: &amp;gt;&#xA;    :for k in keys(s:)&#xA;    :    unlet s:[k]&#xA;    :endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-07-08T17:27:34.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12862" PostTypeId="1" AcceptedAnswerId="12863" CreationDate="2017-07-08T23:29:09.287" Score="2" ViewCount="929" Body="&lt;p&gt;New versions of neovim handle cursor shapes perfectly. But for a special use case I need to change cursor shape manually for a while. Is it possible in Neovim &gt; .2?&lt;/p&gt;&#xA;" OwnerUserId="7153" LastActivityDate="2017-07-08T23:56:10.193" Title="Possibility to set cursor shape manually in Neovim" Tags="|neovim|cursor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12863" PostTypeId="2" ParentId="12862" CreationDate="2017-07-08T23:56:10.193" Score="1" Body="&lt;p&gt;It's possible with this commit: &lt;a href=&quot;https://github.com/neovim/neovim/commit/dd4a5fcbb65ade08b5d2c7951b2924d2d04dc99e&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neovim/neovim/commit/dd4a5fcbb65ade08b5d2c7951b2924d2d04dc99e&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had to use nightly build to be able to use it. To change cursor shape in terminal all you have to do is set &lt;code&gt;guicursor&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7153" LastActivityDate="2017-07-08T23:56:10.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12864" PostTypeId="1" AcceptedAnswerId="12865" CreationDate="2017-07-09T18:30:37.007" Score="3" ViewCount="6130" Body="&lt;p&gt;I'm trying to optimize this solution I came up with. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The code bellow &lt;strong&gt;do works&lt;/strong&gt; fine. So feel free to use it as a valid solution to this question.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; :call ToogleFold()&amp;lt;CR&amp;gt;&#xA;&#xA;function! ToogleFold()&#xA;     if &amp;amp;foldlevel &amp;gt;= 20&#xA;         &quot;normal! zM&amp;lt;CR&amp;gt; (folds all)&#xA;         set foldlevel=0&#xA;     else&#xA;         &quot;normal! zR&amp;lt;CR&amp;gt; (unfolds everything)&#xA;         set foldlevel=20&#xA;     endif&#xA; endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But I believe we can do it all in a single line without the use of functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried some strange combinations here, attempting to get it right. So, to inspire your creativity, here the wrong codes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; @=(foldlevel('.')?'zM':'zR')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;F2&amp;gt; :exe 'if &amp;amp;foldlevel&amp;gt;=20' \ &amp;lt;ESC&amp;gt;zM \ else &amp;lt;ESC&amp;gt;zR'&#xA;nnoremap &amp;lt;F2&amp;gt; :exe &amp;amp;foldlevel&amp;gt;=20? &amp;lt;ESC&amp;gt;zM : &amp;lt;ESC&amp;gt;zR&#xA;nnoremap &amp;lt;F2&amp;gt; :exe '&amp;amp;foldlevel&amp;gt;=20?' &amp;lt;ESC&amp;gt;zM : &amp;lt;ESC&amp;gt;zR'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the and, what I'm trying to achieve is the use of &lt;code&gt;zM&lt;/code&gt; and &lt;code&gt;zR&lt;/code&gt; in normal mode depending on the value of a setting variable &lt;code&gt;foldlevel&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe this solution may be very useful to other similar cases (other variables)&lt;/p&gt;&#xA;" OwnerUserId="13368" LastActivityDate="2022-10-25T12:00:43.390" Title="oneliner map to fold all / unfold all" Tags="|folding|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12865" PostTypeId="2" ParentId="12864" CreationDate="2017-07-09T19:50:45.670" Score="11" Body="&lt;p&gt;So you want to toggle between all lines folded and no lines folded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does this mapping do what you want?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;f2&amp;gt; &amp;amp;foldlevel ? 'zM' :'zR'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-09T19:50:45.670" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12866" PostTypeId="1" CreationDate="2017-07-09T20:20:17.267" Score="3" ViewCount="802" Body="&lt;p&gt;Here's what my colorscheme looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bBBfB.png&quot; alt=&quot;colorscheme&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when there are folds, it looks ugly like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/BbpsQ.png&quot; alt=&quot;colorscheme with folding&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fold background overrides the &quot;gutter&quot; color, but I would like the gutter to remain gray.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to fix this? I have tried &lt;code&gt;hi Folded guibg=NONE&lt;/code&gt; but it still overrides the gutter color.&lt;/p&gt;&#xA;" OwnerUserId="7318" LastActivityDate="2017-07-09T20:20:17.267" Title="Prevent fold background color to override gutter" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12867" PostTypeId="1" CreationDate="2017-07-10T05:25:59.157" Score="22" ViewCount="20873" Body="&lt;p&gt;I want to search and replace each occurrence of a certain pattern with a decimal number which begins at &lt;code&gt;1&lt;/code&gt; and increments by one for each match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can find similarly worded questions that turn out not to be about incrementing a counter but modifying each match by a fixed amount. Other similar questions are about inserting line numbers rather than an incrementing counter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example, before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#1&#xA;#1.25&#xA;#1.5&#xA;#2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#1&#xA;#2&#xA;#3&#xA;#4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My real data has a lot more text all around the stuff I want to re-number.&lt;/p&gt;&#xA;" OwnerUserId="878" LastEditorUserId="878" LastEditDate="2017-07-11T03:47:33.067" LastActivityDate="2020-04-15T19:51:09.017" Title="How to replace each match with incrementing counter?" Tags="|substitute|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12868" PostTypeId="2" ParentId="12867" CreationDate="2017-07-10T06:47:57.210" Score="18" Body="&lt;p&gt;You need substitution with a state. I remember having provided a (/several?) &lt;a href=&quot;http://stackoverflow.com/questions/1809571/how-do-i-substitute-from-a-list-of-strings-in-vim&quot;&gt;complete solution&lt;/a&gt; for this kind of problems on SO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is another way to proceed (1). &#xA;Now, I'll proceed into 2 steps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a dummy list variable I need for the dirty and convoluted trick I'll employ&lt;/li&gt;&#xA;&lt;li&gt;a substitution where I insert the len of this dummy array I'm filling on each matching occurrence.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Which gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let t=[]&#xA;:%s/#\zs\d\+\(\.\d\+\)\=\ze/\=len(add(t,1))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're not used to vim regexes, I use &lt;code&gt;:h /\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; to specify which sub-pattern I'm matching, then I match a series of digits possibly followed by a dot and other digits. This is not perfect for any floating point number, but this is enough here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: You'll have to wrap it up in a couple function + command for a simple interface. Again, there are examples on SO/vim (&lt;a href=&quot;http://vi.stackexchange.com/questions/3028&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;http://stackoverflow.com/questions/1809571/how-do-i-substitute-from-a-list-of-strings-in-vim&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;http://stackoverflow.com/a/25665554/15934&quot;&gt;here&lt;/a&gt;)&#xA;Nowadays I know enough of vim to not care about wrapping this trick into a command. Indeed I'll be able to write this command on the first try, while I'll take several minutes to remember the name of the command.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(1) The objective is to be able to maintain a state in-between substitutions, and to replace the current occurrence with something that depends on the current state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3as%5c%3d&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:s\=&lt;/code&gt;&lt;/a&gt; we are able to insert something resulting from a computation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remains the problem of the state. Either we define a function that's managing an external state, or we update ourselves an external state. In C (and related languages), we could have used something like &lt;code&gt;length++&lt;/code&gt; or &lt;code&gt;length+=1&lt;/code&gt;. Unfortunately, in vim scripts, &lt;code&gt;+=&lt;/code&gt; cannot be used out of the box. It needs to be used either with &lt;code&gt;:set&lt;/code&gt; or with &lt;code&gt;:let&lt;/code&gt;. This means that &lt;code&gt;:let length+=1&lt;/code&gt; increments a number, but doesn't return anything. We cannot write &lt;code&gt;:s/pattern/\=(length+=1)&lt;/code&gt;. We need something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We need mutating functions. i.e. functions that mutates their inputs. We have &lt;code&gt;setreg()&lt;/code&gt;, &lt;code&gt;map()&lt;/code&gt;, &lt;code&gt;add()&lt;/code&gt; and probably more. Let's start with them.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#setreg%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;setreg()&lt;/code&gt;&lt;/a&gt; mutates a register. Perfect. We can write &lt;code&gt;setreg('a',@a+1)&lt;/code&gt; as in @Doktor OSwaldo's solution. And yet, this is not enough. &lt;code&gt;setreg()&lt;/code&gt; is more of a procedure than a function (for those among us who know Pascal, Ada...). This means it doesn't return anything. Actually, it does return something. Nominal exit (i.e. &lt;em&gt;non-exceptionnal&lt;/em&gt; exits) always return something. By default, &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Areturn&quot; rel=&quot;noreferrer&quot;&gt;when we forgot to return something, 0 is returned&lt;/a&gt; -- it also applies with built-in functions. That's why in his solution the replacement expression is actually &lt;code&gt;\=@a+setreg(...)&lt;/code&gt;. Tricky, isn't it?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#map%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;map()&lt;/code&gt;&lt;/a&gt; could also be used. If we start from a list with a single 0 (&lt;code&gt;:let single_length=[0]&lt;/code&gt;), we could increment it thanks to &lt;code&gt;map(single_length, 'v:val + 1')&lt;/code&gt;. Then we need to return the new length. Unlike &lt;code&gt;setreg()&lt;/code&gt;, &lt;code&gt;map()&lt;/code&gt; returns its mutated input.  That's perfect, the length is stored at the first (and unique, and thus last as well) position of the list. The replacement expression could be &lt;code&gt;\=map(...)[0]&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#add%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;add()&lt;/code&gt;&lt;/a&gt; is the one I often use out of habit (I've just though about &lt;code&gt;map()&lt;/code&gt; actually, and I haven't benched their respective performances yet). The idea with &lt;code&gt;add()&lt;/code&gt; is to use a list as the current state, and to append something at the end before each substitution. I often store the new value at the end of the list, and use it for the replacement. As &lt;code&gt;add()&lt;/code&gt; also returns its mutated input list, we can use: &lt;code&gt;\=add(state, Func(state[-1], submatch(0)))[-1]&lt;/code&gt;. In OP's case, we only need to remember how many matches have been detected so far. Returning the length of this state list is enough. Hence my &lt;code&gt;\=len(add(state, whatever))&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-11-30T16:45:39.890" LastActivityDate="2017-11-30T16:45:39.890" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12869" PostTypeId="2" ParentId="12867" CreationDate="2017-07-10T09:23:04.853" Score="23" Body="&lt;pre&gt;&lt;code&gt; :let @a=1 | %s/search/\='replace'.(@a+setreg('a',@a+1))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But beware, it will overwrite your register &lt;code&gt;a&lt;/code&gt;.&#xA;I think it is a little bit more straight forward than luc's answer, but maybe his is faster. If this solution is somehow worse than his, I would love to hear any feedback why his answer is better. Any feedback to improve the answer will be highly appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(It is also based on a SO answer of mine &lt;a href=&quot;https://stackoverflow.com/questions/43539251/how-to-replace-finding-words-with-the-different-in-each-occurrence-in-vi-vim-edi/43539546#43539546&quot;&gt;https://stackoverflow.com/questions/43539251/how-to-replace-finding-words-with-the-different-in-each-occurrence-in-vi-vim-edi/43539546#43539546&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="11316" LastEditorUserId="11316" LastEditDate="2017-07-10T11:04:40.717" LastActivityDate="2017-07-10T11:04:40.717" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12870" PostTypeId="2" ParentId="12835" CreationDate="2017-07-10T12:17:05.237" Score="6" Body="&lt;p&gt;I think that some plugins might do what you want: they create text objects based on the indentation and then let you navigate between these text objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But installing a plugin just for that is not always the best solution: you could do it by youself with a bit of vimscript to add to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First let's create a function which loops on the lines of the buffer and goes to the first line with the same indentation level:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GoToNextIndent(inc)&#xA;    &quot; Get the cursor current position&#xA;    let currentPos = getpos('.')&#xA;    let currentLine = currentPos[1]&#xA;    let matchIndent = 0&#xA;&#xA;    &quot; Look for a line with the same indent level whithout going out of the buffer&#xA;    while !matchIndent &amp;amp;&amp;amp; currentLine != line('$') + 1 &amp;amp;&amp;amp; currentLine != -1&#xA;        let currentLine += a:inc&#xA;        let matchIndent = indent(currentLine) == indent('.')&#xA;    endwhile&#xA;&#xA;    &quot; If a line is found go to this line&#xA;    if (matchIndent)&#xA;        let currentPos[1] = currentLine&#xA;        call setpos('.', currentPos)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the argument &lt;code&gt;inc&lt;/code&gt; should be &lt;code&gt;1&lt;/code&gt; or &lt;code&gt;-1&lt;/code&gt; depending on the way (down or up) you want to scan the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can simply call the function &lt;code&gt;:call GoToNextIndent(1)&lt;/code&gt; or create two convenient mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ni :call GoToNextIndent(1)&amp;lt;CR&amp;gt;&#xA;nnoremap pi :call GoToNextIndent(-1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;ni&lt;/code&gt; in normal mode will go to the next line with the same indent level and &lt;code&gt;pi&lt;/code&gt; to the previous line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;You might want to change the mapped keys to something which doesn't mess with your configuration&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-07-10T12:17:05.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12871" PostTypeId="2" ParentId="12867" CreationDate="2017-07-10T13:54:14.673" Score="8" Body="&lt;p&gt;I found a similar but different question I asked a couple of years ago and managed to change one of its answers without fully understanding what I was doing and it's been working great:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i = 1 | g/#\d\+\(\.\d\+\)\=/s//\=printf(&quot;#%d&quot;, i)/ | let i = i+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Specifically I don't understand why mine doesn't use &lt;code&gt;%&lt;/code&gt; or why I just use a plain variable that the other answers avoid for some reason.&lt;/p&gt;&#xA;" OwnerUserId="878" LastActivityDate="2017-07-10T13:54:14.673" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12872" PostTypeId="1" AcceptedAnswerId="12873" CreationDate="2017-07-10T18:48:38.377" Score="8" ViewCount="868" Body="&lt;p&gt;I have a custom save function, and bound it to &lt;code&gt;:w&lt;/code&gt; by using an abbreviation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cabbrev w call SaveBuffer()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works, but I ran into issues when I wanted to reference window local variables because &lt;code&gt;w:&lt;/code&gt; triggers the abbreviation. How can I get abbreviations to only trigger at the beginning of the command-line?&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-07-10T19:13:31.627" Title="How to make command-line abbreviations that only trigger at begining of line" Tags="|command-line|abbreviations|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12873" PostTypeId="2" ParentId="12872" CreationDate="2017-07-10T18:48:47.097" Score="8" Body="&lt;p&gt;First and foremost, for most cases like this you'll want to use a &lt;code&gt;command!&lt;/code&gt; instead of an abbreviation. This allows you to create a custom command-line command that will not mess up other inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can't override default vim commands with &lt;code&gt;command!&lt;/code&gt;. So an abbreviation is probably acceptable here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Abbreviations can use the special &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; argument which allows an expression to be used in the right hand side. Using this we can construct an abbreviation that only triggers at the beginning of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev &amp;lt;expr&amp;gt; w (getcmdtype() == ':' &amp;amp;&amp;amp; getcmdline() =~ '^w$')? 'call SaveBuffer()' : 'w'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;getcmdtype() == ':'&lt;/code&gt; Ensures that you are in command-line mode and not search mode (or others).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;getcmdline()&lt;/code&gt; Gets the text that is currently in the command line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;=~ '^w$'&lt;/code&gt; A regex that only matches if there is a &quot;w&quot; and nothing else.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;()? '' : ''&lt;/code&gt; A turnary statement that will use the first &lt;code&gt;''&lt;/code&gt; if the expression in the parentheses is true, or the second &lt;code&gt;''&lt;/code&gt; if it is false.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This abbreviation will technically trigger all the time, but in the other cases it simply replaces &lt;code&gt;w&lt;/code&gt; with &lt;code&gt;w&lt;/code&gt; so no harm done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info see &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#E174&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help E174&lt;/code&gt;&lt;/a&gt; (for help on how to use &lt;code&gt;command!&lt;/code&gt;) and &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap-%3Cexpr%3E&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :map-&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-07-10T19:13:31.627" LastActivityDate="2017-07-10T19:13:31.627" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12874" PostTypeId="1" CreationDate="2017-07-10T20:11:45.770" Score="0" ViewCount="244" Body="&lt;p&gt;Someone at my workplace committed non-indented JavaScript I have the VIM plugin &lt;a href=&quot;https://github.com/Chiel92/vim-autoformat&quot; rel=&quot;nofollow noreferrer&quot;&gt;autoformat&lt;/a&gt; installed and want to run &lt;code&gt;:Autoformat&lt;/code&gt; on all .js files in my project directory, how would one do this?&lt;/p&gt;&#xA;" OwnerUserId="13381" LastActivityDate="2017-09-08T22:16:52.573" Title="Run command on all .JS files in a directory recursively?" Tags="|indentation|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12875" PostTypeId="2" ParentId="12874" CreationDate="2017-07-10T20:40:20.307" Score="1" Body="&lt;p&gt;If your project directory is just a regular directory you could use &lt;code&gt;argdo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Navigate to the directory in your shell and open vim with &lt;code&gt;vim ./.*&lt;/code&gt;. This will open all the files in the directory in vim's argument list. Then you can simply do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdo Autoformat &amp;lt;BAR&amp;gt; update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Aargdo&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :argdo&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-07-10T20:40:20.307" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12878" PostTypeId="1" AcceptedAnswerId="12879" CreationDate="2017-07-11T05:18:12.597" Score="0" ViewCount="261" Body="&lt;p&gt;When I try to config my vim, I encounter something similar to below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! A_test_func(arg)&#xA;    if a:arg =~ '^.*[^i]ed$'&#xA;    \ || a:arg =~ '^.*[tk]s$'&#xA;        echo a:arg&#xA;    endif&#xA;endfunc&#xA;&#xA;call A_test_func('works')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which results error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E10: \ should be followed by /, ? or &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have read &lt;code&gt;:h E10&lt;/code&gt;, and &lt;code&gt;:h line-continuation&lt;/code&gt; then to make sure&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cp?     &quot; echos `nocompatible`&#xA;set cpo?    &quot; echos `cpoptions=aABceFs`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also tried to put &lt;code&gt;||&lt;/code&gt; at first line, error too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus I wonder, is line-continuation forbidden for &lt;code&gt;||&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2017-07-11T06:27:11.923" Title="vimscript: Is logical-or operator's two operands must stay in the same line?" Tags="|vimscript|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12879" PostTypeId="2" ParentId="12878" CreationDate="2017-07-11T06:27:11.923" Score="2" Body="&lt;p&gt;Found it! The problem is indeed related to the order of &lt;code&gt;cpo&lt;/code&gt; option setting.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verb set cp?&#xA;nocompatible&#xA;    Last set from /etc/vimrc&#xA;&#xA;:verb set cpo?&#xA;cpoptions=aABceFs&#xA;    Last set from /usr/share/vim/vim80/scripts.vim&#xA;&#xA;:scr&#xA;  1: /etc/vimrc&#xA;  7: ~/.vimrc&#xA; 37: /usr/share/vim/vim80/scripts.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks to @muru, and @Christian Brabandt for pointing me towards the right course.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2017-07-11T06:27:11.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12880" PostTypeId="2" ParentId="3093" CreationDate="2017-07-11T10:01:43.533" Score="5" Body="&lt;p&gt;Based on &lt;a href=&quot;https://vi.stackexchange.com/a/3104/5410&quot;&gt;Drew's answer&lt;/a&gt; this setup worked better for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It &lt;em&gt;increases&lt;/em&gt; or &lt;em&gt;decreases&lt;/em&gt; font-size using &lt;strong&gt;&lt;code&gt;\+&lt;/code&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;code&gt;\-&lt;/code&gt;&lt;/strong&gt; (assuming &lt;code&gt;\&lt;/code&gt; is your leader), and &lt;em&gt;cycles&lt;/em&gt; through the predefined fonts using &lt;strong&gt;&lt;code&gt;cot&lt;/code&gt;&lt;/strong&gt;. I often swap between these fonts depending on whether I am working with source code or text.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:fnt_types = ['SourceCode\ Pro', 'monofur' ]&#xA;let g:fnt_sizes = [ 10, 13 ]&#xA;&#xA;&#xA;let g:fnt_index = 0&#xA;let g:fnt_size  = g:fnt_sizes[g:fnt_index]&#xA;&#xA;function! CycleFont()&#xA;  let g:fnt_index = (g:fnt_index + 1) % len(g:fnt_types)&#xA;  let g:fnt_size  = g:fnt_sizes[g:fnt_index]&#xA;  call ResetFont()&#xA;endfunction&#xA;&#xA;function! ResetFont ()&#xA;  if has('gui_running')&#xA;    exe ':set guifont=' . g:fnt_types[g:fnt_index] . '\ ' . string(g:fnt_size)&#xA;  endif&#xA;endfunction&#xA;&#xA;call ResetFont()&#xA;&#xA;function! FontSizePlus ()&#xA;  let g:fnt_size = g:fnt_size + 0.5&#xA;  call ResetFont()&#xA;endfunction&#xA;&#xA;function! FontSizeMinus ()&#xA;  let g:fnt_size = g:fnt_size - 0.5&#xA;  call ResetFont()&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;+ :call FontSizePlus()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;- :call FontSizeMinus()&amp;lt;cr&amp;gt;&#xA;nnoremap cot :call CycleFont()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5410" LastActivityDate="2017-07-11T10:01:43.533" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12882" PostTypeId="1" CreationDate="2017-07-11T13:27:40.517" Score="10" ViewCount="3387" Body="&lt;p&gt;I want to select the 6th item (here &lt;code&gt;readImage&lt;/code&gt;) in the auto-completion items.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0YqZZ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0YqZZ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The normal way i knew is pressing &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt; for 6 times until the matched word is selected and then press &lt;kbd&gt;enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried different solutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;With the mouse:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set mouse=a &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then moving my cursor on the 6th word,and clicking mouse,no effect.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;By entering a number:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;6&lt;/kbd&gt;, no effect.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What is your smart way to select matched item in auto-completion?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim version on mouse is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version | tr -s  &quot; &quot; &quot;\n&quot; |grep mouse&#xA;+mouse_sgr&#xA;-mouse_sysmouse&#xA;+mouse_urxvt&#xA;+mouse_xterm&#xA;+mouse&#xA;-mouseshape&#xA;+mouse_dec&#xA;-mouse_gpm&#xA;-mouse_jsbterm&#xA;+mouse_netterm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="5181" LastEditDate="2017-07-12T01:23:21.557" LastActivityDate="2019-10-16T01:01:50.250" Title="How to select a matched autocompletion item" Tags="|autocompletion|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12884" PostTypeId="2" ParentId="5639" CreationDate="2017-07-12T17:17:05.943" Score="0" Body="&lt;p&gt;I've found that typing &lt;code&gt;Ctrl+C&lt;/code&gt; would go back to command input and then typing &lt;code&gt;visual&lt;/code&gt; should bring you back to normal editing the document.&lt;/p&gt;&#xA;" OwnerUserId="11798" LastActivityDate="2017-07-12T17:17:05.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12885" PostTypeId="2" ParentId="12787" CreationDate="2017-07-13T02:19:37.480" Score="10" Body="&lt;p&gt;Try a contained syntax region:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match TooLong contained containedin=pythonComment /\%50c.*/&#xA;hi link TooLong Error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of &lt;code&gt;50&lt;/code&gt;, use &lt;code&gt;80&lt;/code&gt; or &lt;code&gt;72&lt;/code&gt; or whichever column you prefer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ah7kI.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ah7kI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-07-13T02:19:37.480" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12886" PostTypeId="1" AcceptedAnswerId="12888" CreationDate="2017-07-13T04:13:46.197" Score="1" ViewCount="188" Body="&lt;p&gt;I'm adding a buffer-local mapping to close netrw windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/ftplugin/netrw.vim&#xA;nnoremap &amp;lt;buffer&amp;gt; q &amp;lt;C-W&amp;gt;c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works, but it hesitates because Netrw has created other mappings with a &lt;code&gt;q&lt;/code&gt; prefix, namely &lt;code&gt;qb&lt;/code&gt;, &lt;code&gt;qf&lt;/code&gt;, &lt;code&gt;qF&lt;/code&gt;, and &lt;code&gt;qL&lt;/code&gt;, so it waits for the duration of &lt;code&gt;'timeoutlen'&lt;/code&gt; before executing my mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want my &lt;code&gt;q&lt;/code&gt; mapping to be instantaneous, so I've unmapped the other &lt;code&gt;q&lt;/code&gt;-sequences:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nunmap &amp;lt;buffer&amp;gt; qb&#xA;nunmap &amp;lt;buffer&amp;gt; qf&#xA;nunmap &amp;lt;buffer&amp;gt; qF&#xA;nunmap &amp;lt;buffer&amp;gt; qL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But rather than hard-code these and have to update them if netrw adds more &lt;code&gt;q&lt;/code&gt; mappings, I'd like to programmatically fetch a list of the keys my netrw buffer has mapped to sequences beginning with &lt;code&gt;q&lt;/code&gt; and use that to drive the unmappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose I could parse the output of &lt;code&gt;:nmap&lt;/code&gt;, but that seems like a kludge. Is this information more directly accessible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer provided below worked perfectly. It turns out, however, there's a way I can avoid the need to fetch these keybindings in the first place:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help map-nowait&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I came across this when reading through the &lt;a href=&quot;https://github.com/justinmk/vim-dirvish/blob/master/ftplugin/dirvish.vim#L1&quot; rel=&quot;nofollow noreferrer&quot;&gt;dirvish&lt;/a&gt; plugin. So rather then perform any &lt;code&gt;nunmap&lt;/code&gt;s, I just changed my ftplugin file to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;nowait&amp;gt; &amp;lt;buffer&amp;gt; q &amp;lt;C-W&amp;gt;c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it works right away!&lt;/p&gt;&#xA;" OwnerUserId="1855" LastEditorUserId="1855" LastEditDate="2017-07-14T23:57:11.647" LastActivityDate="2017-07-14T23:57:11.647" Title="Vimscript: fetch list of keymappings containing a prefix?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12888" PostTypeId="2" ParentId="12886" CreationDate="2017-07-13T07:05:52.500" Score="2" Body="&lt;p&gt;EDIT: My mistake: Neither &lt;code&gt;getcompletion()&lt;/code&gt; nor the old trick (see my &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/command.vim#L133&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;lh#command#matchging_askvim()&lt;/code&gt;&lt;/a&gt; function) are able to return buffer-local mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means: I'm not aware of any way other than parsing  &lt;code&gt;execute('nmap q')&lt;/code&gt; result. This means you'll may need to decrypt &lt;code&gt;@&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt;. From &lt;code&gt;execute()&lt;/code&gt; result, I'll simply extract the keybindings. Then, I'll use &lt;code&gt;maparg()&lt;/code&gt; to have more precise information.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let keybindings = map(split(execute('nmap q'), '\n'), 'split(v:val, &quot;\\W\\+&quot;)[1]')&#xA;let mappings =  map(copy(keybindings), 'maparg(v:val, &quot;n&quot;, 0, 1)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NB: in lh-vim-lib, I have other functions able to obtain mapping states and to restore them eventually. See &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/on.vim#L155&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;lh#on#exit().restore_mapping_and_clear_now()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-07-13T14:14:10.740" LastActivityDate="2017-07-13T14:14:10.740" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12889" PostTypeId="1" CreationDate="2017-07-13T07:19:47.737" Score="3" ViewCount="690" Body="&lt;p&gt;I usually use a layout of one vertical split and two different buffers. When i use &lt;code&gt;:copen&lt;/code&gt;, the quickfix window always opens in the right split, regardless where my cursor is. Consequently, if my cursor is in the left split, and I issue the commands &lt;code&gt;:copen&lt;/code&gt;, &lt;code&gt;:cclose&lt;/code&gt;, the buffer is changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way of opening the quickfix window in the same vertical split where my cursor is?&lt;/p&gt;&#xA;" OwnerUserId="10357" LastActivityDate="2017-07-13T07:19:47.737" Title="Open quickfix in current vertical split" Tags="|quickfix|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12892" PostTypeId="1" AcceptedAnswerId="12893" CreationDate="2017-07-13T18:07:14.323" Score="0" ViewCount="4403" Body="&lt;p&gt;So I'm trying to use &lt;a href=&quot;https://github.com/w0ng/vim-hybrid&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim-Hybrid&lt;/a&gt; as my native Vim theme but I've been running into a couple issues with it. Everytime I run the vim command now, I've been receiving the following error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E488: Trailing characters:       &amp;lt;/tr&amp;gt;&#xA;line 2194:&#xA;E488: Trailing characters:       &amp;lt;tr&amp;gt;&#xA;line 2195:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's a lot more trailing character errors that are firing but I believe that there might be an error with my ~/.vim/colors/hybrid.vim - which I copied and pasted from the repo into the the respective path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the content within my .vimrc: I followed the installation instructions, which told me to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Add to ~/.vimrc:&#xA;&#xA;set background=dark&#xA;colorscheme hybrid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Further down in the instructions, I was also told to add the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:hybrid_custom_term_colors = 1&#xA;let g:hybrid_reduced_contrast = 1 &quot; Remove this line if using the &#xA;default palette.&#xA;colorscheme hybrid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My .vimrc currently looks like this now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:hybrid_custom_term_colors = 1&#xA;let g:hybrid_reduced_contrast = 1&#xA;set background=dark&#xA;colorscheme hybrid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea what went wrong? Any help would be appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Ninja Edit: Forgot to mention that I'm using iTerm!&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="13425" LastActivityDate="2017-07-13T18:41:43.427" Title="E488: Trailing Characters error after attempting to install vim-hybrid" Tags="|vimrc|colorscheme|macvim|iterm2|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12893" PostTypeId="2" ParentId="12892" CreationDate="2017-07-13T18:41:43.427" Score="1" Body="&lt;p&gt;You apparently copy and pasted some html code into your colorscheme file. If you open the file in &lt;a href=&quot;https://github.com/w0ng/vim-hybrid/blob/master/colors/hybrid.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;, click on the &lt;a href=&quot;https://raw.githubusercontent.com/w0ng/vim-hybrid/master/colors/hybrid.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;RAW link&lt;/a&gt; and copy paste again and make sure to overwrite the previous version. (Even better would be to simply download that file using wget or similar)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-13T18:41:43.427" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12894" PostTypeId="1" CreationDate="2017-07-13T20:53:57.490" Score="1" ViewCount="224" Body="&lt;p&gt;When you run &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow noreferrer&quot;&gt;fugitive&lt;/a&gt;'s &lt;code&gt;:Gblame&lt;/code&gt;, it opens a buffer whose 'filetype' is &lt;code&gt;fugitiveblame&lt;/code&gt;. You can hit &lt;code&gt;q&lt;/code&gt; to close its window. You can also hit &lt;code&gt;o&lt;/code&gt; to view the commit for the line your cursor is on in a separate split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Intuitively, I'd expect to be able to hit &lt;code&gt;q&lt;/code&gt; in this window as well, dismissing the commit view, but no such mapping is provided. I'd like to add one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 'filetype' for the commit buffer is &lt;code&gt;git&lt;/code&gt;, and I'm worried there might be other things that use that filetype, so I'm a little hesitant to add a &lt;code&gt;q&lt;/code&gt; mapping to &lt;code&gt;~/.vim/ftplugin/git.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how specific to fugitive the &lt;code&gt;git&lt;/code&gt; 'filetype' is?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2017-07-13T20:53:57.490" Title="How fugitive-specific is the 'git' filetype?" Tags="|git|plugin-fugitive|filetype-git|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12895" PostTypeId="1" CreationDate="2017-07-14T01:12:09.827" Score="0" ViewCount="444" Body="&lt;p&gt;Is it possible to load multiple files at the same using :edit? I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e ~/dev/myproject/*.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it did not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note this is different than &quot;How to open multiple files matching a wildcard expression?&quot; because in that question he is not using :edit)&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2017-07-14T19:09:10.107" Title="Open multiple files using ex command :edit and a wildcard" Tags="|multiple-files|" AnswerCount="0" CommentCount="5" FavoriteCount="0" ClosedDate="2017-07-14T19:05:05.397" ContentLicense="CC BY-SA 3.0" />
  <row Id="12896" PostTypeId="2" ParentId="11646" CreationDate="2017-07-14T04:28:19.280" Score="1" Body="&lt;p&gt;Have you tried using &lt;code&gt;:nnoremap&lt;/code&gt; or &lt;code&gt;:nmap&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;causing the mapping to exist only in normal mode&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Instead of just &lt;code&gt;:map&lt;/code&gt; or &lt;code&gt;:noremap&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Which causes the mapping to exist in all modes (I think)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="13429" LastActivityDate="2017-07-14T04:28:19.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12898" PostTypeId="2" ParentId="12857" CreationDate="2017-07-14T11:49:04.770" Score="1" Body="&lt;p&gt;I'm not sure why &lt;code&gt;&amp;lt;C-C&amp;gt;&lt;/code&gt; does not trigger of an abbreviation after &lt;code&gt;:inoremap &amp;lt;C-C&amp;gt; &amp;lt;C-[&amp;gt;&lt;/code&gt;, but if you &lt;code&gt;:inoremap &amp;lt;C-C&amp;gt; &amp;lt;C-]&amp;gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; abbreviations are correctly expanded.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastActivityDate="2017-07-14T11:49:04.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12899" PostTypeId="1" CreationDate="2017-07-14T13:50:45.980" Score="1" ViewCount="133" Body="&lt;p&gt;I notice an annoying stutter when opening directories. Just a split second, but it's kind of a problem if I'm navigating the directory tree and it hesitates each time I open a different directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it might be double-loading something so to debug, I put the following in &lt;code&gt;~/.vim/ftplugin/netrw.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('s:count')&#xA;  let s:count = 0&#xA;endif&#xA;let s:count += 1&#xA;&#xA;func! Count()&#xA;  echo s:count&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and mapped &lt;code&gt;&amp;lt;leader&amp;gt;j&lt;/code&gt; to call &lt;code&gt;Count()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I open a file in vim, and run &lt;code&gt;:edit %:h&lt;/code&gt;, a netrw buffer opens with the file's containing directory as expected. The &lt;code&gt;s:count&lt;/code&gt; is 2, so my ftplugin was indeed double-loaded. Hitting Enter on a listing to edit that file increments &lt;code&gt;s:count&lt;/code&gt; by 1 more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's consistent: every time navigate into a directory-buffer, &lt;code&gt;s:count&lt;/code&gt; increments by 2, every time I navigate down the file-tree, &lt;code&gt;s:count&lt;/code&gt; increments by 1. This also means that if move down the tree into a subdirectory, it increments by 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a good indicator that something is loading more times than necessary, and if so how might I fix it?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2017-07-14T13:50:45.980" Title="netrw: ftplugin double loaded?" Tags="|netrw|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12900" PostTypeId="2" ParentId="12853" CreationDate="2017-07-14T15:05:34.563" Score="1" Body="&lt;p&gt;I use a &lt;code&gt;normal&lt;/code&gt; command aliased to &lt;code&gt;Sh&lt;/code&gt; and then place the command I want to run after it.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this text in a sourced file (e.g. vimrc):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* -complete=shellcmd ShellRead new | setlocal buftype=nofile bufhidden=hide noswapfile | read !&amp;lt;args&amp;gt;&#xA;cabbrev Sh ShellRead&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then type:&#xA;&lt;code&gt;Sh !make c&lt;/code&gt;&#xA;instead of using the &lt;code&gt;!&lt;/code&gt; and the command runs and shows the output in a new window within vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does consume the vim session, however, so mainly I use it for quick tasks.&lt;/p&gt;&#xA;" OwnerUserId="2303" LastActivityDate="2017-07-14T15:05:34.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12901" PostTypeId="1" CreationDate="2017-07-14T17:16:34.907" Score="7" ViewCount="1018" Body="&lt;p&gt;Lately I've been shifting more nad more of my work from IntelliJ to vim. With a handful of plugins and setting tweaks, I don't miss the IDE much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing I do miss is the ease of navigating a large directory tree of source files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm working on a medium sized project with 39 source files. split across a handful of directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IntelliJ would display the project directory like &lt;a href=&quot;https://i.stack.imgur.com/btMWB.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/btMWB.png&quot; alt=&quot;this&quot;&gt;&lt;/a&gt; (not my picture). If you aren't familiar with an IDE you can click on one of the files to open it in your main editing window, or a split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I just have a bunch of Tmux panes open, but that's only effective for two or three files before the panes get too small.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tmux Sidebar visually replicates the feature, but you still need to manually type in a file name + path to edit it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's native &lt;code&gt;:Ex&lt;/code&gt; and &lt;code&gt;:Sex&lt;/code&gt; work well, but (as far as I can tell) there isn't a way to use them to open a file in another split. I'd like to be able to have it open, and be able to use it to open files in existing buffers/splits.&lt;/p&gt;&#xA;" OwnerUserId="13185" LastActivityDate="2018-03-10T10:41:10.573" Title="What workflow to use when editing large multifile projects" Tags="|split|filesystem|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12902" PostTypeId="1" CreationDate="2017-07-14T20:26:38.753" Score="3" ViewCount="251" Body="&lt;p&gt;I'm trying to develop a plugin that would show results of SQL queries, by executing them inside tmux split and using mysql pager option to save them to the specific file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want now is to either create the new window to show results (if no such window have been created before) or reuse created one. But I don't know how to identify windows and how to switch to the specific window.&#xA;For example, let's say I always want to display results in a horizontal split. How do I know that such split doesn't exist already? Try &lt;code&gt;wincmd j&lt;/code&gt; and check if &lt;code&gt;winnr&lt;/code&gt; haven't changed? What if user would move this window to another location? How do a find it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:ShowResults(query_hash, jobid, data, event)&#xA;    unlet s:jobid&#xA;    if exists('s:results_window')&#xA;        exe s:results_window . ' wincmd w'&#xA;    else&#xA;        split&#xA;        wincmd j&#xA;    endif&#xA;    exe 'view /tmp/queries/' . a:query_hash&#xA;    let s:results_window = winnr()&#xA;    setlocal nowrap&#xA;    nnoremap &amp;lt;buffer&amp;gt; q :q&amp;lt;CR&amp;gt;&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="4472" LastEditDate="2017-09-13T22:04:57.300" LastActivityDate="2018-01-12T00:03:10.383" Title="How to open file in specific window (create or reuse)?" Tags="|vim-windows|plugin-system|tmux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12903" PostTypeId="2" ParentId="12902" CreationDate="2017-07-14T22:33:41.600" Score="2" Body="&lt;p&gt;That's what I've done in lh-vim-lib &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/buffer.vim#L106&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;lh#buffer#jump()&lt;/code&gt;&lt;/a&gt;. You'll have to adapt the &lt;code&gt;...#find()&lt;/code&gt; function to one that fits better your needs. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Function: lh#buffer#jump({filename},{cmd}) {{{2&#xA;function! lh#buffer#jump(filename, cmd) abort&#xA;  let b = lh#buffer#find(a:filename)&#xA;  if b != -1 || type(a:filename) == type(0) | return b | endif&#xA;  call lh#window#create_window_with(a:cmd . ' ' . a:filename)&#xA;  return winnr()&#xA;endfunction&#xA;&#xA;&quot; Function: lh#buffer#find({filename}) {{{2&#xA;&quot; If {filename} is opened in a window, jump to this window, otherwise return -1&#xA;&quot; Moved from searchInRuntimeTime.vim&#xA;function! lh#buffer#find(filename) abort&#xA;  let b = bufwinnr(a:filename)&#xA;  &quot; Workaround a bug in event execution: we may a have a non null buffer, but&#xA;  &quot; with a name that doesn't match what is looked for.&#xA;  &quot; -&amp;gt; &quot;|| bufname(winbufnr(b)) != a:filename&quot;&#xA;  &quot; The second case is used when the filename is actually a buffer name&#xA;  if b == -1 || (fnamemodify(bufname(winbufnr(b)), ':p') != fnamemodify(a:filename, ':p') &amp;amp;&amp;amp; winbufnr(b) != a:filename)&#xA;    return -1&#xA;  endif&#xA;  exe b.'wincmd w'&#xA;  return b&#xA;endfunction&#xA;&#xA;&quot; Function: lh#window#create_window_with(cmd) {{{3&#xA;&quot; Since a few versions, vim throws a lot of E36 errors around:&#xA;&quot; everythime we try to split from a windows where its height equals &amp;amp;winheight&#xA;&quot; (the minimum height)&#xA;function! lh#window#create_window_with(cmd) abort&#xA;  try&#xA;    exe a:cmd&#xA;  catch /E36:/&#xA;    &quot; Try again after an increase of the current window height&#xA;    resize +1&#xA;    exe a:cmd&#xA;  endtry&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But ... what about using the quickfix window?&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-08-13T23:24:05.900" LastActivityDate="2017-08-13T23:24:05.900" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12904" PostTypeId="1" AcceptedAnswerId="12905" CreationDate="2017-07-14T22:51:25.307" Score="0" ViewCount="407" Body="&lt;p&gt;How do you move a single line in Vim with a shortcut, and make the indent always be correct, as is displayed here:&#xA;&lt;a href=&quot;https://twitter.com/manucorporat/status/885054730812223489?s=09&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://twitter.com/manucorporat/status/885054730812223489?s=09&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="605" LastActivityDate="2017-07-19T06:56:00.030" Title="Move line include indent" Tags="|vimrc|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12905" PostTypeId="2" ParentId="12904" CreationDate="2017-07-15T02:17:48.667" Score="2" Body="&lt;p&gt;Easy peasy. To map &lt;kbd&gt;CONTROL&lt;/kbd&gt;+&lt;kbd&gt;DOWN&lt;/kbd&gt; and &lt;kbd&gt;CONTROL&lt;/kbd&gt;+&lt;kbd&gt;UP&lt;/kbd&gt; you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it go &lt;strong&gt;down&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap &amp;lt;C-DOWN&amp;gt; ddp==&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make it go &lt;strong&gt;up&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap &amp;lt;C-UP&amp;gt; ddkP==&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can choose other keys to map, and you can just type the commands and repeat, no need to map. Very basic stuff.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edited: as the answer by Naumann bellow pointed out, vim already have &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;]p&lt;/code&gt; : &lt;code&gt;p==&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[p&lt;/code&gt; : &lt;code&gt;P==&lt;/code&gt; (upper-case P)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, if you still want to map the keys, you may use that instead of &lt;code&gt;p==&lt;/code&gt; or &lt;code&gt;P==&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;BTW, I made a video as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://youtu.be/BARhbRzOa1Y&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://youtu.be/BARhbRzOa1Y&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edited:&#xA;An explanation to this issue can be read &lt;a href=&quot;http://vim.wikia.com/wiki/Moving_lines_up_or_down&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;a href=&quot;https://stackoverflow.com/a/15399297/670521&quot;&gt;answer&lt;/a&gt; of how map &lt;kbd&gt;ALT&lt;/kbd&gt; key also uses exactly this example to illustrate it.&lt;/p&gt;&#xA;" OwnerUserId="13368" LastEditorUserId="4472" LastEditDate="2017-07-19T06:56:00.030" LastActivityDate="2017-07-19T06:56:00.030" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12906" PostTypeId="2" ParentId="12904" CreationDate="2017-07-15T02:31:46.103" Score="2" Body="&lt;p&gt;Vim already has &lt;code&gt;]p&lt;/code&gt; and &lt;code&gt;[p&lt;/code&gt; for this&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;]p&lt;/code&gt; : like &lt;code&gt;p&lt;/code&gt;, but adjust indent to current line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[p&lt;/code&gt; : adjust indent to current line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Read &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%5dp&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ]p&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%5bp&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help [p&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="6698" LastEditDate="2017-07-15T23:35:14.893" LastActivityDate="2017-07-15T23:35:14.893" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12907" PostTypeId="1" CreationDate="2017-07-15T03:23:33.003" Score="1" ViewCount="50" Body="&lt;p&gt;I use &lt;strong&gt;&lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;&lt;/strong&gt; as my leader key, with a short &lt;code&gt;timeoutlen&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = ' '&#xA;set timeout timeoutlen=300 ttimeoutlen=5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sometimes in normal mode, I hit &lt;strong&gt;&lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;&lt;/strong&gt; then hesitate (maybe I changed my mind), letting the timeout expire as I consider my next move.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally this would trigger the default &lt;strong&gt;&lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;&lt;/strong&gt; behavior, moving cursor to the right. To prevent this, I've added:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Space&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with this is, after the timeout has expired, I can't reinitiate a leader key-sequence until I run some (any) other command, such as hitting &lt;code&gt;Esc&lt;/code&gt;. It's as if I need to break out of the &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt; with some intervening command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, with &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;j &amp;lt;Plug&amp;gt;(foo)&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I type &lt;strong&gt;&lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;&lt;/strong&gt; and let the timeout expire&lt;/li&gt;&#xA;&lt;li&gt;then I type &lt;strong&gt;&lt;code&gt;&amp;lt;Space&amp;gt;j&lt;/code&gt;&lt;/strong&gt; expecting it to run &lt;code&gt;&amp;lt;Plug&amp;gt;(foo)&lt;/code&gt;, but it does nothing&lt;/li&gt;&#xA;&lt;li&gt;I hit &lt;code&gt;Esc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;I type &lt;strong&gt;&lt;code&gt;&amp;lt;Space&amp;gt;j&lt;/code&gt;&lt;/strong&gt; --&gt; Vim runs &lt;code&gt;&amp;lt;Plug&amp;gt;(foo)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I change my mapleader to &lt;strong&gt;&lt;code&gt;\&lt;/code&gt;&lt;/strong&gt; and do &lt;code&gt;map &amp;lt;Space&amp;gt; \&lt;/code&gt;, I don't have this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's causing this timeout/Nop behavior? Is there a way to fix it, or should I use the &lt;strong&gt;&lt;code&gt;\&lt;/code&gt;&lt;/strong&gt; workaround?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Update&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This appears to be a known (recent?) bug.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/neovim/neovim/pull/6419&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neovim/neovim/pull/6419&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim/issues/1548&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/issues/1548&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/neovim/neovim/issues/6241&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neovim/neovim/issues/6241&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1855" LastEditorUserId="1855" LastEditDate="2017-07-21T17:31:30.250" LastActivityDate="2017-07-21T17:31:30.250" Title="mapleader &amp; &lt;Nop&gt;: strange timeout behavior" Tags="|key-bindings|" AnswerCount="0" CommentCount="1" ClosedDate="2017-10-10T20:00:34.323" ContentLicense="CC BY-SA 3.0" />
  <row Id="12908" PostTypeId="1" AcceptedAnswerId="13561" CreationDate="2017-07-15T03:33:02.333" Score="1" ViewCount="135" Body="&lt;p&gt;I'd like to provide anyone reading my plugin in Vim a direct link to the help article on &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:command-completion&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;command-completion&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment, I'm simply saying &lt;code&gt;&quot; :help command-completion&lt;/code&gt; but i'd love to do something like&lt;code&gt;&quot; |command-completion|&lt;/code&gt; to allow a user to navigate directrly with &lt;code&gt;C-]&lt;/code&gt;. I've tried a few random combinations but nothing seems to work. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="12886" LastActivityDate="2017-09-14T05:45:40.463" Title="Linking to documentation in a comment" Tags="|vimscript|help-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12909" PostTypeId="1" AcceptedAnswerId="12910" CreationDate="2017-07-15T15:59:51.907" Score="2" ViewCount="742" Body="&lt;p&gt;I use &lt;kbd&gt;Ctrl-R&lt;/kbd&gt; to paste in vim when I am in insert mode, but this , more often than, not messes up the inentation and I have to indent it manually or use &lt;kbd&gt;=&lt;/kbd&gt;. All this makes &lt;kbd&gt;Ctrl-R&lt;/kbd&gt; same as going to normal mode and use &lt;kbd&gt;]p&lt;/kbd&gt; if not less efficient. Any way to paste while in insert mode without messing up indentation ? &lt;/p&gt;&#xA;" OwnerDisplayName="user9120" LastActivityDate="2017-07-15T18:28:48.843" Title="Paste without messing up indentation in insert mode" Tags="|cut-copy-paste|neovim|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12910" PostTypeId="2" ParentId="12909" CreationDate="2017-07-15T18:28:48.843" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;https://neovim.io/doc/user/insert.html#i_CTRL-R_CTRL-P&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-R_CTRL-P&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-R CTRL-P {0-9a-z&quot;%#*+/:.-=}            *i_CTRL-R_CTRL-P*&#xA;    Insert the contents of a register literally and fix the&#xA;    indent, like |[&amp;lt;MiddleMouse&amp;gt;|.&#xA;    Does not replace characters!&#xA;    The '.' register (last inserted text) is still inserted as&#xA;    typed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6698" LastActivityDate="2017-07-15T18:28:48.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12911" PostTypeId="1" AcceptedAnswerId="12924" CreationDate="2017-07-15T22:00:34.617" Score="0" ViewCount="86" Body="&lt;p&gt;I'd like to map &lt;strong&gt;&lt;code&gt;q&lt;/code&gt;&lt;/strong&gt; to &lt;code&gt;:cclose&lt;/code&gt; in the quickfix window, but I wonder if I'd be locking myself out of a world of wonderful macros by doing so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there realistic scenarios where you'd want to be able to start recording a macro from the quickfix window? The only one I can think of is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;open the current error&lt;/li&gt;&#xA;&lt;li&gt;do something&lt;/li&gt;&#xA;&lt;li&gt;return to the quickfix window&lt;/li&gt;&#xA;&lt;li&gt;move down to the next error&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But I think it would be more convenient to open the current error, start the macro from that buffer, do something, and use &lt;code&gt;:cnext&lt;/code&gt; to move to the next error. That way you don't have to jump back and forth between windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a more compelling use-case for preserving the default &lt;strong&gt;&lt;code&gt;q&lt;/code&gt;&lt;/strong&gt; keybinding in the quickfix window?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2017-07-16T23:20:06.920" Title="Would you ever want to start recording a macro from the quickfix window?" Tags="|key-bindings|macro|quickfix|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12912" PostTypeId="2" ParentId="12904" CreationDate="2017-07-15T22:18:41.290" Score="1" Body="&lt;p&gt;This might help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;A-j&amp;gt; :m .+1&amp;lt;CR&amp;gt;==&#xA;nnoremap &amp;lt;A-k&amp;gt; :m .-2&amp;lt;CR&amp;gt;==&#xA;inoremap &amp;lt;A-j&amp;gt; &amp;lt;Esc&amp;gt;:m .+1&amp;lt;CR&amp;gt;==gi&#xA;inoremap &amp;lt;A-k&amp;gt; &amp;lt;Esc&amp;gt;:m .-2&amp;lt;CR&amp;gt;==gi&#xA;vnoremap &amp;lt;A-j&amp;gt; :m '&amp;gt;+1&amp;lt;CR&amp;gt;gv=gv&#xA;vnoremap &amp;lt;A-k&amp;gt; :m '&amp;lt;-2&amp;lt;CR&amp;gt;gv=gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Thank dr-beco Indeed you need the following configuration in your vimrc file in order to have your alt key mapped.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Make Alt key work&#xA;let c='a'&#xA;while c &amp;lt;= 'z'&#xA;  exec &quot;set &amp;lt;A-&quot;.c.&quot;&amp;gt;=\e&quot;.c&#xA;  exec &quot;imap \e&quot;.c.&quot; &amp;lt;A-&quot;.c.&quot;&amp;gt;&quot;&#xA;  let c = nr2char(1+char2nr(c))&#xA;endw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can use it with alt-j / alt-k&lt;/p&gt;&#xA;" OwnerUserId="13447" LastEditorUserId="13447" LastEditDate="2017-07-18T10:59:34.300" LastActivityDate="2017-07-18T10:59:34.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12913" PostTypeId="2" ParentId="12901" CreationDate="2017-07-16T02:06:47.730" Score="1" Body="&lt;p&gt;Install fuzzy searcher plugin, search any file you want then open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example install &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;ctrlp.vim&lt;/a&gt;, &lt;a href=&quot;https://github.com/FelikZ/ctrlp-py-matcher&quot; rel=&quot;nofollow noreferrer&quot;&gt;ctrlp-py-matcher&lt;/a&gt; and &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;nofollow noreferrer&quot;&gt;the_silver_searcher&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add these settings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tracyone/t-vim/blob/master/rc/jump.vim#L79-L149&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tracyone/t-vim/blob/master/rc/jump.vim#L79-L149&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10798" LastActivityDate="2017-07-16T02:06:47.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12914" PostTypeId="2" ParentId="3093" CreationDate="2017-07-16T02:15:15.223" Score="3" Body="&lt;p&gt;You can try this plugin:&lt;a href=&quot;https://github.com/thinca/vim-fontzoom&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-fontzoom&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;m-o&amp;gt; :Fontzoom!&amp;lt;cr&amp;gt;&#xA;map &amp;lt;m--&amp;gt; &amp;lt;Plug&amp;gt;(fontzoom-smaller)&#xA;map &amp;lt;m-=&amp;gt; &amp;lt;Plug&amp;gt;(fontzoom-larger)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10798" LastActivityDate="2017-07-16T02:15:15.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12915" PostTypeId="1" AcceptedAnswerId="12917" CreationDate="2017-07-16T02:52:43.467" Score="5" ViewCount="4839" Body="&lt;p&gt;My current configuration makes vim automatically expand &lt;kbd&gt;TAB&lt;/kbd&gt; to 4 spaces for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Define tab as 4 spaces&#xA;&quot; Taken from http://stackoverflow.com/questions/1878974/redefine-tab-as-4-spaces&#xA;set tabstop=4       &quot; The width of a TAB is set to 4.&#xA;                    &quot; Still it is a \t. It is just that&#xA;                    &quot; Vim will interpret it to be having&#xA;                    &quot; a width of 4.&#xA;set shiftwidth=4    &quot; Indents will have a width of 4&#xA;set softtabstop=4   &quot; Sets the number of columns for a TAB&#xA;set expandtab       &quot; Expand TABs to spaces&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While it is nice to make Tab 4 spaces in Python, a four-space indent in HTML files is just too much. I want to make vim detect the file type, and choose how many spaces to expand Tab into. For example, 2 for HTML and 4 for other file types.&lt;/p&gt;&#xA;" OwnerUserId="6335" LastActivityDate="2022-03-28T23:22:26.093" Title="Expand &lt;TAB&gt; into 2 spaces when and only when editing HTML" Tags="|indentation|formatting|whitespace|filetype-html|tab-characters|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12916" PostTypeId="2" ParentId="12630" CreationDate="2017-07-16T04:54:17.423" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;install fonts with powerline symbol.&lt;a href=&quot;https://github.com/Magnetic2014/YaHei-Consolas-Hybrid-For-Powerline&quot; rel=&quot;nofollow noreferrer&quot;&gt;YaHei-Consolas-Hybrid-For-Powerline&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;set your terminal's font  to this font.&lt;/li&gt;&#xA;&lt;li&gt;set guifont and guifontwide to this font in the case gvim &amp;amp; macvim.see &lt;a href=&quot;https://github.com/tracyone/t-vim/blob/master/rc/gui.vim#L28-L34&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;set airline symbol.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tracyone/t-vim/blob/master/rc/airline.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tracyone/t-vim/blob/master/rc/airline.vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10798" LastActivityDate="2017-07-16T04:54:17.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12917" PostTypeId="2" ParentId="12915" CreationDate="2017-07-16T05:07:26.770" Score="7" Body="&lt;p&gt;Put this in your .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead,BufNewFile *.htm,*.html setlocal tabstop=2 shiftwidth=2 softtabstop=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Briefly, autocmds get processed when the specified events occur for the specified file name patterns. Here we just set the tab values for the current buffer to the desired value in the event of reading or creating a file with &lt;code&gt;.htm&lt;/code&gt; or &lt;code&gt;.html&lt;/code&gt; extension.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many other ways you can customize your settings for a file type: change the color scheme, modify settings globally or locally, run a script or some editor commands, and so on. &lt;code&gt;:help autocmd&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-07-16T06:37:11.120" LastActivityDate="2017-07-16T06:37:11.120" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12919" PostTypeId="1" CreationDate="2017-07-16T15:57:37.817" Score="1" ViewCount="3113" Body="&lt;p&gt;Vim is not loading vim-plug plugins. When I run vim and do &lt;code&gt;:PlugInstall&lt;/code&gt;, it installs the plugins and applies them:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/l73Yy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/l73Yy.png&quot; alt=&quot;Running :PluggInstall&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what happens when I quit vim-plug interface using &lt;code&gt;:q&lt;/code&gt;, vim goes back to normal, no plugin applied:0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/U7Net.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/U7Net.png&quot; alt=&quot;vimrc&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=utf-8&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;set expandtab&#xA;set smarttab&#xA;set autoindent&#xA;set smartindent&#xA;set nowrap&#xA;set smartcase&#xA;set showmatch&#xA;set title&#xA;set ruler&#xA;set et&#xA;set relativenumber&#xA;set incsearch&#xA;set hlsearch&#xA;set autoread&#xA;set autowrite&#xA;set nobackup&#xA;set nowritebackup&#xA;set noswapfile&#xA;set nocompatible&#xA;set hidden&#xA;filetype off&#xA;syntax on&#xA;&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'VundleVim/Vundle.vim'&#xA;&#xA;Plug 'powerline/powerline'&#xA;Plug 'itchyny/lightline.vim'&#xA;Plug 'kien/ctrlp.vim'&#xA;Plug 'jistr/vim-nerdtree-tabs'&#xA;&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13454" LastEditorUserId="1841" LastEditDate="2017-07-17T07:13:28.373" LastActivityDate="2017-07-17T11:56:05.377" Title="vim not loading vim-plug plugins" Tags="|vimrc|plugin-vim-plug|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12920" PostTypeId="1" CreationDate="2017-07-16T18:34:56.403" Score="5" ViewCount="630" Body="&lt;p&gt;When I press &lt;kbd&gt;gx&lt;/kbd&gt; over a link in vim, it opens it in an external application, when it does this it also suspends Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I prevent it from suspending Vim, so that I can use Vim while browsing whatever it opened externally.&lt;/p&gt;&#xA;" OwnerUserId="13456" LastEditorUserId="51" LastEditDate="2017-07-17T16:20:21.323" LastActivityDate="2021-09-01T20:06:22.793" Title="how to stop vim suspending when using gx" Tags="|netrw|linux|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12921" PostTypeId="1" AcceptedAnswerId="12926" CreationDate="2017-07-16T21:26:16.780" Score="1" ViewCount="542" Body="&lt;p&gt;I'm trying to write a wrapper command around &lt;code&gt;:edit&lt;/code&gt; or &lt;code&gt;:find&lt;/code&gt; specifically to open either my vimrc or a subpath of &lt;code&gt;~/.vim/&lt;/code&gt; (e.g. &lt;code&gt;~.vim/autoloads/foo.vim&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run the command with no arguments, it should open &lt;code&gt;~/.vim/vimrc&lt;/code&gt;. It should accept an argument to specify a subpath of &lt;code&gt;~/.vim/&lt;/code&gt;, and provide tab completion of those subpaths.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have something that works, but it feels overly complicated. I'm having to jump through hoops to tweak &lt;code&gt;'path'&lt;/code&gt; before Vim's command completion kicks in.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:vimrc = resolve($MYVIMRC)&#xA;let s:vimrc_dir = fnamemodify(s:vimrc, ':h')&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;f&amp;lt;CR&amp;gt; :call PreparePath()&amp;lt;CR&amp;gt;:EditDotVim &#xA;&#xA;command! -complete=file_in_path -nargs=? EditDotVim :&#xA;      \ call EditDotVim(&amp;lt;f-args&amp;gt;) |&#xA;      \ call RestorePath()&#xA;&#xA;func! PreparePath()&#xA;  let s:orig_path = &amp;amp;l:path&#xA;  let s:orig_buf  = bufnr('')&#xA;  exec 'setl path='.s:vimrc_dir&#xA;endf&#xA;&#xA;func! EditDotVim(...)&#xA;  execute 'edit' a:0 ? a:1 : s:vimrc&#xA;endf&#xA;&#xA;func! RestorePath()&#xA;  call setbufvar(s:orig_buf, '&amp;amp;path', s:orig_path)&#xA;  unlet s:orig_path&#xA;  unlet s:orig_buf&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was originally using a custom completion function and using the &lt;code&gt;find&lt;/code&gt; shell builtin to provide completions, but given Vim's &lt;code&gt;'path'&lt;/code&gt; variable and &lt;code&gt;:find&lt;/code&gt; command, it seemed like I was reinventing the wheel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a more straightforward way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;UPDATE&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm still curious if there's a better way, but for now I've reverted to my original strategy, using custom completion and a little shell magic. I wouldn't call it slow, but it's not quite as snappy as I'd like, and I don't know how portable the &lt;code&gt;find&lt;/code&gt; regex is. But it works for now. I moved this into my autoload directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:vimrc = resolve($MYVIMRC)&#xA;let s:vimrc_dir = fnamemodify(s:vimrc, ':h')&#xA;&#xA;let s:sub_paths = [&#xA;      \ 'after',&#xA;      \ 'autoload',&#xA;      \ 'colors',&#xA;      \ 'compiler',&#xA;      \ 'ftdetect',&#xA;      \ 'ftplugin',&#xA;      \ 'indent',&#xA;      \ 'init',&#xA;      \ 'plugged',&#xA;      \ 'syntax',&#xA;      \ 'tmp',&#xA;      \ 'todo.org',&#xA;      \ 'view',&#xA;      \ 'vimrc'&#xA;      \]&#xA;&#xA;let s:find_paths = '{'.join(s:sub_paths, ',').'}'&#xA;&#xA;func! dotvim#edit(...)&#xA;  execute 'edit' (a:0 ? dotvim#path(a:1) : s:vimrc)&#xA;endf&#xA;&#xA;func! dotvim#list(ArgLead, CmdLine, CursorPos)&#xA;  let findcmd = &quot;find &quot; . s:find_paths .  &quot; -regex '&quot;.a:ArgLead.&quot;[^/]*' -exec ls -pd {} +&quot;&#xA;  return system(&quot;cd &quot; . s:vimrc_dir . &quot; &amp;amp;&amp;amp; &quot; . findcmd)&#xA;endf&#xA;&#xA;func! dotvim#path(subpath)&#xA;  return s:vimrc_dir . '/' . a:subpath&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I went back and forth on the hard-coded paths whitelist vs calling out to &lt;code&gt;ls&lt;/code&gt; to generate it, vs using &lt;code&gt;find *&lt;/code&gt; (if I do &lt;code&gt;find .&lt;/code&gt; I get pesky leading &lt;code&gt;./&lt;/code&gt; in my results), but ultimately the explicit whitelist makes it easy for me to tune which paths I actually care about.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and please ignore the &lt;code&gt;todo.org&lt;/code&gt; file in there. I know it's a cardinal sin having even trace amounts of emacs in my &lt;code&gt;.vim/&lt;/code&gt; ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;UPDATE II&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incorporating the &lt;code&gt;globpath&lt;/code&gt; suggestion, this got a lot cleaner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! dotvim#list(ArgLead, CmdLine, CursorPos)&#xA;  return map(globpath(s:vimrc_dir, a:ArgLead.'*', 0, 1), s:subpath_map)&#xA;endf&#xA;&#xA;let s:subpath_map = { k,v -&amp;gt; fnamemodify(v,':p')[(s:leading_len):] }&#xA;let s:leading_len = len(s:vimrc_dir) + 1&#xA;&#xA;command! -complete=customlist,dotvim#list -nargs=? DotVim call dotvim#edit(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1855" LastEditorUserId="1855" LastEditDate="2017-07-17T12:58:21.930" LastActivityDate="2017-07-17T12:58:21.930" Title="User command with modified 'path' completion?" Tags="|command-line|autocompletion|path|find|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12922" PostTypeId="1" CreationDate="2017-07-16T21:27:14.210" Score="0" ViewCount="262" Body="&lt;p&gt;From &lt;a href=&quot;http://vim.wikia.com/wiki/Remove_unwanted_spaces&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Remove_unwanted_spaces&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function TrimWhiteSpace()&#xA;  %s/\s\+$//e&#xA;endfunction&#xA;&#xA;autocmd FileWritePre * call TrimWhiteSpace()&#xA;autocmd FileAppendPre * call TrimWhiteSpace()&#xA;autocmd FilterWritePre * call TrimWhiteSpace()&#xA;autocmd BufWritePre * call TrimWhiteSpace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On &lt;code&gt;:write&lt;/code&gt; the cursor moves to the first non-blank character of the last trimmed line. How can I make it stay in place?&lt;/p&gt;&#xA;" OwnerUserId="13458" LastEditorDisplayName="user13463" LastEditDate="2017-07-17T16:27:39.720" LastActivityDate="2017-07-17T16:27:39.720" Title="Removing trailing spaces with the substitute command changes the cursor position" Tags="|cursor-movement|substitute|whitespace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12923" PostTypeId="2" ParentId="12922" CreationDate="2017-07-16T21:45:02.507" Score="4" Body="&lt;p&gt;Save the position and restore it again, as in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function TrimWhiteSpace()&#xA;  let save_cursor = getcurpos()&#xA;  %s/\s\+$//e&#xA;  call setpos('.', save_cursor)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="1841" LastEditDate="2017-07-17T07:14:09.630" LastActivityDate="2017-07-17T07:14:09.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12924" PostTypeId="2" ParentId="12911" CreationDate="2017-07-16T23:20:06.920" Score="0" Body="&lt;p&gt;Why not map &lt;code&gt;:cclose&lt;/code&gt; to &lt;code&gt;&amp;lt;Leader&amp;gt;q&lt;/code&gt;, if you want it as a shortcut? My guess is that you will inevitably need macros, and are boxing yourself into a corner by remapping &lt;code&gt;q&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13009" LastActivityDate="2017-07-16T23:20:06.920" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12925" PostTypeId="2" ParentId="11526" CreationDate="2017-07-17T08:08:33.540" Score="4" Body="&lt;p&gt;Since this could be misinterpreted with enable the python3 feature, I consider useful mention this link for an installation according to your needs&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here are excellent guides for: &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;*nix &amp;amp; windows&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: Pay attention to every character in the ./configure instruction and read carefully (as if you'll screw up) before doing it. And read until the end, there is no way to get lost&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should probably add this to ./configure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--enable-fail-if-missing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Avoid to enable both python 2 &amp;amp; 3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Take your time&lt;/strong&gt; This is a very very well explained procedure. Thank to Valloric&lt;/p&gt;&#xA;" OwnerUserId="13451" LastEditorUserId="13451" LastEditDate="2017-07-17T14:54:32.023" LastActivityDate="2017-07-17T14:54:32.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12926" PostTypeId="2" ParentId="12921" CreationDate="2017-07-17T09:34:39.923" Score="1" Body="&lt;p&gt;Custom completion is indeed the way to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But why don't you use &lt;code&gt;globpath&lt;/code&gt; instead of &lt;code&gt;system()&lt;/code&gt;. Exploring directory hierarchies should much faster. Then you can filter results with &lt;code&gt;filter()&lt;/code&gt;, and transform them with &lt;code&gt;map()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to use exact paths, but recurse automatically, you can use &lt;code&gt;some/path/**&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: I resolve &lt;code&gt;.vim/&lt;/code&gt; directory with &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/path.vim#L555&quot; rel=&quot;nofollow noreferrer&quot;&gt;the following&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-07-17T09:34:39.923" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12927" PostTypeId="2" ParentId="12921" CreationDate="2017-07-17T11:52:00.810" Score="3" Body="&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;f&amp;lt;CR&amp;gt; :EditVim ~/.vim/**/*&#xA;command! -complete=file_in_path -nargs=? EditVim : call EditVim (&amp;lt;f-args&amp;gt;)&#xA;&#xA;func! EditVim(...)&#xA;    if a:0 == 0 || a:1 ==? '~/.vim/**/*'&#xA;        execute 'edit ~/.vimrc'&#xA;    else&#xA;        execute 'edit' a:1&#xA;    endif&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mWoxs.gif&quot; alt=&quot;demo&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the &lt;code&gt;~/.vim/**/*foo&lt;/code&gt; pattern will match anything that has &lt;code&gt;foo&lt;/code&gt; and is located in &lt;code&gt;~/.vim/&lt;/code&gt; or any of its subfolders recursively. Given that you want the completion, I assume that you only need this wrapper command for quick navigation to your config files. If so, then you could just use these mappings instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;F :edit ~/.vimrc&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;f :edit ~/.vim/**/* &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user13463" LastActivityDate="2017-07-17T11:52:00.810" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12928" PostTypeId="2" ParentId="12919" CreationDate="2017-07-17T11:56:05.377" Score="-1" Body="&lt;p&gt;the plugins are loading, but powerline wasn't showing, because i had to add &lt;code&gt;set laststatus=2&lt;/code&gt; to ~/.vimrc&lt;/p&gt;&#xA;" OwnerUserId="13454" LastActivityDate="2017-07-17T11:56:05.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12929" PostTypeId="2" ParentId="11765" CreationDate="2017-07-17T15:49:37.703" Score="0" Body="&lt;p&gt;While in normal mode and the cursor is on the left from the closing brace, type the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mxt}vT,r&amp;lt;space&amp;gt;`x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mx                &quot; Save the mark x at the curent cursor position&#xA;  t}              &quot; Move to the right till before the first closing brace&#xA;    v             &quot; Start visual mode per character&#xA;     T,           &quot; Move to the left till after the first comma&#xA;       r&amp;lt;space&amp;gt;   &quot; Replace all characters with spaces&#xA;               `x &quot; Jump to the position of the mark x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To repeat this on a several lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qx                &quot; Start recording the keystrokes to the register x&#xA;   ...            &quot; Type the commands&#xA;       q          &quot; Stop recording&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To playback the keystrokes from the register &lt;code&gt;x&lt;/code&gt; type &lt;code&gt;@x&lt;/code&gt;. Now you can use &lt;code&gt;@@&lt;/code&gt; to repeat the last playback or &lt;code&gt;.&lt;/code&gt; (the dot) to repeat the last action (playback counts as a single action). To view the contents of all registers use the &lt;code&gt;:reg&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Using_marks&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Using_marks&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://vim.wikia.com/wiki/VimTip144&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/VimTip144&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://vim.wikia.com/wiki/Macros&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Macros&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Make sure you are not mixing spaces and tabs or things will get messy. If you need to replace the string with tabs, then instead of &lt;code&gt;vT,r&amp;lt;space&amp;gt;&lt;/code&gt; type &lt;code&gt;dT,4i&amp;lt;Tab&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, where &lt;code&gt;4&lt;/code&gt; is the number of tabs you need to align the brace.&lt;/p&gt;&#xA;" OwnerDisplayName="user13463" LastEditorDisplayName="user13463" LastEditDate="2017-07-17T16:12:13.033" LastActivityDate="2017-07-17T16:12:13.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12931" PostTypeId="1" AcceptedAnswerId="13265" CreationDate="2017-07-17T17:08:43.093" Score="6" ViewCount="2202" Body="&lt;p&gt;Is there a way to go forward to the first letter, maybe using &lt;kbd&gt;f&lt;/kbd&gt; other than specifying the letter itself?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words I want to skip over whitespace, symbols and digits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I ask is that I want to make a macro and different sentences might begin with different letters, so I cannot put a particular letter in the macro. I need some way to say 'skip over everything that is not a letter' in the macro.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="1841" LastEditDate="2017-07-18T07:56:48.317" LastActivityDate="2018-09-17T21:44:51.720" Title="Go forward to first alphabetic character" Tags="|macro|navigation|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12932" PostTypeId="1" CreationDate="2017-07-17T18:41:50.867" Score="1" ViewCount="56" Body="&lt;p&gt;I am using Javascript with typescript if it matters (I don't think it does for this question for reasons that I will explain later) and I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;veryLongFunctionName(arg1: type,&#xA;                     arg2: type,&#xA;                     arg3: type) {&#xA;  /* ... */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I try to make a new line in the function body it auto indents to one indent past the &lt;code&gt;arg3&lt;/code&gt;'s column in the header. For example, since my indentation is set to two spaces, typing &lt;code&gt;osomeCode&amp;lt;ESC&amp;gt;&lt;/code&gt; when my cursor is on &lt;code&gt;arg3&lt;/code&gt; results in the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;veryLongFunctionName(arg1: type,&#xA;                     arg2: type,&#xA;                     arg3: type) {&#xA;                       someCode&#xA;  /* ... */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is obviously not what I would like, I want its indentation level to be based upon the indentation of the function header itself. Even when I remove the typescript and javascript syntax plugins from my .vimrc, it bases its indentation on the wrong line like so.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;veryLongFunctionName(arg1: type,&#xA;                     arg2: type,&#xA;                     arg3: type) {&#xA;                     someCode&#xA;  /* ... */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Only when I completely remove the &lt;code&gt;filetype plugin indent on&lt;/code&gt; line from my .vimrc does the cursor not auto-indent to the column of &lt;code&gt;arg3&lt;/code&gt; (because it doesn't indent at all).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simple solution to this problem?&lt;/p&gt;&#xA;" OwnerUserId="13471" LastEditorUserId="13471" LastEditDate="2017-07-17T19:57:10.447" LastActivityDate="2017-07-17T19:57:10.447" Title="How to ensure smarter indentation after multiline function header?" Tags="|indentation|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12935" PostTypeId="2" ParentId="12931" CreationDate="2017-07-17T19:37:34.780" Score="3" Body="&lt;p&gt;Yes. There's &lt;code&gt;w&lt;/code&gt; (mnemonic: &lt;em&gt;word&lt;/em&gt;) which moves to the beginning of the next word, and &lt;code&gt;b&lt;/code&gt; (&lt;em&gt;backward&lt;/em&gt;) which moves to the beginning of the previous word. Then there's &lt;code&gt;e&lt;/code&gt; which moves to the end of the next word, and &lt;code&gt;ge&lt;/code&gt; which moves to the end of the previous word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change which characters are considered part of a word using the &lt;code&gt;iskeyword&lt;/code&gt; option, and many filetype syntax plugins will set this to the characters which are allowed in identifiers for that language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's capital letter variants (like &lt;code&gt;W&lt;/code&gt;) which counts any non-space character as a word.&lt;/p&gt;&#xA;" OwnerUserId="7547" LastActivityDate="2017-07-17T19:37:34.780" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12936" PostTypeId="2" ParentId="12920" CreationDate="2017-07-17T20:23:49.967" Score="1" Body="&lt;p&gt;Use &lt;a href=&quot;https://github.com/xolox/vim-shell&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-shell&lt;/a&gt; plugin instead with this config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_nogx = 1 &quot; disable netrw's gx mapping.&#xA;nnoremap gx :Open&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="177" LastEditorUserId="51" LastEditDate="2017-08-16T21:53:20.900" LastActivityDate="2017-08-16T21:53:20.900" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12937" PostTypeId="1" CreationDate="2017-07-18T01:24:34.820" Score="1" ViewCount="190" Body="&lt;p&gt;Libraries evolve all the time and I often face the situation where after an update some function name have changed and they return errors in the updated version of the library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's easy to replace all the instances of a word by another however I would like to keep track of the old version by commenting the line containing the old function name, as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;original line (which raises an error)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a line with old code&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;after&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// a line with old code&#xA;a line with new code&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far I did it manually: &lt;code&gt;yy&lt;/code&gt; + &lt;code&gt;p&lt;/code&gt; to copy the line, &lt;code&gt;:%s/\&amp;lt;old code\&amp;gt;/new code/gc&lt;/code&gt; to replace with confirmation, then in the line I want to comment, &lt;code&gt;esc&lt;/code&gt; + &lt;code&gt;I&lt;/code&gt; + &lt;code&gt;//&lt;/code&gt; + &lt;code&gt;esc&lt;/code&gt; and I use the repeat command &lt;code&gt;.&lt;/code&gt; to add my comment to the other appropriate lines. This is fine for few dozen lines of code but not for hundreds of lines, so I'd like to make this less manual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The steps to be taken would be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;search lines with the old code (old function name)&lt;/li&gt;&#xA;&lt;li&gt;copy the lines&lt;/li&gt;&#xA;&lt;li&gt;comment the original lines: add &lt;code&gt;//&lt;/code&gt; (or other) in front of the line&lt;/li&gt;&#xA;&lt;li&gt;replace the old code in the uncommented line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Can this be done in a &quot;vim-apprentice&quot; friendly manner? More advanced methods will be welcome too.&lt;/p&gt;&#xA;" OwnerUserId="12085" LastEditorUserId="1841" LastEditDate="2017-07-18T09:10:21.107" LastActivityDate="2017-07-18T09:10:21.107" Title="Copy a line, comment it and replace a word in copied line" Tags="|search|cut-copy-paste|replace|comments|" AnswerCount="3" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12938" PostTypeId="2" ParentId="12937" CreationDate="2017-07-18T01:59:48.687" Score="1" Body="&lt;p&gt;You can use capture groups in your replace and replace the original line with two lines. Here is an example with python changing print statements to have parentheses (python 2 --&gt;  python 3)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Original text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print 'woo'&#xA;&#xA;print 'woosh'&#xA;&#xA;print 'wee'&#xA;&#xA;print 'weesh'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/print \(.*\)/#print \1 \rprint(\1)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#print 'woo' &#xA;print('woo')&#xA;&#xA;#print 'woosh' &#xA;print('woosh')&#xA;&#xA;#print 'wee' &#xA;print('wee')&#xA;&#xA;#print 'weesh' &#xA;print('weesh')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the command you are trying to replace is long this may be a poor solution&lt;/p&gt;&#xA;" OwnerUserId="13476" LastActivityDate="2017-07-18T01:59:48.687" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12939" PostTypeId="2" ParentId="12937" CreationDate="2017-07-18T07:48:16.153" Score="3" Body="&lt;h3&gt;Script&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! CoRep (pat, ...)&#xA;    let line_loc    = search (a:pat, 'nw')&#xA;    let line        = getline (line_loc)&#xA;&#xA;    call setline (line_loc, '// '.line)&#xA;&#xA;    let pair = 0&#xA;    while pair &amp;lt; a:0&#xA;        let pat = a:000[pair]&#xA;        let sub = a:000[pair+1]&#xA;&#xA;        let line = substitute (line, pat, sub, '')&#xA;        let pair = pair + 2&#xA;    endwhile&#xA;&#xA;    call append (line_loc, line)&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The arguments are:  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First argument is a line pattern. Line is being searched down the cursor, wrapping to the top.&lt;/li&gt;&#xA;&lt;li&gt;Other arguments are pairs of &lt;code&gt;pattern&lt;/code&gt; and &lt;code&gt;substitution&lt;/code&gt; strings (up to 9 pairs). Substitutions are applied to the entire line, in the same order, and stop at the first match.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;Usage&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Call from the command mode or map to &lt;kbd&gt;leader&lt;/kbd&gt;-&lt;kbd&gt;r&lt;/kbd&gt; (or any other key).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;r :CoRep &#xA;command! -nargs=+ CoRep : call CoRep (&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/06Ch7.gif&quot; alt=&quot;demo&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Applies substitution to all matched lines at once&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! CoRepGlob (pat, ...)&#xA;    let origin = getcurpos()&#xA;    call cursor (1, 0)&#xA;&#xA;    while 1&#xA;        let line_loc = search (a:pat, 'cW')&#xA;        if line_loc == 0&#xA;            break&#xA;        endif&#xA;&#xA;        let line = getline (line_loc)&#xA;        call setline (line_loc, '// '.line)&#xA;&#xA;        let pair = 0&#xA;        while pair &amp;lt; a:0&#xA;            let pat = a:000[pair]&#xA;            let sub = a:000[pair+1]&#xA;&#xA;            let line = substitute (line, pat, sub, '')&#xA;            let pair = pair + 2&#xA;        endwhile&#xA;&#xA;        call append (line_loc, line)&#xA;        call cursor (line_loc + 2, 0)&#xA;    endwhile&#xA;&#xA;    call setpos ('.', origin)&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user13463" LastEditorDisplayName="user13463" LastEditDate="2017-07-18T09:00:45.873" LastActivityDate="2017-07-18T09:00:45.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12940" PostTypeId="2" ParentId="12937" CreationDate="2017-07-18T08:04:45.727" Score="1" Body="&lt;p&gt;This is a very rough function, that should do what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    &quot; &amp;lt;range&amp;gt;CopyAndComment char/line/match/replace&#xA;    com! -range=% -nargs=+ CopyAndComment let wsv=winsaveview()|&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call s:CopyAndComment(&amp;lt;q-args&amp;gt;)|call winrestview(wsv)&#xA;&#xA;    function! s:CopyAndComment(args) range&#xA;        let arg=split(a:args, '/')&#xA;        if len(arg) &amp;gt; 4 || len(arg) &amp;lt; 3&#xA;            echoerr &quot;Usage: &amp;lt;range&amp;gt;CopyAndComment char/line/match/replace&quot;&#xA;            return&#xA;        endif&#xA;        if len(arg) == 3&#xA;            let com = split(getbufvar(&quot;%&quot;, '&amp;amp;cms', '# %s'), '%s')[0]&#xA;            call insert(arg, com, 0)&#xA;        endif&#xA;        let arg=map(arg, 'escape(v:val, &quot;/#&quot;)')&#xA;        let s_replace_arg = '\=&quot;'.arg[0]. '&quot;.submatch(0).'.'&quot;\n&quot;'.'.substitute(submatch(0),&quot;'.arg[2].'&quot;,&quot;'.arg[3].'&quot;,&quot;g&quot;)'&#xA;        exe a:firstline.','.a:lastline.'g/'.arg[1].'/s#.*#'.s_replace_arg.'#g'&#xA;    endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This defines a command &lt;code&gt;:CopyAndComment&lt;/code&gt; that takes one argument of the form &lt;code&gt;comment/linematch/search/replace&lt;/code&gt; and it will use the linematch regex to find matching lines to copy. In each matching line, it will copy the line, add a comment char to the original line, and replace the newly created line according to the &lt;code&gt;search/replace&lt;/code&gt; argument. You can leave out the firsts &lt;code&gt;comment&lt;/code&gt; char, in which case the function will take the value from the &lt;code&gt;&amp;amp;commentstring&lt;/code&gt; option and use that (only the first half of it) which defaults to &lt;code&gt;/*&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, the command takes a range argument, so if you only want to replace in the lines 1-5, you would call it like &lt;code&gt;1,5CopyAndComment \#/line/foo/bar&lt;/code&gt;. If no range is given, it defaults to the whole file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Internally the function works by sticking together a &lt;code&gt;:g&lt;/code&gt; command with a &lt;code&gt;:s&lt;/code&gt; command doing all those replacements. However quoting is really ugly, it took my a couple of minutes to twist my brain until I got that correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your example you would then call it as &lt;code&gt;:CopyAndComment \/\/ /line/old/new&lt;/code&gt; (note you have to escape the comment chars &lt;code&gt;//&lt;/code&gt; as this is used as delimiter)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-18T08:04:45.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12941" PostTypeId="1" CreationDate="2017-07-18T08:23:30.463" Score="1" ViewCount="202" Body="&lt;p&gt;I often get an &lt;code&gt;eslint&lt;/code&gt; error in a Javascript file, which is trivial to fix - for example, trailing spaces or incorrect indentation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/o7E5u.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/o7E5u.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, I would have to &lt;code&gt;^XX&lt;/code&gt; to navigate to the beginning of the line and delete two spaces. Not the end of the world, but some cases - like long lines that needs to be broken - are more cumbersome. Note that I am not looking for &lt;a href=&quot;https://vi.stackexchange.com/questions/8381/how-to-auto-fix-common-linting-errors-reported-via-syntastic&quot;&gt;a complete auto-fix for the file&lt;/a&gt;, just a quick fix apply for the current highlighted problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to define a key binding that would auto-fix the current &lt;code&gt;eslint&lt;/code&gt; error, if possible?&lt;/p&gt;&#xA;" OwnerUserId="13179" LastActivityDate="2017-07-18T08:23:30.463" Title="Fix a specific eslint error automatically" Tags="|key-bindings|" AnswerCount="0" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12942" PostTypeId="1" CreationDate="2017-07-18T10:53:11.950" Score="3" ViewCount="647" Body="&lt;p&gt;I'm using Neovim to edit Fortran 90 files and if I type the one-liner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;forall(i=1:10) b(i) = i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Neovim will always assume that it has a &lt;code&gt;forall&lt;/code&gt; block and indent the following lines (til the end of the file). This is only supposed to happen if there is an &lt;code&gt;end forall&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;forall(i=1:10)&#xA;    b(i) = 1&#xA;    a(i) = 1-i&#xA;end forall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this a bug in (neo)vim or is a bug in the Fortran mode I use? How do I fix it? This is my init.vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;allow for project specific vimrc's&#xA;set exrc&#xA;set secure&#xA;set mouse=a&#xA;&#xA;&quot;tab settings&#xA;set tabstop=4&#xA;set softtabstop=4&#xA;set shiftwidth=4&#xA;set expandtab&#xA;&#xA;&quot;line numbers on the right&#xA;set number&#xA;&#xA;&quot;match brackets&#xA;set showmatch&#xA;&#xA;&#xA;&quot;improved searching&#xA;set incsearch&#xA;set ignorecase&#xA;set smartcase&#xA;&#xA;&quot;indentations&#xA;set ai&#xA;set si&#xA;set wrap&#xA;&#xA;&quot;Fortran90 setup&#xA;&quot;use free format Fortran&#xA;let fortran_free_source=1&#xA;&#xA;&quot;allow for tabs&#xA;let fortran_have_tabs=1&#xA;&#xA;&quot;better syntax highlighting (but slower)&#xA;let fortran_more_precise=1&#xA;&#xA;let fortran_do_enddo=1&#xA;&#xA;&quot; Start interactive EasyAlign in visual mode (e.g. vipga)&#xA;xmap ga &amp;lt;Plug&amp;gt;(EasyAlign)&#xA;&#xA;&quot; Start interactive EasyAlign for a motion/text object (e.g. gaip)&#xA;nmap ga &amp;lt;Plug&amp;gt;(EasyAlign)&#xA;&#xA;&#xA;&quot;UltiSnips &amp;amp; youcompleteme&#xA;&quot; make YCM compatible with UltiSnips (using supertab)&#xA;let g:ycm_key_list_select_completion = ['&amp;lt;C-n&amp;gt;', '&amp;lt;Down&amp;gt;']&#xA;let g:ycm_key_list_previous_completion = ['&amp;lt;C-p&amp;gt;', '&amp;lt;Up&amp;gt;']&#xA;let g:SuperTabDefaultCompletionType = '&amp;lt;C-n&amp;gt;'&#xA;&#xA;&quot; better key bindings for UltiSnipsExpandTrigger&#xA;let g:UltiSnipsExpandTrigger = &quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger = &quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger = &quot;&amp;lt;s-tab&amp;gt;&quot;&#xA;&#xA;&quot;vim-plug&#xA;call plug#begin('~/.config/nvim/plugged')&#xA;&quot;Fortran support&#xA;Plug 'rudrab/vimf90'&#xA;&quot;julia&#xA;Plug 'JuliaLang/julia-vim'&#xA;&#xA;Plug 'junegunn/vim-easy-align'&#xA;&#xA;&quot;Themes&#xA;Plug 'vim-scripts/Solarized'&#xA;Plug 'kamwitsta/nordisk'&#xA;Plug 'KeitaNakamura/neodark.vim'&#xA;&#xA;&quot; Track the engine.&#xA;Plug 'SirVer/ultisnips'&#xA;&#xA;&quot; Snippets are separated from the engine. Add this if you want them:&#xA;Plug 'honza/vim-snippets'&#xA;Plug 'kiith-sa/DSnips'&#xA;Plug 'Valloric/YouCompleteMe'&#xA;Plug 'ervandew/supertab'&#xA;&#xA;&quot;Nerd commentor&#xA;Plug 'scrooloose/nerdcommenter'&#xA;&#xA;&quot;Command line&#xA;Plug 'lrvick/Conque-Shell'&#xA;&#xA;&quot;Nerdtree&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'Xuyuanp/nerdtree-git-plugin'&#xA;&#xA;Plug 'airblade/vim-gitgutter'&#xA;&#xA;&quot; Clojure&#xA;&quot; Plug 'guns/vim-clojure-static'&#xA;&quot; Plug 'luochen1990/rainbow'&#xA;call plug#end()&#xA;&#xA;&#xA;syntax enable&#xA;&quot;set t_Co=256   &quot; This is may or may not needed.&#xA;&#xA;&quot;set background=light&#xA;colorscheme neodark&#xA;let g:neodark#background='brown'&#xA;&#xA;&#xA;set nocp&#xA;filetype plugin on&#xA;&#xA;&quot;set leader key&#xA;let mapleader=&quot;,&quot;&#xA;&#xA;&quot;NERDTree appears on Ctrl-n&#xA;map &amp;lt;C-n&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;JSON auto formating&#xA;command J :%!python -m json.tool&#xA;&#xA;&#xA;&quot;Rainbrow parentheses&#xA;&quot;let g:rainbow_active = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13480" LastEditorUserId="1841" LastEditDate="2017-07-18T11:24:27.733" LastActivityDate="2018-06-18T07:11:27.443" Title="Wrong indentation for fortran forall" Tags="|indentation|neovim|filetype-fortran|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12944" PostTypeId="1" CreationDate="2017-07-18T23:40:21.207" Score="4" ViewCount="1052" Body="&lt;p&gt;Is it possible to get the line numbers of selected text to pass to an external command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Context: I'd like to integrate &lt;code&gt;pyfmt&lt;/code&gt; into vim. Ideally, I'd like to be able to select some text and type some shortcut to have the selected text reformatted by &lt;code&gt;pyfmt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I've found that running &lt;code&gt;!pyfmt -i %&lt;/code&gt; will format the whole file. &lt;code&gt;pyfmt&lt;/code&gt; also supports a &lt;code&gt;--lines START-END&lt;/code&gt; option. I'd like to be able to pass the line numbers of the beginning and end of the selected text to &lt;code&gt;pyfmt&lt;/code&gt; so that only what I want to reformat gets reformatted. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="11601" LastActivityDate="2020-11-03T18:06:57.323" Title="How to get line numbers of selected text" Tags="|external-command|ex-mode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12945" PostTypeId="1" CreationDate="2017-07-19T01:37:55.540" Score="6" ViewCount="6058" Body="&lt;p&gt;I would like to automatically close the netrw window when I open a file. I've found a similar question (&lt;a href=&quot;https://vi.stackexchange.com/questions/3489/nerdtree-how-to-open-a-file-and-automatically-close-the-explorer-buffer&quot;&gt;NERDTree How to open a file and automatically close the explorer buffer&lt;/a&gt;), but it refers to NERDTree - not netrw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_banner = 0&#xA;let g:netrw_liststyle = 3&#xA;let g:netrw_browse_split = 4&#xA;let g:netrw_altv = 1&#xA;let g:netrw_winsize = 25&#xA;set autochdir&#xA;map &amp;lt;C-E&amp;gt; :Lexplore&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;This works when using &lt;code&gt;:Explore&lt;/code&gt;, but in my case, I'm trying to make it work when I use &lt;code&gt;:Lexplore&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13489" LastEditorUserId="13489" LastEditDate="2017-07-20T05:53:45.850" LastActivityDate="2017-07-20T05:53:45.850" Title="Automatically close netrw after opening a file" Tags="|netrw|" AnswerCount="1" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12946" PostTypeId="2" ParentId="2129" CreationDate="2017-07-19T03:36:16.393" Score="2" Body="&lt;p&gt;These days I am using &lt;code&gt;[buffer_number]&amp;lt;Ctrl-^&amp;gt;&lt;/code&gt; to switch buffers because it is very fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how to know the buffer number?  I use &lt;a href=&quot;https://github.com/fholgado/minibufexpl.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;MiniBufExplorer&lt;/a&gt; so I can always see the buffer numbers at the top of Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also use the following mapping, because &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; is a bit hard to reach with one hand.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap &amp;lt;C-E&amp;gt; &amp;lt;C-^&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On a fresh machine with no config, I fall back to &lt;code&gt;:b [part_of_filename]&amp;lt;Tab&amp;gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2017-07-19T03:41:33.830" LastActivityDate="2017-07-19T03:41:33.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12947" PostTypeId="2" ParentId="12944" CreationDate="2017-07-19T06:43:15.010" Score="8" Body="&lt;p&gt;The line numbers of the selected text are available in the marks &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt;. So you can use e.g. &lt;code&gt;echo getpos(&quot;'&amp;lt;&quot;)&lt;/code&gt; and &lt;code&gt;echo getpos(&quot;'&amp;gt;&quot;)&lt;/code&gt; to get the start and end of the selected text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I'd like to point out, that you might be over complicating your problem. Your problem can usually be simply achieved, by filtering the selected text through the formatter. Read the help at &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#filter&quot; rel=&quot;noreferrer&quot;&gt;:h filter&lt;/a&gt;. So you could simply visually select your text type &lt;kbd&gt;!&lt;/kbd&gt;&lt;code&gt;pyfmt&lt;/code&gt; and the pyfmt will be run with the selected text as input and whater it outputs will be replaced in your buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This however only works, if the formatter actually takes input from stdin and outputs it to stdout. Not all formatter support that (and it might not even make sense for them), but you might want to check, if pyfmt actually does support this mode.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-19T06:43:15.010" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12948" PostTypeId="2" ParentId="12945" CreationDate="2017-07-19T08:30:34.957" Score="6" Body="&lt;p&gt;I think your problem comes from the following line of your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_browse_split = 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the doc &lt;a href=&quot;http://vimhelp.appspot.com/pi_netrw.txt.html#g%3anetrw_browse_split&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h g:netrw_browse_split&lt;/code&gt;&lt;/a&gt;&#xA;you can read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  *g:netrw_browse_split*    when browsing, &amp;lt;cr&amp;gt; will open the file by:&#xA;                =0: re-using the same window  (default)&#xA;                =1: horizontally splitting the window first&#xA;                =2: vertically   splitting the window first&#xA;                =3: open file in new tab&#xA;                =4: act like &quot;P&quot; (ie. open previous window)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this should solve your problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_browse_split = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Otherwise I think you may be able to adapt the autocommand solution from the question you linked since netrw buffers has a filetype set to &lt;code&gt;netrw&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-07-19T11:50:46.453" LastActivityDate="2017-07-19T11:50:46.453" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12949" PostTypeId="1" AcceptedAnswerId="12950" CreationDate="2017-07-19T15:36:08.133" Score="1" ViewCount="40" Body="&lt;p&gt;Please forgive me as I'm sure this has been asked before, but my Google fu has really failed me here as I'm not sure what this feature is called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given text like this: &lt;code&gt;&quot;Hello ~&quot;&lt;/code&gt; with the cursor where the &lt;code&gt;~&lt;/code&gt; is, is there a plugin that will ignore an inserted &lt;code&gt;&quot;&lt;/code&gt; since it's already there?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most IDEs and code editors have this feature (see: sublime, atom, vscode, visual studio, etc) by default and it helps when you type in (thanks to muscle memory) a single or double quote that's already there. If the algorithm isn't intelligent enough, this &quot;feature&quot; becomes a horrible impediment and a nightmare, but when done right, it can be quite handy (and invisible).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="13499" LastActivityDate="2017-07-19T16:16:36.250" Title="Plugin to ignore quote when it's already there?" Tags="|text-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12950" PostTypeId="2" ParentId="12949" CreationDate="2017-07-19T16:02:21.597" Score="1" Body="&lt;p&gt;It's depends on the bracketing plugin you're using. AFAIK, the more popular ones have the feature. (For instance, it's the case of &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-brackets&lt;/a&gt; I'm maintaining)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if you're using a mapping you've found on the internet or in colleague's &lt;code&gt;.vimrc&lt;/code&gt; like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &quot; &quot;&quot;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it won't be enough, and you'll have to find/write a patch for that mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that particular case your mapping would become.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &quot; (getline('.')[col('.')-1] == '&quot;' ? '&amp;lt;right&amp;gt;' : '&quot;&quot;&amp;lt;left&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, that if the bracket characters take multiple bytes, the mappings would need to look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; µ (getline('.') =~ '\%'.col('.').'cµ' ? '&amp;lt;right&amp;gt;' : 'µµ&amp;lt;left&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then , you'll want to support redo also, and so on. In the end, IMO, you're best using a plugin where all these features are already implemented. Or nothing at all. Some people really don't like auto-closing/balancing of bracket characters -- which I understand without a &lt;em&gt;close everything&lt;/em&gt; feature.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-07-19T16:16:36.250" LastActivityDate="2017-07-19T16:16:36.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12951" PostTypeId="2" ParentId="7105" CreationDate="2017-07-19T23:33:48.887" Score="2" Body="&lt;h1&gt;Short answer&lt;/h1&gt;&#xA;&lt;p&gt;The problem lies in &lt;code&gt;dot.exe&lt;/code&gt;. GraphViz can open files with Unicode paths in Linux but not Windows, unless (maybe) if compiled with Visual Studio 2005.&lt;/p&gt;&#xA;&lt;h1&gt;Research&lt;/h1&gt;&#xA;&lt;p&gt;The code page is set to &lt;code&gt;850&lt;/code&gt;, Vim encoding to &lt;code&gt;UTF-8&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aYeon.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aYeon.gif&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It doesn't give the exact same error, but the &lt;code&gt;dot.exe&lt;/code&gt; seems to receive a wrong argument. I tried passing the same filename to the other program.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rC3gE.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rC3gE.gif&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And it worked just right. Executing both &lt;code&gt;dot.exe&lt;/code&gt; and &lt;code&gt;type&lt;/code&gt;directly from &lt;code&gt;cmd.exe&lt;/code&gt; gives the same result, so neither the Windows Console nor Vim are the problem. The next thing that could cause that error was &lt;code&gt;dot.exe&lt;/code&gt; itself. My suspicion was that it just doesn't know how to handle the Unicode coded arguments properly, as not even all console commands do:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://ss64.com/nt/chcp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ss64.com/nt/chcp.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If you need full Unicode support use PowerShell. There is still VERY limited support for Unicode in the CMD shell, piping, redirection and most commands are still ANSI only. The only commands that work are DIR, FOR /F and TYPE, this allows reading and writing (UTF-16LE / BOM) files and filenames but not much else.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I searched on the web if there is support for Unicode in GraphViz and found that it does support Unicode &lt;em&gt;files&lt;/em&gt; but nothing about Unicode support for the filenames. Neither I found any reports on the GraphViz bug tracker nor posts on the forum about anyone else being interested in reading a Unicode named file. So I looked it up in the source. Here what is &lt;code&gt;dot.exe&lt;/code&gt; entry point looks like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;graphviz-2.40.1\cmd\dot\dot.c&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int main(int argc, char **argv)&#xA;{&#xA;    . . .&#xA;&#xA;/* --------------------&amp;gt; ARGS ARE BEING PASSED HERE */&#xA;    gvParseArgs(Gvc, argc, argv);&#xA;&#xA;    . . .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Following the &lt;code&gt;argv&lt;/code&gt; down the rabbit hole: &lt;code&gt;graphviz-2.40.1\lib\common\args.c&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int gvParseArgs(GVC_t *gvc, int argc, char** argv)&#xA;{&#xA;    int rv;&#xA;    if ((argc = neato_extra_args(gvc, argc, argv)) &amp;lt; 0)    return (1-argc);&#xA;    if ((argc = fdp_extra_args(gvc, argc, argv)) &amp;lt; 0)      return (1-argc);&#xA;    if ((argc = memtest_extra_args(gvc, argc, argv)) &amp;lt; 0)  return (1-argc);&#xA;    if ((argc = config_extra_args(gvc, argc, argv)) &amp;lt; 0)   return (1-argc);&#xA;&#xA;/* --------------------&amp;gt;  HERE GO ALL NON-FLAG ARTUMENTS */&#xA;    if ((rv = dotneato_args_initialize(gvc, argc, argv)))  return rv;&#xA;&#xA;    if (Verbose) gvplugin_write_status(gvc);&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;graphviz-2.40.1\lib\common\input.c&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv)&#xA;{&#xA;    for (i = 1; i &amp;lt; argc; i++) {&#xA;        if (argv[i] &amp;amp;&amp;amp; argv[i][0] == '-') {&#xA;            &#xA;            . . .&#xA;&#xA;/* --------------------&amp;gt;  JUST CASUALLY COPYING CHAR POINTERS */&#xA;        } else if (argv[i])&#xA;            gvc-&amp;gt;input_filenames[nfiles++] = argv[i];&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And finaly &lt;code&gt;graphviz-2.40.1\lib\common\input.c&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;graph_t *gvNextInputGraph(GVC_t *gvc)&#xA;{&#xA;    . . . .&#xA;&#xA;/* --------------------&amp;gt;  OPENING THE FILES FOR READ WITH FOPEN */&#xA;    while ((fn = gvc-&amp;gt;input_filenames[fidx++]) &amp;amp;&amp;amp; !(fp = fopen(fn, &amp;quot;r&amp;quot;)))  {&#xA;&#xA;        . . .&#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/yeby3zcb(v=vs.80).aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;As the MDSN states:&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The &lt;em&gt;fopen&lt;/em&gt; function opens the file specified by filename. &lt;em&gt;_wfopen&lt;/em&gt; is a wide-character version of &lt;em&gt;fopen&lt;/em&gt;; the arguments to &lt;em&gt;_wfopen&lt;/em&gt; are wide-character strings. &lt;em&gt;_wfopen&lt;/em&gt; and &lt;em&gt;fopen&lt;/em&gt; behave identically otherwise. Simply using &lt;em&gt;_wfopen&lt;/em&gt; has no effect on the coded character set used in the file stream.&lt;/p&gt;&#xA;&lt;p&gt;In Visual C++ 2005, fopen supports Unicode file streams.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Sadly, the only option there is to rename the file.&lt;/p&gt;&#xA;" OwnerDisplayName="user13463" LastEditorUserId="-1" LastEditorDisplayName="user13463" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-07-19T23:40:36.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12952" PostTypeId="2" ParentId="2607" CreationDate="2017-07-20T01:33:38.583" Score="4" Body="&lt;p&gt;To open matching files in separate tabs…&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:n */.git/config | tab all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;  &lt;code&gt;:n&lt;/code&gt; (&lt;code&gt;:next&lt;/code&gt;) sets the next-file list to all matches.  &lt;code&gt;tab all&lt;/code&gt; opens all files in the next-file list in new tabs.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;… or …&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for f in glob(&quot;*.py&quot;, 0, 1) | exe &quot;tabe&quot; f | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;  In &lt;code&gt;glob(…)&lt;/code&gt;, the 0 means to include &lt;em&gt;all&lt;/em&gt; matching files, even if they would otherwise be ignored due to the &lt;code&gt;suffixes&lt;/code&gt; or &lt;code&gt;wildignorecase&lt;/code&gt; settings.  The 1 means to return a list, instead of a string.  &lt;code&gt;exe &quot;tabe&quot; f&lt;/code&gt; is a short form of &lt;code&gt;execute &quot;tabedit&quot; f&lt;/code&gt; and means to open the file specified by the variable &lt;code&gt;f&lt;/code&gt; in a new tab.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="6592" LastActivityDate="2017-07-20T01:33:38.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12953" PostTypeId="1" CreationDate="2017-07-20T04:11:28.797" Score="2" ViewCount="842" Body="&lt;p&gt;Occasionally, I need to edit text in Chinese, and the input method I use makes it extremely tedious to do so with vim. Each time I want to leave insert mode, I have to &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; (to return to normal mode) then &lt;code&gt;&amp;lt;C-Space&amp;gt;&lt;/code&gt; (to return to the US-English keyboard layout). Otherwise, vim doesn't recognize any commands (naturally, since each Chinese character involves pressing a sequence of multiple keys).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see that vim comes with certain input-method-aware features (&lt;em&gt;e.g.,&lt;/em&gt; &lt;code&gt;:h 'imactivatekey'&lt;/code&gt;), but they appear to be compatible only with X11 + GTK. Is there any way to have vim change the input method automatically (or otherwise respond to the state of the system's current input method) on a Mac?&lt;/p&gt;&#xA;" OwnerUserId="2593" LastActivityDate="2017-08-02T10:38:28.533" Title="Control (or respond to) Input Method on Mac OS?" Tags="|macos|input-methods|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12955" PostTypeId="1" AcceptedAnswerId="12957" CreationDate="2017-07-20T10:40:03.590" Score="6" ViewCount="1405" Body="&lt;p&gt;I have a single buffer open across multiple vertically split windows and all the windows have &lt;code&gt;scrollbind&lt;/code&gt; set. However, before setting &lt;code&gt;scrollbind&lt;/code&gt;, I had to scroll down in second window in order to make sure that text in second window starts where it ends in first window. In addition, I had to scroll down the text in third window in order to make sure that it starts where it ends in second window. When this was done I set the &lt;code&gt;scrollbind&lt;/code&gt;. Is there an easier way? Scrolling in all the vertically split windows is tedious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;// &lt;strong&gt;EDIT:&lt;/strong&gt; I added a screenshot. As seen below, I have same file(&lt;code&gt;1000_line_file.txt&lt;/code&gt;) open in three windows and I have scrolled the second and third window in a way that first line in second window is &lt;code&gt;line nr 88&lt;/code&gt;, last line in second window is &lt;code&gt;line nr 174&lt;/code&gt; and first line in third windows is &lt;code&gt;line nr 175&lt;/code&gt;. At this point I want to execute &lt;code&gt;:windo set scrollbind&lt;/code&gt; to lock the scrolling. However, this scrolling process in vertically split windows is tedious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OHyTa.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OHyTa.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8626" LastEditorUserId="8626" LastEditDate="2017-07-20T13:26:38.013" LastActivityDate="2017-07-21T10:22:58.520" Title="align/spread file content in vertically split windows" Tags="|scrolling|alignment|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12956" PostTypeId="2" ParentId="12955" CreationDate="2017-07-20T11:40:04.813" Score="0" Body="&lt;p&gt;&lt;code&gt;:syncbind&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will &lt;em&gt;Force all 'scrollbind' windows to have the same relative offset.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just be sure you aren't using scrollbar of non-focused windows as it only works with focused window (and, of course, keyboard scrolling works).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I posted the above before the question had extra details added. However &lt;code&gt;syncbind&lt;/code&gt; could still help with automating the syncing of multiple windows, each one page ahead of the preceding...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say you open 2 splits (for 3 total windows) then do some unrelated work. Now each window is on a different line. But as long as one window is on the line that you want to be relative to this would set you up:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:windo set scrollbind&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:syncbind&lt;/code&gt; (each window is now synced to the same line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:windo set noscrollbind&lt;/code&gt; (temporarily unbind)&lt;/li&gt;&#xA;&lt;li&gt;In second window: &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;F&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;In third window: &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;F&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;F&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:windo set scrollbind&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Obviously you'd want to put this in a script (or a macro per Sergey's answer).&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-07-21T02:36:59.467" LastActivityDate="2017-07-21T02:36:59.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12957" PostTypeId="2" ParentId="12955" CreationDate="2017-07-20T14:05:40.893" Score="3" Body="&lt;p&gt;If you need to make a couple of splits synced with an increasing offset, the routine would be:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Split the window vertically &lt;kbd&gt;C-w&lt;/kbd&gt; &lt;kbd&gt;v&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move to the next window &lt;kbd&gt;C-w&lt;/kbd&gt; &lt;kbd&gt;w&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Scroll down one screen &lt;kbd&gt;C-f&lt;/kbd&gt; (add &lt;kbd&gt;C-e&lt;/kbd&gt; as needed)&lt;/li&gt;&#xA;&lt;li&gt;Repeat steps 1 - 3&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now as all splits are open and you are on the last one, you need to bind them:&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;5&quot;&gt;&#xA;&lt;li&gt;&lt;code&gt;:set scrollbind&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move to the previous window &lt;kbd&gt;C-w&lt;/kbd&gt; &lt;kbd&gt;W&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set scrollbind&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Repeat steps 6 and 7&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Record the macro once and that's it. You can use &lt;code&gt;:windo set scrollbind&lt;/code&gt; instead, but this way it will work even if you have other windows open. Here how it looks like in a register:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^Wv^Ww^F^E^E^Wv^Ww^F^E^E:set scrollbind^@^WW:set scrollbind^@^WW:set scrollbind^@&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TaSv3.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TaSv3.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also worth mentioning. Commands replayed by macro are not registered in the history, so &lt;code&gt;:&lt;/code&gt; &lt;kbd&gt;C-p&lt;/kbd&gt;  &lt;kbd&gt;Return&lt;/kbd&gt; or &lt;code&gt;@:&lt;/code&gt; will execute the most recent command &lt;em&gt;before&lt;/em&gt; the replay.&lt;/p&gt;&#xA;" OwnerDisplayName="user13463" LastEditorDisplayName="user13463" LastEditDate="2017-07-20T14:29:02.127" LastActivityDate="2017-07-20T14:29:02.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12958" PostTypeId="1" AcceptedAnswerId="12960" CreationDate="2017-07-20T15:28:04.720" Score="3" ViewCount="2716" Body="&lt;p&gt;Say I perform a combination of keys and now they are registered in &lt;code&gt;.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to go down X lines and run &lt;code&gt;.&lt;/code&gt; on each one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example say I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{colorComponentId: 0, value: (value.warmWhite * 255)},&#xA;{colorComponentId: 1, value: (value.coldWhite * 255)},&#xA;{colorComponentId: 2, value: (value.red * 255)},&#xA;{colorComponentId: 3, value: (value.green * 255)},&#xA;{colorComponentId: 4, value: (value.blue * 255)}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then run &lt;code&gt;d/}&lt;/code&gt; just after &lt;code&gt;value:&lt;/code&gt; resulting in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{colorComponentId: 0, value:},&#xA;{colorComponentId: 1, value: (value.coldWhite * 255)},&#xA;{colorComponentId: 2, value: (value.red * 255)},&#xA;{colorComponentId: 3, value: (value.green * 255)},&#xA;{colorComponentId: 4, value: (value.blue * 255)}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then found myself pressing &lt;code&gt;down+.&lt;/code&gt; 4 more times.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{colorComponentId: 0, value:},&#xA;{colorComponentId: 1, value:},&#xA;{colorComponentId: 2, value:},&#xA;{colorComponentId: 3, value:},&#xA;{colorComponentId: 4, value:}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there are a way to say something like &quot;do &lt;code&gt;.&lt;/code&gt; down X times&quot;?&lt;/p&gt;&#xA;" OwnerUserId="7783" LastActivityDate="2017-07-20T15:48:55.837" Title="Down and . X times?" Tags="|repeated-commands|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12959" PostTypeId="2" ParentId="12958" CreationDate="2017-07-20T15:47:51.567" Score="4" Body="&lt;p&gt;I would use a macro:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Juste before the deletion do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqdf)jq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; start to record a macro in the register &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;df)&lt;/code&gt; your deletion&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; go down one line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; stop recording the macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then you can press several time &lt;code&gt;@q&lt;/code&gt; to replay the macro of the &lt;code&gt;q&lt;/code&gt; register or simply &lt;code&gt;4@q&lt;/code&gt; to replay it 4 times.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Or you could go with a substitution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Visually select the lines you want to modify and then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/(.*)//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; between the selected line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s/&lt;/code&gt; substitute&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(.*)&lt;/code&gt; anything between the parenthesys&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;//&lt;/code&gt; replace it by nothing&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#complex%2drepeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h complex-repeat&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3as&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :s&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-07-20T15:47:51.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12960" PostTypeId="2" ParentId="12958" CreationDate="2017-07-20T15:48:55.837" Score="4" Body="&lt;p&gt;You can use a macro, though it does require a (small) bit of planning ahead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqdt}jq4@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will work, assuming your cursor is starting on the first line on the space after &lt;code&gt;value:&lt;/code&gt;. Here's an explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;q&#xA;Start recording a macro...&#xA; q&#xA;...in register `q`...&#xA;  dt}j&#xA;...delete until the next `}` and then go down one line...&#xA;      q&#xA;...finish recording the macro...&#xA;       4@q&#xA;...replay the macro in register `q` 4 times.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2017-07-20T15:48:55.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12961" PostTypeId="1" AcceptedAnswerId="13615" CreationDate="2017-07-20T16:16:31.030" Score="10" ViewCount="2260" Body="&lt;p&gt;For years I unknowingly used some, shall we say, deviant distribution of vim that would stay at the location of the highlighted search result after hitting &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; in the middle of a search instead of jumping back to the original position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried for more than a year now to forget that muscle memory, but I cannot for the life of me stop pressing &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; once what I've typed in the search has taken me to the position I'm searching for. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know a) how I can get that behavior back, b) what *nix distribution had a copy of vim that defaulted to this behavior?&lt;/p&gt;&#xA;" OwnerUserId="13499" LastActivityDate="2017-09-19T00:08:07.117" Title="Stay at matching search result after escape" Tags="|search|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12962" PostTypeId="1" CreationDate="2017-07-20T17:17:01.387" Score="5" ViewCount="595" Body="&lt;p&gt;Whenever I open a line using &lt;code&gt;o&lt;/code&gt; or &lt;code&gt;O&lt;/code&gt;, the cursor starts at the correct indentation (I'm not sure if vim uses syntax hints for this or just mimics the position of first character of the neighboring lines). Same happens when opening a line in insert mode with &lt;code&gt;Enter&lt;/code&gt; keypress.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a quick way to similarly auto-indent an empty line? Currently I'm just getting into insert mode and pressing tab manually to manually indent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I most likely want to map this functionality to when &lt;code&gt;A&lt;/code&gt; (append to line) is pressed on an empty line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I've seen &lt;a href=&quot;https://vi.stackexchange.com/questions/3612/how-do-i-prevent-vim-from-unindenting-empty-lines&quot;&gt;How do I prevent vim from unindenting empty lines&lt;/a&gt;. This question is however different since I don't want to prevent vim from unindenting empty lines. I just want to be able to &quot;revive indentation of emptied lines&quot; so not all answers to that question apply to this question.&lt;/p&gt;&#xA;" OwnerUserId="12650" LastEditorUserId="12650" LastEditDate="2017-07-21T05:25:56.927" LastActivityDate="2017-09-19T23:29:03.093" Title="Get same indentation behavior as opening a new line on an empty line" Tags="|indentation|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12963" PostTypeId="1" AcceptedAnswerId="12964" CreationDate="2017-07-20T17:43:17.450" Score="1" ViewCount="757" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/chrisbra/csv.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;csv.vim&lt;/a&gt; and I would like to change the column separator from semicolon to comma.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;How can I change the column separator with CSV.vim?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="10986" LastEditorUserId="33754" LastEditDate="2024-01-24T13:00:29.440" LastActivityDate="2024-01-24T13:00:29.440" Title="CSV.vim how to change the column separator?" Tags="|plugin-csv|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="12964" PostTypeId="2" ParentId="12963" CreationDate="2017-07-20T17:45:51.007" Score="2" Body="&lt;p&gt;This is the solution &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:NewDelimiter ,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10986" LastActivityDate="2017-07-20T17:45:51.007" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12965" PostTypeId="1" AcceptedAnswerId="12966" CreationDate="2017-07-20T18:27:16.287" Score="1" ViewCount="1356" Body="&lt;p&gt;I usually have to worry about escaping &lt;em&gt;search&lt;/em&gt; parameters to get special characters to match literally, but this time I'm seeing a problem with my replacement string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to take text like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@@ something @@ should_be_on_another_line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And turn it into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@@ something @@&#xA; should_be_on_another_line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/ @@ /&lt;/code&gt; matches the second &lt;code&gt;@@&lt;/code&gt; pair on each line just fine, but when I try this command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/ @@ / @@ \n/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I actually end up with this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;@@ something @@^@ should_be_on_another_line&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried escaping the &lt;code&gt;@@ \n&lt;/code&gt; in the replacement as &lt;code&gt;\@\@ \n&lt;/code&gt;, but that didn't help (same results).&lt;/p&gt;&#xA;" OwnerUserId="13499" LastEditorUserId="10604" LastEditDate="2021-06-24T10:47:37.777" LastActivityDate="2021-06-24T10:47:37.777" Title="How do I break a line with :substitute?" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12966" PostTypeId="2" ParentId="12965" CreationDate="2017-07-20T18:52:53.587" Score="3" Body="&lt;p&gt;You are close.  The newline should be &lt;code&gt;\r&lt;/code&gt; in your substitute command.&lt;/p&gt;&#xA;&lt;p&gt;Try&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%s/ @@ / @@ \r /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;from &lt;code&gt;:help :%s&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  &amp;lt;CR&amp;gt;        split line in two at this point&#xA;              (Type the &amp;lt;CR&amp;gt; as CTRL-V &amp;lt;Enter&amp;gt;)                  s&amp;lt;CR&amp;gt;&#xA;  \r          idem                                               s/\r&#xA;  \&amp;lt;CR&amp;gt;       insert a carriage-return (CTRL-M)&#xA;              (Type the &amp;lt;CR&amp;gt; as CTRL-V &amp;lt;Enter&amp;gt;)                  s/\&amp;lt;CR&amp;gt;&#xA;  \n          insert a &amp;lt;NL&amp;gt; (&amp;lt;NUL&amp;gt; in the file)&#xA;              (does NOT break the line)                          s/\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: The issue is not about escaping the &lt;code&gt;@&lt;/code&gt; in your substitute command.  The meaning of &lt;code&gt;\n&lt;/code&gt; differs between the &lt;strong&gt;search&lt;/strong&gt; or the &lt;strong&gt;replace&lt;/strong&gt; side of the expression. The &lt;code&gt;\n&lt;/code&gt; on the right side of the  expression inserts &lt;code&gt;^@&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/q/350661/5978252&quot;&gt;This SO question&lt;/a&gt; has more details, in particular: &lt;code&gt;:h s/\n&lt;/code&gt; from &lt;a href=&quot;https://stackoverflow.com/a/350798/5978252&quot;&gt;this answer&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-07-20T19:46:53.230" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12967" PostTypeId="1" AcceptedAnswerId="12971" CreationDate="2017-07-20T19:47:12.343" Score="1" ViewCount="1711" Body="&lt;p&gt;I have a CSV file where I want to remove every second column. Each column value are separated by quotes and the column values can contain field separators: this means that convenient solutions such as this AWK script &lt;a href=&quot;https://stackoverflow.com/questions/22354082/print-every-nth-column-of-a-file&quot;&gt;here&lt;/a&gt; won't work out of the box because of extra delimiters that do not mean delimination of columns inside quotes. Please, try to find some native Vim solution for this.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;How can I remove every second column in Vim?&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Example data as asked in a comment&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;TakeMe&quot;,&quot;NotMe&quot;,&quot;TakeMe3&quot;,&quot;NotMe,4&quot;,&quot;Take,Me,5&quot;&#xA;&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5,&quot;&#xA;&quot;11&quot;,&quot;22&quot;,&quot;3,3&quot;,&quot;44&quot;,&quot;55&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and intended output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;TakeMe&quot;,&quot;TakeMe3&quot;,&quot;Take,Me,5&quot;&#xA;&quot;1&quot;,&quot;3&quot;,&quot;5,&quot;&#xA;&quot;11&quot;,&quot;3,3&quot;,&quot;55&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Alternative approaches&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:%!awk -F',' '{ for (i=1;i&amp;lt;=NF;i+=2) print $i }'&lt;/code&gt;, then &lt;code&gt;%s@$@,@g&lt;/code&gt; (separate column values), then &lt;code&gt;ggVGJ&lt;/code&gt; (to join all values together with ^M as separators) and then &lt;code&gt;%s@\n@\n@&lt;/code&gt; (to remove ^M in bad formated files to separate rows).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/148285/extract-value-between-double-quotes&quot;&gt;Extract value between double quotes&lt;/a&gt; in Unix.SE&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/7804673/escaping-separator-within-double-quotes-in-awk&quot;&gt;https://stackoverflow.com/questions/7804673/escaping-separator-within-double-quotes-in-awk&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;%!cut -d '&quot;' -f2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,...&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10986" LastActivityDate="2017-07-21T17:24:55.763" Title="How to remove every second column in Vim?" Tags="|filetype|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12968" PostTypeId="1" CreationDate="2017-07-20T19:55:20.607" Score="1" ViewCount="50" Body="&lt;p&gt;I'm trying to hide the quickfix window while building, so that it doesn't show outdated info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can, of course, execute &lt;code&gt;:ccl&lt;/code&gt; at any time to close quickfix. Additionally, I've used autocmd to call a function &lt;code&gt;BeforeQuickFix&lt;/code&gt; which is successfully executed when prior to the execution of &lt;code&gt;makeprg&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;hide quickfix when re-compiling&#xA;function BeforeQuickFix()&#xA;    :ccl&#xA;    :echom &quot;hello test&quot;&#xA;endfunction&#xA;&#xA;autocmd QuickFixCmdPre * :call BeforeQuickFix()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, while I see &quot;hello test&quot; printed prior to the execution of makeprg, the quickfix window never closes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also tried to clear its contents instead with &lt;code&gt;:cexpr []&lt;/code&gt;, but puzzlingly that also has no effect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;hide quickfix when re-compiling&#xA;function BeforeQuickFix()&#xA;    :noautocmd cexpr []&#xA;endfunction&#xA;&#xA;autocmd QuickFixCmdPre * :call BeforeQuickFix()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm sure I can manually hack at &lt;code&gt;makeprg&lt;/code&gt; to get it to do what I want, but there has to be a cleaner way than that, right?&lt;/p&gt;&#xA;" OwnerUserId="13499" LastActivityDate="2017-07-20T19:55:20.607" Title="Can't hide quickfix before executing makeprg" Tags="|autocmd|quickfix|makeprg|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12969" PostTypeId="2" ParentId="12961" CreationDate="2017-07-20T22:30:14.520" Score="1" Body="&lt;p&gt;I don't think you can configure this in VIM (see &lt;code&gt;help incsearch&lt;/code&gt;) but &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/haya14busa/incsearch.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/haya14busa/incsearch.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;may be an option (if it's not already included you could ask for or implement that feature).&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-07-20T22:30:14.520" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12970" PostTypeId="1" AcceptedAnswerId="12972" CreationDate="2017-07-20T22:50:33.057" Score="0" ViewCount="548" Body="&lt;p&gt;Vim indents Ruby multiline method-chains like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;object.read&#xA;  .write&#xA;  .rithmetic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to make it align the dots instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;object.read&#xA;      .write&#xA;      .rithmetic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't been able to find a relevant setting in any of &lt;code&gt;$VIMRUNTIME/indent/ruby.vim&lt;/code&gt;, &lt;code&gt;$VIMRUNTIME/syntax/ruby.vim&lt;/code&gt;, or &lt;a href=&quot;https://github.com/vim-ruby/vim-ruby&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim-ruby/vim-ruby&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this configurable, or do I need to write my own customization?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Update:&lt;/em&gt; I borrowed some ideas from the answer below in an attempt to write a solution that doesn't move the cursor or generate multiple undo-blocks. It works quite well when triggered manually. Wiring it into an insert-mode &lt;strong&gt;&lt;code&gt;.&lt;/code&gt;&lt;/strong&gt; mapping is proving tricky/buggy, but I'm still fiddling with it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! realign#ruby_method_chain()&#xA;  if s:has_leading_dot()&#xA;    call s:align_method_chain_up()&#xA;  endif&#xA;  if line('.') &amp;lt; line('$')&#xA;    call s:align_method_chain_down()&#xA;  endif&#xA;endf&#xA;&#xA;func! s:has_leading_dot()&#xA;  return match(getline('.'), '^\s*\zs\.') != -1&#xA;endf&#xA;&#xA;func! s:align_method_chain_up()&#xA;  let [dot_line, dot_col] = s:chainstart()&#xA;  if dot_line&#xA;    call s:align_range(dot_line + 1, line('.'), dot_col)&#xA;  endif&#xA;endf&#xA;&#xA;func! s:chainstart()&#xA;  let before_line = '\%&amp;lt;'. line('.') .'l'&#xA;  let dot = s:backsearch_chainstart(before_line, '')&#xA;&#xA;  while dot[0] &amp;amp;&amp;amp; s:is_comment(dot)&#xA;    let before_col = '\%&amp;lt;'. dot[1] .'c'&#xA;    let dot = s:backsearch_chainstart(before_line, before_col)&#xA;  endwhile&#xA;&#xA;  return dot&#xA;endf&#xA;&#xA;func! s:backsearch_chainstart(line_anchor, col_anchor)&#xA;  return searchpos(s:chainstart_regex(a:line_anchor, a:col_anchor), 'bWn') &quot; backwards, no-wrap, no-move&#xA;endf&#xA;&#xA;func! s:chainstart_regex(line, col)&#xA;  return '^\s*[^[:blank:].].*' . a:line . a:col . '\zs\.\ze\K'&#xA;endf&#xA;&#xA;func! s:is_comment(pos)&#xA;  return synIDattr(synID(a:pos[0], a:pos[1], 1), 'name') == 'rubyComment'&#xA;endf&#xA;&#xA;func! s:align_range(minline, maxline, col)&#xA;  if a:minline &amp;lt;= a:maxline&#xA;    execute a:minline.','.a:maxline 'left' a:col - 1&#xA;  endif&#xA;endf&#xA;&#xA;func! s:align_method_chain_down()&#xA;  let [curline, dot_col] = s:chaindot()&#xA;  if dot_col&#xA;    let maxline = s:chain_maxline()&#xA;    call s:align_range(curline + 1, maxline, dot_col)&#xA;  endif&#xA;endf&#xA;&#xA;func! s:chaindot()&#xA;  let curline = line('.')&#xA;  let linestr = getline(curline)&#xA;  let dot_idx = match(linestr, '.*\zs\.\ze\K.*$')&#xA;&#xA;  while dot_idx != -1 &amp;amp;&amp;amp; s:is_comment([curline, dot_idx + 1])&#xA;    let linestr = linestr[:(dot_idx - 1)]&#xA;    let dot_idx = match(linestr, '.*\zs\.\ze\K.*$')&#xA;  endwhile&#xA;&#xA;  return [curline, dot_idx + 1]&#xA;endf&#xA;&#xA;func! s:chain_maxline()&#xA;  let pattern = '\%&amp;gt;'.line('.').'l^\s*\([^[:blank:].]\+.*\)\?$'&#xA;  let line_beyond = search(pattern, 'nW')&#xA;  return line_beyond ? line_beyond - 1 : line('$')&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1855" LastEditorUserId="1855" LastEditDate="2017-07-24T13:05:28.980" LastActivityDate="2017-07-24T13:05:28.980" Title="Ruby indentation: align multiline method chains on the leading dot?" Tags="|indentation|filetype-ruby|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12971" PostTypeId="2" ParentId="12967" CreationDate="2017-07-20T23:12:04.313" Score="3" Body="&lt;p&gt;this is doable with :s, as in&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/\(&quot;[^&quot;]*&quot;\)\s*,\s*&quot;[^&quot;]*&quot;/\1/g&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-07-20T23:12:04.313" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12972" PostTypeId="2" ParentId="12970" CreationDate="2017-07-21T01:56:25.450" Score="0" Body="&lt;p&gt;I came up with the following. Put this inside &lt;code&gt;~/.vim/after/ftplugin/ruby.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; . .&amp;lt;esc&amp;gt;:call &amp;lt;sid&amp;gt;electric_dot()&amp;lt;cr&amp;gt;a&#xA;&#xA;function! s:electric_dot()&#xA;  let lnum = line('.')&#xA;  if getline(lnum) !~ '^\s*\.$'&#xA;    return&#xA;  endif&#xA;&#xA;  let pat = '^\s*\.'&#xA;  let start = s:until(pat, 'b')&#xA;  execute lnum&#xA;&#xA;  if start == 0 || getline(start-1) !~ '^\s*\w.*\.\w'&#xA;    normal! ^&#xA;    return&#xA;  endif&#xA;&#xA;  let end = s:until(pat, '')&#xA;  let indent = len(matchstr(getline(start-1), '.*\ze\.'))&#xA;&#xA;  execute start.','.end.'left'.indent&#xA;  execute lnum&#xA;  normal! ^&#xA;endfunction&#xA;&#xA;function! s:until(pat, flags)&#xA;  let lnum = line('.')&#xA;  let [temp,_] = searchpos(a:pat, a:flags.'W')&#xA;  while abs(temp - lnum) == 1&#xA;    let lnum = temp&#xA;    let [temp,_] = searchpos(a:pat, a:flags.'W')&#xA;  endwhile&#xA;  return lnum&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically this creates a mapping on &lt;code&gt;.&lt;/code&gt; in insert mode which finds the closest block of &lt;code&gt;^\s*\.&lt;/code&gt; text. Using this it looks to see if the line before the block matches your &lt;code&gt;object.method&lt;/code&gt; style. If it does then it indents the block to the level of the last &lt;code&gt;.&lt;/code&gt;. Then jumps back into insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Depends on &lt;code&gt;set expandtab&lt;/code&gt;, so no tabs&lt;/li&gt;&#xA;&lt;li&gt;Naive method to search for last method call, so a &lt;code&gt;.&lt;/code&gt; in a parameter will throw this off&lt;/li&gt;&#xA;&lt;li&gt;Depends on &lt;code&gt;set magic&lt;/code&gt;. Could update this with &lt;code&gt;\m&lt;/code&gt; to remove this.&lt;/li&gt;&#xA;&lt;li&gt;Has no understanding of ruby parsing rules so probably misbehaves in some cases.&lt;/li&gt;&#xA;&lt;li&gt;This was a fun exercise for me. I have not plans on maintain this. Do not blame me if it messes up your code, destroys your computer, runs off with your significant other, or any other bad behavior.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-07-21T01:56:25.450" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12973" PostTypeId="1" CreationDate="2017-07-21T02:49:38.070" Score="26" ViewCount="9918" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UuaVB.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UuaVB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;eslint&lt;/code&gt; with &lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;ale&lt;/code&gt;&lt;/a&gt; to lint my Javascript code. After editing a code block, I often have a few errors to fix. Fixing is done by navigating to the next erroneous line, reading the problem from the ruler and fixing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I could skip the navigation phase and use a specific key binding to navigate to the location of the next error - its line, and hopefully its column - it would be great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to use key binding to navigate to the next lint/ale error?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="13179" LastEditorUserId="51" LastEditDate="2017-12-20T23:43:45.010" LastActivityDate="2020-11-09T14:21:36.363" Title="ale linter + eslint: Jump to next error" Tags="|key-bindings|plugin-ale|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12974" PostTypeId="1" CreationDate="2017-07-21T03:29:46.393" Score="0" ViewCount="1454" Body="&lt;h1&gt;Screenshots&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/buVLV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/buVLV.png&quot; alt=&quot;vim screenshot&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/8tOHy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8tOHy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;My problem&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I am working on a &lt;code&gt;js&lt;/code&gt; file, using &lt;code&gt;eslint&lt;/code&gt; as my linter with the &lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ale plugin&lt;/a&gt;, configured using the &lt;code&gt;airbnb&lt;/code&gt; standard which mandates 2 space indentation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open a new line by hitting &lt;code&gt;o&lt;/code&gt;, the new line is indented with 4 spaces, regardless of the filetype. I have set &lt;code&gt;tabstop=4&lt;/code&gt;, but I want this to change for &lt;code&gt;js&lt;/code&gt; files according the the rules of my linter.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;My &lt;code&gt;.vimrc&lt;/code&gt;&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; General settings&#xA;syntax on&#xA;set rulerformat=%l,%c%V%=%P&#xA;set ruler&#xA;set relativenumber      &quot; Current line number is absolute, others relative. Makes j-k jumps easier&#xA;set number              &quot; Show line numbers&#xA;set tabstop=4           &quot; Show tabs as 4 spaces&#xA;set shiftwidth=4        &quot; Indent with 4 spaces when &amp;gt; is pressed&#xA;set expandtab           &quot; Indent with 4 spaces when &amp;gt; is pressed&#xA;set cursorline          &quot; Highlight current line&#xA;filetype on             &quot; :help filetype - Auto-detect the current file type, by name and content&#xA;filetype plugin on      &quot; :help filetype - Enable loading the plugin files for specific file types&#xA;&#xA;&quot; Appearance&#xA;colorscheme tayra&#xA;&#xA;&#xA;&quot; Plugin installation using Plug&#xA;call plug#begin('~/.vim/plugged')&#xA;Plug 'w0rp/ale'&#xA;Plug 'junegunn/fzf.vim'&#xA;Plug 'mhinz/vim-sayonara'&#xA;Plug 'vim-airline/vim-airline'&#xA;Plug 'vim-airline/vim-airline-themes'&#xA;call plug#end()&#xA;&#xA;&quot; Plugin options&#xA;let g:ale_linters = {'javascript': ['eslint']}&#xA;let g:ale_javascript_eslint_executable='/usr/local/bin/eslint'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;What have I tried&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Searching the net, and adding &lt;code&gt;filetype on&lt;/code&gt; and &lt;code&gt;filetype plugin on&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;My question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;How can I set the indentation to automatically suit the current file type?&lt;/p&gt;&#xA;" OwnerUserId="13179" LastActivityDate="2017-07-21T18:33:49.453" Title="How to correctly indent when beginning a new line below the cursor ('o')?" Tags="|indentation|filetype|" AnswerCount="1" CommentCount="1" ClosedDate="2017-07-22T13:51:39.177" ContentLicense="CC BY-SA 3.0" />
  <row Id="12975" PostTypeId="2" ParentId="12962" CreationDate="2017-07-21T05:31:52.543" Score="2" Body="&lt;p&gt;The solution is to use &lt;code&gt;S&lt;/code&gt; on the empty line in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you search for documentation on it via &lt;code&gt;:help S&lt;/code&gt;, you'll find&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;[&quot;x]S&lt;/code&gt; Delete [count] lines [into register x] and start insert.  Synonym for &quot;cc&quot; linewise.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So merely typing &lt;code&gt;S&lt;/code&gt; deletes the present line and starts insert (at the correct indentation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to StandardEyre's comment, which led me to &lt;a href=&quot;https://vi.stackexchange.com/a/3613/12650&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12650" LastActivityDate="2017-07-21T05:31:52.543" CommentCount="0" CommunityOwnedDate="2017-07-21T05:31:52.543" ContentLicense="CC BY-SA 3.0" />
  <row Id="12976" PostTypeId="1" CreationDate="2017-07-21T06:06:50.520" Score="1" ViewCount="81" Body="&lt;p&gt;Is there a way to use QuickFix as a source for auto-completion? Let me explain, my experiments with project-wide autocompletion did not end with any successful results and I tried every plugin imaginable&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However *vim is autocompleting just fine from open files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quite often I use &lt;code&gt;i_CTRL-X_CTRL-L&lt;/code&gt; to complete whole lines because I don't remember paths for importing libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But to make it work I first need to search for a similar line and open the file containing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to autocomplete from the QuickFix window where &lt;code&gt;:Ag&lt;/code&gt; dumps the results?&lt;/p&gt;&#xA;" OwnerUserId="237" LastActivityDate="2017-07-21T06:06:50.520" Title="Use quickfix for completion" Tags="|autocompletion|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12978" PostTypeId="2" ParentId="12955" CreationDate="2017-07-21T10:22:58.520" Score="1" Body="&lt;p&gt;You might be interested in Dr. Chips &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4545&quot; rel=&quot;nofollow noreferrer&quot;&gt;MPage&lt;/a&gt; plugin, which does exactly this. From the documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;MPage shows a file in multiple windows, with each sequential window&#xA;  showing sequential lines of text, rather like a book.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Usage:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:MPage [splits]&#xA;:[splits]MPage&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-21T10:22:58.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12979" PostTypeId="2" ParentId="12967" CreationDate="2017-07-21T11:12:10.510" Score="0" Body="&lt;p&gt;Csv.vim is suggested by its author in GitHub. Perl script runs an external command outputting to a new buffer in Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested them on a CSV file with about 400 rows and 30 columns: the for-loop solution hangs up (never getting completed) while perl solution has an instant completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Csv.vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(100,1,-2) | exe &quot;DeleteColumn&quot; i | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Perl in vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :new | r !perl -nle'$i=0;s/^&quot;|&quot;$//g;print map{$i++&amp;amp;1?&quot;&quot;:&quot;$_ &quot;}split(/&quot;,&quot;/)' &quot;#&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10986" LastEditorUserId="10986" LastEditDate="2017-07-21T17:24:55.763" LastActivityDate="2017-07-21T17:24:55.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12980" PostTypeId="2" ParentId="12967" CreationDate="2017-07-21T12:48:05.283" Score="0" Body="&lt;p&gt;I'm a little unclear on whether column values can contain extra &lt;code&gt;&quot;&lt;/code&gt; characters, as well as the extra commas that you include in your example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the answer is no, then you can record a simple recursive macro to remove every second column on a single line:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;gg&lt;/code&gt;: Move to start of file,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qqq&lt;/code&gt;: Clear the &lt;code&gt;q&lt;/code&gt; register: this is necessary for recursive macros,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt;: Start recording in the &lt;code&gt;q&lt;/code&gt; register,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f&quot;&lt;/code&gt;: Find the end of the first entry,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2dt&quot;&lt;/code&gt;: Delete to end of second entry,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ll&lt;/code&gt;: Move to start of third entry,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@q&lt;/code&gt;: Replay the &lt;code&gt;q&lt;/code&gt; macro. This is currently empty, so nothing happens,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: Finish recording,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;u&lt;/code&gt;: Undo change.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can then play this macro on every line of the file with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%normal @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This may look like a lot of steps, but note that steps 1&amp;ndash;3 and steps 7&amp;ndash;9 are essentially boilerplate, and don't require any thought, and the remaining steps 4&amp;ndash;6 are simple normal-mode movement/editing operations that are just as quick, for me. Macros are always more efficient to &lt;em&gt;use&lt;/em&gt; than they look when they are written down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also that if the number of columns is always the same (as in your example), you don't even need a recursive macro. You can just replay an even simpler macro the correct number of times:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg qq f&quot; 2dt&quot; ll q u&#xA;&#xA;:%normal 3@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If column values &lt;em&gt;can&lt;/em&gt; contain extra quotes, you could in all likelihood still use this approach, but the macro would be more complicated, so another solution might work better.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-07-21T13:13:53.783" LastActivityDate="2017-07-21T13:13:53.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12981" PostTypeId="2" ParentId="12974" CreationDate="2017-07-21T18:06:43.750" Score="1" Body="&lt;p&gt;Vim help says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can enable loading the plugin files for specific file types with:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;:filetype plugin on&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If filetype detection was not switched on yet, it will be as well. &lt;em&gt;The result is that when a file is edited its plugin file is loaded (if there is one for the detected filetype)&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Plugin file is just a regular Vim script. To make indentation 2 spaces long for &lt;code&gt;js&lt;/code&gt; files you need to create a file &lt;code&gt;.vim/ftplugin/javascript.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal tabstop=2&#xA;setlocal shiftwidth=2 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You want to use &lt;code&gt;setlocal&lt;/code&gt; instead of &lt;code&gt;set&lt;/code&gt; because &lt;code&gt;set&lt;/code&gt; changes both local and global values (thus changing the value for all open buffers).&lt;/p&gt;&#xA;" OwnerDisplayName="user13463" LastEditorDisplayName="user13463" LastEditDate="2017-07-21T18:33:49.453" LastActivityDate="2017-07-21T18:33:49.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12982" PostTypeId="1" AcceptedAnswerId="13103" CreationDate="2017-07-21T18:17:14.890" Score="2" ViewCount="1243" Body="&lt;p&gt;Most of the time I have my window split, after editing some code, I &lt;code&gt;:terminal&lt;/code&gt; to run some commands to check if my changes make sense. when I exit the terminal, I don't have the window split anymore, I just lose the buffer that was there before running &lt;code&gt;:terminal&lt;/code&gt;. When I remember before I close the terminal (cause my fingers are faster than my brain), is that I go in normal mode, and &lt;code&gt;ctrl-o&lt;/code&gt; to jump back to the previous buffer. does that leave the terminal still running? is there a better way to go close the terminal and go back to my previous split window with buffers?&lt;/p&gt;&#xA;" OwnerUserId="6381" LastActivityDate="2017-08-01T22:55:42.023" Title="return to buffer after exiting terminal, neovim" Tags="|neovim|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12983" PostTypeId="1" AcceptedAnswerId="13000" CreationDate="2017-07-21T18:35:09.423" Score="1" ViewCount="4429" Body="&lt;p&gt;I am trying to do a search and replace on a large database file where some of the urls are escaped and some not, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://www.example.com&#xA;http:\\/\\/www.example.com&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought I could use a simple character class in a regex like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s~http\(:[/\\]+www.example.com\)~https\1~g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But won't work no matter how I escape it.  Can I use character classes in vim search and replace?  If not, how can I match the url so that any amount of backslashes and forward slashes are matched?&lt;/p&gt;&#xA;" OwnerUserId="13528" LastEditorUserId="24" LastEditDate="2017-07-27T08:07:48.540" LastActivityDate="2017-07-27T08:07:48.540" Title="replacing urls and escaped urls" Tags="|regular-expression|substitute|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12984" PostTypeId="2" ParentId="12983" CreationDate="2017-07-21T20:44:25.743" Score="0" Body="&lt;p&gt;Figured this out myself using alternation and &lt;code&gt;\z&lt;/code&gt; for pattern matching:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s,\zshttp\ze:\(/\|\\\)\+www.example.com,https,g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope this helps someone.&lt;/p&gt;&#xA;" OwnerUserId="13528" LastActivityDate="2017-07-21T20:44:25.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12985" PostTypeId="2" ParentId="6029" CreationDate="2017-07-21T21:53:57.273" Score="3" Body="&lt;p&gt;By calling a user-defined function, a mapping that inserts &quot;Hello, &quot; before prompting for the user's name can be achieved:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:InputName()&#xA;    call inputsave()&#xA;    let g:name = input(&quot;Your name please: &quot;)&#xA;    call inputrestore()&#xA;endfunction&#xA;nnoremap &amp;lt;F1&amp;gt; oHello, &amp;lt;C-\&amp;gt;&amp;lt;C-o&amp;gt;:call &amp;lt;SID&amp;gt;InputName()&amp;lt;CR&amp;gt;&amp;lt;C-r&amp;gt;=name&amp;lt;CR&amp;gt;. You have a nice name.&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This answer (with minor differences) was first shared as a &lt;a href=&quot;https://paste.debian.net/plain/359252&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt; in a comment by @saginaw to the answer by @EvergreenTree, but I had essentially reproduced that answer (with a lot of reading &lt;code&gt;:help&lt;/code&gt; pages and Googling) before clicking the link. This seems a distinct answer, from that of @EvergreenTree&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @saginaw pointed out, &lt;code&gt;:help input()&lt;/code&gt; essentially documents this function-based solution, but @saginaw added the script-local function syntax (&lt;code&gt;s:&lt;/code&gt; to the definition, and &lt;code&gt;&amp;lt;sid&amp;gt;&lt;/code&gt; to the call).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This mapping uses insert special keys, including &lt;code&gt;&amp;lt;C-\&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; (see &lt;code&gt;:help i_CTRL-\_CTRL-O&lt;/code&gt;) and and &lt;code&gt;&amp;lt;C-R&amp;gt;=&lt;/code&gt; (see &lt;code&gt;:help i_CTRL-R_=&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="13527" LastActivityDate="2017-07-21T21:53:57.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12986" PostTypeId="2" ParentId="12962" CreationDate="2017-07-21T22:19:00.923" Score="2" Body="&lt;p&gt;As indicated on &lt;a href=&quot;https://vi.stackexchange.com/a/3613/6590&quot;&gt;this related question&lt;/a&gt;, you cannot indent an empty line.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your options are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;to use &lt;code&gt;S&lt;/code&gt;  on the empty line in normal mode. &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This deletes your empty line and starts a new line at the correct indentation&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;to &lt;a href=&quot;https://vi.stackexchange.com/a/3613/6590&quot;&gt;write something on the line&lt;/a&gt; then delete it&lt;/li&gt;&#xA;&lt;li&gt;to &lt;a href=&quot;https://stackoverflow.com/a/30988323/5978252&quot;&gt;map CR&lt;/a&gt; to something that inserts white space and then deletes it right away&lt;/li&gt;&#xA;&lt;li&gt;to insert &lt;a href=&quot;https://stackoverflow.com/q/2727988/5978252&quot;&gt;a line with white space characters&lt;/a&gt; (and redefine your idea of 'useless whitespace')  ;-)  instead of an empty line (no characters).  &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Note that this depends on (a) your use case and (b) your coding style.&lt;/li&gt;&#xA;&lt;li&gt;When I use python I don't have a lot of constraints on coding style. Because I like to copy &amp;amp; paste python code I favor a line with white space, as supported by &lt;a href=&quot;https://stackoverflow.com/a/2728019/5978252&quot;&gt;this answer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="6590" LastEditDate="2017-07-21T22:31:30.390" LastActivityDate="2017-07-21T22:31:30.390" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12987" PostTypeId="1" CreationDate="2017-07-21T23:34:18.703" Score="3" ViewCount="423" Body="&lt;p&gt;With a &quot;long&quot; ruby file (896 lines in my case) the ruby syntax highlighting is lost when I &lt;code&gt;G&lt;/code&gt; to the bottom of the file. Once that happens and I go back to the top with &lt;code&gt;gg&lt;/code&gt;, the syntax highlighting remains off. The only way to get the syntax highlighting back is to just reload the file with &lt;code&gt;:e&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I just &lt;code&gt;&amp;lt;CTRL-F&amp;gt;&lt;/code&gt; from the top all the way to the bottom, then the syntax highlighting remains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a bit similar to &lt;a href=&quot;https://vi.stackexchange.com/questions/10114/syntax-highlighting-randomly-turns-off&quot;&gt;this post&lt;/a&gt; but definitely not the same, as this happens every time I follow the steps listed above. Highlighting for my :help or .vimrc files is NOT lost, even though my .vimrc file is over 1000 lines long [I know, I know... I have to reorganize this; just haven't had time:].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My syntax-specific plugins include the following; I guess the next thing to try is to remove them one at a time and see which one is the perp.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.vim/bundle/Decho/syntax&#xA;.vim/bundle/nerdtree/syntax&#xA;.vim/bundle/tagbar/syntax&#xA;.vim/bundle/tmux.vim/vim/syntax&#xA;.vim/bundle/vim-coffee-script/after/syntax&#xA;.vim/bundle/vim-coffee-script/syntax&#xA;.vim/bundle/vim-cucumber/syntax&#xA;.vim/bundle/vim-haml/syntax&#xA;.vim/bundle/vim-javascript/syntax&#xA;.vim/bundle/vim-jsx/after/syntax&#xA;.vim/bundle/vim-markdown/syntax&#xA;.vim/bundle/vim-ruby/syntax&#xA;.vim/bundle/vim-snipmate/syntax&#xA;.vim/bundle/vimoutliner/syntax&#xA;.vim/bundle/Vundle.vim/syntax&#xA;.vim/eclim/syntax&#xA;.vim/Plugin/mpc/syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the last change is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  filetype=ruby&#xA;        Last set from /usr/local/Cellar/vim/8.0.0692/share/vim/vim80/filetype.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So not much information there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This only started happening &quot;recently&quot; (past few weeks, plus my machine was re-imaged for macOS Sierra and I've now got the latest versions of everything).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Happens both inside/outside of tmux&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions besides the brute force approach?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="4449" LastEditorUserId="51" LastEditDate="2017-07-22T13:49:16.780" LastActivityDate="2023-12-19T21:05:45.670" Title="ruby syntax highlighting lost on long files" Tags="|syntax-highlighting|filetype-ruby|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12988" PostTypeId="1" AcceptedAnswerId="13001" CreationDate="2017-07-22T01:48:32.877" Score="5" ViewCount="2316" Body="&lt;p&gt;I want to edit words that need accents (á) were they are missing. It's no problem to write down accents in insert mode: it is just &quot;' + letter&quot;, so I can easily write á, é, í, ó, ú. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How do get accent on a letter in normal mode (on top of a given letter)?&lt;/h2&gt;&#xA;&#xA;&lt;h3&gt;How do I transform &quot;o&quot; into &quot;ó&quot; in normal mode (with least keystrokes)?&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;spell check&lt;/strong&gt; is one option, but it seems important to be able to do the check just by reading and modifying, without spell check.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;with &lt;strong&gt;&quot;r'o&quot;&lt;/strong&gt; this could of course be achieved, but I'm looking for less strokes. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Single stroke would be great&lt;/em&gt;. &lt;strong&gt;Like &quot;~&quot;&lt;/strong&gt;, which changes a minor letter to an upper case with just, from &quot;a&quot; to &quot;A&quot;, and back. That is the intended behavior I'm seeking.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Best result would be if every accent could be done with one stroke on each word. This way one could use the repeat command: &quot;.&quot; (which in keyboard implies pressing only one key (.), which is less than &quot;~&quot;, that goes with function key or shift. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;tl,dr: a shortcut for vowels, to edit faster a full text lacking all needed accents&lt;/h3&gt;&#xA;" OwnerUserId="12815" LastActivityDate="2017-07-24T00:51:21.343" Title="How to add accent to letters in normal mode?" Tags="|key-bindings|normal-mode|replace|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12990" PostTypeId="1" AcceptedAnswerId="13019" CreationDate="2017-07-22T04:45:44.037" Score="1" ViewCount="538" Body="&lt;p&gt;I'm on windows, using vim &lt;code&gt;8.0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I do&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:hi TabLine ctermfg=Red ctermbg=Black&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The background of the unselected tabs changes, but not the foreground. It stays &lt;code&gt;Cyan&lt;/code&gt;. It works properly for &lt;code&gt;TabLineSel&lt;/code&gt; though, but not for this one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've quickly looked on Google, but didn't find anything relevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a solution (I would like to get the foreground to be &lt;code&gt;White&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even with the option &lt;code&gt;vim -u NONE&lt;/code&gt;, the default fg color for inactive tabs is Cyan.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/T8FZi.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T8FZi.gif&quot; alt=&quot;Demo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13449" LastEditorUserId="13449" LastEditDate="2017-07-23T04:52:57.373" LastActivityDate="2017-07-24T07:28:46.250" Title=":hi TabLine ctermfg=Whatever not working on Windows" Tags="|tabbed-user-interface|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12991" PostTypeId="1" CreationDate="2017-07-22T05:49:19.927" Score="0" ViewCount="162" Body="&lt;p&gt;I installed some plugins which is supported above &lt;code&gt;vi&lt;/code&gt; version 7.4. When i open files with &lt;code&gt;vi&lt;/code&gt; command its will show the plugin not supported with version 7.3. After that i was opened with &lt;code&gt;vim&lt;/code&gt; command its working. Then i check the version using vi command its showing version 7.3 , in vim version is 8.x. So i checked origin vi command using &lt;code&gt;which vim&lt;/code&gt; , which returns /usr/bin/vi.Its the softlink of another version vim. So I want&#xA;    to remove old version of vim without remove installed plugins&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OS:MAC &lt;/p&gt;&#xA;" OwnerUserId="7834" LastActivityDate="2017-07-22T10:21:58.103" Title="Version conflict between vi and vim" Tags="|macvim|version|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12992" PostTypeId="2" ParentId="12991" CreationDate="2017-07-22T10:21:58.103" Score="2" Body="&lt;p&gt;You don't need to use original vi program, just add following alias to your bashrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vi='vim -u NONE'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10798" LastActivityDate="2017-07-22T10:21:58.103" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12993" PostTypeId="1" CreationDate="2017-07-22T13:30:37.640" Score="2" ViewCount="821" Body="&lt;p&gt;I've set &lt;code&gt;formatprg&lt;/code&gt; in my vimrc to use the &lt;a href=&quot;http://www.nicemice.net/par/&quot; rel=&quot;nofollow noreferrer&quot;&gt;par&lt;/a&gt; text formatter when I type &lt;strong&gt;&lt;code&gt;gq&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setg formatprg=par\ -w90&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I'm in a buffer whose &lt;code&gt;textwidth&lt;/code&gt; has been set (e.g. the gitcommit filetype sets &lt;code&gt;textwidth=72&lt;/code&gt;), I'd like to use that number rather than 90.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of hard-coding different values in a bunch of ftplugin files, I'd like to compute the number dynamically upon usage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I took a look at &lt;code&gt;formatexpr&lt;/code&gt;, but if I set a formatexpr it would also be called whenever I enter characters beyond the textwidth line length, and I don't think I'd want to call out to an external process that frequently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only other solutions I can think of are writing a wrapper around &lt;strong&gt;&lt;code&gt;gq&lt;/code&gt;&lt;/strong&gt; (which I imagine would get complex if I want to support operating-pending mode correctly) and adding an autocmd that listens for the Filetype event and sets &lt;code&gt;formatprg&lt;/code&gt; appropriately. That last solution seems the most reasonable, actually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm curious if there's another option I'm overlooking?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2017-08-22T08:31:16.743" Title="set formatprg dynamically based on textwidth?" Tags="|formatting|options|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12994" PostTypeId="2" ParentId="12988" CreationDate="2017-07-22T13:37:05.187" Score="3" Body="&lt;p&gt;You could put one of the following codes at the end of your &lt;code&gt;vimrc&lt;/code&gt; file to make the &lt;kbd&gt;-&lt;/kbd&gt; key toggle the vowel under the cursor between the &#xA;accented and unaccented form:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The intuitive solution&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleAccent()&#xA;   &quot; Vowels&#xA;   let withAccent   = [ &quot;á&quot;, &quot;é&quot;, &quot;í&quot;, &quot;ó&quot;, &quot;ú&quot;, &quot;Á&quot;, &quot;É&quot;, &quot;Í&quot;, &quot;Ó&quot;, &quot;Ú&quot; ]&#xA;   let withNoAccent = [ &quot;a&quot;, &quot;e&quot;, &quot;i&quot;, &quot;o&quot;, &quot;u&quot;, &quot;A&quot;, &quot;E&quot;, &quot;I&quot;, &quot;O&quot;, &quot;U&quot; ]&#xA;&#xA;   &quot; A better way of getting the character under the cursor&#xA;   &quot; From: https://stackoverflow.com/a/23323958/1121933&#xA;   let character = matchstr( getline('.'), '\%' . col('.') . 'c.' )&#xA;&#xA;   &quot; If it's a vowel without an acute accent over it, 'position' will contain&#xA;   &quot; the index of the matching element in the 'withNoAccent' list or -1 otherwise.&#xA;   let position = match( withNoAccent , character )&#xA;   if position != -1&#xA;      &quot; Replace it with an accented vowel&#xA;      execute &quot;:normal! r&quot; . withAccent[position]&#xA;   else&#xA;      &quot; Check if it's a vowel with an acute accent over it&#xA;      let position = match( withAccent , character )&#xA;      if position != -1&#xA;         &quot; Replace it with a vowel with no accent&#xA;         execute &quot;:normal! r&quot; . withNoAccent[position]&#xA;     endif&#xA;   endif&#xA;&#xA;   &quot; Do nothing if it isn't a vowel&#xA;endfunction&#xA;&#xA;&quot; Map the '-' key&#xA;nnoremap &amp;lt;silent&amp;gt; - :call ToggleAccent()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;The clever solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;See Luc Hermitte's &lt;a href=&quot;https://vi.stackexchange.com/a/13001/6698&quot;&gt;answer&lt;/a&gt;, but here's what's going on:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;s&lt;/code&gt; Delete the character under the cursor, save it into register &lt;code&gt;&quot;&lt;/code&gt; and start insert mode. See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#s&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help s&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt; Insert the content of the register that follows (&lt;code&gt;=&lt;/code&gt; in that case). See &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL%2dR&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-R&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;=&lt;/code&gt; This is the expression register, i.e., you're prompted to enter a expression. Once the expression is evaluated (after you hit &lt;kbd&gt;Enter&lt;/kbd&gt;, represented by &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;), the result (the string returned by &lt;code&gt;tr()&lt;/code&gt;) is saved in that register. See &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL%2dR_%3d&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-R_=&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;tr({src},{fromstr},{tostr})&lt;/code&gt; Return a copy of the &lt;code&gt;{src}&lt;/code&gt; string with all characters which appear in &lt;code&gt;{fromstr}&lt;/code&gt; replaced by the character in that position in the &lt;code&gt;{tostr}&lt;/code&gt; string (see &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#tr%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help tr()&lt;/code&gt;&lt;/a&gt;.) That's what &lt;code&gt;ToggleAccent()&lt;/code&gt; above tries to do. In that case &lt;code&gt;{src}&lt;/code&gt; is &lt;code&gt;@&quot;&lt;/code&gt;, that's the way Vim gets the content of register &lt;code&gt;&quot;&lt;/code&gt;. See &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/19.html#registers-as-variables&quot; rel=&quot;nofollow noreferrer&quot;&gt;Registers as Variables&lt;/a&gt; at &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; Hit &lt;kbd&gt;Enter&lt;/kbd&gt; and evaluate the expression&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; Go back to normal mode&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the &lt;code&gt;.&lt;/code&gt; command doesn't repeat custom mappings, but&#xA;you can read Ingo Karkat's &lt;a href=&quot;https://vi.stackexchange.com/a/10468/6698&quot;&gt;answer&lt;/a&gt; to get around it.&lt;/p&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="6698" LastEditDate="2017-07-24T00:51:21.343" LastActivityDate="2017-07-24T00:51:21.343" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12995" PostTypeId="1" AcceptedAnswerId="12998" CreationDate="2017-07-22T13:47:32.043" Score="1" ViewCount="96" Body="&lt;p&gt;After I do a &lt;code&gt;:sp&lt;/code&gt; or &lt;code&gt;:vsp&lt;/code&gt; I find myself always turning off wrapping in the resulting window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first attempt at automating this action looks like this (for the vertical situation):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! VerticalSplit()&#xA;  vsplit&#xA;  setlocal nowrap&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; :vsp :call VerticalSplit()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to work, but a negative is that when I type &lt;code&gt;:vsp&lt;/code&gt; it doesn't show my typing in the :ex console at the bottom of the screen. This becomes more noticeable when typing other commands such as &lt;code&gt;:vimgrep&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to still show my typing in the ex window, or perhaps a better approach to tackle this problem?&lt;/p&gt;&#xA;" OwnerUserId="2312" LastActivityDate="2017-07-24T23:56:48.170" Title="Custom mapping for ex command -&gt; still show typing in ex console" Tags="|key-bindings|split|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12996" PostTypeId="2" ParentId="613" CreationDate="2017-07-22T17:39:13.287" Score="42" Body="&lt;h1&gt;Vim 8+ / Neovim&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/doc/version8.txt#L97-L103&quot; rel=&quot;noreferrer&quot;&gt;Version 8 introduces a new packages mechanism&lt;/a&gt; that largely replaces the need for existing plugin managers (pathogen, vim-plug, vundle, etc.) at the time of writing (2017).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;https://github.com/vim/vim/blob/03c3bd9fd094c1aede2e8fe3ad8fd25b9f033053/runtime/doc/repeat.txt#L515&quot; rel=&quot;noreferrer&quot;&gt;documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A Vim &lt;strong&gt;package&lt;/strong&gt; is a directory that contains one or more plugins&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A package directory contains two sub-directories:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;start/&lt;/code&gt; - contains plugins that will be automatically loaded&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;opt/&lt;/code&gt; - contains plugins that are loaded on demand with &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/doc/repeat.txt#L546&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:packadd&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It may seem a bit complicated, but in practice &lt;strong&gt;all you have to do is add your plugin here&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                 ↓ package name&#xA;~/ .vim / pack / bundle / start / some-plugin&#xA;          ↑ packages dir          ↑ plugin dir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;On Windows&lt;/strong&gt;: use &lt;code&gt;~\vimfiles\pack\&lt;/code&gt; instead of &lt;code&gt;~/.vim/pack/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By convention, we've used the package name &quot;bundle&quot; as the directory that will contain all our plugins. You can use any name you want, and you can even put your plugins in separate package directories if you really want to.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example: Installing &lt;a href=&quot;https://github.com/tpope/vim-sensible&quot; rel=&quot;noreferrer&quot;&gt;sensible.vim&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ~/.vim/pack/bundle/start&#xA;cd ~/.vim/pack/bundle/start&#xA;git clone https://github.com/tpope/vim-sensible.git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;On Windows&lt;/strong&gt;: use &lt;code&gt;~\vimfiles\pack\&lt;/code&gt; instead of &lt;code&gt;~/.vim/pack/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next time you start Vim, the plugin will load automatically.&lt;/p&gt;&#xA;" OwnerUserId="13438" LastEditorUserId="343" LastEditDate="2020-01-24T17:13:44.243" LastActivityDate="2020-01-24T17:13:44.243" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="12997" PostTypeId="2" ParentId="12993" CreationDate="2017-07-22T18:20:27.427" Score="4" Body="&lt;p&gt;That's when the &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#OptionSet&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;OptionSet&lt;/code&gt;&lt;/a&gt; event comes in handy, but it doesn't work when it's triggered on startup so you need the  &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#VimEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;VimEnter&lt;/code&gt;&lt;/a&gt; event too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your workflow includes several files opened in different windows/buffers, with different &lt;code&gt;textwidth&lt;/code&gt; values, you can include the &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#BufEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;BufEnter&lt;/code&gt;&lt;/a&gt; event to adjust &lt;code&gt;formatprg&lt;/code&gt; (a global option)  according to the &lt;code&gt;textwidth&lt;/code&gt; of the current window/buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could put the following code at the end of your &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setg formatprg=par\ -w90&#xA;&#xA;function! UpdateFormatprg()&#xA;   let &amp;amp;g:formatprg = substitute( &amp;amp;g:formatprg , '\d\+$', &amp;amp;textwidth , &quot;&quot; )&#xA;endfunction&#xA;&#xA;augroup UpdateFormatprgGroup&#xA;   autocmd!&#xA;   autocmd VimEnter,BufEnter * call UpdateFormatprg()&#xA;   autocmd OptionSet textwidth call UpdateFormatprg()&#xA;augroup END &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="6698" LastEditDate="2017-07-22T18:53:06.083" LastActivityDate="2017-07-22T18:53:06.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12998" PostTypeId="2" ParentId="12995" CreationDate="2017-07-22T18:57:25.080" Score="1" Body="&lt;p&gt;With &lt;code&gt;:cabbrev&lt;/code&gt; you can achieve what you want so Christian Brabandt has&#xA;made a great suggestion. Now you have two different approaches, on one hand&#xA;you could try Christian's suggestion and type in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cabbrev vsp vsplit &amp;lt;bar&amp;gt; set nowrap&#xA;:cabbrev sp split &amp;lt;bar&amp;gt; set nowrap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or, on the other hand, you could map &lt;kbd&gt;Enter&lt;/kbd&gt; in command mode, check if you typed in either &lt;code&gt;sp&lt;/code&gt; or &lt;code&gt;vsp&lt;/code&gt; and if so set &lt;code&gt;nowrap&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! WrapIfSplit()&#xA;   let cmdline = getcmdline()&#xA;   if cmdline == &quot;vsp&quot;&#xA;      return &quot;\&amp;lt;C-U&amp;gt;vsplit \&amp;lt;bar&amp;gt; set nowrap\&amp;lt;CR&amp;gt;&quot; &#xA;   elseif cmdline == &quot;sp&quot;&#xA;      return &quot;\&amp;lt;C-U&amp;gt;split \&amp;lt;bar&amp;gt; set nowrap\&amp;lt;CR&amp;gt;&quot; &#xA;   endif&#xA;   return &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;cnoremap &amp;lt;expr&amp;gt;&amp;lt;silent&amp;gt; &amp;lt;CR&amp;gt; WrapIfSplit()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="6698" LastEditDate="2017-07-24T23:56:48.170" LastActivityDate="2017-07-24T23:56:48.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13000" PostTypeId="2" ParentId="12983" CreationDate="2017-07-22T21:14:41.427" Score="1" Body="&lt;p&gt;In your search pattern of the &lt;code&gt;:s&lt;/code&gt; part you are looking for &lt;code&gt;www.&lt;/code&gt; which is not part of your source. So it won't match. Better would be to make that part optionally:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s~http\(:[/\\]\+\(www.\)\?example.com\)~https\1~g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or even better: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s~http:[/\\]\+\(\(www.\)\?example.com\)~https://\1~g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will also normalize the slashes following the protocol part of your URI.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-22T21:14:41.427" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13001" PostTypeId="2" ParentId="12988" CreationDate="2017-07-22T22:45:42.607" Score="7" Body="&lt;p&gt;If you set &lt;code&gt;'digraph'&lt;/code&gt;, (IOW makes sure &lt;code&gt;:set digraph&lt;/code&gt; is in your &lt;code&gt;.vimrc&lt;/code&gt;) it could become as simple as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; µ s&amp;lt;c-r&amp;gt;&quot;&amp;lt;bs&amp;gt;'&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key points are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;s&amp;lt;c-r&amp;gt;&quot;&lt;/code&gt; that replaces the current character under the cursor with itself and stays in insert mode -- this is important for the next step.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;e &amp;lt;BS&amp;gt; '&lt;/code&gt; that becomes &lt;code&gt;é&lt;/code&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note we could also use &lt;code&gt;tr()&lt;/code&gt;, but in that case we'll need to specify all possible replacements. We could even imagine cycles between &lt;code&gt;e é è ê ë&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; µ s&amp;lt;c-r&amp;gt;=tr(@&quot;, 'aeioucnAEIOUCNáéíóúçñÁÉÍÓÚÇÑ', 'áéíóúçñÁÉÍÓUÇÑaeioucnAEIOUCN')&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I use &lt;code&gt;µ&lt;/code&gt;, the Greek mu character, to trigger the mapping as it's available on my French keyboard and easy to recognize when we're not used to mappings. If you prefer &lt;code&gt;-&lt;/code&gt; use it. This is not important. It's up to you to chose a key that you don't, and will never, use for anything else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus: here is a mapping that'll work in visual mode in case you'll want to replace several characters at once. Remark: unlisted characters won't be affected.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;silent&amp;gt; µ s&amp;lt;c-r&amp;gt;=tr(@&quot;,'aeioucnAEIOUCNáéíóúçñÁÉÍÓÚÇÑ', 'áéíóúçñÁÉÍÓUÇÑaeioucnAEIOUCN')&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-07-23T21:31:56.280" LastActivityDate="2017-07-23T21:31:56.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13002" PostTypeId="2" ParentId="12987" CreationDate="2017-07-23T01:01:38.763" Score="0" Body="&lt;p&gt;Sounds like a synchronization issue. Try&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:syntax sync maxlines=1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Find the details in &lt;code&gt;:help :syn-sync&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="10604" LastEditDate="2022-07-27T18:21:22.897" LastActivityDate="2022-07-27T18:21:22.897" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="13004" PostTypeId="2" ParentId="2115" CreationDate="2017-07-23T02:42:26.590" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;I think I'd also accept an answer that gave a command that reverted the file to the state it was in since the last time you opened it. (Or better, jumped back to that undo state.)&lt;/p&gt;&#xA;&lt;p&gt;&amp;gt; Rich&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I really liked the quoted idea so I made &lt;code&gt;:Revert&lt;/code&gt; command. I hope you'll find it relevant to your question.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Real_seq(inner, outer) abort&#xA;  let node = a:outer&#xA;  for i in a:inner&#xA;    if has_key(i, 'alt')&#xA;      call s:Real_seq(i.alt, deepcopy(node))&#xA;    endif&#xA;    if has_key(i, 'curhead')&#xA;      return {'seq': node.seq}&#xA;    endif&#xA;    let node.seq  = i.seq&#xA;  endfor&#xA;endfunction&#xA;&#xA;function! s:Get_seq(tree) abort&#xA;  let query = s:Real_seq(a:tree.entries, {'seq': 0})&#xA;  if (type(query) == 4)&#xA;    return query.seq&#xA;  else&#xA;    return undotree()['seq_cur']&#xA;  endif&#xA;endfunction&#xA;&#xA;au BufReadPost,BufNewFile * if !exists('b:undofile_start') &#xA;      \ | let b:undofile_start = s:Get_seq(undotree()) | endif&#xA;&#xA;command! -bar Revert execute &amp;quot;undo &amp;quot; . get(b:, 'undofile_start', 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Helper functions &lt;code&gt;Get_seq&lt;/code&gt; and &lt;code&gt;Real_seq&lt;/code&gt;, based on &lt;a href=&quot;https://github.com/mbbill/undotree/blob/master/plugin/undotree.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;undotree&lt;/a&gt;, are necessary because &lt;code&gt;undotree()['seq_cur']&lt;/code&gt; is sometimes not enough to pinpoint current position in undo tree. You can read more about it &lt;a href=&quot;https://www.reddit.com/r/vim/comments/dszuz/gundo_my_little_undo_tree_visualization_plugin/c12ril4/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13543" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-07-26T11:20:34.030" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13005" PostTypeId="1" AcceptedAnswerId="13013" CreationDate="2017-07-23T04:49:30.370" Score="4" ViewCount="675" Body="&lt;p&gt;I am using vimwiki with and conceal the long URLs as links like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[[http://a-really-long-long-url|Link]] rest of text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Under my configuration (&lt;code&gt;conceallevel=2 concealcursor=nc linebreak&lt;/code&gt;) it should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Link rest of text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But usually it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Link rest&#xA;of text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is unfortunate, as I don't want the &lt;code&gt;linebreak&lt;/code&gt; setting taking effect on the length of the original line (which is long), but on the displayed line, which is much shorter and shouldn't have be broken into 2 visual lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make &lt;code&gt;linebreak&lt;/code&gt; take the displayed line into consideration when deciding if and whether to break?&lt;/p&gt;&#xA;" OwnerUserId="3188" LastActivityDate="2017-07-24T19:55:46.633" Title="How to make linebreak play along with conceal" Tags="|line-breaks|conceal|plugin-vimwiki|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13006" PostTypeId="1" AcceptedAnswerId="13007" CreationDate="2017-07-23T07:44:40.593" Score="21" ViewCount="3694" Body="&lt;p&gt;I would like to know what is the meaning of the &lt;code&gt;#&lt;/code&gt; symbol in function names e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1860" LastActivityDate="2017-07-23T08:54:48.310" Title="What is the meaining of '#' symbol in function name?" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13007" PostTypeId="2" ParentId="13006" CreationDate="2017-07-23T08:54:48.310" Score="27" Body="&lt;p&gt;That's part of the autoload&#xA; mechanism. From&#xA;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/53.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;Autoloading&lt;/code&gt;&lt;/a&gt; at &#xA;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; &#xA;and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#autoload&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help autoload&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Autoload lets you delay loading code until it's actually needed, so if the &#xA;following function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;has already been loaded, Vim will simply call it normally.  Otherwise Vim will&#xA;look for a file called &lt;code&gt;autoload/pathogen.vim&lt;/code&gt; in your &lt;code&gt;~/.vim&lt;/code&gt; directory . If this&#xA;file exists, Vim will load/source the file. It will then try to call the&#xA;function normally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every &lt;code&gt;#&lt;/code&gt; in the function name works like a path separator.  Thus when calling a&#xA;function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call foo#bar#func()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will look for the file &lt;code&gt;autoload/foo/bar.vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6698" LastActivityDate="2017-07-23T08:54:48.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13008" PostTypeId="1" AcceptedAnswerId="13010" CreationDate="2017-07-23T11:23:31.650" Score="2" ViewCount="578" Body="&lt;p&gt;I want to call the function by its name as string variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Help describes that I need to use the &lt;code&gt;call()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call('ceil', [1.4])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I am getting an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E129: Function name required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="1860" LastActivityDate="2017-07-23T12:04:57.110" Title="E129 when calling the function by call()" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13009" PostTypeId="2" ParentId="12973" CreationDate="2017-07-23T11:59:22.067" Score="15" Body="&lt;p&gt;You can easily move between errors by adding some key bindings to ale's &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mappings (see &lt;code&gt;:h &amp;lt;Plug&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;In this &lt;a href=&quot;https://github.com/dense-analysis/ale#5xi-how-can-i-navigate-between-errors-quickly&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt; use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt; to go to next error and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;k&lt;/kbd&gt; to go to the previous error.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;C-k&amp;gt; &amp;lt;Plug&amp;gt;(ale_previous_wrap)&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;C-j&amp;gt; &amp;lt;Plug&amp;gt;(ale_next_wrap)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13441" LastEditorUserId="10604" LastEditDate="2020-11-09T14:21:36.363" LastActivityDate="2020-11-09T14:21:36.363" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="13010" PostTypeId="2" ParentId="13008" CreationDate="2017-07-23T12:04:57.110" Score="6" Body="&lt;p&gt;the confusing part here is that &lt;code&gt;call&lt;/code&gt; is a command and &lt;code&gt;call()&lt;/code&gt; is a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After : you cannot simply write foo(). You have to write a (ex-) command calling foo(), like in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call foo()    or&#xA;echo foo()    or&#xA;let a=foo()   and alike.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in your example try &lt;code&gt;:echo call('ceil', [1.4])&lt;/code&gt; to see it working&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-07-23T12:04:57.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13011" PostTypeId="1" CreationDate="2017-07-23T13:29:01.083" Score="1" ViewCount="244" Body="&lt;p&gt;I use Colemak layout. In order to use hjkl I remapped several keys nearby with &lt;code&gt;noremap&lt;/code&gt;. It works fine. However, window movement commands somehow do not recognize these mappings. E.g. although I have 'noremap n j' in my vimrc when I press &lt;code&gt;&amp;lt;C-W&amp;gt; n&lt;/code&gt; it opens a new split instead of moving downwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; enters not operator pending mode but some other unknown state. Why is it the case? How can I do my mapping?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to map it like &lt;code&gt;noremap &amp;lt;C-w&amp;gt;n &amp;lt;C-w&amp;gt;j&lt;/code&gt; because of the very small timeout (I need it for other commands).&lt;/p&gt;&#xA;" OwnerUserId="13548" LastActivityDate="2017-07-23T19:43:41.147" Title="Why &lt;C-W&gt; does not enter operator pending mode?" Tags="|key-bindings|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13012" PostTypeId="2" ParentId="7889" CreationDate="2017-07-23T17:00:12.673" Score="13" Body="&lt;p&gt;To solve this nuisance with netrw permanently, I added this to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Per default, netrw leaves unmodified buffers open. This autocommand&#xA;&quot; deletes netrw's buffer once it's hidden (using ':q', for example)&#xA;autocmd FileType netrw setl bufhidden=delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://github.com/tpope/vim-vinegar/issues/13#issuecomment-47133890&quot; rel=&quot;noreferrer&quot;&gt;Tim Pope&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8558" LastActivityDate="2017-07-23T17:00:12.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13013" PostTypeId="2" ParentId="13005" CreationDate="2017-07-23T19:36:59.777" Score="3" Body="&lt;p&gt;No it is not possible. Wrapping occurs on the real characters on the line and not on the concealed characters. Note, that if this would be possible, this would cause kind of &quot;wobbling&quot; effect just by moving/scrolling the cursor, which would be most likely unwanted and it possibly would also affect performance.&#xA;There is also a &lt;a href=&quot;https://github.com/vim/vim/issues/260&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue 260&lt;/a&gt; about it that was closed as won't fix. &lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2017-07-24T19:55:46.633" LastActivityDate="2017-07-24T19:55:46.633" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13014" PostTypeId="2" ParentId="13011" CreationDate="2017-07-23T19:43:41.147" Score="4" Body="&lt;p&gt;&lt;code&gt;CTRL-W&lt;/code&gt; starts a window command, that means, Vim enters a &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/normal.c#L726-L731&quot; rel=&quot;nofollow noreferrer&quot;&gt;special mode&lt;/a&gt;, which won't timeout, awaiting another command and which does not &lt;strong&gt;allow&lt;/strong&gt; maps.&#xA;And this makes sense, since Ctrl-W is no command, after which a motion follows, so I wouldn't expect Operator Pending mode after Ctrl-W.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-23T19:43:41.147" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13015" PostTypeId="2" ParentId="7889" CreationDate="2017-07-23T19:49:37.057" Score="10" Body="&lt;p&gt;This usually happens, if there are &lt;strong&gt;two&lt;/strong&gt; or more buffers which are modified and Vim then usually toggles between them and shows the error message. So when &lt;code&gt;:q!&lt;/code&gt; would abort the &lt;strong&gt;current&lt;/strong&gt; buffer, it wouldn't not abort the other modified buffer, so therefore Vim protects you from losing changes and gives this error message. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are absolutely sure, you want to abort all modifications to &lt;strong&gt;all&lt;/strong&gt; loaded buffers, then simply use &lt;code&gt;:qa!&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-23T19:49:37.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13017" PostTypeId="1" AcceptedAnswerId="13084" CreationDate="2017-07-23T22:51:58.713" Score="5" ViewCount="4429" Body="&lt;p&gt;I'm using MacVim &lt;a href=&quot;https://github.com/macvim-dev/macvim/releases/tag/snapshot-134&quot; rel=&quot;noreferrer&quot;&gt;snapshot 134&lt;/a&gt; (on Mac OS X 10.9.5), which has support for Lua:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version | grep lua&#xA;+dialog_con_gui  +lua/dyn         +rightleft       +writebackup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've got Lua installed and can even run it as an external command from within Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!lua&#xA;Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio&#xA;&amp;gt; print(&quot;hello&quot;)&#xA;hello&#xA;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However,&lt;code&gt;has(&quot;lua&quot;)&lt;/code&gt; returns &lt;code&gt;0&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo has(&quot;lua&quot;)&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And attempting to use it through Vim's interface fails:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:lua print(&quot;hello&quot;)&#xA;E370: Could not load library liblua.5.2.dylib&#xA;Lua library cannot be loaded.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I get Vim to properly detect Lua?&lt;/strong&gt; Is this a case of extremely strict required version matching, such that 5.2 means 5.2 &lt;em&gt;period&lt;/em&gt; and 5.3.3 is not good enough?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did notice &lt;a href=&quot;https://stackoverflow.com/questions/26724859/problems-with-vim-and-lua&quot;&gt;this question over on SO&lt;/a&gt;, but that doesn't seem to help, as all the answers say to install a version of Vim with &lt;code&gt;+lua/dyn&lt;/code&gt;, which I already have.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2017-07-30T16:43:42.170" Title="How to use Lua in Vim?" Tags="|macvim|vimscript-lua|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13019" PostTypeId="2" ParentId="12990" CreationDate="2017-07-24T07:28:46.250" Score="1" Body="&lt;p&gt;Alright, thanks to @tivn, I got the solution and kind of &quot;understood&quot; the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess is that by default, there was something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight TabLine cterm=underline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight TabLine cterm=undercurl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since my terminal (cmder and hyper) did not support underlining, the way they understood it was to set the color to &lt;code&gt;Cyan&lt;/code&gt;. I tried every other possible value mentioned in the help (&lt;code&gt;:help attr-list&lt;/code&gt;), and the other result were that the text disappeared (I guess it was the same color as the background).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the solution is, as @tivn said, to add &lt;code&gt;cterm=None&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight TabLine cterm=None ctermfg=YourForeground ctermbg=YourBackground&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it works!&lt;/p&gt;&#xA;" OwnerUserId="13449" LastActivityDate="2017-07-24T07:28:46.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13020" PostTypeId="1" CreationDate="2017-07-24T07:47:24.063" Score="2" ViewCount="7892" Body="&lt;p&gt;how do I remap backspace combinations? I can remap backspace itself in normal mode, but not in insert mode, and I cannot map combinations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; this works:&#xA;nmap &amp;lt;BS&amp;gt; dd&#xA;&#xA;&quot; this doesn't work:&#xA;imap &amp;lt;BS&amp;gt; &amp;lt;Esc&amp;gt;dd&#xA;nmap &amp;lt;C-BS&amp;gt; dd&#xA;imap &amp;lt;C-BS&amp;gt; &amp;lt;Esc&amp;gt;dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim 7.4 inside Terminator.&lt;/p&gt;&#xA;" OwnerUserId="836" LastActivityDate="2021-04-11T20:01:42.190" Title="How to remap ctrl-backspace in normal and insert modes?" Tags="|key-bindings|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13021" PostTypeId="2" ParentId="13020" CreationDate="2017-07-24T07:56:30.867" Score="4" Body="&lt;p&gt;You need to first press &lt;kbd&gt;ctrl+v&lt;/kbd&gt; in insert mode before pressing &lt;kbd&gt;ctrl+backspace&lt;/kbd&gt; to insert the terminal code of &lt;kbd&gt;ctrl+backspace&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your mapping will look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap ^_ &amp;lt;Esc&amp;gt;dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL%2dV&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-V&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-V      Insert next non-digit literally.  For special keys, the&#xA;            terminal code is inserted.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;However you mapping for &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; in insert mode should work (it works fine on my setup) maybe you should try the non recursive version of the mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;BS&amp;gt; &amp;lt;Esc&amp;gt;dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-07-24T07:56:30.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13022" PostTypeId="1" CreationDate="2017-07-24T08:06:17.813" Score="1" ViewCount="63" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Qj1fY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qj1fY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't see a number of the tabs at the top, even though there's space to show them all. How can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="13555" LastActivityDate="2017-07-24T08:06:17.813" Title="How can I get my tabs to spread to the width of my window?" Tags="|tabbed-user-interface|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13023" PostTypeId="1" CreationDate="2017-07-24T11:55:16.880" Score="1" ViewCount="3000" Body="&lt;p&gt;The problem: I've used ctags with C++ code for a while, but that has no knowledge of the code. If there are many subclasses that overwrite a certain virtual function, then on a Ctrl-] I may end up in the definition of an unexpected subclass.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there better ways to do this?&#xA;I've seen recommendation for rtags and uctags, are these viable and better alternatives as of now? Why?&lt;/p&gt;&#xA;" OwnerUserId="2710" LastActivityDate="2017-07-24T18:26:38.180" Title="Alternatives to ctags: are rtags, uctags or other alternatives better?" Tags="|tags|ctags|filetype-c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13025" PostTypeId="2" ParentId="13023" CreationDate="2017-07-24T13:20:43.460" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/41652773/should-i-use-universal-ctags&quot;&gt;On SO, I've written recently about uctags&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Regarding C++, it makes the difference -- I can't tell regarding C or&#xA;  Java. It has a better understanding of C++ code bases than exuberant&#xA;  ctags.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Otherwise, it's maintained, with unit tests. If it was a fork of an&#xA;  active project, well I may not be able to sort the two. In this case,&#xA;  it's a fork of an unmaintained project. It's built upon what ex-ctags&#xA;  had to offer to offer, let's hope, more.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's likely to be even better with rtags as it's based on clang. But also, I expect it to be slower than uctags, and likely more tricky to set up correctly as all other clang based plugins are.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="1841" LastEditDate="2017-07-24T18:26:38.180" LastActivityDate="2017-07-24T18:26:38.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13027" PostTypeId="2" ParentId="13017" CreationDate="2017-07-24T20:03:25.210" Score="3" Body="&lt;p&gt;Yes, you Vim was compiled in such a way, that Vim will be looking for the dynamic library &lt;code&gt;liblua5.2.dylib&lt;/code&gt;. If Vim cannot find that library, it obviously cannot use the lua extension.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This however is independent of usine &lt;code&gt;:!lua&lt;/code&gt; which will shell out to the lua binary and run that command. For that, you do not need to compile Vim with &lt;code&gt;+lua&lt;/code&gt; you just need to have a lua binary in your path, but that obviously cannot make use of the provided VimScript API. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your system only provides a liblua5.3 library, you either have to compile Vim yourself with that library, or install additionally the liblua5.2 library &lt;strong&gt;in addition&lt;/strong&gt; to the existing system wide library.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-24T20:03:25.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13028" PostTypeId="1" AcceptedAnswerId="13038" CreationDate="2017-07-25T00:52:23.583" Score="4" ViewCount="1681" Body="&lt;p&gt;Simple question. I want to use the &lt;code&gt;Tabular&lt;/code&gt; plugin to right-align end-of-line comments for arbitrary filetypes, and for that I need to write a simple &lt;code&gt;nnoremap&lt;/code&gt; that uses the current filetype's comment character. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastActivityDate="2017-07-25T20:07:07.943" Title="How can I return the current filetype's comment character in vimscript?" Tags="|vimrc|vimscript|comments|plugin-tabular|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13029" PostTypeId="1" AcceptedAnswerId="13031" CreationDate="2017-07-25T01:53:12.593" Score="0" ViewCount="119" Body="&lt;p&gt;I am using the Vim version 8.0 editor, mostly via GVim. I would like to be able to type unicode/greek characters like lambda, mu, alpha inside my Haskell scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a vim plugin called &lt;a href=&quot;https://github.com/joom/latex-unicoder.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;latex-unicoder&lt;/a&gt; which is &lt;em&gt;almost&lt;/em&gt; what I want. The disadvantage of the plugin is that I need to repeatedly go into Normal mode, press Ctrl-L insert the latex symbol for the character and then manually go back into insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is quite tedious. Emacs has something called M-x set-input-method [RET] tex which automatically and immediately replaces the occurences of \lambda, \alpha by their corresponding Greek characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I intend to use only a handful of greek characters, I am willing to manually create such a dictionary of Greek characters for automatic insertion when their latex name is written. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I go about doing this? &lt;/p&gt;&#xA;" OwnerUserId="13566" LastActivityDate="2021-08-02T11:28:03.850" Title="Triggering automatic replacements of certain strings" Tags="|vimrc|unicode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13030" PostTypeId="2" ParentId="13028" CreationDate="2017-07-25T02:16:36.680" Score="0" Body="&lt;p&gt;Well, I figured out how to do this if you also use the &lt;code&gt;NERDCommenter&lt;/code&gt; plugin. Simply query the &lt;code&gt;'left'&lt;/code&gt; key in the dictionary variable &lt;code&gt;b:NERDCommenterDelims&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let CommentChar=b:NERDCommenterDelims['left']&#xA;echo CommentChar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;b:NERDCommenterDelims&lt;/code&gt; also has a &lt;code&gt;'right'&lt;/code&gt; key-value pair to satisfy (e.g.) comments left-delimited by &lt;code&gt;\*&lt;/code&gt; and right-delimited by &lt;code&gt;*\&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastActivityDate="2017-07-25T02:16:36.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13031" PostTypeId="2" ParentId="13029" CreationDate="2017-07-25T02:27:30.060" Score="1" Body="&lt;p&gt;you can do something like&#xA;&lt;code&gt;:iab \mu µ&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note however that this requires &lt;code&gt;:set isk+=\&lt;/code&gt; which may not always be desirable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is &lt;code&gt;:imap \mu µ&lt;/code&gt; . But this has the drawback that things starting with \ will not show up until entered completely&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-07-25T02:27:30.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13032" PostTypeId="1" CreationDate="2017-07-25T04:25:22.320" Score="3" ViewCount="216" Body="&lt;p&gt;I want to save selected text in vim. I use command &lt;code&gt;:'&amp;lt;,'&amp;gt;w! ~/save.txt&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to write a short command instead of it, or mapping it to key mappings.&lt;/p&gt;&#xA;" OwnerUserId="6600" LastActivityDate="2017-07-25T04:37:57.880" Title="how to write command to save selected text?" Tags="|visual-mode|visual-block|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13033" PostTypeId="2" ParentId="13032" CreationDate="2017-07-25T04:37:57.880" Score="2" Body="&lt;p&gt;Here you go:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vnoremap &amp;lt;Leader&amp;gt;s :w! ~/save.txt &amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just paste this into your &lt;code&gt;init.vim&lt;/code&gt;. This assumes you have the text highlighted and are currently in visual mode. Just hit &lt;code&gt;Leader&lt;/code&gt;+&lt;code&gt;s&lt;/code&gt; and it will save the selection for you.&lt;/p&gt;&#xA;" OwnerUserId="13009" LastActivityDate="2017-07-25T04:37:57.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13034" PostTypeId="1" AcceptedAnswerId="13041" CreationDate="2017-07-25T05:05:01.203" Score="1" ViewCount="11787" Body="&lt;p&gt;I'm a novice in Vim and configuring it for writing python scripts comfortably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the a way to automatically put four spaces after I jump onto the first line of &lt;code&gt;while True:&lt;/code&gt; loop ?&lt;/p&gt;&#xA;" OwnerDisplayName="user13567" LastEditorUserId="1841" LastEditDate="2017-07-25T06:55:41.990" LastActivityDate="2019-03-17T20:23:52.443" Title="Automatic whitespace in python" Tags="|indentation|filetype-python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13035" PostTypeId="2" ParentId="13028" CreationDate="2017-07-25T08:09:08.060" Score="2" Body="&lt;p&gt;Depending on the filetype, the way comments are defined can completely change. It's either :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a sequence that says &lt;em&gt;&quot;everything from now up to the end of the line is a comment&quot;&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;or a sequence that says &lt;em&gt;&quot;everything from now up to another sequence is a comment&quot;&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Vim stores the information in the options &lt;code&gt;'comments'&lt;/code&gt; and &lt;code&gt;'commentstring'&lt;/code&gt;. Most commenter plugins duplicate the information as well. See @Luke Davis' answer regarding NERDCommenter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In lh-dev, I use &lt;a href=&quot;https://github.com/LucHermitte/lh-dev/blob/master/autoload/lh/dev.vim#L414&quot; rel=&quot;nofollow noreferrer&quot;&gt;the following&lt;/a&gt; (which can be overridden if need be).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; # Comments related functions {{{2&#xA;&quot; @move to lh/dev/comments/&#xA;&quot; # lh#dev#_open_comment() {{{3&#xA;&quot; @todo cache the results until :source that clears the table&#xA;function! lh#dev#_open_comment() abort&#xA;  &quot; default asks to&#xA;  &quot; - EnhancedCommentify&#xA;  if exists('b:ECcommentOpen') &amp;amp;&amp;amp; !empty(b:ECcommentOpen) &amp;amp;&amp;amp; exists('b:ECcommentClose') &amp;amp;&amp;amp; !empty(b:ECcommentClose)&#xA;    return b:ECcommentOpen&#xA;  &quot; - tComment&#xA;  &quot; - NERDCommenter&#xA;  &quot; - &amp;amp;commentstring&#xA;  elseif !empty(&amp;amp;commentstring) &amp;amp;&amp;amp; &amp;amp;commentstring =~ '\v.+\%s.+'&#xA;    return matchstr(&amp;amp;commentstring, '\v.*\ze\%s')&#xA;  endif&#xA;  return &quot;&quot;&#xA;endfunction&#xA;&#xA;&quot; # lh#dev#_close_comment() {{{3&#xA;&quot; @todo cache the results until :source that clear the table&#xA;function! lh#dev#_close_comment() abort&#xA;  &quot; default asks to&#xA;  &quot; - EnhancedCommentify&#xA;  if exists('b:ECcommentClose') &amp;amp;&amp;amp; !empty(b:ECcommentClose)&#xA;    return b:ECcommentClose&#xA;  &quot; - tComment&#xA;  &quot; - NERDCommenter&#xA;  &quot; - &amp;amp;commentstring&#xA;  elseif !empty(&amp;amp;commentstring) &amp;amp;&amp;amp; &amp;amp;commentstring =~ '\v.+\%s.+'&#xA;    return matchstr(&amp;amp;commentstring, '\v.*\%s\zs.*')&#xA;  endif&#xA;  return &quot;&quot;&#xA;endfunction&#xA;&#xA;&quot; # lh#dev#_line_comment() {{{3&#xA;&quot; @todo cache the results until :source that clear the table&#xA;function! lh#dev#_line_comment() abort&#xA;  &quot; default asks to&#xA;  &quot; - EnhancedCommentify&#xA;  if exists('b:ECcommentOpen') &amp;amp;&amp;amp; !empty(b:ECcommentOpen) &amp;amp;&amp;amp; (!exists('b:ECcommentClose') || empty(b:ECcommentClose))&#xA;    return b:ECcommentOpen&#xA;  &quot; - tComment&#xA;  &quot; - NERDCommenter&#xA;  &quot; - &amp;amp;commentstring&#xA;  elseif !empty(&amp;amp;commentstring) &amp;amp;&amp;amp; &amp;amp;commentstring =~ '\v.+\%s$'&#xA;    return matchstr(&amp;amp;commentstring, '\v.*\ze\%s.*')&#xA;  endif&#xA;  return &quot;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;lh#dev#purge_comments()&lt;/code&gt; to see how it can be used.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-07-25T08:09:08.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13036" PostTypeId="1" AcceptedAnswerId="13037" CreationDate="2017-07-25T18:03:53.743" Score="1" ViewCount="2326" Body="&lt;p&gt;I am using Vim 8.0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often pepper my Haskell code with undefined stub functions to be filled in later. Note that undefined &lt;em&gt;is&lt;/em&gt; a valid keyword in Haskell&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;add :: Int -&amp;gt; Int -&amp;gt; Int&#xA;add a b = undefined&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'd like to do, while in Haskell mode, is to make the word&#xA;&lt;code&gt;undefined&lt;/code&gt; word look like an eye-sore to remind me that implementations are still not complete. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, I would like the background of &lt;code&gt;undefined&lt;/code&gt; to be pink and &#xA;the foreground color of the text to be, say, black&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I go about doing this? &lt;/p&gt;&#xA;" OwnerUserId="13566" LastActivityDate="2017-07-25T19:57:33.450" Title="Highlighting specific words automatically with different background" Tags="|vimrc|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13037" PostTypeId="2" ParentId="13036" CreationDate="2017-07-25T19:57:33.450" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;matchadd()&lt;/code&gt; function like this. First define your custom highlighting color:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi CustomPink ctermbg=205 guibg=hotpink guifg=black ctermfg=black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can color your words like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd('CustomPink', '\&amp;lt;undefined\&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The advantage of using the &lt;code&gt;match&lt;/code&gt; functionality is, that this does not depend on the priorities of the defined syntax definitions and is usually more flexible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, one could create a simple plugin, that defines the colors, highlightes customs words and does some error checking (as well as remembering the id for each match, so it can easily be reverted). But that is out of the scope for my answer for now :)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-25T19:57:33.450" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13038" PostTypeId="2" ParentId="13028" CreationDate="2017-07-25T20:07:07.943" Score="7" Body="&lt;p&gt;I usually go with the &lt;code&gt;'commentstring'&lt;/code&gt; option and depend on the filetype plugin to set this up correctly for me (if not, that should be added to the corresponding filetype to make at least folding work). So in that case, you can simply use: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo split(&amp;amp;commentstring, '%s')[0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which would return the beginning of a Comment. To get the end part, use index 1. &#xA;Note however, that the end part might not be defined (for e.g. something like the shell comment '#'), in which case the index 1 will cause an error E684, so a robust approach would be something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let comment=split(&amp;amp;commentstring, '%s')&#xA;if len(comment)==1&#xA;     call add(comment, '')&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-07-25T20:07:07.943" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13039" PostTypeId="1" AcceptedAnswerId="13042" CreationDate="2017-07-25T21:21:03.507" Score="1" ViewCount="382" Body="&lt;p&gt;Listed &lt;a href=&quot;https://en.wikibooks.org/wiki/Learning_the_vi_Editor/Vim/Modes&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; is &quot;each mode&quot; for vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did not see &quot;search&quot; in the list, but I should think that search (&lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;) would be a mode on its own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to make a very formal presentation about my internship, and I had some space on my poster, so I decided to put a small section regarding how important text editors are for coders since they are in them so much. Since I learned a lot, as I would look up things at home and occasionally at work regarding how to do something, I decided to put a little about vim. So, this seemingly trivial question is actually fairly important to me currently ... and I wouldn't wan to to mislead anyone :P (despite the fact that no one will care and it is, indeed, extremely trivial).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;ps I didn't notice a &quot;search-mode&quot; tag for stackexchange tags below. Does that mean that I have already guess the answer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... What do you all think? Is search a &quot;true&quot; mode?&lt;/p&gt;&#xA;" OwnerUserId="5108" LastActivityDate="2017-07-25T22:54:55.503" Title="is search a true mode in vim?" Tags="|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13040" PostTypeId="2" ParentId="13039" CreationDate="2017-07-25T21:36:11.850" Score="1" Body="&lt;p&gt;&lt;code&gt;help: search-commands&lt;/code&gt; returns the stuff I type to execute searches.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since these are all commands, I always thought of &lt;code&gt;/&lt;/code&gt;  and &lt;code&gt;?&lt;/code&gt; as commands, used in command mode.&lt;/p&gt;&#xA;" OwnerUserId="6590" LastActivityDate="2017-07-25T21:36:11.850" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13041" PostTypeId="2" ParentId="13034" CreationDate="2017-07-25T21:42:58.337" Score="8" Body="&lt;p&gt;You want to have this setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ---- Minimal configuration:&#xA;set smartindent   &quot; Do smart autoindenting when starting a new line&#xA;set shiftwidth=4  &quot; Set number of spaces per auto indentation&#xA;set expandtab     &quot; When using &amp;lt;Tab&amp;gt;, put spaces instead of a &amp;lt;tab&amp;gt; character&#xA;&#xA;&quot; ---- Good to have for consistency&#xA;&quot; set tabstop=4   &quot; Number of spaces that a &amp;lt;Tab&amp;gt; in the file counts for&#xA;&quot; set smarttab    &quot; At &amp;lt;Tab&amp;gt; at beginning line inserts spaces set in shiftwidth&#xA;&#xA;&quot; ---- Bonus for proving the setting&#xA;&quot; Displays '-' for trailing space, '&amp;gt;-' for tabs and '_' for non breakable space&#xA;set listchars=tab:&amp;gt;-,trail:-,nbsp:_&#xA;set list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Minimal configuration&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;smartindent&lt;/code&gt; is the option for automatically indenting when starting a new line. Note that a new line after a line starting with a keyword from &lt;code&gt;cinwords&lt;/code&gt; is automatically indented. That means, whatever the file type is, a new indentation is done after lines starting by &lt;code&gt;while&lt;/code&gt;,&lt;code&gt;for&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;shiftwidth&lt;/code&gt; sets the number of &quot;spaces&quot; when doing a smart indentation. Note that it will add as much tab characters as possible then the number of spaces needed (so if you set tab as eight space long and &lt;code&gt;shiftwidth&lt;/code&gt; to 12, it will put one tab character and four spaces). In your case you want to set it to 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;expandtab&lt;/code&gt; is the option for putting space instead of tab characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h smartindent&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h cinwords&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h shiftwidth&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h expandtab&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Good to have for consistency&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;tabstop&lt;/code&gt; sets the number of &quot;spaces&quot; a tab corresponds. By default it is set to 8 (GNU convention). You want to consider a tab as 4 spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;smarttab&lt;/code&gt; corresponds to the behaviour when you insert a tab in a empty line. If it is set on: it will insert blanks according to &lt;code&gt;shiftwidth&lt;/code&gt;, when off: according to &lt;code&gt;tabstop&lt;/code&gt; or &lt;code&gt;softtabstop&lt;/code&gt;. You want it to be set on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h tabstop&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h softtabstop&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h smarttab&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;listchars&lt;/code&gt; defines the display for different type of characters. In our case: tab are displayed &lt;code&gt;&amp;gt;-&lt;/code&gt; (&lt;code&gt;-&lt;/code&gt; is repeated for filling the size the tab takes), trailing characters are displayed &lt;code&gt;-&lt;/code&gt; and non-breakable space are displayed as &lt;code&gt;_&lt;/code&gt;. With this settings, you can see the difference between tabs and spaces. &lt;code&gt;list&lt;/code&gt; is set to activate the option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h listchars&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h 'list'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Further reading&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Converting_tabs_to_spaces&quot; rel=&quot;noreferrer&quot;&gt;Converting tabs to spaces (Vimwiki)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/episodes/tabs-and-spaces/&quot; rel=&quot;noreferrer&quot;&gt;Tabs and Spaces (Vimcasts)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13576" LastActivityDate="2017-07-25T21:42:58.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13042" PostTypeId="2" ParentId="13039" CreationDate="2017-07-25T21:51:21.510" Score="4" Body="&lt;p&gt;These few commands that are only available while searching via &lt;code&gt;/&lt;/code&gt; / &lt;code&gt;?&lt;/code&gt; with &lt;code&gt;'incsearch'&lt;/code&gt;: &lt;code&gt;&amp;lt;c-l&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;c-g&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;c-t&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure 3 commands constitute a mode, but maybe it does. If we look at the documentation it is listed as a command mode mapping and there is no special &lt;code&gt;map&lt;/code&gt; variant to make more such mappings, e.g. &lt;code&gt;nmap&lt;/code&gt; for normal or &lt;code&gt;xmap&lt;/code&gt; for visual. So it maybe more of a battle of semantics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: there maybe more search only mappings/commands, but I can not think of any.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the following for more help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h /_CTRL-L&#xA;:h /_CTRL-G&#xA;:h /_CTRL-T&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-07-25T22:54:55.503" LastActivityDate="2017-07-25T22:54:55.503" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13043" PostTypeId="1" AcceptedAnswerId="13075" CreationDate="2017-07-25T22:18:14.557" Score="1" ViewCount="173" Body="&lt;p&gt;I am trying to capture the result returned from a function implementing &lt;code&gt;range&lt;/code&gt; as an argument but apparently I get a comparison.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetNumber() range&#xA;  return 4&#xA;endfunction&#xA;&#xA;function! GetString() range&#xA;  return &quot;&quot;&#xA;endfunction&#xA;&#xA;function! GetList() range&#xA;  echo a:firstline&#xA;  echo a:lastline&#xA;  return []&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After having selected some lines, I do the following operations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;echo '&amp;lt;,'&amp;gt;GetNumber()&lt;/code&gt; or &lt;code&gt;let a = &amp;lt;,'&amp;gt;GetNumber()&lt;/code&gt;: returns 0&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;echo '&amp;lt;,'&amp;gt;GetList()&lt;/code&gt; or &lt;code&gt;let a = &amp;lt;,'&amp;gt;GetString()&lt;/code&gt;: returns 1&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;echo '&amp;lt;,'&amp;gt;GetList()&lt;/code&gt; or &lt;code&gt;let a = &amp;lt;,'&amp;gt;GetList()&lt;/code&gt;:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Error E691: Can only compare List with List&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;E15: Invalid expression: '&amp;lt;,'&amp;gt;GetList()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Yet, I can access to the variables &lt;code&gt;a:firstline&lt;/code&gt; and &lt;code&gt;a:lastline&lt;/code&gt; in the functions. I would like to know where could be my error and also where comes this comparison?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the same thing on Vim 7.4 and Vim 8.&lt;/p&gt;&#xA;" OwnerUserId="13576" LastActivityDate="2017-07-28T23:00:47.627" Title="Using range as argument returns a comparison" Tags="|vimscript|functions|range|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13044" PostTypeId="1" AcceptedAnswerId="13054" CreationDate="2017-07-26T03:31:55.313" Score="0" ViewCount="680" Body="&lt;p&gt;I'm in a Ruby file, and because &lt;code&gt;!&lt;/code&gt; is not an &lt;code&gt;iskeyword&lt;/code&gt; character, if I place the cursor on a call to &lt;code&gt;mymethod!&lt;/code&gt; and attempt a tag lookup via &lt;kbd&gt;C - ]&lt;/kbd&gt;, Vim searches for &lt;code&gt;mymethod&lt;/code&gt; (without the &lt;code&gt;!&lt;/code&gt;). Adding &lt;code&gt;!&lt;/code&gt; to the &lt;code&gt;iskeyword&lt;/code&gt; option causes other problems, which I won't go into here.&lt;/p&gt;&#xA;&lt;p&gt;Given the above behavior, I expected hitting &lt;kbd&gt;C - R&lt;/kbd&gt;&lt;kbd&gt;C - W&lt;/kbd&gt; from command-line mode would insert &lt;code&gt;mymethod&lt;/code&gt; on the command-line, but it actually inserts &lt;code&gt;mymethod!&lt;/code&gt; (including the &lt;code&gt;!&lt;/code&gt;). Running &lt;code&gt;expand('&amp;lt;cword&amp;gt;')&lt;/code&gt;, on the other hand, results in &lt;code&gt;mymethod&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What's going on here? The documentation describes &lt;kbd&gt;C - R&lt;/kbd&gt;&lt;kbd&gt;C - W&lt;/kbd&gt;, saying:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Insert the object under the cursor:&lt;br /&gt;&#xA;...&lt;/p&gt;&#xA;&lt;p&gt;CTRL-W    the Word under the cursor&lt;br /&gt;&#xA;CTRL-A    the WORD under the cursor; see WORD&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;and &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;    is replaced with the word under the cursor (like star)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is actually helpful in my case, as it means I can get tag lookups working correctly by putting the following in my &lt;code&gt;.vim/ftplugin/ruby.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt; &amp;lt;C-]&amp;gt; :tag &amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I'm curious where the nuanced behavior comes from and whether it's intentional, or whether it's likely to be fixed at some point, breaking my solution.&lt;/p&gt;&#xA;" OwnerUserId="1855" LastEditorUserId="-1" LastEditorDisplayName="user13463" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-07-26T22:32:46.247" Title="Inconsistent &lt;cword&gt;, &lt;C-R&gt;&lt;C-W&gt;, and keyword behavior" Tags="|filetype-ruby|vi-words|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13045" PostTypeId="2" ParentId="5243" CreationDate="2017-07-26T05:11:17.080" Score="1" Body="&lt;pre&gt;&lt;code&gt;&amp;lt;n&amp;gt;macro &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is commonly used in vim to repeat the macro &quot;n&quot; times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so in order to delete till 1st occurrence of x, you would use &#xA;&lt;code&gt;1dfx&lt;/code&gt;.&#xA;Similarly, to delete till the 3rd occurrence of x, you would use &lt;code&gt;3dfx&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9381" LastActivityDate="2017-07-26T05:11:17.080" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13046" PostTypeId="1" AcceptedAnswerId="13047" CreationDate="2017-07-26T06:50:14.380" Score="2" ViewCount="454" Body="&lt;p&gt;I have between 10-15 files that I edit on a regular basis. I've currently set it up, so I can open them up in a split, by for instance typing: &lt;code&gt;LEADER + e + v&lt;/code&gt; or &lt;code&gt;LEADER + e + g&lt;/code&gt; (here are my Vimrc-commands for this):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;ev :vsplit $MYVIMRC&amp;lt;cr&amp;gt;   &quot; For my Vimrc-file&#xA;:nnoremap &amp;lt;leader&amp;gt;eg :vsplit /path/to/file/foobar.txt&amp;lt;cr&amp;gt;   &quot; Random notes&#xA;:nnoremap &amp;lt;leader&amp;gt;et :vsplit /path/to/file/AnotherFile.txt&amp;lt;cr&amp;gt;    &quot; Other stuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The list of files I edit on a regular basis are growing still, - and I use the feature a lot. I was wondering how difficult it would be to make plugin, - where I get a list of files (in a NERDtree-like-view) - where I can pick the file I want to open in a split. I imagined that the list of files would be maintained manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The files that I want on this list are in all different kind of folders, so I imagined that the list of files would look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/User/myusername/path/one/random_notes.txt    &#xA;/User/myusername/path/two/which/is/different/project_notes.txt &#xA;/User/myusername/path/three/folder/after_work_stuff.txt  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is that something that can be achieved without using Vimscript - or which is the best way to make this? Or is it better to make in bash, somehow? &lt;/p&gt;&#xA;" OwnerUserId="9194" LastActivityDate="2017-07-26T11:19:44.580" Title="Get a NERDtree'ish list of commonly edited files" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13047" PostTypeId="2" ParentId="13046" CreationDate="2017-07-26T07:25:31.340" Score="1" Body="&lt;p&gt;I used &lt;a href=&quot;http://vim.spf13.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SPF 13&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is more on opening up those files you have been editing, then here's two approaches:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;In vim, - use the built-in &lt;code&gt;:browse oldfiles&lt;/code&gt;-command. Then press &lt;kbd&gt;q&lt;/kbd&gt;, whereafter you can type a number (listed on the left), followed by &lt;kbd&gt;ENTER&lt;/kbd&gt; (to open the file).&lt;/li&gt;&#xA;&lt;li&gt;Use this &lt;a href=&quot;https://github.com/xolox/vim-session&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-session plugin&lt;/a&gt; which is already included in SPF13, then :SaveSession for all the files you are editing, then :OpenSession to edit the files when you are back again. The good part of the Vim-session-plugin is it will keep the documents last save state.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Hope this helps!&lt;/p&gt;&#xA;" OwnerUserId="6938" LastEditorUserId="1841" LastEditDate="2017-07-26T11:19:44.580" LastActivityDate="2017-07-26T11:19:44.580" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13050" PostTypeId="1" AcceptedAnswerId="13063" CreationDate="2017-07-26T16:38:50.660" Score="8" ViewCount="542" Body="&lt;p&gt;How can I quickly shift only inner contents of HTML tag X, when they are on separate lines to the opening and closing X tag? Example below: I want to shift &lt;strong&gt;only&lt;/strong&gt; 2 lines with &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tags when the cursor is somewhere on &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;/div&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;  &amp;lt;p&amp;gt;This is some paragraph.&amp;lt;/p&amp;gt;&#xA;  &amp;lt;p&amp;gt;And this is other paragraph.&amp;lt;/p&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the cursor is somewhere on &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; I try to do &lt;code&gt;&amp;gt;it&lt;/code&gt;, but the problem is &lt;code&gt;it&lt;/code&gt; is written in a way which select also newline character after &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; and whitespace before &lt;code&gt;&amp;lt;/div&amp;gt;&lt;/code&gt;, and so the start and ending tags are also shifted (ending tag might be left unshifted if it's on the very beginning of line), which is unwanted by me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I usually do is select everything between &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;s by &lt;code&gt;vit&lt;/code&gt; then go one line up on the end of the selection by &lt;code&gt;k&lt;/code&gt;, switch to the other end by &lt;code&gt;o&lt;/code&gt; and go one line down on the start of the selection by &lt;code&gt;j&lt;/code&gt;, only then shift by &lt;code&gt;&amp;gt;&lt;/code&gt;. The whole sequence is &lt;code&gt;vitkoj&amp;gt;&lt;/code&gt;. Could you do it somehow faster (and more naturally)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm mostly interested in answers using pure Vim functionality without plugins, but HTML plugins recommendations are also welcome. &lt;/p&gt;&#xA;" OwnerUserId="11038" LastEditorUserId="11038" LastEditDate="2017-07-27T08:36:52.237" LastActivityDate="2017-07-27T19:51:16.097" Title="How can I shift only inner contents of HTML element?" Tags="|indentation|filetype-html|object-motions|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13051" PostTypeId="1" AcceptedAnswerId="13052" CreationDate="2017-07-26T17:45:28.230" Score="2" ViewCount="591" Body="&lt;p&gt;I often have code that looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = 1 # description 1&#xA;longer_name = 2 # description 2&#xA;# no_longer_needed = 3 # ignore&#xA;another_name = 4 # description 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and would like to &lt;strong&gt;right-align&lt;/strong&gt; the right-hand annotations, &lt;strong&gt;including&lt;/strong&gt; the annotations of &quot;commented-out&quot; lines, so that it looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = 1                  # description 1&#xA;longer_name = 2        # description 2&#xA;# no_longer_needed = 3 # ignore&#xA;another_name = 4       # description 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do so with the &lt;code&gt;Tabular&lt;/code&gt; plugin? &lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2017-07-26T17:54:52.627" LastActivityDate="2019-02-26T22:39:13.127" Title="How can I right-align end-of-line comments with the Tabular plugin?" Tags="|vimrc|plugin-system|alignment|plugin-tabular|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13052" PostTypeId="2" ParentId="13051" CreationDate="2017-07-26T17:59:56.447" Score="3" Body="&lt;p&gt;Just figured this out and wanted to share with people. You can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Tabularize /^\s*\S.*\zs#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the &lt;code&gt;^\s*\S.*\zs#&lt;/code&gt; is a vim regexp that matches only the &lt;strong&gt;last&lt;/strong&gt; comment character, while ignoring matches that occur as the first non-whitespace character in each line e.g. &quot;commented out&quot; lines (try searching/highlighting it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to put a handy remap in your &lt;code&gt;.vimrc&lt;/code&gt;, for example to &lt;code&gt;&amp;lt;Leader&amp;gt;.&lt;/code&gt;, just use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;. ':Tabularize /^\s*\S.*\zs' . split(&amp;amp;commentstring, '%s')[0] . &quot;&amp;lt;CR&amp;gt;&quot;&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;. ':Tabularize /^\s*\S.*\zs' . split(&amp;amp;commentstring, '%s')[0] . &quot;&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the above aligns by the &quot;start-of-comment&quot; character for an arbitrary filetype.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2019-02-26T22:39:13.127" LastActivityDate="2019-02-26T22:39:13.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13053" PostTypeId="1" AcceptedAnswerId="13070" CreationDate="2017-07-26T19:40:43.227" Score="0" ViewCount="145" Body="&lt;p&gt;In vim you can open all files in present directory with &lt;code&gt;vim *&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of a specific file type in directory with &lt;code&gt;vim *.py&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recursively we use &lt;code&gt;vim **/*&lt;/code&gt; and &lt;code&gt;vim **/*.py&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To open all files in tabs &lt;code&gt;vim -p *&lt;/code&gt;. Recursively &lt;code&gt;vim -p **/*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to open specific file types in specific tabs recursively? Lets say all &lt;code&gt;.py&lt;/code&gt; in tab 1, all &lt;code&gt;.js&lt;/code&gt; files in tab 2, all &lt;code&gt;.html&lt;/code&gt; files in tab3?&lt;/p&gt;&#xA;" OwnerUserId="10879" LastActivityDate="2017-07-28T15:59:39.733" Title="Open One File-type per Tab" Tags="|filetype|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13054" PostTypeId="2" ParentId="13044" CreationDate="2017-07-26T22:32:46.247" Score="1" Body="&lt;p&gt;It is probably the result of the mappings in &lt;code&gt;$VIMRUNTIME/ftplugin/ruby.vim&lt;/code&gt;, which include a mapping of &lt;code&gt;&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;Plug&amp;gt;&amp;lt;cword&amp;gt;&lt;/code&gt; which is then mapped to a call to &lt;code&gt;RubyCursorIdentifier()&lt;/code&gt;. That function contains expressions more complicated than I wished to follow, but it probably sees the &lt;code&gt;!&lt;/code&gt; as belonging to the identifier &lt;code&gt;mymethod&lt;/code&gt; and adds it to the result of &lt;code&gt;&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-07-26T22:32:46.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13055" PostTypeId="1" AcceptedAnswerId="13056" CreationDate="2017-07-27T09:58:26.030" Score="1" ViewCount="1048" Body="&lt;p&gt;I need to replace on all lines sequence of words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public boolean&#xA;public string&#xA;public IList&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with modifier removed aka:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean&#xA;string&#xA;IList&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way how to remove first part of match and keep the other? I know there is something called submatch in vim, but I don't know if it can be used for this case.&#xA;Of course I could simply do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/public //g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but in my case I need to keep public interface and public class.&lt;/p&gt;&#xA;" OwnerUserId="10529" LastActivityDate="2017-07-31T07:30:09.440" Title="Replace two word sequence with second word" Tags="|search|regular-expression|replace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13056" PostTypeId="2" ParentId="13055" CreationDate="2017-07-27T11:08:01.843" Score="4" Body="&lt;p&gt;First, we must know the pattern of the modifiers that you want to remove. It could be something as simple as &lt;code&gt;boolean\|string\|IList&lt;/code&gt; if these are the only keywords, or you could write a more complex expression. For intsance, to match any keyword that is not in a given list, one could use &lt;code&gt;\(\(class\|interface\)\&amp;gt;\)\@!\(\w\+\)&lt;/code&gt;. The first part specifies the list of words that should &lt;em&gt;not&lt;/em&gt; be matched. It uses &lt;code&gt;\@!&lt;/code&gt; to say that the expression should match as long as the preceding part does not match. The final part matches any word. Combined, this would match any word that is not &lt;code&gt;class&lt;/code&gt; or &lt;code&gt;interface&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several ways of solving the initial problem. Here are two regular expression substitutions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/public \(boolean\|string\|IList\)/\1&#xA;:%s/public \ze\(boolean\|string\|IList\)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that we don't need the final &lt;code&gt;/&lt;/code&gt;, since we don't need to provide any flags here. The first expression uses a sub-expression with the &lt;code&gt;\(...\)&lt;/code&gt; syntax and substitutes the matching text with the content of the matched sub-expression. The second expression uses &lt;code&gt;\ze&lt;/code&gt; to set the end of the match. This means that the following part must match, but it won't be counted as part of the matched text. Thus only the &lt;code&gt;public&lt;/code&gt; part is matched and removed by the substitute command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use a global command, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/public \(boolean\|string\|IList\)/ norm! 0dw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will perform the normal mode &quot;command&quot; &lt;code&gt;0dw&lt;/code&gt; (move to first column then delete the following word) on all lines that match the regular expression. I think the current task is best solved by a substitute command, but the global command can be useful in similar, but more complex, tasks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recommended reading:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#pattern.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h pattern.txt&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h \zs&lt;/code&gt; and &lt;code&gt;:h \ze&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h \(&lt;/code&gt; and &lt;code&gt;:h \1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h \@!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h \&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html#:global&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :global&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/various.html#:normal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :normal&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2017-07-31T07:30:09.440" LastActivityDate="2017-07-31T07:30:09.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13059" PostTypeId="2" ParentId="13050" CreationDate="2017-07-27T13:27:40.007" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Could you do it somehow faster (and more naturally)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In Vim you can do everything faster and more natural by adding mappings, macros, and abbreviations. Here is a mapping that you could use to select lines inside a tag from the first inner tag to the last. And if there are no inner tags, that will select the lines of a tag itself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;it vito/&amp;lt;&amp;lt;CR&amp;gt;o?&amp;gt;&amp;lt;CR&amp;gt;V&#xA;&#xA;    Explanation:&#xA;    vit                  -- Visual mode, select inner block of a tag&#xA;       o/&amp;lt;&amp;lt;CR&amp;gt;           -- Limit selection till before the first inner tag&#xA;              o?&amp;gt;&amp;lt;CR&amp;gt;    -- Limit selection till after the last inner tag&#xA;                     V   -- Make selection linewise&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JIDNu.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JIDNu.gif&quot; alt=&quot;mapping_demo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need the &lt;kbd&gt;o&lt;/kbd&gt;&lt;kbd&gt;?&lt;/kbd&gt;&lt;kbd&gt;&gt;&lt;/kbd&gt;&lt;kbd&gt;&amp;lt;CR&amp;gt;&lt;/kbd&gt; because if there are characters on the line before the closing tag, the selection will grab that line as well. Replace &lt;kbd&gt;V&lt;/kbd&gt; with &lt;kbd&gt;&amp;gt;&lt;/kbd&gt; if you just want to indent it and don't need the selection by itself. Hope that helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, assuming that everything from opening to matching enclosing tag is properly indented, you could do &lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt; or &lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;. However if indentation is messed up, that will &lt;em&gt;fix&lt;/em&gt; it instead:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Iz3FM.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Iz3FM.gif&quot; alt=&quot;equals_it_demo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user13463" LastEditorDisplayName="user13463" LastEditDate="2017-07-27T14:23:25.770" LastActivityDate="2017-07-27T14:23:25.770" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13061" PostTypeId="1" CreationDate="2017-07-27T15:53:28.773" Score="3" ViewCount="511" Body="&lt;p&gt;I know that I can repeat last change with &lt;code&gt;.&lt;/code&gt;, last command with &lt;code&gt;@:&lt;/code&gt; and last motion with repmo plugin. What about other actions such as switching to the previous/next tab (&lt;code&gt;gT&lt;/code&gt;/&lt;code&gt;gt&lt;/code&gt;)? Is there a command for that?&lt;/p&gt;&#xA;" OwnerUserId="836" LastActivityDate="2017-07-27T15:53:28.773" Title="How to repeat last mapping/action?" Tags="|repeated-commands|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13062" PostTypeId="1" AcceptedAnswerId="13069" CreationDate="2017-07-27T19:24:09.723" Score="10" ViewCount="2394" Body="&lt;p&gt;I'm trying to establish syntax coloring for a certain lexical syntax: a &quot;buffer literal&quot;. A buffer literal begins with &lt;code&gt;#b'&lt;/code&gt; and ends with &lt;code&gt;'&lt;/code&gt;.  Between the single quotes, there can be undivided pairs of hex digits, with optional whitespace in between, that being spaces, tabs and newlines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Valid buffer literals:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#b'' #b'FF' #b'Fe' #b'dead be&#xA;                      ef'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Invalid:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#b'z' #b'FFF'  #b'9 0'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is what I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match buferr &quot;.&quot; contained&#xA;syn match bufok &quot;[0-9A-Fa-f][0-9A-Fa-f]\|[\t\n ]&quot; contained&#xA;&#xA;syn region buflit start=&quot;#b'&quot;rs=e+1 end=&quot;'&quot;re=s-1 contains=bufok,buferr&#xA;&#xA;hi def link buferr Error&#xA;hi def link bufok String&#xA;hi def link buflit String&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that the &lt;code&gt;bufok&lt;/code&gt; and &lt;code&gt;buferr&lt;/code&gt; match items are being applied to the region delimiters. And thus the &lt;code&gt;#b'&lt;/code&gt; start and &lt;code&gt;'&lt;/code&gt; end are matching &lt;code&gt;buferr&lt;/code&gt; and being highlighted as &lt;code&gt;Error&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to compensate for this using the &lt;code&gt;rs&lt;/code&gt; (region start) and &lt;code&gt;re&lt;/code&gt; (region end) offset options on the &lt;code&gt;region&lt;/code&gt; patterns, seen above, but it has no effect. The matches are not contained to occur between the indicated region start and end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can we tell Vim that we want this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#b'....'&#xA;   rrrr  &amp;lt;- this is the region, in which bufok and buferr are contained!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It really looks like &lt;code&gt;rs&lt;/code&gt; and &lt;code&gt;re&lt;/code&gt; offsets should be doing this, since the documentation says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;The pattern can be followed by a character offset.  This can be used to&#xA;  change the highlighted part, and to &lt;strong&gt;change the text area included in the&#xA;  match or region&lt;/strong&gt; (which &lt;strong&gt;only matters when trying to match other items&lt;/strong&gt;).&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On the contrary, my above fiddling with &lt;code&gt;rs&lt;/code&gt; and &lt;code&gt;re&lt;/code&gt; doesn't seem to be having an effect on the matching of contained items.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm working with Vim as old as 7.3.429.&lt;/p&gt;&#xA;" OwnerUserId="13611" LastEditorUserId="13611" LastEditDate="2017-07-28T03:18:10.217" LastActivityDate="2017-07-28T21:16:03.883" Title="Exclude start and end match from region" Tags="|syntax-highlighting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13063" PostTypeId="2" ParentId="13050" CreationDate="2017-07-27T19:51:16.097" Score="4" Body="&lt;p&gt;That's a great opportunity to leverage text objects (see &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#text%2dobjects&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help text-objects&lt;/code&gt;&lt;/a&gt;). The following code extends the normal behavior of the &lt;code&gt;it&lt;/code&gt; text object (see &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#it&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help it&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#tag%2dblocks&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help tag-blocks&lt;/code&gt;&lt;/a&gt;) to make it consider multi-line HTML tags content as described in your post. In that way, you could also type in &lt;code&gt;vit&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;gt;it&lt;/code&gt;, &lt;code&gt;dit&lt;/code&gt;, &lt;code&gt;cit&lt;/code&gt;, &lt;code&gt;yit&lt;/code&gt; and so on, with the extended behavior in place. You can put this code at the end of the &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; 0: Strict, consider non-blank characters before and after the tags.&#xA;&quot; 1: Flexible, ignore non-blank characters before and after the tags.&#xA;let g:innerMultilineHTMLTagMode = 0&#xA;&#xA;function! InnerMultilineHTMLTag()&#xA;   &quot; Get the position of the first line of the last selected Visual area.&#xA;   let openingMark =  getpos(&quot;'&amp;lt;&quot;)&#xA;&#xA;   &quot; Get the position of the last line of the last selected Visual area.&#xA;   let closingMark = getpos(&quot;'&amp;gt;&quot;)&#xA;&#xA;   &quot; Check whether both marks are on the same line.&#xA;   if openingMark[1] != closingMark[1] &#xA;&#xA;      &quot; Get the lines where the marks are on.&#xA;      let openingLine = getline(openingMark[1])&#xA;      let closingLine = getline(closingMark[1])&#xA;&#xA;      &quot; Check whether there's nothing appended to the opening tag.&#xA;      if g:innerMultilineHTMLTagMode == 1  ||&#xA;         \ match( openingLine, '\S',  openingMark[2] - 1) == -1 &#xA;&#xA;         &quot; Check whether the closing tag is at the beginning of the line.&#xA;         if match( closingLine, &quot;$&quot; ) + 1  ==  closingMark[2]&#xA;            &quot; Restore and adjust the last Visual area.&#xA;            normal! gvVojo&#xA;            return&#xA;&#xA;         &quot; Check whether there's nothing prepended to the closing tag.&#xA;         elseif g:innerMultilineHTMLTagMode == 1  || &#xA;            \   match( closingLine, '\S\%&amp;lt;' . closingMark[2] . &quot;c&quot; ) == -1&#xA;            &quot; Restore and adjust the last Visual area.&#xA;            normal! gvVkojo&#xA;            return&#xA;         endif&#xA;      endif &#xA;   endif&#xA;&#xA;   &quot; Do nothing. Restore the last Visual area.&#xA;   normal! gv&#xA;endfunction&#xA;&#xA;function! ToggleInnerMultilineHTMLTagMode()&#xA;   if g:innerMultilineHTMLTagMode == 0 &#xA;      let g:innerMultilineHTMLTagMode = 1 &#xA;      echo &quot;it text object is now flexible&quot;&#xA;   else&#xA;      let g:innerMultilineHTMLTagMode = 0 &#xA;      echo &quot;it text object is now strict&quot;&#xA;   endif&#xA;endfunction&#xA;&#xA;&quot; Map to set the multi-line HTML tag mode.&#xA;nnoremap - :call ToggleInnerMultilineHTMLTagMode()&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Map to extend the behavior of the 'it' text object to create linewise&#xA;&quot; visual areas within multi-line HTML tags.&#xA;&quot; See https://vi.stackexchange.com/q/13050/6698&#xA;vnoremap it it:&amp;lt;C-U&amp;gt;call InnerMultilineHTMLTag()&amp;lt;CR&amp;gt;&#xA;omap it :normal vit&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are two modes that can be toggled by hitting &lt;kbd&gt;-&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Strict mode&lt;/strong&gt;: (default) Consider the text before and after the targeted tags. If there are non-blank characters after the opening tag or before the closing tag, the &lt;code&gt;it&lt;/code&gt; text object will fall back on the normal behavior. Otherwise It'll make the visual area linewise and only select the content within the tags, ignoring blanks both after the opening tag and before the closing tag.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Flexible mode&lt;/strong&gt;: Ignore the text before and after the targeted tags.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The flexible mode is useful when the code has the following form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;one&quot; &amp;gt; &amp;lt;div class=&quot;two&quot; &amp;gt;&#xA;  &amp;lt;p&amp;gt;This is some paragraph.&amp;lt;/p&amp;gt;&#xA;  &amp;lt;p&amp;gt;And this is other paragraph.&amp;lt;/p&amp;gt;&#xA;&amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and some action is targeted to the indented lines regardless of whether the cursor is on either &lt;code&gt;&amp;lt;div class=&quot;one&quot; &amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;div class=&quot;two&quot; &amp;gt;&lt;/code&gt; tag.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Bonus&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It's also useful to create a text object to allow indented text blocks to be treated as text objects. For example, if the cursor is on the word &lt;code&gt;some&lt;/code&gt; in the first &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag of the example given by Robert, you could use a custom &lt;code&gt;ai&lt;/code&gt; text object, which stands for “an indent”,  to select the line where the cursor is on as well as the next one (both with the same indentation level) and re-indent them with &lt;code&gt;&amp;gt;ai&lt;/code&gt;. Read &lt;a href=&quot;http://vim.wikia.com/wiki/Indent_text_object&quot; rel=&quot;nofollow noreferrer&quot;&gt;Indent text object&lt;/a&gt; at &lt;a href=&quot;http://vim.wikia.com/wiki/Vim_Tips_Wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Tips Wiki&lt;/a&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Reference&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#text%2dobjects&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help text-objects&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#tag%2dblocks&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help tag-blocks&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#it&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help it&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%27%3c&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help '&amp;lt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%27%3e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help '&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getpos%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help getpos()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help getline()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#match%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help match()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5cS&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\S&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5c%25%3cc&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\%&amp;lt;c&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3amap%2dmodes&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :map-modes&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6698" LastActivityDate="2017-07-27T19:51:16.097" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13064" PostTypeId="2" ParentId="5243" CreationDate="2017-07-27T23:35:42.287" Score="1" Body="&lt;p&gt;Given:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yada yada yada$&#xA;yada yada yada x$&#xA;yada yada yada x$&#xA;yada yada yada x$&#xA;xx$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the &lt;code&gt;$&lt;/code&gt; indicate ends of lines (&lt;code&gt;:set list&lt;/code&gt; mode), if the cursor is at the start of second &lt;code&gt;yada&lt;/code&gt; in the first line, first we have to back up to the preceding space using &lt;kbd&gt;h&lt;/kbd&gt;, to include it in the deletion. Then just &lt;kbd&gt;4&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;. In other words, just a count in front of &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;. The result is exactly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yada$&#xA;xx$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13611" LastActivityDate="2017-07-27T23:35:42.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13065" PostTypeId="1" AcceptedAnswerId="13067" CreationDate="2017-07-28T05:50:45.427" Score="5" ViewCount="799" Body="&lt;p&gt;I have a file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Heading A&#xA;&#xA;### Heading B1&#xA;&#xA;lorem ipsum&#xA;&#xA;### Heading B2 &#xA;&#xA;lorem ipsum&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to reduce the header levels of B1 and B2 to look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Heading A&#xA;&#xA;## Heading B1&#xA;&#xA;lorem ipsum&#xA;&#xA;## Heading B2 &#xA;&#xA;lorem ipsum&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know how to increase markdown header levels from this &lt;a href=&quot;https://stackoverflow.com/a/22150165&quot;&gt;answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know &lt;a href=&quot;https://github.com/plasticboy/vim-markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;this plugin&lt;/a&gt; can increase and decrease header levels but it's only for the original markdown flavor. I want to avoid plugins because I want to be able to do this for pandoc (and potentially other markdown flavors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched Google but couldn't find anything helpful (for my level of knowledge).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I &lt;em&gt;decrease&lt;/em&gt; the markdown header level in visual mode without a plugin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update December 10, 2019.&lt;/strong&gt; Thanks for the answers! I've been using this custom command for a while in my init.vim (using Neovim now) and it seems to work well. Sorry, I can't remember clearly where I got this from. I think I combined &lt;a href=&quot;https://vi.stackexchange.com/a/13067/13618&quot;&gt;apparat's answer&lt;/a&gt; with plasticboy's &lt;a href=&quot;https://github.com/plasticboy/vim-markdown/blob/master/ftplugin/markdown.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;HeaderDecrease function&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range HeaderIncrease &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;s/^#/##&#xA;command! -range HeaderDecrease &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;s/^##/#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13618" LastEditorUserId="13618" LastEditDate="2019-12-10T01:04:01.713" LastActivityDate="2019-12-10T01:04:01.713" Title="How to decrease markdown header level in visual mode without a plugin?" Tags="|visual-mode|filetype-markdown|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13066" PostTypeId="2" ParentId="13055" CreationDate="2017-07-28T06:38:45.537" Score="1" Body="&lt;p&gt;If the list of words, where you want to keep &quot;public &lt;em&gt;word&lt;/em&gt;&quot;, is short, you can use something like &lt;code&gt;%s/public \%(\&amp;lt;\%(class\|interface\)\&amp;gt;\)\@!\(\&amp;lt;\i\+\&amp;gt;\)/\1/g&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means &quot;Replace every occurrence of 'public' followed by something that is not the word 'class' or 'interface' but some other word consisting only of letters allowed in identifiers by this word&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The special pairs of parentheses &lt;code&gt;\%(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; are only used for grouping so that &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; make sure that &lt;code&gt;class&lt;/code&gt; and &lt;code&gt;interface&lt;/code&gt; are treated as word, and so that &lt;code&gt;\@!&lt;/code&gt; can refer to more than the single letter just before it. The &quot;normal&quot; parentheses &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; also store the matched text so you can refer to that text with &lt;code&gt;\1&lt;/code&gt;, &lt;code&gt;\2&lt;/code&gt;, ... &lt;code&gt;\9&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastActivityDate="2017-07-28T06:38:45.537" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13067" PostTypeId="2" ParentId="13065" CreationDate="2017-07-28T08:41:40.953" Score="3" Body="&lt;p&gt;You could simply search for two #s at the beginning of the line an replace it with one #.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normal mode global replace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^##/#/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and for visual mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;s/^##/#/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5331" LastEditorUserId="5331" LastEditDate="2017-07-28T14:59:16.737" LastActivityDate="2017-07-28T14:59:16.737" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13068" PostTypeId="2" ParentId="678" CreationDate="2017-07-28T11:55:04.727" Score="14" Body="&lt;p&gt;Another way with a vanilla Vim (without extra conf or plugins). in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!mkdir -p /folder/you/want/&#xA;:w  #save file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim /folder/you/want/myfile.conf&#xA;$ ctrl+z # switch to the terminal then create the folders&#xA;$ mkdir -p /folder/you/want/&#xA;$ fg # return to Vim&#xA;$ :w  #save file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1046" LastActivityDate="2017-07-28T11:55:04.727" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13069" PostTypeId="2" ParentId="13062" CreationDate="2017-07-28T13:16:07.627" Score="6" Body="&lt;p&gt;There are a couple of nuances that need to be grasped in order to make it work:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The &lt;code&gt;&quot;.&quot;&lt;/code&gt; in &lt;code&gt;buferr&lt;/code&gt; matches &lt;code&gt;'&lt;/code&gt; and will eat it up before the pattern in &lt;code&gt;buflit&lt;/code&gt; can see it and, as a result, the &lt;code&gt;buflit&lt;/code&gt; region mismatch both delimiters. You could deal with this issue by adding &lt;code&gt;keepend&lt;/code&gt; (see &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3asyn%2dkeepend&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :syn-keepend&lt;/code&gt;&lt;/a&gt;) before the &lt;code&gt;conteins&lt;/code&gt; argument, but you won't need it in this case.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;rs&lt;/code&gt; and &lt;code&gt;re&lt;/code&gt; offsets only make sense when they're used along with &lt;code&gt;matchgroup&lt;/code&gt;, and that happens to be very helpful because of this (from &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3asyn%2dmatchgroup&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :syn-matchgroup&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;In a start or end pattern that is highlighted with &quot;matchgroup&quot; the&#xA;contained items of the region are not used.  This can be used to avoid&#xA;that a contained item matches in the start or end pattern match.&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;and, as you'll see below, you won't need the &lt;code&gt;rs&lt;/code&gt;and &lt;code&gt;re&lt;/code&gt; offsets in this case either.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax case ignore&#xA;syntax match bufok &quot;\x\x\|\_s&quot; contained&#xA;syntax region buferr matchgroup=buflit start=&quot;#b'&quot; end=&quot;'&quot; contains=bufok&#xA;&#xA;highlight default link buferr Error&#xA;highlight default link bufok String&#xA;highlight default link buflit String&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the region was redefined by highlighting:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;its content as a error by default&lt;/li&gt;&#xA;&lt;li&gt;its delimiters with the &lt;code&gt;buflit&lt;/code&gt; highlighting group&lt;/li&gt;&#xA;&lt;li&gt;the pair of hexadecimal digits with &lt;code&gt;bufok&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;made the &lt;code&gt;:syntax&lt;/code&gt; command case-insensitive with &lt;code&gt;syntax case ignore&lt;/code&gt; (see :help &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3asyn%2dcase&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :syn-case&lt;/code&gt;&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;used &lt;code&gt;\x&lt;/code&gt; to match hexadecimal digits (see &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5cx&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help /\x&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;used &lt;code&gt;\_s&lt;/code&gt; to match whitespace characters, including the end-of-line (see &#xA;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5cs&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help /\s&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5c_s&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help /\_s&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;code&gt;\x&lt;/code&gt; and &lt;code&gt;\_s&lt;/code&gt; are faster than the &lt;code&gt;[]&lt;/code&gt; form.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Bonus&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I used the long form of each command because some experts around here recommend it (and I agree with them), for example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/usr_20.txt.html#20.2&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help usr_20.txt&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;It is recommended that in Vim scripts you write the full command name.  That&#xA;makes it easier to read back when you make later changes.  Except for some&#xA;often used commands like &quot;:w&quot; (&quot;:write&quot;) and &quot;:r&quot; (&quot;:read&quot;).&#xA;A particularly confusing one is &quot;:end&quot;, which could stand for &quot;:endif&quot;,&#xA;&quot;:endwhile&quot; or &quot;:endfunction&quot;.  Therefore, always use the full name.&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;From &lt;a href=&quot;https://stackoverflow.com/a/12585831/1121933&quot;&gt;romainl's answer&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;you should use the long form names of your settings as they are more readable than their short counterpart. Your future self will thank you.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;From &lt;a href=&quot;https://vi.stackexchange.com/questions/8469/difference-between-full-and-short-command/8470#comment14298_8469&quot;&gt;Tommy A's comment&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I consider the short commands as a command line convenience. I &lt;em&gt;always&lt;/em&gt; use full command names in scripts. It's frustrating when the short commands are used in plugins. It makes grepping/searching scripts harder than it needs to be.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6698" LastActivityDate="2017-07-28T13:16:07.627" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13070" PostTypeId="2" ParentId="13053" CreationDate="2017-07-28T15:59:39.733" Score="2" Body="&lt;p&gt;I don't know if there's a way to do what you want, but I've just learned that that's not the way you're supposed to use tabs. This answer (&lt;a href=&quot;https://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers/103590#103590&quot;&gt;https://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers/103590#103590&lt;/a&gt;) was very useful to me, and maybe it can help you too.&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2017-07-28T15:59:39.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13071" PostTypeId="2" ParentId="13065" CreationDate="2017-07-28T18:28:35.557" Score="1" Body="&lt;p&gt;@apparat gave you the correct answer, but I it can be made into filetype specific mappings for ease of use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the following into &lt;code&gt;~/.vim/after/ftplugin/markdown.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; ]# :keeppatterns s/^/#/e&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; [# :keeppatterns s/^#//e&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; [# :&amp;lt;c-u&amp;gt;keeppatterns '&amp;lt;,'&amp;gt;g/^#/keeppatterns s/^#//&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; ]# :&amp;lt;c-u&amp;gt;keeppatterns '&amp;lt;,'&amp;gt;g/^#/keeppatterns s/^#/##/&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This uses &lt;code&gt;:keeppatterns&lt;/code&gt; so requires a never Vim (I think Vim 8+)&lt;/li&gt;&#xA;&lt;li&gt;Uses a substitution so it will affect the &lt;code&gt;&amp;amp;&lt;/code&gt; and &lt;code&gt;g&amp;amp;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Overwrites &lt;code&gt;]#&lt;/code&gt;/&lt;code&gt;[#&lt;/code&gt; mappings. However these are rather useless in markdown&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-07-28T18:28:35.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13072" PostTypeId="1" AcceptedAnswerId="13397" CreationDate="2017-07-28T20:31:25.493" Score="0" ViewCount="369" Body="&lt;p&gt;I am new to VIM and have been looking for a feature/plugin like guake for terminals wherein I could open the help functionality in a dropdown box without typing &lt;code&gt;:q&lt;/code&gt; to close the vim help menu. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a better way than to close and open new windows for help text I would love to hear those options as well.&lt;/p&gt;&#xA;" OwnerUserId="13633" LastActivityDate="2019-02-12T20:34:12.117" Title="Is there a help plugin which can behave like guake for vim?" Tags="|vimrc|help-system|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13074" PostTypeId="2" ParentId="13062" CreationDate="2017-07-28T21:00:48.590" Score="3" Body="&lt;p&gt;Supplementary answer: based on Jair López's clue about &lt;code&gt;matchgroup&lt;/code&gt;, the following &lt;strong&gt;minimal change&lt;/strong&gt; rescues the original concept:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match buferr &quot;[^']&quot; contained                                                                                                            &#xA;syn match bufok &quot;[0-9A-Fa-f][0-9A-Fa-f]\|[\t\n ]&quot; contained                                                                               &#xA;&#xA;syn region buflit matchgroup=buflit start=&quot;#b'&quot; end=&quot;'&quot; contains=bufok,buferr                                                  &#xA;hi def link bufok String                                                                                                                  &#xA;hi def link buferr Error                                                                                                                  &#xA;hi def link buflit String                                                                                                     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first key difference from the nonworking definition is that there is a &lt;code&gt;matchgroup=buflit&lt;/code&gt; there which means that the &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; delimiters are treated as being &lt;code&gt;bufok&lt;/code&gt;, and colorized as &lt;code&gt;String&lt;/code&gt; via the &lt;code&gt;hi def link&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second key difference is that the error match is &quot;any character but apostrophe&quot; rather than &quot;any character&quot;. This way the error match doesn't compete with the closing delimiter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the offset specifiers &lt;code&gt;rs=&lt;/code&gt; and &lt;code&gt;re=&lt;/code&gt; are removed; they are a red herring in this situation that make no difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution differs from the accepted solution in a small way: it doesn't require the region to be categorized as a one big &lt;code&gt;Error&lt;/code&gt; in which the good pieces of syntax are the exceptions to the error. The errors are recognized explicitly within the region as positive matches. The default behavior of &quot;everything else that is not good token material is an error&quot; is implemented by a single character match routed to &lt;code&gt;Error&lt;/code&gt;: flag and drop the bad character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The end effect appears identical as far as I can tell with interactive testing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the exact differences relative to the accepted solution:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the region is called &lt;code&gt;buflit&lt;/code&gt; rather than &lt;code&gt;buferr&lt;/code&gt; and highlighted as a String.&lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;buferr&lt;/code&gt; name is used for a one character bad &lt;code&gt;match&lt;/code&gt; rather than the region.&lt;/li&gt;&#xA;&lt;li&gt;the region contains &lt;code&gt;buferr&lt;/code&gt; also, not only &lt;code&gt;bufok&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It's good to keep both approaches in mind: error highlights can be identified as explicit matches of erroneous figures on a good background, or as implicitly unmatched gaps between good figures on an error background.&lt;/p&gt;&#xA;" OwnerUserId="13611" LastEditorUserId="13611" LastEditDate="2017-07-28T21:16:03.883" LastActivityDate="2017-07-28T21:16:03.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13075" PostTypeId="2" ParentId="13043" CreationDate="2017-07-28T23:00:47.627" Score="0" Body="&lt;p&gt;You're comparing the string to the result of the function: &lt;code&gt;echo '&amp;lt;,' &amp;gt; GetNumber()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:echo&lt;/code&gt; and &lt;code&gt;:let&lt;/code&gt; accept an expression, where &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#expr-function&quot; rel=&quot;nofollow noreferrer&quot;&gt;the only way&lt;/a&gt; to call a function is &lt;code&gt;funcname(args)&lt;/code&gt;; you can't specify a range there. You could use &lt;code&gt;:call&lt;/code&gt;, but &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#:call&quot; rel=&quot;nofollow noreferrer&quot;&gt;it discards the return value&lt;/a&gt;. Thus the only way to get something out of such a function is to set a global variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetList() range&#xA;  echo a:firstline&#xA;  echo a:lastline&#xA;  let g:GetListResult = []&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7415" LastActivityDate="2017-07-28T23:00:47.627" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13078" PostTypeId="2" ParentId="13072" CreationDate="2017-07-29T04:53:18.697" Score="1" Body="&lt;p&gt;I am not familiar with guake and am not sure what you mean by &quot;dropdown box&quot;. However, I will try to give you some tips on how to make using the built in help system a little more convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A common use case I have is that I am looking at some vim script and wondering, what does this command/option do? Let's take this line from my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set laststatus=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have configured Vim to open the help for the word under the cursor when pressing &lt;code&gt;K&lt;/code&gt; in a &lt;code&gt;.vim&lt;/code&gt; file. So what I would do is place the cursor on &lt;code&gt;laststatus&lt;/code&gt; and press &lt;code&gt;K&lt;/code&gt;. This opens a new window where I read what the options mean, and then press &lt;code&gt;CTRL-w c&lt;/code&gt; to close the window, and I'm back where I was.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;K&lt;/code&gt; is the &quot;lookup help&quot; command (&lt;code&gt;:help K&lt;/code&gt;). It usually runs &lt;code&gt;man&lt;/code&gt;, but can be configured to use &lt;code&gt;:help&lt;/code&gt; or any other command or program instead. Put the following in &lt;code&gt;.vim/after/ftplugin/vim.vim&lt;/code&gt; to enable Vim help with &lt;code&gt;K&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal keywordprg=:help&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;:help 'keywordprg&lt;/code&gt;, &lt;code&gt;:help after-directory&lt;/code&gt;, &lt;code&gt;:help ftplugin&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Opening and closing help with &lt;code&gt;K&lt;/code&gt; and &lt;code&gt;CTRL-c&lt;/code&gt; is super-quick!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some other useful related features:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Go to anything under the cursor while in help with &lt;code&gt;CTRL-]&lt;/code&gt;. Go back with &lt;code&gt;CTRL-t&lt;/code&gt;. (&lt;code&gt;:help tag-commands&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Autocomplete Vim commands and functions in insert mode with &lt;code&gt;CTRL-p&lt;/code&gt;. (&lt;code&gt;:help ins-completion&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Does this answer your question? What specific feature are you missing?&lt;/p&gt;&#xA;" OwnerUserId="9996" LastActivityDate="2017-07-29T04:53:18.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13079" PostTypeId="1" AcceptedAnswerId="13116" CreationDate="2017-07-29T19:43:52.807" Score="6" ViewCount="4931" Body="&lt;p&gt;For some reason when I change my colorscheme it doesn't seem to change all the syntax elements, or changes them to a completely different color than they should be. I know the problem &lt;strong&gt;isn't about&lt;/strong&gt; the color capability of my terminal: when I &lt;code&gt;echo $TERM&lt;/code&gt; I get &lt;code&gt;xterm-256color&lt;/code&gt;. I've also tried the command &lt;code&gt;set t_Co=256&lt;/code&gt; before changing the colorscheme and it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The color differences seem to be vaguely similar to how they are in &lt;a href=&quot;https://vi.stackexchange.com/questions/4232/why-does-my-colorscheme-look-different-when-i-run-vim-with-sudo&quot;&gt;this question&lt;/a&gt; but I'm running mingw on windows and the comparison is between what I have and an online screenshot of what it's supposed to look like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far the worst scenario has been with the &lt;a href=&quot;http://vimcolors.com/653/macvim-light/light&quot; rel=&quot;noreferrer&quot;&gt;macvim-light&lt;/a&gt; colorscheme:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/IBq9o.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IBq9o.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but when I change the colorscheme it looks like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/VERvf.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VERvf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see there's a huge difference between these two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/a/4234/13638&quot;&gt;this answer&lt;/a&gt; suggests I ran &lt;code&gt;:scriptnames&lt;/code&gt; among the files that came up, there seemed to be something possibly relevant in &lt;code&gt;/usr/share/vim/vim80/syntax/syncolor.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;background == &quot;dark&quot;&#xA;  SynColor Comment  term=bold cterm=NONE ctermfg=Cyan ctermbg=NONE gui=NONE guifg=#80a0ff guibg=NONE&#xA;  SynColor Constant term=underline cterm=NONE ctermfg=Magenta ctermbg=NONE gui=NONE guifg=#ffa0a0 guibg=NONE&#xA;  SynColor Special  term=bold cterm=NONE ctermfg=LightRed ctermbg=NONE gui=NONE guifg=Orange guibg=NONE&#xA;  SynColor Identifier   term=underline cterm=bold ctermfg=Cyan ctermbg=NONE gui=NONE guifg=#40ffff guibg=NONE&#xA;  SynColor Statement    term=bold cterm=NONE ctermfg=Yellow ctermbg=NONE gui=bold guifg=#ffff60 guibg=NONE&#xA;  SynColor PreProc  term=underline cterm=NONE ctermfg=LightBlue ctermbg=NONE gui=NONE guifg=#ff80ff guibg=NONE&#xA;  SynColor Type     term=underline cterm=NONE ctermfg=LightGreen ctermbg=NONE gui=bold guifg=#60ff60 guibg=NONE&#xA;  SynColor Underlined   term=underline cterm=underline ctermfg=LightBlue gui=underline guifg=#80a0ff&#xA;  SynColor Ignore   term=NONE cterm=NONE ctermfg=black ctermbg=NONE gui=NONE guifg=bg guibg=NONE&#xA;else&#xA;  SynColor Comment  term=bold cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=NONE guifg=Blue guibg=NONE&#xA;  SynColor Constant term=underline cterm=NONE ctermfg=DarkRed ctermbg=NONE gui=NONE guifg=Magenta guibg=NONE&#xA;  SynColor Special  term=bold cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=SlateBlue guibg=NONE&#xA;  SynColor Identifier   term=underline cterm=NONE ctermfg=DarkCyan ctermbg=NONE gui=NONE guifg=DarkCyan guibg=NONE&#xA;  SynColor Statement    term=bold cterm=NONE ctermfg=Brown ctermbg=NONE gui=bold guifg=Brown guibg=NONE&#xA;  SynColor PreProc  term=underline cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=Purple guibg=NONE&#xA;  SynColor Type     term=underline cterm=NONE ctermfg=DarkGreen ctermbg=NONE gui=bold guifg=SeaGreen guibg=NONE&#xA;  SynColor Underlined   term=underline cterm=underline ctermfg=DarkMagenta gui=underline guifg=SlateBlue&#xA;  SynColor Ignore   term=NONE cterm=NONE ctermfg=white ctermbg=NONE gui=NONE guifg=bg guibg=NONE&#xA;endif&#xA;SynColor Error      term=reverse cterm=NONE ctermfg=White ctermbg=Red gui=NONE guifg=White guibg=Red&#xA;SynColor Todo       term=standout cterm=NONE ctermfg=Black ctermbg=Yellow gui=NONE guifg=Blue guibg=Yellow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not quite sure if that affects changing the colorscheme though&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway here's what I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Windows 8.1&#xA;MSys2&#xA;MinGW64&#xA;bash 4.3.46&#xA;vim 8.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13638" LastActivityDate="2017-08-02T12:26:11.010" Title="Why does my colorscheme not look like it should?" Tags="|colorscheme|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13080" PostTypeId="1" AcceptedAnswerId="13081" CreationDate="2017-07-29T20:47:10.563" Score="66" ViewCount="135539" Body="&lt;p&gt;I've looked through various answers which imply that setting the following in &lt;code&gt;.vimrc&lt;/code&gt; would be appropriate to force tab insertions to become spaces.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&amp;quot; On pressing tab, insert 2 spaces&#xA;set expandtab&#xA;&amp;quot; show existing tab with 2 spaces width&#xA;set tabstop=2&#xA;set softtabstop=2&#xA;&amp;quot; when indenting with '&amp;gt;', use 2 spaces width&#xA;set shiftwidth=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, when I attempt to use 2 spaces, it continues to default to 4 spaces per tab. I have tried moving &lt;code&gt;set expandtab&lt;/code&gt; to the bottom of these declarations. I have tried removing the &lt;code&gt;softtabstop&lt;/code&gt; declaration. I've scoured the various answers given to other questions as well.&lt;/p&gt;&#xA;" OwnerUserId="13639" LastEditorUserId="1238" LastEditDate="2020-08-10T21:07:54.957" LastActivityDate="2023-08-30T13:59:02.103" Title="Setting TAB to 2 spaces" Tags="|whitespace|tab-characters|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13081" PostTypeId="2" ParentId="13080" CreationDate="2017-07-30T02:24:27.450" Score="32" Body="&lt;p&gt;Have you sourced your &lt;code&gt;.vimrc&lt;/code&gt; since making these changes? When having vim open just type &lt;code&gt;source ~/.vimrc&lt;/code&gt; (assuming it is in it's default location)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: &lt;a href=&quot;https://stackoverflow.com/questions/1878974/redefine-tab-as-4-spaces&quot;&gt;This could help too&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13009" LastActivityDate="2017-07-30T02:24:27.450" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13082" PostTypeId="2" ParentId="13079" CreationDate="2017-07-30T10:55:04.727" Score="3" Body="&lt;p&gt;You may have the &quot;wrong&quot; setting for &lt;code&gt;background&lt;/code&gt;. Vim can pick one set of colors for 'dark' and another for 'light'. Some schemes look terrible with one value but great with the other (assuming the scheme isn't optimized for both).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check your current setting with &lt;code&gt;:set background?&lt;/code&gt; and then apply the opposite. For example if the last command returned 'light' then do &lt;code&gt;:set background=dark&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note that sometimes I find that &quot;hot-swapping&quot; this value causes the scheme to be altered so it doesn't look right either way. I need to investigate. Choosing the desired setting before opening the file - e.g. by setting it in vimrc file - should work.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this was the cause you can find more information here (in addition to Vim help): &lt;a href=&quot;https://vi.stackexchange.com/questions/12104/what-does-set-background-dark-do?rq=1&quot;&gt;What does :set background=dark do?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; For reference here's what it looks like from mintty 2.7.9 on my Windows machine with &lt;code&gt;background=light&lt;/code&gt; ('dark' looks totally washed out like your example)...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dTOab.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dTOab.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-08-02T05:22:28.217" LastActivityDate="2017-08-02T05:22:28.217" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13084" PostTypeId="2" ParentId="13017" CreationDate="2017-07-30T16:43:42.170" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/13027/2736&quot;&gt;Christian Brabandt&lt;/a&gt; is correct, Vim requires the exact same version it was compiled for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case, however, Vim still failed to load &lt;code&gt;liblua.5.2.dylib&lt;/code&gt; even after installing Lua 5.2. I fixed that by adding a line to my &lt;code&gt;.vimrc&lt;/code&gt; to explicitly tell Vim where to look:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set luadll=/path/to/liblua.5.2.dylib&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2017-07-30T16:43:42.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13086" PostTypeId="1" CreationDate="2017-07-31T11:29:51.643" Score="5" ViewCount="298" Body="&lt;p&gt;I usually have two windows open, one in which I'm working and one in which I'm viewing some information (compiler messages, relevant library headers, etc. etc.). Now, it's easy to switch the buffer &lt;em&gt;on which I'm working&lt;/em&gt; with &lt;code&gt;:b&lt;/code&gt;, which offers nice tab-completion – however, that's not actually necessary very often since I usually spend substantial time working on a single file. What's needed more often is switching the buffer in the &lt;em&gt;other&lt;/em&gt; window, however to do that I now use the pretty awkward &lt;code&gt;^w p&lt;/code&gt; &lt;code&gt;:b foo&lt;/code&gt; &lt;code&gt;^w p&lt;/code&gt; combination.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to choose that buffer &lt;em&gt;without&lt;/em&gt; actually switching to the other window and then back again?&lt;/p&gt;&#xA;" OwnerUserId="6882" LastActivityDate="2017-07-31T13:44:04.773" Title="Is there a direct way to select the buffer displayed in a non-active window?" Tags="|key-bindings|buffers|vim-windows|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13087" PostTypeId="2" ParentId="13086" CreationDate="2017-07-31T11:45:15.460" Score="5" Body="&lt;p&gt;Maybe you could use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ChangeWindow(buf)&#xA;    execute &quot;wincmd p&quot;&#xA;    execute &quot;e &quot; . a:buf&#xA;    execute &quot;wincmd p&quot;&#xA;endfunction&#xA;&#xA;command! -complete=buffer -nargs=1 CW call ChangeWindow(&quot;&amp;lt;args&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You create a function &lt;code&gt;ChangeWindow()&lt;/code&gt; which takes as argument a buffer name and execute the commands you usually do manually (&lt;kbd&gt;ctrl+p&lt;/kbd&gt;, &lt;code&gt;:e newBuf&lt;/code&gt;, &lt;kbd&gt;ctrl+p&lt;/kbd&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also create a command with &lt;code&gt;-complete=buffer&lt;/code&gt; so it will provide the same autocompletion as &lt;code&gt;:b&lt;/code&gt; and it will call the function with the argument to gave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way you only have to do &lt;code&gt;:CW foo&lt;/code&gt; to put the buffer &lt;code&gt;:foo&lt;/code&gt; in the previous window.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-07-31T11:45:15.460" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13088" PostTypeId="2" ParentId="13086" CreationDate="2017-07-31T13:44:04.773" Score="4" Body="&lt;p&gt;If you have a limited amount of buffers to cycle through instead of needing to open a specific buffer or file you could use &lt;code&gt;:bnext&lt;/code&gt; or some variant of that. If you combine that with a &lt;code&gt;:map&lt;/code&gt;-variant and some window switching you could get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F8&amp;gt; &amp;lt;C-W&amp;gt;w:bnext&amp;lt;CR&amp;gt;&amp;lt;C-W&amp;gt;W&#xA;nnoremap &amp;lt;S-F8&amp;gt; &amp;lt;C-W&amp;gt;w:bprevious&amp;lt;CR&amp;gt;&amp;lt;C-W&amp;gt;W&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;kbd&gt;F8&lt;/kbd&gt; and &lt;kbd&gt;Shift-F8&lt;/kbd&gt; will be mapped to cycled forward or backwards between the buffers in the &lt;em&gt;next&lt;/em&gt; window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add that to your &lt;code&gt;.vimrc&lt;/code&gt; and you are good to go. If you do not want to do that just add it as a regular command.&lt;/p&gt;&#xA;" OwnerUserId="12372" LastActivityDate="2017-07-31T13:44:04.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13089" PostTypeId="2" ParentId="12104" CreationDate="2017-07-31T13:47:18.413" Score="56" Body="&lt;h2&gt;What happens when you &lt;code&gt;:set background&lt;/code&gt;&lt;/h2&gt;&#xA;&lt;p&gt;The basic mechanism by which &lt;code&gt;:set background&lt;/code&gt; works is actually pretty simple, and&#xA;it is documented (although not particularly clearly) in &lt;code&gt;:help 'background'&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When 'background' is set Vim will adjust the default color groups for&#xA;the new value.  But the colors used for syntax highlighting will not&#xA;change.                   &lt;em&gt;g:colors_name&lt;/em&gt;&lt;br /&gt;&#xA;When a color scheme is loaded (the &amp;quot;g:colors_name&amp;quot; variable is set)&#xA;setting 'background' will cause the color scheme to be reloaded.  If&#xA;the color scheme adjusts to the value of 'background' this will work.&#xA;However, if the color scheme sets 'background' itself the effect may&#xA;be undone.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So what actually happens when the &lt;code&gt;'background'&lt;/code&gt; option is changed is this:&lt;/p&gt;&#xA;&lt;h3&gt;If no colour scheme is currently loaded&lt;/h3&gt;&#xA;&lt;p&gt;Vim reloads the default colours, using foreground colours deemed appropriate for&#xA;the new setting of &lt;code&gt;'background'&lt;/code&gt;&lt;/p&gt;&#xA;&lt;h3&gt;If a colour scheme is currently loaded&lt;/h3&gt;&#xA;&lt;p&gt;Vim reloads the colour scheme. When the colour scheme is loaded, either the&#xA;colour scheme sets colours appropriate to the new setting of &lt;code&gt;'background'&lt;/code&gt;, or&#xA;the colour scheme &lt;em&gt;resets&lt;/em&gt; &lt;code&gt;'background'&lt;/code&gt; to the old value.&lt;/p&gt;&#xA;&lt;p&gt;As you have already described, the &lt;code&gt;'background'&lt;/code&gt; option is not intended to &lt;em&gt;set&lt;/em&gt;&#xA;the background, but instead to &lt;em&gt;inform&lt;/em&gt; Vim whether the background is dark or&#xA;light.&lt;/p&gt;&#xA;&lt;p&gt;So if the colour scheme resets &lt;code&gt;'background'&lt;/code&gt;, Vim takes this to mean&#xA;that the colour scheme simply doesn't support the new setting of &lt;code&gt;'background'&lt;/code&gt;.&#xA;Since the user has indicated they &lt;em&gt;are using&lt;/em&gt; such a background this means that&#xA;the current colour scheme is no longer appropriate, and so Vim unsets&#xA;&lt;code&gt;g:colors_name&lt;/code&gt; and then reloads the default colours.&lt;/p&gt;&#xA;&lt;p&gt;If you'd like to explore the actual code that is run when &lt;code&gt;'background'&lt;/code&gt; is set, &lt;a href=&quot;https://github.com/vim/vim/blob/9652249a2d02318a28a63a7b5711f25652e8f969/src/optionstr.c#L871&quot; rel=&quot;nofollow noreferrer&quot;&gt;you can start here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;What's happening in your installation&lt;/h2&gt;&#xA;&lt;p&gt;The odd behaviour you describe (in the first version of your question) can be&#xA;explained by this line in the documentation quoted above:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When a color scheme is loaded &lt;em&gt;(the &amp;quot;g:colors_name&amp;quot; variable is set)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The problem is that your &lt;code&gt;colors/darcula.vim&lt;/code&gt; file doesn't set this value, and&#xA;so even though the colors changed when you invoked &lt;code&gt;:color darcula&lt;/code&gt;, &lt;em&gt;Vim&#xA;doesn't consider a colour scheme to currently be loaded.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Therefore, when you call &lt;code&gt;:set background=dark&lt;/code&gt; Vim carries out the step in the&#xA;&amp;quot;If no colour scheme is currently loaded&amp;quot; section above, and sets the default&#xA;colours for a dark background. This explains why &lt;code&gt;:color&lt;/code&gt; then reports&#xA;&lt;code&gt;default&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(Note, however, that setting the default colours does &lt;em&gt;not&lt;/em&gt;, as you might expect,&#xA;remove all the colours that had previously been set, and this is why you end up&#xA;with the results you see, rather than the colours that are displayed when you&#xA;start up Vim in the first place. &lt;a href=&quot;http://peterodding.com/code/vim/colorscheme-switcher/#known_problems&quot; rel=&quot;nofollow noreferrer&quot;&gt;There's some discussion of this issue&#xA;here&lt;/a&gt;. &lt;strong&gt;Edit&lt;/strong&gt;: This issue was fixed in &lt;a href=&quot;https://github.com/vim/vim/commit/05eb5b9cae123b138bbd23cc77e50657ece6b4ad&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim 8.2.1693&lt;/a&gt;.)&lt;/p&gt;&#xA;&lt;p&gt;In short, your colour scheme is misconfigured: See &lt;code&gt;:edit $VIMRUNTIME/colors/README.txt&lt;/code&gt; (in particular the section at the bottom) for&#xA;more details on this, and on the interaction between &lt;code&gt;'background'&lt;/code&gt; and colour&#xA;schemes.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2022-10-18T10:09:31.697" LastActivityDate="2022-10-18T10:09:31.697" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="13090" PostTypeId="2" ParentId="13065" CreationDate="2017-07-31T19:05:04.593" Score="1" Body="&lt;p&gt;Without a plugin you'll likely have a very imperfect solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, while a leading &lt;code&gt;#&lt;/code&gt; is a good sign for a header, it may unfortunately appear in other contexts: in code contexts. If in your markdown text you're likely to have snippets of bash script, Python, Perl, or many others, all the &lt;code&gt;:[range]s/^#&lt;/code&gt; solutions will alter your snippets which you won't want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only have very few headers or bash/perl/... comments, you can use the &lt;em&gt;confirm&lt;/em&gt;  flag of &lt;code&gt;:substitute&lt;/code&gt;. Otherwise, well, you'll dream of something able to distinguish embedded code snippets from headers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently, in my &lt;a href=&quot;https://github.com/LucHermitte/lh-misc/blob/master/autoload/lh/markdown/toc.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;TOC generator&lt;/a&gt; I've used a state-machine to ignore code snippets. The code snippets identification is done with the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let lines = getline(1, '$')&#xA;&quot; First remove blocks of code&#xA;let blocks = map(copy(lines), 'v:val =~ &quot;^\\s*```&quot; ? (v:key + 1) : -1')&#xA;call filter(blocks, 'v:val &amp;gt; 0')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From there, &lt;code&gt;[0, block[0])&lt;/code&gt; defines the first block of line numbers without a code snippet. &lt;code&gt;(block[1], blocks[2])&lt;/code&gt; the second block and so on.From here, you'll want to intersect those lines numbers with the total range on which you'll want to apply the substitution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; let blocks = [1] + blocks + [line('$')]&#xA; let text_ranges = map(range(len(blocks)/2), '[blocks[2*v:val]-1, blocks[2*v:val+1]+1]')&#xA; &quot; Filter out ranges out side the selected range (a:firstline, a:lastline) -- untested&#xA; call filter(text_ranges, 'v:val[1] &amp;gt;= a:firstline') &#xA; call filter(text_ranges, 'v:val[0] &amp;lt;= a:lastline')&#xA; let text_ranges[0][0] = max(text_ranges[0][0], a:firstline)&#xA; let text_ranges[-1][0] = min(text_ranges[-1][0], a:lastline)&#xA; &quot; And finally apply the substitutions (see the other answers)&#xA; for range in text_ranges&#xA;     &quot; todo: make sure range isn't empty&#xA;     &quot; add one level&#xA;     exe range[0].','.range[1].'s/^##/#/'&#xA; endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, this is not trivial, this is one of the reasons we write plugins. BTW, we still have to wrap these lines in a range-function which is to be called from a command.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-08-01T11:56:22.547" LastActivityDate="2017-08-01T11:56:22.547" CommentCount="0" CommunityOwnedDate="2017-08-01T11:56:22.547" ContentLicense="CC BY-SA 3.0" />
  <row Id="13091" PostTypeId="1" AcceptedAnswerId="13093" CreationDate="2017-08-01T03:51:18.180" Score="4" ViewCount="993" Body="&lt;p&gt;I've just developed a nice solution for &lt;a href=&quot;https://unix.stackexchange.com/a/383044/143394&quot;&gt;automatically loading external changes made to a file&lt;/a&gt;, but I'd like a more obvious notification when &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27autoread%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;autoread&lt;/code&gt;&lt;/a&gt; changes my buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way of having a warning text appear (eg coloured red) when &lt;code&gt;autoread&lt;/code&gt; triggers, so I can easily notice any changes?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2017-08-01T04:35:58.043" LastActivityDate="2017-08-01T04:52:51.903" Title="Autocmd event for `autoread`?" Tags="|autocmd|autoload|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13092" PostTypeId="2" ParentId="444" CreationDate="2017-08-01T03:56:43.850" Score="46" Body="&lt;p&gt;In many cases, &lt;code&gt;set autoread&lt;/code&gt; will not work as &lt;a href=&quot;https://stackoverflow.com/a/2490635/5353461&quot;&gt;this answer&lt;/a&gt; explains:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Autoread does not reload file unless you do something like run external command (like &lt;code&gt;!ls&lt;/code&gt; or &lt;code&gt;!sh&lt;/code&gt; etc) &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Focus events will trigger &lt;code&gt;autoread&lt;/code&gt;, but these are not captured unless using &lt;code&gt;gvim&lt;/code&gt;. So, if running plain &lt;code&gt;vim&lt;/code&gt; inside a terminal window or tmux, install&#xA;the plugin &lt;a href=&quot;https://github.com/tmux-plugins/vim-tmux-focus-events&quot; rel=&quot;noreferrer&quot;&gt;vim-tmux-focus-events&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On tmux versions &gt; 1.9, you'll need to add in &lt;code&gt;.tmux.conf&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set -g focus-events on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For additional goodness, adding the following to your &lt;code&gt;vimrc&lt;/code&gt; will trigger &lt;code&gt;autoread&lt;/code&gt; when changing buffers inside while &lt;em&gt;inside&lt;/em&gt; vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FocusGained,BufEnter * :checktime&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2017-08-01T04:12:24.773" LastActivityDate="2017-08-01T04:12:24.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13093" PostTypeId="2" ParentId="13091" CreationDate="2017-08-01T04:13:53.590" Score="7" Body="&lt;p&gt;One way to create a highlighted message is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echohl WarningMsg | echo &quot;Buffer changed!&quot; | echohl None&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first command selects a particular highlight mode for any subsequent &lt;code&gt;echo&lt;/code&gt; calls. When &lt;code&gt;echo&lt;/code&gt; is called the message will be displayed on the status line with approriate color and/or format (in my case white on yellow text). Don't forget the second &lt;code&gt;echohl&lt;/code&gt; to return to regular highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I believe you want to display this when autoread is triggered. I am having success with this autocommand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileChangedShellPost *&#xA;  \ echohl WarningMsg | echo &quot;Buffer changed!&quot; | echohl None&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do &lt;code&gt;set autoread&lt;/code&gt; in my vimrc, load a file with gvim, load it with another editor and change something, come back to gvim. Voila, I get the highlighted message.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-08-01T04:52:51.903" LastActivityDate="2017-08-01T04:52:51.903" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13094" PostTypeId="2" ParentId="4593" CreationDate="2017-08-01T06:56:00.563" Score="-1" Body="&lt;p&gt;I had this same issue running gvim 7.4 on win10. Upgrading to gvim8.0 fixed this problem for me.&lt;/p&gt;&#xA;" OwnerUserId="13668" LastEditorUserId="51" LastEditDate="2017-08-01T09:42:43.380" LastActivityDate="2017-08-01T09:42:43.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13095" PostTypeId="1" AcceptedAnswerId="13096" CreationDate="2017-08-01T08:37:09.463" Score="2" ViewCount="325" Body="&lt;p&gt;I have been going through some &lt;a href=&quot;https://vimgolf.com/challenges/540629666a1e4000020d9e5a#5946a26411266f0006000005&quot; rel=&quot;nofollow noreferrer&quot;&gt;answers to a vimgolf&lt;/a&gt;, and stumbled upon this regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\_W*/-/g|x&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which converts &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abcdefghijklm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-a-b-c-d-e-f-g-h-i-j-k-l-m-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The regex (without unrelated keystrokes) is &lt;code&gt;/\_W*/-/&lt;/code&gt;. The manual indicates that:&#xA; &lt;code&gt;\W&lt;/code&gt; stands for &lt;code&gt;non-word character:       [^0-9A-Za-z_]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\_x   Where &quot;x&quot; is any of the characters above: The character class with&#xA;    end-of-line added&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;\_W&lt;/code&gt; is non-word characters with end-of-line added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does that put the dashes between the characters? Is there a hidden metacharacter between each character in vim text?&lt;/p&gt;&#xA;" OwnerUserId="13179" LastActivityDate="2019-01-16T22:40:05.190" Title="Understanding &quot;\_W*&quot; in vim regex" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13096" PostTypeId="2" ParentId="13095" CreationDate="2017-08-01T09:02:33.493" Score="3" Body="&lt;p&gt;This is not a question of hidden character, the trick comes from the &lt;code&gt;*&lt;/code&gt; combined with the flag &lt;code&gt;g&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifying &lt;code&gt;*&lt;/code&gt; after a character classe will match &quot;zero or more&quot; items (which includes an empty string): between &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; there is zero non-word character, thus &lt;code&gt;\W*&lt;/code&gt; will match this &quot;not existing space&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example you could also have used &lt;code&gt;\_s*&lt;/code&gt; or &lt;code&gt;\_d*&lt;/code&gt; and still get the same result since you match zero items of the class.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-08-01T09:02:33.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13097" PostTypeId="2" ParentId="12953" CreationDate="2017-08-01T10:02:12.807" Score="1" Body="&lt;p&gt;Here's a hacky solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can write a script to change your input mode using AppleScript. Create a file &lt;code&gt;~/.vim/switch_im.applescript&lt;/code&gt; with the following contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tell application &quot;System Events&quot;&#xA;    key code 49 using command down&#xA;end tell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This changes input method by emulating a &lt;kbd&gt;Command&lt;/kbd&gt;+&lt;kbd&gt;Space&lt;/kbd&gt; key press. (N.B. I'm using &lt;kbd&gt;Command&lt;/kbd&gt; because that's the default shortcut. If you have changed this to &lt;kbd&gt;Control&lt;/kbd&gt;, as indicated in your question, change &lt;code&gt;command&lt;/code&gt; to &lt;code&gt;control&lt;/code&gt; in the script.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, add the following to your &lt;code&gt;.vimrc&lt;/code&gt; (or to file(s) in &lt;code&gt;.vim/after/ftplugin/&lt;/code&gt; if you want to restrict the behaviour to particular file types):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; See note 1&#xA;function! SwitchToChinese()&#xA;  silent execute &quot;!osascript &quot; . $HOME . &quot;/.vim/switch_im.applescript &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&quot;&#xA;  let g:chinese_im = 1&#xA;  redraw!&#xA;endfunction&#xA;&#xA;&quot; See note 2&#xA;function! SwitchToEnglish()&#xA;  if exists(&quot;g:chinese_im&quot;) &amp;amp;&amp;amp; g:chinese_im&#xA;    silent execute &quot;!osascript &quot; . $HOME . &quot;/.vim/switch_im.applescript &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&quot;&#xA;    let g:chinese_im = 0&#xA;    redraw!&#xA;  endif&#xA;endfunction&#xA;&#xA;&quot; See note 3&#xA;inoremap &amp;lt;f5&amp;gt; &amp;lt;c-o&amp;gt;:call SwitchToChinese()&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; See note 4&#xA;augroup switchlanguage&#xA;  autocmd!&#xA;  autocmd InsertLeave * call SwitchToEnglish()&#xA;augroup END&#xA;&#xA;&quot; See note 5&#xA;set ttimeoutlen=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code is comprised of the following sections:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;A function to switch from English to Chinese: it works by running the switch input method script with the following command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;silent execute &quot;!osascript &quot; . $HOME . &quot;/.vim/switch_im.applescript &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This acts the same as running the command &lt;code&gt;osascript ~/.vim/switch_im.applescript&lt;/code&gt; from the terminal. The rest of the line (the Vim &lt;code&gt;silent&lt;/code&gt; and the shell redirection and backgrounding) is just intended to make sure nothing is displayed on the screen when the command is run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function also sets a variable to indicate that the input method is now Chinese.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A function to switch to English &lt;em&gt;if&lt;/em&gt; the variable is set to indicate we are currently in Chinese. We don't want to switch if we're already in English!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;An insert mode mapping to switch to Chinese by pressing &lt;kbd&gt;F5&lt;/kbd&gt;. For this code to work, you must always switch to Chinese using this mapping.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;An auto command to switch to English when leaving insert mode.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In order to prevent a delay when pressing &lt;kbd&gt;Escape&lt;/kbd&gt; to exit insert mode, we need to set a very short key-code delay. An alternative solution here would be &lt;code&gt;set noesckeys&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Shortcomings&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I said this solution was hacky. So what are the problems with it?&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;There is a very slight delay when changing the language. If you press another key &lt;em&gt;immediately&lt;/em&gt; after exiting insert mode, that keystroke may be lost. I tried compiling the script into a &lt;code&gt;.scpt&lt;/code&gt; file with Script Editor, but it didn't make a noticeable difference.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It's not a robust solution: in order to work properly, it needs to know which input method is currently in use. Therefore, you &lt;em&gt;must&lt;/em&gt; only change to Chinese by pressing &lt;code&gt;F5&lt;/code&gt; in insert mode, and you &lt;em&gt;must&lt;/em&gt; only change back to English by exiting insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This fragility can be fixed by replacing the naïve &lt;code&gt;switch_im.applescript&lt;/code&gt; script with language-specific scripts. Here's the AppleScript for changing to (British) English:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tell application &quot;System Events&quot; to tell process &quot;SystemUIServer&quot;&#xA;  tell (1st menu bar item of menu bar 1 whose description is &quot;text input&quot;) to {click, click (menu 1's menu item &quot;British&quot;)}&#xA;end tell&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Using more specific scripts means you'll never accidentally change in the wrong direction, and removing the &lt;code&gt;g:chinese_im&lt;/code&gt; guard too would mean you will &lt;em&gt;always&lt;/em&gt; find yourself in English when you leave Insert Mode (and therefore don't need a script, function, or mapping for switching to Chinese).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this script runs noticeably more slowly than the key press version. During my testing I found the extra delay more disruptive than the requirements about switching languages, but, depending on your editing style, you may prefer the safer version. If you always stop and think for a second after leaving insert mode anyway, then the delay won't be an issue for you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attribution: The AppleScript code in this answer was nabbed from &lt;a href=&quot;https://superuser.com/questions/224161/switch-to-specific-input-source&quot;&gt;this question on superuser.com&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-08-01T10:02:12.807" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13099" PostTypeId="1" AcceptedAnswerId="13112" CreationDate="2017-08-01T16:15:38.780" Score="5" ViewCount="4819" Body="&lt;p&gt;When using the vim installed by default in macOS 10.12.5, I can copy text from the terminal by using cmd-C and pasting it into another applications. But when I use the latest version of vim (8.0.0771_1) installed by homebrew, it's impossible to copy any text from the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why? and how to change this behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim installed by default:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr  4 2017 18:14:54)&#xA;Included patches: 1-898, 8056&#xA;Compiled by root@apple.com&#xA;Normal version without GUI.  Features included (+) or not (-):&#xA;+acl             -farsi           -mouse_netterm   +syntax&#xA;-arabic          +file_in_path    -mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           -mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;+builtin_terms   -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         -gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;-clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   -perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    -keymap          +postscript      +virtualedit&#xA;+comments        -langmap         +printer         +visual&#xA;-conceal         +libcall         -profile         +visualextra&#xA;+cryptv          +linebreak       +python/dyn      +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             -rightleft       +windows&#xA;+diff            +menu            +ruby/dyn        +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;-emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            -mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        -mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim installed by homebrew:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jul 25 2017 12:36:48)&#xA;MacOS X (unix) version&#xA;Included patches: 1-771&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     -tcl&#xA;-balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;-browse          -footer          +multi_byte      +terminal&#xA;++builtin_terms  +fork()          +multi_lang      +terminfo&#xA;+byte_offset     -gettext         -mzscheme        +termresponse&#xA;+channel         -hangul_input    +netbeans_intg   +textobjects&#xA;+cindent         +iconv           +num64           +timers&#xA;-clientserver    +insert_expand   +packages        +title&#xA;+clipboard       +job             +path_extra      -toolbar&#xA;+cmdline_compl   +jumplist        +perl            +user_commands&#xA;+cmdline_hist    +keymap          +persistent_undo +vertsplit&#xA;+cmdline_info    +lambda          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python          +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            +ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      +startuptime     -xpm&#xA;+eval            +mouse_dec       +statusline      -xsmp&#xA;+ex_extra        -mouse_gpm       -sun_workshop    -xterm_clipboard&#xA;+extra_search    -mouse_jsbterm   +syntax          -xterm_save&#xA;+farsi           +mouse_netterm   +tag_binary&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework Cocoa   -mmacosx-version-min=10.12 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.26.0/lib/perl5/5.26.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/opt/python/Frameworks -framework Python   -lruby.2.4.1 -lobjc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4926" LastEditorUserId="51" LastEditDate="2017-08-10T19:52:42.307" LastActivityDate="2023-09-15T10:49:10.190" Title="Not able to copy from terminal when using vim from homebrew on macOS" Tags="|os-clipboard|macos|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13101" PostTypeId="1" CreationDate="2017-08-01T22:16:52.990" Score="1" ViewCount="37" Body="&lt;p&gt;I intend to use this to optionally share the search buffer between different Vim instances. I'll have a file on the filesystem that contains the content. So it means I need to set the search register with the contents of a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm hoping there's a clean Vimscript way to do this. It's ok if it uses python or any other language integration too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this is how to edit the register: &lt;code&gt;let @/ = [whatever]&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2017-08-01T22:29:07.350" Title="How to get a variable with the contents of a file on the filesystem?" Tags="|search|register|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13102" PostTypeId="2" ParentId="13101" CreationDate="2017-08-01T22:29:07.350" Score="2" Body="&lt;p&gt;This was easy. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;n :let @/ = join(readfile(glob(&quot;~/.vim/.search&quot;)), &quot;\n&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="390" LastActivityDate="2017-08-01T22:29:07.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13103" PostTypeId="2" ParentId="12982" CreationDate="2017-08-01T22:55:42.023" Score="3" Body="&lt;p&gt;here's what works for me. &lt;code&gt;Ctrl-o&lt;/code&gt; doesn't close the buffer, it just jumps to the previous one. but &lt;code&gt;:buffer #&lt;/code&gt; seems to do it. so in my &lt;code&gt;init.vim&lt;/code&gt; I have &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;tnoremap &amp;lt;ESC&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;:buffer #&amp;lt;CR&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;which closes the terminal buffer and jump back to the previous one, the window is still split. I mapped it to &lt;code&gt;ESC&lt;/code&gt; cause it makes sense to me, but that's personal preference.&lt;/p&gt;&#xA;" OwnerUserId="6381" LastActivityDate="2017-08-01T22:55:42.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13104" PostTypeId="1" AcceptedAnswerId="13110" CreationDate="2017-08-02T03:08:05.920" Score="3" ViewCount="52" Body="&lt;p&gt;In the doc little is said about this number. Can we retrieve the entire arglist using this number and get all the versions of arglist?&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2017-08-02T09:46:04.460" Title="how to use the number returned by arglistid()" Tags="|argument-list|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13105" PostTypeId="1" CreationDate="2017-08-02T07:18:28.173" Score="3" ViewCount="4702" Body="&lt;p&gt;I am trying to improve my vim skills lately, and therefore I edit my &lt;code&gt;.vimrc&lt;/code&gt; a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following &lt;a href=&quot;https://vi.stackexchange.com/questions/24/how-do-i-reload-my-vimrc-without-leaving-vim&quot;&gt;How do I reload my vimrc without leaving Vim?&lt;/a&gt;, I wonder if there is a convenient way to define a keymap for opening &lt;code&gt;.vimrc&lt;/code&gt;, and loading its code after it has been saved?&lt;/p&gt;&#xA;" OwnerUserId="13179" LastActivityDate="2017-08-03T17:00:47.783" Title="keymap for open .vimrc, edit, save and reload" Tags="|vimrc|key-bindings|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13106" PostTypeId="1" AcceptedAnswerId="13136" CreationDate="2017-08-02T07:18:47.507" Score="6" ViewCount="6320" Body="&lt;p&gt;I want to search for:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;From start of the line, any number of white spaces followed by any&#xA;  number of digits NOT followed by a dot.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And replace it with all that was searched and a dot. This is just to introduce a dot in a simple numbered list when forgotten.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I went:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(\s*\d\+\)\.\@!/\1\.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This breaks down if there is a two digit number with a dot following it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;This &lt;code&gt;1 Some text&lt;/code&gt; becomes this &lt;code&gt;1. Some text&lt;/code&gt; as expected.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;But, this &lt;code&gt;10. Some text&lt;/code&gt; becomes &lt;code&gt;1.0. Some text&lt;/code&gt; instead staying unchanged.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3095" LastEditorUserId="1841" LastEditDate="2017-08-02T08:05:42.627" LastActivityDate="2017-08-04T12:48:07.697" Title="Match any number of digits NOT followed by" Tags="|search|regular-expression|substitute|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13107" PostTypeId="2" ParentId="13105" CreationDate="2017-08-02T07:37:30.583" Score="4" Body="&lt;p&gt;You can use this to open it easily:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F3&amp;gt; :e $MYVIMRC&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And replace &lt;code&gt;&amp;lt;F3&amp;gt;&lt;/code&gt; by the key you want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or use a Capital mark which is persistent accross buffers and vim sessions (this is what I use):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open your vimrc in a buffer&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;shift&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; to set the mark (or any capital letter)&lt;/li&gt;&#xA;&lt;li&gt;When you want to open your vimrc again simply press &lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;shift&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; (or any letter you used to set the mark)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To automatically source it after it is saved you can use an autocommand this way you don't have to define a mapping and no matter the way you save your buffer the source command will be executed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost .vimrc source $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I don't think that's a good idea, a mapping to source it like the one in the question you linked seems better since you source the file only when you want to.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-08-02T07:43:56.423" LastActivityDate="2017-08-02T07:43:56.423" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13108" PostTypeId="2" ParentId="13106" CreationDate="2017-08-02T08:00:52.750" Score="4" Body="&lt;p&gt;If I understand correctly your question what you want is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\s*\d\+\([0-9\.]\)\@!/\0.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to group the digits and the dot in the group you're excluding with &lt;code&gt;\@!&lt;/code&gt; other wise the match stops before the &lt;code&gt;0&lt;/code&gt; in &lt;code&gt;10&lt;/code&gt; and the dot is inserted whereas it shouldn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this command you transform this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 Foo&#xA;10 Bar&#xA;10. Bar&#xA;    1 Foo&#xA;    10 Bar&#xA;    10. Bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. Foo&#xA;10. Bar&#xA;10. Bar&#xA;    1. Foo&#xA;    10. Bar&#xA;    10. Bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-08-02T08:00:52.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13109" PostTypeId="2" ParentId="13106" CreationDate="2017-08-02T08:19:29.853" Score="3" Body="&lt;p&gt;Instead of using a zero-width match to specify &lt;em&gt;not&lt;/em&gt; to include the dots, you could set the end of the match and then specify what &lt;em&gt;is&lt;/em&gt; included in the &quot;wrong&quot; lines. That is, if the digits are followed by space or end-of-line, one should add a dot:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\s*\d\+\ze\(\s\|$\)/\0.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;\ze&lt;/code&gt; sets the end of the match, and the group matches either a space or the end-of-line.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-08-02T08:19:29.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13110" PostTypeId="2" ParentId="13104" CreationDate="2017-08-02T09:46:04.460" Score="3" Body="&lt;p&gt;Great question! The only &lt;em&gt;existing&lt;/em&gt; use I can determine from the docs is that it allows you to find out whether a window is currently using a local &lt;code&gt;arglist&lt;/code&gt; or the global one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it looks as though it's just the first step of some more extensive changes that allow you to use the number to manipulate the lists in use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code has already been written (see &lt;a href=&quot;https://github.com/coot/vim_patches#arglistspatch&quot; rel=&quot;nofollow noreferrer&quot;&gt;arglists.patch in this repository&lt;/a&gt;) but hasn't yet been accepted into the main Vim codebase: you can see it mentioned in &lt;code&gt;:help todo&lt;/code&gt; by searching for &lt;code&gt;arglists&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-08-02T09:46:04.460" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13111" PostTypeId="1" AcceptedAnswerId="13115" CreationDate="2017-08-02T09:53:41.690" Score="0" ViewCount="573" Body="&lt;p&gt;When opening a bind zone file, I have to type by hand &lt;code&gt;:set ft=bindzone&lt;/code&gt; to get syntax highlighting. It's not set automatically on load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On another hand others filetypes (such as php, perl or kind) are properly set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where I should look first to solve this ?&lt;/p&gt;&#xA;" OwnerUserId="13679" LastEditorUserId="1841" LastEditDate="2017-08-02T14:04:13.370" LastActivityDate="2017-08-02T14:04:13.370" Title="Vi/Vim 8 on debian stretch : filetype &quot;bindzone&quot; not loaded automatically" Tags="|syntax-highlighting|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13112" PostTypeId="2" ParentId="13099" CreationDate="2017-08-02T10:18:54.587" Score="8" Body="&lt;p&gt;There are few thing you can do to solve this. Homebrew compiled &lt;code&gt;Huge&lt;/code&gt; version, while default Vim is in &lt;code&gt;Normal&lt;/code&gt; version. &lt;code&gt;Huge&lt;/code&gt; adds for example clipboard and more mouse/terminal support. This makes selecting with mouse actually select in Vim (so changes to Visual mode) instead of doing selection on terminal layer.&#xA;Having that said, you can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;press &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt; or &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;*&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt; in Homebrew version after doing the selection,&lt;/li&gt;&#xA;&lt;li&gt;ask Homebrew to compile &lt;code&gt;Normal&lt;/code&gt; version or without mouse_* features (but I don't know the details of how to do that),&lt;/li&gt;&#xA;&lt;li&gt;select holding &lt;kbd&gt;Shift&lt;/kbd&gt; and then do the copy stuff as usual (holding &lt;kbd&gt;Shift&lt;/kbd&gt; should make terminal selection and not passing this to the app running in that terminal)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;set mouse=&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt; to disable interaction with a mouse, but this will disable mouse support for good, so no more selecting focused window, resizing windows, etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2017-08-02T11:50:20.130" LastActivityDate="2017-08-02T11:50:20.130" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13114" PostTypeId="2" ParentId="13111" CreationDate="2017-08-02T10:42:07.043" Score="0" Body="&lt;p&gt;&lt;code&gt;filetype&lt;/code&gt; is set based on the file extension or by &lt;code&gt;ftdetect&lt;/code&gt; plugins.&#xA;For example &lt;code&gt;PHP&lt;/code&gt; files end with &lt;code&gt;.php&lt;/code&gt; and Vim loads if it exist a file &lt;code&gt;php.vim&lt;/code&gt; from directories like &lt;code&gt;ftplugin&lt;/code&gt;, &lt;code&gt;syntax&lt;/code&gt; etc (they need to be in Vim's runtime paths). So your files either should have extension &lt;code&gt;.bindzone&lt;/code&gt; or if they have different extension then you can link in your &lt;code&gt;$HOME/.vimrc/syntax/&amp;lt;extension&amp;gt;.vim&lt;/code&gt; pointing to where the bindzone syntax file is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also add modeline in those files with &lt;code&gt;set ft=bindzone&lt;/code&gt;. A modeline is first or last line in a file that is a valid comment for that file type and contains something like this: &lt;code&gt;vim: set ft=bindzone:&lt;/code&gt; (there can be more settings there). See &lt;code&gt;:help modeline&lt;/code&gt; for more info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution would be to add &lt;code&gt;autocmd&lt;/code&gt; that will set file type for files matching a pattern, for example all files in particular directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile /path/to/bind/zone/files/* set ft=bindzone&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One more solution is to write a &lt;code&gt;ftdetect&lt;/code&gt; plugin, but I don't have experience with that. You can checkout files in &lt;code&gt;ftdetect&lt;/code&gt; directories for more info or the Vim's help.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-08-02T10:42:07.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13115" PostTypeId="2" ParentId="13111" CreationDate="2017-08-02T10:58:49.987" Score="1" Body="&lt;p&gt;the filetype bindzone is supported by default in Vim using the &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/filetype.vim#L297-L307&quot; rel=&quot;nofollow noreferrer&quot;&gt;filetype.vim&lt;/a&gt; in &lt;code&gt;$VIMRUNTIME&lt;/code&gt; which sets the filetype according to the properties of your file. By default however, Vim only sets the filetype to &lt;code&gt;bindzone&lt;/code&gt; if the file is called &lt;code&gt;named.root&lt;/code&gt; and for any file that has the extensions &lt;code&gt;.db&lt;/code&gt; and the first 4 lines match this regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'^; &amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG [0-9.]\+ &amp;lt;&amp;lt;&amp;gt;&amp;gt;\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your files do not match that, consider renaming them (if that is the cause for not detecting it properly), add a modeline as shown by @grodzik or enhance the filetype detection logic (see the &lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-26.8&quot; rel=&quot;nofollow noreferrer&quot;&gt;faq question 26.8&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in case you suspect a bug in the default filetype.vim file, consider creating a PR at the &lt;a href=&quot;https://github.com/vim/vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim/vim&lt;/a&gt; repository suggesting a fix for that.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-08-02T10:58:49.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13116" PostTypeId="2" ParentId="13079" CreationDate="2017-08-02T11:13:26.113" Score="4" Body="&lt;p&gt;The problem with the specific macvim-light colour scheme you link to is that it has incredibly limited support for terminals: the &lt;em&gt;only&lt;/em&gt; syntax groups it adds highlighting for are &lt;code&gt;Normal&lt;/code&gt;, &lt;code&gt;DiffAdd&lt;/code&gt;, &lt;code&gt;DiffChange&lt;/code&gt;, &lt;code&gt;DiffText&lt;/code&gt;, and &lt;code&gt;DiffDelete&lt;/code&gt;. So if you're not viewing a diff, it essentially does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, screenshots of gVim displaying a colour scheme are unlikely ever to match up well with the output in a 256 colour terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you're are dead set on using colour schemes with poor/no support for terminal colours (most of them), you might want to look into the &lt;a href=&quot;https://vim.sourceforge.io/scripts/script.php?script_id=2390&quot; rel=&quot;nofollow noreferrer&quot;&gt;CSApprox&lt;/a&gt; or &lt;a href=&quot;https://vim.sourceforge.io/scripts/script.php?script_id=1809&quot; rel=&quot;nofollow noreferrer&quot;&gt;guicolorscheme&lt;/a&gt; plugins or, better, the newish &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27termguicolors%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'termguicolors'&lt;/code&gt;&lt;/a&gt; option.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-08-02T12:26:11.010" LastActivityDate="2017-08-02T12:26:11.010" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13117" PostTypeId="2" ParentId="13106" CreationDate="2017-08-02T12:06:43.653" Score="3" Body="&lt;p&gt;This seems to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/^\(\s*\d\+\)\(\.\?\d\+\)\?\.\?\(\s\)/\1\2.\3/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the first group is any number of &quot;empty&quot; characters followed by one or more digits;&lt;/li&gt;&#xA;&lt;li&gt;the second group is zero or one point followed by one ore more digits, but this group can appear one or more times;&lt;/li&gt;&#xA;&lt;li&gt;the third group is any number of &quot;empty&quot; characters at the end (so they can be preserved);&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It transforms this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1. abobora&#xA;  10. abobora&#xA;  1 abobora&#xA;  10 abobora&#xA;  10.5 abobora&#xA;&#xA;1 Foo&#xA;10 Bar&#xA;10. Bar&#xA;    1 Foo&#xA;    10 Bar&#xA;    10. Bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1. abobora&#xA;  10. abobora&#xA;  1. abobora&#xA;  10. abobora&#xA;  10.5. abobora&#xA;&#xA;1. Foo&#xA;10. Bar&#xA;10. Bar&#xA;    1. Foo&#xA;    10. Bar&#xA;    10. Bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would be easier to understand without all those escape characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    %s/^(\s*\d+)(\.?\d+)?\.?(\s)/\1\2.\3/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But without them it wouldn't work :)&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2017-08-02T12:06:43.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13118" PostTypeId="2" ParentId="13106" CreationDate="2017-08-02T12:21:22.013" Score="6" Body="&lt;p&gt;I'm surprised how complicated this can be done (-;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your requirement can be met with a simple&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\s*\d\+\zs\.*/./&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^&lt;/code&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lines starting with&lt;br&gt;&#xA;&lt;code&gt;\s*&lt;/code&gt;&amp;nbsp;&amp;nbsp; any number of blanks&lt;br&gt;&#xA;&lt;code&gt;\d\+&lt;/code&gt; followed by one or more digits&lt;br&gt;&#xA;&lt;code&gt;\zs&lt;/code&gt;&amp;nbsp;&amp;nbsp; here starts the pattern that will get replaced&lt;br&gt;&#xA;&lt;code&gt;\.*&lt;/code&gt;&amp;nbsp;&amp;nbsp; any number of dots (you could also do &lt;code&gt;\.\?&lt;/code&gt;) gets replaced&lt;br&gt;&#xA;&lt;code&gt;/./&lt;/code&gt;&amp;nbsp;&amp;nbsp; by a single dot&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the trick is to always put a dot behind the number. If there already is a dot, it gets replaced by a new one.&lt;/p&gt;&#xA;" OwnerUserId="11771" LastEditorUserId="11771" LastEditDate="2017-08-03T06:11:29.697" LastActivityDate="2017-08-03T06:11:29.697" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13119" PostTypeId="1" AcceptedAnswerId="13120" CreationDate="2017-08-02T13:08:23.667" Score="1" ViewCount="847" Body="&lt;p&gt;Does anyone know a quick shortcut I can use to replace a word in a series of words connected with underscores?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Create_in_one_of_these_words&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to make, where &lt;code&gt;|&lt;/code&gt; is cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Create_in_|_of_thse_words&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7783" LastEditorUserId="5395" LastEditDate="2017-08-02T13:26:03.080" LastActivityDate="2017-08-02T14:29:17.247" Title="Replace a word in a stream of words separated with underscore" Tags="|cursor-motions|replace|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13120" PostTypeId="2" ParentId="13119" CreationDate="2017-08-02T13:17:27.917" Score="3" Body="&lt;p&gt;If you are anywhere on that line, you can try this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;0&lt;/kbd&gt; - to go to the beginign of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/one&lt;/code&gt; - to jump to the word &lt;code&gt;one&lt;/code&gt; (in this particular case even &lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt; would be enough - see &lt;code&gt;:help f&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;_&lt;/kbd&gt; - this will delete everything between cursor and character pressed after &lt;code&gt;t&lt;/code&gt; - so in this case everything till &lt;code&gt;_&lt;/code&gt; - and since we used &lt;kbd&gt;c&lt;/kbd&gt; it will leave you in insert mode - see &lt;code&gt;:help t&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-08-02T13:17:27.917" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13122" PostTypeId="2" ParentId="13119" CreationDate="2017-08-02T14:29:17.247" Score="2" Body="&lt;p&gt;Another alternative is to use &lt;a href=&quot;https://github.com/Julian/vim-textobj-variable-segment&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-variable-segment&lt;/a&gt; which along with &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-user&lt;/a&gt;, will allow you to edit segments in snakecase and camelcase words. It provides &lt;code&gt;iv&lt;/code&gt; and &lt;code&gt;av&lt;/code&gt; text objects. This would allow you to do &lt;code&gt;fociv&lt;/code&gt; to change you &lt;code&gt;one&lt;/code&gt; in your example.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-08-02T14:29:17.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13123" PostTypeId="2" ParentId="11966" CreationDate="2017-08-03T08:53:49.737" Score="0" Body="&lt;p&gt;As far as I understod you, all you have to do is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Go to split 1 &lt;code&gt;Ctrl+w 10&amp;lt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Go to split 2 &lt;code&gt;Ctrl+w 10&amp;lt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Split 1 is now 10 columns smaller, and split 3 is 10 columns bigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you do is he following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;| 0 | 1 | 2 | 3 | 4 |&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Decrease the width of split 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;| 0 | 1|  2 | 3 | 4 |&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The width you have taken from split 1 is now in split 2.&#xA;So to restore split 2 to the original size, and to pass the extra width further to split 3, you have to decrease the width of split 2 by the same amount:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;| 0 | 1| 2 |  3 | 4 |&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you have writen that &lt;code&gt;Ctrl+w &amp;lt;&lt;/code&gt; decreases split 0, it is possible, that you have to go the other way arround, and use &lt;code&gt;Ctrl+w 10&amp;gt;&lt;/code&gt;on split 4&lt;/p&gt;&#xA;" OwnerUserId="11316" LastEditorUserId="11316" LastEditDate="2017-08-03T09:10:37.440" LastActivityDate="2017-08-03T09:10:37.440" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13124" PostTypeId="1" AcceptedAnswerId="13125" CreationDate="2017-08-03T08:58:28.540" Score="3" ViewCount="1787" Body="&lt;p&gt;Considering this type of Json structure :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&#xA;    {&#xA;        &quot;id&quot;: &quot;0000000000001&quot;,&#xA;        &quot;en-US&quot;: &quot;String 1&quot;&#xA;    },&#xA;    {&#xA;        &quot;id&quot;: &quot;0000000000002&quot;,&#xA;        &quot;en-US&quot;: &quot;String 2&quot;&#xA;    }&#xA;    ...&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to get this structure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&#xA;    {&#xA;        &quot;id&quot;: &quot;0000000000001&quot;,&#xA;        &quot;en-US&quot;: &quot;String 1&quot;,&#xA;        &quot;en-GB&quot;: &quot;String 1&quot;,&#xA;        &quot;fr-FR&quot;: &quot;String 1&quot;&#xA;    },&#xA;    {&#xA;        &quot;id&quot;: &quot;0000000000002&quot;,&#xA;        &quot;en-US&quot;: &quot;String 2&quot;,&#xA;        &quot;en-GB&quot;: &quot;String 2&quot;,&#xA;        &quot;fr-FR&quot;: &quot;String 2&quot;&#xA;    }&#xA;    ...&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Right now I am able to duplicate the lines with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/en-US/t.&#xA;&#xA; [&#xA;        {&#xA;            &quot;id&quot;: &quot;0000000000001&quot;,&#xA;            &quot;en-US&quot;: &quot;String 1&quot;,&#xA;            &quot;en-US&quot;: &quot;String 1&quot;&#xA;        },&#xA;        {&#xA;            &quot;id&quot;: &quot;0000000000002&quot;,&#xA;            &quot;en-US&quot;: &quot;String 2&quot;,&#xA;            &quot;en-US&quot;: &quot;String 2&quot;&#xA;        }&#xA;        ...&#xA;    ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to concatenate that with sed to replace the string used as regex (en-US) for one of the goals without getting it worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I do the duplicate and replace together?&lt;/p&gt;&#xA;" OwnerUserId="10170" LastEditorUserId="10170" LastEditDate="2017-08-03T13:22:34.133" LastActivityDate="2023-02-10T22:23:05.387" Title="Duplicate line and replace part of line multiple times" Tags="|substitute|global-command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13125" PostTypeId="2" ParentId="13124" CreationDate="2017-08-03T09:21:56.193" Score="5" Body="&lt;p&gt;If you're willing to use one command by language you can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/en-US/t.|s/en-US/en-GB&#xA;g/en-GB/t.|s/fr-FR/en-GB&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see we reuse your command, and add another one to be executed with the &lt;code&gt;|&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; As suggested in the comments (Thank you @Doktor OSwaldo!) it is possible to put the command in a loop to avoid using it several time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let lang=['en-GB','fr-FR'] | for i in lang | execute 'g/en-US/t.|s/en-US/'.i | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Otherwise you can use a macro:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First put &lt;code&gt;en-US&lt;/code&gt; in your search register with &lt;code&gt;/en-US&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then record your macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqnYpci&quot;en-GB&amp;lt;Esc&amp;gt;Ypci&quot;fr-FR&amp;lt;ESC&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We can decompose it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq              Start recording in the register q&#xA;n               Go to the next occurence of the search (i.e &quot;en-US&quot;)&#xA;Yp              Duplicate the line&#xA;ci&quot;             Modify the content of the quotes&#xA;en-GB&amp;lt;Esc&amp;gt;      Put in the quotes 'en-GB' and exist insert mode&#xA;Yp              Duplicate the line&#xA;ci&quot;             Modify the content of the quotes&#xA;fr-FR&amp;lt;Esc&amp;gt;      Put in the quotes 'fr-FR' and exist insert mode&#xA;q               stop recording the macro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then replay the macro as many times as you have lines that you want to duplicate.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: If you want to call the macro only once (instead of specifying how many times it must be executed) you can use a recursive macro:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firs you need to empty the register which will contain the macro (by recording an empty macro):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then use the same macro but add &lt;code&gt;@q&lt;/code&gt; at the end, this way the macro will call itself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqnYpci&quot;en-GB&amp;lt;Esc&amp;gt;Ypci&quot;fr-FR&amp;lt;ESC&amp;gt;@qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One important detail is to use &lt;code&gt;set nowrapscan&lt;/code&gt; this will make the macro fail when it execute the search after the last occurence in the file. Otherwise the macro will loop infinitely in the file and you'll get a lot of duplicate lines. See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27nowrapscan%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'nowrapscan'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-08-03T14:03:55.050" LastActivityDate="2017-08-03T14:03:55.050" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="13127" PostTypeId="1" CreationDate="2017-08-03T14:47:10.753" Score="0" ViewCount="576" Body="&lt;p&gt;The functionality that I am after, is to get a list of the javascript functions present in the file that I am in. Clicking a function in the list will then take me to that function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I go about getting this functionality?&lt;/p&gt;&#xA;" OwnerUserId="605" LastActivityDate="2017-08-07T15:46:26.413" Title="Get list of javascript functions in file" Tags="|autocompletion|functions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13128" PostTypeId="2" ParentId="13105" CreationDate="2017-08-03T15:31:06.243" Score="9" Body="&lt;p&gt;I use below configuration for open and edit and reload my dot vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let mapleader=&quot;,&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;set my mapleader to &quot;,&quot; if you want to know more about mapleader enter &lt;code&gt;:h mapleader&lt;/code&gt; in Vim&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;vm :vsp $MYVIMRC&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Open my vimrc file in vertical tab whenever I pressed &lt;code&gt;,vm&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;sv :source $MYVIMRC&amp;lt;CR&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Reload my vimrc file whenever I pressed &lt;code&gt;,sv&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;w :w!&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Save my current file with ,w instead of typing :w every time.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="13699" LastActivityDate="2017-08-03T15:31:06.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13129" PostTypeId="2" ParentId="13105" CreationDate="2017-08-03T17:00:47.783" Score="1" Body="&lt;p&gt;In order to open my vimrc in a split window only if the current buffer isn't really empty, I have the following mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let vimrc=expand('&amp;lt;sfile&amp;gt;:p')&#xA;nnoremap ,vu :source &amp;lt;C-R&amp;gt;=vimrc&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;nnoremap ,ve :call &amp;lt;sid&amp;gt;OpenVimrc()&amp;lt;cr&amp;gt;&#xA;&#xA;function! s:OpenVimrc()&#xA;  if (0==strlen(bufname('%'))) &amp;amp;&amp;amp; (1==line('$')) &amp;amp;&amp;amp; (0==strlen(getline('$')))&#xA;    &quot; edit in place&#xA;    exe &quot;e &quot;.g:vimrc&#xA;  else&#xA;    exe &quot;sp &quot;.g:vimrc&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NB: As my &lt;code&gt;vimrc&lt;/code&gt; isn't named &lt;code&gt;.vimrc&lt;/code&gt; nor &lt;code&gt;_vimrc&lt;/code&gt; (in order to simplify it's portability to Windows machines), and as it is under a repository managed by the plugin manager I use, I cannot really use &lt;code&gt;$MYVIMRC&lt;/code&gt;. I have another variable computed on-the-fly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: I don't want it to be automatically loaded whenever I save it. I'd rather be explicit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For saving I already have a generic &lt;code&gt;nnoremap &amp;lt;f2&amp;gt; :update&amp;lt;cr&amp;gt;&lt;/code&gt;, we don't need anything specific to the vimrc.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-08-03T17:00:47.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13130" PostTypeId="1" AcceptedAnswerId="13131" CreationDate="2017-08-03T17:17:57.457" Score="2" ViewCount="1742" Body="&lt;p&gt;I'd like my &lt;code&gt;$PATH&lt;/code&gt; to be available to vim when running commands with &lt;code&gt;!&lt;/code&gt;.  How do I set vim's &lt;code&gt;set path=&lt;/code&gt; to my environment variable &lt;code&gt;$PATH&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2017-08-04T07:59:17.240" Title="How to set the vim path to your bash PATH?" Tags="|ex-mode|bash|path|environment-variables|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13131" PostTypeId="2" ParentId="13130" CreationDate="2017-08-03T17:27:25.020" Score="7" Body="&lt;p&gt;&lt;code&gt;&amp;amp;path&lt;/code&gt; has nothing to do with &lt;code&gt;$PATH&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also &lt;code&gt;$PATH&lt;/code&gt; is set and used. See &lt;code&gt;:echo $PATH&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also be able to change its value with &lt;code&gt;:let $PATH = $PATH.':some/path'&lt;/code&gt; -- there are a few write only things, &lt;code&gt;$PATH&lt;/code&gt; is not one of them IIRC&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-08-04T07:59:17.240" LastActivityDate="2017-08-04T07:59:17.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13132" PostTypeId="2" ParentId="6228" CreationDate="2017-08-03T22:27:39.320" Score="2" Body="&lt;p&gt;As mentioned pressing &lt;code&gt;K&lt;/code&gt; on the keyword works by searching a man page. For getting C++ man pages you may try &lt;a href=&quot;https://github.com/aitjcize/cppman&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/aitjcize/cppman&lt;/a&gt; (it gets &quot;man pages&quot; from cplusplus.com and cppreference.com).&lt;/p&gt;&#xA;" OwnerUserId="12367" LastActivityDate="2017-08-03T22:27:39.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13133" PostTypeId="2" ParentId="12827" CreationDate="2017-08-04T01:12:16.650" Score="5" Body="&lt;p&gt;I too struck this issue after updating from Jessie to Stretch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As noted in &lt;a href=&quot;https://vi.stackexchange.com/a/12831/10289&quot;&gt;another answer&lt;/a&gt;, installing &lt;a href=&quot;https://packages.debian.org/stretch/vim-nox&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;vim-nox&lt;/code&gt;&lt;/a&gt; should resolve this issue (as vim-nox in Stretch is compiled against python2). However, I figured that python3 is the way of the future. So I decided to fix it another way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need Python2 support, installing &lt;code&gt;vim-nox&lt;/code&gt; is probably the best method. Note that if you still have &lt;code&gt;vim&lt;/code&gt; installed, that will continue to be the default &quot;&lt;code&gt;vim&lt;/code&gt;&quot; on your system. If you wish to make &lt;code&gt;vim-nox&lt;/code&gt; default you need to do one of the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;completely remove &lt;code&gt;vim&lt;/code&gt;; or&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;update-alternatives&lt;/code&gt; to set &lt;code&gt;vim-nox&lt;/code&gt; as default &quot;&lt;code&gt;vim&lt;/code&gt;&quot;; or&lt;/li&gt;&#xA;&lt;li&gt;just explicitly launch &lt;code&gt;vim-nox&lt;/code&gt;, i.e.: &lt;code&gt;vim.nox &amp;lt;filename&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I fixed mine by tweaking my existing &lt;code&gt;.vim&lt;/code&gt; plugin files. All that needs changing is swap out &lt;code&gt;pyfile&lt;/code&gt; command for &lt;code&gt;py3file&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for file in /home/user/.vim/bundle/custom/plugin/*.vim; do&#xA;    sed -i &quot;s|pyfile|py3file|&quot; $file&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(obviously my username is &lt;code&gt;user&lt;/code&gt;!:)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That solved most of the issues, but one of my &lt;code&gt;.py&lt;/code&gt; plugins then starting giving some different (python3) errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/user/.vim/bundle/custom/plugin/rst.vim:&#xA;line    2:&#xA;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;  File &quot;/home/user/.vim/bundle/custom/plugin/rst.py&quot;, line 100&#xA;    vim.command(&quot;let b:nestings = &quot; + `self.nestings`)&#xA;                                      ^&#xA;SyntaxError: invalid syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I used the &lt;code&gt;2to3&lt;/code&gt; python tool to update that particular script to python3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2to3 -w /home/user/.vim/bundle/custom/plugin/rst.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All fixed! :)&lt;/p&gt;&#xA;" OwnerUserId="10289" LastEditorUserId="10289" LastEditDate="2017-08-04T01:30:34.657" LastActivityDate="2017-08-04T01:30:34.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13134" PostTypeId="1" AcceptedAnswerId="13135" CreationDate="2017-08-04T06:09:10.693" Score="8" ViewCount="527" Body="&lt;p&gt;I'd like to write a plugin that automatically sets the &lt;code&gt;foldlevel&lt;/code&gt; of a newly opened document so that as much of the document fits on the screen as possible. (In other words, I'd like to make sure short documents open fully expanded while long documents open mostly collapsed.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any built-in function in vim that reports the number of visible lines in a document, given the current fold state or a particular fold level? (&lt;em&gt;I.e.,&lt;/em&gt; closed folds count as one line, but lines you'd have to scroll down to see are counted, too.)&lt;/p&gt;&#xA;" OwnerUserId="2593" LastEditorUserId="343" LastEditDate="2017-12-06T11:26:41.123" LastActivityDate="2017-12-06T11:26:41.123" Title="Count number of visible lines in document with folding?" Tags="|folding|functions|counting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13135" PostTypeId="2" ParentId="13134" CreationDate="2017-08-04T09:51:58.080" Score="6" Body="&lt;p&gt;Nice idea! Here's a basic function that achieves your goal using a different technique:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FitOnPage()&#xA;  normal! zR&#xA;  while &amp;amp;foldlevel &amp;gt; 0&#xA;    if line('w0') == 1 &amp;amp;&amp;amp; line('w$') == line('$')&#xA;      break&#xA;    endif&#xA;    normal! zm&#xA;  endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works by first expanding all the folds. It then closes folds (globally) until the entire document is on screen or all the folds are closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It checks if the whole file is on screen by checking if the first and last lines displayed are the first and last lines of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could improve this a bit by closing folds individually, but that would be a lot more complicated.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-08-09T09:04:21.200" LastActivityDate="2017-08-09T09:04:21.200" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13136" PostTypeId="2" ParentId="13106" CreationDate="2017-08-04T12:41:16.527" Score="2" Body="&lt;p&gt;You're almost there, what you need is &lt;code&gt;\&amp;gt;&lt;/code&gt; at the end of the regular expression like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(\s*\d\+\)\.\@!\&amp;gt;/\1\.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even better:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\s*\d\+\.\@!\&amp;gt;\zs/.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; A &lt;code&gt;.&lt;/code&gt; in the replacement part of the &lt;code&gt;:substitute&lt;/code&gt; command is literal so you can remove the leading &lt;code&gt;\&lt;/code&gt;. &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub%2dreplace%2dspecial&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help sub-replace-special&lt;/code&gt;&lt;/a&gt; describes what needs to be escaped and its meaning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you want to make it work for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10.10 something&#xA;10.10.10 something&#xA;10.10.10.10 something&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on, you'll need a regular expression that's similar to yours:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\s*[0-9.]*\d\.\@!\&amp;gt;\zs/.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Explanation&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^\s*&lt;/code&gt; Whitespaces at the beginning of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[0-9.]*&lt;/code&gt; Digits and literal dots that match the correct part of the string, i.e., the &lt;code&gt;10.1&lt;/code&gt;, &lt;code&gt;10.10.1&lt;/code&gt; and &lt;code&gt;10.10.10.1&lt;/code&gt; in the previous example.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\d\.\@!&lt;/code&gt; The digit that requires a dot after it.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\&amp;gt;&lt;/code&gt; The previous digit at the end of a word (see &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5c%3e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\&amp;gt;&lt;/code&gt;&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs\&lt;/code&gt; If the previous regular expression matches,  ignore it and match what follows, i.e., just after the end of the word and before the whitespace in the previous example (see &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5czs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\zs&lt;/code&gt;&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="6698" LastEditDate="2017-08-04T12:48:07.697" LastActivityDate="2017-08-04T12:48:07.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13137" PostTypeId="1" AcceptedAnswerId="13138" CreationDate="2017-08-04T12:43:50.300" Score="4" ViewCount="1176" Body="&lt;p&gt;I'm new to &lt;code&gt;vim&lt;/code&gt; and bumped into a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Short question -- will &lt;code&gt;vim&lt;/code&gt; tell me why it chose to highlight certain text in a certain way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long question --&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;vimdiff&lt;/code&gt; to compare two files, and the &quot;DiffChange&quot; highlight uses a purple background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the files I'm diff'ing are &lt;code&gt;puppet&lt;/code&gt; files, and there are quite a few possible highlights that show the text in the same purple color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I'd really like to do is move to a specific character and have &lt;code&gt;vim&lt;/code&gt; tell me &quot;this character is subject to the following highlights&quot; so that I know which one (for the text color) needs to be changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that possible?&lt;/p&gt;&#xA;" OwnerUserId="894" LastEditorUserId="2736" LastEditDate="2017-08-04T19:59:19.017" LastActivityDate="2017-08-04T19:59:19.017" Title="How to identify the highlight groups in use on a particular character?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ClosedDate="2019-01-10T01:59:36.123" ContentLicense="CC BY-SA 3.0" />
  <row Id="13138" PostTypeId="2" ParentId="13137" CreationDate="2017-08-04T13:03:49.817" Score="3" Body="&lt;p&gt;from my .vimrc (all in one line):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;M-i&amp;gt; :echo &quot;hi&amp;lt;&quot; . synIDattr(synID(line(&quot;.&quot;),col(&quot;.&quot;),1),&quot;name&quot;) . '&amp;gt; trans&amp;lt;' . synIDattr(synID(line(&quot;.&quot;),col(&quot;.&quot;),0),&quot;name&quot;) .&quot;&amp;gt; lo&amp;lt;&quot; . synIDattr(synIDtrans(synID(line(&quot;.&quot;),col(&quot;.&quot;),1)),&quot;name&quot;) . &quot;&amp;gt;&quot;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;move to your character and press Alt-i.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to choose a different key for this mapping.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-08-04T13:03:49.817" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13139" PostTypeId="1" AcceptedAnswerId="13140" CreationDate="2017-08-04T13:12:15.253" Score="1" ViewCount="272" Body="&lt;p&gt;I do a lot of editing in vim and am constantly opening up files using &lt;code&gt;:e&lt;/code&gt; or &lt;code&gt;:new&lt;/code&gt; ...etc. However, when I quit vim, I do not have the files I edited in my &lt;code&gt;.bash_history&lt;/code&gt;. Since I keep finding myself needing this, I thought I'd add an &lt;code&gt;au&lt;/code&gt; recipe like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *&#xA;\ [ check if %:p is same as new file being opened ...is that &amp;lt;afile&amp;gt;?? ] |&#xA;\         !history -s vim &amp;lt;...&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was wondering whether there are any downsides to this ? and secondly, if not, what's the exact idiomatic vimscript way to express this ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: After a bit of reading, I discovered the &lt;code&gt;oldfiles&lt;/code&gt; and &lt;code&gt;browse oldfiles&lt;/code&gt; commands, so as an alternative way to solve my request -- what would be the set of vimscript spells to invoke that will tell vim -- open up the &lt;code&gt;oldfiles&lt;/code&gt; in a buffer if no arguments were provided on the commandline (as opposed to an empty &lt;code&gt;:e&lt;/code&gt; or &lt;code&gt;:new&lt;/code&gt;) ? Essentially, override the vim welcome buffer (which has the centered text of version, help etc), with &lt;code&gt;oldfiles&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...or ...add the files edited in current session to bash_history on exit ...or a different way to achieve the same effect ?&lt;/p&gt;&#xA;" OwnerUserId="11553" LastEditorUserId="11553" LastEditDate="2017-08-04T13:50:34.403" LastActivityDate="2017-08-04T14:12:13.660" Title="Autocommand to add edited filename to bash history" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13140" PostTypeId="2" ParentId="13139" CreationDate="2017-08-04T14:04:49.550" Score="3" Body="&lt;p&gt;Using &lt;code&gt;browse oldfiles&lt;/code&gt; you can create the following autocommand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! VimEnter * if argc() == 0 | browse oldfiles | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is triggered when Vim starts (&lt;code&gt;VimEnter&lt;/code&gt;), it checks if any files were passed as parameter from the command line (&lt;code&gt;if argc() == 0&lt;/code&gt;) and if none were passed it executes &lt;code&gt;browse oldfiles&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details see&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocommand%2devents&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h autocommand-events&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#argc%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h argc()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I don't think inserting the filenames in your bash history is a good idea because for at least two reasons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It might create entries that you don't want&lt;/li&gt;&#xA;&lt;li&gt;I don't know how you'd expected to record the different files but if you open two files and want to access them easily it can be a problem: if you record &lt;code&gt;vim file1&lt;/code&gt; and &lt;code&gt;vim file2&lt;/code&gt; you won't get a command to open both in your history, if you record &lt;code&gt;vim file1 file2&lt;/code&gt; and want to repon only &lt;code&gt;file1&lt;/code&gt; you get the opposite problem.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also maybe you might want to check plugins such as &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;CtrlP&lt;/a&gt; which allow you to get a list of Most Recent Used files don't I won't give you any advice about that because I've never used a plugin to do that.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-08-04T14:12:13.660" LastActivityDate="2017-08-04T14:12:13.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13141" PostTypeId="1" AcceptedAnswerId="13142" CreationDate="2017-08-04T15:21:04.833" Score="5" ViewCount="947" Body="&lt;p&gt;I'm troubleshooting syntax highlighting in my &lt;code&gt;.vimrc&lt;/code&gt; settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My setup is a little complex because I have some filetype settings for plain text and other settings for programming files (using filename extension handlers). It's all very well organized. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is even my text only files have syntax highlighting, and I only noticed when I changed to a new colorscheme. Random words are highlighted in text file. Programming files are OK. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Help me find the settings I should check, &lt;em&gt;What are all of the global mechanisms for highlighting text?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking I need to reorder these settings, so I keep highlighting in code and remove highlighting from text.&lt;/p&gt;&#xA;" OwnerUserId="1694" LastEditorUserId="1694" LastEditDate="2017-08-04T15:35:08.100" LastActivityDate="2017-08-05T07:22:09.070" Title="What are the global settings for syntax highlighting?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13142" PostTypeId="2" ParentId="13141" CreationDate="2017-08-04T18:16:00.507" Score="5" Body="&lt;p&gt;&lt;code&gt;:help syntax-loading&lt;/code&gt; has detailed description of how syntax gets set up. For instance this section on file loading:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Loading the file triggers the BufReadPost autocommands.&#xA;|&#xA;+-  If there is a match with one of the autocommands from |synload-3|&#xA;|   (known file types) or |synload-4| (user's file types), the 'filetype'&#xA;|   option is set to the file type.&#xA;|&#xA;+-  The autocommand at |synload-5| is triggered.  If the file type was not&#xA;|   found yet, then scripts.vim is searched for in 'runtimepath'.  This&#xA;|   should always load $VIMRUNTIME/scripts.vim, which does the following.&#xA;|   |&#xA;|   +-  Source the user's optional file, from the *myscriptsfile*&#xA;|   |   variable.  This is for backwards compatibility with Vim 5.x only.&#xA;|   |&#xA;|   +-  If the file type is still unknown, check the contents of the file,&#xA;|       again with checks like &quot;getline(1) =~ pattern&quot; as to whether the&#xA;|       file type can be recognized, and set 'filetype'.&#xA;|&#xA;+-  When the file type was determined and 'filetype' was set, this&#xA;|   triggers the FileType autocommand |synload-6| above.  It sets&#xA;|   'syntax' to the determined file type.&#xA;|&#xA;+-  When the 'syntax' option was set above, this triggers an autocommand&#xA;|   from |synload-1| (and |synload-2|).  This find the main syntax file in&#xA;|   'runtimepath', with this command:&#xA;|       runtime! syntax/&amp;lt;name&amp;gt;.vim&#xA;|&#xA;+-  Any other user installed FileType or Syntax autocommands are&#xA;triggered.  This can be used to change the highlighting for a specific&#xA;syntax.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Perhaps you can piece things together by going through this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Moving the winning idea from a comment to here...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for a more concrete idea, if you do &lt;code&gt;:hi&lt;/code&gt; you can try to match the text colors with a syntax group and see if that gives you some clues. First thing that comes to mind as far as coloring of plain text is search or incremental search. The next one that comes to mind is spelling errors or warnings. (If it's spelling that can be checked by simply doing typing &lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt; and seeing if the cursor moves to a highlighted word.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-08-05T07:22:09.070" LastActivityDate="2017-08-05T07:22:09.070" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13146" PostTypeId="1" AcceptedAnswerId="13147" CreationDate="2017-08-05T17:41:38.263" Score="3" ViewCount="56" Body="&lt;p&gt;I'm writing a new plugin and as part of a function, I need to check that a register contains a particular &lt;strong&gt;pattern&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked the official documentation but couldn't manage to use any of the &lt;code&gt;search()&lt;/code&gt; or &lt;code&gt;substitute()&lt;/code&gt; functions for this purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how this could be done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Suppose the register is &lt;code&gt;&quot;o&lt;/code&gt; and the pattern is &lt;em&gt;Image&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="13722" LastActivityDate="2017-08-05T17:53:54.153" Title="How to check if a pattern is contained in a register's content?" Tags="|search|regular-expression|register|find|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13147" PostTypeId="2" ParentId="13146" CreationDate="2017-08-05T17:53:54.153" Score="4" Body="&lt;p&gt;To get the content of the register &lt;code&gt;&quot;o&lt;/code&gt; you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getreg('o')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will return the content of the register as a string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To match a string you can use &lt;code&gt;match()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo match(getreg('o'), 'image')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll get &lt;code&gt;-1&lt;/code&gt; if the register doesn't contain &lt;code&gt;image&lt;/code&gt; and a positive interger otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getreg%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getreg()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#match%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h match()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-08-05T17:53:54.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13148" PostTypeId="1" AcceptedAnswerId="13150" CreationDate="2017-08-06T09:52:55.887" Score="0" ViewCount="88" Body="&lt;p&gt;I have the next lines of text in a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;eslint.vim&#xA;flow.vim&#xA;jscs.vim&#xA;jshint.vim&#xA;standard.vim&#xA;xo.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I yank names (without '.vim' part)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even better would be to format it to look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'eslint', 'flow', 'jscs', 'jshint', 'standard', 'xo'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13649" LastEditorUserId="1841" LastEditDate="2017-08-06T11:04:52.623" LastActivityDate="2017-08-06T11:04:52.623" Title="Select several lines untill a specific symbol" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13149" PostTypeId="1" CreationDate="2017-08-06T10:53:37.757" Score="0" ViewCount="487" Body="&lt;p&gt;I outsourced a few sections of my &lt;code&gt;.vimrc&lt;/code&gt; to &lt;code&gt;.vim/custom/binds/foo.vim&lt;/code&gt; to seperate binds for different languages. I know about &lt;code&gt;after&lt;/code&gt; but I want to keep the structure I am currently using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often find my self changing mappings in &lt;code&gt;foo.vim&lt;/code&gt; while working in some &lt;code&gt;file.foo&lt;/code&gt;, and &lt;strong&gt;don't want to close and reopen &lt;code&gt;file.foo&lt;/code&gt; file every time I make changes to &lt;code&gt;foo.vim&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;code&gt;noremap \c0 &amp;lt;Esc&amp;gt;:source&amp;lt;Space&amp;gt;~/.vimrc&amp;lt;Enter&amp;gt;&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; and it performs exactly what I want for the mappings in the rc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to include &lt;code&gt;runtime! custom/binds/*.vim&lt;/code&gt; but this does not seem to work. Not even when executed manually.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help runtime&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When {file} contains wildcards it is expanded to all&#xA;                        matching files.  Example:&#xA;                                :runtime! plugin/*.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what am I missing here?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;inside my &lt;code&gt;.vimrc&lt;/code&gt; I &lt;code&gt;:source ~/.vim/custom/binds/foo.vim&lt;/code&gt;. so sourcing works fine, but I have to do this for every file seperatly.&lt;/p&gt;&#xA;" OwnerUserId="13691" LastEditorUserId="13691" LastEditDate="2017-08-11T20:45:05.760" LastActivityDate="2017-08-11T20:45:05.760" Title="source multiple files with map" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13150" PostTypeId="2" ParentId="13148" CreationDate="2017-08-06T11:00:39.833" Score="1" Body="&lt;p&gt;I think the easiest solution is to use two substitute commands:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First remove the &lt;code&gt;.vim&lt;/code&gt; part, join all the lines and add comma between the words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/.vim/\n/, /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will give you this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;eslint, flow, jscs, jshint, standard, xo, &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then surround the words with quotes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\w\+/'\0'/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'eslint', 'flow', 'jscs', 'jshint', 'standard', 'xo', &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the last comma that you might need to delete with &lt;code&gt;$x&lt;/code&gt; for example.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-08-06T11:00:39.833" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13151" PostTypeId="1" CreationDate="2017-08-06T11:38:06.700" Score="3" ViewCount="4963" Body="&lt;p&gt;I have vim 7.4 Huge version with X11-Athena GUI installed on my laptop running ubuntu 16.04. I would like to safely switch to vim-gtk.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have to uninstall existing vim installation and install vim-gtk from scratch, or is there a better way to achieve the same? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; &#xA;I have installed &lt;code&gt;vim-gtk3&lt;/code&gt;. Following are some additional information regarding my setup:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I have compiled vim from source, and &lt;code&gt;vim --version&lt;/code&gt; returns the output appended below&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  4 2016 01:01:13)&#xA;  Huge version with X11-Athena GUI.  Features included (+) or not (-):&lt;br&gt;&#xA;  +arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;  +autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;  +balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;  +browse          +folding         +mouse_xterm     -tcl&#xA;  ++builtin_terms  -footer          +multi_byte      +terminfo&#xA;  +byte_offset     +fork()          +multi_lang      +termresponse&#xA;  +cindent         +gettext         -mzscheme        +textobjects&#xA;  +clientserver    -hangul_input    +netbeans_intg   +title&#xA;  +clipboard       +iconv           +path_extra      +toolbar&#xA;  +cmdline_compl   +insert_expand   -perl            +user_commands&#xA;  +cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;  +cmdline_info    +keymap          +postscript      +virtualedit&#xA;  +comments        +langmap         +printer         +visual&#xA;  +conceal         +libcall         +profile         +visualextra&#xA;  +cryptv          +linebreak       +python          +viminfo&#xA;  +cscope          +lispindent      -python3         +vreplace&#xA;  +cursorbind      +listcmds        +quickfix        +wildignore&#xA;  +cursorshape     +localmap        +reltime         +wildmenu&#xA;  +dialog_con_gui  -lua             +rightleft       +windows&#xA;  +diff            +menu            -ruby            +writebackup&#xA;  +digraphs        +mksession       +scrollbind      +X11&#xA;  -dnd             +modify_fname    +signs           +xfontset&#xA;  -ebcdic          +mouse           +smartindent     +xim&#xA;  +emacs_tags      +mouseshape      -sniff           +xsmp_interact&#xA;  +eval            +mouse_dec       +startuptime     +xterm_clipboard&#xA;  +ex_extra        -mouse_gpm       +statusline      -xterm_save&#xA;  +extra_search    -mouse_jsbterm   -sun_workshop&lt;br&gt;&#xA;  +farsi           +mouse_netterm   +syntax&lt;br&gt;&#xA;     system vimrc file: &quot;$VIM/vimrc&quot;&#xA;       user vimrc file: &quot;$HOME/.vimrc&quot;&#xA;   2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;        user exrc file: &quot;$HOME/.exrc&quot;&#xA;    system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;      user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;  2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;      system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;    fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;  Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_ATHENA   -I/usr/local/include  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&lt;br&gt;&#xA;  Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim -lXaw -lXmu -lXext -lXt -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -ldl  -lm -ltinfo -lnsl   -ldl    -L/usr/lib/python2.7 -lpython2.7      &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;code&gt;update-alternatives --display vim&lt;/code&gt; returns &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;vim - auto mode&lt;br&gt;&#xA;    link best version is /usr/bin/vim.gtk3&lt;br&gt;&#xA;    link currently points to /usr/bin/vim.gtk3&lt;br&gt;&#xA;    link vim is /usr/bin/vim&lt;br&gt;&#xA;  /usr/bin/vim.gtk3 - priority 50  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;code&gt;update-alternatives --display gvim&lt;/code&gt; returns&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;gvim - auto mode&lt;br&gt;&#xA;  link best version is /usr/bin/vim.gtk3&lt;br&gt;&#xA;  link currently points to /usr/bin/vim.gtk3&lt;br&gt;&#xA;  link gvim is /usr/bin/gvim&lt;br&gt;&#xA;  /usr/bin/vim.gtk3 - priority 50  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;gvim continues to launch vim in Athena gui. &lt;/p&gt;&#xA;" OwnerUserId="8537" LastEditorUserId="14522" LastEditDate="2019-09-13T07:33:38.870" LastActivityDate="2019-09-13T07:33:38.870" Title="How to safely switch from vim-athena to vim-gtk?" Tags="|gvim|linux-ubuntu|x11|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13152" PostTypeId="2" ParentId="13151" CreationDate="2017-08-06T13:52:09.373" Score="4" Body="&lt;p&gt;You don't have to uninstall any of the existing packages.  The vim-{athena,gtk,gtk3,nox} etc. packages just provide the Vim binary built with different feature sets and linked against different GUI toolkits.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Install the &lt;code&gt;vim-gtk&lt;/code&gt; (or on newer systems &lt;code&gt;vim-gtk3&lt;/code&gt;) package&lt;/li&gt;&#xA;&lt;li&gt;Check whether the &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;gvim&lt;/code&gt; alternatives automatically switched to using &lt;code&gt;/usr/bin/vim.gtk&lt;/code&gt; (or &lt;code&gt;/usr/bin/vim.gtk3&lt;/code&gt;).  Note: this should be the case if you haven't manually set priorities on the alternatives.&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;$ update-alternatives --display vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;If you want to change the alternative, run &lt;code&gt;update-alternatives --config vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Repeat for gvim&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-08-06T13:52:09.373" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13153" PostTypeId="1" AcceptedAnswerId="13154" CreationDate="2017-08-06T14:02:58.123" Score="1" ViewCount="798" Body="&lt;p&gt;I'm trying to combine two features of vim, but it doesn't seem to be possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/starting.html#vim-arguments&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim -&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first feature is invoking vim with a single-dash argument, which causes vim to read stdin and use the resulting text as the contents of the initial scratch buffer. (Fun fact: vim then uses stderr to attach to the terminal.) For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf 'a\xC0b'| vim -;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above will cause the initial buffer to have contents &lt;code&gt;aÀb&lt;/code&gt; with &lt;code&gt;'fileencoding'&lt;/code&gt; set to latin1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#:e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:e&lt;/code&gt;&lt;/a&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#[++opt]&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;++enc=X&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second feature is forcing vim to interpret a file's text in a character encoding different from what vim's autodetection algorithm would settle on. This can be done by running &lt;code&gt;:e ++enc=X&lt;/code&gt; where &lt;code&gt;X&lt;/code&gt; is the desired encoding. Irrelevantly, I'm also interested in using the &lt;code&gt;++bad=keep&lt;/code&gt; edit option to specify handling of encoding-invalid bytes. So, for example, running &lt;code&gt;:e ++enc=utf-8 ++bad=keep&lt;/code&gt; will cause vim to reload the current file assuming its contents comprise UTF-8 text, and keeping bytes that are invalid UTF-8 in the buffer (as opposed to stripping them or replacing them with a valid character, the latter being vim's default).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#:e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:e&lt;/code&gt;&lt;/a&gt; command only works on unmodified non-scratch buffers, since it reloads the entire file from disk. The modification state is not the critical roadblock here, since I could easily &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27modified%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:setlocal nomod&lt;/code&gt;&lt;/a&gt;, but I don't see any way around the scratchness problem. The &lt;code&gt;:e&lt;/code&gt; command simply cannot be used in a scratch buffer, since there's no disk file to reload.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on my thinking, when loading a file at startup by specifying it as an argument on the shell command-line, I really think there should be some way of communicating to vim how it should interpret the file's text &lt;em&gt;before&lt;/em&gt; it loads it the first time, since there's no point in letting vim autodetect an incorrect encoding and then fixing it up after-the-fact by reloading the entire file with an &lt;code&gt;:e&lt;/code&gt; command. I think this should apply whether you're reading from stdin or loading one or more disk files at startup, but obviously it's more of a problem for the stdin case, since &lt;code&gt;:e&lt;/code&gt; can't work for a scratch buffer, as I described a moment ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some things I've tried, knowing they wouldn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf 'a\xC0b'| vim - ++enc=utf-8 ++bad=keep; ## E492: Not an editor command: +enc=utf-8&#xA;printf 'a\xC0b'| vim - -c 'e ++enc=utf-8 ++bad=keep'; ## E37: No write since last change&#xA;printf 'a\xC0b'| vim - -c 'e! ++enc=utf-8 ++bad=keep'; ## E32: No file name&#xA;printf 'a\xC0b'| vim - -c 'setlocal nomod| e ++enc=utf-8 ++bad=keep'; ## E32: No file name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution idea&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've thought of one indirect solution, but it's not as convenient as a direct solution would be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, instead of running the text-generation command in the shell and piping it to vim, I'll run the text-generation command from vim and read its output into a readymade scratch buffer using &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#:r&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:r&lt;/code&gt;&lt;/a&gt;, which fortunately supports the same &lt;code&gt;++opt&lt;/code&gt; interpretation options as &lt;code&gt;:e&lt;/code&gt;. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r ++enc=utf-8 ++bad=keep !printf 'a\xC0b';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim displays the resulting UTF-8 buffer as &lt;code&gt;a&amp;lt;c0&amp;gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works, but it's just not as convenient as it could be. I reiterate my earlier point that there should be some way of specifying the initial encoding interpretation at startup, whether reading from stdin or from a disk file. I'm not aware of such a mechanism, but I'm holding out an ounce of hope that a more knowledgeable vim user will know of a way to do this.&lt;/p&gt;&#xA;" OwnerUserId="8927" LastActivityDate="2017-08-08T20:08:45.833" Title="How to combine reading from stdin (- invocation argument) with ++opt" Tags="|invocation|startup|encoding|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13154" PostTypeId="2" ParentId="13153" CreationDate="2017-08-06T14:46:19.533" Score="1" Body="&lt;p&gt;This should solve part of the problem. Try&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;printf 'a\xC0b'| vim - --cmd &quot;set fencs=utf8&quot; -c &quot;set fenc=utf8&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It reads the file as utf-8 as you wanted, but the ++bad=keep thing is not included.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-08-06T14:46:19.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13155" PostTypeId="1" AcceptedAnswerId="13593" CreationDate="2017-08-06T14:57:07.977" Score="8" ViewCount="1178" Body="&lt;p&gt;matchit's &lt;code&gt;%&lt;/code&gt;/&lt;code&gt;g%&lt;/code&gt; are simple enough to use, but I'm having trouble understanding the other mappings, which sound potentially useful but don't seem to work in any understandable way.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;]%  Go to [count] next unmatched group, as specified by&#xA;    |b:match_words|.  Similar to |]}|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would expect this maybe to allow me to jump to &lt;code&gt;endif&lt;/code&gt;, &lt;code&gt;endfunction&lt;/code&gt;, etc.  Take the following vimscript example, using the built-in vim ftplugin (&lt;code&gt;b:match_words&lt;/code&gt; appears to be set.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SuperTab()&#xA;  let l:part = strpart(getline('.'),col('.')-2,1)&#xA;  if (l:part=~'^\W\?$')&#xA;      return &quot;\&amp;lt;Tab&amp;gt;&quot;&#xA;  else&#xA;      return &quot;\&amp;lt;C-n&amp;gt;&quot;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;[%&lt;/code&gt; most of the time jumps to the &lt;code&gt;function!&lt;/code&gt;, occasionally (inconsistently depending on cursor position) jumps to the &lt;code&gt;if&lt;/code&gt;, and totally ignores &lt;code&gt;(&lt;/code&gt;s.  &lt;code&gt;]%&lt;/code&gt; jumps to &lt;code&gt;)&lt;/code&gt;s and nothing else.  &lt;code&gt;va%&lt;/code&gt; behaves identically to &lt;code&gt;[%&lt;/code&gt; in this example and does not select anything.  Is this normal behavior?  Is there some example where these mappings make sense?&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-09-16T11:42:21.403" Title="What do matchit.vim's [%, ]%, a% do?" Tags="|cursor-movement|plugin-matchit|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13157" PostTypeId="2" ParentId="12806" CreationDate="2017-08-06T22:17:29.053" Score="12" Body="&lt;p&gt;You can do this by setting &lt;code&gt;textwidth&lt;/code&gt;, and removing &lt;code&gt;t&lt;/code&gt; from &lt;code&gt;formatoptions&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=29&#xA;set formatoptions-=t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You also need to have the &lt;code&gt;q&lt;/code&gt; option enabled in your &lt;code&gt;formatoptions&lt;/code&gt; to use &lt;code&gt;gq&lt;/code&gt;. It seems to always be on for me, but you might want to add a &lt;code&gt;set formatoptions+=q&lt;/code&gt; to be on the safe side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shouldn't be a problem with your current usecase, but the &lt;code&gt;c&lt;/code&gt; option auto-wraps comments, so if you don't want that do &lt;code&gt;set formatoptions-=c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info see: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help formatoptions &quot; Not much info.&#xA;:help fo-table      &quot; All the options in detail.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10139" LastActivityDate="2017-08-06T22:17:29.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13158" PostTypeId="1" AcceptedAnswerId="13203" CreationDate="2017-08-06T22:31:01.010" Score="1" ViewCount="841" Body="&lt;p&gt;This should be easy but it seems to be a blind spot in vim. I'm looking for a short one line mapping, let's say to &lt;code&gt;&amp;lt;leader&amp;gt;r&lt;/code&gt;, to right-align text inside a visual block selection. For example, consider the following sample text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a1   a&#xA;b22   b&#xA;c234   c&#xA;d4444   d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After, in a visual block, selecting exactly the first '1' to the last '4' (a total of 16 characters) as so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a||||a&#xA;b|||| b&#xA;c||||  c&#xA;d||||   d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and executing our command we should get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a   1a&#xA;b  22 b&#xA;c 234  c&#xA;d4444   d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If we could pipe the block selection to the UNIX utility &lt;code&gt;rs&lt;/code&gt; using &lt;code&gt;rs -j 0 1&lt;/code&gt; and replace the text in-place that would satisfy the problem. Presumably you should be able to delete (via &lt;code&gt;d&lt;/code&gt;), operate on the register, and paste (via &lt;code&gt;p&lt;/code&gt;), but I have not yet been able to get that to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim already has &lt;code&gt;:right&lt;/code&gt; which works linewise but no mechanism that seems to work on selections (for more on why I consider this a blind spot see &lt;code&gt;:h *:visual_example*&lt;/code&gt;). I have added the letters &lt;code&gt;abcd&lt;/code&gt; to break solutions which only work linewise instead of selection-wise and to break solutions which hinge on a common separator. The &lt;code&gt;234&lt;/code&gt; string breaks trivial mirrors which aren't right-aligns in general. I have already reviewed the various table, align, and justify plugins and am not interested in them as an answer. If at all possible functions should be avoided.&lt;/p&gt;&#xA;" OwnerUserId="13731" LastEditorUserId="13731" LastEditDate="2017-08-10T22:12:29.827" LastActivityDate="2017-08-11T13:17:21.727" Title="simple map to right align text selection within visual block?" Tags="|key-bindings|visual-mode|formatting|visual-block|alignment|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13159" PostTypeId="1" AcceptedAnswerId="13160" CreationDate="2017-08-07T01:01:38.227" Score="9" ViewCount="1201" Body="&lt;p&gt;I have been looking through many resources but cannot seem to find the definition of an atom. In the website link &lt;a href=&quot;http://vimregex.com/&quot; rel=&quot;noreferrer&quot;&gt;http://vimregex.com/&lt;/a&gt;, how does an atom defer from a character in regex? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\{-}&#xA;matches 0 or more of the preceding atom, as few as possible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\+&#xA;matches 1 or more of the preceding characters...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12103" LastEditorUserId="4472" LastEditDate="2017-08-07T02:06:09.970" LastActivityDate="2017-08-07T11:27:12.293" Title="What is an atom?" Tags="|regular-expression|terminology|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13160" PostTypeId="2" ParentId="13159" CreationDate="2017-08-07T01:09:25.453" Score="10" Body="&lt;p&gt;A pattern is made up of atoms, from &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2fatom&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help /atom&lt;/code&gt;&lt;/a&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;An atom can be one of a long list of items.  Many atoms match one&#xA;character in the text.  It is often an ordinary character or a character&#xA;class.  Braces can be used to make a pattern into an atom.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;An atom can be one of a long list of items&lt;/em&gt;, refer to  &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2fordinary%2datom&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help /ordinary-atom&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#pattern%2datoms&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help pattern-atoms&lt;/code&gt;&lt;/a&gt; to see the &lt;em&gt;long list of items&lt;/em&gt;. For example, &lt;code&gt;$&lt;/code&gt; (end-of-line) and &lt;code&gt;^&lt;/code&gt; (start-of-line) don't match any character but rather they describe a characteristic of the pattern. See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2fzero%2dwidth&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help /zero-width&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;Many atoms match one character in the text&lt;/em&gt;. That's why atom and character are used interchangeably, for example &lt;code&gt;a&lt;/code&gt; matches a literal &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;[0-9a-z]&lt;/code&gt; matches one character of the range, &lt;code&gt;\$&lt;/code&gt; and &lt;code&gt;\^&lt;/code&gt; match a literal &lt;code&gt;$&lt;/code&gt; and &lt;code&gt;^&lt;/code&gt; respectively. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;Parentheses can be used to make a pattern into an atom&lt;/em&gt;, like &lt;code&gt;\(foo\)&lt;/code&gt; in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(foo\)\?bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, the atom &lt;code&gt;\(foo\)&lt;/code&gt; matches three characters or atoms: &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;o&lt;/code&gt; and &lt;code&gt;o&lt;/code&gt; .&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could find some examples &lt;a href=&quot;https://vi.stackexchange.com/q/13106/6698&quot;&gt;in this question&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="6698" LastEditDate="2017-08-07T11:27:12.293" LastActivityDate="2017-08-07T11:27:12.293" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13161" PostTypeId="1" CreationDate="2017-08-07T06:14:33.383" Score="1" ViewCount="110" Body="&lt;p&gt;In vim, when executing a command with a range specified, the cursor will move to the end of the range. For example, after &lt;code&gt;10;+4print&lt;/code&gt;, cursor will be at line 14 wherever you run this command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q1: Is there a method to hold the cursor while executing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, consider a user defined command with range, such as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -range Test call TestFunc(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;)&#xA;function TestFunc(line1, line2)&#xA;    echo line('.')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with line number shown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q2. run &lt;code&gt;:10;+4Test&lt;/code&gt; will have cursor stop at line 10 and the result will has is also 10. This means the function is called after setting the cursor to line 10. The &lt;code&gt;current line&lt;/code&gt; where the command is executed is not accessible (at least using &lt;code&gt;line('.')&lt;/code&gt;). How should I get the correct line number in the function?&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="1841" LastEditDate="2017-08-07T09:02:40.660" LastActivityDate="2017-08-07T13:19:21.337" Title="specify a range for command but not move cursor" Tags="|range|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13162" PostTypeId="1" AcceptedAnswerId="13165" CreationDate="2017-08-07T10:11:37.053" Score="1" ViewCount="5312" Body="&lt;p&gt;I recently wanted to have a mapping that I could trigger from &lt;code&gt;normal mode&lt;/code&gt; as well as from &lt;code&gt;insert mode&lt;/code&gt;. Writing the same mapping for multiple modes annoyed me as it cluttered my .vimrc and requires me to make the same changes multiple times.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It was pointed out to me, that no such mapping mode exists. See here:&#xA;&lt;a href=&quot;https://superuser.com/questions/1236999/vim-multiple-specific-mappings&quot;&gt;https://superuser.com/questions/1236999/vim-multiple-specific-mappings&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It was also pointed out, that for very simple mappings I could use a function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DoubleMap(x, y)&#xA;  exec &quot;nmap &quot;.x.&quot; &quot;.y&#xA;  exec &quot;imap &quot;.x.&quot; &quot;.y&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I now tried the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created a mapping that takes care of what ever I want to achieve, without using &lt;code&gt;nore&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;COMPLEX-KEY&amp;gt; &amp;lt;ACTION&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I created mappings for the modes I wanted the mapping to work in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;KEY&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;COMPLEX-KEY&amp;gt;&amp;lt;Esc&amp;gt;i&#xA;nnoremap &amp;lt;KEY&amp;gt; &amp;lt;COMPLEX-KEY&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should allow me to outsource complex mappings to another part of the .vimrc or another file altogether, as well as for easier changes and readability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this does not work. Is there a way to trigger a mapping from within a mapping?&lt;/p&gt;&#xA;" OwnerUserId="13691" LastEditorUserId="13691" LastEditDate="2017-08-07T10:21:17.527" LastActivityDate="2017-08-07T11:20:11.743" Title="inoremap + nnoremap" Tags="|vimrc|key-bindings|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13163" PostTypeId="2" ParentId="10678" CreationDate="2017-08-07T10:13:04.277" Score="3" Body="&lt;p&gt;You can use the &lt;code&gt;:yank&lt;/code&gt; ex command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/pattern1/;/pattern2/yank a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;a&lt;/code&gt; is the register you want to use and has a default value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You used &lt;code&gt;;,&lt;/code&gt; in your command. It should be either &lt;code&gt;;&lt;/code&gt; or &lt;code&gt;,&lt;/code&gt;, not both.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="6698" LastEditDate="2017-08-07T11:41:45.840" LastActivityDate="2017-08-07T11:41:45.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13164" PostTypeId="2" ParentId="13162" CreationDate="2017-08-07T10:13:14.157" Score="0" Body="&lt;p&gt;To answer the question I first tried to solve with above clarification (and answer to the question that I ended up asking):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &#xA;&lt;code&gt;noremap &amp;lt;complex-key&amp;gt; &amp;lt;action&amp;gt;&lt;/code&gt;&#xA;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;key&amp;gt; &amp;lt;C-O&amp;gt;&amp;lt;complex-key&amp;gt;&#xA;nmap &amp;lt;key&amp;gt; &amp;lt;complex-key&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to achieve what I was looking for&lt;/p&gt;&#xA;" OwnerUserId="13691" LastEditorUserId="13691" LastEditDate="2017-08-07T10:55:51.750" LastActivityDate="2017-08-07T10:55:51.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13165" PostTypeId="2" ParentId="13162" CreationDate="2017-08-07T10:34:45.157" Score="3" Body="&lt;p&gt;By using the &lt;code&gt;nore&lt;/code&gt; forms, you are specifically telling Vim to ignore any existing mappings. (See &lt;code&gt;:help :nore&lt;/code&gt;, or, for a bit more explanation, &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/05.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this chapter from Learn Vimscript the Hard Way&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use your existing &lt;code&gt;&amp;lt;COMPLEX-KEY&amp;gt;&lt;/code&gt; mapping inside another mapping, use &lt;code&gt;imap&lt;/code&gt; and &lt;code&gt;nmap&lt;/code&gt; for the &lt;code&gt;&amp;lt;KEY&amp;gt;&lt;/code&gt; mappings, not the &lt;code&gt;&amp;lt;COMPLEX-KEY&amp;gt;&lt;/code&gt; mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;COMPLEX-KEY&amp;gt; &amp;lt;ACTION&amp;gt;&#xA;&#xA;imap &amp;lt;KEY&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;COMPLEX-KEY&amp;gt;&amp;lt;Esc&amp;gt;i&#xA;nmap &amp;lt;KEY&amp;gt; &amp;lt;COMPLEX-KEY&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sidenote: You can use &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; to run a single normal mode command from insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;KEY&amp;gt; &amp;lt;C-O&amp;gt;&amp;lt;COMPLEX-KEY&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-08-07T10:40:16.127" LastActivityDate="2017-08-07T10:40:16.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13166" PostTypeId="2" ParentId="13162" CreationDate="2017-08-07T11:20:11.743" Score="1" Body="&lt;p&gt;On a side-note I've implemented a similar feature a long-time ago, &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/menu.vim#L570&quot; rel=&quot;nofollow noreferrer&quot;&gt;now in lh-vim-lib&lt;/a&gt; -- it's quite old and convoluted. I've been using it to generate mappings and menus for various modes (insert, normal, visual, command) that trigger the same action from a same keybinding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Here in one call, I'm able to define mappings and menus for Insert, Normal and Command modes (&lt;code&gt;nic&lt;/code&gt;) that execute &lt;code&gt;:TexMakePDF&lt;/code&gt; on &lt;code&gt;&amp;lt;c-l&amp;gt;pdf&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:MenuMake nic 50.330 &amp;amp;LaTeX.Make\ P&amp;amp;DF\ (via\ dvips)    &amp;lt;C-L&amp;gt;pdf&#xA;   \ &amp;lt;buffer&amp;gt; :wa&amp;lt;CR&amp;gt;:TeXMakePDF&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or here I can insert &lt;code&gt;&amp;lt;em&amp;gt;|&amp;lt;/em&amp;gt;&lt;/code&gt; in insert mode, or surround the current selection (or word -- normal mode) with the same keybinding (or from the same menu entry)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:MapMenu 50.370.300 &amp;amp;HTML.&amp;amp;Fonts.&amp;amp;Emphasize &amp;lt;localleader&amp;gt;em em&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The ideas (implemented in &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/menu.vim#L596&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;s:Build_CMD&lt;/code&gt;&lt;/a&gt;) are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;to use &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; in INSERT mode to revert to normal mode momentarily, &lt;/li&gt;&#xA;&lt;li&gt;to escape command mode (with &lt;code&gt;&amp;lt;c-c&amp;gt;&lt;/code&gt;) to return in normal mode&lt;/li&gt;&#xA;&lt;li&gt;from visual mode we need to keep the range&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-08-07T11:20:11.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13168" PostTypeId="2" ParentId="13149" CreationDate="2017-08-07T14:12:30.510" Score="2" Body="&lt;p&gt;Why don't you use the standard &lt;code&gt;.vim/plugin/&lt;/code&gt; and &lt;code&gt;.vim/ftplugin/{ft}/&lt;/code&gt; ? It's their exact purpose.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;plugins are loaded once when Vim starts&lt;/li&gt;&#xA;&lt;li&gt;ftplugins are loaded every time you open a file, or create a new buffer, that matches the associated filetype.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Don't mix up the official &lt;em&gt;plugins scripts&lt;/em&gt; with the plugins managed by plugin managers. The second kind are just bundles of a set the first kind distributed among specific sub-directories. These specific sub-directories can (and must) also be used for your own configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll also be interested in this &lt;a href=&quot;https://stackoverflow.com/questions/40254993/how-to-unload-a-vim-script-after-sourcing-it-and-making-changes-to-it/40257268#40257268&quot;&gt;SO Q/A&lt;/a&gt; that also discusses reloading scripts -- three reloading solutions are indirectly provided: my &lt;code&gt;:Reload&lt;/code&gt; helper command, Tim Pope's &lt;code&gt;vim-scriptstrease&lt;/code&gt;, and Ingo Karkat's &lt;code&gt;ReloadScript&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-08-07T14:23:39.093" LastActivityDate="2017-08-07T14:23:39.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13169" PostTypeId="1" AcceptedAnswerId="13171" CreationDate="2017-08-07T15:45:18.823" Score="0" ViewCount="150" Body="&lt;p&gt;My workflow revolves around having NerdTree opened with a quickfix at the the bottom and one file opened in a buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often grep within my file only by using the &lt;code&gt;%&lt;/code&gt; shortcut in my grep command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then navigate to quickfix or NerdTree to look at something and rerun my grep command slightly tweaked. At this point the command no longer works as &lt;code&gt;@%&lt;/code&gt; does not contain the name of my file anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could I keep entering non-modifiable buffers from updatding &lt;code&gt;@%&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10769" LastActivityDate="2017-08-07T15:58:33.540" Title="How can I prevent vim from changing the % register when entering non-modifiable windows?" Tags="|quickfix|vimgrep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13170" PostTypeId="2" ParentId="13127" CreationDate="2017-08-07T15:46:26.413" Score="1" Body="&lt;p&gt;You need &lt;a href=&quot;https://majutsushi.github.io/tagbar/&quot; rel=&quot;nofollow noreferrer&quot;&gt;TagBar&lt;/a&gt; and for JavaScript any of the &lt;a href=&quot;https://github.com/majutsushi/tagbar/wiki#javascript&quot; rel=&quot;nofollow noreferrer&quot;&gt;external dependencies suggested in the wiki&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2017-08-07T15:46:26.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13171" PostTypeId="2" ParentId="13169" CreationDate="2017-08-07T15:58:33.540" Score="2" Body="&lt;p&gt;&lt;code&gt;&quot;%&lt;/code&gt; is a read-only register. I doubt there is anything you can do to the register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of simply using &lt;code&gt;%&lt;/code&gt; in your grep command, e.g. &lt;code&gt;:grep 'foo' %&lt;/code&gt;, use &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt; to put in the contents of the register, e.g. &lt;code&gt;:grep 'foo' &amp;lt;c-r&amp;gt;%&lt;/code&gt;. This will paste/put the name of the file in the grep command. To tweak your grep simply do &lt;code&gt;q:&lt;/code&gt; and go and edit your last grep (press return to run).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h c_CTRL-R&#xA;:h c_%&#xA;:h q%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-08-07T15:58:33.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13172" PostTypeId="1" AcceptedAnswerId="13173" CreationDate="2017-08-07T16:03:03.237" Score="1" ViewCount="908" Body="&lt;p&gt;This is perhaps a beginner question, but I'm unable to (intuitively) figure out how to redirect the output of an ex command to a variable for further processing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some background: I'm trying to create a list of file paths that I want to pass to &lt;code&gt;fzf&lt;/code&gt;, and so I'm concatenating several sources into a list. In effect, what I want is something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let list1 = split(system($FZF_DEFAULT_COMMAND), &quot;\n&quot;)&#xA;let list2 = map(range(1, bufnr('$')),'bufname(v:val)')&#xA;let list3 = :oldfiles&#xA;&#xA;call fzf#run({'source': list1 + list2,&#xA;            \ 'sink': 'e',&#xA;            \ })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is with the &lt;code&gt;:oldfiles&lt;/code&gt; list. I can't find the correct syntax to capture the output of that ex command int a local variable &lt;code&gt;list3&lt;/code&gt;. I've tried the obvious (&lt;code&gt;let list3 = :oldfiles&lt;/code&gt;) and some other options (&lt;code&gt;&amp;amp;oldfiles&lt;/code&gt;, &lt;code&gt;call oldfiles()&lt;/code&gt;, &lt;code&gt;:oldfiles | list3&lt;/code&gt;, &lt;code&gt;:oldfiles &amp;gt; list3&lt;/code&gt;, &lt;code&gt;let list3 = :redir &amp;lt;CR&amp;gt; :oldfiles &amp;lt;CR&amp;gt; :redir END &amp;lt;CR&amp;gt;&lt;/code&gt;, etc. to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="13499" LastActivityDate="2017-08-10T16:29:34.750" Title="redirect exmode command to variable" Tags="|ex-mode|variables|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13173" PostTypeId="2" ParentId="13172" CreationDate="2017-08-07T16:16:04.053" Score="5" Body="&lt;p&gt;I managed to figure this one out. neovim and modern versions of vim provide an &lt;code&gt;execute&lt;/code&gt; function that can be used to do just this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let list3 = execute(&quot;:oldfiles&quot;)&lt;/code&gt; does the trick.&lt;/p&gt;&#xA;" OwnerUserId="13499" LastActivityDate="2017-08-07T16:16:04.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13174" PostTypeId="2" ParentId="13172" CreationDate="2017-08-07T16:23:49.043" Score="3" Body="&lt;p&gt;The correct syntax for doing this with &lt;code&gt;redir&lt;/code&gt; (which works in earlier versions of vim than &lt;code&gt;execute()&lt;/code&gt;) is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;redir =&amp;gt; list3&#xA;oldfiles&#xA;redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you really want it to be a one liner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;redir =&amp;gt; list3 | oldfiles | redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is described about halfway down the documentation for &lt;code&gt;:help :redir&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for why the other ideas you tried didn't work:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;oldfiles&lt;/code&gt;: The &lt;code&gt;&amp;amp;&lt;/code&gt; syntax allows you to access an option as a variable. &lt;code&gt;:oldfiles&lt;/code&gt; is an Ex command, not an option.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;call oldfiles()&lt;/code&gt; would call the &lt;code&gt;oldfiles()&lt;/code&gt; function, if one existed. Again, &lt;code&gt;:oldfiles&lt;/code&gt; is an Ex command, not a function.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:oldfiles | list&lt;/code&gt; would run the &lt;code&gt;:oldfiles&lt;/code&gt; command, followed by the &lt;code&gt;:list3&lt;/code&gt; command (again, if one existed).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:oldfiles &amp;gt; list3&lt;/code&gt; As far as I'm aware, this isn't really Vim syntax at all.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;let list3 = :redir &amp;lt;cr&amp;gt; :oldfiles &amp;lt;CR&amp;gt; :redir END &amp;lt;CR&amp;gt;&lt;/code&gt; This definitely isn't Vim syntax.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-08-07T16:29:40.667" LastActivityDate="2017-08-07T16:29:40.667" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13175" PostTypeId="2" ParentId="13172" CreationDate="2017-08-07T16:36:08.897" Score="2" Body="&lt;p&gt;Prefer &lt;code&gt;execute()&lt;/code&gt; over &lt;code&gt;:redir&lt;/code&gt; if you can -- there are less side-effects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that particular case, it seems that &lt;code&gt;v:oldfiles&lt;/code&gt; already contains the information you're looking for.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-08-07T16:36:08.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13176" PostTypeId="2" ParentId="184" CreationDate="2017-08-07T17:01:20.240" Score="4" Body="&lt;p&gt;After trying out several suggested solutions for shortcuts for this in ~/vimrc, I settled on simply adding &lt;code&gt;nmap &amp;lt;esc&amp;gt;&amp;lt;esc&amp;gt; :noh&amp;lt;return&amp;gt;&lt;/code&gt; to it. The double escape prevents interference with the function of the arrow keys. If you're in insert mode, a triple escape is necessary. This is quick to execute and easy to remember.&lt;/p&gt;&#xA;" OwnerUserId="13741" LastActivityDate="2017-08-07T17:01:20.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13177" PostTypeId="1" AcceptedAnswerId="13184" CreationDate="2017-08-08T01:02:52.547" Score="2" ViewCount="1076" Body="&lt;p&gt;When I run yapf on my code, an error page appears, rightly showing the error I have in the code. How on earth do I close this window and go back to my code? &lt;code&gt;:lclose&lt;/code&gt; doesn't work. &lt;code&gt;:close&lt;/code&gt; closed the whole tab, including my code. &lt;code&gt;:q&lt;/code&gt; closes the whole tab again. How can I close this error tab?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running gVim 8.&#xA;Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="13751" LastActivityDate="2017-08-09T08:32:22.587" Title="Closing error window" Tags="|gvim|vim-windows|filetype-python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13178" PostTypeId="1" AcceptedAnswerId="13179" CreationDate="2017-08-08T03:18:18.253" Score="4" ViewCount="1747" Body="&lt;p&gt;I'm trying to set up an autocommand so that new, unnamed buffers are created with &lt;code&gt;ft=markdown&lt;/code&gt;. Someone on SO &lt;a href=&quot;https://stackoverflow.com/a/5492283/4865822&quot;&gt;suggested the following&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter * if &amp;amp;filetype == &quot;&quot; | setlocal ft=markdown | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works great, but with which I have the following gripes:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;this will &lt;code&gt;set ft=markdown&lt;/code&gt; on &lt;strong&gt;named&lt;/strong&gt; buffers, too (&lt;em&gt;e.g.,&lt;/em&gt; &lt;code&gt;:e foo&lt;/code&gt;), and&lt;/li&gt;&#xA;&lt;li&gt;this will run every time I &lt;strong&gt;switch to&lt;/strong&gt; (enter) the buffer, not just when it's first created — not a problem in practice, but not what I want to do in principle.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've been working through the problem myself, but I can only get halfway there.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Success: the right &lt;code&gt;autocmd {pat}&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I've figured out that I can specify unnamed buffers by using a pair of empty curly braces (&lt;code&gt;{}&lt;/code&gt;) in place of a filename pattern. That is,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter {} setlocal ft=markdown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will run on &lt;code&gt;$ vim&lt;/code&gt;, but not on &lt;code&gt;$ vim foo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Failure: the right &lt;code&gt;autocmd {event}&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;So now I'm looking for the right autocmd event: &lt;strong&gt;one that is triggered on &lt;code&gt;:enew&lt;/code&gt; or any other time a blank, unnamed buffer is added to the buffer list.&lt;/strong&gt; I've tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;BufAdd&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;BufCreate&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;BufNew&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;but none of these are triggered on &lt;code&gt;:enew&lt;/code&gt;. I've tested this with the following autocommands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufAdd    * let b:foo = 'foo'&#xA;autocmd BufCreate * let b:foo = 'foo'&#xA;autocmd BufNew    * let b:foo = 'foo'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I edit an existing file, &lt;code&gt;:echo exists('b:foo')&lt;/code&gt; returns 1. When I &lt;code&gt;:enew&lt;/code&gt;, it returns 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(To be clear, &lt;code&gt;BufEnter&lt;/code&gt; still works, but I'm looking for one that only runs once.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an appropriate autocmd here, or should I file a bug?&lt;/p&gt;&#xA;" OwnerUserId="2593" LastActivityDate="2019-02-11T05:56:32.100" Title="autocmd BufAdd/BufCreate/BufNew aren't triggered for new, unnamed buffers (`:enew`)?" Tags="|buffers|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13179" PostTypeId="2" ParentId="13178" CreationDate="2017-08-08T07:32:08.327" Score="2" Body="&lt;p&gt;At first I was thinking of listening for &lt;code&gt;BufNewFile&lt;/code&gt;, but this is not the right event. My mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had the confirmation thanks to a plugin given in another answer: &lt;a href=&quot;http://vi.stackexchange.com/questions/4493/what-is-the-order-of-winenter-bufenter-bufread-syntax-filetype-events&quot;&gt;http://vi.stackexchange.com/questions/4493/what-is-the-order-of-winenter-bufenter-bufread-syntax-filetype-events&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- BufNew -- &#xA;- BufAdd -- &#xA;- BufCreate -- &#xA;- BufLeave -- /tmp/vim_log_autocommands&#xA;- BufEnter -- &#xA;- BufWinEnter -- &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, I've tested with your events:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aug Test&#xA;  au!&#xA;  au BufAdd    * :echom &quot;Add &quot;.expand('&amp;lt;amatch&amp;gt;').&quot;--&quot;.bufnr('%') | let b:test = 1&#xA;  au BufCreate * :echom &quot;Create &quot;.expand('&amp;lt;amatch&amp;gt;').&quot;--&quot;.bufnr('%') | let b:test = 1&#xA;  au BufNew    * :echom &quot;New &quot;.expand('&amp;lt;amatch&amp;gt;').&quot;--&quot;.bufnr('%') | let b:test = 1&#xA;aug END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you look closely, we see, first that the events are correctly triggered, and then that the buffer created isn't &lt;code&gt;bufnr('%')&lt;/code&gt;. Hence &lt;code&gt;&amp;lt;amatch&amp;gt;&lt;/code&gt; that is the proper way to proceed in many autocommands. This is hinted in the documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;NOTE: When this autocommand is executed, the current buffer &lt;code&gt;%&lt;/code&gt; may be different from the buffer being created &lt;code&gt;&amp;lt;afile&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you go back to the buffer (corresponding to the number printed), you'll see that &lt;code&gt;b:test&lt;/code&gt; is set to 1 over there. Actually you can expect the number of the new buffer to be &lt;code&gt;bufnr('$')+1&lt;/code&gt;. Still, I wouldn't use &lt;code&gt;setbufvar()&lt;/code&gt; as &lt;code&gt;getbufinfo(bufnr('%')+1)&lt;/code&gt; is still empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why in the other answer, you were pointing to, they said to listen for &lt;code&gt;BufEnter&lt;/code&gt; I guess. Instead, you'll have to mark the buffers you've already tested. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Either you use an internal variable at your script level&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:been_there = {}&#xA;aug FTOverride&#xA;  au! &#xA;  &quot; untested&#xA;  au BufEnter * if empty(&amp;amp;ft) &amp;amp;&amp;amp; !get(s:been_there, bufnr('%'), 0) | set ft=markdown | let s:been_there[bufnr('%')] = 1 | endif&#xA;aug END&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or you use a buffer variable which will be visible by everyone&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;  &quot; untested&#xA;  au BufEnter * if empty(&amp;amp;ft) &amp;amp;&amp;amp; !get(b:, 'ft_overridden', 0) | set ft=markdown | let b:ft_overridden = 1 | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;EDIT2: In a personal &lt;a href=&quot;https://github.com/LucHermitte/lh-misc/blob/master/plugin/fixfilename.vim#L64&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin I'm maintaining&lt;/a&gt;, I've found another way to proceed. This time I listen for the root events. When triggered, I register an one-time-autocommand on &lt;code&gt;BufEnter&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup auto_jump_to_line&#xA;  au!&#xA;  au BufNewFile,BufWinEnter *:* nested&#xA;        \ call lh#event#register_for_one_execution_at('BufEnter', function(s:getSNR('FixFilename')), 'auto_jump_to_line_1', expand('&amp;lt;afile&amp;gt;:t'))&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/event.vim#L52&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;lh#event#register_for_one_execution_at()&lt;/code&gt;&lt;/a&gt; registers an autocommand that'll start by un-registering itself. I haven't checked in your case, but it may work. But choose only one autocommand among the 3 you've found.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="19763" LastEditDate="2019-02-11T05:56:32.100" LastActivityDate="2019-02-11T05:56:32.100" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="13180" PostTypeId="1" CreationDate="2017-08-08T09:38:04.087" Score="4" ViewCount="2667" Body="&lt;p&gt;I'm writing small liniting plugin and I want to show errors in the quickfix as soon as errorfile changes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! OpenErrors(job_id, data, event)&#xA;    let l:winid = win_getid()&#xA;    let l:output = split(a:data[0])&#xA;    echom l:output[0] . l:output[2]&#xA;    let l:view = winsaveview()&#xA;    exe 'silent! cfile! ' . escape(l:output[0] . l:output[2], '%#/')&#xA;    call winrestview(l:view)&#xA;    if len(getqflist()) &amp;gt; 0&#xA;        copen&#xA;    else&#xA;        cclose&#xA;    endif&#xA;    call win_gotoid(l:winid)&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problems with this code is that it the cursor jumps to quickfix window and it's annoying when errorfile changes fast.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6634" LastEditDate="2019-10-14T06:31:43.243" LastActivityDate="2021-07-29T22:17:41.513" Title="How to show quickfix without jumping to quickfix window?" Tags="|quickfix|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13181" PostTypeId="2" ParentId="13180" CreationDate="2017-08-08T11:51:58.263" Score="1" Body="&lt;p&gt;In &lt;a href=&quot;https://github.com/LucHermitte/vim-build-tools-wrapper/blob/project/autoload/lh/btw/job_build.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Build-Tools-Wrapper&lt;/a&gt;, the callback receives the new line to display (as the job simply executes &lt;code&gt;make&lt;/code&gt; (or equivalent) and doesn't play with any intermediary file), the line is processed with &lt;code&gt;:caddexpr&lt;/code&gt;. If I'm supposed to be at the bottom I simply execute &lt;code&gt;:cbottom&lt;/code&gt; -- moving the cursor (in the qf windows) changes that. These two commands don't change the current window I'm in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also when I &lt;a href=&quot;https://github.com/LucHermitte/vim-build-tools-wrapper/blob/project/autoload/lh/btw/build.vim#L155&quot; rel=&quot;nofollow noreferrer&quot;&gt;start the compilation&lt;/a&gt;, I open the quickfix window without jumping to it. &lt;a href=&quot;https://github.com/LucHermitte/vim-build-tools-wrapper/blob/project/autoload/lh/btw/build.vim#L155&quot; rel=&quot;nofollow noreferrer&quot;&gt;Actually&lt;/a&gt;, I jump to it in order to apply a few hooks (like syntax highlighting, concealment...) and eventually I jump back to the window I was in before starting the background compilation. Along the way I've an &lt;a href=&quot;https://github.com/LucHermitte/vim-build-tools-wrapper/blob/project/autoload/lh/btw/build.vim#L277&quot; rel=&quot;nofollow noreferrer&quot;&gt;old trick&lt;/a&gt; able to detect if we need a qf window in other situations.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-08-08T11:51:58.263" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13182" PostTypeId="2" ParentId="13180" CreationDate="2017-08-08T12:27:50.510" Score="1" Body="&lt;p&gt;Try this quickfix preview plugin: &lt;a href=&quot;https://github.com/ronakg/quickr-preview.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ronakg/quickr-preview.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Fle1t.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Fle1t.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10798" LastActivityDate="2017-08-08T12:27:50.510" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13183" PostTypeId="1" CreationDate="2017-08-08T12:38:12.573" Score="2" ViewCount="503" Body="&lt;p&gt;I am using Vim 7.4 through a remote PuTTY session. I set my &quot;dracula&quot;&#xA;colorscheme in my vimrc, and then immediately after that, I remove the background setting for normal text. For Normal text, I personally prefer a solid (empty) black background to the background color that the dracula colorscheme uses. Here is the relevant code from my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme dracula&#xA;hi Normal ctermfg=231 ctermbg=NONE cterm=NONE &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works when I edit an HTML or text or JavaScript file, but if I edit a Perl file, the dracula colorscheme's default background is used instead. If I type &lt;code&gt;:verbose hi Normal&lt;/code&gt;, it says &quot;Last set from ~/.vim/bundle/vim-dracula/colors/dracula.vim&quot; So it appears the colorscheme file is getting sourced twice: once during the normal loading of the .vimrc and another time later on. Unfortunately the :scriptnames command only shows&#xA;the first time a file gets sourced. How do I find what is causing the dracula.vim file to be sourced again?&lt;/p&gt;&#xA;" OwnerUserId="9047" LastActivityDate="2017-09-09T10:38:47.443" Title="Why is Vim executing a colorscheme file a second time if editing a Perl file?" Tags="|vimrc|colorscheme|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13184" PostTypeId="2" ParentId="13177" CreationDate="2017-08-08T14:20:19.630" Score="5" Body="&lt;p&gt;&lt;strike&gt;It's a&lt;code&gt;quickfix&lt;/code&gt; window, and you can close it with the command &lt;code&gt;:cclose&lt;/code&gt;.&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above is rubbish, and I apologise for answering too hastily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the yapf plugins I found seem to work by replacing your entire file contents with the result of running the yapf command. (This is expected functionality, as yapf is a code formatter.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be able to go back simply by pressing &lt;code&gt;u&lt;/code&gt; to undo the changes that the command you ran has made to your code.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-08-09T08:32:22.587" LastActivityDate="2017-08-09T08:32:22.587" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13185" PostTypeId="1" CreationDate="2017-08-08T15:14:48.653" Score="1" ViewCount="2363" Body="&lt;p&gt;I'm new to Vim and it's just fantastic!&#xA;Now I would like to set up the Latex-suite with reverse searching and found &lt;a href=&quot;http://vim.wikia.com/wiki/Vim_can_interact_with_xdvi&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;this easy way&quot;&gt;this easy way&lt;/a&gt; by compiling to xdvi. But sometimes, I need the .&lt;code&gt;pdf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\ld&lt;/code&gt; : save, compile to &lt;code&gt;.xdvi&lt;/code&gt; and open the default &lt;code&gt;.xdvi&lt;/code&gt; viewer&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\lv&lt;/code&gt;: save, compile to &lt;code&gt;.pdf&lt;/code&gt;  and open the default &lt;code&gt;.pdf&lt;/code&gt;  viewer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How can I do this? Is it possible to save the multi-file LaTeX-project?&lt;/p&gt;&#xA;" OwnerUserId="13760" LastEditorUserId="6698" LastEditDate="2017-08-08T15:54:17.320" LastActivityDate="2017-09-18T18:10:43.137" Title="Vim LaTeX-suite: set keybinding to compile and view pdf" Tags="|key-bindings|plugin-vim-latex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13186" PostTypeId="1" AcceptedAnswerId="13189" CreationDate="2017-08-08T17:31:59.777" Score="1" ViewCount="32" Body="&lt;p&gt;I do a lot of work in plain TeX and XeTeX, editing the documents in vim, and have a variety of templates which I use to make the process more efficient. As you might expect, these use quite a lot of variables which are defined once and then reused. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment, to save typing, I put the most common values for each variable into the template, using the TeX comment delineator (a “%”) to control which one is selected. For example, the template might say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\def\location{%London&#xA;%Paris&#xA;%New York&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, when I am working on a document, I might de-comment the relevant line to define \location as “Paris”:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\def\location{%London&#xA;Paris&#xA;%New York&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whilst this works, it annoys me because I find having one option per line makes the templates unnecessarily long and hard to work my way through. I also can’t re-use the list of options when more than one variable might have a value chosen from the same list (e.g. in the example above, for “\newlocation”, I’d have to copy the list) and it just feels inefficient and the Wrong Way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In an ideal world, I was wondering if there could be something like a drop-down list of options which I could call up and select. However, I have had a look at vim’s default options, and many of the templates / skeleton / snippet plugins and haven’t really been able to see anything that is obviously suitable for something as simple as this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sure this is just me missing the obvious and was therefore wondering if someone could help point me in the right direction?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Jacob&lt;/p&gt;&#xA;" OwnerUserId="13763" LastActivityDate="2017-08-09T00:53:38.517" Title="Fields in templates without resorting to commented-out lists (aka are drop-down options possible?)" Tags="|autocompletion|filetype-tex|text-generation|snippets|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13187" PostTypeId="1" AcceptedAnswerId="13188" CreationDate="2017-08-08T18:44:21.037" Score="4" ViewCount="1821" Body="&lt;p&gt;I am trying to create a command which compares the current file with another by calling &lt;code&gt;:DiffWith(foo.rb)&lt;/code&gt;. See the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function DiffWith(file)&#xA;  botright vsplit a:file&#xA;  windo diffthis&#xA;endfunction&#xA;command -nargs=1 -complete=file Diffwith call DiffWith(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it opens a new file named &lt;code&gt;a:file&lt;/code&gt; instead of the file I state. What do I do wrong?&lt;/p&gt;&#xA;" OwnerUserId="13768" LastEditorUserId="6698" LastEditDate="2017-08-08T18:56:12.093" LastActivityDate="2017-08-09T02:07:35.167" Title="Pass variable in vimscript function to split" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13188" PostTypeId="2" ParentId="13187" CreationDate="2017-08-08T19:10:10.717" Score="4" Body="&lt;p&gt;Many commands in Vim, including &lt;code&gt;:botright&lt;/code&gt; and &lt;code&gt;:vsplit&lt;/code&gt;, expect plain text, no variables or expressions ( see &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#41%2e3&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 41.3&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help expression&lt;/code&gt;&lt;/a&gt; to know what a expression means). But there are commands that do expect variables and/or expressions, such as &lt;code&gt;:echo&lt;/code&gt; and &lt;code&gt;:execute&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/String_interpolation&quot; rel=&quot;nofollow noreferrer&quot;&gt;String interpolation&lt;/a&gt; is common in many programming languages such as Groovy, Kotlin, Perl, PHP, Python, Ruby, Scala, and Swift, and most Unix shells, but not Vimscript. However, when a Vim command expects an expression, it can evaluate variables and use the concatenation operator (the dot &lt;code&gt;.&lt;/code&gt;) to obtain the same effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it would be great if we could use the content of a variable, rather than just plain text, to issue commands such as &lt;code&gt;:botright vsplit a:file&lt;/code&gt;. For that purpose, Vim gives us the &lt;code&gt;:execute&lt;/code&gt; command, from  &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :execute&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe[cute] {expr1} ..    Executes the string that results from the&#xA;                         evaluation of {expr1} as an Ex command.  Multiple&#xA;                         arguments are concatenated, with a space in&#xA;                         between.  To avoid the extra space use the &quot;.&quot;&#xA;                         operator to concatenate strings into one &#xA;                         argument.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In that way, you can take advantage of the &lt;code&gt;:execute&lt;/code&gt; command  to get the intended result, as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function DiffWith(file)&#xA;  execute &quot;botright vsplit&quot; a:file&#xA;  windo diffthis&#xA;endfunction&#xA;command -nargs=1 -complete=file Diffwith call DiffWith(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then you can call it by typing in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Diffwith foo.rb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Bonus&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As Peter Rincker pointed out, Vim includes a similar functionality, see below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:botright vertical diffsplit foo.rb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you can rewrite your command in this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -nargs=1 -complete=file Diffwith botright vertical diffsplit &amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="6698" LastEditDate="2017-08-09T02:07:35.167" LastActivityDate="2017-08-09T02:07:35.167" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13189" PostTypeId="2" ParentId="13186" CreationDate="2017-08-08T19:20:10.733" Score="0" Body="&lt;p&gt;I'm not sure to completely understand your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All snippet/template/skeleton plugins have placeholders that can be replaced at the last moment. Also, many (/most?) can have snippet-variables. For instance, in &lt;a href=&quot;https://github.com/LucHermitte/mu-template&quot; rel=&quot;nofollow noreferrer&quot;&gt;mu-template&lt;/a&gt; I could write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MuT: let s:cities = ['Paris', 'NY']&#xA;MuT: let s:city1 = lh#ui#which('lh#ui#confirm', 'Chose one city', s:cities)&#xA;MuT: let s:city2 = lh#ui#which('lh#ui#confirm', 'Chose another city', s:cities)&#xA;\def\location{%&#xA;&amp;lt;+s:city1+&amp;gt;%&#xA;}&#xA;\def\newlocation{%&#xA;&amp;lt;+s:city2+&amp;gt;%&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you do many expansions at once (once again possible as a template can include another template and inject parameters or share variables), the &lt;code&gt;s:city1&lt;/code&gt; variable will be shared among all snippets. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the following, instead, I centralize/factorize the list of possible locations in one template file. We could use autoload functions instead -- but this time we need to reload the autoload plugin every time we change the function, while it's automatic with templates. I'm doing similar and more complex thing in &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp/blob/master/doc/snippets.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-cpp to generate class definition given a semantic&lt;/a&gt;: the class generation template is a big and complex procedure, the end-snippets instantiate/include the procedure with specialized parameters.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VimL:&quot; a first common template file: tex/internals/common-def.template&#xA;MuT: let s:cities = [ 'London', 'Paris', 'NY' ]&#xA;&#xA;&#xA;VimL: &quot; a leaf snippet file: tex/location.template&#xA;VimL: call s:include('common-def', 'tex/internals')&#xA;MuT: let s:city1 = lh#ui#which('lh#ui#confirm', 'Chose one city', s:cities)&#xA;\def\location{%&#xA;&amp;lt;+s:city1+&amp;gt;%&#xA;}&#xA;&#xA;&#xA;VimL: &quot; another leaf snippet file: tex/newlocation.template&#xA;VimL: call s:include('common-def', 'tex/internals')&#xA;MuT: let s:city2 = lh#ui#which('lh#ui#confirm', 'Chose a new city', s:cities)&#xA;\def\newlocation{%&#xA;&amp;lt;+s:city2+&amp;gt;%&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, once expanded, you won't be able to change all its occurrences to something new. But there, I suspect this is not what you want because you could use the TeX-macro &lt;code&gt;\location&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a pure placeholder worlds, if you have a very big snippet (I'm not sure many other plugins support snippet inclusion), if you change a named placeholder somewhere, it'll be changed everywhere -- until the plugin has determined that the expansion is terminated... BTW: most snippet plugin also support computed stuff and calls to &lt;code&gt;confirm()&lt;/code&gt; &amp;amp; co.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: &lt;code&gt;lh#ui#confirm()&lt;/code&gt; wraps &lt;code&gt;confirm()&lt;/code&gt; or a pure textual equivalent. &lt;code&gt;lh#ui#which()&lt;/code&gt; returns the value selected instead of the index of the value selected. They are defined &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/ui.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-08-09T00:53:38.517" LastActivityDate="2017-08-09T00:53:38.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13190" PostTypeId="1" CreationDate="2017-08-07T15:06:29.270" Score="7" ViewCount="1192" Body="&lt;p&gt;I'm trying to figure out how to do a search and replace on a visual block selection that will replace all occurrences in the visual block selection without replacing all occurrences on the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I was trying to do was remove all of the whitespace from part of multiple lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had something along the lines of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;class1 class2&quot;&amp;gt;  word            &amp;lt;/div&amp;gt;&#xA;&amp;lt;div class=&quot;class1 class2&quot;&amp;gt;  longWord        &amp;lt;/div&amp;gt;&#xA;&amp;lt;div class=&quot;class1 class2&quot;&amp;gt;  evenLongerWord  &amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I wanted to turn it in to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;class1 class2&quot;&amp;gt;word&amp;lt;/div&amp;gt;&#xA;&amp;lt;div class=&quot;class1 class2&quot;&amp;gt;longWord&amp;lt;/div&amp;gt;&#xA;&amp;lt;div class=&quot;class1 class2&quot;&amp;gt;evenLongerWord&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I made this selection with visual block mode (i'm representing the selection with | |):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;class1 class2&quot;&amp;gt;|  word            |&amp;lt;/div&amp;gt;&#xA;&amp;lt;div class=&quot;class1 class2&quot;&amp;gt;|  longWord        |&amp;lt;/div&amp;gt;&#xA;&amp;lt;div class=&quot;class1 class2&quot;&amp;gt;|  evenLongerWord  |&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I ran &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/ //g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that replaced all spaces in the entire line (I'm guessing the 'g' overrides the visual selection column range?) and I ended up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;divclass=&quot;class1class2&quot;&amp;gt;word&amp;lt;/div&amp;gt;&#xA;&amp;lt;divclass=&quot;class1class2&quot;&amp;gt;longWord&amp;lt;/div&amp;gt;&#xA;&amp;lt;divclass=&quot;class1class2&quot;&amp;gt;evenLongerWord&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but if I run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/ //&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then it only replaces the first space on each line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this the default behavior for search and replace in visual selection? I'm using someone elses vimrc that I got from this repo &lt;a href=&quot;https://github.com/amix/vimrc&quot; rel=&quot;noreferrer&quot;&gt;amix/vimrc ultimate vimrc&lt;/a&gt; so it's possible there is something in there that is causing the search and replace to act differently then it is supposed to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is the default behavior then what would be the best way to do what I was trying to do?&lt;/p&gt;&#xA;" OwnerDisplayName="Kevin Aud" LastEditorUserId="21" LastEditDate="2017-08-08T21:31:27.970" LastActivityDate="2017-09-07T22:10:45.773" Title="Replace all occurrences in visual block selection but NOT all occurrences on line" Tags="|substitute|visual-mode|visual-block|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13191" PostTypeId="2" ParentId="13153" CreationDate="2017-08-08T20:08:45.833" Score="1" Body="&lt;p&gt;I've come up with a rather quirky but I think pretty awesome solution to this problem. Upfront warning: It only works from the bash shell on platforms that support process substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The general idea behind the solution is to use a process substitution expansion to read the input from stdin and make it available to vim as a file name. Vim can then read the contents of the temporary file generated by the process substitution mechanism into a buffer using the &lt;code&gt;:read&lt;/code&gt; command, which, as I explained in my question, supports the same &lt;code&gt;++opt&lt;/code&gt; options as &lt;code&gt;:edit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the basic idea:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf 'a\xC0b'| vim -c 'r ++enc=utf-8 ++bad=keep '&amp;lt;(cat)'| $d' &amp;lt;/dev/tty;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, I am no longer passing the dash argument to &lt;code&gt;vim&lt;/code&gt;, and instead I am redirecting its stdin to read directly from the terminal (&lt;code&gt;/dev/stderr&lt;/code&gt; would also work here). Hence, instead of having &lt;code&gt;vim&lt;/code&gt; read directly from the pipeline, &lt;code&gt;vim&lt;/code&gt; initially reads nothing at all; it starts up as normal, creating a single empty scratch buffer during the initialization process. But then, I specify a &lt;code&gt;-c&lt;/code&gt; option to execute the &lt;code&gt;:read&lt;/code&gt; command with the desired &lt;code&gt;++opt&lt;/code&gt; options, and the file name to read is concatenated into the option value from the process substitution expansion, which of course expands to the temporary file name that contains the output of the background command. In this case, all we need is a simple &lt;code&gt;cat&lt;/code&gt; call to get the stdin stream from the pipeline into the temporary file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should mention, I actually had no idea that process substitution commands had access to the stdin stream of the enclosing command context, and I was pleasantly surprised to find that they (apparently) do. I don't know (and therefore can't guarantee) that this will work on all systems. The bash manual seems to say nothing about this aspect of process substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the &lt;code&gt;$d&lt;/code&gt; addendum to the &lt;code&gt;-c&lt;/code&gt; ex command is necessary to delete the extraneous blank line that &lt;code&gt;vim&lt;/code&gt; annoyingly adds when you read a file into an empty buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case anyone's interested, I've enshrined this solution into a more elaborate shell script which automatically parses and relays &lt;code&gt;++opt&lt;/code&gt; options and other &lt;code&gt;vim&lt;/code&gt; arguments to a &lt;code&gt;vim&lt;/code&gt; invocation constructed within the script. This makes the solution particularly powerful and easy-to-use. Here it is (note: I've named the script &lt;code&gt;vim-&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;&#xA;preVimArgs=();&#xA;plusPlusSpecs=();&#xA;postVimArgs=();&#xA;declare -i i=1;&#xA;declare -i gavePlusPlusArg=0; ## assumption&#xA;declare -i gaveEdit=0; ## assumption&#xA;&#xA;## start looping through (assumed) pre vim args&#xA;for ((i = 1; i &amp;lt;= $#; ++i)); do&#xA;    arg=&quot;${@:i:1}&quot;;&#xA;    if [[ &quot;$arg&quot; == ++* ]]; then ## found start of ++opt sequence&#xA;        gavePlusPlusArg=1;&#xA;        if [[ &quot;$arg&quot; != '++' ]]; then ## guard against treating meaningless &quot;++&quot; as a vim :r modifier; we allow meaningless &quot;++&quot; script args to give the caller a means of separating pre from post even if he doesn't want to pass any &quot;real&quot; ++opt args&#xA;            plusPlusSpecs+=(&quot;$arg&quot;);&#xA;            if [[ &quot;$arg&quot; == '++edit' ]]; then gaveEdit=1; fi;&#xA;        fi;&#xA;        for ((++i; i &amp;lt;= $#; ++i)); do&#xA;            arg=&quot;${@:i:1}&quot;;&#xA;            if [[ &quot;$arg&quot; != ++* ]]; then ## found start of post sequence&#xA;                postVimArgs+=(&quot;$arg&quot;);&#xA;                for ((++i; i &amp;lt;= $#; ++i)); do&#xA;                    arg=&quot;${@:i:1}&quot;;&#xA;                    if [[ &quot;$arg&quot; == ++* ]]; then echo &quot;vim-: error: discontiguous ++opt arguments.&quot; &amp;gt;&amp;amp;2; exit 1; fi;&#xA;                    postVimArgs+=(&quot;$arg&quot;);&#xA;                done;&#xA;                break;&#xA;            fi; ## end if (post sequence)&#xA;            if [[ &quot;$arg&quot; != '++' ]]; then ## ditto above&#xA;                plusPlusSpecs+=(&quot;$arg&quot;);&#xA;                if [[ &quot;$arg&quot; == '++edit' ]]; then gaveEdit=1; fi;&#xA;            fi;&#xA;        done;&#xA;        break;&#xA;    fi; ## end if (++opt sequence)&#xA;    preVimArgs+=(&quot;$arg&quot;);&#xA;done;&#xA;## little post-hoc switcheroo: if no actual ++ or ++opt arguments were given, then move pre args to post, since that's more likely to be the caller's intention when just specifying straight vim args&#xA;## if the caller really wants them to be pre, he can specify a meaningless &quot;++&quot; script arg to force all preceding script args to be taken as pre args&#xA;if [[ $gavePlusPlusArg -eq 0 &amp;amp;&amp;amp; ${#preVimArgs[@]} -gt 0 ]]; then&#xA;    postVimArgs=(&quot;${preVimArgs[@]}&quot;);&#xA;    preVimArgs=();&#xA;fi;&#xA;## also, automatically add ++edit if the caller didn't specify it explicitly; this just makes sense for this script's functionality&#xA;if [[ $gaveEdit -eq 0 ]]; then plusPlusSpecs+=('++edit'); fi;&#xA;&#xA;## run the vim command&#xA;exec vim &quot;${preVimArgs[@]}&quot; -c &quot;r${plusPlusSpecs[*]} &quot;&amp;lt;(cat)'| $d' &quot;${postVimArgs[@]}&quot; &amp;lt;/dev/tty;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Demo:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf 'a\xC0b'| vim- ++enc=utf-8 ++bad=keep;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim displays the resulting UTF-8 buffer as &lt;code&gt;a&amp;lt;c0&amp;gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8927" LastActivityDate="2017-08-08T20:08:45.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13192" PostTypeId="2" ParentId="13190" CreationDate="2017-08-08T21:30:02.033" Score="2" Body="&lt;p&gt;You can specify that the search should only match inside visual selections with the &lt;code&gt;\%V&lt;/code&gt; atom, see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5C%V&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help \%V&lt;/code&gt;&lt;/a&gt;. Thus, you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V //g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-08-08T21:30:02.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13193" PostTypeId="1" AcceptedAnswerId="13211" CreationDate="2017-08-08T21:35:18.293" Score="1" ViewCount="130" Body="&lt;p&gt;Does &lt;code&gt;vim&lt;/code&gt; expose an api for manipulating &lt;code&gt;argv&lt;/code&gt; before the &quot;main program&quot; looks at it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to use the syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim /path/to/my/file:100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and have it mean the same thing as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim +100 /path/to/my/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if &lt;code&gt;/path/to/my/file:100&lt;/code&gt; does not itself exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can potentially see writing a wrapper script that does something like the example below, but I would really prefer to keep the logic inside my &lt;code&gt;.vimrc&lt;/code&gt; if possible.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-perl prettyprint-override&quot;&gt;&lt;code&gt;#!/usr/bin/env perl&#xA;use strict;&#xA;use warnings;&#xA;&#xA;my @args;&#xA;&#xA;foreach my $x (@ARGV) {&#xA;    my $candidate = (not (-f $x)) and ($x =~ /:/);&#xA;    if ($candidate) {&#xA;        my ($path, $linum) = split /:/, $x, 2;&#xA;        push @args, (&quot;+&quot; . $linum, $path);&#xA;    } else {&#xA;        push @args, $x;&#xA;    }&#xA;}&#xA;&#xA;exec &quot;vim&quot;, @args;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="205" LastEditDate="2017-08-10T12:05:52.073" LastActivityDate="2017-08-10T12:20:42.503" Title="configure vim to process argv and understand filename:linenumber" Tags="|navigation|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13194" PostTypeId="1" AcceptedAnswerId="13226" CreationDate="2017-08-08T22:45:58.357" Score="1" ViewCount="320" Body="&lt;p&gt;When writing block quotes Markdown, I want to make vim act the same way it does with comment leaders and automatically start new lines with the '&gt;'. I also want to be able to format text this way with &lt;code&gt;gq&lt;/code&gt;. How can I do this? I set my formatoptions to &lt;code&gt;fo+=tacqw&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13769" LastActivityDate="2017-08-11T15:10:19.147" Title="Automatically add '&gt;' at beginning of line following one starting with '&gt;' when writing Markdown" Tags="|formatting|filetype-markdown|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13196" PostTypeId="1" AcceptedAnswerId="13199" CreationDate="2017-08-09T02:06:25.383" Score="0" ViewCount="3429" Body="&lt;p&gt;I just installed Ubuntu 16.04 and installed Vim, I tried to edit some files and when trying to write changes Vim said:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E173 4 more files to edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know why it's happening but it's making my cry like a baby.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Always when I execute &lt;code&gt;vim someFile&lt;/code&gt; in a terminal, it opens a file called &lt;code&gt;example&lt;/code&gt; no matter what name I pass as an argument, even without arguments! it opens the &lt;code&gt;example&lt;/code&gt; file and I can't do anything about!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; is empty, I ran &lt;code&gt;apt-get purge vim&lt;/code&gt; twice already and installed from repos, I deleted the legacy Vi, I built Vim from sources and it's happening the same, I rebooted my machine a lot of times but it keeps happening!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I make it work properly?&lt;/p&gt;&#xA;" OwnerUserId="13771" LastEditorUserId="6698" LastEditDate="2017-08-09T02:27:35.507" LastActivityDate="2017-08-09T06:49:05.950" Title="I can't edit a single file with Vim," Tags="|vimrc|linux-ubuntu|" AnswerCount="1" CommentCount="2" ClosedDate="2017-08-09T07:22:49.803" ContentLicense="CC BY-SA 3.0" />
  <row Id="13197" PostTypeId="2" ParentId="13194" CreationDate="2017-08-09T02:38:16.517" Score="4" Body="&lt;p&gt;The 'mail' ft plugin (at least in vim 7.4) does this by making '&gt;' a comment leader, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set comments+=n:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &quot;n:&quot; means that they can be nested, as they often are in email. You probably don't need that, but might want some of the other options, like 'b' to require a space after the leader&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set comments+=b:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or, for just plain, do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set comments+=:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, having 'q' in your formatoptions (like you already have) should flow with the block quote leader. Likewise, the 'c' in your formatoptions (as you also already have) will keep automatically placing the leader as you are typing text when the line wraps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd also recommend adding 'r' and 'o' to your format options, so that creating new lines (enter in insert mode or 'o' or 'O' in normal mode) also automatically adds the leader:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fo+=qcro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I expect those settings should work fine with markdown as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of the flags for comment leaders are described at &lt;code&gt;:help format-comments&lt;/code&gt; which may help you customize your settings further.&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2017-08-09T02:38:16.517" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13199" PostTypeId="2" ParentId="13196" CreationDate="2017-08-09T06:49:05.950" Score="1" Body="&lt;p&gt;Disclaimer: I do not have enough &quot;reputations&quot; for writing a comment so I post this message as an answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please check with &lt;code&gt;whereis vim&lt;/code&gt; and then try to find the ELF file using the &lt;code&gt;file &amp;lt;pathname&amp;gt;&lt;/code&gt; command. When you find it, use it directly and see if you still have the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example (for my machine and note that the lines starting with &lt;code&gt;$&lt;/code&gt; are the commands I typed):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ whereis vim&#xA;vim: /usr/bin/vim.basic /usr/bin/vim.gnome /usr/bin/vim /usr/bin/vim.tiny /etc/vim /usr/share/vim /usr/share/man/man1/vim.1.gz&#xA;$ file /usr/bin/vim&#xA;/usr/bin/vim: symbolic link to /etc/alternatives/vim&#xA;$ file /etc/alternatives/vim&#xA;/etc/alternatives/vim: symbolic link to /usr/bin/vim.gnome&#xA;$ file /usr/bin/vim.gnome&#xA;/usr/bin/vim.gnome: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=4780361a80931ec2b91b7c62c32364d4b0bd49aa, stripped&#xA;$ /usr/bin/vim.gnome&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If everything act normally with the ELF file, this means somewhere you have an alias or a script file changing the behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Search in your &lt;code&gt;.bashrc&lt;/code&gt; (or anything corresponding to your shell) for aliases like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vim='/usr/bin/vim example you got pranked'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe when searching for the ELF file, &lt;code&gt;file&lt;/code&gt; indicated that one file is a script file (example &lt;code&gt;/usr/bin/vim: Bourne-Again shell script, ASCII text executable&lt;/code&gt;). If this is the case, check the file, maybe you will have something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;/usr/bin/vim.gnome example you got pranked&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope it helped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: In our school, a classmate and I thought it was sad that most of the students use gedit when doing exams on the school computers. He had the great idea to move, on some school computers, &lt;code&gt;/usr/bin/gedit&lt;/code&gt; to &lt;code&gt;/usr/bin/gedit.bak&lt;/code&gt; and to create a script file &lt;code&gt;/usr/bin/gedit&lt;/code&gt; that would open the freshly moved gedit alongside with ten terminals with Vim opened in them.&lt;/p&gt;&#xA;" OwnerUserId="13576" LastActivityDate="2017-08-09T06:49:05.950" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13200" PostTypeId="1" AcceptedAnswerId="13208" CreationDate="2017-08-09T08:33:26.813" Score="4" ViewCount="2599" Body="&lt;p&gt;I want vim to tell me (only when I ask it to) if there are variables not used in the current file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible given that for now I need it in my javascript/php projects?&lt;/p&gt;&#xA;" OwnerUserId="13172" LastActivityDate="2017-08-09T13:37:07.980" Title="How do I make vim highlight unused variables" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13202" PostTypeId="2" ParentId="5067" CreationDate="2017-08-09T08:49:55.910" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;An alternative choice of characters are &lt;code&gt;q&lt;/code&gt; and &lt;code&gt;Q&lt;/code&gt; which do &lt;em&gt;not&lt;/em&gt; overwrite a builtin surrounding (&lt;code&gt;`&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType tex let b:surround_{char2nr(&quot;q&quot;)} = &quot;`\r'&quot;&#xA;autocmd FileType tex let b:surround_{char2nr('Q')} = &quot;``\r''&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;(IMPORTANT)&lt;/strong&gt; However, you cannot delete or change custom surroundings of &lt;code&gt;vim-surround&lt;/code&gt;. Intuitively one would try &lt;code&gt;dsq&lt;/code&gt; or &lt;code&gt;csQq&lt;/code&gt; which do not work. Also dot-repeat is not as convenient since you have to enter again &lt;code&gt;q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to have this, consider switching to the plugin &lt;a href=&quot;https://github.com/machakann/vim-sandwich&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;&lt;code&gt;vim-sandwich&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt;. The default mappings are little bit different: &lt;code&gt;saiwl'&lt;/code&gt; would add &lt;code&gt;`text'&lt;/code&gt;, &lt;code&gt;srbl&quot;&lt;/code&gt; would change it to &lt;code&gt;``text''&lt;/code&gt;, and &lt;code&gt;sdb&lt;/code&gt; would remove them again. &lt;code&gt;sa&lt;/code&gt;, &lt;code&gt;sr&lt;/code&gt;, &lt;code&gt;sd&lt;/code&gt; for add, replace and delete surrounding. &lt;code&gt;l'&lt;/code&gt; for latex single quotation marks, &lt;code&gt;l&quot;&lt;/code&gt; for latex double quotation marks. It also defines a text-object (default &lt;code&gt;ib&lt;/code&gt;), to allow for convenient selection with &lt;code&gt;vib&lt;/code&gt; what the OP has asked. It can be repeated to extend the selection with &lt;code&gt;vibib...&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A convenience feature of &lt;code&gt;vim-surround&lt;/code&gt; which is not well known is following shortcut: use the change command to actually add a surrounding to a word, WORD, sentence or paragraph with one of the special target specifiers &lt;code&gt;[wWsp]&lt;/code&gt;. To surround the current paragraph with a quotation the command is &lt;code&gt;cspQ&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h surround-targets&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The letters w, W, and s correspond to a |word|, a |WORD|, and a |sentence|,&#xA;  respectively.  These are special in that they have nothing to delete, and&#xA;  used with |ds| they are a no-op.  With |cs|, one could consider them a&#xA;  slight shortcut for ysi (cswb == ysiwb, more or less).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A p represents a |paragraph|.  This behaves similarly to w, W, and s above;&#xA;  however, newlines are sometimes added and/or removed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2017-08-14T13:43:52.853" LastActivityDate="2017-08-14T13:43:52.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13203" PostTypeId="2" ParentId="13158" CreationDate="2017-08-09T09:02:52.513" Score="6" Body="&lt;p&gt;Here's a &lt;code&gt;simple&lt;/code&gt; mapping to do the task:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;silent&amp;gt; rs &quot;zy:call setreg(&quot;z&quot;, system(&quot;echo \&quot;&quot; . @z . &quot;\&quot; \| sed 's/[ \\t]\\+//' \| rs -j 0 1&quot;), &quot;b&quot;)&amp;lt;CR&amp;gt;gv&quot;zp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses &lt;code&gt;z&lt;/code&gt; register to keep output of it's intermediate steps. I had to add call to &lt;code&gt;sed&lt;/code&gt; to remove trailing white chars from the input to &lt;code&gt;rs&lt;/code&gt;, because &lt;code&gt;rs&lt;/code&gt; would produce strange output (maybe &lt;code&gt;rs&lt;/code&gt; can be asked to do it by itself, but I couldn't figure it out myself)&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-08-09T09:02:52.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13204" PostTypeId="1" CreationDate="2017-08-09T10:49:25.873" Score="0" ViewCount="372" Body="&lt;p&gt;As is displayed here:&#xA;&lt;a href=&quot;http://andrewradev.com/2011/06/08/vim-and-ctags/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://andrewradev.com/2011/06/08/vim-and-ctags/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can setup ctags to allow us to enter functions and modules as they are being called. But the problem is that I want to enter a the function the given instance is a member of.&#xA;So say,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ibase=new mbase({});&#xA;ibase.onload();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then if I'm over the onload function, and hit ctrl-] to enter the function, I want to enter the onload function that is a member of the module mbase. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently it just enters whatever onload function it encountered first. Which is not what I need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I make the goto functionality take into account which module the instance is a member of?&lt;/p&gt;&#xA;" OwnerUserId="605" LastActivityDate="2017-08-09T11:33:37.130" Title="Goto function definition of class the instance is a member of" Tags="|ctags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13205" PostTypeId="2" ParentId="13204" CreationDate="2017-08-09T11:19:47.483" Score="1" Body="&lt;p&gt;EDIT: Sorry I misread your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either you use a plugin that permits you to select an overload among others. That's one of the reasons I wrote &lt;a href=&quot;https://github.com/LucHermitte/lh-tags/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-tags&lt;/a&gt;. In all cases, you'll need to know by yourself what is the type of your variable. This is not perfect, but more than enough for me. You still have &lt;code&gt;:pselect&lt;/code&gt;, but I've always found it clumsy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also rely on more clever tools. I'm thinking about &lt;a href=&quot;http://langserver.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://langserver.org/&lt;/a&gt; .&#xA;I wonder whether it wouldn't be a better solution. The advantage of LangServer is we can expect it to be able to rely on a tool specialized for the languages we work with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to stick to a pure ctags solution, first prefer universal-ctags. Then, if you want to automatically select the right function, you'll have to write some non trivial code.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First, you'll need to extract the type of the variable. You can start with the &lt;code&gt;gd&lt;/code&gt; command to &lt;strong&gt;g&lt;/strong&gt;oto to the variable &lt;strong&gt;d&lt;/strong&gt;efinition. If it fails, you could run (universal-!)ctags on the current file and make sure to ask for variable declarations/definitions. &lt;/li&gt;&#xA;&lt;li&gt;With this new info, you should be able to find the line where the variable is defined. (*)&lt;/li&gt;&#xA;&lt;li&gt;There, you'll have to analyse the line found to extract the type: &lt;code&gt;mbase&lt;/code&gt; -- in other languages we have other kind of declarations.&lt;/li&gt;&#xA;&lt;li&gt;Eventually you can &lt;code&gt;filter(taglist(funcname), 'v:val.class == &quot;mbase&quot;')&lt;/code&gt;, and jump by yourself to this entry (there is everything needed to behave as a tag jump in lh-tags) -- the exact dictionary key to analyse may depend on the language.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Be aware that if your language permits stuff like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myvar = new SomeType1();&#xA;if (...)&#xA;   myvar = new SomeOtherType2();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or even&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myvar = new SomeType1();&#xA;...&#xA;myvar = new SomeOtherType2();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or worse&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myvar = f(g());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Good luck with ctags in order to extract the exact type. We have other problems when the language supports overriding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) NB: In lh-cpp, I have a series of functions (that I'll like to refactor) I use to extract the type of a C++ variable. It be may adapted to your language. In lh-dev I have an &lt;a href=&quot;https://github.com/LucHermitte/lh-dev/blob/master/autoload/lh/dev.vim#L287&quot; rel=&quot;nofollow noreferrer&quot;&gt;undocumented API to run ctags&lt;/a&gt; on the fly on the current file to extract some specific information without modifying the current tag database -- that I'm also likely to refactor.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-08-09T11:33:37.130" LastActivityDate="2017-08-09T11:33:37.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13207" PostTypeId="1" CreationDate="2017-08-09T12:52:38.743" Score="6" ViewCount="829" Body="&lt;p&gt;Vim highlight SpellCap errors after every fullstop. Also after abbreviations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i.e. without&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;without&lt;/code&gt; gets the SpellCap highlight. This is obious no error, and renders the SpellCap function rather useless for me.&#xA;Is there a way to define abbreviations in vim, so that there is no SpellCap placed afterwards?&lt;/p&gt;&#xA;" OwnerUserId="11316" LastEditorUserId="11316" LastEditDate="2017-08-15T12:40:07.290" LastActivityDate="2017-08-30T12:27:01.727" Title="Deactivate SpellCap-Check after Abbreviation" Tags="|spell-checking|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13208" PostTypeId="2" ParentId="13200" CreationDate="2017-08-09T13:37:07.980" Score="5" Body="&lt;p&gt;I do not work in PHP but the following instructions for JavaScript are still relevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you want is a linter: this is an external software analysing statically you code. For JavaScript, I advise you to use &lt;a href=&quot;http://jslint.com/&quot; rel=&quot;noreferrer&quot;&gt;JSLint&lt;/a&gt;. JSLint is far to be permissive, you should see how to configure it (basically, you just have to put a comment on top of your JavaScript file). I use this configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*jslint todo: true, browser: true, continue: true, white: true*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming you are using Linux, you could install (globally) JSLint on your computer using npm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you need to use it in Vim, for that there are plugins. The simplest way I know is to use &lt;a href=&quot;https://github.com/vim-syntastic/syntastic&quot; rel=&quot;noreferrer&quot;&gt;Syntastic&lt;/a&gt;. Syntastic is a plugin for checking error (when you save the file) on the current file using an external program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have installed JSLint globally, Syntastic would automatically works with your JavaScript files. Note that Syntastic works on Vim 7.4 so there is no asynchronous operation (when you save the file, you have to wait that Syntastic finishes its job).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a nutshell:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a linter to find the unused variables (example: JSLint)&lt;/li&gt;&#xA;&lt;li&gt;Use a plugin that calls linters and compilers for checking errors (example: Syntastic or YouCompleteme with a good dose of despair when configuring it). Or you could see how to do it yourself (start by reading &lt;code&gt;:h errorformat&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;PS: You asked to highlight the variables. With the solution I proposed you, it will not highlight the variables but show the line where errors are present (and the reason of the error).&lt;/p&gt;&#xA;" OwnerUserId="13576" LastActivityDate="2017-08-09T13:37:07.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13209" PostTypeId="1" AcceptedAnswerId="13210" CreationDate="2017-08-09T13:57:27.823" Score="5" ViewCount="341" Body="&lt;p&gt;When I edit C-style languages, I can use &lt;code&gt;%&lt;/code&gt; to jump between pairs of square brackets, braces, and parenthesis.  If there an equivalent between &lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, &lt;code&gt;def&lt;/code&gt;, &lt;code&gt;if&lt;/code&gt; and the last indented line for the block in python?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know python blocks like this tend to be shorter, but I just wondered anyway.&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="51" LastEditDate="2017-08-09T14:03:59.683" LastActivityDate="2017-08-09T20:47:31.027" Title="Is there a % equivalent for editing python code?" Tags="|cursor-movement|filetype-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13210" PostTypeId="2" ParentId="13209" CreationDate="2017-08-09T14:15:55.393" Score="5" Body="&lt;p&gt;That functionality is provided by the matchit plugin that is bundled with Vim. The distributed &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/ftplugin/c.vim#L39&quot; rel=&quot;nofollow noreferrer&quot;&gt;C filetype&lt;/a&gt; plugin includes the configuration &lt;code&gt;b:match_words&lt;/code&gt; that defines those jumps for the matchit plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the distributed &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/ftplugin/python.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;python filetype&lt;/a&gt; does not include a similar change. You can however configure &lt;code&gt;b:match_words&lt;/code&gt; for that case. Simply put the definition of the &lt;code&gt;b:match_words&lt;/code&gt; variable into &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt; (create non-existing direcotories).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even better would be to create a PR with a working definition for the &lt;code&gt;b:match_words&lt;/code&gt; variable at the &lt;a href=&quot;https://github.com/sullyj3/vim-ftplugin-python&quot; rel=&quot;nofollow noreferrer&quot;&gt;upstream python filetype repository&lt;/a&gt; so that it can be distributed with one of the next runtime files updates. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the configuration of the &lt;code&gt;b:match_words&lt;/code&gt; variable, see the help page at &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/pack/dist/opt/matchit/doc/matchit.txt#L254&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h b:match_words&lt;/a&gt;. (You might need to do &lt;code&gt;:packadd matchit&lt;/code&gt; or the help file won't be found.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;So it looks like this might be more complex for python, because python uses no explicit end delimiter but rather the number of spaces. I did not think of it, because I usually do not use python. However, it should still be possible to match those parts. I tried with this simple(?) regex for matching &lt;code&gt;if/elif/&lt;/code&gt; parts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:match_words = &amp;amp;matchpairs . ',^\(\s*\)\&amp;lt;if\&amp;gt;:^\1\&amp;lt;elif\&amp;gt;:^\1\zs\%(elif\)\@!.'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(That works, because it matches the number of spaces in front of the if statement and uses that to match either to the next &lt;code&gt;elif&lt;/code&gt; or the end of the if block. A similar think should work for &lt;code&gt;for&lt;/code&gt; and similar blocks). However one caveat: doesn't work if the if block itsself is the last part of an containing block, so this it does not catch currently:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for line in input.readlines():&#xA;    if (find(line,&quot;endinput&quot;)&amp;lt;0):&#xA;        Zeile=line[0:len(line)-1]+&quot;[Italy]\n&quot;&#xA;        nZeile.append(Zeile)&#xA;input.close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also there seems to be a bug in the matchit plugin, because adding &lt;code&gt;\zs&lt;/code&gt; to the &lt;code&gt;elif&lt;/code&gt; pattern to make the cursor stop at the beginning of the elif (instead of at the beginning of the line), breaks it. Not sure why.&#xA;However, the basic principle should be clear with the example.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2017-08-09T20:47:31.027" LastActivityDate="2017-08-09T20:47:31.027" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13211" PostTypeId="2" ParentId="13193" CreationDate="2017-08-09T15:02:39.523" Score="3" Body="&lt;p&gt;You could write a dirty function for doing this for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile * nested call ReadFile()&#xA;&#xA;func! ReadFile()&#xA;  let l:filename = expand('%:p')&#xA;  if l:filename =~ ':\d\+$'&#xA;    let l:number = matchstr(l:filename, ':\zs\d\+$')&#xA;    let l:filename = matchstr(l:filename, '^[^:]*')&#xA;    execute 'bd |  e! '. l:filename&#xA;    call cursor(l:number, 1)&#xA;  endif&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not beatiful and has some downfalls, but could get you started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Credits to muru for the nested modifier!&lt;/p&gt;&#xA;" OwnerUserId="11316" LastEditorUserId="11316" LastEditDate="2017-08-10T12:20:42.503" LastActivityDate="2017-08-10T12:20:42.503" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13212" PostTypeId="2" ParentId="13158" CreationDate="2017-08-09T19:33:43.987" Score="3" Body="&lt;p&gt;What about doing the substitution on the visual selection with &lt;code&gt;\%V&lt;/code&gt;, and avoiding external programs?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, the following does the job (I'll use &lt;code&gt;\v&lt;/code&gt; to simplify the patterns):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;s/\v%V(\s*)(\S*)(\s*)/\1\3\2/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it won't work with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a1    a&#xA;b2 2  b&#xA;c23 4 c&#xA;d444 4d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We cannot use &lt;code&gt;\v%V(\s*)(.{-})(\s*)$&lt;/code&gt; as &lt;code&gt;$&lt;/code&gt; denote the last position in the line, not in the selection :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the doc, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;s/\v%V(\s*)(.{-})(\s*)%V/\1\3\2/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should work, but it doesn't while &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;s/\v%V(\s*)(.{-})(\s*)%6c/\1\3\2/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in order to get the exact end column (as &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; can be reversed), I have this solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe &quot;'&amp;lt;,'&amp;gt;&quot;.'s/\v%V(\s*)(.{-})(\s*)%'.(1+max([col(&quot;'&amp;lt;&quot;), col(&quot;'&amp;gt;&quot;)])).'c/\1\3\2/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW, we can also use &lt;code&gt;:substitute&lt;/code&gt; and &lt;code&gt;substitute()&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; '&amp;lt;,'&amp;gt;s/\%V.*\%V./\=substitute(submatch(0), '\v^(\s*)(.{-})(\s*)$', '\1\3\2', '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(along the way I think I've found out why I wasn't able to use a second &lt;code&gt;\%V&lt;/code&gt;: it needs something behind. But I'm afraid the pattern will become quite complex)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT4: The almost winning regex is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\v%V(.{-})(\s*)%V@!/\2\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it fails with the new test case. Instead, the following seems to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\v%V(.*\S)(\s*%V\s)%V@!/\2\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And as a mapping it becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:xnoremap µ :s/\v%V(.*\S)(\s*%V\s)%V@!/\2\1/&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Thank you @Christian Brabandt for the hint about &lt;code&gt;/\%V&lt;/code&gt;) BTW, I don't need to match the leading spaces, it's even more simpler....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My understanding is the following: &lt;code&gt;%V.&lt;/code&gt; says the next character belongs to the visual selection. &lt;code&gt;%V@!&lt;/code&gt; says the next character shall not belong. Alas in &lt;code&gt;\s*%V@!&lt;/code&gt;, we match as many spaces as possible as long as after the spaces we are outside the selection. This is not enough as it'll match spaces outside the selection as well. Hence my last edit with &lt;code&gt;(\s*%V\s)&lt;/code&gt; where I request the last space to belong to the selection. If there is no space a the end of the selection, we won't match anything, but who care? This is already right aligned! And we still need a last &lt;code&gt;%V@!&lt;/code&gt; to say after this last character we are outside the selection.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-08-11T00:26:09.743" LastActivityDate="2017-08-11T00:26:09.743" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="13213" PostTypeId="2" ParentId="7924" CreationDate="2017-08-09T23:58:28.413" Score="1" Body="&lt;p&gt;Following lines in .vimrc fixed the problem for me.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au VimEnter * call matchadd('SpecialKey', '^\s\+', -1)&#xA;au VimEnter * call matchadd('SpecialKey', '\s\+$', -1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It overrides other styles application for tabs and trailing spaces inside a cursor line.&lt;/p&gt;&#xA;" OwnerUserId="8194" LastEditorUserId="8194" LastEditDate="2017-08-10T10:53:03.137" LastActivityDate="2017-08-10T10:53:03.137" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13215" PostTypeId="2" ParentId="184" CreationDate="2017-08-10T16:22:24.237" Score="0" Body="&lt;p&gt;I do not think remove hls at all would be a good thing, how about making easy to enable or disable creating a easy shortcut (boolean)&#xA;In my case  --&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; to reselect use gv in normal mode&#xA;nnoremap &amp;lt;S-F11&amp;gt; &amp;lt;ESC&amp;gt;:set hls!&amp;lt;cr&amp;gt;&#xA;inoremap &amp;lt;S-F11&amp;gt; &amp;lt;C-o&amp;gt;:set hls!&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;S-F11&amp;gt; &amp;lt;ESC&amp;gt;:set hls!&amp;lt;cr&amp;gt; &amp;lt;bar&amp;gt; gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The magic happens because of &quot;&lt;code&gt;!&lt;/code&gt;&quot; at the end of the setting&lt;/p&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2017-08-10T16:22:24.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13216" PostTypeId="2" ParentId="13172" CreationDate="2017-08-10T16:29:34.750" Score="0" Body="&lt;p&gt;Personally I have created a function to get my last 20 commands, as it would be useful here it is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; this function gets last 20 cmds to new buffer&#xA;fun! s:RedirHistoryCommands()&#xA;    set paste&#xA;    redir @r&#xA;    history : -20,&#xA;    redir End&#xA;    new&#xA;    put r&#xA;    set nopaste&#xA;    :%s/^\s\+//g&#xA;    :g/^$/d&#xA;endfun&#xA;command! -nargs=0 GetHistory call s:RedirHistoryCommands()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2017-08-10T16:29:34.750" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13217" PostTypeId="1" CreationDate="2017-08-10T17:25:24.487" Score="0" ViewCount="199" Body="&lt;p&gt;When a visual block is created, the block itself is highlighted, but the cursor is highlighted differently, green in my terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I want the block to stay the same but move just the location of the green cursor, how do I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to do this so I can try to make a block edit at the beginning of a line. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;4j$?2x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the '?' is the motion I need to get the cursor back to the beginning of the block. If I do this without moving the cursor, then the whole block gets deleted, instead of just the first 2 characters in the block.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2017-08-10T17:45:31.737" Title="How can I move the cursor in block mode (without changing the block)?" Tags="|visual-block|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13218" PostTypeId="2" ParentId="13217" CreationDate="2017-08-10T17:45:31.737" Score="5" Body="&lt;p&gt;You are looking for the &lt;code&gt;o&lt;/code&gt; visual command which will go to the other end of the visually selected text. There is also &lt;code&gt;O&lt;/code&gt; which moves within the same line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h v_o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-08-10T17:45:31.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13219" PostTypeId="1" CreationDate="2017-08-10T23:10:22.077" Score="11" ViewCount="685" Body="&lt;p&gt;I am interested in using vim to edit a &quot;secure&quot; file, one that is stored encrypted elsewhere (say, somewhere in the cloud), and should not be written as plaintext to the local disk. So the sequence of events might be (with a separate wrapper script or something for non-vim steps 1, 2, and 5):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Retrieve encrypted file from the cloud&lt;/li&gt;&#xA;&lt;li&gt;Decrypt the file, and launch vim while passing the plaintext to vim for editing (perhaps over a new file descriptor?)&lt;/li&gt;&#xA;&lt;li&gt;Edit with vim interactively&lt;/li&gt;&#xA;&lt;li&gt;When the file is written using &lt;code&gt;:w&lt;/code&gt;, write the result (again, through a file descriptor?)&lt;/li&gt;&#xA;&lt;li&gt;Encrypt the new plaintext and store back in the cloud&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now, I understand that the usual way to do this sort of thing is to decrypt, write a temporary file, edit the temporary file in vim, read the temporary file, encrypt, wipe/delete the temp file. What I'm looking for is a way to avoid using a temporary file at all. (Also, everything in &lt;a href=&quot;https://vi.stackexchange.com/questions/6177/the-simplest-way-to-start-vim-in-private-mode&quot;&gt;The simplest way to start Vim in private mode&lt;/a&gt; would be set.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to approach this might be to use something like &lt;code&gt;netrw&lt;/code&gt;, which I'm not terribly familiar with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the purposes of this question, I'm not concerned about the OS swap data (but if there's a vim way to mark its internal data buffers as non-swappable, that would be interesting).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do the above, or better yet, has somebody else already solved this?&lt;/p&gt;&#xA;" OwnerUserId="13806" LastActivityDate="2019-12-02T19:42:44.663" Title="Is there a way to edit secure data in vim without accessing the filesystem?" Tags="|netrw|startup|security|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13220" PostTypeId="1" CreationDate="2017-08-11T01:35:06.893" Score="1" ViewCount="652" Body="&lt;p&gt;TLDR: How can I open a file from the list of recent files without going to the end of the list to get to the prompt for file number?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to open recent files, I do &lt;code&gt;:bro ol&lt;/code&gt; and then when I see the file that I want to open, I have to press &lt;kbd&gt;Space&lt;/kbd&gt; to get to the bottom of the list and to see the prompt for entering the file number. I was wondering if there is a faster way; possibly being able to get the prompt for file number on the first page of recent files, rather than pressing space until I get to the end of the page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;bonus question:&lt;/b&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does &lt;code&gt;:ol&lt;/code&gt; do? Does it just list the recent files and a file cannot be opened from the list?&lt;/p&gt;&#xA;" OwnerUserId="13751" LastEditorUserId="5395" LastEditDate="2017-08-11T06:56:59.343" LastActivityDate="2023-12-07T10:07:01.010" Title="Opening recent files issue" Tags="|vimrc|gvim|filesystem|multiple-files|file-operations|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13221" PostTypeId="1" AcceptedAnswerId="13247" CreationDate="2017-08-11T02:18:44.783" Score="1" ViewCount="289" Body="&lt;p&gt;I use a modified version of &lt;code&gt;industry&lt;/code&gt; where my &lt;code&gt;normal&lt;/code&gt; text color is bright white instead of grey.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the offending line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight Normal ctermfg=white ctermbg=Black guifg=#dddddd  guibg=Black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am having a problem in gnu screen where the bright white-ness bleeds into the next line of text in my terminal and so on until I reset it by hand with the command &lt;code&gt;printf &quot;\033[0m&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to fix this by having vim execute the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimLeave * :call Printf_Fixup()&#xA;&#xA;function! Printf_Fixup()&#xA;    !printf '\033[0m'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but unfortunately, vim doesn't &quot;just execute&quot; the shell command &lt;code&gt;printf '\033[0m'&lt;/code&gt; when exiting, it sometimes prompts me to manually press enter. not sure what's going on there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to configure vim to be more aggressive when &quot;displaying&quot; a colorscheme and use redundant ansi resets all over the place?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="1841" LastEditDate="2017-08-11T08:12:12.270" LastActivityDate="2017-08-15T10:29:31.310" Title="prevent color scheme from bleeding into terminal" Tags="|colorscheme|" AnswerCount="1" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13223" PostTypeId="1" CreationDate="2017-08-10T18:00:32.497" Score="0" ViewCount="125" Body="&lt;p&gt;I want to print stuff to the screen separated by key presses (any key). A reduced version of what I'm trying to do is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo banana &amp;amp;&amp;amp; read -rsn1 &amp;amp;&amp;amp; echo orange &amp;amp;&amp;amp; read -rsn1 &amp;amp;&amp;amp; echo apple&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That works fine in bash, as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would like to do that inside vim (i.e., open vim, print banana, wait for key press, print orange, wait for key press, print apple), so I thought I could use process substitution for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim &amp;lt;(echo banana &amp;amp;&amp;amp; read -rsn1 &amp;amp;&amp;amp; echo orange &amp;amp;&amp;amp; read -rsn1 &amp;amp;&amp;amp; echo apple)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this doesn't work: only banana is printed. It looks like it can't capture key presses and blocks there. Why not? What is going on? How can I work around this?&lt;/p&gt;&#xA;" OwnerDisplayName="faviouz" LastActivityDate="2017-08-11T07:57:55.073" Title="Process substitution with read" Tags="|bash|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13224" PostTypeId="2" ParentId="13223" CreationDate="2017-08-11T07:57:55.073" Score="2" Body="&lt;p&gt;I think the command you're looking for is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +&quot;echo 'banana'&quot; +&quot;call getchar()&quot; +&quot;echo 'orange'&quot; +&quot;call getchar()&quot; +&quot;echo 'apple'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;+&quot;...&quot;&lt;/code&gt; syntax allows to specify a vim command to execute after startup. Thus the line will use vim's &lt;code&gt;echo&lt;/code&gt; to print the word in its command prompt followed by vim's &lt;code&gt;getchar()&lt;/code&gt; which waits for a userinput (see &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getchar%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getchar()&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now why your command didn't worked I may be wrong but I think that &lt;code&gt;read&lt;/code&gt; expects an input on stdin which isn't what you modify when you press a key in vim.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-08-11T07:57:55.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13225" PostTypeId="2" ParentId="13158" CreationDate="2017-08-11T12:56:52.000" Score="0" Body="&lt;p&gt;You and I seem to use different definitions of the word &quot;simple&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You've stated that you're not interested in functions that solve the problem, but, for the benefit of other visitors to this page, here's a function (and mapping) that right aligns by moving spaces from the right side of the selection to the left-side:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RightAlign()&#xA;  &quot; Get the line and column of the visual selection marks&#xA;  let [line1, column1] = getpos(&quot;'&amp;lt;&quot;)[1:2]&#xA;  let [line2, column2] = getpos(&quot;'&amp;gt;&quot;)[1:2]&#xA;&#xA;  for l in range(line1, line2)&#xA;    &quot; Get the line&#xA;    let line = getline(l)&#xA;&#xA;    &quot; Convert string to list for manipulation&#xA;    let line_list = split(line, '\zs')&#xA;&#xA;    &quot; Right align within the visual selection by moving spaces from right side&#xA;    &quot; to left side&#xA;    while line_list[column2 - 1] =~ '\s'&#xA;      &quot; Remove space from right side&#xA;      let space = remove(line_list, column2 - 1)&#xA;      &quot; And add it to left side&#xA;      call insert(line_list, space, column1 - 1)&#xA;    endwhile&#xA;&#xA;    &quot; Convert list back to string and write out&#xA;    call setline(l, join(line_list, &quot;&quot;))&#xA;  endfor&#xA;endfunction&#xA;command! -range RightAlign call RightAlign()&#xA;xnoremap &amp;lt;leader&amp;gt;r :RightAlign&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For me, this is simpler than the existing solutions on the page: it was completely straightforward to write, and I'm confident that if I came back to the code in a year or two I'd be able to figure out how it works in seconds. (Whereas, I still don't completely understand @grodzik and @LucHermitte's ingenious one-liners.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a similar version that works via normal mode commands which is possibly even simpler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RightAlign2()&#xA;  &quot; Get the line and column of the visual selection marks&#xA;  let [line1, column1] = getpos(&quot;'&amp;lt;&quot;)[1:2]&#xA;  let [line2, column2] = getpos(&quot;'&amp;gt;&quot;)[1:2]&#xA;&#xA;  for l in range(line1, line2)&#xA;    &quot; Right align within the visual selection by moving spaces from right side&#xA;    &quot; to left side&#xA;    while getline(l)[column2 - 1] =~ '\s'&#xA;      &quot; Jump to line&#xA;      execute &quot;normal &quot; . l . &quot;G&quot;&#xA;      &quot; Jump to right&#xA;      execute &quot;normal &quot; . column2 . &quot;|&quot;&#xA;      &quot; Cut&#xA;      normal x&#xA;      &quot; Jump to left&#xA;      execute &quot;normal &quot; . column1 . &quot;|&quot;&#xA;      &quot; Paste&#xA;      normal P&#xA;    endwhile&#xA;  endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-08-11T13:17:21.727" LastActivityDate="2017-08-11T13:17:21.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13226" PostTypeId="2" ParentId="13194" CreationDate="2017-08-11T15:10:19.147" Score="1" Body="&lt;p&gt;It turns out vim handles block quotes in Markdown pretty much the way I asked for since at least version 7.4. It loads ftplugin/markdown.vim which sets '&gt;' as a comment leader. It also adds the &lt;code&gt;t&lt;/code&gt; flag to &lt;code&gt;formatoptions&lt;/code&gt; and removes the &lt;code&gt;r&lt;/code&gt; and &lt;code&gt;o&lt;/code&gt; flags. That means if you write until the text is longer than &lt;code&gt;textwidth&lt;/code&gt;, you get a new line that starts with &lt;code&gt;&amp;gt;&lt;/code&gt;. But if you just press enter or add a new line with &lt;kbd&gt;o&lt;/kbd&gt; or &lt;kbd&gt;O&lt;/kbd&gt; you won't get the '&gt;' on the new line. So if you want this functionality you have to override the file type plugin. You can do that by creating the file &lt;code&gt;.vim/after/ftplugin/markdown.vim&lt;/code&gt; and adding &lt;code&gt;set formatoptions+=ro&lt;/code&gt; to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My situation was that I had some paragraphs in a Markdown file that I wanted to turn into blockquotes by adding '&gt;' at the start of every line. The paragraphs were already formatted so there were hard line breaks in them. I added '&gt;' to the start of the first line and expected vim to make the whole paragraph commented if I used &lt;code&gt;gq&lt;/code&gt; over it. Obviously that's not what &lt;code&gt;gq&lt;/code&gt; does when you have a hard line break after what it recognizes as a comment. If it did, code written after a comment when programming would itself be commented out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can solve the problem if we join the lines of the paragraph by pressing &lt;code&gt;[count]&lt;/code&gt;&lt;kbd&gt;J&lt;/kbd&gt; where &lt;code&gt;[count]&lt;/code&gt; is the number of lines to be joined. Then &lt;code&gt;gq&lt;/code&gt; will format the paragraph as we want. If you have the &lt;code&gt;a&lt;/code&gt; flag in &lt;code&gt;formatoptions&lt;/code&gt; it's not necessary to use &lt;code&gt;gq&lt;/code&gt; because the text is automatically reformatted.&lt;/p&gt;&#xA;" OwnerUserId="13769" LastActivityDate="2017-08-11T15:10:19.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13227" PostTypeId="1" AcceptedAnswerId="13246" CreationDate="2017-08-11T20:23:28.327" Score="0" ViewCount="1191" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/vim-scripts/Smart-Tabs/blob/master/plugin/ctab.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim-scripts/Smart-Tabs/blob/master/plugin/ctab.vim&lt;/a&gt; through Vundle.&#xA;How can I temporarily disable it (preferably more readily than by commenting out the bundle and restarting the editor)?&lt;/p&gt;&#xA;" OwnerUserId="4738" LastEditorUserId="4738" LastEditDate="2017-08-14T11:30:09.680" LastActivityDate="2017-08-15T09:20:55.143" Title="Temporarily disabling Smart-Tabs" Tags="|indentation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13229" PostTypeId="1" CreationDate="2017-08-12T13:29:21.943" Score="0" ViewCount="500" Body="&lt;p&gt;I thought I knew how Vim handles indentation but apparently I was wrong.&#xA;When I type  at the beginning of a line, everything seems to work as expected. However when I type  somewhere inside a line, strange things happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose my options are set as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set filetype=c&#xA;set cindent&#xA;set tabstop=8&#xA;set shiftwidth=8&#xA;set softtabstop=0&#xA;set listchars=tab:▸\ ,eol:¬,space:-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That being said I would expect every &lt;code&gt;▸&lt;/code&gt; tab character to have equivalent length of &lt;code&gt;tabstop=8&lt;/code&gt;. That is not the case. What happens is this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/foTTV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/foTTV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure Vim to show every tab character with equivalent length?&lt;/p&gt;&#xA;" OwnerUserId="11421" LastEditorUserId="6698" LastEditDate="2017-08-13T10:56:49.083" LastActivityDate="2017-08-13T10:56:49.083" Title="Strange behaviour when inserting tabs" Tags="|indentation|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13230" PostTypeId="2" ParentId="13229" CreationDate="2017-08-12T13:43:36.907" Score="2" Body="&lt;p&gt;Tab characters &lt;em&gt;don't&lt;/em&gt; have fixed width; that's the purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The original purpose of tabulation is to create neat columns. It's magic: you press one button, and the cursor is automatically at the beginning of the next column. What you define with &lt;code&gt;tabstop&lt;/code&gt; is, in reality, the width of those columns; it &lt;em&gt;isn't&lt;/em&gt; the width of the tab character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really need equivalent spacing, just add the number of spaces you want. Vim's &lt;code&gt;i&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;o&lt;/code&gt; etc. accept counts, so you can just do &lt;code&gt;8i &amp;lt;Esc&amp;gt;&lt;/code&gt; (in Normal mode) to add 8 spaces at current position.&lt;/p&gt;&#xA;" OwnerUserId="7415" LastActivityDate="2017-08-12T13:43:36.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13231" PostTypeId="1" CreationDate="2017-08-12T15:02:36.287" Score="1" ViewCount="210" Body="&lt;p&gt;How can I find out the default value of a variable if it is not set? For example, the default timeout for the leader key is controlled by the &lt;code&gt;timeoutlen&lt;/code&gt; variable, but if I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo timeoutlen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get an &quot;undefined variable&quot; error. Is there any command to find out default values for variables like this?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2017-08-24T10:27:14.877" Title="Find value of variable when it is not set (timeoutlen)" Tags="|variables|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13232" PostTypeId="1" CreationDate="2017-08-12T15:10:33.927" Score="1" ViewCount="492" Body="&lt;p&gt;If I have non-printable characters assigned to a variable, how can I echo them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I have a variable &lt;code&gt;xyz&lt;/code&gt; set to be two spaces and a tab, then if I do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo xyz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it just shows a blank line. I can't actually see the characters to which the variable has been set. Is there any way to get echo to visualize non-printable characters?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2017-09-11T21:05:56.563" Title="How can I echo non-printable characters like spaces?" Tags="|echo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13233" PostTypeId="2" ParentId="13232" CreationDate="2017-08-12T15:48:28.433" Score="3" Body="&lt;p&gt;I often add characters around like in &lt;code&gt;:echo '###'.xyz.'###'&lt;/code&gt;. It's simple enough, and more readable, IMO, than &lt;code&gt;:echo split(xyz, '\zs')&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-08-12T15:48:28.433" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13234" PostTypeId="2" ParentId="13232" CreationDate="2017-08-12T20:18:34.317" Score="4" Body="&lt;p&gt;you can use the &lt;code&gt;strtrans()&lt;/code&gt; function, which translates unprintable characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#strtrans%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;strtrans()&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The result is a String, which is {expr} with all unprintable&#xA;                  characters translated into printable characters 'isprint'.&#xA;                  Like they are shown in a window.  Example: &#xA;                          echo strtrans(@a)&#xA;                 This displays a newline in register a as &quot;^@&quot; instead of&#xA;                  starting a new line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-08-12T20:18:34.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13235" PostTypeId="2" ParentId="13231" CreationDate="2017-08-12T20:20:25.940" Score="2" Body="&lt;p&gt;For options, you can use the special syntax &lt;code&gt;&amp;amp;optionname&lt;/code&gt; to echo its value. This is described in the help at &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-option&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h expr-option&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you would want to do: &lt;code&gt;:echo &amp;amp;timeoutlen&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-08-12T20:20:25.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13238" PostTypeId="1" CreationDate="2017-08-13T18:44:54.287" Score="2" ViewCount="183" Body="&lt;p&gt;I have following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:get_visual_selection()&#xA;    let [line_start, column_start] = getpos(&quot;'&amp;lt;&quot;)[1:2]&#xA;    let [line_end, column_end] = getpos(&quot;'&amp;gt;&quot;)[1:2]&#xA;    let lines = getline(line_start, line_end)&#xA;    if len(lines) == 0&#xA;        return ''&#xA;    endif&#xA;    let lines[-1] = lines[-1][: column_end - 2]&#xA;    let lines[0] = lines[0][column_start - 1:]&#xA;    return join(lines, &quot;\n&quot;)&#xA;endfunction&#xA;&#xA;&quot; dependencies - tpope's surround.vim plugin&#xA;function! s:singleDoubleQuotesToggler() &quot;{{{&#xA;  &quot; select between &quot;&quot; using&#xA;  norm va&quot;&#xA;  let doubleq_sel = s:get_visual_selection()&#xA;  &quot; echo string(doubleq_sel)&#xA;  let doubleq_sel_length = strlen(doubleq_sel)&#xA;  echo string(doubleq_sel_length)&#xA;  exec &quot;norm! \&amp;lt;Esc&amp;gt;&quot;&#xA;  if doubleq_sel_length == 0&#xA;    &quot; echo string(&quot;single&quot;)&#xA;    norm cs'&quot;&#xA;  else&#xA;    &quot; echo string('double')&#xA;    norm cs&quot;'&#xA;  endif&#xA;endfunction &quot;}}}&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; GS :call &amp;lt;SID&amp;gt;singleDoubleQuotesToggler()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;problem is that GS work through once and I dont know why&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://asciinema.org/a/DeMsED2ul6EK5loaoKFyzssG3&quot; rel=&quot;nofollow noreferrer&quot;&gt;video&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11273" LastActivityDate="2017-10-13T18:17:33.973" Title="Help to implement script that toggle single and double quotes" Tags="|vimscript|visual-mode|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13239" PostTypeId="1" AcceptedAnswerId="13243" CreationDate="2017-08-13T21:19:19.373" Score="2" ViewCount="272" Body="&lt;p&gt;How can I make vim accept all CJK characters as correctly spelled while still having the spell check language set to English?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's easier, a rule to only check the spelling of Latin characters would work just as well in practice for me.&lt;/p&gt;&#xA;" OwnerUserId="13769" LastEditorUserId="13769" LastEditDate="2017-08-13T22:30:56.720" LastActivityDate="2017-08-15T02:50:00.897" Title="Exclude East Asian (CJK) characters from spell check" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13240" PostTypeId="2" ParentId="13238" CreationDate="2017-08-13T21:42:41.547" Score="2" Body="&lt;p&gt;For your approach to work, you could define an &lt;code&gt;omap&lt;/code&gt; that finds the smallest enclosing pair, and tests the character under the cursor to trigger the mapping from Surround you wish. I remember a plugin that has defined the operator pending mode you'll need. Its approach was quite smart by testing all possible &lt;code&gt;vi{whatever}&lt;/code&gt; to find the one with the smallest result. From there, you'll just need to test the character under &lt;code&gt;'&amp;lt;&lt;/code&gt;. Alas I can't remember the name of this plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems I've implemented an equivalent in lh-brackets (&lt;a href=&quot;https://github.com/LucHermitte/lh-brackets/blob/master/autoload/lh/brackets.vim#L592&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;s:outer_blocks()&lt;/code&gt;&lt;/a&gt;), it doesn't returns the first characters, but the last one. From there, you'll just need to test the character under the closest position, and you'll know which surround mapping you want to execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's the &lt;code&gt;if p[0] =~ '[&quot;'']'&lt;/code&gt; part that'll be of interest to you. You can assume your &lt;code&gt;s:GetPairs()&lt;/code&gt; results in &lt;code&gt;[ ['&quot;', '&quot;'], [&quot;'&quot;, &quot;'&quot;] ]&lt;/code&gt; -- &lt;code&gt;s:GetPairs()&lt;/code&gt; returns the list of brackets pairs registered for the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:outer_blocks() abort&#xA;  let crt_pairs = copy(s:GetPairs(0))&#xA;  call extend(crt_pairs, s:GetPairs(1))&#xA;  let matches = {}&#xA;  for p in crt_pairs&#xA;    if p[0] != p[1] &quot; searchpos doesn't work in that case&#xA;      let pos = searchpairpos(p[0], '', p[1], 'cWn', &quot;lh#syntax#is_a_comment('.')&quot;)&#xA;      call s:Verbose('Testing searchpos(%1) -&amp;gt; %2', p, pos)&#xA;    elseif p[0] =~ '[&quot;'']'&#xA;      &quot; Stuff which can be checked with vi', vi&quot;&#xA;      let crt_pos = getpos('.')&#xA;      let cleanup = lh#on#exit()&#xA;            \.restore('@a')&#xA;            \.register('call setpos(&quot;.&quot;, '.string(crt_pos).')')&#xA;      try&#xA;        let @a = ''&#xA;        silent! exe 'normal! &quot;aya'.p[0]&#xA;        &quot; 2 chars are to be expected for open and close&#xA;        if lh#encoding#strlen(@a) &amp;gt;= lh#encoding#strlen(p[0].p[1])&#xA;          &quot; In two steps because it may fail&#xA;          &quot; -- it shouldn't though thanks to len(@a) &amp;gt;= 2 * len(open)&#xA;          exe 'normal! v'&#xA;          silent! exe 'normal! a'.p[0]&#xA;          silent! exe &quot;normal! \&amp;lt;esc&amp;gt;&quot;&#xA;          let pos = getpos('.')[1:2]&#xA;        else&#xA;          let pos = [0,0]&#xA;        endif&#xA;        if 0&#xA;          &quot; getpos doesn't seem to work...&#xA;          let pos = getpos('`&amp;gt;')[1:2]&#xA;          if getpos('`&amp;lt;')[1:2] == pos&#xA;            let pos = [0,0]&#xA;          endif&#xA;        endif&#xA;        call s:Verbose('Testing va%1 -&amp;gt; %2 - %3', p[0], pos, @a)&#xA;      finally&#xA;        call cleanup.finalize()&#xA;      endtry&#xA;    else&#xA;      let pos = searchpos(p[0], 'cWnb', 'lh#syntax#is_a_comment(&quot;.&quot;)')&#xA;      if  pos != [0,0]&#xA;        let pos = searchpos(p[1], 'cWn', 'lh#syntax#is_a_comment(&quot;.&quot;)')&#xA;      endif&#xA;      call s:Verbose('Testing /%1 -&amp;gt; %2', p[0], pos)&#xA;    endif&#xA;    if pos != [0,0]&#xA;      let matches[p[0]] = pos&#xA;    endif&#xA;  endfor&#xA;  call s:Verbose('Containing bracket pairs: %1', matches)&#xA;  return matches&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-10-13T18:17:33.973" LastActivityDate="2017-10-13T18:17:33.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13241" PostTypeId="2" ParentId="747" CreationDate="2017-08-14T09:23:55.190" Score="2" Body="&lt;h3&gt;Plugin &lt;a href=&quot;https://github.com/machakann/vim-sandwich/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-sandwich&lt;/code&gt;&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Another useful plugin for this is &lt;code&gt;vim-sandwich&lt;/code&gt; which has defined ft-specific surroundings&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;l`&lt;/code&gt; or &lt;code&gt;l'&lt;/code&gt; for &lt;code&gt;`text'&lt;/code&gt;, &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;l&quot;&lt;/code&gt; for &lt;code&gt;``text''&lt;/code&gt; and &lt;/li&gt;&#xA;&lt;li&gt;textobjects to easily operate on them.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With the default mappings following work&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;textobject:&lt;/strong&gt; replace inner text of &lt;code&gt;`text'&lt;/code&gt; with &lt;code&gt;cisl'&lt;/code&gt; or if auto detection of nearest surrounding is fine &lt;code&gt;cib&lt;/code&gt; (e.g. cursor on &lt;code&gt;h&lt;/code&gt; in &lt;code&gt;`a (phony) text'&lt;/code&gt; requires to press &lt;code&gt;vibibc&lt;/code&gt;). However, you can define following additional textobject &lt;code&gt;iq&lt;/code&gt; (OP example)&#xA;&lt;code&gt;&#xA;omap &amp;lt;unique&amp;gt; iq &amp;lt;Plug&amp;gt;(textobj-sandwich-query-i)l'&#xA;xmap &amp;lt;unique&amp;gt; iq &amp;lt;Plug&amp;gt;(textobj-sandwich-query-i)l'&#xA;omap &amp;lt;unique&amp;gt; aq &amp;lt;Plug&amp;gt;(textobj-sandwich-query-a)l'&#xA;xmap &amp;lt;unique&amp;gt; aq &amp;lt;Plug&amp;gt;(textobj-sandwich-query-a)l'&#xA;omap &amp;lt;unique&amp;gt; iQ &amp;lt;Plug&amp;gt;(textobj-sandwich-query-i)l&quot;&#xA;xmap &amp;lt;unique&amp;gt; iQ &amp;lt;Plug&amp;gt;(textobj-sandwich-query-i)l&quot;&#xA;omap &amp;lt;unique&amp;gt; aQ &amp;lt;Plug&amp;gt;(textobj-sandwich-query-a)l&quot;&#xA;xmap &amp;lt;unique&amp;gt; aQ &amp;lt;Plug&amp;gt;(textobj-sandwich-query-a)l&quot;&#xA;&lt;/code&gt;&#xA;Now simply pressing &lt;code&gt;ciq&lt;/code&gt; or &lt;code&gt;ciQ&lt;/code&gt; works.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;add&lt;/strong&gt; to &lt;code&gt;text&lt;/code&gt; with &lt;code&gt;saiwl'&lt;/code&gt; single apostrophes to get &lt;code&gt;`text'&lt;/code&gt;&lt;br&gt;&#xA;The pattern of the command is &lt;code&gt;sa{motion/textobject}{surrounding}&lt;/code&gt; and means invoke operator &lt;code&gt;add  surrounding&lt;/code&gt; on &lt;code&gt;inner word&lt;/code&gt; and surround type is &lt;code&gt;latex single quote&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;delete&lt;/strong&gt; with &lt;code&gt;sdl'&lt;/code&gt; or with &lt;code&gt;sdb&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;change&lt;/strong&gt; with &lt;code&gt;srl'l&quot;&lt;/code&gt; or with &lt;code&gt;srbl&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It supports&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;repeat.vim by &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tim Pope&lt;/a&gt; or &lt;a href=&quot;https://github.com/kana/vim-repeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kana&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3848&quot; rel=&quot;nofollow noreferrer&quot;&gt;visualrepeat.vim&lt;/a&gt; by Ingo Karkat (not supported by vim-surround by Tim Pope).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-08-29T08:03:45.637" LastActivityDate="2018-08-29T08:03:45.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13243" PostTypeId="2" ParentId="13239" CreationDate="2017-08-15T02:50:00.897" Score="5" Body="&lt;p&gt;Have you tried &lt;code&gt;:set spelllang+=cjk&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help 'spelllang'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If the name &quot;cjk&quot; is included East Asian characters are excluded from&#xA;  spell checking.  This is useful when editing text that also has Asian&#xA;  words.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That sounds exactly like what you're asking for.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2017-08-15T02:50:00.897" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13244" PostTypeId="2" ParentId="13207" CreationDate="2017-08-15T03:28:36.097" Score="4" Body="&lt;p&gt;&lt;code&gt;SpellCap&lt;/code&gt; does not identify misspelled words. It tries to point out places where the first word of a sentence is not correctly capitalized. Thus, adding words to your dictionary probably won't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at &lt;code&gt;:help 'spellcapcheck'&lt;/code&gt; and you'll see that the setting contains punctuation that should mark the end of a sentence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tend to ignore this highlighting. If you can't ignore it &lt;em&gt;and&lt;/em&gt; you don't need Vim to identify capitalization issues then you could just do &lt;code&gt;:set spellcapcheck=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, maybe this information will help root out a more acceptable solution.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2017-08-15T03:28:36.097" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13245" PostTypeId="1" AcceptedAnswerId="13294" CreationDate="2017-08-15T08:35:56.987" Score="4" ViewCount="2270" Body="&lt;p&gt;I'm new to Vim and setting up LaTeX with vimtex. Now, I am looking for a Snippet-Manager and decided to give UltiSnips a try. It seems to be very handy.&#xA;But it doesn't come with a lot snippets (&lt;a href=&quot;https://github.com/honza/vim-snippets/blob/master/snippets/tex.snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;honza/vim-snippets&lt;/a&gt; has about 100 snippets).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now my question: Is there a source providing more snippets (e.g. stuff for mathmode, etc)? Or would somebody be so kind to share his &quot;extended version&quot; of snippets?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot!&lt;/p&gt;&#xA;" OwnerUserId="13760" LastActivityDate="2020-10-17T18:47:17.520" Title="LaTeX: Ultisnips" Tags="|filetype-tex|plugin-ultisnips|plugin-vimtex|" AnswerCount="2" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13246" PostTypeId="2" ParentId="13227" CreationDate="2017-08-15T09:20:55.143" Score="1" Body="&lt;p&gt;This plugin does not offer a method of temporarily disabling it. Therefore you have four options I can think of:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The main functionality of the plugin is provided by insert mode mappings for the &lt;kbd&gt;Tab&lt;/kbd&gt; and &lt;kbd&gt;Backspace&lt;/kbd&gt; keys. You can remove these mappings with &lt;code&gt;:iunmap &amp;lt;tab&amp;gt; | iunmap &amp;lt;bs&amp;gt;&lt;/code&gt; and renable by reloading the plugin entirely with &lt;code&gt;:source [...]/ctab.vim&lt;/code&gt;. (You'll need to fill in the ellipsis with the correct path, I don't know offhand to what location Vundle downloads files.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should work because this particular plugin doesn't seem to follow the standard practice of checking a guard variable to prevent itself from being loaded multiple times. If it did, you'd first need to reset the guard variable before reloading.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fork the plugin and edit it to add this feature. The two most obvious ways of doing this are to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Edit the &lt;code&gt;InsertSmartTab()&lt;/code&gt; and &lt;code&gt;DoSmartDelete()&lt;/code&gt; functions to immediately &lt;code&gt;return&lt;/code&gt; if a new global variable &lt;code&gt;g:ctab_temporarily_disable&lt;/code&gt; is set.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add a &lt;code&gt;SmartTabDisable()&lt;/code&gt; function to call &lt;code&gt;iunmap&lt;/code&gt;, and wrap the &lt;a href=&quot;https://github.com/vim-scripts/Smart-Tabs/blob/master/plugin/ctab.vim#L82&quot; rel=&quot;nofollow noreferrer&quot;&gt;lines that create the mappings&lt;/a&gt; in a function (so it can be invoked from outside the plugin) to re-enable.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As suggested by &lt;a href=&quot;https://vi.stackexchange.com/questions/13227/temporarily-disabling-smart-tabs#comment22700_13227&quot;&gt;Christian Brabandt in a comment&lt;/a&gt;, you can disable all insert maps with &lt;code&gt;:set paste&lt;/code&gt; and then re-enable with &lt;code&gt;:set nopaste&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has a number of other effects, so it's more of a workaround than a solution, but if it meets your requirements it's the simplest option.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;(You've already stated you don't want to do this) Comment out the Vundle line and run &lt;code&gt;:PluginClean&lt;/code&gt;, (&lt;a href=&quot;https://stackoverflow.com/questions/601412/how-to-turn-off-a-plugin-in-vim-temporarily&quot;&gt;or otherwise disable the plugin&lt;/a&gt;,) and restart the editor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-08-15T09:20:55.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13247" PostTypeId="2" ParentId="13221" CreationDate="2017-08-15T10:21:25.307" Score="2" Body="&lt;p&gt;Vim reads the &lt;code&gt;ti&lt;/code&gt; and &lt;code&gt;te&lt;/code&gt; &lt;a href=&quot;https://www.gnu.org/software/termutils/manual/termcap-1.3/html_chapter/termcap_4.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;capabilities&lt;/a&gt; from your termcap and sends the commands in these to the terminal when it starts up and exits, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could manually override the &lt;code&gt;te&lt;/code&gt; setting to instead emit your escape sequence for clearing colours with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let &amp;amp;t_te = &quot;\&amp;lt;esc&amp;gt;[0m&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This shouldn't be necessary, though: Does &lt;code&gt;:set t_te?&lt;/code&gt; report different values when Vim is run within screen and when it is not? If so, you may want to inspect the value stored for &lt;code&gt;te&lt;/code&gt; in your &lt;code&gt;terminfo&lt;/code&gt; database by running &lt;code&gt;terminfo -C&lt;/code&gt; from the shell within and outside of screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/11911/how-can-vim-be-configured-to-restore-normal-terminal-color-on-exit/11918#11918&quot;&gt;See my earlier answer to a similar question for a bit more detail on the &lt;code&gt;t_te&lt;/code&gt; setting.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-08-15T10:29:31.310" LastActivityDate="2017-08-15T10:29:31.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13248" PostTypeId="1" AcceptedAnswerId="13249" CreationDate="2017-08-15T16:04:15.457" Score="1" ViewCount="785" Body="&lt;p&gt;I have a list of file names I'm trying to create insert statements out of. In each file name is the ID I need for the primary key, that I just need to copy from inside the file name to the front of the line (or rear really) so I can continue to build the statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[0-9][0-9][0-9] will find the string I need, I am just not sure how to &quot;store&quot; it and place it at the front of the line. I just need to know what goes in the place of &quot;whatgoeshere&quot; I guess? Or am I going about it all wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/[0-9][0-9][0-9]/^whatgoeshere/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDITED for examples:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Input:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;ABC001.jpg&quot; &#xA;&quot;ABC002.TIF&quot; &#xA;&quot;DEF66.JPG&quot;&#xA;&quot;\\server\subfolder\XYZ011.png&quot;&#xA;&quot;JKL1234.png&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Desired Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;001, 'ABC001.jpg'&#xA;002, 'ABC002.TIF' &#xA;066, 'DEF66.JPG'&#xA;011, '\\server\subfolder\XYZ011.png'&#xA;1234, 'JKL1234.png'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which I will then turn into (which I know how to do once the previous step is done):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;insert into table_name(ID, file_loc) values (001, '\\server\subfolder\ABC001.jpg');&#xA;insert into table_name(ID, file_loc) values (002, '\\server\subfolder\ABC002.TIF');&#xA;---etc and so on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13864" LastEditorUserId="13864" LastEditDate="2017-08-15T20:06:38.370" LastActivityDate="2017-08-15T21:19:47.063" Title="Copy a substring in line to the front of the line" Tags="|regular-expression|cut-copy-paste|substitute|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13249" PostTypeId="2" ParentId="13248" CreationDate="2017-08-15T17:19:42.207" Score="2" Body="&lt;p&gt;If I understand correctly, what you're looking for is &lt;code&gt;\(\)&lt;/code&gt; and &lt;code&gt;\1&lt;/code&gt; to capture the match and then use it later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, you could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/\([0-9][0-9][0-9]\)/^other stuff \1/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; around the search pattern captures it and the &lt;code&gt;\1&lt;/code&gt; goes where ever you want the pattern to go in the replacement part (after &quot;stuff &quot; in my example).  You can also capture multiple groups and refer to them with &lt;code&gt;\2&lt;/code&gt;, &lt;code&gt;\3&lt;/code&gt;, etc.  See &lt;code&gt;:help \(&lt;/code&gt; for more info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, you should be able to simplify your search pattern with &lt;code&gt;\d\{3}&lt;/code&gt; to find three consecutive digits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT based on your examples:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on your examples, this is what I would do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%s/&quot;\(\D*\(\d\+\)\D*\)&quot;/\2, '\1'/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will extract the number and put it at the beginning of the line as well as change the double quotes to single quotes.  This assumes that each line only contains a string within double quotes and that there is only one set of numbers within the line.  This doesn't handle adding the 0 at the start of your third example, but this stackoverflow post might help with that: &lt;a href=&quot;https://stackoverflow.com/questions/1316963/vim-padding-out-lines-with-a-character&quot;&gt;https://stackoverflow.com/questions/1316963/vim-padding-out-lines-with-a-character&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation of the search pattern:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;&lt;/code&gt; - Search for the first double quote.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(&lt;/code&gt; - Start capturing the string within the double quotes so we can print it later.  It will be &lt;code&gt;\1&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\D*&lt;/code&gt; - Find as many non-digit characters as possible at the start of the double quote.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(&lt;/code&gt; - Start a second capture group of just the digits.  This will be &lt;code&gt;\2&lt;/code&gt; in the replacement.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\d\+&lt;/code&gt; - Find as many digit characters as possible (at least one).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\)&lt;/code&gt; - End the capture group for the digits.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\D*&lt;/code&gt; - Find the remaining non-digit characters within the double quotes.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\)&lt;/code&gt; - End the capture group of the entire string within the double quotes.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;&lt;/code&gt; - Find the ending double quote.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1115" LastEditorUserId="1115" LastEditDate="2017-08-15T21:19:47.063" LastActivityDate="2017-08-15T21:19:47.063" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13250" PostTypeId="1" AcceptedAnswerId="13253" CreationDate="2017-08-15T18:31:35.573" Score="4" ViewCount="2002" Body="&lt;p&gt;Sometimes, such as when transcribing FORTRAN code, I find it useful to enter uppercase letters without holding down the &lt;kbd&gt;Shift&lt;/kbd&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, enabling &lt;kbd&gt;Caps Lock&lt;/kbd&gt; is a problem in command mode. Here is my (admittedly inelegant) workaround:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AllCaps()&#xA;    inoremap a A&#xA;    inoremap b B&#xA;    inoremap c C&#xA;    inoremap d D&#xA;    inoremap e E&#xA;    inoremap f F&#xA;    inoremap g G&#xA;    inoremap h H&#xA;    inoremap i I&#xA;    inoremap j J&#xA;    inoremap k K&#xA;    inoremap l L&#xA;    inoremap m M&#xA;    inoremap n N&#xA;    inoremap o O&#xA;    inoremap p P&#xA;    inoremap q Q&#xA;    inoremap r R&#xA;    inoremap s S&#xA;    inoremap t T&#xA;    inoremap u U&#xA;    inoremap v V&#xA;    inoremap w W&#xA;    inoremap x X&#xA;    inoremap y Y&#xA;    inoremap z Z&#xA;endfunction&#xA;&#xA;command! AllCaps call AllCaps()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have an similar command called &lt;code&gt;NoAllCaps&lt;/code&gt; that maps them back to normal. It does the job, but it's not pretty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way?&lt;/p&gt;&#xA;" OwnerUserId="4498" LastEditorUserId="4472" LastEditDate="2017-08-16T01:55:34.620" LastActivityDate="2018-01-19T12:22:20.487" Title="Caps Lock in insert mode only" Tags="|key-bindings|letter-case|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13251" PostTypeId="2" ParentId="13250" CreationDate="2017-08-15T19:05:44.697" Score="0" Body="&lt;p&gt;Are you okay converting the text after you enter it? If so, type in lowercase, select the text with Visual mode and type &lt;code&gt;U&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or avoid Visual mode with &lt;code&gt;gU{motion}&lt;/code&gt;. (See &lt;code&gt;:help uppercase&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Too easy? :)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-08-15T19:11:07.360" LastActivityDate="2017-08-15T19:11:07.360" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13253" PostTypeId="2" ParentId="13250" CreationDate="2017-08-16T11:15:01.277" Score="3" Body="&lt;p&gt;This isn't as concise as my earlier solution (see below) or &lt;a href=&quot;https://vi.stackexchange.com/a/13254/343&quot;&gt;statox's answer&lt;/a&gt;, but it's much cleaner than the former and has the advantage over the latter in that it uppercases individual letters as you type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AllCaps()&#xA;  augroup all_caps&#xA;    autocmd!&#xA;    autocmd InsertCharPre * call &amp;lt;sid&amp;gt;Capitalise()&#xA;  augroup END&#xA;endfunction&#xA;&#xA;function! NoAllCaps()&#xA;  autocmd! all_caps&#xA;endfunction&#xA;&#xA;function! s:Capitalise()&#xA;  let ascii_number = char2nr(v:char)&#xA;  if 97 &amp;lt;= ascii_number &amp;amp;&amp;amp; ascii_number &amp;lt;= 122&#xA;    let v:char = nr2char(ascii_number - 32)&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;AllCaps()&lt;/code&gt; function sets up an autocommand to intercept keypresses during insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;s:Capitalise()&lt;/code&gt; function upper cases each individual keypress if it's a lower case letter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;NoAllCaps()&lt;/code&gt; function simply removes the autocommand.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Older Solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is a more concise version of your existing solution that creates the maps programmatically in a loop.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AllCaps()&#xA;  for letter in range(97,122)&#xA;    execute &quot;inoremap &quot; . nr2char(letter, 1) . &quot; &quot; . nr2char(letter - 32, 1)&#xA;  endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;The capslock.vim Plugin&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have subsequently discovered Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-capslock/blob/master/plugin/capslock.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;capslock.vim plugin&lt;/a&gt;, which uses both of the methods described above to implement this functionality.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Alternative methods&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can also set up &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#language-mapping&quot; rel=&quot;nofollow noreferrer&quot;&gt;language mappings&lt;/a&gt; or a &lt;a href=&quot;http://vimhelp.appspot.com/mbyte.txt.html#mbyte-keymap&quot; rel=&quot;nofollow noreferrer&quot;&gt;keymap&lt;/a&gt; to translate lower to upper case and vice versa, &lt;a href=&quot;http://vim.wikia.com/wiki/Insert-mode_only_Caps_Lock&quot; rel=&quot;nofollow noreferrer&quot;&gt;as described on the Vim Tips Wiki&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once set up, both of the above can be toggled by pressing &lt;kbd&gt;Ctrl+^&lt;/kbd&gt;. (See &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-%5E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-^&lt;/code&gt;&lt;/a&gt;.) See the &lt;a href=&quot;http://vim.wikia.com/wiki/Insert-mode_only_Caps_Lock&quot; rel=&quot;nofollow noreferrer&quot;&gt;linked page on the Wiki&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-19T12:22:20.487" LastActivityDate="2018-01-19T12:22:20.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13254" PostTypeId="2" ParentId="13250" CreationDate="2017-08-16T12:25:04.520" Score="2" Body="&lt;p&gt;You could use the following lines to get an automated solution, I'm not sure if it is really prettier but it seems to be working and takes only 3 lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:capslockfortran = 1&#xA;nnoremap &amp;lt;F5&amp;gt; :let g:capslockfortran = !g:capslockfortran&amp;lt;CR&amp;gt;&#xA;&#xA;autocmd InsertLeave * if g:capslockfortran | execute &quot;normal! `[v`]U | `]&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first two lines create a variable &lt;code&gt;g:capslockfortran&lt;/code&gt; initialized to &lt;code&gt;1&lt;/code&gt; and a mapping (&lt;code&gt;&amp;lt;F5&amp;gt;&lt;/code&gt;) which toggle the value of this variable between &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;0&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third line creates an autocommand which is triggered each time you leave insert mode in fortran files &lt;em&gt;(I never wrote fortran before, it seems that the extension is &lt;code&gt;.f90&lt;/code&gt; but you might want to change that if it is not the correct extension)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command executed tests the value of &lt;code&gt;g:capslockfortran&lt;/code&gt; and if it is set to &lt;code&gt;1&lt;/code&gt; it will select the last inserted text (&lt;code&gt;`[,`]&lt;/code&gt;) and uppercase it with &lt;code&gt;U&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; Thanks to @BLayer comments I also added &lt;code&gt;`]&lt;/code&gt; so that the cursor doesn't change of position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Some notes:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use &lt;code&gt;b:capslockfortran&lt;/code&gt; instead of &lt;code&gt;g:capslockfortran&lt;/code&gt; to be able to enable/disable the automatic uppercase on a buffer basis. That would probably require another autocommand which would initialize the variable for each buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details you can have a look at the following help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd%2devents&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h autocmd-events&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#InsertLeave&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h InsertLeave&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%27%5b&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h '[&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#v_U&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h v_U&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-08-17T07:41:27.917" LastActivityDate="2017-08-17T07:41:27.917" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13255" PostTypeId="1" AcceptedAnswerId="13256" CreationDate="2017-08-16T13:21:46.937" Score="4" ViewCount="221" Body="&lt;p&gt;Im trying to yank part of another line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1  foo=bar &#xA;2&#xA;3  (paste only foo here - without &quot;going/moving&quot; to 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand that I can yank the whole line using &lt;code&gt;:1y.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &quot;pseudocode&quot; for that would be &lt;code&gt;:1yt=&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13877" LastEditorUserId="1841" LastEditDate="2017-08-16T13:36:40.323" LastActivityDate="2017-08-16T20:29:09.120" Title="Yank part of another line based on pattern" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13256" PostTypeId="2" ParentId="13255" CreationDate="2017-08-16T14:19:18.117" Score="4" Body="&lt;p&gt;Your question has two parts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Executing a command on a line different from the current one&lt;/li&gt;&#xA;&lt;li&gt;Executing a command without moving the cursor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;First to yank on the first line you can use this ex command: &lt;code&gt;:1norm! yt=&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be decomposed in three parts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;1&lt;/code&gt; the line on which you want to execute the command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;norm!&lt;/code&gt; which means &quot;execute the following text as some normal mode key presses&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yt=&lt;/code&gt; yank to &lt;code&gt;=&lt;/code&gt; as you already figured out&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now that you know how to yank on another line, you'll realize that the command moves your cursor. You have several solutions to this problem, one of them is to use marks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could simply use &lt;code&gt;ma&lt;/code&gt; before using the previous ex command and after that use &lt;code&gt;`a&lt;/code&gt; to go back to where you were before the command. (IMO it's the simplest solution)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could use several ex commands like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'norm! ma '| execute '1norm! yt=' | execute 'norm! `a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here you'll have to use &lt;code&gt;execute&lt;/code&gt; which means &quot;execute the following string as an ex command&quot;. this is necessary otherwise, vim will consider the &lt;code&gt;|&lt;/code&gt; characters as a part of your &lt;code&gt;norm!&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more details you can read the following help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3anorm&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :norm&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :execute&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#mark&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h mark&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3a%5cbar&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :\bar&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="6489" LastEditDate="2017-08-16T20:29:09.120" LastActivityDate="2017-08-16T20:29:09.120" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13257" PostTypeId="2" ParentId="13255" CreationDate="2017-08-16T17:16:13.537" Score="3" Body="&lt;p&gt;Statox's answer is a great solution. I'd like to provide an alternative:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm m`1Gyt=&amp;lt;C-o&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; is &lt;kbd&gt;ctrl-o&lt;/kbd&gt;, and you can enter it on the command line with &lt;kbd&gt;ctrl-v&lt;/kbd&gt;-&lt;kbd&gt;ctrl-o&lt;/kbd&gt;. This uses a single normal command to add the current location to the jumplist, yank what you need, and then jump to the previous location in the jumplist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#m%60&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h m`&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#CTRL-O&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h CTRL-O&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-08-16T17:16:13.537" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13258" PostTypeId="1" AcceptedAnswerId="13290" CreationDate="2017-08-16T17:39:47.657" Score="2" ViewCount="210" Body="&lt;p&gt;Editing at the top or bottom of the screen is uncomfortable, so why use &lt;code&gt;zz&lt;/code&gt; all the time (also &lt;code&gt;scrolloff&lt;/code&gt;). That works fine in the middle of the document, and in the end, and I can keep the cursor centralized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it seems the beginning of the document cannot be centralized. More precisely, I can't scroll above the first line (while below the last line works fine). Is there anyway to fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="13880" LastActivityDate="2017-08-19T20:58:05.930" Title="Showing lines above beginning of document" Tags="|scrolling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13259" PostTypeId="1" AcceptedAnswerId="13260" CreationDate="2017-08-16T22:30:59.380" Score="4" ViewCount="3637" Body="&lt;p&gt;Let's say I have these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&#xA;# c&#xA;b&#xA;## d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and i want to insert &lt;code&gt;#&lt;/code&gt; on a line starting with a &lt;code&gt;#&lt;/code&gt; so that I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&#xA;## c&#xA;b&#xA;### d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was not able to find anything in the vim help, but I was able to get this far: &lt;code&gt;g/^#/&lt;/code&gt; - what should come after the second &lt;code&gt;/&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="11136" LastActivityDate="2017-08-17T06:48:29.573" Title="How to use :g to insert?" Tags="|global-command|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13260" PostTypeId="2" ParentId="13259" CreationDate="2017-08-16T23:39:49.787" Score="11" Body="&lt;p&gt;What comes after the second &lt;code&gt;/&lt;/code&gt; is an Ex command. In this case you could use&#xA;the &lt;code&gt;:normal&lt;/code&gt; command, which executes its argument as if you typed it in normal&#xA;mode (see &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3anormal&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :normal&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^#/normal I#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or the &lt;code&gt;:substitute&lt;/code&gt; command (see &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3asubstitute&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :substitute&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^#/substitute/^/#/&#xA;&quot; Or just&#xA;:g/^#/s/^/#/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but also you could use the &lt;code&gt;:substitute&lt;/code&gt; command without the &lt;code&gt;:g&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\ze#/#/&#xA;&quot; or&#xA;:%s/^#/#&amp;amp;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5cze&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help /\ze&lt;/code&gt;&lt;/a&gt; and &#xA;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#s%2f%5c%26&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help s/\&amp;amp;&lt;/code&gt;&lt;/a&gt; for more&#xA;information.&lt;/p&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="21" LastEditDate="2017-08-17T06:48:29.573" LastActivityDate="2017-08-17T06:48:29.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13261" PostTypeId="1" AcceptedAnswerId="13262" CreationDate="2017-08-17T08:46:20.953" Score="4" ViewCount="1494" Body="&lt;p&gt;I often use &lt;code&gt;J&lt;/code&gt; to join the current line with the one below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;J                       Join [count] lines, with a minimum of two lines.&#xA;                        Remove the indent and insert up to two spaces (see&#xA;                        below).  Fails when on the last line of the buffer.&#xA;                        If [count] is too big it is reduce to the number of&#xA;                        lines available.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a shortcut key for joining the current line with the line &lt;em&gt;above&lt;/em&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Needless to say, &lt;code&gt;kJ&lt;/code&gt; does the trick; I just wonder if there's a built-in shortcut for that.&lt;/p&gt;&#xA;" OwnerUserId="13179" LastActivityDate="2017-08-17T08:56:08.613" Title="Join the line above the current line" Tags="|key-bindings|join|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13262" PostTypeId="2" ParentId="13261" CreationDate="2017-08-17T08:56:08.613" Score="7" Body="&lt;p&gt;I'm almost sure there is no such mapping. As you wrote, one can use &lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt;. But if you aren't using &lt;kbd&gt;K&lt;/kbd&gt;, you can remap it to &lt;code&gt;kJ&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap K kJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-08-17T08:56:08.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13263" PostTypeId="1" CreationDate="2017-08-17T12:18:26.877" Score="1" ViewCount="300" Body="&lt;p&gt;This little snippet aims to make a little autocomplete script in VimL. the first code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat % | grep function | sed  's/(/ /g' | awk '{print $3}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;list all the method inside a php class. For example the output of this command could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;__construct&#xA;__toString&#xA;foo&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I send to complete function an array&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call complete(col('.'), [&quot;__construct&quot;, &quot;__toString&quot;, &quot;foo&quot;, &quot;bar&quot;])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can see this menu:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pUi5M.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pUi5M.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the final question is, ... how can I transform this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;__construct&#xA;__toString&#xA;foo&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into this &lt;code&gt;[&quot;__construct&quot;, &quot;__toString&quot;, &quot;foo&quot;, &quot;bar&quot;]&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here my wrong code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;F5&amp;gt; &amp;lt;C-R&amp;gt;=CustomComplete()&amp;lt;CR&amp;gt;&#xA;func! CustomComplete()&#xA;    let l:functions = system(&quot;cat % | grep function | sed  's/(/ /g' | awk '{print $3}'&quot;)&#xA;    call complete(col('.'), l:functions)&#xA;    return ''&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2965" LastActivityDate="2017-08-17T13:10:32.187" Title="Store vim external command result lines into a VimL array, to make a little custom autocomplete" Tags="|vimscript|autocompletion|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13264" PostTypeId="2" ParentId="13263" CreationDate="2017-08-17T13:03:25.903" Score="3" Body="&lt;p&gt;You can &lt;code&gt;split()&lt;/code&gt; &lt;code&gt;system()&lt;/code&gt; result into a list, or you can directly use &lt;code&gt;systemlist()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I wouldn't have used a sequence of external programs. Looks like your code is equivalent (untested) to the following which I suspect to be more efficient than cat + grep + sed + awk:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let lines_with_functions = filter(getline(1, '$'), 'v:val =~ &quot;function&quot;')&#xA;let fnames = map(lines_with_functions, 'matchstr(v:val, &quot;\\vfunction\\s+\\zs\\I\\i*\\ze\\s*\\(&quot;)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-08-17T13:10:32.187" LastActivityDate="2017-08-17T13:10:32.187" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13265" PostTypeId="2" ParentId="12931" CreationDate="2017-08-17T14:58:50.383" Score="7" Body="&lt;p&gt;Based on DLMcMMayhem's &lt;a href=&quot;https://vi.stackexchange.com/q/12931/7547#comment-22228&quot;&gt;hint&lt;/a&gt;, I found that following search will do what you need:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/\A*\zs\a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;\A*&lt;/code&gt; searches for zero or more non-alphabetic characters (equivalent to &lt;code&gt;[^A-Za-z]&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;\a&lt;/code&gt; searches for any alphabetic character (equivalent to &lt;code&gt;[A-Za-z]&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;\zs&lt;/code&gt; is a zero-width match (i.e. matches nothing) but tells the regex engine to reset the start of the match to the current position.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When moving to a match with &lt;code&gt;n&lt;/code&gt;, the cursor will move to this position&lt;/li&gt;&#xA;&lt;li&gt;When &lt;code&gt;hlsearch&lt;/code&gt; is turned on, the highlighting will begin at this position&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Mapping&lt;/h2&gt;&#xA;&lt;p&gt;If you need to use this frequently, you can set up a mapping in your &lt;code&gt;.vimrc&lt;/code&gt;. This can be a bit tricky, because there are multiple ways to insert a keyboard code, some of which will only work in Vim (not GVim).&lt;/p&gt;&#xA;&lt;p&gt;The easiest, most compatible way is to type out the following characters into your &lt;code&gt;.vimrc&lt;/code&gt;, verbatim:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; &amp;lt;S-F11&amp;gt; /\A\zs\a&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;map&lt;/code&gt; sets up a keyboard mapping&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; flag tells &lt;code&gt;map&lt;/code&gt; not to echo the command when it executes&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;S-F11&amp;gt;&lt;/code&gt; means &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;F11&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you're unsure how to spell a key, you can type &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; and then the key you want to map to, which will generate a unique code for any key chosen. The codes generated in terminal Vim, however, will be unique to that terminal and are not portable; specifically, they do not work in GVim.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finally comes the keys we want the mapping to type out for us when we use the mapping key&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; represents &lt;kbd&gt;Enter&lt;/kbd&gt;; it's required because you type &lt;kbd&gt;Enter&lt;/kbd&gt; to perform a search action&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Edit&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;2018-09-17 Add &lt;code&gt;*&lt;/code&gt; to regex&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7547" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-09-17T21:44:51.720" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="13267" PostTypeId="1" AcceptedAnswerId="13268" CreationDate="2017-08-17T22:27:17.823" Score="11" ViewCount="5490" Body="&lt;p&gt;I'm trying to understand how the visual-block mode deals with &lt;kbd&gt;Backspace&lt;/kbd&gt; and &lt;kbd&gt;Delete&lt;/kbd&gt;, and if it is possible to vertically select a column of text, delete some characters, then insert new ones in a single selection. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, with these 3 lines of code (each proceeded with 2 spaces):&lt;br&gt;&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  a = 1;  &#xA;  b = 2;  &#xA;  c = 3;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With my cursor on &lt;code&gt;a&lt;/code&gt; I press &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; selecting all the letters, then &lt;kbd&gt;I&lt;/kbd&gt; to go into insert mode. At this point I can delete the two preceeding spaces with &lt;kbd&gt;Backspace&lt;/kbd&gt; then start typing &lt;code&gt;var&lt;/code&gt; but when I hit &lt;kbd&gt;Esc&lt;/kbd&gt; I get the following:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var a = 1;&#xA;  r b = 2;&#xA;  r c = 3;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't understand why Vim is not including the &lt;code&gt;va&lt;/code&gt; on the last two lines. I ran some other tests with &lt;kbd&gt;Backspace&lt;/kbd&gt; and the &lt;kbd&gt;Delete&lt;/kbd&gt; key and noticed that neither of these actions are applied to other lines, however I would then expect something like:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var a = 1;&#xA;  var b = 2;&#xA;  var c = 3;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the multiline cursor doing that causes &lt;code&gt;va&lt;/code&gt; to be overwritten/ignored? Also, I know that I can select the two columns of spaces and delete them with &lt;kbd&gt;d&lt;/kbd&gt; then reselect the three lines and type &lt;code&gt;var&lt;/code&gt;, but is there a way to do this only having to make the selection once?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/q9Yse.jpg&quot; rel=&quot;noreferrer&quot;&gt;deletion then insertion&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://imgur.com/a/Le8qS&quot; rel=&quot;noreferrer&quot;&gt;deletion tests&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've tested this without a &lt;code&gt;vimrc&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13896" LastEditorUserId="5395" LastEditDate="2017-08-18T06:03:54.923" LastActivityDate="2017-08-18T06:17:39.847" Title="Deleting and inserting in a single visual block selection" Tags="|insert-mode|visual-block|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13268" PostTypeId="2" ParentId="13267" CreationDate="2017-08-17T22:57:22.503" Score="17" Body="&lt;p&gt;Instead of deleting with &lt;kbd&gt;d&lt;/kbd&gt;, select &lt;code&gt;spaces&lt;/code&gt; in Visual Block Mode and press &lt;kbd&gt;c&lt;/kbd&gt;, then type &lt;code&gt;var&lt;/code&gt;. Difference is that &lt;kbd&gt;c&lt;/kbd&gt; performs two operations at once - it deletes text and stays in Insert Mode after that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for why Vim is not including &lt;code&gt;va&lt;/code&gt; - simply it's outside of the visually selected block. I couldn't find anything about that in the &lt;code&gt;:help&lt;/code&gt;, but I think Vim is not extending selection left on &lt;kbd&gt;Backspace&lt;/kbd&gt; and it doesn't repeat all the keystrokes like in a macro. It just copies text inserted within seleted area and pastes it after to the remaining lines of selection.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2017-08-18T06:17:39.847" LastActivityDate="2017-08-18T06:17:39.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13269" PostTypeId="1" AcceptedAnswerId="13277" CreationDate="2017-08-18T01:08:23.270" Score="0" ViewCount="173" Body="&lt;p&gt;I have created a &lt;code&gt;vmap&lt;/code&gt; but I can't figure out how to apply a count to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, the mapping is on &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; and &lt;code&gt;4&amp;lt;C-a&amp;gt;&lt;/code&gt; is an example of a command with a count failing to be applied. We would expect the &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; command to be called four times in the second case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the following modified version of &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; for incrementing numbers: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;C-a&amp;gt; $&amp;lt;ESC&amp;gt;`&amp;gt;v`&amp;lt;&amp;lt;C-a&amp;gt;gvo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This version has the benefit that you can visually select a vertical list of numbers and repeatedly increment them using repeated invocations of &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;, without having to reselect, and without having to worry about expanding your selection to capture numbers that have &quot;rolled over&quot; to add another digit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are various tutorials online for getting a count to apply to a mapping. I have been unsuccessful in getting them to work for this command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keywords: &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; &lt;code&gt;ctrl-a&lt;/code&gt; &lt;code&gt;ctrl+a&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13731" LastEditorUserId="343" LastEditDate="2017-12-06T11:23:18.453" LastActivityDate="2017-12-06T11:23:18.453" Title="how to accept count for visual block ctrl+a remap?" Tags="|key-bindings|repeated-commands|visual-block|count|map-operator|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13270" PostTypeId="1" CreationDate="2017-08-18T12:55:28.637" Score="0" ViewCount="95" Body="&lt;p&gt;When I open up a file remotely using &lt;code&gt;scp&lt;/code&gt; (and possibly other protocols), running the &lt;code&gt;undo&lt;/code&gt; command (right away, or repeatedly if I've made edits) clears the file. Why does this happen - is it a bug?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess is that it is a quirk of how remote editing is implemented - like Vim is actually opening a new local file, and then the first &lt;code&gt;change&lt;/code&gt; is to copy all the text of the remote file into the new file.&lt;/p&gt;&#xA;" OwnerUserId="13905" LastEditorUserId="5395" LastEditDate="2017-08-18T12:57:30.723" LastActivityDate="2017-08-18T13:48:55.827" Title="Vim scp undo clears file" Tags="|undo-redo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13271" PostTypeId="1" CreationDate="2017-08-18T13:42:02.210" Score="1" ViewCount="342" Body="&lt;p&gt;I often accidentally open cmdline-window during editing and want to disable the key mappings used to open it in normal mode: &lt;code&gt;q:&lt;/code&gt;, &lt;code&gt;q/&lt;/code&gt;, &lt;code&gt;q?&lt;/code&gt; I tried mapping as such:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap q: &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works when the keys are executed under a second or so but doesn't if there is an extended pause between &lt;code&gt;q&lt;/code&gt; and &lt;code&gt;:&lt;/code&gt;. Until recently I was using this to solve the problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap q &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works for all three mappings but I've discovered I can no longer record macros. How can I disable the cmdline-window mappings and still be able to use &lt;code&gt;q&lt;/code&gt; to record macros?&lt;/p&gt;&#xA;" OwnerUserId="13907" LastEditorUserId="6698" LastEditDate="2017-08-18T14:14:38.183" LastActivityDate="2017-08-18T17:17:11.487" Title="Disable cmdline-window key mappings" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13272" PostTypeId="2" ParentId="13270" CreationDate="2017-08-18T13:48:55.827" Score="1" Body="&lt;p&gt;Vim is using &lt;code&gt;netrw&lt;/code&gt; to enable transparent remote file editing, see &lt;code&gt;:h scp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try running &lt;code&gt;:set modified?&lt;/code&gt; before and after &lt;code&gt;:undo&lt;/code&gt;, you will see that a temporary buffer (probably stored locally) is created, then the content is fetched and written by the plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not a perfect user experience but I guess it's how it works !&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-18T13:48:55.827" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13273" PostTypeId="1" AcceptedAnswerId="13406" CreationDate="2017-08-18T15:59:47.243" Score="2" ViewCount="870" Body="&lt;p&gt;I was looking through the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/vimindex.html#[&quot; rel=&quot;nofollow noreferrer&quot;&gt;default mappings for square brackets&lt;/a&gt;, and I really don't need most of that functionality. I would like to disable these mappings, then use &lt;code&gt;nnoremap [ [[&lt;/code&gt; and &lt;code&gt;nnoremap ] ]]&lt;/code&gt; to be able to jump between functions/definitions with one keystroke. Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps I can turn on &lt;code&gt;set timeout&lt;/code&gt; and &lt;code&gt;set timeoutlen=0&lt;/code&gt; for an individual remap... &lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2017-08-27T23:04:42.300" LastActivityDate="2017-08-28T23:02:51.827" Title="How can I disable square-bracket-prefixed mappings, so I can then remap a single-press square bracket without having to wait for the &quot;timeoutlen&quot;?" Tags="|vimrc|key-bindings|vimscript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13274" PostTypeId="1" AcceptedAnswerId="13275" CreationDate="2017-08-18T16:12:48.360" Score="3" ViewCount="55" Body="&lt;p&gt;I never really use the other commands, and it would be nice to be able to indent/dedent lines this way. The solution for this may be similar to the solution for the &lt;a href=&quot;https://vi.stackexchange.com/questions/13273/how-can-i-disable-all-square-bracket-prefixed-mappings-so-as-to-remap-square-br&quot;&gt;question I asked here&lt;/a&gt;; perhaps involving temporarily setting &lt;code&gt;timeoutlen=0&lt;/code&gt;. Anyone have any ideas?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2022-05-14T22:23:41.360" LastActivityDate="2022-05-14T22:23:41.360" Title="Can I disable the &gt;&gt; and &gt;{motion} commands, then remap the single keystroke &gt; to &quot;indent this line&quot;?" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13275" PostTypeId="2" ParentId="13274" CreationDate="2017-08-18T16:35:38.940" Score="5" Body="&lt;p&gt;You can use &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; option to tell Vim not to wait for any more keys and stop looking for longer mappings.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;nowait&amp;gt; &amp;gt; &amp;gt;&amp;gt;&#xA;nnoremap &amp;lt;nowait&amp;gt; &amp;lt;lt&amp;gt; &amp;lt;lt&amp;gt;&amp;lt;lt&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; requires Vim 7.4+&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I would not recommend these mappings. You can use &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;gt;{motion}&lt;/code&gt; to do your initial indent/shift then use &lt;code&gt;.&lt;/code&gt; to repeat the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :map-nowait&#xA;:h key-notation&#xA;:h .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-08-18T17:07:01.693" LastActivityDate="2017-08-18T17:07:01.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13276" PostTypeId="2" ParentId="13271" CreationDate="2017-08-18T17:17:11.487" Score="2" Body="&lt;p&gt;I doubt this is the answer you want to hear, but you probably need more practice with Vim. Unless you are having key timeout issues all the time then you probably are just not accustom to the commands you are trying to execute. We all fat finger (or at least I do) commands sometime or another. The best way to get better is practice and take each failure as a reminder to keep practicing. I used to hit &lt;code&gt;q:&lt;/code&gt; on accident all the time. I didn't remap &lt;code&gt;q:&lt;/code&gt; to &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; instead I got better at typing, or at least better at typing &lt;code&gt;:q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now opening the command-line window can be annoying, but you can make it easier to close. Add the following to your &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup CommandLineWindow&#xA;    autocmd!&#xA;    autocmd CmdwinEnter * nnoremap &amp;lt;buffer&amp;gt; &amp;lt;esc&amp;gt; :q&amp;lt;cr&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will allow you to use &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; form normal mode to easily close the command-line window. I find this feels natural.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-08-18T17:17:11.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13277" PostTypeId="2" ParentId="13269" CreationDate="2017-08-19T00:26:16.077" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;v:vcount1&lt;/code&gt; with a map expression.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;expr&amp;gt; &amp;lt;c-a&amp;gt; &quot;\&amp;lt;esc&amp;gt;'&amp;lt;V'&amp;gt;&quot;.v:count1.&quot;\&amp;lt;c-a&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key is to escape visual mode then apply the count only to the &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt;. command. Simply use &lt;code&gt;.&lt;/code&gt; to repeat the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you rather reselect and keep visual block mode then use the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;expr&amp;gt; &amp;lt;c-a&amp;gt; &quot;\&amp;lt;esc&amp;gt;`&amp;lt;\&amp;lt;c-v&amp;gt;`&amp;gt;$&quot;.v:count1.&quot;\&amp;lt;c-a&amp;gt;gvo&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :map-expression&#xA;:h string&#xA;:h v:count1&#xA;:h map-modes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-08-19T01:33:27.047" LastActivityDate="2017-08-19T01:33:27.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13278" PostTypeId="2" ParentId="12901" CreationDate="2017-08-19T09:51:15.363" Score="1" Body="&lt;p&gt;You can use the built-in file browser &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;netrw&lt;/a&gt; in a side panel.  Here is a quick introduction:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Open the folder in netrw, perhaps with &lt;code&gt;vim .&lt;/code&gt; or &lt;code&gt;:e folder&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Chose a file and hit &lt;kbd&gt;v&lt;/kbd&gt; to open it in a [v]ertical split.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;But you probably want the file browser on the left. Hit &lt;kbd&gt;Ctrl-W&lt;/kbd&gt; &lt;kbd&gt;x&lt;/kbd&gt; (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#g:netrw_altv&quot; rel=&quot;nofollow noreferrer&quot;&gt;permanent fix&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You might want your current window to be wider. Hit &lt;kbd&gt;20&lt;/kbd&gt; &lt;kbd&gt;Ctrl-W&lt;/kbd&gt; &lt;kbd&gt;&amp;gt;&lt;/kbd&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;strong&gt;next time&lt;/strong&gt; you want to open a file, hit &lt;kbd&gt;Shift-P&lt;/kbd&gt; instead of &lt;kbd&gt;v&lt;/kbd&gt; to open it in the existing file panel (the [P]revious window).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Bonus:&lt;/em&gt;&lt;/strong&gt; As the name suggests, netrw can even work over a network (FTP, SFTP).  I am not sure if file tree plugins like &lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;NerdTree&lt;/a&gt; and &lt;a href=&quot;https://github.com/vim-scripts/vtreeexplorer&quot; rel=&quot;nofollow noreferrer&quot;&gt;VTreeExplorer&lt;/a&gt; offer that behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get netrw to display a tree by pressing the &lt;kbd&gt;i&lt;/kbd&gt; key a few times.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2018-03-10T10:41:10.573" LastActivityDate="2018-03-10T10:41:10.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13279" PostTypeId="1" AcceptedAnswerId="17146" CreationDate="2017-08-19T12:30:13.373" Score="3" ViewCount="423" Body="&lt;h3&gt;Problem&lt;/h3&gt;&#xA;&lt;p&gt;I want to view &lt;code&gt;man&lt;/code&gt;-pages in colour, &lt;strong&gt;preserving &lt;code&gt;nroff&lt;/code&gt;'s bold and italic directives&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How would I edit a buffer's text and setup highlight regions:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;manpage_bold&lt;/code&gt;: For all instances of &lt;code&gt;X&lt;/code&gt; &lt;code&gt;&amp;lt;backspace&amp;gt;&lt;/code&gt; &lt;code&gt;X&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Conceal / remove the final 2 characters, leaving only the first.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;manpage_italic&lt;/code&gt;: For all instances of &lt;code&gt;_&lt;/code&gt; &lt;code&gt;&amp;lt;backspace&amp;gt;&lt;/code&gt; &lt;code&gt;X&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Conceal / remove the leading two characters, leaving only the last.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Where &lt;code&gt;X&lt;/code&gt; is any character other than backspace.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Background&lt;/h3&gt;&#xA;&lt;p&gt;I have &lt;a href=&quot;https://unix.stackexchange.com/a/329092/143394&quot;&gt;&lt;code&gt;less&lt;/code&gt; configured to display manual pages in colour&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CyNy6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CyNy6.png&quot; alt=&quot;Coloured man page example &quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is achieved by telling &lt;code&gt;less&lt;/code&gt; to replace &lt;em&gt;overstrikes&lt;/em&gt; that &lt;code&gt;groff&lt;/code&gt;/&lt;code&gt;nroff&lt;/code&gt; produces to indicate bold / italics with &lt;a href=&quot;https://en.wikipedia.org/wiki/ANSI_escape_code#graphics&quot; rel=&quot;nofollow noreferrer&quot;&gt;ANSI SGR&lt;/a&gt; colour codes.&lt;/p&gt;&#xA;&lt;p&gt;I want &lt;code&gt;vim&lt;/code&gt; to be able to do the analogous thing: view man pages with the original bold / italics by removing the overstrikes and setting up highlight regions.&lt;/p&gt;&#xA;&lt;h3&gt;Overstriking&lt;/h3&gt;&#xA;&lt;p&gt;What's an overstrike I hear you ask? &lt;em&gt;*takes deep breath*&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Unix is a venerable old operating system, dating from the times when teletypes hammered inked ribbon, imprint characters on paper.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Bold&lt;/strong&gt; characters were printed by printing the character, backspacing, then printing the same character again - twice as much ink was impressed upon the paper.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Italic&lt;/em&gt; characters are indicated by printing an underscore (&lt;code&gt;_&lt;/code&gt;), backspace and then the character to be rendered. &lt;a href=&quot;https://unix.stackexchange.com/a/274795/143394&quot;&gt;(source)&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Over 40 years later, &lt;code&gt;man&lt;/code&gt; still uses &lt;code&gt;nroff&lt;/code&gt; to generate the text that is displayed from the &lt;code&gt;troff&lt;/code&gt; man page source file... and &lt;code&gt;nroff&lt;/code&gt; still uses overstriking to indicate boldface / italics.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Non-solutions&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/nhooyr/neoman.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;neoman&lt;/a&gt; and &lt;a href=&quot;https://github.com/lambdalisue/vim-manpager&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-man-pager&lt;/a&gt; only colour by regular expression- they remove the &lt;code&gt;nroff&lt;/code&gt; bold / italic directives which are useful in warnings, etc.&lt;/p&gt;&#xA;&lt;p&gt;When using &lt;code&gt;GROFF_SGR=1&lt;/code&gt; to produce ANSI SGR codes rather than overstrikes,&#xA;&lt;a href=&quot;https://github.com/powerman/vim-plugin-AnsiEsc&quot; rel=&quot;nofollow noreferrer&quot;&gt;AnsiEsc&lt;/a&gt; is needed to display the output, and this doesn't work with &lt;code&gt;set ft=man&lt;/code&gt; syntax highlighting.&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-08-20T18:48:54.450" Title="Convert man page nroff overstrike text into highlight regions" Tags="|pager|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13280" PostTypeId="5" CreationDate="2017-08-19T12:31:57.930" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2017-08-19T12:31:57.930" LastActivityDate="2017-08-19T12:31:57.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13281" PostTypeId="4" CreationDate="2017-08-19T12:31:57.930" Score="0" Body="Using vi/vim as a pager, eg in lieu of `less`" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2017-08-20T02:29:26.213" LastActivityDate="2017-08-20T02:29:26.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13283" PostTypeId="2" ParentId="12901" CreationDate="2017-08-19T14:04:38.970" Score="2" Body="&lt;p&gt;I really like &lt;a href=&quot;http://ranger.nongnu.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ranger&lt;/a&gt; as a file chooser. Unlike &lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDTree&lt;/a&gt; it only shows up when you need it, has Vim like key bindings and can be used without Vim as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/ranger/ranger-assets/master/screenshots/screenshot.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-08-19T14:04:38.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13284" PostTypeId="1" CreationDate="2017-08-19T14:15:08.030" Score="0" ViewCount="296" Body="&lt;p&gt;I have ultisnips installed and when I type &lt;code&gt;ve&lt;/code&gt; in normal mode it changes the word. Let's say I have:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;word&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I type &lt;code&gt;ve&lt;/code&gt; to select until the end of the word it does the following&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://asciinema.org/a/W8wp3y9mOjBOmowcZTvGqzLyB&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://asciinema.org/a/W8wp3y9mOjBOmowcZTvGqzLyB.png&quot; alt=&quot;asciicast&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plese also help me with the proper tag for this question. &lt;/p&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2017-08-20T00:23:34.067" LastActivityDate="2017-08-20T00:23:34.067" Title="Debug ultisnip snippet" Tags="|normal-mode|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13285" PostTypeId="2" ParentId="13185" CreationDate="2017-08-19T17:10:50.303" Score="1" Body="&lt;p&gt;You should take a look at &lt;a href=&quot;http://vim.wikia.com/wiki/Compiling_LaTeX_from_Vim#Vim-Latex_plugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;this Wikia page&lt;/a&gt; about options to compile LaTeX from Vim. The &lt;a href=&quot;https://github.com/vim-latex/vim-latex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-latex&lt;/a&gt; plugin should cover all your needs (e.g. &lt;a href=&quot;http://vim-latex.sourceforge.net/documentation/latex-suite/latex-project.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multiple file LaTeX projects&lt;/a&gt;), you can find the full documentation &lt;a href=&quot;http://vim-latex.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; or with &lt;code&gt;:help latex-suite&lt;/code&gt; from within Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative method is to tweak the &lt;code&gt;&amp;amp;makeprg&lt;/code&gt; option in order to change the program used by the &lt;code&gt;:make&lt;/code&gt; command. From &lt;a href=&quot;http://vim.wikia.com/wiki/Compiling_LaTeX_from_Vim#Manual_setup&quot; rel=&quot;nofollow noreferrer&quot;&gt;the same article&lt;/a&gt;; if using &lt;code&gt;pdflatex&lt;/code&gt;, add this to &lt;code&gt;ftplugin/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:tex_flavor = 'pdflatex'&#xA;compiler tex&#xA;set makeprg=pdflatex\ \-file\-line\-error\ \-interaction=nonstopmode&#xA;set errorformat=%f:%l:\ %m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h :_%&lt;/code&gt; and &lt;code&gt;:h :_#&lt;/code&gt; for their special meaning in &lt;code&gt;&amp;amp;makeprg&lt;/code&gt;.&#xA;Note that &lt;code&gt;&amp;amp;errorformat&lt;/code&gt; is used to describe the output, available in the &lt;code&gt;quickfix&lt;/code&gt; window after each run. &lt;a href=&quot;https://github.com/vim-latex/vim-latex/blob/master/compiler/tex.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is how those are &quot;dynamically&quot; defined in the plugin for LaTeX-suite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you are able to execute &lt;code&gt;:make&lt;/code&gt; successfully, just add a mapping to save, compile and open (this assumes the file is created with the same location and name, and that &lt;code&gt;open&lt;/code&gt; is an actual PDF viewer in your PATH):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap \lv :w&amp;lt;CR&amp;gt;:make&amp;lt;CR&amp;gt;:!open expand('%:r').pdf&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :nnoremap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h expand()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h filename-modifiers&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-19T17:10:50.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13286" PostTypeId="2" ParentId="12901" CreationDate="2017-08-19T18:25:58.960" Score="6" Body="&lt;p&gt;I used &lt;a href=&quot;https://github.com/tpope/vim-vinegar&quot; rel=&quot;nofollow noreferrer&quot;&gt;vinegar&lt;/a&gt; for a long time, and thanks to &quot;the tpope way&quot; taught me the native &lt;code&gt;netrw&lt;/code&gt; shortcuts (which has &lt;a href=&quot;https://shapeshed.com/vim-netrw/#changing-the-directory-view-in-netrw&quot; rel=&quot;nofollow noreferrer&quot;&gt;a tree view&lt;/a&gt; by the way, press &lt;code&gt;i&lt;/code&gt; 3 times). All I miss on a bare Vim is the &lt;code&gt;-&lt;/code&gt; mapping to go up a directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though I switched to &lt;a href=&quot;https://github.com/justinmk/vim-dirvish&quot; rel=&quot;nofollow noreferrer&quot;&gt;dirvish&lt;/a&gt; which is &lt;em&gt;insanely&lt;/em&gt; faster on large directories and has an even more idiomatic approach; from the README:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Path navigator designed to work with Vim's built-in mechanisms and&#xA;  &lt;a href=&quot;https://github.com/tpope/vim-eunuch&quot; rel=&quot;nofollow noreferrer&quot;&gt;complementary&lt;/a&gt;&#xA;  &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugins&lt;/a&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Each line is a filepath (hidden by&#xA;  &lt;a href=&quot;https://neovim.io/doc/user/syntax.html#conceal&quot; rel=&quot;nofollow noreferrer&quot;&gt;conceal&lt;/a&gt;)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Never modifies the filesystem&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Visual selection opens multiple files&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Unlike NERDTree and other plugins mimicking a classic IDE, those two use current buffer to display the file listing forcing a more focused workflow, and in the end allowing more space for the content. Nothing prevents you from opening netrw or dirvish in a vertical split like a project drawer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/W1wkD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/W1wkD.png&quot; alt=&quot;Neovim w/ dirvish &amp;amp; ctrlp&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also used to &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;ctrlp&lt;/a&gt; (visible above) to quickly find files in the current directory. This config inspired from the thoughbot post &lt;a href=&quot;https://robots.thoughtbot.com/faster-grepping-in-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Faster Grepping in Vim&lt;/a&gt;, replaces &lt;code&gt;grep&lt;/code&gt; with &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;ag&lt;/code&gt;&lt;/a&gt; when available:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if executable('ag')&#xA;  &quot; Use Ag over Grep (additional options: --column, --ignore-case)&#xA;  set grepprg=ag\ --nocolor\ --nogroup\ --vimgrep&#xA;&#xA;  &quot; Use The Silver Searcher in CtrlP for listing files&#xA;  &quot; Respect .gitignore and .agignore, ignores hidden files by default&#xA;  let g:ctrlp_user_command = 'ag --nogroup --nocolor --files-with-matches --hidden --ignore .git -g &quot;&quot; --literal %s'&#xA;  &quot; Disable per-session caching&#xA;  let g:ctrlp_use_caching = 0&#xA;else&#xA;  &quot; Exclude .gitignore patterns&#xA;  let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -co --exclude-standard']&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But a simple map can do the trick, just type &lt;code&gt;:e **/*&lt;/code&gt; followed by a pattern and cycle with &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Find a file in current working directory&#xA;nnoremap &amp;lt;Leader&amp;gt;e :e **/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2017-08-24T20:18:53.217" LastActivityDate="2017-08-24T20:18:53.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13287" PostTypeId="2" ParentId="13284" CreationDate="2017-08-19T18:40:59.097" Score="1" Body="&lt;p&gt;Have you tried to &lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;debug your vimrc file&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the issue is narrowed down to this plugin, the &lt;a href=&quot;/questions/tagged/plugin-ultisnips&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;plugin-ultisnips&amp;#39;&quot; rel=&quot;tag&quot;&gt;plugin-ultisnips&lt;/a&gt; tag would be relevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you should post the problematic part of your configuration here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: what does &lt;code&gt;:nmap ve&lt;/code&gt; output?&lt;/p&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2017-08-19T19:06:02.337" LastActivityDate="2017-08-19T19:06:02.337" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13288" PostTypeId="1" AcceptedAnswerId="13289" CreationDate="2017-08-19T19:21:19.170" Score="1" ViewCount="1289" Body="&lt;p&gt;I'm trying to write a script to take a bunch of vim sources in plugins and combine them into a single vimrc that I'm going to treat as an essentially opaque binary file. I'm doing this partially to simplify the process of deploying my vimrc to a new machine and partially to get more familiar with the ins and outs of vimscript/viml.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To start, I'm taking an old plugin &lt;a href=&quot;https://github.com/kana/vim-arpeggio&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kana/vim-arpeggio&lt;/a&gt;, extracting all the non-test &lt;code&gt;.vim&lt;/code&gt; files and concatenating them with my ordinary &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I do that though, I see a bunch of error messages this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;E746: Function name does not match script file name: arpeggio#_map_or_list&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The file is defined in &lt;code&gt;bundle/autoload/arpeggio.vim&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;140:function! arpeggio#_map_or_list(modes, remap_p, q_args)  &quot;{{{2&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had assumed that the &lt;code&gt;arpeggio#&lt;/code&gt; was just another form of namespacing in vim, but it seems there's more to the story.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it have any intrinsic relation to literal name of a file? Is it possible to trick vim into not performing this check?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-08-21T14:38:52.897" Title="How to fake a script file name inside a monolithic vimrc?" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13289" PostTypeId="2" ParentId="13288" CreationDate="2017-08-19T19:44:27.570" Score="3" Body="&lt;p&gt;That's an autoload function. They are used to allow functions to be loaded only when required (when they are called), so that they don't impact Vim's startup time, and for packaging of functions into libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help autoload&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Using a script in the &quot;autoload&quot; directory is simpler, but requires using&#xA;  exactly the right file name.  A function that can be autoloaded has a name&#xA;  like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   :call filename#funcname()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;When such a function is called, and it is not defined yet, Vim will search the&#xA;  &quot;autoload&quot; directories in 'runtimepath' for a script file called&#xA;  &quot;filename.vim&quot;.  For example &quot;~/.vim/autoload/filename.vim&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also &lt;code&gt;:help 41.15&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to move these functions into your .vimrc (losing the autoload benefits), you can simply rename them not to contain the &lt;code&gt;#&lt;/code&gt; character, (and to start with an upper case letter), but I completely agree with &lt;a href=&quot;https://vi.stackexchange.com/a/13291/343&quot;&gt;Luc Hermitte&lt;/a&gt; that it's not a good idea to do so.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-08-21T13:38:09.633" LastActivityDate="2017-08-21T13:38:09.633" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13290" PostTypeId="2" ParentId="13258" CreationDate="2017-08-19T20:58:05.930" Score="2" Body="&lt;p&gt;There is no direct solution to this unless you play with the internals. However you can use a macro to simulate what you are trying to acheive. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;use &lt;code&gt;:1s/\%^/\=&quot;\n\n\n\n\n\n\n\n\n\n\n&quot;/g &amp;lt;Enter&amp;gt; zz&lt;/code&gt; as the first macro to enter 10 lines above the first line of text and center the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After you are done editing, you can use &lt;code&gt;:1s/\n\n\n\n\n\n\n\n\n\n//g&lt;/code&gt; as the second macro to delete the first 10 lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details and explainations can be found here: &lt;a href=&quot;https://github.com/alphaCTzo7G/stackexchange/blob/master/solution.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/alphaCTzo7G/stackexchange/blob/master/solution.md&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can clone this and play around with this file and see if it works for you.&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2017-08-19T20:58:05.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13291" PostTypeId="2" ParentId="13288" CreationDate="2017-08-19T22:37:47.420" Score="3" Body="&lt;p&gt;You don't want to do that for several reasons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Autoload functions need to be in specific autoload plugin files. If you rename the functions, you'll have to rename all their calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There exist script variables and script functions. They are like static variables in C: their visibility is restricted to one file. You can be sure that if two different files have a &lt;code&gt;s:foo&lt;/code&gt; variable and a &lt;code&gt;s:bar()&lt;/code&gt; function, they are certainly used for totally unrelated things. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There exist syntax scripts that are loaded according to specific rules. You don't want to load C syntax highlighting while editing Python files for instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same is true with ftplugins. They are loaded on the fly, when they need to be loaded. You'd need to replace their automated loading with Vim 5 tricks based on autocommands. Colorscheme and compiler plugins are also loaded in their own way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You really don't want to do this. If vim plugins are made of several files, there is a reason. Instead, I encourage you to learn stuff like &lt;code&gt;rsync&lt;/code&gt;, &lt;code&gt;tar&lt;/code&gt;, &lt;code&gt;git&lt;/code&gt; and use them to define a simplified way to deploy your configuration to other places.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to delve into scripting vim, one of the important step consists in understanding Vim way of splitting the venerable &lt;code&gt;.exrc&lt;/code&gt; into multiple files organized into specific directories each with a specific &lt;em&gt;raison d'être&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: autoload plugin files serve two purposes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;delayed/on-the-fly loading that improve vim starting time&lt;/li&gt;&#xA;&lt;li&gt;defining libraries of functions&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-08-21T14:38:52.897" LastActivityDate="2017-08-21T14:38:52.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13292" PostTypeId="2" ParentId="13180" CreationDate="2017-08-20T04:06:32.323" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/LEI/dot-vim/blob/eb0b745ecdb245194fd8957c8338d698cfffe700/config/ale.vim#L81-L102&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is what I ended up using to prevent the cursor from moving after executing &lt;code&gt;copen&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! OpenErrors(job_id, data, event)&#xA;    &quot; Store the original window number&#xA;    let l:winnr = winnr()&#xA;&#xA;    &quot; Open a window to show the current list of errors&#xA;&#xA;    &quot; If focus changed, jump to the last window&#xA;    if l:winnr !=# winnr()&#xA;        wincmd p&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, the &lt;a href=&quot;https://github.com/romainl/vim-qf&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-qf&lt;/a&gt; plugin makes it easier to work with the location/quickfix list.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-20T04:06:32.323" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13293" PostTypeId="2" ParentId="11827" CreationDate="2017-08-20T04:58:56.757" Score="1" Body="&lt;p&gt;As Luc said, you would have to use an &lt;code&gt;autocmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup NoFileType&#xA;  autocmd!&#xA;  autocmd BufNewFile,BufRead * if &amp;amp;filetype ==# '' | setlocal filetype=noft | endif&#xA;  autocmd FileType noft echom 'No file type!'&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or just add this to &lt;code&gt;ftdetect/noft.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead * if &amp;amp;filetype ==# '' | set filetype=noft | endif &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can add mappings in &lt;code&gt;ftplugin/noft.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://vi.stackexchange.com/questions/2545/how-can-i-run-an-autocmd-when-starting-vim-with-no-file-a-non-existing-file-or&quot;&gt;this question&lt;/a&gt; about detecting an empty file at startup.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2017-08-20T05:08:54.767" LastActivityDate="2017-08-20T05:08:54.767" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13294" PostTypeId="2" ParentId="13245" CreationDate="2017-08-20T05:39:25.337" Score="3" Body="&lt;p&gt;Neocomplete is an alternative that may have &lt;a href=&quot;https://github.com/Shougo/neosnippet-snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;different snippets&lt;/a&gt; and is compatible with the UltiSnips repository.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that if you can't find what you are looking for, you might have to &lt;a href=&quot;https://www.sirver.net/blog/2012/01/08/second-episode-of-ultisnips-screencast/&quot; rel=&quot;nofollow noreferrer&quot;&gt;create your own&lt;/a&gt; as statox stated.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-20T05:39:25.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13295" PostTypeId="1" CreationDate="2017-08-20T09:52:58.637" Score="5" ViewCount="1091" Body="&lt;p&gt;Having vim setup for development gives some undesirable effects for editing commit messages &lt;em&gt;(margin not 72, auto-indent typically isn't needed, probably literal tab characters aren't desired, maybe strip trailing space on save?... etc)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are good filetype options for git commit messages?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyFTypeGitCommit()&#xA;  &quot; Good options for commit messages.&#xA;endfunc&#xA;&#xA;autocmd FileType gitcommit call MyFTypeGitCommit()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note, I could post my settings but not sure they're worth promoting for others to use, if someone has this figured out it's likely going to be a more useful answer.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="301" LastEditDate="2017-08-20T09:58:10.420" LastActivityDate="2023-03-24T15:48:23.777" Title="Good vimrc settings for commit messages?" Tags="|vimrc|margin|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13296" PostTypeId="2" ParentId="13295" CreationDate="2017-08-20T10:13:37.770" Score="3" Body="&lt;p&gt;I am using this in &lt;code&gt;ftplugin/gitcommit.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Enable spellchecking&#xA;if has('spell')&#xA;  setlocal spell&#xA;endif&#xA;&#xA;&quot; Automatically wrap at 72 characters&#xA;setlocal textwidth=72&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-20T10:13:37.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13297" PostTypeId="2" ParentId="13295" CreationDate="2017-08-20T10:18:58.213" Score="4" Body="&lt;p&gt;Posting own answer, in case others find it useful.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;function MyFTypeGitCommit()&#xA;  &amp;quot; Check spelling.&#xA;  setlocal spell&#xA;  &amp;quot; Make bad spelling very obvious! (personal preference).&#xA;  :hi SpellBad ctermbg=red ctermfg=white guibg=red guifg=white&#xA;&#xA;  &amp;quot; Never auto-indent.&#xA;  setlocal indentexpr=''&#xA;&#xA;  &amp;quot; No literal tabs, indent 4.&#xA;  setlocal expandtab shiftwidth=4 tabstop=4&#xA;&#xA;  &amp;quot; Margin for emails, make it obvious where 72 characters is.&#xA;  setlocal textwidth=72&#xA;  setlocal colorcolumn=+1&#xA;&#xA;  &amp;quot; Strip space on save.&#xA;  fun! &amp;lt;SID&amp;gt;StripTrailingWhitespaces()&#xA;    let l = line(&amp;quot;.&amp;quot;)&#xA;    let c = col(&amp;quot;.&amp;quot;)&#xA;    %s/\s\+$//e&#xA;    call cursor(l, c)&#xA;  endfun&#xA;  autocmd BufWritePre &amp;lt;buffer&amp;gt; :call &amp;lt;SID&amp;gt;StripTrailingWhitespaces()&#xA;endfun&#xA;&#xA;autocmd FileType gitcommit call MyFTypeGitCommit()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="301" LastEditorUserId="10604" LastEditDate="2023-03-24T15:48:23.777" LastActivityDate="2023-03-24T15:48:23.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13298" PostTypeId="1" CreationDate="2017-08-20T11:12:00.940" Score="1" ViewCount="44" Body="&lt;p&gt;I created a Vim command which will invoke perl6 as a filter, analogous to &lt;code&gt;:perldo&lt;/code&gt;, though of course it isn't as powerful as &lt;code&gt;:perldo&lt;/code&gt;. (Being an external command rather than an internal interpreter, there is no access to Vim's API and no memory of previous state.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command is defined as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -range=% Perl6do exec &quot;&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;!perl6 -pe &quot; . shellescape(&amp;lt;q-args&amp;gt;, 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to work, but when I make a typo, the error output is inserted into the buffer. How do I make the filter abort if the external command gives an error? Do I need to make a helper function which emulates the &quot;!&quot; behavior and does its own error checking?&lt;/p&gt;&#xA;" OwnerUserId="13936" LastEditorUserId="13936" LastEditDate="2017-08-20T12:07:55.350" LastActivityDate="2017-08-20T12:07:55.350" Title="When defining a command which uses an external tool (like :perldo), how do I cancel upon error?" Tags="|external-command|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13299" PostTypeId="1" CreationDate="2017-08-20T11:54:39.883" Score="0" ViewCount="3091" Body="&lt;p&gt;I often navigate to the next occurrence of the current non-paren character. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`HTTP GET www.example.com/example/com` is an example URL.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the cursor is at the beginning of the line at the &lt;code&gt;`&lt;/code&gt; character, it is useful to jump the the next occurrence of the &lt;code&gt;`&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be achieved by &lt;code&gt;f`&lt;/code&gt; (&lt;a href=&quot;https://stackoverflow.com/questions/9402607/how-to-jump-to-a-specific-character-in-vim&quot;&gt;How to jump to a specific character in vim?&lt;/a&gt;), but I winder if I'm missing any single-character shortcut. If not, I'd be happy to know what's the right way to map such a key binding please.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I navigate to the next occurrence of the current character with s single keystroke?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="13179" LastActivityDate="2017-08-20T13:21:30.380" Title="Jump to next occurrence of the current character" Tags="|key-bindings|search|navigation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13300" PostTypeId="2" ParentId="13299" CreationDate="2017-08-20T13:21:30.380" Score="1" Body="&lt;p&gt;It's tricky and working only for predefined pair of characters, but you can leverage &lt;code&gt;matchit&lt;/code&gt; plugin, found &lt;a href=&quot;https://stackoverflow.com/a/21010756/7796750&quot;&gt;on SO&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let b:match_words='`\&amp;lt;:\&amp;gt;`'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can alternate with &lt;code&gt;%&lt;/code&gt;, though it may have caveats (see &lt;code&gt;:help b:match_words&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-20T13:21:30.380" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13301" PostTypeId="1" CreationDate="2017-08-20T13:22:42.027" Score="0" ViewCount="678" Body="&lt;p&gt;I have the following command in my &lt;code&gt;vimrc&lt;/code&gt;file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-S&amp;gt; &amp;lt;esc&amp;gt;:w&amp;lt;CR&amp;gt; i &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which saves the file in insert mode but, for some reason, it also adds an extra space where cursor is present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does it happen?&lt;/p&gt;&#xA;" OwnerUserId="13939" LastEditorUserId="6698" LastEditDate="2017-08-20T14:00:09.433" LastActivityDate="2017-08-21T02:20:25.437" Title="inoremap &lt;C-S&gt; &lt;esc&gt;:w&lt;CR&gt; i" Tags="|vimrc|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13302" PostTypeId="2" ParentId="13301" CreationDate="2017-08-20T14:18:25.030" Score="0" Body="&lt;p&gt;Maybe try using &lt;code&gt;:startinsert&amp;lt;CR&amp;gt;&lt;/code&gt; instead of &lt;code&gt;i&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="6698" LastEditDate="2017-08-20T14:24:10.627" LastActivityDate="2017-08-20T14:24:10.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13304" PostTypeId="2" ParentId="6875" CreationDate="2017-08-20T20:05:44.773" Score="2" Body="&lt;p&gt;Looks like there is no easy way to change font/encoding for menu rendering. Maybe it's somewhere in the code files, and you need to change and compile it in order to be able to decode menu in another encoding. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the same issue (in Russian localization), I think it appears after adding in vimrc this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set termencoding=utf-8 &#xA;set encoding=utf-8&#xA;set fileencodings=utf8,cp1251&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not sure which of them make this problem. So you can try to delete it, and maybe it will resolve the problems. But when you need to open the file in a different encoding, you will need to add ++end every time opening the file with other encodings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I resolved this just by switching to english in gvim. To do this you need to add at the top of vimrc this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set langmenu=en_US.UTF-8    &quot; sets the language of the menu (gvim)&#xA;language en&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13941" LastActivityDate="2017-08-20T20:05:44.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13305" PostTypeId="1" AcceptedAnswerId="13310" CreationDate="2017-08-20T23:16:31.340" Score="6" ViewCount="427" Body="&lt;p&gt;I use Vim to edit the output of shell commands all the time. Appending the dash in this line is second nature:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ./some-command | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But every once in a while I get distracted and forget:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ./some-command | vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This typically causes Vim to hang, pegs one core at 100% CPU, and may disrupt the terminal. Is there a way to fool-proof Vim for me?&lt;/p&gt;&#xA;" OwnerUserId="6523" LastActivityDate="2017-08-26T06:49:44.437" Title="How to prevent accidentally piping text to Vim?" Tags="|terminal|linux|bash|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13306" PostTypeId="2" ParentId="13301" CreationDate="2017-08-21T02:20:25.437" Score="1" Body="&lt;p&gt;I would use &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; to execute your command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-s&amp;gt; &amp;lt;c-o&amp;gt;:w&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-08-21T02:20:25.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13308" PostTypeId="1" CreationDate="2017-08-21T06:55:37.753" Score="1" ViewCount="1095" Body="&lt;p&gt;I have the following line of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  autocmd FileType javascript execute &quot;setlocal formatprg=&quot;.g:prettier_eslint_path2.&quot;\\ --eslint-config-path&quot; . g:eslintrc_full_path .&quot;\\&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can see this when I start vim in the directory which has &lt;code&gt;.eslintrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ESLINTRC PATH&#xA;.eslintrc&#xA;Prettier ESLINT PATH&#xA;/Users/localuser/lendi/lendi-app/node_modules/.bin/prettier-eslint^@&#xA;/Users/localuser/lendi/lendi-app/node_modules/.bin/prettier-eslint&#xA;Has  ESLINTRC&#xA;/Users/localuser/lendi/lendi-app/.eslintrc&#xA;--- Auto-Commands ---&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have the &lt;code&gt;g:eslintrc_full_path&lt;/code&gt; logged out correctly, how do I pass it from the variable to formatprg correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remove the args, I get an empty output as the result of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remove the &lt;code&gt;\\&lt;/code&gt; it informs that it is valid to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I dont understand how to pass arguments to the cli script when using a variable. I did not find any examples of string interpolation when reading through &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/26.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://learnvimscriptthehardway.stevelosh.com/chapters/26.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the following code also causes a problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  autocmd FileType javascript execute &quot;setlocal formatprg=&quot;.g:prettier_eslint_path2.&quot;\\ --eslint-config-path\\ &quot;.g:eslintrc_full_path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and deletes the entire file. I have tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  autocmd FileType javascript execute &quot;setlocal formatprg=&quot;.g:prettier_eslint_path2.&quot;\\ --eslint-config-path\\ &quot;.g:eslintrc_full_path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it deletes the contents of the file as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried it with only &lt;code&gt;--stdin&lt;/code&gt; like this but it fails and converts everything to double quotes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  autocmd FileType javascript execute &quot;setlocal formatprg=&quot;.g:prettier_eslint_path2.&quot;\\ --stdin&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried adding in the single quote as an argument here but it still converts everything to double-quotes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType javascript let &amp;amp;l:formatprg= g:prettier_eslint_path2.&quot;\\ --single-quote\\ --eslint-config-path\\ &quot;. g:eslintrc_full_path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, logging &lt;code&gt;&amp;amp;l:formatprg&lt;/code&gt; does not work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType javascript let &amp;amp;l:formatprg = g:prettier_eslint_path2.' --single-quote --eslint-config-path '. g:eslintrc_full_path&#xA;echom &amp;amp;l:formatprg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried checking the messages:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and it shows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;/Users/localuser/lendi/lendi-app/node_modules/.bin/prettier-eslint --single-quote --write --eslint-config-path /Users/localuser/lendi/lendi-app/.eslintrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which should work. How does neoformat pass the file to the cli script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I solve this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also created a issue on &lt;code&gt;neoformat&lt;/code&gt; for the same:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/sbdchd/neoformat/issues/112&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/sbdchd/neoformat/issues/112&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10361" LastEditorUserId="10361" LastEditDate="2017-08-21T09:19:01.033" LastActivityDate="2018-01-31T11:19:38.987" Title="How to pass argument to Neoformat for prettier-eslint-cli from a variable in vimrc" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13309" PostTypeId="2" ParentId="13308" CreationDate="2017-08-21T07:56:48.507" Score="1" Body="&lt;p&gt;Maybe this is an escaping problem, you should use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType javascript setlocal formatprg=command\ --arg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you need variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType javascript let &amp;amp;l:formatprg = 'command ' . l:arg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: As &lt;a href=&quot;https://github.com/sbdchd/neoformat/issues/112#issuecomment-324322355&quot; rel=&quot;nofollow noreferrer&quot;&gt;commented by the plugin owner&lt;/a&gt;, it would be easier to &lt;a href=&quot;https://github.com/sbdchd/neoformat#config-optional&quot; rel=&quot;nofollow noreferrer&quot;&gt;define a formatter&lt;/a&gt; via Neoformat:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:neoformat_javascript_eslint = {&#xA;            \ 'exe': 'eslint',&#xA;            \ 'args': [],&#xA;            \ }&#xA;&#xA;let g:neoformat_enabled_javascript = ['eslint']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if you want to keep using &lt;code&gt;formatprg&lt;/code&gt;, you should get rid of the &lt;code&gt;FileType&lt;/code&gt; auto command and put &lt;code&gt;setlocal {option}&lt;/code&gt; or &lt;code&gt;let &amp;amp;l:{option}&lt;/code&gt; directly in &lt;code&gt;ftplugin/javascript.vim&lt;/code&gt;, see &lt;a href=&quot;https://vimhelp.appspot.com/usr_43.txt.html#filetype-plugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help filetype-plugin&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2017-09-03T06:34:52.550" LastActivityDate="2017-09-03T06:34:52.550" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13310" PostTypeId="2" ParentId="13305" CreationDate="2017-08-21T08:04:04.833" Score="5" Body="&lt;p&gt;As @chicks pointed out, you can place this script in your PATH:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;#!/usr/bin/env bash&#xA;&#xA;if [[ &quot;$#&quot; -ne 0 ]] || [[ -t 0 ]]; then&#xA;    exec vim &quot;$@&quot;&#xA;else&#xA;    exec vim -&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using a variant of this script in &lt;code&gt;~/bin/e&lt;/code&gt; to open the current directory (&lt;code&gt;vim .&lt;/code&gt;) when no argument is provided.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess you could also use a shell function:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;v() { if [[ &quot;$#&quot; -ne 0 ]] || [[ -t 0 ]]; then vim &quot;$@&quot;; else vim -; fi; } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2017-08-26T06:49:44.437" LastActivityDate="2017-08-26T06:49:44.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13312" PostTypeId="2" ParentId="3670" CreationDate="2017-08-21T10:04:30.523" Score="3" Body="&lt;p&gt;Entering a terminal buffer sets &lt;code&gt;buftype&lt;/code&gt; to terminal, you can actually use this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au BufEnter * if &amp;amp;buftype == 'terminal' | :startinsert | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13948" LastEditorUserId="1841" LastEditDate="2017-08-21T10:54:53.207" LastActivityDate="2017-08-21T10:54:53.207" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13313" PostTypeId="2" ParentId="10598" CreationDate="2017-08-21T14:40:26.010" Score="7" Body="&lt;p&gt;No idea about the clientserver feature, the simplest way I can think of would be to use the &lt;a href=&quot;https://vi.stackexchange.com/a/96/12003&quot;&gt;system clipboard&lt;/a&gt; by default when yanking or pasting which can be done with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard=unnamedplus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Depending on your OS and environment, you might need other tweaks for it to work seamlessly.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Also, you may be able to leverage the &lt;code&gt;viminfo&lt;/code&gt; file (or &lt;code&gt;:h shada&lt;/code&gt; on neovim):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The ShaDa file is used to store:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The command line history.&lt;/li&gt;&#xA;&lt;li&gt;The search string history.&lt;/li&gt;&#xA;&lt;li&gt;The input-line history.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Contents of non-empty registers.&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Marks for several files.&lt;/li&gt;&#xA;&lt;li&gt;File marks, pointing to locations in files.&lt;/li&gt;&#xA;&lt;li&gt;Last search/substitute pattern (for 'n' and '&amp;amp;').&lt;/li&gt;&#xA;&lt;li&gt;The buffer list.&lt;/li&gt;&#xA;&lt;li&gt;Global variables.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-08-23T08:20:26.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13314" PostTypeId="1" AcceptedAnswerId="13315" CreationDate="2017-08-21T17:35:31.457" Score="0" ViewCount="1042" Body="&lt;p&gt;I'm currently stuck on this problem.&#xA;I want, in a vimscript, to replace a variable's brackets when they contain a certain pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To say this differently, say I have a variable &lt;code&gt;foo = &quot;[content] bar&quot;&lt;/code&gt; .&#xA;My purpose is to replace &lt;strong&gt;[content]&lt;/strong&gt; with an empty string, which means that after the substitution we'll get: &lt;code&gt;foo = &quot; bar&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current solution I could find is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let foo = substitute(foo, &quot;\[\]&quot;, &quot;&quot;) | let foo = substitute(foo, &quot;content&quot;, &quot;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but couldn't manage to get it in one call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something I'm missing? Could this be done more easily?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards&lt;/p&gt;&#xA;" OwnerUserId="13951" LastEditorUserId="1841" LastEditDate="2017-08-21T18:12:06.837" LastActivityDate="2017-08-21T18:57:26.333" Title="Replace brackets and the content within the brackets in a variable" Tags="|vimscript|substitute|replace|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13315" PostTypeId="2" ParentId="13314" CreationDate="2017-08-21T17:58:42.243" Score="2" Body="&lt;p&gt;You can do it like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/\[[^]]*\]//g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this somewhat cryptic regexp means to replace everything from start of bracket &lt;code&gt;[&lt;/code&gt; followed by anything not a closing bracket &lt;code&gt;[^]]*&lt;/code&gt; followed by the closing bracket &lt;code&gt;]&lt;/code&gt; by nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&#xA;Since you like to replace variable contents, let me show how to do that.&#xA;Suppose you have a variable &lt;em&gt;foo&lt;/em&gt; (&lt;code&gt;:let foo=&quot;[content] bar&quot;&lt;/code&gt;), then you can do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let foo=substitute(foo, '\[[^]]*\]', '', 'g')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;echo '|'.foo.'|'&lt;/code&gt; returns &lt;code&gt;| bar|&lt;/code&gt; (note the leading space).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure, to use &lt;strong&gt;single quotation marks&lt;/strong&gt;, for double quotation marks you need to double the backslashes, as is explained in the help at &lt;code&gt;:h expr-quote&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2017-08-21T18:57:26.333" LastActivityDate="2017-08-21T18:57:26.333" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="13316" PostTypeId="1" CreationDate="2017-08-21T20:40:52.217" Score="1" ViewCount="65" Body="&lt;p&gt;I have the following binding in my &lt;code&gt;.vimrc&lt;/code&gt; and the default &lt;code&gt;timeoutlen&lt;/code&gt; of 1000ms.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap df &amp;lt;Esc&amp;gt;&#xA;inoremap fd &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I type &lt;code&gt;df&lt;/code&gt; in insert mode slowly but under the threshold, I can see a &lt;code&gt;d&lt;/code&gt; for a little bit before I type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to increase the amount of time before the &lt;code&gt;d&lt;/code&gt; is shown at all? (e.g. to somewhere in the 500ms to 1000ms range).&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-08-21T20:40:52.217" Title="Do not display letter when waiting for key sequence to complete" Tags="|key-bindings|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13318" PostTypeId="2" ParentId="12993" CreationDate="2017-08-22T08:31:16.743" Score="1" Body="&lt;p&gt;You could add this in &lt;code&gt;ftplugin/gitcommit.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; setlocal textwidth=72&#xA;let &amp;amp;l:formatprg = 'par -w' . &amp;amp;l:textwidth&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or using an auto command, just make sure &lt;code&gt;&amp;amp;textwidth&lt;/code&gt; is correctly set before the FileType event:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup FormatPrg&#xA;    autocmd!&#xA;    autocmd FileType gitcommit let &amp;amp;l:formatprg = 'par -w' . &amp;amp;l:textwidth&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-22T08:31:16.743" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13320" PostTypeId="1" CreationDate="2017-08-22T22:28:42.173" Score="1" ViewCount="748" Body="&lt;p&gt;I've established that it's possible to take the contents of a buffer (even one that isn't saved anywhere) and &lt;a href=&quot;https://stackoverflow.com/a/7867410/18149&quot;&gt;pipe it to a command&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;like so: &lt;code&gt;:w ! petit --wordcount&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But! Is it possible to take the output of said command and pipe it back out to a new empty buffer in vim, without writing the output to a file...just writing back into a new buffer...using ex?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2017-08-23T07:52:26.310" Title="Pipe the content of the current buffer into an external command and then read the output into a new empty buffer?" Tags="|buffers|external-command|ex-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13321" PostTypeId="1" CreationDate="2017-08-22T22:59:55.250" Score="1" ViewCount="266" Body="&lt;p&gt;There's a project where I don't want Vim to write in a temp buffer and rename, because my files are watched by another program for writes (and not renamings).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried this in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set backupskip+=*/static/{templates/*.html,js/*.ts}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The goal is to ignore both the &lt;code&gt;templates/&lt;/code&gt; and the &lt;code&gt;js/&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I save, I'm getting: &lt;code&gt;E220: Missing }.&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5387" LastEditorUserId="51" LastEditDate="2017-08-24T09:35:24.083" LastActivityDate="2017-08-24T09:35:24.083" Title="backupskip with { curly braces" Tags="|vimrc|set|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13322" PostTypeId="2" ParentId="13321" CreationDate="2017-08-22T23:02:58.607" Score="1" Body="&lt;p&gt;Actually, the comma is interpreted by &lt;code&gt;set+=&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for this to work, one should escape it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set backupskip+=*/web/static/{js/*.ts\\,templates/*.html}&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5387" LastActivityDate="2017-08-22T23:02:58.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13324" PostTypeId="1" CreationDate="2017-08-23T04:05:02.790" Score="0" ViewCount="226" Body="&lt;p&gt;I posted this question on &lt;a href=&quot;https://stackoverflow.com/q/45826678/1082727&quot;&gt;StackOverflow&lt;/a&gt; first, as I did not know about &quot;Vi and Vim beta&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to augment Vim yank and paste, so when I yank, Vim writes the content to a file? When I paste, it uses the content from the file. I want to have a system wide file which serves as a global buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Context: I run Vim in different tmux splits on a remote server (over ssh). I want seamlessly copy and paste between Vims in tmux splits. I tried a bunch of plugins, but none of them worked, thus the question.&lt;/p&gt;&#xA;" OwnerUserId="13972" LastEditorUserId="5395" LastEditDate="2017-08-23T06:22:30.160" LastActivityDate="2017-08-23T07:44:00.750" Title="Vim yank and paste via a shared file" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ClosedDate="2017-08-23T07:45:36.613" ContentLicense="CC BY-SA 3.0" />
  <row Id="13325" PostTypeId="2" ParentId="10598" CreationDate="2017-08-23T04:59:00.173" Score="1" Body="&lt;p&gt;use tmux，tmux buffer to unname register, uname register to tmux buffer&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tracyone/t-vim/blob/master/autoload/te/tmux.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tracyone/t-vim/blob/master/autoload/te/tmux.vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10798" LastActivityDate="2017-08-23T04:59:00.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13326" PostTypeId="2" ParentId="13324" CreationDate="2017-08-23T07:18:55.730" Score="0" Body="&lt;p&gt;Use register &lt;code&gt;+&lt;/code&gt;. For yanking use &lt;code&gt;&quot;+y&lt;/code&gt; which yanks to register &lt;code&gt;+&lt;/code&gt; and for pasting use &lt;code&gt;&quot;+p&lt;/code&gt; which copies content from &lt;code&gt;+&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the following maps in my vimrc to copy to system clipboard&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;leader&amp;gt;y &quot;+y&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;leader&amp;gt;p &quot;+p&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11395" LastEditorUserId="1841" LastEditDate="2017-08-23T07:44:00.750" LastActivityDate="2017-08-23T07:44:00.750" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13327" PostTypeId="2" ParentId="13320" CreationDate="2017-08-23T07:52:26.310" Score="2" Body="&lt;p&gt;From the gist &quot;&lt;a href=&quot;https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7&quot; rel=&quot;nofollow noreferrer&quot;&gt;Redirect the output of a Vim or external command into a scratch buffer&lt;/a&gt;&quot; by romainl:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Redir(cmd)&#xA;    for win in range(1, winnr('$'))&#xA;        if getwinvar(win, 'scratch')&#xA;            execute win . 'windo close'&#xA;        endif&#xA;    endfor&#xA;    if a:cmd =~ '^!'&#xA;        execute &quot;let output = system('&quot; . substitute(a:cmd, '^!', '', '') . &quot;')&quot;&#xA;    else&#xA;        redir =&amp;gt; output&#xA;        execute a:cmd&#xA;        redir END&#xA;    endif&#xA;    vnew&#xA;    let w:scratch = 1&#xA;    setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile&#xA;    call setline(1, split(output, &quot;\n&quot;))&#xA;endfunction&#xA;&#xA;command! -nargs=1 Redir silent call Redir(&amp;lt;f-args&amp;gt;)&#xA;&#xA;&quot; Usage:&#xA;&quot;   :Redir hi ............. show the full output of command ':hi' in a scratch window&#xA;&quot;   :Redir !ls -al ........ show the full output of command ':!ls -al' in a scratch window&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It captures the result with &lt;code&gt;execute &quot;let output = system()&quot;&lt;/code&gt; and writes it to a new split. Untested:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Redir !petit --wordcount %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%&lt;/code&gt; is replaced with the current file name, see &lt;code&gt;:help c_%&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-23T07:52:26.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13328" PostTypeId="1" AcceptedAnswerId="13329" CreationDate="2017-08-23T13:09:58.930" Score="8" ViewCount="4461" Body="&lt;p&gt;I usually use gvim and it understands the mapping similar to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-Space&amp;gt; &amp;lt;C-n&amp;gt;&#xA;inoremap &amp;lt;C-S-Space&amp;gt; &amp;lt;C-p&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I'm testing nvim and I can use the &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Space&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;Space&lt;/kbd&gt; is not handled correctly and it triggers the same action as &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Space&lt;/kbd&gt; does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now my question is: is this a behaviour of nvim or is the cause of the problem something else (like my terminal)?&lt;/p&gt;&#xA;" OwnerUserId="350" LastEditorUserId="1841" LastEditDate="2017-08-23T13:49:03.607" LastActivityDate="2023-04-15T07:12:34.110" Title="Is it possible to map &lt;C-S-Space&gt; in neovim?" Tags="|key-bindings|neovim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13329" PostTypeId="2" ParentId="13328" CreationDate="2017-08-23T13:52:18.547" Score="9" Body="&lt;p&gt;You are right, this issue arises on terminal Vim. The easiest would be to &lt;strong&gt;stick to Gvim&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: For rxvt-unicode, edit your &lt;code&gt;.Xresources&lt;/code&gt; file and use the CSI found by &lt;a href=&quot;https://vi.stackexchange.com/questions/13328/is-it-possible-to-map-c-s-space-in-neovim/13329#comment22963_13329&quot;&gt;Raphael&lt;/a&gt; in the article &amp;quot;&lt;a href=&quot;http://www.leonerd.org.uk/hacks/fixterms/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fix Keyboard Input on Terminals&lt;/a&gt;&amp;quot;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;URxvt.keysym.S-space: \033[32;2u&lt;/code&gt; to map &lt;code&gt;&amp;lt;S-Space&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;URxvt.keysym.C-S-space: \033[32;6u&lt;/code&gt; to map &lt;code&gt;&amp;lt;C-S-Space&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Avoid_the_escape_key#Mapping_problems&quot; rel=&quot;nofollow noreferrer&quot;&gt;This Vim Tip&lt;/a&gt; addresses the &lt;code&gt;S-Space&lt;/code&gt; mapping problem:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Vim runs on many different hardware and software platforms. Therefore&#xA;some key sequences may not be available. For example, you may be able&#xA;to map Shift-Space in a GUI Vim, but not in a terminal Vim (and even&#xA;if you could, if you were running via PuTTY, for example, Vim might&#xA;not receive the key code).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There seems to be a workaround for &lt;strong&gt;Urxvt&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;For Shift-Space in terminal Vim, I used &lt;code&gt;URxvt.keysym.S-space: \033&lt;/code&gt; in .Xresources. (for the rxvt-unicode terminal emulator).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;And a way to test if your Vim recognises the key combination:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;To test your system, enter insert mode then press Ctrl-K followed by the key of interest (for example, press Ctrl-K then Shift-Space). &lt;code&gt;:help i_CTRL-K&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/279959/how-can-i-make-shiftspacebar-page-up-in-vim&quot;&gt;This SO question&lt;/a&gt; may help you, even though the answer reasserts that:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;You cannot. CMS's solution will work for gVim, but not in vim because terminals cannot distinguish between  and  because curses sees them the same. It might be possible in the future if vim gains libtermkey support and your terminal supports the proper  sequences (xterm does if properly configured; nothing else does yet).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If your are using &lt;strong&gt;iTerm&lt;/strong&gt;, &lt;a href=&quot;https://stackoverflow.com/a/18224694/7796750&quot;&gt;there might be a solution&lt;/a&gt; in the second answer.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;See also &lt;a href=&quot;http://vim.1045645.n5.nabble.com/Mapping-Shift-space-how-to-tell-if-its-possible-tp1191250p1191255.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mapping Shift-space: how to tell if its possible?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When Vim is run in a terminal (i.e., in console mode), it's at the&#xA;mercy of the terminal's keyboard logic. Some keys or key combos will&#xA;not be passed at all. Others will be &amp;quot;translated&amp;quot; according to the&#xA;current locale. For some keys, Shift and/or Ctrl and/or Alt may get&#xA;lost, jointly or severally.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2023-04-15T07:12:34.110" LastActivityDate="2023-04-15T07:12:34.110" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="13330" PostTypeId="1" AcceptedAnswerId="13332" CreationDate="2017-08-23T15:05:41.133" Score="2" ViewCount="1643" Body="&lt;p&gt;I very often need to open files through &lt;code&gt;vsplit/split&lt;/code&gt;. Very often I want to open files in the same directory. Still, I must pass their paths to &lt;code&gt;vsplit/split&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vsplit @/siblingfile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;@&lt;/code&gt; is an alias equal to the path of the current file (that exists only in my imagination of course but you got the idea :) ).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--&amp;gt; vim --version&#xA;VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Nov 24 2016 16:00:18)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:echo has('cmdline_compl') displays 1&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="13172" LastEditorUserId="13172" LastEditDate="2017-08-24T13:28:12.497" LastActivityDate="2017-08-24T13:28:12.497" Title="shortcut of the current directory path when vsplit/split" Tags="|split|variables|path|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13331" PostTypeId="1" AcceptedAnswerId="13334" CreationDate="2017-08-23T15:15:59.620" Score="4" ViewCount="1000" Body="&lt;p&gt;I know about &lt;code&gt;:only&lt;/code&gt; and &lt;kbd&gt;Ctrl+w&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I want to keep NERDTree window untouched. Is there a way to achieve it?&lt;/p&gt;&#xA;" OwnerUserId="13980" LastActivityDate="2017-08-24T00:43:57.960" Title="Close all windows except the current one and NERDTree" Tags="|vim-windows|plugin-nerdtree|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13332" PostTypeId="2" ParentId="13330" CreationDate="2017-08-23T15:16:50.873" Score="5" Body="&lt;p&gt;You're looking for &lt;code&gt;%:h/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: you can tab-complete at any point after the &lt;code&gt;:h&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-08-23T15:16:50.873" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13333" PostTypeId="2" ParentId="13330" CreationDate="2017-08-23T15:20:37.227" Score="2" Body="&lt;p&gt;As Luc indicated, you can type: &lt;code&gt;:vsplit %:h&lt;/code&gt; then &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I use this mapping to transform &lt;code&gt;%%&lt;/code&gt; into the current directory from the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; %% getcmdtype() ==# ':' ? fnameescape(expand('%:h')) . '/' : '%%'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usage: &lt;code&gt;:e %%&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help c_%&lt;/code&gt; (&lt;code&gt;%&lt;/code&gt; replaced with the current file name)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help %:h&lt;/code&gt; (&lt;code&gt;%:h&lt;/code&gt; to get the head of the file name, aka last part removed)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-23T15:20:37.227" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13334" PostTypeId="2" ParentId="13331" CreationDate="2017-08-23T15:46:38.353" Score="4" Body="&lt;p&gt;&lt;strong&gt;This solution only works with vim 8+&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! OnlyAndNerdtree()&#xA;    let currentWindowID = win_getid()&#xA;&#xA;    windo if win_getid() != currentWindowID &amp;amp;&amp;amp; &amp;amp;filetype != 'nerdtree' | close | endif&#xA;endfunction&#xA;&#xA;command! Only call OnlyAndNerdtree()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function gets the id of the current window with &lt;code&gt;win_getid()&lt;/code&gt; then it uses &lt;code&gt;windo&lt;/code&gt; do iterate through all of the windows and execute code following it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code test if the id of the window is different than the id of the current windo and if the filetype of its buffer is different than &lt;code&gt;nerdtree&lt;/code&gt;. If both of the conditions are met, the window is closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the last line creates the command &lt;code&gt;:Only&lt;/code&gt; which calls the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; &lt;code&gt;win_getid()&lt;/code&gt; was only introduced in Vim 8, with previous versions of Vim a workaround must be possible wit &lt;code&gt;winnr()&lt;/code&gt; but it would probably not be as easy as with &lt;code&gt;win_getid()&lt;/code&gt; especially because when a window is closed, the number of the other windows are updated.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-08-23T16:12:21.310" LastActivityDate="2017-08-23T16:12:21.310" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13335" PostTypeId="1" CreationDate="2017-08-23T16:27:08.037" Score="1" ViewCount="149" Body="&lt;p&gt;If I indent the following script with &lt;code&gt;gg=G&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env bash&#xA;&#xA;while true; do&#xA;    case &quot;${1}&quot; in&#xA;        -h) usage; exit 0;;&#xA;        -b) branch=&quot;${2}&quot;; shift 2;;&#xA;        -t) build=&quot;${2}&quot;; shift 2;;&#xA;        -w) write=true; shift 1;;&#xA;        --) shift; break;;&#xA;    esac&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it gets differently indented on two different machines. On machine 1, the indentation is as above, on machine 2, all the different cases (starting from &lt;code&gt;-b&lt;/code&gt;) gets indented to the left. Both machines have exactly the same &lt;code&gt;.vimrc&lt;/code&gt;, where I use &lt;code&gt;aindent&lt;/code&gt; only. On machine 1, vim is version 8.0, on machine 2, it's 7.4. Surely the version should not have such an effect? What else could lead to a different indentation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are a few settings that I use on machine 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype detection:ON plugin:ON indent:ON&#xA;  softtabstop=0                                                                               &#xA;  tabstop=4                                                                                   &#xA;        Last set from ~/.vimrc                                                                &#xA;  shiftwidth=4                                                                                &#xA;        Last set from ~/.vimrc                                                                &#xA;nocindent                                                                                     &#xA;  indentexpr=                                                                                 &#xA;  autoindent                                                                                  &#xA;        Last set from ~/.vimrc                                                                &#xA;nosmartindent                  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And indeed there is one difference on machine 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  indentexpr=GetShIndent()&#xA;    Last set from /usr/share/vim/vim74/indent/sh.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Removing it does not improve the situation, though. So after all, it might be due to a difference in the version of vim. Is there a good setting of indenting that works for both versions?&lt;/p&gt;&#xA;" OwnerUserId="6154" LastEditorUserId="51" LastEditDate="2017-08-23T23:55:02.637" LastActivityDate="2017-08-23T23:55:02.637" Title="indentation different on different computers" Tags="|indentation|filetype-sh|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13336" PostTypeId="2" ParentId="12140" CreationDate="2017-08-23T19:51:45.603" Score="6" Body="&lt;p&gt;From &lt;a href=&quot;http://vim.wikia.com/wiki/How_to_not_move_cursor_when_selecting_window_with_mouse&quot; rel=&quot;noreferrer&quot;&gt;Vim Tips Wiki&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When you are using another application and select go back to Vim by&#xA;  clicking inside Vim's text area, it not only switches application&#xA;  focus to Vim, but it also moves the cursor to that location. If you&#xA;  don't want the cursor to move, put the following in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup NO_CURSOR_MOVE_ON_FOCUS&#xA;  au!&#xA;  au FocusLost * let g:oldmouse=&amp;amp;mouse | set mouse=&#xA;  au FocusGained * if exists('g:oldmouse') | let &amp;amp;mouse=g:oldmouse | unlet g:oldmouse | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Although I am unable to test this on Linux, I've recently started using it on Windows, and it appears to do what you're asking for. (Note that somebody reported an issue with split windows, i.e. after &lt;code&gt;:split&lt;/code&gt;, but I haven't observed it myself.) &lt;/p&gt;&#xA;" OwnerUserId="13984" LastActivityDate="2017-08-23T19:51:45.603" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13337" PostTypeId="2" ParentId="5130" CreationDate="2017-08-23T20:59:27.397" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;104 columns / 51 lines = 2.04&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your calculation is skewed because the aspect ratio of each cell is vertical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example on Terminal.app, with 23pt font and default character spacing, each terminal cell have a width of 7px and a height of 15px for a total of &lt;a href=&quot;https://i.stack.imgur.com/3uAat.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;728x765px&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://chart.googleapis.com/chart?cht=tx&amp;amp;chl=%28104%20*%207%29%20/%20%2851%20*%2015%29%20%3D%20728%20/%20765%20%3D%200.95&quot; alt=&quot;(104 * 7) / (51 * 15) = 728 / 765 = 0.95&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You cannot retrieve the font size from within Vim without invoking external commands or a way of communicating with the terminal, which can become pretty heavy. Obviously, this is different in Gvim thanks to &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27guifont%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'guifont'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you manage to do it, still you need a way to deduct the size of a cell which may vary depending on the terminal program if there is no &lt;em&gt;standard&lt;/em&gt;. I only checked iTerm 2 which luckily have the same result.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Therefore I would opt for a static solution.&#xA;I grafted the minimum width check to this snippet you could place in &lt;code&gt;plugin/help.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Help(...)&#xA;  let l:topic = a:0 ? a:1 : ''&#xA;  if winwidth('%') &amp;gt;= 160 &quot; Minimum width&#xA;    execute 'vertical botright help' l:topic&#xA;    execute 'vertical resize 78'&#xA;  else&#xA;    execute 'botright help' l:topic&#xA;  endif&#xA;endfunction&#xA;&#xA;&quot; Use :H to open a vertical or horizontal help split&#xA;command! -complete=help -nargs=? H call Help(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the window is large enough to keep 80 columns of the current buffer, a narrow help split is opened on the right, otherwise the split is opened below. You can customize the split direction with &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Avertical&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:vertical&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-23T20:59:27.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13338" PostTypeId="1" AcceptedAnswerId="13343" CreationDate="2017-08-23T22:06:08.277" Score="1" ViewCount="492" Body="&lt;p&gt;I am using the &lt;code&gt;gg=G&lt;/code&gt;, &lt;code&gt;=ap&lt;/code&gt; etc. paradigms to reformat some code. This code is in tcl:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;proc something { foo bar } {&#xA;set foo [yadda yadda]&#xA;set foo [yadda yadda]&#xA;set foo [yadda yadda]&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try adjust indents, the formatting changes to: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;proc something { foo bar } {&#xA;    set foo [yadda yadda]&#xA;        set foo [yadda yadda]&#xA;        set foo [yadda yadda]&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would expect all the set statements at the same indent level. Is there a way to do that? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the &quot;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr  4 2017 18:14:54)&quot; what comes with MacS Sierra, invoked as &quot;vi&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="13985" LastEditorUserId="51" LastEditDate="2017-08-23T23:53:23.523" LastActivityDate="2017-08-24T09:09:15.707" Title="Extra indent in Vi/Vim Tcl code block indentation" Tags="|indentation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13339" PostTypeId="2" ParentId="13331" CreationDate="2017-08-24T00:43:57.960" Score="0" Body="&lt;p&gt;buffer only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tracyone/t-vim/blob/master/autoload/te/tools.vim#L70-L106&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tracyone/t-vim/blob/master/autoload/te/tools.vim#L70-L106&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;buffer only&#xA;nnoremap &amp;lt;leader&amp;gt;bo :call te#tools#buf_only('', '')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10798" LastActivityDate="2017-08-24T00:43:57.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13340" PostTypeId="2" ParentId="625" CreationDate="2017-08-24T00:46:18.153" Score="4" Body="&lt;p&gt;Following is my git config:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tracyone/dotfiles/blob/master/.gitconfig&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tracyone/dotfiles/blob/master/.gitconfig&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[core]&#xA;editor = vim&#xA;[diff]&#xA;tool = vimdiff&#xA;[merge]&#xA;tool = vimdiff&#xA;conflictstyle = diff3&#xA;[difftool]&#xA;prompt = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10798" LastActivityDate="2017-08-24T00:46:18.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13341" PostTypeId="1" AcceptedAnswerId="13342" CreationDate="2017-08-24T05:57:43.590" Score="0" ViewCount="301" Body="&lt;p&gt;File sample:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc xyz aca sdasda 2.4 rn 3.4&#xA;abc xyz acs sd3sa 2.4 rn 3.1&#xA;abc xyz acs s12 2.1 rn 3.2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What Im trying to achieve here is if diff of values (ex: &lt;code&gt;3.4&lt;/code&gt; and &lt;code&gt;2.4&lt;/code&gt;) is equal to or greater than &lt;code&gt;1.0&lt;/code&gt; ,then both value should highlight.&#xA;Above output should happen by default when I open a specific file (ex: &lt;code&gt;file_output12&lt;/code&gt; ).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim version: 7.4&#xA;system:Centos 6.8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9311" LastEditorUserId="9311" LastEditDate="2017-08-24T06:16:46.987" LastActivityDate="2017-08-24T08:01:04.730" Title="Highlight column values when difference is greater than a specific value" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13342" PostTypeId="2" ParentId="13341" CreationDate="2017-08-24T08:01:04.730" Score="2" Body="&lt;p&gt;You can try something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    function! HighlightDiff(match1, match2)&#xA;        let a=str2float(a:match1)&#xA;        let b=str2float(a:match2)&#xA;        if abs(a-b) &amp;gt;= 1.0&#xA;            call add(w:matchid, matchaddpos('WarningMsg', [[line('.'), col('.'), strlen(a:match1)]]))&#xA;            call add(w:matchid, matchaddpos('WarningMsg', [[line('.'), col('.')+strlen(a:match1) + 4, strlen(a:match2)]]))&#xA;        endif&#xA;    endfunction&#xA;&#xA;    function! HighlightMatches()&#xA;        &quot; ignore non-existing highlighting ids&#xA;        sil! call map(get(w:, 'matchid', []), 'matchdelete(v:val)')&#xA;        let w:matchid = []&#xA;        :%s/\(\d\+\%(\.\d\+\)\?\) rn \(\d\+\%(\.\d\+\)\?\)/\=HighlightDiff(submatch(1), submatch(2))/gn&#xA;    endfunction&#xA;&#xA;    com! HighlightDiff :call HighlightMatches()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses a regular expression to find numbers optionally followed by &lt;code&gt;.&lt;/code&gt; and more numbers, followed by &lt;code&gt;rn&lt;/code&gt; followed again by numbers with an optional dot. It remembers the position of the two matches and uses &lt;code&gt;matchaddpos()&lt;/code&gt; to highlight those positions if both numbers are greater than &lt;code&gt;1.0&lt;/code&gt; apart. However, since we do not know exactly know, the position of the second match, we have do to some calculation from the first number to the second number (therefore I assume, that &lt;code&gt;rn&lt;/code&gt; must always be 1 space followed by rn followed by 1 space).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It uses a &lt;code&gt;:%s/../\=function/gn&lt;/code&gt; to perform the highlight. It means, that it actually runs a search/replace command, however because of the &lt;code&gt;n&lt;/code&gt; flag, it won't replace anything, just call the function with the match. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of this depends on the following version:&#xA;Vim 7.4 compiled with float support, support for evaluating the expression even when using the &lt;code&gt;n&lt;/code&gt; flag (&lt;a href=&quot;https://github.com/vim/vim/releases/tag/v7.3.627&quot; rel=&quot;nofollow noreferrer&quot;&gt;patch 7.3.627&lt;/a&gt;), and &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v7.4.330&quot; rel=&quot;nofollow noreferrer&quot;&gt;matchaddpos&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-08-24T08:01:04.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13343" PostTypeId="2" ParentId="13338" CreationDate="2017-08-24T09:09:15.707" Score="0" Body="&lt;p&gt;Is the &lt;code&gt;&amp;amp;filetype&lt;/code&gt; properly detected? Vim 7.4 runtime should already include the &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/indent/tcl.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;correct indent file&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Execute &lt;code&gt;:scriptnames&lt;/code&gt; to list all sourced files and look for &lt;code&gt;/usr/share/vim/vim74/indent/tcl.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's missing, make sure you have this line in your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read &lt;a href=&quot;http://vim.wikia.com/wiki/Indenting_source_code#File-type_based_indentation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Indenting source code&lt;/a&gt; on the Vim Tips Wiki for more info on file-type based indentation.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-24T09:09:15.707" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13344" PostTypeId="1" AcceptedAnswerId="13351" CreationDate="2017-08-24T09:53:40.280" Score="8" ViewCount="9106" Body="&lt;p&gt;While navigating file system in &lt;code&gt;:Explore&lt;/code&gt; mode, is it possible to select and open multiple files, each in a new tab?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ended up using a function proposed by &lt;em&gt;Jair López&lt;/em&gt;, because it works pretty much as I envisioned it, although &lt;em&gt;statox&lt;/em&gt; provided a good explanation for built-in netrw mechanics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For consistency, I also added a normal mode mapping to make &lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;T&lt;/kbd&gt;&lt;kbd&gt;T&lt;/kbd&gt; open a new tab, while keeping netrw tab in focus. It simplifies opening tabs for multiple files that aren't listed consecutively.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype netrw nmap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; TT VT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13992" LastEditorUserId="13992" LastEditDate="2017-08-26T14:24:43.293" LastActivityDate="2017-08-28T11:42:05.653" Title="Open multiple files in tabs from Explore mode" Tags="|netrw|tabbed-user-interface|multiple-files|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13345" PostTypeId="2" ParentId="13344" CreationDate="2017-08-24T10:04:51.323" Score="13" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/pi_netrw.txt.html#netrw%2dt&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h netrw-t&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BROWSING WITH A NEW TAB             netrw-t&#xA;&#xA;Normally one enters a file or directory using the &amp;lt;cr&amp;gt;.  The &quot;t&quot; map&#xA;allows one to open a new window holding the new directory listing or file in&#xA;a new tab.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in the netrw window simply press &lt;kbd&gt;t&lt;/kbd&gt; when your cursor is on the file or on the directory you want to open in the new tab.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To do that with multiple files you need to mark them, put them in the arglist and then use the arg list to open the tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To mark a file in a netrw window use &lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the files are marked put them in the arglist with &lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then simply use &lt;code&gt;:argdo tabnew&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; To reduce the number of keypresses you can add the following line in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype netrw nmap &amp;lt;buffer&amp;gt; &amp;lt;F5&amp;gt; ma:argdo tabnew&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is an autocommand which is executed when you open a netrw buffer (&lt;code&gt;FileType netrw&lt;/code&gt;) and creates a mapping only in this buffer which will put the marked files in the arglist and issue the command &lt;code&gt;:argdo tabnew&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that you can simply mark your files with &lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; and use &lt;kbd&gt;F5&lt;/kbd&gt; (or another key if you prefer) to open the files in new tabs.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pi_netrw.txt.html#netrw%2dmf&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h netrw-mf&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pi_netrw.txt.html#netrw%2dma&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h netrw-ma&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3aargdo&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :argdo&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#arglist&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h arglist&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-08-24T11:20:32.930" LastActivityDate="2017-08-24T11:20:32.930" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13346" PostTypeId="2" ParentId="13231" CreationDate="2017-08-24T10:27:14.877" Score="1" Body="&lt;p&gt;You could type &lt;code&gt;:set {option}?&lt;/code&gt; to show the value of an option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to inspect where it was defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set timeoutlen?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-24T10:27:14.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13347" PostTypeId="2" ParentId="13344" CreationDate="2017-08-24T10:55:20.550" Score="1" Body="&lt;p&gt;If you don't mind installing a plugin, you could use &lt;a href=&quot;https://github.com/justinmk/vim-dirvish&quot; rel=&quot;nofollow noreferrer&quot;&gt;dirvish&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the directory opened, visually select the files (e.g. with &lt;code&gt;VG&lt;/code&gt;) and press &lt;code&gt;t&lt;/code&gt; to open in a tab.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-24T10:55:20.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13348" PostTypeId="1" AcceptedAnswerId="13359" CreationDate="2017-08-24T11:01:09.793" Score="2" ViewCount="1224" Body="&lt;p&gt;I installed the plugin &lt;a href=&quot;https://github.com/ternjs/tern_for_vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;tern_for_vim&lt;/a&gt;. Followed all the instructions from readme but it doesn't work. I don't have any autocompletion for javascript, the commands &lt;code&gt;:TernDef&lt;/code&gt; and &lt;code&gt;:TernDoc&lt;/code&gt; are not recognized in vim. I installed the tern server globally using &lt;code&gt;npm&lt;/code&gt; and I can launch it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to launch tern with the &lt;code&gt;--verbose&lt;/code&gt; option but it did not output anything when I tried to use autocompletion in javascript files. It seems that there is no communication between vim and the tern server if I understand it correctly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are my plugins in &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'tmhedberg/SimpylFold'&#xA;Plugin 'vim-syntastic/syntastic'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'kien/ctrlp.vim'&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'vim-scripts/indentpython.vim'&#xA;Plugin 'nvie/vim-flake8'&#xA;Plugin 'davidhalter/jedi-vim'&#xA;Plugin 'SirVer/ultisnips'&#xA;Plugin 'honza/vim-snippets'&#xA;Plugin 'pangloss/vim-javascript'&#xA;Plugin 'mxw/vim-jsx'&#xA;Plugin 'alvan/vim-closetag'&#xA;Plugin 'Valloric/MatchTagAlways'&#xA;Plugin 'ternjs/tern_for_vim'&#xA;Plugin 'lervag/vimtex'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also setup a &lt;code&gt;.tern-config&lt;/code&gt; file in the home directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    &quot;libs&quot;: [&#xA;    &quot;ecmascript&quot;,&#xA;    &quot;browser&quot;,&#xA;    &quot;jquery&quot;&#xA;    ],&#xA;    &quot;plugins&quot;: {&#xA;        &quot;es_modules&quot;: {},&#xA;    &quot;node&quot;: {}&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could run ternjs when I set up YouCompleteMe for python autocompletion, but I didn't like it and chose jedi-vim (which is really nice). Now I want to setup javascript autocompletion but without no luck. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions how I can solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="12297" LastEditorUserId="1841" LastEditDate="2017-08-24T11:26:10.420" LastActivityDate="2017-08-25T10:42:30.750" Title="Cannot setup tern_for_vim plugin" Tags="|linux-ubuntu|plugin-ternjs|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="13350" PostTypeId="1" CreationDate="2017-08-24T18:21:21.487" Score="1" ViewCount="549" Body="&lt;p&gt;Hello Vimmers and LaTeXers,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot get Alt-I to work in vim-latex. It is supposed to insert \item depending on the environment that you are in. Do I need to activate it somehow? Is there a setting for it?&#xA;When, in insert mode, I press Alt-I in itemize environment, and for that matter anywhere, it write e with acute accent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance for your help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I checked &lt;code&gt;:map&lt;/code&gt; and &lt;code&gt;Alt-I&lt;/code&gt; does not appear in that list. What could be wrong?&lt;/p&gt;&#xA;" OwnerUserId="13751" LastEditorUserId="13751" LastEditDate="2017-08-26T02:42:57.077" LastActivityDate="2022-06-29T10:36:10.057" Title="Alt-I doesn't work to inset \item in vim-latex" Tags="|vimrc|plugin-vim-latex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13351" PostTypeId="2" ParentId="13344" CreationDate="2017-08-24T20:33:02.333" Score="4" Body="&lt;p&gt;Let's Vim do it for you. You can put the following code at the end of your &#xA;&lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NetrwOpenMultiTab(current_line,...) range&#xA;   &quot; Get the number of lines.&#xA;   let n_lines =  a:lastline - a:firstline + 1&#xA;&#xA;   &quot; This is the command to be built up.&#xA;   let command = &quot;normal &quot;&#xA;&#xA;   &quot; Iterator.&#xA;   let i = 1&#xA;&#xA;   &quot; Virtually iterate over each line and build the command.&#xA;   while i &amp;lt; n_lines&#xA;      let command .= &quot;tgT:&quot; . ( a:firstline + i ) . &quot;\&amp;lt;CR&amp;gt;:+tabmove\&amp;lt;CR&amp;gt;&quot;&#xA;      let i += 1&#xA;   endwhile&#xA;   let command .= &quot;tgT&quot;&#xA;&#xA;   &quot; Restore the Explore tab position.&#xA;   if i != 1&#xA;      let command .= &quot;:tabmove -&quot; . ( n_lines - 1 ) . &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;   endif&#xA;&#xA;   &quot; Restore the previous cursor line.&#xA;   let command .= &quot;:&quot; . a:current_line  . &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;&#xA;   &quot; Check function arguments&#xA;   if a:0 &amp;gt; 0&#xA;      if a:1 &amp;gt; 0 &amp;amp;&amp;amp; a:1 &amp;lt;= n_lines&#xA;         &quot; The current tab is for the nth file.&#xA;         let command .= ( tabpagenr() + a:1 ) . &quot;gt&quot;&#xA;      else&#xA;         &quot; The current tab is for the last selected file.&#xA;         let command .= (tabpagenr() + n_lines) . &quot;gt&quot;&#xA;      endif&#xA;   endif&#xA;   &quot; The current tab is for the Explore tab by default.&#xA;&#xA;   &quot; Execute the custom command.&#xA;   execute command&#xA;endfunction&#xA;&#xA;&quot; Define mappings.&#xA;augroup NetrwOpenMultiTabGroup&#xA;   autocmd!&#xA;   autocmd Filetype netrw vnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; t &quot;:call NetrwOpenMultiTab(&quot; . line(&quot;.&quot;) . &quot;,&quot; . &quot;v:count)\&amp;lt;CR&amp;gt;&quot;&#xA;   autocmd Filetype netrw vnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; T &quot;:call NetrwOpenMultiTab(&quot; . line(&quot;.&quot;) . &quot;,&quot; . (( v:count == 0) ? '' : v:count) . &quot;)\&amp;lt;CR&amp;gt;&quot;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Restart Vim and then you can:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open Netrw (e.g., with &lt;code&gt;:Explore&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Move the cursor to the first file.&lt;/li&gt;&#xA;&lt;li&gt;Enter Line-wise Visual mode by hitting &lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;V&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;kbd&gt;J&lt;/kbd&gt; (That's not &lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;J&lt;/kbd&gt;, just in case)&#xA;as much as you need to.&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;kbd&gt;T&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Advantages&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You don't need to add any plugin&lt;/li&gt;&#xA;&lt;li&gt;It doesn't stuff the arglist&lt;/li&gt;&#xA;&lt;li&gt;You'll preserve the order of the buffer list and tabs&lt;/li&gt;&#xA;&lt;li&gt;You can choose which tab will be the current one by using or not using a&#xA;count in the mapping.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Explanation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There's a lot going on here so if you're in doubt, just let me know. Let's &#xA;say the directory you open with &lt;code&gt;:Explore&lt;/code&gt; is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;../&#xA;./&#xA;a.txt&#xA;b.txt&#xA;c.txt&#xA;d.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the cursor is on file &lt;code&gt;a.txt&lt;/code&gt; and next, you press &#xA;&lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;V&lt;/kbd&gt; and move the cursor to the line with &lt;code&gt;d.txt&lt;/code&gt;.&#xA;You can hit:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;T&lt;/kbd&gt; to open each file in a tab and select the file &lt;code&gt;d.txt&lt;/code&gt; as the &#xA;current tab&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;T&lt;/kbd&gt; to open each file in a tab and select the file &lt;code&gt;a.txt&lt;/code&gt; as the&#xA;current tab&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;T&lt;/kbd&gt; to open each file in a tab and select the file &lt;code&gt;b.txt&lt;/code&gt; as the&#xA;current tab&lt;/li&gt;&#xA;&lt;li&gt;And so on&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Or you can hit:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;T&lt;/kbd&gt; to open each file in a tab and keep the&#xA;current tab.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;T&lt;/kbd&gt; to do the same as &lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;T&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;T&lt;/kbd&gt; to do the same as &lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;T&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The differences between &lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;T&lt;/kbd&gt; and &lt;kbd&gt;T&lt;/kbd&gt; are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;T&lt;/kbd&gt; select the last selected file as the current tab by default&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;T&lt;/kbd&gt; keeps the current tab by default&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="6698" LastEditDate="2017-08-28T11:42:05.653" LastActivityDate="2017-08-28T11:42:05.653" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="13354" PostTypeId="1" CreationDate="2017-08-25T05:14:19.640" Score="1" ViewCount="626" Body="&lt;p&gt;I want to map &lt;strong&gt;W&lt;/strong&gt; to jump to the next keyword of the language&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;or&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;jump to the next interestingly syntax highlighted word&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the following snippet&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SELECT *&#xA;FROM Fruits&#xA;WHERE Fruits.name = 'Apple' AND Fruits.color = 'Red' AND Fruits.taste = 'crisp'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A desirable result when pressing &lt;strong&gt;W&lt;/strong&gt; should go to SELECT-&gt;FROM-&gt;WHERE-&gt;AND or something similar&lt;/p&gt;&#xA;" OwnerUserId="14004" LastActivityDate="2017-08-25T06:53:47.383" Title="Move to next keyword in vim?" Tags="|navigation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13355" PostTypeId="2" ParentId="13354" CreationDate="2017-08-25T06:53:47.383" Score="2" Body="&lt;p&gt;You can do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    function! MoveCursor(forward)&#xA;        let stop_re = 'sql\%(Keyword\|Operator\|Statement\)'&#xA;        let curpos=getcurpos()&#xA;        while search('\&amp;lt;', 'W'.a:forward)&#xA;            if synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 1), &quot;name&quot;) =~ stop_re&#xA;                break&#xA;            endif&#xA;        endwhile&#xA;        if synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 1), &quot;name&quot;) !~ stop_re&#xA;            call setpos('.', curpos)&#xA;        endif&#xA;    endfunction&#xA;&#xA;    nnoremap W :call MoveCursor('')&amp;lt;cr&amp;gt;&#xA;    nnoremap B :call MoveCursor('b')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where you want to stop, you configure with the &lt;code&gt;stop_re&lt;/code&gt; which is a regular expression, taking the syntax groups on which to stop. You can check with &lt;code&gt;:echo synIDattr(synID(line('.'),col('.'),1),'name')&lt;/code&gt; with the cursor on an interesting syntax definition and add it to that regular expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rest is basically, search forward (or backward) for beginning of the next word, check that it matches your stop regular expression and continue or stop.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-08-25T06:53:47.383" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13356" PostTypeId="1" AcceptedAnswerId="13357" CreationDate="2017-08-25T09:46:07.287" Score="11" ViewCount="14103" Body="&lt;p&gt;I just installed a plugin for python which displays methods tree. So I would like to open the tree on startup, so not necessary to push the buttons everytime I open some &lt;code&gt;.py&lt;/code&gt; file. But, I want this command is executed only for &lt;code&gt;.py&lt;/code&gt; files. Here is how my vimrc piece looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F8&amp;gt; :TagbarToggle&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to execute this command at startup only for &lt;code&gt;.py&lt;/code&gt; files?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2017-09-01T02:31:17.733" Title="How to execute a command on vim startup" Tags="|normal-mode|startup|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13357" PostTypeId="2" ParentId="13356" CreationDate="2017-08-25T10:08:16.400" Score="9" Body="&lt;p&gt;Add in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufEnter *.py :TagbarToggle&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;au&lt;/code&gt; is &lt;code&gt;autocmd&lt;/code&gt;, execute the command automatically.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;BufEnter&lt;/code&gt; is when you enter the file for first time.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;*.py&lt;/code&gt; is for filetype python.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;and the rest is the command to be executed &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4745" LastEditorUserId="4472" LastEditDate="2017-09-01T02:31:17.733" LastActivityDate="2017-09-01T02:31:17.733" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13358" PostTypeId="2" ParentId="13356" CreationDate="2017-08-25T10:09:31.157" Score="12" Body="&lt;p&gt;In my opinion, the cleanest method of doing this is simply to add the command to a file in your &lt;code&gt;.vim/vimfiles&lt;/code&gt; directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/after/ftplugin/python.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or for Windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$HOME\vimfiles\after\ftplugin\python.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This technique is documented in &lt;code&gt;:help ftplugin-overrule&lt;/code&gt; (list item 3), although the context (changing settings) is slightly different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It offers the following benefits over the autocommand technique &lt;a href=&quot;https://vi.stackexchange.com/a/13357/343&quot;&gt;described by kapil&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Less code&lt;/strong&gt;. You just write the Vimscript you want executed. You don't need to code an autocommand and surround it with  &lt;code&gt;augroup&lt;/code&gt; and &lt;code&gt;autocommand!&lt;/code&gt; clear commands.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Less overhead&lt;/strong&gt;. Vim is already detecting the file type and checking for the existence of the &lt;code&gt;after/ftplugin/filetype&lt;/code&gt; file: why add an additional autocommand that performs the same purpose?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cleaner &lt;code&gt;.vimrc&lt;/code&gt;&lt;/strong&gt;. I think it's better to have file-type-specific functionality separated out from my &lt;code&gt;.vimrc&lt;/code&gt;. (Some disagree with this, though: see the disadvantages, below.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It also has a couple of minor disadvantages:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;It only works if you are using Vim's filetype detection. (&lt;code&gt;:help filetype&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this is generally one of the first settings that people enable in their .vimrc, and I'd wager that almost all Vim users already have it switched on.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Some people prefer to keep all their config in their &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-08-25T11:30:04.647" LastActivityDate="2017-08-25T11:30:04.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13359" PostTypeId="2" ParentId="13348" CreationDate="2017-08-25T10:42:30.750" Score="3" Body="&lt;p&gt;Make sure you are editing a JS file (&lt;code&gt;echo &amp;amp;filetype&lt;/code&gt; should output &lt;code&gt;javascript&lt;/code&gt;), and check the function used for omni completion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose setlocal omnifunc?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should display something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  omnifunc=tern#Complete&#xA;        Last set from ~/.vim/plugged/tern_for_vim/autoload/tern.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If not the case, then &lt;code&gt;tern_for_vim/after/ftplugin/javascript_tern.vim&lt;/code&gt; may not be loaded (&lt;code&gt;:scriptnames&lt;/code&gt;). This file contains the call to &lt;code&gt;tern#Enable()&lt;/code&gt; which in turn sets the local &lt;code&gt;&amp;amp;omnifunc&lt;/code&gt; to &lt;code&gt;tern#Complete&lt;/code&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To manually enable omni completion (as a quickfix), you could try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType javascript setlocal omnifunc=tern#Complete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then start completion in insert mode with &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h compl-omni&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h 'omnifunc'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-25T10:42:30.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13360" PostTypeId="2" ParentId="12380" CreationDate="2017-08-25T12:43:32.580" Score="0" Body="&lt;p&gt;I found these more intuitive and useful after trying Rafi's answer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Up&amp;gt;    &amp;lt;C-w&amp;gt;+&#xA;nnoremap &amp;lt;Down&amp;gt;  &amp;lt;C-w&amp;gt;-&#xA;nnoremap &amp;lt;Left&amp;gt;  &amp;lt;C-w&amp;gt;&amp;lt;&#xA;nnoremap &amp;lt;Right&amp;gt; &amp;lt;C-w&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14009" LastActivityDate="2017-08-25T12:43:32.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13361" PostTypeId="2" ParentId="13183" CreationDate="2017-08-25T15:31:44.597" Score="1" Body="&lt;p&gt;It's not resolving the root of the problem, but you could try to override highlight groups each time the colorsheme is set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyColorScheme&#xA;    autocmd!&#xA;    autocmd ColorScheme dracula highlight Normal ctermfg=231 ctermbg=NONE cterm=NONE&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-08-25T15:31:44.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13362" PostTypeId="2" ParentId="12942" CreationDate="2017-08-25T15:40:10.843" Score="1" Body="&lt;p&gt;The program &lt;a href=&quot;https://sourceforge.net/projects/findent/&quot; rel=&quot;nofollow noreferrer&quot;&gt;findent&lt;/a&gt; recognizes &lt;code&gt;forall&lt;/code&gt; and &lt;code&gt;where&lt;/code&gt; one-liners and blocks and indents them correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tarball contains instructions how to incorporate findent in vim and gedit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since version 2.8.2, findent will create the appropriate configuration files for use with vim, gedit and emacs.&lt;/p&gt;&#xA;" OwnerUserId="13993" LastEditorUserId="-1" LastEditDate="2018-06-18T07:11:27.443" LastActivityDate="2018-06-18T07:11:27.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13363" PostTypeId="2" ParentId="196" CreationDate="2017-08-25T16:30:42.753" Score="22" Body="&lt;p&gt;I prefer always breaking the problem into two steps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v(https?):\/\/(.{-})\/.*        &amp;lt;-- Search&#xA;:%s,,Protocol:\1 - Domain:\2,g    &amp;lt;-- Substitution&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using very magic &quot;\v&quot; to avoid many backslashes, referencing the last search&#xA;in substitution and changing substitution delimiter. All these changes make the code more readable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/g4uGI.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/g4uGI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2017-08-25T16:48:49.497" LastActivityDate="2017-08-25T16:48:49.497" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13364" PostTypeId="1" AcceptedAnswerId="13387" CreationDate="2017-08-25T17:04:05.677" Score="5" ViewCount="315" Body="&lt;p&gt;I have a custom key mapping &lt;code&gt;jj&lt;/code&gt; to escape, it works for normal file edit but when I open the file as a superuser the key mapping doesn't work anymore, why?&#xA;I use Antergos os.&lt;/p&gt;&#xA;" OwnerUserId="4745" LastEditorUserId="12003" LastEditDate="2017-08-26T12:58:27.967" LastActivityDate="2017-09-12T15:53:55.643" Title="Vim custom key mapping not working in superuser mode" Tags="|key-bindings|unix|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13366" PostTypeId="2" ParentId="13364" CreationDate="2017-08-25T17:15:31.873" Score="6" Body="&lt;p&gt;When you run vim using &lt;code&gt;su&lt;/code&gt; or &lt;code&gt;sudo&lt;/code&gt;, I believe it's running the root user's &lt;code&gt;.vimrc&lt;/code&gt; (if there is one) instead of yours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the most &quot;correct&quot; way to resolve this is to use &lt;code&gt;sudoedit&lt;/code&gt; rather than running vim directly as the super user.  This answer should get you going with that: &lt;a href=&quot;https://unix.stackexchange.com/questions/46699/start-vim-as-my-user-with-root-privileges&quot;&gt;https://unix.stackexchange.com/questions/46699/start-vim-as-my-user-with-root-privileges&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1115" LastEditorUserId="4472" LastEditDate="2017-08-27T07:20:42.220" LastActivityDate="2017-08-27T07:20:42.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13367" PostTypeId="1" AcceptedAnswerId="13368" CreationDate="2017-08-25T21:12:06.723" Score="2" ViewCount="1589" Body="&lt;p&gt;I'm working with large xml files that have tags, and some are spread across multiple lines, and some are on a single line. I'd like them to all be on a single line. There are other tags in the files besides the one I want to modify.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;group value=&quot;abc&quot;&amp;gt;&#xA;   &amp;lt;line value=&quot;abc&quot; value2=&quot;def&quot;/&amp;gt;&#xA;   &amp;lt;line value=&quot;ghi&quot;&#xA;      value2=&quot;jkl&quot;/&amp;gt;&#xA;&amp;lt;/group&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like it to look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;group value=&quot;abc&quot;&amp;gt;&#xA;   &amp;lt;line value=&quot;abc&quot; value2=&quot;def&quot;/&amp;gt;&#xA;   &amp;lt;line value=&quot;ghi&quot; value2=&quot;jkl&quot;/&amp;gt;&#xA;&amp;lt;/group&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried two approaches so far. The first is to try to apply a join to a range for the &lt;code&gt;&amp;lt;line&amp;gt;&lt;/code&gt; tag. The second is to try to do a substitution across multiple lines to remove newlines and extra whitespace. Some examples that almost work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/&amp;lt;line/,/\/&amp;gt;/join&#xA;:v/\/&amp;gt;/g/&amp;lt;line/,/\/&amp;gt;/join&#xA;:g/&amp;lt;line\_.{-}\/&amp;gt;/s/\n\s*/ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14016" LastEditorUserId="51" LastEditDate="2018-08-22T16:59:10.150" LastActivityDate="2018-08-22T16:59:10.150" Title="How do I remove newlines inside arbitrary xml tags matching a pattern?" Tags="|regular-expression|multiple-lines|filetype-xml|join|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13368" PostTypeId="2" ParentId="13367" CreationDate="2017-08-25T21:48:14.217" Score="1" Body="&lt;p&gt;First off, I never knew that you can have a search in the range. Thanks for making me learn something new!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second off, you were really close with &lt;code&gt;:g/&amp;lt;line/,/\/&amp;gt;/join&lt;/code&gt;. But I'm pretty sure that the problem is that the second line i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &amp;lt;line value=&quot;abc&quot; value2=&quot;def&quot;/&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is also matched by &lt;code&gt;&amp;lt;line/,/\/&amp;gt;&lt;/code&gt; so this line is joined with the next when it shouldn't be. I guess the search can't match it's own line. This seems to be consistent behavior. For example, try putting this into your buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc&#xA;abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:,/abc/join&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does join the two lines together. So to get around this, we'll need to make sure that closed tags are not matched. Originally I had:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/&amp;lt;line.*\(\/&amp;gt;\)\@!..$/,/\/&amp;gt;/j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will match any line containing &lt;code&gt;&amp;lt;line&lt;/code&gt; that doesn't end with &lt;code&gt;/&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this seems like black magic, try mentally breaking it up into 3 parts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;line.*&#xA;\(\/&amp;gt;\)\@!&#xA;..$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And read up on the &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%40%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\@!&lt;/code&gt;&lt;/a&gt; quantifier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now as I write up this answer, I realized there's a much simpler solution using negative character ranges:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/&amp;lt;line.*[^/][^&amp;gt;]$/,/\/&amp;gt;/j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is both simpler, and &lt;em&gt;waaaaay&lt;/em&gt; easier to understand.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-08-25T21:48:14.217" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13369" PostTypeId="1" CreationDate="2017-08-26T08:06:49.220" Score="6" ViewCount="1342" Body="&lt;p&gt;One thing that drives me crazy is unpredictable quickfix behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say I am editing a file, then I split the window and would like to find something and open in that buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;:Ag whatever&lt;/code&gt; to fill the QuickFix and press &lt;code&gt;Enter&lt;/code&gt; on the search result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Expected:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;File is opened in the split I use before going to QuickFix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actual:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;File is opened in any split on the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that you can search first and split after. I usually keep many buffers open to see the whole chain of calls/requires and I would like to insert buffers in between other ones.&lt;/p&gt;&#xA;" OwnerUserId="237" LastActivityDate="2017-08-26T21:33:20.087" Title="Which buffer quickfix file is opened in?" Tags="|buffers|quickfix|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13370" PostTypeId="2" ParentId="13350" CreationDate="2017-08-26T08:53:50.557" Score="5" Body="&lt;p&gt;This seems to be a known issue, see the comment in &lt;a href=&quot;https://github.com/vim-latex/vim-latex/blob/v1.10.0/ftplugin/latex-suite/envmacros.vim#L962-L966&quot; rel=&quot;nofollow noreferrer&quot;&gt;ftplugin/latex-suite/envmacros.vim&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Only include the &amp;lt;M-i&amp;gt; mapping if the user want this. Note that it&#xA;&amp;quot; conflicts with inserting 'é'.&#xA;if !hasmapto(&amp;quot;&amp;lt;Plug&amp;gt;Tex_InsertItemOnThisLine&amp;quot;, &amp;quot;i&amp;quot;) &amp;amp;&amp;amp; g:Tex_AdvancedMath == 1&#xA;    imap &amp;lt;buffer&amp;gt; &amp;lt;M-i&amp;gt; &amp;lt;Plug&amp;gt;Tex_InsertItemOnThisLine&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;From the vim-latex help &lt;a href=&quot;https://github.com/vim-latex/vim-latex/blob/master/doc/latex-suite.txt#L745-L771&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;altkey-mappings&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;By default, the mappings involving the  key are turned off for compatibility with inserting non-ASCII characters. It can be enabled by setting&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:Tex_AdvancedMath = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;in your &lt;code&gt;$VIM/ftplugin/tex.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Curiously, I couldn't find this in the online documentation about &lt;a href=&quot;http://vim-latex.sourceforge.net/documentation/latex-suite/altkey-mappings.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Alt Key Macros&lt;/a&gt; which starts at:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;By default, typing &lt;code&gt;Alt-&amp;lt;key&amp;gt;&lt;/code&gt; in Vim takes focus to the menu bar if a menu with the hotkey &lt;code&gt;&amp;lt;key&amp;gt;&lt;/code&gt; exists. If in your case, there are conflicts due to this behavior, you will need to set&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set winaltkeys=no&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;in your &lt;code&gt;$VIM/ftplugin/tex.vim&lt;/code&gt; in order to use these maps.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;See also &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap-alt-keys&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:map-alt-keys&lt;/code&gt;&lt;/a&gt; for more information on how Vim handles &lt;code&gt;Alt-&amp;lt;key&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2022-06-29T10:36:10.057" LastActivityDate="2022-06-29T10:36:10.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13371" PostTypeId="2" ParentId="13369" CreationDate="2017-08-26T10:04:34.643" Score="2" Body="&lt;p&gt;Are you using &lt;a href=&quot;https://github.com/rking/ag.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;ag.vim&lt;/code&gt;&lt;/a&gt; which is  &lt;a href=&quot;https://github.com/rking/ag.vim/issues/124#issuecomment-227038003&quot; rel=&quot;nofollow noreferrer&quot;&gt;depecrated&lt;/a&gt;? You should try &lt;a href=&quot;https://github.com/mileszs/ack.vim#can-i-use-ag-the-silver-searcher-with-this&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;ack.vim&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that, are you sure that the expected window is focused?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have these settings in my vimrc to make the split direction more &quot;natural&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set splitbelow &quot; Split windows below the current window&#xA;set splitright &quot; Split windows right of the current window&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: From the &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#quickfix-window&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;quickfix-window&lt;/code&gt;&lt;/a&gt; help:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The file containing the error is opened in the window above the&#xA;  quickfix window.  If there already is a window for that file, it is used&#xA;  instead.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It seems to open the file in the &lt;em&gt;bottom right split&lt;/em&gt; every time, not the last used.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2017-08-26T14:31:03.273" LastActivityDate="2017-08-26T14:31:03.273" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13373" PostTypeId="1" AcceptedAnswerId="13375" CreationDate="2017-08-26T14:31:35.003" Score="1" ViewCount="391" Body="&lt;p&gt;I'm trying to create a plugin for inserting things like closing quotes, brackets, parenthesis and xml tags. I know about delimitMate, auto-pairs and others, but I'm not satisfied with them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DelimitMate is kind hard to configure and nice features like &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; expansion doesn't work by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;auto-pairs doesn't work with Python in things like &lt;code&gt;b''&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To insert a closing tag you have to install another plugin and it doesn't work very well (It's been a long time since I tried).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everyone is telling that inserting a pairs automatically is surprisingly hard, but I thought about it for a while and it doesn't seem that hard at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you need to map every character that can trigger insertion to a function that would search a list of user defined regexes for a pair of regexes that would match text before and after the cursor. If match is found is passed to a function that would return the actual text to insert.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way for example inserting closing tags, python's &lt;code&gt;&quot;&quot;&quot;&quot;&quot;&quot;&lt;/code&gt;, &lt;code&gt;f''&lt;/code&gt;is trivial.&#xA;Here's a proof of concept code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! RetMatch(matched)&#xA;    return '&amp;gt;&amp;lt;/' . join(reverse(split(a:matched, '.\zs')), '') . '&amp;gt;'&#xA;endfu&#xA;&#xA;fu! SmartPair()&#xA;    &quot; let pairs = {'&quot;': [['&quot;&quot;', '&quot;&quot;&quot;'], ['[bfr]\?', '&quot;']]}&#xA;    let pairs = {'&amp;gt;': [['[^&amp;lt;]\+\ze&amp;lt;', function('RetMatch')]]}&#xA;    let reversed_line = join(reverse(split(getline('.')[:col('.')], '.\zs')), '')&#xA;    let longest_match_len = -1&#xA;    let longest_match = ''&#xA;    let Longest_substitution = ''&#xA;    for [pattern, Substitution] in pairs['&amp;gt;']&#xA;        let [matched, mstart, mend] = matchstrpos(reversed_line, pattern)&#xA;        if mstart == 0 &amp;amp;&amp;amp; mend - mstart &amp;gt;= longest_match_len&#xA;            let longest_match_len = mend - mstart&#xA;            let longest_match = matched&#xA;            let Longest_substitution = Substitution&#xA;        endif&#xA;    endfor&#xA;    let substitution_type = type(Longest_substitution)&#xA;    if longest_match_len &amp;gt;= 0&#xA;        if substitution_type == 1&#xA;            return '&quot;' . longest_substitution&#xA;        elseif substitution_type == 2&#xA;            return Longest_substitution(longest_match)&#xA;        endif&#xA;    else&#xA;        return '&quot;'&#xA;    endif&#xA;endfu&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &quot; SmartPair()&#xA;inoremap &amp;lt;expr&amp;gt; &amp;gt; SmartPair()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice how the same approarch makes inserting so called space expansion easy, you just need to define a mapping for space, the regexes pair would be something like &lt;code&gt;'('&lt;/code&gt; to match before the cursor, and &lt;code&gt;')'&lt;/code&gt; to match after and a function that would return resulting text would return two spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this also can be achieved by using &lt;code&gt;InsertCharPre&lt;/code&gt;...&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6634" LastEditDate="2017-08-26T14:39:37.663" LastActivityDate="2017-08-26T19:20:06.460" Title="How to move cursor in expression insert mode mapping?" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13374" PostTypeId="1" AcceptedAnswerId="13376" CreationDate="2017-08-26T17:50:09.973" Score="3" ViewCount="787" Body="&lt;p&gt;When I was editing a fairly large text, I accidentally hit &lt;code&gt;gq*&lt;/code&gt; instead of &lt;code&gt;gq}&lt;/code&gt; and then vim apparently seemed to freeze a moment with the message &lt;code&gt;search hit BOTTOM, continuing at TOP&lt;/code&gt; displayed in the command line. I found out it was because the &lt;code&gt;wrapscan&lt;/code&gt; option was enabled by default and when the word under cursor was not found between the cursor position and the end of the file, the search continued from the top.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I should say this is not what we normally expect when formatting text. Besides, the &lt;code&gt;gq&lt;/code&gt; command behaves rather weirdly when search wraps round. So I'm trying to figure out how to set the &lt;code&gt;nowrapscan&lt;/code&gt; option when formatting text with &lt;code&gt;gq&lt;/code&gt;. Though I barely know anything about scripting, I managed to write the following function after reading a couple of topics in help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F4&amp;gt; :set opfunc=GqNoWrapscan&amp;lt;CR&amp;gt;g@&#xA;&#xA;function! GqNoWrapscan(type)&#xA;    let s:wrapscan = &amp;amp;wrapscan&#xA;    set nowrapscan&#xA;    silent exe &quot;normal! '[gq']&quot;&#xA;    let &amp;amp;wrapscan = s:wrapscan&#xA;    unlet! s:wrapscan&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this function does not work as expected. I still get the same message and the &lt;code&gt;nowrapscan&lt;/code&gt; option is apparently not set when I hit &amp;lt;F4&amp;gt;*. Could anyone help?&lt;/p&gt;&#xA;" OwnerUserId="14025" LastEditorUserId="1841" LastEditDate="2017-08-27T13:27:32.313" LastActivityDate="2017-08-27T13:27:32.313" Title="How to set nowrapscan when formatting text with gq" Tags="|search|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13375" PostTypeId="2" ParentId="13373" CreationDate="2017-08-26T19:20:06.460" Score="2" Body="&lt;p&gt;For &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mappings, you are not allowed to move the cursor (or rather the position of the cursor will be restored afterwards) as it is written in the &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#:map-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;help&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However what you can do is return the keychars which would move the cursor, e.g. in your expr do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;expr&amp;gt; , Foobar()&#xA;function Foobar()&#xA;  &quot;... do some magic&#xA;  let result=&quot;...&quot;&#xA;  return &quot;\&amp;lt;left&amp;gt;\&amp;lt;left&amp;gt;&quot;.result&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So don't move the cursor directly, but make the result of your expression move the cursor.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-08-26T19:20:06.460" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13376" PostTypeId="2" ParentId="13374" CreationDate="2017-08-26T20:41:36.200" Score="1" Body="&lt;p&gt;&lt;code&gt;g@&lt;/code&gt; works like this: vim waits for a motion, does the motion, stuffs the beginning and end cursor positions into the &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; marks, then calls your opfunc.   So, by the time &lt;code&gt;GqNoWrapscan&lt;/code&gt; is entered, the &lt;code&gt;*&lt;/code&gt; search has already been done, and &lt;code&gt;wrapscan&lt;/code&gt; was on.  You would need to &lt;code&gt;set nowrapscan&lt;/code&gt; before the &lt;code&gt;g@&lt;/code&gt;.  Unfortunately, what you are trying to accomplish is non-trivial, since if you provide an invalid motion (or press escape), you will wind up with wrapscan changed with no way to change it back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One alternative approach (just for illustration) would be to remap &lt;code&gt;*&lt;/code&gt; in operator-pending mode so that if it comes after a &lt;code&gt;gq&lt;/code&gt;, it does not use &lt;code&gt;wrapscan&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! StarNoWrap()&#xA;    let l:wrapscan = &amp;amp;wrapscan&#xA;    if v:operator ==# 'gq'&#xA;        set nowrapscan&#xA;    endif&#xA;    try&#xA;        exe 'normal! '.v:count.'*'&#xA;    catch /^Vim\%((\a\+)\)\=:E385/&#xA;        &quot; search hit BOTTOM without match&#xA;        &quot; ought to print an error message here&#xA;    endtry&#xA;    let &amp;amp;wrapscan = l:wrapscan&#xA;endfunction&#xA;&#xA;onoremap * :&amp;lt;c-u&amp;gt;call StarNoWrap()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An even simpler and more practical approach would be to just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GqNoWrap()&#xA;    let l:wrapscan = &amp;amp;wrapscan&#xA;    set nowrapscan&#xA;    normal! gq*&#xA;    let &amp;amp;wrapscan = l:wrapscan&#xA;endfunction&#xA;&#xA;nnoremap gq* :&amp;lt;c-u&amp;gt;call GqNoWrapScan()&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; only if you don't want to override regular gq:&#xA;nnoremap &amp;lt;F4&amp;gt; gq&#xA;nnoremap &amp;lt;F4&amp;gt;* :&amp;lt;c-u&amp;gt;call GqNoWrapScan()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will also have to handle &lt;code&gt;#&lt;/code&gt; and possibly &lt;code&gt;n&lt;/code&gt;, &lt;code&gt;N&lt;/code&gt; and a few other commands.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-08-26T20:47:29.090" LastActivityDate="2017-08-26T20:47:29.090" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13377" PostTypeId="2" ParentId="13369" CreationDate="2017-08-26T21:33:20.087" Score="8" Body="&lt;p&gt;This is a fairly widespread and well-known annoyance.  There are at least two plugins which aim to address it: &lt;a href=&quot;https://github.com/romainl/vim-qf&quot; rel=&quot;noreferrer&quot;&gt;vim-qf&lt;/a&gt; and &lt;a href=&quot;https://github.com/yssl/QFEnter&quot; rel=&quot;noreferrer&quot;&gt;QFEnter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, the behavior is quite predictable (cf &lt;code&gt;:help quickfix.txt&lt;/code&gt;).  If the file is already open, vim switches to it and moves to the correct line/column. Otherwise, the window directly above the quickfix window is used (and the buffer is replaced).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So aside from living with the possibly unintuitive default behavior, you have a few options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;remap &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; (or anything else) in the quickfix window to do something else, for example opening the item in the previous window. Example:&#xA;&lt;code&gt;autocmd FileType qf nnoremap &amp;lt;cr&amp;gt; :exe 'wincmd p \| '.line('.').'cc'&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;use a plugin which makes similar maps&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;only ever use &lt;code&gt;:cc&lt;/code&gt;, &lt;code&gt;:cnext&lt;/code&gt;, and &lt;code&gt;:cprev&lt;/code&gt;, which operate in the current window (although this would require&lt;code&gt;set switchbuf=&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-08-26T21:33:20.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13378" PostTypeId="2" ParentId="8741" CreationDate="2017-08-27T02:38:06.507" Score="14" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/romainl/vim-cool&quot; rel=&quot;noreferrer&quot;&gt;vim-cool&lt;/a&gt; is a simple plugin that does just this.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim-cool disables search highlighting when you are done searching and&#xA;  re-enables it when you search again.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It works &lt;em&gt;without remapping&lt;/em&gt; by &lt;a href=&quot;https://github.com/romainl/vim-cool/issues/9&quot; rel=&quot;noreferrer&quot;&gt;using&lt;/a&gt; the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#CursorMoved&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;CursorMoved&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#InsertEnter&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;InsertEnter&lt;/code&gt;&lt;/a&gt; autocommands.&lt;/p&gt;&#xA;" OwnerUserId="14029" LastActivityDate="2017-08-27T02:38:06.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13379" PostTypeId="1" CreationDate="2017-08-27T03:53:29.800" Score="2" ViewCount="492" Body="&lt;p&gt;I'm cleaning data imported from Excel to Access, and ran across funny quotes that I'm having trouble getting unambiguous ASCII codes for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are the hooked single quotes &lt;code&gt;‘&lt;/code&gt; and &lt;code&gt;’&lt;/code&gt;.  Vim's &lt;code&gt;ga&lt;/code&gt; command show them to have decimal codes &lt;code&gt;8216&lt;/code&gt; and &lt;code&gt;8217&lt;/code&gt;, but Microsoft's ASC function shows them to have decimal codes &lt;code&gt;145&lt;/code&gt; and &lt;code&gt;146&lt;/code&gt;.  In the end, I used Microsoft's &lt;code&gt;CHR(145)&lt;/code&gt; and &lt;code&gt;CHR(146)&lt;/code&gt; to locate and clean them, but I was wondering how to interpret the larger numbers returned by Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Microsoft numbers do not have bit patterns that are subsets of the larger Microsoft numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;octave:6&amp;gt; dec2bin([145 146])&#xA;&#xA;   10010001&#xA;   10010010&#xA;&#xA;octave:5&amp;gt; dec2bin([8216 8217])&#xA;&#xA;   10000000011000&#xA;   10000000011001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My vim version details are below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim version details:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May 20 2015 22:20:54)&#xA;Included patches: 1-729&#xA;Compiled by &amp;lt;cygwin-xfree@cygwin.com&amp;gt;&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl             -ebcdic          +localmap        +printer         +title&#xA;+arabic          +emacs_tags      +lua/dyn         +profile         +toolbar&#xA;+autocmd         +eval            +menu            +python/dyn      +user_commands&#xA;+balloon_eval    +ex_extra        +mksession       +python3/dyn     +vertsplit&#xA;+browse          +extra_search    +modify_fname    +quickfix        +virtualedit&#xA;++builtin_terms  +farsi           +mouse           +reltime         +visual&#xA;+byte_offset     +file_in_path    +mouseshape      +rightleft       +visualextra&#xA;+cindent         +find_in_path    +mouse_dec       +ruby/dyn        +viminfo&#xA;+clientserver    +float           -mouse_gpm       +scrollbind      +vreplace&#xA;+clipboard       +folding         -mouse_jsbterm   +signs           +wildignore&#xA;+cmdline_compl   -footer          +mouse_netterm   +smartindent     +wildmenu&#xA;+cmdline_hist    +fork()          +mouse_sgr       -sniff           +windows&#xA;+cmdline_info    +gettext         -mouse_sysmouse  +startuptime     +writebackup&#xA;+comments        -hangul_input    +mouse_urxvt     +statusline      +X11&#xA;+conceal         +iconv           +mouse_xterm     -sun_workshop    -xfontset&#xA;+cryptv          +insert_expand   +multi_byte      +syntax          +xim&#xA;+cscope          +jumplist        +multi_lang      +tag_binary      +xsmp_interact&#xA;+cursorbind      +keymap          -mzscheme        +tag_old_static  +xterm_clipboard&#xA;+cursorshape     +langmap         +netbeans_intg   -tag_any_white   -xterm_save&#xA;+dialog_con_gui  +libcall         +path_extra      -tcl             +xpm&#xA;+diff            +linebreak       +perl/dyn        +terminfo        &#xA;+digraphs        +lispindent      +persistent_undo +termresponse    &#xA;+dnd             +listcmds        +postscript      +textobjects     &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/etc&quot;&#xA; f-b for $VIMRUNTIME: &quot;/usr/share/vim/vim74&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -D_REENTRANT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16    -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/ports/vim/vim-7.4.729-2.x86_64/build=/usr/src/debug/vim-7.4.729-2 -fdebug-prefix-map=/usr/src/ports/vim/vim-7.4.729-2.x86_64/src/vim74=/usr/src/debug/vim-7.4.729-2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -L. -fstack-protector  -L/usr/local/lib -Wl,--as-needed -o vim.exe   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -lgio-2.0 -lXinerama -lXi -lXrandr -lXcursor -lXcomposite -latk-1.0 -lcairo -lz -lGL -lpixman-1 -lEGL -lm -lpthread -lGL -lm -lpthread -lXdamage -lXfixes -lX11-xcb -lxcb-glx -lxcb-shm -lxcb-render -lXrender -lXext -lX11 -lxcb -lXau -lXdmcp -lgdk_pixbuf-2.0 -lm -lpng16 -lm -lz -lgio-2.0 -lz -lpangoft2-1.0 -lharfbuzz -lpango-1.0 -lm -lgmodule-2.0 -lgobject-2.0 -lffi -lglib-2.0 -lintl -lpcre -lintl -liconv -lpcre -lfontconfig -lexpat -lfreetype -lbz2 -lz -lpng16 -lm -lz -lexpat -lfreetype -lbz2 -lz -lpng16 -lm -lz  -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lelf    -lncursesw -liconv -lintl   -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector -L/usr/local/lib  -L/usr/lib/perl5/5.14/x86_64-cygwin-threads/CORE -lperl -ldl -lcrypt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7970" LastEditorUserId="4472" LastEditDate="2017-09-01T02:31:12.170" LastActivityDate="2017-09-01T15:14:46.240" Title="How to interpret ASCII codes returned by &quot;ga&quot; command?" Tags="|microsoft-windows|unicode|encoding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13380" PostTypeId="1" AcceptedAnswerId="13381" CreationDate="2017-08-27T04:54:42.400" Score="1" ViewCount="485" Body="&lt;p&gt;I know there is a shortcut to open a new blank split window horizontally. Namely, &lt;code&gt;ctrl-w + n&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But is there a shortcut to do the same thing vertically? More precisely, I want a shortcut for &lt;code&gt;:vs ene&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't seem to find one inside &lt;code&gt;help&lt;/code&gt;. Does anyone know if such a shortcut exists or how I would go about mapping it myself considering I need to use &lt;code&gt;:&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="14019" LastEditorUserId="51" LastEditDate="2017-08-27T07:23:52.183" LastActivityDate="2017-08-27T07:23:52.183" Title="Is there a shortcut to open a blank vertical split window?" Tags="|key-bindings|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13381" PostTypeId="2" ParentId="13380" CreationDate="2017-08-27T05:27:16.377" Score="2" Body="&lt;p&gt;There's nothing special here, if you don't find a shortcut of your liking for a command just create your own with a simple Normal mode mapping. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap &amp;lt;Leader&amp;gt;v :vs ene&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming your Leader key is backslash then you can just type &lt;kbd&gt;\&lt;/kbd&gt; followed quickly by &lt;kbd&gt;v&lt;/kbd&gt; and you'll get your vertical split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can, of course, choose any key combination you want but using Leader is a good idea as it will not likely conflict with other Vim functionality. (And Leader has other benefits...including the ability to change Leader without changing existing mappings.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is all a bit foreign to you I encourage you to look at Vim help for key mappings (&lt;code&gt;:h mapping&lt;/code&gt;) and the Leader key (&lt;code&gt;:h &amp;lt;Leader&amp;gt;&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-08-27T05:35:00.827" LastActivityDate="2017-08-27T05:35:00.827" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13382" PostTypeId="1" AcceptedAnswerId="13383" CreationDate="2017-08-27T06:53:52.747" Score="1" ViewCount="867" Body="&lt;p&gt;I use gnome-termial most of the time, and the Nord colorscheme works well withat hat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I sometimes also use Tilda (another terminal emulator), and the Nord colorscheme doesn't work well with that!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've put then &lt;code&gt;colorscheme nord&lt;/code&gt; in my vimrc file. How can I disable nord in Vim only one time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:-&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~$ cat .vimrc&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'vim-scripts/c.vim'&#xA;&#xA;Plug 'vim-airline/vim-airline-themes'&#xA;&#xA;Plug 'vim-airline/vim-airline'&#xA;&#xA;Plug 'arcticicestudio/nord-vim'&#xA;&#xA;Plug 'scrooloose/nerdtree'&#xA;set number&#xA;call plug#end()&#xA;if &amp;amp;term ==&quot;gnome-256color&quot;&#xA;    colorscheme nord&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user16300" LastEditorDisplayName="user16300" LastEditDate="2017-08-27T08:08:02.237" LastActivityDate="2017-08-27T08:08:02.237" Title="How can I temporarily change to default color scheme?" Tags="|vimrc|colorscheme|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13383" PostTypeId="2" ParentId="13382" CreationDate="2017-08-27T07:32:35.787" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Acolorscheme&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:colorscheme&lt;/code&gt;&lt;/a&gt; command is just like any Vim command. You can run it from Vim's commandline mode after it started: &lt;code&gt;:colorscheme &amp;lt;name&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This applies to almost everything that you can put in your vimrc by the way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default colour scheme is named &lt;code&gt;default&lt;/code&gt;; you can load it with &lt;code&gt;:colorscheme default&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can try doing it automatically from your vimrc based on the &lt;code&gt;$TERM&lt;/code&gt; setting or something else unique in the environment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;term == &quot;gnome-256color&quot;&#xA;    colorscheme nord&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guessed the &lt;code&gt;TERM&lt;/code&gt; name here, as gnome-terminal doesn't want to start on my system for some reason. You'll have to check if this is the correct value.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;colorscheme&lt;/code&gt; will clear custom highlights, you need to define those in an autocommand if you have any of them (see &lt;a href=&quot;https://vi.stackexchange.com/q/3355/51&quot;&gt;Why do custom highlights in my vimrc get cleared or reset to default?&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-08-27T07:32:35.787" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13384" PostTypeId="1" AcceptedAnswerId="13390" CreationDate="2017-08-27T11:45:47.230" Score="6" ViewCount="3240" Body="&lt;p&gt;I found from the vim's manual that we can echo colored text by the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echohl WarningMsg | echo &quot;Warnging&quot; | echohl None | echo &quot;:Some warning&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will highlight the string &lt;code&gt;Warning&lt;/code&gt; and keep &lt;code&gt;:Some warning&lt;/code&gt; in default color. My problem is that this will display the results in two lines, is there any way to display them in one line?&lt;/p&gt;&#xA;" OwnerUserId="10430" LastActivityDate="2017-08-27T17:58:55.710" Title="Echo highlighted warning in one line" Tags="|vimscript|highlight|echo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13386" PostTypeId="1" CreationDate="2017-08-27T12:51:27.193" Score="1" ViewCount="80" Body="&lt;p&gt;I want to implement a &lt;kbd&gt;Enter&lt;/kbd&gt; expansion for &lt;a href=&quot;https://github.com/purpleP/smartpairs.git&quot; rel=&quot;nofollow noreferrer&quot;&gt;my plugin&lt;/a&gt; like &lt;a href=&quot;https://github.com/Raimondi/delimitMate&quot; rel=&quot;nofollow noreferrer&quot;&gt;delimitMate&lt;/a&gt; and &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;auto pairs&lt;/a&gt; do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've done &lt;code&gt;inoremap &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;&amp;lt;C-o&amp;gt;O&lt;/code&gt;, but If I want to undo what seems like a single change I would need obviously undo twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to do that as a single change?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By &lt;kbd&gt;Enter&lt;/kbd&gt; expansion I mean this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some(|)&#xA;&#xA;Pressing enter&#xA;&#xA;some(&#xA;    |&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="4472" LastEditDate="2017-08-28T07:19:00.770" LastActivityDate="2017-08-28T07:19:00.770" Title="How to auto expand Enter as a single change?" Tags="|key-bindings|" AnswerCount="0" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13387" PostTypeId="2" ParentId="13364" CreationDate="2017-08-27T14:06:24.940" Score="1" Body="&lt;h1&gt;timtowtdi&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;As pointed out in the comments to the other answer you could also solve this with editing root's &lt;code&gt;~/.vimrc&lt;/code&gt; file.  There are other options though.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;symlink&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If your personal &lt;code&gt;~/.vimrc&lt;/code&gt; doesn't have any plugin weirdness or hard-coded directories you could just symlink root's &lt;code&gt;~/.vimrc&lt;/code&gt; to your personal one.  That way any other settings or future changes would also be available when you are root.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# cd /root&#xA;# ln -s ~chicks/.vimrc .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;&lt;code&gt;HOME&lt;/code&gt; environment variable&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;While testing that I also noticed that if my &lt;code&gt;HOME&lt;/code&gt; environment variable was set to my personal home directory vim picked up the settings from there.  My guess is this would work around the directory and plugin weirdness that I worried about with the symlink.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# HOME=/home/chicks&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't have to do this in normal practice because &lt;code&gt;sudo bash&lt;/code&gt; preserves my home directory and I also get my shell settings too.&lt;/p&gt;&#xA;" OwnerUserId="4472" LastEditorUserId="4472" LastEditDate="2017-09-12T15:53:55.643" LastActivityDate="2017-09-12T15:53:55.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13388" PostTypeId="1" AcceptedAnswerId="13389" CreationDate="2017-08-27T14:58:16.280" Score="1" ViewCount="938" Body="&lt;p&gt;I believe the following script in vimrc, which try to set &lt;code&gt;spellfile&lt;/code&gt;, has something to do with the scope of vim variable. Especially the difference of &lt;code&gt;$var&lt;/code&gt; and &lt;code&gt;g:var&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't figure out what's wrong with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:spelldir ='~/.vim/myvim/spell'&#xA;if !exists( 'g:spelldir' )&#xA;  silent exec '!mkdir -p ' . g:spelldir&#xA;endif&#xA;au FileType tex setlocal spf= g:spelldir/en.utf-8.add&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;while it works if we change &lt;code&gt;g:spelldir&lt;/code&gt; to &lt;code&gt;$spelldir&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10430" LastActivityDate="2017-08-28T00:46:25.747" Title="the scope of variable in vim" Tags="|vimscript|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13389" PostTypeId="2" ParentId="13388" CreationDate="2017-08-27T16:13:47.693" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;isdirectory&lt;/code&gt; not &lt;code&gt;exists&lt;/code&gt; to check if a directory exists.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;set&lt;/code&gt;/&lt;code&gt;setlocal&lt;/code&gt; does not expand variables but it does (sometimes) expand environment variables, which explains what you're seeing.  Use this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType tex exe 'setlocal spf='.g:spelldir.'/en.utf-8'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;g:spelldir&lt;/code&gt; is copied into the &lt;code&gt;setlocal&lt;/code&gt; string when the &lt;code&gt;FileType&lt;/code&gt; autocommand is triggered, then the whole string is executed.  It has nothing to do with variable scope, &lt;code&gt;g:&lt;/code&gt; is global.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="4472" LastEditDate="2017-08-28T00:46:25.747" LastActivityDate="2017-08-28T00:46:25.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13390" PostTypeId="2" ParentId="13384" CreationDate="2017-08-27T17:58:55.710" Score="11" Body="&lt;p&gt;This should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EchoWarning(msg)&#xA;  echohl WarningMsg&#xA;  echo &quot;Warning&quot;&#xA;  echohl None&#xA;  echon ': ' a:msg&#xA;endfunction&#xA;&#xA;call EchoWarning('test')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This defined a simple function that you can call with the warning message as the argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you see, the key is the &lt;code&gt;echon&lt;/code&gt; command, which is similar to an &lt;code&gt;echo&lt;/code&gt; except it does not add a newline at the end.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-08-27T17:58:55.710" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13391" PostTypeId="1" AcceptedAnswerId="13393" CreationDate="2017-08-28T00:27:02.603" Score="3" ViewCount="336" Body="&lt;p&gt;Suppose I have several files open each in a different active buffer. Is there a way to save a specific file in a different buffer without first switching to it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of this occurring is if I opened 10 new files and edited them all. I want to only save 3 of them and discard the changes to the remaining 7 before exiting.&lt;/p&gt;&#xA;" OwnerUserId="14019" LastActivityDate="2017-08-28T06:21:57.100" Title="How to save a specific file in a different buffer?" Tags="|save|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13392" PostTypeId="2" ParentId="13391" CreationDate="2017-08-28T04:56:04.793" Score="1" Body="&lt;p&gt;You can &lt;a href=&quot;http://vim.wikia.com/wiki/Run_a_command_in_multiple_buffers&quot; rel=&quot;nofollow noreferrer&quot;&gt;run a command in multiple buffers&lt;/a&gt;, and specify a buffer number range with &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Abufdo&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:bufdo&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]bufdo[!] {cmd}  Execute {cmd} in each buffer in the buffer list or if&#xA;                        [range] is given only for buffers for which their&#xA;                        buffer number is in the [range].  It works like doing&#xA;                        this: &#xA;                                :bfirst&#xA;                                :{cmd}&#xA;                                :bnext&#xA;                                :{cmd}&#xA;                                etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to filter files in the current directory based on a pattern, check &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#arglist&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h arglist&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args &#xA;:argdo update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To close all windows except one or more look up &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#:only&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:only&lt;/code&gt;&lt;/a&gt;, and use &lt;code&gt;:qa!&lt;/code&gt; to discard all changes.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2017-08-28T05:31:35.033" LastActivityDate="2017-08-28T05:31:35.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13393" PostTypeId="2" ParentId="13391" CreationDate="2017-08-28T05:45:11.013" Score="4" Body="&lt;p&gt;There are several ways possible to do what you want, but all involve some kind of scripting. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using &lt;code&gt;bufdo&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could use the already mentioned &lt;code&gt;bufdo&lt;/code&gt; like this (suppose you want to save the buffer number 4):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:4,4bufdo :w&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this will internally switch to buffer 4 and the cursor will remain in that buffer. So you would need to add some more scripting to restore the buffer afterwards. Also, if you don't know the buffer number (see &lt;code&gt;:ls&lt;/code&gt; to find out), but only know the buffer name you need a little bit of scripting, something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let bufnr=bufnr('name')&#xA;if bufnr &amp;gt; 0&#xA;   let curbuf=bufnr('%')&#xA;   try&#xA;       exe bufnr.','.bufnr.'bufdo :w'&#xA;   catch&#xA;   finally&#xA;       exe curbuf.'b'&#xA;   endtry&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is totally untested, but the idea should be clear. You could wrap it into a function and create a custom command to call this function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would only like to save a couple of buffers, say buffer 4 and 6 and reset all other buffers, you could do it like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;bufdo if index([4,6], bufnr('%')) &amp;gt; -1 | :w | else :e! |endif&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will save only buffer number 4 or 6 and reload the other buffers from disk (discarding their changes [depending on your undo settings, this is even undoable]). Note, also untested.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using &lt;code&gt;writefile&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Another alternative is to use the &lt;code&gt;writefile()&lt;/code&gt; function. That would work like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call writefile(getbufline('name', 1, '$'), fnamemodify(bufname('name'), ':p'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will get the content of the buffer that matches 'name' and write it. Note, if name matches several buffers, it will probably fail. So it would be good here to add some error handling here as well.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2017-08-28T06:21:57.100" LastActivityDate="2017-08-28T06:21:57.100" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13394" PostTypeId="1" CreationDate="2017-08-28T07:31:03.443" Score="3" ViewCount="1222" Body="&lt;p&gt;I want to set colorscheme during vimdiff at startup. Note this colorscheme would be different than Vim's colorscheme.&lt;/p&gt;&#xA;" OwnerUserId="9907" LastActivityDate="2017-08-30T14:51:48.393" Title="How to set colorscheme of vimdiff using .vimrc" Tags="|colorscheme|vimdiff|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13395" PostTypeId="2" ParentId="13394" CreationDate="2017-08-28T08:03:38.127" Score="2" Body="&lt;p&gt;You can use an auto command to achieve this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup VimDiff&#xA;    autocmd!&#xA;    autocmd VimEnter,FilterWritePre * if &amp;amp;diff | colorscheme default | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found &lt;code&gt;FileWritePre&lt;/code&gt; in the thread &lt;a href=&quot;http://vim.1045645.n5.nabble.com/Diff-mode-only-mappings-tp1146738p1146739.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Diff mode only mappings&lt;/em&gt;&lt;/a&gt;. This event allows you to enable specific settings after Vim started and when diff mode is set, with &lt;code&gt;:diffthis&lt;/code&gt; for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to check only once (for &lt;code&gt;vim -d&lt;/code&gt;), &lt;code&gt;VimEnter&lt;/code&gt; is enough but you should get rid of the auto command altogether (as &lt;a href=&quot;https://vi.stackexchange.com/questions/13394/how-to-set-colorscheme-of-vimdiff-using-vimrc/13395#comment22961_13395&quot;&gt;Christian&lt;/a&gt; pointed out):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;diff&#xA;    &quot; setup for diff mode&#xA;else&#xA;    &quot; setup for non-diff mode&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read &lt;a href=&quot;https://vimhelp.appspot.com/diff.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h diff&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2017-08-30T14:51:48.393" LastActivityDate="2017-08-30T14:51:48.393" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13396" PostTypeId="2" ParentId="2806" CreationDate="2017-08-28T08:58:21.693" Score="0" Body="&lt;p&gt;You did the opposite. You should have written &lt;code&gt;extends php&lt;/code&gt; in your &lt;code&gt;html.snippets&lt;/code&gt; file. Then you can open a myfile.php and start using html snippets.&lt;/p&gt;&#xA;" OwnerUserId="11707" LastActivityDate="2017-08-28T08:58:21.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13397" PostTypeId="2" ParentId="13072" CreationDate="2017-08-28T09:20:28.897" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;We need to know whether a help window is opened to close it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We could get the list of help buffers and filter the hidden-readonly-nonmodifiable ones with a &lt;code&gt;'help'&lt;/code&gt; filetype that are displayed in a window to know if a help buffer is already displayed. This is quite complex, but this could be done with an boolean expression, and thus used in a oneliner mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the help window can be closed with &lt;code&gt;:helpclose&lt;/code&gt;, it doesn't tell us whether it's open. Yet, we can use it to count the number of windows before and after &lt;code&gt;:helpc&lt;/code&gt;. This is best done with functions.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We need to be able to restore the help window to where it where. Either we listen for event, or we just play with &lt;code&gt;CTRL-O&lt;/code&gt;. &#xA;It may yield a blinking the first time. I guess this part will need improvements. It's meant to be used in a &lt;code&gt;:help sometopic&lt;/code&gt; -&gt; &lt;code&gt;:helpc&lt;/code&gt; -&gt; &lt;code&gt;:help&lt;/code&gt; + &lt;code&gt;CTRL-O&lt;/code&gt; scenario.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Putting all the pieces together.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; I reuse F1, but to toggle this time&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;f1&amp;gt; :call s:toggle_help()&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; untested&#xA;function! s:toggle_help() abort&#xA;    let nb_win = winnr('$')&#xA;    helpc&#xA;    if winnr('$') == nb_win &quot; there was no help window opened&#xA;        &quot; open the help window&#xA;        :top :help&#xA;        :exe &quot;normal \&amp;lt;c-o&amp;gt;&quot;&#xA;    &quot; else... it's already closed&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-08-28T09:20:28.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13398" PostTypeId="1" AcceptedAnswerId="13399" CreationDate="2017-08-28T13:51:53.367" Score="8" ViewCount="4052" Body="&lt;p&gt;I'm trying to find complete documentation for the possible contents of &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I've tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Google search. Plenty of examples, no docs.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;Official docs&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;man vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Searching this beta SE&lt;/li&gt;&#xA;&lt;li&gt;Searching Stackoverflow&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;a href=&quot;https://www.shortcutfoo.com/blog/top-50-vim-configuration-options/&quot; rel=&quot;noreferrer&quot;&gt;this site&lt;/a&gt; lists the &quot;top 50 vim configuration options&quot; and mentions at the end that there are 330 more but doesn't say where.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Short of grepping through the source code, is there any comprehensive documentation for what the contents of a vimrc can be/do?&lt;/p&gt;&#xA;" OwnerUserId="14048" LastEditorUserId="4472" LastEditDate="2017-08-29T04:58:02.330" LastActivityDate="2017-08-29T04:58:02.330" Title="Are there any comprehensive docs for vimrc?" Tags="|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13399" PostTypeId="2" ParentId="13398" CreationDate="2017-08-28T14:06:15.760" Score="8" Body="&lt;p&gt;The hosting site &lt;a href=&quot;http://vimdoc.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;vimdoc.sourceforge.net&lt;/a&gt; is not an official documentation and not up-to-date.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Prefer &lt;a href=&quot;https://vimhelp.appspot.com/&quot; rel=&quot;noreferrer&quot;&gt;vimhelp.appspot.com&lt;/a&gt; if you want to share doc pages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This help is available locally if you have Vim installed, and is one of the more comprehensive despite its density.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://vimhelp.appspot.com/starting.txt.html#vimrc&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h vimrc&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A file that contains initialization commands is called a &quot;vimrc&quot; file.&#xA;  Each line in a vimrc file is executed as an &lt;strong&gt;Ex command line&lt;/strong&gt;.&#xA;  It is sometimes also referred to as &quot;exrc&quot; file.&#xA;  They are the same type of file, but &quot;exrc&quot; is what Vi always used, &quot;vimrc&quot; is a Vim specific name.  Also see &lt;a href=&quot;https://vimhelp.appspot.com/usr_05.txt.html#vimrc-intro&quot; rel=&quot;noreferrer&quot;&gt;vimrc-intro&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.appspot.com/usr_05.txt.html#vimrc-intro&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h vimrc-intro&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The vimrc file can contain &lt;strong&gt;all the commands that you type after a colon&lt;/strong&gt;.&#xA;  The most simple ones are for setting options.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.appspot.com/usr_41.txt.html&quot; rel=&quot;noreferrer&quot;&gt;this page&lt;/a&gt; for more information on how to write a Vim script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should always look up what an option does before adding it to your configuration, take a look at the Vim Tip &lt;em&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Learn_to_use_help&quot; rel=&quot;noreferrer&quot;&gt;Learn to use help&lt;/a&gt;&lt;/em&gt; and &lt;a href=&quot;https://vimhelp.appspot.com/helphelp.txt.html#help&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h help&lt;/code&gt;&lt;/a&gt; for details on how to navigate and search the docs.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.appspot.com/helphelp.txt.html#%3Ahelpgrep&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :helpgrep&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.appspot.com/quickref.txt.html#option-list&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h option-list&lt;/code&gt;&lt;/a&gt; (inspired by garyjohn's answer)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2017-08-28T14:39:30.463" LastActivityDate="2017-08-28T14:39:30.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13400" PostTypeId="2" ParentId="13398" CreationDate="2017-08-28T14:32:14.173" Score="9" Body="&lt;p&gt;The contents of the vimrc file are written in the Vim scripting language, so the file could contain anything expressible in that language. It's not limited to just option settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The vimrc and its contents are explained in the Vim User Manual starting at &lt;code&gt;:help vimrc-intro&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to see a list of just option settings, execute&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:options&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-08-28T14:32:14.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13401" PostTypeId="2" ParentId="10194" CreationDate="2017-08-28T14:45:02.077" Score="7" Body="&lt;p&gt;For those who have this problem and wonder how to work around it without silencing all the errors, here is how I did it in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWritePre * try | undojoin | Neoformat | catch /^Vim\%((\a\+)\)\=:E790/ | endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Credit goes to &lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;Christian Brabandt&lt;/a&gt; and to &lt;a href=&quot;https://stackoverflow.com/a/5702498/287030&quot;&gt;this answer from Randy Morris&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14049" LastActivityDate="2017-08-28T14:45:02.077" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13402" PostTypeId="1" CreationDate="2017-08-28T19:22:03.053" Score="3" ViewCount="287" Body="&lt;p&gt;I think everyone knows that vim can't display multiline messages in quickfix (yes, I know that it can parse them and show them as one big line).&#xA;I thought about ways to workaround this and thought what if vim can wrap lines at arbitrary characters, I know it can wrap lines that are longer than number current screen. Maybe it can be done with arbitrary lines?&#xA;If it would be so I could insert some characters instead of newlines in multiline messages so that vim would break lines at this characters.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6634" LastEditDate="2017-08-28T21:26:31.213" LastActivityDate="2017-08-28T21:26:31.213" Title="Break line even if it fits the screen" Tags="|wrapping|quickfix|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13403" PostTypeId="2" ParentId="13402" CreationDate="2017-08-28T21:09:37.147" Score="1" Body="&lt;p&gt;The &lt;code&gt;linebreak&lt;/code&gt; option instructs vim to wrap at the characters specified in the &lt;code&gt;breakat&lt;/code&gt; option (by default spaces and a handful of punctuation characters).  You can choose some &quot;harmless&quot; control character.  For example, ^Y or control+Y&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wrap linebreak&#xA;exe &quot;set breakat=\&amp;lt;c-y&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will turn&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I think everyone knows that vim can't display^Ymultiline messages in quickfix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(visually) into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I think everyone knows that vim can't display^Y&#xA;multiline messages in quickfix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This introduces the problem that &lt;code&gt;&amp;lt;c-y&amp;gt;&lt;/code&gt; is visible as &lt;code&gt;^Y&lt;/code&gt;.  For this you could use vim's conceal feature.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match QFBreak /\%o31/ conceal cchar=↲&#xA;set cole=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To completely hide the character, use &lt;code&gt;set cole=3&lt;/code&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-08-28T21:09:37.147" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13404" PostTypeId="1" AcceptedAnswerId="13408" CreationDate="2017-08-28T22:14:52.930" Score="1" ViewCount="403" Body="&lt;p&gt;I usually use vim inside screen over ssh and sometimes I notice problems  with the entire line &quot;shifting over&quot; when inserting text in a vertical split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any one of these programs could be responsible for messing up redisplay, but when it does happen, it's distracting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to completely disable vertical splits in vim (even via &lt;code&gt;C-w L&lt;/code&gt; or things that open automatic splits or quickfix buffers) and make vim behave as if it weren't compiled with support for them.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-08-29T00:54:54.753" Title="completely disable vertical splits" Tags="|split|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13406" PostTypeId="2" ParentId="13273" CreationDate="2017-08-28T23:02:51.827" Score="5" Body="&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;nowait&amp;gt; ] ]]&#xA;nnoremap &amp;lt;nowait&amp;gt; [ [[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;actually &lt;em&gt;does&lt;/em&gt; work in plain text files, the problem is that many filetypes have custom &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; mappings for &lt;code&gt;[[&lt;/code&gt;/&lt;code&gt;]]&lt;/code&gt;.  In this case, a global &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; map fails because there are still &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; mappings with that prefix.  We need to make our mapping &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; as well.  However, there are problems&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We cannot use &lt;code&gt;nnoremap &amp;lt;nowait&amp;gt;&amp;lt;buffer&amp;gt; [ [[&lt;/code&gt; because this would use vim's default &lt;code&gt;[[&lt;/code&gt; not the appropriate filetype's.&lt;/li&gt;&#xA;&lt;li&gt;We cannot use &lt;code&gt;nmap &amp;lt;nowait&amp;gt;&amp;lt;buffer&amp;gt; [ [[&lt;/code&gt; because this would create a recursive mapping with itself.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A solution is to use &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; maps with &lt;code&gt;:normal&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;nowait&amp;gt; [ [[&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;nowait&amp;gt; ] ]]&#xA;&#xA;function! MakeBracketMaps()&#xA;    nnoremap &amp;lt;silent&amp;gt;&amp;lt;nowait&amp;gt;&amp;lt;buffer&amp;gt; [ :&amp;lt;c-u&amp;gt;exe 'normal '.v:count.'[['&amp;lt;cr&amp;gt;&#xA;    nnoremap &amp;lt;silent&amp;gt;&amp;lt;nowait&amp;gt;&amp;lt;buffer&amp;gt; ] :&amp;lt;c-u&amp;gt;exe 'normal '.v:count.']]'&amp;lt;cr&amp;gt;&#xA;endfunction&#xA;&#xA;augroup bracketmaps&#xA;    autocmd!&#xA;    autocmd FileType * call MakeBracketMaps()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that many filetype's &lt;code&gt;[[&lt;/code&gt;/&lt;code&gt;]]&lt;/code&gt; implementations don't take a count.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-08-28T23:02:51.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13408" PostTypeId="2" ParentId="13404" CreationDate="2017-08-29T00:54:54.753" Score="5" Body="&lt;p&gt;The feature which controls whether vim supports vertical splits is called &lt;code&gt;+vertsplit&lt;/code&gt; and it is not possible to disable it alone at compile time. &#xA; Specifically, since patch 7.4.1611, vim always supports vertical splits when feature &lt;code&gt;+windows&lt;/code&gt; is enabled (&lt;code&gt;FEAT_WINDOWS&lt;/code&gt;).  The &lt;code&gt;FEAT_VERTSPLIT&lt;/code&gt; preprocessor definition has been completely removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally, &lt;code&gt;:help feature-list&lt;/code&gt; claims that &lt;code&gt;+vertsplit&lt;/code&gt; is enabled only in the &quot;normal&quot; build and up, but this is wrong since &lt;code&gt;+windows&lt;/code&gt; is enabled in the &quot;small&quot; build.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-08-29T00:54:54.753" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13409" PostTypeId="1" CreationDate="2017-08-29T04:03:51.273" Score="1" ViewCount="708" Body="&lt;p&gt;I generally use vim + cscope on Linux, and it works great. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have recently started using Cygwin on Windows 7, and I have been trying to replicate my development environment, with gvim and cscope. My initial attempt has been with Cygwin64, gvim7.4 (windows version), cscope 15.8a (64 bit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have noticed that even though gvim and cscope seem to work fine independently in my Cygwin environment, I seem to have problems with the integration, specifically with loading the cscope database in gvim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following is the error I observe:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing C:\Vim\vimfiles\plugin\cscope_maps.vim:&#xA;line   42:&#xA;E609: Cscope error:       1 [main] cscope 15920 child_copy: cygheap read &#xA;copy failed, 0x180304408..0x1803126E8, done 0, windows pid 15920, Win32 &#xA;error 6    432 [main] cscope 15920 C:\cygwin64\usr\local\bin\cscope.exe: &#xA;*** fatal error - ccalloc would have returned NULL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where line 42 refers to this line in the cscope_maps.vim plugin: &quot;cs add cscope.out&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This error is not seen if I do not have a cscope database in the directory.)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Size of the database does not seem to matter, it fails to load even a tiny database.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, I have tried the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Instead of using cscope from Cygwin, download, compile and install from the latest cscope source (version 15.8b) for 64 bit Cygwin &lt;/li&gt;&#xA;&lt;li&gt;Uninstall older gvim 7.4 and install the latest gvim 8.0&lt;/li&gt;&#xA;&lt;li&gt;Gvim was initially installed in C:\Program Files (x86)\Vim. Since I read that the spaces in path names could be an issue, uninstalled and reinstalled gvim in C:\Vim&lt;/li&gt;&#xA;&lt;li&gt;As I noticed that gvim is a 32 bit executable while cscope was 64 bit, uninstalled cscope and installed the 32 bit version, and attempted to run everything from the 32 bit Cygwin environment&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The last one gave me a similar error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing C:\Vim\vimfiles\plugin\cscope_maps.vim:&#xA;line   42:&#xA;E609: Cscope error:       1 [main] cscope 6276 child_copy: cygheap read copy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Appreciate any insights.&lt;/p&gt;&#xA;" OwnerUserId="14058" LastEditorUserId="14058" LastEditDate="2017-08-29T07:16:06.223" LastActivityDate="2017-08-29T07:16:06.223" Title="cscope database loading issue with gvim" Tags="|gvim|cscope|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13410" PostTypeId="1" AcceptedAnswerId="13411" CreationDate="2017-08-29T17:01:01.520" Score="5" ViewCount="778" Body="&lt;p&gt;I'm not expert in vim at all but I like it a lot.&lt;/p&gt;&#xA;&lt;p&gt;In my personal computer I've loaded the example_vimrc in my &lt;code&gt;.vimrc&lt;/code&gt; and added some extra lines so when I type a bullet point and keep typing till 80 characters, vim automatically wraps my line an continues below like this&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;* This is an example line, just guess that the line break is at 80&#xA;  characters and when I keep typing vim do this great thing of&#xA;  indenting my lines like this.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In my job computer, I have the SAME .vimrc file but I managed to note that the condition '&lt;code&gt;if has (&amp;quot;autocmd&amp;quot;)&lt;/code&gt;' is not true and I don't know what happens (because I'm newbie) but when I type the kind of text like above I get the following&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;* This is an example of a line representing what happens in my job&#xA;* I'm not really pressing ENTER, and obviously I'm not typing a &#xA;* bullet like '*' with each new line because this is the same note &#xA;* but vim automatically adds a new '*' with each line wrap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How can I get rid of this behavior?? I already read a related post and tried to use the option 'set comments=' but I get the following behavior&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;* This is a line after setting 'set comments=' which removes the '*'&#xA;I think, but after line wrapping the indentation doesn't work and&#xA;the text keeps appearing like this, although if I manually add blank&#xA;  spaces like in THIS LINE and I keep typing then when vim wraps the&#xA;  line, automatically aligns the text like this, I hope it can give &#xA;  you a clue of what is happening.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Thanks in advance for your help!, remember my .vimrc is the example_vimrc&lt;/p&gt;&#xA;" OwnerUserId="13771" LastEditorUserId="13771" LastEditDate="2020-09-01T19:40:43.370" LastActivityDate="2020-09-01T19:40:43.370" Title="Avoid vim to add bullet point when wrapping lines" Tags="|vimrc|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13411" PostTypeId="2" ParentId="13410" CreationDate="2017-08-29T17:53:12.063" Score="4" Body="&lt;p&gt;Check out &lt;a href=&quot;http://vim.wikia.com/wiki/Disable_automatic_comment_insertion&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Disable automatic comment insertion&lt;/em&gt;&lt;/a&gt;, you probably want to add this in your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatoptions-=cro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#fo-table&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h fo-table&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;You can use the 'formatoptions' option  to influence how Vim formats text.&#xA;'formatoptions' is a string that can contain any of the letters below. The&#xA;default setting is &quot;tcq&quot;. You can separate the option letters with commas for&#xA;readability.&#xA;&#xA;letter   meaning when present in 'formatoptions'&#xA;&#xA;t        Auto-wrap text using textwidth&#xA;c        Auto-wrap comments using textwidth, inserting the current comment&#xA;         leader automatically.&#xA;r        Automatically insert the current comment leader after hitting&#xA;         &amp;lt;Enter&amp;gt; in Insert mode.&#xA;o        Automatically insert the current comment leader after hitting 'o' or&#xA;         'O' in Normal mode.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Looks like you were on the right track, I should have dug in the &lt;code&gt;:set comments?&lt;/code&gt; direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default value is &lt;code&gt;s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:&amp;gt;,fb:-&lt;/code&gt; (and for the record you replaced &lt;code&gt;mb:*&lt;/code&gt; with &lt;code&gt;fb:*&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#format-comments&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h format-comments&lt;/code&gt;&lt;/a&gt; for more details:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The 'comments' option is a comma-separated list of parts. Each part defines a&#xA;type of comment string. A part consists of:&#xA;        {flags}:{string}&#xA;&#xA;{string} is the literal text that must appear.&#xA;&#xA;{flags}:&#xA;&#xA;  m     Middle of a three-piece comment&#xA;&#xA;  f     Only the first line has the comment string.  Do not repeat comment on&#xA;        the next line, but preserve indentation (e.g., a bullet-list).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2017-08-29T18:54:11.457" LastActivityDate="2017-08-29T18:54:11.457" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13413" PostTypeId="2" ParentId="12843" CreationDate="2017-08-30T02:43:51.453" Score="1" Body="&lt;p&gt;If you do the same thing via visual mode: &lt;code&gt;v3bd&lt;/code&gt;, then &lt;code&gt;u&lt;/code&gt;, you can jump back to where you started by using the mark &lt;code&gt;`&amp;gt;&lt;/code&gt; (that's backtick).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look up &lt;code&gt;:h marks&lt;/code&gt; to learn more; &lt;code&gt;&amp;gt;&lt;/code&gt; corresponds to the end of visual selection, backtick means you want specific position, and not the beginning of line.&lt;/p&gt;&#xA;" OwnerUserId="14072" LastEditorUserId="2736" LastEditDate="2017-08-30T16:23:16.833" LastActivityDate="2017-08-30T16:23:16.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13415" PostTypeId="2" ParentId="12843" CreationDate="2017-08-30T10:12:20.167" Score="4" Body="&lt;p&gt;You're slightly misunderstanding what Vim is doing here. When you do &lt;code&gt;d4b&lt;/code&gt;, there is only a &lt;em&gt;single&lt;/em&gt; action, which deletes from the current position to the position where &lt;code&gt;4b&lt;/code&gt; would jump to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behaviour that you see when you undo with &lt;code&gt;u&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; that Vim is undoing the &lt;code&gt;d&lt;/code&gt; but leaving the &lt;code&gt;4b&lt;/code&gt; motion intact. What's actually happening is that when Vim performs an undo, it places the cursor at the &lt;em&gt;beginning&lt;/em&gt; of the change that is undone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If you do &lt;code&gt;d4wu&lt;/code&gt;, you will see that the cursor stays the same location throughout: it does not end up at the end of the motion, as your interpretation would suggest.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're writing a script/function &lt;a href=&quot;http://vim.wikia.com/wiki/Restore_the_cursor_position_after_undoing_text_change_made_by_a_script&quot; rel=&quot;nofollow noreferrer&quot;&gt;there are workarounds you can use to move the cursor back to its location prior to the undo&lt;/a&gt;, but unfortunately, there's no general command that can always do this: it requires you to know &lt;em&gt;before&lt;/em&gt; you make the edit that you're going to want the cursor position restored after an undo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless you are lucky and find that the location happens to already be saved in an automatic mark as the result of another action (see &lt;code&gt;:help mark-motions&lt;/code&gt;), I'm afraid it's not possible to restore the location of the cursor in the way you desire.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-08-31T08:35:12.067" LastActivityDate="2017-08-31T08:35:12.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13417" PostTypeId="1" CreationDate="2017-08-30T11:17:46.743" Score="2" ViewCount="679" Body="&lt;p&gt;In Swedish, you make compound words by just adding words together right after each other without a space in between as in English. You can make almost any combination, e.g. &quot;staff matters&quot; is &quot;personal&quot; (staff) and &quot;ärenden&quot; (matters) added together like &quot;personalärenden&quot;. The vim spell check marks compound words like this as wrong. How can I make vim recognize words as correct if they consist of several correct words?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I researched it a bit more. Whether or not a word can be part of a compound word or not is decided in the dictionary files (the &lt;code&gt;.dic&lt;/code&gt; and &lt;code&gt;.aff&lt;/code&gt;) with some kind of flags. The &lt;code&gt;.spl&lt;/code&gt; file that vim downloaded for Swedish apparently wasn't based on &lt;code&gt;.dic&lt;/code&gt; and &lt;code&gt;.aff&lt;/code&gt; files with these flags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LibreOffice has no problem with the compound words so I tried downloading the &lt;a href=&quot;https://extensions.libreoffice.org/extensions/swedish-spelling-dictionary-den-stora-svenska-ordlistan&quot; rel=&quot;nofollow noreferrer&quot;&gt;Swedish dictionary&lt;/a&gt; from their extensions website. I then created a &lt;code&gt;.spl&lt;/code&gt; file that vim can use with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:mkspell sv sv_SE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and put the resulting &lt;code&gt;sv.utf-8.spl&lt;/code&gt; in &lt;code&gt;~/.vim/spell&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though LibreOffice and vim now use the same dictionary, vim marks words as wrong even when LibreOffice accepts them.&lt;/p&gt;&#xA;" OwnerUserId="13769" LastEditorUserId="13769" LastEditDate="2017-08-30T19:27:06.137" LastActivityDate="2017-08-30T19:27:06.137" Title="Make spell check recognize Swedish compound words" Tags="|spell-checking|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13418" PostTypeId="1" AcceptedAnswerId="13420" CreationDate="2017-08-30T12:20:18.330" Score="2" ViewCount="859" Body="&lt;p&gt;I have the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set listchars=eol:↵,tab:▸-,trail:¤,nbsp:¤&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;.vimrc&lt;/code&gt; which I use on different machines. If the &lt;code&gt;LC_CTYPE&lt;/code&gt; is not set to an UTF-8 map, I get the message&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E474: Invalid argument: listchars=eol:�~F�,tab:�~V�-,trail:¤,nbsp:¤&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I detect if Vim supports UTF-8? I want to do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('utf8')&#xA;    listchars=eol:↵,tab:▸-,trail:¤,nbsp:¤&#xA;else&#xA;    listchars=...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14081" LastEditorUserId="1841" LastEditDate="2017-08-30T12:25:31.320" LastActivityDate="2017-08-30T13:09:57.770" Title="Detect if Vim can show utf8 characters" Tags="|vimrc|unicode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13419" PostTypeId="2" ParentId="13207" CreationDate="2017-08-30T12:27:01.727" Score="4" Body="&lt;p&gt;Depending on the environment that you are in there might be possibilites.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I write markdown with pandoc or pure LaTex then I put a backslash before the succeeding space of an abbreviation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i.e.\ without&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will not mark &lt;code&gt;without&lt;/code&gt; as missspelled and &lt;code&gt;pandoc&lt;/code&gt; or &lt;code&gt;latex&lt;/code&gt; will produce a correct space between &lt;code&gt;i.e.&lt;/code&gt; and &lt;code&gt;without&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10393" LastActivityDate="2017-08-30T12:27:01.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13420" PostTypeId="2" ParentId="13418" CreationDate="2017-08-30T13:09:57.770" Score="3" Body="&lt;p&gt;You can test the 'encoding' option. For example I have &lt;a href=&quot;https://github.com/chrisbra/vim_dotfiles/blob/master/vimrc#L268-L283&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; in my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;encoding == &quot;utf-8&quot;&#xA;    if !exists(&quot;$PUTTY_TERM&quot;) &amp;amp;&amp;amp; $OS isnot# &quot;Windows_NT&quot;&#xA;        exe &quot;set listchars=nbsp:\u2423,conceal:\u22ef,tab:\u2595\u2014,trail:\u02d1,precedes:\u2026,extends:\u2026,eol:\ub6&quot;&#xA;        exe &quot;set sbr=\u21b3&quot;&#xA;    else&#xA;        &quot; Putty can't display all nice utf-8 chars&#xA;        exe &quot;set listchars=conceal:\u00b7,tab:&amp;gt;\u2014,trail:\u02d1,precedes:\u2026,extends:\u2026,eol:\ub6,nbsp:\u03c7&quot;&#xA;        exe &quot;set sbr=\u2500&quot;&#xA;    endif&#xA;    exe &quot;set fillchars=vert:\u2502,fold:\u2500,diff:\u2014&quot;&#xA;else&#xA;    &quot; Special characters that will be shown, when set list is on&#xA;    set listchars=eol:$,trail:-,tab:&amp;gt;-,extends:&amp;gt;,precedes:&amp;lt;,conceal:+&#xA;    &quot; Display a `+' for wrapped lines&#xA;    set sbr=+&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note also, you shouldn't change the encoding option, once it has been set, because it will invalidate all character data stored in memory in Vim.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-08-30T13:09:57.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13421" PostTypeId="1" CreationDate="2017-08-30T14:34:58.340" Score="1" ViewCount="102" Body="&lt;p&gt;Is there a way to copy a few times a given block from command-line mode, e.g. with the &lt;code&gt;:t&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, how to copy the two lines (block) above the cursor &lt;code&gt;-2,-1&lt;/code&gt; to the current position &lt;code&gt;.&lt;/code&gt;, 3 times with one command instead of three:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;: -2,-1t.&#xA;: -2,-1t.&#xA;: -2,-1t.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9633" LastEditorUserId="343" LastEditDate="2017-12-06T11:19:03.520" LastActivityDate="2017-12-06T11:19:03.520" Title="Is it possible to copy block (given by range) multiple times in a single command?" Tags="|command-line|ex-command|range|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13422" PostTypeId="2" ParentId="2162" CreationDate="2017-08-30T15:17:59.820" Score="0" Body="&lt;p&gt;If &lt;code&gt;set backspace=indent,eol,start&lt;/code&gt; is the last line of your &lt;code&gt;vimrc&lt;/code&gt;, none of solutions will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add one more rule after this, eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ruler&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14085" LastEditorUserId="1841" LastEditDate="2017-08-30T16:18:40.807" LastActivityDate="2017-08-30T16:18:40.807" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13425" PostTypeId="1" AcceptedAnswerId="13427" CreationDate="2017-08-30T19:37:51.070" Score="2" ViewCount="1330" Body="&lt;p&gt;Is it possible to configure vim to store commands in your command history without abbreviations expanded?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance I have the following command (to make it easy to switch back and forth between header and source files)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev &amp;lt;expr&amp;gt; cv 'edit %:r.cpp'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I type &lt;code&gt;:cv&amp;lt;cr&amp;gt;&lt;/code&gt; and then type &lt;code&gt;up&lt;/code&gt; I see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit %:r.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the command window rather than&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to configure the command history (either globally or on a per-abbreviation basis) to not be stored in expanded form.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-12-06T07:14:45.680" Title="cnoreabbrev do not expand abbreviations in command history" Tags="|command-line|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13427" PostTypeId="2" ParentId="13425" CreationDate="2017-08-31T00:07:16.783" Score="3" Body="&lt;p&gt;I don't know how reliable it is, but I came up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:cnorea(lhs, rhs) abort&#xA;    let s:counter = get(s:, 'counter', 0) + 1&#xA;    fu! s:cnorea_{s:counter}() abort closure&#xA;        call timer_start(0, {&#xA;                          \  -&amp;gt; execute('if histget(&quot;:&quot;, -1) ==# '.string(a:rhs)&#xA;                          \ .'|              call histdel(&quot;:&quot;, -1)&#xA;                          \   |          endif&#xA;                          \   |          call histadd(&quot;:&quot;, '.string(a:lhs).')')&#xA;                          \ })&#xA;        return a:rhs&#xA;    endfu&#xA;&#xA;    exe printf('cnorea &amp;lt;expr&amp;gt; %s&#xA;             \                   getcmdtype() ==# &quot;:&quot; &amp;amp;&amp;amp; getcmdpos() ==# %d&#xA;             \                   ?    &amp;lt;sid&amp;gt;cnorea_%d()&#xA;             \                   :    %s'&#xA;             \ , a:lhs, strlen(a:lhs)+1, s:counter, string(a:lhs))&#xA;endfu&#xA;&#xA;call s:cnorea('cv', 'e %:r.cpp')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to work as you want: it expands &lt;code&gt;cv&lt;/code&gt; into &lt;code&gt;e %:r.cpp&lt;/code&gt;, and logs &lt;code&gt;cv&lt;/code&gt; in the command-line history. However, it relies on a timer, so if you want to test it, you first need to check that &lt;code&gt;:echo has('timers')&lt;/code&gt; returns &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could define as many similar abbreviations as you want, by invoking &lt;code&gt;s:cnorea()&lt;/code&gt;, passing to it the &lt;code&gt;{lhs}&lt;/code&gt; and &lt;code&gt;{rhs}&lt;/code&gt; of your abbreviations. Examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call s:cnorea('abcd', 'echo &quot;hello&quot;')&#xA;call s:cnorea('xyz', 'echo &quot;world&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It works like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call s:cnorea('cv', 'e %:r.cpp')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Invokes &lt;code&gt;s:cnorea()&lt;/code&gt;, passing the strings &lt;code&gt;'cv'&lt;/code&gt; and &lt;code&gt;'e %:r.cpp'&lt;/code&gt; as arguments. The latter does 2 things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;define the function &lt;code&gt;s:cnorea_1()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;define the abbreviation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;cnorea &amp;lt;expr&amp;gt; cv getcmdtype() ==# &quot;:&quot; &amp;amp;&amp;amp; getcmdpos() ==# 3 ? &amp;lt;SID&amp;gt;cnorea_1('cv', 'e %:r.cpp') : 'cv'&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Like your original abbreviation, this one uses an expression as its &lt;code&gt;{rhs}&lt;/code&gt;. The expression tests whether you're on a regular Ex command line (&lt;code&gt;getcmdtype() ==# ':'&lt;/code&gt;), and whether you've typed &lt;code&gt;cv&lt;/code&gt; at the beginning of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If any of these 2 conditions isn't satisfied, the expression returns &lt;code&gt;cv&lt;/code&gt;, which negates the expansion. Otherwise, it's expanded into the output of another function &lt;code&gt;s:cnorea_1()&lt;/code&gt;, which is defined like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:cnorea_1() abort closure&#xA;    call timer_start(0, {&#xA;                      \  -&amp;gt; execute('if histget(&quot;:&quot;, -1) ==# '.string(a:rhs)&#xA;                      \ .'|              call histdel(&quot;:&quot;, -1)&#xA;                      \   |          endif&#xA;                      \   |          call histadd(&quot;:&quot;, '.string(a:lhs).')')&#xA;                      \ })&#xA;    return a:rhs&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It returns your the expansion of your abbreviation, but before that, it calls a timer which in turn will call &lt;code&gt;histdel()&lt;/code&gt; to delete &lt;code&gt;:e %:r.cpp&lt;/code&gt; from the history, and &lt;code&gt;histadd()&lt;/code&gt; to add &lt;code&gt;cv&lt;/code&gt; in the history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A timer allows you to defer the execution of a function or a funcref. From the perspective of the timer, the latter is called a callback. Here, the timer doesn't call a function, but a lambda expression, which is a special kind of funcref (see &lt;code&gt;:h Funcref&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The syntax of a lambda expression is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ args -&amp;gt; expr }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo { x,y -&amp;gt; x+y }(1,2)&#xA;   3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It returns &lt;code&gt;3&lt;/code&gt;, because &lt;code&gt;3&lt;/code&gt; is the image of &lt;code&gt;(1,2)&lt;/code&gt; under the function &lt;code&gt;f: x,y -&amp;gt; x+y&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The lambda expression used in the timer is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  {&#xA;\  -&amp;gt; execute('if histget(&quot;:&quot;, -1) ==# '.string(a:rhs)&#xA;\ .'|              call histdel(&quot;:&quot;, -1)&#xA;\   |          endif&#xA;\   |          call histadd(&quot;:&quot;, '.string(a:lhs).')')&#xA;\ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The purpose of this lambda expression/callback is to execute some Ex commands. But Ex commands are not expressions, so you can't write them directly. You have to wrap them inside the function &lt;code&gt;execute()&lt;/code&gt;, which, as any function, is an expression. It takes as argument an Ex command (or a sequence of Ex commands separated by bars) and returns its output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't need any argument, so there's nothing before the arrow &lt;code&gt;-&amp;gt;&lt;/code&gt;. It's just a routine which will execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if histget(&quot;:&quot;, -1) ==# 'e %:r.cpp'&#xA;    call histdel(&quot;:&quot;, -1)&#xA;endif&#xA;call histadd(&quot;:&quot;, 'cv')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This checks whether the last entry in the command-line history is &lt;code&gt;e %:r.cpp&lt;/code&gt; (it should be, it's just a precaution), removes it if this is the case, then adds &lt;code&gt;cv&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To summarize, when you execute &lt;code&gt;:cv&lt;/code&gt; at the beginning of the command-line, it should be expanded into &lt;code&gt;:e %r.cpp&lt;/code&gt;, but in the process, a timer is called to replace &lt;code&gt;:e %:r.cpp&lt;/code&gt; with &lt;code&gt;:cv&lt;/code&gt; in the history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my machine, although the callback is invoked after &lt;code&gt;0&lt;/code&gt; ms, it's not instantaneous. Therefore, if you execute &lt;code&gt;:cv&lt;/code&gt;, Vim should expand it into &lt;code&gt;:e %:r.cpp&lt;/code&gt;, then replace it in the history. If on your machine, the callback is instantaneous, you should increase its waiting time, by replacing the 1st argument passed to &lt;code&gt;timer_start()&lt;/code&gt; with another arbitrary value (as an example, with &lt;code&gt;1&lt;/code&gt;, for &lt;code&gt;1&lt;/code&gt;ms).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it's not completely reliable, because if you expand your abbreviation, without executing it immediately:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cv&#xA;    hit &amp;lt;space&amp;gt; to expand `cv`&#xA;:e %:r.cpp &#xA;    during a few seconds, edit the command-line, maybe to add another command&#xA;    hit &amp;lt;Enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... then the timer will be called too soon, and in your history, you'll get both entries:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cv&#xA;:e %:r.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, you could increase the waiting time (&lt;code&gt;1000&lt;/code&gt; ms, &lt;code&gt;5000&lt;/code&gt; ms, ...), but it's a hack.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A few other notes to better explain the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The counter is needed to make the functions used by every abbreviation unique:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:counter = get(s:, 'counter', 0) + 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's evaluated inside the function name, through an element of syntax called &lt;code&gt;curly braces name&lt;/code&gt; (see &lt;code&gt;:h curly-braces-names&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:cnorea_{s:counter}() abort closure&#xA;&quot;            └─────────┤&#xA;&quot;                      └ curly braces names&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means that the 1st time you call &lt;code&gt;s:cnorea()&lt;/code&gt;, it will define the function &lt;code&gt;s:cnorea_1()&lt;/code&gt; for your 1st abbreviation. The 2nd time, it will define the function &lt;code&gt;s:cnorea_2()&lt;/code&gt; for your 2nd abbreviation, and so on.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You don't need to pass the arguments from &lt;code&gt;s:cnorea()&lt;/code&gt; to &lt;code&gt;s:cnorea_1()&lt;/code&gt;, because of the &lt;code&gt;closure&lt;/code&gt; attribute (see &lt;code&gt;:h closure&lt;/code&gt;). Thanks to this, inside &lt;code&gt;s:cnorea_1()&lt;/code&gt;, you can refer to variables which were defined in the scope of the outer function (&lt;code&gt;s:cnorea()&lt;/code&gt;). So, even though &lt;code&gt;a:lhs&lt;/code&gt; and &lt;code&gt;a:rhs&lt;/code&gt; are in the scope of the arguments of &lt;code&gt;s:cnorea()&lt;/code&gt;, &lt;code&gt;s:cnorea_1()&lt;/code&gt; can still access them.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The abbreviation is installed by executing the output of a &lt;code&gt;printf()&lt;/code&gt; invocation. You don't need it, you could install it without &lt;code&gt;printf()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, &lt;code&gt;printf()&lt;/code&gt; allows you to separate the code from the expressions it contains. Compare:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe ' cnorea &amp;lt;expr&amp;gt; '.a:lhs&#xA;  \.'                       getcmdtype() ==# &quot;:&quot; &amp;amp;&amp;amp; getcmdpos() ==# '.(strlen(a:lhs)+1)&#xA;  \.'                       ?    &amp;lt;sid&amp;gt;cnorea_'.s:counter.'()'&#xA;  \.'                       :    '.string(a:lhs)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe printf('cnorea &amp;lt;expr&amp;gt; %s&#xA;         \                   getcmdtype() ==# &quot;:&quot; &amp;amp;&amp;amp; getcmdpos() ==# %d&#xA;         \                   ?    &amp;lt;sid&amp;gt;cnorea_%d()&#xA;         \                   :    %s'&#xA;         \ , a:lhs, strlen(a:lhs)+1, s:counter, string(a:lhs))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use whichever version you find more readable (if any).&lt;/p&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-09-01T13:56:46.807" LastActivityDate="2017-09-01T13:56:46.807" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13429" PostTypeId="1" AcceptedAnswerId="13457" CreationDate="2017-08-31T10:26:31.760" Score="1" ViewCount="147" Body="&lt;p&gt;Related to but not duplicate¹ of &lt;a href=&quot;https://vi.stackexchange.com/questions/10460/bundling-command-sequences-together-for-repeat&quot;&gt;Bundling command sequences together for repeat (.)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point (&lt;code&gt;.&lt;/code&gt;) command is really useful to redo the last action (insertion, replacement, etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes I find myself making a small mistake that prevent me from repeating the action (because the mistake would be repeated).&#xA;Is it possible to fix that mistake so that the fix is not considered to be the last action but instead added to the previous last action ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, when editing the block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;triangles[0] = ...&#xA;triangles[1] = ...&#xA;triangles[2] = ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To replace &lt;em&gt;triangles&lt;/em&gt; by &lt;em&gt;polygons&lt;/em&gt; without the :s command:&#xA;I go to the first &lt;em&gt;t&lt;/em&gt;, then hit &lt;code&gt;c&lt;/code&gt; then type &lt;em&gt;polygon&lt;/em&gt; (mistake: no &lt;em&gt;s&lt;/em&gt;) then &lt;code&gt;esc&lt;/code&gt;. Then I realize my mistake: I have to go back to the &lt;em&gt;p&lt;/em&gt; then change to &lt;em&gt;polygons&lt;/em&gt;. Instead of doing that I would like to just press a key to amend the last action, then &lt;code&gt;i&lt;/code&gt; then &lt;code&gt;s&lt;/code&gt;. Finally I would use the &lt;code&gt;.&lt;/code&gt; key to repeat on the two last &lt;em&gt;t&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;¹ That question asks to repeat the last N commands/action instead of just the last one while I would like not to create a new command/action but modify the previous one.&lt;/p&gt;&#xA;" OwnerUserId="8409" LastActivityDate="2017-09-02T05:13:32.773" Title="Vim - edit last action before using (.)" Tags="|key-bindings|repeated-commands|undo-redo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13430" PostTypeId="1" AcceptedAnswerId="13431" CreationDate="2017-08-31T12:34:57.507" Score="1" ViewCount="509" Body="&lt;p&gt;I want to map the &lt;code&gt;tab&lt;/code&gt; key to &lt;code&gt;&amp;lt;c-w&amp;gt;w&lt;/code&gt; to switch windows when there is more than one window open. But if there is only one window but multiple tabs, I want it to detect that there is only one window and to switch tabs instead by mapping to &lt;code&gt;gt&lt;/code&gt;. Note both commands are in the same mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? I am asking this one key to map to two different choices and the key only performs the second choice when the first one fails.&lt;/p&gt;&#xA;" OwnerUserId="14019" LastActivityDate="2017-08-31T18:32:45.437" Title="Is it possible to map one key to two commands, doing 2nd command only if first fails" Tags="|vim-windows|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13431" PostTypeId="2" ParentId="13430" CreationDate="2017-08-31T13:01:56.813" Score="2" Body="&lt;p&gt;You can do it using an &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#:map-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;expression-mapping&lt;/a&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt;&amp;lt;silent&amp;gt; &amp;lt;tab&amp;gt; winnr('$')&amp;gt;1 ? &quot;\&amp;lt;c-w&amp;gt;w&quot; : 'gt'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this makes the mapping basically check, if there are several windows open (&lt;code&gt;winnr('$')&lt;/code&gt; is greater than 1) and in that case returns &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;W&lt;/kbd&gt; else, it returns &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: the double quotation marks are necessary, to make Vim correctly parse the key code &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case there exists only one tabpage, you need to add 2 checks, something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt;&amp;lt;silent&amp;gt; &amp;lt;tab&amp;gt; winnr('$')&amp;gt;1 ? &quot;\&amp;lt;c-w&amp;gt;w&quot; : (tabpagenr('$')&amp;gt;1 ? 'gt' : &quot;:bn\&amp;lt;cr&amp;gt;&quot;)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2017-08-31T18:32:45.437" LastActivityDate="2017-08-31T18:32:45.437" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13432" PostTypeId="1" AcceptedAnswerId="13436" CreationDate="2017-08-31T13:23:42.307" Score="0" ViewCount="1368" Body="&lt;p&gt;When running gvim on my RedHat:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;Linux trex-06 3.10.0-514.el7.x86_64 #1 SMP Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&#xA;NAME=&quot;Red Hat Enterprise Linux Server&quot;&#xA;VERSION=&quot;7.3 (Maipo)&quot;&#xA;ID=&quot;rhel&quot;&#xA;ID_LIKE=&quot;fedora&quot;&#xA;VERSION_ID=&quot;7.3&quot;&#xA;PRETTY_NAME=&quot;Red Hat Enterprise Linux Server 7.3 (Maipo)&quot;&#xA;ANSI_COLOR=&quot;0;31&quot;&#xA;CPE_NAME=&quot;cpe:/o:redhat:enterprise_linux:7.3:GA:server&quot;&#xA;HOME_URL=&quot;https://www.redhat.com/&quot;&#xA;BUG_REPORT_URL=&quot;https://bugzilla.redhat.com/&quot;&#xA;REDHAT_BUGZILLA_PRODUCT=&quot;Red Hat Enterprise Linux 7&quot;&#xA;REDHAT_BUGZILLA_PRODUCT_VERSION=7.3&#xA;REDHAT_SUPPORT_PRODUCT=&quot;Red Hat Enterprise Linux&quot;&#xA;REDHAT_SUPPORT_PRODUCT_VERSION=&quot;7.3&quot;&#xA;Red Hat Enterprise Linux Server release 7.3 (Maipo)&#xA;Red Hat Enterprise Linux Server release 7.3 (Maipo)&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The spacing between letters is too wide which looks really bad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PgoBM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PgoBM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried changing font (:set guifont=*) to monospace, and it stays exactly the same. Same goes for other fonts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how to fix it?&lt;/p&gt;&#xA;" OwnerUserId="11475" LastActivityDate="2017-08-31T14:43:25.067" Title="gvim looks terrible on my RedHat. Unable to change font" Tags="|gvim|linux|font|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13433" PostTypeId="1" AcceptedAnswerId="13435" CreationDate="2017-08-31T13:49:48.993" Score="11" ViewCount="2571" Body="&lt;p&gt;Using &lt;code&gt;git&lt;/code&gt; how can I load the list of files in the current commit into Quickfix window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code Review didn't pass and I want to just fix them one by one.&lt;/p&gt;&#xA;" OwnerUserId="237" LastActivityDate="2022-02-12T08:12:42.310" Title="How to load list of files in commit into quickfix" Tags="|quickfix|git|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13434" PostTypeId="2" ParentId="13433" CreationDate="2017-08-31T13:53:35.230" Score="3" Body="&lt;p&gt;The only thing that comes to mind is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git reset --soft head~1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That would &quot;uncommit&quot; the files, and then browse them in Preview window using &lt;code&gt;vim-fugitive&lt;/code&gt; &lt;code&gt;:Gtatus&lt;/code&gt; command. Not exactly Quickfix, but it's readable, stores your position and you can stage/unstage from there.&lt;/p&gt;&#xA;" OwnerUserId="237" LastEditorUserId="237" LastEditDate="2017-08-31T14:01:19.610" LastActivityDate="2017-08-31T14:01:19.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13435" PostTypeId="2" ParentId="13433" CreationDate="2017-08-31T14:32:08.483" Score="7" Body="&lt;p&gt;You could use the following function which has the advantage of not changing the state of your local git repo:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CommitQF(...)&#xA;    &quot; Get the commit hash if it was specified&#xA;    let commit = a:0 == 0 ? '' : a:1&#xA;&#xA;    &quot; Get the result of git show in a list&#xA;    let flist = system('git show --name-only ' . commit . ' | tail -n +7')&#xA;    let flist = split(flist, '\n')&#xA;&#xA;    &quot; Create the dictionnaries used to populate the quickfix list&#xA;    let list = []&#xA;    for f in flist&#xA;        let dic = {'filename': f, &quot;lnum&quot;: 1}&#xA;        call add(list, dic)&#xA;    endfor&#xA;&#xA;    &quot; Populate the qf list&#xA;    call setqflist(list)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can call it without argument or with a commit hash as argument (if no argument is specified, the last commit will be used):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call CommitQF(&quot;cc5b6a976fde8c9ee66387c91765feb202ba0124&quot;)&#xA;call CommitQF()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will use the &lt;code&gt;git show&lt;/code&gt; command with the &lt;code&gt;--name-only&lt;/code&gt; argument to get the name of the files in the commit. The &lt;code&gt;tail -n +7&lt;/code&gt; command removes the lines which are not a file name in the output of &lt;code&gt;git show&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then it will create a list of dictionnaries used to populate the quickfix list (see &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#setqflist%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h setqflist()&lt;/code&gt;&lt;/a&gt; for more details about that).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to use &lt;code&gt;:copen&lt;/code&gt; to open the quicklist after calling the function (or you can add it to the function)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; Another possible approach (&lt;em&gt;and probably a better one&lt;/em&gt;) using only built in features would be to use these settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set makeprg=git\ show\ --name-only\ $*\ \\\|\ tail\ -n\ +7&#xA;set efm+=%f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you can use &lt;code&gt;:make&lt;/code&gt; (for the current commit) or &lt;code&gt;:make fff93a09&lt;/code&gt; (to specify a commit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quickfix window will then contain the list of files and you'll be able to navigate to them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Of course you might want to create a mapping of something to switch between your usual &lt;code&gt;makeprg&lt;/code&gt; and this one)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can have a look at these help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#errorformat&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h errorformat&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27makeprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'makeprg'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Second edit&lt;/strong&gt; @PeterRincker and @LucHermitte made some really nice suggestions in the comments, many thanks to them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use the following one liner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=? -bar Gshow call setqflist(map(systemlist(&quot;git show --pretty='' --name-only &amp;lt;args&amp;gt;&quot;), '{&quot;filename&quot;: v:val, &quot;lnum&quot;: 1}'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To create a command &lt;code&gt;:Gshow&lt;/code&gt; which takes a commit hash as an optionnal argument and populate the quickfix list.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-09-01T07:38:51.103" LastActivityDate="2017-09-01T07:38:51.103" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13436" PostTypeId="2" ParentId="13432" CreationDate="2017-08-31T14:43:25.067" Score="2" Body="&lt;p&gt;As it turns out the fonts that &lt;pre&gt;:set guifont=*&lt;/pre&gt; show are not installed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;No idea why gvim decides to show them. Might be a bug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the suggestion &lt;a href=&quot;https://vi.stackexchange.com/q/9616/51&quot;&gt;here&lt;/a&gt; doesn't work. I believe that the font suggested is also not installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a friend found:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;:set guifont=Courier\ 10\ Pitch\ 13&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which works.&lt;/p&gt;&#xA;" OwnerUserId="11475" LastActivityDate="2017-08-31T14:43:25.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13437" PostTypeId="1" AcceptedAnswerId="13440" CreationDate="2017-08-31T15:43:32.547" Score="2" ViewCount="3301" Body="&lt;p&gt;I just installed Vim and gVim, version 8.0.1026 under Windows 16 64bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything works well, except that the program(s) can't save any historical information about my usage (e.g. recent files, markers, command history). The reason, apparently, is the error that I keep receiving when exiting vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E886: Can't rename viminfo file to C:\Program Files (x86)\Vim\_viminfo!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just checked and made sure that &lt;code&gt;C:\Program Files (x86)\Vim\_viminfo&lt;/code&gt; is not ready-only and that I have all permissions to use it (I am working in my personal computer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could have been causing this?&lt;/p&gt;&#xA;" OwnerUserId="14094" LastActivityDate="2017-08-31T17:08:44.600" Title="Vim does not save any usage history (E886: Can't rename viminfo file)" Tags="|gvim|error|viminfo|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13440" PostTypeId="2" ParentId="13437" CreationDate="2017-08-31T17:08:44.600" Score="1" Body="&lt;p&gt;Writing to &lt;code&gt;C:\Program Files (x86)&lt;/code&gt; usually requires admin privileges, so Vim won't be able to write there, unless it's run as Administrator. But running Vim as Administrator is a security risk, so you should try to avoid doing so unless necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, Administrator is really not necessary. From &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#viminfo-file-name&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help viminfo-file-name&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;The default name of the viminfo file is [...] &quot;$HOME\_viminfo&quot; for&#xA;MS-DOS and Win32. [...] when $HOME is not set, &quot;$VIM\_viminfo&quot; is used.  &#xA;When $VIM is also not set, &quot;c:\_viminfo&quot; is used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It sounds like you have &lt;code&gt;$VIM&lt;/code&gt; set, but not &lt;code&gt;$HOME&lt;/code&gt;. Setting &lt;code&gt;$HOME&lt;/code&gt; in your environment variables to point to your home directory should solve the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can use &lt;a href=&quot;https://vi.stackexchange.com/questions/13437/vim-does-not-save-any-usage-history-e886-cant-rename-viminfo-file#comment23014_13437&quot;&gt;statox's suggestion&lt;/a&gt; and specify an explicit location for the &lt;code&gt;viminfo&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;The 'n' flag in the 'viminfo' option can be used to specify another viminfo&#xA;file name 'viminfo'.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viminfo+=nC:\Users\name\viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2017-08-31T17:08:44.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13441" PostTypeId="2" ParentId="13379" CreationDate="2017-08-31T17:33:12.340" Score="4" Body="&lt;p&gt;Vim is using Unicode (probably UTF-8), but Excel and/or Access are using &lt;a href=&quot;https://en.wikipedia.org/wiki/Windows-1252&quot; rel=&quot;nofollow noreferrer&quot;&gt;Windows-1252&lt;/a&gt; (or possibly a related Windows code page such as 1251 or 1253). Decimal 8216 is hexadecimal 2018, thus &lt;code&gt;‘&lt;/code&gt; is Unicode character U+2018 LEFT SINGLE QUOTATION MARK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/asc-function&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Asc&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/chr-function&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Chr&lt;/code&gt;&lt;/a&gt; are old, pre-Unicode functions, which is why they are reporting the Windows-1252 character codes. If you use &lt;code&gt;AscW&lt;/code&gt; and &lt;code&gt;ChrW&lt;/code&gt; instead, you will find that Access and Excel use the same values as Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set encoding=cp1252&lt;/code&gt; will tell Vim to use the Windows-1252 character encoding. Any non-ASCII characters, such as smart quotes, that already in your buffer will displayed as multiple characters (&lt;a href=&quot;https://en.wikipedia.org/wiki/Mojibake&quot; rel=&quot;nofollow noreferrer&quot;&gt;mojibake&lt;/a&gt;), but any new smart single quotes you enter will use 145 and 146. If you’re not sure how to type them in Vim, enter Insert mode and press &lt;code&gt;Ctrl-K ' 6&lt;/code&gt; for &lt;code&gt;‘&lt;/code&gt; and &lt;code&gt;Ctrl-K ' 9&lt;/code&gt; for &lt;code&gt;’&lt;/code&gt;. &lt;code&gt;ga&lt;/code&gt; will now show that &lt;code&gt;‘&lt;/code&gt; is decimal 145 and &lt;code&gt;’&lt;/code&gt; is 146. &lt;code&gt;:set coding=utf-8&lt;/code&gt; will return Vim to UTF-8 encoding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, I would suggest using &lt;code&gt;AscW&lt;/code&gt; and &lt;code&gt;ChrW&lt;/code&gt; instead of &lt;code&gt;Asc&lt;/code&gt; and &lt;code&gt;Chr&lt;/code&gt;, and I would not suggest switching Vim’s encoding to Windows-1252.&lt;/p&gt;&#xA;" OwnerUserId="2680" LastEditorUserId="2680" LastEditDate="2017-09-01T15:14:46.240" LastActivityDate="2017-09-01T15:14:46.240" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13442" PostTypeId="1" CreationDate="2017-09-01T02:06:56.743" Score="1" ViewCount="118" Body="&lt;p&gt;I have most of the usual tab commands in &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set tabstop=4&lt;/code&gt; &lt;code&gt;set softtabstop=4&lt;/code&gt; &lt;code&gt;set shiftwidth=4&lt;/code&gt; &lt;code&gt;set expandtab&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set breakindent&lt;/code&gt; &lt;code&gt;set autoindent&lt;/code&gt; &lt;code&gt;set smartindent&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are no problems when I open a file that uses spaces over tabs; all tabs produce 4 spaces. But when I open a file someone else has written using tabs, the tabs produce a space of length 8 and stretches out the lines. I can remove this by typing &lt;code&gt;:set tabstop=4&lt;/code&gt; but why must I do this when that command is already loaded in &lt;code&gt;~/.vimrc&lt;/code&gt;? How can I make it automatically alter the tabs to length 4 upon opening the file?&lt;/p&gt;&#xA;" OwnerUserId="14019" LastActivityDate="2017-09-01T02:06:56.743" Title="Files with tabs are length 8 even with set tabstop=4 in vimrc" Tags="|indentation|tab-characters|" AnswerCount="0" CommentCount="5" ClosedDate="2017-09-01T03:31:07.270" ContentLicense="CC BY-SA 3.0" />
  <row Id="13443" PostTypeId="1" AcceptedAnswerId="13444" CreationDate="2017-09-01T05:30:28.480" Score="1" ViewCount="475" Body="&lt;p&gt;It's only happening in one of my &lt;code&gt;.py&lt;/code&gt; files when opened with vim, I am getting some kind of fold info in the gutter that shouldn't be there - made up of the characters '2', '-' and '|'. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LQwu3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LQwu3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I disabled all my plugins to test if there is some plugin issue, but the problem remains. I deleted the files pertaining to this .py in the &lt;code&gt;views&lt;/code&gt; folder in case that may be the issue, but to no avail. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The foldmethod is set to indent. If I change the foldmethod to marker then that annoying info in the gutter goes away, but comes back once I reselect indent method. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The folds look normal when folded however:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/59AYg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/59AYg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone know what is happening, or how to get rid of it?&lt;/p&gt;&#xA;" OwnerUserId="10879" LastActivityDate="2017-09-01T06:53:52.247" Title="Strange Fold Info Showing in Gutter" Tags="|folding|filetype-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13444" PostTypeId="2" ParentId="13443" CreationDate="2017-09-01T06:53:52.247" Score="6" Body="&lt;p&gt;What you see is the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27foldcolumn%27&quot; rel=&quot;noreferrer&quot;&gt;'foldcolumn'&lt;/a&gt; setting for opened folds. If you don't want it, simply disable it: &lt;code&gt;:set foldcolumn=0&lt;/code&gt; To find out where it was set, enter &lt;code&gt;:verbose set foldcolumn?&lt;/code&gt; You might also play with increasing the foldcolumn value, so that the display looks a little bit better.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-09-01T06:53:52.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13445" PostTypeId="1" CreationDate="2017-09-01T07:00:10.807" Score="1" ViewCount="687" Body="&lt;p&gt;I want Vim to execute build the project automatically after I write the buffer to a &lt;code&gt;*.c&lt;/code&gt; or &lt;code&gt;*.cpp&lt;/code&gt; file. Here is what I've done:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.c,*.cpp make&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This one works as expected (but the output is noisy; see the bonus question below):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;main.c&quot; 26L, 448C written&#xA;:!make  2&amp;gt;&amp;amp;1| tee /var/folders/x0/lrg8j6r535n4lvnfnj6lr2fr0000gn/T/vF0bk92/0&#xA;clang -g main.c&#xA;               (1 of 1): clang -g main.c&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is, when there is no makefiles in the current directory, an error is thrown:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;test.c&quot; [New] 0L, 0C written&#xA;:!make  2&amp;gt;&amp;amp;1| tee /var/folders/x0/lrg8j6r535n4lvnfnj6lr2fr0000gn/T/vtVN9SA/0&#xA;make: *** No targets specified and no makefile found.  Stop.&#xA;(1 of 1): make: *** No targets specified and no makefile found.  Stop.&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I tell autocmd to check if a makefile exists before executing the command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus question&lt;/strong&gt;: can I tell autocmd to execute the command &lt;em&gt;quietly&lt;/em&gt;? That is, don't show the output of the command, or more preferably, show it in the status line.&lt;/p&gt;&#xA;" OwnerUserId="6335" LastActivityDate="2017-09-01T14:30:07.587" Title="Checking if Makefile exists before executing autocmd" Tags="|command-line|autocmd|external-command|filesystem|statusline|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13446" PostTypeId="2" ParentId="12827" CreationDate="2017-09-01T07:14:21.100" Score="6" Body="&lt;p&gt;I usually use this procedure for installation (used also under Debian 9)&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;# Clean from standard vim&#xA;sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common&#xA;# Vim dependency&#xA;sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev libperl-dev libncurses5-dev ruby-dev&#xA;&#xA;# if you want gVim add also this &#xA;sudo apt-get install libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev&#xA;&#xA;# Clean and prepare folders&#xA;sudo rm -rf /usr/local/share/vim&#xA;sudo rm /usr/bin/vim&#xA;sudo mkdir /usr/include/lua5.1/include&#xA;&#xA;# Download it and compile&#xA;cd /usr/local/src/&#xA;git clone https://github.com/vim/vim&#xA;cd vim/src&#xA;make distclean&#xA;&#xA;./configure --with-features=huge \&#xA;            --enable-rubyinterp \&#xA;            --with-ruby-command=$(which ruby) \&#xA;            --enable-largefile \&#xA;            --disable-netbeans \&#xA;            --enable-pythoninterp \&#xA;            --with-python-config-dir=/usr/lib/python2.7/config \&#xA;            --enable-perlinterp \&#xA;            --enable-luainterp \&#xA;            --with-luajit \&#xA;            --enable-gui=auto \&#xA;            --enable-fail-if-missing \&#xA;            --with-lua-prefix=/usr/include/lua5.1 \&#xA;            --enable-cscope&#xA;&#xA;make&#xA;sudo make install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For Python 3.5 replace &lt;code&gt;python-dev&lt;/code&gt; with &lt;code&gt;python3-dev&lt;/code&gt; in the &lt;code&gt;sudo apt-get install&lt;/code&gt; line and in the &lt;code&gt;./configure&lt;/code&gt; statement replace the 2.7 row and the row above with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;--enable-python3interp=yes \    &#xA;--with-python3-config-dir=/usr/lib/python3.5/config \&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the Python config directories, you could also use the output of &lt;code&gt;python-config&lt;/code&gt; or &lt;code&gt;python3-config&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;--with-python-config-dir=$(python-config --configdir) \&#xA;# or&#xA;--with-python3-config-dir=$(python3-config --configdir) \&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11363" LastEditorUserId="205" LastEditDate="2018-08-13T03:30:53.843" LastActivityDate="2018-08-13T03:30:53.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13447" PostTypeId="2" ParentId="13445" CreationDate="2017-09-01T09:14:24.863" Score="2" Body="&lt;p&gt;Indeed &lt;code&gt;filereadable()&lt;/code&gt; is how we could detect whether a file exists. Here, you'd want to check &lt;code&gt;filereadable(expand('&amp;lt;amatch&amp;gt;:p:h').'/Makefile'))&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to check for a &lt;code&gt;Makefile&lt;/code&gt; in a directory above the one where your file is, it's &lt;code&gt;findfile()&lt;/code&gt; you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But beware if you have a lot of files, you won't want to freeze vim every time you save a file among the hundred if not the thousand a project contains. And if you want to do that in the background, you'll have to make sure to not start &lt;code&gt;make&lt;/code&gt; several times in parallel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I don't know if you're aware of it, but single file projects don't need a &lt;code&gt;Makefile&lt;/code&gt;. If you're using gnu-make, and if your version of gnu make is properly configured (Mingw one is the only one I'm aware of to be improperly configured), you can just execute &lt;code&gt;:make %&amp;lt;&lt;/code&gt; to compile the current file into an executable.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-09-01T14:30:07.587" LastActivityDate="2017-09-01T14:30:07.587" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13449" PostTypeId="1" CreationDate="2017-09-01T18:13:35.757" Score="0" ViewCount="514" Body="&lt;p&gt;I have autocomplpop plugin installed in my .vim directory. If I use gvim then autocompleting simply works automatically in insert mode without the need to press any CTRL-N to get the drop down list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can emulate that in vim? Where in insert mode I have to press CTRL-N each time to get the drop down menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recollect there was a way of doing that by adding something in .vimrc to emulate that but can't recollect those settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;-ND&lt;/p&gt;&#xA;" OwnerUserId="14110" LastActivityDate="2017-09-02T10:25:58.077" Title="Autocomplete behavior in vim" Tags="|vimrc|autocompletion|gvim|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13451" PostTypeId="1" AcceptedAnswerId="13452" CreationDate="2017-09-01T20:26:41.380" Score="1" ViewCount="88" Body="&lt;p&gt;By default, &lt;code&gt;C-o&lt;/code&gt; allows to execute a normal command from insert mode. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar| baz&#xA;       ^ represents the cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The current mode being insert mode, and the cursor being after the word &lt;code&gt;bar&lt;/code&gt;, to delete the next word, you could hit &lt;code&gt;C-o daw&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However there are several ways to enter insert mode. Most of the time (&lt;code&gt;i&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;o&lt;/code&gt;, &lt;code&gt;O&lt;/code&gt;, ...), &lt;code&gt;C-o&lt;/code&gt; will behave as expected. However, if you enter insert mode from visual mode, for example by pressing &lt;code&gt;A&lt;/code&gt; from visual block mode (&lt;code&gt;:h v_b_A&lt;/code&gt;),  its behavior depends on whether you've already inserted text, and the number of times you pressed it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar| baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you press:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;C-v&lt;/code&gt; to enter visual block mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A&lt;/code&gt; to enter insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C-o&lt;/code&gt; to enter normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;daw&lt;/code&gt; to delete &lt;code&gt;baz&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;... &lt;code&gt;daw&lt;/code&gt; is literally inserted into the buffer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yzAjc.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yzAjc.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you repeat the same sequence of keys, but this time you repeat &lt;code&gt;C-o&lt;/code&gt; a 2nd time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C-v A C-o C-o daw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;C-o&lt;/code&gt; behaves as expected:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3OLBG.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3OLBG.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a third behavior which requires a multi-line text to be observed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo | baz&#xA;foo   baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Suppose you want to add &lt;code&gt;bar&lt;/code&gt; between the &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;baz&lt;/code&gt; on the 2 lines.&#xA;The cursor being between &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;baz&lt;/code&gt; on the 1st line, you can press:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;C-v&lt;/code&gt; to enter visual block mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; to go down one line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A&lt;/code&gt; to enter insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;bar&lt;/code&gt; to insert &lt;code&gt;bar&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you press &lt;code&gt;Escape&lt;/code&gt;, you'll get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar baz&#xA;foo bar baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now suppose you don't press &lt;code&gt;Escape&lt;/code&gt;, because before going back to normal mode, you want to delete the next word &lt;code&gt;baz&lt;/code&gt;. You could press &lt;code&gt;C-o daw&lt;/code&gt;, expecting the following buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar&#xA;foo bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that's not what you'll get, instead you'll have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo daw bar baz&#xA;foo bar baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What happened is that when you pressed &lt;code&gt;C-o&lt;/code&gt;, Vim reinserted the text you had typed (here &lt;code&gt;bar&lt;/code&gt;) at the end of each line of the visual block, and moved the cursor to the upper left corner of the block. In other words, it's as if you had pressed &lt;code&gt;Escape&lt;/code&gt; then &lt;code&gt;i&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;C-o&lt;/code&gt; is often used in an insert mode mapping. Here's an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ino &amp;lt;c-x&amp;gt;&amp;lt;c-k&amp;gt; &amp;lt;c-o&amp;gt;:exe 'setl dict='&#xA;                                    \. (&amp;amp;l:spelllang ==# 'en'&#xA;                                    \? '/usr/share/dict/words'&#xA;                                    \: '/usr/share/dict/ngerman')&#xA;                                    \&amp;lt;cr&amp;gt;&amp;lt;c-x&amp;gt;&amp;lt;c-k&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping customizes the default dictionary completion &lt;code&gt;C-x C-k&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It first checks the buffer-local value of the &lt;code&gt;'spelllang'&lt;/code&gt; option. If it's &lt;code&gt;en&lt;/code&gt;, then the mapping sets the buffer-local option &lt;code&gt;dict&lt;/code&gt; to &lt;code&gt;/usr/share/dict/words&lt;/code&gt; (dictionary for english words), otherwise to &lt;code&gt;/usr/share/dict/ngerman&lt;/code&gt; (dictionary to german words). Then, it performs the usual dictionary completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works as long as you've entered insert mode from normal mode. But if you entered insert mode from visual mode, instead of completing the text looking into a dictionary, it dumps the &lt;code&gt;{rhs}&lt;/code&gt; of the mapping inside the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of this, I never use &lt;code&gt;C-o&lt;/code&gt; in a mapping because I don't know how to detect what was the previous mode, before insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead I use &lt;code&gt;C-r =&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ino &amp;lt;c-x&amp;gt;&amp;lt;c-k&amp;gt; &amp;lt;c-r&amp;gt;=&amp;lt;sid&amp;gt;set_dict()&amp;lt;cr&amp;gt;&amp;lt;c-x&amp;gt;&amp;lt;c-k&amp;gt;&#xA;&#xA;fu! s:set_dict() abort&#xA;    exe 'setl dict='.(&amp;amp;l:spelllang ==# 'en' ? '/usr/share/dict/words' : '/usr/share/dict/ngerman')&#xA;    return ''&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This solves the issue for a mapping. But in an interactive use, sometimes you have to hit &lt;code&gt;C-o&lt;/code&gt; once, and sometimes twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to make &lt;code&gt;i_C-o&lt;/code&gt; unaffected by the mode from which we entered insert mode?&lt;/p&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-09-01T20:51:24.427" LastActivityDate="2017-09-01T21:47:15.397" Title="How to make `i_ctrl-o` unaffected by the mode from which we entered insert mode?" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13452" PostTypeId="2" ParentId="13451" CreationDate="2017-09-01T21:47:15.397" Score="3" Body="&lt;p&gt;This issue, &lt;a href=&quot;https://github.com/vim/vim/issues/1290&quot; rel=&quot;nofollow noreferrer&quot;&gt;needing to use CTRL-O twice when in visual-insert mode&lt;/a&gt;, was fixed in patches &lt;a href=&quot;https://github.com/vim/vim/commit/0b5c93a7f266cd8c90ea27bdaf9f7214a95d64d7&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.0.0282&lt;/a&gt; and &lt;a href=&quot;https://github.com/vim/vim/commit/23fa81d2223cd9bb7c51829c48047b2976bc2d11&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.0.0291&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-09-01T21:47:15.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13454" PostTypeId="1" AcceptedAnswerId="13455" CreationDate="2017-09-02T02:26:45.277" Score="3" ViewCount="519" Body="&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.c,*.cpp,*.h&#xA;  \   let dir=expand('&amp;lt;amatch&amp;gt;:p:h')&#xA;  \ | if filereadable(dir.'/Makefile') || filereadable(dir.'/makefile')&#xA;  \ |   Make &amp;gt; /dev/null&#xA;  \ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want vim to execute the command &lt;code&gt;Make &amp;gt;&amp;gt; /dev/null&lt;/code&gt; if there is a &lt;code&gt;Makefile&lt;/code&gt; or &lt;code&gt;makefile&lt;/code&gt; in the same directory as the current file. However, the command executed is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Dispatch make &amp;gt; /dev/null | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is to say, &lt;code&gt;| endif&lt;/code&gt; is treated as part of the command. How can I tell vim it's part of an if-statement?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;Make&lt;/code&gt; and &lt;code&gt;Dispatch&lt;/code&gt; come from &lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-dispatch&lt;/a&gt;, if it's relevant.&lt;/p&gt;&#xA;" OwnerUserId="6335" LastEditorUserId="6335" LastEditDate="2017-09-02T02:36:12.047" LastActivityDate="2017-09-02T02:43:27.300" Title="endif treated as part of command in autocmd" Tags="|vimrc|vimscript|autocmd|multiple-lines|escape|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13455" PostTypeId="2" ParentId="13454" CreationDate="2017-09-02T02:33:09.437" Score="3" Body="&lt;p&gt;If the &lt;code&gt;:Make&lt;/code&gt; command you are using is &lt;a href=&quot;https://github.com/tpope/vim-dispatch/blob/6dd4480388e4727dfe5c723484c500e03b429c28/plugin/dispatch.vim#L19-L20&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;, then your issue may come from the fact that it was not given the &lt;code&gt;-bar&lt;/code&gt; attribute when it was defined. See &lt;code&gt;:h :command-bar&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-bar        The command can be followed by a &quot;|&quot; and another command.&#xA;            A &quot;|&quot; inside the command argument is not allowed then.&#xA;            Also checks for a &quot; to start a comment.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are other solutions, but the simplest one may be to hide &lt;code&gt;| endif&lt;/code&gt; from &lt;code&gt;:Make&lt;/code&gt; by wrapping it inside a string, and executing the latter with &lt;code&gt;:execute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.c,*.cpp,*.h&#xA;  \   let dir=expand('&amp;lt;amatch&amp;gt;:p:h')&#xA;  \ | if filereadable(dir.'/Makefile') || filereadable(dir.'/makefile')&#xA;  \ |   exe 'Make &amp;gt; /dev/null'&#xA;  \ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the complete list of commands which, like &lt;code&gt;:Make&lt;/code&gt;, see the &lt;code&gt;|&lt;/code&gt; as part of their argument, see &lt;code&gt;:h :bar&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;These commands see the '|' as their argument, and can therefore not be&#xA;followed by another Vim command:&#xA;    :argdo&#xA;    :autocmd&#xA;    :bufdo&#xA;    :cdo&#xA;    :cfdo&#xA;    :command&#xA;    :cscope&#xA;    :debug&#xA;    :folddoopen&#xA;    :folddoclosed&#xA;    :function&#xA;    :global&#xA;    :help&#xA;    :helpfind&#xA;    :lcscope&#xA;    :ldo&#xA;    :lfdo&#xA;    :make&#xA;    :normal&#xA;    :perl&#xA;    :perldo&#xA;    :promptfind&#xA;    :promptrepl&#xA;    :pyfile&#xA;    :python&#xA;    :registers&#xA;    :read !&#xA;    :scscope&#xA;    :sign&#xA;    :tcl&#xA;    :tcldo&#xA;    :tclfile&#xA;    :vglobal&#xA;    :windo&#xA;    :write !&#xA;    :[range]!&#xA;    a user defined command without the &quot;-bar&quot; argument |:command|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-09-02T02:43:27.300" LastActivityDate="2017-09-02T02:43:27.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13456" PostTypeId="2" ParentId="8056" CreationDate="2017-09-02T03:37:27.850" Score="30" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is this usage of &amp;lt;buffer&gt; correct?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think it is correct, but you just need to wrap it inside an augroup, and clear the latter, to make sure that the autocmd won't be duplicated every time you execute a command which reloads the same buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you explained, the special pattern &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; allows you to rely on the built-in filetype detection mechanism, implemented inside the file &lt;code&gt;$VIMRUNTIME/filetype.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this file, you can find the Vim's built-in autocmds which are responsible for setting the correct filetype for any given buffer. For example, for markdown:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Markdown&#xA;au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md  setf markdown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inside your filetype plugin, you could copy the same patterns for every autocmd you install. For example, to automatically save the buffer when your cursor hasn't moved during a few seconds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au CursorHold *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md  update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; is way less verbose:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au CursorHold &amp;lt;buffer&amp;gt; update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Besides, if some day another extension is valid, and &lt;code&gt;$VIMRUNTIME/filetype.vim&lt;/code&gt; is updated to include it, your autocmds won't be informed. And you'll have to update all their patterns inside your filetype plugins.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Will things get messy if I wipe a buffer and open another (hopefully&#xA;  the numbers won't collide, but …)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not sure but I don't think that Vim can re-use the buffer number of a wiped buffer.&#xA;I couldn't find the relevant section from the help, but I found this paragraph from &lt;a href=&quot;http://vim.wikia.com/wiki/Vim_buffer_FAQ&quot; rel=&quot;noreferrer&quot;&gt;vim.wikia.com&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;No. Vim will not re-use the buffer number of a deleted buffer for a&#xA;  new buffer. Vim will always assign the next sequential number for a&#xA;  new buffer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Besides, as &lt;a href=&quot;https://vi.stackexchange.com/questions/8056/for-an-autocmd-in-a-ftplugin-should-i-use-pattern-matching-or-buffer#comment13423_8056&quot;&gt;@Tumbler41&lt;/a&gt; explained, when you wipe a buffer, its autocmds are removed. From &lt;code&gt;:h autocmd-buflocal&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When a buffer is wiped out its buffer-local autocommands are also&#xA;  gone, of course.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you want to check yourself, you can do so by increasing Vim's verbosity level to 6. You can do it temporarily, just for one command, by using the &lt;code&gt;:verbose&lt;/code&gt; modifier. So, inside your markdown buffer, you could execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:6verbose bwipe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, if you check Vim's messages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:messages&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should see a line looking like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;auto-removing autocommand: CursorHold &amp;lt;buffer=42&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;42&lt;/code&gt; was the number of your markdown buffer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are there any pitfalls I should be aware of?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are 3 situations which I would consider as pitfalls and which involve the special pattern &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;. In two of them, &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; may be an issue, in the other it's a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pitfall 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, you should be careful with the way you clear the augroups of your buffer-local autocmds. You must be familiar with this snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup your_group_name&#xA;    autocmd!&#xA;    autocmd Event pattern command&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, you could be tempted to use it for your buffer-local autocmds, unmodified, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup my_markdown&#xA;    autocmd!&#xA;    autocmd CursorHold &amp;lt;buffer&amp;gt; update&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this will have an undesired effect. The first time you load a markdown buffer, let's call it &lt;code&gt;A&lt;/code&gt;, its autocmd will be correctly installed. Then, when you'll reload &lt;code&gt;A&lt;/code&gt;, the autocmd will be deleted (because of &lt;code&gt;autocmd!&lt;/code&gt;), and re-installed. So, the augroup will correctly prevent the duplication of the autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, suppose you load a 2nd markdown buffer, let's call it &lt;code&gt;B&lt;/code&gt;, in a 2nd window. ALL the autocmds of the augroup will be cleared: that is the autocmd of &lt;code&gt;A&lt;/code&gt; and the one of &lt;code&gt;B&lt;/code&gt;. Then, a SINGLE autocmd will be installed for &lt;code&gt;B&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, when you make some change in &lt;code&gt;B&lt;/code&gt;, and wait a few seconds for &lt;code&gt;CursorHold&lt;/code&gt; to be fired, it will be automatically saved. But if you go back to &lt;code&gt;A&lt;/code&gt; and do the same thing, the buffer won't be saved. This is because the last time you loaded a markdown buffer, there was an imbalance between what you removed and what you added. You removed more than what you added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to not remove ALL autocmds, but only the ones of the current buffer, by passing the special pattern &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; to &lt;code&gt;:autocmd!&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup my_markdown&#xA;    autocmd! CursorHold &amp;lt;buffer&amp;gt;&#xA;    autocmd CursorHold &amp;lt;buffer&amp;gt; update&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you could replace &lt;code&gt;CursorHold&lt;/code&gt; with a star to match any event in the line which removes autocmds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup my_markdown&#xA;    autocmd! * &amp;lt;buffer&amp;gt;&#xA;    autocmd CursorHold &amp;lt;buffer&amp;gt; update&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, you don't have to specify all the events to which your autocmds are listening when you want to clear the augroup.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pitfall 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's another pitfall, but this time &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; is not the issue, it's the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you include a local option in a filetype plugin, you probably do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal option1=value&#xA;setlocal option2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will work as expected for buffer-local options, but not always for window-local ones. To illustrate the issue, you could try the following experiment. Create the file &lt;code&gt;~/.vim/after/ftdetect/potion.vim&lt;/code&gt;, and inside it write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.pn setfiletype potion&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This file will automatically set the filetype &lt;code&gt;potion&lt;/code&gt; for any file whose extension is &lt;code&gt;.pn&lt;/code&gt;. You don't need to wrap it inside an augroup because, for this particular kind of file, Vim will do it automatically (see &lt;code&gt;:h ftdetect&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the intermediate directories don't exist on your system, you can create them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, create the filetype plugin &lt;code&gt;~/.vim/after/ftplugin/potion.vim&lt;/code&gt;, and inside it write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By default, in a &lt;code&gt;potion&lt;/code&gt; file, this setting will cause the tab characters to be displayed as &lt;code&gt;^I&lt;/code&gt; and the end of lines as &lt;code&gt;$&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, create a minimal &lt;code&gt;vimrc&lt;/code&gt;; inside &lt;code&gt;/tmp/vimrc&lt;/code&gt; write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... to enable the filetype plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, create a potion file, &lt;code&gt;/tmp/pn.pn&lt;/code&gt;, and a random file &lt;code&gt;/tmp/file&lt;/code&gt;. In the potion file, write something:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar&#xA;baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the random file, write the path to the potion file &lt;code&gt;/tmp/pn.pn&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/tmp/pn.pn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, start Vim with a minimum of initializations, just sourcing the &lt;code&gt;vimrc&lt;/code&gt;, and open both files in vertical viewports:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -Nu /tmp/vimrc -O /tmp/pn.pn /tmp/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should see 2 vertical viewports. The potion file on the left displays the end of lines with dollar signs, the random file on the right doesn't display them at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Give the focus to the random file, and press &lt;code&gt;gf&lt;/code&gt; to display the potion file whose path is under the cursor. You now see the same potion buffer in the right viewport, but this time, the end of lines are not displayed with dollar signs. And if you type &lt;code&gt;:setlocal list?&lt;/code&gt;, Vim should answer with &lt;code&gt;nolist&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BxDUi.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BxDUi.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole chain of events:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BufRead event → set 'filetype' option → load filetype plugins&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... didn't occur, because the first of them, &lt;code&gt;BufRead&lt;/code&gt;, didn't occur when you pressed &lt;code&gt;gf&lt;/code&gt;. The buffer was already loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It may seem unexpected, because when you added &lt;code&gt;setlocal list&lt;/code&gt; inside your potion filetype plugin, you may have thought that it would enable the &lt;code&gt;'list'&lt;/code&gt; option in any window displaying a potion buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is not specific to this new &lt;code&gt;potion&lt;/code&gt; filetype. You can experience it with a &lt;code&gt;markdown&lt;/code&gt; file too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not specific to the &lt;code&gt;'list'&lt;/code&gt; option either. You can experience it with other window-local settings, like &lt;code&gt;'conceallevel'&lt;/code&gt;, &lt;code&gt;'foldmethod'&lt;/code&gt;, &lt;code&gt;'foldexpr'&lt;/code&gt;, &lt;code&gt;'foldtitle'&lt;/code&gt;, ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not specific to the &lt;code&gt;gf&lt;/code&gt; command either. You can experience it with other commands which may change the buffer displayed in the current window:  global mark, &lt;code&gt;C-o&lt;/code&gt; (move backward in the window-local jumplist), &lt;code&gt;:b {buffer_number}&lt;/code&gt;, ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To summarize, the window-local options will be correctly set, if and only if:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the file hasn't been read during the current Vim session (because &lt;code&gt;BufRead&lt;/code&gt; will have to be fired)&lt;/li&gt;&#xA;&lt;li&gt;the file is being displayed in a window where the window-local options were already correctly set&lt;/li&gt;&#xA;&lt;li&gt;the new window is created with a command such as &lt;code&gt;:split&lt;/code&gt; (in this case, it should inherit the window-local options from the window where the command was executed)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Otherwise, the window-local options may not be correctly set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possible solution would be to set them not directly from a filetype plugin, but from an autocmd installed in the latter, which would listen to &lt;code&gt;BufWinEnter&lt;/code&gt;. This event should be fired every time a buffer is displayed in a window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for example, instead of writing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would write this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup my_potion&#xA;    au! * &amp;lt;buffer&amp;gt;&#xA;    au BufWinEnter &amp;lt;buffer&amp;gt; setlocal list&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here, you find again the special pattern &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oozkR.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oozkR.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pitfall 3&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you change the filetype of your buffer, the autocmds will remain. If you want to remove them, you need to configure &lt;code&gt;b:undo_ftplugin&lt;/code&gt; (see &lt;code&gt;:h undo_ftplugin&lt;/code&gt;), and include this command in it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe 'au! my_markdown * &amp;lt;buffer&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, don't try to remove the augroup itself, because there could still be some markdown buffers which have autocmds inside it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FWIW, this is the UltiSnips snippet that I'm using to set &lt;code&gt;b:undo_ftplugin&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet undo &quot;undo ftplugin settings&quot; bm&#xA;&quot; teardown {{{1&#xA;&#xA;let b:undo_ftplugin =         get(b:, 'undo_ftplugin', '')&#xA;\                     .(empty(get(b:, 'undo_ftplugin', '')) ? '' : '|')&#xA;\                     .&quot;${1:&#xA;\                          setl ${2:option}&amp;lt;}${3:&#xA;\                        | exe '${4:n}unmap &amp;lt;buffer&amp;gt; ${5:lhs}'}${6:&#xA;\                        | exe 'au! ${7:group_name} * &amp;lt;buffer&amp;gt;'}${8:&#xA;\                        | unlet! b:${9:variable}}${10:&#xA;\                        | delcommand ${11:Cmd}}&#xA;\                      &quot;&#xA;$0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here's an example of value which I have in &lt;code&gt;~/.vim/after/ftplugin/awk.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:undo_ftplugin =         get(b:, 'undo_ftplugin', '')&#xA;                    \ .(empty(get(b:, 'undo_ftplugin', '')) ? '' : '|')&#xA;                    \ .&quot;&#xA;                    \   setl cms&amp;lt; cocu&amp;lt; cole&amp;lt; fdm&amp;lt; fdt&amp;lt; tw&amp;lt;&#xA;                    \|  exe 'nunmap &amp;lt;buffer&amp;gt; K'&#xA;                    \|  exe 'au! my_awk * &amp;lt;buffer&amp;gt;'&#xA;                    \|  exe 'au! my_awk_format * &amp;lt;buffer&amp;gt;'&#xA;                    \  &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As a side note, I understand why you asked the question, because when I looked for all the lines where the special pattern &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; was used in Vim's default files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vim /au\%[tocmd!].\{-}&amp;lt;buffer&amp;gt;/ $VIMRUNTIME/**/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I only found 9 matches (you may find more or less, I'm using Vim version 8.0, with patches up to &lt;code&gt;134&lt;/code&gt;). And among the 9 matches, 7 are in the documentation, only 2 are actually sourced. You should find them in &lt;a href=&quot;https://github.com/vim/vim/blob/995e4afcfe60aa3c214ba680e7b027a4e05cf62b/runtime/syntax/dircolors.vim#L209-L210&quot; rel=&quot;noreferrer&quot;&gt;$VIMRUNTIME/syntax/dircolors.vim&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorMoved,CursorMovedI &amp;lt;buffer&amp;gt; call s:preview_color('.')&#xA;autocmd CursorHold,CursorHoldI   &amp;lt;buffer&amp;gt; call s:reset_colors()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know if it can cause an issue, but they aren't inside an augroup, which means every time you reload a buffer whose filetype is &lt;code&gt;dircolors&lt;/code&gt; (it happens if you edit a file named &lt;code&gt;.dircolors&lt;/code&gt;, &lt;code&gt;.dir_colors&lt;/code&gt;, or whose path ends with &lt;code&gt;/etc/DIR_COLORS&lt;/code&gt;), the syntax plugin will add a new buffer-local autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim ~/.dir_colors&#xA;:au * &amp;lt;buffer&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last command should display this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CursorHold&#xA;    &amp;lt;buffer=1&amp;gt;&#xA;              call s:reset_colors()&#xA;CursorHoldI&#xA;    &amp;lt;buffer=1&amp;gt;&#xA;              call s:reset_colors()&#xA;CursorMoved&#xA;    &amp;lt;buffer=1&amp;gt;&#xA;              call s:preview_color('.')&#xA;CursorMovedI&#xA;    &amp;lt;buffer=1&amp;gt;&#xA;              call s:preview_color('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, reload the buffer, and ask again what are the buffer-local autocmds for the current buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e&#xA;:au * &amp;lt;buffer&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This time, you will see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CursorHold&#xA;    &amp;lt;buffer=1&amp;gt;&#xA;              call s:reset_colors()&#xA;              call s:reset_colors()&#xA;CursorHoldI&#xA;    &amp;lt;buffer=1&amp;gt;&#xA;              call s:reset_colors()&#xA;              call s:reset_colors()&#xA;CursorMoved&#xA;    &amp;lt;buffer=1&amp;gt;&#xA;              call s:preview_color('.')&#xA;              call s:preview_color('.')&#xA;CursorMovedI&#xA;    &amp;lt;buffer=1&amp;gt;&#xA;              call s:preview_color('.')&#xA;              call s:preview_color('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After every reloading of the file, &lt;code&gt;s:reset_colors()&lt;/code&gt; and &lt;code&gt;s:preview_color('.')&lt;/code&gt; will be called one additional time, every time one of the event &lt;code&gt;CursorHold&lt;/code&gt;, &lt;code&gt;CursorHoldI&lt;/code&gt;, &lt;code&gt;CursorMoved&lt;/code&gt;, &lt;code&gt;CursorMovedI&lt;/code&gt; is fired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's probably not a big issue, because even after reloading a &lt;code&gt;dircolors&lt;/code&gt; file several times, I didn't see a noticeable slowdown, or unexpected behavior from Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is an issue for you, you could contact the maintainer of the syntax plugin, but in the meantime, if you wanted to prevent the duplication of autocmds, you could create your own syntax plugin for &lt;code&gt;dircolors&lt;/code&gt; files, using the file &lt;code&gt;~/.vim/syntax/dircolors.vim&lt;/code&gt;. Inside it you would import the contents of the original syntax plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim ~/.vim/syntax/dircolors.vim&#xA;:r $VIMRUNTIME/syntax/dircolors.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, in the latter, you would just wrap the autocmds inside an augroup which you would clear. So, you would replace these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorMoved,CursorMovedI &amp;lt;buffer&amp;gt; call s:preview_color('.')&#xA;autocmd CursorHold,CursorHoldI   &amp;lt;buffer&amp;gt; call s:reset_colors()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... with these ones:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup my_dircolors_syntax&#xA;    autocmd! * &amp;lt;buffer&amp;gt;&#xA;    autocmd CursorMoved,CursorMovedI &amp;lt;buffer&amp;gt; call s:preview_color('.')&#xA;    autocmd CursorHold,CursorHoldI   &amp;lt;buffer&amp;gt; call s:reset_colors()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that if you created your &lt;code&gt;dircolors&lt;/code&gt; syntax plugin with the file &lt;code&gt;~/.vim/after/syntax/dircolors.vim&lt;/code&gt;, it wouldn't work, because the default syntax plugin would be sourced before. By using &lt;code&gt;~/.vim/syntax/dircolors.vim&lt;/code&gt;, your syntax plugin will be sourced before the default one, and it will set the buffer-local variable &lt;code&gt;b:current_syntax&lt;/code&gt;, which will prevent the default syntax plugin from being sourced because it contains this guard:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;b:current_syntax&quot;)&#xA;    finish&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The general rule seems to be: use the &lt;code&gt;~/.vim/ftplugin&lt;/code&gt; and &lt;code&gt;~/.vim/syntax&lt;/code&gt; directories to create a custom filetype / syntax plugin and prevent the next plugin (for the same filetype) in the runtime path to be sourced (including the default ones). And use &lt;code&gt;~/.vim/after/ftplugin&lt;/code&gt;, &lt;code&gt;~/.vim/after/syntax&lt;/code&gt;, not to prevent other plugins from being sourced, but just to have the last word on the value of some settings.&lt;/p&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-11-22T11:04:48.410" LastActivityDate="2017-11-22T11:04:48.410" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13457" PostTypeId="2" ParentId="13429" CreationDate="2017-09-02T05:13:32.773" Score="0" Body="&lt;p&gt;I doubt it. Take a look at this thread: &lt;a href=&quot;https://vi.stackexchange.com/questions/8275/is-there-a-way-to-repeat-the-p%c3%a6nultimate-or-older-change&quot;&gt;Is there a way to repeat the pænultimate (or older) change?&lt;/a&gt;. Even though the discussion is about something a bit different from what you've mentioned you can deduce that the single repeat mechanism is pretty limited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest thing I can think of would involve a macro. You'd have to remember to start recording before you begin a complex edit. Then if you make a mistake along the lines of your example you can edit the macro and correct it. Then you can repeat to your heart's content with &lt;code&gt;@{register}&lt;/code&gt; and &lt;code&gt;@@&lt;/code&gt;. Editing is possible because a macro is just a series of keystrokes stored in a regular register. But I'm guessing you won't consider this an adequate substitute for what you want to do.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2017-09-02T05:13:32.773" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13458" PostTypeId="1" CreationDate="2017-09-02T08:28:00.637" Score="17" ViewCount="30118" Body="&lt;p&gt;I have a problem with making vim show a colorscheme fully (like in gvim). I've read about how to enable 256 color mode in terminal and it vim, but somehow it just doesn't work. The state of now is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:echo &amp;amp;t_Co&lt;/code&gt; returns &lt;code&gt;256&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[~]$ tput colors&#xA;256&#xA;[~]$ echo $TERM&#xA;xterm-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Colortest shows all the colors:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/VPNOG.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VPNOG.png&quot; alt=&quot;colortest&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But yet, vim doesn't show &lt;code&gt;grey20&lt;/code&gt; color of the colorscheme, instead using the terminal background. I also tried changing it to &lt;code&gt;grey&lt;/code&gt; without success:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ycFF2.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ycFF2.png&quot; alt=&quot;hi Normal&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The system is ubuntu 14.04. and the terminal gnome terminal, although I've tried with terminator and tmux, with no success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea what could gone wrong?&lt;/p&gt;&#xA;" OwnerUserId="14015" LastActivityDate="2020-02-12T12:09:59.183" Title="Make vim show all the colors" Tags="|colorscheme|terminal|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13459" PostTypeId="2" ParentId="13458" CreationDate="2017-09-02T10:02:52.710" Score="11" Body="&lt;p&gt;The colorscheme must be missing &lt;code&gt;cterm&lt;/code&gt; definitions, the full highlight command should look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Normal cterm=NONE ctermfg=15 ctermbg=7 gui=NONE guifg=White guibg=grey20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your terminal supports 256 colors, you might need &lt;a href=&quot;https://en.wikipedia.org/wiki/File:Xterm_256color_chart.svg&quot; rel=&quot;noreferrer&quot;&gt;color codes greater than 16&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a &lt;em&gt;true color&lt;/em&gt; terminal, you could add these settings instead to enable 24-bit compatibility:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set termguicolors&#xA;&#xA;&quot; Correct RGB escape codes for vim inside tmux&#xA;if !has('nvim') &amp;amp;&amp;amp; $TERM ==# 'screen-256color'&#xA;  let &amp;amp;t_8f = &quot;\&amp;lt;Esc&amp;gt;[38;2;%lu;%lu;%lum&quot;&#xA;  let &amp;amp;t_8b = &quot;\&amp;lt;Esc&amp;gt;[48;2;%lu;%lu;%lum&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the help for &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27termguicolors%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'termguicolors'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that the &lt;code&gt;cterm&lt;/code&gt; attributes are still used, not the &lt;code&gt;gui&lt;/code&gt; ones.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Read more:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.appspot.com/syntax.txt.html#highlight-args&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h highlight-args&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.appspot.com/syntax.txt.html#cterm-colors&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h cterm-colors&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/256_colors_in_vim&quot; rel=&quot;noreferrer&quot;&gt;Vim Tip &lt;em&gt;256 colors in vim&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2020-02-12T12:09:59.183" LastActivityDate="2020-02-12T12:09:59.183" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="13460" PostTypeId="2" ParentId="13449" CreationDate="2017-09-02T10:25:58.077" Score="2" Body="&lt;p&gt;As said by &lt;a href=&quot;https://vi.stackexchange.com/questions/13449/autocomplete-behavior-in-vim#comment23062_13449&quot;&gt;B Layer&lt;/a&gt;, this kind of feature should not vary between terminal and GUI versions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure the plugin is enabled from your &lt;code&gt;vimrc&lt;/code&gt; file, and &lt;strong&gt;not&lt;/strong&gt; from &lt;code&gt;gvimrc&lt;/code&gt;. If still not working, check the output of &lt;code&gt;:scriptnames&lt;/code&gt; from both instances to see which files are loaded.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-09-02T10:25:58.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13461" PostTypeId="1" CreationDate="2017-09-02T17:45:18.820" Score="0" ViewCount="933" Body="&lt;p&gt;Here is my vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('$HOME/vimfiles/plugged')&#xA;Plug 'vim-airline/vim-airline'&#xA;Plug 'itchyny/lightline.vim'&#xA;Plug 'kien/ctrlp.vim'&#xA;Plug 'python-mode/python-mode'&#xA;Plug 'rdnetto/YCM-Generator', { 'branch': 'stable'}&#xA;Plug 'davidhalter/jedi-vim'&#xA;Plug 'octol/vim-cpp-enhanced-highlight'&#xA;Plug 'Valloric/YouCompleteMe'&#xA;Plug 'jeaye/color_coded'&#xA;call plug#end()&#xA;&#xA;set encoding=utf-8&#xA;syntax on colorscheme gruvbox&#xA;set backspace=indent,eol,start&#xA;inoremap ii &amp;lt;Esc&amp;gt; inoremap II &amp;lt;Esc&amp;gt;&#xA;set number&#xA;set langmenu=en_US let $LANG = 'en_US'&#xA;source $VIMRUNTIME/delmenu.vim&#xA;source $VIMRUNTIME/menu.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the error I get with &quot;set encoding=utf-8&quot;, after command &quot;:PlugInstall&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EYKcF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EYKcF.png&quot; alt=&quot;error&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Windows 10&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Well, interestingly enough, the problem apparently was in the picture I sent, but below the blue rectangle I put, I had the letter &quot;á&quot; in my path and changing that worked.&lt;/p&gt;&#xA;" OwnerUserId="14122" LastEditorUserId="51" LastEditDate="2017-09-02T23:36:16.940" LastActivityDate="2017-09-02T23:36:16.940" Title="Why is it that if I put &quot;set encoding=utf-8&quot; in my vimrc file, plugins won't load properly?" Tags="|vimrc|encoding|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13462" PostTypeId="2" ParentId="13461" CreationDate="2017-09-02T23:36:06.917" Score="1" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27encoding%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'encoding'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;NOTE: Changing this option will not change the encoding of the existing text in Vim.  It may cause non-ASCII text to become invalid. It should normally be kept at its default value, or set when Vim starts up.  See &lt;a href=&quot;http://vimhelp.appspot.com/mbyte.txt.html#multibyte&quot; rel=&quot;nofollow noreferrer&quot;&gt;multibyte&lt;/a&gt;.  To reload the menus see &lt;a href=&quot;http://vimhelp.appspot.com/mlang.txt.html#%3Amenutrans&quot; rel=&quot;nofollow noreferrer&quot;&gt;:menutrans&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So either set it at the &lt;em&gt;first&lt;/em&gt; line, or don't set it at all.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-09-02T23:36:06.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13463" PostTypeId="1" CreationDate="2017-09-03T03:38:17.273" Score="3" ViewCount="792" Body="&lt;p&gt;Vim8 now has a terminal feature, how can I detect when a terminal is started?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neovim has &lt;code&gt;TermOpen&lt;/code&gt; and &lt;code&gt;TermClose&lt;/code&gt; autocommand events, does vim8 has an equivalent?&lt;/p&gt;&#xA;" OwnerUserId="10798" LastEditorUserId="1841" LastEditDate="2017-09-03T17:22:14.503" LastActivityDate="2017-09-03T17:22:14.503" Title="How to detect terminal enter in vim8" Tags="|terminal|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13464" PostTypeId="1" CreationDate="2017-09-03T06:38:33.123" Score="9" ViewCount="7008" Body="&lt;p&gt;I know in vim I can use :global to execute commands on the matching lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'm wondering if it's possible to execute those commands on every matching pattern, not just lines, consider following example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaa bbb&#xA;aaa ccc aaa ddd ww&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to perform action: &lt;code&gt;normal wdw&lt;/code&gt; on every matching &lt;code&gt;aaa&lt;/code&gt;, so I expect the result to be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaa&#xA;aaa aaa ww&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But with global, it will only do the action once on the 2nd line.&lt;/p&gt;&#xA;" OwnerUserId="1276" LastEditorUserId="467" LastEditDate="2017-09-15T21:33:52.597" LastActivityDate="2023-06-08T17:55:51.290" Title="How to execute command on every matching pattern, not just lines?" Tags="|search|global-command|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13465" PostTypeId="2" ParentId="13464" CreationDate="2017-09-03T07:30:00.193" Score="6" Body="&lt;p&gt;You might be interested by this question: &lt;a href=&quot;https://vi.stackexchange.com/q/9898/12003&quot;&gt;Run a command on every match of a search (not on the line)&lt;/a&gt;. The answer suggests the use of &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;sub-replace-expression&lt;/code&gt;&lt;/a&gt; but this is more adapted when the changes are localized to the matches, and requires you to define a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if the command changes often you would be better off using &lt;strong&gt;macros&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is one way to do it on your snippet, with the explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg/aaa&amp;lt;CR&amp;gt;qqwdwNnq2@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;gg&lt;/code&gt; Go to the top&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/aaa&amp;lt;CR&amp;gt;&lt;/code&gt; Search to go on the first match&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; Start recording a macro into the &lt;code&gt;q&lt;/code&gt; register&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;wdw&lt;/code&gt; Execute your commands, be careful where your cursor lands&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Nn&lt;/code&gt; Needed to put the cursor on the next match every time in this case&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; Stop recording&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2@q&lt;/code&gt; Play two times, or use a recursive macro but mind your &lt;code&gt;&amp;amp;wrapscan&lt;/code&gt; &lt;a href=&quot;https://vi.stackexchange.com/a/13466/12003&quot;&gt;as B Layer explained&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2017-09-03T14:14:00.623" LastActivityDate="2017-09-03T14:14:00.623" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13466" PostTypeId="2" ParentId="13464" CreationDate="2017-09-03T07:34:02.960" Score="6" Body="&lt;p&gt;There's nothing like it mentioned anywhere in repeat.txt (&lt;code&gt;:h repeating&lt;/code&gt;) so one can probably conclude that there's no native support for it.&lt;/p&gt;&#xA;&lt;p&gt;If you're running this on the whole file a &lt;strong&gt;recursive macro&lt;/strong&gt; is a viable approach. Assuming we'll store it in register &lt;strong&gt;q&lt;/strong&gt; the macro is &lt;code&gt;nwdwN@q&lt;/code&gt;. Breaking it down...&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt; - search for the pattern ('aaa' in the question's example)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;wdw&lt;/code&gt; - the base command to be repeated&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;N&lt;/code&gt; - search backwards for the pattern (taking us to same position as the initial &lt;code&gt;n&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@q&lt;/code&gt; - rinse and repeat (this self-referential bit is the &amp;quot;recursive&amp;quot; part)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The following commands will demonstrate how things work.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:let @/ = 'aaa'&lt;/code&gt; : Just as if we'd previously done a search using &lt;code&gt;/aaa&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:let @q = 'nwdwN@q'&lt;/code&gt; : Load the macro into register &lt;strong&gt;q&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gg&lt;/code&gt; : Go to the beginning of the file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@q&lt;/code&gt; : Run the macro.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;em&gt;IMPORTANT: If you have Vim configured to wrap around the end of your file when searching make sure to disable this feature first using &lt;code&gt;:set nowrapscan&lt;/code&gt;. Afterwards, run &lt;code&gt;:set wrapscan&lt;/code&gt; if you wish to re-enable the setting.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="-1" LastEditDate="2021-05-11T01:07:33.350" LastActivityDate="2021-05-11T01:07:33.350" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="13467" PostTypeId="2" ParentId="13464" CreationDate="2017-09-03T12:05:15.343" Score="4" Body="&lt;p&gt;This is job for &lt;code&gt;:substitute&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/pattern\zs\s\+\S\+//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after the pattern (&lt;code&gt;\zs&lt;/code&gt;), I match spaces (&lt;code&gt;\s\+&lt;/code&gt;) followed by any number of non spaces (&lt;code&gt;\S\+&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want &lt;code&gt;dw&lt;/code&gt; and not &lt;code&gt;dW&lt;/code&gt;, you'll prefer &lt;code&gt;\(\k\@!.\)\+\k\+&lt;/code&gt; instead of &lt;code&gt;\s\+\S\+&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-09-03T13:55:21.587" LastActivityDate="2017-09-03T13:55:21.587" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13468" PostTypeId="1" AcceptedAnswerId="13485" CreationDate="2017-09-03T14:42:49.657" Score="4" ViewCount="1304" Body="&lt;p&gt;I have noticed that along with most &lt;code&gt;.spl&lt;/code&gt; files, there is also a &lt;code&gt;.sug&lt;/code&gt; file. As far as I could gather from my search with &lt;code&gt;:help&lt;/code&gt;, this is a file which helps Vim rank suggestions from the &lt;code&gt;.spl&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to search the internet for an explanation of how these &lt;code&gt;.sug&lt;/code&gt; files work, but with no luck.  I have a suspicion, that they have something to do with the numbers that appear if your use &lt;code&gt;:spelldump!&lt;/code&gt; instead of &lt;code&gt;:spelldump&lt;/code&gt; to dump a word list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody tell me how they help rank the suggested words, if this is indeed what they do.  And possibly how one could generate a custom &lt;code&gt;.sug&lt;/code&gt; file if this makes sense to have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I searched the internet most hits I got involved Vim.  Are &lt;code&gt;.sug&lt;/code&gt; files a Vim concept?&lt;/p&gt;&#xA;" OwnerUserId="1498" LastEditorUserId="5395" LastEditDate="2017-09-04T06:50:20.730" LastActivityDate="2017-09-07T19:19:48.033" Title="How does .sug files work, and can you generate them yourself?" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13469" PostTypeId="1" AcceptedAnswerId="13470" CreationDate="2017-09-03T17:55:28.020" Score="1" ViewCount="206" Body="&lt;p&gt;&lt;code&gt;:echo pyeval('vim.current.window.col')&lt;/code&gt; works fine on a normal Neovim instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I start Neovim in diff mode or with the &lt;code&gt;-u NONE&lt;/code&gt; option and try the same command, I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function provider#python#Call:&#xA;line   18:&#xA;NameError(&quot;name 'vim' is not defined&quot;,)&#xA;Traceback (most recent call last):&#xA;  File &quot;/usr/local/lib/python2.7/site-packages/neovim/msgpack_rpc/session.py&quot;, line 181, in handler&#xA;    rv = self._request_cb(name, args)&#xA;  File &quot;/usr/local/lib/python2.7/site-packages/neovim/api/common.py&quot;, line 237, in filter_request_cb&#xA;    walk(self._in, args, self, name, 'request'))&#xA;  File &quot;/usr/local/lib/python2.7/site-packages/neovim/plugin/host.py&quot;, line 69, in _on_request&#xA;    rv = handler(*args)&#xA;  File &quot;/usr/local/lib/python2.7/site-packages/neovim/plugin/script_host.py&quot;, line 148, in python_eval&#xA;    return eval(expr, self.module.__dict__)&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;NameError: name 'vim' is not defined&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea why this is happening? Not sure if this is related to Vim in general or Neovim.&lt;/p&gt;&#xA;" OwnerUserId="7318" LastActivityDate="2017-09-04T00:54:27.213" Title="pyeval not working on vim -u NONE or vim diffs" Tags="|neovim|vimscript-python|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13470" PostTypeId="2" ParentId="13469" CreationDate="2017-09-03T18:09:54.063" Score="2" Body="&lt;p&gt;Thanks to Carpetsmoker's comment, the solution was as simple as doing a&#xA;&lt;code&gt;:python import vim&lt;/code&gt; first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant doc is at &lt;code&gt;:h python-vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7318" LastEditorUserId="7318" LastEditDate="2017-09-04T00:54:27.213" LastActivityDate="2017-09-04T00:54:27.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13471" PostTypeId="1" AcceptedAnswerId="13472" CreationDate="2017-09-03T20:48:16.440" Score="1" ViewCount="1114" Body="&lt;p&gt;Give the following dictionary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mydict = {'foo': {'a': 1, 'b': 2}, 'bar': {'c': 3, 'd': 4}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And a list of keys:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let myfilter = ['foo', 'asdf']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How would one do a &lt;strong&gt;concise&lt;/strong&gt; &quot;left outer join (if null)&quot; or filter and remove any items in &lt;code&gt;mydict&lt;/code&gt; with key in &lt;code&gt;myfilter&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Long&quot; version as a loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for key in myfilter&#xA;    if has_key(mydict, key)&#xA;        call remove(mydict, key)&#xA;    endif&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which would yield:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo mydict&#xA;{'bar': {'c': 3, 'd': 4}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems some combination of &lt;code&gt;filter({expr1}, {expr2})&lt;/code&gt; should do the trick, but haven't been able to come up with a &lt;code&gt;{expr2}&lt;/code&gt; that uses &lt;code&gt;v:key&lt;/code&gt; and successfully returns 0 when defined in &lt;code&gt;myfilter&lt;/code&gt; and otherwise silently errs/return something other than 0.&lt;/p&gt;&#xA;" OwnerUserId="5070" LastEditorUserId="10604" LastEditDate="2021-01-10T23:21:50.143" LastActivityDate="2021-01-10T23:21:50.143" Title="Filter dict items using list of keys" Tags="|vimscript|dictionary|list|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13472" PostTypeId="2" ParentId="13471" CreationDate="2017-09-03T20:48:16.440" Score="5" Body="&lt;p&gt;It's possible to use &lt;code&gt;index({list}, {expr} ..)&lt;/code&gt; for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mydict = {'foo': {'a': 1, 'b': 2}, 'bar': {'c': 3, 'd': 4}}&#xA;let myfilter = ['foo', 'asdf']&#xA;&#xA;call filter(mydict, 'index(myfilter, v:key) == -1')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;index()&lt;/code&gt; returns -1 when &lt;code&gt;{expr}&lt;/code&gt; is not found in &lt;code&gt;{list}&lt;/code&gt; and otherwise the lowest index in &lt;code&gt;{list}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo index(['foo'], 'foo') == -1&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;filter()&lt;/code&gt; removes the item from the List when result of &lt;code&gt;{expr2}&lt;/code&gt; evaluates to 0.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It's also possible to do something similar with dict keys as filter for another dict, but by using &lt;code&gt;has_key({dict}, {key})&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mydict = {'foo': {'a': 1, 'b': 2}, 'bar': {'c': 3, 'd': 4}}&#xA;let myfilter = {'foo': '5', 'asdf': '6'}&#xA;&#xA;call filter(mydict, '!has_key(myfilter, v:key)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;has_key()&lt;/code&gt; returns 1 if &lt;code&gt;{dict}&lt;/code&gt; has an entry with key &lt;code&gt;{key}&lt;/code&gt;, zero otherwise.&lt;/p&gt;&#xA;" OwnerUserId="5070" LastEditorUserId="5070" LastEditDate="2017-09-04T13:54:48.033" LastActivityDate="2017-09-04T13:54:48.033" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13473" PostTypeId="2" ParentId="13425" CreationDate="2017-09-03T21:54:19.197" Score="1" Body="&lt;p&gt;So, user-defined commands &lt;em&gt;must&lt;/em&gt; begin with an uppercase letter. This namespacing rule prevents user-defined commands from trampling built-in vim functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think what I really wanted to do in the above example is define my own command that mimics the look and feel of a built-in command. (begins with a lowercase letter and appears literally in the command history).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to achieve this is to define a user-defined command that's uppercase (like &lt;code&gt;CV&lt;/code&gt;) and have &lt;code&gt;cv&lt;/code&gt; be an abbreviation for that. However, the body of the uppercase command checks if it's being called in command position and expands into the lowercase command (&lt;code&gt;cv&lt;/code&gt;) if it isn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example showing how to do that for my &lt;code&gt;hj&lt;/code&gt; and &lt;code&gt;cv&lt;/code&gt; abbreviations (which just take you to a header or source file in the same directory)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! HJ edit %:r.h&#xA;cnoreabbrev &amp;lt;expr&amp;gt; hj getcmdtype() !=# ':' ? 'hj' : 'HJ'&#xA;command! CV edit %:r.cpp&#xA;cnoreabbrev &amp;lt;expr&amp;gt; cv getcmdtype() !=# ':' ? 'cv' : 'CV'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your history &lt;code&gt;:hj&lt;/code&gt; will still show up as &lt;code&gt;:HJ&lt;/code&gt; when you press up, but the effect isn't nearly as jarring as expanding into &lt;code&gt;:edit %:r.h&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;getcmdtype&lt;/code&gt; expands into a string indicating the context that the command is being invoked in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information on writing commands with &quot;defensive&quot; expansions is here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/11226/resolve-path-to-current-file/11227#11227&quot;&gt;Resolve path to current file&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! CV edit %:r.cpp&#xA;cnoreabbrev &amp;lt;expr&amp;gt; cv CV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is tempting, but a really bad idea. If you type &lt;code&gt;/cv&lt;/code&gt; to search for &lt;code&gt;&quot;cv&quot;&lt;/code&gt;, then the abbreviation will get expanded and your search will become &lt;code&gt;/CV&lt;/code&gt;. This is probably not what you wanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The linked answer also goes into some detail about detecting the &quot;cursor position&quot; when expanding command abbreviations, but I haven't found that necessary (yet).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;getcmdpos() ==# 3&lt;/code&gt; condition (or whatever 1 + the length of the abbreviation is) is actually very important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;hj&lt;/code&gt; and &lt;code&gt;cv&lt;/code&gt; are uncommon enough that they don't often appear as &quot;words&quot; on their own. But if they ever do appear (say you make a &lt;code&gt;foo.hj&lt;/code&gt;) file by mistake, then &lt;code&gt;foo.hj&lt;/code&gt; will get expanded into &lt;code&gt;foo.HJ&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;getcmdtype() !=# ':'&lt;/code&gt; check is not as strict as one might think.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2017-12-06T07:14:45.680" LastActivityDate="2017-12-06T07:14:45.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13474" PostTypeId="2" ParentId="13471" CreationDate="2017-09-04T00:41:37.637" Score="2" Body="&lt;p&gt;If you really want to follow the destructive &lt;code&gt;remove()&lt;/code&gt; path, you could also execute the following convoluted expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo map(copy(myfilter), 'has_key(mydict, v:val) ? remove(mydict, v:val) : mydict')[0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It may be faster with big dictionaries and small list of keys, but honestly, @timss' solution based on &lt;code&gt;filter()&lt;/code&gt; + &lt;code&gt;index()&lt;/code&gt; is the way to go. Both solutions will be much faster than any &lt;code&gt;:for&lt;/code&gt; based solution.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-09-04T00:41:37.637" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13475" PostTypeId="1" AcceptedAnswerId="13476" CreationDate="2017-09-04T05:59:14.190" Score="7" ViewCount="1262" Body="&lt;p&gt;I know that in &lt;code&gt;vim&lt;/code&gt;, &lt;code&gt;map &amp;lt;expr&amp;gt;&lt;/code&gt; allows us to map a key sequence to a new sequence as specified by the return value of an expression. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Wrap()&#xA;    if getline('.') == ''&#xA;        &quot; can I return a &amp;lt;Plug&amp;gt; here?&#xA;        return &quot;Ends an empty line\&amp;lt;cr&amp;gt;&quot;&#xA;    else&#xA;        return &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; Wrap()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the expression, &lt;code&gt;\&amp;lt;cr&amp;gt;&lt;/code&gt; means to return the &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; key. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can also have &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; maps like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Plug&amp;gt;empty &quot;Ends an empty line\&amp;lt;cr&amp;gt;&quot;&#xA;imap &amp;lt;cr&amp;gt; &amp;lt;Plug&amp;gt;empty&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is: if I want to return the &lt;code&gt;&amp;lt;Plug&amp;gt;empty&lt;/code&gt; map only when cursor is in an empty line like in the first example, what should I do?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As @Mass suggested, &lt;strong&gt;the solution is:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Plug&amp;gt;empty &quot;Ends an empty line\&amp;lt;cr&amp;gt;&quot;&#xA;function Wrap()&#xA;    if getline('.') == ''&#xA;        return &quot;\&amp;lt;Plug&amp;gt;empty&quot;&#xA;    else&#xA;        return &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;imap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; Wrap()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last line must use &lt;code&gt;imap&lt;/code&gt; instead of &lt;code&gt;inoremap&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2017-09-05T03:12:06.500" LastActivityDate="2020-05-12T20:11:00.633" Title="return &lt;Plug&gt; in a &lt;expr&gt; map" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13476" PostTypeId="2" ParentId="13475" CreationDate="2017-09-04T06:44:45.533" Score="6" Body="&lt;p&gt;Simply &lt;code&gt;return &quot;\&amp;lt;plug&amp;gt;empty&quot;&lt;/code&gt;  This is doing the same basic thing as &lt;code&gt;&quot;\&amp;lt;cr&amp;gt;&quot;&lt;/code&gt;, returning a string with special characters instead of literal &lt;code&gt;&amp;lt;&lt;/code&gt; &lt;code&gt;c&lt;/code&gt; &lt;code&gt;r&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt; etc. Also ensure your &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; map is not using &lt;code&gt;noremap&lt;/code&gt; so vim uses the &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; remap. (See the last line in the solution below, using &lt;code&gt;imap&lt;/code&gt; instead of &lt;code&gt;inoremap&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Plug&amp;gt;empty &quot;Ends an empty line\&amp;lt;cr&amp;gt;&quot;&#xA;function Wrap()&#xA;    if getline('.') == ''&#xA;        return &quot;\&amp;lt;Plug&amp;gt;empty&quot;&#xA;    else&#xA;        return &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;imap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; Wrap()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="18609" LastEditDate="2020-05-12T20:11:00.633" LastActivityDate="2020-05-12T20:11:00.633" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="13477" PostTypeId="1" CreationDate="2017-09-04T07:07:12.853" Score="1" ViewCount="410" Body="&lt;p&gt;I want to change my &lt;strong&gt;colorscheme&lt;/strong&gt; to the one used by &lt;strong&gt;Github for Ruby&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched for one hour with out any luck. Is the color scheme used by Github open source ? or should I write my own colorscheme inspired by Github's? &lt;/p&gt;&#xA;" OwnerUserId="11395" LastActivityDate="2020-12-10T10:44:55.987" Title="Vim colorscheme similar to Github" Tags="|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13478" PostTypeId="2" ParentId="11668" CreationDate="2017-09-04T07:29:56.077" Score="0" Body="&lt;p&gt;On Windows and Ubuntu, GVim works with &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;Arrow&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11986" LastEditorUserId="11986" LastEditDate="2018-10-11T16:29:34.357" LastActivityDate="2018-10-11T16:29:34.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13479" PostTypeId="2" ParentId="13477" CreationDate="2017-09-04T08:46:25.140" Score="3" Body="&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: There is now a Vim colorscheme based on Github's syntax highlighting as of 2018: &lt;a href=&quot;https://github.com/cormacrelf/vim-colors-github&quot; rel=&quot;nofollow noreferrer&quot;&gt;cormacrelf/vim-colors-github&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I think the closest available is the well known &lt;a href=&quot;https://github.com/endel/vim-github-colorscheme&quot; rel=&quot;nofollow noreferrer&quot;&gt;endel/vim-github-colorscheme&lt;/a&gt;, but it may need some tweaks to suit your taste.&lt;/p&gt;&#xA;&lt;p&gt;Screenshots from the repo:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/744GJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/744GJ.png&quot; alt=&quot;Screenshot 1&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hT9dC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hT9dC.png&quot; alt=&quot;Screenshot 2&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;It seems that GitHub switched from &lt;a href=&quot;http://pygments.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pygments&lt;/a&gt; to &lt;a href=&quot;https://linguist.readthedocs.io/en/latest/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linguist&lt;/a&gt; for syntax highlighting, but it is handled on the server side in both cases. Also check out &lt;a href=&quot;http://rouge.jneen.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Rouge&lt;/a&gt; used on GitLab.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Finally, there is a related question on Stack Overflow: &lt;a href=&quot;https://stackoverflow.com/questions/6246245/using-syntax-highlight-from-github&quot;&gt;Using syntax highlight from GitHub&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2020-12-10T10:44:55.987" LastActivityDate="2020-12-10T10:44:55.987" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="13480" PostTypeId="1" AcceptedAnswerId="13482" CreationDate="2017-09-04T09:33:07.190" Score="10" ViewCount="1342" Body="&lt;p&gt;When I jump to line (&lt;code&gt;:76&lt;/code&gt;) I end up on a fold, but it doesn't open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can quickly unfold the fold and it gets to the right line, but I want to have the fold unfold automatically to save keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way this can be achieved?&lt;/p&gt;&#xA;" OwnerUserId="12905" LastActivityDate="2017-09-04T13:49:59.763" Title="How to make jump to line automatically unfold" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13482" PostTypeId="2" ParentId="13480" CreationDate="2017-09-04T13:49:59.763" Score="12" Body="&lt;p&gt;The &lt;code&gt;foldopen&lt;/code&gt; setting controls which commands will open folds. In &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27foldopen%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'foldopen'&lt;/code&gt;&lt;/a&gt; we can see the list of possible values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            item            commands&#xA;            all             any&#xA;            block           &quot;(&quot;, &quot;{&quot;, &quot;[[&quot;, &quot;[{&quot;, etc.&#xA;            hor             horizontal movements: &quot;l&quot;, &quot;w&quot;, &quot;fx&quot;, etc.&#xA;            insert          any command in Insert mode&#xA;            jump            far jumps: &quot;G&quot;, &quot;gg&quot;, etc.&#xA;            mark            jumping to a mark: &quot;'m&quot;, CTRL-O, etc.&#xA;            percent         &quot;%&quot;&#xA;            quickfix        &quot;:cn&quot;, &quot;:crew&quot;, &quot;:make&quot;, etc.&#xA;            search          search for a pattern: &quot;/&quot;, &quot;n&quot;, &quot;*&quot;, &quot;gd&quot;, etc.&#xA;                            (not for a search pattern in a &quot;:&quot; command)&#xA;                            Also for [s and ]s.&#xA;            tag             jumping to a tag: &quot;:ta&quot;, CTRL-T, etc.&#xA;            undo            undo or redo: &quot;u&quot; and CTRL-R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From reading the documentation you'd expect that &lt;code&gt;set foldopen+=jump&lt;/code&gt; would do the trick, but it doesn't work for &lt;code&gt;:76&lt;/code&gt;, only &lt;code&gt;76G&lt;/code&gt;. I'm not sure if this is intentional or a bug in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;set foldopen=all&lt;/code&gt; &lt;em&gt;does&lt;/em&gt; work correctly; but may have unwanted side-effects (specifically, you can no longer move &quot;over&quot; a fold with &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-09-04T13:49:59.763" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13483" PostTypeId="1" AcceptedAnswerId="13486" CreationDate="2017-09-05T08:45:25.383" Score="1" ViewCount="404" Body="&lt;p&gt;I want to map &lt;code&gt;,&lt;/code&gt; in normal mode to function as autocompleting a word &lt;code&gt;&amp;lt;c-n&amp;gt;&lt;/code&gt; in insert mode. Also, I want to keep pressing &lt;code&gt;,&lt;/code&gt; in normal mode to cycle through the list and then finally when I finish after choosing a word to still stay in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? The only way I can think of is to first map to &lt;code&gt;i&lt;/code&gt; to enter insert mode. But then I don't want &lt;code&gt;i&lt;/code&gt; mapped again in future iterations of &lt;code&gt;,&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="14019" LastActivityDate="2017-09-05T13:49:20.887" Title="Map autocomplete word in normal mode?" Tags="|autocompletion|insert-mode|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13485" PostTypeId="2" ParentId="13468" CreationDate="2017-09-05T12:53:22.560" Score="6" Body="&lt;p&gt;The first hint as to the purpose of these files is &lt;code&gt;:h spell-sug-file&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This file is used&#xA;  to find suggestions by their sound-a-like form quickly.  At the cost&#xA;  of a lot of memory&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are three types of files used in Vim's built-in spell checking tool:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Dictionary&lt;/strong&gt;&#xA;Simple lists of correct/known words that are used to identify spelling errors. Vim scans all words and tries to find each in the configured dictionaries. If a word is not found it can be highlighted as a spelling error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SPL file&lt;/strong&gt;&#xA;These files are used to look up suggested corrections for common mistakes such as &quot;purposeful&quot; misspellings (e.g. &lt;em&gt;suprise&lt;/em&gt; for &lt;em&gt;surprise&lt;/em&gt;) and typos (e.g. &lt;em&gt;teh&lt;/em&gt; for &lt;em&gt;the&lt;/em&gt;). The files contain &lt;em&gt;trie&lt;/em&gt; data structures in binary format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SUG file&lt;/strong&gt;&#xA;These files are used to look up suggested corrections for words that are &quot;sound-alike&quot; or phonetically similar (e.g. &lt;em&gt;funetik&lt;/em&gt; for &lt;em&gt;phonetic&lt;/em&gt;). As noted in the side bar below these suggestions are primarily useful for people who don't know the language well.  Like SPL files, these files contain &lt;em&gt;trie&lt;/em&gt; data structures in binary format. The key values are &quot;soundfolds&quot; which are a kind of normalization of phonetic spellings.  A misspelled word is converted with the &lt;code&gt;soundfold()&lt;/code&gt; function and the result is used to lookup suggestions in the SUG data. There's more information about soundfold/sound-alike conversion and lookup in this &lt;a href=&quot;http://aspell.net/man-html/Phonetic-Code.html&quot; rel=&quot;noreferrer&quot;&gt;Phonetic Code&lt;/a&gt; document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I sussed out most of this from the spell.txt Vim help file but there are also some interesting tidbits in the Vim developer notes at &lt;code&gt;h: develop-spell&lt;/code&gt; and &lt;code&gt;h: develop-spell-suggestions&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some more points of interest:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For some languages, English being a notable exception, these .sug lists can be much larger than their equivalent .spl list. Spanish and Russian are two examples. This is one reason for the warning above about memory usage. &lt;/li&gt;&#xA;&lt;li&gt;The 'sug' file extension is a Vim convention (possibly copied from somewhere else.) The concept of matching phonetic variations is not a Vim innovation.&lt;/li&gt;&#xA;&lt;li&gt;If .spl and .sug files for a language are not installed Vim will try to download them from the Vim ftp server using the Netrw plugin. (English versions are installed by default.) I don't think you'd want to try to generate these yourself.&lt;/li&gt;&#xA;&lt;li&gt;To make use of the phonetic lists you need to set 'spellsuggest' to &lt;em&gt;best&lt;/em&gt; or &lt;em&gt;double&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As for scoring, short of looking at code the best I can do is copy in &lt;code&gt;h: spell-double-scoring&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The 'spellsuggest' option can be used to select &quot;double&quot; scoring.  This&#xA;  mechanism is based on the principle that there are two kinds of spelling&#xA;  mistakes:&lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;&lt;p&gt;You know how to spell the word, but mistype something.  This results in a&#xA;  small editing distance (character swapped/omitted/inserted) and possibly a&#xA;  word that sounds completely different.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;You don't know how to spell the word and type something that sounds right.&#xA;  The edit distance can be big but the word is similar after sound-folding.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;  &#xA;  &lt;p&gt;Since scores for these two mistakes will be very different we use a list&#xA;  for each and mix them.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Side Bar: An interesting aspect of the phonetic lists is that they are mostly useful for non-native speakers of a language since native speakers will not often make mistakes that are phonetically similar while at the same time not the type of error that the normal suggestions identify. On the other hand, non-native speakers that have no idea at all about a word's spelling will often try to &quot;sound it out&quot; and use that spelling. For example, &quot;funetik&quot; in place of &quot;phonetic&quot;. A normal suggestion list is unlikely to get a match on that. &lt;code&gt;:h spell-double-scoring&lt;/code&gt; briefly mentions this differentiation.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-09-07T19:19:48.033" LastActivityDate="2017-09-07T19:19:48.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13486" PostTypeId="2" ParentId="13483" CreationDate="2017-09-05T13:49:20.887" Score="2" Body="&lt;p&gt;The basic strategy is to use an expression mapping and check whether the popup menu is visible to issue the correct keys.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; , :call search('\w\&amp;gt;','cW')&amp;lt;cr&amp;gt;a&amp;lt;c-n&amp;gt;&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; , pumvisible() ? &quot;\&amp;lt;c-n&amp;gt;&quot; : &quot;,&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The normal mapping goes to the end of the word before trying to complete.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-09-05T13:49:20.887" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13488" PostTypeId="2" ParentId="12096" CreationDate="2017-09-06T07:47:54.363" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/12096/mapping-ctrl-caret-in-insert-mode/12112#12112&quot;&gt;Tumbler41&lt;/a&gt; answer is partially incorrect. Use of  &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; is discouraged in favor of &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;, so you should use this line instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;C-^&amp;gt; &amp;lt;C-o&amp;gt;&amp;lt;C-^&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;although both are fine in your case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, for the educational purposes let's consider this example from my old .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F5&amp;gt; :nohl&amp;lt;CR&amp;gt;&#xA;imap &amp;lt;F5&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;F5&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After pressing &lt;kbd&gt;F5&lt;/kbd&gt; two thing will happen beside turning off highlights:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you will exit insert mode&lt;/li&gt;&#xA;&lt;li&gt;cursor moves to the left&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also notice, that pressing &lt;kbd&gt;i&lt;/kbd&gt; to reenter insert mode doesn't move cursor back to the original position, so you need to press &lt;kbd&gt;&amp;rarr;&lt;/kbd&gt; to get it back to where it was before. I personally found it incredibly annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After changing my example to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F5&amp;gt; :nohl&amp;lt;CR&amp;gt;&#xA;imap &amp;lt;F5&amp;gt; &amp;lt;C-o&amp;gt;&amp;lt;F5&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;all of those problems disappear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read more about &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; on the &lt;a href=&quot;http://vim.wikia.com/wiki/Use_Ctrl-O_instead_of_Esc_in_insert_mode_mappings&quot; rel=&quot;nofollow noreferrer&quot;&gt;wiki&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14166" LastActivityDate="2017-09-06T07:47:54.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13491" PostTypeId="1" CreationDate="2017-09-06T10:11:27.527" Score="2" ViewCount="3244" Body="&lt;p&gt;I am using vimwiki on nvim 0.1.7 on Konsole 16.12.3 on Plasma 5.9.5 on Kubuntu 17.04.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wiki text appears bold when it is between two stars. But when between two underscores, it does not appear in italic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same is the case even when I switch the format to markdown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is happening? How do I get to see the italic text?&lt;/p&gt;&#xA;" OwnerUserId="3095" LastEditorUserId="205" LastEditDate="2017-09-07T03:31:13.593" LastActivityDate="2018-01-19T16:55:21.927" Title="No italics in vim" Tags="|neovim|filetype-markdown|plugin-vimwiki|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13492" PostTypeId="2" ParentId="716" CreationDate="2017-09-06T13:21:15.840" Score="0" Body="&lt;p&gt;you can try  &lt;code&gt;go&lt;/code&gt; , also you can add a new keymapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just map &lt;code&gt;gg&lt;/code&gt; key to do this,  here is my config&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call NERDTreeAddKeyMap({&#xA;        \ 'key': 'gg',&#xA;        \ 'callback': 'NERDTreeOpenHandler',&#xA;        \ 'quickhelpText': 'open in current tab',&#xA;        \ 'scope': 'FileNode' })&#xA;&#xA;func! NERDTreeOpenHandler(node)&#xA;    call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1})&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;English is not my mother tongue; please excuse any errors on my part.&lt;/p&gt;&#xA;" OwnerUserId="14171" LastEditorUserId="14171" LastEditDate="2017-09-06T13:37:52.707" LastActivityDate="2017-09-06T13:37:52.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13494" PostTypeId="1" AcceptedAnswerId="13496" CreationDate="2017-09-06T14:38:46.113" Score="4" ViewCount="2312" Body="&lt;p&gt;Is there some built in functionality in Vim to merge the contents of two registers into a single register by appending the two?&lt;/p&gt;&#xA;" OwnerUserId="2082" LastEditorUserId="1841" LastEditDate="2017-09-06T14:56:18.137" LastActivityDate="2017-11-20T11:20:54.663" Title="How to concatenate two registers?" Tags="|register|string-manipulation|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13495" PostTypeId="2" ParentId="13494" CreationDate="2017-09-06T14:42:08.793" Score="3" Body="&lt;p&gt;Let's say you want to merge &lt;code&gt;&quot;a&lt;/code&gt; and &lt;code&gt;&quot;b&lt;/code&gt; into &lt;code&gt;&quot;c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setreg('c', getreg('a').getreg('b'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can of course replace &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt; and &lt;code&gt;c&lt;/code&gt; by whatever register you want.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For a bit more of details:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;getreg('x')&lt;/code&gt; will return the content of the register &lt;code&gt;x&lt;/code&gt; as a string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vim you can concatenate two strings with &lt;code&gt;.&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let str1 = 'foo'&#xA;let str2 = 'bar'&#xA;let result = str1 . str2&#xA;&quot; result is equal to 'foobar'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus &lt;code&gt;getreg('a').getreg('b')&lt;/code&gt; concatenate the content of registers &lt;code&gt;&quot;a&lt;/code&gt; and &lt;code&gt;&quot;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally &lt;code&gt;setreg()&lt;/code&gt; allows you set the content of a register.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See the doc for more details:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getreg%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getreg()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#setreg%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h setreg()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-09-06T14:42:08.793" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13496" PostTypeId="2" ParentId="13494" CreationDate="2017-09-06T15:43:57.393" Score="7" Body="&lt;p&gt;It is not exactly clear what you would like to happen when e.g. one register contains a linewise selection and the other one contains a block selection. But for the easy case, you can always do (as noted in a comment)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @c=@a.@b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and have the concatenation of register a and b in register c. But note, this might have funny effects, if the registers contain blockwise selections (or one register is of a different type than the other).&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2017-09-07T05:19:51.457" LastActivityDate="2017-09-07T05:19:51.457" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13497" PostTypeId="2" ParentId="13494" CreationDate="2017-09-06T15:44:51.333" Score="3" Body="&lt;p&gt;When registers only contain strings, we can do it with the old &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @c = @a . @b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to handle the registers as lists (one element per line), then you'll need to use the new functions described by @statox, but beware, lists are concatenated with &lt;code&gt;+&lt;/code&gt;, not &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg('c', getreg('a', 1, 1) + getreg('b', 1, 1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-09-06T15:44:51.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13498" PostTypeId="1" CreationDate="2017-09-06T18:03:20.103" Score="1" ViewCount="441" Body="&lt;p&gt;I have a tricky problem and don't know how to solve it. I use &lt;code&gt;map&lt;/code&gt; to declare a shortcut key for the gradle test below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-S-F10&amp;gt; &amp;lt;Esc&amp;gt;:wa&amp;lt;CR&amp;gt;:let last_test = expand(&quot;%&quot;)&amp;lt;CR&amp;gt;&amp;lt;S-F10&amp;gt;&#xA;map &amp;lt;S-F10&amp;gt; &amp;lt;Esc&amp;gt;:wa&amp;lt;CR&amp;gt;:call OpenWindow('tests')&amp;lt;CR&amp;gt;:%d&amp;lt;CR&amp;gt;:call RunTests(last_test)&amp;lt;CR&amp;gt;&#xA;&#xA;fun! RunTests(...)&#xA;  if(a:0 == 0)&#xA;    silent .!./gradlew test&#xA;  else&#xA;    execute &quot;silent&quot; &quot;.!./gradlew test --tests '*&quot;.a:1.&quot;'&quot;&#xA;  endif&#xA;endfun&#xA;&#xA;fun! OpenWindow(bufname)&#xA;  let winid = bufwinid(a:bufname)&#xA;  if(winid != -1) &quot;buff window is not closed&#xA;    call win_gotoid(winid)&#xA;    return&#xA;  endif&#xA;&#xA;  let absent = ! bufexists(a:bufname)&#xA;  execute &quot;new &quot;.a:bufname&#xA;  &quot;move window to bottom&#xA;  let n = winnr('$') - winnr()&#xA;  execute n.'wincmd r'&#xA;&#xA;  if(absent) &quot;set options &amp;amp; map for new buffer&#xA;    set bufhidden=hide buftype=nofile nobuflisted noswapfile&#xA;    map &amp;lt;buffer&amp;gt; q &amp;lt;Esc&amp;gt;:q&amp;lt;CR&amp;gt;&#xA;  endif&#xA;&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press &lt;code&gt;&amp;lt;C-S-F10&amp;gt;&lt;/code&gt; this behavior is what I want:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First, if the tests buffer does not exist, then create a new buffer named tests, otherwise open/focus the window for the existing tests buffer.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Next, clear the last test result in tests buffer by &lt;code&gt;%d&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finally, execute &lt;code&gt;RunTests&lt;/code&gt; and fill the result of &lt;code&gt;!./gradlew test&lt;/code&gt; into &lt;code&gt;tests&lt;/code&gt; buffer.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But when I went to refactor the mapping as below, the behavior is not what I want. All of the steps above will not be done until the bash script is done. How can I make my &lt;code&gt;OpenRunTests&lt;/code&gt; execute the behavior like the mapping?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-F10&amp;gt; &amp;lt;Esc&amp;gt;:wa&amp;lt;CR&amp;gt;:silent OpenWinAndRunTests()&amp;lt;CR&amp;gt;&#xA;&#xA;fun! OpenWinAndRunTests()&#xA;  call OpenWindow(&quot;tests&quot;)&#xA;  %d  &quot;clear buffer is not done until the shell command finished, how can I fix it?&#xA;  call RunTests(g:last_test)&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14099" LastEditorUserId="5298" LastEditDate="2017-09-06T22:02:25.193" LastActivityDate="2017-09-07T23:18:46.587" Title="How can I execute bash command in a function like as map?" Tags="|vimscript|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13499" PostTypeId="2" ParentId="13498" CreationDate="2017-09-06T19:27:06.397" Score="1" Body="&lt;p&gt;I would recommend using a full range with you filter command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%!./gradlew test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I have some other thoughts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You may want to look into use &lt;code&gt;:make&lt;/code&gt; and the quickfix list (&lt;a href=&quot;https://github.com/mearns/vim-gradle&quot; rel=&quot;nofollow noreferrer&quot;&gt;gradle compiler plugin&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;You could &lt;code&gt;:bwipe&lt;/code&gt; the buffer and opening a new one&lt;/li&gt;&#xA;&lt;li&gt;I would recommend supplying a mode with your &lt;code&gt;map&lt;/code&gt;'s. e.g. &lt;code&gt;nmap&lt;/code&gt; (Use &lt;code&gt;noremap&lt;/code&gt; if possible)&lt;/li&gt;&#xA;&lt;li&gt;May want to use &lt;code&gt;wincmd J&lt;/code&gt; instead of rotating the window down&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Personally I would recommend you look into &lt;code&gt;:make&lt;/code&gt; and the quickfix list. Using &lt;code&gt;:make&lt;/code&gt; allows for you to collect your errors up into a list known as the quickfix list. Open the quickfix list in a window via &lt;code&gt;:copen&lt;/code&gt;. Using the quickfix you can navigate between the errors in your files, so you are jumping right to where the compiler/linter/test runner says the error is (handy right?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :range&#xA;:h :make&#xA;:h quickfix&#xA;:h :compiler&#xA;:h 'errorformat'&#xA;:h 'makeprg'&#xA;:h :copen&#xA;:h :wincmd&#xA;:h CTRL-W_J&#xA;:h :bw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-09-06T21:13:20.003" LastActivityDate="2017-09-06T21:13:20.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13500" PostTypeId="2" ParentId="2199" CreationDate="2017-09-06T22:43:08.237" Score="0" Body="&lt;p&gt;For an en dash a digraph is the best way to go, as suggested in various other answers. But for arbitrary unicode characters, another way is to use &lt;code&gt;^V&lt;/code&gt; in insert mode (see &lt;code&gt;:he i_CTRL-V_digit&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an en dash that'd be for example &lt;code&gt;^Vu2013&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7814" LastActivityDate="2017-09-06T22:43:08.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13501" PostTypeId="1" CreationDate="2017-09-07T05:17:53.907" Score="3" ViewCount="365" Body="&lt;p&gt;With the &lt;code&gt;:jumps&lt;/code&gt; command, you can display the list of jump locations to aid navigation. That is you can use &lt;code&gt;CTRL_O&lt;/code&gt; and &lt;code&gt;CTRL_I&lt;/code&gt; to jump backwards and forwards respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, my jump lists appear to be very long. When I execute the &lt;code&gt;:jumps&lt;/code&gt; command, my jumps are displayed with the &lt;code&gt;-- More --&lt;/code&gt; prompt at the bottom. How do I navigate/scroll through this information?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that I'm using &lt;code&gt;G&lt;/code&gt; to move to the bottom of the list, but when I then re-enter normal mode, the next key I press begins macro recording (perhaps this is an issue with one of the plugins I am using).&lt;/p&gt;&#xA;" OwnerUserId="10101" LastActivityDate="2017-10-07T06:05:55.647" Title="How do you page through the jump list?" Tags="|scrolling|navigation|jumplist|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13502" PostTypeId="2" ParentId="13501" CreationDate="2017-09-07T05:20:16.727" Score="1" Body="&lt;p&gt;I realised the information is available in the &lt;code&gt;:help more-prompt&lt;/code&gt; section.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think a plugin might be causing auto-macro recording.&lt;/p&gt;&#xA;" OwnerUserId="10101" LastActivityDate="2017-09-07T05:20:16.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13504" PostTypeId="2" ParentId="13498" CreationDate="2017-09-07T11:23:08.997" Score="1" Body="&lt;p&gt;The trick is whenever execute bash command will prevent vim redrawing screen. Actually, it wasn't blocked until the bash command done. So I only need to redraw the screen before execute bash. for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;    v--- redraw the screen before run `./gradlew test`&#xA;%d | redraw | silent .!./gradlew test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The advantage of clear buffer before execute hash is that I can know exactly that the bash whether is done, since I only can see a blank buffer view when the bash is in progress. &lt;/p&gt;&#xA;" OwnerUserId="14099" LastEditorUserId="14099" LastEditDate="2017-09-07T23:18:46.587" LastActivityDate="2017-09-07T23:18:46.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13505" PostTypeId="1" AcceptedAnswerId="13506" CreationDate="2017-09-07T15:07:48.627" Score="20" ViewCount="24035" Body="&lt;p&gt;&lt;code&gt;:help nvim-from-vim&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;create &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt; with these contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath+=~/.vim,~/.vim/after&#xA;set packpath+=~/.vim&#xA;source ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If your system sets &lt;code&gt;$XDG_CONFIG_HOME&lt;/code&gt;, use that instead of &lt;code&gt;~/.config&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But those paths aren't correct for Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim for Windows reads from &lt;code&gt;~/_vimrc&lt;/code&gt; on startup. What's the corresponding file for Neovim?&lt;/p&gt;&#xA;" OwnerUserId="13438" LastActivityDate="2017-09-07T15:07:48.627" Title="Where do I put my &quot;vimrc&quot; file for Neovim on Windows?" Tags="|vimrc|neovim|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13506" PostTypeId="2" ParentId="13505" CreationDate="2017-09-07T15:07:48.627" Score="21" Body="&lt;p&gt;Neovim looks for &lt;code&gt;~\AppData\Local\nvim\init.vim&lt;/code&gt; to run at startup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to create the suggested &lt;code&gt;init.vim&lt;/code&gt; from &lt;code&gt;:help nvim-from-vim&lt;/code&gt;, save the following instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath+=~/vimfiles,~/vimfiles/after&#xA;set packpath+=~/vimfiles&#xA;source ~/_vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can save all your settings to &lt;code&gt;~\_vimrc&lt;/code&gt; just like you did with Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vi.stackexchange.com/a/12596/13438&quot;&gt;this answer&lt;/a&gt; and &lt;code&gt;:help vimrc&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="13438" LastActivityDate="2017-09-07T15:07:48.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13507" PostTypeId="1" AcceptedAnswerId="13508" CreationDate="2017-09-07T16:16:14.823" Score="4" ViewCount="444" Body="&lt;p&gt;I would like to map &lt;code&gt;,&lt;/code&gt; to have the same effect as typing &lt;code&gt;:b &amp;lt;Tab&amp;gt;&lt;/code&gt; in Vim; that is, have the &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; trigger the commandline completion to show all buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;nnoremap , :b &amp;lt;tab&amp;gt;&lt;/code&gt; but I get &lt;code&gt;^I&lt;/code&gt; in the commandline, instead of triggering the completion.&lt;/p&gt;&#xA;" OwnerUserId="14019" LastEditorUserId="14019" LastEditDate="2017-09-07T17:04:12.073" LastActivityDate="2017-09-07T17:04:12.073" Title="How can I trigger commandline tab-completion from a mapping?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13508" PostTypeId="2" ParentId="13507" CreationDate="2017-09-07T17:03:40.943" Score="5" Body="&lt;p&gt;This is the expected behaviour; otherwise you'd have the reverse problem: you wouldn't be able to enter a &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; character in the commandline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have to use the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#feedkeys%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;feedkeys()&lt;/code&gt;&lt;/a&gt; function to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call feedkeys(&quot;:b \&amp;lt;Tab&amp;gt;&quot;, 'tn')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;t&lt;/code&gt; flag in the second argument does the trick; this tells &lt;code&gt;feedkey()&lt;/code&gt; to handle keys as if they're typed by the user. See the help page for more information on that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To map it, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap , :call feedkeys(&quot;:b \&amp;lt;Tab&amp;gt;&quot;, 'tn')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-09-07T17:03:40.943" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13509" PostTypeId="1" CreationDate="2017-09-07T17:22:15.543" Score="4" ViewCount="555" Body="&lt;p&gt;I have the following configuration setting, blatantly stolen from &lt;code&gt;vim-sensible&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; use magical ; option&#xA;if has('path_extra')&#xA;    setglobal tags-=./tags tags^=./tags;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suspect what it does is remove the default &lt;code&gt;./tags&lt;/code&gt; entry for tags files and instead find any tags file that's in &lt;code&gt;.&lt;/code&gt;, &lt;code&gt;..&lt;/code&gt;, &lt;code&gt;../..&lt;/code&gt;, &amp;amp;c.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially I thought that it would pick out only a single tags file, but that is not what it does. Instead it picks out EVERY tags file in &lt;code&gt;.&lt;/code&gt;, &lt;code&gt;..&lt;/code&gt;, &lt;code&gt;../..&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use a script to generate a tags file for the toplevel project and use the same script to generate another one for the area I mainly work in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;project&#xA;├── myfolder&#xA;│   └── tags&#xA;└── tags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I'm &quot;in&quot; the myfolder directory, I would like to pick out just the &lt;code&gt;project/myfolder/tags&lt;/code&gt; file ... otherwise I have problems with duplicate entries. It also kind of defeats the purpose of having a tags file for a subfolder, which is to &quot;narrow&quot; the identifiers that the ctags mechanism is aware of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess my question is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there a simple, well-supported way to work with &quot;hierarchically organized&quot; tags files?&lt;/li&gt;&#xA;&lt;li&gt;What kind of workflow is the magical semicolon-path feature designed to support?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2017-09-07T21:48:33.393" LastActivityDate="2019-12-15T22:06:18.567" Title="use only &quot;closest&quot; tagfile to working directory (of buffer or of vim process)" Tags="|ctags|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13510" PostTypeId="1" CreationDate="2017-09-07T23:07:46.683" Score="2" ViewCount="229" Body="&lt;p&gt;How would I formulate a search pattern for matching &lt;code&gt;if&lt;/code&gt; statements that don't have an opening curly brace on the next line?  I assume it requires the use of something like &lt;code&gt;[^{]&lt;/code&gt; or &lt;code&gt;\@!&lt;/code&gt;, but I'm having trouble getting things to work correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if(some_condition)&#xA;        return;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but not:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if(some_condition)&#xA;    {&#xA;        return;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;{&lt;/code&gt; may be indented one or more levels and I think trying to account for the indentation is what's causing my problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first attempt was to use this pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(.*\n\s*[^{]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works if things aren't indented, but once they are it matches any &lt;code&gt;if&lt;/code&gt; statement regardless of whether the first non-white space character on the next line is a &lt;code&gt;{&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2017-10-08T15:15:50.127" Title="Search pattern for an if statement that isn't followed by curly brace on the next line" Tags="|search|regular-expression|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13511" PostTypeId="2" ParentId="13510" CreationDate="2017-09-07T23:15:13.073" Score="1" Body="&lt;p&gt;Of course just before clicking the submit button, I thought of a way to do it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^\(\s*\)\zsif(.*\ze\n\1[^{]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works by capturing any white space before the &lt;code&gt;if&lt;/code&gt; and searching for the same amount of white space at the start of the next line (using &lt;code&gt;\1&lt;/code&gt;).  Note that this assumes that the white space before the &lt;code&gt;{&lt;/code&gt; exactly matches the white space before the &lt;code&gt;if&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; just limit the highlighting to the actual &lt;code&gt;if&lt;/code&gt; line.&lt;/p&gt;&#xA;" OwnerUserId="1115" LastEditorUserId="1115" LastEditDate="2017-09-08T14:47:30.637" LastActivityDate="2017-09-08T14:47:30.637" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13512" PostTypeId="1" AcceptedAnswerId="13534" CreationDate="2017-09-08T03:32:03.387" Score="8" ViewCount="1203" Body="&lt;p&gt;Is there a way to list the buffers specific to the tab that is open currently in vim or macvim?&lt;/p&gt;&#xA;" OwnerUserId="12605" LastEditorUserId="51" LastEditDate="2017-09-08T08:03:10.180" LastActivityDate="2020-06-03T07:30:19.863" Title="Limit buffer list to current tab" Tags="|buffers|tabbed-user-interface|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13514" PostTypeId="2" ParentId="13512" CreationDate="2017-09-08T10:18:26.183" Score="6" Body="&lt;p&gt;The following code will give you the file names for the current tab (if the buffer in a window is connected to a file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Get the buffer numbers of all windows on the current tab&#xA;let buffers = tabpagebuflist(tabpagenr())&#xA;&quot; Get the name of each buffer&#xA;let buffernames = map(copy(buffers), {key, val -&amp;gt; bufname(val)})&#xA;&quot; Print the buffer names&#xA;echo buffernames&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This needs a sufficiently new version of Vim, which supports lamdas.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastEditorUserId="2636" LastEditDate="2017-09-08T11:25:53.410" LastActivityDate="2017-09-08T11:25:53.410" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13515" PostTypeId="1" AcceptedAnswerId="13519" CreationDate="2017-09-08T14:04:26.570" Score="10" ViewCount="1548" Body="&lt;p&gt;When working with larger or rather deeply nested yaml files (Hi Rails), it happens quickly that I loose sight of where I am with regards to the indentation hierarchy of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A very simple example to illustrate my point:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1| en:&#xA;2|   activerecord:&#xA;3|     errors:&#xA;4|       messages:&#xA;5|         parse_error: is syntactically not correct&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the cursor is on the line 5, I would like to somehow get the info&lt;br&gt;&#xA;&lt;code&gt;en -&amp;gt; activerecord -&amp;gt; errors -&amp;gt; messages -&amp;gt; parse_error&lt;/code&gt;&#xA;via a command or the likes.&lt;/p&gt;&#xA;" OwnerUserId="14202" LastEditorUserId="14202" LastEditDate="2017-09-12T09:54:29.303" LastActivityDate="2020-12-08T03:38:57.610" Title="How to show the current location in a yaml hierarchy" Tags="|navigation|filetype-yaml|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13516" PostTypeId="1" AcceptedAnswerId="13517" CreationDate="2017-09-08T15:02:40.203" Score="6" ViewCount="3027" Body="&lt;p&gt;I mostly use Vim to edit configuration files so I understand why it starts in &lt;strong&gt;normal mode&lt;/strong&gt;. But I also use &lt;em&gt;vi mode&lt;/em&gt; for the REPL (bash, zsh, ipython, etc.) and the shell always starts in &lt;strong&gt;insert mode&lt;/strong&gt; (this makes sense because you just want to start typing a command).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the same reason, when I open a new empty file &lt;code&gt;vim foo.txt&lt;/code&gt;, I want to be in insert mode. So I'm looking for a &lt;em&gt;vimrc&lt;/em&gt; function that checks if the file is empty and then put me in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this way I can be consistent across the terminal. When there aren't text objects I know I'm in insert mode.&lt;/p&gt;&#xA;" OwnerUserId="14203" LastEditorUserId="14203" LastEditDate="2017-09-08T17:18:28.420" LastActivityDate="2019-05-18T02:10:06.713" Title="Start Vim in insert mode for new files" Tags="|vimrc|autocmd|insert-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13517" PostTypeId="2" ParentId="13516" CreationDate="2017-09-08T15:15:18.970" Score="13" Body="&lt;p&gt;You need to add this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile * startinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The autocommand creates a command which is executed on a specific event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the event is &lt;code&gt;BufNewFile&lt;/code&gt; the doc descibes it has:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When starting to edit a file that doesn't&#xA;                exist.  Can be used to read in a skeleton&#xA;                file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;*&lt;/code&gt; is here to execute the command on every new file (not a specific filetype or name)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the command to be executed is &lt;code&gt;startinsert&lt;/code&gt; which starts insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it will also work for new files edited from vim with &lt;code&gt;e foo.txt&lt;/code&gt; for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd%2devents&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h autocmd-events&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#BufNewFile&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h BufNewFile&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#%3astartinsert&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :startinsert&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-09-08T15:20:30.353" LastActivityDate="2017-09-08T15:20:30.353" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13518" PostTypeId="1" AcceptedAnswerId="13524" CreationDate="2017-09-08T19:05:59.107" Score="3" ViewCount="5555" Body="&lt;p&gt;How do you configure vim to prompt for deletion of swap files even if it believes another instance of vim may still be using the file? I still want to see the warning message ... just also have the option to delete the file and overrule vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The option below, for instance, doesn't have the &lt;code&gt;(D)elete&lt;/code&gt; option. (where &lt;code&gt;program.cc&lt;/code&gt; may potentially be modified by another vim instance)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(1) Another program may be editing the same file.  If this is the case,&#xA;    be careful not to end up with two different instances of the same&#xA;    file when making changes.  Quit, or continue with caution.&#xA;(2) An edit session for this file crashed.&#xA;    If this is the case, use &quot;:recover&quot; or &quot;vim -r program.cc&quot;&#xA;    to recover the changes (see &quot;:help recovery&quot;).&#xA;    If you did this already, delete the swap file &quot;program.swp&quot;&#xA;    to avoid this message.&#xA;&#xA;Swap file &quot;program.cc.swp&quot; already exists!&#xA;[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2019-11-22T17:40:48.337" Title="Force prompt for whether to delete a swap file" Tags="|swap-file|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13519" PostTypeId="2" ParentId="13515" CreationDate="2017-09-08T20:00:26.183" Score="7" Body="&lt;p&gt;The right way to do it would be to use an external program if the markup language presents a complex structure or particular edge cases, like the bunch of tools you can find for JSON.&lt;/p&gt;&#xA;&lt;p&gt;&lt;s&gt;Though YAML seems to be pretty straightforward&lt;/s&gt; Even if YAML seems to be &lt;a href=&quot;https://arp242.net/weblog/yaml_probably_not_so_great_after_all.html#its-pretty-complex&quot; rel=&quot;nofollow noreferrer&quot;&gt;pretty complex&lt;/a&gt;, I started with a one liner working on your snippet to end up with this Vim script you could place in &lt;code&gt;ftplugin/yaml.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! YAMLTree()&#xA;    let l:list = []&#xA;    let l:cur = getcurpos()[1]&#xA;    &amp;quot; Retrieve the current line indentation&#xA;    let l:indent = indent(l:cur) + 1&#xA;    &amp;quot; Loop from the cursor position to the top of the file&#xA;    for l:n in reverse(range(1, l:cur))&#xA;        let l:i = indent(l:n)&#xA;        let l:line = getline(l:n)&#xA;        let l:key = substitute(l:line, '^\s*\(\&amp;lt;\w\+\&amp;gt;\):.*', &amp;quot;\\1&amp;quot;, '')&#xA;        &amp;quot; If the indentation decreased and the pattern matched&#xA;        if (l:i &amp;lt; l:indent &amp;amp;&amp;amp; l:key !=# l:line)&#xA;            let l:list = add(l:list, l:key)&#xA;            let l:indent = l:i&#xA;        endif&#xA;    endfor&#xA;    let l:list = reverse(l:list)&#xA;    echo join(l:list, ' -&amp;gt; ')&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;F5&amp;gt; :call YAMLTree()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It loops on each line from the cursor to the top looking for a word &lt;code&gt;\w+&lt;/code&gt; between zero or more spaces &lt;code&gt;\s*&lt;/code&gt; and a colon &lt;code&gt;:&lt;/code&gt;, followed by anything. It also checks for indentation to recognize the keys hierarchy.&lt;/p&gt;&#xA;&lt;p&gt;P.S. My first thought was about indent highlighting plugins like &lt;a href=&quot;https://github.com/Yggdroot/indentLine&quot; rel=&quot;nofollow noreferrer&quot;&gt;indentLine&lt;/a&gt; or &lt;a href=&quot;https://github.com/nathanaelkane/vim-indent-guides&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-indent-guides&lt;/a&gt;. That's something  I initially missed on Vim, but I think the heavy slow-down it can cause cured me.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2020-12-08T03:38:57.610" LastActivityDate="2020-12-08T03:38:57.610" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="13520" PostTypeId="1" AcceptedAnswerId="13523" CreationDate="2017-09-08T20:28:13.197" Score="2" ViewCount="1370" Body="&lt;p&gt;I am totally new to using Vim, and I have been trying out SpaceVim so far. One issue is with keybindings. So I have the Vimtex and Vim-Latex plugins installed. I want to use the compilation option from Vimtex because it automatically uses the &lt;code&gt;latexmk&lt;/code&gt; program to compile my latex code. But, right now the Vim-Latex keybindings is mapped to the &lt;code&gt;&amp;lt;Leader&amp;gt;ll&lt;/code&gt; keybinding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added the following command to the bottom of my &lt;code&gt;init.vim&lt;/code&gt; file, as suggested in a different stackexchange post:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/756/how-can-i-redefine-plugin-key-mappings&quot;&gt;How can I redefine plugin key mappings?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the command I used.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; autocmd VimEnter * noremap \ll VimtexCompile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But for some reason this does not change the keybinding. I am still getting the old keybindings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that this keybinding is attached to the &lt;code&gt;Latex&lt;/code&gt; mode in vim, since this keybinding will only work when it is in a latex file window. Unfortunately each time I currently press the &lt;code&gt;\ll&lt;/code&gt; key, I get thrown into the compiler error log. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="14207" LastEditorUserId="14207" LastEditDate="2017-09-08T20:53:11.907" LastActivityDate="2017-09-08T21:13:54.667" Title="spacevim remapping of plugin keybindings" Tags="|neovim|filetype-tex|plugin-vim-latex|spacevim|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13521" PostTypeId="1" AcceptedAnswerId="13525" CreationDate="2017-09-08T21:06:27.080" Score="1" ViewCount="73" Body="&lt;p&gt;Recently I found this question: &lt;a href=&quot;https://vi.stackexchange.com/questions/13430/is-it-possible-to-map-one-key-to-two-commands-doing-2nd-command-only-if-first-f&quot;&gt;Is it possible to map one key to two commands, doing 2nd command only if first fails&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's working well, but I'd like it to work this way: when &lt;code&gt;Alt-l&lt;/code&gt; is pressed, do &lt;code&gt;ctrl-w&lt;/code&gt; &lt;code&gt;l&lt;/code&gt;, but only when there is another window to the right. Otherwise, do &lt;code&gt;gt&lt;/code&gt;. Same applies to &lt;code&gt;alt-h&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/A5wOI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/A5wOI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this even possible? I can't find any {expr}'s that would could allow me to do such things &lt;/p&gt;&#xA;" OwnerUserId="14021" LastEditorUserId="51" LastEditDate="2017-09-08T21:54:35.937" LastActivityDate="2017-09-08T21:54:35.937" Title="Getting tab and windows movement with one key combination" Tags="|key-bindings|vimscript|vim-windows|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13523" PostTypeId="2" ParentId="13520" CreationDate="2017-09-08T21:13:54.667" Score="3" Body="&lt;p&gt;Disclaimer: I'm the author of vimtex.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You should not use both vimtex and vim-latex at the same time. They are filetype plugins that try to implement the same set of features, at least partially. For some more information about the difference between the plugins, you can read some of the answers here:&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/2047/what-are-the-differences-between-latex-plugins&quot;&gt;What are the differences between LaTeX plugins?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, it &lt;em&gt;is&lt;/em&gt; possible to use both plugins at the same time. You could disable the vimtex mappings with the option &lt;code&gt;g:vimtex_mappings_enabled&lt;/code&gt;. Then, you could map your desired keys to the specific commands that you want. I prefer to do such things in my own custom &lt;code&gt;ftplugin/tex.vim&lt;/code&gt; files (or similar for other filetypes), but you can also use an autocmd such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType tex nnoremap &amp;lt;leader&amp;gt;ll :VimtexCompile&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To sum up: I recommend that you use either vimtex or vim-latex, not both. If you invest some time, I think you will find that vimtex should provide all or most of the useful features from vim-latex, as well as a lot of other useful features. Further, some or most of the other features are left out because other more dedicated plugins should be used instead. As an example, you should look into Ultisnips or neosnippet for insert mode mappings that trigger &quot;templates&quot;. See &lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L157&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h vimtex-non-features&lt;/code&gt;&lt;/a&gt; (the link points to the master version of the docs, and so the line number may change in the future).&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-09-08T21:13:54.667" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13524" PostTypeId="2" ParentId="13518" CreationDate="2017-09-08T21:17:21.887" Score="8" Body="&lt;p&gt;The &quot;Delete it&quot; option isn't displayed if the Vim process is still running; I can't find this documented anywhere but I looked it up in the source code; from &lt;code&gt;memline.c&lt;/code&gt;, line 4512 (slightly simplified):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;do_dialog(&#xA;    [..]&#xA;    process_still_running&#xA;        ? (char_u *)_(&quot;&amp;amp;Open Read-Only\n&amp;amp;Edit anyway\n&amp;amp;Recover\n&amp;amp;Quit\n&amp;amp;Abort&quot;) :&#xA;          (char_u *)_(&quot;&amp;amp;Open Read-Only\n&amp;amp;Edit anyway\n&amp;amp;Recover\n&amp;amp;Delete it\n&amp;amp;Quit\n&amp;amp;Abort&quot;), [..]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The swap file embeds the process ID which created it, and if a process with that PID still exists it considers the process to be &quot;running&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The swap message should display this information:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E325: ATTENTION&#xA;Found a swap file by the name &quot;~/.vim/tmp/swap/swapy.swp&quot;&#xA;          owned by: martin   dated: Fri Sep  8 22:13:35 2017&#xA;         file name: ~martin/swapy&#xA;          modified: no&#xA;         user name: martin   host name: arch.arp242.net&#xA;        process ID: 17355 (still running)&#xA;While opening file &quot;swapy&quot;&#xA;             dated: Fri Sep  8 22:13:35 2017&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;process ID: 17355 (still running)&lt;/code&gt; line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The most likely scenario is that you have another Vim instance running somewhere :-) You could &lt;code&gt;kill&lt;/code&gt; it if you can't find it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a &lt;em&gt;small&lt;/em&gt; chance that the PID got re-used by another process though, in which case your only option is to quit Vim, manually remove the swap file, and restart it again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ rm ~/.vim/tmp/swap/swapy.swp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-09-08T21:17:21.887" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13525" PostTypeId="2" ParentId="13521" CreationDate="2017-09-08T21:26:58.270" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;winnr()&lt;/code&gt; function to get the current window number and then try to execute your mapping &lt;code&gt;&amp;lt;c-w&amp;gt;l&lt;/code&gt; in this case. If the window number doesn't change then execute your other mapping, &lt;code&gt;gt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:trywincmd(win, other)&#xA;  let winnr = winnr()&#xA;  execute 'silent! normal! ' . a:win&#xA;  if winnr() == winnr&#xA;    execute 'silent! normal! ' . a:other&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;c-w&amp;gt;l :call &amp;lt;SID&amp;gt;trywincmd(&quot;\&amp;lt;lt&amp;gt;c-w&amp;gt;l&quot;, &quot;gt\&amp;lt;lt&amp;gt;c-w&amp;gt;t&quot;)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;c-w&amp;gt;h :call &amp;lt;SID&amp;gt;trywincmd(&quot;\&amp;lt;lt&amp;gt;c-w&amp;gt;h&quot;, &quot;gT\&amp;lt;lt&amp;gt;c-w&amp;gt;t&quot;)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: Because this is a mapping we need escape &lt;code&gt;&amp;lt;&lt;/code&gt; as the &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt; key-code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h keycodes&#xA;:h winnr()&#xA;:h execute&#xA;:h :normal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-09-08T21:26:58.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13527" PostTypeId="2" ParentId="13183" CreationDate="2017-09-09T10:38:47.443" Score="3" Body="&lt;p&gt;You can see when files are sourced with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set verbose=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If that doesn't help you can try higher levels:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;= 1    When the viminfo file is read or written.&#xA;&amp;gt;= 2    When a file is &quot;:source&quot;'ed.&#xA;&amp;gt;= 5    Every searched tags file and include file.&#xA;&amp;gt;= 8    Files for which a group of autocommands is executed.&#xA;&amp;gt;= 9    Every executed autocommand.&#xA;&amp;gt;= 12   Every executed function.&#xA;&amp;gt;= 13   When an exception is thrown, caught, finished, or discarded.&#xA;&amp;gt;= 14   Anything pending in a &quot;:finally&quot; clause.&#xA;&amp;gt;= 15   Every executed Ex command (truncated at 200 characters).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2017-09-09T10:38:47.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13528" PostTypeId="2" ParentId="4695" CreationDate="2017-09-09T17:11:13.043" Score="21" Body="&lt;pre&gt;&lt;code&gt;:r!awk '{sum+=$6} END {print &amp;quot;Total: &amp;quot;sum}' %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:r ........... read (put result in this file)&#xA;! ............ external command&#xA;awk .......... external tool&#xA;{sum+=$6} .... sixth field (awk considers spaces as field separator)&#xA;END .......... at the end&#xA;{print &amp;quot;Total: &amp;quot;sum} --&amp;gt; string &amp;quot;Total: &amp;quot; plus your result&#xA;% ............ current file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here's a function that uses Vim's &lt;a href=&quot;https://vimdoc.sourceforge.net/htmldoc/change.html#quote=&quot; rel=&quot;nofollow noreferrer&quot;&gt;expression register&lt;/a&gt; instead of &lt;code&gt;awk&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; This function requires you to select the numbers&#xA;fun! SumVis()&#xA;    try&#xA;        let l:a_save = @a&#xA;        norm! gv&amp;quot;ay&#xA;        let @a = substitute(@a,'[^0-9. ]','+','g')&#xA;        exec &amp;quot;norm! '&amp;gt;o&amp;quot;&#xA;        exec &amp;quot;norm! iTotal \&amp;lt;c-r&amp;gt;=\&amp;lt;c-r&amp;gt;a\&amp;lt;cr&amp;gt;&amp;quot;&#xA;     finally&#xA;        let @a = l:a_save&#xA;     endtry&#xA;endfun&#xA;vnoremap &amp;lt;leader&amp;gt;s :&amp;lt;C-u&amp;gt;call SumVis()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Using the mapping above, all you have to do after loading the function is select the numbers you want to sum and use &lt;code&gt;&amp;lt;leader&amp;gt;s&lt;/code&gt; to sum up the selected area.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Function explanation:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;It uses &lt;code&gt;try/finally/endtry&lt;/code&gt; structure to capture errors.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let l:a_save = @a ............................. if we have register 'a' we save it temporarily&#xA;norm! gv&amp;quot;ay ................................... gv --&amp;gt; reselects and captures selection to 'register a'&#xA;let @a = substitute(@a,'[^0-9. ]','+','g') .... removes all but numbers, dots and spaces from 'register a' and puts '+' among the numbers&#xA;exec &amp;quot;norm! '&amp;gt;o&amp;quot;  ............................. opens new line below selection. see :h '&amp;gt;&#xA;exec &amp;quot;norm! iTotal: \&amp;lt;c-r&amp;gt;=\&amp;lt;c-r&amp;gt;a\&amp;lt;cr&amp;gt;&amp;quot; ...... insert &amp;quot;Total: &amp;quot; plus 'expression register result&#xA;let @a = l:a_save ............................. restores original 'a' register content&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you want to try this function, do the following:&#xA;Copy this function in your browser and run this command on vim &lt;code&gt;:@+&lt;/code&gt;&#xA;this will allow you to use &lt;code&gt;:call SumVis()&lt;/code&gt; normally.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:@+ ......... loads `+` register making the function available&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It needs you to make a visual block selection with &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;, unselect and finally call the function. Or you can use the suggested map which by itself removes the selection before calculating.&lt;/p&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="8558" LastEditDate="2023-05-31T18:58:15.563" LastActivityDate="2023-05-31T18:58:15.563" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="13529" PostTypeId="1" CreationDate="2017-09-10T21:34:02.873" Score="6" ViewCount="2931" Body="&lt;p&gt;I read that vim 8 provides it default plugin manager. I upgraded my vim to vim 8.0 and am trying to install the plugin using the method provided in the documentation. youcompleteme plugin github repo recommends using Vundle to install the plugin on mac. Just wondering if it can also be installed using default plugin manager supported in vim 8.0 and how to install it?&lt;/p&gt;&#xA;" OwnerUserId="14224" LastActivityDate="2019-09-28T11:11:04.367" Title="Is there a way to install youcompleteme plugin using vim 8.0 default plugin manager?" Tags="|plugin-you-complete-me|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13530" PostTypeId="1" AcceptedAnswerId="13544" CreationDate="2017-09-11T00:01:04.810" Score="1" ViewCount="587" Body="&lt;p&gt;Let's think we are going to render html file. We highlight &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tags, so &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;img&lt;/code&gt; will be highlighted as Keywords. We assume &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; accepts attribute &lt;code&gt;href&lt;/code&gt; but not &lt;code&gt;src&lt;/code&gt;, while &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; accepts attribute &lt;code&gt;src&lt;/code&gt; not &lt;code&gt;href&lt;/code&gt;. So in &lt;code&gt;&amp;lt;a href=&quot;place1&quot; src=&quot;place2&quot;&amp;gt;&lt;/code&gt;, &lt;code&gt;href&lt;/code&gt; will be highlighted as, let's say, Identifier, while &lt;code&gt;src&lt;/code&gt; will not be highlighted; while in &lt;code&gt;&amp;lt;img href=&quot;place1&quot; src=&quot;place2&quot;&amp;gt;&lt;/code&gt;, &lt;code&gt;src&lt;/code&gt; will be highlighted but &lt;code&gt;href&lt;/code&gt; will not be highlighted. Is there a way of implementing this via &lt;code&gt;syntax region&lt;/code&gt; or &lt;code&gt;syntax match&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8820" LastActivityDate="2017-09-11T15:32:21.097" Title="How to highlight region over region" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13531" PostTypeId="2" ParentId="13529" CreationDate="2017-09-11T01:39:18.843" Score="8" Body="&lt;pre&gt;&lt;code&gt;mkdir -p ~/.vim/pack/plugins/opt&#xA;git clone https://github.com/Valloric/YouCompleteMe ~/.vim/pack/plugins/opt/YouCompleteMe&#xA;cd ~/.vim/pack/plugins/opt/YouCompleteMe &amp;amp;&amp;amp; git submodule update --init --recursive &amp;amp;&amp;amp; ./install.py --all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;add following code to your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'packadd YouCompleteMe'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or execute&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;packadd YouCompleteMe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when you want to start it.&lt;/p&gt;&#xA;" OwnerUserId="10798" LastEditorUserId="21303" LastEditDate="2019-09-28T11:11:04.367" LastActivityDate="2019-09-28T11:11:04.367" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="13534" PostTypeId="2" ParentId="13512" CreationDate="2017-09-11T08:44:33.533" Score="2" Body="&lt;p&gt;The following code defines a new command :LsByTab that parses the output of :ls and groups it by tabs. You can call the command with an exclamation mark and/or the flags supported by :ls.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&#xA;&quot; Get the output of :ls as a List of lines.&#xA;&quot;&#xA;function! s:LsOutput(bang, args)&#xA;    redir =&amp;gt; ls_output&#xA;    exe 'silent ls' . a:bang a:args&#xA;    redir END&#xA;    return split(ls_output, &quot;\n&quot;)&#xA;endfunction&#xA;&#xA;&quot;&#xA;&quot; Group the output of :ls by tabs and print it.&#xA;&quot;&#xA;function! LsByTab(bang, args)&#xA;    let ls_output = s:LsOutput(a:bang, a:args)&#xA;&#xA;    &quot; Iterate over all tabs.&#xA;    for tab in gettabinfo()&#xA;        echo '===== tab' tab.tabnr '====='&#xA;        &quot; Get the buffer numbers for the current tab.&#xA;        let buffers = tabpagebuflist(tab.tabnr)&#xA;        &quot; Construct a regular expression that matches the buffer numbers&#xA;        &quot; at the start of the lines of the :ls output.&#xA;        let buffers_pat = '^\s*\(' . join(buffers, '\|') . '\)\&amp;gt;'&#xA;        &quot; Filter the lines from the :ls output so that only the lines for&#xA;        &quot; the buffers of the current tab remain.&#xA;        let tab_buffers = filter(copy(ls_output), 'v:val =~ buffers_pat')&#xA;        &quot; Print the info for the current tab.&#xA;        echo join(tab_buffers, &quot;\n&quot;)&#xA;    endfor&#xA;endfunction&#xA;&#xA;command! -bang -nargs=? LsByTab call LsByTab(&amp;lt;q-bang&amp;gt;, &amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2636" LastActivityDate="2017-09-11T08:44:33.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13535" PostTypeId="1" AcceptedAnswerId="13536" CreationDate="2017-09-11T09:21:17.687" Score="22" ViewCount="10772" Body="&lt;p&gt;I have this oneliner in my &lt;code&gt;vimrc&lt;/code&gt; but it does not work :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;patch-7.4.710&quot;) | set listchars+=space:· else | set listchars+=trail:· | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;VIM says :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E518: Unknown option: else&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you help me ?&lt;/p&gt;&#xA;" OwnerUserId="14229" LastEditorUserId="14229" LastEditDate="2024-03-04T09:02:33.870" LastActivityDate="2024-03-04T09:02:33.870" Title="if else endif oneliner in VIM" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13536" PostTypeId="2" ParentId="13535" CreationDate="2017-09-11T09:25:40.770" Score="32" Body="&lt;p&gt;You need to put another &lt;code&gt;|&lt;/code&gt; before &lt;code&gt;else&lt;/code&gt; otherwise vim will think your command is &lt;code&gt;set listchars+=space:· else&lt;/code&gt; instead of two separate commands. That's why you got the error message: &lt;code&gt;else&lt;/code&gt; is an unknown option for the command &lt;code&gt;set&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The correct syntax is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;patch-7.4.710&quot;) | set listchars+=space:· | else | set listchars+=trail:· | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-09-11T09:45:25.797" LastActivityDate="2017-09-11T09:45:25.797" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13537" PostTypeId="1" AcceptedAnswerId="13538" CreationDate="2017-09-08T09:54:21.617" Score="14" ViewCount="9485" Body="&lt;p&gt;I'm using Mac OS X 10.12 and I have &lt;code&gt;set noexpandtab&lt;/code&gt; in my &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are 2 different behaviors :&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;$ vim file.py&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;If run Vim (8.0) to open one file and type &lt;code&gt;:set expandtab?&lt;/code&gt;, it says &lt;code&gt;expandtab&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;$ vim&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;If I run Vim by itself and type &lt;code&gt;:set expandtab?&lt;/code&gt;, it says &lt;code&gt;noexpandtab&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Why is &lt;code&gt;set noexpandtab&lt;/code&gt; in my &lt;code&gt;~/.vimrc&lt;/code&gt; ignored when I open a file ?&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:verbose set expandtab?&lt;/code&gt; says:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;expandtab&#xA;      Last set from /usr/local/Cellar/vim/8.0.0627/share/vim/vim80/ftplugin/python.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14229" OwnerDisplayName="SebMa" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-09-11T13:32:41.253" Title="Why is &quot;set noexpandtab&quot; in my ~/.vimrc ignored when I open a file?" Tags="|indentation|filetype|filetype-python|" AnswerCount="1" CommentCount="8" ClosedDate="2017-09-11T13:33:39.670" ContentLicense="CC BY-SA 3.0" />
  <row Id="13538" PostTypeId="2" ParentId="13537" CreationDate="2017-09-11T05:50:10.307" Score="13" Body="&lt;p&gt;It is not ignored, it is overwritten by your filetype plugin. In this case the python plugin. You can verify that like Marth said, with the &lt;code&gt;:verbose&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set expandtab?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to overwrite the setting in the filetype plugin, you should go for one of the following ways:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Put your settings in a after file:&#xA;&lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt;, see &lt;code&gt;:h after&lt;/code&gt; for more information.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use an autocommand: &lt;code&gt;:autocmd FileType python setlocal noexpandtab&lt;/code&gt;, see &lt;code&gt;:h auto&lt;/code&gt; for more information. *This must be done after the line which activates the filetype plugins (possibly something like &lt;code&gt;:filetype plugin on&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;setlocal&lt;/code&gt;, you should use this instead of &lt;code&gt;set&lt;/code&gt; in both, the autocmd and your after file. Else you can get it all mixed up if you open different filetypes in the same instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DISCLAIMER: Most Lines are directly taken from this SO post: &lt;a href=&quot;https://stackoverflow.com/questions/28375119/override-options-set-by-ftplugins-in-vim&quot;&gt;Override options set by ftplugins in vim&lt;/a&gt; or the comment of Marth. This answer only adjust them for the given problem. So if this helped you, think about leaving an upvote there!&lt;/p&gt;&#xA;" OwnerUserId="11316" OwnerDisplayName="Doktor OSwaldo" LastActivityDate="2017-09-11T05:50:10.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13539" PostTypeId="1" AcceptedAnswerId="13540" CreationDate="2017-09-10T22:42:13.723" Score="3" ViewCount="3641" Body="&lt;p&gt;I have &lt;code&gt;set ruler&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run &lt;code&gt;vim&lt;/code&gt; and then &lt;code&gt;:verbose set ruler?&lt;/code&gt; to check the status of this setting, on Ubuntu Linux it says :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noruler&#xA;        Last set from ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the bash prompt, &lt;code&gt;grep&lt;/code&gt; says :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ grep ruler .vimrc &#xA;set ruler&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And on Debian Linux, &lt;code&gt;:verbose set ruler?&lt;/code&gt; says :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noruler&#xA;        Last set from /usr/share/vim/vim74/debian.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the bash prompt, &lt;code&gt;grep&lt;/code&gt; says :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ grep ruler /usr/share/vim/vim74/debian.vim&#xA;set ruler       &quot; show the cursor position all the time&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does &lt;code&gt;set ruler&lt;/code&gt; get reset to &lt;code&gt;noruler&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="14229" OwnerDisplayName="SebMa" LastEditorUserId="14229" LastEditDate="2017-09-12T09:12:27.363" LastActivityDate="2018-08-10T03:44:51.273" Title="Why does &quot;set ruler&quot; get reset to noruler?" Tags="|linux|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13540" PostTypeId="2" ParentId="13539" CreationDate="2017-09-11T08:41:43.260" Score="7" Body="&lt;p&gt;Check if &lt;code&gt;set paste?&lt;/code&gt; and &lt;code&gt;set compatible?&lt;/code&gt; are set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If they are set, disable them. &lt;code&gt;ruler&lt;/code&gt; is reset if they are set.&lt;br&gt;&#xA;More details at &lt;code&gt;:help ruler&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6221" OwnerDisplayName="dlmeetei" LastActivityDate="2017-09-11T10:16:10.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13541" PostTypeId="2" ParentId="605" CreationDate="2017-09-11T11:47:40.860" Score="3" Body="&lt;p&gt;Ensure setting the cscope using the following in your &lt;code&gt;~/.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cscopetag&#xA;set cst&#xA;set csto=0&#xA;set tags=./tags,tags;/&#xA;cs add cscope.out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once it is done, re-login into the terminal to run cscope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Jump to a tag: &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Jump back: &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;O&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Jump to a tag again: &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;I&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="14232" LastEditorUserId="12003" LastEditDate="2017-09-11T22:36:25.227" LastActivityDate="2017-09-11T22:36:25.227" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13543" PostTypeId="2" ParentId="10460" CreationDate="2017-09-11T14:00:58.583" Score="1" Body="&lt;p&gt;The remarkable contraption that is the &lt;a href=&quot;https://vim.sourceforge.io/scripts/script.php?script_id=4381&quot; rel=&quot;nofollow noreferrer&quot;&gt;RepeatLast&lt;/a&gt; plugin (by our very own &lt;a href=&quot;https://vi.stackexchange.com/users/630/joeytwiddle&quot;&gt;@joeytwiddle&lt;/a&gt;) provides just this functionality, via the unholy method of recording &lt;em&gt;everything&lt;/em&gt; you do as a macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It provides a number of new mappings, but, if I'm reading the documentation correctly, to perform the edits you describe you could use the sequence of commands (presuming you are using the default &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; of &lt;code&gt;\&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Yp&lt;/code&gt; Yank and put/paste the line &lt;code&gt;apple&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; Move down a line so the cursor is now on the &lt;code&gt;pear&lt;/code&gt; line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\D&lt;/code&gt; forget the &lt;code&gt;j&lt;/code&gt; command,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2\.&lt;/code&gt; Repeat the two commands &lt;code&gt;Y&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-09-11T14:00:58.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13544" PostTypeId="2" ParentId="13530" CreationDate="2017-09-11T15:26:48.503" Score="1" Body="&lt;p&gt;You can do this with the &lt;code&gt;:syntax&lt;/code&gt; command's &lt;code&gt;contains&lt;/code&gt;, &lt;code&gt;containedin&lt;/code&gt;, and &lt;code&gt;contained&lt;/code&gt; keywords. See &lt;code&gt;:help syn-contains&lt;/code&gt;, &lt;code&gt;:help syn-containedin&lt;/code&gt; and &lt;code&gt;:help :syn-contained&lt;/code&gt; for the documentation on these, but briefly, the technique is to&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use either &lt;code&gt;contains&lt;/code&gt; to allow an outer group to contain an inner group or &lt;code&gt;containedin&lt;/code&gt; to allow an inner group to be contained within an outer group,&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;contained&lt;/code&gt; to only activate an inner group when it is contained within another.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here a basic example of one way to achieve what you describe in your question (with extremely simplified regular expressions&amp;mdash;the point is to demonstrate the use of the &lt;code&gt;containedin&lt;/code&gt; and &lt;code&gt;contained&lt;/code&gt; keywords, not the matching of tags. If you need help with that, maybe take a look at Vim's included HTML syntax file: &lt;code&gt;e $VIMRUNTIME/syntax/html.vim&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match myAnchorTag /&amp;lt;a.*a&amp;gt;/&#xA;syntax match myImgTag /&amp;lt;img.*img&amp;gt;/&#xA;&#xA;syntax match myHrefAttribute containedin=myAnchorTag contained /href/&#xA;syntax match mySrcAttribute containedin=myImgTag contained /src/&#xA;&#xA;highlight link myHrefAttribute Identifier&#xA;highlight link mySrcAttribute Identifier&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-09-11T15:32:21.097" LastActivityDate="2017-09-11T15:32:21.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13545" PostTypeId="2" ParentId="9967" CreationDate="2017-09-11T16:10:30.717" Score="0" Body="&lt;p&gt;The following function tracks open netrw buffers and calls &lt;code&gt;Lexplore&lt;/code&gt; accordingly. Add it to your &lt;code&gt;.vimrc&lt;/code&gt; and pick your mapping key.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:NetrwIsOpen=0&#xA;&#xA;function! ToggleNetrw()&#xA;    if g:NetrwIsOpen&#xA;        let i = bufnr(&quot;$&quot;)&#xA;        while (i &amp;gt;= 1)&#xA;            if (getbufvar(i, &quot;&amp;amp;filetype&quot;) == &quot;netrw&quot;)&#xA;                silent exe &quot;bwipeout &quot; . i &#xA;            endif&#xA;            let i-=1&#xA;        endwhile&#xA;        let g:NetrwIsOpen=0&#xA;    else&#xA;        let g:NetrwIsOpen=1&#xA;        silent Lexplore&#xA;    endif&#xA;endfunction&#xA;&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;F2&amp;gt; :call ToggleNetrw()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14238" LastActivityDate="2017-09-11T16:10:30.717" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13546" PostTypeId="1" CreationDate="2017-09-11T17:05:06.587" Score="3" ViewCount="683" Body="&lt;p&gt;I recently installed vim-rmarkdown package, and found that the package allows me to see the rendered math equation in macvim, and when move cursor over, the line will render back to latex equation symbols and allows me to edit further. I want to know if this convenient math equation rendering in macvim is available in a package for other filetypes other than RMarkdown files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is when I can see the rendered &lt;code&gt;\theta&lt;/code&gt; inline :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wEa8I.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wEa8I.png&quot; alt=&quot;rendered &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When move cursor to the line, I can see &lt;code&gt;\theta&lt;/code&gt; as usual in tex files: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gLPM2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gLPM2.png&quot; alt=&quot;rendered back&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9387" LastActivityDate="2017-09-11T17:05:06.587" Title="in-line math equation rendering/preview for macvim/vim for filetypes other than RMarkdown" Tags="|filetype|filetype-tex|plugin-vim-latex|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13547" PostTypeId="1" AcceptedAnswerId="13549" CreationDate="2017-09-13T01:06:20.147" Score="3" ViewCount="306" Body="&lt;p&gt;I often find myself doing an interactive search and replace for a string that may be either a whole word &lt;em&gt;or&lt;/em&gt; a partial word, such as changing &lt;code&gt;bar&lt;/code&gt; to &lt;code&gt;jaz&lt;/code&gt; and also &lt;code&gt;foo_bar_blah&lt;/code&gt; to &lt;code&gt;foo_jaz_blah&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I can't just do &lt;code&gt;cw&lt;/code&gt;.  But if I do for example &lt;code&gt;c/_&amp;lt;CR&amp;gt;&lt;/code&gt; then I've lost &lt;code&gt;bar&lt;/code&gt; as the search pattern.  How can I change just the current instance of the search pattern and retain that search pattern?&lt;/p&gt;&#xA;" OwnerUserId="14249" LastEditorUserId="1841" LastEditDate="2017-09-13T07:07:23.783" LastActivityDate="2017-09-13T07:07:23.783" Title="How do I replace only the current instance of the search pattern without losing the pattern?" Tags="|search|replace|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13548" PostTypeId="2" ParentId="13547" CreationDate="2017-09-13T01:15:02.360" Score="3" Body="&lt;p&gt;Here is the answer I finally found after sifting through the vimdoc site, specifically &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;the chapter on patterns&lt;/a&gt; scrolling a few paragraphs below the section labeled &lt;code&gt;*search-offset*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;An example of how to search for matches with a pattern and change the match&#xA;with another word:&#xA;    /foo&amp;lt;CR&amp;gt;    find &quot;foo&quot;&#xA;    c//e        change until end of match&#xA;    bar&amp;lt;Esc&amp;gt;    type replacement&#xA;    //&amp;lt;CR&amp;gt;      go to start of next match&#xA;    c//e        change until end of match&#xA;    beep&amp;lt;Esc&amp;gt;   type another replacement&#xA;                etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The important thing is NOT to use &lt;code&gt;n&lt;/code&gt; to move to the next instance, because doing so will put you at the END of that instance.  You must use &lt;code&gt;//&amp;lt;CR&amp;gt;&lt;/code&gt; as shown.  You can use &lt;code&gt;.&lt;/code&gt; as usual if you just want to repeat the previous &lt;code&gt;c//e&lt;/code&gt; change.&lt;/p&gt;&#xA;" OwnerUserId="14249" LastEditorUserId="14249" LastEditDate="2017-09-13T01:21:03.403" LastActivityDate="2017-09-13T01:21:03.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13549" PostTypeId="2" ParentId="13547" CreationDate="2017-09-13T01:48:51.970" Score="8" Body="&lt;p&gt;To change the current match (or next match, if the cursor is not on a match) use &lt;code&gt;cgn&lt;/code&gt; or &lt;code&gt;gnc&lt;/code&gt;.  Alone, &lt;code&gt;gn&lt;/code&gt; visually selects the match.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-09-13T01:48:51.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13550" PostTypeId="2" ParentId="13238" CreationDate="2017-09-13T03:27:10.140" Score="0" Body="&lt;p&gt;You can use &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-surround&lt;/a&gt;. It's easy to add &lt;code&gt;&quot;&lt;/code&gt; or &lt;code&gt;'&lt;/code&gt;.&lt;br&gt;&#xA;For example, &lt;code&gt;ysw&quot;&lt;/code&gt; will add &lt;code&gt;&quot;&lt;/code&gt; to surround the current word. &lt;/p&gt;&#xA;" OwnerUserId="14251" LastActivityDate="2017-09-13T03:27:10.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13551" PostTypeId="2" ParentId="8851" CreationDate="2017-09-13T09:08:16.063" Score="5" Body="&lt;p&gt;Here is a solution using Vim's recent &lt;code&gt;+timers&lt;/code&gt; feature (which falls back to a non-blinking temporary highlight like Damian Conway's original code if you are a using an older version of Vim that predates the &lt;code&gt;+timers&lt;/code&gt; feature).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sets up two timers: one infinitely repeating timer that toggles the blink (&lt;code&gt;s:blink_timer_id&lt;/code&gt;), and a second to cancel the blinking (&lt;code&gt;s:blink_stop_id&lt;/code&gt;) after the specified time period (&lt;code&gt;s:blink_length&lt;/code&gt;) has elapsed. (Initially I tried doing this with a single timer that repeated the correct number of times, but that didn't work well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that Vim is not blocking while match is blinking, so you can enter new commands immediately. If you press &lt;code&gt;n&lt;/code&gt; again, it will reset the blink timers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also sets up two autocommands, to cancel the blinking immediately if you move the cursor or enter insert mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Modified version of Damian Conway's Die Blinkënmatchen: highlight matches&#xA;&quot;&#xA;&quot; This is how long you want the blinking to last in milliseconds. If you're&#xA;&quot; using an earlier Vim without the `+timers` feature, you need a much shorter&#xA;&quot; blink time because Vim blocks while it waits for the blink to complete.&#xA;let s:blink_length = has(&quot;timers&quot;) ? 500 : 100&#xA;&#xA;if has(&quot;timers&quot;)&#xA;  &quot; This is the length of each blink in milliseconds. If you just want an&#xA;  &quot; interruptible non-blinking highlight, set this to match s:blink_length&#xA;  &quot; by uncommenting the line below&#xA;  let s:blink_freq = 50&#xA;  &quot;let s:blink_freq = s:blink_length&#xA;  let s:blink_match_id = 0&#xA;  let s:blink_timer_id = 0&#xA;  let s:blink_stop_id = 0&#xA;&#xA;  &quot; Toggle the blink highlight. This is called many times repeatedly in order&#xA;  &quot; to create the blinking effect.&#xA;  function! BlinkToggle(timer_id)&#xA;    if s:blink_match_id &amp;gt; 0&#xA;      &quot; Clear highlight&#xA;      call BlinkClear()&#xA;    else&#xA;      &quot; Set highlight&#xA;      let s:blink_match_id = matchadd('ErrorMsg', s:target_pat, 101)&#xA;      redraw&#xA;    endif&#xA;  endfunction&#xA;&#xA;  &quot; Remove the blink highlight&#xA;  function! BlinkClear()&#xA;    call matchdelete(s:blink_match_id)&#xA;    let s:blink_match_id = 0&#xA;    redraw&#xA;  endfunction&#xA;&#xA;  &quot; Stop blinking&#xA;  &quot;&#xA;  &quot; Cancels all the timers and removes the highlight if necessary.&#xA;  function! BlinkStop(timer_id)&#xA;    &quot; Cancel timers&#xA;    if s:blink_timer_id &amp;gt; 0&#xA;      call timer_stop(s:blink_timer_id)&#xA;      let s:blink_timer_id = 0&#xA;    endif&#xA;    if s:blink_stop_id &amp;gt; 0&#xA;      call timer_stop(s:blink_stop_id)&#xA;      let s:blink_stop_id = 0&#xA;    endif&#xA;    &quot; And clear blink highlight&#xA;    if s:blink_match_id &amp;gt; 0&#xA;      call BlinkClear()&#xA;    endif&#xA;  endfunction&#xA;&#xA;  augroup die_blinkmatchen&#xA;    autocmd!&#xA;    autocmd CursorMoved * call BlinkStop(0)&#xA;    autocmd InsertEnter * call BlinkStop(0)&#xA;  augroup END&#xA;endif&#xA;&#xA;function! HLNext(blink_length, blink_freq)&#xA;  let s:target_pat = '\c\%#'.@/&#xA;  if has(&quot;timers&quot;)&#xA;    &quot; Reset any existing blinks&#xA;    call BlinkStop(0)&#xA;    &quot; Start blinking. It is necessary to call this now so that the match is&#xA;    &quot; highlighted initially (in case of large values of a:blink_freq)&#xA;    call BlinkToggle(0)&#xA;    &quot; Set up blink timers.&#xA;    let s:blink_timer_id = timer_start(a:blink_freq, 'BlinkToggle', {'repeat': -1})&#xA;    let s:blink_stop_id = timer_start(a:blink_length, 'BlinkStop')&#xA;  else&#xA;    &quot; Vim doesn't have the +timers feature. Just use Conway's original&#xA;    &quot; code.&#xA;    &quot; Highlight the match&#xA;    let ring = matchadd('ErrorMsg', s:target_pat, 101)&#xA;    redraw&#xA;    &quot; Wait&#xA;    exec 'sleep ' . a:blink_length . 'm'&#xA;    &quot; Remove the highlight&#xA;    call matchdelete(ring)&#xA;    redraw&#xA;  endif&#xA;endfunction&#xA;&#xA;&quot; Set up maps for n and N that blink the match&#xA;execute printf(&quot;nnoremap &amp;lt;silent&amp;gt; n n:call HLNext(%d, %d)&amp;lt;cr&amp;gt;&quot;, s:blink_length, has(&quot;timers&quot;) ? s:blink_freq : s:blink_length)&#xA;execute printf(&quot;nnoremap &amp;lt;silent&amp;gt; N N:call HLNext(%d, %d)&amp;lt;cr&amp;gt;&quot;, s:blink_length, has(&quot;timers&quot;) ? s:blink_freq : s:blink_length)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-09-20T21:51:27.853" LastActivityDate="2017-09-20T21:51:27.853" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13553" PostTypeId="1" CreationDate="2017-09-13T10:55:33.733" Score="1" ViewCount="227" Body="&lt;p&gt;I have a self-extracting &quot;archive&quot; generated by &lt;a href=&quot;http://makeself.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Makeself&lt;/a&gt; tool, which is essentially a shell script with a large binary blob in inside. What I want is to view only text part of the file, while hiding the binary part completely (possibly abbreviating it to one line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a way to speed up the process of opening such file by preventing &lt;code&gt;vim&lt;/code&gt; from reading binary portion, that's even better. Currently, I have to use &lt;code&gt;less&lt;/code&gt; for viewing such files, because &lt;code&gt;vim&lt;/code&gt; just takes too long to load.&lt;/p&gt;&#xA;" OwnerUserId="13992" LastActivityDate="2017-09-13T10:55:33.733" Title="Hide binary portion in mixed text-binary file" Tags="|binary-file|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13557" PostTypeId="1" AcceptedAnswerId="13558" CreationDate="2017-09-13T18:22:40.737" Score="6" ViewCount="3217" Body="&lt;p&gt;I have a list of integers, where each is on a separate line. I'm trying to find a quick way to sum them up directly in VIM without having to write a script that does it for me.&lt;/p&gt;&#xA;" OwnerUserId="8055" LastActivityDate="2022-12-30T10:23:13.843" Title="How do you sum up integers on separate lines in vim?" Tags="|arithmetic|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13558" PostTypeId="2" ParentId="13557" CreationDate="2017-09-13T18:22:52.363" Score="11" Body="&lt;p&gt;What worked for me was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!awk '{print; total+=$1}END{print total}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8055" LastActivityDate="2017-09-13T18:22:52.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13559" PostTypeId="2" ParentId="13557" CreationDate="2017-09-13T18:32:34.747" Score="4" Body="&lt;p&gt;You can use this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! -range=% Sum :echo eval(join(getline(&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;),'+'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It basically gets the lines in the given range (by default whole file) as a list, and evaluates it by joining each list item with a &lt;code&gt;+&lt;/code&gt; between each other.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-09-13T18:32:34.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13560" PostTypeId="2" ParentId="13557" CreationDate="2017-09-13T19:35:02.950" Score="1" Body="&lt;p&gt;Here's a fun (albeit slightly hacky) answer, although I believe it's the shortest answer you'll get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm Dj@&quot;&amp;lt;C-v&amp;gt;&amp;lt;C-a&amp;gt;&amp;lt;cr&amp;gt;&#xA;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(note that &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; means ctrl-v, and &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; means ctrl-a)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works by doing the following on every line: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Deleting it (into the unnamed register)&lt;/li&gt;&#xA;&lt;li&gt;Running the unnamed register as a count, and&lt;/li&gt;&#xA;&lt;li&gt;Incrementing the next number by that much.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then, on the last line, there isn't a next number to increment, so it breaks. However, we have the current sum in the unnamed register, so we can just paste it with &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want a  bunch of blank lines, you could modify the last line to &lt;code&gt;V{p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this only works with positive integers.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-09-13T19:35:02.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13561" PostTypeId="2" ParentId="12908" CreationDate="2017-09-13T20:43:17.983" Score="1" Body="&lt;p&gt;I assume you're following the advice in the Vim help pages (&lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#write-local-help&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h write-local-help&lt;/code&gt;&lt;/a&gt;) and formatting your links with double-stars and double-bars in the Vim style.  However, for vim to recognize them as tags, you have to set the &lt;code&gt;iskeyword&lt;/code&gt; option correctly, namely&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set iskeyword=!-~,^*,^\|,^\&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The way Vim does this for its own help files is to use a modeline.  For an example of this, type &lt;code&gt;:help&lt;/code&gt; and go to the last line in the help window. Finally, you'll have to create a &lt;code&gt;tags&lt;/code&gt; file for your plugin.  Use the &lt;a href=&quot;http://vimhelp.appspot.com/helphelp.txt.html#%3Ahelptags&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:helptags&lt;/code&gt;&lt;/a&gt; command for that.&lt;/p&gt;&#xA;" OwnerUserId="14265" LastEditorUserId="205" LastEditDate="2017-09-14T05:45:40.463" LastActivityDate="2017-09-14T05:45:40.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13563" PostTypeId="2" ParentId="11337" CreationDate="2017-09-14T00:49:50.930" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/tracyone/t-vim/blob/master/autoload/te/tmux.vim#L26-L45&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tracyone/t-vim/blob/master/autoload/te/tmux.vim#L26-L45&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;run ranger using tmux&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call te#tmux#run_command('ranger',0x01)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10798" LastActivityDate="2017-09-14T00:49:50.930" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13564" PostTypeId="1" AcceptedAnswerId="13565" CreationDate="2017-09-14T10:55:34.540" Score="32" ViewCount="13146" Body="&lt;p&gt;I'm curious as to why the default Debian package for vim (the one you normally get by &lt;code&gt;sudo apt-get install vim&lt;/code&gt;) isn't compiled with clipboard support?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neither the regular &lt;code&gt;-clipboard&lt;/code&gt; or &lt;code&gt;-Xterm-clipboard&lt;/code&gt; is enabled, &lt;strong&gt;why&lt;/strong&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There might be reason to not include -Xterm-clipboard on Debian installations without X-server installed, but the regular &lt;code&gt;-clipboard&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any insight into why this is would be helpfull.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;Clarification: I know I can compile Vim with these flags, I just want to know why they aren't enabled by default.&lt;/em&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2689" LastEditorUserId="4472" LastEditDate="2018-01-12T07:49:07.200" LastActivityDate="2018-01-12T07:49:07.200" Title="Why is Vim for Debian compiled without clipboard?" Tags="|linux|installing|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13565" PostTypeId="2" ParentId="13564" CreationDate="2017-09-14T11:35:31.420" Score="35" Body="&lt;p&gt;The &lt;a href=&quot;https://packages.debian.org/stretch/vim&quot; rel=&quot;noreferrer&quot;&gt;package description contains&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This package contains a version of vim compiled with a rather &#xA;  standard set of features.  This package does not provide a GUI &#xA;  version of Vim.  See the other vim-* packages if you need more  (or&#xA;  less).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I believe this was made, because using the clipboard would involve linking against X libraries, which means, you couldn't install vim without also installing a bunch of X dependencies which you usually do not want in a server (or minimal) environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means, if you want the clipboard feature, you should install e.g. the package &lt;code&gt;vim-gtk&lt;/code&gt; (which despite its name also contains a non-gui vim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a similar reason, the package &lt;code&gt;vim-nox&lt;/code&gt; exists. It does not depend on the X server, but needs additional libraries like liblua, libperl, libpython and does therefore install those additional dependencies (which you also probably do not need in a server environment), but no X libraries (like GTK or X11 ones needed for the gui and the clipboard).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-09-14T11:35:31.420" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13566" PostTypeId="1" CreationDate="2017-09-14T00:08:14.257" Score="41" ViewCount="54798" Body="&lt;p&gt;I saw &lt;a href=&quot;https://stackoverflow.com/questions/24684483/completely-disable-mouse-in-console-vim&quot;&gt;completely disable mouse in console Vim&lt;/a&gt; on Stack Overflow.  It sounded like exactly what I wanted, but there the problem was related to Cygwin, so the title was a misnomer.&lt;/p&gt;&#xA;&lt;p&gt;I want to know how to &lt;em&gt;completely&lt;/em&gt; disable &lt;em&gt;all&lt;/em&gt; mouse interactions in Vim on the console.  I don't want scrolling, selecting, clicking, or otherwise looking at the mouse to have any effect within Vim.&lt;/p&gt;&#xA;&lt;p&gt;I like having the mouse in the console, just not when I'm using Vim.  Is this possible?&lt;/p&gt;&#xA;&lt;p&gt;I have a laptop with Ubuntu installed on it and when I type, occasionally the touch pad mouse decides to randomly click or drag between some random coordinates on the screen, even when I try my hardest not to touch the damned thing.  This has the effect of me typing code in the wrong places all the time, and it's getting really old because sometimes it introduces subtle irreversible bugs into my code.&lt;/p&gt;&#xA;&lt;p&gt;I've been able to get rid of scrolling and visual select using the commands below in my &lt;code&gt;.vimrc&lt;/code&gt;, but it still will relocate the cursor when I click.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; disable mouse interactions &amp;quot;&#xA;set mouse=nicr&#xA;map &amp;lt;ScrollWheelUp&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;S-ScrollWheelUp&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;C-ScrollWheelUp&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;ScrollWheelDown&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;S-ScrollWheelDown&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;C-ScrollWheelDown&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;ScrollWheelLeft&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;S-ScrollWheelLeft&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;C-ScrollWheelLeft&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;ScrollWheelRight&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;S-ScrollWheelRight&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;C-ScrollWheelRight&amp;gt; &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What else do I need to do?&lt;/p&gt;&#xA;&lt;p&gt;P.S. I tried &lt;code&gt;set mouse=&lt;/code&gt;, but that seems to reenable visual select...&lt;/p&gt;&#xA;" OwnerUserId="20101" OwnerDisplayName="James M. Lay" LastEditorUserId="23502" LastEditDate="2024-02-26T19:28:55.370" LastActivityDate="2024-02-26T19:28:55.370" Title="Fully disable mouse in console Vim" Tags="|bash|mouse|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="13568" PostTypeId="1" CreationDate="2017-09-14T14:08:46.097" Score="2" ViewCount="1717" Body="&lt;p&gt;Running neovim 0.1.7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open a markdown file, it does not fold - even when I try &lt;code&gt;zM&lt;/code&gt; &lt;code&gt;zR&lt;/code&gt; &lt;code&gt;zc&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set&lt;/code&gt; tells me &lt;code&gt;ft=markdown&lt;/code&gt; and &lt;code&gt;foldmethod=syntax&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get the folding?&lt;/p&gt;&#xA;" OwnerUserId="3095" LastEditorUserId="1841" LastEditDate="2017-09-14T14:45:09.730" LastActivityDate="2018-03-14T21:31:36.173" Title="No folding of markdown files" Tags="|neovim|folding|filetype-markdown|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13569" PostTypeId="2" ParentId="13568" CreationDate="2017-09-14T14:54:21.737" Score="3" Body="&lt;p&gt;The default Vim syntax file for &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/syntax/markdown.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;markdown&lt;/a&gt; does not define any regions that should be folded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you set foldmethod in your .vimrc to syntax, then that means, syntax based folding does not work for markdown. If a plugin did set it, you might want to check with the author of the plugin, why syntax based folding does not work for you. You can check, where this was last set by &lt;code&gt;:verbose :set foldmethod?&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you might want to consider using the plugin &lt;a href=&quot;https://github.com/plasticboy/vim-markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;plasticboy/vim-markdown&lt;/a&gt;, as it does allow folding of markdown files, although it uses an expression-based folding method.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-09-14T14:54:21.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13570" PostTypeId="1" CreationDate="2017-09-14T16:01:45.873" Score="1" ViewCount="504" Body="&lt;p&gt;I'd like to assign [[ to leader[ and ]] to leader].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried the obvious:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader=&quot; &quot;&#xA;nnoremap &amp;lt;leader&amp;gt;[ [[&#xA;nnoremap &amp;lt;leader&amp;gt;] ]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the former mapping doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried with just those lines in _vimrc, and can reproduce this on both Vim8 on windows and Neovim (reasonably recent build from source) on RHEL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: The obvious duplicate question doesn't apply to this one because I have no problem when not using the leader key.&lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastActivityDate="2017-09-14T16:01:45.873" Title="How to map shortcut to double square brackets using the leader key" Tags="|vimrc|key-bindings|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13571" PostTypeId="2" ParentId="13566" CreationDate="2017-09-14T19:31:10.223" Score="1" Body="&lt;p&gt;This is only a partial solution at best, but you can globally disable the mouse/touchpad while vim is running with &lt;code&gt;xinput&lt;/code&gt; in a shell script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xinput set-prop $ID &quot;Device Enabled&quot; 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xinput set-prop $ID &quot;Device Enabled&quot; 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you're ready to have the touchpad work again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;xinput --list&lt;/code&gt; to get the id of your pointing device.&lt;/p&gt;&#xA;" OwnerUserId="14281" LastActivityDate="2017-09-14T19:31:10.223" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13573" PostTypeId="2" ParentId="13566" CreationDate="2017-09-14T20:11:48.700" Score="5" Body="&lt;p&gt;This might work if you put it at the end of your .vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set mouse=c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's probaly not Vim that takes the mouse input, but rather your Terminal-emulator. To disable mouse support on your terminal &lt;a href=&quot;https://unix.stackexchange.com/questions/44513/disabling-mouse-support-in-vim-in-a-gnome-terminal-environment&quot;&gt;this&lt;/a&gt; might help.&lt;/p&gt;&#xA;" OwnerUserId="2689" LastActivityDate="2017-09-14T20:11:48.700" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13574" PostTypeId="2" ParentId="5354" CreationDate="2017-09-14T20:25:16.953" Score="2" Body="&lt;p&gt;What if you gracefully kill Vim? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;kill -s 15 -p [PID for Vim]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;kill -s (signal) 15 is called SIGTERM wich tells that process to gracefully shut itself down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the PID (Process ID) of Vim use:&lt;br&gt;&#xA;&lt;code&gt;ps ax | grep vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2689" LastActivityDate="2017-09-14T20:25:16.953" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13575" PostTypeId="2" ParentId="13564" CreationDate="2017-09-14T20:25:42.303" Score="8" Body="&lt;p&gt;VIM is intended to be a portable editor that &quot;just works&quot; on all systems. By having the default version use the clipboard functionality, it will need to link against X11 libraries, and a separate version of VIM would need to be compiled for desktop versus server (no pre-installed X11/xorg) builds. This is why the &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;vim-gtk&lt;/code&gt; packages are provided.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to compile the command-line version of VIM (I use it with Guake/yakuake all the time), here's the build/install script for Debian-based systems.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Get the compile-dependencies of vim&#xA;sudo apt-get -y build-dep vim&#xA;# Install the &quot;checkinstall&quot; tool so the &quot;make install&quot; step is&#xA;# wrapped and the result is a .deb file that can be removed later by&#xA;# your package manager rather than having to hunt down every file deployed&#xA;# by &quot;make install&quot;, which might not be possible if it overwrites existing&#xA;# system files.&#xA;sudo apt-get -y install checkinstall&#xA;# Install python dev&#xA;sudo apt-get -y install python-dev&#xA;# Install xorg dev&#xA;sudo apt-get -y install xorg-dev&#xA;# Install git&#xA;sudo apt-get -y install git&#xA;# Get the source&#xA;git clone https://github.com/vim/vim.git vim_source&#xA;# Remove ./configure cache in case we have to run this twice due to permissions&#xA;# related issues.&#xA;rm vim_source/src/auto/config.cache&#xA;# Compile it&#xA;cd vim_source&#xA;make clean&#xA;./configure \&#xA;    --enable-perlinterp=dynamic \&#xA;    --enable-pythoninterp=dynamic \&#xA;    --enable-rubyinterp=dynamic \&#xA;    --enable-cscope \&#xA;    --enable-gui=auto \&#xA;    --enable-gtk2-check \&#xA;    --enable-gnome-check \&#xA;    --with-features=normal \&#xA;    --with-x \&#xA;    --with-compiledby=&quot;DevNull &amp;lt;darkstar@/dev/null&amp;gt;&quot; \&#xA;    --with-python-config-dir=/usr/lib/python2.7/config-$(uname -m)-linux-gnu&#xA;# Build quickly (8 parallel jobs, hope your system doesn't get overwhelmed)&#xA;make -j8&#xA;# Need root to install&#xA;sudo checkinstall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14282" LastActivityDate="2017-09-14T20:25:42.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13576" PostTypeId="2" ParentId="5272" CreationDate="2017-09-14T20:40:18.050" Score="2" Body="&lt;p&gt;The reason why Ctrl-Home and Ctrl-End don't work for Vim inside of Tmux is because Tmux eats those inputs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this you need to unbind the affected keys in your Tmux config wich is located at &lt;code&gt;~/.tmux.conf&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To unbind a key&lt;br&gt;&#xA;&lt;code&gt;unbind-key -[key]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for your example:&lt;br&gt;&#xA;&lt;code&gt;unbind-key C-Home&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;unbind-key C-End&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2689" LastActivityDate="2017-09-14T20:40:18.050" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13577" PostTypeId="1" CreationDate="2017-09-14T20:47:04.147" Score="0" ViewCount="90" Body="&lt;p&gt;Here's my existing bind I'm looking to improve: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;L :so $MYVIMRC&amp;lt;CR&amp;gt;:runtime! after/plugin/*.vim&amp;lt;CR&amp;gt;:runtime! after/ftplugin/*.vim&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't work to source &lt;code&gt;&amp;lt;cwd&amp;gt;/.vimrc&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I add that (probably just &lt;code&gt;:so .vimrc&lt;/code&gt;), and more importantly, what is the order in which that actually gets sourced on startup, so I can replicate that?&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2017-09-17T22:38:32.537" Title="vim bind to update initialization without restarting. How to add the loading of local .vimrc?" Tags="|vimscript|startup|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13578" PostTypeId="2" ParentId="13516" CreationDate="2017-09-14T20:59:21.767" Score="1" Body="&lt;p&gt;&lt;code&gt;vim -c 'startinsert'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will start Vim in insert mode pass it a file and it will open that file in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way is to make save this as an alias in your terminal config.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&#xA;&lt;code&gt;alias vim=&quot;vim -c 'startinsert' &quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2689" LastActivityDate="2017-09-14T20:59:21.767" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13579" PostTypeId="2" ParentId="5354" CreationDate="2017-09-14T21:46:29.507" Score="13" Body="&lt;p&gt;You can send commands to vim externally if you're running...&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Vim servers&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;For example, doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --servername vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will cause vim to launch a server with the name &quot;vim&quot;. Call it twice and the new server will be called &quot;vim1&quot;, call it thrice and it will be &quot;vim2&quot;, etc. You might want to make an alias of that command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can know what server a particular instance is named by looking at the window title. When you see:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[No Name] + - VIM3&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;the server name is case-insensitively &quot;VIM3&quot; (&quot;vim3&quot; would refer to the same instance.). Note that if you see:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[No Name] + - VIM&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;that doesn't necessarily mean that it's got a server named &quot;VIM&quot;. You can make sure the server exists by listing the server names with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --serverlist&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Still, the question only arises for &quot;VIM&quot;, specifically. If you see &quot;GVIM&quot; or some other name with a number appended to it, then it does mean it's a server.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How to use client&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Now, onto your question, you can save all and quit a given vim instance by doing, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --servername vim2 --remote-send $'\e:wqa\n'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We use the escape to return to normal mode in case you're in insert or command mode. You can do something other than &lt;code&gt;:wqa&lt;/code&gt;, but that seems the most appropriate to me because it will leave the swapfiles of buffers that could not be saved (because they're new and don't have a filename, etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to do so for all instances like in your case here, you can just loop through the server list like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for instance in $(vim --serverlist); do&#xA;  vim --servername $instance --remote-send $'\e:wqa\n'&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If for some reason you don't like &lt;code&gt;--remote-send&lt;/code&gt;, you can instead use &lt;code&gt;--remote-expr&lt;/code&gt; which has the advantage that it will cause the client to output the result or the error that it might have caused, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --servername vim2 --remote-expr 'execute(&quot;wqa&quot;)'&#xA;&#xA;E141: No file name for buffer 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that using Vim's server functionality requires that Vim was built with the &lt;code&gt;+clientserver&lt;/code&gt; option.&lt;/p&gt;&#xA;" OwnerUserId="14283" LastEditorUserId="2736" LastEditDate="2017-09-15T07:45:14.497" LastActivityDate="2017-09-15T07:45:14.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13580" PostTypeId="2" ParentId="4695" CreationDate="2017-09-14T22:42:19.540" Score="6" Body="&lt;p&gt;Making a plugin or coding this in vimscript seems a little heavy. I believe in a plugin-free vim, and good composition with external tools.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a 1-time command, based on user2571881's, that works even if the buffer has not been saved.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!awk -F '|' '{print; sum+=$4}; END {print &quot;Total: &quot;sum}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to save this command for future use, you might want to name it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -range=% -nargs=1 SumColumn &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;!awk -F '|' '{print; sum+=$('&amp;lt;args&amp;gt;' + 1)} END {print &quot;Total: &quot;sum}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works with visual selection. If you select a few rows and go into command mode, vim will prefix your command with &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt;, which is the line range for the visual selection. So you can run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;SumColumn 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it will only sum the 3rd column of the selected rows. By default the range is &lt;code&gt;%&lt;/code&gt;, so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SumColumn 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will sum the 3rd column of all lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: If you want to be able to specify other field separators and default the column counted to the last one, you can cover the command in &lt;code&gt;bash&lt;/code&gt; and handle the arguments with it, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -range=% -nargs=* SumColumn &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;!bash -c 'awk -F ${2:-|} &quot;{print; sum+=\$(${1:-NF - 2} + 1)} END {print \&quot;Total: \&quot;sum}&quot;' sumcolumn &amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SumColumn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will count the last column of a table with &quot;|&quot; field separators,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SumColumn 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will count the 3rd column of a table with &quot;|&quot; field separators, and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SumColumn 3 +&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will count the 3rd column of a table with &quot;+&quot; field separators.&lt;/p&gt;&#xA;" OwnerUserId="14283" LastEditorUserId="14283" LastEditDate="2017-09-15T16:31:22.713" LastActivityDate="2017-09-15T16:31:22.713" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13581" PostTypeId="1" AcceptedAnswerId="13582" CreationDate="2017-09-15T01:03:51.827" Score="3" ViewCount="357" Body="&lt;p&gt;Suppose I have a line of text of the form &lt;code&gt;(123[456{789}abc]def)&lt;/code&gt; and the cursor is inside the curly braces. In &lt;code&gt;sublime text&lt;/code&gt;, we can use &lt;code&gt;ctrl-shift-m&lt;/code&gt; repeatedly to jump to highlighting &lt;code&gt;789&lt;/code&gt;, &lt;code&gt;{789}&lt;/code&gt;, &lt;code&gt;456{789}abc&lt;/code&gt;, &lt;code&gt;[456{789}abc]&lt;/code&gt;, etc. Is there a way to duplicate this operation in &lt;code&gt;vim&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I know there are &lt;code&gt;%v%&lt;/code&gt; and &lt;code&gt;vib&lt;/code&gt; but they are different commands and not as fluid.&lt;/p&gt;&#xA;" OwnerUserId="14019" LastEditorUserId="1292" LastEditDate="2018-08-18T04:13:45.477" LastActivityDate="2019-04-11T05:43:26.333" Title="Highlight everything inside (, [, and { and expand outwards" Tags="|cursor-motions|visual-mode|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13582" PostTypeId="2" ParentId="13581" CreationDate="2017-09-15T05:09:42.337" Score="2" Body="&lt;p&gt;If I were on the first charater of the line I would do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;f7&lt;/code&gt; to jump to inside the curly braces.&#xA;&lt;code&gt;vw&lt;/code&gt; to hilight 789&#xA;To contincously move outward I would do &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vi]&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;va[&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;vi)&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;va)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I am sure there is a better way.&lt;/p&gt;&#xA;" OwnerUserId="2689" LastEditorUserId="2689" LastEditDate="2019-04-11T05:43:26.333" LastActivityDate="2019-04-11T05:43:26.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13583" PostTypeId="1" AcceptedAnswerId="13590" CreationDate="2017-09-15T10:04:08.293" Score="2" ViewCount="1152" Body="&lt;p&gt;&lt;strong&gt;Case&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A user defined command to open files &lt;em&gt;recursively&lt;/em&gt; in a directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The command&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After weeks trying to get this to work, I got to the following code after trying to understand &lt;a href=&quot;https://vi.stackexchange.com/questions/12921/user-command-with-modified-path-completion&quot;&gt;this answer&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DumbnoteOpenNote(...)&#xA;    let Note = a:1&#xA;    execute &quot;e &quot; Note &#xA;endfunction&#xA;&#xA;function! DumbnotePathsCompletion(...)&#xA;    return split(globpath(g:dumbnoteDefaultCollection, '**/*'), '\n')&#xA;endfunction&#xA;&#xA;command! -bang -complete=customlist,DumbnotePathsCompletion -nargs=* DumbnoteOpenNote call DumbnoteOpenNote(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the following directory structure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|--ADirectory&#xA;    |--BDirectory&#xA;    |  |--Afile&#xA;    |  |--Bfile&#xA;    |&#xA;    |--Cdirectory&#xA;    |  |--Afile&#xA;    |  |--Bfile&#xA;    |&#xA;    |--Afile&#xA;    |--Bfile&#xA;    |--Cfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:DumbnoteOpenNote &amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will expand to the path specified in the &lt;code&gt;customlist&lt;/code&gt; and the completion works just fine with both &lt;code&gt;tab&lt;/code&gt; and the arrows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my first question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it really need to expand to the whole path (in this case &lt;code&gt;/home/user/path/&lt;/code&gt;)? When I use the command, I already know that I am looking for completion only in that path, and I don't need to see the whole path. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to get completion from that path on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Despite of that, if I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:DumbnoteOpenNote &amp;lt;tab&amp;gt;Bf&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hoping to get the completion to the &lt;code&gt;Bfile&lt;/code&gt;, the completion will just come back to the first &lt;em&gt;alphabetical&lt;/em&gt; item. The same happens if typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:DumbnoteOpenNote &amp;lt;tab&amp;gt;CD&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming that the idea is to get completion to the &lt;code&gt;CDirectory&lt;/code&gt;. After that &lt;code&gt;..CD&amp;lt;tab&amp;gt;&lt;/code&gt; the completion will - again - jump back to the first &lt;em&gt;alphabetical&lt;/em&gt; item, in both cases it means &lt;code&gt;BDirectory/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why would the &lt;code&gt;-complete=customlist&lt;/code&gt; be alphabetically ordered? And is it possible to configure that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This behavior happens both on Vim  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to get completion from that path on Vim 8 and Neovim 0.2 both installed from the official Archlinux repositories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help on how to improve this question (and the ascii repository structure) is appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="10493" LastActivityDate="2017-09-15T21:12:22.907" Title="How to set -complete=customlist behavior?" Tags="|vimscript|plugin-system|autocompletion|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13584" PostTypeId="2" ParentId="11811" CreationDate="2017-09-15T13:07:31.433" Score="2" Body="&lt;p&gt;Not a real solution, but it helps loading bigger XML files with long lines. &#xA;This restricts the syntax hightlighting to a line width and everything after this is not highlighted. In this example there is no hightlighting after the 100th char. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set synmaxcol=100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or just disable syntax highlighting completely &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Enable with &lt;code&gt;:syntax on&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="14298" LastActivityDate="2017-09-15T13:07:31.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13585" PostTypeId="2" ParentId="118" CreationDate="2017-09-15T14:15:06.940" Score="4" Body="&lt;p&gt;As of now, you can simply download and compile a new spell file for the VIM. The Unicode quotes were added to the current version of the English dictionary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps, based on &lt;a href=&quot;http://henry.precheur.org/vim/create_spell_file_for_vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Create directory &lt;code&gt;~/.vim/spell&lt;/code&gt; and change to it. (The path is part of VIM's &lt;code&gt;runtimepath&lt;/code&gt;.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For English language, the dictionary can be downloaded &lt;a href=&quot;http://wordlist.aspell.net/dicts/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. (Alternatively: from &lt;a href=&quot;https://cgit.freedesktop.org/libreoffice/dictionaries/tree/en&quot; rel=&quot;nofollow noreferrer&quot;&gt;LibreOffice repo&lt;/a&gt; - you need both &lt;code&gt;.dic&lt;/code&gt; and &lt;code&gt;.aff&lt;/code&gt; files.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.B. For better results, I would recommend getting both en_US and en_GB. en_GB dictionary could be found in the LibreOffice repo.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Unzip the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unzip -x hunspell-en_US-2017.01.22.zip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The archive must at least contain these files: &lt;code&gt;en_US.aff&lt;/code&gt; and &lt;code&gt;en_US.dic&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Start VIM (in the &lt;code&gt;~/.vim/spell&lt;/code&gt; directory) and in VIM execute the command: &lt;code&gt;:mkspell! en en_US&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or if you have also downloaded en_GB files: &lt;code&gt;:mkspell! en en_US en_GB&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Exit VIM, and check the files in the current directory. There should be file &lt;code&gt;en.utf-8.spl&lt;/code&gt; created.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Done!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now, after you start VIM and activate the spell-checking for English language, it should first pick the freshly created &lt;code&gt;.spl&lt;/code&gt; file from &lt;code&gt;~/.vim/spell&lt;/code&gt; which already contains support for the Unicode quotes. At least that how it worked for me.&lt;/p&gt;&#xA;" OwnerUserId="2345" LastActivityDate="2017-09-15T14:15:06.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13586" PostTypeId="1" CreationDate="2017-09-15T14:35:45.960" Score="2" ViewCount="4965" Body="&lt;p&gt;I need an option in vim to display a text file, say &lt;code&gt;text-file&lt;/code&gt;, during the session as would&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo -e `cat text-file` | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vim is given &lt;code&gt;text-file&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;text-file&lt;/code&gt; includes text with escape sequences, such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FIELD 1             TEXT\tOF\n\tFIELD 2\n&#xA;FIELD 1             TEXT OF FIELD 2&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;vim to interpret escape sequences, so that &lt;code&gt;text-file&lt;/code&gt; in the&#xA;example above would be displayed in vim as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FIELD 1             TEXT    OF&#xA;    FIELD 2&#xA;&#xA;FIELD 1             TEXT OF FIELD 2&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14300" LastEditorUserId="205" LastEditDate="2017-09-19T04:17:28.127" LastActivityDate="2018-03-18T15:30:49.903" Title="vim to interpret escape characters (&quot;\n&quot;, &quot;\t&quot;) as does echo" Tags="|formatting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13587" PostTypeId="2" ParentId="13586" CreationDate="2017-09-15T14:59:50.360" Score="1" Body="&lt;p&gt;One solution would be to put this line in your &lt;code&gt;~/.vimrc&lt;/code&gt; file,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set listchars+=tab:&amp;gt;-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and when you want to edit a data file, execute&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will display most special characters so that they can be easily recognized without affecting the layout of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want newlines to appear as &lt;code&gt;\n&lt;/code&gt; and tabs to appear as &lt;code&gt;\t&lt;/code&gt;, you could execute the following substitutions.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\n/\\n/g&#xA;:%s/\t/\\t/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you're done editing, you can convert them back to actual newlines and tabs with the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\\n/\r/g&#xA;:%s/\\t/\t/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that Vim represents newlines as &lt;code&gt;\n&lt;/code&gt; in patterns and as &lt;code&gt;\r&lt;/code&gt; in replacement strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'list'&#xA;:help 'listchars'&#xA;:help /\n&#xA;:help sub-replace-special&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-09-15T14:59:50.360" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13588" PostTypeId="1" CreationDate="2017-09-15T16:46:48.310" Score="3" ViewCount="97" Body="&lt;p&gt;I'm using &lt;code&gt;:syn-cchar&lt;/code&gt; to replace certain syntactic elements with Unicode characters (à la &lt;a href=&quot;https://github.com/enomsg/vim-haskellConcealPlus&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-haskellConcealPlus&lt;/a&gt;). Since I'm replacing several different elements, I'd like to be able to highlight some of them differently, to match whatever color they are without my plugin. However, all conceals appear to be hardcoded to use the &lt;code&gt;Conceal&lt;/code&gt; syntax group. Is this possible to change?&lt;/p&gt;&#xA;" OwnerUserId="10315" LastActivityDate="2017-09-15T16:46:48.310" Title="Can I change the highlight of specific conceals?" Tags="|syntax-highlighting|conceal|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13589" PostTypeId="2" ParentId="11791" CreationDate="2017-09-15T19:21:28.673" Score="2" Body="&lt;p&gt;To yank a last multiline search pattern into register with &lt;a href=&quot;http://vim.wikia.com/wiki/Search_across_multiple_lines#Searching_for_multiline_HTML_comments&quot; rel=&quot;nofollow noreferrer&quot;&gt;a multiline non-greedy pattern&lt;/a&gt;, try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/func(\_.\{-});/norm gn&quot;iy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then you'll have your yanked multiline pattern (between &lt;code&gt;func(&lt;/code&gt; and &lt;code&gt;);&lt;/code&gt;) in your &lt;code&gt;@i&lt;/code&gt; register (print by &lt;code&gt;echo @i&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the command line example as per this &lt;a href=&quot;https://vi.stackexchange.com/a/5148/467&quot;&gt;post&lt;/a&gt; given &lt;code&gt;func.txt&lt;/code&gt; input file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +'sil /func\_.\{-});/norm gny' +'redi&amp;gt;&amp;gt;/dev/stdout|echon @&quot;' -scq! func.txt&#xA;func(a, b,&#xA;c,&#xA;d);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/5144/467&quot;&gt;How to print a multi-line match?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://superuser.com/q/234317/87805&quot;&gt;How can I yank multiple lines into a register?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2017-09-15T20:49:51.900" LastActivityDate="2017-09-15T20:49:51.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13590" PostTypeId="2" ParentId="13583" CreationDate="2017-09-15T21:12:22.907" Score="4" Body="&lt;p&gt;When defining a custom completion function, whatever you return &lt;em&gt;will&lt;/em&gt; go into the completion list. I.e. if you defined this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DumbnotePathsCompletion(...)&#xA;    return &quot;foo&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The completion list would &lt;strong&gt;always&lt;/strong&gt; be &quot;foo&quot; regardless of what you typed. However, vim does let you know what the user has typed so far in the form of the &lt;code&gt;ArgLead&lt;/code&gt; parameter. So if you want a list that only matches what the user has typed so far, you can do that! But you have to do it from scratch. Something like this should work I think:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DumbnotePathsCompletion(ArgLead, CmdLine, CursorPos)&#xA;       let myList = split(globpath(g:dumbnoteDefaultCollection, '**/*'), '\n')&#xA;       return filter(myList, 'v:val =~ &quot;^'. a:ArgLead .'&quot;')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's a bit going on here, but the important part is the &lt;code&gt;filter()&lt;/code&gt; command. It takes the list you generated with globpath and compares each item to &lt;code&gt;a:ArgLead&lt;/code&gt;. If  &lt;code&gt;ArgLead&lt;/code&gt; isn't part of the item then it's removed. This way only the items that match go into the completion list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally you said you wanted to only return relative paths. I'll leave this as an exercise to the reader, but suffice it to say that you could use the current working directory and remove that from any of the items in the list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#filter%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help filter()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Acommand-completion-customlist&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :command-completion-customlist&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-09-15T21:12:22.907" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13591" PostTypeId="1" AcceptedAnswerId="13592" CreationDate="2017-09-15T21:41:42.653" Score="1" ViewCount="91" Body="&lt;p&gt;I've got the following shell command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ex +'/&amp;gt;\zs\w\+\ze&amp;lt;/p' -scq! /dev/stdin &amp;lt;&amp;lt;&amp;lt;$&quot;foo&amp;gt;bar&amp;lt;buzz&quot;&#xA;foo&amp;gt;bar&amp;lt;buzz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however it's matching the whole line, instead of the pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I print only the matching pattern (&lt;code&gt;bar&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2017-09-15T23:57:20.167" Title="How to print only pattern, not a line?" Tags="|search|ex-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13592" PostTypeId="2" ParentId="13591" CreationDate="2017-09-15T23:57:20.167" Score="2" Body="&lt;p&gt;try :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ex +'s/.*&amp;gt;\(\w\+\)&amp;lt;.*/\1/|p' -scq! /dev/stdin &amp;lt;&amp;lt;&amp;lt;$&quot;foo&amp;gt;bar&amp;lt;buzz&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-09-15T23:57:20.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13593" PostTypeId="2" ParentId="13155" CreationDate="2017-09-16T04:47:27.007" Score="7" Body="&lt;p&gt;I'm going to assume that you use the latest &lt;code&gt;matchit&lt;/code&gt; plugin version &lt;a href=&quot;https://github.com/vim/vim/blob/fc2b270cfd36230166df486aae4d96d9d1f32755/runtime/pack/dist/opt/matchit/plugin/matchit.vim&quot; rel=&quot;noreferrer&quot;&gt;1.13.3&lt;/a&gt; which I could find at the moment on Vim's github repository.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;[%&lt;/code&gt; most of the time jumps to the &lt;code&gt;function!&lt;/code&gt;, occasionally&#xA;  (inconsistently depending on cursor position) jumps to the &lt;code&gt;if&lt;/code&gt;, and&#xA;  totally ignores &lt;code&gt;(&lt;/code&gt;s.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When you hit &lt;code&gt;[%&lt;/code&gt;, the &lt;code&gt;s:MultiMatch()&lt;/code&gt; function is invoked. At the end of the latter, there's a &lt;code&gt;while&lt;/code&gt; loop whose number of iterations is &lt;code&gt;v:count1&lt;/code&gt;. This variable stores the count for the last normal command. Here, it should be &lt;code&gt;1&lt;/code&gt;, because you didn't hit any number before &lt;code&gt;[%&lt;/code&gt;. But in the middle of the function, some &lt;code&gt;:normal&lt;/code&gt; commands are executed to save the screen and cursor position. These normal commands alter the value of &lt;code&gt;v:count1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check this like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno cd :&amp;lt;c-u&amp;gt;call Func()&amp;lt;cr&amp;gt;&#xA;fu! Func()&#xA;    echom v:count1&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source this code, and press &lt;code&gt;cd&lt;/code&gt;, read your messages (&lt;code&gt;:messages&lt;/code&gt;): you should see &lt;code&gt;1&lt;/code&gt;, because you didn't hit any number before &lt;code&gt;cd&lt;/code&gt;.&#xA;Now, source this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno cd :&amp;lt;c-u&amp;gt;call Func()&amp;lt;cr&amp;gt;&#xA;fu! Func()&#xA;    norm! 3G&#xA;    echom v:count1&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And do the same experiment, press &lt;code&gt;cd&lt;/code&gt; in a file with more than 3 lines. This time, in the messages, you should see &lt;code&gt;3&lt;/code&gt;, not &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of this, the &lt;code&gt;searchpair()&lt;/code&gt; function inside the loop is invoked too many times, which, I suspect, explains the behavior you described. At least, it does on my machine (Linux, Vim &lt;code&gt;8.0&lt;/code&gt; patches &lt;code&gt;1-134&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this, you could delete the &lt;a href=&quot;https://github.com/vim/vim/blob/fc2b270cfd36230166df486aae4d96d9d1f32755/runtime/pack/dist/opt/matchit/plugin/matchit.vim#L729&quot; rel=&quot;noreferrer&quot;&gt;line 729&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let level = v:count1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And move it at the beginning of the function (before any other commands, including &lt;code&gt;:normal&lt;/code&gt; commands, has the chance to alter &lt;code&gt;v:count1&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:MultiMatch(spflag, mode)&#xA;  if !exists(&quot;b:match_words&quot;) || b:match_words == &quot;&quot;&#xA;    return &quot;&quot;&#xA;  end&#xA;  let level = v:count1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NO6xy.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NO6xy.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I just tried neovim's matchit in vim (surprisingly is different than&#xA;  vim's) and it seems to work.. weird&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is probably because of the &lt;a href=&quot;https://github.com/neovim/neovim/pull/5124&quot; rel=&quot;noreferrer&quot;&gt;pull request #5124&lt;/a&gt; that neovim merged a year ago. According to the commit message, its purpose was to prevent &lt;code&gt;matchit&lt;/code&gt; to add an undesired entry in the jumplist. To solve this, the commit changed how the screen and cursor positions were saved. It doesn't use &lt;code&gt;:normal&lt;/code&gt; commands anymore, but invokes the function &lt;code&gt;winsaveview()&lt;/code&gt; and &lt;code&gt;winrestview()&lt;/code&gt;. By getting rid of &lt;code&gt;:normal&lt;/code&gt;, for a different purpose, they've also fixed the issue you described earlier, because &lt;code&gt;v:count1&lt;/code&gt; isn't modified anymore. Although it could be in the future if some commands are added in the middle of the function.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;]%&lt;/code&gt; jumps to &lt;code&gt;)&lt;/code&gt;s and nothing else.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Towards the end of the &lt;code&gt;s:MultiMatch()&lt;/code&gt; function, &lt;a href=&quot;https://github.com/vim/vim/blob/fc2b270cfd36230166df486aae4d96d9d1f32755/runtime/pack/dist/opt/matchit/plugin/matchit.vim#L722&quot; rel=&quot;noreferrer&quot;&gt;line 722&lt;/a&gt;, the pattern describing the end part of a group of tokens is defined like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let closepat = substitute(closepat, ',', '\\|', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The purpose of the substitution is to replace each comma, which separates 2 consecutive groups of tokens, with a double escaped bar which will be interpreted by Vim's regex engine as an alternation (separation between 2 branches). I think that the substitution should also replace the colons &lt;code&gt;:&lt;/code&gt; which separate the tokens inside each group. So, you could rewrite the substitution like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let closepat = substitute(closepat, '[,:]', '\\|', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this change, &lt;code&gt;]%&lt;/code&gt; should move the cursor on the various tokens described in &lt;code&gt;b:match_words&lt;/code&gt; and &lt;code&gt;&amp;amp;l:matchpairs&lt;/code&gt;, not just &lt;code&gt;)&lt;/code&gt;. At least, it does on my machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KwmYp.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KwmYp.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;va%&lt;/code&gt; behaves identically to &lt;code&gt;[%&lt;/code&gt; in this example and does not select&#xA;  anything.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;With the previous changes, in particular the 2nd one, &lt;code&gt;va%&lt;/code&gt; should select the text between the 2 surrounding tokens. Although, the plugin seems to treat a middle part of a group of tokens (like &lt;code&gt;else&lt;/code&gt; in &lt;code&gt;if|else|endif&lt;/code&gt;) as an end part (it's passed to &lt;code&gt;searchpair()&lt;/code&gt; through its 3rd argument, not its 2nd). So, what it considers to be the surrounding tokens may sometimes surprise you.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;However, neovim's &lt;code&gt;va%&lt;/code&gt; &lt;code&gt;((( )))&lt;/code&gt; does not &quot;expand&quot; after repeated &lt;code&gt;a%&lt;/code&gt;. I'm&#xA;  not sure if vim's ever did, but imo it should. just like &lt;code&gt;a(&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Currently, the visual mapping &lt;code&gt;a%&lt;/code&gt; is defined on &lt;a href=&quot;https://github.com/vim/vim/blob/fc2b270cfd36230166df486aae4d96d9d1f32755/runtime/pack/dist/opt/matchit/plugin/matchit.vim#L71&quot; rel=&quot;noreferrer&quot;&gt;line 71&lt;/a&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap a% &amp;lt;Esc&amp;gt;[%v]%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I add &lt;code&gt;o&lt;/code&gt; at the beginning of the &lt;code&gt;{rhs}&lt;/code&gt;, to move the cursor to the beginning of the selection (&lt;code&gt;:h v_o&lt;/code&gt;), I get the behavior that you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap a% o&amp;lt;Esc&amp;gt;[%v]%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2nhcf.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2nhcf.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's a &lt;a href=&quot;https://gist.githubusercontent.com/lacygoill/315ecfcacb05278a651904e88be1464a/raw/67bb02354e177a52ba43365411a061ad297ded0c/matchit1.vim&quot; rel=&quot;noreferrer&quot;&gt;version&lt;/a&gt; of the &lt;code&gt;matchit&lt;/code&gt; plugin, with the 3 small changes described so far.&lt;br&gt;&#xA;And here's &lt;a href=&quot;https://gist.githubusercontent.com/lacygoill/f9c04c3cf869a71ecfe800b40a491251/raw/14573af104776b7c142d297067695e411ff60398/matchit2.vim&quot; rel=&quot;noreferrer&quot;&gt;another one&lt;/a&gt; where I tried to also include the PR #5124 from Neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to test the code on your machine, but you don't have the rights to change the default &lt;code&gt;matchit&lt;/code&gt; plugin (or you don't want to), you can create the file &lt;code&gt;~/.vim/plugin/matchit.vim&lt;/code&gt;, and write your experimental &lt;code&gt;matchit&lt;/code&gt; plugin there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since in the runtimepath, &lt;code&gt;~/.vim&lt;/code&gt; comes before &lt;code&gt;$VIMRUNTIME&lt;/code&gt;, Vim should source your custom version before the default one. And since, the default plugin has the guard:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;loaded_matchit&quot;) || &amp;amp;cp&#xA;  finish&#xA;endif&#xA;let loaded_matchit = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... only your version should be fully sourced.&lt;/p&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-09-16T11:42:21.403" LastActivityDate="2017-09-16T11:42:21.403" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13595" PostTypeId="2" ParentId="13577" CreationDate="2017-09-16T09:41:42.147" Score="1" Body="&lt;p&gt;I think you're suggesting that &lt;code&gt;&amp;lt;cwd&amp;gt;/.vimrc&lt;/code&gt; gets loaded automatically. It &lt;em&gt;usually&lt;/em&gt; doesn't (exceptions noted below). Only one &lt;code&gt;.vimrc&lt;/code&gt; file gets loaded and that's normally going to be &lt;code&gt;$HOME/.vimrc&lt;/code&gt;. You'll know which one gets picked up because that's what you see in &lt;code&gt;$MYVIMRC&lt;/code&gt;. In other words &lt;code&gt;$MYVIMRC&lt;/code&gt; is normally set once the &lt;code&gt;.vimrc&lt;/code&gt; location has been determined as opposed to &lt;code&gt;$MYVIMRC&lt;/code&gt; dictating what Vim will load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a couple ways to subvert this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As noted in &lt;a href=&quot;https://vi.stackexchange.com/questions/13577/vim-bind-to-update-initialization-without-restarting-how-to-add-the-loading-of#comment23294_13595&quot;&gt;Mass's comment&lt;/a&gt; there actually is an option to read &lt;code&gt;.vimrc&lt;/code&gt; from the current directory! Read &lt;code&gt;:h 'exrc'&lt;/code&gt;, though, as it &lt;em&gt;strongly&lt;/em&gt; discourages use of this option for security reasons (though if you set &lt;code&gt;'secure'&lt;/code&gt; as well it's apparently less dangerous).&lt;/li&gt;&#xA;&lt;li&gt;If you are so inclined you can pre-set &lt;code&gt;$MYVIMRC&lt;/code&gt; in which case the standard vimrc location rules don't apply. See &lt;code&gt;:h .vimrc&lt;/code&gt; for a complete description of all of this.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In any case, if you want to load &lt;code&gt;.vimrc&lt;/code&gt; from your working directory in your mapping then you're right that you simply add &lt;code&gt;:so .vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI there are two ways to see what has been loaded and in what order:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Start Vim with this flag &lt;code&gt;-V2&amp;lt;outfile&amp;gt;&lt;/code&gt;. In &lt;em&gt;outfile&lt;/em&gt; you will see some verbose output that includes all sourced files.&lt;/li&gt;&#xA;&lt;li&gt;If Vim is already running do &lt;code&gt;:scriptnames&lt;/code&gt; to display sourced files.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-09-17T22:38:32.537" LastActivityDate="2017-09-17T22:38:32.537" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13596" PostTypeId="2" ParentId="2046" CreationDate="2017-09-16T10:57:34.563" Score="8" Body="&lt;p&gt;&lt;strong&gt;GDB &lt;code&gt;edit&lt;/code&gt; command&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Opens an editor on the current line using the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$EDITOR +&amp;lt;current-line&amp;gt; &amp;lt;current-file&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default &lt;code&gt;editor&lt;/code&gt; is &lt;code&gt;ex&lt;/code&gt;, but &lt;code&gt;vim&lt;/code&gt; also understands the &lt;code&gt;+&amp;lt;current-line&amp;gt;&lt;/code&gt; format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you quit the editor, you get back into &lt;code&gt;gdb&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This allows you to browse the source freely and is specially powerfull if you have &lt;code&gt;ctags&lt;/code&gt; integration. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a poor-man's built-in one way gdb to vim integration: the main missing thing is setting breakpoints from Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;code&gt;edit&lt;/code&gt; and center&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;edit&lt;/code&gt; does not center Vim by default around the source, so I've created a Python script that does it: &lt;a href=&quot;https://stackoverflow.com/questions/43557405/how-to-open-the-current-file-at-the-current-line-in-a-text-editor-from-gdb/43557406#43557406&quot;&gt;https://stackoverflow.com/questions/43557405/how-to-open-the-current-file-at-the-current-line-in-a-text-editor-from-gdb/43557406#43557406&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Breakpoint command to clipboard helper&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This vim command copies a breakpoint specifier of type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b &amp;lt;file-path&amp;gt;:&amp;lt;line-number&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to the clipboard:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Xg :let @+ = 'b ' . expand('%:p') . ':' . line('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can just paste that into &lt;code&gt;gdb&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a poor man's vim to gdb integration to ease setting breakpoints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;a href=&quot;https://stackoverflow.com/questions/3536600/do-you-debug-c-code-in-vim-how&quot;&gt;https://stackoverflow.com/questions/3536600/do-you-debug-c-code-in-vim-how&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2038" LastEditorUserId="2038" LastEditDate="2018-12-29T14:40:44.120" LastActivityDate="2018-12-29T14:40:44.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13598" PostTypeId="1" AcceptedAnswerId="13600" CreationDate="2017-09-16T12:53:53.013" Score="4" ViewCount="334" Body="&lt;p&gt;I'd just want to get confirmation on (and maybe some background to) the way that Bill Joy's &lt;code&gt;vi&lt;/code&gt;, sometimes found as &lt;code&gt;traditional-vi&lt;/code&gt; on some BSD systems, handles regular expressions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems as if most &quot;special characters&quot; needs to be escaped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Writing, e.g., &lt;code&gt;:s/./x/g&lt;/code&gt; will not replace all characters on the line with &lt;code&gt;x&lt;/code&gt;, but &lt;code&gt;:s/\./x/g&lt;/code&gt; will.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Likewise, &lt;code&gt;*&lt;/code&gt; needs to be escaped and the first &lt;code&gt;[&lt;/code&gt; of any character group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Is this the historic behaviour of Bill's implementation of &lt;code&gt;vi&lt;/code&gt;?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm testing on OpenBSD 6.1-stable with the &lt;code&gt;traditional-vi-20050325p0&lt;/code&gt; package, which takes its sources from &lt;a href=&quot;http://ex-vi.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://ex-vi.sourceforge.net/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ex-vi.sourceforge.net/Changes&quot; rel=&quot;nofollow noreferrer&quot;&gt;The document entitled &quot;Changes in ex and vi&quot;&lt;/a&gt; mentions &quot;traditional regular expressions&quot;. However, I have not found any place detailing what the differences are between these and modern POSIX BREs and EREs. Or whether &quot;traditional&quot; in this context is the same as &quot;basic&quot; (as in BRE) or if the escaping of &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; etc. has anything to do with an older type of regular expressions at all.&lt;/p&gt;&#xA;" OwnerUserId="2252" LastEditorUserId="2252" LastEditDate="2017-09-16T13:17:02.583" LastActivityDate="2017-09-17T02:15:17.467" Title="Traditional Vi and its regular expressions" Tags="|regular-expression|history-of|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13600" PostTypeId="2" ParentId="13598" CreationDate="2017-09-17T02:08:50.093" Score="5" Body="&lt;p&gt;It's always been my understanding that &lt;code&gt;vi&lt;/code&gt; followed the POSIX standard (BRE/ERE). Given the far more tight-knit technical community/ecosystem of the time I think he would have to have been a bit mad to veer from the standard of the time if he wanted people to adopt his editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't currently have any direct evidence for this (like a quote from Bill himself) but this &lt;a href=&quot;https://docs.freebsd.org/44doc/usd/13.viref/paper.pdf&quot; rel=&quot;noreferrer&quot;&gt;1997 Vi/Ex Reference Manual&lt;/a&gt; (PDF, page &lt;em&gt;USD:13-10&lt;/em&gt;) says...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The regular expressions supported by ex/vi are, by default, the Basic Regular&#xA;  Expressions (BRE’s) described in the IEEE POSIX Standard 1003.2. The extended option&#xA;  causes all regular expressions to be interpreted as the Extended Regular Expressions&#xA;  (ERE’s) described by the same standard.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note also the immediately following text which talks about special meaning characters and the &quot;magic&quot; business a bit so that is evidence that it is the &quot;historic behavior&quot; you mention, IMO.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-09-17T02:15:17.467" LastActivityDate="2017-09-17T02:15:17.467" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13601" PostTypeId="2" ParentId="7457" CreationDate="2017-09-17T03:19:00.003" Score="5" Body="&lt;p&gt;As Roflo and Rich mentioned in their comment &lt;a href=&quot;https://vi.stackexchange.com/questions/7457/which-alternatives-to-gvim-exist-on-windows#comment12229_7457&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/7457/which-alternatives-to-gvim-exist-on-windows#comment16039_7457&quot;&gt;here&lt;/a&gt;, your problem with being unable to use visual block (I'm not sure what &lt;code&gt;rx&lt;/code&gt; command is) is because the system-wide vimrc (&lt;code&gt;$VIM\_vimrc&lt;/code&gt;) sources &lt;code&gt;$VIMRUNTIME\mswin.vim&lt;/code&gt; which defines Windows-style mappings like &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; for paste, &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt; for copy, &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt; for cut.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way to get around this is to create a &lt;code&gt;_vimrc&lt;/code&gt; files in your home directory (Note that Windows version of vim uses &lt;code&gt;_vimrc&lt;/code&gt; instead of &lt;code&gt;.vimrc&lt;/code&gt;). As you can see in &lt;code&gt;:h vimrc&lt;/code&gt;, vim looks for vimrc in several locations and only uses the first one it finds while ignoring the rest. The one in the home directory is always searched/used first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Minimal steps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;open gvim or vim&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:e ~/_vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:w&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5072" LastEditorUserId="4472" LastEditDate="2017-10-30T10:52:57.783" LastActivityDate="2017-10-30T10:52:57.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13602" PostTypeId="1" AcceptedAnswerId="13606" CreationDate="2017-09-17T06:53:27.410" Score="3" ViewCount="718" Body="&lt;p&gt;I was solving a problem on Vimgolf (you can take a look at &lt;a href=&quot;http://www.vimgolf.com/challenges/56fb2e75ccffcc0009026473&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;) where I stumbled upon this solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;djgJ.V&quot;=[&amp;lt;C-R&amp;gt;&amp;lt;C-A&amp;gt;]&amp;lt;CR&amp;gt;pZZ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could you please walk me through the meaning of this cryptic keystrokes &lt;code&gt;&quot;=[&amp;lt;C-R&amp;gt;&amp;lt;C-A&amp;gt;]&amp;lt;CR&amp;gt;p&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="14316" LastActivityDate="2017-09-17T15:52:47.760" Title="The meaning of &quot;= in Vim" Tags="|command-line|cut-copy-paste|visual-mode|visual-block|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13603" PostTypeId="1" AcceptedAnswerId="13991" CreationDate="2017-09-17T14:05:45.687" Score="14" ViewCount="46153" Body="&lt;p&gt;I frequently find myself trying to do transformations like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  author    = {{foo&#xA;                bar}},&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  author    = {foo&#xA;                bar},&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I can't find a regex to match the part in between the curly braces.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/{{\(.*\)}}/{\1}/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't work since &lt;code&gt;.&lt;/code&gt; does not match newlines. But &lt;code&gt;[\.\r]&lt;/code&gt; or something doesn't seem to work either. I tried &lt;code&gt;[\s\S]&lt;/code&gt; as well to match whitespace and non-whitespace, but to no avail.&lt;/p&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2017-10-20T14:52:53.410" Title="Regex to match any character including newline" Tags="|regular-expression|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13604" PostTypeId="2" ParentId="13603" CreationDate="2017-09-17T14:10:34.230" Score="1" Body="&lt;p&gt;Turns out one must use &lt;code&gt;\_.*&lt;/code&gt; instead of &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2017-09-17T14:10:34.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13605" PostTypeId="2" ParentId="13602" CreationDate="2017-09-17T14:51:45.357" Score="3" Body="&lt;p&gt;&lt;code&gt;&quot;=&lt;/code&gt; refers to the expression register, which lets you evaluate a bit of vimscript and have vim act like the result of this expression was placed into a register.   &lt;code&gt;&quot;=&lt;/code&gt;&lt;em&gt;expression&lt;/em&gt;&lt;code&gt;&amp;lt;cr&amp;gt;p&lt;/code&gt; is a common idiom to put the result of an expression.  It is a special case of the sequence &lt;code&gt;&quot;ap&lt;/code&gt; where &lt;code&gt;a&lt;/code&gt; is a register.  The key is that this works in visual mode, replacing the existing text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;V&quot;=[&amp;lt;C-R&amp;gt;&amp;lt;C-A&amp;gt;]&amp;lt;CR&amp;gt;p&lt;/code&gt; is a clever (though obtuse) way to turn a comma-separated list into a set of lines.  Prior to pressing &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; this expression looks like &lt;code&gt;[2,3,5,7,11,13,17,19,23,29,]&lt;/code&gt; which is just a list of numbers.  When using &lt;code&gt;p&lt;/code&gt; to put a register that is set to a list, vim distributes the list one entry per line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-R&amp;gt;&amp;lt;C-A&amp;gt;&lt;/code&gt; means put the WORD under the cursor into the command line, which in this case is the entire line.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-09-17T14:51:45.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13606" PostTypeId="2" ParentId="13602" CreationDate="2017-09-17T14:54:32.290" Score="6" Body="&lt;p&gt;For context I'll go over the whole thing. First I'll describe the operations generally and then how they apply to the golf problem specifically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;General Description&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;dj&lt;/code&gt; : Delete with 'one line down motion' (delete current and following line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gJ&lt;/code&gt; : Join current and next line, adding no extra spaces&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt; : Repeat the join&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt; : Line-wise visual selection of the current line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;=&lt;/code&gt; : Prepare to store something into the expression register (&lt;code&gt;=&lt;/code&gt;). &lt;strong&gt;Unlike other registers the expression register is populated from the command line and these two keystrokes take you there.&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[&amp;lt;C-R&amp;gt;&amp;lt;C-A&amp;gt;]&amp;lt;CR&amp;gt;&lt;/code&gt; : &lt;code&gt;Ctrl-R+Ctrl-A&lt;/code&gt; grabs the WORD under the cursor and inserts it into the command line. So store into the expression register (&lt;code&gt;=&lt;/code&gt;) a string that consists of the WORD surrounded by square brackets. The &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is a literal as if you hit &lt;kbd&gt;Enter&lt;/kbd&gt; (just like &lt;code&gt;&amp;lt;C-R&amp;gt;&amp;lt;C-A&amp;gt;&lt;/code&gt; is as if you hit those keys).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; : Overwrite the visually selected text with the contents of the register&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ZZ&lt;/code&gt; - Save and exit Vim&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Golf Problem&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;djgJ.&lt;/code&gt; : Delete the first two lines and join the next two so you have a single line of comma-separated numbers&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt; : Visually select the whole line&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;&quot;=[&amp;lt;C-R&amp;gt;&amp;lt;C-A&amp;gt;]&amp;lt;CR&amp;gt;&lt;/code&gt; : insert into the expression register the bracketed, comma-separated list of numbers: &lt;code&gt;[2,3,5,7,11,13,17,19,23,29,]&lt;/code&gt;. The whole line is one WORD in this case which is why it all gets pulled in. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;p&lt;/code&gt; : Overwrite the comma-separated list of numbers with all the numbers on separate lines. &lt;strong&gt;The expression register is special in that when you &lt;code&gt;p&lt;/code&gt;ut it its contents get &lt;em&gt;evaluated&lt;/em&gt; as an expression first.&lt;/strong&gt; When a comma-separated list &lt;em&gt;expression&lt;/em&gt; is evaluated it resolves into each element on a separate line. E.g. &lt;code&gt;[a,b,c]&lt;/code&gt; evaluates to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a&lt;br&gt;&#xA; b&lt;br&gt;&#xA; c&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ZZ&lt;/code&gt; - Save and exit Vim&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-09-17T15:52:47.760" LastActivityDate="2017-09-17T15:52:47.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13607" PostTypeId="1" AcceptedAnswerId="13647" CreationDate="2017-09-17T18:47:57.493" Score="1" ViewCount="615" Body="&lt;p&gt;How do I change the name of Nerdtree tab in the powerline where it displays filename&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rightnow it displays it as &lt;code&gt;~/dir/dir/NERD_tree_1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want it to be displayed &lt;code&gt;Nerd Tree&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14320" LastActivityDate="2017-09-25T08:14:19.263" Title="Change the powerline name for nerdtree" Tags="|plugin-nerdtree|plugin-powerline|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13609" PostTypeId="1" CreationDate="2017-09-18T01:41:30.967" Score="2" ViewCount="49" Body="&lt;p&gt;Let's see an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;block&#xA;    property Property1&#xA;        key: value&#xA;    end&#xA;    property Property2&#xA;        key: value&#xA;    end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to let property/end pair highlight only in block/end region, and key:value highlight only in property/end region. In this case how do I define the end of the region?&lt;/p&gt;&#xA;" OwnerUserId="8820" LastActivityDate="2017-09-18T01:41:30.967" Title="Define region in region with same end match" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13610" PostTypeId="1" CreationDate="2017-09-18T01:42:01.543" Score="0" ViewCount="47" Body="&lt;p&gt;I'm using Vundle and have &lt;a href=&quot;https://github.com/othree/xml.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;othree/xml.vim&lt;/a&gt; installed, as well as my own bundle for working with PHP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My PHP bundle has the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('b:did_ftplugin') &amp;amp;&amp;amp; 1 == b:did_ftplugin&#xA;    finish&#xA;endif&#xA;&#xA;&quot; ... various things here.&#xA;&#xA;setlocal iskeyword=$,a-z,A-Z,48-57,_-_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the &lt;code&gt;iskeyword&lt;/code&gt; option does NOT contain what I've specified above. If I type &lt;code&gt;verbose set iskeyword?&lt;/code&gt; I get the following output.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iskeyword=@,48-57,_,192-255,58,-&#xA;    Last set from ~/.vim/bundle/xml.vim/ftplugin/xml.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Disabling the &lt;code&gt;othree/xml.vim&lt;/code&gt; plugin solves this problem, but I don't understand why it would be executing in the first place, as the file type is &lt;code&gt;php&lt;/code&gt; and not &lt;code&gt;xml&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers?&lt;/p&gt;&#xA;" OwnerUserId="10101" LastEditorUserId="51" LastEditDate="2017-09-18T03:40:00.470" LastActivityDate="2017-09-18T03:52:47.527" Title="Why is my XML filetype configuration overridding my PHP filetype configuration?" Tags="|filetype-php|filetype-xml|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13611" PostTypeId="2" ParentId="13610" CreationDate="2017-09-18T03:52:47.527" Score="2" Body="&lt;p&gt;The PHP filetype loads the HTML filetype; from &lt;code&gt;$VIMRUNTIME/syntax/php.vim&lt;/code&gt; (around like 63):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime! syntax/html.vim&#xA;unlet b:current_syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because PHP is layered &quot;on top&quot; of HTML, and you can start/stop with the &lt;code&gt;&amp;lt;?php&lt;/code&gt; and &lt;code&gt;?&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That plugin of yours ships with a &lt;a href=&quot;https://github.com/othree/xml.vim/blob/master/ftplugin/html.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;ftplugin/html.vim&lt;/code&gt;&lt;/a&gt; file which load the &lt;code&gt;ftplugin/xml.vim&lt;/code&gt; syntax file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way you can fix this is by resetting the &lt;code&gt;iskeyword&lt;/code&gt; value from an &lt;code&gt;autocmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup fix_php&#xA;    autocmd FileType php setlocal iskeyword&amp;amp;vim&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;iskeyword&amp;amp;vim&lt;/code&gt; will reset it to the default Vim value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also consider creating a bug report on their issue tracker.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-09-18T03:52:47.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13612" PostTypeId="1" AcceptedAnswerId="13613" CreationDate="2017-09-18T19:31:10.543" Score="3" ViewCount="6154" Body="&lt;p&gt;I'm trying to use &lt;code&gt;:!&lt;/code&gt; to run my test suite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The file I'm working on is: &#xA;&lt;code&gt;/foo/bar/baz.py&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My tests are in:&#xA;&lt;code&gt;/foo/test&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried running &lt;code&gt;:!../python -m unittest test&lt;/code&gt; but I get the following &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error:/bin/bash: ../python: No such file or directory&#xA;&#xA;shell returned 127&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I tell VIm to execute a command in the parent directory of my currently loaded buffer? Or more generally, can I tell VIm to execute a command in the root folder of my project regardless of what file I am looking at?&lt;/p&gt;&#xA;" OwnerUserId="11547" LastActivityDate="2017-09-18T21:07:53.100" Title="Executing a shell command in the parent directory" Tags="|external-command|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13613" PostTypeId="2" ParentId="13612" CreationDate="2017-09-18T20:22:21.063" Score="7" Body="&lt;p&gt;To execute a command in the parent directory of Vim's current working directory, just precede the command with &lt;code&gt;cd ..;&lt;/code&gt;, like this example using &lt;code&gt;ls&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!cd ..; ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To execute a command in the parent directory of the current buffer, precede the command with &lt;code&gt;cd %:h/..&lt;/code&gt;, e.g.,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!cd %:h/..; ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help filename-modifiers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to execute a command in the root folder of your project depends on its relationship to Vim's current working directory or on whether there is some environment variable naming it. In the latter case, say your project root directory is in $PROJROOT, then the Vim command would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!cd $PROJROOT; ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that since Vim executes &lt;code&gt;:!&lt;/code&gt; command in a sub-shell, the &lt;code&gt;cd&lt;/code&gt; affects only that sub-shell and doesn't affect Vim's current working directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you start Vim in the root folder of your project and don't have &lt;code&gt;'autochdir'&lt;/code&gt; set, Vim's current working directory will remain the root folder regardless of the file you are looking at and executing your command in that directory should just work without the need for any leading &lt;code&gt;:!cd ...&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-09-18T20:22:21.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13614" PostTypeId="2" ParentId="13612" CreationDate="2017-09-18T20:53:12.937" Score="2" Body="&lt;p&gt;The problem is the command being invalid. Your shell &lt;code&gt;/bin/bash&lt;/code&gt; searches for an executable, in this case &lt;code&gt;python&lt;/code&gt; (try &lt;code&gt;which python&lt;/code&gt; to see where it is located), which in turn requires specific arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;test&lt;/code&gt; is the path, assuming you are one directory down, the correct command would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!python -m unittest ../test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/a/13613/12003&quot;&gt;garyjohn&lt;/a&gt; explained here, you can change the (sub) shell directory (the one created by &lt;code&gt;bash&lt;/code&gt;) with &lt;code&gt;:!cd&lt;/code&gt;. Yet another alternative is to set Vim's current directory (&lt;code&gt;:pwd&lt;/code&gt;) with &lt;code&gt;:cd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You will also find tons of plugins fulfilling this use case (run a program in the background, linter or compiler for example), &lt;a href=&quot;https://github.com/janko-m/vim-test&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-test&lt;/a&gt; comes up as the first Google result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is &lt;a href=&quot;https://github.com/vim-syntastic/syntastic&quot; rel=&quot;nofollow noreferrer&quot;&gt;Syntastic&lt;/a&gt;, a fully-featured syntax checker but lacks asynchronous capability, blocking the terminal while waiting for the program to run. That may change since Vim 8 supports async jobs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you run Neovim, &lt;a href=&quot;https://github.com/neomake/neomake&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neomake&lt;/a&gt; is the perfect match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though I switched to the &lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;Asynchronous Lint Engine&lt;/a&gt; and I am still using it today.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use a lot of other filetypes as well, combine one of these linters with the language pack &lt;a href=&quot;https://github.com/sheerun/vim-polyglot&quot; rel=&quot;nofollow noreferrer&quot;&gt;polyglot&lt;/a&gt; and you are good to go!&lt;/p&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2017-09-18T21:07:53.100" LastActivityDate="2017-09-18T21:07:53.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13615" PostTypeId="2" ParentId="12961" CreationDate="2017-09-19T00:00:29.017" Score="5" Body="&lt;p&gt;There is an option for this:&#xA;&lt;code&gt;set cpoptions+=x&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help cpo-x&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    x   &amp;lt;Esc&amp;gt; on the command-line executes the command-line.&#xA;        The default in Vim is to abandon the command-line,&#xA;        because &amp;lt;Esc&amp;gt; normally aborts a command.  |c_&amp;lt;Esc&amp;gt;|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is also the default vim behavior when &lt;code&gt;compatible&lt;/code&gt; is set, and is the behavior of vi in distributions that ship the &quot;real thing,&quot; such as Arch Linux.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-09-19T00:08:07.117" LastActivityDate="2017-09-19T00:08:07.117" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13616" PostTypeId="1" CreationDate="2017-09-19T00:29:32.803" Score="11" ViewCount="6157" Body="&lt;p&gt;How would I use &lt;code&gt;set iskeyword&lt;/code&gt; to be able to use &lt;code&gt;w&lt;/code&gt; to count Capital letters as words?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example for the following sentence,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ThisIsAShortSentence&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;code&gt;w&lt;/code&gt; will jump from &lt;code&gt;T&lt;/code&gt; -&gt; &lt;code&gt;I&lt;/code&gt; -&gt; &lt;code&gt;A&lt;/code&gt; -&gt; &lt;code&gt;S&lt;/code&gt; -&gt; &lt;code&gt;S&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14339" LastEditorUserId="1841" LastEditDate="2017-09-19T07:26:40.350" LastActivityDate="2023-11-21T01:50:10.067" Title="How to use 'w' to navigate in CamelCase words?" Tags="|cursor-motions|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13617" PostTypeId="2" ParentId="13616" CreationDate="2017-09-19T03:43:22.120" Score="8" Body="&lt;p&gt;This is not how &lt;code&gt;w&lt;/code&gt; and &lt;code&gt;iskeyword&lt;/code&gt; works.  Consider this example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;!his!s!!hort!entence&#xA;^^  ^^^ ^   ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Pressing &lt;code&gt;w&lt;/code&gt; repeatedly, you will see the cursor stops where sequences of &lt;code&gt;!&lt;/code&gt;s meet sequences of alpha characters- there are 8 stops in total (including the first position).  Put differently, &lt;code&gt;w&lt;/code&gt; will only skip over sequences of non-keyword characters if those characters happen to be spaces, tabs, or EOL.  Otherwise, it will stop at symbols before moving on to the next word.&lt;/p&gt;&#xA;&lt;h3&gt;Alternative&lt;/h3&gt;&#xA;&lt;p&gt;I would recommend not removing alpha characters from &lt;code&gt;iskeyword&lt;/code&gt; because its effect is too far-reaching.  Consider the following map:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-k&amp;gt; :&amp;lt;c-u&amp;gt;call search('\u')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;K&lt;/kbd&gt; will move to the next upper case character.&lt;/p&gt;&#xA;&lt;h3&gt;Update for recent vim&lt;/h3&gt;&#xA;&lt;p&gt;Since the introduction of &lt;code&gt;&amp;lt;cmd&amp;gt;&lt;/code&gt;, we can handle visual mode easily&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;c-k&amp;gt; &amp;lt;cmd&amp;gt;call search('\u')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2023-11-21T01:50:10.067" LastActivityDate="2023-11-21T01:50:10.067" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="13618" PostTypeId="2" ParentId="13616" CreationDate="2017-09-19T07:24:55.313" Score="5" Body="&lt;p&gt;You may be interested in a plugin like &lt;a href=&quot;https://github.com/bkad/CamelCaseMotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;camelCaseMotion&lt;/a&gt; which defines some new motions to navigate in the different parts of a camel case word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will not override &lt;code&gt;w&lt;/code&gt; cause that's not how this motion is designed to work but it will provide some functions that you can map to the key sequence that you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it should also work with &lt;code&gt;snake_case&lt;/code&gt; words.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-09-19T11:20:08.720" LastActivityDate="2017-09-19T11:20:08.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13619" PostTypeId="2" ParentId="13616" CreationDate="2017-09-19T07:33:29.017" Score="2" Body="&lt;p&gt;I have copied this wonderful solution from somewhere, but i don't know the source anymore. So it is not my work, but a wonderful documented solution. I only use it as text-object in commands with &lt;code&gt;H&lt;/code&gt; and &lt;code&gt;L&lt;/code&gt; but everything else is there als comment.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use one of the following to define the camel characters.&#xA;&quot; Stop on capital letters.&#xA;&quot; let g:camelchar = &quot;A-Z&quot;&#xA;&quot; Also stop on numbers.&#xA;&quot; let g:camelchar = &quot;A-Z0-9&quot;&#xA;&quot; Include '.' for class member, ',' for separator, ';' end-statement,&#xA;&quot; and &amp;lt;[&amp;lt; bracket starts and &quot;'` quotes.&#xA;let g:camelchar = &quot;A-Z0-9_.,;:{([&amp;lt;`'\&quot;&quot;&#xA;&quot; nnoremap &amp;lt;silent&amp;gt;&amp;lt;Left&amp;gt; :&amp;lt;C-u&amp;gt;call search('\C\&amp;lt;\&amp;lt;Bar&amp;gt;\%(^\&amp;lt;Bar&amp;gt;[^'.g:camelchar.']\@&amp;lt;=\)['.g:camelchar.']\&amp;lt;Bar&amp;gt;['.g:camelchar.']\ze\%([^'.g:camelchar.']\&amp;amp;\&amp;gt;\@!\)\&amp;lt;Bar&amp;gt;\%^','bW')&amp;lt;CR&amp;gt;&#xA;&quot; nnoremap &amp;lt;silent&amp;gt;&amp;lt;Right&amp;gt; :&amp;lt;C-u&amp;gt;call search('\C\&amp;lt;\&amp;lt;Bar&amp;gt;\%(^\&amp;lt;Bar&amp;gt;[^'.g:camelchar.']\@&amp;lt;=\)['.g:camelchar.']\&amp;lt;Bar&amp;gt;['.g:camelchar.']\ze\%([^'.g:camelchar.']\&amp;amp;\&amp;gt;\@!\)\&amp;lt;Bar&amp;gt;\%$','W')&amp;lt;CR&amp;gt;&#xA;&quot; inoremap &amp;lt;silent&amp;gt;&amp;lt;Left&amp;gt; &amp;lt;C-o&amp;gt;:call search('\C\&amp;lt;\&amp;lt;Bar&amp;gt;\%(^\&amp;lt;Bar&amp;gt;[^'.g:camelchar.']\@&amp;lt;=\)['.g:camelchar.']\&amp;lt;Bar&amp;gt;['.g:camelchar.']\ze\%([^'.g:camelchar.']\&amp;amp;\&amp;gt;\@!\)\&amp;lt;Bar&amp;gt;\%^','bW')&amp;lt;CR&amp;gt;&#xA;&quot; inoremap &amp;lt;silent&amp;gt;&amp;lt;Right&amp;gt; &amp;lt;C-o&amp;gt;:call search('\C\&amp;lt;\&amp;lt;Bar&amp;gt;\%(^\&amp;lt;Bar&amp;gt;[^'.g:camelchar.']\@&amp;lt;=\)['.g:camelchar.']\&amp;lt;Bar&amp;gt;['.g:camelchar.']\ze\%([^'.g:camelchar.']\&amp;amp;\&amp;gt;\@!\)\&amp;lt;Bar&amp;gt;\%$','W')&amp;lt;CR&amp;gt;&#xA;&quot; vnoremap &amp;lt;silent&amp;gt;&amp;lt;Left&amp;gt; :&amp;lt;C-U&amp;gt;call search('\C\&amp;lt;\&amp;lt;Bar&amp;gt;\%(^\&amp;lt;Bar&amp;gt;[^'.g:camelchar.']\@&amp;lt;=\)['.g:camelchar.']\&amp;lt;Bar&amp;gt;['.g:camelchar.']\ze\%([^'.g:camelchar.']\&amp;amp;\&amp;gt;\@!\)\&amp;lt;Bar&amp;gt;\%^','bW')&amp;lt;CR&amp;gt;v`&amp;gt;o&#xA;&quot; vnoremap &amp;lt;silent&amp;gt;&amp;lt;Right&amp;gt; &amp;lt;Esc&amp;gt;`&amp;gt;:&amp;lt;C-U&amp;gt;call search('\C\&amp;lt;\&amp;lt;Bar&amp;gt;\%(^\&amp;lt;Bar&amp;gt;[^'.g:camelchar.']\@&amp;lt;=\)['.g:camelchar.']\&amp;lt;Bar&amp;gt;['.g:camelchar.']\ze\%([^'.g:camelchar.']\&amp;amp;\&amp;gt;\@!\)\&amp;lt;Bar&amp;gt;\%$','W')&amp;lt;CR&amp;gt;v`&amp;lt;o&#xA;&#xA;&quot; Move CamelCase with H &amp;amp; L but only as text-object&#xA;onoremap &amp;lt;silent&amp;gt;H :&amp;lt;C-u&amp;gt;call search('\C\&amp;lt;\&amp;lt;Bar&amp;gt;\%(^\&amp;lt;Bar&amp;gt;[^'.g:camelchar.']\@&amp;lt;=\)['.g:camelchar.']\&amp;lt;Bar&amp;gt;['.g:camelchar.']\ze\%([^'.g:camelchar.']\&amp;amp;\&amp;gt;\@!\)\&amp;lt;Bar&amp;gt;\%^','bW')&amp;lt;CR&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt;L :&amp;lt;C-u&amp;gt;call search('\C\&amp;lt;\&amp;lt;Bar&amp;gt;\%(^\&amp;lt;Bar&amp;gt;[^'.g:camelchar.']\@&amp;lt;=\)['.g:camelchar.']\&amp;lt;Bar&amp;gt;['.g:camelchar.']\ze\%([^'.g:camelchar.']\&amp;amp;\&amp;gt;\@!\)\&amp;lt;Bar&amp;gt;\%$','W')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11316" LastEditorUserId="11316" LastEditDate="2017-09-20T11:32:33.697" LastActivityDate="2017-09-20T11:32:33.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13621" PostTypeId="1" AcceptedAnswerId="13629" CreationDate="2017-09-19T09:56:26.850" Score="3" ViewCount="1373" Body="&lt;p&gt;This is a usual shortcut in other editors: indent the current line to the right with &lt;kbd&gt;CMD&lt;/kbd&gt;+&lt;kbd&gt;]&lt;/kbd&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can achieve this in MacVim without leaving the insert mode?&lt;/p&gt;&#xA;" OwnerUserId="14347" LastEditorUserId="4472" LastEditDate="2017-09-22T07:40:18.757" LastActivityDate="2017-11-14T11:02:07.897" Title="Indent line to the right with CMD + ] in insert mode" Tags="|key-bindings|macvim|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13622" PostTypeId="2" ParentId="13586" CreationDate="2017-09-19T12:37:04.910" Score="2" Body="&lt;p&gt;A workaround would be to invoke the command from within Vim, allowing you to display escaped characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!echo -e &quot;$(cat)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;code&gt;%&lt;/code&gt; is a range equal to the entire file, and &lt;code&gt;cat&lt;/code&gt; is used to pass the standard input to &lt;code&gt;echo -e&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that you won't be able to determine which tabs or newlines were delimiters and which were not, thus loosing the ability to revert the file to its original state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have to save the file, you will need to apply a method similar to what &lt;a href=&quot;https://vi.stackexchange.com/a/13587/12003&quot;&gt;garyjohn proposed&lt;/a&gt;, that is replacing with substitute (&lt;code&gt;:%s&lt;/code&gt;) either delimiters themselves or those found in the data before and after editing.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-09-19T12:37:04.910" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13623" PostTypeId="1" AcceptedAnswerId="13644" CreationDate="2017-09-19T15:31:06.287" Score="19" ViewCount="9626" Body="&lt;p&gt;I have html settings set up in my &lt;code&gt;~/.vim/ftplugin/html.vim&lt;/code&gt; file.  I would like these settings to apply to Rhtml files as well.  I made a symbolic link with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ln -s ~/.vim/ftplugin/html.vim ~/.vim/ftplugin/Rhtml.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why doesn't this load my html settings when I open a .Rhtml file?&lt;/p&gt;&#xA;" OwnerUserId="14354" LastEditorUserId="14354" LastEditDate="2017-10-01T02:56:07.593" LastActivityDate="2021-04-23T10:41:52.003" Title="How to create a new vim filetype?" Tags="|filetype|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13624" PostTypeId="5" CreationDate="2017-09-19T15:45:54.790" Score="0" Body="&lt;p&gt;SpaceVim is a community-driven modular vim distribution. It manages collections of plugins in layers, which help collect related packages together to provide IDE-like features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Official GitHub : &lt;a href=&quot;https://github.com/SpaceVim/SpaceVim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/SpaceVim/SpaceVim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/13142418/37595020-273b5bca-2bb2-11e8-8aba-638ed5f1c7ea.png&quot; alt=&quot;welcome-page&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7942" LastEditorUserId="7942" LastEditDate="2018-03-29T19:19:55.770" LastActivityDate="2018-03-29T19:19:55.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13625" PostTypeId="4" CreationDate="2017-09-19T15:45:54.790" Score="0" Body="SpaceVim is a community-driven vim distribution" OwnerUserId="7942" LastEditorUserId="7942" LastEditDate="2018-03-30T02:12:56.547" LastActivityDate="2018-03-30T02:12:56.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13626" PostTypeId="1" AcceptedAnswerId="13628" CreationDate="2017-09-19T15:54:48.733" Score="0" ViewCount="634" Body="&lt;p&gt;On a text file with a hyperlink (&lt;code&gt;http://url/&lt;/code&gt;) if I hover the mouse over the hyperlink and click on it, it is opened on chrome. How can I change the browser that vim decides to use when following hyperlinks, so that I can change the default web browser to firefox?&lt;/p&gt;&#xA;" OwnerUserId="14356" LastEditorUserId="1841" LastEditDate="2017-09-20T06:48:29.633" LastActivityDate="2017-09-20T06:48:29.633" Title="How to setup the default browser to follow hyperlinks" Tags="|external-command|navigation|mouse|" AnswerCount="1" CommentCount="7" FavoriteCount="0" ClosedDate="2017-09-20T11:23:04.737" ContentLicense="CC BY-SA 3.0" />
  <row Id="13627" PostTypeId="2" ParentId="13621" CreationDate="2017-09-19T17:00:59.220" Score="2" Body="&lt;p&gt;The rhs of that mapping is difficult because there's no easily reliable way to jump back to the right column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two backticks returns to the previous jump point, so that &lt;em&gt;might&lt;/em&gt; work, although it's not behaving reliably for me at the moment.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;D-]&amp;gt; &amp;lt;Esc&amp;gt;&amp;gt;&amp;gt;``i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could mark your current spot, but that mark stays in the same column, so once you indent, that column is no longer correct (it's off by whatever you have shiftwidth set to). If you &lt;em&gt;always&lt;/em&gt; set tabstop and shiftwidth to the same thing (e.g. you &lt;em&gt;always&lt;/em&gt; do 2 spaces), you could get around that with something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;D-]&amp;gt; &amp;lt;Esc&amp;gt;ma&amp;gt;&amp;gt;`alla&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'd have a similar problem with &lt;code&gt;gi&lt;/code&gt; (return to previous insert point) but even worse, because you'd actually be back in insert mode shiftwidth characters before where you want to be, so you'd have to have multiple &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think a better solution is to properly configure your indenting and then you won't even need to do this. E.g. &lt;code&gt;:h autoindent&lt;/code&gt;, &lt;code&gt;:h smartindent&lt;/code&gt; and &lt;code&gt;:h cindent&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that these mappings won't work in terminal vim since Cmd is consumed by the terminal itself and not passed to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Per @NathanWilson's response, this would work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;D-]&amp;gt; &amp;lt;C-t&amp;gt;&#xA;inoremap &amp;lt;D-[&amp;gt; &amp;lt;C-d&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6533" LastEditorUserId="6533" LastEditDate="2017-09-19T20:56:37.910" LastActivityDate="2017-09-19T20:56:37.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13628" PostTypeId="2" ParentId="13626" CreationDate="2017-09-19T17:56:25.503" Score="1" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/users/12003/lei&quot;&gt;LEI&lt;/a&gt; commented, the problem resided on my terminal, and it didn't have anything to do with vim. Changing the corresponding parameters of my terminal fixed the issue.&lt;/p&gt;&#xA;" OwnerUserId="14356" LastActivityDate="2017-09-19T17:56:25.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13629" PostTypeId="2" ParentId="13621" CreationDate="2017-09-19T19:47:25.913" Score="4" Body="&lt;p&gt;In insert mode you can indent the current line with &lt;kbd&gt;Ctrl-T&lt;/kbd&gt; and dedent with &lt;kbd&gt;Ctrl-D&lt;/kbd&gt;. Refer to &lt;code&gt;:help i_ctrl-t&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2674" LastActivityDate="2017-09-19T19:47:25.913" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13630" PostTypeId="1" CreationDate="2017-09-19T19:59:27.553" Score="4" ViewCount="716" Body="&lt;p&gt;I have a lot of difficulty doing things like the following in Vim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 'apple'&#xA;2 'orange'&#xA;3 'pear'&#xA;4 $fruit1 = &#xA;5 $fruit2 =&#xA;6 $fruit3 =&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;2&#xA;3&#xA;4 $fruit1 = 'apple';&#xA;5 $fruit2 = 'orange';&#xA;6 $fruit3 = 'pear';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The best approach I can come up with is to record what I hope is a sound macro to make the first edit, then replay it multiple times to get the other lines. Even if I nail that macro the first time, it's complicated enough to require more thought than would Sublime's multiple cursors, and it's certainly more time consuming. In these cases I'm certainly not &lt;a href=&quot;https://pragprog.com/book/dnvim2/practical-vim-second-edition&quot; rel=&quot;nofollow noreferrer&quot;&gt;editing text at the speed of thought&lt;/a&gt;.  How do you deal with this problem quickly and efficiently in Vim?&lt;/p&gt;&#xA;" OwnerUserId="10490" LastActivityDate="2022-10-20T10:15:14.373" Title="How to get around this common multiple-cursors use case?" Tags="|substitute|cursor-motions|macro|" AnswerCount="4" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13631" PostTypeId="1" AcceptedAnswerId="13633" CreationDate="2017-09-19T20:35:57.130" Score="0" ViewCount="197" Body="&lt;p&gt;If I had something like a list of &lt;code&gt;#define&lt;/code&gt;s in a c file, say&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define a&#xA;#define cd&#xA;#define blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I wanted to replace all the &lt;code&gt;#define&lt;/code&gt;s to capitalized characters, can I do this in a single substitution command? Maybe with regex?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking something along the lines of &lt;code&gt;:%s/a/A&lt;/code&gt;, but more of a general command so that I can apply it just once and it gets used on all of the &lt;code&gt;#define&lt;/code&gt;s.&lt;/p&gt;&#xA;" OwnerUserId="14359" LastEditorUserId="2736" LastEditDate="2017-09-20T01:16:16.753" LastActivityDate="2017-09-20T01:16:16.753" Title="Search and replace all next word" Tags="|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13632" PostTypeId="2" ParentId="13630" CreationDate="2017-09-19T20:56:30.057" Score="3" Body="&lt;p&gt;One way to do it (probably not the best):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^Vjj$d)$^VjjA ^[lpgvA;^[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(With &lt;code&gt;^V&lt;/code&gt; as &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; and &lt;code&gt;^[&lt;/code&gt; as &lt;kbd&gt;Escape&lt;/kbd&gt;)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Assuming the cursor is on the top left corner:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Select &amp;amp; delete the first 3 lines&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^V&lt;/code&gt; =&gt; enter in block selection mode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;jj$&lt;/code&gt; =&gt; select the 2 lines below to the end&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;d&lt;/code&gt; =&gt; delete those lines (they get stored in the default register)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Add a space after all &lt;code&gt;=&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;)$&lt;/code&gt; =&gt; move to the next &quot;paragraph&quot; (here, the line 4) then to the end of the line (on the &lt;code&gt;=&lt;/code&gt; sign)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^Vjj&lt;/code&gt; =&gt; select in block mode (the 3 &lt;code&gt;=&lt;/code&gt; signs)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;A ^[&lt;/code&gt; =&gt; append a space to them&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;l&lt;/code&gt; =&gt; move the cursor on the space after the &lt;code&gt;=&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Paste the lines &amp;amp; add the &lt;code&gt;;&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;p&lt;/code&gt; =&gt; paste the 3 lines (copied at the beginning)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^Vjj$&lt;/code&gt; =&gt; reselect what we just pasted (maybe a bad way to do it)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;A;^[&lt;/code&gt; =&gt; append &lt;code&gt;;&lt;/code&gt; at the end of the 3 lines&lt;/p&gt;&#xA;" OwnerUserId="5761" LastEditorUserId="5761" LastEditDate="2017-09-20T08:39:20.233" LastActivityDate="2017-09-20T08:39:20.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13633" PostTypeId="2" ParentId="13631" CreationDate="2017-09-19T21:11:55.843" Score="1" Body="&lt;p&gt;You can use the &lt;code&gt;\U&lt;/code&gt; flag in substitutions to substitute the uppercase version. This will work for the first word on every line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(\w\+\)/\U\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses memory parentheses &lt;code&gt;\( \)&lt;/code&gt; to capture the first word and then &lt;code&gt;\1&lt;/code&gt; in the substitution to &quot;remember&quot; what we've captured.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to get words that aren't at the beginning you might just have to use the word itself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(define\)/\U\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#s%2F%5CU&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help s/\U&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2017-09-19T21:11:55.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13634" PostTypeId="2" ParentId="13631" CreationDate="2017-09-19T21:21:01.273" Score="1" Body="&lt;p&gt;Your question is very close to this one: &lt;a href=&quot;https://vi.stackexchange.com/q/13464/626&quot;&gt;How to execute command on every matching pattern, not just lines?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference is that you don't want to remove the next word, but to change it to uppercase.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mixed with @Tumbler41's solution that changes &lt;code&gt;define&lt;/code&gt; into &lt;code&gt;DEFINE&lt;/code&gt;, it becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/pattern\zs\s\+\S\+/\U&amp;amp;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This time &lt;code&gt;define foo&lt;/code&gt; becomes &lt;code&gt;define FOO&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that thanks to &lt;code&gt;\zs&lt;/code&gt; we don't need a capture group here. We can use &lt;code&gt;&amp;amp;&lt;/code&gt; which is similar to &lt;code&gt;\0&lt;/code&gt;: it contains the complete text matched -- except the context that is matched with a zero-width (&lt;code&gt;\zs&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course all other solutions will work: you can use &lt;code&gt;gUw&lt;/code&gt; instead of &lt;code&gt;dw&lt;/code&gt;, but I'm a &lt;code&gt;:%s&lt;/code&gt; guy, hence my answer :)&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-09-19T21:21:01.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13636" PostTypeId="1" CreationDate="2017-09-20T04:11:50.883" Score="0" ViewCount="697" Body="&lt;p&gt;a weird question that i can't seem to solve&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i want to do a search and replace,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;anything that says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%d, %3d, %13d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or anything like that i want to replace it with XXX&#xA;I'm not sure how to deal with any arbitrary number of numbers in between % and d.. is there anyway i can do this? for even something absurd like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%000010d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried to go about something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/%...\dd\|%..\dd\|%.\dd\|%\dd\|%d/XXX/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to try and solve it each case at a time but I figured there's a better way to do a search and replace.. Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="14359" LastActivityDate="2017-09-20T20:15:21.067" Title="arbitrary length regex?" Tags="|regular-expression|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13637" PostTypeId="2" ParentId="11644" CreationDate="2017-09-20T07:32:20.383" Score="19" Body="&lt;p&gt;The following enables fuzzy file search (i.e &lt;code&gt;:find script.js&lt;/code&gt;) through every file in your project root while excluding the &lt;code&gt;node_modules&lt;/code&gt; dir and its contents. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path+=**                                                                    &#xA;set wildignore+=**/node_modules/** &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tested on:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 11 2017 13:57:34)&#xA;MacOS X (unix) version&lt;/em&gt;&#xA;(Compiled by Homebrew)&lt;/p&gt;&#xA;" OwnerUserId="14238" LastEditorUserId="14238" LastEditDate="2018-06-01T14:53:40.097" LastActivityDate="2018-06-01T14:53:40.097" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="13638" PostTypeId="1" AcceptedAnswerId="13645" CreationDate="2017-09-20T07:55:26.200" Score="3" ViewCount="263" Body="&lt;p&gt;&lt;code&gt;:Rename&lt;/code&gt; (from &lt;a href=&quot;https://vim.sourceforge.io/scripts/script.php?script_id=1928&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-rename&lt;/a&gt;) fails with Python files in my current set up with the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line   46:&#xA;E486: Pattern not found: \s\+$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if the file does not contain trailing whitespaces in at least one line, leading to the file being duplicated (with the new name and the old one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the following file &lt;code&gt;helloworld.py&lt;/code&gt; (note there are no trailing whitespaces):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print(&quot;Hello, world!&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I attempt to use &lt;code&gt;:Rename new_name.py&lt;/code&gt; it will spew out the previously-mentioned error, and I'll end up with two files (&lt;code&gt;helloworld.py&lt;/code&gt; and &lt;code&gt;new_name.py&lt;/code&gt;). If, however, I add whitespaces at the end of the line, the renaming will succeed and the trailing whitespaces are automatically removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to be due to some sort of conflict between &lt;code&gt;vim-rename&lt;/code&gt; and &lt;a href=&quot;https://github.com/python-mode/python-mode/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;python-mode&lt;/code&gt;&lt;/a&gt;, since it only happens with Python files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After debugging what happens on a write with &lt;code&gt;:debug write&lt;/code&gt;, I can see that &lt;code&gt;pymode#trim_whitespaces()&lt;/code&gt; is invoked by default by &lt;code&gt;python-mode&lt;/code&gt;. If I disable it by &lt;code&gt;let g:pymode_trim_whitespaces=0&lt;/code&gt;, the problem with &lt;code&gt;vim-rename&lt;/code&gt; goes away. However, automatic trimming of trailing whitespaces is a feature I don't want to lose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions, in order of importance:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;How can I fix this so that I can rename files and keep the automatic trimming of whitespaces?&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Why is the non-existence of whitespaces causing rename to fail?&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I would prefer to keep &lt;code&gt;vim-rename&lt;/code&gt;, although I'm willing to switch it for a more robust plugin if necessary. Fixing the code in &lt;code&gt;vim-rename&lt;/code&gt; manually would also be acceptable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is of any use, &lt;a href=&quot;https://pastebin.com/55uxuT0P&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; is my complete &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;" OwnerUserId="12266" LastEditorUserId="12266" LastEditDate="2017-09-20T10:36:19.397" LastActivityDate="2017-09-20T13:41:57.510" Title="Why does Rename fails with Python files if there is no trailing space?" Tags="|vimrc|plugin-python-mode|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13639" PostTypeId="2" ParentId="13630" CreationDate="2017-09-20T08:43:13.500" Score="3" Body="&lt;p&gt;I would record a macro (as you said) that is pretty easy one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqdd2jpkJA;&amp;lt;ESC&amp;gt;2-q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this does is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; record macro into register &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dd&lt;/code&gt; delete line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2j&lt;/code&gt; move 2 lines down (to our respective variable)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; paste deleted text (it will be pasted as a line below)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;k&lt;/code&gt; move back up a line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;J&lt;/code&gt; join lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A;&amp;lt;ESC&amp;gt;&lt;/code&gt; add semicolon&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2-&lt;/code&gt; move 2 lines up (to start of line) &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; stop recording&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The benefit is that this will also work for unaligned lines. &lt;/p&gt;&#xA;" OwnerUserId="1259" LastEditorUserId="343" LastEditDate="2017-09-20T09:09:23.073" LastActivityDate="2017-09-20T09:09:23.073" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13641" PostTypeId="1" CreationDate="2017-09-20T09:03:45.697" Score="3" ViewCount="1559" Body="&lt;p&gt;When searching for &lt;code&gt;/a_string&lt;/code&gt; and getting several matches, I can cycle through them with &lt;code&gt;n&lt;/code&gt;, but I'd like the editor window centered on each matching line so I don't have to move my eyes around all the time saccading for the match.&#xA;The same would be useful during search-replace with confirmation, where I want to cycle through each match and confirm or avoid replacement.&#xA;Is there any such option besides remapping &lt;code&gt;n&lt;/code&gt; to &lt;code&gt;nzz&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastEditorUserId="1066" LastEditDate="2017-09-21T12:02:06.850" LastActivityDate="2017-09-23T07:51:32.307" Title="How can I center the window on each search result" Tags="|search|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13643" PostTypeId="2" ParentId="13630" CreationDate="2017-09-20T09:31:48.083" Score="1" Body="&lt;p&gt;The tricky thing about macros is getting your head around what movements and text objects you can use that will work in the general case, so the macro doesn't break when you run it in another location. Generally, you want to avoid character-based movements and prefer searches and word-based movements.&lt;/p&gt;&#xA;&lt;p&gt;Once you've internalised this, though, you should find that you can record most macros pretty much as fast as you could make a single edit, and will rarely make mistakes. Remember that &lt;strike&gt;undoes&lt;/strike&gt;backspaces and delete commands are recorded too, so many errors can be fixed while you are still recording the macro! &lt;em&gt;(&lt;strong&gt;Edit&lt;/strong&gt;: I'm not sure if it was ever true that you could use undo while recording a macro, but it's certainly not true in current versions: when played back, the &lt;code&gt;u&lt;/code&gt; will undo all the changes since the start of the recording.)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, in this example the edits you need to make are so well aligned that pretty much any movements you choose will work e.g.:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;qqlD3j$pa;&amp;lt;esc&amp;gt;2-q2@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; Start recording,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;lD&lt;/code&gt; Move one character to the left and delete to the end of the line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;3j&lt;/code&gt; Move down three lines,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$p&lt;/code&gt; Jump to end of the line and paste the deleted text,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a;&amp;lt;esc&amp;gt;&lt;/code&gt; Add the semicolon,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2-&lt;/code&gt; Move back up to the next line we want to work on,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q2@q&lt;/code&gt; Save the macro and replay it twice.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;(N.B. I was under the impression when writing this answer that the numbers were actually part of the text you wanted editing. Reading the other answers it occurs to me that they may be intended as line-numbers. If so, a slight adjustment is required: &lt;code&gt;qqD3jA&amp;lt;space&amp;gt;;&amp;lt;esc&amp;gt;P2-q2@q&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;If, after practice, you find that you still have trouble with macros, you could of course try installing a &lt;a href=&quot;https://github.com/terryma/vim-multiple-cursors&quot; rel=&quot;nofollow noreferrer&quot;&gt;multiple cursors plugin&lt;/a&gt;. I would note, however, that although the visual feedback such a plugin provides might help you catch errors sooner, the actual editing commands you need to use will be the same as required for a macro, so if you find that you can perform edits using the plugin without making mistakes and having to undo, that suggests you could also do so using a macro.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2022-10-20T10:15:14.373" LastActivityDate="2022-10-20T10:15:14.373" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="13644" PostTypeId="2" ParentId="13623" CreationDate="2017-09-20T09:42:36.373" Score="17" Body="&lt;p&gt;The symlink you've created at &lt;code&gt;~/.vim/ftplugin/Rhtml.vim&lt;/code&gt; tells Vim how to handle files with the &lt;code&gt;RHTML&lt;/code&gt; filetype, but you haven't told Vim how to &lt;em&gt;recognise&lt;/em&gt; which files should have this filetype.&lt;/p&gt;&#xA;&lt;p&gt;Instructions for how to do so can be found in the documentation by running the command &lt;a href=&quot;https://vimhelp.org/filetype.txt.html#new-filetype&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help new-filetype&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can use either the technique described in section A or the one from section C for your purposes. (The former is arguably simpler, but has a couple of disadvantages compared to the latter, which are described in the docs.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2021-04-23T10:41:52.003" LastActivityDate="2021-04-23T10:41:52.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13645" PostTypeId="2" ParentId="13638" CreationDate="2017-09-20T10:18:43.230" Score="4" Body="&lt;p&gt;I'm not clear on why the problem occurs&amp;thinsp;&amp;mdash;&amp;thinsp;the &lt;a href=&quot;https://github.com/python-mode/python-mode/blob/d2dead6ce9d900b26dbf1a06c52969f4194eda64/autoload/pymode.vim#L74&quot; rel=&quot;nofollow noreferrer&quot;&gt;line in &lt;code&gt;pymode#trim_whitespaces()&lt;/code&gt; that is triggering the error&lt;/a&gt; includes a &lt;code&gt;silent!&lt;/code&gt; so the error should be ignored. You could maybe try appending an &lt;code&gt;e&lt;/code&gt; flag to ignore the errors more specifically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! %s/\s\+$//e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If that works, you should probably report it to the author of python-mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'm not too motivated to dig any deeper into what's going wrong, because there's a very simple workaround, which is to write a new command which turns off &quot;trim whitespaces&quot; before running the rename and then restores it afterwards.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyRename(new_name, bang)&#xA;  if exists(&quot;g:pymode_trim_whitespaces&quot;)&#xA;    let orig_trim_whitespaces = g:pymode_trim_whitespaces&#xA;  endif&#xA;  let g:pymode_trim_whitespaces = 0&#xA;&#xA;  execute &quot;Rename&quot; . a:bang . &quot; &quot; . a:new_name&#xA;&#xA;  if exists(&quot;orig_trim_whitespaces&quot;)&#xA;    let g:pymode_trim_whitespaces = orig_trim_whitespaces&#xA;  else&#xA;    unlet g:pymode_trim_whitespaces&#xA;  endif&#xA;endfunction&#xA;&#xA;command! -nargs=* -complete=file -bang MyRename call MyRename(&amp;lt;q-args&amp;gt;, '&amp;lt;bang&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You've also indicated that you're happy to edit the code of &lt;code&gt;vim-rename&lt;/code&gt;, so an even quicker (but even more hacky) fix would be simply to add the lines that set and reset &lt;code&gt;g:pymode_trim_whitespaces&lt;/code&gt; at appropriate places in the Rename() function itself. (i.e. just before and after the line that performs the rename (&lt;code&gt;silent! exe 'saveas' . a:bang . ' ' . l:name&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-09-20T13:41:57.510" LastActivityDate="2017-09-20T13:41:57.510" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13646" PostTypeId="2" ParentId="13641" CreationDate="2017-09-20T10:20:35.500" Score="3" Body="&lt;p&gt;I don't believe there is a builtin setting to do what you want &lt;em&gt;only&lt;/em&gt; for search. If you &lt;code&gt;:set scrolloff=999&lt;/code&gt; (or other arbitrarily high number) you will get the effect you are looking for but it doesn't turn off. In other words, the cursor line will be midway between the top and bottom of the window  whether you're searching, editing, moving around in Normal mode, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help scrolloff&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Minimal number of screen lines to keep above and below the cursor.&#xA;  This will make some context visible around where you are working.  If&#xA;  you set it to a very large value (999) the cursor line will always be&#xA;  in the middle of the window (except at the start or end of the file or&#xA;  when long lines wrap).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Try it out. Some people keep this on all the time. Maybe you'll like it, too. We might also be able to figure out a mapping/script that enables it just while searching, too, but if you don't want to mess around with a mapping with &lt;code&gt;zz&lt;/code&gt; I imagine you don't want to mess around with a mapping for this either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; &lt;em&gt;This is totally superfluous given that &lt;code&gt;zz&lt;/code&gt; should work fine but since I scripted it for kicks and someone might find something useful I give you...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put something like this function and mapping in your &lt;em&gt;vimrc&lt;/em&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CenteredFindNext(forward)&#xA;    &quot; save the current value for later restore&#xA;    let s:so_curr=&amp;amp;scrolloff&#xA;    set scrolloff=999&#xA;    try&#xA;        if a:forward&#xA;            silent normal! n&#xA;        else&#xA;            silent normal! N&#xA;        endif&#xA;    finally&#xA;        &quot; restore no matter what&#xA;        let &amp;amp;scrolloff=s:so_curr&#xA;    endtry&#xA;endfunction&#xA;&#xA;:nnoremap &amp;lt;silent&amp;gt;n :call CenteredFindNext(1)&amp;lt;CR&amp;gt;&#xA;:nnoremap &amp;lt;silent&amp;gt;N :call CenteredFindNext(0)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-09-23T07:51:32.307" LastActivityDate="2017-09-23T07:51:32.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13647" PostTypeId="2" ParentId="13607" CreationDate="2017-09-20T12:08:52.370" Score="0" Body="&lt;p&gt;Looking at the documentation and code I don't see any straightforward way to do customization like that. There are some basic modifications that can be done &lt;a href=&quot;https://powerline.readthedocs.io/en/latest/configuration/segments/vim.html#powerline.segments.vim.file_directory&quot; rel=&quot;nofollow noreferrer&quot;&gt;to the directory portion of the path&lt;/a&gt; and &lt;a href=&quot;https://powerline.readthedocs.io/en/latest/configuration/segments/vim.html#powerline.segments.vim.file_name&quot; rel=&quot;nofollow noreferrer&quot;&gt;the file&#xA;part&lt;/a&gt; but we're talking about basic things like converting &lt;code&gt;/home/foo.bar/&lt;/code&gt; to &lt;code&gt;~foo.bar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But are you sure you're actually using Powerline for your&#xA;tabline? Because it is configured with the &lt;code&gt;'tabline'&lt;/code&gt; setting and you&#xA;said yours was not set to anything. As you can see &lt;a href=&quot;https://powerline.readthedocs.io/en/latest/_modules/powerline/vim.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;near the end of this&#xA;code&lt;/a&gt; Powerline writes to that setting &lt;em&gt;if tabline is configured.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either way there are no easy solutions.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If you are using Powerline for your tabline then you could modify the code I linked to above (e.g. by looking for the Nerd Tree filename and doing some substitution).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you are &lt;em&gt;not&lt;/em&gt; using Powerline for your tabline then you can modify &lt;code&gt;'tabline'&lt;/code&gt; per &lt;code&gt;:help  setting-tabline&lt;/code&gt; but some of the text in that helpfile might dissuade you:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The 'tabline' option allows you to define your preferred way to tab pages labels.  &lt;strong&gt;This isn't easy&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Even with the example they provide you're facing a challenge as it does not show how to bring the back the complete set of features enabled by the default tabline settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TBH, your best bet, if you really want to change this, is to switch to &lt;code&gt;vim-airline&lt;/code&gt;. You can fully modify paths via the &lt;code&gt;:airline#extensions#tabline#fnamemod&lt;/code&gt; variable. I've used both and I prefer airline. It's much more lightweight (pure Vim, no Python) but still has everything I want and looks great. Even Powerline's docs mention this as a good alternative:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You should check out some of the Powerline derivatives. The most lightweight and feature-rich alternative is currently Bailey Ling’s vim-airline project.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-09-25T08:14:19.263" LastActivityDate="2017-09-25T08:14:19.263" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13648" PostTypeId="1" AcceptedAnswerId="13649" CreationDate="2017-09-20T15:47:37.357" Score="3" ViewCount="2639" Body="&lt;p&gt;I currently open my text files with GVim by double-clicking them in my file manager (Thunar, in Xubuntu 16.04). However, when opening a new file, I want GVim to open it as a new tab rather than a new window, pretty much as in other text editors like Sublime Text or Notepad. I have seen posts here or online that relate to open files as tab &lt;strong&gt;when opening files via command line&lt;/strong&gt; (or inside vim). I want to open the files externally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot figure how to do this. Below are the list of settings that GVim offers me related windows and tabs, but I cannot see which one is relevant here.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;6 multiple windows&#xA;&#xA;laststatus  0, 1 or 2; when to use a status line for the last window&#xA;    set ls=1&#xA;statusline  alternate format to be used for a status line&#xA;    set stl=&#xA;equalalways make all windows the same size when adding/removing windows&#xA;    set ea  noea&#xA;eadirection in which direction 'equalalways' works: &quot;ver&quot;, &quot;hor&quot; or &quot;both&quot;&#xA;    set ead=both&#xA;winheight   minimal number of lines used for the current window&#xA;    set wh=1&#xA;winminheight    minimal number of lines used for any window&#xA;    set wmh=1&#xA;winfixheight    keep the height of the window&#xA;    (local to window)&#xA;    set nowfh   wfh&#xA;winfixwidth keep the width of the window&#xA;    (local to window)&#xA;    set nowfw   wfw&#xA;winwidth    minimal number of columns used for the current window&#xA;    set wiw=20&#xA;winminwidth minimal number of columns used for any window&#xA;    set wmw=1&#xA;helpheight  initial height of the help window&#xA;    set hh=20&#xA;previewheight   default height for the preview window&#xA;    set pvh=12&#xA;previewwindow   identifies the preview window&#xA;    (local to window)&#xA;    set nopvw   pvw&#xA;hidden  don't unload a buffer when no longer shown in a window&#xA;    set nohid   hid&#xA;switchbuf   &quot;useopen&quot; and/or &quot;split&quot;; which window to use when jumping&#xA;    to a buffer&#xA;    set swb=&#xA;splitbelow  a new window is put below the current one&#xA;    set nosb    sb&#xA;splitright  a new window is put right of the current one&#xA;    set nospr   spr&#xA;scrollbind  this window scrolls together with other bound windows&#xA;    (local to window)&#xA;    set noscb   scb&#xA;scrollopt   &quot;ver&quot;, &quot;hor&quot; and/or &quot;jump&quot;; list of options for 'scrollbind'&#xA;    set sbo=ver,jump&#xA;cursorbind  this window's cursor moves together with other bound windows&#xA;    (local to window)&#xA;    set nocrb   crb&#xA;&#xA; 7 multiple tab pages&#xA;&#xA;showtabline 0, 1 or 2; when to use a tab pages line&#xA;    set stal=1&#xA;tabpagemax  maximum number of tab pages to open for -p and &quot;tab all&quot;&#xA;    set tpm=10&#xA;tabline custom tab pages line&#xA;    set tal=&#xA;guitablabel custom tab page label for the GUI&#xA;    set gtl=&#xA;guitabtooltip   custom tab page tooltip for the GUI&#xA;    set gtt=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea how to do this? I don't want to have 5 Vim instances open when dealing with many editing simultaneously.&lt;/p&gt;&#xA;" OwnerUserId="14368" LastEditorUserId="14368" LastEditDate="2017-09-20T15:53:25.857" LastActivityDate="2017-09-21T13:40:08.583" Title="Open new file as tab on current vim instance through double-click" Tags="|gvim|tabbed-user-interface|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13649" PostTypeId="2" ParentId="13648" CreationDate="2017-09-20T18:09:04.767" Score="3" Body="&lt;p&gt;You could try the command &lt;code&gt;gvim --remote-tab-silent %F&lt;/code&gt;. &lt;code&gt;Thunar&lt;/code&gt; should substitute &lt;code&gt;%F&lt;/code&gt; with the paths of all selected files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;--remote-tab-silent&lt;/code&gt; is a variant of &lt;code&gt;--remote&lt;/code&gt;. For more info about it, see &lt;code&gt;:h --remote&lt;/code&gt;, &lt;code&gt;:h --remote-silent&lt;/code&gt; and &lt;code&gt;:h --remote-tab-silent&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are various ways to tell &lt;code&gt;Thunar&lt;/code&gt; to use this command when you double-click on a file.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In the settings menu of Xubuntu, there's a section called &lt;code&gt;System&lt;/code&gt;. Inside this section, there's an entry called &lt;code&gt;MIME Type Editor&lt;/code&gt;. If you click on it, you will be presented with a window where you can choose the default applications that the OS should use to open various types of files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can restrict the MIME Types to the ones prefixed with &lt;code&gt;text/&lt;/code&gt;, since they are the most relevant for &lt;code&gt;gVim&lt;/code&gt;. Then, you can look for a type of file you want to open with your custom command &lt;code&gt;gvim --remote-tab-silent %F&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, suppose you are only interested in log files, you could improve the filtering by writing in the &lt;code&gt;filter&lt;/code&gt; field &lt;code&gt;text/x-log&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Click on the default application. It should be gVim, mousepad or some other editor. Then, click on &lt;code&gt;Choose Application...&lt;/code&gt;, and on &lt;code&gt;Use a custom command:&lt;/code&gt;. In the new field, you could type your &lt;code&gt;gvim --remote-tab-silent %F&lt;/code&gt; command. Finally, validate with &lt;code&gt;Open&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could achieve the same result by:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;doing a right-click on a text file&lt;/li&gt;&#xA;&lt;li&gt;clicking on &lt;code&gt;Properties&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;opening the &lt;code&gt;Open With&lt;/code&gt; menu&lt;/li&gt;&#xA;&lt;li&gt;clicking on the &lt;code&gt;Use a custom command:&lt;/code&gt; entry&lt;/li&gt;&#xA;&lt;li&gt;entering &lt;code&gt;gvim --remote-tab-silent %F&lt;/code&gt; in the field which has just been opened&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In Thunar's toolbar, you could also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;click on &lt;code&gt;Edit&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;click on &lt;code&gt;Configure custom actions...&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;click on the &lt;code&gt;+&lt;/code&gt; button (whose tooltip reads &lt;code&gt;Add a new custom action.&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;in the &lt;code&gt;Name:&lt;/code&gt; field, give a name to the new entry you want to add in Thunar's contextual menu; example &lt;code&gt;my_gvim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;in the &lt;code&gt;Command:&lt;/code&gt; field, insert the command &lt;code&gt;gvim --remote-tab-silent %F&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;validate with &lt;code&gt;OK&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After this, when you right-click on a file, or a set of selected files, the contextual menu should contain the entry &lt;code&gt;my_gvim&lt;/code&gt;. If you click on it, it should open the selected files in gVim, one tabpage per file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't see the &lt;code&gt;my_gvim&lt;/code&gt; entry, go back to the menu where you created the entry, click on the edit button (right below the &lt;code&gt;+&lt;/code&gt;), select the 2nd tab (its title is &lt;code&gt;Appearance Conditions&lt;/code&gt;), and make sure that the box &lt;code&gt;Text Files&lt;/code&gt; is ticked (and that the filename pattern is not too restrictive).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to edit multiple MIME types, you can try the following method, but I'm not sure it will work for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside &lt;code&gt;~/.local/share/applications/&lt;/code&gt;, create a file named &lt;code&gt;my_gvim.desktop&lt;/code&gt; (or however else you want). In this file, import the contents of another &lt;code&gt;.desktop&lt;/code&gt; file, and edit it so that it contains your custom command. As an example, I wrote this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Desktop Entry]&#xA;Version=1.0&#xA;Type=Application&#xA;Name=MyGvim&#xA;Icon=&#xA;Exec=gvim --remote-tab-silent %F&#xA;NoDisplay=&#xA;Categories=&#xA;StartupNotify=false&#xA;Terminal=false&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The important line is the one prefixed by &lt;code&gt;Exec=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, you need to find a &lt;code&gt;mimeapps.list&lt;/code&gt; file in your home directory. I used &lt;code&gt;~/.config/mimeapps.list&lt;/code&gt; (you may also try &lt;code&gt;~/.local/share/applications/mimeapps.list&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this file, write your MIME types, using the desktop file you created earlier. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text/markdown=my_gvim.desktop;&#xA;text/x-log=my_gvim.desktop;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add one line per MIME type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to find all the MIME types relative to text files, you could have a look at the list of &lt;code&gt;.xml&lt;/code&gt; files inside &lt;code&gt;/usr/share/mime/text/&lt;/code&gt;. On my system, I found this list of MIME types:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text/cache-manifest&#xA;text/calendar&#xA;text/css&#xA;text/csv-schema&#xA;text/csv&#xA;text/enriched&#xA;text/html&#xA;text/htmlh&#xA;text/markdown&#xA;text/plain&#xA;text/rfc822-headers&#xA;text/richtext&#xA;text/rust&#xA;text/sgml&#xA;text/spreadsheet&#xA;text/tab-separated-values&#xA;text/troff&#xA;text/turtle&#xA;text/vcard&#xA;text/vnd.graphviz&#xA;text/vnd.rn-realtext&#xA;text/vnd.sun.j2me.app-descriptor&#xA;text/vnd.trolltech.linguist&#xA;text/vnd.wap.wml&#xA;text/vnd.wap.wmlscript&#xA;text/vtt&#xA;text/x-adasrc&#xA;text/x-apt-sources-list&#xA;text/x-authors&#xA;text/x-bibtex&#xA;text/x-c++hdr&#xA;text/x-c++src&#xA;text/x-changelog&#xA;text/x-chdr&#xA;text/x-cmake&#xA;text/x-cobol&#xA;text/x-copying&#xA;text/x-credits&#xA;text/x-csharp&#xA;text/x-csrc&#xA;text/x-dcl&#xA;text/x-dsl&#xA;text/x-dsrc&#xA;text/x-eiffel&#xA;text/x-emacs-lisp&#xA;text/x-erlang&#xA;text/x-fortran&#xA;text/x-genie&#xA;text/x-gettext-translation-template&#xA;text/x-gettext-translation&#xA;text/x-go&#xA;text/x-google-video-pointer&#xA;text/x-haskell&#xA;text/x-idl&#xA;text/x-imelody&#xA;text/x-install&#xA;text/x-iptables&#xA;text/x-java&#xA;text/x-ldif&#xA;text/x-lilypond&#xA;text/x-literate-haskell&#xA;text/x-log&#xA;text/x-lua&#xA;text/x-makefile&#xA;text/x-matlab&#xA;text/x-meson&#xA;text/x-microdvd&#xA;text/x-moc&#xA;text/x-modelica&#xA;text/x-mof&#xA;text/x-mpsub&#xA;text/x-mrml&#xA;text/x-ms-regedit&#xA;text/x-mup&#xA;text/x-nfo&#xA;text/x-objcsrc&#xA;text/x-ocaml&#xA;text/x-ocl&#xA;text/x-ooc&#xA;text/x-opml+xml&#xA;text/x-pascal&#xA;text/x-patch&#xA;text/x-python&#xA;text/x-qml&#xA;text/x-readme&#xA;text/x-reject&#xA;text/x-rpm-spec&#xA;text/x-scala&#xA;text/x-scheme&#xA;text/x-scons&#xA;text/x-setext&#xA;text/x-ssa&#xA;text/x-subviewer&#xA;text/x-svhdr&#xA;text/x-svsrc&#xA;text/x-tcl&#xA;text/x-tex&#xA;text/x-texinfo&#xA;text/x-troff-me&#xA;text/x-troff-mm&#xA;text/x-troff-ms&#xA;text/x-txt2tags&#xA;text/x-uil&#xA;text/x-uri&#xA;text/x-uuencode&#xA;text/x-vala&#xA;text/x-verilog&#xA;text/x-vhdl&#xA;text/x-xmi&#xA;text/x-xslfo&#xA;text/x-zim-wiki&#xA;text/xmcd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you used this list, after editing it, you should get something looking like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text/cache-manifest=my_gvim.desktop;&#xA;text/calendar=my_gvim.desktop;&#xA;text/css=my_gvim.desktop;&#xA;text/csv-schema=my_gvim.desktop;&#xA;text/csv=my_gvim.desktop;&#xA;text/enriched=my_gvim.desktop;&#xA;text/html=my_gvim.desktop;&#xA;text/htmlh=my_gvim.desktop;&#xA;text/markdown=my_gvim.desktop;&#xA;text/plain=my_gvim.desktop;&#xA;text/rfc822-headers=my_gvim.desktop;&#xA;text/richtext=my_gvim.desktop;&#xA;text/rust=my_gvim.desktop;&#xA;text/sgml=my_gvim.desktop;&#xA;text/spreadsheet=my_gvim.desktop;&#xA;text/tab-separated-values=my_gvim.desktop;&#xA;text/troff=my_gvim.desktop;&#xA;text/turtle=my_gvim.desktop;&#xA;text/vcard=my_gvim.desktop;&#xA;text/vnd.graphviz=my_gvim.desktop;&#xA;text/vnd.rn-realtext=my_gvim.desktop;&#xA;text/vnd.sun.j2me.app-descriptor=my_gvim.desktop;&#xA;text/vnd.trolltech.linguist=my_gvim.desktop;&#xA;text/vnd.wap.wml=my_gvim.desktop;&#xA;text/vnd.wap.wmlscript=my_gvim.desktop;&#xA;text/vtt=my_gvim.desktop;&#xA;text/x-adasrc=my_gvim.desktop;&#xA;text/x-apt-sources-list=my_gvim.desktop;&#xA;text/x-authors=my_gvim.desktop;&#xA;text/x-bibtex=my_gvim.desktop;&#xA;text/x-c++hdr=my_gvim.desktop;&#xA;text/x-c++src=my_gvim.desktop;&#xA;text/x-changelog=my_gvim.desktop;&#xA;text/x-chdr=my_gvim.desktop;&#xA;text/x-cmake=my_gvim.desktop;&#xA;text/x-cobol=my_gvim.desktop;&#xA;text/x-copying=my_gvim.desktop;&#xA;text/x-credits=my_gvim.desktop;&#xA;text/x-csharp=my_gvim.desktop;&#xA;text/x-csrc=my_gvim.desktop;&#xA;text/x-dcl=my_gvim.desktop;&#xA;text/x-dsl=my_gvim.desktop;&#xA;text/x-dsrc=my_gvim.desktop;&#xA;text/x-eiffel=my_gvim.desktop;&#xA;text/x-emacs-lisp=my_gvim.desktop;&#xA;text/x-erlang=my_gvim.desktop;&#xA;text/x-fortran=my_gvim.desktop;&#xA;text/x-genie=my_gvim.desktop;&#xA;text/x-gettext-translation-template=my_gvim.desktop;&#xA;text/x-gettext-translation=my_gvim.desktop;&#xA;text/x-go=my_gvim.desktop;&#xA;text/x-google-video-pointer=my_gvim.desktop;&#xA;text/x-haskell=my_gvim.desktop;&#xA;text/x-idl=my_gvim.desktop;&#xA;text/x-imelody=my_gvim.desktop;&#xA;text/x-install=my_gvim.desktop;&#xA;text/x-iptables=my_gvim.desktop;&#xA;text/x-java=my_gvim.desktop;&#xA;text/x-ldif=my_gvim.desktop;&#xA;text/x-lilypond=my_gvim.desktop;&#xA;text/x-literate-haskell=my_gvim.desktop;&#xA;text/x-log=my_gvim.desktop;&#xA;text/x-lua=my_gvim.desktop;&#xA;text/x-makefile=my_gvim.desktop;&#xA;text/x-matlab=my_gvim.desktop;&#xA;text/x-meson=my_gvim.desktop;&#xA;text/x-microdvd=my_gvim.desktop;&#xA;text/x-moc=my_gvim.desktop;&#xA;text/x-modelica=my_gvim.desktop;&#xA;text/x-mof=my_gvim.desktop;&#xA;text/x-mpsub=my_gvim.desktop;&#xA;text/x-mrml=my_gvim.desktop;&#xA;text/x-ms-regedit=my_gvim.desktop;&#xA;text/x-mup=my_gvim.desktop;&#xA;text/x-nfo=my_gvim.desktop;&#xA;text/x-objcsrc=my_gvim.desktop;&#xA;text/x-ocaml=my_gvim.desktop;&#xA;text/x-ocl=my_gvim.desktop;&#xA;text/x-ooc=my_gvim.desktop;&#xA;text/x-opml+xml=my_gvim.desktop;&#xA;text/x-pascal=my_gvim.desktop;&#xA;text/x-patch=my_gvim.desktop;&#xA;text/x-python=my_gvim.desktop;&#xA;text/x-qml=my_gvim.desktop;&#xA;text/x-readme=my_gvim.desktop;&#xA;text/x-reject=my_gvim.desktop;&#xA;text/x-rpm-spec=my_gvim.desktop;&#xA;text/x-scala=my_gvim.desktop;&#xA;text/x-scheme=my_gvim.desktop;&#xA;text/x-scons=my_gvim.desktop;&#xA;text/x-setext=my_gvim.desktop;&#xA;text/x-ssa=my_gvim.desktop;&#xA;text/x-subviewer=my_gvim.desktop;&#xA;text/x-svhdr=my_gvim.desktop;&#xA;text/x-svsrc=my_gvim.desktop;&#xA;text/x-tcl=my_gvim.desktop;&#xA;text/x-tex=my_gvim.desktop;&#xA;text/x-texinfo=my_gvim.desktop;&#xA;text/x-troff-me=my_gvim.desktop;&#xA;text/x-troff-mm=my_gvim.desktop;&#xA;text/x-troff-ms=my_gvim.desktop;&#xA;text/x-txt2tags=my_gvim.desktop;&#xA;text/x-uil=my_gvim.desktop;&#xA;text/x-uri=my_gvim.desktop;&#xA;text/x-uuencode=my_gvim.desktop;&#xA;text/x-vala=my_gvim.desktop;&#xA;text/x-verilog=my_gvim.desktop;&#xA;text/x-vhdl=my_gvim.desktop;&#xA;text/x-xmi=my_gvim.desktop;&#xA;text/x-xslfo=my_gvim.desktop;&#xA;text/x-zim-wiki=my_gvim.desktop;&#xA;text/xmcd=my_gvim.desktop;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-09-21T13:40:08.583" LastActivityDate="2017-09-21T13:40:08.583" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13650" PostTypeId="1" AcceptedAnswerId="13659" CreationDate="2017-09-20T18:47:25.237" Score="0" ViewCount="275" Body="&lt;p&gt;Right now I'm trying to configure &lt;code&gt;ctags&lt;/code&gt; in my vim environment but I'm not sure what I'm missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I installed &lt;code&gt;ctags&lt;/code&gt; (using yaourt) and the I added &lt;a href=&quot;https://pastebin.com/fZUP0iX0&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; on &lt;code&gt;~/.ctags&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, I run &lt;code&gt;ctags -R .&lt;/code&gt; on the root of my project and it generated a file &quot;tags&quot; with 14000 lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I open vim and use the &lt;code&gt;:set tags=./tags&lt;/code&gt; making sure that I'm pointing to the right tags file, and when I try to jump to a definition using &lt;code&gt;Ctrl+Shift+}&lt;/code&gt; (in a &lt;a href=&quot;https://www.goodtyping.com/teclatLAT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;latin american keyboard&lt;/a&gt;, which stands for &lt;code&gt;Ctrl+]&lt;/code&gt;) it doesn't work. And when I try to see the &lt;code&gt;:tags&lt;/code&gt;, it shows that there are not any tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing? Why is this not working properly?&lt;/p&gt;&#xA;" OwnerUserId="8228" LastEditorUserId="6489" LastEditDate="2017-09-21T16:22:30.310" LastActivityDate="2017-09-21T16:25:55.003" Title="Ctags not working properly on Latin american keyboard" Tags="|ctags|keyboard-layout|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13651" PostTypeId="2" ParentId="13650" CreationDate="2017-09-20T19:21:23.617" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;set tags=./tags&lt;/code&gt; means &quot;path of the current file&quot; not necessarily the current directory.  The vim default &lt;code&gt;set tags=./tags,tags&lt;/code&gt; would look in both path of current file and current directory.  You can ensure the correct file is shown with &lt;code&gt;echo tagfiles()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The way to show all tags is &lt;code&gt;:tselect /&lt;/code&gt; (not &lt;code&gt;:tags&lt;/code&gt;, which shows the tag stack, only active when you have navigated with tags).  After scrolling down to the bottom of the list, you can type a number to jump to that tag.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-09-20T19:45:40.747" LastActivityDate="2017-09-20T19:45:40.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13652" PostTypeId="2" ParentId="13636" CreationDate="2017-09-20T20:15:21.067" Score="3" Body="&lt;p&gt;This will match any number of digits before the &lt;code&gt;d&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/%\d*d/XXX/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\d&lt;/code&gt; matches any digit, &lt;code&gt;*&lt;/code&gt; matches 0 or more times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h pattern.txt&lt;/code&gt; for all things regex.&lt;/p&gt;&#xA;" OwnerUserId="8233" LastActivityDate="2017-09-20T20:15:21.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13653" PostTypeId="2" ParentId="7914" CreationDate="2017-09-20T21:11:52.353" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/7915/343&quot;&gt;@KarlYngveLervåg's answer&lt;/a&gt; is probably simpler, but you can also achieve this using your original idea of negating the &lt;code&gt;^&lt;/code&gt; atom. To do so you can use &lt;strong&gt;negative look behind&lt;/strong&gt;. (See &lt;code&gt;:help /\@&amp;lt;!&lt;/code&gt;) which causes an atom to match only when it &lt;em&gt;doesn't&lt;/em&gt; follow another specified atom, in this case the &lt;code&gt;^&lt;/code&gt; start of line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The naive expression below where we simply add this in to your existing expression &lt;em&gt;doesn't&lt;/em&gt; work, however, because, if your line starts with multiple spaces, the &lt;em&gt;second&lt;/em&gt; space on the line, and all those that following it, do not immediately follow the start of the line, and thus match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/^\@&amp;lt;!\s\+/ g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So to fix this, we also need to include these start-of-line spaces as part of the thing we don't want our spaces to follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\(^\s*\)\@&amp;lt;!\s\+/ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As @KarlYngveLervåg also noted, we can make this cleaner by only matching when there actually are multiple spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\(^\s*\)\@&amp;lt;!\s\{2,}/ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a final touch, we can simplify this by using the very magic &lt;code&gt;\v&lt;/code&gt; atom (&lt;code&gt;:help /\v&lt;/code&gt;), so we don't have to do quite so much \escaping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    ┌──────────────── 1.     \v - Using &quot;very magic&quot;,&#xA;    │              ┌─ 2.  s{2,} - Match two or more spaces,&#xA;   ┌┤         ┌────┤&#xA;   ││         │    │&#xA;:s/\v(^\s*)@&amp;lt;!\s{2,}/ /g&#xA;     │    ││ │&#xA;     └────┤└─┤&#xA;          │  └─────── 3.    @&amp;lt;! - That do not follow,&#xA;          └────────── 4. (^\s*) - The start of the line followed by&#xA;                                  any number of spaces.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-09-27T14:53:11.917" LastActivityDate="2017-09-27T14:53:11.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13655" PostTypeId="2" ParentId="9212" CreationDate="2017-09-21T13:57:59.007" Score="7" Body="&lt;p&gt;One benefit of &lt;code&gt;:[vim]grep&lt;/code&gt; over &lt;code&gt;/?&lt;/code&gt; is that the results get put into the quickfix list (or location list if you use &lt;code&gt;:l[vim]grep&lt;/code&gt;), this means that you can pull up a list of all matches using &lt;code&gt;:cl&lt;/code&gt;. You can then use a number to go directly to the result you want from the list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also means that you can use the same command for searching the current buffer &lt;code&gt;:[vim]grep pattern %&lt;/code&gt; as for searching your entire code base &lt;code&gt;:[vim]grep pattern path&lt;/code&gt; so there's some nice symmetry to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further to this you can then branch out and use the &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;noreferrer&quot;&gt;Silver Surfer&lt;/a&gt; / &lt;a href=&quot;https://github.com/jremmen/vim-ripgrep&quot; rel=&quot;noreferrer&quot;&gt;Ripgrep&lt;/a&gt; to give you very powerful searching. These can be mapped to the &lt;code&gt;:[vim]grep&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="11986" LastEditorUserId="11986" LastEditDate="2018-10-15T13:35:22.657" LastActivityDate="2018-10-15T13:35:22.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13656" PostTypeId="1" AcceptedAnswerId="13661" CreationDate="2017-09-21T15:02:53.350" Score="2" ViewCount="943" Body="&lt;p&gt;I've been trying to set a custom statusline for help files. I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%!StatusLine()&#xA;function! StatusLine()&#xA;    if &amp;amp;ft == 'help'&#xA;        let b:status = &quot;%#error#[HELP]%*&quot;&#xA;    else&#xA;        let b:status = &quot;my usual statusline&quot;&#xA;    endif&#xA;    return b:status&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when a help window is open, both statuslines become &lt;code&gt;[HELP]&lt;/code&gt; when that window is in focus, and my usual statusline when the main file is open. I tried using &lt;code&gt;setlocal statusline=%!StatusLine()&lt;/code&gt;, but then nothing gets set for the help file and the main file statusline still becomes &lt;code&gt;[HELP]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing here?&lt;/p&gt;&#xA;" OwnerUserId="12652" LastActivityDate="2017-09-22T02:39:37.103" Title="Setting custom statusline for help window" Tags="|split|statusline|help-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13658" PostTypeId="2" ParentId="13656" CreationDate="2017-09-21T15:29:17.207" Score="3" Body="&lt;p&gt;EDIT: SO I tested it out a little more this morning and had a bit of a dig. Your main issue was trying to do it all in the one function, I don't think this will work sorry. It also &lt;a href=&quot;https://stackoverflow.com/questions/20821185/vimrc-checking-ft-doesnt-work-unless-filetype-detect-ran-1st&quot;&gt;looks like&lt;/a&gt; you may have an issue with the filetype detection with the new buffer load. It appears &lt;code&gt;if &amp;amp;ft == 'help'&lt;/code&gt; can be a little problematic, and it's probably better to use an &lt;code&gt;autocmd&lt;/code&gt;, which should be wrapped in an &lt;code&gt;augroup&lt;/code&gt; - from &lt;code&gt;:help augroup-delete&lt;/code&gt; (can test out your new status line while you have a read!)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This prevents having the autocommands defined twice (e.g., after sourcing the .vimrc file again).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've re-written the code so it follows OP's example more closely&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Default statusline&#xA;set statusline=%!StatusLine()&#xA;function! StatusLine()&#xA;    let b:status =  &quot;my usual statusline&quot;&#xA;    return b:status    &#xA;endfunction&#xA;&quot; Override default statusline if help file&#xA;aug HelpStatusLine&#xA;    au!&#xA;    au FileType help setlocal statusline=%!LocalStatusLine()&#xA;aug END&#xA;function! LocalStatusLine()&#xA;    let b:status = &quot;%#error#[HELP]%*&quot;&#xA;    return b:status&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14380" LastEditorUserId="14380" LastEditDate="2017-09-22T02:39:37.103" LastActivityDate="2017-09-22T02:39:37.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13659" PostTypeId="2" ParentId="13650" CreationDate="2017-09-21T16:17:22.853" Score="1" Body="&lt;p&gt;Along with Mass's answer, I think your latin american keyboard might be causing some confusion. Vim can't see Shift and Ctrl when used together on letter keys, because it produces no ASCII output. I simulated a latin american keyboard on my computer and found that in order to trigger tags all I needed to do was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL+}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's counter-intuitive since the documentation says that its &lt;code&gt;CTRL+]&lt;/code&gt; but because of how vim interprets Ctrl this is the correct key combo on a latin american keyboard.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2017-09-21T16:25:55.003" LastActivityDate="2017-09-21T16:25:55.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13660" PostTypeId="1" CreationDate="2017-09-21T17:58:00.070" Score="4" ViewCount="641" Body="&lt;p&gt;I would like a piece of Vimscript which would &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;query the time of day&lt;/li&gt;&#xA;&lt;li&gt;check whether it's later than, say, 6pm&lt;/li&gt;&#xA;&lt;li&gt;set an option based on the result&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Why? So that I get the dark solarized color scheme whenever I open my editor in the evening, the light one otherwise. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this be done?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2017-09-25T07:29:12.153" Title="How can I set an option differently depending on time of day?" Tags="|vimscript|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13661" PostTypeId="2" ParentId="13656" CreationDate="2017-09-21T18:14:12.833" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;https://vimhelp.appspot.com/windows.txt.html#status-line&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h status-line&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This option can be local to the window, so that you can have a different&#xA;  status line in each window.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As ljden pointed out, you must use a local status line otherwise it is set for all buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%!StatusLine()&#xA;function! StatusLine()&#xA;    if &amp;amp;ft == 'help'&#xA;        let l:status = &quot;%#error#[HELP]%*&quot;&#xA;    else&#xA;        let l:status = &quot;my usual statusline&quot;&#xA;    endif&#xA;    let &amp;amp;l:statusline = l:status&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However it might be easier to just add this to &lt;code&gt;~/.vim/ftplugin/help.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal statusline=%#error#[HELP]%*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2017-09-21T18:14:12.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13662" PostTypeId="1" AcceptedAnswerId="13663" CreationDate="2017-09-21T18:46:13.297" Score="6" ViewCount="1318" Body="&lt;p&gt;I usually find myself running pattern replacements on the results of &lt;code&gt;vim-fugitive&lt;/code&gt;'s &lt;code&gt;Ggrep&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Ggrep someFunctionName&#xA;:cfdo %s/someFunctionName/someOtherName/g | update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that works great but I can still see &lt;code&gt;someFunctionName&lt;/code&gt; on the quickfix matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the quickfix gets those values from another function and it doesn't keep track of the actual files, but I'm wondering if there's a way to read the locations and refresh them with the new content.&lt;/p&gt;&#xA;" OwnerUserId="1300" LastActivityDate="2017-09-21T19:43:17.463" Title="Is there a way to update the quickfix entries after running cdo/cfdo?" Tags="|quickfix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13663" PostTypeId="2" ParentId="13662" CreationDate="2017-09-21T19:43:17.463" Score="3" Body="&lt;p&gt;I am sure there is a better way, but this is how I would do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setqflist(map(getqflist(), 'extend(v:val, {&quot;text&quot;:get(getbufline(v:val.bufnr, v:val.lnum),0)})'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically use &lt;code&gt;getqflist()&lt;/code&gt; to get each Quickfix line. Using &lt;code&gt;getbufline()&lt;/code&gt; to get each newly updated line. Then update the quickfix list via &lt;code&gt;setqflist()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: This relies on &lt;code&gt;getbufline()&lt;/code&gt; which requires the buffer to be loaded to get a line back properly (&lt;code&gt;:cfdo&lt;/code&gt; should load the buffers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h setqflist()&#xA;:h getqflist()&#xA;:h map()&#xA;:h extend()&#xA;:h getbufline()&#xA;:h get()&#xA;:h :call&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-09-21T19:43:17.463" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13664" PostTypeId="2" ParentId="13621" CreationDate="2017-09-21T20:47:10.823" Score="0" Body="&lt;p&gt;IMHO the correct answer is (as already mentioned)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;inoremap &amp;lt;D-]&amp;gt; &amp;lt;C-t&amp;gt;&#xA;inoremap &amp;lt;D-[&amp;gt; &amp;lt;C-d&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, you can define the &lt;code&gt;CMD+]&lt;/code&gt; mappings also for normal and visual mode:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;nnoremap &amp;lt;D-]&amp;gt; &amp;gt;&amp;gt;&#xA;nnoremap &amp;lt;D-[&amp;gt; &amp;gt;&amp;gt;&#xA;xnoremap &amp;lt;D-]&amp;gt; &amp;gt;&#xA;xnoremap &amp;lt;D-[&amp;gt; &amp;lt;&#xA;&quot; If you prefer to keep the visual selection (not the vim way)&#xA;&quot; xnoremap &amp;lt;D-]&amp;gt; &amp;gt;gv&#xA;&quot; xnoremap &amp;lt;D-[&amp;gt; &amp;lt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Default Mappings of Vim&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;However, note that vim already provides builtin mappings&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;CTRL-T&#xA;CTRL-D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which obviously work everywhere (Linux/Windows/MacOS, gui/cli, etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, vim is a modal editor where many changes are meant to be done in &lt;em&gt;normal mode&lt;/em&gt; and not in insert mode. I consider increasing or decreasing indentation a change most often done in normal mode. Vim provides mappings to change indentation in normal mode with&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;&amp;gt;&amp;gt; or &amp;gt;{motion} &#xA;&amp;lt;&amp;lt; or &amp;lt;{motion}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Combing &lt;code&gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;&lt;/code&gt; with a &lt;em&gt;text-object&lt;/em&gt; (&lt;code&gt;:h text-objects&lt;/code&gt;) such as &lt;code&gt;ip&lt;/code&gt; you can indent larger parts of text with a single command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another important vim feature here is the &lt;em&gt;dot-command&lt;/em&gt; (&lt;code&gt;:h .&lt;/code&gt;) to repeat it: &lt;code&gt;&amp;gt;ip..&lt;/code&gt; means indent paragraph three times.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Transition to &lt;em&gt;Vim's Way&lt;/em&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I would use &lt;code&gt;CMD+][&lt;/code&gt; mappings to ease your transition to vim. If you know the vim mappings by heart, you could or &lt;em&gt;should&lt;/em&gt; consider removing them. &lt;code&gt;MacVim&lt;/code&gt; provides other &lt;code&gt;CMD+&lt;/code&gt; mappings which follow the macOS human interface guidelines (HIG) &lt;code&gt;:h macvim-shortcuts&lt;/code&gt; (most importantly &lt;code&gt;CMD+s&lt;/code&gt; for saving, &lt;code&gt;CMD+f&lt;/code&gt; for finding, &lt;code&gt;CMD+b&lt;/code&gt; for building and &lt;code&gt;CMD+x/c/v&lt;/code&gt; for cut, copy, paste). However, in my experience when you have become familiar with vim, you do not need them anymore and use vim consistently between platforms. Even though I admit that &lt;code&gt;&quot;+p&lt;/code&gt; is not as convenient as &lt;code&gt;CMD+v&lt;/code&gt;, but in this case IMHO &lt;code&gt;CTRL-t/d&lt;/code&gt; are as good as &lt;code&gt;CMD-]/[&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2017-11-14T11:02:07.897" LastActivityDate="2017-11-14T11:02:07.897" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13665" PostTypeId="2" ParentId="13660" CreationDate="2017-09-22T02:49:26.110" Score="3" Body="&lt;p&gt;No need to reinvent the wheel, had a quick google and &lt;a href=&quot;https://github.com/nightsense/night-and-day&quot; rel=&quot;nofollow noreferrer&quot;&gt;here's&lt;/a&gt; a plugin that does exactly that! Even steps you through installing the plugin manager vim-plug (which is a great plugin manager) if you don't have it already. &lt;/p&gt;&#xA;" OwnerUserId="14380" LastActivityDate="2017-09-22T02:49:26.110" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13666" PostTypeId="1" CreationDate="2017-09-22T03:16:23.037" Score="2" ViewCount="657" Body="&lt;p&gt;Is it possible to use the javascript regex engine instead of built-in one for search and substitute?&lt;/p&gt;&#xA;" OwnerUserId="11904" LastEditorUserId="1841" LastEditDate="2017-09-22T07:46:52.147" LastActivityDate="2017-09-22T12:13:59.940" Title="How to use the JS regex engine instead of the built in engine?" Tags="|search|regular-expression|substitute|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13667" PostTypeId="2" ParentId="13660" CreationDate="2017-09-22T07:59:00.560" Score="12" Body="&lt;p&gt;On a Unix system you can add this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if system('date +%H') &amp;gt; 18&#xA;    colorscheme night&#xA;else&#xA;    colorscheme day&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;date +%H&lt;/code&gt; is a shell command which returns the hour in a 24 format (see &lt;a href=&quot;http://man7.org/linux/man-pages/man1/date.1.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;man date&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;system()&lt;/code&gt; allows you to get the result of a system command in vimscript. It is then easy to compare its result with the hour you want to trigger your setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; as @LucHermitte pointed out in the comments, you should use &lt;code&gt;strftime('%H')&lt;/code&gt; instead of &lt;code&gt;system('date +%H')&lt;/code&gt; this is more portable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that with this solution the code is only executed when you source your vimrc so if you start vim at 5:30 pm, your colorscheme will not change at 6:00 pm if you don't reload your vimrc. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT - Automated and auto-update solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did this because I thought it was fun to do. The plugin linked in @ljden answer may be more robust, this is only a lightweight solution which may have some flaws. The fun thing about this solution is that it will change the colorscheme automatically without having to source your vimrc again: &lt;strong&gt;You can finally code for 24h straight without having to think about your colorscheme!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution will only work with vim8+ and the options &lt;code&gt;+timers&lt;/code&gt; and &lt;code&gt;+job&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is pretty simple, you define:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;g:dayTime&lt;/code&gt; the hour after which we should use daytime colorscheme&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g:nightTime&lt;/code&gt; the hour after which we should use nighttime colorscheme.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g:colorschemeDay&lt;/code&gt; the colorscheme  to use in daytime&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g:colorschemeNight&lt;/code&gt; the colorscheme  to use in nighttime&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;We create two helper functions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;DiffTime()&lt;/code&gt; which returns the number of milliseconds between two hours of the day.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;IsDayTime()&lt;/code&gt; which returns a boolean saying if the current hour is between &lt;code&gt;g:dayTime&lt;/code&gt; and &lt;code&gt;g:nightTime&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;We also create the function &lt;code&gt;ScheduleNewColorscheme&lt;/code&gt; which will do two things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Set the colorscheme according to the hour of the day&lt;/li&gt;&#xA;&lt;li&gt;Set a trigger to call itself when we pass &lt;code&gt;nightTime&lt;/code&gt; or &lt;code&gt;dayTime&lt;/code&gt; again.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Finally, we call the function immediately when the &lt;code&gt;.vimrc&lt;/code&gt; is sourced to set the correct colorscheme:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Define the hours which triggers the dayly colorscheme&#xA;let g:dayTime = [9, 30]&#xA;&quot; Define the hours which triggers the nightly colorscheme&#xA;let g:nightTime = [18, 0]&#xA;&#xA;&quot; Define the colorschemes used by day and by night&#xA;let g:colorschemeDay = 'jellybeans'&#xA;let g:colorschemeNight = 'darkblue'&#xA;&#xA;&quot; Return the number of milliseconds beetwen the current hour and a target hour.&#xA;&quot; Handles the case of a target hour the next day.&#xA;&quot; Both hours should be lists composed of two elements: hours and minutes.&#xA;&quot; Eg 11:20 pm = [23, 20]&#xA;&quot;    09:00 am = [9, 0]&#xA;function! TimeDiff(current, target)&#xA;    let targetMilli   = (a:target[0] * 3600 + a:target[1] * 60) * 1000&#xA;    let currentMilli  = (a:current[0] * 3600 + a:current[1] * 60) * 1000&#xA;&#xA;    if (a:target[0] &amp;gt; a:current[0] || (a:target[0] == a:current[0] &amp;amp;&amp;amp; a:target[1] &amp;gt; a:current[1]))&#xA;        return targetMilli - currentMilli&#xA;    else&#xA;        return (24 * 3600 * 1000) + ( currentMilli - targetMilli )&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot; Check if the current hour is between g:dayTime and g:nighTime&#xA;function! IsDayTime()&#xA;    let hCurrent = strftime('%H')&#xA;    let mCurrent = strftime('%M')&#xA;&#xA;    if hCurrent == g:dayTime[0]&#xA;        return mCurrent &amp;gt;= g:dayTime[1]&#xA;    elseif hCurrent == g:nightTime[0]&#xA;        return mCurrent &amp;lt; g:nightTime[1]&#xA;    else&#xA;        return hCurrent &amp;gt; g:dayTime[0] &amp;amp;&amp;amp; hCurrent &amp;lt; g:nightTime[0]&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot; According to the current time and the nighttime, set the colorscheme and create&#xA;&quot; a trigger for the job which will change the colorscheme&#xA;function! ScheduleNewColorscheme(timer)&#xA;    &quot; Define colorscheme and next time depending on time of day&#xA;    if IsDayTime()&#xA;        let newColorscheme = g:colorschemeDay&#xA;        let targetDate = g:nightTime&#xA;    else&#xA;        let newColorscheme =g:colorschemeNight&#xA;        let targetDate = g:dayTime&#xA;    endif&#xA;&#xA;    &quot; Set new colorscheme&#xA;    echom 'setting colorscheme ' . newColorscheme . ' at ' . strftime('%H:%M')&#xA;    execute 'colorscheme ' . newColorscheme&#xA;&#xA;    let currentDate = [strftime('%H'), strftime('%M')]&#xA;    let startDelay = TimeDiff(currentDate, targetDate)&#xA;&#xA;    &quot; Create the trigger for the next change&#xA;    call timer_start(startDelay, 'ScheduleNewColorscheme', {}) &#xA;endfunction&#xA;&#xA;&quot; When sourcing your vimrc set the colorscheme immediately&#xA;call timer_start(0, 'ScheduleNewColorscheme', {}) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; I looked at the plugin linked in @ljden's answer and it includes another plugin in its source code (&lt;a href=&quot;https://github.com/nightsense/night-and-day/blob/master/plugin/colorscheme-switcher.vim&quot; rel=&quot;noreferrer&quot;&gt;colorscheme-switcher&lt;/a&gt;) which requires a third plugin (&lt;a href=&quot;https://github.com/nightsense/night-and-day/blob/master/plugin/colorscheme-switcher.vim#L14-L21&quot; rel=&quot;noreferrer&quot;&gt;vim-misc&lt;/a&gt;). So I thought why not make a lightweight plugin of my own? So &lt;a href=&quot;https://github.com/statox/colorscheme-changer.vim&quot; rel=&quot;noreferrer&quot;&gt;here it is&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-09-25T07:29:12.153" LastActivityDate="2017-09-25T07:29:12.153" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13668" PostTypeId="1" CreationDate="2017-09-22T10:39:06.013" Score="2" ViewCount="530" Body="&lt;p&gt;I'm using vim 8.0 and tmux 2.5 on ubuntu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I have set the TERM environment &lt;code&gt;export TERM=screen-256color&lt;/code&gt; and run as &lt;code&gt;tmux -2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, nothing goes wrong. It's like the following picture:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lPQNo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lPQNo.png&quot; alt=&quot;Normal&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But after I move cursor over the right parenthesis several times,&#xA;the highlighting will be lost, like the following picture:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SjgjB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SjgjB.png&quot; alt=&quot;lost&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run the commands &lt;code&gt;:NoMatchParen&lt;/code&gt; in vim,&#xA;nothing goes wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any solution to it without turning off parenthesis matching?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="14386" LastActivityDate="2017-09-22T11:18:30.647" Title="vim in tmux lose highlighting" Tags="|syntax-highlighting|tmux|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13670" PostTypeId="2" ParentId="13666" CreationDate="2017-09-22T12:13:59.940" Score="5" Body="&lt;p&gt;I can understand the frustration in having to learn a new&lt;sup&gt;1&lt;/sup&gt; regular expression dialect when you already know one well, but it's not possible to change which dialect Vim uses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's default regular expressions make it quicker to search for the textual elements frequently found in code. Thus you can search for for e.g. &lt;code&gt;foo()&lt;/code&gt; simply with the expression &lt;code&gt;foo()&lt;/code&gt;. Personally, this isn't to my taste, so I have the following in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap / /\v&#xA;nnoremap ? ?\v&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means my searches begin in &quot;very magic&quot; mode, so much less escaping is required to get to regular expression features such as grouping. If I need a normal &quot;magic&quot; expression I can simply delete the &lt;code&gt;\v&lt;/code&gt; by pressing &lt;kbd&gt;Backspace&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, some of the other differences (e.g. the syntax for lookaround) you're just going to have to learn afresh, I'm afraid. The best place if you're already well versed in regular expressions is probably the reference documentation (&lt;code&gt;:help regexp&lt;/code&gt;), but there's also info in the user guide (&lt;code&gt;:help usr_27.txt&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/2279/343&quot;&gt;This previous answer by tommcdo&lt;/a&gt; explains some of the benefits you will get from doing so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1: New to you, that is. Vim's regular expressions pre-date most other current dialects.&lt;/sub&gt;  &lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-09-22T12:13:59.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13671" PostTypeId="1" CreationDate="2017-09-22T16:34:15.723" Score="1" ViewCount="40" Body="&lt;p&gt;I try to inline one syntax in another syntax (to be explicit: CSS in JS template strings). I'd like to build on top of the existing CSS definitions and not create new ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question: Is it possible to access previously defined syntax matches/keywords for access in other syntax definitions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;&lt;hr&gt;&#xA;&lt;br&gt;&#xA;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine the following definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword cssPseudoClassId contained link visited active&#xA;syn match   cssPseudoClassId contained &quot;\&amp;lt;first-\(line\|letter\)\&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I access cssPseudoClassId to include it in another syntax definition to not re-write it manually.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region customWhatever transparent fold&#xA;        \ start=&quot;:&quot;.cssPseudoClassId end=&quot;\ze\(,\|;\|...\)&quot;&#xA;        \ skip=&quot;\\\(`\|\$\)&quot; ...&#xA;        \ contains=css.*Prop,...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any other tips are highly appreciated.  &lt;/p&gt;&#xA;" OwnerUserId="14393" LastActivityDate="2017-09-22T16:34:15.723" Title="How to access syntax elements" Tags="|syntax-highlighting|regular-expression|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13674" PostTypeId="1" CreationDate="2017-09-22T19:35:16.447" Score="3" ViewCount="2108" Body="&lt;p&gt;There is something I cannot do with &lt;code&gt;YouCompleteMe&lt;/code&gt; that I could do when just using tags to navigate to a definition or declaration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The desired behaviour is&lt;/strong&gt; (taking into account that &lt;kbd&gt;,&lt;/kbd&gt; is my leader key):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt; should attempt to go to the definition/declaration in the current buffer. If changes to the buffer are not saved, it should print an error &quot;No write since last change&quot; or something similar and do nothing.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt; should open the definition/declaration in a vertical split, regardless of whether changes to the current buffer have been saved or not (since the original buffer will remain open).&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt; should open the definition/declaration in a new tab, regardless of whether changes to the current buffer have been saved or not (since the original buffer will remain open).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;ctags&lt;/code&gt;, behaviour 1 was the standard &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;, and 2 and 3 could be achieved with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Open definition in new vertical split&#xA;map &amp;lt;leader&amp;gt;ds :vsp &amp;lt;CR&amp;gt;:exec(&quot;tag &quot;.expand(&quot;&amp;lt;cword&amp;gt;&quot;))&amp;lt;CR&amp;gt;&#xA;&quot; Open definition in new tab&#xA;map &amp;lt;leader&amp;gt;dt :tab split&amp;lt;CR&amp;gt;:exec(&quot;tag &quot;.expand(&quot;&amp;lt;cword&amp;gt;&quot;))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;YouCompleteMe&lt;/code&gt; seems to behave differently. According to the &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe#the-gycm_goto_buffer_command-option&quot; rel=&quot;nofollow noreferrer&quot;&gt;official documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;The g:ycm_goto_buffer_command option&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Defines where GoTo* commands result should be opened. Can take one of&#xA;  the following values: [ 'same-buffer', 'horizontal-split',&#xA;  'vertical-split', 'new-tab', 'new-or-existing-tab' ] If this option is&#xA;  set to the 'same-buffer' but current buffer can not be switched (when&#xA;  buffer is modified and nohidden option is set), then result will be&#xA;  opened in horizontal split.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This means that if I define my new mappings as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Shortcuts for navigating to definitions using YouCompleteMe&#xA;map &amp;lt;leader&amp;gt;g  :YcmCompleter GoToDefinitionElseDeclaration&amp;lt;CR&amp;gt;&#xA;&quot; Open definition in new vertical split&#xA;map &amp;lt;leader&amp;gt;ds :vsp &amp;lt;CR&amp;gt;:exec(&quot;YcmCompleter GoToDefinitionElseDeclaration&quot;)&amp;lt;CR&amp;gt;&#xA;&quot; Open definition in new tab&#xA;map &amp;lt;leader&amp;gt;dt :tab split&amp;lt;CR&amp;gt;:exec(&quot;YcmCompleter GoToDefinitionElseDeclaration&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't achieve any of the behaviours if the changes to the file have not been saved:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt; does not print an error, but instead opens the definition/declaration in a new horizontal split.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt; does not open the definition/declaration in the new split directly, but instead creates the vertical split and then opens the definition/declaration in a horizontal split inside the vertical split.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt; does not open the definition/declaration in the new tab directly, but instead creates the new tab and then opens the definition/declaration in a horizontal split inside the tab.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What settings/mappings should I set to achieve the desired behaviour?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="12266" LastActivityDate="2024-03-27T13:06:40.783" Title="Make YouCompleteMe open definition in vertical split even if buffer is not saved" Tags="|vimrc|key-bindings|plugin-you-complete-me|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13675" PostTypeId="5" CreationDate="2017-09-22T21:02:15.503" Score="0" Body="&lt;h1&gt;About Bash&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;There are a variety of interpreters that receive commands either interactively or as a sequence of commands from a file. The &lt;a href=&quot;http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bourne-again shell&lt;/a&gt; (Bash) is one such interpreter. Bash implements the standard &lt;a href=&quot;http://en.wikipedia.org/wiki/Bourne_shell&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bourne Shell&lt;/a&gt; (sh), and offers numerous additions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the Free Software Foundation's &lt;a href=&quot;http://www.gnu.org/software/bash/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bash page&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Bash is an sh-compatible shell that incorporates useful features from the KornShell (ksh) and C shell (csh). It is intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers functional improvements over sh for both programming and interactive use. In addition, most sh scripts can be run by Bash without modification.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Read the &lt;a href=&quot;http://www.gnu.org/software/bash/manual/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bash manual&lt;/a&gt; for technical details.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Books and Resources&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Additional reading materials include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/bash/manual/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bash manual&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://tiswww.case.edu/php/chet/bash/FAQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bash FAQ&lt;/a&gt; by the current primary maintainer, &lt;a href=&quot;http://tiswww.case.edu/php/chet/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chet Ramey&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://mywiki.wooledge.org/BashFAQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bash FAQ&lt;/a&gt; by Lhunath&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://mywiki.wooledge.org/BashPitfalls&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bash pitfalls&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://wiki.bash-hackers.org/scripting/newbie_traps&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bash beginner's mistakes&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://wiki.bash-hackers.org/doku.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bash hackers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://mywiki.wooledge.org/BashGuide&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bash Guide&lt;/a&gt; by Lhunath&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://tldp.org/LDP/abs/html/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Advanced Bash-Scripting Guide&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.tldp.org/LDP/Bash-Beginners-Guide/html/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bash Guide for Beginners&lt;/a&gt; by Machtelt Garrels&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learncodethehardway.org/cli/book/&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Command Line Crash Course&lt;/a&gt; (also a Powershell reference)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4472" LastEditorUserId="4472" LastEditDate="2017-09-23T23:33:49.467" LastActivityDate="2017-09-23T23:33:49.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13676" PostTypeId="4" CreationDate="2017-09-22T21:02:15.503" Score="0" Body="BASH is the GNU Bourne Again SHell, the successor to the classic Unix Bourne sh (shell). It's the default shell for various Linux/GNU systems." OwnerUserId="4472" LastEditorUserId="4472" LastEditDate="2017-09-23T23:33:38.860" LastActivityDate="2017-09-23T23:33:38.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13677" PostTypeId="1" AcceptedAnswerId="13680" CreationDate="2017-09-23T13:49:07.643" Score="2" ViewCount="1530" Body="&lt;p&gt;I want my mapleader to be &lt;kbd&gt;;&lt;/kbd&gt; and keep his Vim functionality, therefore remap the default &lt;kbd&gt;;&lt;/kbd&gt; Vim function to another key, let's say &lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;.&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm new to Vim and it seems like a simple question but I can't find exactly what I what. If you think it's a bad idea, feel free to criticize.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've already included this line in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14401" LastEditorUserId="1841" LastEditDate="2017-09-25T06:45:00.363" LastActivityDate="2017-09-25T06:45:00.363" Title="Vim default key binding" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13679" PostTypeId="1" AcceptedAnswerId="13681" CreationDate="2017-09-24T00:59:32.437" Score="2" ViewCount="162" Body="&lt;p&gt;It seems that vim does not work correctly when editing files in Windows systems directories. For example, editing the PowerShell all users, all hosts profile script fails. The current file has only one (1) line in it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:&amp;gt;Get-Content C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1&#xA;Write-Host &quot;$($PSVersionTable.PSVersion.ToString()) All Users, All Hosts @ $($MyInvocation.MyCommand.Source)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use vim to add one line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 asdf&#xA;2 Write-Host &quot;$($PSVersionTable.PSVersion.ToString()) All Users, All Hosts @ $($MyInvocation.MyCommand.Source)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After saving and exiting vim, the file remains unchanged.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:&amp;gt;Get-Content C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1&#xA;Write-Host &quot;$($PSVersionTable.PSVersion.ToString()) All Users, All Hosts @ $($MyInvocation.MyCommand.Source)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet, when I run vim on the file again, it appears with the line I added.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1 asdf&#xA; 2 Write-Host &quot;$($PSVersionTable.PSVersion.ToString()) All Users, All Hosts @ $($MyInvocation.MyCommand.Source)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do not see any information about the file being read-only. Using Ctrl-G only presents the expected &lt;code&gt;&quot;profile.ps1&quot; line 1 of 2 --50%-- col 1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I start the shell as Administrator and edit the file, it appears to be empty.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using C:&gt;vim --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov  6 2016 17:05:36)&lt;/p&gt;&#xA;" OwnerUserId="14404" LastEditorUserId="343" LastEditDate="2018-10-09T13:45:36.170" LastActivityDate="2018-10-09T15:51:31.617" Title="Why can system directory files not be edited" Tags="|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13680" PostTypeId="2" ParentId="13677" CreationDate="2017-09-24T04:44:54.930" Score="4" Body="&lt;h1&gt;TL;DR&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;noremap&lt;/code&gt; (&lt;code&gt;nnoremap&lt;/code&gt; to make sure make it work only in normal mode)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader=&quot;;&quot;&#xA;nnoremap '. ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Better leader&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;IMO, you should remap &lt;code&gt;;&lt;/code&gt; to &lt;code&gt;:&lt;/code&gt; (if you're on QWERTY). Most people remap their leader to &lt;code&gt;,&lt;/code&gt; also. I think you should do the same (I did and I'm very happy with it). Here's how you do it (just adapt it to your needs).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;code&gt;map&lt;/code&gt; vs &lt;code&gt;noremap&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map&lt;/code&gt; allows you to map certain keystrokes to other ones. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map ; :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this does is as soon as you press &lt;code&gt;;&lt;/code&gt;, it'll do exactly what it would've done if you pressed &lt;code&gt;:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To restrict this shortcut to work only in normal mode, just use &lt;code&gt;nmap&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap ; :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW, do you know what it would have done if you used &lt;code&gt;map&lt;/code&gt; and pressed &lt;code&gt;;&lt;/code&gt; in insert mode? It would have inserted a &lt;code&gt;:&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with &lt;code&gt;map&lt;/code&gt; (and &lt;code&gt;nmap&lt;/code&gt;, &lt;code&gt;imap&lt;/code&gt;, all the family) is that it uses user defined shortcut. For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap a b&#xA;imap b c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, when you press &lt;code&gt;a&lt;/code&gt;, it'll in fact &quot;press&quot; &lt;code&gt;b&lt;/code&gt;, and then &quot;press&quot; &lt;code&gt;c&lt;/code&gt; because of the second &lt;code&gt;imap&lt;/code&gt; (in insert mode of cours). So, when you press &lt;code&gt;a&lt;/code&gt;, it'll insert a &lt;code&gt;c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that's no good at all. It might sounds good, but it isn't reliable, since everything can be remap without you knowing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to counter that, you got &lt;code&gt;noremap&lt;/code&gt; (and &lt;code&gt;nnoremap&lt;/code&gt;, &lt;code&gt;inoremap&lt;/code&gt;, all the family again). These ones only use vim's &lt;strong&gt;default keybindings&lt;/strong&gt;. It doesn't take into account the other mapping. &lt;strong&gt;That's the ones you want to use&lt;/strong&gt; unless you &lt;em&gt;want&lt;/em&gt; to use a plugin's shortcut, or one of yours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, with the previous example, if we would have used &lt;code&gt;inoremap&lt;/code&gt;, and press &lt;code&gt;a&lt;/code&gt;, we would've got &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, we can now interchange &lt;code&gt;:&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ; :&#xA;nnoremap : ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;nmap&lt;/code&gt;, it'll loop forever (&lt;code&gt;;&lt;/code&gt; would press &lt;code&gt;:&lt;/code&gt;, which would press &lt;code&gt;;&lt;/code&gt;, which would...)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Visual mode&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You'll probably want this remap in visual mode too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap : ;&#xA;nnoremap ; :&#xA;vnoremap ; :&#xA;vnoremap : ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to learn vim, I strongly recommend you read &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn VimScript the hard way&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to see the different options about anything in vim, the &lt;code&gt;help&lt;/code&gt;'s great. In this case &lt;code&gt;:help map&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Extra tip&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tab help map&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Opens the help page in a new tab (&lt;code&gt;gt&lt;/code&gt; and &lt;code&gt;gT&lt;/code&gt; to navigate tabs)&lt;/p&gt;&#xA;" OwnerUserId="13449" LastActivityDate="2017-09-24T04:44:54.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13681" PostTypeId="2" ParentId="13679" CreationDate="2017-09-24T06:55:36.640" Score="3" Body="&lt;p&gt;Are you on 64-bit Windows? If so then I believe you are encountering two different files due to some Windows voodoo. See if you find a mirrored version in this folder: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Windows\SysWOW64\WindowsPowerShell\v1.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What the heck is that about? It's related to Windows allowing 32-bit programs to be run on a 64-bit system. The 32-bit emulator...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...redirects calls to System32 folder to the SysWOW64 folder&#xA;  transparently so even if the folder is hard coded to the System32&#xA;  folder (like C:\Windows\System32), the emulator will make sure that&#xA;  the SysWOW64 folder is used instead.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I did some experimenting on my 64-bit system. When I try to edit &lt;code&gt;C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1&lt;/code&gt; with my &lt;em&gt;32-bit&lt;/em&gt; gvim executable I see the same behavior as you and my changes are actually made to the clone under the &lt;code&gt;SysWOW64&lt;/code&gt; folder. Conversely when I try the same thing using a 64-bit vim executable (from my 64-bit Cygwin install) my changes actually affect the &lt;code&gt;System32&lt;/code&gt; version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.samlogic.net/articles/32-64-bit-windows-folder-x86-syswow64.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here's an article that discusses this phenomenon&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what is one to do if one really wants to access a System32 file with a 32-bit editor? Well, there's another magic folder, &lt;code&gt;Sysnative&lt;/code&gt;, that makes this possible. Simply replace &quot;System32&quot; with &quot;Sysnative&quot; in the target file's path and you're in business. Note that this magic folder will not be visible to any 64-bit programs and that includes Explorer (the Windows file manager). Crystal clear, no?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's &lt;a href=&quot;http://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;an article about Sysnative&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-10-09T15:51:31.617" LastActivityDate="2018-10-09T15:51:31.617" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="13682" PostTypeId="1" AcceptedAnswerId="13685" CreationDate="2017-09-24T14:10:49.503" Score="0" ViewCount="446" Body="&lt;p&gt;I'm currently using gvim 8.0 on Windows 10.&#xA;When I try to do the following command,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo system('echo %PATH%')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the following error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E484: Can't open file C:/Users/BITS_A~1/AppData/Local/Temp/VIoBE39.tmp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why would vim try to open a file even when it just needs to echo the PATH variable, and why is it changing my user directory name, bits_and_scraps, to BITS_A~1?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo %PATH%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works perfectly from my cmd.&lt;/p&gt;&#xA;" OwnerUserId="14410" LastActivityDate="2017-09-26T10:51:33.003" Title="Error occurs while echoing system('echo %PATH%')" Tags="|path|echo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13683" PostTypeId="1" CreationDate="2017-09-24T15:14:15.400" Score="0" ViewCount="2180" Body="&lt;p&gt;I'm stalling Vim-latex. I believe I have done steps 1 and 2 on &lt;a href=&quot;http://vim-latex.sourceforge.net/index.php?subject=download&amp;amp;title=Download&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim-latex.sourceforge.net/index.php?subject=download&amp;amp;title=Download&lt;/a&gt;.&#xA;How can I do step 3 if I'm using Windows? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="14411" LastActivityDate="2018-04-22T19:09:36.020" Title="Install vim-latex in windows" Tags="|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13684" PostTypeId="2" ParentId="13683" CreationDate="2017-09-24T16:00:39.747" Score="1" Body="&lt;p&gt;You just need to type &lt;code&gt;helptags ~/vimfiles/doc&lt;/code&gt; in command-line mode, that is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helptags ~/vimfiles/doc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This step will generate help tags (see &lt;code&gt;:h helptags&lt;/code&gt;) files which allow you to use tag jump (&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;]&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;T&lt;/kbd&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Plugin Manager&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Note that plugin manager does this step for you (e.g. &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim#about&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vundle&lt;/a&gt;) and this is also &lt;a href=&quot;https://github.com/vim-latex/vim-latex&quot; rel=&quot;nofollow noreferrer&quot;&gt;recommended&lt;/a&gt;. For instance, after installing Vundle, you just need to put &lt;code&gt;Plugin 'vim-latex/vim-latex'&lt;/code&gt; (in the appropriate place) in your &lt;code&gt;.vimrc&lt;/code&gt; (in your case &lt;code&gt;_vimrc&lt;/code&gt; or &lt;code&gt;_gvimrc&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the Vundle's wiki for more details to install Vundle under Windows. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I never use vim under Windows, so I may be wrong.&lt;/p&gt;&#xA;" OwnerUserId="11430" LastEditorUserId="11430" LastEditDate="2017-09-24T16:05:57.543" LastActivityDate="2017-09-24T16:05:57.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13685" PostTypeId="2" ParentId="13682" CreationDate="2017-09-25T01:33:52.730" Score="2" Body="&lt;p&gt;It sounds like you've overridden some of the settings used to invoke external programs. Is your Vim set up so programs run in either Cygwin or Windows Linux Subsystem by any chance?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try starting &lt;code&gt;vim&lt;/code&gt; with &lt;code&gt;-u NONE -i none&lt;/code&gt;. Alternatively run these after starting &lt;code&gt;vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set shell&amp;amp;&#xA;:set shellxquote&amp;amp;&#xA;:set shellxescape&amp;amp;&#xA;:set shellcmdflag&amp;amp;&#xA;:set shellredir&amp;amp;&#xA;:set shellslash&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does it work now? If not try &lt;code&gt;:set verbose=5&lt;/code&gt; and run again. What does it say?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim saves the output of &lt;code&gt;system()&lt;/code&gt; to a temporary file before doing anything further (such as displaying the result in the Vim window). Looks like the error you are seeing is caused by having Unix style paths configured. Windows doesn't know how to interpret such paths so the write to temporary file fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I was finally able to reproduce this. The shell settings (i.e. those related to &lt;code&gt;/&lt;/code&gt; vs &lt;code&gt;\&lt;/code&gt;) are only part of the story. There is also a quoting issue. Try &lt;code&gt;:echo system('echo &quot;%PATH%&quot;')&lt;/code&gt;. That solved the problem for me. Evaluation of the parameter passed to &lt;code&gt;system()&lt;/code&gt; is not as I originally assumed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess there are characters in our &lt;code&gt;PATH&lt;/code&gt; var, encountered by Vim as it builds the redirect, that are special to Vim...by quoting them they lose their special meaning (as is often the case in shells). (And that error message about opening the temp file became a bit misleading once the slashes were fixed.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, hopefully you can get things working now.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-09-26T10:51:33.003" LastActivityDate="2017-09-26T10:51:33.003" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13687" PostTypeId="1" AcceptedAnswerId="13688" CreationDate="2017-09-25T16:05:37.157" Score="3" ViewCount="553" Body="&lt;p&gt;So the problem is that I've installed (g)Vim and the arrow keys are moving around rather than going through command history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a little complicated by the fact that there was an old version of vim installed by a different user (I've just inherited someone else's dev machine at a new job).  I'm running on windows and have just deleted the vimrc under program files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What setting has changed this behaviour and how do I change it back to normal mode?&lt;/p&gt;&#xA;" OwnerUserId="1518" LastEditorUserId="51" LastEditDate="2017-09-27T07:41:24.870" LastActivityDate="2017-09-27T07:41:24.870" Title="I've just installed (g)Vim, how do I get arrow keys to access command history?" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13688" PostTypeId="2" ParentId="13687" CreationDate="2017-09-25T17:15:21.313" Score="6" Body="&lt;p&gt;Without a &lt;code&gt;.vimrc&lt;/code&gt; vim will run in cp-mode (compatibility-mode).&#xA;Just create a &lt;code&gt;.vimrc&lt;/code&gt; in your home-dir and the problem should be fixed.&#xA;The &lt;code&gt;.vimrc&lt;/code&gt; can be empty, though it is advisable to put &lt;code&gt;set nocp&lt;/code&gt; in there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The full story can be found in &lt;code&gt;:help 'cp&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="11477" LastEditDate="2017-09-26T19:19:48.447" LastActivityDate="2017-09-26T19:19:48.447" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13689" PostTypeId="1" AcceptedAnswerId="13690" CreationDate="2017-09-25T19:50:48.783" Score="78" ViewCount="25844" Body="&lt;p&gt;I'd like to optimize my &quot;find and replace&quot; workflow in Vim. It's something I do often, as I'm sure most of you do too. Usually something along the lines of -- &lt;em&gt;copy a block and change the name of a variable in a few places.&lt;/em&gt; I know, I know, that probably triggers your &quot;why are you copying and pasting code&quot; reflex, but let's not go down that road... There are plenty of valid use cases :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm well aware of the search and replace commands: &lt;code&gt;:s&lt;/code&gt; or &lt;code&gt;:%s&lt;/code&gt; but I don't like them. It forces me to type out both the full variable name I'm searching for and what I'm changing it to. Maybe there is a better way fix the the amount of typing with &lt;code&gt;:%s&lt;/code&gt;? I often use long descriptive variable names, so that is really a deal breaker for me. I also don't like how typing out a variable name from scratch is typo prone and can consume time and brainpower hunting down typos. I much prefer typing it once, and then copying and pasting to just avoid this entirely if possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current workflow uses some combination of movement/yank/select/search/put to move around the file and replace one by one. It is not great but has the benefit of avoiding typing out full variable names. I might just need to type the first few letters with &lt;code&gt;/&lt;/code&gt; or use another movement command (e.g. &lt;code&gt;fx&lt;/code&gt;) depending on what's around and then hit &lt;code&gt;ve&lt;/code&gt; to select the whole word. I also don't mind that I have to repeat for every instance. I never do a full find replace without confirming each change. But it would be much preferable if I could repeat the replacement action with a single keystroke (which I can't do with this method). each replacement is usually something like &lt;code&gt;n&lt;/code&gt; then &lt;code&gt;ve&lt;/code&gt; then &lt;code&gt;p&lt;/code&gt; (or even worse &lt;code&gt;&quot;0p&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a faster way?&lt;/p&gt;&#xA;" OwnerUserId="14428" LastEditorUserId="24" LastEditDate="2017-09-28T20:33:05.173" LastActivityDate="2023-01-05T19:55:52.667" Title="How to find and replace in Vim without having to type the original word?" Tags="|search|substitute|" AnswerCount="12" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13690" PostTypeId="2" ParentId="13689" CreationDate="2017-09-25T20:26:00.883" Score="109" Body="&lt;p&gt;I actually have a pretty similar workflow to yours, (copying and pasting blocks that are similar, then using &lt;code&gt;:s&lt;/code&gt; to change variable names) especially when I'm writing lots of lines that are similar except for which variable they use. But there are a couple things I do that you might find useful.&lt;/p&gt;&#xA;&lt;h3&gt;General vim things&lt;/h3&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The first thing that will help you is realizing that &lt;code&gt;:s//foo/g&lt;/code&gt; will fill in whatever search term you used last and replace that with &lt;em&gt;foo&lt;/em&gt;. That alone can save a lot of time, but when you combine it with the asterisk command (search for the word under the current cursor) it saves tons of time. For example, to change all &lt;code&gt;foo&lt;/code&gt; to &lt;code&gt;spam&lt;/code&gt;, instead of doing&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%s/foo/spam/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Which requires you to type out both foo and spam (which may be long variables), you can simply navigate to foo, and do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    *:%s//spam/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This way, you can quickly get the name of the variable you're changing by searching for it, then you won't need to type it out. This will also work nicely with your current workflow of using &lt;code&gt;n&lt;/code&gt; a lot. It's also helpful to have &lt;code&gt;hlsearch&lt;/code&gt; on, because then you can visually tell where the variables you're replacing are.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;(side note: The asterisk command will add word boundaries, that is &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; around the word under the cursor. If you don't want this, use &lt;code&gt;g*&lt;/code&gt; instead.)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;it would be much preferable if I could repeat the replacement action with a single keystroke&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;You can use &lt;code&gt;@:&lt;/code&gt; to redo the last substitute command. That is nice if you want to do an &lt;code&gt;:s&lt;/code&gt; command on lots of lines, but not all of them so &lt;code&gt;:%s&lt;/code&gt; will not work. Another option is the confirmation flag, i.e. &lt;code&gt;:%s///gc&lt;/code&gt;. This will allow you to type &lt;code&gt;y&lt;/code&gt; or &lt;code&gt;n&lt;/code&gt; on each occurrence to decide if you want to replace it or not.&lt;/p&gt;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/13689/is-there-a-better-method-for-find-and-replace-in-vim#comment23486_13690&quot;&gt;Desty pointed out&lt;/a&gt;, you can also do &lt;kbd&gt;&amp;amp;&lt;/kbd&gt; to re-run the last substitute command, but note that this will &lt;em&gt;not&lt;/em&gt; keep your flags (such as &lt;code&gt;global&lt;/code&gt; or &lt;code&gt;confirm&lt;/code&gt;). Whether that is good or bad depends on your personal opinion. If you would like to use this but have it keep your flags also, you could do&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    nnoremap &amp;amp; :&amp;amp;&amp;amp;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;If you want to change every occurrence in a block, but not every match in the file, you could always use a visual selection of the block, which will fill in&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;to your substitute, which restricts it to the lines you have selected. When combined with the asterisk approach, I find this extremely useful. Additionally, if you are making multiple substitute commands on the same block of lines, you can use &lt;kbd&gt;gv&lt;/kbd&gt; to reselect the same lines to do another command. (whether it's a &lt;code&gt;:substitute&lt;/code&gt; or a normal command)&lt;/p&gt;&#xA;&lt;p&gt;If you do another substitute command, you do not &lt;em&gt;need&lt;/em&gt; to reselect the same lines, because &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt;  will still operate on the same lines. However, it is more convenient to type&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    gv:s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;rather than&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    :'&amp;lt;,'&amp;gt;s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Plugins/Mappings I like&lt;/h3&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I have the following mapping in my &lt;code&gt;.vimrc&lt;/code&gt; which extends the &lt;em&gt;asterisk approach&lt;/em&gt; so that I only have to type the new desired name:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;(R)eplace all&#xA;nnoremap &amp;lt;leader&amp;gt;r yiw:%s/\&amp;lt;&amp;lt;C-r&amp;gt;&amp;quot;\&amp;gt;//g&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;To use this, just put your cursor on the word you want to change, and type &lt;code&gt;&amp;lt;leader&amp;gt;rNewVarName&amp;lt;cr&amp;gt;&lt;/code&gt; and you're done. Note that this will replace all matches without giving you an option to confirm them, so you might not like it as much. Of course, to allow for the confirm option, you could just change it to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    nnoremap &amp;lt;leader&amp;gt;r yiw:%s/\&amp;lt;&amp;lt;C-r&amp;gt;&amp;quot;\&amp;gt;//gc&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;em&gt;edit&lt;/em&gt;: Following both &lt;a href=&quot;https://vi.stackexchange.com/a/13691/2920&quot;&gt;Mass's answer&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/13689/is-there-a-better-method-for-find-and-replace-in-vim#comment23484_13690&quot;&gt;rcorre's comment&lt;/a&gt;, you could also write this as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    nnoremap &amp;lt;leader&amp;gt;r :%s/\&amp;lt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;\&amp;gt;//g&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which has the advantage of keeping your unnamed (yank) register the same.&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;If you're renaming groups of similar variables at the same time, for example, changing&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fooSuffix&#xA;PrefixFoo&#xA;foo1&#xA;SHOUTINGFOO&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    barSuffix&#xA;    PrefixBar&#xA;    bar1&#xA;    SHOUTINGBAR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;it can be a pain to substitute all of them individually. This is where &lt;a href=&quot;https://github.com/tpope/tpope-vim-abolish&quot; rel=&quot;noreferrer&quot;&gt;tpope/vim-abolish&lt;/a&gt; comes in handy. You can replace all of these in one command with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    :%S/foo/bar/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and it takes care of the capitalization for you.&lt;/p&gt;&#xA;&lt;p&gt;These should help you a lot, but let me know if there's anything about these approaches you don't like or feel is lacking. I'm happy to talk about more approaches. :)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;em&gt;Recommended Reading:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:s_c&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h s_c&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#star&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h *&lt;/code&gt;&lt;/a&gt;/&lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%23&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h #&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#gstar&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h g*&lt;/code&gt;&lt;/a&gt;/&lt;a href=&quot;https://vimhelp.org/pattern.txt.html#g%23&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h g#&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html#@:&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h @:&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%3C&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h /\&amp;lt;&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#&amp;amp;&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h &amp;amp;&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="6498" LastEditDate="2023-01-05T19:55:52.667" LastActivityDate="2023-01-05T19:55:52.667" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="13691" PostTypeId="2" ParentId="13689" CreationDate="2017-09-25T20:29:20.270" Score="26" Body="&lt;p&gt;The &lt;code&gt;c_CTRL-R&lt;/code&gt; family of maps can improve your workflow quite a bit:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You need not type variable names when using &lt;code&gt;:s/&lt;/code&gt;, just use &lt;code&gt;CTRL-R&lt;/code&gt; &lt;code&gt;CTRL-W&lt;/code&gt; to insert the word under the cursor into the command line (caveat: this does not escape special characters, like &lt;code&gt;*&lt;/code&gt; does).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After making a small change using &lt;code&gt;ce&lt;/code&gt;, you can search for the old word using &lt;code&gt;/&lt;/code&gt; &lt;code&gt;CTRL-R&lt;/code&gt; &lt;code&gt;-&lt;/code&gt;.  Then use &lt;code&gt;.&lt;/code&gt; to repeat the change.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you need to make changes to the search pattern &lt;code&gt;CTRL-R&lt;/code&gt; &lt;code&gt;/&lt;/code&gt; will place the existing search into the command line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finally, you can put the contents of any register using &lt;code&gt;CTRL-R&lt;/code&gt; &lt;code&gt;{register}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-09-27T16:11:42.497" LastActivityDate="2017-09-27T16:11:42.497" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13692" PostTypeId="1" AcceptedAnswerId="13693" CreationDate="2017-09-26T03:45:00.707" Score="9" ViewCount="916" Body="&lt;p&gt;I have the following in my &lt;code&gt;vimrc&lt;/code&gt; to automatically reload a buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Triger `autoread` when files changes on disk&#xA;&quot; https://unix.stackexchange.com/a/383044/143394&#xA;autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * checktime&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is if I'm in command-line mode (ie, after typing &lt;code&gt;:&lt;/code&gt; in normal mode), and I change focus away from, the back to vim I get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing FocusGained Auto commands for &quot;*&quot;:&#xA;E523: Not allowed here: checktime&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How can I prevent this autocmd running if I'm in command-line mode at the time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a flag set when entering commandline mode? Perhaps an autocmd could set one?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="51" LastEditDate="2017-09-26T10:16:55.090" LastActivityDate="2020-08-30T14:14:56.200" Title="Prevent FocusGained autocmd running in command line editing mode" Tags="|command-line|autocmd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13693" PostTypeId="2" ParentId="13692" CreationDate="2017-09-26T10:17:58.460" Score="5" Body="&lt;p&gt;You can use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;mode()&lt;/code&gt; function allows you to test the current mode (see &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#mode%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h mode()&lt;/code&gt;&lt;/a&gt; for a list of the possible returned values), in command mode it will return &lt;code&gt;c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this command, you can add a check to disallow the execution of your autocommand when you are in command mode you should be fine.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-11-23T12:19:55.420" LastActivityDate="2017-11-23T12:19:55.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13694" PostTypeId="2" ParentId="13689" CreationDate="2017-09-26T15:11:02.837" Score="7" Body="&lt;p&gt;The plugin &lt;a href=&quot;https://github.com/terryma/vim-multiple-cursors&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/terryma/vim-multiple-cursors&lt;/a&gt; takes care of this problem for the most part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My workflow is usually as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Move the cursor to the word to replace.&lt;/li&gt;&#xA;&lt;li&gt;Hold &lt;code&gt;ctrl-n&lt;/code&gt; until everything is selected.&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;c&lt;/code&gt; and start typing the replacement.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The convenient thing here is that you can also do more complicated operations than just search-replace, although I find that if you take that too far, the plugin starts showing some glitches.&lt;/p&gt;&#xA;" OwnerUserId="2455" LastEditorUserId="2455" LastEditDate="2017-09-26T15:52:55.660" LastActivityDate="2017-09-26T15:52:55.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13695" PostTypeId="2" ParentId="13689" CreationDate="2017-09-26T17:31:13.577" Score="7" Body="&lt;p&gt;Another way to do things that hasn't been mentioned yet: You can use the command-line window (opened with &lt;code&gt;q:&lt;/code&gt; in normal mode — see &lt;code&gt;:help q:&lt;/code&gt; for more information), in which you have full access to Vim's autocompletion features (&lt;code&gt;i_CTRL-N&lt;/code&gt;/&lt;code&gt;i_CTRL-P&lt;/code&gt; and the various &lt;code&gt;i_CTRL-X&lt;/code&gt; sequences being among them).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the command-line window you can also use normal-mode commands to edit the command line, which, for example, means you can yank and paste parts of previous commands in your command-line history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that your cursor will be moved to the command-line window when using it, meaning that &lt;code&gt;CTRL-R CTRL-W&lt;/code&gt; and similar methods that involve inserting the text under the cursor won't work there, unlike in the regular command line.&lt;/p&gt;&#xA;" OwnerUserId="1153" LastActivityDate="2017-09-26T17:31:13.577" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13696" PostTypeId="2" ParentId="13689" CreationDate="2017-09-26T23:21:50.327" Score="2" Body="&lt;p&gt;The solution to this is somewhat in between the other answers for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you've got 6 identical lines, and you want to replace 'apple' in the middle two:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I have apples for days&#xA;I have apples for days&#xA;I have apples for days&#xA;I have apples for days&#xA;I have apples for days&#xA;I have apples for days&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I do is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I get to the start of the text I want to replace, 'apple'&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;code&gt;v&lt;/code&gt; to get into visual mode&lt;/li&gt;&#xA;&lt;li&gt;Go down to the last word I want to replace, in this case a few lines so &lt;code&gt;2j&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:s/&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;/&lt;/code&gt; which uses the visual selection as the range for &lt;code&gt;:s&lt;/code&gt;, and then inserts the word under the cursor&lt;/li&gt;&#xA;&lt;li&gt;I hit &lt;code&gt;&amp;lt;C-F&amp;gt;&lt;/code&gt; which puts you into a mode where you can edit your command as if it was a buffer. So you can use whatever completion or plugins you want to choose the replacement word, and you're done.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;All in one line, the flow for this would be &lt;code&gt;/apples&amp;lt;CR&amp;gt;2nv/apples&amp;lt;CR&amp;gt;nn:s/&amp;lt;C-R&amp;gt;&amp;lt;C-W/oranges&amp;lt;CR&amp;gt;&lt;/code&gt; but that looks worse than it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, you can append the &lt;code&gt;/c&lt;/code&gt; to the &lt;code&gt;:s&lt;/code&gt; command to skip the ones you don't want, if your range contains a few you want to skip: &lt;code&gt;:s/&amp;lt;C-R&amp;gt;&amp;lt;C-W/orange/c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively (and perhaps more simply), you could search for the entire word you want to replace, &lt;code&gt;c&lt;/code&gt;hange it, then &lt;code&gt;gn&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt; to repeat the search and apply the same change again. It would look like &lt;code&gt;/\&amp;lt;apple\&amp;gt;&amp;lt;CR&amp;gt;viwcorange&amp;lt;ESC&amp;gt;gn.gn.gn..ngn.&lt;/code&gt; to repeat it on three, then skip an instance, then repeat it one last time.&lt;/p&gt;&#xA;" OwnerUserId="488" LastActivityDate="2017-09-26T23:21:50.327" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13697" PostTypeId="1" AcceptedAnswerId="13699" CreationDate="2017-09-27T01:42:11.427" Score="3" ViewCount="80" Body="&lt;p&gt;I have two commands for somewhat emulating the Emacs command &lt;code&gt;narrow-to-defun&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two commands that move to the top/bottom of the current paragraph &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gt mp{zfgg`p&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gb mp}zfG`p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this works really well for languages where people don't tend to leave blank lines in the middle of function bodies or other &quot;interesting&quot; pieces of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have some projects where I use &gt;=2 blank lines to separate units of code and liberally use single blank lines inside function bodies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an easy way to move by &quot;big paragraphs&quot;, skipping over singleton blank lines?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance a lot of python code looks like, with occasional blank lines within function bodies and two blank lines separating them. Other things that are similar to top-level function definitions, like classes, are spaced accordingly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def some_function(a, b, c):&#xA;    # do stuff&#xA;&#xA;&#xA;def some_other_function(a, c):&#xA;    # do stuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2017-09-27T04:54:51.397" LastActivityDate="2017-09-27T09:32:34.087" Title="How to move to top/bottom of region delimited by consecutive blank lines" Tags="|cursor-motions|navigation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13699" PostTypeId="2" ParentId="13697" CreationDate="2017-09-27T09:32:34.087" Score="4" Body="&lt;p&gt;You can use the regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gt ?^\n\{2,}&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gb /^\n\{2,}&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Find more with &lt;code&gt;:help regex&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9486" LastActivityDate="2017-09-27T09:32:34.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13700" PostTypeId="2" ParentId="13689" CreationDate="2017-09-27T11:28:47.207" Score="2" Body="&lt;p&gt;This is not entirely related to the question, but still should help to select the word to replace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incremental search (&lt;code&gt;set incsearch&lt;/code&gt;) allows you to type the prefix of the word you need to find, and vim will automatically jump to the first occurrence of the prefix as you type more and more. The search will be confirmed if you press Enter and discarded on Esc (in the latter case the cursor will jump back to where it was before the search started).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, incremental search provides one more useful feature. When you've already typed the prefix of a word and the cursor is at the correct position, press &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; to add characters from the word under the cursor  to the search string. This allows you to enter the replaced string with almost no keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if I want to replace &lt;code&gt;someOddVariableName&lt;/code&gt; with &lt;code&gt;evenOdderVariableName&lt;/code&gt;, I&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;type &lt;code&gt;/someOddV&lt;/code&gt; and arrive at the occurrence of &lt;code&gt;someOddVariableName&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;press and hold &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; until &lt;code&gt;someOddVariableName&lt;/code&gt; appears in the search line completely;&lt;/li&gt;&#xA;&lt;li&gt;press Enter to confirm search;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s//evenOdderVariableName/g&lt;/code&gt; or whichever replace command you need; you may wish to follow other answers here.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13548" LastActivityDate="2017-09-27T11:28:47.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13701" PostTypeId="2" ParentId="13689" CreationDate="2017-09-27T15:27:43.237" Score="16" Body="&lt;p&gt;There are a couple more methods that (to my surprise!) haven't been mentioned yet.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Using the &lt;code&gt;gn&lt;/code&gt; Command&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt; works like the &lt;kbd&gt;n&lt;/kbd&gt; command, except that in addition to jumping to the match, it enters visual mode, with the entire match selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to change a word (or anything you can match with a regular expression!) first search for it&lt;sup&gt;1&lt;/sup&gt;, and then press &lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt; followed by the text you want to replace the match with and &lt;kbd&gt;Esc&lt;/kbd&gt; to return to normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(You mention that sometimes the replacement text you want to use is stored in the &lt;code&gt;&quot;0&lt;/code&gt; yank register&amp;#8202;&amp;mdash;&amp;#8202;note that you can quickly enter this without having to retype it by pressing &lt;kbd&gt;Ctrl+R&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt; in insert mode.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then jump to the next match &lt;em&gt;and&lt;/em&gt; repeat the change with a single &lt;kbd&gt;.&lt;/kbd&gt; keystroke!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there are any places where you &lt;em&gt;don't&lt;/em&gt; want to make the replacement, simply press &lt;kbd&gt;u&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt; to undo the change and jump to the next match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1: Speedily, by using the other suggestions on this page such as &lt;kbd&gt;*&lt;/kbd&gt;, &lt;kbd&gt;Ctrl+R&lt;/kbd&gt;&lt;kbd&gt;Ctrl+W&lt;/kbd&gt;, etc. See also &lt;a href=&quot;https://vi.stackexchange.com/questions/13689/is-there-a-better-method-for-find-and-replace-in-vim/13701#comment23501_13701&quot;&gt;Peter Rincker's comment&lt;/a&gt; for more suggestions about how to initially populate your search.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Using Select Mode&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;(I learned this from &lt;a href=&quot;https://vi.stackexchange.com/users/54/romainl&quot;&gt;romainl&lt;/a&gt;'s &lt;a href=&quot;https://www.reddit.com/r/vim/comments/5u99rh/select_mode/ddshdj4/&quot; rel=&quot;noreferrer&quot;&gt;post on the vim subreddit&lt;/a&gt;. I don't know whether he invented it himself or was just passing it on.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Select mode is a bit like visual mode, except if you start typing the selected text is immediately replaced with what you type (like how selection works in most other editors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can thus use this trio of mappings to do a very quick find/replace, which you can change mid file, if necessary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap § *``gn&amp;lt;C-g&amp;gt;&#xA;inoremap § &amp;lt;C-o&amp;gt;gn&amp;lt;C-g&amp;gt;&#xA;snoremap &amp;lt;expr&amp;gt; . @.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Normal mode mapping&lt;/strong&gt;: Enters select mode with the word nearest the cursor selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then type your replacement for the selected word and (&lt;em&gt;without&lt;/em&gt; pressing &lt;kbd&gt;Esc&lt;/kbd&gt;) use the:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Insert mode mapping&lt;/strong&gt;: Jumps to the next match and enters selection mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then either type a new replacement or press &lt;kbd&gt;.&lt;/kbd&gt; to use the:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Select mode mapping&lt;/strong&gt;: Re-enters the last-inserted text — essentially, repeats the last insertion.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-09-28T08:40:52.157" LastActivityDate="2017-09-28T08:40:52.157" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13702" PostTypeId="2" ParentId="13689" CreationDate="2017-09-27T18:45:04.267" Score="2" Body="&lt;p&gt;If you want to replace a variable within the new (pasted) block, I have two suggestions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Automated replace&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to the first line of the new block, hit &lt;code&gt;ma&lt;/code&gt;.  This is marking a location and naming it &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to the last line of the new block, hit &lt;code&gt;mb&lt;/code&gt;.  Now you have two named locations.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now replace &lt;em&gt;between&lt;/em&gt; the two lines, like so:  &lt;code&gt;:'a,'bs/oldVarName/newVarName/g&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;That is, the scope of the replace is between your two marks.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The manual way&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to the first line of the new block.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;/oldVarName&lt;/code&gt; to find the first instance of &lt;code&gt;oldVarName&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Change it like so:  &lt;code&gt;cwnewVarName&amp;lt;Esc&amp;gt;&lt;/code&gt;, which will change word to &lt;code&gt;newVarName&lt;/code&gt; and hitting escape.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;n&lt;/code&gt; to go to next instance of &lt;code&gt;oldVarName&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;.&lt;/code&gt; to repeat the last change (i.e. repeats that &lt;code&gt;cw&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14465" LastEditorUserId="51" LastEditDate="2017-09-29T07:24:42.853" LastActivityDate="2017-09-29T07:24:42.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13708" PostTypeId="2" ParentId="6254" CreationDate="2017-09-28T07:59:45.227" Score="5" Body="&lt;ul&gt;&#xA;&lt;li&gt;Set cursor on&#xA;&lt;code&gt;./&lt;/code&gt; (or directory in which you want to copy)&#xA;, press &lt;code&gt;mt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Set cursor on file you want copy, press &lt;code&gt;mf&lt;/code&gt;, then &lt;code&gt;mc&lt;/code&gt;, type a name of new file, &lt;code&gt;enter&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14481" LastActivityDate="2017-09-28T07:59:45.227" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13709" PostTypeId="1" CreationDate="2017-09-28T12:53:06.967" Score="2" ViewCount="1757" Body="&lt;p&gt;(NB: I've moved this question from another SE site, let me know if thats not ok and I can take this down)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm having issues remapping &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt; to copy visually selected text to the &lt;code&gt;+&lt;/code&gt; register. At the moment I have the following in my &lt;code&gt;.vimrc&lt;/code&gt;   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;C-C&amp;gt; &quot;+y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried remapping a few other things to similar key bindings to see if it was my implementation or the specific combination of keys that was the issue and it is definitely the key combination (eg &lt;code&gt;vnoremap &amp;lt;C-I&amp;gt; &quot;+y&lt;/code&gt; worked and &lt;code&gt;vnoremap &amp;lt;C-C&amp;gt; d&lt;/code&gt; didn't).   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas why it doesn't work and how I could possibly remap it?&lt;br&gt;&#xA;Cheers&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the first post of this q I was directed towards a previous &lt;a href=&quot;https://stackoverflow.com/questions/13072701/why-doesnt-this-vimrc-mapping-work-in-terminal-but-it-does-in-macvim-map-s/13073067#13073067&quot;&gt;answer&lt;/a&gt; that may possibly relate to my issue. From what I read there is a possibility of both  and  doing the same thing. I didn't experience this when I tested it 5 minutes ago so any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OS Ubuntu 16.04&lt;br&gt;&#xA;Vim version 7.4&lt;br&gt;&#xA;see &lt;a href=&quot;https://pastebin.com/G9Uj4eia&quot; rel=&quot;nofollow noreferrer&quot;&gt;pastebin&lt;/a&gt; for full output of &lt;code&gt;$ vim --version&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14380" LastActivityDate="2017-09-28T13:23:58.073" Title="Can't remap &lt;C-C&gt; in vim" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13710" PostTypeId="2" ParentId="13709" CreationDate="2017-09-28T13:23:58.073" Score="1" Body="&lt;p&gt;Instead of writting &lt;code&gt;&amp;lt;c-c&amp;gt;&lt;/code&gt; use the key combination &lt;kbd&gt;Ctrl+v&lt;/kbd&gt;&lt;kbd&gt;ctrl+shift+c&lt;/kbd&gt; to insert the key code in your command. On my setup it gives this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;83&amp;gt; &quot;+y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See my answer &lt;a href=&quot;https://vi.stackexchange.com/q/7722/1841&quot;&gt;here&lt;/a&gt; for more details about how to debug a mapping.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-09-28T13:23:58.073" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13712" PostTypeId="1" AcceptedAnswerId="13714" CreationDate="2017-09-28T16:30:35.310" Score="2" ViewCount="590" Body="&lt;p&gt;Is it possible to suppress messages in vim that are coming from the system or shell? E.g. message from sysadmin or batch queue messages when jobs complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note that I want to specify this at the vim command line or in .vimrc, NOT at the shell or system level.&lt;/strong&gt; I am using an obscure operating system (OpenVMS) so answers specific to Windows, Linux, or MacOS will unfortunately not be helpful to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rationale, if it matters: I'll often have a large number of batch jobs complete which writes over my text in vim and I have to repeatedly hit &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;L&lt;/kbd&gt; to refresh the screen. I don't want to turn off the messages at the system or shell level because I want to see them. I just don't want them messing up my text in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a different editor the system messages would display at the bottom of the window without screwing up the text so if anyone knows how to make vim do that, I would also consider accepting that as an answer.&lt;/p&gt;&#xA;" OwnerUserId="14492" LastEditorUserId="4472" LastEditDate="2017-09-29T01:36:39.493" LastActivityDate="2017-09-29T02:45:55.040" Title="Suppress system broadcasts/messages" Tags="|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13714" PostTypeId="2" ParentId="13712" CreationDate="2017-09-28T22:04:30.847" Score="1" Body="&lt;p&gt;This is what worked for me based on the comments of @Carpetsmoker and @Mass (thanks to both!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added these lines to &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * silent ! set broadcast=none&#xA;autocmd VimLeave * silent ! set broadcast=all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This simply turns messages off when you start vim, and then turns them back on when you exit vim.  &lt;code&gt;set broadcast=xxx&lt;/code&gt; is specific to OpenVMS but I imagine this would work for linux/windows/mac if you substituted the appropriate command.&lt;/p&gt;&#xA;" OwnerUserId="14492" LastEditorUserId="14492" LastEditDate="2017-09-29T02:45:55.040" LastActivityDate="2017-09-29T02:45:55.040" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13715" PostTypeId="2" ParentId="13689" CreationDate="2017-09-29T06:21:48.840" Score="2" Body="&lt;p&gt;You can put the variable name in buffer first (&lt;code&gt;yw&lt;/code&gt; to copy a word), then copy-paste it to &lt;code&gt;:%s&lt;/code&gt; by hitting &lt;code&gt;&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14502" LastEditorUserId="51" LastEditDate="2017-09-29T07:23:13.090" LastActivityDate="2017-09-29T07:23:13.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13718" PostTypeId="1" AcceptedAnswerId="13719" CreationDate="2017-09-29T12:17:59.823" Score="4" ViewCount="6537" Body="&lt;p&gt;I use Vundle to manage my vim plugins. However I just came across &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf&lt;/a&gt;, and its installation instructions require that I use vim-plug. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I make this happen? Wouldn't there be a conflict between vundle and vim-plug?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I tried installing it using vundle by putting the following in my &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call vundle#begin()&#xA;..&#xA;Plugin 'junegunn/fzf.vim'        &#xA;call vundle#end()            &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this seems to have worked fine.. but then when I run vim and type &lt;code&gt;Files&lt;/code&gt; I get this error in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function fzf#vim#files[15]..&amp;lt;SNR&amp;gt;47_fzf[18]..&amp;lt;SNR&amp;gt;47_wrap:&#xA;line   12:&#xA;E117: Unknown function: fzf#wrap&#xA;E15: Invalid expression: fzf#wrap(a:name, opts, a:bang)&#xA;line   14:&#xA;E121: Undefined variable: wrapped&#xA;E15: Invalid expression: wrapped&#xA;Error detected while processing function fzf#vim#files[15]..&amp;lt;SNR&amp;gt;47_fzf:&#xA;line   18:&#xA;E117: Unknown function: fzf#run&#xA;E15: Invalid expression: fzf#run(s:wrap(a:name, merged, bang))&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what do I do?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;update 2&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I installed fzf using brew:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ which fzf&#xA;/usr/local/bin/fzf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but same bug appears.. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;back to the original question: can vundle and vim-plug co-exist?&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="14510" LastEditDate="2017-09-29T12:46:00.063" LastActivityDate="2017-09-29T13:19:48.213" Title="How to install fzf.vim with Vundle?" Tags="|plugin-vundle|plugin-vim-plug|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13719" PostTypeId="2" ParentId="13718" CreationDate="2017-09-29T13:19:48.213" Score="11" Body="&lt;p&gt;You've installed the &lt;strong&gt;fzf.vim&lt;/strong&gt; wrapper plugin, but you haven't installed the base &lt;strong&gt;fzf&lt;/strong&gt; plugin, which provides the underlying functionality, including the autoload functions that the error messages are flagging as &quot;Unknown&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'junegunn/fzf'&#xA;Plugin 'junegunn/fzf.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-09-29T13:19:48.213" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13720" PostTypeId="1" CreationDate="2017-09-29T15:51:45.007" Score="1" ViewCount="219" Body="&lt;p&gt;When I use auto indent in vim, it almost working correctly, but in C++ 's &lt;strong&gt;enum&lt;/strong&gt;, it have some problem like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PNFM5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PNFM5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uselY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uselY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My indent settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set expandtab       &#xA;set tabstop=4       &#xA;set smartindent     &#xA;set autoindent      &#xA;set shiftwidth=2    &#xA;set softtabstop=4   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14514" LastActivityDate="2017-09-29T15:51:45.007" Title="Vim enum indent for C++" Tags="|indentation|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13721" PostTypeId="1" CreationDate="2017-09-29T16:13:41.977" Score="1" ViewCount="106" Body="&lt;p&gt;I installed vim-LaTeX suite and now some of my mappings don't work anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those are my mappings, the last 2 don't work when LaTeX suite is installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType tex inoremap è \`e&#xA;autocmd FileType tex inoremap é \e`&#xA;autocmd FileType tex inoremap ù \`u&#xA;autocmd FileType tex inoremap ò \`o&#xA;autocmd FileType tex inoremap ì \`i&#xA;autocmd FileType tex inoremap à \`a&#xA;&#xA;autocmd FileType tex inoremap ` '&#xA;autocmd FileType tex inoremap ' `&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Those last 2 don't work&lt;/p&gt;&#xA;" OwnerUserId="14299" LastEditorUserId="205" LastEditDate="2018-01-28T05:34:05.973" LastActivityDate="2018-01-28T05:34:05.973" Title="How fix mappings broken by a plugin?" Tags="|key-bindings|plugin-vim-latex|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13723" PostTypeId="1" CreationDate="2017-09-29T16:59:56.750" Score="1" ViewCount="201" Body="&lt;p&gt;I'm doing a lot of repetitive copying.    Starting out with lines like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;first line&#xA;second line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want create a single mapping that produces&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;first line&#xA;second line&#xA;\notes{&#xA;first line&#xA;second line&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can do this with two separate macros:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map  ;aN 'bA^M\notes{^M}&amp;lt;ESC&amp;gt;&#xA;map  ;cp :'a,'bco'b+1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I combine them in what seems like the correct way, i.e.,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map  ;both 'bA^M\notes{^M}&amp;lt;ESC&amp;gt; &amp;lt;bar&amp;gt; :'a,'bco'b+1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result is the as when I type &lt;code&gt;;aN&lt;/code&gt; i.e., the second part of the mapping isn't implemented.    Could somebody explain please what I'm doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="4667" LastActivityDate="2017-10-29T18:12:57.063" Title="combining two map commands" Tags="|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13724" PostTypeId="2" ParentId="13721" CreationDate="2017-09-29T17:14:17.007" Score="1" Body="&lt;p&gt;In this case, read &lt;a href=&quot;http://vim-latex.sourceforge.net/faq.shtml#faq-euro-symbols&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-latex FAQ&lt;/a&gt;. The problem is old, and there is a solution, that enables to map &lt;code&gt;&amp;lt;m-i&amp;gt;&lt;/code&gt; (which vim confounds with &lt;code&gt;é&lt;/code&gt;) to any thing else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: your mappings should be &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; local. You don't want them triggered in commit messages for instance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I've been using accentuated characters in my French LaTeX documents for quite some time now. We don't really need to obfuscate our documents any more.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-09-29T17:14:17.007" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13725" PostTypeId="1" AcceptedAnswerId="13728" CreationDate="2017-09-29T17:20:51.513" Score="3" ViewCount="213" Body="&lt;p&gt;I am editing text of the form&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;first line&#xA;second line&#xA;\note{&#xA;first line&#xA;second line&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to leave intact the text that's delimited by curly brackets&#xA;and edit the text that's not delimited.    But I keep making mistakes and&#xA;editing the delimited text and leaving intact the text I meant to edit.   A way to fix this would be to some how color everything that's contained in &lt;code&gt;\note{  }&lt;/code&gt;     Is there a way to do something like this?&lt;/p&gt;&#xA;" OwnerUserId="4667" LastActivityDate="2017-10-02T13:31:51.803" Title="Changing the color of delimited text" Tags="|delimiter-matching|color|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13726" PostTypeId="2" ParentId="13723" CreationDate="2017-09-29T17:30:44.280" Score="2" Body="&lt;p&gt;You do not use &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; to combine mappings. You simply combine them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map  ;both 'bA^M\notes{^M}&amp;lt;ESC&amp;gt;:'a,'bco'b+1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some thoughts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As a general rule you should use &lt;code&gt;noremap&lt;/code&gt; variants for you mappings.&lt;/li&gt;&#xA;&lt;li&gt;It is best to supply a mode. e.g. &lt;code&gt;nnoremap&lt;/code&gt; for normal mode.&lt;/li&gt;&#xA;&lt;li&gt;Use keycode notation for readability. &lt;code&gt;^M&lt;/code&gt; would become &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;These feel like tex only mappings so maybe use a buffer local mapping. See &lt;code&gt;:h :map-local&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Next I think it would be good to look into text/latex plugins which may provide some helpful mappings. Or at the very least use something like &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;surround.vim&lt;/a&gt; to make surrounding easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would probably use a visual mode mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap Sn :copy '&amp;gt;&amp;lt;cr&amp;gt;']o}&amp;lt;esc&amp;gt;'&amp;gt;o\notes{&amp;lt;esc&amp;gt;^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-09-29T17:30:44.280" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13727" PostTypeId="2" ParentId="13721" CreationDate="2017-09-29T17:50:20.413" Score="1" Body="&lt;p&gt;I figured it out, I added a tex.vim file in the ~/../vim-latex/ftplugin directory, the text of the file is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call IMAP(&quot;'&quot;,'`','tex')&#xA;call IMAP('`',&quot;'&quot;,'tex')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where the quotes around ' are necessary since it's a special character&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: now every 3 ' I get ``' someone knwos why?&lt;/p&gt;&#xA;" OwnerUserId="14299" LastEditorUserId="14299" LastEditDate="2017-09-29T17:57:37.623" LastActivityDate="2017-09-29T17:57:37.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13728" PostTypeId="2" ParentId="13725" CreationDate="2017-09-29T17:50:45.930" Score="5" Body="&lt;p&gt;This is not too complicated. Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match delimited /\\note{\_.\{-}}/ containedin=ALL&#xA;hi delimited guifg=red ctermfg=red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, you can change &lt;em&gt;red&lt;/em&gt; to whatever color you want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this does what you asked for, but it might also do much more than what you asked for because you didn't provide a lot of detail about what &lt;em&gt;exactly&lt;/em&gt; you want to highlight. For example, look at how this is highlighted:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KwGlA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KwGlA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this what you want? Will you have to handle nested brackets? What about when &lt;code&gt;\note&lt;/code&gt; doesn't come at the beginning of the line? What about when the closing &lt;code&gt;}&lt;/code&gt; isn't by itself?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can refine this regex to do exactly what you want. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^\\note{\_.\{-}}$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will only match if the line starts with &lt;code&gt;\note&lt;/code&gt; and then the later line &lt;em&gt;ends&lt;/em&gt; with &lt;code&gt;}&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="4667" LastEditDate="2017-10-02T13:31:51.803" LastActivityDate="2017-10-02T13:31:51.803" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13729" PostTypeId="1" AcceptedAnswerId="13730" CreationDate="2017-09-29T19:59:25.163" Score="1" ViewCount="236" Body="&lt;p&gt;I would classify my mathematics pdf collection in folders named by the &lt;a href=&quot;https://cran.r-project.org/web/classifications/MSC-2010.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;MSC 2010 Classification&lt;/a&gt; (just the 2 top-level). My approach is creating a file which will contain all path and uses &lt;code&gt;mkdir&lt;/code&gt; in a shell loop. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I clean the data then my file has the following content :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00-XX_General&#xA;    00Axx_General_and_miscellaneous_specific_topics&#xA;    00Bxx_Conference_proceedings_and_collections_of_papers&#xA;01-XX_History_and_biography&#xA;    01Axx_History_of_mathematics_and_mathematicians&#xA;03-XX_Mathematical_logic_and_foundations&#xA;    03Axx_Philosophical_aspects_of_logic_and_foundations&#xA;    03Bxx_General_logic&#xA;...    ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How could I transform it to  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00-XX_General&#xA;00-XX_General/00Axx_General_and_miscellaneous_specific_topics&#xA;00-XX_General/00Bxx_Conference_proceedings_and_collections_of_papers&#xA;01-XX_History_and_biography&#xA;01-XX_History_and_biography/01Axx_History_of_mathematics_and_mathematicians&#xA;03-XX_Mathematical_logic_and_foundations&#xA;03-XX_Mathematical_logic_and_foundations/03Axx_Philosophical_aspects_of_logic_and_foundations&#xA;03-XX_Mathematical_logic_and_foundations/03Bxx_General_logic&#xA;...    ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in vim via command-line mode?&lt;/p&gt;&#xA;" OwnerUserId="11430" LastActivityDate="2017-09-30T01:57:31.057" Title="Contextual text processing" Tags="|command-line|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13730" PostTypeId="2" ParentId="13729" CreationDate="2017-09-29T20:31:18.077" Score="2" Body="&lt;p&gt;This can be accomplished using only &lt;code&gt;:substitute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/^\([^ /]\+\).*\n\zs\s\+/\1\/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a breakdown and some intuition on how I created this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s/&lt;/code&gt; substitute on all lines. &lt;em&gt;subtlety&lt;/em&gt;: this relies on vim processing the substitutes in order, so the initial part of the previous line continues to get captured.  I first created this without &lt;code&gt;%&lt;/code&gt; and ensure it worked for one line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^\([^ /]\+\).*\n&lt;/code&gt; match anything at the beginning of the line which is not space or &lt;code&gt;/&lt;/code&gt;, capturing the characters, anything but newline, then finally a newline.  The key here is you can have matches which wrap to the following lines.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs&lt;/code&gt; starting match (i.e., replacement) here.  What comes after this will be what we actually want to replace.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s\+/\1\/&lt;/code&gt; any number (at least 1) of spaces, replacing this with what we captured (stored in &lt;code&gt;\1&lt;/code&gt;) followed by a &lt;code&gt;/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This can be made a bit shorter by using &lt;code&gt;\v&lt;/code&gt; (very magic) and also by changing &lt;code&gt;/&lt;/code&gt; to &lt;code&gt;,&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s,\v^([^ /]+).*\n\zs\s+,\1/&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-09-30T01:57:31.057" LastActivityDate="2017-09-30T01:57:31.057" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13731" PostTypeId="2" ParentId="13729" CreationDate="2017-09-29T20:33:24.923" Score="2" Body="&lt;p&gt;I'm not sure this is exactly what you want but you could try this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sil exe 'g/^\s\+/s:^\s\+:/:|?^\S?t.-|j!|s/^/ /' | %s/^\s/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Broken down:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;               ┌ every time you find a line beginning with a sequence of whitespace&#xA;           ┌───┤&#xA;           │   │          ┌ put a slash at the end of it&#xA;           │   │ ┌────────┤&#xA;           │   │ │        │        ┌ then find the previous line which doesn't begin with a whitespace&#xA;           │   │ │        │ ┌──────┤ and duplicate it above&#xA;           │   │ │        │ │      │&#xA;sil exe 'g/^\s\+/s:^\s\+:/:|?^\S?t.-|j!|s/^/ /' | %s/^\s/&#xA;                                     ││ │    │    └─────┤&#xA;                                     ││ │    │          └ remove a space at the beginning of any line&#xA;                                     ││ └────┤&#xA;                                     ││      └ add a space in front of the line&#xA;                                     └┤&#xA;                                      └ join it with the next line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/13729/contextual-text-processing#comment23561_13731&quot;&gt;Peter Rincker&lt;/a&gt; has a much shorter solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v/^[^ /]\+$/??t-|norm! Js/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's how it works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[^ /]\+$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This pattern describes a line which doesn't contain any space nor slash (see &lt;code&gt;:h /^&lt;/code&gt;, &lt;code&gt;:h /$&lt;/code&gt;, &lt;code&gt;:h /[]&lt;/code&gt;, &lt;code&gt;:h /\+&lt;/code&gt;). If you could replace this pattern with the name &lt;code&gt;pat&lt;/code&gt;, then you could rewrite the previous command like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v/pat/??t-|norm! Js/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This global command tries to find all the lines for which &lt;code&gt;pat&lt;/code&gt; is NOT a valid description. See &lt;code&gt;:h :v&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your example, the following line satisfies this condition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00Axx_General_and_miscellaneous_specific_topics&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For this line, and any other line satisfying the same condition, &lt;code&gt;:v&lt;/code&gt; executes this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;??t-|norm! Js/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The bar is a separation between 2 commands, which are executed consecutively:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;??t-&#xA;norm! Js/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To understand the 1st command, you must know that all Ex commands may be prefixed by a range, which limits their effect to a certain area of the buffer.&#xA;Here the Ex command is &lt;code&gt;:t&lt;/code&gt;, and &lt;code&gt;??&lt;/code&gt; is the range. &lt;code&gt;-&lt;/code&gt; is just an argument passed to &lt;code&gt;:t&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:t&lt;/code&gt; copies/duplicates a line or a group of lines below another arbitrary line.&#xA;Here, it copies the line specified by &lt;code&gt;??&lt;/code&gt;. This line specifier is described in &lt;code&gt;:h range&lt;/code&gt;: it matches the previous line containing the last search pattern. In your case, the last search pattern is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[^ /]\+$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;??t-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… is the same as this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?^[^ /]\+$?t-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it means: &lt;em&gt;find the previous line which does NOT contain a space or a slash and copy it below the line just above me&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why &lt;em&gt;just above me&lt;/em&gt;?&#xA;Because &lt;code&gt;-&lt;/code&gt; is another kind of line specifier. It's a shorthand for &lt;code&gt;.-1&lt;/code&gt;, which stands for the line whose address is equal to the one of the current line (&lt;code&gt;.&lt;/code&gt;) minus &lt;code&gt;1&lt;/code&gt; (&lt;code&gt;-1&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;-1&lt;/code&gt; is a numerical offset. And any numerical offset may be used to tweak a valid line specifier. You can express a numerical offset with a sign (&lt;code&gt;-&lt;/code&gt; or &lt;code&gt;+&lt;/code&gt;) followed by a number, or by piling up &lt;code&gt;-&lt;/code&gt; / &lt;code&gt;+&lt;/code&gt; signs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-3    ⇔    ---&#xA;+4    ⇔    ++++&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a line specifier, you can also omit the dot, so all of these expressions are equivalent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.-1    ⇔    .-    ⇔    -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in the same way, all of these expressions should be equivalent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.+3    ⇔    .+++    ⇔    +++&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, going back to the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00Axx_General_and_miscellaneous_specific_topics&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;:v&lt;/code&gt; finds it, it executes &lt;code&gt;??t-&lt;/code&gt;. Then &lt;code&gt;:t&lt;/code&gt; searches for the previous line which doesn't contain any space nor slash. And &lt;code&gt;:t&lt;/code&gt; finds this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00-XX_General&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally &lt;code&gt;:t&lt;/code&gt; copies the line just above the current one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00Axx_General_and_miscellaneous_specific_topics&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which performs the following transformation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00-XX_General                                           00-XX_General&#xA;    00Axx_General_and_miscellaneous_specific_topics  →  00-XX_General&#xA;                                                        00Axx_General_and_miscellaneous_specific_topics&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should explain the 1st command, executed by &lt;code&gt;:v&lt;/code&gt; every time it finds a line which doesn't contain a space nor a slash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, for the 2nd command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;norm! Js/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should type the 3 keys &lt;code&gt;Js/&lt;/code&gt; in normal mode. &lt;code&gt;J&lt;/code&gt; will join the line which has just been duplicated and the current line, performing this transformation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00-XX_General                                       00-XX_General&#xA;00-XX_General                                    →  00-XX_General 00Axx_General_and_miscellaneous_specific_topics&#xA;00Axx_General_and_miscellaneous_specific_topics    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, &lt;code&gt;s/&lt;/code&gt; will delete the character under the cursor and insert a slash.&#xA;As a result, it will replace the space right after &lt;code&gt;General&lt;/code&gt; with a slash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the whole command will probably not work as expected if one of your lines contains a slash.&#xA;Also, the bang after &lt;code&gt;:normal&lt;/code&gt; is important. Unless you really want the keys to be remapped, always add a bang.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you use &lt;a href=&quot;https://github.com/justinmk/vim-sneak&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sneak&lt;/a&gt;, your &lt;code&gt;s&lt;/code&gt; key will probably be remapped to do something entirely different than what it does by default. Usually, you don't want a plugin or a custom mapping to interfere, so it's a good habit to always add a bang after &lt;code&gt;:normal&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-09-30T01:48:24.857" LastActivityDate="2017-09-30T01:48:24.857" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13732" PostTypeId="1" AcceptedAnswerId="13734" CreationDate="2017-09-29T22:10:00.363" Score="4" ViewCount="1741" Body="&lt;p&gt;Where can I find, e.g., what &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c&lt;/code&gt; (in &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;) mean?&#xA;Like, OK, I can encounter them with the meaning along, but I just want to look up it in some list of all the keys.&#xA;So, is there a list with the meanings of these denotations and a brief explanation of the syntax? &lt;/p&gt;&#xA;" OwnerUserId="14520" LastEditorUserId="14520" LastEditDate="2017-09-29T22:29:40.920" LastActivityDate="2017-09-29T22:36:04.767" Title="What are the names of the keys for mapping?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13733" PostTypeId="2" ParentId="4728" CreationDate="2017-09-29T22:33:40.370" Score="2" Body="&lt;p&gt;Recording keystrokes to macro @a is the same thing as yanking the text corresponding to those keystrokes to register a. Once something is stored in a register, you can either put it or play it as a macro/keystrokes. So you could start recording a macro to @a via &lt;code&gt;qa&lt;/code&gt;, then while the macro is recording, yank some text to register b, perhaps using something like &lt;code&gt;&quot;bye&lt;/code&gt;. All that does is yank text into a different register than it would if you did not specify register b. Now that register b has some text in it, you can play back that text as keystokes by pressing &lt;code&gt;@b&lt;/code&gt;. You can even do that while macro @a is still being recorded. It's metamacrolicious!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main disadvantage of this is it would probably be easier to write some vimscript function that does what you want, and then perhaps call it during a macro recording. The beauty of macros is that you can see the effect of what you are recording while you record it, but this meta macro recording technique takes that away somewhat.&lt;/p&gt;&#xA;" OwnerUserId="1410" LastEditorUserId="1410" LastEditDate="2017-09-29T22:40:55.627" LastActivityDate="2017-09-29T22:40:55.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13734" PostTypeId="2" ParentId="13732" CreationDate="2017-09-29T22:36:04.767" Score="5" Body="&lt;p&gt;These are &quot;keycode&quot; notation. See &lt;code&gt;:h keycodes&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get the help of a command using &lt;code&gt;:h CTRL-O&lt;/code&gt; for &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;. Or you can use &lt;code&gt;:h &amp;lt;c-v&amp;gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; (where you actually press those keys).&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-09-29T22:36:04.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13735" PostTypeId="1" AcceptedAnswerId="13736" CreationDate="2017-09-29T22:49:11.480" Score="1" ViewCount="426" Body="&lt;p&gt;I tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-m&amp;gt;&amp;lt;c-m&amp;gt; &amp;lt;c-w&amp;gt;vs  ene&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-m&amp;gt;&amp;lt;c-m&amp;gt; &amp;lt;c-w&amp;gt;vs&amp;lt;space&amp;gt;ene&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I don't get a new file, I get the same file in a new buffer.&lt;/p&gt;&#xA;" OwnerUserId="14521" LastActivityDate="2017-09-29T23:15:58.053" Title="how can I make keymap to open a new file in a vertical split?" Tags="|vimrc|vim-windows|" AnswerCount="1" CommentCount="1" ClosedDate="2017-09-30T20:02:33.567" ContentLicense="CC BY-SA 3.0" />
  <row Id="13736" PostTypeId="2" ParentId="13735" CreationDate="2017-09-29T23:07:38.043" Score="2" Body="&lt;p&gt;The command you are looking for is &lt;code&gt;:vertical new&lt;/code&gt; or &lt;code&gt;:vnew&lt;/code&gt;.  The latter has the advantage that is easier to make a command which takes a count, e.g., &lt;code&gt;:20vnew&lt;/code&gt;.  In the following mapping,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;c-m&amp;gt;&amp;lt;c-m&amp;gt; :vnew&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;typing a count beforehand, e.g. &lt;code&gt;20&amp;lt;c-m&amp;gt;&amp;lt;c-m&amp;gt;&lt;/code&gt; will specify the width of the new window.  To ignore this count and always split evenly, you can use &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; to remove the line numbers which are placed in the command line after the mapping's &lt;code&gt;:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;c-m&amp;gt;&amp;lt;c-m&amp;gt; :&amp;lt;c-u&amp;gt;vnew&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-09-29T23:15:58.053" LastActivityDate="2017-09-29T23:15:58.053" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13737" PostTypeId="1" AcceptedAnswerId="13738" CreationDate="2017-09-30T00:42:20.513" Score="7" ViewCount="1518" Body="&lt;p&gt;I am on windows 10 and installed pathogen into home/vimfiles/autoload, and as far as I know all went well. Following the directions &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, I installed nerdcommenter. I restarted gvim, tried :help nerdcommenter, and got E109 Sorry no help for nerdcommenter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone suggest a next step?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: the plugin itself did install (as shown in the gvim plugin menu); the issue is that the help files somehow are not associated or connected properly.&lt;/p&gt;&#xA;" OwnerUserId="14521" LastEditorUserId="11477" LastEditDate="2017-10-06T02:07:31.457" LastActivityDate="2017-10-06T02:07:31.457" Title="Plugin help files not found" Tags="|plugin-system|help-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13738" PostTypeId="2" ParentId="13737" CreationDate="2017-09-30T02:36:30.247" Score="10" Body="&lt;p&gt;you have to create the help-tags.&#xA;Run &lt;code&gt;:helptags&lt;/code&gt; for the dir where you installed the docs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On unix this would most likely be &lt;code&gt;:helptags ~/.vim/doc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or simply recreate them all with &lt;code&gt;:helptags ALL&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-09-30T02:36:30.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13739" PostTypeId="1" AcceptedAnswerId="13740" CreationDate="2017-09-30T08:39:30.717" Score="1" ViewCount="69" Body="&lt;p&gt;In visual selection mode, accessed with &lt;code&gt;ctrl-v&lt;/code&gt;, I can replace the character I want (say Z to be replaced by A) within my selection by typing &lt;code&gt;:&lt;/code&gt; followed by &lt;code&gt;s/Z/A&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is extremely useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a case where it works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12_0test&#xA;12_1test&#xA;12_2test&#xA;12_3test&#xA;12_4test&#xA;12_5test&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I select the &quot;2&quot; in the &quot;12&quot; (&lt;code&gt;ctrl-v&lt;/code&gt; and use arrow keys to select all rows with 2 which results in a column of 2 being highlighted) and do &lt;code&gt;:&lt;/code&gt; followed by &lt;code&gt;s/2/3&lt;/code&gt;. I get what I'm expecting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;13_0test&#xA;13_1test&#xA;13_2test&#xA;13_3test&#xA;13_4test&#xA;13_5test&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I just came across a case where, when in a series of lines the first two characters are the same (here 11), block selecting the 2nd digit and trying to replace it with another digit will replace the 1st digit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I mean.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;11_0test&#xA;11_1test&#xA;11_2test&#xA;11_3test&#xA;11_4test&#xA;11_5test&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I select the column of the second &quot;1&quot; in the &quot;11&quot;, then &lt;code&gt;:&lt;/code&gt; followed by &lt;code&gt;s/1/2&lt;/code&gt;; but I end up with this undesired output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;21_0test&#xA;21_1test&#xA;21_2test&#xA;21_3test&#xA;21_4test&#xA;21_5test&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is it so? &lt;/p&gt;&#xA;" OwnerUserId="12085" LastActivityDate="2017-09-30T09:27:03.090" Title="replacing character in a visual block selection replaces the wrong character?" Tags="|replace|visual-block|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13740" PostTypeId="2" ParentId="13739" CreationDate="2017-09-30T09:01:19.290" Score="1" Body="&lt;p&gt;Substitution is a line-wise operation so even though you've selected just one column the operation applies to the whole line. Try doing &lt;code&gt;s/1/2/g&lt;/code&gt;. If this was a character-wise operation this would only replace the second column, too. But it replaces all '1's with '2'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I should point out that you can accomplish what you want by entering &lt;code&gt;r2&lt;/code&gt; after the column is selected...&lt;code&gt;r&lt;/code&gt;eplace &lt;em&gt;is&lt;/em&gt; a single character operation.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-09-30T09:27:03.090" LastActivityDate="2017-09-30T09:27:03.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13741" PostTypeId="1" CreationDate="2017-10-01T03:18:29.837" Score="3" ViewCount="413" Body="&lt;p&gt;I read &lt;code&gt;:h starstar-wildcard&lt;/code&gt;, but I cannot understand some cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In the following examples, I am using the command &lt;code&gt;:vimgrep pattern file&lt;/code&gt; where &quot;pattern&quot; is contained in the concerned files.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- If I have the files &lt;code&gt;foo.txt&lt;/code&gt; and &lt;code&gt;dir/foo.txt&lt;/code&gt; and execute &lt;code&gt;:vimgrep pattern **.txt&lt;/code&gt;, only the first file is found. Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2- If I have a file &lt;code&gt;foo.txt&lt;/code&gt; and execute &lt;code&gt;:vimgrep pattern **/*.txt&lt;/code&gt;, the pattern is found in the file. I would have expected only files with a &lt;code&gt;/&lt;/code&gt; in its name would match (so only .txt files in subdirectories). Why is the &lt;code&gt;/&lt;/code&gt; ignored?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3- &lt;code&gt;**&lt;/code&gt; seems to only match files, not directories. Is that right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I am misunderstanding how the &lt;code&gt;**&lt;/code&gt; wildcard really works.&lt;/p&gt;&#xA;" OwnerUserId="11717" LastEditorUserId="11717" LastEditDate="2017-10-01T20:57:56.280" LastActivityDate="2017-10-02T07:38:16.463" Title="Understand starstar-wildcard" Tags="|vimgrep|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13742" PostTypeId="1" CreationDate="2017-10-01T05:49:03.153" Score="1" ViewCount="73" Body="&lt;p&gt;You can do &lt;code&gt;dap&lt;/code&gt;, or &lt;code&gt;vap&lt;/code&gt;, etc to select a paragraph. I want to be able to select/yank/delete the entire file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to do this would be to have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap af ggoG$&#xA;nnoremap yaf ggVGy&#xA;nnoremap daf ggVGd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But is there a way to create a new 'text object selector; (like &lt;code&gt;p&lt;/code&gt; for paragraph, &lt;code&gt;w&lt;/code&gt; for word, etc&lt;code&gt;) but with&lt;/code&gt;f` for 'file? E.g. with omap?&lt;/p&gt;&#xA;" OwnerUserId="11136" LastEditorUserId="1292" LastEditDate="2019-01-24T13:13:25.560" LastActivityDate="2019-01-24T13:13:25.560" Title="Vim operation - creating a new text object selector for entire file" Tags="|key-bindings|visual-mode|custom-text-object|" AnswerCount="0" CommentCount="5" ClosedDate="2018-08-17T20:20:10.960" ContentLicense="CC BY-SA 4.0" />
  <row Id="13743" PostTypeId="1" AcceptedAnswerId="13745" CreationDate="2017-10-01T09:43:48.450" Score="3" ViewCount="411" Body="&lt;p&gt;I have this file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name ...&#xA;line1&#xA;&#xA;name ...&#xA;line 2&#xA;&#xA;name ...&#xA;line 3&#xA;&#xA;etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to delete lines after the &quot;...&quot; sequence&#xA;,and preserve the others: is possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result will be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name ...&#xA;&#xA;&#xA;name ...&#xA;&#xA;&#xA;name ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5009" LastActivityDate="2017-10-01T10:11:15.660" Title="Is possible in vim to delete a line after a word or character?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13744" PostTypeId="1" AcceptedAnswerId="13749" CreationDate="2017-10-01T10:05:12.443" Score="0" ViewCount="6450" Body="&lt;p&gt;I have downloaded &lt;code&gt;vim-latex-1.9.0.tar.gz&lt;/code&gt;. Then I follow the instruction describe &lt;a href=&quot;http://vim-latex.sourceforge.net/index.php?subject=download&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. But, the plugin doesn't run.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; looks like -  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set showmatch&#xA;inoremap { {}&amp;lt;Left&amp;gt;&#xA;inoremap {&amp;lt;CR&amp;gt; {&amp;lt;CR&amp;gt;}&amp;lt;Esc&amp;gt;O&#xA;inoremap ( ()&amp;lt;Left&amp;gt;&#xA;inoremap [ []&amp;lt;Left&amp;gt;&#xA;inoremap &amp;lt; &amp;lt;&amp;gt;&amp;lt;Left&amp;gt;&#xA;&quot;inoremap &quot;\begin{document}&quot; &quot;\begin{document}&amp;lt;CR&amp;gt;\end{document}&amp;lt;Esc&amp;gt;O&quot;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&quot; REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.&#xA;filetype plugin on&#xA;&#xA;&quot; IMPORTANT: win32 users will need to have 'shellslash' set so that latex&#xA;&quot; can be called correctly.&#xA;set shellslash&#xA;&#xA;&quot; IMPORTANT: grep will sometimes skip displaying the file name if you&#xA;&quot; search in a singe file. This will confuse Latex-Suite. Set your grep&#xA;&quot; program to always generate a file-name.&#xA;set grepprg=grep\ -nH\ $*&#xA;&#xA;&quot; OPTIONAL: This enables automatic indentation as you type.&#xA;filetype indent on&#xA;&#xA;&quot; OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to&#xA;&quot; 'plaintex' instead of 'tex', which results in vim-latex not being loaded.&#xA;&quot; The following changes the default filetype back to 'tex':&#xA;let g:tex_flavor='latex'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;/.vim/ftplugin/tex.vim&lt;/code&gt; looks like-  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; this is mostly a matter of taste. but LaTeX looks good with just a bit&#xA;&quot; of indentation.&#xA;set sw=2&#xA;&quot; TIP: if you write your \label's as \label{fig:something}, then if you&#xA;&quot; type in \ref{fig: and press &amp;lt;C-n&amp;gt; you will automatically cycle through&#xA;&quot; all the figure labels. Very useful!&#xA;set iskeyword+=:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9498" LastEditorUserId="9498" LastEditDate="2017-10-02T00:31:24.713" LastActivityDate="2017-10-02T00:31:24.713" Title="How to install vim-latex plugin?" Tags="|plugin-vim-latex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13745" PostTypeId="2" ParentId="13743" CreationDate="2017-10-01T10:11:15.660" Score="6" Body="&lt;p&gt;you can do this with &lt;code&gt;:g/regexp/+d&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case this would (probably) be &lt;code&gt;:g/\.\.\./+d&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This (internally) marks all lines matching the regexp and then deletes the next line&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-10-01T10:11:15.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13746" PostTypeId="1" AcceptedAnswerId="13755" CreationDate="2017-10-01T15:04:12.067" Score="3" ViewCount="462" Body="&lt;p&gt;I just want to transform&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 1; i &amp;lt;= N; i++) if(ord[i] == -1) dfs(i, 0, i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 1; i &amp;lt;= N; i++) {&#xA;    if(ord[i] == -1) dfs(i, 0, i);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as little key I should press as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the plugin 'surround' but It seems like it has some functions(like 'yss{') that surrounds entire text line with brackets but not the block I want to surround. And if it is possible, i have to add some new lines at some position, so i think it will be so uncomfortable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I also found some original vim commands, but I was too long and seems like taking too much time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll be so glad if you guys tell me which plugin i should use. Thank you!&lt;/p&gt;&#xA;" OwnerUserId="14362" LastActivityDate="2017-10-01T23:15:19.527" Title="Which vim plugin should I use if i want to surround specific text with brackets like this?" Tags="|plugin-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13747" PostTypeId="1" AcceptedAnswerId="13750" CreationDate="2017-10-01T15:28:03.533" Score="2" ViewCount="234" Body="&lt;p&gt;For easy typesetting of song sheets using the &lt;a href=&quot;https://ctan.org/pkg/leadsheets&quot; rel=&quot;nofollow noreferrer&quot;&gt;leadsheets&lt;/a&gt; LaTeX package I want to make a shortcut for vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the leadsheets package, chords are inserted into the lyrics like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^{Am7}Sunny&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So to input this into vim, I have to press &lt;code&gt;i^{Am7}[ESC]&lt;/code&gt; and move to the next word and do the same. However I'd like to be able to just hit some other key which puts me directly in insert mode, just enter the chord name and after exiting with [ESC] have the &lt;code&gt;^{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; put around the inserted text automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="14544" LastActivityDate="2017-10-01T19:48:57.677" Title="Insert text automatically surrounded by other text" Tags="|key-bindings|insert-mode|filetype-tex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13748" PostTypeId="2" ParentId="13746" CreationDate="2017-10-01T17:21:36.843" Score="3" Body="&lt;p&gt;I'm quite surprised &lt;em&gt;surround&lt;/em&gt; plugin doesn't handle this. If it's not there by default, I'm quite certain though that it can be configured to behave this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way, in &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-brackets&lt;/a&gt;, with the default settings, you can select (in visual mode) from &lt;code&gt;if&lt;/code&gt; to the semi-colon and hit your leader key (backspace by default) followed by &lt;code&gt;{&lt;/code&gt;.&lt;a href=&quot;https://i.stack.imgur.com/UcF5L.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UcF5L.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the screencast, &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; is my leader key, and &lt;code&gt;ctrl+alt+4&lt;/code&gt; relates to &lt;code&gt;{&lt;/code&gt; on my French keyboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But honestly, if this is some C++ code, you'd better configure clang-format to your liking and run it on the current line that you would select. This way braces would also be added around the &lt;em&gt;true&lt;/em&gt; path.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-10-01T17:21:36.843" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13749" PostTypeId="2" ParentId="13744" CreationDate="2017-10-01T19:18:38.547" Score="2" Body="&lt;p&gt;All you have to do to install vim-latex manually is download the tarball and extract it in your vimfiles or .vim directory.  The .vimrc and the tex.vim files will change some latex settings, but do not effect installation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim-latex &lt;a href=&quot;https://github.com/vim-latex/vim-latex&quot; rel=&quot;nofollow noreferrer&quot;&gt;recommends&lt;/a&gt; using a plugin manager like &lt;code&gt;pathogen&lt;/code&gt; or &lt;code&gt;Vundle&lt;/code&gt; to install vim-latex.  You can install &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow noreferrer&quot;&gt;pathogen&lt;/a&gt; and then enter &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim/bundle &amp;amp;&amp;amp; \&#xA;git clone https://github.com/vim-latex/vim-latex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: you will have to make appropriate changes if you work on Windows.  The &lt;code&gt;~/.vim&lt;/code&gt; directory &lt;code&gt;~\vimfiles&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: your vim.tex file should be a tex.vim file. This won't effect installation, but you won't get your indentation and caption preferences until you fix this.&lt;/p&gt;&#xA;" OwnerUserId="14354" LastActivityDate="2017-10-01T19:18:38.547" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13750" PostTypeId="2" ParentId="13747" CreationDate="2017-10-01T19:48:57.677" Score="1" Body="&lt;p&gt;You can do this fairly simply with a macro- type the following;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qa&lt;/code&gt; start recording macro to register &lt;code&gt;a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;W&lt;/code&gt; go to start of next WORD&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; stop recording macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now, you need to navigate to the first insertion point (e.g., &lt;code&gt;^&lt;/code&gt; go to start of line).  Next,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qA&lt;/code&gt; continue recording macro to register &lt;code&gt;a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;i^{}&lt;/code&gt;&lt;kbd&gt;escape&lt;/kbd&gt;&lt;code&gt;i&lt;/code&gt; insert the text, move back one, and re-enter insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;ctrl+o&lt;/kbd&gt;&lt;code&gt;q&lt;/code&gt; stop recording macro, while in insert mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;At this point you can type whatever you need between the &lt;code&gt;{}&lt;/code&gt;, then press &lt;kbd&gt;escape&lt;/kbd&gt;.  This handles only the first entry.  Pressing &lt;code&gt;@a&lt;/code&gt; will allow you to continue inserting repeatedly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This macro is equivalent to typing &lt;code&gt;:let @a = &quot;Wi^{}\&amp;lt;esc&amp;gt;i&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-10-01T19:48:57.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13751" PostTypeId="1" AcceptedAnswerId="13752" CreationDate="2017-10-01T22:05:16.733" Score="5" ViewCount="870" Body="&lt;p&gt;Here is a minimal .tex file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{document}&#xA;    \begin{itemize}&#xA;        \item Here is an equation:&#xA;        \begin{align*}&#xA;            x = y&#xA;        \end{align*}&#xA;        \item Here is another item&#xA;    \end{itemize}&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to make the second item bold.&#xA;If I put my cursor before the H and put&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\textbf{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;while in insert mode, the line de-indents as soon as the bracket is put in place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how can I prevent this behavior? I would like no indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem seems to be the equation environment.&#xA;If that is removed then I get the desired behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;filetype plugin indent on&#xA;syntax enable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The behavior goes away if I remove &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but then I also lose some other desired functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately, I will be using this with &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/lervag/vimtex&lt;/a&gt;.&#xA;So solutions involving that plugin would be welcome as well.&lt;/p&gt;&#xA;" OwnerUserId="5464" LastEditorUserId="1292" LastEditDate="2019-07-11T08:06:34.060" LastActivityDate="2019-07-11T08:06:34.060" Title="Indentation in Latex within a list after an equation" Tags="|indentation|filetype-tex|plugin-vim-latex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13752" PostTypeId="2" ParentId="13751" CreationDate="2017-10-01T22:21:23.990" Score="5" Body="&lt;p&gt;The reason this is happening is because the &lt;code&gt;indentexpr&lt;/code&gt; [1] prefers text to be indented inside &lt;code&gt;\item&lt;/code&gt;s. You can see this by pressing &lt;code&gt;gg=G&lt;/code&gt;.  This is what it considers correct indenting: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{document}&#xA;\begin{itemize}&#xA;    \item Here is an equation:&#xA;        \begin{align*}&#xA;            x = y&#xA;        \end{align*}&#xA;    \item Here is another item&#xA;\end{itemize}&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you type &lt;code&gt;\textbf{&lt;/code&gt; (specifically the &lt;code&gt;{&lt;/code&gt;), it realizes that the &lt;code&gt;\item&lt;/code&gt; should be un-indented compared to the text above it (&lt;code&gt;\end{align*}&lt;/code&gt;.  To disable this, you can put&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:tex_indent_items=0&lt;/code&gt; into your vimrc (only works with vim's default tex indent)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you simply don't like the jumping (i.e., re-indenting) when pressing &lt;code&gt;{&lt;/code&gt; behavior, consider:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set indentkeys-={ indentkeys-=}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1] By default, vim uses &lt;code&gt;GetTeXIndent()&lt;/code&gt; as its &lt;code&gt;indentexpr&lt;/code&gt;; vimtex uses a different &lt;code&gt;indentexpr&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-10-01T22:21:23.990" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13754" PostTypeId="1" CreationDate="2017-10-01T23:12:37.937" Score="0" ViewCount="268" Body="&lt;p&gt;when I tried to paste code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 1; i &amp;lt;= N; i++) if(ord[i] == -1) dfs(i, 0, i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from clipboard in vim(of course in insert mode), it became&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 1); i &amp;lt;= N; i++) if(ord[i] == -1) dfs(i, 0, i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it because I'm using some plugins about brackets?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my .vimrc is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme solarflare&#xA;set nocompatible&#xA;filetype off&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'nathanaelkane/vim-indent-guides'&#xA;Plugin 'Auto-Pairs'&#xA;Plugin 'octol/vim-cpp-enhanced-highlight'&#xA;Plugin 'vim-multiple-cursors'&#xA;Plugin 'surround.vim'&#xA;Plugin 'LucHermitte/lh-vim-lib'&#xA;Plugin 'LucHermitte/lh-brackets'&#xA;call vundle#end()&#xA;filetype plugin indent on &quot; Put your non-Plugin stuff after this line&#xA;syntax enable&#xA;set nu&#xA;set smartindent&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;set expandtab&#xA;let g:syntastic_cpp_compiler_options = ' -std=c++11'&#xA;set t_ut=&#xA;set clipboard=unnamedplus&#xA;let c_no_curly_error=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any problem? Please tell me why and then what should i do?&#xA;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="14362" LastActivityDate="2017-10-02T08:56:35.890" Title="Bracket is added in unintended position when I paste some code in vim" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13755" PostTypeId="2" ParentId="13746" CreationDate="2017-10-01T23:15:19.527" Score="3" Body="&lt;p&gt;The &lt;em&gt;surround&lt;/em&gt; plugin does actually support this:&#xA;If your cursor is in the &lt;code&gt;i&lt;/code&gt; of the &lt;code&gt;if&lt;/code&gt;, pressing &lt;code&gt;yS${&lt;/code&gt; or &lt;code&gt;ySf;{&lt;/code&gt; will have the desired effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, substituting an uppercase &lt;code&gt;S&lt;/code&gt; for the lowercase &lt;code&gt;s&lt;/code&gt; in most of the plugin's shortcuts will do a linewise operation instead of the default characterwise one.&lt;/p&gt;&#xA;" OwnerUserId="3343" LastActivityDate="2017-10-01T23:15:19.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13756" PostTypeId="2" ParentId="3307" CreationDate="2017-10-02T00:03:54.197" Score="2" Body="&lt;p&gt;This notation works (&lt;code&gt;file name&lt;/code&gt; + &lt;code&gt;trailing :&lt;/code&gt; + &lt;code&gt;/ pat /&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/include/stdio.h:/int printf/  -- `file name` + `:` + `/ pat /`&#xA;/usr/include/stdio.h:+/int printf/&#xA;/usr/include/stdio.h: /int printf/&#xA;/usr/include/stdio.h: /#define\s/&#xA;/usr/include/stdio.h: /^#define\sSEEK/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with function and mapping below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nn gf :&amp;lt;C-u&amp;gt;call Gf_search()&amp;lt;CR&amp;gt;&#xA;&#xA;func! Gf_search() abort&#xA;    let word = expand('&amp;lt;cWORD&amp;gt;')&#xA;    let idx = stridx(word, ':')&#xA;    if idx != -1&#xA;        let remline = strpart(getline('.'),col('.'))&#xA;        let pat = substitute(remline, '.*[:+ ]/\([^/]*\)/.*', '\1', &quot;&quot;)&#xA;        if pat != remline&#xA;            let pat = substitute(pat, '\\', '\\\\', 'g')&#xA;            let pat = substitute(pat, ' ', '\\ ', 'g')&#xA;            let filename = expand('&amp;lt;cfile&amp;gt;')&#xA;            exec 'e +/'.pat filename&#xA;            return&#xA;        endif&#xA;    endif&#xA;    &quot; fallback to builtin gF&#xA;    norm! gF&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="10254" LastEditDate="2017-10-02T00:47:07.000" LastActivityDate="2017-10-02T00:47:07.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13757" PostTypeId="1" AcceptedAnswerId="13758" CreationDate="2017-10-02T01:37:23.687" Score="7" ViewCount="625" Body="&lt;p&gt;Currently, when I view the quickfix list with &lt;code&gt;:cw&lt;/code&gt;, the columns/pipes are not aligned, as in this example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mQ8Ys.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mQ8Ys.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if there is an option in vim or a plugin to rearrange the pipes so that they align in columns. &lt;a href=&quot;https://github.com/chrisbra/csv.vim&quot; rel=&quot;noreferrer&quot;&gt;csv.vim&lt;/a&gt; does something similar for csv files (see gif in the README).&lt;/p&gt;&#xA;" OwnerUserId="9202" LastActivityDate="2021-02-24T03:20:34.150" Title="Is it possible to align the results in the quickfix list in columns" Tags="|quickfix|alignment|rearrangement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13758" PostTypeId="2" ParentId="13757" CreationDate="2017-10-02T01:49:32.850" Score="5" Body="&lt;p&gt;Some more searching yielded &lt;a href=&quot;https://github.com/MarcWeber/vim-addon-qf-layout&quot; rel=&quot;nofollow noreferrer&quot;&gt;the qf-layout plugin&lt;/a&gt;, which is working great in my initial tests!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to show only the basename instead of the entire filepath, I modified &lt;a href=&quot;https://github.com/MarcWeber/vim-addon-qf-layout/blob/master/autoload/vim_addon_qf_layout.vim#L84&quot; rel=&quot;nofollow noreferrer&quot;&gt;line 84&lt;/a&gt; from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l.filename = bufname(l.bufnr)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l.filename = fnamemodify(bufname(l.bufnr), &quot;:t&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks neat!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cunyK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cunyK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case someone else finds this useful, I recommend adding something like the following to your &lt;code&gt;.vimrc&lt;/code&gt;, and put the formatting you prefer first in the list. I changed from &lt;code&gt;'NOP'&lt;/code&gt; to &lt;code&gt;'vim_addon_qf_layout#DefaultFormatter'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vim_addon_qf_layout = {}&#xA;let g:vim_addon_qf_layout.quickfix_formatters = [&#xA;    \'vim_addon_qf_layout#DefaultFormatter',&#xA;    \'vim_addon_qf_layout#FormatterNoFilename',&#xA;    \'vim_addon_qf_layout#Reset',&#xA;    \'NOP' ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS This plugin works great together with the &lt;a href=&quot;https://github.com/vim-scripts/SpellCheck&quot; rel=&quot;nofollow noreferrer&quot;&gt;SpellCheck plugin&lt;/a&gt; which populates the quickfix list with misspelled words!&lt;/p&gt;&#xA;" OwnerUserId="9202" LastEditorUserId="9202" LastEditDate="2017-10-02T03:09:19.680" LastActivityDate="2017-10-02T03:09:19.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13760" PostTypeId="2" ParentId="13754" CreationDate="2017-10-02T03:37:09.647" Score="5" Body="&lt;p&gt;The issue comes from the &lt;code&gt;LucHermitte/lh-brackets&lt;/code&gt; plugin. &#xA;The issue is the plugin sees an open parenthesis and decides it wants you to add the close parenthesis before the &lt;code&gt;;&lt;/code&gt; and so tries to be helpful by adding it in for you.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... and then what should I do?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is this your own &lt;code&gt;.vimrc&lt;/code&gt; or is this from someone else?   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's your own chances are you probably didn't spend much time reading through the plugin documentations to understand how to use them properly (I did the same too! I know it's hard as a beginner but you'll become better at it if you dive in head first and learn from the get go). If this is the case take the time to read through the &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets/blob/master/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; and the &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets/issues?utf8=%E2%9C%93&amp;amp;q=is%3Aissue&quot; rel=&quot;nofollow noreferrer&quot;&gt;issues&lt;/a&gt; to see if you can find a mention of how to fix your issue. If there's no mention of how to prevent it happening and no issues opened on github then open an issue and explain whats happening. This way LucHermitte will be able to tell you if this is a bug or if you've missed something in the documentation. If this doesn't work out for you, find another plugin, theres plenty out there that will do the job (but understand them, or at least the basics, before you add them)!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is someone elses &lt;code&gt;.vimrc&lt;/code&gt; then &lt;a href=&quot;https://dougblack.io/words/a-good-vimrc.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;make your own&lt;/a&gt;! It's a lot more fun to customise your own and then you'll know what might be causing issues &lt;s&gt; if &lt;/s&gt;  when your &lt;code&gt;.vimrc&lt;/code&gt; gives you more problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a final note, it really isn't hard to debug your &lt;code&gt;.vimrc&lt;/code&gt; yourself, and it is definitely recommended and encouraged you try debug it yourself before asking on a SE site as it shows you've put some time into solving your problem yourself! Have a look through &lt;a href=&quot;https://vi.stackexchange.com/a/2004/14380&quot;&gt;this&lt;/a&gt; answer as a guide on how to do so in future :)&lt;/p&gt;&#xA;" OwnerUserId="14380" LastEditorUserId="14380" LastEditDate="2017-10-02T08:56:35.890" LastActivityDate="2017-10-02T08:56:35.890" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13761" PostTypeId="1" AcceptedAnswerId="13774" CreationDate="2017-10-02T06:13:27.287" Score="5" ViewCount="2931" Body="&lt;p&gt;I try to make python.vim color similar to material theme (sublime text 3), see pictures: &lt;a href=&quot;https://i.stack.imgur.com/Zg5pp.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/Zg5pp.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;expected is material theme and current is mine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may noticed that all method, function for i.e: os.path.exists(replacement_file)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;all &lt;code&gt;os.path.exists&lt;/code&gt; and &lt;code&gt;replacement_file&lt;/code&gt; are in green color but currently I can't do that with python.vim hacks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help and suggestions is highly appreciated. thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: to narrow down the situation, I have sample below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;basename = os.path.splitext(filename)[0]&#xA; if(os.path.isfile(candidate) or os.path.isdir(candidate)):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here I'm trying to match &lt;code&gt;os.path.splitext&lt;/code&gt; and &lt;code&gt;os.path.isfile&lt;/code&gt; and &lt;code&gt;os.path.isdir&lt;/code&gt; that all the name of method or function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What have I achieved so far?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could match &lt;code&gt;os.path.isfile&lt;/code&gt; with this regex &lt;code&gt;(\()(\w+\.)*\w+\(&lt;/code&gt;&#xA;but above regex will not match &lt;code&gt;os.path.splitext&lt;/code&gt; and &lt;code&gt;os.path.isdir&lt;/code&gt; that said have space before them. Any help?&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="51" LastEditDate="2017-10-03T13:19:49.570" LastActivityDate="2017-10-03T13:34:22.767" Title="How can I highlight all function names in Python files?" Tags="|syntax-highlighting|filetype-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13762" PostTypeId="1" AcceptedAnswerId="13763" CreationDate="2017-10-02T06:57:29.713" Score="3" ViewCount="286" Body="&lt;p&gt;We have a custom filetype at work which I use with a plugin i've written.&#xA;There we have a construct like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\item some text.&#xA;  it is indented on level more than the \item tag&#xA;\item the next item should be indentend the same as the previous one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If i type this, I end with that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\item abc&#xA;  \item abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because the indent is increased for the text.&#xA;Now if I do a &lt;code&gt;==&lt;/code&gt; on that line, it is aligned correctly which tells me, that my indent file works correctly. But I want to do this automatically. Since the &lt;code&gt;\item&lt;/code&gt; tag is used a lot, it is laborious to do it manually all the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question, what is resposible for the automatic indent, how can my plugin fix that.&#xA;I now that it won't be possible to give me an working solutions with the information I provide, but it should be sufficient to point me to the right direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I know it looks like LateX, but due to other things used in the fileformat, I can't just use a LateX plugin. (And my Plugin has some other useful stuff).&lt;/p&gt;&#xA;" OwnerUserId="11316" LastActivityDate="2017-10-02T07:37:16.577" Title="autoindent different from manuall indenting" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13763" PostTypeId="2" ParentId="13762" CreationDate="2017-10-02T07:37:16.577" Score="3" Body="&lt;p&gt;You can use the &lt;code&gt;indentkeys&lt;/code&gt; option, e.g. something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal indentkeys+==item&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For LaTeX files, I use this (in vimtex):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal indentkeys+=[,(,{,),},],\&amp;amp;,=item&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;indentkeys&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h indentkeys&lt;/code&gt;&lt;/a&gt; for more info on the syntax.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-10-02T07:37:16.577" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13764" PostTypeId="1" AcceptedAnswerId="13765" CreationDate="2017-10-02T08:00:58.883" Score="1" ViewCount="1115" Body="&lt;p&gt;I've tried to debug an indent function i've written, and came over this strange behaviour. Here I try to detect some LateX tags (debug output):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;echo previous&#xA;\label{ch10.1}&#xA;&amp;gt;echo previous =~ &quot;\\label&quot;&#xA;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This looks fine. Now i try to do the same thing with the &lt;code&gt;\begin&lt;/code&gt; tag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;echo previous&#xA;\begin{uxlist}&#xA;&amp;gt;echo previous =~ &quot;\\begin&quot;&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It somehow works with &lt;code&gt;\\\\&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;echo previous &#xA;\begin{uxlist}&#xA;&amp;gt;echo previous =~ &quot;\\\\begin&quot;&#xA;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which makes no sense at all for me. Is this expected behaviour? If yes I would be rather glad for an explanation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I solved it by replacing doublequotes with singlequotes.&#xA;But it is still strange for example this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;echo previous&#xA;  \end{itemize}&#xA;&amp;gt;previous =~ &quot;\\item&quot; &#xA;1&#xA;&amp;gt;previous =~ &quot;\\end&quot;&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it looks like &lt;code&gt;\\end&lt;/code&gt; is somehow interpreted as &lt;code&gt;\e&lt;/code&gt; (Escape) which can not be found. That would mean I had to esacpe each backslash 2 times, which is why it works with 4 backslashes.&#xA;But as far as I know, that shouldn't be needed?&lt;/p&gt;&#xA;" OwnerUserId="11316" LastEditorUserId="11316" LastEditDate="2017-10-02T10:08:57.570" LastActivityDate="2017-10-02T11:44:05.447" Title="Strange behaviour in Regex, double escape backslash" Tags="|regular-expression|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13765" PostTypeId="2" ParentId="13764" CreationDate="2017-10-02T09:58:29.570" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#expr4&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; says (scroll down to &lt;code&gt;expr5 and expr6&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The &quot;=~&quot; and &quot;!~&quot; operators match the lefthand argument with the righthand&#xA;  argument, which is used as a pattern.  See pattern for what a pattern is.&#xA;  This matching is always done like 'magic' was set and 'cpoptions' is empty, no&#xA;  matter what the actual value of 'magic' or 'cpoptions' is.  This makes scripts&#xA;  portable.  &lt;strong&gt;To avoid backslashes in the regexp pattern to be doubled, use a&#xA;  single-quote string, see literal-string.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So this is intended behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The confusion is caused by the fact that there is no special syntax for regular expressions in Vim's grammar of expressions (like, say, &lt;code&gt;/regex/&lt;/code&gt; is some languages). This means that Vim reuses its syntax for string literals, which enforces its own set of rules on top of syntax of regular expressions.&lt;/p&gt;&#xA;" OwnerUserId="860" LastEditorUserId="860" LastEditDate="2017-10-02T11:44:05.447" LastActivityDate="2017-10-02T11:44:05.447" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13766" PostTypeId="2" ParentId="13689" CreationDate="2017-10-02T18:25:29.570" Score="2" Body="&lt;p&gt;Many of the other answers here already cover the built in ways to improve the find-and-replace workflow but I wanted to mention &lt;a href=&quot;https://github.com/tpope/vim-abolish#substitution&quot; rel=&quot;nofollow noreferrer&quot;&gt;abolish.vim&lt;/a&gt;, a plugin by Tim Pope. It makes replacements where you want to cover a wider range of cases, normally caused by variations in case or because you need to deal with both singular and plural forms of a word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:S/child{,ren}/adult{,s}/g&lt;/code&gt; correctly converts &lt;code&gt;child&lt;/code&gt; to &lt;code&gt;adult&lt;/code&gt;, &lt;code&gt;Children&lt;/code&gt; to &lt;code&gt;Adults&lt;/code&gt; and &lt;code&gt;CHILD&lt;/code&gt; to &lt;code&gt;ADULT&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're dealing with camel cased words, you need to include the capitals where you need them in the original and replacement words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%:S/wordWrap/textBreak/g&lt;/code&gt; correctly handles both &lt;code&gt;wordWrap&lt;/code&gt; and &lt;code&gt;wordwrap&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10108" LastActivityDate="2017-10-02T18:25:29.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13768" PostTypeId="1" CreationDate="2017-10-02T23:07:58.267" Score="2" ViewCount="3623" Body="&lt;p&gt;I was recently going through a tutorial on configuring the Vimrc file to make it behave more like traditional text editors. In that tutorial, I came across the following line: &lt;code&gt;command! -nargs=* Wrap set wrap linebreak nolist&lt;/code&gt;. This has the effect of allowing one to simply type &quot;:Wrap&quot; and activate a number of behaviors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I have is two-fold. First: is there an easy way to disable these settings (after they have been enabled) with a simple command or do I need to enter something like &lt;code&gt;&quot;:set nowrap nolinebreak list&quot;&lt;/code&gt; ? Second, how does that &quot;command!....&quot; work? The tutorial gave no guidance as to how to interpret the mechanics of that line. What does &quot;command!&quot; do? What about &quot;-nargs=*&quot;? I understand everything else methinks...  I am still too new to this to find simply reading the documentation to be particularly elucidating and have yet to find a tutorial on the subject.&lt;/p&gt;&#xA;" OwnerUserId="14476" LastEditorUserId="14476" LastEditDate="2017-10-03T00:11:19.810" LastActivityDate="2017-10-03T15:32:44.577" Title="What is the standard way of creating new Vim Commands?" Tags="|vimrc|wrapping|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13771" PostTypeId="1" AcceptedAnswerId="13773" CreationDate="2017-10-03T11:11:36.680" Score="2" ViewCount="194" Body="&lt;p&gt;There's &lt;a href=&quot;https://stackoverflow.com/questions/3732657/vim-save-then-make-automatically#3732706&quot;&gt;posts on SO&lt;/a&gt; that explain how to do it in general or on files of a particular type but I would like to restrict it to when I'm inside my project directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can run a script to determine whether I am. &#xA;How I can I wire it up with vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, how do I do something like?:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if  !myscript &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 &quot;doesn't work&#xA;    autocmd BufWritePost &amp;lt;buffer&amp;gt; make&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4738" LastActivityDate="2017-10-03T12:10:43.567" Title="How do I make :make run on a buffer write if I'm inside my project directory?" Tags="|autocmd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13772" PostTypeId="2" ParentId="13771" CreationDate="2017-10-03T11:44:44.970" Score="0" Body="&lt;p&gt;If I understand your question correctly then this might help:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:autocmd BufWritePost &amp;lt;buffer&amp;gt; if !system (&quot;myscript &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&quot;) | make | endif&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-10-03T11:44:44.970" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13773" PostTypeId="2" ParentId="13771" CreationDate="2017-10-03T12:10:43.567" Score="2" Body="&lt;p&gt;Another (untested) approach :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:autocmd BufWritePost &amp;lt;buffer&amp;gt; make&lt;/code&gt; and&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:let &amp;amp;makeprg=&quot;if ! myscript &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 ; then make ; fi&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;let &amp;amp;makeprg=&quot;...&quot;&lt;/code&gt; instead of &lt;code&gt;set makeprg ...&lt;/code&gt; to avoid the ugly &lt;code&gt;\&lt;/code&gt;-es.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-10-03T12:10:43.567" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13774" PostTypeId="2" ParentId="13761" CreationDate="2017-10-03T13:18:09.770" Score="4" Body="&lt;p&gt;A regexp that seems to work well is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v[[:alpha:]_.]+\ze(\s?\()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or for syntax highlighting (see &lt;a href=&quot;https://vi.stackexchange.com/q/4975/51&quot;&gt;How can I add additional syntax highlighting rules in my local vimrc?&lt;/a&gt; on how to add this to your vimrc):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match pythonFunction /\v[[:alpha:]_.]+\ze(\s?\()/&#xA;:hi def link pythonFunction Function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To break it down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; – &quot;very magic&quot; mode so we don't have to add so many backslashes.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[[:alpha:]_.]+&lt;/code&gt; – function name, any alphanumeric character, &lt;code&gt;_&lt;/code&gt;, or &lt;code&gt;.&lt;/code&gt; repeated 1 or more times.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\ze&lt;/code&gt; – Match the following group &quot;zero-width&quot;, meaning it won't be included in the match. This matters because otherwise the space and &lt;code&gt;(&lt;/code&gt; will be highlighted as well.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(&lt;/code&gt; – start subgroup, for the &lt;code&gt;\ze&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s?&lt;/code&gt; – Optionally match any space.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(&lt;/code&gt; – match &lt;code&gt;(&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;)&lt;/code&gt; – end subgroup.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-10-03T13:34:22.767" LastActivityDate="2017-10-03T13:34:22.767" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13775" PostTypeId="1" AcceptedAnswerId="13782" CreationDate="2017-10-03T14:16:23.853" Score="2" ViewCount="1542" Body="&lt;p&gt;An expansion of this question: &lt;a href=&quot;https://vi.stackexchange.com/questions/13761&quot;&gt;How can I highlight all function names in Python files?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i have a sample:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;src_file = replacement_file.replace(header_dir, source_dir)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here i need to match variable/arguments inside method/function, i need to match &quot;header_dir&quot;, &quot;source_dir&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestion is highly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm working on the problem so will feedback to you via edit. thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit 1: i try to match the function name, with help of @carpetsmoker i can match function name but can't match inside (), here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match pFun &quot;\v[[:alpha:]_.]+\ze(\s?\()&quot; contained nextgroup=pFunVars&#xA;syn region pFunVars start=&quot;(&quot; end=&quot;)&quot; contained contains=pFunPara transparent keepend&#xA;syn match  pFunPara &quot;[^,]*&quot; contained contains=pythonString,pythonBrackets skipwhite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it doesn't match both function name and variables. highlight completely failed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the fact is if i keep only:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match pFun &quot;\v[[:alpha:]_.]+\ze(\s?\()&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;function name match works. any clues?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 2: i guess match with end is ( and a region that start with &quot;(&quot; make it confused by regex engine. question is how can i separate the match pattern from ending with (, pattern contains ( and start of region is (, is that double &quot;(&quot; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 3: thanks @muru for suggestion, but it works partially,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region pFun matchgroup=Function \start=&quot;\v[[:alpha:]_.]+\ze(\s?\()&quot; end=&quot;)&quot; contains=pFun nextgroup=pFunPara&#xA;syn match pFunPara /\i*\ze\s*=[^,]/ contained contains=pythonString,pythonBrackets skipwhite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here, &quot;pFunPara /\i*\ze\s*=[^,]/&quot; i can't highlight the contains: pythonString, pythonBrackets inside pFunPara, @muru, do you have pattern to improve this? maybe loop via pFun make it impossible to highlight?&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="14274" LastEditDate="2017-10-04T04:02:02.043" LastActivityDate="2017-10-04T05:59:02.317" Title="How can I highlight variable/arguments inside method/function in Python files?" Tags="|syntax-highlighting|gvim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13776" PostTypeId="1" AcceptedAnswerId="13791" CreationDate="2017-10-03T14:23:58.610" Score="0" ViewCount="3065" Body="&lt;p&gt;I'm new to vim and recently installed &lt;a href=&quot;https://powerline.readthedocs.io/en/latest/overview.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;powerline plugin&lt;/a&gt;. I absolutely love using powerline with vim, but the symbols are not properly rendered. And I suspect I missed something here, can anyone help ???&lt;/p&gt;&#xA;&lt;p&gt;Here is how it looks&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/LAo6g.png&quot; alt=&quot;Here is how it looks&quot; title=&quot;Here is how it looks&quot; /&gt;&lt;/p&gt;&#xA;" OwnerUserId="14567" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-10-04T20:17:34.237" Title="powerline font/symbol glitches" Tags="|font|plugin-powerline|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13777" PostTypeId="2" ParentId="13768" CreationDate="2017-10-03T15:21:24.813" Score="3" Body="&lt;p&gt;You've been looking at the documentation for &lt;code&gt;:command&lt;/code&gt; &lt;em&gt;without&lt;/em&gt; any arguments. The documentation when you are passing arguments is a couple of paragraphs further down. (&lt;code&gt;:h E174&lt;/code&gt; to jump straight there.) The relevant part reads: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If the command already exists, an error is reported, &lt;strong&gt;unless a ! is specified, in which case the command is redefined.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The explanation of &lt;code&gt;-nargs&lt;/code&gt; is further down still, at &lt;code&gt;:h :command-nargs&lt;/code&gt;. It begins:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;By default, a user defined command will take no arguments (and an error is reported if any are supplied).  However, it is possible to specify that the command can take arguments, using the -nargs attribute. Valid cases are:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;-nargs=0    No arguments are allowed (the default)&lt;br&gt;&#xA;    -nargs=1    Exactly one argument is required, it includes spaces&lt;br&gt;&#xA;  &lt;strong&gt;-nargs=*    Any number of arguments are allowed (0, 1, or many),&#xA;                      separated by white space&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So the command creates a new command named &lt;code&gt;:Wrap&lt;/code&gt; which takes any number of arguments. If the &lt;code&gt;:Wrap&lt;/code&gt; command already exists, it overwrites it with the new functionality. The &lt;code&gt;:Wrap&lt;/code&gt; command ignores all the arguments and sets &lt;code&gt;nowrap&lt;/code&gt;, &lt;code&gt;nolinebreak&lt;/code&gt;, and &lt;code&gt;list&lt;/code&gt;. Your guess is as good as mine as to why the arguments are allowed if they are simply going to be ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In case you don't know what an &quot;argument&quot; is: it's just words that you type after a command, that the command uses. e.g. when you save a new file with &lt;code&gt;:w &amp;lt;filename&amp;gt;&lt;/code&gt;, the file name you type after the &lt;code&gt;:w&lt;/code&gt; command is the command's argument.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are correct that &lt;code&gt;:set nowrap nolinebreak list&lt;/code&gt; would set/unset the options again. If you wanted to write a command that performed the inverse of the one in your question, then you could try simply changing the options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* Unwrap set nowrap nolinebreak list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-10-03T15:28:50.140" LastActivityDate="2017-10-03T15:28:50.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13778" PostTypeId="1" AcceptedAnswerId="13779" CreationDate="2017-10-03T15:52:12.677" Score="1" ViewCount="143" Body="&lt;p&gt;Is there a quicker way to create more entries of form &lt;code&gt;{ &quot;name&quot;: FIELD_NAME, &quot;type&quot;: &quot;string&quot; }&lt;/code&gt; from a list of words down below, than recording a macro to process each word and then pasting the result in place?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  &quot;namespace&quot;: &quot;my-space&quot;,&#xA;  &quot;type&quot;: &quot;record&quot;,&#xA;  &quot;name&quot;: &quot;Transaction&quot;,&#xA;  &quot;fields&quot;: [&#xA;    { &quot;name&quot;: &quot;transaction_id&quot;, &quot;type&quot;: &quot;string&quot; }&#xA;  ]&#xA;}&#xA;&#xA;# Fields&#xA;first_name&#xA;last_name&#xA;amount&#xA;currency&#xA;transaction_date&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was hoping for an alternative approach where I could use a template string and then use the list of words to create substituted entry for each, so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ &quot;name&quot;: &quot;PLACEHOLDER&quot;, &quot;type&quot;: &quot;string&quot; } =&amp;gt; { &quot;name&quot;: &quot;first_name&quot;, &quot;type&quot;: &quot;string&quot; }&#xA;                                               { &quot;name&quot;: &quot;last_name&quot;, &quot;type&quot;: &quot;string&quot; }&#xA;                                               ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm happy to use the macros, but something along the lines of the above would be more intuitive for me (and hopefully for others, too).&lt;/p&gt;&#xA;" OwnerUserId="935" LastActivityDate="2017-10-03T16:41:02.443" Title="Quickly creating JSON entries in an Avro schema" Tags="|substitute|macro|repeated-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13779" PostTypeId="2" ParentId="13778" CreationDate="2017-10-03T16:05:54.823" Score="2" Body="&lt;p&gt;Have you considered using &lt;code&gt;:substitute&lt;/code&gt;?  First, start with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ &quot;name&quot;: &quot;\1&quot;, &quot;type&quot;: &quot;string&quot; }&#xA;\(\w\+\)&#xA;&#xA;first_name&#xA;last_name&#xA;amount&#xA;currency&#xA;transaction_date&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, on line one, yank to register &lt;code&gt;a&lt;/code&gt;: &lt;code&gt;1G^&quot;a$&lt;/code&gt;.  On line two, yank to register &lt;code&gt;b&lt;/code&gt;: &lt;code&gt;2G^&quot;b$&lt;/code&gt;.  Then perform the substitute on the appropriate lines:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:4,8s/&amp;lt;c-r&amp;gt;b/&amp;lt;c-r&amp;gt;a/&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; means the enter key and &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt; means &lt;code&gt;ctrl+r&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ &quot;name&quot;: &quot;first_name&quot;, &quot;type&quot;: &quot;string&quot; }&#xA;{ &quot;name&quot;: &quot;last_name&quot;, &quot;type&quot;: &quot;string&quot; }&#xA;{ &quot;name&quot;: &quot;amount&quot;, &quot;type&quot;: &quot;string&quot; }&#xA;{ &quot;name&quot;: &quot;currency&quot;, &quot;type&quot;: &quot;string&quot; }&#xA;{ &quot;name&quot;: &quot;transaction_date&quot;, &quot;type&quot;: &quot;string&quot; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could have also used visual block mode, but this method more easily generalizes to multiple fields; you can use &lt;code&gt;\1&lt;/code&gt;, &lt;code&gt;\2&lt;/code&gt; up to &lt;code&gt;\9&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-10-03T16:26:12.107" LastActivityDate="2017-10-03T16:26:12.107" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13781" PostTypeId="1" CreationDate="2017-10-04T04:51:17.213" Score="0" ViewCount="946" Body="&lt;p&gt;I'm currently using zenburn on android studio (java) and it looks very colorful (note: I'm using iTerm2.. not sure if that changes anything)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aVd4B.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aVd4B.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but if I add zenburn color to my vimrc, the same file looks a lot less colorful on vi:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cpjwC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cpjwC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;how do I fix this? I really wanna do all my editing on vi.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I installed &lt;a href=&quot;https://github.com/vim-scripts/cSyntaxAfter&quot; rel=&quot;nofollow noreferrer&quot;&gt;cSyntaxAfter&lt;/a&gt; and there was an improvement: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mcnBz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mcnBz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I still believe there is more than can be done.. ideas?&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="14510" LastEditDate="2017-10-04T06:15:40.170" LastActivityDate="2018-02-02T12:18:37.003" Title="how to get the color theme right with vi on java" Tags="|syntax-highlighting|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13782" PostTypeId="2" ParentId="13775" CreationDate="2017-10-04T05:59:02.317" Score="2" Body="&lt;p&gt;Adapting the syntax commands I used in &lt;a href=&quot;https://vi.stackexchange.com/a/6963/205&quot;&gt;this answer&lt;/a&gt; and the default &lt;code&gt;pythonFunction&lt;/code&gt; syntax match from Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region pFun matchgroup=Function start='\h\i*\(\.\h\i*\)*\s*(' end=')' contains=pFun,pythonString,pythonNumber,pfunPara&#xA;syn match pFunPara /\v(\=\s*)?\zs\h\i*\ze\s*[,)]/ contained&#xA;hi pFunPara ctermfg=yellow&#xA;hi Function ctermfg=green&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Gives me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/a7TBK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/a7TBK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-10-04T05:59:02.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13784" PostTypeId="1" CreationDate="2017-10-04T09:18:32.930" Score="3" ViewCount="2101" Body="&lt;p&gt;Context: I'm trying to use vim's clientserver mode on Mac OS X, using iterm2.  I've compiled vim with clientserver via brew, and I've got XQuartz installed also.  This is to allow continuous compilation for the vimtex plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When opening vim with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --servername VIM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it opens vim seemingly as normal, but &lt;code&gt;v:servername&lt;/code&gt; stays empty, and from another terminal calling &lt;code&gt;vim --serverlist&lt;/code&gt; gives no output (not even an error).  To me, it seems like vim isn't really creating a server at all?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="14574" LastActivityDate="2018-02-01T17:24:35.767" Title="Vim not starting server" Tags="|macos|plugin-vimtex|clientserver|" AnswerCount="2" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13785" PostTypeId="1" AcceptedAnswerId="13788" CreationDate="2017-10-04T09:45:18.147" Score="2" ViewCount="887" Body="&lt;p&gt;When I pipe text to vim I discovered that by using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat somefile | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it works properly, whereas:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat somefile | vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;makes a mess of the code. For example, type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat test.pl | vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where test.pl is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;while true&#xA;do&#xA;    # i like comments&#xA;    say &quot;This line, and the next one, should not be comments&quot;&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;le true&#xA;do&#xA;    # i like comments&#xA;    #     say &quot;This line, and the next one, should not be comments&quot;&#xA;    #     done&#xA;    #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's as if without the hyphen the text appears as if it's being typed, switching modes and extending comments when you press enter etc, whereas with the hyphen it's treated as if a filename containing the piped text was passed to vim.  I cannot locate the relevant help on this.  I'm pretty sure it's not a shell feature (I'm using Bash on a Red Hat box).&lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastEditorDisplayName="user859" LastEditDate="2017-10-05T09:16:50.350" LastActivityDate="2017-10-05T09:16:50.350" Title="Piping to vim vs vim -" Tags="|help-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13786" PostTypeId="1" AcceptedAnswerId="13787" CreationDate="2017-10-04T10:01:10.553" Score="0" ViewCount="191" Body="&lt;p&gt;What keys should be used to enter ^y in the vim editor.&#xA;For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello ^m&#xA;Welcome ^m&#xA;^y^m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here ^y^m is used to separate paragraphs. &lt;/p&gt;&#xA;" OwnerUserId="13261" LastActivityDate="2017-10-04T13:22:39.323" Title="How ^y is represented in vim editor?" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13787" PostTypeId="2" ParentId="13786" CreationDate="2017-10-04T11:31:43.427" Score="3" Body="&lt;p&gt;You can type any literal character with &lt;code&gt;&amp;lt;ctrl-v&amp;gt;&amp;lt;character&amp;gt;&lt;/code&gt;. Thus, to type &lt;code&gt;^y&lt;/code&gt; you can type &lt;code&gt;&amp;lt;ctrl-v&amp;gt;&amp;lt;ctrl-y&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As pointed out by @mMontu in the comments, it is possible that &lt;code&gt;&amp;lt;ctrl-v&amp;gt;&lt;/code&gt; is mapped to something else, e.g. on Windows if &lt;code&gt;$VIMRUNTIME/mswin.vim&lt;/code&gt; is loaded. One can check if there is any custom mappings with &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq%2d20%2e1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:map &amp;lt;c-v&amp;gt;&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2017-10-04T13:22:39.323" LastActivityDate="2017-10-04T13:22:39.323" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13788" PostTypeId="2" ParentId="13785" CreationDate="2017-10-04T11:35:43.527" Score="1" Body="&lt;p&gt;It's not a shell feature, but a common convention for command-line tools to interpret &lt;code&gt;-&lt;/code&gt; argument as an instruction to read data from standard input. Your understanding of how it works is correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For documentation see &lt;a href=&quot;https://vimhelp.appspot.com/starting.txt.html#--&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help --&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;-&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This argument can mean two things, depending on whether Ex mode is to be used.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Starting in Normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -&#xA;ex -v -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Start editing a new buffer, which is filled with text&#xA;  that is read from stdin.  The commands that would normally be&#xA;  read from stdin will now be read from stderr.  Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -name &quot;*.c&quot; -print | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;The buffer will be marked modified, because it contains text&#xA;  that needs to be saved.  Except when in readonly mode, then&#xA;  the buffer is not marked modified.  Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls | view -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Case with &lt;code&gt;stderr&lt;/code&gt; being used as a source of commands is quite unusual, so&#xA;here's an example that demonstrates how it works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls&#xA;commands  input&#xA;$ cat -A commands&#xA;wcwwas^[wgUE:w output$&#xA;$ cat input&#xA;This is input text.&#xA;$ cat input | vim - 2&amp;lt; commands&#xA;Vim: Reading from stdin...&#xA;Vim: Error reading input, exiting...&#xA;Vim: Finished.&#xA;$ ls&#xA;commands  input  output&#xA;$ cat output&#xA;This was INPUT text.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Not sure why it says &quot;error reading input&quot;.)&lt;/p&gt;&#xA;" OwnerUserId="860" LastEditorUserId="860" LastEditDate="2017-10-05T09:03:03.700" LastActivityDate="2017-10-05T09:03:03.700" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13789" PostTypeId="2" ParentId="13785" CreationDate="2017-10-04T11:36:02.570" Score="1" Body="&lt;p&gt;I think you've explained what's happening quite well yourself!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation for this can be found at &lt;code&gt;:help --&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, help for Vim's command line arguments is at &lt;code&gt;:help vim-arguments&lt;/code&gt;, with help for e.g. the specific argument &lt;code&gt;-X&lt;/code&gt; at &lt;code&gt;:help -X&lt;/code&gt;. Because &lt;code&gt;:help -&lt;/code&gt; is unfortunately already occupied, an extra hyphen is added in this instance.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-10-04T14:03:26.807" LastActivityDate="2017-10-04T14:03:26.807" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13790" PostTypeId="1" CreationDate="2017-10-04T16:55:36.623" Score="1" ViewCount="305" Body="&lt;p&gt;I'm using vim with latex to create documents and I insert references using JabRef and create a bibliography.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't use &lt;code&gt;--servername&lt;/code&gt; in neovim (needed for JabRef).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on how to make neovim work with JabRef?&lt;/p&gt;&#xA;" OwnerUserId="14580" LastEditorUserId="1841" LastEditDate="2017-11-13T08:47:13.347" LastActivityDate="2017-11-13T08:47:13.347" Title="How to use JabRef with neovim without the --servername option?" Tags="|neovim|clientserver|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13791" PostTypeId="2" ParentId="13776" CreationDate="2017-10-04T19:18:38.487" Score="3" Body="&lt;p&gt;There are several ways to install the elements such as the solid right arrows in your screenshot. Two are described here: &lt;a href=&quot;https://powerline.readthedocs.io/en/latest/installation.html#fonts-installation&quot; rel=&quot;nofollow noreferrer&quot;&gt;Powerline fonts installation&lt;/a&gt;. One approach involves installing symbol fonts but these tend to have alignment problems such as you've seen. Similarly, pasting in Unicode characters into your configuration doesn't always work well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The preferred way is to install &quot;patched&quot; fonts, regular fonts that have had the elements added. The elements in these are carefully sized proportional to the rest of the font set. You can find many of these fonts on Github at &lt;a href=&quot;http://github.com/powerline/fonts&quot; rel=&quot;nofollow noreferrer&quot;&gt;powerline/fonts&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2017-10-04T19:18:38.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13792" PostTypeId="2" ParentId="13776" CreationDate="2017-10-04T20:17:34.237" Score="0" Body="&lt;p&gt;As mentioned, you'll need a patched font with power line symbols. I recommend installing a &lt;a href=&quot;https://github.com/ryanoasis/nerd-fonts&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nerd Font&lt;/a&gt;, as they'll cover just about any plug in for vim or your terminal. &lt;/p&gt;&#xA;" OwnerUserId="14585" LastActivityDate="2017-10-04T20:17:34.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13793" PostTypeId="1" AcceptedAnswerId="13798" CreationDate="2017-10-05T01:04:00.600" Score="1" ViewCount="283" Body="&lt;p&gt;I have the following two commands for making sure that &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;g*&lt;/code&gt; move between small words containing &lt;code&gt;$&lt;/code&gt; in a sensible way in &lt;code&gt;php&lt;/code&gt;. I know it's possible to just modify the &lt;code&gt;iskeyword&lt;/code&gt; option for the buffer as a whole, but I'm looking to avoid doing that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the following &lt;code&gt;nnoremap&lt;/code&gt; commands to make &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;g*&lt;/code&gt; temporarily use a different value for &lt;code&gt;iskeyword&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype php nnoremap &amp;lt;silent&amp;gt; * :setlocal iskeyword+=\$&amp;lt;cr&amp;gt;*:setlocal iskeyword-=\$&amp;lt;cr&amp;gt;&#xA;autocmd Filetype php nnoremap &amp;lt;silent&amp;gt; g* :setlocal iskeyword+=\$&amp;lt;cr&amp;gt;g*:setlocal iskeyword-=\$&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works but it's a bit ugly and not very modular. Is there a way to factor out these definitions into separate commands or functions that cleanly override &lt;code&gt;iskeyword&lt;/code&gt; and restore the old definition and handle potential errors correctly?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-10-05T06:48:42.110" Title="How to define a command that temporarily modifies an option?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13794" PostTypeId="1" AcceptedAnswerId="13797" CreationDate="2017-10-05T01:54:15.637" Score="4" ViewCount="3217" Body="&lt;p&gt;I have following mapping &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;imap jj :execute 'tabnew'&amp;lt;cfile&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;instead of opening the under the cursor it just puts the string in place.&lt;/p&gt;&#xA;" OwnerUserId="14587" LastActivityDate="2019-01-13T07:46:21.507" Title="imap just inserts instead of executing" Tags="|vimrc|key-bindings|vimscript|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13795" PostTypeId="1" CreationDate="2017-10-05T03:09:59.067" Score="19" ViewCount="12694" Body="&lt;p&gt;I am using YCM plugin for Vim. And sometimes error messages are too long and I do not see them whole (see Fig.).&#xA;&lt;a href=&quot;https://i.stack.imgur.com/bAF8R.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bAF8R.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;So how to expand (temporarly) the status bar in Vim or there is another way to see full message?&lt;/p&gt;&#xA;" OwnerUserId="14589" LastActivityDate="2018-11-21T23:07:04.160" Title="How to see a whole message in status bar in vim?" Tags="|message|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13797" PostTypeId="2" ParentId="13794" CreationDate="2017-10-05T04:13:49.637" Score="1" Body="&lt;p&gt;I figured the issue out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;imap&lt;/code&gt; is actually doing exactly as it's told to do. It is going and pressing keys I typed there. So what I was missing to make it press  before the command &#xA;&lt;code&gt;imap jj &amp;lt;ESC&amp;gt; :tabnew &amp;lt;cfile&amp;gt; &amp;lt;CR&amp;gt;&lt;/code&gt; works perfectly&lt;/p&gt;&#xA;" OwnerUserId="14587" LastActivityDate="2017-10-05T04:13:49.637" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13798" PostTypeId="2" ParentId="13793" CreationDate="2017-10-05T04:44:17.820" Score="2" Body="&lt;p&gt;In a filetype plugin, for example &lt;code&gt;~/.vim/after/ftplugin/php.vim&lt;/code&gt;, you could try this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno &amp;lt;buffer&amp;gt; &amp;lt;nowait&amp;gt; &amp;lt;silent&amp;gt; *  :&amp;lt;c-u&amp;gt;exe &amp;lt;sid&amp;gt;wrap_star(1)&amp;lt;cr&amp;gt;&#xA;nno &amp;lt;buffer&amp;gt; &amp;lt;nowait&amp;gt; &amp;lt;silent&amp;gt; g* :&amp;lt;c-u&amp;gt;exe &amp;lt;sid&amp;gt;wrap_star(0)&amp;lt;cr&amp;gt;&#xA;&#xA;fu! s:wrap_star(whole) abort&#xA;    let isk_save = &amp;amp;l:isk&#xA;    setl isk+=$&#xA;    try&#xA;        exe 'norm! '.v:count1.(a:whole ? '' : 'g').'*'&#xA;    catch&#xA;        return 'echoerr '.string(v:exception)&#xA;    finally&#xA;        let &amp;amp;l:isk = isk_save&#xA;    endtry&#xA;    return ''&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As your original code did, the &lt;code&gt;s:wrap_star()&lt;/code&gt; function should temporarily add the &lt;code&gt;$&lt;/code&gt; character to the buffer-local value of the &lt;code&gt;'iskeyword'&lt;/code&gt; option. The command responsible for moving the cursor is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe 'norm! '.v:count1.(a:whole ? '' : 'g').'*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's wrapped inside a &lt;code&gt;try&lt;/code&gt; conditional to handle a possible error. No matter what happens, that is even if an error occurs, the &lt;code&gt;finally&lt;/code&gt; clause should remove the &lt;code&gt;$&lt;/code&gt; character from &lt;code&gt;'iskeyword'&lt;/code&gt;, before Vim finishes to process the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check this by adding a non-existing command, such as &lt;code&gt;:abcd&lt;/code&gt;, inside the &lt;code&gt;try&lt;/code&gt; conditional:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno &amp;lt;buffer&amp;gt; &amp;lt;nowait&amp;gt; &amp;lt;silent&amp;gt; *  :&amp;lt;c-u&amp;gt;exe &amp;lt;sid&amp;gt;wrap_star(1)&amp;lt;cr&amp;gt;&#xA;nno &amp;lt;buffer&amp;gt; &amp;lt;nowait&amp;gt; &amp;lt;silent&amp;gt; g* :&amp;lt;c-u&amp;gt;exe &amp;lt;sid&amp;gt;wrap_star(0)&amp;lt;cr&amp;gt;&#xA;&#xA;fu! s:wrap_star(whole) abort&#xA;    let isk_save = &amp;amp;l:isk&#xA;    setl isk+=$&#xA;    try&#xA;        abcd&#xA;        exe 'norm! '.v:count1.(a:whole ? '' : 'g').'*'&#xA;    catch&#xA;        return 'echoerr '.string(v:exception)&#xA;    finally&#xA;        let &amp;amp;l:isk = isk_save&#xA;    endtry&#xA;    return ''&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you hit &lt;code&gt;*&lt;/code&gt; on a word, it should raise the error &lt;code&gt;E492&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vim:E492: Not an editor command:        abcd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After that, if you look at the value of &lt;code&gt;'isk'&lt;/code&gt; (&lt;code&gt;:echo &amp;amp;l:isk&lt;/code&gt;), you shouldn't find the &lt;code&gt;$&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; keycode removes all the characters between the cursor position and the beginning of the command-line. You are probably familiar with it, because it's a readline key binding which also works in a bash or zsh shell. When you have typed a wrong command, and you want to rewrite a new one, you can press &lt;code&gt;C-u&lt;/code&gt; to kill the text from the cursor position up to the beginning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not an obligation to use it, but it's a good habit. Watch this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno cd :echo 'hello'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hit &lt;code&gt;cd&lt;/code&gt;: it displays &lt;code&gt;hello&lt;/code&gt;. Now, hit &lt;code&gt;2cd&lt;/code&gt;: it raises the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E481: No range allowed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because, the &lt;code&gt;2&lt;/code&gt; key that you pressed, combined with the first colon in the right-hand-side of your mapping, caused the following automatic translation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2:    →    :.,.+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;:echo&lt;/code&gt; received the range &lt;code&gt;.,.+1&lt;/code&gt; which means &lt;em&gt;from the current line, down to the next one&lt;/em&gt;. But &lt;code&gt;:echo&lt;/code&gt; doesn't accept a range, so it's an error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, it's the same thing, &lt;code&gt;:exe&lt;/code&gt; doesn't accept a range. So, if you hit a number, you don't want &lt;code&gt;:exe&lt;/code&gt; to be, wrongly, prefixed by a range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you press a number to repeat the motion, the function will still have access to it through the built-in variable &lt;code&gt;v:count1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h c^u&lt;/code&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-10-05T06:48:42.110" LastActivityDate="2017-10-05T06:48:42.110" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13799" PostTypeId="2" ParentId="13781" CreationDate="2017-10-05T09:12:24.427" Score="1" Body="&lt;p&gt;The first thing to note is that Zenburn is a Vim colour scheme that has been ported to other editors, and that, judging by the screenshot you've posted, the port to Android Studio is an unusual one&amp;#8202;&amp;mdash;&amp;#8202;it doesn't look much like it usually does:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BrgvP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BrgvP.png&quot; alt=&quot;Zenburn screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The results in your other screenshots are just a combination of Vim's fairly sparse standard Java syntax elements, Zenburn's particular choices for the colouring of these, and the fact that the sections of file that you've screenshotted happen not to include any of the more colourfully-highlighted elements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try adding a comment or a string to see a bit more colour, or type &lt;code&gt;:hi&lt;/code&gt; (and then page down a few times) to see all the Java syntax elements and their current highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to alter the colouring of particular elements whilst staying within the Zenburn colour scheme, one easy way to do so is with a command like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight link javaScopeDecl Error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where the &lt;code&gt;Error&lt;/code&gt; is another syntax item from the output you've just seen that you like the colouring of. The exact command above isn't one I'd necessarily recommend, but it'll certainly show up in the code that you've provided screenshots of!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are various conversations online that discuss improving Vim's default Java syntax highlighting. &lt;a href=&quot;https://superuser.com/questions/627636/better-syntax-highlighting-for-java-in-vim&quot;&gt;Here's one you may have already seen&lt;/a&gt;. &lt;a href=&quot;https://www.reddit.com/r/vim/comments/3bu715/syntax_highlighting_for_java/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here's another&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-03T11:17:32.487" LastActivityDate="2018-01-03T11:17:32.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13800" PostTypeId="2" ParentId="6338" CreationDate="2017-10-05T09:54:36.603" Score="4" Body="&lt;p&gt;Using &lt;a href=&quot;https://chocolatey.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;chocolatey&lt;/a&gt;, you can install neovim like thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;choco install neovim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add &lt;code&gt;--pre&lt;/code&gt; if you want the latest pre-release. It will install &lt;code&gt;nvim-qt&lt;/code&gt; as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All in all, consider it &lt;em&gt;beta&lt;/em&gt; software. However, it works well enough for my needs.&lt;/p&gt;&#xA;" OwnerUserId="622" LastActivityDate="2017-10-05T09:54:36.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13801" PostTypeId="2" ParentId="9387" CreationDate="2017-10-05T10:41:01.787" Score="6" Body="&lt;h2&gt;TL;DR:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It's defined in Vim's PHP and HTML syntax files. To see how to add rules for CSS, jump to the section &lt;strong&gt;And how do I add to them?&lt;/strong&gt; below, or read on for an explanation of how it works.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Where are these syntax rules getting defined?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The JavaScript heredoc is highlighted using Vim's syntax &lt;code&gt;contains&lt;/code&gt;&lt;sup&gt;1&lt;/sup&gt; feature, which allows syntax groups to contain other syntax groups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To find where this is defined, first open up the syntax highlighting file for PHP:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e $VIMRUNTIME/syntax/php.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, presumably the syntax file is finding the JavaScript heredoc based on a match of the string &quot;javascript&quot;, so lets try searching for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/javascript&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The third match is this comment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; including HTML,JavaScript,SQL even if not enabled via options&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Looks promising! Let's take a look at the relevant syntax line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region  phpHereDoc  matchgroup=Delimiter&#xA;\ start=&quot;\(&amp;lt;&amp;lt;&amp;lt;\)\@&amp;lt;=\(\&quot;\=\)\z(\(\I\i*\)\=\(javascript\)\c\(\i*\)\)\2$&quot;&#xA;\ end=&quot;^\z1\(;\=$\)\@=&quot;&#xA;\ contained&#xA;\ contains=@htmlJavascript,phpIdentifierSimply,phpIdentifier,phpIdentifierComplex,phpBackslashSequences,phpMethodsVar,@Spell&#xA;\ keepend extend&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;line continuations added for easier reading&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Okay, so this syntax region finds the JavaScript heredoc with a convoluted regular expression, and allows JavaScript highlighting within the region by including the &lt;code&gt;@htmlJavascript&lt;/code&gt; syntax &lt;code&gt;cluster&lt;/code&gt;&lt;sup&gt;2&lt;/sup&gt; within the &lt;code&gt;contains&lt;/code&gt; argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there is no corresponding definition for CSS heredocs! Lets add one. So the first thing to change is the &lt;code&gt;start&lt;/code&gt; regular expression. Simply change the &lt;code&gt;javascript&lt;/code&gt; into &lt;code&gt;css&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;start=&quot;\(&amp;lt;&amp;lt;&amp;lt;\)\@&amp;lt;=\(\&quot;\=\)\z(\(\I\i*\)\=\(css\)\c\(\i*\)\)\2$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is easy!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But we don't want JavaScript highlighting in our CSS heredoc. So we also need to change the &lt;code&gt;@htmlJavascript&lt;/code&gt; to the CSS equivalent. But what &lt;em&gt;is&lt;/em&gt; the CSS equivalent? (You might be able to guess, but let's go through the motions to be sure.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets search for &lt;code&gt;htmljavascript&lt;/code&gt;&lt;sup&gt;3&lt;/sup&gt; to see where that is defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/htmljavascript&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hmmm. No other results. It must be defined elsewhere! Let's have a quick look at the top of the file to see if we can find any includes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime! syntax/html.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This looks like it could be it&lt;sup&gt;4&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e $VIMRUNTIME/syntax/html.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Run the search again in this file, and we find this line&lt;sup&gt;5&lt;/sup&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn cluster htmlJavaScript      add=@htmlPreproc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So htmlJavaScript is a &lt;code&gt;cluster&lt;/code&gt;, defined in &lt;code&gt;html.vim&lt;/code&gt;. Is there a similar cluster for CSS we can use?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/htmlcss&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yup!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn include @htmlCss syntax/css.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So we just need to replace &lt;code&gt;@htmlJavascript&lt;/code&gt; with &lt;code&gt;@htmlCss&lt;/code&gt; in the &lt;code&gt;contains&lt;/code&gt; argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;contains=@htmlCss,phpIdentifierSimply,phpIdentifier,[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;And how do I add to them?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Save the entire syntax command below in the file &lt;code&gt;~/after/syntax/php.vim&lt;/code&gt; so that it is run after the rest of the PHP syntax processing has been carried out, and you're done!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region  phpHereDoc  matchgroup=Delimiter&#xA;\ start=&quot;\(&amp;lt;&amp;lt;&amp;lt;\)\@&amp;lt;=\(\&quot;\=\)\z(\(\I\i*\)\=\(css\)\c\(\i*\)\)\2$&quot;&#xA;\ end=&quot;^\z1\(;\=$\)\@=&quot;&#xA;\ contained&#xA;\ contains=@htmlCss,phpIdentifierSimply,phpIdentifier,phpIdentifierComplex,phpBackslashSequences,phpMethodsVar,@Spell&#xA;\ keepend extend&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&#xA;1: See &lt;code&gt;:help :syn-contains&lt;/code&gt; for details.&lt;br&gt;&#xA;2: See &lt;code&gt;:help :syn-cluster&lt;/code&gt;.&lt;br&gt;&#xA;3: I've got &lt;code&gt;'ignorecase'&lt;/code&gt; switched on. Without it, you'll need to search for &lt;code&gt;htmlJavascript&lt;/code&gt; or &lt;code&gt;\chtmljavascript&lt;/code&gt;&lt;br&gt;&#xA;4: In fact, based on the naming scheme used in Vim syntax files, we probably could have figured this out based on the &lt;code&gt;htmlJavascript&lt;/code&gt; name alone.&lt;br&gt;&#xA;5: With &quot;JavaScript&quot; capitalised differently, this time. Lucky we've got &lt;code&gt;'ignorecase'&lt;/code&gt; switched on, eh?&#xA;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-10-05T10:41:01.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13802" PostTypeId="1" AcceptedAnswerId="13803" CreationDate="2017-10-05T10:43:47.127" Score="3" ViewCount="2264" Body="&lt;p&gt;I am learning to use VIM to write Python code. Frequently, I need to perform replacements that include metacharacters, e.g. replacing all instances of '2**NN' with 'MM'. How can I achieve this?&lt;/p&gt;&#xA;" OwnerUserId="14590" LastActivityDate="2017-10-05T10:53:38.237" Title="Replacing string including a metacharacter" Tags="|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13803" PostTypeId="2" ParentId="13802" CreationDate="2017-10-05T10:45:18.237" Score="4" Body="&lt;p&gt;In order to match a literal *, you can escape the &lt;code&gt;*&lt;/code&gt; metacharacter with backslashes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/2\*\*NN/MM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See the user manual for an introduction to Vim's search/replace functionality:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h usr_27.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reference manual contains more detailed information on Vim's regular expressions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h regexp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-10-05T10:53:38.237" LastActivityDate="2017-10-05T10:53:38.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13804" PostTypeId="1" AcceptedAnswerId="13807" CreationDate="2017-10-05T13:50:16.017" Score="2" ViewCount="540" Body="&lt;p&gt;When I use imap or inoremap to create any shortcut in Neovim 0.2.0, the&#xA;shortcuts seem to act as if they are not there! Here is an example that I just tried. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; :w!&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;F2&amp;gt; &amp;lt;Esc&amp;gt;:w!&amp;lt;CR&amp;gt;gv&#xA;inoremap &amp;lt;F2&amp;gt; &amp;lt;Esc&amp;gt;:w!&amp;lt;CR&amp;gt;gi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The insert mode mapping just types in the key combination when I enter it in insert mode. However, the normal and visual mode mappings work just fine. I have tried other combinations such as &lt;code&gt;zz&lt;/code&gt; &lt;code&gt;C-s&lt;/code&gt; and others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I have &lt;code&gt;stty -ixon&lt;/code&gt; in my shell rc file. &lt;/p&gt;&#xA;" OwnerUserId="14594" LastActivityDate="2017-10-05T15:40:26.137" Title="Insert mode keymaps: Custom keymaps just insert characters of combination when typed (Neovim)" Tags="|key-bindings|neovim|" AnswerCount="2" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13805" PostTypeId="1" CreationDate="2017-10-05T14:19:10.627" Score="1" ViewCount="287" Body="&lt;p&gt;I used to have a similar problem with the main screen (IIRC), like here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2sWVG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2sWVG.png&quot; alt=&quot;vim-lines-bg-problem&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I solved it by setting &lt;code&gt;set set t_ut=&lt;/code&gt;, as was suggested in &lt;a href=&quot;https://serverfault.com/questions/268555/how-to-tell-vim-to-extend-the-background-color-to-the-whole-screen&quot;&gt;this question's&lt;/a&gt; accepted answer. But now I spotted another similar problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jxgTd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jxgTd.png&quot; alt=&quot;vim-bg-shell-output-problem&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I have not been able to fix it, following directions from other similar questions: &lt;a href=&quot;https://superuser.com/questions/678905/vim-colorscheme-weirdness-for-background-not-non-text-area/678995&quot;&gt;Vim Colorscheme Weirdness for Background&lt;/a&gt;, &lt;a href=&quot;https://superuser.com/questions/399296/256-color-support-for-vim-background-in-tmux&quot;&gt;256 color support for vim background in tmux&lt;/a&gt;, namely setting the TERM variable's value to &lt;code&gt;screen&lt;/code&gt; or &lt;code&gt;screen-256color&lt;/code&gt;. I tried, but to no avail:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo@bar$ TERM=screen&#xA;foo@bar$ echo $TERM&#xA;screen&#xA;foo@bar$ vim /etc/apache2/ports.conf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use Terminator as a terminal, but, it seems, this doesn't matter, since in the default Ubuntu terminal the problem is the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not that this is a huge problem, but it's still annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anyone help? Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="2798" LastActivityDate="2017-10-05T14:19:10.627" Title="How to extend the background color to the whole screen in a shell command's output?" Tags="|colorscheme|color|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13806" PostTypeId="2" ParentId="13804" CreationDate="2017-10-05T15:25:14.157" Score="1" Body="&lt;p&gt;Instead of the &lt;code&gt;&amp;lt;esc&amp;gt;...gi&lt;/code&gt; pattern, it is generally better to use &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; to temporarily leave insert mode to use a command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;F2&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-o&amp;gt;:w!&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;c-\&amp;gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; is like &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; except does not move the cursor backwards when at the end of the line.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-10-05T15:25:14.157" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13807" PostTypeId="2" ParentId="13804" CreationDate="2017-10-05T15:40:26.137" Score="2" Body="&lt;p&gt;So as it turns out, the problem was that I had&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set paste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my &lt;code&gt;init.vim&lt;/code&gt; file. Removing that line solved it, and now insert mode key bindings work fine! &lt;/p&gt;&#xA;" OwnerUserId="14594" LastActivityDate="2017-10-05T15:40:26.137" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13809" PostTypeId="1" AcceptedAnswerId="13810" CreationDate="2017-10-05T16:58:15.143" Score="1" ViewCount="1057" Body="&lt;p&gt;I've the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a1a foo bar buzz&#xA;foo b2b bar buzz&#xA;foo bar c3c buzz&#xA;foo bar buzz d4d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where I can match all words consisting only alpha characters by the following pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\&amp;lt;[a-zA-Z]*\&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, how can I  remove all words which doesn't match the pattern?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the final content is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar buzz&#xA;foo bar buzz&#xA;foo bar buzz&#xA;foo bar buzz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've checked &lt;a href=&quot;http://vim.wikia.com/wiki/Search_for_lines_not_containing_pattern&quot; rel=&quot;nofollow noreferrer&quot;&gt;Search for lines not containing pattern&lt;/a&gt; page, but without luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To remove &lt;em&gt;some&lt;/em&gt; words patching the pattern, &lt;em&gt;global&lt;/em&gt; command can be used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\&amp;lt;[a-zA-Z]*\&amp;gt;/;&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as per this &lt;a href=&quot;https://stackoverflow.com/a/19529723/55075&quot;&gt;post&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when doing opposite:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:v/\&amp;lt;[a-zA-Z]*\&amp;gt;/;&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;there is this message:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Pattern found in every line&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2017-10-05T19:31:41.147" LastActivityDate="2017-10-05T19:31:41.147" Title="How to remove all words which doesn't match the pattern?" Tags="|search|regular-expression|substitute|global-command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13810" PostTypeId="2" ParentId="13809" CreationDate="2017-10-05T17:34:21.020" Score="3" Body="&lt;p&gt;You can do this with &lt;code&gt;\@&amp;lt;!&lt;/code&gt; (which is sometimes called &quot;negative lookbehind&quot;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/\&amp;lt;\w\+\&amp;gt;\(\&amp;lt;\a\+\&amp;gt;\)\@&amp;lt;!&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    \@&amp;lt;! Matches with zero width if the preceding atom does NOT match just&#xA;         before what follows.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is a bit tricky to understand at first:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Initially we try searching for all words (including ones with numbers) &lt;code&gt;/\&amp;lt;\w\+\&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Since we want some words to match and not others, we use a &quot;zero-width&quot; in this position to force certain text to match.  In this case, the text we want is words without a digit: &lt;code&gt;\&amp;lt;\a\+\&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;We wrap the second pattern in &lt;code&gt;\(&lt;/code&gt;...&lt;code&gt;\)\@&amp;lt;!&lt;/code&gt;, which denotes the zero-width mentioned above.  We use &lt;code&gt;\(&lt;/code&gt;...&lt;code&gt;\)&lt;/code&gt; to create a single atom.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now, to remove those words, we can use &lt;code&gt;:substitute&lt;/code&gt;, but add &lt;code&gt;\s\?&lt;/code&gt; to take care of the spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/\&amp;lt;\w\+\&amp;gt;\(\&amp;lt;\a\+\&amp;gt;\)\@&amp;lt;!\s\?//g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can make this slightly shorter using &lt;code&gt;\v&lt;/code&gt; very magic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/\v&amp;lt;\w+&amp;gt;(&amp;lt;\a+&amp;gt;)@&amp;lt;!\s?//g&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-10-05T18:03:16.873" LastActivityDate="2017-10-05T18:03:16.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13812" PostTypeId="1" CreationDate="2017-10-05T18:55:02.043" Score="8" ViewCount="3517" Body="&lt;p&gt;I frequently work with code style which asks that many non-class symbols use &lt;code&gt;snake_case&lt;/code&gt; -- Python, Ruby, and C especially. If I have a symbol like &lt;code&gt;longfirstpart_longsecondpart&lt;/code&gt;, I'd like to be able to jump to the underscore in the middle &lt;em&gt;à la&lt;/em&gt; &lt;code&gt;w&lt;/code&gt; skipping to the next &lt;code&gt;word&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a built-in shortcut or &lt;code&gt;init.vim&lt;/code&gt; variable for this kind of behaviour?&lt;/p&gt;&#xA;" OwnerUserId="10227" LastActivityDate="2019-06-14T07:17:56.530" Title="A version of `w` which skips to the next underscore" Tags="|neovim|cursor-motions|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13813" PostTypeId="2" ParentId="13812" CreationDate="2017-10-05T19:02:33.780" Score="10" Body="&lt;p&gt;This can be done very easily with the &lt;code&gt;iskeyword&lt;/code&gt; option. From &lt;code&gt;:h iskeyword&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *'iskeyword'* *'isk'*&#xA;'iskeyword' 'isk'   string (Vim default for MS-DOS and Win32:&#xA;                        &quot;@,48-57,_,128-167,224-235&quot;&#xA;                   otherwise:  &quot;@,48-57,_,192-255&quot;&#xA;                Vi default: &quot;@,48-57,_&quot;)&#xA;            local to buffer&#xA;            {not in Vi}&#xA;    Keywords are used in searching and recognizing with many commands:&#xA;    &quot;w&quot;, &quot;*&quot;, &quot;[i&quot;, etc.  It is also used for &quot;\k&quot; in a |pattern|.  See&#xA;    'isfname' for a description of the format of this option.  For C&#xA;    programs you could use &quot;a-z,A-Z,48-57,_,.,-,&amp;gt;&quot;.&#xA;    For a help file it is set to all non-blank printable characters except&#xA;    '*', '&quot;' and '|' (so that CTRL-] on a command finds the help for that&#xA;    command).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword-=_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and that should work for you.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-10-05T19:02:33.780" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13814" PostTypeId="2" ParentId="5989" CreationDate="2017-10-05T19:54:58.623" Score="3" Body="&lt;p&gt;This is a fairly old question, but I felt that it was worth contributing that if your given distro/OS has access to &lt;a href=&quot;https://joeyh.name/code/moreutils/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;moreutils&lt;/code&gt;&lt;/a&gt;, then you can install it and simply use &lt;code&gt;vipe&lt;/code&gt; as a standard addition to &lt;code&gt;vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo foo | vipe # Now you can edit &quot;foo&quot; to be &quot;bar&quot;!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;moreutils&lt;/code&gt; is super handy for its other tools, too, and I'd highly recommend them if you're a serious command-line user! :) Take a look at the author's introduction (previous link) for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://rentes.github.io/unix/utilities/2015/07/27/moreutils-package/#installing&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;moreutils&lt;/code&gt; should be generally available to most *nix-like distros via a package manager and via Homebrew on Mac&lt;/a&gt;. For example...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Arch Linux and MSYS2 (more below) as part of the `community` repo&#xA;pacman -Sy moreutils&#xA;&#xA;&#xA;# Mac OS and Homebrew&#xA;brew install moreutils&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;moreutils&lt;/code&gt; is also a &lt;a href=&quot;https://github.com/Alexpux/MSYS2-packages/tree/master/moreutils&quot; rel=&quot;nofollow noreferrer&quot;&gt;part of the MSYS2 package repository&lt;/a&gt;, so you can technically use it on Windows too. :)&lt;/p&gt;&#xA;" OwnerUserId="14600" LastEditorUserId="14600" LastEditDate="2018-03-21T21:00:33.770" LastActivityDate="2018-03-21T21:00:33.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13816" PostTypeId="2" ParentId="13812" CreationDate="2017-10-05T20:35:16.880" Score="6" Body="&lt;p&gt;I would simply use &lt;code&gt;f_&lt;/code&gt;, but that means I know I want to move to the underscore instead of abstractly to the next word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can repeat the last &lt;code&gt;f&lt;/code&gt; with &lt;code&gt;;&lt;/code&gt;, and both &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt; accept a count.&lt;/p&gt;&#xA;" OwnerUserId="14602" LastEditorUserId="51" LastEditDate="2017-10-05T22:04:04.347" LastActivityDate="2017-10-05T22:04:04.347" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13817" PostTypeId="2" ParentId="388" CreationDate="2017-10-05T20:47:32.787" Score="4" Body="&lt;p&gt;For people who want a full plugin manager using Pathogen, there is also apt-vim. You can install it with &lt;code&gt;curl -sL https://raw.githubusercontent.com/egalpin/apt-vim/master/install.sh | sh&lt;/code&gt;&#xA; (as described here: &#xA;&lt;a href=&quot;https://www.linuxsecrets.com/1715-vi-editor-tips-trick-and-secrets-into-the-vi-vim-editor-part-ii&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.linuxsecrets.com/1715-vi-editor-tips-trick-and-secrets-into-the-vi-vim-editor-part-ii&lt;/a&gt;&#xA;). Once installed, you can just type &lt;code&gt;apt-vim install&lt;/code&gt; followed by the name of the package repository, similar to the Ubuntu apt package manager.&lt;/p&gt;&#xA;" OwnerUserId="14603" LastEditorUserId="22746" LastEditDate="2019-06-22T15:05:02.997" LastActivityDate="2019-06-22T15:05:02.997" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="13818" PostTypeId="1" AcceptedAnswerId="13841" CreationDate="2017-10-05T22:32:14.767" Score="6" ViewCount="3446" Body="&lt;p&gt;Is there a command in Vim to move the cursor to the next number?  I know I can do &lt;code&gt;f2&lt;/code&gt; to find the number 2 in the same line, but I'm looking for a more general number-jumping command.&lt;/p&gt;&#xA;" OwnerUserId="14468" LastActivityDate="2021-06-28T21:26:45.067" Title="Jump to Next Number" Tags="|key-bindings|navigation|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13819" PostTypeId="1" AcceptedAnswerId="13820" CreationDate="2017-10-05T23:38:11.843" Score="1" ViewCount="918" Body="&lt;p&gt;Suppose I have many lines of various indentations. E.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqqq&#xA;      wwwwwwww&#xA;    eeeeee&#xA;&#xA;      rrrrrrr&#xA;   tttttt&#xA;        yyyyyyy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I am anywhere on the fourth line above which is blank. Is there a shortcut to jump the cursor to directly under the first &lt;code&gt;e&lt;/code&gt; of the third line?&lt;/p&gt;&#xA;" OwnerUserId="14019" LastActivityDate="2017-10-06T02:03:50.623" Title="How to move to same indentation as previous line" Tags="|indentation|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13820" PostTypeId="2" ParentId="13819" CreationDate="2017-10-06T00:02:31.083" Score="1" Body="&lt;p&gt;I don't believe so. Does the blank line have whitespace or is it totally empty? If the former you can use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;^ kg^j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, &lt;a href=&quot;https://vi.stackexchange.com/questions/13819/how-to-move-to-same-indentation-as-previous-line/13820#comment23705_13820&quot;&gt;courtesy of Mass&lt;/a&gt;, just &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;^ -j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;leader&amp;gt;^&lt;/code&gt; can be replaced with any unused key combo you like. Enter it while in Normal mode and you'll get the effect you need. (If you want it to work with wrapped lines, too, then use &lt;code&gt;gkg^gj&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the blank line is totally empty there's no easy way to go to an arbitrary column. You have to insert the appropriate amount of whitespace first. (Well, that's a bit of a lie...you can use &lt;code&gt;:set virtualedit=all&lt;/code&gt; but that's probably going beyond what you have in mind.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-10-06T02:03:50.623" LastActivityDate="2017-10-06T02:03:50.623" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13821" PostTypeId="2" ParentId="13819" CreationDate="2017-10-06T01:11:24.440" Score="1" Body="&lt;p&gt;If you have &lt;code&gt;set cindent&lt;/code&gt;, you can press &lt;code&gt;S&lt;/code&gt; (or equivalently &lt;code&gt;cc&lt;/code&gt;) to clear the line and start insert mode at that point.   If you want to wind up in normal mode, &lt;code&gt;S &amp;lt;esc&amp;gt;&lt;/code&gt; would work, and fill the line with spaces up to and including under the first &quot;e.&quot;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-10-06T01:24:43.053" LastActivityDate="2017-10-06T01:24:43.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13822" PostTypeId="1" AcceptedAnswerId="13826" CreationDate="2017-10-06T03:10:37.703" Score="2" ViewCount="273" Body="&lt;p&gt;I am working with a &lt;s&gt;new&lt;/s&gt; old code base where virtually all the interesting source files are three levels deep in the directory hierarchy. It's about 1.3M lines of code in more than 2000 &lt;code&gt;.cpp&lt;/code&gt; files. The project &lt;code&gt;Makefile&lt;/code&gt; is set up so that when a compiler error happens, only the file &lt;em&gt;name&lt;/em&gt; part of the file in question is shown, rather than the &lt;em&gt;path&lt;/em&gt; to that file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like to do is be able to ask vim to open a file by name only, and have it look through the directory tree to find that name for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already have a &lt;code&gt;tags&lt;/code&gt; file set up so I can jump to identifiers without caring which directory or source file name they're in, but that doesn't help for actual file names themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a native vim way, or a plugin, that can help with this? My ideal solution would be something that would modify the &lt;code&gt;:n&lt;/code&gt; command so that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If a path is provided (even just &lt;code&gt;./&lt;/code&gt;), the behaviour is unchanged;&lt;/li&gt;&#xA;&lt;li&gt;If only a file name is provided, and a file by that name doesn't exist in the current directory, vim would search through the whole tree under the current directory looking for a file by that name. If one is found, open that.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A solution that uses a different command than &lt;code&gt;:n&lt;/code&gt; would be fine.&lt;/p&gt;&#xA;" OwnerUserId="13806" LastActivityDate="2017-10-09T20:07:08.063" Title="Is there a quick way to open a file anywhere within a directory hierarchy?" Tags="|filesystem|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13823" PostTypeId="1" CreationDate="2017-10-06T03:28:45.723" Score="1" ViewCount="852" Body="&lt;p&gt;I write in German and English and my text sometimes deal specific topics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This lead me to use multiple spelling files for different kinds of texts.&#xA;The advantage for example is when I write in German and I have many topic specific English words I don't add these words to the German spelling file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set spellang=de_de,security,protocols&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For this I wrote a script/vim mapping to decide into which file a new word should be added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I often have the problem when I write a text about a new topic, I have to add a lot of new words.&#xA;When I start spell checking I then first get rid of all the obvious errors and I'm left will all the new words and I would like to see all these words and sort and filter them in a compressed view, to add them into the spell files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could this be made possible?&#xA;Is there a way to have all misspelled words in a new buffer?&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2021-10-03T18:18:20.717" Title="Is there a way to have all misspelled words in a new buffer?" Tags="|spell-checking|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13825" PostTypeId="2" ParentId="13812" CreationDate="2017-10-06T06:58:49.907" Score="2" Body="&lt;p&gt;There are exist two plugins for the improving experience to move through camelCase and snake_case.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The first one is he &lt;a href=&quot;https://github.com/vim-scripts/camelcasemotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;camelcasemotion plugin&lt;/a&gt;, defining the additional commands, normally prepended with a comma. But this one is old and unmaintained for many years.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The second one is actively developed, and uses completely different approach - &lt;a href=&quot;https://github.com/chaoren/vim-wordmotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-wordmotion&lt;/a&gt;. It redefines the word boundaries, so all default commands will work as is, just within new rules:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CamelCaseACRONYMWords_underscore1234&#xA;w---&amp;gt;w--&amp;gt;w-----&amp;gt;w----&amp;gt;w--------&amp;gt;w-&amp;gt;w&#xA;e--&amp;gt;e--&amp;gt;e-----&amp;gt;e---&amp;gt;e---------&amp;gt;e--&amp;gt;e&#xA;b&amp;lt;---b&amp;lt;--b&amp;lt;-----b&amp;lt;----b&amp;lt;--------b&amp;lt;-b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4783" LastEditorUserId="1515" LastEditDate="2019-06-14T07:17:56.530" LastActivityDate="2019-06-14T07:17:56.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13826" PostTypeId="2" ParentId="13822" CreationDate="2017-10-06T07:00:52.470" Score="8" Body="&lt;p&gt;You can do this by setting the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27path%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'path'&lt;/code&gt; option&lt;/a&gt; to include &lt;code&gt;**&lt;/code&gt;, and then using the &lt;code&gt;:find&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set path=.,,**&#xA;:find filename.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The section on &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#file-searching&quot; rel=&quot;noreferrer&quot;&gt;File Searching&lt;/a&gt; in the documentation describes how the &lt;code&gt;**&lt;/code&gt; path wildcard works.&lt;/p&gt;&#xA;" OwnerUserId="13806" LastEditorUserId="13806" LastEditDate="2017-10-06T07:06:10.677" LastActivityDate="2017-10-06T07:06:10.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13827" PostTypeId="2" ParentId="13784" CreationDate="2017-10-06T07:17:42.043" Score="1" Body="&lt;p&gt;clientserver needs X11 for working. So on OSX, you have to run XQuartz. Also, be sure that your vim is not a symlink to mvim with the -v option (mvim -v would run vim in terminal mode without X11 features, from my understanding).&lt;/p&gt;&#xA;" OwnerUserId="14606" LastActivityDate="2017-10-06T07:17:42.043" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13829" PostTypeId="1" AcceptedAnswerId="13831" CreationDate="2017-10-06T11:21:47.350" Score="11" ViewCount="12237" Body="&lt;p&gt;When I press ^K in my vim while I'm in insertion mode a '?' appears and then if I press a and then another character some strange characters appear the following are a few of the characters I could get that way:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;さたåだả۹۸あァǡ۸åさя&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So What is happening here?&lt;/p&gt;&#xA;" OwnerUserId="14609" LastActivityDate="2017-10-06T11:42:06.117" Title="What does CTRL-K do in insertion mode?" Tags="|key-bindings|insert-mode|unicode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13830" PostTypeId="1" AcceptedAnswerId="13835" CreationDate="2017-10-06T11:25:30.380" Score="1" ViewCount="120" Body="&lt;p&gt;In the Clean language, identifiers consist of &lt;em&gt;either all&lt;/em&gt; 'normal' characters (&lt;code&gt;[a-zA-Z][a-zA-Z0-9_`]*&lt;/code&gt;) &lt;em&gt;or all&lt;/em&gt; 'funky' characters (&lt;code&gt;[~!@#$%^&amp;amp;*-=+:&amp;lt;&amp;gt;,./?|]&lt;/code&gt; and perhaps more). What I would like is a &lt;code&gt;iskeyword&lt;/code&gt; setting that recognises this. To clarify some examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;.&amp;gt;&lt;/code&gt; should be one word&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;x&amp;gt;y&lt;/code&gt; should be split as &lt;code&gt;x&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;x.y&lt;/code&gt; should be split as &lt;code&gt;x&lt;/code&gt;, &lt;code&gt;.&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is it possible to write an &lt;code&gt;iskeyword&lt;/code&gt; that does this properly? I have seen &lt;a href=&quot;http://vim.1045645.n5.nabble.com/Contextual-iskeyword-td1155687.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this discussion&lt;/a&gt; where the end result seems to be it is not possible, but this is a slightly different use case and something might have changed  since 2006.&lt;/p&gt;&#xA;" OwnerDisplayName="user2598" LastActivityDate="2017-10-06T12:23:16.153" Title="iskeyword with context" Tags="|vi-words|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13831" PostTypeId="2" ParentId="13829" CreationDate="2017-10-06T11:42:06.117" Score="16" Body="&lt;p&gt;It allows you to enter a digraph&amp;#8202;&amp;mdash;&amp;#8202;it's a method of entering a more extensive range of Unicode characters using pairs of keystrokes. (See &lt;code&gt;:h digraphs&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For future reference, you can find out what insert mode keystrokes do with commands such as: &lt;code&gt;:h i_CTRL-K&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-10-06T11:42:06.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13832" PostTypeId="1" AcceptedAnswerId="13834" CreationDate="2017-10-06T12:02:19.390" Score="1" ViewCount="3123" Body="&lt;p&gt;I have this line in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-'&amp;gt; :marks&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and want to use &lt;kbd&gt;Ctrl-'&lt;/kbd&gt; to show all marks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sadly, it never works, be it on ubuntu, cygwin, or windows 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After vim 8.0 was launched, type &lt;code&gt;:nn &amp;lt;C-'&amp;gt;&lt;/code&gt; echos&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n  &amp;lt;C-'&amp;gt;       * :marks&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus I wonder, is it possible to reliably remapping &lt;code&gt;&amp;lt;C-'&amp;gt;&lt;/code&gt;? or I missed something?&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2020-05-08T03:07:18.377" Title="key mapping &lt;C-'&gt; (Ctrl single quote) not working" Tags="|vimrc|key-bindings|normal-mode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13833" PostTypeId="1" CreationDate="2017-10-06T12:15:30.107" Score="1" ViewCount="154" Body="&lt;p&gt;python builtin function like print, len, sum...&#xA;i can match and highlight other function and its argument. but with builtin function i can't change color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword pythonStatement def nextgroup=pythonFunction skipwhite&#xA;syn match pythonFunction &quot;\%(\%(def\s\|@\)\s*\)\@&amp;lt;=\h\%(\w\|\.\)*&quot; contained nextgroup=pythonVars&#xA;syn region pythonVars start=&quot;(&quot; skip=+\(&quot;.*&quot;\|'.*'\)+ end=&quot;)&quot; contained contains=pythonParameters transparent keepend&#xA;syn match pythonParameters &quot;[^,]*&quot; contained contains=pythonParam skipwhite&#xA;syn match pythonParam &quot;[^,]*&quot; contained contains=pythonExtraOperator,pythonLambdaExpr,pythonBuiltinObj,pythonBuiltinType,pythonConstant,pythonString,pythonNumber,pythonBrackets,pythonSelf,pythonComment skipwhite&#xA;syn match pythonBrackets &quot;{[(|)]}&quot; contained skipwhite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and links all to Function but the result:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ffUTN.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ffUTN.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 1: @Rich: for more clear, below is the expectation:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/iehP4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iehP4.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="14274" LastEditDate="2017-10-08T08:38:58.270" LastActivityDate="2017-10-08T08:38:58.270" Title="Weird highlight behavior: Can't match pythonBuiltin" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13834" PostTypeId="2" ParentId="13832" CreationDate="2017-10-06T12:18:02.563" Score="6" Body="&lt;p&gt;Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like &lt;kbd&gt;Ctrl&lt;/kbd&gt; + non-alphabetic cannot be mapped, and &lt;kbd&gt;Ctrl&lt;/kbd&gt; + letter vs. &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;Shift&lt;/kbd&gt; + letter cannot be distinguished. (Unless your terminal sends a distinct &lt;em&gt;termcap&lt;/em&gt; code for it, which most don't.) In insert or command-line mode, try typing the key combination. If nothing happens / is inserted, you cannot use that key combination. (For &lt;code&gt;&amp;lt;C-'&amp;gt;&lt;/code&gt;, I get a &lt;code&gt;'&lt;/code&gt; in GVIM.) This also applies to &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-M&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; etc. (Only exception is &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-H&amp;gt;&lt;/code&gt;.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. &lt;a href=&quot;http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8&quot; rel=&quot;noreferrer&quot;&gt;http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim release.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2017-10-06T12:18:02.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13835" PostTypeId="2" ParentId="13830" CreationDate="2017-10-06T12:23:16.153" Score="1" Body="&lt;p&gt;The &lt;code&gt;'iskeyword'&lt;/code&gt; option defines the codepoints for a single keyword character, but cannot make a statement about its neighbors. In other words, you'd need a regular expression (something like &lt;code&gt;[a-zA-Z][a-zA-Z0-9_`]*\|[~!@#$%^&amp;amp;*-=+:&amp;lt;&amp;gt;,./?|]\+&lt;/code&gt;), but Vim only offers a &lt;em&gt;set&lt;/em&gt; of characters. Therefore, this still isn't possible. You have to pick either normal &lt;em&gt;or&lt;/em&gt; funky characters, or live with the fact that a mixture of both that is not separated by whitespace is mistakenly recognized as a single keyword.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2017-10-06T12:23:16.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13836" PostTypeId="1" AcceptedAnswerId="13911" CreationDate="2017-10-06T12:34:25.017" Score="1" ViewCount="48" Body="&lt;p&gt;How can I open a page from buffer below or to the right of the page I'm already viewing?&#xA;By the way I want to open split the whole page not only the page I'm currently in.&#xA;imagine I have to rows and I want a column to the right of both rows that contains one file so I'll get from &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_&#xA;&#xA;to:&#xA;&#xA; |_&#xA; |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the new file is opened from buffer.&#xA;actually I would love to know the general answer for how to kinda temporarily group some splits together and add a new split below them as a whole or to the right of them as a whole.&lt;/p&gt;&#xA;" OwnerUserId="14609" LastEditorUserId="14609" LastEditDate="2017-10-06T12:52:15.640" LastActivityDate="2017-10-12T15:22:32.263" Title="How to split the page adding a page from buffer (combining :sp/vs with :b)" Tags="|split|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13837" PostTypeId="2" ParentId="13823" CreationDate="2017-10-06T12:53:12.973" Score="2" Body="&lt;p&gt;That sounds like a perfect use case for my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3844&quot; rel=&quot;nofollow noreferrer&quot;&gt;SpellCheck plugin&lt;/a&gt;: It provides a &lt;code&gt;:SpellCheck&lt;/code&gt; command that puts all spelling errors into the &lt;em&gt;quickfix list&lt;/em&gt;. You can review them there and directly add them into spell files via overloaded &lt;code&gt;zg&lt;/code&gt;, &lt;code&gt;zw&lt;/code&gt;, etc. mappings.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2017-10-06T12:53:12.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13838" PostTypeId="2" ParentId="13836" CreationDate="2017-10-06T12:56:04.323" Score="2" Body="&lt;p&gt;two steps:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:sp newfile&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and then press&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;J&lt;/code&gt;   rsp    &lt;code&gt;&amp;lt;c-w&amp;gt;L&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-10-06T12:56:04.323" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13839" PostTypeId="2" ParentId="13818" CreationDate="2017-10-06T13:07:56.377" Score="10" Body="&lt;p&gt;To summarize the comments and make this a full answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The general search command is shortest: &lt;code&gt;/\d&amp;lt;Enter&amp;gt;&lt;/code&gt;. You can then repeat the search with &lt;code&gt;n&lt;/code&gt; / &lt;code&gt;N&lt;/code&gt;, as usual. To skip to the next full number, not the next digit, use &lt;code&gt;/\d\+&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to clobber your search pattern, you can use the lower-level &lt;code&gt;search()&lt;/code&gt; function. As this is a lot to type, a mapping (defined in your &lt;code&gt;~/.vimrc&lt;/code&gt;) can be convenient:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;nd :call search('\d\+')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unlike the built-in search commands, this doesn't yet support a &lt;code&gt;[count]&lt;/code&gt; to skip some numbers. A robust implementation would need several lines of Vimscript. Alternatively, you can use my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3130&quot; rel=&quot;noreferrer&quot;&gt;CountJump plugin&lt;/a&gt; to generate mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call CountJump#Motion#MakeBracketMotion('', 'd', '', '\d\+', '', 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This defines &lt;code&gt;[d&lt;/code&gt; and &lt;code&gt;]d&lt;/code&gt; mappings that jump to the previous / next start of a number, with an optional &lt;code&gt;[count]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2017-10-06T13:07:56.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13840" PostTypeId="2" ParentId="11668" CreationDate="2017-10-06T13:31:52.503" Score="3" Body="&lt;p&gt;This is most likely because you are using the CLI. In CLI Cntrl + Left doenst work natively in VIM. I am using TMUX/SSH into UBUNTU installed in a virtualbox on windows 10, similar to your situation (no X-server running on my Windows 10). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cntrl+left/right doesnt work when I log in using TMUX/SSH (with no Xserver), however when I use the VIM on the UBUNTU GUI, it does work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the UBUNTU GUI.&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2017-10-06T13:31:52.503" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13841" PostTypeId="2" ParentId="13818" CreationDate="2017-10-06T14:05:42.720" Score="11" Body="&lt;p&gt;&lt;kbd&gt;Ctrl+A&lt;/kbd&gt; and &lt;kbd&gt;Ctrl+X&lt;/kbd&gt; will both jump the cursor to the next number on the line.&lt;/p&gt;&#xA;&lt;p&gt;However, the former will increment the number and the latter will decrement it. You don't want to make any changes, so you have the following options to quickly jump to the next number on the line.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+A&lt;/kbd&gt;&lt;kbd&gt;Ctrl+X&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+X&lt;/kbd&gt;&lt;kbd&gt;Ctrl+A&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2021-06-28T21:26:45.067" LastActivityDate="2021-06-28T21:26:45.067" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="13843" PostTypeId="1" AcceptedAnswerId="13982" CreationDate="2017-10-06T15:30:36.377" Score="0" ViewCount="217" Body="&lt;p&gt;We often run with multiple ruby versions and often I have to recompile YCM when I switch as sometimes I get errors like segfaults or can't find ruby. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering, how do I get YCM to compile by linking to ruby via the shim so that no matter which version of ruby is running it should (theoretically) link to the current one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is there a better (read correct) way to deal with this for YCM?&lt;/p&gt;&#xA;" OwnerUserId="11603" LastActivityDate="2017-10-23T12:27:17.090" Title="how to link YCM through ruby shims that rbenv provide" Tags="|plugin-you-complete-me|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13844" PostTypeId="1" AcceptedAnswerId="13847" CreationDate="2017-10-06T16:18:00.547" Score="1" ViewCount="1182" Body="&lt;p&gt;Here is the vundle part of my vimrc file(I'm omitting the rest to have a minimal q, ask me to put the rest if you think it's needed):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; required                                                                                                                                              &#xA;filetype off                  &quot; required                                                                                                                                              &#xA;&#xA;&quot; set the runtime path to include Vundle and initialize                                                                                                                                &#xA;set rtp+=~/.vim/bundle/Vundle.vim                                                                                                                                                      &#xA;call vundle#begin()                                                                                                                                                                    &#xA;&#xA;&quot; alternatively, pass a path where Vundle should install plugins                                                                                                                       &#xA;&quot;call vundle#begin('~/some/path/here')                                                                                                                                                 &#xA;&#xA;&quot; let Vundle manage Vundle, required                                                                                                                                                   &#xA;Plugin 'gmarik/Vundle.vim'                                                                                                                                                             &#xA;&#xA;&quot; Add all your plugins here (note older versions of Vundle used Bundle instead of Plugin)                                                                                              &#xA;Plugin 'vim-scripts/indentpython.vim'                                                                                                                                                  &#xA;Plugin 'tmhedberg/SimpylFold'                                                                                                                                                          &#xA;Plugin 'Valloric/YouCompleteMe'                                                                                                                                                        &#xA;&#xA;&#xA;&quot; All of your Plugins must be added before the following line                                                                                                                          &#xA;call vundle#end()            &quot; required                                                                                                                                                &#xA;filetype plugin indent on    &quot; required &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I run :PluginInstall I only get the first one installed except for the vundle itself.&#xA;Here is the output I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Installing plugins to /home/aran/.vim/bundle                                                                                                                                          &#xA;. Plugin 'gmarik/Vundle.vim'                                                                                                                                                             &#xA;. Plugin 'tmhedberg/SimpylFold'                                                                                                                                                          &#xA;* Helptags  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14609" LastActivityDate="2018-02-02T08:51:50.943" Title="can't install some plugins with vundle" Tags="|plugin-vundle|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13845" PostTypeId="1" CreationDate="2017-10-06T20:39:25.417" Score="-5" ViewCount="174" Body="&lt;p&gt;I need to know how to reindent the code with syntastic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call Retab()   ## it is showing it's invalid&#xA;:call GetPythonIndent(v:lnum)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need a plugin support.Plz don't provide code for .vimrc.&lt;/p&gt;&#xA;" OwnerUserId="14615" LastActivityDate="2017-10-07T03:28:15.747" Title="What is the command for indenting code in vim with syntastic plugin?" Tags="|help-system|" AnswerCount="1" CommentCount="4" ClosedDate="2017-10-08T19:07:11.997" ContentLicense="CC BY-SA 3.0" />
  <row Id="13847" PostTypeId="2" ParentId="13844" CreationDate="2017-10-07T03:20:32.503" Score="1" Body="&lt;p&gt;Try to change your &lt;code&gt;Plugin 'gmarik/Vundle.vim'&lt;/code&gt; to &lt;code&gt;Plugin 'VundleVim/Vundle.vim'&lt;/code&gt; and reinstall VundleVim from: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'gmarik/Vundle.vim'&lt;/code&gt; is now hosted as &lt;code&gt;'VundleVim/Vundle.vim'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(From &lt;code&gt;Vundle.vim&lt;/code&gt;s &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim/blob/master/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;README&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="14380" LastEditorUserId="-1" LastEditDate="2018-02-02T08:51:50.943" LastActivityDate="2018-02-02T08:51:50.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13848" PostTypeId="2" ParentId="13845" CreationDate="2017-10-07T03:28:15.747" Score="1" Body="&lt;p&gt;You should be able to use vims built in auto-indentation with the command (from normal mode type the following):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg=G&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may also like to ensure you have set the necessary settings in your &lt;code&gt;.vimrc&lt;/code&gt; so your indentation is how you want it (eg &lt;code&gt;shiftwidth&lt;/code&gt; &lt;code&gt;tabstop&lt;/code&gt; &lt;code&gt;expandtab&lt;/code&gt; etc) &lt;/p&gt;&#xA;" OwnerUserId="14380" LastActivityDate="2017-10-07T03:28:15.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13849" PostTypeId="2" ParentId="13833" CreationDate="2017-10-07T11:33:42.737" Score="1" Body="&lt;p&gt;I've found the issue, basically keywords can't be contained in other matches, pythonBuiltin is keyword.&lt;br&gt;&#xA;:help syn-containedin, it has quote:&lt;br&gt;&#xA;&lt;code&gt;Don't forget that keywords never contain another item, thus adding them to &quot;containedin&quot; won't work.&#xA;&lt;/code&gt;&lt;br&gt;&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/27682324/set-item-to-higher-highlight-priority-on-vim/43183947&quot;&gt;here&lt;/a&gt; for more discussion. &lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2017-10-07T11:33:42.737" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13850" PostTypeId="1" AcceptedAnswerId="13852" CreationDate="2017-10-07T14:48:17.343" Score="2" ViewCount="4907" Body="&lt;p&gt;I am using Vim 7 on Ubuntu 16.04 (gnome) and the terminal emulator I am using is terminator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really like the aristocrat/brogrammer colorscheme for Python and so I copy-pasted it in &lt;code&gt;~/.vim/colors/brogrammer.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now here's my problem: when I run vim inside terminal and then set colorscheme to brogrammer then I get ugly black &amp;amp; white look, like so&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eabxb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eabxb.png&quot; alt=&quot;ugly&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;on the contrary, if I press &lt;code&gt;super&lt;/code&gt;, type &lt;code&gt;vim&lt;/code&gt; (i.e. if I launch it as a program from dash and not by typing &lt;code&gt;vim&lt;/code&gt; in terminal) and then set colorscheme to brogrammer I get beautiful colors, like so&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9lwFC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9lwFC.png&quot; alt=&quot;nice&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Why is this happening? what can I do to show those beautiful colors even when launched from terminal?&lt;/p&gt;&#xA;" OwnerUserId="2306" LastActivityDate="2017-10-10T15:04:52.840" Title="Vim in terminal is black-&amp;-white but vim launched from dash shows colors" Tags="|syntax-highlighting|colorscheme|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13852" PostTypeId="2" ParentId="13850" CreationDate="2017-10-07T15:41:29.313" Score="1" Body="&lt;p&gt;Upon closer inspection I found that the vim instance showing correct colors was in fact being run on gnome-terminal, as seen by &lt;code&gt;ps aux | grep -i term&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Evidently, the problem can be sorted by explicitly setting &lt;code&gt;t_Co&lt;/code&gt; to 256 in the color scheme's &lt;code&gt;.vim&lt;/code&gt; file so as to ensure consistent behavior across all terminal emulators supporting 256+ colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;why is this happening&lt;/em&gt;&lt;/strong&gt;: different terminal emulators default to different color bit ranges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;what can I do...&lt;/em&gt;&lt;/strong&gt;: Two possible solutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;In your .bashrc or .zshrc or whatever, set &lt;code&gt;TERM&lt;/code&gt; such that it ends with &lt;code&gt;-256color&lt;/code&gt;, something like &lt;code&gt;set TERM=xterm-256color&lt;/code&gt; (thanks to &lt;a href=&quot;https://answers.launchpad.net/terminator/+question/212170&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; and @Rich)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or, if you don't what to mess with terminal's settings; open the desired color scheme's .vim file and add the line &lt;code&gt;set t_Co=256&lt;/code&gt; near the top&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2306" LastEditorUserId="2306" LastEditDate="2017-10-10T15:04:52.840" LastActivityDate="2017-10-10T15:04:52.840" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13853" PostTypeId="1" AcceptedAnswerId="13857" CreationDate="2017-10-07T16:59:07.520" Score="3" ViewCount="725" Body="&lt;p&gt;Every time I switch back and forth between two buffers, vim tries to re-load some file specific commands.  The error message is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E174: Command already exists: add ! to replace it`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using filetype plugins to handle different preferences and commands for every time of file that I work with.  For example, I have the following code set up in my &lt;code&gt;~/.vim/ftplugin/c.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Build Shortcut&#xA;command CompileC !gcc %:p -o %:r&#xA;noremap &amp;lt;Leader&amp;gt;cc &amp;lt;esc&amp;gt;:CompileC&amp;lt;CR&amp;gt;&#xA;&#xA;command RunC !./%:r&#xA;noremap &amp;lt;Leader&amp;gt;rr &amp;lt;esc&amp;gt;:RunC&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have only a rough understanding that vim needs a &lt;code&gt;autocmd!&lt;/code&gt; to clear the previous autocommand group, but I do not know where to put this.  Can anyone help?&lt;/p&gt;&#xA;" OwnerUserId="14354" LastActivityDate="2017-10-08T02:59:45.477" Title="Are commands in filetype plugins rerun every time the buffer is loaded?" Tags="|autocmd|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13854" PostTypeId="1" AcceptedAnswerId="13856" CreationDate="2017-10-07T17:28:44.793" Score="1" ViewCount="393" Body="&lt;p&gt;Some console editors distinguish between &quot;inserting a newline&quot; and &quot;inserting a newline + matching the level of indentation of the current line&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, the editor &lt;code&gt;mg&lt;/code&gt; distinguishes between &lt;code&gt;C-j&lt;/code&gt; (which matches the previous level of indentation) and &lt;code&gt;C-m&lt;/code&gt; (which just inserts a &lt;code&gt;\n&lt;/code&gt;) in C mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GNU Emacs (which &lt;code&gt;mg&lt;/code&gt; is emulating) does more sophisticated stuff to determine the appropriate level of indentation, but I like the simple &quot;just use the indentation level of the previous line&quot; of mg.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the buffer consists of (where &lt;code&gt;.&lt;/code&gt; is space)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.....a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then hitting &lt;code&gt;C-j&lt;/code&gt; will do...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.....a&#xA;.....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was wondering if there's a way (particularly a built-in way) to get the same indentation-matching behavior in vim when I hit &lt;code&gt;C-j&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a utility function for extracting whitespace characters from the beginning of a numbered line, but I can't figure out how to package it into a command that grabs the corresponding characters from the current line, inserts a newline, and then inserts the whitespace prefix from the original line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetIndentationPrefix(linum)&#xA;    let line = getline(a:linum)&#xA;    let index = 0&#xA;    let target = strlen(line)&#xA;    let whitespace_prefix = ''&#xA;    while index &amp;lt;# target&#xA;        if line[index] ==# ' '&#xA;            let whitespace_prefix = whitespace_prefix . ' '&#xA;        elseif line[index] ==# '\t'&#xA;            let whitespace_prefix = whitespace_prefix . '\t'&#xA;        else&#xA;            break&#xA;        endif&#xA;        let index = index + 1&#xA;    endwhile&#xA;    return whitespace_prefix&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2017-10-07T17:34:08.647" LastActivityDate="2017-10-07T18:17:29.377" Title="Duplicate indentation of current line" Tags="|key-bindings|vimscript|indentation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13855" PostTypeId="2" ParentId="13854" CreationDate="2017-10-07T17:44:20.627" Score="1" Body="&lt;p&gt;If you &lt;code&gt;set ai&lt;/code&gt;, then &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt; (in insert mode) will do what you want.&#xA;If you want the Enter-Key to behave differently then you also can&#xA;&lt;code&gt;:inoremap &amp;lt;cr&amp;gt; &amp;lt;cr&amp;gt;0&amp;lt;c-d&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="11477" LastEditDate="2017-10-07T18:17:29.377" LastActivityDate="2017-10-07T18:17:29.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13856" PostTypeId="2" ParentId="13854" CreationDate="2017-10-07T17:44:57.693" Score="2" Body="&lt;p&gt;If you have &lt;code&gt;set cindent&lt;/code&gt; or &lt;code&gt;set autoindent&lt;/code&gt;, vim actually does match indent when you press &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt;.  But it also does when you press &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;. To circumvent this you could make a mapping like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;cr&amp;gt; &amp;lt;cr&amp;gt;&amp;lt;c-o&amp;gt;i&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt; will match indent, but &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; won't.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-10-07T17:44:57.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13857" PostTypeId="2" ParentId="13853" CreationDate="2017-10-07T18:03:54.547" Score="4" Body="&lt;p&gt;Every time a new or existing file, &lt;em&gt;which is not already open in a loaded buffer&lt;/em&gt;, is &lt;code&gt;:edit&lt;/code&gt;ed or otherwise opened, vim triggers the FileType autocommand and runs the scripts in &lt;code&gt;/ftplugin/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix your error merely replace &lt;code&gt;command&lt;/code&gt; with &lt;code&gt;command!&lt;/code&gt;.  It is also a good idea to use the &lt;code&gt;-buffer&lt;/code&gt; flag to make buffer local commands.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-10-08T02:57:18.050" LastActivityDate="2017-10-08T02:57:18.050" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13858" PostTypeId="1" CreationDate="2017-10-07T21:03:41.467" Score="-1" ViewCount="121" Body="&lt;p&gt;I have a file with 48 lines like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0.00000&#xA;0.00621&#xA;0.16298&#xA;0.19977&#xA;0.40198&#xA;0.29450&#xA;0.49277&#xA;0.28054&#xA;0.43256&#xA;0.18729&#xA;0.28934&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to prepend &lt;code&gt;d.ddddddd,&lt;/code&gt; to each line, each &lt;code&gt;d&lt;/code&gt; represents a digit (so the calculation should be rounded).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The number prepended is calculated as &lt;code&gt;n/48000&lt;/code&gt; where &lt;code&gt;n&lt;/code&gt; is the greatest integer less than the line number (0-indexed, the first line should have 0 prepended)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should end up looking like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0.0000000,0.00000&#xA;0.0000208,0.00621&#xA;0.0000417,0.16298&#xA;0.0000625,0.19977&#xA;0.0000833,0.40198&#xA;0.0001042,0.29450&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="1841" LastEditDate="2017-10-09T08:44:15.893" LastActivityDate="2017-10-09T10:02:45.297" Title="Prepend &quot;number,&quot; to each line, where number is calculated from nth term" Tags="|substitute|line-numbers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13859" PostTypeId="2" ParentId="13853" CreationDate="2017-10-07T21:13:47.717" Score="1" Body="&lt;p&gt;Ftplugins aren't loaded when you switch between buffers. They are loaded only when you open a buffer for the first time, or if you change it's filetype. It's easy to check. Add some &lt;code&gt;:echomsg&lt;/code&gt; in your ftplugins, and play with buffers. As a rule, by default ftplugins are loaded only once per buffer: when the buffer is opened/created -- or when we execute &lt;code&gt;:e (foo.ft)&lt;/code&gt; from  &lt;code&gt;foo.ft&lt;/code&gt; buffer, otherwise &lt;code&gt;:edit&lt;/code&gt; won't trigger filetype autocommands when editing a buffer already opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I stand corrected, thanks @Mass. What I describe regarding the behaviour of &lt;code&gt;:e&lt;/code&gt; is a consequence of &lt;code&gt;set hidden&lt;/code&gt; in my .vimrc. Switching buffers by switching windows doesn't seems to be impacted by &lt;code&gt;'hidden'&lt;/code&gt;, I observe it doesn't trigger any filetype autocommand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you define global stuff in your filetype plugin, well, it gets redefined every time the ftplugin gets loaded. If you open a java ftplugin where &lt;code&gt;&amp;lt;Leader&amp;gt;cc&lt;/code&gt; is mapped to execute &lt;code&gt;javac&lt;/code&gt;, you'd loose you mapping for compiling C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fix is easy: never define global things in ftplugins. &lt;a href=&quot;https://vi.stackexchange.com/a/11701/626&quot;&gt;Define only local things&lt;/a&gt;. The mappings shall be buffer local, as well as the commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, your mappings won't take advantage of one of the earlier feature of vim (compared to vi): the quickfix feature. Unless you make program is improperly configured (like the one shipped with mingw), &lt;a href=&quot;https://stackoverflow.com/a/21477312/15934&quot;&gt;you just need &lt;code&gt;:make %&amp;lt;&lt;/code&gt; to compile mono-file projects&lt;/a&gt;. It'll works with C++, C, fortran...&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-10-08T02:59:45.477" LastActivityDate="2017-10-08T02:59:45.477" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13860" PostTypeId="2" ParentId="6194" CreationDate="2017-10-07T21:19:15.910" Score="11" Body="&lt;p&gt;The difference between the behavior of the motion in &lt;code&gt;cw&lt;/code&gt; vs. &lt;code&gt;dw&lt;/code&gt; can be explained simply: normally if you want to change a word you're going to leave the whitespace following it, while deleting a word suggests you want the whitespace to also be removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do want the whitespace to go away for some reason (I do it regularly enough but can't think of an example) then use the &lt;code&gt;aw&lt;/code&gt; motion: &lt;code&gt;caw&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2017-10-07T21:19:15.910" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13861" PostTypeId="1" CreationDate="2017-10-08T00:03:55.507" Score="1" ViewCount="62" Body="&lt;p&gt;I have this sample:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xtvrM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xtvrM.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I expect &lt;code&gt;arg3&lt;/code&gt; to be colored green as &lt;code&gt;arg1&lt;/code&gt;, &lt;code&gt;arg2&lt;/code&gt; and &lt;code&gt;FunCall&lt;/code&gt; with my current setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match pyFun &quot;xxxx&quot; contains=xxx&#xA;syn region pyFunCall start=&quot;(&quot; end=&quot;)&quot; contained contains=xxxx transparent keepend&#xA;syn match pyFunCallParams &quot;xxx&quot; contained contains=xxxx skipwhite&#xA;syn match pyFunCallParam &quot;xxx&quot; contained contains=xxx skipwhite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess with the above, a match starts with &lt;code&gt;(&lt;/code&gt; from &lt;code&gt;myFunc&lt;/code&gt; then it matches &lt;code&gt;)&lt;/code&gt; of &lt;code&gt;FunCall&lt;/code&gt; and ends the region, so &lt;code&gt;arg3&lt;/code&gt; is actually out of match and I can't highlight it.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how can I ignore &lt;code&gt;()&lt;/code&gt; inside my pyFunCall, I appended &lt;code&gt;transparent&lt;/code&gt; but it didn't work.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="1841" LastEditDate="2017-10-09T08:39:24.307" LastActivityDate="2017-10-09T08:39:24.307" Title="Match through nested function" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13862" PostTypeId="1" AcceptedAnswerId="13877" CreationDate="2017-10-08T03:40:30.920" Score="6" ViewCount="2055" Body="&lt;p&gt;I have the following bindings in my &lt;code&gt;~/.vimrc&lt;/code&gt; to make it easier to &quot;disengage&quot; some of my insert-mode key-bindings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example. &lt;code&gt;`&lt;/code&gt; for &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt; and &lt;code&gt;``&lt;/code&gt; to enter a literal &lt;code&gt;`&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap ` &amp;lt;Nop&amp;gt;&#xA;inoremap `` `&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the most part this works pretty well. However, when inserting &lt;code&gt;`&lt;/code&gt; normally and then allowing the possible-completion to time out I can't enter &lt;code&gt;``&lt;/code&gt; for a literal &lt;code&gt;`&lt;/code&gt; anymore. Nothing happens. I can insert other characters like &lt;code&gt;a&lt;/code&gt; just fine though. (I tested this with only the above file as my &lt;code&gt;.vimrc&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if instead of &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt; I use a different do-nothing command combination like &lt;code&gt;&amp;lt;esc&amp;gt;a&lt;/code&gt;, then I don't see this behavior at all.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap ` &amp;lt;esc&amp;gt;a&#xA;inoremap `` `&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this configuration, I can type a &lt;code&gt;`&lt;/code&gt;, wait for it to time out, and then type &lt;code&gt;``&lt;/code&gt; ... and the result will be a &lt;code&gt;`&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does the first example have this odd behavior?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2017-10-08T06:50:48.167" LastActivityDate="2017-10-10T04:45:33.177" Title="Using a no-op key in insert mode, can't use key after using no-op mapping" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13863" PostTypeId="2" ParentId="6558" CreationDate="2017-10-08T08:09:46.950" Score="6" Body="&lt;p&gt;Add this to your .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('python3')&#xA;    let g:gundo_prefer_python3 = 1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was getting similar error. The above worked for me (I am using Manjaro Linux, and installed community/python-neovim (Python 3 client for neovim)). Found at &lt;a href=&quot;https://bitbucket.org/sjl/gundo.vim/issues/42/about-python3-support&quot; rel=&quot;noreferrer&quot;&gt;https://bitbucket.org/sjl/gundo.vim/issues/42/about-python3-support&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14592" LastEditorUserId="14592" LastEditDate="2017-10-08T08:14:53.887" LastActivityDate="2017-10-08T08:14:53.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13864" PostTypeId="1" AcceptedAnswerId="13874" CreationDate="2017-10-08T14:07:55.437" Score="9" ViewCount="2405" Body="&lt;p&gt;Following this good &lt;a href=&quot;https://til.hashrocket.com/posts/17c44eda91&quot; rel=&quot;noreferrer&quot;&gt;piece of advice&lt;/a&gt;, I have added these lines to my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup AutoSaveFolds&#xA;  autocmd!&#xA;  autocmd BufWinLeave * mkview&#xA;  autocmd BufWinEnter * silent loadview&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does work and my folds are saved. But I get this error now each time I open a unnamed buffer with;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabnew&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or each time I navigate to help with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabhelp vim&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the following message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing BufWinEnter Auto commands for &quot;*&quot;:&#xA;E32: No file name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why do I get this?&lt;br&gt;&#xA;How to prevent it while still getting my folds automately saved?&lt;/p&gt;&#xA;" OwnerUserId="2978" LastEditorUserId="2978" LastEditDate="2017-10-09T08:40:48.370" LastActivityDate="2021-07-12T00:44:10.290" Title="BufWinLeave * mkview with unnamed file: Error 32" Tags="|buffers|autocmd|error|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13865" PostTypeId="1" CreationDate="2017-10-08T14:35:23.440" Score="0" ViewCount="367" Body="&lt;p&gt;I just installed &lt;code&gt;kotlin-vim&lt;/code&gt; plugin.&#xA;The plugin looks like using 8-spaces indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I change it 4-spaces indentation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(To indent all codes I used &lt;code&gt;gg=G&lt;/code&gt;. Maybe I'm using wrong way for indent all the text.)&lt;/p&gt;&#xA;" OwnerUserId="14629" LastEditorUserId="51" LastEditDate="2018-03-08T06:05:50.123" LastActivityDate="2018-03-08T06:05:50.123" Title="How to change 4-space indentation when using &quot;kotlin-vim` plugin" Tags="|indentation|" AnswerCount="1" CommentCount="2" ClosedDate="2018-03-08T06:06:47.593" ContentLicense="CC BY-SA 3.0" />
  <row Id="13866" PostTypeId="1" CreationDate="2017-10-08T19:17:57.977" Score="4" ViewCount="446" Body="&lt;p&gt;I work remotely via ssh on my dev machine which runs a tmux. I want to pipe the output of the Gbrowse back to my laptop. Is there any reasonable way to do that.&lt;/p&gt;&#xA;" OwnerUserId="14631" LastActivityDate="2018-01-10T07:41:16.873" Title="Fugitive Gbrowse while being ssh on a server" Tags="|tmux|plugin-fugitive|ssh|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13867" PostTypeId="1" AcceptedAnswerId="13870" CreationDate="2017-10-08T21:50:08.653" Score="1" ViewCount="277" Body="&lt;p&gt;I've tried &lt;code&gt;:help i_CTRL-G_CTRL-G&lt;/code&gt; and &lt;code&gt;:helpgrep CTRL-G&lt;/code&gt; more generally and can't figure out why &lt;code&gt;&amp;lt;c-g&amp;gt;&amp;lt;c-g&amp;gt;&lt;/code&gt; is equivalent to a &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some context, I was having problems with the mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ` &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it was suggested in a comment here: &lt;a href=&quot;https://vi.stackexchange.com/questions/13862/using-a-no-op-key-in-insert-mode-cant-use-key-after-using-no-op-mapping&quot;&gt;Using a no-op key in insert mode, can&amp;#39;t use key after using no-op mapping&lt;/a&gt;&#xA;That I should use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ` &amp;lt;c-g&amp;gt;&amp;lt;c-g&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this workaround the problem is avoided, but I can't figure out why it works. In particular, I'm trying to understand how &lt;code&gt;&amp;lt;c-g&amp;gt;&amp;lt;c-g&amp;gt;&lt;/code&gt; duplicates some or perhaps all of the observable behavior of &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; ... while simultaneously hitting a different enough codepath to avoid triggering the bug.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-10-09T08:21:46.047" Title="Is &lt;c-g&gt;&lt;c-g&gt; equivalent to &lt;nop&gt; in insert mode?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13868" PostTypeId="2" ParentId="13865" CreationDate="2017-10-09T01:34:58.420" Score="0" Body="&lt;p&gt;After the plugin calls in your &lt;code&gt;.vimrc&lt;/code&gt; have a selection of the following (depending on desired configuration):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4     // how tabs are displayed&#xA;set shiftwidth=4  // how far a shift moves a line&#xA;set softtabstop=4 // how many spaces are inserted by pressing tab*&#xA;set expandtab     // insert tabs as spaces&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;* if you are inserting tabs after text it will insert up to &lt;code&gt;softtabstop&lt;/code&gt; spaces until the number of characters on the line is a multiple of &lt;code&gt;softtabstop&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14380" LastActivityDate="2017-10-09T01:34:58.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13870" PostTypeId="2" ParentId="13867" CreationDate="2017-10-09T08:21:46.047" Score="3" Body="&lt;p&gt;As you saw in your search &lt;code&gt;:help i_CTRL-G_CTRL-G&lt;/code&gt; doesn't exist. It simply means that by default it is mapped to nothing thus pressing &lt;kbd&gt;CTRL-G&lt;/kbd&gt;&lt;kbd&gt;CTRL-G&lt;/kbd&gt; will do nothing which is equivalent to &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In their comment @Mass said it is a workaround: you are abusing the fact that &lt;kbd&gt;CTRL-G&lt;/kbd&gt;&lt;kbd&gt;CTRL-G&lt;/kbd&gt; does nothing to replicate the behavior of &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; without sending the &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; keycode. You could get the equivalent with basically any nonexisting mapping like &lt;code&gt;&amp;lt;c-g&amp;gt;&amp;lt;c-a&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;c-g&amp;gt;&amp;lt;c-b&amp;gt;&lt;/code&gt;, etc&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-10-09T08:21:46.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13871" PostTypeId="2" ParentId="13858" CreationDate="2017-10-09T10:02:45.297" Score="2" Body="&lt;p&gt;Not sure, I understand exactly want you are trying to achieve. But given your test data, I came up with the following substitution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s#.*#\=printf(&quot;%.07f,%s&quot;, ((line('.')-1)/48000.0), submatch(0))&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which uses the substitution command and prepends the result of (dividing line number -1, &lt;code&gt;(line('.')-1)&lt;/code&gt;) by 48000 to each line and formats it to 7 digits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This needs a vim with &lt;code&gt;+float&lt;/code&gt; feature.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-10-09T10:02:45.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13872" PostTypeId="1" AcceptedAnswerId="13873" CreationDate="2017-10-09T11:40:28.453" Score="4" ViewCount="1782" Body="&lt;p&gt;Hopefully, the solution is efficient if it exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A solution that tests if it is a vim builtin command suffices.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; To answer @Xiong Chiamiov comment, here is what I do in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;br&gt;&#xA;basically &lt;strong&gt;get input, then run command, capture and put&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;M-x&amp;gt; :&amp;lt;C-u&amp;gt;call GetInputCommandThenCaptureAndPut()&amp;lt;CR&amp;gt;&#xA;&#xA;func! GetInput()    &quot; https://stackoverflow.com/a/15274117/3625404&#xA;    call inputsave()&#xA;    let cmd = input('ex-command to execute: ')&#xA;    call inputrestore()&#xA;    return cmd&#xA;endfunc&#xA;func! GetInputCommandThenCaptureAndPut()&#xA;    &quot; cmdline keymap works, eg, &amp;lt;C-k&amp;gt; to get last input, &amp;lt;C-f&amp;gt; to open edit window, &amp;lt;C-r&amp;gt; insert register.&#xA;    let cmd = GetInput()&#xA;    if cmd =~ '^\s*!'   &quot; eg, '!ls', '!ll', redraw needed.&#xA;        exec 'r'.cmd&#xA;        redraw!&#xA;    elseif cmd =~ '^ [[.a-zA-z0-9].*'    &quot; one space before shell command, add '!', then run and read.&#xA;        exec 'r!' cmd&#xA;    elseif cmd =~ '^    [[.a-zA-z0-9].*'  &quot; leading '&amp;lt;Tab&amp;gt;' key, execute shell command, witout capture.&#xA;        exec '!' cmd&#xA;    else&#xA;        if strlen(cmd) == 1     &quot; customized shortcut&#xA;            if cmd == 's'&#xA;                let cmd = 'scr'&#xA;            elseif cmd == 'k' || cmd == 'm'   &quot; :k is alias of :mark&#xA;                let cmd = 'marks'&#xA;            endif&#xA;        elseif cmd =~ '^\s*''\(\w*\)''\?\s*$'   &quot; option start with single quote, closing one optional.&#xA;            let cmd = 'set '. substitute(cmd, '^\s*''\(\w*\)''\?\s*$', '\1', '').'?'&#xA;            &quot; let cmd = 'set '.cmd.'?'&#xA;        endif&#xA;        let command = matchstr(cmd, '\w\+')&#xA;        if exists(':'.command)&#xA;            call PutAfterCapture(cmd)&#xA;        else    &quot; not ex command, try run and read shell command.&#xA;            exec 'r!'.cmd&#xA;            redraw!&#xA;        endif&#xA;    endif&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;PutAfterCapture()&lt;/code&gt; is as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! Capture(excmd) abort  &quot; from tpope's scriptease.vim&#xA;try&#xA;    redir =&amp;gt; out&#xA;    exe 'silent! '.a:excmd&#xA;finally&#xA;    redir END&#xA;endtry&#xA;return out&#xA;endfunc&#xA;&#xA;func! PutAfterCapture(command)&#xA;    if a:command =~ '^\s*$'&#xA;        return&#xA;    endif&#xA;    let oldpos = getpos('.')&#xA;    silent! let @c = Capture(a:command)&#xA;    call setpos('.', oldpos)&#xA;    put c&#xA;    call setpos('.', oldpos)&#xA;endfunc!&#xA;&#xA;command! -bar -nargs=+ Icapture call PutAfterCapture(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The workflow is type &lt;code&gt;&amp;lt;M-x&amp;gt;&lt;/code&gt;, then type the cmd to run and capture.&lt;/strong&gt;  &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; is handy for longer input here, &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; works too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ls&lt;/code&gt; -- list of open buffers  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Space&amp;gt;ls&lt;/code&gt; or &lt;code&gt;!ls&lt;/code&gt;  -- list of files in current directory  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s&lt;/code&gt; -- vim files being sourced  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;m&lt;/code&gt; -- marks  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Tab&amp;gt;bc&lt;/code&gt; -- use &lt;code&gt;bc&lt;/code&gt; calculator interactively&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="205" LastEditDate="2017-10-12T03:55:46.697" LastActivityDate="2017-10-12T03:55:46.697" Title="How to test if a string is a vim command?" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13873" PostTypeId="2" ParentId="13872" CreationDate="2017-10-09T12:15:59.630" Score="13" Body="&lt;p&gt;I you only need to know if it is a built-in command, you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exists(':yourstring')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#exists()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h exists()&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="14637" LastEditorUserId="1841" LastEditDate="2017-10-09T14:14:10.160" LastActivityDate="2017-10-09T14:14:10.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13874" PostTypeId="2" ParentId="13864" CreationDate="2017-10-09T12:25:04.570" Score="25" Body="&lt;p&gt;Switching to &lt;code&gt;?*&lt;/code&gt; as the regex will no longer match empty file names. I actually recommend you switch to the following, which is a corresponding block of &lt;code&gt;.vimrc&lt;/code&gt; that has been tweaked to suppress many of the errors you are likely to encounter when following the referenced advice.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup AutoSaveGroup&#xA;  autocmd!&#xA;  &amp;quot; view files are about 500 bytes&#xA;  &amp;quot; bufleave but not bufwinleave captures closing 2nd tab&#xA;  &amp;quot; nested is needed by bufwrite* (if triggered via other autocmd)&#xA;  &amp;quot; BufHidden for compatibility with `set hidden`&#xA;  autocmd BufWinLeave,BufLeave,BufWritePost,BufHidden,QuitPre ?* nested silent! mkview!&#xA;  autocmd BufWinEnter ?* silent! loadview&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;code&gt;BufWritePost&lt;/code&gt; event (+ &lt;code&gt;nested&lt;/code&gt;) can be left out if you prefer, though you will experience no penalty for leaving it in.&lt;/p&gt;&#xA;&lt;p&gt;Furthermore, I use&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set viewoptions=folds,cursor&#xA;set sessionoptions=folds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13731" LastEditorUserId="13731" LastEditDate="2021-07-12T00:44:10.290" LastActivityDate="2021-07-12T00:44:10.290" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="13875" PostTypeId="1" CreationDate="2017-10-09T14:08:49.640" Score="0" ViewCount="346" Body="&lt;p&gt;Some of the times I use YouCompleteMe, Vim 'half-crashes': I cannot continue coding in the current tab, but switching tab and coming back solves the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The autocompletion works about 80% of the time, 20% of the time it crashes. It happens in two different computers, although both are running Ubuntu 16.04 with the same bashrc and same vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just before pressing tab to autocomplete it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/edVe3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/edVe3.png&quot; alt=&quot;Just before&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just after pressing tab it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GST3O.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GST3O.png&quot; alt=&quot;Just after&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the mention of &lt;code&gt;/bin/bash&lt;/code&gt; and &lt;code&gt;unexpected EOF&lt;/code&gt; are pretty consistent every time it crashes. It also doesn't explicitly mention YCM so I'm not entirely sure that's the issue. It's also likely I have a problem in my vimrc but it's not mentioned in the error message either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on what to look for?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="10764" LastEditorUserId="205" LastEditDate="2017-10-10T02:28:22.323" LastActivityDate="2017-10-10T02:28:22.323" Title="Vim crashes when using autocomplete" Tags="|vimrc|autocompletion|plugin-you-complete-me|crash|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13876" PostTypeId="1" CreationDate="2017-10-09T16:41:16.570" Score="1" ViewCount="245" Body="&lt;p&gt;I currently have a skeleton file so that whenever I create a new .cpp file, it copies the c++_template.cpp to the new file. I'm using this line in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile *.cpp 0r ~/workspace_c++/c++_template.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like it to also copy the foldings. Is that possible?&lt;/p&gt;&#xA;" OwnerUserId="14643" LastActivityDate="2017-10-09T22:18:52.623" Title="Vim template/skeleton with folding" Tags="|folding|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13877" PostTypeId="2" ParentId="13862" CreationDate="2017-10-09T17:33:05.000" Score="6" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/hardenedapple/neovim/commit/e8dff19b518dae4ad88e73dbb5b1dfc2ad5e543c&quot; rel=&quot;noreferrer&quot;&gt;hardenedapple&lt;/a&gt; has given an excellent explanation for this, and a proposed fix, but I will describe what is happening in more non-technical terms:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once a vim mapping &quot;times out,&quot; vim does not like to wait again.  Instead, at any point after timeout, it will always immediately expand the longest complete mapping entered up to that point.  Here is another &lt;a href=&quot;https://github.com/neovim/neovim/pull/6419#issuecomment-290916320&quot; rel=&quot;noreferrer&quot;&gt;example&lt;/a&gt; that displays this behavior:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap aaaa :echom 'aaaa mapping'&amp;lt;CR&amp;gt;&#xA;nnoremap bb :echom 'just to ensure timeout matters'&amp;lt;CR&amp;gt;&#xA;nmap b aaa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once &lt;code&gt;b&lt;/code&gt; times out, vim decides on &lt;code&gt;aaa&lt;/code&gt; (i.e., append &lt;code&gt;aa&lt;/code&gt;) and will not wait to see if &lt;code&gt;aaaa&lt;/code&gt; would have been possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the original &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; case this is a bigger problem because &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; expands to &lt;code&gt;''&lt;/code&gt; (i.e., empty string).  So, after timeout, when pressing &lt;code&gt;`&lt;/code&gt; vim gets into an unfortunate loop; every &lt;code&gt;`&lt;/code&gt; is consumed and expanded to &lt;code&gt;''&lt;/code&gt; empty string immediately, but the mapping does not end.  Entering something other than &lt;code&gt;`&lt;/code&gt; can end the mapping.  It nearly impossible to press &lt;code&gt;``&lt;/code&gt; quickly enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whether or not this is a bug is a matter of taste.  It appears to be a problem only when dealing with maps to &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt;.  &lt;a href=&quot;https://github.com/neovim/neovim/pull/6419#issuecomment-290925402&quot; rel=&quot;noreferrer&quot;&gt;Bram has stated&lt;/a&gt; that there is not sufficient justification for a change.  However, it is possible that he hasn't been made aware of this particular case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In support of this being called a &quot;bug,&quot; there are very few &quot;do nothing&quot; commands in insert mode- the most benign map I know of is &lt;code&gt;&amp;lt;c-g&amp;gt;&amp;lt;c-g&amp;gt;&lt;/code&gt; (really there are many nonsense commands starting with &lt;code&gt;&amp;lt;c-g&amp;gt;&lt;/code&gt;), which actually &lt;a href=&quot;https://github.com/vim/vim/blob/9b69f22e66d51d764e9ade87ae8a57ac13ab7348/src/edit.c#L8486&quot; rel=&quot;noreferrer&quot;&gt;causes beeps&lt;/a&gt;, if beeps are enabled.  An alternative fix to vim may be to introduce a new &lt;code&gt;i_&amp;lt;c-g&amp;gt;&lt;/code&gt;-prefix mapping which is documented to do nothing and cause no beeps.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-10-10T04:45:33.177" LastActivityDate="2017-10-10T04:45:33.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13878" PostTypeId="2" ParentId="13876" CreationDate="2017-10-09T17:39:39.307" Score="1" Body="&lt;p&gt;Folding will be copied if it's reproducible. If you're using &lt;code&gt;marker&lt;/code&gt;, &lt;code&gt;indent&lt;/code&gt;, &lt;code&gt;syntax&lt;/code&gt; or &lt;code&gt;expr&lt;/code&gt; folding methods, it should be reproducible automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using &lt;code&gt;manual&lt;/code&gt;, well, it means your template expander plugin will need to interpret some information and use it to fold manually. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I never though about it, but I guess it should be possible to register such a behaviour in &lt;a href=&quot;https://github.com/LucHermitte/mu-template&quot; rel=&quot;nofollow noreferrer&quot;&gt;my fork of mu-template&lt;/a&gt;. In it I can register post-expansion hooks -- that I mainly use to add missing import/include statements. If in that hooks we create manual folds. It should work. The tricky part would be the extraction of the final line numbers to call &lt;code&gt;:l1,l2fold&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like the following will work in simple cases  -- if you start to mix this with other hooks (to automate the inclusion of headers for instance), it'll quite likely require more wiring.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MuT: let s:fold_start = s:Line()&#xA;for (auto&amp;amp;&amp;amp; &amp;lt;+e+&amp;gt; : &amp;lt;+container+&amp;gt;) {&#xA;   &amp;lt;+code+&amp;gt;&#xA;}&#xA;MuT: let s:fold_end = s:Line() - 1&#xA;VimL: call s:AddPostExpandCallback('execute(s:fold_start.&quot;,&quot;.s:fold_end.&quot;fold&quot;)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Regarding the syntax used here. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;+&lt;/code&gt; and &lt;code&gt;+&amp;gt;&lt;/code&gt; delimit placeholders. Mu-template will try to evaluate it's content, otherwise they are inserted as placeholders&lt;/li&gt;&#xA;&lt;li&gt;lines starting with &lt;code&gt;:VimL&lt;/code&gt; are interpreted as Vim commands (that get interpreted with the &lt;code&gt;:execute&lt;/code&gt; command)&lt;/li&gt;&#xA;&lt;li&gt;lines starting with &lt;code&gt;:MuT&lt;/code&gt; are interpreted by mu-template engine, I use them to conditionally decide what to do, in this is case to define a variable that'll get automatically undefined at the end of the expansion.&lt;/li&gt;&#xA;&lt;li&gt;all the &lt;code&gt;s:&lt;/code&gt; functions are helper functions already implemented in mu-template that we can use to define more complex template/snippets: &lt;code&gt;s:Line()&lt;/code&gt; returns the line number where the current line in the template line will be actually inserted/expanded ; &lt;code&gt;s:AddPostExpandCallback()&lt;/code&gt; registers a hook that'll get executed after the expansion has been completed.&lt;/li&gt;&#xA;&lt;li&gt;otherwise, the text we type is directly inserted when the template file is expanded.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-10-09T22:18:52.623" LastActivityDate="2017-10-09T22:18:52.623" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13879" PostTypeId="2" ParentId="13875" CreationDate="2017-10-09T18:51:33.897" Score="1" Body="&lt;p&gt;Common issue is that you don't re-compile YCM when you upgrade it. Try   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim/bundle/YouCompleteMe&#xA;./install.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;refer &lt;a href=&quot;https://github.com/valloric/youcompleteme#ubuntu-linux-x64&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="205" LastEditDate="2017-10-10T02:27:35.987" LastActivityDate="2017-10-10T02:27:35.987" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13880" PostTypeId="2" ParentId="13822" CreationDate="2017-10-09T20:07:08.063" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;CtrlP&lt;/a&gt; should help you. Once you set it up, it is as simple as pressing Ctrl + P (or you can have custom mapping) and typing(or pasting) the name of file.&lt;/p&gt;&#xA;" OwnerUserId="13200" LastActivityDate="2017-10-09T20:07:08.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13882" PostTypeId="2" ParentId="6815" CreationDate="2017-10-10T09:51:49.660" Score="2" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/6815/mixed-color-syntax-in-vim#comment11006_6815&quot;&gt;Peter Rincker notes&lt;/a&gt;, Vim's standard markdown formatting already includes support for highlighting &lt;code&gt;r&lt;/code&gt; code within a &quot;fenced code block&quot;, and to enable it, you just have to set a global variable with code in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:markdown_fenced_languages = ['r']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, after doing so, you will find that your knitr code blocks are still not highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is because knitr uses Pandoc's formatting of info strings &lt;a href=&quot;https://github.com/rstudio/rmarkdown/issues/1073&quot; rel=&quot;nofollow noreferrer&quot;&gt;in order to differentiate R code that is to be run from a regular code block&lt;/a&gt;, and Vim's regular Markdown highlighting doesn't support this&lt;sup&gt;1&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way to fix this is to manually add an extra syntax item to match this type of code block by adding the following line to &lt;code&gt;~/.vim/after/syntax/markdown.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region markdownHighlightr matchgroup=markdownCodeDelimiter start=/^\s*```{r}.*$/ end=/^\s*```\ze\s*$/ keepend contains=@markdownHighlightr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also consider installing a Vim plugin for Pandoc highlighting, which would presumably support this out of the box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1: This can't really be considered an issue in Vim's markdown syntax file. The &lt;a href=&quot;https://daringfireball.net/projects/markdown/&quot; rel=&quot;nofollow noreferrer&quot;&gt;original Markdown syntax&lt;/a&gt; doesn't include fenced code blocks at all, and the &lt;a href=&quot;http://spec.commonmark.org/0.28/#info-string&quot; rel=&quot;nofollow noreferrer&quot;&gt;CommonMark spec&lt;/a&gt; doesn't define how info strings should be formatted.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-10-10T09:51:49.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13884" PostTypeId="2" ParentId="77" CreationDate="2017-10-10T20:33:15.813" Score="0" Body="&lt;p&gt;I wanted this so I just implemented it locally. I'm not as concerned with &quot;executing random code&quot; but this may work for simple needs. Adjust filenames as necessary.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:this_file = expand(&quot;&amp;lt;sfile&amp;gt;&quot;)&#xA;autocmd BufEnter * call LoadLocalVimrc(expand(&quot;&amp;lt;afile&amp;gt;&quot;))&#xA;&#xA;function! LoadLocalVimrc(filename)&#xA;    let l:filepath = fnamemodify(a:filename, ':h')&#xA;    let l:file = findfile(&quot;local.vimrc&quot;, l:filepath . &quot;;/&quot;)&#xA;    if l:file != ''&#xA;        execute &quot;source&quot; l:file&#xA;        execute &quot;nnoremap &amp;lt;F8&amp;gt; :$tabe &quot; . s:this_file . &quot;&amp;lt;CR&amp;gt;:sp &quot; . l:file . &quot;&amp;lt;CR&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &lt;code&gt;local.vimrc&lt;/code&gt; is actually a symlink to a file in my substantial collection of per-company vimrc files which I can keep in source control elsewhere, which makes it easy to move my whole config to other machines or if I visit a company on-site or something. Cascading configs could be used but in practice I don't need that functionality. I also wire up &lt;kbd&gt;F8&lt;/kbd&gt; to open that found file and my &quot;main&quot; &lt;code&gt;.vimrc&lt;/code&gt; in a new tab...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside those local configs, since they're parsed for every opened file, be sure to set you mappings and settings to buffer-local. E.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F3&amp;gt; :silent !p4 edit %&amp;lt;CR&amp;gt;:w!&amp;lt;CR&amp;gt;:e&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;S-F3&amp;gt; :w&amp;lt;CR&amp;gt;:silent !p4 add %&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-F3&amp;gt; :silent !p4 diff %&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;S-C-F3&amp;gt; :silent !p4vc timelapse %&amp;lt;CR&amp;gt;&#xA;&#xA;setlocal textwidth=101&#xA;setlocal noexpandtab&#xA;setlocal shiftwidth=4&#xA;setlocal tabstop=4&#xA;setlocal cinoptions=:0g0(0l1j0*700s+s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2017-10-10T20:33:15.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13885" PostTypeId="1" AcceptedAnswerId="13886" CreationDate="2017-10-11T01:06:23.333" Score="6" ViewCount="573" Body="&lt;p&gt;I have installed a lot of plugins and each may has its own ftplugin settings. What is the way to find out all ftplugin scripts that have been sourced for the current buffer?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Just to summarize the solution based on the accepted answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 'filter #ftplugin/' . &amp;amp;filetype . '.vim$# scriptnames'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2017-10-13T01:11:40.610" LastActivityDate="2019-08-28T17:13:02.743" Title="How to identify all the loaded ftplugins for the current file?" Tags="|plugin-system|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13886" PostTypeId="2" ParentId="13885" CreationDate="2017-10-11T04:04:10.910" Score="8" Body="&lt;p&gt;I don't know of a direct way to get a list of only the things loaded for the current buffer based on filetype, but &lt;code&gt;:scriptnames&lt;/code&gt; will list everything that's been loaded, including system/default plugins, runtime scripts, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To figure out what's additionally autoloaded for a specific filetype, start Vim with no arguments, run &lt;code&gt;:scriptnames&lt;/code&gt;, then open a file of the type you care about, and run &lt;code&gt;:scriptnames&lt;/code&gt; again. If anything new was autoloaded for the filetype, you'll see it appended to the list the second time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can capture the output (to paste into a buffer, for example) with &lt;code&gt;redir&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @a&#xA;:scriptnames&#xA;:redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll see the output displayed, but it will also be copied to register &lt;code&gt;a&lt;/code&gt;. You can paste that into a buffer with &lt;code&gt;&quot;ap&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8233" LastEditorUserId="8233" LastEditDate="2019-08-28T17:13:02.743" LastActivityDate="2019-08-28T17:13:02.743" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="13887" PostTypeId="1" AcceptedAnswerId="13891" CreationDate="2017-10-11T08:57:59.743" Score="2" ViewCount="471" Body="&lt;p&gt;Context: I learned about the &lt;code&gt;:[v]split&lt;/code&gt; command long before I learned the shortcuts &lt;code&gt;Ctrl-w+[s|v]&lt;/code&gt; and as a result I find myself typing these commands often. Is there a way to break this habit ? (as a similar example, when I was first learning vim I mapped the arrow keys to &lt;code&gt;nop&lt;/code&gt; to force me to use &lt;code&gt;hjkl&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The catch is I'd like &lt;code&gt;:[v]split &amp;lt;...&amp;gt;&lt;/code&gt; to still work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generically, do you have any recommendations to force the use of keybindings rather than the equivalent command mode commands ?&lt;/p&gt;&#xA;" OwnerUserId="11553" LastActivityDate="2017-10-12T11:07:24.753" Title="Any recommendations to enforce use of keybindings rather than equivalent command mode commands?" Tags="|command-line|vim-windows|habit-breaking|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13888" PostTypeId="2" ParentId="13887" CreationDate="2017-10-11T09:47:11.127" Score="3" Body="&lt;p&gt;It's not an elegant solution, but the following might work for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap split&amp;lt;cr&amp;gt; echo &quot;Use CTRL-W s!&quot;&amp;lt;cr&amp;gt;&#xA;cnoremap vsplit&amp;lt;cr&amp;gt; echo &quot;Use CTRL-W v!&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. You might need to adapt this with the exact series of keystrokes you use e.g. &lt;code&gt;:vs&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that instead of splitting the window, the &lt;code&gt;:split&lt;/code&gt; and &lt;code&gt;vsplit&lt;/code&gt; commands will admonish you for not using the keyboard shortcuts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:vsplit &amp;lt;...&amp;gt;&lt;/code&gt; will work as normal, though: as soon as you diverge from the mapping (e.g. by typing &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; after &lt;code&gt;:vsplit&lt;/code&gt;), Vim will abandon it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The downside is that &lt;em&gt;while&lt;/em&gt; you are typing &lt;code&gt;vsplit&lt;/code&gt; you will lose most of the visual feedback, because Vim is waiting to see whether or not you are typing the mapping or a different series of keystrokes with a matching prefix. This may or may not be an issue for you.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-10-11T11:59:26.403" LastActivityDate="2017-10-11T11:59:26.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13889" PostTypeId="2" ParentId="5175" CreationDate="2017-10-11T09:47:41.227" Score="1" Body="&lt;p&gt;First off, that's a shitty style enforcement and you have my sympathies. Instead of &lt;em&gt;hiding&lt;/em&gt; how about creating a mapping or functions (like shown below) for deleting the unnecessary lines before editing and adding them when you're done ? something along the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Clean()&#xA;    %s/{\n^$/{/&#xA;    %s/^$\n\(\s*}\)/\1/&#xA;endfunction&#xA;&#xA;function! Pollute()&#xA;    %s/{$/{\r/&#xA;    %s/\(\s*}\)/\r\1/&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The basic idea begin, delete the empty lines at read and replace them at write, didn't try it but I feel like this can be added as an autocmd like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufReadPost *.cpp call Clean()&#xA;au BufWritePost *.cpp call Pollute()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11553" LastEditorUserId="11553" LastEditDate="2017-10-11T10:09:20.227" LastActivityDate="2017-10-11T10:09:20.227" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13890" PostTypeId="1" AcceptedAnswerId="13892" CreationDate="2017-10-11T10:36:00.870" Score="1" ViewCount="161" Body="&lt;p&gt;After the command &lt;code&gt;:set equalprg=echo.sh&lt;/code&gt;, the equals command simply deletes the specified region. Here is &lt;code&gt;echo.sh&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;echo &quot;$1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where is the input? I can assign &lt;code&gt;equalprg&lt;/code&gt; to something like &lt;code&gt;astyle&lt;/code&gt; and it works fine, taking text from vim on &lt;code&gt;stdin&lt;/code&gt;. So why is there nothing on &lt;code&gt;stdin&lt;/code&gt; for a bash script? The same thing happens when setting &lt;code&gt;formatprg&lt;/code&gt; to a bash script too.&lt;/p&gt;&#xA;" OwnerUserId="3353" LastActivityDate="2017-10-11T10:54:23.537" Title="Vim equalprg: why does it fail silently on a bash script?" Tags="|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13891" PostTypeId="2" ParentId="13887" CreationDate="2017-10-11T10:50:43.127" Score="8" Body="&lt;p&gt;You could try to add this code in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:my_overlooked_commands = [&#xA;                            \   { 'old': 'vsplit', 'new': 'C-w v' },&#xA;                            \   { 'old': 'split',  'new': 'C-w s' },&#xA;                            \   { 'old': 'q!',     'new': 'ZQ' },&#xA;                            \   { 'old': 'x',      'new': 'ZZ' },&#xA;                            \]&#xA;&#xA;fu! s:alternative_reminder(cmd) abort&#xA;    call timer_start(0, {-&amp;gt;&#xA;    \ execute('echohl WarningMsg | echo &quot;['.a:cmd.'] was equivalent&quot; | echohl NONE', '') })&#xA;    return ''&#xA;endfu&#xA;&#xA;fu! s:remember(list) abort&#xA;    for cmd in a:list&#xA;        let old = cmd.old&#xA;        let sold = string(old)&#xA;        exe printf('&#xA;        \            cnorea &amp;lt;expr&amp;gt; %s getcmdtype() ==# &quot;:&quot; &amp;amp;&amp;amp; getcmdline() ==# %s&#xA;        \?                   %s.&amp;lt;sid&amp;gt;alternative_reminder(%s)&#xA;        \:                   %s&#xA;        \',          old, sold, sold, string(cmd.new), sold&#xA;        \         )&#xA;    endfor&#xA;endfu&#xA;&#xA;call s:remember(g:my_overlooked_commands)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use it, inside the list &lt;code&gt;g:my_overlooked_commands&lt;/code&gt;, you would need to add the old commands you're currently using, and their new counterparts you would like to use, but frequently forget to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After executing an old command, a message should be displayed in the command-line to remind you that there's an alternative.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: Concerning these 2 &lt;a href=&quot;https://vi.stackexchange.com/questions/13887/any-recommendations-to-enforce-use-of-keybindings-rather-than-equivalent-command/13891?noredirect=1#comment23861_13891&quot;&gt;questions&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;How does the %s.alternative_reminder(%s) part work?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;printf()&lt;/code&gt; expects a string as its first argument (called &lt;code&gt;{fmt}&lt;/code&gt; by the help, probably as an abbreviation for &lt;code&gt;format&lt;/code&gt;), and one or more expressions. The format (first argument) can contain one or several &lt;code&gt;%&lt;/code&gt; items. There are several types of items, &lt;code&gt;%s&lt;/code&gt; is one of them. The &lt;code&gt;s&lt;/code&gt; stands for &lt;code&gt;s&lt;/code&gt;tring. It means that you want &lt;code&gt;printf()&lt;/code&gt; to replace it with the value of an expression whose type is a string. Here's an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let var = 'string' | echo printf('here is a %s', var)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Going back to the code, the contents of the format is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnorea &amp;lt;expr&amp;gt; %s getcmdtype() ==# &quot;:&quot; &amp;amp;&amp;amp; getcmdline() ==# %s&#xA;\?                   %s.&amp;lt;sid&amp;gt;alternative_reminder(%s)&#xA;\:                   %s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It contains 5 &lt;code&gt;%s&lt;/code&gt; items. So, &lt;code&gt;printf()&lt;/code&gt; expects 5 more arguments after the format. Here they are given on the next line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;old, sold, sold, string(cmd.new), sold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The values of these expressions will replace the items in the format, respecting the order in which they are passed to &lt;code&gt;printf()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe printf('&#xA;\            cnorea &amp;lt;expr&amp;gt; %s getcmdtype() ==# &quot;:&quot; &amp;amp;&amp;amp; getcmdline() ==# %s&#xA;\?                   %s.&amp;lt;sid&amp;gt;alternative_reminder(%s)&#xA;\:                   %s&#xA;\',          old, sold, sold, string(cmd.new), sold&#xA;\         )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should be (untested) equivalent to something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe 'cnorea &amp;lt;expr&amp;gt; '.old.' getcmdtype() ==# &quot;:&quot; &amp;amp;&amp;amp; getcmdline() ==# '.sold&#xA;\.              '?     '.sold.'.&amp;lt;sid&amp;gt;alternative_reminder('.string(cmd.new).')'&#xA;\.              ':     '.sold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You don't need to invoke the &lt;code&gt;printf()&lt;/code&gt; function. But as soon as I get a concatenation of strings and other expressions, I find that using &lt;code&gt;printf()&lt;/code&gt; makes the code a little more readable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once &lt;code&gt;printf()&lt;/code&gt; has done its job, &lt;code&gt;:execute&lt;/code&gt; should receive a string looking like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    cnorea &amp;lt;expr&amp;gt; vsplit getcmdtype() ==# &quot;:&quot; &amp;amp;&amp;amp; getcmdline() ==# 'vsplit'&#xA;                  \?     'vsplit'.&amp;lt;sid&amp;gt;alternative_reminder('vsplit')&#xA;                  \:     'vsplit'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is an abbreviation which expands the word &lt;code&gt;vsplit&lt;/code&gt; into the value of an expression, which uses&#xA;the ternary operator &lt;code&gt;?:&lt;/code&gt;. If the test:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getcmdtype() ==# &quot;:&quot; &amp;amp;&amp;amp; getcmdline() ==# 'vsplit'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… is true, then, the value of the expression is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'vsplit'.&amp;lt;sid&amp;gt;alternative_reminder('vsplit')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… otherwise:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'vsplit'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;&amp;lt;sid&amp;gt;alternative_reminder('vsplit')&lt;/code&gt; is an expression whose value is the one returned at the end of the function. By default, a function returns the number &lt;code&gt;0&lt;/code&gt;. But here the function explicitly returns an empty string. So, the function doesn't add anything to the expansion of &lt;code&gt;vsplit&lt;/code&gt;, because it's replaced with an empty string. However, to get to the returned value, Vim must process the code of the function. The latter contains some logic to trigger a warning message when necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The goal of the test is to prevent the reminder to be triggered if you're not on a regular Ex command-line, or if you're not at the beginning of the command-line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, &lt;code&gt;vsplit&lt;/code&gt; should always be expanded into &lt;code&gt;vsplit&lt;/code&gt; (unchanged), but the reminder should be triggered when you execute the command at the beginning of a regular Ex command-line&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;2&quot;&gt;&#xA;  &lt;li&gt;Is it possible to adapt this to actually prevent the split from occurring? Removing the %s. from the quoted line above almost achieves&#xA;  this, but it breaks the :vsplit  case.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I haven't tested it very long and I don't know how reliable it is, but you could try this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:my_overlooked_commands = [&#xA;                            \   { 'old': 'vsplit', 'new': 'C-w v' },&#xA;                            \   { 'old': 'split',  'new': 'C-w s' },&#xA;                            \   { 'old': 'q!',     'new': 'ZQ' },&#xA;                            \   { 'old': 'x',      'new': 'ZZ' },&#xA;                            \]&#xA;&#xA;fu! s:alternative_reminder(old, new) abort&#xA;    if getcmdline()[-1:-1] ==# ' '&#xA;        call feedkeys(&quot;\&amp;lt;bs&amp;gt;&quot;.a:old.' ', 'int')&#xA;    else&#xA;        call timer_start(0, {-&amp;gt;&#xA;        \ execute('echohl WarningMsg | echo &quot;['.a:new.'] was equivalent&quot; | echohl NONE', '') })&#xA;    endif&#xA;    return ''&#xA;endfu&#xA;&#xA;fu! s:remember(list) abort&#xA;    for cmd in a:list&#xA;        let old = cmd.old&#xA;        let sold = string(old)&#xA;        exe printf('&#xA;        \            cnorea &amp;lt;expr&amp;gt; %s getcmdtype() ==# &quot;:&quot; &amp;amp;&amp;amp; getcmdline() ==# %s&#xA;        \?                   timer_start(0, {-&amp;gt; execute(&quot;call &amp;lt;sid&amp;gt;alternative_reminder(%s, %s)&quot;) }) ? &quot;&quot; : &quot;&quot;&#xA;        \:                   %s&#xA;        \',          old, sold, sold, string(cmd.new), sold&#xA;        \         )&#xA;    endfor&#xA;endfu&#xA;&#xA;call s:remember(g:my_overlooked_commands)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-10-12T11:07:24.753" LastActivityDate="2017-10-12T11:07:24.753" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13892" PostTypeId="2" ParentId="13890" CreationDate="2017-10-11T10:54:23.537" Score="3" Body="&lt;p&gt;&lt;code&gt;$1&lt;/code&gt; isn't stdin. It's the first argument passed to the script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's various different ways to &lt;a href=&quot;https://www.google.co.uk/search?q=stdin+bash&quot; rel=&quot;nofollow noreferrer&quot;&gt;read from stdin in bash&lt;/a&gt;. Here's &lt;a href=&quot;http://mockingeye.com/blog/2013/01/22/reading-everything-stdin-in-a-bash-script/&quot; rel=&quot;nofollow noreferrer&quot;&gt;one&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VALUE=$(cat)&#xA;echo &quot;$VALUE&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-10-11T10:54:23.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13893" PostTypeId="2" ParentId="5175" CreationDate="2017-10-11T11:13:55.853" Score="2" Body="&lt;p&gt;It is possible to abuse folds to hide extra empty lines. Here is how one could do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SkipNewlineFoldExpr()&#xA;    let l:curline = getline(v:lnum)&#xA;    &quot; fold begins at {$ or one line before }$&#xA;    if l:curline[-1:] == '{' || getline(v:lnum + 1)[-1:] == '}'&#xA;        return '&amp;gt;1'&#xA;    endif&#xA;    &quot; fold ends one line after {$ or at }$&#xA;    if getline(v:lnum - 1)[-1:] == '{' || l:curline[-1:] == '}'&#xA;        return '&amp;lt;1'&#xA;    endif&#xA;    return 0&#xA;endfunction&#xA;&#xA;function! SkipNewlineFoldText()&#xA;    &quot; fold text matches non-empty line&#xA;    return getline(getline(v:foldstart)[-1:] == '{' ? v:foldstart : v:foldend)&#xA;endfunction&#xA;&#xA;&quot; customize how fold is defined&#xA;set foldexpr=SkipNewlineFoldExpr()&#xA;&quot; customize how fold looks like&#xA;set foldtext=SkipNewlineFoldText()&#xA;&quot; use 'foldexpr'&#xA;set foldmethod=expr&#xA;&#xA;&quot; Optional:&#xA;&quot; drop highlighting of folds&#xA;&quot; highlight clear Folded&#xA;&quot; automatically close folds&#xA;&quot; set foldclose=all&#xA;&quot; automatically open folds on any actions on folded lines&#xA;&quot; set foldopen=all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would look something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Yjpwe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Yjpwe.png&quot; alt=&quot;Folded empty lines&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see there is no syntax highlighting on folded lines, still might be&#xA;something more bearable than lots of unnecessary empty lines. You can also&#xA;switch folds on and off with &lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt; shortcut in case they are getting in&#xA;your way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Folds aren't a small topic and Vim has a separate &lt;a href=&quot;https://vimhelp.appspot.com/fold.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;help file on them&lt;/a&gt;. Related options are linked there too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Detailed behaviour of cursor and search can be controlled via &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27foldopen%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'foldopen'&lt;/code&gt;&lt;/a&gt;, which combined with &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27foldclose%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'foldclose'&lt;/code&gt;&lt;/a&gt; defines when folds will be automatically opened and closed for you.&lt;/p&gt;&#xA;" OwnerUserId="860" LastEditorUserId="860" LastEditDate="2017-10-11T11:43:07.110" LastActivityDate="2017-10-11T11:43:07.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13894" PostTypeId="1" AcceptedAnswerId="13900" CreationDate="2017-10-11T12:08:00.757" Score="4" ViewCount="3467" Body="&lt;p&gt;I'm using:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; move current line up&#xA;imap [u &amp;lt;esc&amp;gt;:m .-2&amp;lt;CR&amp;gt;i&#xA;&amp;quot; move current line down&#xA;imap [d &amp;lt;esc&amp;gt;:m+&amp;lt;CR&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I'd like to keep the current cursor position, and I would like to expand the question to move up/down a block of text.&lt;/p&gt;&#xA;&lt;p&gt;EDIT 1: for example:&lt;br /&gt;&#xA;&lt;code&gt;The current line -&amp;gt;| need to move up is here&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;-&amp;gt;|&lt;/code&gt; is the cursor's position that we need to keep moving.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="36863" LastEditDate="2021-09-13T16:51:25.033" LastActivityDate="2021-09-13T16:51:25.033" Title="Move current line up/down but keep cursor position" Tags="|vimrc|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="13899" PostTypeId="2" ParentId="13894" CreationDate="2017-10-11T13:59:02.887" Score="2" Body="&lt;p&gt;I interpreted &quot;keep position&quot; as the cursor does not move, at all, which may not be what the question intended.  &lt;strong&gt;Note&lt;/strong&gt;: this only works with &lt;code&gt;set nostartofline&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Partial answer for the insert-mode case&lt;/em&gt;: There are two cases to consider.  The trick is to remember &lt;code&gt;:move&lt;/code&gt; puts the cursor at the new position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Current line up&lt;/strong&gt;: instead of moving the current line up, we move the previous line to just below the cursor line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap [u &amp;lt;c-o&amp;gt;:-1m.&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Current line down&lt;/strong&gt;: instead of moving the current line down, we move the next line to just before the cursor line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap [d &amp;lt;c-o&amp;gt;:+1m-1&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: in either case, we use &lt;code&gt;inoremap&lt;/code&gt; and &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;, which are preferable to &lt;code&gt;imap&lt;/code&gt; and &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;...&lt;code&gt;i&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-10-12T13:59:09.400" LastActivityDate="2017-10-12T13:59:09.400" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13900" PostTypeId="2" ParentId="13894" CreationDate="2017-10-11T15:47:52.640" Score="5" Body="&lt;p&gt;&lt;code&gt;ddp&lt;/code&gt; and &lt;code&gt;ddkP&lt;/code&gt; put the cursor at the begin of the line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution was found on &lt;a href=&quot;http://vim.wikia.com/wiki/Moving_lines_up_or_down#Mappings_to_move_lines&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Moving_lines_up_or_down&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;A-j&amp;gt; &amp;lt;Esc&amp;gt;:m .+1&amp;lt;CR&amp;gt;==gi&#xA;inoremap &amp;lt;A-k&amp;gt; &amp;lt;Esc&amp;gt;:m .-2&amp;lt;CR&amp;gt;==gi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For blocks of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;A-j&amp;gt; :m '&amp;gt;+1&amp;lt;CR&amp;gt;gv=gv&#xA;vnoremap &amp;lt;A-k&amp;gt; :m '&amp;lt;-2&amp;lt;CR&amp;gt;gv=gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After selection of a block, press &lt;code&gt;&amp;lt;A-j&amp;gt;&lt;/code&gt; to move the whole block down, &lt;code&gt;&amp;lt;A-k&amp;gt;&lt;/code&gt; to move it up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;A-j&amp;gt; :m .+1&amp;lt;CR&amp;gt;==&#xA;nnoremap &amp;lt;A-k&amp;gt; :m .-2&amp;lt;CR&amp;gt;==&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7913" LastEditorUserId="7913" LastEditDate="2017-10-12T20:02:04.480" LastActivityDate="2017-10-12T20:02:04.480" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13901" PostTypeId="2" ParentId="7561" CreationDate="2017-10-11T16:00:51.963" Score="0" Body="&lt;p&gt;As romanl  stated, &lt;code&gt;ctags&lt;/code&gt; doesn't really understand the code, so the best it can do is point you to functions sharing the name you're searching on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I believe the &lt;code&gt;clang_complete&lt;/code&gt; plugin provides the functionality you seek.  It makes use of the &lt;code&gt;clang&lt;/code&gt; compiler to find the function that actually matches the one you are searching for, and not just one that shares the same name.  It will override the &lt;code&gt;ctrl-]&lt;/code&gt; functionality of &lt;code&gt;ctags&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also seen it stated that &lt;code&gt;YouCompleteMe&lt;/code&gt; renders &lt;code&gt;clang_complete&lt;/code&gt; outmoded, but as I have yet to use it myself, I cannot guarantee its utility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;clang_complete git repo: &lt;a href=&quot;https://github.com/Rip-Rip/clang_complete&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Rip-Rip/clang_complete&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14675" LastActivityDate="2017-10-11T16:00:51.963" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13902" PostTypeId="1" CreationDate="2017-10-12T03:51:33.797" Score="1" ViewCount="1591" Body="&lt;p&gt;This's kind of odd question but I can't change the runtimepath of gvim to comply the same manner like under linux (plugins put under .vim)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to append .vim at the begin of runtimepath like: &lt;code&gt;set runtimepath^=~/.vim/,$VIMRUNTIME&lt;/code&gt;, it doesn't work.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The workaround solution is use mklink command of windows to make .vim as a softlink of vimfiles folder &lt;code&gt;mklink /D .vim vimfiles&lt;/code&gt;, but really don't expect this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there a way to make vim to look into .vim folder instead of vimfiles on windows 10?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P/S: I'm trying to use packages to manage plugins.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="205" LastEditDate="2017-10-12T04:05:56.567" LastActivityDate="2017-10-12T04:05:56.567" Title="Change runtimepath of Gvim on Windows 10" Tags="|vimrc|gvim|microsoft-windows|" AnswerCount="0" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="13903" PostTypeId="2" ParentId="13866" CreationDate="2017-10-12T07:07:11.730" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;Gbrowse!&lt;/code&gt; to get the url copied into the clipboard and then either paste it in the local browser or fire another &lt;code&gt;:!ssh&lt;/code&gt; command from the remote machine to the local machine, like (from &lt;code&gt;vim&lt;/code&gt; in the ssh session)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Gbrowse! | exe &quot;!ssh $LOCAL 'nohup google-chrome &quot; . @+ . &quot;' &amp;amp;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;change &lt;code&gt;google-chrome&lt;/code&gt; to other browsers or &lt;code&gt;xdg-open&lt;/code&gt; to use the default if you are in ubuntu.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2017-10-12T07:07:11.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13904" PostTypeId="1" CreationDate="2017-10-12T08:19:12.973" Score="2" ViewCount="146" Body="&lt;p&gt;I define four key words and two regions in vim scripts&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword KeywordA A nextgroup=rangeA skipwhite skipnl skipempty&#xA;syn keyword KeywordB B contained containedin=rangeA nextgroup=rangeB skipwhite skipnl skipempty&#xA;syn keyword KeywordC C contained containedin=rangeA&#xA;syn keyword KeywordD D contained containedin=rangeB&#xA;&#xA;syn region rangeA start=+{+ end=+}+ contained transparent&#xA;syn region rangeB start=+{+ end=+}+ contained transparent&#xA;&#xA;hi KeywordA ctermfg=blue&#xA;hi KeywordB ctermfg=green&#xA;hi KeywordC ctermfg=cyan&#xA;hi KeywordD ctermfg=red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The keywords A and B has two corresponding regions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;When the file is saved as .cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The highlighting result is like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ltcEQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ltcEQ.png&quot; alt=&quot;highlighting&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, the D is in rangeB,&#xA;but D is not highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However, if I change the file extension to .t&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the result is what I expect:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BO8T6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BO8T6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any solution that I can highlight C and D in rangeB in a cpp file?&#xA;(Since C in rangeB is also in rangeA) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="14386" LastEditorUserId="14386" LastEditDate="2017-10-12T08:33:16.943" LastActivityDate="2017-10-12T08:33:16.943" Title="vim cpp syntax contained region" Tags="|vimscript|syntax-highlighting|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13905" PostTypeId="1" CreationDate="2017-10-12T09:53:46.500" Score="1" ViewCount="503" Body="&lt;p&gt;Besides type in cmdline directly, I also use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;F2&amp;gt; :&amp;lt;c-u&amp;gt;exec join(getline(&quot;'&amp;lt;&quot;,&quot;'&amp;gt;&quot;),&quot;\n&quot;)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;F2&amp;gt; :exec getline(&quot;.&quot;)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;F3&amp;gt; :.w !sed 's/\r$// ; s/^\s*\$\s*\(.*\)\s*/\1/' \|bash -o pipefail&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to run vim/shell command in current buffer. eg,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;F2&amp;gt;&lt;/code&gt; to run current line as vim command.  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;F3&amp;gt;&lt;/code&gt; to run current line as shell command.  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;4&amp;lt;F3&amp;gt;&lt;/code&gt; to run curent line and 3 lines below it as shell command.  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So how can I disable expansion of &lt;code&gt;%&lt;/code&gt;, &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;at cmdline, eg &lt;code&gt;:!awk 'BEGIN { print 4 % 3} '&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;exec&lt;/code&gt; + &lt;code&gt;getline()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2017-10-12T11:18:48.897" Title="How to disable expansion of percent sign('%') in cmdline and `:exec`?" Tags="|key-bindings|vimscript|cmdline|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13906" PostTypeId="2" ParentId="13905" CreationDate="2017-10-12T11:18:48.897" Score="5" Body="&lt;p&gt;&lt;code&gt;escape(getline('.'), '%')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h escape()&lt;/code&gt; for more information&lt;/p&gt;&#xA;" OwnerUserId="4783" LastActivityDate="2017-10-12T11:18:48.897" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13907" PostTypeId="1" AcceptedAnswerId="13910" CreationDate="2017-10-12T12:49:35.273" Score="9" ViewCount="11383" Body="&lt;p&gt;I get E303 (&lt;em&gt;Unable to open swap file for &quot;{filename}&quot;, recovery impossible&lt;/em&gt;) when I open a file in vim in my Ubuntu system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see that the backupdir and directory environment variables are set correctly in vim -  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:se backupdir&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;backupdir=~/tools/Vim_Files/vim_backup&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:se directory&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;directory=~/tools/Vim_Files/vim_backup&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is the output of ls -l in the shell -&lt;br&gt;&#xA;&lt;code&gt;ls -l ~/tools/Vim_Files/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;drwxrwxr-x  2 me  me  4096 Oct 12 17:02 vim_backup&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is the relevant portion of my .vimrc setting up these variables -  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;se nobackup writebackup&#xA;let s:vim_cstmztn_files_dir='~/tools/Vim_Files/'   &#xA;let &amp;amp;directory=s:vim_cstmztn_files_dir.'vim_backup'&#xA;let &amp;amp;backupdir=s:vim_cstmztn_files_dir.'vim_backup'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5768" LastActivityDate="2021-07-06T15:27:15.690" Title="How to resolve E303 (Unable to open swap file) on Linux machine?" Tags="|linux|swap-file|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13908" PostTypeId="1" AcceptedAnswerId="13909" CreationDate="2017-10-12T13:33:31.627" Score="3" ViewCount="76" Body="&lt;p&gt;I have two &lt;code&gt;match&lt;/code&gt; lines in my vimrc. they work when they are used by themselves but when i try to uncomment both i don't get any &lt;code&gt;match&lt;/code&gt;ing behavior:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; highlight spaces used for indenting&#xA;match Visual /^\t*\zs \+/&#xA;&quot; highlight overlength characters&#xA;match Visual /\%81v.\+/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do you get both &lt;code&gt;match&lt;/code&gt; &quot;indenting spaces&quot; and &lt;code&gt;match&lt;/code&gt; &quot;characters past 80 column&quot; to match at the same time?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rewriting the original question to be more generic: &lt;strong&gt;How do you get two &lt;code&gt;match&lt;/code&gt;es at the same time to work?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;p.s. If you are wondering why I have these specific &lt;code&gt;match&lt;/code&gt;es. The &lt;code&gt;match&lt;/code&gt;es are used to help enforce the correct indentation style (the above &lt;code&gt;match&lt;/code&gt;es are for tab-indentation and I have some &lt;code&gt;match&lt;/code&gt;es for spaces-indentation).&lt;/p&gt;&#xA;" OwnerUserId="1894" LastEditorUserId="1894" LastEditDate="2017-10-12T14:04:25.400" LastActivityDate="2017-10-12T14:06:42.623" Title="How do you get two `match`es at the same time to work?" Tags="|indentation|highlight|" AnswerCount="1" CommentCount="2" ClosedDate="2018-04-09T19:13:53.240" ContentLicense="CC BY-SA 3.0" />
  <row Id="13909" PostTypeId="2" ParentId="13908" CreationDate="2017-10-12T13:43:05.623" Score="4" Body="&lt;p&gt;Use &lt;code&gt;2match&lt;/code&gt; for your second match.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; highlight spaces used for indenting&#xA;match Visual /^\t*\zs \+/&#xA;&quot; highlight overlength characters&#xA;2match Visual /\%81v.\+/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's also &lt;code&gt;:3match&lt;/code&gt;, but this is used by the pre-installed &lt;code&gt;matchparen&lt;/code&gt; standard plugin (see &lt;code&gt;:help :3match&lt;/code&gt;), so if you need more matches than this, you're probably best off using the &lt;code&gt;matchadd()&lt;/code&gt; function, or using syntax highlighting instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if you're using the same highlighting group, as you are, you can combine your regular expressions with &lt;code&gt;\|&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; highlight spaces used for indenting and overlength characters&#xA;match Visual /^\t*\zs \+\|\%20v.\+/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-10-12T14:06:42.623" LastActivityDate="2017-10-12T14:06:42.623" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13910" PostTypeId="2" ParentId="13907" CreationDate="2017-10-12T13:47:43.927" Score="7" Body="&lt;p&gt;Vim does not interpolate the &lt;code&gt;~&lt;/code&gt; when using the &lt;code&gt;let &amp;amp;&lt;/code&gt; syntax.  You must do this manually using &lt;code&gt;expand()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;se nobackup writebackup&#xA;let s:vim_cstmztn_files_dir=expand('~/tools/Vim_Files/')&#xA;let &amp;amp;directory=s:vim_cstmztn_files_dir.'vim_backup'&#xA;let &amp;amp;backupdir=s:vim_cstmztn_files_dir.'vim_backup'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-10-12T13:53:56.407" LastActivityDate="2017-10-12T13:53:56.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13911" PostTypeId="2" ParentId="13836" CreationDate="2017-10-12T15:22:32.263" Score="3" Body="&lt;p&gt;&lt;code&gt;:sbuffer&lt;/code&gt; is a split variant of &lt;code&gt;:buffer&lt;/code&gt;. &lt;code&gt;:sb&lt;/code&gt; takes the same parameters &lt;code&gt;:b&lt;/code&gt; i.e. buffer numbers or buffer names.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sb foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can split this below by using &lt;code&gt;:rightbelow&lt;/code&gt; command or &lt;code&gt;'splitbelow'&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:rightb sb foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As @Naumann said you can use &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; followed by &lt;code&gt;H&lt;/code&gt;/&lt;code&gt;J&lt;/code&gt;/&lt;code&gt;K&lt;/code&gt;/&lt;code&gt;L&lt;/code&gt; to move windows/splits however you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :sb&#xA;:h :rightb&#xA;:h 'splitbelow'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-10-12T15:22:32.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13912" PostTypeId="1" CreationDate="2017-10-13T00:24:12.350" Score="1" ViewCount="114" Body="&lt;p&gt;I have the following macro&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @f='ivoid function (void param^[o  {^M^M^[3kwi'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;^[&lt;/code&gt; represents ESC and &lt;code&gt;^M&lt;/code&gt; new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for some reason it does not execute anything after the &lt;code&gt;3k&lt;/code&gt;, I tried replacing the &lt;code&gt;^[&lt;/code&gt; with a &lt;code&gt;^O&lt;/code&gt; which represents CTRL-O, but instead this made the macro paste some weird text at the end that seemed to come from the help page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This macro is defined in &lt;code&gt;~/.vim/ftplugin/c.vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14695" LastEditorUserId="1841" LastEditDate="2017-10-13T07:18:25.797" LastActivityDate="2017-10-13T07:18:25.797" Title="Macros behaving unexpectedly (not executing commands)" Tags="|macro|repeated-commands|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13914" PostTypeId="2" ParentId="13885" CreationDate="2017-10-13T06:44:30.917" Score="4" Body="&lt;p&gt;A manual way might be to use &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#debug-scripts&quot; rel=&quot;nofollow noreferrer&quot;&gt;script debugging&lt;/a&gt;. Edit a file with the &lt;code&gt;:debug&lt;/code&gt; command, say &lt;code&gt;:debug e foo.c&lt;/code&gt;. Then set breakpoints for all &lt;code&gt;.vim&lt;/code&gt; files using &lt;code&gt;breakadd file *.vim&lt;/code&gt;. Repeatedly issue the &lt;code&gt;:cont&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Entering Debug mode.  Type &quot;cont&quot; to continue.&#xA;cmd: e foo.c&#xA;&amp;gt;breakadd file *.vim&#xA;&quot;foo.c&quot; [New File]&#xA;Breakpoint in &quot;/usr/local/Cellar/vim/8.0.1171/share/vim/vim80/ftplugin/c.vim&quot; line 1&#xA;/usr/local/Cellar/vim/8.0.1171/share/vim/vim80/ftplugin/c.vim&#xA;line 7: if exists(&quot;b:did_ftplugin&quot;)&#xA;&amp;gt; c&#xA;Breakpoint in &quot;/usr/local/Cellar/vim/8.0.1171/share/vim/vim80/indent/c.vim&quot; line 1&#xA;/usr/local/Cellar/vim/8.0.1171/share/vim/vim80/indent/c.vim&#xA;line 7: if exists(&quot;b:did_indent&quot;)&#xA;&amp;gt;&#xA;Breakpoint in &quot;/usr/local/Cellar/vim/8.0.1171/share/vim/vim80/syntax/c.vim&quot; line 1&#xA;/usr/local/Cellar/vim/8.0.1171/share/vim/vim80/syntax/c.vim&#xA;line 7: if exists(&quot;b:current_syntax&quot;)&#xA;&amp;gt;&#xA;Breakpoint in &quot;/Users/muru/.vim/plugged/tagbar/plugin/tagbar.vim&quot; line 1&#xA;/Users/muru/.vim/plugged/tagbar/plugin/tagbar.vim&#xA;line 21: scriptencoding utf-8&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't restrict itself to ftplugins, but it does show which plugins will be loaded just by editing this file. The &lt;code&gt;breakadd&lt;/code&gt; pattern can changed to something like &lt;code&gt;breakadd file */ftplugin/*.vim&lt;/code&gt; if you're only interested in files in an &lt;code&gt;ftplugin&lt;/code&gt; directory somewhere.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2017-10-13T06:44:30.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13915" PostTypeId="2" ParentId="1942" CreationDate="2017-10-13T08:38:32.833" Score="9" Body="&lt;p&gt;If you don't care about exit code, you can go with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call system('/usr/bin/zathura using-docker.pdf &amp;amp;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14698" LastActivityDate="2017-10-13T08:38:32.833" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13916" PostTypeId="1" CreationDate="2017-10-13T12:09:00.913" Score="2" ViewCount="87" Body="&lt;p&gt;Say my cursor is in the middle of the screen and I jumped with &lt;code&gt;gg&lt;/code&gt; and then jumping back with &lt;code&gt;C-o&lt;/code&gt; or maybe other jumping command (like using marks). What happens now is that line that have been in the centre of the screen would be at the bottom or at the start. I'd like it to be at the same screen position it was before jump.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2017-10-13T13:51:38.233" Title="How to restore screen after jumping back?" Tags="|jumplist|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13917" PostTypeId="2" ParentId="13916" CreationDate="2017-10-13T13:51:38.233" Score="3" Body="&lt;p&gt;you can use the &lt;code&gt;winsaveview()&lt;/code&gt; and &lt;code&gt;winrestview()&lt;/code&gt; functions, to correctly restore the last saved view. However, there is no easy way to have this done automatically restore a view after a jump or so. You would have to do some Vim Scripting to have this work for you.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-10-13T13:51:38.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13918" PostTypeId="1" AcceptedAnswerId="13933" CreationDate="2017-10-13T15:08:15.567" Score="2" ViewCount="285" Body="&lt;p&gt;I configured mutt to use vim as an editor to write emails (with &lt;code&gt;set editor=vim&lt;/code&gt; in &lt;code&gt;.muttrc&lt;/code&gt;), and I have noticed that when I am in tmux (with an empty &lt;code&gt;.tmux.conf&lt;/code&gt;), the vim keybinding &lt;kbd&gt;CTRL-K&lt;/kbd&gt; in insert mode, which is handy to insert digraphs, does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Outside of Tmux &amp;amp;&amp;amp; mutt, everything works fine: typing &lt;kbd&gt;CTRL-K&lt;/kbd&gt; causes the character &lt;code&gt;?&lt;/code&gt; to temporarily appear under the cursor, and the next two characters I type are correctly interpreted as a digraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know where the error might be coming from?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="11125" LastEditorUserId="1452" LastEditDate="2017-10-14T10:39:19.473" LastActivityDate="2017-10-20T11:52:44.827" Title="i_CTRL-K does not insert digraphs when in Mutt inside tmux" Tags="|digraphs|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="13919" PostTypeId="1" AcceptedAnswerId="13920" CreationDate="2017-10-13T15:23:00.053" Score="3" ViewCount="633" Body="&lt;p&gt;I'm not sure it's even possible, but I'd like to force vim to quit if reading from stdin gave empty data (0 bytes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason is when I'm running commands that may output something containing filesystem paths (e.g. grep(1) or find(1)) I redirect the output to &lt;code&gt;| view -&lt;/code&gt; so be able to quickly jump to a particular file with &lt;code&gt;gF&lt;/code&gt;. Now when the content is empty it make sense to not to start vim at all. How can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative solution would be to put a mediator program that would connect its stdin and stdout when the content is non-empty, and that  would exit otherwise, thus interrupting the pipeline.&lt;/p&gt;&#xA;" OwnerUserId="14707" LastEditorUserId="1841" LastEditDate="2017-10-13T18:12:31.817" LastActivityDate="2017-10-13T18:12:31.817" Title="Read from standard input and close if empty" Tags="|vimscript|invocation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13920" PostTypeId="2" ParentId="13919" CreationDate="2017-10-13T15:57:32.767" Score="4" Body="&lt;p&gt;Here is a &quot;vim only&quot; solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo '' | vim - +'exe !search(&quot;.&quot;)?&quot;quit!&quot;:&quot;&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is not perfect because a) doesn't distinguish between empty (0 bytes) and newline only b) the screen flash and c) the unavoidable message &lt;code&gt;Vim: Reading from stdin...&lt;/code&gt;.  The &quot;intermediary&quot; solution is a bit cleaner.  Assuming you have the utility &lt;code&gt;ifne&lt;/code&gt; (provided by &lt;code&gt;moreutils&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo -n '' | ifne vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;echo -n ''&lt;/code&gt; just simulates the output of your command for this demo- replace with your actual work.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-10-13T16:03:31.250" LastActivityDate="2017-10-13T16:03:31.250" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13922" PostTypeId="1" CreationDate="2017-10-14T00:51:30.437" Score="2" ViewCount="157" Body="&lt;p&gt;If vim started with &lt;code&gt;vim -i ~/tmp/.viminfo&lt;/code&gt;, how can I extract that pathname after vim started?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since upon exiting vim, history, mark, buf-list, etc will automatically write to that file, thus it must be stored somewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is: how can I get that pathname?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;　　 &lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2017-10-14T01:02:28.550" Title="How to get pathname of viminfo file after vim started" Tags="|vimscript|viminfo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13923" PostTypeId="2" ParentId="13922" CreationDate="2017-10-14T01:02:28.550" Score="4" Body="&lt;p&gt;See the &lt;code&gt;viminfofile&lt;/code&gt; option (&lt;code&gt;:help viminfofile&lt;/code&gt;), which is set when using the &lt;code&gt;-i&lt;/code&gt; command line flag.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-10-14T01:02:28.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13925" PostTypeId="1" AcceptedAnswerId="13926" CreationDate="2017-10-14T12:35:58.790" Score="2" ViewCount="2073" Body="&lt;p&gt;On my Raspberry 3 running &lt;code&gt;Raspbian GNU/Linux 9 (stretch)&lt;/code&gt; I get different behaviour for vim depending if I use &lt;code&gt;vim file&lt;/code&gt; or &lt;code&gt;sudo vim file&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Especially two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;With &lt;code&gt;sudo vim&lt;/code&gt; I can use the &lt;code&gt;Page Up&lt;/code&gt; and &lt;code&gt;Page Down&lt;/code&gt; keys to go forward and backwards a page. Without &lt;code&gt;sudo&lt;/code&gt; I can't. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After I close a file, without &lt;code&gt;sudo&lt;/code&gt; the terminal shows the last part of the file I was just in, and without &lt;code&gt;sudo&lt;/code&gt; it doesn't.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I &lt;code&gt;set hlsearch&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;, but when I use &lt;code&gt;sudo&lt;/code&gt; the searched terms don't get highlighted, without &lt;code&gt;sudo&lt;/code&gt; they do.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I want the &lt;code&gt;sudo&lt;/code&gt; behaviour (except for point 3) without having to use &lt;code&gt;sudo&lt;/code&gt; all the time (because of obvious reasons), but I don't even know where to start. Is it a problem with my terminal, is it a problem with my vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set term=ansi&#xA;syntax on&#xA;set hlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope somebody has an idea what is happening here...&lt;/p&gt;&#xA;" OwnerUserId="12977" LastActivityDate="2022-10-20T20:27:43.357" Title="Different behaviour for `vi` and `sudo vi`" Tags="|vimrc|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13926" PostTypeId="2" ParentId="13925" CreationDate="2017-10-14T13:04:20.513" Score="4" Body="&lt;p&gt;Note that as a workaround you can explicitly specify a vimrc file when you launch with &lt;code&gt;vim -u &amp;lt;vimrc&amp;gt;&lt;/code&gt;. But I'm sure you want to find a more permanent &quot;fix&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't tell you exactly what is going on with your system except that it's likely related to environment differences between sudo and non-sudo runs. Here's some info to help you investigate further...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start by looking at &lt;code&gt;:help vimrc&lt;/code&gt;. This describes how &lt;code&gt;vim&lt;/code&gt; finds vimrc files. It's system dependent (e.g. Unix looks in &lt;code&gt;$HOME/.vimrc&lt;/code&gt; first, Windows &lt;code&gt;$HOME/_vimrc&lt;/code&gt;). You'll want to check, for example, the value of &lt;code&gt;$HOME&lt;/code&gt; when running with/without &lt;code&gt;sudo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get some ideas about what is being loaded you can run &lt;code&gt;:scriptnames&lt;/code&gt; from vim. This shows all scripts that have been loaded, in order. Look near the top of the output as that's usually where loading of your vimrc file appears.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also do &lt;code&gt;vim -Vn&lt;/code&gt; which will print out useful information depending on value of &lt;em&gt;n&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;= 1    When the viminfo file is read or written.&#xA;&amp;gt;= 2    When a file is &quot;:source&quot;'ed.&#xA;&amp;gt;= 5    Every searched tags file and include file.&#xA;&amp;gt;= 8    Files for which a group of autocommands is executed.&#xA;&amp;gt;= 9    Every executed autocommand.&#xA;&amp;gt;= 12   Every executed function.&#xA;&amp;gt;= 13   When an exception is thrown, caught, finished, or discarded.&#xA;&amp;gt;= 14   Anything pending in a &quot;:finally&quot; clause.&#xA;&amp;gt;= 15   Every executed Ex command (truncated at 200 characters).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; minnmass' &lt;a href=&quot;https://vi.stackexchange.com/a/13927/11054&quot;&gt;helpful answer&lt;/a&gt; led me to a fact I wasn't aware of. I knew that &lt;code&gt;sudo -e&lt;/code&gt;/&lt;code&gt;sudoedit&lt;/code&gt; helps protect against accidental clobbering of critical files by using temp files but I didn't know this: &lt;em&gt;unlike most commands run by sudo, the editor is run with the &lt;strong&gt;invoking user's environment unmodified.&lt;/strong&gt;&lt;/em&gt; So you may be able to keep &lt;code&gt;$HOME/.vimrc&lt;/code&gt; and do &lt;code&gt;sudo -e &amp;lt;file&amp;gt;&lt;/code&gt;. Give it a try if you are so inclined. (Depending on exiting values, you may first need to do &lt;code&gt;export ENVVAR=vim&lt;/code&gt; where &lt;code&gt;ENVVAR&lt;/code&gt; is any one of &lt;code&gt;SUDO_EDITOR&lt;/code&gt;, &lt;code&gt;VISUAL&lt;/code&gt; or &lt;code&gt;EDITOR&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-10-15T02:17:16.077" LastActivityDate="2017-10-15T02:17:16.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13927" PostTypeId="2" ParentId="13925" CreationDate="2017-10-14T15:20:47.633" Score="8" Body="&lt;p&gt;You're running &lt;code&gt;vim&lt;/code&gt; as root, not as your normal user (that's what &lt;code&gt;sudo&lt;/code&gt; does). Since you're not running &lt;code&gt;vim&lt;/code&gt; as your normal user, your user's .vimrc isn't being consulted (this is the correct, expected behavior).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to edit a file as root, but want to use your regular editor and configuration, look at &lt;code&gt;sudo -e&lt;/code&gt; or &lt;code&gt;sudoedit&lt;/code&gt; (which is basically an alias to &lt;code&gt;sudo -e&lt;/code&gt;). The man page (&lt;a href=&quot;https://www.sudo.ws/man/1.8.18/sudo.man.html#e&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, or just &lt;code&gt;man sudo&lt;/code&gt;) may be useful in configuring your system to use &lt;code&gt;vim&lt;/code&gt; for that purpose.&lt;/p&gt;&#xA;" OwnerUserId="14714" LastActivityDate="2017-10-14T15:20:47.633" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13928" PostTypeId="1" CreationDate="2017-10-14T23:10:00.827" Score="1" ViewCount="41" Body="&lt;p&gt;so if i have the following multiline text in my register &lt;code&gt;+&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ZERO     &#xA;SIGN     &#xA;CARRY    &#xA;AUXILIARY&#xA;PARITY   &#xA;OVERFLOW &#xA;INTERRUPT&#xA;DIRECTION&#xA;TRAP     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case ZERO     :&#xA;  return a-&amp;gt;FLAGS.derp;&#xA;case SIGN     :&#xA;  return a-&amp;gt;FLAGS.derp;&#xA;case CARRY    :&#xA;  return a-&amp;gt;FLAGS.derp;&#xA;case AUXILIARY:&#xA;  return a-&amp;gt;FLAGS.derp;&#xA;case PARITY   :&#xA;  return a-&amp;gt;FLAGS.derp;&#xA;case OVERFLOW :&#xA;  return a-&amp;gt;FLAGS.derp;&#xA;case INTERRUPT:&#xA;  return a-&amp;gt;FLAGS.derp;&#xA;case DIRECTION:&#xA;  return a-&amp;gt;FLAGS.derp;&#xA;case TRAP     :&#xA;  return a-&amp;gt;FLAGS.derp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want the result of a search and replace command (i.e. &lt;code&gt;:%s\derp\register+&lt;/code&gt;\g) to be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case ZERO     :&#xA;  return a-&amp;gt;FLAGS.ZERO;&#xA;case SIGN     :&#xA;  return a-&amp;gt;FLAGS.SIGN;&#xA;case CARRY    :&#xA;  return a-&amp;gt;FLAGS.CARRY;&#xA;case AUXILIARY:&#xA;  return a-&amp;gt;FLAGS.AUXILIARY;&#xA;case PARITY   :&#xA;  return a-&amp;gt;FLAGS.PARITY;&#xA;case OVERFLOW :&#xA;  return a-&amp;gt;FLAGS.OVERFLOW;&#xA;case INTERRUPT:&#xA;  return a-&amp;gt;FLAGS.INTERRUPT;&#xA;case DIRECTION:&#xA;  return a-&amp;gt;FLAGS.DIRECTION;&#xA;case TRAP     :&#xA;  return a-&amp;gt;FLAGS.TRAP;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;:%s/foo/\=@a/g&lt;/code&gt; is very close to this but not close enough, it will insert the totality of the register on each match.&lt;/p&gt;&#xA;" OwnerUserId="14695" LastActivityDate="2017-10-15T06:37:00.820" Title="How to search and replace each hit with a multiline register in which each hit is replaced with an individual line from the register?" Tags="|search|replace|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13929" PostTypeId="1" CreationDate="2017-10-15T02:47:48.840" Score="2" ViewCount="5428" Body="&lt;p&gt;I've been trying to select all characters except the last word (2 groups where 1 group is everything but the last word and the other group is only the last word)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^.\+\([^\w\+]$\)/\2\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is what I have so far and I've been stuck. &lt;/p&gt;&#xA;" OwnerUserId="14719" LastActivityDate="2017-10-16T13:26:32.007" Title="vim how to move last word of each line to beginning of line using regex and backreferences?" Tags="|search|regular-expression|replace|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13930" PostTypeId="2" ParentId="13928" CreationDate="2017-10-15T06:37:00.820" Score="1" Body="&lt;p&gt;One way to do this is using &lt;code&gt;:h sub-replace-expression&lt;/code&gt; with the &lt;code&gt;list&lt;/code&gt; flag of &lt;code&gt;getreg()&lt;/code&gt;, assuming your code starts at line 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s;derp;\=getreg('+',1,1)[float2nr((line('.')-1)/2)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your register looked like this (e.g., using a scratch buffer to duplicate lines):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ZERO     &#xA;ZERO     &#xA;SIGN     &#xA;SIGN     &#xA;CARRY  &#xA;CARRY   &#xA;&amp;amp;c...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this would simplify to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s;derp;\=getreg('+',1,1)[line('.')]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is a handy pattern in many situations.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-10-15T06:37:00.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13931" PostTypeId="2" ParentId="13929" CreationDate="2017-10-15T07:40:48.650" Score="5" Body="&lt;pre&gt;&lt;code&gt;:%s/^\(.\+\)\s\+\(\S\+\)$/\2 \1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second pair of parens contains a continuous string of non-whitespace &lt;code&gt;\S\+&lt;/code&gt; (also known as a &quot;WORD&quot;) preceding the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first pair of parens gobbles everything else except for some whitespace &lt;code&gt;\s\+&lt;/code&gt;. This requirement of ending before some whitespace prevents it from greedily consuming the final WORD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This ignores the whitespace between groups 1 and 2 and then reinserts a single space in the substitution. But we could also do three captures if you want to preserve the whitespace exactly (e.g. if it has tabs):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(.\+\)\(\s\+\)\(\S\+\)$/\3\2\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's make it more readable by using &quot;very magic&quot; mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v^(.+)(\s+)(\S+)$/\3\2\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If a line is indented things get a little ugly. Optionally, we could preserve any indentation thusly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v^(\s*)(.+)(\s+)(\S+)$/\1\4\3\2/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Notes:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I'm assuming that you want to preserve a sentence-like structure in the result (i.e. no space at the beginning that wasn't there before and always put space between the first and second word). If you don't want that use something like the first command above but remove the one space in the substitution.&lt;/li&gt;&#xA;&lt;li&gt;No trailing whitespace allowed, the line won't match so no substitution, but that can be handled by inserting &lt;code&gt;\s*&lt;/code&gt; right before &lt;code&gt;$&lt;/code&gt; in the pattern.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/g&lt;/code&gt; flag is not required as this pattern matches an entire line...only one substitution possible.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-10-15T08:31:15.140" LastActivityDate="2017-10-15T08:31:15.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13932" PostTypeId="2" ParentId="9747" CreationDate="2017-10-15T11:08:46.200" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/46754255/3697584&quot;&gt;Also answered here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just created this for my &lt;a href=&quot;https://github.com/themadsens/thm-dotfiles/blob/master/.vim/autoload/fman.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;:Man viewer&lt;/a&gt;. It tracks the current item in the 'locationlist' window when navigating:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:visibleLoc()&#xA;   return len(filter(getwininfo(), {i,v -&amp;gt; v.loclist}))&#xA;endfunc&#xA;&#xA;function! s:followLine()&#xA;   let curLine = line(&quot;.&quot;)&#xA;   if (exists(&quot;b:lastLine&quot;) &amp;amp;&amp;amp; b:lastLine == curLine) || 0 == s:visibleLoc()&#xA;      return&#xA;   endif&#xA;   let b:lastLine = line(&quot;.&quot;)&#xA;   let ent = len(filter(getloclist(&quot;.&quot;), {i,v -&amp;gt; v.lnum &amp;lt;= curLine}))&#xA;   if ent &amp;lt; 1 || (exists(&quot;b:lastEntry&quot;) &amp;amp;&amp;amp; b:lastEntry == ent)&#xA;      return&#xA;   endif&#xA;   let b:lastEntry = ent&#xA;   let pos = [ 0, curLine, col(&quot;.&quot;), 0 ]&#xA;   exe &quot;ll &quot;.ent&#xA;   call setpos(&quot;.&quot;, pos)&#xA;endfunc&#xA;&#xA;au CursorMoved &amp;lt;buffer&amp;gt; call &amp;lt;SID&amp;gt;followLine()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14721" LastEditorUserId="14721" LastEditDate="2017-10-15T12:13:35.377" LastActivityDate="2017-10-15T12:13:35.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13933" PostTypeId="2" ParentId="13918" CreationDate="2017-10-15T17:35:49.390" Score="2" Body="&lt;p&gt;The origin of the problem was that &lt;code&gt;tmux&lt;/code&gt; was consuming the &lt;code&gt;C-k&lt;/code&gt; keypress. I had blindly followed the instructions that came along with the &lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-tmux-navigator&lt;/code&gt;&lt;/a&gt; plugin at the time I installed it, which recommended using the following line in &lt;code&gt;.tmux.conf&lt;/code&gt; to identify whether or not &lt;code&gt;vim&lt;/code&gt; was running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;is_vim='echo &quot;#{pane_current_command}&quot; | grep -iqE &quot;(^|\/)g?(view|n?vim?)(diff)?$&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way of detecting &lt;code&gt;vim&lt;/code&gt; was not robust, and in my case it didn't detect that I was in &lt;code&gt;vim&lt;/code&gt; when writing an email with &lt;code&gt;mutt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it turns out, the command proposed in the &lt;code&gt;README&lt;/code&gt; of the plugin was changed in &lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator/commit/57701ac650990010ea97b1b4d64779d0b60c769b#diff-04c6e90faac2675aa89e2176d2eec7d8&quot; rel=&quot;nofollow noreferrer&quot;&gt;this commit&lt;/a&gt; to one that makes the detection of vim more robust.&lt;/p&gt;&#xA;" OwnerUserId="11125" LastEditorUserId="11125" LastEditDate="2017-10-20T11:52:44.827" LastActivityDate="2017-10-20T11:52:44.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13934" PostTypeId="1" AcceptedAnswerId="13935" CreationDate="2017-10-15T18:56:46.997" Score="0" ViewCount="135" Body="&lt;p&gt;A few editors that expect to be able to use &lt;code&gt;^S&lt;/code&gt; and &lt;code&gt;^Q&lt;/code&gt; themselves (e.g. gnu emacs, jed, mg) disable flow control in the terminal when the program starts, but restore the original setting when the program is suspended or terminates normally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to configure vim to behave the same way?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-10-15T21:17:46.870" Title="disable flow control and restore it when leaving vim" Tags="|terminal|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13935" PostTypeId="2" ParentId="13934" CreationDate="2017-10-15T21:17:46.870" Score="1" Body="&lt;p&gt;Most likely, the easiest way is to build vim from source with a small modification:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@@ -3416,7 +3416,7 @@ mch_settmode(int tmode)&#xA;        /*&#xA;         * ~ICRNL enables typing ^V^M&#xA;         */&#xA;-       tnew.c_iflag &amp;amp;= ~ICRNL;&#xA;+       tnew.c_iflag &amp;amp;= ~(ICRNL | IXON);&#xA;        tnew.c_lflag &amp;amp;= ~(ICANON | ECHO | ISIG | ECHOE&#xA; # if defined(IEXTEN) &amp;amp;&amp;amp; !defined(__MINT__)&#xA;                    | IEXTEN        /* IEXTEN enables typing ^V on SOLARIS */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-10-15T21:17:46.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13936" PostTypeId="1" AcceptedAnswerId="13937" CreationDate="2017-10-16T06:21:55.867" Score="3" ViewCount="354" Body="&lt;p&gt;I want to send commands to tmux to run Elixir tests from vim. Using the &lt;code&gt;%&lt;/code&gt; variable allows me to run the command to run a test for a single file. The relevant line in my &lt;code&gt;.vimrc&lt;/code&gt; is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;ef :! tmux send -t 0.1 'mix test %:p' Enter&amp;lt;CR&amp;gt;&amp;lt;c-L&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This sends, for example, &lt;code&gt;mix test /path/to/spec.exs&lt;/code&gt; when I'm in a spec. That works for testing a single file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to be able to run a single test. The command would have the format &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;mix test /path/to/test.exs:&amp;lt;lineno&amp;gt;&lt;/code&gt;, so the path, a colon, and the line number. I tried things like &lt;code&gt;line(.)&lt;/code&gt;, but I can't figure out how to interpolate that inside of a &lt;code&gt;tmux send&lt;/code&gt; string.&lt;/p&gt;&#xA;" OwnerUserId="14728" LastActivityDate="2017-10-16T17:20:16.060" Title="Send file and line number to tmux" Tags="|line-numbers|tmux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13937" PostTypeId="2" ParentId="13936" CreationDate="2017-10-16T07:52:58.967" Score="4" Body="&lt;p&gt;Here's an example of inserting line number in a shell command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;!echo &quot; . line(&quot;.&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So your mapping would be something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;ef :exe &quot;!tmux send -t 0.1 'mix test %:p:&quot; . line(&quot;.&quot;) . &quot;' Enter&quot;&amp;lt;CR&amp;gt;&amp;lt;C-L&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I run &lt;code&gt;tmux&lt;/code&gt; so I was able to test that the command appeared in a tmux pane (though I can't actually verify the command since I don't have 'mix').&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-10-16T17:20:16.060" LastActivityDate="2017-10-16T17:20:16.060" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13938" PostTypeId="1" AcceptedAnswerId="13940" CreationDate="2017-10-16T09:06:45.433" Score="8" ViewCount="2322" Body="&lt;p&gt;When using vim in commandline mode, I have to navigate using only arrow keys. I can't use the native vim bindings because when I key &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, it exits commandline mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I was typing a command in commandline mode, &lt;code&gt;:w eiff.txt&lt;/code&gt;, but I realised that I've made a mistake, it should have been &lt;code&gt;diff.txt&lt;/code&gt;, if I try to go back with the &lt;code&gt;b&lt;/code&gt; button, it doesn't work because I can't hit &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there any way to navigate using the vim keys in the command line mode?&lt;/p&gt;&#xA;" OwnerUserId="11044" LastActivityDate="2017-10-16T17:52:05.017" Title="How to navigate using vim keybindings in command line mode?" Tags="|command-line|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13939" PostTypeId="1" AcceptedAnswerId="13944" CreationDate="2017-10-16T09:27:19.990" Score="1" ViewCount="182" Body="&lt;p&gt;I've noticed that recently when I quit vim it prints the following text to the terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Options ---&#xA;  background=dark  helplang=en  relativenumber&#xA;  cursorline  number  scroll=11&#xA;  runtimepath=~/.config/nvim,~/.config/nvim/plugged/vim-sensible/,~/.config/nvim/plugged/vim-multiple-cursors/,~/.config/nvim/plugged/molokai/,~/.config/nvim/plugged/vim-colors-solarized/,~/.config/nvim/plugged/vim-commentary/,~/.config/nvim/plugged/lucario/,~/.config/nvim/plugged/vim-auto-save/,~/.config/nvim/plugged/vim-cpp-enhanced-highlight/,~/.config/nvim/plugged/Improved-Syntax-Highlighting-Vim/,~/.config/nvim/plugged/vimtex/,~/.config/nvim/plugged/vim-sneak/,~/.config/nvim/plugged/pretty-vim-python/,~/.config/nvim/plugged/supertab/,~/.config/nvim/plugged/simpylfold/,~/.config/nvim/plugged/vim-fish/,~/.config/nvim/plugged/vim-airline/,/etc/xdg/nvim,~/.local/share/nvim/site,/usr/local/share/nvim/site,/usr/share/nvim/site,/usr/local/Cellar/neovim/0.2.0_1/share/nvim/runtime,/usr/share/nvim/site/after,/usr/local/share/nvim/site/after,~/.local/share/nvim/site/after,/etc/xdg/nvim/after,~/.config/nvim/plugged/vim-cpp-enhanced-highlight/after,~/.config/nvim/plugged/vimtex/after,~/.config/nvim/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm on a mac and I use neovim but the same behavior happens in regular vim. I don't think I changed anything recently but here is my vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin()&#xA;Plug 'tpope/vim-sensible'&#xA;&quot; Plug 'scrooloose/nerdcommenter'&#xA;Plug 'terryma/vim-multiple-cursors'&#xA;Plug 'tomasr/molokai'&#xA;Plug 'altercation/vim-colors-solarized'&#xA;Plug 'tpope/vim-commentary'&#xA;&#xA;&quot;Plug 'severin-lemaignan/vim-minimap'&#xA;Plug 'raphamorim/lucario'&#xA;Plug '907th/vim-auto-save'&#xA;&quot;&#xA;Plug 'octol/vim-cpp-enhanced-highlight'&#xA;Plug 'dragfire/Improved-Syntax-Highlighting-Vim'&#xA;Plug 'lervag/vimtex'&#xA;&quot;Plug 'klen/python-mode'&#xA;&quot;Plug 'hdima/python-syntax'&#xA;&quot;Plug 'dragfire/improved-syntax-highlighting-vim'&#xA;&quot;Plug 'sheerun/vim-polyglot'&#xA;&quot; Plug 'easymotion/vim-easymotion'&#xA;&quot; Plug 'goldfeld/vim-seek'&#xA;Plug 'justinmk/vim-sneak'&#xA;&quot;Plug 'vim-scripts/TagHighlight'&#xA;&quot;Plug 'xolox/vim-easytags'&#xA;&quot;Plug 'xolox/vim-misc'&#xA;Plug 'sentientmachine/pretty-vim-python'&#xA;Plug 'ervandew/supertab'&#xA;Plug 'tmhedberg/simpylfold'&#xA;&#xA;Plug 'dag/vim-fish'&#xA;Plug 'bling/vim-airline'&#xA;&quot; Plug 'vim-airline/vim-airline-themes'&#xA;call plug#end()&#xA;&#xA;&#xA;colo molokai&#xA;&#xA;&quot;let python_highlight_builtins = 1&#xA;&quot;let g:pymode_python = 'python3'&#xA;if has(&quot;gui_vimr&quot;)&#xA; let g:molokai_original = 1&#xA;endif&#xA;&#xA;inoremap jk &amp;lt;Esc&amp;gt;&#xA;&#xA;set number&#xA;set relativenumber&#xA;set cursorline&#xA;set &#xA;syntax on&#xA;&#xA;let g:multi_cursor_exit_from_insert_mode = 0&#xA;let g:multi_cursor_insert_maps = {'j':1}&#xA;&#xA;&#xA;&quot;set nofoldenable&#xA;set foldlevel=99&#xA;set clipboard=unnamed&#xA;nnoremap &amp;lt;esc&amp;gt; :noh&amp;lt;return&amp;gt;&amp;lt;esc&amp;gt;&#xA;&#xA;set spell&#xA;set mouse=a&#xA;&#xA;let g:vimtex_view_method = 'skim'&#xA;let g:vimtex_view_general_viewer&#xA;      \ = '/Applications/Skim.app/Contents/SharedSupport/displayline'&#xA;let g:vimtex_view_general_options = '-r @line @pdf @tex'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't see any option that could be causing it but I've tried disabling plugins randomly but couldn't come up with a thing which removes the printing&lt;/p&gt;&#xA;" OwnerUserId="14731" LastEditorUserId="1841" LastEditDate="2017-10-16T11:12:51.010" LastActivityDate="2017-10-16T13:17:14.277" Title="Vim prints options on quit" Tags="|vimrc|options|macos|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13940" PostTypeId="2" ParentId="13938" CreationDate="2017-10-16T09:29:35.810" Score="10" Body="&lt;p&gt;You can type &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt; to see command history and edit it like any other buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Press &lt;kbd&gt;Enter&lt;/kbd&gt; on the line with the command you want to execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;p.s.: &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt; works the same but for search history.&lt;/p&gt;&#xA;" OwnerUserId="2710" LastEditorUserId="2710" LastEditDate="2017-10-16T17:52:05.017" LastActivityDate="2017-10-16T17:52:05.017" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13941" PostTypeId="2" ParentId="4600" CreationDate="2017-10-16T11:13:08.853" Score="1" Body="&lt;p&gt;To extend @romainl's answer, (with clipboard support) you can use registers that are shared with system wide clipboard.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;+y    To yank/copy from a vim-terminal&#xA;&quot;+p    To paste in destination vim-terminal&#xA;&#xA;&quot;*y    To yank/copy from a vim-terminal&#xA;&quot;*p    To paste in destination vim-terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By executing these commands, you are &lt;strong&gt;y&lt;/strong&gt;anking/copying/storing selected contents in registers, and &lt;strong&gt;p&lt;/strong&gt;asting them to destination Vim-terminal. These two special registers &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; are shared with the system wide clipboard (and  hence many other programs such as web browser, gedit etc). Register &lt;code&gt;+&lt;/code&gt; is associated with copy/paste buffer and &lt;code&gt;*&lt;/code&gt; is associated with selection buffer (one that inserts a copy of selection with a middle click on a text field in, say, Ubuntu) and can be pasted using &lt;code&gt;ctrl + v&lt;/code&gt; (&lt;code&gt;ctrl + shift + v&lt;/code&gt; on gnome-terminal).&lt;/p&gt;&#xA;" OwnerUserId="3012" LastActivityDate="2017-10-16T11:13:08.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13942" PostTypeId="2" ParentId="4600" CreationDate="2017-10-16T11:55:49.837" Score="1" Body="&lt;p&gt;1) On Fedora I use the following setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dnf install vim-X11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim-X11 comes with clipboard support - maybe in other distros it is similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Set an alias in my .bashrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vim=&quot;vimx&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;3) In .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard=unnamedplus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the usual yank in Vim goes into the system clipboard and every Ctrl-C outside of vim can be pasted in vim.&lt;/p&gt;&#xA;" OwnerUserId="2710" LastEditorUserId="2710" LastEditDate="2017-10-16T17:55:19.750" LastActivityDate="2017-10-16T17:55:19.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13943" PostTypeId="2" ParentId="13929" CreationDate="2017-10-16T13:15:06.637" Score="4" Body="&lt;p&gt;You've specified that you want to use regular expressions and back-references, but, depending on your &lt;a href=&quot;https://vi.stackexchange.com/questions/13929/vim-how-to-move-last-word-of-each-line-to-beginning-of-line-using-regex-and-back#comment23921_13929&quot;&gt;precise requirements&lt;/a&gt;, it's arguably easier to achieve this without using regular expressions.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm $diw0Pa&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. I've written &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; above, as otherwise the space would be invisible: you should enter an actual space character by pressing your space bar once.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This does roughly the same thing as the first &lt;code&gt;:substitute&lt;/code&gt; command in &lt;a href=&quot;https://vi.stackexchange.com/a/13931/343&quot;&gt;B Layer's answer&lt;/a&gt; and, because it just uses normal-mode commands, should be easy to understand for any Vim user:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:%norm&lt;/code&gt;: Run the following series of normal mode commands on every line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt;: Move to end of line; substitute &lt;code&gt;g_&lt;/code&gt; for &lt;code&gt;$&lt;/code&gt; if some of your lines end in whitespace,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;diw&lt;/code&gt;: Delete inner word; substitute &lt;code&gt;W&lt;/code&gt; for &lt;code&gt;w&lt;/code&gt; if you want to move WORDs,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt;: Move to beginning of line; substitute &lt;code&gt;^&lt;/code&gt; for &lt;code&gt;0&lt;/code&gt; if you want to preserve indentation,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt;: Put the word at the beginning of the line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&amp;lt;Space&amp;gt;&lt;/code&gt;: Add in a space.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If your file also contains blank lines, you can use &lt;code&gt;:global&lt;/code&gt; to only run the &lt;code&gt;:normal&lt;/code&gt; command on non-blank lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\S/norm $diw0Pa&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Further improvements are possible if you need more sophisticated handling of whitespace.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-10-16T13:26:32.007" LastActivityDate="2017-10-16T13:26:32.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13944" PostTypeId="2" ParentId="13939" CreationDate="2017-10-16T13:17:14.277" Score="5" Body="&lt;p&gt;From your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;set cursorline&#xA;set                &quot; &amp;lt;- HERE&#xA;syntax on&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &lt;code&gt;set&lt;/code&gt; command must be causing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looks like during initialization Vim&#xA;dumps output to terminal, but you don't see it until&#xA;Vim is closed.  I get similar behaviour if I put stray &lt;code&gt;set&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt;&#xA;file (although I do need to press enter to skip the output, but this must be due to much bigger number of changed options).&lt;/p&gt;&#xA;" OwnerUserId="860" LastActivityDate="2017-10-16T13:17:14.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13945" PostTypeId="1" AcceptedAnswerId="13946" CreationDate="2017-10-16T14:31:09.657" Score="2" ViewCount="1832" Body="&lt;p&gt;While working on something like laravel, I end up creating the same view files index.blade.php, create.blade.php, show.blade.php within different folders like views/articles, views/comments, etc using the nerdTree mostly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to create the files from the command mode or through any plugin, for which i can create a key mapping to speed up things ?&lt;/p&gt;&#xA;" OwnerUserId="14738" LastEditorUserId="14738" LastEditDate="2017-10-16T14:43:09.310" LastActivityDate="2017-10-16T15:09:38.037" Title="How to create multiple files?" Tags="|command-line|multiple-files|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13946" PostTypeId="2" ParentId="13945" CreationDate="2017-10-16T15:08:08.543" Score="5" Body="&lt;p&gt;You can create a bunch of filenamed buffers from within vim using &lt;code&gt;:argadd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argadd dir1/index.blade.php dir2/create.blade.php foo/show.blade.php &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use the syntax&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argadd dir/{foo,bar}.php&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From there, you can switch between buffers using &lt;code&gt;:next&lt;/code&gt;/&lt;code&gt;:Next&lt;/code&gt;, &lt;code&gt;:buffer&lt;/code&gt; or any other way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: vim does not default write the empty buffers to disk unless you explicitly &lt;code&gt;:w&lt;/code&gt; them.  You can easily create them all on disk using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdo w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The plugin &lt;code&gt;vim-projectionist&lt;/code&gt; is designed for this use case:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-projectionist&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/tpope/vim-projectionist&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and the &lt;code&gt;vim-laravel&lt;/code&gt; plugin already has support for &lt;code&gt;vim-projectionist&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/noahfrederick/vim-laravel&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/noahfrederick/vim-laravel&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-10-16T15:08:08.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13947" PostTypeId="2" ParentId="13945" CreationDate="2017-10-16T15:09:38.037" Score="2" Body="&lt;p&gt;You could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* MakeLaravelFiles call MakeLaravelFiles()&#xA;function! MakeLaravelFiles()&#xA;  !touch /path/to/first/file /path/to/second/file /path/to/third/file&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then setup a keymapping to that function, aka&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;ml :MakeLaravelFiles&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note: this snippet creates blank files, but you can use any CLI command you prefer instead of &lt;code&gt;touch&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="14" LastActivityDate="2017-10-16T15:09:38.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13948" PostTypeId="1" CreationDate="2017-10-16T16:56:29.173" Score="0" ViewCount="162" Body="&lt;p&gt;I am using exactly the same version of Vim (Gvim 8.0.1123) across all my Windows machines, and only have the following problem on one of them:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;That I cannot use &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; in insert-mode, to decrease the indentation level of the currently edited line. &lt;code&gt;&amp;lt;c-t&amp;gt;&lt;/code&gt; does still work for increasing the indentation level.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;On this particular Windows machine (Windows 10 Pro), I have tried to uninstall and reinstall Gvim.exe for a few times, and the problem is consistent;&lt;/li&gt;&#xA;&lt;li&gt;And, &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; fails to take effect regardless of the filetypes.&lt;/li&gt;&#xA;&lt;li&gt;I have tried to use a &lt;code&gt;:Listmaps&lt;/code&gt; function (from Plug-in &lt;code&gt;vim-scripts/listmaps.vim&lt;/code&gt;), but do not find anything thing special for &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; mapping.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Environment&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Across all the Windows machines that I have, I should have had almost everything identical: &lt;strong&gt;same&lt;/strong&gt; Gvim distribution (installed from the same &lt;code&gt;*.exe&lt;/code&gt; file), &lt;strong&gt;same&lt;/strong&gt; &lt;code&gt;_vimrc&lt;/code&gt;: all sourcing settings from a common Dropbox folder and &lt;strong&gt;same&lt;/strong&gt; directory structure etc.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Interesting observation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;According to the standard Vim debugging protocol, I shall first try to start Vim (or Gvim) afresh, with no &lt;code&gt;.vimrc&lt;/code&gt; (or &lt;code&gt;_vimrc&lt;/code&gt; loaded at all). I have tried both of the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vim -u NONE -U NONE -N&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gvim -u NONE -U NONE -N&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;While I am not confident that when I open &lt;code&gt;vim&lt;/code&gt; in the Windows Command Prompt, key-code representing the &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; mapping is passed to the Vim process or not, it is interesting to observe that, the Gvim process started afresh shall have the same problem: &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; does not decrease the level of indentation. I think things are only getting more interesting for now.&lt;/p&gt;&#xA;" OwnerUserId="2398" LastEditorUserId="1292" LastEditDate="2018-10-09T22:49:49.850" LastActivityDate="2018-10-09T22:49:49.850" Title="How do I debug normal/insert/cart mode shortcuts that don't behave as expected?" Tags="|gvim|microsoft-windows|" AnswerCount="2" CommentCount="7" FavoriteCount="0" ClosedDate="2017-10-18T07:29:27.190" ContentLicense="CC BY-SA 3.0" />
  <row Id="13949" PostTypeId="1" AcceptedAnswerId="13950" CreationDate="2017-10-16T19:20:56.473" Score="1" ViewCount="234" Body="&lt;p&gt;Context is Ruby. Lets say I have a long line which has a block which I want to have simply in multiple lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let:(variable) { do.some.stuff(expressed_as_a_long_line { x }) }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like split this into multiple lines like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let:(variable) {&#xA;  do.some.stuff(expressed_as_a_long_line { x }) &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and later maybe even:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let:(variable) {&#xA;  do.some.stuff(&#xA;    expressed_as_a_long_line { x }&#xA;  ) &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any simple inbuilt way or plugin for similar stuff?&lt;/p&gt;&#xA;" OwnerUserId="14741" LastActivityDate="2017-10-17T15:36:04.600" Title="Split a block to multiple lines with respecting indenting" Tags="|indentation|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13950" PostTypeId="2" ParentId="13949" CreationDate="2017-10-16T19:50:36.103" Score="3" Body="&lt;p&gt;The plugin &lt;code&gt;splitjoin.vim&lt;/code&gt; is designed to do this and has support for ruby. &lt;a href=&quot;https://github.com/AndrewRadev/splitjoin.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/AndrewRadev/splitjoin.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a vanilla solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! OpenCode()&#xA;    call searchpair('{\|(', '', ')\|}', 'bW')&#xA;    exe 'normal!' &quot;%i\&amp;lt;c-m&amp;gt;\&amp;lt;esc&amp;gt;%a\&amp;lt;c-m&amp;gt;\&amp;lt;esc&amp;gt;\&amp;lt;c-o&amp;gt;m]&quot;&#xA;    normal! '[=']&#xA;    let l:save_slash = @/&#xA;    :'[,']s/\s\+$//e&#xA;    let @/ = l:save_slash&#xA;endfunction&#xA;nnoremap &amp;lt;c-b&amp;gt; :&amp;lt;c-u&amp;gt;call OpenCode()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing Ctrl-B when &lt;em&gt;inside&lt;/em&gt; a block will open it up.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-10-17T15:36:04.600" LastActivityDate="2017-10-17T15:36:04.600" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13951" PostTypeId="1" AcceptedAnswerId="13956" CreationDate="2017-10-17T01:33:33.683" Score="2" ViewCount="511" Body="&lt;p&gt;This is an example of my file format basically it follows this layout:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;word&amp;gt; &amp;lt;wordWithNumbers&amp;gt; &amp;lt;wraped text&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sadfa 23eafa asdfasdf asdfdsf sflsdkjf ;lkja flksad ks adfsdf&#xA;             asdfasdf dfas fasd fadsfaslf;ajdf;lkadjfadjfasdf&#xA;&#xA;ccsfe f32eee asdfasdf asdfdsf sflsdkjf ;lkja flksad ks adfsdf&#xA;             asdfasdf dfas fasd fadsfaslf;ajdf;lkadjfadjfasdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my syntax file that aims to color each of the 3 parts differently&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sy case match&#xA;&#xA;:sy region A start=/^/ end=/^[a-zA-Z]\+ [0-9a-zA-Z]\+ / contains=B,C&#xA;&#xA;:sy match B /^[a-zA-Z]\+ / contained        &quot; seems to work fine.&#xA;:sy match C / [0-9a-zA-Z]\+ / contained     &quot; alternatively colors words in&#xA;                                            &quot; &amp;lt;wraped text&amp;gt;!&#xA;&#xA;:hi B ctermfg=blue&#xA;:hi C ctermfg=green&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Specifically, I'm amused why match C escapes its parent region A. This results in miscolouring &lt;code&gt;&amp;lt;wordwithnumbers&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;wraped text&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea where is my error please?&lt;/p&gt;&#xA;" OwnerUserId="14744" LastEditorUserId="14744" LastEditDate="2017-10-17T01:38:49.193" LastActivityDate="2017-10-17T14:08:52.563" Title="How to write a syntax file" Tags="|syntax-highlighting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13952" PostTypeId="1" AcceptedAnswerId="14245" CreationDate="2017-10-17T06:16:57.247" Score="0" ViewCount="1299" Body="&lt;p&gt;Follow &lt;a href=&quot;https://vi.stackexchange.com/questions/6731/vim-syntax-pattern-to-highlight-python-keyword-argument?noredirect=1&amp;amp;lq=1&quot;&gt;here&lt;/a&gt; @muru point out how to highlight keyword in a function and function name but I want also highlight parameters, for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;abc = myFunc(Green, Orange=Green, Green, abcd(Orange=Green), Green)&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;Green&lt;/code&gt;: it's highlighted &lt;code&gt;green&lt;/code&gt;,&lt;br&gt;&#xA;&lt;code&gt;Orange&lt;/code&gt;: it's highlighted &lt;code&gt;Orange&lt;/code&gt;.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume that we matched function name:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match pFun &quot;XXXX&quot; contains=pFun nextgroup=pVars &#xA;syn region pVars start=&quot;(&quot; end=&quot;)&quot; contained contains=pKeyword,pParam transparent keepend&#xA;syn match pKeyword &quot;\i*\ze\s*=[^=]&quot; contained&#xA;syn match pParam &quot;[^,]*&quot; contained contais=XXXX&#xA;hi def link pKeyword something_green&#xA;hi def link pParam something_orange&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see problems, It overwirte pKeyword with pParam (&lt;code&gt;[^,]*&lt;/code&gt; also match &lt;code&gt;\i*\ze\s*=[^=]&lt;/code&gt;)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question is&lt;/strong&gt;: How to write pParam correctly to exclude pKeyword that give correct highlight.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2017-11-18T06:25:41.433" Title="Highlight function's keyword and parameters" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13953" PostTypeId="2" ParentId="13951" CreationDate="2017-10-17T09:27:33.800" Score="2" Body="&lt;p&gt;I'm no expert on syntax highlighting but I thought I'd take a crack at this as I'd like to learn this stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are seeing the alternating coloring because a) your pattern will match &lt;em&gt;any&lt;/em&gt; space surrounded letter/number words on the line and b) by putting spaces on both ends you prevent adjacent words from matching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was able to get it to work like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sy region A start=/^/ end=/$/ contains=B,C&#xA;:sy match B /^\([a-zA-Z]\+\)/ contained&#xA;:sy match C /\(^[a-zA-Z]\+\)\@&amp;lt;= \(0-9a-zA-Z\+\)/ contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will result in blue colored first word, green second word, and the remainder of the line whatever color is assigned to &lt;code&gt;A&lt;/code&gt;. (I assume this is what you mean by coloring the 3 parts differently.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue with your version is the patterns are too permissive. They need to be constrained to the exact location desired. And some advanced regex concepts are needed for this, i.e. lookarounds. For &lt;code&gt;C&lt;/code&gt; I'm using a &lt;em&gt;positive look-behind&lt;/em&gt; atom (&lt;code&gt;\@&amp;lt;=&lt;/code&gt;) which confirms that the preceding pattern is present but does not count it as part of the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I encourage you to look at existing syntax files. They are verbose but quite illuminating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;P.S. At least that's my inexperienced understanding. I'll defer to any experts who chime in!&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-10-17T09:35:27.723" LastActivityDate="2017-10-17T09:35:27.723" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13954" PostTypeId="1" AcceptedAnswerId="13955" CreationDate="2017-10-17T11:08:28.860" Score="2" ViewCount="1051" Body="&lt;p&gt;I knew that map &lt;strong&gt;/&lt;/strong&gt; is &lt;strong&gt;_&lt;/strong&gt; on linux, but it not work on windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do to map it?&lt;/p&gt;&#xA;" OwnerUserId="14514" LastActivityDate="2017-10-17T12:04:03.867" Title="Map &lt;C-/&gt; on linux and windows" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ClosedDate="2017-10-21T03:14:25.100" ContentLicense="CC BY-SA 3.0" />
  <row Id="13955" PostTypeId="2" ParentId="13954" CreationDate="2017-10-17T12:04:03.867" Score="5" Body="&lt;p&gt;&lt;em&gt;Assuming you are talking about gVim&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are correct about &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;/&lt;/kbd&gt; working on Linux but not on Windows. That is because gVim under Windows doesn't see the &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;/&lt;/kbd&gt; combination. You can check if Vim receives a given sequence by hitting &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; (or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;q&lt;/kbd&gt; if you are using &lt;a href=&quot;http://vimhelp.appspot.com/gui_w32.txt.html#mswin%2evim&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;mswin.vim&lt;/code&gt;&lt;/a&gt;) followed the sequence, as explained in &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq%2d20%2e4&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help faq-20.4&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq%2d20%2e5&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;faq-20.5&lt;/code&gt;&lt;/a&gt; talks explicitly about &lt;kbd&gt;Ctrl&lt;/kbd&gt; sequences, and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;/&lt;/kbd&gt; isn't listed there as reliably detected by Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus I believe you have two options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;select another key combination to map&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;use a external program to translate that combination into something that Vim can detect; for example, using &lt;a href=&quot;https://www.autohotkey.com/&quot; rel=&quot;noreferrer&quot;&gt;Autohotkey&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifWinActive ahk_class Vim&#xA;   Capslock::Esc&#xA;#ifWinActive&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use the above AHK snippet to remap &lt;kbd&gt;Capslock&lt;/kbd&gt; to &lt;kbd&gt;Esc&lt;/kbd&gt; when gVim window is active; you could try to remap &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;/&lt;/kbd&gt; to something like &lt;kbd&gt;F12&lt;/kbd&gt; and then map &lt;kbd&gt;F12&lt;/kbd&gt; in Vim.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2017-10-17T12:04:03.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13956" PostTypeId="2" ParentId="13951" CreationDate="2017-10-17T13:44:45.137" Score="2" Body="&lt;p&gt;Your error is simply that you've misunderstood the &lt;code&gt;contains&lt;/code&gt;/&lt;code&gt;contained&lt;/code&gt; keywords. See &lt;code&gt;:h syn-contains&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The &quot;contains&quot; argument is followed by a list of syntax group names.  These groups will be allowed to &lt;strong&gt;&lt;em&gt;begin&lt;/em&gt;&lt;/strong&gt; inside the item &lt;strong&gt;&lt;em&gt;(they may extend past the containing group's end).&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(emphasis mine)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &quot;match C escapes its parent region&quot; is the correct behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of ways I could think of to adapt your solution to be do what you want (&lt;a href=&quot;https://vi.stackexchange.com/a/13953/343&quot;&gt;B Layer has already suggested making the regular expressions more specific&lt;/a&gt;), but the code you've given actually works correctly (with regards to the matching of syntax groups) for me on the example you've given: &lt;code&gt;&amp;lt;word&amp;gt;&lt;/code&gt; is matched by B and A (and therefore coloured blue), &lt;code&gt;&amp;lt;wordwithnumbers&amp;gt;&lt;/code&gt; is matched by A alone (no colour), and words in &lt;code&gt;&amp;lt;wrappedtext&amp;gt;&lt;/code&gt; alternate between A alone (no colour) and C and A (green).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do note that the last words on the line don't always match group C when they should. This is because you have specified that group C must end with a space, which doesn't occur if the word is at the end of the line. One quick fix for this is to match whitespace-including-line-breaks instead of a literal &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; character by using &lt;code&gt;\_s&lt;/code&gt; (See &lt;code&gt;:h 27.8&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sy match C / [0-9a-zA-Z]\+\_s/ contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you can clarify more precisely what problems you're seeing in the sample text given, or add further examples where the highlighting fails, I should be able to come up with a complete solution as well as simply describing the errors in your code.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-10-17T14:08:52.563" LastActivityDate="2017-10-17T14:08:52.563" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13957" PostTypeId="2" ParentId="13948" CreationDate="2017-10-17T15:01:55.743" Score="1" Body="&lt;p&gt;If your problem only happens in insert mode, then it is clear that Vim sees the key combination. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Despite you use the same &lt;code&gt;_vimrc&lt;/code&gt; file, it might be checking for some environment variable that is different in that specific machine. In any case, as it is related to your Vim configuration, you should follow the procedure in &lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;&quot;How do I debug my vimrc file?&quot;&lt;/a&gt; (or the procedure at &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq%2d2%2e5&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim faq-2.5&lt;/a&gt;). It will allow you to find which line on your &lt;code&gt;_vimrc&lt;/code&gt; or plugin triggers the problem.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2017-10-17T15:01:55.743" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13958" PostTypeId="2" ParentId="13948" CreationDate="2017-10-17T18:53:54.573" Score="0" Body="&lt;h2&gt;Third-party application has &quot;stolen&quot; the &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; mapping.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;My particular problem is caused by a third-party application that fails to occupy the key-mapping of &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; all the time. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;At times, such third-party application shall lose control over the &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; mapping completely. Per my previous testing, it happens to be when I was testing the &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; mapping in Normal mode.&lt;/li&gt;&#xA;&lt;li&gt;Also, AutoHotKey, an auto-script tool that handles key-mappings very well, is able to override the mapping of &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; at the system level&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Uninstalling the third-party application solves the problem.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Takeaway&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;When claiming that a certain key-binding is not working for Vim, one would like to test multiple times, across multiple modes (Normal, Insert, Visual, etc). This shall help to identify whether it is an internal problem with Vim, or should it be an OS-wide problem: a third-party application is occupying the shortcut.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, when one is replicating his/her Vim distribution across multiple machines (and/or different operating systems), check if the same problem is occurring on any other machine/system. If the bug/problem is still specific to one of the machines, then, there is a high probability that a third-party application is causing the particular problem.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Credits:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I would like to give credits in solving this question to @mMontu, who pointed out correctly, that one shall follow the debugging procedure:  &lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;&quot;How do I debug my vimrc file?&quot;&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="2398" LastActivityDate="2017-10-17T18:53:54.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13959" PostTypeId="1" AcceptedAnswerId="13962" CreationDate="2017-10-17T19:36:26.420" Score="2" ViewCount="300" Body="&lt;p&gt;Is it possible to configure vim and cindent to not alter indentation in c++ comments when reindenting the file (gg=G) ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have some formated lists in comments aligned with 4 spaces but vim interpret this as bad indent and realign everything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA;    my list:&#xA;         * item 1&#xA;         * item 2&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA;    my list:&#xA;    * item 1&#xA;    * item 2&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want a way to tell vim: &quot;Don't touch to comments content but indent everything else.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is important because our project use doxygen with a markdown like parser to generate documentation and indentation is used by list levels.&lt;/p&gt;&#xA;" OwnerUserId="13084" LastEditorUserId="13084" LastEditDate="2017-10-17T20:12:46.573" LastActivityDate="2017-10-18T10:23:02.460" Title="Preserve indentation in C++ comments" Tags="|indentation|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13960" PostTypeId="1" CreationDate="2017-10-17T21:27:32.490" Score="5" ViewCount="1061" Body="&lt;p&gt;I like &lt;code&gt;autochdir&lt;/code&gt; a lot, but it breaks my tag browsing, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;main.c:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;d/a.c:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set autochdir&#xA;set tagrelative&#xA;set tags=tags;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;tags:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;main    d/a.c   /^int main() {}$/;&quot;     f&#xA;main    main.c  /^int main() {}$/;&quot;     f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;generated with &lt;code&gt;ctags -R&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u vimrc main.c&#xA;:tag main&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then this works fine and goes to &lt;code&gt;d/a.c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However this fails as it searches for &lt;code&gt;main.c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;:ts&lt;/code&gt; shows relative paths.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose the problem is that &lt;code&gt;:pwd&lt;/code&gt; is &lt;code&gt;d/&lt;/code&gt;, and the path it looks for is just &lt;code&gt;main.c&lt;/code&gt; which is not present in &lt;code&gt;d/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even more confusing to me, if I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u vimrc d/a.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then everything works, and &lt;code&gt;:ts&lt;/code&gt; shows absolute paths.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to solve this? Why isn't &lt;code&gt;tagrelative&lt;/code&gt; helping?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim 8.0, Ubuntu 17.04.&lt;/p&gt;&#xA;" OwnerUserId="2038" LastEditorUserId="2038" LastEditDate="2017-10-18T09:35:39.600" LastActivityDate="2017-10-19T10:51:58.763" Title="How to browse tags when autochdir is set?" Tags="|tags|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13961" PostTypeId="1" CreationDate="2017-10-18T02:20:36.970" Score="3" ViewCount="212" Body="&lt;p&gt;The problem I have is, for example, when using undo (&lt;code&gt;u&lt;/code&gt; in normal mode) or redo, sometimes the message, like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 change; before #520  09:20:15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;stays, but more often it flickers for a split second and is then erased. Then I have to go to &lt;code&gt;:mess&lt;/code&gt; to read it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason seems to be that the message is erased whenever the window is redrawn. (Because in cases when the line above isn't erased, if I resize the gVim window, it causes a redraw and the message disappears at that point.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it would be better if the latest message were displayed until something else starts happening in the message/command line, as opposed to on redraw. But I can't find any pointers to help change that behaviour.&lt;/p&gt;&#xA;" OwnerUserId="2334" LastActivityDate="2017-10-18T14:00:16.677" Title="How to let the latest message persist on redraw?" Tags="|redraw|message|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13962" PostTypeId="2" ParentId="13959" CreationDate="2017-10-18T10:23:02.460" Score="1" Body="&lt;p&gt;I don't believe it's possible to achieve this with &lt;code&gt;'cinoptions'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The correct solution is probably to write a new &lt;code&gt;indentexpr&lt;/code&gt; that applies C-indenting (accessible via the &lt;code&gt;cindent()&lt;/code&gt; function) only to lines that aren't within comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, here's a couple of quick and dirty solutions:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Using a Macro&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First, turn off &lt;code&gt;'wrapscan'&lt;/code&gt;, so searches end when no more matches are found.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nows&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Move the cursor to any position where it's &lt;em&gt;not&lt;/em&gt; within a comment, and then record a recursive macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqqqq=/\/\*\*\|\%$/-&amp;lt;CR&amp;gt;n/\*\//+&amp;lt;CR&amp;gt;@qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can jump to the start of the file and run the macro.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(N.B. If the very first line of your file is a comment, you'll need to skip past this before running the macro, e.g. by doing this instead: &lt;code&gt;gg/\*\/&amp;lt;CR&amp;gt;+@q&lt;/code&gt;)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Broken down:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;qqqqq&lt;/code&gt;: Clear out the &lt;code&gt;q&lt;/code&gt; register and start recording a macro.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;=/\/\*\*\|\%$/-&amp;lt;CR&amp;gt;&lt;/code&gt;: Indent up to the beginning of the first comment or to the end of the file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;n/\*\/+&amp;lt;CR&amp;gt;&lt;/code&gt;: Jump to the end of the comment.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@q&lt;/code&gt;: Playback the &lt;code&gt;q&lt;/code&gt; macro. Currently this is empty (we cleared it in the first step) so nothing happens, but when we run this macro for the first time, this will cause the macro to repeat as many times as necessary.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: Complete the recording.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The first regular expression used is broken down thus:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt;: start of expression&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\/\*\*&lt;/code&gt;: the start of comment (literal &lt;code&gt;/**&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\|&lt;/code&gt;: or&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%$&lt;/code&gt;: the end of the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt;: end of expression&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-&lt;/code&gt;: offset up one line (so the line itself is not indented).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Using a Function&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! IndentIgnoringComments()&#xA;  let in_comment = 0&#xA;  for i in range(1, line('$'))&#xA;    if !in_comment&#xA;      &quot; Check if this line starts a comment&#xA;      if getline(i) =~# '^\s*/\*\*'&#xA;        let in_comment = 1&#xA;      else&#xA;        &quot; Indent line 'i'&#xA;        execute i . &quot;normal ==&quot;&#xA;      endif&#xA;    else&#xA;      &quot; Check if this line ends the comment&#xA;      if getline(i) =~# '\*\/\s*$'&#xA;        let in_comment = 0&#xA;      endif&#xA;    endif&#xA;  endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can run this with &lt;code&gt;:call IndentIgnoringComments()&lt;/code&gt; or you could set up a command or a mapping. e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;= :call IndentIgnoringComments()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-10-18T10:23:02.460" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13964" PostTypeId="2" ParentId="13961" CreationDate="2017-10-18T14:00:16.677" Score="3" Body="&lt;p&gt;Not really what you want but you can still redirect messages to a split with such a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @&quot;&amp;gt;|silent messages|redir END|split|put&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just map it to a shortcut that suits you.&lt;/p&gt;&#xA;" OwnerUserId="13084" LastActivityDate="2017-10-18T14:00:16.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13965" PostTypeId="1" AcceptedAnswerId="13967" CreationDate="2017-10-18T15:56:20.287" Score="16" ViewCount="8812" Body="&lt;p&gt;I read a &lt;a href=&quot;https://medium.com/@crashybang/supercharge-vim-with-fzf-and-ripgrep-d4661fc853d2&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;document&lt;/em&gt;&lt;/a&gt; about vim and the author suggest a line of code that should be put in .vimrc but I totally have no idea what it is.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --glob &quot;!.git/*&quot; --color &quot;always&quot; '.shellescape(&amp;lt;q-args&amp;gt;), 1, &amp;lt;bang&amp;gt;0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So what is &lt;code&gt;command!&lt;/code&gt;, &lt;code&gt;-bang&lt;/code&gt;, &lt;code&gt;-nargs&lt;/code&gt;,etc?&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="1841" LastEditDate="2017-10-18T16:16:01.330" LastActivityDate="2017-10-18T16:16:01.330" Title="What is command! -bang -nargs=* in a vimrc file?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13966" PostTypeId="1" CreationDate="2017-10-18T16:06:51.157" Score="1" ViewCount="63" Body="&lt;p&gt;I am formatting &lt;code&gt;elixir&lt;/code&gt; files &lt;code&gt;.ex&lt;/code&gt; with the help of a contributed plug-in for &lt;code&gt;nvim&lt;/code&gt; like this on Windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmd&amp;gt; nvim.exe -i NONE -n -E +&quot;norm gg=G&quot; -cwq c:/file.ex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine when the command is called inside normal Windows command line prompt. However, if I run the same command in NodeJS using &lt;code&gt;child_process&lt;/code&gt; the formatting gets wrong (not proper indentations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Correct formatting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;defmodule BackendWeb.Endpoint do&#xA;  def go do&#xA;    IO.puts &quot;go&quot;&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Faulty formatting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;defmodule BackendWeb.Endpoint do&#xA;def go do&#xA;IO.puts &quot;go&quot;&#xA;end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea what might be going on here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This formats the file badly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;require('child_process').exec('C:/opt/neovim/bin/nvim.exe -i NONE -n -E +&quot;norm gg=G&quot; -cwq ' + path, function puts(error, stdout, stderr) {});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This formats the file properly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;require('child_process').exec('start /MIN C:/opt/neovim/bin/nvim.exe -i NONE -n -E +&quot;norm gg=G&quot; -cwq ' + path, function puts(error, stdout, stderr) {});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;start /MIN&lt;/code&gt; to run &lt;code&gt;nvim&lt;/code&gt; solved the problem, but it creates for fraction of a second some task bar item (minified window).&lt;/p&gt;&#xA;" OwnerUserId="14763" LastEditorUserId="1841" LastEditDate="2017-10-19T07:28:28.393" LastActivityDate="2017-10-19T07:28:28.393" Title="Incorrect formatting of file when calling nvim inside NodeJS script" Tags="|formatting|microsoft-windows|cmdline|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13967" PostTypeId="2" ParentId="13965" CreationDate="2017-10-18T16:13:16.587" Score="21" Body="&lt;p&gt;As always, the help is your best friend:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3acommand&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :command&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;:com[mand][!] [{attr}...] {cmd} {rep}&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Define a user command.  The name of the command is&#xA;  {cmd} and its replacement text is {rep}.  The command's&#xA;  attributes (see below) are {attr}.  If the command&#xA;  already exists, an error is reported, unless a ! is&#xA;  specified, in which case the command is redefined.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus &lt;code&gt;:command!&lt;/code&gt; is used to create a new command that you can use from the command line. Here the new command is &lt;code&gt;:Find&lt;/code&gt; and it is used to execute &lt;code&gt;fzf#vim#grep()&lt;/code&gt; which is a call to the plugin &lt;a href=&quot;https://github.com/junegunn/fzf&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;fzf&lt;/code&gt;&lt;/a&gt; which will allow to fuzzy find some files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other arguments are described in the documentation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3acommand-nargs&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :command-nargs&lt;/code&gt;&lt;/a&gt; &lt;code&gt;-nargs&lt;/code&gt; is used to make the new command able to take an argument &lt;code&gt;:Find arg1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3acommand-bang&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :command-bang&lt;/code&gt;&lt;/a&gt; &lt;code&gt;-bang&lt;/code&gt; is used to make the new command able to interpret a &lt;code&gt;!&lt;/code&gt; like in &lt;code&gt;:Find!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;!&lt;/code&gt; right after &lt;code&gt;command&lt;/code&gt; is used to tell vim to redefine the command if it already exists, this way when you source your &lt;code&gt;.vimrc&lt;/code&gt; you don't have an error message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the arguments passed to the &lt;code&gt;fzf&lt;/code&gt; function, I'll let you read the doc of the plugin to see what they do :)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-10-18T16:13:16.587" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13968" PostTypeId="1" AcceptedAnswerId="13969" CreationDate="2017-10-18T22:11:59.050" Score="7" ViewCount="6532" Body="&lt;p&gt;Is there a way, built-in or with a plugin, to get an outline of my code in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Eclipse, there is a panel that shows an outline of the code in the file, showing a breakdown of the classes and methods:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyClass&#xA;  MyClass()&#xA;  myMethod(int, String)&#xA;AnotherClass&#xA;  someMoreMethod()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Anything is possible in Vim, but is there currently a way to do this, either built-in or by installing a plugin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Support for jumping to the different methods would be nice, but all I need is something to show the structure of the code.  I would prefer a solution that worked for most of the top languages, but I really need Perl support (and yes, I know my sample code is Java).&lt;/p&gt;&#xA;" OwnerUserId="14468" LastActivityDate="2017-10-19T09:33:06.443" Title="Show Outline of Code" Tags="|navigation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13969" PostTypeId="2" ParentId="13968" CreationDate="2017-10-18T23:19:02.927" Score="8" Body="&lt;p&gt;This is possible with &lt;a href=&quot;https://github.com/majutsushi/tagbar&quot; rel=&quot;noreferrer&quot;&gt;Tagbar plugin&lt;/a&gt;, which use ctags to generate the tags. Used in collaboration with &lt;a href=&quot;https://ctags.io/&quot; rel=&quot;noreferrer&quot;&gt;Universal Ctags&lt;/a&gt;, it supports various langages.&lt;/p&gt;&#xA;" OwnerUserId="13084" LastActivityDate="2017-10-18T23:19:02.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13971" PostTypeId="1" AcceptedAnswerId="13989" CreationDate="2017-10-19T07:26:52.017" Score="3" ViewCount="442" Body="&lt;p&gt;For a few weeks, I have the strangest issue, on a single computer.&#xA;On this computer, when I open a file with Vim, the yank register have a low chance of being pasted on the current position of the cursor, with the number &quot;2&quot; after it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eg : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;myFile.cxx&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;algorithm&amp;gt;&#xA;#include &amp;lt;iterator&amp;gt;&#xA;#include &amp;lt;set&amp;gt;&#xA;#include &amp;lt;cmath&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;my yank register&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;irrelevant code&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;myFile.cxx after i open it with &lt;code&gt;vim myFile.cxx&lt;/code&gt; in xterm.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;irrelevant cod2&#xA;#include &amp;lt;algorithm&amp;gt;&#xA;#include &amp;lt;iterator&amp;gt;&#xA;#include &amp;lt;set&amp;gt;&#xA;#include &amp;lt;cmath&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suspected a bug in my .vimrc configuration so i minimized it, but the bug is still present. Here is my current .vimrc, without any .vim folder present.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax on        &quot;Turn on syntax highlighting&#xA;:set laststatus=2 &quot;Always show status line&#xA;:set tabstop=2    &quot;Number of spaces a TAB in the text stands for&#xA;:set shiftwidth=2 &quot;Number of spaces used for each step of (auto)indent&#xA;:set hlsearch     &quot;Have vim highlight the target of a search&#xA;:set incsearch    &quot;Do incremental searching&#xA;:set ruler        &quot;Show the cursor position all the time&#xA;:set number       &quot;Show line numbers&#xA;&quot;Converting tabs to spaces&#xA;:set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The bug appears only after some time of usage after booting and using vim. Once it starts appearing, the chance of seeing it are quite low, but not negligeable, however I have a hard time reproducing it voluntarily.&lt;/p&gt;&#xA;" OwnerUserId="2056" LastEditorUserId="2056" LastEditDate="2017-10-19T09:24:04.477" LastActivityDate="2017-10-20T09:07:53.350" Title="Vim pasting yank register when opening a new file" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13972" PostTypeId="2" ParentId="12676" CreationDate="2017-10-19T08:04:02.593" Score="0" Body="&lt;p&gt;Ok in fact I needed to match also the leading spaces with this errorformat:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;errorformat=&amp;amp;errorformat . ',' . '%*[ ]Error: %f: line %l: %m'&#xA;let &amp;amp;errorformat=&amp;amp;errorformat . ',' . '%*[ ]Error: %f: %m'&#xA;let &amp;amp;errorformat=&amp;amp;errorformat . ',' . '%*[ ]Fatal: %f: line %l: %m'&#xA;let &amp;amp;errorformat=&amp;amp;errorformat . ',' . '%*[ ]Fatal: %f: %m'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works now like a charm !&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to markzen on freenode #vim who helped me to find out the solution.&lt;/p&gt;&#xA;" OwnerUserId="13084" LastActivityDate="2017-10-19T08:04:02.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13973" PostTypeId="1" CreationDate="2017-10-19T08:21:49.103" Score="0" ViewCount="1884" Body="&lt;p&gt;I'm using vim for python scripting and found that I pretty much often need to jump a word forward &lt;code&gt;e&lt;/code&gt;-button and enter insert mode. Is there some built-in shortcut for this or &lt;code&gt;ea&lt;/code&gt; is reuqired to push all the time?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2017-10-19T15:28:45.103" Title="Vim jump word forward and enter insert mode" Tags="|vimrc|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13974" PostTypeId="2" ParentId="13973" CreationDate="2017-10-19T08:30:03.327" Score="6" Body="&lt;p&gt;There's no single-key shortcut for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two keystrokes is already pretty short, but there are a few keys on your keyboard that Vim doesn't already use in normal mode, or that carry out a command already provided by another key, so if you wanted to you could set up your own shortcut with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;space&amp;gt; ea&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h normal-index&lt;/code&gt; for the complete list of keys that already have functions in normal mode. Anything that's &lt;em&gt;not&lt;/em&gt; listed you can use, and anything that has the description &quot;same as ...&quot; would also be a good candidate. See also &lt;code&gt;:h map-which-keys&lt;/code&gt; for some suggestions.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-10-19T15:28:45.103" LastActivityDate="2017-10-19T15:28:45.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13975" PostTypeId="2" ParentId="13973" CreationDate="2017-10-19T08:37:34.217" Score="5" Body="&lt;p&gt;I think there is no better solution than pressing &lt;code&gt;ea&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you can always add your own shortcut (even on a single char if you want but you will override one default shortcut because everything is taken, choose something you don't use often).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; ea&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for example. &lt;/p&gt;&#xA;" OwnerUserId="13084" LastActivityDate="2017-10-19T08:37:34.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13976" PostTypeId="1" AcceptedAnswerId="13978" CreationDate="2017-10-19T09:26:01.073" Score="0" ViewCount="470" Body="&lt;p&gt;I'm using vim, and I have used ctags and placed this in the ctags config file as per &lt;a href=&quot;https://ericjmritz.wordpress.com/2013/05/22/finding-php-traits-with-exuberant-ctags/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; post:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--regex-php=/^[ \t]*trait[ \t]+([a-z0_9_]+)/\1/t,traits/i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the problem is that I still can't find the trait.. so for example in this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /*Mark user as verified first*/&#xA;    $user = App\User::find($this-&amp;gt;getClient()-&amp;gt;id);&#xA;    $user-&amp;gt;is_verified = true;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;pressing &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt; on my mac returns this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; tags&#xA; prt  path  &amp;lt;mru&amp;gt;={ files }=&amp;lt;buf&amp;gt; &amp;lt;-&amp;gt;                                                                                                                                                                                                          /Users/Shared/dev/php/toters-api&#xA;&amp;gt;&amp;gt;&amp;gt; _&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;jumping to definition in php storm on the same file works fine, and takes me here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;trait ClientHelpers{&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;private $client      = null;&#xA;private $clientToken = null;&#xA;&#xA;&#xA;/*JWT*/&#xA;protected function getClient()&#xA;{&#xA;    if (!$this-&amp;gt;client) {&#xA;        $this-&amp;gt;setClientToken();&#xA;    }&#xA;    return $this-&amp;gt;client;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ideas?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;i checked the contents of my tags file, and &lt;code&gt;getClient&lt;/code&gt; exists there!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getClient       tests/Helpers/ClientHelpers.php /^    protected function getClient()$/;&quot;        f       trait:ClientHelpers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is weird. for completion sake, here is my &lt;a href=&quot;https://gist.github.com/abbood/d66bdf176abdd5a50625c188d876b6e3&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimrc&lt;/a&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;second update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:tags getClient&lt;/code&gt; works!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and i removed this part from my &lt;a href=&quot;https://gist.github.com/abbood/d66bdf176abdd5a50625c188d876b6e3&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimrc&lt;/a&gt; file&#xA;    &quot; The Silver Searcher&#xA;    if executable('ag')&#xA;      &quot; Use ag over grep&#xA;      set grepprg=ag\ --nogroup\ --nocolor\ --ignore\ tags&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &quot; Use ag in CtrlP for listing files. Lightning fast and respects .gitignore&#xA;  let g:ctrlp_user_command = 'ag %s -l --nocolor -g --ignore tags&quot;&quot;'&#xA;&#xA;  &quot; ag is fast enough that CtrlP doesn't need to cache&#xA;  let g:ctrlp_use_caching = 0&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and now when i enter &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt; on top of getClient I get this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OXs6c.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OXs6c.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cuSzj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cuSzj.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;update 3&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;it turns out i was pressing the wrong key.. :( it works fine now!&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="14510" LastEditDate="2017-10-19T11:10:57.913" LastActivityDate="2017-10-19T11:10:57.913" Title="cannot generate ctags for php traits" Tags="|ctags|filetype-php|" AnswerCount="1" CommentCount="2" ClosedDate="2017-10-24T06:26:45.920" ContentLicense="CC BY-SA 3.0" />
  <row Id="13977" PostTypeId="2" ParentId="13968" CreationDate="2017-10-19T09:33:06.443" Score="1" Body="&lt;p&gt;In the interests of completeness, this can also be done with the &lt;a href=&quot;http://vim-taglist.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Taglist plugin&lt;/a&gt;. Most of the advice you will find on the internet recommends the newer Tagbar over Taglist, but reports of the latter's demise seem to have been exaggerated&amp;#8202;&amp;mdash;&amp;#8202;it was updated as recently as 2013&amp;#8202;&amp;mdash;&amp;#8202;and it remains the top-rated and most downloaded plugin on &lt;a href=&quot;https://vim.sourceforge.io/scripts/script_search_results.php?order_by=rating&quot; rel=&quot;nofollow noreferrer&quot;&gt;the official Vim site's script pages&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possible advantage is that Taglist allows the display of tags from multiple files, whereas Tagbar always displays the tags from the current file. I switched to Tagbar several years ago, though, so I'm afraid I can't give a detailed rundown of the differences.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-10-19T09:33:06.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13978" PostTypeId="2" ParentId="13976" CreationDate="2017-10-19T10:18:54.227" Score="1" Body="&lt;p&gt;When you press &lt;kbd&gt;Ctrl-P&lt;/kbd&gt; in normal mode, you are invoking the &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ctrl-P plugin&lt;/a&gt;, and it is displaying a fuzzy finder for files, (with the first entry being the &lt;code&gt;tags&lt;/code&gt; file you've created with ctags).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your cursor is over &lt;code&gt;getClient()&lt;/code&gt;, the keystroke you need to use to jump to its definition is &lt;kbd&gt;Ctrl+]&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this doesn't work, then the first thing to check is whether the &lt;code&gt;getClient&lt;/code&gt; tag actually exists in your tags file. You can do this by opening it in Vim and searching. If the tag doesn't exist, then you'll need to fix the command you are using to invoke ctags.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-10-19T10:18:54.227" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13979" PostTypeId="2" ParentId="13960" CreationDate="2017-10-19T10:51:58.763" Score="5" Body="&lt;h3&gt;Workaround&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Since the problem happens because of relative paths in &lt;code&gt;tags&lt;/code&gt; file, it will go away if there are only absolute paths. &lt;code&gt;ctags&lt;/code&gt; has &lt;code&gt;--tag-relative&lt;/code&gt; option, which:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Indicates that the file paths recorded in the tag file should be relative to the directory containing the tag file, rather than relative to the current directory, &lt;strong&gt;unless the files supplied on the command&#xA;  line are specified with absolute paths&lt;/strong&gt;. This option must appear before the first file name. The default is yes when running in etags mode (see the -e option), no otherwise.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;An easy way of doing it is to run &lt;code&gt;ctags&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctags -R $PWD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Cause of the issue&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;After looking at the source code, I'm pretty sure that this strange behaviour is a bug related to caching of tag search results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I understood Vim uses relative path to &lt;code&gt;tags&lt;/code&gt; in current directory (can be checked via &lt;code&gt;:echo tagfiles()&lt;/code&gt;), but absolute path otherwise. For&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u vimrc main.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;tags&quot;&lt;/code&gt; path is stored in the cache, but it is impossible to compose full path if all you have is &lt;code&gt;&quot;tags&quot;&lt;/code&gt; and &lt;code&gt;&quot;main.c&quot;&lt;/code&gt;. This is why &lt;code&gt;'tagrelative'&lt;/code&gt; doesn't work, input data required for it to work is missing. For&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u vimrc d/a.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim uses full path (not &lt;code&gt;&quot;../tags&quot;&lt;/code&gt;) and everything works as expected.&lt;/p&gt;&#xA;" OwnerUserId="860" LastActivityDate="2017-10-19T10:51:58.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13980" PostTypeId="1" AcceptedAnswerId="13981" CreationDate="2017-10-19T10:57:37.993" Score="1" ViewCount="933" Body="&lt;p&gt;I'm trying to debug my Vimrc config files but I can't find the file where the error is coming from, is there a way to find the file that the line is coming from? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I'm given this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;28_HL:&#xA;line   43:&#xA;E254: Cannot allocate color 0&#xA;E421: Color name or number not recognized: ctermbg= gui=NONE cterm=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't tell me where the file that the error is occuring is, I have tried doing &lt;code&gt;vim -V9myvim.log&lt;/code&gt; and rooting for the error which gives me this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 15: sourcing &quot;/usr/local/share/vim/vim80/syntax/syncolor.vim&quot;&#xA;finished sourcing /usr/local/share/vim/vim80/syntax/syncolor.vim&#xA;continuing in /Users/thermatix/dotfiles/tag-vim/vim/plugged/gruvbox/colors/gruvbox.vim&#xA;Searching for &quot;/usr/local/share/vim/vimfiles/after/syntax/syncolor.vim&quot;&#xA;Searching for &quot;/Users/thermatix/dotfiles/tag-vim/vim/plugged/vim-snipmate/after/syntax/syncolor.vim&quot;&#xA;Searching for &quot;/Users/thermatix/dotfiles/tag-vim/vim/plugged/vim-polyglot/after/syntax/syncolor.vim&quot;&#xA;Searching for &quot;/Users/thermatix/dotfiles/tag-vim/vim/plugged/vim-javascript/after/syntax/syncolor.vim&quot;&#xA;Searching for &quot;/Users/thermatix/dotfiles/tag-vim/vim/plugged/tern_for_vim/after/syntax/syncolor.vim&quot;&#xA;Searching for &quot;/Users/thermatix/dotfiles/tag-vim/vim/plugged/vim-coffee-script/after/syntax/syncolor.vim&quot;&#xA;Searching for &quot;/Users/thermatix/dotfiles/tag-vim/vim/plugged/jedi-vim/after/syntax/syncolor.vim&quot;&#xA;Searching for &quot;/Users/thermatix/dotfiles/tag-vim/vim/plugged/ale/after/syntax/syncolor.vim&quot;&#xA;Searching for &quot;/Users/thermatix/dotfiles/tag-vim/vim/plugged/vim-markdown/after/syntax/syncolor.vim&quot;&#xA;Searching for &quot;/Users/thermatix/.vim/after/syntax/syncolor.vim&quot;&#xA;                                                               Error detected while processing function &amp;lt;SNR&amp;gt;28_HL:&#xA;line   43:&#xA;E254: Cannot allocate color 0&#xA;E421: Color name or number not recognized: ctermbg= gui=NONE cterm=NONE&#xA;finished sourcing /Users/thermatix/dotfiles/tag-vim/vim/plugged/gruvbox/colors/gruvbox.vim&#xA;continuing in /usr/local/share/vim/vim80/syntax/synload.vim&#xA;Executing ColorScheme Auto commands for &quot;gruvbox&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this isn't that helpful because before it was &lt;code&gt;&amp;lt;SNR&amp;gt;32_HL&lt;/code&gt;, then I removed tabular (which was the last loaded plugin before the error) and it change to &lt;code&gt;&amp;lt;SNR&amp;gt;28_HL&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the error in &lt;code&gt;Searching for &quot;/Users/thermatix/.vim/after/syntax/syncolor.vim&quot;&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can't be because there is no after folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried doing &lt;code&gt;grep -r 'ctermbg= gui=NONE cterm=NONE' .vim/&lt;/code&gt; but that found nothing, and grep-ing for the individual attributes found nothing that seem to be related to the error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also tried using &lt;code&gt;vim -D&lt;/code&gt; to try and step through but again, it seems to jump lines till the error happens without actually staging where the error is, so I can't tell where the problem lies, you just get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Entering Debug mode.  Type &quot;cont&quot; to continue.&#xA;/Users/thermatix/.vimrc&#xA;line 1: so ~/.vim/vimrc.vim&#xA;&amp;gt;&#xA;&amp;gt;n&#xA;Error detected while processing function &amp;lt;SNR&amp;gt;28_HL:&#xA;line   43:&#xA;E254: Cannot allocate color 0&#xA;E421: Color name or number not recognized: ctermbg= gui=NONE cterm=NONE&#xA;/Users/thermatix/.vimrc&#xA;line 2: End of sourced file&#xA;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So how do I find where the error is coming from? I mean, telling me the line number is all well and good but it's useless without the file that it's coming from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find the need, my vim config files can be found &lt;a href=&quot;https://github.com/Thermatix/dotfiles/tree/master/tag-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11603" LastEditorUserId="11603" LastEditDate="2017-10-19T11:11:09.770" LastActivityDate="2017-10-19T15:17:59.937" Title="Find file for given line number when given an error" Tags="|vimrc|error|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13981" PostTypeId="2" ParentId="13980" CreationDate="2017-10-19T11:06:18.477" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is the error in Searching for&#xA;  &quot;/Users/thermatix/.vim/after/syntax/syncolor.vim&quot;?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Can't be because there is no after folder.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Actually the problem may be that some plugin expects the folder to exist.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I also tried doing grep -r 'ctermbg= gui=NONE cterm=NONE' .vimrc/ but&#xA;  that found nothing, and grep-ing for the individual attributes found&#xA;  nothing that seem to be related to the error.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You should try grep in &lt;code&gt;~/.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, you should follow the procedure in &lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;&quot;How do I debug my vimrc file?&quot;&lt;/a&gt; (or the procedure at &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq%2d2%2e5&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim faq-2.5&lt;/a&gt;). It will allow you to find which line on your &lt;code&gt;_vimrc&lt;/code&gt; or plugin triggers the problem.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So there's no way to get vim to spit out a file alongside the line&#xA;  number?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not aware of any Vim option that would include the file name; by default it includes only the function name, which in this case is &lt;code&gt;&amp;lt;SNR&amp;gt;28_HL&lt;/code&gt;. Note the &lt;code&gt;&amp;lt;SNR&amp;gt;28_&lt;/code&gt; means it is a script-local function (see &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3cSNR%3e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help &amp;lt;SNR&amp;gt;&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, I usually find quite easy and straightforward to follow the procedures in the link above. If you still prefer to avoid it, you should try to improve your use of the debugger:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I've also tried using vim -D to try and step through but again, it&#xA;  seems to jump lines till the error happens without actually staging&#xA;  where the error is, so I can't tell where the problem lies, you just&#xA;  get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Entering Debug mode.  Type &quot;cont&quot; to continue.&#xA;/Users/thermatix/.vimrc&#xA;line 1: so ~/.vim/vimrc.vim&#xA;&amp;gt;&#xA;&amp;gt;n&#xA;Error detected while processing function &amp;lt;SNR&amp;gt;28_HL:&#xA;line   43:&#xA;E254: Cannot allocate color 0&#xA;E421: Color name or number not recognized: ctermbg= gui=NONE cterm=NONE&#xA;/Users/thermatix/.vimrc&#xA;line 2: End of sourced file&#xA;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Instead of using &lt;code&gt;next&lt;/code&gt; in the line sourcing the &lt;code&gt;vimrc.vim&lt;/code&gt;, you should try to &lt;code&gt;step&lt;/code&gt; -- details can be found at &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%3estep&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help &amp;gt;step&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2017-10-19T15:17:59.937" LastActivityDate="2017-10-19T15:17:59.937" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13982" PostTypeId="2" ParentId="13843" CreationDate="2017-10-19T11:19:52.177" Score="0" Body="&lt;p&gt;Thanks @mMontu, I found a solution in an issue tracker, the answer isn't to get ycm to compile with the current ruby but rather to ensure the correct version that YCM is compiled with is set before opening Vim, you can do that by following the steps found &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/issues/151#issuecomment-74452227&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The specific steps are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If you use Homebrew to install vim, you should update Homebrew: &lt;code&gt;brew update&lt;/code&gt; or update with your package manager specific upgrade update command.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you already installed vim use Homebrew, remove it: &lt;code&gt;brew remove vim&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the system Ruby to compile and install vim: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;for rvm do &lt;code&gt;rvm &amp;lt;system|ruby version&amp;gt; do brew install vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;for rbenv install the &lt;a href=&quot;https://github.com/Rodreegez/rbenv-only&quot; rel=&quot;nofollow noreferrer&quot;&gt;only&lt;/a&gt; plugin and then do &lt;code&gt;rbenv only -r &amp;lt;ruby version&amp;gt; -c &quot;&quot;brew install vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Make a function to acces vim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;for rvm do:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;function vim()&#xA;{&#xA;  cmd=&quot;exec /usr/local/bin/vim $@&quot;&#xA;  rvm $GLOBAL_RUB_VERSION do &quot;$cmd&quot;;&#xA;}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;for rbenv do:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;function vim()&#xA;{&#xA;  cmd=&quot;exec /usr/local/bin/vim $@&quot;&#xA;  rbenv only -r $GLOBAL_RUB_VERSION -c &quot;$cmd&quot;;&#xA;}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11603" LastEditorUserId="11603" LastEditDate="2017-10-23T12:27:17.090" LastActivityDate="2017-10-23T12:27:17.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13983" PostTypeId="1" CreationDate="2017-10-19T12:51:34.507" Score="1" ViewCount="76" Body="&lt;p&gt;I have &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set linespace 20&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in my .vimrc and I quite like the clarity it provides. The only issue I see right now is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lh0Iy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lh0Iy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice how the spacing at the top end of the line is more than the bottom end of the line? How do I make it so that the text in the line is vertically center aligned?&lt;/p&gt;&#xA;" OwnerUserId="14745" LastEditorUserId="14745" LastEditDate="2017-10-19T12:57:05.750" LastActivityDate="2017-10-19T12:57:05.750" Title="Display issue: Vertically center in line when using linespace 20" Tags="|vimrc|macvim|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13984" PostTypeId="1" AcceptedAnswerId="13986" CreationDate="2017-10-19T19:23:08.637" Score="4" ViewCount="7627" Body="&lt;p&gt;Lets say I jump to mark with &lt;code&gt;]'&lt;/code&gt; and I want to remove it, how can I do it without typing &lt;code&gt;:delmarks a&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="14800" LastActivityDate="2017-10-20T15:43:38.827" Title="How do I delete a mark in current line?" Tags="|mark|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13985" PostTypeId="2" ParentId="13984" CreationDate="2017-10-19T20:47:09.710" Score="3" Body="&lt;p&gt;To delete a mark you can use &lt;code&gt;:delmark&lt;/code&gt; it can be shortened to &lt;code&gt;:delm&lt;/code&gt;. &#xA;If you really want something shorter you can map a function which asks for an input but it's not really a common practice to have a map which takes a parameter or ask for an input.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MarkDelete()&#xA;    call inputsave()&#xA;    let l:mark = input(&quot;Mark to del: &quot;)&#xA;    call inputrestore()&#xA;    execute 'delmark '.l:mark&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now just map it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; call MarkDelete()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13084" LastEditorUserId="1841" LastEditDate="2017-10-20T06:53:57.790" LastActivityDate="2017-10-20T06:53:57.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13986" PostTypeId="2" ParentId="13984" CreationDate="2017-10-19T23:06:41.657" Score="1" Body="&lt;p&gt;You can delete all &lt;code&gt;a-z&lt;/code&gt; marks on the current line using this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Delmarks()&#xA;    let l:m = join(filter(&#xA;       \ map(range(char2nr('a'), char2nr('z')), 'nr2char(v:val)'),&#xA;       \ 'line(&quot;''&quot;.v:val) == line(&quot;.&quot;)'))&#xA;    if !empty(l:m)&#xA;        exe 'delmarks' l:m&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and with a map&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; dm :&amp;lt;c-u&amp;gt;call Delmarks()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-10-19T23:06:41.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13987" PostTypeId="1" AcceptedAnswerId="13988" CreationDate="2017-10-20T02:01:08.887" Score="1" ViewCount="623" Body="&lt;p&gt;Due to my terminal emulator, I trying to &lt;a href=&quot;https://stackoverflow.com/a/10216459/5353461&quot;&gt;remap &lt;code&gt;^[(key)&lt;/code&gt; to &lt;code&gt;&amp;lt;A-(key)&amp;gt;&lt;/code&gt;&lt;/a&gt; with the &lt;kbd&gt;&gt;&lt;/kbd&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do a &lt;code&gt;set&lt;/code&gt; for &lt;kbd&gt;Alt&lt;/kbd&gt; + &lt;kbd&gt;&gt;&lt;/kbd&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;A-&amp;gt;&amp;gt;=foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;E846: Key code not set: &amp;lt;A-&amp;gt;&amp;gt;=foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I try to escape the &lt;code&gt;&amp;gt;&lt;/code&gt; I still get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;E846: Key code not set: &amp;lt;A-\&amp;gt;&amp;gt;=foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5324" LastActivityDate="2017-10-20T02:56:46.293" Title="How do I `set &lt;A-&gt;&gt;=foo`?" Tags="|key-bindings|set|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13988" PostTypeId="2" ParentId="13987" CreationDate="2017-10-20T02:51:03.933" Score="2" Body="&lt;p&gt;You can use the following syntax to map the &quot;alt + greater than&quot; key combination&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;a-char-62&amp;gt;=...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;62 being the ASCII code for &lt;code&gt;&amp;gt;&lt;/code&gt;.  This syntax also works for maps&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;a-char-62&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-10-20T02:56:46.293" LastActivityDate="2017-10-20T02:56:46.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13989" PostTypeId="2" ParentId="13971" CreationDate="2017-10-20T09:07:53.350" Score="3" Body="&lt;p&gt;Thanks to this &lt;a href=&quot;https://www.reddit.com/r/vim/comments/74eapd/random_characters_on_startup_with_set/&quot; rel=&quot;nofollow noreferrer&quot;&gt;reddit thread&lt;/a&gt; i was able to fix it by adding&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; set t_RS=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The root cause of the problem have not been determined, but it has something to do with vim misinterpreting a terminal answer to one of its request, since the default value :&#xA;&lt;code&gt;t_RS=^[P1$r2 q^[\&lt;/code&gt; was the command doing the yanking.&lt;/p&gt;&#xA;" OwnerUserId="2056" LastActivityDate="2017-10-20T09:07:53.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13990" PostTypeId="2" ParentId="126" CreationDate="2017-10-20T13:57:53.160" Score="1" Body="&lt;p&gt;The following doc matchit, the the additions below in  ~/.vimrc worked for me&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:runtime macros/matchit.vim&#xA;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14806" LastActivityDate="2017-10-20T13:57:53.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13991" PostTypeId="2" ParentId="13603" CreationDate="2017-10-20T14:52:53.410" Score="26" Body="&lt;p&gt;You should use &lt;code&gt;\_.\{-}&lt;/code&gt; instead of &lt;code&gt;.*&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\_.&lt;/code&gt; matches any character including end-of-line. However, as &lt;code&gt;:h \_.&lt;/code&gt; warns, using it with &lt;code&gt;*&lt;/code&gt; will match all text to the end of the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\{-}&lt;/code&gt; is similar to &lt;code&gt;*&lt;/code&gt;, matching 0 or more instances of the proceeding atom. But it matches &lt;strong&gt;as few as possible&lt;/strong&gt; instead of as many as possible. This makes &lt;code&gt;\{-}&lt;/code&gt; safe if your example pattern appears more than once. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;author = {{foo&#xA;           bar}},&#xA;&#xA;editor = {{buz&#xA;           baz}},&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;%s/{{\(\_.*\)}}/{\1}/g&lt;/code&gt; changes the starting double brace for author, but the closing double brace for editor. Since &lt;code&gt;*&lt;/code&gt; matches as many atoms as possible, the pattern matches until the last double brace it finds. This results in the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;author = {foo&#xA;           bar}},&#xA;&#xA;editor = {{buz&#xA;           baz},&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, using &lt;code&gt;%s/{{\(\_.\{-}\)}}/{\1}/g&lt;/code&gt; gives the desired result for both author and editor as it stops searching at the first double brace it finds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;author = {foo&#xA;           bar},&#xA;&#xA;editor = {buz&#xA;           baz},&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7222" LastActivityDate="2017-10-20T14:52:53.410" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13992" PostTypeId="2" ParentId="13984" CreationDate="2017-10-20T15:27:05.610" Score="7" Body="&lt;p&gt;I'm going to swim against the stream on this one.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Just don't worry about it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Marks are pretty ephemeral and there are bunch of marks Vim automatically maintains like &lt;code&gt;'[&lt;/code&gt;, &lt;code&gt;''&lt;/code&gt;, and &lt;code&gt;'.&lt;/code&gt; Humans are typically very bad at bookkeeping so we typically use only a few registers and a few marks. I personally only use a few &lt;code&gt;a-z&lt;/code&gt; marks (typically &lt;code&gt;'m&lt;/code&gt;) and often only in few immediate contexts e.g. macros or jumping between a few spots. Your workflow maybe different, but I see no reason to &quot;clean up&quot; the marks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to answer your question:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap dm :execute 'delmarks '.nr2char(getchar())&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can do &lt;code&gt;dma&lt;/code&gt; to delete mark &lt;code&gt;'a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or to delete all marks on the current line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Delmarks silent execute 'delmarks '.join(map(filter(filter(map(split(execute('marks'),&quot;\n&quot;),'split(v:val)'), 'v:val[1]==line(&quot;.&quot;)&amp;amp;&amp;amp;v:val[0]!~#&quot;[A-Z]&quot;'), 'v:val[1]==line(&quot;.&quot;)&amp;amp;&amp;amp;v:val[0]!~#&quot;[A-Z]&quot;'), 'v:val[0]'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just map this to a key to so you don't have to type out &lt;code&gt;:Delmarks&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-10-20T15:43:38.827" LastActivityDate="2017-10-20T15:43:38.827" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13993" PostTypeId="1" AcceptedAnswerId="14006" CreationDate="2017-10-20T17:44:44.770" Score="3" ViewCount="538" Body="&lt;p&gt;I love &lt;a href=&quot;https://github.com/mbbill/undotree&quot; rel=&quot;nofollow noreferrer&quot;&gt;UndoTree&lt;/a&gt;, saving me many times when I deleted/rewritten entire paragraphs but days later I realized that I needed to extract a phrase/sentence from them, without completely messing up my current version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/junegunn/goyo.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Goyo&lt;/a&gt; promotes distraction-free writing but I couldn't figure out how to use them together (without going too deep). I can start UndoTree manually or through the callbacks below but I can't switch to the the UndoTree window. This doesn't seem to be the issue with &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fugitive&lt;/a&gt;'s windows but those are not so closely coupled as the ones opened by UndoTree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given enough time I could get into Vim scripting and figure it out but I don't want to (and have the time right now) to reinvent the wheel and it never hurts to ask.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt;: As a workaround, I have my usual setup with UndoTree panes on the left with the main text in a window next to it, then I fire up Goyo and I can leave it by simply hitting &lt;code&gt;gt&lt;/code&gt; to make any complicated undo manipulation but this is not ideal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit2&lt;/strong&gt;: Fugitive uses &lt;code&gt;preview-windows&lt;/code&gt; whereas UndoTree uses &lt;code&gt;:new&lt;/code&gt; with absolute locations (the default is &lt;code&gt;:topleft vertical&lt;/code&gt;). This absolute positioning causes the issue because opening split windows with any of the commands or with Fzf works just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;dirty solution&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/mbbill/undotree/blob/master/autoload/undotree.vim#L479&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/mbbill/undotree/blob/master/autoload/undotree.vim#L479&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;   1 +--473 lines: =================================================&#xA; 478 &#xA; 479     &amp;quot; Create undotree window.&#xA; 480     if g:undotree_WindowLayout == 1 || g:undotree_WindowLayout == 2                                                                                                                                                                                                   &#xA; 481         let cmd = &amp;quot;topleft vertical&amp;quot; .                                                                                                                                                                                                                                &#xA; 482                     \self.width . ' new ' . self.bufname                                                                                                                                                                                                              &#xA; 483     else                                                                                                                                                                                                                                                              &#xA; 484         let cmd = &amp;quot;botright vertical&amp;quot; .                                                                                                                                                                                                                               &#xA; 485                     \self.width . ' new ' . self.bufname                                                                                                                                                                                                              &#xA; 486     endif                                                                                                                                                                                                                                                             &#xA;     --------------------------------------------------------------------&#xA; 487     call s:exec(&amp;quot;silent keepalt &amp;quot;.cmd)&#xA; 493 +----------------------------------------------------------&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Add line &lt;code&gt;let cmd = 'vertical' . self.width . ' new ' . self.bufname&lt;/code&gt; before &lt;code&gt;if&lt;/code&gt; block&lt;/li&gt;&#xA;&lt;li&gt;Comment out &lt;code&gt;if&lt;/code&gt; block&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;   1 &amp;quot;=================================================&#xA; 479     &amp;quot; Create undotree window.&#xA; 480     let cmd = 'vertical' . self.width . ' new ' . self.bufname                                                                                                                                                                                                        &#xA; 481     &amp;quot; if g:undotree_WindowLayout == 1 || g:undotree_WindowLayout == 2                                                                                                                                                                                                 &#xA; 482     &amp;quot;     let cmd = &amp;quot;topleft vertical&amp;quot; .                                                                                                                                                                                                                              &#xA; 483     &amp;quot;                 \self.width . ' new ' . self.bufname                                                                                                                                                                                                            &#xA; 484     &amp;quot; else                                                                                                                                                                                                                                                            &#xA; 485     &amp;quot;     let cmd = &amp;quot;botright vertical&amp;quot; .                                                                                                                                                                                                                             &#xA; 486     &amp;quot;                 \self.width . ' new ' . self.bufname                                                                                                                                                                                                            &#xA; 487     &amp;quot; endif                                                                                                                                                                                                                                                           &#xA; 494     -----------------------------------------------------&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Call &lt;code&gt;:Goyo 110&lt;/code&gt; in Vim&lt;/li&gt;&#xA;&lt;li&gt;Call &lt;code&gt;:UndotreeToggle&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Turns out I did have the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TODO: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Clean up and pull request to UndoTree&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Open issue to Goyo (&lt;code&gt;CTRL-W_CTRL-W&lt;/code&gt; does not work properly with multiple windows)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7706" LastEditorUserId="343" LastEditDate="2017-10-26T08:43:00.997" LastActivityDate="2017-10-26T08:43:00.997" Title="What is a working setup to use Vim plugins UndoTree and Goyo together?" Tags="|vimscript|vim-windows|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13994" PostTypeId="1" AcceptedAnswerId="13998" CreationDate="2017-10-21T09:50:41.943" Score="1" ViewCount="698" Body="&lt;p&gt;In &lt;code&gt;:imap&lt;/code&gt;, I see mappings like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i  ©           *@&amp;lt;C-R&amp;gt;=AutoPairsMoveCharacter(')')&amp;lt;CR&amp;gt;&#xA;i  ¨           *@&amp;lt;C-R&amp;gt;=AutoPairsMoveCharacter('(')&amp;lt;CR&amp;gt;&#xA;i  î           *@&amp;lt;Esc&amp;gt;:call AutoPairsJump()&amp;lt;CR&amp;gt;&#xA;i  ð           *@AutoPairsToggle()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know from the &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;Auto Pairs&lt;/a&gt; page that &lt;code&gt;&amp;lt;M-p&amp;gt;&lt;/code&gt; toggles Auto Pairs, so I can only guess that &lt;code&gt;ð&lt;/code&gt; maps to &lt;code&gt;&amp;lt;M-p&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get vim to display the Meta- mappings in a human readable way?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastActivityDate="2017-10-22T12:13:30.207" Title="Display human readable meta/alt-(key) mappings" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13996" PostTypeId="1" CreationDate="2017-10-21T10:24:00.383" Score="1" ViewCount="171" Body="&lt;p&gt;How do I make &lt;code&gt;equalprg&lt;/code&gt; match my custom indent settings? They are like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:did_indent = 1&#xA;set expandtab       &#xA;set shiftwidth=2&#xA;set softtabstop=2&#xA;&#xA;set autoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And they format the code to this (actually I have to add the 2 extra spaces myself):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(. fs (writeFile &quot;test.txt&quot; &quot;some text&quot; (fn [err]&#xA;  (. res(send (if err &quot;error&quot; &quot;done&quot;)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I use &lt;code&gt;=&lt;/code&gt;, this is what I got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(. fs (writeFile &quot;test.txt&quot; &quot;some text&quot; (fn [err]&#xA;                                         (. res(send (if err &quot;error&quot; &quot;done&quot;)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I keep the first form?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, would it be possible to add the leading spaces automatically then, because I suppose they would be scrapped?&lt;/p&gt;&#xA;" OwnerUserId="2562" LastEditorUserId="51" LastEditDate="2018-08-22T16:58:00.237" LastActivityDate="2021-12-05T19:04:35.427" Title="equalprg with lisp (clojure) and custom indent settings" Tags="|indentation|filetype-clojure|filetype-lisp|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13997" PostTypeId="1" CreationDate="2017-10-21T12:16:00.517" Score="5" ViewCount="4592" Body="&lt;p&gt;I'm using vim for python scripting and currently approaching &lt;code&gt;jedi-vim&lt;/code&gt; for autocomplete, navigation and refactoring. But it would be nice to have some ide-like debugging facilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some plugin available?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2021-02-15T18:20:32.810" Title="Vim python debugger" Tags="|vimrc|filetype-python|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13998" PostTypeId="2" ParentId="13994" CreationDate="2017-10-21T12:45:53.930" Score="1" Body="&lt;p&gt;I don't know if these mappings are readily available anywhere but if not then you could generate them yourself. (That might be necessary anyways if the values are system dependent.) Rather than manually inserting &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;A&lt;/kbd&gt;, &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;B&lt;/kbd&gt;, &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt;, ... into Vim you could use a macro to generate the values. With the macro below you put put the cursor on a character and run the macro and it will print the meta version next to the character. So &lt;code&gt;p&lt;/code&gt; becomes &lt;code&gt;p=ð&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The macro is &lt;code&gt;&quot;=&quot;=\&amp;lt;M-^R^W&amp;gt;&quot;^Mpw&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;^R&lt;/code&gt; and &lt;code&gt;^W&lt;/code&gt; are the actual control characters &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;R&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt;. &lt;code&gt;^M&lt;/code&gt; is inserted by hitting &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So start recording with &lt;code&gt;qq&lt;/code&gt;, enter the macro as described, press &lt;code&gt;q&lt;/code&gt; again and it's ready. Now you can type in, say, the entire lower-case alphabet on a line (characters separated by spaces), put the cursor on &lt;code&gt;a&lt;/code&gt;, enter &lt;code&gt;26@q&lt;/code&gt; and you'll get the complete mapping for those characters. Here's what I get on one system from &lt;code&gt;a b c d e f g h i j k l m n o p q r s t u v w x y z&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a=á b=â c=ã d=ä e=å f=æ g=ç h=è i=é j=ê k=ë l=ì m=í n=î o=ï p=ð q=ñ r=ò s=ó t=ô u=õ v=ö w=÷ x=ø y=ù z=ú&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We use the expression register &lt;code&gt;=&lt;/code&gt; to evaluate a string like &lt;code&gt;&quot;\&amp;lt;M-p&amp;gt;&quot;&lt;/code&gt; which Vim renders as if the equivalent keys were actually pressed.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;=&lt;/code&gt; : Begin entering an expression into the expression register.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;=\&amp;lt;M-&lt;/code&gt; : The beginning of a string like the one described above. (The separator &lt;code&gt;=&lt;/code&gt; can be changed to any character(s) you like.)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^R^W&lt;/code&gt; : &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;R&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; copies the word under the cursor to the command line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;gt;&quot;^M&lt;/code&gt; : Complete the meta-key expression and submit it to the register.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; : &quot;Put&quot; the contents of the expression register which causes the expression to be evaluated and results in the &quot;rendered&quot; character we're looking for.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt; : Go to the next word (character).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-10-22T12:13:30.207" LastActivityDate="2017-10-22T12:13:30.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13999" PostTypeId="2" ParentId="7243" CreationDate="2017-10-21T13:12:05.777" Score="1" Body="&lt;p&gt;I have this plugin just released for interfacing vim and interpreters like R or python:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/iago-lito/intim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/iago-lito/intim/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It provides a few more features than you'd actually expect, but you sure can send one-liners with the only mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;space&amp;gt; &amp;lt;Plug&amp;gt;IntimSendLine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try it out, and don't hesitate to file your first bug reports / feature requests on the repo :)&lt;/p&gt;&#xA;" OwnerUserId="2978" LastActivityDate="2017-10-21T13:12:05.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14000" PostTypeId="2" ParentId="13997" CreationDate="2017-10-21T15:39:56.030" Score="2" Body="&lt;p&gt;Try the python-mode plugin. Its the closest thing to a python ide coupled to VIM. However, as far as I know python-mode and jedi-vim are not compatible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to add more power on top, like youcompleteme or syntastic, you have to build the collection yourself. I just combined a number of plugins: python-mode, syntastic, awesome-vim, youcompleteme. There's a lot of conflicts, and some of them dont work well with each other.&lt;/p&gt;&#xA;" OwnerUserId="13848" LastEditorUserId="13848" LastEditDate="2017-10-26T22:49:10.407" LastActivityDate="2017-10-26T22:49:10.407" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14001" PostTypeId="1" AcceptedAnswerId="14002" CreationDate="2017-10-21T15:57:05.007" Score="1" ViewCount="63" Body="&lt;p&gt;I've posted a number of times to try and get closer to what I'm trying to do. My problem is I have got the commands I need to make the conversion happen, however I cannot successfully map it to a key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the type of sequences I have to convert (123456789 representing any number combination):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0010|C|||N12345678|W1234567891234&#xA;0010|H|S12345678|E123456789||&#xA;0020|L|N12345678|W123456789|N12345678|W12345678912341234&#xA;0030|G|N12345678|W123456789||&#xA;0020|R|N12345678|W123456789|N12345678|W12345678912341234&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my desired outcome:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0010|C|||N12345678|W123456789|123.4&#xA;0010|H|S12345678|E123456789||&#xA;0020|L|N12345678|W123456789|N12345678|W123456789|123.4|123.4&#xA;0030|G|N12345678|W123456789||&#xA;0020|R|N12345678|W123456789|N12345678|W123456789|123.4|123.4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A member on reddit came up with two global commands which does exactly what I need it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/|C|/execute &quot;normal $3hi|\&amp;lt;Esc&amp;gt;$i.&quot;&#xA;&#xA;:g/|L|\||R|/execute &quot;normal $7hi|\&amp;lt;Esc&amp;gt;4li.\&amp;lt;Esc&amp;gt;2li|\&amp;lt;Esc&amp;gt;$i.&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;anyone able to map it to a single key?&lt;/p&gt;&#xA;" OwnerUserId="14346" LastActivityDate="2017-10-21T16:21:53.307" Title="Converting from A to B using mapped key" Tags="|vimrc|vimscript|key-bindings|global-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14002" PostTypeId="2" ParentId="14001" CreationDate="2017-10-21T16:21:53.307" Score="2" Body="&lt;p&gt;Trying to cram that in a single line could get a bit ugly without any particular advantage. Simplest approach is going to be to put the commands in a function in your vimrc like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ConvertNumCols()&#xA;  global/|C|/execute &quot;normal $3hi|\&amp;lt;Esc&amp;gt;$i.&quot;&#xA;  g/|L|\||R|/execute &quot;normal $7hi|\&amp;lt;Esc&amp;gt;4li.\&amp;lt;Esc&amp;gt;2li|\&amp;lt;Esc&amp;gt;$i.&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Along with a mapping that calls it&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap X :call ConvertNumCols()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace &lt;code&gt;X&lt;/code&gt; with whatever key or keys that you want.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2017-10-21T16:21:53.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14003" PostTypeId="1" CreationDate="2017-10-21T19:52:09.143" Score="1" ViewCount="1513" Body="&lt;p&gt;Vim 8 user here. I also use auto pairs and one of the features, called fast wrap or something like that makes use of the &lt;kbd&gt;meta&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt; shortcut. However, if I type &lt;kbd&gt;alt&lt;/kbd&gt;e inside vim nothing happens except that if I press it three times a Swedish a appears on the screen. Any ideas?&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="14817" LastEditorUserId="1841" LastEditDate="2017-10-23T07:55:22.817" LastActivityDate="2018-12-18T04:41:22.163" Title="Autopairs shortcut not working" Tags="|key-bindings|plugin-auto-pairs|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14004" PostTypeId="1" AcceptedAnswerId="14005" CreationDate="2017-10-22T02:43:40.100" Score="1" ViewCount="474" Body="&lt;p&gt;I am using Vim 8. Since I installed vim-polyglot to handle syntax highlighting and indentation of different languages without going crazy, whatever file I open has a tab size of 8 automatically. I know that I could change the tab size manually for every filetype but I thought the purpose of polyglot was not to have to do that. Any help or alternative? &lt;/p&gt;&#xA;" OwnerUserId="14817" LastActivityDate="2017-10-22T09:17:58.163" Title="Tab size fixed to 8 in spite of polyglot." Tags="|tab-characters|plugin-vim-polyglot|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14005" PostTypeId="2" ParentId="14004" CreationDate="2017-10-22T09:17:58.163" Score="2" Body="&lt;p&gt;vim-polyglot is mainly a collection of different filetype and syntax specific plugins. However, setting the tab size is usually a user setting, that should not be set by any filetype plugin. So if you want a different tab size, I suggest to set it in your .vimrc or inside you own filetype plugins (alternatively use FileType autocommands). See also the &lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-26.1&quot; rel=&quot;nofollow noreferrer&quot;&gt;faq question 26.1&lt;/a&gt; and following questions.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2017-10-22T09:17:58.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14006" PostTypeId="2" ParentId="13993" CreationDate="2017-10-22T10:03:10.973" Score="3" Body="&lt;p&gt;UndoTree layouts use absolute positioning commands by default (&lt;code&gt;topleft&lt;/code&gt;,&lt;code&gt;botright&lt;/code&gt;) but it can be configured to accept custom ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; === UndoTree&#xA;&quot; using relative positioning instead&#xA;let g:undotree_CustomUndotreeCmd = 'vertical 32 new'&#xA;let g:undotree_CustomDiffpanelCmd= 'belowright 12 new'&#xA;&#xA;&quot; === Goyo&#xA;&quot; changing from the default 80 to accomodate for UndoTree panel&#xA;let g:goyo_width = 104&#xA;&#xA;&quot; to automatically start UndoTree and Limelight when firing up Goyo&#xA;&quot; (see more in Goyo project repo)&#xA;function! s:goyo_enter()&#xA;  Limelight0.7&#xA;  UndotreeToggle&#xA;  &quot; ...&#xA;endfunction&#xA;&#xA;function! s:goyo_leave()&#xA;  Limelight!&#xA;  UndotreeToggle&#xA;  &quot; ...&#xA;endfunction&#xA;&#xA;autocmd! User GoyoEnter nested call &amp;lt;SID&amp;gt;goyo_enter()&#xA;autocmd! User GoyoLeave nested call &amp;lt;SID&amp;gt;goyo_leave()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/08J8Y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/08J8Y.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7706" LastActivityDate="2017-10-22T10:03:10.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14007" PostTypeId="1" CreationDate="2017-10-22T11:00:40.637" Score="2" ViewCount="118" Body="&lt;p&gt;Suppose in a latex file, I have a line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$X_{i_{j}}$ and $Y^{i_{k}}$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My goal is to define a text object in VIM for the subscript, i.e. &lt;code&gt;_{i_{j}}&lt;/code&gt;, and superscript, i.e. &lt;code&gt;^{i_{k}}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was reading this &lt;a href=&quot;http://vim.wikia.com/wiki/Creating_new_text_objects&quot; rel=&quot;nofollow noreferrer&quot;&gt;wiki page&lt;/a&gt;. It requires more knowledge about command-line mode than I currently have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For subscript, I was thinking the ex command should start by finding &lt;code&gt;_&lt;/code&gt;, then move the cursor to its immediately right, and finally find the paired brace using &lt;code&gt;%&lt;/code&gt; in normal model. I do not know how to write this up in ex command.&lt;/p&gt;&#xA;" OwnerUserId="14826" LastEditorUserId="1292" LastEditDate="2019-01-24T12:47:09.753" LastActivityDate="2019-01-24T12:47:09.753" Title="New text object for LaTeX subscript or superscript" Tags="|filetype-tex|custom-text-object|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14008" PostTypeId="1" CreationDate="2017-10-22T13:14:10.207" Score="5" ViewCount="9247" Body="&lt;p&gt;I am on WSL trying to understand why my &lt;code&gt;fakeclip.vim&lt;/code&gt; doesn't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've added &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:fakeclip_platform = s:PLATFORM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into &lt;code&gt;~/.vim/bundle/vim-fakeclip/autoload/fakeclip.vim&lt;/code&gt;, but I can't access the variable I have created. However I can access &lt;code&gt;g:fakeclip_terminal_multiplexer_type&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I was suspecting vim to not load/use this file. Fakeclip is organized as follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.vim/bundle/vim-fakeclip/&#xA;├── autoload&#xA;│   └── fakeclip.vim&#xA;├── doc&#xA;│   ├── fakeclip.txt&#xA;│   └── tags&#xA;├── Gemfile&#xA;├── plugin&#xA;│   └── fakeclip.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I executed this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo &quot;let g:foo=42&quot; &amp;gt;&amp;gt; .vim/bundle/vim-fakeclip/plugin/fakeclip.vim&#xA;$ echo &quot;let g:bar=42&quot; &amp;gt;&amp;gt; .vim/bundle/vim-fakeclip/autoload/fakeclip.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But once again, &lt;code&gt;g:bar&lt;/code&gt; doesn't exist. So I removed the autoload file: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ rm .vim/bundle/vim-fakeclip/autoload/fakeclip.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;g:fakeclip_terminal_multiplexer_type&lt;/code&gt; which is only defined in this file is still available. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course between each attempt I quit and restarted vim. I also removed &lt;code&gt;.viminfo&lt;/code&gt; just in case. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could some explain what's happening here?&lt;/p&gt;&#xA;" OwnerUserId="2548" LastActivityDate="2017-10-22T17:34:21.563" Title="How an autoload/file.vim is loaded?" Tags="|plugin-system|autoload|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14009" PostTypeId="2" ParentId="14003" CreationDate="2017-10-22T13:23:47.233" Score="1" Body="&lt;p&gt;I just answered yesterday a question from an AutoPair user about &lt;a href=&quot;https://vi.stackexchange.com/questions/13994/display-human-readable-meta-alt-key-mappings&quot;&gt;displaying all meta-key equivalents for regular characters&lt;/a&gt;. That user was fortunate enough to be on a system where &lt;kbd&gt;Alt&lt;/kbd&gt; + &lt;em&gt;key&lt;/em&gt; consistently emits actual characters. In the course of answering I found that I could also use meta-keys in gVim on Windows but get strange results otherwise from Cygwin terminal Vim and when I use Vim after I SSH into Centos or Ubuntu machines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to reiterate what &lt;a href=&quot;https://vi.stackexchange.com/questions/14003/autopairs-shortcut-not-working#comment24025_14003&quot;&gt;Christian said in his comment&lt;/a&gt; your best bet if you don't fall into the lucky group is to change the mappings to use key combinations that actually work for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; A &lt;em&gt;portable&lt;/em&gt; solution would require using something other than &quot;Alt&quot; mappings.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-12-18T04:41:22.163" LastActivityDate="2018-12-18T04:41:22.163" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="14010" PostTypeId="2" ParentId="14008" CreationDate="2017-10-22T17:34:21.563" Score="6" Body="&lt;p&gt;autoload plugins are sourced:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;either when we source them explicitly (like in &lt;code&gt;:runtime autoload/fakeclip.vim&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;or when we call a function that starts in &lt;code&gt;foo#bar#whatever()&lt;/code&gt;, it'll source &lt;code&gt;autoload/foo/bar.vim&lt;/code&gt;, even if the function doesn't exist.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, if you want to define a variable in an autoload plugin, &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;either use a dedicated interface: &lt;code&gt;:call fakeclip#_init()&lt;/code&gt; which is quite cumbersome and defeats the purpose of using autoload plugins;&lt;/li&gt;&#xA;&lt;li&gt;or set the variable in a plain &lt;code&gt;plugin/&lt;/code&gt; instead;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;or don't even try to set it if you're just trying to access an option, you could instead provide an internal accessor for your option, and use this accessor instead of &lt;code&gt;g:fakeclip_platform&lt;/code&gt; from your code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! fakeclip#_platform()&#xA;    return get(g:, 'fakeclip_platform', somedefaultvalue)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-10-22T17:34:21.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14011" PostTypeId="2" ParentId="3514" CreationDate="2017-10-22T20:22:29.330" Score="13" Body="&lt;p&gt;As of version &lt;a href=&quot;https://github.com/vim/vim/commit/fafcf0dd59fd9c4ef743bb333ae40d1d322b6079&quot; rel=&quot;noreferrer&quot;&gt;8.0.1206&lt;/a&gt;, Vim supports this with CmdlineEnter and CmdlineLeave.&lt;/p&gt;&#xA;" OwnerUserId="2537" LastActivityDate="2017-10-22T20:22:29.330" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14012" PostTypeId="1" AcceptedAnswerId="14043" CreationDate="2017-10-23T03:34:11.250" Score="3" ViewCount="10404" Body="&lt;p&gt;I am using macvim Version 8.0.1098 (137) MacOS Sierra 10.12.6. I downloaded NerdTree tabs from &lt;a href=&quot;https://github.com/jistr/vim-nerdtree-tabs&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. I am using pathogen to manage my plugins. All the plugins work except this one. This is the error message I get when I type the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:NERDTreeTabsToggle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;27_NERDTreeToggleAllTabs[7]..&amp;lt;SNR&amp;gt;27_NERDTreeOpenAllTabs[5]..&amp;lt;SNR&amp;gt;27_NERDTreeMirrorOrCreate:&#xA;line    7:&#xA;E464: Ambiguous use of user-defined command:     silent NERDTreeMirror&#xA;line   12:&#xA;E492: Not an editor command:       silent NERDTreeToggle &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I install the simple NerdTree it seems to work totally fine. Any suggestions on how I can figure out what I might be doing wrong here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also when I open macvim now I get the error at the bottom which is&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pdVAq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pdVAq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7053" LastEditorUserId="1841" LastEditDate="2017-10-27T06:46:18.253" LastActivityDate="2022-05-14T19:32:54.510" Title="NERDTreeTabs error message: E492: Not an editor command" Tags="|macvim|plugin-nerdtree|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="14014" PostTypeId="1" AcceptedAnswerId="14030" CreationDate="2017-10-24T05:12:57.833" Score="1" ViewCount="489" Body="&lt;p&gt;In my .vimrc I have explicitly written the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nowrap&#xA;set nospell&#xA;set foldcolumn=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, none of these seem to work by default and I always end up having to type the commands manually after startup. Could this be a file type issue / might it be the case that I have some plugins that override what I set in .vimrc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually if I strip my .vimrc down to just the three lines above, everything works out fine. It turned out that what's messing my wrapping and spelling is the vim-pandoc plugin. This is the minimal .vimrc file needed to reproduce&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;VUNDLE##################################################&#xA;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;Plugin 'vim-pandoc/vim-pandoc'&#xA;&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&quot;##########################################################&#xA;&#xA;set foldcolumn=0&#xA;set nospell&#xA;set nowrap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7784" LastEditorUserId="7784" LastEditDate="2017-10-26T04:59:27.263" LastActivityDate="2017-10-26T05:22:04.663" Title="Settings like nowrap, foldcolumn=0 and nospell have no effect in vimrc" Tags="|vimrc|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14015" PostTypeId="1" CreationDate="2017-10-24T09:26:43.153" Score="9" ViewCount="3740" Body="&lt;p&gt;I work with two displays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I usually open one instance of Vim in display #1 (let's call it Vim #1), which over time ends up having an open buffer for nearly every file in a project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to open one of the files in display #2, with a separate instance of Vim (#2). I ideally want to see the file in the same state I've got it somewhere inside Vim #1: with the same unsaved changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ultimately want to have two separate Vim instances simultaneously editing one buffer (possibly sharing the same &lt;code&gt;.swp&lt;/code&gt;?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do that in Vim?&lt;/p&gt;&#xA;" OwnerUserId="7798" LastEditorUserId="7798" LastEditDate="2017-10-24T09:33:23.263" LastActivityDate="2022-05-27T12:08:50.027" Title="How to share the same buffer between multiple vim instances" Tags="|buffers|sessions|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14017" PostTypeId="1" AcceptedAnswerId="14018" CreationDate="2017-10-24T21:09:17.267" Score="1" ViewCount="696" Body="&lt;p&gt;Vim has this odd behaviour: when I launch it in a terminal emulator under X,&#xA;it highlights closed folds, but when I launch it in console, closed folds'&#xA;representation is more sensible: they are just light blue, not in &#xA;standout/reverse mode. I would very much like Vim to behave under X the same&#xA;as in console, as I find highlighted folds highly distracting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which option controls this?&lt;/p&gt;&#xA;" OwnerUserId="14843" LastActivityDate="2017-10-24T21:41:44.960" Title="Vim highlights closed folds" Tags="|folding|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14018" PostTypeId="2" ParentId="14017" CreationDate="2017-10-24T21:41:44.960" Score="1" Body="&lt;p&gt;Look at &lt;code&gt;:hi Folded&lt;/code&gt;.  You probably have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Folded         xxx term=standout         . . .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Importantly, vim's &lt;code&gt;term=&lt;/code&gt; entry denotes a terminal it thinks cannot produce color (as opposed to &lt;code&gt;cterm=&lt;/code&gt;).  So, one potential way to resolve your issue is to properly set up color in xterm and vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi! Folded term=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if your color scheme overrides this, you will need to do this each time your colors are applied.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-10-24T21:41:44.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14019" PostTypeId="1" AcceptedAnswerId="14036" CreationDate="2017-10-25T09:02:01.773" Score="1" ViewCount="720" Body="&lt;p&gt;Golang &lt;a href=&quot;https://tour.golang.org/basics/3&quot; rel=&quot;nofollow noreferrer&quot;&gt;uses&lt;/a&gt; naming convention to separate functions visibility: exported (public) starts with a capital letter, non-exported (private) with a lower letter. I would like to highlight exported functions, so it would be easier to explore new files and APIs. Here is my try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match Title /func [A-Z][a-z0-9_]*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to improve it somehow? For example, right now &lt;code&gt;func&lt;/code&gt; is highlighted with the name. Is it possible to get rid of it? Maybe someone have better proposals for regex?&#xA;Also, how to apply this only for Go?  &lt;/p&gt;&#xA;" OwnerUserId="14850" LastEditorUserId="51" LastEditDate="2017-11-29T02:30:32.573" LastActivityDate="2017-11-29T03:22:23.503" Title="Highlight exported Go functions" Tags="|syntax-highlighting|regular-expression|highlight|filetype-go|" AnswerCount="2" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14020" PostTypeId="1" AcceptedAnswerId="14021" CreationDate="2017-10-25T09:32:19.430" Score="1" ViewCount="2314" Body="&lt;p&gt;Here is a text with lines containing simple words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AZREG AREDB Z ARGHREHV AZRZEGV RYUJUS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to replace this line with only the first and the last word separated by a space?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have ended up with &lt;code&gt;:! awk '{print $1 &quot; &quot; $NF}'&lt;/code&gt; but I was wondering if there was a full Vim solution…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: VIM - Vi IMproved 7.4&lt;/p&gt;&#xA;" OwnerUserId="9451" LastEditorUserId="343" LastEditDate="2017-10-25T14:47:11.083" LastActivityDate="2017-10-27T08:57:23.927" Title="replace lines with the first and the last word" Tags="|regular-expression|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14021" PostTypeId="2" ParentId="14020" CreationDate="2017-10-25T10:20:25.997" Score="4" Body="&lt;p&gt;Using substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/^\(\w\+\).*\s\(\w\+\)$/\1 \2/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is a single line substitution (&lt;code&gt;:s&lt;/code&gt;). To apply across the entire file use &lt;code&gt;:%s&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;li&gt;The pattern specifies alphanumeric (and underscore) words (&lt;code&gt;\w\+&lt;/code&gt;) anchored to the start (&lt;code&gt;^&lt;/code&gt;) and the end (&lt;code&gt;$&lt;/code&gt;). &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*&lt;/code&gt; slurps up everything short of a final whitespace character (&lt;code&gt;\s&lt;/code&gt;). Without this whitespace &lt;code&gt;.*&lt;/code&gt; would slurp up all remaining characters except for a single &lt;code&gt;\w&lt;/code&gt; because &lt;code&gt;*&lt;/code&gt; is a &quot;greedy&quot; wildcard.&lt;/li&gt;&#xA;&lt;li&gt;By surrounding the start and end word in the pattern with &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; we can refer to them in the substitution with &lt;code&gt;\1&lt;/code&gt; and &lt;code&gt;\2&lt;/code&gt;. These are called &quot;back references&quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Improving things, I prefer 'very magic' mode to make the pattern easier to read. And I'd probably use a stricter version where only lines entirely made up of whitespace separated &lt;em&gt;words&lt;/em&gt; are allowed: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v^(\w+)(\s+\w+)*\s(\w+)$/\1 \3/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: with mention of &lt;code&gt;awk&lt;/code&gt; I thought at first OP was trying to do this on the command line so I provided the following...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Command line version that updates the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -e +'%s/^\(\w\+\).*\s\(\w\+\)$/\1 \2/' +'wq' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using typical command line semantics (pipe to stdin, print to stdout) to just display the changes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat file | vim -e +'%s/^\(\w\+\).*\s\(\w\+\)$/\1 \2/p' +'q!' /dev/stdin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-10-26T09:07:29.250" LastActivityDate="2017-10-26T09:07:29.250" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14022" PostTypeId="1" AcceptedAnswerId="17468" CreationDate="2017-10-25T10:21:43.070" Score="1" ViewCount="187" Body="&lt;p&gt;If I  want to set the filetype manually in vim, I would like to tab complete filetypes vim recognizes. However, right now vim just inserts a literal &lt;code&gt;^I&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ft=markd^I&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2018-09-24T17:10:21.510" Title="Tab completion for filetypes in the commandline" Tags="|command-line|filetype|autocompletion|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14023" PostTypeId="2" ParentId="14022" CreationDate="2017-10-25T10:29:26.610" Score="4" Body="&lt;p&gt;AFAIK, we cannot add completion to standard commands. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have to define your own &lt;code&gt;:SetFT&lt;/code&gt; command and complete with &lt;code&gt;-complete=filetype&lt;/code&gt;&#xA;Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; untested&#xA;command! -nargs=1 -complete=filetype SetFt :set ft=&amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-10-25T10:29:26.610" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14024" PostTypeId="2" ParentId="14020" CreationDate="2017-10-25T11:29:25.730" Score="4" Body="&lt;p&gt;Here's a series of normal mode keystrokes that will perform the required action on a single line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;b&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How to apply this edit to every line in the file&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To run this on every line in your file you can use the &lt;code&gt;:normal&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm! wv$bhd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also apply this to a particular set of lines with a range (see &lt;code&gt;:help cmdline-ranges&lt;/code&gt;) or a global command (see &lt;code&gt;:help :global&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How to deal with indented lines&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;N.B. The sequence of commands described above will fail if the line is indented. In order to deal with indented lines, you will need first to move to the first non-blank character on the line with the &lt;kbd&gt;^&lt;/kbd&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;^&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;b&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Complete explanation of commands used&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;^&lt;/kbd&gt;: Move to first non-blank character on line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;w&lt;/kbd&gt;: Move to beginning of next word on line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;v&lt;/kbd&gt;: Enter visual mode,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;$&lt;/kbd&gt;: Move to the end of the line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;b&lt;/kbd&gt;: Move to the beginning of the last word on the line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;h&lt;/kbd&gt;: Move one column to the left,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;d&lt;/kbd&gt;: Delete the visual selection.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-10-27T08:57:23.927" LastActivityDate="2017-10-27T08:57:23.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14025" PostTypeId="2" ParentId="13997" CreationDate="2017-10-25T18:19:14.637" Score="4" Body="&lt;p&gt;I have successfully used &lt;a href=&quot;https://github.com/joonty/vdebug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vdebug&lt;/a&gt; for php and python, it provides the UI inside vim to visually step through the code, see stack traces, evaluate expressions, etc.&#xA;But unfortunately, it's quite complex to setup (at least was when I was using it) - it requires the DBGP server and &lt;a href=&quot;http://code.activestate.com/komodo/remotedebugging/&quot; rel=&quot;nofollow noreferrer&quot;&gt;komodo's server&lt;/a&gt; worked for me.&#xA;I also have helper &lt;a href=&quot;https://github.com/serebrov/vimrc/blob/b8c2349ebb1eedd294ab0b65ecc4367e3a4df3c7/.vimrc#L1543&quot; rel=&quot;nofollow noreferrer&quot;&gt;snippets&lt;/a&gt; in my vimrc to automatically start the server and then start the debugger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But recently I am only working with python and switched to the combination of &lt;a href=&quot;https://pypi.python.org/pypi/ipdb&quot; rel=&quot;nofollow noreferrer&quot;&gt;ipdb&lt;/a&gt; / &lt;a href=&quot;https://pypi.python.org/pypi/pdbpp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;pdbpp&lt;/a&gt;  console debuggers and I am quite happy with the experience.&#xA;I use &lt;code&gt;ipdb&lt;/code&gt; as primary debugger and &lt;code&gt;pdbpp&lt;/code&gt; provides additional &quot;sticky&quot; (full-screen) mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You just need to &lt;code&gt;pip install ipdb&lt;/code&gt; and &lt;code&gt;pip install pdbpp&lt;/code&gt; and then put a breakpoint (&lt;code&gt;__import__('ipdb').set_trace()&lt;/code&gt;) into your python module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the script or web app stops at the breakpoint, I immediately enter &lt;code&gt;sticky&lt;/code&gt; to switch to the full-screen mode and then use &lt;code&gt;n&lt;/code&gt; / &lt;code&gt;s&lt;/code&gt; and other pdb commands to steps through the code, inspect variables, etc.&lt;/p&gt;&#xA;" OwnerUserId="6013" LastActivityDate="2017-10-25T18:19:14.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14026" PostTypeId="2" ParentId="13795" CreationDate="2017-10-25T18:27:20.307" Score="18" Body="&lt;p&gt;From the YCM documentation.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;YCM will display a short diagnostic message when you move your cursor&#xA;  to the line with the error. You can get a detailed diagnostic message&#xA;  with the &lt;code&gt;&amp;lt;leader&amp;gt;d&lt;/code&gt; key mapping (can be changed in the options) YCM&#xA;  provides when your cursor is on the line with the diagnostic.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You can also see the full diagnostic message for all the diagnostics&#xA;  in the current file in Vim's &lt;code&gt;locationlist&lt;/code&gt;, which can be opened with&#xA;  the &lt;code&gt;:lopen&lt;/code&gt; and &lt;code&gt;:lclose&lt;/code&gt; commands (make sure you have set let&#xA;  &lt;code&gt;g:ycm_always_populate_location_list = 1&lt;/code&gt; in your vimrc). A good way to&#xA;  toggle the display of the locationlist with a single key mapping is&#xA;  provided by another (very small) Vim plugin called ListToggle (which&#xA;  also makes it possible to change the height of the &lt;code&gt;locationlist&lt;/code&gt;&#xA;  window), also written by yours truly.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="14856" LastEditorUserId="19911" LastEditDate="2018-11-21T23:07:04.160" LastActivityDate="2018-11-21T23:07:04.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14027" PostTypeId="2" ParentId="10817" CreationDate="2017-10-25T19:11:31.087" Score="5" Body="&lt;pre&gt;&lt;code&gt;#!/usr/bin/env bash&#xA;&#xA;sudo apt update&#xA;&#xA;sudo apt install -y git&#xA;&#xA;sudo apt install -y build-essential&#xA;&#xA;rm -fr /tmp/vim&#xA;&#xA;git clone https://github.com/vim/vim.git /tmp/vim&#xA;&#xA;make -C /tmp/vim&#xA;&#xA;sudo make install -C /tmp/vim &#xA;&#xA;rm -fr /tmp/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14858" LastEditorUserId="14858" LastEditDate="2017-10-25T19:26:15.833" LastActivityDate="2017-10-25T19:26:15.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14028" PostTypeId="1" CreationDate="2017-10-26T00:53:51.153" Score="8" ViewCount="8939" Body="&lt;p&gt;I've searched a lot about this on Internet but nothing's working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim 8.0.3 on Windows 10 and I can't get the right encoding to work. It's not a problem when writing code, but the problem comes when I try to write some text, mostly because I normally use Spanish and some characters are changed for other symbols. Here's an screenshot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9yhlB.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9yhlB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think the problem is because I'm using Cmder, because in CMD and Powershell I have the same problem. Maybe any of you have the solution to this.&lt;/p&gt;&#xA;" OwnerUserId="14863" LastEditorUserId="1841" LastEditDate="2018-10-09T14:26:34.507" LastActivityDate="2018-10-09T14:26:34.507" Title="UTF-8 not working on VIM" Tags="|microsoft-windows|encoding|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="14029" PostTypeId="1" CreationDate="2017-10-26T01:10:50.997" Score="3" ViewCount="242" Body="&lt;p&gt;I've happily used count prefixes on search commands in vim for probably a couple of decades, so I know they used to count correctly. &lt;code&gt;5n&lt;/code&gt; was equivalent to &lt;code&gt;n&lt;/code&gt; 5 times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As of some recent version, &lt;code&gt;5n&lt;/code&gt; is sometimes equivalent to &lt;code&gt;n&lt;/code&gt; 5 times, and sometimes equivalent to &lt;code&gt;n&lt;/code&gt; 6 times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can no longer type &lt;code&gt;5n&lt;/code&gt;, see the cursor stay in the same place while the &quot;search wrapped&quot; message appears at the bottom of the screen, and know that there are 5 whatevers in the file. Which sounds really silly when I try to explain it, but it's apparently something I was doing subconsciously &lt;em&gt;all the time&lt;/em&gt;, so the new version is driving me crazy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be causing the search repeat count to behave inconsistently, and how can I fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About my environment: The active options as reported by &lt;code&gt;:set&lt;/code&gt; are&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  autoindent          expandtab           ruler               ttymouse=xterm&#xA;  background=dark     fileformats=        shiftwidth=2        viminfo=&#xA;  backspace=1       nofsync               swapsync=           wrapmargin=3&#xA;  cpoptions=BceFs$t nojoinspaces        notextauto&#xA;noequalalways       noloadplugins         tildeop&#xA;noesckeys           nomore                ttyfast&#xA;  completeopt=preview&#xA;  formatoptions=tcroq2b&#xA;  path=.,/usr/include,,,/usr/include/x86_64-linux-gnu&#xA;  printoptions=paper:letter&#xA;  runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/&#xA;vim80,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after&#xA;  suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg&#xA;,.inx,.out,.toc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some of those settings come from the Debian packaging. The rest are my preferences. I don't do scripting, plugins, or any other fancy stuff.&lt;/p&gt;&#xA;" OwnerDisplayName="user1170" LastEditorUserId="343" LastEditDate="2017-12-06T11:23:51.493" LastActivityDate="2017-12-06T11:23:51.493" Title="repeat search in vim: count is off by one sometimes" Tags="|search|count|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14030" PostTypeId="2" ParentId="14014" CreationDate="2017-10-26T05:22:04.663" Score="1" Body="&lt;p&gt;As stated in the edit above my problem was caused by the vim-pandoc plugin. Fix number 2 presented by Doktor OSwaldo &lt;a href=&quot;https://vi.stackexchange.com/a/13538/7784&quot;&gt;for this question&lt;/a&gt; solves this for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType pandoc setlocal nowrap&#xA;autocmd FileType pandoc setlocal nospell&#xA;autocmd FileType pandoc setlocal foldcolumn=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7784" LastActivityDate="2017-10-26T05:22:04.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14031" PostTypeId="2" ParentId="14029" CreationDate="2017-10-26T06:44:55.893" Score="2" Body="&lt;p&gt;It looks like in the current version of &lt;code&gt;vim&lt;/code&gt; the &lt;code&gt;n&lt;/code&gt; command is guaranteed to move the cursor, unless there is exactly &lt;em&gt;one&lt;/em&gt; match on the file.&lt;/p&gt;&#xA;&lt;p&gt;However, the search command &lt;code&gt;/&lt;/code&gt; will behave as you are used to. Consider a file with  these contents:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;word&#xA;word&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Let's imagine that the cursor is at the beginning of the file. Searching for &amp;quot;word&amp;quot; will place the cursor at the beginning of line 2. Pressing &lt;code&gt;2n&lt;/code&gt; the cursor will move to the first line, triggering the &amp;quot;search wrapped&amp;quot; message. Now the cursor is in the first line, and if you press &lt;code&gt;2/&amp;lt;CR&amp;gt;&lt;/code&gt;, it will stay on the first line, also triggering the &amp;quot;search wrapped&amp;quot; message.&lt;/p&gt;&#xA;&lt;h3&gt;Workaround&lt;/h3&gt;&#xA;&lt;p&gt;You can remap &lt;code&gt;n&lt;/code&gt; to restore the desired behavior:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nmap n /&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="259" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-10-26T06:44:55.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14032" PostTypeId="1" CreationDate="2017-10-26T08:21:39.167" Score="1" ViewCount="1426" Body="&lt;p&gt;I'm using vim for only a year. So, I'm a noob.&#xA;I need help regarding setting up youcompleteme plugin for vim 8.0 with c/c++ semantic and java autocomplete support. I tried 2-3 times with no luck. No autocomplete suggestions appears. I use vundle on manjaro linux.&#xA;I tried to follow the instructions in the git page README.md but it's just so confusing!&#xA;I would appreciate a guideline to set up the plugin.&lt;/p&gt;&#xA;" OwnerDisplayName="user14867" LastActivityDate="2018-03-25T15:15:57.773" Title="Vim Youcompleteme" Tags="|plugin-you-complete-me|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14033" PostTypeId="2" ParentId="14032" CreationDate="2017-10-26T12:59:13.917" Score="1" Body="&lt;p&gt;If you didn't get YCM installed at all you may have issues with having the necessary dependencies but assuming you have YCM successfully installed and you installed like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./install --clang-completer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You most likely didn't make a &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt; file. (You would have got a big error at the bottom of your terminal &quot;NoExtraConfDetected: No .ycm_extra_conf.py file detected, ...&quot;) &#xA;What this file does is it basically tells YCM what semantic support it need to provide by giving it the flags you would compile with. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/blob/master/README.md#c-family-semantic-completion&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for details on semantic support from YCM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have ever made a make file before then your job is super simple! Head on over to &lt;a href=&quot;https://github.com/rdnetto/YCM-Generator&quot; rel=&quot;nofollow noreferrer&quot;&gt;YCM-Generator&lt;/a&gt; and follow the simple instructions to get going with generating the file.&lt;br&gt;&#xA;Otherwise if you are only doing very basic stuff at the moment (don't worry we were all there :) ) then you can probably get away with a basic file and once you become a bit more experienced and require more in depth semantic support config files you'll hopefully be comfortable enough generating a more detailed &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example of all that you'd need for now to get going with C:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def FlagsForFile( filename, **kwargs ): &#xA;    return {&#xA;      'flags': [ '-x', 'c', '-Wall', '-Wextra', '-Werror' ], &#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This tells YCM to give you errors to the same level as compiling your program like so &lt;code&gt;gcc -Wall -Wextra -Werror foo.c&lt;/code&gt;. You can go ahead and add/remove flags to this file eg a particular C standard ie &lt;code&gt;-std=gnu99&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then all you need to do is place this file in the directory, or root directory of the program. If you keep all your programs in subfolders of a particular folder, the easiest thing to do for now is just pop it in the main folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Java has a similar process which is also well documented in the &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/blob/master/README.md#javascript-semantic-completion&quot; rel=&quot;nofollow noreferrer&quot;&gt;YCM README.md&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14380" LastActivityDate="2017-10-26T12:59:13.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14035" PostTypeId="1" AcceptedAnswerId="14037" CreationDate="2017-10-26T18:09:20.707" Score="1" ViewCount="4448" Body="&lt;p&gt;I am having a tough time finding and replacing a string using vi.&#xA;Source String: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;amp;DB2_PORT;/&amp;amp;DB2_DATA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;New String after replace: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;amp;DB2_PORT;/&amp;amp;DB2_DATA;:tcp=true&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can find &lt;code&gt;&amp;amp;DB2_DATA;&lt;/code&gt; and replace it with &lt;code&gt;&amp;amp;DB2_DATA;:tcp=true,&lt;/code&gt; but that is not what I need to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please help me understand the appropriate ':s' command in order to achieve this replacement?&lt;/p&gt;&#xA;" OwnerUserId="14870" LastEditorUserId="15641" LastEditDate="2019-04-06T05:48:25.273" LastActivityDate="2019-04-06T05:48:25.273" Title="Find and replace string with slash in it and retain the slash in the new string" Tags="|regular-expression|substitute|replace|find|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="14036" PostTypeId="2" ParentId="14019" CreationDate="2017-10-26T18:53:43.120" Score="4" Body="&lt;p&gt;To borrow &lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;@Christian Brabandt&lt;/a&gt;'s answer in the comments (and break it down further):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match Title /func \zs[A-Z][a-z0-9_]*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The regex is the same as before, but the &lt;code&gt;\zs&lt;/code&gt; marker effectively tells Vim, &quot;Here's where the match &lt;em&gt;starts&lt;/em&gt;.&quot; So we can use this to find the word &lt;code&gt;func&lt;/code&gt;, followed by a space, followed by a valid public Go function name, but we only match from the beginning of the function name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To add this to only Go files, you have two options.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Filetype plugins (preferred)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Drop this in &lt;code&gt;~/.vim/syntax/go.vim&lt;/code&gt; to overrule go highlighting, or &lt;code&gt;~/.vim/after/syntax/go.vim&lt;/code&gt; to modify go highlighting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match Title /func \zs[A-Z][a-z0-9_]*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Autocommands&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Drop this in your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup GoFuncHighlight&#xA;  au!&#xA;  au FileType go match Title /func \zs[A-Z][a-z0-9_]*/&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, when a filetype is set to &quot;go&quot;, we get the match command run&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Further Reading&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help autocmd&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help FileType&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help filetype&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help syntax&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \zs&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As @Carpetsmoker states in the comments:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that this won’t work for (exported) receiver methods, which look like &lt;code&gt;func (f Type) Name()&lt;/code&gt;. In addition unicode identifiers are allowed in Go [...]. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2017-11-29T03:22:23.503" LastActivityDate="2017-11-29T03:22:23.503" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14037" PostTypeId="2" ParentId="14035" CreationDate="2017-10-26T19:50:29.047" Score="2" Body="&lt;p&gt;This should do what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;amp;DB2_PORT;\/&amp;amp;DB2_DATA;/\0:tcp=true/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-10-26T19:50:29.047" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14039" PostTypeId="2" ParentId="14028" CreationDate="2017-10-26T23:07:37.163" Score="3" Body="&lt;p&gt;Windows doesn't use UTF-8 natively. &lt;a href=&quot;https://en.wikipedia.org/wiki/UTF-16#UTF-16LE&quot; rel=&quot;nofollow noreferrer&quot;&gt;It uses UTF-16LE by default&lt;/a&gt;. If you do not &lt;a href=&quot;https://superuser.com/questions/269818/change-default-code-page-of-windows-console-to-utf-8&quot;&gt;change the Windows console to UTF-8&lt;/a&gt;, it is not going to do what you want with the text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Part of the problem may be that you aren't using &lt;a href=&quot;https://en.wikipedia.org/wiki/Win32_console&quot; rel=&quot;nofollow noreferrer&quot;&gt;Windows console&lt;/a&gt;, at least not directly: your screenshot shows you're using a third-party tool called &lt;a href=&quot;http://cmder.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cmder&lt;/a&gt;, which may be part of the problem. It is possible that the UTF-8 solution linked above will fix Cmder, too, but if not, try running Vim via &lt;code&gt;cmd.exe&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that fixes it, you might want to switch to the &lt;a href=&quot;http://cygwin.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cygwin&lt;/a&gt; build of Vim, since Cygwin normally uses &lt;a href=&quot;https://mintty.github.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MinTTY&lt;/a&gt;, a considerably nicer console program than the stock Windows one. Because Cygwin is trying to emulate Linux atop Windows, it uses UTF-8 by default.&lt;/p&gt;&#xA;" OwnerUserId="6852" LastActivityDate="2017-10-26T23:07:37.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14041" PostTypeId="1" AcceptedAnswerId="14042" CreationDate="2017-10-27T05:32:45.760" Score="2" ViewCount="946" Body="&lt;p&gt;I want to find two consecutive non-empty lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AAA&#xA;BBB&#xA;&#xA;    AAA&#xA;BBB&#xA;&#xA;AAA&#xA;    BBB&#xA;&#xA;    AAA&#xA;    BBB&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The file above shows four pairs of consecutive non-empty lines. All of the lines can have trailing white space&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;^\s*\S\+\n\s*\S+&lt;/code&gt; But that does not do the job. Moreover, it does not account for trailing spaces. I tried &lt;code&gt;^\s*\S\+\s*$\n\s*\S+\s*$&lt;/code&gt; too. But no luck again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how do I search for such lines? And it would be great if you could explain your solution.&lt;/p&gt;&#xA;" OwnerUserId="3095" LastActivityDate="2017-10-27T06:29:06.823" Title="Find two consecutive non-empty lines" Tags="|search|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14042" PostTypeId="2" ParentId="14041" CreationDate="2017-10-27T06:29:06.823" Score="4" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/.*\S.*\n.*\S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That finds a line containing at least one non-space character (\S) followed by another line containing at least one non-space character. That assumes that &quot;non-empty&quot; means containing at least one non-space character.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-10-27T06:29:06.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14043" PostTypeId="2" ParentId="14012" CreationDate="2017-10-27T06:51:06.370" Score="2" Body="&lt;p&gt;The error message &lt;code&gt;Not an editor command: silent NERDTreeToggle&lt;/code&gt; says that something is trying to use a command &lt;code&gt;NERDTreeToggle&lt;/code&gt; but this command doesn't exist and Vim can't execute it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;NERDTreeToggle&lt;/code&gt; is a command defined by the plugin &lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDTree&lt;/a&gt; which seems to indicate that the plugin is not installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when you read the very first line of the &lt;a href=&quot;https://github.com/jistr/vim-nerdtree-tabs#installation&quot; rel=&quot;nofollow noreferrer&quot;&gt;installation section in the README&lt;/a&gt; you'll see&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;If you haven't already, install NERDTree (see &lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/scrooloose/nerdtree&lt;/a&gt;)&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus if you install the plugin you should get rid of these errors.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-10-27T06:51:06.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14044" PostTypeId="1" AcceptedAnswerId="14045" CreationDate="2017-10-27T08:57:16.483" Score="0" ViewCount="56" Body="&lt;p&gt;I am wondering why I can't use a mapping for &lt;code&gt;&amp;lt;C-)&amp;gt;&lt;/code&gt; when a mapping for &lt;code&gt;)&lt;/code&gt; already exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:imap&lt;/code&gt; shows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i  )           *@&amp;lt;C-R&amp;gt;=AutoPairsInsert(')')&amp;lt;CR&amp;gt;&#xA;i  &amp;lt;C-)&amp;gt;       * )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I expect to be able to press &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;)&lt;/kbd&gt; and have &lt;code&gt;)&lt;/code&gt; inserted. Instead, my cursor jumps as if I just pressed a an unmodified &lt;kbd&gt;)&lt;/kbd&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I keep my &lt;code&gt;)&lt;/code&gt; mapping and have &lt;code&gt;&amp;lt;C-)&amp;gt;&lt;/code&gt; work also?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2017-11-02T10:37:28.940" LastActivityDate="2017-11-02T10:37:28.940" Title="Mapping of (key) overrides mapping of `&lt;C-(key)&gt;`" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ClosedDate="2017-10-30T10:55:30.793" ContentLicense="CC BY-SA 3.0" />
  <row Id="14045" PostTypeId="2" ParentId="14044" CreationDate="2017-10-27T09:30:07.977" Score="0" Body="&lt;p&gt;The problem comes from my terminal: If I run &lt;code&gt;cat&lt;/code&gt;, pressing &lt;kbd&gt;Ctrl-)&lt;/kbd&gt; and &lt;kbd&gt;)&lt;/kbd&gt; give the same output.&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="1841" LastEditDate="2017-11-02T08:23:44.723" LastActivityDate="2017-11-02T08:23:44.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14046" PostTypeId="1" AcceptedAnswerId="14119" CreationDate="2017-10-27T10:36:42.670" Score="0" ViewCount="1150" Body="&lt;p&gt;I'm using these keyboard shortcuts to navigate/manipulate tabs in MacVim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; tab navigation&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;S-Left&amp;gt; :tabprevious&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;S-Right&amp;gt; :tabnext&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; tab movement&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;S-A-Left&amp;gt; :call MoveTabLeft()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;S-A-Right&amp;gt; :call MoveTabRight()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I'm using custom functions that use &lt;code&gt;tabmove&lt;/code&gt; to position current tab.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When running vim from Terminal.app, &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;Left&lt;/kbd&gt; and &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;Right&lt;/kbd&gt; work (i.e. I can navigate tabs right and left), but when using &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;Arrow&lt;/kbd&gt; nothing happens. Does this require Terminal.app configuration to send some special characters, is this a feature of MacVim only or is there a vim setting I am not using properly?&lt;/p&gt;&#xA;" OwnerUserId="1733" LastActivityDate="2017-11-06T13:00:02.777" Title="How to make &lt;S-A-Left&gt; and &lt;S-A-Right&gt; work in vim within Mac Terminal" Tags="|vimrc|macvim|tabbed-user-interface|macos|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14047" PostTypeId="1" CreationDate="2017-10-27T14:02:35.647" Score="27" ViewCount="1191" Body="&lt;p&gt;Consider the text:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;foobarbaz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;First we highlight the regular expression &lt;code&gt;/foobar/&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match Special /foobar/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3bD5o.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3bD5o.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Next we highlight the regular expression &lt;code&gt;/foobarbaz/&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match Error /foobarbaz/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This match begins in the same position as our &lt;code&gt;Special&lt;/code&gt; group, but it was defined later, and so it takes precedence. (See &lt;a href=&quot;https://vimhelp.org/syntax.txt.html#%3Asyn-priority&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :syn-priority.&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zz65p.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zz65p.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now let's clear that (&lt;code&gt;:syntax clear Error&lt;/code&gt;), and instead try starting our highlighting at &lt;code&gt;bar&lt;/code&gt; by using &lt;code&gt;\zs&lt;/code&gt; to set the start of the match.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match Error /foo\zsbarbaz/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3bD5o.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3bD5o.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Okay, that didn't work, but perhaps it's because by altering the start of the match, this match now begins &lt;em&gt;inside&lt;/em&gt; our earlier group. If that's the case, we can fix it with the &lt;a href=&quot;https://vimhelp.org/syntax.txt.html#%3Asyn-containedin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;containedin&lt;/code&gt;&lt;/a&gt; argument:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match Error /foo\zsbarbaz/ containedin=Special&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/T6JXR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T6JXR.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;That seems to have worked!&lt;/p&gt;&#xA;&lt;p&gt;Now let's try starting our highlighting from the &lt;code&gt;baz&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match Error /foobar\zsbaz/ containedin=Special&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3bD5o.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3bD5o.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Huh. Now that we've moved the start of our &lt;code&gt;Error&lt;/code&gt; match past the end of the &lt;code&gt;Special&lt;/code&gt; match, it no longer works. (Note that I'm not using the &lt;a href=&quot;https://vimhelp.org/syntax.txt.html#%3Asyn-contained&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;contained&lt;/code&gt;&lt;/a&gt; argument, so even if the &lt;code&gt;Error&lt;/code&gt; group  starts outside of the &lt;code&gt;Special&lt;/code&gt; group, it should still match: removing the &lt;code&gt;containedin&lt;/code&gt; argument also has no effect.)&lt;/p&gt;&#xA;&lt;p&gt;The sole mention of &lt;code&gt;\zs&lt;/code&gt; in &lt;code&gt;syntax.txt&lt;/code&gt; doesn't appear to be relevant (it regards multi-line patterns), and &lt;code&gt;:help \zs&lt;/code&gt; also doesn't shed any light on this.&lt;/p&gt;&#xA;&lt;p&gt;What's going on?&lt;/p&gt;&#xA;&lt;p&gt;N.B. For this particular example, I could use an &lt;code&gt;hs&lt;/code&gt; syntax pattern offset to achieve the desired highlighting, and with more complicated regular expressions I could use &lt;code&gt;\@&amp;lt;=&lt;/code&gt; look-behind. But &lt;code&gt;\zs&lt;/code&gt; is recommended over &lt;code&gt;\@&amp;lt;=&lt;/code&gt; for performance reasons, and in any case, I'd still like to understand how the feature &lt;em&gt;works&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2021-03-31T14:50:47.830" LastActivityDate="2021-03-31T14:50:47.830" Title="How does `\zs` interact with syntax matches?" Tags="|syntax-highlighting|regular-expression|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="14048" PostTypeId="2" ParentId="14019" CreationDate="2017-10-27T14:23:42.133" Score="3" Body="&lt;p&gt;David Ben Knoble has already given you a &lt;a href=&quot;https://vi.stackexchange.com/a/14036/343&quot;&gt;good, working solution&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, seeing as this is syntax that you're highlighting, I feel like it's cleaner to perform the task with a &lt;code&gt;:syntax&lt;/code&gt; command. This also has the slight advantage that &lt;code&gt;:match&lt;/code&gt; is free for other purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reasons &lt;a href=&quot;https://vi.stackexchange.com/questions/14047/how-does-zs-interact-with-syntax-matches&quot;&gt;I'm slightly unclear on&lt;/a&gt;, it's not possible to use the previously explained &lt;code&gt;\zs&lt;/code&gt; atom in this match, but it's easy to achieve using a syntax pattern offset instead. Drop the following command in the file &lt;code&gt;~/.vim/after/syntax/go.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match goExportedFunction /func [A-Z][a-z0-9_]*/hs=s+5 contains=goDeclaration&#xA;highlight default link goExportedFunction Title&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This syntax group will take precedence over the existing &lt;code&gt;goDeclaration&lt;/code&gt; group used for the &lt;code&gt;func&lt;/code&gt; because it starts in the same position, but was declared later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;hs=s+5&lt;/code&gt; after the regular expression tells Vim that you want the highlighting to start 5 characters after the beginning of the match i.e. at the start of the function name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;contains=goDeclaration&lt;/code&gt; might not strictly be necessary depending on your colour scheme, but it means that the &lt;code&gt;func&lt;/code&gt; at the beginning of the line is still matched by the &lt;code&gt;goDeclaration&lt;/code&gt; group in the same way as before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.B. For clarity, I've used the same basic regular expression as you used. However, as I suggested &lt;a href=&quot;https://vi.stackexchange.com/questions/14019/highlight-public-go-functions/14048#comment24104_14019&quot;&gt;in a comment&lt;/a&gt;, the following is faster, more concise, and more correct:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match goExportedFunction /func \u\w*/hs=s+5 contains=goDeclaration&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Further Reading&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :syn-priority&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :syn-pattern-offset&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :syn-contains&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="51" LastEditDate="2017-11-29T02:23:20.400" LastActivityDate="2017-11-29T02:23:20.400" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="14049" PostTypeId="2" ParentId="14035" CreationDate="2017-10-27T15:19:45.370" Score="3" Body="&lt;p&gt;As you state, your string contains &lt;code&gt;/&lt;/code&gt; so presumably that is tripping you up since it must be escaped if you use &lt;code&gt;/&lt;/code&gt; to delimit the sections of your substitution command. See the other answer here for solution with escaping. But we don't have to use &lt;code&gt;/&lt;/code&gt; as our separator. We can use any non-alphanumeric, single-byte character except &lt;code&gt;\&lt;/code&gt;, &lt;code&gt;&quot;&lt;/code&gt; or &lt;code&gt;|&lt;/code&gt;. For example, with &lt;code&gt;#&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s#&amp;amp;DB2_PORT;/&amp;amp;DB2_DATA;#&amp;amp;:tcp=true#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: In a substitution &lt;code&gt;&amp;amp;&lt;/code&gt; is replaced with whatever string was matched by your pattern.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-10-27T15:38:04.177" LastActivityDate="2017-10-27T15:38:04.177" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14050" PostTypeId="2" ParentId="14028" CreationDate="2017-10-27T16:54:58.970" Score="7" Body="&lt;p&gt;&lt;strong&gt;GENERAL SETTINGS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim internal use of encoding (this settings is must if you like to use utf-8 or you would like to convert encoding from one to another). I strongly recommend to set this setting in _vimrc file (Windows equivalent of Linux .vimrc file). You can open your _vimrc file with command: :e $MYVIMRC&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:set encoding=utf-8&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Bellow is actual setting that will convert to utf-8 when you execute :w  (saving file). You can also set this in _vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:set fileencoding=utf-8&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is also smart to set encodings (notice &quot;s&quot; at the end of command).&#xA;Bellow settings tries to recognize the encoding of existing file when file is opened. I also suggest to save this setting in _vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:set fileencodings=ucs-bom,utf8,latin1&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SAMPLE HOW TO CONVERT FILE ENCODING FROM ONE ENCODING TO ANOTHER&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now lets say you have a file in some other encoding like cp1250 (latin2) and you would like to convert encoding to utf-8.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Set internal Vim encoding to utf-8. A must have setting if multiple code pages are used and converting between them.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:set encoding=utf-8&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Open file and let Vim know what is your current encoding file is saved in (e.g. cp1250 for Eastern Europe encodings = latin2)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:e ++enc=cp1250 YourFile.txt&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;or if file already opened: :e! ++enc=cp1250&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Set target file encoding to utf-8:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:set fileencoding=utf-8&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now do actual save (conversion happens now):&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:w&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11181" LastEditorUserId="11181" LastEditDate="2017-10-27T17:12:32.040" LastActivityDate="2017-10-27T17:12:32.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14051" PostTypeId="1" AcceptedAnswerId="14054" CreationDate="2017-10-27T18:01:19.533" Score="2" ViewCount="118" Body="&lt;p&gt;I’m usually fine with swap files being created in the same directory as the files being edited—I have the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27directory%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;directory&lt;/code&gt;&lt;/a&gt; setting left on its default value. I have one project, though, with “file watching” functionality that gets confused by swap files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I notice that &lt;code&gt;directory&lt;/code&gt; is a global setting (i.e. you can’t set it on a per-buffer basis). Is there some workaround so that I can change where swap files are put &lt;em&gt;only&lt;/em&gt; when I’m editing files within a certain directory?&lt;/p&gt;&#xA;" OwnerUserId="671" LastEditorUserId="1841" LastEditDate="2017-11-06T07:58:00.450" LastActivityDate="2017-11-06T07:58:00.450" Title="Can I have a per-directory setting for where swap files are stored?" Tags="|swap-file|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14052" PostTypeId="1" AcceptedAnswerId="14053" CreationDate="2017-10-27T21:43:51.783" Score="0" ViewCount="334" Body="&lt;p&gt;Is there a way to have &lt;code&gt;s;/;|;g&lt;/code&gt; run only on the lines I filter using a regex?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a file, which looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Date: 2017/08/18&#xA;Path /home/share/thing&#xA;Path /home/me/thing&#xA;Date: 2017/08/18&#xA;Path /home/share/thing&#xA;Date: 2017/08/18&#xA;Path /home/share/thing&#xA;Path /home/me/thing&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now this is simplified, but the point is I want to substitute the &lt;code&gt;/&lt;/code&gt; on the lines beginning with &lt;code&gt;Path&lt;/code&gt;, but not the ones beginning with &lt;code&gt;Date&lt;/code&gt;.  I can grab all of the lines with &lt;code&gt;Path&lt;/code&gt; easily enough (&lt;code&gt;:g/Path&lt;/code&gt;) and substitute all of the &lt;code&gt;/&lt;/code&gt;s (&lt;code&gt;:%s;/;|;g&lt;/code&gt;), but for substituting on the specific lines I only know how to give &lt;code&gt;s&lt;/code&gt; a range, which doesn't help much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like it would be easiest if you could pipe the output of &lt;code&gt;g&lt;/code&gt; to &lt;code&gt;s&lt;/code&gt;, but I couldn't find anything on doing something like that.&lt;/p&gt;&#xA;" OwnerUserId="14468" LastActivityDate="2017-10-27T21:54:10.323" Title="Substitute only on certain lines" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14053" PostTypeId="2" ParentId="14052" CreationDate="2017-10-27T21:54:10.323" Score="5" Body="&lt;p&gt;You &lt;em&gt;can&lt;/em&gt; &quot;pipe&quot; the lines from &lt;code&gt;:g/&lt;/code&gt; to &lt;code&gt;:s&lt;/code&gt;.  Really, this is a special case of using any command after the &lt;code&gt;g//&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/Path/s;/;|;g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is also documented explicitly at the bottom of the section &lt;code&gt;:help :g&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-10-27T21:54:10.323" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14054" PostTypeId="2" ParentId="14051" CreationDate="2017-10-27T22:01:36.227" Score="2" Body="&lt;p&gt;If you're willing to edit those files only, using a separate instance of vim, you can do a &lt;code&gt;vim -n &amp;lt;filename&amp;gt;&lt;/code&gt; which tells vim to use memory only, no swap files for editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could create a &lt;code&gt;.vimrc&lt;/code&gt; file in that particular directory, containing the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source ~/.vimrc&#xA;directory=~/tmp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then start vim within that directory via &lt;code&gt;vim -u &amp;lt;vimrc&amp;gt; &amp;lt;filename&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2017-10-27T22:01:36.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14055" PostTypeId="2" ParentId="457" CreationDate="2017-10-28T03:44:28.767" Score="-1" Body="&lt;p&gt;The original &quot;ex&quot; was the upgraded version of the &quot;ed&quot; text editor in Unix. In 2BSD a visual mode was added, and the new editor was called &quot;vi&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If one wants to use the ex command line, he will switch to command mode with the &quot;:&quot; key. So in my best understanding ex is actually not there for nostalgy, it is the part to provide command mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also enter its insert mode by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :i &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then hit &quot;enter and type your text. Exit with ^c.&#xA;Or type it all on one command line, like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :i my multiline text \with a second line.^c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14886" LastEditorUserId="205" LastEditDate="2017-10-28T04:40:26.210" LastActivityDate="2017-10-28T04:40:26.210" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14056" PostTypeId="1" AcceptedAnswerId="14058" CreationDate="2017-10-28T08:46:57.757" Score="4" ViewCount="3518" Body="&lt;p&gt;I am using Vim 7.4 and I wish to map the tab key so I can use new combinations to autocomplete arguments in command mode from the current directory &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Contents of current directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Funwithstrings.cs Funwithstrings.exe Funwithstrings.cs~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using vim in this directory :&#xA;I am using following mapping in vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map! as &amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now upon trying this in command mode in the manner &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e Fuas.  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e Fu^I&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I.e., &lt;code&gt;^I&lt;/code&gt; two characters instead of special character &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;&#xA;instead of one of the filenames-- expected results with tab key.&#xA;In a different computer I get &lt;code&gt;:e Fu&amp;lt;Tab&amp;gt;&lt;/code&gt; - 5 characters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong? I am using screen 256 terminal. &lt;/p&gt;&#xA;" OwnerUserId="14887" LastEditorUserId="2736" LastEditDate="2017-10-28T17:45:19.890" LastActivityDate="2020-06-03T19:23:11.847" Title="Remapping tab key to autocomplete in commandline mode in Vim" Tags="|vimrc|key-bindings|autocompletion|normal-mode|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14058" PostTypeId="2" ParentId="14056" CreationDate="2017-10-28T21:21:36.020" Score="5" Body="&lt;p&gt;By default with nocompatible, vim sets &lt;code&gt;wildchar&lt;/code&gt; to &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; which enables you to tab complete &quot;out of the box.&quot;  However, this does not extend to &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;s produced by mappings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if we &lt;code&gt;cnoremap as &amp;lt;tab&amp;gt;&lt;/code&gt;, pressing &lt;code&gt;as&lt;/code&gt;, vim will type literal tabs, which in this case render as &lt;code&gt;^I&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to use &lt;code&gt;wildcharm&lt;/code&gt;, which is &quot;recognized when used inside a macro&quot; (see &lt;code&gt;:help wildcharm&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set wildcharm=&amp;lt;tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative to making a mapping to &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; is to just set &lt;code&gt;wildchar&lt;/code&gt; or &lt;code&gt;wildcharm&lt;/code&gt; to the key you want.  This works only for single characters.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-10-29T15:00:34.647" LastActivityDate="2017-10-29T15:00:34.647" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14061" PostTypeId="1" AcceptedAnswerId="14062" CreationDate="2017-10-30T15:49:12.153" Score="4" ViewCount="1232" Body="&lt;p&gt;Is there a Vim function or variable that would return 1/3rd (or any dynamic value) of the current window height?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/kassio/neoterm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neoterm&lt;/a&gt;, and it's terminal splits open at half the current window height by default. I want them to open at 1/3rd the current window height.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="14" LastActivityDate="2017-10-30T16:30:49.793" Title="How can I open a split at whose height is a percentage of the main window?" Tags="|vim-windows|split|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14062" PostTypeId="2" ParentId="14061" CreationDate="2017-10-30T16:30:49.793" Score="8" Body="&lt;p&gt;The &lt;code&gt;winheight&lt;/code&gt; function will return the height of window &lt;strong&gt;n&lt;/strong&gt;. From &lt;code&gt;:h winheight()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;winheight({nr})                     *winheight()*&#xA;        The result is a Number, which is the height of window {nr}.&#xA;        {nr} can be the window number or the |window-ID|.&#xA;        When {nr} is zero, the height of the current window is&#xA;        returned.  When window {nr} doesn't exist, -1 is returned.&#xA;        An existing window always has a height of zero or more.&#xA;        Examples: &amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;winheight(0)&lt;/code&gt; will give us the height of the current window. &lt;code&gt;split&lt;/code&gt; takes a numerical argument. From &lt;code&gt;:h :split&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[N]sp[lit] [++opt] [+cmd] [file]           *:sp* *:split*&#xA;        Split current window in two.  The result is two viewports on&#xA;        the same file.&#xA;&#xA;        Make the new window N high (default is to use half the height&#xA;        of the current window).  Reduces the current window height to&#xA;        create room (and others, if the 'equalalways' option is set,&#xA;        'eadirection' isn't &quot;hor&quot;, and one of them is higher than the&#xA;        current or the new window).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, combining these two commands, you could do this with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec winheight(0)/3.&quot;split&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec winheight(0)/3.&quot;new&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you want a new buffer, rather than a split on the same file. Since this isn't exactly easy to remember, you could wrap it in a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ThirdSplit()&#xA;  exec winheight(0)/3.&quot;split&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could even make this function take an optional denominator:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Split(ratio)&#xA;  exec winheight(0)/a:ratio.&quot;split&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or of course, you could make a mapping. For example, &lt;code&gt;&amp;lt;leader&amp;gt;s&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;s &quot;:&quot;.winheight(0)/3.&quot;split\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-10-30T16:30:49.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14065" PostTypeId="1" AcceptedAnswerId="14068" CreationDate="2017-10-31T08:28:38.977" Score="8" ViewCount="2021" Body="&lt;p&gt;How can set BufEnter or WinEnter autocmds for entering quickfix window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd WinEnter quickfix echo 'winenter'&#xA;autocmd BufEnter quickfix echo 'bufenter'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;None of them works. I doubt that it is because these two commands needs file name after the event name. Then what is the file pattern for quickfix window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have fugitive installed. By filling the quickfix window using &lt;code&gt;Glog&lt;/code&gt;, the statusline for the quickfix window shows something like &lt;code&gt;[:git --git-dir=...] [Quickfix List]&lt;/code&gt;. Is this the filename of the quickfix buffer which should be used in the pattern of the &lt;code&gt;BufEnter/WinEnter&lt;/code&gt; event? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot see anything if I &lt;code&gt;echo @%&lt;/code&gt; which should usually show the current bufname.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2023-07-19T12:50:09.197" Title="autocmd with quickfix window" Tags="|autocmd|quickfix|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14066" PostTypeId="1" AcceptedAnswerId="14067" CreationDate="2017-10-31T09:13:08.840" Score="1" ViewCount="121" Body="&lt;p&gt;It seems that &lt;code&gt;&amp;amp;&lt;/code&gt; followed by an option name is an variable containing the option value, such as &lt;code&gt;&amp;amp;diff&lt;/code&gt;. What is &lt;code&gt;&amp;amp;l:diff&lt;/code&gt;. I assume it is the local value for &lt;code&gt;diff&lt;/code&gt; option, but I cannot find the doc that mentioned this. (I found the example in &lt;code&gt;fugitive&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, &lt;code&gt;diff&lt;/code&gt; is a window-local option and some other options are buffer-local. Do I use the same &lt;code&gt;l:&lt;/code&gt; for both of them?&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2017-10-31T09:23:38.613" Title="variable names prefixed with &amp;" Tags="|variables|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14067" PostTypeId="2" ParentId="14066" CreationDate="2017-10-31T09:23:38.613" Score="1" Body="&lt;p&gt;It's the same as &lt;code&gt;setlocal&lt;/code&gt;: it changes a setting for just the current buffer or window, instead of locally. See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Alet-%26&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :let-&amp;amp;&lt;/code&gt;&lt;/a&gt; (after you scroll down a bit) and &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%3Asetlocal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :setlocal&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note: in my experience the easiest way to find stuff in Vim's help pages is to enable the &lt;code&gt;wildmenu&lt;/code&gt; setting and press &lt;code&gt;:help :let&amp;lt;Tab&amp;gt;&lt;/code&gt; to see which pages exist, and then select the most appropriate one (&lt;code&gt;:let-&amp;amp;&lt;/code&gt; in this case). Also see &lt;a href=&quot;https://vi.stackexchange.com/q/2136/51&quot;&gt;How do I navigate to topics in Vim's documentation?&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-10-31T09:23:38.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14068" PostTypeId="2" ParentId="14065" CreationDate="2017-10-31T09:29:14.250" Score="11" Body="&lt;p&gt;The parameter for both the &lt;code&gt;WinEnter&lt;/code&gt; and &lt;code&gt;BufEnter&lt;/code&gt; events are matched against the buffer &lt;em&gt;name&lt;/em&gt;, which is empty for the quickfix window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo bufname('')&#xA;[no output]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can still use the &lt;code&gt;buftype&lt;/code&gt; variable though:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd WinEnter * if &amp;amp;buftype == 'quickfix' | echo 'winenter' | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-10-31T09:29:14.250" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14069" PostTypeId="1" CreationDate="2017-10-31T09:58:01.473" Score="1" ViewCount="2711" Body="&lt;p&gt;Having some text selected in visual mode, I need some way of turning it into a string that can be used in an expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! VisualSelection()&#xA;    normal! `&amp;lt;&quot;&quot;y`&amp;gt;&#xA;    return @&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it works by itself, but when I want to use it in a mapping vim complains because of the &lt;code&gt;normal&lt;/code&gt; command, which, guess what, can't be used in mappings with &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;, so I need some different way of doing this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found out that it is possible to find mark positions with regex like &lt;code&gt;\%'&amp;lt;&lt;/code&gt; and &lt;code&gt;\%'&amp;gt;&lt;/code&gt; but I don't know how to find regex in the file in an expression (&lt;code&gt;match&lt;/code&gt; wants a string, and I haven't found any similar function that searches in the file itself)&lt;/p&gt;&#xA;" OwnerUserId="14920" LastEditorUserId="1841" LastEditDate="2017-10-31T10:56:22.373" LastActivityDate="2017-10-31T11:35:06.630" Title="get string from visual selection" Tags="|vimscript|visual-mode|" AnswerCount="1" CommentCount="2" ClosedDate="2017-10-31T12:51:54.517" ContentLicense="CC BY-SA 3.0" />
  <row Id="14070" PostTypeId="1" AcceptedAnswerId="14092" CreationDate="2017-10-31T10:15:15.287" Score="0" ViewCount="196" Body="&lt;p&gt;i am trying to compile the YouCompleteMe (YCM) plugin on cygwin on windows 10, and every time the compiler fails when linking the ycm_core.dll shared library. I will paste my output in this post, which is a very long output, so to summarize, most of the logs are &quot;reference to undefined 'X'&quot; where X is some boost.python related function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already tried these &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Windows-Installation-Guide-for-Unix%E2%80%90like-Environments&quot; rel=&quot;nofollow noreferrer&quot;&gt;instructions&lt;/a&gt;, in which the specified patch does not exist any more, so i used this &lt;a href=&quot;https://gist.github.com/fatso83/9e48064296c337fd2978&quot; rel=&quot;nofollow noreferrer&quot;&gt;patch&lt;/a&gt; but was unable to install it with the patch command (got &quot;hunk failed&quot; every time).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you to anyone that can help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is my output. Note that the post is limited to 30000 characters and my output is over 120000 characters long, so my entire output did not fit in this post. however, it was more or less the same all the way down (more undefined references).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ./install.py&#xA;Searching Python 2.7 libraries...&#xA;Found Python library: /usr/bin/python2.7&#xA;Found Python headers folder: /usr/include/python2.7&#xA;-- The C compiler identification is GNU 6.4.0&#xA;-- The CXX compiler identification is GNU 6.4.0&#xA;-- Check for working C compiler: /usr/bin/cc&#xA;-- Check for working C compiler: /usr/bin/cc -- works&#xA;-- Detecting C compiler ABI info&#xA;-- Detecting C compiler ABI info - done&#xA;-- Detecting C compile features&#xA;-- Detecting C compile features - done&#xA;-- Check for working CXX compiler: /usr/bin/c++.exe&#xA;-- Check for working CXX compiler: /usr/bin/c++.exe -- works&#xA;-- Detecting CXX compiler ABI info&#xA;-- Detecting CXX compiler ABI info - done&#xA;-- Detecting CXX compile features&#xA;-- Detecting CXX compile features - done&#xA;-- Found PythonLibs: /usr/bin/python2.7 (found suitable version &quot;2.7.13&quot;, minimum required is &quot;2.6&quot;)&#xA;NOT using libclang, no semantic completion for C/C++/ObjC will be available&#xA;-- Configuring done&#xA;-- Generating done&#xA;-- Build files have been written to: /tmp/ycm_build_Gt3KX6&#xA;[67/67] Linking CXX shared library /home/gazran/.vim/plugged/YouCompleteMe/third_party/ycmd/ycm_core.dll&#xA;FAILED: /home/gazran/.vim/plugged/YouCompleteMe/third_party/ycmd/ycm_core.dll ycm/libycm_core.dll.a&#xA;: &amp;amp;&amp;amp; /usr/bin/c++.exe  -O3 -DNDEBUG    -shared -Wl,--enable-auto-import -o /home/gazran/.vim/plugged/YouCompleteMe/third_party/ycmd/ycm_core.dll -Wl,--out-implib,ycm/libycm_core.dll.a -Wl,--major-image-version,0,--minor-image-version,0 ycm/CMakeFiles/ycm_core.dir/Candidate.cpp.o ycm/CMakeFiles/ycm_core.dir/CandidateRepository.cpp.o ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o ycm/CMakeFiles/ycm_core.dir/IdentifierDatabase.cpp.o ycm/CMakeFiles/ycm_core.dir/IdentifierUtils.cpp.o ycm/CMakeFiles/ycm_core.dir/LetterNode.cpp.o ycm/CMakeFiles/ycm_core.dir/LetterNodeListMap.cpp.o ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o ycm/CMakeFiles/ycm_core.dir/Result.cpp.o ycm/CMakeFiles/ycm_core.dir/Utils.cpp.o ycm/CMakeFiles/ycm_core.dir/versioning.cpp.o ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o  BoostParts/libBoostParts.a /usr/bin/python2.7 -lrt &amp;amp;&amp;amp; :&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x28): undefined reference to `PyEval_SaveThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x28): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `PyEval_SaveThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x5a): undefined reference to `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x5a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x92): undefined reference to `PyEval_SaveThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x92): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `PyEval_SaveThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0xc3): undefined reference to `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0xc3): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x260): undefined reference to `PyEval_SaveThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x260): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `PyEval_SaveThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x3df): undefined reference to `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x3df): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x505): undefined reference to `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x505): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x5ff): undefined reference to `PyEval_SaveThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x5ff): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `PyEval_SaveThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x7a3): undefined reference to `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x7a3): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x873): undefined reference to `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x873): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x4f): undefined reference to `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0x4f): additional relocation overflows omitted from the output&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text+0xb8): undefined reference to `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/IdentifierCompleter.cpp.o:IdentifierCompleter.cpp:(.text.startup+0x16): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x28f): undefined reference to `PyEval_CallFunction'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x3b0): undefined reference to `PyEval_CallFunction'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x425): undefined reference to `PyEval_CallFunction'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x591): undefined reference to `PyEval_CallFunction'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x15bc): undefined reference to `PyObject_Size'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x15c6): undefined reference to `PyErr_Occurred'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x15d8): undefined reference to `PyObject_Size'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x15e0): undefined reference to `PyErr_Occurred'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x16db): undefined reference to `PyEval_SaveThread'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x17e3): undefined reference to `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x1841): undefined reference to `PyInt_FromLong'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x1941): undefined reference to `PyLong_FromUnsignedLong'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x1b55): undefined reference to `PyInt_FromLong'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x1c84): undefined reference to `PyInt_FromLong'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text+0x1fbb): undefined reference to `PyEval_RestoreThread'&#xA;ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o:PythonSupport.cpp:(.text.startup+0xe): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text+0x44): undefined reference to `PyEval_InitThreads'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text+0xb43): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFvP7_objectENS0_21default_call_policiesENS_3mpl7vector2IvS6_EEEEEclES6_S6_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFvP7_objectENS0_21default_call_policiesENS_3mpl7vector2IvS6_EEEEEclES6_S6_]+0x11): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python6detail21converter_target_typeINS0_15to_python_valueIRKNS0_4listEEEE10get_pytypeEv[_ZN5boost6python6detail21converter_target_typeINS0_15to_python_valueIRKNS0_4listEEEE10get_pytypeEv]+0x3): undefined reference to `__imp_PyList_Type'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python6detail21converter_target_typeINS0_15to_python_valueIRKbEEE10get_pytypeEv[_ZN5boost6python6detail21converter_target_typeINS0_15to_python_valueIRKbEEE10get_pytypeEv]+0x3): undefined reference to `__imp_PyBool_Type'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python6detail21converter_target_typeINS0_15to_python_valueIRKmEEE10get_pytypeEv[_ZN5boost6python6detail21converter_target_typeINS0_15to_python_valueIRKmEEE10get_pytypeEv]+0x3): undefined reference to `__imp_PyInt_Type'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python6detail21converter_target_typeINS0_15to_python_valueIRKSsEEE10get_pytypeEv[_ZN5boost6python6detail21converter_target_typeINS0_15to_python_valueIRKSsEEE10get_pytypeEv]+0x3): undefined reference to `__imp_PyString_Type'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python6detail21converter_target_typeINS0_15to_python_valueIRKiEEE10get_pytypeEv[_ZN5boost6python6detail21converter_target_typeINS0_15to_python_valueIRKiEEE10get_pytypeEv]+0x3): undefined reference to `__imp_PyInt_Type'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python6detail21converter_target_typeINS0_15to_python_valueIRSsEEE10get_pytypeEv[_ZN5boost6python6detail21converter_target_typeINS0_15to_python_valueIRSsEEE10get_pytypeEv]+0x3): undefined reference to `__imp_PyString_Type'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFbvENS0_21default_call_policiesENS_3mpl7vector1IbEEEEEclEP7_objectSE_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFbvENS0_21default_call_policiesENS_3mpl7vector1IbEEEEEclEP7_objectSE_]+0xf): undefined reference to `PyBool_FromLong'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python9converter22shared_ptr_from_pythonINS0_7objects14iterator_rangeINS0_19return_value_policyINS0_15return_by_valueENS0_21default_call_policiesEEEN9__gnu_cxx17__normal_iteratorIPSsSt6vectorISsSaISsEEEEEENS_10shared_ptrEE11convertibleEP7_object[_ZN5boost6python9converter22shared_ptr_from_pythonINS0_7objects14iterator_rangeINS0_19return_value_policyINS0_15return_by_valueENS0_21default_call_policiesEEEN9__gnu_cxx17__normal_iteratorIPSsSt6vectorISsSaISsEEEEEENS_10shared_ptrEE11convertibleEP7_object]+0x3): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python9converter22shared_ptr_from_pythonINS0_7objects14iterator_rangeINS0_19return_value_policyINS0_15return_by_valueENS0_21default_call_policiesEEEN9__gnu_cxx17__normal_iteratorIPSsSt6vectorISsSaISsEEEEEESt10shared_ptrE11convertibleEP7_object[_ZN5boost6python9converter22shared_ptr_from_pythonINS0_7objects14iterator_rangeINS0_19return_value_policyINS0_15return_by_valueENS0_21default_call_policiesEEEN9__gnu_cxx17__normal_iteratorIPSsSt6vectorISsSaISsEEEEEESt10shared_ptrE11convertibleEP7_object]+0x3): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python9converter22shared_ptr_from_pythonIN13YouCompleteMe19IdentifierCompleterENS_10shared_ptrEE11convertibleEP7_object[_ZN5boost6python9converter22shared_ptr_from_pythonIN13YouCompleteMe19IdentifierCompleterENS_10shared_ptrEE11convertibleEP7_object]+0x3): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python9converter22shared_ptr_from_pythonIN13YouCompleteMe19IdentifierCompleterESt10shared_ptrE11convertibleEP7_object[_ZN5boost6python9converter22shared_ptr_from_pythonIN13YouCompleteMe19IdentifierCompleterESt10shared_ptrE11convertibleEP7_object]+0x3): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python9converter22shared_ptr_from_pythonISt6vectorISsSaISsEENS_10shared_ptrEE11convertibleEP7_object[_ZN5boost6python9converter22shared_ptr_from_pythonISt6vectorISsSaISsEENS_10shared_ptrEE11convertibleEP7_object]+0x3): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python9converter22shared_ptr_from_pythonISt6vectorISsSaISsEESt10shared_ptrE11convertibleEP7_object[_ZN5boost6python9converter22shared_ptr_from_pythonISt6vectorISsSaISsEESt10shared_ptrE11convertibleEP7_object]+0x3): more undefined references to `__imp__Py_NoneStruct' follow&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFivENS0_21default_call_policiesENS_3mpl7vector1IiEEEEEclEP7_objectSE_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFivENS0_21default_call_policiesENS_3mpl7vector1IiEEEEEclEP7_objectSE_]+0xf): undefined reference to `PyInt_FromLong'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFvRSt6vectorISsSaISsEENS0_3api6objectEENS0_21default_call_policiesENS_3mpl7vector3IvS8_SA_EEEEEclEP7_objectSK_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFvRSt6vectorISsSaISsEENS0_3api6objectEENS0_21default_call_policiesENS_3mpl7vector3IvS8_SA_EEEEEclEP7_objectSK_]+0x52): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFbRSt6vectorISsSaISsEEP7_objectENS0_21default_call_policiesENS_3mpl7vector3IbS8_SA_EEEEEclESA_SA_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFbRSt6vectorISsSaISsEEP7_objectENS0_21default_call_policiesENS_3mpl7vector3IbS8_SA_EEEEEclESA_SA_]+0x35): undefined reference to `PyBool_FromLong'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFvRSt6vectorISsSaISsEEP7_objectENS0_21default_call_policiesENS_3mpl7vector3IvS8_SA_EEEEEclESA_SA_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFvRSt6vectorISsSaISsEEP7_objectENS0_21default_call_policiesENS_3mpl7vector3IvS8_SA_EEEEEclESA_SA_]+0x2e): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFvRSt6vectorISsSaISsEEP7_objectSA_ENS0_21default_call_policiesENS_3mpl7vector4IvS8_SA_SA_EEEEEclESA_SA_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFvRSt6vectorISsSaISsEEP7_objectSA_ENS0_21default_call_policiesENS_3mpl7vector4IvS8_SA_SA_EEEEEclESA_SA_]+0x32): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFmRSt6vectorISsSaISsEEENS0_21default_call_policiesENS_3mpl7vector2ImS8_EEEEEclEP7_objectSI_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFmRSt6vectorISsSaISsEEENS0_21default_call_policiesENS_3mpl7vector2ImS8_EEEEEclEP7_objectSI_]+0x31): undefined reference to `PyInt_FromLong'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFmRSt6vectorISsSaISsEEENS0_21default_call_policiesENS_3mpl7vector2ImS8_EEEEEclEP7_objectSI_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFmRSt6vectorISsSaISsEEENS0_21default_call_policiesENS_3mpl7vector2ImS8_EEEEEclEP7_objectSI_]+0x3b): undefined reference to `PyLong_FromUnsignedLong'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python9converter21as_to_python_functionINS0_7objects14iterator_rangeINS0_19return_value_policyINS0_15return_by_valueENS0_21default_call_policiesEEEN9__gnu_cxx17__normal_iteratorIPSsSt6vectorISsSaISsEEEEEENS3_18class_cref_wrapperISG_NS3_13make_instanceISG_NS3_12value_holderISG_EEEEEEE7convertEPKv[_ZN5boost6python9converter21as_to_python_functionINS0_7objects14iterator_rangeINS0_19return_value_policyINS0_15return_by_valueENS0_21default_call_policiesEEEN9__gnu_cxx17__normal_iteratorIPSsSt6vectorISsSaISsEEEEEENS3_18class_cref_wrapperISG_NS3_13make_instanceISG_NS3_12value_holderISG_EEEEEEE7convertEPKv]+0x84): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerINS1_14iterator_rangeINS0_19return_value_policyINS0_15return_by_valueENS0_21default_call_policiesEEEN9__gnu_cxx17__normal_iteratorIPSsSt6vectorISsSaISsEEEEE4nextES9_NS_3mpl7vector2IRSsRSH_EEEEEclEP7_objectSR_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerINS1_14iterator_rangeINS0_19return_value_policyINS0_15return_by_valueENS0_21default_call_policiesEEEN9__gnu_cxx17__normal_iteratorIPSsSt6vectorISsSaISsEEEEE4nextES9_NS_3mpl7vector2IRSsRSH_EEEEEclEP7_objectSR_]+0x37): undefined reference to `PyString_FromStringAndSize'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFSsRKNS0_3api6objectEENS0_21default_call_policiesENS_3mpl7vector2ISsS8_EEEEEclEP7_objectSI_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFSsRKNS0_3api6objectEENS0_21default_call_policiesENS_3mpl7vector2ISsS8_EEEEEclEP7_objectSI_]+0x2d): undefined reference to `PyString_FromStringAndSize'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object]+0x13): undefined reference to `__imp_PySlice_Type'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object]+0x141): undefined reference to `__imp_PyExc_IndexError'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object]+0x150): undefined reference to `PyErr_SetString'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object]+0x173): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object]+0x180): undefined reference to `__imp_PyExc_IndexError'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object]+0x18f): undefined reference to `PyErr_SetString'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object]+0x382): undefined reference to `__imp_PyExc_TypeError'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE16base_delete_itemERS4_P7_object]+0x391): undefined reference to `PyErr_SetString'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFNS0_4listERKS5_RKSsS9_mENS0_21default_call_policiesENS_3mpl7vector5IS5_S7_S9_S9_mEEEEEclEP7_objectSJ_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFNS0_4listERKS5_RKSsS9_mENS0_21default_call_policiesENS_3mpl7vector5IS5_S7_S9_S9_mEEEEEclEP7_objectSJ_]+0x1c): undefined reference to `__imp_PyList_Type'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFNS0_4listERKS5_RKSsS9_mENS0_21default_call_policiesENS_3mpl7vector5IS5_S7_S9_S9_mEEEEEclEP7_objectSJ_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFNS0_4listERKS5_RKSsS9_mENS0_21default_call_policiesENS_3mpl7vector5IS5_S7_S9_S9_mEEEEEclEP7_objectSJ_]+0x2a): undefined reference to `PyObject_IsInstance'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFNS0_4listERKS5_RKSsS9_ENS0_21default_call_policiesENS_3mpl7vector4IS5_S7_S9_S9_EEEEEclEP7_objectSJ_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFNS0_4listERKS5_RKSsS9_ENS0_21default_call_policiesENS_3mpl7vector4IS5_S7_S9_S9_EEEEEclEP7_objectSJ_]+0x1c): undefined reference to `__imp_PyList_Type'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFNS0_4listERKS5_RKSsS9_ENS0_21default_call_policiesENS_3mpl7vector4IS5_S7_S9_S9_EEEEEclEP7_objectSJ_[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFNS0_4listERKS5_RKSsS9_ENS0_21default_call_policiesENS_3mpl7vector4IS5_S7_S9_S9_EEEEEclEP7_objectSJ_]+0x2a): undefined reference to `PyObject_IsInstance'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python9converter21as_to_python_functionISt10shared_ptrISt6vectorISsSaISsEEENS0_7objects19class_value_wrapperIS7_NS8_17make_ptr_instanceIS6_NS8_14pointer_holderIS7_S6_EEEEEEE7convertEPKv[_ZN5boost6python9converter21as_to_python_functionISt10shared_ptrISt6vectorISsSaISsEEENS0_7objects19class_value_wrapperIS7_NS8_17make_ptr_instanceIS6_NS8_14pointer_holderIS7_S6_EEEEEEE7convertEPKv]+0x86): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object]+0x13): undefined reference to `__imp_PySlice_Type'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object]+0xc3): undefined reference to `PyString_FromStringAndSize'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object]+0x10d): undefined reference to `__imp_PyExc_IndexError'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object]+0x11c): undefined reference to `PyErr_SetString'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object]+0x143): undefined reference to `__imp__Py_NoneStruct'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object]+0x154): undefined reference to `__imp_PyExc_IndexError'&#xA;ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o:ycm_core.cpp:(.text$_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object[_ZN5boost6python14indexing_suiteISt6vectorISsSaISsEENS0_6detail29final_vector_derived_policiesIS4_Lb0EEELb0ELb0ESsmSsE13base_get_itemENS0_14back_referenceIRS4_EEP7_object]+0x163): undefined reference to `PyErr_SetString'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14919" LastActivityDate="2017-11-02T08:50:36.493" Title="Unable to link ycm_core.dll when compiling YCM" Tags="|plugin-you-complete-me|cygwin|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14071" PostTypeId="2" ParentId="14051" CreationDate="2017-10-31T10:18:41.310" Score="0" Body="&lt;p&gt;I haven't thought this 100% through, but maybe you could look into it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why not do a chain of autocomands, where &lt;code&gt;BufWinEnter&lt;/code&gt; adds a &lt;code&gt;WinEnter&lt;/code&gt; autocommand, which in turn changes &lt;code&gt;directory&lt;/code&gt; and stores the original value in a buffer-local variable, and a &lt;code&gt;WinLeave&lt;/code&gt; aoutocommand that changes it back, and a &lt;code&gt;BufWinLeave&lt;/code&gt; au. that removes the previous two? It's kind of a mess, but if you do it right, it should work well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(please tell me if this needs further explaining)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I just realized this depends on whether or not vim cares about swap files of bufers you aren't currently editing, so it really comes down to testing. If you're willing to spend the, I don't know, probably no more than 30 minutes to try it, please be sure to tell us if it works :)&lt;/p&gt;&#xA;" OwnerUserId="14920" LastActivityDate="2017-10-31T10:18:41.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14072" PostTypeId="2" ParentId="14069" CreationDate="2017-10-31T11:35:06.630" Score="4" Body="&lt;p&gt;Your question is a duplicate of &lt;a href=&quot;https://stackoverflow.com/questions/1533565/how-to-get-visually-selected-text-in-vimscript&quot;&gt;https://stackoverflow.com/questions/1533565/how-to-get-visually-selected-text-in-vimscript&lt;/a&gt; on SO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two solutions, plus many variations, have been provided and discussed.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;One based on manual decoding on text in between &lt;code&gt;getpos()&lt;/code&gt; results, &lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and the traditional one based on &lt;code&gt;normal! gv&quot;ay&lt;/code&gt;, with restoration of register and so on.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! lh#visual#selection() abort&#xA;  try&#xA;    let a_save = @a&#xA;    silent! normal! gv&quot;ay&#xA;    return @a&#xA;  finally&#xA;    let @a = a_save&#xA;  endtry&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-10-31T11:35:06.630" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14073" PostTypeId="1" AcceptedAnswerId="14075" CreationDate="2017-10-31T13:45:40.803" Score="0" ViewCount="1855" Body="&lt;p&gt;I'm using vim for scripting and configs and noticed that I sometimes forget to open file with &lt;code&gt;sudo&lt;/code&gt; and therefore when I made some editings I got the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E45: 'readonly' option is set (add ! to override)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I have to exit and make all the edits I just made for scratch. This is very annoying. Is there a way to approach it? Maybe I can switch from readonly mode without exiting vim?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2017-10-31T14:22:43.520" Title="Vim is in read-only mode" Tags="|vimrc|insert-mode|normal-mode|" AnswerCount="2" CommentCount="0" ClosedDate="2017-10-31T14:54:25.927" ContentLicense="CC BY-SA 3.0" />
  <row Id="14074" PostTypeId="1" AcceptedAnswerId="14738" CreationDate="2017-10-31T14:16:31.160" Score="4" ViewCount="613" Body="&lt;p&gt;&lt;code&gt;:h manpager&lt;/code&gt; describes how to use vim as a manpager:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Works on:&#xA;&#xA;  - Linux&#xA;  - Mac OS&#xA;  - FreeBSD&#xA;  - Cygwin&#xA;  - Win 10 under Bash&#xA;&#xA;Untested:&#xA;&#xA;  - Amiga OS&#xA;  - BeOS&#xA;  - OS/2&#xA;&#xA;For bash,zsh,ksh or dash by adding to the config file (.bashrc,.zshrc, ...)&#xA;&#xA;    export MANPAGER=&quot;env MAN_PN=1 vim -M +MANPAGER -&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The line above works for me on Linux (Debian 9.2), but the same setting on a Mac (10.11 El Capitan) causes the following error every time I invoke &lt;code&gt;man&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;57_MANPAGER:&#xA;line   16:&#xA;E684: list index out of range: 2&#xA;E15: Invalid expression: page_sec[2] page_sec[1]&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Question 1: Is this a bug?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Should I file a bug report with vim?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; This appears to be a bug in the &lt;code&gt;$VIMRUNTIME/plugin/manpager.vim&lt;/code&gt; plugin. Line 18 reads:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let manpage = matchstr( getline(1), '^' . pagesec_pattern )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;It can be fixed by replacing &lt;code&gt;getline(1)&lt;/code&gt; with &lt;code&gt;getline(nextnonblank(1))&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h3&gt;Question 2: Is there a workaround?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I've found alternate settings for the &lt;code&gt;MANPAGER&lt;/code&gt; environment variable on &lt;a href=&quot;https://www.reddit.com/r/vim/comments/4xkyah/til_builtin_man_pager_in_vim/d6giyzp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;/r/vim&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/a/4687/2593&quot;&gt;this StackExchange&lt;/a&gt; that make it work on macOS, but both of them cause navigation via &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; to break and give the folllowing output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sh: -c: line 0: syntax error near unexpected token `||'&#xA;sh: -c: line 0: `(cd '/usr/share/man' &amp;amp;&amp;amp; (echo &quot;.ll 12.1i&quot;; echo &quot;.nr LL 12.1i&quot;; /bin/cat '/usr/share/man/man1/vimtutor.1') | /usr/bin/tbl | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c | ( || true))'&#xA;Error executing formatting or display command.&#xA;System command (cd '/usr/share/man' &amp;amp;&amp;amp; (echo &quot;.ll 12.1i&quot;; echo &quot;.nr LL 12.1i&quot;; /bin/cat '/usr/share/man/man1/vimtutor.1') | /usr/bin/tbl | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c | ( || true)) exited with status 512.&#xA;No entry for vimtutor in section 1 of the manual&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Even with the fix described above, I'm continuing to get this error when navigating between man pages. It looks like it's being caused by the &lt;code&gt;( || true)&lt;/code&gt; statement in the shell command, but I'm not sure where that shell command is being invoked from.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Does anyone know of a fully working solution?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Running vim 8.0.596&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May  8 2017 15:44:54)&#xA;MacOS X (unix) version&#xA;Included patches: 1-596&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2593" LastEditorUserId="4472" LastEditDate="2022-07-21T20:54:51.317" LastActivityDate="2022-07-21T20:54:51.317" Title="Using vim as manpager: works on Linux, fails on macOS" Tags="|linux|macos|bash|manpages|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14075" PostTypeId="2" ParentId="14073" CreationDate="2017-10-31T14:17:18.860" Score="1" Body="&lt;p&gt;You need the &lt;a href=&quot;https://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work&quot;&gt;write with sudo&lt;/a&gt; trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !sudo tee %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also @ChristianBrabandt's &lt;a href=&quot;http://github.com/chrisbra/SudoEdit.vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SudoEdit plugin&lt;/a&gt; which also works on Windows and supports undofiles.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-10-31T14:22:43.520" LastActivityDate="2017-10-31T14:22:43.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14076" PostTypeId="2" ParentId="14073" CreationDate="2017-10-31T14:22:00.800" Score="1" Body="&lt;p&gt;you could reset the readonly option with &lt;code&gt;:set noro&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the underlying problem in your case is access-right.&#xA;As a normal user you (and vim) cannot write a root-file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To save your changes with root-permission you can try :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:w !sudo tee % &amp;gt; /dev/null&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-10-31T14:22:00.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14077" PostTypeId="1" AcceptedAnswerId="14082" CreationDate="2017-10-31T19:17:37.330" Score="6" ViewCount="4190" Body="&lt;p&gt;Using &lt;code&gt;]p&lt;/code&gt; in normal mode, I can paste a yanked line of text on a new line below the cursor with indentation equal to the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;code&gt;:put&lt;/code&gt; command, I can paste a yanked word as if it were a whole line, but the indentation seems to default &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to combine these two? I'm looking to be able to yank an individual word and paste it below the current line with indentation equivalent to the current line. I'm aware &lt;code&gt;:put&amp;lt;ENTER&amp;gt;==&lt;/code&gt; would likely work, but that's slightly awkward.&lt;/p&gt;&#xA;" OwnerUserId="14924" LastActivityDate="2023-11-17T13:47:02.670" Title="Paste word on new line with indentation from current line" Tags="|indentation|cut-copy-paste|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14078" PostTypeId="2" ParentId="14077" CreationDate="2017-10-31T20:14:21.043" Score="5" Body="&lt;p&gt;Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;noreferrer&quot;&gt;unimpaired.vim&lt;/a&gt; provides &lt;code&gt;[p&lt;/code&gt;/&lt;code&gt;]p&lt;/code&gt; variants which force these commands to be line-wise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If don't want to use unimpaired then you will need to cast the register as line-wise and then restore type afterwards. Here is are some mappings that are directly taken from unimaired.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:put(cmd)&#xA;  let [body, type] = [getreg(v:register), getregtype(v:register)]&#xA;  call setreg(v:register, body, 'l')&#xA;  exe 'normal! &quot;'.v:register.a:cmd&#xA;  call setreg(v:register, body, type)&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; ]p :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;put(']p')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; [p :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;put('[p')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-10-31T20:14:21.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14079" PostTypeId="1" AcceptedAnswerId="17229" CreationDate="2017-11-01T03:05:50.370" Score="1" ViewCount="834" Body="&lt;p&gt;I run &lt;code&gt;Glog!&lt;/code&gt; from &lt;code&gt;fugitive&lt;/code&gt; to populate the quickfix window and set the following autocmd for &lt;code&gt;QuickFixCmdPost&lt;/code&gt; (The following questions general and are not specific to &lt;code&gt;Glog&lt;/code&gt;, I just use it as example)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd QuickFixCmdPost * call func()&#xA;&#xA;function func()&#xA;    echomsg 'quickfix: ' . w:quickfix_title&#xA;    botright cwindow&#xA;    if w:quickfix_title =~ 'git.*log'&#xA;        nnoremap &amp;lt;buffer&amp;gt; v &amp;lt;c-w&amp;gt;&amp;lt;cr&amp;gt;&amp;lt;C-w&amp;gt;L&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to doc (&lt;code&gt;:h w:quickfix_title&lt;/code&gt;) &lt;code&gt;w:quickfix_title&lt;/code&gt; is supposed to contain the command used, which is something like &lt;code&gt;:git --git-dir=.git --no-pager log --no-color&lt;/code&gt; set by &lt;code&gt;fugitive&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, after running &lt;code&gt;Glog&lt;/code&gt;, the &lt;code&gt;func()&lt;/code&gt; is called and &lt;code&gt;w:quickfix_title&lt;/code&gt; is always empty. But the quickfix window's statusline still displays the title correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the problem here? It seems that &lt;code&gt;w:quickfix_title&lt;/code&gt; is not set before the autocmd finishes. Calling &lt;code&gt;:cwindow&lt;/code&gt; to open the window does not get it set immediately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A few more questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Accoring to &lt;code&gt;:h QuickFixCmdPre&lt;/code&gt;, the pattern is matched against the command being run, such as &lt;code&gt;:grep&lt;/code&gt;, &lt;code&gt;:lgrep&lt;/code&gt;, etc. If I run &lt;code&gt;:grep abcdefg&lt;/code&gt;, is that &lt;code&gt;abcdefg&lt;/code&gt; part of the command and can be used as pattern? If yes, I know that &lt;code&gt;Glog&lt;/code&gt; contains &lt;code&gt;git.*log&lt;/code&gt; in its command, can I use this as the pattern instead of putting the &lt;code&gt;if&lt;/code&gt; condition in &lt;code&gt;func&lt;/code&gt;, i.e. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd QuickFixCmdPost git*log call func()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If before running &lt;code&gt;Glog&lt;/code&gt; the quickfix window is not open, the following autocmds are not triggered (even if I call &lt;code&gt;cwindow&lt;/code&gt; explicitly in &lt;code&gt;func&lt;/code&gt;): &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;BufEnter&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;WinEnter&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;BufWinEnter&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, if the quickfix window is already open, &lt;code&gt;BufWinEnter&lt;/code&gt; is trigged. What is the reason for this?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;What is the correct way to set up some maps in quickfix window after &lt;code&gt;Glog&lt;/code&gt; is run&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-08-31T02:56:39.633" Title="QuickFixCmdPost autocommand after Glog" Tags="|autocmd|quickfix|plugin-fugitive|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14080" PostTypeId="1" AcceptedAnswerId="14083" CreationDate="2017-11-01T05:23:44.703" Score="2" ViewCount="476" Body="&lt;p&gt;I want to use &lt;code&gt;&amp;lt;C-S-v&amp;gt;&lt;/code&gt; to block visual selection and &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; to paste. And I have the following mapping in the &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; block visual selection&#xA;nnoremap &amp;lt;C-S-v&amp;gt; &amp;lt;c-v&amp;gt;&#xA;&#xA;&quot; paste&#xA;map &amp;lt;C-v&amp;gt; &quot;+gp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the latter seems to override the former. Can anyone help to get it right.&lt;/p&gt;&#xA;" OwnerUserId="12223" LastEditorUserId="12223" LastEditDate="2017-11-01T06:08:12.570" LastActivityDate="2017-11-01T13:18:13.773" Title="Key binding conflict of paste and rectangular blocks select" Tags="|vimrc|key-bindings|" AnswerCount="2" CommentCount="0" ClosedDate="2017-11-02T08:17:58.543" ContentLicense="CC BY-SA 3.0" />
  <row Id="14081" PostTypeId="2" ParentId="14080" CreationDate="2017-11-01T08:34:15.647" Score="2" Body="&lt;p&gt;In insert mode, without any of those mappings, try entering &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; followed by &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;. Now try &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; followed by &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;. Do you see &lt;code&gt;^V&lt;/code&gt; in both cases? Vim doesn't treat the two key-presses as distinct...so you're out of luck. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know control-shift is never a reliable key-combo for use in mappings. Or, to paraphrase &lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-20.5&quot; rel=&quot;nofollow noreferrer&quot;&gt;FAQ 20.5&lt;/a&gt;, Vim can't reliably detect any control characters except those defined by the ASCII standard:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Ctrl-@                 0x00            NUL&#xA;    Ctrl-A to Ctrl-Z       0x01 to 0x1A&#xA;    Ctrl-a to Ctrl-z       0x01 to 0x1A&#xA;    Ctrl-[                 0x1B            ESC&#xA;    Ctrl-\                 0x1C&#xA;    Ctrl-]                 0x1D&#xA;    Ctrl-^                 0x1E&#xA;    Ctrl-_                 0x1F&#xA;    Ctrl-?                 0x7F            DEL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the 2nd and 3rd lines showing identical codes for lower/upper case and no mention of Shift beyond that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the linked FAQ section for a bit more info on the topic including map key recommendations.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-11-01T11:36:10.847" LastActivityDate="2017-11-01T11:36:10.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14082" PostTypeId="2" ParentId="14077" CreationDate="2017-11-01T09:51:19.413" Score="4" Body="&lt;h1&gt;Option 1&lt;/h1&gt;&#xA;&lt;p&gt;you can just do &lt;code&gt;o&amp;lt;esc&amp;gt;p&lt;/code&gt; to&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;make a new line below the current one&lt;/li&gt;&#xA;&lt;li&gt;exit insert mode without removing the auto-indentation (as opposed to &lt;/li&gt;&#xA;&lt;li&gt;paste the word at the cursor position&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Just map that to something like ]P or whatever.&lt;/p&gt;&#xA;&lt;h1&gt;Option 2&lt;/h1&gt;&#xA;&lt;p&gt;You can remap ]p to add a line-break at the end if there isn't one already&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; ]p :let original=@*&amp;lt;CR&amp;gt;:let @* = substitute(@*, &amp;quot;\\n\\?$&amp;quot;, &amp;quot;\n&amp;quot;, &amp;quot;&amp;quot;)&amp;lt;CR&amp;gt;]p:let @*=original&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;h3&gt;How does this work?&lt;/h3&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Save the current value of register &lt;code&gt;*&lt;/code&gt; into the variable &lt;code&gt;original&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Substitute the empty match at the end of the string and optionally a single preceding newline with a newline in the string in register &lt;code&gt;*&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Save the modified string into the register.&lt;/li&gt;&#xA;&lt;li&gt;Perform the original &lt;code&gt;]p&lt;/code&gt; action (because &lt;code&gt;nNOREmap&lt;/code&gt; was used)&lt;/li&gt;&#xA;&lt;li&gt;restore the original value of the &lt;code&gt;*&lt;/code&gt; register from the variable&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Note that your vim may not use the register &lt;code&gt;*&lt;/code&gt; for the clipboard; if the property &lt;code&gt;clipboard&lt;/code&gt; (:help 'clipboard') is not set, vim uses the register &lt;code&gt;&amp;quot;&lt;/code&gt;, on linux it may use &lt;code&gt;+&lt;/code&gt;. In those cases you'd have to modify the mapping accordingly.&lt;/p&gt;&#xA;&lt;h1&gt;Option 3&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ]p :let [content, type] =&#xA;    \ [getreg(v:register), getregtype(v:register)] \|&#xA;    \ call setreg(v:register, content, &amp;quot;V&amp;quot;)&amp;lt;CR&amp;gt;]p&#xA;    \:call setreg(v:register, content, type)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This should be even more universal than option 2, though also a bit longer and uses more functions that may seem unfamiliar to new users.&lt;/p&gt;&#xA;&lt;p&gt;What it does is:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Save the content and type of the register that vim uses for yank/put operations (&lt;code&gt;:help v:register&lt;/code&gt;) into the variables &lt;code&gt;content&lt;/code&gt; and &lt;code&gt;type&lt;/code&gt; (&lt;code&gt;:help let-unpack&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Set the register to its previous text, but with mode &lt;code&gt;&amp;quot;V&amp;quot;&lt;/code&gt; (line-wise)&lt;/li&gt;&#xA;&lt;li&gt;Do the default &lt;code&gt;]p&lt;/code&gt; operation&lt;/li&gt;&#xA;&lt;li&gt;Reset the register to its original mode&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;P.S.: I'm adding option 3 to my own vimrc now :)&lt;/p&gt;&#xA;" OwnerUserId="14920" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-11-01T10:22:30.040" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14083" PostTypeId="2" ParentId="14080" CreationDate="2017-11-01T10:10:28.030" Score="4" Body="&lt;p&gt;Historically, this behaviour was caused by the underlying terminal implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you press the &lt;kbd&gt;V&lt;/kbd&gt; key, the terminal sends the ASCII code &lt;strong&gt;118&lt;/strong&gt;, and when you press &lt;kbd&gt;Shift-V&lt;/kbd&gt;, the terminal sends the ASCII code &lt;strong&gt;86&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;kbd&gt;Ctrl&lt;/kbd&gt; key was used for sending control characters, and it worked by clearing the 6th and 7th bits of any other keys pressed while it was held down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we convert the ASCII codes into binary, it's easier to see what's happening:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;V&lt;/kbd&gt; &lt;strong&gt;86&lt;/strong&gt; → 1010110&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Shift-V&lt;/kbd&gt; &lt;strong&gt;118&lt;/strong&gt; → 1110110&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-V&lt;/kbd&gt; &lt;strong&gt;xx&lt;/strong&gt;10110 → 0010110 → &lt;strong&gt;22&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-Shift-V&lt;/kbd&gt; &lt;strong&gt;xx&lt;/strong&gt;10110 → 0010110 → &lt;strong&gt;22&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The codes sent to Vim are identical!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is therefore &lt;em&gt;impossible&lt;/em&gt; for terminal Vim to distinguish &lt;kbd&gt;Ctrl-Shift-V&lt;/kbd&gt; from &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;.&lt;sup&gt;*&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;gVim uses the same underlying code for handling key-presses, and although it can handle some things that terminal Vim cannot, distinguishing between &lt;kbd&gt;Ctrl+Shift&lt;/kbd&gt; and unshifted &lt;kbd&gt;Ctrl&lt;/kbd&gt; is not one of these.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can work around this in some terminals by configuring them to send a different keycode when you press certain key combinations and then mapping these keycodes in Vim, but such terminal configuration is outside the scope of this site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more detailed explanation of the issue, along with other terminal quirks, can be found here: &lt;a href=&quot;https://catern.com/posts/terminal_quirks.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Terminals are Weird&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;*: There have been more recent developments that enable this, but so far, &lt;a href=&quot;https://groups.google.com/forum/#!msg/vim_dev/2bp9UdfZ63M/sajb9KM0pNYJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;these have not been incorporated into Vim and there are no concrete plans to do so&lt;/a&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-01T13:18:13.773" LastActivityDate="2017-11-01T13:18:13.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14084" PostTypeId="1" CreationDate="2017-11-01T13:08:41.080" Score="1" ViewCount="160" Body="&lt;p&gt;I am trying to write a syntax file (.vim) to hightlight in 2 colour format whenever timestamp at the beginning of the line changes.&#xA;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1:00 - start&#xA;1:00 - wait for event&#xA;2:00 - wait for event&#xA;3:00 - wait for event&#xA;3:00 - wait timedout&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to highlight first two line in grey colour, and switch to which when time change from 1:00 to 2:00 for line 3, and change back to grey at 3:00 for  line 4 and 5.&#xA;Any one got an idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="14935" LastEditorUserId="343" LastEditDate="2017-11-02T11:03:19.207" LastActivityDate="2017-11-02T13:33:11.160" Title="vim syntax highlight for change of pattern" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14085" PostTypeId="2" ParentId="14079" CreationDate="2017-11-01T15:09:30.013" Score="2" Body="&lt;p&gt;&lt;code&gt;w:quickfix_title&lt;/code&gt; is a window-local variable (&lt;code&gt;w:&lt;/code&gt; part). This means &lt;code&gt;w:quickfix_title&lt;/code&gt; will only available after the quickfix window is opened and is focused. This means &lt;code&gt;echomsg w:quickfix_title&lt;/code&gt; will not show the quickfix title reliably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However your first method should work. I checked it and it worked for me after adjusting your function name. You can check for your mapping via &lt;code&gt;nnmap v&lt;/code&gt; while you are in the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This sort of works however once the mapping is created then it is not properly cleared if the quickfix list changes. It would be better to always have a quickfix window mapping and have a conditional on the mapping itself.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup My_qf&#xA;  autocmd!&#xA;  autocmd FileType qf nnoremap &amp;lt;expr&amp;gt; &amp;lt;buffer&amp;gt; v getqflist({'title':1}).title =~ 'git.*log' ? \&quot;&amp;lt;c-w&amp;gt;\&amp;lt;cr&amp;gt;\&amp;lt;c-w&amp;gt;L&quot; : &quot;v&quot;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may decide every quickfix window should have this mapping for consistency then the conditional would not be needed so you would end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup My_qf&#xA;  autocmd!&#xA;  autocmd FileType qf nnoremap  &amp;lt;buffer&amp;gt; v &amp;lt;c-w&amp;gt;\&amp;lt;cr&amp;gt;\&amp;lt;c-w&amp;gt;L&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h QuickFixCmdPost&#xA;:h CTRL-W_&amp;lt;Enter&amp;gt;&#xA;:h getqflist()&#xA;:h w:&#xA;:h w:quickfix_title&#xA;:h :map-expression&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-11-02T14:26:39.067" LastActivityDate="2017-11-02T14:26:39.067" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14086" PostTypeId="1" AcceptedAnswerId="14087" CreationDate="2017-11-01T17:14:43.680" Score="3" ViewCount="417" Body="&lt;p&gt;I have this mapping to move by visible line when wrap is enabled&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; j gj&#xA;nnoremap &amp;lt;silent&amp;gt; k gk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I use a count (like &lt;code&gt;10 j&lt;/code&gt;), I expect to move by actual lines&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to make something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; j (moving_with_repeat ? j : gj)&#xA;nnoremap &amp;lt;silent&amp;gt; k (moving_with_repeat ? k : gk)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11273" LastEditorUserId="343" LastEditDate="2017-12-06T11:26:51.730" LastActivityDate="2017-12-06T11:26:51.730" Title="How can a mapping have behavior dependent on the presence of a count?" Tags="|key-bindings|cursor-movement|count|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14087" PostTypeId="2" ParentId="14086" CreationDate="2017-11-01T17:23:27.467" Score="10" Body="&lt;p&gt;You can use expression maps and Vim's predefined &lt;code&gt;v:count&lt;/code&gt; variable to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; j v:count &amp;gt; 1 ? &quot;j&quot; : &quot;gj&quot;&#xA;nnoremap &amp;lt;expr&amp;gt; k v:count &amp;gt; 1 ? &quot;k&quot; : &quot;gk&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This checks the count and then performs the desired operation.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Further reading&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :map-expression&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help v:count&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help expr1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-03T14:45:19.960" LastActivityDate="2017-11-03T14:45:19.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14088" PostTypeId="1" AcceptedAnswerId="14096" CreationDate="2017-11-02T02:09:23.173" Score="0" ViewCount="224" Body="&lt;p&gt;I am using Vim 7.4 in Windows 7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to map &lt;kbd&gt;F2&lt;/kbd&gt; to the following ex-command,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal ggf\&amp;lt;tab&amp;gt;&quot;| execute &quot;normal \&amp;lt;c-q&amp;gt;G$d&quot;| %s/ \+//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;using the following mapping command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap &amp;lt;F2&amp;gt; :execute &quot;normal ggf\&amp;lt;tab&amp;gt;&quot; \| execute &quot;normal \&amp;lt;c-q&amp;gt;G$d&quot; \| :%s/ \+//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when I press &lt;kbd&gt;F2&lt;/kbd&gt;, the following shows up  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;:execute &quot;normal ggf\^I&quot; | execute &quot;normal \G$d&quot; |%s/ \+//g&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; changes to &lt;code&gt;^I&lt;/code&gt; and &lt;code&gt;&amp;lt;c-q&amp;gt;&lt;/code&gt; disappears. How can I prevent&#xA;those changes to execute the original ex-command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;&amp;lt;c-q&amp;gt;&lt;/code&gt; is the default visual block selection in Vim 7.4 in Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Input and the result,&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Tghcr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tghcr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see the image below &lt;code&gt;&amp;lt;c-q&amp;gt;&lt;/code&gt; disappears,&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Jmb3V.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Jmb3V.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12103" LastEditorUserId="12103" LastEditDate="2017-11-02T11:16:42.110" LastActivityDate="2017-11-02T11:25:51.250" Title="Missing &lt;c-q&gt; when mapping Ex Command" Tags="|key-bindings|gvim|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14089" PostTypeId="1" AcceptedAnswerId="14184" CreationDate="2017-11-02T02:42:12.990" Score="1" ViewCount="1279" Body="&lt;p&gt;I installed UltiSnips with Vundle by placing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'SirVer/ultisnips'¬&#xA;Plugin 'honza/vim-snippets'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;.vimrc&lt;/code&gt; as well as this as it says in the readme&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;c-b&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-z&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I installed the plugin with &lt;code&gt;:PluginInstall&lt;/code&gt; and after restarting vim I can see that the plugin is installed by &lt;code&gt;:UltiSnipsEdit&lt;/code&gt; which opens a new window to add snippets. I added a basic example and save the file which is saved to the project directory in &lt;code&gt;./UltiSnips/html.snippets&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet nn&#xA;&amp;lt;header class=&quot;main-header&quot;&amp;gt;&amp;lt;/header&amp;gt;&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I expect &lt;code&gt;nn&lt;/code&gt; to expand into my snippet content after writing it and hitting tab key. However, it did not happen. I tried disabling other plugins that I have installed and mapping expand trigger to a different key / keys but that did not work either. Is there something I am missing here?&lt;/p&gt;&#xA;" OwnerUserId="14948" LastActivityDate="2017-11-13T11:42:32.887" Title="UltiSnips does not map to ExpandsTrigger" Tags="|key-bindings|plugin-ultisnips|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="14090" PostTypeId="1" CreationDate="2017-11-02T05:49:24.013" Score="3" ViewCount="7548" Body="&lt;p&gt;I pressed &lt;code&gt;:wq&lt;/code&gt; to write and quit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Except now I see a &lt;code&gt;Command Line&lt;/code&gt; at the bottom and nothing I do makes &lt;code&gt;vi&lt;/code&gt; respond (&lt;kbd&gt;Enter&lt;/kbd&gt;, &lt;kbd&gt;Esc&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt;, &lt;kbd&gt;:&lt;/kbd&gt;, &lt;kbd&gt;q&lt;/kbd&gt;, etc.). How do I get back to civilisation from here? If you can save my file at the same time, bonus! Otherwise, I'll try editing it again... if I can ever exit!&lt;/p&gt;&#xA;" OwnerUserId="14950" LastEditorUserId="51" LastEditDate="2017-11-02T13:07:43.777" LastActivityDate="2022-02-15T15:01:43.680" Title="I'm stuck in Vim; I see &quot;Command Line&quot; at the bottom and nothing makes Vim respond" Tags="|command-line|quit|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14091" PostTypeId="2" ParentId="11302" CreationDate="2017-11-02T06:02:06.040" Score="3" Body="&lt;p&gt;You can use &lt;kbd&gt;fn&lt;/kbd&gt; to bypass Mouse Reporting for programs like vim. (i.e. do &lt;kbd&gt;fn&lt;/kbd&gt;+&lt;kbd&gt;left-mouse button&lt;/kbd&gt; to clear the selection.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://superuser.com/questions/125102/mac-os-x-terminal-mouse-support/985865#985865&quot;&gt;https://superuser.com/questions/125102/mac-os-x-terminal-mouse-support/985865#985865&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If you are not using a Mac and you are having a similar issue, you can use &lt;kbd&gt;ctrl-z&lt;/kbd&gt; to suspend vim. Once you are done doing whatever, execute the &lt;code&gt;fg&lt;/code&gt; command to bring vim back up.)&lt;/p&gt;&#xA;" OwnerUserId="14952" LastEditorUserId="14952" LastEditDate="2017-11-02T06:09:26.390" LastActivityDate="2017-11-02T06:09:26.390" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14092" PostTypeId="2" ParentId="14070" CreationDate="2017-11-02T08:50:36.493" Score="0" Body="&lt;p&gt;Thanks to &lt;a href=&quot;https://vi.stackexchange.com/users/1841/statox&quot;&gt;@statox&lt;/a&gt;, I went to check out this &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue tracker&lt;/a&gt;. This in turn led me to YouCompleteMe's CONTRIBUTIND.md document which then sent me to gitter where there is a community chat room for questions about many topics, including YCM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The build was getting the python library from /usr/bin/python2.7 instead of /usr/lib/libpython2.7.dll.a. to fix this, go to ~/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py and change the FindPythonLibraries() function to the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def FindPythonLibraries():&#xA;    return[&quot;/usr/lib/libpython2.7.dll.a&quot;, &quot;/usr/include/python2.7&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14919" LastActivityDate="2017-11-02T08:50:36.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14093" PostTypeId="1" AcceptedAnswerId="14095" CreationDate="2017-11-02T09:19:29.917" Score="0" ViewCount="621" Body="&lt;p&gt;I have this in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; The Silver Searcher&#xA;if executable('ag')&#xA;  &quot; Use ag over grep&#xA;  set grepprg=ag\ --nogroup\ --nocolor\ --ignore\ wiki --ignore\tests    &#xA;endif&#xA;&#xA;&quot; bind \ (backward slash) to grep shortcut&#xA;command -nargs=+ -complete=file -bar Ag silent! grep! &amp;lt;args&amp;gt;|cwindow|redraw!&#xA;nnoremap \ :Ag&amp;lt;SPACE&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it doesn't work, everytime I run vim i get this error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /Users/abdullah/.vimrc:&#xA;line   52:&#xA;E518: Unknown option: --ignore\tests&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when i press &lt;kbd&gt;\&lt;/kbd&gt; it gives me &lt;code&gt;:Ag&lt;/code&gt; in the prompt, but then doesn't ignore the &lt;code&gt;tests&lt;/code&gt; directory (just the wiki one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;although if I do the same from the command line, it works just fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ag --nogroup --nocolor --ignore tags --ignore tests %search_term%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what am i missing?&lt;/p&gt;&#xA;" OwnerUserId="14510" LastActivityDate="2017-11-02T10:56:16.380" Title="why doesn't ag in my vimrc ignore multiple patterns" Tags="|search|the-silver-searcher|" AnswerCount="1" CommentCount="1" ClosedDate="2017-11-06T07:55:07.880" ContentLicense="CC BY-SA 3.0" />
  <row Id="14094" PostTypeId="2" ParentId="14084" CreationDate="2017-11-02T10:25:43.167" Score="2" Body="&lt;p&gt;Here's what I came up with: &lt;code&gt;\v^(\S+).*\n(\1@!&amp;amp;\zs.*)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; sets the expression to very magic (&lt;code&gt;:help /magic&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; anchors the expression to the beginning of a line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(\S+)&lt;/code&gt; is the first word of the line, we will later compare to this&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*\n&lt;/code&gt; the rest of the line including line break; we don't really care about this&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\1@!&lt;/code&gt; matches an empty string here if &lt;code&gt;\1&lt;/code&gt; would not match (&lt;code&gt;\1&lt;/code&gt; is the first word of the previous line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;\zs.*&lt;/code&gt; &lt;code&gt;&amp;amp;&lt;/code&gt; match this if what comes before (anything other than &lt;code&gt;\1&lt;/code&gt;) matches, &lt;code&gt;\zs&lt;/code&gt; ignore what we matched before, this is where the &lt;em&gt;real&lt;/em&gt; match starts, &lt;code&gt;.*&lt;/code&gt; match the rest of the line, meaning the entire line, because we only matched &quot;&quot; with &lt;code&gt;\1@!&lt;/code&gt; and &lt;code&gt;&amp;amp;&lt;/code&gt; goes back to the starting position anyway*.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, what this ends up doing is match a whole line if it starts with a different word than the preceding line. If you want to filter a bit more, and, say, only want lines with a time &lt;code&gt;\d+:\d+&lt;/code&gt; at the start, just switch out the &lt;code&gt;\S+&lt;/code&gt; for your (more specific) pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, as for highlighting those lines, you can use &lt;code&gt;:match&lt;/code&gt; (&lt;code&gt;:help :match&lt;/code&gt; and &lt;code&gt;:help group-name&lt;/code&gt;) like so: &lt;code&gt;:match Todo /\v^(\S+).*\n(\1@!&amp;amp;\zs.*)/&lt;/code&gt;. I am using &lt;code&gt;Todo&lt;/code&gt; here because I like doing that for generic highlights, but you could also use &lt;code&gt;Underlined&lt;/code&gt; for something less in-your-face, or &lt;code&gt;Error&lt;/code&gt; for something even more important-looking. The end result would ultimately be the same though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*meaning, for example, &lt;code&gt;/..:..&amp;amp;00/&lt;/code&gt; matches 00:00 because both &lt;code&gt;/00/&lt;/code&gt; and &lt;code&gt;..:..&lt;/code&gt; match 00:00, but it doesn't match 11:1100, because while &lt;code&gt;..:..&lt;/code&gt; matches 11:11, &lt;code&gt;00&lt;/code&gt; goes back again and tries matching at the same place &lt;code&gt;..:..&lt;/code&gt; did, not after it.&lt;/p&gt;&#xA;" OwnerUserId="14920" LastEditorUserId="343" LastEditDate="2017-11-02T13:33:11.160" LastActivityDate="2017-11-02T13:33:11.160" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14095" PostTypeId="2" ParentId="14093" CreationDate="2017-11-02T10:50:17.647" Score="3" Body="&lt;p&gt;You haven't escaped your command correctly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set grepprg=ag\ --nogroup\ --nocolor\ --ignore\ wiki --ignore\tests&#xA;                                                    ^        ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a missing backslash after &lt;code&gt;wiki&lt;/code&gt; and a missing space before &lt;code&gt;tests&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim is therefore interpreting this as if it were two set commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set grepprg=ag\ --nogroup\ --nocolor\ --ignore\ wiki&#xA;set --ignore\tests&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;--ignore\tests&lt;/code&gt; isn't a Vim option, hence the error. And you're therefore also not passing that &lt;code&gt;ignore&lt;/code&gt; argument to &lt;code&gt;ag&lt;/code&gt;, so the &lt;code&gt;tests&lt;/code&gt; directory is not ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.B. It's easier to set options including whitespace using &lt;code&gt;let&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;grepprg = &quot;ag --nogroup --nocolor --ignore wiki --ignore tests&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Further reading&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :set-args&lt;/code&gt; (the bit right down the bottom, before &lt;code&gt;:set-verbose&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :let-option&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-02T10:56:16.380" LastActivityDate="2017-11-02T10:56:16.380" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14096" PostTypeId="2" ParentId="14088" CreationDate="2017-11-02T11:25:51.250" Score="0" Body="&lt;p&gt;I have figured out the reason based on another vi stackexchange answer. &lt;a href=&quot;https://vi.stackexchange.com/questions/3721/why-do-i-get-a-missing-quote-error-when-using-the-following-in-a-mapping-using-e&quot;&gt;Link&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently the character &lt;code&gt;&amp;lt;&lt;/code&gt; in &lt;code&gt;&amp;lt;c-q&amp;gt;&lt;/code&gt; needs to be replaced by &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt;, though I do not know why but it solves the current problem. So the new mapping would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap &amp;lt;F2&amp;gt; :execute &quot;normal ggf\&amp;lt;tab&amp;gt;&quot; \| execute &quot;normal \&amp;lt;lt&amp;gt;c-q&amp;gt;G$d&quot; \| :%s/ \+//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Input:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/B2Dsn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/B2Dsn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Result:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/nnEjc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nnEjc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And as per @statox's comment, &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; needs to be added to the end of the mapping to actually execute the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the final mapping would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap &amp;lt;F2&amp;gt; :execute &quot;normal ggf\&amp;lt;tab&amp;gt;&quot; \| execute &quot;normal \&amp;lt;lt&amp;gt;c-q&amp;gt;G$d&quot; \| :%s/ \+//g&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12103" LastActivityDate="2017-11-02T11:25:51.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14097" PostTypeId="1" AcceptedAnswerId="14099" CreationDate="2017-11-02T12:16:55.783" Score="2" ViewCount="1269" Body="&lt;h1&gt;Background&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I'm using vi with a php/laravel code base.. I ran ctags and see what happens:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;filename: app/Http/Controllers/RetailerApproveController.php&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;use App\Repositories\ApproveOrderRepo;&#xA;&#xA;...&#xA;&#xA;        $repo = new ApproveOrderRepo();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I do my tags shortcut (&lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;) I jump straight to the use line above, rather than the actual file that contains the definition of ApproveOrderRepo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;notice that if i'm in the file &lt;code&gt;RetailerApproveController&lt;/code&gt; and I run &lt;code&gt;:Tags&lt;/code&gt; I get a list, and it autocompletes as I type &lt;code&gt;ApproveOrderRepo&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0BJv1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0BJv1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which begins like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;namespace App\Repositories;&#xA;&#xA;use App\Order;&#xA;...&#xA;&#xA;class ApproveOrderRepo&#xA;{&#xA;    use DispatchesJobs;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;How do I make the the key mapping automatically jump the class definition file, rather than the use statement or some other file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for reference, this is what i have in my tags file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ApproveOrderRepo        app/Http/Controllers/EnRouteToClientController.php      /^use App\\Repositories\\ApproveOrderRepo;$/;&quot;  a       namespace:App\\Http\\Controllers        typeref:unknown:App\\Repositories\\ApproveOrderRepo&#xA;ApproveOrderRepo        app/Http/Controllers/RetailerApproveController.php      /^use App\\Repositories\\ApproveOrderRepo;$/;&quot;  a       namespace:App\\Http\\Controllers        typeref:unknown:App\\Repositories\\ApproveOrderRepo&#xA;ApproveOrderRepo        app/Repositories/ApproveOrderRepo.php   /^class ApproveOrderRepo$/;&quot;    c       namespace:App\\Repositories&#xA;ApproveOrderRepo        tests/ApproveOrderTest.php      /^use App\\Repositories\\ApproveOrderRepo;$/;&quot;  a       typeref:unknown:App\\Repositories\\ApproveOrderRepo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14510" LastActivityDate="2017-11-02T14:55:25.267" Title="why ctags take me to class definition rather than actual file" Tags="|tags|ctags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14098" PostTypeId="2" ParentId="14090" CreationDate="2017-11-02T13:06:50.300" Score="5" Body="&lt;p&gt;You probably pressed &lt;code&gt;q:&lt;/code&gt; instead of &lt;code&gt;:q&lt;/code&gt;. The &lt;code&gt;q:&lt;/code&gt; command opens the commandline window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can close it like any other window by using &lt;code&gt;:q&lt;/code&gt;, &lt;code&gt;:close&lt;/code&gt;, or &lt;code&gt;&amp;lt;C-w&amp;gt;w&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some people like to disable this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap q: &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or have it auto-correct to &lt;code&gt;:q&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap q: :q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-11-02T13:06:50.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14099" PostTypeId="2" ParentId="14097" CreationDate="2017-11-02T14:50:18.653" Score="7" Body="&lt;h2&gt;What's happening&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;When there are multiple matches for a tag, Vim uses the following list of priorities (listed at &lt;code&gt;:help tag-priority&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;&quot;FSC&quot;  A full matching static tag for the current file.&lt;/li&gt;&#xA;  &lt;li&gt;&quot;F C&quot;  A full matching global tag for the current file.&lt;/li&gt;&#xA;  &lt;li&gt;&quot;F  &quot;  A full matching global tag for another file.&lt;/li&gt;&#xA;  &lt;li&gt;&quot;FS &quot;  A full matching static tag for another file.&lt;/li&gt;&#xA;  &lt;li&gt;[...]&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(These priorities are displayed when using Vim's &lt;code&gt;:tselect&lt;/code&gt; command.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have no static tags in your tags file (these are indicated by the presence of &lt;code&gt;file&lt;/code&gt; or &lt;code&gt;file:...&lt;/code&gt; fields towards the end of the line, so Vim will select &quot;A full matching global tag for the current file&quot; as its first match (and hence the one you jump to with a &lt;code&gt;:tag&lt;/code&gt; command or &lt;kbd&gt;Ctrl+]&lt;/kbd&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only matching tag in your current file is the &lt;code&gt;use&lt;/code&gt; line that Vim therefore jumps to.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How to alter this&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You have several options for altering this behaviour:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;1. Just select the desired tag manually&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Instead of using &lt;kbd&gt;Ctrl+]&lt;/kbd&gt;, you could use (or map) the &lt;code&gt;:tselect&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ts &amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows you to type a number to select the specific tag you want to jump to.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;2. Remove the extra tags entirely&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I can't see much benefit in having the &lt;code&gt;use&lt;/code&gt; lines in your tags file. These are being included as an &lt;code&gt;a&lt;/code&gt; kind (see the fourth tab-separated value on each line), so you could regenerate your tags file without these by adding the following argument to your ctags invokation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--kinds-php=-a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also store that kind in a separate file and alter the &lt;code&gt;'tags'&lt;/code&gt; option on-the-fly to include or not include that file, as &lt;a href=&quot;https://stackoverflow.com/a/7934025/328936&quot;&gt;described by ldog on Stack Overflow&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;3. Use fzf's functionality to skip certain kinds&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You're currently using fzf's &lt;code&gt;:Tags&lt;/code&gt; function. You could create a new command that generates a PHP tags file on the fly which skips the &lt;code&gt;a&lt;/code&gt; kind, as &lt;a href=&quot;https://stackoverflow.com/a/46170966/328936&quot;&gt;described by icc97 on Stack Overflow&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! BTagsEnhanced&#xA;    \ call fzf#vim#buffer_tags(&amp;lt;q-args&amp;gt;, [&#xA;    \ printf('ctags -f - --sort=no --php-kinds=-a --excmd=number&#xA;    \ --language-force=%s %s', &amp;amp;filetype, expand('%:S'))], {})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;4. Write a new function to intelligently select a tag match&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You could write a function that uses &lt;code&gt;taglist()&lt;/code&gt; to access the tags and then uses the logic of your choosing to pick the &quot;best&quot; one. See &lt;a href=&quot;https://stackoverflow.com/a/23029622/328936&quot;&gt;Andrew Radev's answer on Stack Overflow&lt;/a&gt; for a template function that does this.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;5. Post process your tags file&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You could re-sort your tags file according to your desired priority. I wouldn't recommend this option.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-02T14:55:25.267" LastActivityDate="2017-11-02T14:55:25.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14100" PostTypeId="1" CreationDate="2017-11-02T16:35:20.750" Score="0" ViewCount="634" Body="&lt;p&gt;I have a large data file of comma separated variables. I need to remove all lines where the first entry (a number up to four digits) is non-unique. A typical example of what I am working with is below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1062,&quot;Mark&quot;,&quot;Michaelson&quot;,&quot;1&quot;&#xA;1062,&quot;Mark&quot;,&quot;Michaelson&quot;,&quot;2&quot;&#xA;1062,&quot;Mark&quot;,&quot;Michaelson&quot;,&quot;4120&quot;&#xA;1075,&quot;Dan&quot;,&quot;Danson&quot;,15&quot;&#xA;1075,&quot;Dan&quot;,&quot;Danson&quot;,185&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so in the brief example above, I wish to retain the first and forth lines and discard the rest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been trying to use Vim Regex to achieve this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:0/^\w*/+,$g//d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but of course that deletes all lines apart from the first&lt;/p&gt;&#xA;" OwnerUserId="10193" LastActivityDate="2017-11-02T19:42:56.570" Title="How to remove lines where the first &quot;word&quot; is non-unique" Tags="|regular-expression|ex-mode|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14101" PostTypeId="1" AcceptedAnswerId="14129" CreationDate="2017-11-02T17:54:39.703" Score="3" ViewCount="122" Body="&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; &lt;code&gt;^]&lt;/code&gt; doesn't work if cursor is on a function name prefixed with its package.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;code&gt;ctags&lt;/code&gt; and by reading the &lt;code&gt;tags&lt;/code&gt; file generated I ensured that the sub is indexed in the tags file, like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;a_func_like_this lib/Package/Module.pm    /^  sub a_func_like_this {$/;    s&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it works if my cursor is on &lt;code&gt;a_func_like_this&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if the full name is specified (along with its module) like &lt;code&gt;Package::Module::a_func_like_this&lt;/code&gt;, &lt;code&gt;^]&lt;/code&gt; would search for the full name which is not indexed by &lt;code&gt;ctags&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's like the default behaviour of &lt;code&gt;^]&lt;/code&gt; is &lt;code&gt;yiw :tag &amp;lt;C-r&amp;gt;&quot;&amp;lt;CR&amp;gt;&lt;/code&gt;.  Which implies that &lt;code&gt;Package::Module::a_func_like_this&lt;/code&gt; is being searched and thus returns no result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a workaround I want it to just get the part after &lt;code&gt;::&lt;/code&gt; if that presents in the Inner Word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, even with such work around, I may have to manually select the correct version of &lt;code&gt;a_func_like_this&lt;/code&gt; even though the exact file I am looking for is clearly &lt;code&gt;Package::Module&lt;/code&gt; (the part discarded). I guess &lt;code&gt;vi&lt;/code&gt; should have something smarter for tag jumping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I approach this?&lt;/p&gt;&#xA;" OwnerUserId="14820" LastEditorUserId="14820" LastEditDate="2017-11-03T01:16:13.900" LastActivityDate="2017-12-07T09:04:25.550" Title="^] doesn't work if cursor is on a function name prefixed with its package in Perl" Tags="|ctags|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14102" PostTypeId="2" ParentId="14074" CreationDate="2017-11-02T17:59:57.067" Score="-1" Body="&lt;p&gt;just put this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;manvim() { vim -c &quot;Man $1&quot; -c 'silent! only'; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your bashrc or bash_profile. Then source the file &amp;amp; then use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ manvim 'man page name' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;without the quotes.&lt;/p&gt;&#xA;" OwnerUserId="12004" LastActivityDate="2017-11-02T17:59:57.067" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14103" PostTypeId="2" ParentId="14100" CreationDate="2017-11-02T19:42:56.570" Score="1" Body="&lt;p&gt;The &lt;code&gt;g/&lt;/code&gt; only solution would probably be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\(\d\{4}\).\+\n\_.*\%(^\1\D\)/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This leaves the last occurrence.  We look for lines which have another line starting with the same digits an arbitrary number of characters ahead.  The key is the &lt;code&gt;\_.*&lt;/code&gt; in the middle which subsumes as much as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The equivalent very magic version is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\v^(\d{4}).+\n\_.*%(^\1\D)/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another solution is to use &lt;code&gt;:s&lt;/code&gt; and the sub-replace-expression &lt;code&gt;\=&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let seen = {} | %s/^\(\d\{4}\).\+\n/\= has_key(seen, submatch(1)) ? '' : execute('let seen[submatch(1)] = 1').submatch(0) /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This leaves the first occurrence.  It would be better to write a function if this is to be a commonly used operation.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-11-02T19:42:56.570" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14104" PostTypeId="1" AcceptedAnswerId="14105" CreationDate="2017-11-03T02:13:15.710" Score="2" ViewCount="563" Body="&lt;p&gt;I currently use &lt;code&gt;astyle -A8 -t8 -p -j &amp;lt;filename&amp;gt;&lt;/code&gt; to format the code in my C project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to configure my &lt;code&gt;.vimrc&lt;/code&gt; to follow the continuation line format that the above demands? For example &lt;code&gt;astyle&lt;/code&gt; formats the below function call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_function(first_arg, &#xA;&amp;lt;tab&amp;gt;second_arg,&#xA;&amp;lt;tab&amp;gt;third_arg);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(which is the default indentation when I hit &lt;code&gt;Enter&lt;/code&gt;) as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_function(first_arg, &#xA;            second_arg,&#xA;            third_arg);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I saw in &lt;code&gt;cinoptions-values&lt;/code&gt; there was something close:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                               *cino-+*&#xA;+N    Indent a continuation line (a line that spills onto the next)&#xA;      inside a function N additional characters.  (default&#xA;      'shiftwidth').&#xA;       Outside of a function, when the previous line ended in a&#xA;       backslash, the 2 * N is used.&#xA;&#xA;        cino=             cino=+10 &amp;gt;&#xA;          a = b + 9 *       a = b + 9 *&#xA;              c;                      c;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that only aligns to a specific number of spaces. Is there a way to align it like the &lt;code&gt;astyle&lt;/code&gt; example above?&lt;/p&gt;&#xA;" OwnerUserId="12628" LastActivityDate="2017-11-03T03:16:09.553" Title="Indentation like astyle - continuation lines" Tags="|vimrc|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14105" PostTypeId="2" ParentId="14104" CreationDate="2017-11-03T03:16:09.553" Score="3" Body="&lt;p&gt;The option you're looking for is &lt;code&gt;set cino+=(0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(N    When in unclosed parentheses, indent N characters from the line&#xA;      with the unclosed parentheses.  Add a 'shiftwidth' for every&#xA;      unclosed parentheses.  When N is 0 or the unclosed parentheses&#xA;      is the first non-white character in its line, line up with the&#xA;      next non-white character after the unclosed parentheses.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-11-03T03:16:09.553" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14106" PostTypeId="1" AcceptedAnswerId="14107" CreationDate="2017-11-03T11:05:54.483" Score="1" ViewCount="139" Body="&lt;p&gt;I've got highlighting of searches on and have the following set up to clear it in my vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Space&amp;gt; :nohlsearch&amp;lt;Bar&amp;gt;:echo&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also got the haskell plugin type information plugin hdevtools installed.  This keeps a highlight/selection up once you've asked for the type of an expression in case you want to expand that expression using the type info command again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to clear both lots of highlighting with the same key press, previously I'd had it set up to have a different shortcut but it's fiddly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However my plugin shortcuts are set up with autocmds like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType haskell nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;space&amp;gt; :HdevtoolsClear&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know I could just do copy and paste and a  in between but that means if I change this stuff I have to change it in two places.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like some way to do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;clearSearchHighlight = :nohlsearch&amp;lt;Bar&amp;gt;:echo&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Space&amp;gt; clearSearchHighlight&#xA;autocmd FileType haskell nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;space&amp;gt; :HdevtoolsClear&amp;lt;CR&amp;gt; &amp;lt;bar&amp;gt; clearSearchHighlight&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1518" LastActivityDate="2017-11-05T18:49:57.630" Title="Factoring out commands in vimrc?" Tags="|vimrc|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14107" PostTypeId="2" ParentId="14106" CreationDate="2017-11-03T12:49:27.530" Score="3" Body="&lt;p&gt;You could do this by setting up your actions as a user command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use a normal-mode map (which you'd then invoke with &lt;code&gt;:normal&lt;/code&gt;), but in this instance you can't use a function because you can't clear highlighting from a function! (See &lt;code&gt;:help :nohlsearch&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! ClearSearchHighlight nohlsearch | echo&#xA;&#xA;nnoremap &amp;lt;space&amp;gt; :ClearSearchHighlight&amp;lt;CR&amp;gt;&#xA;autocmd FileType haskell nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;space&amp;gt; :HdevtoolsClear&amp;lt;CR&amp;gt;:ClearSearchHighlight&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-03T14:42:11.697" LastActivityDate="2017-11-03T14:42:11.697" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14108" PostTypeId="1" CreationDate="2017-11-03T16:57:51.643" Score="1" ViewCount="41" Body="&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; I have macros in each &lt;code&gt;%m&lt;/code&gt; captured by &lt;code&gt;errorformat&lt;/code&gt; after &lt;code&gt;:make&lt;/code&gt;.  I'd like to have a copy of the file in another split and apply all the macros (so to have a fixed file) and then do a &lt;code&gt;:windo diffthis&lt;/code&gt; to let the user (mostly me) to choose to &lt;code&gt;diffget&lt;/code&gt; the fixed code or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; I am planning to do &lt;code&gt;ggyG&lt;/code&gt; and then &lt;code&gt;:vnew P&lt;/code&gt; then do a recursive macro call until I exhausted all &lt;code&gt;:cnext&lt;/code&gt;.  However the error after exhaustion would stop the whole process which the &lt;code&gt;:windo diffthis&lt;/code&gt; cannot start.  Is there a way to overcome this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To streamline my daily workflow, I'd like to have the Quick Fix Window not only to show where the errors are, but to suggest a way to quick fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming that I have customized &lt;code&gt;makeprg&lt;/code&gt; and &lt;code&gt;errorformat&lt;/code&gt;, such that &lt;code&gt;errorformat&lt;/code&gt; has &lt;code&gt;%m&lt;/code&gt; capturing a &lt;code&gt;vi&lt;/code&gt; macro that would fix the issue when run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example if I am working with jQuery and has this in line 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;var top = $element.top;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:make&lt;/code&gt; will capture this and &lt;code&gt;errorformat&lt;/code&gt; knows that &lt;code&gt;%l&lt;/code&gt; is 1 and &lt;code&gt;%m&lt;/code&gt; would be &lt;code&gt;1G/\.top&amp;lt;cr&amp;gt;i.offset()&amp;lt;esc&amp;gt;&lt;/code&gt; (when run, would correctly insert &lt;code&gt;offset()&lt;/code&gt; before &lt;code&gt;.top&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I am like using &lt;code&gt;:nnoremap Z &amp;lt;C-w&amp;gt;&amp;lt;C-w&amp;gt;f&amp;lt;space&amp;gt;ly$&amp;lt;C-w&amp;gt;&amp;lt;C-w&amp;gt;:@0&amp;lt;cr&amp;gt;&lt;/code&gt; so after I did &lt;code&gt;:cnext&lt;/code&gt; I can use &lt;code&gt;Z&lt;/code&gt; to apply the fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to make &lt;code&gt;vi&lt;/code&gt; smarter so &lt;code&gt;vi&lt;/code&gt; could get me a fixed version of the code and I could check if &lt;code&gt;vi&lt;/code&gt; 's suggestions are acceptable or not.  Therefore I asked the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way I am also interested in how Fugitive managed to create buffers that starts with &lt;code&gt;fugitive://&lt;/code&gt; and there are no warning if I just run &lt;code&gt;:q&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2017-11-03T16:57:51.643" Title="Creating QuickFixed file to apply QuickFixes via diff" Tags="|macro|quickfix|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14109" PostTypeId="2" ParentId="3358" CreationDate="2017-11-03T18:48:45.587" Score="4" Body="&lt;p&gt;There is another nice plugin called &lt;code&gt;mucomplete&lt;/code&gt; (&lt;a href=&quot;https://github.com/lifepillar/vim-mucomplete&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/lifepillar/vim-mucomplete&lt;/a&gt;) that shows automatically a popup with completion suggestions.&lt;/p&gt;&#xA;" OwnerUserId="14974" LastActivityDate="2017-11-03T18:48:45.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14111" PostTypeId="1" AcceptedAnswerId="14121" CreationDate="2017-11-04T23:32:54.210" Score="1" ViewCount="192" Body="&lt;p&gt;I am compiling a program with :make command, then I examine g++ errors using :cwindow. The problem is that the error produced by g++ is longer than 1000 characters and it is cut.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I have to compile this program in separate xterm in order to see complete error message which has 2403 characters length.&lt;/p&gt;&#xA;" OwnerUserId="14986" LastEditorUserId="1841" LastEditDate="2017-11-06T07:57:50.103" LastActivityDate="2017-11-06T17:26:09.393" Title="vim :make :cwindow, I need error length character limit larger than 1000" Tags="|gvim|quickfix|makeprg|hidden-buffers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14112" PostTypeId="1" AcceptedAnswerId="14118" CreationDate="2017-11-05T05:28:50.497" Score="1" ViewCount="434" Body="&lt;p&gt;I would like to map a key so I can quick close all folds but keep unfolded on current cursor and keep cursor's position too.&lt;br&gt;&#xA;Through &lt;code&gt;:h fold&lt;/code&gt; I can use &lt;code&gt;zMzv&lt;/code&gt; but it can't keep cursor's position. &lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2020-06-14T20:59:30.977" Title="Fold all except current cursor and keep cursor position" Tags="|vimrc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14113" PostTypeId="1" CreationDate="2017-11-05T11:15:01.197" Score="2" ViewCount="993" Body="&lt;p&gt;&lt;code&gt;:h region&lt;/code&gt; bring me very little help. I need to exclude a pattern inside a region that should be ignored for example: don't apply match/highlight begin from &lt;code&gt;#&lt;/code&gt; to the end of line &lt;code&gt;$&lt;/code&gt;&lt;br&gt;&#xA;I try to ignore &lt;code&gt;#.*$&lt;/code&gt; inside a region but seem I can't find anything related from help. Did I miss something from docs?&lt;br&gt;&#xA;Or if I need to write a function to do that, do you have any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2018-05-01T23:38:07.103" Title="Ignore pattern inside of a region" Tags="|syntax-highlighting|regular-expression|highlight|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14114" PostTypeId="1" AcceptedAnswerId="14120" CreationDate="2017-11-05T17:54:10.440" Score="16" ViewCount="2359" Body="&lt;p&gt;I have an image on the clipboard and I want to paste it into my document as the text &lt;code&gt;[](img/image1.png)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of first copying it to that directory, I want to do it with a  single &lt;kbd&gt;p&lt;/kbd&gt; key press in Vim. So it hooks &lt;code&gt;p&lt;/code&gt;, checks if I am editing a Markdown file, saves the image from the clipboard to the location &lt;code&gt;img/image1.png&lt;/code&gt;, and inserts &lt;code&gt;[](img/image1.png)&lt;/code&gt; into the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible with Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use macOS and terminal Vim.&lt;/p&gt;&#xA;" OwnerUserId="14989" LastEditorUserId="343" LastEditDate="2017-11-06T15:29:53.387" LastActivityDate="2021-03-03T10:51:58.823" Title="Paste link to image in clipboard when editing Markdown" Tags="|cut-copy-paste|os-clipboard|filetype-markdown|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14115" PostTypeId="2" ParentId="7262" CreationDate="2017-11-05T18:15:02.083" Score="27" Body="&lt;p&gt;With the update from November 2017 of &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/ftplugin/python.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;$VIMRUNTIME/ftplugin/python.vim&lt;/code&gt;&lt;/a&gt; following ft-specific motions are available for the python language&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[[&lt;/code&gt; Jump backwards to begin of current/previous toplevel&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[]&lt;/code&gt; &lt;strong&gt;Jump backwards to end of previous toplevel&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;][&lt;/code&gt; &lt;strong&gt;Jump forwards to end of current toplevel&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;]]&lt;/code&gt; Jump forwards to begin of next toplevel&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[m&lt;/code&gt; Jump backwards to begin of current/previous method/scope&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;[M&lt;/code&gt; Jump backwards to end of previous method/scope&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;]M&lt;/code&gt; Jump forwards to end of current/next method/scope&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;]m&lt;/code&gt; Jump forwards to begin of next method/scope&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Example python file&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;class previous:             # [[[[&#xA;    &#xA;    def method_first:&#xA;        pass&#xA;    # ...&#xA;&#xA;    def method_last:&#xA;        pass                # []&#xA;&#xA;class current:              # [[ or [m...[m[m&#xA;    &#xA;    def method_first:       # [[]m or [m...[m&#xA;        pass                # [[]M or [M...[M&#xA;    # ...&#xA;&#xA;    def method_previous:    # [m[m&#xA;        pass                # [M&#xA;&#xA;    def method_current:     # [m&#xA;        # CURSOR &amp;lt;---------------------------&#xA;        pass                # ]M&#xA;&#xA;    def method_next:        # ]m&#xA;        pass                # ]M]M&#xA;    # ...&#xA;&#xA;    def method_last:        # ][[m or ]m...]m&#xA;        pass                # ][   or ]M...]M&#xA;&#xA;class previous:             # ]]   or ]m...]m]m&#xA;    &#xA;    def method_first:&#xA;        pass&#xA;    # ...&#xA;    &#xA;def global_func:            # ]]]]&#xA;    pass&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This update should be included if your vim patch level is at least &lt;code&gt;8.0.1256&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you can't update but want to use this functionality, you can install the most recent version into the &lt;code&gt;~/.vim&lt;/code&gt; directory:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ curl https://raw.githubusercontent.com/vim/vim/master/runtime/ftplugin/python.vim --create-dirs -o ~/.vim/ftplugin/python.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Plugin &lt;a href=&quot;https://github.com/jeetsukumaran/vim-pythonsense&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pythonsense&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;This plugin provides similar motions but slightly modified:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The stock Vim 8.0 &amp;quot;class&amp;quot; motions (&amp;quot;&lt;code&gt;]]&lt;/code&gt;&amp;quot;, &amp;quot;&lt;code&gt;[[&lt;/code&gt;&amp;quot;, etc.), find blocks that begin at the first column, regardless of whether or not these are class or function blocks, while its method/function motions (&amp;quot;&lt;code&gt;[m&lt;/code&gt;&amp;quot;, &amp;quot;&lt;code&gt;]m&lt;/code&gt;&amp;quot;, etc.) find all blocks at any indent regardless of whether or not these are class or function blocks. In contrast, &amp;quot;Pythonsense&amp;quot; class motions work on finding all and only class definitions, regardless of their indent level, while its method/function motions work on finding all and only method/function definitions, regardless of their indent level.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;All details and examples are given at &lt;a href=&quot;https://github.com/jeetsukumaran/vim-pythonsense#stock-vim-vs-pythonsense-motions&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/jeetsukumaran/vim-pythonsense#stock-vim-vs-pythonsense-motions&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2023-09-20T08:29:43.747" LastActivityDate="2023-09-20T08:29:43.747" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="14116" PostTypeId="2" ParentId="14106" CreationDate="2017-11-05T18:49:57.630" Score="1" Body="&lt;p&gt;You can bind those commands to Ctrl+L:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-l&amp;gt; :nohls&amp;lt;CR&amp;gt;:HdevtoolsClear&amp;lt;CR&amp;gt;:redraw!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ctrl+L usually just redraws the screen. Now it will, in addition, clear the highlighting.&lt;/p&gt;&#xA;" OwnerUserId="14990" LastActivityDate="2017-11-05T18:49:57.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14117" PostTypeId="2" ParentId="14114" CreationDate="2017-11-05T19:16:27.603" Score="9" Body="&lt;p&gt;The following solution should work on most Linux systems. It requires a relatively updated &lt;code&gt;xclip&lt;/code&gt; tool. For a solution that works on MacOS/OSX, see &lt;a href=&quot;https://vi.stackexchange.com/a/14120/21&quot;&gt;@Rich's answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've proposed a solution that maps &lt;code&gt;&amp;lt;leader&amp;gt;p&lt;/code&gt; instead of remapping &lt;code&gt;p&lt;/code&gt;, since I think this is a much saner approach. The function &lt;code&gt;SaveFile&lt;/code&gt; will inspect the clipboard with &lt;code&gt;xclip&lt;/code&gt;. If there is an image file, it will be saved to &lt;code&gt;img/imageN.&amp;lt;ext&amp;gt;&lt;/code&gt;, unless the file already exists. It will also populate the &lt;code&gt;*&lt;/code&gt; register with the &lt;code&gt;[](img/...)&lt;/code&gt; text and then paste it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;p :call SaveFile()&amp;lt;cr&amp;gt;&#xA;&#xA;function! SaveFile() abort&#xA;  let targets = filter(&#xA;        \ systemlist('xclip -selection clipboard -t TARGETS -o'),&#xA;        \ 'v:val =~# ''image''')&#xA;  if empty(targets) | return | endif&#xA;&#xA;  let outdir = expand('%:p:h') . '/img'&#xA;  if !isdirectory(outdir)&#xA;    call mkdir(outdir)&#xA;  endif&#xA;&#xA;  let mimetype = targets[0]&#xA;  let extension = split(mimetype, '/')[-1]&#xA;  let tmpfile = outdir . '/savefile_tmp.' . extension&#xA;  call system(printf('xclip -selection clipboard -t %s -o &amp;gt; %s',&#xA;        \ mimetype, tmpfile))&#xA;&#xA;  let cnt = 0&#xA;  let filename = outdir . '/image' . cnt . '.' . extension&#xA;  while filereadable(filename)&#xA;    call system('diff ' . tmpfile . ' ' . filename)&#xA;    if !v:shell_error&#xA;      call delete(tmpfile)&#xA;      break&#xA;    endif&#xA;&#xA;    let cnt += 1&#xA;    let filename = outdir . '/image' . cnt . '.' . extension&#xA;  endwhile&#xA;&#xA;  if filereadable(tmpfile)&#xA;    call rename(tmpfile, filename)&#xA;  endif&#xA;&#xA;  let @* = '[](' . fnamemodify(filename, ':.') . ')'&#xA;  normal! &quot;*p&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2017-11-08T07:37:06.273" LastActivityDate="2017-11-08T07:37:06.273" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14118" PostTypeId="2" ParentId="14112" CreationDate="2017-11-06T06:04:16.420" Score="3" Body="&lt;p&gt;You can set a mark at the beginning of your mapping and then jump there at the end. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;zv :normal mazMzv`a&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Postscript:&lt;/strong&gt; &lt;em&gt;This was posted when I was merely an apprentice Vim Ninja rather than the MVN (Master Vim Ninja) you see before you today. Of course, in the &amp;lt;ahem&gt;&lt;/em&gt; normal &lt;em&gt;course of things one would be wasteful to create such an nmap when &lt;code&gt;nno &amp;lt;leader&amp;gt;zv mazMzv`a&lt;/code&gt; is equivalent. Funny thing, though...OP says the less enlightened version was the only one to solve his problem. Personally I can't reproduce even the cursor moving part so I just take them at their word and this answer lives on; a signpost aside the road on which I journeyed to top of the mountain.&lt;/em&gt;  B Layer - 6/14/2020 &lt;strong&gt;;)&lt;/strong&gt; &lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-06-14T20:59:30.977" LastActivityDate="2020-06-14T20:59:30.977" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="14119" PostTypeId="2" ParentId="14046" CreationDate="2017-11-06T13:00:02.777" Score="0" Body="&lt;p&gt;Using &lt;kbd&gt;Ctrl+v&lt;/kbd&gt; in insert mode, which &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-V&quot; rel=&quot;nofollow noreferrer&quot;&gt;inserts terminal codes&lt;/a&gt; received by vim, I found out that my Terminal was not sending proper escape codes to vim, therefore vim did not have correct key codes to interpret. Being a native app, MacVim recognized these key codes correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Final solution was to set Terminal.app to produce key codes according &lt;a href=&quot;https://www.emacswiki.org/emacs/ScreenKeys&quot; rel=&quot;nofollow noreferrer&quot;&gt;to this mapping&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;S-up&amp;gt;:      ^[[1;2A &#xA;&amp;lt;S-down&amp;gt;:    ^[[1;2B &#xA;&amp;lt;S-right&amp;gt;:   ^[[1;2C &#xA;&amp;lt;S-left&amp;gt;:    ^[[1;2D &#xA;&#xA;&amp;lt;M-up&amp;gt;:      ^[[1;3A &#xA;&amp;lt;M-down&amp;gt;:    ^[[1;3B &#xA;&amp;lt;M-right&amp;gt;:   ^[[1;3C &#xA;&amp;lt;M-left&amp;gt;:    ^[[1;3D &#xA;&#xA;&amp;lt;M-S-up&amp;gt;:    ^[[1;4A &#xA;&amp;lt;M-S-down&amp;gt;:  ^[[1;4B &#xA;&amp;lt;M-S-right&amp;gt;: ^[[1;4C &#xA;&amp;lt;M-S-left&amp;gt;:  ^[[1;4D &#xA;&#xA;&amp;lt;C-up&amp;gt;:      ^[[1;5A &#xA;&amp;lt;C-down&amp;gt;:    ^[[1;5B &#xA;&amp;lt;C-right&amp;gt;:   ^[[1;5C &#xA;&amp;lt;C-left&amp;gt;:    ^[[1;5D &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1733" LastActivityDate="2017-11-06T13:00:02.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14120" PostTypeId="2" ParentId="14114" CreationDate="2017-11-06T15:23:28.463" Score="5" Body="&lt;p&gt;The usual terminal command for accessing the clipboard on Mac is &lt;code&gt;pbpaste&lt;/code&gt;. However, this doesn't work for image data, so we have to resort to AppleScript:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; p :call MarkdownClipboardImage()&amp;lt;cr&amp;gt;&#xA;&#xA;function! MarkdownClipboardImage() abort&#xA;  &amp;quot; Create `img` directory if it doesn't exist&#xA;  let img_dir = getcwd() . '/img'&#xA;  if !isdirectory(img_dir)&#xA;    silent call mkdir(img_dir)&#xA;  endif&#xA;&#xA;  &amp;quot; First find out what filename to use&#xA;  let index = 1&#xA;  let file_path = img_dir . &amp;quot;/image&amp;quot; . index . &amp;quot;.png&amp;quot;&#xA;  while filereadable(file_path)&#xA;    let index = index + 1&#xA;    let file_path = img_dir . &amp;quot;/image&amp;quot; . index . &amp;quot;.png&amp;quot;&#xA;  endwhile&#xA;&#xA;  let clip_command = 'osascript'&#xA;  let clip_command .= ' -e &amp;quot;set png_data to the clipboard as «class PNGf»&amp;quot;'&#xA;  let clip_command .= ' -e &amp;quot;set referenceNumber to open for access POSIX path of'&#xA;  let clip_command .= ' (POSIX file \&amp;quot;' . file_path . '\&amp;quot;) with write permission&amp;quot;'&#xA;  let clip_command .= ' -e &amp;quot;write png_data to referenceNumber&amp;quot;'&#xA;&#xA;  silent call system(clip_command)&#xA;  if v:shell_error == 1&#xA;    normal! p&#xA;  else&#xA;    execute &amp;quot;normal! i[](&amp;quot; . file_path . &amp;quot;)&amp;quot;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Add the code above to &lt;code&gt;~/.vim/after/ftplugin/markdown.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This saves the clipboard data to the file &amp;quot;img/image1.png&amp;quot; if it contains PNG data. It then just uses the &lt;code&gt;:normal!&lt;/code&gt; to insert the desired markdown link.&lt;/p&gt;&#xA;&lt;p&gt;If the clipboard doesn't contain PNG data (or if we're not in a Markdown file), it performs a regular &lt;kbd&gt;p&lt;/kbd&gt; command.&lt;/p&gt;&#xA;&lt;p&gt;If I were using this, I'd &lt;a href=&quot;https://github.com/sedm0784/vimclipaste&quot; rel=&quot;nofollow noreferrer&quot;&gt;tidy it up&lt;/a&gt; to support further image types and to leave the cursor in a more helpful position, but this works well as a proof of concept.&lt;/p&gt;&#xA;&lt;p&gt;(I'd also use a &lt;code&gt;&amp;lt;leader&amp;gt;p&lt;/code&gt; mapping as &lt;a href=&quot;https://vi.stackexchange.com/a/14117/343&quot;&gt;suggested by Karl Yngve Lervåg&lt;/a&gt; — this seems like functionality I'd prefer to invoke specifically — but that's not what you asked for).&lt;/p&gt;&#xA;&lt;h3&gt;Further reading&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :map-&amp;lt;buffer&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help system()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help v:shell_error&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :normal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://developer.apple.com/library/content/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;AppleScript documentation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2021-03-03T10:51:58.823" LastActivityDate="2021-03-03T10:51:58.823" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="14121" PostTypeId="2" ParentId="14111" CreationDate="2017-11-06T17:26:09.393" Score="3" Body="&lt;p&gt;As of &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v7.4.1802&quot; rel=&quot;nofollow noreferrer&quot;&gt;7.4.1802&lt;/a&gt;, Vim is supposed to quickfix lines up to 4096 bytes long instead of truncating them.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2017-11-06T17:26:09.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14123" PostTypeId="1" CreationDate="2017-11-06T20:46:00.323" Score="0" ViewCount="108" Body="&lt;p&gt;I write code mostly on my laptop for portability. It's a small monitor, so plugins that use the &quot;sign column&quot; tend to take up too much space. For example, I have my &lt;code&gt;Syntastic&lt;/code&gt; plugin configured to &lt;strong&gt;highlight lines with syntax errors in red&lt;/strong&gt; and show a message at the bottom, rather than indicating errors in the signcolumn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin for &lt;strong&gt;navigation between marks&lt;/strong&gt;, for which I can do something similar -- just &lt;strong&gt;highlight the entire line&lt;/strong&gt; in one or two colors? Generally, I won't be using more than a couple marks in an entire file because I won't remember where they are, and I can navigate lines that fit on the screen with simple &lt;code&gt;j&lt;/code&gt;/&lt;code&gt;k&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe I can insert a few lines into my &lt;code&gt;.vimrc&lt;/code&gt; myself -- for example, trigger a special syntax coloring wherever &quot;mark &lt;code&gt;A&lt;/code&gt;&quot; is?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="1841" LastEditDate="2017-11-07T07:55:36.567" LastActivityDate="2017-11-07T07:55:36.567" Title="Plugin for showing marks by *highlighting entire line*, instead of using signcolumn?" Tags="|vimrc|vimscript|navigation|mark|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14124" PostTypeId="2" ParentId="14123" CreationDate="2017-11-06T21:07:05.190" Score="2" Body="&lt;p&gt;There is a pretty quick and dirty way using &lt;code&gt;\%'a&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for c in map(range(char2nr('a'), char2nr('z')), 'nr2char(v:val)')&#xA;    call matchadd('Search', '^.*\%'.&quot;'&quot;.c.'.*$')&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace &lt;code&gt;Search&lt;/code&gt; with an appropriate highlighting group.  You can also replace the &lt;code&gt;map(range(...))&lt;/code&gt; with any set of marks you want, e.g., &lt;code&gt;['A', 'B']&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few caveats:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Only highlights behind characters, not to the end of the screen.&lt;/li&gt;&#xA;&lt;li&gt;Updates only when cursor is moved.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-11-06T21:07:05.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14125" PostTypeId="1" AcceptedAnswerId="14126" CreationDate="2017-11-06T22:57:30.530" Score="2" ViewCount="99" Body="&lt;p&gt;A common process for me is to have a camelCased word that I wish to prepend to. I find the vanilla method a little too cumbersome as I will describe below. What I'm wondering is if there is a better method.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Example&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function foo() {&#xA;  doSomething();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this the &lt;code&gt;doSomething&lt;/code&gt; is in camel case and I want to turn it into &lt;code&gt;shouldDoSomething&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Things I've tried&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Usually I will place the cursor at the beginning of the word and press &lt;kbd&gt;~&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;code&gt;should&lt;/code&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;. However, this requires positioning the cursor correctly and performing a few operations one of which needs to be undone (&lt;kbd&gt;~&lt;/kbd&gt; move cursor to the right requiring an extra &lt;kbd&gt;h&lt;/kbd&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also used tpope's &lt;a href=&quot;https://github.com/tpope/vim-abolish#coercion&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-abolish Coercion&lt;/a&gt; by placing the cursor on the &lt;strong&gt;correct line&lt;/strong&gt; and then &lt;kbd&gt;I&lt;/kbd&gt;&lt;code&gt;something_&lt;/code&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;. Unfortunatly the result of which is &lt;code&gt;shouldDosomething&lt;/code&gt; not &lt;code&gt;shouldDoSomething&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="544" LastActivityDate="2017-11-08T07:10:30.417" Title="How do I prepend text preserving camelcase" Tags="|cursor-movement|cursor-motions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14126" PostTypeId="2" ParentId="14125" CreationDate="2017-11-06T23:19:28.527" Score="5" Body="&lt;p&gt;You can use &lt;code&gt;s&lt;/code&gt; to delete the current letter and put you in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sshouldD&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will let you delete the &lt;code&gt;s&lt;/code&gt; insert &lt;code&gt;shouldD&lt;/code&gt; yielding &lt;code&gt;shouldDoSomething&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: assuming you are on the &lt;code&gt;d&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-11-06T23:19:28.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14127" PostTypeId="1" AcceptedAnswerId="14130" CreationDate="2017-11-07T07:10:13.263" Score="0" ViewCount="79" Body="&lt;p&gt;On text like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#Comment&#xA;#comment&#xA;....&#xA;&#xA;#comment&#xA;#Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to delete the #&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but only on next line,so become..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#Comment&#xA;comment&#xA;....&#xA;&#xA;#comment&#xA;Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far I do it with sed like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sed '/^\#/{n;s/^\#comment/comment/;}'                                                                                  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However how can I do it with vim?&lt;/p&gt;&#xA;" OwnerUserId="5009" LastEditorUserId="1841" LastEditDate="2017-11-07T15:11:45.883" LastActivityDate="2017-11-07T15:11:45.883" Title="How do I delete the first char of next line only?" Tags="|substitute|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14129" PostTypeId="2" ParentId="14101" CreationDate="2017-11-07T08:48:46.390" Score="2" Body="&lt;p&gt;Thanks I have figured it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of a plain &lt;code&gt;ctags -R&lt;/code&gt;, run &lt;code&gt;ctags -R --extra=+q&lt;/code&gt; which also adds the prefix-ed version of the methods into the tags file.&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2017-11-07T08:48:46.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14130" PostTypeId="2" ParentId="14127" CreationDate="2017-11-07T08:50:59.663" Score="5" Body="&lt;p&gt;With Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^#/norm j0x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which runs &lt;code&gt;norm j0x&lt;/code&gt; for each line starting with &lt;code&gt;#&lt;/code&gt;, and &lt;code&gt;j0x&lt;/code&gt; in normal mode moves down one line and removes the first character.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2017-11-07T10:25:36.930" LastActivityDate="2017-11-07T10:25:36.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14131" PostTypeId="2" ParentId="14125" CreationDate="2017-11-07T12:04:30.930" Score="1" Body="&lt;p&gt;how about &lt;kbd&gt;b&lt;/kbd&gt; &lt;kbd&gt;g&lt;/kbd&gt; &lt;kbd&gt;g&lt;/kbd&gt; &lt;kbd&gt;U&lt;/kbd&gt; &lt;kbd&gt;l&lt;/kbd&gt;&#xA; &lt;kbd&gt;i&lt;/kbd&gt; &lt;code&gt;should&lt;/code&gt; &lt;kbd&gt;Esc&lt;/kbd&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can save that into a macro and re-use it if you need to do it a lot. Otherwise don't bother optimizing a task you only do once anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to make this a macro you can do &lt;code&gt;qqbgUli&amp;lt;C-o&amp;gt;q&lt;/code&gt; to save it into the q register. Note that the macro would only be recorded as &lt;code&gt;qqbgUli&lt;/code&gt;, since &lt;code&gt;&amp;lt;C-o&amp;gt;q&lt;/code&gt; is what stops the recording without leaving insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also just map it to something like &lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;leader&amp;gt;i&lt;/code&gt; if you use it often. &lt;code&gt;map &amp;lt;leader&amp;gt;ic bgUli&lt;/code&gt; (&lt;code&gt;ic&lt;/code&gt; as in &lt;strong&gt;I&lt;/strong&gt;nsert preserving &lt;strong&gt;C&lt;/strong&gt;amel-case)&lt;/p&gt;&#xA;" OwnerUserId="14920" LastEditorUserId="14920" LastEditDate="2017-11-08T07:10:30.417" LastActivityDate="2017-11-08T07:10:30.417" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14132" PostTypeId="2" ParentId="9118" CreationDate="2017-11-07T19:44:41.897" Score="11" Body="&lt;p&gt;It is important to realize that this &quot;default&quot; only applies to the &lt;code&gt;gq&lt;/code&gt; and &lt;code&gt;gw&lt;/code&gt; commands and auto-format as described in that section.  The default &lt;code&gt;textwidth&lt;/code&gt; is 0.  Furthermore, &lt;code&gt;:right&lt;/code&gt; and &lt;code&gt;:center&lt;/code&gt; default to 80, not 79.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for why 79 was chosen, it cannot be a direct hold-over from vi since &lt;code&gt;gq&lt;/code&gt;, &lt;code&gt;gw&lt;/code&gt;, and auto-format do not exist in vi.  This is mostly speculation, but I believe the 79 default for auto-format was chosen for consistency with vi's existing auto-wrapping.  That this applies for &lt;code&gt;gq&lt;/code&gt; and &lt;code&gt;gw&lt;/code&gt; is a side-effect; one might expect 80 would have been chosen otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vi (and in vim if &lt;code&gt;textwidth=0&lt;/code&gt;) text starts auto-wrapping at the window width minus &lt;code&gt;wrapmargin&lt;/code&gt;.  However, if &lt;code&gt;wrapmargin=0&lt;/code&gt;, no auto-wrapping will take place. This means that if you were using an ADM-3A with an 80 character limit, with &lt;code&gt;wrapmargin=1&lt;/code&gt;, the maximum width with auto-wrapping is 79.  An upside to this behavior is that there is a place for the cursor to live while waiting to see what the next character is going to be before deciding where to wrap.  Of course, vi and vim could put the cursor on the next line (as observed when typing a very long word) but leaving an extra column is a bit nicer.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-11-07T20:39:20.907" LastActivityDate="2017-11-07T20:39:20.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14133" PostTypeId="1" AcceptedAnswerId="14134" CreationDate="2017-11-08T05:47:30.997" Score="3" ViewCount="2920" Body="&lt;p&gt;I have made a few mappings for my personal configuration file, and I think I am getting a hang of it, however, I am wondering if there are any particular tricks to create mappings for command-line mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that there are keys like &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;h&lt;/kbd&gt; for deleting the  character before the cursor or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Left&lt;/kbd&gt; for moving one &lt;code&gt;WORD&lt;/code&gt; left, and I know how to remap these, but I am unsure what my options are when I want to make new ones.  If I wanted a key (say &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;_&lt;/kbd&gt;) which deletes the content of a parenthesis in insert mode, I would do this with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;C-_&amp;gt; &amp;lt;C-O&amp;gt;dib&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this relies on using normal mode, and I am unsure how, if possible, I could achieve something like that for command-line mode.&lt;/p&gt;&#xA;" OwnerUserId="1498" LastActivityDate="2017-11-13T21:34:06.243" Title="Creating mappings for command-line mode" Tags="|command-line|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14134" PostTypeId="2" ParentId="14133" CreationDate="2017-11-08T14:08:41.917" Score="5" Body="&lt;p&gt;Vim provides a few mechanisms for inspecting the contents of the command-line (See &lt;em&gt;Further Reading&lt;/em&gt;, below), but not many for directly manipulating it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way you could create the mapping you describe above would be to go via the command-line window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cnoremap &amp;lt;expr&amp;gt; &amp;lt;c-_&amp;gt; &amp;amp;cedit.'dib'.'&amp;lt;c-c&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This creates an expression mapping that opens the command-line window, performs a normal mode &lt;code&gt;dib&lt;/code&gt; and then returns to the regular command-line. The downside to this method is that it leaves the command-line window open after the mapping completes (although it no longer has focus). The window closes when you enter or cancel the command. See &lt;a href=&quot;https://vi.stackexchange.com/questions/14133/creating-mappings-for-command-line-mode/14134#comment24259_14134&quot;&gt;Mass's comment, below&lt;/a&gt; for a clever fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your only other real option for complex &lt;code&gt;cmap&lt;/code&gt;s is to use &lt;kbd&gt;Ctrl-\&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt; which allows you to replace the entire command-line with the result of an expression.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Further Reading&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help cmdwin&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'cedit'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help c_CTRL-\_e&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help c_CTRL-R_=&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getcmdline()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getcmdtype()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getcmdpos()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help setcmdpos()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-08T17:04:52.890" LastActivityDate="2017-11-08T17:04:52.890" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14135" PostTypeId="1" AcceptedAnswerId="14138" CreationDate="2017-11-08T14:09:08.350" Score="4" ViewCount="488" Body="&lt;p&gt;I feel like this might be because of my lack of vimscript knowledge.  Basically I want to write a patch for this plugin &lt;a href=&quot;https://github.com/actionshrimp/vim-xpath&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/actionshrimp/vim-xpath&lt;/a&gt; to make it work for python3 (and hence vim8).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can just change it to say py3 everywhere it currently says py however that breaks it for python2 and so wouldn't be submittable as a pull request.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to litter the code with if/else &lt;code&gt;has(&quot;python3&quot;)&lt;/code&gt; everywhere - ideally I'd like to assign the relevant command to a variable in an if else and then just use it everywhere.  Or something similarly elegant &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do that?&lt;/p&gt;&#xA;" OwnerUserId="1518" LastActivityDate="2017-11-08T19:04:45.787" Title="How to write a plugin that works for both Python3 and python?" Tags="|vimscript|vimscript-python|" AnswerCount="1" CommentCount="0" ClosedDate="2018-01-28T18:03:42.200" ContentLicense="CC BY-SA 3.0" />
  <row Id="14137" PostTypeId="1" CreationDate="2017-11-08T17:08:39.180" Score="2" ViewCount="3521" Body="&lt;p&gt;I have neovim 0.2.0 and powerline-status (2.6) on Fedora 26. But it fails as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Se ha detectado un error al procesar function provider#python3#Call:&#xA;línea   18&#xA;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;  File &quot;/usr/lib/python3.6/site-packages/powerline/vim.py&quot;, line 15, in &amp;lt;module&amp;gt;&#xA;    from powerline.bindings.vim import vim_get_func, vim_getvar, get_vim_encoding, python_to_vim&#xA;  File &quot;/usr/lib/python3.6/site-packages/powerline/bindings/vim/__init__.py&quot;, line 44, in &amp;lt;module&amp;gt;&#xA;    vim_encoding = get_vim_encoding()&#xA;  File &quot;/usr/lib/python3.6/site-packages/powerline/bindings/vim/__init__.py&quot;, &#xA;line 25, in get_vim_encoding&#xA;    return vim.options['encoding'].decode('ascii') or 'ascii'&#xA;AttributeError: 'str' object has no attribute 'decode'&#xA;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;NameError: name 'powerline_setup' is not defined&#xA;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;NameError: name 'powerline_setup' is not defined&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the CheckHealth report:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;========================================================================&#xA;## Configuration&#xA;  - SUCCESS: no issues found&#xA;&#xA;## Performance&#xA;  - SUCCESS: Build type: RelWithDebInfo&#xA;&#xA;## Remote Plugins&#xA;  - SUCCESS: Up to date&#xA;&#xA;## terminal&#xA;  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177&#xA;  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~&#xA;&#xA;health#provider#check&#xA;========================================================================&#xA;## Clipboard (optional)&#xA;  - SUCCESS: Clipboard tool found: xsel&#xA;&#xA;## Python 2 provider (optional)&#xA;  - INFO: `g:python_host_prog` is not set.  Searching for python2 in the environment.&#xA;  - INFO: Executable: /usr/bin/python2&#xA;  - INFO: Python2 version: 2.7.13&#xA;  - INFO: python2-neovim version: 0.1.13&#xA;  - SUCCESS: Latest python2-neovim is installed: 0.1.13&#xA;## Python 3 provider (optional)&#xA;  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.&#xA;  - INFO: Executable: /usr/bin/python3&#xA;  - INFO: Python3 version: 3.6.2&#xA;  - INFO: python3-neovim version: 0.1.13&#xA;  - SUCCESS: Latest python3-neovim is installed: 0.1.13&#xA;&#xA;## Ruby provider (optional)&#xA;  - INFO: Ruby: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]&#xA;  - INFO: Host: /home/sergio/bin/neovim-ruby-host&#xA;  - SUCCESS: Latest &quot;neovim&quot; gem is installed: 0.5.1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My .vimrc has: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python3 from powerline.vim import setup as powerline_setup&#xA;python3 powerline_setup()&#xA;python3 del powerline_setup&#xA;set laststatus=2&#xA;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2018-11-19T21:01:15.237" Title="Problem of neovim with powerline-status" Tags="|neovim|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14138" PostTypeId="2" ParentId="14135" CreationDate="2017-11-08T19:04:45.787" Score="6" Body="&lt;p&gt;See &lt;code&gt;help pythonx&lt;/code&gt; in Vim 8:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Because most python code can be written so that it works with python&#xA;  2.6+ and python 3 the pyx* functions and commands have been written.  They work exactly the same as the Python 2 and 3 variants, but select&#xA;  the Python version using the 'pyxversion' setting.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2017-11-08T19:04:45.787" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14139" PostTypeId="2" ParentId="388" CreationDate="2017-11-08T19:31:18.033" Score="1" Body="&lt;p&gt;I was looking for a way to use &lt;code&gt;pathogen&lt;/code&gt; but update easily and make it portable, so perhaps a &lt;code&gt;bash&lt;/code&gt; script might be helpful (using &lt;code&gt;vim-plug&lt;/code&gt; functionality)-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;&#xA;# inspired by https://github.com/thoughtbot/dotfiles/blob/master/hooks/post-up&#xA;&#xA;if [ ! -e &quot;$HOME&quot;/.vim/autoload/pathogen.vim ]; then&#xA;  curl -fLo &quot;$HOME&quot;/.vim/autoload/pathogen.vim --create-dirs \&#xA;      https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim&#xA;fi&#xA;&#xA;if [ -e &quot;$HOME&quot;/.vim/autoload/plug.vim ]; then&#xA;  vim -E -s +PlugUpgrade +qa&#xA;else&#xA;  curl -fLo &quot;$HOME&quot;/.vim/autoload/plug.vim --create-dirs \&#xA;      https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;fi&#xA;vim -u &quot;$HOME&quot;/.vimrc.bundles +PlugUpdate +PlugClean! +qa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then an example &lt;code&gt;.vimrc.bundle&lt;/code&gt;-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;installed via the Githubs&#xA;call plug#begin('~/.vim/bundle')&#xA;Plug 'bling/vim-airline'&#xA;Plug 'scrooloose/syntastic'&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'tpope/vim-fireplace'&#xA;Plug 'vim-scripts/paredit.vim'&#xA;&quot; etc&#xA;&#xA;call plug#end()&#xA;&#xA;&quot;disable vim-plug sugar-- actual config should be set via .vimrc&#xA;filetype plugin indent off &#xA;syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15030" LastEditorUserId="15030" LastEditDate="2017-11-08T19:36:50.267" LastActivityDate="2017-11-08T19:36:50.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14141" PostTypeId="1" AcceptedAnswerId="14142" CreationDate="2017-11-09T00:57:20.167" Score="3" ViewCount="2088" Body="&lt;p&gt;I have 2 buffers on eachother covering top and bottom of the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want ot open a third buffer on right split but the problem is is I make a right split it will only split the top right or bottom right because i have already a horizontal split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there any way to make a vertical or horizontal split on the main level while we have other splits?&lt;/p&gt;&#xA;" OwnerUserId="14587" LastActivityDate="2021-02-20T21:34:47.210" Title="How to open a vertical split to the main view not just next to the current one in case of horizontal splitted viewport?" Tags="|key-bindings|vim-windows|split|keyboard-layout|" AnswerCount="1" CommentCount="0" ClosedDate="2017-11-13T08:48:28.573" ContentLicense="CC BY-SA 3.0" />
  <row Id="14142" PostTypeId="2" ParentId="14141" CreationDate="2017-11-09T03:47:09.283" Score="5" Body="&lt;p&gt;&lt;strike&gt;There isn't one single builtin command to open the buffer &lt;em&gt;and&lt;/em&gt; position it, I don't believe.&lt;/strike&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Option #1&lt;/strong&gt;: &lt;em&gt;Well, it turns out there is. The &lt;code&gt;:botright {cmd}&lt;/code&gt; style of commands (e.g. &lt;code&gt;:botright vsplit&lt;/code&gt;). If @Mass provides an answer please accept that answer. I'll leave this for informational purposes as the Ctrl-W commands discussed at the end might still be of interest to some folks.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Option #2&lt;/strong&gt;: Create your own command with a mapping. For example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;vr &amp;lt;C-W&amp;gt;v&amp;lt;C-W&amp;gt;l&amp;lt;C-W&amp;gt;L&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I've chosen &lt;code&gt;vr&lt;/code&gt; to stand for Vertical Right. It will open a vertical split to the right of the current buffer, move the cursor into it, then move the new buffer to the &amp;quot;far right&amp;quot; which will cause it to span the full height of the window.&lt;/p&gt;&#xA;&lt;p&gt;In general, if you follow &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;W&lt;/kbd&gt; with one of &lt;kbd&gt;H&lt;/kbd&gt;, &lt;kbd&gt;K&lt;/kbd&gt;, &lt;kbd&gt;L&lt;/kbd&gt;, &lt;kbd&gt;J&lt;/kbd&gt; it will move the current buffer to the &lt;em&gt;far&lt;/em&gt; left/top/right/bottom, respectively, which means the buffer will fully span the window horizontally (if moved to far top/bottom) or vertically (far left/right).&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="10604" LastEditDate="2021-02-20T21:34:47.210" LastActivityDate="2021-02-20T21:34:47.210" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="14143" PostTypeId="2" ParentId="10939" CreationDate="2017-11-09T06:39:03.583" Score="9" Body="&lt;p&gt;One way is to do a regex search on &lt;code&gt;runtimepath&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if match(&amp;amp;runtimepath, 'MY-PLUGIN') != -1&#xA;    &quot; ...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you're using &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;noreferrer&quot;&gt;vim-plug&lt;/a&gt;, here's a general purpose method to check:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PlugLoaded(name)&#xA;    return (&#xA;        \ has_key(g:plugs, a:name) &amp;amp;&amp;amp;&#xA;        \ isdirectory(g:plugs[a:name].dir) &amp;amp;&amp;amp;&#xA;        \ stridx(&amp;amp;rtp, g:plugs[a:name].dir) &amp;gt;= 0)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if PlugLoaded('MY-PLUGIN')&#xA;    &quot; ...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7070" LastEditorUserId="7070" LastEditDate="2019-05-19T03:23:32.473" LastActivityDate="2019-05-19T03:23:32.473" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="14145" PostTypeId="1" AcceptedAnswerId="14149" CreationDate="2017-11-09T09:46:07.940" Score="4" ViewCount="950" Body="&lt;p&gt;I am on macOS.  My ultimate goal is to speed up &lt;a href=&quot;https://github.com/vim-scripts/dbext.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;dbext.vim&lt;/a&gt; and I found the page mentioned DBI which depends on &lt;code&gt;has('perl')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'd like to know how to build Neovim to have Perl enabled... Now I am using a neovim which was installed by &lt;code&gt;brew install neovim&lt;/code&gt; but it seems I have to build from sources to enable Perl.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also interested in the way how Deoplete made my nvim &lt;code&gt;has('python3')&lt;/code&gt; from 0 to 1 and didn't require a rebuild.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last but not least.. How do other plugins achieve Async operations?  I may see if it is possible to make dbext.vim run async so I will be less mindful of its speed...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2020-01-23T17:15:12.233" Title="How to build nvim to has_perl?" Tags="|neovim|async|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14146" PostTypeId="1" AcceptedAnswerId="14148" CreationDate="2017-11-09T09:58:09.660" Score="3" ViewCount="65" Body="&lt;p&gt;To open multiple files at a time I use this command (here using the vi tab feature):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -p file1 file2 ... fileN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I want to open a file at the end or at the first occurrence of a text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim + file1 or vim +/searchPattern file1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to combine these 2 operations? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;vim + file1 file2&lt;/code&gt; it works only for the first file.&lt;/p&gt;&#xA;" OwnerUserId="14685" LastEditorUserId="14685" LastEditDate="2017-11-09T12:48:31.660" LastActivityDate="2017-11-09T12:48:31.660" Title="Is it possible to open multiple files at the end or at the first occurrence of a string?" Tags="|search|multiple-files|startup|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14147" PostTypeId="1" CreationDate="2017-11-09T10:24:45.867" Score="1" ViewCount="498" Body="&lt;p&gt;MacOS Sierra 10.12.6 + iTerm2, build 3.1.4 + NeoVim 0.2.0_1.&lt;br&gt;&#xA;I run on iTerm a Tmux session loaded with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;teamocil [session]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In one of tmux windows there's an instance of nvim working smoothly, everything is displayed in its own place in all of the bottom three lines, from last one: tmux status bar, nvim command line, nvim status line.&#xA;Here's the relevant shot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LUlR3.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LUlR3.jpg&quot; alt=&quot;Everything in place&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In another tmux window I want to use a nvim session, sourced with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim -S [path to session.vim]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But here, in this nvim restored session, Tmux does not allow nvim to display messages in its command line, leaving no free lines between Tmux and nvim status lines. Whatever message displayed ovelaps status line, getting an unreadable mess. See following shot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WOA9O.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WOA9O.jpg&quot; alt=&quot;nvim session mess&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like nvim is not getting the correct terminal size when it starts session, either it is not reading it correctly or it is missing the WINCH signal.&#xA;Sending a &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;kill -WINCH $PID&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;signal from another shell solves the problem, so I adopted this as a temporary workaround, sending above command as a slightly delayed background process when opening tmux session.&#xA;But I think this is a neovim related issue and has to be fixed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to make it clear the problem appears only sourcing an existing nvim session inside Tmux.&#xA;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="15040" LastActivityDate="2017-11-09T10:24:45.867" Title="Nvim not getting correct terminal size opening session in tmux" Tags="|neovim|macos|tmux|" AnswerCount="0" CommentCount="1" ClosedDate="2017-11-10T10:20:27.037" ContentLicense="CC BY-SA 3.0" />
  <row Id="14148" PostTypeId="2" ParentId="14146" CreationDate="2017-11-09T10:43:52.750" Score="4" Body="&lt;p&gt;One workaround would be to use &lt;code&gt;:argdo&lt;/code&gt; (which runs an ex command in each file in the argument list):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +&quot;argdo norm G&quot; file1 file2&#xA;vim +&quot;argdo /searchPattern&quot; file1 file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will be left in the final file, so you'll need to manually invoke &lt;code&gt;:first&lt;/code&gt; to return to the beginning of the arglist, or add this as another command-line argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +&quot;argdo norm G&quot; +first file1 file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-09T10:54:23.733" LastActivityDate="2017-11-09T10:54:23.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14149" PostTypeId="2" ParentId="14145" CreationDate="2017-11-09T11:08:32.217" Score="3" Body="&lt;p&gt;Neovim is always compiled with all the features, so rebuilding won't help you: Perl support simply isn't included in the version of Neovim you are running. See (&lt;code&gt;:help feature-compile&lt;/code&gt;, &lt;code&gt;:help nvim-features-missing&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, later versions of Neovim &lt;a href=&quot;https://vi.stackexchange.com/a/22625/343&quot;&gt;&lt;em&gt;do&lt;/em&gt; include Perl support&lt;/a&gt;, so upgrading will add this feature for you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for your other question about Python, not all features require a re-compile to be enabled (see &lt;code&gt;:help feature-list&lt;/code&gt;). &lt;code&gt;has('python3')&lt;/code&gt; returns whether the Python 3 API is &lt;em&gt;currently available&lt;/em&gt;, not whether it was compiled in. (Which it was: see above.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Asynchronous operations are performed using &quot;jobs&quot;. See &lt;code&gt;:help job-control&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-23T17:15:12.233" LastActivityDate="2020-01-23T17:15:12.233" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14150" PostTypeId="1" CreationDate="2017-11-09T13:30:46.643" Score="1" ViewCount="4533" Body="&lt;p&gt;I have created this tab-separated file with Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#id    #comma separated values&#xA;0   d1,d2,cu&#xA;1   iii vvv,iii ccc,mmm ccc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function I use to read the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def read_file(filename):&#xA;    f = open(filename, 'r')&#xA;    raw = f.readlines()&#xA;    f.close()&#xA;    lines = [e.strip().split('\t') for e in raw if not e.startswith('#')]&#xA;    print lines&#xA;    out = dict()&#xA;    for line in lines:&#xA;        out[line[0]] = line[1].split(',') &#xA;    return out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[['0   d1,d2,cu'], ['1   iii vvv,iii ccc,mmm ccc']]&#xA;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;stdin&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;  File &quot;&amp;lt;stdin&amp;gt;&quot;, line 9, in read_file&#xA;IndexError: list index out of range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even though I am using &lt;code&gt;e.strip().split('\t')&lt;/code&gt; in the function, I get &lt;code&gt;[['0   d1,d2,cu'], ['1   iii vvv,iii ccc,mmm ccc']]&lt;/code&gt; as output instead of &lt;code&gt;[['0','d1,d2,cu'], ['1','iii vvv,iii ccc,mmm ccc']]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .vimrc file contains the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;colorscheme default&#xA;set incsearch&#xA;set hlsearch&#xA;set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does it mean that tabs in Vim are spaces ? How to make tabs in Vim be the same as &lt;code&gt;\t&lt;/code&gt; in python ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I edit the file in Gedit, the python function works as expected.&lt;/p&gt;&#xA;" OwnerUserId="15045" LastActivityDate="2019-04-04T07:46:46.640" Title="Tabs on Vim not interpreted as tabs inside python" Tags="|vimrc|filetype-python|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14151" PostTypeId="2" ParentId="14150" CreationDate="2017-11-09T13:48:52.080" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Does it mean that tabs in Vim are spaces ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, that is what &lt;code&gt;expandtab&lt;/code&gt; setting does. See &lt;code&gt;:h expandtab&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How to make tabs in Vim be the same as \t in python ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Change &lt;code&gt;expandtab&lt;/code&gt; to &lt;code&gt;noexpandtab&lt;/code&gt;. If you want to keep &lt;code&gt;expandtab&lt;/code&gt; setting for most of the time, and just in that particular scenario have real tabs instead of spaces, than you can try to add &lt;code&gt;autocommand&lt;/code&gt; based on a file type, or add a modeline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: set noexapndtab:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in those files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eventually, from &lt;code&gt;:h 'expandtab'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;To insert a real tab when 'expandtab' is on, use CTRL-V&amp;lt;Tab&amp;gt;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2017-11-09T13:48:52.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14152" PostTypeId="2" ParentId="9118" CreationDate="2017-11-09T14:15:51.697" Score="10" Body="&lt;p&gt;I don't have any evidence that this is why 79 was originally chosen, but one good reason to &lt;em&gt;leave&lt;/em&gt; it at that value is because if you use &lt;code&gt;'list'&lt;/code&gt; with a value included for &lt;code&gt;eol&lt;/code&gt; in &lt;code&gt;'listchars'&lt;/code&gt; then the display of the listchar will cause an 80-character-length line to wrap onto the next line in an 80-character-wide terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the line is only 79-characters long, then the 80th column is free for the end-of-line &lt;code&gt;listchar&lt;/code&gt; to sit in.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-10T17:01:47.403" LastActivityDate="2017-11-10T17:01:47.403" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14154" PostTypeId="1" CreationDate="2017-11-10T06:33:23.083" Score="0" ViewCount="90" Body="&lt;h1&gt;background&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;So I have the silver search thing going: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; The Silver Searcher&#xA;if executable('ag')&#xA;  &quot; Use ag over grep&#xA;  let &amp;amp;grepprg = &quot;ag --nogroup --nocolor --ignore wiki --ignore tags&quot;&#xA;&#xA;  &quot; Use ag in CtrlP for listing files. Lightning fast and respects .gitignore&#xA;  let g:ctrlp_user_command = 'ag %s -l --nocolor -g &quot;&quot;'&#xA;&#xA;  &quot; ag is fast enough that CtrlP doesn't need to cache&#xA;  let g:ctrlp_use_caching = 0&#xA;endif&#xA;&#xA;&#xA;&quot; bind \ (backward slash) to grep shortcut&#xA;command -nargs=+ -complete=file -bar Ag silent! grep! &amp;lt;args&amp;gt;|cwindow|redraw!&#xA;nnoremap \ :Ag&amp;lt;SPACE&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I click on &lt;kbd&gt;\&lt;/kbd&gt; I get the prompt to search, which is great, it looks like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/v3oA7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/v3oA7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got three questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;how do I dismiss the bottom bar? I'm not sure what that action is called.. ideally I would connect that to some keyboard binding&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How can i make it so that when i click on a file (or perform some keybinding on a file in the list below).. it automatically jumps to the file AND dismiss the bottom bar?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;how can I (with a keyboard shortuct) make the bottom bar &lt;em&gt;higher&lt;/em&gt; and &lt;em&gt;smaller&lt;/em&gt;? sometimes that's useful when i got tonnes of results&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;many thanks&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="14510" LastEditDate="2017-11-10T06:54:28.797" LastActivityDate="2017-11-10T09:33:57.853" Title="How to dismiss the bottom search bar" Tags="|the-silver-searcher|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14155" PostTypeId="1" CreationDate="2017-11-10T08:49:08.360" Score="5" ViewCount="2362" Body="&lt;p&gt;I'm using the &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;noreferrer&quot;&gt;vim-fugitive&lt;/a&gt; plugin for git blame annotations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I'm on a certain line, I type &lt;code&gt;:Gblame&lt;/code&gt; and it shows me the git commits:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ruD4I.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ruD4I.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I click on a git commit hash, I go to it, how can go back to the original view?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus: how can I make the git hash appear on a split view instead of jumping to it?&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="1841" LastEditDate="2017-11-10T10:16:20.197" LastActivityDate="2017-11-10T16:48:05.540" Title="How do I go back when I view a certain git hash" Tags="|plugin-fugitive|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14156" PostTypeId="2" ParentId="14154" CreationDate="2017-11-10T09:33:57.853" Score="1" Body="&lt;p&gt;It's called the quickfix window. (See &lt;code&gt;:h quickfix&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;It can be dismissed with the command &lt;code&gt;:cclose&lt;/code&gt; or with any regular window command. e.g. &lt;kbd&gt;Ctrl-W&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt; or &lt;kbd&gt;Ctrl-W&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;One way you could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; &amp;amp;buftype=='quickfix' ? &quot;\&amp;lt;CR&amp;gt;:cclose\&amp;lt;CR&amp;gt;&quot; : &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another alternative would be to use an autocommand to create a buffer-local mapping only in the quickfix window, or just to use a new trigger for your jump-to-error-and-close mapping. (e.g. &lt;code&gt;&amp;lt;leader&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use the regular window resizing commands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-W&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-W&lt;/kbd&gt;&lt;kbd&gt;-&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These take counts, so you can resize more rapidly with commands such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;Ctrl-W&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-11-10T09:33:57.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14157" PostTypeId="2" ParentId="14155" CreationDate="2017-11-10T10:11:51.497" Score="1" Body="&lt;p&gt;&lt;strong&gt;&lt;em&gt;Update&lt;/strong&gt;: I read &quot;original view&quot; in the question as referring to the git blame view. If instead it is meant to refer to the source code file, then &lt;a href=&quot;https://vi.stackexchange.com/a/14158/343&quot;&gt;@statox's answer&lt;/a&gt; is the correct one.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think fugitive provides a mechanism for going back to the previous blame view.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you make a note of the buffer number &lt;em&gt;before&lt;/em&gt; you jump to the commit (with commands such as &lt;code&gt;:ls!&lt;/code&gt; or &lt;code&gt;:echo bufnr(&quot;&quot;)&lt;/code&gt;), then you can jump back to it by passing a &lt;code&gt;count&lt;/code&gt; to the &lt;code&gt;:b&lt;/code&gt; command, but fugitive's mappings no longer appear to be set up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can make the hash appear in a split view instead of jumping to it by pressing &lt;kbd&gt;o&lt;/kbd&gt; instead of &lt;kbd&gt;Enter&lt;/kbd&gt;. (See &lt;code&gt;:help :Gblame&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-10T14:35:06.250" LastActivityDate="2017-11-10T14:35:06.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14158" PostTypeId="2" ParentId="14155" CreationDate="2017-11-10T10:14:38.160" Score="7" Body="&lt;p&gt;You can use the jump list to go back to your file: pressing &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt; will bring you back to the top of the commit file and pressing it a second time will bring you back to the file you were editing. (see &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#CTRL-O&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h CTRL-O&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#jumplist&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h jumplist&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To open the commit in a split window &lt;a href=&quot;https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt#L210-L228&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h fugitive-:Gblame&lt;/code&gt;&lt;/a&gt; tells you that you can use &lt;kbd&gt;o&lt;/kbd&gt; when you are on the commit line. You can also use &lt;kbd&gt;shift&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt; to open it in a new tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: Instead of clicking on the commit hash you can also use &lt;kbd&gt;Enter&lt;/kbd&gt; to go to the commit message.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-11-10T10:14:38.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14159" PostTypeId="1" AcceptedAnswerId="14160" CreationDate="2017-11-10T12:00:17.810" Score="1" ViewCount="649" Body="&lt;p&gt;I'm following the instructions &lt;a href=&quot;https://mutelight.org/minimal-guide-to-debugging-php-with-xdebug-and-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; to setup xdebug on my local machine on vim. Everything went smooth, until I reached this part:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To initialize a debugging session, XDebug will attempt to make a&#xA;  connection to the remote host and port that you specified above&#xA;  (localhost:9000), so you need to make sure that your Vim is reachable&#xA;  at that address. Unless you're running Vim on the same server as PHP,&#xA;  this may involve building an SSH tunnel back to your development box.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When I run my server locally, I do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;php artisan serve --host 0.0.0.0 --port 8000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and as instructed, pressing F5 will make vim listen to port 9000:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;waiting for a new connection on port 9000 for 10 seconds...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So basically, I want all connections to port 9000 to actually reach my php server at port 8000..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;using &lt;a href=&quot;http://www.revsys.com/writings/quicktips/ssh-tunnel.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;ssh tunnel&lt;/a&gt;, I run this command (which is &lt;code&gt;-L local-port:host:remote-port&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ssh -L 9000:localhost:8000 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but then i get this obnoxious error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ssh -L 9000:localhost:8000&#xA;usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]&#xA;           [-D [bind_address:]port] [-E log_file] [-e escape_char]&#xA;           [-F configfile] [-I pkcs11] [-i identity_file]&#xA;           [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]&#xA;           [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]&#xA;           [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]&#xA;           [user@]hostname [command]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;So based on &lt;a href=&quot;https://vi.stackexchange.com/a/14160/14510&quot;&gt;this&lt;/a&gt; answer.. I simply did the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my xdebug config (located in: &lt;code&gt;/usr/local/etc/php/7.1/conf.d/ext-xdebug.ini&lt;/code&gt;, which I got by running &lt;code&gt;php --ini&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;zend_extension=&quot;/usr/local/Cellar/php71-xdebug/2.5.5/xdebug.so&quot;&#xA;xdebug.remote_enable=1&#xA;xdebug.remote_host=localhost&#xA;xdebug.remote_port=8000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I run my php server as mentioned before (no ssh tunnel)&#xA;I create a breakpoint in my vi by typing &lt;code&gt;:Bp&lt;/code&gt;&#xA;on my vi, I type &lt;kbd&gt;F5&lt;/kbd&gt; then I ge this message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;waiting for a new connection on port 9000 for 10 seconds...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then I immediately go to my postman and run a commmand that hits this endpoint:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://localhost:8000/api/users/login?XDEBUG_SESSION_START=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but then nothing happens (actually postman hangs), then i get this message from vim: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connection Timeout&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what am I missing?&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="14510" LastEditDate="2018-02-16T11:10:16.457" LastActivityDate="2018-02-16T11:10:16.457" Title="how to point xdebug back to vim on local host" Tags="|ssh|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14160" PostTypeId="2" ParentId="14159" CreationDate="2017-11-10T12:17:00.317" Score="2" Body="&lt;p&gt;I think you're misreading the instructions. You don't need to connections on port 9000 to be &lt;em&gt;re-directed&lt;/em&gt; to port 8000. You just need your PHP server to be able to contact your Vim instance.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To initialize a debugging session, XDebug will attempt to make a connection to the remote host and port that you specified above (localhost:9000), so you need to make sure that your Vim is reachable at that address. &lt;strong&gt;&lt;em&gt;Unless you're running Vim on the same server as PHP&lt;/em&gt;&lt;/strong&gt;, this may involve building an SSH tunnel back to your development box.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;are&lt;/em&gt; running Vim on the same server as PHP, so you don't need an SSH tunnel. It should just work when you perform the next step of the tutorial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sidenote: The error message is simply SSH's usage, which is always printed if you enter a malformed ssh command. In this case, I agree that it's not particularly helpful: &lt;a href=&quot;https://www.howtogeek.com/168145/how-to-use-ssh-tunneling/&quot; rel=&quot;nofollow noreferrer&quot;&gt;try this page&lt;/a&gt; or &lt;a href=&quot;https://freddebostrom.wordpress.com/2009/04/10/ssh-tunnel-from-the-command-line/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt; for a better explanation of what SSH tunnels are and how to set them up. (Which, again, you don't actually need to do in this instance.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-10T12:33:30.177" LastActivityDate="2017-11-10T12:33:30.177" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14161" PostTypeId="2" ParentId="14159" CreationDate="2017-11-10T13:54:03.917" Score="0" Body="&lt;p&gt;Basically the thing that confused me about this was the different actors/settings files. Let's be clear about who they are and what they're doing:&lt;/p&gt;&#xA;&lt;h2&gt;PHP&lt;/h2&gt;&#xA;&lt;p&gt;It's both server AND client:&lt;br /&gt;&#xA;&lt;strong&gt;http server&lt;/strong&gt;: it listens for http clients on port 8000&lt;br /&gt;&#xA;&lt;strong&gt;xdebug client&lt;/strong&gt;: connects to the xdebug server on port 9000&lt;/p&gt;&#xA;&lt;h2&gt;vim&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;xdebug server:&lt;/strong&gt;, it serves the php client, &lt;em&gt;using&lt;/em&gt; the Xdebug protocol (ie the same way http is a protocol).&lt;/p&gt;&#xA;&lt;p&gt;php had it's own settings file (present in either &lt;code&gt;php.ini&lt;/code&gt; or &lt;code&gt;/usr/local/etc/php/7.1/conf.d/ext-xdebug.ini&lt;/code&gt;, and it had the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;..&#xA;xdebug.remote_port=8000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;the thing that got me confused was that although this file specified the port as 8000, when i ran the debugger on vim, the status message was:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;waiting for a new connection on port 9000 for 10 seconds...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which made me go all , then I realized (with some help) that the vim settings has port 9000 &lt;a href=&quot;https://github.com/vim-scripts/DBGp-Remote-Debugger-Interface/blob/master/plugin/debugger.vim#L53-L54&quot; rel=&quot;nofollow noreferrer&quot;&gt;by default&lt;/a&gt;, and that port was &lt;em&gt;different&lt;/em&gt; than the xdebug port..&lt;/p&gt;&#xA;&lt;p&gt;my problem is that the xdebug port was set to 8000, whereas the vim one was set to 9000 (again by default).&lt;/p&gt;&#xA;&lt;p&gt;so fixing the problem was simply changing the above in the xdebug config to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xdebug.remote_port=9000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and that's it!&lt;/p&gt;&#xA;&lt;h1&gt;bonus&lt;/h1&gt;&#xA;&lt;p&gt;an alias to debug stuff with php unit&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function debugMethod() {&#xA;    php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 ./vendor/bin/phpunit --filter $1 $2 /path/to/tests/$3/$2.php&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-02-16T11:08:39.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14162" PostTypeId="1" AcceptedAnswerId="14163" CreationDate="2017-11-10T14:28:05.053" Score="2" ViewCount="891" Body="&lt;p&gt;I am using vim on Windows and have following mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;f4&amp;gt; &amp;lt;ESC&amp;gt;:w&amp;lt;CR&amp;gt;:!clang -std=c++11 -o output\%.exe %&amp;lt;CR&amp;gt;&#xA;imap &amp;lt;f5&amp;gt; &amp;lt;ESC&amp;gt;:!output\%.exe&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As we know in windows &lt;code&gt;\&lt;/code&gt; is path separator &lt;code&gt;\&lt;/code&gt; also used in escape sequences in vim-script and commands this command gives me out put as sown in pic.&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/zTG17.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zTG17.png&quot; alt=&quot;output I am getting&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;What I want is shown in the following pic&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ano8p.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ano8p.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My intention is to compile the source and return the output in the 'output' directory  and execute from there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, I get 'output%' as output in the current directory.&lt;/p&gt;&#xA;" OwnerUserId="14887" LastEditorUserId="11054" LastEditDate="2017-11-12T13:51:18.070" LastActivityDate="2017-11-12T13:51:18.070" Title="How to account for special characters \% in mapping" Tags="|key-bindings|external-command|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14163" PostTypeId="2" ParentId="14162" CreationDate="2017-11-10T15:20:28.403" Score="1" Body="&lt;p&gt;First off, you should always use &lt;code&gt;inoremap&lt;/code&gt; rather than &lt;code&gt;imap&lt;/code&gt; (with a small number of exceptions that are not relevant here).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difficulty here is that as soon as &lt;code&gt;%&lt;/code&gt; is put after &lt;code&gt;\&lt;/code&gt;, the backslash goes from path component to escaping character. The only way I could prevent that is to use an expression (&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; on lhs of the mapping) so I could use &lt;code&gt;expand(&quot;%&quot;)&lt;/code&gt; in it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;f4&amp;gt; '&amp;lt;ESC&amp;gt;:w&amp;lt;CR&amp;gt;&amp;lt;ESC&amp;gt;:!clang -std=c++11 -o output\' . expand(&quot;%&quot;) . '.exe ' . expand(&quot;%&quot;) . '&amp;lt;CR&amp;gt;'&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;f5&amp;gt; '&amp;lt;ESC&amp;gt;:!output\' . expand(&quot;%&quot;) . '.exe&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update :&lt;/strong&gt; Actually I found a way to do this without &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;. The second &quot;Note&quot; under &lt;code&gt;:help E809&lt;/code&gt; says that double quotes can be used to isolate &lt;code&gt;%&lt;/code&gt; while retaining its special meaning. It looks a little strange on the &lt;code&gt;cmd.exe&lt;/code&gt; command line but it works in my tests.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;f4&amp;gt; &amp;lt;ESC&amp;gt;:w&amp;lt;CR&amp;gt;&amp;lt;ESC&amp;gt;:!clang -std=c++11 -o output\&quot;%&quot;.exe %&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;f5&amp;gt; &amp;lt;ESC&amp;gt;:!output\&quot;%&quot;.exe&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-11-12T13:48:34.270" LastActivityDate="2017-11-12T13:48:34.270" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14164" PostTypeId="1" CreationDate="2017-11-10T16:39:32.357" Score="2" ViewCount="450" Body="&lt;p&gt;I know I can enter diff mode in vim by calling &lt;code&gt;diffsplit &amp;lt;filename&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also know I can call an external command and replace the file contents with its output (e.g. &lt;a href=&quot;https://vi.stackexchange.com/a/321/15057&quot;&gt;in this answer someone uses a json formatting tool&lt;/a&gt; by calling &lt;code&gt;:%!python -m json.tool&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say I wanted to do something similar, but wanted to see the diff of the current file and the output of the json formatter, and choose which changes to keep. How can I sent the output of the tool to &lt;code&gt;diffsplit&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I could send the output of the formatter to a file in /tmp or something and then do vimdiff on the file from there. But it would be nice to avoid having to read and write an extra file to/from disk.&lt;/li&gt;&#xA;&lt;li&gt;I mainly want to do this for the whole file. If there's a way to send a specific range to the formatter and then diff that range (or diff the result of the command glued into the original file) that would be a nice bonus.&lt;/li&gt;&#xA;&lt;li&gt;I am not actually using a json formatter but am looking for a generic solution that would work for this situation (and similar).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="15057" LastActivityDate="2017-11-11T17:45:13.883" Title="Diffsplit with output of external command in Vim?" Tags="|external-command|vimdiff|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14165" PostTypeId="2" ParentId="14155" CreationDate="2017-11-10T16:48:05.540" Score="0" Body="&lt;p&gt;I would suggest you use &lt;code&gt;o&lt;/code&gt; or &lt;code&gt;O&lt;/code&gt; to open commit in a split or net tab. That way the blame is still there and you can use it as a reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;g?&lt;/code&gt; to see &lt;code&gt;:Gblame&lt;/code&gt;'s help or go to &lt;code&gt;:h fugitive-:Gblame&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-11-10T16:48:05.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14166" PostTypeId="1" CreationDate="2017-11-10T17:10:31.077" Score="4" ViewCount="914" Body="&lt;p&gt;I have two different plugins doing different things while writing Go. Sometimes the plugin that runs the testing (vim-go) will write to the quickfix window, while the plugin that does linting (ALE) writes to the location list. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If they happen to be open and modified at the same time, I get a weird resize of the window until it takes up the whole screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone seen anything like this before? Is there a way I can set a hard window size that cannot be changed?&lt;a href=&quot;https://i.stack.imgur.com/iFP74.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iFP74.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13719" LastEditorUserId="51" LastEditDate="2017-11-29T02:55:16.363" LastActivityDate="2017-11-29T02:55:45.957" Title="quickfix window and location list open at the same time causes weird resize" Tags="|quickfix|window-management|filetype-go|plugin-ale|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14167" PostTypeId="2" ParentId="14164" CreationDate="2017-11-10T19:50:47.313" Score="0" Body="&lt;p&gt;Here is what I came up with for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup FormatDiff&#xA;  autocmd!&#xA;  autocmd TextChanged * if &amp;amp;diff &amp;amp;&amp;amp; get(g:, 'diff_format_prg', '') != '' | silent execute '%!'.g:diff_format_prg | let g:ignore = 1 | diffupdate | unlet g:ignore | | endif&#xA;  autocmd FilterWritePre if &amp;amp;diff &amp;amp;&amp;amp; get(g:, 'diff_format_prg', '') != '' &amp;amp;&amp;amp; get(g:, 'ingore', 0) == 0 | silent execute '%!'.g:diff_format_prg | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then did &lt;code&gt;let g:diff_format_prg = 'jq -S .'&lt;/code&gt;. Followed by by &lt;code&gt;:diffsplit anotherfile.json&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The overview:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try and run the formatter on the very first diff e.g. &lt;code&gt;:diffpslit&lt;/code&gt;. And then for subsequent file changes (&lt;code&gt;TextChange&lt;/code&gt;) run formatter and then do &lt;code&gt;:diffupdate&lt;/code&gt; without triggering an extra formatting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some thoughts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I am not sure how I feel about auto-fromatting on &lt;code&gt;TextChange&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Probably need to check for buffer-local variables instead of just global, &lt;code&gt;g:diff_format_prg&lt;/code&gt;, if this was to be generalized&lt;/li&gt;&#xA;&lt;li&gt;Need a better way of displaying formatter errors or handling them at all&lt;/li&gt;&#xA;&lt;li&gt;Will fire on all filter commands in a diff'ed buffer (unexpected)&lt;/li&gt;&#xA;&lt;li&gt;I am not certain how this could be applied to just a specific buffer range&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h TextChange&#xA;:h FilterWritePre&#xA;:h get()&#xA;:h b:&#xA;:h g:&#xA;:h :range!&#xA;:h diff&#xA;:h diffupdate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-11-10T19:50:47.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14168" PostTypeId="2" ParentId="4919" CreationDate="2017-11-10T21:15:06.587" Score="3" Body="&lt;p&gt;If you are using Tmux, you may have installed some &quot;vim-like&quot; bindings to move around in the window panes which among other things grab the &quot;C-\&quot; before Vim has a chance to use it. If so, remove these from your &lt;code&gt;.tmux.conf&lt;/code&gt; and restart tmux:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&#xA;bind-key -n C-\ if-shell &quot;$is_vim&quot; &quot;send-keys C-\\&quot; &quot;select-pane -l&quot;&lt;br&gt;&#xA;bind-key -T copy-mode-vi C-\ select-pane -l&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6094" LastActivityDate="2017-11-10T21:15:06.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14169" PostTypeId="2" ParentId="6637" CreationDate="2017-11-10T21:59:12.370" Score="2" Body="&lt;p&gt;There's another possibility that has not been addressed in the other answers: vim will refuse to save a file if it is open and locked by another Windows application. Many ordinary Windows apps (Office, for example) lock files that they open. If this is the problem, no amount of messing with permissions or :w! will help you. You simply need to close the file in the other app, and then you will be able to save it from vim. It is unfortunate that vim does not clearly signal this situation to the user.&lt;/p&gt;&#xA;" OwnerUserId="15059" LastActivityDate="2017-11-10T21:59:12.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14172" PostTypeId="2" ParentId="14164" CreationDate="2017-11-11T17:45:13.883" Score="1" Body="&lt;p&gt;I have this one-liner and I hope this helps:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:vnew | setlocal buftype=nofile | exec &quot;read !ls -l&quot; | windo diffthis&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may (and probably will) replace &lt;code&gt;ls -l&lt;/code&gt; with any other commands, and you may need &lt;code&gt;shellescape()&lt;/code&gt; and &lt;code&gt;expand()&lt;/code&gt; to compose your shell command for &lt;code&gt;exec&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding sending selected lines to the command line, you may better do a function, as after &lt;code&gt;vnew&lt;/code&gt; it may be hard to get the selected lines (unless you have yanked it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope these helps: &lt;code&gt;:h buftype&lt;/code&gt; &lt;code&gt;:h exec&lt;/code&gt; &lt;code&gt;:h read!&lt;/code&gt; &lt;code&gt;:h windo&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2017-11-11T17:45:13.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14173" PostTypeId="1" AcceptedAnswerId="14186" CreationDate="2017-11-12T11:49:22.260" Score="1" ViewCount="1279" Body="&lt;p&gt;I'm new to Vim and would like to know is there a plugin, which allows you to call Python help() function on the word under cursor and shows returned text in the splitter buffer?&lt;/p&gt;&#xA;" OwnerUserId="15076" LastActivityDate="2017-11-13T17:52:20.530" Title="Show python help() inside vim" Tags="|plugin-system|filetype-python|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14174" PostTypeId="1" CreationDate="2017-11-12T13:53:05.877" Score="7" ViewCount="2240" Body="&lt;p&gt;I'm using cmder as my Win7 shell. I see the following behaviour:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Works fine (file in current directory):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works fine (absolute path):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim ~/test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works fine (relative path with forward slash):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim subdir/test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does not work fine (relative path with backward slash):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim subdir\test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last example flashes the following in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E303: Unable to open swap file for &quot;subdir\test&quot;, recovery impossible.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doing &lt;code&gt;:set dir&lt;/code&gt; shows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;directory=~/vimswap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which exists and is permissioned correctly (after all, I don't get errors when opening absolute path files, only relative path ones).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect this might have something to do with how cmder/vim represent relative paths - maybe a forward slash/backslash issue?&lt;/p&gt;&#xA;" OwnerUserId="15077" LastEditorUserId="343" LastEditDate="2017-11-14T22:16:25.503" LastActivityDate="2023-12-22T07:07:56.000" Title="Vim error: Unable to open swap file when using backslash as path separator in Windows shell" Tags="|microsoft-windows|swap-file|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14178" PostTypeId="1" AcceptedAnswerId="14214" CreationDate="2017-11-12T20:17:06.307" Score="0" ViewCount="119" Body="&lt;p&gt;Actually I set these options in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4&#xA;set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But everywhere I saw (esp in &lt;a href=&quot;http://vim.wikia.com/wiki/Example_vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim.wikia&lt;/a&gt;) they set different tab option as mine.&#xA;like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shiftwidth=4&#xA;set softtabstop=4&#xA;set softtabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I am confused, Are they same in function?&#xA;Is there any difference between these tab options in vim behaviour?&#xA;Please let me know how I can set my tab options comfortably.&lt;/p&gt;&#xA;" OwnerUserId="15007" LastEditorUserId="7267" LastEditDate="2017-11-14T08:39:37.123" LastActivityDate="2017-11-15T07:36:07.627" Title="Is there any diff between these opions in behaviour?" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14181" PostTypeId="1" CreationDate="2017-11-13T04:23:18.167" Score="1" ViewCount="140" Body="&lt;p&gt;My intention is to facilitate investigation of deeply buried code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, an error is thrown with message &quot;ABC Error&quot; and if &lt;code&gt;|&lt;/code&gt; is where the cursor is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function handleRequest(req) {&#xA;  let param = req.toJSON();&#xA;  if ( param['get'] ) {&#xA;    param['data'].sanitize()&#xA;      .then( d =&amp;gt; {&#xA;        ...&#xA;      })&#xA;      .catch( e =&amp;gt; { alert(&quot;ABC Error&quot;) });|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want the end result to be something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function handleRequest(req) {&#xA;  if ( param['get'] ) {&#xA;    param['data'].sanitize()&#xA;      .catch( e =&amp;gt; { alert(&quot;ABC Error&quot;) });|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The algorithm would be like, getting the &lt;code&gt;indent('.')&lt;/code&gt; and find lines above and fold it -- unless it has a lower indent, and update the current indent until the current indent level reaches 0.  (I know that this would not work very well with &lt;code&gt;else&lt;/code&gt; clauses)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas are welcomed.  &lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2017-11-13T04:23:18.167" Title="How to fold lines above the current unless it has less indentation than the current" Tags="|vimscript|folding|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14182" PostTypeId="2" ParentId="14173" CreationDate="2017-11-13T09:02:07.940" Score="4" Body="&lt;p&gt;It is built-in, have a look at &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#K&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h K&lt;/code&gt;&lt;/a&gt;, it says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;K           Run a program to lookup the keyword under the&#xA;            cursor.  The name of the program is given with the&#xA;            'keywordprg' (kp) option (default is &quot;man&quot;).  The&#xA;            keyword is formed of letters, numbers and the&#xA;            characters in 'iskeyword'.  The keyword under or&#xA;            right of the cursor is used.  The same can be done&#xA;            with the command&#xA;                :!{program} {keyword}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On my setup &lt;code&gt;keywordprg&lt;/code&gt; is set to &lt;code&gt;pydoc&lt;/code&gt; automatically and thus hitting &lt;kbd&gt;shift&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; will show the &lt;code&gt;pydoc&lt;/code&gt; entry for the current word (of course you need &lt;code&gt;pydoc&lt;/code&gt; installed but I think it comes with the &lt;code&gt;python&lt;/code&gt; package).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need something else you can simply install your prefered help program and set &lt;code&gt;keywordprg&lt;/code&gt; accordingly without having to install a plugin.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-11-13T09:02:07.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14184" PostTypeId="2" ParentId="14089" CreationDate="2017-11-13T11:31:32.453" Score="1" Body="&lt;p&gt;So after all the Problem is, that &lt;code&gt;UltiSnips&lt;/code&gt; does not search the projectfolder for snippets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you read &lt;code&gt;:h UltiSnips-snippet-search-path&lt;/code&gt; you can see, that it looks for all folders defined in &lt;code&gt;g:UltiSnipsSnippetDirectories&lt;/code&gt; which are subfolders of a directory defined in the &lt;code&gt;runtimepath&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h runtimepath&lt;/code&gt; shows that this depending on the OS but mostly something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                    Unix: &quot;$HOME/.vim,&#xA;                    $VIM/vimfiles,&#xA;                    $VIMRUNTIME,&#xA;                    $VIM/vimfiles/after,&#xA;                    $HOME/.vim/after&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if you have a plugin manager, the runtimepath will be manipulated. So every folder in your &lt;code&gt;.vim/bundle&lt;/code&gt; directory will be added to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thats a fact &lt;code&gt;UltiSnips&lt;/code&gt; actually uses for snippets in plugins.&#xA;the &lt;code&gt;vim-snippets&lt;/code&gt; Plugin for example has a folder &lt;code&gt;UltiSnips&lt;/code&gt; which is automatically read by &lt;code&gt;UltiSnips&lt;/code&gt; since the pluginmanager will add the plugin to the &lt;code&gt;runtimepath&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for you that means, keep all your snippets in a &lt;code&gt;UltiSnips&lt;/code&gt; folder somewhere in the &lt;code&gt;runtimepath&lt;/code&gt;. Usually &lt;code&gt;~/.vim/UltiSnips&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no possibility for projectspecific snippets (There may be a plugin for that). And I see no reason why there should be projectspecific snippets other then different coding styles. But that is handled by other instruments. If you are interested here is a disscusion about it: &lt;a href=&quot;https://github.com/SirVer/ultisnips/issues/222&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/SirVer/ultisnips/issues/222&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your issue with the &lt;code&gt;UltiSnipsEdit&lt;/code&gt; command there is a &lt;code&gt;g:UltiSnipsSnippetsDir&lt;/code&gt; variable. see &lt;code&gt;:h UltiSnipsEdit&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11316" LastEditorUserId="11316" LastEditDate="2017-11-13T11:42:32.887" LastActivityDate="2017-11-13T11:42:32.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14185" PostTypeId="1" AcceptedAnswerId="14187" CreationDate="2017-11-13T13:26:07.077" Score="3" ViewCount="341" Body="&lt;p&gt;Because I'm on a german keyboard layout &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; are relatively hard to type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a workaround especially for latex I used &lt;code&gt;inoremap &amp;lt;C-j&amp;gt; {&lt;/code&gt; and &lt;code&gt;inoremap &amp;lt;C-l&amp;gt; }&lt;/code&gt; which works great. After internalizing these I also tried to use them in all other modes via &lt;code&gt;noremap &amp;lt;C-j&amp;gt; {&lt;/code&gt; e.g. such that &lt;code&gt;/&amp;lt;C-j&amp;gt;&lt;/code&gt; would search for &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;ci&amp;lt;C-j&amp;gt;&lt;/code&gt; change in curly braces, but this doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried &lt;code&gt;onoremap&lt;/code&gt; and &lt;code&gt;lnoremap&lt;/code&gt; which both failed. But it does work in normal mode i.e. &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; moves a paragraph backward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I understand &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;c&lt;/code&gt; should both go into &quot;operator-pending&quot; mode, so that &lt;code&gt;map&lt;/code&gt; and &lt;code&gt;omap&lt;/code&gt; should both work. I also couldn't find information that &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; is &quot;special&quot; like &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt;, and I guess in that case &lt;code&gt;imap&lt;/code&gt; shouldn't work either. Am I overlooking something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested this on vim 7.4 with an empty config.&lt;/p&gt;&#xA;" OwnerUserId="533" LastEditorUserId="1841" LastEditDate="2017-11-13T15:37:13.830" LastActivityDate="2017-11-13T17:35:26.780" Title="noremap &lt;C-j&gt; to {" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14186" PostTypeId="2" ParentId="14173" CreationDate="2017-11-13T13:44:03.640" Score="1" Body="&lt;p&gt;If you are also looking for other python features (or don't mind disabling features you don't want to have) I can recommend &lt;a href=&quot;https://github.com/davidhalter/jedi-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;jedi-vim&lt;/a&gt;. Its main feature is autocompletion, but it has some other features like show help (K), show usages, rename and goto following imports. If you use something like &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;nofollow noreferrer&quot;&gt;youcompleteme&lt;/a&gt; you probably already use the jedi library for python autocompletion (and if you want to use the other jedi-vim features together with YCM you should deactivate the jedi-vim autocompletion).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I never really used default &lt;code&gt;K&lt;/code&gt; for python files, but a single short test seems to indicate that jedi-vim &lt;code&gt;K&lt;/code&gt; can show docs for stuff where default-vim &lt;code&gt;K&lt;/code&gt; fails.&lt;/p&gt;&#xA;" OwnerUserId="533" LastActivityDate="2017-11-13T13:44:03.640" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14187" PostTypeId="2" ParentId="14185" CreationDate="2017-11-13T13:48:53.413" Score="3" Body="&lt;h2&gt;/&amp;lt;C-j&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/&lt;/code&gt; doesn't enter operator-pending mode, it enters command-line mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this, you want &lt;code&gt;noremap!&lt;/code&gt; which applies to insert mode and command-line mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help map-modes&lt;/code&gt; does imply that your attempt of &lt;code&gt;lnoremap&lt;/code&gt; should have worked, but &lt;code&gt;:help language-mapping&lt;/code&gt;, a bit further down in the file, explains why this is not the case:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Generally: Whenever a character is to be typed that is part of the text in the buffer, not a Vim command character.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[Language mappings] are only used for typed characters.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help i_CTRL-j&lt;/code&gt; links to the insert-mode documentation's &quot;Special keys&quot; section: &lt;code&gt;Ctrl-J&lt;/code&gt; is not a character which gets inserted into the buffer, but instead is a control character that tells Vim to begin a new line&lt;sup&gt;*&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;ci&amp;lt;C-j&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;c&lt;/code&gt; &lt;em&gt;does&lt;/em&gt; enter operator pending mode, and you will find after having run &lt;code&gt;onoremap &amp;lt;C-j&amp;gt; {&lt;/code&gt; as you describe, that &lt;code&gt;c&amp;lt;c-j&amp;gt;&lt;/code&gt; works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is &lt;code&gt;ci{&lt;/code&gt; works differently to how you are imagining. In this command the &lt;em&gt;two&lt;/em&gt; keystrokes &lt;code&gt;i{&lt;/code&gt; are a text object (&lt;code&gt;:help text-objects&lt;/code&gt;), and operator-pending mode maps don't apply in the middle of text objects. I think the fix for these will require a bit more verbosity:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap i&amp;lt;c-j&amp;gt; i{&#xA;onoremap a&amp;lt;c-j&amp;gt; a{&#xA;&quot; etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* If you're thinking that this is just a roundabout way of saying that a &lt;code&gt;LF&lt;/code&gt; character is inserted when you type one, consider how Vim will save different bytes into the file depending on the current value of &lt;code&gt;'fileformat'&lt;/code&gt;&amp;#8202;&amp;mdash;&amp;#8202;it's a subtle distinction, I agree.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-13T17:35:26.780" LastActivityDate="2017-11-13T17:35:26.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14189" PostTypeId="2" ParentId="11336" CreationDate="2017-11-13T16:28:13.773" Score="0" Body="&lt;p&gt;I discovered, on OpenSUSE that the binary file is renamed when installing the gem. So on my computer I need to set have this line in my &lt;code&gt;init.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:ruby_host_prog=&quot;/usr/bin/neovim-ruby-host.ruby2.4&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="15096" LastActivityDate="2017-11-13T16:28:13.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14190" PostTypeId="1" AcceptedAnswerId="14192" CreationDate="2017-11-13T17:47:47.987" Score="2" ViewCount="805" Body="&lt;p&gt;In one of the most popular vimrc’s available (Aimx’s vimrc), there is a line which maps both leader and g:leader to “,”. &lt;a href=&quot;https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim#L58&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim#L58&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the difference between let mapleader and let g:mapleader?&lt;/li&gt;&#xA;&lt;li&gt;Why do you need both to be defined to “,”?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13848" LastEditorUserId="23502" LastEditDate="2022-10-24T06:16:42.417" LastActivityDate="2022-10-24T06:16:42.417" Title="What is the difference between let mapleader =”,”, and let g:mapleader=”,”" Tags="|variables|leader|amix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14191" PostTypeId="2" ParentId="14173" CreationDate="2017-11-13T17:52:20.530" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Ipython is much better suited for showing documentation. If you do &quot;object&quot;? it will show the documentation and if you do object?? it will pull up the source code&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The above suggestions regarding Jedi, Youcompleteme is very good. As far as I know you can even go to their function defintions directly if you have carefully mapped keys to certain go to functions&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A third library that I know encapsulates all and a lot more is python-mode. Try it out.. its ways simpler to install and run that a lot of heavier plugins. &lt;a href=&quot;https://github.com/python-mode/python-mode&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/python-mode/python-mode&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2017-11-13T17:52:20.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14192" PostTypeId="2" ParentId="14190" CreationDate="2017-11-13T18:06:03.233" Score="4" Body="&lt;p&gt;In the &lt;code&gt;.vimrc&lt;/code&gt;, there is no difference between them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without an explicit scope, vim chooses between &lt;code&gt;g:&lt;/code&gt; and &lt;code&gt;l:&lt;/code&gt; depending on the context. &lt;code&gt;l:&lt;/code&gt; is implicit within functions, &lt;code&gt;g:&lt;/code&gt; is implicit everywhere else.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-11-13T18:13:43.777" LastActivityDate="2017-11-13T18:13:43.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14193" PostTypeId="1" AcceptedAnswerId="14197" CreationDate="2017-11-13T19:11:18.157" Score="3" ViewCount="38" Body="&lt;p&gt;I am trying to highlight lines like these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-&amp;gt; Some text without a domain&#xA;-&amp;gt; Some other text with a domain (example.com)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) the leading &quot;-&gt;&quot; not to be highlighted;&#xA;b) the text to be highlighted with, say, &lt;code&gt;Underlined&lt;/code&gt;;&#xA;c) and the domain if given to be highlighted with, say, &lt;code&gt;Comment&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This achieves (a) and (b) but not (c):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region MyLink start=/^-&amp;gt; /hs=e end=/\v(\s\(\a+[.]\a{2,3}\))?$/he=s-1&#xA;highlight link MyLink Underlined&#xA;syntax match Domain /\v\(\a+[.]\a{2,3}\)/&#xA;highlight link Domain Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried add &lt;code&gt;contained&lt;/code&gt; and &lt;code&gt;contains&lt;/code&gt; etc but haven't quite found the right answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help much appreciated!&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2017-11-13T23:07:22.243" Title="How to syntax highlight line with three parts?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14194" PostTypeId="1" AcceptedAnswerId="14198" CreationDate="2017-11-13T19:15:42.493" Score="1" ViewCount="1211" Body="&lt;p&gt;According to:&#xA;&lt;a href=&quot;http://vim.wikia.com/wiki/Example_vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;this wiki&lt;/a&gt;&#xA;&amp;amp;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help timeout&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in vim&#xA;when I set this option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; set notimeout ttimeout ttimeoutlen=200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should set a keycode timeout in 200ms when I add this in my .vimrc file&#xA;But the problem is it doesn't work for me anyway (it doesn't set keycode timeout).&#xA;So is it working right? Or I can't feel it?&#xA;Please let me know why it happens and how can I fix that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OS: Fedora 26&#xA;Terminal: Gnome-terminal 3.24.2 Using VTE version 0.48.4 +GNUTLS&#xA;Vim version: VIM - Vi IMproved 8.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15007" LastEditorUserId="11357" LastEditDate="2019-04-22T11:56:02.977" LastActivityDate="2019-04-22T11:56:02.977" Title="There is no timeout on option" Tags="|vimrc|options|set|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14195" PostTypeId="2" ParentId="14194" CreationDate="2017-11-13T19:52:44.510" Score="0" Body="&lt;p&gt;The correct answer would be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set timeoutlen=200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-11-13T19:52:44.510" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14196" PostTypeId="1" CreationDate="2017-11-13T20:57:26.797" Score="6" ViewCount="1907" Body="&lt;p&gt;I'm struggling to get vim (8.0 (2016 Sep 12)) to parse the output of my build system, and need help with defining my errorformat. The default gcc efm appears to not be matching any lines, so in quickfix I see basically every line of make output, but the lines that actually contain errors show up with odd characters inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example make output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make: Entering directory '/home/tblack/SourceRAM/la/Blocks'&#xA;ZYNQ_GPP src/avpcva.cpp&#xA;src/avpcva.cpp: In destructor 'virtual Blocks::AVPCVA::~AVPCVA()':&#xA;src/avpcva.cpp:152:49: error: 'class AVBC::STC' has no member named 'getHandle'&#xA;         uint16_t handle = stIter-&amp;gt;second-&amp;gt;getHandle();&#xA;                                                 ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the above make output, the quickfix list shows: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|| make: Entering directory '/home/tblack/SourceRAM/la/Blocks'&#xA;|| ZYNQ_GPP src/avpcva.cpp&#xA;|| ^[[01m^[[Ksrc/avpcva.cpp:^[[m^[[K In destructor '^[[01m^[[Kvirtual Blocks::AVPCVA::~AVPCVA()^[[m^[[K':&#xA;|| ^[[01m^[[Ksrc/avpcva.cpp:152:49:^[[m^[[K ^[[01;31m^[[Kerror: ^[[m^[[K'^[[01m^[[Kclass AVBC::STC^[[m^[[K' has no member named '^[[01m^[[Kget    Handle^[[m^[[K'&#xA;||          uint16_t handle = stIter-&amp;gt;second-&amp;gt;getHandle();&#xA;|| ^[[01;32m^[[K                                                 ^^[[m^[[K&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default errorformat for vim's gcc compiler plugin (amazingly) does not appear to beconfigured to support multi-line output (doesn't include any of %E, %C, %Z). I suspect that I just need to adjust my errorformat accordingly, but:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Would my using the default efm explain the odd characters in my quickfix?&lt;/li&gt;&#xA;&lt;li&gt;I could use help with the specification of an efm that will correctly parse my make output. I have been reading the vim docs and browsing the web for days and still not making headway on demystifying and troubleshooting multiline errorformats in vim.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I took a stab at this, using the errorformat below. The first line attempts to define my multi-line error format start(%E)/continue(%C)/end(%Z).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set errorformat =%E%f:%l:%c:\ %trror:\ %m,%-C,%-Z%p^&#xA;set errorformat+=%D%*\\a:\ Entering\ directory\ [`']%f'&#xA;set errorformat+=%X%*\\a:\ Leaving\ directory\ [`']%f'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it does not result in any different behavior from what I described above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="15063" LastActivityDate="2018-10-10T08:00:20.873" Title="need help with vim errorformat to parse multi-line make (gcc) output" Tags="|quickfix|errorformat|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14197" PostTypeId="2" ParentId="14193" CreationDate="2017-11-13T23:07:22.243" Score="2" Body="&lt;p&gt;You were on the right track! You just need to &lt;em&gt;either&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add &lt;code&gt;containedin=MyLink&lt;/code&gt; to your definition of &lt;code&gt;Domain&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Domain /\v\(\a+[.]\a{2,3}\)/ containedin=MyLink&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;or&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add &lt;code&gt;contains=Domain&lt;/code&gt; to your definition of &lt;code&gt;MyLink&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region MyLink start=/^-&amp;gt; /hs=e end=/\v(\s\(\a+[.]\a{2,3}\))?$/he=s-1 contains=Domain&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-11-13T23:07:22.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14198" PostTypeId="2" ParentId="14194" CreationDate="2017-11-13T23:36:17.470" Score="0" Body="&lt;p&gt;You're mistaken about what the documentation is referring to when it mentions key codes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;dd&lt;/code&gt; is not a key code. It is a just a vim command comprised of two key strokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of a key code would be &lt;code&gt;^[[D&lt;/code&gt; (alternatively notated as as &lt;code&gt;&amp;lt;Esc&amp;gt;[D&lt;/code&gt;), which is what the terminal sends when you press the &lt;kbd&gt;Left&lt;/kbd&gt; arrow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key code timeout is intended to allow Vim to handle such sequences differently when they are typed in (which occurs more slowly than when the terminal sends them), allowing you to, for example, type &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt;&lt;kbd&gt;D&lt;/kbd&gt; to leave insert mode and then display macro definitions of the macro under the cursor, but &lt;em&gt;also&lt;/em&gt; to press the left arrow to move one character to the left in insert mode, even though those two operations result in the same sequence of characters being passed from the terminal to Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;code&gt;dd&lt;/code&gt; is a built-in command, it &lt;em&gt;never&lt;/em&gt; times out. However, you can use the &lt;code&gt;timeout/timeoutlen&lt;/code&gt; (not &lt;code&gt;ttimeout/ttimeoutlen&lt;/code&gt;) settings to cause &lt;em&gt;mappings&lt;/em&gt; to time out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set timeout timeoutlen=1000 &quot; These are the defaults&#xA;:nnoremap xd dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Press &lt;code&gt;xd&lt;/code&gt;. It will delete a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now just press &lt;code&gt;x&lt;/code&gt;. Nothing will happen for one second: Vim is waiting to see whether you are typing the &lt;code&gt;xd&lt;/code&gt; mapping. Then, after one second, the mapping will time out, and a single character will be deleted.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-13T23:42:36.170" LastActivityDate="2017-11-13T23:42:36.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14199" PostTypeId="2" ParentId="14196" CreationDate="2017-11-14T02:26:26.400" Score="1" Body="&lt;p&gt;I was able to eliminate the escape codes by changing the -fdiagnostics-color option in gcc. So this answers my first question (the escape codes in vim's make output were caused by a gcc option that colorizes its output, and had nothing to do with vim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I (mostly) answered my second question too. I was using this errorformat:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set errorformat =%E%f:%l:%c:\ %trror:\ %m,%-Z%p^,%+C%.%#&#xA;set errorformat+=%D%*\\a:\ Entering\ directory\ [`']%f'&#xA;set errorformat+=%X%*\\a:\ Leaving\ directory\ [`']%f'&#xA;set errorformat+=%-G%.%#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it was correctly picking out all the multi-line error lines, and showing these in the quickfix (one line per error, as I've specified), but I could not jump to the source location. I assumed the quickfix-directory-stack is messed up, and changed the above %D and %X efm lines (which I copied from the defaults in gcc.vim) above to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set errorformat+=%D%*\\a:\ Entering\ directory\ '%f'&#xA;set errorformat+=%X%*\\a:\ Leaving\ directory\ '%f'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This results in a sane quickfix-directory-stack, and now the quickfix window is working on all counts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, I must ask, is this a bug in the default patterns for parsing Entering/Leaving directories in gcc.vim? Why was it using [`']%f' instead of '%f'?&lt;/p&gt;&#xA;" OwnerUserId="15063" LastActivityDate="2017-11-14T02:26:26.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14200" PostTypeId="2" ParentId="10589" CreationDate="2017-11-14T09:28:51.293" Score="1" Body="&lt;p&gt;There are similar mappings for other filetypes.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;For c-style block comments there exist built-in, ft-independent mappings &lt;code&gt;[*&lt;/code&gt;/&lt;code&gt;]*&lt;/code&gt; (and as a synonym &lt;code&gt;[/&lt;/code&gt;/&lt;code&gt;]/&lt;/code&gt;) &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* &#xA;This is the comment body.&#xA;Variation One.&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This type of block comment is used in many languages:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ActionScript, AutoHotkey, C, C++, C#, D, Go, Java, JavaScript, kotlin, Objective-C, PHP, PL/I, Rust, Scala, SASS, SQL, Swift, Visual Prolog, CSS&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(&lt;a href=&quot;https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(syntax)#Block_comments&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(syntax)#Block_comments&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Other mappings for certain filetypes in &lt;code&gt;$VIMRUNTIME/ftplugin/&lt;/code&gt; exist:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;sql.vim&lt;/code&gt; &lt;code&gt;[&quot;&lt;/code&gt;, &lt;code&gt;]&quot;&lt;/code&gt; (same as &lt;code&gt;vim.vim&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;eiffel.vim&lt;/code&gt; &lt;code&gt;[-&lt;/code&gt;, &lt;code&gt;]-&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;hamster.vim&lt;/code&gt; &lt;code&gt;[#&lt;/code&gt;, &lt;code&gt;]#&lt;/code&gt; (overwrite built-in motions to jump to c-preprocessor &lt;code&gt;#ifdef&lt;/code&gt; which are not used anyway in languages which do not have a c-preprocessor)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can reuse them for languages with identical commentstrings by copying the code to &lt;code&gt;~/.vim/after/ftplugin/&amp;lt;language&amp;gt;.vim&lt;/code&gt;.&#xA;(&lt;a href=&quot;https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(syntax)#Inline_comments&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(syntax)#Inline_comments&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, consider the language &lt;code&gt;lua&lt;/code&gt; which has the same commentstring as &lt;code&gt;eiffel&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:e $VIMRUNTIME/ftplugin/eiffel.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:45,91w ~/.vim/after/ftplugin/lua.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;remove unneeded code and change &lt;code&gt;g:no_eiffel_maps&lt;/code&gt; to &lt;code&gt;g:no_lua_maps&lt;/code&gt; and you should get something like&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre class=&quot;lang-viml prettyprint-override&quot;&gt;&lt;code&gt;if !exists(&quot;g:no_plugin_maps&quot;) &amp;amp;&amp;amp; !exists(&quot;g:no_lua_maps&quot;)&#xA;  function! s:DoMotion(pattern, count, flags) abort&#xA;    normal! m'&#xA;    for i in range(a:count)&#xA;      call search(a:pattern, a:flags)&#xA;    endfor&#xA;  endfunction&#xA;&#xA;  let comment_block_start = '^\%(\s\+--.*\n\)\@&amp;lt;!\s\+--'&#xA;  let comment_block_end = '^\s\+--.*\n\%(\s\+--\)\@!'&#xA;&#xA;  nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; ]- :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;DoMotion(comment_block_start, 1, 'W')&amp;lt;CR&amp;gt;&#xA;  xnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; ]- :&amp;lt;C-U&amp;gt;exe &quot;normal! gv&quot;&amp;lt;Bar&amp;gt;call &amp;lt;SID&amp;gt;DoMotion(comment_block_start, 1, 'W')&amp;lt;CR&amp;gt;&#xA;  nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; [- :&amp;lt;C-U&amp;gt;call &amp;lt;SID&amp;gt;DoMotion(comment_block_end, 1, 'Wb')&amp;lt;CR&amp;gt;&#xA;  xnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; [- :&amp;lt;C-U&amp;gt;exe &quot;normal! gv&quot;&amp;lt;Bar&amp;gt;call &amp;lt;SID&amp;gt;DoMotion(comment_block_end, 1, 'Wb')&amp;lt;CR&amp;gt;&#xA;&#xA;  let b:undo_ftplugin = b:undo_ftplugin .&#xA;    \ &quot;| silent! execute 'unmap &amp;lt;buffer&amp;gt; [-' | silent! execute 'unmap &amp;lt;buffer&amp;gt; ]-'&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2017-11-14T10:35:43.593" LastActivityDate="2017-11-14T10:35:43.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14201" PostTypeId="1" AcceptedAnswerId="14202" CreationDate="2017-11-14T16:14:08.077" Score="1" ViewCount="106" Body="&lt;p&gt;I had following code:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      Time::Time(short y,short m,short d,short h,short mi,short s):&#xA;              (*this).y(y),&#xA;              (*this).m(m),&#xA;              (*this).d(d),&#xA;              (*this).h(h),&#xA;              (*this).mi(mi),&#xA;              (*this).s(s),   {};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to replace all &lt;code&gt;(*this).&lt;/code&gt; with &lt;code&gt;this-&amp;gt;&lt;/code&gt;.&#xA;when I select the above code and use command &lt;code&gt;:%s/\%V(*this)./this-&amp;gt;/g&lt;/code&gt; as give &lt;a href=&quot;http://vim.wikia.com/wiki/Search_and_replace&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, I get following code:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Time::Time(short y,short m,short d,short h,short mi,short s):&#xA;          (*this-&amp;gt;y(y),&#xA;          (*this-&amp;gt;m(m),&#xA;          (*this-&amp;gt;d(d),&#xA;          (*this-&amp;gt;h(h),&#xA;          (*this-&amp;gt;mi(mi),&#xA;          (*this-&amp;gt;s(s),   {};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here is the needed result:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Time::Time(short y,short m,short d,short h,short mi,short s):&#xA;          this-&amp;gt;y(y),&#xA;          this-&amp;gt;m(m),&#xA;          this-&amp;gt;d(d),&#xA;          this-&amp;gt;h(h),&#xA;          this-&amp;gt;mi(mi),&#xA;          this-&amp;gt;s(s),     {};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know that I can remove  &lt;code&gt;(*&lt;/code&gt; manually but what if in future ,something like this but big text need to be replaced ?. that is why I am asking.&lt;/p&gt;&#xA;" OwnerDisplayName="user16300" LastEditorUserId="343" LastEditDate="2017-11-15T15:17:04.513" LastActivityDate="2017-11-15T15:17:04.513" Title="unable to replace text starting from *" Tags="|regular-expression|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14202" PostTypeId="2" ParentId="14201" CreationDate="2017-11-14T16:19:30.970" Score="3" Body="&lt;h2&gt;How to fix your regular expression&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You need to &quot;escape&quot; the &lt;code&gt;*&lt;/code&gt; character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\%V(\*this)./this-&amp;gt;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;What's going wrong&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;*&lt;/code&gt; character in an regular expression means: zero or more of the preceding atom, matching as many as possible. (See &lt;code&gt;:help /star&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You intend &lt;code&gt;(*this&lt;/code&gt; in your expression to match the literal &lt;code&gt;(*this&lt;/code&gt; in your text. Instead, it will match &lt;code&gt;this&lt;/code&gt; or &lt;code&gt;(this&lt;/code&gt; or &lt;code&gt;((this&lt;/code&gt; or &lt;code&gt;(((this&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only the first of these (&lt;code&gt;this&lt;/code&gt; not preceded by any brackets) exists in your text, so that is what the expression matches.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-15T07:59:38.153" LastActivityDate="2017-11-15T07:59:38.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14203" PostTypeId="2" ParentId="3756" CreationDate="2017-11-14T17:31:10.880" Score="8" Body="&lt;p&gt;As of November 2017, all the terminals you are using support the same &lt;a href=&quot;https://vt100.net/docs/vt510-rm/DECSCUSR.html&quot; rel=&quot;noreferrer&quot;&gt;DECSCUSR&lt;/a&gt; escape sequences for changing the cursor shape&lt;sup&gt;1&lt;/sup&gt;. So you don't need to test for the different terminals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such, the only thing that requires different treatment is tmux, which will only forward escape sequences on to the terminal when surrounded by a DCS sequence. You already had this, but in that branch you were passing escape sequences that would only work in iTerm&lt;sup&gt;2&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('$TMUX')&#xA;  let &amp;amp;t_SI = &quot;\ePtmux;\e\e[5 q\e\\&quot;&#xA;  let &amp;amp;t_EI = &quot;\ePtmux;\e\e[2 q\e\\&quot;&#xA;else&#xA;  let &amp;amp;t_SI = &quot;\e[5 q&quot;&#xA;  let &amp;amp;t_EI = &quot;\e[2 q&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1: N.B. By &quot;Terminator&quot; I presume you are referring to GNOME Terminator and not the Java-based terminal. Cygwin isn't a terminal: its default terminal, mintty emulates xterm and so should support this. Earlier versions of iTerm didn't support DECSCUSR, but later versions do. GNOME terminal also added support more recently.&lt;br&gt;&#xA;2: And Konsole (and possibly others), but that's not one of the terminals you've said you use.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-14T22:41:53.093" LastActivityDate="2017-11-14T22:41:53.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14204" PostTypeId="1" CreationDate="2017-11-14T18:24:24.070" Score="3" ViewCount="189" Body="&lt;p&gt;Basically map H and L based on the cursor positon. If I press H the cursor should go to top of the screen and if I press H again I want to scroll up by one page.&lt;/p&gt;&#xA;" OwnerUserId="15105" LastActivityDate="2017-12-10T05:57:36.433" Title="How do I map H and L to scroll by one screen if the cursor in already on the top line or bottom line" Tags="|key-bindings|scrolling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14205" PostTypeId="2" ParentId="14204" CreationDate="2017-11-14T18:36:02.177" Score="2" Body="&lt;p&gt;This is actually a fantastic idea! I might steal this for my own &lt;code&gt;.vimrc&lt;/code&gt;... :P&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, this can be done with &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mappings. I also found &lt;a href=&quot;https://stackoverflow.com/a/6176012/3524982&quot;&gt;this stack overflow answer&lt;/a&gt; extremely helpful. Onto the solution...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; H getcurpos()[1] == line(&quot;w0&quot;) ? &quot;\&amp;lt;PageUp&amp;gt;&quot; : &quot;H&quot;&#xA;nnoremap &amp;lt;expr&amp;gt; L getcurpos()[1] == line(&quot;w$&quot;) ? &quot;\&amp;lt;PageDown&amp;gt;&quot; : &quot;L&quot;&#xA;&#xA;xnoremap &amp;lt;expr&amp;gt; H getcurpos()[1] == line(&quot;w0&quot;) ? &quot;\&amp;lt;PageUp&amp;gt;&quot; : &quot;H&quot;&#xA;xnoremap &amp;lt;expr&amp;gt; L getcurpos()[1] == line(&quot;w$&quot;) ? &quot;\&amp;lt;PageDown&amp;gt;&quot; : &quot;L&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, the way this works is by first evaluating a vimscript expression, and running the resulting string as a sequence of normal mode keys. The expression is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getcurpos()[1] == line(&quot;w0&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;getcurpos&lt;/code&gt; seems to be a vim 8 feature. If you're on an older vim and you don't have this, you could do &lt;code&gt;getpos('.')&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;getcurpos()[1]&lt;/code&gt; will give you the current line number, and &lt;code&gt;line(&quot;w0&quot;)&lt;/code&gt; will give you the first visible line and &lt;code&gt;line(&quot;w$&quot;)&lt;/code&gt; will give you the last visible line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Further reading...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:map-&amp;lt;expr&amp;gt;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h &amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/23921432369e210029a26864cfb4f1537b3c3395/runtime/doc/eval.txt#L4437&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getcurpos()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#line()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h line()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-11-14T18:36:02.177" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14206" PostTypeId="1" AcceptedAnswerId="14208" CreationDate="2017-11-14T20:11:40.820" Score="0" ViewCount="82" Body="&lt;p&gt;Quoting &lt;code&gt;syn-pattern&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;See |pattern| for the explanation of what a pattern is.  Syntax patterns are&#xA;  &lt;strong&gt;always&lt;/strong&gt; interpreted like the 'magic' option is set, no matter what the actual&#xA;  value of 'magic' is.  And the patterns are interpreted like the 'l' flag is&#xA;  not included in 'cpoptions'.  This was done to make syntax files portable and&#xA;  independent of 'compatible' and 'magic' settings.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yet, I'm reading &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/46.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://learnvimscriptthehardway.stevelosh.com/chapters/46.html&lt;/a&gt; and it gives this example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match potionComment &quot;\v#.*$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My interpretation of the doc is that the &lt;code&gt;\v&lt;/code&gt; should be ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also see people asking on this issue for using very magic.  &lt;a href=&quot;https://github.com/pangloss/vim-javascript/issues/813&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/pangloss/vim-javascript/issues/813&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm getting mixed messages.  Does the syntax pattern let you use the very magic option or not?  &lt;/p&gt;&#xA;" OwnerUserId="15080" LastActivityDate="2017-11-14T22:10:03.360" Title="Do syntax patterns let you use very magic or not?" Tags="|syntax-highlighting|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14208" PostTypeId="2" ParentId="14206" CreationDate="2017-11-14T22:10:03.360" Score="2" Body="&lt;p&gt;Yes, syntax patterns allow you to use &quot;very magic&quot;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Syntax patterns are always interpreted like the 'magic' &lt;strong&gt;&lt;em&gt;option&lt;/em&gt;&lt;/strong&gt; is set, no matter what the actual value of 'magic' is.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(emphasis mine)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can see how you're reading this, but you just need to read it more literally. It does not state that the regular expression will be interpreted using &quot;magic&quot; rules. It states that it will be interpreted as if the 'magic' &lt;em&gt;option&lt;/em&gt; is set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider your example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;\v#.*$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How would this expression be interpreted if 'magic' were set?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\v&lt;/code&gt; is present, so the setting is ignored and the remainder of the expression uses &quot;very magic&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation is only relevant to expressions where you're &lt;em&gt;not&lt;/em&gt; specifically stating what level of magic you want to use. If you are specifically selecting this, then the &lt;em&gt;option&lt;/em&gt; would be ignored anyway, and the documented behaviour does not come into play at all.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-11-14T22:10:03.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14209" PostTypeId="1" CreationDate="2017-11-15T01:57:15.300" Score="2" ViewCount="309" Body="&lt;p&gt;When switching back to a buffer (.e.g with &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;^&lt;/kbd&gt; and &lt;code&gt;:bn&lt;/code&gt;, etc.), Vim tries to scroll whatever line the cursor was on last to the center of the window. I find this behavior extremely disorienting, so I use the code in the following link to just leave the window position exactly the way it was.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Avoid_scrolling_when_switch_buffers&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Avoid_scrolling_when_switch_buffers&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works except in one edge case that I believe is because of a bug in Vim itself. &lt;strong&gt;Please follow these steps to re-create the issue (after adding the above Vimscript to your vimrc):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open a relatively long buffer (a couple hundred lines or so).&lt;/li&gt;&#xA;&lt;li&gt;Scroll the window all the way to the top of the buffer (line 1 of buffer at top of window).&lt;/li&gt;&#xA;&lt;li&gt;Move cursor to anywhere in the bottom half of the window, preferably the very last line by using &lt;kbd&gt;L&lt;/kbd&gt; (line 1 of buffer should still be visible at top of window).&lt;/li&gt;&#xA;&lt;li&gt;Switch to another buffer using &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;^&lt;/kbd&gt; or &lt;code&gt;:bn&lt;/code&gt;, then switch back.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Instead of leaving the window position exactly the way it was, Vim scrolls the window so the cursor line is in the middle of the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My System Info:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 10 2017 18:06:39)&#xA;macOS version&#xA;Included patches: 1-1250&#xA;Compiled by Homebrew&#xA;Huge version without GUI.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7454" LastEditorUserId="5395" LastEditDate="2017-11-15T07:38:54.360" LastActivityDate="2017-11-15T07:38:54.360" Title="Avoid Scrolling When Switching Back to a Buffer" Tags="|vim-windows|scrolling|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14210" PostTypeId="2" ParentId="14201" CreationDate="2017-11-15T02:32:26.137" Score="1" Body="&lt;h2&gt;Alternative without Regex&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Not answering the question (about Regex), just hope this may help anyone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OP mentioned &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;when I select the above code in neovim and use command ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If the block is selected, maybe a Block-Change command suits the situation more -- we have to type &lt;code&gt;this-&amp;gt;&lt;/code&gt; anyways. (With Block selection: &lt;code&gt;cthis-&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; or &lt;code&gt;sthis-&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, but &lt;code&gt;s&lt;/code&gt; is documented here instead... &lt;code&gt;:h visual-operators&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read more here: &lt;code&gt;:h blockwise-operators&lt;/code&gt;.  Block Insert &lt;code&gt;I&lt;/code&gt; and Append &lt;code&gt;A&lt;/code&gt; are also quite useful sometimes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, if my cursor is at the &lt;code&gt;(&lt;/code&gt; and I have to block-select all &lt;code&gt;(*this).&lt;/code&gt;, probably I would by (wrong) instinct do &lt;code&gt;&amp;lt;C-v&amp;gt;www&lt;/code&gt; (oh I have gone too far -- I just &lt;code&gt;w&lt;/code&gt; for extend selection) and then &lt;code&gt;h&lt;/code&gt; (to go back) and then &lt;code&gt;jjj&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better way to select them maybe &lt;code&gt;vab&lt;/code&gt; (so you don't have to be at the start of the selection when you enter Visual mode) and then &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; (change to block selection mode) and do the rest &lt;code&gt;ljjj&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps someone -- I feel more comfortable if I don't have to use commands, especially pressing &lt;code&gt;:&lt;/code&gt; in Visual mode needs &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; to clear the &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; -- and Regex are hard to type.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;P.S. I am primarily a Perl dev and I worked with Regex everyday and when I use Regex in (n)vim mostly I'll use very magic so I'll have to escape &lt;em&gt;even&lt;/em&gt; the &lt;code&gt;().&lt;/code&gt;s... There are just too many Regex modes in Vim -- at least I've to be alert about all those characters. (Note the &lt;code&gt;\v&lt;/code&gt; for &lt;code&gt;very magic&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\%V\v\(\*this\)\./this-&amp;gt;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In case you want a plain &quot;replace&quot;, the &lt;code&gt;very nomagic&lt;/code&gt; mode will have less margin for errors: (Because only the escaped ones have special meanings)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\%V\V(*this)./this-&amp;gt;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read more about the 4 Regex modes: &lt;code&gt;:h magic&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only use the above 2 -- depending which has less to escape (Like &lt;code&gt;\V&lt;/code&gt; for a lot of &lt;code&gt;()&lt;/code&gt; in the string and &lt;code&gt;\v&lt;/code&gt; for Perl-like regex functionality).&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2017-11-15T02:32:26.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14211" PostTypeId="1" AcceptedAnswerId="14224" CreationDate="2017-11-15T06:26:57.943" Score="0" ViewCount="954" Body="&lt;p&gt;I'm not sure if I'm asking this right (I think this is a buffer thing?) so here is the scenario (in &lt;a href=&quot;https://github.com/cucumber/cucumber/wiki/Gherkin&quot; rel=&quot;nofollow noreferrer&quot;&gt;gherkin&lt;/a&gt;)&#xA;As a vim user, i would like to use the silver searcher to search for files which have keywords and be able to go back and forth between the files i have visted:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;given&lt;/strong&gt; user launched vi&lt;br&gt;&#xA;&lt;strong&gt;and&lt;/strong&gt; user searched for a term using silver searcher&lt;br&gt;&#xA;&lt;strong&gt;and&lt;/strong&gt; search results appeared in the quick help window&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/0UILS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0UILS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;strong&gt;and&lt;/strong&gt; user selected one of the files&lt;br&gt;&#xA;&lt;strong&gt;and&lt;/strong&gt; that file loaded &lt;/p&gt;&#xA;&#xA;&lt;p&gt;question: how can the user &lt;em&gt;go back&lt;/em&gt; to the original file that was already loaded &lt;em&gt;before&lt;/em&gt; they jumped to the new file? and supposing they did go back, how can they go forward back to the file they just searched?&lt;/p&gt;&#xA;" OwnerUserId="14510" LastActivityDate="2017-11-15T16:36:58.757" Title="how to go back and forth in the view stack in vi" Tags="|buffers|the-silver-searcher|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14213" PostTypeId="2" ParentId="14211" CreationDate="2017-11-15T07:14:28.923" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;:bpre&lt;/code&gt; and &lt;code&gt;:bnext&lt;/code&gt; to go to previous buffer and next one.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2017-11-15T07:14:28.923" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14214" PostTypeId="2" ParentId="14178" CreationDate="2017-11-15T07:36:07.627" Score="0" Body="&lt;p&gt;This &lt;a href=&quot;http://vim.wikia.com/wiki/Converting_tabs_to_spaces&quot; rel=&quot;nofollow noreferrer&quot;&gt;article&lt;/a&gt; may help you clear the idea. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set softtabstop=4&lt;/code&gt; will makes backspace 4 spaces as a tab.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2017-11-15T07:36:07.627" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14215" PostTypeId="1" CreationDate="2017-11-15T08:06:13.153" Score="4" ViewCount="466" Body="&lt;p&gt;You and your collaborators have different preferences for how to indent your files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously they have a barbaric suggestion, whether that's tabs, spaces or something else, doesn't matter, it's &lt;em&gt;wrong&lt;/em&gt;, but now they use it anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can the &lt;em&gt;displayed&lt;/em&gt; indentation be controlled in vim, without altering the indentation on disc when the file is is written to?&lt;/p&gt;&#xA;" OwnerUserId="2004" LastActivityDate="2017-11-15T17:33:04.650" Title="How to change the displayed indentation amount?" Tags="|indentation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14216" PostTypeId="2" ParentId="14215" CreationDate="2017-11-15T09:10:23.753" Score="2" Body="&lt;p&gt;Put this in your .vimrc, and it will define how your tabs are displayed (replacing the number 4 with whatever your preferred number or spaces is):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;set tabstop=4&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As far as I know, you can only affect how tabs are displayed, and not spaces. So if someone religiously uses 2 spaces for indentation, and you want 4 instead, you can not change that without also writing that change to the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE: .editorconfig&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would strongly encourage you to argue for implementing a &lt;a href=&quot;http://editorconfig.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;.editorconfig file&lt;/a&gt; in your project, which will make it much easier to handle this within your team.&lt;/p&gt;&#xA;" OwnerUserId="15116" LastActivityDate="2017-11-15T09:10:23.753" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14217" PostTypeId="1" CreationDate="2017-11-15T09:22:25.137" Score="3" ViewCount="5312" Body="&lt;p&gt;I set &lt;code&gt;statusline=&lt;/code&gt; and &lt;code&gt;fillchars=vert:\|&lt;/code&gt; and the result is for horizontal is here when I try &lt;code&gt;:sp&lt;/code&gt;:&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/S0z9S.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S0z9S.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try &lt;code&gt;:vsp&lt;/code&gt; the reuslt here:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/kUh6F.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kUh6F.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really like to tweak horizontal with &lt;code&gt;fillchars&lt;/code&gt; but vim seems don't allow users to do it. How can I disable completely that annoying bar?&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2017-11-15T17:03:34.017" Title="How to hide horizontal line between windows" Tags="|vimrc|gvim|" AnswerCount="2" CommentCount="3" ClosedDate="2017-11-18T01:39:06.170" ContentLicense="CC BY-SA 3.0" />
  <row Id="14218" PostTypeId="2" ParentId="14215" CreationDate="2017-11-15T11:09:08.867" Score="8" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/a/14216/343&quot;&gt;Robert Axelson has already stated&lt;/a&gt;, if the file is indented using tabs, this is easily achieved by using &lt;code&gt;:set tabstop&lt;/code&gt;, which is designed for this very purpose.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;A solution for halving space indents&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In the interests of hackery, I came up with this code using Vim 7.3's &lt;code&gt;+conceal&lt;/code&gt; feature that allows you to display a file as though the space-based indentation is half what it really is: e.g. it will display a file that uses four spaces for indentation as if uses two spaces instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match HalveIndent /\v^( +)\ze\1/ conceal&#xA;set conceallevel=2&#xA;set concealcursor=nvic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;A solution for doubling space indents&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here's an even hackier version that uses a &lt;code&gt;cchar&lt;/code&gt; replacement character to double all the space-based indent: e.g. It will display a file indented with two spaces as though it is indented with four spaces.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match DoubleIndent /^ \+/&#xA;execute 'syntax match DoubleIndentSpace / / containedin=DoubleIndent contained conceal cchar=' . &quot;\uff0e&quot;&#xA;set conceallevel=2&#xA;set concealcursor=nvic&#xA;highlight Conceal ctermfg=bg guifg=bg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;How they work&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;+conceal&lt;/code&gt; feature  allows you to hide certain text in your file. See &lt;code&gt;:help new-conceal&lt;/code&gt; for a brief introduction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code in the first solution sets up a syntax group &lt;code&gt;HalveIndent&lt;/code&gt; that finds stretches of spaces at the start of a line that are multiples of two, and then hides the first half of the spaces using &lt;code&gt;conceal&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code in the second solution sets up a syntax group &lt;code&gt;DoubleIndent&lt;/code&gt; that finds space-indents, and then another syntax group &lt;code&gt;DoubleIndentSpaces&lt;/code&gt; that finds single spaces within the areas matched by the first group. It then replaces all these spaces with a single Unicode character that will take up two columns on-screen: FULLWIDTH FULL STOP (U+FF0E). (N.B. You could directly insert the character into the command, but in order to make it clearer, I've included it as a string value that is added onto the command with &lt;code&gt;:execute&lt;/code&gt;.) Unfortunately there doesn't appear to be a full width space character: the full width full stop is the most discreet character I could find, but &lt;a href=&quot;http://www.unicode.org/charts/PDF/UFF00.pdf&quot; rel=&quot;noreferrer&quot;&gt;you might prefer another character&lt;/a&gt;. In any case, we then use a &lt;code&gt;highlight&lt;/code&gt; command, to make the displayed character invisible. (Except when the cursor is actually over it.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;conceallevel&lt;/code&gt; to 2 means that, when we're &lt;em&gt;not&lt;/em&gt; setting a &lt;code&gt;cchar&lt;/code&gt; replacement character for the text, it will be completely hidden instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, concealed text is revealed when the cursor is on the same line. Setting &lt;code&gt;'concealcursor'&lt;/code&gt; to &lt;code&gt;nvic&lt;/code&gt; means that the text will remain hidden in all the listed modes&amp;#8202;&amp;mdash;&amp;#8202;if you were to remove, say, the &lt;code&gt;i&lt;/code&gt; from that option, then the text would be revealed when you are in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has the minor downside that when you are moving the cursor within the concealed area, it can move between the concealed characters without actually appearing to move on-screen. If you find this more disorienting that having the concealed text expanding-and-decreasing all the time, you could tweak the &lt;code&gt;concealcursor&lt;/code&gt; value (or remove it entirely).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The regular expression used for halving space indents&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;We are finding whitespace to hide with the regular expression: &lt;code&gt;/\v^( +)\ze\1/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Broken down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; &amp;ndash; Use &quot;very magic&quot; to require less backslash-escaping,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; &amp;ndash; Match the start of the line: we only want to conceal indent!&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;( +)&lt;/code&gt; &amp;ndash; Match one-or-more space characters: as many as possible. We're using parentheses here so we can refer back to what we matched later on.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\ze&lt;/code&gt; &amp;ndash; End the match here: everything after this will not be included in the text that is concealed,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\1&lt;/code&gt; &amp;ndash; Match whatever text was previously matched by the parenthesis-enclosed group, &lt;code&gt;( +)&lt;/code&gt;. So if we previously matched one space, it needs to be followed by another; if we previously matched two spaces, they need to be followed by two more. This means that the whole expression will only match sets of spaces where the number of spaces is a multiple of two.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Further reading:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help syntax&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help conceal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help cchar&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \v&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \ze&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Requirements&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Both solutions require the &lt;code&gt;+syntax&lt;/code&gt; and &lt;code&gt;+conceal&lt;/code&gt; features to be compiled in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution for doubling indents also requires &lt;code&gt;+multi_byte&lt;/code&gt; to be compiled in, and for &lt;code&gt;encoding&lt;/code&gt; to be set to an appropriate value for the unicode string to work (e.g. &lt;code&gt;utf-8&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-15T17:33:04.650" LastActivityDate="2017-11-15T17:33:04.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14219" PostTypeId="2" ParentId="10025" CreationDate="2017-11-15T13:06:45.230" Score="3" Body="&lt;p&gt;I struggled with the same problem and my &lt;code&gt;vimrc&lt;/code&gt; was containing this lines. It disables the default, built-in &lt;code&gt;netrw&lt;/code&gt; plugin. I don't know why but somehow spell files couldn't be downloaded if netrw disabled.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:loaded_netrwPlugin = 1 &quot; Disables netrw.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Solution was &lt;em&gt;at least for me&lt;/em&gt; to delete this line to enable netrw again.&lt;/p&gt;&#xA;" OwnerUserId="9211" LastActivityDate="2017-11-15T13:06:45.230" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14220" PostTypeId="2" ParentId="11373" CreationDate="2017-11-15T13:09:25.163" Score="4" Body="&lt;p&gt;To avoid screen flashes when editing stream &lt;a href=&quot;https://vi.stackexchange.com/q/788/467&quot;&gt;non-interactively&lt;/a&gt;, you need to start Vim in Ex mode by adding &lt;code&gt;-e&lt;/code&gt; (&lt;em&gt;Ex mode&lt;/em&gt;) or &lt;code&gt;-E&lt;/code&gt; (&lt;em&gt;improved Ex mode&lt;/em&gt;) into your command-line arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the simple example editing text from the standard output and printing the result into standard output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo &quot;foo bar&quot; | vim -E +%s/foo.// +%p -cq! /dev/stdin&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To parse your output, you may try the following syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ psql -c &quot;\\d+ person&quot; | \&#xA;  ex +'1s/\s\+View &quot;\([^&quot;]\+\)&quot;/CREATE OR REPLACE VIEW \1 AS/g' +'2,/View.definition/d' +%j +%p -scq! /dev/stdin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output should look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CREATE OR REPLACE VIEW public.person AS SELECT 1 AS person_id, 'John'::text AS first_name, 'Doe'::text AS last_name;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using &lt;code&gt;ex&lt;/code&gt; command is equivalent to run Vim in Ex mode (&lt;code&gt;vim -e&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;+'cmd'&lt;/code&gt;/&lt;code&gt;-c {cmd}&lt;/code&gt; - Invokes Ex command.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-cq!&lt;/code&gt; - Forcibly &lt;strong&gt;q&lt;/strong&gt;uit Vim as we're not saving any files.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-s&lt;/code&gt; - Run in &lt;strong&gt;s&lt;/strong&gt;ilent mode (prevents extra screen flashes).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/dev/stdin&lt;/code&gt; - We use &lt;code&gt;/dev/stdin&lt;/code&gt; as an input file, because &lt;a href=&quot;https://github.com/vim/vim/issues/2342&quot; rel=&quot;nofollow noreferrer&quot;&gt;using &lt;code&gt;-&lt;/code&gt; doesn't work properly&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1s/pattern/something/g&lt;/code&gt; - Substitute &lt;code&gt;pattern&lt;/code&gt; with &lt;code&gt;something&lt;/code&gt; in the &lt;strong&gt;1&lt;/strong&gt;st line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2,/pattern/d&lt;/code&gt; - &lt;strong&gt;D&lt;/strong&gt;elete content starting from the &lt;strong&gt;2&lt;/strong&gt;nd line to the line with &lt;code&gt;pattern&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%j&lt;/code&gt; - &lt;strong&gt;J&lt;/strong&gt;oins all the lines together.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%p&lt;/code&gt; - &lt;strong&gt;P&lt;/strong&gt;rints the buffer to the console output.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2017-11-16T11:30:17.293" LastActivityDate="2017-11-16T11:30:17.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14221" PostTypeId="2" ParentId="7449" CreationDate="2017-11-15T14:18:42.987" Score="1" Body="&lt;p&gt;First off, I'd like to note that the implication that you cannot use the system clipboard from terminal Vim is false. I use it all the time. (This implication isn't in your question, but it is in the comments.) So if I were in your situation, I would simply install a different Vim package that &lt;em&gt;does&lt;/em&gt; include the &lt;code&gt;+clipboard&lt;/code&gt; feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, here's a proof of concept which uses a tmux buffer and the &lt;code&gt;system()&lt;/code&gt; function to provide (just) the functionality you asked for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; yy yy:call system('tmux set-buffer -b vim ' . shellescape(@&quot;))&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; p :let @&quot; = system('tmux show-buffer -b vim')&amp;lt;cr&amp;gt;p$x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These mappings use the standard &lt;code&gt;yy&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt; commands to perform the actual yank and put, but include system calls to save the contents of the unnamed register in a tmux buffer after yanking and load the buffer contents back into the unnamed register before putting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.B. If I were using this in earnest, I would extend this and tidy it up a fair bit (for instance, with these mappings you can now &lt;em&gt;only&lt;/em&gt; &lt;code&gt;p&lt;/code&gt; things that you have previously yanked with &lt;code&gt;yy&lt;/code&gt;: the easiest way around this is use &lt;code&gt;&amp;lt;leader&amp;gt;yy&lt;/code&gt; and &lt;code&gt;&amp;lt;leader&amp;gt;p&lt;/code&gt; as the triggers), but this shows the basic functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's another version which instead uses tmux's &lt;code&gt;send-keys&lt;/code&gt; to directly copy over the contents of the unnamed register when you yank, which in some ways is cleaner, and avoids the problem with the &lt;code&gt;p&lt;/code&gt; mapping described above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; yy yy:call system('tmux send-keys -t 1 &quot;:let @\&quot; = \&quot;' . shellescape(@&quot;)[1:-2] . '\&quot;' . &quot;\r\&quot;&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently this is losing the newline at the end of the yanked line: it could probably be tidied up not to do so.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-15T15:03:40.830" LastActivityDate="2017-11-15T15:03:40.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14222" PostTypeId="2" ParentId="14217" CreationDate="2017-11-15T15:33:55.947" Score="3" Body="&lt;h2&gt;OP's Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;(See if I got it correctly)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OP wanna have a &lt;code&gt;fillchars&lt;/code&gt; for horizontal split line, just like the &lt;code&gt;|&lt;/code&gt; for a vertical split.  &lt;code&gt;Fillchars&lt;/code&gt; line up as a line to split the windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure how OP made the vertical &lt;code&gt;|&lt;/code&gt; disappear -- did OP use &lt;code&gt;:set fillchars=\␣&lt;/code&gt; (I mean the space) instead?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;My Attempt to Answer&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h fillchars&lt;/code&gt;, we know that &lt;code&gt;:set fillchars=stl:-&lt;/code&gt; would fill the empty space after the statusline with &lt;code&gt;-&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then, to get rid of the file name from the statusline, from &lt;code&gt;:h statusline&lt;/code&gt; we know that the default is empty.  (That's why OP's attempt to do &lt;code&gt;:set statusline=&lt;/code&gt; didn't remove the statusline)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-- so we have to set it to a single &lt;code&gt;-&lt;/code&gt; by &lt;code&gt;:set statusline=-&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the whole statusline (for an active Window) is now &lt;code&gt;----...&lt;/code&gt; and what's left is to also do &lt;code&gt;:set fillchars+=stlnc:-&lt;/code&gt;, so non-active Window also has a nice horizontal line for splits.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Tl;dl;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:se stl=- fcs=stl:-,stlnc:-,vert:\|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or a nicely documented one (for putting into a publicly shared &lt;code&gt;.vimrc&lt;/code&gt;, maybe:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set statusline=-        &quot; hide file name in statusline&#xA;:set fillchars=stl:-     &quot; fill active window's statusline with -&#xA;:set fillchars+=stlnc:-  &quot; also fill inactive windows&#xA;:set fillchars+=vert:\|  &quot; add a bar for vertical splits&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For whatever reasons, we can also hide the most bottom statusline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set laststatus=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tested on my own Vim version 7.4.8056 on macOS with &lt;code&gt;vim -u /dev/null&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14820" LastEditorUserId="14820" LastEditDate="2017-11-15T15:46:08.703" LastActivityDate="2017-11-15T15:46:08.703" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14223" PostTypeId="2" ParentId="14217" CreationDate="2017-11-15T15:50:55.157" Score="4" Body="&lt;p&gt;Just set the highlight of both the foreground and the background of the status line(s) to be the same colour as the background of the rest of the window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight StatusLine ctermfg=bg ctermbg=bg guibg=bg guifg=bg   &#xA;:highlight StatusLineNC ctermfg=bg ctermbg=bg guibg=bg guifg=bg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-15T17:03:34.017" LastActivityDate="2017-11-15T17:03:34.017" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14224" PostTypeId="2" ParentId="14211" CreationDate="2017-11-15T16:11:13.017" Score="1" Body="&lt;h3&gt;Jumplist&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; to travel back and forward through the jump list. You can see the jump list via &lt;code&gt;:jumps&lt;/code&gt;. However this my not be the fastest way to get back as you may have jumped a few times.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Alternative file&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;&amp;lt;c-6&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;c-^&amp;gt;&lt;/code&gt; / &lt;code&gt;:b #&lt;/code&gt; to switch to the alternative buffer. This is typically the previous buffer. You can see which buffer is the alternate buffer by looking for the buffer marked with &lt;code&gt;#&lt;/code&gt; in the buffer list via: &lt;code&gt;:ls&lt;/code&gt; / &lt;code&gt;:buffers&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This only works if the previous buffer is the one you want to go to or if you know the buffer number you want to go to (e.g. &lt;code&gt;5&amp;lt;c-6&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Use file marks&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can set an upper case mark (file marks) which will allow you to jump between files. Simply set it before you search &lt;code&gt;mM&lt;/code&gt;, then after you search jump via &lt;code&gt;'M&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The downside with this is you must set the mark before you do your searching.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Splits&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you know you are going go back to your original buffer use a split to view your search result (maybe via &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt; in the quickfix window) and keep your original buffer open. That way all you need to do is close your search buffer (possibly the quickfix window as well, &lt;code&gt;:cclose&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once again this requires you to know in advance that you will be going back.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Advanced buffer navigation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:b&lt;/code&gt; to directly jump to the buffer you desire. Use &lt;code&gt;:b {partial-file-name}&lt;/code&gt; to jump back. You can also use tab completion (&lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; to list completions) and globs (e.g. &lt;code&gt;:b **/foo*.bar&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A common mapping for buffer navigation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :ls&amp;lt;cr&amp;gt;:b&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;For more help see&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h jump-motions&#xA;:h alternative-file&#xA;:h mark-motions&#xA;:h :b&#xA;:h :ls&#xA;:h CTRL-6&#xA;:h c_CTRL-D&#xA;:h cmdline-completion&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-11-15T16:36:58.757" LastActivityDate="2017-11-15T16:36:58.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14225" PostTypeId="1" AcceptedAnswerId="14226" CreationDate="2017-11-15T16:51:58.480" Score="1" ViewCount="339" Body="&lt;p&gt;When open vim or kill buffers to empty I encounter with &lt;code&gt;~&lt;/code&gt; and I'd like to disable/remove it.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/T9Qfa.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T9Qfa.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2017-11-15T17:01:07.120" Title="Remove ~ in buffer at vim startup" Tags="|vimrc|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14226" PostTypeId="2" ParentId="14225" CreationDate="2017-11-15T17:01:07.120" Score="5" Body="&lt;h2&gt;In Vim 8&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight EndOfBuffer ctermfg=bg guifg=bg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;In earlier versions&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight NonText ctermfg=bg guifg=bg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(But this will also hide other things. See &lt;code&gt;:help hl-NonText&lt;/code&gt; and &lt;code&gt;:help 'listchars'&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-11-15T17:01:07.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14227" PostTypeId="2" ParentId="6893" CreationDate="2017-11-15T17:30:11.530" Score="1" Body="&lt;p&gt;It looks like you want to follow the recommendation on &lt;a href=&quot;http://dustycloud.org/blog/vcs-friendly-patchable-document-line-wrapping/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://dustycloud.org/blog/vcs-friendly-patchable-document-line-wrapping/&lt;/a&gt;. This answer offers a solution to apply these rules to several paragraphs in one step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;During writing I would simply recommend, setting &lt;code&gt;textwidth=80&lt;/code&gt;, &lt;code&gt;expandtab&lt;/code&gt;, &lt;code&gt;shiftwidth=2&lt;/code&gt; and press tab when you are in a new line and the sentence is not finished. Auto-insertion of two spaces in new lines often leads to situations where you do not want to have this, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\section{Section 1}&amp;lt;CR&amp;gt;&#xA;  CURSOR UNINTENTIONALLY INDENTED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So back to the situation where you want to fix the indentation of several paragraphs which are not properly indented according to this style (typically after modifying the text):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since sentence detection is quite difficult, one could use a machine learning toolkit (e.g. Apache OpenNLP):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat dusty.txt&#xA;If you do enough work in any sort of free software environment, you get used to&#xA;doing lots of writing of documentation or all sorts of other things in some&#xA;plaintext system which exports to some non-plaintext system.  One way or&#xA;another you have to decide: are you going to wrap your lines with newlines?&#xA;And of course the answer should be &quot;yes&quot; because lines that trail all the way&#xA;off the edge of your terminal is a sin against the plaintext gods, who are&#xA;deceptively mighty, and whose wrath is to be feared (and blessings to be&#xA;embraced).  So okay, of course one line per paragraph is off the table.  So&#xA;what do you do?&#xA;$ tr '\n' ' ' &amp;lt; dusty.txt | opennlp SentenceDetector en-sent.bin 2&amp;gt;/dev/null | par 78p2dh&#xA;If you do enough work in any sort of free software environment, you get used&#xA;  to doing lots of writing of documentation or all sorts of other things in&#xA;  some plaintext system which exports to some non-plaintext system.&#xA;One way or another you have to decide: are you going to wrap your lines with&#xA;  newlines?&#xA;And of course the answer should be &quot;yes&quot; because lines that trail all the way&#xA;  off the edge of your terminal is a sin against the plaintext gods, who are&#xA;  deceptively mighty, and whose wrath is to be feared (and blessings to be&#xA;  embraced).&#xA;So okay, of course one line per paragraph is off the table.&#xA;So what do you do?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim configuration for the operator &lt;code&gt;gq&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;l:formatprg='tr &quot;\\n&quot; &quot; &quot;|opennlp SentenceDetector en-sent.bin 2&amp;gt;/dev/null |par 78p2dh'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should work for the English language and uses the program &lt;a href=&quot;http://www.nicemice.net/par/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.nicemice.net/par/&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For installation details and using alternatively NLTK see &lt;a href=&quot;https://github.com/lervag/vimtex/issues/544#issuecomment-299444814&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/lervag/vimtex/issues/544#issuecomment-299444814&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2017-11-15T17:36:20.380" LastActivityDate="2017-11-15T17:36:20.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14228" PostTypeId="1" CreationDate="2017-11-15T18:48:35.550" Score="3" ViewCount="1856" Body="&lt;p&gt;I'm using (the fantastic) Ag, Silver Searcher, through (the fantastic) fzf.vim plugin. When I search for text, though, I don't want to see matches on file names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Ag finder&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;shows every line in every file that has the word finder in it, when all I want is the files that actually have the word finder &lt;em&gt;in&lt;/em&gt; them.&lt;/p&gt;&#xA;" OwnerUserId="10677" LastActivityDate="2017-11-18T09:58:01.050" Title="How to exclude filenames from Ag search (via fzf.vim)?" Tags="|plugin-fzf|plugin-ag.vim|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14230" PostTypeId="2" ParentId="5195" CreationDate="2017-11-16T11:20:47.797" Score="22" Body="&lt;p&gt;I like to call &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt; &quot;Yester-line&quot;™ like &quot;Yesterday&quot;. Explaining it along with &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; rhymes, too. &quot;Extra-line&quot; and &quot;Yester-line&quot;™.&lt;/p&gt;&#xA;" OwnerUserId="7654" LastActivityDate="2017-11-16T11:20:47.797" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14231" PostTypeId="2" ParentId="2776" CreationDate="2017-11-16T12:32:35.567" Score="0" Body="&lt;p&gt;Here is the shell command using &lt;code&gt;find&lt;/code&gt; and &lt;code&gt;ex&lt;/code&gt; editor (without &lt;a href=&quot;https://vi.stackexchange.com/a/2998/467&quot;&gt;using &lt;code&gt;:bufdo&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find . -name '*.rb' -exec ex +'%s/foo/bar/ge' -V1 -scwq! {} ';'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will edit in-place all &lt;code&gt;*.rb&lt;/code&gt; files in the current folder (recursively) and replace &lt;code&gt;foo&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2017-11-16T12:32:35.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14232" PostTypeId="1" AcceptedAnswerId="14234" CreationDate="2017-11-16T13:58:43.540" Score="3" ViewCount="816" Body="&lt;p&gt;I am writing my first vimrc. I already read help pages for &lt;code&gt;hidden&lt;/code&gt; and &lt;code&gt;nostartofline&lt;/code&gt; options, as well as &lt;a href=&quot;https://www.facebook.com/vimtips/posts/405674039570379&quot; rel=&quot;nofollow noreferrer&quot;&gt;some articles&lt;/a&gt; and other FAQs.&lt;/p&gt;&#xA;&lt;p&gt;However, I still can't understand what the purpose of these two options are.&lt;/p&gt;&#xA;" OwnerUserId="15007" LastEditorUserId="31207" LastEditDate="2021-09-08T20:31:36.467" LastActivityDate="2021-09-08T20:31:36.467" Title="Help understanding options hidden and nostartofline" Tags="|vimrc|options|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14233" PostTypeId="1" CreationDate="2017-11-16T14:00:35.437" Score="0" ViewCount="265" Body="&lt;p&gt;I'm using a combination of buffers and splits. What I want is for &lt;code&gt;:bnext&lt;/code&gt; or &lt;code&gt;:bprev&lt;/code&gt; (or some equivalent) not to open buffers that are already opened in some other split or tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="14587" LastEditorUserId="343" LastEditDate="2017-11-16T15:44:28.083" LastActivityDate="2017-11-16T16:12:25.070" Title="How can I prevent some buffers from being reachable using bnext, bprev?" Tags="|buffers|terminal-buffer|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ClosedDate="2017-11-16T16:15:38.397" ContentLicense="CC BY-SA 3.0" />
  <row Id="14234" PostTypeId="2" ParentId="14232" CreationDate="2017-11-16T14:21:29.407" Score="4" Body="&lt;p&gt;Perhaps examples will help you understand the features:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;'hidden'&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Start a new instance of Vim in the terminal with the command &lt;code&gt;vim -Nu NONE&lt;/code&gt;. This will start Vim with default configuration, and thus &lt;code&gt;'hidden'&lt;/code&gt; will be unset (and &lt;code&gt;'startofline'&lt;/code&gt; will be set).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Enter insert mode by pressing &lt;kbd&gt;i&lt;/kbd&gt;, type in some text, and then press &lt;kbd&gt;Esc&lt;/kbd&gt; to return to normal mode,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Enter the command &lt;code&gt;:e anotherfile.txt&lt;/code&gt; to start editing a new file,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Vim will display an error because you haven't written the file yet,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Enter the command &lt;code&gt;:set hidden&lt;/code&gt; to switch on the &lt;code&gt;'hidden'&lt;/code&gt; option&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Try the command again: &lt;code&gt;:e anotherfile.txt&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What happens?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;'nostartofline'&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;In the same instance of Vim, enter the command &lt;code&gt;:b#&lt;/code&gt;to return to your original buffer.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt; to jump to the beginning of the buffer and then &lt;code&gt;$&lt;/code&gt; to jump to the end of the line. (If the first line is blank, first enter some text.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt; again. The cursor will move to the start of the line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;kbd&gt;$&lt;/kbd&gt; to move back to the end of the line,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Enter the command &lt;code&gt;:set nostartofline&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt; a third time.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What happens?&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-11-16T14:21:29.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14235" PostTypeId="2" ParentId="11210" CreationDate="2017-11-16T14:54:59.703" Score="1" Body="&lt;p&gt;As I don't use &lt;code&gt;,&lt;/code&gt; and like a simple easy to type solution, this works for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map , @@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14969" LastEditorUserId="2920" LastEditDate="2017-11-16T15:32:40.913" LastActivityDate="2017-11-16T15:32:40.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14236" PostTypeId="2" ParentId="4682" CreationDate="2017-11-16T15:15:30.407" Score="2" Body="&lt;p&gt;In Vim, this &lt;a href=&quot;https://github.com/vim/vim/issues/1552&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue&lt;/a&gt; has been addressed in &lt;a href=&quot;https://github.com/vim/vim/commit/234d16286a2733adedef56784c17415ae169b9ad&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;234d162&lt;/code&gt; commit&lt;/a&gt; (&gt;=v8.0.1387).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Solution:   Don't show the message with &lt;code&gt;--not-a-term&lt;/code&gt; was used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So the message is only displayed when user hasn't redirected the stdin.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Similar &lt;a href=&quot;https://github.com/neovim/neovim/pull/6298&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue&lt;/a&gt; has been &lt;a href=&quot;https://github.com/neovim/neovim/commit/bdcb2a38b3667c01efada0c6ed9414426f1c0468&quot; rel=&quot;nofollow noreferrer&quot;&gt;addressed&lt;/a&gt; in the recent version of &lt;a href=&quot;https://github.com/neovim/neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Neovim&lt;/em&gt;&lt;/a&gt; (&lt;em&gt;&gt;=v0.2.2-dev&lt;/em&gt;) which you could use instead of Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once NVim v0.2.2 is released, you should be able to run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo foo | nvim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;without having the message.&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2017-12-12T13:22:47.723" LastActivityDate="2017-12-12T13:22:47.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14237" PostTypeId="2" ParentId="14233" CreationDate="2017-11-16T16:12:25.070" Score="1" Body="&lt;p&gt;As an alternative, stop using &lt;code&gt;:bnext&lt;/code&gt; / &lt;code&gt;:bprev&lt;/code&gt; for navigation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-d1GaUBk-Y10/TyFhskmCYRI/AAAAAAAAARQ/CIEx1V7FLqg/s640/vim-and-vigor-004-flying_is_faster_than_cycling.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Why ride a bike when you can fly?&quot;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just open the buffer you want where you want to open it (and how).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Behold the power of &lt;code&gt;:b&lt;/code&gt;!:&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Uses &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; completion&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; to list out completion&lt;/li&gt;&#xA;&lt;li&gt;Use partial file name. e.g. &lt;code&gt;:b foo&lt;/code&gt;. Works great with &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Globbing. e.g. &lt;code&gt;:b foo*bar&lt;/code&gt; or &lt;code&gt;:b foo/**/bar&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Split variant of &lt;code&gt;:b&lt;/code&gt; is &lt;code&gt;:sb&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Also accepts a buffer number&lt;/li&gt;&#xA;&lt;li&gt;A common mapping: &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :ls&amp;lt;cr&amp;gt;:b&amp;lt;space&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:b&lt;/code&gt; / &lt;code&gt;:sb&lt;/code&gt; will allow you to simply open the buffer you want. No more cycling. No more worrying about the buffer list (&lt;code&gt;:set hidden&lt;/code&gt;). This often leads to simpler window layouts, because you do not feel like you need to &quot;store&quot; a buffer in some split because it is tedious to find it again.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-11-16T16:12:25.070" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14238" PostTypeId="1" CreationDate="2017-11-16T23:23:36.777" Score="1" ViewCount="457" Body="&lt;p&gt;Following this &lt;a href=&quot;https://chrisdown.name/2015/02/26/folding-python-docstrings-in-vim.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;article&lt;/a&gt;, fold show first line &lt;code&gt;set foldtext=getline(v:foldstart+1)&lt;/code&gt;, it does but other folds in file look bad, see pics:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When set &lt;code&gt;foldtext=getline(v:foldstart+1)&lt;/code&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/TVALt.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TVALt.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without set &lt;code&gt;foldtext=getline(v:foldstart+1)&lt;/code&gt;:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/gsIHs.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gsIHs.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'd like to have function/class folded as 2rd pic, and docstring folded as 1st pic. I used &lt;code&gt;SimpylFold&lt;/code&gt; plugin for auto-fold in python.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 1: Have a look at this &lt;a href=&quot;https://stackoverflow.com/a/18241768/5813693&quot;&gt;answer&lt;/a&gt;, I wonder if I only need to match docstring and fold it: &lt;code&gt;substitute(a:string, '^[[:space:][:return:][:cntrl:]]\+\|[[:space:][:return:][:cntrl:]]\+$', '', '')&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="14274" LastEditDate="2017-11-16T23:38:13.127" LastActivityDate="2017-11-16T23:38:13.127" Title="Fold show first line of docstring, keeps other folds intact" Tags="|vimrc|gvim|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14239" PostTypeId="1" CreationDate="2017-11-17T00:06:50.847" Score="10" ViewCount="4870" Body="&lt;p&gt;I'm a bit of a noob when it comes to Linux, only started using it recently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am trying to compile vim with python because I  am using latex live preview and it needs a python compiled vim to work. I am following these steps here: &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At part 3 it says to find your config for your python version such as &lt;code&gt;/usr/lib/python3.6/config&lt;/code&gt;&#xA;I dont have that, I only have this: &lt;code&gt;_sysconfigdata_m_linux_x86_64-linux-gnu.py&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I supposed to make a config directory, or should it already be there?&lt;/p&gt;&#xA;" OwnerUserId="15098" LastEditorUserId="15098" LastEditDate="2019-07-23T14:40:09.480" LastActivityDate="2022-10-26T17:54:30.933" Title="Trying to compile vim with python 3.6. Where is my config directory?" Tags="|vimscript-python|installing|linux-ubuntu|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="14241" PostTypeId="1" AcceptedAnswerId="14259" CreationDate="2017-11-17T11:01:59.993" Score="0" ViewCount="314" Body="&lt;p&gt;When I'm programming. My structure is based on a simple tree.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.&#xA;├── index.js&#xA;└── Pages&#xA;    ├── blog&#xA;    │   └── index.js&#xA;    ├── career&#xA;    ├── contacts&#xA;    │   └── index.js&#xA;    ├── dashboard&#xA;    ├── home&#xA;    │   └── index.js&#xA;    ├── Layouts&#xA;    ├── Menus&#xA;    └── portfolio&#xA;        └── index.js&#xA;&#xA;9 directories, 5 files&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A tree from my actual project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever I need a feature I make a directory for it and when I create a file inside vim I need to always&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TabooRename %basename%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;of the file so in &lt;code&gt;portfolio/index.js&lt;/code&gt; file's tab is read &quot;Portfolio&quot; and all files follow this convention.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to somehow allow this feature in my Taboo settings so I won't have to set it every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at their example in setting it's naming convention &lt;a href=&quot;https://github.com/gcmt/taboo.vim#basic-options&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; I couldn't find a perfect fit for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:taboo_tab_format=&quot;%p%m&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this set my tabs to a very long path from the root of my system. But I only need from the basename of the current file I'm editing.&lt;/p&gt;&#xA;" OwnerUserId="6071" LastEditorUserId="1841" LastEditDate="2017-11-17T11:54:34.840" LastActivityDate="2017-11-19T01:30:33.983" Title="Taboo.vim to show basename of the current file" Tags="|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14242" PostTypeId="1" AcceptedAnswerId="14246" CreationDate="2017-11-17T13:28:11.877" Score="4" ViewCount="2325" Body="&lt;p&gt;The plugin fzf.vim defines the following vim command &lt;a href=&quot;https://github.com/junegunn/fzf.vim/blob/master/plugin/fzf.vim#L51&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command!      -bang -nargs=* Ag   call fzf#vim#ag(&amp;lt;q-args&amp;gt;, &amp;lt;bang&amp;gt;0)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;fzt#vim#ag&lt;/code&gt; function seems to allow passing all the ag options to the ag shell command. There is also a &lt;a href=&quot;https://github.com/junegunn/fzf.vim/blob/master/autoload/fzf/vim.vim#L654&quot; rel=&quot;nofollow noreferrer&quot;&gt;comment regarding this &lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; query, [[ag options], options]&#xA;function! fzf#vim#ag(query, ...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, no matter how I call it everything is passed as the first parameter &lt;code&gt;query&lt;/code&gt;. I've added bunch of logs to the script&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, calling &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Ag SearchString -c app&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and adding following logs to the above function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; query, [[ag options], options]&#xA;function! fzf#vim#ag(query, ...)&#xA;  if type(a:query) != s:TYPE.string&#xA;    return s:warn('Invalid query argument')&#xA;  endif&#xA;  let query = empty(a:query) ? '^(?=.)' : a:query&#xA;  let args = copy(a:000)&#xA;  let ag_opts = len(args) &amp;gt; 1 &amp;amp;&amp;amp; type(args[0]) == s:TYPE.string ? remove(args, 0) : ''&#xA;  let command = ag_opts . ' ' . fzf#shellescape(query)&#xA;  echo query&#xA;  echo ag_opts&#xA;  echo command&#xA;  return call('fzf#vim#ag_raw', insert(args, command, 0))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would print &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SearchString -c app&#xA; 'SearchString -c app'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;meaning &lt;code&gt;ag_opts&lt;/code&gt; was empty&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how to pass the other args as a query to this command?&lt;/p&gt;&#xA;" OwnerUserId="14337" LastEditorUserId="343" LastEditDate="2017-11-17T18:43:00.750" LastActivityDate="2017-11-17T18:43:00.750" Title="How to call the fzf Ag command with multiple arguments?" Tags="|vimscript|the-silver-searcher|argument-list|plugin-fzf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14244" PostTypeId="1" AcceptedAnswerId="14247" CreationDate="2017-11-17T18:17:17.233" Score="2" ViewCount="229" Body="&lt;p&gt;I'm trying to find words before the cursor using &lt;code&gt;searchpos&lt;/code&gt;, then use &lt;code&gt;matchlist&lt;/code&gt; to get the captures.  I can't find a reliable way to anchor the pattern for &lt;code&gt;matchlist&lt;/code&gt;.  For example, if the cursor is positioned on &lt;code&gt;[cursor]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; 3456789012345&#xA;&quot; !!foobar !!foobaz [cursor]  !!foobat&#xA;&#xA;let pat = '\%(!!\)\@&amp;lt;=fooba\(.\)'&#xA;let [l, c] = searchpos(pat, 'bWn')    &quot; returns [2, 14]&#xA;&#xA;echo 'pat1'&#xA;echo l c matchlist(getline(l), pat)                     | &quot; bad&#xA;echo l c matchlist(getline(l), pat, c-3)                | &quot; ok&#xA;echo l c matchlist(getline(l), '\%'.c.'c\%('.pat.'\)')  | &quot; ok&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;searchpos&lt;/code&gt; finds the column 14, since the look-behind is not included in the match.  The first &lt;code&gt;matchlist&lt;/code&gt; finds the wrong &lt;code&gt;fooba.&lt;/code&gt;.  Thus, I need to anchor the pattern using the column number.  The second alternative is not an option because it would require me to know how many characters were zero-width'd.  The third one works great, until...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let pat = '!!\zsfooba\(.\)'&#xA;let [l, c] = searchpos(pat, 'bWn')    &quot; also returns [2, 14]&#xA;&#xA;echo 'pat2'&#xA;echo l c matchlist(getline(l), pat)                     | &quot; bad&#xA;echo l c matchlist(getline(l), pat, c-3)                | &quot; ok&#xA;echo l c matchlist(getline(l), '\%'.c.'c\%('.pat.'\)')  | &quot; bad&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, prepending the column number doesn't work because although &lt;code&gt;\zs&lt;/code&gt; is zero-width, the stuff before it is not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I need a general-purpose solution since this is for a plugin and &lt;code&gt;pat&lt;/code&gt; is supplied by the user.&lt;/li&gt;&#xA;&lt;li&gt;I can't simply replace &lt;code&gt;\zs&lt;/code&gt; with &lt;code&gt;\%14c\zs&lt;/code&gt;, because there may be alternations &lt;code&gt;\|&lt;/code&gt; in the pattern.  For example &lt;code&gt;foo\%14c\zsbar\|foobaz&lt;/code&gt; will allow &lt;code&gt;foobaz&lt;/code&gt; in any position.&lt;/li&gt;&#xA;&lt;li&gt;This is not actually peculiar to &lt;code&gt;searchpos&lt;/code&gt;- the same would be seen with e.g., the character index from &lt;code&gt;match&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Negative look-behinds in &lt;code&gt;pat&lt;/code&gt; are possible.&lt;/li&gt;&#xA;&lt;li&gt;A perfect answer would include the possibility of &lt;code&gt;\ze&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-11-17T19:46:05.723" LastActivityDate="2018-01-20T23:31:55.993" Title="How to anchor matchlist after searchpos?" Tags="|regular-expression|matchlist|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14245" PostTypeId="2" ParentId="13952" CreationDate="2017-11-17T18:24:39.727" Score="2" Body="&lt;p&gt;Lemme try to analyze the syntax a little bit...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Everything inside &lt;code&gt;(&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt; are &lt;code&gt;pVars&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;pKeyword&lt;/code&gt; are a sequence of identifiers followed by &lt;code&gt;=&lt;/code&gt; but not &lt;code&gt;==&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;pParam&lt;/code&gt; are identifiers that are not &lt;code&gt;pKeyword&lt;/code&gt; nor a function call&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So... lemme get the &lt;code&gt;pVars&lt;/code&gt;: &lt;code&gt;:syn match pVars /\v\(\zs.*\ze\)/ contains=pKeyword,pParam&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested with &lt;code&gt;:hi pVars ctermfg=1&lt;/code&gt; so I can see if the &lt;code&gt;syn ...&lt;/code&gt; is correct.  With &lt;code&gt;:syn region&lt;/code&gt;, the last &lt;code&gt;Green&lt;/code&gt; isn't highlighted.  I guess that is not good -- so I excluded the brackets using &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; instead of using &lt;code&gt;:syn region&lt;/code&gt; (though we still got the inner brackets -- at least we saved the last Green).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, as suggested by @Rastapopoulos using &lt;code&gt;/\v\(\zs.*\ze\)/&lt;/code&gt; directly we can see the highlighted region without bothering with &lt;code&gt;:syn clear&lt;/code&gt;.  After testing the &lt;code&gt;/regex&lt;/code&gt;, we know the regex works and using &lt;code&gt;:hi pVars ctermfg=1&lt;/code&gt; helps us deal with &lt;code&gt;contained&lt;/code&gt; and &lt;code&gt;contains&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, the &lt;code&gt;pKeyword&lt;/code&gt;: &lt;code&gt;:syn match pKeyword /\i*\ze\s*=[^=]/ contained&lt;/code&gt;.  Oh we see the keywords &lt;em&gt;not&lt;/em&gt; highlighted anymore -- that means the regex is also working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, the &lt;code&gt;pParam&lt;/code&gt;: Let's start with &lt;code&gt;:hi pParam ctermfg=4&lt;/code&gt; so we can see which are captured just by look at the blue chars. &lt;code&gt;:syn match pParam /\i*\(\i*(\)\@!/ contained&lt;/code&gt;  We excluded functions calls by the logic of &quot;a sequence of identifiers, which is not followed by a sequence of identifiers with an open bracket &lt;code&gt;(&lt;/code&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wait, this is also having the issue of overwriting the highlighting for keywords!  &lt;code&gt;pParam&lt;/code&gt; needs to also exclude &lt;code&gt;pKeyword&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case, we make use of priorities! &lt;code&gt;:help syn-priority&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's reopen our vim to avoid the colors that we used to debug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rearranging gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn match pVars /\v\(\zs.*\ze\)/ contains=pKeyword,pParam&#xA;:syn match pParam /\i*\(\i*(\)\@!/ contained&#xA;:syn match pKeyword /\i*\ze\s*=[^=]/ contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then apply the colors.  See if it works?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DnggK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DnggK.png&quot; alt=&quot;Preview&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample Text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc = myFunc(Green, Orange=abcd(Green, orange=ab(abc(e),g)), Green, abcd(Orange=Green), Green)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;(Optional) Start Vim with &lt;code&gt;vim -Nu NONE&lt;/code&gt; to avoid plugins conflicting just in case.  Do &lt;code&gt;:hi pVars ctermfg=7 | hi pParam ctermfg=4 | hi pKeyword ctermfg=1&lt;/code&gt; to see highlighting in action.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Everything inside of () (excluding the outmost brackets) are &lt;code&gt;pVars&lt;/code&gt; that contains &lt;code&gt;pKeyword&lt;/code&gt; and &lt;code&gt;pParam&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:syn match pVars /\v\(\zs.*\ze\)/ contains=pKeyword,pParam&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;pParam&lt;/code&gt; is a sequence of identifiers, contained in &lt;code&gt;pVars&lt;/code&gt;, &lt;em&gt;not&lt;/em&gt; immediately followed by function names (Identifiers followed by an open bracket, i.e. &lt;code&gt;\i*(&lt;/code&gt;, note that &lt;code&gt;=&lt;/code&gt; is not identifier by default: &lt;code&gt;:help /character-classes&lt;/code&gt; &lt;code&gt;:help isident&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:syn match pParam /\i*\(\i*(\)\@!/ contained&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;pKeyword&lt;/code&gt; -- identifiers followed by a &lt;code&gt;=&lt;/code&gt; but not &lt;code&gt;==&lt;/code&gt;, overriding &lt;code&gt;pParam&lt;/code&gt; (as &lt;code&gt;pParam&lt;/code&gt; also catches keyword -- we can negative lookahead if we want though)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:syn match pKeyword /\i*\ze\s*=[^=]/ contained&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;(Extra) If we want to highlight function names inside &lt;code&gt;pVars&lt;/code&gt;, recall that in (2.) function names are identifiers followed by an open bracket:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:syn match pFunc /\i*\ze(/ containedin=pVars contained&lt;/code&gt; and use &lt;code&gt;:hi pFunc ctermfg=6&lt;/code&gt; to check.  However I haven't found a way to also highlight the outermost function call...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Q5tjw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Q5tjw.png&quot; alt=&quot;highlight inner function calls&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14820" LastEditorUserId="14820" LastEditDate="2017-11-18T06:25:41.433" LastActivityDate="2017-11-18T06:25:41.433" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14246" PostTypeId="2" ParentId="14242" CreationDate="2017-11-17T18:34:49.180" Score="5" Body="&lt;p&gt;&lt;strong&gt;TL;DR: You can't pass &lt;code&gt;ag&lt;/code&gt; options into &lt;em&gt;that&lt;/em&gt; command. (But jump to the bottom for a different one.)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the distinction between the &lt;code&gt;:Ag&lt;/code&gt; command and the &lt;code&gt;fzf#vim#ag&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:Ag&lt;/code&gt; command calls the &lt;code&gt;fzf#vim#ag&lt;/code&gt; function passing it exactly two arguments:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;q-args&amp;gt;&lt;/code&gt;: This is &lt;em&gt;all&lt;/em&gt; the arguments that were passed to the &lt;em&gt;command&lt;/em&gt;, passed as a &lt;em&gt;single&lt;/em&gt; argument. (See &lt;code&gt;:h &amp;lt;q-args&amp;gt;&lt;/code&gt;.)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;bang&amp;gt;0&lt;/code&gt;: &lt;code&gt;&amp;lt;bang&amp;gt;&lt;/code&gt; evaluates to &lt;code&gt;!&lt;/code&gt; if you typed an exclamation point after your command &lt;code&gt;:Ag!&lt;/code&gt; and nothing if you didn't. (See &lt;code&gt;:help &amp;lt;bang&amp;gt;&lt;/code&gt;.) So if you &lt;em&gt;didn't&lt;/em&gt; type an exclamation point then &lt;code&gt;0&lt;/code&gt; is passed as the second argument. And if you &lt;em&gt;did&lt;/em&gt;, then &lt;code&gt;!0&lt;/code&gt; is passed, i.e. the negation of &lt;code&gt;0&lt;/code&gt;, i.e. &lt;code&gt;1&lt;/code&gt;. (Try typing &lt;code&gt;:echo !0&lt;/code&gt; into Vim.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The function takes &lt;code&gt;fzf#vim#ag&lt;/code&gt; is defined with the signature:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! fzf#vim#ag(query, ...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means that inside the function:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The variable &lt;code&gt;a:query&lt;/code&gt; will contain the first argument to the function i.e. &lt;em&gt;all&lt;/em&gt; the arguments that were passed to the command.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The variable &lt;code&gt;a:000&lt;/code&gt; will either be the list &lt;code&gt;[0]&lt;/code&gt; or the list &lt;code&gt;[1]&lt;/code&gt;, depending on whether or not you used an exclamation point after the &lt;code&gt;:Ag&lt;/code&gt; command.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Inside the function &lt;code&gt;ag_opts&lt;/code&gt; is set with the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let args = copy(a:000)&#xA;let ag_opts = len(args) &amp;gt; 1 &amp;amp;&amp;amp; type(args[0]) == s:TYPE.string ? remove(args, 0) : ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first line just makes a copy of the list: &lt;code&gt;a:000&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second line then checks if the length of the list is greater than one. When called from the &lt;code&gt;:Ag&lt;/code&gt; command it never is, so &lt;code&gt;ag_opts&lt;/code&gt; is therefore &lt;em&gt;always&lt;/em&gt; set to the empty string: ''.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, if you want to pass options to the &lt;code&gt;ag&lt;/code&gt; executable, you cannot do it with the command you described in your question: I don't know whether the &lt;code&gt;fzf&lt;/code&gt; plugin currently offers different commands, or whether you will need to write your own, like &lt;a href=&quot;https://github.com/junegunn/fzf.vim/issues/92#issuecomment-191248596&quot; rel=&quot;noreferrer&quot;&gt;this one by the author of fzf&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:ag_with_opts(arg, bang)&#xA;  let tokens  = split(a:arg)&#xA;  let ag_opts = join(filter(copy(tokens), 'v:val =~ &quot;^-&quot;'))&#xA;  let query   = join(filter(copy(tokens), 'v:val !~ &quot;^-&quot;'))&#xA;  call fzf#vim#ag(query, ag_opts, a:bang ? {} : {'down': '40%'})&#xA;endfunction&#xA;&#xA;autocmd VimEnter * command! -nargs=* -bang Ag call s:ag_with_opts(&amp;lt;q-args&amp;gt;, &amp;lt;bang&amp;gt;0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-17T18:40:06.657" LastActivityDate="2017-11-17T18:40:06.657" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14247" PostTypeId="2" ParentId="14244" CreationDate="2017-11-17T19:22:27.283" Score="0" Body="&lt;p&gt;The problem seems to be that is that &lt;code&gt;searchpos&lt;/code&gt; is searching backwards (from the position of the cursor) and &lt;code&gt;matchlist&lt;/code&gt; is searching forwards (from the start of the line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about altering the way we call &lt;code&gt;matchlist&lt;/code&gt; to search backwards too, via the time honoured technique of brute force?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let line1 = getline(l)&#xA;let line2 = getline(l)[c:]&#xA;let line1 = line1[:c-1]&#xA;&#xA;&quot; We want to ignore matches found *after* the position returned by &#xA;&quot; searchpos()&#xA;let boo = matchlist(line2, pat)&#xA;&#xA;while len(line1) &amp;gt; 0&#xA;  let line2 = line1[-1:] . line2&#xA;  let line1 = line1[:-2]&#xA;  let yay = matchlist(line2, pat)&#xA;  if len(yay) &amp;gt; 0 &amp;amp;&amp;amp; yay != boo&#xA;    echo l c yay&#xA;    break&#xA;  endif&#xA;endwhile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's ugly and inefficient, and I have a feeling it might be possible to construct a complicated regular expression that breaks it, but it works for the test cases given.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-21T22:57:38.250" LastActivityDate="2017-11-21T22:57:38.250" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14248" PostTypeId="2" ParentId="4148" CreationDate="2017-11-17T21:50:02.157" Score="2" Body="&lt;p&gt;A much much simpler way without plugins or external commands to remap join (&lt;code&gt;J&lt;/code&gt;) from a space to whatever character you like. For instance, to join with a comma and a space:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap J :s/\n/, /^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the special character newline at the end (&lt;code&gt;^M&lt;/code&gt;) press &lt;code&gt;Ctrl-V&lt;/code&gt; and then Return/Enter. Same goes if you want to replace with a tab (&lt;code&gt;^I&lt;/code&gt;), type &lt;code&gt;Ctrl-I&lt;/code&gt; then &lt;code&gt;Tab&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap J :s/\n/^I/^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this is doing is replacing a newline with a tab on the current line and remapping that behavior to the J character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also works with combinations, as in &lt;code&gt;4J&lt;/code&gt; to join the next 4 lines.&lt;/p&gt;&#xA;" OwnerUserId="15157" LastEditorUserId="51" LastEditDate="2017-11-18T01:40:05.200" LastActivityDate="2017-11-18T01:40:05.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14249" PostTypeId="1" CreationDate="2017-11-18T04:46:16.400" Score="0" ViewCount="505" Body="&lt;p&gt;When I open vim, the &lt;code&gt;~&lt;/code&gt; representing no lines are highlighted according to&#xA;&lt;code&gt;SpecialComment&lt;/code&gt;. So too are the characters in &lt;code&gt;'listchars'&lt;/code&gt; (e.g, &lt;code&gt;:set list&#xA;lcs=tab:\|\&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I insert text that is highlighted as &lt;code&gt;SpecialComment&lt;/code&gt; on my own?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to make plugin that puts &quot;special comments&quot;: for example, create a box&#xA;comment in any language:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-----------------&#xA;|print('hello') |&#xA;-----------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----------------------&#xA;|printf(&quot;hello word&quot;)|&#xA;----------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I would like the highlighting to use &lt;code&gt;SpecialComment&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;SpecialComment&lt;/code&gt; colors only appear in vim. Is it possible to insert special&#xA;comment text with the keyboard?&lt;/p&gt;&#xA;" OwnerUserId="15162" LastEditorUserId="10604" LastEditDate="2019-10-17T21:05:03.733" LastActivityDate="2019-10-17T21:05:03.733" Title="SpecialComment in vim" Tags="|comments|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="14250" PostTypeId="1" CreationDate="2017-11-18T05:26:50.240" Score="1" ViewCount="68" Body="&lt;p&gt;I want to be able to automatically apply my personal patches to plugins when they are updated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I would like to apply &lt;a href=&quot;https://github.com/dalejung/vim-fugitive/commit/21b91d4c18dcdf2a6292a172ab09776d41a6b715&quot; rel=&quot;nofollow noreferrer&quot;&gt;this patch&lt;/a&gt; every time the &lt;code&gt;vim-fugitive&lt;/code&gt; plugin is updated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;a href=&quot;https://github.com/Shougo/neobundle.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;neobundle&lt;/a&gt; to manage my plugins, and would like to be able to do &lt;code&gt;:NeoBundleCheckUpdate&lt;/code&gt; and have the latest upstream changes pulled, and then my patches / commits applied, and then have &lt;code&gt;vim&lt;/code&gt; use the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to automatically apply patches to plugins when they are updated upstream?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastActivityDate="2017-11-18T13:17:24.577" Title="Automatically apply patches when updating plugins" Tags="|plugin-system|plugin-neobundle|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14251" PostTypeId="2" ParentId="4148" CreationDate="2017-11-18T07:41:49.130" Score="6" Body="&lt;p&gt;Just in case someone doesn't like typing Regex and memorizing more Plugin Ex Commands:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Visual-block Append&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Visual-block Append is available in the Visual Block mode (&lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;) and can do a block &lt;strong&gt;A&lt;/strong&gt;ppend (and block &lt;strong&gt;I&lt;/strong&gt;nsert for prepend). (ref: &lt;code&gt;:help v_b_A&lt;/code&gt;, &lt;code&gt;:help v_b_I&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if the last motion in Block Visual Mode is &lt;code&gt;$&lt;/code&gt;, the append will be done at the end of all selections; or else spaces will be inserted before the text you appended (imagine aligning closing &lt;code&gt;)&lt;/code&gt; at the end of several method calls in code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With sample text below and cursor on &lt;code&gt;8&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;8&#xA;9&#xA;10&#xA;12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;}$A,&amp;lt;C-c&amp;gt;&lt;/code&gt;.  After going back to normal mode, we can see &lt;code&gt;,&lt;/code&gt; is appended to all selected lines. (Try without &lt;code&gt;$&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then do &lt;code&gt;gv&lt;/code&gt; to re-select the area and &lt;code&gt;J&lt;/code&gt; or &lt;code&gt;gJ&lt;/code&gt;.  We have a trailing &lt;code&gt;,&lt;/code&gt;: &lt;code&gt;8,9,10,12,&lt;/code&gt; and &lt;code&gt;$x&lt;/code&gt; we're done.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Use Insert for No Trailing &lt;code&gt;,&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Let's undo our text (be it &lt;code&gt;uu..u&lt;/code&gt; or a fancy &lt;code&gt;:ea 1d&amp;lt;cr&amp;gt;:lat 1&lt;/code&gt;), and try Visual Insert:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;j&amp;lt;C-v&amp;gt;}I, &amp;lt;C-c&amp;gt;&lt;/code&gt; and then we can join the lines with &lt;code&gt;gJ&lt;/code&gt; for no spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wait wait wait, something is missing.  How to re-select the whole &quot;array&quot;?  This time we didn't select the first line... so &lt;code&gt;gv&lt;/code&gt; doesn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-- Or it may help, &lt;code&gt;gvok&lt;/code&gt; is re-select (&lt;code&gt;gv&lt;/code&gt;), &lt;code&gt;o&lt;/code&gt;pposite corner and &lt;code&gt;k&lt;/code&gt; up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;P.S. My pinky isn't quick and accurate enough to type &lt;code&gt;/\&lt;/code&gt; for &lt;code&gt;/\n&lt;/code&gt;, so I like combining Vim built-in operations and movements to avoid using Regex.  However if I do this frequent enough, using a mapping -- maybe ones that map to plugins should be better.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2017-11-18T07:41:49.130" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14252" PostTypeId="2" ParentId="12048" CreationDate="2017-11-18T08:55:08.077" Score="0" Body="&lt;p&gt;I think my issue was related to &lt;a href=&quot;https://github.com/vim/vim/issues/1098&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/issues/1098&lt;/a&gt; I've updated to vim 8.0 and it seems to have fixed it.&lt;/p&gt;&#xA;" OwnerUserId="12162" LastActivityDate="2017-11-18T08:55:08.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14253" PostTypeId="2" ParentId="14228" CreationDate="2017-11-18T09:58:01.050" Score="3" Body="&lt;p&gt;To find files which contains some string, the &lt;code&gt;:grep&lt;/code&gt; command is &quot;for that&quot;.  And I know it's quite slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that purpose, I have added the &lt;code&gt;:Find&lt;/code&gt; command to my &lt;code&gt;.vimrc&lt;/code&gt;:  (From this &lt;a href=&quot;https://medium.com/@crashybang/supercharge-vim-with-fzf-and-ripgrep-d4661fc853d2&quot; rel=&quot;nofollow noreferrer&quot;&gt;post&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --glob &quot;!.git/*&quot; --color &quot;always&quot; '.shellescape(&amp;lt;q-args&amp;gt;), 1, &amp;lt;bang&amp;gt;0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that with &lt;code&gt;--fixed-strings&lt;/code&gt; we don't have to quote the string so we theoretically should just do &lt;code&gt;:Find a string with space&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way I am also using &lt;code&gt;set grepprg=rg\ --vimgrep&lt;/code&gt; so instead of the original slow &lt;code&gt;:grep&lt;/code&gt; or &lt;code&gt;:Ag&lt;/code&gt;, I can use &lt;code&gt;:grep finder&lt;/code&gt; to find &lt;strong&gt;files that contains the word &quot;finder&quot;&lt;/strong&gt;, powered by &lt;code&gt;rg&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And use &lt;code&gt;:Ag&lt;/code&gt; (or &lt;code&gt;:FZF&lt;/code&gt;) to find &lt;strong&gt;files that has &quot;finder&quot; in their names&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2017-11-18T09:58:01.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14254" PostTypeId="2" ParentId="14250" CreationDate="2017-11-18T13:17:24.577" Score="2" Body="&lt;p&gt;Note that Neobundle is &lt;a href=&quot;https://github.com/Shougo/neobundle.vim/blob/master/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;not maintained by its author anymore&lt;/a&gt;, it has been replaced by &lt;a href=&quot;https://github.com/shougo/dein.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dein.vim &lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Dein.vim you have a post update hook option available (see &lt;a href=&quot;https://github.com/Shougo/dein.vim/blob/master/doc/dein.txt#L840-L843&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h dein-options-hook_post_update&lt;/code&gt;&lt;/a&gt;) which allows you to execute a function after a plugin is updated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then create a function (in vim or with an external tool) which will apply the patch you want.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-11-18T13:17:24.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14255" PostTypeId="1" AcceptedAnswerId="14256" CreationDate="2017-11-18T17:30:38.143" Score="2" ViewCount="96" Body="&lt;p&gt;Right now I press &lt;code&gt;ce&lt;/code&gt; to replace a word. However, this overrides anything that was in my register before. How can I replace a word and go into insert mode after without replacing what was in my register previously?&lt;/p&gt;&#xA;" OwnerUserId="14523" LastActivityDate="2017-11-21T20:09:36.703" Title="How do I replace a word without putting the word into a register?" Tags="|replace|register|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14256" PostTypeId="2" ParentId="14255" CreationDate="2017-11-18T17:34:12.130" Score="6" Body="&lt;p&gt;You need to use the black hole register (see &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#quote_&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h quote_&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When writing to this register, nothing happens.  This can be used to delete&#xA;  text without affecting the normal registers.  When reading from this register,&#xA;  nothing is returned.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Simply do &lt;code&gt;&quot;_ce&lt;/code&gt; so that the deleted text will be put into the black hole register and not into your unnamed register.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-11-18T17:34:12.130" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14257" PostTypeId="2" ParentId="6827" CreationDate="2017-11-18T21:08:33.777" Score="0" Body="&lt;p&gt;If you're using the GUI:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Error gui=reverse guibg=White guifg=Red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15167" LastActivityDate="2017-11-18T21:08:33.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14258" PostTypeId="2" ParentId="12150" CreationDate="2017-11-19T00:22:23.470" Score="1" Body="&lt;p&gt;This is actually a Vim bug (inherited in Nvim), which wasn't noticeable until the use-case you describe became common.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bug report: &lt;a href=&quot;https://github.com/neovim/neovim/issues/7429&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neovim/neovim/issues/7429&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pull request: &lt;a href=&quot;https://github.com/neovim/neovim/pull/7431&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neovim/neovim/pull/7431&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="578" LastActivityDate="2017-11-19T00:22:23.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14259" PostTypeId="2" ParentId="14241" CreationDate="2017-11-19T01:15:51.413" Score="2" Body="&lt;p&gt;According to the doc you linked &lt;code&gt;%p&lt;/code&gt; (lower case pee) displays the  tab's current working directory which may be a full path. &lt;code&gt;%P&lt;/code&gt; (&lt;em&gt;upper case&lt;/em&gt; pee) displays only the last component of that directory (it's &quot;tail&quot;). For directory &lt;code&gt;/foo/bar/baz&lt;/code&gt; that would show just &lt;code&gt;baz&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that when you open a new file/buffer Vim won't by default change the current working directory to the location of that file. If you want that add &lt;code&gt;set autochdir&lt;/code&gt; in your vimrc. (FYI, the help for this option says &quot;Note: When this option is on some plugins may not work.&quot;)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-11-19T01:30:33.983" LastActivityDate="2017-11-19T01:30:33.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14260" PostTypeId="2" ParentId="14249" CreationDate="2017-11-19T03:17:45.910" Score="2" Body="&lt;p&gt;&lt;em&gt;Background (added 10/2019): when I originally saw this I considered two possible interpretations of your (OP's) request. First, I thought you might be under the impression that syntax highlighting works in a similar fashion as Bash text coloring, i.e. escape codes or equivalent are inserted in plain text and they dictate coloring and formatting for displayed text (escape codes are hidden in display contexts). This is not how Vim works. No directives or meta text exist. It's a (regex) pattern driven system.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;My alternate interpretation was that you want to deliberately type text that will be displayed with a particular highlighting (such as SpecialComment). That's what the original answer covers...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It depends. Highlighting is applied based on the current set of syntax highlighting rules. The current rules are dictated (usually) by the type of file we're editing. You can't open a random file and just know how to enter text &quot;with keyboard&quot; that will get highlighted with SpecialComment coloring. You must be familiar with the rules for the current file type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I open a file with extension &lt;code&gt;.java&lt;/code&gt; I know one way to see SpecialComment highlighting is to enter the first line of text in a javadoc comment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA; * This text is highlighted as a SpecialComment&#xA; *&#xA; * This text is not.&#xA; */&#xA;public void foo() {&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The rules are stored in files under &lt;code&gt;$VIMRUNTIME/syntax&lt;/code&gt;. For the example above it would be &lt;code&gt;java.vim&lt;/code&gt; where you'll find:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi def link javaCommentTitle        SpecialComment&#xA;&#xA;syn region  javaCommentTitle    contained matchgroup=javaDocComment start=&quot;/\*\*&quot;   matchgroup=javaCommentTitle keepend end=&quot;\.$&quot; end=&quot;\.[ \t\r&amp;lt;&amp;amp;]&quot;me=e-1 end=&quot;[^{]@&quot;me=s-2,he=s-1 end=&quot;\*/&quot;me=s-1,he=s-1 contains=@javaHtml,javaCommentStar,javaTodo,@Spell,javaDocTags,javaDocSeeTag&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-10-17T18:39:49.553" LastActivityDate="2019-10-17T18:39:49.553" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="14261" PostTypeId="1" AcceptedAnswerId="14262" CreationDate="2017-11-19T05:51:08.603" Score="3" ViewCount="725" Body="&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;&amp;lt;cr&amp;gt; :execute &quot;normal! i\\\&amp;lt;cr&amp;gt;\&amp;lt;esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run that, it says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E114: Missing quote: &quot;normal! i\\\&#xA;E15: Invalid expression: &quot;normal! i\\\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's wrong with this?  I'm trying to press &lt;code&gt;i&lt;/code&gt; to go into insert mode, add a  &lt;code&gt;\&lt;/code&gt; character, enter a newline, then escape.&lt;/p&gt;&#xA;" OwnerUserId="15080" LastActivityDate="2023-04-30T17:59:47.657" Title="Why am I missing a quote in this remap?" Tags="|key-bindings|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14262" PostTypeId="2" ParentId="14261" CreationDate="2017-11-19T06:01:47.433" Score="5" Body="&lt;p&gt;You used the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;&amp;lt;cr&amp;gt; :execute &quot;normal! i\\\&amp;lt;cr&amp;gt;\&amp;lt;esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the command which does what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;&amp;lt;cr&amp;gt; :execute &quot;normal! i\\\n&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First, &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; has special meaning to &lt;code&gt;:map&lt;/code&gt; (and &lt;code&gt;:abbrev&lt;/code&gt; and a couple others). Most of the rhs of a mapping is processed literally, as if you were typing those characters.  With &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;, &lt;code&gt;:map&lt;/code&gt; acts as if you hit &lt;kbd&gt;Enter&lt;/kbd&gt;. That leaves you submitting &lt;code&gt;:execute &quot;normal! i\\\&lt;/code&gt; ... an incomplete command and thus you get the &quot;Missing quote&quot; error. &lt;code&gt;\n&lt;/code&gt; has no such special meaning, it's just another character and is passed to &lt;code&gt;:execute&lt;/code&gt; in the string parameter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, you don't need to explicitly escape just like you wouldn't if you directly entered &lt;code&gt;:execute &quot;normal! i\\\n&quot;&lt;/code&gt;. Once you hit &lt;kbd&gt;Enter&lt;/kbd&gt; in that case (which we're doing in the mapping with the &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; at the end) the insert occurs and you are returned back to command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to use &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; ;) here's another way to do it...and I'm sure some folks would prefer this version...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;&amp;lt;cr&amp;gt; :star&amp;lt;cr&amp;gt;\&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;:star&lt;/code&gt; is short for &lt;code&gt;:startinsert&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="1841" LastEditDate="2017-11-27T09:46:06.897" LastActivityDate="2017-11-27T09:46:06.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14263" PostTypeId="1" AcceptedAnswerId="14264" CreationDate="2017-11-19T12:08:51.837" Score="0" ViewCount="260" Body="&lt;p&gt;I want to rename my. &quot;.vimrc&quot; as &quot;bob.vimrc&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I want to put it inside &quot;/Users/bob/bobs bits&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can tell, I'm on a Mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But everything keeps going wrong. I don't want a &quot;.vimrc&quot; symlink in ~, because bob wants all sorts of things in &quot;bobs bits&quot; in his folder - keys for vpns, encrypted text files etc, so he doesn't want the operating systems tentacles reaching into his stuff. He just wants to just move his &quot;Bob's bits&quot; to other systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Someone told me I could do: vim -u &quot;/Users/bob/bobs bits/bob.vimrc&quot; bobsnewfile. But his functions come out funny - vim types them out rather that executing them.&lt;/p&gt;&#xA;" OwnerUserId="2985" LastEditorDisplayName="user5791" LastEditDate="2019-01-30T05:58:04.980" LastActivityDate="2019-01-30T05:58:04.980" Title="Renaming .vimrc and putting into other folder" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="14264" PostTypeId="2" ParentId="14263" CreationDate="2017-11-19T16:42:24.557" Score="3" Body="&lt;p&gt;First off, you can place your vimrc contents in &lt;code&gt;~/.vim/vimrc&lt;/code&gt; (except on some platforms, see &lt;code&gt;:h vimrc&lt;/code&gt; for specifics).  If your goal is to eliminate the &lt;code&gt;~/.vim&lt;/code&gt; folder however, you will need to set the &lt;code&gt;VIMINIT&lt;/code&gt; environment variable.  This variable is an ex command line (series of ex commands separated by &lt;code&gt;|&lt;/code&gt;) which are run when vim starts up.  For example, you could use the following in your bashrc (setting environment variables is platform dependent, you should modify for your platform).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;export VIMINIT=&quot;let \$MYVIMRC='XXXwhatever/vimrcXXX' | source \$MYVIMRC&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where vim looks for your personal vimrc is well documented:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h vimrc-intro&lt;/code&gt;, &lt;code&gt;:h $VIM&lt;/code&gt;, &lt;code&gt;:h startup&lt;/code&gt;, &lt;code&gt;:h $MYVIMRC&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-11-19T16:42:24.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14266" PostTypeId="1" CreationDate="2017-11-19T20:10:00.787" Score="-2" ViewCount="83" Body="&lt;p&gt;Here is my .profile (macs don't usually bother with .bashrc)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export VIMINIT=&quot;let $MYVIMRC='/Users/user/userbits/future.vimrc' | source $MYVIMRC&quot;&#xA;source /Users/user/userbits/future.source`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation: &lt;code&gt;/Users&lt;/code&gt; is where users go on macs. It's like &lt;code&gt;/home&lt;/code&gt; in Linux. I've unimaginatively called my user &lt;code&gt;user&lt;/code&gt;. The folder where I want all his things is called &lt;code&gt;/Users/user/userbits&lt;/code&gt;. And I want his &lt;code&gt;.vimrc&lt;/code&gt;in there too, renamed as &lt;code&gt;future.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second line of the code sources a file called &lt;code&gt;/Users/user/userbits/future.source&lt;/code&gt; which is kind of like my &lt;code&gt;.bashrc&lt;/code&gt; - it sets up lots of functions and netrw things. With a &lt;code&gt;.vimrc&lt;/code&gt; in a normal place (eg. `/Users/user/.vimrc') everything works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But whats going wrong when I rename my&lt;code&gt;.vimrc&lt;/code&gt; to &lt;code&gt;future.vimrc&lt;/code&gt; and put it in &lt;code&gt;/Users/user/userbits&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last poster seemed to have it so right, and I've been going through his/her suggested reading for hours. Why can't I do it?&lt;/p&gt;&#xA;" OwnerUserId="2985" LastEditorUserId="2985" LastEditDate="2017-11-19T20:17:10.273" LastActivityDate="2017-11-20T00:36:26.053" Title="Damn I can't do it" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ClosedDate="2017-11-20T08:54:10.450" ContentLicense="CC BY-SA 3.0" />
  <row Id="14267" PostTypeId="2" ParentId="14266" CreationDate="2017-11-20T00:36:26.053" Score="0" Body="&lt;p&gt;Yesss! It works. I thought the backslashes were to make the code more readable, but then you inspired me to turn my phone on its side. Here is my finished . profile for anyone interested in this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export VIMINIT=&quot;let \$MYVIMRC='/Users/user/user bits/future.vimrc' | source \$MYVIMRC&quot;&#xA;source /Users/user/userbits/future.source&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(So happy. Thank you Mass)&lt;/p&gt;&#xA;" OwnerUserId="2985" LastActivityDate="2017-11-20T00:36:26.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14268" PostTypeId="2" ParentId="13494" CreationDate="2017-11-20T11:20:54.663" Score="1" Body="&lt;p&gt;&lt;em&gt;Additionally and as an alternative:&lt;/em&gt;&lt;br&gt;&#xA;if you only want to &lt;strong&gt;append&lt;/strong&gt; something &lt;strong&gt;onto an allready filled register&lt;/strong&gt;,&lt;br&gt;&#xA;you can use the &quot;uppercase-version&quot; of the register-name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you're marking a line of text with &lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;,&lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;you'r &quot;yanking&quot; that text into register @a with &lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;&quot;&lt;/kbd&gt;, &lt;strong&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;/strong&gt;, &lt;kbd&gt;y&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;next you're marking another line of text ...&lt;/li&gt;&#xA;&lt;li&gt;and this one, you're appending onto register @a with &lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;&quot;&lt;/kbd&gt;, &lt;strong&gt;&lt;kbd&gt;A&lt;/kbd&gt;&lt;/strong&gt;, &lt;kbd&gt;y&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As result you have two lines of text in register @a.&lt;/p&gt;&#xA;" OwnerUserId="8319" LastActivityDate="2017-11-20T11:20:54.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14269" PostTypeId="1" CreationDate="2017-11-20T12:43:53.477" Score="7" ViewCount="1885" Body="&lt;p&gt;Is it possible to change how a character is displayed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I explain better, I want to replace the character '*' with math unicode '∗' [U+2217]. This should affect only the way the character is displayed not the file content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I have already tried to use the conceal feature, however I am not really satisfied by the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to have a behaviour similar to listchars and list&#xA;for example listchars=space:. &lt;/p&gt;&#xA;" OwnerUserId="11117" LastActivityDate="2017-11-20T14:14:47.360" Title="change how a character is displayed" Tags="|conceal|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14270" PostTypeId="2" ParentId="14269" CreationDate="2017-11-20T14:04:37.173" Score="8" Body="&lt;p&gt;So as suggested I will give the solution I found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After having&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set conceallevel=1&#xA;set concealcursor=ni&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;there are two ways to achieve the result:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) using &lt;code&gt;:syntax match&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match Conceal /\*/ conceal cchar=∗&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2) using &lt;code&gt;matchadd&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd('Conceal','\*',10,-1,{'conceal': '∗'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;10 is the priority (default is 10)&lt;/li&gt;&#xA;&lt;li&gt;-1 is the match ID (see &lt;code&gt;help matchadd&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You might also consider&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi! link Conceal Normal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to link the syntax highlighting of Conceal group to Normal group. &lt;/p&gt;&#xA;" OwnerUserId="11117" LastEditorUserId="343" LastEditDate="2017-11-20T14:14:47.360" LastActivityDate="2017-11-20T14:14:47.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14271" PostTypeId="1" CreationDate="2017-11-20T16:36:48.780" Score="2" ViewCount="442" Body="&lt;p&gt;Is there a way in which if you move file A to another location and there are other files that have imported file A, the import path will change accordingly in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PyCharm has this and I was wondering if this could be implemented for Vim. An example written in Python:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;main.py&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from projects.scripts import file_a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then move file_a.py to projects/final. If I'm using PyCharm, main.py will be updated with the new import path&lt;/p&gt;&#xA;&#xA;&lt;p&gt;main.py&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from projects.final import file_a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15188" LastEditorUserId="15188" LastEditDate="2017-11-20T16:53:22.737" LastActivityDate="2018-01-19T17:19:49.360" Title="Automatically update import path if file is moved in Vim" Tags="|filetype-python|path|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14272" PostTypeId="2" ParentId="3" CreationDate="2017-11-20T16:51:43.517" Score="14" Body="&lt;p&gt;If you want to use a hotkey for toggling relative line number, here is a snippet in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Toggle relative line number&#xA;nmap &amp;lt;C-L&amp;gt;&amp;lt;C-L&amp;gt; :set invrelativenumber&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, I use ctrl-L twice to toggle it.&lt;/p&gt;&#xA;" OwnerUserId="15190" LastActivityDate="2017-11-20T16:51:43.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14273" PostTypeId="2" ParentId="14271" CreationDate="2017-11-20T16:58:26.553" Score="1" Body="&lt;p&gt;I'm afraid vim can't listen for files moved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is to check how Eunuch plugin works regarding moving files, then you'll need to search for all files that import the moved one, and to update them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also provide a service &quot;ModePythonFile&quot; built on top of Eunuch.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-11-20T16:58:26.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14274" PostTypeId="1" AcceptedAnswerId="14278" CreationDate="2017-11-20T17:10:30.250" Score="4" ViewCount="3736" Body="&lt;p&gt;An operation I do often in vim is to replace the word at the cursor with a single letter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I do this via:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; x &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Where x is my replacement letter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This isn't bad, but is there a way to do this without entering insert mode, so that I don't have to hit Escape when I'm done?&lt;/p&gt;&#xA;" OwnerUserId="15191" LastEditorUserId="15191" LastEditDate="2017-11-20T19:15:31.160" LastActivityDate="2017-11-25T00:57:00.090" Title="Replace the word at the cursor with a single character?" Tags="|normal-mode|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14275" PostTypeId="2" ParentId="14274" CreationDate="2017-11-20T17:43:31.240" Score="5" Body="&lt;p&gt;There is no builtin solution. And I fail to find a one liner. If I put &lt;code&gt;eatchar()&lt;/code&gt; directly in a mapping, it'll see what follows in the mapping instead of what the user will type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following isn't very ergonomic, but it'll work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:repl1() abort&#xA;  let c = nr2char(getchar())&#xA;  exe &quot;normal! ciw&quot;.c.&quot;\&amp;lt;esc&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;&quot; use anything you wish instead of &quot;µ&quot; to trigger the mapping    &#xA;nnoremap &amp;lt;silent&amp;gt; µ :call &amp;lt;sid&amp;gt;repl1()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: See Daniel Kaplan's answer for a oneliner&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, it's also possible to define our own operator (&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#g%40&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h g@&lt;/code&gt;&lt;/a&gt;), so instead of &lt;code&gt;µ&lt;/code&gt;, we could type &lt;code&gt;µiw&lt;/code&gt; (for the current word), &lt;code&gt;µw&lt;/code&gt; (from the cursor position to the end of the current word), and so on. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:opfunc(type) abort&#xA;  let motion = a:type == 'line' ? &quot;'[v']&quot; : '`[v`]'&#xA;  silent exe &quot;normal! &quot;.motion.&quot;c&quot;.nr2char(getchar()).&quot;\&amp;lt;esc&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; µ :set opfunc=&amp;lt;sid&amp;gt;opfunc&amp;lt;cr&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that, I've still haven't found how to force a redraw where we see we're in REPLACE-mode. The best I can come up with is the following, inspired by Daniel Kaplan's solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  silent exe &quot;normal! &quot;.motion.&quot;c¤\&amp;lt;esc&amp;gt;&quot;&#xA;  redraw&#xA;  silent exe &quot;normal! r&quot;.nr2char(getchar())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-11-20T18:32:24.783" LastActivityDate="2017-11-20T18:32:24.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14276" PostTypeId="2" ParentId="14274" CreationDate="2017-11-20T17:44:22.420" Score="6" Body="&lt;p&gt;I couldn't find a way to do this in the docs, so I created a mapping to do it.  You can type this into your .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;rw vwhhc.&amp;lt;esc&amp;gt;r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let me break it down:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vw -&amp;gt; highlight a word&#xA;hh -&amp;gt; go left twice because highlighting a word puts your cursor on the next word, and you don't want to change it&#xA;c  -&amp;gt; change what's highlighted (this will delete the word)&#xA;.  -&amp;gt; put a period there&#xA;&amp;lt;esc&amp;gt; -&amp;gt; go to normal mode&#xA;r -&amp;gt; press r on the period.  The next button you press will replace that . with the character you want.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15080" LastActivityDate="2017-11-20T17:44:22.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14277" PostTypeId="2" ParentId="14274" CreationDate="2017-11-20T19:23:19.030" Score="2" Body="&lt;p&gt;I would do it this way (overkill perhaps):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=1 RW :call ReplaceWord(&amp;lt;f-args&amp;gt;)&#xA;fun! ReplaceWord(char)&#xA;    sil exe &quot;s/&quot; . expand('&amp;lt;cword&amp;gt;') . &quot;/&quot; . a:char . &quot;/&quot;&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can just type &lt;code&gt;:RW x&lt;/code&gt; with your cursor over the word you want to replace. RW stands for &quot;replace word&quot; but you could choose your own preferred command name.&lt;/p&gt;&#xA;" OwnerUserId="10168" LastActivityDate="2017-11-20T19:23:19.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14278" PostTypeId="2" ParentId="14274" CreationDate="2017-11-20T19:24:56.677" Score="9" Body="&lt;p&gt;&lt;code&gt;rXldw&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace the first character with X then move right and delete the rest of the word. No insert mode required. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;rXlde&lt;/code&gt; is actually needed if you are working with a word with trailing space, rather than a delimiter.&lt;/p&gt;&#xA;" OwnerUserId="15194" LastEditorUserId="15194" LastEditDate="2017-11-20T20:48:10.650" LastActivityDate="2017-11-20T20:48:10.650" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14279" PostTypeId="2" ParentId="14274" CreationDate="2017-11-20T20:00:14.473" Score="4" Body="&lt;p&gt;This is an improvement on &lt;a href=&quot;https://vi.stackexchange.com/a/14276/2920&quot;&gt;Daniel Kaplan's answer.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;rw &quot;ciw&quot;.nr2char(getchar()).&quot;\&amp;lt;esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are a couple improvements here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;This uses &lt;code&gt;ciw&lt;/code&gt; instead of &lt;code&gt;vwhhc&lt;/code&gt;. This is shorter and more idiomatic, doesn't move your visual selection marks &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt;, and more importantly, works at the end of a word instead of just at the beginning.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This doesn't do anything until you choose what character you're replacing the word with.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-11-20T20:00:14.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14280" PostTypeId="1" CreationDate="2017-11-20T20:13:05.900" Score="0" ViewCount="85" Body="&lt;p&gt;(Vim 8.0, Windows 7)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to make an autocmd for loading a certain file, that scrolls down five lines from the beginning of the file. It does other things too, so the autocmd itself (inside of an &lt;code&gt;augroup filetype&lt;/code&gt;, incidentally) is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile foo.txt   so $VIM/foo.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;foo.vim&lt;/code&gt; contains various other commands, plus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;norm! 5^E&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I run the above &lt;code&gt;norm&lt;/code&gt; command manually, it does exactly what I want. However, when I use the autocmd, the buffer ends up with the cursor on line 5, but with line 1 still visible. I get the same behavior if I replace &lt;code&gt;^E&lt;/code&gt; with &lt;code&gt;^D&lt;/code&gt;. Nothing also seems to happen if I follow either one with &lt;code&gt;z^M&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could find nothing in the documentation for &lt;code&gt;au&lt;/code&gt;, &lt;code&gt;so&lt;/code&gt;, &lt;code&gt;^E&lt;/code&gt;, or &lt;code&gt;norm&lt;/code&gt; that addresses this. Is it a bug? Or am I missing something obvious?&lt;/p&gt;&#xA;" OwnerUserId="12718" LastActivityDate="2017-11-21T10:22:39.577" Title="norm ^E command works when I type it manually, but fails in an autoloaded vim file. Why?" Tags="|autocmd|scrolling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14281" PostTypeId="1" CreationDate="2017-11-21T07:44:10.963" Score="0" ViewCount="454" Body="&lt;p&gt;I have no idea how to do this, but here's my idea:  Highlight some text in visual mode, type an ex command and a file name.  &lt;em&gt;It takes that highlighted text, deletes it, and appends it to the file you specify, creating it if it doesn't already exist.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've italicized the parts I don't know how to do.  &lt;/p&gt;&#xA;" OwnerUserId="15080" LastActivityDate="2017-11-21T23:07:42.937" Title="Moving highlighted text to another file" Tags="|key-bindings|ex-mode|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14282" PostTypeId="2" ParentId="14280" CreationDate="2017-11-21T10:22:39.577" Score="1" Body="&lt;p&gt;Check whether you have a non-zero value for &lt;code&gt;'scrolloff'&lt;/code&gt;. This forces a minimum number of lines to be visible above/below the cursor. A value of 5 or more in this case would result in exactly the behavior you mention: cursor in the right place but top of the file still visible. A quick-and-diry test would be to just &lt;code&gt;:set scrolloff=0&lt;/code&gt; right before the &lt;code&gt;au&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, indeed, &lt;code&gt;'scrolloff'&lt;/code&gt; appears to be non-zero but you are not setting it yourself then are you using a personal vimrc file? If &lt;em&gt;not&lt;/em&gt;, note that Vim 8 has new behavior where it will source &lt;code&gt;$VIMRUNTIME/defaults.vim&lt;/code&gt; automatically if user vimrc is not found and in that file &lt;code&gt;'scrolloff'&lt;/code&gt; is set to 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea if this is what's happening to you but it seems like a plausible theory. Plus, there's some generally useful info here, e.g. probably not a lot of people know about the new &quot;defaults.vim&quot; behavior.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2017-11-21T10:22:39.577" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14283" PostTypeId="2" ParentId="5753" CreationDate="2017-11-21T11:40:57.543" Score="1" Body="&lt;p&gt;This is a slight variation of &lt;a href=&quot;https://vi.stackexchange.com/a/5776/343&quot;&gt;garyjohn's answer&lt;/a&gt; which removes the requirement to enter control characters directly into your Vimscript by adding the &lt;code&gt;Ctrl&lt;/code&gt; modifier &lt;em&gt;inside&lt;/em&gt; the function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ScrollStop(key)&#xA;  if &amp;amp;buftype !=# &quot;terminal&quot;&#xA;    execute 'normal! ' . nr2char(and(char2nr(a:key), &quot;0b0011111&quot;))&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-E&amp;gt; :call ScrollStop('E')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-Y&amp;gt; :call ScrollStop('Y')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It takes advantage of the way the &lt;kbd&gt;Ctrl&lt;/kbd&gt; key was implemented historically in terminals: by clearing the 6th and 7th bits of the ASCII character: we do this by &lt;code&gt;and&lt;/code&gt;-ing with the binary value &lt;code&gt;0011111&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I could also have used the expression&lt;code&gt;nr2char(toupper(char2nr(a:key)) - 64)&lt;/code&gt;. Ctrl-modified keystrokes are always 64 spots below the upper-case version of the unmodified keystroke: converting to upper-case is the same as clearing the 6th bit; subtracting 64 is the same as clearing the 7th.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-11-21T11:40:57.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14284" PostTypeId="2" ParentId="13020" CreationDate="2017-11-21T13:02:17.873" Score="1" Body="&lt;p&gt;This all works fine in gVim, so I'm presuming you're using terminal Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's hard to say definitively what is happening in your setup without more information, because the way &lt;kbd&gt;Backspace&lt;/kbd&gt; works &lt;a href=&quot;http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;depends on your terminal configuration&lt;/a&gt;. However, note that &lt;code&gt;BS&lt;/code&gt; is a control character, and the way that &lt;a href=&quot;https://catern.com/posts/terminal_quirks.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;control characters were implemented in traditional terminals&lt;/a&gt; was by pressing the &lt;kbd&gt;Ctrl&lt;/kbd&gt; key plus another key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such, it's entirely possible that your terminal is &lt;em&gt;already&lt;/em&gt; sending &lt;kbd&gt;Ctrl-H&lt;/kbd&gt; when you press backspace: if this is the case pressing the &lt;kbd&gt;Ctrl&lt;/kbd&gt; key at the same time will have no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, I suspect &lt;a href=&quot;https://vi.stackexchange.com/a/13021/343&quot;&gt;statox's answer&lt;/a&gt; won't work for you: for me it just results in a mapping of an unmodified &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt;. (Whereas &lt;code&gt;nmap &amp;lt;C-BS&amp;gt;&lt;/code&gt; results in a &lt;em&gt;correct&lt;/em&gt; mapping of &lt;kbd&gt;Ctrl-Backspace&lt;/kbd&gt; that cannot be accessed via key presses!) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that, in general, there are a limited number of reliable Ctrl-mappings you use in Vim. See the &lt;a href=&quot;https://vi.stackexchange.com/questions/8856/mapping-ctrl-with-equal-sign&quot;&gt;this answer to a related question&lt;/a&gt; and the FAQ entry it links to for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, I'm afraid that the &lt;em&gt;real&lt;/em&gt; answer to your question is, &quot;Don't do that.&quot;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-21T13:14:39.147" LastActivityDate="2017-11-21T13:14:39.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14285" PostTypeId="2" ParentId="14281" CreationDate="2017-11-21T14:47:44.433" Score="1" Body="&lt;p&gt;Here is an extremely simplified version as a function (run it in Vim to test):&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Hopefully Inspiring Function&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Assuming that &lt;code&gt;tee&lt;/code&gt; is working on your machine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:function! PasteTo(path)&#xA;:  silent execute &quot;:'&amp;lt;,'&amp;gt;w !tee -a &quot;.a:path&#xA;:  normal! gvd&#xA;:endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, select some text with linewise Visual mode, and do &lt;code&gt;:call PasteTo('a.txt')&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;(You'll need to press &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; to clear that &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt; inserted)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The lines are gone and you can do &lt;code&gt;:vnew a.txt&lt;/code&gt; to see them there.  Try it to see if it also appends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation: First line appends the lines to the file.  Second one deletes the lines. (By &lt;code&gt;gv&lt;/code&gt; to repeat selection and &lt;code&gt;d&lt;/code&gt; to use visual delete)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Making that an Ex Command&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -nargs=1 Cap call PasteTo(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, you can use &lt;code&gt;:Cap a.txt&lt;/code&gt; (short form for cut and paste).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Questions&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;It is strange if I have forgotten to press &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt;... like if I selected 2 lines the text will be pasted twice.  And extra lines deleted?  What happened?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It runs for each selected line -- so when I selected 2, it copies and deletes once, and when the function is called for the 2nd line, it copies again and deletes again!  You may want to do a mapping so &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; is pressed before you &quot;enter&quot; &lt;code&gt;:Cap&lt;/code&gt;, or investigate for other ways to make your function works nicely with Visual mode.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Even if I just character-wise select, it copies the whole line.. &lt;a href=&quot;https://stackoverflow.com/questions/1533565/how-to-get-visually-selected-text-in-vimscript&quot;&gt;How to get visually selected text in VimScript&lt;/a&gt;? (xolox is promising, I'm using his easytags plugin).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Hope this helps and hope I have given enough rope...&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2017-11-21T14:47:44.433" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14286" PostTypeId="1" CreationDate="2017-11-21T15:12:07.317" Score="1" ViewCount="541" Body="&lt;p&gt;How to count lines in current paragraph?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo line(&quot;'}&quot;) - line(&quot;'{&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is near, but not correct, and not considering corner cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to fix? or use another approach?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;== Edit ==&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanna count inner lines of current paragraph using vimscript, i.e., count given by &lt;code&gt;yip&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;since both marks &lt;code&gt;'{&lt;/code&gt; and &lt;code&gt;'}&lt;/code&gt; both point to empty line or line that only containing blank (space+Tab) if posssible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The corner case is thus when above condition not match, that is, &lt;code&gt;'{&lt;/code&gt; is first line and/or &lt;code&gt;'}&lt;/code&gt; is last line of the graph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;== Solution ==&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;see &lt;a href=&quot;https://vi.stackexchange.com/a/14294/10254&quot;&gt;my answer below&lt;/a&gt;, -- a vimscript function that could be embeded inside of &lt;code&gt;statusline&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="343" LastEditDate="2017-12-06T11:12:19.533" LastActivityDate="2017-12-06T11:12:19.533" Title="vim line count of current paragraph" Tags="|vimscript|counting|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14287" PostTypeId="2" ParentId="14286" CreationDate="2017-11-21T15:36:53.747" Score="5" Body="&lt;p&gt;You can &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; to select the current paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you press &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;CTRL + G&lt;/kbd&gt; you'll get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Selected 3 of 5 Lines; 8 of 12 Words; 101 of 291 Chars; 101 of 297 Bytes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-11-21T15:36:53.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14288" PostTypeId="1" CreationDate="2017-11-21T16:31:40.290" Score="1" ViewCount="1053" Body="&lt;p&gt;SpaceVim is very slow for me on large files, and in order to track down what's causing it, I'd like to disable an entire layer (for example, the autocomplete layer)... how would I go about doing this?&lt;/p&gt;&#xA;" OwnerUserId="15207" LastActivityDate="2017-12-17T07:42:06.070" Title="disable SpaceVim layers" Tags="|spacevim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14289" PostTypeId="1" CreationDate="2017-11-21T18:27:29.607" Score="2" ViewCount="2585" Body="&lt;p&gt;Given that the pattern &lt;code&gt;.\+&lt;/code&gt; is frequently used, is there an abbreviated way of specifying it in Vim Regex?&lt;/p&gt;&#xA;" OwnerUserId="15208" LastActivityDate="2017-12-21T20:24:34.847" Title="In Vim regex, Is there an abbreviation for the pattern dot followed by plus sign?" Tags="|regular-expression|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14290" PostTypeId="2" ParentId="14255" CreationDate="2017-11-21T20:09:36.703" Score="0" Body="&lt;p&gt;@statox is spot on with the &lt;em&gt;Black hole&lt;/em&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact I use this so much I remapped to my &lt;code&gt;x&lt;/code&gt; key in my .vimrc file:&#xA;    &lt;code&gt;noremap x &quot;_x&lt;/code&gt;  This allows me to visual select then &lt;code&gt;x&lt;/code&gt; it away while maintaining my last yanked text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to swap text from one place to another check out &lt;a href=&quot;https://github.com/tommcdo/vim-exchange&quot; rel=&quot;nofollow noreferrer&quot;&gt;tommcdo/vim-exchange&lt;/a&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="8493" LastActivityDate="2017-11-21T20:09:36.703" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14291" PostTypeId="2" ParentId="14289" CreationDate="2017-11-21T20:16:08.817" Score="1" Body="&lt;p&gt;When you type &lt;code&gt;/&lt;/code&gt; you're in command mode.  You can remap this by putting this in your .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap .+ .\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means, if you type &lt;code&gt;.+&lt;/code&gt; in command mode, replace it with &lt;code&gt;.\+&lt;/code&gt;.  You can replace the &lt;code&gt;.+&lt;/code&gt; on the left with anything you want.&lt;/p&gt;&#xA;" OwnerUserId="15080" LastActivityDate="2017-11-21T20:16:08.817" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14293" PostTypeId="2" ParentId="14281" CreationDate="2017-11-21T23:07:42.937" Score="2" Body="&lt;p&gt;Combining the advice of @SunnyPun and @Rich, I came up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -range -complete=file Move '&amp;lt;,'&amp;gt;w! &amp;gt;&amp;gt; &amp;lt;args&amp;gt;|'&amp;lt;,'&amp;gt;d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15080" LastActivityDate="2017-11-21T23:07:42.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14294" PostTypeId="2" ParentId="14286" CreationDate="2017-11-22T01:15:44.177" Score="1" Body="&lt;p&gt;Sorry for not emphasize, as the tag indicates, I want a vimscript solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Never mind, I found a solution, and wrap it in a function. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! LineCountCurrentParagraph()&#xA;    return line(&quot;'}&quot;) - line(&quot;'{&quot;) + ((match(getline(&quot;'{&quot;),'^\s*$') == -1) + (match(getline(&quot;'}&quot;),'^\s*$') == -1) -1)&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is then used inside of my &lt;code&gt;statusline&lt;/code&gt; settings.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{LineCountCurrentParagraph()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2017-11-22T01:15:44.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14296" PostTypeId="1" AcceptedAnswerId="14297" CreationDate="2017-11-22T13:47:50.480" Score="4" ViewCount="1137" Body="&lt;p&gt;In my &lt;code&gt;ftplugin/plaintext.vim&lt;/code&gt; script, I have the &lt;code&gt;formatoptions&lt;/code&gt; set for editing mostly prose:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal formatoptions=tcroqan1j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, in very specific instances -- particularly, Python's idiomatic &lt;code&gt;requirements.txt&lt;/code&gt; file -- I want the format options relaxed. I tried this within the same ftplugin script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Remove wrapping for Python &quot;requirements.txt&quot; files&#xA;autocmd BufRead,BufNewFile requirements.txt setlocal formatoptions=croj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...but it doesn't seem to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to have local settings for specific files (based on their name) and, if so, how would I go about it?&lt;/p&gt;&#xA;" OwnerUserId="1368" LastActivityDate="2017-11-22T19:11:16.023" Title="Set formatoptions for a specific file" Tags="|autocmd|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14297" PostTypeId="2" ParentId="14296" CreationDate="2017-11-22T14:26:04.320" Score="5" Body="&lt;p&gt;The code in &lt;code&gt;ftplugin/plaintext.vim&lt;/code&gt; is run when the file type is set, which occurs &lt;em&gt;after&lt;/em&gt; the file has been opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you are setting up your autocommand &lt;em&gt;after&lt;/em&gt; the file has already been opened. Thus, the autocommand never fires. If you were to close and reopen the file in the same Vim session you'd find &lt;code&gt;formatoptions&lt;/code&gt; set correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Easiest fix is to move your line to set up the autocommand into your &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: It occurs to me there might be an &lt;em&gt;additional&lt;/em&gt; problem even when the autocommand &lt;em&gt;does&lt;/em&gt; fire: the value it sets might then be overwritten by the code in your ftplugin file: if simply moving the autocommand doesn't fix the issue, you could also try checking the file name in your ftplugin file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Don't overwrite value set by autocommand&#xA;if expand('%:t') != 'requirements.txt'&#xA;  setlocal formatoptions=tcroqan1j&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2&lt;/strong&gt;: Of course, with the conditional in place, there's not much point in having a separate autocommand!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if expand('%:t') == 'requirements.txt'&#xA;  setlocal formatoptions=croj&#xA;else&#xA;  setlocal formatoptions=tcroqan1j&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a nagging feeling there's a more elegant way to implement this, but right now what that solution might be eludes me. Perhaps someone else will provide an alternative answer later on.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-22T19:11:16.023" LastActivityDate="2017-11-22T19:11:16.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14298" PostTypeId="1" CreationDate="2017-11-22T14:58:31.963" Score="1" ViewCount="235" Body="&lt;p&gt;Sometimes I'm using GVim not only for coding, but also for typing texts in Russian language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm very annoyed that I have to switch my keyboard layout back to English each time when I return to command mode. Is there any way to make GVim obeying keycodes sent by X server rather than keysyms, so that it could work in command mode regardless to which keyboard layout is selected?&lt;/p&gt;&#xA;" OwnerUserId="14502" LastActivityDate="2017-11-22T15:08:03.067" Title="How can I make gvim keyboard language-agnostic in command mode?" Tags="|gvim|keyboard-layout|x11|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14299" PostTypeId="2" ParentId="14298" CreationDate="2017-11-22T15:08:03.067" Score="2" Body="&lt;p&gt;One option is to use the plugins &lt;code&gt;https://github.com/lyokha/vim-xkbswitch&lt;/code&gt; or &lt;code&gt;https://github.com/rlue/vim-barbaric&lt;/code&gt;, which switch the input method in vim's input mode using xkbswitch.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-11-22T15:08:03.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14300" PostTypeId="1" CreationDate="2017-11-02T11:53:35.587" Score="7" ViewCount="6317" Body="&lt;p&gt;In Vim 8, you can open a terminal inside Vim with the &lt;code&gt;term&lt;/code&gt; command. This opens a new buffer of type &lt;code&gt;terminal&lt;/code&gt; inside vim. Is there any way of sending lines from other buffers to this type of buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;some binding&amp;gt; &amp;lt;sends the entire line under cursor to buffer of type='terminal'&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I am trying to achieve with this is to evaluate REPL statements without using any plugins&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help in advance!&lt;/p&gt;&#xA;" OwnerDisplayName="Hitesh Paul" LastEditorUserId="51" LastEditDate="2019-06-01T01:59:07.007" LastActivityDate="2022-11-07T13:23:47.690" Title="VIM: how to send entire line to a buffer of type &quot;Terminal&quot;?" Tags="|bash|terminal|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="14301" PostTypeId="1" AcceptedAnswerId="14302" CreationDate="2017-11-22T16:03:30.457" Score="4" ViewCount="402" Body="&lt;p&gt;I haven't been able to find documentation on how vim knows if register contents came from a linewise-selection vs characterwise or blockwise selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, given the text below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hello there my name is Markus&#xA;and I went to the store to buy&#xA;bananas and motor oil&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I select the first line in linewise visual mode, yank it to a specific register, and save the register contents to a file, the register contents are only what I had selected:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bSlAF.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bSlAF.gif&quot; alt=&quot;Nothing special about register contents&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if I then reload the unnamed register (&lt;code&gt;@&quot;&lt;/code&gt;) with the contents of &lt;code&gt;/tmp/output.txt&lt;/code&gt;, and paste it, it pastes as if I had selected it in characterwise or blockwise visual mode:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pSJbm.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pSJbm.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to assume that vim is tracking how register contents are set, and that if it is done directly from a yank/cut/delete/etc., it saves which visual mode it was done in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, how &lt;em&gt;exactly&lt;/em&gt; does that work? I'm working on a plugin, and I'd like to be able to tell vim to paste text as if they were originally copied in linewise or characterwise visual mode.&lt;/p&gt;&#xA;" OwnerUserId="15221" LastActivityDate="2017-11-22T16:20:01.660" Title="How does vim know if register contents were from a linewise selection when pasting?" Tags="|vimscript|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14302" PostTypeId="2" ParentId="14301" CreationDate="2017-11-22T16:20:01.660" Score="7" Body="&lt;p&gt;You can use &lt;code&gt;getregtype()&lt;/code&gt; to get a register's type (characterwise, linewise, blockwise).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo getregtype('a')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will yield, &lt;code&gt;v&lt;/code&gt;, &lt;code&gt;V&lt;/code&gt;, or &lt;code&gt;&amp;lt;c-v&amp;gt;&lt;/code&gt; for the &lt;code&gt;&quot;a&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h getregtype()&#xA;:h getreg()&#xA;:h setreg()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-11-22T16:20:01.660" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14303" PostTypeId="1" AcceptedAnswerId="14304" CreationDate="2017-11-22T18:14:15.210" Score="0" ViewCount="559" Body="&lt;p&gt;I'm just looking for a very basic indentation scheme. In &lt;code&gt;.vimrc&lt;/code&gt; I have &lt;code&gt;:set tabstop=2&lt;/code&gt;. Adding &lt;code&gt;:set smartindent&lt;/code&gt; has the effect of indenting the code by four tabs, very strange? A single tab the size of four spaces would be fine (despite my preferred tabstop), but four tabs? What is the issue here? &lt;code&gt;:set cindent&lt;/code&gt; has the same effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: vim 7.4 on ubuntu 16.04&lt;/p&gt;&#xA;" OwnerUserId="15223" LastEditorUserId="15223" LastEditDate="2017-11-22T18:19:23.587" LastActivityDate="2017-11-22T19:06:26.333" Title="`smartindent` indents four tabs?" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14304" PostTypeId="2" ParentId="14303" CreationDate="2017-11-22T19:06:26.333" Score="3" Body="&lt;p&gt;&lt;code&gt;set tabstop=2&lt;/code&gt; means tabs are displayed as at most 2 characters, it does not control the amount of indent.  You have &lt;code&gt;shiftwidth=8&lt;/code&gt; which controls the amount of indent.    When vim indents (assuming &lt;code&gt;noexpandtab&lt;/code&gt;), it tries to use tabs first, hence you get 4 tabs of 2 apparent spaces each for a total of 4*2=8 spaces equivalent indent.  The solution is to set &lt;code&gt;shiftwidth&lt;/code&gt; appropriately&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-11-22T19:06:26.333" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14305" PostTypeId="1" AcceptedAnswerId="14306" CreationDate="2017-11-22T19:32:09.833" Score="5" ViewCount="513" Body="&lt;p&gt;I just found out that we can use &#xA;&lt;code&gt;:e .&lt;/code&gt; to enter the browsing mode and then can choose file what we like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fbKWX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fbKWX.png&quot; alt=&quot;vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't know how to get back to already opened file without choosing it again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; and &lt;code&gt;:q&lt;/code&gt; but the first one doesn't work and second closes the file I have opened already (&lt;code&gt;.vimrc&lt;/code&gt; in my case).&lt;/p&gt;&#xA;" OwnerUserId="15224" LastEditorUserId="11986" LastEditDate="2017-11-23T07:54:31.960" LastActivityDate="2017-11-23T16:06:44.770" Title="How to escape from file browsing mode?" Tags="|buffers|netrw|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14306" PostTypeId="2" ParentId="14305" CreationDate="2017-11-22T20:10:42.130" Score="8" Body="&lt;p&gt;You can use any of Vim's many buffer-switching commands to return to the file you were previously working on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a few possibilities:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use the &lt;code&gt;:buffer&lt;/code&gt; command to jump to the alternate buffer: &lt;code&gt;:b #&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use the normal mode command to jump to the alternate buffer: &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Just step back through the jump list till you get there: &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/users/778/peter-rincker&quot;&gt;Peter Rincker&lt;/a&gt; points out in a comment below, you can also use the dedicated &lt;code&gt;:Rexplore&lt;/code&gt; command provided by the file explorer plugin (netrw) itself to do this: &lt;code&gt;:Rex&lt;/code&gt; will return you to the file you were editing previously if run from explorer view (and will conversely return you back &lt;em&gt;to&lt;/em&gt; the explorer view if you subsequently run it from a normal buffer).&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-22T21:51:52.400" LastActivityDate="2017-11-22T21:51:52.400" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14307" PostTypeId="2" ParentId="12973" CreationDate="2017-11-22T20:13:11.037" Score="38" Body="&lt;p&gt;ALE has many commands that can navigate linting errors, and &lt;code&gt;:ALENext&lt;/code&gt; works great for this operation. By default, ALE maps no bindings, I assume to allow for non-clashing customization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;~/.vimrc&lt;/code&gt; (or &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt; for NeoVim), I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;aj :ALENext&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;ak :ALEPrevious&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Leader is &lt;kbd&gt;\&lt;/kbd&gt; by default&lt;/p&gt;&#xA;" OwnerUserId="15226" LastEditorUserId="15226" LastEditDate="2018-02-11T01:26:52.103" LastActivityDate="2018-02-11T01:26:52.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14308" PostTypeId="1" AcceptedAnswerId="14309" CreationDate="2017-11-22T22:34:19.467" Score="0" ViewCount="207" Body="&lt;p&gt;I have this function that I rarely run and it uses &lt;code&gt;matchaddpos&lt;/code&gt;.  This function highlights at a set position so if I edit text, the same spot is highlighted even though the contents have shifted.  I figure the best way to solve this is to create an autocmd like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup headwords&#xA;    autocmd!&#xA;    autocmd InsertEnter * call clearmatches()&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That works fine, but it seems unnecessary to have that run every time I enter insert mode.  How could I make this &quot;self destructing&quot;.  Where if this autocmd runs one, it no longer runs on future InsertEnter's?&lt;/p&gt;&#xA;" OwnerUserId="15080" LastActivityDate="2017-11-22T22:48:32.733" Title="Deleting an autocmd after it's run" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14309" PostTypeId="2" ParentId="14308" CreationDate="2017-11-22T22:48:32.733" Score="2" Body="&lt;p&gt;You can simply use &lt;code&gt;autocmd! headwords&lt;/code&gt;.  For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup headwords&#xA;    autocmd!&#xA;    autocmd InsertEnter * call clearmatches() | autocmd! headwords&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-11-22T22:48:32.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14310" PostTypeId="2" ParentId="14274" CreationDate="2017-11-23T03:08:59.737" Score="1" Body="&lt;pre&gt;&lt;code&gt;:map , cwx&amp;lt;esc&amp;gt;r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;x&lt;/code&gt; is a temporary replacement character.  The &lt;code&gt;r&lt;/code&gt; at the end leaves it in replace mode to replace the temporary character &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to change &lt;code&gt;asdf&lt;/code&gt; to &lt;code&gt;y&lt;/code&gt; with the cursor on &lt;code&gt;a&lt;/code&gt; type &lt;code&gt;,y&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="15231" LastEditorUserId="15231" LastEditDate="2017-11-25T00:57:00.090" LastActivityDate="2017-11-25T00:57:00.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14311" PostTypeId="1" CreationDate="2017-11-23T06:16:02.323" Score="0" ViewCount="910" Body="&lt;p&gt;Pursuing a vimscript function or expression that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;count how many buffers been modified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e., how many buffers &lt;code&gt;:bm&lt;/code&gt; could switch to,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;given that option &lt;code&gt;hidden&lt;/code&gt; is set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;== Edit ==&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the hope of used in &lt;code&gt;statusline&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="343" LastEditDate="2017-12-06T11:22:41.777" LastActivityDate="2018-12-31T17:02:00.373" Title="vim: count how many buffers been modified?" Tags="|vimscript|buffers|statusline|counting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14312" PostTypeId="1" AcceptedAnswerId="14325" CreationDate="2017-11-23T07:59:44.553" Score="0" ViewCount="115" Body="&lt;p&gt;The following commands work fine when I issue them from the command mode in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(^\s\+\)\(\S\+.*)\s*\){$/\1\2\r\1{/g&#xA;:g/^\s*\/\/$/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I run the above commands as a script as below:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;vim -c &quot;commands.vim&quot; myfile.c&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I get errors:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/br6IW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/br6IW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I am aware of this question: &lt;a href=&quot;https://vi.stackexchange.com/questions/5273/how-to-use-c-command-line-option&quot;&gt;How to use &amp;quot;-c&amp;quot; command line option?&lt;/a&gt; but it has not helped with the error.&lt;/p&gt;&#xA;" OwnerUserId="15208" LastActivityDate="2017-11-24T12:07:26.783" Title="Using -c command line option for Vim 7.4 on Windows produces errors" Tags="|command-line|global-command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14313" PostTypeId="2" ParentId="14311" CreationDate="2017-11-23T08:00:10.323" Score="2" Body="&lt;p&gt;Found it. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! CountModifiedBuffer()&#xA;    let mod = map(getbufinfo(), 'v:val.changed')&#xA;    return len(filter(mod, 'v:val'))&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;== Edit ==&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;%{IsBuffersModified()}&lt;/code&gt; instead of builtin &lt;code&gt;%m&lt;/code&gt; inside my &lt;code&gt;statusline&lt;/code&gt; setting, which encode more info.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; [+] if only current modified, [+3] if 3 modified including current buffer.&#xA;&quot; [3] if 3 modified and current not, &quot;&quot; if none modified.&#xA;func! IsBuffersModified()&#xA;    let cnt = CountModifiedBuffer()&#xA;    return cnt == 0 ? &quot;&quot; : ( &amp;amp;modified ? &quot;[+&quot;. (cnt&amp;gt;1?cnt:&quot;&quot;) .&quot;]&quot; : &quot;[&quot;.cnt.&quot;]&quot; )&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;== Edit Edit ==&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;CountModifiedBuffer&lt;/code&gt; could be one-liner.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    return len(filter(getbufinfo(), 'v:val.changed == 1'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="10254" LastEditDate="2017-11-23T09:33:10.510" LastActivityDate="2017-11-23T09:33:10.510" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14314" PostTypeId="2" ParentId="14312" CreationDate="2017-11-23T09:05:41.633" Score="0" Body="&lt;p&gt;Based on comment from ChristianBraband, I found a solution, with help from this page: &lt;a href=&quot;https://en.wikibooks.org/wiki/Learning_the_vi_Editor/Vim/Modes&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikibooks.org/wiki/Learning_the_vi_Editor/Vim/Modes&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modify the &lt;code&gt;commands.vim&lt;/code&gt; script so that file update and quit are included at the end:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(^\s\+\)\(\S\+.*)\s*\){$/\1\2\r\1{/g&#xA;:g/^\s*\/\/$/d&#xA;:update&#xA;:quit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Run from the command line as follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;vim -c &quot;source commands.vim&quot; myfile.c&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Update: Removed the unnecessary -E option per comment from @Rich.&lt;/p&gt;&#xA;" OwnerUserId="15208" LastEditorUserId="15208" LastEditDate="2017-11-24T12:07:26.783" LastActivityDate="2017-11-24T12:07:26.783" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14315" PostTypeId="1" CreationDate="2017-11-23T12:01:31.600" Score="7" ViewCount="1615" Body="&lt;p&gt;Extremely related to &lt;a href=&quot;https://vi.stackexchange.com/questions/13692/prevent-focusgained-autocmd-running-in-command-line-editing-mode&quot;&gt;this&lt;/a&gt; except the answer there doesn't work&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get the following error when entering command-line editing mode &lt;code&gt;q:&lt;/code&gt; or &lt;code&gt;Ctrl-F&lt;/code&gt; (when already in command mode)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing CursorHold Auto commands for &quot;*&quot;:&#xA;E11: Invalid in command-line window; &amp;lt;CR&amp;gt; executes, CTRL-C quits:  checktime | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The relevant section of my .vimrc is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;automatically reload file when changes detected&#xA;set autoread &quot;this doesn't work on it's own!&#xA;&#xA;&quot;https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim/383044#383044&#xA;&quot;on these events, any filename... and not in command mode then check files for changes&#xA;autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif&#xA;&#xA;&quot; Notification after file change&#xA;autocmd FileChangedShellPost *&#xA;  \ echohl WarningMsg | echo &quot;File changed on disk. Buffer reloaded.&quot; | echohl None&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So my question is how do I detect that I'm in the command-line window and stop that command from running there?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a bit of reading &lt;code&gt;:h command-line&lt;/code&gt; I tried replacing the condition with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if mode() != 'c' &amp;amp;&amp;amp; getcmdwintype() == ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I'm still seeing the same issue.&lt;/p&gt;&#xA;" OwnerUserId="1518" LastEditorUserId="1841" LastEditDate="2017-11-23T12:17:00.520" LastActivityDate="2019-06-22T03:58:44.490" Title="How can I tell if I'm in the command window?" Tags="|command-line-window|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14316" PostTypeId="2" ParentId="14315" CreationDate="2017-11-23T13:17:34.040" Score="3" Body="&lt;p&gt;&lt;code&gt;bufname('%')&lt;/code&gt; returns &lt;code&gt;&quot;[Command Line]&quot;&lt;/code&gt; in my case. I don't know if there is another information elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also listen for &lt;code&gt;CmdwinEnter&lt;/code&gt; and &lt;code&gt;CmdwinLeave&lt;/code&gt; events and maintain an internal state that'll tell you in which mode you are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Here is what I would do. Note, this is completely untested. This may not work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ==== file: autoload/cmdlinewindow.vim&#xA;&quot; Initialize to 0, keep the current state if the script is reloaded&#xA;let s:is_opened = get(s:, 'is_opened', 0)&#xA;&#xA;function! cmdlinewindow#_enter() abort&#xA;    call lh#assert#false(s:is_opened)&#xA;    let s:is_opened = 1&#xA;endfunction&#xA;&#xA;function! cmdlinewindow#_leave() abort&#xA;    call lh#assert#true(s:is_opened)&#xA;    let s:is_opened = 0&#xA;endfunction&#xA;&#xA;function! cmdlinewindow#is_opened()&#xA;    return s:is_opened&#xA;endfunction&#xA;&#xA;&quot; ==== file: plugin/cmdlinewindow.vim&#xA;aug WatchCmdLineWindow&#xA;    au!&#xA;    au CmdwinEnter * call cmdlinewindow#_enter()&#xA;    au CmdwinLeave * call cmdlinewindow#_leave()&#xA;aug END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, from elsewhere, you'd just have to check cmdlinewindow#is_opened() result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/DbC.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;lh#assert#...()&lt;/code&gt;&lt;/a&gt; comes from my vim script library. They are not needed, yet they state in which state I expect to be when calling these functions.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-11-23T15:18:08.383" LastActivityDate="2017-11-23T15:18:08.383" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14317" PostTypeId="2" ParentId="14315" CreationDate="2017-11-23T14:37:27.117" Score="7" Body="&lt;p&gt;Based on Luc's help I ended up going with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if !bufexists(&quot;[Command Line]&quot;) | checktime | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason this works is that the Command Line window is fairly modal so you can't have one accidentally open in the background - you will only get that buffer if you are actively editing in the command-line-window&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only caveat here is that if you save a buffer with that name, which I did accidentally at some point when messing around with this stuff - in which case the Command line window complains when it gets opened and instead gets named &lt;code&gt;&quot;[Scratch]&quot;&lt;/code&gt; or something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also worth noting that you should probably have something like this at the very top of your .vimrc as autocmds are just added to a list and if you are developing them you can end up with your &lt;a href=&quot;https://vi.stackexchange.com/questions/5580/remove-augroups-around-autocmds-in-vimrc&quot;&gt;old ones kicking around&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;clear out previous autocmds to stop them being duplicated when resourcing&#xA;&quot;this file&#xA;autocmd!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also learned you can list all autocmds by doing &lt;code&gt;:autocmd&lt;/code&gt; and list for a specific event like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd CursorHold&#xA;--- Auto-Commands ---&#xA;ALECursorGroup  CursorHold&#xA;    *         call ale#cursor#EchoCursorWarningWithDelay()&#xA;CursorHold&#xA;    *         if !bufexists(&quot;[Command Line]&quot;) | checktime | endif&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1518" LastEditorUserId="1518" LastEditDate="2017-11-23T14:42:40.237" LastActivityDate="2017-11-23T14:42:40.237" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14318" PostTypeId="1" AcceptedAnswerId="14319" CreationDate="2017-11-23T15:16:02.927" Score="2" ViewCount="43" Body="&lt;p&gt;Basically my question is this. On my terminal I have vi mode enable. It saves me lots of time editing command line arguments and zooming throught the file system. I would like to have a similar mode enabled in the vim command mode. Chief reason being is regular expressions for my code. s/ / / commands can get quite tedious and having a vi-like mode for editing commands would be awesome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also if this is not a recommended modifcation, does anyone have recommendations for plugins which make s/ / / usage more speedy and efficient?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help&lt;/p&gt;&#xA;" OwnerUserId="15237" LastActivityDate="2017-11-23T15:19:55.153" Title="Can I change the command mode (: ...) so that I can have vi shortcuts?" Tags="|regular-expression|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14319" PostTypeId="2" ParentId="14318" CreationDate="2017-11-23T15:19:55.153" Score="3" Body="&lt;p&gt;you can press &lt;code&gt;ctrl-f&lt;/code&gt; after : to get access to the commands (same for /)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or you can enter cmd-mode with &lt;code&gt;q:&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-11-23T15:19:55.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14320" PostTypeId="2" ParentId="14305" CreationDate="2017-11-23T16:06:44.770" Score="1" Body="&lt;p&gt;as &lt;a href=&quot;https://vi.stackexchange.com/users/343/rich&quot;&gt;Rich&lt;/a&gt; has mentioned, we can use &#xA;&lt;code&gt;:b&amp;lt;buffer_number&amp;gt;&lt;/code&gt; to jump to a buffer,&lt;br&gt;&#xA;we can see &lt;code&gt;buffer_number&lt;/code&gt; using command &lt;code&gt;:list&lt;/code&gt; &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case I just wanted to go to previous buffer/file, so we can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this will get us to the previously edited buffer,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks, &lt;a href=&quot;https://vi.stackexchange.com/users/11986/icc97&quot;&gt;icc97&lt;/a&gt;, &lt;a href=&quot;https://vi.stackexchange.com/users/343/rich&quot;&gt;Rich&lt;/a&gt; and everyone....&lt;br&gt;&lt;br&gt;&#xA;&lt;code&gt;#Happy coding&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="15224" LastActivityDate="2017-11-23T16:06:44.770" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14321" PostTypeId="1" CreationDate="2017-11-23T16:43:48.847" Score="3" ViewCount="681" Body="&lt;p&gt;&lt;code&gt;:browse oldfiles&amp;lt;cr&amp;gt;&lt;/code&gt; is useful for quickly navigating to a file I've worked on recently.&lt;/p&gt;&#xA;&lt;p&gt;Sometimes though, I want to suspend &lt;code&gt;vim&lt;/code&gt; and do some &lt;code&gt;grep&lt;/code&gt; or &lt;code&gt;ack&lt;/code&gt; search and find a new file that I'm interested in (let's call it &lt;code&gt;sneaky.h&lt;/code&gt;). If I open a fresh &lt;code&gt;vim&lt;/code&gt; using &lt;code&gt;vim sneaky.h&lt;/code&gt; and then close it immediately, &lt;code&gt;sneaky.h&lt;/code&gt; will appear in the &lt;code&gt;oldfiles&lt;/code&gt; list the next time I launch Vim.&lt;/p&gt;&#xA;&lt;p&gt;However, my original &lt;code&gt;vim&lt;/code&gt; instance, the one I started before searching for &lt;code&gt;sneaky.h&lt;/code&gt;, does not have the file in the &lt;code&gt;oldfiles&lt;/code&gt; list.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to direct vim to refresh the &lt;code&gt;oldfiles&lt;/code&gt; list and populate it again without restarting vim?&lt;/p&gt;&#xA;&lt;p&gt;Also, is there a more efficient way to get a file like &lt;code&gt;sneaky.h&lt;/code&gt; into the &lt;code&gt;oldfiles&lt;/code&gt; pool without opening it and closing it immediately?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="23502" LastEditDate="2023-10-23T13:17:32.320" LastActivityDate="2024-03-21T15:02:45.410" Title="How to refresh the oldfiles list without restarting Vim?" Tags="|filesystem|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="14322" PostTypeId="1" CreationDate="2017-11-23T17:43:05.060" Score="0" ViewCount="630" Body="&lt;p&gt;I have below .vimrc key mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-S-j&amp;gt; :tabmove -1&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;C-S-k&amp;gt; :tabmove +1&amp;lt;cr&amp;gt;&#xA;&#xA;nmap &amp;lt;C-j&amp;gt; gT&#xA;nmap &amp;lt;C-k&amp;gt; gt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't know why C-S-j|k is not working.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2017-11-23T17:43:05.060" Title="Why shift key is not working" Tags="|key-bindings|" AnswerCount="0" CommentCount="2" ClosedDate="2017-11-24T08:39:54.373" ContentLicense="CC BY-SA 3.0" />
  <row Id="14323" PostTypeId="1" CreationDate="2017-11-23T17:58:38.587" Score="2" ViewCount="666" Body="&lt;p&gt;I'm editing some Javascript in which the following is common:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code&gt;var foo = `&#xA;  a bunch&#xA;  of text&#xA;  and stuff&#xA;`;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I'd like to quickly be able to select the entire block between the backticks, like I would with the command &lt;code&gt;vib&lt;/code&gt; if it were inside parens rather than backticks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it only seems to treat backticks as inline rather than block, and I'm not sure how to get around that.&lt;/p&gt;&#xA;" OwnerUserId="15241" LastEditorUserId="1841" LastEditDate="2017-11-27T09:45:02.923" LastActivityDate="2022-10-28T20:18:49.203" Title="Select a backtick-delimited block, rather than an inline string?" Tags="|visual-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14324" PostTypeId="1" CreationDate="2017-11-23T18:39:51.477" Score="1" ViewCount="28" Body="&lt;p&gt;Vim-Latex has a feature which folds the tex document into the respective environments e.g. sections,equations. Can I enable somthing similar for Java?&lt;/p&gt;&#xA;" OwnerUserId="15237" LastActivityDate="2017-11-23T18:39:51.477" Title="Java equivalent for vim-latex folds" Tags="|plugin-vim-latex|filetype-java|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14325" PostTypeId="2" ParentId="14312" CreationDate="2017-11-23T23:19:26.740" Score="2" Body="&lt;p&gt;Vim's &lt;code&gt;-s {scriptin}&lt;/code&gt; command line argument&lt;sup&gt;*&lt;/sup&gt; allows you to supply a file the contents of which will be interpreted as if you had typed them in, character by character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be used for normal mode commands, but because you also generally enter command-line mode commands by typing them in, it works fine for ex commands too, so long as you include the colons at the start of each line (as you have).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -s commands.vim myfile.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help -s&lt;/code&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* Not to be confused with Vim's &lt;em&gt;other&lt;/em&gt; &lt;code&gt;-s&lt;/code&gt; argument, which only applies when ex mode is also specified: see &lt;code&gt;:help -s-ex&lt;/code&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-11-23T23:19:26.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14326" PostTypeId="2" ParentId="14323" CreationDate="2017-11-24T04:30:47.137" Score="2" Body="&lt;p&gt;&lt;code&gt;ib&lt;/code&gt; is referred to as a text object.  You can achieve &lt;em&gt;very&lt;/em&gt; basic functionality using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Ticks(inner)&#xA;    normal! gv&#xA;    call searchpos('`', 'bW')&#xA;    if a:inner | exe &quot;normal! 1\&amp;lt;space&amp;gt;&quot; | endif&#xA;    normal! o&#xA;    call searchpos('`', 'W')&#xA;    if a:inner | exe &quot;normal! \&amp;lt;bs&amp;gt;&quot; | endif&#xA;endfunction&#xA;&#xA;vnoremap &amp;lt;silent&amp;gt; a` :&amp;lt;c-u&amp;gt;call Ticks(0)&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; i` :&amp;lt;c-u&amp;gt;call Ticks(1)&amp;lt;cr&amp;gt;&#xA;&#xA;onoremap &amp;lt;silent&amp;gt; a` :&amp;lt;c-u&amp;gt;normal va`&amp;lt;cr&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; i` :&amp;lt;c-u&amp;gt;normal vi`&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is usually more robust to use a plugin designed for this.  There are many plugins implementing different text objects.  You may be interested specifically in:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/fvictorio/vim-textobj-backticks&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/fvictorio/vim-textobj-backticks&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kana/vim-textobj-user&lt;/a&gt; (dependency of the above)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/thinca/vim-textobj-between&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/thinca/vim-textobj-between&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-11-24T04:30:47.137" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14328" PostTypeId="2" ParentId="12677" CreationDate="2017-11-24T11:05:36.233" Score="1" Body="&lt;p&gt;The most likely scenario is that the the colour scheme is changing correctly, but that Vim isn't actually displaying the colours anywhere because you don't have syntax highlighting enabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try running the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If that fixes it, you can add it to your &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/a/12704/343&quot;&gt;@13312 hints&lt;/a&gt;, it's also possible (but unlikely) that Vim believes itself to be running in a black and white terminal. If this is the case, then &lt;code&gt;set t_Co?&lt;/code&gt; will output 0: this is the number of colours that Vim believes the terminal supports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This indicates there is a problem with your terminal configuration. If that is the case, then adding &lt;code&gt;set t_Co=256&lt;/code&gt; as they suggest will force Vim to act as though the terminal supports 256 colours (regardless of whether this is actually the case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, much better fix would be to fix your terminal configuration so that Vim uses the correct value automatically, as it should. The first thing to check is the output of the command &lt;code&gt;tput colors&lt;/code&gt; when run in your shell.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-24T11:14:20.470" LastActivityDate="2017-11-24T11:14:20.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14329" PostTypeId="1" AcceptedAnswerId="14334" CreationDate="2017-11-24T12:47:25.703" Score="1" ViewCount="52" Body="&lt;p&gt;I have below mapping in .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap gb &amp;lt;C-^&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I want to do is open a directory, gf to a file, then gb go back to previous directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But sometime gb is not working properly. It goes back to another text file instead of previous directory.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2017-11-25T11:07:12.283" Title="Why sometimes C-^ is not working as expected?" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14331" PostTypeId="1" AcceptedAnswerId="14332" CreationDate="2017-11-25T04:33:04.093" Score="1" ViewCount="58" Body="&lt;p&gt;I have i-mapped &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-s&amp;gt;&lt;/code&gt; etc. to commonly used keys that I use often but find annoying to type normally, for example &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;_&lt;/code&gt;. It works as expected in insert mode, but when executing a single-character replacement with &lt;code&gt;r&lt;/code&gt;, I get some kind of escape sequence instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried &lt;code&gt;nnoremap r&amp;lt;C-(key)&amp;gt; character&lt;/code&gt; and &lt;code&gt;nmap r&amp;lt;C-(key)&amp;gt; character&lt;/code&gt;, but seemingly-random things happen when i execute &lt;code&gt;r&amp;lt;C-(key)&amp;gt;&lt;/code&gt;. Mapping to different characters (symbols) gives very different results. Prefixing the character with &lt;code&gt;\&lt;/code&gt; just makes nothing happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is a way I can remap &lt;code&gt;&amp;lt;C-(key)&amp;gt;&lt;/code&gt; while replacing a character?&lt;/p&gt;&#xA;" OwnerUserId="11809" LastActivityDate="2017-11-25T09:36:59.930" Title="Can I remap &lt;C-(key)&gt; while replacing a character? If not, is there a workaround or hack?" Tags="|key-bindings|normal-mode|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14332" PostTypeId="2" ParentId="14331" CreationDate="2017-11-25T08:54:03.553" Score="1" Body="&lt;p&gt;This has to be done through the feature known as &quot;language mapping&quot;. This feature allows entry of non-English/ASCII characters using a standard keyboard but more generally allows one to control the mapping of &lt;em&gt;characters entered into a buffer&lt;/em&gt; which is what &lt;code&gt;r&lt;/code&gt; emits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to do two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use &lt;code&gt;lmap&lt;/code&gt; for the mapping rather than &lt;code&gt;imap&lt;/code&gt;. E.g. &lt;code&gt;:lnoremap &amp;lt;c-a&amp;gt; *&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Enable language mapping. This can be done with &lt;code&gt;:set iminsert=1&lt;/code&gt; or by typing &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;^&lt;/kbd&gt; (control-caret) while in insert mode.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Besides &lt;code&gt;:h :lmap&lt;/code&gt; see &lt;code&gt;:h 45.5&lt;/code&gt;, &lt;code&gt;:h i_Ctrl-^&lt;/code&gt; and &lt;code&gt;:h 'iminsert'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;lmap&lt;/code&gt; also applies to characters entered while in Insert mode so &lt;code&gt;lmap&lt;/code&gt; should be all you need for your general use case of replacing &quot;annoying&quot; characters with easier-to-type variants.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-11-25T09:36:59.930" LastActivityDate="2017-11-25T09:36:59.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14333" PostTypeId="1" CreationDate="2017-11-25T10:39:20.590" Score="2" ViewCount="351" Body="&lt;p&gt;&lt;em&gt;(This is a copy of my original &lt;a href=&quot;https://stackoverflow.com/questions/47435330/getting-coordinates-of-a-visual-block-via-neovim-api&quot;&gt;question&lt;/a&gt; on stackoverflow)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hi!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am browsing through the list of available functions in Neovim Python Client API in search of a way to get coordinates of a &lt;strong&gt;current&lt;/strong&gt; visual mode selection. Something that would give me a pair of (row #,column #) of a visual block start/end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried using the vim native getpos function in the following way (suggested in a comment to the original question):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from neovim import attach&#xA;&#xA;nvim = attach('child', argv=[&quot;/bin/env&quot;,&quot;nvim&quot;,&quot;--embed&quot;])&#xA;buffer = nvim.current.buffer&#xA;buffer[0] = 'visual mode' &#xA;nvim.feedkeys(&quot;fmve&quot;)&#xA;print(&quot;Current caret position: {}&quot;.format(nvim.windows[0].cursor))&#xA;cmd ='getpos(&quot;\'&amp;lt;&quot;)' # cmd=r&quot;&quot;&quot;getpos(&quot;'&amp;lt;&quot;)&quot;&quot;&quot;&#xA;print(&quot;Start of visual selection: {}&quot;.format(nvim.eval(cmd)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue with the using &quot;'&amp;lt;&quot; mark is that i need to leave the visual mode to get the coordinates, so a call to &lt;code&gt;feedkeys&lt;/code&gt; needs to become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim.feedkeys(&quot;fmve&amp;lt;Esc&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;while my task requires staying in the visual mode.  Is there another recipe?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="7215" LastEditorUserId="7215" LastEditDate="2017-11-25T11:32:03.430" LastActivityDate="2017-11-25T13:54:11.523" Title="getting coordinates of a visual block via Neovim python API" Tags="|neovim|neovim-python-client|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14334" PostTypeId="2" ParentId="14329" CreationDate="2017-11-25T11:07:12.283" Score="2" Body="&lt;p&gt;The problem is netrw, the plugin which allows vim to browse directories, overrides the &lt;code&gt;gb&lt;/code&gt; map for its bookmarks feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can disable this by providing a junk mapping in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;sid&amp;gt;NetrwBookHistHandler_gb &amp;lt;Plug&amp;gt;NetrwBookHistHandler_gb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or use any left hand side&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;f4&amp;gt; &amp;lt;Plug&amp;gt;NetrwBookHistHandler_gb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, you don't need to use gf to go to a file inside a directory.  Pressing enter works too.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-11-25T11:07:12.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14336" PostTypeId="2" ParentId="10761" CreationDate="2017-11-25T18:48:36.270" Score="2" Body="&lt;p&gt;I've mostly been avoiding tabs because of this problem, but now I have a function that has the tab duplication behavior I want. I've tested it, but haven't started using it in earnest. There may be some hidden drawback to this workflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One problem with the function is that it doesn't duplicate some of the state from the previous buffer-window pair (like whether &lt;code&gt;set number&lt;/code&gt; is on or not). Speculating a bit, &lt;code&gt;c-w T&lt;/code&gt; probably does not have this problem because no duplication is performed and the window is probably just reparented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has a couple of 1-based lists for things like buffers, tabs, and windows. As far as I can tell, they are 1-based because the &lt;code&gt;0&lt;/code&gt; key is used to move to the beginning of a line and as a result passing zero as a numeric argument is impossible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We care about three lists for emulating this functionality:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The global list of tab pages&lt;/li&gt;&#xA;&lt;li&gt;The per-[tab page] list of windows&lt;/li&gt;&#xA;&lt;li&gt;The global list of buffers&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;We save all of this values, then create a new tab via &quot;tabnew&quot;. New tabs are always created to the right, so none of the indices below the tab that we &lt;code&gt;tabnew&lt;/code&gt;'d from are invalidated. (A more robust way to do this would probably be better though).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;tabnew&lt;/code&gt; command also moves focus to the new tab and the single window within it. From there we can use the &lt;code&gt;buffer&lt;/code&gt; command to create a view onto the buffer that originally had focus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we use the saved index of the original tab to restore focus back to that tab. And then, largely out of paranoia, we set the focus within that tab to the original window. Vim seems to remember which window has focus in non-visible tabs, but I don't like relying on that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(A few stylistic points: the explicit numeric conversion &lt;code&gt;0+&lt;/code&gt;, global variables, and assertions are all intentional)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TabDuplicate()&#xA;  &quot; set vars, sanity checking&#xA;  let g:tabdup_win      = 0+ winnr()&#xA;  let g:tabdup_buf      = 0+ bufnr('%')&#xA;  let g:tabdup_tabpage  = 0+ tabpagenr()&#xA;  call assert_true(g:tabdup_win &amp;gt; 0)&#xA;  call assert_true(g:tabdup_buf &amp;gt; 0)&#xA;  call assert_true(g:tabdup_tabpage &amp;gt; 0)&#xA;  &quot; make a new tab page,&#xA;  &quot; the new tab page will have focus&#xA;  &quot; none of the indices, which are all&#xA;  &quot; less than the current index, are&#xA;  &quot; invalidated by creating a new tab&#xA;  execute &quot;tabnew&quot;&#xA;  &quot; visit the buffer we saved&#xA;  execute &quot;buffer &quot; . g:tabdup_buf&#xA;  &quot; return to the original tab page&#xA;  execute &quot;tabnext &quot; . g:tabdup_tabpage&#xA;  &quot; return focus to original window&#xA;  execute g:tabdup_win . &quot; windcmd w&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2018-12-10T17:35:31.070" LastActivityDate="2018-12-10T17:35:31.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14337" PostTypeId="1" AcceptedAnswerId="14338" CreationDate="2017-11-25T20:17:37.897" Score="2" ViewCount="760" Body="&lt;p&gt;How do you set a window-local option (&lt;code&gt;number&lt;/code&gt;) in literally every window/buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was to bind &lt;code&gt;&amp;lt;leader&amp;gt;t&lt;/code&gt; to toggle the &lt;code&gt;number&lt;/code&gt; option in every buffer, using a global variable &lt;code&gt;g:linum_status&lt;/code&gt; as the source of truth for whether line numbers should be active or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I'm trying to figure out how to make &lt;code&gt;number&lt;/code&gt; act like a global option, even though it's window-local.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following options set initially&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:linum_status = 0&#xA;set nonumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and had the following (broken) function &lt;code&gt;ToggleLinum&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleLinum()&#xA;  if g:linum_status&#xA;    bufdo execute &quot;set nonumber&quot;&#xA;    let g:linum_status = 0&#xA;  else&#xA;    bufdo execute &quot;set number&quot;&#xA;    let g:linum_status = 1&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function, however, only toggles the &lt;code&gt;number&lt;/code&gt; option in the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried switching &lt;code&gt;bufdo&lt;/code&gt; to &lt;code&gt;windo&lt;/code&gt;, which is a little better. Now all of the windows in the focused tab switch, which is actually fairly intuitive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still though, is there a way to make flip &lt;code&gt;number&lt;/code&gt; on or off for &quot;every&quot; buffer, possibly exempting things like netrw file exploring buffers.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-11-25T22:16:51.687" Title="Set window-local option in every buffer/window" Tags="|buffers|line-numbers|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14338" PostTypeId="2" ParentId="14337" CreationDate="2017-11-25T20:39:07.390" Score="2" Body="&lt;p&gt;You could try the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;t :&amp;lt;c-u&amp;gt;call ToggleLinum()&amp;lt;cr&amp;gt;&#xA;&#xA;function! ToggleLinum() abort&#xA;    let orig_win = win_getid()&#xA;    let ft_to_ignore = ['netrw']&#xA;    if &amp;amp;l:number&#xA;        tabdo windo if index(ft_to_ignore, &amp;amp;ft) &amp;lt; 0 | setl nonumber | endif&#xA;    else&#xA;        tabdo windo if index(ft_to_ignore, &amp;amp;ft) &amp;lt; 0 | setl number | endif&#xA;    endif&#xA;    call win_gotoid(orig_win)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses &lt;code&gt;:tabdo&lt;/code&gt; to iterate over the tab pages, and &lt;code&gt;:windo&lt;/code&gt; to iterate over the windows in each of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, in addition to &lt;code&gt;netrw&lt;/code&gt;, you wanted to ignore other filetypes, you could add them to the list &lt;code&gt;ft_to_ignore&lt;/code&gt;. For example, to also ignore quickfix windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let ft_to_ignore = ['netrw', 'qf']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function decides whether it should enable or disable &lt;code&gt;'number'&lt;/code&gt; in all windows based on the value of this option in the current window (&lt;code&gt;&amp;amp;l:number&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;:tabdo&lt;/code&gt; and &lt;code&gt;:windo&lt;/code&gt; will change the focused window (it will become the last window in the last tab page) you can use &lt;code&gt;win_getid()&lt;/code&gt; to save the unique ID of the original window, and &lt;code&gt;win_gotoid()&lt;/code&gt; to get back to it, once the function has finished toggling &lt;code&gt;'number'&lt;/code&gt; everywhere.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can nest windo inside tabdo? What kind of thing are they&#xA;  syntactically?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Honestly, I don't know what is the correct term for these keywords. But I can try to help you understand why it makes sense to nest them. From &lt;code&gt;:h :tabdo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;It works like doing this:&#xA;        :tabfirst&#xA;        :{cmd}&#xA;        :tabnext&#xA;        :{cmd}&#xA;        etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, from &lt;code&gt;:h :windo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;It works like doing this:&#xA;        CTRL-W t&#xA;        :{cmd}&#xA;        CTRL-W w&#xA;        :{cmd}&#xA;        etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the first snippet of code, the one given in &lt;code&gt;:h :tabdo&lt;/code&gt;, replace &lt;code&gt;{cmd}&lt;/code&gt; with the 2nd snippet of code (increasing the level of indentation to better see the 2 different levels of nesting); it should give you the following pseudo-code, which still looks valid:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabfirst&#xA;    CTRL-W t&#xA;    :{cmd}&#xA;    CTRL-W w&#xA;    :{cmd}&#xA;    etc.&#xA;:tabnext&#xA;    CTRL-W t&#xA;    :{cmd}&#xA;    CTRL-W w&#xA;    :{cmd}&#xA;    etc.&#xA;etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;FWIW, the way I see &lt;code&gt;tabdo&lt;/code&gt; and &lt;code&gt;windo&lt;/code&gt;, is like tab triggers in &lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/423f264e753cec260b4f14455126e6db7ba429af/doc/UltiSnips.txt#L645&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt;. That is, they are expanded into snippets of code. In the help, &lt;code&gt;{cmd}&lt;/code&gt; is a placeholder which, in the snippet, will be replaced with the command (or here another snippet) you pass to &lt;code&gt;:tabdo&lt;/code&gt;/&lt;code&gt;:windo&lt;/code&gt; as an argument.&lt;/p&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-11-25T22:16:51.687" LastActivityDate="2017-11-25T22:16:51.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14339" PostTypeId="2" ParentId="11578" CreationDate="2017-11-26T06:26:30.967" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;It consists of nothing but this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight clear&#xA;syn keyword syntaxElementKeyword ok&#xA;hi def link syntaxElementKeyword Todo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;highlight clear&lt;/code&gt; will remove all the highlight groups, but not the syntax groups.&#xA;They belong to 2 related but still different mechanisms. Their purpose is to answer 2 questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;What&lt;/strong&gt; do you want to color? The answer is given by the syntax groups defined in a syntax plugin.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;How&lt;/strong&gt; do you want to color it? The answer is given by the highlight groups defined in a colorscheme.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, since  you were writing  a syntax plugin,  and not a colorscheme,  you probably wanted  to write&#xA;&lt;code&gt;syntax clear&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But if I do &lt;code&gt;:e&lt;/code&gt; on the text file, the syntax highlighting turns off then I have to run &lt;code&gt;:set syntax=test&lt;/code&gt; again.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If your syntax plugin is not sourced, it means that the &lt;code&gt;'syntax'&lt;/code&gt; option was not (properly) set.&#xA;Which means that the &lt;code&gt;'filetype'&lt;/code&gt; option was not (properly) set.&lt;br&gt;&#xA;Which means that the filetype was not (properly) detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The filetype detection mechanism is explained in &lt;code&gt;:h ftdetect&lt;/code&gt;.&#xA;The help says that there are 4 ways to implement the detection and setting of a type of file.&#xA;They are labeled &lt;code&gt;A.&lt;/code&gt;, &lt;code&gt;B.&lt;/code&gt;, &lt;code&gt;C.&lt;/code&gt;, and &lt;code&gt;D.&lt;/code&gt;.&#xA;Each of them is broken down into a set of 3 steps, prefixed with numbers (&lt;code&gt;1.&lt;/code&gt;, &lt;code&gt;2.&lt;/code&gt;, &lt;code&gt;3.&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They all install autocmds.&#xA;But they differ in 2 ways: their location, and the command they use to set the filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The location is important, because depending on the one you choose, your autocmds will be installed&#xA;before or after the default ones which are written inside &lt;code&gt;$VIMRUNTIME/filetype.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a flowchart to help you decide where to write them (assuming you're working with the filetype&#xA;&lt;code&gt;test&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                             +--------------------------------+&#xA;                             |                                |&#xA;                             | Do you want them to be sourced |&#xA;                             | before the default ones?       |&#xA;                             |                                |&#xA;                 yes   +_____+--------------------------------+____+   no&#xA;                      /                                             \&#xA;                     /                                               \&#xA;                    v                                                 v&#xA;+-------------------------------------------+                       ***************&#xA;|                                           |                  *****               *****&#xA;| Does the filetype of your files depend on |               ***                         ***&#xA;| the extension in their names, or on       |               *   ~/.vim/ftdetect/test.vim  *&#xA;| their contents?                           |               ***                         ***&#xA;|                                           |                  *****               *****&#xA;+-------------------------------------------+                       ***************&#xA;                |                        |&#xA;   extension    |                        |    contents&#xA;                |                        |&#xA;                v                        v&#xA;       *************                  *************&#xA;  *****             *****         ****             ****&#xA;**                       **     **                     **&#xA;*   ~/.vim/filetype.vim   *     *   ~/.vim/scripts.vim  *&#xA;**                       **     **                     **&#xA;  *****             *****         ****             ****&#xA;       *************                  *************&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for the command which you can use to set the filetype of a file:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use &lt;code&gt;:set&lt;/code&gt; if you want to set it unconditionally: &lt;code&gt;set filetype=test&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;:setfiletype&lt;/code&gt; if you want to set it on the condition it hasn't been done before by another&#xA;autocmd: &lt;code&gt;setfiletype test&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, if you wanted to unconditionally set the filetype of a file whose extension is &lt;code&gt;.test&lt;/code&gt;, before&#xA;the default autocmds in &lt;code&gt;$VIMRUNTIME/filetype.vim&lt;/code&gt;, you would need to choose an implementation similar&#xA;to the one labeled &lt;code&gt;C.&lt;/code&gt; in &lt;code&gt;:h ftdetect&lt;/code&gt;. The example given there is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; my filetype file&#xA;if exists(&quot;did_load_filetypes&quot;)&#xA;  finish&#xA;endif&#xA;augroup filetypedetect&#xA;  au! BufRead,BufNewFile *.mine             setfiletype mine&#xA;  au! BufRead,BufNewFile *.xyz              setfiletype drawing&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adapted to your file whose extension is &lt;code&gt;.test&lt;/code&gt;, it would give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; my filetype file&#xA;if exists(&quot;did_load_filetypes&quot;)&#xA;  finish&#xA;endif&#xA;augroup filetypedetect&#xA;  au! BufRead,BufNewFile *.test             set filetype=test&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once this file is created, you need to restart Vim. After that, whenever you reload a file whose&#xA;extension is &lt;code&gt;.test&lt;/code&gt;, here's what will happen:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;BufReadPost&lt;/code&gt; is fired&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;au! BufRead,BufNewFile *.test             set filetype=test&lt;/code&gt; is triggered&lt;/li&gt;&#xA;&lt;li&gt;the buffer-local option &lt;code&gt;'filetype'&lt;/code&gt; receives the value &lt;code&gt;test&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;FileType&lt;/code&gt; is fired with the value &lt;code&gt;test&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;the buffer-local option &lt;code&gt;'syntax'&lt;/code&gt; receives the value &lt;code&gt;test&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Syntax&lt;/code&gt; is fired with the value &lt;code&gt;test&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;your &lt;code&gt;test&lt;/code&gt; syntax plugin is sourced,&#xA;if it's located in &lt;code&gt;~/.vim/syntax/test.vim&lt;/code&gt; or &lt;code&gt;~/.vim/after/syntax/test.vim&lt;/code&gt; (or in any file whose path is matched by the pattern &lt;code&gt;{directory in $VIMRUNTIME}/syntax/test.vim&lt;/code&gt; or &lt;code&gt;{directory in $VIMRUNTIME}/syntax/test/*.vim&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you want your &lt;code&gt;test&lt;/code&gt; syntax plugin to be sourced before a possible &lt;code&gt;test&lt;/code&gt; syntax plugin present in &lt;code&gt;$VIMRUNTIME&lt;/code&gt;, use &lt;code&gt;~/.vim/syntax/test.vim&lt;/code&gt;. Otherwise, use &lt;code&gt;~/.vim/after/syntax/test.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sourcing your syntax plugin before the one in &lt;code&gt;$VIMRUNTIME&lt;/code&gt; is useful when you want to ignore the latter, and completely redefine it. Sourcing it after is useful when you just want to tweak a few syntax groups.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But then if I edit test.vim, I cannot get the  changes I make to take effect unless I close out my&#xA;  text file and then reenable syntax highlighting.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As you found out in  your &lt;a href=&quot;https://vi.stackexchange.com/a/11580/13370&quot;&gt;answer&lt;/a&gt;, the issue comes from&#xA;the &lt;code&gt;def&lt;/code&gt; argument of the &lt;code&gt;:highlight&lt;/code&gt; command, which is described in &lt;code&gt;:h :hi-default&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The [default] argument is used for setting the default highlighting for a&#xA;group.      If highlighting has already been specified for the group the command&#xA;will be ignored.  Also when there is an existing link.&#xA;&#xA;Using [default] is especially useful to overrule the highlighting of a&#xA;specific syntax file.  For example, the C syntax file contains:&#xA;        :highlight default link cComment Comment&#xA;If you like Question highlighting for C comments, put this in your vimrc file:&#xA;        :highlight link cComment Question&#xA;Without the &quot;default&quot; in the C syntax file, the highlighting would be&#xA;overruled when the syntax file is loaded.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;def&lt;/code&gt; tells Vim that if the highlighting group has already been specified then the command should be&#xA;ignored. IOW, the link you write is just a DEFault value, to be used as a fallback only if the group&#xA;has not been configured.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In  your case, it means that if you want  to change  how the syntax  groups of your &lt;code&gt;test&lt;/code&gt; file are colored  during the  same Vim session, you should avoid this argument, so that Vim applies your link unconditionally, and ignores any possible pre-existing link.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want more information about how to write a syntax plugin, you could read &lt;code&gt;:help usr_44&lt;/code&gt;.&lt;br&gt;&#xA;It's a chapter of the user manual (not the reference manual, so it should be easier to read).&lt;/p&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-11-26T17:25:28.703" LastActivityDate="2017-11-26T17:25:28.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14340" PostTypeId="1" CreationDate="2017-11-26T12:57:14.773" Score="1" ViewCount="239" Body="&lt;p&gt;Shougo is no longer maintaining NeoBundle, but instead has re-written a plugin manager from scratch under the name &lt;code&gt;Dein&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/Shougo/dein.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dein GitHub page&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;No Vundle/NeoBundle compatibility&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Given that NeoBundle is no longer actively developed, how does one migrate from NeoBundle to Dein?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastActivityDate="2017-11-26T12:57:14.773" Title="How to migrate from NeoBundle to Dein?" Tags="|plugin-system|plugin-neobundle|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14341" PostTypeId="2" ParentId="14323" CreationDate="2017-11-26T17:32:14.053" Score="1" Body="&lt;h3&gt;Plugin &lt;code&gt;targets.vim&lt;/code&gt; by Christian Wellenbrock (aka wellle)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This plugin provides following &lt;em&gt;four&lt;/em&gt; text-objects:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;i`&lt;/code&gt; - Select &lt;em&gt;inside backticks&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a ` bbbbbbbb ` e&#xA;   └── i` ──┘&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;a`&lt;/code&gt; - Select including backticks.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a ` bbbbbbbb ` e&#xA;  └─── a` ───┘&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;I`&lt;/code&gt; - Like &lt;em&gt;inside backticks&lt;/em&gt;, but exclude whitespace at&#xA;both ends. Useful for changing contents while preserving spacing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a ` bbbbbbbb ` e&#xA;    └─ I` ─┘&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;A`&lt;/code&gt; - Select around a quote. Like a quote, but include whitespace in one&#xA;direction. Prefers to select trailing whitespace, falls back to select&#xA;leading whitespace.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a ` bbbbbbbb ` e&#xA;  └─── A` ────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Please note, this plugin tries to improve the built-in text-objects. This can be a matter of taste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find the documentation here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/wellle/targets.vim#quote-text-objects&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/wellle/targets.vim#quote-text-objects&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h targets-quote-text-objects&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&#xA;As already mentioned there are  many plugins. Not yet mentioned are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/paradigm/TextObjectify&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/paradigm/TextObjectify&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kurkale6ka/vim-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kurkale6ka/vim-pairs&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and a few plugins try to offer a &lt;em&gt;smart selection&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/gcmt/wildfire.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/gcmt/wildfire.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/gorkunov/smartpairs.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/gorkunov/smartpairs.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2017-11-26T17:46:30.917" LastActivityDate="2017-11-26T17:46:30.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14342" PostTypeId="1" AcceptedAnswerId="14343" CreationDate="2017-11-26T19:20:38.480" Score="2" ViewCount="521" Body="&lt;p&gt;I use &lt;code&gt;&amp;lt;bs&amp;gt;&lt;/code&gt; for scrolling up half a page and &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; for scrolling down:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like the same keybindings to be available in NerdTree. It seems that &lt;code&gt;o&lt;/code&gt; and &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; are equivalent in file-mode in NerdTree (just based on the help text) and that &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; doesn't seems to play much of a role in the other modes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to prevent &lt;code&gt;NerdTree&lt;/code&gt; from binding &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; at all?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More generally, what is a good general strategy (if one exists) for &quot;reclaiming&quot; a keybinding from an overzealous plugin without too many side effects?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2017-11-26T19:38:49.740" LastActivityDate="2017-11-26T20:00:16.343" Title="Prevent nerdtree from rebinding &lt;cr&gt;" Tags="|key-bindings|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14343" PostTypeId="2" ParentId="14342" CreationDate="2017-11-26T19:41:32.587" Score="2" Body="&lt;p&gt;I don't know much about &lt;code&gt;NerdTree&lt;/code&gt;, but according to &lt;code&gt;:h NERDTreeKeymapAPI&lt;/code&gt;, you can use&#xA;a function provided by the plugin, &lt;code&gt;NERDTreeAddKeyMap()&lt;/code&gt;, to override default mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4.1. Key map API                                           *NERDTreeKeymapAPI*&#xA;&#xA;NERDTreeAddKeyMap({options})                             *NERDTreeAddKeyMap()*&#xA;    Adds a new keymapping for all NERD tree buffers.&#xA;    {options} must be a dictionary, and must contain the following keys:&#xA;    &quot;key&quot; - the trigger key for the new mapping&#xA;    &quot;callback&quot; - the function the new mapping will be bound to&#xA;    &quot;quickhelpText&quot; - the text that will appear in the quickhelp (see&#xA;    |NERDTree-?|)&#xA;    &quot;override&quot; - if 1 then this new mapping will override whatever previous&#xA;    mapping was defined for the key/scope combo. Useful for overriding the&#xA;    default mappings.&#xA;&#xA;    Additionally, a &quot;scope&quot; argument may be supplied. This constrains the&#xA;    mapping so that it is only activated if the cursor is on a certain object.&#xA;    That object is then passed into the handling method. Possible values are:&#xA;        &quot;FileNode&quot; - a file node&#xA;        &quot;DirNode&quot; - a directory node&#xA;        &quot;Node&quot; - a file or directory node&#xA;        &quot;Bookmark&quot; - A bookmark&#xA;        &quot;all&quot; - the keymap is not constrained to any scope (default). When&#xA;        thei is used, the handling function is not passed any arguments.&#xA;&#xA;&#xA;    Example: &amp;gt;&#xA;        call NERDTreeAddKeyMap({&#xA;            \ 'key': 'foo',&#xA;            \ 'callback': 'NERDTreeCDHandler',&#xA;            \ 'quickhelpText': 'echo full path of current node',&#xA;            \ 'scope': 'DirNode' })&#xA;&#xA;        function! NERDTreeCDHandler(dirnode)&#xA;            call a:dirnode.changeToDir()&#xA;        endfunction&#xA;&amp;lt;&#xA;    This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim.&#xA;    It adds a (redundant) mapping on 'foo' which changes vim's CWD to that of&#xA;    the current dir node. Note this mapping will only fire when the cursor is&#xA;    on a directory node.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your case, if you want &lt;code&gt;CR&lt;/code&gt; to act as &lt;code&gt;C-d&lt;/code&gt;, to scroll down half a page, you could write in &lt;code&gt;~/.vim/after/plugin/my_nerdtree.vim&lt;/code&gt; (you can create the missing directories if &lt;code&gt;~/.vim/after/plugin/&lt;/code&gt; doesn't exist on your system):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call NERDTreeAddKeyMap({&#xA;\                       'key': '&amp;lt;cr&amp;gt;',&#xA;\                       'callback': {-&amp;gt; feedkeys(&quot;\&amp;lt;c-d&amp;gt;&quot;, 'int')},&#xA;\                      })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More generally, you can use &lt;code&gt;~/.vim/after/plugin/my_plugin.vim&lt;/code&gt; to override whatever customization&#xA;was done by a third-party plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if &lt;code&gt;NerdTree&lt;/code&gt; didn't provide this public function, in the same file as before, you could install an autocmd listening to &lt;code&gt;FileType&lt;/code&gt;, which would remap &lt;code&gt;CR&lt;/code&gt; to &lt;code&gt;C-d&lt;/code&gt;, but only in a &lt;code&gt;NerdTree&lt;/code&gt; buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup my_nerdtree&#xA;    au!&#xA;    au FileType nerdtree nnoremap &amp;lt;buffer&amp;gt; &amp;lt;cr&amp;gt; &amp;lt;c-d&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although, both methods are not exactly equivalent here. The public function seems to provide more control over the mapping, and it could even be more reliable, I don't know.&lt;/p&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-11-26T20:00:16.343" LastActivityDate="2017-11-26T20:00:16.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14344" PostTypeId="1" CreationDate="2017-11-27T08:21:42.663" Score="1" ViewCount="51" Body="&lt;p&gt;As soon as I put the cursor on column 79 or beyond, the Vim viewport jumps to make sure the cursor is put in the middle of the viewport. I find it massively disturbing, but could not navigate my way through the &lt;code&gt;:h&lt;/code&gt; pages to find how to turn it off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to change what that limit is, or even disable it altogether?&lt;/p&gt;&#xA;" OwnerUserId="2082" LastActivityDate="2017-11-27T08:21:42.663" Title="Prevent viewport from jumping to the right" Tags="|cursor-movement|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14345" PostTypeId="2" ParentId="233" CreationDate="2017-11-27T14:40:25.700" Score="-1" Body="&lt;p&gt;At bottom of the file, I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: ts=2 sw=2 sts=2 sr noet st ai si&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example &lt;code&gt;Dockerfile&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FROM centos-7&#xA;RUN ...&#xA;CMD ...&#xA;&#xA;# vim: ts=2 sw=2 sts=2 sr noet st ai si&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want keep the indentation only, use &lt;code&gt;# vim: st ai si&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6222" LastActivityDate="2017-11-27T14:40:25.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14346" PostTypeId="1" CreationDate="2017-11-27T19:23:20.587" Score="3" ViewCount="1177" Body="&lt;p&gt;Whenever I call Vim from the CLI, either to edit a file (&lt;code&gt;vim idk.tex&lt;/code&gt;) or without arguments, or run a command (&lt;code&gt;vim +help&lt;/code&gt;), it gets sent to the background, as if I had pressed &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Z&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to use it, I always have to send the job to foreground, either to wait for it to finish or to begin working in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried this on Zsh, bash, fish and tmux (with each shell), and it's always the same behavior. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't reproduce it with &lt;a href=&quot;https://github.com/bling/minivimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;minivimrc&lt;/a&gt;, so I don't know if I should report it as an Airline bug or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have hacked up an alias (&lt;code&gt;vim=&quot;vim;fg&quot;&lt;/code&gt;) so that it won't bug me daily, but it's not feasible when I have other background jobs or when vim fails to start for whatever reason (besides, it's just a hack).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers as to where I should look or ask are welcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running Vim (GVim package) on Termite (v12) on Arch (fully up to date)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vimrc is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; for when using elsewhere&#xA;set fsync backspace=indent,eol,start updatetime=1500&#xA;set shell=bash\ -i&#xA;&quot; search candy&#xA;set incsearch nohlsearch ignorecase smartcase&#xA;&#xA;&quot; useful shiz&#xA;set number hidden cursorline cursorcolumn&#xA;set splitright&#xA;set mouse=a mousefocus clipboard=unnamedplus&#xA;set smarttab autoindent copyindent&#xA;set scrolloff=2   &quot; 2 lines of context when scrolling&#xA;syntax enable&#xA;set history=1000 undolevels=1000&#xA;&quot; non-printable and double-width chars&#xA;set list listchars=tab:&amp;gt;-,trail:Â·,extends:#,nbsp:Â·&#xA;set ambiwidth=single&#xA;&quot; tab -&amp;gt; 2 spaces, autoindent when pasting&#xA;set expandtab tabstop=2&#xA;&quot; default tab-&amp;gt;2 spaces, use multiples of 2 when autoindenting&#xA;set softtabstop=2 shiftwidth=2 shiftround&#xA;&quot; wrap shiz&#xA;set wrap linebreak nolist&#xA;set directory=/tmp   &quot; store swap files here&#xA;filetype on&#xA;filetype indent plugin on&#xA;set ttimeoutlen=10&#xA;set noshowmode&#xA;set showcmd&#xA;set colorcolumn=80&#xA;hi ColorColumn ctermbg=7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15277" LastEditorUserId="51" LastEditDate="2017-11-29T00:05:54.587" LastActivityDate="2017-11-29T00:06:45.553" Title="Vim immediately sent to background" Tags="|vimrc|startup|job-control|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14347" PostTypeId="2" ParentId="14346" CreationDate="2017-11-27T22:36:31.497" Score="2" Body="&lt;p&gt;I shouldn't have set the shell as interactive. Somehow it pauses the main Vim process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shell=bash\ -i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shell=bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15277" LastEditorUserId="51" LastEditDate="2017-11-29T00:05:25.970" LastActivityDate="2017-11-29T00:05:25.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14348" PostTypeId="2" ParentId="3105" CreationDate="2017-11-28T00:49:32.190" Score="0" Body="&lt;p&gt;And to save that one precious key stroke you can use &lt;code&gt;0C&lt;/code&gt; which will delete all the characters on the current line and put you into insert mode.&lt;/p&gt;&#xA;" OwnerUserId="15284" LastActivityDate="2017-11-28T00:49:32.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14351" PostTypeId="5" CreationDate="2017-11-28T12:27:43.033" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/jmcantrell/vim-virtualenv&quot; rel=&quot;nofollow noreferrer&quot;&gt;virtualenv.vim&lt;/a&gt; is a Vim plugin for working with Python virtualenvs.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-28T12:27:43.033" LastActivityDate="2017-11-28T12:27:43.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14352" PostTypeId="4" CreationDate="2017-11-28T12:27:43.033" Score="0" Body="Questions about the virtualenv.vim plugin" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-28T12:27:43.033" LastActivityDate="2017-11-28T12:27:43.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14353" PostTypeId="1" AcceptedAnswerId="14354" CreationDate="2017-11-28T16:01:44.727" Score="6" ViewCount="440" Body="&lt;p&gt;I set up this function in my .vimrc file. It duplicates the current window, moves it to a new tab, &lt;code&gt;read&lt;/code&gt;s the output of &lt;a href=&quot;https://github.com/google/yapf&quot; rel=&quot;noreferrer&quot;&gt;yapf&lt;/a&gt; (a code formatter) run on the current file, sets up a diff between the original file and the formatted file, and selects the original file window. Then I proceed to merge the format changes I like by using &lt;code&gt;]c&lt;/code&gt; and &lt;code&gt;[c&lt;/code&gt; to navigate the changes and &lt;code&gt;do&lt;/code&gt;/&lt;code&gt;dp&lt;/code&gt; to accept the formatted change or keep the original.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the function I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Yapf()                                                                &#xA;         exe &quot;normal \&amp;lt;C-w&amp;gt;s\&amp;lt;C-w&amp;gt;T&quot;                                                 &#xA;         vnew                                                                    &#xA;         setlocal buftype=nofile                                                 &#xA;         read !yapf #                                                            &#xA;         windo diffthis                                                          &#xA;         wincmd p                                                                &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I came up with this with help from &lt;a href=&quot;https://vi.stackexchange.com/a/14172/15057&quot;&gt;answers to a previous question&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I tend to run this on scripts that start with a shebang line, and it always seemed to suggest a blank line at the start of the file (which would break the shebang behaviour). E.g. I created a new file with the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/python2&#xA;&#xA;print &quot;hi&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then calling &lt;code&gt;call Yapf()&lt;/code&gt; in vim, the resulting diff shows a blank line at the top of the output of the yapf call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calling yapf from the command line directly on the file produces an output with no extra initial line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this extra line coming from how I am using &lt;code&gt;read&lt;/code&gt;? How can I fix my function to avoid this issue?&lt;/p&gt;&#xA;" OwnerUserId="15057" LastActivityDate="2017-11-30T22:09:23.480" Title="`Read` seems to bring an extra line - how to prevent this?" Tags="|external-command|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14354" PostTypeId="2" ParentId="14353" CreationDate="2017-11-28T16:57:20.907" Score="8" Body="&lt;p&gt;I don't have a good explanation for why Vim does this, it just does. &lt;code&gt;:help :read&lt;/code&gt; says that the &lt;code&gt;:read&lt;/code&gt; command inserts text below the cursor and Vim considers the cursor in an empty buffer to be on the first line, even though there is no line in the buffer at that point. So a &lt;code&gt;:read&lt;/code&gt; into an empty buffer will always leave an empty first line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To work around that, I always follow the &lt;code&gt;:read&lt;/code&gt; command in such scripts with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0d_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which deletes the first line into the &quot;black hole register&quot;. See &lt;code&gt;:help quote_&lt;/code&gt;. That way, no normal registers are affected by the deletion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also work around this by replacing that first line with the results of some command, as with your command as an example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.!yapf #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-11-28T16:57:20.907" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14355" PostTypeId="2" ParentId="14353" CreationDate="2017-11-28T16:59:15.593" Score="4" Body="&lt;p&gt;You have options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Filter the contents of your new split via &lt;code&gt;%!yapf #&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Delete the last line &lt;code&gt;:1d_&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Let's clean up that function a little:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;stop messing with the window layout. aka no &lt;code&gt;&amp;lt;c-w&amp;gt;s&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;wipe the buffer when we are done&lt;/li&gt;&#xA;&lt;li&gt;stop diff'ing when close the buffer&lt;/li&gt;&#xA;&lt;li&gt;set the filetype so we get some highlighting&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All together now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Yapf()                                                                &#xA;  let bufnr = bufnr('%')&#xA;  tabnew&#xA;  execute 'b' . bufnr&#xA;  vnew                                                                    &#xA;  setlocal buftype=nofile                                                 &#xA;  setlocal bufhidden=wipe                                                 &#xA;  setlocal noswapfile&#xA;  read !yapf #                                                            &#xA;  0delete_&#xA;  let &amp;amp;filetype=getbufvar('#', '&amp;amp;filetype')&#xA;  execute 'autocmd BufWipeout &amp;lt;buffer&amp;gt; diffoff!'&#xA;  diffthis&#xA;  wincmd p                                                                &#xA;  diffthis&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h range!&#xA;:h :d&#xA;:h quote_&#xA;:h 'filetype'&#xA;:h getbufvar()&#xA;:h tabnew&#xA;:h :b&#xA;:h bufnr()&#xA;:h :diffoff&#xA;:h BufWipeout&#xA;:h 'bufhidden'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-11-28T17:15:32.897" LastActivityDate="2017-11-28T17:15:32.897" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14356" PostTypeId="1" AcceptedAnswerId="14359" CreationDate="2017-11-28T18:52:21.273" Score="6" ViewCount="3513" Body="&lt;p&gt;Is there any built-in way to jump to the next or previous error in the quickfix/location list relative to the current cursor position?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say my quickfix list looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---quickfix list---&#xA;a.txt - line 1&#xA;a.txt - line 2&#xA;b.txt - line 6&#xA;b.txt - line 7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am currently in &lt;code&gt;b.txt&lt;/code&gt; on line 1. If I try &lt;code&gt;:cnext&lt;/code&gt; Vim will jump to &lt;code&gt;a.txt&lt;/code&gt; on line 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead I would prefer to jump to &lt;code&gt;b.txt&lt;/code&gt; on line 6 (and whatever column is specified in the qf list)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b.txt - 1 =&amp;gt; b.txt - 6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15294" LastEditorUserId="1841" LastEditDate="2017-11-28T19:28:07.190" LastActivityDate="2019-05-03T20:21:59.180" Title="Go to quickfix next/previous (cnext/cprevious) relative to current file position?" Tags="|quickfix|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14357" PostTypeId="1" AcceptedAnswerId="14358" CreationDate="2017-11-28T19:28:17.927" Score="3" ViewCount="4241" Body="&lt;p&gt;According to &lt;a href=&quot;https://vi.stackexchange.com/questions/11879/how-can-put-vimrc-and-viminfo-into-vim-directory&quot;&gt;this FAQ&lt;/a&gt; for moving .viminfo file to .vim dir we should add &lt;code&gt;viminfo+=n~/.vim/viminfo&lt;/code&gt; to vimrc file but when I put this line in my vimrc, every time I open vim, it will return this: &lt;code&gt;E492: Not an editor command: viminfo+=n~/.vim/viminfo&lt;/code&gt; But I don't know why and how can I fix it, so please let me know that and don't mark [duplicate] on this question.&lt;/p&gt;&#xA;" OwnerUserId="15007" LastActivityDate="2021-05-25T11:30:11.550" Title="Moving .viminfo file to .vim dir" Tags="|vimrc|viminfo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14358" PostTypeId="2" ParentId="14357" CreationDate="2017-11-28T19:32:32.953" Score="4" Body="&lt;p&gt;&lt;code&gt;viminfo&lt;/code&gt; is an option, @Tommy A forgot the keyword &lt;code&gt;set&lt;/code&gt; in his command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viminfo+=n~/.vim/viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should work properly. If you read &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27viminfo%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'viminfo'&lt;/code&gt;&lt;/a&gt; you can see an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set viminfo='50,&amp;lt;1000,s100,:0,n~/vim/viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt; As @Carpetsmoker mentioned it in the comments, neovim has a different format for these options so one should use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('nvim') | let &amp;amp;viminfo .= '.nvim' | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-11-29T08:33:06.490" LastActivityDate="2017-11-29T08:33:06.490" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14359" PostTypeId="2" ParentId="14356" CreationDate="2017-11-28T20:00:34.917" Score="6" Body="&lt;p&gt;There is no built in way to do file specific &lt;code&gt;:cnext&lt;/code&gt;. You would have to roll your own function/command to do such a task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my interpretation of &lt;code&gt;:Cfnext&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar -count=1 Cfnext exe 'cc'.(get(get(filter(map(getqflist(), 'extend(v:val, {&quot;idx&quot;: v:key})'), 'bufname(v:val.bufnr) == expand(&quot;%&quot;) &amp;amp;&amp;amp; line(&quot;.&quot;) &amp;lt;= v:val.lnum &amp;amp;&amp;amp; col(&quot;.&quot;) &amp;lt; v:val.col'), 0, {}), 'idx', getqflist({'idx':1}).idx-1)+&amp;lt;count&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a cleaned up and more complete version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar -count=1 Cfnext execute &amp;lt;SID&amp;gt;cfnext(&amp;lt;count&amp;gt;, 'qf')&#xA;command! -bar -count=1 Cfprev execute &amp;lt;SID&amp;gt;cfnext(&amp;lt;count&amp;gt;, 'qf', 1)&#xA;command! -bar -count=1 Lfnext execute &amp;lt;SID&amp;gt;cfnext(&amp;lt;count&amp;gt;, 'loc')&#xA;command! -bar -count=1 Lfprev execute &amp;lt;SID&amp;gt;cfnext(&amp;lt;count&amp;gt;, 'loc', 1)&#xA;&#xA;function! s:cfnext(count, list, ...) abort&#xA;  let reverse = a:0 &amp;amp;&amp;amp; a:1 &#xA;  let func = 'get' . a:list . 'list'&#xA;  let params = a:list == 'loc' ? [0] : []&#xA;  let cmd = a:list == 'loc' ? 'll' : 'cc'&#xA;&#xA;  let items = call(func, params)&#xA;  if len(items) == 0&#xA;    return 'echoerr ' . string('E42: No Errors')&#xA;  endif&#xA;&#xA;  call map(items, 'extend(v:val, {&quot;idx&quot;: v:key + 1})')&#xA;  if reverse&#xA;    call reverse(items)&#xA;  endif&#xA;&#xA;  let [bufnr, cmp] = [bufnr('%'), reverse ? 1 : -1]&#xA;  let context = [line('.'), col('.')]&#xA;  if v:version &amp;gt; 800 || has('patch-8.0.1112')&#xA;    let current = call(func, extend(copy(params), [{'idx':1}])).idx&#xA;  else&#xA;    redir =&amp;gt; capture | execute cmd | redir END&#xA;    let current = str2nr(matchstr(capture, '(\zs\d\+\ze of \d\+)'))&#xA;  endif&#xA;  call add(context, current)&#xA;&#xA;  call filter(items, 'v:val.bufnr == bufnr &amp;amp;&amp;amp; s:cmp(context, [v:val.lnum, v:val.col, v:val.idx]) == cmp')&#xA;&#xA;  let idx = get(get(items, 0, {}), 'idx', 'E553: No more items')&#xA;&#xA;  if type(idx) == type(0)&#xA;    return cmd . idx&#xA;  else&#xA;     return 'echoerr' . string(idx)&#xA;  endif&#xA;endfunction&#xA;&#xA;function! s:cmp(a, b)&#xA;  for i in range(len(a:a))&#xA;    if a:a[i] &amp;lt; a:b[i]&#xA;      return -1&#xA;    elseif a:a[i] &amp;gt; a:b[i]&#xA;      return 1&#xA;    endif&#xA;  endfor&#xA;  return 0&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h getqflist()&#xA;:h filter()&#xA;:h index()&#xA;:h :cc&#xA;:h bufname()&#xA;:h expand()&#xA;:h map()&#xA;:h extend()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-12-01T21:17:14.280" LastActivityDate="2017-12-01T21:17:14.280" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14360" PostTypeId="2" ParentId="11879" CreationDate="2017-11-28T20:03:31.007" Score="0" Body="&lt;p&gt;For me hard links are the best for this purpose,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ln ~/.vimrc .vim/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will let you edit any of them and if you have been using git for storing  .vim&#xA;We can just create after pulling it from github.&lt;/p&gt;&#xA;" OwnerUserId="15224" LastEditorUserId="15224" LastEditDate="2020-08-21T06:46:59.750" LastActivityDate="2020-08-21T06:46:59.750" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="14361" PostTypeId="1" AcceptedAnswerId="14363" CreationDate="2017-11-28T22:27:37.307" Score="2" ViewCount="1009" Body="&lt;p&gt;I am using &lt;code&gt;NeoVim&lt;/code&gt; with &lt;code&gt;Tmux&lt;/code&gt; on an Ubuntu on Windows setup. I have bound neovim's clipboard to the system clipboard by using : &lt;code&gt;set clipboard+=unnamedplus&lt;/code&gt; and further configuration inside tmux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, everything works just fine, except for a detail that bothers me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As of now, when I delete a character in insert mode with &lt;kbd&gt;DEL&lt;/kbd&gt;, it works just fine. However, when I do that in normal mode, the character is deleted but also copied to the clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is there this difference ? Is there a way to disable this behaviour ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; I've also tried this on a Xubuntu machine running the same tmux config and &lt;code&gt;vim.gtk&lt;/code&gt;, and I have the same issue&lt;/p&gt;&#xA;" OwnerUserId="15300" LastActivityDate="2017-11-28T23:30:56.213" Title="Don't yank character with &lt;DEL&gt; key in normal mode" Tags="|cut-copy-paste|neovim|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14362" PostTypeId="2" ParentId="14361" CreationDate="2017-11-28T23:25:31.130" Score="4" Body="&lt;p&gt;This is because &lt;code&gt;&amp;lt;del&amp;gt;&lt;/code&gt; is equivalent to &lt;kbd&gt;x&lt;/kbd&gt;, or &lt;kbd&gt;dl&lt;/kbd&gt;, which not only delete, but also yank to the unnamed register by default. From &lt;code&gt;:h &amp;lt;del&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&quot;x]&amp;lt;Del&amp;gt;   or                  *&amp;lt;Del&amp;gt;* *x* *dl*&#xA;[&quot;x]x           Delete [count] characters under and after the cursor&#xA;            [into register x] (not |linewise|).  Does the same as&#xA;            &quot;dl&quot;.&#xA;            The &amp;lt;Del&amp;gt; key does not take a [count].  Instead, it&#xA;            deletes the last character of the count.&#xA;            See |:fixdel| if the &amp;lt;Del&amp;gt; key does not do what you&#xA;            want.  See |'whichwrap'| for deleting a line break&#xA;            (join lines).  {Vi does not support &amp;lt;Del&amp;gt;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The fix is really simple. Just add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;del&amp;gt; &quot;_x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your &lt;code&gt;.vimrc&lt;/code&gt; file. This will make it delete into the black-hole register (like &lt;code&gt;/dev/null&lt;/code&gt; on linux) and leave your other registers the same.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-11-28T23:25:31.130" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14363" PostTypeId="2" ParentId="14361" CreationDate="2017-11-28T23:30:56.213" Score="3" Body="&lt;p&gt;One quick fix I can think of is remapping the del key so it will use _ register.&#xA;so if you just add &#xA;&lt;code&gt;nnoremap &amp;lt;Del&amp;gt; &quot;_x&lt;/code&gt;&#xA;into your &lt;code&gt;$MYVIMRC&lt;/code&gt; &lt;code&gt;init.nvim&lt;/code&gt; for neovim or &lt;code&gt;~/.vimrc&lt;/code&gt; for standard vim&#xA;it should just do what you ask&lt;/p&gt;&#xA;" OwnerUserId="14587" LastActivityDate="2017-11-28T23:30:56.213" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14364" PostTypeId="1" AcceptedAnswerId="14365" CreationDate="2017-11-28T23:34:35.903" Score="1" ViewCount="877" Body="&lt;p&gt;I am writing a bash script about session management and what I want is if there's something in the arglist not to source the session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I couldn't find a way to check the length of &lt;code&gt;:args&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all how do I even assign the output of it into a variable?&lt;/p&gt;&#xA;" OwnerUserId="14587" LastEditorUserId="51" LastEditDate="2017-11-29T00:14:25.350" LastActivityDate="2017-11-29T00:14:25.350" Title="How can i get the arglist count?" Tags="|vimscript|neovim|argument-list|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14365" PostTypeId="2" ParentId="14364" CreationDate="2017-11-29T00:13:52.950" Score="4" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#argv%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;argv()&lt;/code&gt;&lt;/a&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim a b c&#xA;:echo argv()&#xA;['a', 'b', 'c']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is also the &lt;code&gt;argc()&lt;/code&gt; function to get the length of the argument list (which is the same as &lt;code&gt;len(argv())&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note: I found this by going to &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#arg-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help function-list&lt;/code&gt;&lt;/a&gt; and searching for &lt;code&gt;arg&lt;/code&gt; :-) I find &lt;code&gt;:help function-list&lt;/code&gt; to be one of the most useful Vim pages when writing VimScript. Tattoo it on your arm!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also documented in some detail at &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#argument-list&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help argument-list&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-11-29T00:13:52.950" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14366" PostTypeId="2" ParentId="14166" CreationDate="2017-11-29T02:46:26.177" Score="2" Body="&lt;p&gt;Unfortunately there is no easy way to fix this at the moment, the OP has opened a &lt;a href=&quot;https://github.com/fatih/vim-go/issues/1571&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-go issue&lt;/a&gt; and we agree that this is something vim-go can do better. Now we just need someone to spend time fixing it :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the meanwhile, you &lt;em&gt;can&lt;/em&gt; do some things to use ALE and vim-go simultaneously.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Setting &lt;code&gt;g:go_list_type = 'locationlist'&lt;/code&gt; will make vim-go always use the location list. It will &lt;em&gt;overwrite&lt;/em&gt; the location list, though (so still not perfect), but it's better than having two lists.&lt;br&gt;&#xA;You can also use &lt;code&gt;g:ale_set_quickfix = 1&lt;/code&gt; to make ALE use the quickfix window, if you prefer.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For many things, I use ALE and not vim-go, because I prefer to have the same behaviour in all filetypes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; No gofmt on save. We use ALE.&#xA;let g:go_fmt_autosave = 0&#xA;&#xA;augroup my_go_settings&#xA;    autocmd!&#xA;&#xA;    &quot; Because I use ALE these commands are useless to me.&#xA;    autocmd FileType go&#xA;                \  delc GoErrCheck | delc GoLint | delc GoVet&#xA;                \| delc GoFmt | delc GoImports | delc GoFmtAutoSaveToggle&#xA;                \| delc GoMetaLinter&#xA;augroup end&#xA;&#xA;&quot; Format code for me on :w&#xA;let g:ale_fix_on_save = 1&#xA;&#xA;&quot; goimports on save.&#xA;let g:ale_fixers = {'go': ['goimports']}&#xA;&#xA;&quot; Linters&#xA;let g:ale_linters = {'go': ['gometalinter']}&#xA;let g:ale_go_gometalinter_options = '--disable-all'&#xA;            \ . ' --enable=vet'&#xA;            \ . ' --enable=golint'&#xA;            \ . ' --enable=errcheck'&#xA;            \ . ' --enable=ineffassign'&#xA;            \ . ' --enable=goconst'&#xA;            \ . ' --enable=goimports'&#xA;            \ . ' --enable=lll --line-length=120'&#xA;            &quot; These are slow (&amp;gt;2s)&#xA;            &quot; \ . ' --enable=varcheck'&#xA;            &quot; \ . ' --enable=interfacer'&#xA;            &quot; \ . ' --enable=unconvert'&#xA;            &quot; \ . ' --enable=structcheck'&#xA;            &quot; \ . ' --enable=megacheck'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To be fair, vim-go's GoFmt implementation is actually better, and handles more cases. But ALE's syntax checking is better, and the fix_on_save feature works well enough (I use it daily). I plan to spend some time to improve ALE in this regard soon™.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This combination of settings doesn't cover 100% of the cases, but it does most of them, and overall it works quite well for me.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-11-29T02:55:45.957" LastActivityDate="2017-11-29T02:55:45.957" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14367" PostTypeId="1" AcceptedAnswerId="14372" CreationDate="2017-11-29T08:02:11.747" Score="2" ViewCount="136" Body="&lt;p&gt;After some settings (like installing other plugins and defining some mappings), I've found that GitGutter's Next Hunk (&lt;code&gt;]c&lt;/code&gt; and &lt;code&gt;[c&lt;/code&gt;) doesn't work any more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do &lt;code&gt;]cabc&lt;/code&gt; I will see &lt;code&gt;:&amp;lt;C-U&amp;gt;execute v:count1 . 'GitGutterNextHunk'&amp;lt;CR&amp;gt;abc&lt;/code&gt;in the command, which means the mapping resulted in entering the text in command directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I do &lt;code&gt;:map&lt;/code&gt; I see &lt;code&gt;]c&lt;/code&gt; correctly mapped to &lt;code&gt;&amp;lt;Plug&amp;gt;GitGutterNextHunk&lt;/code&gt;, which is then mapped as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n  &amp;lt;Plug&amp;gt;GitGutterNextHunk * &amp;amp;diff ? ']c' : &quot;:&amp;lt;C-U&amp;gt;execute v:count1 . 'GitGutterNextHunk'&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Btw, calling directly like &lt;code&gt;:execute 'GitGutterNextHunk'&lt;/code&gt; works.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This all happens after I added the line &lt;code&gt;set cpoptions=&quot;aABceFsd&quot;&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt;. I added the &lt;code&gt;d&lt;/code&gt; for &lt;code&gt;tags&lt;/code&gt; integration.  How may that interfere with my mappings?&lt;/p&gt;&#xA;" OwnerUserId="14820" LastEditorUserId="343" LastEditDate="2017-11-30T09:46:12.453" LastActivityDate="2017-11-30T17:17:46.420" Title="GitGutter's Mapping goes to Command as Plain Text after changing cpoptions" Tags="|key-bindings|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14368" PostTypeId="1" CreationDate="2017-11-29T10:21:11.417" Score="1" ViewCount="144" Body="&lt;p&gt;According to &lt;code&gt;:help v&lt;/code&gt; a count of &lt;code&gt;1&lt;/code&gt; provided to &lt;code&gt;v&lt;/code&gt; will select the same number of characters as the previous selection, but starting from the current cursor (see full help below). When there was no previous selection, it will select &lt;code&gt;count&lt;/code&gt; characters. Is it possible to reset this count to obtain the default behaviour?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[count]v    Start Visual mode per character.&#xA;            With [count] select the same number of characters or&#xA;            lines as used for the last Visual operation, but at&#xA;            the current cursor position, multiplied by [count].&#xA;            When the previous Visual operation was on a block both&#xA;            the width and height of the block are multiplied by&#xA;            [count].&#xA;            When there was no previous Visual operation [count]&#xA;            characters are selected.  This is like moving the&#xA;            cursor right N * [count] characters.  One less when&#xA;            'selection' is not &quot;exclusive&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8061" LastEditorUserId="343" LastEditDate="2017-12-06T11:11:51.720" LastActivityDate="2017-12-06T11:11:51.720" Title="reset count for `v`" Tags="|visual-mode|count|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14369" PostTypeId="2" ParentId="14368" CreationDate="2017-11-29T11:00:28.213" Score="2" Body="&lt;p&gt;One easy way to workaround this would be by typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v&quot;_y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will yank a single character into the black hole register. Therefore, it's only effect is to reset the visual count to 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifying the blackhole register with &lt;code&gt;&quot;_&lt;/code&gt; isn't strictly necessary, but it prevents the operation from affecting your registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that setting the visual count to 1 only has the desired effect if &lt;code&gt;'selection'&lt;/code&gt; is not set to &lt;code&gt;exclusive&lt;/code&gt;. (Its default value is &lt;code&gt;inclusive&lt;/code&gt;.) If &lt;code&gt;'selection'&lt;/code&gt; &lt;em&gt;is&lt;/em&gt; set to &lt;code&gt;exclusive&lt;/code&gt;, then your subsequent &lt;code&gt;[count]v&lt;/code&gt; operation will still select &lt;code&gt;[count]&lt;/code&gt; characters, which for &lt;code&gt;selection=exclusive&lt;/code&gt; is one too few.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-29T11:14:48.930" LastActivityDate="2017-11-29T11:14:48.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14371" PostTypeId="1" AcceptedAnswerId="15602" CreationDate="2017-11-29T15:35:38.860" Score="3" ViewCount="10851" Body="&lt;p&gt;My neovim doesn't load file type plugins when loading a ruby/eruby file. Here is the corresponding configuration files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for f in ~/.config/nvim/after/ftplugin/* ; do echo &quot;# $f&quot; ; cat $f; done&#xA;# /home/psychoslave/.config/nvim/after/ftplugin/erb.vim&#xA;&quot; Turn off vi compatibility&#xA;set nocompatible&#xA;&#xA;set smartindent&#xA;set noautoindent&#xA;set filetype=ruby&#xA;filetype indent off&#xA;filetype plugin indent on&#xA;set shiftwidth=2&#xA;set tabstop=2&#xA;set expandtab&#xA;&quot;set ai &quot;Auto indent&#xA;&quot;set si &quot;Smart indent&#xA;&quot;set wrap &quot;Wrap line&#xA;set backspace=indent,eol,start&#xA;set filetype=eruby&#xA;# /home/psychoslave/.config/nvim/after/ftplugin/eruby.vim&#xA;&quot; Turn off vi compatibility&#xA;set nocompatible&#xA;&#xA;set smartindent&#xA;set noautoindent&#xA;set filetype=ruby&#xA;filetype indent off&#xA;filetype plugin indent on&#xA;set shiftwidth=2&#xA;set tabstop=2&#xA;set expandtab&#xA;&quot;set ai &quot;Auto indent&#xA;&quot;set si &quot;Smart indent&#xA;&quot;set wrap &quot;Wrap line&#xA;set backspace=indent,eol,start&#xA;set filetype=eruby&#xA;# /home/psychoslave/.config/nvim/after/ftplugin/ruby.vim&#xA;&quot; Turn off vi compatibility&#xA;set nocompatible&#xA;&#xA;set smartindent&#xA;set noautoindent&#xA;set filetype=ruby&#xA;filetype indent off&#xA;filetype plugin indent on&#xA;set shiftwidth=2&#xA;set tabstop=2&#xA;set expandtab&#xA;&quot;set ai &quot;Auto indent&#xA;&quot;set si &quot;Smart indent&#xA;&quot;set wrap &quot;Wrap line&#xA;set backspace=indent,eol,start&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I open a ruby file, it doesn't have tab set to 2 spaces and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did added &lt;code&gt;filetype plugin indent on&lt;/code&gt; in &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once running, trying to launch &lt;code&gt;:so ~/.config/nvim/after/ftplugin/eruby.vim&lt;/code&gt; will lead to the following error, repeated multiple times:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line    6:                                                                                                                             &#xA;E218: autocommand nesting too deep                                                                                                     &#xA;Error detected while processing FileType Auto commands for &quot;*&quot;:                                                                        &#xA;E218: autocommand nesting too deep &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I resolve this problem? Is there a way to list what configuration files a neovim red and in which order?&lt;/p&gt;&#xA;" OwnerUserId="11597" LastActivityDate="2018-03-17T12:51:31.260" Title="Why files in `~/.config/nvim/after/ftplugin/` are not taken into acount?" Tags="|neovim|filetype|filetype-ruby|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14372" PostTypeId="2" ParentId="14367" CreationDate="2017-11-29T18:35:22.310" Score="3" Body="&lt;p&gt;From what it looks like &lt;a href=&quot;https://github.com/airblade/vim-gitgutter&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitGutter&lt;/a&gt; by default maps &lt;code&gt;&amp;lt;Plug&amp;gt;GitGutterNextHunk&lt;/code&gt; and &lt;code&gt;&amp;lt;Plug&amp;gt;GitGutterPrevHunk&lt;/code&gt; to &lt;code&gt;]c&lt;/code&gt; and &lt;code&gt;[c&lt;/code&gt; respectively. However it will not create the mappings in the following scenarios:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Already have mapping to &lt;code&gt;&amp;lt;Plug&amp;gt;GitGutterNextHunk&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Already have a mapping to &lt;code&gt;]c&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Have &lt;code&gt;g:gitgutter_map_keys&lt;/code&gt; set to zero&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My best guess is that may have already mapped &lt;code&gt;]c&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wish to debug further then I would recommend using &lt;code&gt;:verbose&lt;/code&gt; to see what &lt;code&gt;]c&lt;/code&gt; is mapped to and where the mapping came from, e.g. &lt;code&gt;verbose nmap ]c&lt;/code&gt;. Or filtering you mappings via &lt;code&gt;:filter /GitGutter/ nmap&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-11-29T18:35:22.310" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14373" PostTypeId="1" CreationDate="2017-11-29T21:21:23.327" Score="2" ViewCount="77" Body="&lt;p&gt;Is it possible to &quot;preprocess&quot; the oldfiles list so that it's easier to navigate visually?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I can tell, the contents of the oldfiles list are presented as ordinary absolute paths, but with the user's home directory replaced with &lt;code&gt;~&lt;/code&gt;. This works well for most cases, but sometimes I'm navigating deep in a directory that's outside of my home directory and it's hard to read the file names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I'm editing files in &lt;code&gt;/tmp/some/deeply/nested/hierarchy&lt;/code&gt; and visit a bunch of files there, they show up as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: /tmp/some/deeply/nested/hierarchy/h&#xA;2: /tmp/some/deeply/nested/hierarchy/g&#xA;3: /tmp/some/deeply/nested/hierarchy/f&#xA;4: /tmp/some/deeply/nested/hierarchy/e&#xA;5: /tmp/some/deeply/nested/hierarchy/d&#xA;6: /tmp/some/deeply/nested/hierarchy/c&#xA;7: /tmp/some/deeply/nested/hierarchy/b&#xA;8: /tmp/some/deeply/nested/hierarchy/a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using a probably-way-longer-than-necessary perl script I can extract just the filename&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;perl -ne 'chomp; @w = split /\s+/; $b = &quot;&quot;; $w[-1] =~ m{/([^/]*)\z} and $b = $1; printf &quot;%s %s %s\n&quot;, $w[0], $b, &quot;@w[1..$#w]&quot;;'&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When run against the contents of oldfiles list it produces the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: h /tmp/some/deeply/nested/hierarchy/h&#xA;2: g /tmp/some/deeply/nested/hierarchy/g&#xA;3: f /tmp/some/deeply/nested/hierarchy/f&#xA;4: e /tmp/some/deeply/nested/hierarchy/e&#xA;5: d /tmp/some/deeply/nested/hierarchy/d&#xA;6: c /tmp/some/deeply/nested/hierarchy/c&#xA;7: b /tmp/some/deeply/nested/hierarchy/b&#xA;8: a /tmp/some/deeply/nested/hierarchy/a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can either use my script as a filter ... or define a filter in VimL to change how the oldfiles list is displayed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, ideally, just change some format string somewhere that vim uses.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-11-30T13:28:10.603" Title="Alter how oldfiles are displayed" Tags="|external-command|filesystem|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14374" PostTypeId="1" CreationDate="2017-11-29T21:46:12.783" Score="1" ViewCount="1277" Body="&lt;p&gt;I have added the following two lines into my .vimrc file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; stop fortran 90 from automatically insert line break beyond 80&#xA;set textwidth=0 wrapmargin=0&#xA;&#xA;&quot; stop vim wrapping beyond 80, avoid visual breaking in vim&#xA;set nowrap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but still no success. vim keeps breaking lines in my f90 source file as before, which is very annoying. Any further suggestions?&lt;/p&gt;&#xA;" OwnerUserId="15318" LastActivityDate="2020-02-13T13:47:47.110" Title="how to avoid vim breaking line beyond 80 characters in fortran files" Tags="|line-breaks|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14376" PostTypeId="2" ParentId="14374" CreationDate="2017-11-29T22:34:28.160" Score="7" Body="&lt;p&gt;&lt;code&gt;'textwidth'&lt;/code&gt; is local to the buffer. I imagine Vim's default fortran plugin (&lt;code&gt;$RUNTIME/ftplugin/fortran.vim&lt;/code&gt;) is setting &lt;code&gt;'textwidth'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To override this default add the following to &lt;code&gt;~/.vim/after/ftplugin/fortran.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal textwidth=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can set other fortran setting you wish to override here as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;:verbose&lt;/code&gt; to see where an option was last set. e.g. &lt;code&gt;:verbose set textwidth?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'textwidth'&#xA;:h after-directory&#xA;:h :setlocal&#xA;:h :verbose&#xA;:h :set&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-11-29T22:34:28.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14377" PostTypeId="1" AcceptedAnswerId="14382" CreationDate="2017-11-30T00:51:48.783" Score="2" ViewCount="355" Body="&lt;p&gt;I like the terminal in neovim. I am accustomed to tmux and tmux's copy-mode, and type &lt;code&gt;q&lt;/code&gt; to exit copy-mode to return back to regular-interactive-mode. Now, in neovim, when in NORMAL mode (which is akin to copy-mode in tmux), I end up typing &lt;code&gt;q&lt;/code&gt; hoping to get back to INSERT mode, only to realize nothing happening (as neovim dutifully prepares to start recording). I also use macro recording in vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there a way to normal-mode-map &lt;code&gt;q&lt;/code&gt; to &lt;code&gt;a&lt;/code&gt; only when its a terminal-buffer? And retain &lt;code&gt;q&lt;/code&gt; for its existing record-macro use in other buffers?&lt;/p&gt;&#xA;" OwnerUserId="15320" LastEditorUserId="1841" LastEditDate="2017-11-30T08:39:01.693" LastActivityDate="2019-04-01T04:19:52.390" Title="Neovim - Map selectively only on a terminal window" Tags="|neovim|terminal-buffer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14378" PostTypeId="1" CreationDate="2017-11-30T12:50:16.280" Score="1" ViewCount="763" Body="&lt;p&gt;Actually I'm using Python to make REST calls from inside Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible use only Vimscript to make REST calls?&lt;/p&gt;&#xA;" OwnerUserId="177" LastActivityDate="2018-10-01T03:04:01.920" Title="REST call using Vimscript" Tags="|vimscript|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14379" PostTypeId="1" AcceptedAnswerId="14381" CreationDate="2017-11-30T13:30:38.443" Score="7" ViewCount="3653" Body="&lt;p&gt;I am using zsh, urxvt, tmux and in there vim. I am not 100% sure who causes the effect but I would like to bind something to ctrl and m but not to carriage return in vim. Does somebody how this is done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much in advance!&lt;/p&gt;&#xA;" OwnerUserId="6816" LastEditorUserId="51" LastEditDate="2017-11-30T17:52:30.157" LastActivityDate="2017-11-30T17:52:30.157" Title="Separate C-m and Enter" Tags="|key-bindings|tmux|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14380" PostTypeId="2" ParentId="12867" CreationDate="2017-11-30T14:51:25.187" Score="7" Body="&lt;p&gt;There are already &lt;a href=&quot;https://vi.stackexchange.com/a/12871/343&quot;&gt;three&lt;/a&gt; &lt;a href=&quot;https://vi.stackexchange.com/a/12869/343&quot;&gt;great&lt;/a&gt; &lt;a href=&quot;https://vi.stackexchange.com/a/12868/343&quot;&gt;answers&lt;/a&gt; on this page, but, as &lt;a href=&quot;https://vi.stackexchange.com/questions/12867/how-to-replace-each-match-with-incrementing-counter#comment22139_12871&quot;&gt;Luc Hermitte suggested in a comment&lt;/a&gt;, if you're doing this off-the-cuff, the important thing is how quickly and easily you can alight upon a working solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such, this is a problem that I wouldn't actually use &lt;code&gt;:substitute&lt;/code&gt; for at all: it's one that can easily be solved using regular normal mode commands and a recursive macro:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;(If necessary)&lt;/em&gt; First, turn off &lt;code&gt;'wrapscan'&lt;/code&gt;. The regular expression we're going to use will match the desired result text as well as the initial text, so with &lt;code&gt;'wrapscan'&lt;/code&gt; on, the macro would otherwise continue playing back forever. (Or until you realise what's happening and press &lt;code&gt;&amp;lt;C-C&amp;gt;&lt;/code&gt;.):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nowrapscan&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Set up your search term (using the same base regular expression already mentioned in the existing answers):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/#\d\+\(\.\d\+\)\?&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;(If necessary)&lt;/em&gt; Jump back to the first match by pressing &lt;code&gt;N&lt;/code&gt; as many times as required,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;(If necessary)&lt;/em&gt; Change the first match into the desired text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cE#1&amp;lt;Esc&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Clear out the &lt;code&gt;&quot;q&lt;/code&gt; register and start recording a macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqqqq&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Yank the current counter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yiW&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Jump to the next match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Replace the current counter with the one we just yanked:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vEp&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Increment the counter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-A&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Play macro &lt;code&gt;q&lt;/code&gt;. Register &lt;code&gt;&quot;q&lt;/code&gt; is still empty because we cleared it in step 5, so nothing happens at this point:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@q&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Stop recording the macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Play the new macro, and watch!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@q&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As with all macros, this looks like a lot of steps when explained as I have done above, but note that actually typing these in is &lt;em&gt;very&lt;/em&gt; quick for me: apart from the recursive-macro-recording-boilerplate they're all just the regular editing commands I'm performing all the time during editing. The only step where I had to do anything even &lt;em&gt;approaching&lt;/em&gt; thinking was step 2, where I wrote the regular expression to perform the search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Formatted as two command-line mode commands and a series of keystrokes, the speed of this type of solution becomes more clear: I can conjure up the following pretty much as fast as I can type it&lt;sup&gt;1&lt;/sup&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nowrapscan&#xA;/#\d\+\(\.\d\+\)\?&#xA;cE#1&amp;lt;Esc&amp;gt;qqqqqyiWnvEp&amp;lt;C-A&amp;gt;@qq@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I probably could have come up with the other solutions on this page with a bit of thought and some referencing of the documentation&lt;sup&gt;2&lt;/sup&gt;, but, once you understand how macros work, they really are easy to churn out at whatever speed you usually edit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1: There &lt;em&gt;are&lt;/em&gt; situations where macros require more thought, but I find they don't come up much in practice. And generally the situations where they occur are ones where a macro is the &lt;em&gt;only&lt;/em&gt; practical solution.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;2: Not to imply that the other answerers couldn't have come up with their solutions similarly easily: they just require skills/knowledge that I personally don't have so easily at my fingertips. But &lt;em&gt;all&lt;/em&gt; Vim users know how to use regular editing commands!&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-30T16:41:11.783" LastActivityDate="2017-11-30T16:41:11.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14381" PostTypeId="2" ParentId="14379" CreationDate="2017-11-30T15:31:08.043" Score="13" Body="&lt;p&gt;As far as Vim is concerned, &lt;code&gt;&amp;lt;C-M&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/2bp9UdfZ63M/sajb9KM0pNYJ&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;are the same thing&lt;/em&gt;&lt;/a&gt;: they are represented in the same way internally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your terminal is truly sending different keycodes (mine doesn't) for when you press &lt;kbd&gt;Ctrl-M&lt;/kbd&gt; vs &lt;kbd&gt;Enter&lt;/kbd&gt;, then you might be able to map them separately by using their literal values when you set up the mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace the following in your &lt;code&gt;vimrc&lt;/code&gt;/Vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;CR&amp;gt; [keypresses]&#xA;nnoremap &amp;lt;C-M&amp;gt; [other keypresses]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the following,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap [actual ctrl-m keycode] [keypresses]&#xA;nnoremap [actual CR keycode] [other keypresses]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where you enter the keycodes by pressing &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Ctrl-M&lt;/kbd&gt; and &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;, respectively.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-11-30T15:31:08.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14382" PostTypeId="2" ParentId="14377" CreationDate="2017-11-30T16:34:08.087" Score="2" Body="&lt;p&gt;I imagine you can use a buffer-local mapping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; q a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All you need now is a way to apply it to only terminal buffers. Put the following in your &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyTermMappings&#xA;  autocmd!&#xA;  autocmd TermOpen * nnoremap &amp;lt;buffer&amp;gt; q a&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I do not use NeoVim so this is all guesswork.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-11-30T16:34:08.087" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14383" PostTypeId="2" ParentId="14367" CreationDate="2017-11-30T16:50:45.927" Score="4" Body="&lt;p&gt;I'm not 100% sure &lt;em&gt;how&lt;/em&gt; this is happening, but it's happening &lt;em&gt;because&lt;/em&gt; you are setting your &lt;code&gt;'cpoptions'&lt;/code&gt; incorrectly: when using &lt;code&gt;:set&lt;/code&gt; to set a string option, you should &lt;em&gt;not&lt;/em&gt; enclose the desired value in quotes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cpoptions=aABceFsd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As an aside, the documentation for &lt;code&gt;'cpoptions'&lt;/code&gt;recommends that if you just want to add the &lt;code&gt;d&lt;/code&gt; flag to the default value, you should use the &quot;+=&quot; feature of set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cpoptions+=d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-11-30T17:17:46.420" LastActivityDate="2017-11-30T17:17:46.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14384" PostTypeId="2" ParentId="14353" CreationDate="2017-11-30T22:09:23.480" Score="4" Body="&lt;p&gt;Read interprets the address &lt;code&gt;0&lt;/code&gt; to mean &quot;before the first line&quot;, which effectively puts its output on line 1. This works for me interactively in Vim 8:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:0read name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h {address}&lt;/code&gt; describes address &lt;code&gt;0&lt;/code&gt; and even uses &lt;code&gt;:read&lt;/code&gt; as an example :)&lt;/p&gt;&#xA;" OwnerUserId="14611" LastActivityDate="2017-11-30T22:09:23.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14385" PostTypeId="1" AcceptedAnswerId="14386" CreationDate="2017-12-01T07:29:11.060" Score="12" ViewCount="4522" Body="&lt;p&gt;I know &lt;code&gt;.&lt;/code&gt; operator concatenate strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how to repeat a string N times, similar to &lt;code&gt;&quot;abc&quot; * 3&lt;/code&gt; in python?&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2017-12-01T07:46:22.680" Title="vimscript: how to repeat a string N times?" Tags="|vimscript|string-manipulation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14386" PostTypeId="2" ParentId="14385" CreationDate="2017-12-01T07:46:22.680" Score="20" Body="&lt;p&gt;To repeat a string you want to use the (appropriately named) function &lt;code&gt;repeat()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The doc is here &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#repeat%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h repeat()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you can use it like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let foo = repeat(&quot;abc&quot;, 3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-12-01T07:46:22.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14390" PostTypeId="2" ParentId="2136" CreationDate="2017-12-02T13:30:44.593" Score="7" Body="&lt;p&gt;-0.1 make notes about vim in a file. Use it as reference and container.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;fast way to find vim help of &lt;code&gt;key | :cmd | 'option' | etc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h gi&lt;/code&gt; or &lt;code&gt;:h g;&lt;/code&gt; for &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt; or &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;;&lt;/kbd&gt; in normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h ^i&lt;/code&gt; for &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;i&lt;/kbd&gt; in normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h ^w^w&lt;/code&gt; for &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;w&lt;/kbd&gt; in normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h ^wf&lt;/code&gt; for &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; in normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h i^n&lt;/code&gt; for insert mode &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;n&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h c^r^r&lt;/code&gt; for cmdline mode &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;r&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;r&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :pu&lt;/code&gt; for ex-command &lt;code&gt;:put&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h 'cb'&lt;/code&gt; for option &lt;code&gt;clipboard&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h `&amp;gt;&lt;/code&gt; for mark &lt;code&gt;&amp;lt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h @:&lt;/code&gt; for option &lt;code&gt;repeat last ex command by eval register :&lt;/code&gt; (same mechanism as macro).&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;type &lt;code&gt;:h range&lt;/code&gt;, at this time you are in cmdline mode, then:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;type &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;a&lt;/kbd&gt; to complete all candidate that contain &lt;code&gt;range&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;type &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;f&lt;/kbd&gt; to popup a small edit window &lt;code&gt;[Command Line]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;&quot;*dd&lt;/code&gt; to cut it to system clipboard.&lt;/li&gt;&#xA;&lt;li&gt;type &lt;kbd&gt;o&lt;/kbd&gt; and &lt;kbd&gt;Enter&lt;/kbd&gt; to cancel and exit window &lt;code&gt;[Command Line]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;h :range range() &amp;lt;range&amp;gt; [range] :func-range ...&lt;/code&gt; is excerpt&lt;/li&gt;&#xA;&lt;li&gt;similarly, &lt;code&gt;h mode-Ex mode-replace mode-cmdline mode-switching ...&lt;/code&gt; is excerpt for &lt;code&gt;mode-&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;similar word that might be of interest: &lt;code&gt;buf&lt;/code&gt; &lt;code&gt;win&lt;/code&gt; &lt;code&gt;tab&lt;/code&gt; &lt;code&gt;line&lt;/code&gt;, etc.&lt;/li&gt;&#xA;&lt;li&gt;summary: this one shows a way to find interesting items given a keyword with help of &lt;code&gt;cmdline-completion&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;-0.2 define a buffer-local key-mapping to invoke vim help of word under cursor, when in previously mentioned vim notes file.&lt;br&gt;&#xA;(and possibly with post-processing after extract &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;, in a vimscript function)&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2017-12-02T13:30:44.593" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14391" PostTypeId="1" AcceptedAnswerId="14392" CreationDate="2017-12-03T01:35:52.050" Score="1" ViewCount="1020" Body="&lt;p&gt;Need a function that,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;returns a string, which is result of cmdline-completion Ctrl-a, i.e.,&#xA;a list of words seperated by space.&lt;/li&gt;&#xA;&lt;li&gt;given an input string of partial ex-command.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For example,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;given &lt;code&gt;:h bufwin&lt;/code&gt;, return &lt;code&gt;h bufwinid() bufwinnr() BufWinEnter BufWinLeave&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;given &lt;code&gt;:call getl&lt;/code&gt;, return &lt;code&gt;call getline( getloclist(&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;== further clarification ==&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h cmdline-completion&lt;/code&gt; has relevant info about &lt;code&gt;c^a&lt;/code&gt; and &lt;code&gt;c^f&lt;/code&gt;. (&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;a&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;f&lt;/kbd&gt; in cmdline-mode)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As said in &lt;a href=&quot;https://vi.stackexchange.com/a/14390/10254&quot;&gt;this answer about find vim-doc efficiently&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal-mode, type &lt;code&gt;:h bufwin&lt;/code&gt; then type &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;a&lt;/kbd&gt;, will show all completion candidates,&#xA;whereas type &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;f&lt;/kbd&gt; then &lt;kbd&gt;dd&lt;/kbd&gt; could manually get the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But here what I pursuit is an automated version wrapped in a vimscript function.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2017-12-03T21:04:24.517" Title="vimscript: get result of cmdline-completion Ctrl-a" Tags="|vimscript|functions|help-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14392" PostTypeId="2" ParentId="14391" CreationDate="2017-12-03T01:43:12.703" Score="4" Body="&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry, I misunderstood your question. I think you want the &lt;code&gt;getcompletion()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;given :h bufwin, return h bufwinid() bufwinnr() BufWinEnter BufWinLeave&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could get this with the following invocation of &lt;code&gt;getcompletion()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo getcompletion('*bufwin', 'help')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;given &lt;code&gt;:call getl&lt;/code&gt;, return &lt;code&gt;call getline( getloclist(&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And you could get this with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo getcompletion('getl', 'function')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The signature of the function is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getcompletion({pat}, {type} [, {filtered}])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It expects 2 mandatory arguments, and accepts 1 optional one.&#xA;The 1st argument is a pattern, which can include some metacharacters like &lt;code&gt;*&lt;/code&gt; (match any sequence of characters; see &lt;code&gt;:help wildcard&lt;/code&gt;). The 2nd argument is the type of completion in which you're interested. Currently, there are 33 possible types:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup         autocmd groups&#xA;buffer          buffer names&#xA;behave          :behave suboptions&#xA;color           color schemes&#xA;command         Ex command (and arguments)&#xA;compiler        compilers&#xA;cscope          |:cscope| suboptions&#xA;dir             directory names&#xA;environment     environment variable names&#xA;event           autocommand events&#xA;expression      Vim expression&#xA;file            file and directory names&#xA;file_in_path    file and directory names in |'path'|&#xA;filetype        filetype names |'filetype'|&#xA;function        function name&#xA;help            help subjects&#xA;highlight       highlight groups&#xA;history         :history suboptions&#xA;locale          locale names (as output of locale -a)&#xA;mapclear        buffer argument&#xA;mapping         mapping name&#xA;menu            menus&#xA;messages        |:messages| suboptions&#xA;option          options&#xA;packadd         optional package |pack-add| names&#xA;shellcmd        Shell command&#xA;sign            |:sign| suboptions&#xA;syntax          syntax file names |'syntax'|&#xA;syntime         |:syntime| suboptions&#xA;tag             tags&#xA;tag_listfiles   tags, file names&#xA;user            user names&#xA;var             user variables&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the 3rd optional argument is passed to the function, and is set to 1, the value of your &lt;code&gt;'wildignore'&lt;/code&gt; option is taken into consideration to eliminate some of the matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to capture the completion matches for several types simultaneously, you could try this custom function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:get_cmdline_candidates(pat, types) abort&#xA;    let lists = map(a:types, { i,v -&amp;gt; getcompletion(a:pat, v, 1)})&#xA;    let candidates = []&#xA;    for a_list in lists&#xA;        let candidates += a_list&#xA;    endfor&#xA;    return uniq(sort(candidates))&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usage example (in a script):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let myvar = s:get_cmdline_candidates('*win', ['command', 'function'])&#xA;echo myvar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should display all commands and functions containing the keyword &lt;code&gt;win&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But all matches are mixed in a single list. If this is an issue, you could try this function instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:get_cmdline_candidates(pat, types) abort&#xA;    let dicts = map(a:types, { i,v -&amp;gt; { v : getcompletion(a:pat, v, 1) }})&#xA;    call filter(dicts, {i,v -&amp;gt; !empty(v)})&#xA;    let candidates = {}&#xA;    for a_dict in dicts&#xA;        call extend(candidates, a_dict)&#xA;    endfor&#xA;    return candidates&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usage example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let myvar = s:get_cmdline_candidates('*win', ['command', 'function'])&#xA;echo myvar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This time, &lt;code&gt;myvar&lt;/code&gt; contains a dictionary with 2 keys, &lt;code&gt;'command'&lt;/code&gt; and &lt;code&gt;'function'&lt;/code&gt;, whose values are the associated completion matches for the pattern &lt;code&gt;*win&lt;/code&gt;. You can access the commands with &lt;code&gt;myvar.command&lt;/code&gt;, and the functions with &lt;code&gt;myvar.function&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How to silently ignore failed calls of &lt;code&gt;getcompletion()&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you think an error may occur, you could use a &lt;code&gt;try&lt;/code&gt; conditional to catch and ignore it. Example &lt;code&gt;1&lt;/code&gt; (the output will be a list):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:get_cmdline_candidates(pat, types) abort&#xA;    let candidates = []&#xA;    for a_type in a:types&#xA;        try&#xA;            let candidates += getcompletion(a:pat, a_type, 1)&#xA;        catch&#xA;        endtry&#xA;    endfor&#xA;    return uniq(sort(candidates))&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example &lt;code&gt;2&lt;/code&gt; (the output will be a dictionary):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:get_cmdline_candidates(pat, types) abort&#xA;    let candidates = {}&#xA;    for a_type in a:types&#xA;        try&#xA;            call extend(candidates, { a_type: getcompletion(a:pat, a_type, 1)})&#xA;        catch&#xA;        endtry&#xA;    endfor&#xA;    return candidates&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that you need a Vim version more recent than &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v7.4.2011&quot; rel=&quot;nofollow noreferrer&quot;&gt;7.4.2011&lt;/a&gt;, since it's the patch where &lt;code&gt;getcompletion()&lt;/code&gt; was added in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see &lt;code&gt;:help getcompletion()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Old answer&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came up with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cno &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-d&amp;gt; '&amp;lt;c-a&amp;gt;'.&amp;lt;sid&amp;gt;capture_cmdline_candidates()&#xA;&#xA;fu! s:capture_cmdline_candidates() abort&#xA;    call timer_start(0, {-&amp;gt; setreg('&quot;', getcmdline(), 'l')&#xA;    \                     + feedkeys(&quot;\&amp;lt;c-c&amp;gt;&quot;, 'int') })&#xA;    return ''&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It installs a mapping using the key sequence &lt;code&gt;C-x C-d&lt;/code&gt;, but you could change it for whatever else you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you press it, the &lt;code&gt;s:capture_cmdline_candidates()&lt;/code&gt; function should populate the unnamed register (&lt;code&gt;@&quot;&lt;/code&gt;) with all the candidates which would have been written on the command line if you had pressed &lt;code&gt;C-a&lt;/code&gt;. It also makes you directly quit the command line, so that you can put the contents of the unnamed register in the buffer you want, by pressing &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Actually, you could eliminate the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cno &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-d&amp;gt; '&amp;lt;c-a&amp;gt;'.timer_start(0, {-&amp;gt; setreg('&quot;', getcmdline(), 'l') + feedkeys('&amp;lt;c-c&amp;gt;', 'int') })[-1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could also try this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cno &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-d&amp;gt; '&amp;lt;c-a&amp;gt;'.&amp;amp;cedit.'dd:q&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I tested it, the brief appearance of the command line window was a little distracting, because its name was displayed in the tabline.&lt;/p&gt;&#xA;" OwnerUserId="13370" LastEditorUserId="13370" LastEditDate="2017-12-03T21:04:24.517" LastActivityDate="2017-12-03T21:04:24.517" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14393" PostTypeId="2" ParentId="678" CreationDate="2017-12-03T01:47:23.023" Score="2" Body="&lt;p&gt;I hope to contribute a version that builds on the above answers to streamline the workflow just that much more. I'm often creating new files within a wide range of project structures. This tweak will save me a solid amount of time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two &lt;em&gt;dependencies&lt;/em&gt; that I can think of:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I set &lt;code&gt;autochdir&lt;/code&gt; because of how it works with &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; for my import statements.  &lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;saveas&lt;/code&gt; &quot;leaves behind&quot; (if you will) a hidden buffer at the &lt;em&gt;end&lt;/em&gt; of the buffer list. I'm not sure if that is state behavior that all vim/nvim instances enjoy. &lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Other FYI: I use NVIM on a Mac OS&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Auto magically Mkdir&#xA;&quot; ====================&#xA;&#xA;autocmd BufWritePre * call MkDir()&#xA;&#xA;function! MkDir()&#xA;   if !isdirectory(expand(&quot;&amp;lt;afile&amp;gt;:p:h&quot;))&#xA;      let confirmation=confirm(&quot;Create a new directory?&quot;, &quot;&amp;amp;Yes\n&amp;amp;No&quot;)&#xA;      if confirmation == 1&#xA;         call mkdir(expand(&quot;&amp;lt;afile&amp;gt;:p:h&quot;), &quot;p&quot;)&#xA;         lcd %:p:h&#xA;         saveas %:t&#xA;         echom &quot;Created a new directory:&quot; expand(&quot;&amp;lt;afile&amp;gt;:p:h&quot;)&#xA;         let buf_del = bufnr(&quot;$&quot;)&#xA;         exe &quot;bd&quot; . buf_del&#xA;      endif&#xA;      redraw&#xA;   endif&#xA;endfunction&#xA;&#xA;&quot; Conditionaly create the parent directory when writing to disk&#xA;&quot; &amp;lt;afile&amp;gt; refers to the file we are saving&#xA;&quot; :p is a modifier that expands to full filename&#xA;&quot; :h is a modifier that removes the file from full filename&#xA;&quot; :t is a modifier that generates the filename with extension&#xA;&quot; &quot;p&quot; is the flag that will create all the parent directories&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="15391" LastActivityDate="2017-12-03T01:47:23.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14394" PostTypeId="1" AcceptedAnswerId="14396" CreationDate="2017-12-03T04:16:31.093" Score="4" ViewCount="95" Body="&lt;p&gt;Is there any way to bind &lt;code&gt;cI&amp;lt;char&amp;gt;&lt;/code&gt; to forward to next  ocurrence and change inside &lt;code&gt;&amp;lt;char&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[p]rint(arg)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;, pressing &lt;code&gt;cI(&lt;/code&gt; would result in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print(|)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;, &lt;code&gt;[]&lt;/code&gt; represents cursor in normal mode and &lt;code&gt;|&lt;/code&gt; represents cursor in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in summary, &lt;code&gt;cI(&lt;/code&gt; would represent a shortcut to a key sequence like this &lt;code&gt;f(ci(&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15393" LastEditorUserId="15393" LastEditDate="2017-12-03T04:38:12.030" LastActivityDate="2017-12-04T10:32:13.963" Title="Forward to char and change inside the same char" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14396" PostTypeId="2" ParentId="14394" CreationDate="2017-12-03T06:39:24.687" Score="5" Body="&lt;p&gt;How about &lt;code&gt;cI&amp;lt;char&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LHS of a mapping is a static string. You can't have a &quot;dynamic&quot; mapping with, say, a placeholder character that gets replaced with whatever character the user types. I suppose you could brute-force it and enter mappings for all the relevant chars: &lt;code&gt;cIw&lt;/code&gt;, &lt;code&gt;cIW&lt;/code&gt;, &lt;code&gt;cI(&lt;/code&gt;, etc. I'm guessing you're hoping for something better than that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can think of one way to get close to what you want. Create a function and mapping like these (you can put them in your &lt;em&gt;vimrc&lt;/em&gt; file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ChangeInsideChar()&#xA;    let l:char = input(&quot;Enter a character: &quot;)&#xA;    exec 'normal! f' . l:char . 'di' . l:char&#xA;    startinsert&#xA;endfunction&#xA;&#xA;nnoremap cI :call ChangeInsideChar()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you hit &lt;code&gt;cI&lt;/code&gt; in Normal mode a prompt will appear. Enter the appropriate character then hit &lt;kbd&gt;Enter&lt;/kbd&gt; and the magic will happen. Using your example, if at the prompt you entered &lt;kbd&gt;(&lt;/kbd&gt; and &lt;kbd&gt;Enter&lt;/kbd&gt; that will  delete the text inside the next set of parens and leave you in Insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can enter these sequences pretty quickly so in effect this solution is like just adding one extra key press to your hoped for binding. Heck, I've already thought of a few ideas for using this general technique myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Thanks to a pointer from &lt;a href=&quot;https://vi.stackexchange.com/users/343/rich&quot;&gt;Rich&lt;/a&gt;, &lt;a href=&quot;https://vi.stackexchange.com/questions/14394/forward-to-char-and-change-inside-the-same-char/14396#comment24730_14396&quot;&gt;here&lt;/a&gt;, we can &lt;em&gt;eliminate &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/em&gt; because Vim has a single char fetch function. Here's the new and improved function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ChangeInsideChar()&#xA;    echomsg 'Enter a character '&#xA;    let l:mychar = nr2char(getchar())&#xA;    exec 'normal! f' . l:mychar . 'di' . l:mychar&#xA;    startinsert&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-12-04T10:32:13.963" LastActivityDate="2017-12-04T10:32:13.963" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14397" PostTypeId="2" ParentId="14391" CreationDate="2017-12-03T12:59:10.407" Score="2" Body="&lt;p&gt;Nowadays we have no reason to play with &lt;code&gt;c_CTRL-A&lt;/code&gt; as we have &lt;code&gt;getcompletion()&lt;/code&gt;. See @user852573's answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the past, however, we had to &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;create a dummy command with the completion mode we're interested into&lt;/li&gt;&#xA;&lt;li&gt;inject that command and the leading parameter in the command line&lt;/li&gt;&#xA;&lt;li&gt;ask to see all the possible completions (with &lt;code&gt;c_CTRL-A&lt;/code&gt;), &lt;/li&gt;&#xA;&lt;li&gt;surround the new command-line with &lt;code&gt;let g:whatever=&quot;&lt;/code&gt; and &lt;code&gt;&quot;&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;and finally execute.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then the &lt;code&gt;whatever&lt;/code&gt; global variable would contain the name of the dummy command and all possible completions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There were a few caveats: double-quotes could mess the result. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix that, we could then use &lt;code&gt;getcmdline()&lt;/code&gt;. Alas to use it in the flow we had to inject a new cmapping that could add noise when the objective is to find mapppings -- I had the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result is in my &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/command.vim#L133&quot; rel=&quot;nofollow noreferrer&quot;&gt;library plugin&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Function: lh#command#matching_askvim(what, lead) {{{3&#xA;if exists('*getcompletion')&#xA;  function! lh#command#matching_askvim(what, lead) abort&#xA;    return getcompletion(a:lead, a:what)&#xA;  endfunction&#xA;else&#xA;  function! lh#command#matching_askvim(what, lead) abort&#xA;    let cleanup = lh#on#exit()&#xA;          \.register('delcom LHAskVimMatchingCompletion')&#xA;    try&#xA;      exe 'command! -complete='.a:what.' -nargs=* LHAskVimMatchingCompletion :echo &quot;&amp;lt;args&amp;gt;&quot;'&#xA;      if exists('*getcmdline')&#xA;        call cleanup&#xA;              \.restore('g:cmds')&#xA;              \.restore_buffer_mapping('µ', 'c')&#xA;              \.restore_mapping_and_clear_now('&amp;lt;c-a&amp;gt;', 'c')&#xA;        cnoremap &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; µ s:register()&#xA;        function! s:register()&#xA;          let g:cmds = split(getcmdline(), ' ')[1:]&#xA;          return ''&#xA;        endfunction&#xA;        silent! exe &quot;norm :LHAskVimMatchingCompletion &quot;.a:lead.&quot;\&amp;lt;c-a&amp;gt;µ&quot;&#xA;        return g:cmds&#xA;      else&#xA;        &quot; The following may lead to problem with unescaped quotes =&amp;gt; use&#xA;        &quot; getcmdline() when available&#xA;        silent! exe &quot;norm! :LHAskVimMatchingCompletion &quot;.a:lead.&quot;\&amp;lt;c-a&amp;gt;\&quot;\&amp;lt;home&amp;gt;let\ cmds=\&quot;\&amp;lt;cr&amp;gt;&quot;&#xA;        return split(cmds, ' ')[1:]&#xA;      endif&#xA;    finally&#xA;      call cleanup.finalize()&#xA;    endtry&#xA;  endfunction&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-12-03T13:08:51.257" LastActivityDate="2017-12-03T13:08:51.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14398" PostTypeId="1" CreationDate="2017-12-03T17:34:48.940" Score="2" ViewCount="90" Body="&lt;p&gt;I'm using a &lt;code&gt;CursorMoved&lt;/code&gt; autocommand with &lt;code&gt;searchpos&lt;/code&gt; to &lt;a href=&quot;https://github.com/andymass/vim-matchup&quot; rel=&quot;nofollow noreferrer&quot;&gt;do highlighting of special words&lt;/a&gt;.  I've been using &lt;code&gt;set cpo-=c&lt;/code&gt; to handle possible overlapping matches, and I restore it afterwards.  This &lt;code&gt;set&lt;/code&gt; seems to be causing a lot of cursor lag when scrolling with &lt;code&gt;hjkl&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I don't understand where the lag is coming from.  I wrapped the &lt;code&gt;set&lt;/code&gt; in a &lt;code&gt;reltime&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a = reltime()&#xA;noautocmd set cpo-=c&#xA;let g:foo = reltimestr(reltime(a))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I inspect &lt;code&gt;g:foo&lt;/code&gt; and it's 0.000025; much, much too low to be causing any sort of lag.  In fact, my entire &lt;code&gt;CursorMoved&lt;/code&gt; autocommand takes no more than 10 milliseconds.  Replacing the &lt;code&gt;set&lt;/code&gt; with a &lt;code&gt;sleep 10m&lt;/code&gt; removes the &quot;lag&quot; entirely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another odd thing is the lag happens when using vim over SSH, but not locally.  So, why does &lt;code&gt;set cpo-=c&lt;/code&gt; appear slow, but is not actually empirically slow?&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-12-03T17:34:48.940" Title="why does cpo-=c cause perceptual &quot;lag?&quot;" Tags="|search|set|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14399" PostTypeId="1" AcceptedAnswerId="14400" CreationDate="2017-12-03T22:00:21.187" Score="2" ViewCount="1389" Body="&lt;p&gt;If you use of &lt;code&gt;softtabstop&lt;/code&gt; and &lt;code&gt;expandtab&lt;/code&gt; options in vary ways and try to test them, these options are opposite in function (at least as I think).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;et&lt;/code&gt; option will produce the appropriate number of space when we press TAB key and when we press BS the spaces will delete one by one in the other hand when we set &lt;code&gt;sts&lt;/code&gt; and press BS it will delete a tab (not spaces one by one).&#xA;Thus setting &lt;code&gt;et&lt;/code&gt; and &lt;code&gt;sts&lt;/code&gt; option in vimrc together isn't a good idea because they will break their effect together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now am I thinking right? (If not please let me know how they are differ in function and behaviour.)&lt;/p&gt;&#xA;" OwnerUserId="15007" LastEditorUserId="51" LastEditDate="2018-07-09T15:11:11.030" LastActivityDate="2018-07-09T15:11:11.030" Title="Differ between 'softtabstop' and 'expandtab' options in function" Tags="|vimrc|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14400" PostTypeId="2" ParentId="14399" CreationDate="2017-12-03T22:09:38.793" Score="6" Body="&lt;p&gt;No. &lt;code&gt;sts&lt;/code&gt; and &lt;code&gt;et&lt;/code&gt; options have distinct functions and are not mutually exclusive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;softtabstop&lt;/code&gt; and &lt;code&gt;noexpandtab&lt;/code&gt;, vim will insert a &lt;em&gt;mixture of tabs and spaces&lt;/em&gt;, to make it up to the &lt;code&gt;sts&lt;/code&gt; value.  How many tabs are inserted depends on &lt;code&gt;tabstop&lt;/code&gt;, for example &lt;code&gt;ts=3&lt;/code&gt;, &lt;code&gt;sts=4&lt;/code&gt;, vim will insert one tab and one space, for a total of 4 spaces-equivalent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;softtabstop&lt;/code&gt; and &lt;code&gt;expandtab&lt;/code&gt;, vim will insert the &lt;code&gt;sts&lt;/code&gt; number of spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In both cases, backspacing still works as though you had inserted a tab which is &lt;code&gt;sts&lt;/code&gt; wide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim's behavior and number of indent-related options is perhaps surprising, but this is not merely an &quot;academic&quot; discussion.  For a real example, see the vim source code, which uses indents of four spaces-equivalent but &lt;code&gt;tabstop=8&lt;/code&gt;.  So, lines indented once get four spaces in front, lines indented twice get a tab, and lines indented thrice get a tab then four spaces.  In this case, one &lt;em&gt;might&lt;/em&gt; prefer &lt;code&gt;set sts=4 sw=4 ts=8&lt;/code&gt;.  When pressing &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; twice, vim will insert a real tab instead of spaces.  Note also this answer does not discuss interaction with the &lt;code&gt;shiftwidth&lt;/code&gt; or &lt;code&gt;smarttab&lt;/code&gt; options.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-12-03T22:32:22.707" LastActivityDate="2017-12-03T22:32:22.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14401" PostTypeId="1" AcceptedAnswerId="14402" CreationDate="2017-12-03T23:34:03.677" Score="2" ViewCount="490" Body="&lt;p&gt;I have a permanent window for file explorer enabled by &lt;code&gt;netrw_altv=1&lt;/code&gt; option. The problem is that when I run vim with file or directory as an argument the window with file explorer is focused. How can I use &lt;code&gt;autocmd&lt;/code&gt; on &lt;code&gt;VimEnter&lt;/code&gt; to automatically focus on the window with the file content (the window on the right) if file is passed as an argument with vim and leave vim focused on the windows with the file explorer (the window on the right) if directory is passed as an argument with vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mean, when calling vim like that:&lt;br&gt;&#xA;&lt;code&gt;vim ~/.&lt;/code&gt;&lt;br&gt;&#xA;then:  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This window____|&lt;br&gt;&#xA;  should be______|&lt;br&gt;&#xA;  focused _______|&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And when calling vim with a file as an argument:&lt;br&gt;&#xA;&lt;code&gt;vim src/main.c&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;_______________| This  window&lt;br&gt;&#xA;  _______________| should be&lt;br&gt;&#xA;  _______________| focused  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="15408" LastActivityDate="2018-01-03T09:13:06.687" Title="Focus on file when when opening when permanent window for file explorer is enabled" Tags="|autocmd|netrw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14402" PostTypeId="2" ParentId="14401" CreationDate="2017-12-04T08:49:23.853" Score="2" Body="&lt;p&gt;You could try to add this autocommand to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * if (argc() &amp;gt; 0 &amp;amp;&amp;amp; filereadable(argv()[0])) | wincmd l | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to check if you provided some arguments on the command line (see &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#argc%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h argc()&lt;/code&gt;&lt;/a&gt;) and if the first argument is an actual file (see &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#filereadable%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h filereadable()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#argv%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h argv()&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that is the case then we use &lt;code&gt;wincmd&lt;/code&gt; to change to the left split (see &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3awincmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :wincmd&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-12-04T08:49:23.853" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14403" PostTypeId="1" AcceptedAnswerId="14412" CreationDate="2017-12-04T09:03:43.000" Score="32" ViewCount="28362" Body="&lt;p&gt;I am trying to write a Vim function which should make the window go to the previous open buffer.&lt;/p&gt;&#xA;&lt;p&gt;How can I do it from the command line? My first idea was to find out some &lt;kbd&gt;Ctrl-O&lt;/kbd&gt; command line alternative.&lt;/p&gt;&#xA;" OwnerUserId="11971" LastEditorUserId="4866" LastEditDate="2023-11-30T11:55:44.423" LastActivityDate="2023-11-30T12:42:12.447" Title="How to go to previous open buffer from Vim command line?" Tags="|command-line|buffers|" AnswerCount="8" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="14404" PostTypeId="2" ParentId="14403" CreationDate="2017-12-04T09:21:28.850" Score="0" Body="&lt;p&gt;I found the solution in use of &lt;code&gt;normal&lt;/code&gt; command. There would be such a line in my function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe &quot;normal \&amp;lt;C-O&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11971" LastActivityDate="2017-12-04T09:21:28.850" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14405" PostTypeId="1" AcceptedAnswerId="14407" CreationDate="2017-12-04T11:20:09.667" Score="5" ViewCount="8491" Body="&lt;p&gt;I need to define &lt;code&gt;LocalLeader&lt;/code&gt; for various plugins and I would like to set it to &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;. If I add this to my &lt;code&gt;vimrc&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let maplocalleader = &quot;&amp;lt;Space&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;typing space in normal mode just moves the cursor by one position (i.e. my command had no effect). Setting the &lt;code&gt;LocalLeader&lt;/code&gt; to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let maplocalleader = &quot;\\&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;allows mappings to work properly when prefixed by &lt;code&gt;\&lt;/code&gt;. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="15416" LastActivityDate="2019-03-06T11:05:27.760" Title="How do I define LocalLeader as &lt;Space&gt;?" Tags="|vimrc|leader|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14406" PostTypeId="1" CreationDate="2017-12-04T11:23:39.680" Score="1" ViewCount="1202" Body="&lt;p&gt;I'd like to change the appearance of my cursor to something similar to this picture:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/knvQd.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/knvQd.jpg&quot; alt=&quot;image showing a cursor with a yellow underscore and a block background differing from the editor background&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I have &lt;code&gt;_&lt;/code&gt; in the cursor, and how do I change the color of the cursor?&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="21251" LastEditDate="2021-07-05T21:12:12.780" LastActivityDate="2021-07-05T21:12:12.780" Title="Tweaking the cursor in gVim" Tags="|gvim|cursor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="14407" PostTypeId="2" ParentId="14405" CreationDate="2017-12-04T11:39:11.393" Score="10" Body="&lt;p&gt;You should use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let maplocalleader=&quot;\&amp;lt;space&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the mapping is the same for the reguler leader &lt;code&gt;let mapleader=&quot;\&amp;lt;Space&amp;gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-12-04T11:39:11.393" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14408" PostTypeId="1" AcceptedAnswerId="14410" CreationDate="2017-12-04T12:15:49.620" Score="10" ViewCount="4212" Body="&lt;p&gt;Is there any way to set options typed on multiple lines with a single &lt;code&gt;:set&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a part of my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;se nu&#xA;se sm&#xA;se hls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And as you see, I have &lt;code&gt;se&lt;/code&gt; on every line in which I set an option. I know that I can set the all options in one line with a single &lt;code&gt;se&lt;/code&gt; but How can I set them with one &lt;code&gt;se&lt;/code&gt; but with the options themselves specified on multiple lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. I'd like to write something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;se nu,&#xA;sm,&#xA;hls,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15007" LastEditorUserId="343" LastEditDate="2017-12-04T14:41:37.167" LastActivityDate="2020-11-24T21:16:26.110" Title="Can I set multiple 'options' with a single `:set` command spread over multiple lines?" Tags="|vimrc|options|set|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14410" PostTypeId="2" ParentId="14408" CreationDate="2017-12-04T14:30:57.847" Score="11" Body="&lt;p&gt;I'd personally recommend against doing so, but you can use Vim's &amp;quot;line continuation&amp;quot; feature for this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set number&#xA;\ showmatch&#xA;\ hlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will be interpreted by Vim as if the contents of the lines after the backslashes were written at the end of the previous line:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set number showmatch hlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that whitespace &lt;em&gt;before&lt;/em&gt; the backslash is ignored:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set number&#xA;  \ showmatch&#xA;  \ hlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;code&gt;:help line-continuation&lt;/code&gt; for more details.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;ino&lt;/code&gt; and &lt;code&gt;cnorea&lt;/code&gt; are the short forms of the &lt;code&gt;inoremap&lt;/code&gt; and &lt;code&gt;cnoreabbrev&lt;/code&gt; commands. It is not possible to merge multiple map/abbreviation commands into a single command in this way: this only works with &lt;code&gt;:set&lt;/code&gt; because that command already allows you to set multiple options with a single command.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-11-24T21:16:26.110" LastActivityDate="2020-11-24T21:16:26.110" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="14412" PostTypeId="2" ParentId="14403" CreationDate="2017-12-04T15:19:52.570" Score="48" Body="&lt;p&gt;The jumplist is not the best way to do buffer navigation. Vim has a great number of buffer navigation tools which are probably better used for this task.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-^&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;c-6&amp;gt;&lt;/code&gt; - jump to the alternative file or if providing a count to a certain buffer number. See &lt;code&gt;:h CTRL-6&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:b&lt;/code&gt; - jump to a specific buffer. Takes buffer number or partial filename. See &lt;code&gt;:h :b&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:sb&lt;/code&gt; - split variant of &lt;code&gt;:b&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:ls&lt;/code&gt;/&lt;code&gt;:buffers&lt;/code&gt; - list opened buffers. See &lt;code&gt;:h :ls&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;#&lt;/code&gt; used to represent the alternative file which is often the previous buffer. e.g. &lt;code&gt;:b#&lt;/code&gt;. See &lt;code&gt;:h c_#&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Common mapping &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :ls&amp;lt;cr&amp;gt;:b&amp;lt;space&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you really do want to use the jump list you may want to look at Ingo Karkat's &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2695&quot; rel=&quot;noreferrer&quot;&gt;EnhancedJumps&lt;/a&gt; plugin or see &lt;a href=&quot;https://github.com/dhruvasagar/vim-buffer-history&quot; rel=&quot;noreferrer&quot;&gt;vim-buffer-history&lt;/a&gt; plugin which is sort of similar.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-12-04T19:12:41.840" LastActivityDate="2017-12-04T19:12:41.840" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14414" PostTypeId="1" AcceptedAnswerId="14415" CreationDate="2017-12-04T21:23:27.953" Score="3" ViewCount="283" Body="&lt;p&gt;I use YouCompleteMe for python3 code completion, and when I have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_python_binary_path = '/usr/bin/python3'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;~/.vimrc&lt;/code&gt; it works great. However, if I change it to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let python3path = system('/usr/bin/which python3')&#xA;let g:ycm_python_binary_path = python3path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It stops working. In both cases after vim startup the &lt;code&gt;:echo g:ycm_python_binary_path&lt;/code&gt; shows &lt;code&gt;/usr/bin/python3&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="15145" LastEditorUserId="15145" LastEditDate="2017-12-05T07:25:19.220" LastActivityDate="2017-12-05T07:25:19.220" Title="Why python autocompletion does not work if path to python binary is taken from variable?" Tags="|external-command|plugin-you-complete-me|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14415" PostTypeId="2" ParentId="14414" CreationDate="2017-12-04T21:50:53.837" Score="3" Body="&lt;p&gt;Almost all Unix commandline programs end their output with a trailing newline, and Vim's &lt;code&gt;system()&lt;/code&gt; doesn't remove this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be a difficult to spot with a regular &lt;code&gt;:echo&lt;/code&gt;; the easiest way to check this from Vim is by piping the output to &lt;code&gt;hexdump&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo system('/usr/bin/which python3 | hexdump -C')&#xA;00000000  2f 75 73 72 2f 62 69 6e  2f 70 79 74 68 6f 6e 33  |/usr/bin/python3|&#xA;00000010  0a                                                |.|&#xA;00000011&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last character (&lt;code&gt;0a&lt;/code&gt;) is a newline (&quot;\n&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no straight-forward way to dump the hex output of a Vim string like with &lt;code&gt;hexdump&lt;/code&gt;; so if you want to check the value of a string then the easiest way is to output with a prefix and suffix; for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let python3path = system('/usr/bin/which python3')&#xA;:echo 'X' . python3path . 'X'&#xA;X/usr/bin/python3&#xA;X&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice how that second &lt;code&gt;X&lt;/code&gt; is on a new line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use something like this to remove the newline &lt;code&gt;python3path&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let python3path = system('/usr/bin/which python3')[:-2]&#xA;:echo 'X' . python3path . 'X'&#xA;X/usr/bin/python3X&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which removes the last character (the &lt;code&gt;\n&lt;/code&gt;) from the string that &lt;code&gt;system()&lt;/code&gt; returns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you could &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#substitute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;substitute()&lt;/code&gt;&lt;/a&gt; it, which is guaranteed to work for strings that don't end with a &lt;code&gt;\n&lt;/code&gt; at a (very) slight performance/readability cost:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let python3path = substitute(system('/usr/bin/which python3'), &quot;\n$&quot;, &quot;&quot;, 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-12-05T07:09:51.887" LastActivityDate="2017-12-05T07:09:51.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14416" PostTypeId="1" CreationDate="2017-12-05T05:12:54.060" Score="5" ViewCount="701" Body="&lt;p&gt;&lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; both, by default, drop you in the first non-whitespace column of the given row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This behavior is kind of distracting when quickly scanning through pages. Is there a way to get way to configure vim to keep the cursor in the same column when scrolling by pages. I have &lt;code&gt;virtualedit&lt;/code&gt; enabled, so not-moving the cursor is always possible, even if &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; moves focus to an empty line.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-12-05T07:31:53.233" Title="keep same column when navigating by pages?" Tags="|scrolling|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14417" PostTypeId="2" ParentId="14416" CreationDate="2017-12-05T07:31:18.130" Score="5" Body="&lt;p&gt;The relevant option is &lt;code&gt;startofline&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set nostartofline&lt;/code&gt; will prevent vim from moving to just after leading indentation after performing a motion like &lt;code&gt;c-u&lt;/code&gt;, &lt;code&gt;c-d&lt;/code&gt;, &lt;code&gt;gg&lt;/code&gt;, &lt;code&gt;G&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can confirm that it interacts in the expected way (not moving the column) when &lt;code&gt;virtualedit&lt;/code&gt; is enabled.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-12-05T07:31:18.130" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14418" PostTypeId="2" ParentId="14416" CreationDate="2017-12-05T07:31:53.233" Score="9" Body="&lt;p&gt;In addition to setting &lt;code&gt;virtualedit=all&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nostartofline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-12-05T07:31:53.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14419" PostTypeId="1" AcceptedAnswerId="14420" CreationDate="2017-12-05T08:36:10.690" Score="1" ViewCount="199" Body="&lt;p&gt;Using &lt;code&gt;gt&lt;/code&gt; and &lt;code&gt;:tabnext&lt;/code&gt; I need to wait some time and I experience the same lag when I use &lt;code&gt;:split myfile.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However &lt;code&gt;vim myfile.txt&lt;/code&gt; from bash opens much faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Mac is pretty fast, and I don't have too many plugins installed. I use Vim 8 installed with Brew.&lt;/p&gt;&#xA;" OwnerUserId="6038" LastEditorUserId="1841" LastEditDate="2017-12-05T08:40:16.727" LastActivityDate="2017-12-05T09:58:28.147" Title="Switching between tabs takes a few seconds" Tags="|tabbed-user-interface|performance|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14420" PostTypeId="2" ParentId="14419" CreationDate="2017-12-05T08:49:08.387" Score="1" Body="&lt;p&gt;I started Vim without my vimrc and plugins using&lt;br&gt;&#xA;&lt;code&gt;HOME=/dev/null vim -u NONE myfile.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Works fast. So I need to investigate the plugins and my configuration...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: bottleneck was in plugin &lt;a href=&quot;https://github.com/ternjs/tern_for_vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;tern_for_vim&lt;/a&gt;, I filled the &lt;a href=&quot;https://github.com/ternjs/tern_for_vim/issues/189&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6038" LastEditorUserId="6038" LastEditDate="2017-12-05T09:58:28.147" LastActivityDate="2017-12-05T09:58:28.147" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14421" PostTypeId="1" AcceptedAnswerId="14422" CreationDate="2017-12-05T10:52:54.667" Score="3" ViewCount="422" Body="&lt;p&gt;Some of the files I am editing have a huge amount of whitespace leading before each line, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;module Something&#xA;  module Inside&#xA;    class FinallyClass&#xA;      def each_method_adds_indentation_as_well&#xA;        # actual code&#xA;        # ..&#xA;        # ..&#xA;      end&#xA;    end&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And sometimes even more indentation happens before it actually gets into the code part which I work on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to condense one, or two levels of indentation somehow through a plugin or a setting? (while maintaining the file contents intact)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that above would become&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;module Something&#xA;module Inside # (hidden indent level 1)&#xA;class FinallyClass # (hidden indent level 2)&#xA;  def each_method_adds_indentation_as_well&#xA;    # actual code&#xA;    # ..&#xA;    # ..&#xA;  end&#xA;end # (hidden indent level 2)&#xA;end # (hidden indent level 1)&#xA;end &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12905" LastEditorUserId="51" LastEditDate="2017-12-06T10:03:19.750" LastActivityDate="2018-05-21T04:43:07.663" Title="Is there a way to hide leading whitespace?" Tags="|indentation|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14422" PostTypeId="2" ParentId="14421" CreationDate="2017-12-05T11:29:23.987" Score="6" Body="&lt;p&gt;You can achieve this with Vim's &lt;code&gt;conceal&lt;/code&gt; feature:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Hide one or two two-space indents&#xA;syntax match HideTwoIndents /\v^  (  )?/ conceal&#xA;&#xA;&quot; (Optional) Hide regardless of cursor position&#xA;set concealcursor=nvic&#xA;&#xA;&quot; Hide concealed matches without replacement chars completely&#xA;set conceallevel=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This tells Vim to hide the first (and second, if that exists) level of indentation using a regular expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is something you want to use a lot (and not just a quick fix for a particular set of files) then you'll want to improve it to build the regular expression using your current &lt;code&gt;'shiftwidth'&lt;/code&gt; value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of &lt;a href=&quot;https://vi.stackexchange.com/questions/14425/why-are-concealed-tabs-displayed-wider-than-a-single-tabstop&quot;&gt;some odd behaviour with the way Vim displays concealed tabs&lt;/a&gt;, you'll need something slightly more complicated for tab indents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match HideOneIndent /\v^\t\ze[^\t]/ conceal&#xA;syntax match HideTwoIndents /\v^\t*\zs\t\t\ze[^\t]/ conceal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Further Reading&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help conceal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'conceallevel'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'concealcursor'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-12-06T09:38:13.937" LastActivityDate="2017-12-06T09:38:13.937" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14423" PostTypeId="1" AcceptedAnswerId="14424" CreationDate="2017-12-05T11:30:36.430" Score="2" ViewCount="550" Body="&lt;p&gt;vim-help &lt;code&gt;:h search()&lt;/code&gt; says it start search at column 0 of cursor position.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Search for regexp pattern {pattern}.  The search starts at the cursor&#xA;  position (you can use |cursor()| to set it).&lt;br&gt;&#xA;  .... &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;'b'   search Backward instead of forward&lt;br&gt;&#xA;  'e'   move to the End of the match&lt;br&gt;&#xA;  'z'   start searching at the cursor column instead of zero&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;.... When the 'z' flag is not given, searching always starts in column&#xA;  zero and then matches before the cursor are skipped. When the 'c' flag&#xA;  is present in 'cpo' the next search starts after the match.  Without&#xA;  the 'c' flag the next search starts one column further.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus, when below script being sourced,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! GoParagraphStart(flags) range abort&#xA;    echo search('^',a:flags)&#xA;endfunc&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; { :call GoParagraphStart('be')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; } :call GoParagraphStart('e')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suppose, be the cursor at the first column or not, pressing &lt;kbd&gt;{&lt;/kbd&gt; will always move cursor to previous line. But the result is&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;go previous line if cursor at first column&lt;/li&gt;&#xA;&lt;li&gt;go first column of current line if not at first column.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Which make me puzzled. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Is the behavior wrong, or I mis-interpreted the meaning of the help file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;version:  vim 8.0 with patch 1-1216 on Cygwin64&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;== motivation &amp;amp; the true problem ==&lt;/strong&gt;&lt;br&gt;&#xA;previous function definition is for illustrative purpose, original one is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! GoParagraphStart(flags) range abort&#xA;    if v:count &amp;lt; 2&#xA;        call search('\(\_^\s*\_$\n\_^.\)', a:flags)&#xA;    else&#xA;        let cnt = 0&#xA;        while cnt &amp;lt; v:count&#xA;            call search('\(\_^\s*\_$\n\_^.\)', a:flags) &#xA;            let cnt += 1&#xA;        endwhile&#xA;    endif&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The behavior I needed is&lt;/strong&gt;, when cursor at first line or a paragraph, pressing &lt;kbd&gt;{&lt;/kbd&gt; will go previous paragraph's first line, no matter cursor at column zero or not. However, currently not working if cursor not at column zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;== P.S. ==&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Answer not answering the question, but instead do fix and achieve the intended behavior is well-appreciated too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;== Edit ==&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @statox stated, the behavior is indeed as documented, the departure is because, depends on &lt;code&gt;found-pos == line('.'), col('.')&lt;/code&gt;, the result will be rejected if true, else accept. unless flag &lt;code&gt;c&lt;/code&gt; is specified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, the fix is easy, add &lt;code&gt;call cursor('.',1)&lt;/code&gt; or &lt;code&gt;norm! 0&lt;/code&gt; before do search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(side notes. concerning &lt;code&gt;norm! k$&lt;/code&gt;, it fixs backward search, but break forward search.)&lt;/p&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="10254" LastEditDate="2017-12-05T14:12:36.183" LastActivityDate="2017-12-05T14:12:36.183" Title="vimscript: strange behavior of search() with flags 'be'?" Tags="|vimscript|search|functions|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14424" PostTypeId="2" ParentId="14423" CreationDate="2017-12-05T11:52:54.497" Score="2" Body="&lt;h3&gt;Why does the search move the cursor to the previous line if you are on the first column?&lt;/h3&gt;&#xA;&lt;p&gt;If you are on the first &lt;code&gt;a&lt;/code&gt; of the following line:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;abcabc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Using &lt;code&gt;call search('a')&lt;/code&gt; will move the cursor to the 4th letter of the line. It is because &lt;code&gt;search()&lt;/code&gt; by default doesn't accept a match at the cursor position (you can use the flag &lt;code&gt;c&lt;/code&gt; to change that). Thus it is the same when you search backward: the beginning of the line at the current position is not accepted by search. The behavior you are observing is the one which is documented.&lt;/p&gt;&#xA;&lt;h3&gt;How to solve that?&lt;/h3&gt;&#xA;&lt;p&gt;If you want to always go to the previous line you should be able to use &lt;code&gt;norm! k$&lt;/code&gt; before you use &lt;code&gt;search()&lt;/code&gt; this way you will always be on the end of the previous line and you should get the behavior &lt;code&gt;go first column of current line if not at first column.&lt;/code&gt; each time.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2017-12-05T11:52:54.497" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14425" PostTypeId="1" AcceptedAnswerId="22717" CreationDate="2017-12-05T11:59:22.510" Score="7" ViewCount="89" Body="&lt;p&gt;I just wrote the following code in &lt;a href=&quot;https://vi.stackexchange.com/a/14422/343&quot;&gt;an answer to another question&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match HideTwoIndents /\v^\t(\t)?/ conceal&#xA;set conceallevel=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works great if &lt;code&gt;'list'&lt;/code&gt; is set &lt;em&gt;and&lt;/em&gt; if &lt;code&gt;'listchars'&lt;/code&gt; does not contain a value for &lt;code&gt;tab:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if &lt;code&gt;'list'&lt;/code&gt; is unset &lt;em&gt;or&lt;/em&gt; if &lt;code&gt;'listchars'&lt;/code&gt; contains a value for &lt;code&gt;tab:&lt;/code&gt; then if there are more than two tabs at the start of the line,  the first two will be concealed as expected, but the third will be displayed as though it has a width of 3&amp;times;&lt;code&gt;'tabstop'&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. after running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match HideTwoIndents /\v^\t(\t)?/ conceal&#xA;set conceallevel=2&#xA;set tabstop=2&#xA;set list&#xA;set listchars+=tab:xy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;Three tabs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will be displayed correctly when the cursor is not on the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xyxyxyThree tabs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but will be displayed incorrectly when the cursor is on the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xyyyyyThree tabs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would expect it to displayed as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xyThree tabs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this documented behaviour, or should it be reported as a bug?&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-12-05T12:33:33.427" LastActivityDate="2020-01-31T09:46:24.647" Title="Why are tabs adjacent to concealed tabs displayed wider than a single tabstop?" Tags="|options|tab-characters|conceal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14426" PostTypeId="1" AcceptedAnswerId="14431" CreationDate="2017-12-05T12:58:52.030" Score="0" ViewCount="1537" Body="&lt;p&gt;I have read &lt;code&gt;'ai'&lt;/code&gt;, &lt;code&gt;'si'&lt;/code&gt;, &lt;code&gt;'cin'&lt;/code&gt;, &lt;code&gt;'ci'&lt;/code&gt;  help pages in Vim but I still cannot realize that what indention option is good for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, I can read that :help pages again and set whatever I need in my vimrc but can I use all of the above indention options in my vimrc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mean, &lt;strong&gt;if I set them step by step, will vim conflict the options together and cause trouble in each indention?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I have found that setting &lt;code&gt;'si'&lt;/code&gt; has no effect when &lt;code&gt;'cin'&lt;/code&gt; is present and setting &lt;code&gt;'ci'&lt;/code&gt; isn't recommended when &lt;code&gt;'ai'&lt;/code&gt; is present. &lt;strong&gt;Is it true?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="15007" LastEditorUserId="15007" LastEditDate="2017-12-05T14:26:28.883" LastActivityDate="2017-12-05T16:43:33.867" Title="Differences between indention options" Tags="|vimrc|indentation|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14429" PostTypeId="1" AcceptedAnswerId="19377" CreationDate="2017-12-05T15:22:03.897" Score="11" ViewCount="10020" Body="&lt;p&gt;I'm using Neovim 0.2.2 on macOS High Sierra (10.13.1), installed via &lt;code&gt;brew install neovim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I removed &lt;code&gt;.config/nvim/init.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neovim starts up using German for interface labels, as shown here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/B3agI.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/B3agI.png&quot; alt=&quot;German labels in Neovim interface&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the output of &lt;code&gt;locale&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LANG=&#xA;LC_COLLATE=&quot;C&quot;&#xA;LC_CTYPE=&quot;en_US.UTF-8&quot;&#xA;LC_MESSAGES=&quot;C&quot;&#xA;LC_MONETARY=&quot;C&quot;&#xA;LC_NUMERIC=&quot;C&quot;&#xA;LC_TIME=&quot;C&quot;&#xA;LC_ALL=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are my &quot;Language &amp;amp; Region&quot; settings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/l1kV5.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/l1kV5.png&quot; alt=&quot;macOS Language &amp;amp; Region Settings&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All my other applications, GUI or command line, are in English.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone enlighten me on what is causing Neovim to display German interface labels and how I can override that to use English instead?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched the Neovim documentation and Google on how to manually set Neovim's interface language, but couldn't find anything.&lt;/p&gt;&#xA;" OwnerUserId="14636" LastActivityDate="2024-04-04T09:23:52.320" Title="Why is my Neovim not in English and how do I force it to be?" Tags="|neovim|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14430" PostTypeId="2" ParentId="14429" CreationDate="2017-12-05T15:28:03.230" Score="2" Body="&lt;p&gt;Regarding the second part of my question: just after posting I had the ingenious idea of setting &lt;code&gt;LANG=en_US&lt;/code&gt; and that actually works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just out of curiosity, I'd still be interested in the answer to the first part: where exactly did Neovim get the idea to use German instead of defaulting to English in the first place?&lt;/p&gt;&#xA;" OwnerUserId="14636" LastEditorUserId="14636" LastEditDate="2017-12-05T15:33:39.023" LastActivityDate="2017-12-05T15:33:39.023" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14431" PostTypeId="2" ParentId="14426" CreationDate="2017-12-05T16:43:33.867" Score="2" Body="&lt;p&gt;From &lt;code&gt;:h indent.txt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;There are in fact four main methods available for indentation, each one&#xA;overrides the previous if it is enabled, or non-empty for 'indentexpr':&#xA;'autoindent'    uses the indent from the previous line.&#xA;'smartindent'   is like 'autoindent' but also recognizes some C syntax to&#xA;        increase/reduce the indent where appropriate.&#xA;'cindent'   Works more cleverly than the other two and is configurable to&#xA;        different indenting styles.&#xA;'indentexpr'    The most flexible of all: Evaluates an expression to compute&#xA;        the indent of a line.  When non-empty this method overrides&#xA;        the other ones.  See |indent-expression|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the 4 indent types are &lt;code&gt;'autoindent'&lt;/code&gt;, &lt;code&gt;'smartindent'&lt;/code&gt;, &lt;code&gt;'cindent'&lt;/code&gt;, and &lt;code&gt;'indentexpr'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I can ... set whatever I need in my vimrc but can I use all of the above indention options in my vimrc?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Indention settings are local to a buffer. Typically when you have &lt;code&gt;filetype plugin indent on&lt;/code&gt; you get the default indent setting for the &lt;code&gt;'filetype'&lt;/code&gt;. If you want to change the indent settings for a file type I would recommend you add your changes to &lt;code&gt;~/.vim/after/indent/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt;, e.g. &lt;code&gt;~/.vim/after/indent/c.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also worth looking through &lt;code&gt;:h indent.text&lt;/code&gt; as some filetypes have special options which can change indention styles/preferences.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-12-05T16:43:33.867" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14433" PostTypeId="1" AcceptedAnswerId="14434" CreationDate="2017-12-05T23:38:48.883" Score="7" ViewCount="5767" Body="&lt;p&gt;Sometimes I need to move to a particular byte offset or move to the nth unicode rune in a file (utf-8).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does vim expose a way to move to an absolute byte/char offset or to move the cursor forward a backward a given number of bytes/chars?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-12-06T00:32:26.403" Title="move forward by a certain number of chars or bytes?" Tags="|unicode|navigation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14434" PostTypeId="2" ParentId="14433" CreationDate="2017-12-05T23:59:05.490" Score="12" Body="&lt;p&gt;To go to the Nth byte in the file: use &lt;code&gt;:go N&lt;/code&gt;, &lt;code&gt;:Ngo&lt;/code&gt;, or &lt;code&gt;Ngo&lt;/code&gt; (normal mode).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To move N bytes ahead, you could use something like this &lt;code&gt;:exe 'go' line2byte(line(&quot;.&quot;))+col(&quot;.&quot;)-1+N&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless you have changed &lt;code&gt;virtualedit&lt;/code&gt;, you can move forward with &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt;.  To go to the Nth character in the file, use &lt;code&gt;1goN&amp;lt;space&amp;gt;&lt;/code&gt; in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To move ahead N characters, use &lt;code&gt;N&amp;lt;space&amp;gt;&lt;/code&gt; in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: besides the obvious multi-byte character difference these also differ in that the first counts newlines and the second doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have &lt;code&gt;set virtualedit=all&lt;/code&gt;, space won't work.  Instead you could use &lt;code&gt;/\%#\_.\{N}/e&lt;/code&gt; for relative or &lt;code&gt;/\%1l\%1c\_.\{4}/e&lt;/code&gt; for absolute.  Unlike the &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; version this counts end-of-lines.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-12-06T00:32:26.403" LastActivityDate="2017-12-06T00:32:26.403" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14435" PostTypeId="1" AcceptedAnswerId="14448" CreationDate="2017-12-06T06:34:23.320" Score="2" ViewCount="115" Body="&lt;p&gt;I have a set of bindings for jumping to the (n*10)th column that are basically just sugar over the &lt;code&gt;|&lt;/code&gt; command and somewhat nice for coarse horizontal movement.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;`      0&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;1     10\|&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;2     20\|&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;3     30\|&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;4     40\|&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;5     50\|&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;6     60\|&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;7     70\|&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;8     80\|&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;9     90\|&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;0    100\|&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;-    110\|&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;=    120\|&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;&amp;lt;bs&amp;gt; 130\|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the most part, it works well. However, I'll sometimes hit a stray digit by accident, say &lt;kbd&gt;1&lt;/kbd&gt; and then hit &lt;kbd&gt;leader&lt;/kbd&gt; &lt;kbd&gt;2&lt;/kbd&gt; and jump to column 120 by mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to modify the commands so that they clear numeric arguments before being executed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using the &lt;code&gt;normal&lt;/code&gt; command to wrap one of the options&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;1 :normal &quot;10\\\|&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(and several variations of backslashing to prevent the &lt;code&gt;|&lt;/code&gt; from being interpreted as a line separator in the body of the &lt;code&gt;nnoremap&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But doing that seems to be equivalent to &lt;kbd&gt;0&lt;/kbd&gt; for some reason.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="343" LastEditDate="2017-12-06T11:09:18.987" LastActivityDate="2017-12-06T16:46:01.650" Title="How to clear digit arguments in a mapping?" Tags="|key-bindings|vimscript|count|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14437" PostTypeId="2" ParentId="14435" CreationDate="2017-12-06T10:19:10.137" Score="3" Body="&lt;p&gt;One way to do it would be to carry out the movement with a function. The existing &lt;code&gt;count&lt;/code&gt; will be converted to a &lt;code&gt;range&lt;/code&gt; on the command line, but we can clear this with &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has the slight advantage of allowing you to compress the numerical mappings down a little:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(1, 9)&#xA;  execute 'nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;'.i.' :&amp;lt;C-U&amp;gt;call cursor(0, '.i.'0)&amp;lt;CR&amp;gt;'&#xA;endfor&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;` :&amp;lt;C-U&amp;gt;call cursor(0, 1)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;0 :&amp;lt;C-U&amp;gt;call cursor(0, 100)&amp;lt;CR&amp;gt;&#xA;&quot; etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(hat-tip to &lt;a href=&quot;https://vi.stackexchange.com/users/51/carpetsmoker&quot;&gt;Carpetsmoker&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/users/11054/b-layer&quot;&gt;B Layer&lt;/a&gt; for use of &lt;code&gt;cursor()&lt;/code&gt; instead of the function originally in this answer).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Further Reading&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :call&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help v:count&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help cursor()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-12-06T14:14:05.750" LastActivityDate="2017-12-06T14:14:05.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14438" PostTypeId="2" ParentId="9760" CreationDate="2017-12-06T10:36:52.070" Score="5" Body="&lt;p&gt;Updating the &lt;code&gt;vim&lt;/code&gt; package fixed the broken arrows issue for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are on Ubuntu, run &lt;code&gt;apt upgrade vim&lt;/code&gt;. Interestingly, &lt;code&gt;apt install vim&lt;/code&gt; also helps. And even more interestingly, after update &lt;code&gt;vim&lt;/code&gt; version stays the same:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)&#xA;Included patches: 1-1689&#xA;Extra patches: 8.0.0056&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it helps.&lt;/p&gt;&#xA;" OwnerUserId="15461" LastEditorUserId="15461" LastEditDate="2017-12-06T10:45:12.140" LastActivityDate="2017-12-06T10:45:12.140" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14439" PostTypeId="5" CreationDate="2017-12-06T11:07:10.077" Score="0" Body="" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-12-06T11:07:10.077" LastActivityDate="2017-12-06T11:07:10.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14440" PostTypeId="4" CreationDate="2017-12-06T11:07:10.077" Score="0" Body="Questions about how to count the number of occurrences of something. Questions about the Vim feature that repeats commands should use the 'count' tag instead." OwnerUserId="343" LastEditorUserId="1452" LastEditDate="2018-04-07T14:00:23.440" LastActivityDate="2018-04-07T14:00:23.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14441" PostTypeId="1" AcceptedAnswerId="14442" CreationDate="2017-12-06T12:21:03.933" Score="11" ViewCount="2243" Body="&lt;p&gt;From time to time I like to engage in a round of &lt;a href=&quot;http://vimgolf.com/&quot; rel=&quot;noreferrer&quot;&gt;vimgolf&lt;/a&gt;. It can be enlightening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How are they able to record all the keystrokes? That must be a vim feature. Anybody any idea how to do that. It could come in handy to record everything in certain circumstances.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastEditorUserId="51" LastEditDate="2017-12-06T13:39:36.547" LastActivityDate="2021-10-04T06:32:53.573" Title="How does vimgolf record all keystrokes?" Tags="|key-bindings|user-input|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14442" PostTypeId="2" ParentId="14441" CreationDate="2017-12-06T12:29:30.597" Score="13" Body="&lt;p&gt;They probably use the built-in parameter &lt;code&gt;-w&lt;/code&gt;, see &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#-w&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h -w&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-w {scriptout}  All the characters that you type are recorded in the file&#xA;        &quot;scriptout&quot;, until you exit Vim.  This is useful if you want&#xA;        to create a script file to be used with &quot;vim -s&quot; or&#xA;        &quot;:source!&quot;.  When the &quot;scriptout&quot; file already exists, new&#xA;        characters are appended.  See also |complex-repeat|.&#xA;        {scriptout} cannot start with a digit.&#xA;        {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt; As @B Layer pointed out the actual code uses the &lt;code&gt;-W&lt;/code&gt; parameter which is basically the same as &lt;code&gt;-w&lt;/code&gt; but the log file is overwritten instead of appending the keystrokes to it (&lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#-W&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h -W&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-W {scriptout}  Like -w, but do not append, overwrite an existing file.&#xA;        {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-12-06T12:41:42.457" LastActivityDate="2017-12-06T12:41:42.457" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14443" PostTypeId="2" ParentId="14441" CreationDate="2017-12-06T12:32:24.857" Score="16" Body="&lt;p&gt;I don't think it's quite that simple but you can look at the Ruby code yourself here:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/igrigorik/vimgolf/tree/master/lib/vimgolf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/igrigorik/vimgolf/tree/master/lib/vimgolf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I see a class for keylogging, for one.&lt;/p&gt;&#xA;&lt;p&gt;Here's the command that is used to launch &lt;code&gt;vim&lt;/code&gt; in &lt;a href=&quot;https://github.com/igrigorik/vimgolf/blob/master/lib/vimgolf/lib/vimgolf/cli.rb&quot; rel=&quot;nofollow noreferrer&quot;&gt;lib/vimgolf/cli.rb&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; vimcmd = GOLFVIM.shellsplit + %W{-Z -n --noplugin --nofork -i NONE +0 &#xA;    -u #{challenge.vimrc_path} -U NONE -W #{challenge.log_path} #{challenge.work_path}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;@statox was (very nearly) right about &lt;code&gt;-w outfile&lt;/code&gt; ... &lt;code&gt;-W outfile&lt;/code&gt;, actually, which overwrites the file to which the typed characters are sent rather than appending to it. But as I said, not &amp;quot;quite that simple&amp;quot;...compare the contents of one of those files and what gets generated by the vimgolf tool. This is from &lt;a href=&quot;http://www.vimgolf.com/challenges/4d716c76919202611400002b&quot; rel=&quot;nofollow noreferrer&quot;&gt;an actual vimgolf problem&lt;/a&gt;...&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;&lt;code&gt;-W&lt;/code&gt; output:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;^VGI0. ^[gvg^AZZ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;vimgolf displayed/uploaded output:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-V&amp;gt;GI0. &amp;lt;Esc&amp;gt;gvg&amp;lt;C-A&amp;gt;ZZ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I spent a few minutes looking a bit closer at things. Here's how the raw form gets converted to the more readable Vimgolf format...&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/igrigorik/vimgolf/blob/master/lib/vimgolf/lib/vimgolf/keylog.rb&quot; rel=&quot;nofollow noreferrer&quot;&gt;The keylogger class keylog.rb&lt;/a&gt; that I mention above is indeed a major piece of the puzzle but it's actually fairly straightforward. The keycodes that Vim saves to the &lt;code&gt;-W&lt;/code&gt; log file are either one byte or three bytes long. The latter always start with the value 0x80 to distinguish them from one-byte codes.&lt;/p&gt;&#xA;&lt;p&gt;To decode the one-byte keycodes a simple array lookup is done.&lt;/p&gt;&#xA;&lt;p&gt;Example: If you press &lt;kbd&gt;G&lt;/kbd&gt; the byte 0x47 is saved to the &lt;code&gt;-W&lt;/code&gt; file. (Hex 47 is the ASCII code for the letter &lt;code&gt;G&lt;/code&gt;.) In the lookup array the element at position 0x47 contains, naturally, &lt;code&gt;G&lt;/code&gt;. For printable characters this is an obvious conversion but it's necessary for non-printable ASCII characters that we want to have a nice name like &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For multi-byte keycodes there is a hash table that maps bytes two and three to a human readable string.&lt;/p&gt;&#xA;&lt;p&gt;Example: If you press &lt;kbd&gt;Home&lt;/kbd&gt; the three-byte sequence &lt;code&gt;80 6B 68&lt;/code&gt; is saved to the &lt;code&gt;-W&lt;/code&gt; file. The last two bytes are converted to ASCII and concatenated: &lt;code&gt;kh&lt;/code&gt;. In the hash table that string is mapped to the string &lt;code&gt;&amp;lt;Home&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There are some exceptions/corner-cases that are handled differently but most of the keycodes are resolved by one of the two methods described above.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2021-10-04T06:32:53.573" LastActivityDate="2021-10-04T06:32:53.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14445" PostTypeId="1" AcceptedAnswerId="14447" CreationDate="2017-12-06T15:34:22.857" Score="1" ViewCount="2802" Body="&lt;p&gt;What does &lt;kbd&gt;C-V&lt;/kbd&gt; &lt;kbd&gt;?&lt;/kbd&gt; &lt;kbd&gt;space&lt;/kbd&gt; &lt;kbd&gt;CR&lt;/kbd&gt; do?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone explain that key by key?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know &lt;kbd&gt;C-V&lt;/kbd&gt; is visual block mode, but the &lt;kbd&gt;?&lt;/kbd&gt; ? How does that work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine this, with the cursor on the first line, first char:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    abc&#xA;    abc&#xA;    abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I do the above, the result is that the visual block selects the whitespace before the &lt;code&gt;abc&lt;/code&gt; on all lines.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastEditorUserId="1841" LastEditDate="2017-12-07T09:14:43.413" LastActivityDate="2017-12-07T09:14:43.413" Title="What does &lt;C-V&gt;?&lt;Space&gt;&lt;CR&gt; do?" Tags="|key-bindings|visual-block|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14446" PostTypeId="2" ParentId="9760" CreationDate="2017-12-06T15:48:44.540" Score="21" Body="&lt;h1&gt;What's causing the behaviour&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;When you press the left arrow, your terminal is sending the following escape sequence:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ESC O D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can also be notated as &lt;code&gt;^[OD&lt;/code&gt;, where &lt;code&gt;^[&lt;/code&gt; is notation for &lt;code&gt;Ctrl-[&lt;/code&gt;, which is another way of notating or entering the ESC character. (Try it in insert mode!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim is not recognising this as an escape sequence, and therefore it is treating those keystrokes as if you had typed them out yourself:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;: Leave insert mode,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;O&lt;/kbd&gt;: Begin a new line above the cursor and enter insert mode,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;D&lt;/kbd&gt;: Enter a 'D' character.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can confirm that this is what your terminal is sending by entering insert mode and then pressing &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; followed by the &lt;kbd&gt;Left&lt;/kbd&gt; arrow.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;What's going wrong&lt;/h1&gt;&#xA;&#xA;&lt;h2&gt;The escape sequence might be timing out&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;only&lt;/em&gt; way that Vim can distinguish the escape sequence from the same three characters manually typed in is by the time that occurs between the receipt of each character. It's possible therefore on slow terminals or very busy systems that there is sufficient delay between each character that Vim is deciding it's not an escape sequence and just interpreting the keystrokes as described above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is described in &lt;code&gt;:help vt100-cursor-keys&lt;/code&gt; and further in &lt;code&gt;:help timeout&lt;/code&gt;&amp;#8202;&amp;mdash;&amp;#8202;the suggested solution is to set a sufficiently large &lt;code&gt;ttimeoutlen&lt;/code&gt;, but disabling timeouts entirely by setting both &lt;code&gt;notimeout&lt;/code&gt; and &lt;code&gt;nottimeout&lt;/code&gt; would also work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, given your setup, this is pretty unlikely to be the issue.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Vim doesn't recognise the sequence&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It's more likely that the problem is that Vim doesn't recognise the escape sequence sent, and so is interpreting it as keystrokes. You can check this with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set &amp;lt;left&amp;gt;?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a working setup with your current terminal configuration, this should give either of the following outputs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t_kl &amp;lt;Left&amp;gt;      ^[O*D&#xA;t_kl &amp;lt;Left&amp;gt;      ^[OD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you see anything else&lt;sup&gt;1&lt;/sup&gt;, then Vim and your terminal are not quite speaking the same language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;correct&lt;/em&gt; way to fix this would be to fix your terminal configuration so that your terminfo database reports the sequences that are actually sent when you press the arrow keys, but doing so can be complicated. A slightly hacky fix is to change what your terminal sends to match what Vim is expecting. I infer from your comments that you are using the default Mac Terminal.app: You can change what escape sequences are sent for each keystroke in Preferences &amp;rarr; Profiles &amp;rarr; Your profile &amp;rarr; Keyboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the easiest fix is probably to inform Vim directly what escape sequences to expect. You can do this by setting its terminal options thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;up&amp;gt;=^[OA&#xA;set &amp;lt;down&amp;gt;=^[OB&#xA;set &amp;lt;right&amp;gt;=^[OC&#xA;set &amp;lt;left&amp;gt;=^[OD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the &lt;code&gt;^[&lt;/code&gt; in the above is a literal &lt;code&gt;ESC&lt;/code&gt; character. You cannot just type &lt;kbd&gt;^&lt;/kbd&gt; followed by &lt;kbd&gt;[&lt;/kbd&gt;! The easiest way to enter the mappings is to enter e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;left&amp;gt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then, still in insert mode, press &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; followed by the &lt;kbd&gt;left&lt;/kbd&gt; arrow. Note that you are then setting the escape sequence directly to what Vim receives when you press the arrow key... by sending it that sequence!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1: One likely possibility is the &lt;a href=&quot;https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_sequences&quot; rel=&quot;noreferrer&quot;&gt;CSI sequence&lt;/a&gt;: &lt;code&gt;^[[D&lt;/code&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-12-06T15:54:35.487" LastActivityDate="2017-12-06T15:54:35.487" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14447" PostTypeId="2" ParentId="14445" CreationDate="2017-12-06T15:58:37.730" Score="7" Body="&lt;p&gt;You need to see this as an action (&lt;code&gt;&amp;lt;c-v&amp;gt;&lt;/code&gt;) followed by a motion (&lt;code&gt;? &amp;lt;CR&amp;gt;&lt;/code&gt;) which is the basis of the Vim &quot;grammar&quot;. For example &lt;code&gt;ve&lt;/code&gt; is an action (&lt;code&gt;v&lt;/code&gt; visually selection) followed by a motion (&lt;code&gt;e&lt;/code&gt; until the end of the word).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-v&amp;gt;&lt;/code&gt; starts a block selection from the cursor position to the next motion&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;?&lt;/code&gt; starts a backward search&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&lt;/code&gt; is your search pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; starts the search&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here the next match (i.e. the previous whitespace) is the &quot;next motion&quot; expected by &lt;code&gt;&amp;lt;c-v&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your command starts a block selection from the cursor to the previous whitespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could get the equivalent behavior with &lt;code&gt;&amp;lt;c-v&amp;gt;B&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt; To answer your example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#visual-block&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h visual-block&lt;/code&gt;&lt;/a&gt; tells us that&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;With CTRL-V (blockwise Visual mode) the highlighted text will be a rectangle between start position and the cursor.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your start position is the first whitespace of the first line. After you use the backward search your cursor position is last whitespace of the last line. If you draw a rectangle between these two points, you should see why all of the whitespaces are selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now in your example remove a whitespace on the last line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    abc&#xA;    abc&#xA;   abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And use the same selection. You will notice that only the first two columns are selected because your start position didn't change but the cursor position changed since the previous whitespace isn't in the same place anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About my &lt;code&gt;&amp;lt;c-v&amp;gt;B&lt;/code&gt; example it doesn't work in your case because the motion &lt;code&gt;B&lt;/code&gt; doesn't look for another line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will notice that if you use &lt;code&gt;set nowrapscan&lt;/code&gt; the backward search will not be allowed to go to the last line so you will not select the rectangle anymore. (&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27wrapscan%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'wrapscan'&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-12-07T07:54:31.697" LastActivityDate="2017-12-07T07:54:31.697" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14448" PostTypeId="2" ParentId="14435" CreationDate="2017-12-06T16:46:01.650" Score="2" Body="&lt;p&gt;You almost had it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you need &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; to clear the count&lt;/li&gt;&#xA;&lt;li&gt;and then either you use quotes with &lt;code&gt;:exe&lt;/code&gt;, or you use none&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In short:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;1 :&amp;lt;c-u&amp;gt;exe 'normal! 10\|'&amp;lt;cr&amp;gt;&#xA;&quot; or&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;1 :&amp;lt;c-u&amp;gt;normal! 10\|&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-12-06T16:46:01.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14449" PostTypeId="1" CreationDate="2017-12-07T01:22:20.003" Score="1" ViewCount="67" Body="&lt;p&gt;I've got the following vim script to show a perldoc or per man page into a new tab and then rewrap it the text so it's more readable (I have a very wide monitor).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap K :execute &quot;tabnew &amp;lt;bar&amp;gt; read !man &quot; . expand(&quot;&amp;lt;cword&amp;gt;&quot;) . &quot; &amp;lt;bar&amp;gt;&amp;lt;bar&amp;gt;&quot; . &quot; perldoc &quot; . expand(&quot;&amp;lt;cword&amp;gt;&quot;) . &quot; &amp;lt;bar&amp;gt;&amp;lt;bar&amp;gt;&quot; . &quot; perldoc -f &quot; . expand(&quot;&amp;lt;cword&amp;gt;&quot;) . &quot; &amp;lt;bar&amp;gt;&amp;lt;bar&amp;gt; &quot; . &quot; perldoc -q &quot; . expand(&quot;&amp;lt;cword&amp;gt;&quot;)&amp;lt;cr&amp;gt;1G:set tw=80&amp;lt;cr&amp;gt;gggqGgg`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that UTF-8 characters from the man pages appear to be getting mangled. How do I modify the &lt;code&gt;read&lt;/code&gt; command or change the tab's settings to properly display these characters?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="1841" LastEditDate="2017-12-07T10:24:00.947" LastActivityDate="2017-12-07T10:24:00.947" Title="Reading in content from an external command with utf-8" Tags="|external-command|encoding|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14450" PostTypeId="1" AcceptedAnswerId="14452" CreationDate="2017-12-07T17:02:05.407" Score="1" ViewCount="123" Body="&lt;p&gt;Let's say I have the text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the cursor on &lt;code&gt;z&lt;/code&gt;, I would expect &lt;code&gt;:normal! lb&lt;/code&gt; to move the cursor to the first letter of &lt;code&gt;baz&lt;/code&gt;.  In actual fact the cursor does not move.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However typing &lt;code&gt;:normal! l&lt;/code&gt; and then &lt;code&gt;:normal! b&lt;/code&gt; does move the cursor as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The docs for &lt;code&gt;:normal!&lt;/code&gt; state:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Execution stops when an error is encountered.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is this why &lt;code&gt;:normal! lb&lt;/code&gt; doesn't do what I expect?  The &lt;code&gt;l&lt;/code&gt; cannot move to the right and so it is treated as a (silent) error?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2017-12-08T09:56:56.160" Title="Why doesn't &quot;normal! lb&quot; on last character of line move to beginning of word?" Tags="|vimscript|cursor-motions|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14451" PostTypeId="1" AcceptedAnswerId="14453" CreationDate="2017-12-07T17:31:32.900" Score="4" ViewCount="1451" Body="&lt;p&gt;When in visual mode you can select the new line character. E.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The quick brown fox jumps over the lazy dog.⏎&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In visual mode you can select both the period and the (invisible) carriage return, or even &lt;em&gt;just&lt;/em&gt; the carriage return (if you delete it you'll join the current and the next lines).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal mode, on the other hand, I can't get the cursor on top of that character, which really annoys me. Every now and then I want to select some text &lt;em&gt;including the new line before it&lt;/em&gt;. So I have to go to visual mode, select what I want and then type &lt;code&gt;o&lt;/code&gt; and go back a character to select the new line. It would be a lot better if I could have the cursor on the new line to begin with, so I'd just go into visual mode and select what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to make that happen?&lt;/p&gt;&#xA;" OwnerUserId="7642" LastActivityDate="2017-12-07T17:39:51.247" Title="Move cursor to new line character" Tags="|cursor-movement|normal-mode|cursor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14452" PostTypeId="2" ParentId="14450" CreationDate="2017-12-07T17:34:11.007" Score="1" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/14450/why-doesnt-normal-lb-on-last-character-of-line-move-to-beginning-of-word/14452#comment24833_14450&quot;&gt;@statox notes&lt;/a&gt;, you've answered your own question!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As your cursor is already at the rightmost position in the line, attempting to move further to right causes an error, and the &lt;code&gt;:normal!&lt;/code&gt; execution ends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, however, that this behaviour is dependent on at least two of Vim's default options. Try either of the following commands first, and your normal command will work as you originally expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This allows `l` to move down to the beginning of the next line&#xA;:set whichwrap+=l&#xA;&#xA;&quot; This allows `l` to move past the last character on the line&#xA;:set virtualedit=all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similar behaviour can be utilised to &lt;a href=&quot;https://vi.stackexchange.com/a/6428/343&quot;&gt;write recursive macros that stop at the end of a line&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-12-07T17:34:11.007" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14453" PostTypeId="2" ParentId="14451" CreationDate="2017-12-07T17:39:32.807" Score="6" Body="&lt;p&gt;If you simply want the cursor to be able to go one past the end of the line for the purpose of starting visual mode, you want the setting &lt;code&gt;set virtualedit=onemore&lt;/code&gt; (see &lt;code&gt;:help 've&lt;/code&gt;).  However, this does not let you remove the new line character in normal mode (in vim you usually use &lt;code&gt;J&lt;/code&gt; to do this).&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-12-07T17:39:32.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14454" PostTypeId="2" ParentId="14451" CreationDate="2017-12-07T17:39:51.247" Score="4" Body="&lt;p&gt;You can use &lt;code&gt;'virtualedit'&lt;/code&gt; for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set virtualedit=onemore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note however the warnings in &lt;code&gt;:help 'virtualedit'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;onemore&quot; is not the same, it will only allow moving the cursor just&#xA;      after the last character of the line.  This makes some commands more&#xA;      consistent.  Previously the cursor was always past the end of the line&#xA;      if the line was empty.  But it is far from Vi compatible.  It may also&#xA;      break some plugins or Vim scripts.  For example because |l| can move&#xA;      the cursor after the last character.  Use with care!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-12-07T17:39:51.247" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14455" PostTypeId="1" AcceptedAnswerId="14456" CreationDate="2017-12-07T19:28:37.247" Score="0" ViewCount="707" Body="&lt;p&gt;I have errors which looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Error] Z:\absolute\file\path.cpp(42): error C2065: 'foo': undeclared identifier&#xA;[Info] Z:\another\file\path.cpp(42): error C2050: 'foo': switch expression not integral&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I used the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CompilerSet errorformat=[\a\+]\ %f(%l):\ %m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it does not appear to work. The &quot;channel&quot; part seems to not match (&lt;code&gt;\a\+&lt;/code&gt;), since if I replace it with &lt;code&gt;Error&lt;/code&gt; or &lt;code&gt;Info&lt;/code&gt;, I capture the related lines.&lt;/p&gt;&#xA;" OwnerUserId="15490" LastEditorUserId="1841" LastEditDate="2017-12-08T08:59:33.660" LastActivityDate="2017-12-08T08:59:33.660" Title="Errorformat not recognizing my errors" Tags="|quickfix|errorformat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14456" PostTypeId="2" ParentId="14455" CreationDate="2017-12-07T21:39:55.700" Score="1" Body="&lt;pre&gt;&lt;code&gt;set errorformat=[%t%*\\a]\ %f(%l):\ %m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pattern &lt;code&gt;\a\+&lt;/code&gt;, is equivalent to &lt;code&gt;%*\\a&lt;/code&gt; according to &lt;code&gt;:h errorformat&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However you may want to look to see if Vim already supports your compiler of choice. Do &lt;code&gt;:compiler&lt;/code&gt; then tab complete or use &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; to get a list of known compilers.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-12-07T21:48:24.627" LastActivityDate="2017-12-07T21:48:24.627" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14457" PostTypeId="1" CreationDate="2017-12-07T23:08:46.810" Score="2" ViewCount="196" Body="&lt;p&gt;I am trying to add the following lines to my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-Tab&amp;gt; &amp;lt;C-w&amp;gt;w&#xA;nnoremap &amp;lt;C-S-Tab&amp;gt; &amp;lt;C-w&amp;gt;W&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As per &lt;a href=&quot;http://vim.wikia.com/wiki/Switching_between_files&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Tutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I can't seem to get these to work. Other mappings I have tried work well. I am running Linux Mint 18. Any ideas of what I am doing wrong. I am a long time VI user - although have always just used standard setup no major customisation.&lt;/p&gt;&#xA;" OwnerUserId="15491" LastActivityDate="2017-12-07T23:23:47.030" Title="Tabbing between files" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14458" PostTypeId="2" ParentId="14457" CreationDate="2017-12-07T23:23:47.030" Score="3" Body="&lt;p&gt;This is because &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; in vimscript and mappings is very buggy. For whatever reason, I frequently find cases where it doesn't work &lt;a href=&quot;https://vi.stackexchange.com/a/206/2920&quot;&gt;such as this one&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But thankfully, the solution is simple. You can do &lt;code&gt;wincmd w&lt;/code&gt; or &lt;code&gt;wincmd W&lt;/code&gt; as an ex command instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-tab&amp;gt; :wincmd w&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;C-S-tab&amp;gt; :wincmd W&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works just fine for me.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2017-12-07T23:23:47.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14459" PostTypeId="1" AcceptedAnswerId="14460" CreationDate="2017-12-08T00:27:45.160" Score="0" ViewCount="514" Body="&lt;p&gt;I often use &lt;code&gt;dt&lt;/code&gt;, but that only deletes to a character.  Is there something like &lt;code&gt;dt&lt;/code&gt; that lets me type in a search instead of a single char?  I would want to delete from my current cursor to that first search term.  &lt;/p&gt;&#xA;" OwnerUserId="15080" LastActivityDate="2017-12-08T00:37:12.037" Title="Delete to next search result?" Tags="|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14460" PostTypeId="2" ParentId="14459" CreationDate="2017-12-08T00:37:12.037" Score="8" Body="&lt;p&gt;this can be done with &lt;code&gt;d/term&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-12-08T00:37:12.037" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14461" PostTypeId="1" AcceptedAnswerId="14464" CreationDate="2017-12-08T00:57:41.693" Score="1" ViewCount="83" Body="&lt;p&gt;If spell checking is on and I type &quot;the the&quot; two times in a row, it marks it as an error.  This is described in the docs as Word Combinations.  Can I make my own rules like this?  How is this done?  I imagine &lt;code&gt;zw&lt;/code&gt; only works on the word you're on.&lt;/p&gt;&#xA;" OwnerUserId="15080" LastActivityDate="2017-12-08T07:19:46.613" Title="Vim spell checking marks &quot;the the&quot; in red. Can I define my own rules like that?" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14462" PostTypeId="1" AcceptedAnswerId="14463" CreationDate="2017-12-08T03:06:03.680" Score="1" ViewCount="80" Body="&lt;p&gt;I'm writing some functions to make it easier to manage vim's current directory and I'm trying to figure out how to quote the directory name when assembling a command to execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I'm running &lt;code&gt;execute printf(&quot;chdir %s&quot;, expand(&quot;%:h&quot;))&lt;/code&gt; and I'd like to know how to make it more secure/predictable/functionally correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can make that snippet a little bit more robust by using &lt;code&gt;'&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute printf(&quot;chdir '%s'&quot;, expand(&quot;%:h&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'm wondering if there's a solution that handles all cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some context/motivation,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;code&gt;noautochdir&lt;/code&gt; set and a global variable &lt;code&gt;g:dir_jump_orig&lt;/code&gt; to the value of the current working directory on startup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noautochdir&#xA;let g:dir_jump_orig = $PWD&#xA;&#xA;function! DirJumpGoFocused()&#xA;  execute printf(&quot;chdir %s&quot;, expand(&quot;%:h&quot;))&#xA;endfunction&#xA;&#xA;function! DirJumpGoOrig()&#xA;  execute printf(&quot;chdir %s&quot;, g:dir_jump_orig))&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;&amp;lt;c-i&amp;gt; :&amp;lt;c-u&amp;gt;call DirJumpGoOrig()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;c     :&amp;lt;c-u&amp;gt;call DirJumpGoFocused()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to make &lt;code&gt;DirJumpGoOrig&lt;/code&gt; and &lt;code&gt;DirJumpGoFocused&lt;/code&gt; more reliable.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2017-12-08T03:23:09.797" Title="Dealing with special characters when creating commands to eval" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14463" PostTypeId="2" ParentId="14462" CreationDate="2017-12-08T03:23:09.797" Score="4" Body="&lt;p&gt;You are looking for &lt;code&gt;fnameescape()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'cd ' . fnameescape(expand(&quot;%:h&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see &lt;code&gt;:h fnameescape()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-12-08T03:23:09.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14464" PostTypeId="2" ParentId="14461" CreationDate="2017-12-08T07:10:45.343" Score="2" Body="&lt;p&gt;&lt;code&gt;zw&lt;/code&gt; should work just fine. Select the words with Visual mode first. I just verified this myself (Vim 8.0). You can also add them manually by going to the first file you see with &lt;code&gt;set spellfile?&lt;/code&gt;. Simply put the words on their own line and append &lt;code&gt;/!&lt;/code&gt;, e.g. &lt;code&gt;is bad/!&lt;/code&gt;. If they don't appear as a spelling error immediately after &lt;code&gt;zw&lt;/code&gt; try doing a screen redraw with &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;L&lt;/kbd&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured some of this out by doing &lt;code&gt;:h spell&lt;/code&gt; and then &lt;code&gt;/the the&lt;/code&gt;. That's the example they use whenever discussing multi-word entries. :)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-12-08T07:19:46.613" LastActivityDate="2017-12-08T07:19:46.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14465" PostTypeId="1" AcceptedAnswerId="14479" CreationDate="2017-12-08T09:23:42.997" Score="3" ViewCount="1439" Body="&lt;p&gt;Can I change &lt;code&gt;/&lt;/code&gt; command to execute a fuzzy search instead of a regex based one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be useful to still be able to access the classic &lt;code&gt;/&lt;/code&gt; functionality at certain times.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="7267" LastEditDate="2017-12-10T19:02:47.643" LastActivityDate="2017-12-10T19:02:47.643" Title="Fuzzy find within buffer" Tags="|find|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14467" PostTypeId="1" CreationDate="2017-12-08T13:11:51.043" Score="1" ViewCount="858" Body="&lt;p&gt;I am setting &lt;code&gt;makeprg&lt;/code&gt; to &lt;code&gt;perl %&lt;/code&gt; to run my Perl script (if there's a better way, I'm up for that, too), and it works just fine, except that it reproduces the first line of output prefixed with the text &quot;(1 of n)&quot;, where n seems to be the total output line count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to suppress that, leaving me with just what my Perl script produces.  Can I suppress that report line from &lt;code&gt;:make&lt;/code&gt;?  The .vimrc line that sets up makeprg is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType perl   :set makeprg=perl\ %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15498" LastEditorUserId="1841" LastEditDate="2017-12-08T13:14:43.897" LastActivityDate="2019-09-03T11:00:19.020" Title="Silencing :make command" Tags="|makeprg|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14469" PostTypeId="1" AcceptedAnswerId="14470" CreationDate="2017-12-08T14:55:45.247" Score="2" ViewCount="626" Body="&lt;p&gt;In my vimrc, I have a &lt;code&gt;compiler myCompiler&lt;/code&gt;. When the editor starts up, everything is fine. When I switch to a new file, the &lt;code&gt;compiler&lt;/code&gt; settings (&lt;code&gt;makeprg&lt;/code&gt; and &lt;code&gt;errorformat&lt;/code&gt;) revert to their defaults.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I set the &lt;code&gt;compiler&lt;/code&gt; globally?&lt;/p&gt;&#xA;" OwnerUserId="15490" LastEditorUserId="28" LastEditDate="2017-12-11T08:11:42.590" LastActivityDate="2017-12-11T08:11:42.590" Title="How to set up compiler globally?" Tags="|makeprg|errorformat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14470" PostTypeId="2" ParentId="14469" CreationDate="2017-12-08T15:02:20.800" Score="6" Body="&lt;p&gt;Use &lt;code&gt;:compiler!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h :compiler&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:comp[iler][!] {name}       Set options to work with compiler {name}.&#xA;                            Without the &quot;!&quot; options are set for the&#xA;                            current buffer.  With &quot;!&quot; global options are&#xA;                            set.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-12-08T15:02:20.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14471" PostTypeId="2" ParentId="3752" CreationDate="2017-12-08T17:28:10.680" Score="6" Body="&lt;h3&gt;&lt;code&gt;html2vimdoc.py&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The most promising tool I've found is &lt;code&gt;html2vimdoc.py&lt;/code&gt; which can be found here&#xA;&lt;a href=&quot;http://peterodding.com/code/vim/tools&quot; rel=&quot;noreferrer&quot;&gt;http://peterodding.com/code/vim/tools&lt;/a&gt; and on &lt;a href=&quot;https://github.com/xolox/vim-tools&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;. It can convert markdown and html to vim's help format. Advertised features are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It can deal with complex HTML thanks to [BeautifulSoup] bs&lt;/li&gt;&#xA;&lt;li&gt;Automatically generates Vim help file tags for headings&lt;/li&gt;&#xA;&lt;li&gt;Generates table of contents from headings &amp;amp; tags&lt;/li&gt;&#xA;&lt;li&gt;Supports nested block structures like nested lists, preformatted blocks inside lists, etc.&lt;/li&gt;&#xA;&lt;li&gt;Compacts &amp;amp; expands list items based on average number of lines per list item&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;An older alternative is &lt;a href=&quot;https://github.com/mklabs/vim-markdown-helpfile&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/mklabs/vim-markdown-helpfile&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There has also been a discussion on &lt;a href=&quot;https://superuser.com/q/415470/generating-help-files-for-vim&quot;&gt;https://superuser.com/q/415470/generating-help-files-for-vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2017-12-09T13:35:22.117" LastActivityDate="2017-12-09T13:35:22.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14473" PostTypeId="1" CreationDate="2017-12-09T14:24:53.410" Score="3" ViewCount="2830" Body="&lt;p&gt;I am writing a lot of c++ in vim. I am looking for a way to compile and run the current project including all .cpp-Files in the directory that I am currently in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are already several threads about this topic, but they either treat one single .cpp-File or are using a Makefile for building and running. I would want to avoid Makefiles. my goal is to just run something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g++ *.cpp -o [Filename]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with a keybinding from Normalmode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anybody that could help me with this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tim&lt;/p&gt;&#xA;" OwnerUserId="15508" LastEditorUserId="28" LastEditDate="2017-12-10T07:16:16.587" LastActivityDate="2023-04-09T10:35:19.890" Title="Compiling and running multiple c++ files from vim" Tags="|vimrc|filetype-c++|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14474" PostTypeId="2" ParentId="10049" CreationDate="2017-12-09T18:55:45.823" Score="0" Body="&lt;p&gt;&lt;code&gt;:nnoremap &amp;gt;&amp;gt; I&amp;lt;tab&amp;gt;&amp;lt;esc&amp;gt;^&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:nnoremap &amp;lt;&amp;lt; :s/\v^\t//&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first one will insert a tab at the start of the current line, without breaking any other characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second one deletes the first character on the line &lt;em&gt;only if it's a tab&lt;/em&gt; (by searching and replacing it with nothing).&#xA;If you have &lt;code&gt;hlsearch&lt;/code&gt; on, you can add a &lt;code&gt;:noh&lt;/code&gt; call to the end of the second one to get rid of the highlighted residue.&lt;/p&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2017-12-09T18:55:45.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14475" PostTypeId="1" AcceptedAnswerId="14484" CreationDate="2017-12-09T19:40:48.077" Score="1" ViewCount="100" Body="&lt;p&gt;I've set up an autocmd to automatically create directories of the filepath I'm writing to: &lt;code&gt;au BufWritePre,FileWritePre * call &amp;lt;SID&amp;gt;EnsureDir(expand('&amp;lt;afile&amp;gt;:p:h'))&lt;/code&gt;. This prevents creating directories when I discard the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to continue to be able to use stdin, provide url filepaths, and read files into buffers from within vim as normal. But how can I use netrw's features yet prevent it's FileExplorer autocmd (on &lt;code&gt;VimEnter&lt;/code&gt;) to act on new/nonexistent, local files? What's a good approach to this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;hr/&gt;&lt;sup&gt;I hope it's clear what i'm asking. I'm suprised that I could not find a similar question. I read pi_netrw.txt, but could not find a method there. I use neovim version 0.2.2 on linux 4.14.3-1-ARCH.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="1027" LastEditorUserId="1027" LastEditDate="2017-12-09T20:07:26.613" LastActivityDate="2017-12-10T14:42:40.067" Title="How to make netrw ignore new local files?" Tags="|netrw|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14476" PostTypeId="1" AcceptedAnswerId="14477" CreationDate="2017-12-09T19:42:03.663" Score="2" ViewCount="1546" Body="&lt;p&gt;I find it obnoxious that highlight search stays on until you manually turn it off.  If I have edited some text after searching, 99% of the time that means I found what I was looking for and I don't need highlighting anymore.  How can I make it so highlighting turns off when I edit a file?  Here's what I tried, but for some reason it doesn't seem to have an effect.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup allfiles&#xA;    autocmd!&#xA;    autocmd TextChanged,TextChangedI * :nohl&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15080" LastActivityDate="2017-12-09T20:27:03.380" Title="How do you clear highlighting if you edit text?" Tags="|search|autocmd|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14477" PostTypeId="2" ParentId="14476" CreationDate="2017-12-09T20:27:03.380" Score="4" Body="&lt;p&gt;&lt;code&gt;:help noh&lt;/code&gt; explains why this isn't working.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  :noh[lsearch]     Stop the highlighting for the 'hlsearch' option.  It&#xA;        is automatically turned back on when using a search&#xA;        command, or setting the 'hlsearch' option.&#xA;        This command doesn't work in an autocommand, because&#xA;        the highlighting state is saved and restored when&#xA;        executing autocommands |autocmd-searchpat|.&#xA;        Same thing for when invoking a user function.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may be interested in the plugin &lt;a href=&quot;https://github.com/romainl/vim-cool&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/romainl/vim-cool&lt;/a&gt; .&#xA;The basic trick is to use &lt;code&gt;feedkeys&lt;/code&gt; and a &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mapping with &lt;code&gt;execute(&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;Plug&amp;gt;(StopHL) execute('nohlsearch')[-1]&#xA;fu! StopHL()&#xA;    if !v:hlsearch || mode() isnot 'n'&#xA;        return&#xA;    endif&#xA;    sil call feedkeys(&quot;\&amp;lt;Plug&amp;gt;(StopHL)&quot;, 'm')&#xA;endfu&#xA;au InsertEnter * call StopHL()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://github.com/romainl/vim-cool/issues/9#issue-196870339&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/romainl/vim-cool/issues/9#issue-196870339&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-12-09T20:27:03.380" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14478" PostTypeId="2" ParentId="14204" CreationDate="2017-12-10T05:57:36.433" Score="1" Body="&lt;p&gt;I use a non-zero value for &lt;code&gt;'scrolloff'&lt;/code&gt; so this one handles &lt;code&gt;&amp;amp;scrolloff &amp;gt; 0&lt;/code&gt; and has a few other small enhancements compared to DJMcMayhem's fine submission:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Incorporates a suggestion that I like from &lt;a href=&quot;https://vi.stackexchange.com/questions/14204/how-do-i-map-h-and-l-to-scroll-by-one-screen-if-the-cursor-in-already-on-the-top?newsletter=1&amp;amp;nlcode=701806%7c7f5c#comment24386_14205&quot;&gt;this comment&lt;/a&gt; to keep the cursor at the top/bottom of the screen after paging up/down.&lt;/li&gt;&#xA;&lt;li&gt;Uses &lt;code&gt;line()&lt;/code&gt; rather than &lt;code&gt;getcurpos()&lt;/code&gt; for consistency and to avoid any potential compatibility issues with &lt;code&gt;getcurpos()&lt;/code&gt; and earlier versions of Vim&lt;/li&gt;&#xA;&lt;li&gt;Uses the more Vim-like (to me anyways) &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;F&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;B&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; H line(&quot;.&quot;) - &amp;amp;scrolloff == line(&quot;w0&quot;) ? &quot;\&amp;lt;C-B&amp;gt;H&quot; : &quot;H&quot;&#xA;nnoremap &amp;lt;expr&amp;gt; L line(&quot;.&quot;) + &amp;amp;scrolloff == line(&quot;w$&quot;) ? &quot;\&amp;lt;C-F&amp;gt;L&quot; : &quot;L&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly for &lt;code&gt;xnoremap&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2017-12-10T05:57:36.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14479" PostTypeId="2" ParentId="14465" CreationDate="2017-12-10T06:29:10.570" Score="1" Body="&lt;p&gt;Try &lt;a href=&quot;https://github.com/ggvgc/vim-fuzzysearch&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ggvgc/vim-fuzzysearch&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then simply...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap / :FuzzySearch&amp;lt;CR&amp;gt;&#xA;let g:fuzzysearch_prompt = '/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;/&lt;/code&gt; will take you to a prompt where you enter your pattern and it all looks just like normal Vim. I believe  From there &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; will work without modification. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If they aren't already enabled then &lt;code&gt;set incsearch&lt;/code&gt; and, possibly, &lt;code&gt;set hlsearch&lt;/code&gt; as they enhance that &quot;fuzzy search feeling&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can optionally tune some other things per your preferences with these settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g:fuzzysearch_hlsearch = 1&#xA;g:fuzzysearch_ignorecase = 1   &#xA;g:fuzzysearch_max_history = 30&#xA;g:fuzzysearch_match_spaces = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the core functionality of this plugin is pretty simple. It just alters your search term so non-space characters (if &lt;code&gt;g:fuzzysearch_match_spaces&lt;/code&gt; is 1 then &lt;em&gt;any&lt;/em&gt; characters) are allowed between the characters &lt;em&gt;you&lt;/em&gt; enter and submits the updated pattern to native Vim search. But I just tried it and it felt like a decent approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To go back to native search &lt;code&gt;nunmap /&lt;/code&gt;. You can map the &lt;code&gt;nnoremap&lt;/code&gt; and &lt;code&gt;nunmap&lt;/code&gt; commands to Normal mode shortcuts to make it really convenient to toggle between the search modes.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-12-10T06:42:00.440" LastActivityDate="2017-12-10T06:42:00.440" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14480" PostTypeId="2" ParentId="14473" CreationDate="2017-12-10T09:27:22.623" Score="1" Body="&lt;p&gt;Sorry, I've misread your request. However, if editing a source file means, that only a single binary has to be updated my answer below is helpful. If your project has grown to consist of several binaries which depend on shared source code, this definitely sounds like you need a build tool and I will give you a quick start in my new answer:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Build Tool: CMake&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you do not like GNU Make, or the Makefiles in particular, consider CMake as tool to generate Makefiles for you. To make it more clear: vim is not a build tool!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple setup with CMake would be to create the file &lt;code&gt;CMakeLists.txt&lt;/code&gt; in your project folder&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmake_minimum_required (VERSION 3.0)&#xA;project (Tutorial)&#xA;add_executable(binaryname1 main1.cpp)&#xA;add_executable(binaryname2 main2.cpp)&#xA;...&#xA;add_executable(binarynameN mainN.cpp)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or if your binaries have the same name as your cpp files and they are located in the main folder, you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;file( GLOB APP_SOURCES *.cpp )&#xA;foreach( testsourcefile ${APP_SOURCES} )&#xA;    string( REPLACE &quot;.cpp&quot; &quot;&quot; testname ${testsourcefile} )&#xA;    add_executable( ${testname} ${testsourcefile} )&#xA;endforeach( testsourcefile ${APP_SOURCES} )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some build tools do not support wildcards to detect source files: &lt;a href=&quot;http://mesonbuild.com/FAQ.html#why-cant-i-specify-target-files-with-a-wildcard&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://mesonbuild.com/FAQ.html#why-cant-i-specify-target-files-with-a-wildcard&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create the Makefile with &lt;code&gt;$ cmake .&lt;/code&gt;. The created Makefile compiles all of your binaries with one invocation of &lt;code&gt;$ make&lt;/code&gt; or within vim with &lt;code&gt;:make&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And as a beginner you should be aware of the following: you do not need to re-run cmake as long as you do not change the file &lt;code&gt;CMakeLists.txt&lt;/code&gt;. For example, editing a shared source file in vim and simply calling &lt;code&gt;:make&lt;/code&gt; is sufficient to update all of your binaries. CMake has automatically detected the dependencies and creates a sensible Makefile, so that the Makefile targets will be considered as out-of-date by your file change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternative build tools:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://mesonbuild.com/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;meson&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://bazel.build/&quot; rel=&quot;nofollow noreferrer&quot;&gt;bazel&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.scons.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;scons&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://premake.github.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;premake&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Old answer:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Plugin &lt;em&gt;SingleCompile&lt;/em&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you do not mind using plugins, there are also several ones for the situation where the compilation is straightforward (no configuration of linking, includepaths, ...). One to consider is called &lt;em&gt;SingleCompile&lt;/em&gt; and is available from &lt;a href=&quot;http://singlecompile.topbug.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://singlecompile.topbug.net/&lt;/a&gt; and on &lt;a href=&quot;https://github.com/xuhdev/SingleCompile&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;. The suggested mappings are&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F9&amp;gt; :SCCompile&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;F10&amp;gt; :SCCompileRun&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Alternatives&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://wolfgangmehner.github.io/vim-plugins/csupport.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;c-support&lt;/a&gt; by W.Mehner: &lt;code&gt;F9&lt;/code&gt; by &lt;a href=&quot;https://wolfgangmehner.github.io/vim-plugins/doc/csupport.html#csupport-hotkeys&quot; rel=&quot;nofollow noreferrer&quot;&gt;default&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/thinca/vim-quickrun&quot; rel=&quot;nofollow noreferrer&quot;&gt;quickrun&lt;/a&gt; by Thinca&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/LucHermitte/vim-build-tools-wrapper&quot; rel=&quot;nofollow noreferrer&quot;&gt;build-tools-wrapper&lt;/a&gt; by Luc Hermitte (author of cpp plugin &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-cpp&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you like to run and interact with your compiled program see this discussion on reddit &lt;a href=&quot;https://www.reddit.com/r/vim/comments/6vfrrz/plugin_to_compile_and_run_file/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.reddit.com/r/vim/comments/6vfrrz/plugin_to_compile_and_run_file/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-04-03T12:28:36.940" LastActivityDate="2018-04-03T12:28:36.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14481" PostTypeId="1" AcceptedAnswerId="14490" CreationDate="2017-12-10T11:09:09.977" Score="2" ViewCount="925" Body="&lt;p&gt;In vim I need to glance over a folded json text and see the value of a key as the folds title?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking through the help I saw how to fold by reqular expression though not how to change the folds title.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What suggestions do you have?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ikmj8.png&quot; alt=&quot;Screenshot&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Screenshot of  result thanks to @Mass solution&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Ie1bT.png&quot; alt=&quot;Screenshot&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="15513" LastEditorUserId="15513" LastEditDate="2017-12-11T06:50:01.787" LastActivityDate="2017-12-11T14:04:52.193" Title="How to change the fold title in vim" Tags="|folding|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14482" PostTypeId="1" AcceptedAnswerId="14485" CreationDate="2017-12-10T11:42:50.330" Score="3" ViewCount="4255" Body="&lt;p&gt;I would like to know how I can select text character by character, in visual mode, using a combination of shift+direction without using the mouse.&#xA;Actually, with Shit + Left/Right gvim selects the text word by word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in the following screenshot, I am able to select the text &lt;strong&gt;std::cout&lt;/strong&gt; using the mouse, left button click on the start of text and then shifting the mouse cursor to the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E9zWN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E9zWN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I replicate this behavior with just using the keyboard ?&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="51" LastEditDate="2017-12-10T11:52:04.940" LastActivityDate="2017-12-10T16:28:20.213" Title="How to select text character by character with shift and directions?" Tags="|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14483" PostTypeId="2" ParentId="14481" CreationDate="2017-12-10T12:18:44.833" Score="1" Body="&lt;p&gt;Vim will always show the beginning of the first line as hint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You wrote, that you use JSON. JSON is a pure data format, if it was something else, I would have advised, to use a comment at the beginning of the fold, so that you could see it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only possible workaround, that I see, would be to follow the advise given &lt;a href=&quot;https://stackoverflow.com/questions/244777/can-comments-be-used-in-json&quot;&gt;here&lt;/a&gt;, so that the first field in an entry contains the desired string. If you fold then, it would result in what you are looking for. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this may not be what you are looking for, because you will need some kind of filter, to prepare your json file.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastEditorUserId="7267" LastEditDate="2017-12-11T14:04:52.193" LastActivityDate="2017-12-11T14:04:52.193" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14484" PostTypeId="2" ParentId="14475" CreationDate="2017-12-10T14:42:40.067" Score="0" Body="&lt;p&gt;When testing, I could not disable plugins. I forgot about a file in &lt;code&gt;/usr/local/share/nvim/site/...&lt;/code&gt; It turns out that I silently ran a &lt;code&gt;bwipeout&lt;/code&gt; and &lt;code&gt;edit&lt;/code&gt; when incorrectly handling &lt;code&gt;&amp;lt;amatch&amp;gt;&lt;/code&gt; on a &lt;code&gt;BufNewFile&lt;/code&gt; autocmd. I simplified my knotty setup and included a simple &lt;code&gt;isdirectory()&lt;/code&gt; check.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;netrwPlugin.vim behaves as expected (at least for my usage). sorry.&lt;/p&gt;&#xA;" OwnerUserId="1027" LastActivityDate="2017-12-10T14:42:40.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14485" PostTypeId="2" ParentId="14482" CreationDate="2017-12-10T16:28:20.213" Score="5" Body="&lt;p&gt;&lt;strong&gt;short answer:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;W&lt;/kbd&gt; selects &lt;code&gt;std::cout&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to select character by character, just&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;v&lt;/kbd&gt; and then &lt;kbd&gt;h&lt;/kbd&gt; / &lt;kbd&gt;l&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;long answer:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;v&lt;/kbd&gt; enters &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html&quot; rel=&quot;noreferrer&quot;&gt;visual mode&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;W&lt;/kbd&gt; &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html&quot; rel=&quot;noreferrer&quot;&gt;motion&lt;/a&gt; to select &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#W&quot; rel=&quot;noreferrer&quot;&gt;WORD&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to select character by character, just&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;v&lt;/kbd&gt;  enters visual mode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;h&lt;/kbd&gt; / &lt;kbd&gt;l&lt;/kbd&gt; &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_02.html#02.3&quot; rel=&quot;noreferrer&quot;&gt;motion by character&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The answer assumes, that you are not using any plugins and that they do not define additional motions)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimcasts.org&quot; rel=&quot;noreferrer&quot;&gt;Vimcasts&lt;/a&gt; has excellent videos, that basically explain everything.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-12-10T16:28:20.213" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14486" PostTypeId="1" AcceptedAnswerId="14500" CreationDate="2017-12-10T16:38:40.920" Score="7" ViewCount="20868" Body="&lt;p&gt;Today I was trying to copy and paste multiple lines in visual block mode and found this excellent &lt;a href=&quot;https://i.stack.imgur.com/AIg6y.gif&quot; rel=&quot;noreferrer&quot;&gt;answer&lt;/a&gt; on StackOverflow showing how to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is a gif of what I was trying to accomplish:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AIg6y.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AIg6y.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I tried this in my vim, it didn't work. But after I remove the &lt;code&gt;set clipboard=unnamed&lt;/code&gt; from my vimrc, pasting a block worked flawlessly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what the command &lt;code&gt;set clipboard=unnamed&lt;/code&gt; does?&lt;/p&gt;&#xA;" OwnerUserId="15518" LastEditorUserId="7267" LastEditDate="2017-12-11T01:24:53.087" LastActivityDate="2020-02-24T15:19:43.357" Title="What does it mean to set clipboard=unnamed?" Tags="|visual-block|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14487" PostTypeId="2" ParentId="6258" CreationDate="2017-12-10T17:17:14.000" Score="1" Body="&lt;p&gt;I can't explain this but if you put Netrw in tree style with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_liststyle=3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;netrw don't close the current buffer, it open in a new buffer in the same window when you use &lt;code&gt;:Explore&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11113" LastActivityDate="2017-12-10T17:17:14.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14488" PostTypeId="2" ParentId="7665" CreationDate="2017-12-10T17:41:38.570" Score="19" Body="&lt;p&gt;Use &lt;code&gt;:e %:h&amp;lt;filename&amp;gt;&lt;/code&gt;, or specifically for your question &lt;code&gt;:e %:hb.pl&lt;/code&gt;. Individually these tokens mean&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:e&lt;/code&gt;          edit, but you could use :tabnew or :split etc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%&lt;/code&gt;           the current file path&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h&lt;/code&gt;          'head', which in this usage is the directory of the currently open file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;filename&amp;gt;&lt;/code&gt;  the relative path of the file you want to open&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also hit &lt;code&gt;tab&lt;/code&gt; after typing &lt;code&gt;:h&lt;/code&gt; for a list of filenames at that path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For further reading, execute &lt;code&gt;:help expand()&lt;/code&gt; in vi(m) for more about token expansion.&lt;/p&gt;&#xA;" OwnerUserId="15520" LastEditorUserId="15520" LastEditDate="2017-12-14T00:06:27.207" LastActivityDate="2017-12-14T00:06:27.207" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14489" PostTypeId="1" CreationDate="2017-12-10T18:44:41.523" Score="2" ViewCount="985" Body="&lt;p&gt;I want to disable &lt;code&gt;cursorline&lt;/code&gt; when leaving the NERD tree window and enable it when entering the window again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following setting works fine when using &lt;code&gt;&amp;lt;C-w&amp;gt;w&lt;/code&gt; or similar, but not when &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;. Hitting &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; opens the file in other window, moves to it, and &lt;code&gt;cursorline&lt;/code&gt; remains visible. How can I make it work?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup Cursorline&#xA;  au!&#xA;  au WinEnter * if exists('t:NERDTreeBufName') &amp;amp;&amp;amp; bufname(&quot;%&quot;) == t:NERDTreeBufName | setlocal cursorline | endif&#xA;  au WinLeave * setlocal nocursorline&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Environment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- vim&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 14 2017 20:07:29)&#xA;Included patches: 1-1297&#xA;- NERDTree&#xA;master (461ea6d2d854100f7954c21453bb3b926ad930e6)&#xA;- OS&#xA;Linux&#xA;- Terminal&#xA;mintty on Windows&#xA;GNU screen&#xA;TERM=screen-256color-bce&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.vimrc (simplified for testing):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;syntax enable&#xA;&#xA;set runtimepath^=~/git/nerdtree/&#xA;&#xA;autocmd! BufEnter * call ToggleCursorLine()&#xA;&#xA;function! ToggleCursorLine()&#xA;  if (bufname(&quot;%&quot;) =~ &quot;NERD_Tree_&quot;)&#xA;    setlocal cursorline&#xA;  else&#xA;    setlocal nocursorline&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15522" LastEditorUserId="15522" LastEditDate="2017-12-11T19:55:58.403" LastActivityDate="2017-12-17T01:44:57.937" Title="Disable cursorline when leaving NERD tree window" Tags="|plugin-nerdtree|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14490" PostTypeId="2" ParentId="14481" CreationDate="2017-12-10T19:55:28.647" Score="5" Body="&lt;p&gt;No problem.  Here is a basic implementation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldtext=FoldText()&#xA;&#xA;function! FoldText()&#xA;  let l:fs = match(getline(v:foldstart, v:foldend), '&quot;label&quot;:')&#xA;  if l:fs &amp;lt; 0&#xA;    return foldtext()&#xA;  endif&#xA;  let l:label = matchstr(getline(v:foldstart + l:fs),&#xA;        \ '&quot;label&quot;:\s\+&quot;\zs[^&quot;]\+\ze&quot;')&#xA;  let l:ft = substitute(foldtext(), ': \zs.\+', l:label, '')&#xA;  return l:ft&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-12-10T19:55:28.647" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14491" PostTypeId="1" AcceptedAnswerId="14529" CreationDate="2017-12-10T19:58:51.190" Score="7" ViewCount="709" Body="&lt;p&gt;This one is driving me mad. I'm using XTerm(330) and the latest vim 8.0.1365 (on FreeBSD).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes, not always, about 1 in 5, when I open a file with vim, a funny line is inserted above line 1. After a lot of head scratching, I realized it is the last line I deleted in a previous session. In other words, it looks like &lt;code&gt;&quot;&quot;P&lt;/code&gt; (paste the &lt;code&gt;&quot;&lt;/code&gt; register) is run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some more investigation, I found this only happens when I have &lt;code&gt;*sunKeyboard: true&lt;/code&gt; set in the XTerm resources, and when I use a rendered font, such as &lt;code&gt;-fa &quot;DejaVu Sans Mono:size=24&quot;&lt;/code&gt;. (I told you it was strange, didn't I?). I have no &lt;code&gt;.vimrc&lt;/code&gt; and no &lt;code&gt;.vim&lt;/code&gt; directory, to avoid any plugin playing tricks on me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can reproduce the effect somewhat with the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;rm -f .viminfo; echo inserted &amp;gt;bar; echo x &amp;gt;baz&#xA;vim -c d -c wq bar&#xA;echo '*sunKeyboard: true' &amp;gt; XTerm&#xA;export XAPPLRESDIR=$PWD&#xA;for i in 1 2 3 4 5 6; do&#xA;   xterm -fa &quot;DejaVu Sans Mono:size=24&quot; -e vim baz&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will create the necessary files, place &lt;code&gt;inserted&lt;/code&gt; in the &lt;code&gt;&quot;&lt;/code&gt; register and invoke vim a few times. If you see a one line file with &lt;code&gt;x&lt;/code&gt; in the first line, all is fine; enter &lt;code&gt;q&lt;/code&gt; for the next invocation. If however you see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inserte2&#xA;x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you have reproduced the problem. Note also that the last character of line 1 has been replaced by &lt;code&gt;2&lt;/code&gt;. This seems to come from the &lt;code&gt;.&lt;/code&gt; register. Here are the registers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:reg&#xA;--- Registers ---&#xA;&quot;&quot;   inserted^J&#xA;&quot;1   inserted^J&#xA;&quot;.   2&#xA;&quot;%   baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Trying the script several times, can you reproduce the problem? Be sure to move &lt;code&gt;.vimrc&lt;/code&gt; and &lt;code&gt;.vim&lt;/code&gt; temporarily out of the way.&lt;/li&gt;&#xA;&lt;li&gt;If so, can you tell me what is going on here?&lt;/li&gt;&#xA;&lt;li&gt;Any suggestions how to get to the bottom of this?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looks like I'm not the only one: &lt;a href=&quot;https://github.com/vim/vim/issues/2238&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/issues/2238&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2347" LastEditorUserId="2347" LastEditDate="2018-02-14T19:54:50.910" LastActivityDate="2018-02-14T19:54:50.910" Title="Strange vim/xterm interaction: auto-insertion of `&quot;` register when opening file" Tags="|register|startup|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14492" PostTypeId="1" AcceptedAnswerId="14499" CreationDate="2017-12-10T22:53:38.060" Score="2" ViewCount="684" Body="&lt;p&gt;I have a quite large directory that I frequently need to search through for specific lines. Currently I simply use the built in &lt;code&gt;grep&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vim &quot;search&quot; **/*.cpp | cw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that going through all files in the repo takes ~1-2 minutes normally due to having to the OS globbing all files, and it really slows down development. On the command line, I can store file paths in a file and use them without having to reindex everytime:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; find . -type f -name &quot;*.cpp&quot; &amp;gt; cppfiles&#xA;&amp;gt; grep &quot;search&quot; `cat cppfiles` # possible to reuse the index files for multiple searches. Goes _a lot_ faster.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I do the same thing with the built-in search?&lt;/p&gt;&#xA;" OwnerUserId="6957" LastEditorUserId="6957" LastEditDate="2017-12-11T00:11:16.730" LastActivityDate="2017-12-11T15:30:37.537" Title="Is it possible to use vimgrep with file paths from a file?" Tags="|search|vimgrep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14493" PostTypeId="1" CreationDate="2017-12-11T05:55:51.137" Score="1" ViewCount="643" Body="&lt;p&gt;I do a lot of programming in Ruby, and a common edit suggested by Rubocop (a linter) is to reformat an array of symbols&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[:foo, :bar, :baz]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as a &lt;a href=&quot;http://ruby-doc.org/core-2.4.0/doc/syntax/literals_rdoc.html#label-Percent+Strings&quot; rel=&quot;nofollow noreferrer&quot;&gt;percent string&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%i[foo bar baz]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm looking for a quick way to remove all colons and commas between the brackets without affecting text on the same line outside the brackets. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to specify a search query that will ignore matches outside of a given set of delimiters? I tried tossing the delimiters into the search query, but any way I can think of to structure the regular expression winds up consuming the other matches.&lt;/p&gt;&#xA;" OwnerUserId="2593" LastActivityDate="2020-04-02T15:28:10.897" Title="Search query to match multiple instances on a line, only between certain delimiters?" Tags="|regular-expression|search|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14494" PostTypeId="2" ParentId="14493" CreationDate="2017-12-11T10:25:59.017" Score="1" Body="&lt;p&gt;This can be solved by using two substitutions together.&#xA;The second one will only match, if the first one matched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you get errors on the second one, you can use &lt;code&gt;/ge&lt;/code&gt; so that errors are ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%s/\v[:(\w+),?]/\1/g | %s/\v(\[.*\])/%i\1/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Short breakdown:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\v&lt;/code&gt;              -  &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/magic&quot; rel=&quot;nofollow noreferrer&quot;&gt;very magic mode&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;[:(\w+),?]/\1/g&lt;/code&gt; - the substitution  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;,?&lt;/code&gt;              - match the &lt;code&gt;,&lt;/code&gt; zero or once  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;|&lt;/code&gt;               - concatenate another command; executed, if the first was sucessful  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\1&lt;/code&gt;              - references the first match group&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-12-11T10:25:59.017" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14495" PostTypeId="1" AcceptedAnswerId="14498" CreationDate="2017-12-11T13:49:34.687" Score="1" ViewCount="295" Body="&lt;p&gt;In short: how do I define a regex that matches &lt;code&gt;'iskeyword'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My initial thought was that &lt;code&gt;match(str, '\w*')&lt;/code&gt; would match an arbitrary number of keyword characters in &lt;code&gt;str&lt;/code&gt;, but it really only matches to a predefined list (as confirmed by &lt;code&gt;:h \w&lt;/code&gt;). Of course, I could manually make up a target with &lt;code&gt;[]&lt;/code&gt;, but that does not feel right. Am I missing something here?&lt;/p&gt;&#xA;" OwnerUserId="8061" LastEditorUserId="1841" LastEditDate="2017-12-11T13:56:55.883" LastActivityDate="2017-12-11T13:57:49.923" Title="Character class to match &quot;iskeyword&quot; characters" Tags="|regular-expression|keyword|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14496" PostTypeId="5" CreationDate="2017-12-11T13:51:04.930" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27iskeyword%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'iskeyword'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#word&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h word&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="1841" LastEditDate="2017-12-13T14:09:14.743" LastActivityDate="2017-12-13T14:09:14.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14497" PostTypeId="4" CreationDate="2017-12-11T13:51:04.930" Score="0" Body="Keywords are sequences of characters that are included in the 'iskeyword' option.&#xD;&#xA;&#xD;&#xA;They are commonly referred to as word." OwnerUserId="8061" LastEditorUserId="1841" LastEditDate="2017-12-13T14:07:34.533" LastActivityDate="2017-12-13T14:07:34.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14498" PostTypeId="2" ParentId="14495" CreationDate="2017-12-11T13:52:47.350" Score="4" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2fcharacter-classes&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /character-classes&lt;/code&gt;&lt;/a&gt; you are looking for &lt;code&gt;\k&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    magic   nomagic matches ~&#xA;/\k \k      \k      keyword character (see 'iskeyword' option)&#xA;/\K \K      \K      like &quot;\k&quot;, but excluding digits&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also &lt;code&gt;\w&lt;/code&gt; matches &quot;word&quot; characters (i.e. &lt;code&gt;[0-9A-Za-z_]&lt;/code&gt;) as in opposition to &quot;WORD&quot; characters. The difference is explained in &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#word&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h word&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-12-11T13:57:49.923" LastActivityDate="2017-12-11T13:57:49.923" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14499" PostTypeId="2" ParentId="14492" CreationDate="2017-12-11T15:30:37.537" Score="2" Body="&lt;p&gt;On unix like systems, you can use backticks directly in the vimgrep command (in any command that takes file names)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep &quot;search&quot; `cat cppfiles` | cw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is vim-only way by loading the cpp files into the argument list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%argdelete&#xA;:argadd **/*.cpp&#xA;:vimgrep &quot;search&quot; ##&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;##&lt;/code&gt; is a special notation for the argument list.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-12-11T15:30:37.537" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14500" PostTypeId="2" ParentId="14486" CreationDate="2017-12-11T15:32:17.730" Score="2" Body="&lt;p&gt;This question is answered at &lt;a href=&quot;https://stackoverflow.com/questions/30691466/what-is-difference-between-vims-clipboard-unnamed-and-unnamedplus-settings&quot;&gt;stackoverflow&lt;/a&gt;. It controls, how the clipboard register of vim is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could always just &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;clipboard&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'clipboard'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-12-11T15:32:17.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14501" PostTypeId="2" ParentId="14467" CreationDate="2017-12-11T15:52:12.460" Score="0" Body="&lt;p&gt;&lt;code&gt;autocmd BufRead *.pl map &amp;lt;F5&amp;gt; :exe ':silent !perl %'&amp;lt;CR&amp;gt;:redr!&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This defines an &lt;a href=&quot;https://www.google.de/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0ahUKEwj4hrmgp4LYAhVIORoKHZixA1MQFggnMAA&amp;amp;url=http%3A%2F%2Fvimdoc.sourceforge.net%2Fhtmldoc%2Fautocmd.html&amp;amp;usg=AOvVaw12cDtpSqZ40geXlyYoNRx2&quot; rel=&quot;nofollow noreferrer&quot;&gt;autocmd&lt;/a&gt; for perl files.&#xA;If &lt;kbd&gt;F5&lt;/kbd&gt; is pressed, the current file will be sent to the perl interpreter, afterwards the buffer is redrawn, so you will not see any output.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-12-11T15:52:12.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14502" PostTypeId="1" CreationDate="2017-12-11T16:35:09.740" Score="0" ViewCount="244" Body="&lt;p&gt;I'm looking for a dictionary (as in the wikitionary; not the data structure)&#xA;plugin for vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One where I could put my cursor on &lt;code&gt;pyrolysis&lt;/code&gt;, type a command such as&#xA;&lt;code&gt;:Dictionary&lt;/code&gt; and get something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noun, Chemistry.  &#xA;1.  &#xA;the subjection of organic compounds to very high temperatures.  &#xA;2.  &#xA;the resulting decomposition.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have found this &lt;a href=&quot;https://github.com/itchyny/dictionary.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;dictionary.vim&lt;/a&gt;, but it provides no detailed instructions on how to install it.&lt;/p&gt;&#xA;" OwnerUserId="10216" LastEditorUserId="1841" LastEditDate="2017-12-11T16:45:37.360" LastActivityDate="2017-12-17T03:55:23.220" Title="Dictionary (as in wikitionary) plugin indication" Tags="|word-processing|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14503" PostTypeId="2" ParentId="14489" CreationDate="2017-12-11T16:44:02.793" Score="0" Body="&lt;p&gt;If you would like to have this functionality, please but the following code in your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufEnter * call ToggleCursorLine()&#xA;&#xA;function! ToggleCursorLine()&#xA;    if (bufname(&quot;%&quot;) =~ &quot;NERD_Tree_&quot;)&#xA;        setlocal cursorline&#xA;    else&#xA;        setlocal nocursorline&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This creates a function, that will be executed via autocommand on entering any buffer and set cursorline accordingly.&#xA;Tested on Mac with vim 8.0.237 in iterm 3.1.5.b2.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastEditorUserId="7267" LastEditDate="2017-12-11T18:49:57.037" LastActivityDate="2017-12-11T18:49:57.037" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14504" PostTypeId="2" ParentId="12528" CreationDate="2017-12-11T18:24:06.247" Score="5" Body="&lt;p&gt;You should use the Plugin &lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;noreferrer&quot;&gt;AsyncRun&lt;/a&gt;.&#xA;It allows the execution of external commands in the background as well as loading output back into a buffer or the quickfixlist. And it works well on Windows.&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-12-11T18:24:06.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14506" PostTypeId="1" AcceptedAnswerId="14508" CreationDate="2017-12-12T01:47:14.527" Score="0" ViewCount="56" Body="&lt;p&gt;I am trying to define a map to define a key to sort a file based on a pattern, eg&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;so :sort i /ap\s\+&amp;lt;leader&amp;gt;/&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I execute ,so the sort is limited to the first 6 chars of the pattern, ie the picture. I guess there's a limit on the pattern size but can anyone tell me why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/03yno.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/03yno.png&quot; alt=&quot;,so not using full pattern&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could call the external sort but would prefer not to.&lt;/p&gt;&#xA;" OwnerUserId="1313" LastActivityDate="2017-12-12T08:20:08.120" Title="nmap seems to have a limit on text after a command eg sort i /pattern/" Tags="|vimscript|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14507" PostTypeId="2" ParentId="14502" CreationDate="2017-12-12T07:35:09.510" Score="1" Body="&lt;p&gt;Put your cursor on a word then do...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r http://services.aonaware.com/DictService/DictService.asmx/De‌​fine?word=&amp;lt;cword&amp;gt; | %s/&amp;lt;\_.\{-}&amp;gt;//g | %s/^M//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll want to do a little bit more sophisticated post-processing to remove the XML. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was just fooling around with this at first. It started as an exercise for myself to see how quickly I could come up with something.&lt;sup&gt;1&lt;/sup&gt; But it actually, generally works and it demonstrates a couple less familiar features (&lt;code&gt;netrw&lt;/code&gt; and &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;) so I figured I'd post. A little better filtering and you could have something. Here's a sample using exactly the command above...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;playful&#xA;&#xA;  playful&#xA;&#xA;    gcide&#xA;    The Collaborative International Dictionary of English v.0.44&#xA;&#xA;  Playful \Play&quot;ful\, a.&#xA;Sportive; gamboling; frolicsome; indulging a sportive fancy;&#xA;humorous; merry; as, a playful child; a playful writer. --&#xA;{Play&quot;ful*ly}, adv. -- {Play&quot;ful*ness}, n.&#xA;[1913 Webster]&#xA;&#xA;&#xA;  playful&#xA;&#xA;    wn&#xA;    WordNet (r) 2.0&#xA;&#xA;  playful&#xA; adj : full of fun and high spirits; &quot;playful children sjust let&#xA;       loose from school&quot; [ant: {unplayful}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1. 15-20 minutes, most of which was spent searching for a free, simple, usable API.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-12-12T15:02:29.820" LastActivityDate="2017-12-12T15:02:29.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14508" PostTypeId="2" ParentId="14506" CreationDate="2017-12-12T08:20:08.120" Score="2" Body="&lt;p&gt;There is no limit to a pattern size and your mapping does exactly what you asked it to do. Your problem is that you didn't ask it to do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your command is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;so :sort i /ap\s\+&amp;lt;leader&amp;gt;/&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What we can see in your screenshot is that when you pressed &lt;code&gt;&amp;lt;leader&amp;gt;so&lt;/code&gt; vim executed the mapping until it met &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; where it put a &lt;code&gt;,&lt;/code&gt; instead. This is pretty normal you probably have &lt;code&gt;let mapleader = &quot;,&quot;&lt;/code&gt; somewhere in your &lt;code&gt;vimrc&lt;/code&gt;. After that, the mapping continued with &lt;code&gt;/&lt;/code&gt; and you can't see &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; since it is the keypress which validates the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your problem is not a limit in the pattern it is that the command you want to map doesn't work properly. To solve that you should&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Take your pattern &lt;code&gt;/ap\s\+&amp;lt;leader&amp;gt;/&lt;/code&gt; and change it until it matches what you want (simply start a search with &lt;code&gt;/&lt;/code&gt; and modify the pattern until you are satisfied&lt;/li&gt;&#xA;&lt;li&gt;Once your pattern works use the command &lt;code&gt;:sort i /newpattern/&lt;/code&gt; from Vim command line to be sure it works properly.&lt;/li&gt;&#xA;&lt;li&gt;Finally, when you command works you can create your mapping. (Note that I would advise using &lt;code&gt;nnoremap&lt;/code&gt; instead of &lt;code&gt;nmap&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-12-12T08:20:08.120" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14509" PostTypeId="1" AcceptedAnswerId="14512" CreationDate="2017-12-12T13:44:34.823" Score="1" ViewCount="759" Body="&lt;p&gt;I've noticed that after I use &lt;code&gt;:vs &amp;lt;file&amp;gt;&lt;/code&gt; or &lt;code&gt;:sp &amp;lt;file&amp;gt;&lt;/code&gt; I have no buffer variables defined for this buffer. So I get &lt;code&gt;E121: Undefined variable: b:Var&lt;/code&gt; after &lt;code&gt;:echo b:Var&lt;/code&gt; there. But in the first opened buffer I have no errors. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="14989" LastActivityDate="2017-12-13T13:37:41.197" Title="Buffer variable is not set after :vs &lt;file&gt;" Tags="|vimscript|split|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14510" PostTypeId="2" ParentId="14114" CreationDate="2017-12-12T13:48:23.580" Score="6" Body="&lt;p&gt;Based on answers above I've created a &lt;a href=&quot;https://github.com/ferrine/md-img-paste.vim&quot; rel=&quot;noreferrer&quot;&gt;Plugin&lt;/a&gt; for vim solving my problem for macos and possibly for linux. Hope you'll find this plugin useful. I also appreciate any contributions and feature requests.&lt;/p&gt;&#xA;" OwnerUserId="14989" LastActivityDate="2017-12-12T13:48:23.580" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14511" PostTypeId="2" ParentId="14509" CreationDate="2017-12-12T13:52:48.313" Score="3" Body="&lt;p&gt;The doc (&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#b%3avar&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h b:var&lt;/code&gt;&lt;/a&gt;) says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A variable name that is preceded with &quot;b:&quot; is local to the current buffer.&#xA;  Thus you can have several &quot;b:foo&quot; variables, one for each buffer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When you create a variable prefixed with &lt;code&gt;b:&lt;/code&gt; it is local to a buffer so if you create a new buffer the variable will not exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a variable accessible from every buffer you can use &lt;code&gt;g:&lt;/code&gt; or &lt;code&gt;s:&lt;/code&gt; if you are in a script. See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#internal-variables&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h internal-variables&lt;/code&gt;&lt;/a&gt; for a description of the different possible scopes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;There are several name spaces for variables.  Which one is to be used is&#xA;specified by what is prepended:&#xA;&#xA;                (nothing) In a function: local to a function; otherwise: global&#xA;buffer-variable    b:     Local to the current buffer.&#xA;window-variable    w:     Local to the current window.&#xA;tabpage-variable   t:     Local to the current tab page.&#xA;global-variable    g:     Global.&#xA;local-variable     l:     Local to a function.&#xA;script-variable    s:     Local to a |:source|'ed Vim script.&#xA;function-argument  a:     Function argument (only inside a function).&#xA;vim-variable       v:     Global, predefined by Vim.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-12-12T13:58:01.947" LastActivityDate="2017-12-12T13:58:01.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14512" PostTypeId="2" ParentId="14509" CreationDate="2017-12-12T14:31:27.263" Score="3" Body="&lt;p&gt;The important thing to understand is that buffer variables are not inherited from the buffer from where you load/create the new buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Buffer variables can be created manually, but the typical scenario is that a buffer related autocommand will create the variable. In other words, most of the time it's done automatically in ftplugins or in project management plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Corollary: never define buffer local variable in &lt;code&gt;plugin/&lt;/code&gt; files, or in your &lt;code&gt;.vimrc&lt;/code&gt; -- unless it's done from a function triggered from a buffer related autocommand. This is the same with buffer local mappings, commands, abbreviations...&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-12-13T13:37:41.197" LastActivityDate="2017-12-13T13:37:41.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14513" PostTypeId="1" AcceptedAnswerId="14515" CreationDate="2017-12-12T15:18:33.847" Score="1" ViewCount="600" Body="&lt;p&gt;I noticed using evim that when I press Shift key plus any direction key (so &lt;code&gt;&amp;lt;S-Up&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;S-Down&amp;gt;&lt;/code&gt; etc., the editor automatically switches to insert-select mode, letting me select the text block with direction keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I think this mode is more handy than typing ESC, v, etc. each time, I tried to replicate this behavior using shortcuts with gvim, for example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap &amp;lt;S-Up&amp;gt; &amp;lt;Esc&amp;gt;:v&amp;lt;Up&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;without success. No way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I replicate this evim's behavior in gvim ?&#xA;Is this possible ?&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="11477" LastEditDate="2017-12-12T19:35:38.180" LastActivityDate="2017-12-12T19:35:38.180" Title="Linux gvim - toggle/retain insert-select mode while Shift key is pressed" Tags="|gvim|visual-mode|insert-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14514" PostTypeId="2" ParentId="14513" CreationDate="2017-12-12T15:27:57.577" Score="2" Body="&lt;p&gt;You need to remove &lt;code&gt;:&lt;/code&gt; in &lt;code&gt;:v&lt;/code&gt; because you don't want to use the command &lt;code&gt;:v&lt;/code&gt; which is the negation of &lt;code&gt;:g&lt;/code&gt;, you want to press &lt;kbd&gt;v&lt;/kbd&gt; in normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap &amp;lt;S-Up&amp;gt; &amp;lt;Esc&amp;gt;v&amp;lt;Up&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Also you should use &lt;code&gt;inoremap&lt;/code&gt; it is much better to avoid unwanted behaviors)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-12-12T15:27:57.577" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14515" PostTypeId="2" ParentId="14513" CreationDate="2017-12-12T16:11:39.097" Score="4" Body="&lt;p&gt;The option which controls this behavior is &lt;code&gt;keymodel&lt;/code&gt;.  In &lt;code&gt;evim&lt;/code&gt;, it is set to &lt;code&gt;startsel,stopsel&lt;/code&gt;.  From &lt;code&gt;:help 'keymodel&lt;/code&gt;;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   startsel     Using a shifted special key starts selection (either&#xA;        Select mode or Visual mode, depending on &quot;key&quot; being&#xA;        present in 'selectmode').&#xA;&#xA;   stopsel      Using a not-shifted special key stops selection.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, &quot;special key&quot; means arrows, end/home, pageup/down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can simply use &lt;code&gt;set keymodel=startsel&lt;/code&gt; if you prefer not to cancel the selection when not pressing shift.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using this option, &lt;code&gt;vim&lt;/code&gt; will by default enter visual mode unlike &lt;code&gt;evim&lt;/code&gt;, which enters select mode.  You can instead enter select mode in this case by using the additional option,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set selectmode+=key&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-12-12T16:11:39.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14516" PostTypeId="1" CreationDate="2017-12-12T20:16:20.750" Score="2" ViewCount="276" Body="&lt;p&gt;I have the following in my &lt;code&gt;.vimrc&lt;/code&gt; (I don't recall where I found the original):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Cut, Copy, Paste&#xA;vnoremap &amp;lt;S-Del&amp;gt;        &quot;+x&#xA;vnoremap &amp;lt;C-Insert&amp;gt;     &quot;+y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I use Shift+Cursor keys to select some text and then press Ctrl+Ins to copy that text to the X11 clipboard, it works fine in gVim, but not in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further investigation (using &lt;code&gt;noremap &amp;lt;Leader&amp;gt;y &quot;+y&lt;/code&gt;) suggests that there's nothing wrong with the clipboard support, but rather something wrong with the keybinding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I confirmed this by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Leader&amp;gt;p :echo 'hello'&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;C-Insert&amp;gt; :echo 'hello'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The former works; the latter does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Linux Mint 18.3, Cinnamon, Gnome Terminal&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="5339" LastEditorUserId="5339" LastEditDate="2017-12-13T09:49:42.733" LastActivityDate="2017-12-13T09:49:42.733" Title="Ctrl+Ins keybinding won't work in Vim, does in gVim?" Tags="|gvim|" AnswerCount="0" CommentCount="4" ClosedDate="2017-12-13T12:23:14.407" ContentLicense="CC BY-SA 3.0" />
  <row Id="14517" PostTypeId="2" ParentId="6658" CreationDate="2017-12-13T01:22:11.243" Score="3" Body="&lt;p&gt;On Windows, &lt;code&gt;$HOME/vimfiles/after/ftplugin/foobar.vim&lt;/code&gt; runs after loading the standard &lt;code&gt;foobar&lt;/code&gt; ftplugin.&lt;/p&gt;&#xA;" OwnerUserId="488" LastActivityDate="2017-12-13T01:22:11.243" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14518" PostTypeId="1" AcceptedAnswerId="14521" CreationDate="2017-12-13T08:48:40.873" Score="2" ViewCount="2322" Body="&lt;p&gt;I want to display file size in the &lt;code&gt;rulerformat&lt;/code&gt; in &lt;code&gt;vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please answer for all file size formats like bits, bytes, kibibytes, mebibytes, gibibytes&lt;/p&gt;&#xA;" OwnerUserId="12533" LastEditorUserId="1841" LastEditDate="2017-12-13T09:01:59.077" LastActivityDate="2019-02-27T18:17:14.860" Title="How to display file size in vim rulerformat?" Tags="|statusline|ruler|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14519" PostTypeId="1" AcceptedAnswerId="14533" CreationDate="2017-12-13T09:37:18.617" Score="12" ViewCount="11615" Body="&lt;p&gt;When I edit file:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;/home/me/projects/myproj/src/util.c&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;I would like to start terminal at:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;/home/me/projects/myproj/src&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;With Vim version &amp;gt; 8 I can run &lt;code&gt;:terminal&lt;/code&gt; but it always starts at folder in which I've opened Vim (which is &lt;code&gt;/home/me/projects/myproj&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="11971" LastEditorUserId="23502" LastEditDate="2023-09-08T05:14:46.573" LastActivityDate="2023-09-08T05:14:46.573" Title="How to run internal Vim terminal at current file's dir?" Tags="|terminal|working-directory|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14520" PostTypeId="2" ParentId="14519" CreationDate="2017-12-13T09:47:47.270" Score="10" Body="&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3acd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :cd&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3alcd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :lcd&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:cd&lt;/code&gt; changes the current directory for all the windows while &lt;code&gt;:lcd&lt;/code&gt; changes the current directory for the current window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change the current directory to the directory containing the current file with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cd %:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can use &lt;code&gt;set autochdir&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt; to change the current working directory whenever you open a file, switch buffers, delete a buffer or open/close a window.  It will change to the directory containing the file which was opened or selected. (see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27autochdir%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'autochdir'&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that the doc mentions that &lt;code&gt;autochdir&lt;/code&gt; may break some plugin and &lt;a href=&quot;http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file&quot; rel=&quot;noreferrer&quot;&gt;this wikia page&lt;/a&gt; suggests the following autocommand to replace this setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter * silent! lcd %:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-12-13T09:52:52.953" LastActivityDate="2017-12-13T09:52:52.953" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14521" PostTypeId="2" ParentId="14518" CreationDate="2017-12-13T09:54:14.833" Score="7" Body="&lt;p&gt;You can get the size of the buffer in bytes with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo line2byte('$') + len(getline('$'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#line2byte%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;line2byte()&lt;/code&gt;&lt;/a&gt; gets the number of bytes until the last line, but not &lt;em&gt;including&lt;/em&gt; the last line, so we need to add the length of the last line ourselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;%{expr}&lt;/code&gt; to use any expression inside the &lt;code&gt;statusline&lt;/code&gt; or &lt;code&gt;rulerfrmat&lt;/code&gt; settings; for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;statusline .= &quot;%{line2byte('$') + len(getline('$'))}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or to display as KiB etc. simply divide by 1024, 1024^2, etc. A handy function might be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! HumanSize(bytes) abort&#xA;    let l:bytes = a:bytes&#xA;    let l:sizes = ['B', 'KiB', 'MiB', 'GiB']&#xA;    let l:i = 0&#xA;    while l:bytes &amp;gt;= 1024&#xA;        let l:bytes = l:bytes / 1024.0&#xA;        let l:i += 1&#xA;    endwhile&#xA;    return printf('%.1f%s', l:bytes, l:sizes[l:i])&#xA;endfun&#xA;&#xA;let &amp;amp;statusline .= &quot;%{HumanSize(line2byte('$') + len(getline('$')))}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will display a size as &quot;Bytes&quot;, &quot;KiB&quot;, etc. depending on what makes the most sense.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2017-12-13T09:59:17.240" LastActivityDate="2017-12-13T09:59:17.240" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14522" PostTypeId="1" CreationDate="2017-12-13T15:10:49.320" Score="1" ViewCount="88" Body="&lt;p&gt;The commands &lt;code&gt;1 CTRL-G&lt;/code&gt; and &lt;code&gt;:pwd&lt;/code&gt; return related but different results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 CTRL-G    &quot;~/dev/src/tiff.c&quot; 170 lines --15%--&#xA;:pwd        /home/user/src&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, &lt;code&gt;CTRL-G&lt;/code&gt; returns the file, not the working directory, but interestingly enough uses the tilde (~) shortcut to the home directory, but &lt;code&gt;pwd&lt;/code&gt; does not give the tilde, but expands it out. Also, &lt;code&gt;CTRL-G&lt;/code&gt; surrounds the path in quotation marks, but &lt;code&gt;pwd&lt;/code&gt; does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the significance of these differences? For example, why would CTRL-G have quotation marks around it, but pwd not?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2017-12-13T15:10:49.320" Title="Difference between 1 CTRL-G and :pwd, quotation marks?" Tags="|working-directory|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14523" PostTypeId="1" CreationDate="2017-12-13T15:50:43.283" Score="3" ViewCount="1007" Body="&lt;p&gt;How can I call a function in vimscript in the context of a specified buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, &lt;code&gt;line2byte&lt;/code&gt; works for the current buffer. I am implementing a callback, where I receive a buffer number as an argument and I need to call &lt;code&gt;line2byte&lt;/code&gt; for the specified buffer, which might not be the one currently focused by the user.&lt;/p&gt;&#xA;" OwnerUserId="8891" LastActivityDate="2017-12-15T11:14:52.657" Title="call function in context of buffer" Tags="|vimscript|buffers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14524" PostTypeId="2" ParentId="14523" CreationDate="2017-12-13T16:24:57.217" Score="3" Body="&lt;p&gt;If your function does not take a &lt;em&gt;bufnr&lt;/em&gt; as parameter and if there is no alternative function that does, you'll need to jump to that particular buffer and call your function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;del&gt;The caveat? It'll trigger autocommands, which means stuff you may not desire is likely to happen.&lt;/del&gt; EDIT: I didn't know about &lt;code&gt;noautocmd&lt;/code&gt; which prevents autocommands from being triggered when loading other buffers momentarily. See @Karl Yngve Lervåg's answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your particular case though, it seems that &lt;code&gt;line2byte(lnum+1)&lt;/code&gt; is almost identical to &lt;code&gt;eval(join(map(getbufline(bufnr, 1, lnum), 'strlen(v:val)'), '+'))+lnum+1&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the line ending is not unix, the offset may be &lt;code&gt;&amp;amp;ff =='unix' ? lnum+1 : 2*lnum+2&lt;/code&gt; -- I haven't checked dos case, nor mixed line endings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the second question: &quot;how to emulate &lt;code&gt;byte2line()&lt;/code&gt;?&quot;, it can be done this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! bufbyte2line(bufid, byteidx) abort&#xA;    let lines = map(getbufline(a:bufid, 1, '$'), 'v:val.&quot;\n&quot;')&#xA;    let line_lengths = map(lines, 'len(v:val)')&#xA;    let acc = [0]&#xA;    call map(line_lengths, 'add(acc, acc[-1]+v:val)')&#xA;    return len(filter(acc, 'v:val &amp;lt;= a:byteidx'))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-12-14T13:09:34.990" LastActivityDate="2017-12-14T13:09:34.990" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14525" PostTypeId="1" CreationDate="2017-12-13T17:38:15.383" Score="1" ViewCount="1168" Body="&lt;p&gt;I have several files where I want to change a word in several files from oldWord to newWord. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note I want to do this with the new cpo feature. I also would like to do this in one command line chain, rather than one command at a time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should this command do it? Or is there a better way do this in VIM? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set hidden | :vimgrep oldWord ./gulp-tasks/*.s | :cdo s/oldWord/newWord/g | :set wall  ?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15557" LastEditorUserId="1841" LastEditDate="2017-12-14T07:46:45.127" LastActivityDate="2017-12-14T07:46:45.127" Title="Search and replace multiple files" Tags="|regular-expression|search|" AnswerCount="1" CommentCount="2" ClosedDate="2017-12-14T07:47:20.423" ContentLicense="CC BY-SA 3.0" />
  <row Id="14526" PostTypeId="2" ParentId="5439" CreationDate="2017-12-13T17:41:45.037" Score="0" Body="&lt;p&gt;I have the netrw version from Sep 19, 2016 and still encounter the same issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of netrw, I use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3133&quot; rel=&quot;nofollow noreferrer&quot;&gt;tyru's plugin&lt;/a&gt; to open a URL in the browser.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin works great so far. &lt;/p&gt;&#xA;" OwnerUserId="8558" LastActivityDate="2017-12-13T17:41:45.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14527" PostTypeId="2" ParentId="14525" CreationDate="2017-12-13T17:55:51.240" Score="3" Body="&lt;p&gt;I imagine you meant something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set hidden&#xA;:vimgrep /foo/ dir/*.s&#xA;:cfdo %s/foo/bar/g | w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All in one line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set hidden | vimgrep/foo/ dir/*.s | cfdo %s/foo/bar/g | w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Related Vimcasts episode: &lt;a href=&quot;http://vimcasts.org/episodes/project-wide-find-and-replace/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Project-wide find and replace&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :vimgrep&#xA;:h :cfdo&#xA;:h 'hidden'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2017-12-13T18:01:22.100" LastActivityDate="2017-12-13T18:01:22.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14528" PostTypeId="1" CreationDate="2017-12-13T19:47:54.803" Score="1" ViewCount="115" Body="&lt;p&gt;I'm a vim user and forgot to grab my csh/vim settings before leaving my prev company.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, when tooling around my unix shell, I used vim commands (eg go back and forth using VIM quick-keys, using 'b', using 'w', etc).&lt;/p&gt;&#xA;" OwnerUserId="15563" LastActivityDate="2017-12-14T00:10:35.757" Title="How do I move cursor around on unix shell using VIM commands?" Tags="|command-line|unix|" AnswerCount="1" CommentCount="1" ClosedDate="2017-12-14T07:45:25.433" ContentLicense="CC BY-SA 3.0" />
  <row Id="14529" PostTypeId="2" ParentId="14491" CreationDate="2017-12-13T21:44:54.010" Score="5" Body="&lt;p&gt;When vim starts up, it interrogates your terminal emulator, which responds with terminal codes.  vim usually captures this in &lt;code&gt;v:termresponse&lt;/code&gt;.  Sometimes, however, the codes get through and they frequently look like vim commands and cause unintended behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two of the options which controls what &lt;em&gt;vim&lt;/em&gt; sends seem to cause many people issues:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t_RS    request terminal cursor style           *t_RS* *'t_RS'*&#xA;t_SH    set cursor shape                        *t_SH* *'t_SH'*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These were added recently to allow vim to set the cursor shape and determine the default terminal cursor.  Setting either of these to empty (&lt;code&gt;set t_SH=&lt;/code&gt; or &lt;code&gt;set t_RS=&lt;/code&gt;) causes vim to skip the check.  It is the response from your terminal which is causing the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is most likely a vim bug, because it should work by default in xterm.  Besides setting these options to empty, I suggest,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;updating to the most recent vim version&lt;/li&gt;&#xA;&lt;li&gt;report the bug (see &lt;code&gt;:h bugs&lt;/code&gt;), carefully noting your platform and terminal emulator, the precise behavior seen, and the value of &lt;code&gt;v:termresponse&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="-1" LastEditDate="2017-12-15T11:48:15.827" LastActivityDate="2017-12-15T11:48:15.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14530" PostTypeId="2" ParentId="14528" CreationDate="2017-12-14T00:10:35.757" Score="2" Body="&lt;p&gt;I'm not sure about csh specifically, but for sh, ksh, and Bash, &lt;code&gt;set -o vi&lt;/code&gt;, and for Zsh I think &lt;code&gt;bindkey -v&lt;/code&gt;. You can add that to your &lt;code&gt;~/.profile&lt;/code&gt; or whatever. You can also add this to your &lt;code&gt;~/inputrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set editing-mode vi&#xA;set keymap vi-command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for all programs that use Readline (including Bash).&lt;/p&gt;&#xA;" OwnerUserId="15565" LastActivityDate="2017-12-14T00:10:35.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14532" PostTypeId="2" ParentId="14523" CreationDate="2017-12-14T07:39:10.643" Score="6" Body="&lt;p&gt;You can temporarily change the buffer before calling &lt;code&gt;line2byte&lt;/code&gt;. However, you need to be careful. In particular, you should avoid changing the alternate file and prevent autocommands from firing. For this, you need &lt;code&gt;keepalt&lt;/code&gt; and &lt;code&gt;noautocmd&lt;/code&gt;, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this should work, where I assume the &lt;code&gt;lnum&lt;/code&gt; is supplied as an argument as well (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Line2ByteBuf(bufnr, lnum) abort&#xA;  let l:bufnr = bufnr('')&#xA;&#xA;  execute 'noautocmd keepalt buffer' a:bufnr&#xA;  let l:bytes = line2byte(a:lnum)&#xA;  execute 'noautocmd keepalt buffer' l:bufnr&#xA;&#xA;  return l:bytes&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you should probably also add a check if the supplied buffer &lt;code&gt;bufnr&lt;/code&gt; exists and similar. I left that as an exercise for the reader.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2017-12-15T11:14:52.657" LastActivityDate="2017-12-15T11:14:52.657" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14533" PostTypeId="2" ParentId="14519" CreationDate="2017-12-14T09:15:00.973" Score="15" Body="&lt;p&gt;I am grateful to @statox for useful hints, but as I don't wont to change current dir each time I come to following: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F6&amp;gt; :let $VIM_DIR=expand('%:p:h')&amp;lt;CR&amp;gt;:terminal&amp;lt;CR&amp;gt;cd $VIM_DIR&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11971" LastEditorUserId="11971" LastEditDate="2017-12-14T09:35:43.830" LastActivityDate="2017-12-14T09:35:43.830" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14534" PostTypeId="1" CreationDate="2017-12-14T09:33:43.050" Score="2" ViewCount="114" Body="&lt;p&gt;I just got a &lt;code&gt;mac&lt;/code&gt; and have been trying to setup Vim 8 on the built-in terminal. I am mostly having some difficulties with colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) After &lt;code&gt;set number&lt;/code&gt;, how do I change the line number colors?&#xA;I tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works for me on Linux but it doesn't work on Mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Is there a way to change the &lt;code&gt;colorscheme&lt;/code&gt;? It seems I can't edit the files in &lt;code&gt;/usr/share/vim/vim80/colors&lt;/code&gt; or add another file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Is there a way to make the syntax highlighting richer?&#xA;I added the following which doesn't seem to have any effect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;try&#xA;    &quot; Java: 'new', 'instanceof'&#xA;    autocmd FileType java highlight Operator ctermfg=5  guifg=#d175bc&#xA;    &quot; Java: 'this', 'super'&#xA;    autocmd FileType java highlight Typedef ctermfg=5  guifg=#d175bc&#xA;    &quot; Java: 'void', 'int', 'double'&#xA;    autocmd FileType java highlight Type ctermfg=4  guifg=#69b7d3&#xA;catch&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Linux, those commands would at least make Java's syntax recognition a bit better.&lt;/p&gt;&#xA;" OwnerUserId="14019" LastEditorUserId="135" LastEditDate="2017-12-15T20:25:06.990" LastActivityDate="2017-12-15T20:25:06.990" Title="Color questions for macOS" Tags="|colorscheme|terminal|macos|color|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14535" PostTypeId="1" AcceptedAnswerId="14536" CreationDate="2017-12-14T11:33:05.277" Score="10" ViewCount="3699" Body="&lt;p&gt;Is there any way to jump to a buffer by entering buffer number right from &lt;code&gt;:ls&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mean, why this command expect me to &lt;code&gt;Press ENTER or type command to continue&lt;/code&gt;, if pressing for example &lt;code&gt;2&lt;/code&gt;, wouldn't do anything?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously I won't any plugin to be installed, at least one little script in &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="15568" LastEditorUserId="28" LastEditDate="2017-12-15T11:48:08.337" LastActivityDate="2020-06-19T19:12:28.937" Title="How to jump to buffer from ls?" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14536" PostTypeId="2" ParentId="14535" CreationDate="2017-12-14T11:55:45.603" Score="14" Body="&lt;p&gt;Without changing anything the quickest way from that prompt is probably to press &lt;code&gt;:b&lt;/code&gt; + number + &lt;kbd&gt;Enter&lt;/kbd&gt;. But as a bit of a shortcut here's what I (and a lot of other people) use that gets me there from Normal mode:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;ls :ls&amp;lt;cr&amp;gt;:b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can replace &lt;code&gt;&amp;lt;leader&amp;gt;ls&lt;/code&gt; with any unused Normal mode key combo. After pressing the keys you'll see the buffer list and you can enter the number + &lt;kbd&gt;Enter&lt;/kbd&gt; without dealing with that &lt;code&gt;Press ENTER...&lt;/code&gt; prompt.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; OP would like to override &lt;code&gt;:ls&lt;/code&gt; altogether. That can be done with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:cnoremap ls ls&amp;lt;cr&amp;gt;:b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but this is not recommended since the mapping will happen anywhere &amp;quot;ls&amp;quot; is typed in a command or search term! (Thanks to &lt;a href=&quot;https://vi.stackexchange.com/users/778/peter-rincker&quot;&gt;Peter Rincker&lt;/a&gt; for &lt;a href=&quot;https://vi.stackexchange.com/questions/14535/jump-to-buffer-from-ls/14536?noredirect=1#comment24970_14536&quot;&gt;the warning&lt;/a&gt;.) While you can overcome this by typing &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; before typing &amp;quot;ls&amp;quot; anywhere (e.g. to search for &amp;quot;hills&amp;quot; you'd have to do &lt;code&gt;/hil^Vls&lt;/code&gt;) that's hardly convenient. Better to choose a key-combo that is unlikely to occur in commands or search terms. In Vim help they have an example with &amp;quot;_ls&amp;quot; so &lt;code&gt;:cnoremap _ls ...&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; I've since removed the &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; from my own mapping and edited the mappings above to reflect this. It's not necessary and, more importantly, I occasionally decide I want to unload a buffer from this point using &lt;code&gt;:bd&lt;/code&gt; (aka &lt;a href=&quot;https://vimhelp.org/windows.txt.html#:bdelete&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:bdelete&lt;/code&gt;&lt;/a&gt;). The &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; meant having to type &lt;kbd&gt;Backspace&lt;/kbd&gt; before &lt;kbd&gt;d&lt;/kbd&gt; and the buffer number.&lt;/p&gt;&#xA;&lt;p&gt;Also, there supposedly was going to be an update five months ago based on a suggestion in the comments from @Rich but that seems to have fallen through the cracks 'til now...&lt;/p&gt;&#xA;&lt;p&gt;He offers a more robust handling of a command-line override of &lt;code&gt;ls&lt;/code&gt;. His version behaves slightly differently from the &lt;code&gt;:cnoremap&lt;/code&gt; mapping above: the latter shows the buffer list after typing &lt;code&gt;ls&lt;/code&gt; while the other waits until a subsequent press of &lt;kbd&gt;Enter&lt;/kbd&gt;. It's trivial to adapt his solution to match the above. Which one to choose is simply a matter of taste. Both have the benefit of avoiding any Ctrl-V nonsense and only activating upon typing &lt;code&gt;ls&lt;/code&gt;/&lt;code&gt;ls&amp;lt;CR&amp;gt;&lt;/code&gt; right after the command-line's opening &lt;code&gt;:&lt;/code&gt; versus activating inappropriately upon typing them somewhere else.&lt;/p&gt;&#xA;&lt;p&gt;Here's the improved mapping to replace the one above. Simply add &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; after the first &lt;code&gt;ls&lt;/code&gt; to get the other flavor.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; ls (getcmdtype() == ':' &amp;amp;&amp;amp; getcmdpos() == 1) ? &amp;quot;ls\&amp;lt;CR&amp;gt;:b&amp;quot; : &amp;quot;ls&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I recommend trying both and going with whatever suits you best but make sure you &lt;code&gt;:cunmap&lt;/code&gt; one before trying the other.&lt;/p&gt;&#xA;&lt;p&gt;Or you can blow all of this off and just use &lt;code&gt;&amp;lt;leader&amp;gt;ls&lt;/code&gt; from Normal mode like most people prefer to do. :)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-06-19T19:12:28.937" LastActivityDate="2020-06-19T19:12:28.937" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="14537" PostTypeId="1" CreationDate="2017-12-14T14:22:57.247" Score="3" ViewCount="238" Body="&lt;p&gt;I'm creating a plugin and I'm writing its documentation according to &lt;code&gt;:helptags&lt;/code&gt;. However I cannot link my tags if they have an hyphen in them. The strange thing is that &lt;code&gt;help-writing&lt;/code&gt; itself has a hyphen and I can jump to it using &lt;code&gt;CTRL-]&lt;/code&gt; depending on the vim instance I'm running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reproducibility:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1   ===============================================================================&#xA;2   CONTENTS                                                *vim-dictionary-contents*&#xA;3   &#xA;4   1. Intro ................................................. |vim-dictionary-intro|&#xA;5   2. Variables ......................................... |vim-dictionary-variables|&#xA;6   3. Details ............................................. |vim-dictionary-details|&#xA;7   4. Next steps ....................................... |vim-dictionary-next-steps|&#xA;8   5. Development ..................................... |vim-dictionary-development|&#xA;9   6. License ............................................. |vim-dictionary-license|&#xA;10  &#xA;11  ===============================================================================&#xA;12  1. Intro ~&#xA;13                                                             *vim-dictionary-intro*&#xA;14  &#xA;15  This plugin adds a dictionary functionality to your vim. It aims to be the&#xA;16  simplest. Only one command defined:&#xA;17  &#xA;18      Dictionary 'term'&#xA;19  &#xA;20  This command should open a new scratch window with the 'term' definition.&#xA;21  &#xA;22  All of this plugin's customization are two variables related to the window size&#xA;23  of the dictionary window.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I execute &lt;code&gt;:helptags /path/to/dir&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then putting my cursor on line 4 on the &lt;code&gt;|vim-dictionary-intro|&lt;/code&gt; tag and pressing &lt;code&gt;CTRL-]&lt;/code&gt; I get: &lt;code&gt;E426: tag not found: intro&lt;/code&gt; which is pretty obvious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By issuing &lt;code&gt;set ft?&lt;/code&gt; I get &lt;code&gt;filetype=help&lt;/code&gt;. So my conclusion is that the filetype is correct and I hoped that vim would understand that a word between &lt;code&gt;|&lt;/code&gt; but that does not happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I change &lt;code&gt;vim-dictionary-intro&lt;/code&gt; to &lt;code&gt;vimdictionaryintro&lt;/code&gt; I can jump around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is then how to have the proper behavior as I have with &lt;code&gt;help-writing&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Helptags inexpected behavior if tag has hyphen&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: no &lt;code&gt;helptags&lt;/code&gt; tag for adequate keywording the question.&lt;/p&gt;&#xA;" OwnerUserId="10216" LastActivityDate="2017-12-14T18:27:17.290" Title="Helptags has unexpected behavior if tag has hyphen" Tags="|help-system|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14538" PostTypeId="1" AcceptedAnswerId="14539" CreationDate="2017-12-14T15:04:33.193" Score="2" ViewCount="663" Body="&lt;p&gt;When I select text in Vim using the mouse, the editor displays &quot;SELECT&quot; at the bottom of the window, like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/P4HLy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/P4HLy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This always makes me uneasy, because I have found that the Select mode somehow changes very easily into Insert mode.  Is there a way to have a &quot;read-only select mode&quot;, if you will, such that Vim does not react in any way in response to mouse select operations?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Vim 8.0.586 on Windows 10.&lt;/p&gt;&#xA;" OwnerUserId="15208" LastActivityDate="2017-12-14T15:38:57.603" Title="Read-only (silent) select in Vim" Tags="|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14539" PostTypeId="2" ParentId="14538" CreationDate="2017-12-14T15:38:57.603" Score="7" Body="&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/2093578/how-to-make-gvim-on-windows-behave-exacly-like-linux-console-vim&quot;&gt;Get rid of mswin.vim&lt;/a&gt; that comes activated by default on Windows platforms. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of the select-mode, you'll be back in the visual-mode. It's not read-only strictly speaking, but at least it's not half-way between insert-mode and visual-mode.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2017-12-14T15:38:57.603" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14540" PostTypeId="2" ParentId="14537" CreationDate="2017-12-14T18:27:17.290" Score="3" Body="&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;: not vim's fault: persistence in vim files was the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for the record the problem was not with vim. The plugin hierarchy and the customization level that we employ in our files make vim unpredictable sometimes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution was to remove persistence related to the aforementioned help file. So after deleting the:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;file from &lt;code&gt;viewdir&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;file from &lt;code&gt;undodir&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;file from &lt;code&gt;backupdir&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Things worked as expected. I find this function and command definition very helpful to avoid those things:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! CleanViewFile :call s:CleanViewFile()&#xA;&quot; s:CleanViewFile() &quot; {{{&#xA;function! s:CleanViewFile()&#xA;    function! DeleteFromViewdir()&#xA;        &quot; # Function to permanently delete views created by 'mkview'&#xA;        &quot; https://stackoverflow.com/questions/28384159/vim-how-to-remove-clear-views-created-by-mkview-from-inside-of-vim&#xA;        let path = fnamemodify(bufname('%'),':p')&#xA;        &quot; vim's odd =~ escaping for /&#xA;        let path = substitute(path, '=', '==', 'g')&#xA;        if empty($HOME)&#xA;        else&#xA;            let path = substitute(path, '^'.$HOME, '\~', '')&#xA;        endif&#xA;        let path = substitute(path, '/', '=+', 'g') . '='&#xA;        &quot; view directory&#xA;        let path = &amp;amp;viewdir.'/'.path&#xA;        call delete(path)&#xA;        echom &quot;Deleted: &quot;.path&#xA;    endfunction&#xA;    function! DeleteFromUndodir()&#xA;        &quot; # Function to permanently delete views created by 'mkview'&#xA;        &quot; https://stackoverflow.com/questions/28384159/vim-how-to-remove-clear-views-created-by-mkview-from-inside-of-vim&#xA;        let path = fnamemodify(bufname('%'),':p')&#xA;        let path = substitute(path, '/', '%', 'g')&#xA;        let path = &amp;amp;undodir.'/'.path&#xA;        call delete(path)&#xA;        &quot; echom path&#xA;        echom &quot;Deleted: &quot;.path&#xA;    endfunction&#xA;    function! DeleteFromBackupdir()&#xA;        &quot; # Function to permanently delete views created by 'mkview'&#xA;        &quot; https://stackoverflow.com/questions/28384159/vim-how-to-remove-clear-views-created-by-mkview-from-inside-of-vim&#xA;        let path = fnamemodify(bufname('%'),':t')&#xA;        let path = &amp;amp;backupdir.'/'.path.'~'&#xA;        call delete(path)&#xA;        echom &quot;Deleted: &quot;.path&#xA;    endfunction&#xA;    &quot; Clean the view file and parse the modeline for current buffer.&#xA;    &quot; Clean the view file and parse the modeline for current buffer.&#xA;&#xA;    &quot; Saves the file vithout creating the view file.&#xA;    &quot; TODO: winsaveview may be a better option.&#xA;    let save_cursor = getcurpos()&#xA;    silent! noautocmd w!&#xA;    &quot; set filetype=&amp;amp;filetype&#xA;&#xA;    &quot; Buffer name without extension.&#xA;    let buffer_name=expand(&quot;%:t&quot;)&#xA;    &quot; Create variable to remove view file for this file.&#xA;    let shell_command=&quot;rm &quot; . shellescape(&amp;amp;viewdir . &quot;/*&quot; . buffer_name . &quot;*&quot;)&#xA;    &quot; Clean the view file.&#xA;    silent! call system(shell_command)&#xA;&#xA;    &quot; Buffer name without extension.&#xA;    let full_buffer_name=expand(&quot;%:p&quot;)&#xA;    &quot; Use sed to remove viminfo options from this file.&#xA;    &quot; echom s:cachedir&#xA;    &quot; TODO: Use sed to remove viminfo options from this file.&#xA;    &quot; let shell_command=&quot;sed -i /&quot; . full_buffer_name . &quot;/^\s*$/d &quot; . shellescape(s:cachedir . &quot;/viminfo&quot;)&#xA;    &quot; echom shell_command&#xA;    &quot; silent! call system(shell_command)&#xA;    &quot;&#xA;    &quot; Full path to buffer.&#xA;    silent! execute &quot;normal! :edit! &quot; . full_buffer_name . &quot;\r&quot;&#xA;    silent! execute &quot;:e!&quot;&#xA;    &quot; Improves by  the modeline reading the modeline.&#xA;    doautocmd BufEnter&#xA;    let &amp;amp;filetype=&amp;amp;filetype&#xA;    call setpos('.', save_cursor)&#xA;    call DeleteFromViewdir()&#xA;    call DeleteFromUndodir()&#xA;    call DeleteFromBackupdir()&#xA;endfunction&#xA;&quot; }}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And run &lt;code&gt;:execute 'tabdo CleanViewFile' | silent! noautocmd xa! | silent noautocmd qa!&lt;/code&gt; from time to time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks @Carpetsmoker for the help.&lt;/p&gt;&#xA;" OwnerUserId="10216" LastActivityDate="2017-12-14T18:27:17.290" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14541" PostTypeId="1" AcceptedAnswerId="14573" CreationDate="2017-12-14T18:57:14.810" Score="4" ViewCount="3740" Body="&lt;p&gt;I have read &lt;a href=&quot;http://vim.wikia.com/wiki/Configuring_the_cursor&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt; &amp;amp; I added &lt;code&gt;se gcr+=a:blinkon0&lt;/code&gt; in my vimrc to stop blinking cursor in my Vim, also I sourced my vimrc again but the matter is it doesn't work &amp;amp; cursor is still blinking in all modes. Please let me know why it doesn't work for me &amp;amp; How can I fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit 1:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OS: Fedora Linux 27 x86_64 &amp;amp; Vim version: 8.0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit 2:&lt;/em&gt; &#xA;I think I have found a solution for that. Actually Herb Wolfe was right and this option seems not working on Vim (but in gvim it works fine). For stop cursor blinking you can disable cursor blinking in your terminal emulator instead. Also &lt;a href=&quot;http://vim.wikia.com/wiki/Change_cursor_shape_in_different_modes&quot; rel=&quot;nofollow noreferrer&quot;&gt;this wiki&lt;/a&gt; may help.&lt;/p&gt;&#xA;" OwnerUserId="15007" LastEditorUserId="15007" LastEditDate="2017-12-14T21:42:43.367" LastActivityDate="2017-12-17T18:24:05.457" Title="No_cursor_blinking doesn't work" Tags="|vimrc|cursor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14542" PostTypeId="1" CreationDate="2017-12-15T01:51:48.883" Score="0" ViewCount="489" Body="&lt;p&gt;One feature useful to me is Ctr-V column visual mode. This way I can avoid typing lines nearly the same multiple times. Is there a way in vim I can do this over a range like 5,14,22,.. so that the change is applied to those lines as well?&lt;/p&gt;&#xA;" OwnerUserId="15237" LastActivityDate="2017-12-15T05:49:45.217" Title="Writing text to multiple lines in different locations of the text file" Tags="|visual-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14543" PostTypeId="2" ParentId="14542" CreationDate="2017-12-15T05:38:05.843" Score="1" Body="&lt;p&gt;Not without a plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a handful of plugins with &quot;multi-cursor&quot;, &quot;multi-line&quot; and/or &quot;multi-edit&quot; functionality. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At least one emulates the multi-cursor behavior found in the Sublime editor: &lt;a href=&quot;https://github.com/terryma/vim-multiple-cursors&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/terryma/vim-multiple-cursors&lt;/a&gt;. The basic functionality is to place cursors wherever you like by clicking and then start typing. The text will appear simultaneously at every location with a cursor. You can also place the cursors based on a regex rather than where you click your mouse. I've installed this one and it works pretty well but I don't use it all that much since it's not a way of working that I find myself unable to replicate or approximate by other means.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another operates a lot like Visual mode except you can select non-contiguous sections of text: &lt;a href=&quot;https://github.com/alfredodeza/plexer.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/alfredodeza/plexer.vim&lt;/a&gt; . I haven't tried this one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure there are others.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-12-15T05:49:45.217" LastActivityDate="2017-12-15T05:49:45.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14544" PostTypeId="1" AcceptedAnswerId="14545" CreationDate="2017-12-15T05:40:52.217" Score="8" ViewCount="4904" Body="&lt;p&gt;Currently, my vimrc has&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cursorline&#xA;hi CursorLine cterm=underline ctermbg=none ctermfg=none&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to be set &lt;code&gt;cterm&lt;/code&gt; to both &lt;code&gt;underline&lt;/code&gt; and &lt;code&gt;bold&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="12533" LastEditorUserId="51" LastEditDate="2017-12-17T13:21:39.840" LastActivityDate="2017-12-17T13:21:39.840" Title="How to set value of cterm to both bold and underline?" Tags="|syntax-highlighting|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14545" PostTypeId="2" ParentId="14544" CreationDate="2017-12-15T06:14:58.787" Score="28" Body="&lt;p&gt;Vim has excellent help files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had no idea what the answer was to this question but I found it in one minute:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:h cterm&lt;/code&gt; (don't hit &lt;kbd&gt;Enter&lt;/kbd&gt; yet)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Tab&lt;/kbd&gt; for auto-completion to see some choices&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;highlight-cterm&lt;/em&gt; sounds promising so tab over to it and hit &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Hmm, &lt;em&gt;cterm={attr-list}&lt;/em&gt; and &lt;em&gt;See above for the description of attr-list&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;That last &quot;attr-list&quot; is highlighted as a tag so put cursor over it and hit &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;]&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;And voila..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attr-list is a comma separated list (without spaces) of the following items (in any order):&#xA;        bold&#xA;        underline&#xA;        ..etc..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;cterm=underline,bold&lt;/code&gt; is the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has excellent help files.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-12-15T10:45:03.080" LastActivityDate="2017-12-15T10:45:03.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14546" PostTypeId="1" AcceptedAnswerId="14547" CreationDate="2017-12-15T06:51:35.127" Score="5" ViewCount="1046" Body="&lt;p&gt;I have managed to do this with a super long find-replace but I'm sure there's a simpler way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a file of the form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E01 2017 10 24 00 00 00-1.90001e-04-8.79280e-12 0.00000e+00&#xA;            3.20000e+01 8.53750e+01 2.90408e-09 3.04855e+00&#xA;            4.08463e-06 3.01205e-04 1.49385e-06 5.44061e+03&#xA;            1.72800e+05 6.14672e-08-1.45096e+00-7.45058e-09&#xA;            9.95466e-01 3.22187e+02-2.16382e+00-5.72952e-09&#xA;            7.50018e-11 2.58000e+02 1.90000e+03 0.00000e+00&#xA;            3.12000e+00 0.00000e+00-4.49424e-09 0.00000e+00&#xA;            1.73500e+05 0.00000e+00 0.00000e+00 0.00000e+00&#xA;E01 2017 10 24 00 00 00-1.90001e-04-8.79280e-12 0.00000e+00&#xA;            3.20000e+01 8.53750e+01 2.90410e-09 3.04855e+00&#xA;            4.08460e-06 3.01205e-04 1.49380e-06 5.44061e+03&#xA;            1.72800e+05 6.14672e-08-1.45100e+00-7.45058e-09&#xA;            9.95470e-01 3.22187e+02-2.16380e+00-5.72952e-09&#xA;            7.50020e-11 5.21000e+02 1.90000e+03 0.00000e+00&#xA;            0.00000e+00 0.00000e+00-4.49420e-09-5.35510e-09&#xA;            1.73400e+05 0.00000e+00 0.00000e+00 0.00000e+00&#xA;E02 2017 10 24 00 00 00-5.65248e-06 9.24880e-13 0.00000e+00&#xA;            3.20000e+01 1.05375e+02 2.89100e-09-7.19798e-01&#xA;            4.93710e-06 2.56068e-04 2.77200e-06 5.44061e+03&#xA;            1.72800e+05 4.84287e-08-1.49240e+00-8.75443e-08&#xA;            9.95490e-01 2.94906e+02-1.54180e+00-5.75452e-09&#xA;            1.30070e-10 2.58000e+02 1.90000e+03 0.00000e+00&#xA;            0.00000e+00 0.00000e+00-6.99620e-09 0.00000e+00&#xA;            1.73500e+05 0.00000e+00 0.00000e+00 0.00000e+00&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each line starting with &lt;code&gt;E&lt;/code&gt; represents the beginning of a &quot;block&quot;. All blocks are 8 lines long, and the width of the columns is fixed for the whole file. I want to delete a block if the second element of the sixth line of the block is (not) &lt;code&gt;2.58000e+02&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So after deleting all blocks which do have &lt;code&gt;2.58000e+02&lt;/code&gt; as the second element of their sixth line I would expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E01 2017 10 24 00 00 00-1.90001e-04-8.79280e-12 0.00000e+00&#xA;            3.20000e+01 8.53750e+01 2.90410e-09 3.04855e+00&#xA;            4.08460e-06 3.01205e-04 1.49380e-06 5.44061e+03&#xA;            1.72800e+05 6.14672e-08-1.45100e+00-7.45058e-09&#xA;            9.95470e-01 3.22187e+02-2.16380e+00-5.72952e-09&#xA;            7.50020e-11 5.21000e+02 1.90000e+03 0.00000e+00&#xA;            0.00000e+00 0.00000e+00-4.49420e-09-5.35510e-09&#xA;            1.73400e+05 0.00000e+00 0.00000e+00 0.00000e+00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After deleting all blocks whose second element in the sixth line is not &lt;code&gt;2.58000e+02&lt;/code&gt; I would expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E01 2017 10 24 00 00 00-1.90001e-04-8.79280e-12 0.00000e+00&#xA;            3.20000e+01 8.53750e+01 2.90408e-09 3.04855e+00&#xA;            4.08463e-06 3.01205e-04 1.49385e-06 5.44061e+03&#xA;            1.72800e+05 6.14672e-08-1.45096e+00-7.45058e-09&#xA;            9.95466e-01 3.22187e+02-2.16382e+00-5.72952e-09&#xA;            7.50018e-11 2.58000e+02 1.90000e+03 0.00000e+00&#xA;            3.12000e+00 0.00000e+00-4.49424e-09 0.00000e+00&#xA;            1.73500e+05 0.00000e+00 0.00000e+00 0.00000e+00&#xA;E02 2017 10 24 00 00 00-5.65248e-06 9.24880e-13 0.00000e+00&#xA;            3.20000e+01 1.05375e+02 2.89100e-09-7.19798e-01&#xA;            4.93710e-06 2.56068e-04 2.77200e-06 5.44061e+03&#xA;            1.72800e+05 4.84287e-08-1.49240e+00-8.75443e-08&#xA;            9.95490e-01 2.94906e+02-1.54180e+00-5.75452e-09&#xA;            1.30070e-10 2.58000e+02 1.90000e+03 0.00000e+00&#xA;            0.00000e+00 0.00000e+00-6.99620e-09 0.00000e+00&#xA;            1.73500e+05 0.00000e+00 0.00000e+00 0.00000e+00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;My attempt&lt;/h1&gt;&#xA;&#xA;&lt;h2&gt;To delete the blocks which contain &lt;code&gt;2.58000e+02&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First delete the block themselves with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^E[0-9 .e+-]\+\n\([0-9 .e+-]\+\n\)\{4}[ ]\+[0-9.e+-]\+ 2.58000e+02\([0-9 .e+-]\+\n\)\+//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then remove the blank lines which remain after the blocks that have been preserved:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\n^[ ]\{}$//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;To delete the blocks which do &lt;em&gt;not&lt;/em&gt; contain &lt;code&gt;2.58000e+02&lt;/code&gt;:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This one was tougher. What I did is store the result of the previous command in a separate file, and from terminal perform the diff between the original file and the new file, and keep the lines which are in the original one and not the second one. This however requires leaving ViM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simpler way to achieve these two things?&lt;/p&gt;&#xA;" OwnerUserId="12266" LastEditorUserId="12266" LastEditDate="2017-12-15T07:16:49.443" LastActivityDate="2017-12-15T16:51:26.010" Title="Delete block of code if a pattern is (not) detected in one of the lines" Tags="|regular-expression|search|replace|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14547" PostTypeId="2" ParentId="14546" CreationDate="2017-12-15T07:15:26.993" Score="8" Body="&lt;p&gt;&lt;strong&gt;To delete&lt;/strong&gt; the blocks containing &lt;code&gt;2.58000e+02&lt;/code&gt;, you can use following global command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\v^E(.*$\n){5}\s+.{-}2.58000e\+02/,+7d_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This breaks down as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/                                 starts a global command&#xA;\v^E(.*$\n){5}\s+.{-}2.58000e\+02   searches for blocks containing 2.58&#xA;/,+7d_                              sets a range from the start of a match up until &#xA;                                    the next 7 lines and deletes the lines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To retain&lt;/strong&gt; the blocks containing &lt;code&gt;2.58000e+02&lt;/code&gt;, instead of searching and deleting blocks &lt;em&gt;not&lt;/em&gt; containing your search pattern I'd suggest to use a register to copy the required blocks to. This way you can reuse your search pattern.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=''|g/\v^E(.*$\n){5}\s+.{-}2.58000e\+02/,+7y A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This breaks down as    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=''|g/                       clears the a register and starts a global command&#xA;\v^E(.*$\n){5}\s+.{-}2.58000e\+02   searches for blocks containing 2.58&#xA;/,+7y A                             sets a range from the start of a match up until &#xA;                                    the next 7 lines and appends the lines to a register&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Following all this, your workflow could be as follows&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Search your pattern: &lt;code&gt;/\v^E(.*$\n){5}\s+.{-}2.58000e\+02&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Copy all matching blocks to register &lt;code&gt;a&lt;/code&gt;: &lt;code&gt;:let @a=''|g//,+7y A&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Delete all matching blocks from buffer: &lt;code&gt;:g//,+7d_&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Paste register &lt;code&gt;a&lt;/code&gt; into a new buffer: &lt;code&gt;&quot;ap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;even easier &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Search your pattern: &lt;code&gt;/\v^E(.*$\n){5}\s+.{-}2.58000e\+02&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Cut all matching blocks to register &lt;code&gt;a&lt;/code&gt;: &lt;code&gt;:let @a=''|g//,+7d A&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Paste register &lt;code&gt;a&lt;/code&gt; into a new buffer: &lt;code&gt;&quot;ap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1003" LastEditorUserId="1003" LastEditDate="2017-12-15T08:52:03.770" LastActivityDate="2017-12-15T08:52:03.770" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14548" PostTypeId="2" ParentId="14546" CreationDate="2017-12-15T11:16:46.083" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;:%s;\v^E\d* \d*( \d\d)+.&lt;em&gt;\n(\s+.&lt;/em&gt;\n){4}\s+([- ]\d+.\d+e[-+]\d+ )(2.580+e+\d+)@!.&lt;em&gt;\n(\s+.&lt;/em&gt;\n)*;;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;worked for me, at least using your sample from the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Simply&quot; make sure you match up to where the 2.58... should appear, and use a &lt;em&gt;zero-width&lt;/em&gt; assertion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have to do this more than once, for the love of G-d, write a Perl script (probably only be a couple of lines :o)) and run it with&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:%!perl my-filter.pl&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="14114" LastActivityDate="2017-12-15T11:16:46.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14549" PostTypeId="2" ParentId="1915" CreationDate="2017-12-15T12:43:16.300" Score="1" Body="&lt;p&gt;What worked great for me with &lt;code&gt;vi&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:set number&lt;/code&gt; to view the number of the line until  where I wanted to delete;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+1289 idle &#xA;+1289 idle &#xA;+1290 # &amp;lt;- I want to delete until here&#xA;+1291 if [[ ! -z &quot;$SFIN&quot; ]]&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Go back to the line where deletion had to start&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Used deletion from current line, in normal mode&gt; &lt;code&gt;d1290G&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6946" LastActivityDate="2017-12-15T12:43:16.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14551" PostTypeId="2" ParentId="14546" CreationDate="2017-12-15T16:51:26.010" Score="1" Body="&lt;p&gt;To show that this can be done in Awk (gawk specifically).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gawk -v FPAT='-?.{7}e[-+]..' -v RS='\nE' '{ gsub(/^[0-9]/, &quot;E&amp;amp;&quot;); gsub(/\n$/, &quot;&quot;) } $21 == &quot;2.58000e+02&quot;' input.txt &amp;gt; output.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For readability:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    gsub(/^[0-9]/, &quot;E&amp;amp;&quot;);&#xA;    gsub(/\n$/, &quot;&quot;)&#xA;}&#xA;&#xA;$21 == &quot;2.58000e+02&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some Gawk details:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use &lt;code&gt;FPAT&lt;/code&gt; to define what is considered a field. In this case something that looks like a number in scientific noation&lt;/li&gt;&#xA;&lt;li&gt;Set the records separator, &lt;code&gt;RS&lt;/code&gt;, to a new line followed by &lt;code&gt;E&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use substitutions (&lt;code&gt;gsub&lt;/code&gt;) to add back the &lt;code&gt;E&lt;/code&gt; to the block and remove trailing newline&lt;/li&gt;&#xA;&lt;li&gt;Output only blocks which field 21 matches &lt;code&gt;2.58000e+02&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can run this in Vim via the filter command, &lt;code&gt;:%!&lt;/code&gt;. See &lt;code&gt;:h :range!&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-12-15T16:51:26.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14552" PostTypeId="1" AcceptedAnswerId="14553" CreationDate="2017-12-16T00:41:11.630" Score="6" ViewCount="2045" Body="&lt;p&gt;On my previous setup, I used the following binding to move between my splits&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;A-Up&amp;gt; :wincmd k&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;A-Down&amp;gt; :wincmd j&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;A-Left&amp;gt; :wincmd h&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;A-Right&amp;gt; :wincmd l&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to switch them to something more vim-like, using the 'hjkl' keys instead of the arrow pad. To do such, I mapped it like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;A-k&amp;gt; :wincmd k&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;A-j&amp;gt; :wincmd j&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;A-h&amp;gt; :wincmd h&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;A-l&amp;gt; :wincmd l&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But its not working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a specific thing to bind it to the &lt;code&gt;alt&lt;/code&gt; key, or do I have to unbind it somewhere?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="15602" LastActivityDate="2017-12-21T15:53:04.453" Title="Map Alt-{ijkl} for tab split navigation" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14553" PostTypeId="2" ParentId="14552" CreationDate="2017-12-16T06:00:34.667" Score="5" Body="&lt;p&gt;Alt-key combos emit different things on different systems. One thing you can do is map the actual key code that your system emits. Instead of something like &lt;code&gt;&amp;lt;A-K&amp;gt;&lt;/code&gt; enter &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; followed by &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;K&lt;/kbd&gt;. On my system that appears as &lt;code&gt;ë&lt;/code&gt; but has the desired effect when I do &lt;code&gt;Alt-K&lt;/code&gt; in Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if you copy your vimrc file to a different system it may not work there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important general tip:&lt;/strong&gt; Unless you have a definitive need to do otherwise &lt;em&gt;always&lt;/em&gt; &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/05.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;use &lt;code&gt;nnoremap&lt;/code&gt; rather than &lt;code&gt;nmap&lt;/code&gt;&lt;/a&gt; (same for &lt;code&gt;inoremap&lt;/code&gt;, &lt;code&gt;cnoremap&lt;/code&gt;, etc.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-12-21T15:53:04.453" LastActivityDate="2017-12-21T15:53:04.453" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14554" PostTypeId="1" CreationDate="2017-12-16T06:52:17.560" Score="1" ViewCount="1332" Body="&lt;p&gt;This is what I have in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if empty(glob('~/.vim/autoload/plug.vim'))&#xA;  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs&#xA;    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC&#xA;endif&#xA;&#xA;call plug#begin('~/.vim/plugged')&#xA;Plug 'junegunn/vim-plug'&#xA;Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }&#xA;call plug#end()&#xA;&#xA;filetype plugin indent on&#xA;set smartcase&#xA;set incsearch&#xA;set hlsearch&#xA;set smartindent&#xA;set wildignore=*.pyc&#xA;set number&#xA;set nowrap&#xA;&#xA;let g:netrw_list_hide= '.*\.pyc$'&#xA;let g:html_indent_inctags = &quot;html,body,head,tbody,div&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I have a name.html file that starts with DOCTYPE and has all the html body etc tags the autoindent works correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I have another file.html in which I have written different things many of which not being correct html format and then I select a specific part of the text that is proper html and then press = it doesn't work.&#xA;Here is the part of file that is pure html and I can't autoindent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &amp;lt;ul class=&quot;pagination&quot;&amp;gt;&#xA;   &amp;lt;li class=&quot;page-item&quot;&amp;gt;&amp;lt;a class=&quot;page-link&quot; href=&quot;#&quot;&amp;gt;Previous&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#xA;     &amp;lt;li class=&quot;page-item&quot;&amp;gt;&amp;lt;a class=&quot;page-link&quot; href=&quot;#&quot;&amp;gt;1&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#xA;       &amp;lt;li class=&quot;page-item&quot;&amp;gt;&amp;lt;a class=&quot;page-link&quot; href=&quot;#&quot;&amp;gt;2&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#xA;         &amp;lt;li class=&quot;page-item&quot;&amp;gt;&amp;lt;a class=&quot;page-link&quot; href=&quot;#&quot;&amp;gt;3&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#xA;           &amp;lt;li class=&quot;page-item&quot;&amp;gt;&amp;lt;a class=&quot;page-link&quot; href=&quot;#&quot;&amp;gt;Next&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#xA;           &amp;lt;/ul&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is what I do to select that part when I'm in the normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;152GV158G=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea on where the problem is coming from and how to fix it!?&lt;/p&gt;&#xA;" OwnerUserId="14609" LastActivityDate="2017-12-16T06:52:17.560" Title="vim autoindent not working correctly" Tags="|vimrc|indentation|filetype-html|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14555" PostTypeId="1" AcceptedAnswerId="14580" CreationDate="2017-12-16T08:13:43.287" Score="4" ViewCount="1678" Body="&lt;p&gt;Oftentimes I'll want to put remaps in my &lt;code&gt;.vimrc&lt;/code&gt; that use plugin commands. When a plugin happens to not be installed, these remaps will result in errors. A simple workaround would be to put an if-statement around plugin-specific remaps that checks whether that plugin has been activated.&lt;/p&gt;&#xA;&lt;p&gt;How can I do this with VimPlug? Does VimPlug store a list somewhere?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;, to clarify things: I need an actual list or a string, not the panel that &lt;code&gt;:PlugStatus&lt;/code&gt; brings up. For example: with &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/35.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;a list&lt;/a&gt; of activated plugins, any mappings specific to the plugin &lt;code&gt;plugin_name&lt;/code&gt; would be wrapped in this if statement:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if index(plugin_list, 'plugin_name') != -1&#xA;  &amp;lt;special maps here&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;code&gt;index&lt;/code&gt; command returns &lt;code&gt;-1&lt;/code&gt; if the string &lt;code&gt;'plugin_name'&lt;/code&gt; is not contained in the list &lt;code&gt;plugin_list&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2020-12-21T04:57:04.990" LastActivityDate="2020-12-21T04:57:04.990" Title="How can I list the plugins currently *active* when using VIM-Plug?" Tags="|plugin-system|plugin-vim-plug|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="14557" PostTypeId="1" CreationDate="2017-12-16T16:35:16.873" Score="2" ViewCount="85" Body="&lt;p&gt;By using &lt;code&gt;suffixesadd&lt;/code&gt; I can navigate modules without file extensions. However, when I import modules by using path completion(&lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-F&amp;gt;&lt;/code&gt;) the file extensions do not get omitted. Are there any options that make path completion omits specific suffixes?&lt;/p&gt;&#xA;" OwnerUserId="6859" LastEditorUserId="6859" LastEditDate="2017-12-17T13:27:20.923" LastActivityDate="2017-12-17T13:27:20.923" Title="Filename completion without suffix" Tags="|autocompletion|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14558" PostTypeId="1" AcceptedAnswerId="14559" CreationDate="2017-12-16T18:04:29.830" Score="3" ViewCount="280" Body="&lt;p&gt;This is probably a really simple question but I can't seem to figure it out myself. I'm using a command from &lt;a href=&quot;https://stackoverflow.com/a/11045051&quot;&gt;this answer on Stackoverflow&lt;/a&gt; to &quot;unwrap&quot; text. The person who answered gave the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/./,-/\n$/j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for unwrapping all paragraphs in a file but keeping the empty line between them. Does it match the whole paragraph somehow? I'm guessing so since the last part seems to match &quot;empty line&quot;. The part that I really can't understand is &lt;code&gt;/,-/&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13769" LastActivityDate="2017-12-16T20:00:32.067" Title="Explain the ./,-/\n$ pattern when using :global" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14559" PostTypeId="2" ParentId="14558" CreationDate="2017-12-16T18:46:00.503" Score="4" Body="&lt;p&gt;It's actually quite subtle.  Here is a step-by-step derivation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First off, the pattern &lt;code&gt;\n$&lt;/code&gt; matches the ends of paragraphs.  It's end-of-line, followed by an end-of-line- the only way this can happen is if the end of a line precedes an empty line.  This is roughly equivalent to &lt;code&gt;\n\ze\n&lt;/code&gt;, except that doesn't work at the end of the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recognize that &lt;code&gt;,-/{re}/&lt;/code&gt; denotes a range, starting from the current result of &lt;code&gt;:g/./&lt;/code&gt; (because of the empty string before the comma).  Together &lt;code&gt;,-/\n$/j&lt;/code&gt; denotes the ranged command &lt;code&gt;:join&lt;/code&gt;.  This is not the normal command &lt;code&gt;J&lt;/code&gt;. (!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g/./{cmd}&lt;/code&gt; collects &lt;em&gt;all&lt;/em&gt; lines containing any characters (i.e., not empty) and runs the ranged command on them.  The real clever bit is that you don't have to worry about going over lines multiple times because we're joining them.  Try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/./,-/\n$/p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will see that at first this prints the entire paragraph which we want to join, but then it starts printing successive sub-paragraphs.  Since we're joining this doesn't matter.  &lt;code&gt;g/&lt;/code&gt; works over its matches one-by-one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is one remaining detail- what is the &lt;code&gt;-&lt;/code&gt; for?   If you try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/./,/\n$/p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this &lt;em&gt;almost&lt;/em&gt; works, but it sometimes adds white-space after paragraphs.  This is because the &lt;code&gt;/&lt;/code&gt; inside a range is defined as the &lt;em&gt;next&lt;/em&gt; line that includes the pattern.  The &lt;code&gt;-&lt;/code&gt; moves the end range up by one &lt;em&gt;before searching&lt;/em&gt; so the potential empty line is not joined in.  This would also be equivalent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/./,-1/\n$/p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-12-16T20:00:32.067" LastActivityDate="2017-12-16T20:00:32.067" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14560" PostTypeId="1" AcceptedAnswerId="14588" CreationDate="2017-12-16T19:03:34.590" Score="2" ViewCount="1194" Body="&lt;p&gt;How do I change the directory when I'm already in &lt;code&gt;:Explorer&lt;/code&gt;?  Sometimes I open it up by saying &lt;code&gt;:vs .&lt;/code&gt; and from there I want to go to &lt;code&gt;~/vim/&lt;/code&gt; or something.  I'm not sure how to do that without traversing the tree to get there or quitting and typing &lt;code&gt;:vs ~/vim/&lt;/code&gt;.  Isn't there some way to change the directory when you're already in &lt;code&gt;:Explorer&lt;/code&gt;?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched using F1 but didn't find anything.  &lt;/p&gt;&#xA;" OwnerUserId="15080" LastActivityDate="2017-12-19T14:26:42.257" Title="Change to a specific directory in :Explorer" Tags="|netrw|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14561" PostTypeId="1" AcceptedAnswerId="14562" CreationDate="2017-12-16T20:54:01.490" Score="2" ViewCount="202" Body="&lt;p&gt;When I enter in visual-mode and I want to delete a block of text before the newline character (only visible if selected/highlighted in visual-mode), I accidentally always select the newline character also, making the line below to &lt;em&gt;move up&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make the visual-mode cursor to discard the newline selection ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I took a look into the help but I think I did not found anything useful for my problem..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could use the &lt;code&gt;set list&lt;/code&gt; option so to see the newline character (red $)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0IMEn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0IMEn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't want to use the &lt;code&gt;set list&lt;/code&gt; neither accidentally select the newline character(0xa).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can achieve this behavior using evim, but of course I don't want to use evim since I loose other modes.&#xA;If this is possible in evim, I understand it's possible also in gvim.&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="15254" LastEditDate="2017-12-16T22:24:05.243" LastActivityDate="2017-12-16T23:49:14.590" Title="Linux gvim visual mode cursor - avoid newline selection" Tags="|visual-mode|highlight|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14562" PostTypeId="2" ParentId="14561" CreationDate="2017-12-16T22:44:01.533" Score="1" Body="&lt;p&gt;I solved using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set selection=exclusive&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the option that controls this behavior.&lt;br&gt;&#xA;For more info check &lt;code&gt;help selection&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="15254" LastEditDate="2017-12-16T23:49:14.590" LastActivityDate="2017-12-16T23:49:14.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14563" PostTypeId="2" ParentId="14489" CreationDate="2017-12-17T01:30:33.457" Score="1" Body="&lt;p&gt;This will work for all window panes not just the NERDTree pane.&#xA;These lines go above in your .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cursorline &#xA;set cursorcolumn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These lines go below in your .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup cursor_off&#xA;    autocmd!&#xA;    autocmd WinLeave * set nocursorline nocursorcolumn&#xA;    autocmd WinEnter * set cursorline cursorcolumn&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15464" LastEditorUserId="15464" LastEditDate="2017-12-17T01:44:57.937" LastActivityDate="2017-12-17T01:44:57.937" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14564" PostTypeId="1" AcceptedAnswerId="14569" CreationDate="2017-12-17T02:09:25.780" Score="4" ViewCount="346" Body="&lt;p&gt;Using vimdiff, I can compare two files and generate it's corresponding HTML via the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;: TOhtml | wq | q | q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(the &lt;code&gt;wq&lt;/code&gt; will save the &lt;code&gt;Diff.html&lt;/code&gt; file, and the two &lt;code&gt;q&lt;/code&gt;s will quit out of the two &lt;code&gt;vimdiff&lt;/code&gt;ing files.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before I output to the &lt;code&gt;Diff.html&lt;/code&gt; file, I'd like for all of the folds (places where code is identical between files) to be expanded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to run a command in Vim, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:normal zo | TOhtml | wq | q | q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the result is not what I expected.  The above multi-command will only expand the folds (via &lt;code&gt;zo&lt;/code&gt;); that is, it will ignore &lt;code&gt;TOhtml&lt;/code&gt;, &lt;code&gt;wq&lt;/code&gt;, &lt;code&gt;q&lt;/code&gt;, and &lt;code&gt;q&lt;/code&gt;.  I have to use the &lt;code&gt;normal&lt;/code&gt; command because &lt;code&gt;zo&lt;/code&gt; is a normal-mode command, as opposed to a execute-mode command.  It seems that when chaining commands after the normal command, the latter commands will not execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Although it appears you cannot have execute commands after a &lt;code&gt;normal&lt;/code&gt; command, you can have a &lt;code&gt;normal&lt;/code&gt; command after an execute command.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:q | normal zo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will in fact quit out of the first file's diff and then expand all folds in the remaining file's diff.&lt;/p&gt;&#xA;" OwnerUserId="15608" LastEditorUserId="15608" LastEditDate="2017-12-17T02:16:44.437" LastActivityDate="2017-12-17T13:05:09.073" Title="Multi-command with normal mode and execute mode" Tags="|vimdiff|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14565" PostTypeId="1" AcceptedAnswerId="14567" CreationDate="2017-12-17T02:40:45.027" Score="1" ViewCount="1511" Body="&lt;p&gt;I'm trying SpaceVim and I would like to use the plugin UltiSnips with it, instead of Neosnippets that comes with it as default.&#xA;Based on what I found in &lt;a href=&quot;http://spacevim.org/documentation&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://spacevim.org/documentation&lt;/a&gt;, &lt;a href=&quot;https://spacevim.org/layers&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://spacevim.org/layers&lt;/a&gt; and in :h SpaceVim I did what follows.&#xA;I added this to .SpaceVim.d/init.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:spacevim_force_global_config = 0&#xA;let g:spacevim_snippet_engine = 'ultisnips'&#xA;&quot; disable neosnippet to avoid conflict with UltiSnips&#xA;let g:spacevim_disabled_plugins=[&#xA;\ ['Shougo/neosnippet.vim'],&#xA;\ ]&#xA;&quot; custom plugin&#xA;let g:spacevim_custom_plugins=[&#xA;\ ['SirVer/ultisnips/', {'on_ft' : 'autocomplete'}],&#xA;\ ]&#xA;let g:neosnippet#snippets_directory = '~/.SpaceVim.d/snippets'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I created manually a directory 'snippets' inside .SpaceVim.d and put a directory UltiSnips with my snippet file 'tidal.snippets', for &lt;a href=&quot;https://tidalcycles.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tidal&lt;/a&gt;.&#xA;My snippets are like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet spr$ &quot;spread ($)&quot; i&#xA;spread ($) [ $1, $2, $3 $0]&#xA;  ${VISUAL}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My setup is Linux Ubuntu 17.10, Neovim, SpaceVim 0.6-dev&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm getting this errors when I try to expand a snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function SpaceVim#mapping#tab#expandable:                                                                             &#xA;line    1:                                                                                                                                            &#xA;E117: Unknown function: UltiSnips#ExpandSnippetOrJump                                                                                                 &#xA;Press ENTER or type command to continue                                                                                                               &#xA;Error detected while processing function SpaceVim#mapping#tab#expandable:                                                                             &#xA;line    1:                                                                                                                                            &#xA;E15: Invalid expression: UltiSnips#ExpandSnippetOrJump()                                                                                              &#xA;Press ENTER or type command to continue                                                                                                               &#xA;Error detected while processing function SpaceVim#mapping#tab#expandable:                                                                             &#xA;line    2:                                                                                                                                            &#xA;E121: Undefined variable: g:ulti_expand_or_jump_res                                                                                                   &#xA;Press ENTER or type command to continue                                                                                                               &#xA;Error detected while processing function SpaceVim#mapping#tab#expandable:                                                                             &#xA;line    2:                                                                                                                 &#xA;E15: Invalid expression: g:ulti_expand_or_jump_res &amp;gt; 0                                                                                                &#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'm doing wrong? How could I make this work?&lt;/p&gt;&#xA;" OwnerUserId="15606" LastEditorUserId="51" LastEditDate="2017-12-17T09:40:48.797" LastActivityDate="2017-12-17T09:40:48.797" Title="How to use UltiSnips with SpaceVim?" Tags="|neovim|plugin-ultisnips|spacevim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14566" PostTypeId="2" ParentId="14502" CreationDate="2017-12-17T03:55:23.220" Score="1" Body="&lt;p&gt;As the vim community did not have such a plugin I have then developed it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is available at:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/fmv1992/vim_dictionary&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/fmv1992/vim_dictionary&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Features&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Works offline (downloads a dictionary during the install).&lt;/li&gt;&#xA;&lt;li&gt;Is asynchronous: one instance of the plugin launches a server which serves all your vim instances (memory efficient).&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is &lt;strong&gt;simple&lt;/strong&gt;: just one command is defined: &lt;code&gt;:Dictionary&lt;/code&gt;. Usage:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Simple to install: &lt;code&gt;make install&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Simple to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Dictionary rodent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yields:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RODENT&#xA;Ro&quot;dent, a. Etym: [L. rodens, -entis, p. pr. of rodere to gnaw. See&#xA;Rase, v. t., and cf. Rostrum.]&#xA;&#xA;1. Gnawing; biting; corroding; (Med.) applied to a destructive&#xA;variety of cancer or ulcer.&#xA;&#xA;2. (Zoöl.)&#xA;(a) Gnawing.&#xA;(b) Of or pertaining to the Rodentia.&#xA;&#xA;RODENT&#xA;Ro&quot;dent, n. (Zoöl.)&#xA;&#xA;Defn: One of the Rodentia.&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Has highlightings for ease of reading.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Has a battery of tests and is passing on TravisCI (therefore it meets a good coding standard).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Requirements&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vim8&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;+channel&lt;/code&gt; feature&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;python3&lt;/code&gt; feature&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Screencasting&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://asciinema.org/a/s9Gk1QCcPBwjM4OAxViNIlUoR&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://asciinema.org/a/s9Gk1QCcPBwjM4OAxViNIlUoR.png&quot; alt=&quot;asciicast&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any feedback is appreciated. Made for the vim community.&lt;/p&gt;&#xA;" OwnerUserId="10216" LastActivityDate="2017-12-17T03:55:23.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14567" PostTypeId="2" ParentId="14565" CreationDate="2017-12-17T07:35:06.260" Score="1" Body="&lt;p&gt;Just remove&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:spacevim_custom_plugins=[&#xA;\ ['SirVer/ultisnips/', {'on_ft' : 'autocomplete'}],&#xA;\ ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;no need to use custom plugin, just change &lt;code&gt;g:spacevim_snippet_engine&lt;/code&gt; is enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still get issue, please use the issue tracker of SpaceVim github repo.&lt;/p&gt;&#xA;" OwnerUserId="7942" LastEditorUserId="51" LastEditDate="2017-12-17T09:40:33.067" LastActivityDate="2017-12-17T09:40:33.067" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14568" PostTypeId="2" ParentId="14288" CreationDate="2017-12-17T07:42:06.070" Score="2" Body="&lt;p&gt;In SpaceVim, all layers is a list in &lt;code&gt;g:spacevim_plugin_groups&lt;/code&gt;. you can remove item in it. but it is not better way to remove layers. we will Update document about layer config. please check out the PRs in spacevim repo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2017-12-17T07:42:06.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14569" PostTypeId="2" ParentId="14564" CreationDate="2017-12-17T13:05:09.073" Score="4" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3Anormal&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :normal&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This command cannot be followed by another command,&#xA;since any '|' is considered part of the command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can get around this by using &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Aexecute&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:execute&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 'normal! zo' | TOhtml | wq | q | q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But perhaps it is better to make a function/command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! DiffHTML()&#xA;    normal! zo&#xA;    TOhtml&#xA;    wq | q | q&#xA;endfun&#xA;&#xA;command! DiffHTML call DiffHTML&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-12-17T13:05:09.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14570" PostTypeId="1" CreationDate="2017-12-17T17:06:22.420" Score="3" ViewCount="702" Body="&lt;p&gt;I use Ubuntu as my desktop OS. I want my vim to be portable so that I can use my vim configuration as well as the plugins I use in my college PCs too. Is there any way to have a portable version of Vim for Ubuntu or similar Linux distros?&lt;/p&gt;&#xA;" OwnerUserId="15616" LastActivityDate="2018-01-16T18:56:46.977" Title="Portable Vim for Ubuntu Linux" Tags="|linux-ubuntu|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14571" PostTypeId="2" ParentId="14570" CreationDate="2017-12-17T18:07:22.060" Score="1" Body="&lt;p&gt;Save your .vimrc online and download it to each computer you use. Make sure Vim is installed on each one of those computers.&lt;/p&gt;&#xA;" OwnerUserId="15464" LastActivityDate="2017-12-17T18:07:22.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14573" PostTypeId="2" ParentId="14541" CreationDate="2017-12-17T18:24:05.457" Score="11" Body="&lt;p&gt;In gvim you use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guicursor+=a:blinkon0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In vim run in the terminal you would change the terminal setting to disable the blinking.&lt;/p&gt;&#xA;" OwnerUserId="15464" LastActivityDate="2017-12-17T18:24:05.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14574" PostTypeId="2" ParentId="14570" CreationDate="2017-12-17T18:43:48.253" Score="1" Body="&lt;p&gt;Echoing &lt;a href=&quot;https://vi.stackexchange.com/a/14571/10604&quot;&gt;tluafed’s answer&lt;/a&gt;, one solution is to version control your configuration and clone/symlink it on each machine. Then keeping up-to-date is as easy as pulling changes on each machine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is particularly easy using e.g. &lt;a href=&quot;http://github.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;. You can find a number of dotfile repos (including &lt;a href=&quot;http://github.com/benknoble/Dotfiles&quot; rel=&quot;nofollow noreferrer&quot;&gt;mine&lt;/a&gt;) there. My repo contains vim configuration, a large number of other dotfiles, and an installation script (since I’m doing more than just symlinking things). However, you can browse it to get a basic idea of how to set up a vim config or dotfiles repo, and optionally write a script to do the symlinking for you. This is a fairly common solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt; that some plugins may not be compatible with all versions of Vim, so if running more than one version you’ll need a way to disable plugins on a per-machine basis. I use &lt;a href=&quot;https://git-scm.com/book/en/v2/Git-Tools-Submodules&quot; rel=&quot;nofollow noreferrer&quot;&gt;git submodules&lt;/a&gt; for this, allowing me to simply activate the ones that work.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2017-12-17T18:43:48.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14575" PostTypeId="1" AcceptedAnswerId="14584" CreationDate="2017-12-17T22:55:08.710" Score="4" ViewCount="2245" Body="&lt;p&gt;I managed to record a macro pressing &lt;code&gt;&amp;lt;leader&amp;gt;-q-r-&amp;lt;letter&amp;gt;&lt;/code&gt;, but I can't make it play.&#xA;The documentations says &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SpaceVim has mapped normal &lt;code&gt;q&lt;/code&gt; as smart buffer close, the normal func of&#xA;  &lt;code&gt;q&lt;/code&gt; can be get by &lt;code&gt;&amp;lt;leader&amp;gt;qr&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;but says nothing about playing it.&#xA;I tried &lt;code&gt;&amp;lt;leader&amp;gt;-@-r-&amp;lt;letter&amp;gt;&lt;/code&gt; and &lt;code&gt;@-r-&amp;lt;letter&amp;gt;&lt;/code&gt; but it didn't work.&#xA;Could it be because I'm using a German keyboard and the '@' is &lt;code&gt;&amp;lt;AltGr&amp;gt;@-q&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="15606" LastEditorUserId="343" LastEditDate="2017-12-18T10:10:25.467" LastActivityDate="2017-12-18T10:10:25.467" Title="How to play recorder macro in SpaceVim?" Tags="|macro|spacevim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14576" PostTypeId="1" AcceptedAnswerId="14577" CreationDate="2017-12-18T01:01:01.030" Score="0" ViewCount="226" Body="&lt;p&gt;I just realized some &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; maps I have in my &lt;code&gt;.vimrc&lt;/code&gt; were being silently ignored on an installation of VIM on a remote server that I'm using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I check whether the &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; option is available at all, and skip those sections of my &lt;code&gt;.vimrc&lt;/code&gt; if it is not?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastActivityDate="2017-12-18T01:49:19.493" Title="How to check if `&lt;nowait&gt;` mapping option is available for current VIM installation?" Tags="|vimrc|key-bindings|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14577" PostTypeId="2" ParentId="14576" CreationDate="2017-12-18T01:49:19.493" Score="2" Body="&lt;p&gt;&lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; was added in version 7.3.1261.  You can check for at least this version using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if v:version &amp;gt; 703 || v:version == 703 &amp;amp;&amp;amp; has(&quot;patch1261&quot;)&#xA;   ...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-12-18T01:49:19.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14578" PostTypeId="1" AcceptedAnswerId="14579" CreationDate="2017-12-18T03:07:32.747" Score="3" ViewCount="349" Body="&lt;p&gt;How can I perform a search-and-replace and leave the cursor at the end of the replacement? I want to replace $...$ with \(...\) as I type in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that I can't use an abbreviation, since $ is replaced with two different strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution I've cobbled together so far is equivalent to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Foo()&#xA;    let pat = '\$\(.\{-}\)\$'&#xA;    if line =~ pat&#xA;        execute 's/' . pat . '/\\(\1\\)/'&#xA;        call cursor('.', matchend(getline('.'), '\\)'))&#xA;    endif&#xA;endfunction&#xA;&#xA;inoremap $ $&amp;lt;C-O&amp;gt;:call Foo()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to do this? The only alternative I found is to add the length of '\\)' to the column number from searchpos, and that isn't any nicer.&lt;/p&gt;&#xA;" OwnerUserId="13278" LastActivityDate="2017-12-19T15:16:01.970" Title="Replace text and move cursor to end of replacement in insert mode" Tags="|vimscript|cursor-movement|insert-mode|filetype-tex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14579" PostTypeId="2" ParentId="14578" CreationDate="2017-12-18T04:54:41.810" Score="4" Body="&lt;p&gt;One way to get this effect is to instead adaptively enter either &lt;code&gt;\(&lt;/code&gt; or &lt;code&gt;\)&lt;/code&gt; depending on which is needed.  So the first &lt;code&gt;$&lt;/code&gt; will type &lt;code&gt;\(&lt;/code&gt; and the second will type &lt;code&gt;\)&lt;/code&gt;.  To figure out which we need, we use &lt;code&gt;searchpairpos&lt;/code&gt;, which returns &lt;code&gt;[0,0]&lt;/code&gt; when outside the &lt;code&gt;\(..\)&lt;/code&gt; pair.  Besides being cleaner to code, it is also a bit nicer while typing and works over multiple lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! IDollar()&#xA;  let [l:l,l:c] = searchpairpos('\\(', '', '\\)', 'cbWn')&#xA;  return l:l ? '\)' : '\('&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; $ IDollar()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you would rather the exact behavior mentioned in your question, here is an improved version of your script.  There are a few differences:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;use &lt;code&gt;setline&lt;/code&gt; instead of &lt;code&gt;s/&lt;/code&gt; because there are fewer side-effects,&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;cursor()&lt;/code&gt; since we know the cursor always needs to move forward by 2, &lt;/li&gt;&#xA;&lt;li&gt;use the &lt;code&gt;&amp;lt;c-r&amp;gt;=&lt;/code&gt; pattern instead of &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; since &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; resets the last insert position (useful when &lt;code&gt;backspace&lt;/code&gt; does not contain &lt;code&gt;start&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Foo()&#xA;  let l:pat = '\$\([^\$]\+\)\$'&#xA;  let l:line = getline('.')&#xA;  if l:line =~ l:pat&#xA;    call setline('.', substitute(l:line, l:pat, '\\(\1\\)', ''))&#xA;    call cursor(0, col('.')+2)&#xA;  endif&#xA;  return ''&#xA;endfunction&#xA;inoremap $ $&amp;lt;c-r&amp;gt;=Foo()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-12-18T05:23:27.407" LastActivityDate="2017-12-18T05:23:27.407" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14580" PostTypeId="2" ParentId="14555" CreationDate="2017-12-18T04:55:07.727" Score="5" Body="&lt;p&gt;You can get all plugs from &lt;code&gt;g:plugs_order&lt;/code&gt; list or &lt;code&gt;g:plugs&lt;/code&gt; dict.&#xA;&lt;code&gt;g:plugs&lt;/code&gt;'s value also contain useful config infomation about the plug. Like &lt;code&gt;dir&lt;/code&gt; where the plug is installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has_key(g:plugs, &quot;name&quot;)&#xA;    &quot; do something&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to check and do something when the plug exist.&lt;/p&gt;&#xA;" OwnerUserId="15622" LastEditorUserId="28" LastEditDate="2017-12-18T06:46:56.490" LastActivityDate="2017-12-18T06:46:56.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14581" PostTypeId="1" AcceptedAnswerId="14585" CreationDate="2017-12-18T07:25:26.973" Score="2" ViewCount="1322" Body="&lt;p&gt;I just installed Linux Mint 18.3 and to my surprise colors in vim changed!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0Zh7K.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0Zh7K.png&quot; alt=&quot;comparison screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim in the terminal on the left has the color scheme I've always seen and got used to. Vim in the terminal on the right has the new colors. On the left, I'm ssh'ed into a different machine. On the right is my new Mint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both windows are of the same terminal emulator, with the same profile settings, so the issue is not with my color scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get the normal colors back?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; It looks like the old colors flash for a tenth of a second when I open a file, but then the colors are reverted to new. As I wrote in the comments, in both cases, &lt;code&gt;:colorscheme&lt;/code&gt; returns &lt;code&gt;default&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10391" LastEditorUserId="4472" LastEditDate="2017-12-22T11:34:35.330" LastActivityDate="2023-01-03T23:31:03.013" Title="Get back regular vim colors" Tags="|syntax-highlighting|terminal|color|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14582" PostTypeId="1" AcceptedAnswerId="14583" CreationDate="2017-12-18T08:36:49.420" Score="0" ViewCount="646" Body="&lt;pre&gt;&lt;code&gt;function! JumpDef()&#xA;    normal! &amp;lt;C-]&amp;gt;&#xA;endfunction&#xA;if &amp;amp;filetype != &quot;elixir&quot;&#xA;    nnoremap &amp;lt;C-]&amp;gt; :call JumpDef()&amp;lt;CR&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the filetype is not elixir, pressing &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; does nothing. I would have expected the above to do exactly the same thing as if the above code was not there. Why does it not exist?&lt;/p&gt;&#xA;" OwnerUserId="11136" LastActivityDate="2017-12-18T09:49:17.890" Title="normal! &lt;C-]&gt; Not working" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14583" PostTypeId="2" ParentId="14582" CreationDate="2017-12-18T09:43:00.453" Score="5" Body="&lt;p&gt;The notation you're using for &lt;code&gt;CTRL-]&lt;/code&gt; doesn't work in that context. The command you're using will act as though you had typed the following five keystrokes in normal mode: &lt;kbd&gt;&amp;lt;&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt;&lt;kbd&gt;-&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;&gt;&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to invoke the &lt;code&gt;CTRL-]&lt;/code&gt; functionality, use the following instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;normal! \&amp;lt;C-]&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(See &lt;code&gt;:help :execute&lt;/code&gt; and &lt;code&gt;:help string&lt;/code&gt; for more details of how this works.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an aside, if the code you've pasted is in your &lt;code&gt;vimrc&lt;/code&gt;, it won't have the effect you're aiming for, of creating a mapping that doesn't apply to the elixir filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code in your vimrc is run when Vim is starting up before the file is opened: at that time, &lt;code&gt;'filetype'&lt;/code&gt; will never be set to &lt;code&gt;elixir&lt;/code&gt;, and thus the mapping will always be created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One simple way to fix this is to move the filetype check into the mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! JumpDef()&#xA;    if &amp;amp;filetype != &quot;elixir&quot;&#xA;        execute &quot;normal! \&amp;lt;C-]&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;C-]&amp;gt; :call JumpDef()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2017-12-18T09:49:17.890" LastActivityDate="2017-12-18T09:49:17.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14584" PostTypeId="2" ParentId="14575" CreationDate="2017-12-18T10:01:42.630" Score="8" Body="&lt;p&gt;SpaceVim uses &lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt; instead of &lt;kbd&gt;q&lt;/kbd&gt; because it remaps &lt;kbd&gt;q&lt;/kbd&gt; to another function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I can tell from the documentation, &lt;kbd&gt;@&lt;/kbd&gt; is not used for another function: so you play back macros in the usual way: &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;letter&lt;/kbd&gt; &lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2017-12-18T10:01:42.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14585" PostTypeId="2" ParentId="14581" CreationDate="2017-12-18T19:52:27.007" Score="4" Body="&lt;p&gt;I'm not sure what you mean by &quot;profile settings&quot;, but I'm assuming you mean terminal profiles, which don't affect vim (much).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try opening your &lt;code&gt;.vimrc&lt;/code&gt;.  It should be in your home directory, named that.  Inside the &lt;code&gt;.vimrc&lt;/code&gt;, you can set different settings to load every time you open vim, such as colorschemes.  If you want to always use the default one, just add &lt;code&gt;colorscheme default&lt;/code&gt; into the file.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, neither of the images you have look like the default scheme to me.  Your best bet is to check the colorscheme of the terminal you like with &lt;code&gt;:colorscheme&lt;/code&gt; (with vim open, of course) and add that to your newer terminal's vimrc.  You may also need to copy the colorscheme file from &lt;code&gt;/usr/share/vim/colors/&lt;/code&gt;, into the new terminal.  You may need to poke around a bit in &lt;code&gt;/usr/share/vim&lt;/code&gt; first, it's been a while since I've installed Mint.  After the scheme is copied over, set the scheme you want with &lt;code&gt;colorscheme name_of_scheme_you_desire&lt;/code&gt; in your vimrc, and that's it.&lt;/p&gt;&#xA;" OwnerDisplayName="user11389" LastActivityDate="2017-12-18T19:52:27.007" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14586" PostTypeId="1" CreationDate="2017-12-19T06:25:15.043" Score="5" ViewCount="783" Body="&lt;p&gt;I'm running into a problem that I've never really ran into before with my setup. I've set up my NERDTree config in the &lt;code&gt;.vimrc&lt;/code&gt; so that every time that I open a directory NERDTree will also open but it should also stay open when I open a file (NERDTree to the left and buffers to the right) however, it doesn't do that. Right now it does open NERDTree but once I click &lt;code&gt;enter&lt;/code&gt; on the file I want to open, NERDTree closes and I'm left only with the file I opened (no NERDTree on the left). The code is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd StdinReadPre * let s:std_in=1&#xA;autocmd VimEnter * if argc() == 0 &amp;amp;&amp;amp; !exists(&quot;s:std_in&quot;) | NERDTree | endif&#xA;autocmd bufenter * if (winnr(&quot;$&quot;) == 1 &amp;amp;&amp;amp; exists(&quot;b:NERDTree&quot;) &amp;amp;&amp;amp; b:NERDTree.isTabTree()) | q | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this is the config I've been using on my &lt;code&gt;.vimrc&lt;/code&gt; for NERDTree for quite some time, usually I just copy+paste my &lt;code&gt;.vimrc&lt;/code&gt; into any new install of vim and it works after setting everything up. And in this case, everything else works, and even NERDTree, but it just closes after I open the file. &lt;/p&gt;&#xA;" OwnerUserId="15636" LastActivityDate="2019-08-12T20:03:00.460" Title="NERDTree on Vim" Tags="|plugin-nerdtree|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14587" PostTypeId="1" AcceptedAnswerId="14590" CreationDate="2017-12-19T13:19:08.967" Score="29" ViewCount="25530" Body="&lt;p&gt;In vim, I can put color schemes inside &lt;code&gt;~/.vim/colors/&lt;/code&gt; folder. Where should I put color schemes so that NeoVim can pick them up?&lt;/p&gt;&#xA;" OwnerUserId="5643" LastActivityDate="2019-07-28T00:20:12.263" Title="Which directory to put color schemes?" Tags="|neovim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14588" PostTypeId="2" ParentId="14560" CreationDate="2017-12-19T14:20:40.690" Score="2" Body="&lt;p&gt;Simply opening a directory for &quot;editing&quot; works just fine for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e ~/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-12-19T14:26:42.257" LastActivityDate="2017-12-19T14:26:42.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14589" PostTypeId="2" ParentId="14578" CreationDate="2017-12-19T15:16:01.970" Score="2" Body="&lt;p&gt;You can use &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;surround.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:surround_{char2nr('R')} = &quot;\\(\r\\)&quot;&#xA;imap $ $&amp;lt;esc&amp;gt;cs$R`]a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to create a custom surrounding, &quot;R&quot;, which is &lt;code&gt;\(...\)&lt;/code&gt;. We use this surrounding to replace &lt;code&gt;$...$&lt;/code&gt;. Use the &lt;code&gt;']&lt;/code&gt; mark to restart the insert at the end of the changed text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h surround-customizing&#xA;:h surround-mappings&#xA;:h ']&#xA;:h char2nr(&#xA;:h curly-braces-names&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-12-19T15:16:01.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14590" PostTypeId="2" ParentId="14587" CreationDate="2017-12-19T15:46:43.897" Score="37" Body="&lt;p&gt;The directory is &lt;code&gt;~/.config/nvim/colors&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5643" LastActivityDate="2017-12-19T15:46:43.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14591" PostTypeId="1" CreationDate="2017-12-19T16:47:42.383" Score="1" ViewCount="913" Body="&lt;h1&gt;Problem Statement&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Currently I use VIM in a terminal to write code. All my notes are on Microsoft Word 365, which I have been using for a long while.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using markdown recently, used VIM to write the code, then preview the formatting in Google Chrome but faced a lot of problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since my notes have lots of equations, I use MathJax to write the equations. If I use MathJax for inserting equations in Mardown documents, using VIM, there is no easy way to tell if the equation is correctly formatted. So, I have to preview the .md file in Google Chrome with a Google Chrome Extension (&lt;a href=&quot;https://chrome.google.com/webstore/detail/markdown-viewer/ckkdlimhmcjmikdlpkmbgfkaikojcbjk?utm_source=chrome-app-launcher-info-dialog&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://chrome.google.com/webstore/detail/markdown-viewer/ckkdlimhmcjmikdlpkmbgfkaikojcbjk?utm_source=chrome-app-launcher-info-dialog&lt;/a&gt;). However, when I load/reload/autoload the .md file in Google Chrome, it takes me to the top of the .md file, not at the last edited location, which tends to be far away from the current location. &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Is there any Windows/Linux application which will show the formatted document (with images, equations etc) at the &lt;strong&gt;current cursor location&lt;/strong&gt;, similar to when using Microsoft Word, when I am editing the .md file in VIM?&lt;/p&gt;&#xA;" OwnerUserId="13848" LastEditorUserId="51" LastEditDate="2017-12-20T23:41:36.110" LastActivityDate="2017-12-20T23:41:36.110" Title="Viewer for Markdown/MathJax rich text editing in vim/neovim?" Tags="|neovim|filetype-markdown|large-documents|filetype-mathjax|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14592" PostTypeId="2" ParentId="4817" CreationDate="2017-12-19T17:28:10.327" Score="1" Body="&lt;p&gt;Another solution (in normal mode) after opening vim/neovim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ctrl-o Ctrl-o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2017-12-19T17:28:10.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14593" PostTypeId="2" ParentId="14586" CreationDate="2017-12-19T18:26:23.110" Score="1" Body="&#xA;&#xA;&lt;p&gt;I have these in my config. This works well.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;&quot;Open NERDtree automatically on vim startup&#xA;autocmd vimenter * NERDTree&#xA;&#xA;&quot;close NERDtree if that is the last window left&#xA;autocmd bufenter * if (winnr(&quot;$&quot;) == 1 &amp;amp;&amp;amp; exists(&quot;b:NERDTree&quot;) &amp;amp;&amp;amp; b:NERDTree.isTabTree()) | q | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13848" LastEditorDisplayName="user11389" LastEditDate="2017-12-20T01:21:45.820" LastActivityDate="2017-12-20T01:21:45.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14594" PostTypeId="2" ParentId="14586" CreationDate="2017-12-19T23:08:02.847" Score="0" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; don't quit NERDTree after opening a buffer&#xA;let NERDTreeQuitOnOpen = 0&#xA;&quot; start NERDTree when vim starts&#xA;autocmd VimEnter * NERDTree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="15254" LastEditDate="2017-12-20T13:32:55.940" LastActivityDate="2017-12-20T13:32:55.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14595" PostTypeId="1" CreationDate="2017-12-19T23:13:34.610" Score="3" ViewCount="110" Body="&lt;p&gt;The repeat command &lt;code&gt;.&lt;/code&gt; is awesome. Is it possible to cycle through the last few commands, instead of only being able to repeat the last command? Something like yankring for repeat?&lt;/p&gt;&#xA;" OwnerUserId="6154" LastActivityDate="2017-12-20T01:47:21.457" Title="Repeat not only last command" Tags="|repeated-commands|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14596" PostTypeId="1" AcceptedAnswerId="14601" CreationDate="2017-12-19T23:20:24.180" Score="3" ViewCount="54" Body="&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;test &quot;UD.1 should delete the given record&quot; do&#xA;  [user, compnay ] = insert_record()&#xA;  asset = Asset |&amp;gt; last |&amp;gt; Repo.one&#xA;  {:ok, deleted} = Delete.delete(to_string(asset.id), user, company)&#xA;  assert asset.id == deleted.id&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is an &lt;code&gt;.exs&lt;/code&gt; file. I have done &lt;code&gt;:set spell&lt;/code&gt; and you can see the &lt;code&gt;UD&lt;/code&gt; has a line under it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the second line, &lt;code&gt;compnay&lt;/code&gt; is spelled incorrectly, however the spell checker is not picking it up. Why is that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need to install something?&lt;/p&gt;&#xA;" OwnerUserId="15642" LastEditorUserId="15642" LastEditDate="2017-12-20T00:16:08.863" LastActivityDate="2017-12-20T04:57:18.707" Title="Why the spellcheck is not working properly for .exs files?" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14597" PostTypeId="1" CreationDate="2017-12-19T23:22:54.940" Score="3" ViewCount="244" Body="&lt;p&gt;I am using the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1879&quot; rel=&quot;nofollow noreferrer&quot;&gt;autocomplete&lt;/a&gt; and I feel quite comfortable with it because it's minimalistic and simple.&#xA;But there is just a thing I dislike: sometimes it interferes with the mouse scrolling auto-changing some word...&#xA;Well, sometimes it also interferes when I jump from word to word in insert-mode, obligating me to undo the pop-up with direction keys...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps in this last weeks I am playing too much with vim, but my intention is to investigate the small plugin code to adjust it as my needs (if possible), enabling / disabling it depending if I am writing or not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pseudocode I thought is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start typing or entering insert-mode, execute &lt;code&gt;acp#enable()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Stop typing or exit from insert-mode, execute &lt;code&gt;acp#disable()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So is there any possible vim option that could enable it only when I am typing and disable after a short timeout when I stop/pause typing text ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this too good to be true?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just saw these interesting features: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TextChangedI            &#xA;                After a change was made to the text in the&#xA;                current buffer in Insert mode.&#xA;                Not triggered when the popup menu is visible.&#xA;                Otherwise the same as TextChanged.&#xA;&#xA;InsertCharPre           &#xA;                When a character is typed in Insert mode,&#xA;                before inserting the char.&#xA;                The |v:char| variable indicates the char typed&#xA;                and can be changed during the event to insert&#xA;                a different character.  When |v:char| is set&#xA;                to more than one character this text is&#xA;                inserted literally.&#xA;                It is not allowed to change the text |textlock|.&#xA;                The event is not triggered when 'paste' is&#xA;                set.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;help timeout&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorDisplayName="user11389" LastEditDate="2017-12-20T08:44:14.293" LastActivityDate="2024-03-17T12:06:00.773" Title="gvim Linux - autocomplete plugin - enable / disable depending if the user is typing or not" Tags="|autocompletion|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14598" PostTypeId="1" AcceptedAnswerId="14604" CreationDate="2017-12-20T01:35:38.487" Score="9" ViewCount="1661" Body="&lt;p&gt;In one of the vim plugins I use, we have been thinking about using python vs vimscript going forward (&lt;a href=&quot;https://github.com/python-mode/python-mode/issues/813#issuecomment-344754563&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/python-mode/python-mode/issues/813#issuecomment-344754563&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that you can use Python to write plugins for VIM (&lt;a href=&quot;https://dzone.com/articles/how-write-vim-plugins-python&quot; rel=&quot;noreferrer&quot;&gt;https://dzone.com/articles/how-write-vim-plugins-python&lt;/a&gt;) as long as you have a &lt;code&gt;+python&lt;/code&gt;/&lt;code&gt;+python3&lt;/code&gt; in your vim distribution, the plugin should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't written any plugins for VIM, but I think writing an opensource VIM plugin for Python development in Python is better compared to writing it in VimL. You will notice that there are multiple users who suggested solutions, but don’t know VimL, and don’t want to learn it, because they already know Python and are working in Python. Thus writing new code in Python going forward will enable us to get more users as well as get more contributors and create more value.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;What are the drawbacks of writing a Vim plugin using Python vs VimL? (Let's assume that all users who use this plugin already has &lt;code&gt;+python&lt;/code&gt;/&lt;code&gt;+python3&lt;/code&gt;, because they are going to be using it to develop Python)&lt;/p&gt;&#xA;" OwnerUserId="13848" LastEditorUserId="51" LastEditDate="2017-12-20T23:41:16.220" LastActivityDate="2017-12-24T17:40:22.220" Title="Drawbacks of using Python to develop new code in a VIM plugin" Tags="|vimscript|plugin-system|vimscript-python|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14599" PostTypeId="2" ParentId="14595" CreationDate="2017-12-20T01:47:21.457" Score="3" Body="&lt;p&gt;From what I understand Vim doesn’t have a way of repeating normal mode history use a while back, unless you write it out to a file: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/587/13848&quot;&gt;https://vi.stackexchange.com/a/587/13848&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2017-12-20T01:47:21.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14600" PostTypeId="1" CreationDate="2017-12-20T04:27:49.507" Score="1" ViewCount="262" Body="&lt;p&gt;I'm &lt;em&gt;quite&lt;/em&gt; new to Vimscript and editing &lt;code&gt;~/.vimrc&lt;/code&gt;, and was tweaking this file after having installed Pathogen and Syntastic to do live syntax checking for JavaScript. However, in my current set-up, I want Syntastic to use the per-project executables for the syntax checking, located within &lt;code&gt;./node_modules/.bin/&lt;/code&gt; (the command &lt;code&gt;npm bin&lt;/code&gt; returns this path). In my search for how to do this, I came across GitHub issues like &lt;a href=&quot;https://github.com/vim-syntastic/syntastic/issues/1692&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;, using the following Vimscript variable and assignment (or something like it; there are several instances on that page):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_javascript_eslint_exe = '$(npm bin)/eslint'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, in my attempts to use this construct, it wouldn't &quot;work&quot;; &lt;code&gt;eslint&lt;/code&gt; isn't found, and running &lt;code&gt;:SyntasticInfo&lt;/code&gt; shows that there are no checkers available for &lt;code&gt;.js&lt;/code&gt; and &lt;code&gt;.jsx&lt;/code&gt; files. However, when I adapted this to the following...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_javascript_eslint_exec = '`npm bin`/eslint'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... it works! Could someone explain to me, this noob, why the first construct doesn't work, what I could be missing here? Really wanting to learn! &lt;/p&gt;&#xA;" OwnerUserId="15644" LastActivityDate="2017-12-20T04:27:49.507" Title="Backticks vs. $() in strings/variable assignment" Tags="|vimrc|vimscript|plugin-syntastic|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14601" PostTypeId="2" ParentId="14596" CreationDate="2017-12-20T04:57:18.707" Score="3" Body="&lt;p&gt;Use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  :syntax spell toplevel&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Many file types define regions where spell checking takes place. This is usually comments and strings, leaving the rest of the code not spell checked. However, you can change this behavior by having vim spell check everything (called the toplevel syntax).&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2017-12-20T04:57:18.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14602" PostTypeId="1" CreationDate="2017-12-20T06:58:31.940" Score="2" ViewCount="2903" Body="&lt;p&gt;Following the instructions on the &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vundle GitHub page&lt;/a&gt;, entering &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in terminal on MacOS gives &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;fatal: could not create leading directories of '/Users/carlo/.vim/bundle/Vundle.vim': Not a directory&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think it has to do with the &lt;code&gt;/.vim&lt;/code&gt; directory being hidden, but I couldn't get past this.&lt;/p&gt;&#xA;" OwnerUserId="15647" LastEditorUserId="135" LastEditDate="2017-12-20T12:29:44.123" LastActivityDate="2018-03-20T20:40:35.960" Title="Installing Vundle: &quot;fatal: could not create leading directories&quot;" Tags="|macos|plugin-vundle|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14604" PostTypeId="2" ParentId="14598" CreationDate="2017-12-20T15:59:45.077" Score="9" Body="&lt;h3&gt;TL;DR:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Requiring &lt;code&gt;+python&lt;/code&gt;/&lt;code&gt;+python3&lt;/code&gt; support for a python based development plugin. That sounds completely reasonable.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;About Vim plugins and human behavior&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Generally, speaking humans want things to appear simple and &quot;just work&quot;. When it comes to Vim plugins, Vimmers typically want plugins with no or very few dependencies. Basically it should be as simple as a &lt;code&gt;git clone&lt;/code&gt; and/or a few lines in their &lt;code&gt;vimrc&lt;/code&gt; file. The more a plugin requires to be configured in order to work initially or requires some dependency is just adding a barrier to entry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A great example of this behavior is &lt;a href=&quot;https://github.com/wincent/command-t&quot; rel=&quot;noreferrer&quot;&gt;CommandT&lt;/a&gt; vs &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;noreferrer&quot;&gt;CtrlP&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CommandT uses Ruby and C to accomplish fuzzy finding&lt;/li&gt;&#xA;&lt;li&gt;CtrlP on the other hand is pure VimL/Vimscript&lt;/li&gt;&#xA;&lt;li&gt;CommandT is typically faster than vanilla CtrlP&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now you would assume CommandT to be more popular especially since it came out first, but that is not the case. CommandT has &lt;a href=&quot;https://vimawesome.com/?q=command-t&quot; rel=&quot;noreferrer&quot;&gt;approximately 2000 users&lt;/a&gt; and CtrlP has &lt;a href=&quot;https://vimawesome.com/?q=ctrlp&quot; rel=&quot;noreferrer&quot;&gt;approximately 20,000 users&lt;/a&gt;. In my opinion CommandT's requirements cause a barrier to entry. You simply cannot &lt;code&gt;git clone&lt;/code&gt; your vim dotfiles and be up and running on a new machine with CommandT like you can with CtrlP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Counterpoint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is C + Ruby not &lt;code&gt;+python&lt;/code&gt;/&lt;code&gt;+python3&lt;/code&gt;. There is built in support for Python. You are absolutely correct. An &lt;a href=&quot;https://vimawesome.com/?q=undo&quot; rel=&quot;noreferrer&quot;&gt;example that proves this&lt;/a&gt; point would be &lt;a href=&quot;https://github.com/sjl/gundo.vim&quot; rel=&quot;noreferrer&quot;&gt;Gundo&lt;/a&gt; (~5,000) using &lt;code&gt;+python&lt;/code&gt; vs &lt;a href=&quot;https://github.com/mbbill/undotree&quot; rel=&quot;noreferrer&quot;&gt;undotree&lt;/a&gt; (~1,000) which is pure VimL. I would argue, in my personal opinion, that undotree is less well known than Gundo (first to market) and the fact that many are using undotree may very well have to do with it being pure VimL vs python.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Good enough for me, I will just use Python for my Vim plugin!&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;At the end of the day you have to know quite a bit about Vim and some VimL to do Vim plugin in Python. The &lt;code&gt;vim&lt;/code&gt; module is much better than it was before, but still requires a fair amount of VimL eval-like situations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim.command(&quot;set tw=72&quot;)&#xA;vim.command(&quot;%s/aaa/bbb/g&quot;)&#xA;text_width = vim.eval(&quot;&amp;amp;tw&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h python-vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will also need VimL to &quot;bootstrap&quot; the python portion of you plugin. So there is no escaping VimL, just reducing the amount.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Conclusions&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you have a need for &lt;code&gt;+python&lt;/code&gt;/&lt;code&gt;+python3&lt;/code&gt; then certainly use it. It sounds like you have a wonderful use case for python support. However in my opinion you will not completely escape VimL/Vimscript. I would recommend doing Vim things in VimL and use python for thing that are hard/tricky/slow to do in VimL.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2017-12-20T15:59:45.077" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14605" PostTypeId="1" AcceptedAnswerId="14606" CreationDate="2017-12-20T17:32:03.080" Score="4" ViewCount="5336" Body="&lt;p&gt;From &lt;code&gt;:h 'ar'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...If this option has a local value, use this command to switch back to&#xA;      using the global value: &#xA;          :set autoread&amp;lt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What do &lt;strong&gt;local&lt;/strong&gt; &amp;amp; &lt;strong&gt;global&lt;/strong&gt; value exactly mean?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I have searched about global &amp;amp; local value but no desired answer, on the other hand if there is no FAQ reference for this subject this question can be, so please let me know what are differs between &lt;strong&gt;local&lt;/strong&gt; &amp;amp; &lt;strong&gt;global&lt;/strong&gt; value. Thanks.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="15007" LastActivityDate="2017-12-20T18:41:21.883" Title="Differences between local &amp; global" Tags="|vimrc|options|global-command|setlocal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14606" PostTypeId="2" ParentId="14605" CreationDate="2017-12-20T17:59:42.447" Score="7" Body="&lt;p&gt;Global options apply to all of vim, and local options apply only to the current window/buffer. To set a global option, use &lt;code&gt;:setglobal&lt;/code&gt;.  To set a local option, which preserves the global option but overwrites for the current window, use &lt;code&gt;:setlocal&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set&lt;/code&gt; defaults to local when inside a file, and global when not.  The syntax works like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set[local|global] [option]=[value]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setlocal syntax=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also set options with &lt;code&gt;let&lt;/code&gt;, use prepend &lt;code&gt;&amp;amp;&lt;/code&gt; before the &lt;code&gt;g&lt;/code&gt;/&lt;code&gt;l&lt;/code&gt;, like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let &amp;amp;[g|l]:optionname&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My old answer, for variables:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, &lt;strong&gt;local&lt;/strong&gt; means specific to the current window/buffer/tab/function.  &lt;strong&gt;Global&lt;/strong&gt; means vim-wide (in that instance).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To set a global variable, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:var = 0&#xA;:echo var&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(the echo just outputs the value, of course)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To set a local variable, use &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt;, &lt;code&gt;s&lt;/code&gt;, or &lt;code&gt;l&lt;/code&gt; instead of &lt;code&gt;g&lt;/code&gt; in &lt;code&gt;g:var&lt;/code&gt;.&lt;br&gt;&#xA;&lt;code&gt;w&lt;/code&gt; is for the current window, &lt;code&gt;b&lt;/code&gt; is for the current buffer, &lt;code&gt;t&lt;/code&gt; is the current tab, &lt;code&gt;s&lt;/code&gt; is the current script, and &lt;code&gt;l&lt;/code&gt; is the current function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't use a prefix, it defaults to global (but &lt;code&gt;l&lt;/code&gt; if inside a function).&lt;/p&gt;&#xA;" OwnerDisplayName="user11389" LastEditorDisplayName="user11389" LastEditDate="2017-12-20T18:41:21.883" LastActivityDate="2017-12-20T18:41:21.883" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14607" PostTypeId="2" ParentId="14602" CreationDate="2017-12-20T18:46:53.473" Score="1" Body="&lt;p&gt;You said when you run &lt;code&gt;ls -a&lt;/code&gt;, you see &lt;code&gt;/.vim&lt;/code&gt;.  First, make sure you have it in your home directory, try running &lt;code&gt;cd&lt;/code&gt; and then &lt;code&gt;ls -a&lt;/code&gt;.  &lt;code&gt;/.vim&lt;/code&gt; is not &lt;code&gt;~/.vim&lt;/code&gt;, and you really shouldn't be making folders like that in the &lt;code&gt;/&lt;/code&gt; directory (which is computer-wide and has special permissions).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be making your dir with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir ~/.vim/bundle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;~&lt;/code&gt; at the start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this fails with another &quot;not a directory&quot;, run &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir ~/.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then run the first command again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After this, you can run &lt;code&gt;git clone&lt;/code&gt; successfully.  For what it's worth, you don't need to specify the path, just &lt;code&gt;cd ~/.vim/bundle&lt;/code&gt; and run &lt;code&gt;git clone &amp;lt;url&amp;gt;&lt;/code&gt;.  It will automatically name it the same as the git repo, which is &quot;Vundle&quot;.&lt;/p&gt;&#xA;" OwnerDisplayName="user11389" LastActivityDate="2017-12-20T18:46:53.473" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14608" PostTypeId="1" AcceptedAnswerId="14623" CreationDate="2017-12-20T19:43:45.870" Score="1" ViewCount="387" Body="&lt;p&gt;If I initiate vim from command line prompt, everything works as expected, but when it is initiated from a script, then syntax color highlighting is lost. The script can be as simple as the following,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #!/bin/bash&#xA; vi NR_NK.f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please help me find out why this is the case, and how to possibly fix it.&lt;/p&gt;&#xA;" OwnerUserId="15318" LastActivityDate="2017-12-21T17:22:14.700" Title="why I am losing syntax highlighting when vim is invoked within a script?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14609" PostTypeId="1" AcceptedAnswerId="14620" CreationDate="2017-12-20T20:25:09.057" Score="1" ViewCount="1043" Body="&lt;p&gt;How can one set the text of the command line in command mode?&#xA;So when it is not in use? Same as the message that appears when writing a file? I'm looking for a solution for vim and/or nvim, preferably nvim&lt;/p&gt;&#xA;" OwnerUserId="7267" LastActivityDate="2017-12-21T14:54:26.700" Title="vimscript: set text of command line in command mode?" Tags="|vimscript|command-line|neovim|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14610" PostTypeId="2" ParentId="14609" CreationDate="2017-12-20T20:36:03.003" Score="0" Body="&lt;p&gt;&lt;code&gt;:echo &quot;text&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;does it.&#xA;Read &lt;code&gt;:help :echo&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-12-20T20:36:03.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14612" PostTypeId="1" AcceptedAnswerId="14613" CreationDate="2017-12-20T22:52:58.177" Score="1" ViewCount="2004" Body="&lt;p&gt;In Vim the Backspace key only works on the current line of text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This creates a problem if I am entering multiple lines of text and notice an error on the previous line. I have no apparent way to back up to the previous line and correct the mistake. I have to complete the edit, then go back and change it which can be annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: I am typing lines of code and forget to end a line with a semicolon before hitting Enter. I would like to hit backspace, enter the semicolon, then hit Enter again and continue. This does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway to go back to a previous line while in insert mode?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="51" LastEditDate="2017-12-20T23:27:15.287" LastActivityDate="2017-12-20T23:27:15.287" Title="Backspace over newline" Tags="|insert-mode|" AnswerCount="1" CommentCount="1" ClosedDate="2017-12-20T23:28:06.003" ContentLicense="CC BY-SA 3.0" />
  <row Id="14613" PostTypeId="2" ParentId="14612" CreationDate="2017-12-20T22:58:38.763" Score="6" Body="&lt;p&gt;this is controlled by the &lt;code&gt;backspace&lt;/code&gt; option.&#xA;You want &lt;code&gt;:set bs=eol&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2017-12-20T22:58:38.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14614" PostTypeId="1" AcceptedAnswerId="14628" CreationDate="2017-12-21T06:21:00.413" Score="1" ViewCount="133" Body="&lt;p&gt;I was using vim-tmux-navigator and &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; had always worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One day, I found it doesn't work anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When doing &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;C-j&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;C-m&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;enter&amp;gt;&lt;/code&gt; in command mode, they all give me &lt;code&gt;^M&lt;/code&gt;.&#xA;However testing on my colleague's Mac, the &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; would return &lt;code&gt;^@&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I know is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The plugin maps &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; instead of some specific keystrokes&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:verbose map&lt;/code&gt; shows nothing suspicious.  No &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; mappings.  Only mapping &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to &lt;code&gt;:TmuxNavigateDown&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any ideas? (I am using iTerm2)&lt;/p&gt;&#xA;" OwnerUserId="14820" LastEditorUserId="14820" LastEditDate="2017-12-21T07:11:37.207" LastActivityDate="2017-12-22T08:42:18.203" Title="What are reasons that makes &lt;C-j&gt; map to ^M instead of ^@?" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14615" PostTypeId="1" AcceptedAnswerId="33059" CreationDate="2017-12-21T10:34:54.930" Score="4" ViewCount="1639" Body="&lt;p&gt;I have relative numbering turned on. There's no immediate way of telling which direction I want to move, however. For example, sometimes I see line number &quot;7&quot; and move &lt;code&gt;7j&lt;/code&gt; (7 lines down) when I really wanted to move &lt;code&gt;7k&lt;/code&gt; (7 lines up).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to colour line numbers above the current line differently to line numbers below? This way I could very quickly determine whether I should move up or down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware I could look at the surrounding numbers to determine the direction I should move, but colours convey meaning more quickly.&lt;/p&gt;&#xA;" OwnerUserId="15532" LastEditorUserId="51" LastEditDate="2017-12-21T11:13:00.663" LastActivityDate="2021-08-09T09:28:46.250" Title="Relative line number colouring" Tags="|cursor-movement|highlight|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14616" PostTypeId="1" AcceptedAnswerId="14617" CreationDate="2017-12-21T11:10:49.283" Score="2" ViewCount="645" Body="&lt;p&gt;I'm trying to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;* :let @/ =&quot;&amp;lt;cword&amp;gt;&quot;&amp;lt;cr&amp;gt;&amp;lt;bar&amp;gt;:set hlsearch&amp;lt;cr&amp;gt;                                                   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but can't get the first bit to work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;* :let @/ =&quot;&amp;lt;cword&amp;gt;&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to highlight the word under the cursor but not jump to the next match automatically (often this is useful if you have multiple files open and you want to highlight a function definition in another file where you are using the function in the first file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came up with the &lt;code&gt;let&lt;/code&gt; bit after reading &lt;code&gt;:h @/&lt;/code&gt; and given &lt;code&gt;:let&lt;/code&gt; is an ex command I thought I'd be able to use &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got stuck with adding or removing the quotes - no quotes gives an error and quotes just makes it search for &lt;code&gt;&quot;&amp;lt;cword&amp;gt;&quot;&lt;/code&gt; literally.  Likewise I also tried single quotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd be open to other ways of achieving the same thing but I'd also like to get to the bottom of why this doesn't work&lt;/p&gt;&#xA;" OwnerUserId="1518" LastActivityDate="2018-01-20T13:22:18.093" Title="Highlight the current word... or using :let and &lt;cword&gt; together" Tags="|search|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14617" PostTypeId="2" ParentId="14616" CreationDate="2017-12-21T12:28:07.580" Score="3" Body="&lt;p&gt;Managed to work it out after running into some difficulties using &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; in a different mapping that was using &lt;code&gt;/&lt;/code&gt; to search...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ended up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;* :let @/ = '\&amp;lt;'.expand(&quot;&amp;lt;cword&amp;gt;&quot;).'\&amp;gt;'&amp;lt;cr&amp;gt;:set hlsearch&amp;lt;cr&amp;gt;:echo&amp;lt;cr&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/9261123/add-word-under-cursor-to-search-pattern&quot;&gt;This post&lt;/a&gt; showed me how to use cword in search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/26.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;This site&lt;/a&gt; told me that &lt;code&gt;.&lt;/code&gt; is string concatenation&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; are vim regex for start and end of word so it stops it highlighting part of &lt;code&gt;nohlsearch&lt;/code&gt; if you used the command on &lt;code&gt;hlsearch&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The echo at the end is just to clear the commandline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When doing something a bit like this but more complicated I also got caught by &lt;a href=&quot;https://vi.stackexchange.com/questions/9706/what-is-the-difference-between-single-and-double-quoted-strings&quot;&gt;the difference between single and double quotes&lt;/a&gt;.... basically use single quotes when you're doing regex!&lt;/p&gt;&#xA;" OwnerUserId="1518" LastActivityDate="2017-12-21T12:28:07.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14618" PostTypeId="1" AcceptedAnswerId="14619" CreationDate="2017-12-21T13:25:58.317" Score="1" ViewCount="541" Body="&lt;p&gt;It seems I cannot open with Neovim the files I have encrypted with Vim.&#xA;Neovim just open the files without decrypting them, displaying all those gibberish character sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it considered normal ? Is there a way around, or is it a bug ?&lt;/p&gt;&#xA;" OwnerUserId="1682" LastActivityDate="2017-12-21T13:32:00.613" Title="Open with Neovim files that were encrypted with Vim" Tags="|neovim|encryption|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14619" PostTypeId="2" ParentId="14618" CreationDate="2017-12-21T13:32:00.613" Score="3" Body="&lt;p&gt;All support for &lt;code&gt;cryptmethod&lt;/code&gt; was removed in &lt;a href=&quot;https://github.com/neovim/neovim/commit/85338fe1d5a56f82546e16c305c2048c081771e0&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;85338fe&lt;/code&gt;&lt;/a&gt;. See the linked pull requests for (lengthy) discussions about it. There is no way to open these files with Neovim. You will need to use Vim.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-12-21T13:32:00.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14620" PostTypeId="2" ParentId="14609" CreationDate="2017-12-21T14:26:28.470" Score="1" Body="&lt;p&gt;With your affirmative reply to my comment I believe I have a handle on what you are looking for. Basically you want a custom message to always occupy the command line when nothing else is happening there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fundamental way to populate the command line with arbitrary text is just &lt;code&gt;:echo&lt;/code&gt; (or one of its variants). &lt;code&gt;:echo &quot;hello world&quot;&lt;/code&gt;, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure you could do something sophisticated with, let's say, a function and a timer where the timer periodically calls the function to call &lt;code&gt;:echo&lt;/code&gt; after checking for certain conditions (e.g. making sure the command line isn't active).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a poor man's solution, though, you could use &lt;code&gt;autocmd&lt;/code&gt; and various, appropriate event types and have them emit the message. The idea is to pick events that hopefully nicely fill the gaps of those times when you aren't on the command line. For example, add this to your vimrc and you'll find that the message &quot;Hello!&quot; pretty consistently occupies the commmand line...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup cmdlinemsg&#xA;  let g:cmdmsg=&quot;Hello!&quot;&#xA;&#xA;  autocmd!&#xA;&#xA;  au CursorMoved * :echo g:cmdmsg&#xA;  au CursorHold * :echo g:cmdmsg&#xA;  au TextChanged * :echo g:cmdmsg&#xA;  au TextChangedI * :echo g:cmdmsg&#xA;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I didn't check this for side effects or potentially negative impacts on too many Vim actions except for basic editing and navigation but this might get you started on the right path...at least until someone posts that function/timer thingy. :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I was repeatedly muttering &quot;hack!&quot; under my breath when I began toying with this idea. And I didn't spend too much time choosing the event types. But so far, exactly as typed above, it's working surprisingly well! (At least until someone comes along and says &quot;Uh, dude, you forgot about X.&quot;) &lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-12-21T14:54:26.700" LastActivityDate="2017-12-21T14:54:26.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14621" PostTypeId="1" CreationDate="2017-12-21T16:56:26.503" Score="1" ViewCount="996" Body="&lt;p&gt;I've been using tmux for a while, and recently tried &lt;code&gt;:term&lt;/code&gt; in Neovim for a few days.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aside from some small trivial differences, it seems mostly the same to me? What is the advantage of using &lt;code&gt;:term&lt;/code&gt;? What can I do with it that I can't do with tmux.&lt;/p&gt;&#xA;" OwnerUserId="15669" LastEditorUserId="51" LastEditDate="2017-12-22T11:36:55.090" LastActivityDate="2017-12-22T11:36:55.090" Title="What can Neovim/Vim's :terminal do that tmux can't?" Tags="|tmux|terminal-buffer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14622" PostTypeId="1" CreationDate="2017-12-21T17:13:26.473" Score="22" ViewCount="10543" Body="&lt;p&gt;How can I close the Netrw buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried both :bd and :bw and neither work.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2021-02-01T23:32:33.900" Title="How can I close the Netrw buffer?" Tags="|netrw|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14623" PostTypeId="2" ParentId="14608" CreationDate="2017-12-21T17:22:14.700" Score="1" Body="&lt;p&gt;As Mass pointed out, your script is running &lt;code&gt;vi&lt;/code&gt;, not &lt;code&gt;vim&lt;/code&gt;. That may be because you have &lt;code&gt;vi&lt;/code&gt; as an alias for &lt;code&gt;vim&lt;/code&gt; and are used to typing &lt;code&gt;vi&lt;/code&gt; rather than &lt;code&gt;vim&lt;/code&gt; on the command line. Aliases are not expanded by bash when the shell is not interactive, as when it is processing your script. Therefore, your script may be running the program &lt;code&gt;vi&lt;/code&gt; in your PATH, which is often a minimal version of Vim without support for syntax highlighting.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-12-21T17:22:14.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14624" PostTypeId="2" ParentId="14621" CreationDate="2017-12-21T18:17:39.220" Score="2" Body="&lt;p&gt;This is obviously an opiniated question. Here's my opinion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Advantages of neovim (or Vim) terminal:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Normal mode gives the power of Vim inside a terminal window&lt;/li&gt;&#xA;&lt;li&gt;Can use vimscript to customize mappings and commands&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Advantages of tmux:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Allows persistent sessions&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;IMHO this is the most important aspect of tmux, because:&lt;/li&gt;&#xA;&lt;li&gt;It allows to detach a session, then leave the computer, log on from a different computer and continue the session from where we left it&lt;/li&gt;&#xA;&lt;li&gt;It also helps when working through bad network connections, since one may always reconnect to the tmux session if the network connection is lost&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Fits better into a workflow where Vim is only one of many useful tools. I often use tmux even if I don't work with text editing at all.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-12-21T18:17:39.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14625" PostTypeId="1" CreationDate="2017-12-21T20:30:01.683" Score="1" ViewCount="257" Body="&lt;p&gt;When we write code, we usually jump between different parts of the code (using the scrolling or the search functions).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this situations, on Linux, *vim shifts the cursor to the visible area. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you are editing on line 10 (but suppose you are not paying attention to the current line number), and you want to just view what you did wrote at line 250 (scrolling the window), the cursor will be shifted near the line 250. &#xA;If you want to go back (to line 10), and you don't remember the line number, you have to scroll again until you find the line you was at.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to leave the cursor fixed (in this case at line 10) when you scroll the window, in such a way that you can jump back to the line just typing a key ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I took a look at &lt;code&gt;:help scroll&lt;/code&gt; and &lt;code&gt;:help cursor&lt;/code&gt;, but these help don't say nothing about a fixed cursor option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/202/scroll-the-screen-not-the-cursor-when-using-scrollwheel&quot;&gt;This&lt;/a&gt; question threat the same problem, but &lt;code&gt;:set mouse=a&lt;/code&gt; doesn't do the trick, neither the marks.&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="4472" LastEditDate="2017-12-21T21:39:53.513" LastActivityDate="2017-12-24T17:52:55.637" Title="gvim Linux - GUI scroll without cursor shift" Tags="|gvim|scrolling|cursor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14627" PostTypeId="2" ParentId="14625" CreationDate="2017-12-22T00:35:03.583" Score="5" Body="&lt;p&gt;Vim doesn't remember where you've been in a file unless you made a change there (see &lt;code&gt;:help changelist&lt;/code&gt;) or jumped there (see &lt;code&gt;help jumplist&lt;/code&gt;). Also, Vim's cursor is always somewhere in a window, that is, in the part of the buffer visible to the user, so you can't leave the cursor on some line and not have it follow you as you scroll elsewhere in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The usual solution to your problem is to set a mark (see &lt;code&gt;:help mark-motions&lt;/code&gt;) at the original line (e.g., &lt;code&gt;ma&lt;/code&gt;), then jump back to that mark when you're done looking elsewhere (e.g., &lt;code&gt;'a&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2017-12-22T00:35:03.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14628" PostTypeId="2" ParentId="14614" CreationDate="2017-12-22T08:42:18.203" Score="0" Body="&lt;p&gt;This is indeed a very weird issue.  After &quot;fixing&quot;, my &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; is now returning &lt;code&gt;^@&lt;/code&gt; and the mapping to &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be a Tmux session problem.  After turning off tmux and re-attaching the session again, everything is fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. for whoever also getting the other issues addressed in the comments, those are really separate issues -- the tags is that I moved &lt;code&gt;tags&lt;/code&gt; from project root to &lt;code&gt;.git&lt;/code&gt; thus the paths are all wrong; and the &lt;code&gt;vimrc&lt;/code&gt; is because there is really a swap file there which is being edited in some halted vim process.&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2017-12-22T08:42:18.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14629" PostTypeId="1" CreationDate="2017-12-22T10:03:14.123" Score="2" ViewCount="2447" Body="&lt;p&gt;Let's say the lines in words.txt look like this, for example:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Cute Stack 10&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Dog Fire 384&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Phone Real 485&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I want to check if the middle text in each line (stack, fire, real) is equal to a certain input by the user, and if it is, then to print that entire line. &lt;/p&gt;&#xA;" OwnerUserId="15675" LastActivityDate="2022-11-02T19:02:45.477" Title="How can I extract text between two parts in a single line in Python?" Tags="|string-manipulation|" AnswerCount="1" CommentCount="2" ClosedDate="2017-12-23T12:47:48.553" ContentLicense="CC BY-SA 3.0" />
  <row Id="14630" PostTypeId="2" ParentId="14629" CreationDate="2017-12-22T11:39:44.473" Score="1" Body="&lt;p&gt;In your example, each line has three words in it, with the last &amp;quot;word&amp;quot; also being an integer - but if we read those lines in, they will be of the string-type persuasion; so we'd have to cast that last word to do arithmetic with it. Which is not part of your question, just to clarify what the code below will be doing and not doing.&lt;/p&gt;&#xA;&lt;p&gt;We will use the split function that the string library provides to look for (hence the variable is named 'look' - nomen est omen) the string &amp;quot;Fire&amp;quot; - imagine this as being passed in as your user input you mentioned. Then we assume we got the text (variable named 'text') from somewhere with the three lines in it you posted as example. Of course the &amp;quot;\n&amp;quot;-bit of the string is the escape sequence for a newline-character.&lt;/p&gt;&#xA;&lt;p&gt;This is also the argument we pass to the split function, which - nomen es omen - splits up our string at each occurrence of the passed in delimiter, meaning any newline characters. The result is an array with each line as an element in it.&lt;/p&gt;&#xA;&lt;p&gt;We then loop over these, use split again to separate the words - here I used a space, you might want to use a TAB (&amp;quot;\t&amp;quot;).&lt;/p&gt;&#xA;&lt;p&gt;We check there are 3 words in the result of that split and whether or not the second word (index: 0, 1, 2 for the three elements) is equal to the string we are looking for … if so: you have reached your goal&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;from string import split&#xA;look = &amp;quot;Fire&amp;quot;&#xA;text = &amp;quot;Cute Stack 10\nDog Fire 384\nPhone Real 485\n&amp;quot;&#xA;list = text.split(&amp;quot;\n&amp;quot;)&#xA;for line in list:&#xA;    words = list.split(&amp;quot; &amp;quot;)&#xA;    if( len(words) == 3 &amp;amp;&amp;amp; words[1] == look ):&#xA;        print line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10492" LastEditorUserId="21410" LastEditDate="2022-11-02T19:02:45.477" LastActivityDate="2022-11-02T19:02:45.477" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="14633" PostTypeId="2" ParentId="14622" CreationDate="2017-12-22T17:16:41.800" Score="8" Body="&#xA;&#xA;&lt;p&gt;I've had this problem, when using Vinegar to make netrw easier to use.  I found a site that offers one solution &lt;a href=&quot;https://codeyarns.com/2015/02/02/cannot-close-buffer-of-netrw-in-vim/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, and &lt;a href=&quot;https://github.com/tpope/vim-vinegar/issues/13&quot; rel=&quot;noreferrer&quot;&gt;more solutions here.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution that worked for me, was to add this to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;autocmd FileType netrw setl bufhidden=wipe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the sake of completeness, other solutions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;@serebrov&lt;/strong&gt; on Github:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;function! QuitNetrw()&#xA;  for i in range(1, bufnr($))&#xA;    if buflisted(i)&#xA;      if getbufvar(i, '&amp;amp;filetype') == &quot;netrw&quot;&#xA;        silent exe 'bwipeout ' . i&#xA;      endif&#xA;    endif&#xA;  endfor&#xA;endfunction&#xA;&#xA;autocmd MyAutoCmd VimLeavePre *  call QuitNetrw()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;@slashfoo&lt;/strong&gt; on Github:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;&quot; Remove 'set hidden'&#xA;set nohidden&#xA;&#xA;augroup netrw_buf_hidden_fix&#xA;    autocmd!&#xA;&#xA;    &quot; Set all non-netrw buffers to bufhidden=hide&#xA;    autocmd BufWinEnter *&#xA;                \  if &amp;amp;ft != 'netrw'&#xA;                \|     set bufhidden=hide&#xA;                \| endif&#xA;&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first solution was posted by &lt;strong&gt;@tpope&lt;/strong&gt;, also on github.&lt;/p&gt;&#xA;" OwnerDisplayName="user11389" LastActivityDate="2017-12-22T17:16:41.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14635" PostTypeId="1" AcceptedAnswerId="14637" CreationDate="2017-12-22T19:03:46.977" Score="7" ViewCount="677" Body="&lt;p&gt;Been looking for a method to measure words per minute, with no luck. Is there any way to do this?&lt;/p&gt;&#xA;" OwnerUserId="9717" LastEditorUserId="51" LastEditDate="2017-12-22T20:00:09.553" LastActivityDate="2017-12-22T20:16:34.620" Title="How to measure words per minute?" Tags="|user-input|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14637" PostTypeId="2" ParentId="14635" CreationDate="2017-12-22T20:16:34.620" Score="11" Body="&lt;p&gt;Making a command for this means:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Recording the time and number of words in the buffer at the start; you can use the &lt;code&gt;wordcount()&lt;/code&gt; function to get the word count, and the &lt;code&gt;reltime()&lt;/code&gt; function to get the time.&lt;/li&gt;&#xA;&lt;li&gt;Subtracting the current time and number of words from the values we had at the start.&lt;/li&gt;&#xA;&lt;li&gt;Profit!&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here is a basic function which does exactly that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:wpm() abort&#xA;    &quot; Start!&#xA;    if get(b:, 'wpm_start', 0) is 0&#xA;        let b:wpm_start = [reltime(), wordcount()]&#xA;    &quot; Finish&#xA;    else&#xA;        let l:time = reltime(b:wpm_start[0])&#xA;        let l:words = wordcount()['words'] - b:wpm_start[1]['words']&#xA;        unlet b:wpm_start&#xA;        echom printf('%s WPM; in %s seconds you typed %s words',&#xA;            \ l:words / max([1, l:time[0] / 60]), l:time[0], l:words)&#xA;    endif&#xA;endfun&#xA;&#xA;command! WPM call s:wpm()&#xA;&#xA;&quot; Optional: automatically do this when starting/leaving insert mode.&#xA;augroup wpm&#xA;    autocmd!&#xA;    autocmd InsertEnter * :WPM&#xA;    autocmd InsertLeave * :WPM&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2017-12-22T20:16:34.620" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14639" PostTypeId="1" AcceptedAnswerId="14641" CreationDate="2017-12-23T11:55:03.660" Score="0" ViewCount="75" Body="&lt;p&gt;I have the following mappings in my &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Add new lines and spaces without changing the mode&#xA;nmap &amp;lt;leader&amp;gt;j mvo&amp;lt;Esc&amp;gt;`v&#xA;nmap &amp;lt;leader&amp;gt;k mvO&amp;lt;Esc&amp;gt;`v&#xA;nmap &amp;lt;leader&amp;gt;h i&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;l&#xA;nmap &amp;lt;leader&amp;gt;l a&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All shortcuts work, but I can't get consistent behavior with &lt;kbd&gt;leader+h/l&lt;/kbd&gt; commands.&lt;br&gt;&#xA;For example, here is the word and cursor is at &lt;strong&gt;h&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Floccinaucini&lt;strong&gt;h&lt;/strong&gt;ilipilification&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When we press &lt;kbd&gt;leader+l&lt;/kbd&gt;, one space gets instantly added to the right and cursor stays at &lt;strong&gt;h&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Floccinaucini&lt;strong&gt;h&lt;/strong&gt; ilipilification&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;u&lt;/kbd&gt; moves cursor one position to the right, which is unexpected.&lt;br&gt;&#xA;Next, when we press &lt;kbd&gt;leader+h&lt;/kbd&gt;, space gets added to the left with approximately 3 seconds delay:  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Floccinaucini &lt;strong&gt;h&lt;/strong&gt;ilipilification&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, this time pressing &lt;kbd&gt;u&lt;/kbd&gt; leaves cursor at &lt;strong&gt;h&lt;/strong&gt; as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NVIM v0.2.2&lt;br&gt;&#xA;Any clues?&lt;/p&gt;&#xA;" OwnerDisplayName="user6649" LastActivityDate="2017-12-23T18:58:26.463" Title="Inconsistent moves" Tags="|key-bindings|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14640" PostTypeId="1" CreationDate="2017-12-23T18:49:56.293" Score="1" ViewCount="4092" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vOklf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vOklf.png&quot; alt=&quot;long line&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my .vimrc setting for wrapping line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nowrap &quot; Don't auto wrap on load&#xA;set fo-=t &quot; Don't wrap text when type&#xA;&quot;set colorcolumn= 80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5586" LastActivityDate="2017-12-25T16:38:46.057" Title="how to break a long line into 80 characters per line" Tags="|line-breaks|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14641" PostTypeId="2" ParentId="14639" CreationDate="2017-12-23T18:58:26.463" Score="2" Body="&lt;p&gt;Actually the behavior you are observing is the expected one: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When you delete some text and undo the deletion, &lt;code&gt;u&lt;/code&gt; brings you back to the beginning of the deleted text.&lt;/li&gt;&#xA;&lt;li&gt;When you write some text and undo the addition, &lt;code&gt;u&lt;/code&gt; bring you back to the end of the added text.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Both of your mapping &lt;code&gt;&amp;lt;leader&amp;gt;h&lt;/code&gt; and &lt;code&gt;&amp;lt;leader&amp;gt;l&lt;/code&gt; add a new character. When you undo what they did you will get to the end of the deleted text no matter what motions you used before the undo. I think what confused you is that you changed the position of your cursor with the final &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt; motions in your mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can replace your mappings by the following to convince yourself that the behavior is the expected one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;h i&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;0&#xA;nmap &amp;lt;leader&amp;gt;l a&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So as far as I know your mappings are working properly and you can't do much to change the behavior of &lt;code&gt;u&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-12-23T18:58:26.463" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14642" PostTypeId="1" AcceptedAnswerId="14643" CreationDate="2017-12-23T20:54:44.033" Score="1" ViewCount="134" Body="&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;td $F)i, args2&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# base string&#xA;test ----&amp;gt; (args1)&#xA;&#xA;# expected string after &amp;lt;leader&amp;gt;td&#xA;test ----&amp;gt; (args1, args2)&#xA;&#xA;# real result string &#xA;test ----&amp;gt; (args1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above are the &lt;code&gt;key-map&lt;/code&gt; and what I expect with the &lt;code&gt;key-map&lt;/code&gt;. However, the result is that the cursor is stopped the end of the string not entering &lt;code&gt;insert mode&lt;/code&gt;. When I simulate the &lt;code&gt;key-map&lt;/code&gt;, typing keys in the &lt;code&gt;&amp;lt;leader&amp;gt;td&lt;/code&gt; by hand, it works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, The more wired thing is the below. After appending a character at the end of the string, It works as expected. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# base string, I append ':' character at the end of the string&#xA;test ----&amp;gt; (args1):&#xA;&#xA;# real result string, it works !!!?&#xA;test ----&amp;gt; (args1, args2):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What have I missed?&lt;/p&gt;&#xA;" OwnerUserId="14057" LastActivityDate="2017-12-23T21:21:56.487" Title="Key-binding doesn't work as expected, &quot;nnoremap &lt;leader&gt;td $F)i, args2&lt;ESC&gt;&quot;" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14643" PostTypeId="2" ParentId="14642" CreationDate="2017-12-23T21:21:56.487" Score="1" Body="&lt;p&gt;From &lt;code&gt;:h map-error&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        *map-error*&#xA;Note that when an error is encountered (that causes an error message or beep)&#xA;the rest of the mapping is not executed.  This is Vi-compatible.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your mapping, if the &lt;code&gt;F&lt;/code&gt; command fails to find a closing parenthesis, Vim will stop processing the rest of the &lt;code&gt;{rhs}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want Vim to ignore a possible error, you could use the &lt;code&gt;:silent&lt;/code&gt; command, followed by the &lt;code&gt;!&lt;/code&gt; argument. From &lt;code&gt;:h :sil&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When [!] is added, error messages will also be&#xA;skipped, and commands and mappings will not be aborted&#xA;when an error is detected.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's how you could rewrite your mapping, using the &lt;code&gt;:normal&lt;/code&gt; command to type the keys from the command line, prefixed by &lt;code&gt;:silent&lt;/code&gt; to ignore any error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno  &amp;lt;silent&amp;gt;  &amp;lt;leader&amp;gt;td  :&amp;lt;c-u&amp;gt;sil! norm! $F)i, args2&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15612" LastActivityDate="2017-12-23T21:21:56.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14644" PostTypeId="1" CreationDate="2017-12-23T22:46:12.027" Score="1" ViewCount="792" Body="&lt;p&gt;I'm trying to integrate opam-user-setup's output with vim-plug. I've produced the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:opam_share_dir = system(&quot;opam config var share&quot;)&#xA;let s:opam_share_dir = substitute(s:opam_share_dir, '[\r\n]*$', '', '')&#xA;&#xA;let s:opam_configuration = {}&#xA;&#xA;function! OpamConfOcpIndent()&#xA;   Plug s:opam_share_dir . &quot;/ocp-indent/vim&quot;&#xA;endfunction&#xA;let s:opam_configuration['ocp-indent'] = function('OpamConfOcpIndent')&#xA;&#xA;function! OpamConfOcpIndex()&#xA;   Plug s:opam_share_dir . &quot;/ocp-index/vim&quot;&#xA;endfunction&#xA;let s:opam_configuration['ocp-index'] = function('OpamConfOcpIndex')&#xA;&#xA;function! OpamConfMerlin()&#xA;   Plug s:opam_share_dir . &quot;/merlin/vim&quot;&#xA;endfunction&#xA;let s:opam_configuration['merlin'] = function('OpamConfMerlin')&#xA;&#xA;let s:opam_packages = [&quot;ocp-indent&quot;, &quot;ocp-index&quot;, &quot;merlin&quot;]&#xA;let s:opam_check_cmdline = [&quot;opam list --installed --short --safe --color=never&quot;] + s:opam_packages&#xA;let s:opam_available_tools = split(system(join(s:opam_check_cmdline)))&#xA;for tool in s:opam_packages&#xA;   &quot; Respect package order (merlin should be after ocp-index)&#xA;   if count(s:opam_available_tools, tool) &amp;gt; 0&#xA;      call s:opam_configuration[tool]()&#xA;   endif&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the &lt;code&gt;Plug s:opam_share_dir . &quot;/ocp-indent/vim&quot;&lt;/code&gt;-style lines explode with this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function OpamConfOcpIndent:&#xA;line    1:&#xA;E121: Undefined variable: s:opam_share_dir&#xA;E116: Invalid arguments for function plug#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I add &lt;code&gt;echo s:opam_share_dir&lt;/code&gt; immediately before the &lt;code&gt;Plug s:opam_share_dir ...&lt;/code&gt; line, it works just fine — the variable is definitely defined. What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tl;dr I can't figure out how to pass a variable to a custom command, in a vim-script.&lt;/p&gt;&#xA;" OwnerUserId="6108" LastActivityDate="2017-12-23T22:46:12.027" Title="Invoking a command with a defined variable results in &quot;undefined variable&quot;" Tags="|vimscript|variables|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14645" PostTypeId="1" CreationDate="2017-12-24T14:14:28.870" Score="1" ViewCount="870" Body="&lt;p&gt;I recently set my nvim theme to &lt;a href=&quot;https://github.com/NLKNguyen/papercolor-theme/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PaperColor&lt;/a&gt; but after following the instructions and setting my background color to &lt;code&gt;dark&lt;/code&gt; it leaves some dead space at the bottom and on the right.Here is a screenshot.&lt;a href=&quot;https://i.stack.imgur.com/JFCrn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JFCrn.png&quot; alt=&quot;visible dark borders&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .vimrc is in the screenshot.How can i remove the dead space? I'm using gnome-terminal and NeoVim v0.2.2&lt;/p&gt;&#xA;" OwnerUserId="15698" LastActivityDate="2017-12-24T14:14:28.870" Title="Neovim:Background color doesn't fill terminal window" Tags="|neovim|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14646" PostTypeId="1" AcceptedAnswerId="14649" CreationDate="2017-12-24T14:32:21.880" Score="8" ViewCount="10655" Body="&lt;p&gt;In neovim, when use the command &lt;code&gt;:term&lt;/code&gt;, it opens a new shell with &lt;code&gt;bash&lt;/code&gt;. I want to use &lt;code&gt;zsh&lt;/code&gt; by default. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;zsh&lt;/code&gt; is already my default shell. I changed it with &lt;code&gt;chsh&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15669" LastActivityDate="2017-12-25T09:13:32.800" Title="How to use zsh by default for terminal emulator" Tags="|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14647" PostTypeId="2" ParentId="14598" CreationDate="2017-12-24T17:40:22.220" Score="2" Body="&lt;p&gt;Speaking for myself, mostly in Windows but sometimes other platforms, I've never been satisfied by the reality of the Python integration. I appreciate that it's there for the folks that need it but it doesn't &quot;just work;&quot; you've got to get the precise version of the Python DLL and it was trial and error for me when I last did it and ultimately I found that the payoff wasn't worth the effort.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Today, I have some functionality that I wrote in Python that I use inside of Vim and I trigger it with a &lt;code&gt;system('python ...')&lt;/code&gt; call to execute the script.&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2017-12-24T17:40:22.220" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14648" PostTypeId="2" ParentId="14625" CreationDate="2017-12-24T17:52:55.637" Score="2" Body="&lt;p&gt;Vim has this behavior on all platforms that I'm aware of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two options:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you jumped to the new location by searching, just double-tap &lt;kbd&gt;'&lt;/kbd&gt; to go back to the line you were on or &lt;kbd&gt;`&lt;/kbd&gt; to get right to the character position you were at.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regardless of how you moved around,  &lt;kbd&gt;Ctrl-O&lt;/kbd&gt; goes to &quot;older&quot; positions and &lt;kbd&gt;Ctrl-I&lt;/kbd&gt; goes the other way if you go too far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read &lt;code&gt;:help jump-motions&lt;/code&gt; at a minimum but you'll probably learn a lot if you read the entire &lt;code&gt;:help  navigation&lt;/code&gt; document.&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2017-12-24T17:52:55.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14649" PostTypeId="2" ParentId="14646" CreationDate="2017-12-25T08:11:20.700" Score="11" Body="&lt;p&gt;Looking at &lt;a href=&quot;https://neovim.io/doc/user/various.html#:terminal&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :terminal&lt;/code&gt;&lt;/a&gt; it says&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Execute {cmd} with 'shell' in a new terminal buffer&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So use &lt;code&gt;:set shell=/path/to/zsh&lt;/code&gt;. Put it in your vimrc file (probably &lt;em&gt;init.vim&lt;/em&gt;) to make it &quot;permanent&quot;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-12-25T09:13:32.800" LastActivityDate="2017-12-25T09:13:32.800" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14651" PostTypeId="2" ParentId="14622" CreationDate="2017-12-25T16:21:23.483" Score="-3" Body="&lt;p&gt;typing &lt;code&gt;q&lt;/code&gt; while in the buffer closes mine.&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2017-12-25T16:21:23.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14652" PostTypeId="2" ParentId="14640" CreationDate="2017-12-25T16:38:46.057" Score="1" Body="&lt;p&gt;Use &lt;code&gt;:set tw=80&lt;/code&gt;. Also make sure you are not in “paste” mode. (&lt;a href=&quot;https://stackoverflow.com/a/1272371/4752883&quot;&gt;https://stackoverflow.com/a/1272371/4752883&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need visual guidance on where you are with respect to 80 characters you can use &lt;code&gt;:set colorcolumn = 80&lt;/code&gt; (&lt;a href=&quot;https://vi.stackexchange.com/a/576/13848&quot;&gt;https://vi.stackexchange.com/a/576/13848&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2017-12-25T16:38:46.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14653" PostTypeId="1" AcceptedAnswerId="14654" CreationDate="2017-12-25T18:16:42.773" Score="3" ViewCount="180" Body="&lt;p&gt;From &lt;code&gt;:h indent.txt&lt;/code&gt;:  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...each one overrides the previous if it is enabled...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now if I set &lt;code&gt;'cin'&lt;/code&gt; after &lt;code&gt;'ai'&lt;/code&gt;, Does &lt;code&gt;'cin'&lt;/code&gt; disable the effect of &lt;code&gt;'ai'&lt;/code&gt;?.&lt;br&gt;&#xA;&lt;em&gt;If no, so what is the purpose of &quot;override&quot; exactly?&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="15007" LastEditorUserId="15007" LastEditDate="2017-12-25T18:51:31.570" LastActivityDate="2017-12-25T18:58:22.190" Title="Does each indention option override the previous one?" Tags="|vimrc|indentation|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14654" PostTypeId="2" ParentId="14653" CreationDate="2017-12-25T18:43:46.913" Score="2" Body="&lt;p&gt;Order does not matter.  The override behavior is based on what is currently set/unset, changing one option value does not change others.  Additionally, &lt;code&gt;indent.txt&lt;/code&gt; refers to &lt;em&gt;methods&lt;/em&gt; not &lt;em&gt;settings&lt;/em&gt;, so the behavior is not completely straight-forward since the expression in &lt;code&gt;indentexpr&lt;/code&gt; can itself return &quot;not enabled.&quot;  The documentation requires some further explanation:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If &lt;code&gt;indentexpr&lt;/code&gt; is set, &lt;code&gt;cindent&lt;/code&gt;,&lt;code&gt;smartindent&lt;/code&gt;, and &lt;code&gt;autoindent&lt;/code&gt; will all have no base effect (* caveat 1 applies).  Note that for &lt;code&gt;indentexpr&lt;/code&gt; &quot;unset&quot; means set to empty string.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;code&gt;cindent&lt;/code&gt; is set and &lt;code&gt;indentexpr&lt;/code&gt; is unset, &lt;code&gt;{smartindent,autoindent}&lt;/code&gt; will have no effect.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;code&gt;smartindent&lt;/code&gt; is set and &lt;code&gt;{cindent, indentexpr}&lt;/code&gt; are unset, &lt;code&gt;autoindent&lt;/code&gt; &#xA;will have no effect (* caveat 2 applies).&lt;/li&gt;&#xA;&lt;li&gt;Finally, if &lt;code&gt;{cindent, indentexpr, smartindent}&lt;/code&gt; are unset &lt;code&gt;autoindent&lt;/code&gt; takes effect.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;(* caveat 1 ) If &lt;code&gt;indentexpr&lt;/code&gt; returns -1, vim specifies that the value of &lt;code&gt;autoindent&lt;/code&gt; is used.  So, if &lt;code&gt;smartindent&lt;/code&gt; or &lt;code&gt;cindent&lt;/code&gt; is on, and &lt;code&gt;autoindent&lt;/code&gt; is off, and the &lt;code&gt;indentexpr&lt;/code&gt; evaluates to -1, indenting will not take place, which is potentially unexpected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(* caveat 2 ) The documentation is misleading here.  You &lt;em&gt;should&lt;/em&gt; set &lt;code&gt;autoindent&lt;/code&gt; if you have &lt;code&gt;smartindent&lt;/code&gt; for reasons that are unclear (besides perhaps the reason given in (* caveat 1) above).  From &lt;code&gt;:h smartindent&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Normally 'autoindent' should also be on when using 'smartindent'.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The bottom line is you should always set &quot;lesser&quot; indent methods when using &quot;greater&quot; ones, although it sometimes doesn't matter.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2017-12-25T18:58:22.190" LastActivityDate="2017-12-25T18:58:22.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14655" PostTypeId="1" AcceptedAnswerId="14666" CreationDate="2017-12-25T23:08:10.093" Score="1" ViewCount="1502" Body="&lt;p&gt;Hi I am trying out vimtex on a multi-file project, and so far I was liking it a lot. However, I just found out that vimtex commands (&lt;code&gt;\lv&lt;/code&gt;, &lt;code&gt;\lt&lt;/code&gt;, &lt;code&gt;\li&lt;/code&gt;, etc) work correctly when used while editing the main file, but have no effect when editing imported files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now since most of the work happens in imported files this is quite a big problem. By the way, continuos compilation does not stop when switching to imported files, so I can still see changes in real-time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am on ubuntu, using vim 8.0 compiled with &lt;code&gt;--with-features=huge&lt;/code&gt; and using zathura for pdf visualization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried creating an empty &lt;code&gt;main.tex.latexmain&lt;/code&gt; file and also putting all the imported files in the same folder of main file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know why this happens?&lt;/p&gt;&#xA;" OwnerUserId="11366" LastActivityDate="2017-12-27T22:16:13.810" Title="Vimtex commands only working on main file" Tags="|filetype-tex|plugin-vimtex|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14656" PostTypeId="1" CreationDate="2017-12-26T00:33:35.880" Score="1" ViewCount="878" Body="&lt;p&gt;I'm trying to configure &lt;a href=&quot;https://github.com/prabirshrestha/asyncomplete.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;asyncomplete.vim&lt;/a&gt; so that the completion menu is shown when inserting at least two succeeding 'word'-characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'm having trouble understanding why &lt;code&gt;asyncomplete#force_refresh()&lt;/code&gt; or &lt;code&gt;asyncomplete#_force_refresh()&lt;/code&gt; doesn't seem to work when used in a autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a test config:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code&gt;set secure&#xA;set nobackup&#xA;set cot=menu,menuone&#xA;set noshowmode&#xA;&#xA;&quot; setup this test&#xA;function! s:setup() abort&#xA;  let s:testdir='/tmp/nvim'&#xA;  let s:plugdir=s:testdir.'/autoload'&#xA;  if !isdirectory(s:plugdir)&#xA;    call mkdir(s:plugdir, 'p', 0755)&#xA;  endif&#xA;  &quot; requires plug.vim&#xA;  if empty(glob(s:plugdir.'/plug.vim')) &amp;amp;&amp;amp; executable('curl')&#xA;    call system('curl -fLo '.shellescape(expand(s:plugdir))&#xA;          \.'/plug.vim --create-dirs'&#xA;          \.' https://raw.githubusercontent.com/junegunn/'&#xA;          \.'vim-plug/master/plug.vim')&#xA;    call assert_notequal(0, v:shell_error)&#xA;  endif&#xA;  let s:plugged=s:testdir.'/plugged'&#xA;  if !isdirectory(s:plugged)&#xA;    call mkdir(s:plugged, 'p', 0755)&#xA;  endif&#xA;  let &amp;amp;rtp=expand(s:testdir).','.expand(s:plugged).',$VIMRUNTIME'&#xA;endfunction&#xA;&#xA;call &amp;lt;SID&amp;gt;setup()&#xA;call plug#begin(expand(s:plugged))&#xA;&quot; Prabir Shrestha:&#xA;Plug 'prabirshrestha/asyncomplete.vim'&#xA;      \|Plug 'prabirshrestha/asyncomplete-buffer.vim'&#xA;      \|Plug 'prabirshrestha/asyncomplete-neosnippet.vim'&#xA;      \|Plug 'yami-beta/asyncomplete-omni.vim'&#xA;&quot; Shougo Matsu:&#xA;Plug 'Shougo/neosnippet.vim'&#xA;      \| Plug 'Shougo/neosnippet-snippets'&#xA;call plug#end()&#xA;&#xA;if !has_key(g:plugs, 'asyncomplete.vim')&#xA;  if exists(':PlugInstall')&#xA;    augroup Install&#xA;      au!&#xA;      au BufWinEnter * PlugInstall&#xA;         \| echomsg 'Please restart vim'&#xA;    augroup END&#xA;  endif&#xA;  finish&#xA;else&#xA;  augroup Install au! augroup END&#xA;endif&#xA;&#xA;let g:asyncomplete_remove_duplicates=1&#xA;let g:asyncomplete_log_file = expand(s:testdir.'/asyncomplete.log')&#xA;let g:asyncomplete_auto_popup = 0&#xA;&#xA;augroup Complete&#xA;  au!&#xA;  au FileType * if &amp;amp;omnifunc == &quot;&quot;&#xA;        \ | setl omnifunc=syntaxcomplete#Complete&#xA;        \ | endif&#xA;  au InsertCharPre * call &amp;lt;SID&amp;gt;check_minchar()&#xA;  au CompleteDone  * if pumvisible() == 0 | pclose | endif&#xA;augroup END&#xA;&#xA;function! s:check_minchar() abort&#xA;  let l:char = getline('.')[col('.')-2].v:char&#xA;  if l:char =~# '\k\k'&#xA;    if !asyncomplete#menu_selected()&#xA;      &quot; what to do?&#xA;      &quot; call asyncomplete#_force_refresh()&#xA;      &quot; call feedkeys(&quot;\&amp;lt;c-r&amp;gt;=asyncomplete#_force_refresh()\&amp;lt;CR&amp;gt;&quot;, &quot;nt&quot;)&#xA;      &quot; call feedkeys(&quot;\&amp;lt;c-o&amp;gt;:call asyncomplete#_force_refresh()\&amp;lt;CR&amp;gt;&quot;, &quot;nt&quot;)&#xA;      &quot; echo 'menu?'&#xA;    endif&#xA;    &quot; I've also tried&#xA;    &quot; if !pumvisible() | call asyncomplete#force_refresh() | endif&#xA;  endif&#xA;endfunction&#xA;&#xA;call asyncomplete#register_source(asyncomplete#sources#buffer#get_source_options({&#xA;      \ 'name': 'buffer',&#xA;      \ 'whitelist': ['*'],&#xA;      \ 'blacklist': ['go'],&#xA;      \ 'completor': function('asyncomplete#sources#buffer#completor'),&#xA;      \ }))&#xA;call asyncomplete#register_source(asyncomplete#sources#omni#get_source_options({&#xA;      \ 'name': 'omni',&#xA;      \ 'whitelist': ['*'],&#xA;      \ 'blacklist': ['html'],&#xA;      \ 'completor': function('asyncomplete#sources#omni#completor')&#xA;      \  }))&#xA;call asyncomplete#register_source(asyncomplete#sources#neosnippet#get_source_options({&#xA;      \ 'name': 'neosnippet',&#xA;      \ 'whitelist': ['*'],&#xA;      \ 'completor': function('asyncomplete#sources#neosnippet#completor'),&#xA;      \ }))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;hr/&gt;&lt;sup&gt;I use neovim version 0.2.2 on linux 4.14.3-1-ARCH.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="1027" LastEditorUserId="1027" LastEditDate="2017-12-26T11:51:35.507" LastActivityDate="2017-12-26T11:51:35.507" Title="asyncomplete.vim: how can I automatically show the completion menu after two succeeding 'word'-characters?" Tags="|autocompletion|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14657" PostTypeId="1" CreationDate="2017-12-26T06:15:49.480" Score="3" ViewCount="1537" Body="&lt;p&gt;I know there is &lt;code&gt;:copen&lt;/code&gt; command which opens &lt;code&gt;quickfix&lt;/code&gt; window but it doesn't immediately switch to it(till it open). How can I wait for it to be sure my next commands in script would be executed in &lt;code&gt;quickfix&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="11971" LastActivityDate="2017-12-29T01:45:44.590" Title="How to go to quickfix window?" Tags="|vimscript|quickfix|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14658" PostTypeId="1" CreationDate="2017-12-26T09:36:24.533" Score="0" ViewCount="46" Body="&lt;p&gt;A &lt;code&gt;g&lt;/code&gt; command can find the lines globally and then apply actions, like the following would find lines that contain &lt;code&gt;foo&lt;/code&gt; and delete those lines: &lt;code&gt;:g/foo/d&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An &lt;code&gt;s&lt;/code&gt; command is more well-known for its substitution power: &lt;code&gt;:s/foo/bar/&lt;/code&gt; would substitute the first &lt;code&gt;foo&lt;/code&gt; of the current line with &lt;code&gt;bar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if it is possible to create my own excmd which takes this form &lt;code&gt;:&amp;lt;excmd&amp;gt;/&amp;lt;1st param&amp;gt;/&amp;lt;2nd param&amp;gt;/&amp;lt;options&amp;gt;&lt;/code&gt;, which, in turn calls a function like &lt;code&gt;MyFunc( param1, param2, options )&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having this syntactic sugar would greatly help since the function should deal with quotes, whitespaces and other special characters (like &lt;code&gt;!&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt;) a lot, and using &lt;code&gt;/&lt;/code&gt; as the delimiter would greatly avoid much escaping problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2018-02-25T23:16:18.467" Title="How may I create an excmd that has a signature like g, s, v commands? (`:cmd/str1/str2/options`)" Tags="|functions|ex-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14659" PostTypeId="2" ParentId="14658" CreationDate="2017-12-26T12:03:29.467" Score="1" Body="&lt;p&gt;Yes of course. You'll just need to parse the parameter you receive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the first char as delimiter, and &lt;code&gt;split()&lt;/code&gt; the string with this delimiter. Of course, if you wish to support stuff like &lt;code&gt;:Whatever/st\/uff/other&lt;/code&gt;, it'll be a little bit more complex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I remember to have given a few answers on SO/vi.SE that implement such command: &lt;a href=&quot;https://vi.stackexchange.com/questions/3028/search-and-replace-but-ignore-text-in-quotes&quot;&gt;Here&lt;/a&gt;, &lt;a href=&quot;https://stackoverflow.com/questions/1809571/how-do-i-substitute-from-a-list-of-strings-in-vim&quot;&gt;here&lt;/a&gt;, and &lt;a href=&quot;https://stackoverflow.com/questions/25665318/vim-equivalent-of-the-tr-command/25665554#25665554&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, in &lt;a href=&quot;https://github.com/LucHermitte/lh-style/blob/master/plugin/lh-style.vim#L77&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-style&lt;/a&gt; I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -range -complete=custom,s:CompleteConvertNames&#xA;      \ ConvertNames &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call s:ConvertNames(&amp;lt;f-args&amp;gt;)&#xA;&#xA;&quot; Function: s:ConvertNames(repl_arg) {{{3&#xA;&quot; Syntax: ConvertNames/{regex}/{convertion_type}&#xA;function! s:ConvertNames(repl_arg) range abort&#xA;  let sep = a:repl_arg[0]&#xA;  let fields = split(a:repl_arg, sep)&#xA;  if len(fields) != 2 &amp;amp;&amp;amp; len(fields) != 3&#xA;    throw &quot;:NameConvert/{regex}/{convertion_type}/[{opt}] expects exactly two or three parameters&quot;&#xA;  endif&#xA;  let convertion_type = fields[1]&#xA;  let i = lh#list#find_if(s:k_convertions, 'v:1_[0]=='.string(convertion_type))&#xA;  if i == -1&#xA;    throw &quot;convertion (&quot;.convertion_type.&quot;) not found&quot;&#xA;  endif&#xA;  &quot; build the action to execute&#xA;  let ConvertFunc = function(s:k_convertions[i][1])&#xA;  let action = '\=(ConvertFunc(submatch(0)))'&#xA;  let cmd = a:firstline . ',' . a:lastline . 's'&#xA;        \. sep . fields[0]&#xA;        \. sep . action&#xA;        \. sep.(len(fields)&amp;gt;=3 ? fields[2] : '')&#xA;  &quot; echomsg cmd&#xA;  exe cmd&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: Here is another (untested) example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 &#xA;      \ Hello call s:Hello(&amp;lt;f-args&amp;gt;)&#xA;&#xA;function! s:ConvertNames(repl_arg) range abort&#xA;  let sep = a:repl_arg[0]&#xA;  let fields = split(a:repl_arg, sep)&#xA;  let cmd = 'echo &quot;Hello&quot;.'.string(join(fields, ',')))&#xA;  exe cmd&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2017-12-27T22:10:34.860" LastActivityDate="2017-12-27T22:10:34.860" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14660" PostTypeId="1" AcceptedAnswerId="14746" CreationDate="2017-12-26T16:17:13.193" Score="3" ViewCount="240" Body="&lt;p&gt;From the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#complete-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim documentation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FUNCTIONS FOR FINDING COMPLETIONS           *complete-functions*&#xA;&#xA;This applies to 'completefunc' and 'omnifunc'.&#xA;&#xA;The function is called in two different ways:&#xA;- First the function is called to find the start of the text to be completed.&#xA;- Later the function is called to actually find the matches.&#xA;&#xA;On the first invocation the arguments are:&#xA;   a:findstart  1&#xA;   a:base   empty&#xA;&#xA;The function must return the column where the completion starts.  It must be a&#xA;number between zero and the cursor column &quot;col('.')&quot;.  This involves looking&#xA;at the characters just before the cursor and including those characters that&#xA;could be part of the completed item.  The text between this column and the&#xA;cursor column will be replaced with the matches.&#xA;&#xA;Special return values:&#xA;   -1 If no completion can be done, the completion will be cancelled with an&#xA;      error message.&#xA;   -2 To cancel silently and stay in completion mode.&#xA;   -3 To cancel silently and leave completion mode.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function will be called twice and only the second time vim will interpret -1 as cancellation? Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested this with (version 8.0)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyCompletion(findstart, base)&#xA;    echomsg &quot;Call MyCompletion&quot; a:findstart&#xA;    if a:findstart&#xA;        return -1&#xA;    endif&#xA;    &quot; return -1&#xA;    return [&quot;foo&quot;, &quot;abc&quot;, &quot;123&quot;]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if I can not find a start for completion I have to use a nonlocal variable to remember this or test again?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if findstart&#xA;   if test&#xA;       s:completion_failed = 1&#xA;       return whatever&#xA;   endif&#xA;endif&#xA;&#xA;if s:completion_failed&#xA;    return -1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15718" LastEditorUserId="15718" LastEditDate="2018-01-07T19:03:56.840" LastActivityDate="2018-01-07T19:03:56.840" Title="Completion Function Return Value -1 Cancellation" Tags="|vimscript|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14662" PostTypeId="1" AcceptedAnswerId="14667" CreationDate="2017-12-27T09:21:07.307" Score="1" ViewCount="451" Body="&lt;p&gt;I was seeing the docs in &lt;code&gt;:help map-mode&lt;/code&gt; where I saw that &lt;code&gt;map!&lt;/code&gt; works for &lt;code&gt;Insert and Command-line&lt;/code&gt; modes while &lt;code&gt;lmap&lt;/code&gt; works on &lt;code&gt;Insert, Command-line, Lang-Arg&lt;/code&gt; But I've never heard of &lt;code&gt;Lang-Arg&lt;/code&gt; mode. Can you explain to me what that mode is?!&lt;/p&gt;&#xA;" OwnerUserId="14609" LastActivityDate="2017-12-27T22:53:20.683" Title="What is Lang-Arg in vim?" Tags="|key-bindings|visual-mode|insert-mode|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14663" PostTypeId="1" CreationDate="2017-12-27T10:55:56.483" Score="5" ViewCount="1817" Body="&lt;p&gt;&lt;strong&gt;Backstory:&lt;/strong&gt; So there is all these notes app like Evernote Onenote... but I do not want to be locked into a system and only are going to use my laptop. So I thought why not use vim to edit markdown files which are saved in a Dropbox folder. And it would be nice to have tags working on it as well but there are a few problems with tags, I can't easily rename them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; How can I change tags and files without changing the tag location? Eg a tag called &lt;code&gt;flying potato project&lt;/code&gt; and I want to rename it to &lt;code&gt;potato express&lt;/code&gt; and change the file from &lt;code&gt;potato-idea.md&lt;/code&gt; to &lt;code&gt;potato-idea-for-ever.md&lt;/code&gt; but still keeping the tag location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe something with ids? Eg the tag for the text about potato express could be &lt;code&gt;@253&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;INFO EDIT:&lt;/strong&gt;&#xA;If you don't know what vim tags is then have a look at this website &lt;a href=&quot;http://vim.wikia.com/wiki/Browsing_programs_with_tags&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Browsing_programs_with_tags&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;:&#xA;This post has also been posted here&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/47932055/use-tags-in-vim-for-notes&quot;&gt;https://stackoverflow.com/questions/47932055/use-tags-in-vim-for-notes&lt;/a&gt; and&#xA;&lt;a href=&quot;https://superuser.com/questions/1279464/how-to-use-tags-in-vim-for-notes&quot;&gt;https://superuser.com/questions/1279464/how-to-use-tags-in-vim-for-notes&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15726" LastEditorUserId="15726" LastEditDate="2017-12-27T16:14:26.523" LastActivityDate="2020-04-23T13:11:40.320" Title="How To Use Tags In Vim For Notes" Tags="|tags|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="14664" PostTypeId="2" ParentId="14663" CreationDate="2017-12-27T11:28:23.050" Score="1" Body="&lt;p&gt;This is not strictly speaking an answer to your question, but there are several plugins that provides a note-taking system for Vim, for instance:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimwiki.github.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimwiki.github.io/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://peterodding.com/code/vim/notes/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://peterodding.com/code/vim/notes/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11896" LastActivityDate="2017-12-27T11:28:23.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14666" PostTypeId="2" ParentId="14655" CreationDate="2017-12-27T22:16:13.810" Score="3" Body="&lt;p&gt;Short answer: add &lt;code&gt;let g:tex_flavor = 'latex'&lt;/code&gt; to your vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So, more details. First: This problem is not related to &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt;. vimtex depends on the internal &lt;code&gt;tex&lt;/code&gt; plugin, e.g. for filetype detection and syntax, and this particular problem is with how the internal &lt;code&gt;tex&lt;/code&gt; plugin recognizes the filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be more specific, the internal &lt;code&gt;tex&lt;/code&gt; plugin differs between different flavors: &lt;code&gt;plain&lt;/code&gt;, &lt;code&gt;context&lt;/code&gt;, and &lt;code&gt;latex&lt;/code&gt;. Which one is used depends on two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The header of the loaded file, and&lt;/li&gt;&#xA;&lt;li&gt;The value of the &lt;code&gt;g:tex_flavor&lt;/code&gt; option.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;g:tex_flavor&lt;/code&gt; option is used to set the &quot;default&quot; style, which is used when the flavor can not be decided from the header. The header is parsed for two things: Either a &lt;code&gt;%&amp;amp;&amp;lt;format&amp;gt;&lt;/code&gt; string, or some keywords that identify the flavor. If you don't set &lt;code&gt;g:tex_flavor&lt;/code&gt;, it defaults to &lt;code&gt;plaintex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h g:tex_flavor&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/autoload/dist/ft.vim#L636&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:e $VIMRUNTIME/autoload/dist/ft.vim&lt;/code&gt; (close to line 636)&lt;/a&gt; (different location in neovim)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-12-27T22:16:13.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14667" PostTypeId="2" ParentId="14662" CreationDate="2017-12-27T22:53:20.683" Score="4" Body="&lt;p&gt;Short answer: This is a feature that allows one to &quot;map&quot; the normal characters on a keyboard to language specific characters, e.g. latin to cryllic or greek.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help language-mapping&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                *language-mapping*&#xA;&quot;:lmap&quot; defines a mapping that applies to:&#xA;- Insert mode&#xA;- Command-line mode&#xA;- when entering a search pattern&#xA;- the argument of the commands that accept a text character, such as &quot;r&quot; and&#xA;  &quot;f&quot;&#xA;- for the input() line&#xA;Generally: Whenever a character is to be typed that is part of the text in the&#xA;buffer, not a Vim command character.  &quot;Lang-Arg&quot; isn't really another mode,&#xA;it's just used here for this situation.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is more info, so please open the suggested help page to read on. See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'keymap'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'iminsert'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 45.5&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I did not know this before answering. I did the following steps to find this info:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help map-mode&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/Lang-Arg&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nn&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21" LastActivityDate="2017-12-27T22:53:20.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14668" PostTypeId="1" CreationDate="2017-12-28T08:51:16.600" Score="2" ViewCount="611" Body="&lt;p&gt;I'm trying to figure out how to get yapf to use my current conda environment when resolving imports. Basically, I just see a ton of the following errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;physics.py|6 col 1 error| [import-error] Unable to import 'torch' &#xA;physics.py|8 col 1 error| [import-error] Unable to import 'torch.autograd'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For autoformatting, my .vimrc currently just contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType python AutoFormatBuffer yapf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and yapf has been installed using pathogen. If using yapf is too much of a burden, is there some other autoformatter that works seamlessly with conda?&lt;/p&gt;&#xA;" OwnerUserId="15739" LastActivityDate="2018-01-06T17:06:38.433" Title="Getting vim with yapf to work with anaconda environments" Tags="|formatting|filetype-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14670" PostTypeId="2" ParentId="2162" CreationDate="2017-12-28T17:26:59.607" Score="6" Body="&lt;p&gt;Just in case anyone is experience not explainable &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; behavior using ConEmu on Windows, you may have to remap the &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; key to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Char-0x07F&amp;gt; &amp;lt;BS&amp;gt;&#xA;nnoremap &amp;lt;Char-0x07F&amp;gt; &amp;lt;BS&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://conemu.github.io/en/VimXterm.html#vim-bs-issue&quot; rel=&quot;noreferrer&quot;&gt;More information&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15743" LastEditorUserId="51" LastEditDate="2017-12-29T10:00:36.187" LastActivityDate="2017-12-29T10:00:36.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14671" PostTypeId="2" ParentId="2814" CreationDate="2017-12-28T19:34:46.920" Score="0" Body="&lt;p&gt;The problem was that was the vim binary I was using wasn't compiled with &lt;code&gt;+xterm_clipboard&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2017-12-28T19:34:46.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14672" PostTypeId="1" AcceptedAnswerId="14673" CreationDate="2017-12-28T22:41:33.970" Score="2" ViewCount="58" Body="&lt;p&gt;I am using vim --remote-send. As per &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/remote.html#--remote-send&quot; rel=&quot;nofollow noreferrer&quot;&gt;the documentation&lt;/a&gt; It automatically expands &quot;special&quot; key signifiers, so that e.g. &lt;code&gt;vim --remote-send &quot;&amp;lt;C-t&amp;gt;&quot;&lt;/code&gt; simulates pressing ctrl-t. I would like to send the literal key sequence &lt;code&gt;&amp;lt;&lt;/code&gt;,&lt;code&gt;C&lt;/code&gt;,&lt;code&gt;-&lt;/code&gt;,&lt;code&gt;t&lt;/code&gt;,&lt;code&gt;&amp;gt;&lt;/code&gt;, but vim's documentation offers no clues. I have tried &lt;code&gt;vim --remote-send '\&amp;lt;C-t&amp;gt;'&lt;/code&gt; but this just does a literal backslash followed by ctrl-t. How can I escape special sequences?&lt;/p&gt;&#xA;" OwnerUserId="13151" LastActivityDate="2017-12-29T00:00:04.010" Title="How to send literal form of special key sequences with --remote-send" Tags="|clientserver|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14673" PostTypeId="2" ParentId="14672" CreationDate="2017-12-29T00:00:04.010" Score="5" Body="&lt;p&gt;In any context where a &quot;keycode&quot; is expected, use &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt; to represent a literal &lt;code&gt;&amp;lt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --remote-send &quot;&amp;lt;lt&amp;gt;C-t&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://neovim.io/doc/user/intro.html#keycodes&quot; rel=&quot;noreferrer&quot;&gt;:help keycodes&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="578" LastActivityDate="2017-12-29T00:00:04.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14674" PostTypeId="2" ParentId="14657" CreationDate="2017-12-29T01:45:44.590" Score="1" Body="&lt;p&gt;This is the function that I use to ensure the Preview window is open and has focus. I like this window to be in the first tab, if you don't want that then your logic will vary accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a function that is mapped to hotkeys that fire off builds of different flavors; this function is called right before I execute &lt;code&gt;:make&lt;/code&gt; with my desired options.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EnsurePreviewWindow()&#xA;    if ! &amp;amp;previewwindow          &quot; don't do this in the preview window&#xA;        tabfirst&#xA;        silent! wincmd P         &quot; jump to preview window&#xA;        if ! &amp;amp;previewwindow      &quot; if we still aren't there...&#xA;            0tabnew&#xA;            setlocal switchbuf=useopen&#xA;            execute &quot;copen&quot; (&amp;amp;lines / 3)&#xA;            set previewwindow&#xA;        endif&#xA;        silent! wincmd p&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2017-12-29T01:45:44.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14675" PostTypeId="1" AcceptedAnswerId="14676" CreationDate="2017-12-29T10:01:55.017" Score="2" ViewCount="167" Body="&lt;p&gt;I know I can select pasted text using &lt;a href=&quot;http://vim.wikia.com/wiki/Selecting_your_pasted_text&quot; rel=&quot;nofollow noreferrer&quot;&gt;this trick&lt;/a&gt; mapped to &lt;code&gt;gp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means if I paste and then want to select the pasted block, I need to say &lt;code&gt;p&lt;/code&gt; and &lt;code&gt;gp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to paste and immediately select that, ideally with &lt;code&gt;P&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will I mess anything up if I rebind &lt;code&gt;P&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="12905" LastActivityDate="2017-12-29T10:21:47.127" Title="Map key to paste and immediately select" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14676" PostTypeId="2" ParentId="14675" CreationDate="2017-12-29T10:21:47.127" Score="5" Body="&lt;p&gt;You can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap P p`[v`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doing this you will not &quot;mess&quot; anything but you will loose the ability to put the text from the register before the cursor (which is what &lt;code&gt;P&lt;/code&gt; does by default).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid loosing &lt;code&gt;P&lt;/code&gt; you could also use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap P P`[v`]&#xA;nnoremap p p`[v`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you will still get the put before and after cursor behavior but you will also always select the text put.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2017-12-29T10:21:47.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14679" PostTypeId="1" AcceptedAnswerId="14680" CreationDate="2017-12-29T18:45:33.903" Score="1" ViewCount="59" Body="&lt;p&gt;If I map Vim 's native shortcut &amp;amp; key codes (e.g. &lt;code&gt;nn ; :&lt;/code&gt;) do other plugins break (e.g. break on their commands &amp;amp; command line)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Actually I saw &lt;code&gt;nn ; :&lt;/code&gt; on an article but the writer of the article said that it may break some plugins. Why It may break some plugins?&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="15007" LastEditorUserId="1841" LastEditDate="2017-12-29T18:57:42.767" LastActivityDate="2017-12-29T18:59:24.820" Title="Will remapping ; break my plugins?" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14680" PostTypeId="2" ParentId="14679" CreationDate="2017-12-29T18:52:17.627" Score="5" Body="&lt;p&gt;It all depends on the plugins you use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the author says that mapping &lt;code&gt;;&lt;/code&gt; to &lt;code&gt;:&lt;/code&gt; may break a plugin, they simply mean that you won't be able to use &lt;code&gt;;&lt;/code&gt; anymore and if a plugin has a command which uses the &lt;code&gt;;&lt;/code&gt; the command might not work anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now this mapping is pretty common on qwerty keyboards so it shouldn't be a problem on most plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your best bet is to use this mapping and see if you encounter a plugin which uses &lt;code&gt;;&lt;/code&gt;. If that is the case you can either stop using the plugin (or try to replace it) or remap another key to &lt;code&gt;;&lt;/code&gt; (e.g. &lt;code&gt;nnoremap : ;&lt;/code&gt;) and use &lt;code&gt;:&lt;/code&gt; instead of &lt;code&gt;;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that in vanilla vim &lt;code&gt;;&lt;/code&gt; is used to repeat the last &lt;code&gt;t&lt;/code&gt;, &lt;code&gt;T&lt;/code&gt;, &lt;code&gt;f&lt;/code&gt; or &lt;code&gt;F&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;On a totally different topic, don't use &lt;code&gt;nn&lt;/code&gt; use &lt;code&gt;nnoremap&lt;/code&gt; instead it is much easier to read and considered as a best practice&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2017-12-29T18:59:24.820" LastActivityDate="2017-12-29T18:59:24.820" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14681" PostTypeId="2" ParentId="10901" CreationDate="2017-12-30T01:03:08.443" Score="1" Body="&lt;h3&gt;tl;dr&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;a bug in &lt;code&gt;vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;how to reproduce/inspect&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Build &lt;code&gt;vim&lt;/code&gt; from sources with the following patch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diff --git a/src/misc1.c b/src/misc1.c&#xA;index 2d635d677..44ccf4a7a 100644&#xA;--- a/src/misc1.c&#xA;+++ b/src/misc1.c&#xA;@@ -10171,8 +10171,18 @@ unix_expandpath(&#xA;     char_u *path,&#xA;     int        wildoff,&#xA;     int        flags,      /* EW_* flags */&#xA;-    int        didstar)    /* expanded &quot;**&quot; once already */&#xA;-{&#xA;+    int        didstar, int __l)   /* expanded &quot;**&quot; once already */&#xA;+{&#xA;+FILE *__fp;&#xA;+int __i;&#xA;+__fp = fopen(&quot;../log&quot;, &quot;a&quot;);&#xA;+fprintf(__fp, &quot;%*sunix_expandpath: path: %s, wildoff: %i, flags: %x, didstar: %i\n&quot;, __l * 4, &quot;&quot;, path, wildoff, flags, didstar);&#xA;+if (gap-&amp;gt;ga_len) {&#xA;+    fprintf(__fp, &quot;%*s    gap:\n&quot;, __l * 4, &quot;&quot;);&#xA;+    for (__i = 0; __i &amp;lt; gap-&amp;gt;ga_len; __i++)&#xA;+   fprintf(__fp, &quot;%*s        %s\n&quot;, __l * 4, &quot;&quot;, ((char **)gap-&amp;gt;ga_data)[__i]);&#xA;+}&#xA;+fclose(__fp);&#xA;     char_u *buf;&#xA;     char_u *path_end;&#xA;     char_u *p, *s, *e;&#xA;@@ -10274,6 +10284,9 @@ unix_expandpath(&#xA;    regmatch.rm_ic = p_fic; /* ignore case when 'fileignorecase' is set */&#xA;     if (flags &amp;amp; (EW_NOERROR | EW_NOTWILD))&#xA;    ++emsg_silent;&#xA;+__fp = fopen(&quot;../log&quot;, &quot;a&quot;);&#xA;+fprintf(__fp, &quot;%*s    pat: %s\n&quot;, __l * 4, &quot;&quot;, pat);&#xA;+fclose(__fp);&#xA;     regmatch.regprog = vim_regcomp(pat, RE_MAGIC);&#xA;     if (flags &amp;amp; (EW_NOERROR | EW_NOTWILD))&#xA;    --emsg_silent;&#xA;@@ -10292,12 +10305,15 @@ unix_expandpath(&#xA;     {&#xA;    STRCPY(s, path_end + 1);&#xA;    ++stardepth;&#xA;-   (void)unix_expandpath(gap, buf, (int)(s - buf), flags, TRUE);&#xA;+   (void)unix_expandpath(gap, buf, (int)(s - buf), flags, TRUE, __l + 1);&#xA;    --stardepth;&#xA;     }&#xA;&#xA;     /* open the directory for scanning */&#xA;     *s = NUL;&#xA;+__fp = fopen(&quot;../log&quot;, &quot;a&quot;);&#xA;+fprintf(__fp, &quot;%*s    inspecting: %s\n&quot;, __l * 4, &quot;&quot;, *buf == NUL ? &quot;.&quot; : buf);&#xA;+fclose(__fp);&#xA;     dirp = opendir(*buf == NUL ? &quot;.&quot; : (char *)buf);&#xA;&#xA;     /* Find all matching entries */&#xA;@@ -10308,6 +10324,9 @@ unix_expandpath(&#xA;        dp = readdir(dirp);&#xA;        if (dp == NULL)&#xA;        break;&#xA;+__fp = fopen(&quot;../log&quot;, &quot;a&quot;);&#xA;+fprintf(__fp, &quot;%*s    entry: %s\n&quot;, __l * 4, &quot;&quot;, dp-&amp;gt;d_name);&#xA;+fclose(__fp);&#xA;        if ((dp-&amp;gt;d_name[0] != '.' || starts_with_dot&#xA;            || ((flags &amp;amp; EW_DODOT)&#xA;                &amp;amp;&amp;amp; dp-&amp;gt;d_name[1] != NUL&#xA;@@ -10327,7 +10346,7 @@ unix_expandpath(&#xA;            STRCPY(buf + len, &quot;/**&quot;);&#xA;            STRCPY(buf + len + 3, path_end);&#xA;            ++stardepth;&#xA;-           (void)unix_expandpath(gap, buf, len + 1, flags, TRUE);&#xA;+           (void)unix_expandpath(gap, buf, len + 1, flags, TRUE, __l + 1);&#xA;            --stardepth;&#xA;        }&#xA;&#xA;@@ -10336,12 +10355,15 @@ unix_expandpath(&#xA;        {&#xA;            /* need to expand another component of the path */&#xA;            /* remove backslashes for the remaining components only */&#xA;-           (void)unix_expandpath(gap, buf, len + 1, flags, FALSE);&#xA;+           (void)unix_expandpath(gap, buf, len + 1, flags, FALSE, __l + 1);&#xA;        }&#xA;        else&#xA;        {&#xA;            stat_T  sb;&#xA;&#xA;+__fp = fopen(&quot;../log&quot;, &quot;a&quot;);&#xA;+fprintf(__fp, &quot;%*s    found: %s\n&quot;, __l * 4, &quot;&quot;, buf);&#xA;+fclose(__fp);&#xA;            /* no more wildcards, check if there is a match */&#xA;            /* remove backslashes for the remaining components only */&#xA;            if (*path_end != NUL)&#xA;@@ -10362,6 +10384,9 @@ unix_expandpath(&#xA;            }&#xA; #endif&#xA;            addfile(gap, buf, flags);&#xA;+__fp = fopen(&quot;../log&quot;, &quot;a&quot;);&#xA;+fprintf(__fp, &quot;%*s    added: %s\n&quot;, __l * 4, &quot;&quot;, buf);&#xA;+fclose(__fp);&#xA;            }&#xA;        }&#xA;        }&#xA;diff --git a/src/os_unix.c b/src/os_unix.c&#xA;index ff0b0e88d..40c1236fe 100644&#xA;--- a/src/os_unix.c&#xA;+++ b/src/os_unix.c&#xA;@@ -6255,7 +6255,7 @@ mch_expandpath(&#xA;     char_u *path,&#xA;     int        flags)      /* EW_* flags */&#xA; {&#xA;-    return unix_expandpath(gap, path, 0, flags, FALSE);&#xA;+    return unix_expandpath(gap, path, 0, flags, FALSE, 0);&#xA; }&#xA; #endif&#xA;&#xA;diff --git a/src/proto/misc1.pro b/src/proto/misc1.pro&#xA;index 4e299e5f9..50319b6d5 100644&#xA;--- a/src/proto/misc1.pro&#xA;+++ b/src/proto/misc1.pro&#xA;@@ -98,7 +98,7 @@ void fast_breakcheck(void);&#xA; int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file, int flags);&#xA; int expand_wildcards(int num_pat, char_u **pat, int *num_files, char_u ***files, int flags);&#xA; int match_suffix(char_u *fname);&#xA;-int unix_expandpath(garray_T *gap, char_u *path, int wildoff, int flags, int didstar);&#xA;+int unix_expandpath(garray_T *gap, char_u *path, int wildoff, int flags, int didstar, int __l);&#xA; void remove_duplicates(garray_T *gap);&#xA; int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file, int flags);&#xA; void addfile(garray_T *gap, char_u *f, int flags);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ./configure CFLAGS='-g -O0 -gdwarf-2 -g3' CXXFLAGS='-g -O0 -gdwarf-2 -g3'&#xA;$ make&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;-g&lt;/code&gt; - add debugging information&lt;br&gt;&#xA;&lt;code&gt;-O0&lt;/code&gt; - reduce optimizations&lt;br&gt;&#xA;&lt;code&gt;-gdwarf-2 -g3&lt;/code&gt; - include information about &lt;a href=&quot;http://www.delorie.com/gnu/docs/gdb/gdb_17.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;preprocessor macros&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create test directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ mkdir -p a/b b&#xA;$ touch a/b/c b/c&#xA;$ tree&#xA;.&#xA;├── a&#xA;│   └── b&#xA;│       └── c&#xA;└── b&#xA;    └── c&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run &lt;code&gt;gdb&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ rm ../log; gdb --args ../vim/src/vim -u NONE&#xA;(gdb) break mch_expandpath&#xA;(gdb) r&#xA;:args **/b/**/*&#xA;(gdb) n&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;cat ../log&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unix_expandpath: path: **/b/**/*, wildoff: 0, flags: f, didstar: 0&#xA;    pat: .*&#xA;    (1) unix_expandpath: path: b/**/*, wildoff: 0, flags: f, didstar: 1&#xA;        pat: .*&#xA;        inspecting: b/&#xA;        entry: ..&#xA;        entry: c&#xA;        unix_expandpath: path: b/c/**/*, wildoff: 4, flags: f, didstar: 1&#xA;            pat: .*&#xA;            inspecting: b/c/&#xA;        unix_expandpath: path: b/c/*, wildoff: 4, flags: f, didstar: 0&#xA;            pat: .*&#xA;            inspecting: b/c/&#xA;        entry: .&#xA;    inspecting: .&#xA;    entry: a&#xA;    unix_expandpath: path: a/**/b/**/*, wildoff: 2, flags: f, didstar: 1&#xA;        pat: .*&#xA;        inspecting: a/&#xA;        entry: b&#xA;        unix_expandpath: path: a/b/**/b/**/*, wildoff: 4, flags: f, didstar: 1&#xA;            pat: .*&#xA;            inspecting: a/b/&#xA;            entry: ..&#xA;            entry: c&#xA;            unix_expandpath: path: a/b/c/**/b/**/*, wildoff: 6, flags: f, didstar: 1&#xA;                pat: .*&#xA;                inspecting: a/b/c/&#xA;            unix_expandpath: path: a/b/c/b/**/*, wildoff: 6, flags: f, didstar: 0&#xA;                pat: .*&#xA;                unix_expandpath: path: a/b/c/b/*, wildoff: 8, flags: f, didstar: 1&#xA;                    pat: .*&#xA;                    inspecting: a/b/c/b/&#xA;                inspecting: a/b/c/b/&#xA;            entry: .&#xA;        unix_expandpath: path: a/b/b/**/*, wildoff: 4, flags: f, didstar: 0&#xA;            pat: .*&#xA;            unix_expandpath: path: a/b/b/*, wildoff: 6, flags: f, didstar: 1&#xA;                pat: .*&#xA;                inspecting: a/b/b/&#xA;            inspecting: a/b/b/&#xA;        entry: ..&#xA;        entry: .&#xA;    (2) unix_expandpath: path: a/b/**/*, wildoff: 2, flags: f, didstar: 0&#xA;        pat: .*&#xA;        unix_expandpath: path: a/b/*, wildoff: 4, flags: f, didstar: 1&#xA;            pat: .*&#xA;            inspecting: a/b/&#xA;            entry: ..&#xA;            entry: c&#xA;            found: a/b/c&#xA;            added: a/b/c&#xA;            entry: .&#xA;        inspecting: a/b/&#xA;        entry: ..&#xA;        entry: c&#xA;        unix_expandpath: path: a/b/c/**/*, wildoff: 6, flags: f, didstar: 1&#xA;            gap:&#xA;                a/b/c&#xA;            pat: .*&#xA;            inspecting: a/b/c/&#xA;        unix_expandpath: path: a/b/c/*, wildoff: 6, flags: f, didstar: 0&#xA;            gap:&#xA;                a/b/c&#xA;            pat: .*&#xA;            inspecting: a/b/c/&#xA;        entry: .&#xA;    entry: b&#xA;    unix_expandpath: path: b/**/b/**/*, wildoff: 2, flags: f, didstar: 1&#xA;        gap:&#xA;            a/b/c&#xA;        pat: .*&#xA;        inspecting: b/&#xA;        entry: ..&#xA;        entry: c&#xA;        unix_expandpath: path: b/c/**/b/**/*, wildoff: 4, flags: f, didstar: 1&#xA;            gap:&#xA;                a/b/c&#xA;            pat: .*&#xA;            inspecting: b/c/&#xA;        unix_expandpath: path: b/c/b/**/*, wildoff: 4, flags: f, didstar: 0&#xA;            gap:&#xA;                a/b/c&#xA;            pat: .*&#xA;            unix_expandpath: path: b/c/b/*, wildoff: 6, flags: f, didstar: 1&#xA;                gap:&#xA;                    a/b/c&#xA;                pat: .*&#xA;                inspecting: b/c/b/&#xA;            inspecting: b/c/b/&#xA;        entry: .&#xA;    unix_expandpath: path: b/b/**/*, wildoff: 2, flags: f, didstar: 0&#xA;        gap:&#xA;            a/b/c&#xA;        pat: .*&#xA;        unix_expandpath: path: b/b/*, wildoff: 4, flags: f, didstar: 1&#xA;            gap:&#xA;                a/b/c&#xA;            pat: .*&#xA;            inspecting: b/b/&#xA;        inspecting: b/b/&#xA;    entry: ..&#xA;    entry: .&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here we can see that if &lt;code&gt;unix_expandpath (1)&lt;/code&gt; had received &lt;code&gt;didstar == 0&lt;/code&gt;, as &lt;code&gt;unix_expandpath (2)&lt;/code&gt; did, &lt;code&gt;b/c&lt;/code&gt; would have &lt;a href=&quot;https://github.com/vim/vim/blob/v8.0.1427/src/misc1.c#L10290&quot; rel=&quot;nofollow noreferrer&quot;&gt;matched&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1553" LastActivityDate="2017-12-30T01:03:08.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14682" PostTypeId="1" AcceptedAnswerId="14683" CreationDate="2017-12-30T09:12:04.840" Score="1" ViewCount="2572" Body="&lt;p&gt;I have this mapping in my &lt;code&gt;.vimrc&lt;/code&gt; file for swapping one line with the line above it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;c-k&amp;gt; dd-P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It work just fine almost in any case except for two cases. when I select the first line I and press  I expect nothing to happen and in that case if I manually do &lt;code&gt;dd-P&lt;/code&gt; the line will be removed and pasted again (so nothing happens) but if I press  the line will be removed!(I guess it's because in that case &lt;code&gt;-&lt;/code&gt; will lead to an error message or something!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the other problem is when I'm at the last line of the file &lt;code&gt;dd-P&lt;/code&gt; will swap the last line with the two lines above it instead of only the last line above it. (Which is understandable but I want to find a workaround for it.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I have in mind is to make vim do &lt;code&gt;ddP&lt;/code&gt; instead of &lt;code&gt;dd-P&lt;/code&gt; if the cursor is either at the first or the last line of the file.(or maybe just do nothing in case of the first line but I think this way I'll have fewer exceptions to make)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get what I want?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also it would be great if someone could tell me a way to make this swapping work smartly and automatically indent itself(I have a plugin that does thisone for me and I can simply call the plugin after that but I was just wondering what would the &lt;code&gt;.vimrc&lt;/code&gt; approach for this.)&lt;/p&gt;&#xA;" OwnerUserId="14609" LastActivityDate="2017-12-30T21:20:50.803" Title="vim mapping not working as expected" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14683" PostTypeId="2" ParentId="14682" CreationDate="2017-12-30T14:04:04.567" Score="5" Body="&lt;p&gt;Actually you can just use the &lt;code&gt;:m[ove]&lt;/code&gt; command to accomplish what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap &amp;lt;silent&amp;gt; &amp;lt;c-k&amp;gt; :.m-2&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will move the current line (&lt;code&gt;.&lt;/code&gt;) to &quot;below the line given by address&quot;. The address here (&lt;code&gt;-2&lt;/code&gt;) is two lines up from current position. I added &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; to prevent all this from appearing on the command line when you use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One noteworthy thing here is that an error message will appear if you try it on line 1. If you ask me, that's the way it ought to be. Still, if you'd prefer not to see the error then use this variation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap &amp;lt;silent&amp;gt; &amp;lt;c-k&amp;gt; :sil! .m-2&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:sil[ent]&lt;/code&gt; command when followed by a bang (&lt;code&gt;!&lt;/code&gt;) will suppress errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use this in Insert mode you'll need to get out of Insert (with &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;) before doing the move. Then you can get back to Insert with &lt;code&gt;:startinsert&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;silent&amp;gt; &amp;lt;c-k&amp;gt; &amp;lt;esc&amp;gt;:silent! .m-2 \| startinsert&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to do any more customization I recommend you use my original solution below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few more things...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Note my use of &lt;code&gt;:noremap&lt;/code&gt;. &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/05.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;You should always use this&lt;/a&gt; (and &lt;code&gt;:nnoremap&lt;/code&gt;, &lt;code&gt;:inoremap&lt;/code&gt;, etc.) unless you definitively want to do otherwise.&lt;/li&gt;&#xA;&lt;li&gt;I'm assuming you intentionally selected &lt;code&gt;:map&lt;/code&gt; over &lt;code&gt;:nmap&lt;/code&gt;. But if you only intend to use this for Normal mode it would be better to use &lt;code&gt;:nnoremap&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Regarding your secondary request, given that it's probably not just a &quot;here's a one line fix, no questions asked&quot; kind of thing I suggest you post another question for that.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: I didn't think to use &lt;code&gt;:move&lt;/code&gt; at first and had written a function to address this question. I'll leave it here in case anyone's interested.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The cleanest way, IMO, is to use a function. Put something like this in your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SmartLineSwap()&#xA;  let lineno = line(&quot;.&quot;)  &quot; the current line&#xA;  if lineno == line(&quot;$&quot;)  &quot; the last line in the buffer&#xA;    exe &quot;normal! ddP&quot;&#xA;  elseif lineno != 1&#xA;    exe &quot;normal! dd-P&quot;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then your mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap &amp;lt;c-k&amp;gt; :call SmartLineSwap()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-12-30T21:20:50.803" LastActivityDate="2017-12-30T21:20:50.803" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="14686" PostTypeId="1" AcceptedAnswerId="14687" CreationDate="2017-12-31T08:41:02.000" Score="9" ViewCount="2373" Body="&lt;h1&gt;My Problem&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I have added the following to my &lt;code&gt;.vimrc&lt;/code&gt; to enable spell checks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Spell Checking&#xA;set spelllang=en_us&#xA;set spellfile=$HOME/en.utf-8.add&#xA;set spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Giving the following highlight:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gi2UR.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gi2UR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both &quot;permalink&quot; and &quot;Serverless&quot; are marked as errors, and are reachable with &lt;code&gt;]s&lt;/code&gt;. However, one is cyan and the other is red, and I want to know their difference.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;What Have I Tried&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Searching for &quot;vim spell check colors&quot; and alike&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/spell.html&quot; rel=&quot;noreferrer&quot;&gt;RTFM&lt;/a&gt; and &lt;code&gt;help spell&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;My Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What is the meaning of the different spell check highlight colors in vim?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="13179" LastActivityDate="2017-12-31T23:26:22.260" Title="What is the difference between red and cyan in spell check highlighting?" Tags="|spell-checking|color|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14687" PostTypeId="2" ParentId="14686" CreationDate="2017-12-31T09:14:58.590" Score="11" Body="&lt;p&gt;If your highlighting is like mine then that would be a &lt;code&gt;SpellLocal&lt;/code&gt; error.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;SpellLocal&lt;/strong&gt; Word that is recognized by the spellchecker as one that is used in another region.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A word may be spelled differently in various regions.  For example,&#xA;  English comes in (at least) these variants:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;en&lt;/strong&gt;:         all regions&lt;br&gt;&#xA;      &lt;strong&gt;en_au&lt;/strong&gt;:      Australia&lt;br&gt;&#xA;      &lt;strong&gt;en_ca&lt;/strong&gt;:      Canada&lt;br&gt;&#xA;      &lt;strong&gt;en_gb&lt;/strong&gt;:      Great Britain&lt;br&gt;&#xA;      &lt;strong&gt;en_nz&lt;/strong&gt;:      New Zealand&lt;br&gt;&#xA;      &lt;strong&gt;en_us&lt;/strong&gt;:      USA&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Words that are not used in one region but are used in another region&#xA;  are highlighted with SpellLocal&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You should be able to confirm this by running the following command which will show highlight settings for just spell check related elements.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:for item in ['Bad','Cap','Local','Rare']| exe &quot;hi Spell&quot;.item| endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's what I see (&lt;code&gt;SpellLocal&lt;/code&gt; is &lt;code&gt;Cyan&lt;/code&gt;...might also show as &lt;code&gt;#008787&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SpellBad       xxx term=reverse ctermbg=12 gui=undercurl guisp=Red&#xA;                   links to Error&#xA;SpellCap       xxx term=reverse ctermbg=9 gui=undercurl guisp=Blue&#xA;                   links to Error&#xA;SpellLocal     xxx term=underline ctermbg=11 gui=undercurl guisp=Cyan&#xA;                   links to Error&#xA;SpellRare      xxx term=reverse ctermbg=13 gui=undercurl guisp=Magenta&#xA;                   links to Error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h spell-quickstart&lt;/code&gt; and &lt;code&gt;:h spell-remarks&lt;/code&gt;. The first one has these short descriptions of all four error types along with tag links to further help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SpellBad    word not recognized         |hl-SpellBad|    &#xA;SpellCap    word not capitalised        |hl-SpellCap|    &#xA;SpellRare   rare word                   |hl-SpellRare|    &#xA;SpellLocal  wrong spelling for region   |hl-SpellLocal|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Thought I'd add an example of how to see &lt;code&gt;SpellLocal&lt;/code&gt; in action. The region is specified with the &lt;code&gt;'spelllang'&lt;/code&gt; option. In my versions of Vim this is set to &quot;en&quot; by default which allows all regional spellings. However if I do &lt;code&gt;:set spelllang=en_us&lt;/code&gt; and then check spelling of &quot;green is the colour&quot; then &quot;colour&quot; will be highlighted in cyan since that is not considered a correct spelling of &quot;color&quot; in the U.S. but is valid in other regions such as &quot;en_gb&quot;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2017-12-31T23:26:22.260" LastActivityDate="2017-12-31T23:26:22.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14688" PostTypeId="1" AcceptedAnswerId="14689" CreationDate="2017-12-31T22:46:57.533" Score="2" ViewCount="1044" Body="&lt;p&gt;How to replace only if whole line match pattern?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example, input:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo, bar, baz #&#xA;lorem, ipsum, ret&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example, output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo, &#xA;bar, &#xA;baz #&#xA;lorem, ipsum, ret&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should only replace commas with comma+newline if we have &lt;code&gt;#&lt;/code&gt; at end of line.&lt;/p&gt;&#xA;" OwnerUserId="15769" LastActivityDate="2018-01-01T00:05:49.020" Title="Sub replace if whole line match pattern" Tags="|regular-expression|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14689" PostTypeId="2" ParentId="14688" CreationDate="2017-12-31T23:38:26.873" Score="4" Body="&lt;p&gt;Use the global command (&lt;code&gt;:g&lt;/code&gt;) which runs specified commands on all matching lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/#$/s/,/,\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will do the substitution &lt;code&gt;s/,/,\r/g&lt;/code&gt; on all lines that end with pound sign (&lt;code&gt;/#$/&lt;/code&gt;). If you meant for it to be more specific just change the pattern between the first set of slashes. For example if you only wanted to apply this to lines that have two commas &lt;code&gt;/^[^,]*,[^,]*,[^,]*#$/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#multi-repeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :g&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-01-01T00:05:49.020" LastActivityDate="2018-01-01T00:05:49.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14690" PostTypeId="1" AcceptedAnswerId="14691" CreationDate="2018-01-01T16:35:46.393" Score="3" ViewCount="278" Body="&lt;pre&gt;&lt;code&gt;function! DebugC()&#xA;    let l:debugStr = &quot;printf(\&quot;&quot; . s:debugPrefixStr . s:debugCounter . &quot;\&quot;);&quot;&#xA;&#xA;    if g:debugstringAlwaysIncludeHeader&#xA;        let l:incStr = &quot;#include &amp;lt;stdio.h&amp;gt;; &quot;&#xA;        let l:debugStr = l:incStr . l:debugStr&#xA;    endif&#xA;&#xA;    :put=l:debugStr&#xA;endfunc &quot; }}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Method dumps the text correctly but if I use execute instead of call, it always moves the cursor to the top of the &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; doesn't move to top of file&#xA;autocmd Filetype c,cpp nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;DumpDebugString  :call DebugC()&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; moves cursor to the top of the file&#xA;autocmd Filetype c,cpp nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;DumpDebugString  :exe DebugC()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adding &lt;code&gt;getcurpos()&lt;/code&gt;, &lt;code&gt;setpos()&lt;/code&gt; at the start and end of the function doesn't seem to solve the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers?&lt;/p&gt;&#xA;" OwnerUserId="6972" LastActivityDate="2018-01-01T17:34:13.937" Title=":exe moves cursor to first line of buffer" Tags="|cursor-motions|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14691" PostTypeId="2" ParentId="14690" CreationDate="2018-01-01T17:34:13.937" Score="7" Body="&lt;p&gt;In vim, a function which does not explicitly return a value actually returns 0.  So, your code is equivalent to &lt;code&gt;exe 0&lt;/code&gt;, which is like &lt;code&gt;:0&lt;/code&gt; meaning move the cursor to the first line.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-01-01T17:34:13.937" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14694" PostTypeId="1" CreationDate="2018-01-02T12:36:58.977" Score="1" ViewCount="589" Body="&lt;p&gt;This is very similar to &lt;a href=&quot;https://vi.stackexchange.com/questions/5835/how-to-run-bash-command-over-current-file-and-replace-buffer-with-result&quot;&gt;how-to-run-bash-command-over-current-file-and-replace-buffer-with-result&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I need to know how I can access current buffer when the file does not exist?&#xA;i.e.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I open vim&lt;/li&gt;&#xA;&lt;li&gt;goto insert mode e,g, press : &lt;code&gt;i&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;paste a json, possibly incomplete&lt;/li&gt;&#xA;&lt;li&gt;Run the command &lt;code&gt;!% jq&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For now I get output as error from jq.&lt;/p&gt;&#xA;" OwnerUserId="15783" LastActivityDate="2018-01-02T12:36:58.977" Title="vim + jq :: how to format possibly incorrect text in unsaved file" Tags="|buffers|formatting|" AnswerCount="0" CommentCount="6" FavoriteCount="0" ClosedDate="2018-01-02T17:14:38.907" ContentLicense="CC BY-SA 3.0" />
  <row Id="14696" PostTypeId="1" CreationDate="2018-01-02T20:00:16.250" Score="4" ViewCount="143" Body="&lt;p&gt;Is it possible to tell SnipMate to ignore a specific set of snippets?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's take &lt;code&gt;vim-snippets/snippets/javascript/javascript-jquery.snippets&lt;/code&gt; as an example. When editing a JavaScript file, all snippet files matching &lt;code&gt;vim-snippets/snippets/javascript/*.snippets&lt;/code&gt; are being loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I do not use jQuery, I don't want the jQuery snippets to be loaded. Is there some way to make SnipMate load only the files that I want it to load, or exclude the files that I don't want?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Googling this has not led to a solution.&lt;/p&gt;&#xA;" OwnerUserId="15789" LastActivityDate="2018-01-02T20:00:16.250" Title="Disable a specific set of snippets in SnipMate" Tags="|snippets|plugin-snipmate|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14697" PostTypeId="1" CreationDate="2018-01-03T00:22:11.610" Score="1" ViewCount="36" Body="&lt;p&gt;Why does the output of &lt;code&gt;syn list&lt;/code&gt; not include &lt;code&gt;region&lt;/code&gt; in the syntax group definition line, like it does for 'match' type groups? What is the meaning of the &lt;code&gt;xxx&lt;/code&gt; in that line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got a vim 8.0 function that accepts a syntax group name, parses the output of &lt;code&gt;syn list&lt;/code&gt; for that group, then clears and redefines that syntax group with a minor tweak (in this case, it is toggling the conceal arg). The final step requires executing &lt;code&gt;syn match&lt;/code&gt;, &lt;code&gt;syn region&lt;/code&gt;, etc.. and so requires determination of the specified group's type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I've stated above, the group type is not provided for regions, so before I just work around this by grepping for the required and unique &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; args in order to determine group type, I thought I'd ask whether anyone knows why this discrepancy exists. Is it a bug? Is there some other (better) way to grokk syntax group type from &lt;code&gt;syn list&lt;/code&gt; output?&lt;/p&gt;&#xA;" OwnerUserId="15063" LastActivityDate="2018-01-03T00:22:11.610" Title="Determining syntax group type from output of 'syn list' (doesn't appear to work for regions)" Tags="|syntax-highlighting|functions|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14698" PostTypeId="1" CreationDate="2018-01-03T00:52:50.977" Score="9" ViewCount="7797" Body="&lt;p&gt;When I try to save a file I get the attached error almost every time. I haven't opened or modified the file in different editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is for Elixir files, and the code get compiled. Not sure if that is the cause of this error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway that I can bypass this as it is getting super annoying. &#xA;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/T630l.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T630l.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15642" LastEditorUserId="51" LastEditDate="2018-01-03T01:02:54.847" LastActivityDate="2021-07-13T17:51:43.253" Title="How to bypass &quot;The file has been changed since reading it&quot;?" Tags="|save|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14699" PostTypeId="2" ParentId="3875" CreationDate="2018-01-03T02:18:10.690" Score="39" Body="&lt;p&gt;If you don't want to add mappings or a package dependency, you can just yank &lt;code&gt;yy&lt;/code&gt; an empty line and then pasted &lt;code&gt;p&lt;/code&gt; for below cursor and &lt;code&gt;P&lt;/code&gt; for above the cursor.&lt;/p&gt;&#xA;" OwnerUserId="15794" LastEditorUserId="15794" LastEditDate="2022-02-11T17:58:44.747" LastActivityDate="2022-02-11T17:58:44.747" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="14700" PostTypeId="1" AcceptedAnswerId="14701" CreationDate="2018-01-03T06:26:13.870" Score="9" ViewCount="7145" Body="&lt;p&gt;Following my pressing ':' I can switch to command insert mode and pressing 'Up Arrow' I can bring up my previous command. &lt;br/&gt;&lt;br/&gt;&#xA;How can I delete a word left of my cursor during command insert mode?&#xA;Say for my example I have this in my command pane:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!sh listtablefromdb.sh mytablename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to delete &lt;code&gt;mytablename&lt;/code&gt; via single keyboard shortcut&lt;/p&gt;&#xA;" OwnerUserId="7332" LastEditorUserId="7332" LastEditDate="2018-01-03T10:07:33.890" LastActivityDate="2018-01-03T10:22:01.473" Title="How can I delete whole word in command insert mode?" Tags="|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14701" PostTypeId="2" ParentId="14700" CreationDate="2018-01-03T07:31:18.070" Score="18" Body="&lt;p&gt;If you press &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;U&lt;/kbd&gt; all characters to the left of the cursor until the beginning of the commandline will be deleted. This is also explained in the help at &#xA;&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-U&quot; rel=&quot;noreferrer&quot;&gt;:h c_CTRL-U&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To delete a single word, you can use &lt;kbd&gt;Ctrl-W&lt;/kbd&gt;(&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-W&quot; rel=&quot;noreferrer&quot;&gt;:h c_CTRL-W&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-01-03T10:22:01.473" LastActivityDate="2018-01-03T10:22:01.473" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14702" PostTypeId="2" ParentId="14700" CreationDate="2018-01-03T09:11:16.943" Score="7" Body="&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;W&lt;/kbd&gt; will delete one word.&lt;/p&gt;&#xA;" OwnerUserId="11136" LastActivityDate="2018-01-03T09:11:16.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14703" PostTypeId="1" AcceptedAnswerId="14705" CreationDate="2018-01-03T10:23:19.663" Score="4" ViewCount="535" Body="&lt;p&gt;I often find myself in this situation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\foo{\bar abc \baz{def} more stuff}&#xA;          ↑&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to change anything from the cursor position to the &lt;em&gt;correct&lt;/em&gt; enclosing brace. In simple cases, &lt;code&gt;ct}&lt;/code&gt; works fine, but not here, as it would yield&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\foo{\bar } more stuff}&#xA;          ↑&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other simple cases, when I am happy to change the whole content of the braces, I can use text objects, i.e. &lt;code&gt;ci}&lt;/code&gt;, to change everything correctly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\foo{}&#xA;     ↑&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how do I get to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\foo{\bar }&#xA;          ↑&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ideally somehow using text objects  (i.e. &lt;code&gt;i}&lt;/code&gt;), so that it works well in general?&lt;/p&gt;&#xA;" OwnerUserId="1937" LastEditorUserId="343" LastEditDate="2018-01-03T11:08:21.433" LastActivityDate="2018-01-05T02:46:51.857" Title="Delete from cursor position to end of text object" Tags="|cursor-motions|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14704" PostTypeId="2" ParentId="14703" CreationDate="2018-01-03T10:32:53.183" Score="4" Body="&lt;p&gt;when I do &lt;code&gt;c2t}&lt;/code&gt; it seems to work, but this is assuming you know that it's the second bracket.&lt;/p&gt;&#xA;" OwnerUserId="15802" LastActivityDate="2018-01-03T10:32:53.183" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14705" PostTypeId="2" ParentId="14703" CreationDate="2018-01-03T10:44:54.317" Score="5" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/tommcdo/vim-ninja-feet&quot; rel=&quot;noreferrer&quot;&gt;ninja-feet.vim&lt;/a&gt; plugin by &lt;a href=&quot;https://vi.stackexchange.com/users/64/tommcdo&quot;&gt;Tom McDonald&lt;/a&gt; adds this functionality to Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With it installed, add &lt;kbd&gt;[&lt;/kbd&gt; or &lt;kbd&gt;]&lt;/kbd&gt; between the operator and text object to specify which end you wish edit: press &lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;}&lt;/kbd&gt; to perform the edit you describe.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-03T10:44:54.317" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14706" PostTypeId="2" ParentId="7085" CreationDate="2018-01-03T13:21:08.613" Score="0" Body="&lt;p&gt;If there are lines that contains uppercase words, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.,.+3s/\([A-Z]\)\([A-Z]\+\)/\=submatch(1).tolower(submatch(2))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will transform current line and subsequent 3 lines. the result is like below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;original:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;12&quot;&gt;&#xA;  &lt;li&gt;DO-IT-YOURSELF TRANQUILIZERS THAT BRING PEACE OF MIND 187&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;transformed:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;12&quot;&gt;&#xA;  &lt;li&gt;Do-It-Yourself Tranquilizers That Bring Peace Of Mind 187&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;to lowercase/uppercase is similar, but simpler.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2018-01-03T13:21:08.613" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14707" PostTypeId="2" ParentId="14703" CreationDate="2018-01-03T19:32:15.217" Score="0" Body="&lt;p&gt;Use the change command, using search (/) semantics:&#xA;&quot;Change until the next occurrence of right brace&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;c/}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15812" LastActivityDate="2018-01-03T19:32:15.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14709" PostTypeId="1" AcceptedAnswerId="14710" CreationDate="2018-01-03T21:09:47.830" Score="2" ViewCount="931" Body="&lt;p&gt;If I run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !node&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will take my current buffer and send it to stdin and run the code in node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @+ | echo &quot;bob&quot; | redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It ends up on the system clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I want to copy the output to the clipboard, by running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @+ | w !node | redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems the input from the current buffer does not reach node, and that it tries to run redir as a command from bash for some reason.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @+ | w !node | redir END&#xA;/bin/bash: redir: command not found&#xA;events.js:141&#xA;      throw er; // Unhandled 'error' event&#xA;      ^&#xA;&#xA;Error: write EPIPE&#xA;    at exports._errnoException (util.js:907:11)&#xA;    at WriteWrap.afterWrite (net.js:790:14)&#xA;&#xA;shell returned 127&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there some other way to do this?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2018-01-03T21:41:20.763" Title="Copy output of bash command to system clipboard?" Tags="|buffers|external-command|ex-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14710" PostTypeId="2" ParentId="14709" CreationDate="2018-01-03T21:21:02.473" Score="8" Body="&lt;p&gt;Everything after &lt;code&gt;!&lt;/code&gt; will be a command, including &lt;code&gt;|&lt;/code&gt;. So what you're running is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @+&#xA;:w !node | redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes sense, since using &lt;code&gt;|&lt;/code&gt; is shell commands is common to pipe output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest workaround is to use multiple lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @+&#xA;:w !node&#xA;:redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or you can use &lt;code&gt;:execute&lt;/code&gt; to work around this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @+ | :exe 'w !node' | redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2018-01-03T21:41:20.763" LastActivityDate="2018-01-03T21:41:20.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14712" PostTypeId="1" CreationDate="2018-01-03T22:27:18.550" Score="1" ViewCount="611" Body="&lt;p&gt;As title, is there any options in vim that can do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Need a way to control messages system in vim, and as usual even hard-coded, still need preserve some options for users.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="14274" LastEditDate="2018-01-04T03:17:12.213" LastActivityDate="2018-01-04T07:38:33.683" Title="Hide bottom message when open new file" Tags="|startup|message|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14713" PostTypeId="1" CreationDate="2018-01-04T00:31:08.060" Score="1" ViewCount="811" Body="&lt;p&gt;I'm trying to work with indenting yaml in vim, and I'm trying to convert it to JSON.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say I have a file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---&#xA;  foo: bar&#xA;  baz:&#xA;    - qux&#xA;    - quxx&#xA;  corge: null&#xA;  grault: 1&#xA;  garply: true&#xA;  waldo: &quot;false&quot;&#xA;  fred: undefined&#xA;  literal_block: |&#xA;   blah wee  `bib` &#xA;   blah&#xA;  # Multiple-line strings can be written either as a 'literal block' (using |),&#xA;  # or a 'folded block' (using '&amp;gt;').&#xA;  test: blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The literal block part (as well as the indentation overall) are giving me a hard time.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When typing a &lt;a href=&quot;http://www.yaml.org/spec/1.2/spec.html#id2795688&quot; rel=&quot;nofollow noreferrer&quot;&gt;literal_block&lt;/a&gt; I usually start off with all the content un-indented.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  literal_block: |&#xA;blah wee  `bib` &#xA;blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then what I was hoping to do was to indent 3 spaces when I press either the tab key or by pressing &gt;&gt; to indent like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  literal_block: |&#xA;   blah wee  `bib` &#xA;   blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that should result in an output from the &lt;a href=&quot;http://yaml-online-parser.appspot.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;yaml-to-json parser&lt;/a&gt; of something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  &quot;waldo&quot;: &quot;false&quot;, &#xA;  &quot;baz&quot;: [&#xA;    &quot;qux&quot;, &#xA;    &quot;quxx&quot;&#xA;  ], &#xA;  &quot;fred&quot;: &quot;undefined&quot;, &#xA;  &quot;corge&quot;: null, &#xA;  &quot;literal_block&quot;: &quot;blah wee  `bib` \nblah\n&quot;, &#xA;  &quot;grault&quot;: 1, &#xA;  &quot;test&quot;: &quot;blah&quot;, &#xA;  &quot;garply&quot;: true, &#xA;  &quot;foo&quot;: &quot;bar&quot;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, that's not what happens when I press those keys, instead I get &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  literal_block: |&#xA;        blah wee  `bib` &#xA;        blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and a parser error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've even installed the &lt;code&gt;vim-ansible-yaml plugin&lt;/code&gt; as suggested by &lt;a href=&quot;https://stackoverflow.com/a/27427876/18149&quot;&gt;this post&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I try a different plugin for my indents?  It seems like literal-block indents have 3 spaces beyond the parent, and everything else gets 2 spaces.&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2018-01-04T00:31:08.060" Title="Working with yaml literal-blocks in vim?" Tags="|filetype-yaml|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14714" PostTypeId="1" AcceptedAnswerId="21036" CreationDate="2018-01-04T01:30:05.880" Score="1" ViewCount="665" Body="&lt;p&gt;When we type &lt;code&gt;:qa&lt;/code&gt; or &lt;code&gt;:wqa&lt;/code&gt;, neovim quits/save-and-quits all buffers. This also closes any terminal buffers that are open, even if there are pending jobs running. Those jobs just get killed!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to have neovim ask for a confirmation when a terminal window is open (like trying to do a &lt;code&gt;:qa&lt;/code&gt; when there are edited buffers). This way the running jobs aren't killed, when I accidently type &lt;code&gt;:qa&lt;/code&gt; to quit vim.&lt;/p&gt;&#xA;" OwnerUserId="15320" LastActivityDate="2019-08-30T10:40:08.913" Title="Have NeoVim confirm before closing when terminals are open" Tags="|neovim|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14715" PostTypeId="2" ParentId="14712" CreationDate="2018-01-04T03:17:54.337" Score="2" Body="&lt;p&gt;as suggested by Carpetsmoker in comments, here is how I solved this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shortmess+=F&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="1841" LastEditDate="2018-01-04T07:38:33.683" LastActivityDate="2018-01-04T07:38:33.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14716" PostTypeId="1" CreationDate="2018-01-04T09:16:01.380" Score="0" ViewCount="146" Body="&lt;p&gt;One bash script is named without file extension, NERD Commenter works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another bash script name is aaa.sa. NERD Commenter is using -- to comment a line instead of #. File syntax highlight is also wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Sha7T.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Sha7T.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-01-04T09:24:41.973" Title="NERD Commenter: Why it choose -- to comment a bash file?" Tags="|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14717" PostTypeId="2" ParentId="14716" CreationDate="2018-01-04T09:24:41.973" Score="4" Body="&lt;p&gt;&lt;code&gt;.sa&lt;/code&gt; files are &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/filetype.vim#L1384-L1385&quot; rel=&quot;nofollow noreferrer&quot;&gt;detected by Vim&lt;/a&gt; as &lt;a href=&quot;http://www.icsi.berkeley.edu/~sather&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sather&lt;/a&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check in Vim by issuing &lt;code&gt;:verbose set filetype?&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to have your own filetypes detected matching a particular pattern, please check the &lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-26.8&quot; rel=&quot;nofollow noreferrer&quot;&gt;faq&lt;/a&gt; (also other questions in the same section might be relevant for you).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, I find using the extension &lt;code&gt;sa&lt;/code&gt; for bash files confusing and un-intuitive.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-01-04T09:24:41.973" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14718" PostTypeId="1" CreationDate="2018-01-04T11:30:27.437" Score="2" ViewCount="122" Body="&lt;p&gt;In the vimgolf challenge &lt;a href=&quot;http://vimgolf.com/challenges/5192f96ad8df110002000002&quot; rel=&quot;nofollow noreferrer&quot;&gt;Words in parens&lt;/a&gt;, I use &lt;code&gt;cw(ctrl-r&amp;quot;)Esc&lt;/code&gt; to format &amp;quot;one&amp;quot; and then use &lt;code&gt;w.&lt;/code&gt; to format the next two words, but the results are three copies of the text &amp;quot;(one)&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;I use the &lt;code&gt;:reg&lt;/code&gt; command to confirm the &lt;code&gt;&amp;quot;&lt;/code&gt; unnamed register content equals &amp;quot;three&amp;quot;, and I found another solution that formats the text correctly: use &lt;code&gt;cw(ctrl-r ctrl-o&amp;quot;)Esc&lt;/code&gt; to format &amp;quot;one&amp;quot;, then use &lt;code&gt;w.&lt;/code&gt; to format the next two.&lt;/p&gt;&#xA;&lt;p&gt;But I'm still confused about the vim dot command in this case: why does the dot command not act the same as typing out the command again? There must be something I have missed about the vim dot command: I hope someone can give me an explanation about this case.&lt;/p&gt;&#xA;" OwnerUserId="15816" LastEditorUserId="343" LastEditDate="2020-06-29T08:41:46.627" LastActivityDate="2020-06-29T08:41:46.627" Title="vim dot command act result not same as full type command with &lt;C-r&gt;&quot;" Tags="|vimrc|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="14719" PostTypeId="1" CreationDate="2018-01-04T13:57:44.680" Score="2" ViewCount="115" Body="&lt;p&gt;I have set up vim on a new machine according to &lt;a href=&quot;https://github.com/spicycode/Vimlander-2-The-Quickening&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimlander-2-The-Quickening&lt;/a&gt;, but I keep running into the following errors when I open a file in command mode: &lt;code&gt;:e /path/to/file&lt;/code&gt;, &lt;code&gt;:vs /path/to/file&lt;/code&gt;, or &lt;code&gt;:sp /path/to/file&lt;/code&gt;. Does anyone recognize these errors or resolved them?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;62_UseConfigFiles[26]..&amp;lt;SNR&amp;gt;62_Initialize[47]..&amp;lt;SNR&amp;gt;62_InitializePythonBuiltin:&#xA;line   23:&#xA;E887: Sorry, this command is disabled, the Python's site module could not be loaded.&#xA;Error detected while processing function &amp;lt;SNR&amp;gt;62_UseConfigFiles[41]..&amp;lt;SNR&amp;gt;62_UseConfigFiles_Python_Builtin:&#xA;line    6:&#xA;E887: Sorry, this command is disabled, the Python's site module could not be loaded.&#xA;I suspect there is something wrong with my shell config, but it's hard to identity the cause of the problem.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suspect there is something wrong with my shell config and how it loads Python, but it's hard to identity the cause of the problem.&lt;/p&gt;&#xA;" OwnerUserId="15822" LastActivityDate="2018-01-04T13:57:44.680" Title="Vim: error opening files &lt;SNR&gt;62_InitializePythonBuiltin the Python's site module could not be loaded" Tags="|bash|" AnswerCount="0" CommentCount="4" ClosedDate="2018-01-04T16:02:04.660" ContentLicense="CC BY-SA 3.0" />
  <row Id="14720" PostTypeId="1" AcceptedAnswerId="14721" CreationDate="2018-01-04T14:45:22.980" Score="0" ViewCount="183" Body="&lt;p&gt;How can I create a new buffer just after(next to) the one I am on ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let say I have three buffers opened (1, 2, 3) and I am (my cursor) currently in buffer 1. If I add a new buffer (with &lt;code&gt;:edit&lt;/code&gt; for example) it will open it in buffer 4, but instead I want to open it in buffer 2 without deleting other existent buffers (so maybe buffer 2 and 3 will become 3 and 4, it's a sort of insert).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any way to do this? (I did some research and found nothing). Thanks.&lt;/p&gt;&#xA;" OwnerUserId="15823" LastEditorUserId="15823" LastEditDate="2018-01-04T16:37:01.683" LastActivityDate="2018-01-05T02:25:06.153" Title="Add new buffer after current one" Tags="|buffers|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14721" PostTypeId="2" ParentId="14720" CreationDate="2018-01-04T15:17:48.173" Score="1" Body="&lt;p&gt;There is no way to target buffer numbers in order to rearrange them or to say, &lt;em&gt;&quot;now it contains this file&quot;&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could do a &lt;code&gt;:b 2&lt;/code&gt; + &lt;code&gt;:%d_&lt;/code&gt; + &lt;code&gt;:read somefile&lt;/code&gt;, but that won't be enough, you'd also need to clear filetype, filename, local options and variables, syntax highlighting, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best thing to do: forget buffer numbers, there is no way to organize them as you'd like.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-01-04T15:17:48.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14723" PostTypeId="1" AcceptedAnswerId="14725" CreationDate="2018-01-04T21:14:31.013" Score="3" ViewCount="815" Body="&lt;p&gt;I'd like to reproduce this zsh mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;smart_dot() {&#xA;  if [[ $LBUFFER = *.. ]]; then&#xA;    LBUFFER+=/..&#xA;  else&#xA;    LBUFFER+=.&#xA;  fi&#xA;}&#xA;zle -N smart_dot&#xA;bindkey -M viins -- . smart_dot&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At first I used this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code&gt;function! Smart_dot() abort&#xA;  if getcmdtype() =~# '[:]'&#xA;    let l:cmd=getcmdline()&#xA;    if match(l:cmd, '\.\.$') !=-1&#xA;      return '/..'&#xA;    else&#xA;      return &quot;.&quot;&#xA;    endif&#xA;  else&#xA;    return getcmdline()&#xA;  endif&#xA;endfunction&#xA;cnoremap . &amp;lt;c-r&amp;gt;=Smart_dot()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but how do turn this into local function? I've tried many variants on this that wouldn't work because it complained &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; was not used in a script context. Do I need to use &lt;code&gt;&amp;lt;c-r&amp;gt;=&lt;/code&gt; or &lt;code&gt;&amp;lt;c-\&amp;gt;e&lt;/code&gt;? Do I need to use the &lt;code&gt;expand(&amp;lt;sfile&amp;gt;)&lt;/code&gt; trick to get the script number, described near the end of section &lt;code&gt;:h script-local&lt;/code&gt;? Or do I need to &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; this? I'm confused.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; function! s:smart_dot() ...&#xA;cnoremap . &amp;lt;C-\&amp;gt;ecall(function('&amp;lt;SID&amp;gt;smart_dot()'), [])&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1027" LastActivityDate="2018-01-04T23:39:58.447" Title="How to cmap a local function?" Tags="|key-bindings|expression-register|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14724" PostTypeId="1" AcceptedAnswerId="14726" CreationDate="2018-01-04T21:27:51.083" Score="1" ViewCount="424" Body="&lt;p&gt;I have installed ctags (Ubuntu 16.04), added &lt;code&gt;set tags=./tags;&lt;/code&gt; to &lt;code&gt;.vimrc&lt;/code&gt; file, it kinda works, I can move around ruby classes and methods I have defined myself but when I want to see Rails built-in sources definitions it does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, when I press &lt;code&gt;ctrl+]&lt;/code&gt; having the cursor under &lt;code&gt;Post.new&lt;/code&gt; in my controller it works, it takes me to the definition of the Post class in post.rb file. When I position the cursor on &lt;code&gt;has_many&lt;/code&gt; method it does not work, it throws an error (translated from polish) &lt;code&gt;E426: Can't find indicator: has_many&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix the problem?&lt;/p&gt;&#xA;" OwnerUserId="15825" LastActivityDate="2018-01-04T23:42:58.503" Title="Ctags with Rails not working" Tags="|ctags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14725" PostTypeId="2" ParentId="14723" CreationDate="2018-01-04T23:39:58.447" Score="4" Body="&lt;p&gt;You may use &lt;code&gt;&amp;lt;sid&amp;gt;&lt;/code&gt; directly in this context like any other key code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap . &amp;lt;c-r&amp;gt;=&amp;lt;sid&amp;gt;Smart_dot()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason is the &lt;code&gt;*map&lt;/code&gt; family of commands are special in that they convert key codes to actual real characters.  For example, &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; is converted to a carriage return, code 13, and &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt; is converted to code 18.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-01-04T23:39:58.447" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14726" PostTypeId="2" ParentId="14724" CreationDate="2018-01-04T23:42:58.503" Score="0" Body="&lt;p&gt;I've managed to resolve my problem myself by installing the gem &lt;a href=&quot;https://github.com/tpope/gem-ctags&quot; rel=&quot;nofollow noreferrer&quot;&gt;gem-ctags&lt;/a&gt; and followed the instructions included there. In order to keep the tags up-to-date install &lt;a href=&quot;https://github.com/tpope/vim-bundler&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-bundler&lt;/a&gt; plugin, which automatically alters the tags to include all gems after executing &lt;code&gt;bundle&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="15825" LastActivityDate="2018-01-04T23:42:58.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14727" PostTypeId="2" ParentId="14720" CreationDate="2018-01-05T02:25:06.153" Score="0" Body="&lt;p&gt;If you're concerned to keep things &quot;in order&quot;, using &lt;code&gt;:argedit&lt;/code&gt; or &lt;code&gt;:argadd&lt;/code&gt; adds the filename to the list and you can then stick to :n :N for navigation. I usually map a pair of keys (e.g. F3/F4) to mean previous / next so I don't have to keep hitting ESCAPE and : when I'm editing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map! &amp;lt;special&amp;gt; &amp;lt;F3&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-o&amp;gt;&amp;lt;F3&amp;gt;&#xA;map! &amp;lt;special&amp;gt; &amp;lt;F4&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-o&amp;gt;&amp;lt;F4&amp;gt;&#xA;map &amp;lt;special&amp;gt; &amp;lt;F3&amp;gt; :N&amp;lt;Enter&amp;gt;&#xA;map &amp;lt;special&amp;gt; &amp;lt;F4&amp;gt; :n&amp;lt;Enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yes, I know how lazy that is ...&lt;/p&gt;&#xA;" OwnerUserId="14114" LastActivityDate="2018-01-05T02:25:06.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14728" PostTypeId="2" ParentId="14703" CreationDate="2018-01-05T02:46:51.857" Score="2" Body="&lt;p&gt;If you don't mind having the retype the closing &lt;code&gt;}&lt;/code&gt; would:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;c]}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;do what you want? Although I think I prefer v]} so I can see what it's going to change first ...&lt;/p&gt;&#xA;" OwnerUserId="14114" LastActivityDate="2018-01-05T02:46:51.857" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14729" PostTypeId="1" AcceptedAnswerId="14730" CreationDate="2018-01-05T03:45:36.190" Score="1" ViewCount="768" Body="&lt;p&gt;Installed vim with &lt;a href=&quot;http://spacevim.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;SpaceVim&lt;/a&gt; on macOS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When ran &lt;code&gt;vim&lt;/code&gt; in the &lt;code&gt;iTerm2&lt;/code&gt; terminal, the information can't been shown rightly at status bar. Much of them been shown as &lt;code&gt;?&lt;/code&gt;. Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vc7iy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vc7iy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15817" LastEditorUserId="15817" LastEditDate="2018-01-05T04:05:34.890" LastActivityDate="2018-01-10T08:04:30.370" Title="Why some information can't been shown at status bar with iTerm2?" Tags="|terminal|unicode|macos|iterm2|spacevim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14730" PostTypeId="2" ParentId="14729" CreationDate="2018-01-05T07:32:51.473" Score="1" Body="&lt;p&gt;SpaceVim uses a built-in modular status line, which depends on a power line patched font. These fonts include extra symbols that render as arrows in the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find pre-patched fonts here: &lt;a href=&quot;https://github.com/powerline/fonts&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/powerline/fonts&lt;/a&gt;.&#xA;I’m pretty sure that repository also has instructions for patching an arbitrary font if none of the fonts it provides are to your liking. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After installing one you’ll need to switch to using that font in iTerm2.&lt;/p&gt;&#xA;" OwnerUserId="8335" LastEditorUserId="5298" LastEditDate="2018-01-10T08:04:30.370" LastActivityDate="2018-01-10T08:04:30.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14734" PostTypeId="1" AcceptedAnswerId="14735" CreationDate="2018-01-06T00:14:38.930" Score="0" ViewCount="225" Body="&lt;p&gt;I had the following mapping to go to the 1st non blank character of a line&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap M ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I then decided that if I was already at the 1st non blank character I wanted M to take me to the absolute 1st character of the line.&lt;br&gt;&#xA;I was able to hack together the following vimscript function to do this.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;func Mbehaviour()&#xA;    let origPos = getcurpos()&#xA;    normal! ^&#xA;    let newPos = getcurpos()&#xA;    call setpos('.', origPos)&#xA;    if newPos == origPos&#xA;        execute &quot;normal! \&amp;lt;Home&amp;gt;&quot;&#xA;    else&#xA;        normal! ^&#xA;    endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;&amp;amp; then map this to M with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap M :call Mbehaviour()&amp;lt;CR&amp;gt;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My question is how can I get the same thing to work in visual mode?&lt;/p&gt;&#xA;" OwnerUserId="15835" LastEditorUserId="15835" LastEditDate="2018-01-06T00:32:25.767" LastActivityDate="2018-01-06T00:36:19.640" Title="Replicate normal mode function in visual mode" Tags="|visual-mode|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14735" PostTypeId="2" ParentId="14734" CreationDate="2018-01-06T00:31:07.540" Score="1" Body="&lt;p&gt;In &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp/blob/master/plugin/homeLikeVC%2B%2B.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-cpp&lt;/a&gt;, I have a single (old) function that can be used from all three modes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; &amp;lt;c-o&amp;gt;@=&amp;lt;SID&amp;gt;HomeLikeVCpp()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; @=&amp;lt;SID&amp;gt;HomeLikeVCpp()&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; @=&amp;lt;SID&amp;gt;HomeLikeVCpp()&amp;lt;cr&amp;gt;&#xA;&#xA;function! s:HomeLikeVCpp()&#xA;  let ll = strpart(getline('.'), -1, col('.'))&#xA;  if ll =~ '^\s\+$' | return '0'&#xA;  else              | return '^'&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess it could be rewritten as a &lt;code&gt;:map-&amp;lt;expr&amp;gt;&lt;/code&gt; now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Years later, I'm wondering why I was bothering to test a substring against a regex, while testing the current column is more than enough -- unless we really want to start with the first non blank character.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;expr&amp;gt; &amp;lt;home&amp;gt; col('.') == 1 ? '^' : '0'&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;home&amp;gt; col('.') == 1 ? '^' : '0'&#xA;inoremap &amp;lt;expr&amp;gt; µ col('.') == 1 ? '&amp;lt;c-o&amp;gt;^' : '&amp;lt;c-o&amp;gt;0'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Anyway, don't fight with &lt;code&gt;:normal&lt;/code&gt;. I found best to avoid this command from functions whenever I can. Keep it simple.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-01-06T00:36:19.640" LastActivityDate="2018-01-06T00:36:19.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14736" PostTypeId="1" CreationDate="2018-01-06T06:28:03.003" Score="1" ViewCount="168" Body="&lt;p&gt;There are many question regarding this on SE and various solutions have been provided on how to access system clipboard on various platforms. I &lt;code&gt;ssh&lt;/code&gt; to various machines and on some platforms, my clipboard and vim stop playing well (specially over shh).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin to which makes vim access the system clipboard on almost all Linux, MacOSX, and puTTy (with &lt;code&gt;ssh -X&lt;/code&gt;) ?&lt;/p&gt;&#xA;" OwnerUserId="7610" LastEditorUserId="7610" LastEditDate="2018-01-06T07:03:37.350" LastActivityDate="2018-01-06T07:27:30.763" Title="Any vim-plugin to access system clipboard on as many unix platforms as possible?" Tags="|plugin-system|os-clipboard|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14737" PostTypeId="2" ParentId="14736" CreationDate="2018-01-06T07:27:30.763" Score="2" Body="&lt;p&gt;I've not heard of such a plugin (doesn't mean it doesn't exist). But I can lay out an alternative approach...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of dealing with multiple systems and their disparate clipboard configurations use your local &lt;code&gt;vim&lt;/code&gt; (+netrw) to edit remote files. Since you mention accessing remote systems with &lt;code&gt;ssh&lt;/code&gt; then &lt;code&gt;vim&lt;/code&gt; can use &lt;code&gt;scp&lt;/code&gt;, for one. Let's say you want to update a text file in a remote home directory...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Nread scp://my.name@example.com/~/file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e scp://my.name@example.com/~/file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works from the command line, too. (&lt;code&gt;$ vim scp://etc&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can cut and paste to your heart's content using just the local clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other protocols are available including these (&lt;code&gt;:h netrw-read&lt;/code&gt; for complete list):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Nread &quot;ftp://[user@]machine[[:#]port]/path&quot;    uses ftp w/ &amp;lt;.netrc&amp;gt;&#xA;:Nread &quot;http://[user@]machine/path&quot;             uses http&#xA;:Nread &quot;rsync://[user@]machine[:port]/path&quot;     uses rsync&#xA;:Nread &quot;scp://[user@]machine[[:#]port]/path&quot;    uses scp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Editing_remote_files_via_scp_in_vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;More remote editing tips&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If your workflow is more along the lines of impromptu use of &lt;code&gt;vim&lt;/code&gt; while you're doing work on the command line of a remote machine then check out out &lt;a href=&quot;http://sshmenu.sourceforge.net/articles/bcvi&quot; rel=&quot;nofollow noreferrer&quot;&gt;bcvi&lt;/a&gt;. Install this standalone script on a remote machine and then when you do &lt;code&gt;vi file.txt&lt;/code&gt; on the remote (e.g. during an &lt;code&gt;ssh&lt;/code&gt; session) your &lt;em&gt;local&lt;/em&gt; &lt;code&gt;[g]vim&lt;/code&gt; will open the remote file automatically using the same underlying mechanism as described above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some outside the box thinking for you.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-01-06T07:27:30.763" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14738" PostTypeId="2" ParentId="14074" CreationDate="2018-01-06T08:58:19.467" Score="2" Body="&lt;p&gt;This was &lt;a href=&quot;https://github.com/vim/vim/issues/2323&quot; rel=&quot;nofollow noreferrer&quot;&gt;identified as a bug&lt;/a&gt; and has been (to the best of my knowledge) resolved thanks to the hard work of @ChristianBrabandt and others.&lt;/p&gt;&#xA;" OwnerUserId="2593" LastActivityDate="2018-01-06T08:58:19.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14739" PostTypeId="1" CreationDate="2018-01-06T14:16:49.423" Score="0" ViewCount="262" Body="&lt;p&gt;I would like to be able to find an occurence of a pattern, highlight it, go to the next occurence of the pattern, highlight it, go to the next one, and so on and so forth, and on the end delete all the occurences and enter insert mode. For example, find all occurences of  one by one and on the end delete all of them and enter insert mode to replace it with &lt;p&gt;. The reason I want to see the occurences one by one is that I first want to see where the occurence is in the code in order to decide if I want to delete it or not. For example, I have some HTML and want to see where the tags are in a certain code block in order to decide if I want to delete them or not. I know I can do dw to cut a word or cw to delete a word and enter insert mode. I know I can use regular expressions like  :%s/my_patter/replace_pattern/gc but that would delete all the occurences in the whole file, which I don't want. I want to first iterate over each occurence of the pattern, skip it if I want to ommit it before I decide if I want to replace it with something else. This is similar to what you can do in Sublime by selecting a word and pressing ctrl+D and then perform the change on all the occurences with one key stroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I have this code and in here I would like to replace all the &lt;code&gt;div&lt;/code&gt;s but the second one with &lt;code&gt;p&lt;/code&gt; at once:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;form-group&quot;&amp;gt;&#xA;  &amp;lt;%= f.label :daily_hours, class: &quot;col-sm-2 control-label&quot; %&amp;gt;&#xA;  &amp;lt;%= f.text_field :daily_hours, class: &quot;form-control&quot; %&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&amp;lt;div class=&quot;form-group&quot;&amp;gt;&#xA;  &amp;lt;%= f.label :date, class: &quot;col-sm-2 control-label&quot; %&amp;gt;&#xA;  &amp;lt;%= f.date_field :date, class: &quot;form-control&quot; %&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&amp;lt;div class=&quot;form-group&quot;&amp;gt;&#xA;  &amp;lt;%= f.label :work_performed, class: &quot;col-sm-2 control-label&quot; %&amp;gt;&#xA;  &amp;lt;%= f.text_area :work_performed, class: &quot;form-control&quot; %&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15825" LastActivityDate="2018-01-08T00:45:53.527" Title="Vim - find an occurence of a pattern one by one and and edit it at once" Tags="|search|substitute|replace|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14740" PostTypeId="1" AcceptedAnswerId="14741" CreationDate="2018-01-06T16:30:36.333" Score="2" ViewCount="135" Body="&lt;p&gt;Like the title, What is the meaning of &lt;code&gt;#&lt;/code&gt; in &lt;code&gt;:g/pattern/z#.5&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:g/pattern/z#.5&lt;/code&gt; and &lt;code&gt;:g/pattern/z.5&lt;/code&gt;return the same output for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, If I want to help description of &lt;code&gt;#&lt;/code&gt; with &lt;code&gt;:h&lt;/code&gt; command, how to find it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h #&lt;/code&gt; seems to show another description which is about search.&lt;/p&gt;&#xA;" OwnerUserId="14057" LastActivityDate="2018-01-06T16:33:02.797" Title="What is the meaning of &quot;#&quot; in &quot;:g/pattern/z#.5&quot;" Tags="|ex-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14741" PostTypeId="2" ParentId="14740" CreationDate="2018-01-06T16:33:02.797" Score="1" Body="&lt;p&gt;in this context &lt;code&gt;z.5&lt;/code&gt; and &lt;code&gt;z#.5&lt;/code&gt; are identical.&#xA;You find the help under &lt;code&gt;:help :#&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-01-06T16:33:02.797" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14742" PostTypeId="2" ParentId="14668" CreationDate="2018-01-06T17:06:38.433" Score="1" Body="&lt;p&gt;In general, vim still doesn't handle anaconda environments nicely. I don't know if you open vim from the terminal, after you activate the environment, or not, so it's hard to tell what's going on, but I will tell you what I do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Neovim, and open it from the terminal after activating my environment.&#xA;Inside init.vim (==.vimrc) I use the variable &lt;code&gt;$CONDA_PREFIX&lt;/code&gt; to get to the environment directory. My pylint for example is set up like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let PYLINT = $CONDA_PREFIX&#xA;let PYLINT .= '/bin/pylint'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I use &lt;code&gt;PYLINT&lt;/code&gt; as the executable path for Neomake to run it on each save:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:neomake_python_mypylint_maker = {&#xA;    \ 'args': [&#xA;    \ '--output-format', 'text',&#xA;    \ '--reports', 'no',&#xA;    \ '--msg-template=&quot;{path}:{line}:{column}:{C}: [{symbol}] {msg}&quot;',&#xA;    \ '--rcfile=/home/abeka/workspace/pylint.cfg'&#xA;    \ ],&#xA;    \ 'errorformat':&#xA;    \ '%A%f:%l:%c:%t: %m,' .&#xA;    \ '%A%f:%l: %m,' .&#xA;    \ '%A%f:(%l): %m,' .&#xA;    \ '%-Z%p^%.%#,' .&#xA;    \ '%-G%.%#',&#xA;    \ 'exe': PYLINT,&#xA;    \ 'postprocess': function('neomake#makers#ft#python#PylintEntryProcess'),&#xA;\ }&#xA;&#xA;autocmd! BufWritePost ~/workspace/*/*.py Neomake mypylint&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope this gives you enough data to tweak your settings accordingly.&lt;/p&gt;&#xA;" OwnerUserId="3188" LastActivityDate="2018-01-06T17:06:38.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14743" PostTypeId="1" CreationDate="2018-01-07T01:26:08.283" Score="3" ViewCount="6529" Body="&lt;p&gt;Other than deleting the plugin directory in &lt;code&gt;/bundle/&lt;/code&gt; I have not been able to successfully uninstall a plugin. I found &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim/issues/733&quot; rel=&quot;nofollow noreferrer&quot;&gt;this issue&lt;/a&gt; and have tried removing the plugin from my &lt;code&gt;vimrc&lt;/code&gt;, running &lt;code&gt;:PluginInstall&lt;/code&gt;, &lt;code&gt;:PluginUpdate&lt;/code&gt;, and &lt;code&gt;:PluginClean&lt;/code&gt;, but I cannot seem to uninstall any of the plugins with &lt;code&gt;vundle&lt;/code&gt;.  This is my &lt;a href=&quot;https://github.com/robskrob/Dirty-Sprite-2&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim setup&lt;/a&gt;. Given my linked vim setup and the commands that I have tried to run, does anyone know what could be wrong? Has anyone ran into this problem before and solved it?&lt;/p&gt;&#xA;" OwnerUserId="15822" LastActivityDate="2019-07-25T01:34:59.457" Title="Cannot remove a plugin with Vundle" Tags="|plugin-vundle|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14744" PostTypeId="1" CreationDate="2018-01-07T09:09:11.073" Score="0" ViewCount="4238" Body="&lt;p&gt;I am a new user of vim and want to add a plugin SuperTab for autocompletion. I searched for the plugin from vimawesome and it says&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Place this in your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Plugin 'ervandew/supertab'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've created a .vimrc file in my home directory but I don't know which commands to use before and after adding &lt;code&gt;Plugin 'ervandew/supertab'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="15848" LastActivityDate="2018-01-08T00:31:53.060" Title="How to add Plugin in .vimrc file?" Tags="|vimrc|plugin-system|plugin-you-complete-me|" AnswerCount="1" CommentCount="0" ClosedDate="2018-01-08T08:04:41.290" ContentLicense="CC BY-SA 3.0" />
  <row Id="14746" PostTypeId="2" ParentId="14660" CreationDate="2018-01-07T18:55:56.747" Score="1" Body="&lt;p&gt;Just skimming the vim source code i found this section in &lt;code&gt;edit.c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /* Return value -2 means the user complete function wants to&#xA;     * cancel the complete without an error.&#xA;     * Return value -3 does the same as -2 and leaves CTRL-X mode.*/&#xA;    if (col == -2)&#xA;    return FAIL;&#xA;    if (col == -3)&#xA;    {&#xA;    ctrl_x_mode = 0;&#xA;    edit_submode = NULL;&#xA;    if (!shortmess(SHM_COMPLETIONMENU))&#xA;        msg_clr_cmdline();&#xA;    return FAIL;&#xA;    }&#xA;&#xA;    /*&#xA;     * Reset extended parameters of completion, when start new&#xA;     * completion.&#xA;     */&#xA;    compl_opt_refresh_always = FALSE;&#xA;&#xA;    if (col &amp;lt; 0)&#xA;    col = curs_col;&#xA;    compl_col = col;&#xA;    if (compl_col &amp;gt; curs_col)&#xA;    compl_col = curs_col;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when the completion function is called, the return values &lt;code&gt;-2&lt;/code&gt; and &lt;code&gt;-3&lt;/code&gt; are handled according to the documentation, but the case &lt;code&gt;-1&lt;/code&gt; is ignored on the first invoke and the value set to &lt;code&gt;curs_col&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="15718" LastActivityDate="2018-01-07T18:55:56.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14747" PostTypeId="1" CreationDate="2018-01-07T20:12:39.640" Score="0" ViewCount="192" Body="&lt;p&gt;If I have this directory: &lt;code&gt;/home/abc/def/apples/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I want to replace it with this directory: &lt;code&gt;/home/nfl/nfl/nba/&lt;/code&gt; in vim, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;what is the syntax? I tried using &lt;code&gt;%s/a/b/g&lt;/code&gt; but this command fails.&lt;/p&gt;&#xA;" OwnerUserId="15860" LastEditorUserId="51" LastEditDate="2018-01-07T20:55:10.933" LastActivityDate="2018-01-07T20:57:01.250" Title="What is the syntax if I want to replace one directory with another in vim given that I have '/' in it?" Tags="|substitute|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14748" PostTypeId="2" ParentId="14747" CreationDate="2018-01-07T20:57:01.250" Score="4" Body="&lt;p&gt;You can escape the &lt;code&gt;/&lt;/code&gt; with a backslash (&lt;code&gt;\&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\/path\/name/\/new\/path/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is usually okay if you have just one or two &lt;code&gt;/&lt;/code&gt;s, but it quickly becomes very unwieldy. A better option is to &lt;a href=&quot;https://vi.stackexchange.com/q/3156/51&quot;&gt;use a different delimiter&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s!/path/name!/new/path!g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2018-01-07T20:57:01.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14749" PostTypeId="2" ParentId="14744" CreationDate="2018-01-08T00:31:53.060" Score="-1" Body="&lt;p&gt;It all depends on your plugin manager. There is handful list of them&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/k-takata/minpac&quot; rel=&quot;nofollow noreferrer&quot;&gt;minpac&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vundle&lt;/a&gt; (I believe that this is the one in your description)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Shougo/dein.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dein&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can install it manually either using “old fashioned way” (aka copy content of all directories into respective directories in &lt;code&gt;.vim&lt;/code&gt;) or you can use built in package loader &lt;code&gt;:h pack-add&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="1259" LastActivityDate="2018-01-08T00:31:53.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14750" PostTypeId="2" ParentId="14739" CreationDate="2018-01-08T00:45:53.527" Score="2" Body="&lt;p&gt;There are 2 ways to achieve what you want.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;using &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:s_flags&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;c&lt;/code&gt; flag for &lt;code&gt;:s&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;searching for whatever text you want and then you can use &lt;code&gt;cgn&lt;/code&gt; to change next occurrence and then &lt;code&gt;.&lt;/code&gt; through rest of occurrences. The difference there is that with this solution you can use completion, the disadvantage is that this requires more recent Vim and sometimes can cause problems with recursive changes. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1259" LastActivityDate="2018-01-08T00:45:53.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14751" PostTypeId="1" AcceptedAnswerId="14758" CreationDate="2018-01-08T10:29:52.957" Score="0" ViewCount="104" Body="&lt;p&gt;It's a couple of month that I'm using &lt;strong&gt;Vim&lt;/strong&gt; and I'm happy with it. But working on big files &lt;em&gt;(About 2000 lines)&lt;/em&gt; is really annoying.&lt;br&gt;&#xA;I have some plugins and today I wanted to fix this problem. So I removed them and tested again, But oddly performance was the same!&lt;br&gt;&#xA;So I removed &lt;code&gt;.vimrc&lt;/code&gt; from &lt;code&gt;$HOME&lt;/code&gt; and saw it works fine &lt;em&gt;(I had &lt;code&gt;syntax:on&lt;/code&gt;, So not too fine)&lt;/em&gt;. Tested again with &lt;code&gt;vim -u NONE&lt;/code&gt; and it was great.&lt;br&gt;&#xA;But when I created an &lt;strong&gt;empty&lt;/strong&gt; &lt;code&gt;.vimrc&lt;/code&gt; in &lt;code&gt;$HOME&lt;/code&gt; and the slowing down problem came back!&lt;br&gt;&#xA;Currently I'm using &lt;code&gt;Fedora 27&lt;/code&gt; with &lt;code&gt;Vim 8.0.1427&lt;/code&gt;.&lt;br&gt;&#xA;I did some research but didn't find anything related to this problem. So if there is something I could do to fix this, I appreciate your help.&lt;/p&gt;&#xA;" OwnerUserId="15866" LastActivityDate="2018-01-09T11:54:31.450" Title="Vim Slowing down when creating .vimrc in $HOME" Tags="|vimrc|performance|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14753" PostTypeId="1" CreationDate="2018-01-08T22:33:38.733" Score="-1" ViewCount="3346" Body="&lt;p&gt;On my system vim has a &quot;defaults.vim&quot; file that is getting sourced. For example, if I do vim --version, I see the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that the defaults file has a bunch of annoying settings in it. How can I disable it? I had read elsewhere that as long as I had a ~/.vimrc file that the defaults file would not be loaded, but this is not true. I have a blank ~/.vimrc and defaults is still getting loaded. How can I prevent this?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2023-12-27T18:38:45.467" Title="How to disable defaults.vim?" Tags="|default-settings|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14755" PostTypeId="2" ParentId="14753" CreationDate="2018-01-09T03:40:36.663" Score="3" Body="&lt;p&gt;From &lt;code&gt;:h defaults.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If Vim is started normally and no user vimrc file is found, the&#xA;  $VIMRUTIME/defaults.vim script is loaded.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Perhaps an empty vimrc is the same as no vimrc...? Anyways, try this...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Near the start of &lt;code&gt;$VIMRUNTIME/defaults.vim&lt;/code&gt; you'll see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('skip_defaults_vim')&#xA;  finish&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So put something like this near the start of your &lt;em&gt;system&lt;/em&gt; vimrc and that should suppress it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let skip_defaults_vim=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use of this variable in the system vimrc is documented: &lt;code&gt;:h skip_defaults_vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-01-09T03:52:10.383" LastActivityDate="2018-01-09T03:52:10.383" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14756" PostTypeId="1" AcceptedAnswerId="14757" CreationDate="2018-01-09T09:51:54.817" Score="1" ViewCount="788" Body="&lt;p&gt;I want to automate something I started using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Short story is I have a file with some lines and I want to execute each line every now and then and see its' output, but I don't want it to override the contents of the buffer containing the commands. Instead, I rather store it in a new buffer/tab so that when I close everything nothing is stored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did something with mktemp, but I want to use vim's internal capabilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My workflow is currently as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;select the command I want to execute (example: &lt;code&gt;ping 8.8.8.8&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;execute &lt;code&gt;:tabnew | r! &amp;lt;YANKED TEXT&amp;gt;&lt;/code&gt; where I get &lt;code&gt;&amp;lt;YANKED TEXT&amp;gt;&lt;/code&gt; from using &lt;code&gt;ctrl+r&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Output is stored in a new tab, but I want to automate it, preferably using &lt;code&gt;vmap &amp;lt;somekey&amp;gt;&lt;/code&gt; somehow to be able to press a key to evaluate a command and see its' output in a new buffer/tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how to mimic what I currently do to a &lt;code&gt;vmap&lt;/code&gt; binding. I tried &lt;code&gt;vmap &amp;lt;F2&amp;gt; tabnew | r! @&quot;&lt;/code&gt; which failed (probably for some obvious reason).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nice to have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I don't want to use plugins for this, seems simple enough to accomplish.&lt;/li&gt;&#xA;&lt;li&gt;I don't want to write complex vimscripts.&lt;/li&gt;&#xA;&lt;li&gt;I want to understand each step.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Pointers to what to read to accomplish this would be great as well.&lt;/p&gt;&#xA;" OwnerUserId="7404" LastActivityDate="2018-01-09T15:48:55.943" Title="Execute selection and redirect output to new buffer/tab" Tags="|key-bindings|cut-copy-paste|external-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14757" PostTypeId="2" ParentId="14756" CreationDate="2018-01-09T10:05:24.093" Score="2" Body="&lt;h3&gt;Solution&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can achieve this with the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;F2&amp;gt; y:tabnew&amp;lt;CR&amp;gt;:r! &amp;lt;C-R&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This simply mimics the keystrokes that you were previously entering manually, including the presses of the &lt;kbd&gt;Enter&lt;/kbd&gt; key: &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;. (You should note therefore that, like your manual steps, this has the side-effect of setting the yank and unnamed registers to the yanked text.)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Why Your Command Didn't Work&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Your command was failing for a couple of reasons:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The bar character &lt;code&gt;|&lt;/code&gt; in your command is interpreted as ending the mapping, so the following &lt;code&gt;r! @&quot;&lt;/code&gt; is then run immediately as a separate command. An alternative solution is to use the &lt;code&gt;&amp;lt;Bar&amp;gt;&lt;/code&gt; stand in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;F2&amp;gt; y:tabnew &amp;lt;Bar&amp;gt; r! &amp;lt;C-R&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will create a mapping that actually uses a &lt;code&gt;|&lt;/code&gt; in the ex command that is run. (If the difference is unclear, try removing the final &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; from the end of the mapping and then invoke it.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can't use &lt;code&gt;@&lt;/code&gt; in that context. It doesn't expand into the contents of the register: instead the entire &lt;code&gt;@&quot;&lt;/code&gt; is passed to the shell as the command to run.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;Suggestion: Use &lt;code&gt;nore&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;As a side-note, it's generally better to use the non-recursive forms of the various map commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;F2&amp;gt; y:tabnew&amp;lt;CR&amp;gt;:r! ^R&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should only use the plain forms if you have a specific reason for doing so (which will be almost never.)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Further Reading&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The part of the documentation that explains all of the above is Chapter 40 of the user manual:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help usr_40&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-09T15:48:55.943" LastActivityDate="2018-01-09T15:48:55.943" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14758" PostTypeId="2" ParentId="14751" CreationDate="2018-01-09T11:54:31.450" Score="1" Body="&lt;p&gt;Note that in version 8 Vim started loading some default configuration when no &lt;code&gt;vimrc&lt;/code&gt; is found - &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#defaults%2evim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help defaults.vim&lt;/code&gt;&lt;/a&gt;. So you could try loading those defaults in your &lt;code&gt;vimrc&lt;/code&gt; (as explained on that help entry), and if it solves the problem you can comment it until you find the setting that you are missing.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2018-01-09T11:54:31.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14759" PostTypeId="1" AcceptedAnswerId="14760" CreationDate="2018-01-09T13:42:09.210" Score="1" ViewCount="507" Body="&lt;p&gt;This question is really two questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First question: Does vimscript support having interpolated strings as values in a dictionary?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second question: Is it possible to remap keys from within a loop? While items is an obvious choice (to me) for creating the loop, I'm open to other loops if they allow this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; attempted code:&#xA;let path_dict = {&#xA;  \'o.': './',&#xA;  \'o/': &quot;$p_root&quot;,&#xA;  \'oc': &quot;$p_css&quot;,&#xA;  \'oh': &quot;$p_html&quot;,&#xA;  \'oj': &quot;$p_js&quot;,&#xA;  \'ol': &quot;$p_learn&quot;,&#xA;  \}&#xA;&#xA;for [keybinding, filepath] in items(path_dict)&#xA;  nnoremap &amp;lt;Leader&amp;gt;keybinding :call Notrw(filepath)&amp;lt;CR&amp;gt;&#xA;endfor&#xA;&#xA;&quot; desired result:&#xA;&quot; nnoremap &amp;lt;Leader&amp;gt;o/ :call Notrw($p_root)&amp;lt;CR&amp;gt;&#xA;&quot; nnoremap &amp;lt;Leader&amp;gt;oh :call Notrw($p_html)&amp;lt;CR&amp;gt;&#xA;&quot; nnoremap &amp;lt;Leader&amp;gt;oc :call Notrw($p_css)&amp;lt;CR&amp;gt;&#xA;&quot; nnoremap &amp;lt;Leader&amp;gt;oj :call Notrw($p_js)&amp;lt;CR&amp;gt;&#xA;&quot; nnoremap &amp;lt;Leader&amp;gt;ol :call Notrw($p_learn)&amp;lt;CR&amp;gt;&#xA;&quot; nnoremap &amp;lt;Leader&amp;gt;o. :call Notrw('./')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15588" LastActivityDate="2018-01-09T15:20:19.360" Title="Remapping keybindings within items loop" Tags="|key-bindings|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14760" PostTypeId="2" ParentId="14759" CreationDate="2018-01-09T15:14:40.367" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Does vimscript support having interpolated strings as values in a dictionary?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, but you can have (nearly) arbitrary expressions within dictionary values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a = {&#xA;    \ 'goodbye': variable,&#xA;    \ 'world': $ENVVAR,&#xA;    \ 'hello': printf('%d', 10),&#xA;    \}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to remap keys from within a loop? While items is an obvious choice (to me) for creating the loop, I'm open to other loops if they allow this.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;execute&lt;/code&gt; it is possible to do anything in a loop.  Any command sequence which can be uttered in a script can be wrapped in a string and &lt;code&gt;execute&lt;/code&gt;d (possibly up to minor syntax changes).&#xA;For instance,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for [keybinding, filepath] in items(path_dict)&#xA;    execute 'nnoremap &amp;lt;Leader&amp;gt;'.keybinding ':call Notrw('.filepath.')'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that execute inserts spaces between successive arguments (such as between &lt;code&gt;keybinding&lt;/code&gt; and &lt;code&gt;':call&lt;/code&gt;).  To suppress this you must concatenate the strings using &lt;code&gt;.&lt;/code&gt;.  An alternative to concatenation is to use &lt;code&gt;printf&lt;/code&gt;.  Note that since &lt;code&gt;execute&lt;/code&gt; is effectively what is called &lt;code&gt;eval&lt;/code&gt; in other languages, standard string validation security warnings apply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two cases where vim allows true &quot;interpolation.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) In unix/linux (at least), and only in filename arguments, you may use backticks to supply filename(s) as a result of an external command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:next `find . -name ver\\*.c -print`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Escaping can be difficult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) In variable names only, you can use another variable (see &lt;code&gt;:h curly-braces-names&lt;/code&gt;) interpolated into the name.  For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_{adjective}_variable&#xA;echo my_{&amp;amp;background}_message&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;refer to the interpolated variable as you'd expect, e.g., &lt;code&gt;my_blue_variable&lt;/code&gt;, or &lt;code&gt;my_dark_message&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-01-09T15:20:19.360" LastActivityDate="2018-01-09T15:20:19.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14761" PostTypeId="1" AcceptedAnswerId="14762" CreationDate="2018-01-09T17:32:25.073" Score="2" ViewCount="97" Body="&lt;p&gt;We use a date format that appends the day at the end of the date like so: &lt;code&gt;20180109tu@1730&lt;/code&gt;. Is there any way to get the two letter day format?&lt;/p&gt;&#xA;" OwnerUserId="15876" LastEditorUserId="51" LastEditDate="2018-01-12T07:50:05.630" LastActivityDate="2018-01-12T07:50:05.833" Title="strftime format support two letter day option" Tags="|formatting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14762" PostTypeId="2" ParentId="14761" CreationDate="2018-01-09T18:00:24.923" Score="1" Body="&lt;p&gt;I've decided to make work-around where I just manually go back a few characters and reformat accordingly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;d &quot;=strftime(&quot;%Y%m%d%a&quot;)&amp;lt;CR&amp;gt;Pxh~&#xA;nnoremap &amp;lt;leader&amp;gt;D &quot;=strftime(&quot;%Y%m%d%a@%H%M%S&quot;)&amp;lt;CR&amp;gt;PF@hxhh~E&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15876" LastActivityDate="2018-01-09T18:00:24.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14763" PostTypeId="2" ParentId="104" CreationDate="2018-01-09T20:51:28.730" Score="9" Body="&lt;p&gt;You need to set your status line to be viewable and also set it to path.  I did so permanently by adding the two lines below to my ~/.vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set laststatus=2&#xA;set statusline+=%F&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to just run that once.  Then when VIing a document type &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set laststatus=2       &amp;lt;ENTER&amp;gt;&#xA;:set statusline+=%F     &amp;lt;ENTER&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15879" LastActivityDate="2018-01-09T20:51:28.730" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14764" PostTypeId="1" CreationDate="2018-01-09T22:30:51.020" Score="6" ViewCount="822" Body="&lt;p&gt;I'm trying to get &lt;code&gt;balloonevalterm&lt;/code&gt; to work in the terminal version of vim, but for some reason it does not yet work. Here's my &lt;code&gt;macros.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyBalloonExpr()&#xA;  let macros = {&#xA;  \ 'MACRO' : &quot;MACRO\ndo { something(); } while (0)&quot;,&#xA;  \ }&#xA;  return get(macros, v:beval_text, '')&#xA;endfunction&#xA;set bexpr=MyBalloonExpr()&#xA;set ballooneval&#xA;set balloonevalterm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I source this file with &lt;code&gt;:so %&lt;/code&gt; in gvim, all is fine: when I place the mouse pointer over &lt;code&gt;MACRO&lt;/code&gt; the balloon &lt;code&gt;MACRO  do { something(); } while (0)&lt;/code&gt; appears. Sweet!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I can't get the balloon to appear in the terminal version of vim, even though &lt;code&gt;set balloonevalterm&lt;/code&gt; should do so, according to my understanding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vim 8.0.1427 in an XTerm(330), &lt;code&gt;TERM=xterm-256color&lt;/code&gt; on FreeBSD and &lt;code&gt;:ver&lt;/code&gt; shows it is compiled with &lt;code&gt;+ballon_eval&lt;/code&gt; and &lt;code&gt;+balloon_eval_term&lt;/code&gt;. What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="2347" LastEditorUserId="2347" LastEditDate="2018-01-10T05:56:52.670" LastActivityDate="2018-05-29T20:16:16.323" Title="Getting balloonevalterm to work (terminal version)" Tags="|terminal|functions|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14766" PostTypeId="2" ParentId="104" CreationDate="2018-01-10T19:13:58.857" Score="9" Body="&lt;p&gt;The following will display the path &lt;em&gt;relative to your current directory&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:f[ile]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is &lt;code&gt;:f&lt;/code&gt; or &lt;code&gt;:file&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11896" LastEditorUserId="11896" LastEditDate="2019-11-06T17:26:17.473" LastActivityDate="2019-11-06T17:26:17.473" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="14767" PostTypeId="1" CreationDate="2018-01-11T00:13:47.050" Score="1" ViewCount="197" Body="&lt;p&gt;I know the title isn't all too descriptive but I don't have a better way to describe it. Whenever I open a file with &lt;code&gt;vim&lt;/code&gt; (but interestingly not &lt;code&gt;nvim&lt;/code&gt;), a bizarre sequence of characters shows under the cursor until I take my first action in the file, at which point it disappears, revealing the content that would ordinarily be there. Here are a couple pictures that show the issue better:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/HFsz2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HFsz2.png&quot; alt=&quot;vim when first opening file&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Hq8nr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Hq8nr.png&quot; alt=&quot;after first action&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15888" LastActivityDate="2018-01-11T00:13:47.050" Title="Weird sequence of characters temporarily when opening file" Tags="|startup|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14768" PostTypeId="1" AcceptedAnswerId="14770" CreationDate="2018-01-11T03:46:03.857" Score="3" ViewCount="65" Body="&lt;p&gt;For example: if my cursor is on &lt;code&gt;c&lt;/code&gt; in &lt;code&gt;abcde&lt;/code&gt; and I do &lt;code&gt;gUw&lt;/code&gt; then the result is &lt;code&gt;abCDE&lt;/code&gt; with the cursor on &lt;code&gt;C&lt;/code&gt;, while &lt;code&gt;gUb&lt;/code&gt; results in &lt;code&gt;ABcde&lt;/code&gt; with the cursor on &lt;code&gt;A&lt;/code&gt;. Is this the expected behaviour? It seems that these two should behave analogously, but they don't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I should add that I'm using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan 10 2018 11:27:58)&#xA;macOS version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15889" LastEditorUserId="15889" LastEditDate="2018-01-11T04:05:41.263" LastActivityDate="2018-01-11T07:45:22.727" Title="Why does gUw keep cursor in same position but gUb moves it to the start of the word?" Tags="|cursor-movement|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14770" PostTypeId="2" ParentId="14768" CreationDate="2018-01-11T07:45:22.727" Score="5" Body="&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#operator&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h operator&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;After applying the operator the cursor is mostly left at the start of the text&#xA;  that was operated upon.  For example, &quot;yfe&quot; doesn't move the cursor, but &quot;yFe&quot;&#xA;  moves the cursor leftwards to the &quot;e&quot; where the yank started.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You are experiencing the expected behavior: your cursor is put at the beginning of the text described by your motion.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-01-11T07:45:22.727" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14772" PostTypeId="1" CreationDate="2018-01-11T09:36:02.083" Score="-1" ViewCount="3475" Body="&lt;p&gt;Why my vim highlight some specific words? As showing in the following screenshot picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I locate my problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/c06j7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/c06j7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is my .vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible    &quot; be iMproved, required&#xA;filetype off    &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot; call vundle#begin('~/some/path/here')&#xA;&quot;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;&quot; The following are examples of different formats supported.&#xA;&quot; Keep Plugin commands between vundle#begin/end.&#xA;&#xA;&quot; expanding abbreviations similar to emmet&#xA;Plugin 'mattn/emmet-vim'&#xA;&#xA;&quot; tree explorer&#xA;Plugin 'scrooloose/nerdtree'&#xA;&#xA;&quot; auto completion&#xA;Plugin 'Valloric/YouCompleteMe'&#xA;&quot; git gateway plugin on GitHub repo&#xA;Plugin 'tpope/vim-fugitive'&#xA;&quot; vim autoformat from github&#xA;Plugin 'Chiel92/vim-autoformat'&#xA;&quot; simple color selector of vCoolor&#xA;Plugin 'KabbAmine/vCoolor.vim'&#xA;&quot; block comment&#xA;Plugin 'scrooloose/nerdcommenter'&#xA;&quot; syntastic check&#xA;&quot; Plugin 'scrooloose/syntastic'&#xA;&quot; All of your Plugins must be added before the following line&#xA;&#xA;&quot; fuzzy file, buffer, mru, tag, etc finder&#xA;Plugin 'ctrlpvim/ctrlp.vim'&#xA;&#xA;&quot; powerline vim&#xA;Plugin 'vim-airline/vim-airline'&#xA;&#xA;&quot; react, jsx&#xA;Plugin 'pangloss/vim-javascript'&#xA;Plugin 'mxw/vim-jsx'&#xA;&#xA;&quot; es6 syntax&#xA;Plugin 'othree/yajs.vim'&#xA;Plugin 'maxmellon/vim-jsx-pretty'&#xA;&#xA;&quot; vim syntastic&#xA;Plugin 'vim-syntastic/syntastic'&#xA;&#xA;&quot; eslint fix&#xA;Plugin 'ruanyl/vim-fixmyjs'&#xA;&#xA;&quot; vim jsbeautify&#xA;Plugin 'maksimr/vim-jsbeautify'&#xA;&#xA;Plugin 'millermedeiros/vim-esformatter'&#xA;&#xA;&quot; vim-vue syntax&#xA;&quot; Plugin 'posva/vim-vue'&#xA;&#xA;&quot; vim-misc&#xA;Plugin 'xolox/vim-misc'&#xA;&#xA;&quot; automated tag generation and syntax highlighting in vim&#xA;Plugin 'xolox/vim-easytags'&#xA;&#xA;&quot; an overview of the structure of source code&#xA;Plugin 'vim-scripts/taglist.vim'&#xA;&#xA;&quot; tern plugin for vim&#xA;Plugin 'ternjs/tern_for_vim'&#xA;&#xA;&quot; editorconfig&#xA;Plugin 'editorconfig/editorconfig-vim'&#xA;&#xA;&quot; vim json&#xA;Plugin 'leshill/vim-json'&#xA;&#xA;&quot; tagbar&#xA;Plugin 'majutsushi/tagbar'&#xA;&#xA;&quot; fzf&#xA;Plugin 'junegunn/fzf.vim'&#xA;&#xA;call vundle#end()   &quot;required&#xA;filetype plugin indent on&#xA;&#xA;execute pathogen#infect()&#xA;&#xA;&#xA;&quot; General setting&#xA;&quot;&#xA;&quot; Filetype Syntax&#xA;syntax on&#xA;filetype plugin indent on&#xA;filetype plugin on&#xA;&#xA;&quot; utf-8 support&#xA;set encoding=utf-8&#xA;&#xA;&quot; Tabs&#xA;set autoindent&#xA;set modeline&#xA;set expandtab&#xA;set shiftwidth=4&#xA;set softtabstop=4&#xA;&#xA;&quot; Mouse and appearance&#xA;set mouse=a&#xA;set mousehide&#xA;set number&#xA;set hlsearch&#xA;&#xA;&quot;Window&#xA;&quot; Normal Mode Key Bindings&#xA;nnoremap &amp;lt;C-k&amp;gt;  &amp;lt;C-w&amp;gt;k  &quot; Move along windows faster&#xA;nnoremap &amp;lt;C-j&amp;gt;  &amp;lt;C-w&amp;gt;j  &quot; Move along windows faster&#xA;nnoremap &amp;lt;C-h&amp;gt;  &amp;lt;C-w&amp;gt;h  &quot; Move along windows faster&#xA;nnoremap &amp;lt;C-l&amp;gt;  &amp;lt;C-w&amp;gt;l  &quot; Move along windows faster&#xA;&#xA;&quot; Line movement&#xA;&quot; nnoremap j  gj  &quot; Move along rows, not lines&#xA;&quot; nnoremap k  gk  &quot; Move along rows, not lines&#xA;&quot; nnoremap 0  g0  &quot; Move along rows, not lines&#xA;&quot; nnoremap $  g$  &quot; Useful for long lines&#xA;&#xA;syntax enable&#xA;&quot; set background=light&#xA;&quot; let g:solarized_termcolors=256&#xA;&quot; colorscheme solarized&#xA;&#xA;&#xA;nmap &amp;lt;F1&amp;gt; :set paste&amp;lt;CR&amp;gt;:r !pbpaste&amp;lt;CR&amp;gt;:set nopaste&amp;lt;CR&amp;gt;&#xA;imap &amp;lt;F1&amp;gt; &amp;lt;Esc&amp;gt;:set paste&amp;lt;CR&amp;gt;:r !pbpaste&amp;lt;CR&amp;gt;:set nopaste&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;F2&amp;gt; :.w !pbcopy&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;vmap &amp;lt;F2&amp;gt; :w !pbcopy&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&#xA;&#xA;if bufwinnr(1)&#xA;  map + &amp;lt;C-W&amp;gt;+&#xA;  map _ &amp;lt;C-W&amp;gt;-&#xA;  map = &amp;lt;C-W&amp;gt;&amp;gt;&#xA;  map - &amp;lt;C-W&amp;gt;&amp;lt;&#xA;endif&#xA;&#xA;&#xA;&quot; vim-thematic&#xA;let g:thematic#themes = {&#xA;\ 'bubblegum'  : {&#xA;\                },&#xA;\ 'jellybeans' : { 'laststatus': 0,&#xA;\                  'ruler': 1,&#xA;\                },&#xA;\ 'pencil_dark' :{'colorscheme': 'pencil',&#xA;\                 'background': 'dark',&#xA;\                 'airline-theme': 'badwolf',&#xA;\                 'ruler': 1,&#xA;\                },&#xA;\ 'pencil_lite' :{'colorscheme': 'pencil',&#xA;\                 'background': 'light',&#xA;\                 'airline-theme': 'light',&#xA;\                 'ruler': 1,&#xA;\                },&#xA;\ }&#xA;&#xA;&#xA;let g:thematic#defaults = {&#xA;\ 'airline-theme': 'jellybeans',&#xA;\ 'background': 'dark',&#xA;\ 'laststatus': 2,&#xA;\ }&#xA;&#xA;&quot; Plugins&#xA;autocmd FileType css set omnifunc=csscomplete#CompleteCSS&#xA;&#xA;&quot; mapleader&#xA;let mapleader = &quot;,&quot;&#xA;&#xA;&quot; vim-autoformat folders containing formatters&#xA;let g:autoformat_verbosemode=1&#xA;let verbose=1&#xA;let g:formatterpath = [ '/usr/local/bin/js-beautify', '/usr/local/bin/html-beautify', '/usr/local/bin/css-beautify']&#xA;noremap &amp;lt;F3&amp;gt; :Autoformat&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; YouCompleteMe go to definition&#xA;nnoremap &amp;lt;Leader&amp;gt;jd :YcmCompleter GoToDefinition&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; compile java&#xA;autocmd FileType java set makeprg=javac\ %&#xA;set errorformat=%A%f:%l:\ %m,%-Z%p^,%-C%.%#&#xA;map &amp;lt;Leader&amp;gt;r :make&amp;lt;Return&amp;gt;:copen&amp;lt;Return&amp;gt;&#xA;&#xA;&#xA;&quot; search only over a visual range&#xA;function! RangeSearch(direction)&#xA;  call inputsave()&#xA;  let g:srchstr = input(a:direction)&#xA;  call inputrestore()&#xA;  if strlen(g:srchstr) &amp;gt; 0&#xA;    let g:srchstr = g:srchstr.&#xA;          \ '\%&amp;gt;'.(line(&quot;'&amp;lt;&quot;)-1).'l'.&#xA;          \ '\%&amp;lt;'.(line(&quot;'&amp;gt;&quot;)+1).'l'&#xA;  else&#xA;    let g:srchstr = ''&#xA;  endif&#xA;endfunction&#xA;vnoremap &amp;lt;silent&amp;gt; / :&amp;lt;C-U&amp;gt;call RangeSearch('/')&amp;lt;CR&amp;gt;:if strlen(g:srchstr) &amp;gt; 0\|exec '/'.g:srchstr\|endif&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; ? :&amp;lt;C-U&amp;gt;call RangeSearch('?')&amp;lt;CR&amp;gt;:if strlen(g:srchstr) &amp;gt; 0\|exec '?'.g:srchstr\|endif&amp;lt;CR&amp;gt;&#xA;&#xA;&#xA;&quot; Automatic reloading of .vimrc&#xA;autocmd! bufwritepost .vimrc source %&#xA;&#xA;&quot; Better copy &amp;amp; paste&#xA;set pastetoggle=&amp;lt;F2&amp;gt;&#xA;set clipboard=unnamed&#xA;&#xA;&quot; Mouse and backspace&#xA;set mouse=a     &quot; on OSX press ALT and click&#xA;set bs=2    &quot; make backspace behave like normal again&#xA;&#xA;&quot; Rebind &amp;lt;leader&amp;gt; key&#xA;let mapleader=&quot;,&quot;&#xA;&#xA;&quot; Bind nohl&#xA;&quot; Removes highlight of your last search&#xA;noremap &amp;lt;C-n&amp;gt; :nohl&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;C-n&amp;gt; :nohl&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;C-n&amp;gt; :nohl&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Quicksave command&#xA;&quot; ? can't work&#xA;noremap &amp;lt;C-s&amp;gt; :w&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;C-s&amp;gt; &amp;lt;C-c&amp;gt; :update&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;C-s&amp;gt; &amp;lt;C-o&amp;gt;:update&amp;lt;CR&amp;gt;&#xA;&#xA;&#xA;&quot; Quick quit command&#xA;noremap &amp;lt;leader&amp;gt;e :quit&amp;lt;CR&amp;gt; &quot; Quit current window&#xA;noremap &amp;lt;leader&amp;gt;E :qa!&amp;lt;CR&amp;gt;  &quot; Quit all windows&#xA;&#xA;&quot; bind Ctrl+&amp;lt;movement&amp;gt; keys to move around the windows&#xA;map &amp;lt;c-j&amp;gt; &amp;lt;c-w&amp;gt;j&#xA;map &amp;lt;c-k&amp;gt; &amp;lt;c-w&amp;gt;k&#xA;map &amp;lt;c-l&amp;gt; &amp;lt;c-w&amp;gt;l&#xA;map &amp;lt;c-h&amp;gt; &amp;lt;c-w&amp;gt;h&#xA;&#xA;&quot; easier moving between tabs&#xA;nnoremap &amp;lt;C-tab&amp;gt;    :tabnext&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-t&amp;gt;  :tabnew&amp;lt;CR&amp;gt;&#xA;map &amp;lt;leader&amp;gt;n :tabprevious&amp;lt;CR&amp;gt;&#xA;map &amp;lt;leader&amp;gt;m :tabnext&amp;lt;CR&amp;gt;&#xA;&#xA;&#xA;&quot; map sort function to a key&#xA;vnoremap &amp;lt;Leader&amp;gt;s :sort&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; easier moving of code blocks&#xA;vnoremap &amp;lt; &amp;lt;gv  &quot; better indentation&#xA;vnoremap &amp;gt; &amp;gt;gv  &quot; better indentation&#xA;&#xA;&quot; Color scheme&#xA;&quot; ? how does it work&#xA;&quot;set t_Co=256&#xA;&quot;color wombat256mod&#xA;&#xA;&quot; Disable stupid backup and swap files - they trigger too many eventes&#xA;&quot; for file system watchers&#xA;set nobackup&#xA;set nowritebackup&#xA;set noswapfile&#xA;&#xA;&quot; virtualenv support&#xA;py &amp;lt;&amp;lt; EOF&#xA;import os&#xA;import sys&#xA;if 'VIRTUAL_ENV' in os.environ:&#xA;  project_base_dir = os.environ['VIRTUAL_ENV']&#xA;  activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')&#xA;  execfile(activate_this, dict(__file__=activate_this))&#xA;&#xA;EOF&#xA;&#xA;&quot; python syntax checking/highlighting&#xA;let python_highlight_all=1&#xA;&#xA;&#xA;&quot; scrooloose/syntastic settings&#xA;&quot;set statusline+=%#warningmsg#&#xA;&quot;set statusline+=%{SyntasticStatuslineFlag()}&#xA;&quot;set statusline+=%*&#xA;&#xA;&quot;let g:syntastic_always_populate_loc_list = 1&#xA;&quot;let g:syntastic_auto_loc_list = 1&#xA;&quot;let g:syntastic_check_on_open = 1&#xA;&quot;let g:syntastic_check_on_wq = 0&#xA;&#xA;&#xA;&quot; YouCompleteMe config&#xA;let g:ycm_python_binary_path = 'python3'&#xA;&#xA;&#xA;&quot; open all folds&#xA;set foldlevel=99&#xA;&#xA;&quot; move to previous window&#xA;nmap &amp;lt;Leader&amp;gt;p :&amp;lt;c-w&amp;gt;&amp;lt;c-p&amp;gt;&#xA;&#xA;&quot; toggle nerdtree&#xA;nmap &amp;lt;Leader&amp;gt;a :NERDTreeToggle&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; autoreflesh nerdtree&#xA;&quot;autocmd BufWritePost * NERDTreeFocus | execute 'normal R' | wincmd p&#xA;&#xA;&#xA;&quot; reload all buffer&#xA;nmap &amp;lt;leader&amp;gt;z :bufdo e&amp;lt;cr&amp;gt;&#xA;&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot; =&amp;gt; CTRL-P&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot;let g:ctrlp_map = '&amp;lt;c-p&amp;gt;'&#xA;&quot;let g:ctrlp_cmd = 'CtrlP'&#xA;&quot;let g:ctrlp_by_filename = 1&#xA;&quot;let g:ctrlp_regexp = 1&#xA;&quot;let g:ctrlp_match_window = 'bottom, order:ttb, min:1, max:20, results:10'&#xA;&quot;let g:ctrlp_switch_buffer = 'Et'&#xA;&quot;let g:ctrlp_reuse_window = 'netrw'&#xA;&quot;let g:ctrlp_tabpage_position = 'ac'&#xA;&quot;set wildignore+=*/tmp/*,*.so,*.swp,*.zip&#xA;&quot;let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git\|dist\|target'&#xA;&quot;&quot;let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'&#xA;&quot;&quot;let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist)|(\.(swp|ico|git|svn))$'&#xA;&quot;&quot;let g:ctrlp_custom_ignore = {&#xA;  &quot;&quot;\ 'dir':  '\v[\/]\.(git|hg|svn)$',&#xA;  &quot;&quot;\ 'file': '\v\.(exe|so|dll)$',&#xA;  &quot;&quot;\ 'link': 'some_bad_symbolic_links',&#xA;  &quot;&quot;\ }&#xA;&quot;let g:ctrlp_working_path_mode = 'ra'&#xA;&#xA;&quot;&quot;let g:ctrlp_user_command = 'find %s -type f'        &quot; MacOSX/Linux&#xA;&quot;&quot;let g:ctrlp_user_command = ['.git']&#xA;&quot;map ff :CtrlPMixed&amp;lt;cr&amp;gt;&#xA;&#xA;&quot;&quot;&quot; ctrlp&#xA;   let g:ctrlp_use_caching = 1&#xA;   let g:ctrlp_clear_cache_on_exit = 0&#xA;   let g:ctrlp_cache_dir = '$HOME/.vim/cache/ctrlp'&#xA;   let g:ctrlp_max_files = 1000&#xA;   let g:ctrlp_max_history = &amp;amp;history&#xA;   let g:ctrlp_max_depth = 10&#xA;   let g:ctrlp_user_command = [&#xA;         \ '.git', 'cd %s &amp;amp;&amp;amp; git ls-files . -co --exclude-standard',&#xA;         \ 'rg %s --files --color=never --glob &quot;&quot;',&#xA;         \ 'find %s -type f'&#xA;         \ ]&#xA;   let g:ctrlp_custom_ignore = {&#xA;     \ 'dir': '\.git\|dist$',&#xA;     \ 'file': '\v\.(exe|so|dll)$',&#xA;   \ }&#xA;   &quot;let g:ctrlp_custom_ignore = 'dist'&#xA;   &quot; let g:ctrlp_user_command = ['rg --files']&#xA;   let g:ctrlp_working_path_mode = 'ra'&#xA;   let g:ctrlp_reuse_window = 'startify'&#xA;map ff :CtrlP&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; powerline vim setup&#xA;let g:airline_powerline_fonts = 1&#xA;&#xA;&quot; react jsx&#xA;let g:jsx_ext_required = 0&#xA;&#xA;&quot; change line&#xA;map &amp;lt;leader&amp;gt;i &amp;lt;ESC&amp;gt;i&amp;lt;CR&amp;gt;&amp;lt;ESC&amp;gt;&#xA;&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot; Plugins setup&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&#xA;&quot; vim-syntastic/syntastic&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;&#xA;&quot; eslint fixmyjs&#xA;let g:fixmyjs_rc_filename = '.eslintrc.js'&#xA;noremap &amp;lt;Leader&amp;gt;f :Fixmyjs&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; will run esformatter after pressing &amp;lt;leader&amp;gt; followed by the 'e' and 's' keys&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;es :Esformatter&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;es :EsformatterVisual&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;vim-jsx-pretty&#xA;let g:vim_jsx_pretty_enable_jsx_highlight = 1&#xA;let g:vim_jsx_pretty_colorful_config = 0&#xA;&#xA;&#xA;&quot;&#xA;&quot; General Rules&#xA;&quot;&#xA;&#xA;&quot; Searching with smart case&#xA;set ignorecase&#xA;set smartcase&#xA;&#xA;&quot; jump from, eg, a &amp;lt;div&amp;gt; to its &amp;lt;/div&amp;gt;&#xA;runtime macros/matchit.vim&#xA;&#xA;&#xA;&quot; jsbeautify&#xA;map &amp;lt;leader&amp;gt;b :call JsBeautify()&amp;lt;cr&amp;gt;&#xA;&quot; or&#xA;autocmd FileType javascript noremap &amp;lt;buffer&amp;gt;  &amp;lt;leader&amp;gt;b :call JsBeautify()&amp;lt;cr&amp;gt;&#xA;&quot; for json&#xA;autocmd FileType json noremap &amp;lt;buffer&amp;gt; &amp;lt;leader&amp;gt;b :call JsonBeautify()&amp;lt;cr&amp;gt;&#xA;&quot; for jsx&#xA;autocmd FileType jsx noremap &amp;lt;buffer&amp;gt; &amp;lt;leader&amp;gt;b :call JsxBeautify()&amp;lt;cr&amp;gt;&#xA;&quot; for html&#xA;autocmd FileType html noremap &amp;lt;buffer&amp;gt; &amp;lt;leader&amp;gt;b :call HtmlBeautify()&amp;lt;cr&amp;gt;&#xA;&quot; for css or scss&#xA;autocmd FileType css noremap &amp;lt;buffer&amp;gt; &amp;lt;leader&amp;gt;b :call CSSBeautify()&amp;lt;cr&amp;gt;&#xA;&#xA;&#xA;&quot; vue file syntax highlight&#xA;&quot; au BufReadPost *.vue set syntax=html&#xA;&#xA;&#xA;&quot; set html file tab convert to spaces&#xA;autocmd FileType html setlocal shiftwidth=4 softtabstop=4 expandtab&#xA;&#xA;&quot; set js file tab convert to spaces&#xA;autocmd FileType javascript setlocal shiftwidth=4 softtabstop=4 expandtab&#xA;&#xA;&quot; posva/vim-vue syntax highlighting stops working randomly&#xA;&quot; autocmd FileType vue syntax sync fromstart&#xA;&#xA;&quot; vim-taglist set&#xA;let Tlist_Ctags_Cmd = '/usr/local/bin/ctags'&#xA;&#xA;&quot; Tern settings&#xA;let g:tern_show_argument_hints='on_hold'&#xA;let g:tern_map_keys=1&#xA;&#xA;&quot; File navigation&#xA;set wildmenu&#xA;set wildmode=list:full&#xA;&#xA;&quot; foldmethod&#xA;&quot;setlocal foldmethod=indent&#xA;&#xA;&quot; opening in a new tab under cursor file&#xA;nnoremap gf &amp;lt;C-W&amp;gt;gf&#xA;vnoremap gf &amp;lt;C-W&amp;gt;gf&#xA;&#xA;&quot; syntax maximum column&#xA;set synmaxcol=1200&#xA;&#xA;inoremap jk &amp;lt;ESC&amp;gt;&#xA;&#xA;&quot; vim grep under cursor&#xA;&quot; opens search results in a window w/ links and highlight the matches&#xA;command! -nargs=+ Grep execute 'grep! -I -r -n -e &amp;lt;args&amp;gt; ./src ./build' | copen&#xA;&quot; shift-control-* Greps for the word under the cursor&#xA;:nmap &amp;lt;leader&amp;gt;g :Grep &amp;lt;c-r&amp;gt;=expand(&quot;&amp;lt;cword&amp;gt;&quot;)&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; tagbar&#xA;&quot; nmap &amp;lt;leader&amp;gt;tbt: TagbarToggle&amp;lt;CR&amp;gt;&#xA;&quot; Let Vim walk up directory hierarchy from CWD to root looking for tags file&#xA;set tags=tags;/&#xA;&quot; Tell EasyTags to use the tags file found by Vim&#xA;let g:easytags_dynamic_files = 1&#xA;&#xA;&quot; If installed using Homebrew&#xA;set rtp+=/usr/local/opt/fzf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8364" LastActivityDate="2018-01-11T11:10:46.963" Title="Why vim highlight some specific words?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ClosedDate="2018-01-11T17:07:56.037" ContentLicense="CC BY-SA 3.0" />
  <row Id="14773" PostTypeId="2" ParentId="14772" CreationDate="2018-01-11T11:10:46.963" Score="5" Body="&lt;p&gt;I doubt anyone here is going to the trouble of reading all of your configurations and plugins, setting-up an environment to reproduce the problem and investigate it further.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it is easy for you to debug it yourself, by following the procedure described on &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq-2.5&quot; rel=&quot;noreferrer&quot;&gt;Vim-FAQ  2.5&lt;/a&gt;; here is part of it:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2.5. I have a &quot;xyz&quot; (some) problem with Vim. How do I determine it is a&#xA;       problem with my setup or with Vim?  / Have I found a bug in Vim?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;First, you need to find out, whether the error is in the actual&#xA;  runtime files or any plugin that is distributed with Vim or whether it&#xA;  is a simple side effect of any configuration option from your .vimrc&#xA;  or .gvimrc. So first, start vim like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;this starts Vim in nocompatible mode (-N), without reading your&#xA;  viminfo file (-i NONE), without reading any configuration file (-u&#xA;  NONE for not reading .vimrc file and -U NONE for not reading a .gvimrc&#xA;  file) or even plugin.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If the error does not occur when starting Vim this way, then the&#xA;  problem is either related to some plugin of yours or some setting in&#xA;  one of your local setup files. You need to find out, what triggers the&#xA;  error, you try starting Vim this way: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;If the error occurs, the problem is your .viminfo file. Simply delete&#xA;  the viminfo file then. If the error does not occur, try: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u ~/.vimrc --noplugin -N -i NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This will simply use your .vimrc as configuration file, but not load&#xA;  any plugins. If the error occurs this time, the error is possibly&#xA;  caused by some configuration option inside your .vimrc file. Depending&#xA;  on the length of your vimrc file, it can be quite hard to trace the&#xA;  origin within that file.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The best way is to add :finish command in the middle of your .vimrc.&#xA;  Then restart again using the same command line. If the error still&#xA;  occurs, the bug must be caused because of a setting in the first half&#xA;  of your .vimrc. If it doesn't happen, the problematic setting must be&#xA;  in the second half of your .vimrc. So move the :finish command to the&#xA;  middle of that half, of which you know that triggers the error and&#xA;  move your way along, until you find the problematic option. If your&#xA;  .vimrc is 350 lines long, you need at a maximum 9 tries to find the&#xA;  offending line (in practise, this can often be further reduced, since&#xA;  often lines depend on each other).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If the problem does not occur, when only loading your .vimrc file, the&#xA;  error must be caused by a plugin or another runtime file (indent&#xA;  autoload or syntax script). Check the output of the :scriptnames&#xA;  command to see what files have been loaded and for each one try to&#xA;  disable each one by one and see which one triggers the bug. Often&#xA;  files that are loaded by vim, have a simple configuration variable to&#xA;  disable them, but you need to check inside each file separately.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2018-01-11T11:10:46.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14774" PostTypeId="1" AcceptedAnswerId="14776" CreationDate="2018-01-11T15:42:41.787" Score="1" ViewCount="140" Body="&lt;p&gt;When searching for something in vim or gvim, I use the &lt;code&gt;/&lt;/code&gt;. If I make a type and press enter, I need to type the string in again, hopefully a second time without a typo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to configure vim to have a recently searched list so I can &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;-key something? If not, how do you handle typos when searching?&lt;/p&gt;&#xA;" OwnerUserId="2475" LastActivityDate="2018-01-11T15:59:39.697" Title="don't retype search" Tags="|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14775" PostTypeId="2" ParentId="14774" CreationDate="2018-01-11T15:49:37.933" Score="1" Body="&lt;p&gt;Vim already has a recently searched list. You can use the up and down arrows to cycle through your search (or command) history.&lt;/p&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2018-01-11T15:49:37.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14776" PostTypeId="2" ParentId="14774" CreationDate="2018-01-11T15:50:29.753" Score="5" Body="&lt;p&gt;Use &lt;code&gt;q/&lt;/code&gt; to open the command-line window with the previous search history. As a bonus you can use your standard vim editing maps. For more help see &lt;code&gt;:h q/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related &lt;a href=&quot;http://vimcasts.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimcasts&lt;/a&gt; episode: &lt;a href=&quot;http://vimcasts.org/episodes/refining-search-patterns-with-the-command-line-window/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Refining search patterns with the command-line window&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;/&lt;/code&gt; then use the up arrow (similar to bash) to bring up the previous search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To help with typo's consider turning on &lt;code&gt;'incsearch'&lt;/code&gt; to show the current match. You can add the following to your &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set incsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h 'incsearch'&lt;/code&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also be interested in &lt;a href=&quot;https://github.com/xtal8/traces.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;traces.vim&lt;/a&gt; if you want highlighting for &lt;code&gt;:substitute&lt;/code&gt; and ranges.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-01-11T15:59:39.697" LastActivityDate="2018-01-11T15:59:39.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14777" PostTypeId="1" AcceptedAnswerId="14779" CreationDate="2018-01-11T21:54:12.857" Score="2" ViewCount="83" Body="&lt;p&gt;I have something like the following text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;( parens ) ( 1 + growth )   (1+growth)   (1 +growth) ( parens )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'd like replace every instance of &lt;code&gt;( 1 + growth )&lt;/code&gt;, regardless of whitespace,  with say, &lt;code&gt;growthFun&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The nongreedy search command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/(.\{-}1.\{-}+.\{-}growth.\{-})/s//growthFun/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;almost works, i.e., it locates the second and third instances, but the first time around it grabs   &lt;code&gt;( parens ) ( 1 + growth )&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is puzzling since it does &lt;em&gt;not&lt;/em&gt; do the same thing at the end of the line, i.e., it does not grab  &lt;code&gt;(1 +growth) ( parens )&lt;/code&gt; the third time around.      Could somebody please explain why the difference, and then how to avoid the first incorrect grab?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A closely related question is:    the nongreedy construction &lt;code&gt;.\{-}&lt;/code&gt; must be the most horrible, unnatural things the &lt;code&gt;vi&lt;/code&gt; inventors every invented.    Is there a way to alias it in &lt;code&gt;.vimrc&lt;/code&gt; so that, for example, typing&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:g/( ;ng 1 ;ng etc )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;would expand to &lt;/p&gt;&#xA;&#xA;&lt;p&gt;:g/( .\{-}  1 .\{-}  etc )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any advice!&lt;/p&gt;&#xA;" OwnerUserId="4667" LastActivityDate="2018-01-12T04:23:26.190" Title="search nongreedily for a bunch of terms delimited by parentheses" Tags="|search|replace|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14779" PostTypeId="2" ParentId="14777" CreationDate="2018-01-11T23:15:04.190" Score="4" Body="&lt;p&gt;Rather than searching for as few of any character as possible, change it to search for as many white space characters as possible.  This can be done by replacing &lt;code&gt;.\{-}&lt;/code&gt; with &lt;code&gt;\s*&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would simplify (at least I think it's simpler) further with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/(\s*1\s*+\s*growth\s*)/growthFun/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, take a look at &lt;code&gt;:help character-classes&lt;/code&gt;.  There are a lot of really useful character classes that can be used to match only certain types of characters, such as only digits or only lower case letters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;It occurs to me that I didn't necessarily answer your questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason you are seeing a difference in behavior is because the end of your pattern is &lt;code&gt;growth.\{-})&lt;/code&gt; and &lt;code&gt;\{-}&lt;/code&gt; finds 0 or more of the previous atom, but as few as possible.  So, this is basically saying &quot;Find &lt;code&gt;growth&lt;/code&gt;, then find a &lt;code&gt;)&lt;/code&gt; and do it in as few characters as you can&quot;.  Since there is a &lt;code&gt;)&lt;/code&gt; immediately after the last &lt;code&gt;growth&lt;/code&gt;, it doesn't have to go very far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, the beginning of your pattern is &lt;code&gt;(.\{-}1&lt;/code&gt; which similarly says &quot;Find a &lt;code&gt;(&lt;/code&gt; and a &lt;code&gt;1&lt;/code&gt; and do it in as few characters as you can&quot;.  Since a &lt;code&gt;1&lt;/code&gt; doesn't appear within the first group of parentheses, it has to continue until the second group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not aware of any way to alias the &lt;code&gt;.\{-}&lt;/code&gt;.  I also found this syntax rather awkward at first, but it seems to make a bit more sense when you realize that you can use numbers inside the curly braces to specify exactly how many to match (or even a range of how many to match).  For example, you can do &lt;code&gt;\{6}&lt;/code&gt; to find exactly 6 of the previous atom or &lt;code&gt;\{2,6}&lt;/code&gt; to find 2 to 6 of them.  Adding a &lt;code&gt;-&lt;/code&gt; such as &lt;code&gt;\{-6}&lt;/code&gt; means to find up to 6, but as few as possible.  Leave out the number (i.e. &lt;code&gt;\{-}&lt;/code&gt;) and you're just saying &quot;find as few as possible&quot;.  &lt;code&gt;:help pattern-multi-items&lt;/code&gt; has a bunch more information about this.&lt;/p&gt;&#xA;" OwnerUserId="1115" LastEditorUserId="1115" LastEditDate="2018-01-12T00:36:11.143" LastActivityDate="2018-01-12T00:36:11.143" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14780" PostTypeId="2" ParentId="14777" CreationDate="2018-01-11T23:52:25.067" Score="5" Body="&lt;p&gt;&lt;strong&gt;Replace non-new line character with the space character or non-parenthesis&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we examine the start of your match expression, &lt;code&gt;(.\{-}1&lt;/code&gt;, we see that we can find a quick match which finds the minimum number of non-newline characters until the first &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the results of this match, &lt;code&gt;/(.\{-}1&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NPU6n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NPU6n.png&quot; alt=&quot;(.{-}1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This behavior you are seeing is expected behavior. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I like the idea of going after a space character, &lt;code&gt;\s&lt;/code&gt;, or a non-parenthesis character class for our atom which we are trying to find a non-greedy match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/(\s\{-}1\s\{-}+\s\{-}growth\s\{-})/s//growthFun/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are the results:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3KUB7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3KUB7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my  non-parenthesis character class command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/([^()]\{-}1[^()]\{-}+[^()]\{-}growth[^()]\{-})/s//growthFun/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are the results for non-parenthesis character class:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kB9Du.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kB9Du.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With your second question, I personally like the syntax for quantifiers.  Perhaps someone else has some ideas on this.&lt;/p&gt;&#xA;" OwnerUserId="2679" LastEditorUserId="2679" LastEditDate="2018-01-12T04:23:26.190" LastActivityDate="2018-01-12T04:23:26.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14782" PostTypeId="1" CreationDate="2018-01-12T04:28:52.420" Score="0" ViewCount="135" Body="&lt;p&gt;How can I search and replace &lt;code&gt;array[j]&lt;/code&gt; by &lt;code&gt;array&lt;/code&gt; in the whole script?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;:%s/array[j]/array/&lt;/code&gt; but that does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="15895" LastEditorUserId="1841" LastEditDate="2018-01-12T08:03:21.207" LastActivityDate="2018-01-12T08:03:21.207" Title="Special search and replace" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14783" PostTypeId="2" ParentId="14782" CreationDate="2018-01-12T06:01:08.960" Score="2" Body="&lt;p&gt;You need to escape the brackets, as they are special characters used to indicate a list in a substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your command should be &lt;code&gt;:%s/array\[j\]/array/g&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2018-01-12T06:01:08.960" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14785" PostTypeId="1" CreationDate="2018-01-12T09:24:25.447" Score="8" ViewCount="2074" Body="&lt;p&gt;As a developer who grew up on hardware with no &lt;a href=&quot;https://en.wikipedia.org/wiki/Memory_management_unit&quot; rel=&quot;noreferrer&quot;&gt;MMU&lt;/a&gt; I have a habit of saving my work often, usually after every insert. Thus, when presented with the recovery dialogue after a crash or disconnect there is a very high probability that there were no unsaved changes and that the swapfile is identical to the saved file. I would like to reduce the friction between me and vim when trying to open files in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a recent example from the message shown to me when I edit a file after an unclean shutdown:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E325: ATTENTION&#xA;Found a swap file by the name &quot;~/.vim/swapfiles/algorithm_params.h.swp&quot;&#xA;          owned by: ana   dated: Thu Jan 11 16:09:00 2018&#xA;         file name: ~ana/src/algorithm_params.h&#xA;          modified: no&#xA;         user name: ana   host name: anavirt&#xA;        process ID: 8932&#xA;While opening file &quot;src/algorithm_params.h&quot;&#xA;             dated: Thu Jan 11 16:08:55 2018&#xA;&#xA;(1) Another program may be editing the same file.  If this is the case,&#xA;    be careful not to end up with two different instances of the same&#xA;    file when making changes.  Quit, or continue with caution.&#xA;(2) An edit session for this file crashed.&#xA;    If this is the case, use &quot;:recover&quot; or &quot;vim -r src/algorithm_params.h&quot;&#xA;    to recover the changes (see &quot;:help recovery&quot;).&#xA;    If you did this already, delete the swap file &quot;/home/ana/.vim/swapfiles/algorithm_params.h.swp&quot;&#xA;    to avoid this message.&#xA;&#xA;Swap file &quot;~/.vim/swapfiles/algorithm_params.h.swp&quot; already exists!&#xA;[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideally, I don't even want to &lt;em&gt;see&lt;/em&gt; this dialogue. From what I understand, vim has the information necessary, but I may be wrong on these:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;modified: no&lt;/code&gt; means that it knows that the swap file is identical to the saved file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;process ID: 8932&lt;/code&gt; means that the process used to generate this file is no longer running, otherwise it would say &lt;em&gt;(still running)&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is there any way to tell vim to just delete the swapfile and edit the main file without even asking, if these two conditions are met, and otherwise pop up this dialogue as usual?&lt;/p&gt;&#xA;" OwnerUserId="6389" LastActivityDate="2018-01-12T18:02:25.013" Title="Automatically delete swap file if it matches the saved file" Tags="|swap-file|crash-recovery|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14786" PostTypeId="1" AcceptedAnswerId="14790" CreationDate="2018-01-12T13:33:33.923" Score="1" ViewCount="262" Body="&lt;p&gt;I know it's weird and I don't know if it's possible but it would be great to have the name of the command I run in the terminal emulator when I use bash or zsh.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment, to launch a new terminal, I do something like &lt;code&gt;:term zsh&lt;/code&gt; so the buffer is named &lt;code&gt;term://.//26149:zsh&lt;/code&gt;. Now, I launch a long running command like &lt;code&gt;docker-compose up app&lt;/code&gt;. I want the buffer to be renamed to something like &lt;code&gt;term://.//docker-compose up app&lt;/code&gt;. I can do it manually by using &lt;code&gt;:file&lt;/code&gt; but is there a way to do it automatically?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main goal is to access it very fast by doing &lt;code&gt;:b docker&lt;/code&gt;. If you have other tips to do that, I'm open to suggestions.&lt;/p&gt;&#xA;" OwnerUserId="15669" LastActivityDate="2018-01-12T18:54:41.447" Title="Name the buffer with the current command that runs in the term emulator" Tags="|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14787" PostTypeId="1" AcceptedAnswerId="14788" CreationDate="2018-01-12T14:16:55.677" Score="5" ViewCount="447" Body="&lt;p&gt;The root of my question is about a difference between the way Vim processes multiple substitutions and they way other editors (Sublime, for example) do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;thing1&#xA;thing2&#xA;thing3&#xA;thing4&#xA;thing5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to perform this substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v^(.*)$\n?/'\1',/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Sublime, performing a &quot;Replace All&quot; with that regex &amp;amp; replacement results in what I intended:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'thing1','thing2','thing3','thing4','thing5',&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Vim, though, I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'thing1',thing2&#xA;'thing3',thing4&#xA;'thing5',&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adding a &lt;code&gt;c&lt;/code&gt; flag seems to explain this behavior:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QHuWQ.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QHuWQ.gif&quot; alt=&quot;Incremental substitution&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim seems to be processing each substitution one at a time, which then causes the next line not to match, because it's no longer at the start of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Removing &lt;code&gt;^&lt;/code&gt; from the regex makes it work as expected, but is there another way? Is there any way to make Vim's substitution behave more like other editors' -- i.e. identifying all matches, then replacing them &lt;em&gt;all&lt;/em&gt; regardless of how they're changed by earlier substitutions?&lt;/p&gt;&#xA;" OwnerUserId="15904" LastActivityDate="2018-01-12T17:57:32.907" Title="Can vim perform all substitutions simultaneously?" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14788" PostTypeId="2" ParentId="14787" CreationDate="2018-01-12T15:05:00.950" Score="6" Body="&lt;h3&gt;What is going on? Why does Vim behave this way vs Sublime Text?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I do not know Vim's internals (open source) and I do not know Sublime Text's internals (closed source) either, but we can guess what is going on here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From your example we see that vim does substitutions iteratively. Therefore, the &lt;code&gt;^&lt;/code&gt; does not match for next piece of text after a single substitution. Sublime Text on the other hand seems to do all the matching up front and then does all the substitutions. It is a subtle but slight difference. Normally it doesn't matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the next question is why does Vim behave this way? My guess this behavior is an optimization. My proof would be creating a file with the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaaaaab&#xA;aaaaaacaaaaaab&#xA;aaaaaadaaaaaab&#xA;aaaaaab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now duplicate those lines a large amount like 10,000 times (total of 40,000 lines). Now do the following substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/a*b/foo/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What happens?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim handles it like a champ. It is fast!. Although a little slower with &lt;code&gt;set regexengine=1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sublime Text stalls for quite some time then finally does the replacement. If you increase the number of &lt;code&gt;a&lt;/code&gt;'s then eventually you can make Sublime Text stall by just typing in the &quot;Find What&quot; portion of the text, not even getting to the &quot;Replace With&quot; field yet?!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I tested this with Sublime Text 2 and Vim 8&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Can Vim work like Sublime Text?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I do not know of any native way to change this behavior. You may be able to create your own version of &lt;code&gt;:substitute&lt;/code&gt; which does the initial matching first and then the substitution.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Conclusion&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Both Vim and Sublime Text use different regex engines. I think it is perfectly reasonable to expect them to behave slightly differently when it comes to substitutions as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to see your substitutions as you type I recommend you use &lt;a href=&quot;https://github.com/xtal8/traces.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;traces.vim&lt;/a&gt; or Neovim's &lt;code&gt;'inccommand'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-01-12T17:57:32.907" LastActivityDate="2018-01-12T17:57:32.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14789" PostTypeId="2" ParentId="14785" CreationDate="2018-01-12T18:02:25.013" Score="3" Body="&lt;p&gt;Since you do not need the swap-functionality, you can disable it using &lt;code&gt;:set noswapfile&lt;/code&gt; or include &lt;code&gt;set noswapfile&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9004" LastActivityDate="2018-01-12T18:02:25.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14790" PostTypeId="2" ParentId="14786" CreationDate="2018-01-12T18:54:41.447" Score="2" Body="&lt;p&gt;Alternative:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do &lt;code&gt;:b term&amp;lt;tab&amp;gt;&lt;/code&gt;. Assuming you do not have many terminal buffers open. Or &lt;code&gt;:b term&lt;/code&gt; if you only have 1 instance&lt;/li&gt;&#xA;&lt;li&gt;Set a file mark, &lt;code&gt;mD&lt;/code&gt;, then use &lt;code&gt;'D&lt;/code&gt; to return&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:file&lt;/code&gt; to name your buffer something you like and will remember. e.g. &lt;code&gt;:file repl&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now in theory if you can change the buffer name via &lt;code&gt;:file&lt;/code&gt; and &lt;code&gt;b:term_title&lt;/code&gt; is the current program, then you can automatically change the buffer name. Maybe update the buffer name when you leave the buffer. The idea:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup TermName&#xA;    autocmd!&#xA;    autocmd BufLeave term://* if len(get(b:, 'term_title', '')) | execute 'file ' . matchstr(expand('&amp;lt;afile&amp;gt;'), 'term://(.{-}//(\d+:)?)?\ze.*') . escape(b:term_title, ' ') | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I do not have NeoVim and I have not tested this in any way.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-01-12T18:54:41.447" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14791" PostTypeId="1" AcceptedAnswerId="14792" CreationDate="2018-01-12T22:44:45.280" Score="0" ViewCount="493" Body="&lt;p&gt;I have keymap in my &lt;code&gt;init.vim&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;y :call NERDTreeFind()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It opens a default file in the &lt;code&gt;NERDTree&lt;/code&gt; window from vim's command line by typing &lt;code&gt;:NERDTreeFind&lt;/code&gt; as it expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I'm pressing the shortcut &lt;code&gt;&amp;lt;leader&amp;gt;y&lt;/code&gt; I got this message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E117: Unknown function: NERDTreeFind&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What might be a problem here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;neovim&lt;/code&gt; under OSX.&lt;/p&gt;&#xA;" OwnerUserId="8709" LastEditorUserId="8709" LastEditDate="2018-01-12T22:59:03.440" LastActivityDate="2018-01-12T23:34:56.003" Title="Weird behavior of NERDTreeFind function" Tags="|key-bindings|neovim|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14792" PostTypeId="2" ParentId="14791" CreationDate="2018-01-12T23:12:00.327" Score="3" Body="&lt;p&gt;Judging by the &lt;a href=&quot;https://github.com/scrooloose/nerdtree/blob/master/doc/NERDTree.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt;, &lt;code&gt;NERDTreeFind&lt;/code&gt; is a command, not a function. This means you do not need &lt;code&gt;:call&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;y :NERDTreeFind&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-01-12T23:34:56.003" LastActivityDate="2018-01-12T23:34:56.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14793" PostTypeId="1" CreationDate="2018-01-13T02:15:10.693" Score="5" ViewCount="2995" Body="&lt;p&gt;My _vimrc contains the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;source $VIMRUNTIME/vimrc_example.vim&#xA;source $VIMRUNTIME/mswin.vim&#xA;behave mswin&#xA;&#xA;&#xA;nmap &amp;lt;c-l&amp;gt; :w&amp;lt;CR&amp;gt;&#xA;&#xA;nmap &amp;lt;c-m&amp;gt; :w&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I try to map &lt;kbd&gt;control&lt;/kbd&gt;+&lt;kbd&gt;l&lt;/kbd&gt; to &lt;code&gt;:w&lt;/code&gt;, and &lt;kbd&gt;control&lt;/kbd&gt;+&lt;kbd&gt;m&lt;/kbd&gt; is the control group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I open a new file, press &lt;code&gt;ctrl-m&lt;/code&gt;, the file saves. I press &lt;code&gt;ctrl-l&lt;/code&gt;, the command line shows &lt;code&gt;:update&lt;/code&gt;. I press &lt;code&gt;ctrl-shift-l&lt;/code&gt;, the file saves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dhg0S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dhg0S.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;The figure shows the UI after I press &lt;code&gt;ctrl-l&lt;/code&gt;. The cursor was on the previous line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qYujE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qYujE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;I run &lt;code&gt;:map&lt;/code&gt; , &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; is registered, but I can only trigger it with &lt;code&gt;ctrl-shift-l&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does the mapping of &lt;code&gt;ctrl-l&lt;/code&gt; fail? &lt;/p&gt;&#xA;" OwnerUserId="15911" LastEditorUserId="1841" LastEditDate="2018-01-19T08:48:50.993" LastActivityDate="2020-07-23T00:31:33.770" Title="Unable to map ctrl-l" Tags="|key-bindings|gvim|microsoft-windows|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14795" PostTypeId="2" ParentId="14743" CreationDate="2018-01-13T08:06:58.467" Score="10" Body="&lt;ol&gt;&#xA;&lt;li&gt;In your _vimrc delete the &lt;code&gt;Plugin 'blabla'&lt;/code&gt; line you want to uninstall.&lt;/li&gt;&#xA;&lt;li&gt;Execute &lt;code&gt;:PluginClean&lt;/code&gt; in vim.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;By the way, make sure PluginClean do the right thing&#xA;you should open a new vim window to execute &lt;code&gt;:PluginClean&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="15891" LastEditorUserId="15891" LastEditDate="2018-07-09T09:56:37.450" LastActivityDate="2018-07-09T09:56:37.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14796" PostTypeId="1" AcceptedAnswerId="14805" CreationDate="2018-01-13T08:55:57.440" Score="2" ViewCount="8534" Body="&lt;p&gt;This question is a follow up to &lt;a href=&quot;https://stackoverflow.com/questions/30943802/macvimnerdtree-how-to-open-a-file-as-a-split-in-furthest-horizontal-split&quot;&gt;this one&lt;/a&gt; (graphs copied from there). The OP was wondering how to split the pane of File 3 horizontally. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/========================================================\&#xA;|          |                      |                      |&#xA;|          |                      |                      |&#xA;|          |     file 1           |                      |&#xA;|          |                      |                      |&#xA;|          |______________________|                      |&#xA;| NERDTree |                      |     File 3           |&#xA;|          |                      |                      |&#xA;|          |    file 2            |                      |&#xA;|          |                      |                      |&#xA;\__________|______________________|______________________/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;currently if I were to be on the &lt;code&gt;File 3&lt;/code&gt; pane, then click on &lt;code&gt;ctrl+n&lt;/code&gt; to jump to nerdtree, then select &lt;code&gt;&amp;lt;file name&amp;gt; + i&lt;/code&gt;, my expectation is to have this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/========================================================\&#xA;|          |                      |                      |&#xA;|          |                      |                      |&#xA;|          |     file 1           |       File 4         |&#xA;|          |                      |                      |&#xA;|          |______________________|______________________|&#xA;| NERDTree |                      |                      |&#xA;|          |                      |                      |&#xA;|          |    file 2            |      File 3          |&#xA;|          |                      |                      |&#xA;\__________|______________________|______________________/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but instead i am getting this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/========================================================\&#xA;|          |                      |                      |&#xA;|          |       file 1         |                      |&#xA;|          |______________________|                      |                      &#xA;|          |                      |                      |&#xA;|          |                      |                      |&#xA;|          |       File 2         |        file 3        | &#xA;| NERDTree |                      |                      |&#xA;|          |______________________|                      |                      &#xA;|          |                      |                      |&#xA;|          |       file 4         |                      |&#xA;|          |                      |                      |&#xA;\__________|______________________|______________________/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The OP found the solution by using a mouse with mvim. I would like a solution &lt;em&gt;without using a mouse&lt;/em&gt; since the one of the main reasons I use vim is &lt;em&gt;not&lt;/em&gt; to use a mouse. &lt;/p&gt;&#xA;" OwnerUserId="14510" LastActivityDate="2018-09-22T04:07:44.480" Title="how to split panes (vertically and horizontally) straight from nerdree" Tags="|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14798" PostTypeId="2" ParentId="10016" CreationDate="2018-01-13T15:21:32.363" Score="1" Body="&lt;p&gt;Functions from other answers didn't work for me, but I found a simple solution that works if you always keep NERDTree open like I do. There's no command to unfocus NERDTree, but we can focus it and then switch to the previous window to ensure it's unfocused. Note that this will cause it to open if it wasn't.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_map = ''&#xA;map &amp;lt;C-P&amp;gt; :NERDTreeFocus&amp;lt;CR&amp;gt;:wincmd w&amp;lt;CR&amp;gt;:CtrlP&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15916" LastActivityDate="2018-01-13T15:21:32.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14800" PostTypeId="1" CreationDate="2018-01-14T02:30:19.410" Score="1" ViewCount="417" Body="&lt;p&gt;When I use the args command it opens the files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args `find . -name \*.html`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to do an operation on the arglist without opening the files at all in a buffer, or either opening them one at a time, doing the operation and then closing them. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args `find . -name \*.html`&#xA;:argdo %s/replace/with this/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to go through the files and do the replacement one at a time. I do not want to open the files in buffers. Also, due to memory constraints, I do not want to have all the files open at one time in any situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-12-06T21:51:57.940" Title="Use the arglist without opening the files" Tags="|multiple-files|argument-list|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14801" PostTypeId="1" AcceptedAnswerId="14814" CreationDate="2018-01-14T03:25:23.737" Score="0" ViewCount="3508" Body="&lt;p&gt;Sometimes I just want to see whether a regex is matching the right stuff. If I could cause Vim to visually select the matching text, it would be one way to do this. Is there a method for doing this?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2022-03-03T15:15:47.910" Title="How can I visually select a regex match?" Tags="|regular-expression|visual-mode|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14802" PostTypeId="2" ParentId="14801" CreationDate="2018-01-14T03:29:27.683" Score="4" Body="&lt;p&gt;This can be achieved with &lt;code&gt;gn&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#gn&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h gn&lt;/code&gt;&lt;/a&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="1841" LastEditDate="2018-01-15T08:03:45.343" LastActivityDate="2018-01-15T08:03:45.343" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14803" PostTypeId="1" AcceptedAnswerId="14811" CreationDate="2018-01-14T06:12:04.363" Score="2" ViewCount="1189" Body="&lt;p&gt;For most files, Vim (terminal) is syntax highlighting properly without any issues. However, I am unable to get it to work for &lt;code&gt;CMakeLists.txt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6scPU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6scPU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neovim has no trouble with syntax highlighting, neither does gvim. I also tried this plugin with no effect: &lt;a href=&quot;https://github.com/pboettch/vim-cmake-syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/pboettch/vim-cmake-syntax&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;syntax on&#xA;set t_Co=256&#xA;au BufNewFile,BufRead *.cmake,CMakeLists.txt set filetype=cmake&#xA;# tried this variation too&#xA;# autocmd BufEnter *.cmake,CMakeLists.txt,*.cmake.in :setlocal filetype=cmake&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12597" LastEditorUserId="1292" LastEditDate="2019-05-30T09:06:04.223" LastActivityDate="2021-01-18T15:32:08.830" Title="CMake syntax highlighting not working as expected" Tags="|syntax-highlighting|plugin-cmake.vim|filetype-cmake|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14804" PostTypeId="1" AcceptedAnswerId="14816" CreationDate="2018-01-14T11:03:21.597" Score="2" ViewCount="568" Body="&lt;p&gt;Is there any way to use an interactive interpreter as the &lt;code&gt;makeprg&lt;/code&gt;? I want the interpreter to stay interactive after invoking &lt;code&gt;:make&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I wanted to invoke python on the current file and stay in interactive mode, I would imagine that &lt;code&gt;:set makeprg=python\ -i\ %&lt;/code&gt; would do what I wanted, the &lt;code&gt;-i&lt;/code&gt; argument telling python to stay in interactive mode after running a script. However if I run a small python script like this vim just prints out the python command prompt (&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;) and then returns me to the editor.&lt;/p&gt;&#xA;" OwnerUserId="15920" LastActivityDate="2018-01-15T16:03:18.880" Title="Using an interactive interpreter as makeprg" Tags="|makeprg|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14805" PostTypeId="2" ParentId="14796" CreationDate="2018-01-14T11:08:06.273" Score="4" Body="&lt;p&gt;The linked question asks how to jump directly from &lt;em&gt;File 3&lt;/em&gt; window to &lt;em&gt;NERDTree&lt;/em&gt; window without hopping through &lt;em&gt;File 1&lt;/em&gt; or &lt;em&gt;File 2&lt;/em&gt; window first. The OP's solution is to use the mouse to click on the &lt;em&gt;NERDTree&lt;/em&gt; window. If you're just asking for a non-mouse way to do that then one answer is &lt;code&gt;2^wh&lt;/code&gt;. That is, hit &lt;kbd&gt;2&lt;/kbd&gt; then &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; then &lt;kbd&gt;H&lt;/kbd&gt;. (Refer to &lt;code&gt;:h CTRL-W_CTRL-H&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I don't think that'll solve your problem. But this does, based on my testing: &lt;code&gt;:set splitright&lt;/code&gt;. Setting this causes new vertical splits to open to the right rather than the left (the default). With this I can recreate your four windows with &lt;em&gt;File 4&lt;/em&gt; appearing in the same column as &lt;em&gt;File 3&lt;/em&gt; when I open it from &lt;em&gt;NERDTree&lt;/em&gt; with &lt;code&gt;s&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; At first I thought the precise layout of three-windows didn't matter but if you have to have it look like your first diagram then you'll need to use another approach: from &lt;em&gt;File 3&lt;/em&gt; window do &lt;code&gt;:split&lt;/code&gt; then do the &lt;code&gt;2^wh&lt;/code&gt; command to go to &lt;em&gt;NERDTree&lt;/em&gt; and, lastly, choose a file with &lt;code&gt;o&lt;/code&gt;. You'll end up in the same four-window layout that you asked for and the cursor will be in the newly opened fourth window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could even add a mapping that will take care of the split and cursor move with a key press or two.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;n :split \| :2winc h&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Normal mode enter &lt;code&gt;\n&lt;/code&gt;. Or change that to some other unused key combo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; An upvote drew my eye to this answer of mine and it occurred to me that it would be more convenient if you could use one mapping to go from &lt;em&gt;NERDTree&lt;/em&gt; and the first layout shown in the question to &lt;em&gt;File 4&lt;/em&gt; window of the second layout.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;o :2winc l \| split \| 2winc h \| norm o&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put the cursor on the file you want to open and instead of just hitting &lt;kbd&gt;O&lt;/kbd&gt; (i.e. enter a lower case &lt;code&gt;o&lt;/code&gt;) hit the leader key first then &lt;kbd&gt;O&lt;/kbd&gt;. That's it. (There's nothing new as far as technique here, I'm just packaging things in a nicer way and saving someone from having to figure out the mapping.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-09-22T04:07:44.480" LastActivityDate="2018-09-22T04:07:44.480" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="14807" PostTypeId="1" AcceptedAnswerId="14810" CreationDate="2018-01-14T14:53:49.827" Score="0" ViewCount="245" Body="&lt;p&gt;Suppose I want to look through a lot of files, one by one, using &lt;code&gt;vi *&lt;/code&gt;. Is there an easy way to look a these files in non-alphabetical order, for example in order of newest or oldest first?&lt;/p&gt;&#xA;" OwnerUserId="15922" LastActivityDate="2018-01-14T19:38:56.763" Title="opening multiple files in order of last changed" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14808" PostTypeId="1" CreationDate="2018-01-14T15:18:58.883" Score="1" ViewCount="64" Body="&lt;p&gt;The help entry for filter explains what the idea is and gives some examples of filters like &lt;code&gt;sort&lt;/code&gt; and &lt;code&gt;indent&lt;/code&gt;, but does not list the possibilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I find out all the possible filters?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-01-14T15:47:52.357" Title="What filters are available?" Tags="|filter|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14809" PostTypeId="2" ParentId="14808" CreationDate="2018-01-14T15:47:52.357" Score="4" Body="&lt;p&gt;consider every program that reads stdin and writes stdout a filter.&#xA;What is available is out of scope of vim. It largely depends on your OS and installation. The sort of the example in the vim-docu is not part of vim.&#xA;Besides, it is a bad example, since quite a while vim has inbuild-sort.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;sed, perl, python, node, cat, tail, less .... are all valid filters&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-01-14T15:47:52.357" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14810" PostTypeId="2" ParentId="14807" CreationDate="2018-01-14T16:43:08.917" Score="3" Body="&lt;p&gt;I hope to be proven wrong but as far as I know there isn't an &quot;easy&quot; way to edit an arbitrarily sorted list of files. But if you are using a *nix system there is a solution that will work in many cases...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the most part you're going to need to utilize other commands to build your sorted file list. Once you have that you can pass those files to &lt;code&gt;vim&lt;/code&gt; on the command line and the order you specify is the order they'll be accessed during editing (with &lt;code&gt;:next&lt;/code&gt;, &lt;code&gt;:last&lt;/code&gt;, &lt;code&gt;:argdo&lt;/code&gt;, etc.). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most obvious way to sort files by common criteria is &lt;code&gt;ls&lt;/code&gt;. See the &lt;code&gt;ls&lt;/code&gt; man page for available flags but a couple key flags are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;-t&lt;/code&gt; - sort by modification time (most recent first)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-S&lt;/code&gt; - sort by file size (largest first)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-r&lt;/code&gt; - reverse the current sort&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, using the output of &lt;code&gt;ls&lt;/code&gt; as input to other commands is generally a bad idea for reasons that are too involved to go into here except to say that one of the root problems is that all kinds of wacky characters are allowed in file names (newlines, tabs, control-characters, etc.). However, if you know your filenames are all made up of basic, printing characters than you can pipe &lt;code&gt;ls&lt;/code&gt; output into vim like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls -rt *.sh | xargs -r sh -c 'exec vim &quot;$@&quot; &amp;lt; /dev/tty' vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;vim&lt;/code&gt; will open with all &lt;code&gt;.sh&lt;/code&gt; files in order of modification time, oldest first. I'd put the &lt;code&gt;xargs&lt;/code&gt; part in a function...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xv() {&#xA;  xargs -r sh -c 'exec vim &quot;$@&quot; &amp;lt; /dev/tty' vim&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and then you can easily apply it to future commands such as...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find -name '*.txt' | xv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;But don't forget what I said about files with weird characters in their names!&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; If you're wondering what a proper solution looks like (that handles any legal filename) here's one that edits all &lt;code&gt;.sh&lt;/code&gt; files in the current directory sorted in order of file size, largest first:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find -maxdepth 1 -name '*.sh' -printf &quot;%s %f\0&quot; | sort -zrn \&#xA;    | awk 'BEGIN{RS=&quot;\0&quot;; ORS=&quot;\0&quot;} {sub(/[0-9]* /, &quot;&quot;, $0); print}' \&#xA;    | xargs -0 -r sh -c 'exec vim &quot;$@&quot; &amp;lt; /dev/tty' vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A deep explanation is beyond the scope of this answer but a fundamental change is &lt;code&gt;find&lt;/code&gt; emits &lt;em&gt;NUL&lt;/em&gt; (&lt;code&gt;\0&lt;/code&gt;) as &quot;line&quot; (record) separator rather than newline which is not possible with &lt;code&gt;ls&lt;/code&gt;. That helps deal with filenames that contain newlines. Further...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;find&lt;/code&gt; : more precise output than &lt;code&gt;ls&lt;/code&gt;; here the output is of form &lt;code&gt;size-bytes filename&lt;/code&gt; + &lt;code&gt;NUL&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sort&lt;/code&gt; : reverse numerical sort, &lt;code&gt;-z&lt;/code&gt; to accept &lt;em&gt;NUL&lt;/em&gt; terminator&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;awk&lt;/code&gt; : strip off each size value&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;xargs&lt;/code&gt; : like above but &lt;code&gt;-0&lt;/code&gt; to accept &lt;em&gt;NUL&lt;/em&gt; terminator&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Anyways, this hardly meets OPs requirement of &quot;an easy way&quot; so it's been relegated to this postscript.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-01-14T19:38:56.763" LastActivityDate="2018-01-14T19:38:56.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14811" PostTypeId="2" ParentId="14803" CreationDate="2018-01-14T20:20:17.253" Score="1" Body="&lt;p&gt;The issue it turns out is a conflict with the &lt;em&gt;Rainbow Parenthesis&lt;/em&gt; plugin: &lt;a href=&quot;https://github.com/kien/rainbow_parentheses.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kien/rainbow_parentheses.vim&lt;/a&gt;, which is too bad as it's a nice plugin but the syntax highlighting functionality is more important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For future reference, the following variant of the &lt;em&gt;Rainbow Parenthesis&lt;/em&gt; plugin is also problematic: &lt;a href=&quot;https://github.com/luochen1990/rainbow&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/luochen1990/rainbow&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12597" LastEditorUserId="12597" LastEditDate="2018-02-14T20:45:47.427" LastActivityDate="2018-02-14T20:45:47.427" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14812" PostTypeId="1" CreationDate="2018-01-15T00:47:59.277" Score="3" ViewCount="1294" Body="&lt;p&gt;I am going through the unfortunate process of making keybinds to change colorschemes, but different plugins have their own highlight groups which is making this difficult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to set the terminal background color for all highlight groups of a specific color at the same time? I am trying to make all the white background components grey (color 254).&lt;/p&gt;&#xA;" OwnerUserId="15930" LastEditorUserId="23502" LastEditDate="2023-10-29T06:00:50.923" LastActivityDate="2023-10-31T08:11:28.800" Title="How to edit all Vim highlight groups?" Tags="|syntax-highlighting|colorscheme|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14814" PostTypeId="2" ParentId="14801" CreationDate="2018-01-15T13:30:28.260" Score="5" Body="&lt;p&gt;Vim will use a colour for search matches if you have the &lt;code&gt;'hlsearch'&lt;/code&gt; option switched on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set hlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then just search for your regular expression and see if it is highlighted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/regex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that, if you also have &lt;code&gt;'incsearch'&lt;/code&gt; set, Vim will begin highlighting matches as soon as you start typing in your regular expression: with that option disabled the highlighting won't occur until you execute the search by pressing &lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;Search&lt;/code&gt; highlighting group is used for highlighting. You can check how this group is configured with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight Search&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you are done, you can remove the highlighting with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nohlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the difference between this and &lt;code&gt;:set nohlsearch&lt;/code&gt;, which turns off search highlighting entirely: the &lt;code&gt;:nohlsearch&lt;/code&gt; command leaves the &lt;code&gt;hlsearch&lt;/code&gt; option &lt;em&gt;on&lt;/em&gt;, and will only turn off highlighting until the next time you search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'hlsearch'&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-15T13:30:28.260" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14816" PostTypeId="2" ParentId="14804" CreationDate="2018-01-15T16:03:18.880" Score="2" Body="&lt;p&gt;You can run &lt;code&gt;:make&lt;/code&gt; to lint and then run &lt;code&gt;:terminal&lt;/code&gt; if there are no errors.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* -bang -complete=file_in_path PythonMake call &amp;lt;SID&amp;gt;PythonMake(&quot;&amp;lt;bang&amp;gt;&quot;, &amp;lt;q-args&amp;gt;)&#xA;function! s:PythonMake(bang, args)&#xA;    execute 'make' . a:bang . ' ' . a:args&#xA;    if empty(filter(getqflist(), 'v:val.valid'))&#xA;        execute 'terminal python -i %'&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I have not tested this code in any way nor do I use NeoVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to use &lt;code&gt;:make&lt;/code&gt; then check for any valid errors (&lt;code&gt;valid&lt;/code&gt; key) which is returned by &lt;code&gt;getqflist()&lt;/code&gt;. If no errors then run your &lt;code&gt;:terminal&lt;/code&gt; command with the current buffer's filename, &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :command&#xA;:h :make&#xA;:h getqflist()&#xA;:h filter()&#xA;:h empty()&#xA;:h :terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-01-15T16:03:18.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14817" PostTypeId="1" CreationDate="2018-01-15T19:37:32.330" Score="1" ViewCount="124" Body="&lt;p&gt;As the Title states &lt;code&gt;b:changedtick&lt;/code&gt; is never zero.&#xA;No plugin or special setting seems to be involved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE&#xA;:echo b:changedtick&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;returns a value != 0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same happens if I start vim with a filename (no matter if the file exists)&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-01-15T19:37:32.330" Title="why is b:changedtick never zero?" Tags="|variables|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14820" PostTypeId="1" AcceptedAnswerId="14821" CreationDate="2018-01-16T06:25:12.690" Score="2" ViewCount="1448" Body="&lt;p&gt;I use the vertical split command a lot &lt;code&gt;:vsplit&lt;/code&gt;, and I also have click on &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt; to look at the definition of a variable (after generating the Ctags).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to do a keyboard shortcut that does both like so:&#xA;I see a variable I would like to see the definition of, so I put the cursor ontop of that variable, perform the keyboard shortcut, and then a vertical split on the right side should show with the definition of that variable (even if it's defined in the same file).. then I perform &lt;em&gt;another&lt;/em&gt; keyboard shortcut to dismiss that new window and return to exactly where I was&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do that?&lt;/p&gt;&#xA;" OwnerUserId="14510" LastActivityDate="2018-01-16T09:49:18.313" Title="shortcut to open definition of variable in a vertical split" Tags="|split|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14821" PostTypeId="2" ParentId="14820" CreationDate="2018-01-16T09:32:44.650" Score="6" Body="&lt;p&gt;From the command line this will open a new vertical split with the tag target:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vert winc ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:winc ]&lt;/code&gt; is the command line equivalent of the &lt;code&gt;CTRL-W CTRL-]&lt;/code&gt; key combo mentioned in &lt;a href=&quot;https://vi.stackexchange.com/users/21/karl-yngve-lerv%c3%a5g&quot;&gt;a comment above&lt;/a&gt;...except neither the Normal mode version nor the command line version require the second &lt;kbd&gt;Ctrl&lt;/kbd&gt;. &lt;code&gt;CTRL-W ]&lt;/code&gt; is sufficient. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In fact, many of the &lt;code&gt;CTRL-W&lt;/code&gt; commands have variations where the second &lt;kbd&gt;Ctrl&lt;/kbd&gt; is optional. The idea is to be forgiving if the user is rapidly pressing the keys and doesn't release &lt;kbd&gt;Ctrl&lt;/kbd&gt; quickly enough after &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we have the modifier &lt;code&gt;:vert&lt;/code&gt; that for certain commands that open a horizontal split opens a vertical split instead. That's why we're using the command line for this rather than the Normal mode keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, sounds like you want a Normal mode mapping for it so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap XX :vert winc ]&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change &lt;code&gt;XX&lt;/code&gt; to whatever unused key combo you prefer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To close the window and return to where you were press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; followed by &lt;kbd&gt;C&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-01-16T09:49:18.313" LastActivityDate="2018-01-16T09:49:18.313" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14822" PostTypeId="2" ParentId="14812" CreationDate="2018-01-16T13:24:18.087" Score="4" Body="&lt;p&gt;You can probably loop the list returned by &lt;code&gt;getcompletion('','highlight')&lt;/code&gt; and get the background with &lt;code&gt;synIDattr(synIDtrans(hlID(l:thislistitem)), &quot;bg&quot;)&lt;/code&gt; (see &lt;code&gt;:h hlID()&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1027" LastActivityDate="2018-01-16T13:24:18.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14823" PostTypeId="1" CreationDate="2018-01-16T13:45:49.097" Score="1" ViewCount="285" Body="&lt;p&gt;I'm trying to get Vim all decked out with some fancy plugins on my work laptop but I am running into some issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;echo &amp;amp;rtp&lt;/code&gt; I can see that Vim will look in several directories for startup files, including the &lt;code&gt;H:&lt;/code&gt; drive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that &lt;code&gt;H:&lt;/code&gt; is a network drive at work and I don't want to have anything Vim related in that drive. Additionally I disconnect from the network at times so it would be a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I installed CtrlP and it is only indexing this &lt;code&gt;H&lt;/code&gt; drive which has nothing in it so obviously it is not providing any benefit. All of my code is under a directory off &lt;code&gt;C:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I launch NERDTRee it displays &lt;code&gt;NERD_tree_1 - (H:\)&lt;/code&gt;. In order to get other plugins to work I hardcoded the path (I use vim-plug):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('C:/Program Files (x86)/Vim/vimfiles/.vim/plugged)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm probably missing something obvious right in front of my face. I do have other plugins installed and they are working. My environment:&#xA;Windows 7&#xA;gVim 8&lt;/p&gt;&#xA;" OwnerUserId="15946" LastEditorUserId="51" LastEditDate="2018-01-16T17:57:06.917" LastActivityDate="2018-01-16T17:57:06.917" Title="Vim Plugin Path Issue" Tags="|microsoft-windows|plugin-ctrlp|plugin-vim-plug|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14824" PostTypeId="1" CreationDate="2018-01-16T14:39:06.503" Score="1" ViewCount="109" Body="&lt;p&gt;I describe this as Fish-like as it is referenced as such by zsh-autocomplete, and I would define it as follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The appearance of a (temporary) automatically inserted completion match, that is highlighted in greyscale. Only when accepting the match the cursor position would be affected and normal highlight groups would be applied.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think this concept of &quot;phantom text&quot; would be a nice extension to the naitive completion options. It would be a means for (future multi-line) completions to be inserted when selected from the menu, without moving the cursor or changing the view state of the window, depending on other completion options. I think this is doable with the asynchronicity these days.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know if there have been efforts made to do this? Do you this is useful?&lt;/p&gt;&#xA;" OwnerUserId="1027" LastActivityDate="2018-01-16T14:39:06.503" Title="Fish-like autosuggestions depending on 'completeopt'" Tags="|autocompletion|insert-mode|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14825" PostTypeId="1" AcceptedAnswerId="14839" CreationDate="2018-01-16T17:27:30.253" Score="0" ViewCount="740" Body="&lt;p&gt;Currently mark character is bright red as in below screenshot. &#xA;How to change it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5HMn3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5HMn3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="343" LastEditDate="2018-01-17T13:30:55.640" LastActivityDate="2018-01-17T13:30:55.640" Title="Plugin vim-signature: How to change mark column character color?" Tags="|mark|color|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14829" PostTypeId="1" AcceptedAnswerId="14831" CreationDate="2018-01-17T06:21:33.267" Score="5" ViewCount="1861" Body="&lt;p&gt;Is there a way to view a list of open buffers and close several buffers without leaving that list?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best I know of for closing multiple buffers is using &lt;code&gt;:ls&lt;/code&gt; to get a list of buffers, memorizing the numbers of the buffers you want to close, and then using &lt;code&gt;:bdelete&lt;/code&gt;/&lt;code&gt;:bd&lt;/code&gt; with a prefix to close those buffers, e.g. &lt;code&gt;:3,5bd&lt;/code&gt;. Sometimes I'll have several buffers open and I want to close a buffer (or at least mark a buffer to be closed) while still looking for more buffers to close. With &lt;code&gt;:ls&lt;/code&gt; and &lt;code&gt;:bd&lt;/code&gt;, this is very inconvenient because I have to enter &lt;code&gt;:ls&lt;/code&gt; again and again between closing buffers rather than closing several buffers and then signaling that I'm done.&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2021-10-05T15:22:46.953" Title="Close multiple buffers interactively" Tags="|buffers|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14831" PostTypeId="2" ParentId="14829" CreationDate="2018-01-17T07:26:11.390" Score="7" Body="&lt;p&gt;There is a popular mapping that will show the &lt;code&gt;:ls&lt;/code&gt; result above a prompt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;ls :ls&amp;lt;cr&amp;gt;:b&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of showing &lt;code&gt;:b&lt;/code&gt;, as in that mapping, we'll show &lt;code&gt;:bd&lt;/code&gt; instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;lsd :ls&amp;lt;cr&amp;gt;:bd&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(If you prefer a different mapping than &lt;code&gt;lsd&lt;/code&gt;, heh, feel free to change it.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Append whatever buffer numbers you want to delete, space separated, and hit &lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you'd rather enter ranges of buffer numbers, like &lt;code&gt;:2,5bd&lt;/code&gt; this variation will put the cursor at the beginning, before &lt;code&gt;bd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;lsd :ls&amp;lt;cr&amp;gt;:bd&amp;lt;home&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But you have to pick one or the other or use two mappings. Personally I use the first mapping and hit &lt;kbd&gt;Home&lt;/kbd&gt; if I want to enter a range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus Update:&lt;/strong&gt; Wanted to stretch my vimscript muscles so came up with this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Displays buffer list, prompts for buffer numbers and ranges and deletes&#xA;&quot; associated buffers. Example input: 2 5,9 12&#xA;&quot; Hit Enter alone to exit. &#xA;function! InteractiveBufDelete()&#xA;    let l:prompt = &quot;Specify buffers to delete: &quot;&#xA;&#xA;    ls | let bufnums = input(l:prompt)&#xA;    while strlen(bufnums)&#xA;        echo &quot;\n&quot;&#xA;        let buflist = split(bufnums)&#xA;        for bufitem in buflist&#xA;            if match(bufitem, '^\d\+,\d\+$') &amp;gt;= 0&#xA;                exec ':' . bufitem . 'bd'&#xA;            elseif match(bufitem, '^\d\+$') &amp;gt;= 0&#xA;                exec ':bd ' . bufitem&#xA;            else&#xA;                echohl ErrorMsg | echo 'Not a number or range: ' . bufitem | echohl None&#xA;            endif &#xA;        endfor&#xA;        ls | let bufnums = input(l:prompt)&#xA;    endwhile &#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put in your vimrc file along with a mapping like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;bd :call InteractiveBufDelete()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if you hit &lt;code&gt;\bd&lt;/code&gt; in Normal mode you'll see the buffer listing and a prompt. Enter space-separated numbers or ranges, such as &lt;code&gt;2 5,8 11&lt;/code&gt;, and hit Enter and all associated buffers will be deleted. The process will repeat until you hit Enter alone. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(I'll leave it to you to add any additional validation or error checking beyond what I have.)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-10-04T01:39:53.853" LastActivityDate="2018-10-04T01:39:53.853" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="14832" PostTypeId="1" AcceptedAnswerId="14835" CreationDate="2018-01-17T08:35:35.557" Score="4" ViewCount="1350" Body="&lt;p&gt;What vimscript magic allows one to create buffers with highly customized behavior, that effectively act like a TUI, such as those presented by NerdTree or other file explorer plugins and Gundo or other undo tree plugins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a core set of vimscript features that are crucial to creating this sort of behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a vimscript newbie, so this question might sound confusingly vague to the pros but please bear with me. From a naive perspective, there are &quot;TUI-ish&quot; plugins that seem magical but also appear to implement somewhat similar interfaces where there is a read-only buffer that presents information, allows limited selecting, has unusual arrowing/&lt;code&gt;hjkl&lt;/code&gt;-ing behavior, and invokes special behavior when &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;/&lt;code&gt;Enter&lt;/code&gt; is pressed. What vimscript magic is needed to implement those behaviors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please go ahead and comment to ask for necessary clarifications to answer the question!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I have experience on other SE sites and I've been meaning to learn deeper vimscript enlightenment but I thought it would be worthwhile to ask this question from a newbie perspective and simply phrase it as best I could.)&lt;/p&gt;&#xA;" OwnerUserId="268" LastActivityDate="2018-01-17T11:10:27.813" Title="How to create a buffer with customized behavior? / How to create a buffer that acts like a TUI?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14833" PostTypeId="2" ParentId="2702" CreationDate="2018-01-17T08:51:52.193" Score="4" Body="&lt;p&gt;from this &lt;a href=&quot;https://stackoverflow.com/a/48296697/4940240&quot;&gt;answer&lt;/a&gt; (refering to an answer by &lt;a href=&quot;https://stackoverflow.com/users/2467354/phan-hai-quang&quot;&gt;PhanHaiQuang&lt;/a&gt; and a comment by &lt;a href=&quot;https://stackoverflow.com/users/407256/flukus&quot;&gt;flukus&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One can run this oneliner from ex (whithin vim) when needed (or put each command in vimrc, for when log-files are opened.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set autoread | au CursorHold * checktime | call feedkeys(&quot;lh&quot;)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;br&gt;&#xA;- &lt;strong&gt;autoread&lt;/strong&gt;: reads the file when changed from the outside (but it doesnt work on its own, there is no internal timer or something like that. It will only read the file when vim does an action, like a command in ex &lt;code&gt;:!&lt;/code&gt;&lt;br&gt;&#xA;- &lt;strong&gt;CursorHold * checktime&lt;/strong&gt;: when the cursor isn't moved by the user for the time specified in 'updatetime' (which is 4000 miliseconds by default) checktime is executed, which checks for changes from outside the file&lt;br&gt;&#xA;- &lt;strong&gt;call feedkeys(&quot;lh&quot;)&lt;/strong&gt;: the cursor is moved once, right and back left. and then nothing happens (... which means, that CursorHold is triggered, which means we have a &lt;strong&gt;loop&lt;/strong&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2239" LastActivityDate="2018-01-17T08:51:52.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14835" PostTypeId="2" ParentId="14832" CreationDate="2018-01-17T11:10:27.813" Score="12" Body="&lt;p&gt;&lt;em&gt;N.B. I'm not sure if figuring out the behaviour of large, advanced plugins is the&lt;/em&gt; best &lt;em&gt;introduction to Vimscript&amp;#8202;&amp;mdash;&amp;#8202;you might be better off first reading the relevant parts of the user manual (Chapters 40 &amp;amp; 41) to get a grounding in the basics or taking a look at a tutorial such as the excellent &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; (which was written by the auther of the Gundo plugin you mention), but in case you're determined to jump in at the deep end&amp;hellip;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plugins use a few methods to achieve the various different aspects you describe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, there are several local options that affect the behaviour of buffers (which can be set and queried via the standard &lt;code&gt;:set&lt;/code&gt; command). In particular:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'modifiable'&lt;/code&gt; prevents you from making any changes to a buffer's content, &lt;code&gt;'readonly'&lt;/code&gt;, prevents you from &lt;em&gt;saving&lt;/em&gt; any changes you've made to a buffer's content,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'buftype'&lt;/code&gt; specifies the type of the buffer: the &lt;code&gt;nofile&lt;/code&gt; value is generally used for the buffers you describe,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'buflisted'&lt;/code&gt; specifies whether the buffer will appear in the buffer list (e.g. in the output of the &lt;code&gt;:ls&lt;/code&gt; command),&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'bufhidden'&lt;/code&gt; specifies what will happen to buffers when they are no longer displayed in a window: some plugins might use the &lt;code&gt;delete&lt;/code&gt; value.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Most of the above (and more) is described in &lt;code&gt;:help special-buffers&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One other thing you could try is running a plain &lt;code&gt;:set&lt;/code&gt; with no arguments in the buffer in which you are curious about the behaviour: this will display all the options which do not have their default settings. You can then read the &lt;code&gt;:help&lt;/code&gt; for any that you don't recognise. Make sure to include the single quotes in your command to avoid ambiguity:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'buftype'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The behaviour of keystrokes is altered with mappings, using the various variants of the &lt;code&gt;:map&lt;/code&gt; command. You can examine, for example, how Gundo implements special movement for the &lt;kbd&gt;j&lt;/kbd&gt; keystroke by typing &lt;code&gt;nmap j&lt;/code&gt; in the Gundo buffer. The problem you're going to have as a Vimscript beginner is interpreting its output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n  j           &amp;amp;@:call &amp;lt;SNR&amp;gt;28_GundoMove(1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is described in detail in &lt;code&gt;:help map-listing&lt;/code&gt;, but essentially, what this tells you is that &lt;kbd&gt;j&lt;/kbd&gt; is mapped to a function called &lt;code&gt;GundoMove()&lt;/code&gt;. You'd need to delve into the plugin's code to figure out how the behaviour is implemented, but again, that's not necessarily the quickest path to understanding for a beginner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for presenting information, there are &lt;em&gt;lots&lt;/em&gt; of different ways you can add text to a buffer in Vim. Describing all of these is a bit too open-ended of a task for an answer on this site: if you really want to find out how a specific plugin does this, you're going to need to look at that plugin's code. Feel free to ask new questions if you come up with more specific queries while doing so.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-17T11:10:27.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14836" PostTypeId="1" AcceptedAnswerId="14837" CreationDate="2018-01-17T11:20:28.557" Score="2" ViewCount="238" Body="&lt;p&gt;I don't know what vim cannot do, so far, I feel it is so powerful!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need indent in Normal Mode for c++ code. I found vim is using &quot;&lt;strong&gt;&lt;em&gt;=&lt;/em&gt;&lt;/strong&gt;&quot; to that, just visual/mouse select the code and hit &quot;=&quot; key, or doing &quot;gg=G&quot; for all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following style is what I need (no indentation after a keyword). It might be ugly, but let's just don't discuss that. I'm using it as an example. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;template&amp;lt; class T &amp;gt; class Stack&#xA;{&#xA;    public:&#xA;    Stack(int = default_value);&#xA;    Stack()//destructor&#xA;    {delete [] values;}&#xA;    bool push( T );&#xA;    T pop();&#xA;    bool isEmpty();&#xA;    bool isFull();&#xA;    private:&#xA;    int size;&#xA;    T *values;&#xA;    int index;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After &quot;=&quot; indenting, I got the following code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;template&amp;lt; class T &amp;gt; class Stack&#xA;{&#xA;    public:&#xA;        Stack(int = default_value);&#xA;        Stack()//destructor&#xA;        {delete [] values;}&#xA;        bool push( T );&#xA;        T pop();&#xA;        bool isEmpty();&#xA;        bool isFull();&#xA;    private:&#xA;        int size;&#xA;        T *values;&#xA;        int index;&#xA;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Is there a way to configure/change the indentation style/schema behind the &quot;=&quot; operator or Is there a mechanism to load some sort of indentation schema into the &quot;=&quot; in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="15958" LastActivityDate="2018-01-17T17:14:26.713" Title="Indenting schema, is there a sort of thing you can load/configure into &quot;=&quot; in vim?" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14837" PostTypeId="2" ParentId="14836" CreationDate="2018-01-17T11:59:45.080" Score="5" Body="&lt;p&gt;For your specific query (indentation of statements following a C++ scope declaration), you can use Vim's C-indenting and add the &lt;code&gt;h&lt;/code&gt; setting to &lt;code&gt;cinoptions&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use C-indenting&#xA;:set cindent&#xA;&#xA;&quot; Don't indent further after scope declaration&#xA;:set cinoptions+=h0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More generally, you can also use either an external program or Vimscript to configure the behaviour of the &lt;code&gt;=&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;'equalprg'&lt;/code&gt; option to specify an external program or the &lt;code&gt;'indentexpr'&lt;/code&gt; option to specify a (Vimscript) indent expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help C-indenting&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help cinoptions&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help cino-h&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help =&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'equalprg'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 'indentexpr'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help indent-expression&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-17T17:14:26.713" LastActivityDate="2018-01-17T17:14:26.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14838" PostTypeId="2" ParentId="14825" CreationDate="2018-01-17T12:22:12.497" Score="2" Body="&lt;p&gt;Mark column is added by plugin: &lt;code&gt;vim-signature&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Need to edit: &lt;code&gt;$HOME/.vim/bundle/vim-signature/autoload/signature/utils.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change 'SignatureMarkText' color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Need to exit vim to see the change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ifeWF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ifeWF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-01-17T12:22:12.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14839" PostTypeId="2" ParentId="14825" CreationDate="2018-01-17T13:29:44.883" Score="2" Body="&lt;p&gt;By default, the vim-signature plugin uses the &lt;code&gt;SignatureMarkText&lt;/code&gt; highlighting group for its mark signs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's better to set the colour of this in your &lt;code&gt;vimrc&lt;/code&gt; rather than editing the plugin's code (which could cause problems if/when you want to update the plugin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following line to your &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight SignatureMarkText guifg=White ctermfg=White&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(You can also run this command from command-line mode to apply the change without restarting Vim.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the plugin uses the same mechanism for setting the colour, the &lt;code&gt;CheckAndSetHL()&lt;/code&gt; function (for which you altered the parameters in your answer) builds essentially the same command as the above.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-17T13:29:44.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14841" PostTypeId="1" CreationDate="2018-01-17T16:37:30.290" Score="3" ViewCount="62" Body="&lt;p&gt;&lt;code&gt;:vimgrep&lt;/code&gt; can list search result in the Quickfix window.&lt;br&gt;&#xA;&lt;code&gt;:cn&lt;/code&gt; can jump to next matching and NORMAL window is also updated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If switch to NORMAL window and &lt;code&gt;n&lt;/code&gt;, it will jump to next matching place, but Quickfix windows is unchanged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can we make NORMAL and Quickfix window fully synchronized?&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-01-17T16:37:30.290" Title="How to synchronize between NORMAL and Quickfix window?" Tags="|quickfix|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14842" PostTypeId="1" CreationDate="2018-01-17T17:16:46.467" Score="0" ViewCount="88" Body="&lt;p&gt;I recorded a register and it work normally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mistakenly overrode that register, fortunately I already saved the pattern.&#xA;It's as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V}y}pV}:s/_a\(\&amp;gt;\|_\)/_b\1/g^MpV}:s/_a\(\&amp;gt;\|_\)/_c\1/g^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means I copy a block (which have &lt;code&gt;_a&lt;/code&gt; or &lt;code&gt;_a_&lt;/code&gt;) and paste it to two others block, then change &lt;code&gt;_a&lt;/code&gt; or &lt;code&gt;_a_&lt;/code&gt; to &lt;code&gt;_b&lt;/code&gt;, &lt;code&gt;_b_&lt;/code&gt; and &lt;code&gt;_c&lt;/code&gt;, &lt;code&gt;_c_&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I copy this line to my new register and execute, it don't understand that it need to replace ^M with Enter.&#xA;However, it stop at command line with exact whole register content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried change ^M to &lt;code&gt;&amp;lt;C-M&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;, but they don't work also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help.&lt;/p&gt;&#xA;" OwnerUserId="15965" LastEditorUserId="6489" LastEditDate="2018-01-17T19:20:54.783" LastActivityDate="2018-03-19T08:34:38.380" Title="Edit record register with multiple subtitution" Tags="|substitute|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14843" PostTypeId="2" ParentId="14842" CreationDate="2018-01-17T17:27:29.563" Score="1" Body="&lt;p&gt;This blog &lt;a href=&quot;http://of-vim-and-vigor.blogspot.com/2012/06/advanced-macros-in-vim-commentary.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://of-vim-and-vigor.blogspot.com/2012/06/advanced-macros-in-vim-commentary.html&lt;/a&gt; help me to answer this question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The content of register need to change to: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;V}y}pV}:s/_a\\(\\&amp;gt;\\|_\\)/_b\\1/g\&amp;lt;CR&amp;gt;pV}:s/_a\\(\\&amp;gt;\\|_\\)/_c\\1/g\&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then use &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let @i = &quot;V}y}pV}:s/_a\\(\\&amp;gt;\\|_\\)/_b\\1/g\&amp;lt;CR&amp;gt;pV}:s/_a\\(\\&amp;gt;\\|_\\)/_c\\1/g\&amp;lt;CR&amp;gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that I can use my @i register.&lt;/p&gt;&#xA;" OwnerUserId="15965" LastEditorUserId="6489" LastEditDate="2018-01-17T19:24:27.317" LastActivityDate="2018-01-17T19:24:27.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14844" PostTypeId="2" ParentId="14842" CreationDate="2018-01-17T17:31:58.487" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;&quot;ip&lt;/code&gt; to put the register into a buffer, edit it, then use &lt;code&gt;&quot;iy$&lt;/code&gt; or similar to put it back into the register.  This mostly preserves the meanings of special characters such as &lt;code&gt;^M&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-01-17T17:31:58.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14847" PostTypeId="1" CreationDate="2018-01-18T00:48:38.093" Score="3" ViewCount="115" Body="&lt;p&gt;So I often use repeated invocations of &lt;kbd&gt;gq&lt;/kbd&gt;&lt;kbd&gt;ip&lt;/kbd&gt; to re-wrap paragraphs of text or comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the quickest way I've memorized for &lt;em&gt;moving&lt;/em&gt; between paragraphs, &lt;kbd&gt;}&lt;/kbd&gt;, lands me &lt;em&gt;between&lt;/em&gt; them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Qui⁁ut delectus ex enim. Qui doloremque suscipit itaque. Dolores assumenda commodi&#xA;laudantium eum ut sed. Facere voluptas omnis sunt assumenda quis.  Cupiditate aut&#xA;quidem corporis consequatur. Libero sed qui ea odio nisi.&#xA;&#xA;Unde tempore suscipit et dolor unde nisi. Placeat asperiores sed rerum pariatur&#xA;nobis velit ea.  Doloremque impedit alias eligendi iusto sit in.  Eos commodi non&#xA;voluptates omnis sunt est.&#xA;&#xA;Aliquami magni molestiae quo sit. Qui id eligendi minus esse provident.&#xA;Perspiciatis ut tenetur ad consequuntur vel aut ullam.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... &lt;kbd&gt;gq&lt;/kbd&gt;&lt;kbd&gt;ip&lt;/kbd&gt;&lt;kbd&gt;}&lt;/kbd&gt; ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Qui ut delectus ex enim. Qui doloremque suscipit itaque. Dolores&#xA;assumenda commodi laudantium eum ut sed. Facere voluptas omnis sunt&#xA;assumenda quis.  Cupiditate aut quidem corporis consequatur. Libero&#xA;sed qui ea odio nisi.&#xA;⁁&#xA;Unde tempore suscipit et dolor unde nisi. Placeat asperiores sed rerum pariatur&#xA;nobis velit ea.  Doloremque impedit alias eligendi iusto sit in.  Eos commodi non&#xA;voluptates omnis sunt est.&#xA;&#xA;Aliquami magni molestiae quo sit. Qui id eligendi minus esse provident.&#xA;Perspiciatis ut tenetur ad consequuntur vel aut ullam.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I can use a non-text-object motion thereafter (&lt;kbd&gt;gq&lt;/kbd&gt;&lt;kbd&gt;}&lt;/kbd&gt;) to continue reformatting paragraphs; but that doesn't apply to every situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tl;dr&lt;/strong&gt; Is there a way for me to preform motion by-paragraph, but end up on the first/last character of the paragraph object?&lt;/p&gt;&#xA;" OwnerUserId="6108" LastActivityDate="2018-01-18T07:11:27.083" Title="How do I move by paragraphs, but end up *in* the paragraph?" Tags="|cursor-motions|formatting|object-motions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14848" PostTypeId="1" CreationDate="2018-01-18T00:57:45.703" Score="0" ViewCount="360" Body="&lt;p&gt;In search expressions I know I can find the shortest match on line with the following expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;begin.\{-}end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So for example, if the text is like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;begin end1 end2 end3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it will match up to the &quot;1&quot;. However, what if the text is spread over multiple lines like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;begin blah blah blah&#xA;blah blah blah end1 end2 end3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I do the same match across the end of line?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-01-18T01:14:54.253" Title="How can I match the shortest string including new lines?" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14849" PostTypeId="2" ParentId="14848" CreationDate="2018-01-18T01:14:54.253" Score="2" Body="&lt;p&gt;try &lt;code&gt;/begin\_.\{-}end&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\_.&lt;/code&gt;   Matches any single character or end-of-line.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-01-18T01:14:54.253" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14850" PostTypeId="2" ParentId="14847" CreationDate="2018-01-18T03:29:41.043" Score="1" Body="&lt;p&gt;So you just want to substitute something for &lt;code&gt;}&lt;/code&gt; that moves down to the first non-empty line, i.e. the next paragraph? If I'm reading that right then...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's just an extra character to do this, &lt;code&gt;)&lt;/code&gt;, but if &lt;code&gt;})&lt;/code&gt; is more than you want to type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap } })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't always want the new/modified movement you can add an alternate with the default movement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap \} }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or leave the default movement alone and use &lt;code&gt;\}&lt;/code&gt; (or whatever keys you want) for your modified movement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I'm using &lt;code&gt;)&lt;/code&gt; rather than, say, &lt;code&gt;j&lt;/code&gt; so multiple empty lines between paragraphs are handled.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-01-18T07:11:27.083" LastActivityDate="2018-01-18T07:11:27.083" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14851" PostTypeId="1" AcceptedAnswerId="14888" CreationDate="2018-01-18T06:41:19.147" Score="21" ViewCount="4585" Body="&lt;p&gt;This screen I got after running the &lt;code&gt;:Gstatus&lt;/code&gt; command:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cpPAe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cpPAe.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then I moved the cursor to &lt;code&gt;init.vim&lt;/code&gt; file and pressed the &lt;code&gt;p&lt;/code&gt; key, i.e. run &lt;code&gt;git add –patch&lt;/code&gt; for the current file.&lt;/p&gt;&#xA;&lt;p&gt;Now I have this screen:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3j0SA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3j0SA.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you can see, here's the usual interaction for git add patch in a terminal. In the terminal I can press &lt;code&gt;y&lt;/code&gt; to add the current chunk of code to the stage area, press &lt;code&gt;n&lt;/code&gt; to skip the current one and so on.&lt;/p&gt;&#xA;&lt;p&gt;But here in &lt;code&gt;fugitive.vim&lt;/code&gt; I can't figure out what I should press. Should I press &lt;code&gt;:w&lt;/code&gt; to add the current chunk to stage? Or should I press &lt;code&gt;-&lt;/code&gt;, or &lt;code&gt;:q&lt;/code&gt; to skip?&lt;/p&gt;&#xA;&lt;p&gt;P.S. I'm using Neovim&lt;/p&gt;&#xA;" OwnerUserId="8709" LastEditorUserId="23502" LastEditDate="2023-06-05T20:49:05.217" LastActivityDate="2023-06-05T20:49:05.217" Title="How to patch add in Fugitive plugin?" Tags="|neovim|plugin-system|plugin-fugitive|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="14852" PostTypeId="2" ParentId="14842" CreationDate="2018-01-18T07:18:33.330" Score="2" Body="&lt;p&gt;Your solution is one way. But to insert something into a register from a buffer (e.g. &lt;code&gt;&quot;iy$&lt;/code&gt;) as you were originally attempting to do...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Literal control-characters can be entered by prepending &lt;code&gt;^V&lt;/code&gt; (CTRL-V). So before you yank your text into the register replace &lt;code&gt;^M&lt;/code&gt; (caret plus letter &quot;M&quot;) with what you get by hitting &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; then &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;M&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-01-18T07:27:01.653" LastActivityDate="2018-01-18T07:27:01.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14853" PostTypeId="1" CreationDate="2018-01-18T10:12:31.503" Score="1" ViewCount="34" Body="&lt;p&gt;I've mapped control-m to start the Syntastic check mode (Active/Passive)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-m&amp;gt; :SyntasticToggleMode&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in normal mode, when I tap the return key, it also toggles the mode. When removing the mapping line above, the problem is off. Any clue of that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="15958" LastEditorUserId="1841" LastEditDate="2018-01-18T10:36:27.953" LastActivityDate="2018-01-18T10:36:27.953" Title="Mapping influenced my return key to toggle the syntastic check mode" Tags="|key-bindings|" AnswerCount="0" CommentCount="2" ClosedDate="2018-01-18T10:34:30.013" ContentLicense="CC BY-SA 3.0" />
  <row Id="14855" PostTypeId="1" CreationDate="2018-01-18T12:41:23.307" Score="1" ViewCount="1929" Body="&lt;p&gt;My Vim is kinda slow for nearly everything. Opening a file takes five seconds, it flickers when I move up and down NerdTree and sometimes when I switch windows or tabs, it freezes for dozens of seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a lot of plugins enabled, plus webpack watch running. I have htop running on a separate monitor, and sometimes the 4 CPUs go 100% when I save a file(that's because of webpack), so this bottleneck is understandable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the others cited above are not. How do I get to know what exactly is causing these bottlenecks in my Vim? Is there a way to know this without experimenting disabling plugins, etc?&lt;/p&gt;&#xA;" OwnerUserId="15976" LastEditorUserId="9004" LastEditDate="2018-01-19T08:35:36.377" LastActivityDate="2022-07-05T03:03:10.373" Title="Analyze NeoVim Performance Bottlenecks" Tags="|neovim|performance|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14856" PostTypeId="1" CreationDate="2018-01-18T14:08:20.337" Score="5" ViewCount="1459" Body="&lt;p&gt;How can I disable all user mappings only for current buffer in vim? I've tried &lt;code&gt;:mapclear&lt;/code&gt; but it removed mappings for all buffers.&lt;/p&gt;&#xA;" OwnerUserId="6859" LastActivityDate="2023-01-21T14:14:21.143" Title="Clear mappings in current buffer" Tags="|key-bindings|vimscript|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14858" PostTypeId="2" ParentId="14856" CreationDate="2018-01-18T18:02:05.310" Score="2" Body="&lt;p&gt;You might be looking for &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This argument ensures that the command or the mapping will be effective only in the local buffer rather than the global buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clear all the user-mapping in the local buffer, &lt;code&gt;:mapclear &amp;lt;buffer&amp;gt;&lt;/code&gt; should be used. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, look at &lt;code&gt;:h :map-&amp;lt;buffer&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="9004" LastActivityDate="2018-01-18T18:02:05.310" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14859" PostTypeId="2" ParentId="8406" CreationDate="2018-01-18T18:36:37.153" Score="2" Body="&lt;p&gt;To supress vim changing the window title just disable the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;&quot;disable title modification&#xA;set notitle&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="15979" LastEditorUserId="15979" LastEditDate="2018-01-18T18:47:53.350" LastActivityDate="2018-01-18T18:47:53.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14860" PostTypeId="1" AcceptedAnswerId="14861" CreationDate="2018-01-18T21:33:11.253" Score="1" ViewCount="2534" Body="&lt;p&gt;I want to have something like a &lt;code&gt;virtualenv&lt;/code&gt; for Vim: on my Windows machine, the plugins are normally located in &lt;code&gt;vimfiles&lt;/code&gt;, &lt;code&gt;_vimrc&lt;/code&gt; holds the settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For debugging reasons, I want to create a separate environment  with an empty &lt;code&gt;vimfiles2&lt;/code&gt; directory and a blank &lt;code&gt;_vimrc2&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do that?&lt;/p&gt;&#xA;" OwnerUserId="1041" LastActivityDate="2018-01-19T11:07:19.490" Title="How do I use different Vim environments?" Tags="|vimrc|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14861" PostTypeId="2" ParentId="14860" CreationDate="2018-01-18T21:45:54.560" Score="0" Body="&lt;p&gt;Just found it myself: the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;rtp&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;runtimepath&lt;/code&gt;&lt;/a&gt; is the solution!&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;create a new &lt;code&gt;vimrc&lt;/code&gt;, e.g. &lt;code&gt;new-vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;inside that &lt;code&gt;new-vimrc&lt;/code&gt; set up the &lt;code&gt;runtimepath&lt;/code&gt; so that it points to a new directory. Sample for Windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath=~/new-vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/vimfiles/after&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Start your Vim now with the &lt;code&gt;-u&lt;/code&gt; option specifying the location of the new &lt;code&gt;vimrc&lt;/code&gt; to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u $HOME/new-vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1041" LastEditorUserId="1041" LastEditDate="2018-01-19T07:48:12.630" LastActivityDate="2018-01-19T07:48:12.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14862" PostTypeId="1" CreationDate="2018-01-18T22:37:58.650" Score="1" ViewCount="1525" Body="&lt;p&gt;My Netrw config here.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_banner = 0&#xA;let g:netrw_liststyle = 3&#xA;let g:netrw_browse_split = 4&#xA;let g:netrw_altv = 1&#xA;let g:netrw_winsize = 25&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just i want to hide &quot;|&quot; and &quot;/&quot;. But how?&#xA;I try &lt;code&gt;:help netrw&lt;/code&gt; command but i can't found solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Lm6xA.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Lm6xA.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user19532" LastActivityDate="2018-01-21T16:28:28.163" Title="Netrw how to hide line?" Tags="|netrw|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14863" PostTypeId="2" ParentId="14862" CreationDate="2018-01-19T00:48:44.430" Score="3" Body="&lt;p&gt;There's no documented way to hide the slashes that follow directory names. If you're willing to change a bit of code to remove them then find the following line in &lt;code&gt;$VIMRUNTIME/autoload/netrw.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let pfile= filename.&quot;/&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can just search for &quot;getftype&quot; to get you in the general area of the (large) file...the line above is within a few lines of the last occurrence of that string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now just remove the &lt;code&gt;/&lt;/code&gt; (leave the surrounding quotes) and save the change. That should do it. The next time you launch an instance of &lt;code&gt;vim&lt;/code&gt; no more slashes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the vertical lines, they are integral to tree-style listings which is what you are using. The listings would be difficult to read without them so it's no surprise that there's no way to disable them. You &lt;em&gt;could&lt;/em&gt; use a different list style...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change &lt;code&gt;g:netrw_liststyle&lt;/code&gt; to 0, 1 or 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h netrw-browser-settings&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  *g:netrw_liststyle*       Set the default listing style:&#xA;                                = 0: thin listing (one file per line)&#xA;                                = 1: long listing (one file per line with time&#xA;                                     stamp information and file size)&#xA;                                = 2: wide listing (multiple files in columns)&#xA;                                = 3: tree style listing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-01-19T17:14:34.533" LastActivityDate="2018-01-19T17:14:34.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14864" PostTypeId="1" AcceptedAnswerId="14954" CreationDate="2018-01-19T09:58:28.677" Score="0" ViewCount="234" Body="&lt;p&gt;When I select some text in Visual mode (either with keyboard or mouse), and I scroll the mouse wheel up/down, the visual mode expands the selection in up/down direction according to the mouse scrolling, and I don't want this behavior (I want to expand it &lt;em&gt;manually&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following remapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnoremap &amp;lt;ScrollWheelUp&amp;gt; gv5k&#xA;:vnoremap &amp;lt;ScrollWheelDown&amp;gt; gv5j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but works only for the first try (select text and scroll. If I select another text and scroll again, selection will be expanded), in addition, mouse must be disabled for visual mode. So this setting is not what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do not expand the text selection with the mouse wheel, leaving it enabled for Visual mode selection also ?&lt;/p&gt;&#xA;" OwnerUserId="15254" LastActivityDate="2018-01-24T15:55:28.710" Title="Is it possible to do not expand the Visual-mode selection with ScrollWheelUp/Down?" Tags="|visual-mode|mouse|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14865" PostTypeId="2" ParentId="14860" CreationDate="2018-01-19T10:38:58.547" Score="1" Body="&lt;p&gt;An easier way to do this than overriding the &lt;code&gt;'runtimepath'&lt;/code&gt; setting in your vimrc is to set the &lt;code&gt;HOME&lt;/code&gt; environment variable for the vim command in your shell command. e.g.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In bash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir ~/new-vimhome&#xA;HOME=~/new-vimhome vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or in the Windows Command prompt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir %USERDRIVE%%USERPATH%\new-vimhome&#xA;set HOME=%USERDRIVE%%USERPATH%\new-vimhome&#xA;vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that Windows Vim uses the &lt;code&gt;HOME&lt;/code&gt; environment variable if it is set, but it usually isn't&amp;#8202;&amp;mdash;&amp;#8202;and other programs won't generally check it&amp;#8202;&amp;mdash;&amp;#8202;so it should be safe to set it persistently as we do above.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then set up any Vim configuration you desire within that home directory, in the usual way. e.g.:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir ~/new-vimhome/.vim&#xA;touch ~/new-vimhome/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Windows Command Prompt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir %USERDRIVE%%USERPATH%\new-vimhome\vimfiles&#xA;vim %USERDRIVE%%USERPATH%\new-vimhome\_vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. As &lt;a href=&quot;https://vi.stackexchange.com/questions/14860/how-do-i-use-different-vim-environments/14865#comment25465_14865&quot;&gt;@eckes notes in a comment&lt;/a&gt;, this solution does have the caveat that &lt;code&gt;$HOME&lt;/code&gt; will point to the new directory rather than your &lt;em&gt;real&lt;/em&gt; home directory, so the &lt;code&gt;$HOME&lt;/code&gt; environment variable and &lt;code&gt;~&lt;/code&gt; shortcut can't be used for accessing files located there within an instance Vim running in this way. (Although you can of course still access such files using absolute paths or Windows's standard environment variables.) If you don't want this degree of separation from your usual environment, &lt;a href=&quot;https://vi.stackexchange.com/posts/14861/revisions&quot;&gt;their solution&lt;/a&gt; might therefore be preferable.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-19T11:07:19.490" LastActivityDate="2018-01-19T11:07:19.490" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14866" PostTypeId="1" CreationDate="2018-01-19T11:01:50.820" Score="0" ViewCount="37" Body="&lt;p&gt;To learn my mappings, I want to toggle an individual help (like e.g. a cheatsheet or so). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how to toggle showing of a window, is there any way or neat key map to toggle something like &quot;:split ~/.vim_help&quot; (with low height of the new window)? The purpose is to show my helpfile quickly, look for the command I can't remember and close (toggle) it then?&lt;/p&gt;&#xA;" OwnerUserId="15987" LastEditorUserId="1841" LastEditDate="2018-01-19T12:40:53.183" LastActivityDate="2018-01-19T13:18:09.723" Title="Toggle showing a file (e.g. individual Cheatsheet)" Tags="|key-bindings|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14867" PostTypeId="1" AcceptedAnswerId="14869" CreationDate="2018-01-19T11:02:38.857" Score="0" ViewCount="432" Body="&lt;p&gt;At the moment, my commenting and un-commenting is done by two different strokes listed below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;c 0&amp;lt;insert&amp;gt;//&amp;lt;Esc&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;&amp;lt;leader&amp;gt;c :s;^\s*//&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is tedious for me, can someone help me to write a mapping macro that  &lt;code&gt;&amp;lt;leader&amp;gt;c&lt;/code&gt; stroke removes the comments, if there are any, or add one otherwise. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the comments/uncomments will all be done by the single lovely &lt;code&gt;&amp;lt;leader&amp;gt;c&lt;/code&gt;, that would be a lot less pain in my ......&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;p.s.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you intended to learn Vimrc, read the answer, try those cool solutions. However, here comes the better pain killer: &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERD Commenter&lt;/a&gt;, &lt;/p&gt;&#xA;" OwnerUserId="15958" LastEditorUserId="15958" LastEditDate="2018-01-19T14:27:09.353" LastActivityDate="2018-01-19T16:36:29.783" Title="Comment and uncomment by the same key strokes" Tags="|vimrc|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14868" PostTypeId="1" AcceptedAnswerId="14880" CreationDate="2018-01-19T11:08:48.730" Score="2" ViewCount="239" Body="&lt;p&gt;I have read in various documentation that when Vim is started in Ex mode, it attempts to &quot;act like&quot; Ex, so I gather from this that Ex is a separate program and is not an actual part of the Vim source code and has its own separate code maintained by people other than those maintaining Vim. If this is true, what is the relationship between the two?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does Vim copy and paste Ex's source code into its own project to create the Ex functionality, or does it try to emulate it from scratch?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I notice that the regular expression syntax and features in Ex and Vim appear to be identical. If they are completely separate programs, then how is the parity maintained? Do they have a shared regex library that both use?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-01-20T02:35:38.430" Title="What is the relationship between command line Ex and Vim?" Tags="|regular-expression|ex-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14869" PostTypeId="2" ParentId="14867" CreationDate="2018-01-19T12:35:54.977" Score="3" Body="&lt;p&gt;You can achieve this kind of effect simply with an expression map and the ternary operator:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;c getline('.')[0:1] == '//'&#xA;  \ ? &quot;:s;^\s*//&amp;lt;cr&amp;gt;&quot;&#xA;  \ : &quot;0&amp;lt;insert&amp;gt;//&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An expression mapping maps your &lt;code&gt;&amp;lt;leader&amp;gt;c&lt;/code&gt; to the result of an expression. In this case, it tests if the first two character in the line are &lt;code&gt;//&lt;/code&gt; and then carries one of the commands you already wrote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3amap-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :map-expression&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help expr1&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-19T12:48:10.143" LastActivityDate="2018-01-19T12:48:10.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14870" PostTypeId="2" ParentId="14867" CreationDate="2018-01-19T12:38:12.897" Score="5" Body="&lt;p&gt;If you want to use your own mappings you can try something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;c IsCommented() ? &quot;:s;^\s*//&amp;lt;cr&amp;gt;&quot; : &quot;0&amp;lt;insert&amp;gt;//&amp;lt;Esc&amp;gt;&quot;&#xA;&#xA;function! IsCommented()&#xA;    return substitute(getline('.'), '^\s*', '', '')[0] == &quot;/&quot; &amp;amp;&amp;amp; substitute(getline('.'), '^\s*', '', '')[0] == substitute(getline('.'), '^\s*', '', '')[1]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;IsCommented()&lt;/code&gt; will return true is the first two characters of the current line are &lt;code&gt;/&lt;/code&gt; and false otherwise (note that it will ignore the leading whitespaces) and the mapping is conditioned by the result of this command (See &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3amap-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :map-expression&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would recommend not to reinvent the wheel and use a plugin like &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDCommenter&lt;/a&gt; or &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-commentary&lt;/a&gt; which are pretty powerful and lightweight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; As &lt;a href=&quot;https://vi.stackexchange.com/questions/14867/comment-and-uncomment-by-the-same-key-strokes/14870#comment25467_14870&quot;&gt;@Rich said&lt;/a&gt;: &lt;a href=&quot;https://github.com/tomtom/tcomment_vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;tcomment&lt;/a&gt; never gets any love.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-01-19T16:36:29.783" LastActivityDate="2018-01-19T16:36:29.783" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14871" PostTypeId="1" CreationDate="2018-01-19T13:15:26.433" Score="1" ViewCount="64" Body="&lt;p&gt;When I need to work with some scrambled javascript/json code, one of my first steps is to introduce proper line breaks, followed by proper brace based indentation. For the later, I found the following command very helpful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%g/{/:normal $&amp;gt;i{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With at most a single opening brace on any line, this produces near perfect indentation in no time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when trying to run the same command from the command line with the &lt;code&gt;-c&lt;/code&gt; option, it simply does not seem to have any effect. I tried the following invocation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c ':%g/{/:normal $&amp;gt;i{' -c ':wq' some_scrambled_json_file.json&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does this not work? And how do I need to change my invocation to make it work?&lt;/p&gt;&#xA;" OwnerUserId="15988" LastActivityDate="2018-01-19T14:49:28.260" Title="indenting with ':g' command not working from the command line" Tags="|normal-mode|invocation|global-command|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14872" PostTypeId="2" ParentId="14866" CreationDate="2018-01-19T13:18:09.723" Score="1" Body="&lt;p&gt;This is not the shortest solution (nor the most elegant) but you can use it as a basis and tailor it to fit your needs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Create the mapping which will toggle the cheatsheet&#xA;nnoremap &amp;lt;F1&amp;gt; :call Cheatsheet()&amp;lt;CR&amp;gt;&#xA;&#xA;function! Cheatsheet()&#xA;    &quot; Save the z register&#xA;    let save_z = getreg('z')&#xA;&#xA;    &quot; Get the list of buffers in the z register&#xA;    redir @z&#xA;        silent filter /cheatsheet/ ls&#xA;    redir END&#xA;&#xA;    &quot; Get the result in a variable and restore the register&#xA;    let buff = getreg('z')&#xA;    call setreg('z', save_z)&#xA;&#xA;    &quot; The results has several lines, make it only one&#xA;    let buff = substitute(buff, '\n', '', 'g')&#xA;&#xA;    &quot; Get the status (hiden 'h' or not 'a') of the buffer&#xA;    let status = buff[match(buff, '[ah]')]&#xA;&#xA;    &quot; If the buffer is not hidden delete it, that will close the split&#xA;    if status == &quot;a&quot;&#xA;        let buffnumber = substitute(buff, '^\s*', '', '')[0]&#xA;        execute &quot;bdelete &quot; . buffnumber&#xA;    &quot; Else open a split&#xA;    else&#xA;        vsplit ~/.cheatsheet&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These help topics might be helpful:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3aredir&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :redir&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3afilter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :filter&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getreg%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getreg()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#substitute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h substitute()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3als&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :ls&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-01-19T13:18:09.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14873" PostTypeId="2" ParentId="13491" CreationDate="2018-01-19T13:43:45.907" Score="4" Body="&lt;p&gt;It's possible your terminal doesn't support italics. Go through &lt;a href=&quot;https://jsatk.us/vim-tmux-italics-and-insanity-9a96b69eeca6&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt; (if you're interested in learning a little) to possibly fix your issue. Start at the paragraph with vimrc in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll provide a tl;dr transcription below&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Transcription of above link.&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;type this into your shell: &lt;code&gt;echo -e &quot;\e[3mfoo\e[23m&quot;&lt;/code&gt; if it shows up in italics, good we're halfway there already.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If it doesn't you might have to &quot;patch&quot; your shell to include italic support. I quote patch because if the terminal doesn't support it, then no matter what you patch in, it won't work. You'd have to try another terminal that does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2a. Enter this command: &lt;code&gt;infocmp -L $TERM &amp;gt; $TERM.terminfo&lt;/code&gt;. It outputs all the details of your current &lt;code&gt;$TERM&lt;/code&gt; in a nice format and puts them in a file that you can edit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2b. Using whatever tool you want, search for the &lt;code&gt;ritm&lt;/code&gt; and &lt;code&gt;sitm&lt;/code&gt;. Since we saw above that italics don't print to your terminal, they shouldn't exist. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2c. Add the following to your $TERM.terminfo file &lt;code&gt;ritm=\E[23m&lt;/code&gt; &amp;amp; &lt;code&gt;sitm=\E[3m&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2d. Compile the new terminfo file by doing this: &lt;code&gt;tic -o ~/. $TERM.terminfo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2e. Kill and restart the tmux server, and you should now have italics capabilities.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add the following to your &lt;code&gt;.vimrc&lt;/code&gt; (Might not be necessary, you should test it on your system)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;set t_ZH=^[[3m&lt;/code&gt; &amp;amp; &lt;code&gt;set t_ZR=^[[23m&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;After all this, you should be good to go.&lt;/p&gt;&#xA;" OwnerUserId="14367" LastEditorUserId="14367" LastEditDate="2018-01-19T16:55:21.927" LastActivityDate="2018-01-19T16:55:21.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14876" PostTypeId="1" CreationDate="2018-01-19T14:57:49.323" Score="1" ViewCount="523" Body="&lt;p&gt;I'm running external command inside vim by &lt;code&gt;:!command&lt;/code&gt;.&lt;br&gt;&#xA;Noticed vim will source .cshrc before run the command, because I've added some echo in the .cshrc.&lt;br&gt;&#xA;Is there a way to force vim don't source the .cshrc?&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-02-06T12:05:31.773" Title="How to disable vim source .cshrc when running external command?" Tags="|external-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14878" PostTypeId="1" AcceptedAnswerId="14881" CreationDate="2018-01-19T15:13:11.167" Score="1" ViewCount="642" Body="&lt;p&gt;I'd like to pull out a variable something like this to save repeating the same thing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:twoLinesStartingWithWords = '^\w\+.*\n\w\+.*'&#xA;&quot;next/previous definition&#xA;nnoremap &amp;lt;Leader&amp;gt;n /\=s:twoLinesStartingWithWords&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;N ?\=s:twoLinesStartingWithWords&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do I need to use the search register or is there a simpler way?&lt;/p&gt;&#xA;" OwnerUserId="1518" LastActivityDate="2018-01-19T15:39:39.073" Title="How do you use variables in a search?" Tags="|search|variables|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14880" PostTypeId="2" ParentId="14868" CreationDate="2018-01-19T15:20:58.257" Score="2" Body="&lt;p&gt;ex is completely part of vim, it is just a special mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Unix-systems there is a program called ex which is in fact a simple symlink to vim (just like gvim, evim, rvim, vimdiff et. al).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim acts on argv[0] (the invokation name) and switches mode accordingly.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-01-19T15:20:58.257" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14881" PostTypeId="2" ParentId="14878" CreationDate="2018-01-19T15:31:23.797" Score="4" Body="&lt;p&gt;You can include variables in mappings by building the map command as a string and executing it with the &lt;code&gt;:execute&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:twoLinesStartingWithWords = '^\w\+.*\n\w\+.*'&#xA;&#xA;execute 'nnoremap &amp;lt;leader&amp;gt;n /' . s:twoLinesStartingWithWords . '&amp;lt;CR&amp;gt;'&#xA;execute 'nnoremap &amp;lt;leader&amp;gt;N ?' . s:twoLinesStartingWithWords . '&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-19T15:39:39.073" LastActivityDate="2018-01-19T15:39:39.073" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14882" PostTypeId="2" ParentId="14868" CreationDate="2018-01-20T02:21:01.283" Score="2" Body="&lt;p&gt;&lt;code&gt;ex&lt;/code&gt; being part of &lt;code&gt;vim&lt;/code&gt; is a modern contrivance, a convenience made possible by the particular way these text editors evolved. &lt;code&gt;ex&lt;/code&gt; is actually a predecessor of &lt;code&gt;vim&lt;/code&gt;/&lt;code&gt;vi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://en.wikipedia.org/wiki/Ex_(text_editor)&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipeida&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The original Unix editor...was the rather user-unfriendly ed. G. Coulouris...developed an improved version called em in 1975. While visiting Berkeley, Coulouris&#xA;  presented his program to Bill Joy, who modified it...it became ex.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;vim&lt;/code&gt; builds on &lt;code&gt;ex&lt;/code&gt; and for the most part&lt;sup&gt;1&lt;/sup&gt; has a super-set of the functionality it is relatively easy to implement &lt;code&gt;ex&lt;/code&gt; with &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ex was eventually given a full-screen visual interface...thereby becoming the vi text editor.&#xA;  &lt;strong&gt;In recent times&lt;/strong&gt;, ex is implemented as a personality of the vi program;&#xA;  most variants of vi still have an &quot;ex mode&quot;, which is invoked using&#xA;  the command ex, or from within vi for one command by typing the :&#xA;  (colon) character. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;sub&gt;I say &quot;for the most part&quot; because, again quoting Wikipedia, &quot;although there is overlap between ex and vi functionality, some things can only be done with ex commands, so it remains useful when using vi.&quot;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-01-20T02:35:38.430" LastActivityDate="2018-01-20T02:35:38.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14883" PostTypeId="1" CreationDate="2018-01-20T04:28:52.927" Score="2" ViewCount="1898" Body="&lt;p&gt;On unix, you can do something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$NVIM_LISTEN_ADDRESS=/some/path nvim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Windows, that does not work. What is the equivalent?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My use case is detailed out here: &lt;a href=&quot;https://github.com/mhinz/neovim-remote/pull/74&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/mhinz/neovim-remote/pull/74&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, &lt;code&gt;neovim-remote&lt;/code&gt; needs to be able to start an nvim process with the &lt;code&gt;NVIM_LISTEN_ADDRESS&lt;/code&gt; variable set on Windows. So far, I have tried the &quot;obvious&quot; thing of just repeating what the Unix syntax is, but that doesn't work. I have also looked at the startup options available by typing in &lt;code&gt;nvim.exe --help&lt;/code&gt;, but none of the options seem relevant to me. &lt;/p&gt;&#xA;" OwnerUserId="15998" LastEditorUserId="15998" LastEditDate="2018-01-20T18:44:33.123" LastActivityDate="2018-08-20T01:01:26.210" Title="How do I set `$NVIM_LISTEN_ADDRESS` on startup using windows?" Tags="|neovim|microsoft-windows|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14884" PostTypeId="1" AcceptedAnswerId="14885" CreationDate="2018-01-20T06:24:39.857" Score="2" ViewCount="554" Body="&lt;p&gt;Simple question: I might have content formatted like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;item1 item2 # this is a comment&#xA;longer_name1 foobarbaz # another comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that I want to see aligned as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;item1        item2     # this is a comment&#xA;longer_name1 foobarbaz # another comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and notice the spaces in the comments are not matched or aligned. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastActivityDate="2018-01-27T10:08:08.643" Title="How can I use Tabularize to align by spaces, but ignore spaces in end-of-line comments?" Tags="|regular-expression|plugin-system|plugin-tabular|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14885" PostTypeId="2" ParentId="14884" CreationDate="2018-01-20T06:28:04.063" Score="2" Body="&lt;p&gt;I solved this problem and wanted to share with everyone: just takes a little regex-magic to match the first space after non-whitespace text, except where it is preceded by a comment character anywhere in the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, you can place these lines in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;expr&amp;gt; -&amp;lt;Space&amp;gt; ':Tabularize /\S\(' . split(&amp;amp;commentstring, '%s')[0] . '.*\)\@&amp;lt;!\zs\ /l0&amp;lt;CR&amp;gt;'&#xA;nnoremap &amp;lt;expr&amp;gt; -&amp;lt;Space&amp;gt; ':Tabularize /\S\(' . split(&amp;amp;commentstring, '%s')[0] . '.*\)\@&amp;lt;!\zs\ /l0&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note we can detect the filetype comment-character by parsing &lt;code&gt;&amp;amp;commentstring&lt;/code&gt; (try &lt;code&gt;:echo &amp;amp;commentstring&lt;/code&gt; to see what it looks like). You can also replace that call to &lt;code&gt;split()&lt;/code&gt; as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;expr&amp;gt; -&amp;lt;Space&amp;gt; ':Tabularize /\S\(' . b:NERDCommenterDelims['left'] . '.*\)\@&amp;lt;!\zs\ /l0&amp;lt;CR&amp;gt;'&#xA;nnoremap &amp;lt;expr&amp;gt; -&amp;lt;Space&amp;gt; ':Tabularize /\S\(' . b:NERDCommenterDelims['left'] . '.*\)\@&amp;lt;!\zs\ /l0&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you happen to use the NERDCommenter plugin.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Came across a great example of where this is useful today: &lt;strong&gt;case statements in bash scripts&lt;/strong&gt; -- so the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case &quot;$string&quot; in&#xA;  foo) command ;; # here's a command&#xA;  foobarbaz) longer_command ;; # and another one&#xA;  abcdef) f ;; # the last command&#xA;  *) hello ;; # and the default case&#xA;esac&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case &quot;$string&quot; in&#xA;  foo)       command        ;; # here's a command&#xA;  foobarbaz) longer_command ;; # and another one&#xA;  abcdef)    f              ;; # a final command&#xA;  *)         hello          ;; # default case&#xA;esac&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;note again that the spaces in end-of-line comments are ignored.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2018-01-27T10:08:08.643" LastActivityDate="2018-01-27T10:08:08.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14887" PostTypeId="1" CreationDate="2018-01-20T10:03:52.357" Score="1" ViewCount="130" Body="&lt;p&gt;There are many make-variant, maybe the most popular is the &lt;a href=&quot;https://www.gnu.org/software/make/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GNU make&lt;/a&gt;. The vim package contains &lt;code&gt;syntax/make.vim&lt;/code&gt; which related to GNU make.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many people use different make, for example &lt;a href=&quot;https://www.freebsd.org/cgi/man.cgi?make(1)&quot; rel=&quot;nofollow noreferrer&quot;&gt;FreeBSD's make&lt;/a&gt; which has different syntax than GNU make.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does exist syntax file for BSD's make? And if yes, where?&lt;/p&gt;&#xA;" OwnerUserId="11418" LastActivityDate="2018-02-22T19:30:08.210" Title="Does exist BSD's make syntax file?" Tags="|syntax-highlighting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14888" PostTypeId="2" ParentId="14851" CreationDate="2018-01-20T11:35:17.653" Score="29" Body="&lt;h1&gt;Short Answer&lt;/h1&gt;&#xA;&lt;p&gt;Just use the normal interactive buttons. In (regular) vim, pressing &lt;kbd&gt;p&lt;/kbd&gt; drops you into the interactive terminal patch, so it's the interface you're used to.&lt;/p&gt;&#xA;&lt;p&gt;For neovim users: Just enter insert mode (&lt;kbd&gt;i&lt;/kbd&gt;), then it works as a terminal, the cursor goes to 'stage this hunk...' line.&lt;/p&gt;&#xA;&lt;p&gt;In newer versions, you can use &lt;kbd&gt;P&lt;/kbd&gt; instead, and the interface is builtin (not an external terminal).&lt;/p&gt;&#xA;&lt;h1&gt;Long Answer: Don't use &lt;code&gt;p&lt;/code&gt;!&lt;/h1&gt;&#xA;&lt;p&gt;If you're already using &lt;a href=&quot;/questions/tagged/plugin-fugitive&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;plugin-fugitive&amp;#39;&quot; aria-label=&quot;show questions tagged &amp;#39;plugin-fugitive&amp;#39;&quot; rel=&quot;tag&quot; aria-labelledby=&quot;tag-plugin-fugitive-tooltip-container&quot;&gt;plugin-fugitive&lt;/a&gt;, I'd highly recommend learning how to use it &lt;strike&gt;properly&lt;/strike&gt; powerfully.&lt;/p&gt;&#xA;&lt;p&gt;From the &lt;code&gt;:Git&lt;/code&gt; window, you can trigger a number of commands.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;Pro tip:&lt;/em&gt; &lt;kbd&gt;)&lt;/kbd&gt; moves to the next file in the window (and &lt;kbd&gt;(&lt;/kbd&gt; previous). &lt;code&gt;g?&lt;/code&gt; brings up a list of other shortcuts.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/21410/10604&quot;&gt;Another answer&lt;/a&gt; covers recent updates to the status window that may be even easier to use for patch-like adding than the diff method below, using &lt;code&gt;-&lt;/code&gt; and &lt;code&gt;=&lt;/code&gt;. This is my preferred method.&lt;/p&gt;&#xA;&lt;p&gt;You can hit &lt;kbd&gt;dd&lt;/kbd&gt; on any file to bring up a &lt;code&gt;:Gdiffsplit&lt;/code&gt; window. This window will show you the differences between the file on disk and the file in the git index. You add pieces to the git index (simulating &lt;code&gt;git add --patch&lt;/code&gt;), but in a much more &amp;quot;vim-like&amp;quot; way.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;Pro tip:&lt;/em&gt; in any vimdiff window (including &lt;code&gt;:Gdiffsplit&lt;/code&gt;), use &lt;code&gt;]c&lt;/code&gt; and &lt;code&gt;[c&lt;/code&gt; to jump between diffs&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The working copy is always on the &lt;strong&gt;right&lt;/strong&gt;, and the version in the index is always on the &lt;strong&gt;left&lt;/strong&gt;. Note that updating the index ('patching' pieces of the file) is as simple as pulling changes from the working copy to the index. We have the commands &lt;code&gt;do&lt;/code&gt; and &lt;code&gt;dp&lt;/code&gt; for this. Which to run depends on where you are.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;do&lt;/code&gt; (or 'diff-obtain'--&lt;code&gt;:diffget&lt;/code&gt;) &lt;em&gt;pulls&lt;/em&gt; the nearby diff over from the other side&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dp&lt;/code&gt; (or 'diff-put'--&lt;code&gt;:diffput&lt;/code&gt;) &lt;em&gt;puts&lt;/em&gt; the nearby diff in the other side&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The result? From the working copy, use &lt;code&gt;dp&lt;/code&gt; to add changes you want to stage, or &lt;code&gt;do&lt;/code&gt; to reset changes. (You can actually also run these from the index, but it's slightly less intuitive to me.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:diffget&lt;/code&gt; and &lt;code&gt;:diffput&lt;/code&gt; work with ranges (read: visual mode), if you don't want to stage an entire diff hunk at once.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;Tip:&lt;/em&gt; if the colors look weird, try &lt;code&gt;:diffupdate&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h2&gt;I added changes to the index, now what?&lt;/h2&gt;&#xA;&lt;p&gt;Write the &lt;strong&gt;index&lt;/strong&gt; file (e.g. &lt;code&gt;:w&lt;/code&gt;) and watch the status window update!&lt;/p&gt;&#xA;&lt;h3&gt;References&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimcasts.org/episodes/fugitive-vim-working-with-the-git-index/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimcast on fugitive and the git index&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fugitive help&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Vim help&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2023-06-05T19:00:24.850" LastActivityDate="2023-06-05T19:00:24.850" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="14889" PostTypeId="1" AcceptedAnswerId="14890" CreationDate="2018-01-20T21:11:33.257" Score="2" ViewCount="3466" Body="&lt;p&gt;How does one enter (and view) italic text in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am interested in a keymap by which I can toggle to &quot;italic mode&quot; and back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example from the &lt;a href=&quot;https://peterodding.com/code/vim/notes/&quot; rel=&quot;nofollow noreferrer&quot;&gt;infopage of a certain vim plugin&lt;/a&gt;: see the text under the heading Text Styles&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IlAkP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IlAkP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11449" LastEditorUserId="11449" LastEditDate="2018-01-20T21:48:05.587" LastActivityDate="2018-01-21T08:58:48.317" Title="Entering italic text in vim" Tags="|word-processing|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14890" PostTypeId="2" ParentId="14889" CreationDate="2018-01-20T21:42:19.967" Score="7" Body="&lt;p&gt;TLDR: There is no such thing. Vim edits plain text, and there is no &quot;italic mode&quot; or anything like that.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To be more specific: Vim is not a word processor. You are confusing file formats and how they render in typical WYSIWYG interfaces (like Microsoft Word) with a text editor, like Vim, Emacs, Notepad, etc. The latter, including Vim, only edits plain text regardless of the file format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be more nuanced: There are different file formats, and in some file formats, Vim uses syntax highlighting to show formatted text in e.g. italics. As an example, if you use Vim to edit a file in the Markdown format, you could (with the right setup) make text between pairs of &lt;code&gt;*&lt;/code&gt; appear italized.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The question was updated with an example that indicates more about what is wanted. Here is a general remark: With a plugin like &lt;a href=&quot;https://peterodding.com/code/vim/notes/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-notes&lt;/a&gt;, syntax highlighting is used to provide italics in Vim. To make this work, one either has to use a terminal that supports italics (and bold font and so on), or to use a gui variant such as gvim. Further, one has to have the &lt;code&gt;conceal&lt;/code&gt; feature. Most Vim's tend to have this nowadays. Finally, to get the italized font, you need to use the specified syntax, which is &lt;code&gt;_text in italics_&lt;/code&gt; for this particular plugin.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2018-01-21T08:58:48.317" LastActivityDate="2018-01-21T08:58:48.317" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14891" PostTypeId="1" AcceptedAnswerId="14898" CreationDate="2018-01-20T23:20:43.747" Score="2" ViewCount="1674" Body="&lt;p&gt;At work I usually keep only a few files in buffer, typically a Yang file, a Java file, and possibly something like a readme file. In such an environment, the Yang syntax highlighting does not work. Example &quot;run&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim yangfile.yang # Yang syntax highlighting works&#xA;:e Foo.java         # new or existing file, doesnt'matter&#xA;:bnext              # Yang syntax highlighting is gone, all text is white&#xA;:so ~/.vimrc        # this does not work&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; is quite small, it starts with &lt;code&gt;source ~/yang.vim&lt;/code&gt; (this file is available &lt;a href=&quot;http://www.yang-central.org/twiki/pub/Main/YangTools/yang.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;) and then less than 50 more lines of pretty basic Vim configurations (I can edit my question to include the entire &lt;code&gt;.vimrc&lt;/code&gt; on request).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix this problem? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="15223" LastActivityDate="2018-01-21T17:14:48.373" Title="Syntax highlighting gone when using buffer" Tags="|syntax-highlighting|buffers|filetype-java|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14893" PostTypeId="1" CreationDate="2018-01-21T07:46:38.747" Score="-1" ViewCount="89" Body="&lt;p&gt;How do I find out the value of an option? I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo ignorecase&#xA;:echo g:ignorecase&#xA;:echo v:ignorecase&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;None of these work.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-01-21T08:58:22.390" Title="How do I find out the value of an option?" Tags="|variables|" AnswerCount="1" CommentCount="1" ClosedDate="2018-01-21T19:00:22.730" ContentLicense="CC BY-SA 3.0" />
  <row Id="14894" PostTypeId="2" ParentId="14893" CreationDate="2018-01-21T08:58:22.390" Score="4" Body="&lt;p&gt;To find out the value of an option, use either:&#xA;&lt;code&gt;set option?&lt;/code&gt; (e.g. add the questionmark to the option name)&#xA;or use &lt;code&gt;:echo &amp;amp;option&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is described at &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-option&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h expr-option&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-01-21T08:58:22.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14895" PostTypeId="1" CreationDate="2018-01-21T10:11:43.130" Score="1" ViewCount="73" Body="&lt;p&gt;I would like to find a plugin, what can do the following in normal mode of vim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Parameter initialization&lt;/li&gt;&#xA;&lt;li&gt;Parameter substitution into text based on templates&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Suppose we have many sql query where &lt;code&gt;country_code&lt;/code&gt; can change but the other conditions are always the same :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;select * from customers c where c.id= ... c.country_code=36 &#xA;select * from product p where p.name= ... p.country_code=36&#xA;.... several other query with ... country_code=36&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, the plugin can replace the &lt;code&gt;:cc&lt;/code&gt; to &lt;code&gt;36&lt;/code&gt; and result can be on the clipboard, or buffer but I dont want to touch the original queries, i want to keep them as templates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="16010" LastEditorUserId="1841" LastEditDate="2018-01-21T18:48:49.020" LastActivityDate="2018-01-21T18:48:49.020" Title="parameter substitution template plugin" Tags="|substitute|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="14897" PostTypeId="1" CreationDate="2018-01-21T16:29:12.233" Score="2" ViewCount="326" Body="&lt;p&gt;I have a bash_file that operates on a latex file to produce a pdf.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;/usr/bin/pandoc/ filein.md -t beamer -o fileout.md ;&#xA;/usr/bin/pdflatex/ fileother.tex ;&#xA;/usr/bin/evince fileother.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I execute in normal mode&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;! ./bash_file.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it works fine but I cannnot work in vim while I am viewing the pdf&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be in vim normal mode and have a command, that executes the .sh without disturbing my current buffer (so that I can keep working on the tex file). I want something that should work similar to leader-ll leader-lv commands in the vim latex-suite template.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I do this? Thanks :) &lt;/p&gt;&#xA;" OwnerUserId="11895" LastEditorUserId="205" LastEditDate="2018-01-23T05:55:40.050" LastActivityDate="2019-02-12T07:41:41.380" Title="How to execute a bash command from the normal mode and send the output on a different buffer?" Tags="|buffers|external-command|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14898" PostTypeId="2" ParentId="14891" CreationDate="2018-01-21T17:14:48.373" Score="3" Body="&lt;p&gt;Thanks to David Ben Knoble's comment I was able to find relevant information and solve my problem. I did as follows and it worked for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;.vimrc&lt;/code&gt;, remove &lt;code&gt;source ~/yang.vim&lt;/code&gt;, add &lt;code&gt;:syntax on&lt;/code&gt; and &lt;code&gt;:filetype plugin on&lt;/code&gt; (I added them to the top of the file). Inside vim (normal mode), type &lt;code&gt;:set runtimepath?&lt;/code&gt;. In my case one of the directories printed was &lt;code&gt;~/.vim&lt;/code&gt;. Move &lt;code&gt;yang.vim&lt;/code&gt; to &lt;code&gt;~/.vim/syntax&lt;/code&gt; (create if needed). Finally, create &lt;code&gt;~/.vim/ftdetect/yang.vim&lt;/code&gt; (create subdir if needed) and enter the following in that file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.yang set filetype=yang&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Done and done. Useful links:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://medium.com/usevim/vim-101-runtimepath-83194d411b0a&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim 101: runtimepath&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Creating_your_own_syntax_files&quot; rel=&quot;nofollow noreferrer&quot;&gt;Creating your own syntax files&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15223" LastActivityDate="2018-01-21T17:14:48.373" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14899" PostTypeId="2" ParentId="14897" CreationDate="2018-01-21T19:13:11.813" Score="2" Body="&lt;p&gt;If you start vim in a folder which contains the file &lt;code&gt;foo.sh&lt;/code&gt; with the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;&#xA;echo &quot;Output of the bash script&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can open a new buffer (&lt;code&gt;:enew&lt;/code&gt; for example) and execute the script and get it's output in this new buffer with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:read ! ./foo.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your new buffer will contain:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Output of the bash script&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;read&lt;/code&gt; executes a command and insert its standard output below the cursor and &lt;code&gt;!&lt;/code&gt; executes a command in the shell (here the command is &lt;code&gt;./foo.sh&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course if you use it often you can make it a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    command! MyCommand enew | read ! ./test.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;:MyCommand&lt;/code&gt; will open the new buffer and read the output of your script into the new buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#%3aread&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :read&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3a%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :!&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-01-21T19:13:11.813" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14900" PostTypeId="2" ParentId="14887" CreationDate="2018-01-21T19:26:57.930" Score="1" Body="&lt;p&gt;From the point of view of syntax highlighting, GNU make and BSD make should be very close to identical. GNU make is a super-set of POSIX make (which is very close to what BSD uses), so there might be a few syntax highlighting options available for GNU make that you won't use with BSD make, but I don't think that you'll end up with any syntax in BSD make that's missing.&lt;/p&gt;&#xA;" OwnerUserId="2797" LastActivityDate="2018-01-21T19:26:57.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14901" PostTypeId="1" AcceptedAnswerId="14930" CreationDate="2018-01-21T20:19:38.573" Score="1" ViewCount="159" Body="&lt;p&gt;Right now I am using Pathogen to manage bundles in my &lt;code&gt;~/.vim&lt;/code&gt; folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have my public &lt;code&gt;dotfiles&lt;/code&gt; repo which has all my configs, including my entire &lt;code&gt;.vim&lt;/code&gt; folder. I don't use symlinks to do this, because it has been a nightmare doing it that way. Whenever I want to update my &lt;code&gt;dotfiles&lt;/code&gt; repo I just copy and paste the whole &lt;code&gt;.vim&lt;/code&gt; folder periodically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to download all repos manually from GitHub and update them that way, but I just redid everything using &lt;code&gt;git clone&lt;/code&gt; so that I can update all my local vim bundles easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem now though is that I can't commit these repos... I suppose I can do something with submodules but I don't know the logistics of that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can make pathogen just re-download all the repos if I just give it some git paths? That would be ideal, so that whenever someone uses my dotfiles they just download the fresh versions with one command, kind of like how &lt;code&gt;npm&lt;/code&gt; works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are my other options to solve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goals are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I can easily update my own bundles with a recursive &lt;code&gt;git pull&lt;/code&gt; or some other easy command&lt;/li&gt;&#xA;&lt;li&gt;I can commit this so that other people using my dotfiles can run that same command&lt;/li&gt;&#xA;&lt;li&gt;I don't want to use symlinks&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: This might be a wack idea, but what if I just create a vim function which pulls the repos, and I place that command right in my &lt;code&gt;.vimrc&lt;/code&gt;. This command would pull the repos, that way I can install/update all in the same command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there, I would just decide 'what' bundles go in my &lt;code&gt;.vim&lt;/code&gt; folder by modifying that one list. I imagine some plugin out there does this already?&lt;/p&gt;&#xA;" OwnerUserId="16016" LastEditorUserId="16016" LastEditDate="2018-01-21T20:26:40.123" LastActivityDate="2018-01-23T13:35:14.437" Title="Commiting pathogen bundles?" Tags="|vimrc|git|plugin-pathogen|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14902" PostTypeId="2" ParentId="14883" CreationDate="2018-01-21T20:24:27.160" Score="0" Body="&lt;p&gt;You can temporarily set the environment variable &lt;code&gt;NVIM_LISTEN_ADDRESS&lt;/code&gt; to point to a file of interest. Then, any &lt;code&gt;nvim&lt;/code&gt; process that is started will have that as its listen address. Thus, you don't need to pass it in as an option to the program (and in fact, the unix code I shared in the question probably does not do that).&lt;/p&gt;&#xA;" OwnerUserId="15998" LastActivityDate="2018-01-21T20:24:27.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14903" PostTypeId="1" CreationDate="2018-01-21T20:40:51.303" Score="1" ViewCount="48" Body="&lt;p&gt;I really don't know how to explain this, but when I get an error in the cmdline with some linters (Ale and Syntastic for example), it shifts up and basically breaks the view of my code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim itself doesn't shift along with it. Almost like the new lines that are a result of error expanding up write empty lines over the lines of the file. It doesn't edit the file, but the view doesn't update and I have to go over the file with cursor to force a rerender.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have attached a &lt;a href=&quot;https://streamable.com/s8oy5&quot; rel=&quot;nofollow noreferrer&quot;&gt;video to explain&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also here is my &lt;a href=&quot;https://raw.githubusercontent.com/rtaibah/.dotfiles/master/.vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;.vimrc file&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16015" LastActivityDate="2018-01-21T20:40:51.303" Title="Vim cmdline breaks my view of a file when outputting errors from linters" Tags="|vimrc|error|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14904" PostTypeId="1" AcceptedAnswerId="14910" CreationDate="2018-01-22T05:55:05.060" Score="2" ViewCount="3202" Body="&lt;p&gt;When editing a dos-format file from a codebase which is mainly used with Visual Studio in a Windows environment on my local Ubuntu machine with VIM, I get to see the ^M character instead of a newline.&lt;/p&gt;&#xA;&lt;p&gt;According to the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/digraph.html#digraph-table&quot; rel=&quot;nofollow noreferrer&quot;&gt;VIM documentation&lt;/a&gt;, this represents the carriage return character.&lt;/p&gt;&#xA;&lt;p&gt;Further complicating the problem is that this only occurs in certain places in the file, so the newlines don't seem to have a &lt;em&gt;consistent&lt;/em&gt; format.&lt;/p&gt;&#xA;&lt;p&gt;By default, VIM recognizes the file as dos file-format, which I see by executing &lt;code&gt;:set ff?&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My goal is to edit the file without breaking its platform conformity; I don't want to persistently &lt;em&gt;convert&lt;/em&gt; the file, only because I'm editing in VIM. Hence, the &lt;a href=&quot;https://stackoverflow.com/a/5843561/3646263&quot;&gt;existing answer&lt;/a&gt; doesn't satisfy my problem. &lt;a href=&quot;https://stackoverflow.com/a/22816221/3646263&quot;&gt;This answer&lt;/a&gt;, doesn't either.&lt;/p&gt;&#xA;&lt;p&gt;Given this requirement, can I get VIM to just &lt;em&gt;display&lt;/em&gt; all ^M's as newlines via some syntax highlighting setting?&lt;/p&gt;&#xA;&lt;p&gt;Note that ^M isn't composed out of plain characters. If you'd insert them manually in VIM, you'd have to insert Cntr-V before inserting each character.&lt;/p&gt;&#xA;" OwnerUserId="11449" LastEditorUserId="11449" LastEditDate="2021-03-22T12:01:17.467" LastActivityDate="2021-03-22T12:01:17.467" Title="View ^M as newline in vim without persistent file conversion" Tags="|file-formats|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="14905" PostTypeId="1" CreationDate="2018-01-22T06:05:08.053" Score="2" ViewCount="63" Body="&lt;p&gt;I don't look at my keyboard when I type (I don't think a lot of people do these days) and I catch myself occasionally pressing 'u' in visual mode by mistake. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This causes all the text in a visual bloc to go lower case. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's happened multiple times and I would really want to disable this functionality. I am aware that I can use &lt;code&gt;~&lt;/code&gt; to change case. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I disable &lt;code&gt;u&lt;/code&gt; during visual mode (lowercasing) but not &lt;code&gt;u&lt;/code&gt; (undo)? &lt;/p&gt;&#xA;" OwnerUserId="11727" LastActivityDate="2018-01-22T06:17:27.410" Title="Disable lowercasing through 'u'" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14906" PostTypeId="2" ParentId="14905" CreationDate="2018-01-22T06:17:27.410" Score="3" Body="&lt;p&gt;You can map &lt;code&gt;u&lt;/code&gt; to a no-op in visual mode with the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vmap u &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That won't affect the behavior of &lt;code&gt;u&lt;/code&gt; in normal mode. See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help &amp;lt;Nop&amp;gt;&#xA;:help map-modes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2018-01-22T06:17:27.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14907" PostTypeId="1" CreationDate="2018-01-22T08:01:46.947" Score="4" ViewCount="4647" Body="&lt;p&gt;I use Plug as my plugin manager and have this line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Plug 'MyPlugin', { 'for' : 'c'}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which means it should only load the plugin &lt;code&gt;MyPlugin&lt;/code&gt; when a file of the filetype &lt;code&gt;c&lt;/code&gt; is opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works fine, but right after that I have a function call: &lt;code&gt;call MyPlugin#doSomething(...)&lt;/code&gt; which leads to an error everytime I dont open a file of the filetype  &lt;code&gt;c&lt;/code&gt;. is there some kind of if statement to check if the plugin &lt;code&gt;MyPlugin&lt;/code&gt; has been loaded?&lt;/p&gt;&#xA;" OwnerUserId="16021" LastEditorUserId="343" LastEditDate="2018-01-22T10:52:25.353" LastActivityDate="2020-03-18T15:58:49.813" Title="Call function only when the plugin is loaded" Tags="|plugin-system|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14910" PostTypeId="2" ParentId="14904" CreationDate="2018-01-22T10:06:50.673" Score="4" Body="&lt;h2&gt;&lt;code&gt;^M&lt;/code&gt; visible with &lt;code&gt;ff=dos&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;set ff?&lt;/code&gt; reports that the file is &lt;code&gt;dos&lt;/code&gt; and you are seeing &lt;code&gt;^M&lt;/code&gt; carriage return characters at the end of &lt;em&gt;any&lt;/em&gt; lines, then your file already has broken, non-conforming line-endings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. if the file displays like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;regular line&#xA;another regular line&#xA;line with an extra carriage return^M&#xA;third regular line    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means that the actual content of your file looks something like (broken into lines for clarity):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;regular line^M^J&#xA;another regular line^M^J&#xA;line with an extra carriage return^M^M^J&#xA;third regular line^M^J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this is the case, the appropriate cause of action is simply to delete the extra carriage return and to look into how the file came to have such odd line endings.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;code&gt;^M&lt;/code&gt; visible with &lt;code&gt;ff=unix&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A more common scenario is that you have a file with mixed endings. This would result in a file where certain (dos-formatted) lines are displayed with a &lt;code&gt;^M&lt;/code&gt; at the end of the line. If you were seeing a file like this, however, &lt;code&gt;:set ff?&lt;/code&gt; would report &lt;code&gt;unix&lt;/code&gt;, not &lt;code&gt;dos&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This scenario can be fixed by adding carriage returns to lines which do not have them. I usually do this by yanking a carriage return from one of the lines that has one, and then using a &lt;code&gt;:global&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/[^\r]$/norm! $p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. As far as I am aware, you cannot easily perform the above fix with a &lt;code&gt;:substitute&lt;/code&gt; command, because the carriage return in the replacement would be interpreted as a newline and instead a linefeed will be added.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The carriage returns will still be visible after running command, but when you save and reopen, Vim will reinterpret the file as &lt;code&gt;dos&lt;/code&gt; format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative fix is to remove &lt;em&gt;all&lt;/em&gt; the carriage returns at the end of lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\r$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This leaves you with a file with &lt;code&gt;unix&lt;/code&gt; line endings, but it's easy to get Vim to convert these back into &lt;code&gt;dos&lt;/code&gt; line endings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set fileformat=dos&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;UPDATE: &lt;code&gt;^M&lt;/code&gt; &lt;em&gt;instead&lt;/em&gt; of newlines&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It turns out that what the OP is seeing is something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;first line^Msecond line&#xA;third line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means that some of the line-endings don't contain linefeeds at all, they are &lt;em&gt;just&lt;/em&gt; a carriage return. (This is old &quot;Classic&quot; MacOS style for line-endings&amp;#8202;&amp;mdash;&amp;#8202;&lt;code&gt;mac&lt;/code&gt; in &lt;code&gt;'fileformats'&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly to the situations described above, this is incorrect in a &lt;code&gt;dos&lt;/code&gt; formatted file: the file &lt;em&gt;is&lt;/em&gt; malformed, even if Visual Studio displays it in a way that &lt;em&gt;looks&lt;/em&gt; correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be fixed with the following confusing &lt;code&gt;:substitute&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\r/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, the command doesn't actually replace all carriage returns with carriage returns!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &quot;search&quot; part of the command the &lt;code&gt;\r&lt;/code&gt; carriage return will only match the ones that are not being using in a CRLF line-ending pair. In the &quot;replace&quot; part, the carriage return is interpreted as a newline, splitting the lines correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After making the edit, the file will now be correctly formatted with &lt;code&gt;dos&lt;/code&gt; endings throughout, and so will display correctly both in Vim and Visual Studio.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Viewing the actual contents with &lt;code&gt;xxd&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Vim comes with a hex editor that can be used to view (or edit) the byte-level contents of the file. If you're sceptical about what I've written above, you can double-check what actual line-endings are being used with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!xxd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. &lt;strong&gt;This will replace the contents of your file&lt;/strong&gt; with a hex-dump: when you are done, press &lt;code&gt;u&lt;/code&gt; to undo the change and return to your file.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regular contents are displayed on the right, the corresponding hex-codes on the left. On the right-hand side, both carriage returns and linefeeds are displayed as dots, so a unix line-ending will be shown as &lt;code&gt;.&lt;/code&gt; a dos line ending as &lt;code&gt;..&lt;/code&gt; and a dos ending with an extra carriage return as &lt;code&gt;...&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-22T14:30:53.613" LastActivityDate="2018-01-22T14:30:53.613" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14911" PostTypeId="2" ParentId="14907" CreationDate="2018-01-22T12:10:16.737" Score="3" Body="&lt;p&gt;In the case of autoload functions, what I usually do is the following&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I check whether the function is known&lt;/li&gt;&#xA;&lt;li&gt;If not I explicitly try-to-source its autoload plugin, with &lt;code&gt;:runtime&lt;/code&gt; that takes care of &lt;code&gt;&amp;amp;rtp&lt;/code&gt;, and that fails silently.&lt;/li&gt;&#xA;&lt;li&gt;I check again whether the function is known&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;IOW:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ! exists('*MyPlugin#doSomething')&#xA;   runtime autoload/MyPlugin.vim&#xA;endif&#xA;if exists('*MyPlugin#doSomething')&#xA;    call MyPlugin#doSomething(args)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: that if your plugin is mainly made of ftplugin and of autoloaded scripts, I don't see the point of the &lt;code&gt;{ 'for' : 'c'}&lt;/code&gt; specification.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-01-22T12:35:41.813" LastActivityDate="2018-01-22T12:35:41.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14912" PostTypeId="1" CreationDate="2018-01-22T12:53:22.423" Score="2" ViewCount="1254" Body="&lt;p&gt;I've created a local syntax file def.vim and saved in ~/.vim/syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First it's working, but just after I closed gvim and several other windows, it stops working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First I checked &lt;code&gt;:scriptnames&lt;/code&gt;. Local def.vim is loaded.&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/JBnc7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JBnc7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also checked syntax list.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/wraZn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wraZn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just don't understand why suddenly it stops working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is local def.vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Vim syntax file&#xA;&quot; Language:     DEF &#xA;&#xA;&quot; def register definition&#xA;if exists(&quot;b:current_syntax&quot;)&#xA;  finish&#xA;endif&#xA;&#xA;&quot; let s:cpo_save =&quot;  &amp;amp;cpo&#xA;&quot; set cpo&amp;amp;vim&#xA;&#xA;&quot; case is not significant&#xA;syn case ignore&#xA;&#xA;&quot; def keywords&#xA;syn keyword defStatement endf endg endr &#xA;syn keyword defStatement field&#xA;syn keyword defStatement group&#xA;syn keyword defStatement register&#xA;syn keyword defStatement version&#xA;&#xA;&quot; syn match   defStatement &quot;\&amp;lt;\(field\|endf\)\&amp;gt;&quot;&#xA;&quot; syn match   defStatement &quot;\&amp;lt;\(register\|endr\)\&amp;gt;&quot;&#xA;&quot; syn match   defStatement &quot;\&amp;lt;\(group\|endg\)\&amp;gt;&quot;&#xA;&#xA;&quot; &quot; Predefined VHDL types&#xA;&quot; syn keyword defType desc title default split readonly&#xA;&#xA;&quot; syn match  defVector &quot;0B[01_]\+&quot;&#xA;&quot; syn match  defVector &quot;0O[0-7_]\+&quot;&#xA;syn match  defVector &quot;0X[0-9a-f_]\+&quot;&#xA;syn match  defVector &quot;\[[0-9]\+ \.\. [0-9]\+\]&quot;&#xA;&quot; syn match  defCharacter &quot;'.'&quot;&#xA;&quot; syn region defString start=+&quot;+  end=+&quot;+ contains=@Spell&#xA;&#xA;&quot; syn match defComment &quot;--.*$&quot; contains=@Spell&#xA;&quot; syn match defComment &quot;{.*}&quot; contains=@Spell&#xA;&#xA;let b:current_syntax = &quot;def&quot;&#xA;&#xA;&quot; let &amp;amp;cpo = s:cpo_save&#xA;&quot; unlet s:cpo_save&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="13402" LastEditDate="2018-01-22T12:59:46.557" LastActivityDate="2018-05-22T15:10:57.843" Title="Why local syntax file is not working?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14913" PostTypeId="2" ParentId="14912" CreationDate="2018-01-22T13:40:25.937" Score="1" Body="&lt;p&gt;Found the reason, need to add below highlight links.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HiLink cDefine      PreProc      &#xA;HiLink defSpecial   Special&#xA;HiLink defStatement Statement&#xA;HiLink defCharacter String&#xA;HiLink defString    String&#xA;HiLink defVector    String&#xA;HiLink defBoolean   String&#xA;HiLink defComment   Comment&#xA;HiLink defNumber    String&#xA;HiLink defTime      String&#xA;HiLink defType      Type&#xA;HiLink defOperator  Type&#xA;HiLink defGlobal    Error&#xA;HiLink defAttribute Type&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-01-22T13:40:25.937" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14914" PostTypeId="2" ParentId="14907" CreationDate="2018-01-22T14:03:36.307" Score="7" Body="&lt;p&gt;Rather than have my &lt;code&gt;~/.vimrc&lt;/code&gt; load a plugin ahead of when it would normally be loaded, I usually solve this problem in one of two ways.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Call the function in a &lt;code&gt;~/.vimrc/after/plugin/MyPlugin.vim&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;if exists('*MyPlugin#doSomething')&#xA;    call MyPlugin#doSomething(args)&#xA;endif&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Call the function in an autocommand in your &lt;code&gt;~/.vimrc&lt;/code&gt; so that it will be executed after plugins are loaded.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au VimEnter * if exists('*MyPlugin#doSomething') | call MyPlugin#doSomething(args) | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="626" LastEditDate="2018-01-22T14:40:30.883" LastActivityDate="2018-01-22T14:40:30.883" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14915" PostTypeId="1" CreationDate="2018-01-22T14:40:15.363" Score="0" ViewCount="543" Body="&lt;p&gt;I'll leave ? at the beginning of a commented line to mark a todo item.&lt;br&gt;&#xA;&lt;code&gt;-- ? TODO ...&lt;/code&gt;&lt;br&gt;&#xA;This line will be marked as comment.&lt;br&gt;&#xA;How to highlight the ? and the remaining text by Todo color while keep the -- as comment color? &lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-01-22T15:05:15.830" Title="How to highlight todo in a comment line?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14916" PostTypeId="2" ParentId="14915" CreationDate="2018-01-22T14:52:53.850" Score="1" Body="&lt;p&gt;You'll need to know what syntax item your filetype uses for comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only languages I know that use &lt;code&gt;--&lt;/code&gt; as a comment marker are Ada and MySQL. For these, use the following lines, respectively:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Todo /--\s*\zs?.*/ containedin=adaComment&#xA;syntax match Todo /--\s*\zs?.*/ containedin=mysqlComment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We're matching the entire comment (because we don't want question marks halfway through a comment to be marked as TODO items), but using &lt;code&gt;\zs&lt;/code&gt; to tell Vim to only start highlighting at the &lt;code&gt;?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Breaking down the regular expression:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;--\s*&lt;/code&gt;: Match two dashes followed by any amount of whitespace,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs&lt;/code&gt;: &quot;Start&quot; the match,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;?&lt;/code&gt;: Match a question mark,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*&lt;/code&gt;: Match anything else that follows on that line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-22T15:05:15.830" LastActivityDate="2018-01-22T15:05:15.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14917" PostTypeId="1" AcceptedAnswerId="14919" CreationDate="2018-01-22T15:55:59.680" Score="0" ViewCount="1577" Body="&lt;p&gt;Can add() and insert() be performed on a dictionary? The help file is unclear on this. If so, what is the correct syntax?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If these functions do not work on dictionaries, then how can I add or insert items to the dictionary?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2021-10-25T02:34:38.087" Title="Can add() and insert() be performed on a dictionary?" Tags="|dictionary|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14918" PostTypeId="2" ParentId="14917" CreationDate="2018-01-22T16:02:15.727" Score="2" Body="&lt;p&gt;Maybe you are looking to the wrong part of the documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#dict%2dfunctions&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help dict-functions&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Dictionary manipulation:                *dict-functions*&#xA;            get()           get an entry without an error for a wrong key&#xA;            len()           number of entries in a Dictionary&#xA;            has_key()       check whether a key appears in a Dictionary&#xA;            empty()         check if Dictionary is empty&#xA;            remove()        remove an entry from a Dictionary&#xA;   --&amp;gt;      extend()        add entries from one Dictionary to another&#xA;            filter()        remove selected entries from a Dictionary&#xA;            map()           change each Dictionary entry&#xA;            keys()          get List of Dictionary keys&#xA;            values()        get List of Dictionary values&#xA;            items()         get List of Dictionary key-value pairs&#xA;            copy()          make a shallow copy of a Dictionary&#xA;            deepcopy()      make a full copy of a Dictionary&#xA;            string()        String representation of a Dictionary&#xA;            max()           maximum value in a Dictionary&#xA;            min()           minimum value in a Dictionary&#xA;            count()         count number of times a value appears&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additional information and examples can be found at &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#41.8&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 41.8&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This only works for a key that is made of ASCII letters, digits and the&#xA;underscore.  You can also assign a new value this way: &amp;gt;&#xA;&#xA;        :let uk2nl.four = 'vier'&#xA;        :echo uk2nl&#xA;    {'three': 'drie', 'four': 'vier', 'one': 'een', 'two': 'twee'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2018-01-22T16:36:54.260" LastActivityDate="2018-01-22T16:36:54.260" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14919" PostTypeId="2" ParentId="14917" CreationDate="2018-01-22T21:42:57.850" Score="6" Body="&lt;p&gt;Dictionaries aren't ordered, so there's no need for &lt;code&gt;add()&lt;/code&gt; or &lt;code&gt;insert()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Values are added to a dictionary using either&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let d.foo = 'bar'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let d['foo'] = 'bar'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also suggest reviewing &lt;a href=&quot;https://vimhelp.appspot.com/usr_41.txt.html#41.8&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 41.8&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#Dictionary&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help Dictionary&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2018-01-22T21:49:36.383" LastActivityDate="2018-01-22T21:49:36.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14920" PostTypeId="1" CreationDate="2018-01-23T00:08:28.880" Score="0" ViewCount="61" Body="&lt;p&gt;So in vim usually I press&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v j j j &amp;gt; esc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then &lt;code&gt;gv&lt;/code&gt; to reselect so that I can indent a couple of lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can we reselect in VI?&lt;/p&gt;&#xA;" OwnerUserId="15942" LastEditorUserId="1841" LastEditDate="2018-01-26T08:04:19.757" LastActivityDate="2018-01-26T08:04:19.757" Title="sublimetext vintage mode, vs VIM trying to find a substitute for a shortcut key" Tags="|indentation|visual-mode|" AnswerCount="1" CommentCount="2" ClosedDate="2018-01-26T08:02:20.567" ContentLicense="CC BY-SA 3.0" />
  <row Id="14921" PostTypeId="2" ParentId="14920" CreationDate="2018-01-23T00:40:16.907" Score="2" Body="&lt;p&gt;vi does not have a visual mode and hence does not have the maps &lt;code&gt;v&lt;/code&gt;, &lt;code&gt;gv&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More precisely, in vi (the &quot;visual&quot; editor), the &lt;em&gt;normal&lt;/em&gt; mode which you are in by default when starting vi is sometimes called visual mode.  In vim, this mode is always called normal mode whereas visual mode always refers to a distinct mode which allows text selection.  vi has no mode which corresponds to vim's visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is at least one legacy usage of this previous terminology in vim- to leave ex mode (after pressing &lt;code&gt;Q&lt;/code&gt;) you have to type &lt;code&gt;:visual&lt;/code&gt; to return to normal mode.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-01-23T00:40:16.907" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14923" PostTypeId="1" AcceptedAnswerId="14939" CreationDate="2018-01-23T05:58:18.307" Score="1" ViewCount="1529" Body="&lt;p&gt;I got this in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set grepprg=grep\ -nriI\ --exclude=tags\ --exclude-dir=vendor&#xA;&#xA;&quot; The Silver Searcher&#xA;if executable('ag')&#xA;  &quot; Use ag over grep&#xA;  let &amp;amp;grepprg = &quot;ag --nogroup --nocolor --ignore wiki --ignore tags --ignore tests --ignore dist -w&quot;&#xA;&#xA;  ..&#xA;endif&#xA;&#xA;&quot; bind \ (backward slash) to grep shortcut&#xA;command -nargs=+ -complete=file -bar Ag silent! grep! &amp;lt;args&amp;gt;|cwindow|redraw!&#xA;nnoremap \ :Ag&amp;lt;SPACE&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I type &lt;kbd&gt;\&lt;/kbd&gt; the prompt turns into &lt;code&gt;:Ag&lt;/code&gt;, when I search for single words, it works like a charm. But when I search for sentences with spaces in between (even if i enclose with &lt;code&gt;&quot;&lt;/code&gt;) nothing works.. how do i fix this?&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="343" LastEditDate="2018-01-24T11:11:34.287" LastActivityDate="2018-01-24T11:51:33.820" Title="my ag shortcut chokes on spaces" Tags="|command-line|external-command|the-silver-searcher|vimgrep|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14924" PostTypeId="1" AcceptedAnswerId="14936" CreationDate="2018-01-23T08:08:01.737" Score="4" ViewCount="1393" Body="&lt;p&gt;I'm looking for a way to make a single configuration file both for windows platform and for unix one. So for now i have two configs .vimrc for unix and _vimrc for windows platform and the only difference between them is a necessary commands to vundle plugin manager. (i desregard the difference with filename, as i aim only to store a common version of file on my dotfiles repo and symlink with the right name at place)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unix:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp+=~/.vim/bundle/Vundle.vim/&#xA;call vundle#rc()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;...&#xA;call vundle#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Win:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp+=$HOME/vimfiles/bundle/Vundle.vim/&#xA;call vundle#begin('$USERPROFILE/vimfiles/bundle/')&#xA;Plugin 'VundleVim/Vundle.vim&#xA;...&#xA;call vundle#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it's boring to maintain changes in both as i'm working on linux as well on windows platform. I guess i could do operating system detection like &lt;code&gt;if has(&quot;win32&quot;)&lt;/code&gt; but i think it's not a good idea to wrap every system dependent statement in construction like this. I'm wondering if there any option to this and how you deal with this.&lt;/p&gt;&#xA;" OwnerUserId="11110" LastActivityDate="2018-01-25T10:02:09.180" Title="Common vimrc config for unix and windows" Tags="|vimrc|plugin-vundle|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14925" PostTypeId="1" CreationDate="2018-01-23T08:30:44.117" Score="0" ViewCount="921" Body="&lt;p&gt;I'm jealous of my co-workers using phpstorm etc to visualize the db schema etc.. I was wondering if there was a solution for that on vim? I googled around and found this&#xA;&lt;a href=&quot;https://github.com/vim-scripts/dbext.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim-scripts/dbext.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;although it seems kind of dated and the documentation seems lacking. help?&lt;/p&gt;&#xA;" OwnerUserId="14510" LastActivityDate="2018-03-09T14:15:45.470" Title="Looking for a good Database Visualization Tool" Tags="|plugin-system|" AnswerCount="2" CommentCount="4" ClosedDate="2018-03-09T14:50:17.733" ContentLicense="CC BY-SA 3.0" />
  <row Id="14926" PostTypeId="2" ParentId="14925" CreationDate="2018-01-23T10:05:30.433" Score="4" Body="&lt;p&gt;As statox explained, Vim is a &lt;em&gt;text editor&lt;/em&gt;, not a database tool, not a coffee machine. But if you want to augment Vim's potential with external tools, you can, and you should!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On your specific question, you really should learn to use your database CLI. It'll give you the best knowledge of what's inside your DB. And because it will be a CLI, you can call it/read from Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, look at &lt;a href=&quot;https://github.com/mattn/vdbi-vim/blob/master/autoload/vdbi.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/mattn/vdbi-vim/blob/master/autoload/vdbi.vim&lt;/a&gt;. It's another DB plugin visualisation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's wrapping the &lt;code&gt;SELECT ...&lt;/code&gt; in functions so you can use them against different DBS. In a nutshell it's &lt;a href=&quot;https://github.com/mattn/vdbi-vim/blob/master/autoload/vdbi.vim#L248&quot; rel=&quot;nofollow noreferrer&quot;&gt;reading from the cli&lt;/a&gt; and &lt;a href=&quot;https://github.com/mattn/vdbi-vim/blob/master/autoload/vdbi.vim#L286&quot; rel=&quot;nofollow noreferrer&quot;&gt;putting it in the buffer&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's cool and all, but it's not using Vim to anything related to the DB. You're using Vim to diplay the result of your query, and manipulate it and &lt;code&gt;:g/re/p&lt;/code&gt; it if you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim is a &lt;em&gt;text editor&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1821" LastActivityDate="2018-01-23T10:05:30.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14927" PostTypeId="2" ParentId="14901" CreationDate="2018-01-23T10:38:45.350" Score="2" Body="&lt;p&gt;I have tried the submodule approach and ... I ended up switching to vim-plug. This is essentially what Vundle, vim-plug etc. do: you provide a list of plugins (or repositories), and Vundle/vim-plug provides you functions or commands to install/update them all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current setup is like this: things in &lt;code&gt;~&lt;/code&gt; in one repo, with a submodule or two for zsh plugins and &lt;code&gt;~/.vim&lt;/code&gt;. So &lt;em&gt;now&lt;/em&gt; my initialization looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone --recursive https://.../home.git&#xA;cp -r home/. ~ &amp;amp;&amp;amp; rm -rf home&#xA;vim -c PlugUpdate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not a one liner, but not particularly complicated either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main reason why I switched to vim-plug was updating the plugins. Updating submodules is an annoyance. This is especially complicated by plugins like YouCompleteMe which themselves include submodules, so you don't want to blindly pull in the latest of everything in every submodule (and so you should be cautious with using recursive updates). I think this can be done safely by adding &lt;a href=&quot;https://stackoverflow.com/a/9189815/2072269&quot;&gt;submodules tracking a branch&lt;/a&gt;, but I'd rather not learn Git that much unless I need to. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But all told, using vim-plug is far easier than messing around with submodules. Note that, unlike Vundle, the vim-plug script is directly added to &lt;code&gt;.vim/autoload&lt;/code&gt;, just like with pathogen, so if you have the &lt;code&gt;.vim&lt;/code&gt; directory, you can just run the &lt;code&gt;PlugInstall&lt;/code&gt; vim command.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;vim-plug also sweetened the deal with conditional installation of plugins - since I didn't want all my plugins everywhere. It doesn't make sense to install, say, vim-go on a server which would never have golang installed. &lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-01-23T10:38:45.350" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14929" PostTypeId="2" ParentId="12484" CreationDate="2018-01-23T12:29:47.047" Score="1" Body="&lt;p&gt;In my case I have found in &lt;code&gt;plugged/vim-snippets/UltiSnips/all.snippets&lt;/code&gt; a snippet called &lt;code&gt;box&lt;/code&gt; that makes something like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----------------------&#xA;-  some text inside  -&#xA;----------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After reading a little bit more the code I figured out that if you set your filetype like &lt;code&gt;:setf c&lt;/code&gt; and type &lt;code&gt;box&amp;lt;tab&amp;gt;&lt;/code&gt;you will get your something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*************&#xA;*  my text  *&#xA;*************/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means you just have to make a slightly different version of &lt;code&gt;all.snippets&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2018-03-02T15:46:38.330" LastActivityDate="2018-03-02T15:46:38.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14930" PostTypeId="2" ParentId="14901" CreationDate="2018-01-23T13:29:12.227" Score="4" Body="&lt;p&gt;Using git submodules is a common way of doing this. The &lt;a href=&quot;http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen/&quot; rel=&quot;nofollow noreferrer&quot;&gt;VimCasts episode&lt;/a&gt; is a great explanation, but the basic commands are as below:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Adding a new plugin&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim&#xA;git submodule add http://github.com/&amp;lt;username&amp;gt;/&amp;lt;pluginname&amp;gt;.git bundle/&amp;lt;pluginname&amp;gt;&#xA;git add .&#xA;git commit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Updating a plugin&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Git submodules are also repositories in their own right:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim/bundle/&amp;lt;pluginname&amp;gt;&#xA;git pull&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Installing/updating plugins on another machine&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim&#xA;git pull&#xA;git submodule update --init&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this workflow is not specific to Pathogen: it works fine using Vim 8's packages feature and file paths.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative to all the above is to delegate installation/upkeep of your plugins to a Plugin Manager. Vim has &lt;a href=&quot;https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers&quot;&gt;plenty of options&lt;/a&gt; if that's the path you choose to take.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-23T13:35:14.437" LastActivityDate="2018-01-23T13:35:14.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14931" PostTypeId="1" CreationDate="2018-01-23T17:50:48.317" Score="1" ViewCount="44" Body="&lt;p&gt;Sometimes I get lost in normal mode. Is there a way to have vim/vi print the last keys pressed, perhaps at the top/bottom of the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in normal mode I may enter the command &lt;code&gt;22gg&lt;/code&gt; to go to line 22.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a somewhat trivial example, however I may accidentally type &lt;code&gt;222gg&lt;/code&gt;. I would like to be able to see what I enter into normal mode somehow. Is this possible or is there a plugin for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: The linked question doesn't seem to resolve the problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've followed the link but it isn't working.&lt;/p&gt;&#xA;" OwnerUserId="3246" LastEditorUserId="205" LastEditDate="2018-01-27T11:33:42.890" LastActivityDate="2018-01-27T11:33:42.890" Title="Is there a way to print the current sequence of command keys in normal mode?" Tags="|normal-mode|" AnswerCount="0" CommentCount="3" ClosedDate="2018-01-24T03:12:50.667" ContentLicense="CC BY-SA 3.0" />
  <row Id="14932" PostTypeId="1" CreationDate="2018-01-24T04:21:31.413" Score="2" ViewCount="1388" Body="&lt;p&gt;My vimrc about wrap is set like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wrap &quot;Wrap lines&#xA;set breakindent &quot; indent after line wrapped&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the wrapped lines are not equal in length, such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 1:   some contents ..... &amp;lt;end&amp;gt;&#xA;          continued line ..... other contents &amp;lt;end&amp;gt;&#xA;line 2: ....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The line 1 and its wrapped line does not agree in length, and neither of them is as long as the longest length the window provides. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes when I write Chinese characters, the line just wrapped at the position of space even though it is not finished, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.&amp;lt;space&amp;gt;&#xA;地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地&#xA;地地地地地地地地地地地地地地地地地地地地寺地&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 1: 地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地地寺地&#xA;        地地地地地地地地地地地地地地地地地地地地地地地地地地地&amp;lt;space&amp;gt;&#xA;        地地地地地地地地地地地地地地地地地地地地地地地地地&#xA;line 2: ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How could I make the wrapped lines the same length, and thus make the paragraph a shape of rectangular?&lt;/p&gt;&#xA;" OwnerUserId="16038" LastEditorUserId="1841" LastEditDate="2018-01-24T08:04:29.827" LastActivityDate="2022-06-07T15:04:55.423" Title="The indent of wrapped lines" Tags="|wrapping|line-breaks|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14933" PostTypeId="1" CreationDate="2018-01-24T05:06:05.860" Score="2" ViewCount="3317" Body="&lt;p&gt;I like to write notes in markdown file. Most of the times my notes are about coding, but sometimes I need to write some math equations or symbols. I would like to see the equations directly in the vim, so I add the following lines in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set conceallevel=2&#xA;set concealcursor=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I write the following content in my .md file, it is not converted into math equations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$\sqrt{X^2} + \sum{X}$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How could I write markdown notes in vim as I did in typora, with real-time format conversion and math symbols support?&lt;/p&gt;&#xA;" OwnerUserId="16038" LastEditorUserId="1841" LastEditDate="2018-01-24T09:11:09.220" LastActivityDate="2018-01-24T20:39:52.290" Title="How to show math equations or formula in markdown file" Tags="|filetype-markdown|conceal|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14934" PostTypeId="2" ParentId="14924" CreationDate="2018-01-24T08:17:56.633" Score="3" Body="&lt;p&gt;As it turned out there are common practice to wrap platform specific options in statements which checks the system and set properties accrodingly to this. For some could be convenient to separate such statements into different files. As to me i end up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;win32&quot;)&#xA;  set rtp+=$HOME/vimfiles/bundle/Vundle.vim/&#xA;  call vundle#begin('$USERPROFILE/vimfiles/bundle/')&#xA;else&#xA;  set rtp+=~/.vim/bundle/Vundle.vim/&#xA;  call vundle#rc()&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So i made changes in single &lt;code&gt;vimrc&lt;/code&gt; and symlink it depending on platform.&lt;/p&gt;&#xA;" OwnerUserId="11110" LastActivityDate="2018-01-24T08:17:56.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14935" PostTypeId="1" CreationDate="2018-01-24T09:32:41.493" Score="1" ViewCount="48" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Osgue.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Osgue.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;First, I don't know what happed, which means the cause may not as the title suggests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was editing with vim.  one or two mis-key strokes, now whenever I open file with vim. All the Contents are all selected by default (please see screenshot once the file open up, it is all yellow highlight?, once I select the context &quot;using namespacre std to (line) defines poin, then it look normal again. ). When I select the contents. it look normal again. How can i fix it ? I quit and re-open didn't work. i even empty the vimrc and source the it. didn't work as well. Please help. &lt;/p&gt;&#xA;" OwnerUserId="16044" LastActivityDate="2018-01-24T10:58:12.333" Title="Contents are all selected by default" Tags="|vimrc|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14936" PostTypeId="2" ParentId="14924" CreationDate="2018-01-24T10:24:37.863" Score="2" Body="&lt;p&gt;If you are already using symlinks to set up your Vim configuration, and if&amp;#8202;&amp;mdash;&amp;#8202;as I infer from your comments&amp;#8202;&amp;mdash;&amp;#8202;the only operating system dependent part of your current config is your Vundle setup, then you don't actually need any special code in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Windows Command Line&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:: You'll already be setting up this symlink&#xA;mklink /D %HOMEDRIVE%%HOMEPATH%\vimfiles &amp;lt;path_to_repo\vimfiles&amp;gt;&#xA;&#xA;:: Set up another link for access via &quot;~/.vim&quot; path&#xA;mklink /D %HOMEDRIVE%%HOMEPATH%\.vim &amp;lt;path_to_repo\vimfiles&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. Instead of creating two symlinks, you could fiddle with &lt;code&gt;'runtimepath'&lt;/code&gt;, but the above seems simpler to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Unix Shell&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:: You'll already be setting up this symlink&#xA;ln -s &amp;lt;path_to_repo/vimfiles&amp;gt; ~/.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;vimrc&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This code will now work on both Unix and Windows&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. &lt;code&gt;~&lt;/code&gt; can be used in options on both Windows and Unix. See &lt;code&gt;:help $HOME&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you remove the leading &lt;code&gt;_&lt;/code&gt; or &lt;code&gt;.&lt;/code&gt; from your &lt;code&gt;vimrc&lt;/code&gt; filename you won't need to symlink it separately: you can just place it inside your &lt;code&gt;.vim&lt;/code&gt; directory (See &lt;code&gt;:help vimrc&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-25T10:02:09.180" LastActivityDate="2018-01-25T10:02:09.180" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14937" PostTypeId="2" ParentId="14933" CreationDate="2018-01-24T10:51:07.440" Score="4" Body="&lt;p&gt;&lt;em&gt;My interpretation is that the OP is looking for rendering of markup into fancy, graphical depictions of equations and formulae. If instead the question is about simple substitutions of Unicode mathematical characters then @Rich has &lt;a href=&quot;https://vi.stackexchange.com/a/14947/11054&quot;&gt;a nice answer&lt;/a&gt;.&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim&lt;/code&gt; is a text editor. It can display parallel, uniformly sized and spaced rows of Unicode characters and nothing more. Just like what you're reading now. The best you can do with markup languages is edit them and, possibly, launch an external command that renders them into a format that you'll need to read in an external viewer (e.g. browser, PDF viewer, &lt;code&gt;man&lt;/code&gt;, etc.). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, that's exactly what I do with &lt;code&gt;asciidoctor&lt;/code&gt;. I write my notes using AsciiDoc markup in &lt;code&gt;vim&lt;/code&gt;. I have &lt;code&gt;vim&lt;/code&gt; shortcuts to external commands that render the markup as HTML then launch/load my browser with that HTML.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The next level of sophistication is to set up &lt;a href=&quot;http://asciidoctor.org/docs/editing-asciidoc-with-live-preview/&quot; rel=&quot;nofollow noreferrer&quot;&gt;live preview&lt;/a&gt;. We put &lt;code&gt;vim&lt;/code&gt; and the viewer app side by side then use a file monitoring tool that upon seeing changes to the markup file renders and reloads the viewer automatically. That's as close to live editing of markup as you'll get with &lt;code&gt;vim&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-01-24T20:39:52.290" LastActivityDate="2018-01-24T20:39:52.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14938" PostTypeId="2" ParentId="14935" CreationDate="2018-01-24T10:58:12.333" Score="1" Body="&lt;p&gt;In addition to removing the &lt;code&gt;vimrc&lt;/code&gt;, you could try removing &lt;code&gt;~/.viminfo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the problem persists, try disabling your plugins - alternatively you could start Vim with &lt;code&gt;vim -u NONE -U NONE -N&lt;/code&gt;, which disables both initialization files and plugins, as explained in &lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;this similar question&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a last resort, try installing the latest Vim version.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2018-01-24T10:58:12.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14939" PostTypeId="2" ParentId="14923" CreationDate="2018-01-24T11:10:02.990" Score="6" Body="&lt;h2&gt; Why It's Broken&lt;/h2&gt;&#xA;&lt;p&gt;The problem is that you've used &lt;code&gt;-bar&lt;/code&gt; in your command definition. This attribute is used to specify that you can use a &lt;code&gt;|&lt;/code&gt; after an &lt;em&gt;invocation&lt;/em&gt; of your new command e.g.:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Ag search_term | copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, the &lt;code&gt;-bar&lt;/code&gt; flag also checks for &lt;code&gt;&amp;quot;&lt;/code&gt; characters to start a comment (See :help :command-bar.)&lt;/p&gt;&#xA;&lt;p&gt;This means that when you issue the command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Ag &amp;quot;find me&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;code&gt;&amp;quot;find me&amp;quot;&lt;/code&gt; is interpreted as a comment, resulting in Vim running the command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Ag&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;...and you get the following error (because you specified that arguments are required with &lt;code&gt;-nargs=+&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;E471: Argument required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Workarounds&lt;/h2&gt;&#xA;&lt;p&gt;One workaround is to use &lt;code&gt;'&lt;/code&gt; characters instead (noting &lt;a href=&quot;https://stackoverflow.com/questions/6697753/difference-between-single-and-double-quotes-in-bash&quot;&gt;the difference between the two when used in e.g. bash&lt;/a&gt; — now you can no longer search for things containing single quotes):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Ag 'find me'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Alternatively, you can escape whitespace:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Ag find\ me&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;How to Fix It&lt;/h2&gt;&#xA;&lt;p&gt;However, you can also simply remove the &lt;code&gt;-bar&lt;/code&gt; attribute:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=+ -complete=file Ag silent! grep! &amp;lt;args&amp;gt;|cwindow|redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;em&gt;N.B. It is not necessary to use the &lt;code&gt;-bar&lt;/code&gt; attribute to allow the use of &lt;code&gt;|&lt;/code&gt; in the&lt;/em&gt; definition &lt;em&gt;of a command, in case that's why you added it.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;After doing so, all of the following will work:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Ag find\ me&#xA;:Ag 'find me'&#xA;:Ag &amp;quot;Can't find me&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Extra Credit&lt;/h2&gt;&#xA;&lt;p&gt;If you don't &lt;em&gt;want&lt;/em&gt; to have to use quotes or escaping when invoking &lt;code&gt;:grep&lt;/code&gt; or &lt;code&gt;:Ag&lt;/code&gt;, you can get Vim to do the escaping for you:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! Ag(args) abort&#xA;  execute &amp;quot;silent! grep!&amp;quot; shellescape(a:args)&#xA;  cwindow&#xA;  redraw!&#xA;endfunction&#xA;&#xA;command -nargs=+ -complete=file Ag call Ag(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now this works:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Ag find me&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-01-24T11:51:33.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14940" PostTypeId="1" CreationDate="2018-01-24T11:33:59.757" Score="0" ViewCount="815" Body="&lt;p&gt;The easiest way to explain this question is to show you my code and what I am trying to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some code, before any edits are made:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// some block of code here&#xA;// blaa blaa&#xA;// please imagine these comments are code&#xA;&#xA;// another block of code after some whitespace break between&#xA;// this block and the previous&#xA;// blaa blaa&#xA;// please imagine these comments are code&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now imagine I want to edit &quot;in-between&quot; the 2 blocks of code above. I enter insert mode when the caret is between the blocks (on the whitespace line) I add some lines of whitespace (an extra 2), go up a line and enter a new variable name.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// some block of code here&#xA;// blaa blaa&#xA;// please imagine these comments are code&#xA;&#xA;double a_very_long_variable_name = 0.0;&#xA;&#xA;// another block of code after some whitespace break between&#xA;// this block and the previous&#xA;// blaa blaa&#xA;// please imagine these comments are code&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I escape from insert mode (back to normal mode) and yank the variable name &quot;a_very_long_variable_name&quot; using &quot;yiw&quot; (yank in word) command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I go down 1 line, to the blank line and press &quot;p&quot; to put. I get this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// some block of code here&#xA;// blaa blaa&#xA;// please imagine these comments are code&#xA;&#xA;double a_very_long_variable_name = 0.0;&#xA;a_very_long_variable_name&#xA;// another block of code after some whitespace break between&#xA;// this block and the previous&#xA;// blaa blaa&#xA;// please imagine these comments are code&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I want is to &quot;put&quot;, but to add a new whitespace line (a newline character) after the put command.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there already a command to do this? It seems like something that would be frequently required.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I believe I can accomplish this by creating a new command like this in my vimrc. (I am not sure yet what the nmap syntax is... Will search for this now.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;S-p&amp;gt; p$i&amp;lt;Enter&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: The command above should actually be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;S-p&amp;gt; p$a&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3246" LastActivityDate="2018-01-24T13:19:43.793" Title="&quot;Put&quot; command in normal mode: Insert a new line after &quot;put&quot;" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14941" PostTypeId="2" ParentId="14940" CreationDate="2018-01-24T12:00:27.140" Score="3" Body="&lt;p&gt;What you are looking for is &lt;code&gt;o&lt;/code&gt; in normal mode see &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#o&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h o&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Begin a new line below the cursor and insert text, repeat [count] times.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note there is also &lt;code&gt;O&lt;/code&gt; which adds a newline above the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example you may want a mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;S-p&amp;gt; po&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a side note I use these mappings to insert a newline without leaving normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Quickly insert an empty new line without entering insert mode&#xA;nnoremap &amp;lt;Leader&amp;gt;o o&amp;lt;Esc&amp;gt;0&quot;_D&#xA;nnoremap &amp;lt;Leader&amp;gt;O O&amp;lt;Esc&amp;gt;0&quot;_D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;0&quot;_D&lt;/code&gt; delete the content of the new line using the black hole register to avoid having a newline containing some whitespaces.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also it is not part of your question but your mapping can be &lt;code&gt;nnoremap P&lt;/code&gt; instead of &lt;code&gt;nnoremap &amp;lt;S-p&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-01-24T12:00:27.140" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="14942" PostTypeId="1" CreationDate="2018-01-24T12:18:07.173" Score="0" ViewCount="87" Body="&lt;p&gt;I am trying to write a command that yanks the whitespace (indentation) at the start of a line as well as yanking some other object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have several ideas of how this could be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the following example, where we want to make a new command similar to &quot;yiw&quot; which yanks the variable name &lt;code&gt;hello_world&lt;/code&gt; but also yanks the whitespace before &lt;code&gt;double&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// no indentation on this line&#xA;    double hello_world = 10.0; // there is some indentation on this line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;We could either store the current cursor position, go to the start of the line, yank the whitespace, go back to where we were, execute the yiw command and somehow get these 2 yanks to &quot;concatinate&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or we could execute the yiw command, go to the end of the line, add a new line, put the yank buffer, go back up to the start of the line, yank the whitespace, go down again, put the whitespace at the start of the line, delete-yank the whole line and put it again. (So that the yank buffer contains what we want.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or some combination of the above.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Firstly, while not essential, I don't know how to manipulate the yank buffer, or how to &quot;concatinate&quot; to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly I do not know how to save the cursor position and then restore it. This is also not essential but the &quot;work around&quot; as described above is messy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way of accomplishing a yank and retaining the indentation whitespace?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my attempt so far. It works but doesn't seem like a particularly good solution. Also &quot;o&quot; seems like an inefficient combination to put in a command since everything else is done without entering insert mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;S-y&amp;gt;iw yiwo&amp;lt;ESC&amp;gt;p-0y^&amp;lt;DOWN&amp;gt;PddP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3246" LastEditorUserId="3246" LastEditDate="2018-01-24T12:27:33.997" LastActivityDate="2018-01-24T13:13:24.117" Title="Yank-in-word with indentation: Get/set buffer position, manipulate yank buffer" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14943" PostTypeId="1" CreationDate="2018-01-24T12:52:43.667" Score="2" ViewCount="621" Body="&lt;p&gt;I would like to use vim to write python codes, it is good to use python-mode plugin. However, I have to debug with pdb in the terminal, which is quite inconvenient since I have no way to view the whole code. Are there any plugins that can be the front end of debug tools such as gdb or pdb, and allow me to debug in vim directly?&lt;/p&gt;&#xA;" OwnerUserId="16038" LastActivityDate="2018-01-24T13:24:33.827" Title="What is a good debug front end plugin" Tags="|filetype-python|plugin-python-mode|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14944" PostTypeId="2" ParentId="14942" CreationDate="2018-01-24T13:13:24.117" Score="2" Body="&lt;p&gt;You can concatenate to some registers using capital letters.  &lt;code&gt;&quot;Ay&lt;/code&gt; concatenates to instead of replaces register &lt;code&gt;a&lt;/code&gt;.  However, there is no way to concatenate yank to the unnamed register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moving the cursor and restoring it can be done with marks and/or &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;. For example you could &lt;code&gt;m'&lt;/code&gt; to save the cursor position, then &lt;code&gt;`'&lt;/code&gt; to restore it, or simply use &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;.  Alternatively, you can use named marks like &lt;code&gt;ma&lt;/code&gt; and &lt;code&gt;`a&lt;/code&gt;.  Both of these have side-effects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend using command syntax instead.  In this case, it is easier to write and understand, and has fewer side-effects than your proposed methods.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;yiw :&amp;lt;c-u&amp;gt;let @&quot;=repeat(' ', indent('.')).expand('&amp;lt;cword&amp;gt;')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A few of the features need explaining:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;let @&quot;=&lt;/code&gt; places the expression in the unnamed register.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;repeat(' ', N)&lt;/code&gt; is a series of &lt;code&gt;N&lt;/code&gt; spaces and &lt;code&gt;indent('.')&lt;/code&gt; gets the number of spaces at the beginning of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;expand('&amp;lt;cword&amp;gt;')&lt;/code&gt; retrieves the current word, similar to &lt;code&gt;iw&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-01-24T13:13:24.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14945" PostTypeId="2" ParentId="14940" CreationDate="2018-01-24T13:19:43.793" Score="4" Body="&lt;p&gt;There is indeed a single command that will do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be abbreviated to &lt;code&gt;:pu&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also add a &lt;code&gt;!&lt;/code&gt;  to insert the new line of text above the cursor: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or add a &lt;code&gt;[line]&lt;/code&gt; to insert the text after/before any line you specify in the buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:4put&#xA;:4put!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :put&lt;/code&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to map it, you could write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;S-P&amp;gt; :put&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although, personally, I'd use a different trigger: &lt;code&gt;P&lt;/code&gt; in normal mode is a command I use all the time.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-24T13:19:43.793" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14946" PostTypeId="2" ParentId="14943" CreationDate="2018-01-24T13:24:33.827" Score="1" Body="&lt;p&gt;You should check the existing plugins with &lt;a href=&quot;https://vimawesome.com/?q=pdb&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Awesome&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim Awesome is a directory of Vim plugins sourced from GitHub,&#xA;  Vim.org, and user submissions. Plugin usage data is extracted from&#xA;  dotfiles repos on GitHub.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A quick search on that site brought these results:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vimpdb by Godefroid Chapelle - Pdb and Vim integration&lt;/li&gt;&#xA;&lt;li&gt;pdbvim by Mathew Yeates - Interface to pdb for debugging python scripts&lt;/li&gt;&#xA;&lt;li&gt;pybreak by Niklas Thörne - Vim function for toggling pdb.set_trace statement at cursor position&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2018-01-24T13:24:33.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14947" PostTypeId="2" ParentId="14933" CreationDate="2018-01-24T14:01:41.903" Score="6" Body="&lt;p&gt;Mathematical equations cannot be displayed in Vim in this way: Vim has no means of rendering them, as &lt;a href=&quot;https://vi.stackexchange.com/a/14937/343&quot;&gt;@BLayer explains in his answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, mathematical &lt;em&gt;symbols&lt;/em&gt; you can indeed display using Vim's &lt;code&gt;conceal&lt;/code&gt; feature, as you suggest in your tags. The following commands will replace various mathsy HTML entities with their corresponding Unicode characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match MathSymbols /\V&amp;amp;radic;/ conceal cchar=√&#xA;:syntax match MathSymbols /\V&amp;amp;sup2;/ conceal cchar=²&#xA;:syntax match MathSymbols /\V&amp;amp;sum;/ conceal cchar=∑&#xA;:set conceallevel=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;amp;radic;x&amp;amp;sup2; + &amp;amp;sum;x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will display in Vim something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;radic;x&amp;sup2; + &amp;sum;x&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could of course just type those Unicode symbols in directly, instead! (Either using your operating system's input features, or Vim's &lt;code&gt;digraphs&lt;/code&gt; feature.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. Markdown itself does not allow equations to be entered in this way. Typora appears to have added support of these &lt;a href=&quot;http://support.typora.io/Markdown-Reference/#math-blocks&quot; rel=&quot;noreferrer&quot;&gt;using MathJax&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-24T15:02:01.600" LastActivityDate="2018-01-24T15:02:01.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14950" PostTypeId="1" AcceptedAnswerId="14952" CreationDate="2018-01-24T15:11:18.060" Score="6" ViewCount="9915" Body="&lt;p&gt;After opening vim as normal user. Is it possible to open a new file as sudo user? like for example in &lt;code&gt;:e file&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14609" LastEditorUserId="14609" LastEditDate="2018-01-24T15:15:54.573" LastActivityDate="2018-01-24T17:42:24.387" Title="How to open a file as sudo from within vim?" Tags="|sudo|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14951" PostTypeId="1" AcceptedAnswerId="14953" CreationDate="2018-01-24T15:15:44.717" Score="1" ViewCount="702" Body="&lt;p&gt;I'm debugging a problematic function that imports another function with a similar name - &lt;code&gt;read_table&lt;/code&gt; vs &lt;code&gt;read.table&lt;/code&gt;. I've examined the file in sublime, which concludes that there are no instances of &lt;code&gt;read.table&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I run &lt;code&gt;?read.table&lt;/code&gt;, vim just iterates over all the instances of &lt;code&gt;read_table&lt;/code&gt;. Is the period some sort of wildcard for vim search? How can I get around this problem to find the true instances of &lt;code&gt;read.table&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="14452" LastActivityDate="2018-01-24T15:25:15.197" Title="Search confuses periods and underscores" Tags="|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14952" PostTypeId="2" ParentId="14950" CreationDate="2018-01-24T15:23:01.987" Score="10" Body="&lt;p&gt;One workaround is to open the file normally:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then use the &lt;a href=&quot;https://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work&quot;&gt;sudo tee trick&lt;/a&gt; when &lt;em&gt;writing&lt;/em&gt; the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !sudo tee %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't have read permission on the file, you're going to need to use sudo to get the file contents into Vim, too.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; (If necessary) Create a new, empty buffer&#xA;:new&#xA;&#xA;&quot; Read file into the empty buffer&#xA;:r !sudo cat file&#xA;&#xA;&quot; Delete first (empty) line&#xA;:1d&#xA;&#xA;&quot; Do edits...&#xA;&#xA;&quot; Write file&#xA;:w !sudo tee file&#xA;&#xA;&quot; Discard buffer and file contents&#xA;:bd!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Personally, if I haven't already started making changes to the file, I'd just quit vim and then use &lt;a href=&quot;http://www.wingtiplabs.com/blog/posts/2013/03/13/sudoedit/&quot; rel=&quot;noreferrer&quot;&gt;sudoedit&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:qall&#xA;sudoedit file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-24T17:42:24.387" LastActivityDate="2018-01-24T17:42:24.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14953" PostTypeId="2" ParentId="14951" CreationDate="2018-01-24T15:25:15.197" Score="5" Body="&lt;p&gt;A period means &quot;any character&quot; in a regular expression. Use &lt;code&gt;\.&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?read\.table&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help regexp&lt;/code&gt; for more details. Specifically, see &lt;code&gt;:help /.&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-24T15:25:15.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14954" PostTypeId="2" ParentId="14864" CreationDate="2018-01-24T15:55:28.710" Score="1" Body="&lt;p&gt;The behaviour you request is essentially impossible to achieve in Vim, because of two immutable facts:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When in visual mode, the cursor is always at one end of the selection. With the exception of jumping to the other end of the selection by pressing &lt;code&gt;o&lt;/code&gt;, if you move the cursor, you are by definition altering the selection,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The cursor is always visible on screen. If you scroll the text so that the cursor would be off-screen, the cursor moves so that it remains on-screen.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Therefore, if you scroll so that the entire original selection is off-screen, you must also be altering the selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could write Vimscript that detects when you are about to scroll off-screen with the mouse, removes the selection, and then also detects when you scroll back and replaces it, but it would be a fair sized chunk of exceedingly hacky code, and there are a large number of edge cases it would have to deal with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. Would you still expect to be able to press &lt;code&gt;d&lt;/code&gt; to delete the conceptual selection while it is offscreen? If so, then even more hacky code is required. You also want to be able to press &lt;code&gt;c&lt;/code&gt; to change it? More code. etc.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-24T15:55:28.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14955" PostTypeId="2" ParentId="14950" CreationDate="2018-01-24T17:10:35.590" Score="4" Body="&lt;p&gt;I use the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2709&quot; rel=&quot;nofollow noreferrer&quot;&gt;SudoEdit&lt;/a&gt; plugin, which defines the commands &lt;code&gt;SudoRead&lt;/code&gt; and &lt;code&gt;SudoWrite&lt;/code&gt;, which allow me to read and write with sudo permissions a file I didn't think to open with &lt;code&gt;sudoedit&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2018-01-24T17:10:35.590" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14956" PostTypeId="1" AcceptedAnswerId="14957" CreationDate="2018-01-24T19:08:43.493" Score="1" ViewCount="675" Body="&lt;p&gt;One of the most basic editing commands is &lt;code&gt;c&amp;lt;motion&amp;gt;&lt;/code&gt; to change text, e.g. &lt;code&gt;cw&lt;/code&gt; - change word, &lt;code&gt;c$&lt;/code&gt; - change to end of line, &lt;code&gt;cc&lt;/code&gt; - change entire line, &lt;code&gt;c3l&lt;/code&gt; - change 3 characters to the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, why then does &lt;code&gt;cb&lt;/code&gt; at the end of a word prepare for replacement, excluding the last character of the word (i.e. the character that the cursor was over when typing the command)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vb&lt;/code&gt; at the end of a word will select the entire word, including the last character. Should &lt;code&gt;cb&lt;/code&gt; not be expected to have the same behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short: The behavior of &lt;code&gt;vbc&lt;/code&gt; is expected, but behavior of &lt;code&gt;hvbc&lt;/code&gt; is equivalent to &lt;code&gt;cb&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim &lt;code&gt;8.0.1350&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems this behavior follows more the idea that the cursor is &quot;between&quot; characters (insert mode) rather than &quot;over&quot; a character (normal mode).&lt;/p&gt;&#xA;" OwnerUserId="16056" LastActivityDate="2019-10-10T03:36:37.647" Title="Unexpected behavior from cb command" Tags="|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14957" PostTypeId="2" ParentId="14956" CreationDate="2018-01-24T19:37:03.590" Score="9" Body="&lt;p&gt;The &lt;code&gt;b&lt;/code&gt; motion is an exclusive motion. Visual mode is inclusive by default (See &lt;code&gt;:h 'selection'&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h exclusive&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A character motion is either inclusive or exclusive.  When inclusive, the&#xA;start and end position of the motion are included in the operation.  When&#xA;exclusive, the last character towards the end of the buffer is not included.&#xA;Linewise motions always include the start and end position.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are using &lt;code&gt;b&lt;/code&gt; when you probably want to use the &lt;code&gt;iw&lt;/code&gt; text object instead, e.g. &lt;code&gt;cb&lt;/code&gt; vs &lt;code&gt;ciw&lt;/code&gt;. See &lt;code&gt;:h iw&lt;/code&gt; and &lt;code&gt;:h text-objects&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also force inclusivity on a motion by using &lt;code&gt;v&lt;/code&gt; after an operator, e.g. &lt;code&gt;cvb&lt;/code&gt; will do a change over motion &lt;code&gt;b&lt;/code&gt; but inclusively. See &lt;code&gt;:h o_v&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-01-24T21:16:00.827" LastActivityDate="2018-01-24T21:16:00.827" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14959" PostTypeId="1" CreationDate="2018-01-25T07:23:17.053" Score="3" ViewCount="5092" Body="&lt;p&gt;I'm using basically the formatting of the Google C++ Style Guide. How can I configure neovim to use these settings for C++? On the other hand, for pure C, I would like it to use the BSD style.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I just type code and then run clang-format (through the google codefmt plugin), which takes care of formatting. But it would be nicer to automatically get the correct indentation levels etc. when I hit return after an opening bracket.&lt;/p&gt;&#xA;" OwnerUserId="15739" LastActivityDate="2018-01-25T09:54:28.090" Title="Setting C++ indentation level?" Tags="|indentation|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14960" PostTypeId="2" ParentId="14959" CreationDate="2018-01-25T08:11:00.647" Score="2" Body="&lt;p&gt;You can configure different styles of C/C++ indenting by setting &lt;code&gt;'cindent'&lt;/code&gt; and &lt;code&gt;'cinoptions'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help cinoptions-values&lt;/code&gt; for more details on what can be configured and &lt;code&gt;:help C-indenting&lt;/code&gt; for information on C indenting in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can have different settings for C and C++ by placing your configuration in two locations:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;~/.vim/after/ftplugin/c.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cindent&#xA;set cinoptions=&amp;lt;the options you want for C&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;~/.vim/after/ftplugin/cpp.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cindent&#xA;set cinoptions=&amp;lt;the options you want for C++&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might also like to take a look at &lt;a href=&quot;https://vi.stackexchange.com/questions/6530/how-to-override-the-command&quot;&gt;this question about using clang-format for the &lt;code&gt;=&lt;/code&gt; command&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim also allows you to set up completely custom indenting using an indent expression. (See &lt;code&gt;:help 'indentexpr'&lt;/code&gt;) This is what &lt;a href=&quot;https://vi.stackexchange.com/questions/14959/setting-c-indentation-level/14960#comment25636_14960&quot;&gt;the script you mention in the comments&lt;/a&gt; does. You can install that for CPP by renaming the file and placing it in the location:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/indent/cpp.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find more details at &lt;code&gt;:help 30.3&lt;/code&gt; and &lt;code&gt;:help indent-expression&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-25T09:54:28.090" LastActivityDate="2018-01-25T09:54:28.090" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14961" PostTypeId="1" AcceptedAnswerId="14964" CreationDate="2018-01-25T09:55:18.397" Score="0" ViewCount="3614" Body="&lt;p&gt;Example line: &lt;code&gt;^    some_string    : other_string $&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to yank &lt;code&gt;some_string&lt;/code&gt; before &lt;code&gt;:&lt;/code&gt; without the spaces|tabs?&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-01-25T14:10:31.477" Title="How to yank string before a special character?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14962" PostTypeId="1" AcceptedAnswerId="14963" CreationDate="2018-01-25T10:49:12.453" Score="0" ViewCount="1564" Body="&lt;p&gt;There is probably an easy solution for this, but here it goes :&#xA;whenever I do a &lt;code&gt;git commit&lt;/code&gt;, an error appears (copied hereunder). Vim then starts, some of my &lt;code&gt;.vimrc&lt;/code&gt; features are enabled, some are not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I don't need all of my .vimrc options to just write a commit, I thought that a possible solution for that would be to &lt;strong&gt;create a &lt;code&gt;.vimrc&lt;/code&gt; file specifically for git commits&lt;/strong&gt;, but I don't know how that should be done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Error :&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/homehome/.vimrc:&#xA;line  106:&#xA;E518: Unknown option: foldenable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7128" LastEditorUserId="343" LastEditDate="2018-01-25T12:14:43.240" LastActivityDate="2018-01-25T12:14:43.240" Title="Create a specific .vimrc for git commits usage?" Tags="|vimrc|git|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14963" PostTypeId="2" ParentId="14962" CreationDate="2018-01-25T11:07:06.797" Score="5" Body="&lt;p&gt;It is strange that the error just appear with &lt;code&gt;git commit&lt;/code&gt; -- I guess you have two versions of Vim installed, and the one used by git is older/have less features and thus complain about that option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try &lt;a href=&quot;https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration&quot; rel=&quot;noreferrer&quot;&gt;to configure you git editor&lt;/a&gt; passing the full path of the Vim you normally use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, I agree with the comments on your question: you should fix your &lt;code&gt;vimrc&lt;/code&gt; instead of creating another one. And that setting a option which is local to window doesn't make much sense -- it would be better in a &lt;a href=&quot;http://vimhelp.appspot.com/usr_43.txt.html#filetype%2dplugin&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;filetype-plugin&lt;/code&gt;&lt;/a&gt; or in a &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#auto%2dsetting&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;modeline&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a last resort you could check if the option is available before setting it. In &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27foldenable%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'foldenable'&lt;/code&gt;&lt;/a&gt; it says it requires the &lt;code&gt;folding&lt;/code&gt; feature, so you can if that feature using &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#has%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;has()&lt;/code&gt;&lt;/a&gt;, or maybe check directly the option as explained in &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#exists%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help exists()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2018-01-25T11:07:06.797" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14964" PostTypeId="2" ParentId="14961" CreationDate="2018-01-25T12:47:02.010" Score="0" Body="&lt;p&gt;As you probably know all commands are quite location dependent.&#xA;So the &lt;em&gt;best&lt;/em&gt; command will differ depending on your starting location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;yiw&lt;/code&gt; will work fine if you are standing on the &lt;code&gt;some_string&lt;/code&gt;.&#xA;If you are on the line you can get there by &lt;code&gt;^&lt;/code&gt; (go to beginning first word of the line)&#xA;Then &lt;code&gt;yiw&lt;/code&gt; to yank the word only. (thanks @statox)&lt;/p&gt;&#xA;" OwnerUserId="16065" LastEditorUserId="16065" LastEditDate="2018-01-25T14:10:31.477" LastActivityDate="2018-01-25T14:10:31.477" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14966" PostTypeId="2" ParentId="4244" CreationDate="2018-01-25T13:20:39.783" Score="2" Body="&lt;p&gt;Simple answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, it's extremly useful for programming, especially in Python, in which tabulation is crucial. &#xA;When you press backspace with sts=4, it will untab the line, not delete a single space character.&lt;/p&gt;&#xA;" OwnerUserId="16066" LastActivityDate="2018-01-25T13:20:39.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14967" PostTypeId="2" ParentId="831" CreationDate="2018-01-25T14:24:47.567" Score="2" Body="&lt;p&gt;To collect &lt;em&gt;only&lt;/em&gt; stderr, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shellpipe=2&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To collect &lt;em&gt;both&lt;/em&gt; stderr and stdout:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shellpipe=&amp;gt;%s\ 2&amp;gt;&amp;amp;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, to collect both and watch builds as they proceed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shellpipe=2&amp;gt;&amp;amp;1\ \|\ tee&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16068" LastActivityDate="2018-01-25T14:24:47.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14968" PostTypeId="1" AcceptedAnswerId="14981" CreationDate="2018-01-25T16:32:01.543" Score="0" ViewCount="63" Body="&lt;p&gt;I have a question about tabs within vim and I'm using VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan 17 2018 20:33:56) Included patches: 1-1255 Compiled by _pbuild@amd64.ports.openbsd.org&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tab bindings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This replaces :tabnew which I used to bind to this mapping&#xA;nmap &amp;lt;leader&amp;gt;t :enew&amp;lt;cr&amp;gt;&#xA;&quot;&#xA;&quot; Move to the next buffer&#xA;nmap &amp;lt;leader&amp;gt;l :bnext&amp;lt;CR&amp;gt;&#xA;&quot;&#xA;&quot; Move to the previous buffer&#xA;nmap &amp;lt;leader&amp;gt;h :bprevious&amp;lt;CR&amp;gt;&#xA;&quot;&#xA;&quot; Close the current buffer and move to the previous one&#xA;&quot; This replicates the idea of closing a tab&#xA;nmap &amp;lt;leader&amp;gt;bq :bp &amp;lt;BAR&amp;gt; bd #&amp;lt;CR&amp;gt;&#xA;&quot;&#xA;&quot; Show all open buffers and their status&#xA;nmap &amp;lt;leader&amp;gt;bl :ls&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The question I have is, is it possible to prevent the cursor from jumping to the beginning of the line? If I have two different files open and I'm half way on the line, when I switch to &quot; file2&quot; and back to &quot;file&quot;, I'll be on the correct line, but at the beginning of the line. This causes me to use either w or w# to get back to where I was.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't seem to have this issue if I were to vs &quot;file&quot; and &quot;file2&quot;.&lt;/p&gt;&#xA;" OwnerUserId="2475" LastEditorUserId="11054" LastEditDate="2018-01-27T02:44:23.070" LastActivityDate="2018-01-27T02:44:23.070" Title="Don't reset vim tab to the beinning line" Tags="|indentation|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14969" PostTypeId="2" ParentId="14473" CreationDate="2018-01-25T16:37:42.090" Score="4" Body="&lt;p&gt;&lt;code&gt;:make&lt;/code&gt; doesn't have to actually use a Makefile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let &amp;amp;makeprg = &quot;g++ *.cpp -o [Filename]&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then run the command with &lt;code&gt;:make&lt;/code&gt; and if desired you can set up a normal mode mapping for this with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;m :make&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'makeprg'&lt;/code&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll probably also want to ensure &lt;code&gt;'errorformat'&lt;/code&gt; is set up appropriately so that the quickfix window is filled correctly (having a look at &lt;code&gt;$VIMRUNTIME/compiler/gcc&lt;/code&gt; is probably a good start), and you might also like to look into &lt;code&gt;:help compiler-select&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-25T16:44:38.317" LastActivityDate="2018-01-25T16:44:38.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14970" PostTypeId="1" CreationDate="2018-01-25T16:47:09.923" Score="1" ViewCount="60" Body="&lt;p&gt;I'm in a Linux class right now and the question was brought up as to if there was a command to see what's in your buffer list inside vi. I searched online to see if I could find anything, but found nothing, so I went ahead and started to attempt creating a script myself, however I cannot seem to get the commands right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while [ : ]&#xA;do&#xA;clear&#xA;&#xA;echo &quot;What buffer position would you like to see?&quot;&#xA;&#xA;read choice&#xA;&#xA;case $choice in&#xA;1) '&quot;1p' ;;&#xA;2) '&quot;2p' ;;&#xA;3) '&quot;3p' ;;&#xA;4) '&quot;4p' ;;&#xA;5) '&quot;5p' ;;&#xA;6) '&quot;6p' ;;&#xA;7) '&quot;7p' ;;&#xA;8) '&quot;8p' ;;&#xA;9) '&quot;9p' ;;&#xA;0) '&quot;0p' ;;&#xA;&#xA;&#xA;esac ; read -n 1 ;&#xA;&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried swapping the command for something like this too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1) vi -c \&quot;1p ;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how I might be able to pull a vi command out into command line like that? Thank you! (Side note, this is NOT homework or required. I just want to see if it can be done. I asked my professor to help me with it, and even he was stumped)&lt;/p&gt;&#xA;" OwnerUserId="16071" LastActivityDate="2018-01-25T23:14:05.143" Title="Attempt to create a buffer output script" Tags="|linux|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14972" PostTypeId="2" ParentId="14970" CreationDate="2018-01-25T17:17:59.773" Score="2" Body="&lt;p&gt;First thing's first: I infer from your code (which uses &lt;code&gt;&quot;1p&lt;/code&gt; etc.) that you actually mean &quot;register&quot; when you write &quot;buffer&quot;. In Vim terminology, a &quot;buffer&quot; is Vim's in-memory representation of a file (which may or may not actually exist on disk). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, I gather from your code that what you are trying to achieve is the construction of a bash script that will allow you to query the contents of Vim's registers &lt;em&gt;from outside of Vim.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, here is a command that will print the contents of Vim's numbered register &lt;code&gt;&quot;0&lt;/code&gt; (the yank register) from your shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -es -c'normal &quot;0P' -c%p -cq! -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I leave it as an exercise to you to figure out how to incorporate that into your bash script: it's outside the scope of this site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Broken down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vim&lt;/code&gt;: Run Vim,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-es&lt;/code&gt;: in silent mode,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-c&lt;/code&gt;: passing in the commands...&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal &quot;0P&lt;/code&gt;: use the normal mode command &lt;code&gt;&quot;0P&lt;/code&gt; to paste the contents of the &lt;code&gt;&quot;0&lt;/code&gt; register at the start of the buffer,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-c%p&lt;/code&gt;: print the contents of the buffer (i.e. output it to &lt;code&gt;stdout&lt;/code&gt; i.e. the shell)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-cq!&lt;/code&gt;: quit, discarding the contents of the buffer (which you altered with the &lt;code&gt;&quot;0P&lt;/code&gt; command),&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help vim-arguments&lt;/code&gt;, &lt;a href=&quot;https://vi.stackexchange.com/questions/788/how-to-edit-files-non-interactively-e-g-in-pipeline&quot;&gt;this earlier question&lt;/a&gt;, and &lt;a href=&quot;https://vi.stackexchange.com/questions/11373/how-can-you-use-vim-as-a-stream-editor&quot;&gt;this one&lt;/a&gt; for more details on how this works.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-25T23:14:05.143" LastActivityDate="2018-01-25T23:14:05.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14973" PostTypeId="1" AcceptedAnswerId="14975" CreationDate="2018-01-25T18:26:15.053" Score="1" ViewCount="343" Body="&lt;p&gt;I'm writing a function that uses Vim's Python API. The function runs while I'm in &lt;code&gt;insert&lt;/code&gt; mode and I want this function to set my mode to &lt;code&gt;normal&lt;/code&gt; mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried a few things, like for example, this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import vim&#xA;vim.eval(r'execute normal! \&amp;lt;esc&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But unfortunately this doesn't work. I just get the error &lt;code&gt;VIM:E121: Undefined variable: execute&lt;/code&gt;. Any help would be greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, generally speaking, I'd really like to know more about the &lt;code&gt;vim&lt;/code&gt; module. It doesn't have a &lt;code&gt;__file__&lt;/code&gt; attribute, assuming that's because it's compiled. Is there source code anywhere I can view? Or generally where the file lives so that I can try importing it and running &lt;code&gt;help(vim)&lt;/code&gt; without having to re-run my functions in a Vim environment. If you have any information on that, in particular, it'd help a lot. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="16073" LastActivityDate="2018-01-25T19:56:16.930" Title="Use Python to change to normal mode" Tags="|insert-mode|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14974" PostTypeId="1" AcceptedAnswerId="15691" CreationDate="2018-01-25T18:48:15.127" Score="2" ViewCount="242" Body="&lt;p&gt;I have, for many years, mapped the space key to page-down. I love this mapping, except when I don't love it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, I don't love it when I accidentally press the space key, which happens more than I care to admit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm toying with a workaround that so far seems OK: I use two key mappings that will restore my window after an accidental space key: One maps the space key to call winsaveview(), then press page-down; the other maps 'qqq' to call winrestview()). My vimrc has the mappings as follows..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;--- This is to restore the window view if SPACE key is accidentally pressed&#xA;map &amp;lt;Space&amp;gt; :let winrestdict = winsaveview()&amp;lt;CR&amp;gt;&amp;lt;pagedown&amp;gt;&#xA;map qqq :call winrestview(winrestdict)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I use 'qqq' simply because it is quick and easy to type)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above solution appears to work for me, so feel free to use it if nobody has an alternative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is this... is there a cleaner way (i.e., without having to define the two key mappings above) to accomplish my goal of returning the cursor (and view) to exactly the previous location after pressing a page-down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Page-down (Ctrl-F) doesn't get added to the jump list, so Ctrl-O is not a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(although maybe there's a setting to add page-down to the commands that update the jump list? I couldn't find anything like this)&lt;/p&gt;&#xA;" OwnerUserId="6203" LastActivityDate="2018-03-27T09:11:17.393" Title="Recovering from accidental pagedown" Tags="|vimrc|key-bindings|jumplist|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14975" PostTypeId="2" ParentId="14973" CreationDate="2018-01-25T19:45:36.283" Score="3" Body="&lt;p&gt;Your question is more of a vim issue than a python one.  &lt;code&gt;vim.eval&lt;/code&gt; is basically the same as vim's &lt;code&gt;eval(&lt;/code&gt; which evaluates an &lt;em&gt;expression&lt;/em&gt; and does not run a &lt;em&gt;command&lt;/em&gt; like &lt;code&gt;execute&lt;/code&gt;.  Additionally, your syntax for &lt;code&gt;execute&lt;/code&gt; is wrong since the command takes a string: &lt;code&gt;execute &quot;normal! \&amp;lt;esc&amp;gt;&quot;&lt;/code&gt; would be more correct.  You could instead use the expression form &lt;code&gt;execute()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim.eval(r'execute(&quot;normal! \&amp;lt;esc&amp;gt;&quot;)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, since you ultimately want to use a command I would recommend just using &lt;code&gt;vim.command(cmd)&lt;/code&gt; instead.  vim already has a command for leaving insert mode, &lt;code&gt;stopinsert&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; vim.command('stopinsert')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The documentation for the methods in the built-in &lt;code&gt;vim&lt;/code&gt; module can be found using &lt;code&gt;:help python&lt;/code&gt; which brings up &lt;code&gt;doc/if_pyth.txt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-01-25T19:56:16.930" LastActivityDate="2018-01-25T19:56:16.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14976" PostTypeId="1" AcceptedAnswerId="14977" CreationDate="2018-01-25T21:35:31.813" Score="1" ViewCount="816" Body="&lt;p&gt;Because I am used to autocompleting by pressing the return/enter key, I want to remap the return key to &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;p&lt;/kbd&gt; in insert mode. &lt;strong&gt;However&lt;/strong&gt;, I only want to remap it when the cursor is directly behind a letter (a-z).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="10823" LastActivityDate="2018-01-25T23:11:56.953" Title="Remapping return key to &lt;C-p&gt;" Tags="|vimrc|key-bindings|autocompletion|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14977" PostTypeId="2" ParentId="14976" CreationDate="2018-01-25T23:07:04.340" Score="4" Body="&lt;p&gt;Sure it is!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this expression mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; getline('.')[col('.') - 2] =~ '\a' ? &quot;\&amp;lt;C-P&amp;gt;&quot; : &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How this works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;getline('.')[col('.') - 2]&lt;/code&gt;: This returns the character immediately before the cursor (i.e. the one you just typed).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;=~ '\a'&lt;/code&gt;: This checks if the character is an alphabetic character a-z or A-Z&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;? &quot;\&amp;lt;C-P&amp;gt;&quot; : &quot;\&amp;lt;CR&amp;gt;&quot;&lt;/code&gt;: If the character is alphabetic then your keypress is mapped to &lt;code&gt;&amp;lt;C-P&amp;gt;&lt;/code&gt;. If not, it is mapped to &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more details, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :map-expr&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help expr1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getline()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help col()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-25T23:11:56.953" LastActivityDate="2018-01-25T23:11:56.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14978" PostTypeId="1" AcceptedAnswerId="14979" CreationDate="2018-01-25T23:11:18.007" Score="0" ViewCount="101" Body="&lt;p&gt;I've been trying to write a regex that turns the following structure&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Ignore this line&#xA;&#xA;Foo&#xA;Foo&#xA;&#xA;# Ignore this line too&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Ignore this line&#xA;&#xA;IF BAR THEN&#xA;    Foo&#xA;    Foo&#xA;&#xA;# Ignore this line too&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far I have the following regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s#\(\n\)\?\(\(Foo\n\)\+\)\(\n\)\?#\= submatch(1) . 'IF BAR THEN\r' . &#xA;substitute(submatch(2), 'Foo', '    &amp;amp;', 'g') . submatch(4)#gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Ignore this line&#xA;&#xA;IF BAR THEN\r    FOO&#xA;    Foo&#xA;&#xA;# Ignore this line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried using &lt;code&gt;\n&lt;/code&gt;, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, &lt;code&gt;^M&lt;/code&gt; but none seem to have the desired output. Please advise!&lt;/p&gt;&#xA;" OwnerUserId="16075" LastEditorUserId="16075" LastEditDate="2018-01-25T23:17:17.577" LastActivityDate="2018-01-25T23:18:47.873" Title="Newline in sub-replace expression" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14979" PostTypeId="2" ParentId="14978" CreationDate="2018-01-25T23:18:47.873" Score="1" Body="&lt;p&gt;The problem is that you're using a literal string (delimited by single quotes) where you want to use an escape character &lt;code&gt;\r&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace them with double quotes to fix:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;... &quot;IF BAR THEN\r&quot; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(See &lt;code&gt;:help string&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-25T23:18:47.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14980" PostTypeId="2" ParentId="5780" CreationDate="2018-01-25T23:29:24.523" Score="4" Body="&lt;p&gt;You can also print all file types in the terminal by running the following 2 commands:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd $(vim -e -T dumb --cmd 'exe &quot;set t_cm=\&amp;lt;C-M&amp;gt;&quot;|echo $VIMRUNTIME|quit' | tr -d '\015')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat &amp;lt;(ls -1 ftplugin/*.vim) &amp;lt;(ls -1 syntax/*.vim) | tr '\n' '\0' | xargs -0 -n 1 basename | sort | uniq | cut -f 1 -d '.'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First command simply navigates to your vim runtime path (for me it was &lt;em&gt;/usr/share/vim/vim80&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second command lists all the file type names in the two folders where vim stores the file type definitions.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Suggested improvements to the two commands by muru which offer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd &quot;$(vim -Nesc '!echo $VIMRUNTIME' -c qa)&quot;&#xA;find syntax ftplugin -iname '*.vim' -exec basename -s .vim {} + | sort -u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16076" LastEditorUserId="25829" LastEditDate="2019-11-25T08:54:32.720" LastActivityDate="2019-11-25T08:54:32.720" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="14981" PostTypeId="2" ParentId="14968" CreationDate="2018-01-25T23:33:21.107" Score="2" Body="&lt;p&gt;You need to unset the &lt;code&gt;'startofline'&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nostartofline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'startofline'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-25T23:33:21.107" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14982" PostTypeId="2" ParentId="14974" CreationDate="2018-01-26T00:39:10.713" Score="0" Body="&lt;p&gt;I am not sure we can make this cleaner. The issue is you are pressing something accidentally. The best way to fix this is to break the bad habit. Personally, I would recommend making the &quot;restore&quot; mapping far more annoying, that way it helps you break the habit.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;space&amp;gt; :let s:winrestdict = winsaveview()&amp;lt;cr&amp;gt;&amp;lt;c-f&amp;gt;&#xA;nnoremap 1&amp;lt;space&amp;gt; :&amp;lt;c-u&amp;gt;call winrestview(s:winrestdict)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ramp up the difficulty with with crazier and crazier key mappings: &lt;code&gt;q&amp;lt;space&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;lt&amp;gt;&amp;lt;space&amp;gt;&lt;/code&gt;, &lt;code&gt;91&amp;lt;space&amp;gt;&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really do want to make this feel more native you could use &lt;code&gt;m'&lt;/code&gt; to make it so double-backtick will work, but like you said this will not restore the window position exactly.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-01-26T00:39:10.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14983" PostTypeId="1" CreationDate="2018-01-26T01:00:21.987" Score="2" ViewCount="137" Body="&lt;p&gt;Since some days ago I stumbled upon an annoying situation every time I tried to edit some files on a server with Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It won't open the files, and a split appeared on each buffer saying:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This security scheme is not implemented&#xA;[SSL Cipher ECDHE-RSA-AES256-GCM-SHA384]&#xA;I won't open a connection to XXX.XXX.XX.XX (only to XXX.XXX.XX.XX)&#xA;ftp: bind: Address already in use&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is quite similar to &lt;a href=&quot;https://www.reddit.com/r/vim/comments/4jqzg6/netrw_error_on_windows/&quot; rel=&quot;nofollow noreferrer&quot;&gt;another annoying thing some dude on Reddit had to deal with&lt;/a&gt;. I don't have a Reddit account nor want to make a new one for me, so hopefully he gets to this someday (or maybe someone here can tell him about this).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The weird thing is that, although it would show similar output, I could connect to the server with &lt;code&gt;ftp&lt;/code&gt; on the shell. Even didn't had any problems working with files with KDE's Dolphin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some hours googling around, I found a workaround for this could be making Vim to use &lt;code&gt;ftp&lt;/code&gt; in passive mode (setting &lt;code&gt;let g:netrw_ftp_cmd=&quot;ftp -p&quot;&lt;/code&gt; on ~/.vimrc - or, you know, /etc/vim/vimrc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This time it showed the files, still with a split on each buffer. But every time I did some edit and tried to save changes, it throwed another error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function netrw#NetWrite:&#xA;E16: Invalid range: 14bw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim said it didn't saved any change, but the changes on the server were actually made (!). So this turned out to be annoying as hell.&lt;/p&gt;&#xA;" OwnerUserId="15880" LastEditorUserId="15880" LastEditDate="2018-01-27T13:42:24.560" LastActivityDate="2018-01-27T13:42:24.560" Title="netrw: This security scheme is not implemented" Tags="|netrw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14984" PostTypeId="2" ParentId="14983" CreationDate="2018-01-26T01:00:21.987" Score="1" Body="&lt;p&gt;After two days scratching my bald head and googling around trying to find an answer, I realized &lt;code&gt;ftp&lt;/code&gt; has something to do with this. So I started messing around with it, trying to get rid of the &quot;This security scheme is not implemented&quot; message. So I realized executing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ftp -z nossl ftp.myserver.com&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would bypass that. Then I just changed the parameter for the &lt;code&gt;ftp&lt;/code&gt; call on vim options to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_ftp_cmd=&quot;ftp -z nossl&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;em&gt;voilá&lt;/em&gt;. Back to the game, baby. Maybe not a secure thing to do, but... well, it works.&lt;/p&gt;&#xA;" OwnerUserId="15880" LastEditorUserId="15880" LastEditDate="2018-01-27T12:18:51.173" LastActivityDate="2018-01-27T12:18:51.173" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14985" PostTypeId="1" AcceptedAnswerId="14994" CreationDate="2018-01-26T07:54:31.297" Score="0" ViewCount="3238" Body="&lt;p&gt;so this is a case where the toy doesn't look like what's advertised on the box. I tried to install the &lt;a href=&quot;https://github.com/jdkanani/vim-material-theme&quot; rel=&quot;nofollow noreferrer&quot;&gt;material-theme&lt;/a&gt; on my vim, which should be a standard exercise. However this is what it looks like on my vim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ICEJc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ICEJc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as opposed to what's advertised here:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/zedb2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zedb2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;vim colors content:&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/colors $ ls -1&#xA;guardian.vim&#xA;hybrid.vim&#xA;material-theme.vim&#xA;molokai.vim&#xA;molokaicpp.vim&#xA;molokaiyo.vim&#xA;molokaiyo_matlab.vim&#xA;molokaiyo_r.vim&#xA;molokaiyo_tex.vim&#xA;molokaiyophp.vim&#xA;monokai.vim&#xA;monokambat.vim&#xA;slate2.vim&#xA;sweyla988775.vim&#xA;two2tango.vim&#xA;wombat.vim&#xA;zenburn.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;vim syntax files:&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/syntax $ ls -1&#xA;html.vim&#xA;java.vim&#xA;json.vim&#xA;matlab.vim&#xA;php.vim&#xA;python.vim&#xA;r.vim&#xA;rmd.vim&#xA;tex.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what am I missing?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BqEda.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BqEda.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it works after trying on macvim! however it's a bitter sweet feeling.. b/c i'm so used to working on vim from within the terminal.. having to launch a new app for vim almost defeats the purpose of using vim the first place for me.. so not sure what to do next.&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="14510" LastEditDate="2018-01-27T18:53:06.183" LastActivityDate="2018-01-27T18:53:06.183" Title="why is the material theme looking all weird on my vim" Tags="|colorscheme|color|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14986" PostTypeId="1" CreationDate="2018-01-26T11:04:09.403" Score="1" ViewCount="1278" Body="&lt;p&gt;In the middle of a line, Press &lt;code&gt;v&lt;/code&gt; and select multiple lines.&lt;br&gt;&#xA;How to yank the word at current cursor from all selected lines and add spaces if the word is shorter than the longest one to make copied columns aligned.&lt;br&gt;&#xA;For example, current cursor is in the beginning of second data_out from first line.&lt;br&gt;&#xA;Please note below example is in the middle of a file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     ...&#xA;     data_out =&amp;gt; data_out,&#xA;     read     =&amp;gt; read,&#xA;     write    =&amp;gt; write,&#xA;     full     =&amp;gt; full,&#xA;     notempty =&amp;gt; notempty,&#xA;     ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After &quot;copy&quot; I can paste below columns. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;data_in ,&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;data_out,&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;read    ,&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;write   ,&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;full    ,&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;notempty,&lt;/code&gt;  &lt;/p&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="13402" LastEditDate="2018-01-26T17:11:45.153" LastActivityDate="2018-01-26T17:11:45.153" Title="How to yank word from all selected lines in visual mode?" Tags="|cut-copy-paste|visual-mode|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14987" PostTypeId="2" ParentId="14986" CreationDate="2018-01-26T11:34:21.167" Score="2" Body="&lt;p&gt;You can do it with using block selection (&lt;a href=&quot;http://vimhelp.appspot.com/usr_04.txt.html#04%2e4&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 04.4&lt;/code&gt;&lt;/a&gt;) and &lt;code&gt;A&lt;/code&gt; (&lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#v_b_A_example&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help v_b_A_example&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-q&amp;gt;Gx&lt;/code&gt;: use visual block to delete leading space&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f &amp;lt;c-q&amp;gt;G$x&lt;/code&gt;: delete the block from the space to the end of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-q&amp;gt;G$A,&amp;lt;esc&amp;gt;&lt;/code&gt;: add the comma to the end of each line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Q&lt;/kbd&gt; above is intended to start block selection -- as it was noted in the comments, the default is &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt;; I'm using the alternative mentioned in &lt;a href=&quot;http://vimhelp.appspot.com/gui_w32.txt.html#CTRL%2dQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help CTRL-Q&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also do it through substitute(&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3asu&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :su&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%s/^\s*//&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%s/\s=.*$/,/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I want it works in visual mode because sometimes the code is not&#xA;  perfectly column aligned. So hope there is an easy way to column copy&#xA;  in the visual mode instead of manually align the code first.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can do this without changing the code visually; what you really want is to retrieve the number of the lines currently selected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyIndent()&#xA;    silent s/^\s*//&#xA;    silent s/\s=.*$/,/&#xA;endfunction&#xA;&#xA;vnoremap &amp;lt;leader&amp;gt;i :call MyIndent()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this you can select the lines and hit leader (usually &lt;kbd&gt;\&lt;/kbd&gt;)+&lt;kbd&gt;i&lt;/kbd&gt; to perform the changes.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2018-01-26T17:03:45.790" LastActivityDate="2018-01-26T17:03:45.790" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="14988" PostTypeId="1" AcceptedAnswerId="14993" CreationDate="2018-01-26T11:44:57.060" Score="0" ViewCount="68" Body="&lt;p&gt;I've created a macro to add a piece of code.&lt;br&gt;&#xA;The macro runs fine.&lt;br&gt;&#xA;But when added to .vimrc, it reports error.&lt;br&gt;&#xA;(The macro becomes weird when paste here.)&lt;br&gt;&#xA;    &lt;code&gt;let @p='iprocess (clk, resetn)&lt;/code&gt;&lt;br&gt;&#xA;    &lt;code&gt;€kbbegin&lt;/code&gt;&lt;br&gt;&#xA;    &lt;code&gt;if (resetn = '0') then&lt;/code&gt;    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;€kbelse€kbif (clk'event and clk = '1') then&#xA;&#xA;€kbend if;&#xA;€kbend if;&#xA;€ku€@7€kb€kb€kb€kd€kuprocess;q€kb'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/53XhI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/53XhI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DCqbu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DCqbu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-01-26T16:09:57.567" Title="Why .vimrc reports error when adding recorded macro?" Tags="|vimrc|macro|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14990" PostTypeId="2" ParentId="5780" CreationDate="2018-01-26T12:53:21.040" Score="31" Body="&lt;p&gt;If your version of vim is recent enough (v7.4.2011+), you can ask for known filetypes with the function we can now use to help define manual autocompletion: &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getcompletion%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;getcompletion()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:echo getcompletion('', 'filetype')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you want to restrict the list to filetypes starting with a &lt;code&gt;'c'&lt;/code&gt;, you'd call&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:echo getcompletion('c', 'filetype')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and so on.&lt;/p&gt;&#xA;&lt;p&gt;Note: unlike solutions that parse the file names and directory names in &lt;code&gt;$VIMRUNTIME/{syntax,ftplugin}/&lt;/code&gt;, this solution analyses &lt;code&gt;'runtimepath'&lt;/code&gt; as well.&#xA;As far as I understand, it doesn't see new filetypes defined/registered on the fly with &lt;code&gt;set ft=foobar&lt;/code&gt;, nor after autocommands.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2022-10-19T13:23:43.637" LastActivityDate="2022-10-19T13:23:43.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14992" PostTypeId="2" ParentId="8768" CreationDate="2018-01-26T14:57:12.427" Score="2" Body="&lt;p&gt;Cool idea!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't mention what you think is wrong with your code. It looks pretty good to me!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd probably do it the other way around: it's only the &lt;em&gt;local&lt;/em&gt; behaviour you want to change, so ideally, we'd remove the &lt;code&gt;GlobalSpell&lt;/code&gt; function and all the Global mappings, and just alter the local spelling functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately this approach only works if &lt;code&gt;'spellfile'&lt;/code&gt; isn't empty before the autocommand runs. (Because with an empty &lt;code&gt;'spellfile'&lt;/code&gt;, Vim figures out a location in the &lt;code&gt;'runtimepath'&lt;/code&gt; at the time you add a spelling, but you have no way of accessing that path.) It &lt;em&gt;also&lt;/em&gt; won't work if &lt;code&gt;'spellfile'&lt;/code&gt; is already a list: to be more robust it should really count the entries and alter the &lt;code&gt;zg&lt;/code&gt; count accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, the following approach is okay for personal use in a .vimrc, but you can't really use it in your plugin.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set spell&#xA;set spellfile=~/global.utf-8.add&#xA;&#xA;augroup persistent_spelling&#xA;  autocmd!&#xA;  autocmd BufNewFile,BufRead * let &amp;amp;l:spellfile .= ',' . expand('%:p:h') . '/.' .&#xA;    \ substitute(expand('%:t'), '\(.*\)\..*', '\1', '') . '.utf-8.add'&#xA;augroup END&#xA;&#xA;function! LocalSpell(cmd)&#xA;  if &amp;amp;l:spellfile !~ &quot;,&quot;&#xA;    execute &quot;normal! &quot; . a:cmd&#xA;  else&#xA;    execute &quot;normal! 2&quot; . tolower(a:cmd)&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap zG :call LocalSpell(&quot;zG&quot;)&amp;lt;cr&amp;gt;&#xA;nnoremap zW :call LocalSpell(&quot;zW&quot;)&amp;lt;cr&amp;gt;&#xA;nnoremap zuG :call LocalSpell(&quot;zuG&quot;)&amp;lt;cr&amp;gt;&#xA;nnoremap zuW :call LocalSpell(&quot;zuW&quot;)&amp;lt;cr&amp;gt;&#xA;vnoremap zG :call LocalSpell(&quot;gvzG&quot;)&amp;lt;cr&amp;gt;&#xA;vnoremap zW :call LocalSpell(&quot;gvzW&quot;)&amp;lt;cr&amp;gt;&#xA;vnoremap zuG :call LocalSpell(&quot;gvzuG&quot;)&amp;lt;cr&amp;gt;&#xA;vnoremap zuW :call LocalSpell(&quot;gvzuW&quot;)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above I also surrounded your &lt;code&gt;autocommand&lt;/code&gt; in an &lt;code&gt;augroup&lt;/code&gt;, which is always a good idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also consider using expression mappings. You would then&#xA;remove the &lt;code&gt;if&lt;/code&gt; block from the function, and instead write mappings like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; zG if &amp;amp;l:spellfile !~ ',' ? 'zG' : ':call LocalSpell(&quot;zG&quot;)&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if it's actually worth it in this case, though: you're just&#xA;moving complexity from the function to the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only other thing that sticks out is the long series of very similar map commands. You could trim this down a bit with a loop (and unlike the above you &lt;em&gt;can&lt;/em&gt; use this approach in your plugin):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for lhs in ['zG', 'zW', 'zuG', 'zuW']&#xA;  execute 'nnoremap' lhs ':call LocalSpell(&quot;'.lhs.'&quot;)&amp;lt;cr&amp;gt;'&#xA;  execute 'vnoremap' lhs ':call LocalSpell(&quot;gv'.lhs.'&quot;)&amp;lt;cr&amp;gt;'&#xA;  let lhs = tolower(lhs)&#xA;  execute 'nnoremap' lhs ':call GlobalSpell(&quot;'.lhs.'&quot;)&amp;lt;cr&amp;gt;'&#xA;  execute 'vnoremap' lhs ':call GlobalSpell(&quot;gv'.lhs.'&quot;)&amp;lt;cr&amp;gt;'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're feeling super &lt;a href=&quot;https://en.wikipedia.org/wiki/Don%27t_repeat_yourself&quot; rel=&quot;nofollow noreferrer&quot;&gt;DRY&lt;/a&gt; then you could create all the mappings with a single &lt;code&gt;:execute&lt;/code&gt; line, but I think this is actually a bad idea: you'd end up with much more complicated code that's almost as long as the original! I tried it anyway, for fun:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for [map_type, gv_type] in items({'n': '', 'v': 'gv'})&#xA;  for scope_type in ['Local', 'Global']&#xA;    for undo_type in ['', 'u']&#xA;      for spell_type in ['G', 'W']&#xA;        if scope_type == 'Global'&#xA;          let spell_type = tolower(spell_type)&#xA;        endif&#xA;        let lhs = 'z'.undo_type.spell_type&#xA;        execute map_type.'noremap' lhs&#xA;          \ ':call' scope_type.'Spell(&quot;'.gv_type.lhs.'&quot;)&amp;lt;cr&amp;gt;'&#xA;      endfor&#xA;    endfor&#xA;  endfor&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally I note that &lt;em&gt;none&lt;/em&gt; of the above works if the file you're editing has an underscore in its name, because you cannot use underscores in spell file names! You'll need to alter your autocommand to strip these out/transform them.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-26T14:57:12.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14993" PostTypeId="2" ParentId="14988" CreationDate="2018-01-26T15:00:49.673" Score="1" Body="&lt;p&gt;The way you initialize has two flaws:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, it is usually better to use &lt;code&gt;setreg()&lt;/code&gt; to set the value of a register, it is more robust than &lt;code&gt;let @X =&lt;/code&gt; and allows you to choose the type of the register (characterwise, linewise, blockwise)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, your string contains the keycode of some key (e.g. &lt;code&gt;^M&lt;/code&gt; for &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;). I guess that you recorded your macro and tried to get what you recorded and that's what caused the problem. In your vimrc you need to write the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setreg('p',  &quot;iprocess (clk, resetn)^M€kbbegin^Mif (resetn = '0') then^M&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;^M&lt;/code&gt; is not entered manually but is entered by pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; then &lt;kbd&gt;Enter&lt;/kbd&gt; this allows you to write the keycode of the key which &lt;code&gt;setreg()&lt;/code&gt; can then interpret properly. Note that you should do that with the others special keys like &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; As mentioned by @Rich in the comments using &lt;code&gt;\&amp;lt;CR&amp;gt;&lt;/code&gt; inside a double quoted string is arguably more robust than &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#setreg%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h setreg()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-V&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-V&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-01-26T16:09:57.567" LastActivityDate="2018-01-26T16:09:57.567" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14994" PostTypeId="2" ParentId="14985" CreationDate="2018-01-26T18:32:31.383" Score="5" Body="&lt;p&gt;Looking through the color settings in the theme, it's only defining the full color range for the GUI, and is using the default 16 terminal colors.  Your screen shot appears to be using fairly standard terminal colors, so I am going to assume that you are running in a terminal.  If you are editing local files, the easiest way to get the full color scheme would be to switch from vim to gvim.  (If you are using the default install of vim on a Linux desktop, you may need to install one of the GUI packages.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have to run in a terminal, and your terminal supports 256 colors, you may be able to approximate the colors by converting the theme.  This works better for some themes than for others, because 256 colors is still a lot fewer than the ~16 million available to the GUI.  Getting 256 color terminal support if you don't have it set up already is a whole topic unto itself, but there is some good advice in the vim wiki here: &lt;a href=&quot;http://vim.wikia.com/wiki/256_colors_in_vim&quot; rel=&quot;noreferrer&quot;&gt;http://vim.wikia.com/wiki/256_colors_in_vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Short version: If your terminal capabilities are configured correctly, &lt;code&gt;:set t_Co=256&lt;/code&gt; should be sufficient.  If not, you may be in for a crash course in one of the most arcane subjects in modern computing.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there, there are several plugins that will attempt to convert a GUI theme to a 256 color theme. &#xA; &lt;a href=&quot;http://vim.wikia.com/wiki/Using_GUI_color_settings_in_a_terminal&quot; rel=&quot;noreferrer&quot;&gt;http://vim.wikia.com/wiki/Using_GUI_color_settings_in_a_terminal&lt;/a&gt; has some instructions for how to use guicolorscheme or CSApprox.  I haven't used either of these in a very long time, so I can't comment on their relative merits.&lt;/p&gt;&#xA;" OwnerUserId="1688" LastActivityDate="2018-01-26T18:32:31.383" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14996" PostTypeId="1" AcceptedAnswerId="14998" CreationDate="2018-01-27T00:15:54.387" Score="2" ViewCount="1599" Body="&lt;p&gt;I want to turn off the syntax highlighting for TODO items, like TODO and FIXME. How can I achieve this?&lt;/p&gt;&#xA;" OwnerUserId="12054" LastEditorUserId="4866" LastEditDate="2024-03-03T21:30:45.027" LastActivityDate="2024-03-03T21:30:45.027" Title="Turn off syntax highlighting for TODO items" Tags="|highlight|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14997" PostTypeId="1" CreationDate="2018-01-27T01:23:46.697" Score="0" ViewCount="317" Body="&lt;p&gt;How can I get a numeric return value from an Ex command. For example, if I want to set a variable to the number of times a pattern occurs in a buffer. I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let answer=exe('%s/xyz//n')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I get the error &quot;Unknown function exe&quot;.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-01-27T07:54:18.000" Title="How do I get a numeric return value from an Ex command?" Tags="|vimscript|ex-mode|functions|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14998" PostTypeId="2" ParentId="14996" CreationDate="2018-01-27T03:01:47.747" Score="5" Body="&lt;p&gt;The brute force approach is to nuke it with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi clear TODO&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This may have a side effect you don't expect, though, since it can remove all highlighting from the text in question. For instance, if the TODO text is in a code comment where normal comment text has some other highlighting, then after your run this command the TODO text will appear different (e.g. white on black) than the rest of the comment text (e.g. yellow on black).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe you're okay with that. If you're not someone may come along with a more nuanced solution.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-01-27T03:15:28.880" LastActivityDate="2018-01-27T03:15:28.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14999" PostTypeId="2" ParentId="14997" CreationDate="2018-01-27T03:25:17.593" Score="3" Body="&lt;p&gt;The function is &lt;code&gt;execute()&lt;/code&gt; not &lt;code&gt;exe()&lt;/code&gt;. Command names can be abbreviated, not functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer to your question &quot;how can I get a numeric return value from a command&quot; is &quot;call a command that returns a number&quot;. ;) No seriously. Your assignment to a variable is valid. But your example won't work as &lt;code&gt;execute()&lt;/code&gt; returns the string that is returned by the &lt;code&gt;:s&lt;/code&gt; call. And in fact &lt;code&gt;execute()&lt;/code&gt; always returns strings so you'll never get a number from it. But a numerical string will often do and if you &lt;em&gt;really&lt;/em&gt; need a number you can wrap a command/function that returns a string in &lt;code&gt;str2nr()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that answers your question, but turning to your example we can get a numerical string answer as follows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The string returned by &lt;code&gt;:s&lt;/code&gt; is of the form &lt;code&gt;X matches on Y lines&lt;/code&gt; so if you want to extract the number of matches you can use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let answer=substitute(execute('%s/xyz//n'), ' .*', '', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It just strips off everything from the first space on leaving the first number. A bit hacky. &lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-01-27T07:54:18.000" LastActivityDate="2018-01-27T07:54:18.000" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="15000" PostTypeId="2" ParentId="11240" CreationDate="2018-01-27T03:39:44.847" Score="9" Body="&lt;p&gt;I think you can get the same result as in the video with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;${1/(&quot;.*)|.*/(?1:comment =&amp;gt; )/}${1:&quot;some comment&quot;}${1/(&quot;.*)|.*/(?1:,&#xA;)/}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It can be broken down into 3 parts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      ┌ mirror of tabstop n°1&#xA;      │                          ┌ substitution&#xA;    ┌─┤┌─────────────────────────┤&#xA;(A) ${1/(&quot;.*)|.*/(?1:comment =&amp;gt; )/}&#xA;&#xA;&#xA;      ┌ tabstop n° 1&#xA;      │              ┌ placeholder text,                                       &#xA;      │              │ which fills the tabstop as long as you don't replace it &#xA;    ┌─┤┌─────────────┤&#xA;(B) ${1:&quot;some comment&quot;}&#xA;&#xA;&#xA;      ┌ mirror of tabstop n°1&#xA;      │              ┌ beginning of substitution&#xA;    ┌─┤┌─────────────┤&#xA;(C) ${1/(&quot;.*)|.*/(?1:,&#xA;    )/}&#xA;    └─┤&#xA;      └ end of substitution&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(B)&lt;/code&gt; is the  real tabstop. The one in which  you can insert an arbitrary comment.   &lt;code&gt;(A)&lt;/code&gt; and &lt;code&gt;(C)&lt;/code&gt; are  just mirrors  of &lt;code&gt;(B)&lt;/code&gt;. But,  contrary to  a simple  mirror, which  would simply  re-insert the original tabstop  at the desired position  (and which here you  would write as &lt;code&gt;$1&lt;/code&gt;),  these mirrors perform a substitution on the original tabstop.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To avoid any confusion later, here are 3 kinds of &lt;code&gt;${some_number}&lt;/code&gt; token which are going to be used later:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;┌───────────────────────────┬──────────────────────────────────────────────┐&#xA;│ $1                        │ a tabstop, if it's the first in the snippet  │&#xA;│                           │ a mirror of the 1st tabstop otherwise        │&#xA;├───────────────────────────┼──────────────────────────────────────────────┤&#xA;│ ${1:hello}                │ a tabstop, whose placeholder text is `hello` │&#xA;├───────────────────────────┼──────────────────────────────────────────────┤&#xA;│ ${1/pattern/replacement/} │ a mirror of the 1st tabstop                  │&#xA;│                           │ in which you substitute the text             │&#xA;│                           │ matched by `pattern` with `replacement`      │&#xA;└───────────────────────────┴──────────────────────────────────────────────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's how &lt;code&gt;(A)&lt;/code&gt; works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;:&lt;br&gt;&#xA;if you insert some text beginning with a double quote in the tabstop, the mirror should prepend it with &lt;code&gt;comment =&amp;gt;&lt;/code&gt;. Otherwise, it shouldn't insert anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose that when you jump to the tabstop &lt;code&gt;(B)&lt;/code&gt;, you write &lt;code&gt;&quot;hello world&quot;&lt;/code&gt;, and suppose you wrote &lt;code&gt;(A)&lt;/code&gt; as a simple mirror &lt;code&gt;$1&lt;/code&gt;. You would get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet test&#xA;    $1${1:&quot;some comment&quot;}&#xA;endsnippet&#xA;&#xA;→&#xA;&#xA;&quot;some comment&quot;&quot;some comment&quot;&#xA;└────────────┤└────────────┤&#xA;             │             └ tabstop&#xA;             └ mirror&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that's not how &lt;code&gt;(A)&lt;/code&gt; was written earlier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;${1/(&quot;.*)|.*/(?1:comment =&amp;gt; )/}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, you perform a substitution which replaces the text matched by the pattern &lt;code&gt;(&quot;.*)|.*&lt;/code&gt; with the replacement &lt;code&gt;(?1:comment =&amp;gt; )&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pattern consists of 2 branches, the first one being captured by the parentheses so that you can check whether it was matched in the replacement part of the substitution via &lt;code&gt;?1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first branch describes some text beginning with a double quote:  &lt;code&gt;&quot;.*&lt;/code&gt;,&#xA;while the 2nd one describes any text:  &lt;code&gt;.*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The replacement part checks whether the 1st capturing group is not empty (i.e. &lt;em&gt;“Does the text you wrote in the 1st tabstop begin with a double quote?”&lt;/em&gt;). If it's not, it's replaced with &lt;code&gt;comment =&amp;gt;&lt;/code&gt;, otherwise nothing is inserted. Nothing is inserted because there's no 2nd &lt;code&gt;:&lt;/code&gt;. IOW, these 2 replacements are equivalent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(?1:comment =&amp;gt; )&#xA;&#xA;(?1:comment =&amp;gt; :)&#xA; └┤ └─────────┤└┤&#xA;  │           │ └ if no, don't insert anything&#xA;  │           └ if yes, replace it with `comment =&amp;gt; `&#xA;  └ is the tabstop matched by the 1st capturing group?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the 2nd branch in the pattern (&lt;code&gt;|.*&lt;/code&gt;) is important. It asks UltiSnips to remove the whole mirror if the original tabstop doesn't begin with a double quote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And note that the parentheses in the replacement are also important. They tell UltiSnips that it's not a literal string, but a conditional expression which must be evaluated. They are similar to the &lt;code&gt;\=&lt;/code&gt; token which you may use in the replacement part of a substitution command in Vim (see &lt;code&gt;:h :s\=&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's how &lt;code&gt;(C)&lt;/code&gt; works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;:&lt;br&gt;&#xA;if you insert some text beginning with a double quote in the tabstop, the mirror should append it with a comma, a newline, and some indentation on the next line. Otherwise, it shouldn't insert anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Functionally, &lt;code&gt;(C)&lt;/code&gt; is identical to &lt;code&gt;(A)&lt;/code&gt;: a mirror whose replacement part checks the contents of the original tabstop to decide what it should insert. The only difference is in the contents of the replacement part. The latter contains here a comma, a newline, and some indentation.&#xA;Since it contains a newline, the code of the mirror is written on 2 lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                  newline inside replacement&#xA;                  v&#xA;${1/(&quot;.*)|.*/(?1:, &#xA;)/}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may find the code a little unreadable, and be tempted to move the newline outside the replacement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                     newline outside replacement&#xA;                     v&#xA;${1/(&quot;.*)|.*/(?1:,)/}&#xA;…&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if you do, when you'll remove the tabstop, the whole line won't be removed: the newline and the indentation will remain. You have to include it in the replacement, so that its presence depends on the first capturing group being non-empty, and so that it's removed when you decide that the tabstop is useless.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's a full snippet which should implement the behavior you observed in the video:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet user &quot;demo&quot; bm&#xA;group { &quot;${1:username}&quot;:&#xA;    ensure =&amp;gt; ${2:present},&#xA;    uid =&amp;gt; ${3:123},&#xA;    gid =&amp;gt; ${4:123},&#xA;    ${5/(&quot;.*)|.*/(?1:comment =&amp;gt; )/}${5:&quot;some comment&quot;}${5/(&quot;.*)|.*/(?1:,&#xA;    )/}home =&amp;gt; ${6:&quot;/home/$1&quot;},&#xA;    managehome =&amp;gt; ${7:false},&#xA;    require =&amp;gt; ${8/./\u$0/}[&quot;${8:group}&quot;],&#xA;}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At least it does seem to behave like in the video on my machine:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/B9KkL.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/B9KkL.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see &lt;code&gt;:h Ultisnips-replacement-string&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15612" LastEditorUserId="15612" LastEditDate="2018-01-27T05:22:08.890" LastActivityDate="2018-01-27T05:22:08.890" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15001" PostTypeId="2" ParentId="10913" CreationDate="2018-01-27T07:06:00.863" Score="3" Body="&lt;p&gt;Here's how &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/blob/master/autoload/youcompleteme.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;youcompleteme&lt;/a&gt; does.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Define a function for determining whether python3 is available:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:UsingPython3()&#xA;  if has('python3')&#xA;    return 1&#xA;  endif&#xA;    return 0&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;then get the right python command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:using_python3 = s:UsingPython3()&#xA;let s:python_until_eof = s:using_python3 ? &quot;python3 &amp;lt;&amp;lt; EOF&quot; : &quot;python &amp;lt;&amp;lt; EOF&quot;&#xA;let s:python_command = s:using_python3 ? &quot;py3 &quot; : &quot;py &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="9709" LastActivityDate="2018-01-27T07:06:00.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15002" PostTypeId="1" AcceptedAnswerId="15003" CreationDate="2018-01-27T08:12:16.960" Score="6" ViewCount="3430" Body="&lt;p&gt;I use Vim a lot for writing tasks and I used ^p for completions. However, is there a plugin that suggests you completions while typing like in Andriod-smartphones ?&#xA;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="16095" LastActivityDate="2018-01-28T13:16:40.690" Title="Completion suggestions while typing" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15003" PostTypeId="2" ParentId="15002" CreationDate="2018-01-27T08:24:37.267" Score="5" Body="&lt;p&gt;By &quot;suggests you completions&quot; I assume you mean that the completion popup appears automatically without interrupting your typing. If so, yes, there are a number of them. To name two &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1879&quot; rel=&quot;nofollow noreferrer&quot;&gt;AutoComplPop&lt;/a&gt; and &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouCompleteMe&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://vimawesome.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;VimAwesome&lt;/a&gt; to search for others. It has &lt;a href=&quot;https://vimawesome.com/?q=tag:autocomplete&quot; rel=&quot;nofollow noreferrer&quot;&gt;an entire category&lt;/a&gt; dedicated to &quot;autocomplete&quot;, a super set of the type of plugin you're interested in. Included are &lt;a href=&quot;https://vi.stackexchange.com/questions/15002/completion-suggestions-while-typing#comment25712_15003&quot;&gt;the two mentioned by Karl&lt;/a&gt; in the comments below: &lt;a href=&quot;https://vimawesome.com/plugin/nvim-completion-manager&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvim-completion-manager&lt;/a&gt; and &lt;a href=&quot;https://vimawesome.com/plugin/deoplete-nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;deoplete&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-01-28T13:16:40.690" LastActivityDate="2018-01-28T13:16:40.690" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15004" PostTypeId="1" CreationDate="2018-01-27T10:54:16.943" Score="0" ViewCount="155" Body="&lt;p&gt;How can I get help on operators as opposed to normal mode commands? For example, if I type the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I will get the help on the normal mode dot command, not on the string concatenation operator which is the same symbol.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-01-30T07:42:14.997" Title="How do you get help with operators?" Tags="|help-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15005" PostTypeId="2" ParentId="15004" CreationDate="2018-01-27T11:22:15.707" Score="2" Body="&lt;p&gt;The help tags for those are usually prefixed with &lt;code&gt;expr-&lt;/code&gt;. For example: &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-.&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help expr-.&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expr5 and expr6                                         expr5 expr6&#xA;---------------&#xA;expr6 +  expr6 ..       Number addition or List concatenation expr-+&#xA;expr6 -  expr6 ..       Number subtraction                      expr--&#xA;expr6 .  expr6 ..       String concatenation                    expr-.&#xA;&#xA;For Lists only &quot;+&quot; is possible and then both expr6 must be a list.  The&#xA;result is a new list with the two lists Concatenated.&#xA;&#xA;expr7 *  expr7 ..       Number multiplication                   expr-star&#xA;expr7 /  expr7 ..       Number division                         expr-/&#xA;expr7 %  expr7 ..       Number modulo                           expr-%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-01-27T11:22:15.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15006" PostTypeId="2" ParentId="15004" CreationDate="2018-01-27T11:23:54.820" Score="3" Body="&lt;p&gt;If you want to know about string concatenation, you can use the help entry &lt;code&gt;:h expr-.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the help tags follow a generic style, which if you know it, it helps to find the correct tag. (e.g. options are always enclosed in single quotes). To learn about that, check the help (of course :)) at &lt;a href=&quot;http://vimhelp.appspot.com/usr_02.txt.html#help-summary&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h help-summary&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="7814" LastEditDate="2018-01-30T07:42:14.997" LastActivityDate="2018-01-30T07:42:14.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15007" PostTypeId="1" AcceptedAnswerId="15008" CreationDate="2018-01-27T11:33:59.263" Score="0" ViewCount="57" Body="&lt;p&gt;Once in a while I do work on a large number of files (i.e. today it was about 1,700) using a command such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim `find . -name *.cpp`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I use the &quot;n&quot; (no changes) or &quot;wn&quot; (made a change) to go through all my files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once in a while I notice I missed something and would like to restart at a certain position. Is there a way to reset that buffer position? I found that I could use a &lt;code&gt;&amp;lt;count&amp;gt;:n&lt;/code&gt; or &lt;code&gt;&amp;lt;count&amp;gt;:N&lt;/code&gt; but that's not as practical as specifying that this or that specific buffer should now be the one (i.e. I have to do the math...)&lt;/p&gt;&#xA;" OwnerUserId="9276" LastActivityDate="2018-01-27T11:52:50.637" Title="Is there a way to change the &quot;current buffer&quot;--the one that gets defined when I use &quot;n&quot; and &quot;N&quot;?" Tags="|buffers|navigation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15008" PostTypeId="2" ParentId="15007" CreationDate="2018-01-27T11:52:50.637" Score="4" Body="&lt;p&gt;With &lt;code&gt;:n&lt;/code&gt; you are going through the argument list. You can use &lt;code&gt;:args&lt;/code&gt; to see where you are in the current argument list. You can use &lt;code&gt;:first&lt;/code&gt; to start at the beginning and use &lt;code&gt;:last&lt;/code&gt; to go to the last argument. You can also use &lt;code&gt;:previous&lt;/code&gt; to go to the previous argument. To add files to the argument list you can use the &lt;code&gt;:argadd&lt;/code&gt; and &lt;code&gt;argedit&lt;/code&gt; command. And finally if you want to be at a specific argument, use &lt;code&gt;:Nargu&lt;/code&gt; command (e.g. to edit the third file from your argument list, use &lt;code&gt;:3argu&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, there is also the bufferlist, which is independent of the argument list. You can move through the buffer list using &lt;code&gt;:bnext&lt;/code&gt; and similar commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the detail about it at &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#arglist&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h arglist&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/usr_07.txt.html#07.2&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 07.2&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-01-27T11:52:50.637" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15009" PostTypeId="1" AcceptedAnswerId="15019" CreationDate="2018-01-27T13:51:24.383" Score="5" ViewCount="1196" Body="&lt;p&gt;I found it strange that I can never have Vim show line number automatically for &lt;code&gt;.py&lt;/code&gt; files, even if I have this as my &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=dark&#xA;autocmd FileType py,c set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Strangely enough, when I run &lt;code&gt;vim xxx.c&lt;/code&gt; (regardless of whether &lt;code&gt;xxx.c&lt;/code&gt; exists), it enables line number automatically, but never when I run &lt;code&gt;vim xxx.py&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried some random extensions, but only &lt;code&gt;c&lt;/code&gt; works. Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType py,c,xxx,yyy,abcd,wxyz set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I open a file with the extension written above, only &lt;code&gt;.c&lt;/code&gt; file has line number automatically enabled. I tried re-ordering those extensions, but it made no difference.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In case they matter, here are my related settings. I've never done any modification to Vim except creating a &lt;code&gt;.vimrc&lt;/code&gt; file under my home directory, after installing Vim using &lt;code&gt;sudo apt install vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output when I run &lt;code&gt;vim --version&lt;/code&gt; on my Windows Subsystem for Linux:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)&#xA;Included patches: 1-1689&#xA;Extra patches: 8.0.0056&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +tag_binary&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_old_static&#xA;+autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;-balloon_eval    +float           +mouse_urxvt     -tcl&#xA;-browse          +folding         +mouse_xterm     +terminfo&#xA;++builtin_terms  -footer          +multi_byte      +termresponse&#xA;+byte_offset     +fork()          +multi_lang      +textobjects&#xA;+channel         +gettext         -mzscheme        +timers&#xA;+cindent         -hangul_input    +netbeans_intg   +title&#xA;-clientserver    +iconv           +packages        -toolbar&#xA;-clipboard       +insert_expand   +path_extra      +user_commands&#xA;+cmdline_compl   +job             -perl            +vertsplit&#xA;+cmdline_hist    +jumplist        +persistent_undo +virtualedit&#xA;+cmdline_info    +keymap          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       -python          +vreplace&#xA;+cscope          +lispindent      +python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con      -lua             +rightleft       +writebackup&#xA;+diff            +menu            -ruby            -X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;-dnd             +modify_fname    +signs           -xim&#xA;-ebcdic          +mouse           +smartindent     -xsmp&#xA;+emacs_tags      -mouseshape      +startuptime     -xterm_clipboard&#xA;+eval            +mouse_dec       +statusline      -xterm_save&#xA;+ex_extra        +mouse_gpm       -sun_workshop    -xpm&#xA;+extra_search    -mouse_jsbterm   +syntax&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl     -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the output for &lt;code&gt;uname -a&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Linux iBug-PC 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Extra information:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Non-existent environment variable: $VIM&#xA;Non-modified file: /usr/share/vim/vimrc&#xA;Non-existent directory: ~/.vim/&#xA;Non-existent file: ~/.exrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Kindly tell me how to make Vim show line number for Python scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: In this post, &quot;Python file&quot; means exactly any file with extension &lt;code&gt;.py&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16096" LastEditorUserId="16096" LastEditDate="2018-01-27T13:59:48.947" LastActivityDate="2019-10-06T02:07:58.123" Title="Vim never shows line number for Python files even though I have `.vimrc`" Tags="|vimrc|autocmd|filetype|line-numbers|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15010" PostTypeId="1" CreationDate="2018-01-27T17:07:46.447" Score="0" ViewCount="40" Body="&lt;p&gt;After I write a file with &lt;kbd&gt;:w!&lt;/kbd&gt; I see in the ruler the following output message text in the ruler or status line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;FILE_NAME&quot; 192L, 9357C written&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is this output message text called in the &lt;code&gt;help&lt;/code&gt; system?&lt;/li&gt;&#xA;&lt;li&gt;How do I edit it to show word count?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The output of the &lt;code&gt;wc&lt;/code&gt; command shows line, word and character counts.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wc ./FILE_NAME&#xA;192 1695 9357 ./FILE_NAME&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I write a file I would like to add &lt;strong&gt;1695W&lt;/strong&gt; to the output message text shown.&lt;/p&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="6590" LastEditDate="2018-01-27T19:05:46.083" LastActivityDate="2018-01-27T19:56:00.090" Title="How do I add word count to output message on successful write?" Tags="|save|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15011" PostTypeId="1" AcceptedAnswerId="15012" CreationDate="2018-01-27T18:02:02.713" Score="5" ViewCount="955" Body="&lt;p&gt;This didn't get much love on stackoverflow (&lt;a href=&quot;https://stackoverflow.com/q/48269793/2512141&quot;&gt;https://stackoverflow.com/q/48269793/2512141&lt;/a&gt;), but I think it's important so I'm reposting here. I think this could be a major barrier to people using Vim's buffers as they're intended, and consequently they resort to tabs to get the file-switching capability they need. Text from the original post follows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's Netrw file explorer has the following bug: Running the command :e. will open Netrw, but after Netrw closes there is a latent buffer in Vim's buffer list which cannot be traversed with command :bprev. (:bnext works fine.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This bug is discussed in the following places:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.bountysource.com/issues/45921122-previous-doesn-t-work-with-e-buffer&quot; rel=&quot;noreferrer&quot;&gt;https://www.bountysource.com/issues/45921122-previous-doesn-t-work-with-e-buffer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_use/zzeQItJQNZI&quot; rel=&quot;noreferrer&quot;&gt;https://groups.google.com/forum/#!topic/vim_use/zzeQItJQNZI&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To replicate this bug, start Vim and run the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls!&#xA;:edit ./file1.txt | ls!&#xA;:edit ./file2.txt | ls!&#xA;:e. #(choose file3.txt in Netrw)&#xA;:edit ./file4.txt | ls!&#xA;:ls!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At this point, you will see buffers for the files you have opened as well as some buffers with paths, and a buffer with [No Name]. Try to navigate these buffers with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bnext | ls!&#xA;:bprev | ls!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will find that :bnext successfully loops over the buffers, but :bprev hangs on the Netrw buffer. Is there a workaround for this bug so that buffer navigation with :bnext and :bprev still works?&lt;/p&gt;&#xA;" OwnerUserId="16100" LastActivityDate="2020-02-22T16:33:00.357" Title="Is there a workaround for Vim's Netrw :bprev bug?" Tags="|netrw|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15012" PostTypeId="2" ParentId="15011" CreationDate="2018-01-27T18:02:36.603" Score="3" Body="&lt;p&gt;I've discovered through experimentation that &lt;code&gt;:bprev&lt;/code&gt; will resume functioning if I delete the path buffer just prior to the &lt;code&gt;[No Name]&lt;/code&gt; buffer. However, this is burdensome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, I have started using &lt;code&gt;:Explore&lt;/code&gt; to open Netrw. This does not create the latent buffer which trips up &lt;code&gt;:bprev&lt;/code&gt;, but I am still able to browse my local directory tree and open files for editing.&lt;/p&gt;&#xA;" OwnerUserId="16100" LastEditorUserId="10604" LastEditDate="2020-02-22T16:33:00.357" LastActivityDate="2020-02-22T16:33:00.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15013" PostTypeId="2" ParentId="15010" CreationDate="2018-01-27T19:56:00.090" Score="2" Body="&lt;p&gt;I am not sure, what that message is called like and did not find anything in the help currently. However what the message looks like can be influenced with the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27shm%27&quot; rel=&quot;nofollow noreferrer&quot;&gt; 'shm'&lt;/a&gt; (shortmessage) option and the flag &lt;code&gt;l&lt;/code&gt;, see link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to change it, I would suggest to create a &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#BufWritePost&quot; rel=&quot;nofollow noreferrer&quot;&gt;BufWritePost`&lt;/a&gt; autocommand, that outputs the required information, e.g. like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! WordCount()&#xA;  let wc=wordcount()&#xA;  return  '&quot;'.&#xA;    \ expand(&quot;&amp;lt;afile&amp;gt;&quot;). '&quot; '.&#xA;    \ line('$'). 'L, '.&#xA;    \ wc['chars']. 'C '.&#xA;    \ wc['words']. 'W written'&#xA;endfunction&#xA;&#xA;augroup MyBufWritePost&#xA;  au!&#xA;  au BufWritePost * echom WordCount()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-01-27T19:56:00.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15014" PostTypeId="2" ParentId="13784" CreationDate="2018-01-27T22:24:51.160" Score="4" Body="&lt;p&gt;I had exactly the same problem when trying to get vimtex working with Skim. That is, I had vim 8 installed with &lt;code&gt;--with-client-server&lt;/code&gt; (showing as &lt;code&gt;+clientserver&lt;/code&gt;) and XQuartz running but &lt;code&gt;--servername&lt;/code&gt; option was just ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution for me was setting &lt;code&gt;DISPLAY&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;export DISPLAY=:0.0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that everything worked exactly as it should.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt;: &lt;code&gt;help x11-clientserver&lt;/code&gt; says&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The communication between client and server goes through&#xA;  the X server.  The display of the Vim server must be&#xA;  specified.  The usual protection of the X server is used,&#xA;  you must be able to open a window on the X server for the&#xA;  communication to work.  It is possible to communicate&#xA;  between different systems.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="16104" LastEditorUserId="16104" LastEditDate="2018-02-01T17:24:35.767" LastActivityDate="2018-02-01T17:24:35.767" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15015" PostTypeId="1" CreationDate="2018-01-27T23:29:13.880" Score="2" ViewCount="476" Body="&lt;p&gt;How do I globally turn off undercurls in Vim-GUIs (GVim &amp;amp; MacVim)?&lt;/p&gt;&#xA;" OwnerUserId="16107" LastActivityDate="2018-05-29T01:52:28.587" Title="How do I turn off undercurls in Vim-GUIs?" Tags="|gvim|macvim|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15016" PostTypeId="1" AcceptedAnswerId="15017" CreationDate="2018-01-28T02:55:17.553" Score="2" ViewCount="1559" Body="&lt;p&gt;I'm really struggling to figure out how to find all occurrences of a semicolon not preceded by a backslash. I'm hoping to find a quick vim command to clean up long bash commands that I've opened with fc -e vim. Usually I can just do a regular find semicolon and replace with semicolon then new line to split my commands onto separate lines to make my script more readable. In this case I have a find -exec command in there which ends with \; but is then piped into another command. I want this to all be on one line. I know it would be quick to do by hand but I'm trying to learn vim better. I've tried all kinds of things but from my understanding the following should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(\\;\)\@&amp;lt;!;/;^M/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it catches the \; in my find command as well. I would appreciate one of you pros pointing out what I'm missing here. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="16109" LastActivityDate="2018-01-28T22:03:29.813" Title="Finding all semicolons not preceded by backslash" Tags="|substitute|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15017" PostTypeId="2" ParentId="15016" CreationDate="2018-01-28T03:00:08.383" Score="4" Body="&lt;p&gt;this regex should match what you want&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/\(^\|[^\\]\)\zs;/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Broken down:&#xA;&lt;code&gt;&#xA;/\(^\|[^\\]\)\zs;/&#xA;122222222222233345&#xA; aabccdeeefgg&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 : /       start the search&#xA;2 : \(...\) group what to match first (consists of a...g)&#xA;  a: \(  begin a group (kind of making an atom)&#xA;  b: ^   start of line&#xA;  c: \|  or&#xA;  d: [   start a character class&#xA;  e: ^\\ elements of the class are all but \ (^ negates here)&#xA;  f: ]   end the character class&#xA;  g: \)  end of group&#xA;3 : \zs  set the search-start&#xA;4 : ;    what to search for&#xA;5 : /    end the search&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="11477" LastEditDate="2018-01-28T22:03:29.813" LastActivityDate="2018-01-28T22:03:29.813" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15018" PostTypeId="2" ParentId="13515" CreationDate="2018-01-28T07:57:54.450" Score="2" Body="&lt;p&gt;I'm using the &lt;a href=&quot;https://github.com/lmeijvogel/vim-yaml-helper&quot; rel=&quot;nofollow noreferrer&quot;&gt;yaml plugin by Meijvogel&lt;/a&gt; and that has a &lt;code&gt;YamlDisplayFullPath&lt;/code&gt; function which he recommends putting into autodisplay mode though I prefer it on &lt;code&gt;InsertLeave&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! InsertLeave *.yml YamlDisplayFullPath  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6828" LastEditorUserId="1841" LastEditDate="2018-01-28T18:01:52.180" LastActivityDate="2018-01-28T18:01:52.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15019" PostTypeId="2" ParentId="15009" CreationDate="2018-01-28T12:30:29.283" Score="8" Body="&lt;h2&gt;Why it didn't work&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help FileType&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                      *FileType*&#xA;FileType        When the 'filetype' option has been set.  The&#xA;                pattern is matched against the filetype.&#xA;                &amp;lt;afile&amp;gt; can be used for the name of the file&#xA;                where this option was set, and &amp;lt;amatch&amp;gt; for&#xA;                the new value of 'filetype'.  Navigating to&#xA;                another window or buffer is not allowed.&#xA;                See |filetypes|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key bit there is&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The pattern is matched against the &lt;em&gt;filetype&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;meaning that any &lt;code&gt;autocmd&lt;/code&gt; using &lt;code&gt;FileType&lt;/code&gt; should be followed by an actual filetype.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The &quot;solution&quot;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType python,c set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;HOWEVER&lt;/em&gt; read on...&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Frame Challenge : Using Vim Properly&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd&lt;/code&gt; is &lt;em&gt;NOT&lt;/em&gt; the solution to &lt;code&gt;filetype&lt;/code&gt;-dependent settings. It might seem like a good candidate at first, but Vim was built with a philosophy of placing files in a defined directory structure to affect behavior. Most vim users learn about vimrc first. But there are more (see &lt;code&gt;:help rtp&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What this means for the OP is as follows: Python (and C) &lt;code&gt;filetype&lt;/code&gt;-dependent settings, mappings, &amp;amp;c. should be placed in&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;~/.vim/ftplugin/$FILETYPE.vim&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;E.g., create &lt;code&gt;~/.vim/ftplugin/python.vim&lt;/code&gt; with the contents&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to have Python files get &lt;code&gt;number&lt;/code&gt; on. Note I used &lt;code&gt;setlocal&lt;/code&gt; to make it buffer specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find that something in these files conflicts with other settings, you should place the offending line in &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt; to have it override any other settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, make sure you at least enable filetype plugins with &lt;code&gt;filetype plugin on&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In response to comments, &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Using file extensions&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;To perform an &lt;code&gt;autocmd&lt;/code&gt; on an arbitrary file extension, you can use any of the various &lt;code&gt;autocmd&lt;/code&gt;s that match on the file name, and then use a glob (&lt;code&gt;*.ext&lt;/code&gt;) as the pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two most common I see are &lt;code&gt;BufNewFile&lt;/code&gt; and &lt;code&gt;BufRead&lt;/code&gt; (or &lt;code&gt;BufReadPost&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In practice, this is all of them (excepting a few special cases like &lt;code&gt;FileType&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help autocmd-events&lt;/code&gt; for more.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-10-06T02:07:58.123" LastActivityDate="2019-10-06T02:07:58.123" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="15020" PostTypeId="1" AcceptedAnswerId="15021" CreationDate="2018-01-28T14:38:24.197" Score="2" ViewCount="431" Body="&lt;p&gt;In insert mode, &lt;code&gt;CTRL-P&lt;/code&gt; autocompletes a word from earlier in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A subsequent &lt;code&gt;CTRL-X CTRL-P&lt;/code&gt; will insert the word that followed that word.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;canFail :: Either Error Success&#xA;&#xA;canAlsoFail :: Ei█&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;CTRL-P&lt;/code&gt; autocompletes &quot;Either&quot; &amp;nbsp; &amp;nbsp; &lt;code&gt;canAlsoFail :: Either█&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;CTRL-X CTRL-P&lt;/code&gt; inserts &quot;Error&quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;code&gt;canAlsoFail :: Either Error█&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;CTRL-X CTRL-P&lt;/code&gt; inserts &quot;Success&quot;  &lt;code&gt;canAlsoFail :: Either Error Success█&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When dealing with lines that start differently but end the same (like the above example), it would be convenient to complete the rest of the line with a single keystroke, rather than mashing &lt;code&gt;CTRL-X CTRL-P&lt;/code&gt; repeatedly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm going to try to implement this, but I can see it getting hairy in a hurry. Does anyone know of:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a plugin that offers this functionality?&lt;/li&gt;&#xA;&lt;li&gt;a built-in feature I've overlooked?&lt;/li&gt;&#xA;&lt;li&gt;a robust approach to implementing this?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;does Vim expose any data about the location it's completing from?&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1855" LastEditorUserId="1855" LastEditDate="2018-01-28T15:06:23.547" LastActivityDate="2018-01-30T16:49:51.713" Title="Multiword completion (CTRL-X CTRL-P) to end of line" Tags="|autocompletion|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15021" PostTypeId="2" ParentId="15020" CreationDate="2018-01-28T16:04:11.817" Score="3" Body="&lt;p&gt;You could try and find a simpler keysequence. As an example, assuming you don't&#xA;need &lt;code&gt;C-z&lt;/code&gt; to suspend Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ino  &amp;lt;expr&amp;gt;&amp;lt;silent&amp;gt;  &amp;lt;c-z&amp;gt;  &amp;lt;sid&amp;gt;easy_c_x_c_p()&#xA;&#xA;fu! s:easy_c_x_c_p() abort&#xA;    let cot_save = &amp;amp;cot&#xA;    set cot-=noinsert&#xA;    call timer_start(0, {-&amp;gt; execute('let &amp;amp;cot = '.string(cot_save))})&#xA;    return &quot;\&amp;lt;c-x&amp;gt;\&amp;lt;c-p&amp;gt;&quot;&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could install a submode in which you only need to press &lt;code&gt;C-p&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:submode_keep_leaving_key = 1&#xA;&#xA;call submode#enter_with('my-c_x-c_p', 'i', '', '&amp;lt;c-x&amp;gt;&amp;lt;c-p&amp;gt;', '&amp;lt;c-x&amp;gt;&amp;lt;c-p&amp;gt;')&#xA;call submode#map(       'my-c_x-c_p', 'i', '',      '&amp;lt;c-p&amp;gt;', '&amp;lt;c-x&amp;gt;&amp;lt;c-p&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;submode#enter_with()&lt;/code&gt; and &lt;code&gt;submode#map()&lt;/code&gt; functions are provided by the &lt;a href=&quot;https://github.com/kana/vim-submode&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-submode&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could try a custom mapping which would:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;look for the complete word before the cursor&lt;/li&gt;&#xA;&lt;li&gt;look for the previous line containing this word&lt;/li&gt;&#xA;&lt;li&gt;look for the text on this line, after this word&lt;/li&gt;&#xA;&lt;li&gt;insert this text&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Something like this (it uses the keysequence &lt;code&gt;C-x C-z&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ino  &amp;lt;expr&amp;gt;  &amp;lt;c-x&amp;gt;&amp;lt;c-z&amp;gt;  &amp;lt;sid&amp;gt;complete_until_eol()&#xA;&#xA;fu! s:complete_until_eol() abort&#xA;    let pat   = '.*\zs\&amp;lt;\k*\s*\%'.col('.').'c'&#xA;    let word  = matchstr(getline('.'), pat)&#xA;    let lines = reverse(getline(1, line('.')-1))&#xA;&#xA;    let idx = match(lines, word)&#xA;    if idx == -1&#xA;        return ''&#xA;    endif&#xA;&#xA;    let text = matchstr(lines[idx], word.'\zs.*')&#xA;    return text&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would need to press &lt;code&gt;C-p&lt;/code&gt; or &lt;code&gt;C-x C-p&lt;/code&gt; to complete the first word, then &lt;code&gt;C-x C-z&lt;/code&gt; to complete until the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could write a custom completion function which would suggest all end of lines starting from the word before the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ino  &amp;lt;silent&amp;gt;  &amp;lt;c-x&amp;gt;&amp;lt;c-z&amp;gt;  &amp;lt;c-r&amp;gt;=&amp;lt;sid&amp;gt;complete_to_eol()&amp;lt;cr&amp;gt;&#xA;&#xA;fu! s:complete_to_eol() abort&#xA;    let word = matchstr(getline('.'), '\k\+\%(\s*\)\?\%'.col('.').'c')&#xA;&#xA;    let lines = getline(1,line('.')-1) + getline(line('.')+1, '$')&#xA;    call filter(lines, {i,v -&amp;gt; v =~# word})&#xA;    call map(lines, {i,v -&amp;gt; matchstr(v, word.'.*$')})&#xA;&#xA;    let from_where = col('.') - len(word)&#xA;    if !empty(lines)&#xA;        call complete(from_where, lines)&#xA;    endif&#xA;    return ''&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I haven't tried it, but you could have a look at the &lt;a href=&quot;https://github.com/fsharpasharp/vim-story&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-story&lt;/a&gt; plugin.&lt;/p&gt;&#xA;" OwnerUserId="15612" LastEditorUserId="15612" LastEditDate="2018-01-30T16:49:51.713" LastActivityDate="2018-01-30T16:49:51.713" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15022" PostTypeId="1" CreationDate="2018-01-28T21:58:24.543" Score="1" ViewCount="1282" Body="&lt;p&gt;I've been struggling with this topic for a little more than i'd like to admit but here it is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've set my vim (~/.vimrc) to indent using 4 spaces using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set expandtab&#xA;:set tabstop=4&#xA;:set shiftwidth=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whenever I want to detete one of these groups I have to remove every one of the spaces. I thought vim would recognize this and remove them all like they were a single tab. Could anyone shed some light?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thks in advance :3&lt;/p&gt;&#xA;" OwnerUserId="16115" LastActivityDate="2018-01-29T15:21:25.447" Title="Vim, erasing multiple spaces used as indentation" Tags="|indentation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15023" PostTypeId="2" ParentId="15015" CreationDate="2018-01-29T00:00:24.680" Score="2" Body="&lt;p&gt;I found the solution myself. Enter &lt;code&gt;:hi SpellBad&lt;/code&gt;, &lt;code&gt;:hi SpellCap&lt;/code&gt;, &lt;code&gt;:hi SpellRare&lt;/code&gt; and &lt;code&gt;:hi SpellLocal&lt;/code&gt; in normal mode. It will output the display settings of your spell checker. Note the output in a list. Remove all parameters with the value &lt;code&gt;undercurl&lt;/code&gt;. Add this to your &lt;code&gt;.vimrc&lt;/code&gt;, changed according to your own settings.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd ColorScheme * hi clear SpellBad&#xA;    \| hi SpellBad term=reverse ctermbg=12 guisp=Firebrick2&#xA;    \| hi SpellCap term=reverse ctermbg=9 guisp=Blue&#xA;    \| hi SpellRare term=reverse ctermbg=13 guisp=Magenta&#xA;    \| hi SpellLocal term=underline ctermbg=11 guisp=DarkCyan&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The important part is, that no parameter with the value &lt;code&gt;undercurl&lt;/code&gt; is present.&lt;/p&gt;&#xA;" OwnerUserId="16107" LastActivityDate="2018-01-29T00:00:24.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15024" PostTypeId="2" ParentId="15022" CreationDate="2018-01-29T01:29:46.777" Score="3" Body="&lt;p&gt;You may prefer either or both of the following options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set smarttab&#xA;set softtabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The primary difference between these two options in your case (where &lt;code&gt;expandtab tabstop=4 shiftwidth=4&lt;/code&gt;) is whether the &quot;backspace deletes 4 spaces&quot; behavior works only at the beginning of lines (as with &lt;code&gt;smarttab&lt;/code&gt; only) or everywhere, aligning to tab stops (as with &lt;code&gt;softtabstop=4&lt;/code&gt;).  For other values of &lt;code&gt;expandtab&lt;/code&gt;, &lt;code&gt;tabstop&lt;/code&gt;, &lt;code&gt;shiftwidth&lt;/code&gt; the behavior is much more complex.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-01-29T01:29:46.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15026" PostTypeId="1" CreationDate="2018-01-29T11:50:50.163" Score="0" ViewCount="1078" Body="&lt;p&gt;I'm using Neovim v0.2.2 on Windows and I'm finding that editing files using paths with the tilde key (~) doesn't work as I'm expecting, for example if I enter the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e ~\AppData\Local\nvim\init.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Neovim will edit the following file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;c:\AppData\Local\nvim\init.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this a bug or is this not meant to work on Windows? I'm not using any form of terminal emulation, I'm just running nvim-qt.exe directly.&lt;/p&gt;&#xA;" OwnerUserId="7678" LastActivityDate="2018-01-30T11:36:33.533" Title="Tilde (~) paths do not work in windows neovim" Tags="|neovim|neovim-qt|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15027" PostTypeId="2" ParentId="10049" CreationDate="2018-01-29T15:13:52.317" Score="0" Body="&lt;p&gt;Two things.  If you really want to mix tabs and spaces, you really need to count on all spaces that are a complete tab stop, to be replaced with a tab.  If you are having problems with using such a file for printing, or viewing on a web page or some other place where tab expansion there, is different than what you are using for editing, then filter your file through 'pr -te ' and that will remove all tabs and replace them with spaces.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use 'pr -te 8' on files with odd tab practices and then do &quot;:set ts=8 sw=8', '1G' '&amp;gt;G', '&amp;lt;G' and then ':set ts=4 sw=4' to use the tab expansions I use.  There are all kinds of complaints about tabs vs spaces which have been on going for decades.  In the end, the use of leading tabs produces a lot less hassle for formatting than 'spaces' does, and I can edit a lot faster in VI if I can use 'space' and 'backspace' to move past indentation levels than have to use 'l' and 'h' which require a hand position switch and typically a glance at the keyboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you are just typing a new program, IDEs and other places where auto indent is done for you, you can feel comfortable and just ignore leading spaces.  But in the end, it just creates problems when another person can't change indentation levels for themselves, to make the code more readable.&lt;/p&gt;&#xA;" OwnerUserId="16126" LastActivityDate="2018-01-29T15:13:52.317" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15028" PostTypeId="2" ParentId="15022" CreationDate="2018-01-29T15:21:25.447" Score="2" Body="&lt;p&gt;The other choice is to just use '&amp;lt;&amp;lt;' or '&amp;gt;&amp;gt;' to shift the line left or right.  That should give you exactly the behavior you want from anywhere on the line.  You can of course delimit a group of lines by moving to an opening or closing '[', '(' or '{', and doing '&amp;lt;%' or '&amp;gt;%' to shift a range of lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course other movement types work as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &amp;gt;L&#xA; &amp;gt;/foo^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and others.&lt;/p&gt;&#xA;" OwnerUserId="16126" LastActivityDate="2018-01-29T15:21:25.447" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15030" PostTypeId="1" AcceptedAnswerId="15031" CreationDate="2018-01-30T06:32:50.557" Score="0" ViewCount="186" Body="&lt;p&gt;I'm programming Bash scripts using Vim in Ubuntu 16.04 (on Windows Subsystem for Linux).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The filename ends in &lt;code&gt;.sh&lt;/code&gt; and the first line of the file is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I wrote this command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rm -rf /tmp/*&#xA;   ~~~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &quot;word&quot; &lt;code&gt;-rf&lt;/code&gt; is shown in red (I use underlying tildes to point it out). I guess it's because Vim detected that &lt;code&gt;-rm&lt;/code&gt; is a dangerous option when supplied to &lt;code&gt;rm&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later I wrote this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tmpDir=$(mktemp &quot;tmp-XXXXXX&quot;)&#xA;          ~~~~~~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and Vim confusingly marked &lt;code&gt;mktemp&lt;/code&gt; as red.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/q95e7.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is that? Can I stop Vim from marking this very word as red?&lt;/p&gt;&#xA;" OwnerUserId="16096" LastActivityDate="2018-01-30T07:29:47.037" Title="Vim highlights word &quot;mktemp&quot; in Bash script" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15031" PostTypeId="2" ParentId="15030" CreationDate="2018-01-30T07:29:47.037" Score="1" Body="&lt;p&gt;First, &lt;code&gt;-rf&lt;/code&gt; is shown in red because it is recognized as an option, and red is the default color for the &lt;code&gt;shOption&lt;/code&gt; syntax group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;mktemp&lt;/code&gt; is colored red because it is recognized as a &lt;code&gt;shCommandSub&lt;/code&gt;. Bash commands will typically be colored differently here. You should notice that most things written in &lt;code&gt;$(...)&lt;/code&gt; will be colored red, except strings, bash commands, and probably some more things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see the syntax group(s) of the word under the cursor with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo reverse(map(synstack(line('.'), col('.')), 'synIDattr(v:val, &quot;name&quot;)'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-01-30T07:29:47.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15032" PostTypeId="2" ParentId="10176" CreationDate="2018-01-30T07:38:14.147" Score="0" Body="&lt;p&gt;I may be off from your actual purpose and you may already know what I suggest here, but how about opening the file in a new &lt;em&gt;tab&lt;/em&gt; from within vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:tabnew some_file.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If some_file.txt exists it will open it in a new tab, if not it will create a new empty file. You navigate from tab to tab with &lt;code&gt;gt&lt;/code&gt; (move one tab on the right) and &lt;code&gt;gT&lt;/code&gt; (move the other way).&lt;/p&gt;&#xA;" OwnerUserId="12085" LastActivityDate="2018-01-30T07:38:14.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15033" PostTypeId="1" AcceptedAnswerId="15034" CreationDate="2018-01-30T09:13:29.340" Score="2" ViewCount="382" Body="&lt;p&gt;I'm editing a ~1000 line Python file containing long docstrings. Occasionally, when I'm in editing the middle of a file, the syntax highlighting will 'invert' so that everything outside the docstrings is highlighted as if it were a docstring, and the contents of the docstrings themselves are highlighted as Python code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's as if the highlighting algorithm only considers a small local region around the current editing area for its algorithm, and it always assumes the start of that region is code, even if that region happens to begin inside a docstring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other colleagues have the same issue when they edit this file too, and we don't have anything special or nonstandard in our vimrcs.&lt;/p&gt;&#xA;" OwnerUserId="16131" LastActivityDate="2018-01-30T09:33:46.757" Title="Inverted syntax highlighting of multiline strings in Python" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15034" PostTypeId="2" ParentId="15033" CreationDate="2018-01-30T09:33:46.757" Score="5" Body="&lt;p&gt;Because of the way Vim syntax highlighting works, it can sometimes lose track of its context, causing issues such as the one you describe. You can check if this is the issue by running the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax sync fromstart&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will cause Vim always to read all the way back to the start of the file when highlighting. This can be slow, so if this fixes the issue, you might like to investigate the other options: Vim offers several different methods to determine how far back to read when highlighting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are described at &lt;code&gt;:help :syn-sync&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to check what sync values Vim is currently using, you can use the bare command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax sync&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-30T09:33:46.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15035" PostTypeId="2" ParentId="15026" CreationDate="2018-01-30T09:56:37.453" Score="1" Body="&lt;p&gt;Running &lt;code&gt;:echo $HOME&lt;/code&gt; (suggested by muru) returned &lt;code&gt;c:\&lt;/code&gt;, which showed that the problem was a rogue &lt;code&gt;HOME&lt;/code&gt; environment variable. Deleting this variable fixed the problem.&lt;/p&gt;&#xA;" OwnerUserId="7678" LastEditorUserId="343" LastEditDate="2018-01-30T11:36:33.533" LastActivityDate="2018-01-30T11:36:33.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15036" PostTypeId="2" ParentId="10176" CreationDate="2018-01-30T09:59:18.210" Score="2" Body="&lt;p&gt;When you use Vim's &lt;code&gt;--remote&lt;/code&gt; options, it constructs a &lt;code&gt;:drop&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the specified file is not already open in an existing window, it will be opened in the current window, unless the file currently in that window cannot be &lt;code&gt;abandon&lt;/code&gt;ed. (i.e. if the current file is modified and you have both &lt;code&gt;hidden&lt;/code&gt; and &lt;code&gt;autowrite&lt;/code&gt; options switched off.) In that case, the window is split instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note however, that at some point in the past there was a bug with this behaviour, which was fixed in version 6.1.173:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When using remote control to edit a position in a file and this file is the current buffer and it's modified, the window is split and the &quot;:drop&quot; command fails.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-30T09:59:18.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15037" PostTypeId="1" AcceptedAnswerId="15038" CreationDate="2018-01-30T12:40:31.823" Score="11" ViewCount="8208" Body="&lt;p&gt;For example, substitute &lt;code&gt;:&lt;/code&gt; with register 0's content.&lt;br&gt;&#xA;What's the correct command for &lt;code&gt;:s/:/&quot;0/&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2022-09-05T16:23:29.617" Title="How to replace string with register content?" Tags="|replace|register|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15038" PostTypeId="2" ParentId="15037" CreationDate="2018-01-30T12:58:14.250" Score="16" Body="&lt;p&gt;&lt;em&gt;N.B. In all the below, I presume that your question is only about the method of accessing the register's contents from an ex command, and that the rest of your &lt;code&gt;:substitute&lt;/code&gt; command (which replaces only the first match on the current line) does what you require. If you actually want to replace globally, you will need to use a &lt;code&gt;%&lt;/code&gt; range and the &lt;code&gt;g&lt;/code&gt; flag: &lt;code&gt;:%s/find/replace/g&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Interactively in Command Line Mode&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If this is being done interactively, you can do so by inserting the contents of the register into the command using &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Type the first part of your command, &lt;code&gt;:s/:/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then type &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt; to insert the contents of the yank register &lt;code&gt;&quot;0&lt;/code&gt; into the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you may need to then edit the command line slightly before pressing &lt;kbd&gt;Return&lt;/kbd&gt; to run the substitution. e.g. if the register contained a string that included a forward slash &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;In Vimscript&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If this is in a script, then you can use the &lt;code&gt;@0&lt;/code&gt; notation or the &lt;code&gt;getreg()&lt;/code&gt; function to access register contents. You can also then perform escaping automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 's/:/' . escape(getreg('0'), '/')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Update: In a Macro&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you want to do this in a macro recorded from keystrokes, the first method works fine: &lt;kbd&gt;Ctrl-R&lt;/kbd&gt; is recorded just like other keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're instead creating a macro by assigning a string value to a register, you can use something like the below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @q = &quot;:s/:/\&amp;lt;C-R&amp;gt;0\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using the &lt;code&gt;:let&lt;/code&gt; command above for simplicity, but the &lt;code&gt;setreg()&lt;/code&gt; function is more robust.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Further Reading&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help c_CTRL-R&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help expr9&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getreg()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :execute&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help string&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-01-30T14:44:07.283" LastActivityDate="2018-01-30T14:44:07.283" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15039" PostTypeId="1" CreationDate="2018-01-30T13:17:41.323" Score="6" ViewCount="991" Body="&lt;p&gt;It used to work when I used python2, but now I can't use &lt;code&gt;^X^O&lt;/code&gt; to complete function names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do have vim with &lt;code&gt;-python&lt;/code&gt; and &lt;code&gt;+python3&lt;/code&gt; (on Ubuntu 16.04), but here is the error I get when trying Ctrl-X Ctrl-O:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error: Required vim compiled with +python&#xA;E117: Unknown function : pythoncomplete#Complete&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get a working python3-completion in Vim? Thanks a lot. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to use any completion plugin, since this is supposed to work with normal vim.&#xA;I have looked at &lt;a href=&quot;https://stackoverflow.com/q/2084875/4614641&quot;&gt;this question&lt;/a&gt;, but no answer helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Checking where omnifunc was defined with &lt;code&gt;verbose set omnifunc?&lt;/code&gt;, it says&#xA;&lt;code&gt;/usr/share/vim/vim74/ftplugin/python.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As suggested by @ChristianBrabandt, when I set omnifunc to &lt;code&gt;python3complete#Complete&lt;/code&gt;, it can complete a few stuff, like &lt;code&gt;sys.&lt;/code&gt;, but still doesn't work for other modules, e.g argparse. Why is that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a temporary fix is to set omnifunc in my &lt;code&gt;~/.vim/ftplugin/python.vim&lt;/code&gt;, unless anyone has a better suggestion?&lt;/p&gt;&#xA;" OwnerUserId="9863" LastEditorUserId="9863" LastEditDate="2018-01-30T13:38:34.750" LastActivityDate="2018-01-30T13:38:34.750" Title="vim compiled with python3 but python3 omni-completion does not work" Tags="|autocompletion|filetype-python|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15040" PostTypeId="2" ParentId="15037" CreationDate="2018-01-30T14:05:26.113" Score="3" Body="&lt;p&gt;Besides @Rich's solution of using a substitution, &lt;code&gt;:s&lt;/code&gt;, uou can use the &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;gn&lt;/code&gt;, and &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt; to do this as well.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cgn&amp;lt;c-r&amp;gt;0&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can simply spam repeat, &lt;code&gt;.&lt;/code&gt; to do the next substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if spamming the dot command is not desirable, then you can make a macro to do it for you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @q = '.@q'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can simply run the macro from the &lt;code&gt;&quot;q&lt;/code&gt; register via &lt;code&gt;@q&lt;/code&gt; which will repeat the &lt;code&gt;.&lt;/code&gt; command until it runs out of matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related &lt;a href=&quot;http://vimcasts.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimcasts&lt;/a&gt; episode: &lt;a href=&quot;http://vimcasts.org/episodes/operating-on-search-matches-using-gn/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Operating on search matches using gn&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-01-30T14:05:26.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15042" PostTypeId="1" CreationDate="2018-01-30T20:18:51.973" Score="2" ViewCount="1015" Body="&lt;p&gt;I am new to Vim plugins and am looking to use the &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-plug&lt;/code&gt;&lt;/a&gt; plugin manager. The &lt;a href=&quot;https://github.com/junegunn/vim-plug/wiki/tutorial#setting-up&quot; rel=&quot;nofollow noreferrer&quot;&gt;installation instruction&lt;/a&gt; advises me to download the &lt;code&gt;.vim&lt;/code&gt; file and add it to &lt;code&gt;~/.vim/autoload&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/40151127/2317532&quot;&gt;This answer&lt;/a&gt; suggests that &lt;code&gt;vim-plug&lt;/code&gt; is itself a plugin. However, &lt;a href=&quot;https://stackoverflow.com/a/1639644/2317532&quot;&gt;several&lt;/a&gt; &lt;a href=&quot;https://vi.stackexchange.com/a/614/16141&quot;&gt;answers&lt;/a&gt; have suggested placing plugins that comes as a single &lt;code&gt;.vim&lt;/code&gt; file in the &lt;code&gt;~/.vim/plugin&lt;/code&gt; directory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that some directories under &lt;code&gt;~/.vim&lt;/code&gt; has special meaning. The &lt;code&gt;~/.vim/autoload&lt;/code&gt; directory is to house autoload scripts that are invoked when the function is ran. These functions can be ran by plugins or just used generally. The &lt;code&gt;~/.vim/plugin&lt;/code&gt; directory are for plugin scripts, which are sourced by Vim when it starts up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So why should the &lt;code&gt;plug.vim&lt;/code&gt; script be added to the &lt;code&gt;autoload&lt;/code&gt; directory and not &lt;code&gt;plugin&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="16141" LastEditorUserId="16141" LastEditDate="2018-01-30T20:29:55.643" LastActivityDate="2018-01-30T21:00:01.703" Title="Why does `vim-plug` add the .vim file to .vim/autoload and not .vim/plugin?" Tags="|plugin-system|plugin-vim-plug|autoload|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15043" PostTypeId="2" ParentId="15042" CreationDate="2018-01-30T21:00:01.703" Score="5" Body="&lt;p&gt;Choosing between &lt;code&gt;plugin/&lt;/code&gt; and &lt;code&gt;autoload/&lt;/code&gt; is a matter of how a plugin designer intends the plugin to be used.  vim-plug is intended to be placed in &lt;code&gt;autoload/&lt;/code&gt; because it is initialized through functions named &lt;code&gt;plug#[...]&lt;/code&gt;.  vim-plug is not loaded and does nothing until you call one of these functions.  This is a better practice than using &lt;code&gt;plugin/&lt;/code&gt; because if the user installs the &lt;code&gt;plug.vim&lt;/code&gt; file but does not use it, there is almost no impact to startup time.  The small downside is that you actually need to place &lt;code&gt;call plug#begin()&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt;, and this was the choice made.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim-plug's &lt;code&gt;plug.vim&lt;/code&gt; cannot be placed in &lt;code&gt;plugin/&lt;/code&gt; because the function naming scheme &lt;code&gt;plug#[...]&lt;/code&gt; is valid only in &lt;code&gt;autoload/&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-01-30T21:00:01.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15044" PostTypeId="1" AcceptedAnswerId="15045" CreationDate="2018-01-31T05:11:39.587" Score="3" ViewCount="1015" Body="&lt;p&gt;Does anyone know if it's possible to change the window title for nvim to this pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{cwd}/{current-file} - vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;E.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_project_dir/README.md - vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/equalsraf/neovim-qt&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvim-qt&lt;/a&gt; with i3wm (I'm not sure if it matters for this).&lt;/p&gt;&#xA;" OwnerUserId="6542" LastActivityDate="2018-01-31T07:49:59.860" Title="How to set window title to cwd + current opened file" Tags="|vimrc|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15045" PostTypeId="2" ParentId="15044" CreationDate="2018-01-31T07:49:59.860" Score="4" Body="&lt;p&gt;You can set the 'titlestring' option to an expression that returns statusline expandos that will be evaluated by Vim and displayed in the title. E.g. use&#xA;something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set title titlestring=%(%{expand(\&quot;%:~:.:h\&quot;)}%)/%t\ -\ Vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read the help at &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;titlestring&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'statusline'&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;statusline&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'statusline'&lt;/a&gt;&#xA;for the meaning of those items.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-01-31T07:49:59.860" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15046" PostTypeId="1" AcceptedAnswerId="15047" CreationDate="2018-01-31T10:17:24.077" Score="2" ViewCount="3611" Body="&lt;p&gt;Does anyone know how I can get the directory name of the CWD without the preceding path?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to build a titlestring like this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{cwd_dirname_without_path}/{file_path_relative_to_cwd}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think &lt;code&gt;%f&lt;/code&gt; would suffice for the second part of the title, but the first part seems tricky. &lt;/p&gt;&#xA;" OwnerUserId="6542" LastActivityDate="2018-01-31T10:27:49.117" Title="Get directory name from CWD (dirname without preceding path)?" Tags="|vimrc|neovim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15047" PostTypeId="2" ParentId="15046" CreationDate="2018-01-31T10:27:49.117" Score="13" Body="&lt;p&gt;There are several possibilities:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Use an substitute: &lt;code&gt;:echo substitute(getcwd(), '^.*/', '', '')&lt;/code&gt; (which basically means, cut off anything from the beginning until the latest &lt;code&gt;/&lt;/code&gt;, note this needs to be adjusted on Windows because the &lt;code&gt;\&lt;/code&gt; is path separator there).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Using &lt;code&gt;fnamemodify()&lt;/code&gt;, something like this should do it: &lt;code&gt;:echo fnamemodify(getcwd(), ':t')&lt;/code&gt; (which basically means, return the tail path of the current working directory).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See also the help at &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getcwd%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help getcwd()&lt;/code&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#fnamemodify%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help fnamemodify()&lt;/code&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getcwd%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help getcwd()&lt;/code&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#substitute%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help substitute()&lt;/code&gt;&lt;/a&gt; and&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#filename-modifiers&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help filename-modifiers&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-01-31T10:27:49.117" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15048" PostTypeId="2" ParentId="13308" CreationDate="2018-01-31T11:19:38.987" Score="0" Body="&lt;p&gt;When using the &lt;code&gt;formatprg&lt;/code&gt; option, Vim passes the file contents to the external program on &lt;code&gt;stdin&lt;/code&gt;. (See &lt;code&gt;:help 'formatprg'&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are not telling prettier-eslint-cli to expect to receive input in this way, and so the command fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/prettier/prettier-eslint-cli&quot; rel=&quot;nofollow noreferrer&quot;&gt;README for prettier-eslint-cli&lt;/a&gt; explains how to use it from Vim:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim users can add the following to their .vimrc:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;autocmd FileType javascript set formatprg=prettier-eslint\ &lt;strong&gt;&lt;em&gt;--stdin&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Emphasis mine)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also want to specify the paths of the executable and rcfile, so you need to amend this to add these in, whilst continuing to pass the necessary &lt;code&gt;--stdin&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType javascript let &amp;amp;l:formatprg = g:prettier_eslint_path2.' --stdin --eslint-config-path '. g:eslintrc_full_path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-31T11:19:38.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15049" PostTypeId="1" AcceptedAnswerId="15052" CreationDate="2018-01-31T17:33:48.050" Score="7" ViewCount="802" Body="&lt;p&gt;I frequently have one root project open which I've :cd'd to.  I also have other tabs with :lcd's set.  This is great and works really nicely, but occasionally I end up looking at something in the main project as a result of opening a Buffer from the main project in one of my other windows...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;at this point I'd like to do something to swap out of :lcd mode and back into :cd mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading &lt;code&gt;:h cd&lt;/code&gt; I can't work it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It states:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When a :cd command is used, the current window will lose his local current&#xA;directory and will use the global current directory from now on.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However as I'm running on linux just running a blank &lt;code&gt;:cd&lt;/code&gt; actually wipes out my global directory and sets it to &lt;code&gt;~&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find a way of accessing the &lt;code&gt;:cd&lt;/code&gt; value that isn't modified by having an &lt;code&gt;:lcd&lt;/code&gt; set&lt;/p&gt;&#xA;" OwnerUserId="1518" LastEditorUserId="343" LastEditDate="2018-02-02T15:56:43.620" LastActivityDate="2018-02-10T03:06:03.377" Title="How do you go back to your to global current directory after inheriting an lcd" Tags="|working-directory|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15050" PostTypeId="2" ParentId="15049" CreationDate="2018-01-31T19:40:22.247" Score="3" Body="&lt;p&gt;You can access the working directory of another window with the function &lt;code&gt;getcwd()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So although this isn't the most convenient or robust solution, if your root project (with the global working directory) is in the first, leftmost tab page, you could use the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute 'cd' getcwd(1, 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will remove the local current directory and set the global current directory to be the current directory of the topmost window in the leftmost tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the root project is &lt;em&gt;always&lt;/em&gt; in the leftmost tab page, then you could set up a mapping or a command to make this easier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! Gcd execute 'cd' getcwd(1, 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then invoke the command with &lt;code&gt;:Gcd&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-01-31T19:40:22.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15051" PostTypeId="1" AcceptedAnswerId="15053" CreationDate="2018-01-31T21:16:40.563" Score="5" ViewCount="1070" Body="&lt;p&gt;Based upon documentation there is explicitly a way to have multiple spell file for &quot;spell&quot; but I cannot, for the life of me, figure out how to use more than one spell file at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under my current configuration I have two spell files, but I am unsure of how I got them. The first is, of course, the master spelling file for English, and the second is my custom words. I assume the custom word file was created upon my first instance of designating a word correct (pressing &quot;zg&quot;), and that seems to be indicated in the documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would ideally like is to have four total spell files, configured as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the master &quot;English&quot; file with all of the standard English words.&lt;/li&gt;&#xA;&lt;li&gt;a second &quot;custom&quot; file which are for all the words that I use regularly, and are common across all file types.&lt;/li&gt;&#xA;&lt;li&gt;a file type specific spell file for words that I only use in certain files (e.g. tex, md etc.)&lt;/li&gt;&#xA;&lt;li&gt;a file for each individual document, for words that I only want registered as correct in that document.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have the first two as it stands, and that seems to be the default. Based upon documentation it seems like the 4th should be possible as well, as the documentation seems to indicate that, at least for some versions of vim, the spell file would be contained in the same directory as the file in the buffer if not explicitly located elsewhere in .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this seems overly complicated, the logic is as follows. The need for files 1 and 2 are to keep from corrupting the English language by accidentally changing a standard spelling (which is probably why it is the default). File type 3 is so that I can put in custom commands that I will normally only use for certain file types, but I do not want those accidentally marked as good in other file types, when they would not be appropriate there. Finally, in each file I have words (usually names) which are correct within that file, and only that file, but which might be wrong elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any guidance is welcome.&lt;/p&gt;&#xA;" OwnerUserId="16156" LastActivityDate="2018-02-01T06:57:28.497" Title="How can I use multiple spell files at the same time?" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15052" PostTypeId="2" ParentId="15049" CreationDate="2018-01-31T22:16:28.227" Score="6" Body="&lt;p&gt;As of vim 8.0.1489, one may use &lt;code&gt;getcwd(-1)&lt;/code&gt; to retrieve the global directory. &#xA; Thus, the following will work to restore a window to the global directory and cause it to forget its local directory (as explained in the documentation):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if haslocaldir()&#xA;    execute 'cd' getcwd(-1)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This feature was available in neovim before it made it to vim.  Prior to vim 8.0.1489, there was no simple way to determine the global directory (though there is &lt;code&gt;haslocaldir()&lt;/code&gt; to tell if a window has been issued an &lt;code&gt;:lcd&lt;/code&gt;).  Two possible ways are &lt;code&gt;mksession&lt;/code&gt; and &lt;code&gt;set cpo-=s&lt;/code&gt;+&lt;code&gt;new&lt;/code&gt;.  One practical option would be to wrap the &lt;code&gt;:cd&lt;/code&gt; command.  For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au VimEnter * let g:my_project_dir = getcwd()&#xA;command! -nargs=? -complete=dir Cd execute 'cd' &amp;lt;q-args&amp;gt; | let g:my_project_dir=getcwd()&#xA;cnoreabbrev &amp;lt;expr&amp;gt; cd getcmdtype()==':' &amp;amp;&amp;amp; getcmdline()=='cd' ? 'Cd' : 'cd'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you want to restore a window to the global directory you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! RestoreCwd execute 'cd' g:my_project_dir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-02-10T03:06:03.377" LastActivityDate="2018-02-10T03:06:03.377" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="15053" PostTypeId="2" ParentId="15051" CreationDate="2018-01-31T23:04:30.537" Score="14" Body="&lt;p&gt;Vim finds the file you're referring to as the &quot;master&quot; file by searching for files with a particular naming scheme in the &lt;code&gt;spell&lt;/code&gt; subdirectory within the paths specified by your &lt;code&gt;runtimepath&lt;/code&gt;. (See &lt;code&gt;:help spell-load&lt;/code&gt;) This is already working in your setup, though, so you don't need to worry about it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then have as many additional files as you like by specifying the &lt;code&gt;'spellfile'&lt;/code&gt; option as a comma-separated list: in your case, you would have three values: the first for your global custom list, the second for a filetype based list, and the third for per-file spellings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try adding something like the following to your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Global spellfile&#xA;set spellfile=~/.vim/custom.utf-8.add&#xA;&#xA;augroup spellfiles&#xA;  autocmd!&#xA;  &quot; Per file spellfile&#xA;  autocmd BufNewFile,BufRead * let &amp;amp;l:spellfile .= ',' . expand('%:p:h') . '/.' .&#xA;  \ expand('%:t') . '.utf-8.add,'&#xA;&#xA;  &quot; Per file type spellfile (FileType autocmd seems to fire before BufNewFile)&#xA;  autocmd BufNewFile,BufRead *.markdown setlocal spellfile+=~/.vim/markdown.utf-8.add&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets up the three &lt;code&gt;'spellfile'&lt;/code&gt; files in the order:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Global &quot;custom&quot; spell file&lt;/li&gt;&#xA;&lt;li&gt;Per file spell file&lt;/li&gt;&#xA;&lt;li&gt;Per file type spell file&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then you just need to specify which file you want to add corrections to, by passing a &lt;code&gt;count&lt;/code&gt; to the various spell commands, e.g. to add a word to the &quot;markdown&quot; file type spellfile, you'd use the command: &lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The slightly odd ordering is because the file &lt;em&gt;type&lt;/em&gt; spellfile may not always exist, and so must go last in order that the per-file spellfile always be in the same position.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-01T06:57:28.497" LastActivityDate="2018-02-01T06:57:28.497" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15054" PostTypeId="1" CreationDate="2018-02-01T04:25:48.780" Score="0" ViewCount="471" Body="&lt;p&gt;Okay, so I have a syntax file &lt;code&gt;asciidoc.vim&lt;/code&gt; in &lt;code&gt;~/.vim/syntax&lt;/code&gt; and this file is actually loaded, as I checked with &lt;code&gt;scriptnames&lt;/code&gt;.&#xA;But for some reason, it only works, if the builtin syntax files haven't loaded (and applied). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way only to make the syntax files load that I specify?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2018-02-01T14:28:31.320" Title="How to only load a certain syntax file" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15055" PostTypeId="2" ParentId="15054" CreationDate="2018-02-01T07:31:47.117" Score="5" Body="&lt;p&gt;If you look at the builtin syntax file &lt;code&gt;$VIMRUNTIME/syntax/asciidoc.vim&lt;/code&gt;, you'll see near the top, this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;b:current_syntax&quot;)&#xA;  finish&#xA;endif&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and near the bottom, this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:current_syntax = &quot;asciidoc&quot;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, if you put that last line in your own &lt;code&gt;asciidoc.vim&lt;/code&gt;, the builtin &lt;code&gt;asciidoc.vim&lt;/code&gt; will see that value and &lt;code&gt;finish&lt;/code&gt; early.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help mysyntaxfile-replace&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="2055" LastEditDate="2018-02-01T14:28:31.320" LastActivityDate="2018-02-01T14:28:31.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15056" PostTypeId="1" AcceptedAnswerId="15057" CreationDate="2018-02-01T13:12:57.653" Score="11" ViewCount="9730" Body="&lt;p&gt;I've read that pathogen works on nvim, i tried to follow the vim installation process:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ~/.vim/autoload ~/.vim/bundle &amp;amp;&amp;amp; \&#xA;curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Changing the .vim/bundle part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ~/.vim/autoload ~/.local/share/nvim/bundle &amp;amp;&amp;amp; \&#xA;curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;my init.vim is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;set guicursor=&#xA;set clipboard+=unnamedplus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when i launch nvim i get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E117: unknown function: pathogen#infect()&#xA;E15: invalid expression: pathogen#infect() &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16167" LastEditorUserId="205" LastEditDate="2018-02-01T13:21:47.587" LastActivityDate="2019-04-16T13:49:09.903" Title="How to install pathogen on Neovim?" Tags="|neovim|plugin-pathogen|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15057" PostTypeId="2" ParentId="15056" CreationDate="2018-02-01T14:11:19.607" Score="14" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;mkdir -p ~/.vim/autoload ~/.local/share/nvim/bundle&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is wrong for Neovim.  &lt;code&gt;~/.config/nvim&lt;/code&gt; is the replacement for &lt;code&gt;~/.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;mkdir -p ~/.config/nvim/autoload ~/.config/nvim/bundle&lt;/code&gt; is what you should use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;If&lt;/em&gt; you want to your config to work with both Vim and Neovim, then I would recommend symlinks.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ~/.config/&#xA;ln -s ~/.vim ~/.config/nvim &#xA;ln -s ~/.vimrc ~/.config/nvim/init.vim &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/.local/share/nvim/init&lt;/code&gt; is also part of &lt;code&gt;'runtimepath'&lt;/code&gt;, so if you wanted to keep plugins separate from your personal config, that would be an alternate place to put the &lt;code&gt;bundle&lt;/code&gt; directory.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="-1" LastEditDate="2019-04-16T13:49:09.903" LastActivityDate="2019-04-16T13:49:09.903" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="15058" PostTypeId="2" ParentId="15049" CreationDate="2018-02-01T17:48:10.333" Score="2" Body="&lt;p&gt;One way to find out the current global directory, in case there exists a window where we aren't using a current local directory could be to search for this window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For each &lt;code&gt;tab&lt;/code&gt;, we could filter the windows with no current local dir with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let wins = filter(range(1, tabpagewinnr(tab, '$')), '! haslocaldir(v:val, tab)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the result isn't empty, then we have the current global directory with &lt;code&gt;getwcd(wins[0], tab)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A complete solution would then be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let wins_per_tabs = map(range(1, tabpagenr('$')), &quot;range(1, tabpagewinnr(v:val, '$'))&quot;)&#xA;&#xA;let wins_tabs_with_glob_dir = [] &quot; list filled only when it matches&#xA;call map(deepcopy(wins_per_tabs), {tab, wins -&amp;gt; map(wins, 'haslocaldir(v:val,tab)? [0,0] : add(g:wins_tabs_with_glob_dir, [v:val, tab+1])')})&#xA;&#xA;if !empty(wins_tabs_with_glob_dir)&#xA;    let glob_cwd = call('getcwd', wins_tabs_with_glob_dir[0])&#xA;    &quot; and do whatever you want with it&#xA;else&#xA;    &quot; we have no idea what it was...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(As you see, I don't like &lt;code&gt;:for&lt;/code&gt; loops, they are usually slower, and they are a nightmare to debug)&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-02-01T17:55:38.413" LastActivityDate="2018-02-01T17:55:38.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15059" PostTypeId="1" CreationDate="2018-02-01T21:20:11.060" Score="1" ViewCount="59" Body="&lt;p&gt;Is there a way to invoke :redrawstatus from a window that is different than the window whose statusline is to be updated ?  Not a global :redrawstatus to all windows, but to one specific window.&lt;/p&gt;&#xA;" OwnerUserId="16177" LastActivityDate="2018-02-01T21:20:11.060" Title="How to trigger :redrawstatus to a different window?" Tags="|statusline|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15060" PostTypeId="1" CreationDate="2018-02-01T23:11:38.523" Score="1" ViewCount="455" Body="&lt;p&gt;I have a bind that invokes vim on a file with a search term: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is shell scripting.&#xA;&lt;code&gt;vim $FILE &quot;+/$SEARCHTERM&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem that happens is that &lt;strong&gt;only if&lt;/strong&gt; &lt;code&gt;$SEARCHTERM&lt;/code&gt; appears just once in a file, it seems to be emitting &lt;code&gt;search hit BOTTOM, continuing at TOP&lt;/code&gt; and this is presumably causing the opening of the buffer to be interactively delayed with &lt;code&gt;Press ENTER or type command to continue&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want this not to happen to make the file open to the search term for me immediately.&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-04-02T23:59:31.923" Title="How to run vim from command line and prevent press ENTER or type command to continue" Tags="|search|silent-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15061" PostTypeId="2" ParentId="15060" CreationDate="2018-02-01T23:11:38.523" Score="1" Body="&lt;p&gt;Providing the argument &lt;code&gt;&quot;+silent /${SEARCHTERM}&quot;&lt;/code&gt; to vim was my solution. This should be equivalent to running the &lt;code&gt;:/&lt;/code&gt; search using &lt;code&gt;:silent /&lt;/code&gt; which does the trick. No need to change how vim normally behaves with searches!&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-02-01T23:11:38.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15062" PostTypeId="1" CreationDate="2018-02-02T06:28:50.053" Score="0" ViewCount="297" Body="&lt;p&gt;In the function-list, it gives execute() as running an ex command, but it does not seem to be returning a string as I expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I run this on a file that has 'abc' in it somewhere:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo execute(&quot;%s/abc//gen&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it answers: &quot;1 match on 1 line&quot;. Then if make the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo str2nr(&quot;1 match on 1 line&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it returns the number 1 on the status line. However, finally, if I run this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo str2nr(execute(&quot;%s/abc//gen&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it returns 0 on the status line, not 1 as expected. What is going wrong here?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-02-02T07:21:33.670" Title="What does execute() return?" Tags="|ex-mode|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15063" PostTypeId="2" ParentId="15062" CreationDate="2018-02-02T07:21:33.670" Score="3" Body="&lt;p&gt;The reason is that the result of &lt;code&gt;execute(&quot;%s/abc//gen&quot;)&lt;/code&gt; is not the same as the string &lt;code&gt;&quot;1 match on 1 line&quot;&lt;/code&gt;, but &lt;code&gt;&quot;\n1 match on 1 line&quot;&lt;/code&gt;. When you echo this, it outputs as expected, but with &lt;code&gt;str2nr&lt;/code&gt;, the initial newline  leads to your unexpected 0 return value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As is described in &lt;code&gt;:help execute()&lt;/code&gt;, you can use split to get a list of lines of the output. So, this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo str2nr(join(split(execute('%s/abc//gen'), &quot;\n&quot;)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-02-02T07:21:33.670" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15064" PostTypeId="1" CreationDate="2018-02-02T09:25:39.780" Score="0" ViewCount="215" Body="&lt;p&gt;I was looking for a way to &lt;em&gt;highlight&lt;/em&gt; lines above the cursor line to mark them as &lt;em&gt;done&lt;/em&gt;, whatever that means in the context of what I'm doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came up with this &lt;code&gt;match Comment /\_.*\%#.*/&lt;/code&gt; or, in words, &lt;em&gt;highlight everything including newlines up until the cursor character, and then the rest of the line too as comment text&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This does the job and allows me to easily progress through a document/source file by moving the cursor down, but the problem is: It's slow. REALLY slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some better way to achieve the same result? I don't mind it involving a lot of magic, since I will most likely hide it away behind a function in my vimrc anyway, but I am restricted to only vimscript.&lt;/p&gt;&#xA;" OwnerUserId="14920" LastEditorUserId="14920" LastEditDate="2018-02-02T09:36:45.913" LastActivityDate="2018-02-02T09:41:24.087" Title="Highlight lines above cursor" Tags="|vimscript|regular-expression|highlight|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15065" PostTypeId="2" ParentId="15064" CreationDate="2018-02-02T09:41:24.087" Score="2" Body="&lt;p&gt;For me, simply using syntax matching by prepending &lt;code&gt;syntax&lt;/code&gt; seems to make it acceptably fast:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Comment /\_.*\%#.*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If that's not fast enough for you, perhaps you can alter your &lt;code&gt;sync&lt;/code&gt; setting. See &lt;code&gt;:help :syn-sync&lt;/code&gt;. I presumed this setting was why using syntax matching is faster than &lt;code&gt;:match&lt;/code&gt; for this expression, but even using &lt;code&gt;:syntax sync fromstart&lt;/code&gt; it still works fast for me (in the files I've tested it in).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's still no good, you could try setting up a syntax region instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region Error start=/\%^/ end=/\%#.*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This matches the beginning of the file and the cursor position, but nothing in between, so I imagine it would be super fast.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-02T09:41:24.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15066" PostTypeId="1" AcceptedAnswerId="15067" CreationDate="2018-02-02T10:45:11.360" Score="2" ViewCount="672" Body="&lt;p&gt;I like to add marks for move across files but most of the time, I don't care about the line. I want to go on the last position of the cursor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I have this marks :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:marks&#xA;mark line  col file/text&#xA; '      1    0 class ContentsController &amp;lt; ApplicationController&#xA; C    350    4 @content.attributes = @content.default_attributes&#xA; M    387    2 app/models/content.rb&#xA; V      3    0 app/views/contents/index.html.erb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;g'M&lt;/code&gt; will move to &lt;code&gt;app/models/content.rb&lt;/code&gt; on the last cursor position.&lt;/p&gt;&#xA;" OwnerUserId="15669" LastActivityDate="2018-02-02T21:21:36.630" Title="Go to the last cursor position using marks" Tags="|mark|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15067" PostTypeId="2" ParentId="15066" CreationDate="2018-02-02T14:28:39.187" Score="4" Body="&lt;p&gt;The mark &lt;code&gt;&quot;&lt;/code&gt; indicates the position of the cursor when you last exited a buffer. Using that...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Continue to use your cross-file marks but immediately follow with &lt;code&gt;'&quot;&lt;/code&gt; (or &lt;code&gt;`&quot;&lt;/code&gt; to restore the column as well as the line):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'X'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make it a bit more convenient you can create a mapping that does the same thing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;'X 'X'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you put this in a function so you can do the double-jump with any mark:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! Jump2(mark)&#xA;    exec &quot;norm! '&quot; . a:mark . &quot;'\&quot;&quot;&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To run it &lt;code&gt;:call Jump2('X')&lt;/code&gt;. A user command and/or mapping can shorten things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taking things further, see &lt;code&gt;:help last-position-jump&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    This autocommand jumps to the last known position in a file&#xA;    just after opening it, if the '&quot; mark is set: &amp;gt;&#xA;:au BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) | exe &quot;normal! g`\&quot;&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you instead used &lt;code&gt;BufEnter&lt;/code&gt;/&lt;code&gt;BufWinEnter&lt;/code&gt; then each time you switch to a different buffer you'll start at the last known position. That may be more than you had in mind but you can easily add logic to the &lt;code&gt;autocommand&lt;/code&gt; so it only occurs under certain conditions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's just a few things that come to mind. Really, &quot;the possibilities are limited only by your imagination!&quot; ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: Mark &lt;code&gt;&quot;&lt;/code&gt; might not always be set...but from a practical standpoint it usually will be.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-02-02T21:21:36.630" LastActivityDate="2018-02-02T21:21:36.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15068" PostTypeId="1" AcceptedAnswerId="15069" CreationDate="2018-02-02T16:36:49.470" Score="5" ViewCount="3674" Body="&lt;p&gt;This is probably just a bandaid for a greater problem, but I had the following code for MacVim (GUI mode) in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd GUIEnter * winpos 100 50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is it's not working properly on startup, yet if I run &lt;code&gt;winpos&lt;/code&gt; even 1 second after it starts it works perfect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;GUIEnter&lt;/code&gt; command seems to be correct from all I read, and it's still doing GUI stuff after this obviously, because it keeps moving the window just a bit from where I want it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible as a hacky workaround to let MacVim load completely, wait 200ms and then execute the &lt;code&gt;winpos&lt;/code&gt; command?&lt;/p&gt;&#xA;" OwnerUserId="16016" LastActivityDate="2018-02-02T17:34:51.547" Title="Delay before running vim command?" Tags="|autocmd|macvim|startup|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15069" PostTypeId="2" ParentId="15068" CreationDate="2018-02-02T17:34:51.547" Score="11" Body="&lt;p&gt;In recent vim versions, you can use &lt;code&gt;timer_start&lt;/code&gt; to delay an operation.  For example, to execute &lt;code&gt;winpos&lt;/code&gt; 200 milliseconds after vim starts,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * call timer_start(200, { tid -&amp;gt; execute('winpos 100 50')})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-02-02T17:34:51.547" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15070" PostTypeId="1" CreationDate="2018-02-02T20:03:08.143" Score="0" ViewCount="663" Body="&lt;p&gt;I have a very large number of files under a specific directory.&#xA;If I start &lt;code&gt;vim&lt;/code&gt; from the wrong place, &lt;code&gt;command-t&lt;/code&gt; tries to index the whole thing, which results in vim hanging for a long time before &lt;code&gt;command-t&lt;/code&gt; gives up saying that there are too many files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want the content of that directory to be indexed by &lt;code&gt;command-t&lt;/code&gt;, so following &lt;code&gt;:help command-t-wildignore&lt;/code&gt; I tried setting &lt;code&gt;wildignore&lt;/code&gt; with &lt;code&gt;:set wildignore=/absolute/path/to/nasty/folder/*&lt;/code&gt;.&#xA;Issuing &lt;code&gt;set wildignore&lt;/code&gt; before trying &lt;code&gt;command-t&lt;/code&gt; confirms that &lt;code&gt;wildignore&lt;/code&gt; is correctly set up.&#xA;However, &lt;code&gt;command-t&lt;/code&gt; keeps on &lt;em&gt;not&lt;/em&gt; ignoring said folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried with &lt;code&gt;:set wildignore=relative/path/to/folder/*&lt;/code&gt; but to no avail (and I would prefer to ignore a specific folder with its absolute path anyway).&#xA;I didn't find the explanation of how to use &lt;code&gt;wildignore&lt;/code&gt; particularly clear though, so I may be using the wrong syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What syntax should be used for this to work properly?&lt;/p&gt;&#xA;" OwnerUserId="602" LastEditorUserId="11357" LastEditDate="2022-04-04T09:37:06.773" LastActivityDate="2022-04-04T09:37:06.773" Title="How to tell command-t to ignore a specific directory" Tags="|command|working-directory|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15072" PostTypeId="1" AcceptedAnswerId="15093" CreationDate="2018-02-02T23:24:32.880" Score="3" ViewCount="3493" Body="&lt;p&gt;I've been trying to get Shift+Tab or &lt;code&gt;&amp;lt;S-Tab&amp;gt;&lt;/code&gt; to work in VIM and  I can't figure it out.&lt;/p&gt;&#xA;&lt;p&gt;I read &lt;a href=&quot;http://vim.wikia.com/wiki/Make_Shift-Tab_work&quot; rel=&quot;nofollow noreferrer&quot;&gt;this document&lt;/a&gt;, but the &lt;code&gt;remap&lt;/code&gt; solution &lt;em&gt;only works for normal mode&lt;/em&gt; (because if I press Shift+Tab, VIM reads the literal escape &lt;code&gt;^]&lt;/code&gt; in the Shift+Tab escape sequence &lt;code&gt;^]]Z&lt;/code&gt;, which causes VIM to leave insert mode!), and the &lt;code&gt;set t_kb=&amp;quot;&amp;lt;stuff&amp;gt;&amp;quot;&lt;/code&gt; also &lt;em&gt;only works for normal mode&lt;/em&gt; on my vim. You can test the latter option by entering:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;exe 'set t_kB=' . nr2char(27) . '[Z'&#xA;nmap &amp;lt;S-Tab&amp;gt; ihello world!&#xA;imap &amp;lt;S-Tab&amp;gt; hello world!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;...then try pressing Shift+Tab. The first remap does work, but the second remap is ignored. I also tried the &lt;code&gt;xmodmap&lt;/code&gt; from the terminal, then entering VIM, and still I have the same issue.&lt;/p&gt;&#xA;&lt;p&gt;Can anything be done here?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2022-05-25T20:32:08.927" LastActivityDate="2022-05-25T20:33:15.550" Title="Getting Shift-Tab to work in VIM Insert mode" Tags="|key-bindings|vimscript|tab-characters|" AnswerCount="2" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15073" PostTypeId="1" CreationDate="2018-02-03T01:27:05.777" Score="0" ViewCount="168" Body="&lt;p&gt;I have a function that counts the number of matches in a file using the substitute Ex command with the /n flag and returns the value. However, I cannot echo the answer because the status line is getting overwritten by the file name. In other words, I will do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo Myfun(&quot;pattern&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the result will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;scratch1&quot; [Modified][New file] 3 lines --100%--   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I use the message history (echom) it clearly shows that the correct result is being generated and returned, but the message is getting overwritten by the &quot;modified&quot; message. I don't understand this because the script does not modify anything. Why is the status line getting overwritten?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The effect seems to be caused by bufdo. A minimal example of Myfun is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Myfun( pattern )&#xA;    let command = '%s/'.a:pattern.'//gen'&#xA;    let count_pattern = 0&#xA;    bufdo let count_pattern += str2nr( strpart( execute( command ), 1 ) )&#xA;    return count_pattern&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the environment has only one open buffer then the echo command works correctly, but if there are more than one buffers open, then the status line is getting overwritten. In other words, what is happening is the following sequence of events:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;function runs (switching buffers in the process)&lt;/li&gt;&#xA;&lt;li&gt;function returns a number it calculated&lt;/li&gt;&#xA;&lt;li&gt;echo command prints that number to the status line&lt;/li&gt;&#xA;&lt;li&gt;Vim writes &quot;&quot;example&quot; [New file] --No lines in buffer--&quot; to status line&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, after the command is over Vim is updating the status line if the buffer was changed at any point when the command executed. I need to prevent this from happening to see the result.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="6952" LastEditDate="2018-02-03T11:29:58.547" LastActivityDate="2018-02-03T20:51:05.070" Title="My status line is getting erased, so I can't print function result" Tags="|vimscript|functions|statusline|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="15075" PostTypeId="2" ParentId="15073" CreationDate="2018-02-03T20:51:05.070" Score="2" Body="&lt;p&gt;Your problem comes from the fact that bufdo loads each buffer in the current window and then Vim will output in the command line (note: Note the statusline, that is a different area!) that it is editing the buffer and it has been modified. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose, you have 'hidden' set, otherwise, you wouldn't be able to switch buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: the result of your function is printed correctly, it is just that afterwards the message area will get overwritten by another message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest way would be to use &lt;code&gt;:sil :bufdo&lt;/code&gt; to hide those messages or you can set the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;shortmess&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;'shortmess'&lt;/a&gt; option to include the flag &quot;F&quot; (which suppresses this info entirely).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Whenever you use the &lt;code&gt;bufdo&lt;/code&gt; function, you should restore the current buffer afterwards again. It is a bad habit to find yourself in another buffer other executing a function. This might lead to unexpected results.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-02-03T20:51:05.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15076" PostTypeId="1" CreationDate="2018-02-05T04:52:04.623" Score="0" ViewCount="1531" Body="&lt;p&gt;If I have a function that takes a range, how can I echo the return value of the function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the following does not work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo 2,8call MyFunction()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-12-13T08:04:51.020" Title="How can I echo the result of function with a range?" Tags="|vimscript|functions|range|echo|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15078" PostTypeId="2" ParentId="15076" CreationDate="2018-02-05T08:18:47.977" Score="4" Body="&lt;p&gt;I looked into this, and I could not find a direct way of doing it. However, one possibility is to create an auxiliary function, that is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Range() range abort&#xA;  return RangeAux(a:firstline, a:lastline)&#xA;endfunction&#xA;&#xA;function! RangeAux(lnum1, lnum2) abort&#xA;  echo a:lnum1&#xA;  echo a:lnum2&#xA;endfunction&#xA;&#xA;1,3call Range()&#xA;call RangeAux(1,3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-02-05T08:18:47.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15079" PostTypeId="2" ParentId="15076" CreationDate="2018-02-05T11:02:26.473" Score="3" Body="&lt;p&gt;@Karl's answer is pretty good but you can also use &lt;code&gt;execute()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo execute(&quot;1,2call Range()&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can even use variables for the range: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l1=1&#xA;let l2=2&#xA;echo execute(l1 . &quot;,&quot; . l2 . &quot;call Range()&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-02-05T11:02:26.473" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15080" PostTypeId="1" CreationDate="2018-02-05T13:02:36.930" Score="2" ViewCount="483" Body="&lt;p&gt;How can I make &lt;code&gt;zC&lt;/code&gt; fold only the current fold and the ones underneath? now it closes all outer folds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, something like this will result in all brackets closing, while I would like to have only &lt;code&gt;GlossList&lt;/code&gt; and the ones underneath folded.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{                                                                               &#xA;  &quot;glossary&quot;: {                                                               &#xA;    &quot;title&quot;: &quot;example glossary&quot;,                                            &#xA;    &quot;GlossDiv&quot;: {                                                               &#xA;    &quot;title&quot;: &quot;S&quot;,                                                       &#xA;    &quot;GlossList&quot;: { &amp;lt;-cursor here                                                            &#xA;       &quot;GlossEntry&quot;: {                                                 &#xA;         &quot;ID&quot;: &quot;SGML&quot;,                                               &#xA;         &quot;SortAs&quot;: &quot;SGML&quot;,                                                     &#xA;         &quot;GlossTerm&quot;: &quot;Standard Generalized Markup Language&quot;,                  &#xA;         &quot;Acronym&quot;: &quot;SGML&quot;,                                                    &#xA;         &quot;Abbrev&quot;: &quot;ISO 8879:1986&quot;,                                            &#xA;         &quot;GlossDef&quot;: {&#xA;           &quot;para&quot;: &quot;A meta-markup language, used to create markup languages such as DocBook.&quot;,&#xA;           &quot;GlossSeeAlso&quot;: [&quot;GML&quot;, &quot;XML&quot;]&#xA;         },&#xA;         &quot;GlossSee&quot;: &quot;markup&quot;                                                  &#xA;              }                                                               &#xA;          }                                                                   &#xA;      }                                                                       &#xA;  }                                                                           &#xA;}   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Atom's Vim integration works like that, but I can't get used to the editor itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;How vim behaves&#xA;&lt;a href=&quot;https://i.stack.imgur.com/rTyDX.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rTyDX.gif&quot; alt=&quot;zC Vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How atom behaves (and I would like to get vim to behave)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Q8A0G.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Q8A0G.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1545" LastEditorUserId="1545" LastEditDate="2018-02-06T09:22:03.367" LastActivityDate="2018-02-06T10:15:44.303" Title="Make zC close only current and nested folds" Tags="|folding|filetype-json|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15081" PostTypeId="1" CreationDate="2018-02-05T13:11:46.760" Score="10" ViewCount="3590" Body="&lt;p&gt;I get this on my vim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/I1jZy.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/I1jZy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but the arabic translation is showing all messed up (in reverse orderlike dessem pu)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it should instead show like this (this is rendered in source tree:)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/HvfOQ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HvfOQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to I make this work? (note: I'm using the terminal version of mac:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 14 2017 18:28:18)&#xA;MacOS X (unix) version&#xA;Included patches: 1-1100&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     -tcl&#xA;-balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;-browse          -footer          +multi_byte      +terminal&#xA;++builtin_terms  +fork()          +multi_lang      +terminfo&#xA;+byte_offset     -gettext         -mzscheme        +termresponse&#xA;+channel         -hangul_input    +netbeans_intg   +textobjects&#xA;+cindent         +iconv           +num64           +timers&#xA;-clientserver    +insert_expand   +packages        +title&#xA;+clipboard       +job             +path_extra      -toolbar&#xA;+cmdline_compl   +jumplist        +perl            +user_commands&#xA;+cmdline_hist    +keymap          +persistent_undo +vertsplit&#xA;+cmdline_info    +lambda          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python          +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            +ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      +startuptime     -xpm&#xA;+eval            +mouse_dec       +statusline      -xsmp&#xA;+ex_extra        -mouse_gpm       -sun_workshop    -xterm_clipboard&#xA;+extra_search    -mouse_jsbterm   +syntax          -xterm_save&#xA;+farsi           +mouse_netterm   +tag_binary&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;arabic support is even worse on mlterm&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ROoo5.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ROoo5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="14510" LastEditDate="2018-02-06T08:06:56.467" LastActivityDate="2018-05-07T10:41:17.510" Title="how to make vim properly render RTL (Right to Left) languages" Tags="|vimrc|macvim|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15082" PostTypeId="1" CreationDate="2018-02-05T13:39:21.690" Score="1" ViewCount="521" Body="&lt;p&gt;I want to fold all special documentation comments, and only all special documentation comments.&#xA;To do that I created a new syntax, &lt;code&gt;doxygenComment&lt;/code&gt; and added highlighting (in red, just to test it).&#xA;The comments are getting highlighted correctly, but my &lt;code&gt;GetCppFold&lt;/code&gt; doesn't seem to work, since no comments are getting folded:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetype_cpp&#xA;    autocmd!&#xA;&#xA;    &quot; Create custom doxygen comment style&#xA;    autocmd FileType cpp syn region doxygenComment start=&quot;/\*\!&quot; end=&quot;\*/&quot;&#xA;    autocmd FileType cpp hi link doxygenComment cError&#xA;&#xA;    &quot; Fold comments.&#xA;    autocmd FileType cpp setlocal foldmethod=expr&#xA;    autocmd FileType cpp setlocal foldexpr=GetCppFold(v:lnum)&#xA;&#xA;    &quot; Close all folds.&#xA;    autocmd BufRead *.cxx,*.hxx,*.cpp,*.hpp normal zM&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following function simply checks whether the line is considered a &lt;code&gt;doxygenComment&lt;/code&gt; or not, and returns the appropriate fold level. Keep in mind, I don't want any additional indent/syntax folding. I only want the comments folded (technically, I would want to have the functions folded, too, but this seems to be quite hard, since the syntax can't decipher between function and namespace or classes).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetCppFold(lnum)&#xA;    let line = getline(a:lnum)&#xA;&#xA;    &quot; Check whether the line is empty or whitespace only.&#xA;    if line =~? '\v^\s*$'&#xA;        return '-1'&#xA;    endif&#xA;&#xA;    let a:data = join(map(synstack(a:lnum, 1), 'synIDattr(v:val, &quot;name&quot;)'))&#xA;    if a:data =~? &quot;.*omment.*&quot;&#xA;        echo &quot;match&quot;&#xA;        return '='&#xA;    endif&#xA;&#xA;    return '-1'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16217" LastEditorUserId="1841" LastEditDate="2018-02-05T13:42:47.920" LastActivityDate="2024-01-06T16:00:40.057" Title="Fold special comments" Tags="|folding|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15083" PostTypeId="1" CreationDate="2018-02-05T14:31:58.963" Score="1" ViewCount="143" Body="&lt;p&gt;I extracted the text from a pdf which I need to edit further in vim. It contains quite a few diacritical combinations, some of them apparently got converted to control characters by &lt;code&gt;pdftotext&lt;/code&gt;. It seems most of which I already found, but &amp;lt;8e&gt; remains. &lt;/p&gt;&#xA;" OwnerUserId="2774" LastActivityDate="2018-02-05T16:45:29.673" Title="How do I write &lt;8e&gt;?" Tags="|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15084" PostTypeId="2" ParentId="15083" CreationDate="2018-02-05T14:35:14.057" Score="0" Body="&lt;p&gt;It seems I found my answer already myself, noting it down here for future reference: &lt;code&gt;&amp;lt;8e&amp;gt;&lt;/code&gt;, highlighted in blue, is a unicode number, which can be entered in a standard Ubuntu setup via something like &lt;code&gt;&amp;lt;ctrl&amp;gt;&amp;lt;shift&amp;gt;u008e&amp;lt;enter&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2774" LastEditorUserId="51" LastEditDate="2018-02-05T15:27:36.090" LastActivityDate="2018-02-05T15:27:36.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15085" PostTypeId="2" ParentId="15083" CreationDate="2018-02-05T16:45:29.673" Score="5" Body="&lt;p&gt;Vim provides a mechanism for entering arbitrary characters, which should work across all operating systems. See &lt;code&gt;:help i_CTRL-V_digit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To enter &lt;code&gt;&amp;lt;8e&amp;gt;&lt;/code&gt;, you can type the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;8&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if you have &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;mapped to perform another operation (such as, on Windows, paste, via &lt;code&gt;mswin.vim&lt;/code&gt;) then in GUI Vim you can use &lt;kbd&gt;Ctrl-Q&lt;/kbd&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-05T16:45:29.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15086" PostTypeId="2" ParentId="15082" CreationDate="2018-02-05T16:52:22.547" Score="0" Body="&lt;p&gt;You're only returning two different values from your function:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;-1&lt;/code&gt;: the fold level is undefined, use the fold level of a line before or after this line, whichever is the lowest.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;=&lt;/code&gt;: use fold level from the previous line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want the function to work, you're going to need to return an actual fold level at some point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Also, you're returning &lt;code&gt;-1&lt;/code&gt; as a string&amp;mdash;I think it should be a number.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-05T16:52:22.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15087" PostTypeId="2" ParentId="15081" CreationDate="2018-02-05T17:06:29.277" Score="8" Body="&lt;p&gt;Vim only supports displaying files containing mixed RTL and LTF text in a terminal which also supports this (such as &lt;a href=&quot;http://mlterm.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;mlterm&lt;/a&gt;). (You're not using GUI Vim, but I'll note for future readers that it is also not supported there.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your terminal does support this, you will also need to ensure that the &lt;code&gt;'termbidi'&lt;/code&gt; option is set. This is set by default when Vim is running under mlterm, and unset otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'termbidi'&lt;/code&gt; and &lt;code&gt;:help arabic.txt&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-05T17:06:29.277" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15088" PostTypeId="1" CreationDate="2018-02-05T21:27:00.483" Score="0" ViewCount="5943" Body="&lt;p&gt;I am trying a simple find and replace function in VI Editor to change a profile path but the &lt;code&gt;/&lt;/code&gt; is getting in my way and I need a simple and clever solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/profile: &quot;/fldr0/local/fldr/fldr1/profile/production/production.auto.profile&quot;/profile: &quot;/fldr0/local/fldr/fldr1/profile/development/development.auto.profile&quot;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And got &lt;code&gt;E488: Trailing characters&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know it has to do with the slashes but not sure what a good workaround would be since I thought the &lt;code&gt;&quot;&quot;&lt;/code&gt; would take care of it but they didn't - any help appreciated! Read all the other threads and couldn't come up with a solution probably due to lack of brain power on my part&lt;/p&gt;&#xA;" OwnerUserId="16225" LastEditorUserId="15641" LastEditDate="2019-04-06T05:48:35.680" LastActivityDate="2019-04-06T05:48:35.680" Title="E488: Trailing characters error in VI with find and replace command" Tags="|regular-expression|substitute|replace|find|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15089" PostTypeId="2" ParentId="15088" CreationDate="2018-02-05T22:53:21.927" Score="2" Body="&lt;p&gt;You want to change instances of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;profile: /fldr0/local/fldr/fldr1/profile/production/production.auto.profile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;profile: /fldr0/local/fldr/fldr1/profile/development/development.auto.profile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One way is to use a different delimiter than &lt;code&gt;/&lt;/code&gt; for the &lt;code&gt;:substitute&lt;/code&gt; command,&#xA;i.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s;profile: /fldr0/local/fldr/fldr1/profile/production/production.auto.profile;profile: /fldr0/local/fldr/fldr1/profile/development/development.auto.profile;g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it can also be simplified quite alot:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/profile:.*\zsproduction\/production/development\/development/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above regular expression, &lt;code&gt;profile:.*&lt;/code&gt; will match the first part in&#xA;a greedy manner, up until the first &lt;code&gt;production&lt;/code&gt;. &lt;code&gt;\zs&lt;/code&gt; sets the start of the&#xA;matched part, which means everything before this is ignored for the&#xA;replacement. Finally, the &lt;code&gt;production/production&lt;/code&gt; is the only part of the&#xA;string we want to change, and we escape the &lt;code&gt;/&lt;/code&gt; with a backslash, i.e. &lt;code&gt;\/&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-02-05T22:53:21.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15090" PostTypeId="1" AcceptedAnswerId="15091" CreationDate="2018-02-06T01:41:19.833" Score="4" ViewCount="1732" Body="&lt;p&gt;I'm using nvim and LaTeX together, and for the most part it's been great. However, nvim appears to be incorrectly highlighting underscores that appear in filenames I include as part of the subfiles package (&lt;a href=&quot;https://www.sharelatex.com/learn/Multi-file_LaTeX_projects#The_subfiles_package&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sharelatex.com/learn/Multi-file_LaTeX_projects#The_subfiles_package&lt;/a&gt;). At first I thought this was syntastic's fault, but I've verified that disabling syntastic does not solve the issue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what the highlights look like: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tHtdg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tHtdg.png&quot; alt=&quot;incorrect highlights in nvim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think vim thinks that the underscores are an illegal character in this context, however the report compiles just fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on turning this behavior off? Maybe just in this context if possible?&lt;/p&gt;&#xA;" OwnerUserId="16232" LastEditorUserId="1292" LastEditDate="2018-08-19T11:13:54.987" LastActivityDate="2018-08-19T11:13:54.987" Title="Syntax highlighting of underscores in LaTeX, even though they only appear in filenames" Tags="|syntax-highlighting|filetype-tex|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="15091" PostTypeId="2" ParentId="15090" CreationDate="2018-02-06T02:19:24.810" Score="5" Body="&lt;p&gt;This is happening because the syntax file for LaTeX does not recognize &lt;code&gt;\subfile{&lt;/code&gt; as a command which takes a file name.  You can customize this as follows.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your config directory (&lt;code&gt;.vim&lt;/code&gt;, &lt;code&gt;.config/nvim&lt;/code&gt;, etc), create the directory structure &lt;code&gt;/after/syntax/&lt;/code&gt;.  Create a file called &lt;code&gt;tex.vim&lt;/code&gt; with the following contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match texInputFile &quot;\\subfile\s*\(\[.*\]\)\={.\{-}}&quot;&#xA;     \ contains=texStatement,texInputCurlies,texInputFileOpt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then reload vim.  This instructs vim to treat the pattern &lt;code&gt;\subfile{name}&lt;/code&gt; as containing a file name, similar to &lt;code&gt;\input{}&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-02-06T02:25:09.723" LastActivityDate="2018-02-06T02:25:09.723" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15092" PostTypeId="1" AcceptedAnswerId="15111" CreationDate="2018-02-06T03:39:46.797" Score="3" ViewCount="2176" Body="&lt;p&gt;I like using the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; key to confirm my selection in the popup menu. However I don't like the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; key doing absolutely nothing when no item was selected in the menu -- in this case, it usually means I don't want to confirm a completion, I just want to insert a newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current remap&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; pumvisible() ? &quot;\&amp;lt;C-y&amp;gt;&quot; : &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will &quot;confirm the selection&quot; and close the popup menu even if no item is selected -- i.e. the cursor stays in the same place. Is there another function I can use in the above ternary operation, or some other approach, that will give me the desired behavior?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastActivityDate="2020-05-28T20:41:15.633" Title="Auto-complete popup menu: make Enter trigger newline if no item was selected" Tags="|key-bindings|autocompletion|plugin-you-complete-me|plugin-neocomplete|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15093" PostTypeId="2" ParentId="15072" CreationDate="2018-02-06T03:42:25.640" Score="3" Body="&lt;p&gt;Thanks to @B Layer for their help. Turns out that all escape-prefixed keycodes (e.g. forward-delete, shift-tab, scroll-wheel-up, scroll-wheel-down) will fail for the mode in question if there is any mapping of the escape key. That is: most (all?) of the keyboard events in &lt;code&gt;:help terminal-key-codes&lt;/code&gt; will fail. In my case, I had &lt;code&gt;inoremap &amp;lt;Esc&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;other stuff&amp;gt;&lt;/code&gt; in my .vimrc.&lt;/p&gt;&#xA;&lt;p&gt;So the answer is: if you want to use these key-codes, never, ever map the escape key.&lt;/p&gt;&#xA;&lt;p&gt;You also need to make sure the &lt;code&gt;&amp;amp;esckeys&lt;/code&gt; option is turned on with the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set esckeys&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but this was not the issue in my case.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2022-05-25T20:33:15.550" LastActivityDate="2022-05-25T20:33:15.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15094" PostTypeId="1" CreationDate="2018-02-06T09:17:30.467" Score="1" ViewCount="2393" Body="&lt;p&gt;I am developing a command line application that uses Vim to edit an existing file. Think &lt;code&gt;visudo&lt;/code&gt; or &lt;code&gt;crontab -e&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any command line option that I can pass to Vim to disable shell commands?&lt;/p&gt;&#xA;" OwnerUserId="9987" LastEditorUserId="51" LastEditDate="2018-04-08T23:58:35.867" LastActivityDate="2018-04-08T23:59:00.787" Title="Can I disable running shell commands in Vim?" Tags="|external-command|options|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15096" PostTypeId="1" AcceptedAnswerId="15099" CreationDate="2018-02-06T09:41:57.450" Score="3" ViewCount="519" Body="&lt;p&gt;I have following text &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_printer&#xA;_printer&#xA;_printer&#xA;_printer&#xA;_printer&#xA;_printer&#xA;_printer&#xA;_printer&#xA;printer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to find the last one by using a search for the text &lt;code&gt;printer&lt;/code&gt; which is not preceded by an underscore character &lt;code&gt;_&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that zero matches are &lt;code&gt;!&lt;/code&gt;: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/zero-width&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/zero-width&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/!_printer&#xA;/!/_printer&#xA;/!\_printer&#xA;/![_]printer&#xA;/(_)@!printer&#xA;/_@!printer&#xA;//_@!printer&#xA;/\_@!printer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;None of them works. What is the correct pattern for this search?&lt;/p&gt;&#xA;" OwnerUserId="1480" LastEditorUserId="343" LastEditDate="2018-02-06T10:07:05.947" LastActivityDate="2018-02-06T10:07:05.947" Title="How to use zero matches in regular expression?" Tags="|regular-expression|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15098" PostTypeId="2" ParentId="15080" CreationDate="2018-02-06T09:45:03.907" Score="1" Body="&lt;p&gt;&lt;em&gt;Seems that this would have a straightforward answer yet I'm not finding anything &lt;strong&gt;simple&lt;/strong&gt; that accomplishes exactly what OP wants. OTOH, I'm not too well versed in folds! Anyways, here are some approximations. Maybe they'll be useful...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you know the number of fold levels from the deepest point to the cursor you can do &lt;code&gt;Nzm&lt;/code&gt; where N is an integer. With your example this would be &lt;code&gt;3zm&lt;/code&gt;. Open it back up with &lt;code&gt;3zr&lt;/code&gt; (or &lt;code&gt;zr&lt;/code&gt; three times) Unfortunately, this starts from the deepest point &lt;em&gt;in the buffer&lt;/em&gt; and works its way up. IOW it's not related to your cursor position!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative that takes the cursor position into consideration, is to move your cursor to the deepest point of the section you want to fold, as opposed to the top of the section, and repeat &lt;code&gt;zc&lt;/code&gt; (enter repeatedly or do &lt;code&gt;Nzc&lt;/code&gt; with appropriate &lt;code&gt;N&lt;/code&gt;) until you are at the point you are starting in your example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I'm using syntax folding here &lt;code&gt;set fdm=syntax&lt;/code&gt; as opposed to &lt;code&gt;indent&lt;/code&gt; or other method.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-02-06T10:15:44.303" LastActivityDate="2018-02-06T10:15:44.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15099" PostTypeId="2" ParentId="15096" CreationDate="2018-02-06T09:54:17.107" Score="6" Body="&lt;p&gt;You're using the wrong zero width multi item. &lt;code&gt;\@!&lt;/code&gt; is negative look-&lt;em&gt;ahead&lt;/em&gt;. You could use it to e.g. find any &lt;code&gt;printer&lt;/code&gt; that is not &lt;em&gt;followed&lt;/em&gt; by an underscore:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/printer_\@!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The multi item you want to use is negative look-&lt;em&gt;behind&lt;/em&gt; &lt;code&gt;\_@&amp;lt;!&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/_\@&amp;lt;!printer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help \_@&amp;lt;!&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative technique would be to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\_[^_]printer/s+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Find any character (including an end-of-line) that is &lt;em&gt;not&lt;/em&gt; an underscore, followed by &lt;code&gt;printer&lt;/code&gt;, and place the cursor one character on from the beginning of the match.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-06T10:06:21.463" LastActivityDate="2018-02-06T10:06:21.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15100" PostTypeId="1" CreationDate="2018-02-06T10:06:01.730" Score="0" ViewCount="681" Body="&lt;p&gt;I am developing a command line application that uses VIM to edit an existing file - think visudo or crontab -e&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I launch VIM, I'm passing it the path of an existing file. I want the user to be able to modify and save the file (e.g. :w or ZZ) but I do not want the user to have the ability to save the file with another name, e.g. :w new-name.txt&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any command line option that I can pass to VIM to disable or prevent saving to a new or other file?&lt;/p&gt;&#xA;" OwnerUserId="9987" LastActivityDate="2018-02-08T14:47:21.670" Title="Prevent saving buffer with new name" Tags="|options|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15101" PostTypeId="2" ParentId="15100" CreationDate="2018-02-06T10:28:18.303" Score="3" Body="&lt;p&gt;I don't believe it's possible to completely prevent the user from doing this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you could prevent the user from doing it inadvertently via the use of autocommands. Here's a rough proof of concept that ignores the new file name when the user attempts &lt;code&gt;:w newname.txt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MySave&#xA;autocmd BufWriteCmd * :w % | set nomodified&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, note that there are many ways that a user can save text to a file in Vim. e.g. If you also want to catch &lt;code&gt;:saveas&lt;/code&gt;, you're going to also need to look into the &lt;code&gt;BufFilePre/BufFilePost&lt;/code&gt; autocommands; if you want to prevent the user writing ranges of the file, you'll also need to set up something for &lt;code&gt;FileWriteCmd&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also want to start Vim with the &lt;code&gt;-Z&lt;/code&gt; argument. See &lt;code&gt;:help -Z&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help autocmd.txt&lt;/code&gt; for more details, in particular, &lt;code&gt;:help Cmd-event&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A sufficiently knowledgeable user could simply remove these autocommands, (and even if they couldn't, they could just copy the text to the clipboard!) so this will only be a speedbump for a someone determined to save the text elsewhere.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-06T16:02:27.367" LastActivityDate="2018-02-06T16:02:27.367" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15102" PostTypeId="2" ParentId="15100" CreationDate="2018-02-06T10:42:16.460" Score="3" Body="&lt;p&gt;As suggested by the answer from @Rich, you'll have to jump through lots of hoops to make this work well in Vim. Depending on how secure you want it to be, you might be better off looking to the hosting operating system (ACL, file system permissions, chroot/jails etc.) For instance, you might set up a user with very tight restrictions on what they are permitted to do (e.g. they aren't allowed to create files on disk) and run vim as that user. This way you'll have the assurance of being backed by a proven authorization solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However you do it take note of &lt;code&gt;:h -Z&lt;/code&gt;. This puts Vim in restricted mode which blocks commands that use an external shell...the first thing someone serious about getting around the restrictions would look at. - &lt;em&gt;Aha, I just noticed that @Rich already mentioned this. Well, it's a good idea! :)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way you slice it I don't see this being an easy problem to solve.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-02-08T14:47:21.670" LastActivityDate="2018-02-08T14:47:21.670" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15103" PostTypeId="2" ParentId="3725" CreationDate="2018-02-06T11:19:43.417" Score="37" Body="&lt;pre&gt;&#xA;CTRL-W x           exchange current window with window N&#xA;                   (default: next window)&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;index.txt&lt;/code&gt; section 2.2, &quot;Window commands&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If A is the current window, then the next will be B, so you only need &lt;code&gt;&amp;lt;C-w&amp;gt; x&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If B is the current window (and there are more windows below) then you'll first have to go to A, then exchange: &lt;code&gt;&amp;lt;C-w&amp;gt; k &amp;lt;C-w&amp;gt; x&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7600" LastActivityDate="2018-02-06T11:19:43.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15104" PostTypeId="2" ParentId="14876" CreationDate="2018-02-06T12:05:31.773" Score="1" Body="&lt;p&gt;&lt;code&gt;-f&lt;/code&gt; tells &lt;code&gt;csh&lt;/code&gt; not to source its startup scripts, so you need to tell Vim to give that flag to the shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:!&lt;/code&gt; and &lt;code&gt;!&lt;/code&gt; use the shell specified in the &lt;code&gt;shell&lt;/code&gt; option, with flag(s) from the &lt;code&gt;shellcmdflag&lt;/code&gt; option.  By default, that is &lt;code&gt;-c&lt;/code&gt;, which has to come immediately before the command to run.  If you want additional options, you'll need to insert them before that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shellcmdflag=-f\ -c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7600" LastActivityDate="2018-02-06T12:05:31.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15105" PostTypeId="1" CreationDate="2018-02-06T12:53:14.100" Score="1" ViewCount="1207" Body="&lt;p&gt;I am apparently not getting a return value from execute():&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Example()&#xA;    return 5&#xA;endfunction&#xA;&#xA;:echo execute(&quot;call Example()&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just results in a blank line. The 5 is not printed. Why is this?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-02-06T13:38:39.957" Title="Execute() is not returning a value" Tags="|vimscript|ex-mode|echo|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15106" PostTypeId="1" AcceptedAnswerId="15112" CreationDate="2018-02-06T12:53:15.850" Score="1" ViewCount="377" Body="&lt;p&gt;I have NERDTree open all the time and sometimes I forget I have my cursor in there and I try to switch my main window to another buffer and it switched the NERDTree one, which get super annoying after doing it...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to lock the NERDTree buffer from changing, or should I just map a command that sequentially takes care of resetting it?&lt;/p&gt;&#xA;" OwnerUserId="13719" LastActivityDate="2018-02-07T02:14:17.033" Title="Is there a way to lock a buffer from changing?" Tags="|neovim|buffers|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15107" PostTypeId="2" ParentId="15105" CreationDate="2018-02-06T13:26:32.610" Score="3" Body="&lt;p&gt;From the documentation of &lt;code&gt;execute&lt;/code&gt;, i.e. &lt;code&gt;:h execute()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;execute({command} [, {silent}])&lt;/code&gt;&lt;br&gt;&#xA;  Execute &lt;code&gt;{command}&lt;/code&gt; and capture its output.&lt;br&gt;&#xA;  If &lt;code&gt;{command}&lt;/code&gt; is a String, returns &lt;code&gt;{command}&lt;/code&gt; output.&lt;br&gt;&#xA;  If &lt;code&gt;{command}&lt;/code&gt; is a List, returns concatenated outputs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;execute()&lt;/code&gt; returns the output of whatever is executed, not the return value of any function that may (or may not) be executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo execute('echo &quot;test&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will echo &quot;test&quot;, while&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo execute('call SomeFunc(...)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will only output whatever is echoed inside the function &lt;code&gt;SomeFunc&lt;/code&gt;. The return value is not relevant here.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-02-06T13:26:32.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15108" PostTypeId="2" ParentId="15105" CreationDate="2018-02-06T13:27:12.023" Score="2" Body="&lt;p&gt;this is because &lt;code&gt;call Example()&lt;/code&gt; alone wouldn't print anything.&#xA;You need &lt;code&gt;:echo execute(&quot;echo Example()&quot;)&lt;/code&gt; for execute() to print anything.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-02-06T13:27:12.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15109" PostTypeId="2" ParentId="15105" CreationDate="2018-02-06T13:38:39.957" Score="0" Body="&lt;p&gt;If your goal is just to print the return value of the function, you don't need the &lt;code&gt;execute&lt;/code&gt; or the &lt;code&gt;call&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo Example()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-06T13:38:39.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15110" PostTypeId="1" CreationDate="2018-02-06T14:33:27.490" Score="1" ViewCount="397" Body="&lt;p&gt;I'm trying to setup vim-LaTeX on a new pc and I'm having problems with compile and view. (&#xA;&lt;code&gt;\ll&lt;/code&gt; and &lt;code&gt;\lv&lt;/code&gt; commands).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I push &lt;code&gt;\ll&lt;/code&gt; I get the following error;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function Tex_RunLaTeX..Tex_SetupErrorWindow..Tex_GetMainFileName:&#xA;line   23:&#xA;E121: Undefined variable: v:true&#xA;E116: Invalid arguments for function glob('*.latexmain',v:true) == ''&#xA;E15: Invalid expression: glob('*.latexmain',v:true) == ''&#xA;line   34:&#xA;E121: Undefined variable: v:true&#xA;E116: Invalid arguments for function glob('*.latexmain',v:true)&#xA;E15: Invalid expression: glob('*.latexmain',v:true)&#xA;line   35:&#xA;E121: Undefined variable: lheadfile&#xA;E15: Invalid expression: lheadfile != ''&#xA;line   51:&#xA;E121: Undefined variable: lheadfile&#xA;E15: Invalid expression: lheadfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When i try to &lt;code&gt;\lv&lt;/code&gt; I get don't get an error, but evince does not open either.&lt;/p&gt;&#xA;" OwnerUserId="15685" LastEditorUserId="15685" LastEditDate="2018-02-13T14:28:37.030" LastActivityDate="2018-02-13T14:28:37.030" Title="vim - latex suite compile and view keys does not work" Tags="|filetype-tex|plugin-vim-latex|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15111" PostTypeId="2" ParentId="15092" CreationDate="2018-02-06T18:13:40.703" Score="0" Body="&lt;p&gt;I solved this with a fairly hacky solution. I just remap the keys I want to use for scrolling the popup menu to also increment/decrement a counter as the menu is scrolled. If the counter is zero, we will insert a newline instead of &quot;confirming&quot; our choice in the popup menu. Note these were developed with the &lt;a href=&quot;https://github.com/Shougo/neocomplete.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;neocomplete plugin&lt;/a&gt; with the option &lt;code&gt;let g:neocomplete#enable_auto_select=0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally just use &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;S-Tab&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;ScrollWheelUp&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;ScrollWheelDown&amp;gt;&lt;/code&gt; but included some other remaps for people who prefer different keys.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Reset the counter with autocmds where possible&#xA;au BufEnter * let b:tabcount=0&#xA;au InsertEnter * let b:tabcount=0&#xA;&quot;Helper functions&#xA;function! s:tabincrease() &quot;use this inside &amp;lt;expr&amp;gt; remaps&#xA;  let b:tabcount+=1&#xA;  return &quot;&quot; &quot;returns empty string so can be used inside &amp;lt;expr&amp;gt;&#xA;endfunction&#xA;function! s:tabdecrease() &quot;use this inside &amp;lt;expr&amp;gt; remaps&#xA;  let b:tabcount-=1&#xA;  return &quot;&quot;&#xA;endfunction&#xA;function! s:tabreset() &quot;use this inside &amp;lt;expr&amp;gt; remaps&#xA;  let b:tabcount=0&#xA;  return &quot;&quot;&#xA;endfunction&#xA;&quot;Map the default keys for navigating completion popup menu&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-y&amp;gt; pumvisible() ? &quot;\&amp;lt;C-y&amp;gt;&quot;.&amp;lt;sid&amp;gt;tabreset() : &quot;\&amp;lt;C-y&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-e&amp;gt; pumvisible() ? &quot;\&amp;lt;C-e&amp;gt;&quot;.&amp;lt;sid&amp;gt;tabreset() : &quot;\&amp;lt;C-e&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-n&amp;gt; &amp;lt;sid&amp;gt;tabincrease().&quot;\&amp;lt;C-n&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-p&amp;gt; &amp;lt;sid&amp;gt;tabdecrease().&quot;\&amp;lt;C-p&amp;gt;&quot;&#xA;&quot;Map custom keys for confirming/cancelling a menu selection&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; pumvisible() ? b:tabcount==0 ? &quot;\&amp;lt;C-e&amp;gt;\&amp;lt;CR&amp;gt;&quot; : &quot;\&amp;lt;C-y&amp;gt;&quot;.&amp;lt;sid&amp;gt;tabreset() : &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Space&amp;gt; pumvisible() ? &quot;\&amp;lt;Space&amp;gt;&quot;.&amp;lt;sid&amp;gt;tabreset() : &quot;\&amp;lt;Space&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;BS&amp;gt; pumvisible() ? &quot;\&amp;lt;C-e&amp;gt;\&amp;lt;BS&amp;gt;&quot;.&amp;lt;sid&amp;gt;tabreset() : &quot;\&amp;lt;BS&amp;gt;&quot;&#xA;&quot;Map custom keys for scrolling through the menu&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; pumvisible() ? &amp;lt;sid&amp;gt;tabincrease().&quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;Tab&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;S-Tab&amp;gt; pumvisible() ? &amp;lt;sid&amp;gt;tabdecrease().&quot;\&amp;lt;C-p&amp;gt;&quot; : &quot;\&amp;lt;S-Tab&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Down&amp;gt; pumvisible() ? &amp;lt;sid&amp;gt;tabincrease().&quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;Down&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Up&amp;gt; pumvisible() ? &amp;lt;sid&amp;gt;tabdecrease().&quot;\&amp;lt;C-p&amp;gt;&quot; : &quot;\&amp;lt;Up&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;ScrollWheelDown&amp;gt; pumvisible() ? &amp;lt;sid&amp;gt;tabincrease().&quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;ScrollWheelDown&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;ScrollWheelUp&amp;gt; pumvisible() ? &amp;lt;sid&amp;gt;tabdecrease().&quot;\&amp;lt;C-p&amp;gt;&quot; : &quot;\&amp;lt;ScrollWheelUp&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2018-02-06T18:20:40.830" LastActivityDate="2018-02-06T18:20:40.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15112" PostTypeId="2" ParentId="15106" CreationDate="2018-02-06T20:59:31.023" Score="1" Body="&lt;p&gt;I'm not aware of a native way to do this but you could set up an autocommand for NERDTree buffer only:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType nerdtree&#xA;    \ nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-O&amp;gt; &amp;lt;ESC&amp;gt; |&#xA;    \ nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-^&amp;gt; &amp;lt;ESC&amp;gt; |&#xA;    ...etc...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'd want to map like this whatever buffer swapping keys/commands that find yourself hitting regularly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(For Normal mode mappings I'd use &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; because it beeps or flashes the screen when already in Normal mode...a nice warning. If you've silenced that or just prefer to do absolutely nothing you can replace it with &lt;code&gt;&amp;lt;NOP&amp;gt;&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-02-07T02:14:17.033" LastActivityDate="2018-02-07T02:14:17.033" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15113" PostTypeId="1" CreationDate="2018-02-06T22:54:15.947" Score="4" ViewCount="2874" Body="&lt;p&gt;There isn't much from VS Code I can't reproduce with neovim but working with javascript/node, I am quite jealous of the fact that the autocompletion works with any (or most?) libraries added to the node_modules folder...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea of plugins allowing that? With youcompleteme, deoplete or language server protocol/ternjs based plugins, I've never been able to get it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thx!&lt;/p&gt;&#xA;" OwnerUserId="7579" LastEditorUserId="7579" LastEditDate="2020-12-09T22:19:50.980" LastActivityDate="2020-12-14T14:56:57.007" Title="Autocompletion with NodeJS, Visual Studio style" Tags="|neovim|autocompletion|plugin-ternjs|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="15114" PostTypeId="2" ParentId="11018" CreationDate="2018-02-07T11:01:29.670" Score="1" Body="&lt;p&gt;Be sure to &lt;em&gt;properly&lt;/em&gt; set the &lt;code&gt;guifont&lt;/code&gt; variable to the particular powerline font name and size you want to use. Excerpt for your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; use powerline symbols (supported by the hack font family)&#xA;let g:airline_powerline_fonts = 1&#xA;&#xA;&quot; set font for GUI vim&#xA;if has(&quot;gui_running&quot;)&#xA;    if has(&quot;win32&quot;)&#xA;      set guifont=Hack:h9:cANSI:qDRAFT&#xA;    else&#xA;      set guifont=Hack\ 11&#xA;    endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was facing the same problem with gvim on debian with gnome and only solved it after using the &quot;Select Font...&quot; dialog from within gvim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is how I discovered that the &lt;code&gt;guifont&lt;/code&gt; variable setting for gvim on debian is different from Windows. This is also mentioned at &lt;a href=&quot;http://vim.wikia.com/wiki/Change_font&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Change_font&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16251" LastActivityDate="2018-02-07T11:01:29.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15115" PostTypeId="1" AcceptedAnswerId="15118" CreationDate="2018-02-07T12:40:37.837" Score="4" ViewCount="1133" Body="&lt;p&gt;When searching for autocompletion on any command via &lt;kbd&gt;Tab&lt;/kbd&gt;, now &lt;code&gt;vim&lt;/code&gt; shows me a list of the available options:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qOFvh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qOFvh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was used to push the right-arrow &lt;kbd&gt;-&gt;&lt;/kbd&gt; in order to select an option while navigating them with &lt;kbd&gt;Tab&lt;/kbd&gt;, but now that doesn't work anymore. I need to push the &lt;kbd&gt;Space&lt;/kbd&gt; button instead, but that's pretty annoying when going inside a file-system hierarchy as I need to delete every white space again to show the new listing of files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to restore the &lt;kbd&gt;-&gt;&lt;/kbd&gt; selector?&lt;/p&gt;&#xA;" OwnerUserId="11736" LastActivityDate="2018-02-07T16:03:05.110" Title="Confirm selection among options" Tags="|autocompletion|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15116" PostTypeId="1" AcceptedAnswerId="15117" CreationDate="2018-02-07T14:27:11.613" Score="0" ViewCount="1413" Body="&lt;p&gt;I disabled arrow keys with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I now want arrow keys back. I removed this from my .vimrc and the configuration still applies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the default configuration for arrow keys that I should add to my .vimrc to make them work again?&lt;/p&gt;&#xA;" OwnerUserId="16253" LastActivityDate="2018-02-07T14:48:43.350" Title="How to enable back arrow keys" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="1" ClosedDate="2018-02-07T18:39:14.300" ContentLicense="CC BY-SA 3.0" />
  <row Id="15117" PostTypeId="2" ParentId="15116" CreationDate="2018-02-07T14:48:43.350" Score="3" Body="&lt;p&gt;First thing's first: did you restart Vim after altering your &lt;code&gt;.vimrc&lt;/code&gt;? Unless you &lt;code&gt;:source&lt;/code&gt; it manually or have autocommands set up to automate this when it is changed, it is only read on start-up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you remove the configuration from your &lt;code&gt;.vimrc&lt;/code&gt; then it should no longer apply. Most likely some other part of your configuration is affecting these keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try running the following command within Vim to see if your arrow keys are currently mapped, and if so, what mapped them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose nmap &amp;lt;Up&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If that reports &lt;code&gt;No mapping found&lt;/code&gt;, then something else is going wrong. It's worth checking that Vim is actually receiving the arrow-key events. Try entering insert mode and then pressing the series of keystrokes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Up&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That should tell you the keycode that Vim is receiving when you press an arrow key, and you can then investigate further why that is not resulting in movement for you.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-07T14:48:43.350" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15118" PostTypeId="2" ParentId="15115" CreationDate="2018-02-07T16:03:05.110" Score="6" Body="&lt;p&gt;The behavior you are describing is controlled by the &lt;code&gt;wildmenu&lt;/code&gt; option (&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27wildmenu%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'wildmenu'&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;While the &quot;wildmenu&quot; is active the following keys have special&#xA;  meanings:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;&amp;lt;Left&amp;gt; &amp;lt;Right&amp;gt;&lt;/code&gt;  - select previous/next match (like CTRL-P/CTRL-N)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;&amp;lt;Down&amp;gt;&lt;/code&gt;      - in filename/menu name completion: move into a subdirectory or submenu.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;        - in menu completion, when the cursor is just after a dot: move into a submenu.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt;        - in filename/menu name completion: move up into parent directory or parent menu.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The default value of this option is off but I would say that it is useful to add &lt;code&gt;set wildmenu&lt;/code&gt; to your vimrc.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-02-07T16:03:05.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15119" PostTypeId="2" ParentId="15094" CreationDate="2018-02-07T21:21:43.447" Score="2" Body="&lt;p&gt;The &lt;code&gt;-Z&lt;/code&gt; (restricted mode) command line option is what I'm looking for. This provides sufficient protection against &lt;code&gt;:!&lt;/code&gt; being used. Thanks to &lt;a href=&quot;https://vi.stackexchange.com/users/343/rich&quot;&gt;Rich&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/users/11054/b-layer&quot;&gt;B Layer&lt;/a&gt; for pointing this out in my sister question, &quot;&lt;a href=&quot;https://vi.stackexchange.com/questions/15100/prevent-saving-buffer-with-new-name&quot;&gt;Prevent saving buffer with new name&lt;/a&gt;&quot;&lt;/p&gt;&#xA;" OwnerUserId="9987" LastEditorUserId="51" LastEditDate="2018-04-08T23:59:00.787" LastActivityDate="2018-04-08T23:59:00.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15120" PostTypeId="1" AcceptedAnswerId="15123" CreationDate="2018-02-07T21:32:36.970" Score="5" ViewCount="439" Body="&lt;p&gt;Is there a good way to reverse a set of paragraphs (navigable via cursor motion &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;)?  My practical use case is reversing the order of blocks of latex code (ie, reversing the order of jobs in a resume from oldest-to-newest to newest-to-oldest).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{rSubsection}{Example 1}{}{Redacted}{}&#xA;\item Stuff I did&#xA;\item Also did other things&#xA;\end{rSubsection}&#xA;&#xA;\begin{rSubsection}{Example 2}{}{Redacted}{}&#xA;\item Stuff I did&#xA;\item Also did other things&#xA;\end{rSubsection}&#xA;&#xA;\begin{rSubsection}{Example 3}{}{Redacted}{}&#xA;\item Stuff I did&#xA;\item Also did other things&#xA;\end{rSubsection}&#xA;&#xA;\begin{rSubsection}{Example 4}{}{Redacted}{}&#xA;\item Stuff I did&#xA;\item Also did other things&#xA;\end{rSubsection}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="235" LastActivityDate="2018-02-16T09:43:20.173" Title="Reverse a set of paragraphs" Tags="|cursor-motions|normal-mode|macro|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15121" PostTypeId="2" ParentId="15120" CreationDate="2018-02-07T21:48:58.190" Score="3" Body="&lt;p&gt;You could try these 3 commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^\\begin/,/^\\end/-s/$/\=&quot;\&amp;lt;c-a&amp;gt;&quot;/|?^\\begin?,+j!&#xA;g/^/m0&#xA;%s/\%u0001/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one appends a literal &lt;code&gt;C-a&lt;/code&gt; character at the end of every line in your paragraphs, and joins all the lines in each paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that your paragraphs have been reduced to single lines, the second command can reverse their order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the third command splits the lines back into paragraphs, by removing the literal &lt;code&gt;C-a&lt;/code&gt; characters, and replacing them with newlines.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The first command can be explained like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^\\begin/,/^\\end/-s/$/\=&quot;\&amp;lt;c-a&amp;gt;&quot;/|?^\\begin?,+j!&#xA;└────────┤ └─────────────────────┤   └────────────┤&#xA;         │                       │                └ and this one (B)&#xA;         │                       └ execute this command (A)&#xA;         └ for every line beginning with `\begin`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(A)&lt;/code&gt; can be broken down further:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;,/^\\end/-s/$/\=&quot;\&amp;lt;c-a&amp;gt;&quot;/&#xA;│└──────┤│└─┤ └────────┤&#xA;│       ││  │          └ with a literal `C-a`&#xA;│       ││  │&#xA;│       ││  └ replaces any end-of-line&#xA;│       ││&#xA;│       │└ … and move up one line&#xA;│       │&#xA;│       └ down to the next line beginning with `\end` …&#xA;│&#xA;└ from the current line (because there's nothing before the comma; you could write a dot; here it's implicit)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a substitution command whose:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;range is &lt;code&gt;,/^\\end/-&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;pattern is &lt;code&gt;$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;replacement is &lt;code&gt;\&amp;lt;c-a&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It replaces any end-of-line with a literal &lt;code&gt;C-a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(B)&lt;/code&gt; can be broken down like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?^\\begin?,+j!&#xA;└────────┤ │││&#xA;         │ ││└ without adding/removing any space&#xA;         │ ││&#xA;         │ │└ join all the lines inside the range&#xA;         │ │&#xA;         │ └ down to the line below the current line (`+` = `.+1`)&#xA;         │&#xA;         └ from the previous line beginning with `\begin`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The 2nd command can be explained like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^/m0&#xA;└─┤ └┤&#xA;  │  └ move it at the top&#xA;  │&#xA;  └ for every line in the file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The 3rd command can be explained like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\%u0001/\r/g&#xA;└┤ └─────┤ └┤ │&#xA; │       │  │ └ globally (i.e. all the occurrences on a line; not just the 1st)&#xA; │       │  │&#xA; │       │  └ with a newline&#xA; │       │&#xA; │       └ replace a `C-a` (`0001` is its unicode)&#xA; │&#xA; └ for every line in the file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :g&#xA;:help :s&#xA;:help :m&#xA;:help :j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, I haven't used any of them, but you could try the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4958&quot; rel=&quot;nofollow noreferrer&quot;&gt;AdvancedSorters&lt;/a&gt; plugin (the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4433&quot; rel=&quot;nofollow noreferrer&quot;&gt;ingo-library&lt;/a&gt; being a dependency), or &lt;a href=&quot;https://gist.github.com/PeterRincker/582ea9be24a69e6dd8e237eb877b8978&quot; rel=&quot;nofollow noreferrer&quot;&gt;this snippet of code&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15612" LastEditorUserId="15612" LastEditDate="2018-02-08T11:36:29.747" LastActivityDate="2018-02-08T11:36:29.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15122" PostTypeId="2" ParentId="12678" CreationDate="2018-02-07T22:10:23.757" Score="3" Body="&lt;p&gt;You could also give the same value to the &lt;code&gt;'wildchar'&lt;/code&gt; and &lt;code&gt;'wildcharm'&lt;/code&gt; options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wc=9&#xA;set wcm=9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;9&lt;/code&gt; is the decimal code of the &lt;code&gt;Tab&lt;/code&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For your particular issue, &lt;code&gt;'wcm'&lt;/code&gt; is probably the only option you need to set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It determines which key must be pressed during the recording of a macro, or in the &lt;code&gt;{rhs}&lt;/code&gt; of a mapping to start wildcard expansion in the command-line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you should probably give it the same value as &lt;code&gt;'wc'&lt;/code&gt;, otherwise you won't be able to replay a macro opening the wildmenu:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8hghG.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8hghG.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15612" LastEditorUserId="15612" LastEditDate="2018-02-08T11:37:40.803" LastActivityDate="2018-02-08T11:37:40.803" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15123" PostTypeId="2" ParentId="15120" CreationDate="2018-02-08T10:13:58.093" Score="4" Body="&lt;p&gt;If this wasn't something that I did frequently enough to set up a mapping/custom command, I'd probably just use a macro to automate my normal edit commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;O&amp;lt;Esc&amp;gt;mfGo&amp;lt;Esc&amp;gt;qqmt'fd}mf'tPq3@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Broken down, the steps look like this&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;O&amp;lt;Esc&amp;gt;&lt;/code&gt;: Navigate to the line above the first paragraph. Your sample doesn't actually include such a line, so we're adding one.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;mf&lt;/code&gt;: Set a &quot;&lt;code&gt;f&lt;/code&gt;rom&quot; mark.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Go&amp;lt;Esc&amp;gt;&lt;/code&gt;: Navigate to the line below the last paragraph. Again, your sample doesn't include one, so we're adding it.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt;: Start recording a macro into the &lt;code&gt;&quot;q&lt;/code&gt; register.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;mt&lt;/code&gt;: Set a &quot;&lt;code&gt;t&lt;/code&gt;o&quot; mark.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'f&lt;/code&gt;: Jump to the &quot;&lt;code&gt;f&lt;/code&gt;rom&quot; mark.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d}&lt;/code&gt;: Delete the paragraph.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;mf&lt;/code&gt;: We just deleted our &quot;&lt;code&gt;f&lt;/code&gt;rom mark&quot;, so reset it.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'t&lt;/code&gt;: Jump to the &quot;&lt;code&gt;t&lt;/code&gt;o&quot; mark.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt;: Paste the deleted paragraph above the current line (and mark).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: Stop recording.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;3@q&lt;/code&gt;: Replay the macro three times. &lt;code&gt;2@q&lt;/code&gt; would also work, but it would leave the cursor after the (new) first paragraph instead of before it. Alternatively, if you don't want to count how many paragraphs need to be sorted, you could just replay it once with &lt;code&gt;@q&lt;/code&gt;, and then mash &lt;code&gt;@@&lt;/code&gt; until the paragraphs are all sorted.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you need to remove the lines we added in steps 1 &amp;amp; 3, you can do so with the commands &lt;code&gt;ddGdd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimgolf.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Golfers&lt;/a&gt; could probably shorten the number of keystrokes required, but doing it straightforwardly like this is easier in real-life scenarios. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, I would personally find this much easier to come up with on the fly than the initial &lt;code&gt;global&lt;/code&gt; command in &lt;a href=&quot;https://vi.stackexchange.com/a/15121/343&quot;&gt;user786441's otherwise excellent answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's another version that performs the same edits as in &lt;a href=&quot;https://vi.stackexchange.com/a/15162/343&quot;&gt;@SergioAraujo's excellent command-line answer&lt;/a&gt; (see the &lt;code&gt;dapggP&lt;/code&gt; in the middle), but uses a mark instead of a search to find the next paragraph to operate on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Go&amp;lt;Esc&amp;gt;gg}maqqjdapggP'aq2@qdd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-16T09:43:20.173" LastActivityDate="2018-02-16T09:43:20.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15124" PostTypeId="1" AcceptedAnswerId="15125" CreationDate="2018-02-08T13:26:06.067" Score="0" ViewCount="781" Body="&lt;p&gt;If I open CtrlP in the standard &quot;files&quot; mode I can't find the currently opened file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to change this behavior: I would like to see all files including the current opened file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I there a way to change this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I couldn't find any such open in the help file)&lt;/p&gt;&#xA;" OwnerUserId="3230" LastEditorUserId="3230" LastEditDate="2018-02-08T13:51:15.670" LastActivityDate="2018-02-08T14:03:42.820" Title="Let CtrlP show all files including the file being edited" Tags="|plugin-ctrlp|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15125" PostTypeId="2" ParentId="15124" CreationDate="2018-02-08T13:53:22.797" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim/blob/master/doc/ctrlp.txt#L459&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'g:ctrlp_match_current_file'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Includes the current file in the match entries: &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;let g:ctrlp_match_current_file = 1&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can add the line to your vimrc if you want the behavior to be permanent.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-02-08T14:03:42.820" LastActivityDate="2018-02-08T14:03:42.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15126" PostTypeId="1" AcceptedAnswerId="15127" CreationDate="2018-02-08T14:15:34.643" Score="0" ViewCount="45" Body="&lt;p&gt;I am looking for a way to replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\cmd1{stuff \cmd2{other stuff}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(stuff \cmd2{other stuff})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\\cmd1{\(.\{-}\)}/(\1)/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this returns&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(stuff \cmd2{other stuff)}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;since the first &lt;code&gt;}&lt;/code&gt; after &lt;code&gt;{&lt;/code&gt; is taken because of &lt;code&gt;\{-}&lt;/code&gt; -- taking the greedy version does not help, in the case that there is another &lt;code&gt;}&lt;/code&gt; later on the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better expression to put inside &lt;code&gt;{\( \)}&lt;/code&gt; so that &lt;code&gt;\( \)&lt;/code&gt; encompasses everything up to the matching &lt;code&gt;}&lt;/code&gt; to &lt;code&gt;{&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="16271" LastEditorUserId="1841" LastEditDate="2018-02-08T17:00:30.733" LastActivityDate="2018-02-08T17:00:30.733" Title="Matching delimited text, taking into account level" Tags="|regular-expression|replace|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15127" PostTypeId="2" ParentId="15126" CreationDate="2018-02-08T15:53:18.180" Score="1" Body="&lt;h2&gt;Regular Expression&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you &lt;em&gt;don't&lt;/em&gt; need to be able to support arbitrary levels of nesting, (if there's never a &lt;code&gt;\cmd3&lt;/code&gt; inside your &lt;code&gt;\cmd2&lt;/code&gt;), then you can do this by incorporating the inner brackets into your expression, and matching &quot;any character that's not a bracket&quot; &lt;code&gt;[^}]&lt;/code&gt; instead of &quot;any character&quot; &lt;code&gt;.&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\\cmd1{\([^{]*{[^}]*}\)}/(\1)/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Macro Alternative&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you can use a macro instead:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're using the &lt;code&gt;c&lt;/code&gt; confirm flag to inspect every change, so try the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/\\cmd1{&amp;lt;Cr&amp;gt;&lt;/code&gt;: Find the first &lt;code&gt;\cmd1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt;: Start recording&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dt{&lt;/code&gt;: delete the &lt;code&gt;\cmd1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt;: Jump to matching &lt;code&gt;}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;r)``r(&lt;/code&gt;: Replace curly brackets with round ones&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt;: Jump to next match&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: Stop recording&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then press &lt;code&gt;@q&lt;/code&gt; to repeat the change, or &lt;code&gt;n&lt;/code&gt; to skip this instance and jump to the next. After you've used &lt;code&gt;@q&lt;/code&gt; at least once, you can use &lt;code&gt;@@&lt;/code&gt; as a faster shortcut.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you actually don't want to review the changes as you make them, you can make the macro recursive by changing the recording steps 2&amp;ndash;7 to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqqqqdt{%r)``r(n@qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then invoke it a single time to make all the changes in one go: &lt;code&gt;@q&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-08T16:29:45.160" LastActivityDate="2018-02-08T16:29:45.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15128" PostTypeId="1" AcceptedAnswerId="15132" CreationDate="2018-02-08T17:50:26.497" Score="0" ViewCount="501" Body="&lt;p&gt;I have a tab-delimited text file with fairly long lines. To improve readability, I would like to color text in each column individually. Is this possible in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the first column text would be green, the second magenta and the third one in yellow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be nice if a shortcut could be set so that I can quickly activate this mode when needed.&lt;/p&gt;&#xA;" OwnerUserId="15971" LastActivityDate="2018-02-08T19:12:04.720" Title="Set text color for each column" Tags="|color|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15129" PostTypeId="1" AcceptedAnswerId="15131" CreationDate="2018-02-08T18:25:03.823" Score="0" ViewCount="376" Body="&lt;p&gt;So I have made about 10/12 substitutions in my current file using &lt;code&gt;%s/longpatternN//g&lt;/code&gt;. Unfortunately I have to apply these same substitutions in 10 &#xA; or more of my files. I can access my last commands via &lt;code&gt;up arrow&lt;/code&gt;. So I am trying to copy my last command pattern, build a &lt;code&gt;sed&lt;/code&gt; command and put them in a shell script to automate this boring stuff. But it looks like my Git Bash not letting me select and copy these substitution command texts via my mouse in vim. So where can I access all history of my all recent vim commands? Can we access any files may be vim storing these commands into?&lt;/p&gt;&#xA;" OwnerUserId="7332" LastEditorUserId="1292" LastEditDate="2019-11-19T10:36:55.793" LastActivityDate="2019-11-19T10:36:55.793" Title="Where are my recent commands stored in Vim?" Tags="|command-history|viminfo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15131" PostTypeId="2" ParentId="15129" CreationDate="2018-02-08T18:41:54.510" Score="1" Body="&lt;p&gt;You have a couple of options here. I thing Vim inside Git Bash can access the windows clipboard, so you can try the following:&#xA;&lt;code&gt;q:&lt;/code&gt; to enter to history 'edit' mode, then &lt;code&gt;k&lt;/code&gt; many times as needed or search for your pattern with &lt;code&gt;?&lt;/code&gt;, and then&#xA;&lt;code&gt;&#xA;0v$&#xA;&quot;+y&#xA;&lt;/code&gt;&#xA;Here &lt;code&gt;+&lt;/code&gt; is the register for the clipboard. After the previos commands you can paste on the bash prompt without problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the other option is (on command prompt): &lt;code&gt;cat $HOME/.viminfo | grep ':s'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;$HOME/.viminfo&lt;/code&gt; contains information about your vim sessions, including commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I also recommend to take a look on &lt;code&gt;:h :bufdo&lt;/code&gt; and &lt;code&gt;:h :argdo&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11690" LastEditorUserId="11690" LastEditDate="2018-02-08T18:53:58.010" LastActivityDate="2018-02-08T18:53:58.010" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15132" PostTypeId="2" ParentId="15128" CreationDate="2018-02-08T19:12:04.720" Score="2" Body="&lt;p&gt;I assume by &quot;column&quot; you mean in a tab-delimited sense.  You can get this effect with the following code.  Turn on and off with &lt;code&gt;:DoColorColumns&lt;/code&gt;/&lt;code&gt;:NoColorColumns&lt;/code&gt;. You can easily make a mapping if desired.&#xA;All this is doing is using &lt;code&gt;matchadd(&lt;/code&gt; with a regular expression that skips the appropriate number of &lt;code&gt;text+tab&lt;/code&gt; blocks.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ColorColumns(state)&#xA;  let l:colors = ['green', 'magenta', 'yellow',&#xA;        \ 'red', 'blue', 'darkyellow', 'cyan', 'white']&#xA;&#xA;  if exists('s:column_matchids')&#xA;    call map(filter(s:column_matchids, 'v:val &amp;gt; -1'),&#xA;          \'matchdelete(v:val)')&#xA;  endif&#xA;  let s:column_matchids = repeat([-1], len(l:colors))&#xA;&#xA;  if !a:state | return | endif&#xA;&#xA;  for l:i in range(len(l:colors))&#xA;    exe 'hi Column'.l:i 'guifg='.l:colors[l:i] 'ctermbg='.l:colors[l:i]&#xA;    let s:column_matchids[l:i] = matchadd('Column'.l:i,&#xA;          \ '^'.repeat('.\{-}\t',l:i).'\zs.\{-}\ze$')&#xA;  endfor&#xA;endfunction&#xA;&#xA;command! DoColorColumns call ColorColumns(1)&#xA;command! NoColorColumns call ColorColumns(0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also the plugin &lt;a href=&quot;https://github.com/chrisbra/csv.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/chrisbra/csv.vim&lt;/a&gt;, which works for tab-delimited files as well as comma-separated ones.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-02-08T19:12:04.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15134" PostTypeId="1" AcceptedAnswerId="15136" CreationDate="2018-02-08T20:34:38.487" Score="0" ViewCount="115" Body="&lt;p&gt;I was trying to find out if it is possible to give an ex command a list of lines instead of a range? &lt;/p&gt;&#xA;" OwnerUserId="16273" LastActivityDate="2018-02-09T07:56:15.407" Title="Discrete line numbers specified individually not as range" Tags="|vimscript|ex-mode|line-numbers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15135" PostTypeId="1" CreationDate="2018-02-08T21:45:59.773" Score="1" ViewCount="41" Body="&lt;p&gt;Is it possible to see the sequence of key presses that are undone/redone when using u and Ctrl-r commands?&lt;/p&gt;&#xA;" OwnerUserId="15997" LastEditorUserId="15997" LastEditDate="2018-02-08T22:02:58.167" LastActivityDate="2018-02-08T22:02:58.167" Title="How to view the command that was just un(re)done" Tags="|undo-redo|command-history|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15136" PostTypeId="2" ParentId="15134" CreationDate="2018-02-09T07:56:15.407" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3arange&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :range&lt;/code&gt;&lt;/a&gt; it doesn't seem possible to use a list of numbers as a range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that what you are looking for is the global command (&lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%3aglobal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :global&lt;/code&gt;&lt;/a&gt;) which applies a command on the lines matching a pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2fordinary-atom&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /ordinary-atom&lt;/code&gt;&lt;/a&gt; you will see that &lt;code&gt;\%Xl&lt;/code&gt; allows you to match the line number &lt;code&gt;X&lt;/code&gt;. So for example if you have the following buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar&#xA;fizz&#xA;fuzz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you want to replace &lt;code&gt;f&lt;/code&gt; by &lt;code&gt;F&lt;/code&gt; on the first line you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\%1l/s/f/F&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if you want to do it on the first and third line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\%1l\|\%3l/s/f/F&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-02-09T07:56:15.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15137" PostTypeId="1" CreationDate="2018-02-09T10:05:45.263" Score="0" ViewCount="19" Body="&lt;p&gt;I'm using &lt;kbd&gt;CTRL&lt;/kbd&gt; + &lt;kbd&gt;n&lt;/kbd&gt; to do auto-completion when editing - since years.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One things that annoys me (and now I want the solution) is that the completion is not replaced characters until the next non-letter-characters (everything else than &lt;code&gt;0-9a-zA-Z_&lt;/code&gt; for me).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For exemple, I have the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;auto a = obj-&amp;gt;getSomething()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to change the called method to &lt;code&gt;getString&lt;/code&gt;. I'll put my cursor right behind the &lt;code&gt;S&lt;/code&gt; and press &lt;kbd&gt;CTRL&lt;/kbd&gt; + &lt;kbd&gt;n&lt;/kbd&gt; until the right method appears and I select it with &lt;kbd&gt;ENTER&lt;/kbd&gt;. Here is what I end up with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;auto a = obj-&amp;gt;getStringomethingNumber()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideally vim would have replaced everything up to &lt;code&gt;(&lt;/code&gt; with the method-name, so to get it directly, without have to do &lt;kbd&gt;dw&lt;/kbd&gt; manually.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;auto a = obj-&amp;gt;getString()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can achieve this?&lt;/p&gt;&#xA;" OwnerUserId="1542" LastEditorUserId="1542" LastEditDate="2018-02-09T10:12:14.493" LastActivityDate="2018-02-09T10:12:14.493" Title="How to configure autocompletion so that it replaces everything until non-word-char?" Tags="|autocompletion|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15138" PostTypeId="1" AcceptedAnswerId="16134" CreationDate="2018-02-09T10:23:34.567" Score="2" ViewCount="718" Body="&lt;p&gt;I've been using vim for two years but there are many things I don't know very well.&#xA;Today, I was coding in c++ and found that I wanted to type the snippet like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Horse(COLOR color, HANDS height, int age):&#xA;Animal(age),&#xA;itsColor(color),&#xA;itsHeight(height) {&#xA;    cout &amp;lt;&amp;lt; &quot;Horse constructor...\n&quot;;&#xA;}   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead I found:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Horse(COLOR color, HANDS height, int age):&#xA;Animal(age),&#xA;    itsColor(color),&#xA;    itsHeight(height) {&#xA;        cout &amp;lt;&amp;lt; &quot;Horse constructor...\n&quot;;&#xA;    } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I make the closing curly brace to align with the constructor definition?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vimrc settings are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set secure&#xA;set showmode&#xA;set number&#xA;set relativenumber&#xA;set cursorline&#xA;set linebreak&#xA;set colorcolumn=81&#xA;set updatetime=1000&#xA;set conceallevel=0&#xA;set showbreak=↳&#xA;set wrap&#xA;set lcs=tab:&amp;gt;-,nbsp:%,trail:¬&#xA;set list&#xA;set cinoptions=g0,l1,i0&#xA;set smarttab&#xA;set tabstop=4&#xA;set softtabstop=4&#xA;set shiftwidth=4&#xA;set shiftround&#xA;set expandtab&#xA;autocmd FileType make setlocal noexpandtab&#xA;autocmd FileType markdown setlocal colorcolumn=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-27T04:19:08.663" LastActivityDate="2019-02-27T04:19:08.663" Title="Set Indentation when Declaring Constructors for C++ Classes with Inheritance" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15139" PostTypeId="1" AcceptedAnswerId="15149" CreationDate="2018-02-09T12:26:12.963" Score="2" ViewCount="1598" Body="&lt;p&gt;What can I do to have proper highlighting on a .git file? I chose Vim as my default editor when I commit files, the color scheme(&lt;a href=&quot;https://github.com/morhetz/gruvbox&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gruvbox&lt;/a&gt;) is applied, but I get strange colors as I start typing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to have the delimiter on the recommended number of characters to write before changing to a new line as well. It seems like I only get it for the first line. Afterwards I get this strange highlighted text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/02Jp8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/02Jp8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16284" LastActivityDate="2018-02-09T18:33:30.623" Title="Strange Highlighting during Git Commit" Tags="|syntax-highlighting|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15140" PostTypeId="1" AcceptedAnswerId="15142" CreationDate="2018-02-09T12:42:07.870" Score="9" ViewCount="966" Body="&lt;p&gt;I have a macro to swap text.&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/bWWZP.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bWWZP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For single line, it's running without problem.&lt;br&gt;&#xA;But if I run this macro many times and one line is empty or different pattern, it will print below error and stop.&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/h27kE.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h27kE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;Is there a way to force it keep running even the pattern is not found.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-11-16T18:38:00.907" Title="How to force macro keep running even pattern is not found?" Tags="|macro|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15142" PostTypeId="2" ParentId="15140" CreationDate="2018-02-09T13:03:05.343" Score="10" Body="&lt;p&gt;You can use &lt;code&gt;:try&lt;/code&gt; to do that (&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3atry&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :try&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example (I didn't use your macro because you posted it as an image and it's not easy to copy :) )&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @z=':try|s/foo/bar/|catch||endtry^M'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that &lt;code&gt;^M&lt;/code&gt; should be entered with &lt;kbd&gt;ctrl+v&lt;/kbd&gt;&lt;kbd&gt;enter&lt;/kbd&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way &lt;code&gt;@z&lt;/code&gt; will try to make the substitution and if it fails nothing will happen. For example on this buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;faa&#xA;fii&#xA;foo&#xA;faa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;5@z&lt;/code&gt; will substitute all of the &lt;code&gt;foo&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-02-09T15:26:51.593" LastActivityDate="2018-02-09T15:26:51.593" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15143" PostTypeId="1" CreationDate="2018-02-09T14:39:28.777" Score="0" ViewCount="731" Body="&lt;p&gt;I have found how to &lt;a href=&quot;https://vi.stackexchange.com/q/1942/9863&quot;&gt;silently&lt;/a&gt; execute a command with &lt;code&gt;:silent&lt;/code&gt;, but I actually would like to &lt;strong&gt;echo&lt;/strong&gt; the command being executed, without getting into this &quot;hit-enter&quot; prompt. How to do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My example is a function for synctex forward search, put into my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SyncTexForward()&#xA;    &quot; use file path relative to current directory&#xA;    let execstr = &quot;silent !zathura --synctex-forward &quot;.line(&quot;.&quot;).&quot;:&quot;.col(&quot;.&quot;).&quot;:&quot;.@%.&quot; &quot;.fnamemodify(@%, &quot;:r&quot;) . &quot;.pdf &amp;amp;&quot;&#xA;    exec execstr&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without &lt;code&gt;silent&lt;/code&gt;, it would display the command + its output, that is one line with the pid, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!zathura --synctex-forward 612:1:myfile.tex myfile.pdf &amp;amp;&#xA;[1] 4648&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried temporarily changing &lt;code&gt;&amp;amp;cmdheight&lt;/code&gt; to 2, but it has the same effect as &lt;code&gt;silent&lt;/code&gt; (no echo at all)&lt;/p&gt;&#xA;" OwnerUserId="9863" LastActivityDate="2018-02-09T17:39:38.293" Title="How to echo a command but avoid the &quot;hit enter&quot; prompt" Tags="|echo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15146" PostTypeId="1" AcceptedAnswerId="15148" CreationDate="2018-02-09T17:28:16.193" Score="0" ViewCount="200" Body="&lt;p&gt;Is it possible to execute bash string manipulations to the filename of the current file, represented by &lt;code&gt;%&lt;/code&gt; in external commands from within vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am editing a file &lt;code&gt;myfile.txt&lt;/code&gt;. Using &lt;code&gt;:! command %&lt;/code&gt;, I can execute a &lt;code&gt;command&lt;/code&gt; on &lt;code&gt;myfile.txt&lt;/code&gt; from within vim. For instance, to copy &lt;code&gt;myfile.txt&lt;/code&gt; to &lt;code&gt;myfile.ext&lt;/code&gt; (simply change the extension), I can write &lt;code&gt;:! cp % myfile.ext&lt;/code&gt;. But there is some redundancy, and I'd like to deduce &lt;code&gt;myfile.ext&lt;/code&gt; from &lt;code&gt;%&lt;/code&gt; (and avoid writing &lt;code&gt;myfile&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In bash, if the name &lt;code&gt;myfile.txt&lt;/code&gt; is contained in the variable &lt;code&gt;$var&lt;/code&gt;, I can write &lt;code&gt;cp $var ${var%txt}ext&lt;/code&gt; for instance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to mimick this in vim? Of course, I cannot write &lt;code&gt;:! cp % ${%%txt}ext&lt;/code&gt;... though it is what I'd like to be able to!&lt;/p&gt;&#xA;" OwnerUserId="16287" LastActivityDate="2018-02-09T18:09:37.083" Title="Substring of filename in external command (bang)" Tags="|external-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15147" PostTypeId="2" ParentId="15143" CreationDate="2018-02-09T17:39:38.293" Score="1" Body="&lt;p&gt;So my question was quite stupid actually. It sufficed to add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo execstr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;just before&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec execstr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I could also capture the shell stdout and display it too, it would also be nice.&lt;/p&gt;&#xA;" OwnerUserId="9863" LastActivityDate="2018-02-09T17:39:38.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15148" PostTypeId="2" ParentId="15146" CreationDate="2018-02-09T18:09:37.083" Score="3" Body="&lt;p&gt;You don't need to shell out to save a copy with a different extension. Try either of the following, both of which use the &quot;root&quot; &lt;code&gt;:r&lt;/code&gt; modifier to strip the extension from the filename:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w %:r.ext&#xA;:sav %:r.ext&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The former will save a copy, but leave you editing the original. The latter will switch over so that you are now editing the copy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h filename-modifiers&lt;/code&gt; for details of the many different modifiers Vim provides.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-09T18:09:37.083" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15149" PostTypeId="2" ParentId="15139" CreationDate="2018-02-09T18:33:30.623" Score="10" Body="&lt;p&gt;Your Vim setup is actually behaving correctly, here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Git commit messages are recommended always to have a blank line after the first line. The strange colouring you're seeing is highlighting this as an error so you can fix it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The recommended line limit for the first line is smaller than the limit for later lines (because the first line is often pushed off to the right by commit IDs. etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, your config has set up hard-wrapping using &lt;code&gt;'textwidth'&lt;/code&gt; for the later lines, and the colouring to indicate when you've reached the recommended limit for the first line.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-09T18:33:30.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15150" PostTypeId="1" CreationDate="2018-02-09T20:03:47.953" Score="4" ViewCount="1445" Body="&lt;p&gt;I'm using vim 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the attached picture you see yellow vertical lines that indicate the indentations of a code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/idjmT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/idjmT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to color depending on their indentation level? E.g. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;all vertical indentation lines on indentation level 1 should be red&lt;/p&gt;&#xA;&#xA;&lt;p&gt;all vertical indentation lines on indentation level 2 should be yellow&lt;/p&gt;&#xA;&#xA;&lt;p&gt;all vertical indentation lines on indentation level 3 should be green&lt;/p&gt;&#xA;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: If it is of any relevance: I'm using &lt;a href=&quot;https://github.com/Yggdroot/indentLine&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Yggdroot/indentLine&lt;/a&gt;&#xA;That plugin doesn't have an option to color the vertical indentation lines  dependent on the indentation level&lt;/p&gt;&#xA;" OwnerUserId="16282" LastActivityDate="2024-03-16T18:04:55.547" Title="Is it possible to color vim vertical indentation lines depending on the indentation level?" Tags="|indentation|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15151" PostTypeId="1" AcceptedAnswerId="15154" CreationDate="2018-02-09T23:04:27.707" Score="3" ViewCount="848" Body="&lt;p&gt;For instance move from (the cursor is on the letter in bold italic, in the second column)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;b&lt;b&gt;&lt;i&gt;l&lt;/i&gt;&lt;/b&gt;ablabla&#xA;blablabla&#xA;blablabla&#xA;blablabla&#xA;  bla&#xA;  bla&#xA;  bla&#xA;bLablabla&#xA;l@st&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;blablabla&#xA;blablabla&#xA;blablabla&#xA;b&lt;b&gt;&lt;i&gt;l&lt;/i&gt;&lt;/b&gt;ablabla&#xA;  bla&#xA;  bla&#xA;  bla&#xA;bLablabla&#xA;l@st&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then to the &quot;@&quot;. That would be &quot;vertical &lt;code&gt;E&lt;/code&gt;&quot;. And the same for &lt;code&gt;W&lt;/code&gt; (move from the initial position to the capital &quot;L&quot;) and &lt;code&gt;B&lt;/code&gt; (@ → L → first l).&lt;/p&gt;&#xA;" OwnerUserId="16012" LastEditorUserId="16012" LastEditDate="2018-02-10T17:31:22.453" LastActivityDate="2018-02-12T22:41:14.127" Title="Move to the first/last non-whitespace character of the column (&quot;vertical W/B/E&quot;)" Tags="|cursor-movement|cursor-motions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15152" PostTypeId="1" CreationDate="2018-02-10T08:48:46.143" Score="2" ViewCount="350" Body="&lt;p&gt;Recently, neovim auto indent was working fine, but suddenly it stopped working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is my &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt;:- &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.local/share/nvim/plugged')&#xA;&#xA;Plug 'townk/vim-autoclose'&#xA;&#xA;Plug 'wesq3/vim-windowswap'&#xA;&#xA;Plug 'scrooloose/nerdtree'&#xA;&#xA;Plug 'vim-scripts/c.vim'&#xA;&#xA;Plug 'vim-airline/vim-airline'&#xA;&#xA;Plug 'vim-airline/vim-airline-themes'&#xA;&#xA;Plug 'arcticicestudio/nord-vim'&#xA;&#xA;set number&#xA;&#xA;call plug#end()&#xA;&#xA;&#xA;colorscheme nord&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the same file as it was when neovim indentation was working correctly.&#xA;I just found out that indentation is also not working in vim.  &lt;/p&gt;&#xA;" OwnerDisplayName="user16300" LastEditorUserId="5298" LastEditDate="2018-02-12T07:34:43.587" LastActivityDate="2018-02-12T07:34:43.587" Title="vim auto indent suddenly stopped working" Tags="|neovim|indentation|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15153" PostTypeId="1" AcceptedAnswerId="15164" CreationDate="2018-02-10T13:05:34.963" Score="1" ViewCount="672" Body="&lt;p&gt;The expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v(A)@&amp;lt;=b+\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;means?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's sure this is able to find 'bbbA' in &quot;AbbbA'-s.&#xA;It's trivial that the number n of b-s can be any n &gt; 1.&lt;/p&gt;&#xA;" OwnerUserId="15440" LastEditorUserId="15440" LastEditDate="2018-02-10T13:18:50.703" LastActivityDate="2018-02-11T21:42:04.903" Title="What '\v' and '@&lt;=' in '/\v(A)@&lt;=b+\1' regex means?" Tags="|regular-expression|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15154" PostTypeId="2" ParentId="15151" CreationDate="2018-02-10T13:59:38.127" Score="5" Body="&lt;p&gt;Interesting. Vertical analogues of word motion commands. I'm not aware of any native way to do this so my first thought is to just start with regex searches. Turns out doing such searches in one step is not trivial but still viable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First a couple notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;To make it quite a bit easier I'm using (vertical) &lt;code&gt;WORD&lt;/code&gt; motions (&lt;code&gt;W&lt;/code&gt;,&lt;code&gt;B&lt;/code&gt;,&lt;code&gt;E&lt;/code&gt;) rather than &lt;code&gt;word&lt;/code&gt; (&lt;code&gt;w&lt;/code&gt;,&lt;code&gt;b&lt;/code&gt;,&lt;code&gt;e&lt;/code&gt;). The latter is &lt;code&gt;[a-zA-Z0-9_]+&lt;/code&gt; OR a sequence of other non-blank characters while a &lt;code&gt;WORD&lt;/code&gt; is just &lt;code&gt;\S+&lt;/code&gt;. In fact, your example is actually demonstrating &lt;code&gt;WORD&lt;/code&gt; motion because otherwise the second &lt;code&gt;e&lt;/code&gt; would end up on the &lt;code&gt;L&lt;/code&gt; not the &lt;code&gt;@&lt;/code&gt;. &lt;em&gt;[Note: the question originally referred to &lt;code&gt;w&lt;/code&gt;,&lt;code&gt;b&lt;/code&gt;,&lt;code&gt;e&lt;/code&gt; but has since been edited.]&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;The patterns will use 'very magic' flag to reduce length and improve readability.&lt;/li&gt;&#xA;&lt;li&gt;To start, my pattern will be based on a fixed column number (4). This will be made variable later. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Starting with &lt;code&gt;E&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v%4v\S.*(\n.{3}\s|\n.{,3}\n|%$)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; - very magic&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%4v\S&lt;/code&gt; - in column 4 there must be a non-whitespace character (our &lt;code&gt;WORD&lt;/code&gt; char)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*&lt;/code&gt; - slurp up anything remaining on the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(..|..|..)&lt;/code&gt; - parens indicating any of the following three patterns are allowed on the next line...&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\n.{3}\s&lt;/code&gt; - after the current line's newline the next line starts with three characters followed by whitespace (in the cursor column)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\n.{,3}\n&lt;/code&gt; - after the newline there are three or fewer characters total on the next line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%$&lt;/code&gt; - there is no next line as indicated by this &lt;em&gt;end of file&lt;/em&gt; token (allowing vertical &lt;code&gt;E&lt;/code&gt; motion to end on the last line of the buffer)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This doesn't do us much good as a standalone pattern. The best thing to do is put it in a function. The key lines will look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let curcol = getcurpos()[2]&#xA;let prevcol = curcol - 1&#xA;call searchpos('\v%' . curcol . 'v\S.*\n(.{' . prevcol . '}\s|.{,' . prevcol . '}\n)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This just looks at whatever column the cursor is currently on and inserts that and one less into the previously discussed pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Combining the above pattern and similar patterns for the other motions and parameterizing by motion types &lt;code&gt;W&lt;/code&gt;, &lt;code&gt;B&lt;/code&gt; and &lt;code&gt;E&lt;/code&gt; I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! VertWordMotion(motion)&#xA;    let curcol = getcurpos()[2]&#xA;    let prevcol = curcol - 1&#xA;    if a:motion == 'E'&#xA;        call searchpos('\v%' . curcol . 'v\S.*(\n.{' . prevcol . '}\s|\n.{,' . prevcol . '}\n|%$)', 'W')&#xA;    elseif a:motion == 'B'&#xA;        call searchpos('\v(%' . curcol . 'v\s.*\n|^.{,' . prevcol . '}\n|%^).{' . prevcol . '}\zs\S', 'bW')&#xA;    elseif a:motion == 'W'&#xA;        call searchpos('\v(%' . curcol . 'v\s.*|^.{,' . prevcol . '})\n.{' . prevcol . '}\zs\S', 'W')&#xA;    else&#xA;        echohl ErrorMsg | echo 'Not a valid motion: ' . a:motion | echohl None&#xA;    endif&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, create mappings like these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;E :call VertWordMotion('E')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;B :call VertWordMotion('B')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;W :call VertWordMotion('W')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-02-12T22:41:14.127" LastActivityDate="2018-02-12T22:41:14.127" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="15155" PostTypeId="1" CreationDate="2018-02-10T14:07:25.940" Score="2" ViewCount="1281" Body="&lt;p&gt;I am trying to map the key sequence Ctrl-W arrow key to navigate between open split windows in Vim. I find it a bit too complicated to press 3 keys to move between open windows so ideally I would like to map this sequence to the sequence I normally use in Terminator Alt-arrow key. For example, in Terminator I would press Alt-Left to move one window to the left, Alt-Down to move one window to the bottom, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried following &lt;a href=&quot;http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_2)&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim key mappings page&lt;/a&gt; and tried this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:map &amp;lt;press Alt-Down&amp;gt; &amp;lt;press Ctrl-W&amp;gt;&amp;lt;press Down&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but it doesn't work. No error message. Nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also tried this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:map &amp;lt;A-Down&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;Down&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but it doesn't work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I miss anything?&#xA;How do I map Ctrl-W arrow to Alt-arrow?&lt;/p&gt;&#xA;" OwnerUserId="15825" LastEditorUserId="15825" LastEditDate="2018-02-10T19:26:24.167" LastActivityDate="2018-02-11T00:50:07.767" Title="How to map Ctrl-W &lt;arrow&gt; to Alt &lt;arrow&gt;" Tags="|vimrc|" AnswerCount="0" CommentCount="4" ClosedDate="2018-02-12T08:11:56.977" ContentLicense="CC BY-SA 3.0" />
  <row Id="15160" PostTypeId="1" CreationDate="2018-02-11T15:33:31.180" Score="5" ViewCount="9437" Body="&lt;p&gt;While editing a file my neovim crashed when I tried to save the file (with the error message &lt;code&gt;&amp;quot;init.vim&amp;quot; 77L, 2423C writtennvim(5888,0x7fffa9f29340) malloc: *** error for object 0x7f861301d400: pointer being freed was not allocated&lt;/code&gt;), and after that I tried to edit it again, the following dialog is shown.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Swap file &amp;quot;~/.local/share/nvim/swap//%Users%me%.config%nvim%init.vim.swp&amp;quot; already exists!&lt;/p&gt;&#xA;&lt;p&gt;[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;However, it seems that all of the options I choose lead to the same crash and recover loop, so I tried to delete all the swap files.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.local/share/nvim/swap&#xA;rm -rf *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The swap files are all gone, but even after that, when I tried to open the file, edit, and save it, the same crash occured, and then the swap file is created and the same recovery mode is shown on the next launch.&lt;/p&gt;&#xA;&lt;p&gt;How can I discard the swap and regain my editing capability without installing it again?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-02-12T09:46:57.907" Title="How to delete swap files on neovim?" Tags="|neovim|swap-file|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15162" PostTypeId="2" ParentId="15120" CreationDate="2018-02-11T20:47:30.857" Score="3" Body="&lt;p&gt;Another one line solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$put _ | g/Example [2-4]/normal! dapggP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One line solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$pu _ | 16,20m0 | 16,20m5 | 16,20m10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have thought a lot until reach this elegant solution (one-liner above). In this solution, we are adding a new lind at the end &lt;code&gt;:$pu _&lt;/code&gt;, then, we are getting the last lines and moving them to the line 0, 5 and 10 respectively&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$pu _ | normal gg&#xA;:16,$m.-1 | normal j&#xA;2@:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(old solution) This solution will invert the blocks order&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$put _ ..................... add a new line at the end&#xA;4k .........................  move to the begining of {example 4}&#xA;5:m-0 ......................  move next 5 lines to line zero&#xA;}}j ........................  move to {example 3}&#xA;5:m-11 .....................  move block to 11 lines before&#xA;}j .........................  move to the {example 2}&#xA;5:m-6 ......................  finishes the magic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice: When you type &lt;code&gt;5:m-0&lt;/code&gt; for example vim will show &lt;code&gt;:.,.+4m-0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OBS: if this block is inside a bigger one you have to use your &#xA;     Relative numbers to do the trick &lt;code&gt;:set nu rnu&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want mappings to move blocks &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot; Move lines in all modes &#xA;vnoremap J :m '&amp;gt;+1&amp;lt;CR&amp;gt;gv=gv&#xA;vnoremap K :m '&amp;lt;-2&amp;lt;CR&amp;gt;gv=gv&#xA;inoremap &amp;lt;A-j&amp;gt; &amp;lt;Esc&amp;gt;:m+&amp;lt;CR&amp;gt;==gi&#xA;inoremap &amp;lt;A-k&amp;gt; &amp;lt;Esc&amp;gt;:m-2&amp;lt;CR&amp;gt;==gi&#xA;nnoremap &amp;lt;A-j&amp;gt; :m+&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;A-k&amp;gt; :m-2&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2018-02-15T17:51:51.997" LastActivityDate="2018-02-15T17:51:51.997" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15163" PostTypeId="2" ParentId="15151" CreationDate="2018-02-11T21:29:59.130" Score="2" Body="&lt;p&gt;Although I think @BLayer's answer is very good, I also think it is worth mentioning the &lt;a href=&quot;https://github.com/machakann/vim-columnmove&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-columnmove&lt;/a&gt; plugin:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This plugin implements several keymappings to move cursor in vertical direction.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The plugin implements columnwise versions of the following motions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;f&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;F&lt;/code&gt;, &lt;code&gt;T&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;&lt;/code&gt;, &lt;code&gt;,&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;W&lt;/code&gt;, &lt;code&gt;B&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;e&lt;/code&gt;, &lt;code&gt;ge&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;E&lt;/code&gt;, &lt;code&gt;gE&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've used it for some time and finds it works very well.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-02-11T21:29:59.130" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15164" PostTypeId="2" ParentId="15153" CreationDate="2018-02-11T21:42:04.903" Score="1" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5Cv&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\v&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use of &quot;\v&quot; means that in the pattern after it all ASCII characters except '0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\v&lt;/code&gt; is also called &quot;very magic&quot; mode. By adding &lt;code&gt;\v&lt;/code&gt; one may often type regexes with a smaller amount of characters, since one does not need to escape things. As an example, &lt;code&gt;\v(a|b|c)&lt;/code&gt; is equivalent to &lt;code&gt;\(a\|b\|c\)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%40%3C%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\@&amp;lt;=&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Matches with zero width if the preceding atom matches just before what follows.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This can often (but not always) be replaced with &lt;code&gt;\zs&lt;/code&gt;, which is both faster and easier to type. An example, using &lt;code&gt;\v&lt;/code&gt; to reduce the escaping: &lt;code&gt;\v(foo)@&amp;lt;=bar&lt;/code&gt; will match any &lt;code&gt;bar&lt;/code&gt; in &lt;code&gt;foobar&lt;/code&gt;. This is equivalent to &lt;code&gt;foo\zsbar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The regex &lt;code&gt;/\v(A)@&amp;lt;=b+\1&lt;/code&gt; will match any number of &lt;code&gt;b&lt;/code&gt;s followed by an &lt;code&gt;A&lt;/code&gt; as long as it is preceded by an &lt;code&gt;A&lt;/code&gt;, e.g. &lt;code&gt;A[bA]&lt;/code&gt; and &lt;code&gt;A[bbbbbba]&lt;/code&gt;, where &lt;code&gt;[]&lt;/code&gt; denotes the beginning and end of the matched pattern. This specific regex is much better to write as &lt;code&gt;A\zsb\+A&lt;/code&gt;, which will be both faster and is easier to type.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-02-11T21:42:04.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15165" PostTypeId="1" AcceptedAnswerId="15166" CreationDate="2018-02-12T01:54:22.680" Score="6" ViewCount="5556" Body="&lt;p&gt;I have found a vim's short-key list &lt;a href=&quot;https://hea-www.harvard.edu/~fine/Tech/vi.html&quot; rel=&quot;noreferrer&quot;&gt;https://hea-www.harvard.edu/~fine/Tech/vi.html&lt;/a&gt;. But, I don't understand the &lt;code&gt;m&lt;/code&gt; command's role.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uQniG.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uQniG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9498" LastActivityDate="2018-02-12T08:11:17.947" Title="What does vim's m command do?" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15166" PostTypeId="2" ParentId="15165" CreationDate="2018-02-12T08:11:17.947" Score="6" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#m&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h m&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;m{a-zA-Z}     Set mark {a-zA-Z} at cursor position (does not move&#xA;              the cursor, this is not a motion command).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And a little bit under that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;'{a-z}  `{a-z}        Jump to the mark {a-z} in the current buffer.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which means that with &lt;code&gt;mx&lt;/code&gt; (where &lt;code&gt;x&lt;/code&gt; is any letter) you can put a mark on a bufffer, this way you can go back to this place in the buffer whenever you want with &lt;code&gt;'x&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;lower case marks are local to a buffer while upper case marks can reach anyfile&lt;/li&gt;&#xA;&lt;li&gt;You can use &lt;kbd&gt;`x&lt;/kbd&gt; instead of &lt;kbd&gt;'x&lt;/kbd&gt; to reach the column where you put the mark&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:marks&lt;/code&gt; list the current marks&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#mark-motions&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h mark-motions&lt;/code&gt;&lt;/a&gt; is a good place to start with marks.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-02-12T08:11:17.947" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15167" PostTypeId="1" AcceptedAnswerId="15168" CreationDate="2018-02-12T09:05:16.507" Score="0" ViewCount="844" Body="&lt;p&gt;I know that normal mode and command mode is same thing but tells different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iPBJQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iPBJQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this in &lt;a href=&quot;http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_1)&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-&lt;em&gt;Tutorial&lt;/em&gt;(Part_1)&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9498" LastActivityDate="2018-02-12T09:21:58.730" Title="What is the difference between normal mode and command mode in vim?" Tags="|normal-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15168" PostTypeId="2" ParentId="15167" CreationDate="2018-02-12T09:21:58.730" Score="3" Body="&lt;p&gt;&lt;em&gt;command mode&lt;/em&gt; and &lt;em&gt;command-line mode&lt;/em&gt; must not be confused.&#xA;command-line mode is also called &lt;em&gt;ex-mode&lt;/em&gt;.&#xA;You are in command-line mode when you press &lt;code&gt;:&lt;/code&gt; or &lt;code&gt;Q&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-02-12T09:21:58.730" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15170" PostTypeId="1" AcceptedAnswerId="15171" CreationDate="2018-02-12T15:14:18.467" Score="1" ViewCount="613" Body="&lt;p&gt;Is there a way to use &lt;code&gt;:lvimgrep&lt;/code&gt; and to limit the results to one match per file, so that each file with a match only appears once in the location list?&lt;/p&gt;&#xA;" OwnerUserId="3316" LastActivityDate="2018-02-14T11:51:41.980" Title=":lvimgrep with one match per file" Tags="|vimgrep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15171" PostTypeId="2" ParentId="15170" CreationDate="2018-02-12T15:28:57.470" Score="2" Body="&lt;p&gt;According to the &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#:vimgrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;help&lt;/a&gt; you can use &lt;code&gt;:1lvimgrep pattern&lt;/code&gt; to have only a single match per file added to the quickfix list.&#xA;I have never tried that however and so I am not sure how well that works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&#xA;Okay, I have apparently misunderstood the problem as mentioned in the comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there does not seem to exist an easy way to do what you want. That leaves us with those alternatives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use an external grep like tool&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;grep&lt;/code&gt; supports the &lt;code&gt;-l&lt;/code&gt; &lt;a href=&quot;https://www.gnu.org/software/grep/manual/grep.html#General-Output-Control&quot; rel=&quot;nofollow noreferrer&quot;&gt;flag&lt;/a&gt;, which makes it stop on the first match per file. Same is true for &lt;a href=&quot;https://git-scm.com/docs/git-grep#git-grep--l&quot; rel=&quot;nofollow noreferrer&quot;&gt;git-grep&lt;/a&gt;. This has the additional advantage that it might be a lot faster and you  can use standard perl like regexps as this is often a complaint for many users about the &lt;a href=&quot;https://en.wikipedia.org/wiki/Leaning_toothpick_syndrome&quot; rel=&quot;nofollow noreferrer&quot;&gt;leaning toothpick syndrom&lt;/a&gt;. And you can use it with a custom &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27grepprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'grepprg'&lt;/code&gt;&lt;/a&gt; so the result will be available in the quickfixlist.&#xA;However this might be a problem, if you depend on vim like regular expressions, as this will become impossible.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Filter the vimgrep result&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getloclist()&quot; rel=&quot;nofollow noreferrer&quot;&gt;getloclist()&lt;/a&gt; or &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getqflist()&quot; rel=&quot;nofollow noreferrer&quot;&gt;getqflist()&lt;/a&gt; functions to post-process the result from &lt;code&gt;lvimgrep&lt;/code&gt; and only get a single match per file. However, this has the disadvantage, that &lt;code&gt;vimgrep&lt;/code&gt; still processes the complete file (so has no performance benefit if it would stop on the first match) and you will also add additional costs to filter the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FilterLocList()&#xA;  let a=getloclist(0)&#xA;  let file={}&#xA;  let result=[]&#xA;  for entry in a&#xA;    if !has_key(file, entry.bufnr)&#xA;      call add(result, entry)&#xA;      let file[entry.bufnr]=1&#xA;    endif&#xA;  endfor&#xA;  if !empty(result)&#xA;    call setloclist(0, result, 'r')&#xA;  endif&#xA;endfu&#xA;&#xA;com! -nargs=0 FilterLocList :call FilterLocList()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So after doing a &lt;code&gt;:lvimgrep&lt;/code&gt; command, you call &lt;code&gt;:FilterLocList&lt;/code&gt; and the location list for the current window will only contain the first match.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make use of &lt;code&gt;:lnf&lt;/code&gt; and &lt;code&gt;:lpf&lt;/code&gt; commands&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3Alnf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :lnf&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3Alpf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :lpf&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You simply do not care, how many entries the location list has and you jump directly to the next file in the location list using the &lt;code&gt;:lnf&lt;/code&gt; command. You can jump to the previous file using the &lt;code&gt;:lpf&lt;/code&gt; command. Similar commands exist for the quickfix list (&lt;code&gt;:cnf&lt;/code&gt; and &lt;code&gt;:cpf&lt;/code&gt;)&#xA;- Use a custom command&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another alternative would be to create a custom command, that does what you want. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LVimgrepOnce(pattern, argspat)&#xA;  let args=glob(a:argspat, 1, 1)&#xA;  if empty(args)&#xA;    echo &quot;No matching files found&quot;&#xA;    return&#xA;  endif&#xA;  &quot; clear location list&#xA;  lexpr []&#xA;  for file in args&#xA;    try&#xA;      exe &quot;1lvimgrepadd /&quot;. a:pattern. '/j' file&#xA;    catch&#xA;    endtry&#xA;  endfor&#xA;  lopen&#xA;  let w:quickfix_title='vimgrep '. a:pattern. ' '. a:argspat&#xA;endfu&#xA;&#xA;:com! -nargs=+ Lvimgrep :call LVimgrepOnce(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will call a simple &lt;code&gt;:1vimgrepadd&lt;/code&gt; command for each file specified and gather the result in the quickfix list (or more specifically in the location list).&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-02-14T11:51:41.980" LastActivityDate="2018-02-14T11:51:41.980" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15172" PostTypeId="1" AcceptedAnswerId="15173" CreationDate="2018-02-12T16:01:03.307" Score="1" ViewCount="282" Body="&lt;p&gt;I would like to write a buffer which isn't the current buffer to a temp file.  I have found two ways to do this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(assuming buffer 42 is the one to be written)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either use &lt;code&gt;writefile()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call writefile(getbufline(42, 1, '$'), tmpfile)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or switch to the target buffer, use &lt;code&gt;:write&lt;/code&gt;, and switch back again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let current = bufnr('')&#xA;noautocmd buffer 42&#xA;&quot; ... code to store &amp;amp;modified, '[, and '] ...&#xA;execute 'noautocmd keepalt silent write!' tmpfile&#xA;&quot; ... code to restore &amp;amp;modified, '[, and '] ...&#xA;execute 'noautocmd buffer' current&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with &lt;code&gt;writefile()&lt;/code&gt; is that it assumes your line endings are NL.  If they are CRNL you have to insert the CRs yourself.  Either way, you have to assume that all the lines have the same ending – which they really should, but you never know...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with the second is that when you switch away from the current buffer, unknown side-effects might happen.  For example, if the current buffer is a neovim terminal buffer, neovim will close it when you leave it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better approach than either of these?  Is there a better way to implement either of these?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2018-02-12T17:19:04.093" Title="How to write a buffer which isn't the current to a temp file?" Tags="|buffers|save|terminal-buffer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15173" PostTypeId="2" ParentId="15172" CreationDate="2018-02-12T17:07:40.067" Score="1" Body="&lt;p&gt;I don't think you need to worry about mixed line endings. Unless forced by the &lt;code&gt;'fileformats'&lt;/code&gt; setting, Vim opens files containing these as &lt;code&gt;unix&lt;/code&gt;, and lines ending CRLF will just have a CR visible in the buffer. The mixed endings will therefore be preserved when you write out the file with LF endings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(And if &lt;code&gt;'fileformats'&lt;/code&gt; &lt;em&gt;doesn't&lt;/em&gt; contain &lt;code&gt;unix&lt;/code&gt;, then LF endings seem to be converted to CRLF on &lt;em&gt;opening&lt;/em&gt;, so you can't actually have mixed endings if &lt;code&gt;'fileformat'&lt;/code&gt; is set to &lt;code&gt;dos&lt;/code&gt;: therefore writing with CRLFs is correct.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, you can do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let buffer_contents = getbufline(buffer_number, 1, '$')&#xA;&#xA;if (getbufvar(buffer_number, '&amp;amp;fileformat') ==# 'dos')&#xA;  let buffer_contents = map(buffer_contents, 'v:val.&quot;\r&quot;')&#xA;endif&#xA;&#xA;call writefile(buffer_contents, tmpfile)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Credit to &lt;a href=&quot;https://vi.stackexchange.com/questions/15172/how-to-write-a-buffer-which-isnt-the-current-to-a-temp-file/15173#comment25968_15172&quot;&gt;@Mass for the method of accessing the buffer's current &lt;code&gt;'fileformat'&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-12T17:19:04.093" LastActivityDate="2018-02-12T17:19:04.093" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15174" PostTypeId="1" AcceptedAnswerId="15175" CreationDate="2018-02-12T18:08:54.047" Score="3" ViewCount="1666" Body="&lt;p&gt;I am using Debian 9 and am running Vim in Xfce4 Terminal. I would like to print to hardcopy, &lt;code&gt;:ha&lt;/code&gt; or &lt;code&gt;:hardcopy&lt;/code&gt; without printing the header. By default the header has the file name and page number at the top. However, I do not want my pages to have any header information on them.&lt;/p&gt;&#xA;" OwnerUserId="16322" LastActivityDate="2022-05-18T11:25:23.940" Title="Make hardcopy without a header" Tags="|printing|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15175" PostTypeId="2" ParentId="15174" CreationDate="2018-02-12T18:08:54.047" Score="3" Body="&lt;p&gt;This will make the header blank. There has to be a space following the backslash. Otherwise it will print a backslash as the header.&lt;br /&gt;&#xA;&lt;code&gt;:set printheader=\&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16322" LastEditorUserId="16322" LastEditDate="2018-02-15T14:44:23.640" LastActivityDate="2018-02-15T14:44:23.640" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15176" PostTypeId="1" CreationDate="2018-02-12T20:22:52.257" Score="1" ViewCount="65" Body="&lt;p&gt;I would like to play sounds for accessibility reasons. Do I need to patch and compile (neo)vim to provide some sort of &lt;code&gt;OnError&lt;/code&gt; autocmd?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit:&lt;/strong&gt; more generically I'm looking for a way to hook into console dialog so that speech synthesis can be used. &lt;code&gt;confirm()&lt;/code&gt;'s optional &lt;code&gt;{type}&lt;/code&gt; argument could also be of better use by playing an appropriate sound for error,info,warning or generic messages.&lt;/p&gt;&#xA;" OwnerUserId="1027" LastEditorUserId="1027" LastEditDate="2018-02-13T20:50:39.907" LastActivityDate="2018-02-13T20:50:39.907" Title="How does one automatically run a function when any error message appears?" Tags="|autocmd|external-command|error|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15179" PostTypeId="2" ParentId="15113" CreationDate="2018-02-13T02:10:17.633" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Edit: For TypeScript I would recommend trying COC. If you are using JavaScript and COC isn't helping, then Tern might be worth a try.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I have had some success with this plugin: &lt;a href=&quot;https://github.com/ternjs/tern_for_vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ternjs/tern_for_vim&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But it does require some setting up:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;After installing the plugin, you need to &lt;code&gt;cd&lt;/code&gt; into the plugin folder and run &lt;code&gt;npm install&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For each project you work on, you need to create a &lt;code&gt;.tern-project&lt;/code&gt; file.  (See below)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I also tweak some of the plugin's config in Vim:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Don't keep locking up Vim (an issue if the codebase is large)&#xA;let g:tern_show_argument_hints = 'never'&#xA;&#xA;let g:tern_show_signature_in_pum = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I make the &lt;code&gt;K&lt;/code&gt; key use Tern to look up documentation:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost  *.js  nnoremap &amp;lt;buffer&amp;gt; K :TernDoc&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here is an example &lt;code&gt;.tern-project&lt;/code&gt; file you can start from:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  &amp;quot;ecmaVersion&amp;quot;: 7,&#xA;  &amp;quot;libs&amp;quot;: [],&#xA;  &amp;quot;loadEagerly&amp;quot;: [&#xA;    &amp;quot;app.js&amp;quot;,&#xA;    &amp;quot;lib/globals.js&amp;quot;&#xA;  ],&#xA;  &amp;quot;plugins&amp;quot;: {&#xA;    &amp;quot;node&amp;quot;: {&#xA;      &amp;quot;dontLoad&amp;quot;: &amp;quot;&amp;quot;,&#xA;      &amp;quot;load&amp;quot;: &amp;quot;&amp;quot;,&#xA;      &amp;quot;modules&amp;quot;: &amp;quot;&amp;quot;&#xA;    },&#xA;    &amp;quot;node_resolve&amp;quot;: {},&#xA;    &amp;quot;modules&amp;quot;: {&#xA;      &amp;quot;dontLoad&amp;quot;: &amp;quot;&amp;quot;,&#xA;      &amp;quot;load&amp;quot;: &amp;quot;&amp;quot;,&#xA;      &amp;quot;modules&amp;quot;: &amp;quot;&amp;quot;&#xA;    },&#xA;    &amp;quot;commonjs&amp;quot;: {},&#xA;    &amp;quot;doc_comment&amp;quot;: {}&#xA;  },&#xA;  &amp;quot;dependencyBudget&amp;quot;: 2000&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The dependencyBudget will stop waiting for a response if Tern cannot provide one quickly.  But I have found that the server will continue loading scripts and inferring in the background, so you can wait a while and then try the completion again.&lt;/p&gt;&#xA;&lt;p&gt;(I have completion on Tab but I can't see where that was configured!)&lt;/p&gt;&#xA;&lt;p&gt;There are some &lt;a href=&quot;https://github.com/ternjs/tern/issues/759&quot; rel=&quot;nofollow noreferrer&quot;&gt;more examples of &lt;code&gt;.tern-project&lt;/code&gt; files here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2020-12-14T14:56:57.007" LastActivityDate="2020-12-14T14:56:57.007" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="15180" PostTypeId="1" CreationDate="2018-02-13T03:36:56.280" Score="0" ViewCount="416" Body="&lt;p&gt;I want to have a vim register that pastes :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;&#xA;#include &amp;lt;string&amp;gt;&#xA;#define 1e9 + 7&#xA;typedef long long ll;&#xA;using namespace std;&#xA;int main(int argc, char ** argv){&#xA;&#xA;return 0;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I write this in .vimrc ahead of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a = '...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have write it all in a single line. How do I specify the newlines after each include directive.&lt;/p&gt;&#xA;" OwnerUserId="16325" LastActivityDate="2018-04-14T12:33:38.513" Title="Competitive coding template in vim macro" Tags="|vimrc|vimscript|macro|filetype-c++|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15181" PostTypeId="2" ParentId="15180" CreationDate="2018-02-13T04:51:06.650" Score="1" Body="&lt;p&gt;This isn't exactly what you asked for, but I think it may be a &quot;better&quot; solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap cct :-1read $HOME/.vim/cct.c&amp;lt;CR&amp;gt;6ji&amp;lt;Tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing in &lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt; in Normal mode will paste in the contents from&#xA;&lt;code&gt;$HOME/.vim/cct.c&lt;/code&gt;, which would contain the template you want. Then, &lt;code&gt;6ji&amp;lt;Tab&amp;gt;&lt;/code&gt; moves&#xA;you to inside the &lt;code&gt;main&lt;/code&gt; function, puts you in Insert mode and adds an indent to start you off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can of course change the shortcut to your leader key plus something or anything else really. I think this is probably better and more easily updated than putting the whole template directly in your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16326" LastEditorUserId="16326" LastEditDate="2018-02-13T04:56:38.073" LastActivityDate="2018-02-13T04:56:38.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15182" PostTypeId="1" AcceptedAnswerId="15190" CreationDate="2018-02-13T07:06:00.617" Score="7" ViewCount="2186" Body="&lt;p&gt;&lt;strong&gt;Note: this question is specific to the relatively new Ubuntu Bash on Windows system.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it seems possible to paste into Vim from the Windows clipboard by simply right clicking in insert mode after enabling the Quick Edit Mode option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But has anyone figured out how to paste into Windows something that was copied using Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried using the &lt;code&gt;&quot;*&lt;/code&gt; and &lt;code&gt;&quot;+&lt;/code&gt; registers, but it seems as though they aren't even present. I ran &lt;code&gt;:reg&lt;/code&gt; and only saw the &lt;code&gt;&quot;&quot;&lt;/code&gt;, &lt;code&gt;&quot;0&lt;/code&gt;, &lt;code&gt;&quot;.&lt;/code&gt;, &lt;code&gt;&quot;:&lt;/code&gt;, &lt;code&gt;&quot;/&lt;/code&gt; registers. Are other people at least seeing the registers? Or is it just me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, my version of Vim has the &lt;code&gt;+clipboard&lt;/code&gt; and &lt;code&gt;+xterm_clipboard&lt;/code&gt; features installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I can do is use the mouse, select text in vim, then right click to copy, then paste like normal in Windows. But I'd really rather just &lt;code&gt;yank&lt;/code&gt; items in Vim into the Windows clipboard.&lt;/p&gt;&#xA;" OwnerUserId="13078" LastEditorUserId="1841" LastEditDate="2018-10-09T14:37:56.397" LastActivityDate="2023-05-23T23:04:33.493" Title="Copying From Vim to Ubuntu Bash on Windows" Tags="|microsoft-windows|os-clipboard|linux-ubuntu|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15183" PostTypeId="1" AcceptedAnswerId="15184" CreationDate="2018-02-13T07:58:40.440" Score="2" ViewCount="322" Body="&lt;p&gt;Let's say I have ordered TODO list with priorities, sorted already with &lt;code&gt;:sort n&lt;/code&gt; similar to :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. shopping&#xA;3. cooking.&#xA;D 5. car repair.&#xA;D 11. tap fix.&#xA;12. project start&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;D&lt;/code&gt; means done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;code&gt;:sort n&lt;/code&gt; function to sort this list, but all done (&lt;code&gt;D&lt;/code&gt;) things should go at the end of list. Result should be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. shopping&#xA;3. cooking&#xA;12. project start. &#xA;D 5. car repair. &#xA;D 11. tap fix.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to do that?&lt;/p&gt;&#xA;" OwnerUserId="16328" LastEditorUserId="1841" LastEditDate="2018-02-13T09:10:53.633" LastActivityDate="2018-02-13T09:43:39.990" Title="Sorted TODO list with :sort n and letters" Tags="|sort|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15184" PostTypeId="2" ParentId="15183" CreationDate="2018-02-13T08:34:00.267" Score="3" Body="&lt;p&gt;Try adding this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;td :sort n&amp;lt;CR&amp;gt;:sort n /[D]/&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in Normal mode, you can type &lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; (assuming you haven't changed the default leader key to something else) to sort your to-do list.&lt;/p&gt;&#xA;" OwnerUserId="16326" LastActivityDate="2018-02-13T08:34:00.267" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15185" PostTypeId="2" ParentId="15183" CreationDate="2018-02-13T09:43:39.990" Score="3" Body="&lt;p&gt;If your list is already sorted with &lt;code&gt;:sort n&lt;/code&gt;, you can move the done &lt;code&gt;D&lt;/code&gt; items to the bottom of the list with a global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^D/m$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works through the file from top to bottom, moving each line that starts with a D. Because the &lt;code&gt;D&lt;/code&gt; lines are already sorted when you run the command, they remain sorted after it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to perform both steps in a single go, you could use a mapping similar to the one &lt;a href=&quot;https://vi.stackexchange.com/a/15184/343&quot;&gt;suggested by Kevin&lt;/a&gt; or perhaps a custom command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Run this command with :TodoSort&#xA;:command! TodoSort sort n | g/^D/m$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-13T09:43:39.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15186" PostTypeId="2" ParentId="363" CreationDate="2018-02-13T10:29:38.877" Score="6" Body="&lt;p&gt;I've created the command-line tool &lt;a href=&quot;https://github.com/nschloe/tablign&quot; rel=&quot;noreferrer&quot;&gt;tablign&lt;/a&gt; for this purpose; it works from within vim as well. Simply install with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[sudo -H] pip3 install tablign&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;mark the table in vim and call&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;:!tablign&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(vim fills in the first few characters for you if you've marked the table.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can't do fixed column widths yet, but that could be added if need arises.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3RVab.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3RVab.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13710" LastEditorUserId="13710" LastEditDate="2018-12-26T13:39:16.253" LastActivityDate="2018-12-26T13:39:16.253" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15187" PostTypeId="2" ParentId="15180" CreationDate="2018-02-13T11:25:12.770" Score="0" Body="&lt;p&gt;I'm presuming (because you used the &lt;a href=&quot;https://vi.stackexchange.com/questions/tagged/macro&quot;&gt;[macro]&lt;/a&gt; tag) that you want to set the &lt;code&gt;&quot;a&lt;/code&gt; register to be a macro, that, when played back, inserts the provided lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to do that is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a = &quot;o&quot;&#xA;      \. &quot;#include &amp;lt;iostream&amp;gt;\r&quot;&#xA;      \. &quot;#include &amp;lt;string&amp;gt;\r&quot;&#xA;      \. &quot;#define 1e9 + 7\r&quot;&#xA;      \. &quot;typedef long long ll;\r&quot;&#xA;      \. &quot;using namespace std;\r&quot;&#xA;      \. &quot;int main(int argc, char ** argv){\r&quot;&#xA;      \. &quot;\r&quot;&#xA;      \. &quot;return 0;}\&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\&lt;/code&gt; line continuations and &lt;code&gt;.&lt;/code&gt; concatenations aren't strictly necessary. You could include the whole lot in a single string, but this will look neater in your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think I'd actually use this myself, though. It would be cleaner to set up a mapping or command to do this, to use &lt;a href=&quot;https://vi.stackexchange.com/a/15181/343&quot;&gt;Kevin's solution&lt;/a&gt;, or to look into the several &lt;a href=&quot;https://www.google.co.uk/search?q=vim+snippet&quot; rel=&quot;nofollow noreferrer&quot;&gt;snippet plugins&lt;/a&gt; that provide this feature in a more flexible way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you actually just want the register to contain the text so that you can &lt;code&gt;put&lt;/code&gt; it with commands such as &lt;code&gt;&quot;ap&lt;/code&gt;, you need to alter the code slightly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a = &quot;#include &amp;lt;iostream&amp;gt;\n&quot;&#xA;      \. &quot;#include &amp;lt;string&amp;gt;\n&quot;&#xA;      \. &quot;#define 1e9 + 7\n&quot;&#xA;      \. &quot;typedef long long ll;\n&quot;&#xA;      \. &quot;using namespace std;\n&quot;&#xA;      \. &quot;int main(int argc, char ** argv){\n&quot;&#xA;      \. &quot;\n&quot;&#xA;      \. &quot;return 0;}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-13T11:33:32.303" LastActivityDate="2018-02-13T11:33:32.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15189" PostTypeId="1" CreationDate="2018-02-13T15:38:20.463" Score="2" ViewCount="1542" Body="&lt;h1&gt;Description&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I have a problem with weird unknown symbols in the fileformat placement and encoding sections.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Environment&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vim: 7.4.1689 &lt;/li&gt;&#xA;&lt;li&gt;vim-airline: 0.9&lt;/li&gt;&#xA;&lt;li&gt;OS: Ubuntu 16.04&lt;/li&gt;&#xA;&lt;li&gt;Reproduced with a minimal vimrc: yes&lt;/li&gt;&#xA;&lt;li&gt;vimrc config &lt;a href=&quot;http://freetexthost.com/iplxmcqls4&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Tested on terminals: xfce4-terminal, pantheon-terminal, gnome-terminal, xterm&lt;/li&gt;&#xA;&lt;li&gt;$TERM variable: xterm-256color&lt;/li&gt;&#xA;&lt;li&gt;color configuration (:set t_Co?): t_Co=256&lt;/li&gt;&#xA;&lt;li&gt;am i using Neovim: No&lt;/li&gt;&#xA;&lt;li&gt;does it happen in Vim: Yes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is screenshot without &lt;code&gt;let g:airline_powerline_fonts = 1&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt; , i've commented it.&#xA;&lt;img src=&quot;https://user-images.githubusercontent.com/10868371/35854271-93631c7e-0b38-11e8-9b1c-2bfe4fdf9151.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I want to NOTICE, these symbols are not undisplayed arrow symbols, because i see it in normal, font-enabled mode too&lt;/strong&gt;&#xA;&lt;img src=&quot;https://user-images.githubusercontent.com/10868371/35855077-d5d1c2fc-0b3a-11e8-86ad-a278b540d928.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to edit&#xA;&lt;code&gt;let g:airline_section_y (fileencoding, fileformat)&lt;/code&gt; from &lt;a href=&quot;https://github.com/vim-airline/vim-airline/blob/master/doc/airline.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;doc/airline.txt&lt;/a&gt;&#xA;by inserting&#xA;&lt;code&gt;let g:airline_section_y = 'NOT_HERE'&lt;/code&gt; into the .vimrc, but it gave me only this&#xA;&lt;img src=&quot;https://user-images.githubusercontent.com/10868371/35859727-da82c7c4-0b49-11e8-8ddf-73484f99e26c.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:airline_section_x = 'NOT_HERE'&lt;/code&gt; X section - the same nothing&#xA;&lt;img src=&quot;https://user-images.githubusercontent.com/10868371/35860607-602c3fa6-0b4d-11e8-9293-44fa64808bf4.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qpTzT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qpTzT.png&quot; alt=&quot;Same with nerd tree&quot;&gt;&lt;/a&gt;&#xA;There are no icons for file list at all. You can check my vimrc config &lt;a href=&quot;http://freetexthost.com/iplxmcqls4&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;XTerm&lt;/em&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/eb9ck.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eb9ck.png&quot; alt=&quot; &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For the test, I even deployed vim in docker, latest ubuntu&lt;/li&gt;&#xA;&lt;li&gt;I disabled ALL plugins by PlugClean (vundle), and i still see this symbols&lt;/li&gt;&#xA;&lt;li&gt;Fonts: &lt;a href=&quot;https://github.com/powerline/fonts&quot; rel=&quot;nofollow noreferrer&quot;&gt;powerline fonts&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:echo &quot;\ue0b2&quot;&lt;/code&gt; Prints left arrow&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Please, tell me how can i remove them? Or what is this?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="16331" LastEditorUserId="16331" LastEditDate="2018-02-13T15:45:56.793" LastActivityDate="2018-02-21T10:11:29.683" Title="Unknown symbols in vim near filename and filetype" Tags="|plugin-airline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15190" PostTypeId="2" ParentId="15182" CreationDate="2018-02-13T18:31:37.313" Score="11" Body="&lt;p&gt;Thank you to @Christian Brabandt for linking this in the comments: &lt;a href=&quot;https://www.reddit.com/r/vim/comments/7pmv3d/workflows_that_work/dskyram/&quot; rel=&quot;noreferrer&quot;&gt;https://www.reddit.com/r/vim/comments/7pmv3d/workflows_that_work/dskyram/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Works great. Just put the following in your vimrc and make sure to have vim version &gt;= 8.0.1394&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; WSL yank support&#xA;let s:clip = '/mnt/c/Windows/System32/clip.exe'  &quot; default location&#xA;if executable(s:clip)&#xA;    augroup WSLYank&#xA;        autocmd!&#xA;        autocmd TextYankPost * call system('echo '.shellescape(join(v:event.regcontents, &quot;\&amp;lt;CR&amp;gt;&quot;)).' | '.s:clip)&#xA;    augroup END&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13078" LastActivityDate="2018-02-13T18:31:37.313" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15191" PostTypeId="1" AcceptedAnswerId="15283" CreationDate="2018-02-13T20:29:23.300" Score="5" ViewCount="284" Body="&lt;p&gt;Using the &lt;code&gt;backup&lt;/code&gt; option, I'd like vim to keep the backup of a file until that file is closed, instead of overwriting the backup every time the file is saved. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want Vim to do that because I often find myself wishing that I could see a file as it was at the beginning of the editing session (for files that I don't want to keep under version control).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: the backup should become a copy of the file as the file was when I last saved it before closing. That is, if I edit a file and quit without saving, the backup should not be written.&lt;/p&gt;&#xA;" OwnerUserId="16012" LastEditorUserId="16012" LastEditDate="2018-02-20T12:18:21.863" LastActivityDate="2018-02-26T15:16:38.527" Title="Make backup only once per session, when I close a file" Tags="|vimrc|backup|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="15192" PostTypeId="1" AcceptedAnswerId="15195" CreationDate="2018-02-13T21:02:13.173" Score="2" ViewCount="165" Body="&lt;p&gt;I am experiencing a problem for which I have no idea where I can start the search to solve it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I go into insert mode and start writing something and then quit insert mode with &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; and then use &lt;code&gt;k&lt;/code&gt; to go up a line, the cursor indeed moves up, but leaves a &lt;em&gt;highlighted&lt;/em&gt; &lt;code&gt;q&lt;/code&gt; where I inserted the last letter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When being in normal mode and I use &lt;code&gt;r&lt;/code&gt; to overwrite text, the letter below the cursor immediatly turns into a highlighted &lt;code&gt;q&lt;/code&gt; and moves to the right. When I then press any key, the letter below the cursor is again turned into a highlighted &lt;code&gt;q&lt;/code&gt; and the cursor move right again. From then on, all sorts of strange things happen, like jumping one line up etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Except of that, vim seems to behave normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to give more information on that, but I have no idea what could be interesting for this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the same &lt;code&gt;.vimrc&lt;/code&gt; files as in other installations where I don't have this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly, when I write a file with such highlighted &lt;code&gt;q&lt;/code&gt;s and then go to the shell and &lt;code&gt;cat&lt;/code&gt; such a file, the text is as I typed it.&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="51" LastEditDate="2018-08-22T16:57:04.843" LastActivityDate="2018-08-22T16:57:04.843" Title="&lt;esc&gt;k inserts `q`, r inserts two qs" Tags="|terminal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15193" PostTypeId="1" CreationDate="2018-02-13T21:37:02.573" Score="3" ViewCount="2215" Body="&lt;p&gt;Bascially, I want to increase the space between line number and code. Other line number plugin is also acceptable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YAe6J.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YAe6J.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GpHIk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GpHIk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16335" LastEditorUserId="1841" LastEditDate="2018-02-13T22:08:31.593" LastActivityDate="2023-01-31T17:26:12.063" Title="How can I have more space between line number and code?" Tags="|line-numbers|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15194" PostTypeId="1" CreationDate="2018-02-13T21:45:06.283" Score="0" ViewCount="740" Body="&lt;p&gt;I have recently recompiled vim, and ever since, when I have a big file, the scrolling gets slow. &lt;code&gt;cursorline&lt;/code&gt; seems to be the problem; it doesn't matter if I use any of my plugins, if I have &lt;code&gt;cursorline&lt;/code&gt; on, then the redrawing (and thus, the scrolling) gets slower, and the syntax highlight, while on its own inoffensive, when combined with &lt;code&gt;cursorline&lt;/code&gt; makes the redrawing process &lt;em&gt;very&lt;/em&gt; slow. Pretty much all of the solutions I have seen to this problem include either removing the syntax highlight or the &lt;code&gt;cursorline&lt;/code&gt;; however, I was wondering if it would be possible to solve this some way. I have also already tried using &lt;code&gt;set lazyredraw&lt;/code&gt;, &lt;code&gt;set ttyfast&lt;/code&gt;, &lt;code&gt;set foldmethod=manual&lt;/code&gt; and &lt;code&gt;set synmaxcol=128&lt;/code&gt;, with no better results. Does anybody have more ideas?&lt;/p&gt;&#xA;" OwnerUserId="1806" LastActivityDate="2018-02-14T07:58:50.023" Title="Cursorline/Columnline slowdown" Tags="|syntax-highlighting|scrolling|cursorline|redraw|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15195" PostTypeId="2" ParentId="15192" CreationDate="2018-02-13T22:27:39.230" Score="4" Body="&lt;p&gt;It seems your issue comes from setting some terminal options, with sequences to change the shape of the cursor, in a terminal/console which doesn't support them. See &lt;code&gt;:h terminal-options&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change the shape of the cursor by sending the right sequence to the &lt;code&gt;xterm&lt;/code&gt; terminal (and others which support it too), sometimes called &lt;code&gt;DECSCUSR&lt;/code&gt;.&#xA;Not sure what the acronym means. Just a guess (no idea what the final R means):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Digital Equipment Corporation Set CUrsor Style&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The general syntax of the sequence is described &lt;a href=&quot;http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Functions-using-CSI-_-ordered-by-the-final-character_s_&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CSI Ps SP q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;CSI&lt;/code&gt; means &lt;code&gt;Control Sequence Introducer&lt;/code&gt;, and is produced by the keys &lt;code&gt;Esc [&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Ps&lt;/code&gt; is a single numeric parameter&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;SP&lt;/code&gt; is a space&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For example, to change the shape of the cursor to an underline, you can send the sequence &lt;code&gt;Esc[4 q&lt;/code&gt; to the terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ printf '\e[4 q'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use this to change the shape of the cursor depending on the current mode.&#xA;For example, Vim automatically sends the sequence stored in the terminal option &lt;code&gt;t_SR&lt;/code&gt; when you enter replace mode (see &lt;code&gt;:h t_SR&lt;/code&gt;). So, if you wanted the cursor to go from a block to an underline when you enter replace mode, you could set &lt;code&gt;t_SR&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;t_SR = &quot;\e[4 q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, when you leave replace mode (or insert mode), Vim sends the sequence assigned to the option &lt;code&gt;t_EI&lt;/code&gt; (see &lt;code&gt;:h t_EI&lt;/code&gt;). You can use this to restore the shape of the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;t_EI = &quot;\e[2 q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some &lt;a href=&quot;https://github.com/jszakmeister/vim-togglecursor&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugins&lt;/a&gt; do this configuration automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for the configuration to work, you must be sure that the terminal understands/supports those sequences.&#xA;I don't know a reliable way to programmatically detect whether a terminal supports a given sequence.&#xA;I guess you have to make the experiment to be sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, on my machine, &lt;code&gt;printf '\e[4 q'&lt;/code&gt; works in &lt;code&gt;urxvt&lt;/code&gt; but not in &lt;code&gt;xfce4-terminal&lt;/code&gt;. So I know that I shouldn't set a terminal option (&lt;code&gt;t_xx&lt;/code&gt;) with the sequence &lt;code&gt;&quot;\e[4 q&quot;&lt;/code&gt; in &lt;code&gt;xfce4-terminal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to wrap your settings with the right guard, whose purpose is to guess the identity of the terminal.&#xA;Usually this involves looking at some shell environment variables, the most important one being &lt;code&gt;$TERM&lt;/code&gt;.&#xA;As an example, you could try something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !has('gui_running') &amp;amp;&amp;amp; $TERM =~# '^\%(name1\|name2\|…\)'&#xA;    &quot; write your settings here&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace &lt;code&gt;name1&lt;/code&gt;, &lt;code&gt;name2&lt;/code&gt;, … with the names of the terminals you're using (as reported by &lt;code&gt;echo $TERM&lt;/code&gt;), and for which you know the sequences are supported.&lt;/p&gt;&#xA;" OwnerUserId="15612" LastEditorUserId="15612" LastEditDate="2018-02-14T02:46:38.970" LastActivityDate="2018-02-14T02:46:38.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15196" PostTypeId="1" AcceptedAnswerId="15197" CreationDate="2018-02-14T00:00:18.940" Score="2" ViewCount="404" Body="&lt;p&gt;In order to parse certain log file and make a plot of sequential numbers, I need to filter out the lines with numbers which appearing lower than in the previous lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, given the list of lines with integers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;62&#xA;116&#xA;33&#xA;20&#xA;61&#xA;67&#xA;89&#xA;82&#xA;15&#xA;109&#xA;73&#xA;101&#xA;115&#xA;120&#xA;41&#xA;103&#xA;94&#xA;122&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: File can be generated by &lt;code&gt;hexdump -n100 -e '1/1 &quot;%d&quot; &quot;\n&quot;' /dev/urandom | grep -v ^-&lt;/code&gt;.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to filter out (remove) the numbers that way, so all of them are sequential (so they look kind of sorted).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally if the command will take into the account all the previous lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my expected results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;62&#xA;116&#xA;120&#xA;122&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the command won't filter correctly after first time, I can always re-run it couple of times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my attempt based on this &lt;a href=&quot;https://vi.stackexchange.com/a/4821/467&quot;&gt;post&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/ if getline(line('.')-1) &amp;lt; getline('.') | delete | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it removes all the lines instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How I should correct my command? Or what other approach I could use?&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="467" LastEditDate="2018-02-14T00:07:27.700" LastActivityDate="2018-02-14T15:15:16.710" Title="How to remove lines which have lower numbers than before, and keep only the sequential?" Tags="|vimscript|substitute|global-command|multiple-lines|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15197" PostTypeId="2" ParentId="15196" CreationDate="2018-02-14T00:27:59.767" Score="3" Body="&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, you could do it with a single global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^/if str2nr(getline('.')) &amp;lt;= str2nr(getline(line('.')-1)) | d_ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Old answer&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe you could try these 2 global commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/if str2nr(getline('.')) &amp;lt;= str2nr(getline(search('[^x]$', 'bnW'))) | s/$/x/ | endif&#xA;:g/x$/d_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one should append an &lt;code&gt;x&lt;/code&gt; at the end of any line which breaks the progression of the numbers to mark it for future deletion. While the second one should delete all the marked lines.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The purpose of &lt;code&gt;str2nr()&lt;/code&gt; is to convert the strings into numbers. It matters, among other things, to prevent Vim from performing an octal conversion if the number begins with a &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for &lt;code&gt;search()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;search('[^x]$', 'bnW')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Its purpose is to find the previous line which doesn't end with an &lt;code&gt;x&lt;/code&gt;, and return its address so that &lt;code&gt;getline()&lt;/code&gt; can grab its text contents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're sure that your lines contain only digits, you could modify the invocation of &lt;code&gt;search()&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;search('^\d\+$', 'bnW')&#xA;                  │││    &#xA;                  ││└ don't wrap around the end/beginning of the file&#xA;                  │└ don't move the cursor&#xA;                  └ look backward&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you think your text may originally contain some &lt;code&gt;x&lt;/code&gt;s, then you could use another less frequent character, such as &lt;code&gt;C-a&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/if str2nr(getline('.')) &amp;lt;= str2nr(getline(search('^\d\+$', 'bnW'))) | s/$/\=&quot;\&amp;lt;c-a&amp;gt;&quot;/ | endif&#xA;:g/\%x01$/d_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15612" LastEditorUserId="15612" LastEditDate="2018-02-14T04:48:34.227" LastActivityDate="2018-02-14T04:48:34.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15199" PostTypeId="2" ParentId="14239" CreationDate="2018-02-14T01:51:40.990" Score="3" Body="&lt;p&gt;Although not pretty sure, I guess you are on a x64 platform. The corresponding path is under /usr/lib64/pythonXX.&lt;/p&gt;&#xA;" OwnerUserId="16340" LastActivityDate="2018-02-14T01:51:40.990" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15200" PostTypeId="1" AcceptedAnswerId="15202" CreationDate="2018-02-14T02:53:10.323" Score="2" ViewCount="756" Body="&lt;p&gt;I would like to use ctrl-k and ctrl-j to not only move the cursor up or down (by lines), but also to scroll the portion of the document that is visible.  Effectively, leave the cursor where it is and move the document past it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can accomplish this for the most part using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;c-j&amp;gt; j&amp;lt;c-e&amp;gt;&#xA;:nnoremap &amp;lt;c-k&amp;gt; k&amp;lt;c-y&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this has two issues:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Minor issue: when the cursor is at the bottom visible line (&lt;code&gt;L&lt;/code&gt;) or the top visible line (&lt;code&gt;H&lt;/code&gt;), then an extra line is shown by ctrl-j and ctrl-k respectively (undesirable behavior).&lt;/li&gt;&#xA;&lt;li&gt;Major issue: this shortcut doesn't work with counts.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How can I improve on my solution to avoid these issues?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2018-02-14T10:59:34.837" Title="Make ctrl-j and ctrl-k work like they do in less?" Tags="|key-bindings|cursor-movement|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15201" PostTypeId="2" ParentId="9967" CreationDate="2018-02-14T05:13:40.753" Score="1" Body="&lt;p&gt;If you want to close NERDTree window make sure you are inside the NERDTree menu. You can switch windows by using &lt;code&gt;ctrl+w&lt;/code&gt; then type &lt;code&gt;:q&lt;/code&gt; to close NERDTree window so that you will be left with the window for editing your code.&lt;/p&gt;&#xA;" OwnerUserId="14699" LastActivityDate="2018-02-14T05:13:40.753" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15202" PostTypeId="2" ParentId="15200" CreationDate="2018-02-14T05:42:01.403" Score="4" Body="&lt;p&gt;I was able to solve the first issue using a bit of logic in the mapping so that the &lt;code&gt;j&lt;/code&gt;/&lt;code&gt;k&lt;/code&gt; is emitted after &lt;code&gt;&amp;lt;c-e&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;c-y&amp;gt;&lt;/code&gt; if the current line is the bottom/top line of the window...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-j&amp;gt; winline() == winheight(0) ? &quot;\&amp;lt;c-e&amp;gt;j&quot; : &quot;j\&amp;lt;c-e&amp;gt;&quot;&#xA;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-k&amp;gt; winline() == 1 ? &quot;\&amp;lt;c-y&amp;gt;k&quot; : &quot;k\&amp;lt;c-y&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the count, you can create user commands that accept counts. Should be able to combine above with that. See &lt;code&gt;:h usr_40.txt&lt;/code&gt; and &lt;code&gt;:h user-commands&lt;/code&gt;. (I'd help but must depart for a while.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Actually, thanks to &lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;@ChristianBrabandt&lt;/a&gt; we have &lt;a href=&quot;https://vi.stackexchange.com/questions/15200/make-ctrl-j-and-ctrl-k-work-like-they-do-in-less/15202?noredirect=1#comment26009_15202&quot;&gt;a better, easier approach to handling counts&lt;/a&gt; which is to use the read-only Vim variable &lt;code&gt;v:count1&lt;/code&gt;. This contains the count given for the last Normal command and it works with mappings. (There is also a &lt;code&gt;v:count&lt;/code&gt; which is almost the same thing but &lt;code&gt;v:count1&lt;/code&gt; will contain default value 1 if no count was entered.) So that gives us:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-j&amp;gt; winline() == winheight(0) ? &quot;\&amp;lt;c-e&amp;gt;&quot;.v:count1.&quot;j&quot; : &quot;j&quot;.v:count1.&quot;\&amp;lt;c-e&amp;gt;&quot;&#xA;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-k&amp;gt; winline() == 1 ? &quot;\&amp;lt;c-y&amp;gt;&quot;.v:count1.&quot;k&quot; : &quot;k&quot;.v:count1.&quot;\&amp;lt;c-y&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(We only prepend the count to the second motion as the first gets the count implicitly.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-02-14T10:59:34.837" LastActivityDate="2018-02-14T10:59:34.837" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="15203" PostTypeId="2" ParentId="15194" CreationDate="2018-02-14T07:58:50.023" Score="2" Body="&lt;p&gt;As @Christian Brabandt pointed out in the comment this is &lt;a href=&quot;https://github.com/vim/vim/issues/2584&quot; rel=&quot;nofollow noreferrer&quot;&gt;a known issue&lt;/a&gt; and there might not be a lot of solutions, for now, to make &lt;code&gt;cursorline&lt;/code&gt; work properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can use different workarounds:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;In &lt;a href=&quot;https://vi.stackexchange.com/questions/3480/viml-sleep-within-a-function/3481#3481&quot;&gt;this answer&lt;/a&gt; @Carpetsmoker suggest a mapping which will set &lt;code&gt;cursorline&lt;/code&gt; and &lt;code&gt;cursorcolumn&lt;/code&gt; for a fraction of a second. This is pretty useful to easily locate your cursor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I also created &lt;a href=&quot;https://github.com/statox/gutterline.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;gutterline.vim&lt;/a&gt; which is a plugin which simply adds a sign in the gutter where your cursor is it was meant to be as simple as possible and the result is something like this:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n9Cja.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n9Cja.png&quot; alt=&quot;gutterline screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-02-14T07:58:50.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15204" PostTypeId="1" AcceptedAnswerId="15236" CreationDate="2018-02-14T10:15:04.463" Score="3" ViewCount="8357" Body="&lt;p&gt;Let's say there is a file &lt;code&gt;\\server-42\tmp\dir\test.txt&lt;/code&gt;.  When my plugin tries to execute this command via &lt;code&gt;system()&lt;/code&gt; it triggers an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd &quot;\\server-42\tmp\dir&quot; &amp;amp;&amp;amp; git ls-files --error-unmatch --full-name test.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error is &lt;code&gt;E484: Can't open file C:\Users\foo\AppData\Local\Temp\blah.tmp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The directory is produced by &lt;code&gt;shellescape(fnamemodify(filepath, ':h')&lt;/code&gt;, where &lt;code&gt;filepath&lt;/code&gt; is the full path to file.  The file is produced by &lt;code&gt;shellescape(fnamemodify(filepath, ':t')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get this to work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2018-02-16T22:12:11.823" Title="What is the correct way to escape UNC paths?" Tags="|vimscript|external-command|microsoft-windows|filesystem|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15205" PostTypeId="1" CreationDate="2018-02-14T12:07:19.053" Score="1" ViewCount="565" Body="&lt;p&gt;I want to create a function to copy VHDL component.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can get the component start and end line number as returned value from other functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But don't know how to use the returns to copy the component inside a function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! VHDL_Yank_Component()  &#xA;   let current_line = line('.')  &#xA;   let component_start  = VHDL_Find_Component_Start()  &#xA;   let component_end    = VHDL_Find_Component_End()  &#xA;   if (component_start != -1) &amp;amp;&amp;amp; (component_end != -1)  &#xA;      normal &quot;:&quot;.component_start&quot;,&quot;.component_end&quot;Y&quot;&#xA;      echo &quot;Component copied&quot;    &#xA;   else  &#xA;      normal :.current_line&amp;lt;CR&amp;gt;  &#xA;      echo &quot;Can't find valid component to copy&quot;  &#xA;   endif  &#xA;endfunction   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-02-14T14:05:40.783" Title="How to use function returns?" Tags="|functions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15207" PostTypeId="2" ParentId="15205" CreationDate="2018-02-14T14:05:40.783" Score="2" Body="&lt;p&gt;Below is fixed code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! VHDL_Yank_Component()  &#xA;   let current_line = line('.')  &#xA;   let component_start = VHDL_Find_Component_Start()  &#xA;&#xA;   if (component_start == -1)  &#xA;      exe &quot;:&quot;.current_line  &#xA;      echo &quot;Can't find valid component start.&quot;  &#xA;      return -1  &#xA;   endif  &#xA;&#xA;   let component_end = VHDL_Find_Component_End()  &#xA;   if (component_end ==  -1) || (component_start &amp;gt; component_end)  &#xA;      exe &quot;:&quot;.current_line  &#xA;      echo &quot;Can't find valid component end.&quot;  &#xA;      return -1  &#xA;   endif  &#xA;&#xA;   if (component_start != -1) &amp;amp;&amp;amp; (component_end != -1)  &#xA;      exe &quot;:&quot;.component_start.&quot;,&quot;.component_end.&quot;y&quot;  &#xA;      echo &quot;Component copied: &quot; .g:component_name  &#xA;   else  &#xA;      exe &quot;:&quot;.current_line  &#xA;      echo &quot;Can't find valid component to copy&quot;  &#xA;      return -1  &#xA;   endif  &#xA;endfunction   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-02-14T14:05:40.783" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15208" PostTypeId="2" ParentId="15196" CreationDate="2018-02-14T15:15:16.710" Score="3" Body="&lt;p&gt;This feels like a job for awk:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ awk '$1 &amp;gt; x {x = $1;print}' in_file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or using filter, &lt;code&gt;:[range]!&lt;/code&gt;, inside of Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!awk '$1 &amp;gt; x {x = $1;print}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :range!&#xA;:h :range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-02-14T15:15:16.710" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15209" PostTypeId="1" AcceptedAnswerId="15210" CreationDate="2018-02-14T21:17:50.123" Score="0" ViewCount="463" Body="&lt;p&gt;I added &lt;code&gt;set hlsearch&lt;/code&gt; to highlight my searches which is helpful. And I can turn it off by using &lt;code&gt;:nohlsearch&lt;/code&gt; or remapping that to a key. But when I tried to use it on &lt;code&gt;CursorHold&lt;/code&gt; event, it doesn't work. Other commands work on &lt;code&gt;CursorHold&lt;/code&gt; but not for &lt;code&gt;nohl&lt;/code&gt; or &lt;code&gt;nohlsearch&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CursorHold on my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;clear highlight search every 1sec&#xA;set updatetime=1000&#xA;autocmd CursorHold * exec &quot;noh&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16343" LastActivityDate="2018-02-14T21:53:10.383" Title="CursorHold event not working on nohlsearch" Tags="|search|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15210" PostTypeId="2" ParentId="15209" CreationDate="2018-02-14T21:53:10.383" Score="2" Body="&lt;p&gt;Please note, that your &lt;code&gt;:exe &quot;noh&quot;&lt;/code&gt; does not need exe, you could simply use &lt;code&gt;:noh&lt;/code&gt;, since you do not need to dynamically build up a string as command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned in the comment, this does not work, because of what is described at &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-searchpat&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help autocmd-searchpat&lt;/code&gt;&lt;/a&gt;. &#xA;However there are a couple of workarounds:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#feedkeys%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;feedkeys()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:autocmd CursorHold * :sil call feedkeys(&quot;:nohls\&amp;lt;cr&amp;gt;\&amp;lt;c-l&amp;gt;&quot;, 'tn')&lt;/code&gt;&#xA;This will use feedkeys using the &lt;code&gt;t&lt;/code&gt;and &lt;code&gt;n&lt;/code&gt; flags which makes sure, Vim receives the input as if &lt;em&gt;the user typed it like that&lt;/em&gt; and works around the problem mentioned at &lt;code&gt;:h autocmd-searchpat&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using CmdlindLeave autocommand&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is a relatively new autocommand, that was included with patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.0.1206&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.0.1206&lt;/a&gt; and can be used to automatically set &lt;code&gt;:nohls&lt;/code&gt; after leaving the commandline as explained at &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27incsearch%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'incsearch'&lt;/code&gt;&lt;/a&gt;&#xA;Note: This feature is only available since patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.0.1238&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.0.1238&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-02-14T21:53:10.383" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15211" PostTypeId="1" AcceptedAnswerId="15214" CreationDate="2018-02-15T02:57:57.077" Score="3" ViewCount="1384" Body="&lt;p&gt;I want -  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;variable++;&lt;/code&gt; then &lt;code&gt;variable ++;&lt;/code&gt;  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;variable1 + variable2&lt;/code&gt; nothing to do&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;variable1 +variable2&lt;/code&gt; then &lt;code&gt;variable1 + variable2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;variable1+ variable2&lt;/code&gt; then &lt;code&gt;variable1 + variable2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;variable1+variable2&lt;/code&gt; then &lt;code&gt;variable1 + variable2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;similarly for &lt;code&gt;-,*,/,&amp;gt;=,&amp;lt;=,!=,==&lt;/code&gt;.&lt;br&gt;&#xA;And if - &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;variable1 = variable2&lt;/code&gt; then nothing to do&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;variable1 =variable2&lt;/code&gt; then &lt;code&gt;variable1 = variable2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;variable1= variable2&lt;/code&gt; then &lt;code&gt;variable1 = variable2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;variable1=variable2&lt;/code&gt; then &lt;code&gt;variable1 = variable2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I try the search regex as &lt;code&gt;[a-zA-Z]+([-+/*=]|&amp;gt;=|&amp;lt;=|!=|==)&lt;/code&gt; although it is not correct fully.&lt;/p&gt;&#xA;" OwnerUserId="16318" LastEditorUserId="4472" LastEditDate="2018-02-15T18:45:48.533" LastActivityDate="2018-02-15T18:45:48.533" Title="How to put space before and after operators for enhanced readability?" Tags="|regular-expression|search|replace|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15212" PostTypeId="1" AcceptedAnswerId="15213" CreationDate="2018-02-15T03:45:17.657" Score="7" ViewCount="5231" Body="&lt;p&gt;I am using neovim 0.2.3 dev and xfce4-clipman clipboard manager. I want to copy from the neovim into registers and put it into clipman register. How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-27T04:20:22.793" LastActivityDate="2019-02-27T04:20:22.793" Title="Neovim Clipboard Selection" Tags="|neovim|os-clipboard|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15213" PostTypeId="2" ParentId="15212" CreationDate="2018-02-15T04:11:12.647" Score="12" Body="&lt;p&gt;I got around the problem I posted. I am leaving the solution if and when anyone gets stuck in similar situations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put this snippet into your init.nvim. Then install xclip. For easy manipulation you can also use some gui clipboard manager like xfce4-clipman. But xclip is necessary for the following snippet.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:clipboard = {&#xA;  \   'name': 'xclip-xfce4-clipman',&#xA;  \   'copy': {&#xA;  \      '+': 'xclip -selection clipboard',&#xA;  \      '*': 'xclip -selection clipboard',&#xA;  \    },&#xA;  \   'paste': {&#xA;  \      '+': 'xclip -selection clipboard -o',&#xA;  \      '*': 'xclip -selection clipboard -o',&#xA;  \   },&#xA;  \   'cache_enabled': 1,&#xA;  \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2018-02-15T04:11:12.647" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15214" PostTypeId="2" ParentId="15211" CreationDate="2018-02-15T06:39:18.537" Score="4" Body="&lt;p&gt;One way to do this would be this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First change the infix operators:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(\w) ?(\+|-|\*|\/|\&amp;gt;\=|\&amp;lt;\=|!\=|\=|\=\=) ?(\w|-)/\1 \2 \3/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. This also handles the &lt;code&gt;int x=-b&lt;/code&gt; case &lt;a href=&quot;https://vi.stackexchange.com/questions/15211/how-to-put-space-before-and-after-of-a-operator-for-ehance-readability/15214?noredirect=1#comment26065_15214&quot;&gt;mentioned in the comments&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the postfix &lt;code&gt;++&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(\w)\+\+/\1 ++/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Broken down, that first regular expression is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt;: Turn on &quot;very magic&quot; matching.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(\w) ?&lt;/code&gt;: Find a &quot;word character&quot; optionally followed by a space, capturing the word character into a group.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(\+|-|\*|\/|\&amp;gt;\=|\&amp;lt;\=|!\=|\=|\=\=)&lt;/code&gt;: Find any of &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;!=&lt;/code&gt;, &lt;code&gt;=&lt;/code&gt;, or &lt;code&gt;==&lt;/code&gt;, capturing it into a second group.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;_?(\w|-)&lt;/code&gt;: Find another optional space (represented here as an underscore so you can see it!) followed by another word character (or minus symbol), captured into the third group.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;We then replace the entire match with the contents of the three groups, separated by spaces:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\1 \2 \3&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info, see &lt;code&gt;:help regexp&lt;/code&gt;, and specifically:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \magic&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \w&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \?&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \|&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help \1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-15T10:04:30.130" LastActivityDate="2018-02-15T10:04:30.130" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="15215" PostTypeId="1" AcceptedAnswerId="15220" CreationDate="2018-02-15T07:45:35.693" Score="3" ViewCount="1025" Body="&lt;p&gt;I'm using xfce4-terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I remapped most Alt+key combinations in a file that is loaded in the .virmc.&#xA;The file (called alt_bindings.vim, only loaded in vim 8 terminal mode) is like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;M-a&amp;gt;=^]a&#xA;set &amp;lt;M-A&amp;gt;=^]A&#xA;set &amp;lt;M-b&amp;gt;=^]b&#xA;set &amp;lt;M-B&amp;gt;=^]B&#xA;set &amp;lt;M-c&amp;gt;=^]c&#xA;set &amp;lt;M-C&amp;gt;=^]C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc for most keys. I excluded some combinations that gave me errors right away, such as &lt;code&gt;alt+O&lt;/code&gt; and &lt;code&gt;alt+[&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I have macros like this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;w   0vf'snno^I ^[lywio^[plxxx  :set &amp;lt;80&amp;gt;kD&amp;lt;80&amp;gt;kD^[wwD&amp;lt;80&amp;gt;kd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^[&lt;/code&gt; is &lt;kbd&gt;Esc&lt;/kbd&gt; key, but the macro seems to trigger my defined keys instead, and it breaks the macro totally. For example, &lt;code&gt;^[plxxx&lt;/code&gt; would be &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;code&gt;plxxx&lt;/code&gt; that is: back to normal mode, paste, right, delete 3x. It does something else entirely instead (like inserting xxx and other chars). The problem goes away if I don't load those mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;Alt&amp;gt;=^]&#xA;set &amp;lt;M-A&amp;gt;=&amp;lt;Alt&amp;gt;A&#xA;set &amp;lt;M-b&amp;gt;=&amp;lt;Alt&amp;gt;b&#xA;set &amp;lt;M-B&amp;gt;=&amp;lt;Alt&amp;gt;B&#xA;set &amp;lt;M-c&amp;gt;=&amp;lt;Alt&amp;gt;c&#xA;set &amp;lt;M-C&amp;gt;=&amp;lt;Alt&amp;gt;C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work. I also tried something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;t_F13&amp;gt;=^]&#xA;set &amp;lt;M-A&amp;gt;=&amp;lt;t_F13&amp;gt;A&#xA;set &amp;lt;M-b&amp;gt;=&amp;lt;t_F13&amp;gt;b&#xA;set &amp;lt;M-B&amp;gt;=&amp;lt;t_F13&amp;gt;B&#xA;set &amp;lt;M-c&amp;gt;=&amp;lt;t_F13&amp;gt;c&#xA;set &amp;lt;M-C&amp;gt;=&amp;lt;t_F13&amp;gt;C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but weird stuff happens and keys don't work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then used (taken from &lt;a href=&quot;https://stackoverflow.com/questions/35330381/getting-alt-to-work-in-the-terminal-with-tmux-and-vim&quot;&gt;here&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let c='a'&#xA;while c &amp;lt;= 'z'&#xA;  exec &quot;set &amp;lt;M-&quot;.c.&quot;&amp;gt;=&quot;.c&#xA;  exec &quot;nnoremap &quot;.c.&quot; &amp;lt;M-&quot;.c.&quot;&amp;gt;&quot;&#xA;  let c = nr2char(1+char2nr(c))&#xA;endw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it works, but it exhibits the same problem (broken macros).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="16351" LastEditorUserId="16351" LastEditDate="2018-02-16T08:47:15.430" LastActivityDate="2018-02-16T10:46:01.913" Title="Remapping Alt key in terminal: problem with macros" Tags="|key-bindings|terminal|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15216" PostTypeId="1" AcceptedAnswerId="15217" CreationDate="2018-02-15T08:33:28.793" Score="2" ViewCount="1021" Body="&lt;p&gt;In &lt;a href=&quot;http://vim.wikia.com/wiki/Dictionary_completions&quot; rel=&quot;nofollow noreferrer&quot;&gt;this wikia tip&lt;/a&gt; I found &lt;code&gt;set complete+=k&lt;/code&gt; and &lt;code&gt;set complete+=t&lt;/code&gt;. I applied both but only the first one worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is what is the difference between these?&lt;/p&gt;&#xA;" OwnerUserId="16318" LastEditorUserId="1841" LastEditDate="2018-02-15T08:39:42.437" LastActivityDate="2018-02-15T08:39:42.437" Title="What is the difference between set complete+=t and set complete+=k in vim?" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15217" PostTypeId="2" ParentId="15216" CreationDate="2018-02-15T08:38:52.350" Score="6" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27complete%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'complete'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;k   scan the files given with the 'dictionary' option&#xA;]   tag completion&#xA;t   same as &quot;]&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The tag &lt;code&gt;k&lt;/code&gt; allows you to specify a file containing some words you want to use for completion. The tag &lt;code&gt;t&lt;/code&gt; is used to complete tags generated by a program like exuberant Ctags or cscope. For more details about tags see &lt;a href=&quot;http://vimhelp.appspot.com/tagsrch.txt.html#tag&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h tag&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you used &lt;code&gt;set complete+=t&lt;/code&gt; it's not that it didn't work it is that you probably didn't generate a tag file.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-02-15T08:38:52.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15218" PostTypeId="1" AcceptedAnswerId="15219" CreationDate="2018-02-15T08:58:50.643" Score="8" ViewCount="12196" Body="&lt;p&gt;I read the solution answered in &lt;a href=&quot;https://stackoverflow.com/questions/11037825/vim-get-out-of-parenthesis-brackets-etc&quot;&gt;https://stackoverflow.com/questions/11037825/vim-get-out-of-parenthesis-brackets-etc&lt;/a&gt;. That is nothing but command &lt;code&gt;A&lt;/code&gt; that takes away you in the end of line.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, my requirement is something different. Suppose I have a file containing -&lt;br&gt;&#xA;&lt;code&gt;x = (3+5)/(2+1);&lt;/code&gt;&lt;br&gt;&#xA;When cursor is on &lt;code&gt;+&lt;/code&gt; I want to move the cursor on &lt;code&gt;/&lt;/code&gt; or first &lt;code&gt;)&lt;/code&gt;, but not on &lt;code&gt;;&lt;/code&gt;(You can consider 'after the character' instead of 'on the character' ).&lt;/p&gt;&#xA;" OwnerUserId="9498" LastActivityDate="2018-02-15T14:25:57.150" Title="How to go to end/get out of the parenthesis of a line in vim?" Tags="|cursor-movement|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15219" PostTypeId="2" ParentId="15218" CreationDate="2018-02-15T09:36:56.807" Score="23" Body="&lt;p&gt;I'm not 100% clear if this is what you're asking, but I think you might be looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This jumps to the nearest enclosing &lt;code&gt;)&lt;/code&gt;. So if your cursor was on the &lt;code&gt;/&lt;/code&gt; in the below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(2 / (3 + 5) * 9) &#xA;   ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would skip past the first &lt;code&gt;)&lt;/code&gt; and jump to here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(2 / (3 + 5) * 9)&#xA;                ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, for your more simple case, &lt;code&gt;%%&lt;/code&gt; would also work. The first &lt;code&gt;%&lt;/code&gt; jumps to the opening &lt;code&gt;(&lt;/code&gt;, and the second jumps to its counterpart, the closing &lt;code&gt;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help ])&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help %&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-15T09:42:05.707" LastActivityDate="2018-02-15T09:42:05.707" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15220" PostTypeId="2" ParentId="15215" CreationDate="2018-02-15T10:59:27.673" Score="7" Body="&lt;p&gt;The problem is caused by the way that &lt;a href=&quot;https://catern.com/posts/terminal_quirks.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;terminals have historically handled&lt;/a&gt; the &lt;kbd&gt;Alt&lt;/kbd&gt;/&lt;kbd&gt;Meta&lt;/kbd&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Back in the mists of history, some computers/terminals had a &lt;kbd&gt;Meta&lt;/kbd&gt; key. When this was held down while another key was pressed, the 8th bit of the character was set. So e.g. pressing the &lt;kbd&gt;a&lt;/kbd&gt; key with or without the &lt;kbd&gt;Meta&lt;/kbd&gt; key depressed would result in the following keycodes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;       Hex  Binary&#xA;     p 0x70 01110000 &#xA;Meta+p 0xF0 11110000&#xA;            ^&#xA;            |&#xA;            8th bit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when sending this information a network, the 8th bit was sometimes used for other purposes (if the protocol/environment was not &quot;8-bit clean&quot;) and this method could not be used. An alternative solution was instead to transmit an ESC character followed by the unmodified character. e.g. &lt;code&gt;^[p&lt;/code&gt;. This would then be interpreted by programs that received it as a &lt;kbd&gt;Meta-P&lt;/kbd&gt; keypress.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is why Vim is interpreting your &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; in the macro as &lt;kbd&gt;Meta-P&lt;/kbd&gt; and triggering your mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason the problem doesn't occur when you manually type &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; is that when Vim receives an ESC character, it waits for a short period of time to see whether it is followed by another character (See &lt;code&gt;:help 'ttimeout'&lt;/code&gt;). If none follows within the time specified in your settings, Vim interprets it as a &lt;kbd&gt;Esc&lt;/kbd&gt; keypress. If Vim receives another character within that timeframe, it interprets the pair as a &lt;kbd&gt;Meta-key&lt;/kbd&gt; chord and triggers the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you play back the macro, the keypresses are replayed as fast as possible, and so Vim interprets them incorrectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I'm not aware of a great solution for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The options I can think of are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use GUI Vim: this handles the &lt;kbd&gt;Alt&lt;/kbd&gt; key itself, and so the mappings will work transparently,&lt;/li&gt;&#xA;&lt;li&gt;Configure your terminal to send some other keycode for each Alt-chord, and then map these keycodes in Vim,&lt;/li&gt;&#xA;&lt;li&gt;Use Neovim. I'm &lt;a href=&quot;https://github.com/tpope/vim-rsi/issues/13#issuecomment-122384689&quot; rel=&quot;nofollow noreferrer&quot;&gt;led to believe&lt;/a&gt; Neovim doesn't have this issue (although I'm not sure how it gets around it).&lt;/li&gt;&#xA;&lt;li&gt;Alter the way you record your macro so that the key following the &lt;kbd&gt;Esc&lt;/kbd&gt; isn't one that would trigger a mapping. e.g. while recording, type &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;Ctrl-C&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; instead of &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;,&lt;/li&gt;&#xA;&lt;li&gt;Don't use Alt-mappings. :(&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: Your comment gave me an idea: instead of manually sourcing files before and after running a macro, you can get Vim to do it for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SetKeycodes()&#xA;  &quot; N.B. Type ^[ as &amp;lt;Ctrl-V&amp;gt;&amp;lt;Esc&amp;gt;&#xA;  set &amp;lt;M-o&amp;gt;=^[o&#xA;  set &amp;lt;M-p&amp;gt;=^[p&#xA;  &quot;etc&#xA;endfunction&#xA;call SetKeycodes()&#xA;&#xA;function! UnsetKeycodes()&#xA;  set &amp;lt;M-o&amp;gt;=&#xA;  set &amp;lt;M-p&amp;gt;=&#xA;  &quot;etc&#xA;endfunction&#xA;&#xA;function! RunMacro()&#xA;  let r = getchar()&#xA;  echom r&#xA;  call UnsetKeycodes()&#xA;  execute &quot;normal! @&quot; . nr2char(r)&#xA;  call SetKeycodes()&#xA;endfunction&#xA;&#xA;nnoremap @ :call RunMacro()&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;M-o&amp;gt; Mapping (o)&#xA;inoremap &amp;lt;M-p&amp;gt; Mapping (p)&#xA;set ttimeoutlen=10&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-16T10:46:01.913" LastActivityDate="2018-02-16T10:46:01.913" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15221" PostTypeId="2" ParentId="15218" CreationDate="2018-02-15T14:25:57.150" Score="2" Body="&lt;p&gt;My plugin &lt;a href=&quot;https://github.com/andymass/vim-matchup&quot; rel=&quot;nofollow noreferrer&quot;&gt;match-up&lt;/a&gt; provides the mappings &lt;code&gt;]%&lt;/code&gt; and &lt;code&gt;[%&lt;/code&gt; which is like a delimiter-agnostic version of &lt;code&gt;])&lt;/code&gt;/&lt;code&gt;]}&lt;/code&gt;  to go to either element of a surrounding matching pair.  Since it uses the symbols listed in &lt;code&gt;matchpairs&lt;/code&gt;, it works for &lt;code&gt;()&lt;/code&gt;/&lt;code&gt;{}&lt;/code&gt;/&lt;code&gt;[]&lt;/code&gt; by default and will work for &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; if &lt;code&gt;matchpairs&lt;/code&gt; contains &lt;code&gt;&amp;lt;:&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Filetypes can also specify more advanced matching pairs (e.g., &lt;code&gt;if/endif&lt;/code&gt; in vimscript), similar to the plugin matchit which is distributed with vim (except matchit seems to be unmaintained and these &lt;a href=&quot;https://vi.stackexchange.com/questions/13155/what-do-matchit-vims-a-do&quot;&gt;mappings don't work&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-02-15T14:25:57.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15222" PostTypeId="1" AcceptedAnswerId="15223" CreationDate="2018-02-15T15:20:35.470" Score="3" ViewCount="2274" Body="&lt;p&gt;I'm just starting with VIM and I'm trying to install this custom color scheme: &lt;a href=&quot;https://github.com/devnul1/heman&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/devnul1/heman&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created a .vim directory on my home directory and inside .vim I created a directory colors, inside that I uploaded the color scheme file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.vim/colors/heman.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then created a .vimrc file with this configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;colorscheme heman&#xA;set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know the .vimrc file is working because when I open VIM I get line numbers, but thing is I don't get the custom color scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I doing something wrong? Could someone point me in the right direction?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="16354" LastActivityDate="2018-02-16T06:01:41.953" Title="Using a custom color scheme and setting it as default" Tags="|vimrc|colorscheme|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15223" PostTypeId="2" ParentId="15222" CreationDate="2018-02-15T16:35:17.403" Score="3" Body="&lt;p&gt;I notice that that colorscheme requires a 256 color terminal, based on this towards the beginning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !has('gui_running') &amp;amp;&amp;amp; &amp;amp;t_Co != 256&#xA;    finish&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's likely that your Mac at home doesn't set the &lt;code&gt;TERM&lt;/code&gt; environment variable by default to indicate that it supports 256 colors, whereas your phone's terminal emulator/SSH client does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check the value of the &lt;code&gt;TERM&lt;/code&gt; variable (&lt;code&gt;echo $TERM&lt;/code&gt;); I'm guessing that it's &lt;code&gt;xterm&lt;/code&gt;, indicating that the terminal does &lt;em&gt;not&lt;/em&gt; support 256 colors, whereas it should be &lt;code&gt;xterm-256color&lt;/code&gt; to indicate that it &lt;em&gt;does&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many terminal emulators (e.g. XTerm) still set the &lt;code&gt;TERM&lt;/code&gt; to &lt;code&gt;xterm&lt;/code&gt; by default for historical reasons even though they support 256 colors, requiring you to manually override that (to do this in XTerm, you set the following resource: &lt;code&gt;XTerm*termName: xterm-256color&lt;/code&gt;). I'd imagine you just need to do that for whatever particular terminal emulator you're using on your Mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also try setting the &lt;code&gt;TERM&lt;/code&gt; variable manually in your shell before entering VIM, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TERM=xterm-256color vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export TERM=xterm-256color&#xA;vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16356" LastEditorUserId="16356" LastEditDate="2018-02-15T16:42:02.553" LastActivityDate="2018-02-15T16:42:02.553" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15225" PostTypeId="1" CreationDate="2018-02-16T13:55:31.330" Score="10" ViewCount="10577" Body="&lt;p&gt;Consider an answer to &lt;a href=&quot;https://vi.stackexchange.com/questions/613/how-do-i-install-a-plugin-in-vim-vi&quot;&gt;How do I install a plugin in Vim/vi?&lt;/a&gt;: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;&quot; For MS Windows, this is probably better:&#xA;&quot;call plug#begin('~/vimfiles/plugged')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And more generally, things which go into &lt;code&gt;'~/.vim'&lt;/code&gt; under Linux should go into &lt;code&gt;'~/vimfiles'&lt;/code&gt; under Windows. How can I refer to the correct directory in my &lt;code&gt;.vimrc&lt;/code&gt; (or in other Vimscript files, I guess)?&lt;/p&gt;&#xA;" OwnerUserId="16365" LastActivityDate="2024-01-09T23:41:58.350" Title="How to refer to &quot;~/vimfiles&quot; on Windows and &quot;~/.vim&quot; on Linux?" Tags="|vimrc|vimscript|" AnswerCount="7" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15226" PostTypeId="2" ParentId="15225" CreationDate="2018-02-16T13:58:00.997" Score="5" Body="&lt;p&gt;An answer I found, but not sure whether it's optimal or correct in all circumstances: &lt;code&gt;split(&amp;amp;rtp, ',')[0] . '/plugged'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16365" LastActivityDate="2018-02-16T13:58:00.997" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15227" PostTypeId="2" ParentId="15225" CreationDate="2018-02-16T14:30:06.080" Score="9" Body="&lt;p&gt;Another possible solution is to test the features of your installation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('win32')&#xA;    let $MYPLUGDIRECTORY = &quot;~/vimfiles/plugged&quot;&#xA;else&#xA;    let $MYPLUGDIRECTORY = &quot;~/.vim/plugged&quot;&#xA;endif&#xA;&#xA;call plug#begin($MYPLUGDIRECTORY)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It has the advantage to let you mess with your &lt;code&gt;rtp&lt;/code&gt; setup. For example, if for whatever reason the first directory in &lt;code&gt;rtp&lt;/code&gt; is not &lt;code&gt;$HOME/.vim/&lt;/code&gt; you will not break your plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An important note from the doc, &lt;code&gt;has('win32')&lt;/code&gt; works for both 32 and 64 bits systems:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;win32           Win32 version of Vim (MS-Windows 95 and later, 32 or 64 bits)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can read more at:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#has%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h has()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#feature-list&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h feature-list&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-02-16T14:43:40.700" LastActivityDate="2018-02-16T14:43:40.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15228" PostTypeId="2" ParentId="15225" CreationDate="2018-02-16T14:32:25.583" Score="5" Body="&lt;p&gt;I create a symlink from &lt;code&gt;.vim&lt;/code&gt; to &lt;code&gt;vimfiles&lt;/code&gt; in the Windows Command prompt, and then use just &lt;code&gt;.vim&lt;/code&gt; throughout my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mklink /D .vim %HOMEDRIVE%%HOMEPATH%\vimfiles&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Actually, what I do is link both &lt;code&gt;vimfiles&lt;/code&gt; and &lt;code&gt;.vim&lt;/code&gt; to a git repository, elsewhere, but this should work fine too.)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-16T14:32:25.583" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15229" PostTypeId="2" ParentId="15225" CreationDate="2018-02-16T14:37:26.310" Score="2" Body="&lt;p&gt;I use the following (from my &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-vim-lib&lt;/a&gt; library plugin):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! lh#path#vimfiles() abort&#xA;  let re_HOME = lh#path#to_regex($HOME.'/')&#xA;  let re_LUCHOME = exists('$LUCHOME') ? '\|'.lh#path#to_regex($LUCHOME.'/'): ''&#xA;  let what = '\%('.re_HOME.re_LUCHOME.'\)'.'\(vimfiles\|.vim\|.config[/\\]nvim\)'&#xA;  &quot; Comment what&#xA;  let z = lh#path#find(&amp;amp;rtp,what)&#xA;  return z&#xA;endfunction&#xA;&#xA;function! lh#path#to_regex(path) abort&#xA;  let regex = substitute(a:path, '[/\\]', '[/\\\\]', 'g')&#xA;  return regex&#xA;endfunction&#xA;&#xA;function! lh#path#find(paths, regex) abort&#xA;  let paths = (type(a:paths) == type([]))&#xA;        \ ? (a:paths)&#xA;        \ : split(a:paths,',')&#xA;  call filter(paths, 'match(v:val, a:regex) != -1')&#xA;  let shortest = lh#list#arg_min(paths, function('len'))&#xA;  return empty(paths) ? '' : paths[shortest]&#xA;endfunction&#xA;&#xA;function! lh#list#arg_min(list, ...) abort&#xA;  if empty(a:list) | return -1 | endif&#xA;  if a:0 &amp;gt; 0&#xA;    let Transfo = a:1&#xA;    let list = map(copy(a:list), '[Transfo(v:val), v:key]')&#xA;  else&#xA;    let list = map(copy(a:list), '[v:val, v:key]')&#xA;  endif&#xA;  let res = [list[0]]&#xA;  call map(list[1:], 'add(res, v:val[0] &amp;lt; res[-1][0] ? v:val : res[-1])')&#xA;  return res[-1][1]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's somehow overkill, but at least it permits me to share accounts (in that case I put my configuration stuff in &lt;code&gt;~/luc&lt;/code&gt; and I set &lt;code&gt;$LUCHOME&lt;/code&gt; -- yeah this is really bad, but sometimes very bad practices are enforced), and it works with vim (windows and *nix), and neovim apparently, and it supports any value for shellslash. It doesn't expect &lt;code&gt;~/{.vim,vimfiles}/&lt;/code&gt; to be the first directory in &lt;code&gt;&amp;amp;rtp&lt;/code&gt; either.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-02-16T14:37:26.310" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15230" PostTypeId="2" ParentId="15225" CreationDate="2018-02-16T15:43:08.700" Score="1" Body="&lt;p&gt;Just check to see if the directory exists with &lt;code&gt;isdirectory()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if isdirectory(expand('~/.vim/plugged', ':p'))&#xA;    call plug#begin('~/.vim/plugged')&#xA;else&#xA;    call plug#begin('~/vimfiles/plugged')&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h isdirectory()&#xA;:h fnamemodify()&#xA;:h expand()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-02-16T21:59:35.060" LastActivityDate="2018-02-16T21:59:35.060" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15231" PostTypeId="1" AcceptedAnswerId="15232" CreationDate="2018-02-16T16:47:19.830" Score="3" ViewCount="894" Body="&lt;p&gt;When using &lt;code&gt;foldmethod=marker&lt;/code&gt;, how do you select or reference exactly the contents of the current fold?  I want to swap the order of two folds.  If they were paragraphs, I would do &lt;code&gt;dap&lt;/code&gt; &lt;code&gt;{&lt;/code&gt; &lt;code&gt;p&lt;/code&gt;.  However, I can't find a corresponding &lt;code&gt;daz&lt;/code&gt;.  I think the answer is obvious, but I sure can't find it here or on Google.  Possibly related to &lt;a href=&quot;https://vi.stackexchange.com/q/12717/1430&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MCVE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Fold 1 {{{&#xA;&#xA;}}}&#xA;Fold 2 {{{&#xA;&#xA;}}}&#xA;Fold 3 {{{&#xA;}}}&#xA;&#xA;- vi: set foldmethod=marker: -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put the cursor on &lt;code&gt;Fold 2&lt;/code&gt;.  Then &lt;code&gt;dzj&lt;/code&gt; removes the contents of &lt;code&gt;Fold 2&lt;/code&gt;, and also the &lt;code&gt;Fold 3&lt;/code&gt; line.  Or, put the cursor on the &lt;code&gt;}}}&lt;/code&gt; of &lt;code&gt;Fold 2&lt;/code&gt;, and &lt;code&gt;dzk&lt;/code&gt; kills the end of &lt;code&gt;Fold 1&lt;/code&gt; as well.  Similar results from &lt;code&gt;d[z&lt;/code&gt; and &lt;code&gt;d]z&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;zd&lt;/code&gt; removes the fold markers, but I want to actually grab the contents of the fold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I could do something like &lt;code&gt;viz&lt;/code&gt; &lt;code&gt;d&lt;/code&gt;, that would work great &amp;mdash; but searches for &quot;visual&quot; and &quot;folding&quot; are giving me lots of hits about &lt;code&gt;v&amp;lt;motion&amp;gt;zf&lt;/code&gt;, which is not what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, the only options I have found are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;to delete, &lt;code&gt;zc&lt;/code&gt; &lt;code&gt;dd&lt;/code&gt; (close the fold, then delete the resulting single line).&lt;/li&gt;&#xA;&lt;li&gt;to select in visual mode, &lt;code&gt;zc&lt;/code&gt; &lt;code&gt;V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Are those indeed the Right Things to use?&lt;/p&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="1292" LastEditDate="2019-01-24T12:56:13.750" LastActivityDate="2022-08-25T16:05:39.447" Title="How to select/delete/yank the contents of only the current fold?" Tags="|cut-copy-paste|cursor-motions|folding|object-motions|custom-text-object|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15232" PostTypeId="2" ParentId="15231" CreationDate="2018-02-16T17:11:51.713" Score="6" Body="&lt;p&gt;There is no text object for folds in vim, but there is a plugin which provides them, &lt;code&gt;az&lt;/code&gt;/&lt;code&gt;iz&lt;/code&gt;: &lt;a href=&quot;https://github.com/kana/vim-textobj-fold&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/kana/vim-textobj-fold&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are vanilla alternatives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;vi{&lt;/code&gt;/&lt;code&gt;va{&lt;/code&gt;.  This may or may not select what you want, depending on whether your markers are in comments or not.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;[zV]z&lt;/code&gt;.  Alternatively you can replace &lt;code&gt;V&lt;/code&gt; with any operator.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;make your own: &lt;code&gt;xnoremap az [zo]z&lt;/code&gt;, &lt;code&gt;xnoremap iz [zjo]zk&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-02-16T17:11:51.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15233" PostTypeId="2" ParentId="15231" CreationDate="2018-02-16T17:14:45.880" Score="6" Body="&lt;p&gt;To delete the current fold, you simply have &lt;code&gt;zd&lt;/code&gt; for instance&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you could also define an operator-pending mode mapping with for instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:onoremap iz :&amp;lt;c-u&amp;gt;normal! [zV]z&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will permit stuff like &lt;code&gt;diz&lt;/code&gt;, &lt;code&gt;ciz&lt;/code&gt;, &lt;code&gt;yiz&lt;/code&gt;, &lt;code&gt;=iz&lt;/code&gt; and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, the related visual mode mapping would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:xnoremap iz [zo]z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-02-16T17:14:45.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15234" PostTypeId="1" CreationDate="2018-02-16T19:52:31.390" Score="3" ViewCount="328" Body="&lt;p&gt;I am trying to emulate the Atom JavaScript syntax highlighting in vim, but there are a few things missing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Namely, I'd like to highlight objects and their chains in red. It'd be dandy if I could also highlight classes in yellow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I'm seeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Si197.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Si197.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Atom&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/T3GGD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T3GGD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using this enhanced highlighting plugin&#xA;&lt;a href=&quot;https://github.com/pangloss/vim-javascript&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/pangloss/vim-javascript&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16368" LastActivityDate="2023-01-23T16:04:10.513" Title="How can I change Javascript syntax to higlight objects?" Tags="|syntax-highlighting|filetype-javascript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15235" PostTypeId="2" ParentId="15225" CreationDate="2018-02-16T21:41:46.080" Score="2" Body="&lt;p&gt;You can read the path of &lt;code&gt;$MYVIMRC&lt;/code&gt; (which points to your &lt;code&gt;.vimrc&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin(fnamemodify($MYVIMRC, &quot;:p:h&quot;) . '/bundle')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16369" LastEditorUserId="16369" LastEditDate="2018-02-17T11:12:40.180" LastActivityDate="2018-02-17T11:12:40.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15236" PostTypeId="2" ParentId="15204" CreationDate="2018-02-16T22:12:11.823" Score="6" Body="&lt;p&gt;The problem you are encountering is, that the commandline subsystem on Windows does not support UNC paths. (Try running cmd.com and then &lt;code&gt;cd \\server\path\to\dir&lt;/code&gt; and notice the error message &lt;code&gt;CMD does not support UNC paths as current directories.&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That leaves you with mapping the path to a temporary drive letter using &lt;code&gt;net use&lt;/code&gt; or instead of using &lt;code&gt;cd&lt;/code&gt; use &lt;a href=&quot;https://superuser.com/questions/282963/browse-an-unc-path-using-windows-cmd-without-mapping-it-to-a-network-drive/399885#399885&quot;&gt;&lt;code&gt;pushd&lt;/code&gt;&lt;/a&gt; instead, which basically maps your path to a temporary drive letter so you'll be able to access that file afterwards easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;pushd&lt;/code&gt; will temporarily create a drive mapping to the network share and then change into a path relative to it. &lt;code&gt;popd&lt;/code&gt; then will disconnects the share and return to your previous current directory.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-02-16T22:12:11.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15237" PostTypeId="1" CreationDate="2018-02-17T06:04:17.387" Score="1" ViewCount="660" Body="&lt;p&gt;I have the following configuration in my vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-A&amp;gt; &amp;lt;Plug&amp;gt;InsertComment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And somewhere in my vim folder I defined&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;InsertComment &amp;lt;ESC&amp;gt;:call INSERT_MY_COMMENT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mapping worked really well after I configured it. But somehow recently it stopped functioning. And whenever I can to use the Key-bind in the insert mode, instead calling the function that I mapped, vim will just paste the entire &lt;code&gt;&amp;lt;Plug&amp;gt;InsertComment&lt;/code&gt; thing to my buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to debug and found out that if I map &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;C-A&amp;gt; &amp;lt;ESC&amp;gt;:call INSERT_MY_COMMENT&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;it still works as desired, which means there must be something wrong with the &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I really have no clue on why &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; would stop being interpreted by vim as a handle to call other plugins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried to manually copy and paste &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;InsertComment &amp;lt;ESC&amp;gt;:call INSERT_MY_COMMENT&#xA;inoremap &amp;lt;C-A&amp;gt; &amp;lt;Plug&amp;gt;InsertComment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in to vim's command line, just to make sure the configurations have not accidentally been unset. But still, vim wouldn't accept that as a function, but rather copy the plain text to buffer.&lt;/p&gt;&#xA;" OwnerUserId="16146" LastActivityDate="2018-02-21T07:55:57.873" Title="Vim stops treating &quot;&lt;Plug&gt;&quot; as a keyword to call functions in insert mode" Tags="|vimrc|plugin-system|key-bindings|plugin-vim-latex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15238" PostTypeId="2" ParentId="15237" CreationDate="2018-02-17T08:14:50.227" Score="4" Body="&lt;p&gt;If you use a nore mapping to tie a sequence of keys to &lt;code&gt;&amp;lt;plug&amp;gt;something&lt;/code&gt;, even if there is a mapping behind that &lt;code&gt;&amp;lt;plug&amp;gt;something&lt;/code&gt;, it'll be ignored. In the documentation, &lt;code&gt;nore&lt;/code&gt; is said to prevent &lt;em&gt;recursion&lt;/em&gt;. That's what is happening here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means that: the &lt;code&gt;&amp;lt;plug&amp;gt;something&lt;/code&gt; mapping shall indeed be defined with &lt;code&gt;noremap&lt;/code&gt;, but the actual keybinding chosen shall not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IOW, the correct definitions become&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; in a plugin: &#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;InsertComment &amp;lt;c-o&amp;gt;:call INSERT_MY_COMMENT()&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; in your .vimrc&#xA;imap &amp;lt;C-A&amp;gt; &amp;lt;Plug&amp;gt;InsertComment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-02-17T08:14:50.227" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15239" PostTypeId="2" ParentId="15237" CreationDate="2018-02-17T08:22:07.337" Score="2" Body="&lt;p&gt;Your problem is that you are using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-A&amp;gt; &amp;lt;Plug&amp;gt;InsertComment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That basically means, that recursive resolution of your mapped keys is &lt;strong&gt;prevented&lt;/strong&gt; which is usually not what you want. Therefore change your mapping to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;C-A&amp;gt; &amp;lt;Plug&amp;gt;InsertComment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also the extensive &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#using-%3CPlug%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;help&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Start reading from the paragraph that starts with &lt;strong&gt;MAPPING&lt;/strong&gt;) &lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-02-21T07:55:57.873" LastActivityDate="2018-02-21T07:55:57.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15240" PostTypeId="2" ParentId="2105" CreationDate="2018-02-17T11:21:01.760" Score="1" Body="&lt;p&gt;Using relative numbers. Paragraph starts at line 13 and spams more 4 lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :13,13+4g/^/m12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2018-02-17T11:21:01.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15241" PostTypeId="1" AcceptedAnswerId="15249" CreationDate="2018-02-17T13:22:23.337" Score="1" ViewCount="233" Body="&lt;p&gt;Say I have the table:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;| TITLE             |&#xA;| This is some text |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I center align the TITLE like so?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|       TITLE       |&#xA;| This is some text |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried using both EasyAlign and Tabular but without much success.&lt;/p&gt;&#xA;" OwnerUserId="16379" LastActivityDate="2018-02-19T16:55:44.227" Title="How can I center align a word(s) in a table?" Tags="|alignment|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15242" PostTypeId="2" ParentId="4944" CreationDate="2018-02-17T15:20:11.647" Score="6" Body="&lt;p&gt;From wikia&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;Leader&amp;gt;r c&amp;lt;C-O&amp;gt;:set revins&amp;lt;CR&amp;gt;&amp;lt;C-R&amp;gt;&quot;&amp;lt;Esc&amp;gt;:set norevins&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more see: &lt;code&gt;:h revins&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2018-02-17T15:20:11.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15243" PostTypeId="1" AcceptedAnswerId="15246" CreationDate="2018-02-17T16:00:35.573" Score="5" ViewCount="3459" Body="&lt;p&gt;I have the following lines in my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g = 0&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;C-g&amp;gt; &amp;lt;C-o&amp;gt;:let g = !g&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-_&amp;gt; &amp;lt;C-o&amp;gt;(g == 0 ? :undo : :redo)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to emulate an emacs-like undo/redo feature in insert mode. I'm not sure how to escape or use colon-commands inside a ternary expression. Any help would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="16381" LastActivityDate="2018-02-17T21:00:55.423" Title="Using colon-commands inside ternary expression" Tags="|key-bindings|vimscript|command-line|undo-redo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15244" PostTypeId="2" ParentId="9212" CreationDate="2018-02-17T17:30:44.870" Score="1" Body="&lt;p&gt;There are 3 primary advantages I see&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use a consistent &lt;code&gt;regex&lt;/code&gt; engine/syntax:&lt;/strong&gt; Using &lt;code&gt;:grep/vimgrep&lt;/code&gt; allows you to define a &lt;code&gt;grepprg&lt;/code&gt;, which can be defined to &lt;code&gt;grep/ack/ag&lt;/code&gt; etc. Using this you can search the current buffer or multiple buffers/files, using a consistent &lt;code&gt;regex&lt;/code&gt; engine. On the other hand, if you use &lt;em&gt;vim’s&lt;/em&gt;&lt;code&gt;/pattern&lt;/code&gt; option, you are stuck on vim’s default regex engine, which has a different syntax compared to &lt;code&gt;extended regular expression&lt;/code&gt; syntax. So, anytime you have to search for an expression, you will have to think/remember whether you should use &lt;code&gt;\)&lt;/code&gt; or just &lt;code&gt;)&lt;/code&gt; and other differences. This can be very annoying (&lt;a href=&quot;https://stackoverflow.com/questions/3864467/whats-the-difference-between-vim-regex-and-normal-regex&quot;&gt;https://stackoverflow.com/questions/3864467/whats-the-difference-between-vim-regex-and-normal-regex&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;vimgrep populates a quickfix/location list&lt;/strong&gt;: using &lt;code&gt;:grep/vimgrep&lt;/code&gt; allows you to populate a search list. (&lt;a href=&quot;https://medium.com/@lakshmankumar12/quickfix-and-location-list-in-vim-ca0292ac894d&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://medium.com/@lakshmankumar12/quickfix-and-location-list-in-vim-ca0292ac894d&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do want to use the location list, you can use &lt;code&gt;]q&lt;/code&gt; shortcut to navigate it if you have Tim-Popes unimpaired plugin (&lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tpope/vim-unimpaired&lt;/a&gt;) &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;complicated searches while within vim&lt;/strong&gt;: typically if you have to do complicated searches you may have to use the command line. However, if you define the &lt;code&gt;greprg&lt;/code&gt; properly and use a command such as [1]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:vim /pattern1/ &lt;code&gt;find . -type f&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do very complicated searches and display the search results in your &lt;code&gt;location list&lt;/code&gt; or &lt;code&gt;quickfix list&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;[1] &lt;a href=&quot;http://vimcasts.org/episodes/search-multiple-files-with-vimgrep/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimcasts.org/episodes/search-multiple-files-with-vimgrep/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-02-17T17:30:44.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15245" PostTypeId="2" ParentId="14698" CreationDate="2018-02-17T18:06:41.383" Score="2" Body="&lt;p&gt;By any chance are you using Acronis True Image? I found that the new &quot;Active Protection&quot; they provide was causing exactly this problem. Going into Settings -&gt; Manage Processes and adding the full path to gvim.exe as a trusted application got rid of the problem.&lt;/p&gt;&#xA;" OwnerUserId="16383" LastActivityDate="2018-02-17T18:06:41.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15246" PostTypeId="2" ParentId="15243" CreationDate="2018-02-17T21:00:55.423" Score="7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;inoremap   (g == 0 ? :undo : :redo)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You are using an expression mapping, so you must return an expression, e.g. in your case a string describing the command you want Vim to perform. That means your mapping should look like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-_&amp;gt; &quot;\&amp;lt;C-o&amp;gt;&quot;.(g == 0 ? ':undo' : ':redo'). &quot;\&amp;lt;CR&amp;gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, even slightly simplified:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-_&amp;gt; &quot;\&amp;lt;c-o&amp;gt;&quot;.(g ? ':red' : ':u').&quot;\n&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing to note is, that I am not sure, that &lt;code&gt;&amp;lt;C-_&amp;gt;&lt;/code&gt; will actually work. This might or might not work, depending on whether you are using a Gui version of vim or whatever type of terminal you use. See also the &lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-20.5&quot; rel=&quot;noreferrer&quot;&gt;faq&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-02-17T21:00:55.423" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15247" PostTypeId="1" CreationDate="2018-02-18T18:49:46.237" Score="3" ViewCount="598" Body="&lt;p&gt;I often escape insert mode only to change the current line's indent by pressing &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; and then immediately go back to writing.&#xA;I wanted to make this easier, so I included these lines on my config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;tab&amp;gt; &amp;lt;esc&amp;gt;&amp;gt;&amp;gt;a&#xA;inoremap &amp;lt;S-tab&amp;gt; &amp;lt;esc&amp;gt;&amp;lt;&amp;lt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, for some reason, whenever you &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;, Vim moves the cursor to the start of the line as if you had pressed &lt;code&gt;^&lt;/code&gt;.&#xA;Is there a way to prevent this?&lt;/p&gt;&#xA;" OwnerUserId="16396" LastActivityDate="2020-06-06T15:45:14.253" Title="Is there a way to indent and outdent lines without moving the cursor?" Tags="|key-bindings|indentation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15248" PostTypeId="2" ParentId="15247" CreationDate="2018-02-18T18:55:09.703" Score="3" Body="&lt;p&gt;This behavior is determined by the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;startofline&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;'startofline'&lt;/a&gt; option. Set it to off, if you don't want that.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-02-18T18:55:09.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15249" PostTypeId="2" ParentId="15241" CreationDate="2018-02-18T19:07:27.903" Score="1" Body="&lt;p&gt;&lt;em&gt;Per the comments I'm offering this as a very rudimentary solution in case no one has a better suggestion. It's limited and hardly production grade. But OP asked to see it after I offered...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This function requires that there be no whitespace before or after the framing characters (&lt;code&gt;|&lt;/code&gt; in the first and last columns of your example). And it only works well with padding made up of spaces (!) ... with tabs it &lt;em&gt;might&lt;/em&gt; work but only with a fortuitous placement of the tabs. Hey, I'm an &lt;code&gt;expandtabs&lt;/code&gt; kind of guy, sorry. :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! CenterEmbedText()&#xA;    norm! 0&#xA;    let sp1 = searchpos('^\S*\zs\s', 'c')[1]&#xA;    let wd1 = searchpos('\S', 'z')[1]&#xA;    let sp2 = searchpos('\s\+\S\+$', 'zs')[1]&#xA;    let wd2 = searchpos('\s\zs\S', 'z')[1]&#xA;    let lm = wd1 - sp1&#xA;    let rm = wd2 - sp2&#xA;    let mm = abs(rm - lm) / 2&#xA;    if rm &amp;gt; lm&#xA;        exec 'norm! ' . sp2 . '|' . mm . 'x' . sp1 . '|p'&#xA;    elseif rm &amp;lt; lm&#xA;        let mm =  (mm == 0) ? 1 : mm&#xA;        exec 'norm! ' . sp2 . '|' . mm . &quot;i \&amp;lt;ESC&amp;gt;&quot; . sp1 . '|' . mm . 'x'&#xA;    endif&#xA;endfunc&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;c :call CenterEmbedText()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the mapping you can replace &lt;code&gt;&amp;lt;leader&amp;gt;c&lt;/code&gt; with whatever unused key combo you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function simply counts the spaces to the left and right of the text to center (stored in variables &lt;code&gt;lm&lt;/code&gt; and &lt;code&gt;rm&lt;/code&gt;) and balances things, if necessary, by deleting &lt;code&gt;mm&lt;/code&gt; spaces from one side and adding them to the other side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use just put the cursor anywhere on the line to modify and enter the mapped key sequence (&lt;kbd&gt;Space&lt;/kbd&gt; &lt;kbd&gt;C&lt;/kbd&gt; for me.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested it with text similar to your example and it works fine. Let me know if you have text for which it doesn't work and I'll take a look.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I noticed that when center falls between two columns this is inconsistent on whether it uses -1 or +1 as the center and I'll fix when I get a chance.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-02-18T23:44:09.133" LastActivityDate="2018-02-18T23:44:09.133" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15250" PostTypeId="2" ParentId="15247" CreationDate="2018-02-18T19:12:50.053" Score="2" Body="&lt;p&gt;Found it!&#xA;&lt;code&gt;&amp;lt;C-t&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; are used to indent and outdent from insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This snippet creates the behavior I was looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;tab&amp;gt; &amp;lt;C-t&amp;gt;&#xA;inoremap &amp;lt;S-tab&amp;gt; &amp;lt;C-d&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16396" LastActivityDate="2018-02-18T19:12:50.053" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15251" PostTypeId="1" AcceptedAnswerId="15253" CreationDate="2018-02-18T22:04:12.670" Score="1" ViewCount="370" Body="&lt;p&gt;After &lt;code&gt;:terminal&lt;/code&gt; runs, is there a way within Vim script to determine the type of shell that started with creation of the terminal ?  &lt;em&gt;within Vimscript, NOT via OS commands&lt;/em&gt; such as &lt;code&gt;ps&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="16177" LastActivityDate="2018-02-18T22:15:44.570" Title="How to know the shell started with :terminal?" Tags="|vimscript|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15252" PostTypeId="1" CreationDate="2018-02-18T22:12:34.090" Score="1" ViewCount="208" Body="&lt;p&gt;Every file I open in vim lately, even new empty files, as a ($p) at the beginning. This does not appear to be real - inserting text overwrites it, and once it's overwritten it does not return.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently reinstalled vim (through homebrew) and suspect that may have been the origin of the problem, but reinstalling again does not fix it. &lt;code&gt;vim -U NONE&lt;/code&gt; still adds the characters to the beginning as well, which from what .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea what might be doing this, or how to fix it. It's easy enough to ignore, but I can't help but wonder what's causing it.&lt;/p&gt;&#xA;" OwnerUserId="16398" LastActivityDate="2018-02-18T22:12:34.090" Title="Why are [$p] characters appearing at the beginning of every file?" Tags="|echo|" AnswerCount="0" CommentCount="1" ClosedDate="2018-02-19T22:43:51.970" ContentLicense="CC BY-SA 3.0" />
  <row Id="15253" PostTypeId="2" ParentId="15251" CreationDate="2018-02-18T22:15:44.570" Score="3" Body="&lt;p&gt;From &lt;code&gt;:help :terminal&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        If [command] is not given the 'shell' option is used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can retrieve the shell executable which will be run with &lt;code&gt;&amp;amp;shell&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to get the command line used to start the terminal, irrespective of &lt;code&gt;'shell'&lt;/code&gt;, just use the buffer name, e.g.,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:terms = term_list()&#xA;let l:bufname = empty(l:terms) ? '' : bufname(l:terms[-1])&#xA;let l:shell = substitute(l:bufname, '^!', '', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-02-18T22:15:44.570" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15254" PostTypeId="1" AcceptedAnswerId="15256" CreationDate="2018-02-18T22:52:58.870" Score="0" ViewCount="159" Body="&lt;p&gt;I am editing a source code in &lt;em&gt;language1&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't have a built-in syntax highliting configuration into my vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, its syntax is very similar to &lt;em&gt;language2&lt;/em&gt;, which has. I think, syntax highliting the sources as &lt;em&gt;language2&lt;/em&gt; would be pretty okay for me. Thus, I tried to set up the syntax highliting of &lt;em&gt;language2&lt;/em&gt; to the files with extensions of &lt;em&gt;language1&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Checking the syntax highliting configuration of my distribution-provided vim (&lt;code&gt;filetype.vim&lt;/code&gt;), I found the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.&amp;lt;ext2&amp;gt;  setf language2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus, I inserted a line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.&amp;lt;ext1&amp;gt;  setf language2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into my local &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, nothing happened. My source files - in &lt;em&gt;language1&lt;/em&gt; - are still un-syntax highlited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is it so? How could I make it working?&lt;/p&gt;&#xA;" OwnerUserId="28" LastActivityDate="2018-02-18T23:53:37.450" Title="How to affect the syntax highliting filetype from local vimrc?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15255" PostTypeId="1" AcceptedAnswerId="15257" CreationDate="2018-02-18T22:55:14.877" Score="1" ViewCount="814" Body="&lt;p&gt;I transitioned to Dvorak so now I'm remapping the keys on Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the decisions are remap &lt;code&gt;q&lt;/code&gt; to &lt;code&gt;d&lt;/code&gt;, so I wrote the following on &lt;code&gt;~/.config/nvim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap q d &#xA;noremap qq dd&#xA;noremap Q D&#xA;noremap qt dk&#xA;noremap qh dj&#xA;noremap qw dw&#xA;noremap qe de&#xA;noremap q0 d0&#xA;noremap q$ d$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this doesn't work if you use a number, such as &lt;code&gt;q2w&lt;/code&gt;. Typing &lt;code&gt;q&lt;/code&gt; makes the editor waiting, and then typing &lt;code&gt;2&lt;/code&gt; triggers a single delete, and then typing &lt;code&gt;w&lt;/code&gt; just moves the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is practically unfeasible to map every number combination (&lt;code&gt;q3w&lt;/code&gt;, &lt;code&gt;q4w&lt;/code&gt;, etc...). Is there any way to remap all the number combinations together?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2018-02-19T06:02:06.523" Title="How can I remap Vim keys with numbers?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15256" PostTypeId="2" ParentId="15254" CreationDate="2018-02-18T23:53:37.450" Score="2" Body="&lt;p&gt;A quick solution is to just replace &lt;code&gt;setf&lt;/code&gt; with &lt;code&gt;set filetype&lt;/code&gt; in the line in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.&amp;lt;ext1&amp;gt;  set filetype=language2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is explained in &lt;code&gt;:help ftdetect&lt;/code&gt; but it is quite difficult understand.  In this specific case the reason is very simple- that vim has already used &lt;code&gt;setf&lt;/code&gt; to set a file type for &lt;code&gt;ext1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose &lt;code&gt;ext1=ts&lt;/code&gt;.  In &lt;code&gt;/usr/share/vim/vim80/filetype.vim&lt;/code&gt;, we see,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Qt Linguist translation source and Qt User Interface Files are XML&#xA;au BufNewFile,BufRead *.ts,*.ui         setf xml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means any following &lt;code&gt;setf&lt;/code&gt; issued in &lt;code&gt;autocmd&lt;/code&gt;s will fail:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setf[iletype] [FALLBACK] {filetype}            *:setf* *:setfiletype*&#xA;        Set the 'filetype' option to {filetype}, but only if&#xA;        not done yet in a sequence of (nested) autocommands.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-02-18T23:53:37.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15257" PostTypeId="2" ParentId="15255" CreationDate="2018-02-19T05:49:03.717" Score="3" Body="&lt;p&gt;If all you want to do is have &quot;q&quot; work like &quot;d&quot; when you enter Normal mode commands then you can use the &lt;code&gt;'langmap'&lt;/code&gt; setting. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set langmap=qd,QD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;q2w&lt;/code&gt; will work exactly the same as &lt;code&gt;d2w&lt;/code&gt;. The mapping is also applied in Visual mode. In all other modes nothing changes, &quot;q&quot; is &quot;q&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h lmap&lt;/code&gt; because there are a couple potentially important details (e.g. what to do if there is any interference with any of your mappings.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are reams of information out there on using Vim with a Dvorak keyboard, BTW. The &lt;a href=&quot;http://vim.wikia.com/wiki/Using_Vim_with_the_Dvorak_keyboard_layout&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Wiki&lt;/a&gt; is one example.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-02-19T06:02:06.523" LastActivityDate="2018-02-19T06:02:06.523" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15259" PostTypeId="2" ParentId="15241" CreationDate="2018-02-19T16:25:31.737" Score="1" Body="&lt;h3&gt;Re-centering with a substitution or &quot;how I learned to abuse regex backtracking&quot;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;For giggles you can do this with a &lt;code&gt;:substitution&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v\|\zs(\s*)(.{-})(\s*)\ze\|/\=substitute(submatch(1).submatch(3),'\v(\s*)(\1\s=)','\1'.escape(submatch(2),'&amp;amp;~').'\2','')/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Overview&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Capture the text and the leading and trailing characters, spaces in this case. We use a sub-replace-expression to do another substitution to divide up the spaces in half. This balancing act is done via the regex engine's backtracking because math is hard (let's go shopping).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using very magic, &lt;code&gt;\v&lt;/code&gt;, to simplify regex. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27magic%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'magic'&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Using a sub-replace-expression, &lt;code&gt;\=&lt;/code&gt;. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h sub-replace-expression&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;{-}&lt;/code&gt; is a non-greedy version of &lt;code&gt;*&lt;/code&gt;. Similar to &lt;code&gt;*?&lt;/code&gt; in Perl-speak. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#E60&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\{-&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Learn more about this regex trick here: &lt;a href=&quot;https://stackoverflow.com/a/15844169/438329&quot;&gt;An easy way to center text between first and last non-white word in vim?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Using &lt;code&gt;\zs&lt;/code&gt; &amp;amp; &lt;code&gt;\ze&lt;/code&gt; to set start and end of matching text&lt;/li&gt;&#xA;&lt;li&gt;Possibly use &lt;code&gt;:keeppatterns&lt;/code&gt; to prevent side-effects.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Probably best to make this into a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -range -bar CenterCells keeppatterns &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;s/\v\|\zs(\s*)(.{-})(\s*)\ze\|/\=substitute(submatch(1).submatch(3),'\v(\s*)(\1\s=)','\1'.escape(submatch(2),'&amp;amp;~').'\2','')/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:s&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :s&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h sub-replace-expression&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#submatch()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h submatch()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#escape()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h escape()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27magic%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'magic'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#E60&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\{-&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5C=&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\=&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5Czs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\zs&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:command&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :command&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Centering with &lt;code&gt;:Tabularize&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You need to set the start and end of the matches with &lt;code&gt;\zs&lt;/code&gt; &amp;amp; &lt;code&gt;\ze&lt;/code&gt;. Use the &lt;code&gt;c&lt;/code&gt; flag for centering.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Tabularize/|\s*\zs.\{-}\ze\s*|/c1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-02-19T16:55:44.227" LastActivityDate="2018-02-19T16:55:44.227" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15260" PostTypeId="1" AcceptedAnswerId="15266" CreationDate="2018-02-19T16:45:17.410" Score="0" ViewCount="63" Body="&lt;p&gt;I am a Vim newbie with one week experience and I'm already enjoying it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've successfully written an (ugly) command+function+mapping with which I can extract some code to a new variable in JavaScript. This is my code, it works with motions (\jsexviw) and selection in visual mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range -nargs=1 JsExVar normal `&amp;lt;v`&amp;gt;d^[i&amp;lt;args&amp;gt;^[Ovar &amp;lt;args&amp;gt; = (^[pa);^[&#xA;&#xA;function! FnJsExVar(type)&#xA;    silent exec 'JsExVar '.input(&quot;Variable name: &quot;)&#xA;endfunction&#xA;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;jsexv &quot;:JsExVar &quot;.input(&quot;Variable name: &quot;).&quot;&amp;lt;cr&amp;gt;&quot;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;jsexv :set opfunc=FnJsExVar&amp;lt;CR&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I still don't fully understand the different ways of executing things, so I assume the code can be improved and cleaned a lot. Thanks in advance for any correction and suggestion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;----- EDIT ------&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've refactored a bit to avoid duplicated input(&quot;Variable name: &quot;) but now I have a weird (0) param when calling the function from the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range JsExVar call ExecJsExVar(0) &#xA;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;jsexv &quot;:JsExVar&amp;lt;cr&amp;gt;&quot;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;jsexv :set opfunc=ExecJsExVar&amp;lt;CR&amp;gt;g@&#xA;&#xA;function! ExecJsExVar(type)&#xA;    let varname = input(&quot;Variable name: &quot;)&#xA;    silent exec &quot;normal `&amp;lt;v`&amp;gt;di&quot;.varname.&quot;^[&quot;&#xA;    silent exec &quot;normal Ovar &quot;.varname.&quot; = ^[&quot;&#xA;    silent exec &quot;normal pa;^[&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;----- (more) EDIT ------&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, it wasn't really working with motions. I think this works... but the question is: can this be done with one function?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range JsExVar call JavascriptExtractVariable(0) &#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;jsxv :JsExVar&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;jsxv :set opfunc=JavascriptExtractVariable2&amp;lt;CR&amp;gt;g@&#xA;&#xA;function! JavascriptExtractVariable(type)&#xA;    let varname = input(&quot;Variable name: &quot;)&#xA;    silent exec &quot;normal `&amp;lt;v`&amp;gt;di&quot;.varname.&quot;&quot;&#xA;    silent exec &quot;normal Ovar &quot;.varname.&quot; = (&quot;&#xA;    silent exec &quot;normal pa);&quot;&#xA;endfunction&#xA;&#xA;function! JavascriptExtractVariable2(type)&#xA;    let varname = input(&quot;Variable name: &quot;)&#xA;    silent exec &quot;normal `[v`]di&quot;.varname.&quot;&quot;&#xA;    silent exec &quot;normal Ovar &quot;.varname.&quot; = (&quot;&#xA;    silent exec &quot;normal pa);&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(re-edited because wrong code)&lt;/p&gt;&#xA;" OwnerUserId="16411" LastEditorUserId="1841" LastEditDate="2018-02-20T07:43:40.287" LastActivityDate="2018-02-20T11:15:12.470" Title="Extract JavaScript variable (feature example): how to improve it?" Tags="|functions|object-motions|user-commands|user-input|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15261" PostTypeId="1" CreationDate="2018-02-19T19:32:19.617" Score="2" ViewCount="1207" Body="&lt;p&gt;Sorry if this is the wrong place to ask this, I'm new to the site :/ I asked the same question in TeX StackExchange, and I was pointed here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My issue is this: when editing in vim, my syntax file highlights underscores and carets when found in non-math text, which is fine, except vim doesn't recognize that &quot;align&quot; is a math environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A user in TeX StackExchange suggested that I take a look at my &lt;code&gt;tex.vim&lt;/code&gt; syntax file. I don't have one in &lt;code&gt;~/.vim&lt;/code&gt;, but I do have one in &lt;code&gt;/usr/share/vim/vim74/syntax/&lt;/code&gt;. There seems to be no real difference in the way &lt;code&gt;align&lt;/code&gt; and &lt;code&gt;equation&lt;/code&gt; are treated in the syntax file, yet Vim highlights only &lt;code&gt;equation&lt;/code&gt; and not &lt;code&gt;align.&lt;/code&gt; How might I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UqJZz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UqJZz.png&quot; alt=&quot;how do I fix this??&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16413" LastActivityDate="2018-08-19T04:03:58.393" Title="How do I make vim highlight math properly in the align environment?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15262" PostTypeId="1" AcceptedAnswerId="15263" CreationDate="2018-02-19T21:01:31.633" Score="0" ViewCount="63" Body="&lt;p&gt;In my experience with vim I found relative numbers pretty useful. But I would like to know if is there an argument I could give to the my neovim configuration file so I could configure it in such way that &lt;strong&gt;relative numbers stay the same but in the current line number it actually displays the line I am at and not just the number 0&lt;/strong&gt;. Any help would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="16330" LastEditorUserId="16330" LastEditDate="2018-02-25T19:15:08.933" LastActivityDate="2018-02-25T19:15:08.933" Title="Having a modified relativenumber" Tags="|options|line-numbers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15263" PostTypeId="2" ParentId="15262" CreationDate="2018-02-19T21:21:10.240" Score="2" Body="&lt;p&gt;That's my everyday configuration. Just set both of these...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set relativenumber&#xA;:set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If, for example, the cursor is on line 50 you'd see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;..&#xA; 2&#xA; 1&#xA;50&#xA; 1&#xA; 2&#xA;..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's it!&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-02-19T21:21:10.240" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15264" PostTypeId="2" ParentId="15261" CreationDate="2018-02-20T00:13:07.777" Score="1" Body="&lt;p&gt;This may or may not apply to you since you're using vim version 7.4, but the following is true for the current vim version (&lt;code&gt;8.0.1525&lt;/code&gt; as I write this).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometime recently, syntax support for LaTeX packages such as &lt;code&gt;amsmath&lt;/code&gt; was removed from the default syntax files.  As far as I know these syntax files are now only available here &lt;a href=&quot;http://www.drchip.org/astronaut/vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.drchip.org/astronaut/vim/&lt;/a&gt;; scroll down to &quot;Latex Package Support&quot; (or direct link to &lt;a href=&quot;http://www.drchip.org/astronaut/vim/vbafiles/amsmath.vba.gz&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin vimball for amsmath&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can install a different latex filetype plugin which has support for amsmath syntax, for example &lt;a href=&quot;https://github.com/lervag/vimtex/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt;.  This plugin does &lt;em&gt;much&lt;/em&gt; more than just syntax highlighting though.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-02-20T00:13:07.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15266" PostTypeId="2" ParentId="15260" CreationDate="2018-02-20T03:53:27.630" Score="0" Body="&lt;p&gt;Using &lt;a href=&quot;https://stackoverflow.com/questions/8994276/defining-a-new-vim-operator-with-a-parameter/8998136#8998136&quot;&gt;this answer&lt;/a&gt; I've been able to make it work without the command and with one function. And I learnt what that argument was for, how to use optional arguments and the func-range modifier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;jsxv :call JsExtractVariable(visualmode(), 1)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;jsxv :set opfunc=JsExtractVariable&amp;lt;CR&amp;gt;g@&#xA;function! JsExtractVariable(vt, ...) range&#xA;    let varname = input(&quot;Variable name: &quot;)&#xA;    silent exec &quot;normal &quot;.SelectByMode(a:0).&quot;di&quot;.varname.&quot;^[&quot;&#xA;    silent exec &quot;normal Ovar &quot;.varname.&quot; = (^[pa);^[&quot;&#xA;endfunction&#xA;&#xA;function! SelectByMode(isvisual)&#xA;    return (a:isvisual ? &quot;`&amp;lt;v`&amp;gt;&quot; : &quot;`[v`]&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I post this as an answer because it's the kind of improvement I was looking for. Any other suggestion will be welcome, thanks.&lt;/p&gt;&#xA;" OwnerUserId="16411" LastEditorUserId="16411" LastEditDate="2018-02-20T04:06:02.277" LastActivityDate="2018-02-20T04:06:02.277" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15267" PostTypeId="1" AcceptedAnswerId="15268" CreationDate="2018-02-20T07:36:09.750" Score="0" ViewCount="492" Body="&lt;p&gt;I have this mapping to surround a Word with jQuery id selector &lt;code&gt;$(&quot;#...&quot;)&lt;/code&gt; and it works fine using a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! JqId normal viwo^[i#^[ysiW&quot;ysiW)i$^[E&#xA;nnoremap &amp;lt;Leader&amp;gt;jqid :JqId&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I cannot make it works only with the mapping, it inserts the &lt;code&gt;$&lt;/code&gt; sign, but the vim-surround commands do nothing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;jqid viwo^[i#^[ysiW&quot;ysiW)i$^[E&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also tried this (for testing purposes) and it doesn't work either:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;jqid ysiW&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any hint? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="16411" LastEditorUserId="1841" LastEditDate="2018-02-20T08:38:03.483" LastActivityDate="2018-02-20T15:11:55.233" Title="Mapping using tpope/vim-surround only works with command" Tags="|key-bindings|plugin-vim-surround|user-commands|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15268" PostTypeId="2" ParentId="15267" CreationDate="2018-02-20T07:53:22.090" Score="2" Body="&lt;p&gt;&lt;em&gt;EDIT&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your mapping doesn't work because you are in a rare case where you want to use &lt;code&gt;nmap&lt;/code&gt; instead of &lt;code&gt;nnoremap&lt;/code&gt;: You want to use in a mapping an already defined mapping. Using &lt;code&gt;nnoremap&lt;/code&gt; you said to Vim &quot;use the default behavior of &lt;code&gt;ysiW&quot;&lt;/code&gt;&quot; instead of &quot;use the behavior defined by a plugin&quot;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If I understand your mapping correctly you want to be able to transform&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$(&quot;#foo&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim surround is useful when you need to provide a different character to surround your word, here you know that you will always use it with the same characters so you could just use built-in motions. For example something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;yourkey&amp;gt; bi$(&quot;#&amp;lt;Esc&amp;gt;ea&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping will work if you are not on the first character of the word it would need a bit of work to be more robust but what I want to say with this answer is don't use a plugin if you don't actually need it.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-02-20T08:38:49.027" LastActivityDate="2018-02-20T08:38:49.027" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15269" PostTypeId="1" CreationDate="2018-02-20T10:41:11.850" Score="1" ViewCount="166" Body="&lt;p&gt;I'm writing a client for Neovim. The rpc api has a &lt;code&gt;nvim_ui_try_resize({width}, {height})&lt;/code&gt; method to resize the screen of Neovim instance. But I need to set the exact size of the editable area (excluding tabbar header, sign column, numbers column, cmdline, statusbar, etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first question is: is it possible to set the size of the editable area directly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And as I expect a &quot;No&quot; as the answer to my first question my second question is: is it possible to query the size of the editable area? (so that I can set it by trial and error)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want hacky solutions, I need something that will still work after Neovim upgrades.&lt;/p&gt;&#xA;" OwnerUserId="7153" LastEditorUserId="1841" LastEditDate="2018-02-20T12:12:48.007" LastActivityDate="2018-02-20T12:12:48.007" Title="How to set/get size of editable area in a neovim client" Tags="|neovim|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15270" PostTypeId="2" ParentId="15260" CreationDate="2018-02-20T11:01:06.817" Score="0" Body="&lt;p&gt;Here's a couple of things you might not already know:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Including Special Characters in String Constants&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Instead of inserting special characters literally, by typing e.g. &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;, you can use the forms described in &lt;code&gt;:help string&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent exec &quot;normal Ovar &quot;.varname.&quot; = (\&amp;lt;Esc&amp;gt;pa);\&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes it easier to see what the code is doing when viewed in contexts which do not highlight the special characters, and is better for cut and paste (I had to edit all the ESC characters in your code when copying it into my &lt;code&gt;.vimrc&lt;/code&gt; to try it out)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Simple Variable Extraction&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This isn't really the sort of information you were looking for, but you can perform a more basic version of your edits by using &lt;kbd&gt;Ctrl-A&lt;/kbd&gt; in insert mode to insert the previously inserted text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From visual mode:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Type &lt;code&gt;c&lt;/code&gt; followed by your new variable name and press &lt;kbd&gt;Esc&lt;/kbd&gt; to leave insert mode.&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;Ovar&lt;/code&gt; (including the trailing space)&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;Ctrl-A&lt;/kbd&gt; to add in the variable name again.&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;= ;&amp;lt;Esc&amp;gt;&lt;/code&gt; (including the leading space) to complete the line.&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;P&lt;/kbd&gt; to &lt;code&gt;put&lt;/code&gt; the value of the new variable before the semi-colon.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To do the same from normal mode, simply add in the motion after you press &lt;kbd&gt;c&lt;/kbd&gt; in step 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could of course extract Steps 2&amp;ndash;5 into a normal mode mapping which you could then use after performing step 1 manually (from either visual or normal mode):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;nnoremap &amp;lt;Leader&amp;gt;jsxv Ovar \&amp;lt;C-A&amp;gt; = ;\&amp;lt;Esc&amp;gt;P&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-20T11:15:12.470" LastActivityDate="2018-02-20T11:15:12.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15271" PostTypeId="2" ParentId="15191" CreationDate="2018-02-20T11:41:20.690" Score="1" Body="&lt;p&gt;------ EDIT ------&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry, I think I've mistaken the functionality of BackupDir... maybe what you need it's to call copy on BufWinLeave (?):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufWinLeave * :!cp % %.bak&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Re-Edit As @Rich has suggested in comments, it seems easier to use :w instead of :!cp. Also the &lt;a href=&quot;http://vim.wikia.com/wiki/Cycle_through_buffers_including_hidden_buffers&quot; rel=&quot;nofollow noreferrer&quot;&gt;SwitchToNextBuffer() function here&lt;/a&gt; could be needed to iterate over all buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;------ original answer ------&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Disclaimer: I'm a ultra-noob, but) I looked for &quot;vim manual backup&quot; (&lt;a href=&quot;https://superuser.com/questions/1135293/possible-to-make-a-backup-of-original-file-in-vim&quot;&gt;found this BackupDir() function&lt;/a&gt;) and &quot;vim on quit event&quot; (&lt;a href=&quot;https://stackoverflow.com/questions/20386219/automatically-run-script-when-exiting-vim&quot;&gt;found this&lt;/a&gt;) so maybe something like that would work (I didn't try):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BackupDir()&#xA;   if has('win32') || has('win64')&#xA;      let l:backupdir=$VIM.'/backup/'.&#xA;               \substitute(expand('%:p:h'), '\:', '~', '')&#xA;   else&#xA;      let l:backupdir=$HOME.'/.vim/backup/'.&#xA;               \substitute(expand('%:p:h'), '^'.$HOME, '~', '')&#xA;   endif&#xA;&#xA;   if !isdirectory(l:backupdir)&#xA;      call mkdir(l:backupdir, 'p', 0700)&#xA;   endif&#xA;&#xA;   let &amp;amp;backupdir=l:backupdir&#xA;   let &amp;amp;backupext=strftime('~%Y-%m-%d_%H-%M-%S~')&#xA;endfunction&#xA;&#xA;autocmd! BufWinLeave * call BackupDir()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16411" LastEditorUserId="16411" LastEditDate="2018-02-20T12:04:52.743" LastActivityDate="2018-02-20T12:04:52.743" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15274" PostTypeId="2" ParentId="15267" CreationDate="2018-02-20T15:11:55.233" Score="0" Body="&lt;p&gt;Alternatively you can setup a customized &quot;surrounding&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:surround_{char2nr('i')} = &quot;$(\&quot;#\r\&quot;)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use the &quot;i&quot; surrounding with all your surrounding operators, &lt;code&gt;ys&lt;/code&gt;, insert mode &lt;code&gt;&amp;lt;c-s&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;c-g&amp;gt;s&lt;/code&gt;, visual mode (&lt;code&gt;S&lt;/code&gt;), etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h surround-customizing&#xA;:h curly-braces-names&#xA;:h :let&#xA;:h char2nr()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-02-20T15:11:55.233" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15275" PostTypeId="5" CreationDate="2018-02-20T15:29:18.903" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2018-02-20T15:29:18.903" LastActivityDate="2018-02-20T15:29:18.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15276" PostTypeId="4" CreationDate="2018-02-20T15:29:18.903" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2018-02-20T15:29:18.903" LastActivityDate="2018-02-20T15:29:18.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15277" PostTypeId="1" CreationDate="2018-02-20T16:24:09.670" Score="1" ViewCount="179" Body="&lt;p&gt;I have a substitute expression to find words beginning with a dollar signs and capture them like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\$\(.*\)\&amp;gt;//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However there are a lot of escape sequences in the regular expression (4). Is there a way to avoid so many escapes in this expression?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-02-20T16:46:09.273" Title="Avoid so much escaping in substitution expression" Tags="|regular-expression|substitute|escape|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15278" PostTypeId="2" ParentId="15277" CreationDate="2018-02-20T16:37:56.987" Score="2" Body="&lt;p&gt;You could use a &quot;very magic&quot; expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v\$(.*)&amp;gt;//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(See &lt;code&gt;:help \v&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd also note that your expression doesn't do what you say you want it to do. For example, it includes the &quot;bar&quot; in this match: &quot;$foo bar&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe try this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v\$(\S+)//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-20T16:43:28.773" LastActivityDate="2018-02-20T16:43:28.773" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15279" PostTypeId="2" ParentId="15277" CreationDate="2018-02-20T16:40:58.900" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;'magic'&lt;/code&gt; or &lt;code&gt;\zs&lt;/code&gt; to reduce the need for escaping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/$\zs.*\&amp;gt;//g&#xA;:%s/$\zs\k*//g&#xA;:%s/\v\$(\k*)//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;code&gt;\k&lt;/code&gt; to capture anything that looks like a keyword as that will more than likely be what you want and will remove the need for &lt;code&gt;\&amp;gt;&lt;/code&gt;. With &lt;code&gt;\zs&lt;/code&gt; your capture group is now &lt;code&gt;\0&lt;/code&gt;/&lt;code&gt;&amp;amp;&lt;/code&gt;. The &lt;code&gt;$&lt;/code&gt; often does not need to be escaped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;:%s/$\zs.*\&amp;gt;//g&lt;/code&gt; may be too greedy if you want to capture just &lt;code&gt;$foo&lt;/code&gt;. It will instead capture &lt;code&gt;$foo bar&lt;/code&gt;. This maybe desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h /\zs&#xA;:h /\v&#xA;:h 'magic'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-02-20T16:46:09.273" LastActivityDate="2018-02-20T16:46:09.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15280" PostTypeId="1" AcceptedAnswerId="15304" CreationDate="2018-02-20T16:49:33.527" Score="2" ViewCount="1542" Body="&lt;p&gt;I am using &lt;code&gt;system()&lt;/code&gt; to change a buffer's file.  I apply the same change to the buffer itself.  I can't just reload the buffer because there are other unsaved changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I come to write the buffer, Vim gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WARNING: The file has changed since reading it!!!&#xA;Do you really want to write to it (y/n)?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do really want to write to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I avoid this warning?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried adding a &lt;code&gt;FileChangedShell&lt;/code&gt; autocmd which doesn't do anything, but it does not get fired for &lt;code&gt;system()&lt;/code&gt; calls.  So I added a &lt;code&gt;silent execute ':!'&lt;/code&gt;, which seems to trigger the autocmd, but the screen gets all messed up – and vim still shows the warning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2018-02-21T12:53:17.953" Title="How to avoid &quot;file has changed&quot; warning when writing buffer?" Tags="|external-command|save|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15282" PostTypeId="2" ParentId="15191" CreationDate="2018-02-20T18:44:24.803" Score="1" Body="&lt;p&gt;Isn't it simpler to use a wrapper that'll do exactly that? You might want to check for permissions in final solution but proof of concept:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;&#xA;CURRENT=&quot;$1&quot;&#xA;BACKUP=&quot;$1&quot;.backup&#xA;&#xA;cp &quot;$CURRENT&quot; &quot;$BACKUP&quot;&#xA;vi &quot;$CURRENT&quot;&#xA;vimdiff &quot;$BACKUP&quot; &quot;$CURRENT&quot;&#xA;rm &quot;$BACKUP&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;None of the commands is forked so shell will wait for execution of the previous line to finish before invoking the next one, seems exactly as what you need. Save it to &lt;code&gt;~/bin/vimbak&lt;/code&gt; and add permissions to run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;chmod u+x ~/bin/vimbak&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then just:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimbak file_you_want_to_edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2719" LastEditorUserId="2719" LastEditDate="2018-02-26T15:16:38.527" LastActivityDate="2018-02-26T15:16:38.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15283" PostTypeId="2" ParentId="15191" CreationDate="2018-02-20T19:42:51.430" Score="3" Body="&lt;p&gt;I'm pretty sure it's not possible to use Vim's &lt;code&gt;backup&lt;/code&gt; feature to do this, so instead I've written a proof of concept that achieves your goal (of being able to see the changes made since the beginning of the session) more directly, with autocommands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It writes out a file containing the current contents of the buffer when the buffer is read, and then deletes it when you unload the buffer (with e.g. &lt;code&gt;:bdelete&lt;/code&gt; or by quitting Vim).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyInitialState&#xA;  au!&#xA;  au BufReadPost * call CreateInitialState()&#xA;  au BufUnload * call DeleteInitialState()&#xA;augroup END&#xA;&#xA;function! CreateInitialState() abort&#xA;  let file_name = BackupFileName('&amp;lt;afile&amp;gt;')&#xA;  if filewritable(file_name) == 1 ||&#xA;      \ (!glob(file_name) &amp;amp;&amp;amp;&#xA;      \ filewritable(fnamemodify(file_name, ':p:h')) == 2)&#xA;    execute &quot;write!&quot; file_name&#xA;  endif&#xA;endfunction&#xA;&#xA;function! DeleteInitialState() abort&#xA;  let file_name = BackupFileName('&amp;lt;afile&amp;gt;')&#xA;  if filewritable(file_name) == 1&#xA;    call delete(file_name)&#xA;  endif&#xA;endfunction&#xA;&#xA;function! BackupFileName(file_name) abort&#xA;  return expand(a:file_name) . '.initstate'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will need a bit of tidying up if you want a really robust solution&amp;#8202;&amp;mdash;&amp;#8202;for example it doesn't really work with Vim's default &lt;code&gt;:set nohidden&lt;/code&gt; (one solution would be to keep a list of backup files and delete them all when quitting Vim instead of individually on buffer unload), and I'd imagine there will be edge cases that need handling&amp;#8202;&amp;mdash;&amp;#8202;but it should be enough to get you started.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Extra Credit&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here's a &lt;code&gt;:CompareInitialState&lt;/code&gt; command you can use to check your current file content against your &quot;backups&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CompareInitialState() abort&#xA;  let file_name = BackupFileName('%')&#xA;  diffthis&#xA;  vnew&#xA;  setlocal buftype=nofile&#xA;  setlocal bufhidden=delete&#xA;  setlocal noswapfile&#xA;  execute &quot;read&quot; file_name&#xA;  1delete&#xA;  diffthis&#xA;  wincmd p&#xA;endfunction&#xA;&#xA;command! CompareInitialState :call CompareInitialState()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Older version&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here's my initial version that I wrote before it occurred to me that you don't actually need the &quot;backup&quot; file to exist when you're not in Vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyInitialState&#xA;  au!&#xA;  au BufReadPost * write! &amp;lt;afile&amp;gt;.initstate&#xA;  au BufUnload * call DeleteInitial()&#xA;augroup END&#xA;&#xA;function! DeleteInitial() abort&#xA;  let file_name = expand('&amp;lt;afile&amp;gt;') . '.initstate'&#xA;  echom file_name&#xA;  if filewritable(file_name)&#xA;    call delete(file_name)&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-23T10:29:01.653" LastActivityDate="2018-02-23T10:29:01.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15284" PostTypeId="2" ParentId="14883" CreationDate="2018-02-20T22:13:21.047" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;set&lt;/code&gt; to set an environment variable for the current Command prompt window, so the following is a slightly closer equivalent to your Unix command than setting the environment variable globally in the GUI:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set NVIM_LISTEN_ADDRESS=/some/path&#xA;nvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-20T22:13:21.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15285" PostTypeId="1" AcceptedAnswerId="15286" CreationDate="2018-02-20T22:18:58.973" Score="0" ViewCount="2126" Body="&lt;p&gt;In the &lt;code&gt;~/.vimrc&lt;/code&gt; the clipboard has been enabled:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard=unnamed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But after hitting &lt;code&gt;v&lt;/code&gt; for Visual &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/csBD7m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/csBD7m.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and then hitting &lt;code&gt;y&lt;/code&gt; (yank)  then &lt;code&gt;escape&lt;/code&gt; there is no contents in the clipboard.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XiRUWm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XiRUWm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://www.python.org/about/gettingstarted/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.python.org/about/gettingstarted/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What else needs to be done?&lt;/p&gt;&#xA;" OwnerUserId="16428" LastEditorUserId="16428" LastEditDate="2018-02-20T23:04:55.493" LastActivityDate="2018-02-20T23:07:45.883" Title="Copying to clipboard with clipboard=unnamed set" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15286" PostTypeId="2" ParentId="15285" CreationDate="2018-02-20T23:07:45.883" Score="2" Body="&lt;p&gt;Using &lt;code&gt;clipboard=unnamed&lt;/code&gt; requires that your copy of Vim has system clipboard support built in. You can check this with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo has('clipboard')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or simply by inspecting the output of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-20T23:07:45.883" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15287" PostTypeId="1" AcceptedAnswerId="15288" CreationDate="2018-02-20T23:36:26.733" Score="0" ViewCount="87" Body="&lt;p&gt;If I run this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:user_config=fnamemodify('user.vim', ':p')&#xA;echom s:user_config&#xA;if filereadable(&quot;s:user_config&quot;)&#xA;  echom 'this is true'&#xA;else&#xA;  echom 'this is false'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the result will be: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/root/vim_test/user.vim&#xA;this is false&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even though there is a valid file at the path. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why this is happening? Am I passing the variables wrongly? &lt;/p&gt;&#xA;" OwnerUserId="7010" LastActivityDate="2018-02-20T23:50:37.423" Title="passing local script variables to viml functions" Tags="|functions|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15288" PostTypeId="2" ParentId="15287" CreationDate="2018-02-20T23:50:37.423" Score="3" Body="&lt;p&gt;You're testing whether the file literally named &quot;s:user_config&quot; exists. Try this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if filereadable(s:user_config)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-02-20T23:50:37.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15292" PostTypeId="1" AcceptedAnswerId="15297" CreationDate="2018-02-21T08:49:32.680" Score="1" ViewCount="238" Body="&lt;p&gt;I want to add this string &quot;&lt;code&gt;declare(strict_types=1);&lt;/code&gt;&quot; after &lt;code&gt;&amp;lt;?php&lt;/code&gt; when I save or open a file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;declare(strict_types=1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the file already contains &lt;code&gt;declare(strict_types=1);&lt;/code&gt; don't do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe there is a plugin or something?&#xA;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="3302" LastEditorUserId="1841" LastEditDate="2018-02-21T10:57:45.613" LastActivityDate="2023-11-02T03:11:57.613" Title="How to add specific string if it is not exists in current file?" Tags="|vimscript|text-generation|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15293" PostTypeId="1" CreationDate="2018-02-21T08:52:09.047" Score="1" ViewCount="692" Body="&lt;p&gt;How can I get the effect of multiple &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;s being pressed when I press &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; once?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current config requires me to press &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; twice to switch to Normal mode: once to close the completion pop-up and again to switch to Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I tried (and it didn't work):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap &amp;lt;ESC&amp;gt; &amp;lt;ESC&amp;gt;&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I am using NeoVim version 0.2.2&lt;/p&gt;&#xA;" OwnerUserId="16436" LastEditorUserId="1841" LastEditDate="2018-02-21T10:41:14.427" LastActivityDate="2018-03-23T10:58:11.977" Title="Multiple &lt;ESC&gt; with a single &lt;ESC&gt;" Tags="|key-bindings|neovim|plugin-deoplete|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15295" PostTypeId="2" ParentId="15293" CreationDate="2018-02-21T09:41:53.640" Score="3" Body="&lt;p&gt;For future references, I would suggest you to always use &lt;code&gt;noremap&lt;/code&gt; version of vim keymapping. Otherwise, the mappings get remapped. For example when you map like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap &amp;lt;Esc&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your mapped &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; gets again mapped to two more &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. So it would probably be recursive. So, instead do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;Esc&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will cancel remapping in the mapped keys.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="21" LastEditDate="2018-02-21T09:44:41.883" LastActivityDate="2018-02-21T09:44:41.883" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15296" PostTypeId="2" ParentId="15189" CreationDate="2018-02-21T10:11:29.683" Score="3" Body="&lt;p&gt;I think it's from the  Plug 'ryanoasis/vim-devicons' plugin. You probably need their specific patched fonts along with powerline fonts to work it. Because powerline fonts doesn't cover the huge list of fonts used in the awesome fonts.&#xA;Personally, I would be way away from these extra burdens just to get some icons in the terminal. So, please remove 'ryanoasis/vim-devicons' plugin and see if the problem goes away. If it does, then you can go ahead and find out how to work the plugin like the way you want to. Let me know what happened, Ok?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2018-02-21T10:11:29.683" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15297" PostTypeId="2" ParentId="15292" CreationDate="2018-02-21T10:55:51.557" Score="2" Body="&lt;p&gt;Something like this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AddPHPStrictTypes()&#xA;    &quot; Save the cursor position&#xA;    let cursor_save = getpos('.')&#xA;&#xA;    &quot; Go to the begining of the file&#xA;    call cursor(1, 1)&#xA;&#xA;    &quot; Get the line containing &quot;&amp;lt;?php&quot;&#xA;    let phpLine = search('&amp;lt;?php')&#xA;&#xA;    &quot; If the declaration isn't in the buffer and there is one line containing &quot;&amp;lt;?php&quot;&#xA;    if search('&amp;lt;?php\ndeclare(strict_types=1);') == 0 &amp;amp;&amp;amp; phpLine != 0&#xA;        &quot; Add the declaration after the line&#xA;        call append(phpLine, &quot;declare(strict_types=1);&quot;)&#xA;    endif&#xA;&#xA;    &quot; Restore cursor position&#xA;    call setpos('.', cursor_save)&#xA;endfunction&#xA;&#xA;&#xA;autocmd! BufReadPost *php call AddPHPStrictTypes()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We declare a function which searches for the declaration. If the declaration is not found it search for the line containing &lt;code&gt;&amp;lt;?php&lt;/code&gt; and add the declaration after it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we use an autocommand to execute the function each time you open a new php file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To understand the function better you may want to read&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getpos%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getpos()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#setpos%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h setpos()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#cursor%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h cursor()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#search%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h search()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#append%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h append()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And to change the autocommand:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#%3aautocmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :autocmd&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-events&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h autocmd-events&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-02-21T11:52:56.007" LastActivityDate="2018-02-21T11:52:56.007" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15298" PostTypeId="1" AcceptedAnswerId="15302" CreationDate="2018-02-21T11:39:36.273" Score="0" ViewCount="724" Body="&lt;p&gt;I want to search in Vi for two tabs but not for three or more tabs. I tried several things like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\t\t\(\t\)@!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But nothing works. Any idea?&lt;/p&gt;&#xA;" OwnerUserId="9517" LastEditorUserId="1841" LastEditDate="2018-02-21T12:00:11.190" LastActivityDate="2018-02-21T12:05:36.647" Title="Search for 2 but not for 3 tab characters" Tags="|search|tab-characters|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15299" PostTypeId="1" AcceptedAnswerId="15301" CreationDate="2018-02-21T11:41:29.970" Score="0" ViewCount="975" Body="&lt;p&gt;Suppose I have the following code:   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:user_config=fnamemodify('user.vim', ':p')&#xA;echom 'file found: ' . s:user_config&#xA;if filereadable(s:user_config)  &#xA;  source s:user_config&#xA;else&#xA;  echom s:user_config . 'was not found'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I run this, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;file found: /home/ninrod/vim_test/user.vim&#xA;Error detected while processing /home/ninrod/vim_test/test.vim:&#xA;line    4:&#xA;E484: Can't open file s:user_config&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;on the echo line, the variable &lt;code&gt;s:user_config&lt;/code&gt; was correctly interpolated. How do I tell vim to interpolate the &lt;code&gt;s:user_config&lt;/code&gt; on the source line? &lt;/p&gt;&#xA;" OwnerUserId="7010" LastActivityDate="2018-02-21T12:12:38.610" Title="How to correctly use a local script variable" Tags="|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15301" PostTypeId="2" ParentId="15299" CreationDate="2018-02-21T11:58:07.560" Score="2" Body="&lt;p&gt;As it is written, your code will execute literally &lt;code&gt;source s:user_config&lt;/code&gt; and you want to execute &lt;code&gt;source [content of the variable]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;execute()&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;source &quot; . s:user_config&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :execute&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe[cute] {expr1} ..   Executes the string that results from the evaluation&#xA;            of {expr1} as an Ex command.&#xA;            Multiple arguments are concatenated, with a space in&#xA;            between.  To avoid the extra space use the &quot;.&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-02-21T11:58:07.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15302" PostTypeId="2" ParentId="15298" CreationDate="2018-02-21T12:05:36.647" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;:/\t\t(\t)@!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your regular expression is almost valid, except that you need to use &lt;code&gt;\@&lt;/code&gt; instead of &lt;code&gt;@&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However first note, that using &lt;code&gt;:/&lt;/code&gt; means the cursor will be put on the line matching the regular expression (this is usually used as an address, see &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3A%2F&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :/&lt;/code&gt;&lt;/a&gt;), which is different from searching. For searching use the &lt;code&gt;/&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, using &lt;code&gt;\t\{2\}\t\@!&lt;/code&gt; should work, but note, that this will match lines having more than two tabs, because the match would simply start at a later &lt;code&gt;\t&lt;/code&gt;. So you need to anchor your match at the beginning to match non-tabs as well. Something like this might work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\%([^\t]\|^\)\zs\t\{2\}\t\@!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which comes down to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/         - start a search command&#xA;\%(...\)  - start a group&#xA;[^\t]     - match a non-tab&#xA;\|        - OR&#xA;^         - start of line&#xA;\zs       - start match now (not the previous char)&#xA;\t\{2\}   - at least 2 tabs&#xA;\t\@!     - not followed by another tab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can use &lt;code&gt;/\t\@&amp;lt;!\t\{2\}\t\@!&lt;/code&gt; which is similar to the previous expression, except that it uses a zero-width negative look-behind assertion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that those look-around assertions can be slow in Vim.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-02-21T12:05:36.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15303" PostTypeId="2" ParentId="15299" CreationDate="2018-02-21T12:12:38.610" Score="1" Body="&lt;p&gt;I'm not sure you're aware of it, but most of the time we don't need to do what you're trying to achieve the way you're doing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you respect vim standard way of organizing scripts, if you drop your file into &lt;code&gt;~/.vim/plugin/&lt;/code&gt; it'll be automatically loaded. You cannot know when (regarding the load order of all the scripts in the same directory -- it seems to be sorted lexicographically nowadays), but it'll be loaded. This also means: drop your configuration files in &lt;code&gt;~/.vim&lt;/code&gt; not in &lt;code&gt;~/vim_test&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a mapping/command/abbreviation defined in that plugin, you can enforce its load with &lt;code&gt;:runtime plugin/user.vim&lt;/code&gt;. Don't forget to add inclusion guards to avoid the script to be loaded twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a function from the plugin, then make it an autoload plugin, drop it in: &lt;code&gt;~/.vim/autoload&lt;/code&gt;. Prefix the function name with the plugin name, like &lt;code&gt;user#my_function()&lt;/code&gt;, and simply call that function from where you need it: &lt;code&gt;call user#my_function(parameters)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't described the situation with filetype specific configuration, but it isn't much different.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-02-21T12:12:38.610" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15304" PostTypeId="2" ParentId="15280" CreationDate="2018-02-21T12:53:17.953" Score="1" Body="&lt;p&gt;One solution is to store the contents of the buffer, reload the file (to make vim happy), then restore the contents.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let lastline = line('$')&#xA;let bufcontents = getline(1, lastline)&#xA;edit!&#xA;call setline(1, bufcontents)&#xA;if line('$') &amp;gt; lastline&#xA;  execute lastline+1.',$:d _'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2018-02-21T12:53:17.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15306" PostTypeId="1" CreationDate="2018-02-21T16:26:24.477" Score="0" ViewCount="576" Body="&lt;p&gt;Is there a way to operate on a specific column of data without specifying the exact column number but only the column number? For example, if I have data like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc   123  45.6  jkq&#xA;df    456   7.8  sfladf&#xA;ghij   92  98.0  adad&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to do something on the third column (whitespace delimited), for example a search and replace. How can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\%25c\d\+/xyz/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or something like that if I know the exact column is 25, but if I do not know the exact column and just specify the 3rd column which is whitespace delimited, how can I do that?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-02-21T19:12:12.143" Title="Operate on third column of data" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15307" PostTypeId="2" ParentId="594" CreationDate="2018-02-21T17:01:44.387" Score="1" Body="&lt;p&gt;You can try this plugin: &lt;a href=&quot;https://github.com/junegunn/vim-easy-align&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-easy-align&lt;/a&gt;.      &lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-02-21T17:01:44.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15308" PostTypeId="1" AcceptedAnswerId="15316" CreationDate="2018-02-21T17:18:03.807" Score="2" ViewCount="230" Body="&lt;p&gt;Not sure how to align the first column with EasyAlign.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Visual select below two lines and &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;*&lt;/kbd&gt;&lt;kbd&gt;space&lt;/kbd&gt;    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   wr_strobe &amp;lt;= abc dc asdf  &#xA;            rd_strobe &amp;lt;= asd sdfk asdfasd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Only first column is not aligned.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   wr_strobe          &amp;lt;= abc dc   asdf&#xA;            rd_strobe &amp;lt;= asd sdfk asdfasd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-02-22T07:45:39.463" Title="How to align first column with vim-easy-align?" Tags="|plugin-easy-align|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15309" PostTypeId="2" ParentId="15306" CreationDate="2018-02-21T17:27:23.467" Score="1" Body="&lt;p&gt;This is a very very rough sketch of how to do it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First construct your search pattern, that is add the appropriate number of whitespace delimited columns in front of your pattern, then add your pattern then add something to fix the pattern at the next whitespace separated pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a simple proof of concept, that needs a lot more error management and probably also fix a couple of corner cases (one being how to find the same regex several times in your column)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetColumnPat(pat, nr)&#xA;    let start='^\%(\S\+\s\+\)'&#xA;    let end='\S*'&#xA;    let pat=start.&#xA;    \ '\{'.(a:nr-1).'\}'.&#xA;    \ '.\{-\}\zs'. a:pat. '\ze.\{-\}'.&#xA;    \ end&#xA;    return pat&#xA;endfunction&#xA;&#xA;function! SearchC(arg)&#xA;    try&#xA;        let args=split(a:arg, a:arg[0])&#xA;        if len(args) != 2&#xA;            throw &quot;unexpected input&quot;&#xA;        endif&#xA;    catch&#xA;        echo &quot;Unexpected input&quot;&#xA;    endtry&#xA;    let arg=escape(args[0], '/')&#xA;    let a=GetColumnPat(arg, args[1])&#xA;    let @/=a&#xA;    try&#xA;        exe &quot;norm! n&quot;&#xA;    catch /^Vim\%((\a\+)\)\=:E486/&#xA;        echoerr &quot;Pattern '&quot;. a:args[0]. &quot;not found&quot;&#xA;    endtry&#xA;endfu&#xA;&#xA;:com! -nargs=+ SearchInColumn :call SearchC(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use &lt;code&gt;:SearchInColumn /foobar/4&lt;/code&gt; to search for foobar in the fourth column. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I implemented a similar command in my &lt;a href=&quot;https://github.com/chrisbra/csv.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;csv plugin&lt;/a&gt;, see the definition of the &lt;a href=&quot;https://github.com/chrisbra/csv.vim/blob/master/ftplugin/csv.vim#L279-L334&quot; rel=&quot;nofollow noreferrer&quot;&gt;SearchColumn()&lt;/a&gt; function. It still suffers from the &lt;strong&gt;find several times the same thing in the same column&lt;/strong&gt; problem and I haven't found a good way around it. Despite that, it surprisingly works well in enough in practice and I haven't received many complaints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach might be to visually select the region you need to search, open it up in a new window and do your search (and possible replace) there. You can use my &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn/&quot; rel=&quot;nofollow noreferrer&quot;&gt;NrrwRgn plugin&lt;/a&gt; for that&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-02-21T17:27:23.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15310" PostTypeId="2" ParentId="15306" CreationDate="2018-02-21T19:12:12.143" Score="2" Body="&lt;p&gt;I think this sounds like a job for awk. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ awk 'sub(/[0-9]+/, &quot;foo&quot;, $3)' input.txt &amp;gt; output.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using inside of Vim via filter, &lt;code&gt;:!&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!awk 'sub(/[0-9]+/, &quot;foo&quot;, $3)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: this will effect the output whitespace. May want to adjust &lt;code&gt;OFS&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-02-21T19:12:12.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15311" PostTypeId="1" CreationDate="2018-02-21T19:31:36.180" Score="-1" ViewCount="106" Body="&lt;p&gt;In the Vim documentation, it says that \r &quot;matches &amp;lt; CR &gt;&quot;, however for the result of replacement I could not find in the documentation a description of what it does. For example, imagine this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\n/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On a unix system I know that this will replace newlines (0x0A) with newlines (0x0A) because on unix systems pressing &amp;lt; CR &gt; produces a 0x0A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, what does it do on a Windows system? Will it replace 0x0A with 0x0A 0x0D (the Windows end of line)?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-02-21T20:03:45.257" Title="Is \r operating system specific?" Tags="|substitute|replace|encoding|escape|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15312" PostTypeId="2" ParentId="15311" CreationDate="2018-02-21T20:03:45.257" Score="4" Body="&lt;p&gt;No, that is not true. Internally, &lt;code&gt;\n&lt;/code&gt; will always match the line termination of a buffer regardless of whether the actual file uses &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;CR&amp;gt;&amp;lt;NL&amp;gt;&lt;/code&gt; as line terminator (e.g. the &lt;code&gt;'fileformat'&lt;/code&gt;) option does not matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a replace command however, the &lt;code&gt;\r&lt;/code&gt; in the replace part will always produce an actual new line, since the &lt;code&gt;\n&lt;/code&gt; will insert a ASCII-NUL 0x0 into the buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is one of the implementation details, that can be seen on certain operations. Some of it is explained at &lt;a href=&quot;https://vimhelp.appspot.com/pattern.txt.html#CR-used-for-NL&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h CR-used-for-NL&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.appspot.com/pattern.txt.html#NL-used-for-Nul&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h NL-used-for-NUL&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How the newline will finally being converted on writing the buffer, is determined by the &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#&amp;#39;fileformat&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;'fileformat'&lt;/a&gt; option.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-02-21T20:03:45.257" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15316" PostTypeId="2" ParentId="15308" CreationDate="2018-02-22T07:45:39.463" Score="3" Body="&lt;p&gt;The reason for this is that the default setting of vim-easy-align is to keep the current indentation. You can get the desired alignment with &lt;code&gt;ga&amp;lt;c-i&amp;gt;*&amp;lt;space&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find the EasyAlignLign feature to be very useful for this sort of thing. If you map e.g. &lt;code&gt;gA&lt;/code&gt; to &lt;code&gt;&amp;lt;plug&amp;gt;(LiveEasyAlign)&lt;/code&gt;, then visually select your text and do &lt;code&gt;gA&lt;/code&gt;. Now you can see how your current settings work. E.g., &lt;code&gt;gA*&amp;lt;space&amp;gt;&amp;lt;c-i&amp;gt;&amp;lt;space&amp;gt;&lt;/code&gt; would give the same result as above, except you would see the changes as you apply the settings.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-02-22T07:45:39.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15317" PostTypeId="2" ParentId="594" CreationDate="2018-02-22T09:34:53.700" Score="2" Body="&lt;p&gt;Here's another method that doesn't use any plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First replace the spaces with much bigger spaces. No need to be precise: just mash the &lt;kbd&gt;Space&lt;/kbd&gt; key a bunch of times:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/ /        /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now trim them all to be the same length:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm! 10|dw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only tricky part is knowing what count to use. For this example it's fairly easy, The longest line contains a 7 letter word: &lt;code&gt;epsilon&lt;/code&gt; plus 2 more characters (a colon and a space), so you need to use a count of 9 + 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more complicated alignments you might benefit by having your current cursor position displayed in your statusline (or by using something like &lt;code&gt;getcurpos()&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can just position the cursor manually on each line and use normal-mode &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; &lt;a href=&quot;https://stackoverflow.com/a/28414916/328936&quot;&gt;by hand&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use this technique &lt;a href=&quot;https://stackoverflow.com/a/8363443/328936&quot;&gt;in a macro&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqf:a    &amp;lt;Esc&amp;gt;10|dw+q4@q&#xA;     └──┤&#xA;        └─ Mash space bar here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-22T10:02:58.137" LastActivityDate="2018-02-22T10:02:58.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15318" PostTypeId="1" AcceptedAnswerId="15319" CreationDate="2018-02-22T11:45:07.773" Score="8" ViewCount="1624" Body="&lt;p&gt;I'm using the following key binding to visually select the current paragraph.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;v }kV{j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is works as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;}&lt;/code&gt; Move below the current paragraph.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;k&lt;/code&gt; Move one line up.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt; Start line-based visual selection.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;{&lt;/code&gt; Move above the current paragraph.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; Move one line down.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This works well except for the last paragraph in the file. If there is no empty line below the current paragraph &lt;code&gt;}&lt;/code&gt; stops at the last line inside the paragraph. The following &lt;code&gt;k&lt;/code&gt; results in the last line of the paragraph not being included in the selection. The same problem occurs with the very first paragraph in the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make this key binding to also work for paragraphs at the top of bottom of the document?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a text object for this?&lt;/p&gt;&#xA;" OwnerUserId="3255" LastEditorUserId="1292" LastEditDate="2018-08-17T09:50:56.637" LastActivityDate="2018-08-17T09:50:56.637" Title="Key binding to select the current paragraph" Tags="|key-bindings|cursor-motions|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15319" PostTypeId="2" ParentId="15318" CreationDate="2018-02-22T11:52:02.400" Score="14" Body="&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#ip&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h ip&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#ap&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h ap&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You are looking for the built in &lt;code&gt;vip&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#text-objects&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h text-objects&lt;/code&gt;&lt;/a&gt; is a good start to find the text objects you are looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; To address your comment: to move the cursor to one end or the other end of the current visual selection you can simply use &lt;code&gt;o&lt;/code&gt; in visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#v_o&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h v_o&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-02-22T12:23:33.693" LastActivityDate="2018-02-22T12:23:33.693" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15321" PostTypeId="2" ParentId="14887" CreationDate="2018-02-22T19:30:08.210" Score="1" Body="&lt;p&gt;I didn't find any ready-to-use solution so I began to write it. The actual version can find &lt;a href=&quot;https://svn.uzsolt.hu/homefiles/vimfiles/trunk/after/syntax/make.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. It's only a complement to main &lt;code&gt;syntax/make.vim&lt;/code&gt; so should place into &lt;code&gt;~/.vim/after/syntax&lt;/code&gt; directory.&lt;/p&gt;&#xA;" OwnerUserId="11418" LastActivityDate="2018-02-22T19:30:08.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15322" PostTypeId="1" AcceptedAnswerId="15323" CreationDate="2018-02-23T02:30:06.767" Score="2" ViewCount="469" Body="&lt;p&gt;Given these file names, I want to get the corresponding value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Chart.js          =&amp;gt; C.j&#xA;chart.js          =&amp;gt; c.j&#xA;chart-type.js     =&amp;gt; ct.j&#xA;ChartType.js      =&amp;gt; CT.j&#xA;_chart-type.scss  =&amp;gt; ct.s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my vimscript which only returns the first letter.&lt;br&gt;&#xA;As you can see my main motivation is to shorten names in airline tabline extension.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! airline#extensions#tabline#formatters#default#format(bufnr, buffers)&#xA;      return strpart(fnamemodify(bufname(a:bufnr), ':t'), 0, 1)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16460" LastActivityDate="2018-02-23T06:55:16.943" Title="Vimscript, how to shorten a filename?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15323" PostTypeId="2" ParentId="15322" CreationDate="2018-02-23T03:43:33.270" Score="4" Body="&lt;p&gt;I tried this code (written in &lt;code&gt;/tmp/vim.vim&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! Shorten_filename() abort&#xA;    let bufname = fnamemodify(bufname('%'), ':t')&#xA;    let tokens = split(bufname, '\ze\u\|[-_]')&#xA;    call map(tokens, {i,v -&amp;gt; matchstr(v, '\a')})&#xA;    let ext = fnamemodify(bufname, ':e')&#xA;    return join(tokens, '').(!empty(ext) ? '.'.ext[0] : '')&#xA;endfu&#xA;&#xA;set laststatus=2&#xA;set stl+=%{Shorten_filename()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then started Vim like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -Nu /tmp/vim.vim Chart.js chart.js chart-type.js ChartType.js _chart-type.scss&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And executed &lt;code&gt;:next&lt;/code&gt; to review each buffer in the argument list. The statusline displayed successively:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;C.j&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;c.j&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ct.j&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;CT.j&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ct.s&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, I guess you could try it as a base for your script. Maybe something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! airline#extensions#tabline#formatters#default#format(bufnr, buffers)&#xA;    let bufname = fnamemodify(bufname(a:bufnr), ':t')&#xA;    let tokens = split(bufname, '\ze\u\|[-_]')&#xA;    call map(tokens, {i,v -&amp;gt; matchstr(v, '\a')})&#xA;    let ext = fnamemodify(bufname, ':e')&#xA;    return join(tokens, '').(!empty(ext) ? '.'.ext[0] : '')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15612" LastEditorUserId="15612" LastEditDate="2018-02-23T06:55:16.943" LastActivityDate="2018-02-23T06:55:16.943" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15324" PostTypeId="1" AcceptedAnswerId="15328" CreationDate="2018-02-23T08:50:45.820" Score="9" ViewCount="6803" Body="&lt;p&gt;If I run &lt;code&gt;cat&lt;/code&gt; under terminal (xterm-256color), and then press the up arrow button, I see &lt;code&gt;^[[A&lt;/code&gt; as output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I press &lt;code&gt;&amp;lt;ctrl-v&amp;gt;&lt;/code&gt; &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt; in vim insert mode, I see &lt;code&gt;^[OA&lt;/code&gt; as output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So i wonder why the byte sequence &lt;code&gt;^[[A&lt;/code&gt; will become &lt;code&gt;^[OA&lt;/code&gt;, is there any internal key code translation in vim?&lt;/p&gt;&#xA;" OwnerUserId="16438" LastActivityDate="2018-02-23T14:56:43.660" Title="Up arrow key code, why '^[[A' becomes '^[OA'?" Tags="|terminal|escape|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15325" PostTypeId="1" AcceptedAnswerId="15329" CreationDate="2018-02-23T09:28:29.403" Score="2" ViewCount="697" Body="&lt;p&gt;I would like to set &lt;code&gt;set spell&lt;/code&gt; whenever I open a &lt;code&gt;tex&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first attempt is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType tex setlocal spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;code&gt;setlocal&lt;/code&gt; here because I may open other files in new tabs after opening a &lt;code&gt;tex&lt;/code&gt; file and I don't want &lt;code&gt;spell&lt;/code&gt; in the new files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works well, but I notice that if I open another &lt;code&gt;tex&lt;/code&gt; file in new tab, the &lt;code&gt;spell&lt;/code&gt; is not enabled. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd TabEnter,FileType tex setlocal spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it does not work.&lt;/p&gt;&#xA;" OwnerUserId="16463" LastEditorUserId="16463" LastEditDate="2018-02-23T09:35:26.710" LastActivityDate="2018-02-23T15:35:31.300" Title="Using `TabEnter` and `FileType` in the same `autocmd`" Tags="|autocmd|spell-checking|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15326" PostTypeId="1" CreationDate="2018-02-23T09:43:12.127" Score="1" ViewCount="155" Body="&lt;p&gt;I use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2508&quot; rel=&quot;nofollow noreferrer&quot;&gt;DBGp Remote Debugger Interface&lt;/a&gt; for debuggign in vim. which works excellent, but it's missing some things that I would like to have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a watch variable features (most important)&lt;/li&gt;&#xA;&lt;li&gt;auto complete when evaluating an expression&lt;/li&gt;&#xA;&lt;li&gt;going through previous expression evaluation history&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;any recommendations on other vim debugging plugins that have these?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UFbjj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UFbjj.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14510" LastActivityDate="2018-02-23T09:43:12.127" Title="how to set a watch in the vim debugger" Tags="|vimrc|plugin-system|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15327" PostTypeId="2" ParentId="15325" CreationDate="2018-02-23T09:43:41.193" Score="0" Body="&lt;p&gt;I've got the desired behavior using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPre *.tex setlocal spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16463" LastActivityDate="2018-02-23T09:43:41.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15328" PostTypeId="2" ParentId="15324" CreationDate="2018-02-23T09:49:59.690" Score="14" Body="&lt;p&gt;You can paste Vim's builtin termcap database in the current buffer with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;put =execute('set termcap')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In it, you should find the text &lt;code&gt;t_ku &amp;lt;Up&amp;gt; ^[OA&lt;/code&gt;, which means that when you press &lt;code&gt;Up&lt;/code&gt;, the terminal will send &lt;code&gt;Esc O A&lt;/code&gt;. Or you could just execute &lt;code&gt;:echo &amp;amp;t_ku&lt;/code&gt;, to get the value of the terminal option &lt;code&gt;'t_ku'&lt;/code&gt; (see &lt;code&gt;:h t_ku&lt;/code&gt;). It should display &lt;code&gt;^[OA&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know all the details about why there's a difference between &lt;code&gt;$ cat&lt;/code&gt; and Vim, but you may be interested in these links:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://invisible-island.net/xterm/xterm.faq.html#xterm_arrows&quot; rel=&quot;noreferrer&quot;&gt;xterm arrows&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-PC-Style-Function-Keys&quot; rel=&quot;noreferrer&quot;&gt;PC-Style Function Keys&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here's an excerpt from the first link:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;VTxxx (VT100 and up) terminals may send different escape sequences for the cursor (arrow) keys depending on how they are set up. The choices are referred to as the normal and application modes. Initially, the terminal is in normal mode.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;VTxxx terminals are usually set up so that full-screen applications will use the cursor application mode strings. This is good for full-screen applications, including legacy applications which may have hard-coded behavior, but bad for interactive shells (e.g., ksh, tcsh, bash) which use arrow keys to scroll through a history of command strings.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;To see the difference between normal/application modes, consider this example:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;In normal (non-application) mode, the terminal transmits a down-arrow as \E[C, which happens to echo as a down-arrow.&lt;/li&gt;&#xA;  &lt;li&gt;In application mode the terminal transmits \EOC, which echoes as C. That is because the \EO is the SS3 control, which says to use the character from the G3 character set for the next cell.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And here's a table from the second one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The cursor keys transmit the following escape sequences depending on the&#xA;mode specified via the DECCKM escape sequence.&#xA;&#xA;              Key            Normal     Application&#xA;              -------------+----------+-------------&#xA;              Cursor Up    | CSI A    | SS3 A&#xA;              Cursor Down  | CSI B    | SS3 B&#xA;              Cursor Right | CSI C    | SS3 C&#xA;              Cursor Left  | CSI D    | SS3 D&#xA;              -------------+----------+-------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, it seems that the terminal is in “normal mode” when you are in the shell, and in “application mode” when you are in a full-screen application such as Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you press &lt;code&gt;Up&lt;/code&gt;, the terminal sends the sequence:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(if it's in normal mode) &lt;code&gt;CSI A&lt;/code&gt;, where &lt;code&gt;CSI&lt;/code&gt; means &lt;code&gt;Control Sequence Introducer&lt;/code&gt; and is produced by &lt;code&gt;ESC [&lt;/code&gt;; in caret notation, the whole sequence is displayed as &lt;code&gt;^[[A&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;(if it's in application mode) &lt;code&gt;SS3 A&lt;/code&gt;, where &lt;code&gt;SS3&lt;/code&gt; is described as &lt;code&gt;Single Shift Select of G3 Character Set&lt;/code&gt; &lt;a href=&quot;http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-C1-_8-Bit_-Control-Characters&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, and is produced by &lt;code&gt;ESC O&lt;/code&gt;; in caret notation, the whole sequence is displayed as &lt;code&gt;^[OA&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also probably find these 2 sequences, &lt;code&gt;Esc [ A&lt;/code&gt; and &lt;code&gt;Esc O A&lt;/code&gt;, in the &lt;code&gt;xterm-256color&lt;/code&gt; entry of your terminfo database:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ infocmp -x xterm-256color | vim -R -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inside this buffer, if you look for the capabilities &lt;code&gt;cuu1&lt;/code&gt; and &lt;code&gt;kcuu1&lt;/code&gt;, you should find:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cuu1=\E[A&#xA;kcuu1=\EOA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;man terminfo&lt;/code&gt;, these capabilities are described as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   cursor_up              cuu1                    up               up one line&#xA;   key_up                 kcuu1                   ku               up-arrow key&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As rightly pointed out by &lt;a href=&quot;https://vi.stackexchange.com/questions/15324/up-arrow-key-code-why-a-becomes-oa#comment26247_15328&quot;&gt;@Rich&lt;/a&gt;, in the shell, you can make the terminal enter the application mode by sending the sequence stored in the &lt;code&gt;smkx&lt;/code&gt; capability. To do so, you may execute &lt;code&gt;$ tput smkx&lt;/code&gt;. And to make it re-enter the normal mode, you may execute &lt;code&gt;$ tput rmkx&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you could temporarily make the &lt;code&gt;Up&lt;/code&gt; key produce &lt;code&gt;Esc O A&lt;/code&gt; like in Vim, if you executed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ tput smkx&#xA;$ cat&#xA;  Up&#xA;  C-c&#xA;$ tput rmkx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;smkx&lt;/code&gt; and &lt;code&gt;rmkx&lt;/code&gt; capabilities are also described in &lt;code&gt;man terminfo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;keypad_xmit         smkx        ks        enter 'keyboard_transmit' mode&#xA;keypad_local        rmkx        ke        leave 'keyboard_transmit' mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason, here, the application mode is called &lt;code&gt;keyboard_transmit&lt;/code&gt; mode. In Vim, it's called &lt;code&gt;keypad transmit&lt;/code&gt; mode (see &lt;code&gt;:h t_ks&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="15612" LastEditorUserId="15612" LastEditDate="2018-02-23T14:56:43.660" LastActivityDate="2018-02-23T14:56:43.660" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15329" PostTypeId="2" ParentId="15325" CreationDate="2018-02-23T15:35:31.300" Score="6" Body="&lt;h1&gt;Frame Challenge : Using Vim &quot;Properly&quot;&lt;sup&gt;1&lt;/sup&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd&lt;/code&gt; is &lt;em&gt;NOT&lt;/em&gt; the solution to &lt;code&gt;filetype&lt;/code&gt;-dependent settings. It might seem like a good candidate at first, but Vim was built after the Unix philosophy of placing files in defined directory structure to affect behavior. Most vim users learn about vimrc first. But there are more (see &lt;code&gt;:help rtp&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What this means for the OP is as follows : Tex &lt;code&gt;filetype&lt;/code&gt;-dependent settings, mappings, &amp;amp;c. should be placed in&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;~/.vim/ftplugin/tex.vim&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;E.g., create &lt;code&gt;~/.vim/ftplugin/tex.vim&lt;/code&gt; with the contents&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to have Tex files get &lt;code&gt;spell&lt;/code&gt; on. Note I used &lt;code&gt;setlocal&lt;/code&gt; to make it buffer specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find that something in these files conflicts with other settings, you should place the offending line in &lt;code&gt;~/.vim/after/ftplugin/tex.vim&lt;/code&gt; to have it override any other settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, make sure you at least enable filetype plugins with &lt;code&gt;filetype plugin on&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Further Resources&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help filetype&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help ft-tex-syntax&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help ft-tex-ftplugin&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I put &quot;properly&quot; in quotes because at times, when speaking about the Vim philosophy, I've been told its powerful configurability means there is no &quot;right&quot; way to use it. I disagree—I admit there are lots of creative ways to use a saw, but it was originally meant to cut things (wood mostly).&lt;/li&gt;&#xA;&lt;li&gt;The original version of this answer came from my own post &lt;a href=&quot;https://vi.stackexchange.com/a/15019/10604&quot;&gt;here&lt;/a&gt;. I do not consider them explicit duplicates, however.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-02-23T15:35:31.300" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15330" PostTypeId="1" AcceptedAnswerId="15332" CreationDate="2018-02-23T16:31:46.867" Score="2" ViewCount="596" Body="&lt;pre&gt;&lt;code&gt;export MANPAGER=&quot;nvim +set\ filetype=man -&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have this under my shell configuration, I've been using neovim as my man pager and one thing I love most is its table of contents functionality, pressing &lt;code&gt;gO&lt;/code&gt; or by calling &lt;code&gt;man#show_toc()&lt;/code&gt; function. Currently when I open a man page with &lt;code&gt;man fzf&lt;/code&gt; command for example, pressing &lt;code&gt;gO&lt;/code&gt; would bring location list at the bottom of the window like this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/CYbnG.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and the thing I want to see is this,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mjYe3.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but it should be open automatically every time when I run man command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call man#show_toc() | quit&#xA;vertical topleft lopen&#xA;vertical resize 40&#xA;setlocal nonumber norelativenumber&#xA;wincmd p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could do by entering these commands by hand or putting them in a file named &lt;code&gt;ftplugin/man.vim&lt;/code&gt; but still it doesn't feel right, such like syntax highlighting doesn't work. Is there any better way to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="9211" LastActivityDate="2018-02-23T20:43:53.513" Title="How can I automate this, open location list and set its position for man filetype?" Tags="|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15331" PostTypeId="2" ParentId="7378" CreationDate="2018-02-23T16:51:19.893" Score="1" Body="&lt;p&gt;I had this same issue then I typed &lt;code&gt;:help hardmode&lt;/code&gt;Lo and behold I found&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'g:HardMode_level' If set to 'wannabe' &#xA;arrow keys disabled, but not   hjkl etc.                                                                                              &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By the way I am one of the vim beginners that found this plugin extremely helpful since it really pushed me away from the mouse. &lt;/p&gt;&#xA;" OwnerUserId="16471" LastEditorUserId="16471" LastEditDate="2018-02-23T18:22:38.680" LastActivityDate="2018-02-23T18:22:38.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15332" PostTypeId="2" ParentId="15330" CreationDate="2018-02-23T17:08:41.020" Score="2" Body="&lt;p&gt;You could try to install an autocmd listening to &lt;code&gt;FileType qf&lt;/code&gt;, which would check whether the title of the location window is &lt;code&gt;Man TOC&lt;/code&gt;, and which would reposition the latter on the far left of the screen (+ resize it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup reposition_man_toc&#xA;    au!&#xA;    au FileType qf  call s:reposition_man_toc()&#xA;augroup END&#xA;&#xA;fu! s:reposition_man_toc() abort&#xA;    let title = get(getloclist(0, {'title':1}), 'title', '')&#xA;    if title isnot# 'Man TOC'&#xA;        return&#xA;    endif&#xA;    wincmd H&#xA;    vert resize 40&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want the location window to be automatically opened, &lt;a href=&quot;https://vi.stackexchange.com/questions/15330/how-can-i-automate-this-open-location-list-and-set-its-position-for-man-filetyp#comment26261_15332&quot;&gt;as you suggested&lt;/a&gt;, you could also try to add a 2nd autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType man call man#show_toc()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which would give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup reposition_man_toc&#xA;    au!&#xA;    au FileType man  call man#show_toc()&#xA;    au FileType qf  call s:reposition_man_toc()&#xA;augroup END&#xA;&#xA;fu! s:reposition_man_toc() abort&#xA;    let title = get(getloclist(0, {'title':1}), 'title', '')&#xA;    if title isnot# 'Man TOC'&#xA;        return&#xA;    endif&#xA;    wincmd H&#xA;    vert resize 40&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or maybe you could install a single autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup open_toc&#xA;    au!&#xA;    au FileType  man  call s:open_toc()&#xA;augroup END&#xA;&#xA;fu! s:open_toc() abort&#xA;    call man#show_toc()&#xA;    let title = get(getloclist(0, {'title':1}), 'title', '')&#xA;    if title isnot# 'Man TOC'&#xA;        return&#xA;    endif&#xA;    wincmd H&#xA;    vert resize 40&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As rightly pointed out by &lt;a href=&quot;https://vi.stackexchange.com/questions/15330/how-can-i-automate-this-open-location-list-and-set-its-position-for-man-filetyp#comment26268_15332&quot;&gt;Christian Brabandt&lt;/a&gt;, you could simplify the code by using the window-local variable &lt;code&gt;w:quickfix_title&lt;/code&gt;, and eliminate the call to &lt;code&gt;getloclist()&lt;/code&gt;. It would give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup open_toc&#xA;    au!&#xA;    au FileType  man  call s:open_toc()&#xA;augroup END&#xA;&#xA;fu! s:open_toc() abort&#xA;    call man#show_toc()&#xA;    if w:quickfix_title isnot# 'Man TOC'&#xA;        return&#xA;    endif&#xA;    wincmd H&#xA;    vert resize 40&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15612" LastEditorUserId="15612" LastEditDate="2018-02-23T20:43:53.513" LastActivityDate="2018-02-23T20:43:53.513" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15333" PostTypeId="1" AcceptedAnswerId="15334" CreationDate="2018-02-23T17:40:25.173" Score="2" ViewCount="35" Body="&lt;p&gt;I write LaTeX code in vim. I also installed vim-latex. When I am inside a &lt;code&gt;itemize&lt;/code&gt; block that means inside &lt;code&gt;\begin{itemize}....\end{itemize}&lt;/code&gt; I enter &lt;kbd&gt;Enter&lt;/kbd&gt; and add new &lt;code&gt;\item ....&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If vim can detect the block and add &lt;code&gt;\item&lt;/code&gt; command when I enter &lt;kbd&gt;Enter&lt;/kbd&gt; inside that block it easy very helpful to and I can make same things for another block also.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess it may be possible in vim.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am waiting vim's super expert(super hero).&lt;/p&gt;&#xA;" OwnerUserId="9498" LastActivityDate="2018-02-23T18:32:13.327" Title="Inserting text within a block automaticaly for each Enter button pressing?" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15334" PostTypeId="2" ParentId="15333" CreationDate="2018-02-23T18:02:47.940" Score="3" Body="&lt;p&gt;This can be achieved very simply using the following pattern, using a conditional expression map and &lt;code&gt;searchpairpos&lt;/code&gt; which detects the presence of an unclosed itemize environment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CheckItemize()&#xA;    let [l:lnum, l:cnum] = searchpairpos('\\begin{itemize}', '',&#xA;                \  '\\end{itemize}', 'nbW')&#xA;    return l:lnum &amp;gt; 0&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; CheckItemize() ? '&amp;lt;cr&amp;gt;&amp;lt;tab&amp;gt;\item ' : '&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on your indent settings, you may use instead: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; CheckItemize() ? '&amp;lt;cr&amp;gt;\item ' : '&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-02-23T18:32:13.327" LastActivityDate="2018-02-23T18:32:13.327" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15335" PostTypeId="1" CreationDate="2018-02-23T18:46:38.507" Score="2" ViewCount="1579" Body="&lt;p&gt;I don't really know a better way to describe this, but copying multiple lines in Visual Mode flat out doesn't work. I hit V, highlight the lines, hit y, and then it will tell me &quot;31 lines yanked&quot; (or however many I copied) but then when I go to paste it only puts down the first 2 lines. And one of those lines wasn't even highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any clue how I can get this text editor to actually do its job? This is some pretty basic stuff and shouldn't be this difficult.&lt;/p&gt;&#xA;" OwnerUserId="16474" LastActivityDate="2022-07-05T14:20:33.777" Title="Copying lines in visual mode only lets me paste 2 lines" Tags="|cut-copy-paste|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15336" PostTypeId="2" ParentId="15335" CreationDate="2018-02-23T20:20:22.167" Score="2" Body="&lt;p&gt;this is not the expected behavior - perhaps you have something mapped in such a way that it causes this behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;try starting vim using &#xA;    vim -u /dev/null -U /dev/null --noplugin&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then, assuming the expected behavior, you can divide and conquer in your .vimrc, .gvimrc and plugins.&lt;/p&gt;&#xA;" OwnerUserId="16478" LastActivityDate="2018-02-23T20:20:22.167" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15339" PostTypeId="1" AcceptedAnswerId="15340" CreationDate="2018-02-24T08:45:35.193" Score="1" ViewCount="802" Body="&lt;p&gt;When I try to type in my directory to open my file, for example &lt;code&gt;~/Desktop&lt;/code&gt;, the tab completion doesn't work at the point of &lt;code&gt;~/d&lt;/code&gt;, since the completion only works on the capital letter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already wrote the following on &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt;, though it doesn't seem to be effective on the command-line case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ignorecase   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I make the tab completion on the capital letter on the command-line even though I type in a lowercase letter?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2018-02-24T09:37:05.827" Title="Is it possible to make the tab completion on command-line mode case insensitive?" Tags="|command-line|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15340" PostTypeId="2" ParentId="15339" CreationDate="2018-02-24T09:37:05.827" Score="4" Body="&lt;p&gt;You can set the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27wildignorecase%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'wildignorecase'&lt;/code&gt; option&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When set case is ignored when completing file names and directories.&#xA;  Has no effect when 'fileignorecase' is set.&#xA;  Does not apply when the shell is used to expand wildcards, which&#xA;  happens when there are special characters.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-02-24T09:37:05.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15341" PostTypeId="1" CreationDate="2018-02-24T11:38:30.567" Score="1" ViewCount="278" Body="&lt;p&gt;I have installed two vim plugins &lt;a href=&quot;https://github.com/artur-shaik/vim-javacomplete2&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;javacomplete2&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://github.com/junegunn/vim-emoji&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-emoji&lt;/code&gt;&lt;/a&gt; successfully but I'm not able to use their auto-prompting feature which enables the user to select an autocomplete suggestion without having to press any key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case of &lt;code&gt;javacomplete2&lt;/code&gt;, I am able to use &lt;code&gt;SUPERTAB&lt;/code&gt; alongside to fetch suggestions but that isn't satisfactory since it slows down my programming let alone make it faster. And there are no suggestions in case of &lt;code&gt;vim-emoji&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that my &lt;code&gt;.vimrc&lt;/code&gt; file is probably misconfigured, but since the documentation of these plugins is hard for a &lt;strong&gt;vim-beginner&lt;/strong&gt; like me to understand. I'm reaching out to StackExchange for help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;a href=&quot;https://github.com/UtkarshVerma/dotfiles/blob/master/vim/.vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;.vimrc&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I have ensured &lt;code&gt;echo &amp;amp;omnifunc&lt;/code&gt; and &lt;code&gt;echo &amp;amp;completefunc&lt;/code&gt;. tl;dr I want autocomplete suggestions while typing as in &lt;code&gt;YouCompleteMe&lt;/code&gt; for both the plugins.&lt;/p&gt;&#xA;" OwnerUserId="16461" LastEditorUserId="51" LastEditDate="2018-03-01T07:16:10.423" LastActivityDate="2018-03-01T07:16:10.423" Title="Issues with autocomplete in vim8" Tags="|vimscript|autocompletion|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="15342" PostTypeId="2" ParentId="8733" CreationDate="2018-02-24T13:38:20.150" Score="4" Body="&lt;p&gt;Since I was in search for a good way to input unicode Japanese characters in&#xA;VIM, this post was really helpful. I tried using &lt;code&gt;skk.vim&lt;/code&gt; but found it really&#xA;difficult, because contrary to the OP, I couldn't understand the documentation&#xA;at all, because I have just started learning Japanese. However, I managed to&#xA;find an alternative plugin, which seems to be a continuation of &lt;code&gt;skk.vim&lt;/code&gt; by&#xA;the same author.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tyru/eskk.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;eskk.vim&lt;/a&gt; has English documentation and is&#xA;well maintained, what is more, it also going to support&#xA;&lt;a href=&quot;https://github.com/neovim/neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;neovim&lt;/a&gt; with&#xA;&lt;a href=&quot;https://github.com/tyru/eskk.vim/pull/214&quot; rel=&quot;nofollow noreferrer&quot;&gt;this PR&lt;/a&gt;.&#xA;Thanks to @shougo for this feature!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For anyone as new to Japanese as me, you basically need to know a few things on&#xA;how to write your Japanese easily:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Hiragana mode is enabled in the &lt;code&gt;INSERT&lt;/code&gt; mode by pressing &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When you are in the hiragana mode, you can press &lt;code&gt;&amp;lt;q&amp;gt;&lt;/code&gt; to toggle the katakana&#xA;mode.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you want to convert hiragana to kanji, in insert mode start the word you&#xA;want to convert with &lt;code&gt;;&lt;/code&gt; and then at the end press &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; in order to&#xA;trigger the omni-completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, for the conversion functionality, you will need to have a large &lt;code&gt;JISYO&lt;/code&gt;&#xA;dictionary and it is enough to just download it with the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;touch &quot;~/.local/share/nvim/skk/skk-jisyo.s&quot;&#xA;target=&quot;~/.local/share/nvim/skk/SKK-JISYO.L&quot;&#xA;rm -rf &quot;${target}&quot;{,.gz}&#xA;curl \&#xA;  --create-dirs \&#xA;  --output &quot;${target}.gz&quot; \&#xA;  https://skk-dev.github.io/dict/SKK-JISYO.L.gz&#xA;gunzip &quot;${target}.gz&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;code&gt;neovim&lt;/code&gt; for this and below is the minimal &lt;code&gt;init.vim&lt;/code&gt; (or &lt;code&gt;.vimrc&lt;/code&gt;&#xA;as it should be compatible with &lt;code&gt;vim&lt;/code&gt; as well):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:data_dir = $HOME . '/.local/share/nvim'&#xA;&#xA;call plug#begin(s:data_dir . '/plugged')&#xA;Plug 'tyru/eskk.vim', { 'branch': 'neovim' }&#xA;call plug#end()&#xA;&#xA;let g:eskk#directory = s:data_dir . '/skk'&#xA;let g:eskk#dictionary = {&#xA;    \   'path': s:data_dir . '/skk/skk-jisyo.s',&#xA;    \   'sorted': 0,&#xA;    \   'encoding': 'utf-8',&#xA;    \}&#xA;let g:eskk#large_dictionary = {&#xA;    \   'path': s:data_dir . '/skk/SKK-JISYO.L',&#xA;    \   'sorted': 1,&#xA;    \   'encoding': 'euc-jp',&#xA;    \}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16484" LastEditorUserId="16484" LastEditDate="2019-04-06T18:42:28.370" LastActivityDate="2019-04-06T18:42:28.370" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15343" PostTypeId="1" CreationDate="2018-02-24T15:25:11.853" Score="1" ViewCount="1353" Body="&lt;p&gt;I am using Mobaxterm which has cygwin tools.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim/gvim are working fine. I am using same vimrc file for both (with -u option). Note that I have same issue without any vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make vimdiff works, I had to define diffexpr this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyDiffWin()&#xA;  let opt = &quot;&quot;&#xA;  if &amp;amp;diffopt =~ &quot;icase&quot;&#xA;    let opt = opt . &quot;-i &quot;&#xA;  endif&#xA;  if &amp;amp;diffopt =~ &quot;iwhite&quot;&#xA;    let opt = opt . &quot;-b &quot;&#xA;  endif&#xA;  execute '! ls '. v:fname_in&#xA;  silent execute &quot;!/bin/diff.exe -a --binary &quot; . opt . v:fname_in . &quot; &quot; . v:fname_new . &quot; &amp;gt; &quot; . v:fname_out&#xA;endfunction&#xA;set diffexpr=MyDiff()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I try to use gvimdiff, with same vimrc, I have the same issue I had with vimdiff without diffexpr :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E810: Cannot read or write temp files &#xA;E97: Cannot create diffs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to display the files used by diff.exe with the command &lt;code&gt;execute '! ls '. v:fname_in&lt;/code&gt;&#xA;But it does not display anything :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! ls /home/mobaxterm/tmp/vD9PXDX/0&#xA;&#xA;Command terminated&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So not surprising he cannot diff files !&#xA;But I do not understand the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim and gvim are in version 8.0.494&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TIA&lt;/p&gt;&#xA;&#xA;&lt;p&gt;JP&lt;/p&gt;&#xA;" OwnerUserId="16486" LastEditorUserId="1841" LastEditDate="2018-02-26T15:37:07.173" LastActivityDate="2019-03-11T15:33:29.873" Title="How to make gvimdiff works under MobaXterm or cygwin?" Tags="|vimdiff|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15344" PostTypeId="1" AcceptedAnswerId="15346" CreationDate="2018-02-24T18:01:46.543" Score="1" ViewCount="176" Body="&lt;p&gt;I have &lt;code&gt;undodir=~/.vim/undodir&lt;/code&gt; such that persistent-undo history files don't clutter my source code directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, for one particular source file, I'd like to have its persistent-undo history file to be stored in the same directory as the source file itself — such that I could move them together to a different machine and the undo history would portably be still there on the other machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seemed natural to use a modeline for this, so I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vi: undodir=.:undofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when opening the file, I got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing modelines:&#xA;line 1:&#xA;E520: Not allowed in a modeline: undodir=.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess this is because &lt;code&gt;'undodir'&lt;/code&gt; is a &lt;em&gt;global&lt;/em&gt; setting...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm not sure if there is a workable way to do this...&lt;/p&gt;&#xA;" OwnerUserId="2334" LastActivityDate="2018-02-25T08:35:35.653" Title="Local persistent undo file modeline" Tags="|undo-redo|persistent-state|modeline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15345" PostTypeId="2" ParentId="15072" CreationDate="2018-02-24T19:29:58.280" Score="0" Body="&lt;p&gt;I had the same thing. Shift tab worked fine in other modes but not in insert mode. It does get detected, because Supertab reacts in the statusline. This overwrites it fine for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;Esc&amp;gt;[Z &amp;lt;Esc&amp;gt; :call whatever&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar but different from a solution in the document mentioned in the main question. It does mess with the shift tab in supertab now.&lt;/p&gt;&#xA;" OwnerUserId="16457" LastEditorUserId="16457" LastEditDate="2018-02-25T07:38:57.720" LastActivityDate="2018-02-25T07:38:57.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15346" PostTypeId="2" ParentId="15344" CreationDate="2018-02-24T21:28:37.433" Score="3" Body="&lt;p&gt;No, the &lt;code&gt;'undodir'&lt;/code&gt; option cannot be set from a modeline, because it has the &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/option.c#L2910&quot; rel=&quot;nofollow noreferrer&quot;&gt;'SECURE'&lt;/a&gt; flag set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this is a global option, it does not make sense to set this option differently for a specific file, that would also affect all other buffers that are edited later then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However it might be possible to use a &lt;code&gt;BufRead&lt;/code&gt; in combination with a &lt;code&gt;BufWritePost&lt;/code&gt; autocommand to do what you want.. Something similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set undodir=~/tmp/undodir,. undofile&#xA;augroup MyUndoDir&#xA;  au!&#xA;  au BufRead /tmp/foobar.vim :setl noundofile&#xA;  au BufWritePost /tmp/foobar.vim  exe &quot;wundo &quot;. fnamemodify(@%, ':h'). '/.'. fnamemodify(@%, ':t'). '.un~'&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the &lt;code&gt;'undofile'&lt;/code&gt; option has been disabled for that buffer whenever we edit it, we need to explicitly write the undofile on an &lt;code&gt;BufWritePost&lt;/code&gt; autocommand. Of course you need to use the actual filename instead of &lt;code&gt;/tmp/foobar.vim&lt;/code&gt; in the example.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-02-25T08:35:35.653" LastActivityDate="2018-02-25T08:35:35.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15347" PostTypeId="1" AcceptedAnswerId="15356" CreationDate="2018-02-25T07:26:18.680" Score="1" ViewCount="479" Body="&lt;p&gt;I was trying to learn javascript the other day and was using emacs as I have been trying to learn emacs as well. But after sometimes my left wrist started to hurt(as one's does) so I switched to neovim and noticed a significant amount of lag in html files with&#xA;    document.write();&#xA;statements for some reason. I turned off the syntax highlighting and the lag was gone. I am using joshdick/onedark.vim colorscheme. I thought about changing into some other colorscheme, but I would rather stay in this one as my all other resources use the same colorscheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how to cope with this?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-27T04:20:47.470" LastActivityDate="2019-02-27T04:20:47.470" Title="Enabling Syntax in Vim Creates Lag" Tags="|syntax-highlighting|filetype-html|filetype-javascript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="15348" PostTypeId="1" CreationDate="2018-02-25T08:40:41.663" Score="1" ViewCount="46" Body="&lt;p&gt;Setting up vim on WSL, and I want to be able to redirect the vim internal clipboard to the windows clipboard. This is possible if running an X server like XMing, but I don't want to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have 2 programs, clip and get-clipboard, that I can run from the shell to access the clipboard. But how might I go about faking things so that clipboard operations using the + register end up piping the text to/from those problems?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not above compiling myself, although that's not ideal.&lt;/p&gt;&#xA;" OwnerUserId="16419" LastActivityDate="2018-02-25T15:07:54.283" Title="Change where a register actually points (in this case, redirect &quot;+&quot; [sys clipboard], to an external program)" Tags="|external-command|microsoft-windows|register|" AnswerCount="0" CommentCount="1" ClosedDate="2018-02-25T14:15:02.473" ContentLicense="CC BY-SA 3.0" />
  <row Id="15349" PostTypeId="1" AcceptedAnswerId="15352" CreationDate="2018-02-25T09:33:43.810" Score="4" ViewCount="1778" Body="&lt;p&gt;I code mainly in 2 languages &lt;strong&gt;python&lt;/strong&gt; and &lt;strong&gt;HTML&lt;/strong&gt;. I currently have the indenting configured for python in my neovim configuration file but I would to know &lt;strong&gt;&lt;em&gt;how to make neovim auto-detect the type of file and change the indenting script for that specific type of language&lt;/em&gt;&lt;/strong&gt;...in this case &lt;em&gt;HTML&lt;/em&gt;. Any help would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="16330" LastEditorUserId="16330" LastEditDate="2018-02-25T19:12:31.690" LastActivityDate="2018-02-25T19:12:31.690" Title="How to change indenting for html files?" Tags="|neovim|indentation|filetype-html|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15350" PostTypeId="1" AcceptedAnswerId="15353" CreationDate="2018-02-25T12:46:57.590" Score="0" ViewCount="360" Body="&lt;p&gt;I set the following on my &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set langmap=qd,QD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;q&lt;/code&gt; does not work since I set the following (so &lt;code&gt;q&lt;/code&gt; just moves the cursor to left):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap d h&#xA;noremap h gj&#xA;noremap t gk&#xA;noremap n l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I set them to &lt;code&gt;langmap&lt;/code&gt; as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set langmap=qd,QD,dh,hj,tk,nl,ln,LN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I type in &lt;code&gt;h&lt;/code&gt;, it inserts a line, since I also set the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap j o&amp;lt;Esc&amp;gt;k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To recap, I want to set the &lt;code&gt;q&lt;/code&gt; to &lt;code&gt;d&lt;/code&gt;, which then makes &lt;code&gt;noremap d h&lt;/code&gt; not working, so I added it to &lt;code&gt;langmap&lt;/code&gt; as well, but it then becomes incompatible with other remap settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is it possible to set the &lt;code&gt;langmap&lt;/code&gt; as well as &lt;code&gt;noremap&lt;/code&gt;, without the keys being set recursively?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Dvorak so I want to set it like the above.&lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2018-02-25T13:39:17.983" Title="How can I use langmap and noremap together?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15352" PostTypeId="2" ParentId="15349" CreationDate="2018-02-25T13:20:21.450" Score="2" Body="&lt;p&gt;Here is an example from the &lt;a href=&quot;https://vimhelp.appspot.com/vim_faq.txt.html#faq-26.1&quot; rel=&quot;nofollow noreferrer&quot;&gt;faq&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can create filetype plugins to set different options for different&#xA;  types of files. You should first enable filetype plugins using the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  :filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;A filetype plugin is a vim script that is loaded whenever Vim opens or&#xA;  creates a file of that type.  For example, to ensure that the 'textwidth'&#xA;  option is set to 80 when editing a C program (filetype 'c'), create one of&#xA;  the following files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;          ~/.vim/ftplugin/c.vim (Unix)&#xA;          %HOME%\vimfiles\ftplugin\c.vim (Windows)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;with the following text in it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;          setlocal textwidth=80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;You can also use autocommands to set specific options when editing specific&#xA;  type of files. For example, to set the 'textwidth' option to 75 for only&#xA;  *.txt files, you can use the following autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  autocmd BufRead *.txt setlocal textwidth=80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For more information, read&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.appspot.com/usr_43.txt.html#filetype-plugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;:help filetype-plugin&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.appspot.com/usr_05.txt.html#add-filetype-plugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;:help add-filetype-plugin&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-02-25T13:20:21.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15353" PostTypeId="2" ParentId="15350" CreationDate="2018-02-25T13:30:19.007" Score="1" Body="&lt;p&gt;As I mentioned in my answer to your original question on this topic AND in an associated comment to you (!!), the help for &lt;code&gt;'langmap'&lt;/code&gt; has advice for handling interference from &lt;code&gt;:map&lt;/code&gt; mappings. Specifically, it suggests resetting of &lt;code&gt;'langremap'&lt;/code&gt;. When that is off...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...setting 'langmap' does not apply to characters resulting from a&#xA;  mapping. This basically means, if you noticed that setting 'langmap'&#xA;  disables some of your mappings, try resetting this option.  This&#xA;  option defaults to on for backwards compatibility.  Set it off if that&#xA;  works for you to avoid mappings to break.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I applied your settings and reset &lt;code&gt;'langremap'&lt;/code&gt; and &lt;code&gt;h&lt;/code&gt; no longer inserts a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, though, that this isn't a panacea for all potential conflicts. If you have a jumble of mappings containing the same keys there may be other problems. You'll need to be judicious in what you decide to map. (And, of course, always use &lt;code&gt;:noremap&lt;/code&gt; and friends instead of &lt;code&gt;:map&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-02-25T13:39:17.983" LastActivityDate="2018-02-25T13:39:17.983" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15354" PostTypeId="1" AcceptedAnswerId="15355" CreationDate="2018-02-25T14:14:31.830" Score="2" ViewCount="61" Body="&lt;p&gt;I like to take minutes for meetings using vim+Markdown(CommonMark)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like having something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Meeting Name - 2018-02-25&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The way I accomplish this is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i# Meeting Name - ^[:put =strftime('%F')&amp;lt;cr&amp;gt;kJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better way? I know you can do &lt;code&gt;:-1put ...&lt;/code&gt; and it will put things on the &lt;em&gt;previous&lt;/em&gt; line, but is there a way to &lt;code&gt;:put&lt;/code&gt; at the end of the line? (obviously I could make a macro/map, but is there a better way with just put?)&lt;/p&gt;&#xA;" OwnerUserId="5574" LastEditorUserId="5574" LastEditDate="2018-02-26T17:19:00.107" LastActivityDate="2018-02-26T17:19:00.107" Title=":put at the end of the current line?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15355" PostTypeId="2" ParentId="15354" CreationDate="2018-02-25T14:37:09.220" Score="3" Body="&lt;p&gt;Why stick to put?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a nice alternative to it, like :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;i#Meeting Name - ^R=strftime(&quot;%F&quot;)&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;btw: Your example seems to be missing a &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; after the &lt;code&gt;)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="343" LastEditDate="2018-02-26T10:17:47.133" LastActivityDate="2018-02-26T10:17:47.133" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15356" PostTypeId="2" ParentId="15347" CreationDate="2018-02-25T19:07:53.300" Score="1" Body="&lt;h2&gt;Vim-polyglot&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;vim-polyglot contains what it calls 'language packs', which are sets of syntax, ftplugin, and other files that 'enhance' the experience of working with a particular language. These files work as explained by the help reference, in particular at &lt;code&gt;:help rtp&lt;/code&gt; and various topics like &lt;code&gt;syntax&lt;/code&gt;, &lt;code&gt;ftplugin&lt;/code&gt;, &amp;amp;c.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Regexes/syntax&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Regexes are common to syntax files as a way to define for Vim that, say, &lt;code&gt;var&lt;/code&gt; is a keyword and &lt;code&gt;123&lt;/code&gt; is a constant. If a regex is 'slow', it will slow down syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By 'slow' I mean that vim's regex engine has a hard time handling it efficiently; this is always a known limitation of regexes, although for the most part vim handles them quite well.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Fixes&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Suffer through slowness (but this is Vim, not emacs, so I'm going to guess you &lt;em&gt;don't&lt;/em&gt; want that)&lt;/li&gt;&#xA;&lt;li&gt;Turn off syntax highlighting (apparently there is a trend of people doing this to focus better?)&lt;/li&gt;&#xA;&lt;li&gt;Remove your vim-polyglot (consider filing a bug related to your specific language &lt;code&gt;js&lt;/code&gt;)&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If they then fix the bug, you can reuse the plugin&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;Lacking the time and effort to fully explain syntax files/the runtime path, I'm going to point any curious readers to &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/42.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; (thank you Steve Losh). In fact, if you haven't already, the whole book there is a good read.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2018-02-26T08:02:49.267" LastActivityDate="2018-02-26T08:02:49.267" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15357" PostTypeId="2" ParentId="10477" CreationDate="2018-02-25T19:54:32.087" Score="7" Body="&lt;p&gt;On neovim additionally to &lt;code&gt;getbufinfo()&lt;/code&gt; one can also use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let buffers = nvim_list_bufs()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://neovim.io/doc/user/api.html#nvim_list_bufs()&quot; rel=&quot;noreferrer&quot;&gt;nvim_list_bufs&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14337" LastActivityDate="2018-02-25T19:54:32.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15358" PostTypeId="1" CreationDate="2018-02-25T20:52:55.980" Score="1" ViewCount="87" Body="&lt;p&gt;I want to put timestamp using &lt;kbd&gt;Leader&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt; (&lt;code&gt;\ts&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the following script &lt;code&gt;timestamp.bat&lt;/code&gt;(Windows 7):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@echo off&#xA;cls&#xA;echo|set /p=%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%:%time:~3,2%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the result should be something like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum.. 2018-02-25 21:43 lorem ipsum..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, when I am in the correct position to put the timestamp, insertion go to one line under. I think it is due to the &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; character at the begining of output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to trim  character from output if I have such a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;ts :r! timestamp.bat&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; nnoremap &amp;lt;leader&amp;gt;ts :put =strftime(\&quot;%c\&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there other solution to this problem?&lt;/p&gt;&#xA;" OwnerUserId="16328" LastEditorUserId="1841" LastEditDate="2018-02-26T10:15:36.737" LastActivityDate="2018-02-26T10:15:36.737" Title="Trim/clear new line character from batch script at Windows7 with gvim" Tags="|vimscript|text-generation|command-line-window|" AnswerCount="0" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15359" PostTypeId="1" AcceptedAnswerId="15361" CreationDate="2018-02-26T16:53:21.950" Score="2" ViewCount="89" Body="&lt;p&gt;Regarding this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f{char}                 To [count]'th occurrence of {char} to the right.  The&#xA;                        cursor is placed on {char} |inclusive|.&#xA;                        {char} can be entered as a digraph |digraph-arg|.&#xA;                        When 'encoding' is set to Unicode, composing&#xA;                        characters may be used, see |utf-8-char-arg|.&#xA;                        |:lmap| mappings apply to {char}.  The CTRL-^ command&#xA;                        in Insert mode can be used to switch this on/off&#xA;                        |i_CTRL-^|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to change its behaviour as such. Take this sample string, in which &lt;code&gt;^&lt;/code&gt; indicates the cursor position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foobar(); // boat programming SO meme&#xA;                              ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The keystroke: &lt;code&gt;f;&lt;/code&gt; would leave the cursor in place, because there is no &lt;code&gt;;&lt;/code&gt; right of the cursor. I would rather have it function that it would search left instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foobar(); // boat programming SO meme&#xA;        ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sense? The reverse should apply, as the &lt;code&gt;t;&lt;/code&gt; sequence. &lt;/p&gt;&#xA;" OwnerUserId="7960" LastEditorUserId="1841" LastEditDate="2018-02-26T17:37:53.760" LastActivityDate="2018-02-27T08:15:04.370" Title="How to change f{char} to search left if no char was found searching right?" Tags="|cursor-movement|cursor-motions|cursor|find|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15360" PostTypeId="2" ParentId="15359" CreationDate="2018-02-26T17:25:50.297" Score="2" Body="&lt;p&gt;Before the actual answer, a personnal opinion:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote the code to show that it can work but I don't think it is a good idea to use this code: having &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt; going backward and &lt;code&gt;F&lt;/code&gt; and &lt;code&gt;T&lt;/code&gt; going forward might be pretty disturbing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it is better to use &lt;code&gt;,&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt;: if &lt;code&gt;f;&lt;/code&gt; doesn't find a character then simply use &lt;code&gt;,&lt;/code&gt; to replay the motion in the other direction: it is one more keystroke but a much more predictable behavior.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%2c&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ,&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%3b&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now for the answer, you can try something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; f :call MyPreciseMotions('f', 'F')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; F :call MyPreciseMotions('F', 'f')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; t :call MyPreciseMotions('t', 'T')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; T :call MyPreciseMotions('T', 't')&amp;lt;CR&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; f :call MyPreciseMotions('f', 'F')&amp;lt;CR&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; F :call MyPreciseMotions('F', 'f')&amp;lt;CR&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; t :call MyPreciseMotions('t', 'T')&amp;lt;CR&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; T :call MyPreciseMotions('T', 't')&amp;lt;CR&amp;gt;&#xA;&#xA;function! MyPreciseMotions(firstCmd, secondCmd)&#xA;    &quot; Get a character from the user&#xA;    let charToReach = nr2char(getchar())&#xA;&#xA;    &quot; Save the cursor position&#xA;    let cursor_save = getpos('.')&#xA;&#xA;    &quot; Try to reach the character&#xA;    execute &quot;norm! &quot; . a:firstCmd . charToReach&#xA;&#xA;    &quot; If we didn't move try the other direction&#xA;    if (getpos('.')[2] == cursor_save[2])&#xA;        execute &quot;norm! &quot; . a:secondCmd . charToReach&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You create four mappings for your four motions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function takes as arguments the first motion to try then the second one. It uses &lt;code&gt;getchar()&lt;/code&gt; to get the character to reach and then try to reach it, using the first then the second command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it seems to be working properly but &lt;code&gt;,&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt; might not work as you expect anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some interesting help topics related to the code:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getchar%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getchar()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getpos%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getpos()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :execute&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3amap-%3csilent%3e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :map-&amp;lt;silent&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-02-27T08:15:04.370" LastActivityDate="2018-02-27T08:15:04.370" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15361" PostTypeId="2" ParentId="15359" CreationDate="2018-02-26T19:52:12.577" Score="2" Body="&lt;p&gt;Here is another approach:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; \f MySearch('f')&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; \t MySearch('t')&#xA;&#xA;func! MySearch(cmd)&#xA;    let arg=getchar()&#xA;    if arg !~ '^\d\+'&#xA;        &quot; no real key, mouse click  or something unusual, so abort&#xA;        return a:cmd.&quot;\&amp;lt;esc&amp;gt;&quot;&#xA;    else&#xA;        let arg=nr2char(arg)&#xA;    endif&#xA;    let pat='\%'.line('.').'l\V'.escape(arg,'\\')&#xA;    if search(pat,'nWz')&#xA;        return a:cmd.arg&#xA;    else&#xA;        return nr2char(char2nr(a:cmd)-32).arg&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses an expression mapping and searches from the current cursor position if after it the requested character is found. If yes, the original command with the entered character is returned, else If dynamically calculates the uppercase command of the given command and returns that.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-02-26T19:52:12.577" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="15362" PostTypeId="1" AcceptedAnswerId="15363" CreationDate="2018-02-26T20:38:58.527" Score="3" ViewCount="201" Body="&lt;p&gt;When I'm writing Latex files in vim, the syntax highlighting recognizes &lt;code&gt;\newcommand&lt;/code&gt; as the start of a new command environment, but not &lt;code&gt;\newcommand*&lt;/code&gt;. Digging into the syntax file, it seems that to fix this I want to replace the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match texNewCmd &quot;\\newcommand\&amp;gt;&quot; nextgroup=texCmdName skipwhite skipnl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match texNewCmd &quot;\\newcommand\*\=\&amp;gt;&quot; nextgroup=texCmdName skipwhite skipnl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd prefer it if rather than editing the existing syntax file directly, I could include this change in a separate file. I read that by adding a separate &lt;code&gt;tex.vim&lt;/code&gt; file in the &lt;code&gt;~/.vim/syntax&lt;/code&gt; or &lt;code&gt;~/.vim/after/syntax&lt;/code&gt; folder I can include small changes to the syntax highlighting, but that doesn't seem to be working. Is there a way to change what this group is matched to without editing it directly in the included syntax file?&lt;/p&gt;&#xA;" OwnerUserId="16503" LastActivityDate="2018-02-26T20:53:02.363" Title="How do I change the regex for a single syntax highlighting match?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15363" PostTypeId="2" ParentId="15362" CreationDate="2018-02-26T20:53:02.363" Score="3" Body="&lt;p&gt;Your attempt doesn't work because &lt;code&gt;\\newcommand\*\=\&amp;gt;&lt;/code&gt; can never match the text &lt;code&gt;\newcommand*&lt;/code&gt;.  &lt;code&gt;\&amp;gt;&lt;/code&gt; denotes a word right boundary but &lt;code&gt;*&lt;/code&gt; is not a word character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put this in &lt;code&gt;~/.vim/after/syntax/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match texNewCmd &quot;\\newcommand\*&quot; nextgroup=texCmdName skipwhite skipnl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-02-26T20:53:02.363" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15364" PostTypeId="1" CreationDate="2018-02-26T21:07:32.483" Score="1" ViewCount="202" Body="&lt;p&gt;I'd like low-level control over exactly what bytes I send and receive from a process spawned from some vimscript. What encoding is used for communications with commands started with &lt;code&gt;:!foo&lt;/code&gt;? Can I influence this choice? How are newlines handled?&lt;/p&gt;&#xA;" OwnerUserId="2982" LastActivityDate="2018-02-26T21:07:32.483" Title="What encoding does :! use?" Tags="|vimscript|command-line|external-command|encoding|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="15365" PostTypeId="1" AcceptedAnswerId="15367" CreationDate="2018-02-26T21:38:48.690" Score="0" ViewCount="562" Body="&lt;p&gt;I am trying to edit a json file, and I need to take out the lines starting and ending with &lt;code&gt;{%&lt;/code&gt; and &lt;code&gt;%}&lt;/code&gt; respectively and move them to the beginning of the file. I need to do it at different places in a single file and repeat it for a lot of files, hence I am looking for a single command to this for one place and then I can repeat it again and again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ex.&#xA;Current file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{% data 1 %}&#xA;&#xA;{&#xA;&#xA;  &quot;data1&quot;: [&#xA;&#xA;     detail1a: data detail 1a&#xA;&#xA;     detail1b: data detail 1b&#xA;&#xA;  ]&#xA;&#xA;}&#xA;&#xA;{% data 2a %}&#xA;&#xA;{% data 2b %}&#xA;&#xA;{&#xA;&#xA;  &quot;data2&quot;: [&#xA;&#xA;     detail2a: data detail 2a&#xA;&#xA;     detail2b: data detail 2b&#xA;&#xA;  ]&#xA;&#xA;}&#xA;&#xA;{% data 3a %}&#xA;&#xA;{&#xA;&#xA;  &quot;data3&quot;: [&#xA;&#xA;     detail3a: data detail 3a&#xA;&#xA;  ]&#xA;&#xA;}&#xA;&#xA;In this file, i want to remove all the data xa/xb lines and paste them at the beginning of the file like:&#xA;&#xA;{% data 1 %}&#xA;&#xA;{% data 2a %}&#xA;&#xA;{% data 2b %}&#xA;&#xA;{% data 3a %}&#xA;&amp;lt;rest of the lines&amp;gt;% data 3a %}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I can use &lt;code&gt;:%s/^\(\s\+\)]\n}\n{$/\1],/g&lt;/code&gt; to remove the }{ to join it  as a single execution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can do &lt;code&gt;/^{%.*%}$&lt;/code&gt; to get the line but how do I cut it and move it to line 0 (pushing down whatever is at line 0 already).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: This is my first post in stackechange and I tried looking for all the existing posts to my best. The closet I found is this (&lt;a href=&quot;https://vi.stackexchange.com/questions/3912/cut-line-trim-it-and-then-paste-it-on-another-line&quot;&gt;Cut line, trim it and then paste it on another line&lt;/a&gt;) but it doesn't solve my purpose. Please excuse if I missed some norms.&lt;/p&gt;&#xA;" OwnerUserId="16504" LastEditorUserId="1841" LastEditDate="2018-02-27T09:57:20.050" LastActivityDate="2018-02-27T09:57:20.050" Title="Cut a regex matching line and paste it at another line" Tags="|cut-copy-paste|filetype-json|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15366" PostTypeId="1" CreationDate="2018-02-26T21:44:48.380" Score="0" ViewCount="712" Body="&lt;p&gt;Let's say I have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// that is just a comment&#xA;// that is just a comment&#xA;// that is just a comment&#xA;// that is just a comment&#xA;// that is just a comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to type * at &lt;code&gt;//&lt;/code&gt; to use the command &lt;code&gt;cgn&lt;/code&gt; and then typing just &lt;code&gt;.&lt;/code&gt; instead of classical &lt;code&gt;n .&lt;/code&gt; getting this result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* that is just a comment&#xA;/* that is just a comment&#xA;/* that is just a comment&#xA;/* that is just a comment&#xA;/* that is just a comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My solutin was setting search register manually: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @/='//'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a faster solution?&#xA;I know visual block changing but my question is just for better understanding of vim.&lt;/p&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="343" LastEditDate="2018-02-26T23:14:36.590" LastActivityDate="2018-02-27T09:46:51.793" Title="Why when I type * over double slashes '//' doesn't vim highlight it as a search word?" Tags="|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15367" PostTypeId="2" ParentId="15365" CreationDate="2018-02-26T22:37:17.773" Score="1" Body="&lt;p&gt;The most direct solution is a &lt;code&gt;:global&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^{%.*%}$/m0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The slight problem is that this leaves the lines in reverse order. A simple solution is just to run it again! (By pressing &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;Up&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that seems inelegant to you, it's also possible to do it in a single pass. Here's one way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:2mark a&#xA;:2,$g/^{%.*%}$/normal! dd'aP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Noting that the first line is already in the correct place, we first set a mark &lt;code&gt;a&lt;/code&gt; on the second line. We then run a &lt;code&gt;:normal&lt;/code&gt; command on each of the remaining matching lines to move each of them above the line we just marked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :global&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :move&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :normal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help cmdline-ranges&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-27T09:42:25.037" LastActivityDate="2018-02-27T09:42:25.037" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15368" PostTypeId="2" ParentId="15366" CreationDate="2018-02-26T22:56:56.173" Score="2" Body="&lt;p&gt;The reason that this isn't working for you is that forward slash &lt;code&gt;/&lt;/code&gt; (ASCII 47), isn't included in your &lt;code&gt;'iskeyword'&lt;/code&gt; setting, which in Vim defaults to &lt;code&gt;@,48-57,_,192-255&lt;/code&gt;.&lt;sup&gt;1&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;could&lt;/em&gt; fix it by adding the forward slash to your &lt;code&gt;'iskeyword'&lt;/code&gt; setting but I &lt;strong&gt;wouldn't recommend doing this&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setlocal iskeyword+=/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;'iskeyword'&lt;/code&gt; setting is used in many places in Vim, and there's a fairly decent chance that by adding forward slash to it you will break things. e.g. Do you like being able to step through the components of a path with the &lt;code&gt;w&lt;/code&gt; motion?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Slightly quicker than setting the search register with a &lt;code&gt;:let&lt;/code&gt; command is just searching:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\/\/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you find the construction of regular expressions to be slow, you could also take advantage of the method the &lt;code&gt;*&lt;/code&gt; uses for selecting what to search for:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;the keyword under the cursor |'iskeyword'|&lt;/li&gt;&#xA;  &lt;li&gt;the first keyword after the cursor, in the current line&lt;/li&gt;&#xA;  &lt;li&gt;the non-blank word under the cursor&lt;/li&gt;&#xA;  &lt;li&gt;[...]&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In order that steps 1 &amp;amp; 2 don't find anything, construct a line which contains no keywords, search for it, and then remove it again, by typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;o//&amp;lt;Esc&amp;gt;*u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then carry on with your &lt;code&gt;cgn&lt;/code&gt; replacements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details on the &lt;code&gt;'iskeyword'&lt;/code&gt; setting, see &lt;code&gt;:help 'iskeyword'&lt;/code&gt; and &lt;code&gt;:help 'isfname'&lt;/code&gt; (the latter just for the description of the format of the former), and for more details of how &lt;code&gt;*&lt;/code&gt; works see &lt;code&gt;:help *&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1: Except on Windows, where it's slightly different: &lt;code&gt;@,48-57,_,128-167,224-235&lt;/code&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-27T09:46:51.793" LastActivityDate="2018-02-27T09:46:51.793" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15369" PostTypeId="2" ParentId="15366" CreationDate="2018-02-26T23:04:07.747" Score="1" Body="&lt;p&gt;You could use &lt;code&gt;?//&amp;lt;cr&amp;gt;&lt;/code&gt; which is quite fast to type.  Since &lt;code&gt;n&lt;/code&gt; would now work backwards, you'd have to do &lt;code&gt;cgN&lt;/code&gt; if you cared about order.  Or you could type &lt;code&gt;/&amp;lt;cr&amp;gt;&lt;/code&gt; to forward-ize the search.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-02-26T23:04:07.747" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15370" PostTypeId="1" AcceptedAnswerId="15466" CreationDate="2018-02-27T01:01:31.797" Score="4" ViewCount="1487" Body="&lt;p&gt;I am experimenting with default key mappings and am considering remapping the &lt;code&gt;g&lt;/code&gt; key entirely. But first I would like to turn off all the existing mappings that &lt;code&gt;g&lt;/code&gt; has. For now I am using this kind of hack:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; disable all g maps&#xA;let g:netrw_nogx = 1 &quot; allows disabling gx&#xA;let s:chars1 = map(range(char2nr('a'), char2nr('x')), 'nr2char(v:val)')&#xA;let s:chars2 = map(range(char2nr('A'), char2nr('Z')), 'nr2char(v:val)')&#xA;let s:chars = s:chars1 + s:chars2&#xA;let s:chars = s:chars+['0','1','2','3','4','5','6','7','8','9','+','-','=','_']&#xA;let s:chars = s:chars+['~','`','!','@','#','$','%','^','&amp;amp;','*','(',')','/','?']&#xA;let s:chars = s:chars+['[',']','{','}','\','\|',':',';','&quot;',&quot;'&quot;,'&amp;lt;',&quot;&amp;gt;&quot;,'.',',']&#xA;&#xA;for char in s:chars&#xA;  execute 'noremap g' . char . ' &amp;lt;nop&amp;gt;'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this is very messy and &lt;code&gt;g&amp;lt;ctrl-_&amp;gt;&lt;/code&gt; maps are still left in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some cleaner way to accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="307" LastActivityDate="2021-02-12T00:48:13.600" Title="Unmap all combinations starting with certain key" Tags="|key-bindings|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15372" PostTypeId="1" AcceptedAnswerId="15373" CreationDate="2018-02-27T09:35:17.997" Score="2" ViewCount="198" Body="&lt;p&gt;I would like to move to the start of the line on the command-line mode with Ctrl + a. Right now I have the following setting on my &lt;code&gt;~/.vimrc&lt;/code&gt;, which is effective on insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-a&amp;gt; &amp;lt;Esc&amp;gt;I&#xA;inoremap &amp;lt;C-e&amp;gt; &amp;lt;Esc&amp;gt;A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course on the normal mode you can move using &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At least on the command-line mode, I can move to the end of the line by Ctrl + e, but is it also possible to move to the start of the line, possibly with Ctrl + a?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2018-02-27T10:26:01.943" Title="Can I move to the start of the line on command-line mode?" Tags="|key-bindings|command-line|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15373" PostTypeId="2" ParentId="15372" CreationDate="2018-02-27T09:45:52.600" Score="3" Body="&lt;p&gt;In command line mode &lt;code&gt;&amp;lt;C-b&amp;gt;&lt;/code&gt; is used to move to the beginning of the line &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-B&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h c_CTRL-B&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;c-a&amp;gt; &amp;lt;c-b&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that I would argue that it is useful to learn to use &lt;code&gt;&amp;lt;c-b&amp;gt;&lt;/code&gt;: &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; in command line mode insert all of the file names which match the pattern in front of the cursor which can be pretty useful. For example, in my home directory, I can type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argadd .bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then when I type &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; the command line will become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argadd .bashrc .bash_aliases .bash_aliases_local .bash_history .bash_profile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I can then edit all of these files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To keep this feature you can also create the invert mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;c-b&amp;gt; &amp;lt;c-a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-02-27T10:26:01.943" LastActivityDate="2018-02-27T10:26:01.943" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15374" PostTypeId="1" CreationDate="2018-02-27T09:54:52.183" Score="1" ViewCount="2177" Body="&lt;p&gt;I have the following code in my vimrc to compile my latex documents with &lt;code&gt;&amp;lt;F5&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F5&amp;gt; :write &amp;lt;Bar&amp;gt; :if expand(&quot;%&quot;) == &quot;body.tex&quot; &amp;lt;bar&amp;gt;&#xA;:exe ':!arara -v &quot;main.tex&quot;' &amp;lt;cr&amp;gt;&#xA;:endif &amp;lt;cr&amp;gt; &amp;lt;bar&amp;gt; :!arara -v % &amp;lt;cr&amp;gt; :endif &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Line breaks added purley for legibility, no linebreaks in my original code.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I sometimes separate my latex documents in one containing the preamble, called &quot;main.tex&quot;, and one containing the text, called &quot;body.tex&quot;. If that's the case I want arara to run on the file called &quot;main.tex&quot;, otherwise I want it to run on the file I'm writing on itself. None of this matters to the question I'm asking, I just wanted to explain what I'm doing here.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Oddly enough, this code is working, and it only works as intended if I keep it this way. A plausible assumption would have been that the following code would have been sufficient:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F5&amp;gt; :write &amp;lt;Bar&amp;gt; :if expand(&quot;%&quot;) == &quot;body.tex&quot; &amp;lt;bar&amp;gt;&#xA;:exe ':!arara -v &quot;main.tex&quot;' &amp;lt;bar&amp;gt; &#xA;:else &amp;lt;bar&amp;gt; :!arara -v % &amp;lt;bar&amp;gt; :endif &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, vim complains about &lt;code&gt;:else&lt;/code&gt; outside of &lt;code&gt;:if&lt;/code&gt; if I'm in a file not called &quot;body.tex&quot;, and if I'm within body.tex, I have to press enter to run arara, and have to close the &lt;code&gt;if&lt;/code&gt; manually by entering &lt;code&gt;:endif&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'd also expect vim to complain about the two occurrences of &lt;code&gt;endif&lt;/code&gt; in a single &lt;code&gt;if&lt;/code&gt; command in the first code, and for the first one to be utterly redundant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody shed some light on the exact syntax that I'm dealing with here? Vim help hasn't been a lot of actual help on this.&lt;/p&gt;&#xA;" OwnerUserId="16509" LastEditorUserId="1841" LastEditDate="2018-02-27T11:53:01.903" LastActivityDate="2018-02-27T11:53:01.903" Title="Syntax of :endif in if-statements" Tags="|vimscript|filetype-tex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15375" PostTypeId="2" ParentId="15374" CreationDate="2018-02-27T10:19:12.103" Score="5" Body="&lt;p&gt;Rather than figuring out what's going on with your existing mappings, it's easier and more readable just to use a function, instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :call &amp;lt;SID&amp;gt;compile_latex()&amp;lt;CR&amp;gt;&#xA;&#xA;function! s:compile_latex() abort&#xA;  write&#xA;  if expand(&quot;%&quot;) == &quot;body.tex&quot;&#xA;    !arara -v &quot;main.tex&quot;&#xA;  else&#xA;    !arara '-v %'&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. The &lt;code&gt;:execute&lt;/code&gt; didn't seem to be necessary, so I removed that, too and I used a non-recursive mapping, which you should do unless you have a reason not to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;em&gt;must&lt;/em&gt; have a one liner, an expression mapping using a ternary expression might be clearer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;F5&amp;gt; expand(&quot;%&quot;) == &quot;body.tex&quot;&#xA;  \ ? ':write &amp;lt;bar&amp;gt; !arara -v &quot;main.tex&quot;&amp;lt;CR&amp;gt;'&#xA;  \ : ':write &amp;lt;bar&amp;gt; !arara ''-v %''&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :map-expr&lt;/code&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-02-27T10:30:22.463" LastActivityDate="2018-02-27T10:30:22.463" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15377" PostTypeId="1" AcceptedAnswerId="15387" CreationDate="2018-02-27T18:07:06.977" Score="2" ViewCount="101" Body="&lt;p&gt;I have a beamer(LaTeX) file containing many &lt;code&gt;\begin{frame}&lt;/code&gt; lines. I want to debug the code to viewing the output of its. The pdf output shows frame number. When I try to change a specific numbered frame in source I have to give more time to find out that frame as there is no fame numbering in source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I want to give frame number as comment in each &lt;code&gt;\begin{frame}&lt;/code&gt; as &lt;code&gt;\begin{frame}%frame_no&lt;/code&gt; when it is not commented yet.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, I don't want to write this each time when I add a frame and calculate the number. I want to make this autonomous such that when I press &lt;code&gt;:w&lt;/code&gt; or any user command it add the frame number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample file - &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\documentclass[usenames,dvipsnames]{beamer}&#xA;\usepackage{xcolor}&#xA;\usepackage{tikz}&#xA;\usepackage{listings}&#xA;\usepackage{algpseudocode}&#xA;\usefonttheme[onlymath]{serif}&#xA;\usepackage{amsmath}&#xA;\usetheme{Madrid}&#xA;&#xA;&#xA;\algnewcommand\algorithmicinput{\textbf{Input:}}&#xA;\algnewcommand\algorithmicoutput{\textbf{Output:}}&#xA;\algnewcommand\algorithmicinitialization{\textbf{Initialize:}}&#xA;\algnewcommand\Input{\item[\algorithmicinput]}%&#xA;\algnewcommand\Output{\item[\algorithmicoutput]}%&#xA;\algnewcommand\Initialize{\item[\algorithmicinitialization]}%&#xA;&#xA;&#xA;\logo{%&#xA;  \includegraphics[width=1cm,height=1.5cm,keepaspectratio]{Image/DUlogo}%&#xA;  \hspace{\dimexpr\paperwidth-2cm-5pt}%&#xA;  \includegraphics[width=1cm,height=1cm,keepaspectratio]{Image/GNR.png}%&#xA;}&#xA;\begin{document}&#xA;  \title{Cross-Layer  Resource  Allocation With  Elastic Service Scaling in Cloud Radio Access Network}&#xA;  \author[alhelal \&amp;amp; Jobayed Ullah]{&#xA;  \parbox{2.5cm}{&#xA;\centering Md.Al-Helal\\Roll:SH-51}\hspace{1cm}&#xA;\parbox{2.5cm}{&#xA;{\centering Jobayed Ullah\\Roll:EK-107}}&#xA;}&#xA;\institute[CSEDU]{Computer Science \&amp;amp; Engineering\\CSEDU}&#xA;\date{February 25, 2018}&#xA;\begin{frame}&#xA;  \maketitle&#xA;\end{frame}&#xA;  \title{Cross-Layer  Resource  Allocation With  Elastic Service Scaling in Cloud Radio Access Network}&#xA;  \author{Jianhua Tang\\ Wee Pen Tay\\ Tony Q. S. Quek}&#xA;\institute{IEEE Transactions on Wireless Communications, vol 14, no. 9}&#xA;\date{September 2015}&#xA;\begin{frame}&#xA;  \maketitle&#xA;\end{frame}&#xA;  \author{alhelal \&amp;amp; Jobayed Ullah}&#xA;\institute{CSEDU}&#xA;\begin{frame}&#xA;\maketitle&#xA;\end{frame}&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9498" LastActivityDate="2018-02-28T17:00:47.550" Title="How to replace string with value and the occurance number?" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15378" PostTypeId="2" ParentId="15377" CreationDate="2018-02-27T18:39:03.640" Score="2" Body="&lt;p&gt;If I understand you correctly, you should be able to to it with e.g. a custom command. Something like this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function NumberFrame(match)&#xA;    let g:number+=1&#xA;    return a:match.'%'.g:number&#xA;endfunction&#xA;&#xA;:com! NumberFrame :let g:number=0|:%s#\(\\begin{frame}\)\(%\d\+\)\?#\=NumberFrame(submatch(1))#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That uses a custom command &lt;code&gt;:NumberFrame&lt;/code&gt;, that first initializes the counter, followed by a &lt;code&gt;:s&lt;/code&gt; command that looks for &lt;code&gt;\begin{frame}&lt;/code&gt; followed by an optional comment, takes the input to a function that increments the counter and returns the input followed by your comment. So in your Latex document simply call &lt;code&gt;:NumberFrame&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can put that definition into &lt;code&gt;~/.vim/vimrc&lt;/code&gt; (or whatever vimrc file you are using) or you can put that into &lt;code&gt;~/.vim/ftplugin/tex.vim&lt;/code&gt; to make that command filetype specific (e.g. it will only be available in tex documents). Make sure you have a line &lt;code&gt;:filetype plugin on&lt;/code&gt; in your .vimrc to enable filetype specific plugins. In that case you should probably put a &lt;code&gt;:let b:undo_ftplugin=':delcommand NumberFrame'&lt;/code&gt; to delete the command when another filetype is loaded. See the help at &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#undo_ftplugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h undo_ftplugin&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get more fancy about it (e.g. add some more error conditions, refine your regular expression, recount on &lt;code&gt;BufWritePre&lt;/code&gt; autocommands, etc). But as such it is a simple solution that shows how to do the main thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the help at &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h sub-replace-expression&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-02-28T06:37:21.803" LastActivityDate="2018-02-28T06:37:21.803" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15379" PostTypeId="1" CreationDate="2018-02-27T18:48:10.937" Score="1" ViewCount="498" Body="&lt;p&gt;The help text for &lt;code&gt;fileencodings&lt;/code&gt; says this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is a list of character encodings considered when starting to edit&#xA;      an existing file.  When a file is read, Vim tries to use the first&#xA;      mentioned character encoding.  If an error is detected, the next one&#xA;      in the list is tried.  When an encoding is found that works,&#xA;      'fileencoding' is set to it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since all byte strings are valid &lt;code&gt;latin1&lt;/code&gt; text, but &lt;code&gt;utf-8&lt;/code&gt; is more common, I have set my &lt;code&gt;fileencodings&lt;/code&gt; as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fileencodings=utf-8,latin1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, vim appears to use &lt;code&gt;utf-8&lt;/code&gt; even when there are decoding errors. A minimal example is the file containing the bytes &lt;code&gt;0x00 0xfd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% xxd test.in&#xA;00000000: 00fd                                     ..&#xA;% vim test.in&#xA;&quot;test.in&quot; [noeol][ILLEGAL BYTE in line 1] 1L, 2C&#xA;:set fileencoding?&#xA;fileencoding=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is this? How can I ask vim to fall back to latin1 when it sees illegal bytes?&lt;/p&gt;&#xA;" OwnerUserId="2982" LastActivityDate="2018-03-29T20:26:00.797" Title="Can I fall back to latin1 if there are illegal bytes?" Tags="|encoding|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15380" PostTypeId="2" ParentId="15379" CreationDate="2018-02-27T18:58:02.750" Score="0" Body="&lt;p&gt;I think this is, because Vim uses the &lt;code&gt;utf-8&lt;/code&gt; encoding. it should work when manually forcing &lt;code&gt;encoding=latin1&lt;/code&gt;. However I would not recommend setting this option. An alternative is to force Vim reading that file with a latin1 encoding, like this &lt;code&gt;:e ++enc=latin1&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-02-27T18:58:02.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15382" PostTypeId="1" CreationDate="2018-02-27T21:22:36.947" Score="0" ViewCount="819" Body="&lt;p&gt;Regarding this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f{char}                 To [count]'th occurrence of {char} to the right.  The&#xA;                        cursor is placed on {char} |inclusive|.&#xA;                        {char} can be entered as a digraph |digraph-arg|.&#xA;                        When 'encoding' is set to Unicode, composing&#xA;                        characters may be used, see |utf-8-char-arg|.&#xA;                        |:lmap| mappings apply to {char}.  The CTRL-^ command&#xA;                        in Insert mode can be used to switch this on/off&#xA;                        |i_CTRL-^|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to change its behaviour as such. Take this sample string, in which &lt;code&gt;^&lt;/code&gt; indicates the cursor position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fooBar(); // boat programming SO meme&#xA;^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The keystroke: &lt;code&gt;fb&lt;/code&gt; would ordinarily jump to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fooBar(); // boat programming SO meme&#xA;             ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would rather have it jump to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fooBar(); // boat programming SO meme&#xA;   ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sense? Ideally the solution should continue to work with ';' &lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2018-04-09T14:08:31.963" Title="How to make f{char} case insensitive?" Tags="|vimrc|cursor-movement|cursor-motions|letter-case|find|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15383" PostTypeId="1" CreationDate="2018-02-27T21:25:58.650" Score="4" ViewCount="2974" Body="&lt;p&gt;If I quit Neovim's containing terminal without exiting Vim first, then the next time I run Neovim I get the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E575: Error while reading ShaDa file: mark entry at position 2957 has&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to not see this error on startup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To reproduce this error run &lt;code&gt;nvim --cmd term&lt;/code&gt; exit the terminal while still in vim and then run &lt;code&gt;nvim --cmd term&lt;/code&gt; again. This error is caused by not exiting vim before closing the terminal.&lt;/p&gt;&#xA;" OwnerUserId="16515" LastEditorUserId="343" LastEditDate="2018-03-05T15:50:21.803" LastActivityDate="2018-07-07T17:24:25.567" Title="How can I suppress startup error E575?" Tags="|neovim|error|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15384" PostTypeId="2" ParentId="2867" CreationDate="2018-02-28T03:58:55.487" Score="6" Body="&lt;p&gt;Christian Brabandt has listed &lt;a href=&quot;https://superuser.com/a/935646/52910&quot;&gt;a number of different methods&lt;/a&gt; over on superuser.com.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like this one because it is short:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @z = system(&quot;date&quot;)[:-2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastActivityDate="2018-02-28T03:58:55.487" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15385" PostTypeId="1" CreationDate="2018-02-28T08:16:21.283" Score="3" ViewCount="112" Body="&lt;p&gt;I want to syntax highlight a header region in custom style and a body region with the existing markdown style:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Title: Test Note&#xA;Id: 147648d8-8680-4847-8f50-dd4a67f870b5&#xA;Created-At: 2018-02-26 22:44:20.784550+00:00&#xA;Updated-At: 2018-02-26 22:44:20.784550+00:00&#xA;&#xA;# A heading&#xA;Some text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The common start and end of the regions &lt;code&gt;Header&lt;/code&gt; and &lt;code&gt;markdownBody&lt;/code&gt; is the blank line. I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match HeaderValue contained '.*$'&#xA;syn match HeaderKey contained '^.*:' nextgroup=HeaderValue&#xA;&#xA;syn region Header start=&quot;\%^&quot; end=&quot;\ze\n\n&quot; transparent contains=HeaderKey&#xA;&#xA;unlet! b:current_syntax&#xA;syn include @MARKDOWN syntax/markdown.vim&#xA;let b:current_syntax = &quot;mystyle&quot;&#xA;&#xA;syn region MarkdownBody start=&quot;\n\n&quot; end=&quot;\%$&quot; contains=@MARKDOWN&#xA;&#xA;hi def link HeaderKey Type&#xA;hi def link HeaderValue Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works for the header, but not for the body. If I replace the two occurrences of &lt;code&gt;\n\n&lt;/code&gt; with, e. g., &lt;code&gt;END&lt;/code&gt; and replace the blank line in the text with &lt;code&gt;END&lt;/code&gt;, it works, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to mean there is a special handling of &lt;code&gt;\n\n&lt;/code&gt;. How can I use a blank line as a &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; marker?&lt;/p&gt;&#xA;" OwnerUserId="16519" LastActivityDate="2018-03-01T14:28:14.600" Title="Use blank line as end for one region and as start of another" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15387" PostTypeId="2" ParentId="15377" CreationDate="2018-02-28T15:22:18.483" Score="1" Body="&lt;p&gt;There is another way to proceed without needing to define an helper function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to fill a list and to inject the list size with &lt;code&gt;:s\=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let counter=[]&#xA;:%s/\\begin{frame}\zs\(%\d\+\)\=/\='%'.len(add(counter, 42))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or as a command in a &lt;code&gt;~/.vim/ftplugin/tex/count-frames.vim&lt;/code&gt; ftplugin file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -b -range=% -nargs=0 NumberFrames &#xA;    \ :let g:counter=[]|:&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;s/\\begin{frame}.\{-}\zs\(%frame_\d\+\|$\)/\='%frame_'.len(add(g:counter, 42))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will work on the whole buffer by default, or only on a given range that can be defined explicitly  (&lt;code&gt;:12,42NumberFrames&lt;/code&gt;) or with a visual selection (&lt;code&gt;'&amp;lt;,'&amp;gt;NumberRanges&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-02-28T17:00:47.550" LastActivityDate="2018-02-28T17:00:47.550" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="15388" PostTypeId="1" AcceptedAnswerId="15389" CreationDate="2018-02-28T18:07:59.927" Score="1" ViewCount="531" Body="&lt;p&gt;Is there a good macro or regex expression that I can use in Vim to generate a &lt;code&gt;.h&lt;/code&gt; file from a &lt;code&gt;.c&lt;/code&gt; file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, take the following &lt;code&gt;.c&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// temp.c&#xA;// comment 1&#xA;// comment 2&#xA;void function1(int a, int b) {&#xA;    int x = 0;&#xA;    if (x == 0) {&#xA;        x = 1;&#xA;    }&#xA;    else { x = 2; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and generate the following &lt;code&gt;.h&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// temp.h&#xA;// comment 1&#xA;// comment 2&#xA;void function1(int a, int b);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My current method involves copying the &lt;code&gt;.c&lt;/code&gt; file, renaming it as a &lt;code&gt;.h&lt;/code&gt; file, then just deleting lines until it makes a header file&lt;/p&gt;&#xA;" OwnerUserId="13078" LastActivityDate="2018-03-01T14:20:04.770" Title="C - Generate .h file from .c file" Tags="|regular-expression|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15389" PostTypeId="2" ParentId="15388" CreationDate="2018-02-28T18:38:25.317" Score="2" Body="&lt;p&gt;If it's always in that format, you could do the following regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v^\S.*\zs \{$\n(.*\n)*\}$/;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this isn't a foolproof method because it relies on proper formatting. It's also pretty verbose and rather hard to understand. I would prefer a &lt;em&gt;global&lt;/em&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\S.*{$/norm $hc%;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This basically just says &lt;em&gt;on any line where &lt;code&gt;^\S.*{$&lt;/code&gt; matches&lt;/em&gt; (e.g. the start of a function) &lt;em&gt;run the following command&lt;/em&gt;. The command to run is &lt;code&gt;$hc%;&lt;/code&gt;, which in normal mode, will go to the end of the line, back one character, and change everything until the matching &lt;code&gt;}&lt;/code&gt; with a &lt;code&gt;;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-02-28T18:38:25.317" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15390" PostTypeId="2" ParentId="15388" CreationDate="2018-02-28T20:24:16.573" Score="0" Body="&lt;p&gt;Many thanks to @DJMcMayhem for his answer. For anyone else who comes to this post, I changed the regex a little bit and stuck it in a function like the one below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; convert a .c file to a .h file&#xA;fun! s:convertC2H()&#xA;    w %:r.h&#xA;    tabe %:r.h&#xA;    execute 'g/^\S.*{$/norm $h%s;'&#xA;endfun&#xA;command! ConvertC2H :call s:convertC2H()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I edited the function to now also include copying the &lt;code&gt;.c&lt;/code&gt; file out to a &lt;code&gt;.h&lt;/code&gt; file (with the same name except the file extension).&lt;/p&gt;&#xA;" OwnerUserId="13078" LastEditorUserId="13078" LastEditDate="2018-03-01T14:20:04.770" LastActivityDate="2018-03-01T14:20:04.770" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15391" PostTypeId="1" AcceptedAnswerId="15408" CreationDate="2018-03-01T02:49:38.927" Score="2" ViewCount="317" Body="&lt;p&gt;I am trying to improve Vim's syntax highlighting for YAML files. YAML supports long string literals that begin with either a &quot;&gt;&quot; or &quot;|&quot;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;keyA: &amp;gt;&#xA;  A string literal&#xA;  that spans&#xA;&#xA;  multiple lines&#xA;keyB:&#xA;  keyC: |&#xA;    Another string literal&#xA;    That spans multiple lines&#xA;keyD: somevalue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The scope of the string is indentation-dependent -- everything is included in it until a line with a smaller indent begins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have defined a syntax region like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region yamlLongStringLiteral start=&quot;\v\&amp;gt;|\|&quot; end=/^\ze\S/ contains=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note: I've excluded &lt;code&gt;contained&lt;/code&gt; from the definition above because it 's irrelevant to this question). This works for string literals stored in top-level keys (e.g. &lt;code&gt;keyA&lt;/code&gt; above) but fails for literals stored in nested keys (e.g. &lt;code&gt;keyC&lt;/code&gt; above). What I need to do is detect the indentation of the first line of the long literal and terminate the region on the first line with a lesser indent level. This would seem to require accessing captured groups from the start pattern in the end pattern. Is this possible, or is there some other way to accomplish my goal?&lt;/p&gt;&#xA;" OwnerUserId="13151" LastActivityDate="2018-03-01T21:24:16.333" Title="Backreference for syntax region" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15392" PostTypeId="1" AcceptedAnswerId="15398" CreationDate="2018-03-01T04:19:43.470" Score="1" ViewCount="208" Body="&lt;p&gt;I recently became aware of the &lt;code&gt;getcompletion&lt;/code&gt; function which can return autocompletion options for a variety of different things &lt;em&gt;(shell commands, vim autocommand events, files, etc.)&lt;/em&gt;.  Many of the types of things that it can autocomplete are not available in insert mode completion &lt;em&gt;(see &lt;code&gt;ins-completion&lt;/code&gt;)&lt;/em&gt;.  Is there a way of harnessing &lt;code&gt;getcompletion&lt;/code&gt; in insert mode autocompletion?&lt;/p&gt;&#xA;" OwnerUserId="865" LastActivityDate="2018-03-01T10:18:57.217" Title="Using getcompletion function for insert mode autocompletion" Tags="|autocompletion|insert-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15393" PostTypeId="1" AcceptedAnswerId="15394" CreationDate="2018-03-01T06:45:05.057" Score="2" ViewCount="682" Body="&lt;p&gt;I just discovered that vim defaults &lt;code&gt;modeline&lt;/code&gt; to &lt;code&gt;off&lt;/code&gt; when executed as &lt;em&gt;root&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the reason for this?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="51" LastEditDate="2018-03-01T07:16:04.230" LastActivityDate="2018-03-01T07:16:04.230" Title="Why is modeline off for root?" Tags="|modeline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15394" PostTypeId="2" ParentId="15393" CreationDate="2018-03-01T06:58:40.423" Score="2" Body="&lt;p&gt;That is for security reasons. In the past, there have been a couple of vulnerabilities that resulted in e.g. arbitrary code execution. Also you might not want to have certain options set &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So one of the measures against it was to disallow modelines for the super user. Another measure was that only certain safe considered options can be set. Options that take an expression are generally not allowed to be set via modelines as this would result in having arbitrary vim code executed while reading a file.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-03-01T06:58:40.423" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15395" PostTypeId="1" CreationDate="2018-03-01T07:23:43.483" Score="1" ViewCount="213" Body="&lt;p&gt;Every time I open a file from NERDTree, it seems to do a &lt;code&gt;:lcd&lt;/code&gt; to the location of that file. If I open 5 files from NERDTree, I will have 5 different working directories in each buffer. I can't seem to find the setting that affects this behavior.&lt;/p&gt;&#xA;" OwnerUserId="3378" LastEditorUserId="1841" LastEditDate="2018-03-01T08:40:28.727" LastActivityDate="2018-03-01T08:40:28.727" Title="NERDTree seems to perform :lcd" Tags="|plugin-nerdtree|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15396" PostTypeId="2" ParentId="2995" CreationDate="2018-03-01T08:47:49.547" Score="-1" Body="&lt;p&gt;You can try this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:colorscheme&lt;/code&gt;, Then hit the &lt;kbd&gt;space&lt;/kbd&gt; key and then the &lt;kbd&gt;tab&lt;/kbd&gt; key.&lt;/p&gt;&#xA;" OwnerUserId="16532" LastEditorUserId="1841" LastEditDate="2018-03-01T09:28:55.797" LastActivityDate="2018-03-01T09:28:55.797" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15398" PostTypeId="2" ParentId="15392" CreationDate="2018-03-01T10:18:57.217" Score="1" Body="&lt;p&gt;You can set up &quot;user completion&quot; (invoked with in insert mode with &lt;kbd&gt;Ctrl-X&lt;/kbd&gt;&lt;kbd&gt;Ctrl-U&lt;/kbd&gt;) to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CompleteColorschemes(findstart, base)&#xA;  if a:findstart&#xA;    &quot; locate the start of the word&#xA;    let line = getline('.')&#xA;    let start = col('.') - 1&#xA;    while start &amp;gt; 0 &amp;amp;&amp;amp; line[start - 1] =~ '\a'&#xA;      let start -= 1&#xA;    endwhile&#xA;    return start&#xA;  else&#xA;    &quot; Use getcompletion() to complete colorschemes&#xA;    return getcompletion(a:base, 'color')&#xA;  endif&#xA;endfunction&#xA;set completefunc=CompleteColorschemes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a slight adaptation of the example given in &lt;code&gt;:help complete-functions&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Omni completion (&lt;code&gt;omnifunc&lt;/code&gt;, &lt;kbd&gt;Ctrl-X&lt;/kbd&gt;&lt;kbd&gt;Ctrl-O&lt;/kbd&gt;) works in the same way, and is intended for filetype-specific completions&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-03-01T10:18:57.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15399" PostTypeId="2" ParentId="2995" CreationDate="2018-03-01T12:04:02.553" Score="8" Body="&lt;p&gt;If you want to do this in Vimscript, you can get a &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#List&quot; rel=&quot;noreferrer&quot;&gt;List&lt;/a&gt; of color schemes by using the getcompletion() function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let c = getcompletion('', 'color')&#xA;echo c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a bit simpler than the existing Vimscript answer, which scans the filesystem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help getcompletion()&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-01T17:31:40.727" LastActivityDate="2018-03-01T17:31:40.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15401" PostTypeId="1" AcceptedAnswerId="15403" CreationDate="2018-03-01T13:36:33.270" Score="4" ViewCount="1391" Body="&lt;p&gt;I added and use &lt;a href=&quot;https://github.com/Shougo/deoplete.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;deoplete&lt;/a&gt; to get a list of completion while typing. However, typing in a word shows the completion list with the cursor being nowhere on the list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On some IDEs like Xcode, when you type in a word, the completion pops up with the cursor already on the first item. So it is possble to just push &lt;kbd&gt;return&lt;/kbd&gt; to choose the completion, instead of pushing &lt;kbd&gt;down&lt;/kbd&gt; and &lt;kbd&gt;return&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is more convenient yet all the GIFs on the deocomplete Github page don't put the cursor on the first item. Is it possible to archive this behavior?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastEditorUserId="343" LastEditDate="2018-03-01T14:13:53.963" LastActivityDate="2018-03-01T16:29:26.063" Title="Is it possible to put the cursor on the first item on auto-completion?" Tags="|autocompletion|plugin-deoplete|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15402" PostTypeId="2" ParentId="15385" CreationDate="2018-03-01T14:28:14.600" Score="1" Body="&lt;p&gt;Ok, I found the solution: differently from what I assumed, &lt;code&gt;syn region&lt;/code&gt; works line-oriented already, so a single &lt;code&gt;\n&lt;/code&gt; instead of &lt;code&gt;\n\n&lt;/code&gt; does it. Take a look at &lt;a href=&quot;https://github.com/fqxp/nete-vim/blob/master/syntax/nete.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;the working code&lt;/a&gt; if you’re interested.&lt;/p&gt;&#xA;" OwnerUserId="16519" LastActivityDate="2018-03-01T14:28:14.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15403" PostTypeId="2" ParentId="15401" CreationDate="2018-03-01T16:29:26.063" Score="7" Body="&lt;p&gt;If you use the &lt;code&gt;noinsert&lt;/code&gt; flag in &lt;code&gt;completeopt&lt;/code&gt; in combination with &lt;code&gt;menu&lt;/code&gt;, the first item will be selected (but not inserted into the buffer).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; set completeopt=menu,noinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-03-01T16:29:26.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15404" PostTypeId="1" AcceptedAnswerId="15406" CreationDate="2018-03-01T16:29:41.550" Score="0" ViewCount="632" Body="&lt;p&gt;Basically, I need to indent a block of R code. Unfortunately, vim's tab size is bigger than the two spaces that I'm using. Is it possible to accomplish this without hitting the space bar twice for every line I need to indent?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motivation for this may be of note: I originally wrote the script in Rstudio before moving it to a server. Many indents just go away when I edit the server-side file with vim. However, if I transfer the file to my laptop (via winSCP) and open it in rstudio, all the indents look perfect!&lt;/p&gt;&#xA;" OwnerUserId="14452" LastActivityDate="2018-03-01T20:09:40.003" Title="Pseudo-Indent (two spaces) Multiple Lines" Tags="|indentation|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15405" PostTypeId="1" AcceptedAnswerId="15661" CreationDate="2018-03-01T19:25:56.683" Score="4" ViewCount="511" Body="&lt;p&gt;I'm using one of Vim distribution called SpaceVim and everything is good enough except some details. How do I make spacevim to preserve column position when moving between lines? For instance - move from first line and 10 column (1:10) to second line without any columns (2:1) and then get back (all using &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; keys). Now you are on 1:1 position instead of 1:10 as expected and how &lt;strong&gt;nvim behaves by default&lt;/strong&gt;. What option or toggle is responsible for column position preserving? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="16538" LastEditorUserId="16280" LastEditDate="2018-03-02T15:54:09.063" LastActivityDate="2018-03-25T13:50:02.330" Title="How do I make Vim preserve column position when moving between lines?" Tags="|cursor-movement|spacevim|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="15406" PostTypeId="2" ParentId="15404" CreationDate="2018-03-01T20:09:40.003" Score="1" Body="&lt;p&gt;First, you probably want to set &lt;code&gt;tabstop&lt;/code&gt; and &lt;code&gt;shiftwidth&lt;/code&gt; to &lt;code&gt;2&lt;/code&gt; to have the indentation work as you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you want these settings applied only for the files with the filetype &lt;code&gt;r&lt;/code&gt;, the best way to do that is to create a custom &lt;code&gt;ftplugin&lt;/code&gt;. To do that you want to create the file &lt;code&gt;~/.vim/after/ftplugin/r.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This file will be sourced when the filetype of a buffer is set to &lt;code&gt;r&lt;/code&gt; and after the &lt;code&gt;ftplugin&lt;/code&gt; which comes with Vim by default has been sourced (this way you don't loose the already existing settings).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this file you can simply add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal tabstop=2&#xA;setlocal shiftwidth=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here you need to use &lt;code&gt;setlocal&lt;/code&gt; instead of &lt;code&gt;set&lt;/code&gt; to make sure that the settings will only apply to the current buffer and not to all buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some interesting related help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#ftplugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ftplugin&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%3asetlocal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :setlocal&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27shiftwidth%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'shiftwidth'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27tabstop%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'tabstop'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And a good read about indentation settings in Vim: &lt;a href=&quot;https://www.reddit.com/r/vim/wiki/tabstop&quot; rel=&quot;nofollow noreferrer&quot;&gt;/r/vim wiki&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-03-01T20:09:40.003" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15407" PostTypeId="1" CreationDate="2018-03-01T20:28:25.487" Score="2" ViewCount="38" Body="&lt;p&gt;On Windows I'm used to have the gVimDiff context menu when two or more files are selected in Windows Explorer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something similar for Nemo on Ubuntu? I searched for the string in the title and nothing relevant seemed to have been returned.&lt;/p&gt;&#xA;" OwnerUserId="2334" LastActivityDate="2018-03-01T20:28:25.487" Title="gVimDiff in Nemo context menu" Tags="|linux-ubuntu|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15408" PostTypeId="2" ParentId="15391" CreationDate="2018-03-01T21:24:16.333" Score="2" Body="&lt;p&gt;Thanks to Christian's comment above, I came up with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region yamlLongStringLiteral&#xA;      \ start=&quot;\(&amp;gt;\||\) *\n^\z( \+\)&quot;&#xA;      \ end=&quot;^\(\z1\|$\)\@!&quot;&#xA;      \ contains=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\z&lt;/code&gt; in the start pattern stores a group holding the leading indent, which is then referenced in the end pattern with &lt;code&gt;\z1&lt;/code&gt;.  &lt;code&gt;\@!&lt;/code&gt; does negative lookahead, so &lt;code&gt;^\(\z1|$\)\@!&lt;/code&gt; means: &quot;any non-empty line that does not start with the saved indent group&quot;.&lt;/p&gt;&#xA;" OwnerUserId="13151" LastActivityDate="2018-03-01T21:24:16.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15409" PostTypeId="1" AcceptedAnswerId="15412" CreationDate="2018-03-01T22:37:06.637" Score="2" ViewCount="80" Body="&lt;p&gt;I am trying to do a search and replace in vim (rather, gvim) and keep getting stuck up trying to separate words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to convert something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(COND &amp;lt;ASEL&amp;amp;~ASELb|XOR|~XORb&amp;gt; (&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(COND ASEL=1'b1 &amp;amp;&amp;amp; ASELb=1'b0 || XOR=1'b1 || XORb=1'b1 (&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, every occurrence of these 'words' has to be changed this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~ABC --&amp;gt; ABC=1'b0&#xA; ABC --&amp;gt; ABC=1'b1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried something like this to do it but can't get the pattern to match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\([&amp;lt;&amp;amp;|]\)\~\([^&amp;lt;&amp;amp;|]\)\([&amp;gt;&amp;amp;|]\)/\1\2==1'b0\3&#xA;s/\([&amp;lt;&amp;amp;|]\)\([^&amp;lt;&amp;amp;|=]+\)\([&amp;gt;&amp;amp;|]\)/\1\2==1'b1\3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea behind this was to do one 'word' at a time by separating it out in \2 above and then printing \1 and \3 as is with \2=1'b0 or \2=1'b1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then take care of the rest, like '&amp;amp;' going to '&amp;amp;&amp;amp;', removing the '&amp;lt;..&gt;' at the ends in the subsequent commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong here? Is there a better way to go about this?&lt;/p&gt;&#xA;" OwnerUserId="16540" LastActivityDate="2018-05-01T05:06:07.533" Title="Break-down long strings and search/replace individual words" Tags="|regular-expression|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15410" PostTypeId="2" ParentId="10897" CreationDate="2018-03-02T01:05:29.613" Score="49" Body="&lt;p&gt;One quick fix is to disable syntax highlighting. Sometimes the code syntax highlighting will cause the foreground text to be the same color as the vimdiff background color, making the text &quot;invisible&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:syntax off&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to automatically do this for vimdiff, then add this to the end of your &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;diff&#xA;    syntax off&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6610" LastEditorUserId="6610" LastEditDate="2018-03-02T01:16:12.113" LastActivityDate="2018-03-02T01:16:12.113" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15412" PostTypeId="2" ParentId="15409" CreationDate="2018-03-02T04:26:18.613" Score="0" Body="&lt;p&gt;see if this works...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(COND &amp;lt;ASEL&amp;amp;~ASELb|XOR|~XORb&amp;gt; (&#xA;&#xA;#step 1&#xA;s/\v[&amp;lt;&amp;amp;|]\zs\u+/&amp;amp;=1'b1/g&#xA;(COND &amp;lt;ASEL=1'b1&amp;amp;~ASELb|XOR=1'b1|~XORb&amp;gt; (&#xA;&#xA;#step 2&#xA;s/\v[&amp;lt;&amp;amp;|]\zs\~(\u+b)/\1=1'b0/g&#xA;(COND &amp;lt;ASEL=1'b1&amp;amp;ASELb=1'b0|XOR=1'b1|XORb=1'b0&amp;gt; (&#xA;&#xA;#step 3&#xA;s/[&amp;amp;|]/ &amp;amp;&amp;amp; /g&#xA;(COND &amp;lt;ASEL=1'b1 &amp;amp;&amp;amp; ASELb=1'b0 || XOR=1'b1 || XORb=1'b0&amp;gt; (&#xA;&#xA;#step 4&#xA;s/[&amp;lt;&amp;gt;]//g&#xA;(COND ASEL=1'b1 &amp;amp;&amp;amp; ASELb=1'b0 || XOR=1'b1 || XORb=1'b0 (&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; is very magic mode so that &lt;code&gt;()&lt;/code&gt;, &lt;code&gt;+&lt;/code&gt; etc doesn't need to be escaped&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs&lt;/code&gt; to set start of match&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;as one-liner&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\v[&amp;lt;&amp;amp;|]\zs\u+/&amp;amp;=1'b1/g | s/\v[&amp;lt;&amp;amp;|]\zs\~(\u+b)/\1=1'b0/g | s/[&amp;amp;|]/ &amp;amp;&amp;amp; /g | s/[&amp;lt;&amp;gt;]//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1616" LastActivityDate="2018-03-02T04:26:18.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15413" PostTypeId="1" AcceptedAnswerId="15414" CreationDate="2018-03-02T07:48:02.353" Score="0" ViewCount="606" Body="&lt;p&gt;In Vim, you can use &lt;Kbd&gt;Command&lt;/Kbd&gt; + &lt;Kbd&gt;Delete&lt;/Kbd&gt; to delete all texts before the current cursor on the line (on insert-mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this functionality doesn't seem to exist in Neovim. I tried moving my &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt; to somewhere else temporarily but only found it is persistent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does this useful key combination not work in Neovim? Or is it only me? &lt;/p&gt;&#xA;" OwnerUserId="1072" LastEditorUserId="16280" LastEditDate="2018-03-02T21:46:57.407" LastActivityDate="2018-03-02T21:46:57.407" Title="Why does the Command + delete not work in Neovim?" Tags="|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15414" PostTypeId="2" ParentId="15413" CreationDate="2018-03-02T13:47:20.760" Score="2" Body="&lt;p&gt;&lt;code&gt;Cmd + Delete&lt;/code&gt; is (obviously) a macOS only shortcut. I may be wrong but I think Neovim removed the runtime files that provided OS specific shortcuts. Anyway you can achieve the same using the standard &lt;code&gt;Ctrl + U&lt;/code&gt;. I say standard because you can try this shortcut on most Unix terminal applications (try it directly in Bash!) and it does the same regardless of the operating system (that means &lt;code&gt;Ctrl + U&lt;/code&gt; does the same in macOS, any Linux distribution, FreeBSD, Windows Subsystem for Linux, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim and of course Neovim make heavy use of standard terminal shortcuts, for example you can suspend them and go back to your command line with &lt;code&gt;Ctrl + Z&lt;/code&gt;, or delete the word before the cursor with &lt;code&gt;Ctrl + W&lt;/code&gt;. &lt;code&gt;:h CTRL-&lt;/code&gt; and then &lt;code&gt;Tab&lt;/code&gt; will allow you to see all the shortcuts with the &lt;code&gt;Ctrl&lt;/code&gt; modifier. &lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2018-03-02T13:47:20.760" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15415" PostTypeId="2" ParentId="15383" CreationDate="2018-03-02T14:33:43.667" Score="6" Body="&lt;p&gt;Check your &lt;code&gt;init.vim&lt;/code&gt;. If there is any line concerning &lt;code&gt;viminfo&lt;/code&gt;, temporarily remove/comment it, you can later discover the reason it messed up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then backup and remove &lt;code&gt;~/.local/share/nvim/shada&lt;/code&gt; folder. Then start up Neovim, the folder will be auto-generated with a file named &lt;code&gt;main.shada&lt;/code&gt;. Hopefully, your error will be gone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error possibly surfaced because neovim deprecated vim's &lt;code&gt;viminfo&lt;/code&gt; format. Instead neovim uses &lt;code&gt;shada&lt;/code&gt; or &lt;code&gt;shared data&lt;/code&gt;. But possibly your &lt;code&gt;init.vim&lt;/code&gt; contains some reference to &lt;code&gt;viminfo&lt;/code&gt; formatted code which it can't read.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2018-03-02T16:47:53.687" LastActivityDate="2018-03-02T16:47:53.687" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15416" PostTypeId="1" AcceptedAnswerId="15443" CreationDate="2018-03-02T15:18:51.830" Score="1" ViewCount="399" Body="&lt;p&gt;Recently I started using and learning Vim. I turned off movement keys in my &lt;code&gt;.vimrc&lt;/code&gt; file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Up&amp;gt; &amp;lt;NOP&amp;gt;&#xA;noremap &amp;lt;Down&amp;gt; &amp;lt;NOP&amp;gt;&#xA;noremap &amp;lt;Left&amp;gt; &amp;lt;NOP&amp;gt;&#xA;noremap &amp;lt;Right&amp;gt; &amp;lt;NOP&amp;gt;&#xA;noremap h &amp;lt;NOP&amp;gt;&#xA;noremap j &amp;lt;NOP&amp;gt;&#xA;noremap k &amp;lt;NOP&amp;gt;&#xA;noremap l &amp;lt;NOP&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I'd like to use netrw file browser, but I can't navigate in it without movement keys (&lt;kbd&gt;h&lt;/kbd&gt;, &lt;kbd&gt;j&lt;/kbd&gt;, &lt;kbd&gt;k&lt;/kbd&gt;, and &lt;kbd&gt;l&lt;/kbd&gt;, or arrow keys), since I disabled them. Is there a way to allow movement keys &lt;em&gt;in&lt;/em&gt; netrw (basically, allow movement only when a cursor in it)?&lt;/p&gt;&#xA;" OwnerUserId="16554" LastEditorUserId="16554" LastEditDate="2018-03-02T15:26:01.957" LastActivityDate="2019-02-17T17:06:22.757" Title="How to enable disabled movement keys in netrw?" Tags="|key-bindings|cursor-movement|netrw|filesystem|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15417" PostTypeId="1" CreationDate="2018-03-02T17:11:39.270" Score="0" ViewCount="243" Body="&lt;p&gt;I'm looking for a shortcut for loading back-reference groups using the same separator. Such a beast may not exist but it would be useful to me if it does. An example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting with this string&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:111 222 333 444 555&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;applying this pattern&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(\d\+\) \(\d\+\) \(\d\+\) \(\d\+\) \(\d\+\)/\5 \4 \3 \2 \1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will give me this result&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:555 444 333 222 111&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'm looking for is something to replace the match,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:\(\d\+\) \(\d\+\) \(\d\+\) \(\d\+\) \(\d\+\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by giving it a pattern and a separator, and have it load as many groups as match.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;::%s/&amp;lt;&quot;\(\d\+\) &quot;&amp;gt;/\5 \4 \3 \2 \1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="16556" LastActivityDate="2018-03-02T18:07:35.393" Title="loading back-reference groups &quot;shortcut&quot;" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15418" PostTypeId="2" ParentId="15417" CreationDate="2018-03-02T17:57:25.650" Score="2" Body="&lt;p&gt;Many ways to do it!&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Awk&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ awk '{for(i=1;i&amp;lt;=NF/2;i++) { t = $(NF-i+1); $(NF-i+1) = $i; $i = t; } print}' inpout.txt &amp;gt; output.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Prettier version of awk program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    for (i=1; i&amp;lt;=NF/2; i++) {&#xA;        t = $(NF-i+1);&#xA;        $(NF-i+1) = $i;&#xA;        $i = t;&#xA;    }&#xA;    print&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From inside Vim using filter, &lt;code&gt;:!&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!awk '{for(i=1;i&amp;lt;=NF/2;i++) { t = $(NF-i+1); $(NF-i+1) = $i; $i = t; } print}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Perl&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;From:  &lt;a href=&quot;https://unix.stackexchange.com/questions/46275/swapping-an-unlimited-number-of-columns&quot;&gt;Swapping an unlimited number of columns&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!perl -lane 'print join &quot; &quot;, reverse @F'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Pure Vim:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;split()&lt;/code&gt;, &lt;code&gt;join()&lt;/code&gt;, and &lt;code&gt;reverse()&lt;/code&gt; to parse &amp;amp; reverse each line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/call setline('.', join(reverse(split(getline(&quot;.&quot;), ' ')), &quot; &quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :g&#xA;:h :call&#xA;:h setline()&#xA;:h getline()&#xA;:h join()&#xA;:h reverse()&#xA;:h split()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-03-02T18:07:35.393" LastActivityDate="2018-03-02T18:07:35.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15419" PostTypeId="2" ParentId="15416" CreationDate="2018-03-03T03:38:43.563" Score="1" Body="&lt;p&gt;Since you said you're learning vim, I'd point you to learn your way through &lt;code&gt;autocmd&lt;/code&gt;. Take a look at &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/12.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I myself am pretty beginner at vimming, so if the solution doesn't work don't think you couldn't pull it off, it's probably because my solution is wrong. But try this anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put these lines in your &lt;code&gt;.vimrc&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup FiletypeSpecificMappings&#xA;    autocmd FileType netrw noremap &amp;lt;buffer&amp;gt; j j&#xA;    autocmd FileType netrw noremap &amp;lt;buffer&amp;gt; k k&#xA;    autocmd FileType netrw noremap &amp;lt;buffer&amp;gt; h h&#xA;    autocmd FileType netrw noremap &amp;lt;buffer&amp;gt; l l&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here if &lt;code&gt;netrw&lt;/code&gt; is opened its local buffer will have the above key mappings, not any other buffers. I searched for ways to compress these four lines into one but couldn't find any.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-17T17:06:22.757" LastActivityDate="2019-02-17T17:06:22.757" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="15420" PostTypeId="1" AcceptedAnswerId="15421" CreationDate="2018-03-03T06:05:07.597" Score="1" ViewCount="2181" Body="&lt;p&gt;I usually work on js files and php files. My js files require 2 spaces tab, whereas my php requires 4. How can I make vim dynamically change that depending on the file type I'm working on? &lt;/p&gt;&#xA;" OwnerUserId="14510" LastActivityDate="2019-02-17T17:00:52.730" Title="how to make vim indentation file type specific?" Tags="|tab-characters|" AnswerCount="1" CommentCount="0" ClosedDate="2018-03-03T23:49:53.163" ContentLicense="CC BY-SA 3.0" />
  <row Id="15421" PostTypeId="2" ParentId="15420" CreationDate="2018-03-03T06:43:54.063" Score="4" Body="&lt;p&gt;Putting these in your &lt;code&gt;.vimrc&lt;/code&gt; should do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup FileTypeSpecificAutocommands&#xA;    autocmd FileType javascript setlocal tabstop=2 softtabstop=2 shiftwidth=2&#xA;    autocmd FileType php setlocal tabstop=2 softtabstop=2 shiftwidth=2&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should also use expandtab to convert tabs into spaces, I think. Also, you might wanna check out &lt;a href=&quot;http://tedlogan.com/techblog3.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this blogpost&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you don't mind splitting up your vimrc in modular files, you can put the following commands in &lt;code&gt;~/.vim/after/ftplugin/javascript.vim&lt;/code&gt; and &lt;code&gt;~/.vim/after/ftplugin/php.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal tabstop = softtabstop = shiftwidth = 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-17T17:00:52.730" LastActivityDate="2019-02-17T17:00:52.730" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="15422" PostTypeId="1" AcceptedAnswerId="15502" CreationDate="2018-03-03T13:14:39.237" Score="4" ViewCount="1237" Body="&lt;p&gt;At some point an update broke my vim's spell checking ability. This is always a good opportunity to review my &lt;code&gt;.vimrc&lt;/code&gt;. I figured out that vim's spell checking abilities actually go far further then just checking a word against a dictionary. It can check for words it can't find, words that are wrongly capitalized, words that are rare (bonus question: What is an example of a rare word?) and words that are wrong for the region selected. I updated my &lt;code&gt;.vimrc&lt;/code&gt; to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Toggle spell checking&#xA;map &amp;lt;leader&amp;gt;ss :setlocal spell! spelllang=en_us&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; Colors for words that failed spell check&#xA;&quot; Word not recognized&#xA;hi clear SpellBad&#xA;hi SpellBad cterm=underline ctermfg=blue&#xA;&quot; Word not capitalized&#xA;hi clear SpellCap&#xA;hi SpellCap cterm=underline ctermfg=red&#xA;&quot; Word is rare&#xA;hi clear SpellRare&#xA;hi SpellRare cterm=underline ctermfg=green&#xA;&quot; Wrong spelling for selected region&#xA;hi clear SpellLocal&#xA;hi SpellLocal cterm=underline ctermfg=yellow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works like a charm! I now write a sentence:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DIRzd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DIRzd.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and am surprised to learn that &lt;code&gt;muon&lt;/code&gt; is wrong for the selected region. The way I understand this, is that &lt;code&gt;muon&lt;/code&gt; is correct in one English dialect. My question now is: How do I figure out in what dialect this word is considered as correct?&lt;/p&gt;&#xA;" OwnerUserId="6154" LastActivityDate="2018-03-09T16:15:06.637" Title="Figure out which dictionary is used when spell checking" Tags="|vimrc|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15423" PostTypeId="2" ParentId="10061" CreationDate="2018-03-03T14:42:46.253" Score="3" Body="&lt;p&gt;One dumb solution I find is to type &lt;code&gt;:!clear&lt;/code&gt; in vim, but this is just a temporary solution. I am yet to find a better solution. Are you able to fix your issue?&lt;/p&gt;&#xA;" OwnerUserId="16571" LastActivityDate="2018-03-03T14:42:46.253" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15424" PostTypeId="1" CreationDate="2018-03-03T14:51:00.177" Score="3" ViewCount="1483" Body="&lt;p&gt;I am using Vim, and somehow the Vim doesn't refresh display properly. &#xA;&lt;a href=&quot;https://i.stack.imgur.com/6UZ7G.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6UZ7G.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I use &lt;code&gt;set cursorline&lt;/code&gt; and move to the next time, the remnant of the cursorline remains. Same goes to when I type&lt;code&gt;:&lt;/code&gt;, the bottom panel is supposed to be cleared, but the text remained there, which is really annoying. I also tried &lt;code&gt;vim -U NONE -u NONE -N&lt;/code&gt; but it didn't solve the problem either. My system is xterm and vim is able to detect the right xterm. I am at a loss as to how to fixed the problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did find a temporary solution, that is type &lt;code&gt;:!clear&lt;/code&gt; in Vim, which will keep Vim functional for the session, but it's annoying that I have do this every time I go to vim. Just wondering if there is a better solution.&lt;/p&gt;&#xA;" OwnerUserId="16571" LastActivityDate="2018-03-03T15:57:05.667" Title="Vim display won't refresh" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15425" PostTypeId="2" ParentId="15424" CreationDate="2018-03-03T15:57:05.667" Score="2" Body="&lt;p&gt;I find the solution. Basically it's an encoding issue. For some reason my Vim doesn't work with UTF-8, so I set my system LANG to ASCII, now everything works just fine. In case anyone runs into similar problem, tinker your encoder setting, which might help.&lt;/p&gt;&#xA;" OwnerUserId="16571" LastActivityDate="2018-03-03T15:57:05.667" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15426" PostTypeId="1" AcceptedAnswerId="15428" CreationDate="2018-03-03T16:24:08.133" Score="2" ViewCount="315" Body="&lt;p&gt;I would like to use the mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-k&amp;gt; :bprev&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, whenever I press &lt;code&gt;ctrl-k&lt;/code&gt;, there is a second delay before anything happens. When I use a different key combination, like ctrl-j, everything works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea why this happens and how this can be solved?&lt;/p&gt;&#xA;" OwnerUserId="2455" LastActivityDate="2018-03-03T18:19:29.637" Title="Remapping ctrl-k has a delay" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15427" PostTypeId="2" ParentId="15405" CreationDate="2018-03-03T18:16:01.190" Score="1" Body="&lt;p&gt;I am learning light vimscripting, so I am not sure if this will work. But put these in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NextLine()&#xA;  let c = col(&quot;.&quot;)&#xA;  execute &quot;normal! j&quot; . c . &quot;|&quot;&#xA;endfunction&#xA;function! PreviousLine()&#xA;  let c = col(&quot;.&quot;)&#xA;  execute &quot;normal! k&quot; . c . &quot;|&quot;&#xA;endfunction&#xA;nnoremap j :call NextLine()&#xA;nnoremap k :call PreviousLine()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These will not give you native vim experience because if you go down to a line of zero column, then the next line will also be on the zeroth column, not the column of the previous column. This would require, I think, another function for checking if any &lt;kbd&gt;h&lt;/kbd&gt; or l has been pressed in between the function calls to preserve intelligent column number preservation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I think it should get the job done for now.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2018-03-03T18:16:01.190" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15428" PostTypeId="2" ParentId="15426" CreationDate="2018-03-03T18:19:29.637" Score="3" Body="&lt;p&gt;There is another mapping &lt;kbd&gt;Cntrl&lt;/kbd&gt;+&lt;kbd&gt;k&lt;/kbd&gt;+&lt;kbd&gt;something&lt;/kbd&gt; so that when you press &lt;kbd&gt;Cntrl&lt;/kbd&gt;+&lt;kbd&gt;k&lt;/kbd&gt;, it waits and sees if you press another key. Find and disable that keymapping and you should be good to go.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2018-03-03T18:19:29.637" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15429" PostTypeId="1" AcceptedAnswerId="15442" CreationDate="2018-03-04T12:11:59.160" Score="2" ViewCount="1275" Body="&lt;p&gt;Unfortunately &lt;code&gt;nnoremap ab gd:&lt;/code&gt; doesn't work on my machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I hit &lt;code&gt;ab&lt;/code&gt;, the &lt;code&gt;gd:&lt;/code&gt; remap selects the words under the cursor as &lt;code&gt;gd&lt;/code&gt; (or &lt;code&gt;gD&lt;/code&gt;) should do but it doesn't enter into command mode after as &lt;code&gt;:&lt;/code&gt; usually does. If I type the sequence &lt;code&gt;gd:&lt;/code&gt; or&lt;code&gt;gD:&lt;/code&gt; directly in neovim, it works fine and enters into command mode after selecting the words under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I replace &lt;code&gt;gd&lt;/code&gt; with &lt;code&gt;gg&lt;/code&gt;, &lt;code&gt;nnoremap ab gg:&lt;/code&gt; works fine. It moves to the beginning and enters command mode. Any ideas why &lt;code&gt;gg:&lt;/code&gt; works while &lt;code&gt;gd:&lt;/code&gt; doesn't?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to make a map such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gR gD:%s/&amp;lt;C-R&amp;gt;///gc&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for global search and replace&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;&#xA;NVIM v0.2.2&#xA;Build type: RelWithDebInfo&#xA;LuaJIT 2.0.4&#xA;Compilation: /usr/bin/x86_64-linux-gnu-gcc -g -O2 -fPIE -fstack-protector-    strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=2 -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_UNIBI_HAS_VAR_FROM -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/build/neovim-HJnLxJ/neovim-0.2.2/build/config -I/build/neovim-HJnLxJ/neovim-0.2.2/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/build/neovim-HJnLxJ/neovim-0.2.2/build/src/nvim/auto     -I/build/neovim-HJnLxJ/neovim-0.2.2/build/include&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;&#xA;Features: +acl +iconv +jemalloc +tui &#xA;See &quot;:help feature-compile&quot;&#xA;&#xA;   system vimrc file: &quot;$VIM/sysinit.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/nvim&quot;&#xA;&#xA;Run :checkhealth for more info&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My full plugin free &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt; looks like this (where &lt;code&gt;ab&lt;/code&gt; doesn't work and &lt;code&gt;ba&lt;/code&gt; does work):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guicursor=&#xA;nnoremap ab gD:&#xA;nnoremap ba gg:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ab gD:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gD&lt;/code&gt; means 'go to definition'. This fails when this command is executed at the defintion itself. It works only when:&#xA;&lt;strong&gt;the selected word is not the first occurence&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple workaround is to use a search with &lt;code&gt;*&lt;/code&gt; instead of 'go to definition'&#xA;&lt;code&gt;nnoremap ab *:&lt;/code&gt;. search and replace would then be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gR *:%s/&amp;lt;C-R&amp;gt;///gc&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16583" LastEditorUserId="1841" LastEditDate="2018-03-04T17:47:52.943" LastActivityDate="2018-03-05T15:26:51.113" Title="neovim nnoremap doesn't enter command mode after `gd`" Tags="|key-bindings|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15431" PostTypeId="1" CreationDate="2018-03-04T14:19:22.310" Score="7" ViewCount="17818" Body="&lt;p&gt;I know there'a probably a plugin for that, but since Neovim has a built-in terminal I wanna use it. I just want to bind a key that runs the current file in Python 3. I tried using @% and %, but the shell does not recognize these variables. I think the best way would be to export the current file path as an environment variable, and make use it on the terminal. How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="16290" LastActivityDate="2024-01-08T05:46:54.493" Title="How can I make the Neovim terminal run the current file in Python?" Tags="|neovim|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15432" PostTypeId="2" ParentId="3382" CreationDate="2018-03-04T17:28:21.347" Score="1" Body="&lt;p&gt;One practical use in one function. In the bellow function the python comment &lt;code&gt;#&lt;/code&gt; is added and removed depending on the result of &lt;code&gt;getline('.')[0]&lt;/code&gt;. If the line has a comment the char &lt;code&gt;#&lt;/code&gt; is deleted, but in this case we don't want it to mess with our default register.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleComment()&#xA;    let l:win_view = winsaveview()&#xA;    if getline('.')[0] == &quot;#&quot;&#xA;        normal! 0&quot;_x&#xA;    else&#xA;        normal! I#&#xA;    endif&#xA;    call winrestview(l:win_view)&#xA;endfunction&#xA;nnoremap &amp;lt;Leader&amp;gt;t :call ToggleComment()&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;Leader&amp;gt;t &amp;lt;C-o&amp;gt;:call ToggleComment()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2018-03-04T17:28:21.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15433" PostTypeId="1" CreationDate="2018-03-04T17:30:57.520" Score="1" ViewCount="37" Body="&lt;p&gt;I'm kinda new to vim, and I wanted to play with macros. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a bunch to fit with my previous muscle memory, including this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; imap &amp;lt;C-i&amp;gt; &amp;lt;ESC&amp;gt;m`$a&amp;lt;CR&amp;gt;&amp;lt;ESC&amp;gt;==k``i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The intended behavior was to create a line below the cursor, but keep editing the line. First it never really worked, and second, I could isolate this line of being responsible of something strange:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As soon as I add it, the Tab button is having exactly the same behavior as the CTRL+i button in edition mode. I may miss something obvious, would anyone have any idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;THanks&lt;/p&gt;&#xA;" OwnerUserId="16587" LastEditorUserId="1841" LastEditDate="2018-03-04T17:48:33.930" LastActivityDate="2018-03-04T19:09:35.967" Title="Unintended tabulation bind" Tags="|key-bindings|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15434" PostTypeId="2" ParentId="15433" CreationDate="2018-03-04T17:41:23.107" Score="2" Body="&lt;p&gt;First you might want to read &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#o&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h o&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#O&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h O&lt;/code&gt;&lt;/a&gt; which are built-in command to add new lines in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In insert mode these mappings are what you are trying to do (see &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL%2dO&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-O&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-k&amp;gt; &amp;lt;c-o&amp;gt;O&#xA;inoremap &amp;lt;c-j&amp;gt; &amp;lt;c-o&amp;gt;o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now about why your &lt;code&gt;tab&lt;/code&gt; key stops working: it is because your terminal sends the same keycode for &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; and &lt;code&gt;tab&lt;/code&gt;. You can see it in insert mode by pressing &lt;kbd&gt;ctrl+v&lt;/kbd&gt;&lt;kbd&gt;ctrl+i&lt;/kbd&gt; and &lt;kbd&gt;ctrl+v&lt;/kbd&gt;&lt;kbd&gt;tab&lt;/kbd&gt;. (See &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL%2dV&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-V&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made &lt;a href=&quot;https://vi.stackexchange.com/q/7722/1841&quot;&gt;this answer&lt;/a&gt; some time ago to help people debug this kind of problems.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-03-04T19:09:35.967" LastActivityDate="2018-03-04T19:09:35.967" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15435" PostTypeId="1" CreationDate="2018-03-05T02:11:11.300" Score="1" ViewCount="599" Body="&lt;p&gt;I just installed neovim. But I not sure how to auto indent bash code. I have vim configured so that it can autoindent code. My &lt;code&gt;~/.vimrc&lt;/code&gt; has the following code. But it seems that they will not be loaded with neovim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun BenIndent()&#xA;  let oldLine=line('.')&#xA;  normal gg=G&#xA;  execute ':' . oldLine&#xA;endfun&#xA;map -- :call BenIndent()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16594" LastActivityDate="2018-03-05T15:08:12.520" Title="How to indent bash code with neovim?" Tags="|neovim|indentation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15436" PostTypeId="2" ParentId="15435" CreationDate="2018-03-05T07:28:47.407" Score="0" Body="&lt;p&gt;I think you should use the function as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BenIndent()&#xA;  let oldLine=line('.')&#xA;  normal! gg=G&#xA;  execute ':' . oldLine&#xA;endfunction&#xA;nnoremap -- :call BenIndent()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should work now I think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I changed from your function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun -&amp;gt; function! BenIndent()  &quot; I've just always known functions to be declared this way, I may be wrong&#xA;  let oldLine=line('.')&#xA;  normal -&amp;gt; normal! gg=G      &quot; the ! sign tells vim to not remap the provided keys, e.g. if you map g to :q then vim would quit when indenting!&#xA;  execute ':' . oldLine&#xA;endfun -&amp;gt; endfunction         &quot; just my convention&#xA;map -&amp;gt; nnoremap -- :call BenIndent()&amp;lt;CR&amp;gt; &quot; noremap tells vim not to use remapped keys and n is for mapping in normal mode only, if you want in other modes change n with v, i or c etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;prefix of &lt;code&gt;-&amp;gt;&lt;/code&gt; is your code and suffix is mine.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2018-03-05T07:41:08.820" LastActivityDate="2018-03-05T07:41:08.820" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15437" PostTypeId="1" AcceptedAnswerId="15440" CreationDate="2018-03-05T07:54:46.347" Score="6" ViewCount="6018" Body="&lt;p&gt;I never thought of the use of foldcolumns in vim. There are &lt;code&gt;-&lt;/code&gt; and &lt;code&gt;+&lt;/code&gt; signs to indicate foldable or folded parts of the code, that I understand. But what about the numbers inside the cosecutive &lt;code&gt;-&lt;/code&gt; signs? If I increase foldcolumn width the numbers take another form. I learned that the numbers help to identify foldable parts properly. Can someone explain its use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read &lt;code&gt;foldcolumn.txt&lt;/code&gt;, &lt;code&gt;folding.txt&lt;/code&gt; and &lt;code&gt;foldmethods.txt&lt;/code&gt; and I still don't understand foldcolumns!&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-27T04:21:31.933" LastActivityDate="2019-02-27T04:21:31.933" Title="Use of Foldcolumns in Vim" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15438" PostTypeId="1" AcceptedAnswerId="15439" CreationDate="2018-03-05T13:59:41.977" Score="1" ViewCount="1036" Body="&lt;p&gt;I want to search file for pattern, duplicate every line that matches that pattern, then in perform substitution on each duplicated line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose file looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a 1&#xA;a 2&#xA;b 1&#xA;b 2&#xA;c 1&#xA;c 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to duplicate each line matching &lt;code&gt;/2&lt;/code&gt;, then substitute &lt;code&gt;2&lt;/code&gt; with &lt;code&gt;3&lt;/code&gt; (&lt;code&gt;s/2/3&lt;/code&gt;), and end up with file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a 1&#xA;a 2&#xA;a 3&#xA;b 1&#xA;b 2&#xA;b 3&#xA;c 1&#xA;c 2&#xA;c 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5512" LastActivityDate="2018-03-05T14:04:34.000" Title="Copy lines matching pattern, then substitute" Tags="|search|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15439" PostTypeId="2" ParentId="15438" CreationDate="2018-03-05T14:04:34.000" Score="5" Body="&lt;p&gt;You can do that with a &lt;code&gt;:g&lt;/code&gt; command which marks all lines on which to act and then run a combination of a &lt;code&gt;:t&lt;/code&gt; (copy) and &lt;code&gt;:s&lt;/code&gt; (substitute) command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/2$/t.|s/2/3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This executes on each line matching &lt;code&gt;2$&lt;/code&gt; the following command: &lt;code&gt;:t.|s/2/3&lt;/code&gt;&#xA;which means, copy the current line and afterwards replace the 2 by 3 in the current (copied) line.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-03-05T14:04:34.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15440" PostTypeId="2" ParentId="15437" CreationDate="2018-03-05T14:43:50.153" Score="11" Body="&lt;p&gt;They indicate folds and their nesting levels:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;code&gt;+&lt;/code&gt; plus symbol marks a closed fold, and a &lt;code&gt;-&lt;/code&gt; minus marks the first line of an open fold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;foldcolumn&lt;/code&gt; is high enough (i.e. greater that the number of open nested folds currently being displayed), then each nested open fold will be preceded by a bar character &lt;code&gt;|&lt;/code&gt;, so if you have 3 nested open folds you will see a display something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     not in a fold&#xA;-    start of fold 1&#xA;|    inside fold 1&#xA;|-   start of fold 2&#xA;||   inside fold 2&#xA;||-  start of fold 3&#xA;|||  inside fold 3&#xA;|||+ closed fold 4&#xA;|||  inside fold 3&#xA;|||  end of fold 3&#xA;||   inside fold 2&#xA;||   end of fold 2&#xA;|    inside fold 1&#xA;|    end of fold 1&#xA;     not in a fold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if you decrease the size of &lt;code&gt;foldcolumn&lt;/code&gt; so there is no longer enough room to use this style of display), then nested bar characters will be replaced with digits as necessary:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g., with the example above, if you execute &lt;code&gt;:set foldcolumn=3&lt;/code&gt;, there is not enough room for three nested &lt;code&gt;|&lt;/code&gt; characters &lt;em&gt;and&lt;/em&gt; a &lt;code&gt;+&lt;/code&gt; sign, so numbers are used instead as necessary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     not in a fold&#xA;-    start of fold 1&#xA;|    inside fold 1&#xA;|-   start of fold 2&#xA;||   inside fold 2&#xA;2-  start of fold 3&#xA;23  inside fold 3&#xA;23+ closed fold 4&#xA;23  inside fold 3&#xA;23  end of fold 3&#xA;||   inside fold 2&#xA;||   end of fold 2&#xA;|    inside fold 1&#xA;|    end of fold 1&#xA;     not in a fold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With  &lt;code&gt;foldcolumn=1&lt;/code&gt; the number of &lt;code&gt;|&lt;/code&gt; characters that can be displayed is even more restricted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  not in a fold&#xA;- start of fold 1&#xA;| inside fold 1&#xA;- start of fold 2&#xA;2 inside fold 2&#xA;- start of fold 3&#xA;3 inside fold 3&#xA;+ closed fold 4&#xA;3 inside fold 3&#xA;3 end of fold 3&#xA;2 inside fold 2&#xA;2 end of fold 2&#xA;| inside fold 1&#xA;| end of fold 1&#xA;  not in a fold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-03-05T14:43:50.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15441" PostTypeId="2" ParentId="15435" CreationDate="2018-03-05T15:08:12.520" Score="1" Body="&lt;p&gt;Neovim doesn't use the location &lt;code&gt;~/.vimrc&lt;/code&gt; for its configuration file. Try moving, copying, or symlinking your file to the location:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.config/nvim/init.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-03-05T15:08:12.520" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15442" PostTypeId="2" ParentId="15429" CreationDate="2018-03-05T15:26:51.113" Score="1" Body="&lt;p&gt;Not sure what's going wrong with your map. It works for me (but I don't use Neovim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, rather than relying the side effects of &lt;code&gt;gd&lt;/code&gt; or &lt;code&gt;*&lt;/code&gt; (that they set the search register &lt;code&gt;&quot;/&lt;/code&gt;), you could instead insert the word into the search command more directly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gR :%s/\V\&amp;lt;&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;\&amp;gt;//gc&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. I'm using very-nomagic &lt;code&gt;\V&lt;/code&gt; in the regular expression for consistency with your original command, &lt;code&gt;gd&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This utilises the command-line editing command &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;Ctrl-W&lt;/kbd&gt;, which inserts the word currently under the cursor into the command-line. (See &lt;code&gt;:help c_CTRL-R_CTRL-W&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-03-05T15:26:51.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15443" PostTypeId="2" ParentId="15416" CreationDate="2018-03-05T16:13:21.603" Score="0" Body="&lt;p&gt;My &lt;em&gt;real&lt;/em&gt; answer is &quot;don't do that&quot;, but if you insist, you could do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;expr&amp;gt; h &amp;amp;filetype ==? 'netrw' ? 'h' : ''&#xA;noremap &amp;lt;expr&amp;gt; j &amp;amp;filetype ==? 'netrw' ? 'j' : ''&#xA;noremap &amp;lt;expr&amp;gt; k &amp;amp;filetype ==? 'netrw' ? 'k' : ''&#xA;noremap &amp;lt;expr&amp;gt; l &amp;amp;filetype ==? 'netrw' ? 'l' : ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These commands create mappings that check the filetype, and then either perform an hjkl movement or do nothing, accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :map-expression&lt;/code&gt; for details on how this works.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-05T16:27:28.150" LastActivityDate="2018-03-05T16:27:28.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15444" PostTypeId="1" AcceptedAnswerId="15446" CreationDate="2018-03-05T21:00:06.443" Score="1" ViewCount="455" Body="&lt;p&gt;When I press return at the end of a comment line, vim will automatically insert the comment leader on the next line as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// My comment bla bla&#xA;// ‸&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I like this feature and I would like to leave it switched on. However, quite often, I also want to write uncommented code on the next line. Is there an easy way to configure vim in such a way that pressing backspace once in this position will remove the whole comment leader? I find it at little bit annoying to always have to press backspace three times.&lt;/p&gt;&#xA;" OwnerUserId="16601" LastActivityDate="2019-11-20T22:03:15.367" Title="Remove automatic comment leader" Tags="|comments|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15445" PostTypeId="1" CreationDate="2018-03-05T21:06:51.040" Score="0" ViewCount="312" Body="&lt;p&gt;At the bottom of my file, I'd to have something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// vim: syntax=cpp.doxygen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Only, when I do that, it breaks my auto-load of my own cpp.vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufReadPost *.cpp          so $HOME/vim/presentrack.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I write code where my with C++ classes have variable members that start with &lt;code&gt;f_&lt;/code&gt; and with my syntax I see those in a specific color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I define some global variables (rarely, though) which start with &lt;code&gt;g_&lt;/code&gt;. Again I give them a special color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also like the special doxygen highlighting because it shows me whether I mistype something without having to run doxygen (it helps fixing some mistakes quickly.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get the best of both worlds?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, my &lt;code&gt;presentrack.vim&lt;/code&gt; has an include:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/syntax/cpp.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I would imagine I would have to instead include doxygen and not have doxygen at the bottom of my .cpp file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like is a way that both syntaxes would co-exist, although I would imagine that is not supported, I thought I'd ask.&lt;/p&gt;&#xA;" OwnerUserId="9276" LastActivityDate="2018-03-06T03:25:00.597" Title="Is there a way to use cpp.doxygen syntax file and my own cpp.vim syntax file?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15446" PostTypeId="2" ParentId="15444" CreationDate="2018-03-05T21:12:45.697" Score="0" Body="&lt;p&gt;You can accomplish this with a simple mapping;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;bs&amp;gt; getline('.') =~# '^//\s*$' ? &quot;&amp;lt;c-u&amp;gt;&quot; : &quot;&amp;lt;bs&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that if your &lt;code&gt;backspace&lt;/code&gt; setting includes &lt;code&gt;start&lt;/code&gt;, this will delete the comment regardless of whether it was automatically entered or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, here is a slightly different workflow.  I use the following snippet; pressing &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; will insert the comment leader, pressing &lt;code&gt;shift&lt;/code&gt;+&lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; will not.  Note that not all terminals support this key combination.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;set &amp;lt;f26&amp;gt;=\&amp;lt;esc&amp;gt;OM&quot;&#xA;&#xA;inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;f26&amp;gt;&#xA;    \ synIDattr(synID(line('.'), col('.')-1, 1), 'name') =~? 'comment'&#xA;    \ ? &quot;&amp;lt;cr&amp;gt;&amp;lt;c-u&amp;gt;&quot;&#xA;    \ : &quot;&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-03-05T21:12:45.697" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15447" PostTypeId="1" AcceptedAnswerId="15453" CreationDate="2018-03-05T22:22:17.853" Score="4" ViewCount="642" Body="&lt;p&gt;I am relatively new to vim and have started using the &lt;a href=&quot;https://github.com/jpalardy/vim-slime&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-slime&lt;/a&gt; plugin. One thing I use it for is to run python scripts, for example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SlimeSend1 python ~/myPythonFile.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I now would like to automate the command above. More specifically, I would like to map the command above to a keystroke, but for whatever python file I happen to be working with. Using F5 as my example keystroke, I am looking for something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;F5&amp;gt; SlimeSend1 python expand('%:p')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command above doesn't work because it sends the literal string &quot;python expand('%:p')&quot;. As a note, I have gone through vim-slime's documentation, but still can't figure this out.&lt;/p&gt;&#xA;" OwnerUserId="16602" LastEditorUserId="16602" LastEditDate="2018-03-06T07:24:32.590" LastActivityDate="2018-03-06T09:37:31.147" Title="sending variable commands in vim-slime" Tags="|command-line|external-command|tmux|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15448" PostTypeId="2" ParentId="15447" CreationDate="2018-03-05T23:34:05.587" Score="1" Body="&lt;p&gt;As you found out, &lt;code&gt;:SlimeSend1&lt;/code&gt; sends its arguments literally, as a single string.  You could type &lt;code&gt;CTRL+R&lt;/code&gt; to insert the &lt;code&gt;%&lt;/code&gt; register, which is the current filename:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SlimeSend1 python &amp;lt;c-r&amp;gt;%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could use &lt;code&gt;SlimeSend0&lt;/code&gt; instead which accepts an expression.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SlimeSend0 'python '.expand('%:p')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command is a bit unwieldy.  You can use a wrapper command;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:flags = '&amp;lt;\=\%(:[p8~.htre]\|:g\=s\(.\).\{-\}\1.\{-\}\1\)*'&#xA;let s:expandable = '\\*\%(&amp;lt;\w\+&amp;gt;\|%\|#\d*\)' . s:flags&#xA;function! s:expand(string) abort&#xA;  let slashes = len(matchstr(a:string, '^\%(\\\\\)*'))&#xA;  sandbox let v = repeat('\', slashes/2) . expand(a:string[slashes : -1])&#xA;  return v&#xA;endfunction&#xA;function! TExpand(string) abort&#xA;  return substitute(a:string, s:expandable,&#xA;          \ '\=s:expand(submatch(0))', 'g')&#xA;endfunction&#xA;&#xA;command! -complete=shellcmd -bang -nargs=+ Send&#xA;      \ SlimeSend0 TExpand(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I stole the &lt;code&gt;TExpand&lt;/code&gt; function from &lt;a href=&quot;https://github.com/tpope/vim-dispatch/blob/e83ac42fefa4bcf2b4197bec2b4d917e15225815/autoload/dispatch.vim#L42&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dispatch&lt;/a&gt;.  If you have Dispatch installed you can simply use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -complete=shellcmd -bang -nargs=+ Send&#xA;      \ SlimeSend0 dispatch#expand(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;:Send python %&lt;/code&gt; will work as you expect.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-03-05T23:43:22.293" LastActivityDate="2018-03-05T23:43:22.293" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15449" PostTypeId="2" ParentId="15445" CreationDate="2018-03-06T03:25:00.597" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;when I do that, it breaks my auto-load of my own cpp.vim.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufReadPost *.cpp          so $HOME/vim/presentrack.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The canonical way to extend the syntax highlighting for the &lt;code&gt;cpp&lt;/code&gt; filetype would be to put your custom rules in &lt;code&gt;~/.vim/after/syntax/cpp.vim&lt;/code&gt;.  That will automatically be loaded for you.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-03-06T03:25:00.597" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15450" PostTypeId="1" AcceptedAnswerId="15451" CreationDate="2018-03-06T04:21:38.043" Score="2" ViewCount="512" Body="&lt;p&gt;I want to map &lt;code&gt;&amp;lt;leader&amp;gt;h&lt;/code&gt; to &lt;code&gt;:bprev&amp;lt;CR&amp;gt;&lt;/code&gt;, with my leader key as &lt;code&gt;\&amp;lt;space&amp;gt;&lt;/code&gt;, so I wrote the following in my init.vim (I also have &lt;code&gt;nnoremap &amp;lt;space&amp;gt; &amp;lt;Nop&amp;gt;&lt;/code&gt; in my init.vim to override the default normal mode behaviour of &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;space&amp;gt; &amp;lt;nop&amp;gt;&#xA;let mapleader = &quot;\&amp;lt;space&amp;gt;&quot;&#xA;nnoremap &amp;lt;leader&amp;gt;h :bprev&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I have &lt;a href=&quot;https://github.com/airblade/vim-gitgutter&quot; rel=&quot;nofollow noreferrer&quot;&gt;airblade/vim-gitgutter&lt;/a&gt; installed which adds a delay to my mapping because of plugin mappings &lt;code&gt;&amp;lt;space&amp;gt;hp&lt;/code&gt;, &lt;code&gt;&amp;lt;space&amp;gt;hu&lt;/code&gt;, &lt;code&gt;&amp;lt;space&amp;gt;hs&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose noremap &amp;lt;leader&amp;gt;h&#xA;n  &amp;lt;Space&amp;gt;hp     &amp;lt;Plug&amp;gt;GitGutterPreviewHunk&#xA;    Last set from ~/.config/nvim/bundle/vim-gitgutter/plugin/gitgutter.vim&#xA;n  &amp;lt;Space&amp;gt;hu     &amp;lt;Plug&amp;gt;GitGutterUndoHunk&#xA;    Last set from ~/.config/nvim/bundle/vim-gitgutter/plugin/gitgutter.vim&#xA;n  &amp;lt;Space&amp;gt;hs     &amp;lt;Plug&amp;gt;GitGutterStageHunk&#xA;    Last set from ~/.config/nvim/bundle/vim-gitgutter/plugin/gitgutter.vim&#xA;n  &amp;lt;Space&amp;gt;h    * :bprev&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.config/nvim/init.vim&#xA;n  &amp;lt;Space&amp;gt;     * &amp;lt;Nop&amp;gt;&#xA;    Last set from ~/.config/nvim/init.vim&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/4637412/unmapping-vim-plugin-mappings&quot;&gt;This question&lt;/a&gt; indicates that I can remap plugin bindings by writing my custom bindings in a .vim file in &lt;code&gt;.config/nvim/after/plugin&lt;/code&gt;, so I tried moving the definition of my mapping there instead along with &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt; bindings for &lt;code&gt;&amp;lt;space&amp;gt;hp&lt;/code&gt;, &lt;code&gt;&amp;lt;space&amp;gt;hu&lt;/code&gt;, &lt;code&gt;&amp;lt;space&amp;gt;hs&lt;/code&gt;, but that doesn't work because my &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt; mappings still delay the execution of my &lt;code&gt;&amp;lt;space&amp;gt;h&lt;/code&gt; mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose noremap &amp;lt;leader&amp;gt;h&#xA;n  &amp;lt;Space&amp;gt;h    * :bprev&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.config/nvim/after/plugin/keys.vim&#xA;n  &amp;lt;Space&amp;gt;hp     &amp;lt;Nop&amp;gt;&#xA;    Last set from ~/.config/nvim/after/plugin/keys.vim&#xA;n  &amp;lt;Space&amp;gt;hu     &amp;lt;Nop&amp;gt;&#xA;    Last set from ~/.config/nvim/after/plugin/keys.vim&#xA;n  &amp;lt;Space&amp;gt;hs     &amp;lt;Nop&amp;gt;&#xA;    Last set from ~/.config/nvim/after/plugin/keys.vim&#xA;n  &amp;lt;Space&amp;gt;     * &amp;lt;Nop&amp;gt;&#xA;    Last set from ~/.config/nvim/init.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I override these mappings so that they don't interfere? Also, I have yet to find a decent &quot;best practice&quot; to avoid these types of conflicts - does one exist?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I have tried putting &lt;code&gt;exe :mapclear&lt;/code&gt; at the top of my new &lt;code&gt;.config/nvim/after/plugin/keys.vim&lt;/code&gt;, but that clears all keybindings from all my plugins and my init.vim which is ... less than satisfactory - however, I don't think it's a terrible idea to move all my keybindings here and not rely on plugin defaults.&lt;/p&gt;&#xA;" OwnerUserId="16605" LastEditorUserId="16605" LastEditDate="2018-03-06T04:31:01.660" LastActivityDate="2018-03-06T04:31:38.163" Title="vim mapping delayed because of plugin" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15451" PostTypeId="2" ParentId="15450" CreationDate="2018-03-06T04:31:38.163" Score="4" Body="&lt;p&gt;vim-gitgutter follows best practices with respect to mappings.  Specifically, before it makes its maps it checks three conditions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The global variable &lt;code&gt;g:gitgutter_map_keys&lt;/code&gt; is true.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;One option is to &lt;code&gt;let g:gitgutter_map_keys = 0&lt;/code&gt;, but then &lt;em&gt;no&lt;/em&gt; mappings will be made and you would have to make the ones you use manually.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;There is not already a &lt;code&gt;&amp;lt;leader&amp;gt;hs&lt;/code&gt; map&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can make your own &lt;code&gt;&amp;lt;leader&amp;gt;hs&lt;/code&gt; map, but this won't help you because it would still cause a delay.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;There is not already a mapping to &lt;code&gt;&amp;lt;Plug&amp;gt;GitGutterStageHunk&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In my opinion the easiest method is to use your own preferred mapping,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;gsh &amp;lt;Plug&amp;gt;GitGutterStageHunk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows you to still use the functionality.  Or, you can use a junk mapping;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;plug&amp;gt;(disable-ggsh) &amp;lt;Plug&amp;gt;GitGutterStageHunk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do this for all the right-hand-side maps you don't want vim-gitgutter to map to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A different method, used when plugin do not follow mapping best practices, is to manually unmap what you don't like.  It is easiest to do this in &lt;code&gt;after/plugin/keys.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nunmap &amp;lt;leader&amp;gt;hs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or within the &lt;code&gt;VimEnter&lt;/code&gt; event:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * nunmap &amp;lt;leader&amp;gt;hs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-03-06T04:31:38.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15452" PostTypeId="2" ParentId="3093" CreationDate="2018-03-06T09:07:14.843" Score="10" Body="&lt;p&gt;Apparently, the way to write the font settings are quite platform-dependent. What worked for me (gVim in MX Linux 17, an XFCE Debian-based Linux distribution):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Determine the current font settings in an open gvim instance&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;: set guifont?&#xA;‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾&#xA; guifont=DejaVu Sans Mono 12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use this information to write the settings (modifying the size as desired) in the gVim configuration file, &lt;strong&gt;escaping the spaces with backslashes&lt;/strong&gt;, and &lt;strong&gt;not using &lt;code&gt;:&lt;/code&gt; before the size&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;~/.gvimrc&#xA;‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾&#xA;set guifont=DejaVu\ Sans\ Mono\ 18`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;After saving, new instances of gvim should use the new desired size.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h5&gt;References&lt;/h5&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://askubuntu.com/a/3532/129295&quot;&gt;How to save font choice in gVim? - Ask Ubuntu&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/21894257/1878788&quot;&gt;vim - List of fonts available in gvim - Stack Overflow&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/3094/13481&quot;&gt;How can I change the font size in gVim? - Vi and Vim Stack Exchange&lt;/a&gt; (comments)&lt;/p&gt;&#xA;" OwnerUserId="13481" LastEditorUserId="33871" LastEditDate="2021-11-16T12:15:46.607" LastActivityDate="2021-11-16T12:15:46.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15453" PostTypeId="2" ParentId="15447" CreationDate="2018-03-06T09:37:31.147" Score="2" Body="&lt;p&gt;As a general rule of thumb, you can always get around this kind of problem by using &lt;code&gt;:execute&lt;/code&gt; and building the command you want to run as a string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;F5&amp;gt; :execute 'SlimeSend1 python' expand('%:p')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :execute&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-03-06T09:37:31.147" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15456" PostTypeId="1" AcceptedAnswerId="15460" CreationDate="2018-03-06T17:29:05.643" Score="1" ViewCount="6878" Body="&lt;p&gt;Line pattern:&lt;br&gt;&#xA;&lt;code&gt;abc : some-thing&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;abc : some-thing;&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;abc : some-thing --commment-:&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;abc : some-thing; --commment-:&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Requirements:&lt;br&gt;&#xA;1. Want to substitute the string between &lt;code&gt;:&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt;.&lt;br&gt;&#xA;2. Comment is start with &lt;code&gt;--&lt;/code&gt;. Comment can contain any character, including &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;.&lt;br&gt;&#xA;3. &lt;code&gt;something&lt;/code&gt; can contain single &lt;code&gt;-&lt;/code&gt;, but no &lt;code&gt;:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Expected result:&lt;br&gt;&#xA;&lt;code&gt;abc :&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;abc :;&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;abc : --comment-:&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;abc :; --comment-:&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:s/:.*[^;]/:/&lt;/code&gt; works fine if there is no comment at the end.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;=======================================================  &#xA;Some &quot;complicated&quot; code:&#xA;&#xA;     let current_line=getline('.')  &#xA;     if current_line =~ &quot;:&quot;  &#xA;     &quot; check if containts ;  &#xA;     if current_line =~ &quot;;&quot;  &#xA;        let contain_sc = 1  &#xA;     else  &#xA;        let contain_sc = 0  &#xA;     endif  &#xA;     &quot; check if containts --  &#xA;     if current_line =~ &quot;--&quot;  &#xA;        let contain_comment = 1  &#xA;     else  &#xA;        let contain_comment = 0  &#xA;     endif  &#xA;     &quot; echo contain_sc.&quot;,&quot;.contain_comment  &#xA;     if (contain_sc == 1) || ((contain_sc == 0) &amp;amp;&amp;amp; (contain_comment == 0))  &#xA;        :s/:\zs[^;]*//  &#xA;     else  &#xA;        :s/:\zs.*--\ze/--/  &#xA;     endif  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="13402" LastEditDate="2018-03-09T10:51:40.307" LastActivityDate="2018-03-09T13:21:31.513" Title="How to substitute string between two special characters?" Tags="|substitute|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15457" PostTypeId="1" CreationDate="2018-03-06T21:39:14.730" Score="6" ViewCount="3932" Body="&lt;pre&gt;&lt;code&gt;                                                'wildignore' 'wig'&#xA;'wildignore' 'wig'      string  (default &quot;&quot;)&#xA;                        global&#xA;                        {not available when compiled without the +wildignore&#xA;                        feature}&#xA;        A list of file patterns.  A file that matches with one of these&#xA;        patterns is ignored when expanding wildcards, completing file or&#xA;        directory names, and influences the result of expand(), glob() and&#xA;        globpath() unless a flag is passed to disable this.&#xA;        The pattern is used like with :autocmd, see autocmd-patterns.&#xA;        Also see 'suffixes'.&#xA;        Example:&#xA;                :set wildignore=*.o,*.obj&#xA;        The use of :set+= and :set-= is preferred when adding or removing&#xA;        a pattern from the list.  This avoids problems when a future version&#xA;        uses another default.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that this documentation would indicate that &lt;code&gt;wildignore&lt;/code&gt; will cause functions like glob/expand/globpath to ignore the patterns in this variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently this is my setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wildignore=*.o,*.a,*.so,*.pyc,*.swp,.git/,*.class,*/target/*,.idea/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I use glob:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo glob(&quot;.gi*&quot;)&#xA;.git&#xA;.gitignore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not what I'd expect from the documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit .gi&amp;lt;TAB&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will instantly complete to &lt;code&gt;.gitignore&lt;/code&gt; and subsequent double taps of  will not cycle to &lt;code&gt;.git&lt;/code&gt;.  So it seems that &lt;code&gt;:edit&lt;/code&gt; uses wildignore as I'd expect.&lt;/p&gt;&#xA;" OwnerUserId="8786" LastEditorUserId="21" LastEditDate="2018-03-07T07:29:17.647" LastActivityDate="2019-03-05T01:28:16.563" Title="What does `wildignore` actually do and what functions/tools respect it?" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15459" PostTypeId="1" AcceptedAnswerId="15461" CreationDate="2018-03-06T23:15:00.877" Score="0" ViewCount="327" Body="&lt;p&gt;I'd like to define a mapping that performs a &quot;recursively&quot; defined behavior (e.g. uses a &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; target) followed by a non-recursively defined behavior. For example, using the &lt;a href=&quot;https://github.com/bkad/CamelCaseMotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;camelcase motion&lt;/a&gt; plugin, I want to move forward a camelcase word and then enter insert mode. Neither of these work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap -w &amp;lt;Plug&amp;gt;CamelCaseMotion_wi&#xA;nnoremap -w &amp;lt;Plug&amp;gt;CamelCaseMotion_wi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because the &lt;code&gt;i&lt;/code&gt; needs to be done non-recursively and &lt;code&gt;&amp;lt;Plug&amp;gt;CamelCaseMotion_w&lt;/code&gt; needs to be done recursively. What's the best way to achieve my goal?&lt;/p&gt;&#xA;" OwnerUserId="13151" LastActivityDate="2018-03-06T23:45:12.750" Title="Mapping that mixes recursive and non-recursive behavior" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15460" PostTypeId="2" ParentId="15456" CreationDate="2018-03-06T23:39:08.167" Score="5" Body="&lt;p&gt;&lt;strong&gt;New answer to cover the new requirements:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a solution that should cover the new examples.  This one even retains that pesky space before the comment in the third example that I struggled with in the original update.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/^.\{-}:\zs.\{-}\ze\%($\|;\|\s*--\)//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s/&lt;/code&gt; - Start the substitution command for the entire file.  If you want to operate only on the current line get rid of the &lt;code&gt;%&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^.\{-}:&lt;/code&gt; - Starting from the beginning of the line, find as few characters as possible until the first &lt;code&gt;:&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs.\{-}\ze&lt;/code&gt; - Find as few characters as possible.  The &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; sets the start and end of the part that will be replaced (the &lt;code&gt;some-thing&lt;/code&gt; parts).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%(&lt;/code&gt; - Group the following characters until the &lt;code&gt;\)&lt;/code&gt;.  Inside here we will specify all of the patterns, separated by &lt;code&gt;\|&lt;/code&gt;, that we don't want to replace at the end of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt; - Match the end of the line.  This covers the first example.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\|&lt;/code&gt; - Basically a logical &quot;OR&quot;.  If we didn't match the previous pattern (the end of the line character) try matching the next pattern.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;&lt;/code&gt; - Match a literal &lt;code&gt;;&lt;/code&gt;.  This covers the second and fourth examples.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\|&lt;/code&gt; - Another logical &quot;OR&quot;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s*--&lt;/code&gt; - Match as many spaces as possible followed by &lt;code&gt;--&lt;/code&gt;.  This covers the third example.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\)&lt;/code&gt; - End the group started by &lt;code&gt;\%(&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;//&lt;/code&gt; - Defines the replacement pattern, which is nothing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original answer:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Providing your desired result for each example would be helpful to make sure the answers achieve what you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I'm understanding correctly, you want to replace all the text that comes after the first &lt;code&gt;:&lt;/code&gt; on the line and before a &lt;code&gt;;&lt;/code&gt;.  If there is no &lt;code&gt;;&lt;/code&gt;, then replace the entire line after the &lt;code&gt;:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all that is correct, I would use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/:\zs[^;]*//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key part of this is the &lt;code&gt;\zs&lt;/code&gt; in the search pattern.  This sets the start of the text that will be replaced.  So, basically we look for a &lt;code&gt;:&lt;/code&gt;, then set the position where we will start replacing.  Then, look for as many non-&lt;code&gt;;&lt;/code&gt; characters until the end of the line.  Then replace everything from that start position to where ever we ended up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to perform the substitution on all of the lines at once, add a &lt;code&gt;%&lt;/code&gt; to the beginning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/:\zs[^;]*//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;\ze&lt;/code&gt; to mark the end of the replacement part.  For example, if you only wanted to do the replacement only on lines with the &lt;code&gt;;&lt;/code&gt;, you could do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/:\zs[^;]*\ze;//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help \zs&lt;/code&gt; and &lt;code&gt;:help \ze&lt;/code&gt; explains this further.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If any of my assumptions were incorrect, please clarify the question and I can update my answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;(Original) Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is as close as I'm able to get with a single expression.  I can't seem to figure out a way to retain the space before the &lt;code&gt;--&lt;/code&gt; in your third example.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/:\zs[^;-]*//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only difference from what I previously wrote is that we now also include &lt;code&gt;-&lt;/code&gt; as a character that we want to exclude from the match.  This, of course, assumes that a &lt;code&gt;-&lt;/code&gt; won't exist in the &lt;code&gt;something&lt;/code&gt; part that you're trying to replace.&lt;/p&gt;&#xA;" OwnerUserId="1115" LastEditorUserId="1115" LastEditDate="2018-03-09T13:21:31.513" LastActivityDate="2018-03-09T13:21:31.513" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="15461" PostTypeId="2" ParentId="15459" CreationDate="2018-03-06T23:45:12.750" Score="4" Body="&lt;p&gt;You can do this by introducing your own &lt;code&gt;nore&lt;/code&gt; map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;plug&amp;gt;(my-i) i&#xA;nmap -w &amp;lt;Plug&amp;gt;CamelCaseMotion_w&amp;lt;plug&amp;gt;(my-i)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-03-06T23:45:12.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15462" PostTypeId="1" CreationDate="2018-03-07T00:55:59.490" Score="1" ViewCount="240" Body="&lt;p&gt;I have these commands in my &lt;code&gt;~/.vim/ftplugin/markdown.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal spell spelllang=en&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open a Markdown file, however, &lt;code&gt;'nospell'&lt;/code&gt; is in effect; output of &lt;code&gt;:verbose set spell?&lt;/code&gt; shows the &quot;last set&quot; location was my ftplugin, but the values are wrong:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nospell&#xA;        Last set from ~/.vim/ftplugin/markdown.vim&#xA;spelllang=&#xA;        Last set from ~/.vim/ftplugin/markdown.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Same thing happens if I put the setting in &lt;code&gt;~/.vim/after/ftplugin/markdown.vim&lt;/code&gt;, or in an autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown setlocal spell spelllang=en&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also happens with &lt;code&gt;:set&lt;/code&gt; instead of &lt;code&gt;:setlocal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I logged messages with &lt;code&gt;:echomsg&lt;/code&gt; to prove that the ftplugin was being sourced (it is), and I used &lt;code&gt;:redir&lt;/code&gt; inside the ftplugin to show that the settings were correct at the end of the file (also at the end of the &quot;after/ftplugin&quot; file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;redir &amp;gt;&amp;gt; /tmp/log&#xA;verbose set spell? spelllang?&#xA;redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to see what could be overriding it by doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set verbosefile=/tmp/log&#xA;:set verbose=20&#xA;:e /tmp/some.md&#xA;:q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I can't see anywhere that could be overriding it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I tried grepping inside &lt;code&gt;$VIMRUNTIME&lt;/code&gt; and &lt;code&gt;~/.vim&lt;/code&gt; to see if I could find any files that might be setting &lt;code&gt;'spl'&lt;/code&gt; or &lt;code&gt;'spelllang'&lt;/code&gt;, but there doesn't seem to be anything that could be getting loaded upon accessing a Markdown file that could do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same settings (&lt;code&gt;setlocal&lt;/code&gt; in an ftplugin file) work just fine for other filetypes, such as &quot;mail&quot;, and in fact this setting used to work just fine for Markdown files too, but at some point it stopped working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Happens in Vim and Neovim (tested on v8.0 with patches 1-1350, and v0.2.2 respectively).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how I can get to the bottom of this?&lt;/p&gt;&#xA;" OwnerUserId="10084" LastActivityDate="2018-03-07T01:31:16.940" Title="What's setting an ftplugin 'spell' back to 'nospell'?" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15463" PostTypeId="2" ParentId="15462" CreationDate="2018-03-07T01:31:16.940" Score="1" Body="&lt;p&gt;I eventually found the answer: an autocmd that ended up calling &lt;code&gt;ownsyntax on&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the help (&lt;code&gt;:h w:current_syntax&lt;/code&gt;) reveals:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Note: This resets the 'spell', 'spellcapcheck' and 'spellfile' options.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10084" LastActivityDate="2018-03-07T01:31:16.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15464" PostTypeId="2" ParentId="15457" CreationDate="2018-03-07T02:29:04.207" Score="5" Body="&lt;p&gt;One of the items in your &lt;code&gt;'wildignore'&lt;/code&gt; list is &lt;code&gt;.git/&lt;/code&gt;. I think you'll get the behavior you're looking for if you change it to &lt;code&gt;.git,.git/*&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But to understand what's going on here, I think you have highlighted a behavioral difference between the way completion and functions like &lt;code&gt;glob()&lt;/code&gt; work. My guess is that the functions don't identify a directory called &lt;code&gt;.git&lt;/code&gt; as a match for the pattern &lt;code&gt;.git/&lt;/code&gt; because the trailing slash isn't actually part of the name. However, for tab completion, the trailing slash is often inserted for directories as a convenience. Maybe for completion, the trailing slash is added to the input before it gets filtered by the pattern.&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2018-03-07T02:29:04.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15465" PostTypeId="2" ParentId="10849" CreationDate="2018-03-07T03:04:53.933" Score="1" Body="&lt;p&gt;Though it's not elegant, you could define mappings for combinations of the &lt;code&gt;f&lt;/code&gt; family and numbers/symbols. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap f1 f!&#xA;nnoremap f! f1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To extend the function you used in your &lt;code&gt;.vimrc&lt;/code&gt;, you could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Swap_keys(a, b, do)&#xA;  if a:do&#xA;    for prefix in ['', 'f', 't', 'F', 'T']&#xA;      exe 'noremap' prefix.a:a prefix.a:b&#xA;      exe 'noremap' prefix.a:b prefix.a:a&#xA;    endfor&#xA;    exe 'inoremap' a:a a:b&#xA;    exe 'inoremap' a:b a:a&#xA;    exe 'cnoremap' a:a a:b&#xA;    exe 'cnoremap' a:b a:a&#xA;  else&#xA;    for prefix in ['', 'f', 't', 'F', 'T']&#xA;      exe 'noremap' prefix.a:a prefix.a:a&#xA;      exe 'noremap' prefix.a:b prefix.a:b&#xA;    endfor&#xA;    exe 'inoremap' a:a a:a&#xA;    exe 'inoremap' a:b a:b&#xA;    exe 'cnoremap' a:a a:a&#xA;    exe 'cnoremap' a:b a:b&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="64" LastActivityDate="2018-03-07T03:04:53.933" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15466" PostTypeId="2" ParentId="15370" CreationDate="2018-03-07T03:58:40.530" Score="3" Body="&lt;h3&gt;Suppressing the built-in &lt;code&gt;g&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Here's a mapping that will suppress all &lt;code&gt;g&lt;/code&gt;-prefixed bindings, and only allow custom mappings that begin with &lt;code&gt;g&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SuppressG()&#xA;  let c = nr2char(getchar())&#xA;  if maparg('g'.c, 'n') != ''&#xA;    return 'g'.c&#xA;  else&#xA;    return '\&amp;lt;Nop&amp;gt;'&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt; g SuppressG()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to make a top-level mapping for &lt;code&gt;g&lt;/code&gt; itself that then reads a single character from the keyboard. If a Normal mode mapping to &lt;code&gt;g&lt;/code&gt; followed by the input character exists, return that. Otherwise, return &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt;. It works with chords, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The effect is that when you haven't defined any other mappings beginning with &lt;code&gt;g&lt;/code&gt;, all of Vim's built-in bindings beginning with &lt;code&gt;g&lt;/code&gt; will do nothing. For example, &lt;code&gt;ge&lt;/code&gt;, which normally moves backwards to the end of a word, would now be a no-op.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Creating a custom mapping&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you also defined a custom mapping to &lt;code&gt;ge&lt;/code&gt;, then your mapping would take effect. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ge G&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;ge&lt;/code&gt; moves to the last line of the buffer, but all other &lt;code&gt;g&lt;/code&gt; bindings still do nothing.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Restoring built-ins&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can also restore the &lt;code&gt;g&lt;/code&gt; mappings you want to keep. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gg gg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes &lt;code&gt;gg&lt;/code&gt; once again move to the first line of the buffer.&lt;/p&gt;&#xA;" OwnerUserId="64" LastEditorUserId="64" LastEditDate="2018-03-08T14:45:19.403" LastActivityDate="2018-03-08T14:45:19.403" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15467" PostTypeId="1" AcceptedAnswerId="15469" CreationDate="2018-03-07T04:34:19.053" Score="1" ViewCount="116" Body="&lt;p&gt;I am sorry for the rather fuzzy title of my question. I am working on some text, which I take from web-page and try to annotate it with LaTeX commands using Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I write in Vim following pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dot line-break 2spaces capital letter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to search through the text to replace it.&#xA;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="16620" LastEditorUserId="1841" LastEditDate="2018-03-07T08:00:59.147" LastActivityDate="2018-03-09T00:07:32.640" Title="how to write following pattern in vim?" Tags="|search|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15468" PostTypeId="1" AcceptedAnswerId="15472" CreationDate="2018-03-07T08:03:51.977" Score="1" ViewCount="851" Body="&lt;p&gt;I have used the following command in Git Bash to perform a 'vimdiff' for 2 XML files.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff  xml1.xml xml2.xml -c TOhtml -c 'w! result.html' -c 'qa!'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The HTML file which is getting generated is too flashy. The differences are highlighted in Magenta and the background is Black in color. Also the font colors are Cyan and Green. Is there a way to modify the color settings, so that the result file doesn't contain too many bright colors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below are the things which I have tried out, but it doesn't give the required result.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Tried changing the 'Foreground' and 'Background' color in the Bash terminal and then performed the vimdiff operation. But the HTML file still contains bright colors.&lt;/li&gt;&#xA;&lt;li&gt;In Vim I checked for &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3acolorscheme&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :colorscheme&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3aTOhtml&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :TOhtml&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3ahighlight&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :highlight&lt;/code&gt;&lt;/a&gt; but not sure what exactly should be changed.&lt;/li&gt;&#xA;&lt;li&gt;I found that most of the sites mention about changing the .vimrc file. I was able to locate the &lt;code&gt;.vimrc&lt;/code&gt; file but not sure what changes should be made to the file.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is there any resolution for the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTML output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vhgmo.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vhgmo.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16621" LastEditorUserId="1841" LastEditDate="2018-10-09T14:30:46.687" LastActivityDate="2018-10-09T14:30:46.687" Title="How to customize the color of an HTML output file generated from Git Bash?" Tags="|vimrc|microsoft-windows|vimdiff|bash|git|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="15469" PostTypeId="2" ParentId="15467" CreationDate="2018-03-07T08:04:26.923" Score="2" Body="&lt;p&gt;To match a dot followed by a new line beginning with two spaces and one capital letter you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\.\n\s\{2}[A-Z]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\.        Matches a literal .&#xA;\n        is a new line&#xA;\s        is a whitespace&#xA;\{2}      is exactly 2 occurences of the previous atom (i.e. \s)&#xA;[A-Z]     is a capital letter between A and Z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="64" LastEditDate="2018-03-09T00:07:32.640" LastActivityDate="2018-03-09T00:07:32.640" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15470" PostTypeId="2" ParentId="15370" CreationDate="2018-03-07T10:40:51.403" Score="2" Body="&lt;p&gt;If your version of vim is recent enough, you could obtain all the mappings starting with &lt;code&gt;g&lt;/code&gt; thanks to &lt;code&gt;getcompletion('g', 'mapping')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you won't know the mode associated, you'd need to filter the list with &lt;code&gt;mapcheck()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you won't obtain the default keybindings this way.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-03-07T10:40:51.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15471" PostTypeId="1" AcceptedAnswerId="29409" CreationDate="2018-03-07T14:40:23.870" Score="11" ViewCount="2557" Body="&lt;p&gt;I jot notes in a tiny split window (buffer) regularly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-W&amp;gt;s&#xA;:enew&#xA;:res 5&#xA;... jot jot...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I create a new horizontal split in the same tab, that little window resizes, as if doing &lt;code&gt;&amp;lt;C-W&amp;gt;=&lt;/code&gt;, which brings me to the question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Can I keep a split from resizing?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="2777" LastEditorUserId="1841" LastEditDate="2018-03-07T14:45:55.613" LastActivityDate="2021-02-27T12:52:50.100" Title="How to lock a window height / width?" Tags="|vim-windows|split|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15472" PostTypeId="2" ParentId="15468" CreationDate="2018-03-07T14:49:45.703" Score="1" Body="&lt;p&gt;As the &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#2html.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;2HTML section of help&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;After you save the resulting file, you can view it with any browser.&#xA;  The colors should be exactly the same as you see them in Vim. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So change the color scheme to something you like by calling &lt;code&gt;:colo&lt;/code&gt; in your command before &lt;code&gt;TOhtml&lt;/code&gt;. Using scheme &lt;em&gt;molokai&lt;/em&gt;, for example, you have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff  xml1.xml xml2.xml -c 'colo molokai' -c TOhtml -c 'w! result.html' -c 'qa!'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've verified that this works.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-03-07T15:01:47.123" LastActivityDate="2018-03-07T15:01:47.123" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15473" PostTypeId="2" ParentId="15471" CreationDate="2018-03-07T14:50:33.077" Score="8" Body="&lt;p&gt;If you read the doc for the command you use you will see &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#CTRL-W_S&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h CTRL-W_S&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Reduces the current window height to create room (and others, if the 'equalalways' option is set, 'eadirection' isn't &quot;hor&quot;, and one of them is higher than the current or the new window).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you can read &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27equalalways%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'equalalways'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When on, all the windows are automatically made the same size after splitting or closing a window.  This also happens the moment the option is switched on.  When off, splitting a window will reduce the size of the current window and leave the other windows the same.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So adding this to your vimrc should resolve your issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noequalalways&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="22518" LastEditDate="2019-06-03T15:56:30.790" LastActivityDate="2019-06-03T15:56:30.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15475" PostTypeId="1" AcceptedAnswerId="15476" CreationDate="2018-03-07T17:06:06.420" Score="0" ViewCount="417" Body="&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/3926718/766570&quot;&gt;This&lt;/a&gt; pattern is very useful to me to get the count of a pattern in a vim file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/pattern//gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do a keymap so that I can simply invoke it + &lt;code&gt;pattern&lt;/code&gt; while I'm in vim?&lt;/p&gt;&#xA;" OwnerUserId="14510" LastActivityDate="2018-03-07T21:53:58.317" Title="how to create a keymap for vim that has a regex argument" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15476" PostTypeId="2" ParentId="15475" CreationDate="2018-03-07T17:16:26.093" Score="4" Body="&lt;p&gt;You can use a mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap  S  :%s///gn&amp;lt;LEFT&amp;gt;&amp;lt;LEFT&amp;gt;&amp;lt;LEFT&amp;gt;&amp;lt;LEFT&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;LEFT&amp;gt;&lt;/code&gt; is the left arrow key which allows you to move your cursor in command line mode. This way you can press &lt;code&gt;S&lt;/code&gt; + &lt;code&gt;pattern&lt;/code&gt; and you are good to go.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-03-07T17:16:26.093" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15477" PostTypeId="2" ParentId="15475" CreationDate="2018-03-07T18:15:07.500" Score="3" Body="&lt;p&gt;You should also be able to ask the user to type the pattern with &lt;code&gt;&amp;lt;c-r&amp;gt;=input(&quot;What do you want to count?&quot;)&amp;lt;cr&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't find this approach very ergonomic, I avoid using &lt;code&gt;input()&lt;/code&gt; as much as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, I have another approach: I've defined a &lt;code&gt;Count&lt;/code&gt; command. In the end, I type &lt;code&gt;:Cou&amp;lt;tab&amp;gt; &amp;lt;pattern&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It could be defined with the one-liner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -range=% Count &#xA;\  echo eval(join(map(getline(&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;), 'count(v:val, &quot;&amp;lt;args&amp;gt;&quot;)'), '+'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you prefer to stick with &lt;code&gt;s//gn&lt;/code&gt; -&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -range=% Count keeppatterns &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;s/&amp;lt;args&amp;gt;//gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;del&gt;(I prefer the solution with &lt;code&gt;:echo&lt;/code&gt; as it leaves the search register unchanged, and as such it doesn't change what's highlighted when &lt;code&gt;&amp;amp;hlsearch&lt;/code&gt; is set)&lt;/del&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-03-07T21:53:58.317" LastActivityDate="2018-03-07T21:53:58.317" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15478" PostTypeId="1" AcceptedAnswerId="15482" CreationDate="2018-03-07T18:28:16.573" Score="6" ViewCount="3869" Body="&lt;p&gt;Suppose I’ve selected some text in visual mode. How do I insert a certain piece of text at the beginning of the selection and a different piece of text at the end?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I’m only concerned with “normal” visual mode, not visual line mode or visual block mode.)&lt;/p&gt;&#xA;" OwnerUserId="671" LastActivityDate="2023-08-10T15:46:21.240" Title="How do I add text before and after the visual selection?" Tags="|substitute|visual-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15479" PostTypeId="2" ParentId="15478" CreationDate="2018-03-07T18:28:16.573" Score="0" Body="&lt;p&gt;Suppose you want to wrap the selected text with &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt;. Make your selection and then run this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V.*\%V./[[&amp;amp;]]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that if you type &lt;kbd&gt;:&lt;/kbd&gt; in visual mode then the &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; is inserted for you, so you only need to type &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt; to get the &lt;code&gt;:'&amp;lt;,'&amp;gt;s&lt;/code&gt; at the beginning of the command.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What’s going on here?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%25V&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\%V&lt;/code&gt;&lt;/a&gt; is a special matching atom. For whatever reason, the docs say, “To make sure the whole pattern is inside the Visual area put it at the start and &lt;em&gt;just before the end&lt;/em&gt; of the pattern” (emphasis added). That’s why there’s an extra &lt;code&gt;.&lt;/code&gt; in the pattern. Here’s what each atom in the pattern means:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\%V&lt;/code&gt;: match the beginning of the visual selection.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*&lt;/code&gt;: match everything from the beginning of the selection up to, &lt;em&gt;but not including,&lt;/em&gt; the final character.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%V&lt;/code&gt;: match “just before the end” of the selection.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt;: match the final character in the selection.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Despite these complexities, we can use the convenient &lt;code&gt;&amp;amp;&lt;/code&gt; in the replacement string to mean “the entire string that was selected.”&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Caveat&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This will not work as expected if your selection spans multiple lines: each line will end up with its own &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt; (or whatever strings you’re using). I tried to replace the &lt;code&gt;.&lt;/code&gt; with &lt;code&gt;\_.&lt;/code&gt; in the pattern but that just made things weird—text was inserted well outside of the visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Improvements to my answer would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="671" LastActivityDate="2018-03-07T18:28:16.573" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15482" PostTypeId="2" ParentId="15478" CreationDate="2018-03-07T19:08:59.243" Score="9" Body="&lt;p&gt;Use &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt; to replace the text and &quot;surround&quot; it. From visual mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;c(&amp;lt;c-r&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will surround the text with &lt;code&gt;(&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternative: If you find yourself doing many &quot;surrounding&quot; like operations you may want to look into the &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;noreferrer&quot;&gt;surround.vim&lt;/a&gt; or &lt;a href=&quot;https://github.com/machakann/vim-sandwich&quot; rel=&quot;noreferrer&quot;&gt;vim-sandwich&lt;/a&gt; plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h v_c&#xA;:h i_CTRL-R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-03-08T15:07:33.987" LastActivityDate="2018-03-08T15:07:33.987" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15483" PostTypeId="1" CreationDate="2018-03-07T20:00:50.390" Score="4" ViewCount="3220" Body="&lt;p&gt;I have many autocommands in my vimrc. Some of them do have the augroup wrapping to make them not duplicate when re-sourcing the vimrc, but many do not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than try to wrap all of them at this point, I figured that for my vimrc sourcing bind&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;L :so $MYVIMRC&amp;lt;CR&amp;gt;:runtime! after/plugin/*.vim&amp;lt;CR&amp;gt;:runtime! after/ftplugin/*.vim&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that i should just have it do something similar to treating the entire vimrc as a global augroup and clear that before sourcing the scripts again. I think that I cannot literally do this, because only autocommand-commands should be inside of an augroup, and nested augroups probably are not a thing... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this be done? I'm hoping for a feature that just does this, rather than having to programmatically find all set autocommands to clear them one at a time.&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-04-14T15:33:15.953" Title="Clear ALL autocommands" Tags="|autocmd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15484" PostTypeId="1" AcceptedAnswerId="15486" CreationDate="2018-03-08T06:53:35.703" Score="1" ViewCount="1223" Body="&lt;p&gt;I'm trying to learn multi line highlighting and have managed to get the following working&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region myMinusStart start=/^\s\+zzzz / end=/^\s\+qqqq / concealends&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the concealends is not hiding the line with  &lt;code&gt;zzzz $&lt;/code&gt; or the line with &lt;code&gt;qqqq $&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading `:h :syn-concealends' it seemed to say that to conceal the ends they need a match group so I tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match myMinusBegin /^\s\+zzzz / contained conceal&#xA;syntax match myMinusEnd  /^\s\+qqqq /  contained conceal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/twaez.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/twaez.png&quot; alt=&quot;example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the start line still didn't conceal. Any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: For some reason the &lt;code&gt;zzzz&lt;/code&gt;  is reporting as MyMinusStart which would suggest why it's not concealing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried the following thinking the pattern had to differ but with no luck&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match myMinusBegin /^\s\+zzzz / contained conceal&#xA;syntax match myMinusEnd  /^\s\+qqqq /  contained conceal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&#xA;I tried Karl's suggestion, below, and that hid the start and end markers but after removing transparent, as it hid the color highlighting , there's a termination problem in the pattern I can't work out&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Karl's suggestion&lt;/strong&gt;&#xA;    syntax region myMinusStart start=/^\s+zzzz / end=/^\s+qqqq /&#xA;        \ transparent&#xA;        \ contains=myMinusBegin,myMinusEnd&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match myMinusBegin /^\s\+zzzz / contained conceal&#xA;syntax match myMinusEnd  /^\s\+qqqq /  contained conceal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Dke36.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Dke36.png&quot; alt=&quot;Example 1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason once I enter &lt;code&gt;zzzz $&lt;/code&gt; and &lt;code&gt;qqqq $&lt;/code&gt; once it color hilights to the end of the file. There are three blocks that match the region but I can't see why the coloring continues until file end.&lt;/p&gt;&#xA;" OwnerUserId="1313" LastEditorUserId="1313" LastEditDate="2018-03-09T00:35:32.213" LastActivityDate="2020-11-27T11:01:35.677" Title="concealing the start and end pattern in syntax region" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15486" PostTypeId="2" ParentId="15484" CreationDate="2018-03-08T10:15:29.977" Score="5" Body="&lt;p&gt;Try the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;syntax region myMinusStart start=/^\s\+zzzz / end=/^\s\+qqqq /&#xA;      \ keepend&#xA;      \ contains=myMinusBegin,myMinusEnd&#xA;&#xA;syntax match myMinusBegin /^\s\+zzzz / contained conceal&#xA;syntax match myMinusEnd  /^\s\+qqqq /  contained conceal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that you need to set &lt;code&gt;conceallevel&lt;/code&gt; e.g. to 2, see &lt;code&gt;:h conceallevel&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: A simpler alternative:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;syntax region myMinusRegion matchgroup=myMinusDelim&#xA;      \ start=/^\s\+zzzz / end=/^\s\+qqqq /&#xA;      \ concealends&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Of course, if you want the start and end matches to be highlighted differently, then the original version is necessary.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2020-11-27T11:01:35.677" LastActivityDate="2020-11-27T11:01:35.677" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="15487" PostTypeId="1" AcceptedAnswerId="15488" CreationDate="2018-03-08T12:00:04.873" Score="11" ViewCount="2474" Body="&lt;p&gt;I have a function in vim which will open all buffers as tabs. However after I add this function, vimdiff too opens the files to be compared as different tabs and hence doesn't show the differences. Is there a way where I can find out if its vim or vimdiff which is invoking my vimrc file?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! OpenTabs()&#xA;    let bf=len(filter(range(1, bufnr('$')), 'buflisted(v:val)'))&#xA;    if bf &amp;gt; 1&#xA;      exe &quot;tab 5sball&quot;&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16636" LastActivityDate="2018-03-08T12:12:28.873" Title="How do I differentiate between vim and vimdiff from within vimrc?" Tags="|vimrc|vimdiff|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15488" PostTypeId="2" ParentId="15487" CreationDate="2018-03-08T12:12:22.367" Score="14" Body="&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/diff.txt.html#diff&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help diff&lt;/code&gt;&lt;/a&gt; covers this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In your .vimrc file you could do something special when Vim was started in&#xA;  diff mode.  You could use a construct like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   if &amp;amp;diff&#xA;      setup for diff mode&#xA;   else&#xA;      setup for non-diff mode&#xA;   endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-03-08T12:12:22.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15489" PostTypeId="2" ParentId="15487" CreationDate="2018-03-08T12:12:28.873" Score="12" Body="&lt;p&gt;You can use the &lt;code&gt;&amp;amp;diff&lt;/code&gt; option like in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;diff&#xA;    echo &quot;in diff mode&quot;&#xA;else&#xA;    echo &quot;not in diff mode&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27diff%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'diff'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-03-08T12:12:28.873" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15490" PostTypeId="1" AcceptedAnswerId="15492" CreationDate="2018-03-08T13:13:59.960" Score="1" ViewCount="476" Body="&lt;p&gt;I see this guard clause at the top of a lot of plugins,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;g:loaded_thisplugin&quot;) || v:version &amp;lt; 700 || &amp;amp;cp&#xA;  finish&#xA;endif&#xA;let g:loaded_thisplugin = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there something specific about versions of Vim prior to 7.0 that motivates this version check?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2018-03-08T14:21:27.943" Title="Why do plugins check v:version &lt; 700?" Tags="|plugin-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15491" PostTypeId="2" ParentId="15490" CreationDate="2018-03-08T13:28:25.737" Score="1" Body="&lt;p&gt;Not all plugins have this condition. This is added if the plugin uses a feature that didn’t exist before version 7. &lt;/p&gt;&#xA;" OwnerUserId="16636" LastActivityDate="2018-03-08T13:28:25.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15492" PostTypeId="2" ParentId="15490" CreationDate="2018-03-08T14:21:27.943" Score="8" Body="&lt;p&gt;&lt;code&gt;v:version&lt;/code&gt; specifies your current version of Vim. Version 7.0 has version 700, 7.2 has version 702, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, version 7 was a very major release with many enhancements to the previous release 6, that introduced man scripting enhancements. For example I believe prior to that version dictionaries, Funcrefs and lists were not available, many functions did not exists, no floating point data type (that one was actually included I believe with 7.2), Tab pages were not possible, Spell checking has been included, Completion functions have been added, the undo branches feature was added, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in principle this is just a guard, that your plugin is run by a Vim version, that has all required features needed for the plugin to perform its work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are interested in what feature was added in which version, read the help at &lt;code&gt;:h new-8&lt;/code&gt;, &lt;code&gt;:h new-7&lt;/code&gt; &lt;code&gt;:h new-6&lt;/code&gt;, etc...&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-03-08T14:21:27.943" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15493" PostTypeId="1" AcceptedAnswerId="15494" CreationDate="2018-03-08T16:22:41.607" Score="0" ViewCount="1626" Body="&lt;p&gt;I have a csv that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1,wer123,name,address1,age,2,cde789,name,address1,address2,age,3,529owq,name,address1,age&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want this csv to be formatted as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1, wer123, name, address1, age&#xA;2, cde789, name, address1 address2, age&#xA;3, 529owq, name, address1, age&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is scrapped data where address field sometimes have two lines . I tried to find the fifth coma using &lt;code&gt;5f,&lt;/code&gt; and then &lt;code&gt;r&amp;lt;C-r&amp;gt;&lt;/code&gt; but it caused problem where address have two values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The logic is to find the fifth coma, check whether the next field is a number and insert a new line . If it is not a number then delete the previous coma and find the next number and insert a new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this procedure is correct is it possible to do this using vim or should I go for python ? If it is possible then how to do it ? The csv is a big file with some 5000+ values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the columns other than the first two ie; name, address and age are of utf-8 format . So here age is not a number . Sorry that i forgot to mention that earlier . &lt;/p&gt;&#xA;" OwnerUserId="5947" LastEditorUserId="5947" LastEditDate="2018-03-09T00:42:04.250" LastActivityDate="2018-03-09T03:33:24.553" Title="How to format csv with regex" Tags="|regular-expression|formatting|repeated-commands|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15494" PostTypeId="2" ParentId="15493" CreationDate="2018-03-09T03:27:43.590" Score="2" Body="&lt;p&gt;This solution assumes there are no commas except for the column separators (i.e. no commas in quotes or escaped with a &lt;code&gt;\&lt;/code&gt; or anything like that).  It also assumes that the column after the row number will never be only digits.  If that can't be guaranteed, then I think things become significantly more complicated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If my assumptions were acceptable then you should be able to do this in three steps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\d\+\%(,[^,]*\)\{4}\%(,[^,]*\)\?\zs,\ze\d\+,/\r/g&#xA;:%s/\%([^,]*,\)\{3}[^,]*\zs,\ze[^,]*,[^,]/ /&#xA;:%s/,\zs\ze/ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First, split each record into separate rows:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\d\+\%(,[^,]*\)\{4}\%(,[^,]*\)\?\zs,\ze\d\+,/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:s/&lt;/code&gt; - Start the substitution command.  I'm assuming everything currently exists on one line.  If there are multiple lines add a &lt;code&gt;%&lt;/code&gt; before the &lt;code&gt;s&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\d\+&lt;/code&gt; - Find one or more digits.  This finds the row number of the record.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%(&lt;/code&gt; - Group the following characters until the &lt;code&gt;\)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;,&lt;/code&gt; - Find a comma.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^,]*&lt;/code&gt; - Find as many non-comma characters as possible.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\)&lt;/code&gt; - End the group of characters started by &lt;code&gt;\%(&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\{4}&lt;/code&gt; - Find exactly 4 matches of the group contained by the &lt;code&gt;\%(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt;.  This finds the column after the row number, the name, address 1 and either address 2 or the age (depending on whether address 2 is present).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%(,[^,]*\)\?&lt;/code&gt; - Create another group of a comma followed by as many non-comma characters as possible.  This time, however, the match is optional because of the &lt;code&gt;\?&lt;/code&gt;.  This matches age if the previous group had address 2.  If there was no address 2, then this matches nothing (this is because of the &lt;code&gt;\d\+,&lt;/code&gt; that appears a bit later).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs,\ze&lt;/code&gt; - Find a comma.  The &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; sets the start and end range that will be replaced.  This basically means that only this comma will be replaced with the replacement pattern (the &lt;code&gt;\r&lt;/code&gt; that appears later).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\d\+,&lt;/code&gt; - Find another set of digits followed by a comma.  This finds the row number of the next record.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt; - Separator between the search pattern and the replacement pattern,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\r&lt;/code&gt; - Replace the comma that was between the &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; in the search pattern with a new line character.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/g&lt;/code&gt; - Specifies that all occurrences of the search pattern on the line should be replaced.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This should work on the example you provided as well as a few others that I tried.  I can't promise that it will work in all cases, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Next, get rid of the comma between the address 1 and address 2 columns:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\%([^,]*,\)\{3}[^,]*\zs,\ze[^,]*,[^,]/ /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s/&lt;/code&gt; - Start the substitution command, but this time perform it on all lines in the file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%([^,]*,\)\{3}&lt;/code&gt; - Create a group of as many non-comma characters as possible followed by a comma and match exactly 3 of these groups.  This finds the row number, the next column and the name.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^,]*&lt;/code&gt; - Find as many non-comma characters as possible.  This finds address 1.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs,\ze&lt;/code&gt; - Set the replacement range around the comma after address 1 (the one we want to get rid of).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^,]*,[^,]&lt;/code&gt; - Find as many non-comma characters followed by a comma followed by more non-comma characters.  This matches address 2 and age (and the comma separating them).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/ /&lt;/code&gt; - Separator between the search pattern and the replacement pattern followed by a space (the space is what will replace the comma between &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt;) followed by another &lt;code&gt;/&lt;/code&gt; to end the command.  The last &lt;code&gt;/&lt;/code&gt; isn't strictly necessary, but I added it to make it clear that there is a space in there.  Also, the &lt;code&gt;g&lt;/code&gt; isn't necessary like in the first step since we are only looking to replace the first occurrence of the search pattern (there would only ever be one one each line in this case anyway).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Finally, add a space after the remaining commas to make it look pretty:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/,\zs\ze/ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s/&lt;/code&gt; - Start the substitution command on the whole file again.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;,&lt;/code&gt; - Find a comma.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs\ze&lt;/code&gt; - Set the start and end of the replacement range.  Since there is nothing between them, it will basically insert the replacement pattern here.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/ /g&lt;/code&gt; - Basically the same thing as in the second step.  This time the &lt;code&gt;g&lt;/code&gt; is necessary because we want to perform the replacement for every comma on each line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1115" LastEditorUserId="1115" LastEditDate="2018-03-09T03:33:24.553" LastActivityDate="2018-03-09T03:33:24.553" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15495" PostTypeId="2" ParentId="3683" CreationDate="2018-03-09T12:34:51.827" Score="3" Body="&lt;p&gt;Even though I agree with @Vitor's comment saying that Vim is not meant to interact with a database, here is another solution:&lt;/p&gt;&#xA;&lt;p&gt;Tim Pope recently released &lt;a href=&quot;https://github.com/tpope/vim-dadbod&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-dadbod&lt;/a&gt; that he calls &amp;quot;a more modern take on dbext.vim&amp;quot;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;DB is a Vim plugin for interacting with databases.&#xA;It's a more modern take on dbext.vim, improving on it on the following ways:&#xA;&#xA;    - Connections are specified with a single URL, rather than prompting you&#xA;      for 14 separate variables&#xA;    - All interaction is through invoking :DB, not 53 different commands and 35&#xA;      different maps (omitting many of the more esoteric features, of course)&#xA;    - Supports a modern array of backends, including NoSQL databases:&#xA;        - MongoDB&#xA;        - MySQL&#xA;        - PostgreSQL&#xA;        - Redis&#xA;        - Sqlite&#xA;        - Your own easily implemented adapter&#xA;    - Easily configurable based on a project directory (as seen in rails.vim, for example),&#xA;      rather than just globally or in a per-file modeline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;From what I tested the postgresql integration works fine, given the usual quality of Pope's plugins there's a chance that it is a good solution.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="23502" LastEditDate="2022-05-16T10:54:03.127" LastActivityDate="2022-05-16T10:54:03.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15496" PostTypeId="1" AcceptedAnswerId="15499" CreationDate="2018-03-09T14:14:04.410" Score="1" ViewCount="778" Body="&lt;p&gt;If I store a value in a register in vim, is there a way I can transfer it to the system clipboard using a quick ex command?  Or do I need to write a macro to do that?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2018-03-09T14:49:50.100" Title="How to transfer a register to the system clipboard?" Tags="|register|os-clipboard|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15497" PostTypeId="2" ParentId="14925" CreationDate="2018-03-09T14:15:45.470" Score="0" Body="&lt;p&gt;Tim Pope just created a plugin called &lt;a href=&quot;https://github.com/tpope/vim-db&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-db&lt;/a&gt;. It's &quot;a modern take on dbext.vim&quot;, which seems to be exactly what you are looking for.&lt;/p&gt;&#xA;" OwnerUserId="16646" LastActivityDate="2018-03-09T14:15:45.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15498" PostTypeId="2" ParentId="15496" CreationDate="2018-03-09T14:20:21.777" Score="3" Body="&lt;pre&gt;&lt;code&gt;let @* = @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;q&lt;/code&gt; is the register in question.&lt;/p&gt;&#xA;" OwnerUserId="5232" LastActivityDate="2018-03-09T14:20:21.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15499" PostTypeId="2" ParentId="15496" CreationDate="2018-03-09T14:21:35.683" Score="4" Body="&lt;p&gt;you can try &lt;code&gt;:let @*=@a&lt;/code&gt; to assign register a to register *.&#xA;Same for @+ (depending on which clipboard you want)&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-03-09T14:21:35.683" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15500" PostTypeId="2" ParentId="15496" CreationDate="2018-03-09T14:47:19.613" Score="4" Body="&lt;p&gt;While &lt;code&gt;let @*&lt;/code&gt; and &lt;code&gt;let @+&lt;/code&gt; works, the recommended way to do it in the doc is to use &lt;code&gt;setreg()&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setreg('+', @a)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#setreg%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h setreg()&lt;/code&gt;&lt;/a&gt; which even contains an example of what you want to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg('*', @%, 'ac')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The third argument is used to specify the type of the register you want to copy. It is also used to append the register to the current content of the clipboard:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;If {options} contains &quot;a&quot; or {regname} is upper case,&#xA;then the value is appended.&#xA;{options} can also contain a register type specification:&#xA;    &quot;c&quot; or &quot;v&quot;          |characterwise| mode&#xA;    &quot;l&quot; or &quot;V&quot;          |linewise| mode&#xA;    &quot;b&quot; or &quot;&amp;lt;CTRL-V&amp;gt;&quot; |blockwise-visual| mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="11477" LastEditDate="2018-03-09T14:49:50.100" LastActivityDate="2018-03-09T14:49:50.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15501" PostTypeId="2" ParentId="15383" CreationDate="2018-03-09T14:52:29.087" Score="0" Body="&lt;p&gt;if you are a linux user:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo ':term' | nvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will send the commands directly through the pipe. So there won't be any error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally also put an alias into my &lt;code&gt;.bashrc&lt;/code&gt; file too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias nvim='echo &quot;:term&quot; | nvim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;If you still want to open files with nvim you might want to put something like this into your &lt;code&gt;bashrc&lt;/code&gt; file (and remove the alias)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim() {&#xA;    if [[ $@ == &quot;.&quot; ]]; then&#xA;        command echo &quot;:terminal&quot; | nvim&#xA;    else&#xA;        command nvim &quot;$@&quot;&#xA;    fi&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16652" LastEditorUserId="16652" LastEditDate="2018-03-09T15:45:19.797" LastActivityDate="2018-03-09T15:45:19.797" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15502" PostTypeId="2" ParentId="15422" CreationDate="2018-03-09T15:55:49.830" Score="2" Body="&lt;p&gt;Try &lt;code&gt;:spelldump&lt;/code&gt;.  A buffer will open with a long listing of words.  At the top is something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/regions=usaucagbnz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This defines a set of regions for the current language, &lt;code&gt;1=us&lt;/code&gt;, &lt;code&gt;2=au&lt;/code&gt;, &lt;code&gt;3=ca&lt;/code&gt;, &lt;code&gt;4=gb&lt;/code&gt;, &lt;code&gt;5=nz&lt;/code&gt;.  Searching for &lt;code&gt;muon&lt;/code&gt;, we see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Munson's/245&#xA;Munster&#xA;Munster's&#xA;muon/245&#xA;muon's/245&#xA;muons/245&#xA;Muppet&#xA;Muppet's&#xA;mural&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Words that have no &lt;code&gt;/&lt;/code&gt; are considered acceptable in any region.  Words that have &lt;code&gt;/&lt;/code&gt; followed by numbers are acceptable in those numbered regions.  So, vim thinks &lt;code&gt;muon&lt;/code&gt; is correct in Australia, Great Britain, and New Zealand, and nowhere else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I don't think this is actually true; muon is a valid word in all regions; but vim had to source its dictionaries from somewhere so it is bound by the accuracy of those sources.  Fortunately, vim offers the ability to customize the spell checker dictionaries.  The most basic way is to put your cursor over &lt;code&gt;muon&lt;/code&gt; and type &lt;code&gt;zg&lt;/code&gt; in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for rare words, there is only one listed in the default English dictionary: the word &lt;code&gt;vim&lt;/code&gt;, and only in regions 2 and 5- Australia and New Zealand.  You can do &lt;code&gt;:/\w\/?&lt;/code&gt; to look for them.  However, I wasn't able to get vim to actually call it a rare word in any region, probably because the word &lt;code&gt;Vim&lt;/code&gt; is also listed in regions &lt;code&gt;2,5&lt;/code&gt; so vim calls it &lt;code&gt;SpellCap&lt;/code&gt; instead of &lt;code&gt;SpellRare&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-03-09T16:15:06.637" LastActivityDate="2018-03-09T16:15:06.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15503" PostTypeId="1" AcceptedAnswerId="15504" CreationDate="2018-03-09T23:11:45.097" Score="8" ViewCount="5341" Body="&lt;p&gt;Searching for a solution to show hidden characters, I found the example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set listchars=eol:$,tab:&amp;gt;-,trail:~,extends:&amp;gt;,precedes:&amp;lt;&#xA;:set list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What are &lt;code&gt;extends&lt;/code&gt; and &lt;code&gt;precedes&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I expected a file to have only tabs, but these options show some spaces as &lt;code&gt;&amp;gt;&lt;/code&gt; rather than &lt;code&gt;&amp;gt;-&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://askubuntu.com/questions/74485/how-to-display-hidden-characters-in-vim&quot;&gt;How to Display Hidden Characters in vim?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1694" LastActivityDate="2018-03-10T05:05:51.160" Title="Using set listchars, what are 'extends' and 'precedes'?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15504" PostTypeId="2" ParentId="15503" CreationDate="2018-03-10T05:05:51.160" Score="10" Body="&lt;p&gt;Extends and Precedes are used when you don't have line wrapping on, to show that there is more text to the left or right of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a wide window, I might have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|This is a long line of text.$      |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With extends and precedes set as you have, and shrinking the terminal a lot with the cursor at the beginning of the line (and &lt;code&gt;:set nowrap&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|This is a long li&amp;gt;|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hitting &lt;code&gt;$&lt;/code&gt; will show the precedes as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|&amp;lt;e of text.$      |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Moving to the middle:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|&amp;lt;long line of tex&amp;gt;|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(you can read more in the documentation for listchars, see &lt;code&gt;:help 'listchars'&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to seeing '&gt;' instead of '&gt;-' or '&gt;---' for tabs, depending on where you are, a tab stop one character away from where the tab character is would result in a single character shown. Inserting a tab at the beginning (and wider window):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|&amp;gt;---This is a long line of text.$   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;adding 'ab'&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|ab&amp;gt;-This is a long line of text.$   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adding 'c'&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|abc&amp;gt;This is a long line of text.$   |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The '&gt;' in this case always shows where the tab character is, and the '-' shows what additional columns were skipped to reach the tab stop, if any.&lt;/p&gt;&#xA;" OwnerUserId="227" LastActivityDate="2018-03-10T05:05:51.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15505" PostTypeId="1" AcceptedAnswerId="15531" CreationDate="2018-03-10T07:44:17.007" Score="13" ViewCount="4155" Body="&lt;p&gt;I'm still learning Vim and making small customizing on it. I'm struggling a bit to create a custom style/syntax highlight which would highlight the whole todo line. So in the picture instead of having just the &quot;TODO&quot; colored, I would like the whole line to be colored, or at least everything after the word &quot;TODO&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dpWqK.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dpWqK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I made some attempts myself by applying this SO-post answer: &lt;a href=&quot;https://stackoverflow.com/questions/4097259/in-vim-how-do-i-highlight-todo-and-fixme&quot;&gt;https://stackoverflow.com/questions/4097259/in-vim-how-do-i-highlight-todo-and-fixme&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and added the answer's rules to my Vim theme's file in &lt;code&gt;.vim/colors/myTheme.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match   myTodo   contained   &quot;\&amp;lt;\(TODO\|FIXME\):&quot;&#xA;hi def link myTodo Todo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well this did not highlight the &quot;:&quot; like in the SO was described and neither it did highlight the line when I edited the regex to match the rest of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also checked that the rule was in place on editor by using &lt;code&gt;:syn list myTodo&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After this experiment I figured that maybe I should add this rule to syntax highlighting files instead of my theme. However, I'm not sure if this is a correct assumption and how to do it. I'd like to highlight TODO lines in every language I work with, be it Tex, Python, JS etc. By inspecting directory &lt;code&gt;/usr/share/vim/vim74/syntax/&lt;/code&gt; it looks like each language needs a separate syntax file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to define the TODO-highlight syntax globally? How and where should I put the definition? Btw, I use Vim from terminal on Linux.&lt;/p&gt;&#xA;" OwnerUserId="16647" LastEditorUserId="343" LastEditDate="2018-03-12T14:49:55.140" LastActivityDate="2018-03-12T15:08:43.210" Title="Highlight whole todo comment line" Tags="|syntax-highlighting|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15506" PostTypeId="2" ParentId="8285" CreationDate="2018-03-10T09:54:50.227" Score="4" Body="&lt;p&gt;I'd like to add another option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do &lt;code&gt;/original&lt;/code&gt; and then do &lt;code&gt;:%s//replacement&lt;/code&gt;.&#xA;(Use &lt;code&gt;/c&lt;/code&gt; at the end if you want confirmation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although you are pressing 3 more keys, this has an advantage over doing just &lt;code&gt;%s/original/replacement&lt;/code&gt; because it provides a visual cue that your search is correct.&lt;/p&gt;&#xA;" OwnerUserId="16658" LastEditorUserId="1841" LastEditDate="2018-03-10T12:46:36.083" LastActivityDate="2018-03-10T12:46:36.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15507" PostTypeId="1" AcceptedAnswerId="15509" CreationDate="2018-03-10T12:42:24.140" Score="0" ViewCount="136" Body="&lt;p&gt;Based on v:count help I define:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map _x :&amp;lt;C-U&amp;gt;echo &quot;the count is &quot; . v:count . ' and count1 is ' . v:count1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_x&#xA;the count is 0 and count1 is 1&#xA;0_x&#xA;the count is 0 and count1 is 1&#xA;1_x&#xA;the count is 1 and count1 is 1&#xA;3_x&#xA;the count is 3 and count1 is 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My goal is detect when map do not get count at all, but v:count always get a 0 value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any chance to detect that?&lt;/p&gt;&#xA;" OwnerUserId="2779" LastEditorUserId="2779" LastEditDate="2018-03-13T12:11:12.253" LastActivityDate="2018-03-13T12:11:12.253" Title="Is it possible to detect when a command uses no count?" Tags="|count|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15508" PostTypeId="1" CreationDate="2018-03-10T12:49:18.797" Score="0" ViewCount="72" Body="&lt;p&gt;I'm not that experienced with vim. I've been working with some html/php in macvim and there's this annoying behaviour that I don't know how to control. See below. &lt;code&gt;x&lt;/code&gt; denotes the current position of the cursor&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &amp;lt;?php&#xA;    $relatedPrograms = get_field('related_programs');&#xA;&#xA;    echo '&amp;lt;ul class=&quot;min-list&quot;&amp;gt;';&#xA;    foreach($relatedPrograms as $program) { ?&amp;gt;&#xA;        &amp;lt;li&amp;gt;&amp;lt;a href=&quot;&amp;lt;?php echo get_the_permalink($program); ?&amp;gt;&quot;&amp;gt;&amp;lt;?php echo get_the_title($program); ?&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#xA;&#xA;    &amp;lt;?php }x&#xA;    ?&amp;gt;  &#xA;    &amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to create a blank line between &lt;code&gt;?php }&lt;/code&gt; and &lt;code&gt;?&amp;gt;&lt;/code&gt; but I don't want anything to get pulled to the beginning of the line. After pressing &lt;kbd&gt;Enter&lt;/kbd&gt;, it pulls the whole content to the beginning of the current line and enters newline. &lt;code&gt;x&lt;/code&gt; denotes the new position of the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    echo '&amp;lt;ul class=&quot;min-list&quot;&amp;gt;';&#xA;       foreach($relatedPrograms as $program) { ?&amp;gt;&#xA;           &amp;lt;li&amp;gt;&amp;lt;a href=&quot;&amp;lt;?php echo get_the_permalink($program); ?&amp;gt;&quot;&amp;gt;&amp;lt;?php echo get_the_title($program); ?&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#xA;&#xA;&amp;lt;?php }  // this line has been pulled to the beginning of line.&#xA;x &#xA;       ?&amp;gt;  &#xA;       &amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;syntax on&#xA;set nowrap&#xA;set encoding=utf8&#xA;&#xA;&quot; Tabs vs Space {{{&#xA;set tabstop=4                           &quot; Use 4 spaces for &amp;lt;Tab&amp;gt; and :retab&#xA;set shiftwidth=4&#xA;set expandtab                           &quot; Expand tabs to spaces&#xA;set smarttab&#xA;&quot; }}}&#xA;&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'junegunn/vim-easy-align'&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'vim-syntastic/syntastic'&#xA;Plug 'tomtom/tcomment_vim'&#xA;Plug 'sheerun/vim-polyglot'&#xA;&#xA;call plug#end()&#xA;&#xA;&quot; Start Nerdtree if no file is specified&#xA;autocmd StdinReadPre * let s:std_in=1&#xA;autocmd VimEnter * if argc() == 0 &amp;amp;&amp;amp; !exists(&quot;s:std_in&quot;) | NERDTree | endif&#xA;&#xA;&quot; start NERDTree Ctrl-n&#xA;map &amp;lt;C-n&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Leader C is the prefix for code related mappings&#xA;&quot; comment/uncomment line with ,cc&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;cc :TComment&amp;lt;CR&amp;gt;&#xA;&quot; Sytastic config&#xA;set statusline+=%#warningmsg#                                   &quot;syntastic&#xA;set statusline+=%{SyntasticStatuslineFlag()}                    &quot;syntastic&#xA;set statusline+=%*                                              &quot;syntastic&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1                    &quot;syntastic&#xA;let g:syntastic_auto_loc_list = 1                               &quot;syntastic&#xA;let g:syntastic_check_on_open = 1                               &quot;syntastic&#xA;let g:syntastic_check_on_wq = 0                                 &quot;syntastic&#xA;&#xA;&quot; Mappings to access buffers (don't use &quot;\p&quot; because a&#xA;&quot; delay before pressing &quot;p&quot; would accidentally paste).&#xA;&quot; \l       : list buffers&#xA;&quot; \b \f \g : go back/forward/last-used&#xA;&quot; \1 \2 \3 : go to buffer 1/2/3 etc&#xA;nnoremap &amp;lt;Leader&amp;gt;l :ls&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;b :bp&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;f :bn&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;g :e#&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;1 :1b&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;2 :2b&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;3 :3b&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;4 :4b&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;5 :5b&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;6 :6b&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;7 :7b&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;8 :8b&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;9 :9b&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;0 :10b&amp;lt;CR&amp;gt;&#xA;&quot; It's useful to show the buffer number in the status line.&#xA;set laststatus=2 statusline=%02n:%&amp;lt;%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10247" LastEditorUserId="1841" LastEditDate="2018-03-10T13:06:36.220" LastActivityDate="2018-04-11T00:06:46.910" Title="Going to newline pulls existing code to beginning of line" Tags="|indentation|" AnswerCount="1" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15509" PostTypeId="2" ParentId="15507" CreationDate="2018-03-10T17:25:19.563" Score="3" Body="&lt;p&gt;&lt;code&gt;0&lt;/code&gt; is not a valid count.  &lt;code&gt;0_x&lt;/code&gt; does not mean give a count of &lt;code&gt;0&lt;/code&gt; to command &lt;code&gt;_x&lt;/code&gt;, it means go to the first column of the line, then run command &lt;code&gt;_x&lt;/code&gt;.  You cannot give &lt;code&gt;0&lt;/code&gt; as a count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence, &lt;code&gt;v:count == 0&lt;/code&gt; means no count is provided.  Some commands interpret count &lt;code&gt;0&lt;/code&gt; as equivalent to &lt;code&gt;1&lt;/code&gt;.  For this reason, a shortcut &lt;code&gt;v:count1&lt;/code&gt; is also provided which is the same as &lt;code&gt;v:count&lt;/code&gt; except when no count is given, in which case &lt;code&gt;v:count == 1&lt;/code&gt;. You cannot use &lt;code&gt;v:count1&lt;/code&gt; alone to determine when no count is provided.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-03-10T17:25:19.563" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15510" PostTypeId="1" CreationDate="2018-03-10T18:19:03.577" Score="0" ViewCount="586" Body="&lt;p&gt;I know this must seem stupid... however I've just wasted like 2 hours trying to get vim-plug working.  I am on CentOS7.  I type vi and it brings up vim 7.4.160.  I typed vim and I get vim: command not found.  After faffing about for ages and searching on google as I could not get the plugin manager to work, I finally did yum install vim.  And it did.  Typing vi and the plugin manager still did now work.  Finally now I type vim and the plugin manager works.  vi and vim commands with no args brings up the exact same VIM - Vi IMproved banner and exact same versions.  At this point I am just curious as to what is going on in the background to cause this behavior.&lt;/p&gt;&#xA;" OwnerUserId="16660" LastActivityDate="2018-04-10T02:01:43.300" Title="what is the difference between calling vim by typing vi and typing vim" Tags="|original-vi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15512" PostTypeId="2" ParentId="15510" CreationDate="2018-03-11T01:25:26.920" Score="3" Body="&lt;p&gt;If you want to run Vim, then type vim. ☺&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a more serious note, most of the Linux distributions provide different builds of Vim, with varying feature levels (i.e., the &lt;code&gt;--with-features=...&lt;/code&gt; argument when running &lt;code&gt;./configure&lt;/code&gt;), GUI support, and enabled language bindings.  Speaking with my Debian maintainer hat on, I provide these packages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vim-tiny: small features, only provides the vi binary, intentionally runs with &lt;code&gt;'compatible'&lt;/code&gt; set, no language bindings, no X/GUI support&lt;/li&gt;&#xA;&lt;li&gt;vim: huge features, no language bindings, no X/GUI support&lt;/li&gt;&#xA;&lt;li&gt;vim-nox: huge features, all language bindings except Racket, no X/GUI support&lt;/li&gt;&#xA;&lt;li&gt;vim-gtk/gtk3/athena: huge features all language bindings except Racket, X/GUI support&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In Debian land, you can have more than one of the packages above installed and can use the alternatives system (via the &lt;code&gt;update-alternatives&lt;/code&gt; command) to decide which one is used when typing &lt;code&gt;vi&lt;/code&gt;, &lt;code&gt;vim&lt;/code&gt;, &lt;code&gt;gvim&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds like there's a similar set of packages in CentOS land.  I'm not sure if there's something similar to the alternatives system, which would let you configure what &lt;code&gt;vi&lt;/code&gt; runs, or if vi is &lt;em&gt;only&lt;/em&gt; provided by the vim-minimal package.  I think it's the latter since I seem to recall that when you install the package that provides a GUI, you have to run &lt;code&gt;vimx&lt;/code&gt; to run that binary in the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as what the actual differences are between the different binaries, you should be able to get a high-level overview from your package manager.  You can also ask Vim to tell you.  Compare &lt;code&gt;vi --version&lt;/code&gt; to &lt;code&gt;vim --version&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2018-03-11T01:25:26.920" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15513" PostTypeId="1" AcceptedAnswerId="15514" CreationDate="2018-03-11T03:02:26.407" Score="0" ViewCount="12405" Body="&lt;p&gt;Tried google it, but I still can't figure our where to download gvim 8.0.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-03-11T17:12:25.517" Title="Where to download gvim 8.0?" Tags="|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15514" PostTypeId="2" ParentId="15513" CreationDate="2018-03-11T09:00:29.113" Score="3" Body="&lt;p&gt;The vim.org website lists downloads for all platforms including Windows, it can be downloaded from here &lt;a href=&quot;https://www.vim.org/download.php#pc&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gvim.&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It includes GUI and console versions, for 32 bit and 64 bit systems. &lt;/p&gt;&#xA;" OwnerUserId="9004" LastActivityDate="2018-03-11T09:00:29.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15515" PostTypeId="1" AcceptedAnswerId="15517" CreationDate="2018-03-11T11:23:05.227" Score="3" ViewCount="5660" Body="&lt;p&gt;&lt;em&gt;Hello, so I just posted an issue in neovim's officiall github repo about a problem I am going to tell you about in a couple seconds and after finding a solution they told me the instructions were outdated and so they redirected me here...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My issue is that...being a vim user I got used to the deafult cursor shape which is the default terminal one but after switching to neovim I've realised that when I switch to insert mode the shape of my cursor switches to such a gui cursor or a vertical bar which don't get me wrong...it is a really cool feature and thing to have but I don't particulary like it so I've been trying to remove or disable it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;https://github.com/neovim/neovim/pull/5977#issuecomment-372105560&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; thread which is the one I was talking about the solution was that I change the value of &lt;strong&gt;NVIM_TUI_ENABLE_CURSOR_SHAPE&lt;/strong&gt; &#xA;to &lt;strong&gt;0&lt;/strong&gt; but apperantly that is &lt;strong&gt;outdated&lt;/strong&gt; so I would like to get some help from this forums. Some more information about neovim and terminal you can find below and and help would be greatly appreciated!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Neovim Version 0.2.2&#xA;URXVT Version 9.22&#xA;Operating System : Manjaro i3 4.12.24-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: Ashok recommended so I better visualize my problem with some pictures so here they are...&#xA;The deafult cursor I would like to have which is the one you get on vim as well is&lt;br&gt;&lt;a href=&quot;https://i.stack.imgur.com/tlyQ9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tlyQ9.png&quot; alt=&quot;this&quot;&gt;&lt;/a&gt;&lt;br&gt; and I want that to not change in all modes...however when I switch to insert mode in neovim it changed the cursor to some sort of vertical shape like&lt;br&gt; &lt;a href=&quot;https://i.stack.imgur.com/j5oE7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/j5oE7.png&quot; alt=&quot;this&quot;&gt;&lt;/a&gt;.&lt;br&gt; Hope I made it easier to understand!&lt;/p&gt;&#xA;" OwnerUserId="16330" LastEditorUserId="16330" LastEditDate="2018-03-11T12:55:33.473" LastActivityDate="2018-03-11T13:50:12.343" Title="How disable cursor shape modes in neovim?" Tags="|neovim|cursor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15517" PostTypeId="2" ParentId="15515" CreationDate="2018-03-11T13:50:12.343" Score="3" Body="&lt;p&gt;As described in the &lt;a href=&quot;https://github.com/neovim/neovim/wiki/FAQ#how-to-change-cursor-shape-in-the-terminal&quot; rel=&quot;nofollow noreferrer&quot;&gt;FAQ&lt;/a&gt;, prior to version 0.2 cursor shaping was only enabled if &lt;code&gt;$NVIM_TUI_ENABLE_CURSOR_SHAPE&lt;/code&gt; was set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting with 0.2, the &lt;code&gt;'guicursor'&lt;/code&gt; option took over this functionality, so that the behavior could be consistent among UIs.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For Neovim &amp;lt; 0.2, don't set &lt;code&gt;$NVIM_TUI_ENABLE_CURSOR_SHAPE&lt;/code&gt; if you don't want cursor shaping&lt;/li&gt;&#xA;&lt;li&gt;Otherwise, put &lt;code&gt;set guicursor=&lt;/code&gt; in your init.vim to disable it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="15" LastActivityDate="2018-03-11T13:50:12.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15520" PostTypeId="1" AcceptedAnswerId="15976" CreationDate="2018-03-11T19:58:40.760" Score="-1" ViewCount="498" Body="&lt;p&gt;I've found the following command to execute Python or Matlab or any other language as far as I understand to execute code&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F9&amp;gt; :exec '!python' shellescape(@%, 1)&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;a href=&quot;https://stackoverflow.com/a/18948530/1886529&quot;&gt;source&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map &amp;lt;F5&amp;gt; &amp;lt;Esc&amp;gt;:w&amp;lt;CR&amp;gt;:!%:p&amp;lt;CR&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;a href=&quot;https://stackoverflow.com/a/601084/1886529&quot;&gt;source&lt;/a&gt;; supposedly should work for all scripts as it uses vim expand however I had this working before but now is giving me a &lt;code&gt;shell returned 126&lt;/code&gt; error)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to automatically execute the code without explicitly specifying the command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, if I have any script (Matlab, Python, Latex, ...) open and I press &lt;code&gt;F9&lt;/code&gt; the script is executed? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or maybe there's a package for such a thing?&lt;/p&gt;&#xA;" OwnerUserId="7703" LastEditorUserId="7703" LastEditDate="2018-03-11T20:15:45.467" LastActivityDate="2018-05-23T23:39:53.777" Title="Shortcut for automatic execution" Tags="|vimrc|external-command|packages|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15522" PostTypeId="1" AcceptedAnswerId="15607" CreationDate="2018-03-11T21:54:37.067" Score="3" ViewCount="7434" Body="&lt;p&gt;I know there's a number of ways you can suspend a Neovim/Vim session. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way being &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;Z&lt;/kbd&gt; to jump back into the command prompt, and press &lt;code&gt;fg&lt;/code&gt; and &lt;kbd&gt;ENTER&lt;/kbd&gt; to go back into your Neovim/Vim session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However....Doing this on Windows seems to freeze my console entirely to the point where I have to end the process by force. I don't want to use the &lt;code&gt;:!&lt;/code&gt; command in neovim because that's not what I'm trying to do, and the &lt;code&gt;:sus&lt;/code&gt; command essentially does the same thing as &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;Z&lt;/kbd&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this on Windows ? I know for sure that it can be done on Linux, and from a little research apparently &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;Z&lt;/kbd&gt; means end of input on DOS/Windows machines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT: 3/12/18&lt;/strong&gt;&#xA;Also, as additional info I used both ConEmu and the default Windows command line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT: 3/14/18&lt;/strong&gt;&#xA;Using the &lt;code&gt;:shell&lt;/code&gt; or &lt;code&gt;:sus&lt;/code&gt; command seems to get it to work fine in regular vanilla Vim 8.0 in combination with &lt;code&gt;exit&lt;/code&gt;, but that's only in regular Vim. &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;Z&lt;/kbd&gt; also works as well if I edit my &lt;code&gt;_vimrc&lt;/code&gt; to get rid of source &lt;code&gt;$VIMRUNTIME/mswin.vim&lt;/code&gt; and &lt;code&gt;behave mswin&lt;/code&gt;. I still will like this to be able to work in neovim&lt;/p&gt;&#xA;" OwnerUserId="9885" LastEditorUserId="1292" LastEditDate="2018-10-09T14:33:43.923" LastActivityDate="2018-10-09T14:33:43.923" Title="How to successfully back out to command prompt with Ctrl-Z in Neovim on Windows?" Tags="|neovim|microsoft-windows|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="15523" PostTypeId="1" AcceptedAnswerId="15605" CreationDate="2018-03-11T23:30:08.967" Score="4" ViewCount="166" Body="&lt;p&gt;Seems to be related to this question &lt;a href=&quot;https://vi.stackexchange.com/q/215/12597&quot;&gt;What is the &amp;#39;[Command Line]&amp;#39; that sometimes comes up when I try to quit, and how can I quickly exit it?&lt;/a&gt;, but the solution doesn't work for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HWuEc.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HWuEc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I pressed &lt;code&gt;esc&lt;/code&gt;, typed &lt;code&gt;:q&lt;/code&gt;, &lt;code&gt;&amp;lt;C-w&amp;gt; q&lt;/code&gt; but nothing seems to work. The window seems to capture every input and simply displays it, even mouse input!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has happened to me a few times and everytime I forced to close the terminal. How do I go back to my work without closing vim and without closing the terminal.&lt;/p&gt;&#xA;" OwnerUserId="12597" LastActivityDate="2018-03-17T20:54:33.190" Title="What is this strange area, and how do I exit out of it" Tags="|quit|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15524" PostTypeId="2" ParentId="15508" CreationDate="2018-03-11T23:30:11.233" Score="1" Body="&lt;p&gt;As suggested by David, I experimented with .vimrc to see what's the culprit by stripping it down to bare minimum.&#xA;It turned out the offending plugin was 'vim-easy-align'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="10247" LastActivityDate="2018-03-11T23:30:11.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15525" PostTypeId="1" AcceptedAnswerId="15553" CreationDate="2018-03-12T00:46:25.837" Score="0" ViewCount="288" Body="&lt;p&gt;I'm completely new to Vim scripting, so forgive me if this may seem trivial, but I would like to modify the Behavior of the Home and End keys such that, if the cursor is somewhere between the first and last non-blank character of the line, they would take me to the first or last non-blank character, respectively. However, if the cursor is already sitting on the first or last character of the line, they go to the first or last non-blank character on the &lt;em&gt;next&lt;/em&gt; line, respectively. I think I know some bits and pieces of how to do this, but I have trouble figuring out how to query for the two conditions (cursor on first or last character of the line). Seeing a complete solution would help me learn good coding style also. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="16675" LastActivityDate="2018-03-13T20:35:32.060" Title="Simple modification of behavior of Home, End keys" Tags="|vimscript|cursor-motions|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15526" PostTypeId="2" ParentId="15520" CreationDate="2018-03-12T08:42:37.480" Score="4" Body="&lt;p&gt;You are looking for the &lt;code&gt;makeprg&lt;/code&gt; option, &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27makeprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'makeprg'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                    *'makeprg'* *'mp'*&#xA;'makeprg' 'mp'                      string    (default &quot;make&quot;, VMS: &quot;MMS&quot;)&#xA;                                    global or local to buffer |global-local|&#xA;                                    {not in Vi}&#xA;    Program to use for the &quot;:make&quot; command.  See :make_makeprg.&#xA;&#xA;    This option may contain '%' and '#' characters, &#xA;    which are expanded to the current and alternate file name.  Use |::S| &#xA;    to escape file names in case they contain special characters.&#xA;    Environment variables are expanded |:set_env|.  See |option-backslash|&#xA;    about including spaces and backslashes.&#xA;&#xA;    Note that a '|' must be escaped twice: once for &quot;:set&quot; and once for&#xA;    the interpretation of a command.  When you use a filter called&#xA;    &quot;myfilter&quot; do it like this:&#xA;&#xA;        :set makeprg=gmake\ \\\|\ myfilter&#xA;&#xA;    The placeholder &quot;$*&quot; can be given (even multiple times) to specify&#xA;    where the arguments will be included, for example:&#xA;&#xA;        :set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*}&#xA;&#xA;    This option cannot be set from a |modeline| or in the |sandbox|, for&#xA;    security reasons.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The best way to use it is to define the option in an ftplugin. For example for python create &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt; containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal makeprg=python\ %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Create a new ftplugin and adapt the &lt;code&gt;makeprg&lt;/code&gt; for each filetype you want to handle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can simply use the command &lt;code&gt;:make&lt;/code&gt; in the file you want to source or create a mapping like &lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :make&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some related help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27makeprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'makeprg'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3amake&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :make&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/usr_05.txt.html#ftplugins&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ftplugins&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%3asetlocal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :setlocal&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-03-12T08:42:37.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15527" PostTypeId="2" ParentId="15523" CreationDate="2018-03-12T08:52:49.090" Score="2" Body="&lt;p&gt;It looks like some escape sequence got you into &lt;code&gt;:i&lt;/code&gt; insert mode. Try to exit by typing &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; + &lt;code&gt;.&lt;/code&gt; + &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; (a single dot on a blank line followed by enter).&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2018-03-12T08:52:49.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15529" PostTypeId="1" CreationDate="2018-03-12T09:43:35.057" Score="1" ViewCount="22" Body="&lt;p&gt;When I use tmux, I can hold &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;c&lt;/kbd&gt; and continue pressing any of the 4 arrow directions I want to resize a pane: I then see the pane of interest resizing while pressing and I stop when I get visually satisfied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I split the window in Vim, is there a similar in way to reproduce this behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest way I found for the moment is: &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;w&lt;/kbd&gt; + &lt;kbd&gt;&gt;&lt;/kbd&gt; (for example) but I have to re-press all these buttons over and over (while in tmux I just re-press the arrow direction and the pane resizes faster)&lt;/p&gt;&#xA;" OwnerUserId="10060" LastEditorUserId="343" LastEditDate="2018-03-12T09:55:17.980" LastActivityDate="2018-03-12T09:55:17.980" Title="Resize windows &quot;visually&quot;" Tags="|vim-windows|" AnswerCount="0" CommentCount="1" ClosedDate="2018-03-12T10:00:00.557" ContentLicense="CC BY-SA 3.0" />
  <row Id="15530" PostTypeId="2" ParentId="15525" CreationDate="2018-03-12T10:38:36.167" Score="3" Body="&lt;p&gt;&lt;em&gt;That's odd, I was quite sure this question was a duplicate, but I cannot find the other Q/A.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway. This is &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp/blob/master/plugin/homeLikeVC%2B%2B.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;how I proceed&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; &amp;lt;c-o&amp;gt;@=&amp;lt;SID&amp;gt;HomeLikeVCpp()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; @=&amp;lt;SID&amp;gt;HomeLikeVCpp()&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; @=&amp;lt;SID&amp;gt;HomeLikeVCpp()&amp;lt;cr&amp;gt;&#xA;&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;@=&amp;lt;SID&amp;gt;EndLikeVCpp()&amp;lt;cr&amp;gt;a&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt; @=&amp;lt;SID&amp;gt;EndLikeVCpp()&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt; @=&amp;lt;SID&amp;gt;EndLikeVCpp()&amp;lt;cr&amp;gt;&#xA;&#xA;function! s:HomeLikeVCpp()&#xA;  let ll = strpart(getline('.'), -1, col('.'))&#xA;  if ll =~ '^\s\+$' | return '0'&#xA;  else              | return '^'&#xA;  endif&#xA;endfunction&#xA;&#xA;&#xA;function! s:EndLikeVCpp()&#xA;  let l = strpart(getline('.'), col('.')-1)&#xA;  let ll = match(l, '^\S\s*$')&#xA;&#xA;  if getline('.') =~ '^\s*$'&#xA;    if col('.') + (mode()!='v') == col('$') | return 'g_'&#xA;    else                                    | return '$'&#xA;    endif&#xA;  else&#xA;    if ll &amp;gt;= 0 | return '$'&#xA;    else       | return 'g_'&#xA;    endif&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nowadays, I'd rewrite it with &lt;code&gt;:map-&amp;lt;expr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-03-12T10:38:36.167" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15531" PostTypeId="2" ParentId="15505" CreationDate="2018-03-12T14:36:30.560" Score="15" Body="&lt;p&gt;I'm not sure why the answer you linked to is accepted and so highly voted, because neither of the included solutions will actually work, and while a working solution is alluded to in the explanation, that solution still involves messing with the &lt;code&gt;'iskeyword'&lt;/code&gt; setting and everything that entails, which is neither necessary nor a good idea, just to fix this single issue with syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are three problems with the solution you've tried, which can be figured out by digesting the contents of the documentation at &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-contains&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :syn-contains&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-priority&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :syn-priority&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Problem 1: &lt;code&gt;contained&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The first problem is that you need your &lt;code&gt;myTodo&lt;/code&gt; item to be found &lt;em&gt;inside&lt;/em&gt; other syntax items, viz. comments. You might imagine that the &lt;code&gt;contained&lt;/code&gt; argument in the suggested &lt;code&gt;:syntax&lt;/code&gt; command achieves this, but that's not what that means: instead, the &lt;code&gt;contained&lt;/code&gt; keyword declares that your syntax item &lt;em&gt;cannot&lt;/em&gt; be found at the top level outside of other syntax items: it doesn't specify where it &lt;em&gt;can&lt;/em&gt; be found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to allow your &lt;code&gt;myTodo&lt;/code&gt; item to be found inside another syntax item, it must either be specifically listed in a &lt;code&gt;contains&lt;/code&gt; argument in that item's definition, or instead the &lt;code&gt;myTodo&lt;/code&gt; item must list the other item as a &lt;code&gt;containedin&lt;/code&gt; argument. The first of these is not practical&amp;mdash;the &quot;comment&quot; syntax item is defined elsewhere&amp;mdash; so we must instead use &lt;code&gt;containedin&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match myTodo /\v&amp;lt;(TODO|FIXME).*/ containedin=.*Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. I'm using a &quot;very-magic&quot; search to make the regular expression a bit easier to write/read. See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5Cv&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help \v&lt;/code&gt;&lt;/a&gt; for details.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will allow your &lt;code&gt;myTodo&lt;/code&gt; item to be contained within any syntax item that ends in &lt;code&gt;Comment&lt;/code&gt;. This isn't truly &quot;global&quot;, but it probably more closely matches what you want. If you really want this to match &lt;em&gt;anywhere&lt;/em&gt;, then you could instead use the special &lt;code&gt;ALL&lt;/code&gt; keyword described in &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-contains&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :syn-contains&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match myTodo /\v&amp;lt;(TODO|FIXME).*/ containedin=ALL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Problem 2: &lt;code&gt;keyword&lt;/code&gt; vs &lt;code&gt;match&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You will note that the above still doesn't actually work. This is because the &lt;em&gt;existing&lt;/em&gt; TODO highlighting takes precedence. This is generally implemented as a &lt;code&gt;keyword&lt;/code&gt;, and you will see in the list of priorities linked above that &lt;code&gt;keyword&lt;/code&gt;s take priority over &lt;code&gt;match&lt;/code&gt;es that begin at the same position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way to work around this is to make your match start &lt;em&gt;before&lt;/em&gt; the existing keyword, and then adjust the start of the highlighting accordingly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match myTodo /\v.&amp;lt;(TODO|FIXME).*/hs=s+1 containedin=.*Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(See &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-pattern-offset&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :syn-pattern-offset&lt;/code&gt;&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this will not work at the start of the line. If you need it to, then you could instead use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match myTodo /\v\_.&amp;lt;(TODO|FIXME).*/hs=s+1 containedin=.*Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(See &lt;a href=&quot;http://vimhelp.appspot.com/usr_27.txt.html#27.8&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 27.8&lt;/code&gt;&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;em&gt;still&lt;/em&gt; won't work if your TODO item begins at the very start of the file. If you need this, you're going to need to either: delete the existing&#xA;&quot;todo&quot; keyword syntax items with &lt;code&gt;:syntax clear&lt;/code&gt; commands, or use something a bit more complicated:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax keyword myTodo TODO FIXME nextgroup=myRestOfTodo&#xA;:syntax match myRestOfTodo /.*/ containedin=NONE contained&#xA;:highlight link myTodo Todo&#xA;:highlight link myRestOfTodo Todo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets up a &lt;code&gt;keyword&lt;/code&gt; item for todo items, and a match item that matches everything but can &lt;em&gt;only&lt;/em&gt; be found immediately following a &lt;code&gt;myTodo&lt;/code&gt; item.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(See &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-nextgroup&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :syn-nextgroup&lt;/code&gt;&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Problem 3: Where to put the commands&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;So now we have some commands that will work when run manually in a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a rule of thumb, Vim doesn't really care in what files you place your config. It's not true that syntax commands will only have an effect if they are in a &quot;syntax highlighting file&quot;, as you wonder in your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the reason for all the different locations within &lt;code&gt;.vim&lt;/code&gt; that you can place config is that the different files are loaded automatically by Vim at various different times, and in order for our code to work, we ideally want it to be run after the existing syntax has been set up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such, the simplest solution that will work globally is probably to use an autocommand in your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup myTodo&#xA;  autocmd!&#xA;  autocmd Syntax * syntax match myTodo /\v\_.&amp;lt;(TODO|FIXME).*/hs=s+1 containedin=.*Comment&#xA;augroup END&#xA;&#xA;highlight link myTodo Todo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you &lt;em&gt;were&lt;/em&gt; happy with setting up the matches specifically for each filetype, I'd recommend nixing the autocommand and instead placing the &lt;code&gt;:syntax&lt;/code&gt; commands within the relevant files in &lt;code&gt;.vim/after/syntax&lt;/code&gt;, e.g. &lt;code&gt;.vim/after/syntax/plaintex.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll leave it as an exercise to the reader to figure out how to alter the above to use instead the other solution that utilises &lt;code&gt;nextgroup&lt;/code&gt;. ;)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-12T15:08:43.210" LastActivityDate="2018-03-12T15:08:43.210" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15532" PostTypeId="1" CreationDate="2018-03-12T21:52:05.990" Score="0" ViewCount="31" Body="&lt;p&gt;For example, I need to type &lt;code&gt;(others =&amp;gt; '0')&lt;/code&gt; many times.&lt;br&gt;&#xA;Can I define &lt;code&gt;(others =&amp;gt; '0')&lt;/code&gt; as a keyword. If I type something like &lt;code&gt;other&lt;/code&gt; then &lt;code&gt;(others =&amp;gt; '0')&lt;/code&gt; will show in the selection menu.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-03-12T21:52:05.990" Title="YouCompleteMe: How to define special keyword?" Tags="|keyword|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15533" PostTypeId="1" AcceptedAnswerId="15534" CreationDate="2018-03-12T22:41:33.850" Score="0" ViewCount="211" Body="&lt;p&gt;I have two shell commands which I want to run. However I only want to run the second one if the first one was successful.&#xA;For simplicity let the commands be &lt;code&gt;ls&lt;/code&gt; and &lt;code&gt;ls&lt;/code&gt;.&#xA;I can call then once at a time manually, no problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:terminal ls&#xA;Home Documents ...&#xA;:terminal ls&#xA;Home Documents ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I combine them, it breaks completely.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:terminal ls &amp;amp;&amp;amp; ls&#xA;ls: cannot access '&amp;amp;&amp;amp;': No such file or directory&#xA;ls: cannot access 'ls': No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the buffer name it looks like it is calling &lt;code&gt;:!ls &amp;amp;&amp;amp; ls&lt;/code&gt; as it should.&#xA;However &lt;code&gt;!ls &amp;amp;&amp;amp; ls&lt;/code&gt; gives the desired result for me, and &lt;code&gt;:terminal ls &amp;amp;&amp;amp; ls&lt;/code&gt; doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody explain this?&lt;/p&gt;&#xA;" OwnerUserId="7877" LastActivityDate="2018-03-12T22:59:24.080" Title="Combining shell commands with :terminal" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15534" PostTypeId="2" ParentId="15533" CreationDate="2018-03-12T22:59:24.080" Score="2" Body="&lt;p&gt;you need a shell to parse &amp;amp;&amp;amp;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;try &lt;code&gt;:terminal bash -c &quot;ls &amp;amp;&amp;amp; ls&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;without a shell &lt;code&gt;ls&lt;/code&gt; will see all the arguments, including &amp;amp;&amp;amp; and ls and will hence fail&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-03-12T22:59:24.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15535" PostTypeId="1" CreationDate="2018-03-13T03:16:28.097" Score="0" ViewCount="3098" Body="&lt;pre&gt;&lt;code&gt;NVIM v0.2.2&#xA;Build type: Release&#xA;LuaJIT 2.0.5&#xA;Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -I/tmp/neovim-20180209-92407-udkzoo/neovim-0.2.2/build/config -I/tmp/neovim-20180209-92407-udkzoo/neovim-0.2.2/src -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/opt/gettext/include -I/usr/include -I/tmp/neovim-20180209-92407-udkzoo/neovim-0.2.2/build/src/nvim/auto -I/tmp/neovim-20180209-92407-udkzoo/neovim-0.2.2/build/include&#xA;Compiled by brew@HighSierra.local&#xA;&#xA;Features: +acl +iconv +jemalloc +tui&#xA;See &quot;:help feature-compile&quot;&#xA;&#xA;   system vimrc file: &quot;$VIM/sysinit.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/Cellar/neovim/0.2.2_1/share/nvim&quot;&#xA;&#xA;Run :checkhealth for more info&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After running some git commands with fugitive, the cursor is placed at the end, for e.g:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;[Process Exited 0]_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I just need to press enter to back to the previous buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do the same, the cursor is placed at the beginning and I have to type &lt;code&gt;:bd(!)&lt;/code&gt; to close that buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What caused this? How to back to previous behaviour?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;init.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set backup&#xA;let day = strftime(&quot;%Y-%m-%d&quot;)&#xA;let user = substitute(system('whoami'), '\n', '', '')&#xA;if user == 'root'&#xA;    let backupdir = &quot;/var/root/.vim/backup/&quot;.day&#xA;else&#xA;    let backupdir = $HOME.&quot;/.vim/backup/&quot;.day&#xA;endif&#xA;silent! let xyz = mkdir(backupdir, &quot;p&quot;)&#xA;let cmd = &quot;set backupdir=&quot;.backupdir&#xA;execute cmd&#xA;let time = strftime(&quot;.%H:%M:%S&quot;)&#xA;let cmd = &quot;set backupext=&quot;.time&#xA;execute cmd&#xA;&#xA;syntax on&#xA;set number&#xA;set background=dark&#xA;let g:solarized_termcolors = 256&#xA;let g:solarized_visibility = &quot;high&quot;&#xA;let g:solarized_contrast = &quot;high&quot;&#xA;let g:solarized_termtrans = 1&#xA;colorscheme solarized&#xA;&#xA;autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab&#xA;&#xA;set clipboard=unnamed&#xA;execute pathogen#infect()&#xA;let g:SuperTabDefaultCompletionType = &quot;context&quot;&#xA;&#xA;filetype off&#xA;&#xA;set nocompatible&#xA;filetype plugin indent on&#xA;autocmd BufRead,BufNewFile *.jinja2 set filetype=jinja&#xA;&#xA;nnoremap &amp;lt;F6&amp;gt; :GundoToggle&amp;lt;CR&amp;gt;&#xA;&#xA;au BufNewFile *.jinja2 so ~/.vim/header/jinja_header.txt&#xA;au BufNewFile *.py so ~/.vim/header/py_header.txt&#xA;au BufNewFile *.sls so ~/.vim/header/sls_header.txt&#xA;&#xA;let mapleader = &quot;\&amp;lt;Space&amp;gt;&quot;&#xA;nnoremap &amp;lt;Leader&amp;gt;o :CtrlP&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;w :w&amp;lt;CR&amp;gt;&#xA;vmap &amp;lt;Leader&amp;gt;y &quot;+y&#xA;vmap &amp;lt;Leader&amp;gt;d &quot;+d&#xA;nmap &amp;lt;Leader&amp;gt;p &quot;+p&#xA;nmap &amp;lt;Leader&amp;gt;P &quot;+P&#xA;vmap &amp;lt;Leader&amp;gt;p &quot;+p&#xA;vmap &amp;lt;Leader&amp;gt;P &quot;+P&#xA;nmap &amp;lt;Leader&amp;gt;&amp;lt;Leader&amp;gt; V&#xA;&#xA;vmap v &amp;lt;Plug&amp;gt;(expand_region_expand)&#xA;vmap &amp;lt;C-v&amp;gt; &amp;lt;Plug&amp;gt;(expand_region_shrink)&#xA;&#xA;&quot; highlight excess line length (79)&#xA;autocmd Filetype py rst textwidth=79&#xA;set colorcolumn=+1&#xA;&#xA;&quot; disable folding&#xA;set nofoldenable&#xA;&quot; end of disable folding&#xA;&#xA;autocmd filetype crontab setlocal nobackup nowritebackup&#xA;&#xA;let g:vim_json_syntax_conceal = 0&#xA;&#xA;let g:ranger_map_keys = 0&#xA;&#xA;set hidden&#xA;:nnoremap &amp;lt;Tab&amp;gt; :bnext&amp;lt;CR&amp;gt;&#xA;:nnoremap &amp;lt;S-Tab&amp;gt; :bprevious&amp;lt;CR&amp;gt;&#xA;&#xA;set completeopt=longest,menuone&#xA;&#xA;for fpath in split(globpath('~/.vimrc.d/', '*.vim'), '\n')&#xA;  exe 'source' fpath&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16690" LastEditorUserId="16690" LastEditDate="2018-03-13T09:56:53.810" LastActivityDate="2018-09-24T00:28:10.983" Title="neovim: how to close the terminal buffer by just pressing enter?" Tags="|neovim|buffers|plugin-fugitive|terminal-buffer|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15536" PostTypeId="1" CreationDate="2018-03-13T08:38:53.343" Score="1" ViewCount="112" Body="&lt;p&gt;I know that I can print whole path by &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt; &lt;kbd&gt;=&lt;/kbd&gt; &lt;code&gt;expand('%:p')&lt;/code&gt; in insert mode. I can also print head/tail with &lt;code&gt;expand('%:h')&lt;/code&gt;, &lt;code&gt;expand('%:t')&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to print the filename with it's parent directory. Like if the full path was &#xA;&lt;code&gt;/home/torsho/maalamaal/src/maalamaal/urls.py&lt;/code&gt; it would insert &lt;code&gt;maalamaal/urls.py&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13695" LastEditorUserId="1841" LastEditDate="2018-03-13T08:56:59.077" LastActivityDate="2018-03-13T12:44:26.687" Title="How to print the filename with parent directory in insert mode?" Tags="|insert-mode|filesystem|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15537" PostTypeId="2" ParentId="15536" CreationDate="2018-03-13T08:58:53.907" Score="1" Body="&lt;p&gt;You can have a look at &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#filename-modifiers&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h filename-modifiers&lt;/code&gt;&lt;/a&gt;&#xA;for a list of the modifiers you can use with &lt;code&gt;expand()&lt;/code&gt;. A possible solution is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expand('%:p:s?.*/\(.*/\)/?\1?')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses the full path modifier &lt;code&gt;:p&lt;/code&gt; and then the substitution modifier &lt;code&gt;:s&lt;/code&gt; to keep only the last directory in the path and the filename + extension.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-03-13T09:07:51.497" LastActivityDate="2018-03-13T09:07:51.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15538" PostTypeId="1" AcceptedAnswerId="15544" CreationDate="2018-03-13T09:03:16.923" Score="1" ViewCount="265" Body="&lt;p&gt;Neovim assigns a file type of &quot;conf&quot; to SConscruct and SConscript files -- aka the scons configuration scripts. This is wrong. It should be Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried adding: &lt;code&gt;au BufNewFile,BufRead SCons* setf python&lt;/code&gt; to my &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt; yet the file type remains set at &quot;conf&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did try it on vim and it worked fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="622" LastEditorUserId="622" LastEditDate="2018-03-13T12:55:38.300" LastActivityDate="2018-03-14T12:10:36.193" Title="Scons files not recognised as Python but as conf" Tags="|neovim|filetype|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15540" PostTypeId="1" AcceptedAnswerId="15543" CreationDate="2018-03-13T12:35:08.583" Score="1" ViewCount="43" Body="&lt;p&gt;Is it possible to define mappings that only get active when a certain &lt;code&gt;spelllang&lt;/code&gt; is set?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. I want to set the following mapping, but only if I use &lt;code&gt;spelllang=de&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap oe ö&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7877" LastActivityDate="2018-03-13T12:46:03.470" Title="Spellllang dependent key mapping" Tags="|key-bindings|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15541" PostTypeId="2" ParentId="15536" CreationDate="2018-03-13T12:36:46.580" Score="2" Body="&lt;p&gt;You can use multiple modifiers in a single call to expand, so you can find the parent directory by asking for the tail of the head.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expand('%:h:t') . '/' . expand('%:t')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need to do this frequently, you could perhaps use a mapping so you don't have to type it in all the time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;F5&amp;gt; &amp;lt;C-R&amp;gt;=expand('%:h:t') . '/' . expand('%:t')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want it to use a backslash as the path separator on Windows, you can check the operating system with &lt;code&gt;has()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;F5&amp;gt; &amp;lt;C-R&amp;gt;=expand('%:h:t') . (has('win32') ? '\' : '/') . expand('%:t')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-13T12:44:26.687" LastActivityDate="2018-03-13T12:44:26.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15542" PostTypeId="1" AcceptedAnswerId="15569" CreationDate="2018-03-13T12:38:44.150" Score="0" ViewCount="272" Body="&lt;p&gt;Recently insert position becomes strange.&lt;br&gt;&#xA;&lt;kbd&gt;i&lt;/kbd&gt; can change insert position. Sometimes insert to the left of current cursor, sometimes to the right.&lt;br&gt;&#xA;Caps is not activated. VIM 8.0 1-586&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2023-02-27T15:01:20.147" Title="Insert position" Tags="|insert-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15543" PostTypeId="2" ParentId="15540" CreationDate="2018-03-13T12:40:00.767" Score="4" Body="&lt;p&gt;You can use a conditionnal mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; oe ( &amp;amp;spelllang == &quot;de&quot; ) ? &quot;ö&quot; : &quot;oe&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; specified Vim knows that when it sees &lt;code&gt;oe&lt;/code&gt; as an input it should execute the rest of the mapping as a vimscript expression and map &lt;code&gt;oe&lt;/code&gt; to the result of this expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the expression is a conditionnal operator: if &lt;code&gt;&amp;amp;spelllang == &quot;de&quot;&lt;/code&gt; is true then return &lt;code&gt;ö&lt;/code&gt; otherwise return &lt;code&gt;oe&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3amap-%3cexpr%3e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :map-&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-03-13T12:46:03.470" LastActivityDate="2018-03-13T12:46:03.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15544" PostTypeId="2" ParentId="15538" CreationDate="2018-03-13T13:13:37.267" Score="3" Body="&lt;p&gt;There are a couple of problems here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, you are using the &lt;code&gt;:setfiletype&lt;/code&gt; command, which only sets the &lt;code&gt;'filetype'&lt;/code&gt; if it has not already been set. (See &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%3Asetfiletype&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :setfiletype&lt;/code&gt;&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you change your autocommand to set the &lt;code&gt;'filetype'&lt;/code&gt; directly with &lt;code&gt;:set filetype=python&lt;/code&gt;, this will result in the &lt;code&gt;python&lt;/code&gt; filetype being used, as you desire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this still isn't perfect, because now Vim is first setting the &lt;code&gt;'filetype'&lt;/code&gt; to &lt;code&gt;conf&lt;/code&gt; (based on its contents) and then &lt;em&gt;changing&lt;/em&gt; it to &lt;code&gt;python&lt;/code&gt;, and it's possible that some options are set for &lt;code&gt;conf&lt;/code&gt; files that you do not want in &lt;code&gt;python&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid this, follow the instructions in section &lt;strong&gt;C&lt;/strong&gt; of &lt;a href=&quot;http://vimhelp.appspot.com/filetype.txt.html#new-filetype&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help new-filetype&lt;/code&gt;&lt;/a&gt; to detect this filetype &lt;em&gt;before&lt;/em&gt; the installed detection runs by creating a &lt;code&gt;.vim/filetype.vim&lt;/code&gt; file with the following contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; my filetype file&#xA;if exists(&quot;did_load_filetypes&quot;)&#xA;  finish&#xA;endif&#xA;augroup filetypedetect&#xA;  autocmd! BufRead,BufNewFile SCons* setfiletype python&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd also note that it's not really a &lt;em&gt;bug&lt;/em&gt; that Vim is using a &lt;code&gt;'filetype'&lt;/code&gt; of &lt;code&gt;conf&lt;/code&gt; here. Vim's runtime files set a large number of types automatically, but they cannot automatically set the types of &lt;em&gt;all&lt;/em&gt; files, now and in the future. This is why the mechanisms described in the documentation linked to above exist: to allow you to add &lt;code&gt;filetype&lt;/code&gt; detection for currently unsupported files as necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is of course, reasonable to suggest that it be added as a feature request: hopefully automatic detection of SCons files will be added in future versions!&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-14T12:10:36.193" LastActivityDate="2018-03-14T12:10:36.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15545" PostTypeId="1" AcceptedAnswerId="15546" CreationDate="2018-03-13T13:48:25.303" Score="2" ViewCount="93" Body="&lt;p&gt;I find myself more then once doing this repetitive thing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;do amount_foo blah_blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need to copy this n times, but change the &lt;code&gt;foo&lt;/code&gt; part. I copy and paste it as many times as needed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;do amount_foo blah_blah&#xA;do amount_foo blah_blah&#xA;do amount_foo blah_blah&#xA;do amount_foo blah_blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then a replace on one and one line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/foo/bar&#xA;:'&amp;lt;,'&amp;gt;s/foo/baz&#xA;:'&amp;lt;,'&amp;gt;s/foo/lot&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;do amount_foo blah_blah&#xA;do amount_bar blah_blah&#xA;do amount_baz blah_blah&#xA;do amount_lot blah_blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a quicker way to do the same? Is there for example a way to pass a list to replace so that one could do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/foo/\=some_magic bar, baz, lot&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Easy enough to write a function for it, but there is perhaps a better way to do this natively?&lt;/p&gt;&#xA;" OwnerUserId="16695" LastActivityDate="2018-03-13T14:10:32.843" Title="Replace same match with squential list" Tags="|replace|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15546" PostTypeId="2" ParentId="15545" CreationDate="2018-03-13T14:10:32.843" Score="4" Body="&lt;p&gt;You are correct you can use a sub-replace-expression, &lt;code&gt;\=&lt;/code&gt;, to do the list manipulation and replacement.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let a = ['foo', 'bar', 'baz']&#xA;:%s/amount_\zsfoo/\=add(a, remove(a, 0))[-1]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &quot;rotates&quot; the array, &lt;code&gt;a&lt;/code&gt;, in-place  and uses the last position of the array as the value for the replacement of the substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :s&#xA;:h range&#xA;:h /\zs&#xA;:h :s\=&#xA;:h reverse(&#xA;:h :s_flags&#xA;:h Lists&#xA;:h add(&#xA;:h remove&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-03-13T14:10:32.843" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15547" PostTypeId="2" ParentId="15538" CreationDate="2018-03-13T17:35:28.200" Score="1" Body="&lt;p&gt;Put a file this content into your &lt;code&gt;.vim/ftdetect&lt;/code&gt; folder, I name it scons.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead,BufNewFile SCons{truct,cript} set filetype=python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://bitbucket.org/plunket/dotfiles/src/1dc45bcec068220b7df2079b9c1e3b07fd76048f/vim/ftdetect/scons.vim?at=master&amp;amp;fileviewer=file-view-default&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://bitbucket.org/plunket/dotfiles/src/1dc45bcec068220b7df2079b9c1e3b07fd76048f/vim/ftdetect/scons.vim?at=master&amp;amp;fileviewer=file-view-default&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6430" LastActivityDate="2018-03-13T17:35:28.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15548" PostTypeId="2" ParentId="12794" CreationDate="2018-03-13T18:27:18.323" Score="161" Body="&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;br /&gt;&#xA;&lt;br /&gt;&#xA;You can use your existing &lt;code&gt;~/.vimrc&lt;/code&gt;, files, and plugins located within &lt;code&gt;~/.vim&lt;/code&gt; without having to symlink the files.&lt;/p&gt;&#xA;&lt;p&gt;And this is now documented in NeoVim manual, see &lt;a href=&quot;https://neovim.io/doc/user/nvim.html#nvim-from-vim&quot; rel=&quot;noreferrer&quot;&gt;Transitioning from Vim&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For Linux and macOS, just add below lines to the top of your &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt;, or &lt;code&gt;%LOCALAPPDATA%\nvim\init.vim&lt;/code&gt; for Windows.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath^=~/.vim runtimepath+=~/.vim/after&#xA;let &amp;amp;packpath=&amp;amp;runtimepath&#xA;source ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The above lines will add the existing paths and &lt;code&gt;~/.vimrc&lt;/code&gt; file to your nvim setup.&lt;/p&gt;&#xA;&lt;p&gt;Credit goes to  &lt;a href=&quot;http://vimcasts.org/episodes/meet-neovim/&quot; rel=&quot;noreferrer&quot;&gt;vimcast 71 : Meet Neovim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10550" LastEditorUserId="22375" LastEditDate="2020-10-05T07:04:50.043" LastActivityDate="2020-10-05T07:04:50.043" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="15550" PostTypeId="1" CreationDate="2018-03-13T18:43:21.460" Score="2" ViewCount="962" Body="&lt;p&gt;I recently was doing some Vim editing and noticed the behavior was very different for two important keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only difference I made was I started bash using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;env -i bash --init-script ~/.bashrc.custom.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use &lt;kbd&gt;home&lt;/kbd&gt;, &lt;kbd&gt;end&lt;/kbd&gt; to move the cursor around in &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But instead of &lt;kbd&gt;home&lt;/kbd&gt;, &lt;kbd&gt;end&lt;/kbd&gt; moving the cursor... pressing these keys would enter &lt;code&gt;vim&lt;/code&gt;'s insert mode and output 'H' and 'F' characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want the old behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I start &lt;code&gt;bash&lt;/code&gt; normally I get the old behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do you fix the &lt;kbd&gt;home&lt;/kbd&gt;, &lt;kbd&gt;end&lt;/kbd&gt; keys producing 'H' and 'F'?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1894" LastEditorUserId="51" LastEditDate="2018-09-09T23:54:26.773" LastActivityDate="2020-01-03T03:03:05.360" Title="How do you fix the Home and End keys producing 'H' and 'F'?" Tags="|terminal|environment-variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15551" PostTypeId="2" ParentId="15550" CreationDate="2018-03-13T18:43:21.460" Score="1" Body="&lt;p&gt;&lt;strong&gt;Make sure the environment variable &lt;code&gt;TERM&lt;/code&gt; is set. For example set the environment variable from &lt;code&gt;bash&lt;/code&gt; via &lt;code&gt;export TERM=xterm&lt;/code&gt; THEN open &lt;code&gt;vim&lt;/code&gt;. Once in &lt;code&gt;vim&lt;/code&gt; you can check that it worked by doing &lt;code&gt;set term&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Apparently &lt;code&gt;vim&lt;/code&gt; checks the environment variable &lt;code&gt;TERM&lt;/code&gt; to decide what how to handle terminal control characters (more info on &lt;code&gt;vim&lt;/code&gt; handling terminal control characters open &lt;code&gt;vim&lt;/code&gt; help by doing &lt;code&gt;vim&lt;/code&gt; command &lt;code&gt;help term&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was missing the &lt;code&gt;TERM&lt;/code&gt; variable, &lt;code&gt;vim&lt;/code&gt; would use the default and &lt;code&gt;set term=ansi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for my situation I made sure set the &lt;code&gt;TERM&lt;/code&gt; environment variable was set (in my ~/.bashrc.custom.sh).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set the value of &lt;code&gt;export TERM=xterm&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when I open &lt;code&gt;vim&lt;/code&gt; the value of &lt;code&gt;set term&lt;/code&gt; is &lt;code&gt;xterm&lt;/code&gt; and I get the expected behavior from &lt;kbd&gt;home&lt;/kbd&gt;, &lt;kbd&gt;end&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1894" LastActivityDate="2018-03-13T18:43:21.460" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15552" PostTypeId="1" CreationDate="2018-03-13T19:25:13.890" Score="2" ViewCount="1853" Body="&lt;p&gt;Could somebody explain me what happens here? I want to get my plugin update the airline at the &lt;code&gt;MpcAdd&lt;/code&gt; function call. Yet, no calls seem to work from inside the function. The &lt;code&gt;MpcAdd&lt;/code&gt; function call is triggered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If I  was to write the &lt;code&gt;qwe&lt;/code&gt; line immediately after the &lt;code&gt;asd&lt;/code&gt; line, &lt;code&gt;qwe&lt;/code&gt; would show up)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:RefreshAirline(text)&#xA;    call airline#parts#define('andrew', {'text': a:text})&#xA;    let g:airline_section_b = airline#section#create(['andrew'])&#xA;endfunction&#xA;&#xA;call s:RefreshAirline(&quot;asd&quot;)&#xA;&#xA;function! s:MpcAdd(line)&#xA;    let l:file = split(a:line)[0]&#xA;    call s:RefreshAirline(&quot;qwe&quot;)  &amp;lt;--- does not work here&#xA;    silent execute &quot;:redraw!&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16700" LastActivityDate="2018-03-13T19:25:13.890" Title="Calling vimscript functions from inside functions?" Tags="|vimscript|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15553" PostTypeId="2" ParentId="15525" CreationDate="2018-03-13T20:13:14.537" Score="0" Body="&lt;p&gt;Thanks everybody for their pointers. Here is my solution, in case it's helpful to someone:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Enhanced Home and End keys                           &#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; &amp;lt;c-o&amp;gt;@=&amp;lt;SID&amp;gt;ExtHome()&amp;lt;cr&amp;gt;i    &#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; @=&amp;lt;SID&amp;gt;ExtHome()&amp;lt;cr&amp;gt;          &#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; @=&amp;lt;SID&amp;gt;ExtHome()&amp;lt;cr&amp;gt;          &#xA;&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;@=&amp;lt;SID&amp;gt;ExtEnd()&amp;lt;cr&amp;gt;a &#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt; @=&amp;lt;SID&amp;gt;ExtEnd()&amp;lt;cr&amp;gt;            &#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt; @=&amp;lt;SID&amp;gt;ExtEnd()&amp;lt;cr&amp;gt;            &#xA;&#xA;function! s:ExtHome()                                  &#xA;   if col('.')=='1'  | return 'j'                      &#xA;   else              | return '0'                      &#xA;   endif                                               &#xA;endfunction                                            &#xA;&#xA;function! s:ExtEnd()                                   &#xA;   if strlen(getline('.')) == 0            | return 'j'&#xA;   elseif strlen(getline('.')) == col('.') | return 'j'&#xA;   else                                    | return '$'&#xA;   endif                                               &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16675" LastEditorUserId="16675" LastEditDate="2018-03-13T20:35:32.060" LastActivityDate="2018-03-13T20:35:32.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15554" PostTypeId="1" AcceptedAnswerId="15564" CreationDate="2018-03-13T22:41:36.213" Score="4" ViewCount="1827" Body="&lt;p&gt;I'm setting up a vim environment install script. I'm using vim-plug for plugin management.&lt;br&gt;&#xA;What I'd like to do is, from the install.sh, run vim and call PlugInstall to&#xA; trigger plugin download and install.&lt;br&gt;&#xA;The plugin file is set up to also set plugin-specific settings, so creates errors&#xA;relating to undefined variables when the plugins aren't installed (i.e., the&#xA;first time it starts up.) This requires user input of enter to bypass.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, the process would display the PlugInstall window and require no user &#xA;input, without showing plugin error messages.&lt;br&gt;&#xA;Second-best would be this, but the&#xA;error messages are still seen (still without requiring input).&lt;br&gt;&#xA;3rd best would be to have no output, but quietly wait until the plugins are, in&#xA;fact, installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are the commands I've tried so far, with their results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Command runs with no error, but also doesn't actually do anything:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;PlugInstall&quot; | vim -es&#xA;echo &quot;PlugInstall|qa!&quot; | vim -E&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Plugin errors, enter ex then get stuck (treats arg as filename):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -ecs PlugInstall\|qa!&#xA;vim -ec silent PlugInstall\|qa!&#xA;vim -ec silent exec PlugInstall\|qa!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;Error reading input&quot;. Still get plugin errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;:PlugInstall&quot; | vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Plugin errors requiring enter to continue, then works as desired:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c PlugInstall\|qa!&#xA;vim +PlugInstall! +qa!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: Further experimentation managed to get a chimera working. This satisfies second-best outcome. However, it ruins the shell session: input doesn't show up, and the prompt is seriously misaligned.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf &quot;\n&quot; | vim -c PlugInstall\|qa!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: &lt;code&gt;vim -E +PlugInstall +qall&lt;/code&gt; (mentioned in comments below) satisfies criteria 2&lt;/p&gt;&#xA;" OwnerUserId="16419" LastEditorUserId="16419" LastEditDate="2020-06-14T03:25:48.473" LastActivityDate="2020-06-14T03:25:48.473" Title="Call vim command from shell, and suppress output while it operates" Tags="|command-line|plugin-system|ex-mode|invocation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15555" PostTypeId="1" AcceptedAnswerId="15557" CreationDate="2018-03-13T23:34:59.787" Score="3" ViewCount="1307" Body="&lt;p&gt;I like to indent my shell scripts with two spaces instead of a TAB. So, I set &lt;code&gt;setlocal shiftwidth=2&lt;/code&gt; in &lt;code&gt;~/.vim/after/ftplugin/sh.vim&lt;/code&gt;. It works, but I noticed that when the indentation level gets greater than 8 spaces, Vim replaces them with a tab. So, I also added &quot;setlocal expandtab&quot; in this file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this replaces &lt;em&gt;all&lt;/em&gt; tabs by 8 spaces, even the ones inserted when I press the TAB key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking for suitable settings to &lt;em&gt;always&lt;/em&gt; have indentation (automatic or manual) composed of spaces only, but still insert a real tab when I press the TAB key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On other Q&amp;amp;A, I found functions to toggle between spaces and tabs, but I'm looking for a solution which doesn't involve any kind of toggling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Likewise, sticking with &lt;code&gt;shiftwidth&lt;/code&gt; only and use &lt;code&gt;:retab&lt;/code&gt; from time to time after momentarily enabling &lt;code&gt;expandtab&lt;/code&gt; would not be a suitable solution (let alone the fact that since tabs and spaces are indistinguishable on screen, I wouldn't know when a file needs to be &quot;retabbed&quot;).&lt;/p&gt;&#xA;" OwnerUserId="16704" LastActivityDate="2018-03-14T00:34:54.360" Title="Auto-indent with spaces, but insert TAB when I press the TAB key" Tags="|indentation|tab-characters|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15556" PostTypeId="2" ParentId="15535" CreationDate="2018-03-14T00:18:23.567" Score="3" Body="&lt;p&gt;From version 0.2.1, &lt;code&gt;:terminal&lt;/code&gt; now starts in normal mode instead of terminal mode: &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Following-HEAD#20170821&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neovim/neovim/wiki/Following-HEAD#20170821&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Btw, don't know why this does not enter Terminal mode automatically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter term://* startinsert&#xA;autocmd BufLeave term://* stopinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd TermOpen * startinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16690" LastActivityDate="2018-03-14T00:18:23.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15557" PostTypeId="2" ParentId="15555" CreationDate="2018-03-14T00:34:54.360" Score="5" Body="&lt;p&gt;You can always type a literal tab using &lt;code&gt;&amp;lt;c-v&amp;gt;&amp;lt;tab&amp;gt;&lt;/code&gt;.  Thus, you can &lt;code&gt;set expandtab&lt;/code&gt; to always keep indent spaces, and use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;tab&amp;gt; &amp;lt;c-v&amp;gt;&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to always insert a tab character when pressing the tab key.  You should not use &lt;code&gt;:retab&lt;/code&gt; at all in this case, since it will convert your tabs into spaces.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-03-14T00:34:54.360" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15559" PostTypeId="1" CreationDate="2018-03-14T07:06:50.870" Score="0" ViewCount="276" Body="&lt;p&gt;I have followed your post and used &lt;code&gt;:%s/\\u\(\x\{4\}\)/\=nr2char('0x'.submatch(1),1)/g&lt;/code&gt; to translate unicode escape sequences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I have to open the file and need to press escape and paste your command.  I wanted to write a bash script which will open a file and execute this command automatically. I tried doing this as shown in below but its not working..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;script.sh:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# usage bash script.sh file1.csv&#xA;#!/bin/bash&#xA;cat $1 :%s/\\u\(\x\{4\}\)/\=nr2char('0x'.submatch(1),1)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you please help how to write a bash script to open a file and do this translation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="16708" LastEditorUserId="343" LastEditDate="2018-03-14T11:27:54.900" LastActivityDate="2018-03-14T11:35:23.537" Title="bash script to open file and translate text" Tags="|terminal|invocation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15560" PostTypeId="1" AcceptedAnswerId="15562" CreationDate="2018-03-14T08:25:31.827" Score="3" ViewCount="430" Body="&lt;p&gt;Suppose there is a particular plugin that I wanna tweak part of its functionality (and it is not under active development anymore), I'd like to test the modified version without pushing to my forked repo and &lt;code&gt;:PlugUpdate&lt;/code&gt;. (I use &lt;code&gt;vim-plug&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is a convenient way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. A simple example is that I would like to know the output of a (multiline) function which starts like &lt;code&gt;function! s:some_action()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14820" LastEditorUserId="343" LastEditDate="2018-03-14T11:21:11.017" LastActivityDate="2018-03-14T11:54:12.927" Title="What are suggested ways to modify a plugin that was installed by vim-plug?" Tags="|vimscript|plugin-vim-plug|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15561" PostTypeId="2" ParentId="15559" CreationDate="2018-03-14T11:19:41.687" Score="1" Body="&lt;p&gt;Your code doesn't work because you don't actually invoke Vim anywhere!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;vim -c '%s/\\u\(\x\{4\}\)/\=nr2char(&quot;0x&quot;.submatch(1),1)/g' -c &quot;wq&quot; &quot;$1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will open the file, run the command, save, and quit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#-c&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help -c&lt;/code&gt;&lt;/a&gt; for more details on how the Vim command works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I changed the quote characters used in your &lt;code&gt;:substitute&lt;/code&gt; command from single quotes to double quotes. This doesn't make any difference to this particular Vim string, and it makes it easier to include the command in the shell script, because you can then use a &lt;a href=&quot;https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;literal single quoted string&lt;/a&gt; and don't have to &lt;a href=&quot;https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html#Double-Quotes&quot; rel=&quot;nofollow noreferrer&quot;&gt;escape things&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you actually &lt;em&gt;needed&lt;/em&gt; to use single quotes in your Vim command, then you would need to &lt;a href=&quot;https://stackoverflow.com/questions/1250079/how-to-escape-single-quotes-within-single-quoted-strings&quot;&gt;go to further lengths&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-14T11:35:23.537" LastActivityDate="2018-03-14T11:35:23.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15562" PostTypeId="2" ParentId="15560" CreationDate="2018-03-14T11:52:03.917" Score="2" Body="&lt;p&gt;If you installed the plugin with &lt;code&gt;vim-plug&lt;/code&gt;, then all the files from the plugin will be located at &lt;code&gt;~/.vim/plugged/&amp;lt;NAME&amp;gt;&lt;/code&gt;. You can just modify these files, and test the changes (re-source the modified files or simply restart vim). This way you don't need to interact at all with &lt;code&gt;vim-plug&lt;/code&gt; or with the Github fork.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;~/.vim/plugged/&amp;lt;NAME&amp;gt;&lt;/code&gt; contains just a clone of a git repo, you can also do all things you know from git. E.g. create a new branch for the changes. Then you can simply swap between the original plugin and the modified one by &lt;code&gt;git checkout master&lt;/code&gt; / &lt;code&gt;git checkout new_feature&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="7877" LastEditorUserId="343" LastEditDate="2018-03-14T11:54:12.927" LastActivityDate="2018-03-14T11:54:12.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15564" PostTypeId="2" ParentId="15554" CreationDate="2018-03-14T13:14:58.817" Score="6" Body="&lt;p&gt;I successfully used this command in a non-interactive way, but you have to specify the file containing the &lt;code&gt;Plug&lt;/code&gt; calls:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -E -s -u &quot;$HOME/.vimrc&quot; +PlugInstall +qall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might want to read more on how silent mode works with &lt;code&gt;:help -s-ex&lt;/code&gt;, and maybe add the verbose argument (&lt;code&gt;-V&lt;/code&gt;) for debugging.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2018-03-14T13:14:58.817" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15565" PostTypeId="1" AcceptedAnswerId="15566" CreationDate="2018-03-14T13:52:50.767" Score="1" ViewCount="136" Body="&lt;p&gt;I hope someone can riddle me this one: I have set up the function below to have a slightly more fancy behavior of the End key, moving first to the end of the line, but if the cursor is already at the end of the line, moving to the end of the next line. This works just fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;@=&amp;lt;SID&amp;gt;ExtEnd()&amp;lt;cr&amp;gt;a&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt; @=&amp;lt;SID&amp;gt;ExtEnd()&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt; @=&amp;lt;SID&amp;gt;ExtEnd()&amp;lt;cr&amp;gt;&#xA;&#xA;function! s:ExtEnd()&#xA;   if strlen(getline('.')) == 0            | return 'j'&#xA;   elseif strlen(getline('.')) == col('.') | return 'j'&#xA;   else                                    | return '$'&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my issue: I wanted to make this even more fancy by checking if the cursor is in front of the first non-blank character on the line. If that is the case, I would have it move to the first non-blank character on the first press of End, then to the end of the line on the next, and finally to the end of the next line on the third. To achieve this, I need to figure out the position of the first non-blank character on the line. I didn't find a function to do that directly, so I thought of a slightly kludgy solution of saving my cursor position (&lt;code&gt;spos&lt;/code&gt;), jumping to the first non-blank character, saving that position (&lt;code&gt;fpos&lt;/code&gt;), and then jumping back to the original saved position. The resulting code looks like so (this isn't finished yet, the actual cursor motions defined within the &lt;code&gt;if&lt;/code&gt;-block are unchanged at this point):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:ExtEnd()&#xA;   let spos=getpos(&quot;.&quot;)&#xA;   normal! ^&#xA;   let fpos=getpos(&quot;.&quot;)&#xA;   call setpos(&quot;.&quot;, spos)&#xA;   if strlen(getline('.')) == 0            | return 'j'&#xA;   elseif strlen(getline('.')) == col('.') | return 'j'&#xA;   else                                    | return '$'&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In theory (well, &lt;em&gt;my&lt;/em&gt; theory anyway) the additional four lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   let spos=getpos(&quot;.&quot;)&#xA;   normal! ^&#xA;   let fpos=getpos(&quot;.&quot;)&#xA;   call setpos(&quot;.&quot;, spos)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should have no effect, but they do: Now my cursor goes to the end of the line on the first press of End, but then it will jump to the first non-blank character on the next line, which doesn't seem to make any sense at all to me. Even if those four lines should change the cursor position (which they shouldn't) that should not result in the downward motion of the cursor. It's almost like the code is not executed in the sequence given.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is going wrong here?&lt;/p&gt;&#xA;" OwnerUserId="16675" LastActivityDate="2018-03-14T15:02:06.030" Title="mystery cursor motion" Tags="|vimscript|cursor-motions|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15566" PostTypeId="2" ParentId="15565" CreationDate="2018-03-14T14:17:16.853" Score="2" Body="&lt;p&gt;You do save and restore the cursor position. However note, that when moving to the first non-blank character &lt;code&gt;^&lt;/code&gt;, you also set the desired column for the cursor (called curswant attribute). That one is not reset on your &lt;code&gt;setpos()&lt;/code&gt; call. Therefore, when your function returns &lt;code&gt;j&lt;/code&gt; to move down a line, it will move down &lt;strong&gt;and&lt;/strong&gt; to the desired column position (curswant).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prevent that, use the &lt;code&gt;getcurpos()&lt;/code&gt; function instead of &lt;code&gt;getpos()&lt;/code&gt; function, which additionally also stores the curswant attribute of the cursor. &lt;code&gt;getpos()&lt;/code&gt; can handle either a 4 member list (the traditional way, without the curswant attribute) or a 5 member list (including the curswant attribute). Those functions are quite new, the &lt;code&gt;getcurpos()&lt;/code&gt; function is only available in Vim 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also please note, that your function could possibly be written easier by makeing use of &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#:map-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;expression mappings&lt;/a&gt; (however, it does not allow &lt;code&gt;:norm&lt;/code&gt; commands).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-03-14T14:17:16.853" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15567" PostTypeId="2" ParentId="15565" CreationDate="2018-03-14T14:38:41.417" Score="1" Body="&lt;p&gt;Whilst I admire your kludge (not being sarcastic! I love that sort of workaround!) you actually can find the position of the first non-blank on the current line without moving the cursor about:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let first_non_blank = match(getline('.'), '\S')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the value it returns is zero-based, so if there are no spaces at the start of the line it will return &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-14T14:44:21.333" LastActivityDate="2018-03-14T14:44:21.333" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15568" PostTypeId="2" ParentId="15565" CreationDate="2018-03-14T14:40:13.563" Score="0" Body="&lt;p&gt;Just to complete this following the answers given by Christian, here is the complete function that does what I described in my original question:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:ExtEnd()&#xA;   let savedview=winsaveview()&#xA;   normal! ^&#xA;   let fnzcol=getpos(&quot;.&quot;)[2]&#xA;   call winrestview(savedview)&#xA;   if strlen(getline('.')) == 0            | return 'j'&#xA;   elseif getpos(&quot;.&quot;)[2] &amp;lt; fnzcol          | return '^'&#xA;   elseif strlen(getline('.')) == col('.') | return 'j'&#xA;   else                                    | return '$'&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With Rich's suggestion above, we have the more elegant version below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:ExtEnd()&#xA;   let fnzcol=match(getline('.'), '\S')&#xA;   if strlen(getline('.')) == 0            | return 'j'&#xA;   elseif getpos(&quot;.&quot;)[2] &amp;lt; fnzcol          | return '^'&#xA;   elseif strlen(getline('.')) == col('.') | return 'j'&#xA;   else                                    | return '$'&#xA;   endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16675" LastEditorUserId="16675" LastEditDate="2018-03-14T15:02:06.030" LastActivityDate="2018-03-14T15:02:06.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15569" PostTypeId="2" ParentId="15542" CreationDate="2018-03-14T16:22:49.993" Score="0" Body="&lt;p&gt;Thanks for the link below. Now this issue is solved.&lt;br&gt;&#xA;&lt;a href=&quot;http://vim.wikia.com/wiki/Prevent_escape_from_moving_the_cursor_one_character_to_the_left&quot; rel=&quot;nofollow noreferrer&quot;&gt;Prevent escape from moving the cursor one character to the left&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Cursor move to the left is the default behaviour. Although it's kinda &#xA;annoying to me.  &lt;/li&gt;&#xA;&lt;li&gt;Side effect of above link is after &lt;code&gt;a&lt;/code&gt; &lt;code&gt;Esc&lt;/code&gt;, cursor will keep moving to the right.&lt;/li&gt;&#xA;&lt;li&gt;Not sure why below two mapping will make &lt;code&gt;ctrl-a&lt;/code&gt; move cursor to the right.&lt;br&gt;&#xA;&lt;code&gt;map saveses :mksession! ~/bin/vim/session/default.ses&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;map loadses :source     ~/bin/vim/session/default.ses&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="13402" LastEditDate="2018-03-20T11:57:30.863" LastActivityDate="2018-03-20T11:57:30.863" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15571" PostTypeId="2" ParentId="13568" CreationDate="2018-03-14T21:31:36.173" Score="0" Body="&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're more than welcome to steal snippets from my  &lt;a href=&quot;https://github.com/ipatch/dotfiles&quot; rel=&quot;nofollow noreferrer&quot;&gt;bat belt&lt;/a&gt; if you'd like &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So I came across this same scenario a couple of days ago, and ended up watching this  &lt;a href=&quot;http://vimcasts.org/episodes/how-to-fold/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which lead me to putting the the following together,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/.vim/after/ftplugin/markdown/folding.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MarkdownFolds()&#xA;  let thisline = getline(v:lnum)&#xA;  if match(thisline, '^##') &amp;gt;= 0&#xA;    return &quot;&amp;gt;2&quot;&#xA;  elseif match(thisline, '^#') &amp;gt;= 0&#xA;    return &quot;&amp;gt;1&quot;&#xA;  else&#xA;    return &quot;=&quot;&#xA;  endif&#xA;endfunction&#xA;setlocal foldmethod=expr&#xA;setlocal foldexpr=MarkdownFolds()&#xA;&#xA;function! MarkdownFoldText()&#xA;  let foldsize = (v:foldend-v:foldstart)&#xA;  return getline(v:foldstart).' ('.foldsize.' lines)'&#xA;endfunction&#xA;setlocal foldtext=MarkdownFoldText()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but still relied on using the default key bindings for folding &lt;/p&gt;&#xA;&#xA;&lt;p&gt;so long story short I mapped the &lt;kbd&gt;tab&lt;/kbd&gt; key to toggle code folding with the below snippet in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; enable code folding&#xA;set foldmethod=syntax&#xA;&quot; NOTE: the below settings remember code folds on a per file basis&#xA;&quot; CREDIT:  https://github.com/d86leader/vim-config/blob/58b5ff43c268c74c5aa2e7f6e931167f6064c02f/vimrc#L412&#xA;&#xA;augroup autoview&#xA;  autocmd!&#xA;  autocmd BufWinLeave ?* call &amp;lt;SID&amp;gt;make_view()&#xA;  autocmd BufWinEnter ?* call &amp;lt;SID&amp;gt;load_view()&#xA;augroup END&#xA;fun! s:make_view() abort&#xA;  if @% != &quot;&quot; &amp;amp;&amp;amp; &amp;amp;foldmethod != 'diff'&#xA;    mkview!&#xA;  endif&#xA;endfun&#xA;fun! s:load_view() abort&#xA;  if @% != &quot;&quot;&#xA;    silent! loadview&#xA;  endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Disclaimer&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt; Make sure you create the appropriate directories to store the view files, so when you close a file / buffer (n)vim remembers to restore your previous code fold settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;cheers &lt;br /&gt;&#xA;Chris &lt;/p&gt;&#xA;" OwnerUserId="10550" LastActivityDate="2018-03-14T21:31:36.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15572" PostTypeId="2" ParentId="2614" CreationDate="2018-03-15T06:55:25.693" Score="1" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup escape_mapping&#xA;  autocmd TermResponse * nnoremap &amp;lt;Esc&amp;gt; :noh&amp;lt;CR&amp;gt;&amp;lt;esc&amp;gt;&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;cf &lt;a href=&quot;https://stackoverflow.com/a/16027716/400545&quot;&gt;https://stackoverflow.com/a/16027716/400545&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7318" LastActivityDate="2018-03-15T06:55:25.693" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15573" PostTypeId="1" AcceptedAnswerId="15586" CreationDate="2018-03-15T10:10:15.327" Score="2" ViewCount="303" Body="&lt;p&gt;Is there a way edit command line or search history?&#xA;I have read &lt;a href=&quot;https://vi.stackexchange.com/questions/7713/is-there-search-and-replace-history-in-vim&quot;&gt;Is there search and replace history in vim?&lt;/a&gt; and tried using q: to open the history and do changes there, but all it seems to be able to do is take an edited line, execute it and append it to the history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to do is just replace a line in history (in-place) without necessarily executing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use case: I try to create a plugin, that appends words under the cursor to the search (when the user presses a button). The most part is done by changing the @/ register. But I also want to update the original search command so that a user can actually find the command that would issue the modified search. I could simply re-execute the search, but then the history would get flooded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Buffer&lt;/em&gt;: This is some fine text in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;User enters&lt;/em&gt;: &quot;/some&quot;, the cursor goes to &quot;some&quot; and the last line in search history will contain &quot;/some&quot;. Then, the user moves the cursor to &quot;text&quot;, presses a certain key and text is added to the search term. So now, the search term would be &quot;/some\|text&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to change/overwrite the last line in search history to be &quot;/some\|text&quot;.&lt;/p&gt;&#xA;" OwnerUserId="16714" LastActivityDate="2018-03-15T16:50:54.310" Title="How to search and replace in the history" Tags="|search|replace|command-history|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15574" PostTypeId="1" AcceptedAnswerId="15577" CreationDate="2018-03-15T10:33:16.740" Score="0" ViewCount="1418" Body="&lt;p&gt;I try to do something similar to &lt;a href=&quot;https://vi.stackexchange.com/questions/8431/how-to-use-the-argument-of-a-vimscript-function-in-an-inner-python-function&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. I have a python script in a file &lt;code&gt;/tmp/testme.py&lt;/code&gt; which should do different things depending on what argum&#xA;ents are passed to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import vim&#xA;&#xA;currentline = int(vim.eval('line(&quot;.&quot;)'))&#xA;&#xA;if vim.argument == &quot;close&quot;: # quasi code here&#xA;    mylines = [ 'this is the script',&#xA;                'and I say good bye!' ]&#xA;else:&#xA;    mylines = [ 'this is the script',&#xA;                'and I say hello!' ]&#xA;&#xA;vim.current.buffer[currentline:currentline] = mylines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I intend to call it from vim with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py3f /tmp/testme.py &quot;close&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for the if branch or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py3f /tmp/testme.py &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for the else branch. Is there a way to pass arguments to scripts called with &lt;code&gt;pyf&lt;/code&gt; or &lt;code&gt;py3f&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The syntax I suggest above fails because &lt;code&gt;&quot;close&quot;&lt;/code&gt; is understood as second filename and vim tells me off&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E172: Only one file name allowed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FileNotFoundError: [Errno 2] No such file or directory: &quot;/tmp/testme.py 'close'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6044" LastActivityDate="2018-03-15T11:46:03.787" Title="passing arguments to pyfile/py3file function" Tags="|vimscript-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15575" PostTypeId="1" CreationDate="2018-03-15T11:38:38.903" Score="0" ViewCount="1692" Body="&lt;p&gt;I want to map &lt;code&gt;&amp;lt;M-h&amp;gt;&lt;/code&gt; to &lt;kbd&gt;&amp;larr;&lt;/kbd&gt; in insert mode. I add &lt;code&gt;imap &amp;lt;M-h&amp;gt; &amp;lt;Left&amp;gt;&lt;/code&gt; to .vimrc.&lt;br&gt;&#xA;But if I press &lt;code&gt;&amp;lt;M-h&amp;gt;&lt;/code&gt;, Help menu will pop up.&#xA;How to disable this and force &lt;code&gt;&amp;lt;M-h&amp;gt;&lt;/code&gt; to &lt;kbd&gt;&amp;larr;&lt;/kbd&gt; in insert mode?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/39UN4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/39UN4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="13402" LastEditDate="2018-03-15T14:04:16.083" LastActivityDate="2018-04-19T16:30:58.500" Title="How to disable Help menu in insert mode?" Tags="|key-bindings|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15576" PostTypeId="2" ParentId="15573" CreationDate="2018-03-15T11:45:25.523" Score="0" Body="&lt;p&gt;Vim stores both the command history and the search history and many other things like registers and jumplists in &lt;code&gt;~/.viminfo&lt;/code&gt;.&#xA;You can remove/edit entries from the history by deleting/changing the corresponing lines in the file.&lt;/p&gt;&#xA;" OwnerUserId="7877" LastActivityDate="2018-03-15T11:45:25.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15577" PostTypeId="2" ParentId="15574" CreationDate="2018-03-15T11:46:03.787" Score="1" Body="&lt;p&gt;&lt;code&gt;:help :pyfile&lt;/code&gt; describes the mechanism to pass arguments as such:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To pass arguments you need to set &lt;code&gt;sys.argv[]&lt;/code&gt; explicitly.  Example:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:python import sys&#xA;:python sys.argv = [&quot;foo&quot;, &quot;bar&quot;]&#xA;:pyfile myscript.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2018-03-15T11:46:03.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15578" PostTypeId="1" AcceptedAnswerId="15579" CreationDate="2018-03-15T12:59:55.050" Score="0" ViewCount="1546" Body="&lt;p&gt;I know how to create normal and command mappings, but I am trying to make a command that toggles between two states, (a) create 3 mappings and (b) reset them using unmap. How can I do this in my vimrc config?&lt;/p&gt;&#xA;" OwnerUserId="16379" LastActivityDate="2018-03-15T14:32:26.473" Title="How can I toggle multiple mappings on/off with a command?" Tags="|vimrc|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15579" PostTypeId="2" ParentId="15578" CreationDate="2018-03-15T13:18:36.183" Score="3" Body="&lt;p&gt;You can use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:mappingsState=1&#xA;&#xA;command! TM call ToggleMappings()&#xA;&#xA;function! ToggleMappings()&#xA;    if s:mappingsState&#xA;        nnoremap &amp;lt;F1&amp;gt; :echo &quot;mapping 1&quot;&amp;lt;CR&amp;gt;&#xA;        &quot; Or any mapping you want to create&#xA;    else&#xA;        unmap &amp;lt;F1&amp;gt;&#xA;        &quot; Or any key you want to unmap&#xA;    endif&#xA;&#xA;    let s:mappingsState = !s:mappingsState&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This create a variable which will keep track of the state of the mappings, a function which maps or unmaps the keys depending on this state and a command &lt;code&gt;:TM&lt;/code&gt; which calls the function.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-03-15T13:18:36.183" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15580" PostTypeId="2" ParentId="15483" CreationDate="2018-03-15T14:31:23.913" Score="5" Body="&lt;p&gt;&lt;code&gt;autocmd!&lt;/code&gt; at the top of .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html&quot; rel=&quot;noreferrer&quot;&gt;From the docs:&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When your .vimrc file is sourced twice, the autocommands will appear twice.&#xA;  To avoid this, put this command in your .vimrc file, before defining&#xA;  autocommands:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd!    &quot; Remove ALL autocommands for the current group.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you don't want to remove all autocommands, you can instead use a variable&#xA;  to ensure that Vim includes the autocommands only once:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:if !exists(&quot;autocommands_loaded&quot;)&#xA;:  let autocommands_loaded = 1&#xA;:  au ...&#xA;:endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: That's from the 7.4 docs. &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-define&quot; rel=&quot;noreferrer&quot;&gt;The 8.0 docs&lt;/a&gt; omit &lt;code&gt;autocmd!&lt;/code&gt; in favor of groups:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:autocmd adds to the list of autocommands regardless of whether they are&#xA;  already present.  When your .vimrc file is sourced twice, the autocommands&#xA;  will appear twice.  To avoid this, define your autocommands in a group, so&#xA;  that you can easily clear them: &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    augroup vimrc&#xA;      autocmd!      &quot; Remove all vimrc autocommands&#xA;      au BufNewFile,BufRead *.html so &amp;lt;sfile&amp;gt;:h/html.vim&#xA;    augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you don't want to remove all autocommands, you can instead use a variable&#xA;  to ensure that Vim includes the autocommands only once: &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    :if !exists(&quot;autocommands_loaded&quot;)&#xA;    :  let autocommands_loaded = 1&#xA;    :  au ...&#xA;    :endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9267" LastEditorUserId="9267" LastEditDate="2018-03-15T14:50:21.750" LastActivityDate="2018-03-15T14:50:21.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15581" PostTypeId="2" ParentId="15578" CreationDate="2018-03-15T14:32:26.473" Score="0" Body="&lt;p&gt;A long, long, time ago, I've published a &lt;a href=&quot;https://github.com/LucHermitte/lh-misc/blob/master/plugin/Triggers.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin aimed at toggling the state of various things&lt;/a&gt; (vim settings, mappings, abbreviations...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK it still works, but the code is old and quite cumbersome by vim7 standards -- yeah, vim 8 is out, and vim 8.1 not that far away. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use the (badly named) Trigger.vim plugin, &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;install first &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;my vim library plugin&lt;/a&gt; it depends upon, then drop &lt;code&gt;Trigger.vim&lt;/code&gt; into your &lt;code&gt;~/.vim/plugin/&lt;/code&gt; directory.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;then, the easier way consist in putting all your mappings in a function in a dedicated file &lt;code&gt;~/.vim/plugin/after/mymappings.vim&lt;/code&gt; for instance, and register the toggling with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; to put in plugin/mymappings.vim, &#xA;&quot; expecting the mappings are defined in the function FRabbrInit()&#xA;call Trigger_Function('&amp;lt;Plug&amp;gt;(do-toggle-fr-abbreviations)', 'FRabbrInit', expand('&amp;lt;sfile&amp;gt;:p'), 0, 0 )&#xA;&#xA;nmap &amp;lt;Plug&amp;gt;(toggle-fr-abbreviations) &amp;lt;Plug&amp;gt;(do-toggle-fr-abbreviations)&#xA;if !hasmapto('&amp;lt;Plug&amp;gt;(toggle-fr-abbreviations)', 'n')&#xA;    nmap &amp;lt;silent&amp;gt; &amp;lt;unique&amp;gt; &amp;lt;leader&amp;gt;tfa &amp;lt;Plug&amp;gt;(toggle-fr-abbreviations)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;See my &lt;a href=&quot;https://github.com/LucHermitte/lh-misc/blob/master/plugin/fr-abbr.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin/fr-abbr.vim&lt;/a&gt; plugin for a complete (and very old-school) example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Someday I should move these functions into an autoload plugin and simplify a few things.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-03-15T14:32:26.473" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15582" PostTypeId="1" AcceptedAnswerId="15583" CreationDate="2018-03-15T14:59:51.353" Score="1" ViewCount="153" Body="&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-define&quot; rel=&quot;nofollow noreferrer&quot;&gt;The docs say:&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;:autocmd&lt;/code&gt; adds to the list of autocommands regardless of whether they are&#xA;  already present.  When your .vimrc file is sourced twice, the autocommands&#xA;  will appear twice.  To avoid this, define your autocommands in a group, so&#xA;  that you can easily clear them: &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    augroup vimrc&#xA;      autocmd!      &quot; Remove all vimrc autocommands&#xA;      au BufNewFile,BufRead *.html so &amp;lt;sfile&amp;gt;:h/html.vim&#xA;    augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I put that in my .vimrc, I get an error when it's sourced:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E216: No such group or event: &quot; Remove all vimrc autocommands&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And it appears not to work. My autocommands run multiple times when I re-source .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remove the comment, it seems fine. So is there a bug with &lt;code&gt;autocmd!&lt;/code&gt; trying to parse comments? Or did I miss something?&lt;/p&gt;&#xA;" OwnerUserId="9267" LastActivityDate="2018-03-15T15:14:53.033" Title="autocmd! tries to parse comment" Tags="|autocmd|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15583" PostTypeId="2" ParentId="15582" CreationDate="2018-03-15T15:07:21.130" Score="3" Body="&lt;p&gt;You're correct that you cannot put a comment on the same line as that command, but it's not really a &lt;em&gt;bug&lt;/em&gt;. That's just how VimScript works: you can't put a comment in a place where it will be parsed as an argument. (See &lt;code&gt;:help :quote&lt;/code&gt; and the &lt;code&gt;COMMENTS&lt;/code&gt; section of &lt;code&gt;:help 41.10&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, it's not great that the documentation specifically recommends code that doesn't work, and also &lt;code&gt;:help :quote&lt;/code&gt; states that &quot;This is mentioned where the command is explained&quot;, which does not appear to be true in this case, so you could maybe raise those points as an issue with the Vim dev team.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-15T15:14:53.033" LastActivityDate="2018-03-15T15:14:53.033" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15584" PostTypeId="1" CreationDate="2018-03-15T15:34:47.447" Score="22" ViewCount="12354" Body="&lt;p&gt;I have a way to handle swap files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And it works but it takes a while.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here goes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First I try to find the original vim session&#xA;-- track down if the PID is still alive &#xA;-- and if the PID is still alive I go try and find that vim session and save the file and quit... and I'm done (stop here)&#xA;-- If I can't open the vim session I kill the PID... and have to recover the file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;try to view the diff&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I hit &lt;kbd&gt;r&lt;/kbd&gt; to recover the file&lt;/li&gt;&#xA;&lt;li&gt;save the recovered file to a temporary file&lt;/li&gt;&#xA;&lt;li&gt;quit vim&lt;/li&gt;&#xA;&lt;li&gt;do a command line vimdiff between the two&lt;/li&gt;&#xA;&lt;li&gt;manually fix any conflicts&lt;/li&gt;&#xA;&lt;li&gt;save the file&lt;/li&gt;&#xA;&lt;li&gt;quit vim&lt;/li&gt;&#xA;&lt;li&gt;delete the temporary file&lt;/li&gt;&#xA;&lt;li&gt;reopen vim&lt;/li&gt;&#xA;&lt;li&gt;done&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I wanted to find a way to do the same thing but more efficiently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I view the diff of the file with the recovered file, resolve any differences, save the file without quitting vim or using plugins?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1894" LastEditorUserId="4866" LastEditDate="2024-02-06T09:14:34.140" LastActivityDate="2024-02-06T09:14:34.140" Title="How do you view the diff of a swap file without quitting Vim?" Tags="|swap-file|crash-recovery|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="15585" PostTypeId="2" ParentId="15584" CreationDate="2018-03-15T15:34:47.447" Score="25" Body="&lt;p&gt;&lt;strong&gt;Here is the &lt;code&gt;vim&lt;/code&gt; commands you need to view the diff, resolve any differences, and save the file. All done without quitting &lt;code&gt;vim&lt;/code&gt; or using plugins.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;From the command line, open the file, there will be a command line prompt, choose to &amp;quot;recover the file&amp;quot; by selecting &lt;code&gt;r&lt;/code&gt;, then the rest of the steps are all inside &lt;code&gt;vim&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;save the recovered file (if the destination file exists, then overwrite)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:sav! ~/.recovered&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;open the original (not-recovered file) in a new window&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:vsplit&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;ctrl-w&lt;/kbd&gt; &lt;kbd&gt;w&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:bn&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;on the left, is the recovered file&lt;/li&gt;&#xA;&lt;li&gt;on the right, is the un-recovered file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;diff the two files&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:diffthis&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;ctrl-w&lt;/kbd&gt; &lt;kbd&gt;w&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:diffthis&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;now we have a diff of the two files (see &lt;code&gt;man vimdiff&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;resolve any conflicts (see &lt;code&gt;man vimdiff&lt;/code&gt; for more info)&lt;/li&gt;&#xA;&lt;li&gt;save any changes made to the unresolved file&lt;/li&gt;&#xA;&lt;li&gt;delete the swap file&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:!rm -v path/to/.file.swp&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;quit vim&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;I am sure there are better methods because my solution requires 7 steps. If you have a better solution please edit my solution or provide a better solution.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;p.s. I must give credit where credit is due.&lt;/p&gt;&#xA;&lt;p&gt;I started with the solution from &lt;a href=&quot;http://vim.wikia.com/wiki/Swap_file_%22...%22already_exists!_-_so_diff_it&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Swap_file_%22...%22already_exists!_-_so_diff_it&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I modified the linked solution because&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the linked solution does not handle opening a file that is under a directory&lt;/li&gt;&#xA;&lt;li&gt;the instructions on that page were not clear and required lots of time for me to reverse engineer what was needed... hence this written solution&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1894" LastEditorUserId="1894" LastEditDate="2023-02-01T17:39:30.417" LastActivityDate="2023-02-01T17:39:30.417" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="15586" PostTypeId="2" ParentId="15573" CreationDate="2018-03-15T16:50:54.310" Score="2" Body="&lt;p&gt;You can edit the search history with the following,: &lt;code&gt;histadd()&lt;/code&gt;, &lt;code&gt;histget()&lt;/code&gt;, and &lt;code&gt;histdel()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h histadd()&lt;/code&gt; for more help.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-03-15T16:50:54.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15587" PostTypeId="1" AcceptedAnswerId="15588" CreationDate="2018-03-15T17:08:12.117" Score="4" ViewCount="3049" Body="&lt;p&gt;Suppose that I have marks &lt;code&gt;'a&lt;/code&gt; and &lt;code&gt;'b&lt;/code&gt;, and I want to search for all occurrences of &lt;code&gt;foo&lt;/code&gt; between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;ex&lt;/code&gt; command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'a,'bs/foo/bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will &lt;em&gt;replace&lt;/em&gt; only between &lt;code&gt;'a&lt;/code&gt; and &lt;code&gt;'b&lt;/code&gt;.  Is there any command like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'a,'b/foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that will &lt;em&gt;find&lt;/em&gt; &lt;code&gt;foo&lt;/code&gt; only between those two marks?  (That exact syntax does &lt;em&gt;something&lt;/em&gt;, but I can't figure out what.  It doesn't seem to be what I want.)&lt;/p&gt;&#xA;" OwnerUserId="2108" LastEditorUserId="2108" LastEditDate="2018-03-15T18:07:59.943" LastActivityDate="2019-11-27T12:00:00.687" Title="Find only between marks" Tags="|search|mark|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15588" PostTypeId="2" ParentId="15587" CreationDate="2018-03-15T17:16:06.193" Score="5" Body="&lt;p&gt;You can use &lt;code&gt;\%&amp;gt;'m&lt;/code&gt; and &lt;code&gt;\%&amp;lt;'m&lt;/code&gt; to match after and before a given mark, &lt;code&gt;m&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\%&amp;gt;'afoo\%&amp;lt;'b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more helps see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h /\%'m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-03-15T17:16:06.193" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15589" PostTypeId="1" AcceptedAnswerId="15590" CreationDate="2018-03-15T19:12:03.343" Score="1" ViewCount="222" Body="&lt;p&gt;while coding in vim I use often special comment to denote&#xA;section of the file. For example in C it is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//;; some title 1&#xA;//;; some title 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have also configured a shortcut to print with a global command (g/.../p)&#xA;all such entries in the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output print looks like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;16 //;; some title 1&#xA;32 //;; some title 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then I just type &lt;code&gt;:&lt;/code&gt; and the line number to jump directly to the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I am quite satisfied with it, it would be much faster If i could&#xA;navigate in this list like a mini buffer and then select the entry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I use fzf in vim I was thinking about creating a vim list to input to fzf. However the idea got much harder to implement as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some easier way to do it?&lt;/p&gt;&#xA;" OwnerUserId="11117" LastActivityDate="2018-03-15T19:28:02.440" Title="creating a menu for navigation in file" Tags="|navigation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15590" PostTypeId="2" ParentId="15589" CreationDate="2018-03-15T19:28:02.440" Score="2" Body="&lt;p&gt;This seems like a pretty good use-case for the location list, so here is one &quot;vanilla vim&quot; solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:lvimgrep '\V//;;' % | lopen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can make a mapping or a command around this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Breakdown: &lt;code&gt;lvimgrep&lt;/code&gt; loads the location list with lines matching &lt;code&gt;//;;&lt;/code&gt; (we use &lt;code&gt;\V&lt;/code&gt; to make it easier to enter this pattern), from the current file (&lt;code&gt;%&lt;/code&gt;).  Then we open the location list using &lt;code&gt;lopen&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;:lnext&lt;/code&gt; and &lt;code&gt;:lprev&lt;/code&gt; (among other commands) to navigate between positoins.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-03-15T19:28:02.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15591" PostTypeId="1" CreationDate="2018-03-15T20:13:16.637" Score="7" ViewCount="467" Body="&lt;p&gt;Is the effective default value for &lt;code&gt;titlestring&lt;/code&gt; documented somewhere?  By effective, I mean the one that displays &lt;code&gt;$(basename) ($(dirname)) (m of n) - GVIM1&lt;/code&gt; or &lt;code&gt;... ((m) of n)&lt;/code&gt;, even though &lt;code&gt;titlestring&lt;/code&gt; is &quot;actually&quot; empty (so I guess it's some hard-coded default somewhere).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason is that I would like to change the &lt;code&gt;m of n&lt;/code&gt; part to use the buffer list rather than the argument list (the latter being quite confusing when one frequently uses e.g. :bd), but keep the rest.  Yes, I could probably work it out by fully reading the docs on &lt;code&gt;statusline&lt;/code&gt;, but I'm trying to avoid that...&lt;/p&gt;&#xA;" OwnerUserId="16737" LastActivityDate="2018-03-15T20:13:16.637" Title="What is the default &quot;effective&quot; titlestring?" Tags="|options|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15592" PostTypeId="1" CreationDate="2018-03-15T22:14:13.033" Score="1" ViewCount="532" Body="&lt;p&gt;I set the following highlight:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:hi Normal ctermfg=250 ctermbg=235&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The text is a nice light gray on dark gray, as intended. But the cursor has become dark blue. I'd love to have it just be the reverse of Normal.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/J88AN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/J88AN.png&quot; alt=&quot;desc&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Setting similar Normal highlights has different effects:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:hi Normal ctermfg=250 ctermbg=234&lt;/code&gt; medium blue&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:hi Normal ctermfg=250 ctermbg=233&lt;/code&gt; green&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:hi Normal ctermfg=250 ctermbg=232&lt;/code&gt; teal&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Of course, those also change the background as expected. Changing the &lt;code&gt;ctermfg&lt;/code&gt; doesn't seem to do anything to the cursor color.&lt;/p&gt;&#xA;&lt;p&gt;I'm using Vim 8.0 (also tried 7.4) on CentOS 7 via xterm (&lt;code&gt;term=xterm-256color&lt;/code&gt;).&lt;br /&gt;&#xA;(Update: I'm ssh-ing to the CentOS system from SecureCRT 8 on Windows 10. My SecureCRT session is set to xterm emulation.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Configuring_the_cursor#Changing_the_cursor_color_in_insert_mode&quot; rel=&quot;nofollow noreferrer&quot;&gt;Escape codes for xterm&lt;/a&gt; have no effect on the cursor color.&lt;br /&gt;&#xA;There doesn't seem to be anything in &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Ahi-normal-cterm&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help hi-normal-cterm&lt;/code&gt;&lt;/a&gt; about cursor color.&lt;br /&gt;&#xA;&lt;a href=&quot;https://unix.stackexchange.com/a/289676/128023&quot;&gt;Someone who knows a lot more about xterm than me says&lt;/a&gt; that it should just invert the fg/bg colors.&lt;/p&gt;&#xA;&lt;p&gt;I don't know much about terminal types and such, but is there a way I can get my cursor to a normal color combo?&lt;/p&gt;&#xA;" OwnerUserId="9267" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-03-21T20:45:28.467" Title="Normal highlight group changes cursor color in vim in xterm" Tags="|terminal|highlight|cursor|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="15593" PostTypeId="1" AcceptedAnswerId="15594" CreationDate="2018-03-16T02:27:54.350" Score="0" ViewCount="73" Body="&lt;p&gt;I'd like to add ruler marks/virtual columns along the lines of &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;matchadd('ColorColumn', '\%81v', 100)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;while &lt;em&gt;restricting their display to the cursorline&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas ? &lt;/p&gt;&#xA;" OwnerUserId="16177" LastActivityDate="2018-03-16T09:49:08.883" Title="Isolate a matched virtual column ruler to the cursorline only?" Tags="|syntax-highlighting|cursorline|ruler|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15594" PostTypeId="2" ParentId="15593" CreationDate="2018-03-16T09:37:04.567" Score="2" Body="&lt;p&gt;Try the following two commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Match when cursor before column&#xA;matchadd('ColorColumn', '\%#.*\zs\%81v', 100)&#xA;&#xA;&quot; Match when cursor after column&#xA;matchadd('ColorColumn', '\%81v\ze.*\%#', 100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should be possible to combine these into a single regular expression, but simply placing them into an alternation with &lt;code&gt;\|&lt;/code&gt; doesn't work correctly*, so doing so seems like more trouble than it's worth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These work by finding the cursor position &lt;code&gt;\%#&lt;/code&gt; either following or followed by the specified column, but excluding everything apart from the column from the match with &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help /\%#&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help /\zs&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help /\ze&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* At a guess, there may be some complexity in the interaction between &lt;code&gt;\zs&lt;/code&gt;/&lt;code&gt;\ze&lt;/code&gt; and alternation that I'm unaware of&amp;mdash;you might have better luck with lookahead &lt;code&gt;\@=&lt;/code&gt; and lookbehind &lt;code&gt;\@&amp;lt;=&lt;/code&gt;, but note that these are inefficient compared to &lt;code&gt;\zs&lt;/code&gt;/&lt;code&gt;\ze&lt;/code&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-16T09:49:08.883" LastActivityDate="2018-03-16T09:49:08.883" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15595" PostTypeId="1" AcceptedAnswerId="15613" CreationDate="2018-03-16T09:37:16.283" Score="4" ViewCount="480" Body="&lt;p&gt;I'm currently using the session saving to restore the state when the app (MacVim) is closed. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;q :mksession! ~/.vim/Session.vim&amp;lt;CR&amp;gt;:wqa&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;www :mksession! ~/.vim/Session.vim&amp;lt;CR&amp;gt;:qa!&amp;lt;CR&amp;gt;&#xA;&#xA;function! RestoreSession()&#xA;   if argc() == 0 &quot;vim called without arguments&#xA;        execute (has(&quot;gui_running&quot;) ? &quot;&quot; : &quot;silent!&quot;) 'source ~/.vim/Session.vim'&#xA;   end&#xA;endfunction&#xA;autocmd VimEnter * call RestoreSession()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this only works for a single GUI window. When I trigger the shortcut, it closes the current window. After all the windows are closed in the same way and then I open the app again, only the last closed GUI window is restored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to close all the GUI windows simultaneously and restore all of them on the next launch?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastEditorUserId="343" LastEditDate="2018-03-16T09:56:40.607" LastActivityDate="2018-03-21T02:01:43.963" Title="Can I retain and restore all the GUI windows and its files on launch on Vim?" Tags="|vimrc|macvim|sessions|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="15596" PostTypeId="2" ParentId="8169" CreationDate="2018-03-16T12:25:23.897" Score="0" Body="&#xA;&#xA;&lt;p&gt;If you'd like your cursor to restore the last position known to &lt;em&gt;viminfo&lt;/em&gt;, you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost * call setpos(&quot;.&quot;, getpos(&quot;'\&quot;&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;romainl's answer has been particularly useful to me, and I have been using this a lot (since I am a web dev):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup VIMRC&#xA;    autocmd!&#xA;    autocmd BufLeave,WinLeave *.html normal! mH&#xA;    autocmd BufLeave,WinLeave *.css normal! mC&#xA;    autocmd BufLeave,WinLeave *.js normal! mJ&#xA;augroup end&#xA;&#xA;nnoremap &amp;lt;space&amp;gt;h `Hzz&#xA;nnoremap &amp;lt;space&amp;gt;c `Czz&#xA;nnoremap &amp;lt;space&amp;gt;j `Jzz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The final potentially useful thing is the option, &lt;code&gt;:help 'nostartofline&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;               *'startofline'* *'sol'* *'nostartofline'* *'nosol'*&#xA;'startofline' 'sol' boolean (default on)&#xA;            global&#xA;            {not in Vi}&#xA;    When &quot;on&quot; the commands listed below move the cursor to the first&#xA;    non-blank of the line.  When off the cursor is kept in the same column&#xA;    (if possible).  This applies to the commands: CTRL-D, CTRL-U, CTRL-B,&#xA;    CTRL-F, &quot;G&quot;, &quot;H&quot;, &quot;M&quot;, &quot;L&quot;, gg, and to the commands &quot;d&quot;, &quot;&amp;lt;&amp;lt;&quot; and &quot;&amp;gt;&amp;gt;&quot;&#xA;    with a linewise operator, with &quot;%&quot; with a count and to buffer changing&#xA;    commands (CTRL-^, :bnext, :bNext, etc.).  Also for an Ex command that&#xA;    only has a line number, e.g., &quot;:25&quot; or &quot;:+&quot;.&#xA;    In case of buffer changing commands the cursor is placed at the column&#xA;    where it was the last time the buffer was edited.&#xA;    NOTE: This option is set when 'compatible' is set.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5108" LastActivityDate="2018-03-16T12:25:23.897" CommentCount="0" CommunityOwnedDate="2018-03-16T12:25:23.897" ContentLicense="CC BY-SA 3.0" />
  <row Id="15597" PostTypeId="1" CreationDate="2018-03-16T13:24:45.123" Score="3" ViewCount="522" Body="&lt;p&gt;After noticing some lag that only happens when I use neovim to open Ruby files, I have debugged it and find the result quite interesting (from ms 255 to ms 1294):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;times in msec&#xA; clock   self+sourced   self:  sourced script&#xA; clock   elapsed:              other lines&#xA;&#xA;000.011  000.011: --- NVIM STARTING ---&#xA;000.779  000.768: locale set&#xA;001.476  000.697: inits 1&#xA;001.495  000.019: window checked&#xA;002.105  000.610: parsing arguments&#xA;002.110  000.005: expanding arguments&#xA;002.217  000.107: inits 2&#xA;002.547  000.330: init highlight&#xA;003.332  000.246  000.246: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/syncolor.vim&#xA;003.471  000.510  000.264: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/synload.vim&#xA;032.373  028.808  028.808: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/filetype.vim&#xA;032.458  029.613  000.295: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/syntax.vim&#xA;035.139  002.590  002.590: sourcing /Users/huyvo/.config/nvim/autoload/plug.vim&#xA;040.513  002.977  002.977: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/ftoff.vim&#xA;066.653  024.721  024.721: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/filetype.vim&#xA;066.877  000.053  000.053: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/ftplugin.vim&#xA;067.060  000.042  000.042: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/indent.vim&#xA;067.277  000.052  000.052: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/filetype.vim&#xA;067.456  000.047  000.047: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/ftplugin.vim&#xA;067.682  000.030  000.030: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/indent.vim&#xA;068.327  000.178  000.178: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/syncolor.vim&#xA;069.049  000.160  000.160: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/syncolor.vim&#xA;069.383  000.156  000.156: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/syncolor.vim&#xA;076.225  007.741  007.425: sourcing /Users/huyvo/.config/nvim/plugged/nord-vim/colors/nord.vim&#xA;076.373  073.635  005.590: sourcing /Users/huyvo/.config/nvim/init.vim&#xA;076.379  000.198: sourcing vimrc file(s)&#xA;077.077  000.201  000.201: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/autoload/gitgutter/utility.vim&#xA;077.502  000.133  000.133: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/autoload/gitgutter/highlight.vim&#xA;078.311  001.671  001.337: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/plugin/gitgutter.vim&#xA;078.910  000.475  000.475: sourcing /Users/huyvo/.config/nvim/plugged/vim-surround/plugin/surround.vim&#xA;079.628  000.576  000.576: sourcing /Users/huyvo/.config/nvim/plugged/lightline.vim/plugin/lightline.vim&#xA;080.824  001.015  001.015: sourcing /Users/huyvo/.fzf/plugin/fzf.vim&#xA;081.703  000.757  000.757: sourcing /Users/huyvo/.config/nvim/plugged/fzf.vim/plugin/fzf.vim&#xA;081.930  000.105  000.105: sourcing /Users/huyvo/.config/nvim/plugged/vim-startify/plugin/startify.vim&#xA;082.597  000.143  000.143: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/autoload/nerdtree.vim&#xA;083.686  000.470  000.470: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/path.vim&#xA;083.884  000.111  000.111: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/menu_controller.vim&#xA;084.039  000.077  000.077: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/menu_item.vim&#xA;084.217  000.100  000.100: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/key_map.vim&#xA;084.498  000.203  000.203: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/bookmark.vim&#xA;084.792  000.213  000.213: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/tree_file_node.vim&#xA;085.240  000.365  000.365: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/tree_dir_node.vim&#xA;085.512  000.191  000.191: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/opener.vim&#xA;085.811  000.218  000.218: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/creator.vim&#xA;085.937  000.047  000.047: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/flag_set.vim&#xA;086.144  000.130  000.130: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/nerdtree.vim&#xA;086.586  000.365  000.365: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/ui.vim&#xA;086.696  000.026  000.026: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/event.vim&#xA;086.813  000.040  000.040: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/notifier.vim&#xA;087.268  000.366  000.366: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/autoload/nerdtree/ui_glue.vim&#xA;103.030  000.101  000.101: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/nerdtree_plugin/exec_menuitem.vim&#xA;103.591  000.511  000.511: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/nerdtree_plugin/fs_menu.vim&#xA;104.421  000.693  000.693: sourcing /Users/huyvo/.config/nvim/plugged/vim-nerdtree-tabs/nerdtree_plugin/vim-nerdtree-tabs.vim&#xA;104.617  022.568  018.197: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/plugin/NERD_tree.vim&#xA;109.363  004.623  004.623: sourcing /Users/huyvo/.config/nvim/plugged/nerdcommenter/plugin/NERD_commenter.vim&#xA;116.162  006.246  006.246: sourcing /Users/huyvo/.config/nvim/plugged/vim-fugitive/plugin/fugitive.vim&#xA;117.079  000.304  000.304: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale.vim&#xA;118.349  000.205  000.205: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/toggle.vim&#xA;118.826  002.472  001.964: sourcing /Users/huyvo/.config/nvim/plugged/ale/plugin/ale.vim&#xA;119.636  000.095  000.095: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/provider/pythonx.vim&#xA;199.542  080.219  080.124: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/provider/python.vim&#xA;239.339  000.269  000.269: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/remote/host.vim&#xA;239.441  039.710  039.441: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/provider/python3.vim&#xA;239.785  120.779  000.850: sourcing /Users/huyvo/.config/nvim/plugged/YouCompleteMe/plugin/youcompleteme.vim&#xA;240.366  000.036  000.036: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/gui_shim.vim&#xA;240.723  000.317  000.317: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/gzip.vim&#xA;240.791  000.027  000.027: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/health.vim&#xA;240.899  000.071  000.071: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/man.vim&#xA;241.515  000.576  000.576: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/matchit.vim&#xA;241.803  000.190  000.190: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/matchparen.vim&#xA;242.308  000.457  000.457: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/netrwPlugin.vim&#xA;242.982  000.192  000.192: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/remote/define.vim&#xA;243.066  000.503  000.311: sourcing /Users/huyvo/.local/share/nvim/rplugin.vim&#xA;243.074  000.713  000.210: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/rplugin.vim&#xA;243.140  000.019  000.019: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/rrhelper.vim&#xA;243.292  000.108  000.108: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/shada.vim&#xA;243.373  000.032  000.032: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/spellfile.vim&#xA;243.563  000.146  000.146: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/tarPlugin.vim&#xA;243.700  000.092  000.092: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/tohtml.vim&#xA;243.771  000.026  000.026: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/tutor.vim&#xA;244.002  000.182  000.182: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/zipPlugin.vim&#xA;244.013  003.354: loading plugins&#xA;244.111  000.098: loading packages&#xA;244.326  000.049  000.049: sourcing /Users/huyvo/.config/nvim/plugged/ale/after/plugin/ale.vim&#xA;244.343  000.183: loading after plugins&#xA;244.351  000.008: inits 3&#xA;245.530  001.179: reading ShaDa&#xA;247.687  002.156: clearing screen&#xA;254.170  002.672  002.672: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/ruby.vim&#xA;255.154  000.225  000.225: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/provider/ruby.vim&#xA;1294.907  1040.213  1039.989: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/ftplugin/ruby.vim&#xA;1296.065  000.501  000.501: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/indent/ruby.vim&#xA;1296.577  000.386  000.386: sourcing /Users/huyvo/.config/nvim/plugged/lightline.vim/autoload/lightline.vim&#xA;1297.137  000.048  000.048: sourcing /Users/huyvo/.config/nvim/plugged/lightline.vim/autoload/lightline/tab.vim&#xA;1297.633  000.193  000.193: sourcing /Users/huyvo/.config/nvim/plugged/lightline.vim/autoload/lightline/colorscheme.vim&#xA;1298.123  000.854  000.661: sourcing /Users/huyvo/.config/nvim/plugged/nord-vim/autoload/lightline/colorscheme/nord.vim&#xA;1301.287  000.062  000.062: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/events.vim&#xA;1301.666  000.200  000.200: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/util.vim&#xA;1302.204  000.291  000.291: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/linter.vim&#xA;1302.882  000.366  000.366: sourcing /Users/huyvo/.config/nvim/plugged/ale/ale_linters/ruby/brakeman.vim&#xA;1303.305  000.368  000.368: sourcing /Users/huyvo/.config/nvim/plugged/ale/ale_linters/ruby/rails_best_practices.vim&#xA;1303.730  000.371  000.371: sourcing /Users/huyvo/.config/nvim/plugged/ale/ale_linters/ruby/reek.vim&#xA;1304.144  000.360  000.360: sourcing /Users/huyvo/.config/nvim/plugged/ale/ale_linters/ruby/rubocop.vim&#xA;1304.549  000.354  000.354: sourcing /Users/huyvo/.config/nvim/plugged/ale/ale_linters/ruby/ruby.vim&#xA;1307.615  000.051  000.051: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/pattern_options.vim&#xA;1309.866  000.999  000.999: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/engine.vim&#xA;1310.342  000.118  000.118: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/handlers/rubocop.vim&#xA;1310.679  000.072  000.072: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/history.vim&#xA;1311.167  000.058  000.058: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/command.vim&#xA;1326.470  000.765  000.765: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/job.vim&#xA;1349.343  052.544: opening buffers&#xA;1350.024  000.365  000.365: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/autoload/gitgutter.vim&#xA;1351.377  000.145  000.145: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/autoload/gitgutter/async.vim&#xA;1351.682  000.151  000.151: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/autoload/gitgutter/debug.vim&#xA;1377.794  021.768  021.768: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/autoload/gitgutter/diff.vim&#xA;1400.106  028.334: BufEnter autocommands&#xA;1400.123  000.017: editing files in windows&#xA;1401.999  001.034  001.034: sourcing /Users/huyvo/.config/nvim/plugged/YouCompleteMe/autoload/youcompleteme.vim&#xA;1525.528  000.147  000.147: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/provider.vim&#xA;1605.589  204.286: VimEnter autocommands&#xA;1605.597  000.008: before starting main loop&#xA;1606.038  000.176  000.176: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/cursor.vim&#xA;1623.767  017.995: first screen update&#xA;1623.771  000.004: --- NVIM STARTED ---&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sourcing ruby.vim takes very long time to finish, I don't think that the root cause is because of my settings and plugins, but because neovim somehow just doesn't know where my ruby path is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding &lt;code&gt;let g:ruby_path=&quot;/usr/bin/ruby&quot;&lt;/code&gt; to the configuration file does solve the lagging problem, but it raises another question: what's wrong with neovim and ruby path? And if neovim doesn't know where Ruby path is at the beginning, why does it take so long to find the path?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to look for the &lt;code&gt;init.vim&lt;/code&gt; of other Ruby developers. None of them explicitly set ruby path in their config. If they don't have the lagging problem then why me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My configuration can be found at &lt;a href=&quot;https://github.com/huyvohcmc/dotfiles/blob/master/init.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/huyvohcmc/dotfiles/blob/master/init.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;Here is my result when I run &lt;code&gt;checkhealth&lt;/code&gt; fyi:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;health#nvim#check&#xA;========================================================================&#xA;## Configuration&#xA;  - OK: no issues found&#xA;&#xA;## Performance&#xA;  - OK: Build type: Release&#xA;&#xA;## Remote Plugins&#xA;  - OK: Up to date&#xA;&#xA;## terminal&#xA;  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H&#xA;  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~&#xA;  - INFO: $XTERM_VERSION=''&#xA;  - INFO: $VTE_VERSION=''&#xA;  - INFO: $SSH_TTY=''&#xA;&#xA;health#provider#check&#xA;========================================================================&#xA;## Clipboard (optional)&#xA;  - OK: Clipboard tool found: pbcopy&#xA;&#xA;## Python 2 provider (optional)&#xA;  - INFO: Using: g:python_host_prog = &quot;/usr/local/bin/python&quot;&#xA;  - INFO: Executable: /usr/local/bin/python&#xA;  - INFO: Python2 version: 2.7.14&#xA;  - INFO: python-neovim version: 0.2.4&#xA;  - OK: Latest python-neovim is installed: 0.2.4&#xA;&#xA;## Python 3 provider (optional)&#xA;  - INFO: Using: g:python3_host_prog = &quot;/usr/local/bin/python3&quot;&#xA;  - INFO: Executable: /usr/local/bin/python3&#xA;  - INFO: Python3 version: 3.6.4&#xA;  - INFO: python3-neovim version: 0.2.4&#xA;  - OK: Latest python3-neovim is installed: 0.2.4&#xA;&#xA;## Ruby provider (optional)&#xA;  - INFO: Ruby: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin17]&#xA;  - INFO: Host: /Users/huyvo/.rbenv/shims/neovim-ruby-host&#xA;  - OK: Latest &quot;neovim&quot; gem is installed: 0.7.1&#xA;&#xA;## Node provider (optional)&#xA;  - INFO: Node: v8.9.4&#xA;  - INFO: Host: /Users/huyvo/.nvm/versions/node/v8.9.4/bin/neovim-node-host&#xA;  - OK: Latest &quot;neovim&quot; npm is installed: 3.5.2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16749" LastEditorUserId="16749" LastEditDate="2018-03-17T04:50:48.403" LastActivityDate="2018-03-17T04:50:48.403" Title="Neovim takes so long to source ruby.vim" Tags="|vimrc|neovim|filetype-ruby|" AnswerCount="0" CommentCount="7" ClosedDate="2018-03-19T07:48:19.053" ContentLicense="CC BY-SA 3.0" />
  <row Id="15598" PostTypeId="1" AcceptedAnswerId="15599" CreationDate="2018-03-16T15:27:40.967" Score="0" ViewCount="300" Body="&lt;h1&gt;Background&lt;/h1&gt;&#xA;&lt;p&gt;When working on &lt;code&gt;.c&lt;/code&gt; and &lt;code&gt;.h&lt;/code&gt; files, I have a couple options turned on, namely:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;filetype indent on&#xA;autocmd BufEnter *.c   setlocal tabstop=8 shiftwidth=8 softtabstop=8 textwidth=80 noexpandtab cindent cinoptions=:0,l1,t0,g0,(0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This enables a really useful feature for me: when I move the cursor over a bracket (&lt;kbd&gt;&lt;code&gt;[&lt;/code&gt;&lt;/kbd&gt;, &lt;kbd&gt;&lt;code&gt;]&lt;/code&gt;&lt;/kbd&gt;), parenthesis (&lt;kbd&gt;&lt;code&gt;(&lt;/code&gt;&lt;/kbd&gt;, &lt;kbd&gt;&lt;code&gt;)&lt;/code&gt;&lt;/kbd&gt;), or brace (&lt;kbd&gt;&lt;code&gt;{&lt;/code&gt;&lt;/kbd&gt;, &lt;kbd&gt;&lt;code&gt;}&lt;/code&gt;&lt;/kbd&gt;) character, the matching &amp;quot;partner&amp;quot; (assuming my code is syntactically correct) is highlighted, and I can jump between the &amp;quot;partners&amp;quot; via the &lt;kbd&gt;&lt;code&gt;%&lt;/code&gt;&lt;/kbd&gt; key.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;Problem&lt;/h1&gt;&#xA;&lt;p&gt;I edit a lot of GNU M4 files, and the most commonly used delimiter/bracket-like characters are the back-tick (&lt;kbd&gt;&lt;code&gt;`&lt;/code&gt;&lt;/kbd&gt;) and single-quote (&lt;kbd&gt;&lt;code&gt;'&lt;/code&gt;&lt;/kbd&gt;) characters. Unfortunately, I cannot highlight and/or jump between pairs like I can with brackets, braces, etc.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is it possible to enable the matching/highlighting/jumping-to-partner features I've described for arbitrary pairs of symbols, assuming that start/stop characters &lt;strong&gt;are not&lt;/strong&gt; the same (i.e. backtick and single-quote, in my case)?&lt;/li&gt;&#xA;&lt;li&gt;Is it possible to enable the matching/highlighting/jumping-to-partner features I've described for arbitrary pairs of symbols, assuming that start/stop characters &lt;strong&gt;are&lt;/strong&gt; the same (i.e. a pair of double-quotation marks)?&lt;/li&gt;&#xA;&lt;li&gt;Does VI/VIM have the ability to detect escaped symbols, i.e.: could it match a pair of double quotation marks (&lt;kbd&gt;&lt;code&gt;&amp;quot;&lt;/code&gt;&lt;/kbd&gt;), but know to ignore double-quotes with a backslash immediately to the left (i.e. &lt;kbd&gt;&lt;code&gt;\&amp;quot;&lt;/code&gt;&lt;/kbd&gt;)?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="14282" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-03-16T16:18:39.550" Title="Enable %-key jumping/highlighting for backticks (`) and single-quotes (') in M4 files" Tags="|cursor-motions|highlight|delimiter-matching|jumplist|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15599" PostTypeId="2" ParentId="15598" CreationDate="2018-03-16T16:13:28.397" Score="1" Body="&lt;p&gt;For question 1, try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set matchpairs+=`:'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'matchpairs'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This requires the characters to be different, so it won't help you with question 2 (or indeed 3).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For these latter two requirements, the short answer is that Vim doesn't provide this feature by default, and it will be tricky to implement well because it requires a greater understanding of context (and, ideally syntax,) than Vim currently has.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a related aside, if you want to match things that aren't single characters, see also &lt;code&gt;:help matchit&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-16T16:18:39.550" LastActivityDate="2018-03-16T16:18:39.550" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15600" PostTypeId="1" AcceptedAnswerId="15601" CreationDate="2018-03-16T19:22:13.127" Score="0" ViewCount="564" Body="&lt;p&gt;I have the following mappings in my .vimrc; they automatically close brackets of various kinds for me.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ino &amp;quot; &amp;quot;&amp;quot;&amp;lt;left&amp;gt;&#xA;ino ( ()&amp;lt;left&amp;gt;&#xA;ino ' ''&amp;lt;left&amp;gt;&#xA;ino [ []&amp;lt;left&amp;gt;&#xA;ino { {}&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What I would like is that when I press &lt;code&gt;)&lt;/code&gt; and have a &lt;code&gt;)&lt;/code&gt; to the right of my cursor, I go beyond it.&lt;/p&gt;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&lt;p&gt;from&#xA;&lt;a href=&quot;https://i.stack.imgur.com/BiFHS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BiFHS.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt; to &lt;a href=&quot;https://i.stack.imgur.com/yK6b1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yK6b1.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt; while in &lt;strong&gt;insert&lt;/strong&gt; mode just by typing &lt;code&gt;)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user16659" LastEditorUserId="10604" LastEditDate="2021-06-29T14:49:52.683" LastActivityDate="2021-06-29T14:49:52.683" Title="How do I move the cursor to the right when typing a closing bracket?" Tags="|key-bindings|insert-mode|cursor-motions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="15601" PostTypeId="2" ParentId="15600" CreationDate="2018-03-17T02:15:03.997" Score="3" Body="&lt;p&gt;You can use an expression mapping that looks at the character after the cursor. Let's build that up.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Getting the character after your cursor&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Using Vim's functions &lt;code&gt;getline()&lt;/code&gt; and &lt;code&gt;getpos()&lt;/code&gt;, we can figure out what character follows the cursor in Insert mode. &lt;code&gt;getline('.')&lt;/code&gt; returns the current line as a string, which we can index using &lt;code&gt;[]&lt;/code&gt; notation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the position of your cursor, you can use &lt;code&gt;getpos('.')&lt;/code&gt;. It returns an array including the buffer number, line number, column, and virtual offset of the cursor. Here, we're interested in the column, which we'll use as the index of the current line: &lt;code&gt;getpos('.')[2]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the column number returned by &lt;code&gt;getpos()&lt;/code&gt; is 1-indexed and strings are 0-indexed, we have to subtract 1 from the column to get the index of character after our cursor in Insert mode. So all together, the expression &lt;code&gt;getline('.')[getpos('.')[2] - 1]&lt;/code&gt; represents the character after our cursor.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Building the mapping&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;With expression mappings, an expression is evaluated as a string to be used as the right-hand-side. We'll make an expression mapping that evaluates to &lt;code&gt;&amp;lt;Right&amp;gt;&lt;/code&gt; if the next character is &lt;code&gt;)&lt;/code&gt;, or the actual &lt;code&gt;)&lt;/code&gt; character otherwise.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; ) getline('.')[getpos('.')[2] - 1] == ')' ? '&amp;lt;Right&amp;gt;' : ')'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Relevant documentation:&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:map-%3Cexpr%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :map-&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#getline()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help getline()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#getpos()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help getpos()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="64" LastEditorUserId="64" LastEditDate="2018-03-17T14:11:34.320" LastActivityDate="2018-03-17T14:11:34.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15602" PostTypeId="2" ParentId="14371" CreationDate="2018-03-17T12:45:58.707" Score="3" Body="&lt;p&gt;Just make sure your basic configuration has filetype enabled to begin with:&#xA;&lt;code&gt;filetype plugin on&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is, but sill not working as intended, you can set filetypes explicitly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this should be in your &lt;code&gt;~/.vimrc&lt;/code&gt; or &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt; depending on whichever editor you are actually using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyRubyCode&#xA;&quot; Files with extension .rb are processed as Ruby code&#xA;    automcd!&#xA;    autocmd BufReadPre,FileReadPre *.rb set ft=ruby&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will pick up whatever ruby file attributes set in your &lt;strong&gt;proper&lt;/strong&gt; vim path ftplugin:&#xA;e.g, &lt;code&gt;/usr/share/vim/vim80/ftplugin&lt;/code&gt;&#xA;(this is the actual path for both vim and neovim in a Fedora 27 distribution).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe you just want the MyRubyCode above so (probably) remove the custom files from your personal ftplugin folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g, &lt;code&gt;~/.config/nvim/after/ftplugin&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g, &lt;code&gt;~/.config/nvim/ftplugin&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The files you are putting there are doing silly things that don't help your cause. i.e., setting the file as a ruby file after it had been recognized as a ruby file. (&lt;strong&gt;filetype recognition happens before&lt;/strong&gt; ftplugin so it doesn't make sense).  That's why you should use your vim config file instead of fiddling with paths you don't fully understand yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Notice:&lt;/strong&gt; if you don't want to fiddle with file extensions, just open the file and type &lt;code&gt;:set ft=ruby&lt;/code&gt; in Vim's command line. If you want to make the change permanent, just use some Vim magic &lt;em&gt;(modeline)&lt;/em&gt; at the very end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;# vim: set ft=ruby&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Enjoy.&lt;/p&gt;&#xA;" OwnerUserId="14089" LastEditorUserId="14089" LastEditDate="2018-03-17T12:51:31.260" LastActivityDate="2018-03-17T12:51:31.260" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="15603" PostTypeId="1" AcceptedAnswerId="15604" CreationDate="2018-03-17T18:16:01.457" Score="1" ViewCount="186" Body="&lt;p&gt;I'm writing a vimscript function that converts a single ASCII control-character in the range 1 - 26 (e.g. &lt;code&gt;^F&lt;/code&gt;) to its two-character printable representation (e.g. &lt;code&gt;^&lt;/code&gt; &lt;code&gt;F&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! CtrlCharStr(arg)&#xA;  let cntrl = matchstr(a:arg, '^[[:cntrl:]]$')&#xA;  let ascii = char2nr(cntrl)&#xA;&#xA;  if ascii &amp;gt;= 1 &amp;amp;&amp;amp; ascii &amp;lt;= 26&#xA;    let letter = nr2char(ascii + 64)&#xA;    return '^'.letter&#xA;  else&#xA;    return ''&#xA;  endif&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a more straightforward way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I'm doing this in the first place is to check whether the given character appears in &lt;code&gt;'indentkeys'&lt;/code&gt;, e.g. &lt;code&gt;!^F&lt;/code&gt;, and should re-indent the current line instead of being inserted.&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2018-03-17T19:13:03.187" Title="Convert control-character (^F) to ascii string (&quot;^F&quot;)" Tags="|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15604" PostTypeId="2" ParentId="15603" CreationDate="2018-03-17T19:07:29.923" Score="1" Body="&lt;p&gt;Maybe you could use the &lt;code&gt;strtrans()&lt;/code&gt; function. From &lt;code&gt;:h strtrans()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The result is a String, which is {expr} with all unprintable&#xA;characters translated into printable characters |'isprint'|.&#xA;Like they are shown in a window.  Example:&#xA;        echo strtrans(@a)&#xA;This displays a newline in register a as &quot;^@&quot; instead of&#xA;starting a new line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As an example, you could try this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! CtrlCharStr(arg) abort&#xA;    return a:arg =~# '^[[:cntrl:]]$'&#xA;    \?         strtrans(a:arg)&#xA;    \:         ''&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or without continuation lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! CtrlCharStr(arg) abort&#xA;    return a:arg =~# '^[[:cntrl:]]$' ? strtrans(a:arg) : ''&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the argument passed to the function is a single control character, the function should return its caret notation.&#xA;Otherwise, it should return an empty string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;?:&lt;/code&gt; is a ternary operator used to build a conditional expression. The latter evaluates to different values depending on whether an arbitrary test succeeds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expr = test ? value1 : value2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;test&lt;/code&gt; is true, then &lt;code&gt;expr&lt;/code&gt; evaluates to &lt;code&gt;value1&lt;/code&gt;, otherwise to &lt;code&gt;value2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see &lt;code&gt;:h expr1&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16670" LastEditorUserId="16670" LastEditDate="2018-03-17T19:13:03.187" LastActivityDate="2018-03-17T19:13:03.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15605" PostTypeId="2" ParentId="15523" CreationDate="2018-03-17T19:42:04.787" Score="0" Body="&lt;p&gt;It seems that this may be related to &lt;code&gt;tmux&lt;/code&gt; and not &lt;code&gt;vim&lt;/code&gt;. I'm still not sure what happens but there is some combination of keys that results in the extra console like area to appear that captures all input, no matter where it's coming from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution for now is to press &lt;code&gt;&amp;lt;C-z&amp;gt;&lt;/code&gt; to suspend vim, the only key combination I found that doesn't seem to be captured, and then type &lt;code&gt;fg&lt;/code&gt; to bring back vim.&lt;/p&gt;&#xA;" OwnerUserId="12597" LastEditorUserId="12597" LastEditDate="2018-03-17T20:54:33.190" LastActivityDate="2018-03-17T20:54:33.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15606" PostTypeId="2" ParentId="4170" CreationDate="2018-03-17T21:35:03.443" Score="0" Body="&lt;p&gt;Based on &lt;a href=&quot;https://vi.stackexchange.com/users/8031/ms-kim&quot;&gt;ms-kim&lt;/a&gt; solution I have developed a slightly different variation that saves col postion.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DeleteLineAbove()&#xA;    if line('.') == 1&#xA;        echom &quot;You are at the first line!&quot;&#xA;        return&#xA;    endif&#xA;    let l:colsave = col(&quot;.&quot;)&#xA;    exec  &quot;normal! kdd&quot;&#xA;    call cursor(line(&quot;.&quot;), l:colsave)&#xA;endfunction&#xA;nnoremap &amp;lt;Leader&amp;gt;k :call DeleteLineAbove()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OBS: I have also used &lt;a href=&quot;https://stackoverflow.com/a/34370951/2571881&quot;&gt;this post&lt;/a&gt; as reference.&lt;/p&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2018-03-22T19:46:53.580" LastActivityDate="2018-03-22T19:46:53.580" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15607" PostTypeId="2" ParentId="15522" CreationDate="2018-03-18T04:26:49.017" Score="4" Body="&lt;p&gt;I found an answer, and apparently suspending the console doesn't work on Windows TUI as of yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/neovim/neovim/issues/6660&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neovim/neovim/issues/6660&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9885" LastActivityDate="2018-03-18T04:26:49.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15608" PostTypeId="1" AcceptedAnswerId="15614" CreationDate="2018-03-18T20:02:34.207" Score="6" ViewCount="2393" Body="&lt;p&gt;I would like to change the default green terminal statusline below to my usual colorscheme statusline color:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/L5Ooi.png&quot; alt=&quot;terminal_green_bar&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? There is no mention of it in &lt;code&gt;:h terminal&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7318" LastEditorUserId="7318" LastEditDate="2018-03-19T20:44:13.930" LastActivityDate="2018-03-19T20:44:13.930" Title="Is it possible to change the statusline color in Vim 8 terminal windows?" Tags="|terminal|terminal-buffer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15610" PostTypeId="2" ParentId="1942" CreationDate="2018-03-18T22:28:58.910" Score="4" Body="&lt;p&gt;I use the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Silent call SilentExec(&amp;lt;q-args&amp;gt;)&#xA;&#xA;function! SilentExec(cmd)&#xA;  let cmd = substitute(a:cmd, '^!', '', '')&#xA;  let cmd = substitute(cmd, '%', shellescape(expand('%')), '')&#xA;  call system(cmd)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can type the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Silent !your_command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This looks almost like Vim's built-in &lt;code&gt;silent !&lt;/code&gt; command, except for the capital &lt;code&gt;S&lt;/code&gt;. It even allows for an optional &lt;code&gt;!&lt;/code&gt; to make it look even more similar. The call to &lt;code&gt;system()&lt;/code&gt; makes the shell command truly silent: no screen flashes and no redraws.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(and if you ever need a status code, you can check the &lt;code&gt;v:shell_error&lt;/code&gt; variable, see help for more info)&lt;/p&gt;&#xA;" OwnerUserId="7318" LastActivityDate="2018-03-18T22:28:58.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15611" PostTypeId="1" AcceptedAnswerId="15612" CreationDate="2018-03-19T04:25:36.387" Score="0" ViewCount="139" Body="&lt;p&gt;I use the following code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LastModified()&#xA;  if &amp;amp;modified&#xA;    let save_cursor = getpos(&quot;.&quot;)&#xA;    let n = min([6, line(&quot;$&quot;)])&#xA;    keepjumps execute '&quot;1,&quot; . n . &quot;s#^% Modified:\zs.*# &quot; . strftime(&quot;%H:%M %A, %-d %B %Y&quot;) . &quot;#&quot;'&#xA;    call histdel('search', -2)&#xA;    keepjumps call setpos('.', save_cursor)&#xA;  endif&#xA;endfun&#xA;&#xA;autocmd BufWritePre *.tex call LastModified()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to automatically add a timestamp to latex files.  The top of my tex contain lines like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#xA;% Title:    ...some title...&#xA;% Author:   ...author...&#xA;% Modified:  8:31 Monday, 19 Mar 2018&#xA;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so the date at the end of the &lt;code&gt;Modified&lt;/code&gt; line should be updated to the current date and time. This used to work fine but for reasons I don't understand it stopped working a month or so ago. Can anyone see what the problem is? I am using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 18 2018 06:43:13)&#xA;macOS version&#xA;Included patches: 1-1522&#xA;Compiled by Homebrew&lt;/p&gt;&#xA;" OwnerUserId="14564" LastActivityDate="2018-03-19T05:25:00.600" Title="Automatically inserted timestamp no longer working" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15612" PostTypeId="2" ParentId="15611" CreationDate="2018-03-19T05:18:39.320" Score="1" Body="&lt;p&gt;The quoting of your &lt;code&gt;execute&lt;/code&gt; statement looks wrong. You don't need to quote the entire thing, just the strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;keepjumps exec ':1,' . n . 's#^% Modified:\zs.*# ' . strftime('%H:%M %A, %d %B %Y') . '#'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using single-quotes to ensure no unexpected expansions occur.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plus, the &lt;code&gt;strftime&lt;/code&gt; parameter &lt;code&gt;-%d&lt;/code&gt; also doesn't look right. (And, indeed, I get an error). I removed the &lt;code&gt;-&lt;/code&gt; here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% Modified: 22:27 Sunday, 18 March 2018&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-03-19T05:25:00.600" LastActivityDate="2018-03-19T05:25:00.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15613" PostTypeId="2" ParentId="15595" CreationDate="2018-03-19T07:07:34.720" Score="5" Body="&lt;p&gt;As I mentioned in my comments a session is associated with a single invocation of Vim so you can't do exactly what you're hoping to do. But I also mentioned something might be possible using shell scripts and Vim's &quot;clientserver&quot; functionality. I decided to chase that down...primarily for my own edification but since it works I figured I'd share it. (Your version of Vim must be compiled with &lt;code&gt;+clientserver&lt;/code&gt;.  Look at the output of &lt;code&gt;:version&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;These are rudimentary scripts. My goal is just to demonstrate the concept rather than build production-grade stuff.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;save_vim_sessions.sh&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash  &#xA;&#xA;# For each instance of Vim save the session in a common directory,&#xA;# save the files, and then quit Vim. You can run this from one of&#xA;# the Vim instances if you like, perhaps using a key mapping.&#xA;&#xA;SESSDIR=/tmp/vimsess&#xA;if [[ -d $SESSDIR ]]; then&#xA;    rm &quot;$SESSDIR&quot;/* 2&amp;gt; /dev/null&#xA;else&#xA;    mkdir -p &quot;$SESSDIR&quot;&#xA;    chmod 0777 &quot;$SESSDIR&quot;&#xA;fi&#xA;&#xA;for server in $(vim --serverlist); do&#xA;    vim --servername &quot;$server&quot; \&#xA;        --remote-send ':&amp;lt;c-u&amp;gt;mksession! $TMP/vimsess/%:t&amp;lt;cr&amp;gt;' \&#xA;        --remote-send ':wqa&amp;lt;cr&amp;gt;'&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the most part the &lt;code&gt;--remote-send&lt;/code&gt; parameters are self explanatory with the possible exception of &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; and &lt;code&gt;%:t&lt;/code&gt;. &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; sends &lt;code&gt;Ctrl-U&lt;/code&gt; which clears the Vim command line in case some text was already present. &lt;code&gt;%&lt;/code&gt; represents the file path/name loaded in the current buffer. &lt;code&gt;:t&lt;/code&gt; is a modifier that strips off the path and leaves just the name. For example, if you're editing &lt;code&gt;/foo/bar.txt&lt;/code&gt; the session will be saved in &lt;code&gt;/tmp/vimsess/bar.txt&lt;/code&gt;. It's a quick and dirty way to choose a &lt;em&gt;relatively&lt;/em&gt; unique name for the session file. (Remember this isn't production-grade.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;launch_vim_sessions.sh&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash  &#xA;&#xA;# Launch a vim session for each file in the common directory. &#xA;# The end result is to exactly restore everything closed by &#xA;# the other script.&#xA;&#xA;SESSDIR=/tmp/vimsess&#xA;if [[ ! -d $SESSDIR ]]; then&#xA;    echo &quot;Directory $SESSDIR not found&quot;&#xA;    exit 1&#xA;fi&#xA;&#xA;for sess in &quot;$SESSDIR&quot;/*; do&#xA;    vim -S &quot;$sess&quot; &amp;amp;&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes that &lt;code&gt;$TMP&lt;/code&gt; in Vim has value &lt;code&gt;/tmp&lt;/code&gt;. Update that and the directory in &lt;code&gt;SESSDIR&lt;/code&gt; as needed to match your own preferences and/or system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using command &lt;code&gt;vim&lt;/code&gt; here but that could just as well be &lt;code&gt;gvim&lt;/code&gt;...I tested it with GUI windows as opposed to terminal Vim (the question is about GUI vim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's it.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-03-21T02:01:43.963" LastActivityDate="2018-03-21T02:01:43.963" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15614" PostTypeId="2" ParentId="15608" CreationDate="2018-03-19T08:59:51.033" Score="8" Body="&lt;p&gt;The still somewhat new internal terminal implementation of Vim 8 uses the &lt;code&gt;StatusLineTerm&lt;/code&gt; highlighting group for the active window and the &lt;code&gt;StatusLineTermNC&lt;/code&gt; highlighting group for the statusline of an inactive window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you might want to tweak the corresponding highlighting groups like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi StatusLineTerm ctermbg=red ctermfg=black guibg=#ff0000 guifg=black&#xA;:hi StatusLineTermNC ctermbg=red ctermfg=darkblack guibg=darkred guifg=black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course use whatever looks good to your style :)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-03-19T08:59:51.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15615" PostTypeId="1" CreationDate="2018-03-19T11:03:22.397" Score="1" ViewCount="437" Body="&lt;p&gt;I have the following in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set expandtab &quot;Use soft tabs (spaces)&#xA;set shiftwidth=2 &quot;Set tab width = 2&#xA;set softtabstop=2 &quot;Set tab width = 2&#xA;set autoindent &quot;Set indent of previous line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I open another file which contains soft tabs of width 4 spaces, how can I make Vim to automatically set my tab also to 4 spaces, depending on the file. Currently, if I'm on a line which is indented 4 spaces and I press &lt;code&gt;o&lt;/code&gt; in normal mode, the cursor jumps to next line, but only 2 spaces from left.&lt;br&gt;&#xA;I also tried using &lt;code&gt;set smartindent&lt;/code&gt;, but doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="14996" LastActivityDate="2018-03-19T11:03:22.397" Title="Set tab width according to file" Tags="|indentation|tab-characters|" AnswerCount="0" CommentCount="2" ClosedDate="2018-03-19T14:07:34.533" ContentLicense="CC BY-SA 3.0" />
  <row Id="15616" PostTypeId="1" CreationDate="2018-03-19T20:16:32.113" Score="1" ViewCount="198" Body="&lt;p&gt;I usually have about 4 or 5 windows open in Vim. Currently - one of my files is very large(in size) - a CPU cache trace. Every time I search with &quot;/&quot;, vim searches all windows before returning the result which takes a very long time because vim tries to search the CPU trace. Is there any nifty feature to just have vim search my current window?&lt;/p&gt;&#xA;" OwnerUserId="16784" LastActivityDate="2018-03-19T20:16:32.113" Title="Disable regex searching in specific windows" Tags="|regular-expression|gvim|vim-windows|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15617" PostTypeId="1" AcceptedAnswerId="15622" CreationDate="2018-03-19T21:45:56.423" Score="0" ViewCount="619" Body="&lt;p&gt;Is there a way to preview js/html/css projects inside a browser, just like the &lt;a href=&quot;https://youtu.be/0Xy3yDDY4IE&quot; rel=&quot;nofollow noreferrer&quot;&gt;Atom-Live-Server&lt;/a&gt;. So, I am after a server-client way of doing this, I mean in realtime as the files are being edited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides Atom, Brackets IDE seems to be doing this, straight from their site:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Get a real-time connection to your browser. Make changes to CSS and&#xA;  HTML and you'll instantly see those changes on screen.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I have to admit, this is not purely a VIM question, however, I would love to know what would be considered as a good setup when using VIM for web development.&lt;/p&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="5328" LastEditDate="2018-03-20T13:22:01.670" LastActivityDate="2018-03-20T13:34:14.100" Title="Is there a workflow to preview javascript/html/css projects inside the browser?" Tags="|clientserver|filetype-javascript|" AnswerCount="2" CommentCount="2" ClosedDate="2018-03-20T14:22:14.023" ContentLicense="CC BY-SA 3.0" />
  <row Id="15618" PostTypeId="2" ParentId="15617" CreationDate="2018-03-19T23:10:43.613" Score="1" Body="&lt;p&gt;Atom is the only editor I know of that has that capability built-in. You'll need to bring in third party tools. I did some research on a related topic some time back as I was looking for real-time rendering of AsciiDoc markup as I typed it in (I write my work notes in AsciiDoc). The most viable editor-agnostic solution I saw was &lt;a href=&quot;http://livereload.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Live Reload&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This app watches specified files/directories on your file system and as you save changes to your js/css/whatever (e.g. from Vim) the file is preprocessed as needed and the browser window(s) refreshed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; &lt;em&gt;Alternatively&lt;/em&gt;, you could use an IDE like Intellij or Eclipse that has a Vim emulator. Obviously you get good real-time update capabilities with an IDE. And while emulators are an imperfect replacement for actual Vim if you're not too advanced of a user and not too picky about exact duplication of features it might work just fine for you.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-03-20T11:49:48.577" LastActivityDate="2018-03-20T11:49:48.577" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15619" PostTypeId="2" ParentId="9486" CreationDate="2018-03-19T23:27:41.923" Score="1" Body="&lt;p&gt;I'm using 32bit vim for compatibility with other extensions, but the 64 bit python is first on my PATH for other reasons.  Hence I &lt;a href=&quot;https://stackoverflow.com/a/17963884/1519199&quot;&gt;installed the 32 bit python using conda&lt;/a&gt; via:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set CONDA_FORCE_32BIT=1&#xA;conda create -n py27_32bit python=2.7&#xA;activate py27_32bit&#xA;pip install jedi&#xA;deactivate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and added this to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('win32')&amp;amp;&amp;amp; isdirectory('C:/Users/USER/AppData/Local/Continuum/anaconda2/envs/py27_32bit/')&#xA;    let $PATH = 'C:/Users/USER/AppData/Local/Continuum/anaconda2/envs/py27_32bit/;&#xA;                \C:/Users/USER/AppData/Local/Continuum/anaconda2/envs/py27_32bit/lib/;' . $PATH&#xA;    let $PYTHONPATH = 'C:/Users/USER/AppData/Local/Continuum/anaconda2/envs/py27_32bit/;&#xA;                \C:/Users/USER/AppData/Local/Continuum/anaconda2/envs/py27_32bit/DLLs/;&#xA;                \:/Users/USER/AppData/Local/Continuum/anaconda2/envs/py27_32bit/lib/;' &#xA;endif &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;C:/Users/USER/AppData/Local/Continuum/anaconda2&lt;/code&gt; is the result of calling &lt;code&gt;conda info --base&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16785" LastEditorUserId="16785" LastEditDate="2018-03-20T03:16:04.853" LastActivityDate="2018-03-20T03:16:04.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15620" PostTypeId="2" ParentId="15575" CreationDate="2018-03-20T10:01:53.517" Score="1" Body="&lt;p&gt;This is probaby what you want: &lt;code&gt;:imenu disable Help&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1782" LastActivityDate="2018-03-20T10:01:53.517" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15621" PostTypeId="2" ParentId="15575" CreationDate="2018-03-20T10:19:51.563" Score="1" Body="&lt;p&gt;Found a way: remove the menu bar &lt;code&gt;:set guioptions -=m&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks below link.&lt;br&gt;&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/13525518/how-to-hide-the-menu-tool-bar-of-gvim&quot;&gt;How to hide the menu/tool bar of gvim?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-03-20T10:19:51.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15622" PostTypeId="2" ParentId="15617" CreationDate="2018-03-20T13:34:14.100" Score="2" Body="&lt;p&gt;What you are looking for has nothing to do with Vim or any editor you are using, you want a tool like &lt;a href=&quot;https://gruntjs.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;grunt.js&lt;/a&gt;. Grunt is a task runner that you can configure to do a lot of things automatically, including serving your source files, watching them and reloading the changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are &lt;em&gt;a lot&lt;/em&gt; of resources online showing you how to do this and this would be out of the scope of this question but basically, you will need to&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Add grunt to your dev dependencies&lt;/li&gt;&#xA;&lt;li&gt;Create a &lt;code&gt;gruntfile.js&lt;/code&gt; in your project&lt;/li&gt;&#xA;&lt;li&gt;In this gruntfile declare which files to watch and how to serve your project&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;grunt serve&lt;/code&gt; to serve your project via a local web server.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After that it should be transparent: you will be able to modify your source code as you usually do and the changes should be live reloaded in your browser. This has the huge advantage of being editor/IDE agnostic and easily replicable when you work in a team.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;a href=&quot;https://www.thecrumb.com/2014/03/15/using-grunt-for-live-reload/&quot; rel=&quot;nofollow noreferrer&quot;&gt;gulp.js&lt;/a&gt; should be able to do the same but I personally never used it before.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-03-20T13:34:14.100" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15624" PostTypeId="1" AcceptedAnswerId="15625" CreationDate="2018-03-20T16:59:32.603" Score="0" ViewCount="532" Body="&lt;p&gt;I recently installed &lt;a href=&quot;https://github.com/junegunn/fzf&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf&lt;/a&gt; CLI fuzzy search utility, and the accompanying &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf.vim&lt;/a&gt; file with it.  They both work great, and I have been enjoying my experience with them thus far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'd like to keep the default key bindings of &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt; and &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;k&lt;/kbd&gt; to move up and down through things like the buffer list when invoking fzf within vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I tend to use Neovim / Vim within tmux sessions quite frequently, and I have &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt; and &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;k&lt;/kbd&gt; to move about the various panes within a tmux window, thus not allowing me to move about the buffers list presented by fzf.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does Vim / Neovim support a &quot;contextual key binding&quot;?  &lt;em&gt;Not sure if that is what it should be called or not&lt;/em&gt;&quot;, but basically I'd like to have &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt; work within fzf when a buffer list &quot;window / modal&quot; is present, and then also work to move about tmux panes when the buffer list presented by fzf is not present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I'd like to have my cake  and eat it  at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;fzf can be brought up within the context of the Vim &lt;code&gt;command mode&lt;/code&gt;, I hope that helps clarify things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, forgot to mention I'm using &lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-tmux-navigator&lt;/a&gt; to seamlessly switch between panes from a Vim session and those of a tmux session. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is a picture of what I attempted to describe above using words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0oIEh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0oIEh.png&quot; alt=&quot;fzf-context-within-vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;cheers &lt;br /&gt;&#xA;Chris&lt;/p&gt;&#xA;" OwnerUserId="10550" LastEditorUserId="10550" LastEditDate="2018-03-20T17:22:25.387" LastActivityDate="2018-03-20T17:25:57.380" Title="Contextual key bindings when a specific context menu is open" Tags="|neovim|vim-windows|plugin-fzf|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15625" PostTypeId="2" ParentId="15624" CreationDate="2018-03-20T17:20:31.227" Score="1" Body="&lt;p&gt;I have the following lines in my &lt;code&gt;~.tmux.conf&lt;/code&gt;, and they allow me to continue to use &lt;kbd&gt;Ctrl-H&lt;/kbd&gt;, &lt;kbd&gt;Ctrl-J&lt;/kbd&gt;, &lt;kbd&gt;Ctrl-K&lt;/kbd&gt;, and &lt;kbd&gt;Ctrl-L&lt;/kbd&gt; for navigation within Vim (between windows and also between CtrlP results), and yet also use them for navigating between tmux panes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# smart pane switching with awareness of vim splits and of emacs (but not emacs splits)&#xA;bind-key -n C-h run &quot;(tmux display-message -p '#{pane_current_command}' | grep -iqE '(vim|emacs)' &amp;amp;&amp;amp; tmux send-keys C-h) || tmux select-pane -L&quot;&#xA;bind-key -n C-j run &quot;(tmux display-message -p '#{pane_current_command}' | grep -iqE '(vim|emacs)' &amp;amp;&amp;amp; tmux send-keys C-j) || tmux select-pane -D&quot;&#xA;bind-key -n C-k run &quot;(tmux display-message -p '#{pane_current_command}' | grep -iqE '(vim|emacs)' &amp;amp;&amp;amp; tmux send-keys C-k) || tmux select-pane -U&quot;&#xA;bind-key -n C-l run &quot;(tmux display-message -p '#{pane_current_command}' | grep -iqE '(vim|emacs)' &amp;amp;&amp;amp; tmux send-keys C-l) || tmux select-pane -R&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A quick google suggests that &lt;a href=&quot;https://gist.github.com/mislav/5189704&quot; rel=&quot;nofollow noreferrer&quot;&gt;I stole the idea from here&lt;/a&gt;, although I bear sole responsibility for the addition of the half-completed support for emacs.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-20T17:25:57.380" LastActivityDate="2018-03-20T17:25:57.380" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15626" PostTypeId="1" AcceptedAnswerId="15627" CreationDate="2018-03-20T22:56:41.267" Score="1" ViewCount="748" Body="&lt;p&gt;How to disable the command key in Vim in Mac?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I accidentally press command + w and close the view or command + p and print opens up, it is super annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't find any reference on this matter on Google. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;" OwnerUserId="15642" LastEditorUserId="51" LastEditDate="2018-03-20T23:21:23.017" LastActivityDate="2018-03-21T01:49:55.023" Title="How to disable the command key in Vim in Mac?" Tags="|key-bindings|macos|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15627" PostTypeId="2" ParentId="15626" CreationDate="2018-03-21T01:49:55.023" Score="2" Body="&lt;p&gt;If, by 'Vim in Mac', you mean MacVim as opposed to simply running vim in a terminal emulator on Mac, then you're going to run into some problems with vim having certain expectations, and MacOS having certain expectations regarding the menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't care about having 'Close Window' and 'Print' in your menu at all, you can add lines like &lt;code&gt;:aunmenu File.Close\ Window&lt;/code&gt; and &lt;code&gt;:aunmenu File.Print&lt;/code&gt; (&lt;code&gt;:help aunmenu&lt;/code&gt;) to your &lt;code&gt;.vimrc&lt;/code&gt; or &lt;code&gt;.gvimrc&lt;/code&gt;. If you still want them in the menu, there's a half-solution that involves both vim and MacOS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MacOS allows you to arbitrarily set keyboard shortcuts to perform menu items in an application. Vim allows you to both create menu items that do anything, and includes nothing as one of those possible actions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;.vimrc&lt;/code&gt; or &lt;code&gt;.gvimrc&lt;/code&gt;, you'll need to define a menu item for the &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt; mapping (&lt;code&gt;:help &amp;lt;Nop&amp;gt;&lt;/code&gt;). I'd probably put it in Tools, with the &lt;code&gt;.vimrc&lt;/code&gt; entry &lt;code&gt;:amenu Tools.NOP &amp;lt;Nop&amp;gt;&lt;/code&gt;. Doing this, and either restarting MacVim or sourcing the dotfile should show a NOP command in the Tools menu. Click it, it should do nothing. &lt;code&gt;:amenu&lt;/code&gt; ensures that it's present in all modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, on the MacOS side, you'll need to open System Preferences, go to the Keyboard preference pane, go to the Shortcuts tab, choose App Shortcuts from the list on the left, and then press the plus button on the list on the right to start overwriting the default shortcuts. MacVim may not show up in the Application list, you may need to find it by choosing 'Other...'. For Menu Title, just enter NOP (or whatever you called it — but you only need the name of the entry itself, not what menu it's in). Finally, hit Cmd-W for Keyboard Shortcut. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we run into why this is a half-solution — any given menu item can only have one keyboard shortcut. You could, if you wish, create NOP1, NOP2, etc. It starts to feel more and more like a hack, but it should work. &lt;/p&gt;&#xA;" OwnerUserId="14684" LastActivityDate="2018-03-21T01:49:55.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15628" PostTypeId="1" CreationDate="2018-03-21T10:07:28.487" Score="4" ViewCount="922" Body="&lt;p&gt;&lt;code&gt;gf&lt;/code&gt; runs fine with absolute or relative path.&lt;br&gt;&#xA;Is it possible to open a file with variable in the path?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in a tcl file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;set FILE_ROOT /user/abc&#xA;...   &#xA;read_file ${FILE_ROOT}/some/path/abc.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to open ${FILE_ROOT}/some/path/abc.txt inside vim?&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2022-10-27T19:40:07.033" Title="How to open a file with variable in the path?" Tags="|variables|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15630" PostTypeId="1" AcceptedAnswerId="15634" CreationDate="2018-03-21T14:45:10.727" Score="9" ViewCount="5315" Body="&lt;p&gt;I'm using gnome-terminal, which uses 7-bit input. This means Vim's meta/alt keys, e.g. &lt;code&gt;&amp;lt;M-f&amp;gt;&lt;/code&gt; don't work without some extra configuration. I know how to set that up for normal keys, like &lt;kbd&gt;F&lt;/kbd&gt;, but not for &lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I press &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;F&lt;/kbd&gt; the terminal sends &lt;code&gt;^[&lt;/code&gt; &lt;code&gt;F&lt;/code&gt;, where the &lt;code&gt;^[&lt;/code&gt; is a single Escape byte (&lt;code&gt;\x1b&lt;/code&gt;). I can make &lt;code&gt;&amp;lt;M-f&amp;gt;&lt;/code&gt; usable by doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set  &amp;lt;F13&amp;gt;=^[f&#xA;map  &amp;lt;F13&amp;gt; &amp;lt;M-f&amp;gt;&#xA;map! &amp;lt;F13&amp;gt; &amp;lt;M-f&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do this for the Enter key (&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2018-03-22T03:11:28.200" Title="How to map Alt-Enter" Tags="|key-bindings|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15631" PostTypeId="1" AcceptedAnswerId="15632" CreationDate="2018-03-21T22:03:09.153" Score="3" ViewCount="1975" Body="&lt;p&gt;If I'm at file &lt;code&gt;/a/b/c/foo.txt&lt;/code&gt;, I'd like the statusline to display &lt;code&gt;c/foo.txt&lt;/code&gt;. Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason for this is that for web development, too many files are named &lt;code&gt;index.js&lt;/code&gt; to make just the tail useful, while the full path (or relative path) is too long to make it easy to parse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only relevant statusline options I see are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%f&lt;/code&gt; which is the path relative to the current directory&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%F&lt;/code&gt; the full path to the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%t&lt;/code&gt; only the filename (tail).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2512" LastActivityDate="2018-03-21T23:34:49.600" Title="Show filename tail and parent directory in statusline" Tags="|statusline|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15632" PostTypeId="2" ParentId="15631" CreationDate="2018-03-21T23:34:49.600" Score="6" Body="&lt;p&gt;You can include arbitrary expressions in your status line with &lt;code&gt;%{}&lt;/code&gt;. Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set statusline=%{expand('%:p:h:t')}/%t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This finds the tail of the head of the full path (i.e. just the parent directory) and then tacks on filename using the &lt;code&gt;%t&lt;/code&gt; item you already mentioned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help expand()&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-03-21T23:34:49.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15633" PostTypeId="1" AcceptedAnswerId="15637" CreationDate="2018-03-22T00:50:48.017" Score="2" ViewCount="1237" Body="&lt;p&gt;I set a couple terminal options so that Vim changes the cursor shape to a vertical bar when I enter Insert mode, an underbar for Replace mode, and a block when I return to Normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;t_SI=&quot;\&amp;lt;Esc&amp;gt;[6 q&quot;&#xA;let &amp;amp;t_SR=&quot;\&amp;lt;Esc&amp;gt;[4 q&quot;&#xA;let &amp;amp;t_EI=&quot;\&amp;lt;Esc&amp;gt;[0 q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;'ttimeoutlen'&lt;/code&gt; has a high enough setting, there's a noticeable delay when leaving Insert mode, because you type &lt;kbd&gt;Escape&lt;/kbd&gt; and Vim waits to see if it was the beginning of an &lt;code&gt;&amp;lt;Esc&amp;gt;[0 q&lt;/code&gt; sequence. It waits &lt;code&gt;'ttimeoutlen'&lt;/code&gt; milliseconds before deciding the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; was an actual &lt;kbd&gt;Escape&lt;/kbd&gt; keypress.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I usually keep &lt;code&gt;'ttimeoutlen'&lt;/code&gt; set at 5, so it's not really noticeable. But I was also curious to try a &quot;sledgehammer&quot; workaround:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Esc&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it works. Even more interesting is this works as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Esc&amp;gt; &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess because Vim knows the right-hand-side of a mapping is the result of a keypress, not an input keycode, so it doesn't apply &lt;code&gt;'ttimeoutlen'&lt;/code&gt; (but would apply &lt;code&gt;'timoutlen'&lt;/code&gt; if you had other &lt;code&gt;imap&lt;/code&gt;s that started with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems a little weird, but I'm having a hard time thinking of any downside this approach could have. I plan on keeping my &lt;code&gt;'ttimeoutlen'&lt;/code&gt; low anyway, but maybe this could shave a couple extra milliseconds off the delay? Not that I'll actually notice :P&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any reason not to do this? What could it break?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is there a better solution altogether that I've missed? I suspect the answer is to just leave &lt;code&gt;'ttimeoutlen'&lt;/code&gt; set to a low number and forget about it, but I am curious if anyone else has found different solutions.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Update&lt;/em&gt;:&#xA;I found a caveat to this approach. The &lt;code&gt;imap&lt;/code&gt; effects escaping from Insert and Replace modes, and you can do the same for Visual mode with &lt;code&gt;vmap&lt;/code&gt;, but none of these affects the timeout when canceling an &lt;code&gt;r&lt;/code&gt; command in Normal mode using &lt;kbd&gt;Escape&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It still seems like a useful hack -- escaping from an &lt;code&gt;r&lt;/code&gt; command is a corner case -- but it's not a full solution.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Update-2&lt;/em&gt;: I found what this breaks. If you want to use a Meta/Alt key in an &lt;code&gt;imap&lt;/code&gt;, e.g. &lt;code&gt;inoremap &amp;lt;M-d&amp;gt; foo&lt;/code&gt;, the &lt;code&gt;inoremap &amp;lt;Esc&amp;gt; &amp;lt;Esc&amp;gt;&lt;/code&gt; breaks that functionality because &lt;code&gt;&amp;lt;M-d&amp;gt;&lt;/code&gt; consists of an Escape byte (&lt;code&gt;0x1b&lt;/code&gt;) followed by the D byte. To take it to the extreme, imagine you'd defined a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;M-d&amp;gt;d bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;&amp;lt;M-d&amp;gt;d&lt;/code&gt; in insert mode would end up deleting the current line! That's a corner case, but mapping Meta/Alt keys is not, so this is enough to convince me that &lt;code&gt;imap&lt;/code&gt;ping &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to itself is a bad idea. It is, after all, a hack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above won't apply if your terminal runs in 8-bit mode, since Alt/Meta will be represented by the high-bit instead of a leading Esc byte, but on 7-bit terminals (gnome-terminal, alacritty, etc.) it does apply.&lt;/p&gt;&#xA;" OwnerUserId="1855" LastEditorUserId="1855" LastEditDate="2018-03-22T13:03:15.953" LastActivityDate="2018-03-22T14:30:37.837" Title="Delayed esc from insert mode caused by cursor-shape terminal sequence" Tags="|terminal|cursor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15634" PostTypeId="2" ParentId="15630" CreationDate="2018-03-22T02:22:26.840" Score="12" Body="&lt;p&gt;On many terminals (specifically the ones that send alt-modified keys as &lt;code&gt;escape&lt;/code&gt; then &lt;code&gt;key&lt;/code&gt;), you can map alt+enter in the same way as many other alt combinations,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;a-cr&amp;gt;=^[^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is two characters- escape then control m.  Alternatively,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;set &amp;lt;a-cr&amp;gt;=\&amp;lt;esc&amp;gt;\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can then use &lt;code&gt;&amp;lt;a-cr&amp;gt;&lt;/code&gt; in maps;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;a-cr&amp;gt; something&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no standard way to map &lt;code&gt;alt+shift+enter&lt;/code&gt;, or indeed any other &lt;code&gt;alt+shift+&lt;/code&gt; combination.  Also, if your terminal supports it, you will have to use one of the unused F keys, e.g. &lt;code&gt;&amp;lt;f13&amp;gt;&lt;/code&gt; through &lt;code&gt;&amp;lt;f37&amp;gt;&lt;/code&gt; on linux (since there's no &lt;code&gt;&amp;lt;s-c-cr&amp;gt;&lt;/code&gt; key code in vim) set to your terminal's proprietary escape sequence.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;f25&amp;gt;=...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, my terminal sends escape, escape, then OM (four characters):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;f25&amp;gt;=^[^[OM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-03-22T03:11:28.200" LastActivityDate="2018-03-22T03:11:28.200" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15635" PostTypeId="1" AcceptedAnswerId="15636" CreationDate="2018-03-22T11:44:56.197" Score="2" ViewCount="555" Body="&lt;p&gt;I'm trying to create a new custom colorscheme and syntax highlighting. I have copied some examples into ~/.vim/colors/ and ~/.vim/syntax with new names inside for the scheme. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the basics work fine, so happy with the files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to get some custom colour comments working, rather than just a single one, so something similar to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# = Normal comment&#xA;##1 = Red&#xA;##2 = Dark Red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my colorscheme I have (that I can't get working)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Comment term=bold ctermfg=4 guifg=#406090&#xA;hi Comment1 term=bold ctermfg=4 guifg=#a00000&#xA;hi Comment2 term=bold ctermfg=4 guifg=#800000&#xA;&quot;&quot; I want to reference these&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my syntax file I have...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HiLink perlComment            Comment&#xA;HiLink perlComment1           Conditional&#xA;HiLink perlComment2           String&#xA;&#xA;&#xA;syn match  perlComment          &quot;#.*&quot; contains=perlTodo&#xA;syn match  perlComment1         &quot;##1.*&quot; contains=perlTodo&#xA;syn match  perlComment2         &quot;##2.*&quot; contains=perlTodo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This partly works, in that I can get the unique comment highlighting working, but ONLY if I match it to a String/Conditional/Comment, i.e an already established 'keyword' or colorshceme or something (not sure what the term is here).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I was thinking I could do something like...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HiLink perlComment2 Comment2 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To match the earlier colorscheme settings (but this doesn't work, I can't seem to reflect changes from the colorscheme file), so I'm likely misunderstanding what's happening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to create a custom term like String/Conditional that would match in the colorscheme ? I think I'm missing a link somewhere.&lt;/p&gt;&#xA;" OwnerUserId="15949" LastEditorUserId="15949" LastEditDate="2018-03-22T11:59:07.813" LastActivityDate="2018-04-21T13:59:24.457" Title="How to add a new colorscheme syntax keyword" Tags="|syntax-highlighting|colorscheme|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15636" PostTypeId="2" ParentId="15635" CreationDate="2018-03-22T13:24:09.393" Score="0" Body="&lt;p&gt;I was an idiot thinking that the colorscheme was using guifg, when in my case it was using ctermfg, so when I started changing that in the colorscheme, all worked fine. So I just needed...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Comment1 term=bold cterm=bold ctermfg=205&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As an example, the rest was fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to Rich for the help in getting there.&lt;/p&gt;&#xA;" OwnerUserId="15949" LastActivityDate="2018-03-22T13:24:09.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15637" PostTypeId="2" ParentId="15633" CreationDate="2018-03-22T14:30:37.837" Score="2" Body="&lt;p&gt;This has nothing to do with the cursor shaping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole reason the timeout settings exist is for the reason you found out in &lt;code&gt;Update-2&lt;/code&gt; -- some keys that you type send a byte sequence that starts with an &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;.  This includes alt mappings, arrow keys, function keys, mouse interaction, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since most terminals aren't running in 8-bit mode, you're going to encounter a delay when typing &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;.  Of course, nothing requires you to wait for that delay.  If you just continue typing, you'll perform the same disambiguation that Vim is waiting for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since 8-bit mode isn't typical, it follows that mapping &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; is a terrible idea.  That's going to interfere with more than just &lt;code&gt;&amp;lt;Alt-...&amp;gt;&lt;/code&gt; mappings.  The common workaround is to do exactly as you've suggested and reduce the timeout.  This has even been &lt;a href=&quot;https://github.com/vim/vim/commit/e07e797db0c5ef1aafc650d8bb0d39fb052cf1e1&quot; rel=&quot;nofollow noreferrer&quot;&gt;adopted&lt;/a&gt; in defaults.vim.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2018-03-22T14:30:37.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15638" PostTypeId="1" AcceptedAnswerId="15640" CreationDate="2018-03-22T14:38:29.917" Score="0" ViewCount="119" Body="&lt;p&gt;Suppose I have this (where my insertion point is designated &quot;|&quot;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;col1           col2&#xA;&#xA;thing          oeueaoue|&#xA;another&#xA;something&#xA;test&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What keystroke(s) would I use so the insertion point jumps to here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;col1           col2&#xA;&#xA;thing          oeueaoue&#xA;another        |&#xA;something&#xA;test&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is &lt;kbd&gt;return&lt;/kbd&gt;+&lt;kbd&gt;A&lt;/kbd&gt;+&lt;kbd&gt;tab&lt;/kbd&gt;… (normal mode) the only way?&lt;/p&gt;&#xA;" OwnerUserId="5224" LastActivityDate="2018-03-22T22:52:59.830" Title="Vim: Aligning insertion point with left side of column" Tags="|key-bindings|indentation|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15639" PostTypeId="1" AcceptedAnswerId="15644" CreationDate="2018-03-22T15:12:29.773" Score="1" ViewCount="418" Body="&lt;p&gt;When you want to leave insert mode, it's possible to avoid to trigger the &lt;code&gt;InsertLeave&lt;/code&gt; event by &#xA;pressing &lt;kbd&gt;Ctrl-C&lt;/kbd&gt; instead of &lt;kbd&gt;Esc&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I try to use this method inside an insert mapping, it still triggers the event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in a new buffer, let's run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au InsertLeave &amp;lt;buffer&amp;gt; call append('$', 'InsertLeave was triggered')&#xA;:imap &amp;lt;buffer&amp;gt; &amp;lt;cr&amp;gt; &amp;lt;c-c&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then if you press the (mapped) &lt;kbd&gt;return&lt;/kbd&gt; key in order to exit insert mode, despite the use of &lt;code&gt;&amp;lt;c-c&amp;gt;&lt;/code&gt; in the mapping &#xA;definition, you can see that the &lt;code&gt;InsertLeave&lt;/code&gt; event is triggered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do to avoid the trigger of this event? The use of &lt;code&gt;:noautocmd&lt;/code&gt; does not help as well, &#xA;since we need to leave insert mode first to use this command.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;EDIT (explanations)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To explain the aim of my question: I want to write a tiny plugin which would allow to easily edit &#xA;several lines at the &lt;em&gt;same start column&lt;/em&gt;, by hitting the return key. This 'table mode' should be togglable&#xA;by hitting a quick shortkey in insert mode. For example, this kind of situation is quite usual:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; The following strings need to be filled with something:&#xA;var1 = &quot;&quot;&#xA;var2 = &quot;&quot;&#xA;var3 = &quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The plugin looks pretty easy to write... But :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When my 'table mode' is active, I want that when leaving insert mode (by pressing &lt;kbd&gt;Esc&lt;/kbd&gt;, or &lt;em&gt;any&lt;/em&gt; other way, like the plugin &#xA;&lt;code&gt;vim-easyescape&lt;/code&gt; - so remapping &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; is not an answer), then my 'table mode' just simply cancels and unmaps the return key.&#xA;So, I added an autocommand for the &lt;code&gt;InsertLeave&lt;/code&gt; event, which cancels all the stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But my mapping for the &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; key (aka the main feature) &lt;strong&gt;does trigger this event&lt;/strong&gt; as well (because it needs to go to normal mode, in order to move to the right position),&#xA;then it cancels my 'table mode' after the first press of the return key. I don't want this at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum it up, I need to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Cancel my 'table mode' each time insert mode is leaving&lt;/li&gt;&#xA;&lt;li&gt;Make an exception for the &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; mapping, which needs to go to normal mode to execute the &lt;code&gt;[count]|&lt;/code&gt; command, without cancelling anything.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is the code I started to write, with some comments about the issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:is_active = v:false&#xA;&#xA;&#xA;function! tablemode#activate()&#xA;    if s:is_active&#xA;        return&#xA;    endif&#xA;    let s:is_active = v:true&#xA;&#xA;    let s:start_col = virtcol('.')&#xA;&#xA;    &quot; Not needed for this question, running &quot;:set ve=all&quot; is enough:&#xA;    &quot; call _#set_temp_option('virtualedit', 'all')&#xA;&#xA;    exe printf(&quot;inoremap &amp;lt;buffer&amp;gt; &amp;lt;cr&amp;gt; &amp;lt;c-c&amp;gt;j%s&amp;lt;bar&amp;gt;i&quot;, s:start_col)&#xA;    &quot; !!! Even when using &amp;lt;c-c&amp;gt; instead of &amp;lt;esc&amp;gt;, the InsertLeave event&#xA;    &quot; is triggered, then cancels everything, which is not wanted at all&#xA;&#xA;    augroup tablemode&#xA;        au!&#xA;&#xA;        au InsertLeave &amp;lt;buffer&amp;gt; call tablemode#desactivate()&#xA;        &quot; !!! This line is needed, but the &amp;lt;cr&amp;gt; mapping will&#xA;        &quot; not work as expected (unless you comment this :au command)&#xA;    augroup END&#xA;endf&#xA;&#xA;&#xA;function! tablemode#desactivate()&#xA;    if !s:is_active&#xA;        return&#xA;    endif&#xA;    let s:is_active = v:false&#xA;&#xA;    &quot; Not needed for this question (restores old option state):&#xA;    &quot; call _#restore_option('virtualedit')&#xA;&#xA;    iunmap &amp;lt;buffer&amp;gt; &amp;lt;cr&amp;gt;&#xA;    augroup tablemode&#xA;        au!&#xA;    augroup END&#xA;endf&#xA;&#xA;&#xA;function! tablemode#toggle()&#xA;    if s:is_active&#xA;        call tablemode#desactivate()&#xA;    else&#xA;        call tablemode#activate()&#xA;    endif&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's a mapping example, in order to test my script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap &amp;lt;c-b&amp;gt; &amp;lt;c-o&amp;gt;:call tablemode#toggle()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5516" LastEditorUserId="5516" LastEditDate="2018-03-22T22:36:19.353" LastActivityDate="2018-03-23T14:34:14.667" Title="How to not trigger InsertLeave inside an imap?" Tags="|key-bindings|autocmd|insert-mode|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15640" PostTypeId="2" ParentId="15638" CreationDate="2018-03-22T17:16:24.463" Score="0" Body="&lt;p&gt;from &lt;a href=&quot;https://stackoverflow.com/a/49431508/1429450&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When there are many lines to edit, it can be useful to map the return&#xA;  key temporarily, something like that in your case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;buffer&amp;gt; &amp;lt;cr&amp;gt; &amp;lt;esc&amp;gt;jA&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;When you're done, just cancel the map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iunmap &amp;lt;buffer&amp;gt; &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5224" LastActivityDate="2018-03-22T17:16:24.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15641" PostTypeId="2" ParentId="15638" CreationDate="2018-03-22T22:22:38.997" Score="1" Body="&lt;p&gt;You can use &lt;a href=&quot;https://github.com/godlygeek/tabular&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:Tabularize&lt;/code&gt;&lt;/a&gt; to do this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Tabularize /\s\+\zs/l1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are plenty of other alignment plugins. e.g. &lt;a href=&quot;https://github.com/junegunn/vim-easy-align&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-easy-align&lt;/a&gt; and &lt;a href=&quot;https://github.com/tommcdo/vim-lion&quot; rel=&quot;nofollow noreferrer&quot;&gt;lion.vim&lt;/a&gt;. I would recommend installing an alignment tool if this becomes common. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want it automated then you can do something similar to Tim Pope's &lt;a href=&quot;https://gist.github.com/tpope/287147&quot; rel=&quot;nofollow noreferrer&quot;&gt;cucumbertables.vim&lt;/a&gt;. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;space&amp;gt;   &amp;lt;space&amp;gt;.&amp;lt;Esc&amp;gt;:call &amp;lt;SID&amp;gt;align()&amp;lt;CR&amp;gt;&quot;_s&#xA;&#xA;function! s:align()&#xA;  let p = '^\%(\w\+\s\+\)\+\w\+$'&#xA;  if exists(':Tabularize') &amp;amp;&amp;amp; getline('.') =~# '^\w\+\s' &amp;amp;&amp;amp; (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)&#xA;    let column = strlen(substitute(substitute(getline('.')[0:col('.')],'\S\+','.','g'), '\s*', '', 'g'))&#xA;    Tabularize/\s\+\zs/l1&#xA;    normal! 0&#xA;    call search(repeat('\w\+\s\+',column-1) . '.', 'ce', line('.'))&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I have not fully tested this code. Use as is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend this to be a buffer local mapping. See &lt;code&gt;:h map-local&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Want a more native/simpler approach? Use &lt;code&gt;&amp;lt;c-y&amp;gt;&lt;/code&gt; to copy a character right above the current location. You can simply spam &lt;code&gt;&amp;lt;c-y&amp;gt;&lt;/code&gt; until you have your whitespace alignment. See &lt;code&gt;:h i_CTRL-y&lt;/code&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-03-22T22:52:59.830" LastActivityDate="2018-03-22T22:52:59.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15642" PostTypeId="1" AcceptedAnswerId="15643" CreationDate="2018-03-23T06:54:01.930" Score="1" ViewCount="1870" Body="&lt;p&gt;I have &lt;code&gt;inoremap jj &amp;lt;ESC&amp;gt;&lt;/code&gt; in my &lt;code&gt;vimrc&lt;/code&gt; on my &lt;code&gt;Ubuntu 16.04&lt;/code&gt;. I have no idea why my &lt;code&gt;jj&lt;/code&gt; not working and its just typing literally &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; in my text file for my &lt;code&gt;jj&lt;/code&gt; press.&lt;br/&gt;&#xA;&lt;br/&gt;Any idea how can I get around this?&lt;br/&gt;My full &lt;code&gt;vimrc&lt;/code&gt;:&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map j gj&#xA;map k gk&#xA;&#xA;set smartindent&#xA;set nowritebackup  &#xA;set noswapfile     &#xA;set nobackup&#xA;&#xA;colo delek&#xA;inoremap jj &amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7332" LastActivityDate="2018-03-23T10:25:19.053" Title="&lt;Esc&gt; key mapping seems to be not working in my vim 8.0 on my Ubuntu 16.04" Tags="|vimrc|linux-ubuntu|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15643" PostTypeId="2" ParentId="15642" CreationDate="2018-03-23T09:15:46.753" Score="2" Body="&lt;p&gt;At the beginning of your vimrc (before your mappings), you should add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will change many behaviours inside vim  (see help), and will certainly solve your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a &lt;a href=&quot;https://superuser.com/questions/328167/map-function-keys-like-cr-in-vim-on-cygwin&quot;&gt;similar question&lt;/a&gt; on SuperUser.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this solution works, however it means that the &lt;code&gt;compatible&lt;/code&gt; option has not been automatically unset by &#xA;Vim, which however should happen in most cases (see &lt;code&gt;:h compatible-default&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It probably means that you're not using a &lt;em&gt;user&lt;/em&gt; vimrc configuration file, like &lt;code&gt;~/.vimrc&lt;/code&gt;. In this &#xA;case, Vim would unset the &lt;code&gt;compatible&lt;/code&gt; option automatically. So a better solution would be to put&#xA;your configuration in such a file (see &lt;code&gt;:h .vimrc&lt;/code&gt; for other possible names that Vim will be able&#xA;to detect).&lt;/p&gt;&#xA;" OwnerUserId="5516" LastEditorUserId="5516" LastEditDate="2018-03-23T10:25:19.053" LastActivityDate="2018-03-23T10:25:19.053" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15644" PostTypeId="2" ParentId="15639" CreationDate="2018-03-23T12:49:48.213" Score="1" Body="&lt;p&gt;You could try adding a guard:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Are we currently within a &amp;lt;CR&amp;gt; press?&#xA;let s:in_cr = v:false&#xA;&#xA;function! tablemode#deactivate()&#xA;    if !s:in_cr&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; Deactivate stuff&#xA;    ...&#xA;endfunction&#xA;&#xA;function! tablemode#my_cr_wrapper()&#xA;    &quot; At this point, we are still in insert mode&#xA;    let s:in_cr = v:true&#xA;&#xA;    &quot; Exit insert mode and call the real function&#xA;    return &quot;\&amp;lt;Esc&amp;gt;:call tablemode#my_cr()\&amp;lt;CR&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;function! tablemode#my_cr()&#xA;    &quot; Do what you need to do&#xA;    ...&#xA;&#xA;    &quot; Re-enable the autocommand&#xA;    let s:in_cr = v:false&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; tablemode#my_cr_wrapper()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. I haven't tried running the code above. There may be minor errors/typos you need to fix, but it should give you the idea.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't edit the buffer or persistently move the cursor inside the expression mapping (see &lt;code&gt;:help :map-expression&lt;/code&gt;), but you &lt;em&gt;can&lt;/em&gt; include keystrokes which do so in your return value. Therefore, depending on how complicated your &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; mapping actually is, you might not need the second &lt;code&gt;my_cr()&lt;/code&gt; function at all, including everything in the &lt;code&gt;my_cr_wrapper()&lt;/code&gt; return value.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-03-23T12:49:48.213" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15645" PostTypeId="2" ParentId="15639" CreationDate="2018-03-23T14:34:14.667" Score="1" Body="&lt;p&gt;Embrace &lt;code&gt;InsertLeave&lt;/code&gt; instead of trying to avoid it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup TableMode&#xA;    autocmd!&#xA;    autocmd InsertLeave *&#xA;                \ if get(g:, 'table_mode', 0) |&#xA;                \   let g:table_mode = 0 |&#xA;                \   execute &quot;normal! \&amp;lt;cr&amp;gt; &quot; |&#xA;                \   call search('&quot;', 'e', line('.')+1) |&#xA;                \   call feedkeys('a', 't') |&#xA;                \ endif&#xA;augroup END&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; &amp;lt;SID&amp;gt;advance()&#xA;&#xA;function! s:advance()&#xA;    let pat = '&quot;[^&quot;]*&quot;'&#xA;    if getline('.') =~ pat &amp;amp;&amp;amp; strpart(getline('.'), 0, col('.')) =~ '^[^&quot;]*&quot;[^&quot;]*' &amp;amp;&amp;amp; getline(line('.')+1) =~ pat&#xA;        let g:table_mode = 1&#xA;        return &quot;\&amp;lt;esc&amp;gt;&quot;&#xA;    else&#xA;        let g:table_mode = 0&#xA;        return &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The secret sauce here is to use &lt;code&gt;feedkeys()&lt;/code&gt; to start back into insert mode after the &lt;code&gt;InsertLeave&lt;/code&gt; autocmd event. Map &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to determine if &quot;table mode&quot; should be active for the next line, otherwise just use &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h feedkeys()&#xA;:h :map-expression&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-03-23T14:34:14.667" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15646" PostTypeId="1" AcceptedAnswerId="15647" CreationDate="2018-03-23T15:11:59.623" Score="0" ViewCount="112" Body="&lt;p&gt;Every time I vim open, I get the standard warning about another user, swap file already exists, abort/quit/.., etc. I've been trying for at least 2 hours, and I'm sure I don't have the file open myself. The machine in question runs RHEL and I'm using putty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to figure out who has my file open? I'm thinking the result will be one of the machine's user ('s names), but it could be an IP address or something else I suppose. I'm also not sure if this question is more appropriate for unix/linux or vi/vim, so apologies if I tried the wrong one first&lt;/p&gt;&#xA;" OwnerUserId="14452" LastActivityDate="2018-03-23T17:01:42.593" Title="Discover which other user(s) are accessing a file" Tags="|save|swap-file|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15647" PostTypeId="2" ParentId="15646" CreationDate="2018-03-23T16:51:36.223" Score="5" Body="&lt;p&gt;I think you might be misinterpreting the meaning/operation of the swap file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The swap file &lt;em&gt;might&lt;/em&gt; indicate that some other person/process is currently editing that file, but it doesn't necessarily mean that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If an instance of Vim crashed, for example, the swap file will hang around &lt;em&gt;until you take steps to remove it&lt;/em&gt;, by e.g. selecting the &lt;code&gt;(D)elete&lt;/code&gt; option at the prompt, or by manually deleting it outside of Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The message itself tells you the owner of the swap file, along the time and date it was last saved and some other useful information such as whether or not the swap file actually contains any changes, the process ID of the instance of Vim that created it, and whether that process is still running. You can discern from this information whether there actually is another user editing the file or not.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-23T17:01:42.593" LastActivityDate="2018-03-23T17:01:42.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15648" PostTypeId="1" CreationDate="2018-03-23T20:58:11.363" Score="1" ViewCount="84" Body="&lt;p&gt;Apparently there are &lt;a href=&quot;https://stackoverflow.com/questions/30443836/install-vim-via-homebrew-with-python-and-python3-support#answer-30516109&quot;&gt;some issues&lt;/a&gt; preventing &lt;code&gt;vim&lt;/code&gt; from being built with both &lt;code&gt;python&lt;/code&gt; and &lt;code&gt;python3&lt;/code&gt; support under many linux distributions and OSX.  This makes it difficult or impossible for many users to use packages (AKA plugins, addons, etc.) which use python 2 while also using packages that use python 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such, is it recommended to use one of either python 2 or python 3 when developing vim packages?  Or should packages include both python 2 and python 3 code and switch between them using &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#has()&quot; rel=&quot;nofollow noreferrer&quot;&gt;has(&quot;python&quot;)&lt;/a&gt;?&lt;/p&gt;&#xA;" OwnerUserId="9412" LastActivityDate="2018-03-23T20:58:11.363" Title="Vim package development python support for 2, 3, or both?" Tags="|vimscript-python|plugin-development|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15649" PostTypeId="1" AcceptedAnswerId="15650" CreationDate="2018-03-23T22:11:12.690" Score="1" ViewCount="81" Body="&lt;p&gt;Given the following line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is a testing line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When my cursor is on &quot;a&quot; and then I type &lt;code&gt;2s&lt;/code&gt;, it becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is testing line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My cursor is on &quot;t&quot; of testing, and I am in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something like this that replaces words instead of letters and then puts you in insert mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="16105" LastEditorUserId="1111" LastEditDate="2018-08-22T14:54:14.363" LastActivityDate="2018-08-22T14:54:14.363" Title="Is there something like '5s' for replacing words (instead of letters)?" Tags="|insert-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="15650" PostTypeId="2" ParentId="15649" CreationDate="2018-03-23T23:31:20.627" Score="3" Body="&lt;p&gt;If you're asking whether there's a way to eliminate &lt;em&gt;n&lt;/em&gt; words and drop into insert mode to conveniently replace them with something else, yes there is, with a few variations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With your cursor on the &lt;code&gt;a&lt;/code&gt;, you could do &lt;code&gt;c2w&lt;/code&gt; (or &lt;code&gt;2cw&lt;/code&gt;) to remove &lt;code&gt;a testing&lt;/code&gt; and drop into insert mode with your cursor before the space preceding &lt;code&gt;line&lt;/code&gt;. This operation can also span multiple lines, so if you had your cursor on the &lt;code&gt;a&lt;/code&gt; in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is a testing line&#xA;and this is another one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and typed &lt;code&gt;5cw&lt;/code&gt; it would join the lines and drop you into insert mode with your cursor placed between &lt;code&gt;is&lt;/code&gt; and &lt;code&gt;is&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is  is another one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;w&lt;/code&gt; movement in this context encompasses characters from the cursor to the end of a word, so if you start from within a word, the beginning of the word will be unaffected. For example, with the cursor on the &lt;code&gt;x&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;flexible stuff bends&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;typing &lt;code&gt;c2w&lt;/code&gt; eliminates &lt;code&gt;xible stuff&lt;/code&gt; and puts you insert mode with the cursor after the &lt;code&gt;fle&lt;/code&gt; in &lt;code&gt;fle bends&lt;/code&gt;. You could also have used &lt;code&gt;e&lt;/code&gt; instead of &lt;code&gt;w&lt;/code&gt; in all the previous examples and it would behave the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to operate on the entire word instead, you could use &lt;code&gt;caw&lt;/code&gt; or &lt;code&gt;ciw&lt;/code&gt;. In the previous example, typing &lt;code&gt;2caw&lt;/code&gt; removes &lt;code&gt;flexible stuff&lt;/code&gt; (including the following space) and puts you in insert mode with your cursor right before &lt;code&gt;bends&lt;/code&gt;. &lt;code&gt;ciw&lt;/code&gt; acts a bit differently, and it's easier to try it out and get a sense for it than for me to try to describe it.&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2018-03-23T23:31:20.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15651" PostTypeId="1" AcceptedAnswerId="15660" CreationDate="2018-03-24T06:19:49.247" Score="5" ViewCount="2004" Body="&lt;p&gt;I recently installed Neovim and SpaceVim. My line number order is broken:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Qygj4.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qygj4.png&quot; alt=&quot;Broken line numbers&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This occurs when working on any file, with both Vim and Neovim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I solve this? I'm a newbie to Vim and don't know how to go about troubleshooting it. &lt;/p&gt;&#xA;" OwnerUserId="16841" LastEditorUserId="7942" LastEditDate="2018-03-25T13:55:57.637" LastActivityDate="2018-07-03T18:50:22.697" Title="Line number order is broken" Tags="|line-numbers|spacevim|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15652" PostTypeId="1" CreationDate="2018-03-24T19:40:02.230" Score="4" ViewCount="905" Body="&lt;p&gt;Maybe it was discussed many times (I strongly believe), but I could not formulate my question properly. So lets imagine we have this sequence of words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Applying &lt;code&gt;3e&lt;/code&gt; will move us onto:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar ba|z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where pipe character is the position of the cursor, but why? As far as I can read the docs &lt;code&gt;e&lt;/code&gt; moves you to the end of the next word starting from the current position,. Shouldn't we end up like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar baz|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is this relevant to the idea that final position after applying of the combination should be still placed &lt;em&gt;within&lt;/em&gt; a sequence, while &lt;code&gt;baz|&lt;/code&gt; is outside this?&lt;/p&gt;&#xA;" OwnerUserId="12349" LastEditorUserId="2920" LastEditDate="2018-03-24T23:22:51.093" LastActivityDate="2022-04-06T03:09:22.120" Title="Why does &quot;e&quot; move you one character before the actual end of the word?" Tags="|cursor-movement|cursor-motions|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15653" PostTypeId="2" ParentId="15652" CreationDate="2018-03-24T23:26:04.470" Score="1" Body="&lt;p&gt;The result is not to put the cursor between the &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;z&lt;/code&gt; (as the pipe character seems to illustrate in your example) but to put the cursor &lt;em&gt;on&lt;/em&gt; the &lt;code&gt;z&lt;/code&gt;. In normal mode the cursor sits &lt;em&gt;on top&lt;/em&gt; of a character rather than being between characters. (Think of what the &lt;code&gt;r&lt;/code&gt;eplace command does. Wouldn't really work if the cursor was between characters.) Based on that, the definition of &quot;to the end of word&quot;, which is how help describes it, is no longer ambiguous. Since it doesn't say &lt;em&gt;before&lt;/em&gt; the end of word or &lt;em&gt;after&lt;/em&gt; the end of word there is just one choice: &lt;em&gt;on&lt;/em&gt; the last element of the word, i.e. &lt;code&gt;z&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-03-25T00:21:59.373" LastActivityDate="2018-03-25T00:21:59.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15654" PostTypeId="2" ParentId="15652" CreationDate="2018-03-24T23:26:37.053" Score="11" Body="&lt;p&gt;&lt;em&gt;This is assuming that your setup is using the ordinary &lt;code&gt;e&lt;/code&gt;. If this doesn't answer your question, check if &lt;code&gt;e&lt;/code&gt; is mapped to anything with &lt;code&gt;:nmap e&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This comes from a fundamental misunderstanding of where vim's cursor is situated. In insert mode, vim functions like a traditional editor, and the cursor goes &lt;strong&gt;&lt;em&gt;between&lt;/em&gt;&lt;/strong&gt; characters. So you can have the cursor situated like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar ba|z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the cursor between the 'a' and the 'z'. However, this is impossible in normal mode. In normal mode, rather than having the cursor between characters, you'll have it &lt;strong&gt;&lt;em&gt;on&lt;/em&gt;&lt;/strong&gt; a single character. So instead of between the 'a' and the 'z', you'll have it here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;          v&#xA;foo bar baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;         v&#xA;foo bar baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but &lt;em&gt;never&lt;/em&gt; here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar ba|z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One way to make this difference more apparent is to make the cursor shape a bar in insert mode and a block in normal mode. The block will be positioned over the character the cursor is on. &lt;a href=&quot;http://vim.wikia.com/wiki/Change_cursor_shape_in_different_modes&quot; rel=&quot;noreferrer&quot;&gt;This vim tips&lt;/a&gt; describes how to set that up.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-03-24T23:26:37.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15656" PostTypeId="1" AcceptedAnswerId="15657" CreationDate="2018-03-25T00:42:56.463" Score="0" ViewCount="46" Body="&lt;p&gt;I have following &lt;code&gt;c.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap {&amp;lt;CR&amp;gt; {&amp;lt;CR&amp;gt;}&amp;lt;Esc&amp;gt;O&#xA;imap [ []&amp;lt;Left&amp;gt;&#xA;imap # #include&amp;lt;&amp;gt;&amp;lt;Left&amp;gt;&#xA;&#xA;command F %s/\v(\w) ?(\+|-|\*|\/|\&amp;gt;\=|\&amp;lt;\=|!\=|\=|\=\=) ?(\w|-)/\1 \2 \3/g | %s/\v([;,])([^ ])/\1 \2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And my sample file is &lt;code&gt;test.c&lt;/code&gt; containing  &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;if(a==3)&#xA;if(array[4]==3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then if I execute command &lt;code&gt;F&lt;/code&gt; then the above file is changed into&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;if(a == 3)&#xA;if(array[4]==3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First &lt;code&gt;==&lt;/code&gt; sign is indented but not in second. Why?&lt;/p&gt;&#xA;" OwnerUserId="9498" LastEditorUserId="16280" LastEditDate="2019-04-01T16:33:26.937" LastActivityDate="2019-04-01T16:33:26.937" Title="Indentation script does not work for all occurrence" Tags="|command-line|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15657" PostTypeId="2" ParentId="15656" CreationDate="2018-03-25T10:45:55.833" Score="1" Body="&lt;p&gt;The only relevant part is the first substitution in the &lt;code&gt;F&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v(\w) ?(\+|-|\*|\/|\&amp;gt;\=|\&amp;lt;\=|!\=|\=|\=\=) ?(\w|-)/\1 \2 \3/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Breaking down the pattern:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; - set 'very magic' option, many characters have special meaning without having to be escaped&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(\w)&lt;/code&gt; - match one &lt;code&gt;word&lt;/code&gt; character which is same as &lt;code&gt;[0-9A-Za-z_]&lt;/code&gt;, the parens allow this match to be inserted into the substitution via back-reference (e.g. &lt;code&gt;\1&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;space&amp;gt;?&lt;/code&gt; - match 0 or 1 space&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(\+|-|\*|\/|\&amp;gt;\=|\&amp;lt;\=|!\=|\=|\=\=)&lt;/code&gt; - match an arithmetic operator, surrounding with parens for back-ref use&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;space&amp;gt;?&lt;/code&gt; - match 0 or 1 space&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(\w|-)&lt;/code&gt; - same as &lt;code&gt;(\w)&lt;/code&gt; above except also allow dash to match&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(The substitution &lt;code&gt;\1 \2 \3&lt;/code&gt;, with back-reference to each of the paren surrounded pattern parts, adds an extra space before and after the arithmetic operator.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be pretty clear now from the breakdown of the pattern that &lt;code&gt;a==3&lt;/code&gt; matches and &lt;code&gt;array[4]==3&lt;/code&gt; does not as the character preceding the operator, i.e. &lt;code&gt;]&lt;/code&gt;, is not a &lt;code&gt;word&lt;/code&gt; character. One option to allow &lt;code&gt;]&lt;/code&gt; as well is to replace &lt;code&gt;(\w)&lt;/code&gt; with &lt;code&gt;([]0-9A-Za-z_])&lt;/code&gt; or &lt;code&gt;(]|\w)&lt;/code&gt;. Choosing the latter we end up with this for &lt;code&gt;F&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command F %s/\v(]|\w) ?(\+|-|\*|\/|\&amp;gt;\=|\&amp;lt;\=|!\=|\=|\=\=) ?(\w|-)/\1 \2 \3/g | %s/\v([;,])([^ ])/\1 \2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-04-01T04:40:20.280" LastActivityDate="2018-04-01T04:40:20.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15659" PostTypeId="2" ParentId="2493" CreationDate="2018-03-25T13:36:45.080" Score="4" Body="&lt;p&gt;Check out the Pull Request into the &lt;strong&gt;neovim&lt;/strong&gt; editor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/neovim/neovim/pull/8169&quot; rel=&quot;nofollow noreferrer&quot;&gt;[RFC] Add an option to use numbered registers for smaller deletions #8169&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to add the &lt;code&gt;smalldel&lt;/code&gt; option, which allows you to configure the minimum number of deleted characters to be pushed into the numbered registers &quot;1..&quot;9&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next neovim release after this PR is merged (if this happens) will contain this option.&lt;/p&gt;&#xA;" OwnerUserId="16852" LastActivityDate="2018-03-25T13:36:45.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15660" PostTypeId="2" ParentId="15651" CreationDate="2018-03-25T13:39:16.217" Score="4" Body="&lt;p&gt;In SpaceVim, we use &lt;code&gt;g:spacevim_relativenumber&lt;/code&gt; to config relativenumber. if by default it is 1, if you want to disable this feature. just add&#xA;&lt;code&gt;let g:spacevim_relativenumber = 0&lt;/code&gt; to your custom config. the config can be opened via &lt;code&gt;SPC f v d&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;why we make this option enabled by default?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;because relativenumber is very useful for line move, you can use &lt;code&gt;7j&lt;/code&gt; to move down 7 line, and you can see the &lt;code&gt;7&lt;/code&gt; before moving.&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2018-03-25T13:39:16.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15661" PostTypeId="2" ParentId="15405" CreationDate="2018-03-25T13:50:02.330" Score="3" Body="&lt;p&gt;As author of SpaceVim, I can not reproduce this issue in master branch. and we do not map &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; in spacevim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you should check result of &lt;code&gt;:verbose map j&lt;/code&gt; or &lt;code&gt;:verbose map k&lt;/code&gt;, this command will show what and where j and k is mapped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if the result is empty, you need to check autocmd like &lt;code&gt;CursorMoved&lt;/code&gt; via &lt;code&gt;:au CursorMoved&lt;/code&gt;, the output will what autocmd will be called when move cursor.&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2018-03-25T13:50:02.330" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15662" PostTypeId="1" CreationDate="2018-03-25T14:12:38.350" Score="2" ViewCount="2325" Body="&lt;pre&gt;&lt;code&gt;vim --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 30 2017 18:21:38)&#xA;Included patches: 1-197, 322, 377-378, 550, 703, 706-707&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     -tcl&#xA;-balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;-browse          -footer          +multi_byte      +terminfo&#xA;++builtin_terms  +fork()          +multi_lang      +termresponse&#xA;+byte_offset     +gettext         -mzscheme        +textobjects&#xA;+channel         -hangul_input    +netbeans_intg   +timers&#xA;+cindent         +iconv           +num64           +title&#xA;-clientserver    +insert_expand   +packages        -toolbar&#xA;-clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        -perl            +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       -python          +vreplace&#xA;+cscope          +lispindent      -python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con      -lua             +rightleft       +writebackup&#xA;+diff            +menu            -ruby            -X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;-dnd             +modify_fname    +signs           -xim&#xA;-ebcdic          +mouse           +smartindent     -xpm&#xA;+emacs_tags      -mouseshape      +startuptime     -xsmp&#xA;+eval            +mouse_dec       +statusline      -xterm_clipboard&#xA;+ex_extra        +mouse_gpm       -sun_workshop    -xterm_save&#xA;+extra_search    -mouse_jsbterm   +syntax          &#xA;+farsi           +mouse_netterm   +tag_binary      &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-R2d1UQ/vim-8.0.0197=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: gcc   -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux -lacl -lattr -lgpm -ldl     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set omnicompletion for php in my .vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;set omnifunc=syntaxcomplete#Complete&#xA;autocmd FileType php set omnifunc=phpcomplete#CompletePHP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To edit a test.php file,input the word &lt;code&gt;html&lt;/code&gt; ,now i want to get all the php functions beginning with &lt;code&gt;html&lt;/code&gt;.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ctrl+x&lt;/code&gt; result in  &lt;code&gt;-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y) Pattern not found&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go on to press &lt;code&gt;ctrl+o&lt;/code&gt; result in &lt;code&gt;Omni completion (^O^N^P) pattern not found&lt;/code&gt;.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why and how to fix it?  &lt;/p&gt;&#xA;" OwnerUserId="13416" LastEditorUserId="13416" LastEditDate="2018-03-31T09:00:19.127" LastActivityDate="2018-03-31T09:00:19.127" Title="Why -- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y) Pattern not found?" Tags="|vimrc|autocompletion|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15663" PostTypeId="1" AcceptedAnswerId="15680" CreationDate="2018-03-25T17:00:27.377" Score="3" ViewCount="2434" Body="&lt;p&gt;I have a &lt;code&gt;file.c&lt;/code&gt; containing  &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#inlcude&amp;lt;stdio.h&amp;gt;&#xA;&#xA;int main()&#xA;{&#xA;    printf(&quot;Hello world\n&quot;);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can copy the main function using &lt;code&gt;:3,6y&lt;/code&gt;. But, when the function is big enough then in order to know in which line the function ends I need to scroll.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to copy entire function using something like &lt;code&gt;:copy main&lt;/code&gt;?  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="9498" LastEditorUserId="16280" LastEditDate="2019-04-01T16:21:33.790" LastActivityDate="2023-04-15T07:39:56.360" Title="Is there any way to copy a entire function without indicating line number?" Tags="|cut-copy-paste|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15664" PostTypeId="1" AcceptedAnswerId="15667" CreationDate="2018-03-25T17:11:52.547" Score="3" ViewCount="14554" Body="&lt;pre&gt;&lt;code&gt;#inlcude&amp;lt;stdio.h&amp;gt;&#xA;int main()&#xA;{&#xA;   printf(&quot;Hello world\n&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to comment line where the cursor is. For, example if I am on the line &lt;code&gt;printf&lt;/code&gt; then I want to get following -  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#inlcude&amp;lt;stdio.h&amp;gt;&#xA;int main()&#xA;{&#xA;   /* printf(&quot;Hello world\n&quot;); */&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[keep in mind the comment style is &lt;code&gt;/* */&lt;/code&gt;]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command may be &lt;code&gt;:C&lt;/code&gt; or &lt;code&gt;:Comment&lt;/code&gt; or &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;a key&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="9498" LastActivityDate="2020-07-12T08:35:20.293" Title="How to comment a line in vim?" Tags="|comments|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15665" PostTypeId="2" ParentId="15663" CreationDate="2018-03-25T17:13:55.507" Score="4" Body="&lt;p&gt;Here is one option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/int main(/;/^}/y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This searches for &lt;code&gt;int main(&lt;/code&gt;, goes to that line, then searches forward to the ending brace (assumed to be in the first column), takes the two lines as a range, and yanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are already on the &lt;code&gt;int main&lt;/code&gt; line you could simply use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:,/^}/y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or in normal mode, one of the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y/^}/e&#xA;yv/^}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without either &lt;code&gt;v&lt;/code&gt; (make inclusive) or &lt;code&gt;/e&lt;/code&gt; (cursor to end of match) the ending brace will not be included.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-03-25T17:13:55.507" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15666" PostTypeId="1" CreationDate="2018-03-25T21:27:33.857" Score="0" ViewCount="41" Body="&lt;p&gt;Given a bash function, &lt;code&gt;getMyFilePath()&lt;/code&gt;, which results in a directory path, &lt;code&gt;/mydir&lt;/code&gt;, how can I open a new tab, passing this function to navigate there?&lt;/p&gt;&#xA;" OwnerUserId="11715" LastActivityDate="2018-03-26T08:04:01.773" Title="e or tabe into path resulting from a ! command" Tags="|external-command|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15667" PostTypeId="2" ParentId="15664" CreationDate="2018-03-26T00:03:16.330" Score="12" Body="&lt;p&gt;One way would be to map the keystrokes you would use to a key combination:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gcc I/* &amp;lt;ESC&amp;gt;A */&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In normal mode, when pressing &lt;code&gt;gcc&lt;/code&gt;, this will go to the beginning of the line and insert &lt;code&gt;/* &lt;/code&gt;, then goes to the end of the line and insert &lt;code&gt; */&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This might be already enough for you, but if you want more I would recommend just using a plugin for that, e.g. &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tim Pope's vim-commentary&lt;/a&gt;.  Besides commenting C files, it also supports many other programming languages and uses the appropriate comment format for them.  You can define custom comment formats, and you can also uncomment lines (with the same combination &lt;code&gt;gcc&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="7877" LastEditorUserId="15661" LastEditDate="2020-07-12T08:35:20.293" LastActivityDate="2020-07-12T08:35:20.293" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="15669" PostTypeId="2" ParentId="15666" CreationDate="2018-03-26T08:04:01.773" Score="1" Body="&lt;p&gt;You could use &lt;code&gt;execute&lt;/code&gt; and &lt;code&gt;system&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;tabnew &quot;.system(&quot;getMyFilePath()&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But most likely you could solve your use case without the function.&#xA;Have a look at &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#filename-modifiers&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h filename-modifiers&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11316" LastActivityDate="2018-03-26T08:04:01.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15670" PostTypeId="1" AcceptedAnswerId="15672" CreationDate="2018-03-26T08:57:14.890" Score="0" ViewCount="528" Body="&lt;p&gt;I have installed tern_for_vim and setted complete in .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType javascript setlocal omnifunc=tern#Complete&#xA;autocmd FileType php set omnifunc=phpcomplete#CompletePHP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now i can call javascript  complete  when editing html file via ctrl+x and ctrl+o.&lt;br&gt;&#xA;The php completion can pop up when editing a php file (vim test.php) via ctrl+x and ctrl+o.&lt;br&gt;&#xA;Many php and javascript code snippets are embeded in a html file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What i can do now:&lt;br&gt;&#xA;During editing my html file(vim test.html), when javascript complete needed ,it can call via ctrl+x and ctrl+o;  when php complete needed ,it can't call via ctrl+x and ctrl+o.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What i expect:&lt;br&gt;&#xA;During editing my html file(vim test.html), when javascript complete needed ,it can call via ctrl+x and ctrl+o;  when php complete needed ,it can  call via ctrl+x and ctrl+o.&lt;br&gt;&#xA;YouCompleteMe and tern_for_vim  installed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat  .tern-project&#xA;{&#xA;    &quot;ecmaVersion&quot;: 6,&#xA;    &quot;libs&quot;: [&#xA;        &quot;browser&quot;,&#xA;        &quot;underscore&quot;,&#xA;        &quot;jquery&quot;&#xA;    ],&#xA;    &quot;plugins&quot;: {&#xA;        &quot;node&quot;: {}&#xA;    }&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I reset my .vimrc according to Rich's code.    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat .vimrc&#xA;set nobackup&#xA;set nowritebackup    &#xA;set tabstop=4&#xA;set sts=4&#xA;set expandtab&#xA;set softtabstop=4&#xA;set shiftwidth=4    &#xA;set number    &#xA;execute pathogen#infect()&#xA;execute pathogen#helptags()&#xA;&#xA;filetype plugin on    &#xA;autocmd FileType html setlocal omnifunc=MyHTMLComplete&#xA;function! MyHTMLComplete(findstart, base)&#xA;    if search('&amp;lt;?php', 'bnW') &amp;gt; search('&amp;lt;script&amp;gt;', 'bnW')&#xA;        return phpcomplete#CompletePHP(a:findstart, a:base)&#xA;    else&#xA;        return tern#Complete(a:findstart,a:base)&#xA;    endif&#xA;endfunction&#xA;&#xA;ls .vim/bundle&#xA;phpcomplete.vim  tabular  tern_for_vim  webapi-vim  YouCompleteMe&#xA;&#xA;&#xA;vim test.html&#xA;&amp;lt;script&amp;gt;&#xA;    document.get &#xA;&amp;lt;/script&amp;gt;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vxyN8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vxyN8.png&quot; alt=&quot;js complete in html file called by ctrl-x + ctrl-o&quot;&gt;&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add php code snippet to test complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fmswQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fmswQ.png&quot; alt=&quot;php complete in html file can&amp;#39;t called by ctrl-x + ctrl-o&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit a single test.php file.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/xJye7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xJye7.png&quot; alt=&quot;php complete in php file called by ctrl-x + ctrl-o&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to achieve my target?     &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting .vimrc as setting1 :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;execute pathogen#helptags()&#xA;&#xA;filetype plugin on    &#xA;autocmd FileType html setlocal omnifunc=MyHTMLComplete&#xA;function! MyHTMLComplete(findstart, base)&#xA;    if search('&amp;lt;?php', 'bnW') &amp;gt; search('&amp;lt;script&amp;gt;', 'bnW')&#xA;        return phpcomplete#CompletePHP(a:findstart, a:base)&#xA;    else&#xA;        return tern#Complete(a:findstart,a:base)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setting .vimrc as setting2 :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;execute pathogen#helptags()&#xA;autocmd FileType javascript setlocal omnifunc=tern#Complete&#xA;autocmd FileType php set omnifunc=phpcomplete#CompletePHP&#xA;filetype plugin on    &#xA;autocmd FileType html setlocal omnifunc=MyHTMLComplete&#xA;function! MyHTMLComplete(findstart, base)&#xA;    if search('&amp;lt;?php', 'bnW') &amp;gt; search('&amp;lt;script&amp;gt;', 'bnW')&#xA;        return phpcomplete#CompletePHP(a:findstart, a:base)&#xA;    else&#xA;        return tern#Complete(a:findstart,a:base)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is tested that both setting1 and setting2 take the same effect.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;verbose :set omnifunc?&#xA;  omnifunc=MyHTMLComplete&#xA;        Last set from ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="5181" LastEditDate="2018-04-02T09:53:04.620" LastActivityDate="2018-04-02T11:49:48.877" Title="How to call both javascript and php complete in editing html file with vim?" Tags="|autocompletion|" AnswerCount="2" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15671" PostTypeId="1" AcceptedAnswerId="15675" CreationDate="2018-03-26T09:14:56.610" Score="1" ViewCount="761" Body="&lt;p&gt;I have recently started using st. But nvim doesn't change cursor shape like that in gnome-terminal or xfce4-terminal in this terminal. What's more confusing is that it works fine in tmux inside st!&#xA;I don't know anything about st. So, my question is, what's wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Very, very, confusing observation. I didn't install st-terminal per se. I cloned and compiled and launched it from rofi menu. But if I launch st from another terminal like xfce4-terminal, it handles nvim cursor changes currectly, although a little slow!&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2018-03-27T05:19:31.503" LastActivityDate="2018-03-27T12:18:22.627" Title="neovim doesn't change cursor in st terminal" Tags="|cursor|st|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15672" PostTypeId="2" ParentId="15670" CreationDate="2018-03-26T09:35:08.853" Score="2" Body="&lt;p&gt;Here's some rough code to start you off. Create the file &lt;code&gt;.vim/after/ftplugin/html.vim&lt;/code&gt; and add the&#xA;following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal omnifunc=MyHTMLComplete &#xA;&#xA;function! MyHTMLComplete(findstart, base)&#xA;    if search('&amp;lt;?php', 'bnW') &amp;gt; search('&amp;lt;script&amp;gt;', 'bnW')&#xA;        return phpcomplete#CompletePHP(a:findstart, a:base)&#xA;    else&#xA;        return tern#Complete(a:findstart,a:base)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It first uses the &lt;code&gt;search()&lt;/code&gt; function to look for the nearest &lt;code&gt;php&lt;/code&gt; and &lt;code&gt;script&lt;/code&gt; section starts, passing the following flags:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;b&lt;/code&gt; - search backwards,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt; - don't move the cursor,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;W&lt;/code&gt; - don't wrap around at the start of the file,&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It then passes on the call to the corresponding existing complete function, depending on which section starts later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is obviously an exceedingly imprecise check of the current context. Hopefully this is enough to start you off, but you'll need to improve this quite a lot for this to be a robust solution!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possibly a better technique for discerning what type of code you are in would be to use &lt;code&gt;synstack()&lt;/code&gt; and its related functions to interrogate Vim's syntax highlighting information. Something like the following might work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for id in synstack(line('.'), col('.'))&#xA;    if synIDattr(id, 'name') =~? 'javascript'&#xA;        echom &quot;In Javascript!&quot;&#xA;        break&#xA;    endif&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more details, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help complete-functions&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help search()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help synstack()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-04-02T06:52:49.340" LastActivityDate="2018-04-02T06:52:49.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15673" PostTypeId="1" AcceptedAnswerId="15674" CreationDate="2018-03-26T13:09:28.443" Score="46" ViewCount="18273" Body="&lt;p&gt;I have read it in many articles (&lt;a href=&quot;http://kgrz.io/getting-started-with-using-vim.html&quot; rel=&quot;noreferrer&quot;&gt;e.g.&lt;/a&gt;) that it's a bad practice to use arrow keys in normal mode. Could somebody explain why is it considered a wrong practice, if at all?&lt;/p&gt;&#xA;" OwnerUserId="16636" LastEditorUserId="205" LastEditDate="2018-03-27T07:49:12.590" LastActivityDate="2018-04-01T22:59:08.413" Title="Why is using arrow keys in normal mode considered bad practice?" Tags="|key-bindings|cursor-movement|" AnswerCount="8" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15674" PostTypeId="2" ParentId="15673" CreationDate="2018-03-26T13:22:21.547" Score="73" Body="&lt;p&gt;Actually this is not a bad practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A lot of people (&lt;em&gt;including Vim's doc as @B Layer's answer shows&lt;/em&gt;) argue that you shall not use arrow keys because it makes your hands move from the home row (the second line of your keyboard where you have &lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt;) and that make you less efficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is (IMO at least) a bad result from vim &quot;purists&quot; circle jerk: new users follow this blindly, some even disable the arrow keys and then they complain that they are not as efficient as before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only real rule to use vim is to use it efficiently: if you feel more comfortable using &lt;kbd&gt;Left&lt;/kbd&gt; and &lt;kbd&gt;Right&lt;/kbd&gt; than &lt;kbd&gt;h&lt;/kbd&gt; and &lt;kbd&gt;l&lt;/kbd&gt;  be it, use the arrow keys. Vim even has &lt;code&gt;set mouse=a&lt;/code&gt; option if you want to use a mouse!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you get used to vim and get better with the different available motions (&lt;kbd&gt;f&lt;/kbd&gt;, &lt;kbd&gt;t&lt;/kbd&gt;, &lt;kbd&gt;,&lt;/kbd&gt;, &lt;kbd&gt;;&lt;/kbd&gt;, &lt;kbd&gt;w&lt;/kbd&gt;, &lt;kbd&gt;b&lt;/kbd&gt;, &lt;kbd&gt;e&lt;/kbd&gt;, &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;, and basically everything in &lt;a href=&quot;http://vimhelp.appspot.com/quickref.txt.html#quickref&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h quickref&lt;/code&gt;&lt;/a&gt;) you might realize that you don't use arrow keys that much. And if you still use them, it's not a problem, use what you are most efficient with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; That the argument of don't leave the home row for more efficiency is not that good in my opinion: If you take a look at &lt;a href=&quot;https://vi.stackexchange.com/q/9313/1841&quot;&gt;Why does vim use hjkl&lt;/a&gt; you'll see that these keys were chosen because there weren't any arrow keys when Vi was written. One could argue that maybe if the keyboards were different at this time no one would consider not using the arrow keys a good practice.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-04-01T18:26:15.323" LastActivityDate="2018-04-01T18:26:15.323" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="15675" PostTypeId="2" ParentId="15671" CreationDate="2018-03-26T13:36:22.737" Score="4" Body="&lt;p&gt;This should be fixed in the release after 0.2.2.  This was reported in &lt;a href=&quot;https://github.com/neovim/neovim/issues/7641&quot; rel=&quot;nofollow noreferrer&quot;&gt;neovim/neovim#7641&lt;/a&gt; and the issue was that st's terminfo incorrectly specifies how to change the cursor shape.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fix in neovim was to ignore what st reports and use the typical values for those escape sequences.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2018-03-27T12:18:22.627" LastActivityDate="2018-03-27T12:18:22.627" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15676" PostTypeId="2" ParentId="15673" CreationDate="2018-03-26T13:41:06.473" Score="30" Body="&lt;p&gt;While I agree with @statox that no one should be chastised, shunned, excommunicated, or tarred-and-feathered if they choose to use the arrow keys...use your software however you see fit...I wouldn't exude as much of a laissez-faire attitude if I were giving guidance to an open-minded new user. I'd pretty strongly recommend that they start with following best practices. They are &quot;best practices&quot; for a reason...they've been employed to good effect by lots of people who came before you and me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Heck, even &lt;a href=&quot;http://vimhelp.appspot.com/usr_02.txt.html#hjkl&quot; rel=&quot;noreferrer&quot;&gt;Vim's own help nudges you in that direction&lt;/a&gt;, though not without hyperbole (&quot;&lt;em&gt;greatly&lt;/em&gt; slow down&quot;)...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can also move the cursor by using the arrow keys.  If you do,&#xA;  however, you greatly slow down your editing because to press the arrow&#xA;  keys, you must move your hand from the text keys to the arrow keys.&#xA;  Considering that you might be doing it hundreds of times an hour, this&#xA;  can take a significant amount of time.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There's also the fact that whatever choices you make at the start may become habits that are difficult to break if you want to change in the future. So all else being equal why not adopt a recommended habit now rather than take the chance that using arrow keys &lt;em&gt;is&lt;/em&gt; inefficient or carpal-killing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All in all, consider giving an honest effort to doing things without arrow keys. After a reasonable amount of time if you just can't live without up/down/left/right...don't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;...is what I would say to a new user who was interested in my opinion. Don't take it personally if you don't agree (I'm talking to you, downvoter).&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-03-27T01:20:57.790" LastActivityDate="2018-03-27T01:20:57.790" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="15677" PostTypeId="5" CreationDate="2018-03-26T14:49:30.713" Score="0" Body="&lt;p&gt;Homepage: &lt;a href=&quot;https://st.suckless.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://st.suckless.org/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2018-03-26T14:49:30.713" LastActivityDate="2018-03-26T14:49:30.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15678" PostTypeId="4" CreationDate="2018-03-26T14:49:30.713" Score="0" Body="st is a &quot;simple terminal&quot; from suckless.org. Use this for questions specific to running Vim in st." OwnerUserId="51" LastEditorUserId="51" LastEditDate="2018-03-26T14:49:30.713" LastActivityDate="2018-03-26T14:49:30.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15679" PostTypeId="2" ParentId="15663" CreationDate="2018-03-26T15:09:03.600" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;[[&lt;/code&gt; &amp;amp; &lt;code&gt;][&lt;/code&gt; to help you find the start and end of your function. You can also use &lt;code&gt;[m&lt;/code&gt; and &lt;code&gt;]m&lt;/code&gt; as well.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[mkV]my&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A simply method text-object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap aM :&amp;lt;c-u&amp;gt;normal [mv]m&amp;lt;cr&amp;gt;&#xA;onoremap aM :normal vaM&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: these will probably need to be updated for you needs, but they are a good starting point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can use &lt;code&gt;yaM&lt;/code&gt; or &lt;code&gt;vaM&lt;/code&gt; to copy the method/function body.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h ]]&#xA;:h ]m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-03-26T15:09:03.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15680" PostTypeId="2" ParentId="15663" CreationDate="2018-03-26T15:48:01.493" Score="5" Body="&lt;p&gt;Yet another way is to use the &lt;code&gt;%&lt;/code&gt; motion, after placing the cursor on the second line in your example (&lt;code&gt;/main&lt;/code&gt;), I would use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Vj%y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt;: enable visual-line selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt;: go down to the opening curly brace&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt;: find the next matching item&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt;: copy the selected text&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For more advanced operations, text-objects are a good choice as &lt;a href=&quot;https://vi.stackexchange.com/a/15679/12003&quot;&gt;suggested&lt;/a&gt; by Peter Rincker, or maybe a plugin like &lt;a href=&quot;https://github.com/LucHermitte/vim-refactor&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-refactor&lt;/a&gt; allowing you to extract functions and more.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2023-04-15T07:39:56.360" LastActivityDate="2023-04-15T07:39:56.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15682" PostTypeId="1" CreationDate="2018-03-26T19:30:48.110" Score="1" ViewCount="717" Body="&lt;p&gt;I have a large JSON file that I am largely familiar with, but I have to jump around the file in VIM quite a bit and tweak options and such. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if there is a VIM plugin available that allows me to specify a JSONPath / jq / JMESPath path on the search command line to easily jump to a specific key/value object in the file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a comparable plugin for xpath in XML files: &lt;a href=&quot;https://github.com/actionshrimp/vim-xpath&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/actionshrimp/vim-xpath&lt;/a&gt; , but the JSON-based plugins I have found only deal with syntax highlighting, linting, pretty-printing/formatting, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I'd like to just be able to use JSON Path notation (or the like) to easily jump to the spot in my JSON file I need to read/modify/etc.&lt;/p&gt;&#xA;" OwnerUserId="16869" LastActivityDate="2018-07-16T18:25:28.300" Title="Is there a VIM plugin available to add JSONPath / jq / JMESPath path searching?" Tags="|filetype-json|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15684" PostTypeId="1" CreationDate="2018-03-26T20:47:27.407" Score="0" ViewCount="103" Body="&lt;p&gt;I have the following vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:base_path=&quot;~/.config/nvim/&quot;&#xA;let g:plugins_path=base_path.&quot;plugins/&quot;&#xA;let g:repos_path=plugins_path.&quot;repos/github.com/&quot;&#xA;&#xA;set runtimepath+=g:repos_path.&quot;Shougo/dein.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it's doing something weird, instead of seeing a path at the end, I'm seeing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtimepath=~/.config/nvim,/etc/xdg/nvim,~/.local/share/nvim/site,/usr/local/share/nvim/site,/usr/share/nvim/site,/usr/local/Cellar/neovim/0.2.2_1/share/nvi&#xA;    m/runtime,/usr/share/nvim/site/after,/usr/local/share/nvim/site/after,~/.local/share/nvim/site/after,/etc/xdg/nvim/after,~/.config/nvim/after,g:repos_path.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's adding this to the end: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;,g:repos_path.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;,~/.config/nvim/plugins/repos/github.com/Shougo/dein.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is vim not adding the path to the end correctly and also why is this happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;The only way to get this to work is to use the fullpath without any quotes like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath+=~/.config/nvim/plugins/repos/github.com/Shougo/dein.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11603" LastEditorUserId="11603" LastEditDate="2018-03-26T20:54:27.677" LastActivityDate="2018-03-26T21:01:38.990" Title="Vim not using variable value when changing a setting" Tags="|vimscript|neovim|variables|set|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15685" PostTypeId="2" ParentId="15684" CreationDate="2018-03-26T21:01:38.990" Score="1" Body="&lt;p&gt;After reading &lt;a href=&quot;https://stackoverflow.com/a/5736810/3536548&quot;&gt;this&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;let &amp;amp;backupdir=s:vimetc.'backups/'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I realised what I needed to do was this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;runtimepath=&amp;amp;runtimepath.','.g:repos_path.&quot;Shougo/dein.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to say, vim script can be a bit inconsistent, using bare strings works fine but without it you need to some some weird stuff to get it to work if you want to use variables.&lt;/p&gt;&#xA;" OwnerUserId="11603" LastActivityDate="2018-03-26T21:01:38.990" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15686" PostTypeId="2" ParentId="15673" CreationDate="2018-03-26T21:52:41.300" Score="41" Body="&lt;p&gt;I don't know if this is really relevant any more, but I'm an old-timer so here's a bit of history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the old days, VT100 terminals had arrow keys, but pressing one transmitted an escape sequence like &lt;code&gt;&amp;lt;ESC&amp;gt;[A&lt;/code&gt; for up, &lt;code&gt;&amp;lt;ESC&amp;gt;[B&lt;/code&gt; for down, etc.&lt;br&gt;&#xA;Also, being a serial terminal communicating at 9600 baud, it was possible for the user to press the keys too fast to transmit the whole sequence which would cause one key press to interrupt the sequence of the previous key press and confuse vi.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would cause vi to inexplicably go into insert mode and insert [B[B[B[B[B[B into your file if you held down the down arrow.  I say inexplicably because there's nothing about this sequence that should enter insert mode and the fact that each sequence starts with an ESC character should have exited insert mode.  But still, it would insert garbage.  Not always - just when you were in a hurry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One quickly got tired of this and decided to just stick to the &lt;code&gt;hjkl&lt;/code&gt; keys.&lt;/p&gt;&#xA;" OwnerUserId="16870" LastActivityDate="2018-03-26T21:52:41.300" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15687" PostTypeId="2" ParentId="15673" CreationDate="2018-03-26T23:22:45.103" Score="5" Body="&lt;p&gt;The usual answer involves efficiency.  You've likely been trained over the years to employ touch typing, which employs keeping your hands on asdf and jkl;.  A vast majority of the key bindings in Vi are designed around this fact, including the hjkl movement commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I actually use both.  I use hjkl when I'm actively editing large sections of text, and the arrow keys when scrolling through log files (and |, g, and / when I'm doing spot edits throughout a file).  This just happens to be what works well for me, and in a case like this, that's what really matters.&lt;/p&gt;&#xA;" OwnerUserId="16873" LastActivityDate="2018-03-26T23:22:45.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15689" PostTypeId="2" ParentId="10869" CreationDate="2018-03-27T01:24:38.643" Score="0" Body="&lt;p&gt;Close vim completely, and reopen the file manually (ie &lt;code&gt;:edit FileName.ext&lt;/code&gt; instead of &lt;code&gt;:MRU&lt;/code&gt;), ensuring there's no badly-cased names in the path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just solved a similar problem where my filename in vim was lowercase, but the actual path was uppercase, and Fugitive couldn't find the lowercased file for whatever reason. It seemed to persist even after I relaunched vim and opened the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem was actually that the MRU plugin I was using (CtrlP) had managed to store the lowercase filename, so after restarting vim, when I manually typed &lt;code&gt;:e UpperCaseFileName.type&lt;/code&gt;, instead of going through the MRU file via a plugin, it used the correct path.&lt;/p&gt;&#xA;" OwnerUserId="488" LastActivityDate="2018-03-27T01:24:38.643" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15690" PostTypeId="2" ParentId="15673" CreationDate="2018-03-27T08:07:57.553" Score="7" Body="&lt;p&gt;A more precise statement might be &lt;strong&gt;&quot;using the arrow keys is bad practice &lt;em&gt;while trying to learn vim better&lt;/em&gt;&quot;&lt;/strong&gt;. People new to vim are used to using the arrow keys to move around and so don't learn &lt;code&gt;hjkl&lt;/code&gt;, thus not getting the chance to see if this is preferable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, after gaining some general familiarity with vim, I &lt;a href=&quot;https://vi.stackexchange.com/questions/5851/how-to-disable-arrow-keys-in-vim&quot;&gt;disabled the arrow keys&lt;/a&gt; for a while to get the hang of &lt;code&gt;hjkl&lt;/code&gt; and reenabled them later to simplify my &lt;code&gt;.vimrc&lt;/code&gt;. The conventional wisdom holds in my case; once I knew how to use both &lt;code&gt;hjkl&lt;/code&gt; and the arrow keys, I found myself almost exclusively using the former.&lt;/p&gt;&#xA;" OwnerUserId="7813" LastEditorUserId="7813" LastEditDate="2018-03-28T13:27:43.127" LastActivityDate="2018-03-28T13:27:43.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15691" PostTypeId="2" ParentId="14974" CreationDate="2018-03-27T08:15:48.487" Score="2" Body="&lt;p&gt;I map navigations such as &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; to add the current location to the jump list before jumping so I can always go back. In your case you'd need something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;space&amp;gt; mp`p&amp;lt;c-d&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then you can return after an accidental space with &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user859" LastEditorUserId="343" LastEditDate="2018-03-27T09:11:17.393" LastActivityDate="2018-03-27T09:11:17.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15692" PostTypeId="1" CreationDate="2018-03-27T08:16:48.170" Score="1" ViewCount="209" Body="&lt;p&gt;I'd like &lt;code&gt;=&lt;/code&gt; to indent block C-style comments like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Comment.&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;not this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Comment.&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the extra space before the last &lt;code&gt;*&lt;/code&gt;. (I would like to automatically align the first &lt;code&gt;/&lt;/code&gt; and the last &lt;code&gt;*&lt;/code&gt; at the current indentation level.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is a simple way, preferably compatible with &lt;code&gt;autoindent&lt;/code&gt;, to specify this in my &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="7813" LastEditorUserId="7813" LastEditDate="2018-03-27T08:47:36.967" LastActivityDate="2018-03-27T08:57:07.010" Title="How can I adjust ='s alignment of C-style comments?" Tags="|vimrc|indentation|alignment|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15693" PostTypeId="2" ParentId="15692" CreationDate="2018-03-27T08:43:09.183" Score="3" Body="&lt;p&gt;You can adjust the indent of the end comment by setting the &lt;code&gt;'comments'&lt;/code&gt; option. e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set comments=s:/*,m:\ ,e-3:*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is documented at &lt;code&gt;:help 'comments'&lt;/code&gt; and &lt;code&gt;:help format-comments&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also want to look into how you currently have it set by using the command: &lt;code&gt;:verbose set comments&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably should also consider using &lt;code&gt;'cindent'&lt;/code&gt; instead of &lt;code&gt;'autoindent'&lt;/code&gt;, and if you do so, you may want to take a look at: &lt;code&gt;:help cino-C&lt;/code&gt;, which will allow you to tweak the indent of that middle line.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-27T08:57:07.010" LastActivityDate="2018-03-27T08:57:07.010" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15698" PostTypeId="1" AcceptedAnswerId="15699" CreationDate="2018-03-27T11:12:58.943" Score="3" ViewCount="2297" Body="&lt;p&gt;I want to add section to mu airline that will display the output of a function called &lt;code&gt;SpinnerText()&lt;/code&gt; taken from &lt;a href=&quot;https://github.com/neomake/neomake/issues/112#issuecomment-318926748&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I honestly don't really understand how to do it and yes I did look at the documentation on the main page of &lt;a href=&quot;https://github.com/vim-airline/vim-airline#extensible-pipeline&quot; rel=&quot;nofollow noreferrer&quot;&gt;airline's repo&lt;/a&gt; but I still didn't really understand it as there wasn't an example about using a function call.&lt;/p&gt;&#xA;" OwnerUserId="11603" LastActivityDate="2021-05-13T10:20:19.653" Title="Add custom section to airline" Tags="|neovim|plugin-airline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15699" PostTypeId="2" ParentId="15698" CreationDate="2018-03-27T11:24:03.130" Score="11" Body="&lt;p&gt;The README of a project is not meant to be a complete documentation, generally it is worth reading the doc. For example: &lt;a href=&quot;https://github.com/vim-airline/vim-airline/blob/f1529ce051ee07381ab137d488e3e0c83e8f880c/doc/airline.txt#L1371-L1401&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h airline-advanced-customization&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-------------------------------------                        *airline-parts*&#xA;A part is something that contains metadata that eventually gets rendered into&#xA;the statusline. You can define parts that contain constant strings or&#xA;functions. Defining parts is needed if you want to use features like automatic&#xA;insertion of separators or hiding based on window width.&#xA;&#xA;For example, this is how you would define a part function:&#xA;  call airline#parts#define_function('foo', 'GetFooText')&#xA;&#xA;Here is how you would define a part that is visible only if the window width&#xA;greater than a minimum width.&#xA;  call airline#parts#define_minwidth('foo', 50)&#xA;&#xA;Parts can be configured to be visible conditionally.&#xA;  call airline#parts#define_condition('foo', 'getcwd() =~ &quot;work_dir&quot;')&#xA;&#xA;&#xA;Now add part &quot;foo&quot; to section section airline_section_y:&#xA;  let g:airline_section_y = airline#section#create_right(['ffenc','foo'])&#xA;&#xA;Note: Part definitions are combinative; e.g. the two examples above modify the&#xA;same `foo` part.&#xA;&#xA;Note: Look at the source code and tests for the full API.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can simply create your function, create a new part with &lt;code&gt;airline#parts#define_function&lt;/code&gt; and add this part to one of your sections.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-05-06T07:13:51.927" LastActivityDate="2019-05-06T07:13:51.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15700" PostTypeId="2" ParentId="15673" CreationDate="2018-03-27T12:43:53.260" Score="16" Body="&lt;p&gt;Other answers have said that the efficiency loss from moving your hands from the home row isn't that big a deal, and I mostly agree.  However, what &lt;em&gt;is&lt;/em&gt; a big deal is when you are learning vim, always using arrow keys to avoid switching back into normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, using a single &lt;kbd&gt;&amp;#8592;&lt;/kbd&gt; where you would have used a single &lt;kbd&gt;h&lt;/kbd&gt; isn't a huge loss in productivity, but using &lt;kbd&gt;&amp;#8592;&lt;/kbd&gt;&lt;kbd&gt;&amp;#8592;&lt;/kbd&gt;&lt;kbd&gt;&amp;#8592;&lt;/kbd&gt;&lt;kbd&gt;&amp;#8592;&lt;/kbd&gt;&lt;kbd&gt;&amp;#8592;&lt;/kbd&gt;&lt;kbd&gt;&amp;#8592;&lt;/kbd&gt;&lt;kbd&gt;&amp;#8592;&lt;/kbd&gt;&lt;kbd&gt;&amp;#8592;&lt;/kbd&gt;&lt;kbd&gt;&amp;#8592;&lt;/kbd&gt;&lt;kbd&gt;&amp;#8592;&lt;/kbd&gt; where you could have used &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;I&lt;/kbd&gt; &lt;em&gt;is&lt;/em&gt; a huge loss.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why people tell you to avoid the arrow keys when you're learning vim, because it forces you to learn normal mode instead of never leaving insert mode.  Normal mode is where all your efficiency gains are.&lt;/p&gt;&#xA;" OwnerUserId="780" LastActivityDate="2018-03-27T12:43:53.260" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15702" PostTypeId="1" AcceptedAnswerId="15703" CreationDate="2018-03-27T16:02:42.840" Score="4" ViewCount="429" Body="&lt;p&gt;I think this should be a quick answer, but I can't figure it out from &lt;code&gt;:help location-list&lt;/code&gt; and my Google searches seem to highlight that I may not know the correct terms to look for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the sake of this scenario, lets say I'm using syntastic to run &lt;code&gt;hlint&lt;/code&gt; on a Haskell file, and it's adding things to the location-list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my &lt;code&gt;.vimrc&lt;/code&gt;, I have &lt;code&gt;set nowrap&lt;/code&gt; on (that's the way I like it) but I am imagining that since the &lt;code&gt;location-list&lt;/code&gt; is a separate pane that I could probably target it with something akin to &lt;code&gt;autocmd [???] location-list set wrap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way? (I would especially appreciate a link to the docs about this because I think that might help me grok stuff inthe future.)&lt;/p&gt;&#xA;" OwnerUserId="16897" LastEditorUserId="1841" LastEditDate="2018-03-27T16:13:48.020" LastActivityDate="2018-03-27T16:17:59.727" Title="How do I wrap the location-list by default (without turning on wrap for files)?" Tags="|wrapping|plugin-syntastic|location-list|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15703" PostTypeId="2" ParentId="15702" CreationDate="2018-03-27T16:07:25.483" Score="11" Body="&lt;p&gt;You can indeed use an autocommand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyStuff&#xA;  autocmd!&#xA;  autocmd FileType qf setlocal wrap&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will affect the quickfix window, too, but I presume that would be desirable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find a sort of oblique reference to this in the documentation by opening &lt;code&gt;:help location-list&lt;/code&gt; and then searching for &lt;code&gt;filetype&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even better, use Vim's &lt;code&gt;after&lt;/code&gt; directory. Create a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.vim/after/ftplugin/qf.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal wrap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is documented in &lt;code&gt;:help after-directory&lt;/code&gt; and, perhaps more relevantly, in &lt;code&gt;:help ftplugin-overrule&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-27T16:17:59.727" LastActivityDate="2018-03-27T16:17:59.727" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15704" PostTypeId="1" CreationDate="2018-03-27T16:12:54.693" Score="2" ViewCount="62" Body="&lt;p&gt;Using GVIM, I sometimes hold ctrl-d to page-down a lot, and I let go of ctrl first (unintentionally and momentarily) and cause a line to be deleted b/c an additional 'd' without 'ctrl' is sent. What is the expected behavior on different operating systems? I remember testing this a while back and seeing MacOS not perform a repeat of 'd', but now I see it does. Is there a standard resolution to this issue? Is it a GVIM issue?&lt;/p&gt;&#xA;" OwnerUserId="16900" OwnerDisplayName="nachum" LastEditorUserId="11357" LastEditDate="2018-08-31T10:21:54.997" LastActivityDate="2018-08-31T10:21:54.997" Title="Key repeat - removal of modifier" Tags="|gvim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15706" PostTypeId="2" ParentId="15673" CreationDate="2018-03-27T20:02:46.830" Score="7" Body="&lt;p&gt;There are two main reasons why people say you shouldn't use the arrow keys.  Some claim that hjkl is preferred because it keeps your hands on the home row, which isn't &lt;em&gt;false&lt;/em&gt;, but also doesn't matter.  Others, including myself, would say you shouldn't use the arrow keys if you're moving more than a few characters, but you shouldn't use hjkl, either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The important thing isn't &lt;em&gt;which&lt;/em&gt; keys you're using, but rather &lt;em&gt;how many&lt;/em&gt;.  If you want to move to the beginning of the word, you don't hit &lt;code&gt;hhh&lt;/code&gt;; you hit &lt;code&gt;b&lt;/code&gt;.  End of the word is &lt;code&gt;e&lt;/code&gt;, not &lt;code&gt;llll&lt;/code&gt;.  Beginning of the line: &lt;code&gt;0&lt;/code&gt;, end of the line: &lt;code&gt;$&lt;/code&gt;.  And anything further, &lt;code&gt;/search&lt;/code&gt; for the text that exists where you want to go. (or whichever of the advanced movement commands you prefer).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But any time you find yourself typing the same key more than twice in a row, there's a better way to do it.&lt;/p&gt;&#xA;" OwnerUserId="10995" LastActivityDate="2018-03-27T20:02:46.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15707" PostTypeId="2" ParentId="5032" CreationDate="2018-03-27T20:39:04.970" Score="0" Body="&lt;p&gt;I'm on OS X and running the following command in vim worked for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_browser_viewer='open'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13702" LastActivityDate="2018-03-27T20:39:04.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15708" PostTypeId="2" ParentId="11697" CreationDate="2018-03-28T00:21:53.780" Score="3" Body="&lt;ul&gt;&#xA;&lt;li&gt;Search for empty quotes: &lt;code&gt;/&quot;&quot;&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;Repeat search with &lt;kbd&gt;n&lt;/kbd&gt; key;&lt;/li&gt;&#xA;&lt;li&gt;Enter text into empty quotes with &lt;kbd&gt;a&lt;/kbd&gt; key.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16911" LastActivityDate="2018-03-28T00:21:53.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15709" PostTypeId="1" CreationDate="2018-03-28T09:23:13.953" Score="5" ViewCount="3498" Body="&lt;p&gt;I'm often editing code where others didn't care about trailing white-spaces. I'm using the &lt;a href=&quot;https://vi.stackexchange.com/a/456/1542&quot;&gt;TrimWhiteSpace()-function from this answer&lt;/a&gt; to remove white-spaces when saving the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However that leaves me with changes all other the file and VCS gives me many unrelated changes to revert or to commit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I would like to automatically strip trailing white-spaces of every line I pressed &lt;kbd&gt;ENTER&lt;/kbd&gt; while being in insert-mode. At least I think this is what I need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this? Googling for some seconds did not bring up anything (not even on this site).&lt;/p&gt;&#xA;" OwnerUserId="1542" LastActivityDate="2018-03-28T16:20:16.637" Title="How to remove trailing white-spaces automatically while typing?" Tags="|whitespace|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15710" PostTypeId="1" AcceptedAnswerId="15789" CreationDate="2018-03-28T10:04:27.860" Score="0" ViewCount="64" Body="&lt;pre&gt;&lt;code&gt;vim command.txt&#xA;key=&quot;123456&quot;&#xA;openssl enc -des3 -a -salt -in /tmp/test   -k ${key} -out /tmp/test.asc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In vim's command mode &lt;code&gt;:1,2!bash&lt;/code&gt;,the file &lt;code&gt;/tmp/test&lt;/code&gt; was encrypted into &lt;code&gt;/tmp/test.asc&lt;/code&gt; ,but all the lines in command.txt dispear,where is my lines in the edited file &lt;code&gt;command.txt&lt;/code&gt;?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YrfGx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YrfGx.png&quot; alt=&quot;Why all lines dispear after executing the lines on edited file?&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to recover it?&lt;br&gt;&#xA;How to keep all the lines in vim after executed by bash?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="5181" LastEditDate="2018-04-01T08:41:20.660" LastActivityDate="2018-04-02T00:52:50.270" Title="Why all lines dispear after executing the lines on edited file?" Tags="|bash|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15711" PostTypeId="2" ParentId="15709" CreationDate="2018-03-28T10:14:19.857" Score="3" Body="&lt;p&gt;I think someone is probably going to shoot me for this monstrosity. However:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;CR&amp;gt; &amp;lt;Esc&amp;gt;g_lDo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This maps insert mode &lt;Kbd&gt;Enter&lt;/Kbd&gt; to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;: return to normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g_&lt;/code&gt;: move to last non-blank character in line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;l&lt;/code&gt;: move one character to the right&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;D&lt;/code&gt;: delete to end of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&lt;/code&gt;: move to the next line, returning to insert mode&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;While I guess this accomplishes what you describe, I suspect there's a case I haven't thought of which will produce weird and wonderful behaviour! It could also prove quite nasty for any file types where whitespace is important or required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you note, there are tools out there which strip whitespace from end of line on save. For completeness, I'll mention that the &lt;a href=&quot;http://vim.wikia.com/wiki/Remove_unwanted_spaces&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Wikia&lt;/a&gt; describes a number of them, this for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Strip line endings for certain filetypes&#xA;autocmd FileType c,cpp,java,php autocmd BufWritePre &amp;lt;buffer&amp;gt; %s/\s\+$//e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="463" LastActivityDate="2018-03-28T10:14:19.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15712" PostTypeId="2" ParentId="15704" CreationDate="2018-03-28T10:31:05.747" Score="1" Body="&lt;p&gt;I don't think it's GVim. This happens in the Linux terminal too. It may be OS-dependent, but I suspect it's more likely that you can count on the next key repeat of &lt;Kbd&gt;d&lt;/Kbd&gt; to be interpreted as &lt;Kbd&gt;d&lt;/Kbd&gt; and not &lt;Kbd&gt;Ctrl&lt;/Kbd&gt;&lt;Kbd&gt;D&lt;/Kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What to do? Pak's &lt;Kbd&gt;Ctrl&lt;/Kbd&gt;&lt;Kbd&gt;F&lt;/Kbd&gt; suggestion is a good one (&lt;code&gt;:help pagedown&lt;/code&gt;). Faster, too. You could also consider binding &lt;Kbd&gt;Ctrl&lt;/Kbd&gt;&lt;Kbd&gt;J&lt;/Kbd&gt;, which would leave you moving down one line at a time if you lift up the wrong key. (I use that to move between splits, but it might work for you).&lt;/p&gt;&#xA;" OwnerUserId="463" LastActivityDate="2018-03-28T10:31:05.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15713" PostTypeId="1" CreationDate="2018-03-28T10:52:13.237" Score="12" ViewCount="1214" Body="&lt;h3&gt;Use Case&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I'm in normal mode. I've not explicitly thought about recording a macro, but I make a single command change. I can now repeat this action by using dot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I now realize it's a useful action to save in a macro to use later rather than typing the whole command every time. I can either attend to all the changes which need this command right now by using dot, or I can continue with editing and use this command later by saving it in a macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The latter is what I want to do, but the easiest way I can think of doing it is not easy - undo my change, start recording a macro and retype the command to make the required change and stop recording the macro. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;What I've Tried so Far:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Recording dot in a macro doesn't work because it records the dot and not the change which dot performs. (For example, let's say the command stored in dot was &lt;code&gt;d5w&lt;/code&gt; If you start recording a macro and do the action via . expecting that it'll delete 5 words every time you run the macro, then that will not happen. The next time you run the macro it'll do dot and not the command &lt;code&gt;d5w&lt;/code&gt;. This means that if you made some other change after recording the macro - say delete 3 words using &lt;code&gt;d3w&lt;/code&gt; and it was the last change you performed, then when you run the macro it will delete 3 words and not 5, because it's just running &lt;code&gt;.&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="12650" LastActivityDate="2018-07-01T22:19:42.323" Title="Save last action (.) in a macro" Tags="|macro|repeated-commands|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15714" PostTypeId="2" ParentId="15709" CreationDate="2018-03-28T11:00:24.310" Score="0" Body="&lt;p&gt;I'd count the number of space characters before the cursor at the moment &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; is hit and produce as many &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt;. It can be done with &lt;code&gt;substitute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; substitute(matchstr(getline('.')[: col('.')-2], '\S\zs\s*$'), '.', &quot;&amp;lt;bs&amp;gt;&quot;, 'g').&quot;&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or with &lt;code&gt;repeat&lt;/code&gt;+&lt;code&gt;len&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; repeat(&quot;&amp;lt;bs&amp;gt;&quot;, len(matchstr(getline('.')[: col('.')-2], '\S\zs\s*$'))).&quot;&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As there is no movement/break (with &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;) in the flow of this solution, anything that is typed can be undone, redone , etc. However, if you start a new insert sequence to cut after a series of spaces, redoing the same insertion sequence with &lt;code&gt;.&lt;/code&gt; elsewhere is likely to remove too many characters.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;\S\zs&lt;/code&gt; is a workaround when we're on en empty line and when each &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; deletes &lt;code&gt;&amp;amp;sw&lt;/code&gt; characters. In that case I should check &lt;code&gt;getline()&lt;/code&gt; result and do something smarter.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A version that behaves a little bit better regarding indented empty lines is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:trim_ws_on_the_fly()&#xA;  let line = getline('.')&#xA;  &quot; TODO: set and reset &amp;amp;bs&#xA;  if line =~ '^\s*$'&#xA;    let nb = (virtcol('.') + 2*&amp;amp;sw-2) / &amp;amp;sw - 1&#xA;    &quot; echomsg &quot;remove &quot;virtcol('.').'/'.&amp;amp;sw.' -&amp;gt; '.nb&#xA;  else&#xA;    let nb = len(matchstr(line[: col('.')-2], '\s*$'))&#xA;    let line = ''&#xA;  endif&#xA;  return repeat(&quot;\&amp;lt;bs&amp;gt;&quot;, nb).&quot;\&amp;lt;cr&amp;gt;&quot;.line&#xA;endfunction&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; &amp;lt;sid&amp;gt;trim_ws_on_the_fly()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-03-28T16:20:16.637" LastActivityDate="2018-03-28T16:20:16.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15715" PostTypeId="2" ParentId="15709" CreationDate="2018-03-28T13:08:42.367" Score="5" Body="&lt;p&gt;I'd do it with an autocommand that fires whenever you leave insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PreciseTrimWhiteSpace()&#xA;  &quot; We need to save the view because the substitute command might&#xA;  &quot; or might not move the cursor, depending on whether it finds&#xA;  &quot; any whitespace.&#xA;  let saved_view = winsaveview()&#xA;&#xA;  &quot; Remove white space. Ignore &quot;not found&quot; errors. Don't change jumplist.&#xA;  keepjumps '[,']s/\s\+$//e&#xA;&#xA;  &quot; Move cursor back if necessary.&#xA;  call winrestview(saved_view)&#xA;endfunction&#xA;&#xA;augroup PreciseTrimWhiteSpace&#xA;  autocmd!&#xA;  autocmd InsertLeave * call PreciseTrimWhiteSpace()&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This performs a substitute command using the range of lines between the &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt; marks: i.e. it removes whitespace that was introduced by the most recent insert.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To me, this seems more elegant than using an insert mapping, (but others may disagree).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help InsertLeave&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help ranges&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :s_flags&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :keepjumps&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help '[&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-28T13:22:31.113" LastActivityDate="2018-03-28T13:22:31.113" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15716" PostTypeId="1" AcceptedAnswerId="15782" CreationDate="2018-03-28T15:57:34.620" Score="2" ViewCount="83" Body="&lt;p&gt;I use this keymapping toggle to highlighting on and off, but when I originally found it, the author did not list two &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; at the end of the command. I found that if I didn't have two &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; there, then I was required to press &lt;kbd&gt;Return&lt;/kbd&gt; after my keymapping. Why? ... because now that I can get the macro (wrong term?) to execute, my cursor advances to the next line after executing the mapping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight OverLength ctermbg=gray&#xA;match OverLength /\%81v.\+/&#xA;let OLstate = 1&#xA;nnoremap oi : if (OLstate == 0) \| match OverLength /%81v.\+/ \| else \| match OverLength /%9999v/ \| endif \| let OLstate = 1 - OLstate &amp;lt;cr&amp;gt; &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16795" LastEditorUserId="16795" LastEditDate="2019-02-01T18:17:36.660" LastActivityDate="2019-02-01T18:17:36.660" Title="Why are two &lt;cr&gt; characters required when executing this highlighting toggle command?" Tags="|key-bindings|command-line|normal-mode|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15717" PostTypeId="1" CreationDate="2018-03-28T17:30:27.717" Score="0" ViewCount="1096" Body="&lt;p&gt;Using textwidth (tw=74) a word will be moved to the next line (with an indent usually) with a newline character at the end of the line avoiding over-length. This is a hard wrap, and resizing the window will not change the location of the wrap. Using &lt;code&gt;:set wrap&lt;/code&gt;, soft wrapping sends the text that would fall off the right side of the window to the next line instead, keeping all of a line's text visible. I'd like to combine some of each function, such that a word moves entirely to the next line after a certain point, but does not get permanently sent there in the file with a newline character. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't matter if this sending to the next line occurs only immediately after a string broaching the set number of columns.&lt;/p&gt;&#xA;" OwnerUserId="16795" LastActivityDate="2022-05-10T01:04:57.443" Title="How can I soft-wrap a word to a new line?" Tags="|wrapping|line-breaks|multiple-lines|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15718" PostTypeId="1" CreationDate="2018-03-28T19:02:56.720" Score="0" ViewCount="635" Body="&lt;p&gt;How can I compile vim for my user only so set source path to /home/user/ ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And how can I track changes with git.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I want to build and compile vim from source, and store it on my github repo. Then other users can download the vim from github and use it.&lt;/p&gt;&#xA;" OwnerUserId="16591" LastEditorUserId="28" LastEditDate="2018-03-29T01:56:53.900" LastActivityDate="2018-10-18T23:11:00.033" Title="How to compile vim for user only and use git to track it?" Tags="|git|path|compile-vim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15719" PostTypeId="2" ParentId="15717" CreationDate="2018-03-28T19:41:06.320" Score="1" Body="&lt;p&gt;I think you're looking for the &lt;code&gt;'linebreak'&lt;/code&gt; option:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:set linebreak&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;code&gt;:help 'linebreak'&lt;/code&gt; for details, including the use of &lt;code&gt;'breakat'&lt;/code&gt;, &lt;code&gt;'breakindent'&lt;/code&gt;, and &lt;code&gt;'showbreak'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="10604" LastEditDate="2022-05-10T01:04:57.443" LastActivityDate="2022-05-10T01:04:57.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15720" PostTypeId="1" AcceptedAnswerId="15727" CreationDate="2018-03-28T19:59:17.007" Score="0" ViewCount="95" Body="&lt;p&gt;I recently discovered the world of vim session files, and they are awesome for working with multi-file code projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when opening a &lt;code&gt;man&lt;/code&gt; page I don't need a session file created for viewing man pages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like using Neovim to view man pages because of the color and trackpad support when reading a man page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently cobbled the below together to view man pages using a function called &lt;code&gt;vman&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function vman --description 'use vim / nvim to read man pages'&#xA;  man $argv | col -bp | iconv -c | nvim 'set ft=man nomod nolist' -;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I invoke, &lt;code&gt;nvim&lt;/code&gt; it loads the below &lt;code&gt;session.vim&lt;/code&gt; file from &lt;code&gt;$HOME/.vim/plugin&lt;/code&gt; directory&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; CREDIT: https://stackoverflow.com/a/47656092/708807&#xA;&#xA;function! MakeSession(overwrite)&#xA;  let b:sessiondir = $HOME . &quot;/.vim/sessions&quot; . getcwd()&#xA;  if (filewritable(b:sessiondir) != 2)&#xA;    exe 'silent !mkdir -p ' b:sessiondir&#xA;    redraw!&#xA;  endif&#xA;  let b:filename = b:sessiondir . '/session.vim'&#xA;  if a:overwrite == 0 &amp;amp;&amp;amp; !empty(glob(b:filename))&#xA;    return&#xA;  endif&#xA;  exe &quot;mksession! &quot; . b:filename&#xA;endfunction&#xA;&#xA;function! LoadSession()&#xA;  let b:sessiondir = $HOME . &quot;/.vim/sessions&quot; . getcwd()&#xA;  let b:sessionfile = b:sessiondir . &quot;/session.vim&quot;&#xA;  if (filereadable(b:sessionfile))&#xA;    exe 'source ' b:sessionfile&#xA;  else&#xA;    echo &quot;No session loaded.&quot;&#xA;  endif&#xA;endfunction&#xA;&#xA;&quot; Adding automatons for when entering or leaving Vim&#xA;if(argc() == 0)&#xA;  au VimEnter * nested :call LoadSession()&#xA;  au VimLeave * :call MakeSession(1)&#xA;else&#xA;  au VimLeave * :call MakeSession(0)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there some a way I can check to see if the buffer is loading a &lt;code&gt;.man&lt;/code&gt; file and not create a session file?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Per Rich's answer, I ended up modifying the above posted &lt;code&gt;sessions.vim&lt;/code&gt; file to the below,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&quot; sessions.vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; CREDIT: https://stackoverflow.com/a/47656092/708807&#xA;&#xA;    function! MakeSession(overwrite)&#xA;      if &amp;amp;filetype ==? 'man'&#xA;        return&#xA;      else&#xA;        let b:sessiondir = $HOME . &quot;/.vim/sessions&quot; . getcwd()&#xA;        if (filewritable(b:sessiondir) != 2)&#xA;          exe 'silent !mkdir -p ' b:sessiondir&#xA;          redraw!&#xA;        endif&#xA;        let b:filename = b:sessiondir . '/session.vim'&#xA;        if a:overwrite == 0 &amp;amp;&amp;amp; !empty(glob(b:filename))&#xA;          return&#xA;        endif&#xA;        exe &quot;mksession! &quot; . b:filename&#xA;      endif&#xA;    endfunction&#xA;&#xA;    function! LoadSession()&#xA;      if &amp;amp;filetype ==? 'man'&#xA;        return&#xA;      else&#xA;        let b:sessiondir = $HOME . &quot;/.vim/sessions&quot; . getcwd()&#xA;        let b:sessionfile = b:sessiondir . &quot;/session.vim&quot;&#xA;        if (filereadable(b:sessionfile))&#xA;          exe 'source ' b:sessionfile&#xA;        else&#xA;          echo &quot;No session loaded.&quot;&#xA;        endif&#xA;      endif&#xA;    endfunction&#xA;&#xA;    &quot; Adding automatons for when entering or leaving Vim&#xA;    if(argc() == 0)&#xA;      au VimEnter * nested :call LoadSession()&#xA;      au VimLeave * :call MakeSession(1)&#xA;    else&#xA;      au VimLeave * :call MakeSession(0)&#xA;    endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10550" LastEditorUserId="10550" LastEditDate="2018-03-29T18:01:13.330" LastActivityDate="2018-03-29T18:01:13.330" Title="How to NOT create a view and session file when viewing man pages" Tags="|vimscript|neovim|sessions|pager|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15721" PostTypeId="1" AcceptedAnswerId="15742" CreationDate="2018-03-28T20:04:24.500" Score="1" ViewCount="212" Body="&lt;p&gt;I am trying to write my PhD thesis in vim using LaTeX&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the documents will have two distinct types of content - markups that are relatively short, and paragraph text that is rather long.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{some environment}&#xA; Long content here (Lorem  ipsum dolor ......&#xA;.........&#xA;\end{end enviroment}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the drafts will involve a lot of edits, in order to keep my writing comprehensible for the text, I had set an &lt;code&gt;autocmd&lt;/code&gt; to set &lt;code&gt;formatoptions=at&lt;/code&gt; and &lt;code&gt;textwidth=110&lt;/code&gt; based on &lt;code&gt;filetype=tex&lt;/code&gt; so that vim shall insert linebreaks appropriately and reformat documents on the fly upon delete/edit cycles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that these reformats happen for the markup text also. For example, if I edit just the markup, the autoformatting kicks in, realigning linebreaks to satisfy the textwidth setting. Similarly, comment lines are also mangled up by the on-the-fly reformatting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I set up the &lt;code&gt;formatoptions&lt;/code&gt; in my vimrc in such a way that these autocommands fire only for long paragraphs and leaves short texts and comments unchanged.&lt;/p&gt;&#xA;" OwnerUserId="8408" LastActivityDate="2018-03-31T06:15:19.590" Title="formatoptions for hybrid (short markup + long paragraphs) content" Tags="|autocmd|formatting|filetype|filetype-tex|wrapping|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15722" PostTypeId="1" CreationDate="2018-03-28T23:21:41.000" Score="6" ViewCount="988" Body="&lt;p&gt;From Terminal.app on my Mac, I SSH in to a box where I run Vim 8.0.1601. Left at that, everything works fine. But if I launch Vim from within a tmux window, go to insert mode, and then attempt to paste text from my Mac's clipboard into the terminal window, autoindent breaks the formatting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I place this on my Mac's clipboard...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Level 1&#xA;    Level 2&#xA;    Level 2&#xA;Level 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and then paste it into Vim running in tmux, I get this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Level 1&#xA;    Level 2&#xA;        Level 2&#xA;        Level 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is all wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the standard solution to this problem is to use &quot;paste mode&quot; as described here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/2514445/turning-off-auto-indent-when-pasting-text-into-vim&quot;&gt;https://stackoverflow.com/questions/2514445/turning-off-auto-indent-when-pasting-text-into-vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I shouldn't have to do this because Terminal.app supports bracketed paste mode (described here: &lt;a href=&quot;https://cirw.in/blog/bracketed-paste&quot; rel=&quot;noreferrer&quot;&gt;https://cirw.in/blog/bracketed-paste&lt;/a&gt;), and so does Vim. And I can confirm bracketed paste mode results in the correct paste behavior without my having to manually invoke paste mode—at least it works if I don't run tmux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without running tmux I see $TERM is set to xterm-256color, which matches Terminal.app's declaration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From within tmux I can see $TERM is set to &quot;screen-256color&quot;. From within tmux, if I override $TERM (I run &quot;export TERM=xterm-256color&quot;) and then run Vim, bracketed paste mode works, and my pastes from my Mac are once again correctly indented. But this is a hack, and I don't know what unintended side effects I'm signing up for by spoofing $TERM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim seem to look for &quot;xterm-256color&quot; in $TERM so it knows it is safe to offer bracketed paste mode. But in the case of tmux, it seems to be safe anyway. tmux just doesn't present to Vim a $TERM of &quot;xterm-256color&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are plugins and .vimrc configurations that address this (see &lt;a href=&quot;https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode&quot; rel=&quot;noreferrer&quot;&gt;https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode&lt;/a&gt;). But it doesn't seem like one should have to do any of this given that Vim already implements the functionality natively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing the &quot;correct&quot; way to make this work?&lt;/p&gt;&#xA;" OwnerUserId="16930" LastActivityDate="2018-06-26T16:31:01.227" Title="Vim, tmux, and xterm-bracketed-paste" Tags="|cut-copy-paste|tmux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15723" PostTypeId="2" ParentId="15718" CreationDate="2018-03-28T23:36:17.303" Score="4" Body="&lt;ol&gt;&#xA;&lt;li&gt;Google for vim to find their homepage. You find &lt;a href=&quot;http://www.vim.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.vim.org&lt;/a&gt; .&lt;/li&gt;&#xA;&lt;li&gt;Look on their homepage, where is their upstream source. If you have luck, they are on the github.&lt;/li&gt;&#xA;&lt;li&gt;On the &quot;&lt;a href=&quot;https://www.vim.org/download.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;Download&lt;/a&gt;&quot; section, they show many of their upstreams, first is the github one.&lt;/li&gt;&#xA;&lt;li&gt;They say, &lt;code&gt;git clone https://github.com/vim/vim.git&lt;/code&gt; is the clone command what you want, however you want likely to register/login github&lt;sup&gt;1&lt;/sup&gt; (later I explain why).&lt;/li&gt;&#xA;&lt;li&gt;So go to their github page, &lt;a href=&quot;https://github.com/vim/vim.git&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim.git&lt;/a&gt; , which redirects to their project page, &lt;a href=&quot;https://github.com/vim/vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim&lt;/a&gt; . This is the official upstream. Many project has only a mirror on the github, typically you can't issue merge requests for them, and they may be late (sometimes even with years). This time, not this is the case.&lt;/li&gt;&#xA;&lt;li&gt;Fork the project by clicking the &quot;Fork&quot; button on the github. Now you have your cloned repository, in &lt;code&gt;https://github.com/&amp;lt;yourusername&amp;gt;/vim.git&lt;/code&gt; .&lt;/li&gt;&#xA;&lt;li&gt;Clone this into your computer with the command &lt;code&gt;git clone git@github.com:&amp;lt;yourusername&amp;gt;/vim.git&lt;/code&gt;. Do this into your home.&lt;/li&gt;&#xA;&lt;li&gt;Now you have the latest vim sources in your &lt;code&gt;/home/user/vim&lt;/code&gt; directory.&lt;/li&gt;&#xA;&lt;li&gt;Compile this as they say, which is typically a &lt;code&gt;./configure&lt;/code&gt; command. However, you want to install it into your home, so you need also a &lt;code&gt;--prefix=/home/&amp;lt;yourusername&amp;gt;/vim-dist&lt;/code&gt; or similar flag.&lt;/li&gt;&#xA;&lt;li&gt;Put also other flags, as &lt;code&gt;./configure --help&lt;/code&gt; explains. Selecting them may be a big work, but it worths its price.&lt;/li&gt;&#xA;&lt;li&gt;Add also the upstream repository to the remote repositories with the command &lt;code&gt;git remote add upstream git@github.com:vim/vim.git&lt;/code&gt;, followed by a &lt;code&gt;get fetch --all&lt;/code&gt;. In this scenario, you will working and commiting to your own repository, but you will be able to fetch newer commit (= changes) from the upstream.&lt;/li&gt;&#xA;&lt;li&gt;You may not surely work on their &lt;code&gt;master&lt;/code&gt; branch, but it is very likely, because they don't use branches, only tags.&lt;/li&gt;&#xA;&lt;li&gt;So, after compiling git, install it with &lt;code&gt;make install&lt;/code&gt;. The &lt;code&gt;--prefix&lt;/code&gt; flag in your configuration step guarantees that this will install vim into your &lt;code&gt;/home/&amp;lt;yourusername&amp;gt;/vim-dist&lt;/code&gt; directory.&lt;/li&gt;&#xA;&lt;li&gt;A well-working project should have to use a correct &lt;code&gt;.gitignore&lt;/code&gt;, i.e. compilation-time generated temporary files (objects, for example) should exist as new source file, rather they should be ignored by the git. You can check this with a &lt;code&gt;git status&lt;/code&gt; command. If you see new files in the compilation, then your first task is to fix their &lt;code&gt;.gitignore&lt;/code&gt; and make a pull request from that.&lt;/li&gt;&#xA;&lt;li&gt;It is possible, that some of your libraries won't exist on the system, the &lt;code&gt;configure&lt;/code&gt; script will explain, which ones. You will need to find and compile also them, if you don't have a root account to install packages system-wide.&lt;/li&gt;&#xA;&lt;li&gt;Tune your initfiles to use the vim in your installation path: either you can put &lt;code&gt;/home/&amp;lt;yourusername&amp;gt;/vim-dist/bin&lt;/code&gt; into your &lt;code&gt;PATH&lt;/code&gt;, or you can have a &lt;code&gt;/home/&amp;lt;yourusername&amp;gt;/bin&lt;/code&gt; directory, which is already included into your &lt;code&gt;PATH&lt;/code&gt;, and which contains wrapper script to anything what you are installing as a user.&lt;/li&gt;&#xA;&lt;li&gt;Sometimes it is useful to fetch the upstream changes with a &lt;code&gt;git fetch --all&lt;/code&gt;, and merge them into your according branch(es), this time &lt;code&gt;git merge remotes/upstream/master&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If you make a change, it is practical to upload to the github with a &lt;code&gt;git push&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If you make an useful change, go to page of your fork, (&lt;code&gt;https://github.com/&amp;lt;yourusername&amp;gt;/vim&lt;/code&gt;), and click &lt;em&gt;create pull request&lt;/em&gt;. This advices your changes to the upstream developers, who may decide to include your commits into the upstream repository. It is a big glory, if it first time happens.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;sub&gt;Meanwhile, Github was bought by the Microsoft, and it is now a Microsoft division. Being likely an opensource enthusiast, it is up to you, how it will affect your free hosting choices. I personally moved to &lt;a href=&quot;https://gitlab.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="28" LastEditorUserId="28" LastEditDate="2018-10-18T23:11:00.033" LastActivityDate="2018-10-18T23:11:00.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15724" PostTypeId="1" CreationDate="2018-03-29T01:43:47.307" Score="4" ViewCount="923" Body="&lt;p&gt;It used to work by adding following line into a file even it has no suffix &lt;code&gt;.vim&lt;/code&gt;, my vim version is &lt;code&gt;v8.0.1500&lt;/code&gt;, on &lt;code&gt;OS X 10.13.3&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim:ft=vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried adding following two lines to &lt;strong&gt;$MYVIMRC&lt;/strong&gt;, after &lt;code&gt;filetype plugin indent on&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set modeline&#xA;set modelines=5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And changed &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim:ft=vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim:set  ft=vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Still doesn't work :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is my &lt;a href=&quot;https://github.com/kenshinji/dotfiles/blob/master/vim/.vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;.vimrc&lt;/a&gt; for reference, and for example, &lt;a href=&quot;https://github.com/kenshinji/dotfiles/blob/master/vim/rcplugins/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;this file&lt;/a&gt; couldn't be detected as a vim file.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SOLUTION&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Add following two lines to &lt;strong&gt;$MYVIMRC&lt;/strong&gt;, after &lt;code&gt;filetype plugin indent on&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;set modeline&#xA;set modelines=5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;use &lt;code&gt;&quot; vim:ft=vim&lt;/code&gt; or &lt;code&gt;&quot; vim:set  ft=vim:&lt;/code&gt; instead of &lt;code&gt;&quot; vim:set  ft=vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7971" LastEditorUserId="7971" LastEditDate="2018-04-03T01:50:43.620" LastActivityDate="2018-08-14T17:34:17.590" Title="Vim can't detect if a file is vim file type by commenting a file with vim:ft=vim" Tags="|filetype|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="15725" PostTypeId="2" ParentId="15724" CreationDate="2018-03-29T01:55:25.323" Score="1" Body="&lt;p&gt;You need to have &lt;code&gt;:set modeline&lt;/code&gt; (e.g. in your &lt;code&gt;~/.vimrc&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="1111" LastEditDate="2018-08-14T17:31:54.583" LastActivityDate="2018-08-14T17:31:54.583" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="15727" PostTypeId="2" ParentId="15720" CreationDate="2018-03-29T08:58:02.803" Score="1" Body="&lt;p&gt;So long as you don't open lots of other files inside the instance of Vim that you're using to view man pages, you can achieve this by checking the file type of the current buffer before saving the session:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MakeSession(overwrite)&#xA;  if &amp;amp;filetype ==? 'man'&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; The rest of your code...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-03-29T08:58:02.803" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15728" PostTypeId="2" ParentId="509" CreationDate="2018-03-29T09:07:28.870" Score="0" Body="&lt;p&gt;Mark the text using the visual command and then use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!par 40j &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where 40 is the column width and &lt;code&gt;j&lt;/code&gt; means justify.&lt;/p&gt;&#xA;" OwnerUserId="16937" LastEditorUserId="1841" LastEditDate="2018-03-29T09:56:13.600" LastActivityDate="2018-03-29T09:56:13.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15729" PostTypeId="1" AcceptedAnswerId="15737" CreationDate="2018-03-29T09:11:42.983" Score="2" ViewCount="1330" Body="&lt;p&gt;I was wondering if the statusline between horizontal splits can be removed. Maybe it can be replaced by command line? &lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2018-03-29T15:40:45.003" Title="remove vim statusline for horizontal splits with laststatus already set to 0" Tags="|statusline|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15730" PostTypeId="2" ParentId="15710" CreationDate="2018-03-29T09:43:36.817" Score="2" Body="&lt;p&gt;Vim is removing the lines because you are instructing it to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The feature you're invoking with your command is the &quot;filter&quot; feature. This takes all or some of the contents of a file, passes them to an external command on standard input, &lt;em&gt;and then replaces them with the output of that command&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are passing two commands to the &lt;code&gt;bash&lt;/code&gt; program. It executes them, but doing so does not result in any output, so the net effect on your file is that the lines are removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help filter&lt;/code&gt; for more details, and specifically &lt;code&gt;:help :range!&lt;/code&gt; for the variation you're using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would offer some more suggestions on better methods to achieve your goal, but I'm afraid I don't really understand what it is you're trying to do.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-03-29T09:43:36.817" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15731" PostTypeId="1" AcceptedAnswerId="15732" CreationDate="2018-03-29T09:49:05.567" Score="0" ViewCount="230" Body="&lt;p&gt;I want to define &lt;code&gt;&amp;lt;C-s&amp;gt;&lt;/code&gt; to save current editing file in any mode.&lt;br&gt;&#xA;&lt;code&gt;map &amp;lt;C-s&amp;gt; :call StripWhitespace()&amp;lt;CR&amp;gt;&lt;/code&gt; works fine in normal mode. But if I'm in insert mode, always need to &lt;code&gt;Esc&lt;/code&gt; before saving.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tried below methods, but failed.&lt;br&gt;&#xA;&lt;code&gt;imap &amp;lt;C-s&amp;gt; :call StripWhitespace()&amp;lt;CR&amp;gt;&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! My_Force_Save()&#xA;   if mode() != 'n'&#xA;      exe &quot;normal! \&amp;lt;esc&amp;gt;&quot;&#xA;   endif&#xA;   call StripWhitespace()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! StripWhitespace ()&#xA;    let save_cursor = getpos(&quot;.&quot;)&#xA;    let old_query = getreg('/')&#xA;    :%s/\s\+$//e&#xA;    call setpos('.', save_cursor)&#xA;    call setreg('/', old_query)&#xA;    exe &quot;:w!&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-03-30T07:25:13.140" Title="How to create a key mapping to save file in any mode?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15732" PostTypeId="2" ParentId="15731" CreationDate="2018-03-29T10:14:54.870" Score="4" Body="&lt;p&gt;The &lt;code&gt;:map&lt;/code&gt; command you tried works in normal,&#xA;visual, and operator pending modes, and the&#xA;&lt;code&gt;:imap&lt;/code&gt; command works in insert mode, so you're&#xA;going to need both, but you're also going to need&#xA;to make a few changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, you should always use the non-recursive&#xA;&lt;code&gt;nore&lt;/code&gt; forms of the various map commands unless&#xA;you have a specific reason not to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, note that the map commands work as though&#xA;you are typing out the things you map to. When you&#xA;type a colon in visual mode, the command-line is&#xA;pre-populated with a &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt; range. We don't want&#xA;to pass this range to the &lt;code&gt;:call&lt;/code&gt; command, so we&#xA;need to clear it first with &lt;kbd&gt;Ctrl-U&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C-S&amp;gt; :&amp;lt;C-U&amp;gt;call StripWhitespace()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly, to call a function from an insert mode&#xA;map, you need to include the &lt;kbd&gt;Esc&lt;/kbd&gt; in&#xA;your mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-S&amp;gt; &amp;lt;Esc&amp;gt;:call StripWhitespace()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even better, use &lt;kbd&gt;Ctrl-O&lt;/kbd&gt; to perform a single command and remain in insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-S&amp;gt; &amp;lt;C-O&amp;gt;:call StripWhitespace()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help i_CTRL-O&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-30T07:25:13.140" LastActivityDate="2018-03-30T07:25:13.140" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15733" PostTypeId="1" AcceptedAnswerId="15734" CreationDate="2018-03-29T12:07:10.417" Score="0" ViewCount="538" Body="&lt;p&gt;I would like to have autocompletion active on its own like on &lt;strong&gt;sublime text&lt;/strong&gt; without doing &lt;code&gt;Ctrl+n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to have this without any none native plugins as the already existing autocompletion in vim fits my needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess this can be done through &lt;code&gt;.vimrc&lt;/code&gt; but I have no idea how to do it.&lt;/p&gt;&#xA;" OwnerDisplayName="user16659" LastActivityDate="2018-03-29T13:32:13.447" Title="Auto activate autocompletion" Tags="|vimrc|autocompletion|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15734" PostTypeId="2" ParentId="15733" CreationDate="2018-03-29T13:32:13.447" Score="2" Body="&lt;p&gt;Okay, this is really a hacky approach and I am not sure this is guaranteed to work all the time. However I managed to get something to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyCompletion&#xA;  autocmd!&#xA;  autocmd InsertCharPre * if v:char=~'[a-zA-Z_0-9]' | call feedkeys(&quot;\&amp;lt;c-n&amp;gt;&quot;, 'it')|endif&#xA;augroup end&#xA;&#xA;set completeopt+=noinsert,noselect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason I call it hacky and experimental is, that we are using &lt;code&gt;feedkeys()&lt;/code&gt; to inject a &lt;code&gt;Control-N&lt;/code&gt; character into the input queue whenever a character is entered that matches &lt;code&gt;[a-zA-Z0-9_]&lt;/code&gt; (adjust to taste).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However this might be unexpected for Vim and might cause all kind of problems later since the input queue buffer has been tempered with by us and that might be unexpected by Vim, so use with care!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And to make sure, the autocompletion won't overwrite what we have currently written, we need to set &lt;code&gt;:set completeopt+=noinsert,noselect&lt;/code&gt; (which basically means open the popup menu, but do not select anything yet and do not insert anything yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also please note, this uses a stupid &lt;code&gt;&amp;lt;Ctrl-N&amp;gt;&lt;/code&gt; key, which means that the more clever completions (like e.g. path, omni- or user-defined completions) that are available (see &lt;code&gt;:h ins-completion&lt;/code&gt;) won't be used. &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-03-29T13:32:13.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15736" PostTypeId="2" ParentId="6903" CreationDate="2018-03-29T15:29:06.893" Score="1" Body="&lt;p&gt;in your example, if you want vim treat &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; as words, you can use&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&#xA;set iskeywords+={&#xA;set iskeywords+=}&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then you press &lt;code&gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; the whold &lt;code&gt;WORDS&lt;/code&gt; will be completed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;see my pic&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PB2c6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PB2c6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2018-03-29T15:29:06.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15737" PostTypeId="2" ParentId="15729" CreationDate="2018-03-29T15:40:45.003" Score="2" Body="&lt;p&gt;You can not remove the statusline, if you have more than two horizontal splits, But you can change the highlight of statusline, just make it same as your normal content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&#xA;let &amp;amp;statusline='%#Normal# '&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is my vim screenshort, and it have two splits, vim file on the top, and markdown is below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JbYEK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JbYEK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2018-03-29T15:40:45.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15738" PostTypeId="2" ParentId="15724" CreationDate="2018-03-29T16:44:24.743" Score="5" Body="&lt;p&gt;As Naumann pointed out, &lt;code&gt;modeline&lt;/code&gt; has to be set on.  This is the default if you're not root.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your modeline also has to be within &lt;code&gt;modelines&lt;/code&gt; (default 5) lines from the top or bottom of the file in order to be detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also test that the settings work when you set them manually.  You might be missing a dependent setting like &lt;code&gt;filetype on&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="780" LastActivityDate="2018-03-29T16:44:24.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15739" PostTypeId="1" AcceptedAnswerId="16247" CreationDate="2018-03-29T18:03:05.410" Score="7" ViewCount="966" Body="&lt;p&gt;When I'm using &lt;code&gt;vim&lt;/code&gt; in a terminal, it uses the &lt;code&gt;PATH&lt;/code&gt; I have set, and I can run programs and scripts located in my &lt;code&gt;~/bin&lt;/code&gt; folder using &lt;code&gt;!&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! some_bash_script.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try this in MacVim, it doesnt find my personal shell scripts. How can I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've set my shell in my &lt;code&gt;~/.vimrc&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shell=/bin/zsh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that doesn't seem to help. I did notice that if I launch MacVim from the command line, it works as expected, i assume because the shell's environment is the environment in which MacVim ends up running in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ open -a MacVim.app&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to do this? I like launching MacVim using Spotlight, but it doesnt work if I do it that way, only via Terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: This is &lt;a href=&quot;https://vi.stackexchange.com/q/13130/9850&quot;&gt;similar to this question&lt;/a&gt;, but that was for &lt;code&gt;vim&lt;/code&gt;, not &lt;code&gt;gvim&lt;/code&gt; or &lt;code&gt;MacVim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9850" LastEditorUserId="9850" LastEditDate="2018-03-29T18:10:19.753" LastActivityDate="2018-05-16T23:41:10.630" Title="MacVim - doesnt find programs in PATH when running commands using &quot;!&quot;" Tags="|gvim|macvim|bash|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15740" PostTypeId="2" ParentId="15739" CreationDate="2018-03-29T19:18:32.907" Score="2" Body="&lt;p&gt;So far, my best solution is to launch MacVim using an alternate application launcher, which you can create using AppleScript like so:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Create an apple script like by Running &quot;Script Editor&quot;, clicking &quot;New Document&quot;, and supplying the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tell application &quot;Terminal&quot;&#xA;     do script &quot;open -a MacVim.app; exit&quot;&#xA;     delay 5&#xA;    quit&#xA;end tell&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Export that as an application, by&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;choosing &quot;File | Export&quot;&lt;/li&gt;&#xA;&lt;li&gt;choose &quot;File Format&quot; as &quot;Application&quot;&lt;/li&gt;&#xA;&lt;li&gt;Click &quot;Save&quot;, and call it whatever you like. I called mine &lt;code&gt;MacVimLauncher.app&lt;/code&gt;, and I saved it under &lt;code&gt;Applications&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run that instead of &lt;code&gt;MacVim.app&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note: If you have MacVim running, you have to shut it down before trying this out. I've had &lt;a href=&quot;https://stackoverflow.com/a/38592434/26510&quot;&gt;a similar problem with Eclipse in the past&lt;/a&gt;, and this should solve that issue as well!&lt;/p&gt;&#xA;" OwnerUserId="9850" LastEditorUserId="9850" LastEditDate="2018-03-30T11:27:31.123" LastActivityDate="2018-03-30T11:27:31.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15741" PostTypeId="2" ParentId="15379" CreationDate="2018-03-29T20:26:00.797" Score="2" Body="&lt;p&gt;The biggest problem with your example is &lt;code&gt;[noeol]&lt;/code&gt;. Note that the bytes &lt;code&gt;00 DF&lt;/code&gt; do not really make a file that a text editor expects; if you add a newline to the end (&lt;code&gt;00 DF 0A&lt;/code&gt;), you &lt;em&gt;definitely&lt;/em&gt; won't get the &lt;code&gt;[noeol]&lt;/code&gt; error, and I suspect that the file will now correctly open as latin1 (it does in my tests), and you'll see something like &lt;code&gt;&amp;lt;00&amp;gt;ý&lt;/code&gt; or &lt;code&gt;^@ý&lt;/code&gt;. I'm not sure if this is what you expect or not - but latin1 is an 8-bit encoding, so your file consists of a literal NULL (which vim doesn't have a good way to print, so it prints as &lt;code&gt;&amp;lt;00&amp;gt;&lt;/code&gt; if you have &lt;code&gt;display=uhex&lt;/code&gt; set, or &lt;code&gt;^@&lt;/code&gt; if not) followed by the character at &lt;code&gt;DF&lt;/code&gt;, &lt;code&gt;ý&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;00&lt;/code&gt; is NULL in ASCII, I'm not even sure if it's valid in latin1, but (for me at least), vim doesn't choke on it. &lt;/p&gt;&#xA;" OwnerUserId="14684" LastActivityDate="2018-03-29T20:26:00.797" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15742" PostTypeId="2" ParentId="15721" CreationDate="2018-03-29T20:53:49.610" Score="2" Body="&lt;h2&gt;&lt;a href=&quot;https://ctan.org/pkg/latexindent&quot; rel=&quot;nofollow noreferrer&quot;&gt;latexindent.pl&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I cannot answer your question regarding setting &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27formatoptions%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;formatoptions&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27textwidth%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;textwidth&lt;/code&gt;&lt;/a&gt; differently for different parts of the same file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would recommend to use a dedicated tool to format LaTeX code such as  &lt;code&gt;latexindent.pl&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This tool has to be configured via a &lt;code&gt;config.yaml&lt;/code&gt; file, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;modifyLineBreaks:&#xA;    textWrapOptions:&#xA;       columns: 110&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Invocation on commandline would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ latexindent.pl -m input.tex -o output.tex -l config.yaml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also call this on the current file within vim with &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:!latexindent.pl -w -m % -l config.yaml&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;latexindent.pl&lt;/code&gt; can also read from STDIN and output to STDOUT and therefore can be used as a &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#filter&quot; rel=&quot;nofollow noreferrer&quot;&gt;filter&lt;/a&gt; in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also assign this command to &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27formatprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;formatprg&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the vim plugin &lt;a href=&quot;https://github.com/sbdchd/neoformat&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/sbdchd/neoformat&lt;/a&gt; for a setup of latexindent.pl.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;An alternative to &lt;code&gt;latexindent.pl&lt;/code&gt; is the vim plugin &lt;code&gt;vimtex&lt;/code&gt; which offers format capabilities by a custom &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27formatexpr%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;formatexpr&lt;/code&gt;&lt;/a&gt;.&#xA;This is not enabled by default:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*g:vimtex_format_enabled*&#xA;  If enabled, |vimtex| uses a custom |formatexpr| that should handle inline&#xA;  comments. That is, if it is enabled, comments at end of lines will not be&#xA;  joined with the |gq| command.&#xA;&#xA;  Default value: 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need to customize how your code is formatted, &lt;code&gt;latexindent.pl&lt;/code&gt; offers more possibilities.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-03-31T06:15:19.590" LastActivityDate="2018-03-31T06:15:19.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15743" PostTypeId="1" AcceptedAnswerId="15749" CreationDate="2018-03-29T23:10:22.290" Score="5" ViewCount="3824" Body="&lt;p&gt;If i press a bunch of key sequences like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/term&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and there are five matches on the screen currently, i will have to press &lt;code&gt;n&lt;/code&gt; five times to see the next search result that is not on the screen. Is there a single key (or two) that I can press to emulate pressing &lt;code&gt;n&lt;/code&gt; five times in the situation?&lt;/p&gt;&#xA;" OwnerUserId="11136" LastEditorUserId="11136" LastEditDate="2018-03-31T01:01:10.460" LastActivityDate="2018-04-01T00:59:10.627" Title="Is there a key to go to the next search result that is not on the screen currently?" Tags="|search|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15744" PostTypeId="2" ParentId="15743" CreationDate="2018-03-29T23:32:08.793" Score="0" Body="&lt;p&gt;n/N support counts, You can use 5n. I recommend to read &lt;code&gt;:h n&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2018-03-29T23:32:08.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15745" PostTypeId="2" ParentId="15724" CreationDate="2018-03-29T23:53:48.070" Score="2" Body="&lt;p&gt;First, you need make sure your &lt;code&gt;modeline&lt;/code&gt; is on. Check it via &lt;code&gt;set modeline?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, update the last line to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim:set  ft=vim:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to add an &lt;code&gt;:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, new &lt;code&gt;modeline&lt;/code&gt; will not be executed until some &lt;code&gt;autocmd&lt;/code&gt; is called, for example.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;open a new empty file&lt;/li&gt;&#xA;&lt;li&gt;add &lt;code&gt;&quot; vim:set  ft=vim:&lt;/code&gt; to then end&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then, you will see the file type will not have changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, if you use &lt;code&gt;:w&lt;/code&gt; or &lt;code&gt;:e&lt;/code&gt;, the filetype will change.&lt;/p&gt;&#xA;" OwnerUserId="7942" LastEditorUserId="1111" LastEditDate="2018-08-14T17:34:17.590" LastActivityDate="2018-08-14T17:34:17.590" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="15746" PostTypeId="1" AcceptedAnswerId="15747" CreationDate="2018-03-30T01:27:42.730" Score="5" ViewCount="850" Body="&lt;p&gt;I am attempting to delete from start of line until string &lt;code&gt;foo&lt;/code&gt;.  In normal mode, &lt;code&gt;0d/foo&lt;/code&gt; accomplishes this. Now, I would like to do this for every line in my buffer. Reading documentation and SO it seems that &lt;code&gt;%normal&lt;/code&gt; command is a good match for this; indeed:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%norm! 0dfo&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;deletes from the start of line to the first inclusive occurrence of char &#xA; &lt;code&gt;o&lt;/code&gt;, as expected. However:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%norm! 0d/foo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;has no effect in Vim 8.0.  Oddly enough, it works as I expected in Emacs EVIL mode. Am I misunderstanding the expected behavior?&lt;/p&gt;&#xA;" OwnerUserId="16953" LastActivityDate="2019-01-26T15:38:46.610" Title="Delete with search motion in normal command" Tags="|cursor-motions|normal-mode|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15747" PostTypeId="2" ParentId="15746" CreationDate="2018-03-30T01:44:26.857" Score="6" Body="&lt;p&gt;It is expected.  &lt;code&gt;:norm! sequence&lt;/code&gt; is roughly equivalent to pressing the sequence followed by escape.  Try typing &lt;code&gt;0d/foo&amp;lt;esc&amp;gt;&lt;/code&gt;, you'll see it doesn't work because escape terminates the motion and operator (by default with &lt;code&gt;nocompatible&lt;/code&gt;).  Instead you should use &lt;code&gt;:%norm! 0d/foo^M&lt;/code&gt;, where &lt;code&gt;^M&lt;/code&gt; is a literal carriage return character (type CTRL-V CTRL-M or CTRL-M enter).&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-03-30T01:44:26.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15748" PostTypeId="2" ParentId="15746" CreationDate="2018-03-30T09:15:26.797" Score="3" Body="&lt;p&gt;There is a problem with your search motion approach. If &quot;foo&quot; doesn't appear on a line or multiple consecutive lines, &lt;strong&gt;you will end up deleting entire lines up until the next instance of &quot;foo&quot;&lt;/strong&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using a search motion, you could simply use a global &lt;code&gt;:substitute&lt;/code&gt; and leverage the zero-width atom &lt;code&gt;\ze&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^.\{-}\zefoo//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will delete any and all text from the beginning of a line up to, but not including &quot;foo&quot;, for every line in the buffer. The &lt;code&gt;\{-}&lt;/code&gt; atom is a non-greedy version of &lt;code&gt;*&lt;/code&gt;, meaning it will match as few times as possible, deleting only up to the first &quot;foo&quot; on the line (Thanks for catching this, wmmso).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you didn't specify in your question, if you want to match only on the whole word &quot;foo&quot; and not substrings, then you must wrap &quot;foo&quot; in &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^.\{-}\ze\&amp;lt;foo\&amp;gt;//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;How it works&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\ze&lt;/code&gt; is a zero-width atom that explicitly marks the end of the match. In other words, it overrides where the actual end of a match is, even if there is more matching text after the &lt;code&gt;\ze&lt;/code&gt;, like in the command above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how the help page describes it, from &lt;code&gt;:h \ze&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Matches at any position, and sets the end of the match there: The previous char is the last char of the whole match. Can be used multiple times, the last one encountered in a matching branch is used.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Example: &quot;end\ze(if\|for)&quot; matches the &quot;end&quot; in &quot;endif&quot; and &quot;endfor&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is a pretty good explanation, but I think an interactive, visual example speaks for itself. Let's look at this example buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cats dogs birds foo fish&#xA;cats foo dogs birds fish&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't have it enabled already, &lt;code&gt;:set hlsearch incsearch&lt;/code&gt;. Now, begin a search like so: &lt;code&gt;/^.\{-}foo&lt;/code&gt;. Hitting &lt;kbd&gt;Enter&lt;/kbd&gt; is unnecessary. The buffer should visually highlight the exact matched portion like so (assume the brackets denote what is highlighted):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[cats dogs birds foo] fish&#xA;cats foo dogs birds fish&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As expected, this matches everything from the beginning of the line, stopping with &quot;foo&quot;. But we don't want to include &quot;foo&quot; when we delete, so how do we keep &quot;foo&quot; out of the match, while still requiring its presence? &lt;code&gt;\ze&lt;/code&gt; to the rescue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you still have the search open, modify it by inserting a &lt;code&gt;\ze&lt;/code&gt; between the &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;foo&lt;/code&gt;, just like in the pattern in the top of this answer: &lt;code&gt;/^.\{-}\zefoo&lt;/code&gt;. You should see the highlighted portion shrink back to just before &quot;foo&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[cats dogs birds ]foo fish&#xA;cats foo dogs birds fish&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is important to remember that &quot;foo&quot; is still an important part of this match in that it must be there for anything to match at all. If we replace &quot;foo&quot; with &quot;bar&quot; in the example buffer, the same pattern would return not return any matches:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cats dogs birds bar fish&#xA;cats bar dogs birds fish&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Bonus Information&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Just as an extra bit of info, &lt;code&gt;\zs&lt;/code&gt; is the counterpart to &lt;code&gt;\ze&lt;/code&gt;, and sets the &lt;em&gt;start&lt;/em&gt; of the match. This can come in handy, for example, when what you'd like to match is preceded by whitespace that you don't want in the match. &lt;code&gt;/\s*\zsfoo&lt;/code&gt; would match &lt;em&gt;only&lt;/em&gt; &quot;foo&quot;, even if it had an arbitrary amount of whitespace before it.&lt;/p&gt;&#xA;" OwnerUserId="1452" LastEditorUserId="1452" LastEditDate="2018-04-06T10:03:11.017" LastActivityDate="2018-04-06T10:03:11.017" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15749" PostTypeId="2" ParentId="15743" CreationDate="2018-03-30T10:00:48.363" Score="10" Body="&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;F&lt;/kbd&gt; &lt;kbd&gt;n&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Scroll one page forward (downward) in the buffer, then find next match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not the most elegant solution, but it &lt;em&gt;is&lt;/em&gt; simple, and it doesn't require you to think of the appropriate count for your &lt;kbd&gt;n&lt;/kbd&gt; motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also go the other way with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;B&lt;/kbd&gt; &lt;kbd&gt;N&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you asked for a single key, you can just make this into a mapping; whatever is most comfortable for you. Maybe something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C-n&amp;gt; &amp;lt;C-f&amp;gt;n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By default, &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;n&lt;/kbd&gt; is just an alias for &lt;kbd&gt;j&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1452" LastEditorUserId="1452" LastEditDate="2018-03-30T23:10:20.250" LastActivityDate="2018-03-30T23:10:20.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15750" PostTypeId="1" AcceptedAnswerId="15751" CreationDate="2018-03-30T13:10:07.740" Score="0" ViewCount="119" Body="&lt;p&gt;I have following line in my vimrc-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead,BufNewFile *.COB,*.PCO set filetype=cobol &quot;force filetype as cobol for .COB and .PCO files&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I have put below lines in my custom plugin at the beginning  (~/.vim/plugin/cobmods.vim)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;ft != &quot;cobol&quot;&#xA;   finish&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't want the plugin to load for other filetypes but this code doesn't work. &#xA;I have tried putting the plugin inside ~/.vim/after/plugin so that it loads last but still it doesn't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any different event that I am supposed to use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I have used below code inside the plugin and it works fine&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if expand('%:e') != 'COB' &amp;amp;&amp;amp; expand('%:e') != 'PCO'&#xA;   finish&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this doesn't look like the right way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note: I can't change filetype.vim to include *.COB &amp;amp; *.PCO as I don't have the adequate rights as this resides in the installation location and not my home directory. &lt;/p&gt;&#xA;" OwnerUserId="16636" LastEditorUserId="16636" LastEditDate="2018-03-30T14:34:35.157" LastActivityDate="2019-01-26T15:38:26.293" Title="Unable to detect filetype which is set forcefully inside a custom plugin" Tags="|autocmd|plugin-system|filetype|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15751" PostTypeId="2" ParentId="15750" CreationDate="2018-03-30T13:15:11.013" Score="3" Body="&lt;p&gt;Files in &lt;code&gt;plugin&lt;/code&gt; run during Vim startup (regardless of the file you're opening), before setting the file type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remove your check of the filetype option and move the file to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/ftplugin/cobol.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd also recommend reading the contents of &lt;code&gt;:help ftplugin&lt;/code&gt;, (in particular the part about setting &lt;code&gt;b:did_ftplugin&lt;/code&gt;) and &lt;code&gt;:help new-filetype&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-03-30T13:22:10.147" LastActivityDate="2018-03-30T13:22:10.147" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15752" PostTypeId="1" AcceptedAnswerId="15756" CreationDate="2018-03-30T13:54:31.973" Score="0" ViewCount="111" Body="&lt;p&gt;VIM's Wikia documentation states that you can disable indentation for certain filestypes by inserting the line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:did_indent = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the file &lt;code&gt;~/.vim/indent/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; where &lt;code&gt;&amp;lt;filetype&amp;gt;&lt;/code&gt; is substituted by the filetype used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if I want this applied specifically to files without a suffix? What filetype does that constitute? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already tried using &lt;code&gt;autocmd FileType  let b:did_indent = 1&lt;/code&gt; in my vimrc file, which doesn't work, as expected, since the blank space doesn't constitute &lt;em&gt;no suffix files&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By indentation, I mean the behaviour that you get by having &lt;code&gt;set autoindent&lt;/code&gt; inside your vimrc. I want this disabled for text-editing; in my case, files without a suffix.&lt;/p&gt;&#xA;" OwnerUserId="11449" LastEditorUserId="11449" LastEditDate="2018-03-30T14:47:34.580" LastActivityDate="2018-03-30T15:20:44.193" Title="Disabling indentation for filenames without suffix" Tags="|indentation|filetype|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15753" PostTypeId="1" AcceptedAnswerId="15754" CreationDate="2018-03-30T14:44:21.687" Score="1" ViewCount="311" Body="&lt;p&gt;I like to use external configuration for most of my dot files in my home directory. Simple example, here is my .bash_aliases file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;. /path/to/external/alias-config.conf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the external file contains my aliases. Same idea with my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;. /path/to/external/vim-config.conf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I open vim I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/demo/.vimrc:&#xA;line    1:&#xA;E492: Not an editor command: . '/path/to/external/vim-config.conf'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I change my .vimrc to be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source /path/to/external/vim-config.conf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it is able to successfully source my external configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It was my understanding that 'source' is an alias of '.', so what is going on here? I try to write the dot files in my home directory to be POSIX compliant, so this sort of thing undermines my intention.  Any insight into this peculiarity would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My default shell is Bash and my OS is Ubuntu Server 16.04, if that makes any difference.&lt;/p&gt;&#xA;" OwnerUserId="16978" OwnerDisplayName="Harold Fischer" LastActivityDate="2018-03-30T15:02:19.750" Title="Why can't vim interpret '.' as 'source' in my .vimrc file?" Tags="|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15754" PostTypeId="2" ParentId="15753" CreationDate="2018-03-30T14:49:15.697" Score="7" Body="&lt;p&gt;It's quite simple: &lt;code&gt;bash&lt;/code&gt; has a different configuration file syntax than &lt;code&gt;vim&lt;/code&gt; and what works for one program doesn't necessarily work for another. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;bash&lt;/code&gt; can use &lt;code&gt;. file&lt;/code&gt; and &lt;code&gt;source file&lt;/code&gt; but &lt;code&gt;vim&lt;/code&gt; doesn't understand the &lt;code&gt;. file&lt;/code&gt; syntax. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, being Posix compliant matters for the shell, not for the config file of an application (like &lt;code&gt;vim&lt;/code&gt;). &lt;/p&gt;&#xA;" OwnerUserId="16968" OwnerDisplayName="Sven" LastActivityDate="2018-03-30T14:49:15.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15755" PostTypeId="2" ParentId="15753" CreationDate="2018-03-30T15:02:19.750" Score="2" Body="&lt;p&gt;Sven said it all, except most commands can be shortened; in this case you could write &lt;code&gt;so&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                    *:so* *:source* *load-vim-script*&#xA;:so[urce] {file}    Read Ex commands from {file}.  These are commands that&#xA;                    start with a &quot;:&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a side-note, it's often a good practice to use the long version in scripts for clarity. Vim also handles partial commands, e.g. &lt;code&gt;:sourc&lt;/code&gt;, &lt;code&gt;:sour&lt;/code&gt; or &lt;code&gt;:sou&lt;/code&gt; have the same effect.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2018-03-30T15:02:19.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15756" PostTypeId="2" ParentId="15752" CreationDate="2018-03-30T15:08:04.237" Score="1" Body="&lt;p&gt;Files without a recognized filetype do not trigger the &lt;code&gt;FileType&lt;/code&gt; autocmd at all.  Sometimes, but not always, this means files without an extension in their name.  Filetypes and suffixes are different things.  To be sure, you can do &lt;code&gt;:set filetype?&lt;/code&gt; to see what the filetype is set to.  If this is an empty string, then no &lt;code&gt;FileType&lt;/code&gt; autocmd can be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems to me what you want is the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Files with a &lt;code&gt;filetype&lt;/code&gt; get &lt;code&gt;set autoindent&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Files without a &lt;code&gt;filetype&lt;/code&gt; (i.e., plain text) get &lt;code&gt;set noautoindent&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thus in your vimrc, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noautoindent&#xA;augroup vimrc_indent&#xA;    au!&#xA;    autocmd FileType * set autoindent&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first &lt;code&gt;set&lt;/code&gt; sets the global option value, which applies to all buffers unless otherwise stated.  The second &lt;code&gt;set&lt;/code&gt; sets the option for files with filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help autocmd&lt;/code&gt; and &lt;code&gt;:help augroup&lt;/code&gt; for the meaning of &lt;code&gt;augroup&lt;/code&gt; and &lt;code&gt;au!&lt;/code&gt;.  Briefly, this pattern of wrapping an &lt;code&gt;autocmd&lt;/code&gt; with &lt;code&gt;augroup&lt;/code&gt; (&lt;code&gt;vimrc_indent&lt;/code&gt; is a completely arbitrary string) prevents multiple instances of the same &lt;code&gt;autocmd&lt;/code&gt; from being installed when your vimrc is reloaded.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-03-30T15:20:44.193" LastActivityDate="2018-03-30T15:20:44.193" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15757" PostTypeId="1" AcceptedAnswerId="15758" CreationDate="2018-03-30T15:45:16.887" Score="6" ViewCount="717" Body="&lt;p&gt;Like doing &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; &#xA;but 5 times &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not trying to indent multiple lines.&lt;/p&gt;&#xA;" OwnerUserId="13695" LastActivityDate="2023-02-02T14:58:46.153" Title="How to indent one line multiple times?" Tags="|key-bindings|cursor-motions|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15758" PostTypeId="2" ParentId="15757" CreationDate="2018-03-30T16:25:19.123" Score="7" Body="&lt;p&gt;You can use &lt;code&gt;:&amp;gt;&lt;/code&gt;. Repeat &lt;code&gt;&amp;gt;&lt;/code&gt; as many times as you want to shift. For example, if you want to shift 5 times use &lt;code&gt;:&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Personally, I would just use &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; and then repeat the command with the &lt;code&gt;.&lt;/code&gt; (repeat) command.&lt;/p&gt;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:h :&amp;gt;&#xA;:h &amp;gt;&amp;gt;&#xA;:h .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="2045" LastEditDate="2023-02-01T16:25:22.693" LastActivityDate="2023-02-01T16:25:22.693" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="15759" PostTypeId="1" CreationDate="2018-03-30T17:14:20.197" Score="1" ViewCount="49" Body="&lt;p&gt;In vim8, you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:. term&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to send the current line to execute in your terminal's shell (e.g., bash). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how, in normal and ex mode, do you execute a single line that contains line continuations -- ie backslash characters (&lt;code&gt;\&lt;/code&gt;) like the following?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;curl 'http://localhost:8983/solr/films/select?q=*:*&amp;amp;rows=0'\&#xA;'&amp;amp;facet=true'\&#xA;'&amp;amp;facet.range=initial_release_date'\&#xA;'&amp;amp;facet.range.start=NOW-20YEAR'\&#xA;'&amp;amp;facet.range.end=NOW'\&#xA;'&amp;amp;facet.range.gap=%2B1YEAR'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following works but seems clumsy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\\\n// | . term&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15006" LastEditorUserId="15006" LastEditDate="2018-03-30T17:24:23.543" LastActivityDate="2018-03-30T17:24:23.543" Title="How to execute (using bash) a buffer with line continuations (\)?" Tags="|terminal|terminal-buffer|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15760" PostTypeId="1" CreationDate="2018-03-30T17:19:49.827" Score="3" ViewCount="2154" Body="&lt;p&gt;I am trying to get the mouse selected text in a register in normal mode. If the selection is a substring, only the selection should be copied, not the complete word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently the script has:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;normal! &quot;zyiw&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would use the script on remote servers without X too. vim is compiled without clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="16969" LastEditorUserId="16969" LastEditDate="2018-03-30T17:49:05.083" LastActivityDate="2019-01-26T15:37:52.267" Title="vimscript: how to get selected text in a register in normal mode?" Tags="|normal-mode|" AnswerCount="2" CommentCount="7" ClosedDate="2018-04-07T16:48:48.630" ContentLicense="CC BY-SA 3.0" />
  <row Id="15761" PostTypeId="2" ParentId="15760" CreationDate="2018-03-30T19:40:22.287" Score="1" Body="&lt;p&gt;Selection of text via the mouse (in a plain vanilla vim, no vimrc, no plugins, etc) places the selection in the &quot;* register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A subsequent assignment,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @f = @*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will place the text into the f register. A mapping such as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map ^va :let @f = @*^v^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will copy the &quot;* register to the *f register using ^a (control-a). additional configuration will permit using &amp;lt;C-a&gt; and &amp;lt;CR&gt; in place of ^va and ^vM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps the simplest way, however, is to select the text with the mouse or one of the &quot;V&quot; commands (V, v, CTL-v) and then enter in normal mode&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;gy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will &quot;yank&quot; the current selection into the &quot;Y register.&lt;/p&gt;&#xA;" OwnerUserId="16478" LastEditorDisplayName="user5791" LastEditDate="2019-01-26T15:37:52.267" LastActivityDate="2019-01-26T15:37:52.267" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="15763" PostTypeId="2" ParentId="15760" CreationDate="2018-03-30T23:18:03.620" Score="0" Body="&lt;p&gt;Here's what I did finally:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vim I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;C-a&amp;gt; :normal! gv&quot;zy&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in the script I added:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:if @z == &quot;&quot;                                                                                                                            &#xA;    normal! &quot;zyiw                                                                                                                       &#xA;:endif&#xA;...&#xA;// do something&#xA;...&#xA;:let @z = &quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In general, a visual selection followed by 1. Esc and 2. ^a will be highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is no visual selection, the word under cursor will be highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The complete script is &lt;a href=&quot;https://gist.github.com/jarun/0d89dc61598118926ed82947e88610b3&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16969" LastActivityDate="2018-03-30T23:18:03.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15764" PostTypeId="1" CreationDate="2018-03-31T00:25:59.350" Score="2" ViewCount="300" Body="&lt;p&gt;For example, suppose I have this line of JavaScript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;console.log(&#xA;   &quot;This is a really long line that I want to format, and it is inside of a quote&quot;&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to select the quote line in VISUAL-LINE mode, the pres &lt;code&gt;gq&lt;/code&gt; to format it, but it doesn't work. The result is something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;console.log(&#xA;  &quot;This is a really long line that I want to&#xA;  format, and it is inside of a quote&quot;&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I was hoping that it would be something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;console.log(&#xA;  &quot;This is a really long line that I want to &quot;+&#xA;  &quot;format, and it is inside of a quote&quot;&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so that the result is still a proper string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do this with Vim?&lt;/p&gt;&#xA;" OwnerUserId="5626" LastActivityDate="2020-03-30T08:10:25.560" Title="How to format quotes, so that Vim breaks long lines into multiple quotes on multiple lines?" Tags="|vimrc|neovim|formatting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15765" PostTypeId="2" ParentId="15757" CreationDate="2018-03-31T03:18:28.483" Score="6" Body="&lt;p&gt;As an addition to Peter Rincker's answer, you can also enter visual-line mode (&lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;) and use &lt;kbd&gt;&gt;&lt;/kbd&gt; with a count. Unlike in normal mode, the count is used to specify how many &lt;code&gt;shiftwidth&lt;/code&gt;s to indent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you prefer the comfort of giving a hard count, this is the only option that I'm aware of outside of a plugin or custom function.&lt;/p&gt;&#xA;" OwnerUserId="1452" LastActivityDate="2018-03-31T03:18:28.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15766" PostTypeId="2" ParentId="15743" CreationDate="2018-03-31T04:19:39.170" Score="3" Body="&lt;p&gt;You could use Ln to search next instance on the next page and HN to search previous instance on previous page. &#xA;L - Jump to bottom of the screen&#xA;H - Jump to the top of the screen&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can map these to any shortcut you want. &lt;/p&gt;&#xA;" OwnerUserId="16636" LastActivityDate="2018-03-31T04:19:39.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15769" PostTypeId="1" AcceptedAnswerId="15772" CreationDate="2018-03-31T15:03:29.770" Score="1" ViewCount="574" Body="&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;autocmd FileType python set omnifunc=pythoncomplete#Complete &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found that pythoncomplete can't complete python's build-in functions.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim  test.py&#xA;import os&#xA;os. #Now the complete menu pop up.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/N2YU3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/N2YU3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When i want to auto complete python's build-in function such as &lt;code&gt;frozenset&lt;/code&gt;,&#xA;input &lt;code&gt;frozen&lt;/code&gt; and input &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; ,an error occurs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/swcP4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/swcP4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="5181" LastActivityDate="2018-03-31T15:44:31.530" Title="pythoncomplete can't complete python's build-in functions?" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15771" PostTypeId="2" ParentId="15743" CreationDate="2018-03-31T15:36:30.070" Score="0" Body="&lt;p&gt;Heres the out put from &lt;code&gt;:h n&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n                       Repeat the latest &quot;/&quot; or &quot;?&quot; [count] times.&#xA;                         If the cursor doesn't move the search is repeated with&#xA;                         count + 1.&#xA;                         last-pattern {Vi: no count}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can just use &lt;code&gt;5n&lt;/code&gt; to go forward or &lt;code&gt;5N&lt;/code&gt; to go backwards&lt;/p&gt;&#xA;" OwnerUserId="13848" LastEditorUserId="13848" LastEditDate="2018-04-01T00:59:10.627" LastActivityDate="2018-04-01T00:59:10.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15772" PostTypeId="2" ParentId="15769" CreationDate="2018-03-31T15:44:31.530" Score="1" Body="&lt;p&gt;If you are referring to the following plugin:&#xA;&lt;a href=&quot;https://github.com/mjbrownie/pythoncomplete.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/mjbrownie/pythoncomplete.vim&lt;/a&gt; or&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1542&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.vim.org/scripts/script.php?script_id=1542&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you will notice that they haven't been updated since 2014 or 2009 respectively.&#xA;Obviously vim has come a long way, and if these plugins are not updated and&#xA;depending on which version of vim you are using, these will have problems.&#xA;Instead of trying to figure out whats going on, and so that you can keep using&#xA;the plugin, I suggest you change your plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The latest autocomplete plugin that is gainin a lot of traction is :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/palantir/python-language-server&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/palantir/python-language-server&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in conjunction with &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/autozimu/LanguageClient-neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/autozimu/LanguageClient-neovim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are vim8 or neovim, these will work much better. The LSP plugin is also&#xA;used in &lt;code&gt;VSCode&lt;/code&gt;, so its used very widely and shouldn't have too many bugs. On the&#xA;other hand &lt;code&gt;pythoncomplete&lt;/code&gt; is not very well used, and is likely to have more&#xA;bugs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are on older versions of vim, you can use&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/davidhalter/jedi-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/davidhalter/jedi-vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which should be compatible with all version of &lt;code&gt;vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-03-31T15:44:31.530" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15773" PostTypeId="2" ParentId="15757" CreationDate="2018-03-31T15:54:42.100" Score="3" Body="&lt;p&gt;Press &lt;code&gt;shift-v&lt;/code&gt; to visually select the line, or block of lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then in normal mode press &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;10&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-03-31T15:54:42.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15774" PostTypeId="2" ParentId="15746" CreationDate="2018-03-31T16:02:06.443" Score="0" Body="&lt;p&gt;I use the global command a lot if I have to repeat a normal mode command over a text file such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%g/foo/norm ^d$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will search for lines which contain the word &lt;code&gt;foo&lt;/code&gt;, on all lines in the current buffer. Then it will go to the first character of the line, and delete everything till the end  of the line&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-03-31T16:02:06.443" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15775" PostTypeId="1" AcceptedAnswerId="15817" CreationDate="2018-03-31T18:00:18.913" Score="2" ViewCount="583" Body="&lt;p&gt;The other day I was using one of my non-interactive scripts to set up my dot files for my home directory, including my .vimrc file. This is what I had the script put into my .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;. /etc/external/config.conf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This was before I knew vim can interpret 'source' but not '.' when sourcing external configuration. I thought my script worked well and then I got this error later when opening up vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;search hit BOTTOM, continuing at TOPError detected while processing &#xA;/home/demo/.vimrc:&#xA;line    1:&#xA;E486: Pattern not found: etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would have been really nice if I could have run some sort of sanity check on my .vimrc &lt;em&gt;in my script&lt;/em&gt; so that I could have found out about my misconfigured settings sooner rather than later. How can I run a sanity check on my .vimrc configuration &lt;em&gt;from the shell programmatically, without user interaction&lt;/em&gt;?&lt;/p&gt;&#xA;" OwnerUserId="16978" LastEditorUserId="16978" LastEditDate="2018-04-04T16:11:28.717" LastActivityDate="2018-04-06T14:30:22.647" Title="How do I perform a sanity check on my .vimrc from the shell programmatically?" Tags="|vimrc|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15776" PostTypeId="2" ParentId="15750" CreationDate="2018-03-31T20:09:39.490" Score="0" Body="&lt;p&gt;In addition to ft-plugin, you might check out &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h after-directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's a big hammer, but it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You shouldn't need to do this, however.  And your test for &lt;code&gt;ft == 'cobol'&lt;/code&gt; shouldn't be needed either, because if you put your ftplugin in ~/.vim/ftplugin/cobol.vim (as recommended above), only files of type 'cobol' will source it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you add the autocmd to set the file type for .cob files, it will be set correctly for files ending in .cob.  But note that, in my plain out-o-the-box vim in current mint (ubuntu derivative) distribution, the cob extension will be detected without it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need &quot;already sourced&quot; code though.  Look at the first few lines of almost any file in $VIMRUNTIME/ftplugin. &lt;/p&gt;&#xA;" OwnerUserId="16478" LastEditorDisplayName="user5791" LastEditDate="2019-01-26T15:38:26.293" LastActivityDate="2019-01-26T15:38:26.293" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="15777" PostTypeId="1" CreationDate="2018-03-31T21:12:28.613" Score="1" ViewCount="74" Body="&lt;p&gt;I am trying to create an Emacs like &lt;code&gt;Ctrl-l&lt;/code&gt; feature, similar to Vim's H, M and L. For those who don't now, these keys jump to top, middle, and bottom of the window. I already have something but I am missing the &quot;if&quot; part.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleHML()&#xA;    let l:winheight = winheight('%')&#xA;    let l:top = 1&#xA;    let l:middle = l:winheight / 2&#xA;    let l:bottom = l:winheight&#xA;    if ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think I have to create another variable to keep the state until the next function call, but I don't know how to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing I ended up thinking, exec a normal command inside the function. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec 'normal! H'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="2920" LastEditDate="2018-04-01T06:10:48.250" LastActivityDate="2018-04-03T20:29:32.130" Title="How can I toggle between three predefined positions?" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15780" PostTypeId="2" ParentId="15746" CreationDate="2018-04-01T01:55:37.550" Score="0" Body="&lt;p&gt;Using this as test text in a plain vanilla vim 7.4 set with &lt;code&gt;'nocompatible'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;first&#xA; food is good.   foo 123 foo 123 foo 123&#xA;qwerty qwer yui&#xA;   foo 123 foo 123 foo 123&#xA;last&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tl;dr&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Record the following into a register using, eg., &lt;code&gt;qa&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\&amp;lt;foo\&amp;gt;^Md0j&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;finish up with &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; (terminate recording)&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Type &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:% :normal @a&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;hit enter, voila done&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The nitty gritty, or, how I got it to work.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;d/foo&lt;/code&gt; at the beginning of a line which has &quot;foo&quot; in it  works great. But using it on a line without &quot;foo&quot; will delete all the lines between here and there.  Using &lt;code&gt;:g&lt;/code&gt; one can get a command to work on each line containing foo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:g/foo/ s/foo/FOO/&lt;/code&gt;, you can get the first foo on each line to turn into FOO.  So, you'd THINK using&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:g/foo/ d/foo&lt;/code&gt; or &lt;code&gt;:g/foo/ d/foo/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;would be the ticket.  Nope. Results in a &quot;trailing characters&quot; error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g/foo/ :normal d2fo&lt;/code&gt; works but if &quot;o&quot; appears twice before &quot;foo&quot;, this won't have the desired effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Searching for &quot;/foo/e&quot; will move the cursor to the end of a search pattern. And moving to a line where &quot;foo&quot; exists and entering &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%normal d/foo/e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will indeed delete to the end of &quot;foo&quot;. So, again, you'd THINK&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%normal d/foo/e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would just work. Nope. Does nothing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:%s/.*foo//&lt;/code&gt; again kills all foos.  Not what the OP asked. and using &lt;code&gt;\ze&lt;/code&gt; gets non-greedy behavior, but it's overridden by earlier matches on the line - see &lt;code&gt;:h non-greedy&lt;/code&gt;.  And, they're right. &lt;code&gt;.*foo&lt;/code&gt; matches before &lt;code&gt;^-to-the-first-foo&lt;/code&gt;, so it wins. Maybe I just don't understand using &lt;code&gt;\ze&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SO...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting cmds in a register and using @-register-name works, so let's try &lt;code&gt;d/foo^M&lt;/code&gt; in a register &lt;code&gt;q&lt;/code&gt; and use &lt;code&gt;:% @q&lt;/code&gt;. Nope. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cutting a long story short - let's record into register &quot;q&quot; what it takes to do this on a single line: put&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\&amp;lt;foo\&amp;gt;^Md0j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into register (eg) &lt;code&gt;q&lt;/code&gt; or use &lt;code&gt;qq&lt;/code&gt; and type it using &lt;code&gt;^V^M&lt;/code&gt; where &lt;code&gt;^M&lt;/code&gt; appears.  Or use &lt;code&gt;qq&lt;/code&gt; to record it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now execute &lt;code&gt;q&lt;/code&gt; on each line using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:% :normal @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;happiness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;dissecting&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\&amp;lt;foo\&amp;gt;^Md0j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the &quot;/foo&quot; finds the next occurrence - the &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; limit the search to just &quot;foo&quot;, not &quot;food&quot;.  &lt;code&gt;^M&lt;/code&gt; should have been entered in record mode as hitting enter. &lt;code&gt;d0&lt;/code&gt; deletes to column 1.  &lt;code&gt;v0x&lt;/code&gt; works too.  &lt;code&gt;j&lt;/code&gt; gets to the beginning of the next line, preventing finding another &quot;foo&quot; on this line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rube Goldberg, where are you...&lt;/p&gt;&#xA;" OwnerUserId="16478" LastEditorDisplayName="user5791" LastEditDate="2019-01-26T15:38:46.610" LastActivityDate="2019-01-26T15:38:46.610" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="15781" PostTypeId="2" ParentId="15713" CreationDate="2018-04-01T02:34:47.203" Score="1" Body="&lt;p&gt;copy the content of the &quot;:&quot; register (what you just did) into another register, eg., register a:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a = @:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can execute it again using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16478" LastActivityDate="2018-04-01T02:34:47.203" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15782" PostTypeId="2" ParentId="15716" CreationDate="2018-04-01T03:21:07.900" Score="0" Body="&lt;p&gt;I think you want&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;: ... endif &amp;lt;cr&amp;gt; :let OLstate = 1 - OLstate &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;: ... endif \| let OLstate = 1 - OLstate &amp;lt;cr&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, &lt;strong&gt;&lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/strong&gt; after the &lt;code&gt;endif&lt;/code&gt;, a &lt;strong&gt;&lt;code&gt;:&lt;/code&gt;&lt;/strong&gt; before &lt;code&gt;let&lt;/code&gt; and &lt;strong&gt;&lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/strong&gt; after the &lt;code&gt;let&lt;/code&gt; statement. There are two commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;vim 7.4&lt;/code&gt;, plain vanilla, no &lt;code&gt;.vimrc&lt;/code&gt;, no plugins.&lt;/p&gt;&#xA;" OwnerUserId="16478" LastEditorUserId="16914" LastEditDate="2018-04-07T16:52:05.357" LastActivityDate="2018-04-07T16:52:05.357" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15783" PostTypeId="2" ParentId="15777" CreationDate="2018-04-01T06:10:03.977" Score="3" Body="&lt;p&gt;This should do what you're looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleHML()&#xA;    if winline() &amp;lt; winheight('%') / 2&#xA;      normal M&#xA;    elseif winline() &amp;lt; winheight('%')&#xA;      normal L&#xA;    else&#xA;      normal H&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I removed the variables, since they aren't really necessary. This will always jump down unless it's already at the bottom, in which case it will jump up. &lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-04-01T06:10:03.977" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15784" PostTypeId="2" ParentId="8158" CreationDate="2018-04-01T17:06:50.810" Score="1" Body="&lt;p&gt;I have installed vim package and got visual mode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;apk add vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16997" LastActivityDate="2018-04-01T17:06:50.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15785" PostTypeId="2" ParentId="15777" CreationDate="2018-04-01T19:13:04.767" Score="0" Body="&lt;p&gt;After some sweat, I figured out one solution, not so easy as I thought. We have to discover if the file is larger or not than &lt;code&gt;winheight('%')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleHML()&#xA;    set scrolloff=0&#xA;    let l:last_win_line = ( line('$') &amp;lt;= winheight('%') ? line('$')  : winheight('%')  )&#xA;    if winline() &amp;lt; l:last_win_line / 2&#xA;      normal M&#xA;    elseif winline() &amp;lt; l:last_win_line&#xA;      normal L&#xA;    else&#xA;      normal H&#xA;    endif&#xA;endfunction&#xA;nnoremap &amp;lt;C-l&amp;gt; :call ToggleHML()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reference: &lt;a href=&quot;http://vim.1045645.n5.nabble.com/Vim-General-f1139531.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.1045645.n5.nabble.com/Vim-General-f1139531.html&lt;/a&gt; &#xA;were I figured ou how to get the last line number &lt;code&gt;line('$')&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2018-04-03T20:29:32.130" LastActivityDate="2018-04-03T20:29:32.130" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15786" PostTypeId="2" ParentId="2950" CreationDate="2018-04-01T21:01:23.387" Score="5" Body="&lt;p&gt;Here's a strategy I use for this that utilizes the &lt;code&gt;BASH_ENV&lt;/code&gt; which you can read about in &lt;code&gt;man bash&lt;/code&gt; (and below). This strategy focuses specifically on what I want made available in vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When  bash  is started non-interactively, to run a shell script, for example,&#xA;it looks for the variable BASH_ENV in the environment, expands its value if it&#xA;appears there, and uses the expanded value as the name of a file to read and&#xA;execute.  Bash behaves as if the following command were executed:&#xA;&#xA;if [ -n &quot;$BASH_ENV&quot; ]; then . &quot;$BASH_ENV&quot;; fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, in your vimrc, you can do something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let $BASH_ENV=&quot;~/.vim/vim_bash&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;vim_bash&lt;/code&gt; you have content like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;shopt -s expand_aliases  &#xA;alias ll='ls -la'&#xA;alias foo='bar'&#xA;alias you='get the idea'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that's really all there is to it. Now in vim you can do &lt;code&gt;!ll&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really did want to use your entire &lt;code&gt;.bashrc&lt;/code&gt; you'd have to make sure you add &lt;code&gt;shopt -s expand_aliases&lt;/code&gt; in it.&lt;/p&gt;&#xA;" OwnerUserId="287" LastEditorUserId="287" LastEditDate="2020-04-22T03:52:57.873" LastActivityDate="2020-04-22T03:52:57.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15787" PostTypeId="2" ParentId="15673" CreationDate="2018-04-01T22:59:08.413" Score="2" Body="&lt;p&gt;Long time ago, many terminals did not have arrow keys, or did not have all four of them.  Software systems that needed navigation normally provided some sort of navigation approach without relying on arrow keys, and vi's hjkl is a canonical example.  (Another classical example is WordStar's ^E-^S-^X-^D.)  As keyboard navigation's utility became increasingly obvious, more and more new terminals began to come with arrow keys, and software systems often mapped these to the old ways of navigation.  However, this provided a portability concern of sorts: if children trained at schools were to come to rely on such a fancy new-fangled feature as arrow keys, the thinking was, they might not be able to be productive on the — once common — keyboards without arrow keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, teachers of courses into basic computing began to cautiously warn students to learn to use the lowest common denominator so as to maximise their employability.  And this practice has long outlived any reasons that it may once have had.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In modern implementations of vi, the main reason to prefer hjkl is that it's slightly faster to use keys already under your hand than moving your hand to wherever your arrow keys are.  The downside of avoiding the context switch of your hand, of course, is that you may need to perform a context switch of vi.  Nowadays, when humans are very rarely treasured by typing speed, whether you do one or the other is pretty much a matter of personal preference, and there's nothing inherently bad about using arrow keys anymore, if there ever was.&lt;/p&gt;&#xA;" OwnerUserId="16999" LastActivityDate="2018-04-01T22:59:08.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15788" PostTypeId="1" AcceptedAnswerId="15794" CreationDate="2018-04-02T00:05:01.680" Score="0" ViewCount="226" Body="&lt;p&gt;Is there anyway that I can see the number of result with &lt;code&gt;:Ag&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(attached) If somewhere I could see the number of return would be awesome. I can't find any reference for it on Internet. Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .vimrc setup: &lt;a href=&quot;https://gist.github.com/houmanka/9790614407bcbed4e12d199b9bef32e8&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gist.github.com/houmanka/9790614407bcbed4e12d199b9bef32e8&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IrUrW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IrUrW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After I do the search, in the quickfix window I type &lt;code&gt;:set errorformat&lt;/code&gt; and I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;errorformat=%*[^&quot;]&quot;%f&quot;%*\D%l: %m,&quot;%f&quot;%*\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each f&#xA;unction it appears in.),%-GIn file included from %f:%l:%c:,%-GIn file included from %f:%l:%c\,,%-GIn file included from %f:%l:%c,%&#xA;-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l)&#xA;:%m,%f:%l:%m,&quot;%f&quot;\, line %l%*\D%c%*[^ ] %m,%D%*\a[%*\d]: Entering directory %*[`']%f',%X%*\a[%*\d]: Leaving directory %*[`']%f',%D&#xA;%*\a: Entering directory %*[`']%f',%X%*\a: Leaving directory %*[`']%f',%DMaking %*\a in %f,%f|%l| %m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15642" LastEditorUserId="15642" LastEditDate="2018-04-03T22:50:10.923" LastActivityDate="2018-04-05T12:59:07.790" Title="How to see the number of search return with Ag?" Tags="|vimrc|search|the-silver-searcher|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15789" PostTypeId="2" ParentId="15710" CreationDate="2018-04-02T00:52:50.270" Score="1" Body="&lt;pre&gt;&lt;code&gt;:1,2 !bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the line in edited file lost after executing bash command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;：1,2 w  !bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the line in edited file remained after executing bash command&lt;/p&gt;&#xA;" OwnerUserId="5181" LastActivityDate="2018-04-02T00:52:50.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15790" PostTypeId="2" ParentId="4091" CreationDate="2018-04-02T03:28:05.693" Score="2" Body="&lt;p&gt;I can't comment because my account is new so sorry about that, but ++++1 for ctrl-space. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was sold by the time I made it halfway through the help. Ctrlspace has a structure like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;workspaces --&amp;gt; contain tabs --&amp;gt; contain buffers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, you can save a workspace for each project that you are working on and then immediately load it whenever you want. This means that any time you close vim you can save all of your buffer and tab splits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also name your tabs. If that isn't enough, you can also very easily change working directories and create bookmarks for directories that you use frequently. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It interfaces nicely with nerdtree if you use that (although honestly you probably won't even feel like you need it after a week with ctrlspace)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;Consider this use case:&lt;/b&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have a project. It involves planting trees. There are fruit trees and money trees. Money trees contain dollars and cents while fruit trees contain apples and oranges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this example apples, oranges, dollars, and cents are all &quot;buffers.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ctrlspace lets you separate apples and oranges into one &quot;tab&quot; which you can label &quot;fruit&quot; -- this label will appear in the tag line at the top of your window. Likewise, dollars and cents go into a &quot;money&quot; tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;trees&quot; workspace saves this entire configuration and lets you access it immediately any time you open vim.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now that I'm aware of it's existence, I really can not imagine doing object oriented development in vim without this plugin. Just in case, here is the link:&#xA;&lt;a href=&quot;https://github.com/szw/vim-ctrlspace&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/szw/vim-ctrlspace&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17001" LastEditorUserId="17001" LastEditDate="2018-04-03T03:31:52.237" LastActivityDate="2018-04-03T03:31:52.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15791" PostTypeId="1" CreationDate="2018-04-02T07:19:55.787" Score="1" ViewCount="1239" Body="&lt;p&gt;At the moment when I run &lt;code&gt;nvim path/to/folder/&lt;/code&gt; it opens up the netrw window for it (more accurately, the &lt;a href=&quot;https://github.com/justinmk/vim-dirvish&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dirvish&lt;/a&gt; window for it), I'd like this to not be the case.&lt;/p&gt;&#xA;&lt;p&gt;Ideal behaviour is that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;when I do &lt;code&gt;nvim path/to/file.js&lt;/code&gt; it opens the file, as normal, and&lt;/li&gt;&#xA;&lt;li&gt;when I do &lt;code&gt;nvim path/to/folder/&lt;/code&gt; it opens the normal empty buffer (the one with the copyright statement and so on) but with the CWD set to &lt;code&gt;path/to/folder/&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This is basically to mimic a bit more the Atom behaviour, where as soon as I open the folder (usually with &lt;code&gt;nvim .&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;I can do fuzzy matching for the files right away, Dirvish has bound &lt;code&gt;Ctrl-p&lt;/code&gt; (my fuzzy match key) to something else so I can't use it in that case.&lt;/p&gt;&#xA;" OwnerUserId="17005" LastEditorUserId="23502" LastEditDate="2022-10-31T10:51:26.103" LastActivityDate="2023-12-25T14:03:35.577" Title="How to make Vim open empty buffer with CWD set when opening a folder?" Tags="|neovim|netrw|startup|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="15792" PostTypeId="1" AcceptedAnswerId="15796" CreationDate="2018-04-02T08:38:26.863" Score="0" ViewCount="98" Body="&lt;p&gt;I can use &lt;code&gt;fd&lt;/code&gt; to jump to the next &lt;code&gt;d&lt;/code&gt; character. How can I jump to the next semicolun? &lt;code&gt;f;&lt;/code&gt; doesn't seem to work. Also, for other special symbols.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="17007" LastActivityDate="2018-04-02T21:00:54.873" Title="Jump to next semicolun" Tags="|cursor-movement|cursor-motions|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15793" PostTypeId="2" ParentId="15670" CreationDate="2018-04-02T11:49:48.877" Score="0" Body="&lt;p&gt;It works as following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;autocmd FileType html setlocal omnifunc=MyHTMLComplete&#xA;function! MyHTMLComplete(findstart, base)&#xA;    autocmd FileType javascript setlocal omnifunc=tern#Complete&#xA;    autocmd FileType php set omnifunc=phpcomplete#CompletePHP&#xA;    if search('&amp;lt;?php', 'bnW') &amp;gt; search('&amp;lt;script&amp;gt;', 'bnW')&#xA;        return phpcomplete#CompletePHP(a:findstart, a:base)&#xA;    else&#xA;        return tern#Complete(a:findstart,a:base)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5181" LastActivityDate="2018-04-02T11:49:48.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15794" PostTypeId="2" ParentId="15788" CreationDate="2018-04-02T12:07:37.470" Score="4" Body="&lt;p&gt;&lt;code&gt;:Ag&lt;/code&gt; inserts its results into a so-called Quickfix window and, as for anything loaded there, an indication of the current result and total results will be displayed on the right side of the status line. See the &lt;code&gt;1/46&lt;/code&gt; in your screen shot? That means you're currently on the first result out of a total of 46.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you've already closed the Quickfix window then just by using the Quickfix navigation commands (&lt;code&gt;:cnext&lt;/code&gt;, &lt;code&gt;:cc&lt;/code&gt;, &lt;code&gt;:cfirst&lt;/code&gt;, etc.) you'll see &quot;&lt;em&gt;[current] of [total]&lt;/em&gt;&quot; prefixed to the (new) current result in the message area (command line). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, though, that all of the navigation commands can move the cursor. If you're still on the current result then &lt;code&gt;:cc&lt;/code&gt; will display the position/total and result text without moving the cursor but if you've previously navigated away you can see the total while ensuring the cursor is not moved by using the nice solution @PeterRincker provides below: &lt;code&gt;:echo len(getqflist())&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Non-Vim Note:&lt;/strong&gt; Your result count will not be accurate because you have all those &lt;code&gt;||&lt;/code&gt; lines in your &lt;code&gt;ag&lt;/code&gt; output. This is caused by the &lt;code&gt;--noheading&lt;/code&gt; flag. There's no reason for that to be there when feeding Quickfix. Remove it and the result count should be correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Epilogue:&lt;/strong&gt; To save someone from reading the wall of comments below let me just sum up what else they cover beyond the previous paragraph: I discovered there is a variable in the &lt;code&gt;ag&lt;/code&gt; plugin, &lt;code&gt;g:ag_prg&lt;/code&gt;, that can be used to specify the exact &lt;code&gt;ag&lt;/code&gt; command used for searches. It so happens that this is where &lt;code&gt;--noheading&lt;/code&gt; originated so OP removed that flag and the problem of extra &lt;code&gt;||&lt;/code&gt; lines went away. &lt;em&gt;And they lived happily ever after.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-04-05T12:59:07.790" LastActivityDate="2018-04-05T12:59:07.790" CommentCount="18" ContentLicense="CC BY-SA 3.0" />
  <row Id="15795" PostTypeId="2" ParentId="15682" CreationDate="2018-04-02T17:33:51.250" Score="1" Body="&lt;p&gt;As an alternative you can use something like &lt;a href=&quot;https://github.com/tomnomnom/gron/&quot; rel=&quot;nofollow noreferrer&quot;&gt;gron&lt;/a&gt; or &lt;a href=&quot;https://github.com/zacharyvoase/jsonpipe&quot; rel=&quot;nofollow noreferrer&quot;&gt;jsonpipe&lt;/a&gt; to create paths next to the content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of what &lt;code&gt;gron&lt;/code&gt; output would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;json[0].commit.author = {};&#xA;json[0].commit.author.date = &quot;2016-07-02T10:51:21Z&quot;;&#xA;json[0].commit.author.email = &quot;mail@tomnomnom.com&quot;;&#xA;json[0].commit.author.name = &quot;Tom Hudson&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can do your searching and editing then undo this via &lt;code&gt;%!gron --ungron&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-04-02T17:33:51.250" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15796" PostTypeId="2" ParentId="15792" CreationDate="2018-04-02T21:00:54.873" Score="2" Body="&lt;p&gt;I had a similar problem a while back. As a temporary solution you can use &lt;code&gt;/;&lt;/code&gt;, and then use n.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will search for &lt;code&gt;;&lt;/code&gt; and jump to that position&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-04-02T21:00:54.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15799" PostTypeId="2" ParentId="2950" CreationDate="2018-04-03T05:29:14.653" Score="2" Body="&lt;p&gt;There's a bunch of different plugins for that. For example, &lt;a href=&quot;https://github.com/christoomey/vim-run-interactive&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-run-interactive&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But today you can also use &lt;code&gt;:help :terminal&lt;/code&gt;. Or use &lt;code&gt;GNU Screen&lt;/code&gt; or &lt;code&gt;tmux&lt;/code&gt;. Or just split windows in your terminal emulator.&lt;/p&gt;&#xA;" OwnerUserId="5232" LastActivityDate="2018-04-03T05:29:14.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15800" PostTypeId="1" AcceptedAnswerId="15801" CreationDate="2018-04-03T08:01:17.753" Score="0" ViewCount="282" Body="&lt;p&gt;I have an &lt;a href=&quot;https://github.com/NixOS/nix/issues/2034&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue&lt;/a&gt; with Vim in NixOS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that Vim sets to  &lt;code&gt;shell&lt;/code&gt; the path to not desired bash (non-interactive bash).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I want to know how Vim finds a shell and sets its path to &lt;code&gt;shell&lt;/code&gt; to fix the issue.&lt;/p&gt;&#xA;" OwnerUserId="17022" LastEditorUserId="17022" LastEditDate="2018-04-03T08:13:35.493" LastActivityDate="2018-04-03T08:38:50.063" Title="How does Vim sets 'shell'?" Tags="|variables|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15801" PostTypeId="2" ParentId="15800" CreationDate="2018-04-03T08:38:50.063" Score="0" Body="&lt;p&gt;Looks like it is set from environment variable $SHELL. .&#xA;For example try run vim like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% env SHELL=/bin/csh vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1782" LastActivityDate="2018-04-03T08:38:50.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15802" PostTypeId="2" ParentId="491" CreationDate="2018-04-03T10:53:15.520" Score="8" Body="&lt;h3&gt;&lt;code&gt;:UseVimball path&lt;/code&gt; instead of &lt;code&gt;:so [name].vba&lt;/code&gt; for vim8-packages/dein/vim-plug/minpac&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you use vim8 pack paths or a plugin manager which supports local plugins (e.g. &lt;a href=&quot;https://github.com/Shougo/dein.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;dein&lt;/a&gt; or &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt;), you might want to install a &lt;a href=&quot;http://vimhelp.appspot.com/pi_vimball.txt.html#vimball&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;vimball&lt;/em&gt;&lt;/a&gt; (&lt;code&gt;.vba[.gz]&lt;/code&gt;) into a specific directory and not merge it with your &lt;code&gt;~/.vim&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example: Installation of &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#VIS&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Vis&lt;/em&gt; (Visual Block Cmds)&lt;/a&gt; by Charles Campbell (DrChip)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;vim8 pack path/minpac&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use the &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#packages&quot; rel=&quot;nofollow noreferrer&quot;&gt;package&lt;/a&gt; feature of vim8 or &lt;a href=&quot;https://github.com/k-takata/minpac&quot; rel=&quot;nofollow noreferrer&quot;&gt;minpac&lt;/a&gt;, &lt;code&gt;~/.vim/pack/manual/start/vis&lt;/code&gt; would be a sensible location. The installation steps would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim http://www.drchip.org/astronaut/vim/vbafiles/vis.vba.gz&#xA;:UseVimball ~/.vim/pack/manual/start/vis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;a href=&quot;https://github.com/Shougo/dein.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;dein&lt;/a&gt; or &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt;, you would install the vimball not in a pack path but one of your choice and would add this plugin with a plugin manager specific line to your &lt;code&gt;$MYVIMRC&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;dein&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim http://www.drchip.org/astronaut/vim/vbafiles/vis.vba.gz&#xA;:UseVimball ~/.vim/dein-manual/vis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dein#add('~/.vim/dein-manual/vis')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;vim-plug&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim http://www.drchip.org/astronaut/vim/vbafiles/vis.vba.gz&#xA;:UseVimball ~/.vim/plugged-manual/vis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug '~/.vim/plugged-manual/vis'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Installing new version of a default plugin&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;However, note that default plugins (e.g. &lt;em&gt;netrw&lt;/em&gt;) are sourced before plugins installed into a vim 8 &lt;code&gt;packpath&lt;/code&gt;. The source order is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;$HOME/.vim/plugin&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$VIM/plugin&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$VIMRUNTIME/plugin&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$HOME/.vim/pack/*/start/*/plugin&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This means installing a newer &lt;em&gt;netrw&lt;/em&gt; version into a &lt;code&gt;packpath&lt;/code&gt; is not as straightforward as one would think. See for details &lt;a href=&quot;https://vi.stackexchange.com/questions/11604/vim-8-packages-how-do-i-overwrite-a-default-package&quot;&gt;Vim 8 packages, how do I overwrite a default package?&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-11-24T08:46:21.220" LastActivityDate="2018-11-24T08:46:21.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="15804" PostTypeId="1" AcceptedAnswerId="15805" CreationDate="2018-04-03T14:59:12.193" Score="0" ViewCount="120" Body="&lt;h1&gt;My problem&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Consider the following line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4cIIm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4cIIm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have just pasted &lt;code&gt;@SrvrlessDaysTLVtlv&lt;/code&gt; before &lt;code&gt;tlv@serverlessdays.io&lt;/code&gt;, and I'd like to delete anything from the small-case &lt;code&gt;t&lt;/code&gt; till EOL.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;What have I tried&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;d$&lt;/code&gt; deletes from the &lt;code&gt;V&lt;/code&gt; till EOL, not from the &lt;code&gt;t&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Read about motions, found nothing about deleting from the &lt;em&gt;next&lt;/em&gt; character&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;My question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What is the right motion (for delete or yank) from the &lt;em&gt;next&lt;/em&gt; cursor, not from the current one?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="13179" LastActivityDate="2018-04-03T15:19:19.060" Title="Delete from the next character till EOL" Tags="|cut-copy-paste|cursor-motions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15805" PostTypeId="2" ParentId="15804" CreationDate="2018-04-03T15:10:46.430" Score="4" Body="&lt;p&gt;I think the easiest and quickest solution is to move the cursor of one character to the right (with &lt;kbd&gt;l&lt;/kbd&gt; or &lt;kbd&gt;right&lt;/kbd&gt; or &lt;kbd&gt;space&lt;/kbd&gt;) and then delete until the end of the line with &lt;kbd&gt;D&lt;/kbd&gt; (or &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt; which is the same thing)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;kbd&gt;l&lt;/kbd&gt;&lt;kbd&gt;D&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You'll end up on the end of the line so moving the cursor is not that bad and you still have only two key to stroke.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-04-03T15:19:19.060" LastActivityDate="2018-04-03T15:19:19.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15806" PostTypeId="1" AcceptedAnswerId="15854" CreationDate="2018-04-03T17:10:04.610" Score="1" ViewCount="454" Body="&lt;p&gt;I can successfully toggle between different conceal levels in Neovim, which is rather handy when working with markdown documents.  Also, when working with with multiple documents in a Neovim session, I save the state of the open documents to a session file so I can pick up where I left off, ie. not having to reopen all the documents I had open in the previous session, however the conceal level isn't preserved when relaunching a Neovim session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure there is a way to preserve the conceal level of a document on a per file / session basis, I just don't know how to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm saving Neovim sessions with the below Vimscript, &lt;strong&gt;sessions.vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; CREDIT: https://stackoverflow.com/a/47656092/708807&#xA;&#xA;function! MakeSession(overwrite)&#xA;  if &amp;amp;filetype ==? 'man'&#xA;    return&#xA;  else&#xA;    let b:sessiondir = $HOME . &quot;/.vim/sessions&quot; . getcwd()&#xA;    if (filewritable(b:sessiondir) != 2)&#xA;      exe 'silent !mkdir -p ' b:sessiondir&#xA;      redraw!&#xA;    endif&#xA;    let b:filename = b:sessiondir . '/session.vim'&#xA;    if a:overwrite == 0 &amp;amp;&amp;amp; !empty(glob(b:filename))&#xA;      return&#xA;    endif&#xA;    exe &quot;mksession! &quot; . b:filename&#xA;  endif&#xA;endfunction&#xA;&#xA;function! LoadSession()&#xA;  if &amp;amp;filetype ==? 'man'&#xA;    return&#xA;  else&#xA;    let b:sessiondir = $HOME . &quot;/.vim/sessions&quot; . getcwd()&#xA;    let b:sessionfile = b:sessiondir . &quot;/session.vim&quot;&#xA;    if (filereadable(b:sessionfile))&#xA;      exe 'source ' b:sessionfile&#xA;    else&#xA;      echo &quot;No session loaded.&quot;&#xA;    endif&#xA;  endif&#xA;endfunction&#xA;&#xA;&quot; Adding automatons for when entering or leaving Vim&#xA;if(argc() == 0)&#xA;  au VimEnter * nested :call LoadSession()&#xA;  au VimLeave * :call MakeSession(1)&#xA;else&#xA;  au VimLeave * :call MakeSession(0)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10550" LastActivityDate="2018-04-08T01:41:13.490" Title="Persistent conceal settings through Vim / Neovim restarts" Tags="|vimscript|neovim|sessions|conceal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15807" PostTypeId="1" CreationDate="2018-04-03T17:51:57.520" Score="1" ViewCount="142" Body="&lt;p&gt;When one of my vim subwindows is opened to a network drive with many zip files, switching to that subwindows causes vim to hang for 10 seconds or so.  The Windows Task Manager shows sustained increased bandwidth usage during that time, so I assume that netrw is reading the list of files within each zip file.  I am in a very controlled computational setting, so upgrading is not easy.  Is there a quick vim source code patch that alleviates this delay?  I am currently on netrw v149, installed as part of Cygwin on Windows 7.&lt;/p&gt;&#xA;" OwnerUserId="7970" LastEditorUserId="7970" LastEditDate="2018-04-04T19:43:29.303" LastActivityDate="2018-04-04T19:43:29.303" Title="netrw freezes if vim subwindow includes &quot;beefy&quot; network drive" Tags="|netrw|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15808" PostTypeId="2" ParentId="15775" CreationDate="2018-04-04T01:27:06.120" Score="3" Body="&lt;pre&gt;&lt;code&gt;vim -q fakefile &amp;gt;/dev/null 2&amp;gt;/tmp/checkforerrors; grep -q -F 'Error detected while processing ' /tmp/checkforerrors &amp;amp;&amp;amp; echo '.vimrc syntax is bad' || echo '.vimrc syntax is good!!'; rm /tmp/checkforerrors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would love to hear from some vi/vim experts about whether this command is safe and effective. Very ugly and hackish, but it seems to work well as a way to run a sanity check on my .vimrc file.&lt;/p&gt;&#xA;" OwnerUserId="16978" LastEditorUserId="16978" LastEditDate="2018-04-06T14:30:22.647" LastActivityDate="2018-04-06T14:30:22.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15809" PostTypeId="1" AcceptedAnswerId="15810" CreationDate="2018-04-04T07:06:12.067" Score="0" ViewCount="883" Body="&lt;p&gt;I want the backspace to behave the same in normal mode as insert mode and it should also enter insert mode.&lt;/p&gt;&#xA;" OwnerDisplayName="user12460" LastEditorUserId="1841" LastEditDate="2018-04-04T08:35:53.600" LastActivityDate="2018-04-04T08:35:53.600" Title="Make backspace delete character and enter insert mode when in normal mode" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15810" PostTypeId="2" ParentId="15809" CreationDate="2018-04-04T07:39:48.813" Score="1" Body="&lt;p&gt;try &lt;code&gt;:nnoremap &amp;lt;bs&amp;gt; Xi&lt;/code&gt;&#xA;together with &lt;code&gt;:set bs=2&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-04-04T07:39:48.813" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15812" PostTypeId="1" AcceptedAnswerId="15813" CreationDate="2018-04-04T08:50:45.293" Score="0" ViewCount="757" Body="&lt;p&gt;For debian9, the setting in .vimrc take effect for gvim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Bitstream\ Vera\ Sans\ Mono\ 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For win7,the setting in _vimrc take no effect for gvim at all.&lt;br&gt;&#xA;I open gvim in my win7,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set guifont?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result is &lt;code&gt;Bitstream Vera Sans Mono&lt;/code&gt;,but i find that the character inputed in my gvim in win7 is not &lt;code&gt;Bitstream Vera Sans Mono&lt;/code&gt;,why?&#xA;How to set gui's font in win7&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="5181" LastEditDate="2018-04-04T09:11:14.940" LastActivityDate="2018-04-04T09:31:39.773" Title="Set gui's font in win7" Tags="|font|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15813" PostTypeId="2" ParentId="15812" CreationDate="2018-04-04T09:31:00.693" Score="3" Body="&lt;p&gt;See: &lt;code&gt;:help guifont&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The font name depends on the GUI used.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;For the Win32 GUI&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;p&gt;takes these options in the font name:&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;hXX - height is XX (points, can be floating-point)&lt;/li&gt;&#xA;  &lt;li&gt;wXX - width is XX (points, can be floating-point)&lt;/li&gt;&#xA;  &lt;li&gt;b   - bold&lt;/li&gt;&#xA;  &lt;li&gt;i   - italic&lt;/li&gt;&#xA;  &lt;li&gt;u   - underline&lt;/li&gt;&#xA;  &lt;li&gt;s   - strikeout&lt;/li&gt;&#xA;  &lt;li&gt;cXX - character set XX.  Valid charsets are: ANSI, ARABIC,&#xA;      BALTIC, CHINESEBIG5, DEFAULT, EASTEUROPE, GB2312, GREEK,&#xA;      HANGEUL, HEBREW, JOHAB, MAC, OEM, RUSSIAN, SHIFTJIS,&#xA;      SYMBOL, THAI, TURKISH, VIETNAMESE ANSI and BALTIC.&#xA;      Normally you would use &quot;cDEFAULT&quot;.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Use a ':' to separate the options.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;A '_' can be used in the place of a space, so you don't need to use&#xA;  backslashes to escape the spaces.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set guifont=courier_new:h12:w5:b:cRUSSIAN&#xA;:set guifont=Andale_Mono:h7.5:w4.5&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Bitstream_Vera_Sans_Mono:h14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note also:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For Win32, GTK, Motif, Mac OS and Photon:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :set guifont=*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;will bring up a font requester, where you can pick the font you want.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After doing so, you can check the output of &lt;code&gt;:set guifont?&lt;/code&gt; again to see the correct format.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-04-04T09:31:00.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15814" PostTypeId="2" ParentId="15812" CreationDate="2018-04-04T09:31:39.773" Score="1" Body="&lt;p&gt;You're using the right command. You need to install the font in a way that is recognized by Windows itself and you need to specify the correct name. See &lt;code&gt;:help guifont&lt;/code&gt; for the naming conventions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you can see all available fonts with &lt;code&gt;:set guifont=*&lt;/code&gt;. This will open a standard font-chooser dialog.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-04-04T09:31:39.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15816" PostTypeId="2" ParentId="15791" CreationDate="2018-04-04T15:51:49.427" Score="0" Body="&lt;p&gt;Actually the problem was a misunderstanding of behaviour from my end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Atom, one does &lt;code&gt;atom .&lt;/code&gt; to open the current folder. In &lt;code&gt;vim&lt;/code&gt;/&lt;code&gt;nvim&lt;/code&gt;/&lt;code&gt;vimr&lt;/code&gt; one can simply call it without a path and the current folder will be opened as CWD by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the solution is to simply call the command without any path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I apologize that the question is a bit badly worded and lacks accurate information.&lt;/p&gt;&#xA;" OwnerUserId="17005" LastActivityDate="2018-04-04T15:51:49.427" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15817" PostTypeId="2" ParentId="15775" CreationDate="2018-04-04T20:34:52.663" Score="3" Body="&lt;p&gt;It might be preferable to install an external tool, configurable depending on your needs: it may even have warnings you didn't know about.&#xA;I recommend &lt;a href=&quot;https://github.com/Kuniwak/vint&quot; rel=&quot;nofollow noreferrer&quot;&gt;vint&lt;/a&gt;, which I use with &lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ale&lt;/a&gt; for live linting.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But if you go down this path you need the command to fail (exit code != 0). You can achieve this with an intermediary file (instead of an inline command for readability), i.e. &lt;code&gt;test.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;try&#xA;  source $HOME/.vimrc&#xA;  quit&#xA;catch&#xA;  cquit&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pattern (see &lt;code&gt;:h :catch&lt;/code&gt;) should not only contain &quot;Error detected while processing&quot;, or you would miss some messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you have to to verify if &lt;code&gt;vim -u test.vim&lt;/code&gt; fails, for example in bash:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;vim -N -u test.vim; [[ $? -ne 0 ]] &amp;amp;&amp;amp; echo &quot;Invalid .vimrc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my case I needed &lt;code&gt;-N&lt;/code&gt; to avoid errors as I don't explicitly &lt;code&gt;set nocompatible&lt;/code&gt; in my configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, check &lt;a href=&quot;https://vi.stackexchange.com/a/15564/12003&quot;&gt;this answer&lt;/a&gt; about silent mode and running Vim non-interactively.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2018-04-04T20:34:52.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15818" PostTypeId="2" ParentId="5082" CreationDate="2018-04-05T00:08:10.607" Score="5" Body="&lt;p&gt;I recommend the &lt;a href=&quot;https://github.com/htacg/tidy-html5&quot; rel=&quot;nofollow noreferrer&quot;&gt;tidy-html5&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;As a web developer myself, I also recommend aligning the HTML tags a little differently,&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/airbnb/javascript/tree/master/react#alignment&quot; rel=&quot;nofollow noreferrer&quot;&gt;AirBnb React Styleguide&lt;/a&gt; (most legible &amp;amp; recommended for React)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;a href=&amp;quot;http://someverylongurl.com/foo/bar/blaz/SinwzvO.jpg&amp;quot;&amp;gt;&#xA;  &amp;lt;img&#xA;    src=&amp;quot;http://someverylongurl.com/foo/bar/blaz/Sinwzv0.jpg&amp;quot;&#xA;    class=&amp;quot;ri&amp;quot;&#xA;    alt=&amp;quot;This is an image&amp;quot;&#xA;  &amp;gt;&#xA;&amp;lt;/a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://google.github.io/styleguide/htmlcssguide.html#HTML_Line-Wrapping&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google HTML Styleguide&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;a href=&amp;quot;http://someverylongurl.com/foo/bar/blaz/SinwzvO.jpg&amp;quot;&amp;gt;&#xA;  &amp;lt;img src=&amp;quot;http://someverylongurl.com/foo/bar/blaz/Sinwzv0.jpg&amp;quot;&#xA;       class=&amp;quot;ri&amp;quot; alt=&amp;quot;This is an image&amp;quot;&amp;gt;&#xA;&amp;lt;/a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will really help formatters avoid crazy indentations.&lt;/p&gt;&#xA;" OwnerUserId="14504" LastEditorUserId="14504" LastEditDate="2021-07-13T18:35:54.250" LastActivityDate="2021-07-13T18:35:54.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15819" PostTypeId="1" CreationDate="2018-04-05T01:49:38.787" Score="1" ViewCount="832" Body="&lt;p&gt;&lt;strong&gt;My question is if there is a possible way to hide everything except all text except the current line?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some background:&#xA;I have a really big JSON file which I just did a macro on and am doing a quick eyeball to see that everything looks alright.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm currently doing is searching for a specific keyword and going next.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg: &lt;code&gt;/&quot;Name&quot;:&lt;/code&gt; and holding &lt;code&gt;n&lt;/code&gt; to go to the next result. (dw &lt;code&gt;n&lt;/code&gt; is already mapped to &lt;code&gt;nZZ&lt;/code&gt;) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is really useful at the moment, but it's also very distracting to see other information on the top and bottom constantly changing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a possible way to hide everything except the current line (image for reference)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VcQSa.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VcQSa.png&quot; alt=&quot;Image for reference&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17045" LastActivityDate="2018-04-10T00:31:06.673" Title="Vim only show current line / hide every other line" Tags="|search|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="15820" PostTypeId="1" AcceptedAnswerId="15822" CreationDate="2018-04-05T05:58:58.160" Score="4" ViewCount="1579" Body="&lt;p&gt;Is there a way to indent automatcally after typing a : when editing python in vim?  I works that way in CodeMirror and I found it nice; so I wondered if vim has that capability?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2019-02-26T15:02:23.910" Title="Plugin for vim that auto indents after a : when editing python?" Tags="|filetype-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15821" PostTypeId="2" ParentId="15819" CreationDate="2018-04-05T07:26:38.470" Score="0" Body="&lt;p&gt;You could use &quot;vimgrep&quot; to get all the results in a quickfix window and jump to the results you want to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not exactly what you're looking for but a workaround.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimgrep /&quot;Name&quot;:/j | cw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: Switch between quickfix window and the buffer using CTRL-W CTRL-W&lt;/p&gt;&#xA;" OwnerUserId="16636" LastEditorUserId="16636" LastEditDate="2018-04-05T08:31:35.800" LastActivityDate="2018-04-05T08:31:35.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15822" PostTypeId="2" ParentId="15820" CreationDate="2018-04-05T08:37:50.347" Score="7" Body="&lt;p&gt;Try adding the following lines to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. The &lt;code&gt;plugin&lt;/code&gt; is not necessary for indenting, but it enables filetype plugins to run, which you probably want.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will cause Vim to load its Python indent script when you edit a Python file, which will set the following option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set indentexpr=GetPythonIndent(v:lnum)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will cause Vim to use an automatic indent on lines after statements that end in &lt;code&gt;:&lt;/code&gt; characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you'd like to see how this works, you can view the indent script with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e $VIMRUNTIME/indent/python.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h :filetype-indent-on&lt;/code&gt; and &lt;code&gt;:h indent-expressions&lt;/code&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find Vim's included indent file insufficient for your needs, &lt;a href=&quot;https://github.com/Vimjas/vim-python-pep8-indent.git&quot; rel=&quot;nofollow noreferrer&quot;&gt;you might like to try this plugin&lt;/a&gt;, which offers a few refinements over the built-in version: this is what I'm currently using for Python indenting.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-02-26T15:02:23.910" LastActivityDate="2019-02-26T15:02:23.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15823" PostTypeId="2" ParentId="15819" CreationDate="2018-04-05T09:00:08.670" Score="0" Body="&lt;p&gt;One way to achieve this would be to set all your highlighting groups to have the same foreground &lt;code&gt;ctermfg/guifg&lt;/code&gt; and background &lt;code&gt;ctermbg/guibg&lt;/code&gt; colours, and then use &lt;code&gt;set cursorline&lt;/code&gt; and the &lt;code&gt;CursorLine&lt;/code&gt; highlight group to change the colour of the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, an easier way to do it is to install the &lt;a href=&quot;https://github.com/junegunn/limelight.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Limelight plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need to add the following configuration to your &lt;code&gt;.vimrc&lt;/code&gt; in order to make Limelight focus on a single line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:limelight_bop = '^'&#xA;let g:limelight_eop = '$'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then switch Limelight on and off with the commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Limelight 1&#xA;:Limelight!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. The &lt;code&gt;1&lt;/code&gt; in the command above is an opacity/intensity parameter. If you do not include it, or use instead a value between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;, then Limelight will dim down the other lines, but not hide them completely.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-04-05T09:00:08.670" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15824" PostTypeId="2" ParentId="15819" CreationDate="2018-04-05T10:55:19.597" Score="2" Body="&lt;p&gt;I think you can use 'Conceal' feature.&#xA;For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:match Conceal /^.*$/&#xA;:set conceallevel=3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All the lines except current one will be concealed.&#xA;If you do not like the 'Conceal' color,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight Conceal NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you finish, just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:match&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1641" LastActivityDate="2018-04-05T10:55:19.597" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15825" PostTypeId="1" AcceptedAnswerId="15890" CreationDate="2018-04-05T11:06:35.497" Score="0" ViewCount="765" Body="&lt;p&gt;When I open a ruby based file (&lt;code&gt;.rb,.erb&lt;/code&gt;) in nvim, it causes my whole laptop to slow down!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to be caused by &lt;code&gt;sheerun/vim-polyglot&lt;/code&gt; that I use for syntax highlighting, specifically the ruby module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any one have a better option or a way to fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/Thermatix/dotfiles/tree/master/tag-config/config/nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvim config&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11603" LastEditorUserId="11603" LastEditDate="2018-04-05T11:36:28.640" LastActivityDate="2018-04-10T21:04:29.770" Title="sheerun/vim-polyglot ruby seems cause enormous slow down, how to fix or better plugin to use?" Tags="|neovim|performance|filetype-ruby|plugin-vim-polyglot|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15826" PostTypeId="1" CreationDate="2018-04-05T14:55:57.053" Score="1" ViewCount="490" Body="&lt;p&gt;I have been using spf13-vim for a while now. Recently I have upgraded by pulling down master from GitHub repo. After the updates I see that spf13-vim has neocomplete enabled by default.&#xA;One of the settings in &lt;strong&gt;&lt;em&gt;~/.vimrc.bundles&lt;/em&gt;&lt;/strong&gt; is as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('g:spf13_bundle_groups')&#xA;        let g:spf13_bundle_groups=['general', 'writing', 'neocomplete', 'programming', 'php', 'ruby', 'python', 'javascript', 'html', 'misc',]&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another setting in &lt;strong&gt;&lt;em&gt;~/.vimrc&lt;/em&gt;&lt;/strong&gt; is as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; neocomplete {&#xA;        if count(g:spf13_bundle_groups, 'neocomplete')&#xA;            let g:acp_enableAtStartup = 0&#xA;            let g:neocomplete#enable_at_startup = 1&#xA;            let g:neocomplete#enable_smart_case = 1&#xA;            let g:neocomplete#enable_auto_delimiter = 1&#xA;            let g:neocomplete#max_list = 15&#xA;            let g:neocomplete#force_overwrite_completefunc = 1&#xA;            ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then further down in &lt;strong&gt;&lt;em&gt;~/.vimrc&lt;/em&gt;&lt;/strong&gt; some key bindings as following...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Define keyword.&#xA;            if !exists('g:neocomplete#keyword_patterns')&#xA;                let g:neocomplete#keyword_patterns = {}&#xA;            endif&#xA;            let g:neocomplete#keyword_patterns['default'] = '\h\w*'&#xA;&#xA;            &quot; Plugin key-mappings {&#xA;                &quot; These two lines conflict with the default digraph mapping of &amp;lt;C-K&amp;gt;&#xA;                if !exists('g:spf13_no_neosnippet_expand')&#xA;                    imap &amp;lt;C-k&amp;gt; &amp;lt;Plug&amp;gt;(neosnippet_expand_or_jump)&#xA;                    smap &amp;lt;C-k&amp;gt; &amp;lt;Plug&amp;gt;(neosnippet_expand_or_jump)&#xA;                endif&#xA;                if exists('g:spf13_noninvasive_completion')&#xA;                    inoremap &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;&#xA;                    &quot; &amp;lt;ESC&amp;gt; takes you out of insert mode&#xA;                    inoremap &amp;lt;expr&amp;gt; &amp;lt;Esc&amp;gt;   pumvisible() ? &quot;\&amp;lt;C-y&amp;gt;\&amp;lt;Esc&amp;gt;&quot; : &quot;\&amp;lt;Esc&amp;gt;&quot;&#xA;                    &quot; &amp;lt;CR&amp;gt; accepts first, then sends the &amp;lt;CR&amp;gt;&#xA;                    inoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt;    pumvisible() ? &quot;\&amp;lt;C-y&amp;gt;\&amp;lt;CR&amp;gt;&quot; : &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;                    &quot; &amp;lt;Down&amp;gt; and &amp;lt;Up&amp;gt; cycle like &amp;lt;Tab&amp;gt; and &amp;lt;S-Tab&amp;gt;&#xA;                    inoremap &amp;lt;expr&amp;gt; &amp;lt;Down&amp;gt;  pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;Down&amp;gt;&quot;&#xA;                    inoremap &amp;lt;expr&amp;gt; &amp;lt;Up&amp;gt;    pumvisible() ? &quot;\&amp;lt;C-p&amp;gt;&quot; : &quot;\&amp;lt;Up&amp;gt;&quot;&#xA;                    &quot; Jump up and down the list&#xA;                    inoremap &amp;lt;expr&amp;gt; &amp;lt;C-d&amp;gt;   pumvisible() ? &quot;\&amp;lt;PageDown&amp;gt;\&amp;lt;C-p&amp;gt;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;C-d&amp;gt;&quot;&#xA;                    inoremap &amp;lt;expr&amp;gt; &amp;lt;C-u&amp;gt;   pumvisible() ? &quot;\&amp;lt;PageUp&amp;gt;\&amp;lt;C-p&amp;gt;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;C-u&amp;gt;&quot;&#xA;                else&#xA;                    &quot; &amp;lt;C-k&amp;gt; Complete Snippet&#xA;                    &quot; &amp;lt;C-k&amp;gt; Jump to next snippet point&#xA;                    imap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt;&amp;lt;C-k&amp;gt; neosnippet#expandable() ?&#xA;                                \ &quot;\&amp;lt;Plug&amp;gt;(neosnippet_expand_or_jump)&quot; : (pumvisible() ?&#xA;                                \ &quot;\&amp;lt;C-e&amp;gt;&quot; : &quot;\&amp;lt;Plug&amp;gt;(neosnippet_expand_or_jump)&quot;)&#xA;                    smap &amp;lt;TAB&amp;gt; &amp;lt;Right&amp;gt;&amp;lt;Plug&amp;gt;(neosnippet_jump_or_expand)&#xA;&#xA;                    inoremap &amp;lt;expr&amp;gt;&amp;lt;C-g&amp;gt; neocomplete#undo_completion()&#xA;                    inoremap &amp;lt;expr&amp;gt;&amp;lt;C-l&amp;gt; neocomplete#complete_common_string()&#xA;                    &quot;inoremap &amp;lt;expr&amp;gt;&amp;lt;CR&amp;gt; neocomplete#complete_common_string()&#xA;&#xA;                    &quot; &amp;lt;CR&amp;gt;: close popup&#xA;                    &quot; &amp;lt;s-CR&amp;gt;: close popup and save indent.&#xA;                    inoremap &amp;lt;expr&amp;gt;&amp;lt;s-CR&amp;gt; pumvisible() ? neocomplete#smart_close_popup().&quot;\&amp;lt;CR&amp;gt;&quot; : &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;&#xA;                    function! CleverCr()&#xA;                        if pumvisible()&#xA;                            if neosnippet#expandable()&#xA;                                let exp = &quot;\&amp;lt;Plug&amp;gt;(neosnippet_expand)&quot;&#xA;                                return exp . neocomplete#smart_close_popup()&#xA;                            else&#xA;                                return neocomplete#smart_close_popup()&#xA;                            endif&#xA;                        else&#xA;                            return &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;                        endif&#xA;                    endfunction&#xA;&#xA;                    &quot; &amp;lt;CR&amp;gt; close popup and save indent or expand snippet&#xA;                    imap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; CleverCr()&#xA;                    &quot; &amp;lt;C-h&amp;gt;, &amp;lt;BS&amp;gt;: close popup and delete backword char.&#xA;                    inoremap &amp;lt;expr&amp;gt;&amp;lt;BS&amp;gt; neocomplete#smart_close_popup().&quot;\&amp;lt;C-h&amp;gt;&quot;&#xA;                    inoremap &amp;lt;expr&amp;gt;&amp;lt;C-y&amp;gt; neocomplete#smart_close_popup()&#xA;                endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So from these config pieces, it seems like neocomplete is enabled by default. However, now when I enter any document in vim and try to edit in insert mode, Backspace (on MAC) doesn't work as usual and I get error saying:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E117: Unknown function: neocomplete#smart_close_popup&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;E15: Invalid expression: neocomplete#smart_close_popup().&quot;\^H&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I tried following approaches to fix it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a)&#xA;By putting following in my &lt;strong&gt;&lt;em&gt;~/.vimrc.before.local&lt;/em&gt;&lt;/strong&gt; (notice omitted neocomplete). I don't like the approach because this completely disables neocomplete.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:spf13_bundle_groups=['general', 'writing', 'programming', 'php', 'ruby', 'python', 'scala', 'javascript', 'html', 'misc',]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;b)&#xA;Setting following at the bottom of my &lt;strong&gt;&lt;em&gt;~/.vimrc&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set backspace = indent,eol,start&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This approach didn't work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I have idea maybe to put following in my &lt;strong&gt;&lt;em&gt;~/.vimrc.before.local&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:spf13_noninvasive_completion = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I don't know what autocompletions I would loose with that? Also, is there another way to fix this, or why is my spf13-vim installation unable to find&#xA; &lt;strong&gt;&lt;em&gt;neocomplete#smart_close_popup&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="17053" LastEditorUserId="1841" LastEditDate="2018-04-05T15:07:43.293" LastActivityDate="2020-08-22T22:04:40.587" Title="neocomplete error when using latest spf13-vim" Tags="|macvim|plugin-neocomplete|plugin-spf13|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15827" PostTypeId="2" ParentId="15826" CreationDate="2018-04-05T15:02:42.227" Score="1" Body="&lt;p&gt;It happened to be the problem with how I updated &lt;strong&gt;spf13-vim&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did only&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.spf13-vim/&#xA;git pull&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I forgot to do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +BundleInstall! +BundleClean +q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After doing that, &lt;strong&gt;spf13-vim&lt;/strong&gt; re-installed some packages and installed following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+ Shougo/neocomplete.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After openning new vim files I am now able to use Backspace again without problems with neocomplete.&lt;/p&gt;&#xA;" OwnerUserId="17053" LastActivityDate="2018-04-05T15:02:42.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15828" PostTypeId="2" ParentId="6844" CreationDate="2018-04-05T16:49:32.267" Score="2" Body="&lt;p&gt;you can create a shortcut for nvim-qt.vim and change the target to something like &lt;code&gt;C:\tools\neovim\Neovim\bin\nvim-qt.exe -qwindowgeometry 1030x608&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and the window becomes the size you specified. &lt;/p&gt;&#xA;" OwnerUserId="11572" LastActivityDate="2018-04-05T16:49:32.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15829" PostTypeId="1" CreationDate="2018-04-06T00:09:28.007" Score="2" ViewCount="413" Body="&lt;p&gt;Sometimes I have two windows open and I search for a word that appears in both. Hitting &lt;kbd&gt;n&lt;/kbd&gt; only cycles through the results in the active window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It'd be really convenient to somehow jump to the next search result in all open windows.&lt;/p&gt;&#xA;" OwnerUserId="14504" LastActivityDate="2018-04-06T20:31:07.640" Title="How do I jump to the next search result in a different window?" Tags="|search|buffers|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15830" PostTypeId="1" AcceptedAnswerId="16079" CreationDate="2018-04-06T00:13:19.347" Score="1" ViewCount="139" Body="&lt;p&gt;I'm a very new vim user and I'm enjoying it, so I've decided to try SpaceVim. But each time I launch vim, I see the error &lt;code&gt;Can not set language to en_US.utf8&lt;/code&gt;, and vim gives me the option to press  and continue the launch. Everything seams to be working fine, but I'd rather have the error fixed and not need to press the extra key each time I launch vim. I've tried adding the line &lt;code&gt;let g:spacevim_language = 'en_XX.utf8'&lt;/code&gt; (where 'XX' is my country's ISO code) to the init.vim file, but this seams to have no effect. &lt;/p&gt;&#xA;" OwnerUserId="16949" LastActivityDate="2018-12-25T11:00:32.077" Title="'Can not set language' error on SpaceVim launch" Tags="|error|spacevim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15831" PostTypeId="1" CreationDate="2018-04-06T04:53:43.263" Score="1" ViewCount="53" Body="&lt;p&gt;Recent versions of Vim provide each quickfix list with a unique id and allow you to set an arbitrary &quot;context&quot; attribute on the list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to set the &quot;context&quot; on an existing quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setqflist([], 'r', {'context': 'foo'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it's unclear to me whether I should use &lt;code&gt;'r'&lt;/code&gt; (replace) or &lt;code&gt;'a'&lt;/code&gt; (append), since I'm not actually modifying the list entries, just a property attached to the overall list. It seems to behave the same either way, so I guess that argument is irrelevant in this case, but am I missing something?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2018-04-06T04:53:43.263" Title="Correct way to add &quot;context&quot; attribute to an existing quickfix list" Tags="|quickfix|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15833" PostTypeId="1" AcceptedAnswerId="15834" CreationDate="2018-04-06T08:35:12.443" Score="0" ViewCount="46" Body="&lt;p&gt;Part of setting in my .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat .vimrc&#xA;autocmd FileType txt setlocal omnifunc=CompleteMonths &#xA;fun! CompleteMonths(findstart, base)&#xA;  if a:findstart&#xA;    &quot; locate the start of the word&#xA;    let line = getline('.')&#xA;    let start = col('.') - 1&#xA;    while start &amp;gt; 0 &amp;amp;&amp;amp; line[start - 1] =~ '\a'&#xA;      let start -= 1&#xA;    endwhile&#xA;    return start&#xA;  else&#xA;    &quot; find months matching with &quot;a:base&quot;&#xA;    let res = []&#xA;    for m in split(&quot;Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec&quot;)&#xA;      if m =~ '^' . a:base&#xA;    call add(res, m)&#xA;      endif&#xA;    endfor&#xA;    return res&#xA;  endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now edit a test.txt file in vim.&#xA;Input &lt;code&gt;J&lt;/code&gt; and press &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; ,why no month complete menu pop up? &lt;/p&gt;&#xA;" OwnerUserId="5181" LastActivityDate="2018-04-06T08:50:21.440" Title="Why can't complete month in txt file?" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15834" PostTypeId="2" ParentId="15833" CreationDate="2018-04-06T08:50:21.440" Score="1" Body="&lt;p&gt;You need to change your autocmd to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType text set omnifunc=CompleteMonths&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The file type for &lt;code&gt;.txt&lt;/code&gt; files is &lt;code&gt;text&lt;/code&gt; not &lt;code&gt;txt&lt;/code&gt; and &lt;code&gt;omnifunc&lt;/code&gt; is already local to the buffer (see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27omnifunc%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'omnifunc'&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also need to make sure that you have a line like this in your vimrc to be sure that the filetype is set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With these modifications on your vimrc, the completion works on my setup.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-04-06T08:50:21.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15835" PostTypeId="2" ParentId="14698" CreationDate="2018-04-06T09:10:07.080" Score="2" Body="&lt;p&gt;As correctly stated by Christian Brabandt &lt;a href=&quot;https://vi.stackexchange.com/questions/14698/how-to-bypass-the-file-has-been-changed-since-reading-it#comment25235_14698&quot;&gt;in the comments&lt;/a&gt;, use &lt;code&gt;:h W11&lt;/code&gt; to see possible reasons for such warning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my own case I was editing file located on the Samba share under Windows and possible inconsistency in timezones across Win/*nix invoked such warning.&#xA;Putting the file to Linux machine solved the problem for me.&lt;/p&gt;&#xA;" OwnerUserId="3208" LastEditorUserId="1841" LastEditDate="2018-04-06T09:42:19.667" LastActivityDate="2018-04-06T09:42:19.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15836" PostTypeId="1" AcceptedAnswerId="15838" CreationDate="2018-04-06T09:24:51.647" Score="-1" ViewCount="470" Body="&lt;p&gt;I am building my statusline.  Previously I used functions to return information, but recently I learnt that these can be done in one line. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{&amp;amp;modified?'\ \ [+]':''}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need to find if file is readonly or non-modifiable, like the example above. Right now I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{&amp;amp;readonly?'\ ':''}\ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I need something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{(&amp;amp;readonly || !&amp;amp;modifiable)?'\ ':''}\ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get an error: &lt;code&gt;unclosed expression sequence&lt;/code&gt;.  What's the situation here?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="1430" LastEditDate="2018-04-07T01:01:16.490" LastActivityDate="2018-04-07T01:01:16.490" Title="Showing read-only or non-modifiable status in status line" Tags="|statusline|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15838" PostTypeId="2" ParentId="15836" CreationDate="2018-04-06T09:50:13.200" Score="2" Body="&lt;p&gt;The full error gives you a hint as to the problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E540: Unclosed expression sequence: statusline=%{(&amp;amp;readonly&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You cannot include unescaped space characters in &lt;code&gt;:set&lt;/code&gt; commands, because Vim interprets them as the end of the setting. (See &lt;code&gt;:h option-backslash&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quickest solution is to escape your space characters (or just remove them! &lt;code&gt;(&amp;amp;readonly||!&amp;amp;modifiable)&lt;/code&gt; will evaluate fine), but I prefer to use &lt;code&gt;:let&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;statusline .= '%{(&amp;amp;readonly || !&amp;amp;modifiable) ? &quot; &quot; : &quot;&quot;} '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(See &lt;code&gt;:h :let-option&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-04-06T10:54:03.003" LastActivityDate="2018-04-06T10:54:03.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15841" PostTypeId="2" ParentId="15829" CreationDate="2018-04-06T14:37:03.850" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;:vimgrep&lt;/code&gt; to do your search over the windows and use &lt;code&gt;'switchbuf'&lt;/code&gt; with a value of at least &lt;code&gt;useopen&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'vimgrep //j ' . join(map(range(1, winnr('$')), '&quot;#&quot;.winbufnr(v:val)'), ' ')&#xA;set switchbuf+=useopen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use the quickfix list to jump between matches you searched via &lt;code&gt;:cnext&lt;/code&gt;/&lt;code&gt;:cprev&lt;/code&gt; (&lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;I suggest mapping these&lt;/a&gt;) or by using the quickfix window, &lt;code&gt;:copen&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I can't really see myself using this kind of search. I typically need to search more files so I use &lt;code&gt;:vimgrep&lt;/code&gt; or &lt;code&gt;:grep&lt;/code&gt; (I use ripgrep as my &lt;code&gt;'grepprg'&lt;/code&gt;). I use my own &lt;code&gt;:Cfilter&lt;/code&gt; command to grep/filter the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:cfilter(list, bang, pat)&#xA;  let [bool, operator] = a:bang ? ['&amp;amp;&amp;amp;', '!~'] : ['||', '=~']&#xA;  let pat = a:pat =~ '^/.*/$' ? a:pat[1:-2] : a:pat&#xA;  let pat = pat == '' ? @/ : pat&#xA;  call call('set'.a:list.'list', [(filter(call('get'.a:list.'list', []), &quot;bufname(v:val.bufnr) &quot;.operator.&quot; pat &quot;.bool.&quot; v:val.text &quot;.operator.&quot; pat&quot;))])&#xA;  echo 'Filtered list: '.(a:bang ? 'not ' : '').'matching '.a:pat.' ('.len(call('get'.a:list.'list', [])).' items)'&#xA;endfunction&#xA;command! -nargs=1 -bang Cfilter call &amp;lt;SID&amp;gt;cfilter('qf', &amp;lt;bang&amp;gt;0, &amp;lt;q-args&amp;gt;)&#xA;command! -nargs=1 -bang Lfilter call &amp;lt;SID&amp;gt;cfilter('loc', &amp;lt;bang&amp;gt;0, &amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:Cfilter foo&lt;/code&gt; will filter the list for only entries with &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;:Cfilter! foo&lt;/code&gt; will filter the list with only entries without &lt;code&gt;foo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more helps see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :vimgrep&#xA;:h :_#n&#xA;:h join()&#xA;:h map()&#xA;:h range()&#xA;:h winnr()&#xA;:h winbufnr()&#xA;:h v:val&#xA;:h :execute&#xA;:h 'swb'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-04-06T14:37:03.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15843" PostTypeId="1" AcceptedAnswerId="16006" CreationDate="2018-04-06T17:12:06.100" Score="4" ViewCount="318" Body="&lt;p&gt;I am writing a VBA routine so I can use &lt;em&gt;normal-mode&lt;/em&gt; commands in Microsoft Word.  (Yes, I am!  &lt;strong&gt;Edit&lt;/strong&gt; And &lt;a href=&quot;https://github.com/cxw42/VimWord&quot; rel=&quot;nofollow noreferrer&quot;&gt;here you go!&lt;/a&gt;)  I am only going to support the &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;, and &lt;code&gt;y&lt;/code&gt; operators initially, and only char/word/sentence/paragraph motions.  No visual mode, no &lt;code&gt;]]&lt;/code&gt; &amp;amp;c., no &lt;code&gt;&quot;*&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an easy way to parse the command the user has entered?  My thought is that it probably can be done with a regex, since the count/operator/count/motion sequence is fairly restrictive.  Something like (very magic):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^([0-9]*)([dcy])([0-9]*)([ai][wWsp]|[hjklGfFtTwebWEB\)\(\}\{])$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone already have a regex or parser that will do this?  I am wondering if I have missed any corner cases or subtleties in the above.  (&lt;strong&gt;Edit&lt;/strong&gt; For example, I had included &lt;code&gt;0&lt;/code&gt; as a valid trailing character, which interacted badly with the &lt;code&gt;[0-9]*&lt;/code&gt; before it.)  Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="51" LastEditDate="2018-08-22T16:52:45.283" LastActivityDate="2020-02-13T11:10:59.320" Title="Parsing a valid normal-mode command (possibly with regex)? (for Vim-like Word add-in)" Tags="|regular-expression|normal-mode|microsoft-windows|parsing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15844" PostTypeId="1" CreationDate="2018-04-06T19:15:17.657" Score="0" ViewCount="1590" Body="&lt;p&gt;I have vi shortcuts set on my gnome-terminal and can't figure out how to scroll through the terminal's output after the change. Before I could use Shift+Page-up, but this isn't working in normal or insert mode. I'm also using tmux.&lt;/p&gt;&#xA;" OwnerUserId="16949" LastActivityDate="2018-04-06T20:40:33.740" Title="Scrolling the terminal with vi shortcuts?" Tags="|key-bindings|terminal|scrolling|" AnswerCount="1" CommentCount="1" ClosedDate="2018-04-07T16:51:44.920" ContentLicense="CC BY-SA 3.0" />
  <row Id="15845" PostTypeId="2" ParentId="15844" CreationDate="2018-04-06T19:34:26.087" Score="3" Body="&lt;p&gt;In tmux you can use &lt;code&gt;prefix+[&lt;/code&gt; to &lt;a href=&quot;https://superuser.com/questions/209437/how-do-i-scroll-in-tmux&quot;&gt;enable scrolling&lt;/a&gt;, which allows you to scroll inside your pane using vim bindings. Use &lt;code&gt;q&lt;/code&gt; to exit this mode.&lt;/p&gt;&#xA;" OwnerUserId="7601" LastEditorUserId="7601" LastEditDate="2018-04-06T20:40:33.740" LastActivityDate="2018-04-06T20:40:33.740" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15846" PostTypeId="1" AcceptedAnswerId="16011" CreationDate="2018-04-06T22:46:31.847" Score="7" ViewCount="729" Body="&lt;p&gt;Vim 8 has introduced the sign feature, that allows people to mark locations within a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed there is a &lt;code&gt;:sign jump&lt;/code&gt; command to jump to a sign, but it requires a buffer &lt;em&gt;and&lt;/em&gt; an id as an argument, so as far as I could tell I would have to use &lt;code&gt;:sign place&lt;/code&gt; to find out the sign id and then also know which file the sign belongs to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some combination of vimscript functions that allow me to jump to &quot;the next sign&quot; in some sense, similar to how &lt;code&gt;:cn&lt;/code&gt; jumps to the next quickfix location? Alternatively, is there an easy way to fill quickfix with the sign locations?&lt;/p&gt;&#xA;" OwnerUserId="13662" LastActivityDate="2018-07-20T21:45:55.243" Title="Is there a way to quickly jump to signs?" Tags="|quickfix|signs|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15847" PostTypeId="1" AcceptedAnswerId="15848" CreationDate="2018-04-07T01:19:27.837" Score="3" ViewCount="1518" Body="&lt;p&gt;I tried to install vim from source. I do not have sudo rights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, i cloned the last revision from github, and configured as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure                  \&#xA;    --with-features=huge                    \&#xA;    --enable-multibyte                      \&#xA;    --enable-pythoninterp=dynamic           \&#xA;    --enable-python3interp=dynamic          \&#xA;    --with-python-config-dir=$PY_CONFIG     \&#xA;    --with-python3-config-dir=$PY3_CONFIG   \&#xA;    --enable-gui=gtk2                       \&#xA;    --enable-cscope                         \&#xA;    --prefix=$HOME/.local $@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;note the &lt;code&gt;$HOME/.local&lt;/code&gt; prefix.&#xA;Then I did &lt;code&gt;make &amp;amp;&amp;amp; make install&lt;/code&gt;.&#xA;All went great. Now, unfortunately, when I try to take my first steps with vim, and do &lt;code&gt;~/.local/bin/vimtutor&lt;/code&gt;, It complains that it can't find the corresponding page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing command line:&#xA;E484: Can't open file /usr/share/vim/vim74/tutor/tutor.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am baffled how it thinks that I might have vim 7.4, and managed to mess up it's paths like that - because it installed the corresponding files, as was to be expected, in &lt;code&gt;/home/simon/.local/share/vim/vim80&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Help? :D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tips on whether I have not yet grasped how to build software like vim with make locally the right way, would be also very appreciated :) I'm new to the whole linux stuff...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot!&lt;/p&gt;&#xA;" OwnerUserId="17075" LastEditorUserId="205" LastEditDate="2018-04-07T05:42:01.797" LastActivityDate="2018-04-07T06:00:24.297" Title="Vim 8 built locally with custom prefix -- doesn't find tutor right off the bat" Tags="|installing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15848" PostTypeId="2" ParentId="15847" CreationDate="2018-04-07T06:00:24.297" Score="0" Body="&lt;p&gt;Note that &lt;code&gt;vimtutor&lt;/code&gt; is actually &lt;a href=&quot;https://github.com/vim/vim/blob/d07969093a9b3051511c478d71c36de6fc33c0d6/src/vimtutor#L55&quot; rel=&quot;nofollow noreferrer&quot;&gt;a script&lt;/a&gt; with searches for a suitable &lt;code&gt;vim&lt;/code&gt; and runs it. So, make sure that your local &lt;code&gt;vim&lt;/code&gt; comes before the system vim in &lt;code&gt;PATH&lt;/code&gt;. For example, with this minimal &lt;code&gt;PATH&lt;/code&gt; ensuring no other &lt;code&gt;vim&lt;/code&gt; is found, &lt;code&gt;vimtutor&lt;/code&gt; loads fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PATH=$HOME/.local/bin:/bin ~/.local/bin/vimtutor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's better to prefix &lt;code&gt;$HOME/.local/bin&lt;/code&gt; to &lt;code&gt;$PATH&lt;/code&gt; in your &lt;code&gt;.profile&lt;/code&gt; or equivalent.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-04-07T06:00:24.297" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15849" PostTypeId="1" AcceptedAnswerId="15851" CreationDate="2018-04-07T08:26:38.733" Score="0" ViewCount="413" Body="&lt;p&gt;Can you help me how this function does what it does, like step by step?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GitBranch()&#xA;    return system(&quot;git rev-parse --abbrev-ref HEAD 2&amp;gt;/dev/null | tr -d '\n'&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I previously used a &lt;a href=&quot;https://github.com/itchyny/lightline.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt;. Now I came across this function but can't understand it. Can anyone help me?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2018-04-07T09:58:21.177" Title="Learning vimscripting and functions" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15850" PostTypeId="1" AcceptedAnswerId="15866" CreationDate="2018-04-07T09:14:06.970" Score="2" ViewCount="786" Body="&lt;p&gt;I want trailing and leading whitespaces to be highlighted by vim. I created a ~/.vimrc file and appended this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; highlight trailing and leading whitespaces&#xA;highlight TrailingWhitespaces ctermbg=red&#xA;match TrailingWhitespaces /\s\s*$/&#xA;highlight LeadingWhitespaces ctermbg=red&#xA;match LeadingWhitespaces /^\s\s*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason &lt;code&gt;/\s+$/&lt;/code&gt; and &lt;code&gt;/^\s+/&lt;/code&gt;  didn't work at all it matched &#xA;the &lt;code&gt;+&lt;/code&gt; literally - i.e. &lt;code&gt;/\s\+$/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore,  only the first one, Trailing- or LeadingWhitespaces is being applied:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/uvask.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uvask.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, leading whitespaces are highlighted but trailing ones are not. Once I put the &lt;code&gt;LeadingWhitespaces&lt;/code&gt; at the top, only trailing whitespaces are highlighted:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7t4ku.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7t4ku.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I not doing right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think there is a conflict with any other options in my ~/.vimrc file but just in case, &lt;a href=&quot;https://pastebucket.com/565899&quot; rel=&quot;nofollow noreferrer&quot;&gt;here is the whole file&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17079" LastEditorUserId="17079" LastEditDate="2018-04-07T09:21:00.787" LastActivityDate="2018-04-09T09:07:59.517" Title="Why does vim not highlighting leading and trailing spaces?" Tags="|vimrc|vimscript|regular-expression|" AnswerCount="1" CommentCount="2" ClosedDate="2018-04-10T06:05:44.647" ContentLicense="CC BY-SA 3.0" />
  <row Id="15851" PostTypeId="2" ParentId="15849" CreationDate="2018-04-07T09:49:58.953" Score="2" Body="&lt;p&gt;The function calls Vim's &lt;code&gt;system()&lt;/code&gt; function. This passes its argument (a pipeline containing a git command) on to the shell and returns its output. See &lt;code&gt;help system()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm afraid explaining the way any given shell pipeline works isn't within the scope of this site. I'd recommend reading &lt;code&gt;man git-rev-parse&lt;/code&gt; and &lt;code&gt;man tr&lt;/code&gt; in your shell, or perhaps you could ask on &lt;a href=&quot;https://stackoverflow.com/&quot;&gt;Stack Overflow&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be honest, you don't really need to know in detail how the git command works. It returns your current branch: that's all you need to know!&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-04-07T09:58:21.177" LastActivityDate="2018-04-07T09:58:21.177" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15852" PostTypeId="1" AcceptedAnswerId="15853" CreationDate="2018-04-07T20:59:28.910" Score="0" ViewCount="730" Body="&lt;p&gt;I'd like to map a function key (f.i. F7) to have quickly the &lt;strong&gt;gggqG&lt;/strong&gt; format command; i'd like to place it permanently in my .vimrc and working in console (not in gvim). I red some literature, but I was not able to solve. Any suggestion? Thanx&lt;/p&gt;&#xA;" OwnerUserId="16136" LastActivityDate="2018-04-07T21:38:47.600" Title="How to map a function key in (console) vim" Tags="|vimrc|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15853" PostTypeId="2" ParentId="15852" CreationDate="2018-04-07T21:38:47.600" Score="1" Body="&lt;p&gt;simply put &lt;code&gt;map &amp;lt;f7&amp;gt; gggqG&lt;/code&gt; into your .vimrc. It works out of the box for most&#xA;terminals, including xterm and xterm-256color&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-04-07T21:38:47.600" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15854" PostTypeId="2" ParentId="15806" CreationDate="2018-04-08T01:41:13.490" Score="1" Body="&lt;p&gt;Another week, another Saturday night .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added the below line to the above posted &lt;strong&gt;sessions.vim&lt;/strong&gt; file, and now custom code folds, and conceal levels are being persisted through Vim / Neovim restarts. ✧&lt;em&gt;｡٩(ˊᗜˋ&lt;/em&gt;)و✧*｡&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set sessionoptions=folds,localoptions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10550" LastActivityDate="2018-04-08T01:41:13.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15855" PostTypeId="1" AcceptedAnswerId="15856" CreationDate="2018-04-08T03:47:47.390" Score="0" ViewCount="805" Body="&lt;p&gt;If I want to change the tab size, I can do that with &lt;code&gt;set tabstop=&amp;lt;number&amp;gt;&lt;/code&gt;. I have that in my .vimrc to make it 4 instead of 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I indent/deindent text by highlighting it then using &lt;code&gt;&amp;gt;&lt;/code&gt;, it still uses the default tab size of 8. How can I make this be 4 too?&lt;/p&gt;&#xA;" OwnerUserId="17088" LastEditorUserId="1841" LastEditDate="2018-04-08T10:55:51.667" LastActivityDate="2018-04-08T10:55:51.667" Title="How to change the size of the indent that's created using &quot;&gt;&quot; (forward arrow)?" Tags="|vimrc|indentation|tab-characters|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15856" PostTypeId="2" ParentId="15855" CreationDate="2018-04-08T06:35:31.500" Score="3" Body="&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h &amp;gt;&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        &amp;lt;&#xA; &amp;gt;{motion}              Shift {motion} lines one 'shiftwidth' rightwards.&#xA;                                                        &amp;gt;&amp;gt;&#xA; &amp;gt;&amp;gt;                     Shift [count] lines one 'shiftwidth' rightwards.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you need to set &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27shiftwidth%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;shiftwidth&lt;/code&gt;&lt;/a&gt; to affect this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shiftwidth=4&#xA;&quot; or, to use the value of 'tabstop'&#xA;set shiftwidth=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-04-08T06:35:31.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15857" PostTypeId="1" CreationDate="2018-04-08T15:05:00.670" Score="5" ViewCount="68" Body="&lt;p&gt;Vim uses regular expressions for syntax highlighting. Often maintaining these can become rather unwieldy. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match goVarAssign /\v[_.[:alnum:]]+(,\s*[_.[:alnum:]]+)*\ze(\s*([-^+|^\/%&amp;amp;]|\*|\&amp;lt;\&amp;lt;|\&amp;gt;\&amp;gt;|\&amp;amp;\^)?\=[^=])/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example Python supports &lt;a href=&quot;https://docs.python.org/3/library/re.html#re.X&quot; rel=&quot;noreferrer&quot;&gt;comments inside regular expressions&lt;/a&gt;, which would make things a lot more helpful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match goVarAssign /\v&#xA;    [_.[:alnum:]]+          &quot; One or more valid identifier characters.&#xA;    (,\s*[_.[:alnum:]]+)*   &quot; Repeated one or more times separated by ,&#xA;    \ze                     &quot; Start matching here&#xA;    (&#xA;      \s*                   &quot; Any whitespace&#xA;      (                     &quot; ... um?&#xA;        [-^+|^\/%&amp;amp;]|&#xA;        \*|&#xA;        \&amp;lt;\&amp;lt;|&#xA;        \&amp;gt;\&amp;gt;|&#xA;        \&amp;amp;\^&#xA;      )&#xA;      ?\=[^=]               &quot; .. um?&#xA;    )&#xA;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above pseudo-example does not work, but is there any way to approach something like that in Vim?&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2018-04-08T15:05:00.670" Title="How can I make syntax highlighting files more readable and maintainable?" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15859" PostTypeId="1" AcceptedAnswerId="15861" CreationDate="2018-04-08T18:28:53.193" Score="14" ViewCount="5277" Body="&lt;p&gt;Every now and then I want to diff two random things (like a source-code vs some code I find online). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could obviously create two files locally and diff them, - but I was wondering if there was a way to open Vimdiff with two empty documents (not to be saved anywhere); where I could copy/paste the text in to diff them quickly and efficiently. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I just write &lt;code&gt;vimdiff&lt;/code&gt; then I just get an empty vim-editor. &lt;/p&gt;&#xA;" OwnerUserId="9194" LastActivityDate="2020-09-29T08:51:02.147" Title="Using Vimdiff to diff two things that are not local documents" Tags="|vimdiff|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15861" PostTypeId="2" ParentId="15859" CreationDate="2018-04-08T19:11:48.550" Score="25" Body="&lt;p&gt;You can diff two unwritten buffers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open vim (or open a new tab in you current vim instance)&lt;/li&gt;&#xA;&lt;li&gt;Put your current code in one buffer or open an existing file (&lt;code&gt;:e ./mySourceFile&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Split your screen with &lt;code&gt;:sp&lt;/code&gt; or &lt;kbd&gt;ctrl+w&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Open a new buffer (&lt;code&gt;:e&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Put the new code you want to diff in this new buffer&lt;/li&gt;&#xA;&lt;li&gt;And make a diff between the two buffers with &lt;code&gt;:windo diffthis&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;If you update one of the buffers update the diff with &lt;code&gt;:diffupdate&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;When you're done use &lt;code&gt;:diffoff!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/diff.txt.html#%3adiffthis&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :diffthis&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/diff.txt.html#%3adiffupdate&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :diffupdate&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/diff.txt.html#%3adiffoff&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :diffoff&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="20720" LastEditDate="2020-09-29T08:51:02.147" LastActivityDate="2020-09-29T08:51:02.147" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="15862" PostTypeId="1" AcceptedAnswerId="15863" CreationDate="2018-04-08T20:58:15.607" Score="0" ViewCount="46" Body="&lt;p&gt;I am sorry that my English was not good enough to clearly describe the task in the title.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a more descriptive attempt. Let us say I have the following text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\gls{tla}{TLA}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(As a side note, this is a partial excerpt from a &lt;code&gt;latex&lt;/code&gt; document. This command is useful for defining acronyms and generating glossary later on.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is the following: Let us say, I have copied  the line immediately below with &lt;code&gt;yyp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\gls{tla}{TLA}&#xA;\gls{tla}{TLA}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wish to change the second line to the following with a single edit operation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\gls{tla}{TLA}&#xA;\gls{tbd}{TBD}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i.e. I wish to perform a substitution for the case-sensitive and case-insensitive version in one go. I believe this is possible with some knowledgeable vim-fu, since it involves only a single semantic transformation (and the case conversion can be seen as a side-effect/add-on operation that remain fixed in sequence.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to achieve this? I am not opposed to the use of plugins to aid this, but standalone &amp;amp; elegant pure vim-only solutions (with some very-magic regex) will also be highly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="8408" LastEditorUserId="8408" LastEditDate="2018-04-08T21:22:44.530" LastActivityDate="2018-04-08T22:44:09.503" Title="How do I substitute two same words (of different cases) to another two words whilst retaining their original cases?" Tags="|command-line|substitute|letter-case|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15863" PostTypeId="2" ParentId="15862" CreationDate="2018-04-08T22:44:09.503" Score="3" Body="&lt;p&gt;I will assume you are starting with the following, i.e., after changing all the first arguments using any text editing method (e.g., visual block mode).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\gls{tbd}{TLA}&#xA;\gls{foo}{TLA}&#xA;\gls{bar}{TLA}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, all we need to do is make the second argument match.  A simple way to do this is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\\gls{\(\w\+\)}{\zs\w*\ze}/\=toupper(submatch(1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Breaking it down, we look for &lt;code&gt;\gls{word}{..}&lt;/code&gt; and capture the word into group &lt;code&gt;\1&lt;/code&gt;.  Targeting only the second argument using &lt;code&gt;\zs..\ze&lt;/code&gt;, we replace with a transformed version of the &lt;code&gt;word&lt;/code&gt; (&lt;code&gt;\=&lt;/code&gt; allows us to use an expression for replacement).&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-04-08T22:44:09.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15864" PostTypeId="1" CreationDate="2018-04-09T04:10:56.940" Score="2" ViewCount="246" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6Djn6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6Djn6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using nvi I have a file that I want to exit but everytime I use :q it just opens this thing and I can't exit out of it. Does anyone know what it is and how to get rid of it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: this is nvi and not vim, so hasn't been caused by accidentally typing &lt;code&gt;q:&lt;/code&gt; or by a mapping to &lt;code&gt;q:&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17096" LastEditorUserId="7878" LastEditDate="2018-04-09T14:45:05.517" LastActivityDate="2018-04-09T16:09:35.973" Title=":q will not let me exit vim" Tags="|buffers|quit|nvi|" AnswerCount="0" CommentCount="11" ClosedDate="2018-04-09T16:09:40.340" ContentLicense="CC BY-SA 3.0" />
  <row Id="15865" PostTypeId="2" ParentId="15819" CreationDate="2018-04-09T07:13:09.980" Score="0" Body="&lt;p&gt;This solution looks simple enough :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match Ignore /^\(.*&quot;Name&quot;:\)\@!.*$/ containedin=ALL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1782" LastEditorUserId="1782" LastEditDate="2018-04-10T00:31:06.673" LastActivityDate="2018-04-10T00:31:06.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15866" PostTypeId="2" ParentId="15850" CreationDate="2018-04-09T09:07:59.517" Score="3" Body="&lt;p&gt;The main issue with your code is that you can only have one &lt;code&gt;:match&lt;/code&gt; at a time, so your second call overwrites your first call. (See &lt;code&gt;:help :match&lt;/code&gt;&amp;#8202;&amp;mdash;&amp;#8202;a few paragraphs down.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim provides a &lt;code&gt;:2match&lt;/code&gt; command for the purpose of highlighting a second pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match TrailingWhitespaces /\s\s*$/&#xA;2match LeadingWhitespaces /^\s\s*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could use the &lt;code&gt;matchadd()&lt;/code&gt; function, or (ab)use the &lt;code&gt;:syntax&lt;/code&gt; highlighting to provide multiple regular expressions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match TrailingWhitespaces /\s\s*$/&#xA;syntax match LeadingWhitespaces /^\s\s*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could combine the two regular expressions with &lt;code&gt;\|&lt;/code&gt;: (See &lt;code&gt;:help /\|&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match TrailingAndLeadingWhitespaces /\s\s*$\|^\s\s*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A couple of other notes:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Even with two match commands, you don't really need two highlight &lt;em&gt;groups&lt;/em&gt;, since you're using the same colour for both matches.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Unless you're using a &lt;code&gt;very magic&lt;/code&gt; search (see &lt;code&gt;:help /\v&lt;/code&gt;) then &lt;code&gt;+&lt;/code&gt; does indeed match a literal plus character. You need to use &lt;code&gt;\+&lt;/code&gt; to match &quot;one or more of the preceding atom&quot;. You appear to have figured this out though, because you actually include a working regular expression in your question: &lt;code&gt;/\s\+$/&lt;/code&gt;, so I'm not sure why you didn't use this in your matches?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-04-09T09:07:59.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15867" PostTypeId="1" AcceptedAnswerId="15869" CreationDate="2018-04-09T10:11:05.127" Score="2" ViewCount="1025" Body="&lt;p&gt;I saw &lt;a href=&quot;https://www.youtube.com/watch?v=Q4I_Ft-VLAg&quot; rel=&quot;nofollow noreferrer&quot;&gt;this wonderful video&lt;/a&gt; and really love the config of it, which is why I wanted to replicate it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following line implements a double space keymapping which searches for the next &lt;code&gt;&amp;lt;++&amp;gt;&lt;/code&gt;, deletes it and moves the cursor there while not putting it into the internal vim buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt; &amp;lt;Esc&amp;gt;/&amp;lt;++&amp;gt;&amp;lt;Enter&amp;gt;&quot;_c4l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works perfectly, but there is one thing I would like to change: After pressing space once, it waits for approximately one second before actually moving the cursor in order to receive the second space. What I would like is that it does not wait for the second space but always runs the replacing &quot;command&quot; as soon as there are two spaces in a row. Is that possible somehow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alexander Schoch&lt;/p&gt;&#xA;" OwnerUserId="17099" LastActivityDate="2018-04-09T13:01:56.570" Title="Disable mapping delay" Tags="|vimrc|key-bindings|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15868" PostTypeId="1" CreationDate="2018-04-09T10:28:12.117" Score="3" ViewCount="72" Body="&lt;p&gt;Is there a way to make the automatic line wrapping of vim aware of the syntax of the file instead of just wrapping at the closest whitespace?&#xA;I am specifically interested in Python but I guess it would be more or less the same for most other languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's give an example to illustrate the problem. The following line is too long for my settings (max. 79 characters per line):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;some_variable_with_a_very_long_name = a_function_with_a_very_long_name(argument_with_long_name)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When typing, it automatically gets wrapped when reaching the limit.  However, it can only wrap at whitespaces, i.e. the result looks as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;some_variable_with_a_very_long_name =&#xA;a_function_with_a_very_long_name(argument_with_long_name)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does not look nice and for Python it is even invalid syntax.  What I would like to achieve is something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;some_variable_with_a_very_long_name = a_function_with_a_very_long_name(&#xA;    argument_with_long_name)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A similar issue is that it should not wrap inside a string.&lt;/p&gt;&#xA;" OwnerUserId="3261" LastEditorUserId="3261" LastEditDate="2018-04-12T07:10:37.647" LastActivityDate="2018-04-12T07:10:37.647" Title="Syntax-aware line wrapping" Tags="|filetype|wrapping|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15869" PostTypeId="2" ParentId="15867" CreationDate="2018-04-09T13:01:56.570" Score="0" Body="&lt;p&gt;I don't think there's a really good solution for this: Vim doesn't keep track of previous keystrokes, so if you want your initial press to insert a space character immediately, Vim will have no idea that it did so by the second press.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can tweak the length of time that Vim waits keypresses within mappings by changing the &lt;code&gt;'timeoutlen'&lt;/code&gt; option: if &lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt; is your &lt;em&gt;only&lt;/em&gt; insert mode mapping you could probably even set this to a pretty low value as part of an &lt;code&gt;InsertEnter&lt;/code&gt; autocommand, resetting it on &lt;code&gt;InsertLeave&lt;/code&gt;. (See &lt;code&gt;:help autocommand&lt;/code&gt; for details of these.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could set up an expression mapping for a single &lt;kbd&gt;Space&lt;/kbd&gt; that checks to see if it is the second press by inspecting the contents of the buffer around the cursor, or you could set up a mapping that inserts a space character when you press the space bar but waits for the next keypress to see if it is also a space character before it returns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to attempt the former, you'll want to read:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :map-expression&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getcurpos()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getline()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And for the latter, the following will be helpful:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help feedkeys()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getchar()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-04-09T13:01:56.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15870" PostTypeId="2" ParentId="15382" CreationDate="2018-04-09T13:09:58.837" Score="2" Body="&lt;p&gt;A basic version of this is actually in the reference manual as an example of how to use the &lt;code&gt;getchar()&lt;/code&gt; function:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This example redefines &amp;quot;f&amp;quot; to ignore case:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:nmap f :call FindChar()&amp;lt;CR&amp;gt;&#xA;:function FindChar()&#xA;:  let c = nr2char(getchar())&#xA;:  while col('.') &amp;lt; col('$') - 1&#xA;:    normal l&#xA;:    if getline('.')[col('.') - 1] ==? c&#xA;:      break&#xA;:    endif&#xA;:  endwhile&#xA;:endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;See &lt;code&gt;:help getchar()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that this doesn't handle counts or other, related commands (&lt;code&gt;t&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;T&lt;/code&gt;, &lt;code&gt;;&lt;/code&gt;, &lt;code&gt;,&lt;/code&gt;), although it could be adapted to do so.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-04-09T13:42:05.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15871" PostTypeId="2" ParentId="15382" CreationDate="2018-04-09T13:42:48.730" Score="1" Body="&lt;p&gt;Here is a one-liner solution built on top of &lt;code&gt;getchar())&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; f :silent! exe &quot;normal! &quot;. substitute(matchstr(getline('.')[col('.') :], '\v\c.{-}'.nr2char(getchar())), '.', &quot;l&quot;, &quot;g&quot;)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to extract all the characters from the current position till the character typed, and to convert them in as many &lt;code&gt;&amp;lt;right&amp;gt;&lt;/code&gt; as necessary. Note that as this is a one liner mapping definition, I cannot use &lt;code&gt;\&amp;lt;right&amp;gt;&lt;/code&gt; easily, hence the more obfuscated &lt;code&gt;l&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I don't use a loop as loops are slow and a PITA to debug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to support a &lt;em&gt;count&lt;/em&gt;, it could become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; f :&amp;lt;c-u&amp;gt;silent! exe &quot;normal! &quot;. substitute(matchstr(getline('.')[col('.') :], '\v\c(.{-}'.nr2char(getchar()).'){'.v:count1.'}'), '.', &quot;l&quot;, &quot;g&quot;)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What changes here is the use of &lt;code&gt;:&amp;lt;c-u&amp;gt;&lt;/code&gt; to clear the count, and the fact that I've surrounded the pattern &lt;code&gt;.{-}Z&lt;/code&gt; (by &lt;code&gt;Z&lt;/code&gt; I meant the result of &lt;code&gt;nr2char(getchar())&lt;/code&gt;) with &lt;code&gt;(...){v:count1}&lt;/code&gt; (lose syntax) to count exactly the number of &lt;em&gt;whatever Z&lt;/em&gt; I want.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-04-09T14:08:31.963" LastActivityDate="2018-04-09T14:08:31.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15872" PostTypeId="2" ParentId="68" CreationDate="2018-04-09T14:03:23.610" Score="7" Body="&lt;p&gt;By chance, I have written a plugin that does exactly this. It is called &lt;a href=&quot;https://github.com/sedm0784/vim-you-autocorrect&quot; rel=&quot;noreferrer&quot;&gt;Vim You, Autocorrect!&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After installing, type &lt;code&gt;:EnableAutocorrect&lt;/code&gt; to switch it on in any buffer, and you will soon see that &lt;a href=&quot;https://vi.stackexchange.com/a/312/343&quot;&gt;wchargin's scaremongering&lt;/a&gt; is quite unfounded.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-04-09T14:03:23.610" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15873" PostTypeId="1" AcceptedAnswerId="15894" CreationDate="2018-04-09T14:15:50.957" Score="5" ViewCount="2064" Body="&lt;p&gt;When splitting the editor window, the caret symbols appear in the status line of the current window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zCtC7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zCtC7.png&quot; alt=&quot;carets in status line&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This happens when &lt;code&gt;StatusLine&lt;/code&gt; and &lt;code&gt;StatusLineNC&lt;/code&gt; have the same highlighting. For example, when&#xA;&lt;code&gt;cterm=none ctermfg=white ctermbg=black&lt;/code&gt; is set for both of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to prevent the symbols to appear while preserving the same highlighting for both status lines?&lt;/p&gt;&#xA;" OwnerUserId="12857" LastEditorUserId="12857" LastEditDate="2018-04-12T13:29:51.913" LastActivityDate="2021-10-27T00:28:03.473" Title="Carets in status line" Tags="|split|statusline|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15875" PostTypeId="1" AcceptedAnswerId="15876" CreationDate="2018-04-09T17:58:35.820" Score="10" ViewCount="711" Body="&lt;p&gt;I want to test in a script if this version of vim supports the &quot;CmdlineEnter&quot; event. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a relatively new addition in vim and neovim doesn't support it in it's current 0.2.2 version (although there is a merged PR that adds that event)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I test if this event is supported in the current version of vim? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  has(CmdlineEnter)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;raises an error.&lt;/p&gt;&#xA;" OwnerUserId="14981" LastEditorUserId="1238" LastEditDate="2019-12-28T18:49:21.990" LastActivityDate="2019-12-28T18:49:21.990" Title="How to test if certain event is supported?" Tags="|vimscript|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15876" PostTypeId="2" ParentId="15875" CreationDate="2018-04-09T18:24:29.927" Score="15" Body="&lt;p&gt;There are at least three ways to tell if a particular autocmd is supported:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;exists('##CmdlineEnter')&lt;/code&gt;. This should be exactly what you need.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Check for the patch it was introduced in.  For example, &lt;code&gt;CmdlineEnter&lt;/code&gt; was added in patch &lt;a href=&quot;https://github.com/vim/vim/commit/fafcf0dd59fd9c4ef743bb333ae40d1d322b6079&quot; rel=&quot;noreferrer&quot;&gt;8.0.1206&lt;/a&gt;.  I determined this by looking at recent vim commits and git blame on the help files.  Thus you can use &lt;code&gt;has('patch-8.0.1206')&lt;/code&gt;.  Although Neovim does not follow vim development exactly, when features are added from &quot;upstream,&quot; the vim patch numbers are included too.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a &lt;code&gt;try|catch|endtry&lt;/code&gt; block around &lt;code&gt;autocmd&lt;/code&gt;.  E.g.,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;try&#xA;     silent autocmd CmdlineEnter&#xA;catch /^Vim\%((\a\+)\)\=:E216/&#xA;     &quot; autocmd is not supported&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When installing an autocmd handler you could simply use &lt;code&gt;silent! autocmd CmdlineEnter * ...&lt;/code&gt; to suppress all errors, if your code doesn't actually need to know whether the command is supported.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can check if an autocmd is &lt;em&gt;subscribed to&lt;/em&gt; using &lt;code&gt;exists('#CmdlineEnter')&lt;/code&gt;.  This will return 0 if the autocmd exists but has no listeners.  Sometimes this is all the info you need.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-04-09T19:00:46.043" LastActivityDate="2018-04-09T19:00:46.043" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="15877" PostTypeId="1" CreationDate="2018-04-09T18:41:53.057" Score="7" ViewCount="730" Body="&lt;p&gt;gVim seems to have problems displaying text in Tamil (and possibly other Indic languages), even when the font supports it. For eg., here's some text in Emacs and the same text in gVim (both under Windows):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gq1X1.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gq1X1.png&quot; alt=&quot;In Emacs&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/M6GJX.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/M6GJX.png&quot; alt=&quot;In Vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both use the exact same font here (Dejavu Sans Mono, 13). But within Vim, the characters are all overlapping with each other to the point of unreadability, whereas emacs seems to have no problem displaying it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make the problem clear, here's a single word from the text, first in emacs: &lt;a href=&quot;https://i.stack.imgur.com/lTooy.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lTooy.png&quot; alt=&quot;clear text in emacs&quot;&gt;&lt;/a&gt;, and then in Vim &lt;a href=&quot;https://i.stack.imgur.com/LgEoE.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LgEoE.png&quot; alt=&quot;unreadable in Vim&quot;&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried many other Unicode monospace fonts available, and the result is the same: other editors display the Tamil glyphs without an issue, while Vim's are the same overlapping mess every time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this type of rendering problems a known issue, and are there any fixes or workaround available? I'd prefer to continue editing in Vim for Tamil texts too, if it is at all possible. &lt;/p&gt;&#xA;" OwnerUserId="2374" LastEditorUserId="2374" LastEditDate="2018-04-09T18:50:57.727" LastActivityDate="2018-04-09T18:50:57.727" Title="Unreadable display of Tamil characters in Vim" Tags="|unicode|font|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="15878" PostTypeId="1" CreationDate="2018-04-10T02:50:56.403" Score="1" ViewCount="30" Body="&lt;p&gt;I am using &lt;code&gt;neovim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When editing a &lt;code&gt;.tex&lt;/code&gt; file I don't want to wrap the lines within certain environments like &lt;code&gt;equation&lt;/code&gt; or &lt;code&gt;align&lt;/code&gt; and some others.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{equation}&#xA;    % very long line I don't want to wrap because \left( \frac{}{} \right) is very long and wrapping makes it harder to read&#xA;\end{equation}&#xA;And I want these lines to be wrapped because its text with some possible&#xA;inline maths. I am ok with inline math being wrapped for example $ax^2+b&#xA;x+c=0$  doesn't bother me.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I wan't rest of the documents to be wrapped as usual. Is there any way I can do this?&lt;/p&gt;&#xA;" OwnerUserId="7368" LastEditorUserId="343" LastEditDate="2018-04-10T09:38:10.200" LastActivityDate="2018-04-10T09:38:10.200" Title="Do not wrap certain environments" Tags="|filetype-tex|wrapping|" AnswerCount="0" CommentCount="1" ClosedDate="2018-04-16T09:22:26.793" ContentLicense="CC BY-SA 3.0" />
  <row Id="15879" PostTypeId="1" CreationDate="2018-04-10T04:58:58.617" Score="0" ViewCount="58" Body="&lt;p&gt;I know I can move to the last line of the file using &lt;code&gt;G&lt;/code&gt; but that will move cursor to the first column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When in visual block mode I would like to extend the selection to the last line without moving the cursor&lt;/p&gt;&#xA;" OwnerUserId="11633" LastActivityDate="2018-04-10T05:54:10.940" Title="Move to last line leave cursor in place" Tags="|visual-block|" AnswerCount="1" CommentCount="1" ClosedDate="2018-04-10T07:45:01.437" ContentLicense="CC BY-SA 3.0" />
  <row Id="15880" PostTypeId="2" ParentId="15879" CreationDate="2018-04-10T05:54:10.940" Score="0" Body="&lt;p&gt;This will keep your cursor column position unchanged:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nostartofline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1782" LastActivityDate="2018-04-10T05:54:10.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15881" PostTypeId="1" AcceptedAnswerId="15884" CreationDate="2018-04-10T08:13:28.977" Score="4" ViewCount="473" Body="&lt;p&gt;Consider editing the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo = long_function_name(var_one, var_two, var_three, var_four)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the &lt;code&gt;textwidth&lt;/code&gt; 'column' occurs just after &lt;code&gt;var_two&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to be able to press &lt;code&gt;gqq&lt;/code&gt; on the line and it get formatted to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo = long_function_name(var_one, var_two, &#xA;                         var_three, var_four)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently it does this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo = long_function_name(var_one, var_two, &#xA;    var_three, var_four)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can this be done?&lt;/p&gt;&#xA;" OwnerUserId="3155" LastActivityDate="2018-04-10T14:37:42.043" Title="Using `gq` to correctly wrap function arguments" Tags="|formatting|wrapping|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15883" PostTypeId="1" CreationDate="2018-04-10T12:08:11.040" Score="2" ViewCount="101" Body="&lt;p&gt;MacVim's documentation specifically (&lt;a href=&quot;https://github.com/macvim-dev/macvim/blob/54928cd17323e2851f28e41eb7b82da6322d65f8/runtime/doc/gui_mac.txt#L243&quot; rel=&quot;nofollow noreferrer&quot;&gt;if obliquely&lt;/a&gt;) mentions &lt;a href=&quot;https://en.wikipedia.org/wiki/Font_substitution&quot; rel=&quot;nofollow noreferrer&quot;&gt;font substitution&lt;/a&gt;, and &lt;a href=&quot;https://github.com/vim/vim/issues/1438#issuecomment-277143647&quot; rel=&quot;nofollow noreferrer&quot;&gt;I've found evidence online&lt;/a&gt; that GTK2 gVim does it too.&lt;/p&gt;&#xA;&lt;p&gt;But does Windows gvim?&lt;/p&gt;&#xA;&lt;p&gt;N.B. I'm already aware of the &lt;code&gt;'guifontwide'&lt;/code&gt; setting.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2022-07-25T21:36:49.227" LastActivityDate="2022-07-25T21:36:49.227" Title="Does Windows GUI Vim perform font substitution for glyphs unavailable in current font?" Tags="|gvim|microsoft-windows|font|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15884" PostTypeId="2" ParentId="15881" CreationDate="2018-04-10T12:20:40.390" Score="3" Body="&lt;p&gt;Assuming you are editing a file recognized by Vim as source code and therefore Vim's more sophisticated indenting is enabled&lt;sup&gt;1&lt;/sup&gt; (check with &lt;code&gt;:set cindent?&lt;/code&gt;) you can just do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cinoptions=(0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;:set textwidth=50&lt;/code&gt; I get this formatting of your example line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo = long_function_name(var_one, var_two,&#xA;                         var_three, var_four)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;cinoptions&lt;/code&gt; allows you to tune how Vim indents various code constructs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;(N&lt;/code&gt; option is described, in part, in &lt;code&gt;:h cino-(&lt;/code&gt; thusly...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(N    ... When N is 0 or the unclosed parentheses&#xA;      is the first non-white character in its line, line up with the&#xA;      next non-white character after the unclosed parentheses.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But for this particular case the help for &lt;code&gt;WN&lt;/code&gt; (&lt;code&gt;:h cino-W&lt;/code&gt;) actually has a (counter) example that is more in line with your case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WN    When in unclosed parentheses and N is non-zero and either&#xA;      using &quot;(0&quot; or &quot;u0&quot; ...&#xA;&#xA;    cino=(0                         cino=(0,W4&#xA;      a_long_line(                    a_long_line(&#xA;                  argument,               argument,&#xA;                  argument);              argument);&#xA;      a_short_line(argument,          a_short_line(argument,&#xA;                   argument);                      argument);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We want it to look like the example on the left so &lt;code&gt;cinoptions=(0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at &lt;code&gt;:h cinoptions-values&lt;/code&gt; for heaps of other ways to tune the indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; &lt;sub&gt;This doesn't apply to all languages. See the comments/chat for discussion about Python files having &lt;code&gt;nocindent&lt;/code&gt; by default. &lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-04-10T14:37:42.043" LastActivityDate="2018-04-10T14:37:42.043" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="15885" PostTypeId="1" AcceptedAnswerId="15888" CreationDate="2018-04-10T12:23:42.443" Score="1" ViewCount="152" Body="&lt;p&gt;So I made this mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;%p$?/&amp;lt;CR&amp;gt;d$V&quot;uy:cd &amp;lt;C-r&amp;gt;u&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is the crux of the mapping but it leaves artifacts in the current file, that is part of what I want to avoid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My attempt at creating a function is more or less a direct translation thus far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that I really don't know vimscript very well.&#xA;Any help is appreciated, even some good documentation, or a pointer to relevant help files in vimhelp.&lt;/p&gt;&#xA;" OwnerUserId="17119" LastEditorUserId="5298" LastEditDate="2018-04-10T21:17:16.327" LastActivityDate="2018-04-10T21:17:16.327" Title="How to transform this mapping into a function?" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15886" PostTypeId="1" AcceptedAnswerId="15887" CreationDate="2018-04-10T13:00:45.537" Score="0" ViewCount="79" Body="&lt;p&gt;I have this issue with my vim setup, where some words get highlighted unnecessarily. The image below shows an example. The words &lt;em&gt;not&lt;/em&gt; and &lt;em&gt;to&lt;/em&gt; where highlighted but there's no reason for them to be. How do I stop this from happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, notice this happens with every color scheme I have installed and I'm using the &lt;code&gt;polyglot&lt;/code&gt; plugin to provide with syntax highlighting rules for each language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sBokb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sBokb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14568" LastEditorUserId="51" LastEditDate="2018-04-10T13:03:01.773" LastActivityDate="2018-04-10T13:13:39.310" Title="How do I stop vim from higlighting uncessary words in PHP" Tags="|syntax-highlighting|filetype-php|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15887" PostTypeId="2" ParentId="15886" CreationDate="2018-04-10T13:13:39.310" Score="4" Body="&lt;p&gt;It looks like it's highlighting SQL keywords. There is a setting in the PHP syntax highlighter to do that: &lt;code&gt;php_sql_query&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is off by default, so check your vimrc if you added that, or try adding &lt;code&gt;let g:php_sql_query = 1&lt;/code&gt; to your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;code&gt;:help ft-php-syntax&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2018-04-10T13:13:39.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15888" PostTypeId="2" ParentId="15885" CreationDate="2018-04-10T13:28:10.653" Score="3" Body="&lt;p&gt;If I understand your mapping properly it is used to get the directory containing the current buffer and then &lt;code&gt;cd&lt;/code&gt; to this directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You say that your mapping leaves characters in your current buffer and that is why you want to use a function. I think that using a function here is not necessary you just need to write a better mapping. By &quot;better mapping&quot; I mean a mapping which will use built-in features and will not have to modify your buffer just to change the working directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example something like this would do the job:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;yourkey&amp;gt; :execute &quot;cd &quot; . expand('%:h')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's break the executed command down:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;cd &quot; . expand('%:h')&#xA;&#xA;execute                         will take a string and execute it as a command&#xA;        &quot;cd &quot;                   is the beginning of the command you want to execute&#xA;              .                 allows to concatenate two strings&#xA;                expand('   ')   will be used to tranform a file name as we want&#xA;                        %       is the current file name&#xA;                         :h     tells to expand() to return only the directory of the file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can try to use directly in the command line &lt;code&gt;:echo expand('%:h')&lt;/code&gt; to understand better what's happening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some help topics you might want to read:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :execute&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expand%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h expand()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt; As @LuHermitte pointed out in the comments, while the previous mappings works using &lt;code&gt;execute&lt;/code&gt; and &lt;code&gt;expand()&lt;/code&gt; is clearly overkill since the command line can substitute &lt;code&gt;%:h&lt;/code&gt; on its own. So the mapping should be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;yourkey&amp;gt; :cd %:h&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Use &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; to avoid echoing the mapping in the command line)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-04-10T13:49:03.533" LastActivityDate="2018-04-10T13:49:03.533" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15889" PostTypeId="1" CreationDate="2018-04-10T18:03:02.127" Score="1" ViewCount="389" Body="&lt;p&gt;I have &lt;code&gt;syntax off&lt;/code&gt; at the end of my nvim.init file, but no matter how hard I try there is always diffsplit coloring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to disable it because I guess (Neo)vim is very slow with syntax highlighting enabled of files of the size I would like to diff.&lt;/p&gt;&#xA;" OwnerUserId="11633" LastEditorUserId="11633" LastEditDate="2018-04-11T19:42:24.290" LastActivityDate="2018-04-11T19:42:24.290" Title="Disable vimdiff syntax highlighting" Tags="|syntax-highlighting|neovim|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15890" PostTypeId="2" ParentId="15825" CreationDate="2018-04-10T21:01:28.900" Score="1" Body="&lt;p&gt;It seems that if ruby path is not set correctly during vim compilation, it slows down vim when editing ruby files, check &lt;a href=&quot;https://stackoverflow.com/a/12141652/5586914&quot;&gt;this post&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, using old regex engine (&lt;code&gt;set re=1&lt;/code&gt;) rather than the new one speed things up apparently.&lt;/p&gt;&#xA;" OwnerUserId="17125" LastEditorUserId="17125" LastEditDate="2018-04-10T21:04:29.770" LastActivityDate="2018-04-10T21:04:29.770" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15891" PostTypeId="1" CreationDate="2018-04-11T03:36:42.513" Score="2" ViewCount="64" Body="&lt;p&gt;I have a really large file with many paths in it. I don't want it to participate in any of the completion mechanisms. Is there a way to mark a particular buffer as &quot;not a candidate for keyword completion&quot; or, equivalently, to close it as soon as I leave the buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some motivation for doing it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a file called &lt;code&gt;~/FILES&lt;/code&gt; that consists of two columns like this, with the name of a file in the left column and the full path on the right. It's just a manually generated index with a very simple format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an excerpt of the file showing part of the Linux kernel source.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ABCDBCDA.c                              ~/ws/opt/linux/tools/lib/lockdep/tests/ABCDBCDA.c&#xA;ABCDBDDA.c                              ~/ws/opt/linux/tools/lib/lockdep/tests/ABCDBDDA.c&#xA;ABI.txt                                 ~/ws/opt/linux/Documentation/devicetree/bindings/ABI.txt&#xA;ABI.txt                                 ~/ws/opt/linux/Documentation/mn10300/ABI.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This file is very long and really slows down keyword completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been using this binding to delete the buffer when following paths using &lt;code&gt;gf&lt;/code&gt;, the most common way to exit the &lt;code&gt;~/FILES&lt;/code&gt; buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; gf gf:silent! bdelete ~/FILES&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it's really modifying the behavior in the wrong place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way of marking the buffer?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2018-05-11T08:56:13.830" Title="Close particular buffer immediately upon leaving it" Tags="|autocompletion|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15893" PostTypeId="2" ParentId="15891" CreationDate="2018-04-11T08:53:14.003" Score="1" Body="&lt;p&gt;If I understand what you're asking for, you could use autocmd to close ~/FILES when you leave this buffer. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufLeave,BufWinLeave ~/FILES :bd ~/FILES&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, everytime you &quot;leave&quot; this buffer (using :e or :n etc.) it will close ~/FILES.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="16636" LastActivityDate="2018-04-11T08:53:14.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15894" PostTypeId="2" ParentId="15873" CreationDate="2018-04-11T13:52:11.500" Score="7" Body="&lt;p&gt;This is the standard behaviour of Vim. If &lt;code&gt;StatusLine&lt;/code&gt; and &lt;code&gt;StatusLineNC&lt;/code&gt; have the same highlighting, the program will use the caret character (&lt;code&gt;^&lt;/code&gt;) in the status line of the current window (in order to highlight it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This behaviour cannot be changed. The only thing that can be done is to change the caret to something else by the use of the &lt;code&gt;fillchars&lt;/code&gt; option. Like this: &lt;code&gt;set filchars=stl:+,stlnc:-&lt;/code&gt;. That way the current window and non-current windows will be marked by pluses and minuses in their status lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, setting spaces as the values of &lt;code&gt;stl&lt;/code&gt; and &lt;code&gt;stlnc&lt;/code&gt; doesn't affect the situation in the given circumstances. If Vim sees non-printable characters in the &lt;code&gt;fillchars&lt;/code&gt; values and there is no other way to differentiate windows, it adds carets to the status line of the current window automatically (and the equal signs to non-current windows if &lt;code&gt;set highlight+=Sn&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Despite what was said before, there actually &lt;em&gt;is&lt;/em&gt; a trick, which allows to have the same highlighting in status lines without carets to appear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is that Vim considers that current and non-current status line highlights are the same if both terminal &lt;em&gt;and&lt;/em&gt; GUI colors match. When working in a terminal, you don't care what GUI colors are. So, they can be freely changed without affecting the editor look.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight StatusLine   cterm=none ctermfg=white ctermbg=black guibg=red&#xA;highlight StatusLineNC cterm=none ctermfg=white ctermbg=black guibg=green&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way Vim won't consider that status lines are the same and won't add any indication to the status line of the current window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strangely, this trick doesn't work for the GUI version of the editor. When setting the same GUI foreground and background colors for both status lines along with different terminal background colors, carets still appear.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Relevant information&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help hl-StatusLineNC&#xA;---------------------&#xA;&#xA;Note: if this is equal to &quot;StatusLine&quot; Vim will use &quot;^^^&quot; in the status line&#xA;of the current window.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'fillchars'&#xA;-----------------&#xA;&#xA;Characters to fill the statuslines and vertical separators. It is a comma&#xA;separated list of items:&#xA;&#xA;  item     default     Used for&#xA;  stl:c    ' ' or '^'  statusline of the current window&#xA;  stlnc:c  ' ' or '='  statusline of the non-current windows&#xA;  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help status-line&#xA;-----------------&#xA;&#xA;Normally, inversion is used to display the status line. This can be changed&#xA;with the 's' character in the 'highlight' option. For example, &quot;sb&quot; sets it&#xA;to bold characters.&#xA;&#xA;If no highlighting is used for the status line (&quot;sn&quot;), the '^' character is&#xA;used for the current window, and '=' for other windows.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'highlight'&#xA;-----------------&#xA;&#xA;This option can be used to set highlighting mode for various occasions. It&#xA;is a comma separated list of character pairs. The first character in a pair&#xA;gives the occasion, the second the mode to use for that occasion.&#xA;&#xA;The occasions are:&#xA;&#xA;  s  status line of current window&#xA;  S  status lines of not-current windows&#xA;  ...&#xA;&#xA;The display modes are:&#xA;&#xA;  n  no highlighting&#xA;  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Links&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/7223309/vim-statusline-uses-carret-symbols-for-spaces-how-to-switch-to-spaces&quot;&gt;https://stackoverflow.com/questions/7223309/vim-statusline-uses-carret-symbols-for-spaces-how-to-switch-to-spaces&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/arcticicestudio/nord-vim/issues/37&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/arcticicestudio/nord-vim/issues/37&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12857" LastEditorUserId="12857" LastEditDate="2018-07-30T09:21:45.063" LastActivityDate="2018-07-30T09:21:45.063" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15897" PostTypeId="1" CreationDate="2018-04-12T09:18:10.797" Score="0" ViewCount="181" Body="&lt;p&gt;I have a strange trouble with vim (8.0.95). My format options are &lt;code&gt;fo=cq&lt;/code&gt; and &lt;code&gt;nowrap&lt;/code&gt;. When I have a long line, which does not fit my terminal window, the view of the file does not include the first column. Lets say the line has 300 characters, but my terminal window only shows 100. Then, if my cursor is on character 300, I can only see characters 201-300.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, when pressing &lt;code&gt;0&lt;/code&gt;, the cursor jumps to character 201, and the horizontal scroll does not change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;code&gt;Shift+i&lt;/code&gt;, the cursor moves to character 1 and switches to insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same happens for &lt;code&gt;$&lt;/code&gt; and &lt;code&gt;Shift+a&lt;/code&gt;. But it does not happen for a vanilla config. Any idea which plugin/setting might affect this behavior? This happens irrespective of the &lt;code&gt;filetype&lt;/code&gt;. And whether I'm in Gnome terminal or on the console.&lt;/p&gt;&#xA;" OwnerUserId="17141" LastActivityDate="2018-05-12T09:59:27.570" Title="`0` only moving to first &quot;visible&quot; column" Tags="|vimrc|cursor-movement|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15898" PostTypeId="2" ParentId="15897" CreationDate="2018-04-12T09:27:05.563" Score="1" Body="&lt;p&gt;I found the problem. I had some settings for usage of &lt;code&gt;:set wrap lbr&lt;/code&gt; with &lt;code&gt;vimtex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap  &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; k gk&#xA;noremap  &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; j gj&#xA;noremap  &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; 0 g0&#xA;noremap  &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; $ g$&#xA;onoremap &amp;lt;silent&amp;gt; j gj&#xA;onoremap &amp;lt;silent&amp;gt; k gk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I will outsource them to an ftplugin file.&lt;/p&gt;&#xA;" OwnerUserId="17141" LastActivityDate="2018-04-12T09:27:05.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15899" PostTypeId="1" AcceptedAnswerId="17157" CreationDate="2018-04-12T09:49:09.143" Score="0" ViewCount="804" Body="&lt;p&gt;After moving from &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim-plug&lt;/a&gt; to &lt;a href=&quot;https://github.com/k-takata/minpac&quot; rel=&quot;nofollow noreferrer&quot;&gt;Minpac&lt;/a&gt;, the only missing functionality has been to be able to load local paths.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually I managed to make it work (details below), but I've got the feeling that there might be some flaws in the workflow and that I'm missing something  in relation to the new 'packages' and 'jobs' features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With Vim-plug that would be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&#xA;Plug '/usr/local/opt/localplugin'&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have Minpac installed and configured both in Vim and Neovim by following its README and the Vimcasts' episode &lt;a href=&quot;http://vimcasts.org/episodes/minpac/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Meet Minpac&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By following the discussion in &lt;a href=&quot;https://github.com/k-takata/minpac/issues/29&quot; rel=&quot;nofollow noreferrer&quot;&gt;this issue&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't think it's useful., because minpac doesn't manage runtime path.&#xA;  Isn't it enough to modify the runtime path directly?&#xA;  E.g.:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;set rtp+=/usr/local/opt/fzf&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Or, if you put a plugin under the package directory, you don't need to modify rtp. Vim will do it automatically.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've managed to make it kind of work (in Neovim) by putting a sample plugin under the package directory (under &lt;code&gt;*/start/&lt;/code&gt;).&#xA;It is possible to see the changes by either restarting Neovim or by &lt;code&gt;:source path/to/plugin/localplugin.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I don't understand the difference between the method above (by placing the plugin inside the package directory) and by modifying the &lt;code&gt;rtp&lt;/code&gt;.&#xA;Despite of that, to restart or to use &lt;code&gt;:source&lt;/code&gt; doesn't feel like the proper way to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone expand on how to properly (re)load local plugins with the use of Minpac and &lt;code&gt;packages&lt;/code&gt; and &lt;code&gt;jobs&lt;/code&gt; features?&lt;/p&gt;&#xA;" OwnerUserId="10493" LastEditorUserId="51" LastEditDate="2018-08-22T16:57:27.337" LastActivityDate="2018-08-23T09:23:25.603" Title="How to load a &quot;local&quot; plugin with Minpac properly?" Tags="|neovim|plugin-system|packages|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15900" PostTypeId="1" AcceptedAnswerId="15902" CreationDate="2018-04-12T10:27:04.590" Score="2" ViewCount="697" Body="&lt;p&gt;In vim's command-line, after typing the first few characters, when I press the &lt;code&gt;tab&lt;/code&gt; key, the wildmenu appears. However, irritatingly, it requires me one additional press of the &lt;code&gt;tab&lt;/code&gt; key to select the first entry. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the time, it is the first entry I am looking for anyway. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure vim to automatically select the first entry whenever the wildmenu is activated? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I just want to select the first entry, i.e. highlight it and ready to be activated. I still wish to retain the standard behaviour of manually activating the selection with &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8408" LastEditorUserId="8408" LastEditDate="2018-04-12T11:20:24.130" LastActivityDate="2018-04-12T11:33:22.770" Title="How to automatically select the first entry of the wildmenu without having to tab?" Tags="|vimrc|command-line|wildmenu|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15901" PostTypeId="2" ParentId="15764" CreationDate="2018-04-12T11:29:56.940" Score="1" Body="&lt;p&gt;For what it is worth: &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#gq&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h gq&lt;/code&gt;&lt;/a&gt; explains that you have 3 ways to format your code with &lt;code&gt;gq&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;1. If 'formatexpr' is not empty the expression is&#xA;   evaluated. This can differ for each buffer.&#xA;2. If 'formatprg' is not empty an external program&#xA;   is used.&#xA;3. Otherwise formatting is done internally.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Let's begin with the third option: the internal formatting is controlled by &lt;code&gt;'formatoptions'&lt;/code&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#fo-table&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h fo-table&lt;/code&gt;&lt;/a&gt; shows that we can't achieve what you want to do with built-in options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you have two choices: either find an external program which will format your code as you want or write a function used by &lt;code&gt;formatexpr&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About &lt;code&gt;formatexpr&lt;/code&gt; the help (&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27formatexpr%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'formatexpr'&lt;/code&gt;&lt;/a&gt;) doesn't tell us a lot about how to write the function. You can have a look at &lt;a href=&quot;http://vim.1045645.n5.nabble.com/How-to-write-formatexpr-script-td1197037.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this Vim dev&lt;/a&gt; mailing list post and &lt;a href=&quot;https://vi.stackexchange.com/a/2848/1841&quot;&gt;this answer&lt;/a&gt; to get some very basic examples. I think writing such a function might be a lot of trouble since you would need to re-implement the current behavior of &lt;code&gt;gq&lt;/code&gt; &lt;em&gt;and&lt;/em&gt; add the quotes formatting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I would say that your best bet is to find an external tool to do the formatting and set your &lt;code&gt;formatprg&lt;/code&gt; properly. (Remember to set it in an ftplugin so that it only affects javascript code.)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-04-12T11:29:56.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15902" PostTypeId="2" ParentId="15900" CreationDate="2018-04-12T11:33:22.770" Score="4" Body="&lt;p&gt;You probably want to set &lt;code&gt;wildmode&lt;/code&gt; accordingly to your needs, &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27wildmode%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'wildmode'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;Completion mode that is used for the character specified with&#xA;'wildchar'.  It is a comma separated list of up to four parts.  Each&#xA;part specifies what to do for each consecutive use of 'wildchar'.  The&#xA;first part specifies the behavior for the first use of 'wildchar',&#xA;The second part for the second use, etc.&#xA;These are the possible values for each part:&#xA;&#xA;&quot;&quot;                Complete only the first match.&#xA;&#xA;&quot;full&quot;            Complete the next full match.  After the last match,&#xA;                  the original string is used and then the first match&#xA;                  again.&#xA;&#xA;&quot;longest&quot;         Complete till longest common string.  If this doesn't&#xA;                  result in a longer string, use the next part.&#xA;&#xA;&quot;longest:full&quot;    Like &quot;longest&quot;, but also start 'wildmenu' if it is&#xA;                  enabled.&#xA;&#xA;&quot;list&quot;            When more than one match, list all matches.&#xA;&#xA;&quot;list:full&quot;       When more than one match, list all matches and&#xA;                  complete first match.&#xA;&#xA;&quot;list:longest&quot;    When more than one match, list all matches and&#xA;                  complete till longest common string.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For example, I would recommend you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmode=longest,list:full&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-04-12T11:33:22.770" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15903" PostTypeId="2" ParentId="4695" CreationDate="2018-04-12T12:19:23.797" Score="1" Body="&lt;h3&gt;vmap &lt;code&gt;++&lt;/code&gt; from plugin &lt;code&gt;vmath&lt;/code&gt; by Damian Conway&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Install plugin from &lt;a href=&quot;https://github.com/thoughtstream/Damian-Conway-s-Vim-Setup/blob/master/plugin/vmath.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt; (only 178 sloc)&#xA;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ wget https://raw.githubusercontent.com/thoughtstream/Damian-Conway-s-Vim-Setup/master/plugin/vmath.vim -P ~/.vim/pack/manual/start/damians-tools/plugin&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add mapping to your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt;  ++  VMATH_YankAndAnalyse()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I would suggest to use something else, e.g. &lt;code&gt;gA&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move to the third colum &lt;code&gt;2f|&lt;/code&gt; and select the column in visual-block mode &lt;code&gt;&amp;lt;C-V&amp;gt;G$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;++&lt;/code&gt; (or your chosen mapping)&lt;/li&gt;&#xA;&lt;li&gt;Results are shown and stored in registers (sum in &lt;code&gt;s&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Insert sum from register &lt;code&gt;s&lt;/code&gt;, e.g. with &lt;code&gt;&quot;sp&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For a presentation of this plugin see the YouTube video &lt;a href=&quot;https://www.youtube.com/watch?v=aHm36-na4-4#t=29m00s&quot; rel=&quot;nofollow noreferrer&quot;&gt;Damian Conway, &quot;More Instantly Better Vim&quot; - OSCON 2013&lt;/a&gt; (starting at minute 29).&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-04-12T13:31:40.883" LastActivityDate="2018-04-12T13:31:40.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15904" PostTypeId="2" ParentId="2116" CreationDate="2018-04-12T12:33:33.380" Score="6" Body="&lt;p&gt;&lt;code&gt;cpo&lt;/code&gt; means &lt;code&gt;compatible option&lt;/code&gt; and &lt;code&gt;&amp;amp;&lt;/code&gt; means option variable, so &lt;code&gt;&amp;amp;cpo&lt;/code&gt; represents the value of compatible option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set cpo&amp;amp;vim&lt;/code&gt; is a special syntax which tells vim to reset the option of &lt;code&gt;cpo&lt;/code&gt; which defaults to &lt;code&gt;aABceFs&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the doc in &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#cpo&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h cpo&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17143" LastEditorUserId="1841" LastEditDate="2018-04-12T12:59:19.200" LastActivityDate="2018-04-12T12:59:19.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15905" PostTypeId="1" AcceptedAnswerId="15912" CreationDate="2018-04-12T13:03:29.910" Score="8" ViewCount="502" Body="&lt;p&gt;If you define a function with the &lt;code&gt;abort&lt;/code&gt; argument, your function will abort as soon as an error is detected. Is there any case where this is &lt;em&gt;not&lt;/em&gt; what you'd want?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if your function needs to perform some final cleanup, I'd expect using &lt;code&gt;finally&lt;/code&gt; in combination with &lt;code&gt;abort&lt;/code&gt; would be the best practice, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Foo() abort&#xA;  call s:make_mess()&#xA;  try&#xA;    call s:might_fail()&#xA;  finally&#xA;    call s:cleanup()&#xA;  endtry&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any case where you'd actually want &lt;em&gt;non&lt;/em&gt;-abort behavior?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2018-04-13T12:01:40.727" Title="When should a function *not* be defined with &quot;abort&quot;" Tags="|functions|error|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15906" PostTypeId="2" ParentId="4695" CreationDate="2018-04-12T13:20:11.600" Score="5" Body="&lt;p&gt;If the columns are properly aligned, this can be done with a simple oneliner.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;first select the column in &lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#visual%2dblock&quot; rel=&quot;noreferrer&quot;&gt;block-wise visual mode&lt;/a&gt; as other answers have demonstrate -&gt; &lt;code&gt;CTRL-V&lt;/code&gt; + move the cursor&lt;/li&gt;&#xA;&lt;li&gt;yank the selection with &lt;code&gt;y&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;type: &lt;code&gt;:echo eval(join(split(@&quot;, '\_s\+'), '+'))&lt;/code&gt; which splits the text yanked on spaces and new lines, rejoin the element with &lt;code&gt;+&lt;/code&gt; character, and evaluate the string.&lt;/li&gt;&#xA;&lt;li&gt;another way to proceed: replace newlines with &lt;code&gt;+&lt;/code&gt; and evaluate: &lt;code&gt;:echo eval(substitute(@&quot;, &quot;\n&quot;, '+', 'g'))&lt;/code&gt; -- &lt;code&gt;eval()&lt;/code&gt; is the closest thing to &lt;code&gt;reduce&lt;/code&gt; we have.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If not, you'll have to use other tricks to count fields. For instance, &lt;code&gt;split(getline('.'), &quot;[ \t|]\\+&quot;)&lt;/code&gt; can be used to split the columns from a row in your array. From there, it becomes as simple as:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;select your lines in visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:echo eval(join(map(getline(&quot;'&amp;lt;&quot;, &quot;'&amp;gt;&quot;), { -&amp;gt; split(v:val, &quot;[ \t|]\\+&quot;)[2] }), '+'))&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In order to get rid of the magical values (field number - 1, and &lt;code&gt;+&lt;/code&gt;), it can become a command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -range=% -nargs=+ OnField &#xA;    \ echo { field, what -&amp;gt; eval(join(map(getline(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;), { -&amp;gt; split(v:val, &quot;[ \t|]\\+&quot;)[field-1] }), what))}(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be used with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:OnField  3 +&#xA;:2,5OnField  3 +&#xA;:'&amp;lt;,'&amp;gt;Onfield 3 *   &quot; after line-wise selection&#xA;....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: Here I use lambdas from Vim 7.4.1xxx&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-04-12T13:20:11.600" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15907" PostTypeId="2" ParentId="4695" CreationDate="2018-04-12T13:28:55.090" Score="1" Body="&lt;h2&gt;External cli tool &lt;a href=&quot;https://csvkit.readthedocs.io/en/1.0.3/scripts/csvstat.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;csvstat&lt;/code&gt;&lt;/a&gt; from &lt;a href=&quot;https://github.com/wireservice/csvkit&quot; rel=&quot;nofollow noreferrer&quot;&gt;csvkit&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!csvstat -d '|' -H -c 4 --sum %&#xA;69.5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Short explanation of the options&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;-d DELIMITER&lt;/code&gt; Delimiting character of the input CSV file. Here &lt;code&gt;|&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-H&lt;/code&gt; Specify that the input CSV file has no header row.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-c COLUMNS&lt;/code&gt; A comma separated list of column indices or names to&#xA;   be examined. Defaults to all columns.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;--sum&lt;/code&gt; Only output sums.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This tool also provides min, max, mean, median, stdev (standard deviation), count unique values, list of frequent values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Insert into file with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;=system(&quot;csvstat -d '|' -H -c 4 --sum FILENAME 2&amp;gt; /dev/null&quot;)  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Installation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;On macOS &lt;em&gt;csvkit&lt;/em&gt; is available via homebrew and on Debian/Ubuntu and similar it can be installed with &lt;code&gt;$ sudo apt install csvkit&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-04-12T16:06:54.253" LastActivityDate="2018-04-12T16:06:54.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15908" PostTypeId="2" ParentId="598" CreationDate="2018-04-12T16:19:51.297" Score="2" Body="&lt;h2&gt;Plugin &lt;em&gt;vim-move&lt;/em&gt; by matze&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Available from&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4687&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.vim.org/scripts/script.php?script_id=4687&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/matze/vim-move&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/matze/vim-move&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Default mappings in visual and normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;A-k&amp;gt;   Move current line/selection up&#xA;&amp;lt;A-j&amp;gt;   Move current line/selection down&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-04-12T16:29:49.823" LastActivityDate="2018-04-12T16:29:49.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15910" PostTypeId="1" CreationDate="2018-04-12T19:39:41.503" Score="1" ViewCount="1426" Body="&lt;p&gt;When I do a search within VIM the found text is highlighted in yellow with white letters.  For my eyes it is impossible to distinguish the text highlighted.  I am looking for the way to change those highlight colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My comment to wbogacz did not format well and I do not see a reply option, so I edit here again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am a Linux and vim notice.  When you wrote:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit $VIMRUNTIME/colors/colors_name.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That begins with the colon so I presume it is from within vim.  I was not able to get that to work.  Opening another terminal and using the command line for&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Echo $VIMRUNTIME&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yields a blank line.  Looking at your line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Search term=reverse ctermfg=Black ctermbg=Cyan gui=NONE guifg=Black guibg=Cyan&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will take some learning on my part.  Where does it belong?  Where can I read about that?&lt;/p&gt;&#xA;" OwnerUserId="17146" LastEditorUserId="343" LastEditDate="2018-04-13T09:43:00.237" LastActivityDate="2018-09-10T11:01:35.727" Title="How can I change the colors used for highlight search matches?" Tags="|search|highlight|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15911" PostTypeId="2" ParentId="15910" CreationDate="2018-04-12T20:39:27.767" Score="1" Body="&lt;p&gt;I am unclear the intent of your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Searching and those results within VIM?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In which case follow this general procedure:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Find the colorscheme you are in:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:echo g:colors_name&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Mine is wolf.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Find the file for edit at (generally):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:edit $VIMRUNTIME/colors/colors_name.vim&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, mine is&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:edit $VIMRUNTIME/colors/wolf.vim&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;find the line for Search; mine is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;hi Search      term=reverse                    ctermfg=Black       ctermbg=Cyan        gui=NONE        guifg=Black     guibg=Cyan&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;which shows searched terms in Black on Cyan. There are a variety of additional colors for term, in case it is necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For further info on highlight in vim see:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:he highlight&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;OR are you searching and want those results (former questions) within Stackexchange (the question is unclear)?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use the Search bar with general terms right next to the Stackexchange icon at top of screen.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Terms such as 'highlight colors' will search this Stackexchange to provide previous relevant questions and their answers.&lt;/p&gt;&#xA;" OwnerUserId="10509" LastActivityDate="2018-04-12T20:39:27.767" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15912" PostTypeId="2" ParentId="15905" CreationDate="2018-04-12T23:16:43.747" Score="8" Body="&lt;p&gt;Discl.: It's just guessing on my part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;abort&lt;/code&gt; didn't exist when &lt;code&gt;function&lt;/code&gt; was introduced. I guess that in order to not break existing code it was decided to not change the current behaviour and to provide another behaviour only when functions are explicitly annotated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, where should we not use it? I see no good reason. Even if a non annotated function continues after an error, we do observe many annoying error messages about unbalanced control statements (&lt;code&gt;if&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I execute code that can fail, I'd rather be explicit with &lt;code&gt;silent!&lt;/code&gt;, &lt;code&gt;try...catch&lt;/code&gt; or any other specific approach. I do have many non-&lt;code&gt;abort&lt;/code&gt;-annotated functions, it's just a sign they are very old and that I haven't upgraded them yet.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-04-13T12:01:40.727" LastActivityDate="2018-04-13T12:01:40.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15916" PostTypeId="1" AcceptedAnswerId="15982" CreationDate="2018-04-13T17:01:59.637" Score="3" ViewCount="501" Body="&lt;p&gt;I tend to use GVim a lot. Very frequently, I'll click on some other window and then when I click on vim to regain focus, my cursor will end up in some random location depending on where I clicked. I find this extremely obnoxious. I can generally remember where my cursor is before navigating away, but I don't like having to hunt it down every time I return to using gvim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought I could fix this by adding this to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FocusGained * normal &amp;lt;C-o&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(where &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; is the actual control character) but this doesn't work. It usually just navigates away from my current file. This happens even if I add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FocusLost * normal m`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I gave up on fixing this through the use of the jumplist. Instead, it seems like I could fix this by setting &lt;code&gt;mouse&lt;/code&gt;. In general, I'd prefer to have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I initially tried the following autocommands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FocusLost * set mouse=&#xA;au FocusGained * set mouse=a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it seems like the autocommand is processed &lt;em&gt;before&lt;/em&gt; the mouse click is registered and the cursor is moved. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My next thought is to asynchronously re-enable the mouse so that the mouse click will be ignored before my &lt;code&gt;mouse&lt;/code&gt; setting is changed. Something along the lines of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FocusGained * async_call(&quot;set mouse=a&quot;, 200ms) &quot;pseudocode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'm not sure exactly how to do this step. I can't find any info on the correct way to asynchronously call vimscript.  I would like an answer either for how to do this asynchronously like I explained, but if there's a simpler way too achieve this then that would be appreciated too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated. I am using vim 8.0 GUI version on Windows.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="51" LastEditDate="2018-08-22T16:33:08.553" LastActivityDate="2023-06-09T09:26:03.753" Title="How to use &quot;FocusGained&quot; to stop my cursor from moving" Tags="|vimscript|autocmd|mouse|async|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="15917" PostTypeId="1" CreationDate="2018-04-13T20:23:06.093" Score="2" ViewCount="149" Body="&lt;p&gt;When running shell commands in a terminal buffer I often just want to examine the output, and then close the buffer. Let's say I call &lt;code&gt;:term ls&lt;/code&gt;. How would I implement a simple &quot;Press any key to close&quot; which wipes out the terminal buffer on pressing any key?&lt;/p&gt;&#xA;" OwnerUserId="16806" LastActivityDate="2018-04-13T20:23:06.093" Title="Implement &quot;Press any key to close&quot; in neovim terminal buffer" Tags="|vimscript|neovim|terminal|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15918" PostTypeId="1" CreationDate="2018-04-14T02:08:36.453" Score="2" ViewCount="1171" Body="&lt;p&gt;I use &lt;a href=&quot;https://github.com/ivanbrennan/zoo&quot; rel=&quot;nofollow noreferrer&quot;&gt;something&lt;/a&gt; like &lt;a href=&quot;https://github.com/troydm/zoomwintab.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;zoomwintab&lt;/a&gt; to zoom in/out of a single window view, using tabs to simulate the effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It exposes a toggle function to zoom in on a single window, and to zoom back out to the orginal layout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I'm zoomed in and I &lt;code&gt;quit&lt;/code&gt; (rather than toggle), I want to return to the original layout, but with that window removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To achieve this, I'm recording the unique window id the zoom originated from,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let origin_win = win_getid()&#xA;&quot; ...zoom in... (elided)&#xA;let s:origin_wins[win_getid()] = origin_win&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and using that to determine which window I need to quit in addition to the current one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup Zoo&#xA;  au!&#xA;  au QuitPre * if s:zoomed_win_only() | call s:quit_origin() | endif&#xA;augroup END&#xA;&#xA;func! s:quit_origin() abort&#xA;  let og = s:get_origin()&#xA;&#xA;  if s:exists(og)&#xA;    let i = win_getid()&#xA;    call win_gotoid(og) | quit&#xA;    call win_gotoid(i)&#xA;  endif&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm very happy with it, but I think it could be improved if there was a way to quit a specific window by its id. That way I could avoid the need to switch to the origin window, quit it, and switch back to the zoomed window I'm about to quit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a cleaner way I might do this?&lt;/p&gt;&#xA;" OwnerUserId="1855" LastActivityDate="2021-07-30T21:52:31.580" Title="Quit a window by its win_getid() identifier?" Tags="|vim-windows|window-management|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15919" PostTypeId="1" CreationDate="2018-04-14T03:35:00.387" Score="0" ViewCount="56" Body="&lt;p&gt;vim1 is my local vim.vim2 is the remote vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ssh root@remote_ip&#xA;vim &#xA;#it is vim2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now some content in my vim1's + register.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;curl -X POST https://content.dropboxapi.com/2/files/upload \&#xA;        --header &quot;Authorization: Bearer xxxx&quot; \&#xA;        --header &quot;Dropbox-API-Arg:  {\&quot;path\&quot;:\&quot;/test.txt\&quot;,\&quot;mode\&quot;:{\&quot;.tag\&quot;:\&quot;overwrite\&quot;}}&quot; \&#xA;        --header &quot;Content-Type: application/octet-stream&quot; \&#xA;        --data-binary @&quot;test.txt&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to copy content in my vim1's + register into my vim2.     &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.To input  &lt;code&gt;ctrl+shift+v&lt;/code&gt; in vim2 will get bad formatted content.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;curl -X POST https://content.dropboxapi.com/2/files/upload \&#xA;                    --header &quot;Authorization: Bearer xxxx&quot; \&#xA;                                --header &quot;Dropbox-API-Arg:  {\&quot;path\&quot;:\&quot;/test.txt\&quot;,\&quot;mode\&quot;:{\&quot;.tag\&quot;:\&quot;overwrite\&quot;}}&quot; \&#xA;                                            --header &quot;Content-Type: application/octet-stream&quot; \&#xA;                                                        --data-binary @&quot;test.txt&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2.To input &lt;code&gt;:&quot;+p&lt;/code&gt; in vim2 can't do the trick.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to copy content in + register from local vim to remote vim in good format?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastActivityDate="2018-04-17T23:34:55.593" Title="How to copy content in + register from local vim to remote vim in good format?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15920" PostTypeId="1" AcceptedAnswerId="15921" CreationDate="2018-04-14T15:05:46.733" Score="5" ViewCount="444" Body="&lt;p&gt;I'm trying to wrap my head around vim plugin development and I see a constant check on a variable to see if the plugin has already been loaded like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('g:loaded_plugin') || &amp;amp;cp&#xA;  finish&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes sense since it's trying to not load the plugin twice but why is it checking the second part?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've searched on the documentation on the &lt;code&gt;&amp;amp;&lt;/code&gt; and the &lt;code&gt;cp&lt;/code&gt; command and it's not ringing anything on my head. As said in the documentation, the &lt;code&gt;&amp;amp;&lt;/code&gt; is used to replay the last substitution command and the &lt;code&gt;cp&lt;/code&gt; is to get to the next Error.&lt;/p&gt;&#xA;" OwnerUserId="17105" LastActivityDate="2021-04-21T22:05:50.557" Title="Why vim plugins have a check on &amp;cp" Tags="|vimscript|plugin-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15921" PostTypeId="2" ParentId="15920" CreationDate="2018-04-14T18:35:04.727" Score="6" Body="&lt;p&gt;That checks for the &lt;code&gt;compatible&lt;/code&gt; option being set. Usually you don't want plugins to be run when the compatible option is set, because well for one Vim wouldn't actually be compatible anymore and seconds of all, the compatible option e.g. does not allow for line continuations e.g. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a = 'foobar'&#xA;     \ . ' and more text'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could fix that, by setting a specific &lt;code&gt;cpotions&lt;/code&gt; flag, but the general consensus in the Vim community seems to be, to just not bother and skip loading the plugin if Vim starts in compatible mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Alet-option&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :let-option&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-04-14T18:35:04.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15922" PostTypeId="1" AcceptedAnswerId="15925" CreationDate="2018-04-14T20:49:30.367" Score="1" ViewCount="138" Body="&lt;p&gt;I need to change the content within a &lt;code&gt;[count]&lt;/code&gt; number of braces for each line in my buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 {Lorem} ipsum dolor {amet} blah blah {change this text} more blah blah&#xA;2 Hello. The {sun} rises in {the} east. blah {blah}. {also change this text}. final blah&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;line 1&lt;/code&gt;, I need to substitute the content within the &lt;code&gt;3rd&lt;/code&gt; set of braces to &lt;code&gt;random forest&lt;/code&gt;.  For &lt;code&gt;line 2&lt;/code&gt;, I need to change the text within &lt;code&gt;4th&lt;/code&gt; set of braces to &lt;code&gt;alchemy&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know of a naive  method for doing this, i.e. for each line, first move the cursor to the desired braces and perform a &lt;code&gt;ci}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the reasons of efficiency (as I am editing/proof-reading a large text-file with such markup), I wish to do these per-line substitutions &lt;strong&gt;&lt;em&gt;without&lt;/em&gt;&lt;/strong&gt; moving the cursor from &lt;code&gt;column 1&lt;/code&gt; for each linewise substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this? Does &lt;code&gt;ex&lt;/code&gt; mode help?&lt;/p&gt;&#xA;" OwnerUserId="8408" LastEditorUserId="8408" LastEditDate="2018-04-15T07:01:15.370" LastActivityDate="2018-07-10T00:31:53.130" Title="Changing content within the specified [count] number of braces for each line" Tags="|cursor-movement|substitute|cursor-motions|count|object-motions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15923" PostTypeId="2" ParentId="15922" CreationDate="2018-04-15T01:00:39.757" Score="1" Body="&lt;p&gt;Execute the following in normal mode on the first line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2f{ci{REPLACEMENT_TEXT&amp;lt;ESC&amp;gt;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will find the target brace, change the content to REPLACEMENT_TEXT and then return the cursor back to the beginning of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the second line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4f{ci{REPLACEMENT_TEXT&amp;lt;ESC&amp;gt;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the exact number of braces to search for depend on if the first character on the line is a brace.&lt;/p&gt;&#xA;" OwnerUserId="12736" LastActivityDate="2018-04-15T01:00:39.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15924" PostTypeId="2" ParentId="8382" CreationDate="2018-04-15T01:07:42.513" Score="3" Body="&lt;p&gt;Solution for me was to add this line after the filetype plugin on into my &lt;code&gt;~/.vimrc&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;autocmd FileType python setlocal noexpandtab shiftwidth=4 softtabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14827" LastActivityDate="2018-04-15T01:07:42.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15925" PostTypeId="2" ParentId="15922" CreationDate="2018-04-15T07:25:38.900" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://vi.stackexchange.com/posts/15923/edit&quot;&gt;answer from @RubenWesterberg&lt;/a&gt; is a correct sequence of Normal mode commands to do what you want. But I read your request to not move the cursor a little more literally. Also, if you need to make substitutions like this frequently you probably want something a bit less manual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use standard substitution in a mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;{ ':&amp;lt;c-u&amp;gt;s/\({.\{-}\)\{' . v:count1 . '}\zs[^}]*/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is used in Normal mode by entering &lt;code&gt;N\{&lt;/code&gt; where &lt;code&gt;N&lt;/code&gt; is the numerical 1-based &quot;index&quot; of the bracket pair within which you want to replace text. (I'm assuming you are using default &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; key &lt;code&gt;\&lt;/code&gt;). This will take you to the command-line with a pre-populated &lt;code&gt;:substitute&lt;/code&gt; command. The cursor will be placed so you merely enter the replacement text followed by &lt;kbd&gt;Enter&lt;/kbd&gt; and the work is done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep in mind that the value of &lt;code&gt;N&lt;/code&gt; is counted from the current cursor position. It will still work if the cursor is not in the first column but if any brackets appear before the cursor they will not be counted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;N&lt;/code&gt; can be omitted in which case a default of index 1 will be used.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; For fun, if we want to take the no-cursor-movement requirement to the extreme this version will add Normal mode command &lt;code&gt;0&lt;/code&gt; after the substitution so you always end up back in the first column:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;{ ':&amp;lt;c-u&amp;gt;s/\({.\{-}\)\{' . v:count1 . '}\zs[^}]*// \| norm! 0&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; Didn't have time to do this earlier so here's a breakdown of the pattern in the substitution. If we have &lt;code&gt;N=3&lt;/code&gt; then substitution renders as the following (with the cursor at the very end):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\({.\{-}\)\{3}\zs[^}]*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;{.\{-}&lt;/code&gt; - Match a left bracket, &lt;code&gt;{&lt;/code&gt;, followed by zero or more characters until a later segment of the pattern is matched or the pattern end is reached. &lt;code&gt;.\{-}&lt;/code&gt; is like &lt;code&gt;.*&lt;/code&gt; except that the latter matches as many characters as possible while the former matches as few as possible.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(...\)\{3}&lt;/code&gt; - Match the previous pattern exactly three times.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs&lt;/code&gt; - Indicates that the substitution will replace characters starting at this position rather than replacing the whole pattern match. In this case, it is the position of the first character inside the target bracket pair.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^}]*&lt;/code&gt; - Match zero or more characters that are not &lt;code&gt;}&lt;/code&gt; or, in other words, match everything inside the target bracket pair.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-07-10T00:31:53.130" LastActivityDate="2018-07-10T00:31:53.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15926" PostTypeId="1" CreationDate="2018-04-15T09:39:53.300" Score="1" ViewCount="1668" Body="&lt;p&gt;I've tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;let g:solarized_termcolors=256&#xA;set t_Co=256&#xA;set background=dark&#xA;colorscheme solarized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it doesn't look like GVim, how can I achieve that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now&#xA;&lt;a href=&quot;https://i.stack.imgur.com/AiSpC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AiSpC.png&quot; alt=&quot;Right now&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17168" LastEditorUserId="51" LastEditDate="2018-04-15T17:41:22.570" LastActivityDate="2019-04-11T12:00:51.760" Title="Vim Terminal - Solarized Colorscheme [Gnome]" Tags="|terminal|colorscheme|plugin-solarized|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15927" PostTypeId="1" AcceptedAnswerId="15929" CreationDate="2018-04-15T13:32:29.867" Score="1" ViewCount="1164" Body="&lt;p&gt;&lt;code&gt;:scriptnames&lt;/code&gt; can list all plugins installed in my vim.&lt;br&gt;&#xA;How to write the output of scriptnames into a file?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:scriptnames &amp;gt; names.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It can't do the trick.&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="51" LastEditDate="2018-04-15T17:38:46.320" LastActivityDate="2018-04-15T17:38:46.320" Title="How to write the output of scriptnames into a file?" Tags="|vimscript|ex-mode|" AnswerCount="2" CommentCount="0" ClosedDate="2018-04-16T07:22:35.173" ContentLicense="CC BY-SA 3.0" />
  <row Id="15928" PostTypeId="1" CreationDate="2018-04-15T13:46:36.977" Score="-4" ViewCount="465" Body="&lt;p&gt;Password-free ssh authentication had been set.&lt;br&gt;&#xA;There is a file &lt;code&gt;/home/test.txt&lt;/code&gt; in my remote_ip.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim scp://root@remote_ip//home/test.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why vim  scp  can't read file on my remote vps?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim  --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 30 2017 18:21:38)&#xA;ls -al   /home/test.txt&#xA;-rw-r--r-- 1 root root 100 Apr 23 12:40 /home/test.txt&#xA;enough space left on both local and remote device.&#xA;ssh credential established between my vps and local pc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To connect with my vps.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ssh  -i .ssh/id_rsa  -p 1000  root@remote_ip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The port number is 1000 not standard 22.&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="5181" LastEditDate="2018-04-25T03:26:58.400" LastActivityDate="2018-04-25T03:26:58.400" Title="Why vim scp can't read file on my remote vps?" Tags="|ssh|" AnswerCount="1" CommentCount="2" ClosedDate="2018-04-24T13:31:02.620" ContentLicense="CC BY-SA 3.0" />
  <row Id="15929" PostTypeId="2" ParentId="15927" CreationDate="2018-04-15T14:23:19.920" Score="4" Body="&lt;p&gt;this can be done with &lt;code&gt;redir &amp;gt;names.txt|silent scriptnames|redir END&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;silent&lt;/code&gt; here to avoid a &lt;strong&gt;-- more --&lt;/strong&gt; -prompt.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-04-15T14:23:19.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15931" PostTypeId="2" ParentId="15927" CreationDate="2018-04-15T16:20:04.410" Score="4" Body="&lt;p&gt;If you just want to list them in a buffer, there is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new&#xA;:put=execute('scriptnames')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need to search, well, there is &lt;code&gt;filter()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo filter(split(execute('scriptnames'), &quot;\n&quot;), 'v:val =~ &quot;syntax&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-04-15T16:20:04.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15933" PostTypeId="1" AcceptedAnswerId="15935" CreationDate="2018-04-15T18:05:39.953" Score="2" ViewCount="702" Body="&lt;p&gt;I hope this question is a duplicate one because I have already tried to find &lt;code&gt;init.vim&lt;/code&gt; inside the nvim folder but I am unable to locate the file.&#xA;Also, would I have to create it explicitly or would it be automatically created on installation?&#xA;Kindly help me out.&#xA;Both of these folders are empty. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;pre&gt;C:\Users\dell\AppData\Local\nvim&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;pre&gt;C:\Users\dell\AppData\Local\nvim-data&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Windows 8.1.&lt;/p&gt;&#xA;" OwnerUserId="17123" LastEditorUserId="17123" LastEditDate="2018-04-15T18:28:30.230" LastActivityDate="2018-04-15T22:07:52.793" Title="init.vim cannot be found" Tags="|neovim|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15934" PostTypeId="2" ParentId="15918" CreationDate="2018-04-15T19:08:10.717" Score="3" Body="&lt;p&gt;You can retrieve the window number (as opposed to the window ID) and then use &lt;code&gt;wincmd&lt;/code&gt; to close:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let winnr = win_id2win(og)&#xA;if winnr &amp;gt; 0&#xA;    execute winnr.'wincmd c'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Keep in mind this won't work if the window isn't in the current tab page.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-04-15T19:08:10.717" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15935" PostTypeId="2" ParentId="15933" CreationDate="2018-04-15T22:07:52.793" Score="4" Body="&lt;p&gt;Neovim won't create the &lt;code&gt;~/AppData/Local/nvim/init.vim&lt;/code&gt; file during installation. You will have to create it yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way to confirm it's being loaded is to create the file with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echoerr &quot;init.vim is loaded&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which should show an error message on startup.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2018-04-15T22:07:52.793" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15936" PostTypeId="1" CreationDate="2018-04-15T22:26:32.523" Score="1" ViewCount="1538" Body="&lt;p&gt;I've discovered that I can edit the .vimrc file to create custom commands and would like to create simpler &lt;a href=&quot;http://vim.wikia.com/wiki/Search_and_replace&quot; rel=&quot;nofollow noreferrer&quot;&gt;search and replace&lt;/a&gt; alternative commands, but have no idea how to edit &lt;code&gt;%s/foo/bar/gc&lt;/code&gt; so that it uses the words I pass after the &lt;code&gt;:command&lt;/code&gt; in vim instead of 'foo' and 'bar.'&#xA;Would prefer a simple solution not requiring me to learn vimscript.&lt;/p&gt;&#xA;" OwnerUserId="16949" LastActivityDate="2018-04-16T06:26:47.653" Title="Using arguments in a .vimrc command" Tags="|vimrc|user-commands|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15937" PostTypeId="1" CreationDate="2018-04-16T03:39:19.810" Score="2" ViewCount="84" Body="&lt;p&gt;I've been playing around trying to learn VimL and to do so, I'm toying with the Evernote Ruby SDK to do basic stuff. Is there a reference manual where to find a full Ruby bindings guide or something that helps develop Vim plugins using Ruby? or is the &lt;code&gt;:h ruby&lt;/code&gt; man all there is? I mean, is it worth the effort?&lt;/p&gt;&#xA;" OwnerUserId="17105" LastEditorUserId="51" LastEditDate="2018-04-16T03:50:00.290" LastActivityDate="2018-04-16T03:50:00.290" Title="Is it possible to develop decent plugins using Ruby?" Tags="|vimscript|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15938" PostTypeId="2" ParentId="15926" CreationDate="2018-04-16T03:58:38.987" Score="4" Body="&lt;p&gt;According to the &lt;a href=&quot;https://github.com/altercation/vim-colors-solarized#important-note-for-terminal-users&quot; rel=&quot;nofollow noreferrer&quot;&gt;readme&lt;/a&gt; of the vim sector of ethan's solarized colorscheme, you need to set the colorscheme of your terminal explicitly. You can take a look at &lt;a href=&quot;https://github.com/chriskempson/base16-shell&quot; rel=&quot;nofollow noreferrer&quot;&gt;base 16&lt;/a&gt;. Install it, and run &lt;code&gt;base16_solarized-dark&lt;/code&gt;. Then vim will, hopefully, show the colors properly. And also put this in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set termguicolors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in place of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2018-04-16T06:42:47.943" LastActivityDate="2018-04-16T06:42:47.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15939" PostTypeId="2" ParentId="15936" CreationDate="2018-04-16T06:26:47.653" Score="5" Body="&lt;p&gt;If you are using the &lt;code&gt;:%s&lt;/code&gt; command, you are already using some very simple VimScript. So much for not learning it :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to create your custom command, you can use e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! -nargs=1 Replace :%s/&amp;lt;args&amp;gt;/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This defines a new command &lt;code&gt;:Replace&lt;/code&gt; and you can use &lt;code&gt;:Replace foo/bar&lt;/code&gt;  to have all foo be replaced by bar across the complete document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is basically as simple and straight forward as possible, however this requires you to always supply an argument in the form &lt;code&gt;searchterm/replaceterm&lt;/code&gt; e.g. you need to include the slash, so that dynamically a new command can be build up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could get very much sophisticated however, e.g. add some error management, use 2 arguments for searching and replacing, use a specific &lt;code&gt;magic&lt;/code&gt; setting, so that it will handle e.g. &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;\&lt;/code&gt; correctly or how to handle the &lt;code&gt;/&lt;/code&gt; if it appears in the search or replace term.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This however requires using a function and doing a bit more of processing of the arguments and is way much out of scope, if you do not want to learn VimScript.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-04-16T06:26:47.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15942" PostTypeId="1" CreationDate="2018-04-16T12:17:26.857" Score="0" ViewCount="78" Body="&lt;p&gt;Trying to fold content so the 'method definition' / 'explanatory' lines are all showing regardless of depth, and the content between them is folded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Folding examples on the wikis and in tutorials all seem to fold by nested depth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# RSpec code example&#xA;# '...' represents many lines of content&#xA;...&#xA;context 'depth 0' do&#xA;  ...&#xA;  context 'depth 1' do&#xA;    ...&#xA;    it 'depth 2' do&#xA;      ...&#xA;    end&#xA;  end&#xA;  ...&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Folding with syntax matching, foldlevel=1 will give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# RSpec code example&#xA;# '...' represents many lines&#xA;...&#xA;context 'depth 0' do&#xA;  ...&#xA;  +-- 66 lines: context 'depth 1' do {--------------------------&#xA;  ...&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Trying to fold away the content &lt;code&gt;...&lt;/code&gt;, how do I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# RSpec code example&#xA;# '...' represents many lines of content&#xA;+-- MANY lines: ... {--------------------------&#xA;context 'depth 0' do&#xA;+-- MANY lines: ... {--------------------------&#xA;  context 'depth 1' do&#xA;+-- MANY lines: ... {--------------------------&#xA;    it 'depth 2' do&#xA;+-- MANY lines: ... {--------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12635" LastActivityDate="2019-08-09T16:02:45.360" Title="Folding RSpec content not depth" Tags="|folding|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15943" PostTypeId="2" ParentId="15942" CreationDate="2018-04-16T12:17:26.857" Score="1" Body="&lt;p&gt;To show the lines ending in &lt;code&gt;do&lt;/code&gt;, and fold away everything else:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set foldexpr=getline(v:lnum)=~'do$'?'=':getline(v:lnum-1)=~'do$'?'a1':getline(v:lnum+1)=~'do$'?'s1':'='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Breakdown&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# using '#' as comments&#xA;# this is ran on each line to work out its indentation level&#xA;&#xA;:set foldexpr=&#xA;  getline(v:lnum)=~'do$' # current line regex match lines that end in 'do'&#xA;  ? # if the previous statement is true do this&#xA;    '=' # same indent level as previous line&#xA;  : # else&#xA;    getline(v:lnum-1)=~'do$' # examine previous line, same matcher&#xA;    ? # if previous&#xA;      'a1' # one indent level deeper than previous line&#xA;    : # else&#xA;      getline(v:lnum+1)=~'do$'# examine next line, same matcher&#xA;      ? # if previous&#xA;        's1' # one indent level up from previous line&#xA;      : # else&#xA;        '=' # same indent level as previous line&#xA;&#xA;# if you want to exclude e.g. lines that are 'before do',&#xA;# then change &quot;getline(v:lnum)=~'do$'&quot;&#xA;# to &quot;getline(v:lnum)=~'do$'&amp;amp;&amp;amp;getline(v:lnum)!~'before\\sdo$'&quot;&#xA;# giving :set foldexpr=getline(v:lnum)=~'do$'&amp;amp;&amp;amp;getline(v:lnum)!~'before\\sdo$'?'=':getline(v:lnum-1)=~'do$'&amp;amp;&amp;amp;getline(v:lnum-1)!~'before\\sdo$'?'a1':getline(v:lnum+1)=~'do$'&amp;amp;&amp;amp;getline(v:lnum+1)!~'before\\sdo$'?'s1':'='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Beginner Notes&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you're a beginner and its not working, remember to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set foldmethod=expr&#xA;:set foldlevel=0&#xA;:set foldenable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets foldmethod to use the expression set in &lt;code&gt;foldexpr&lt;/code&gt;, sets &lt;code&gt;foldlevel&lt;/code&gt; to 0 - which is important as this solution gives every line a foldlevel of 1 or 0, and lastly no matter what commands you run, if &lt;code&gt;foldenable&lt;/code&gt; is not set you won't see anything. If you alter the command, make sure there are no spaces, use &lt;code&gt;\s&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12635" LastActivityDate="2018-04-16T12:17:26.857" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15944" PostTypeId="1" CreationDate="2018-04-16T12:27:46.573" Score="13" ViewCount="3357" Body="&lt;p&gt;I've seen this question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/93/is-there-a-way-to-count-the-number-of-occurrences-of-a-word-in-a-file/100&quot;&gt;Is there a way to count the number of occurrences of a word in a file?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but most of the time I search using &lt;kbd&gt;*&lt;/kbd&gt; or just &lt;kbd&gt;/&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to display automatically in the statusline the number of matches when using these commands? &lt;/p&gt;&#xA;" OwnerUserId="2710" LastActivityDate="2020-05-27T20:20:22.023" Title="How to display in the statusline the number of matches from a search?" Tags="|search|statusline|counting|" AnswerCount="3" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15945" PostTypeId="1" AcceptedAnswerId="15947" CreationDate="2018-04-16T14:36:45.317" Score="20" ViewCount="2916" Body="&lt;p&gt;I would like to store the result of a &lt;code&gt;system()&lt;/code&gt; call in a variable without the trailing &lt;code&gt;^@&lt;/code&gt; character. At the moment I do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var = system('command | xargs -i echo -n &quot;{}&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it feels convoluted. Is there a simpler solution?&lt;/p&gt;&#xA;" OwnerUserId="11125" LastActivityDate="2018-04-16T14:53:07.537" Title="Remove new line from result of system()" Tags="|formatting|functions|" AnswerCount="2" CommentCount="0" ClosedDate="2018-04-17T19:35:13.153" ContentLicense="CC BY-SA 3.0" />
  <row Id="15946" PostTypeId="2" ParentId="15945" CreationDate="2018-04-16T14:42:38.977" Score="6" Body="&lt;p&gt;You probably want to use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#systemlist%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h systemlist()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;systemlist({expr} [, {input}])                *systemlist()*&#xA;      Same as system(), but returns a List with lines (parts of&#xA;      output separated by NL) with NULs transformed into NLs.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is usally a good way to handle system call without having to handle the new line characters.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-04-16T14:42:38.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15947" PostTypeId="2" ParentId="15945" CreationDate="2018-04-16T14:53:07.537" Score="26" Body="&lt;p&gt;If you don't want to use &lt;code&gt;systemlist&lt;/code&gt; for whatever reason, you can explicitly remove the newline and/or whitespace.  Since vim 8.0.1630 (very recent), there is a &lt;code&gt;trim()&lt;/code&gt; function which removes whitespace, including newline, from the &lt;em&gt;front and the back&lt;/em&gt; of a string.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;trim(system('command'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A common way, if you know there will always be a trailing newline is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;system('command')[:-2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, you can use substitute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(system('command'), '\n$', '', '')     &quot; newline only&#xA;substitute(system('command'), '\_s*$', '', '')   &quot; any whitespace&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-04-16T14:53:07.537" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15948" PostTypeId="1" AcceptedAnswerId="15949" CreationDate="2018-04-16T20:38:55.853" Score="7" ViewCount="4613" Body="&lt;p&gt;While working through vimtutor, I tried a variant on&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/old/new/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by leaving off the &lt;code&gt;g&lt;/code&gt; flag&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/old/new&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and expected the substitution to only occur once in the whole file. After all, this mirrors the behavior of &lt;code&gt;:s/old/new&lt;/code&gt;, which operates on the current line and only substitutes once unless the &lt;code&gt;g&lt;/code&gt; flag is present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the &lt;code&gt;g&lt;/code&gt; the &lt;code&gt;:%s&lt;/code&gt; substitution command does seem to matter, as both variants operate many times on the whole file. Is this documented anywhere, and how do you make sense of this discrepancy?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Workaround&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I'm aware that I can replace just one instance anywhere in the file with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/old/new/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and decline the prompt after the first substitution. I'm seeking understanding on the non-interactive version without the &lt;code&gt;c&lt;/code&gt; flag.&lt;/p&gt;&#xA;" OwnerUserId="17188" LastActivityDate="2018-04-16T21:05:35.587" Title="When substituting with :%s/old/new/g, does g flag have any effect?" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15949" PostTypeId="2" ParentId="15948" CreationDate="2018-04-16T21:05:35.587" Score="10" Body="&lt;p&gt;The &lt;code&gt;g&lt;/code&gt; flag to the &lt;code&gt;:s&lt;/code&gt; command does not influence how many items are replaced in the whole file, but rather how often to apply the substition &lt;strong&gt;per line&lt;/strong&gt;. E.g. &lt;code&gt;:%s/foo/bar/g&lt;/code&gt; in a file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo foo foo&#xA;foo&#xA;foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it will be replaced to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bar bar bar&#xA;bar&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;while the command &lt;code&gt;:%s/foo/bar/&lt;/code&gt; will replace the file to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bar foo foo&#xA;bar&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In general, if you want a region to be excluded from the effect of the &lt;code&gt;:s&lt;/code&gt; command, you should use an address that excludes it from being affected by that command (this applies in general to all ex commands).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-04-16T21:05:35.587" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15950" PostTypeId="1" AcceptedAnswerId="15963" CreationDate="2018-04-16T22:48:38.827" Score="0" ViewCount="60" Body="&lt;p&gt;If I have this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a{word}   a{20]   a{word}   a{20]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and type &lt;code&gt;:g/a{.\{-}\]/s/{/\[/gc&lt;/code&gt;   vi prompts me to change all four occurrences of &lt;code&gt;{&lt;/code&gt; to &lt;code&gt;[&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want it to prompt me to replace only the matches that occur immediately to the right of the cursor after finding a match, i.e., to prompt me to  change only the &lt;code&gt;a{20]&lt;/code&gt;'s to &lt;code&gt;a[20]&lt;/code&gt;'s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could somebody explain how to do this please?&lt;/p&gt;&#xA;" OwnerUserId="4667" LastActivityDate="2018-04-18T13:51:08.613" Title="limiting global search&amp;replace to matches that occur immediately to the right of the cursor" Tags="|search|replace|global-command|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15951" PostTypeId="2" ParentId="15950" CreationDate="2018-04-17T02:16:34.367" Score="2" Body="&lt;p&gt;I think rather than trying to base things on the current cursor position, you'd be better off formulating your search pattern to be more specific to what you're looking for.  From what I can tell, you're trying to replace the &lt;code&gt;{&lt;/code&gt; before a number that's followed by a &lt;code&gt;]&lt;/code&gt;.  I would do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/{\ze\d\+\]/[/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:g&lt;/code&gt; command wasn't really necessary, so I combined it into just a substitute command.  This first searches for a &lt;code&gt;{&lt;/code&gt;, followed by one or more digits followed by a &lt;code&gt;]&lt;/code&gt;.  The &lt;code&gt;\ze&lt;/code&gt; after the &lt;code&gt;{&lt;/code&gt; sets the end of the search pattern.  This makes it so that only the stuff before it (in this case, the &lt;code&gt;{&lt;/code&gt;) gets replaced by the replacement part, which is simply a &lt;code&gt;[&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2018-04-17T02:16:34.367" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15952" PostTypeId="2" ParentId="9967" CreationDate="2018-04-17T03:07:04.393" Score="27" Body="&lt;p&gt;To open NerdTree : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:NERDTreeFocus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To switch beetween nerdtree and file opened windows :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctrl + ww (double w)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctrl + w + (h/j/k/l)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To close NerdTree (in nerdtree window) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17192" LastEditorUserId="17192" LastEditDate="2019-05-03T07:05:21.363" LastActivityDate="2019-05-03T07:05:21.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15953" PostTypeId="1" AcceptedAnswerId="15954" CreationDate="2018-04-17T16:01:27.037" Score="1" ViewCount="232" Body="&lt;p&gt;I use &lt;code&gt;vimgrep&lt;/code&gt; with &lt;code&gt;:cnew&lt;/code&gt; and &lt;code&gt;:cold&lt;/code&gt; a lot.  I could be looking at a &lt;code&gt;vimgrep&lt;/code&gt; list from several &lt;code&gt;vimgrep&lt;/code&gt; commands ago.  Is there a way to refresh the &lt;code&gt;vimgrep&lt;/code&gt; list without typing in the corresponding &lt;code&gt;vimgrep&lt;/code&gt; command?  It might be quite far up in the command history, so it often takes more time to find it.  By refresh, I mean search through all the files that were searched in the original issuance of the &lt;code&gt;vimgrep&lt;/code&gt; command.  Some may have been changed due to editing.&lt;/p&gt;&#xA;" OwnerUserId="7970" LastActivityDate="2018-04-17T16:26:59.113" Title="Refresh `vimgrep` list?" Tags="|vimgrep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15954" PostTypeId="2" ParentId="15953" CreationDate="2018-04-17T16:26:59.113" Score="1" Body="&lt;p&gt;You can always do &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt; on the command line with a prefix of &lt;code&gt;:vimgrep&lt;/code&gt; to make searching history easier. You may also want to check out &lt;code&gt;q:&lt;/code&gt; and the use &lt;code&gt;?&lt;/code&gt;/&lt;code&gt;/&lt;/code&gt; to search for the command to re-execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming the quickfix title is set correctly, you can use following the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute get(getqflist({'title':1}), 'title')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This however I am not certain this will work with all &lt;code&gt;:grep&lt;/code&gt;/&lt;code&gt;:make&lt;/code&gt; commands. You also need a newer Vim version to get the Quckfix list title (Vim 8+ I think).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find yourself doing this often you may want to bind a mapping or command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=0 -bar QFRefresh execute get(getqflist({'title':1}), 'title')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h getqflist()&#xA;:h :execute&#xA;:h :get&#xA;:h q:&#xA;:h cmdwin&#xA;:h c_Up&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-04-17T16:26:59.113" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15955" PostTypeId="1" AcceptedAnswerId="15956" CreationDate="2018-04-17T20:16:23.147" Score="2" ViewCount="337" Body="&lt;p&gt;Goal: write code to do block commenting/uncommenting while keeping the current indentation level. &lt;a href=&quot;https://vi.stackexchange.com/a/16122/17205&quot;&gt;This has been solved, see here for my code&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current problem: use s/// to match a line that begins with spaces/tabs and then a comment character, which will depend on the file being modified. In this case, I want to move from &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    // this is a comment that can be toggled on/off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    this is a comment that can be toggled on/off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With my cursor on the commented line above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let b:commentChar='//'&#xA;:s@(^\s*)\=b:commentChar\s*@\1@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried escaping the parentheses, escaping or unescaping the &lt;code&gt;=&lt;/code&gt;, and using &lt;code&gt;\v&lt;/code&gt; which someone told me would be &quot;magic&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This does not work. (I didn't want to use &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;#&lt;/code&gt; as the delimiter because my variable can be &lt;code&gt;//&lt;/code&gt; or &lt;code&gt;#&lt;/code&gt; and didn't want to use &lt;code&gt;:&lt;/code&gt; as I need that for scoping with &lt;code&gt;b:commentChar&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="17205" LastEditorUserId="17205" LastEditDate="2018-05-02T23:38:38.300" LastActivityDate="2018-05-02T23:38:38.300" Title="How to match pattern with buffer-scoped variable" Tags="|substitute|variables|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="15956" PostTypeId="2" ParentId="15955" CreationDate="2018-04-17T20:58:22.897" Score="2" Body="&lt;p&gt;You cannot use &lt;code&gt;\=&lt;/code&gt; in the &quot;search&quot; portion of a &lt;code&gt;:substitute&lt;/code&gt; command to introduce an expression. Actually, &lt;code&gt;\=&lt;/code&gt; does have meaning in this context but it &quot;matches 0 or 1 of the preceding atom, as many as possible,&quot; which is not what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you should use &lt;code&gt;&amp;lt;c-r&amp;gt;=b:commentChar&amp;lt;cr&amp;gt;&lt;/code&gt;.  This means literal &lt;code&gt;CTRL-R=&lt;/code&gt; to introduce an expression and then &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to end the expression (copy and pasting this won't work).  Your substitute also uses &lt;code&gt;()&lt;/code&gt; which means literal parentheses, not a group.  Here is a working command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v(^\s*)\V&amp;lt;c-r&amp;gt;=escape(b:commentChar, '\/')&amp;lt;cr&amp;gt;\v\s*/\1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;uses &lt;code&gt;\v&lt;/code&gt; to make parentheses act as a group- not strictly necessary but it prevents the user's &lt;code&gt;magic&lt;/code&gt; setting from interfering.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\V&lt;/code&gt; before the expression to allow literal text and &lt;code&gt;\v&lt;/code&gt; afterwards.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;escape()&lt;/code&gt; so we don't have to worry about any slashes in the expression so we can safely use &lt;code&gt;s//&lt;/code&gt;.  Using &lt;code&gt;s@@&lt;/code&gt; works too, but there is the (maybe remote) possibility that &lt;code&gt;b:commentChar&lt;/code&gt; contains &lt;code&gt;@&lt;/code&gt;.  &lt;code&gt;escape&lt;/code&gt; handles all cases.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Again &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; are literal characters you must type.  This is handled transparently in mappings, e.g., copy and pasting the following would work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;c :s/\v(^\s*)\V&amp;lt;c-r&amp;gt;=escape(b:commentChar, '\/')&amp;lt;cr&amp;gt;\v\s*/\1/&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could use &lt;code&gt;execute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 's/\v(^\s*)\V'.escape(b:commentChar, '\/').'\v\s*/\1/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-04-17T21:04:56.113" LastActivityDate="2018-04-17T21:04:56.113" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15957" PostTypeId="2" ParentId="15919" CreationDate="2018-04-17T23:34:55.593" Score="1" Body="&lt;p&gt;I think it is pasting that messes the format. Have you tried &lt;code&gt;:set paste&lt;/code&gt; before &lt;code&gt;ctrl+shift+v&lt;/code&gt; in the remote vim?&lt;/p&gt;&#xA;" OwnerUserId="8807" LastActivityDate="2018-04-17T23:34:55.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15958" PostTypeId="1" AcceptedAnswerId="15961" CreationDate="2018-04-18T00:11:44.777" Score="0" ViewCount="754" Body="&lt;p&gt;When I have the quickfix window open (e.g. from &lt;code&gt;:grep foo&amp;lt;cr&amp;gt;:cw&lt;/code&gt;) I can go to the window and hit &lt;kbd&gt;Enter&lt;/kbd&gt; and it will open the file under the cursor in an existing buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to open it in a new buffer, besides &lt;code&gt;:split&lt;/code&gt; and then going to the quickfix window?&lt;/p&gt;&#xA;" OwnerUserId="5574" LastActivityDate="2018-04-18T08:00:35.280" Title="How do I open a quickfix result in a new buffer?" Tags="|buffers|quickfix|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15959" PostTypeId="1" CreationDate="2018-04-18T01:11:14.947" Score="3" ViewCount="1277" Body="&lt;p&gt;I am trying to setup my development environment using vim and some plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My workspace root is a directory with very large number of sub-directories and files. I am going to be working on files from a &lt;strong&gt;very very small subset&lt;/strong&gt; of this root directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a simplified overview,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;My workspace root directory ($workspace) contains 1000+ different projects (sub-dirs with lot of sources files, tools and docs)&lt;/li&gt;&#xA;&lt;li&gt;I am working on max 4-5 &quot;projects&quot; inside this workspace at a time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All version control, build and run commands are run at the $workspace root directory. Hence, I want to keep the vim open with its CWD as the workspace root.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use plug-ins such as NerdTree and Ctrl-P, etc. These plugins usually work at a CWD level and try to index/cache contents of the entire $workspace. So, direct usage of them is causing my file navigation to be impossibly slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to set-up a white-listing system (a file called .project or something) at the $workspace root that lists all the directories that I am interested in. I need vim and its plugins to only index or parse the contents of these very few sub-directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could not find a turn-key solution that achieves this. I am willing to write some code to make this work. Any ideas and suggestions are most welcome.&lt;/p&gt;&#xA;" OwnerUserId="17209" LastActivityDate="2018-05-03T15:39:47.113" Title="How to setup vim for working in a very large directory?" Tags="|filesystem|plugin-nerdtree|plugin-ctrlp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15960" PostTypeId="1" CreationDate="2018-04-18T07:41:01.337" Score="2" ViewCount="210" Body="&lt;p&gt;I want to be able to show someone a particular file's undo history in vim, remotely. It's a little complicated, so let me explain one step at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For starters, I can set a custom undofile and rewind to the start of file history:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -c &quot;rundo &amp;lt;undofile&amp;gt;&quot; -c &quot;earlier 9999d&quot; &amp;lt;text_file&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've packaged both files (&lt;code&gt;undofile&lt;/code&gt; and &lt;code&gt;text_file&lt;/code&gt;) into a tar archive and uploaded those to a web server. Now, I can have someone load the files into vim with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ wget -q -O - &amp;lt;tar_archive_url&amp;gt; | tar xf - &amp;amp;&amp;amp; vim -c &quot;rundo &amp;lt;undofile&amp;gt;&quot; &amp;lt;text_file&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this isn't quite what I want — it actually extracts the files to the user's working directory, so now they have to &lt;code&gt;rm&lt;/code&gt; them when they're done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like is a way to read both the text file and the undofile directly from the command line (via STDIN, process substitution, or some other magic) to achieve the same effect as the command above without littering the user's working directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that vim can read a file from STDIN:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wget -q -O - &amp;lt;tar_archive_url&amp;gt; | tar -x &amp;lt;text_file&amp;gt; -f - -O | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but assigning the undofile (with &lt;code&gt;rundo&lt;/code&gt;) is an internal vim command, not a shell command. Is there any way to get vim to &lt;code&gt;rundo&lt;/code&gt; from STDIN / process substitution / etc rather than a literal file?&lt;/p&gt;&#xA;" OwnerUserId="2593" LastActivityDate="2018-04-18T07:41:01.337" Title="Bash process substitution on vim command line?" Tags="|command-line|bash|undo-redo|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15961" PostTypeId="2" ParentId="15958" CreationDate="2018-04-18T08:00:35.280" Score="1" Body="&lt;p&gt;see &lt;code&gt;switchbuf&lt;/code&gt; option, see:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h switchbuf&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you may setup switchbuf as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set switchbuf=useopen,split&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9681" LastActivityDate="2018-04-18T08:00:35.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15963" PostTypeId="2" ParentId="15950" CreationDate="2018-04-18T08:30:12.917" Score="2" Body="&lt;p&gt;You've explained in a comment your requirements:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have many occurrences of the pattern {ab] in the file, where a and be a numbers between 0-9, I want to change each such occurrence to [ab], and ignore the myriad occurrences of {'s that occur on the same lines as the {ab]'s.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This expression only includes two digits &lt;code&gt;\d&lt;/code&gt; between the &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; characters and ends the match with &lt;code&gt;\ze&lt;/code&gt; after the opening &lt;code&gt;{&lt;/code&gt; so that the rest of the expression isn't replaced:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/{\ze\d\d]/[/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you instead want it to match any number of digits, use a non-greedy repeat &lt;code&gt;\{-}&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/{\ze\d\{-}]/[/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can also help explain why what you were trying doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:global&lt;/code&gt; command simply runs the following command on all the matching lines. It &lt;em&gt;doesn't&lt;/em&gt; specifically place the cursor at the position of the match. If you must, it's better to imagine it placing it at the start of the line, because that's how &lt;code&gt;:g//normal&lt;/code&gt; works, (e.g. Try something like &lt;code&gt;:g/a/norm f1x&lt;/code&gt; and see that it deletes the first &lt;code&gt;1&lt;/code&gt; character after the first character on the line: not the first after an &lt;code&gt;a&lt;/code&gt; character,) but see &lt;code&gt;:help :global&lt;/code&gt; for an explanation of how the command &lt;em&gt;actually&lt;/em&gt; functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And regardless of the above, the substitute command ignores cursor position anyway. If you use the &lt;code&gt;g&lt;/code&gt; flag, it acts on all matches on the line, and if you omit it, it acts only on the first match &lt;em&gt;on the line&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-04-18T13:51:08.613" LastActivityDate="2018-04-18T13:51:08.613" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15964" PostTypeId="1" AcceptedAnswerId="15965" CreationDate="2018-04-18T08:39:41.993" Score="0" ViewCount="91" Body="&lt;p&gt;I have 2 ways to open a file for editing:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:b &amp;lt;filename&amp;gt;&lt;/code&gt; to switch to an opened buffer -- imagine that I have a lot of folders containing &lt;code&gt;index.html&lt;/code&gt; so by using &lt;code&gt;:b&lt;/code&gt; I know I am working on the one that I should be working on.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fuzzy File Search (&lt;code&gt;:FZF&lt;/code&gt;) just in case I haven't opened the file or I have killed the buffer with &lt;code&gt;:bd&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question:&lt;/strong&gt; Is there a way to automate, such that if &lt;code&gt;:b &amp;lt;filename&amp;gt;&lt;/code&gt; fails (E94: No matching buffer), nvim will call &lt;code&gt;:FZF&lt;/code&gt; and use &lt;code&gt;&amp;lt;filename&amp;gt;&lt;/code&gt; to search?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. It'd be best if I used &lt;code&gt;:b107&lt;/code&gt; and I mistyped the number, &lt;code&gt;FZF&lt;/code&gt; will not be triggered. (distinguishing cases whether I use &lt;code&gt;:b&lt;/code&gt; with string or number)&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2018-04-19T08:31:28.083" Title="How to add a fallback when :b buffer change fails" Tags="|buffers|the-silver-searcher|plugin-fzf|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15965" PostTypeId="2" ParentId="15964" CreationDate="2018-04-18T09:15:55.987" Score="1" Body="&lt;p&gt;You can't change the way the &lt;code&gt;:b&lt;/code&gt; command works, but you can create an alternative &lt;code&gt;:B&lt;/code&gt; command, and then create an abbreviation to always use the &lt;code&gt;:B&lt;/code&gt; command when you type &lt;code&gt;:b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The below works by first trying using the &lt;code&gt;:b&lt;/code&gt; command, and if the E94 error is thrown, doing a &lt;code&gt;:FZF&lt;/code&gt; instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BWithFallback(buffer_name) abort&#xA;  &quot; Check if the input is a number or a string&#xA;  if a:buffer_name =~# '^\d\+$'&#xA;    execute 'b' a:buffer_name&#xA;  else&#xA;    try&#xA;      &quot; Try opening the buffer&#xA;      execute 'b' a:buffer_name&#xA;    catch /E94/&#xA;      &quot; If the buffer didn't exist, try doing a fuzzy file search&#xA;      &quot; using the command provided by the OP.&#xA;      execute 'FZF -q' a:buffer_name&#xA;    endtry&#xA;  endif&#xA;endfunction&#xA;&#xA;&quot; Create new :B command. You could also use -complete=file if you prefer&#xA;command! -nargs=1 -complete=buffer B call BWithFallback('&amp;lt;args&amp;gt;')&#xA;&#xA;&quot; When you type :b, replace it with :B&#xA;cnoreabbrev &amp;lt;expr&amp;gt; b (getcmdtype() == ':' &amp;amp;&amp;amp; getcmdline() ==# 'b') ? 'B' : b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-04-19T08:31:28.083" LastActivityDate="2018-04-19T08:31:28.083" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15966" PostTypeId="1" AcceptedAnswerId="15995" CreationDate="2018-04-18T11:07:04.843" Score="6" ViewCount="1204" Body="&lt;p&gt;After starting neovim with &lt;code&gt;nvim -u NONE&lt;/code&gt;,&#xA;why do the following commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:term&#xA;:au BufWinEnter,WinEnter &amp;lt;buffer&amp;gt; startinsert&#xA;:tabnew&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;leave me in &lt;strong&gt;insert&lt;/strong&gt; mode in the new tab, and how can I avoid that? The same behaviour happens when replacing &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; by &lt;code&gt;term://*&lt;/code&gt;, as in the answer provided &lt;a href=&quot;https://vi.stackexchange.com/questions/3670/how-to-enter-insert-mode-when-entering-neovim-terminal-pane/3765#comment27385_3765&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11125" LastEditorUserId="11125" LastEditDate="2018-04-25T22:45:06.253" LastActivityDate="2018-04-25T22:45:06.253" Title="Strange behaviour of autocmd" Tags="|autocmd|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15967" PostTypeId="1" AcceptedAnswerId="15979" CreationDate="2018-04-18T16:27:49.907" Score="5" ViewCount="1001" Body="&lt;p&gt;I just found out about this option in vim !!! &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:lisp_rainbow = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's pretty exciting to learn something so useful. I can't figure out how to customize it though. Specially, I want to expel the prominent red colored parenthesis out of the available options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can do it with some plugins. But there are so many, and few (two actually) of which I tried did not work as expected. Bear in mind, I don't particularly want this rainbow parenthesis functionality for any other filetypes except &lt;code&gt;lisp&lt;/code&gt;. So, I would be happy with stock options, no plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how do I customize this option in [neo]vim.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-27T04:17:33.943" LastActivityDate="2019-05-08T08:30:57.190" Title="Rainbow Parenthesis for Lisp in Vim" Tags="|filetype-lisp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15968" PostTypeId="1" CreationDate="2018-04-18T18:06:30.150" Score="5" ViewCount="2684" Body="&lt;p&gt;This question is very basic, but somehow absurdly difficult to find an answer for, because everything you find explains how to save the buffer, and I'm not interested in making new buffers or saving the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had been using (for years!) some pretty ugly code that requires vim to be built with python in order to work: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if has('python')&#xA;        python &amp;lt;&amp;lt; EOF&#xA;from os.path import expanduser&#xA;f = open('/path/to/file', 'w')&#xA;# print f&#xA;w = vim.eval(&quot;varname&quot;)&#xA;f.write(w)&#xA;f.close()&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That snippet uses the simple-to-use python file api to write the contents of vim variable &lt;code&gt;varname&lt;/code&gt; into &lt;code&gt;/path/to/file&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-08-16T20:00:53.027" Title="How to write a value or variable into a file using only vimscript?" Tags="|save|filesystem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15969" PostTypeId="2" ParentId="15968" CreationDate="2018-04-18T18:06:30.150" Score="8" Body="&lt;p&gt;&lt;code&gt;writefile()&lt;/code&gt; is the ticket, but has some quirks you have to account for, such as splitting on newlines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call writefile(split(varname, &quot;\n&quot;, 1), glob('/path/to/file'), 'b')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-04-18T18:06:30.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15970" PostTypeId="2" ParentId="11301" CreationDate="2018-04-18T18:09:45.373" Score="0" Body="&lt;p&gt;The accepted answer is absolutely correct - these features are fixed from compile time. If installing a heavier build is not an option, however, and depending on what a user wants/needs, one may be able to approximate the &lt;code&gt;clipboard&lt;/code&gt; feature using &lt;code&gt;:read&lt;/code&gt;/&lt;code&gt;system()&lt;/code&gt; and their system's tool for manipulating the clipboard (&lt;code&gt;xsel&lt;/code&gt; on Linux, &lt;code&gt;pbcopy&lt;/code&gt;/&lt;code&gt;pbpaste&lt;/code&gt; on macOS, &lt;code&gt;putclip&lt;/code&gt;/&lt;code&gt;getclip&lt;/code&gt; on cygwin, etc.).&lt;/p&gt;&#xA;" OwnerUserId="14684" LastActivityDate="2018-04-18T18:09:45.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15972" PostTypeId="1" CreationDate="2018-04-18T19:09:49.507" Score="1" ViewCount="245" Body="&lt;p&gt;Inside of a variable, a newline is encoded as &lt;code&gt;^@&lt;/code&gt; which represents a null byte. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the vim Ex &lt;em&gt;command line&lt;/em&gt; it is possible to issue something like &lt;code&gt;substitute(var, '^@', '\\n', 'g')&lt;/code&gt;, this produces &lt;code&gt;\n&lt;/code&gt; instead which can be passed to e.g. bash cleanly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, putting this into a function inside my vimrc breaks horribly with a missing quote E115, so I have to escape it somehow, but I cannot figure out how. &lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-05-18T19:30:53.837" Title="Convert newline to something else in variable using substitute" Tags="|vimscript|functions|line-breaks|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15973" PostTypeId="2" ParentId="15972" CreationDate="2018-04-18T19:14:24.340" Score="2" Body="&lt;p&gt;I've figured out that &lt;code&gt;'\n'&lt;/code&gt; can be used in &lt;code&gt;substitute()&lt;/code&gt; to refer to the null byte which is used internally to represent an end of line. This solved my problem.&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-04-18T19:14:24.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15974" PostTypeId="1" AcceptedAnswerId="15975" CreationDate="2018-04-18T19:56:50.347" Score="3" ViewCount="2458" Body="&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have several lines starting with &lt;code&gt;:q:&lt;/code&gt;, which I want to jump to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:q: regex syntax&#xA;(...)&#xA;:q: regex examples&#xA;(...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to jump to the start of &lt;code&gt;regex syntax&lt;/code&gt; or &lt;code&gt;regex example&lt;/code&gt; with a specific regex find expression via &lt;code&gt;/&lt;/code&gt;. Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why not just use &lt;code&gt;W&lt;/code&gt; to jump to it? Well, it would just be nice to jump to each expression with the use of &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2018-04-27T10:24:32.317" Title="How to do a find with a regex and jump to a specific position within the match" Tags="|regular-expression|find|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15975" PostTypeId="2" ParentId="15974" CreationDate="2018-04-18T20:53:04.363" Score="5" Body="&lt;p&gt;You can use &lt;code&gt;\zs&lt;/code&gt; (and it's complement, &lt;code&gt;\ze&lt;/code&gt;), e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/:q: \zs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should work for your example (assuming there is exactly 1 space after the second &lt;code&gt;:&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works by setting the start (or end in the case of &lt;code&gt;\ze&lt;/code&gt;) of the matching text to a point somewhere in the middle of the regex. Check out &lt;code&gt;:h \zs&lt;/code&gt;, it has a much better description than I can give, with additional examples.&lt;/p&gt;&#xA;" OwnerUserId="16910" LastActivityDate="2018-04-18T20:53:04.363" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15976" PostTypeId="2" ParentId="15520" CreationDate="2018-04-19T00:03:15.623" Score="0" Body="&lt;p&gt;Surprisingly, the problem had nothing to do with the command listed in the question. &lt;strong&gt;Apparently, the order of the commands in &lt;code&gt;.vimrc&lt;/code&gt; matters&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I moved the mapping to the top of the file and it worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps others while the downvoters continue their greedy search for more points.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: It is no longer at the top of the vimrc however at the time it seemed like something else was interfering with it.&lt;/p&gt;&#xA;" OwnerUserId="7703" LastEditorUserId="7703" LastEditDate="2018-05-23T23:39:53.777" LastActivityDate="2018-05-23T23:39:53.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15977" PostTypeId="1" AcceptedAnswerId="15978" CreationDate="2018-04-19T03:09:07.597" Score="0" ViewCount="214" Body="&lt;p&gt;In cjk characters set, full width space has the unicode value is U+3000, the english space unicode (half width space) value is U+0020.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to input full width space in Vim?   &lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="51" LastEditDate="2018-08-22T16:56:19.347" LastActivityDate="2018-08-22T16:56:19.347" Title="How to input full width spacewhite in vim?" Tags="|unicode|digraphs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="15978" PostTypeId="2" ParentId="15977" CreationDate="2018-04-19T03:29:56.483" Score="1" Body="&lt;p&gt;The digraph for &lt;code&gt;U+3000&lt;/code&gt; is &lt;code&gt;IS&lt;/code&gt;, which you can enter with &lt;code&gt;CTRL-K IS&lt;/code&gt;.  If you prefer to use a different digraph, you can assign one with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dig ?? 12288&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;12288 is the decimal equivalent of 0x3000.  Or, you can make a map, e.g.,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-l&amp;gt; &amp;lt;c-k&amp;gt;IS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can enter arbitrary unicode using &lt;code&gt;CTRL-V u3000&lt;/code&gt; (see &lt;code&gt;:help i_CTRL-V_digit&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-04-19T03:29:56.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15979" PostTypeId="2" ParentId="15967" CreationDate="2018-04-19T04:16:11.270" Score="3" Body="&lt;p&gt;I assume when you say &quot;customize&quot; you don't mean anything besides changing the parentheses colors. Look in &lt;code&gt;$VIMRUNTIME/syntax/lisp.vim&lt;/code&gt; and search for &quot;lisp_rainbow&quot; and you'll find this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   if &amp;amp;bg == &quot;dark&quot;&#xA;    hi def hlLevel0 ctermfg=red         guifg=red1&#xA;    hi def hlLevel1 ctermfg=yellow      guifg=orange1&#xA;    hi def hlLevel2 ctermfg=green       guifg=yellow1&#xA;    hi def hlLevel3 ctermfg=cyan        guifg=greenyellow&#xA;    hi def hlLevel4 ctermfg=magenta     guifg=green1&#xA;    hi def hlLevel5 ctermfg=red         guifg=springgreen1&#xA;    hi def hlLevel6 ctermfg=yellow      guifg=cyan1&#xA;    hi def hlLevel7 ctermfg=green       guifg=slateblue1&#xA;    hi def hlLevel8 ctermfg=cyan        guifg=magenta1&#xA;    hi def hlLevel9 ctermfg=magenta     guifg=purple1&#xA;   else&#xA;    hi def hlLevel0 ctermfg=red         guifg=red3&#xA;    hi def hlLevel1 ctermfg=darkyellow  guifg=orangered3&#xA;    hi def hlLevel2 ctermfg=darkgreen   guifg=orange2&#xA;    hi def hlLevel3 ctermfg=blue        guifg=yellow3&#xA;    hi def hlLevel4 ctermfg=darkmagenta guifg=olivedrab4&#xA;    hi def hlLevel5 ctermfg=red         guifg=green4&#xA;    hi def hlLevel6 ctermfg=darkyellow  guifg=paleturquoise3&#xA;    hi def hlLevel7 ctermfg=darkgreen   guifg=deepskyblue4&#xA;    hi def hlLevel8 ctermfg=blue        guifg=darkslateblue&#xA;    hi def hlLevel9 ctermfg=darkmagenta guifg=darkviolet&#xA;   endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So just override whatever colors you want. This command will change the first level of red to blue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi hlLevel0 ctermfg=blue guifg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't know if you can just put this line in your vimrc...it may depend on what order things are loaded, when/where you set g:lisp_rainbow, etc. Worse comes to worst, you could add an &lt;code&gt;autocommand&lt;/code&gt; for filetype lisp in vimrc and add your overrides to that.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-04-19T04:23:42.007" LastActivityDate="2018-04-19T04:23:42.007" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15980" PostTypeId="1" CreationDate="2018-04-19T08:30:15.420" Score="0" ViewCount="138" Body="&lt;p&gt;In my .vimrc,f5 was binded with CheckMark function to change all &lt;code&gt;。&lt;/code&gt; into &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CheckMark()  &#xA;    if search('。')  &#xA;        let s:line=search('。')  &#xA;        execute s:line . &quot;s/。/\./g&quot; &#xA;    endif   &#xA;endfunction  &#xA;&#xA;map &amp;lt;F5&amp;gt; :call CheckMark()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to  color the selected  character &lt;code&gt;。&lt;/code&gt; with red ,instead of changing it?   &lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="343" LastEditDate="2018-04-23T14:37:52.690" LastActivityDate="2018-04-23T14:37:52.690" Title="How to color the selected character with red instead of changing it?" Tags="|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15981" PostTypeId="2" ParentId="15980" CreationDate="2018-04-19T09:01:11.897" Score="1" Body="&lt;p&gt;You can use the &lt;code&gt;:match&lt;/code&gt; command to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight CheckMark ctermfg=red guifg=red&#xA;:match CheckMark /。/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want this highlighting only to occur when you invoke your mapping, you can replace the contents of your &lt;code&gt;CheckMark()&lt;/code&gt; function with the &lt;code&gt;:match&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :match&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-04-19T09:01:11.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15982" PostTypeId="2" ParentId="15916" CreationDate="2018-04-19T10:02:21.283" Score="3" Body="&lt;p&gt;I guess mouse clicks don't update the jump list. (&lt;code&gt;:help jump-motions&lt;/code&gt; seems to confirm this is the case.)&lt;/p&gt;&#xA;&lt;p&gt;Try this, for the async solution:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup MouseHack&#xA;  autocmd!&#xA;  autocmd FocusLost * set mouse=&#xA;  autocmd FocusGained * call timer_start(200, 'ReenableMouse')&#xA;augroup END&#xA;&#xA;function ReenableMouse(timer_id)&#xA;  set mouse=a&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that this requires the &lt;code&gt;+timers&lt;/code&gt; feature, introduced in v7.4.1578. If you're likely to be running an earlier version of Vim, you'll want to surround all the above with a &lt;code&gt;if has('timers')&lt;/code&gt; guard.&lt;/p&gt;&#xA;&lt;p&gt;As of &lt;a href=&quot;https://github.com/vim/vim/commit/a48d4e44a24191f5495e17d7616771c20ae3e3c1&quot; rel=&quot;nofollow noreferrer&quot;&gt;v8.2.3761&lt;/a&gt;, this will also work in terminal Vim.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2023-06-09T09:26:03.753" LastActivityDate="2023-06-09T09:26:03.753" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="15984" PostTypeId="2" ParentId="15575" CreationDate="2018-04-19T13:40:19.220" Score="1" Body="&lt;p&gt;The default gvim menus are located at $VIMRUNTIME/menu.vim. You can copy this file into your local vim settings, disable loading of the default menus with &lt;code&gt;:let did_install_default_menus=1&lt;/code&gt; in your .vimrc (see &lt;code&gt;:help menu.vim&lt;/code&gt;), and then source the copy which you will edit. You'll notice that the commands to add the Help menus (like &lt;code&gt;:an 9999.10 &amp;amp;Help.&amp;amp;Overview&amp;lt;Tab&amp;gt;&amp;lt;F1&amp;gt; :help&amp;lt;CR&amp;gt;&lt;/code&gt;) have ampersands before the 'H' in 'Help'; this ampersand decides shortcut keys. You could then change the shortcut key, or remove it altogether while still retaining the Help menu. &lt;/p&gt;&#xA;" OwnerUserId="14684" LastActivityDate="2018-04-19T13:40:19.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15986" PostTypeId="2" ParentId="15575" CreationDate="2018-04-19T14:26:17.773" Score="1" Body="&lt;p&gt;&lt;code&gt;Alt&lt;/code&gt; key is in competition between mappings and menus. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To choose which one has the priority, you'll need to set &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27winaltkeys%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'winaltkeys'&lt;/code&gt;&lt;/a&gt;. Set it to &lt;code&gt;no&lt;/code&gt; in order to completely ignore menu alt-shortcuts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution is less intrusive than the one where menu bar is completely removed. The menu is still displayed, we just loose the shortcuts.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-04-19T16:30:58.500" LastActivityDate="2018-04-19T16:30:58.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15987" PostTypeId="1" AcceptedAnswerId="15992" CreationDate="2018-04-19T16:07:15.613" Score="1" ViewCount="1454" Body="&lt;p&gt;I write using LaTeX a lot for scientific writing. I often need to modify some text that includes numbers and units like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4.2 cm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\SI{4.2}{cm}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to be properly typeset by LaTeX. Of course, the exact number and unit can change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know a &quot;magic&quot; command I can do that—when &lt;code&gt;4.2 cm&lt;/code&gt; is highlighted in visual mode—will change to the &lt;code&gt;\SI{4.2}{cm}&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the magic here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make this particularly useful, I'd like to have the substitution take place, but leave the curser at the beginning of the units with the units visually selected. I have to do additional formatting of the units that can't be done automatically with a simple mapping; I have to touch it up at the end.&lt;/p&gt;&#xA;" OwnerUserId="7213" LastEditorUserId="7213" LastEditDate="2018-04-19T21:29:02.440" LastActivityDate="2018-04-20T20:40:12.213" Title="How to change highlighted text?" Tags="|visual-mode|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15988" PostTypeId="2" ParentId="15959" CreationDate="2018-04-19T16:51:26.483" Score="2" Body="&lt;p&gt;It is possible using the &lt;a href=&quot;https://github.com/justinmk/vim-dirvish&quot; rel=&quot;nofollow noreferrer&quot;&gt;dirvish&lt;/a&gt; file explorer, which by the way is much faster than the native netrw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin allows to manipulate the content of its buffer (see &quot;How do I filter&quot; in &lt;code&gt;:h dirvish-faq&lt;/code&gt;) and has an option to automatically execute a command. Keep in mind that it operates on the full path and directories have trailing slashes, so to keep everything starting with &quot;a&quot; or ending with &quot;z&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:dirvish_mode = ':silent keeppatterns g!/a[^/]*\/$\|.*z\/$/d _'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this example, &lt;code&gt;:global!&lt;/code&gt; is used to reverse the search and &lt;code&gt;d&lt;/code&gt; to delete the matching lines. The patterns are not thoroughly tested but it seems to work:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;a[^/]*\/$&lt;/code&gt; looks for &quot;a&quot; followed by anything but a slash before the last &quot;/&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\|&lt;/code&gt; OR&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*z\/$&lt;/code&gt; looks for anything ending with &quot;z/&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://stackoverflow.com/q/18932012/7796750&quot;&gt;How to load different .vimrc file for different working directory?&#xA;&lt;/a&gt; to set this option based on the current working directory (but you might want it only if the opened directory matches the CWD).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, take a look at the end of &lt;a href=&quot;https://vi.stackexchange.com/a/13286/12003&quot;&gt;this answer&lt;/a&gt; about editing large projects and how to optimize ctrlp.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2018-04-19T16:51:26.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15990" PostTypeId="2" ParentId="1942" CreationDate="2018-04-19T17:33:19.640" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;AsyncRun&lt;/a&gt; plugin if designed for this, it allows you to run shell commands in the background in Vim8/NeoVim and display the output in the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just as a replacement of &lt;code&gt;!&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:AsyncRun ls -la /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also hide the output in quickfix window completely:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:AsyncRun -mode=3 ls -la /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When job finished, AsyncRun will notify you by passing an option &lt;code&gt;-post&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:AsyncRun -post=some_vim_script   ls -la /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The vim script defined by &lt;code&gt;-post&lt;/code&gt; will be executed after job finished.&lt;/p&gt;&#xA;" OwnerUserId="9681" LastActivityDate="2018-04-19T17:33:19.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15991" PostTypeId="2" ParentId="5921" CreationDate="2018-04-19T20:01:08.753" Score="7" Body="&lt;p&gt;The fugitive &lt;code&gt;Git checkout &amp;lt;branch&amp;gt;&lt;/code&gt; has a downside that it doesn't autocomplete the branch name. Using &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;noreferrer&quot;&gt;fzf.vim&lt;/a&gt; I've created this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:changebranch(branch) &#xA;    execute 'Git checkout' . a:branch&#xA;    call feedkeys(&quot;i&quot;)&#xA;endfunction&#xA;&#xA;command! -bang Gbranch call fzf#run({&#xA;            \ 'source': 'git branch -a --no-color | grep -v &quot;^\* &quot; ', &#xA;            \ 'sink': function('s:changebranch')&#xA;            \ })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;hope you find it useful&lt;/p&gt;&#xA;" OwnerUserId="17232" LastActivityDate="2018-04-19T20:01:08.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15992" PostTypeId="2" ParentId="15987" CreationDate="2018-04-19T20:09:49.540" Score="1" Body="&lt;p&gt;You could try the following to use &lt;kbd&gt;F1&lt;/kbd&gt; to call your magic function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;F1&amp;gt; c&amp;lt;C-R&amp;gt;=substitute(@&quot;, '\v(\S+)\s+(\S+)', '\\SI{\1}{\2}', '')&amp;lt;CR&amp;gt;&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Relevant documentation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq%2d20%2e17&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help faq-20.17&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#substitute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help substitute()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_%3cC%2dR%3e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help c_&amp;lt;C-R&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Ideas:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you always have a number followed by a unit, you could avoid the visual selection by placing the cursor on the number:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F1&amp;gt; c2aW&amp;lt;C-R&amp;gt;=substitute(@&quot;, '\v(\S+)\s+(\S+)', '\\SI{\1}{\2}', '')&amp;lt;CR&amp;gt;&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if you have a list of known units, you could use a regular &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3as&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:s&lt;/code&gt;&lt;/a&gt; to replace all the occurences:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F2&amp;gt; :%s/\v\C(\S+)\s+(km&amp;lt;bar&amp;gt;m&amp;lt;bar&amp;gt;cm&amp;lt;bar&amp;gt;mm)&amp;gt;/\\SI{\1}{\2}/gc&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(in this case you could tune the regular expression - e.g: checking for a number with or without decimal separator instead of selecting non-space characters before the units)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#E76&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help pattern&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#map%2dbar&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help map-bar&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;1) I've tried changing the command from F1 to CTRL-s by using , but the mapping no longer works. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've tried in gVim and it worked fine. I guess you are using Vim in terminal, where it is very likely it won't work.&#xA;Check the following FAQs for more info:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq%2d20%2e5&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help faq-20.5&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq%2d20%2e4&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help faq-20.4&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2) Is it possible to—after the substitution is done—to leave the curser at the beginning of the units (and have the units visually selected)? I've updated my question to reflect 2).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You just have to appending the commands to that mapping as needed. In this case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;F1&amp;gt; c&amp;lt;C-R&amp;gt;=substitute(@&quot;, '\v(\S+)\s+(\S+)', '\\SI{\1}{\2}', '')&amp;lt;CR&amp;gt;&amp;lt;ESC&amp;gt;vb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2018-04-20T12:09:39.190" LastActivityDate="2018-04-20T12:09:39.190" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15994" PostTypeId="2" ParentId="15987" CreationDate="2018-04-20T00:19:20.463" Score="1" Body="&lt;p&gt;The first answer is perfectly fine but I think it's worth mentioning use of a macro with Normal mode commands as an alternative. One Normal mode command sequence to do the formatting &lt;em&gt;and&lt;/em&gt; leave the units visually selected is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i\SI{&amp;lt;Esc&amp;gt;f s}{&amp;lt;Esc&amp;gt;Ea}&amp;lt;Esc&amp;gt;2T{vt}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put the cursor on the first character of the units before executing this. Here &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; means hit the &lt;kbd&gt;Esc&lt;/kbd&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To record it as a macro in register &quot;q&quot; first enter &lt;code&gt;qq&lt;/code&gt; and end the sequence with &lt;code&gt;q&lt;/code&gt;. Then you can put the cursor on an occurrence and do &lt;code&gt;@q&lt;/code&gt; to rerun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll surely want to make this reusable. You could save the macro in your vimrc...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @q=&quot;i\\SI{\&amp;lt;Esc&amp;gt;f s}{\&amp;lt;Esc&amp;gt;Ea}\&amp;lt;Esc&amp;gt;2T{vt}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; is literally those five characters, starting with &lt;kbd&gt;&amp;lt;&lt;/kbd&gt;. Don't forget the backslash that precedes these and note the double quotes that surround everything. Even easier: copy/paste the whole line from here to your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;But&lt;/em&gt; at this point it probably makes more sense to put the command sequence in a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F1&amp;gt; i\SI{&amp;lt;Esc&amp;gt;f s}{&amp;lt;Esc&amp;gt;Ea}&amp;lt;Esc&amp;gt;2T{vt}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No escaping of &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; or &lt;code&gt;\&lt;/code&gt; needed here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Here's a mapping with an improved version of the command sequence:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F1&amp;gt; i\SI{&amp;lt;C-O&amp;gt;W&amp;lt;BS&amp;gt;}{&amp;lt;C-O&amp;gt;E&amp;lt;Right&amp;gt;}&amp;lt;Esc&amp;gt;2T{vt}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This eliminates two of the three &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; by using &lt;code&gt;ctrl-o&lt;/code&gt;. That allows the whole thing to be undone with a single &lt;code&gt;u&lt;/code&gt;. (And, as a positive side effect, it may also seem to run faster if you are on a slow machine.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-04-20T20:40:12.213" LastActivityDate="2018-04-20T20:40:12.213" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15995" PostTypeId="2" ParentId="15966" CreationDate="2018-04-20T03:40:11.650" Score="3" Body="&lt;p&gt;The culprit appears to be the WinEnter autocmd, which is apparently being triggered with the buffer you left and not the one you entered. To demonstrate, you can set up an autocmd like this to print the name of the buffer the WinEnter command was run on, or 'unnamed buffer' if it has no name. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup Testingautocmd!&#xA;    autocmd WinEnter * echom (empty(expand('&amp;lt;amatch&amp;gt;'))? 'unnamed buffer' : expand('&amp;lt;amatch&amp;gt;'))&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To see the output when running &lt;code&gt;:tabnew&lt;/code&gt;, &lt;code&gt;:new&lt;/code&gt;, and &lt;code&gt;:vnew&lt;/code&gt;, you'll need to run &lt;code&gt;:messages&lt;/code&gt;, as vim annoyingly overwrites the commandline with a blank line for those commands (that's why I used &lt;code&gt;:echom[sg]&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By checking the messages you can see that when &lt;code&gt;:tabnew&lt;/code&gt;, &lt;code&gt;:new&lt;/code&gt; or &lt;code&gt;:vnew&lt;/code&gt; is run we get the name of the last buffer (in your case a terminal code) instead of 'unnamed buffer' like you'd expect, so it appears that vim still thinks it's in the old buffer when it runs the WinEnter command, and so erronously triggers &lt;code&gt;:startinsert&lt;/code&gt; on the new file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for how to fix it, triggering the autocmd on BufEnter will work most of the time (as you already know), except for the case of switching between two windows both containing the same terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's buffers are it's abstraction of files. Windows are simply areas of the screen that offer a view onto a buffer. All windows showing the same file are views of parts of the same buffer - this includes windows in different tabs, as vim tabs are just collections of windows. So WinLeave and WinEnter completely ignore what's in any buffer and are fired everytime you move between two different windows. The BufLeave and BufEnter completely ignore whether you move windows and are fired only when vim changes the buffer you're currently editing (it calls this the current file and it's the one who's name you can use as &lt;code&gt;%&lt;/code&gt; on the commandline, see &lt;code&gt;:h current-file&lt;/code&gt;). So typically when switching between two windows which have different files open, both BufLeave/Enter and WinLeave/Enter get called (both of their conditions are satisfied). BufWinLeave/BufWinEnter gets triggered when a window changes the buffer it's viewing. Commands like &lt;code&gt;:e&lt;/code&gt; and &lt;code&gt;:b&lt;/code&gt; usually trigger this. &lt;code&gt;:e&lt;/code&gt; and &lt;code&gt;:b&lt;/code&gt; also usually trigger BufLeave/Enter, but not WinLeave/Enter; although the current window hasn't changed, the current file has (BufLeave/Enter) and the file displayed in the current window has (BufWinLeave/Enter). You can look at these commands being executed by getting them to echo messages everytime they are fired (like my example above), to see what happens whereever you're unsure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence by triggering startinsert on BufEnter you get into insert mode whenever the current buffer switches to a terminal, which I assume is almost always what you want. As I mentioned, it breaks when you have to windows both viewing the same terminal buffer and you switch between those; the current file does not change and so BufEnter is never triggered.&lt;/p&gt;&#xA;" OwnerUserId="16910" LastActivityDate="2018-04-20T03:40:11.650" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15997" PostTypeId="1" AcceptedAnswerId="16000" CreationDate="2018-04-20T07:43:50.320" Score="1" ViewCount="2934" Body="&lt;p&gt;I set up my &lt;code&gt;.vimrc&lt;/code&gt; so that NERDTree automatically shows up on the left when opening vim for editing a file (&lt;code&gt;autocmd VimEnter * NERDTree&lt;/code&gt;). This means, that NERDTree is the active buffer instead, and I have to press &lt;code&gt;&amp;lt;C-w&amp;gt;w&lt;/code&gt; every time to focus on the file I want to edit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this automatically? &lt;/p&gt;&#xA;" OwnerUserId="16700" LastEditorUserId="16700" LastEditDate="2018-04-20T08:12:56.827" LastActivityDate="2019-04-04T07:03:31.317" Title="Change buffer focus on enter?" Tags="|buffers|plugin-nerdtree|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15998" PostTypeId="2" ParentId="15928" CreationDate="2018-04-20T07:49:16.053" Score="3" Body="&lt;p&gt;Okay, I'm blind shooting here, but here are some ideas&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You have older vim version than 6.&lt;/li&gt;&#xA;&lt;li&gt;The remote file is not readable&lt;/li&gt;&#xA;&lt;li&gt;No space left on the local device.&lt;/li&gt;&#xA;&lt;li&gt;Local firewall blocks the outgoing connection&lt;/li&gt;&#xA;&lt;li&gt;Remote firewall blocks the connection&lt;/li&gt;&#xA;&lt;li&gt;Your ssh public key is not in the &lt;code&gt;authorized_keys&lt;/code&gt; file on remote&lt;/li&gt;&#xA;&lt;li&gt;Your local ssh keys are not in the default folder &lt;code&gt;.ssh&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You may want to debug your ssh connection first with &lt;code&gt;ssh xy@remote -vvv&lt;/code&gt; to find out if the connection can be established. &lt;/p&gt;&#xA;" OwnerUserId="16700" LastEditorUserId="16700" LastEditDate="2018-04-20T08:15:10.033" LastActivityDate="2018-04-20T08:15:10.033" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15999" PostTypeId="1" CreationDate="2018-04-20T08:06:10.440" Score="2" ViewCount="77" Body="&lt;p&gt;I am using &lt;code&gt;foldmethod=indent&lt;/code&gt; when working on Python files. This is generally ok. However when I unfold a function, I would like the docstring to stay folded even though it is at the same indent level as the rest of the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def f(x):&#xA;    &quot;&quot;&quot;This is my docstring, lets indent a useful equation the function&#xA;    is used to calculate:&#xA;        f(x) = x.&#xA;    When opening one fold level, this docstring should stay folded.&#xA;    &quot;&quot;&quot;&#xA;&#xA;    return x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My unfolding would then go as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Starting view when all folds active.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def f(x):&#xA;+-- 7 lines: &quot;&quot;&quot;This is my docstring, lets indent a useful equation the function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2) Opening of the fold keeps the docstring folded despite being same indent level as rest of the function body.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def f(x):&#xA;+-- 6 lines: &quot;&quot;&quot;This is my docstring, lets indent a useful equation the function&#xA;    return x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3155" LastActivityDate="2018-04-20T08:06:10.440" Title="Extra fold of docstring when using foldmethod=indent" Tags="|folding|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16000" PostTypeId="2" ParentId="15997" CreationDate="2018-04-20T08:33:16.730" Score="9" Body="&lt;p&gt;You can change your autocommand to execute &lt;code&gt;&amp;lt;c-w&amp;gt;w&lt;/code&gt; after executing &lt;code&gt;NERDTree&lt;/code&gt;. To do so you can use &lt;code&gt;wincmd&lt;/code&gt; which is the equivalent of pressing &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; but with a command (see &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3awincmd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :wincmd&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! VimEnter * NERDTree | wincmd w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-04-04T07:03:31.317" LastActivityDate="2019-04-04T07:03:31.317" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16002" PostTypeId="1" CreationDate="2018-04-20T09:35:26.043" Score="1" ViewCount="399" Body="&lt;p&gt;When I get the results of a search (whether via &lt;code&gt;:cw&lt;/code&gt; or the &lt;code&gt;Ack.vim&lt;/code&gt; plugin), it goes into the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then open the file by hitting enter, make changes, and save the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quickfix window is now gone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to zoom through the files one by one, keeping the quickfix open until I'm done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be best if the quickfix window updates with the last search though I'd rather have it stay open with stale data rather than close and force me to re-run the last search manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any tips?&lt;/p&gt;&#xA;" OwnerUserId="17241" LastActivityDate="2018-04-20T09:35:26.043" Title="How to keep results of grep open while saving?" Tags="|quickfix|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16003" PostTypeId="1" AcceptedAnswerId="16009" CreationDate="2018-04-20T09:50:38.097" Score="0" ViewCount="77" Body="&lt;p&gt;My test.txt for this example.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;　  unicode 3000  (whitespace in Chinese mark)&#xA;！  unicode ff01&#xA;＾  unicode ff3e&#xA;～  unicode ff5e &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XvLd6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XvLd6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command can match  whitespace in Chinese mark(&lt;code&gt;u3000&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi! ChineseMark ctermbg=red guibg=red&#xA;match ChineseMark /\%u3000/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Jd3uw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Jd3uw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;！&lt;/code&gt; can be matched with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match ChineseMark /\%uff01/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rw9cU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rw9cU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;＾&lt;/code&gt; can be matched with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match ChineseMark /\%uff3e/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;！&lt;/code&gt; can be matched with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match ChineseMark /\%uff5e/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now i want to match character whose unicode code point is &lt;code&gt;u3000&lt;/code&gt; and characters whose unicode code points are from &lt;code&gt;uff01&lt;/code&gt; till &lt;code&gt;uff5e&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match ChineseMark /[\%u3000\%uff01-\$uff5e]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The expression &lt;code&gt;/[\%u3000\%uff01-\$uff5e]/&lt;/code&gt; can't do the trick,How to express this kind of unicode code points  set in match command?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastActivityDate="2018-04-20T20:03:44.740" Title="How to express an unicode code points set in match command?" Tags="|unicode|matchlist|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16005" PostTypeId="1" CreationDate="2018-04-20T12:34:59.357" Score="1" ViewCount="370" Body="&lt;p&gt;How to execute ahk (AutoHotScripts) scripts using gVim?&lt;/p&gt;&#xA;&lt;p&gt;Let say I have interpreter:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;C:\Program Files\AutoHotkey\AutoHotkey.exe&amp;quot; /ErrorStdOut &amp;quot;d:\ahk\myscript.ahk&amp;quot; 2&amp;gt;&amp;quot;Syntax-Error Log.txt&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;While I am in normal mode in gVim I press &lt;code&gt;leader s&lt;/code&gt;. Screen divides into two windows. New window with Error Stream shows at the bottom. Similar to every IDE behaviour when you run/debug program.&lt;/p&gt;&#xA;&lt;p&gt;Window focus should stay at the window with ahk script. If everything is OK, then ahk script is executed.&lt;/p&gt;&#xA;" OwnerUserId="16328" LastEditorUserId="23502" LastEditDate="2023-03-30T23:43:28.877" LastActivityDate="2023-12-26T01:02:25.260" Title="How to run/debug ahk (AutoHotScripts) scripts using gVim, Vim?" Tags="|gvim|microsoft-windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16006" PostTypeId="2" ParentId="15843" CreationDate="2018-04-20T15:38:35.770" Score="3" Body="&lt;p&gt;I have written my &lt;a href=&quot;https://github.com/cxw42/VimWord&quot; rel=&quot;nofollow noreferrer&quot;&gt;Word add-in&lt;/a&gt; using VBScript regex v5.5 to parse the command.  Feedback and contributions welcome!  As of 2019-02-15, the add-in works in Word 2007&amp;ndash;2016.  &lt;strong&gt;Edit&lt;/strong&gt;  As of 2020-02-13, 64-bit Word is also supported.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am largely following the model in &lt;a href=&quot;https://glts.github.io/2013/04/28/vim-normal-mode-grammar.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;the grammar&lt;/a&gt; @Mass kindly linked to.  &lt;strong&gt;As of &lt;a href=&quot;https://github.com/cxw42/VimWord/releases/tag/v0.2.9&quot; rel=&quot;nofollow noreferrer&quot;&gt;v0.2.9&lt;/a&gt;&lt;/strong&gt;, my regex is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^(([1-9][0-9]*)?((([HMLGhjklwbWB\x28\x29\x7b\x7d]|g?[eE0\^\$]|[fFtT](.))|(gW)?g?[\*#]|g?[pP])|([cdyv])([1-9][0-9]*)?(([\[\]])?([ai])([wWsp])|[fFtT](.)|[HMLGhjklwbWB\x28\x29\x7b\x7d]|g?[eE0\^\$])))$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;em&gt;zero-based&lt;/em&gt; submatch numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1   The initial count&#xA;&#xA;3   Intransitive verb (e.g., 0, w, f&amp;lt;char&amp;gt;)&#xA;4   Motion for an intransitive verb&#xA;5   The &amp;lt;char&amp;gt; of an f, F, t, or T&#xA;&#xA;7   Transitive verb (e.g., operators d, c, y)&#xA;8   The count after the operator&#xA;9   The motion or text object (&quot;target&quot;)&#xA;10  vim-ninja-feet* [ or ]&#xA;11  a or i if you are selecting a text object&#xA;12   For a and i motions, which type of object is being selected (w, W, s, p)&#xA;13  For f, F, t and T motions, which character is being used&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;* &lt;a href=&quot;https://github.com/tommcdo/vim-ninja-feet&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-ninja-feet&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Registers are still not supported.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regex is complicated enough that I wrote a &lt;a href=&quot;https://github.com/cxw42/VimWord/blob/master/re2vba.pl&quot; rel=&quot;nofollow noreferrer&quot;&gt;Perl script&lt;/a&gt; to generate the regex from a text description of it.  That description is below.  Run &lt;code&gt;./re2vba.pl vim-regex.txt&lt;/code&gt; to generate the regex and submatch-number assignments on stdout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the description, &lt;code&gt;(?&amp;lt;name&amp;gt;...)&lt;/code&gt; represents a named submatch, and &lt;code&gt;(?&amp;lt;=piece-name)&lt;/code&gt; pulls in a named piece of the regex.  Comments (&lt;code&gt;#...&lt;/code&gt; or &lt;code&gt;(?#...)&lt;/code&gt;) and trailing whitespace (after stripping comments) are ignored.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Main pattern&#xA;main        ^(  (?# Note: registers not yet implemented)&#xA;                (?&amp;lt;count1&amp;gt;[1-9][0-9]*)?&#xA;                (?:&#xA;                    (?&amp;lt;=intrans)&#xA;                    |&#xA;                    (?&amp;lt;=trans)&#xA;                )&#xA;            )$&#xA;&#xA;# Motions that don't take arguments (although they may take counts).&#xA;# A motion of &quot;0&quot; is special-cased in the parsing code to keep the regex&#xA;# clean.  This regex, after backtracking, matches &quot;10&quot; as a count of &quot;1&quot;&#xA;# followed by a &quot;0&quot; motion.  We special-case rather than handling that here.&#xA;noarg-motion    [HMLG&#xA;                hjkl&#xA;                wbWB&#xA;                \x28\x29\x7b\x7d]|&#xA;                    (?# 28/29 are parens, move sentence )&#xA;                    (?# 7b/7d are braces, move paragraph )&#xA;                g?[eE0\^\$]         (?# gw, gb, etc. are not motions.)&#xA;                (?#  ^ Note: 0 is special-cased in the parsing code.)&#xA;&#xA;# Intransitive, including motions.  These can take a count, namely ?&amp;lt;count1&amp;gt;.&#xA;intrans     (?&amp;lt;iverb&amp;gt;&#xA;                (?&amp;lt;imotion&amp;gt;             (?# motions)&#xA;                    (?&amp;lt;=noarg-motion)|&#xA;                    [fFtT](?&amp;lt;itext&amp;gt;.)&#xA;                )|&#xA;&#xA;                (gW)?g?[\*#]|           (?# searches)&#xA;&#xA;                g?[pP]                  (?# pastes)&#xA;            )&#xA;                # IVERB: what to do&#xA;                        # ITEXT: character to jump to&#xA;&#xA;# Text-object selection ([ai][something])&#xA;textobj     (?&amp;lt;ninja&amp;gt;[\[\]])?               (?# Ninja-feet marker)&#xA;                                    # https://github.com/tommcdo/vim-ninja-feet&#xA;            (?&amp;lt;tobj_range&amp;gt;[ai])             (?# Introducer)&#xA;            (?&amp;lt;objtype&amp;gt;[wWsp])              (?# Type of text object)&#xA;&#xA;# Transitive: verb, count, object, object type, text&#xA;trans       (?&amp;lt;tverb&amp;gt;[cdyv])                (?# TVERB: what to do)&#xA;            (?&amp;lt;count2&amp;gt;[1-9][0-9]*)?         (?# Count after the operator)&#xA;            (?&amp;lt;target&amp;gt;                      (?# What to work on)&#xA;                (?&amp;lt;=textobj)|               (?# Text objects)&#xA;                [fFtT](?&amp;lt;ttext&amp;gt;.)|          (?# Motions with an argument)&#xA;                (?&amp;lt;=noarg-motion)&#xA;            )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note 1: Just like in Vim, &lt;code&gt;v&lt;/code&gt; selects the text moved over.  However, Word is essentially always in a combination of normal and visual modes, so &lt;code&gt;v&lt;/code&gt; doesn't leave you in any special mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note 2: I don't need the &lt;code&gt;c&lt;/code&gt; intransitive verb for one-offs, since you are back in Word (i.e., insert mode) after a &lt;code&gt;d&lt;/code&gt;.  However, I am working on a loop version that will leave you in Normal mode after a &lt;code&gt;d&lt;/code&gt; but not after a &lt;code&gt;c&lt;/code&gt;(&lt;a href=&quot;https://github.com/cxw42/VimWord/issues/3&quot; rel=&quot;nofollow noreferrer&quot;&gt;#3&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="1430" LastEditDate="2020-02-13T11:10:59.320" LastActivityDate="2020-02-13T11:10:59.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16008" PostTypeId="2" ParentId="9774" CreationDate="2018-04-20T18:13:48.010" Score="2" Body="&lt;p&gt;Try adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_ut=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to ~/.vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had the same issue on Debian 9 with Gnome Terminal and Mate Terminal, and on some Fedora and Centos virtual machines where I did not have GUI installed. Adding this line solved the problem.&lt;/p&gt;&#xA;" OwnerUserId="17245" LastEditorUserId="17245" LastEditDate="2018-04-24T19:37:34.577" LastActivityDate="2018-04-24T19:37:34.577" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16009" PostTypeId="2" ParentId="16003" CreationDate="2018-04-20T20:03:44.740" Score="3" Body="&lt;p&gt;The syntax for unicode characters inside &lt;code&gt;[]&lt;/code&gt; is different, you just omit the &lt;code&gt;%&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match ChineseMark /[\u3000\uff01-\uff5e]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\%uxxxx&lt;/code&gt; is an atom while &lt;code&gt;\uff01&lt;/code&gt; is character in a collection.  You cannot use atoms inside collections.  See &lt;code&gt;:help /[&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-04-20T20:03:44.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16011" PostTypeId="2" ParentId="15846" CreationDate="2018-04-21T06:23:33.213" Score="3" Body="&lt;p&gt;Use &lt;a href=&quot;https://github.com/ZeroKnight/vim-signjump&quot; rel=&quot;nofollow noreferrer&quot;&gt;SignJump&lt;/a&gt;. For whatever reason, Vim offers no way to quickly jump to tags outside of the horrendously unfriendly &lt;code&gt;:sign jump&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once installed, simply use &lt;code&gt;]s&lt;/code&gt; and &lt;code&gt;[s&lt;/code&gt; to jump to the next and previous sign relative to the cursor position. You can also use &lt;code&gt;]S&lt;/code&gt; and &lt;code&gt;[S&lt;/code&gt; to jump to the first and last sign, respectively. It is general purpose and will jump to &lt;em&gt;any&lt;/em&gt; sign.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Full Disclosure&lt;/strong&gt;: I am the author of this plugin.&lt;/p&gt;&#xA;" OwnerUserId="1452" LastEditorUserId="1452" LastEditDate="2018-07-20T21:45:55.243" LastActivityDate="2018-07-20T21:45:55.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16013" PostTypeId="1" CreationDate="2018-04-22T01:15:17.620" Score="1" ViewCount="1500" Body="&lt;p&gt;I am at the end of hour-long research on why I cannot install vim with proper python support. Problems already recognized: Impossible to install python 2 and 3 support together on ubuntu 16.04; oh well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After finding &lt;a href=&quot;https://gist.github.com/klen/3d327e5f84e36dc04bd7&quot; rel=&quot;nofollow noreferrer&quot;&gt;this gist detailing options someone got to work with pyenv and OSX&lt;/a&gt;, I arrived at the following parameters to compile vim, which should really work from the best of my knowledge:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Parameters: &#xA; - No sudo, &#xA; - no python development libraries -&gt; get Python via pyenv seems sensible.&#xA; - Installed pyenv, installed a python 2.7 in there this way: &lt;code&gt;env PYTHON_CONFIGURE_OPTS=&quot;--enable-shared&quot; pyenv install -fk 2.7&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;configuring...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export LIBRARY_PATH=&quot;$HOME/.pyenv/versions/2.7/lib:$LIBRARY_PATH&quot;&#xA;PY_CONFIG=&quot;$HOME/.pyenv/prefix 2.7/lib/python2.7/config&quot; # I checked that this exists&#xA;./configure                  \&#xA;    --with-features=huge                    \&#xA;    --enable-multibyte                      \&#xA;    --enable-pythoninterp=yes           \&#xA;    --with-python-config-dir=$PY_CONFIG     \&#xA;    --enable-gui=gtk2                       \&#xA;    --enable-cscope                         \&#xA;    --prefix=&quot;$HOME/.local&quot; $@&#xA;&#xA;make install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The configuration yielded i.a.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;checking for python2... (cached) /usr/bin/python2&#xA;checking Python version... (cached) 2.7&#xA;checking Python is 2.3 or better... yep&#xA;checking Python's install prefix... (cached) /usr&#xA;checking Python's execution prefix... (cached) /usr&#xA;(cached) checking Python's configuration directory... (cached) /home/simon/.pyenv/versions/2.7/lib/python2.7/config&#xA;(cached) checking Python's dll name... (cached) libpython2.7.a&#xA;checking if -pthread should be used... yes&#xA;checking if compile and link flags for Python are sane... yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which seems okay, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The compiled &lt;code&gt;vim --version&lt;/code&gt; tells me I have compiled with +python support.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I try to use a python-related plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;78_init[14]..&amp;lt;SNR&amp;gt;78_exec_file:&#xA;line    3:&#xA;E887: Sorry, this command is disabled, the Python's site module could not be loaded.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why god why :(&#xA;Please help, thank you so much!&lt;/p&gt;&#xA;" OwnerUserId="17075" LastActivityDate="2022-07-31T06:07:35.677" Title="Python support using pyenv" Tags="|vimscript-python|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16014" PostTypeId="2" ParentId="16013" CreationDate="2018-04-22T01:38:33.677" Score="1" Body="&lt;p&gt;Okay, I have found out the error now.&#xA;Turns out the configure-and-make-process had cached some information during erroneous attempts to configure the python to be linked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;make distclean&lt;/code&gt; was required to remove this cached information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it okay to leave this question as reference for others trying to build their vim against pyenv? If not, it may be deleted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some notes: &#xA; - Due to being on Ubuntu 16.04, I had to pick one of Python 2 and Python 3 support, i.e. one of &lt;code&gt;--enable-pythoninterp&lt;/code&gt; and &lt;code&gt;--enable-python3interp&lt;/code&gt; flags. See here: &lt;a href=&quot;https://stackoverflow.com/a/23656675/2385695&quot;&gt;https://stackoverflow.com/a/23656675/2385695&lt;/a&gt;&#xA; - On other systems, you may able to get both, but you should be cautious; as I understood it, the dynamic linking nature can hit you back later.&#xA; - The vim plugin &lt;a href=&quot;https://github.com/lambdalisue/vim-pyenv&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/lambdalisue/vim-pyenv&lt;/a&gt; can help you use the right pyenv version down the road for autocompletion with jedi-enabled plugins etc.&lt;/p&gt;&#xA;" OwnerUserId="17075" LastActivityDate="2018-04-22T01:38:33.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16015" PostTypeId="1" CreationDate="2018-04-22T11:27:33.833" Score="4" ViewCount="222" Body="&lt;p&gt;Background: I'm an english-speaking, francophone student. In an effort to improve my vocabulary, my MacBook has been running in French since January, when I arrived in France. Incidentally, this means that &lt;code&gt;$LANG=fr_FR.utf-8&lt;/code&gt;. I was able to get ahold of the spell files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I decided it would be nice if I had access to vim help in french. &lt;code&gt;:help help-translated&lt;/code&gt; points to &lt;a href=&quot;http://www.vim.org/translations.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;the translations page&lt;/a&gt;, which points us to this &lt;a href=&quot;http://vim.dindinx.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;website&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, Safari reports it &quot;can't find the server.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick &lt;a href=&quot;https://www.google.com/?q=vim+french+help+files&quot; rel=&quot;nofollow noreferrer&quot;&gt;google search&lt;/a&gt; didn't turn up anything useful either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did find &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/8gL01Udn8E8/i4pk_Oi4CAAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;this translation from 2017&lt;/a&gt;, but it appears to be the error messages only and is not a drop-in bundle of help files per &lt;code&gt;:help&lt;/code&gt; itself--it appears it may have to be compiled in?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: Where are the vim help files in French? Do they still exist? If not, will someone get them back online so I can use them? (I would gladly put them in a GitHub repo somewhere so they persist for eternity).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/RLrs0XJxfa4/9t9wg-MsCgAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;relevant post&lt;/a&gt; on the &lt;code&gt;vim_dev&lt;/code&gt; mailing list.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B.&lt;/em&gt; &lt;code&gt;vimtutor fr&lt;/code&gt; works just fine.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2018-04-23T17:53:13.390" LastActivityDate="2020-10-11T12:27:24.063" Title="Where are the French help files?" Tags="|help-system|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16016" PostTypeId="1" AcceptedAnswerId="16017" CreationDate="2018-04-22T13:13:51.617" Score="0" ViewCount="72" Body="&lt;pre&gt;&lt;code&gt;!sed -i &quot;N;4i\xxxxxxxx&quot; % &#xA;!sed -i &quot;N;10a\yyyyyyyy&quot; % &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add a line containing  &lt;code&gt;xxxxxxx&lt;/code&gt; before the 4-th line,and add a line containing  &lt;code&gt;yyyyyyyy&lt;/code&gt; after the 10-th line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to write a function to add a line containing  &lt;code&gt;xxxxxxx&lt;/code&gt; before the m-th line,and add a line containing  &lt;code&gt;yyyyyyyy&lt;/code&gt; after the n-th line with vimscript?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastActivityDate="2018-04-22T15:23:26.553" Title="Add some lines in vim" Tags="|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16017" PostTypeId="2" ParentId="16016" CreationDate="2018-04-22T15:23:26.553" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#append%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h append()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;append({lnum}, {expr})                    *append()*&#xA;      When {expr} is a |List|: Append each item of the |List| as a&#xA;      text line below line {lnum} in the current buffer.&#xA;      Otherwise append {expr} as one text line below line {lnum} in&#xA;      the current buffer.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you can use this to add a line after the 10th line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call append(10, &quot;yyyyyyy&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And to add a line before the 4th one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call append(3, &quot;xxxxxx&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may also want to read &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3aput&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :put&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-04-22T15:23:26.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16018" PostTypeId="2" ParentId="5354" CreationDate="2018-04-22T20:02:34.883" Score="13" Body="&lt;p&gt;Install the &lt;code&gt;reptyr&lt;/code&gt; command using the system's package manager, such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt install reptyr&#xA;pacman -Sy reptyr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then use the &lt;code&gt;reptyr&lt;/code&gt; command to switch the remote tty to the local (new) tty, as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ssh user@remote-hostname&#xA;ps auxw | grep -i vim&#xA;reptyr PID&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;PID&lt;/code&gt; is the process ID from the &lt;code&gt;ps&lt;/code&gt; command output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Upon the error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Unable to attach to pid 12345: Permission denied&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Change the &quot;ptrace scope&quot; to 0:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo su -&#xA;echo 0 &amp;gt; /proc/sys/kernel/yama/ptrace_scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once the vim session has been swapped from the old session to the new one, save and quit as usual. Note that you may have to press &lt;kbd&gt;Enter&lt;/kbd&gt; to refresh the console.&lt;/p&gt;&#xA;" OwnerUserId="1575" LastEditorUserId="1575" LastEditDate="2019-02-11T18:37:30.047" LastActivityDate="2019-02-11T18:37:30.047" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16019" PostTypeId="1" AcceptedAnswerId="16021" CreationDate="2018-04-22T22:39:08.560" Score="4" ViewCount="2542" Body="&lt;p&gt;When I start a terminal with the &lt;code&gt;:terminal&lt;/code&gt; command, I get this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;++ parse_git_branch&#xA;bash: parse_git_branch: command not found&#xA;~ $&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;parse_git_branch&lt;/code&gt; is a bash function defined in my &lt;code&gt;.bash_profile&lt;/code&gt; that I use for a custom prompt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export PS1=&quot;\\[\\033[33;1m\\]\\w\\[\\033[m\\]\$(parse_git_branch || echo unknown)\\[\\033[00m\\] $ &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does neovim not read the &lt;code&gt;.bash_profile&lt;/code&gt;?  How can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="5373" LastActivityDate="2018-04-23T01:14:39.537" Title="Neovim `:terminal` not reading .bash_profile" Tags="|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16020" PostTypeId="1" CreationDate="2018-04-23T00:05:22.010" Score="1" ViewCount="133" Body="&lt;p&gt;When toggling folds with &lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;, any folds expanding above the current line cause the current line to disorientingly jump to a different place on the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I keep the current line fixed in the same place while toggling folds?&lt;/p&gt;&#xA;" OwnerUserId="6079" LastActivityDate="2018-12-21T23:42:20.107" Title="Keep current line in same position when toggling folds (zi)?" Tags="|folding|scrolling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16021" PostTypeId="2" ParentId="16019" CreationDate="2018-04-23T00:10:41.190" Score="6" Body="&lt;p&gt;&lt;em&gt;I'll take a crack at this though I'm purely a Vim user.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at &lt;code&gt;man bash&lt;/code&gt; you'll find the rules bash uses to load the various startup files. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When bash is invoked as an interactive login shell, or as a&#xA;  non-interactive shell with the --login option, it first reads and&#xA;  executes commands from the file /etc/profile, if that file exists.&#xA;  After reading that file, it looks for ~/.bash_profile, ~/.bash_login,&#xA;  and ~/.profile, in that order,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you need to start a login shell...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A login shell is one whose first character of argument zero is a -, or&#xA;  one started with the --login option.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So adding &lt;code&gt;--login&lt;/code&gt; to the bash command that neovim uses should do what you want. (Assuming it's the same as vim that can be specified with something like &lt;code&gt;let &amp;amp;shell='/usr/bin/bash --login'&lt;/code&gt; in neovim init file.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, &lt;code&gt;--rcfile path-to-bash-profile&lt;/code&gt; can probably be used instead of &lt;code&gt;--login&lt;/code&gt;. The difference between the two is subtle and for most in-vim use they are effectively equivalent. I mention both in the unlikely event someone is doing something sensitive to whether the terminal is a login shell or not in which case they can try the alternative.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-04-23T01:14:39.537" LastActivityDate="2018-04-23T01:14:39.537" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16022" PostTypeId="2" ParentId="16020" CreationDate="2018-04-23T07:07:12.570" Score="-1" Body="&lt;p&gt;Instead of &lt;code&gt;zi&lt;/code&gt; you should use &lt;code&gt;zo&lt;/code&gt; to open a fold and &lt;code&gt;zc&lt;/code&gt; to close it or &lt;code&gt;za&lt;/code&gt; to toggle the fold. These commands never make the current line jump for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that these commands have a recursive equivalent: &lt;code&gt;zC&lt;/code&gt;, &lt;code&gt;zO&lt;/code&gt; and &lt;code&gt;zA&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/fold.txt.html#zo&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h zo&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/fold.txt.html#zc&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h zc&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/fold.txt.html#za&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h za&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-04-23T07:07:12.570" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16024" PostTypeId="1" AcceptedAnswerId="16025" CreationDate="2018-04-23T08:58:41.213" Score="2" ViewCount="1550" Body="&lt;p&gt;I'm new to Vim, and for the paste couple of weeks, I've been using NERDTree with no problems. However, I recently added a few key mappings and am now unable to open NERDTree with the &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; command. Nothing happens when I run the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the part of my &lt;code&gt;.vimrc&lt;/code&gt; that I found to be causing the problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Map semicolon to colon and vice versa&#xA;nnoremap ; :&#xA;nnoremap : ;&#xA;&#xA;&quot; Map shortcuts to align = for Tabularize&#xA;vmap &amp;lt;Leader&amp;gt;a= :Tabularize /=&amp;lt;CR&amp;gt;&#xA;&quot; The following line doesn't work as well.&#xA;nmap &amp;lt;Leader&amp;gt;a= :Tabularize /=&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once I remove the &lt;code&gt;nnoremap : ;&lt;/code&gt; command, NERDTree begins working again. Why is this happening, and how can I fix it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, the shortcut to call Tabularize works in the visual mode but not in insert mode. I don't know if this and the NERDTree problems are related.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background information:&lt;/strong&gt; I'm running Vim 7.4.52 on bash on Windows (Windows Subsystem for Linux). &lt;/p&gt;&#xA;" OwnerUserId="17269" LastEditorUserId="17269" LastEditDate="2018-04-23T09:15:59.977" LastActivityDate="2021-09-05T23:44:21.293" Title="Unable to Open NERDTree" Tags="|vimrc|key-bindings|vim-windows|plugin-system|plugin-nerdtree|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16025" PostTypeId="2" ParentId="16024" CreationDate="2018-04-23T09:58:08.933" Score="3" Body="&lt;p&gt;The problem is that when you invoke your Tabularize mapping, the &lt;code&gt;:&lt;/code&gt; in the right-hand-side of the mapping is remapped to a &lt;code&gt;;&lt;/code&gt; by your colon map, and the keystrokes that are then invoked are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;;Tabularize /=&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to fix this, you need to tell your Tabularize mapping to ignore existing mappings, and instead use the default functionality. You do this by using the non-recursive form of the map command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;a= :Tabularize /=&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This tells Vim to use an &lt;em&gt;actual&lt;/em&gt; colon, and to ignore anything that colon (and everything else in the rhs) may be mapped to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that your &lt;code&gt;vmap&lt;/code&gt; command is subject to similar issues: it's just that you don't currently have colon mapped to anything in visual mode, so it works by happenstance. To make your mapping robust, you should use &lt;code&gt;vnoremap&lt;/code&gt; here, similarly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I imagine this is also causing your NERDTree issue: I don't believe &lt;kbd&gt;Ctrl-N&lt;/kbd&gt; is a standard keystroke for opening NERDTree, so you've probably got that set up as a mapping in your &lt;code&gt;.vimrc&lt;/code&gt; somewhere, and it's probably not using the non-recursive form of the map command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a general rule of thumb, you should always use the &lt;code&gt;nore&lt;/code&gt; forms of the various map commands, only using the bare forms if you have a specific reason to do so, which will happen infrequently (or never!)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-04-23T10:30:24.183" LastActivityDate="2018-04-23T10:30:24.183" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16026" PostTypeId="1" CreationDate="2018-04-23T13:13:36.983" Score="1" ViewCount="236" Body="&lt;p&gt;I have a rather annoying case of duplicate messages being displayed whenever I go put my cursor on a line. Whenever my cursor lands &lt;em&gt;on&lt;/em&gt; the line, a message like &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;[Error]not found: type Playfield&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is displayed. When I move the cursor to the left, it's replaced by &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;qf - (17 of 33): private method in class Reader is never used&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I move my cursor further to the left, &lt;em&gt;yet anoter&lt;/em&gt; message is shown (this is because I have multiple quickfix entries for the same line but in different columns):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;qf - (31 of 33): not found: type Playfield&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is incredibly annoying. It would be nice if the first message never appeared in the first place because it's redundant and shadows the two other messages - as mentioned, these only appear once I begin moving my cursor left and right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the first message relate to quickfix at all? If not, how can I determine where it originates from?&lt;/p&gt;&#xA;" OwnerUserId="13662" LastActivityDate="2018-04-23T13:13:36.983" Title="How do I remove duplicate quickfix messages?" Tags="|quickfix|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16027" PostTypeId="1" CreationDate="2018-04-23T13:40:29.637" Score="5" ViewCount="267" Body="&lt;p&gt;From &lt;code&gt;:h g&amp;lt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The &lt;code&gt;g&amp;lt;&lt;/code&gt; command can be used to see the last page of previous command output.&#xA;  This is especially useful if you accidentally typed &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; at the hit-enter&#xA;  prompt.  You are then back at the hit-enter prompt &lt;strong&gt;and can then scroll further&#xA;  back&lt;/strong&gt;.&#xA;  Note: If the output has been stopped with &lt;code&gt;q&lt;/code&gt; at the more prompt, it will only&#xA;  be displayed up to this point.&#xA;  The previous command output is cleared when another command produces output.&#xA;  The &lt;code&gt;g&amp;lt;&lt;/code&gt; output is not redirected.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To test the &lt;code&gt;g&amp;lt;&lt;/code&gt; command, I've started Vim with no configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -Nu NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, I've tried to execute a command producing a long output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args $VIMRUNTIME/**/*.vim&#xA;:args&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These commands populate the global arglist with all the &lt;code&gt;.vim&lt;/code&gt; files in &lt;code&gt;$VIMRUNTIME&lt;/code&gt;, and display its contents in Vim's internal pager.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I've scrolled the output down to the bottom by keeping pressing &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;I've pressed &lt;code&gt;Enter&lt;/code&gt; to leave the pager, and get back to the buffer.&lt;/li&gt;&#xA;&lt;li&gt;I've pressed &lt;code&gt;g&amp;lt;&lt;/code&gt; which re-displays the last page of the pager.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;According to the last excerpt from the help you can scroll back after pressing &lt;code&gt;g&amp;lt;&lt;/code&gt;.&lt;br&gt;&#xA;And according to &lt;code&gt;:h hit-enter&lt;/code&gt;, you can scroll back by pressing &lt;code&gt;k&lt;/code&gt;, &lt;code&gt;Up&lt;/code&gt;, &lt;code&gt;u&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, or &lt;code&gt;g&lt;/code&gt;, on the condition that &lt;code&gt;'compatible'&lt;/code&gt; is reset and &lt;code&gt;'more'&lt;/code&gt; is set:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;-&gt; Press &lt;code&gt;'k'&lt;/code&gt;, &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt;, &lt;code&gt;'u'&lt;/code&gt;, &lt;code&gt;'b'&lt;/code&gt; or &lt;code&gt;'g'&lt;/code&gt; to scroll back in the messages.  This&#xA;     works the same way as at the &lt;code&gt;|more-prompt|&lt;/code&gt;.  Only works when &lt;code&gt;'compatible'&lt;/code&gt;&#xA;     is off and &lt;code&gt;'more'&lt;/code&gt; is on.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But on my machine (Linux, Vim &lt;code&gt;8.0.1747&lt;/code&gt;), pressing any of these keys doesn't scroll back, even though &lt;code&gt;'compatible'&lt;/code&gt; is reset and &lt;code&gt;'more'&lt;/code&gt; is set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to scroll back in the output of the last Ex command after pressing &lt;code&gt;g&amp;lt;&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="17270" LastEditorUserId="10604" LastEditDate="2020-03-27T14:23:30.667" LastActivityDate="2020-03-27T14:23:30.667" Title="How to scroll back in the output of the last Ex command after pressing `g&lt;`?" Tags="|scrolling|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16028" PostTypeId="1" CreationDate="2018-04-23T17:31:55.597" Score="1" ViewCount="1266" Body="&lt;p&gt;I have searched unsuccessfully everywhere for an answer to this question and could not find an acceptable answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am taking a list of table names from a database, and dynamically creating alter statements to change the database name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am getting is something like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call_center&#xA;catalog_page&#xA;catalog_returns&#xA;catalog_sales&#xA;customer&#xA;customer_address&#xA;customer_demographics&#xA;date_dim&#xA;household_demographics&#xA;income_band&#xA;inventory&#xA;item&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do a search and replace with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; %s/^/alter table /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And end up with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alter table call_center$&#xA;alter table catalog_page$&#xA;alter table catalog_returns$&#xA;alter table catalog_sales$&#xA;alter table customer$&#xA;alter table customer_address$&#xA;alter table customer_demographics$&#xA;alter table date_dim$&#xA;alter table household_demographics$&#xA;alter table income_band$&#xA;alter table inventory$&#xA;alter table item$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I run the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v(\S\s+)(\S+\s+)(\S+)$/\1\2\3\ rename to tpcds.\3;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alter table call_center rename to tpcds.call_center;&#xA;alter table catalog_page rename to tpcds.catalog_page;&#xA;alter table catalog_returns rename to tpcds.catalog_returns;&#xA;alter table catalog_sales rename to tpcds.catalog_sales;&#xA;alter table customer rename to tpcds.customer;&#xA;alter table customer_address rename to tpcds.customer_address;&#xA;alter table customer_demographics rename to tpcds.customer_demographics;&#xA;alter table date_dim rename to tpcds.date_dim;&#xA;alter table household_demographics rename to tpcds.household_demographics;&#xA;alter table income_band rename to tpcds.income_band;&#xA;alter table inventory rename to tpcds.inventory;&#xA;alter table item rename to tpcds.item;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can shorten this to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v(\S\s+){1}(\S+)$/\1\2 rename to tpcds.\2;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, what I was never able to figure out, and need help with, how do you move a word, by its &quot;position/index&quot; to somewhere else in the line? I know how to do this if you are looking a specific word (like cat), but what if the word is always different, but in the same position? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, what if I were building select clauses, and wanted to change the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;select cc_call_center_id, cc_name from call_center;&#xA;select i_item_id, i_name from item;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;select cc_call_center_id, cc_name from call_center order by cc_call_center_id;&#xA;select i_item_id, i_name from item order by i_item_id;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do you select the nth word (in this case, the 2nd) and append it somewhere else in the line (in this case, to the end of the line)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*BTW, I realize I could just change it to &quot;order by 1&quot;, but this is just an example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this makes sense.&#xA;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="17274" LastActivityDate="2018-04-23T17:36:27.550" Title="Find the nth word in a line, and replace it back into the line in different position" Tags="|regular-expression|search|replace|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16029" PostTypeId="2" ParentId="16028" CreationDate="2018-04-23T17:36:27.550" Score="2" Body="&lt;p&gt;Personally, I would use &lt;code&gt;:normal&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm wyiwf;i order by &amp;lt;c-v&amp;gt;&amp;lt;c-r&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use a substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\w\+\s\+\(\w\+\).*\zs;/ order by \1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;code&gt;\zs&lt;/code&gt; to set the start of the match to simply the substitution. If you are having issue with substitutions then I suggest using &lt;a href=&quot;https://github.com/markonm/traces.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;traces.vim&lt;/a&gt; to help give visual feedback.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :norm&#xA;:h :range&#xA;:h c_CTRL-R&#xA;:h /\zs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-04-23T17:36:27.550" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16030" PostTypeId="2" ParentId="5658" CreationDate="2018-04-23T18:18:54.240" Score="3" Body="&lt;p&gt;I wrote the following script that allows you to close a fold while &quot;moving&quot; left when you are at the beginning of a line and to open a closed fold by trying to move right when on the fold line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When trying to move right opens the fold, the cursor does not actually move but stays on the same column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That way, one can move up and down in the leftmost column and use &quot;moves&quot; right/left to quickly open/close folds which makes browsing folded code efficient!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Disclaimer: not tested on documents using hard tabs at the start of lines)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MoveAndFoldLeft()&#xA;    let line = getpos('.')[1]&#xA;    let col  = getpos('.')[2]&#xA;&#xA;    if l:col ==# 1 &amp;amp;&amp;amp; foldlevel(l:line)&#xA;        execute &quot;foldclose&quot;&#xA;    else    &#xA;        execute &quot;normal! h&quot;&#xA;    endif   &#xA;endfunction&#xA;&#xA;function! MoveAndFoldRight()&#xA;    let line = getpos('.')[1]&#xA;&#xA;    if foldlevel(line) &amp;amp;&amp;amp; foldclosed(line) != -1&#xA;        execute &quot;foldopen&quot;&#xA;    else    &#xA;        execute &quot;normal! l&quot;&#xA;    endif   &#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Left&amp;gt;  :call MoveAndFoldLeft()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; h       :call MoveAndFoldLeft()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Right&amp;gt; :call MoveAndFoldRight()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; l       :call MoveAndFoldRight()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14076" LastEditorUserId="14076" LastEditDate="2018-04-23T21:40:42.893" LastActivityDate="2018-04-23T21:40:42.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16031" PostTypeId="1" CreationDate="2018-04-23T23:42:04.550" Score="0" ViewCount="62" Body="&lt;p&gt;I'm not sure if the title makes sense, but I'll try to explain what I'm trying to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a file with some code like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some_var = 3;&#xA;...&#xA;func(some_var);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The file has a bunch of calls to &lt;code&gt;func&lt;/code&gt; and I'd like to find all occurrences of the variable passed to each call.  In this case I'd like to find &lt;code&gt;some_var&lt;/code&gt; on the line where it is assigned as well as where it is passed to the function.  Unfortunately the variable name may differ in each instance, so I can't just search for the variable name directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to search for the call to the function, capture the argument passed to it and then set the search pattern to that argument?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following, but it seems sub-expressions don't work with the &lt;code&gt;:g&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/func(\(\w\+\))/let @/ = \1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2018-04-24T15:30:06.173" Title="Setting the search pattern to just a portion of a regex pattern" Tags="|regular-expression|search|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16032" PostTypeId="2" ParentId="11426" CreationDate="2018-04-24T00:20:33.363" Score="1" Body="&lt;p&gt;With focus on &lt;code&gt;NERDTree&lt;/code&gt;, type &lt;code&gt;A&lt;/code&gt;. Then open some file from &lt;code&gt;NERDTree&lt;/code&gt; and it will open correctly.&lt;/p&gt;&#xA;" OwnerUserId="1806" LastActivityDate="2018-04-24T00:20:33.363" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16034" PostTypeId="2" ParentId="16031" CreationDate="2018-04-24T15:30:06.173" Score="2" Body="&lt;p&gt;I'd probably use a simple macro for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq/func(./e&amp;lt;CR&amp;gt;#q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B In the above, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is a single press of your &lt;kbd&gt;Return&lt;/kbd&gt; key.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Broken down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; Start recording a macro into the &lt;code&gt;&quot;q&lt;/code&gt; register,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/func(./e&amp;lt;CR&amp;gt;&lt;/code&gt; Search for the function, leaving the cursor on the first character of the argument .&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;#&lt;/code&gt; Search backwards for the variable&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; Stop recording the macro.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can then press &lt;kbd&gt;n&lt;/kbd&gt; if necessary, to continue searching backwards for the variable, in case it is assigned to more than once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you've finished inspecting that variable, press &lt;kbd&gt;Ctrl-O&lt;/kbd&gt; to step back through the jumplist until you're back at the function call, and then press &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; to replay the macro to find the next call to the function and the argument that is passed to it.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-04-24T15:30:06.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16036" PostTypeId="1" CreationDate="2018-04-25T03:30:04.127" Score="1" ViewCount="58" Body="&lt;p&gt;For some reason, Vim started to indent JavaScript in this crazy manner. I bet it's related to some settings in my syntax plugins, but I can't seem to figure out which ones are causing this behavior:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;badFormattingWithLongLine.map(m =&amp;gt;&#xA;                               ...&#xA;                             )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to force it to do minimal indentation for all files and filetypes as this Ruby-inspired flag-style is very annoying because I have to &lt;code&gt;dw&lt;/code&gt; the whitespace manually for each line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;goodFormattingWithLongLine.map(m =&amp;gt;&#xA;  ...&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="237" LastEditorUserId="237" LastEditDate="2018-04-25T03:35:33.240" LastActivityDate="2018-04-25T03:35:33.240" Title="Autoindent with minimal indentation" Tags="|indentation|formatting|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16037" PostTypeId="1" AcceptedAnswerId="16047" CreationDate="2018-04-25T04:11:10.790" Score="29" ViewCount="13909" Body="&lt;p&gt;Everytime I cut out of a session in vim by losing my connection I'm rather filled with dred  (and yet I continue to use vim...what a masochistist I must be) because when I open my files again a pile of swap-files are waiting to take a shot at destroying my work.  What are the best practices for working with vim swap files?  Do you just pick the newest one?  If the file works the way you expect, do you just delete the swap files?  How do you get rid of them?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2019-10-18T19:59:17.553" Title="VIM swap-file best practices?" Tags="|swap-file|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16038" PostTypeId="2" ParentId="16005" CreationDate="2018-04-25T11:52:35.450" Score="0" Body="&lt;p&gt;I manage to do partial solution, but still there is problem with, nesting errorlog windows, and cmd.exe that hangs after execution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;noremap &amp;lt;leader&amp;gt;s :!&quot;C:\Program Files\AutoHotkey\AutoHotkey.exe&quot; /ErrorStdOut&#xA;\ %:p 2&amp;gt;&quot;errorlog.txt&quot;&amp;lt;CR&amp;gt; :sp errorlog.txt&amp;lt;CR&amp;gt;&amp;lt;C-W&amp;gt;J&amp;lt;CR&amp;gt; :resize 5&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16328" LastActivityDate="2018-04-25T11:52:35.450" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16040" PostTypeId="1" CreationDate="2018-04-25T18:23:27.123" Score="1" ViewCount="235" Body="&lt;p&gt;I'm trying to pass a command to 'vim-tmux-runner' on each file save with &lt;code&gt;au&lt;/code&gt; bellow.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileWritePost,BufWritePost *.py :VtrSendCommandToRunner python manage.py test &amp;lt;afile&amp;gt;:p:h:t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:VtrSendCommandToRunner&lt;/code&gt; sends a command to shell in another tmux pane&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;python manage.py test&lt;/code&gt; is the actual command being sent to shell&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;afile&amp;gt;:p:h:t&lt;/code&gt; and at the end of the command I add a variable that should be expanded to the name of the folder that my file was just saved in.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On each save my shell command tells me that there is no such file as &lt;code&gt;&amp;lt;afile&amp;gt;:p:h:t&lt;/code&gt; so as I understand vim did not expand those variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before I added &lt;code&gt;:VtrSendCommandToRunner&lt;/code&gt; (originally my Ex command started with &lt;code&gt;:!&lt;/code&gt;) my Ex command was expanded correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to rewrite that Ex command in couple other ways but I can't get anything to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some versions of Ex command that I tried(all failed me):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;afile&amp;gt;:p:h:t&#xA;%:p:h:t&#xA;expand(%:p:h:t)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get vim to expand &lt;code&gt;%&lt;/code&gt; to a file name then?&lt;/p&gt;&#xA;" OwnerUserId="5827" LastEditorUserId="1841" LastEditDate="2018-04-26T07:17:29.360" LastActivityDate="2018-04-26T07:17:29.360" Title="How vim doesn't expand Ex commands in autocmd?" Tags="|command-line|autocmd|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16041" PostTypeId="1" AcceptedAnswerId="16042" CreationDate="2018-04-25T20:33:09.200" Score="-1" ViewCount="65" Body="&lt;p&gt;Using the * key searches for the word under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use # to do the same, backwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When search is active, all instances of word appears highlighted. I want to know if is possible to remove the highlight selection.&lt;/p&gt;&#xA;" OwnerUserId="2965" LastActivityDate="2018-04-25T20:52:18.493" Title="hidden highlight selection when search with * or # is active" Tags="|syntax-highlighting|highlight|" AnswerCount="1" CommentCount="0" ClosedDate="2018-04-26T07:20:10.583" ContentLicense="CC BY-SA 3.0" />
  <row Id="16042" PostTypeId="2" ParentId="16041" CreationDate="2018-04-25T20:52:18.493" Score="2" Body="&lt;p&gt;&lt;code&gt;hlsearch&lt;/code&gt; controls this; it can be turned off with &lt;code&gt;:set nohlsearch&lt;/code&gt;. This affects all sorts of searches, however, and not just &lt;kbd&gt;*&lt;/kbd&gt; and &lt;kbd&gt;#&lt;/kbd&gt;. One could, theoretically, remap &lt;kbd&gt;*&lt;/kbd&gt; and &lt;kbd&gt;#&lt;/kbd&gt; to do what they do and then execute &lt;code&gt;:nohlsearch&lt;/code&gt; (or &lt;code&gt;:noh&lt;/code&gt;) with &lt;code&gt;:nnoremap * * :noh&amp;lt;CR&amp;gt;&lt;/code&gt; and &lt;code&gt;:nnoremap # # :noh&amp;lt;CR&amp;gt;&lt;/code&gt; to clear highlighting every time a &lt;kbd&gt;*&lt;/kbd&gt; or &lt;kbd&gt;#&lt;/kbd&gt; is performed. The highlighting will still flicker, but clear essentially immediately.&lt;/p&gt;&#xA;" OwnerUserId="14684" LastActivityDate="2018-04-25T20:52:18.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16043" PostTypeId="1" AcceptedAnswerId="16044" CreationDate="2018-04-25T22:52:03.493" Score="4" ViewCount="1668" Body="&lt;p&gt;Whenever using NASM, and syntactic I get the warning&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;instruction not supported in 16-bit mode&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How do I provide the argument to tell it to not use 16-bit mode?&lt;/p&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="5078" LastEditDate="2018-10-01T22:01:27.007" LastActivityDate="2018-10-01T22:01:27.007" Title="NASM and Syntastic: instruction not supported in 16-bit mode" Tags="|plugin-syntastic|filetype-assembly|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16044" PostTypeId="2" ParentId="16043" CreationDate="2018-04-25T22:52:03.493" Score="5" Body="&lt;p&gt;This is the default in NASM, try using the &lt;a href=&quot;https://github.com/rpavlik/assembler/blob/master/doc/manual/nasm-directives.txt&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;BITS&lt;/code&gt;&lt;/a&gt; directive by putting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BITS 64;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;at the top of the &lt;code&gt;.asm&lt;/code&gt; file.&lt;/p&gt;&#xA;" OwnerUserId="5078" LastActivityDate="2018-04-25T22:52:03.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16045" PostTypeId="1" AcceptedAnswerId="16046" CreationDate="2018-04-26T03:30:20.010" Score="3" ViewCount="2603" Body="&lt;p&gt;If I am in an open fold containing closed folds, how do I recursively open all those closed folds?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I kind of thought this would be the use-case for &lt;code&gt;zO&lt;/code&gt;, but it seems &lt;code&gt;zO&lt;/code&gt; only works when the fold is already closed. Is a better way to accomplish this than closing and re-opening the current fold recursively (&lt;code&gt;za zA&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="6079" LastActivityDate="2020-04-19T12:42:44.440" Title="Recursively open all folds in current open fold?" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16046" PostTypeId="2" ParentId="16045" CreationDate="2018-04-26T03:51:46.183" Score="8" Body="&lt;p&gt;I don't think there's anything shorter than &lt;code&gt;zczA&lt;/code&gt;. That's pretty easy and probably what I'd do. I guess you could shorten it a bit with a mapping ;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;O zczA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But let's say you absolutely can't or don't want to close the already open fold. This is what I came up with...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It's not a Normal mode command but from the command line &lt;code&gt;foldopen&lt;/code&gt; might do what you want...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:{range}foldo[pen][!]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's say you have folds like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10: F1&amp;lt;&#xA;+1: ...&#xA;+2: F1.1&amp;gt;&#xA;??: ...&#xA;??: F1.1.1&amp;gt;&#xA;??: ...&#xA;+3: ...&#xA;+4: F1.2&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;&amp;lt;&lt;/code&gt; indicates an open fold, &lt;code&gt;&amp;gt;&lt;/code&gt; closed. &lt;code&gt;F1&lt;/code&gt; is an open fold at line 10. &lt;code&gt;F1.1&lt;/code&gt; is a closed fold nested inside &lt;code&gt;F1&lt;/code&gt; that starts +2 lines down. &lt;code&gt;??&lt;/code&gt; indicates that we can't currently see that line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're on line 10 then this will open &lt;code&gt;F1.1&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:+2foldo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add a bang, &lt;code&gt;:+2foldo!&lt;/code&gt; and it will operate recursively so &lt;code&gt;F1.1.1&lt;/code&gt; will open as well. With range &lt;code&gt;+4&lt;/code&gt; you'll also open &lt;code&gt;F1.2&lt;/code&gt; as well as any folds nested inside it (if you are using &lt;code&gt;!&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that makes sense. Play around with it. Note the close equivalent; it is the same format with name &lt;code&gt;foldc[lose]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using the Marker type of folds (surrounded with &lt;code&gt;{{{&lt;/code&gt; and &lt;code&gt;}}}&lt;/code&gt;) then an alternative is to go the end of the first line of the open fold of interest, put the cursor on one of the three &lt;code&gt;{&lt;/code&gt;, hit &lt;code&gt;V%&lt;/code&gt; which will select everything inside the fold and then hit &lt;code&gt;zO&lt;/code&gt; for recursive open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of this is as nice as a simple, short Normal mode key sequence...perhaps someone knows folds better than me and has a better idea...but you could use a mapping to keep it in Normal mode. I haven't tested this yet but I'm thinking along the lines of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;zO ':+' . v:count1 . 'foldo!&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So Normal mode sequence &lt;code&gt;2\zO&lt;/code&gt; should do the same as &lt;code&gt;:+2foldo!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; @ropeladder has a Normal/Visual mode command that doesn't require closing the outer fold first:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;]z&lt;/code&gt; : jump to end of current open fold&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;s-v&amp;gt;&lt;/code&gt; : (Shift-V) start linewise visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[z&lt;/code&gt; : jump to beginning of current open fold&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;zO&lt;/code&gt; : recursively open all folds that are visually selected&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Of course, it'd be much easier to close the outer fold first and use &lt;code&gt;zczA&lt;/code&gt; but since this doesn't close first and isn't on the command line I figured I'd note it. (And bonus points for &lt;code&gt;]z&lt;/code&gt;/&lt;code&gt;[z&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-04-19T12:42:44.440" LastActivityDate="2020-04-19T12:42:44.440" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16047" PostTypeId="2" ParentId="16037" CreationDate="2018-04-26T05:30:17.090" Score="45" Body="&lt;h3&gt;Don't Panic!&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Recovering files is &lt;em&gt;always&lt;/em&gt; safe, because vim &lt;em&gt;never&lt;/em&gt; writes any changes until you write them yourself. So recovering from a swap file and then closing without saving won't change anything.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Organize your swapfiles:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Get vim to put all your swap files in the same place, so you always know where they are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set directory^=$HOME/.vim/swap//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or wherever you prefer. Use &lt;code&gt;//&lt;/code&gt; at the end of the filename makes vim use absolute file paths for the swap file names so you don't get name collisions. &lt;strong&gt;Make sure the directory exists, or vim won't use it&lt;/strong&gt; (it won't create it for you).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: This only works on environment variables, if you want to use a vimscript variable then we need to use some &lt;code&gt;:execute&lt;/code&gt; magic:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;set directory^=&quot;.my_vim_home_var.&quot;/swap//&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Diff the differences:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim's help suggests a very useful command to use in this situation: &lt;code&gt;:DiffOrig&lt;/code&gt;.  It's &lt;strong&gt;not a default vim command&lt;/strong&gt;, so copy the implementation from &lt;code&gt;:h :DiffOrig&lt;/code&gt; into your vimrc. (it's also in &lt;code&gt;$VIMRUNTIME/defaults.vim&lt;/code&gt; if you have vim8). Now, you can recover the file and simply run DiffOrig to get a vimdiff of what's changed from the unmodified version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to compare the contents of multiple swap files, recover your file with each different swap file, and then write the result to temporary files. Now load up the files and run &lt;code&gt;:diffthis&lt;/code&gt; on each file, make the changes you want, write back to the original file, and delete the temporary and swap files.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Useful commands:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:swapname&lt;/code&gt; : get the name vim is using for the swap file for the current buffer (&lt;code&gt;:h :swapname&lt;/code&gt;)&#xA;&lt;code&gt;:recover&lt;/code&gt; : recovers the selected file, same as when you start vim and press &lt;kbd&gt;R&lt;/kbd&gt; (&lt;code&gt;:h :recover&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Check out the help:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim has an entire section of the user manual on recovery: &lt;code&gt;:usr_11.txt&lt;/code&gt;&lt;br&gt;&#xA;Vim's reference help on swap files: &lt;code&gt;:h swap-file&lt;/code&gt; , &lt;code&gt;h recovery&lt;/code&gt;&lt;br&gt;&#xA;Help on the directory option (for setting the swap file location): &lt;code&gt;:h 'directory'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Modified example for setting directory, as pointed out in comments by @B Layer&lt;/p&gt;&#xA;" OwnerUserId="16910" LastEditorUserId="16910" LastEditDate="2018-06-08T04:14:18.970" LastActivityDate="2018-06-08T04:14:18.970" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16048" PostTypeId="2" ParentId="5333" CreationDate="2018-04-26T09:26:03.120" Score="1" Body="&lt;p&gt;There&amp;rsquo;s no shortcut I'm aware of, but Vim does have a feature that allows you to move a visual selection. It's not useful for the specific use-case described, but it might be for moves of larger selections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#V&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help V&lt;/code&gt;&lt;/a&gt; explains:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;With &lt;code&gt;[count]&lt;/code&gt; select the same number of lines as used for the last Visual operation, but at the current cursor position, multiplied by &lt;code&gt;[count]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you can move a linewise visual selection with the following sequence:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pressing &lt;kbd&gt;y&lt;/kbd&gt; to perform a &amp;ldquo;Visual operation&amp;rdquo;,&lt;/li&gt;&#xA;&lt;li&gt;Using whichever of Vim&amp;rsquo;s motions are the most convenient/efficient to move the cursor to the first line of the location where you want the selection to be moved to. &lt;/li&gt;&#xA;&lt;li&gt;Pressing &lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; to re-enter Visual mode with the same number of lines selected.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This obviously stores the previously selected text in the yank and unnamed registers. If this is not desirable, you can prevent it by using &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;_&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt; to yank into the &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#quote_&quot; rel=&quot;nofollow noreferrer&quot;&gt;black hole register&lt;/a&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other commands to enter visual mode also take &lt;a href=&quot;https://vi.stackexchange.com/questions/tagged/count&quot;&gt;counts&lt;/a&gt;, so you can use this technique for characterwise or blockwise selections, too.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-04-26T09:26:03.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16049" PostTypeId="1" AcceptedAnswerId="16050" CreationDate="2018-04-26T10:00:33.350" Score="1" ViewCount="419" Body="&lt;p&gt;This problem started because I want to run a command in visual mode with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent! '&amp;lt;,'&amp;gt; command here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however if I do a mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap ,a :silent! '&amp;lt;,'&amp;gt; command here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then in vim runs like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;silent! '&amp;lt;,'&amp;gt; command here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the same happens if i use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap ,a :exe &quot;silent! '&amp;lt;,'&amp;gt; command&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that it is converted to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;exe &quot;silent!....&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11944" LastEditorUserId="343" LastEditDate="2018-04-26T10:11:22.853" LastActivityDate="2018-04-27T00:49:18.683" Title="remove automatic '&lt;,'&gt; when hitting colon in visual mode" Tags="|key-bindings|vimscript|visual-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16050" PostTypeId="2" ParentId="16049" CreationDate="2018-04-26T10:03:54.057" Score="7" Body="&lt;p&gt;Putting aside mappings for a moment, what do we do when we're manually entering commands and find a range on the command line that we don't want? Hit &lt;kbd&gt;Backspace&lt;/kbd&gt; five times? Well...yes...that's one possibility but there's &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-U&quot; rel=&quot;nofollow noreferrer&quot;&gt;something better than that&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                    c_CTRL-U&#xA;CTRL-U      Remove all characters between the cursor position and&#xA;            the beginning of the line. ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since a mapping is essentially the same as the equivalent manual command we just need to translate &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;U&lt;/kbd&gt; to something that works in Vimscript. That would be the equivalent &lt;a href=&quot;http://vimhelp.appspot.com/intro.txt.html#keycodes&quot; rel=&quot;nofollow noreferrer&quot;&gt;keycode&lt;/a&gt; &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So add &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; at the beginning of your mapping right after the opening &lt;code&gt;:&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap ,a :&amp;lt;C-U&amp;gt;silent! ..etc..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will clear &lt;em&gt;any&lt;/em&gt; text that happens to currently be on the command line before your command(s) are applied.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-04-27T00:49:18.683" LastActivityDate="2018-04-27T00:49:18.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16052" PostTypeId="1" AcceptedAnswerId="16057" CreationDate="2018-04-26T13:13:21.517" Score="3" ViewCount="1576" Body="&lt;p&gt;I noticed, that in any source code file, regardless of the programming language, I can use the dictionary autocompletion (&lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;x&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;k&lt;/kbd&gt;) if the &lt;code&gt;spell&lt;/code&gt; option is set, if it's not, then the editor gives an error message, &quot;'dictionary' option is empty&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to make the dictionary autocompletion enabled without setting of the &lt;code&gt;spell&lt;/code&gt; option?&lt;/p&gt;&#xA;" OwnerUserId="2798" LastEditorUserId="1841" LastEditDate="2018-04-26T15:32:58.030" LastActivityDate="2018-04-26T16:32:17.407" Title="How to enable dictionary autocompletion without spell option set" Tags="|autocompletion|spell-checking|dictionary|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16053" PostTypeId="1" CreationDate="2018-04-23T23:37:19.310" Score="1" ViewCount="1333" Body="&lt;p&gt;I'm trying to automate cleaning up old vim undo files that are for files that have since been deleted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I've created a new vim script at &lt;code&gt;~/.vim/autoload/cleanupUndos.vim&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function cleanupUndos#clean()&#xA;    let undofiles = systemlist('ls /Users/me/.vim/undodir/')&#xA;&#xA;    for undofile in undofiles&#xA;        let filepath = substitute(undofile, &quot;%&quot;, &quot;/&quot;, &quot;g&quot;)&#xA;        if empty(glob(filepath))&#xA;            echo &quot;File doesn't exist, deleting undofile for &quot; filepath&#xA;            let deleteresult = delete(undofile)&#xA;            echo deleteresult == 0 ? 'SUCCEEDED' : 'FAILED'&#xA;        endif&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in my &lt;code&gt;~/.vimrc&lt;/code&gt; I've set the undofile and undodir and added the autocmd for running the cleanup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set undofile&#xA;set undodir=/Users/me/.vim/undodir&#xA;autocmd VimEnter * :call cleanupUndos#clean()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that when I open vim, it immediately prints &lt;code&gt;FAILED&lt;/code&gt; and none of the files ever get deleted. I can run the &lt;code&gt;delete(filename)&lt;/code&gt; command in a vim session and it works, but it doesn't seem to work when run from the script. I've tried &lt;a href=&quot;https://unix.stackexchange.com/a/430646/182202&quot;&gt;different ways of deleting files&lt;/a&gt; with no success. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I delete files from within a vimscript?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I'm running Vim version 7.4.8056 on MacOS Sierra 10.12.6.)&lt;/p&gt;&#xA;" OwnerUserId="17300" OwnerDisplayName="Logan" LastActivityDate="2018-08-25T10:02:03.880" Title="How to delete a file from within a vimscript?" Tags="|macos|vimrc|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16054" PostTypeId="2" ParentId="16053" CreationDate="2018-04-26T14:23:57.990" Score="1" Body="&lt;p&gt;You will need to escape file name since it contains &quot;/&quot;. Try using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delete(fnameescape(filepath))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check &lt;code&gt;:help fnameescape&lt;/code&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="16636" LastActivityDate="2018-04-26T14:23:57.990" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16056" PostTypeId="2" ParentId="16052" CreationDate="2018-04-26T15:32:14.703" Score="3" Body="&lt;p&gt;The doc &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#compl-dictionary&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h compl-dictionary&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-X CTRL-K        Search the files given with the 'dictionary' option&#xA;                     for words that start with the keyword in front of the&#xA;                     cursor.&#xA;                     [...] By default,&#xA;                     the 'dictionary' option is empty.&#xA;                     For suggestions where to find a list of words, see the&#xA;                     'dictionary' option.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you simply need to set you &lt;code&gt;'dictionary'&lt;/code&gt; option to get the completion you are looking for&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-04-26T15:32:14.703" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16057" PostTypeId="2" ParentId="16052" CreationDate="2018-04-26T16:21:24.660" Score="3" Body="&lt;p&gt;I use the following in my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-k&amp;gt; SpellCheck(&quot;\&amp;lt;c-x&amp;gt;\&amp;lt;c-k&amp;gt;&quot;)&#xA;nnoremap z= :&amp;lt;c-u&amp;gt;call SpellCheck()&amp;lt;cr&amp;gt;z=&#xA;function! SpellCheck(...)&#xA;  let s:spell_restore = &amp;amp;spell&#xA;  set spell&#xA;  augroup restore_spell_option&#xA;    autocmd!&#xA;    autocmd CursorMoved,CompleteDone &amp;lt;buffer&amp;gt; let &amp;amp;spell = s:spell_restore | autocmd! restore_spell_option&#xA;  augroup END&#xA;  return a:0 ? a:1 : ''&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The basic idea is to turn on &lt;code&gt;'spell'&lt;/code&gt; for &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-k&amp;gt;&lt;/code&gt; and &lt;code&gt;z=&lt;/code&gt; and then restore the previous value of &lt;code&gt;'spell'&lt;/code&gt;. It is a bit clumsy for &lt;code&gt;z=&lt;/code&gt; when no spell option is selected, but it works pretty well in practice.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-04-26T16:32:17.407" LastActivityDate="2018-04-26T16:32:17.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16058" PostTypeId="1" AcceptedAnswerId="16059" CreationDate="2018-04-26T17:48:06.780" Score="3" ViewCount="919" Body="&lt;p&gt;Given some text stored in a variable, is it possible to write this text to an arbitrary &lt;em&gt;buffer&lt;/em&gt; in the background? I ask about buffers specifically because I'm aware of &lt;code&gt;writefile()&lt;/code&gt;, but I want to write to a buffer with no associated file (i.e. &lt;code&gt;buftype=acwrite&lt;/code&gt;). The buffer holds a representation of a database record.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is possible via the Ruby API, but I can't figure out how to do with vimscript. &lt;code&gt;append()&lt;/code&gt; only operates on the current buffer. &lt;/p&gt;&#xA;" OwnerUserId="13151" LastEditorUserId="13151" LastEditDate="2018-04-26T17:59:23.867" LastActivityDate="2018-04-27T09:59:03.380" Title="Manipulate content of background (non-current) buffers from vimscript" Tags="|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16059" PostTypeId="2" ParentId="16058" CreationDate="2018-04-26T17:56:53.763" Score="2" Body="&lt;p&gt;If your Vim version is more recent than &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.0.1039&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.0.1039&lt;/a&gt;, you could use the &lt;code&gt;setbufline()&lt;/code&gt; function. It allows you to replace a line in an arbitrary buffer with any text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usage example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setbufline(12, 34, 'hello world')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should replace the text on the line &lt;code&gt;34&lt;/code&gt; inside the buffer &lt;code&gt;12&lt;/code&gt; with &lt;code&gt;hello world&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What if the old content has more lines than the new content?&#xA;  Do you know how I would get rid of those lines?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Maybe you could replace the first lines of the buffer with the text you have stored in your variable, then replace all the rest with empty strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let your_buffer_number = 123&#xA;let your_new_lines = ['foo', 'bar', 'baz']&#xA;let remaining_lines = len(getbufline(your_buffer_number, 1, '$')) - len(your_new_lines)&#xA;call setbufline(your_buffer_number, 1, your_new_lines + repeat([''], remaining_lines))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will not delete the superfluous lines, but it should make them empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace the buffer number &lt;code&gt;123&lt;/code&gt; with the one you're actually using, and the list of texts &lt;code&gt;['foo', 'bar', 'baz']&lt;/code&gt; with the ones you want to write in your buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h getbufline()&#xA;:h setbufline()&#xA;:h repeat()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you're using Neovim, and it's more recent than &lt;a href=&quot;https://github.com/neovim/neovim/tree/v0.2.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;v0.2.0&lt;/a&gt;, then you could use the &lt;code&gt;nvim_buf_set_lines()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usage example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call nvim_buf_set_lines(123, 0, len(getbufline(123, 1, '$')), 0, ['foo', 'bar', 'baz'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should replace all the lines in the &lt;code&gt;123&lt;/code&gt;th buffer with the lines &lt;code&gt;foo&lt;/code&gt;, &lt;code&gt;bar&lt;/code&gt; and &lt;code&gt;baz&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a result, this function would also delete the superfluous lines, if the old contents of the buffer is longer than the new one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I'm not sure about the exact Neovim version which introduced the function, but &lt;code&gt;0.2.0&lt;/code&gt; is the one given by&#xA;&lt;a href=&quot;https://github.com/tweekmonster/helpful.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;helpful.vim&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17270" LastEditorUserId="17270" LastEditDate="2018-04-27T09:59:03.380" LastActivityDate="2018-04-27T09:59:03.380" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16060" PostTypeId="1" AcceptedAnswerId="16062" CreationDate="2018-04-27T09:17:58.620" Score="5" ViewCount="533" Body="&lt;p&gt;I have been using VIM for quite some time now and I wish to level up my VIM skills. I have started going through some VimL or vim script as it's called.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;To motivate me further, I am just curious to find out, are there any other potential advantages of learning VimL/vimscript apart from being able to develop and understand plugins for VIM ?&lt;/li&gt;&#xA;&lt;li&gt;Kindly provide/suggest other application which uses VimL (if at all) apart from VIM plugin development?&lt;/li&gt;&#xA;&lt;li&gt;Is there any other use-case/application of VimL?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Any projects (not focused on vim plugin development) using VimL as the main language would also be an interesting information worth mentioning.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="17317" LastEditorUserId="17317" LastEditDate="2018-04-27T11:04:46.587" LastActivityDate="2018-04-27T11:04:46.587" Title="What are/could be the potential advantages of learning VimL or vim scripting language?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ClosedDate="2018-04-27T11:37:15.607" ContentLicense="CC BY-SA 3.0" />
  <row Id="16062" PostTypeId="2" ParentId="16060" CreationDate="2018-04-27T09:56:30.860" Score="5" Body="&lt;p&gt;Vimscript is used to customise the behaviour of your editor, and the uses to which you can apply it are literally endless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the boundary between Vim &lt;em&gt;configuration&lt;/em&gt; and Vim &lt;em&gt;scripting&lt;/em&gt; is pretty fuzzy: in many respects, if you have a &lt;code&gt;.vimrc&lt;/code&gt; file, then you have already started learning Vimscript, because Vimscript is what that file contains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also that a plugin is just some Vimscript neatly packaged up, often (but not always) so that it can be distributed and used by other people. Many plugins started out as just a bit of Vimscript in someone's .vimrc, and then gained functionality and grew until the author decided to split them out into a plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yes: if you ever want Vim to do &lt;em&gt;anything&lt;/em&gt; differently from how it would if you started it with &lt;code&gt;vim -Nu NONE&lt;/code&gt;, then there is lots of benefit to learning Vimscript, even if you don't intend to develop and release any plugins yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plus it's just fun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, your question about whether anyone uses Vimscript for any &lt;em&gt;projects&lt;/em&gt; that aren't related to Vim development doesn't really make much sense. There are no interpreters for Vimscript other than Vim, so anything you develop in Vimscript must run inside Vim, even if it's not strictly speaking a &lt;em&gt;plugin&lt;/em&gt;.&lt;sup&gt;*&lt;/sup&gt; &lt;a href=&quot;https://github.com/zyedidia/vim-snake&quot; rel=&quot;nofollow noreferrer&quot;&gt;This implementation of the game Snake&lt;/a&gt; doesn't really have anything to do with editing text, but it &lt;em&gt;is&lt;/em&gt; still a Vim plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And while Vimscript is Turing complete and thus could in &lt;em&gt;theory&lt;/em&gt; be used for pretty much anything, in reality it's very tailored for the task of customising Vim's behaviour, and has many rough edges, so its utility for building code that is completely unrelated to Vim (other than using it as an installation platform) is pretty limited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* If you wrote 10,000 lines of Vimscript and told anyone that wanted to use it to copy and paste it into their .vimrc, that's not a &quot;plugin&quot;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-04-27T10:04:49.720" LastActivityDate="2018-04-27T10:04:49.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16063" PostTypeId="2" ParentId="15974" CreationDate="2018-04-27T10:24:32.317" Score="3" Body="&lt;p&gt;You can change the location in which the cursor is left after a search by using an &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#search-offset&quot; rel=&quot;nofollow noreferrer&quot;&gt;offset&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can either an &quot;end&quot; or &quot;start&quot; offset for your specific example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/:q:/e+2&#xA;/:q:/s+4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#search-offset&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help search-offset&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can apply these offsets retroactively to an existing search by using an empty regular expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/:q:&#xA;//e+2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-04-27T10:24:32.317" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16065" PostTypeId="1" AcceptedAnswerId="16066" CreationDate="2018-04-27T14:26:06.307" Score="4" ViewCount="4910" Body="&lt;ol&gt;&#xA;&lt;li&gt;Is there a way I can directly import/insert the output of any linux command into vim editor? For example: &lt;code&gt;pwd&lt;/code&gt; in currently open vim buffer.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;From terminal how can I directly open command output for manipulation? For example: opening &lt;code&gt;lshw&lt;/code&gt; output in vim and filter unwanted info and quick save file.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="17317" LastEditorUserId="17317" LastEditDate="2018-04-27T14:53:16.173" LastActivityDate="2021-06-29T14:52:39.460" Title="How can I import output from linux commands into vim for editing?" Tags="|external-command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16066" PostTypeId="2" ParentId="16065" CreationDate="2018-04-27T14:31:00.020" Score="4" Body="&lt;h3&gt;Import shell output&lt;/h3&gt;&#xA;&lt;p&gt;Launch vi or vim and try:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;!!pwd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The output will be pasted in the current buffer&lt;/p&gt;&#xA;&lt;p&gt;Checkout the possible options:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:help !!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Pipe &lt;code&gt;stdout&lt;/code&gt; to vim&lt;/h3&gt;&#xA;&lt;p&gt;Try:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;pwd | vi -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17308" LastEditorUserId="10604" LastEditDate="2021-06-29T14:52:39.460" LastActivityDate="2021-06-29T14:52:39.460" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16067" PostTypeId="2" ParentId="16065" CreationDate="2018-04-27T14:40:42.770" Score="10" Body="&lt;p&gt;You could use &lt;code&gt;:read&lt;/code&gt; (see &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#%3aread&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :read&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;:[range]r[ead] [++opt] !{cmd}&#xA;          Execute {cmd} and insert its standard output below&#xA;          the cursor or the specified line.  A temporary file is&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For example: &lt;code&gt;:read ! pwd&lt;/code&gt; will put the current working directory at the cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you can pipe your command to grep to filter what you want.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-04-27T14:40:42.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16068" PostTypeId="1" AcceptedAnswerId="16070" CreationDate="2018-04-27T14:46:30.370" Score="1" ViewCount="169" Body="&lt;p&gt;How to remove a line and paste it at the beginning of a range?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 1&#xA;line 2&#xA;line 3&#xA;line 4&#xA;xxxxxxxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, here I want to remove the 5th line and paste it before the first two lines, to change the buffer into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xxxxxxxxline 1&#xA;xxxxxxxxline 2&#xA;line 3&#xA;line 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to do that with a simple vim command?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="1841" LastEditDate="2018-04-27T15:21:58.940" LastActivityDate="2018-05-22T10:35:11.340" Title="How to remove a line and paste it at the beginning of a range" Tags="|cut-copy-paste|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16069" PostTypeId="2" ParentId="16068" CreationDate="2018-04-27T14:56:33.467" Score="3" Body="&lt;p&gt;You can do the following, starting with your buffer like this and your cursor on the first &lt;code&gt;x&lt;/code&gt; of the last line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 1&#xA;line 2&#xA;line 3&#xA;line 4&#xA;xxxxxxxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First we copy the last line with &lt;kbd&gt;Y&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 1&#xA;line 2&#xA;line 3&#xA;line 4&#xA;xxxxxxxx&#xA;xxxxxxxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your cursor is now on the first &lt;code&gt;x&lt;/code&gt; of the new last line, so you enter visual bloc mode with &lt;kbd&gt;ctrl+v&lt;/kbd&gt; and select the lines with &lt;kbd&gt;$&lt;/kbd&gt; (to go to the end of the line) and &lt;kbd&gt;k&lt;/kbd&gt; to select the line above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then delete the lines with &lt;kbd&gt;d&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 1&#xA;line 2&#xA;line 3&#xA;line 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt; to go to the first character of the first line and paste what you just deleted with &lt;kbd&gt;P&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xxxxxxxxline 1&#xA;xxxxxxxxline 2&#xA;line 3&#xA;line 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So all in one you can do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Y&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;ctrl+v&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#visual-block&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h visual-block&lt;/code&gt;&lt;/a&gt; for more details about visual block mode.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-04-27T14:56:33.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16070" PostTypeId="2" ParentId="16068" CreationDate="2018-04-27T16:20:52.953" Score="1" Body="&lt;p&gt;Here's a couple of alternative methods. They're&#xA;both a few more keystrokes than &lt;a href=&quot;https://vi.stackexchange.com/a/16069/343&quot;&gt;@statox's&#xA;answer&lt;/a&gt;,&#xA;but I think they're worth posting because they&#xA;show a few different techniques.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Visual block mode &amp;amp; &lt;code&gt;Ctrl-R&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Like @statox, I'm presuming you start (on the&#xA;first character) of the 5th line for this&#xA;solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First we yank all the &lt;code&gt;x&lt;/code&gt; characters (but not the newline):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we delete the line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we jump to the top of the file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we enter visual block mode, and move down a line so the beginning of the start of both lines are selected:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we insert at the start of the visual block. When doing this, anything we insert will be inserted on both lines of the block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;&lt;code&gt;I&lt;/code&gt;&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, we enter the contents of the yank register by using insert mode's Ctrl-R feature. (See &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;:help i_CTRL-R&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;0&lt;/code&gt;&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, we leave insert mode:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the complete set of commands is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;I&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;&lt;code&gt;0&lt;/code&gt;&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Ex Commands&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here's a method that only uses the command line. The following commands can be run with the cursor at any position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First we move line 5 to the top of the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5m0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then we create another copy of that line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1t2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then we join the lines up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,2norm!Jx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, the complete set of ex commands is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5m0&#xA;:1t2&#xA;:1,2norm!Jx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-05-22T10:35:11.340" LastActivityDate="2018-05-22T10:35:11.340" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16071" PostTypeId="1" AcceptedAnswerId="16072" CreationDate="2018-04-27T18:32:25.973" Score="5" ViewCount="6252" Body="&lt;p&gt;I have multiple lines like the once below in .vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap \html :-1read $HOME/.vim/snippets/html_basic.snippet&amp;lt;CR&amp;gt;&#xA;nnoremap \bs   :-1read $HOME/.vim/snippets/bootstrap.snippet&amp;lt;CR&amp;gt;&#xA;...&#xA;more snippets like these&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem is if I want to change my snippet directory &lt;code&gt;$HOME/.vim/snippets&lt;/code&gt; to something else like &lt;code&gt;$HOME/.vim/templates/&lt;/code&gt; I would have to edit all the map commands above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I refactor and execute the same map commands using variables containing snippet directory path? For instance, something like this ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# variable holding snippet directory path&#xA;let snippet_home = &quot;$HOME/.vim/templates/&quot;&#xA;&#xA;# map commands using $snippet_home variable value to read file contents&#xA;nnoremap \html :-1read $snippet_home/html_basic.snippet&amp;lt;CR&amp;gt;&#xA;nnoremap \bs   :-1read $snippet_home/bootstrap.snippet&amp;lt;CR&amp;gt;&#xA;...&#xA;more snippets like these&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way if I move or rename my &lt;code&gt;snippet&lt;/code&gt; directory I would have to simple update &lt;code&gt;snippet_home&lt;/code&gt; variable and all map commands remain the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kindly suggest how do I achieve this in vimscript?&lt;/p&gt;&#xA;" OwnerUserId="17317" LastEditorUserId="17317" LastEditDate="2018-04-27T18:37:28.077" LastActivityDate="2020-04-25T20:16:19.523" Title="How can I use a string variables for filepath in vimscript map command?" Tags="|vimscript|variables|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16072" PostTypeId="2" ParentId="16071" CreationDate="2018-04-27T20:36:08.287" Score="6" Body="&lt;p&gt;One method is to use a &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping which evaluates the RHS of the mapping as Vimscript rather than use it literally as for regular mappings. The tricky part of this is the fact that we have two levels of variable expansion: &lt;code&gt;snippet_home&lt;/code&gt; and the environment variable contained within, &lt;code&gt;$HOME&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first approach expands the env var when the containing variable is initialized...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let snippet_home = $HOME . '/.vim/templates'&#xA;nnoremap &amp;lt;expr&amp;gt; \html ':-1read ' . snippet_home . '/html_basic.snippet&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works best with an environment variable that is static (doesn't change often). &lt;code&gt;$HOME&lt;/code&gt; certainly qualifies as such.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second approach will expand the environment variable each time you execute the mapped command...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let snippet_home = '$HOME/.vim/templates'&#xA;nnoremap &amp;lt;expr&amp;gt; \html ':-1read ' . expand(snippet_home)  . '/html_basic.snippet&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping will evaluate snippet_home as &lt;code&gt;$HOME/.vim/templates&lt;/code&gt; so we need to evaluate it again. Thus, the call to &lt;code&gt;expand()&lt;/code&gt; which, among other things, will &quot;expand environment variables&quot;. See &lt;code&gt;:h expand()&lt;/code&gt; (you'll have to scroll down a bit to find the part about env vars).&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="12003" LastEditDate="2018-04-28T11:58:16.450" LastActivityDate="2018-04-28T11:58:16.450" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16073" PostTypeId="1" AcceptedAnswerId="16074" CreationDate="2018-04-27T23:47:37.067" Score="0" ViewCount="556" Body="&lt;p&gt;I got to know commands like &lt;code&gt;ls -la | vim -&lt;/code&gt; can be used to open Linux command output in vim.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What does &lt;code&gt;-&lt;/code&gt; mean after vim?&lt;/li&gt;&#xA;&lt;li&gt;Is it some kind of special switch?&lt;/li&gt;&#xA;&lt;li&gt;Why doesn't simply using &lt;code&gt;ls -la | vim&lt;/code&gt; works ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="17317" LastActivityDate="2018-04-28T02:49:34.183" Title="What does `-` mean in command `ls -la | vim -`?" Tags="|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16074" PostTypeId="2" ParentId="16073" CreationDate="2018-04-28T02:49:34.183" Score="2" Body="&lt;p&gt;from &lt;code&gt;help --&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Start editing a new buffer, which is filled with text&#xA;that is read from stdin.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ls | vim&lt;/code&gt; doesn't work, because vim reads it's commands from the terminal (as opposed to the content of a buffer)&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-04-28T02:49:34.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16076" PostTypeId="1" CreationDate="2018-04-28T23:25:36.457" Score="1" ViewCount="475" Body="&lt;p&gt;I have multiple lines with the key &quot;booktitle&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  booktitle={Advances in Cryptology - CRYPTO' 89 Proceedings},&#xA;  volume={435},&#xA;  series={Lecture Notes in Computer Science},&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to replace the uppercase letters of each value with {LETTER}, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  booktitle={{A}dvances in {C}ryptology - {CRYPTO}' 89 {P}roceedings},&#xA;  volume={435},&#xA;  series={Lecture Notes in Computer Science},&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could you help me please?&lt;/p&gt;&#xA;" OwnerUserId="17152" LastEditorUserId="12003" LastEditDate="2018-04-29T13:29:17.857" LastActivityDate="2018-04-29T13:29:17.857" Title="Replace capitalized letters in matching lines" Tags="|replace|multiple-lines|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16077" PostTypeId="1" AcceptedAnswerId="16080" CreationDate="2018-04-29T00:07:02.923" Score="8" ViewCount="552" Body="&lt;p&gt;Currently when I use :terminal to quickly open a terminal in vim, it opens in a new pane. Is it possible to change this behaviour so that it replaces the current one? I realise this would be undesirable for most, but I would rather open the new pane and get it where I want it first (maybe I'll need it open for a little while on the far right of the screen, but if I call :terminal it'll split horizontally and put the terminal on the bottom. It's also much quicker and easier to resize the pane with shortcuts &lt;em&gt;before&lt;/em&gt; calling :terminal)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="17341" LastActivityDate="2018-04-29T16:02:14.513" Title="make :terminal use the current pane" Tags="|terminal-buffer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16078" PostTypeId="2" ParentId="16076" CreationDate="2018-04-29T00:25:18.390" Score="5" Body="&lt;p&gt;To obtain this result you could use &lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#%3Asubstitute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:substitute&lt;/code&gt;&lt;/a&gt;, for example with the cursor on the first line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\u\+/{\0}/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\u\+&lt;/code&gt; one or more uppercase character: equivalent to &lt;code&gt;[A-Z]\+&lt;/code&gt;, see&lt;a href=&quot;https://vimhelp.appspot.com/pattern.txt.html#%2F%5Cu&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h \u&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\0&lt;/code&gt; whole matched pattern, see &lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#sub-replace-special&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h sub-replace-special&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g&lt;/code&gt; is a flag needed to replace all occurrences in the line unless &lt;code&gt;gdefault&lt;/code&gt; is on&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To affect more than one line, you can specify a &lt;a href=&quot;https://vimhelp.appspot.com/cmdline.txt.html#cmdline-ranges&quot; rel=&quot;nofollow noreferrer&quot;&gt;range&lt;/a&gt;, e.g. &lt;code&gt;:%s&lt;/code&gt; for the entire file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to execute this substitution multiple times but only on lines starting with a defined pattern (&lt;code&gt;/^  booktitle=/&lt;/code&gt; in this case), &lt;a href=&quot;https://vimhelp.appspot.com/repeat.txt.html#%3Aglobal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:global&lt;/code&gt;&lt;/a&gt; is probably what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^  booktitle=/s/\u\+/{\0}/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12003" LastEditorUserId="12003" LastEditDate="2018-04-29T13:09:55.603" LastActivityDate="2018-04-29T13:09:55.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16079" PostTypeId="2" ParentId="15830" CreationDate="2018-04-29T06:09:55.003" Score="0" Body="&lt;p&gt;In SpaceVim we have a code snippet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&#xA;  &quot;&quot;&#xA;  &quot; set language&#xA;  if !empty(g:spacevim_language)&#xA;    silent exec 'lan ' . g:spacevim_language&#xA;  endif&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so I think you should use a correct value.&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2018-04-29T06:09:55.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16080" PostTypeId="2" ParentId="16077" CreationDate="2018-04-29T16:02:14.513" Score="7" Body="&lt;p&gt;You can replace the current window with a terminal using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:terminal ++curwin&#xA;:ter ++curwin     &quot; shorter form&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can create a mapping or command for convenience&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap \t :terminal ++curwin&amp;lt;cr&amp;gt;&#xA;command! Terminal terminal ++curwin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-04-29T16:02:14.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16081" PostTypeId="2" ParentId="10708" CreationDate="2018-04-30T04:54:57.790" Score="5" Body="&lt;p&gt;I actually made it work just fine with &lt;code&gt;termguicolors&lt;/code&gt;. This is what I did&#xA;1. in my ~/.bash_profile i put this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export TERM=xterm-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and inside my ~/.vimrc I had this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax enable&#xA;colorscheme Spacegray&#xA;&#xA;set termguicolors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it worked perfectly! &lt;a href=&quot;https://github.com/neovim/neovim/issues/6096#issuecomment-279224144&quot; rel=&quot;noreferrer&quot;&gt;reference&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14510" LastActivityDate="2018-04-30T04:54:57.790" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16082" PostTypeId="1" AcceptedAnswerId="16084" CreationDate="2018-04-30T07:43:31.710" Score="1" ViewCount="1938" Body="&lt;p&gt;In vim I sometimes want to quickly change the content of a variable using its current content as template using vim editing capabilities. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I want to append the word &quot;bar&quot; to the existing variable &lt;code&gt;myvar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let myvar=&quot;foo&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A possible workflow could be a ex-command (say &lt;code&gt;Edit&lt;/code&gt;) editing myvar in a new buffer with &quot;foo&quot; as its contend and upon saving the buffer it would overwrite the new content (i.e. &quot;foo bar&quot;) to the variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Edit myvar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I feel there must be an elegant solution, possibly even another workflow than the one outlined above.&lt;/p&gt;&#xA;" OwnerUserId="15083" LastActivityDate="2018-04-30T14:07:58.953" Title="How to quickly edit vim variable content?" Tags="|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16083" PostTypeId="2" ParentId="10534" CreationDate="2018-04-30T08:28:27.760" Score="5" Body="&lt;h2&gt;To combine changes from both the target and merge branches in a single command:&lt;/h2&gt;&#xA;&lt;p&gt;You can just delete the lines with Git conflict markers. The following two methods will delete all lines that start with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&#xA;=======&#xA;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Method 1:&lt;/strong&gt; &lt;em&gt;Manually Entering and Executing a Command&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:g/^&amp;lt;\{7}\|^|\{7}\|^=\{7}\|^&amp;gt;\{7}/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Method 2:&lt;/strong&gt; &lt;em&gt;Implementing a User Defined Command&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;Delete all Git conflict markers&#xA;&amp;quot;Creates the command :GremoveConflictMarkers&#xA;function! RemoveConflictMarkers() range&#xA;  echom a:firstline.'-'.a:lastline&#xA;  execute a:firstline.','.a:lastline . ' g/^&amp;lt;\{7}\|^|\{7}\|^=\{7}\|^&amp;gt;\{7}/d'&#xA;endfunction&#xA;&amp;quot;-range=% default is whole file&#xA;command! -range=% GremoveConflictMarkers &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call RemoveConflictMarkers()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Vim &lt;em&gt;diffget&lt;/em&gt; and &lt;em&gt;diffput&lt;/em&gt; will only choose one branch or the other. So the only real solution other than the one given above is to manually yank and paste from both files into the working copy.&lt;/p&gt;&#xA;" OwnerUserId="5223" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-04-30T08:28:27.760" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16084" PostTypeId="2" ParentId="16082" CreationDate="2018-04-30T08:54:07.413" Score="7" Body="&lt;p&gt;You've picked an unfortunate example, as it's more easily achieved with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let myvar .= 'bar'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Still, for more complicated edits, you could use the following commands:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Insert the variable into the buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;o&amp;lt;C-R&amp;gt;=myvar&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. In the above, &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; denotes a press of &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;, and &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is a press of &lt;kbd&gt;Return&lt;/kbd&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Perform your edits.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Reassign the contents of the line to the variable and delete the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let myvar = getline('.') | d&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Steps 1 &amp;amp; 3 can be converted into mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;ev &quot;o\&amp;lt;C-R&amp;gt;=&quot; . input('Variable: ', 'myvar', 'var') . &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;av ':let ' . input('Variable: ', 'myvar', 'var') . &quot; = getline('.') &amp;lt;bar&amp;gt; d\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These prompt the user for which variable they want to edit/assign to, offering a default of &lt;code&gt;myvar&lt;/code&gt;, and using &lt;code&gt;variable&lt;/code&gt; completion so you don't have to type out the whole variable name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;em&gt;always&lt;/em&gt; want to edit &lt;code&gt;myvar&lt;/code&gt;, you can just replace the call to &lt;code&gt;input()&lt;/code&gt; with &lt;code&gt;myvar&lt;/code&gt;. If you only want to be asked in the &lt;em&gt;first&lt;/em&gt; mapping, then you could save the name of the variable selected in a variable and use that in the second mapping: at that point you'd probably be better off using a mapping that calls a function instead of attempting to cram it into a one-liner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Creating a more polished, complete solution as described in the question is left as an exercise to the reader. You'd probably want to set up a function to create the new buffer and insert the contents of the variable, and a &lt;code&gt;BufWriteCmd&lt;/code&gt; autocommand to intercept the saving of that buffer (and &lt;em&gt;only&lt;/em&gt; that buffer) and instead reassign to the variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further reading:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help i_CTRL-R_=&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getline()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :d&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :map-expr&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help input()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :command-completion&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :function&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help autocommand&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help Cmd-event&lt;/code&gt; &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-04-30T09:21:27.163" LastActivityDate="2018-04-30T09:21:27.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16085" PostTypeId="1" AcceptedAnswerId="16086" CreationDate="2018-04-30T09:51:00.093" Score="5" ViewCount="10099" Body="&lt;p&gt;For indenting there's no problem. I enter the visual-block mode, select the  block, enter insert mode, press &lt;code&gt;ctrl-t&lt;/code&gt; (or just press &lt;code&gt;tab&lt;/code&gt;), exit the visual-block mode, and the whole block is indented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def my_function():&#xA;print('entering my_function')&#xA;print('leaving my_function')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def my_function():&#xA;    print('entering my_function')&#xA;    print('leaving my_function')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Taking this last piece of code, if I follow the same steps as described in the first paragraph, but pressing &lt;code&gt;ctrl-d&lt;/code&gt; instead of &lt;code&gt;ctrl-t&lt;/code&gt;, the result is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def my_function():&#xA;    print('entering my_function')&#xA;print('leaving my_function')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even if select both lines in the visual-block mode, only the one on which I apply the unindent command gets affected.&lt;/p&gt;&#xA;" OwnerUserId="13062" LastActivityDate="2023-02-17T13:26:29.520" Title="How to unindent code blocks?" Tags="|indentation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16086" PostTypeId="2" ParentId="16085" CreationDate="2018-04-30T10:14:58.757" Score="11" Body="&lt;p&gt;You don't need to enter insert mode via visual-block mode to indent/outdent multiple lines: you can do it directly from visual mode by pressing &lt;kbd&gt;&amp;gt;&lt;/kbd&gt; for indent and &lt;kbd&gt;&amp;lt;&lt;/kbd&gt; for outdent. (See &lt;code&gt;:help v_&amp;lt;&lt;/code&gt; and &lt;code&gt;:help v_&amp;gt;&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;To indent multiple levels, you can either repeat the operation by pressing &lt;code&gt;.&lt;/code&gt; or pass a count to the &lt;code&gt;&amp;lt;&lt;/code&gt;/&lt;code&gt;&amp;gt;&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2023-02-17T13:26:29.520" LastActivityDate="2023-02-17T13:26:29.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16087" PostTypeId="2" ParentId="5901" CreationDate="2018-04-30T11:39:53.470" Score="6" Body="&lt;p&gt;Try putting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call rpcnotify(0, 'Gui', 'WindowMaximized', 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your &lt;code&gt;ginit.vim&lt;/code&gt;. I haven't tested on Linux, but it works on Windows 7.&lt;/p&gt;&#xA;" OwnerUserId="13135" LastActivityDate="2018-04-30T11:39:53.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16089" PostTypeId="2" ParentId="16082" CreationDate="2018-04-30T14:07:58.953" Score="2" Body="&lt;p&gt;The plugin &lt;a href=&quot;https://github.com/thinca/vim-editvar&quot; rel=&quot;nofollow noreferrer&quot;&gt;editvar&lt;/a&gt; does this.  Just use &lt;code&gt;:Editvar myvar&lt;/code&gt;, where &lt;code&gt;myvar&lt;/code&gt; is a variable.  This opens a window with the variable's contents.  You can type &lt;code&gt;:w&lt;/code&gt; to update the variable value.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-04-30T14:07:58.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16090" PostTypeId="1" AcceptedAnswerId="16091" CreationDate="2018-04-30T14:30:26.750" Score="4" ViewCount="2466" Body="&lt;p&gt;I'm trying to pass the word under the cursor to gtags and chain the definition search and the reference search together using a single function key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My understanding is that this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F4&amp;gt; :Gtags -di &amp;lt;cword&amp;gt;&amp;lt;CR&amp;gt;:Gtagsa -ri &amp;lt;cword&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get the following message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error: Line which matches to &amp;lt;cword&amp;gt; not found.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just using &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; should work. And using the following from &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/32.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; works fine and expands &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; as I would expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;g :grep -R &amp;lt;cword&amp;gt; .&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The word under the cursor is passed to grep and searched for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;nmap&lt;/code&gt;, &lt;code&gt;noremap&lt;/code&gt;, and &lt;code&gt;nnoremap&lt;/code&gt; (I understand the difference, I was just trying everything). I've also tried &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;, &lt;code&gt;'&amp;lt;cword&amp;gt;'&lt;/code&gt;, and &lt;code&gt;expand('&amp;lt;cword&amp;gt;')&lt;/code&gt;. I've yet to find a combination that works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best I've been able to find is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F4&amp;gt; :Gtags -di &amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;&amp;lt;CR&amp;gt;:Gtagsa -ri &amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will get the word under the cursor and pass it to the definition search, but jump to the beginning of the line and pass that word to the reference search. For example, given the following with the cursor over &lt;code&gt;my_func&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void my_func(void)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The QuickFix opens with the location of the definition of &lt;code&gt;my_func&lt;/code&gt;, but then returns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error: Line which matches to void not found.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the proper way to map &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; so that both commands are run? Why does &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; work when passed to &lt;code&gt;grep&lt;/code&gt; but not &lt;code&gt;Gtags&lt;/code&gt;? Why does using &lt;code&gt;&amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; jump to the beginning of the line?&lt;/p&gt;&#xA;" OwnerUserId="1154" LastActivityDate="2018-04-30T16:29:18.800" Title="Trouble using &lt;cword&gt; in mapping" Tags="|vimrc|key-bindings|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16091" PostTypeId="2" ParentId="16090" CreationDate="2018-04-30T15:30:36.020" Score="11" Body="&lt;p&gt;&lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; looks like a key code such as &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt;, but it is not.  As such it is not expanded by &lt;code&gt;nnoremap&lt;/code&gt;, but is expanded by &lt;code&gt;:grep&lt;/code&gt; and a few other commands which take shell-type arguments.  &lt;code&gt;Gtags &amp;lt;cword&amp;gt;&lt;/code&gt; does not work becasue &lt;code&gt;Gtags&lt;/code&gt; does not know how to expand &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;- this feature would have to be added deliberately to that command.  This is as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second problem is you need to expand &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; once between the commands &lt;code&gt;Gtags&lt;/code&gt; and &lt;code&gt;Gtagsa&lt;/code&gt;, since the cursor moves after the first command (think of &lt;code&gt;nnoremap&lt;/code&gt; as typing the sequence as you would type).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative is to use &lt;code&gt;execute&lt;/code&gt; to chain the commands together.  The pipe is escaped because otherwise it would be a command separator for the &lt;code&gt;nnoremap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F4&amp;gt; :execute 'Gtags -di &amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;' \| execute 'Gtagsa -ri &amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, this is typed (and expanded) as you would type but the command action is delayed until the final &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;.  Note, this is simple but will likely fail if the word contains quotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another method is to use an expression map with &lt;code&gt;expand()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;expr&amp;gt; &amp;lt;F4&amp;gt; ':Gtags -di '.expand('&amp;lt;cword&amp;gt;').'&amp;lt;cr&amp;gt;'&#xA;       \ . ':Gtagsa -ri '.expand('&amp;lt;cword&amp;gt;').'&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This expands both &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;s at the time &lt;code&gt;&amp;lt;f4&amp;gt;&lt;/code&gt; is pressed.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-04-30T16:29:18.800" LastActivityDate="2018-04-30T16:29:18.800" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16092" PostTypeId="1" AcceptedAnswerId="16093" CreationDate="2018-04-30T18:35:19.663" Score="0" ViewCount="226" Body="&lt;p&gt;From my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap s &amp;lt;Plug&amp;gt;(easymotion-overwin-f)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets up an &lt;code&gt;nmap&lt;/code&gt; which invokes the EasyMotion plugin when I type &lt;code&gt;,s&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that &lt;code&gt;nmap&lt;/code&gt; works just fine, and is indeed triggered by &lt;code&gt;,s&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I do &lt;code&gt;:nmap ,s&lt;/code&gt; or &lt;code&gt;:nmap &amp;lt;Leader&amp;gt;s&lt;/code&gt; nvim prints &quot;No mapping found.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;EDIT&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Some output from &lt;code&gt;:filter /easy/ nmap&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5EEgD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5EEgD.png&quot; alt=&quot;filter&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5373" LastEditorUserId="5373" LastEditDate="2018-04-30T19:12:13.943" LastActivityDate="2018-04-30T19:47:16.287" Title="Why is this map added using &lt;Plug&gt; not showing up?" Tags="|key-bindings|neovim|gvim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16093" PostTypeId="2" ParentId="16092" CreationDate="2018-04-30T19:41:46.477" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;However, if I do :nmap ,s or :nmap s nvim prints &amp;quot;No mapping found.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Why?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;:map&lt;/code&gt; (and variants) will return the mappings that Vim/NeoVim is currently using. In your setup you have:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nmap ,, &amp;lt;Plug&amp;gt;(easymotion-prefix)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There are a few more that &lt;a href=&quot;https://github.com/easymotion/vim-easymotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;easymotion&lt;/a&gt; looks to map. Specifically ones that look like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Plug&amp;gt;(easymotion-prefix)N &amp;lt;Plug&amp;gt;(easymotion-N)&#xA;&amp;lt;Plug&amp;gt;(easymotion-prefix)n &amp;lt;Plug&amp;gt;(easymotion-n)&#xA;&amp;lt;Plug&amp;gt;(easymotion-prefix)j &amp;lt;Plug&amp;gt;(easymotion-j)&#xA;&amp;quot; So on and so forth&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;None of the mappings you have a &lt;code&gt;*&lt;/code&gt; ahead of the Right-hand-side. See &lt;code&gt;:h map-listing&lt;/code&gt;. This means the mappings will trigger other mappings (aka recursive mappings). This mean you can trigger &lt;code&gt;&amp;lt;Plug&amp;gt;(easymotion-N)&lt;/code&gt; via &lt;code&gt;&amp;lt;Plug&amp;gt;(easymotion-prefix)N&lt;/code&gt; which is also equivalent to &lt;code&gt;,,N&lt;/code&gt;. There is no &lt;code&gt;,,N&lt;/code&gt; mapping, but due to the maps being recursive and chording &lt;code&gt;&amp;lt;Plug&amp;gt;(easymotion-N)&lt;/code&gt; can still be executed.&lt;/p&gt;&#xA;&lt;p&gt;So when you execute, &lt;code&gt;,,s&lt;/code&gt; the &lt;code&gt;,,&lt;/code&gt; maps to &lt;code&gt;&amp;lt;Plug&amp;gt;(easymotion-prefix)&lt;/code&gt; then waits for another possible letter to find another mapping. In this case a &lt;code&gt;s&lt;/code&gt;. When the &lt;code&gt;s&lt;/code&gt; is pressed it expands fully to &lt;code&gt;&amp;lt;Plug&amp;gt;(easymotion-s)&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:h mapping&#xA;:h map-listing&#xA;:h :filter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-04-30T19:47:16.287" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16094" PostTypeId="1" AcceptedAnswerId="16097" CreationDate="2018-04-30T20:39:03.453" Score="6" ViewCount="3624" Body="&lt;p&gt;Not sure if this one is possible, but say I have a file with two blocks of text, in this case English words and their French translations. eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vivre&#xA;aimer&#xA;étudier&#xA;&#xA;to live&#xA;to like&#xA;to study&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to copy the second block and match them by position only, perhaps with a '-', eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vivre - to live&#xA;aimer - to like&#xA;étudier - to study&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17359" LastActivityDate="2018-05-05T03:18:55.717" Title="Add a block of text to end of lines" Tags="|visual-block|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16095" PostTypeId="2" ParentId="16094" CreationDate="2018-04-30T21:03:02.640" Score="6" Body="&lt;p&gt;Sure. A macro can do this without too much trouble. With your cursor on the first character of the first line (Anything in &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; is a special key and not a litteral &lt;code&gt;&amp;lt;key&amp;gt;&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq&quot;ay$:let @a .= ' - '&amp;lt;CR&amp;gt;4j&quot;Ay$jjo&amp;lt;Ctrl+R&amp;gt;a&amp;lt;Esc&amp;gt;^6kq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt;: Starts a macro in register &lt;code&gt;q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;ay$&lt;/code&gt;: Yank to the end of line into the &lt;code&gt;a&lt;/code&gt; register. (Not &lt;code&gt;yy&lt;/code&gt; to avoid the newline)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:let @a .= ' - '&amp;lt;CR&amp;gt;&lt;/code&gt;: Append the text &lt;code&gt;-&lt;/code&gt; to register &lt;code&gt;a&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;4j&quot;Ay$&lt;/code&gt;: Go down to the corresponding english text and &lt;em&gt;append&lt;/em&gt; to regester &lt;code&gt;a&lt;/code&gt; with &lt;code&gt;A&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2jo&amp;lt;Ctrl+R&amp;gt;a&amp;lt;Esc&amp;gt;&lt;/code&gt;: Print the contents of register &lt;code&gt;a&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^6k&lt;/code&gt;: Put the cursor back to the beginning to yank the next term.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: End the macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then execute the macro with &lt;code&gt;#@q&lt;/code&gt; where &lt;code&gt;#&lt;/code&gt; is how many times you want to execute the macro (A.K.A. how many lines you have to copy). Any numbers in the macro may have to be adjusted for how many lines you need to skip over in your real text.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2018-04-30T21:03:02.640" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16096" PostTypeId="2" ParentId="16094" CreationDate="2018-04-30T23:06:08.827" Score="4" Body="&lt;p&gt;Assuming you're on a Linux or Unix system with the &lt;code&gt;paste&lt;/code&gt; command available and your blocks are in two files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim file1&#xA;:%!paste - file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1866" LastActivityDate="2018-04-30T23:06:08.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16097" PostTypeId="2" ParentId="16094" CreationDate="2018-04-30T23:23:01.837" Score="10" Body="&lt;p&gt;While doing yank/put while iterating through the rows works fine this can actually be done with a single yank/put thanks to blockwise Visual mode. That is the mode you enter by hitting &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; from Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since OP is flexible on the format and because some of this is probably new for a lot of folks I'll show a couple methods for joining the text using a Visual block.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Tabular&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Personally I like this format which emulates a table; sections separated by a bit of whitespace and the rightmost section left-aligned on a single column...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vivre     to live&#xA;aimer     to like&#xA;étudier   to study&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The feature that makes this possible is called &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27virtualedit%27&quot; rel=&quot;noreferrer&quot;&gt;&quot;Virtual editing&quot;&lt;/a&gt; which allows some interesting movement with the cursor.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...the cursor can be positioned where there is&#xA;  no actual character.  This can be halfway into a tab or beyond the end&#xA;  of the line.  Useful for &lt;em&gt;selecting a rectangle in Visual mode and&#xA;  editing a table.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(Emphasis is mine...selecting a rectangle and editing a table is kind of what we'll be doing.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case we'll set the option to &quot;block&quot; which allows virtual editing in blockwise Visual mode: &lt;code&gt;:set ve=block&lt;/code&gt;. Then, with the cursor at the start of the first block (i.e. on the &lt;code&gt;v&lt;/code&gt; in &lt;code&gt;vivre&lt;/code&gt;)...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-V&amp;gt;}&amp;lt;BS&amp;gt;ll&quot;adgvVjd&quot;aP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-V&amp;gt;&lt;/code&gt; - &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; to enter blockwise Visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;}&amp;lt;BS&amp;gt;&lt;/code&gt; - move to the bottom right of the text block&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ll&lt;/code&gt; - pick up a couple extra spaces as padding (this is where virtual editing comes into play)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;ad&lt;/code&gt; - delete the selected text into register &lt;em&gt;a&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gvV&lt;/code&gt; - reselect the previously selected visual block and switch to &quot;linewise&quot; mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;jd&lt;/code&gt; - add an extra line to the selection and then delete the selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;aP&lt;/code&gt; - insert the first block of text before the second block&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(At this point you may want to reset virtual edit to its default value: &lt;code&gt;:set ve&amp;amp;&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I golfed this down to two fewer characters by yanking instead of deleting and taking advantage of the fact that the last yank one does can be found in register 0: &lt;code&gt;&amp;lt;C-V&amp;gt;}&amp;lt;BS&amp;gt;llygvVjd&quot;0P&lt;/code&gt;. I also could have kept the delete and &lt;code&gt;P&lt;/code&gt;ut from register 2 since each delete &quot;pushed&quot; onto a stack of sorts: registers 1-9.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Dash-delimited&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you prefer the dash separation we can also use blockwise Visual mode and we don't even need virtual editing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mt&amp;lt;C-V&amp;gt;}mb&amp;lt;BS&amp;gt;$A - &amp;lt;Esc&amp;gt;gvd'bjPkd't&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Briefly, this will&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Mark the beginning of the first block&lt;/li&gt;&#xA;&lt;li&gt;Select the block with blockwise Visual mode, marking the following line in the process.&lt;/li&gt;&#xA;&lt;li&gt;Append &lt;code&gt;-&lt;/code&gt; to all lines&lt;/li&gt;&#xA;&lt;li&gt;Reselect the block and delete the contained text&lt;/li&gt;&#xA;&lt;li&gt;Go to the second block and &lt;code&gt;P&lt;/code&gt;ut/prepend the first block&lt;/li&gt;&#xA;&lt;li&gt;Using the marks set earlier remove the (now empty) first block lines &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vivre - to live&#xA;aimer - to like&#xA;étudier - to study&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Reuse&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you're saying &quot;But I want macros so I can reuse it&quot; you can create a mapping instead. These are easier to keep in your vimrc, for one thing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the second solution, for example, you'd just copy it straight in to the mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;X mt&amp;lt;C-V&amp;gt;}mb&amp;lt;BS&amp;gt;$A - &amp;lt;Esc&amp;gt;gvd'bjPkd't&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Use whatever keystrokes you want in place of &lt;code&gt;&amp;lt;leader&amp;gt;X&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-05-05T03:18:55.717" LastActivityDate="2018-05-05T03:18:55.717" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16098" PostTypeId="2" ParentId="7803" CreationDate="2018-05-01T04:43:42.660" Score="1" Body="&lt;p&gt;TL;DR try the &lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;asyncrun.vim&lt;/a&gt; plugin, it will allow you run shell commands in background and read output from quickfix window in realtime.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can define shell scripts in your dotfiles repository and execute the script with F3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F3&amp;gt; :AsyncRun -cwd=&amp;lt;root&amp;gt; sh /path/to/your/dotfiles/script/build_advanced.sh &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following shell environment variables are defined by AsyncRun:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$VIM_FILEPATH  - File name of current buffer with full path&#xA;$VIM_FILENAME  - File name of current buffer without path&#xA;$VIM_FILEDIR   - Full path of current buffer without the file name&#xA;$VIM_FILEEXT   - File extension of current buffer&#xA;$VIM_FILENOEXT - File name of current buffer without path and extension&#xA;$VIM_CWD       - Current directory&#xA;$VIM_RELDIR    - File path relativize to current directory&#xA;$VIM_RELNAME   - File name relativize to current directory &#xA;$VIM_ROOT      - Project root directory&#xA;$VIM_CWORD     - Current word under cursor&#xA;$VIM_CFILE     - Current filename under cursor&#xA;$VIM_GUI       - Is running under gui ?&#xA;$VIM_VERSION   - Value of v:version&#xA;$VIM_COLUMNS   - How many columns in vim's screen&#xA;$VIM_LINES     - How many lines in vim's screen&#xA;$VIM_SVRNAME   - Value of v:servername for +clientserver usage&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All the above environment variables can be used in your build_advanced.sh. By using these environment variables, the script can call the cmake and then make if cmake finished successfully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.quora.com/How-do-I-compile-a-program-C++-or-Java-in-Vim-like-Sublime-Text-Ctrl+B/answer/Lin-Wei-31&quot; rel=&quot;nofollow noreferrer&quot;&gt;How do I compile a program (C++ or Java) in Vim, like Sublime Text (Ctrl+B)?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9681" LastActivityDate="2018-05-01T04:43:42.660" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16099" PostTypeId="2" ParentId="2670" CreationDate="2018-05-01T04:53:26.347" Score="1" Body="&lt;p&gt;Vim 8 has released for 2 years and shipped with all the mean stream Linux distributions and Mac OS X. But a lot of vim tutorials are still teaching people something ten years ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can compile your C++/Java programs in vim as convenience as Sublime Text or NotePad++ with some dedicated plugins for Vim 8 or NeoVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the &lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;AsyncRun&lt;/a&gt; plugin will allow you run shell commands in background and read output from quickfix window in realtime.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4gImp.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;See the screen capture&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just like compiling programs in IDEs, the compilation errors will be matched by errorformat and be highlighted and become selectable. You can navigate errors in the quickfix window or continue editing while compiling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Quick setup&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Copy &amp;amp; paste the lines below to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'skywind3000/asyncrun.vim'&#xA;&#xA;&quot; open quickfix window automatically when AsyncRun is executed&#xA;&quot; set the quickfix window 6 lines height.&#xA;let g:asyncrun_open = 6&#xA;&#xA;&quot; ring the bell to notify you job finished&#xA;let g:asyncrun_bell = 1&#xA;&#xA;&quot; F10 to toggle quickfix window&#xA;nnoremap &amp;lt;F10&amp;gt; :call asyncrun#quickfix_toggle(6)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you input “:AsyncRun echo hello ” in the command line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vi0Db.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;see the capture here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will see the realtime command output in the open quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Compile and run a single file&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Compiling a single file with AsyncRun is much simpler than Sublime Text’s build system. We can setup F9 for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;F9&amp;gt; :AsyncRun gcc -Wall -O2 &quot;$(VIM_FILEPATH)&quot; -o &quot;$(VIM_FILEDIR)/$(VIM_FILENOEXT)&quot; &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The macros in &lt;code&gt;$(..)&lt;/code&gt; form will be expanded as the real file name or directory, and then we will have F5 to run the executable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;F5&amp;gt; :AsyncRun -raw -cwd=$(VIM_FILEDIR) &quot;$(VIM_FILEDIR)/$(VIM_FILENOEXT)&quot; &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The double quotation mark is used to handle path names containing spaces. The option &lt;code&gt;-cwd=$(VIM_FILEDIR)&lt;/code&gt; means running the file in the file's directory. The absolute path name &lt;code&gt;$(VIM_FILEDIR)/$(VIM_FILENOEXT)&lt;/code&gt; is used because linux needs a &lt;code&gt;./&lt;/code&gt; prefix to running executables in current directory, but windows doesn't . Using the absolute path name of the binary file can handle this crossing platform issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option &lt;code&gt;-raw&lt;/code&gt; means the output will not be matched by vim's errorformat, and will be displayed in quickfix as what it is. Now you can compile your file with F9, check the compilation errors in quickfix window and press F5 to run the binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Build C/C++ Projects&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No matter what build tool you are using, make or cmake, project building means acting to a group of files. It requires locating the project root directory. AsyncRun uses a simple method called root markers to identify the project root. The Project Root is identified as the nearest ancestor directory of the current file which contains one of these directories or files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:asyncrun_rootmarks = ['.svn', '.git', '.root', '_darcs'] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If none of the parent directories contains these root markers, the directory of the current file is used as the project root. This enables us to use either &lt;code&gt;&amp;lt;root&amp;gt;&lt;/code&gt; or &lt;code&gt;$(VIM_ROOT)&lt;/code&gt; to represent the project root. and F7 can be setup to build the current project:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;F7&amp;gt; :AsyncRun -cwd=&amp;lt;root&amp;gt; make &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What if your current project is not in any git or subversion repository ? How to find out where is my project root ? The solution is very simple, just put an empty .root file in your project root, it will be located easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let’s move on, setup F8 to run the current project:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;F8&amp;gt; :AsyncRun -cwd=&amp;lt;root&amp;gt; -raw make run &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The project will run in its root directory. Of course, you need define the run rule in your own makefile. then remap F6 to test:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;F6&amp;gt; :AsyncRun -cwd=&amp;lt;root&amp;gt; -raw make test &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are using cmake, F4 can be map to update your Makefile:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;F4&amp;gt; :AsyncRun -cwd=&amp;lt;root&amp;gt; cmake . &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Due to the implementation of c runtime, if the process is running is a non-tty environment, all the data in stdout will be buffered until process exits. So, there must be a &lt;code&gt;fflush(stdout)&lt;/code&gt; after your &lt;code&gt;printf&lt;/code&gt; statement if you want to see the real-time output. or you can close the stdout buffer at the beginning by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setbuf(stdout, NULL);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the mean time, if you are writing C++ code, a std::endl can be appended to the end of std::cout. It can force flush the stdout buffer. If you are developing on windows, AsyncRun can open a new cmd window for the child process:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;F5&amp;gt; :AsyncRun -cwd=$(VIM_FILEDIR) -mode=4 &quot;$(VIM_FILEDIR)/$(VIM_FILENOEXT)&quot; &amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;F8&amp;gt; :AsyncRun -cwd=&amp;lt;root&amp;gt; -mode=4 make run &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the option &lt;code&gt;-mode=4&lt;/code&gt; on windows will open a new prompt window to run the command, just like running command line programs in Visual Studio. Finally, we have these key mappings below:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;F4: update Makefile with cmake.&lt;/li&gt;&#xA;&lt;li&gt;F5: run the single file&lt;/li&gt;&#xA;&lt;li&gt;F6: run project test&lt;/li&gt;&#xA;&lt;li&gt;F7: build project&lt;/li&gt;&#xA;&lt;li&gt;F8: run project&lt;/li&gt;&#xA;&lt;li&gt;F9: compile the single file&lt;/li&gt;&#xA;&lt;li&gt;F10: toggle quickfix window&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It is more like build system in NotePad++ and GEdit. If you are using cmake heavily, you can write a simple shell script located in &lt;code&gt;~/.vim/script/build.sh&lt;/code&gt; to combine F4 and F7 together: it will update Makefile if CMakeList.txt has been changed, then exectute make.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Advanced usage&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also define shell scripts in your dotfiles repository and execute the script with F3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F3&amp;gt; :AsyncRun -cwd=&amp;lt;root&amp;gt; sh /path/to/your/dotfiles/script/build_advanced.sh &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following shell environment variables are defined by AsyncRun:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$VIM_FILEPATH  - File name of current buffer with full path&#xA;$VIM_FILENAME  - File name of current buffer without path&#xA;$VIM_FILEDIR   - Full path of current buffer without the file name&#xA;$VIM_FILEEXT   - File extension of current buffer&#xA;$VIM_FILENOEXT - File name of current buffer without path and extension&#xA;$VIM_CWD       - Current directory&#xA;$VIM_RELDIR    - File path relativize to current directory&#xA;$VIM_RELNAME   - File name relativize to current directory &#xA;$VIM_ROOT      - Project root directory&#xA;$VIM_CWORD     - Current word under cursor&#xA;$VIM_CFILE     - Current filename under cursor&#xA;$VIM_GUI       - Is running under gui ?&#xA;$VIM_VERSION   - Value of v:version&#xA;$VIM_COLUMNS   - How many columns in vim's screen&#xA;$VIM_LINES     - How many lines in vim's screen&#xA;$VIM_SVRNAME   - Value of v:servername for +clientserver usage&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All the above environment variables can be used in your &lt;code&gt;build_advanced.sh&lt;/code&gt;. Using the external shell script file can do more complex work then a single command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Grep symbols&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes, If you don't have a well setup environment in you remote linux box, grep is the most cheap way to search symbol definition and references among sources. Now we will have F2 to search keyword under cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('win32') || has('win64')&#xA;    noremap &amp;lt;F2&amp;gt; :AsyncRun! -cwd=&amp;lt;root&amp;gt; grep -n -s -R &amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt; --include='*.h' --include='*.c*' '&amp;lt;root&amp;gt;' &amp;lt;cr&amp;gt;&#xA;else&#xA;    noremap &amp;lt;F2&amp;gt; :AsyncRun! -cwd=&amp;lt;root&amp;gt; findstr /n /s /C:&quot;&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;&quot; &quot;\%CD\%\*.h&quot; &quot;\%CD\%\*.c*&quot; &amp;lt;cr&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above script will run grep or findstr in your project root directory, and find symbols in only &lt;code&gt;.c&lt;/code&gt;, &lt;code&gt;.cpp&lt;/code&gt; and &lt;code&gt;.h&lt;/code&gt; files. Now we move around the cursor and press F2, the symbol references in current project will be displayed in the quickfix window immediately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This simple keymap is enough for most time. And you can improve this script to support more file types or other grep tools in your vimrc .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That’s the practical way to build/run C/C++ projects in Vim 8 or NeoVim. Just like Sublime Text’s build system and NotePad++’s NppExec.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No more outdated vim tutorials again, try something new.&lt;/p&gt;&#xA;" OwnerUserId="9681" LastActivityDate="2018-05-01T04:53:26.347" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16100" PostTypeId="1" AcceptedAnswerId="16101" CreationDate="2018-05-01T06:25:01.187" Score="1" ViewCount="69" Body="&lt;p&gt;Say I have a paragraph like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1&#xA;line2&#xA;line3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to select all and then transform like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:start&#xA;line1&#xA;:end&#xA;&#xA;:start&#xA;line2&#xA;:end&#xA;&#xA;:start&#xA;line3&#xA;:end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't ask me why, we have some strange text transformation requirements. I could do it with Python but how can I do this in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I would start by selecting the block via &lt;code&gt;V&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="17359" LastActivityDate="2018-05-01T06:59:41.320" Title="Wrapping lines in a paragraph with header and footer lines" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16101" PostTypeId="2" ParentId="16100" CreationDate="2018-05-01T06:49:55.173" Score="5" Body="&lt;p&gt;The classic &lt;code&gt;:s&lt;/code&gt; command can do stuff like this easily. e.g. type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/.*/:start\r&amp;amp;\r:end\r/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/.*/:start\r&amp;amp;\r:end\r/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;on the command line if you select the area first, because &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; denote the visually selected range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.*&lt;/code&gt; matches the entire line, &lt;code&gt;\r&lt;/code&gt; is inserting newline, the &lt;code&gt;&amp;amp;&lt;/code&gt; in the pattern represents the matched text (&lt;code&gt;:h s/\r&lt;/code&gt;, &lt;code&gt;:h s/\&amp;amp;&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="16910" LastEditorUserId="16910" LastEditDate="2018-05-01T06:59:41.320" LastActivityDate="2018-05-01T06:59:41.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16102" PostTypeId="1" AcceptedAnswerId="16103" CreationDate="2018-05-01T10:28:28.110" Score="4" ViewCount="596" Body="&lt;p&gt;I have been working with a stock vim configuration for a long time. I want to modify just a couple of settings. I don't want to lose the rest of the default configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I create a new &lt;code&gt;.vimrc&lt;/code&gt; I lose all the default settings.&#xA;If I &lt;code&gt;cp /usr/share/vim/vimrc ~/.vimrc&lt;/code&gt; I lose all the default settings.&#xA;If I &lt;code&gt;cp /etc/vim/vimrc ~/.vimrc&lt;/code&gt; I lose all the default settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I retain the default system wide settings, while overriding the few particular settings that I want?&lt;/p&gt;&#xA;" OwnerUserId="17364" LastActivityDate="2018-05-01T12:36:15.220" Title="Vim on Debian, configuration issues" Tags="|vimrc|linux-debian|default-settings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16103" PostTypeId="2" ParentId="16102" CreationDate="2018-05-01T12:36:15.220" Score="5" Body="&lt;p&gt;&lt;code&gt;/usr/share/vim/vimrc&lt;/code&gt; is always sourced regardless of your vimrc (assuming &lt;code&gt;$VIM&lt;/code&gt; doesn't point somewhere else - &lt;code&gt;:h system-vimrc&lt;/code&gt;). The settings you're probably missing are in &lt;code&gt;defaults.vim&lt;/code&gt;, a file that &lt;em&gt;only&lt;/em&gt; gets sourced if you don't have a personal vimrc. To get them back add these two lines to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unlet! skip_defaults_vim&#xA;source $VIMRUNTIME/defaults.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check the rest of the help on the subject on &lt;code&gt;:h defaults.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My information might be wrong however. I'm assuming here you're running vim 8, first included in debian 9. Unfortunately the only current debian system I can check is still running debian 8 stable, where vim doesn't have &lt;code&gt;defaults.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16910" LastActivityDate="2018-05-01T12:36:15.220" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16104" PostTypeId="1" CreationDate="2018-05-01T12:59:48.733" Score="15" ViewCount="1653" Body="&lt;p&gt;&lt;s&gt;When a window is split, given that Vi/Vim splits are not stored in a tree structure, the &amp;quot;direction of the split&amp;quot; is basically &amp;quot;the window in which the cursor is placed after the command&amp;quot;.&lt;/s&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Update 2018-05-01&lt;/em&gt;: @mass clarified that splits are stored in a tree structure and that the direction actually refers to the direction of the &amp;quot;split bar&amp;quot;. Thanks!&lt;/p&gt;&#xA;&lt;p&gt;I however, think of my splits as a, in some way, spatial history of my editing session where time flows from left to right (as in a web browser) and from up to down (like when scrolling a text document)*.&lt;/p&gt;&#xA;&lt;p&gt;When I split a window, it is usually because I want to reference something based on my current file, and would need to navigate this file before continuing with my work. I think of opening a buffer in a new window is a event that adds to the session history.&lt;/p&gt;&#xA;&lt;p&gt;Why are Vi's and Vim's defaults left (&lt;code&gt;:vsplit&lt;/code&gt;) and above (&lt;code&gt;:split&lt;/code&gt;)? Was the decision motivated by technical, UI/workflow, or legacy reasons? Or something completely different? I noticed that the default in Emacs is to split down (&lt;code&gt;C-x 2&lt;/code&gt; is &lt;code&gt;split-window-below&lt;/code&gt;) and right (&lt;code&gt;C-x 3&lt;/code&gt; is &lt;code&gt;split-window-right&lt;/code&gt;)...&lt;/p&gt;&#xA;&lt;p&gt;If you know the history behind the defaults, I would be happy if you could share the answer! If you prefer the defaults, please comment on why!&lt;/p&gt;&#xA;&lt;p&gt;* &lt;em&gt;also reading most current European written languages&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="10133" LastEditorUserId="23502" LastEditDate="2022-07-14T00:25:32.577" LastActivityDate="2022-08-13T01:01:50.183" Title="Vi and Vim default to split left and split above. What is the history and motivation behind this?" Tags="|split|history-of|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16105" PostTypeId="2" ParentId="9753" CreationDate="2018-05-01T13:16:17.873" Score="5" Body="&lt;p&gt;As far as I can tell (and from @Antony's comments), &lt;code&gt;autoindent&lt;/code&gt; must be turned on for this to work. From the help pages:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When autoindent is on, formatting (with the &quot;gq&quot; command or when you reach 'textwidth' in Insert mode) uses the indentation of the first line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;…and, in practice, it works for me to reformat long list items.&lt;/p&gt;&#xA;" OwnerUserId="10083" LastActivityDate="2018-05-01T13:16:17.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16106" PostTypeId="1" AcceptedAnswerId="16107" CreationDate="2018-05-01T14:47:13.547" Score="1" ViewCount="1085" Body="&lt;p&gt;I was wondering if it is possible to combine the &lt;code&gt;gq&lt;/code&gt; operation with other commands, as one might do with the &lt;code&gt;|&lt;/code&gt; operator. For example, it would be nice to be able to write a command like &lt;code&gt;:'&amp;lt;,'&amp;gt;left4 |gq&lt;/code&gt;. However, vim says that &lt;code&gt;gq&lt;/code&gt; in this context is not an editor command, because it is interpreting it as &lt;code&gt;:gq&lt;/code&gt;. Is there any workaround? &lt;/p&gt;&#xA;" OwnerUserId="17367" LastActivityDate="2018-05-01T14:53:54.420" Title="combining the gq command" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16107" PostTypeId="2" ParentId="16106" CreationDate="2018-05-01T14:53:54.420" Score="6" Body="&lt;p&gt;You can run normal mode commands from the command-line with the &lt;code&gt;:normal&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this instance, we want to first reselect the visual selection, and then run the &lt;code&gt;gq&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;left4 | norm! gvgq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :normal&lt;/code&gt; and &lt;code&gt;:help gv&lt;/code&gt; for more details. &lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-05-01T14:53:54.420" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16108" PostTypeId="1" AcceptedAnswerId="16136" CreationDate="2018-05-01T16:03:50.837" Score="5" ViewCount="11038" Body="&lt;h3&gt;Problem&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Anytime I switch to a colorscheme the background turns this ugly gray that gives everything a washed out look. Why does this happen, and how can I prevent it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example screenshot—&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/I2sUz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/I2sUz.png&quot; alt=&quot;Dracula scheme&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;More details&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This does not appear to happen when using &lt;a href=&quot;https://github.com/agude/vim-eldar&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;agude/vim-eldar&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:hi&lt;/code&gt; reports are below for vim-eldar—&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose hi Normal Normal xxx         guifg=White guibg=Black&#xA;    Last set from ~/.local/share/nvim/plugged/vim-eldar/colors/eldar.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and Dracula—&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose hi Normal Normal xxx         ctermfg=255 ctermbg=236 guifg=#F8F8F2 guibg=#282A36&#xA;    Last set from ~/.local/share/nvim/plugged/vim/colors/Dracula.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Attempts&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I've tried the following two things but no luck:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;make sure terminal color is set to xterm-256 color&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set background=dark&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My iTerm2 color preset is &lt;code&gt;dark background&lt;/code&gt;—&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aojP4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aojP4.png&quot; alt=&quot;iTerm2 prefs&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14882" LastEditorUserId="10604" LastEditDate="2018-05-03T07:04:20.517" LastActivityDate="2020-08-12T12:29:54.167" Title="Neovim Gray Background" Tags="|terminal|colorscheme|iterm2|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="16109" PostTypeId="2" ParentId="388" CreationDate="2018-05-01T18:37:36.123" Score="67" Body="&lt;p&gt;Both Vim 8.0 and Neovim have their own built-in package manager. In Vim 8.0 create the following directories:&#xA;&lt;code&gt;.vim/pack/*/start&lt;/code&gt;, where &lt;code&gt;*&lt;/code&gt; is any name you want to use; e.g. &lt;code&gt;.vim/pack/jimmy/start&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clone your plugin into the start directory just as you would if you were using pathogen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With Neovim, the directories are a little more longwinded:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.local/share/nvim/site/pack/*/start&lt;/code&gt;. From there do the same as for Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no need at all for another plugin manager.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim or Neovim, run &lt;code&gt;:h packages&lt;/code&gt; for a little more detail. Read the part about colours because they are different, though not much. You need no extra instructions in your &lt;code&gt;.vimrc&lt;/code&gt; or your &lt;code&gt;nvim/init.vim&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="17370" LastEditorUserId="343" LastEditDate="2018-05-02T10:59:43.107" LastActivityDate="2018-05-02T10:59:43.107" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16110" PostTypeId="1" AcceptedAnswerId="16113" CreationDate="2018-05-01T19:09:14.920" Score="5" ViewCount="4215" Body="&lt;p&gt;We can get highlight group information by the following command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi[ghlight] {group-name}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But is it possible to get this information by given keyword? Something like this : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match Integer '\d\+'&#xA;hi def link Integer Constant&#xA;&#xA;:hi '3'&#xA;Integer xxx links to Constant&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11430" LastActivityDate="2020-12-28T08:34:48.637" Title="Interactively check given string highlight group" Tags="|syntax-highlighting|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16111" PostTypeId="2" ParentId="5173" CreationDate="2018-05-01T22:41:33.040" Score="4" Body="&lt;p&gt;This may be helpful for future readers:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This function returns an executable command which can restore the actual highlight attributes for one highlight group (not fully tested, but it handles linked groups):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetHiCommand(group)&#xA;    redir =&amp;gt; l:output&#xA;        silent! exec 'hi' a:group&#xA;    redir end&#xA;&#xA;    let l:link = matchstr(l:output, 'links to \zs\w\+')&#xA;&#xA;    if empty(l:link)&#xA;        let l:attrs = matchstr(l:output, '\&amp;lt;xxx \zs[^\n]*')&#xA;        return printf('hi %s %s', a:group, l:attrs)&#xA;    else&#xA;        return printf('hi! link %s %s', a:group, l:link)&#xA;    endif&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo GetHiCommand('LineNr')&#xA;hi LineNr term=underline ctermfg=243 guifg=#7c6f64&#xA;&#xA;:echo GetHiCommand('MoreMsg')&#xA;hi! link MoreMsg GruvboxYellowBold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5516" LastActivityDate="2018-05-01T22:41:33.040" CommentCount="0" CommunityOwnedDate="2018-05-01T22:41:33.040" ContentLicense="CC BY-SA 3.0" />
  <row Id="16112" PostTypeId="2" ParentId="14113" CreationDate="2018-05-01T23:38:07.103" Score="2" Body="&lt;p&gt;Create a testing file with the following contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# foobar&#xA;&#xA;{&#xA;    # foo&#xA;}&#xA;&#xA;[&#xA;    # bar&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;First solution&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn Comment /#.*$/&#xA;:syn myRegionWithoutComment start='{' end='}'&#xA;:syn myRegionWithComment start='[' end=']' contains=ALL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Second solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Try &lt;code&gt;:h syn-skip&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;skip={skip_pattern} The search pattern that defines text inside&#xA;                  the region where not to look for the end.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/47.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way, Even More Advanced Syntax Highlighting&lt;/a&gt; for an example.&lt;/p&gt;&#xA;" OwnerUserId="11430" LastActivityDate="2018-05-01T23:38:07.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16113" PostTypeId="2" ParentId="16110" CreationDate="2018-05-02T09:36:11.447" Score="13" Body="&lt;p&gt;If I understand your question correctly, it's not possible to do exactly what you're asking. Vim needs the items to be in their correct context in order to determine what highlighting applies to them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you &lt;em&gt;can&lt;/em&gt; ask Vim what syntax items are currently being applied. See the example at the end of &lt;code&gt;:help synID()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 1), &quot;name&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will output the name of the syntax item under the cursor. So instead of typing &lt;code&gt;:hi '3'&lt;/code&gt;, you'd find a &lt;code&gt;3&lt;/code&gt; in your current, syntax-highlighted buffer (or add one), place the cursor on it, and run the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To obtain the highlighting information, you can slot the above into a &lt;code&gt;:highlight&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'hi' synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 1), &quot;name&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your purpose is debugging syntax highlighting, then you will also find the example in &lt;code&gt;:help synstack()&lt;/code&gt; useful. I have a little wrapper command in my &lt;code&gt;.vimrc&lt;/code&gt; containing that code so I can check syntax items quickly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:syntax_query() abort&#xA;  for id in synstack(line(&quot;.&quot;), col(&quot;.&quot;))&#xA;    echo synIDattr(id, &quot;name&quot;)&#xA;  endfor&#xA;endfunction&#xA;command! SyntaxQuery call s:syntax_query()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can modify the &lt;code&gt;echo&lt;/code&gt; line similarly, if you want this also to display highlighting info:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'hi' synIDattr(id, &quot;name&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-05-02T13:16:27.857" LastActivityDate="2018-05-02T13:16:27.857" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16114" PostTypeId="2" ParentId="12376" CreationDate="2018-05-02T14:26:03.400" Score="13" Body="&lt;p&gt;I'm aware this is a very old question but I recently found a good solution. After much frustration, I came across these ways to access the windows system clipboard by copying and pasting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By copying, with vim version &gt;= 8.0.1394, as noted in another answer &lt;a href=&quot;https://vi.stackexchange.com/a/15190&quot;&gt;https://vi.stackexchange.com/a/15190&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:clip = '/mnt/c/Windows/System32/clip.exe' &#xA;if executable(s:clip)&#xA;    augroup WSLYank&#xA;        autocmd!&#xA;        autocmd TextYankPost * call system('echo '.shellescape(join(v:event.regcontents, &quot;\&amp;lt;CR&amp;gt;&quot;)).' | '.s:clip)&#xA;    augroup END&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pasting, mapping to fake registry commands, i.e. &quot;=p or &quot;+p or whatever. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; &quot;=p :r !powershell.exe -Command Get-Clipboard&amp;lt;CR&amp;gt;&#xA;map! &amp;lt;silent&amp;gt; &amp;lt;C-r&amp;gt;= :r !powershell.exe -Command Get-Clipboard&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; I thought this will be better :)&#xA;noremap &quot;+p :exe 'norm a'.system('/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command Get-Clipboard')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Right-click pasting works, but is unsatisfying if you don't want to use the mouse&lt;/p&gt;&#xA;" OwnerUserId="17381" LastEditorUserId="20180" LastEditDate="2019-01-08T13:28:16.313" LastActivityDate="2019-01-08T13:28:16.313" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16115" PostTypeId="1" CreationDate="2018-05-02T15:45:40.500" Score="2" ViewCount="546" Body="&lt;p&gt;I have the &lt;code&gt;foldmethod=indent&lt;/code&gt; setting, the problem with it is that when I'm pasting a line or lines before the first line of a fold and all of these lines have the same or a greater level of indentation as the fold in question, the fold collapses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a screen shot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0BNwb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0BNwb.png&quot; alt=&quot;a fold collapses on paste&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is a gif animation of my actions in Vim with default settings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/M5dgZ.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/M5dgZ.gif&quot; alt=&quot;a fold collapses on paste example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I prevent this behavior? I would like the fold to remain open regardless of where I paste and what I paste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I paste not on the first line of a fold, or the text pasted has at least one line which has a lesser indentation level, an empty line for instance, the fold doesn't collapse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to set &lt;code&gt;foldmethod=manual&lt;/code&gt; before a paste, similar to a solution &lt;a href=&quot;https://stackoverflow.com/questions/3922267/vim-opens-my-folds-on-paste-how-to-prevent-that#4701478&quot;&gt;here&lt;/a&gt;, but it seems there is no such event for the autocommand, for instance something like &lt;code&gt;TextChangedPrev&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Currently, I suppose, that this is a bug, which has to do something with a way how Vim handles indentation folds. The folds are defined only by the number of white spaces from the &quot;0 column&quot;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If I paste a line with the indentation smaller, than the fold's one, the pasted line is considered to belong to a previous fold.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I paste a line with indentation level bigger than the fold's one, then it creates a new fold, technically and should be indented (or shouldn't, since blocks smaller than two lines are not indented, as far as I know.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;But if I paste a line with the same indentation as the fold's one at the fold's first line, I would suppose that line to be treated like a line in the currently, already existing fold.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;And this is a bug supposedly, since it looks like Vim for some reason miscounts the indentation and thinks that a new fold has just been created&lt;/strong&gt;, so it takes all lines above and below, which have the same indent level and collapses them.&lt;/p&gt;&#xA;" OwnerUserId="2798" LastEditorUserId="2798" LastEditDate="2018-05-04T09:20:59.480" LastActivityDate="2018-05-04T09:20:59.480" Title="How to prevent Vim to collapse a fold with foldmethod=indent on a text paste?" Tags="|indentation|folding|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16116" PostTypeId="1" AcceptedAnswerId="16118" CreationDate="2018-05-02T16:11:28.527" Score="0" ViewCount="113" Body="&lt;p&gt;Recently I have been documenting a lot of code which are usually in markdown files (.md). And I frequently come across texts where I have to retype previously written word. Like,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cp file_1 file_2&#xA;mv -v file1 file2&#xA;git clone --bare repo_name repo_name.git&#xA;etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently, I have been using the following sequence to achieve copying and pasting the previous word without using mouse:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;some_word &lt;kbd&gt;Esc&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;+&lt;kbd&gt;b&lt;/kbd&gt;+&lt;kbd&gt;y&lt;/kbd&gt;+&lt;kbd&gt;A&lt;/kbd&gt;+&lt;kbd&gt;Esc&lt;/kbd&gt;+&lt;kbd&gt;p&lt;/kbd&gt;+&lt;kbd&gt;A&lt;/kbd&gt; rest of the sentence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;BUT&lt;/strong&gt; this seems rather having to press more keys strokes than the word itself (&amp;lt; 8 strokes), and doesn't seems like a wise thing to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So the question,&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there a better way to achieving this using default VIM sequences. Kindly do not suggest &lt;code&gt;key mapping&lt;/code&gt; unless there is no other alternative.&lt;/li&gt;&#xA;&lt;li&gt;Can I copy-paste text without leaving the &lt;code&gt;vim insert mode&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="17317" LastEditorUserId="17317" LastEditDate="2018-05-02T17:10:51.507" LastActivityDate="2018-05-02T17:36:55.863" Title="Better way to copy paste previous word using vim's default keyboard sequences?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16117" PostTypeId="1" AcceptedAnswerId="16122" CreationDate="2018-05-02T16:13:00.943" Score="1" ViewCount="239" Body="&lt;p&gt;I am trying to get &lt;code&gt;vim&lt;/code&gt; to do block commenting and uncommenting of highlighted lines while keeping the correct indentation level. I am so frustratingly close. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:commentChar='//'&#xA;autocmd BufReadPost *.[ch]    let b:commentChar='//'&#xA;autocmd BufReadPost *.cpp    let b:commentChar='//'&#xA;autocmd BufReadPost *.py    let b:commentChar='#'&#xA;autocmd BufReadPost *.*sh    let b:commentChar='#'&#xA;function! Docomment ()&#xA;  &quot;make comments on all the lines we've grabbed&#xA;  execute 's/^\s*/&amp;amp;'.escape(b:commentChar, '\/').' /e'&#xA;  nohl&#xA;endfunction&#xA;function! Uncomment ()&#xA;  &quot;uncomment on all our lines&#xA;  execute 's/\v(^\s*)\V'.escape(b:commentChar, '\/').'\v\s*/\1/e'&#xA;  nohl&#xA;endfunction&#xA;function! Comment ()&#xA;  &quot;does the first line begin with a comment?&#xA;  let l:line=getpos(&quot;'&amp;lt;&quot;)[1]&#xA;  &quot;if there's a match&#xA;  if match(getline(l:line), '^\s*'.b:commentChar)&amp;gt;-1&#xA;    echom &quot;calling uncomment&quot;&#xA;    call Uncomment()&#xA;  else&#xA;    echom &quot;calling docomment&quot;&#xA;    call Docomment()&#xA;  endif&#xA;endfunction&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;C-r&amp;gt; :call Comment()&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Current behavior on highlighting the following sample lines and calling &lt;code&gt;C-r&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;These are sample lines&#xA;What will vim do here?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// These are sample lines&#xA;What will vim do here?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;:messages&lt;/code&gt; is &lt;code&gt;calling comment, calling uncomment&lt;/code&gt; which tells me that vim is first commenting the first line, then going back to look at the first line, seeing that it starts with a comment, and then uncommenting the second line. However, when calling the &lt;code&gt;Uncomment()&lt;/code&gt; function, it works correctly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// If I started with highlighting&#xA;// multiple commented lines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will be correctly changed to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If I started with highlighting&#xA;multiple commented lines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I get vim to only look at the first line once, and then stop re-checking it after it's changed the line?&lt;/p&gt;&#xA;" OwnerUserId="17205" LastEditorUserId="17205" LastEditDate="2018-05-02T23:32:20.530" LastActivityDate="2018-05-02T23:39:44.143" Title="Visual mode toggle block commenting with vimrc command" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16118" PostTypeId="2" ParentId="16116" CreationDate="2018-05-02T17:17:32.523" Score="4" Body="&lt;p&gt;One of the easiest ways to insert words from the buffer is using &lt;code&gt;keyword completion&lt;/code&gt;.  This is done using the keys &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;n&lt;/kbd&gt; and &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;p&lt;/kbd&gt;, or &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt; &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;n&lt;/kbd&gt; and &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt; &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;p&lt;/kbd&gt; in insert mode.  The exact behavior depends on the options &lt;code&gt;completeopt&lt;/code&gt; and &lt;code&gt;complete&lt;/code&gt;, so I will assume you have set the defaults.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference between these is&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;p&lt;/kbd&gt; targets words before the cursor (&quot;previous&quot;) and &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;n&lt;/kbd&gt; targets words after the cursor (&quot;next&quot;) and&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;using &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt; first targets the current buffer only but without &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt; it targets all buffers.  This behavior can be changed using &lt;code&gt;complete&lt;/code&gt; (see &lt;code&gt;:help 'complete'&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thus, by default, to insert the word before the cursor you merely need to type &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;p&lt;/kbd&gt; or &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt; &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;p&lt;/kbd&gt; once.  The latter may be slightly faster if you have many buffers open.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="17317" LastEditDate="2018-05-02T17:36:55.863" LastActivityDate="2018-05-02T17:36:55.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16119" PostTypeId="1" CreationDate="2018-05-02T18:30:13.083" Score="6" ViewCount="1531" Body="&lt;p&gt;Sometimes I want to open vim in preparation of opening a file in the directory tree. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So i start it without a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I use a map to open NERDTree:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:NERDTreeFind&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This fails with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NERDTree: no file for the current buffer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OK so this is perhaps a deficiency in the plugin, and I want to add a check (either to use inside my bind, or to PR upstream to handle this edge case for the plugin). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I check that I am in a &lt;code&gt;[No Name]&lt;/code&gt; buffer? &lt;code&gt;@%&lt;/code&gt;? &lt;code&gt;:f&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-05-02T18:30:13.083" Title="How to see if Vim has a file opened or not, or has a buffer open" Tags="|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16120" PostTypeId="2" ParentId="16119" CreationDate="2018-05-02T18:30:13.083" Score="5" Body="&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;f :call SmartNERDTree()&amp;lt;CR&amp;gt;&#xA;&#xA;function! SmartNERDTree()                   &#xA;    if @% == &quot;&quot;&#xA;        NERDTreeToggle                      &#xA;    else                                    &#xA;        NERDTreeFind                        &#xA;    endif                                   &#xA;endfun                                      &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm sure it would be possible to make it a oneliner in the map. The question is about whether it would be more readable.&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-05-02T18:30:13.083" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16121" PostTypeId="2" ParentId="16015" CreationDate="2018-05-02T20:17:12.417" Score="4" Body="&lt;p&gt;The answer, for the moment, seems to be:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There isn't one (at least, not past vim 6).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As mentioned on &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/RLrs0XJxfa4/vzdT27GBCgAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-dev&lt;/a&gt; by the former maintainer, a very old archive has been put up at &lt;a href=&quot;http://www.google.com/url?q=http%3A%2F%2Fdindinx.net%2Ffiles%2Fstuff%2Fvim.tar.gz&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNEQWoi79Xyjpvv6qHxwHNh08NiHiQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;dindinx.net&lt;/a&gt;. The current French maintenance is only &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/RLrs0XJxfa4/z4J_nSCFCgAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;messages, tutorial, man pages, and gvim menus&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;Efforts are underway to find a more up-to-date version, and to possibly host somewhere.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-05-02T20:17:12.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16122" PostTypeId="2" ParentId="16117" CreationDate="2018-05-02T23:30:31.497" Score="0" Body="&lt;p&gt;This answer is here to 1) show the correct code to paste into a &lt;code&gt;.vimrc&lt;/code&gt; to get &lt;code&gt;vim 7.4+&lt;/code&gt; to do block commenting/uncommenting while keeping indentation level with 1 shortcut in visual mode and 2) to explain it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:commentChar='//'&#xA;autocmd BufNewFile,BufReadPost *.[ch]    let b:commentChar='//'&#xA;autocmd BufNewFile,BufReadPost *.cpp    let b:commentChar='//'&#xA;autocmd BufNewFile,BufReadPost *.py    let b:commentChar='#'&#xA;autocmd BufNewFile,BufReadPost *.*sh    let b:commentChar='#'&#xA;function! Docomment ()&#xA;  &quot;make comments on all the lines we've grabbed&#xA;  execute '''&amp;lt;,''&amp;gt;s/^\s*/&amp;amp;'.escape(b:commentChar, '\/').' /e'&#xA;endfunction&#xA;function! Uncomment ()&#xA;  &quot;uncomment on all our lines&#xA;  execute '''&amp;lt;,''&amp;gt;s/\v(^\s*)'.escape(b:commentChar, '\/').'\v\s*/\1/e'&#xA;endfunction&#xA;function! Comment ()&#xA;  &quot;does the first line begin with a comment?&#xA;  let l:line=getpos(&quot;'&amp;lt;&quot;)[1]&#xA;  &quot;if there's a match&#xA;  if match(getline(l:line), '^\s*'.b:commentChar)&amp;gt;-1&#xA;    call Uncomment()&#xA;  else&#xA;    call Docomment()&#xA;  endif&#xA;endfunction&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;C-r&amp;gt; :&amp;lt;C-u&amp;gt;call Comment()&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How it works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;let b:commentChar='//'&lt;/code&gt; : This creates a variable in vim. the &lt;code&gt;b&lt;/code&gt; here refers to the scope, which in this case is contained to the buffer, meaning the currently opened file. Your comment characters are strings and need to be wrapped in quotes, the quotes are not part of what will be substituted in when toggling comments.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;autocmd BufNewFile,BufReadPost *...&lt;/code&gt; : Autocommands trigger on different things, in this case, these are triggering when a new file or the read file ends with a certain extension. Once triggered, the execute the following command, which allows us to change the &lt;code&gt;commentChar&lt;/code&gt; depending on filetype. There are other ways to do this, but they are more confusing to novices (like me).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;function! Docomment()&lt;/code&gt; : Functions are declared by starting with &lt;code&gt;function&lt;/code&gt; and ending with &lt;code&gt;endfunction&lt;/code&gt;. Functions must start with a capital. the &lt;code&gt;!&lt;/code&gt; ensures that this function overwrites any previous functions defined as &lt;code&gt;Docomment()&lt;/code&gt; with this version of &lt;code&gt;Docomment()&lt;/code&gt;. Without the &lt;code&gt;!&lt;/code&gt;, I had errors, but that might be because I was defining new functions through the vim command line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;execute '''&amp;lt;,''&amp;gt;s/^\s*/&amp;amp;'.escape(b:commentChar, '\/').' /e'&lt;/code&gt; : Execute calls a command. In this case, we are executing &lt;code&gt;substitute&lt;/code&gt;, which can take a range (by default this is the current line) such as &lt;code&gt;%&lt;/code&gt; for the whole buffer or &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; for the highlighted section. &lt;code&gt;^\s*&lt;/code&gt; is regex to match the start of a line followed by any amount of whitespace, which is then appended to (due to &lt;code&gt;&amp;amp;&lt;/code&gt;). The &lt;code&gt;.&lt;/code&gt; here is used for string concatenation, since &lt;code&gt;escape()&lt;/code&gt; can't be wrapped in quotes. &lt;code&gt;escape()&lt;/code&gt; allows you to escape character in &lt;code&gt;commentChar&lt;/code&gt; that matches the arguments (in this case, &lt;code&gt;\&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt;) by prepending them with a &lt;code&gt;\&lt;/code&gt;. After this, we concatenate again with the end of our &lt;code&gt;substitute&lt;/code&gt; string, which has the &lt;code&gt;e&lt;/code&gt; flag. This flag lets us fail silently, meaning that if we do not find a match on a given line, we won't yell about it. As a whole, this line lets us put a comment character followed by a space just before the first text, meaning we keep our indentation level.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;execute '''&amp;lt;,''&amp;gt;s/\v(^\s*)'.escape(b:commentChar, '\/').'\v\s*/\1/e'&lt;/code&gt; : This is similar to our last huge long command. Unique to this one, we have &lt;code&gt;\v&lt;/code&gt;, which makes sure that we don't have to escape our &lt;code&gt;()&lt;/code&gt;, and &lt;code&gt;1&lt;/code&gt;, which refers to the group we made with our &lt;code&gt;()&lt;/code&gt;. Basically, we're matching a line that starts with any amount of whitespace and then our comment character followed by any amount of whitespace, and we are only keeping the first set of whitespace. Again, &lt;code&gt;e&lt;/code&gt; lets us fail silently if we don't have a comment character on that line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;let l:line=getpos(&quot;'&amp;lt;&quot;)[1]&lt;/code&gt; : this sets a variable much like we did with our comment character, but &lt;code&gt;l&lt;/code&gt; refers to the local scope (local to this function). &lt;code&gt;getpos()&lt;/code&gt; gets the position of, in this case, the start of our highlighting, and the &lt;code&gt;[1]&lt;/code&gt; means we only care about the line number, not other things like the column number.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;if match(getline(l:line), '^\s*'.b:commentChar)&amp;gt;-1&lt;/code&gt; : you know how &lt;code&gt;if&lt;/code&gt; works. &lt;code&gt;match()&lt;/code&gt; checks if the first thing contains the second thing, so we grab the line that we started our highlighting on, and check if it starts with whitespace followed by our comment character. &lt;code&gt;match()&lt;/code&gt; returns the index where this is true, and &lt;code&gt;-1&lt;/code&gt; if no matches were found. Since &lt;code&gt;if&lt;/code&gt; evaluates all nonzero numbers to be true, we have to compare our output to see if it's greater than -1. Comparison in &lt;code&gt;vim&lt;/code&gt; returns 0 if false and 1 if true, which is what &lt;code&gt;if&lt;/code&gt; wants to see to evaluate correctly.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;vnoremap &amp;lt;silent&amp;gt; &amp;lt;C-r&amp;gt; :&amp;lt;C-u&amp;gt;call Comment()&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt; : &lt;code&gt;vnoremap&lt;/code&gt; means map the following command in visual mode, but don't map it recursively (meaning don't change any other commands that might use  in other ways). Basically, if you're a vim novice, always use &lt;code&gt;noremap&lt;/code&gt; to make sure you don't break things. &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; means &quot;I don't want your words, just your actions&quot; and tells it not to print anything to the command line. &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; is the thing we're mapping, which is ctrl+r in this case (note that you can still use C-r normally for &quot;redo&quot; in normal mode with this mapping). &lt;code&gt;C-u&lt;/code&gt; is kinda confusing, but basically it makes sure you don't lose track of your visual highlighting (according to &lt;a href=&quot;https://vi.stackexchange.com/questions/9751/understanding-ctrl-u-combination&quot;&gt;this answer&lt;/a&gt; it makes your command start with &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; which is what we want). &lt;code&gt;call&lt;/code&gt; here just tells vim to execute the function we named, and &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; refers to hitting the &lt;code&gt;enter&lt;/code&gt; button. We have to hit it once to actually call the function (otherwise we've just typed &lt;code&gt;call function()&lt;/code&gt; on the command line, and we have to hit it again to get our substitutes to go through all the way (not really sure why, but whatever). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Anyway, hopefully this helps. This will take anything highlighted with &lt;code&gt;v&lt;/code&gt;, &lt;code&gt;V&lt;/code&gt;, or &lt;code&gt;C-v&lt;/code&gt;, check if the first line is commented, if yes, try to uncomment all highlighted lines, and if not, add an extra layer of comment characters to each line. This is my desired behavior; I did not just want it to toggle whether each line in the block was commented or not, so it works perfectly for me after &lt;a href=&quot;https://vi.stackexchange.com/questions/15955/how-to-match-pattern-with-buffer-scoped-variable&quot;&gt;asking&lt;/a&gt; &lt;a href=&quot;https://vi.stackexchange.com/questions/15971/invalid-match-arguments&quot;&gt;multiple&lt;/a&gt; questions on the subject. &lt;/p&gt;&#xA;" OwnerUserId="17205" LastEditorUserId="17205" LastEditDate="2018-05-02T23:39:44.143" LastActivityDate="2018-05-02T23:39:44.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16123" PostTypeId="2" ParentId="130" CreationDate="2018-05-02T23:50:25.597" Score="2" Body="&lt;p&gt;This answer is here to 1) show the correct code to paste into a &lt;code&gt;.vimrc&lt;/code&gt; to get &lt;code&gt;vim 7.4+&lt;/code&gt; to do block commenting/uncommenting while keeping indentation level with 1 shortcut in visual mode and 2) to explain it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:commentChar='//'&#xA;autocmd BufNewFile,BufReadPost *.[ch]    let b:commentChar='//'&#xA;autocmd BufNewFile,BufReadPost *.cpp    let b:commentChar='//'&#xA;autocmd BufNewFile,BufReadPost *.py    let b:commentChar='#'&#xA;autocmd BufNewFile,BufReadPost *.*sh    let b:commentChar='#'&#xA;function! Docomment ()&#xA;  &quot;make comments on all the lines we've grabbed&#xA;  execute '''&amp;lt;,''&amp;gt;s/^\s*/&amp;amp;'.escape(b:commentChar, '\/').' /e'&#xA;endfunction&#xA;function! Uncomment ()&#xA;  &quot;uncomment on all our lines&#xA;  execute '''&amp;lt;,''&amp;gt;s/\v(^\s*)'.escape(b:commentChar, '\/').'\v\s*/\1/e'&#xA;endfunction&#xA;function! Comment ()&#xA;  &quot;does the first line begin with a comment?&#xA;  let l:line=getpos(&quot;'&amp;lt;&quot;)[1]&#xA;  &quot;if there's a match&#xA;  if match(getline(l:line), '^\s*'.b:commentChar)&amp;gt;-1&#xA;    call Uncomment()&#xA;  else&#xA;    call Docomment()&#xA;  endif&#xA;endfunction&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;C-r&amp;gt; :&amp;lt;C-u&amp;gt;call Comment()&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How it works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;let b:commentChar='//'&lt;/code&gt; : This creates a variable in vim. the &lt;code&gt;b&lt;/code&gt; here refers to the scope, which in this case is contained to the buffer, meaning the currently opened file. Your comment characters are strings and need to be wrapped in quotes, the quotes are not part of what will be substituted in when toggling comments.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;autocmd BufNewFile,BufReadPost *...&lt;/code&gt; : Autocommands trigger on different things, in this case, these are triggering when a new file or the read file ends with a certain extension. Once triggered, the execute the following command, which allows us to change the &lt;code&gt;commentChar&lt;/code&gt; depending on filetype. There are other ways to do this, but they are more confusing to novices (like me).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;function! Docomment()&lt;/code&gt; : Functions are declared by starting with &lt;code&gt;function&lt;/code&gt; and ending with &lt;code&gt;endfunction&lt;/code&gt;. Functions must start with a capital. the &lt;code&gt;!&lt;/code&gt; ensures that this function overwrites any previous functions defined as &lt;code&gt;Docomment()&lt;/code&gt; with this version of &lt;code&gt;Docomment()&lt;/code&gt;. Without the &lt;code&gt;!&lt;/code&gt;, I had errors, but that might be because I was defining new functions through the vim command line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;execute '''&amp;lt;,''&amp;gt;s/^\s*/&amp;amp;'.escape(b:commentChar, '\/').' /e'&lt;/code&gt; : Execute calls a command. In this case, we are executing &lt;code&gt;substitute&lt;/code&gt;, which can take a range (by default this is the current line) such as &lt;code&gt;%&lt;/code&gt; for the whole buffer or &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; for the highlighted section. &lt;code&gt;^\s*&lt;/code&gt; is regex to match the start of a line followed by any amount of whitespace, which is then appended to (due to &lt;code&gt;&amp;amp;&lt;/code&gt;). The &lt;code&gt;.&lt;/code&gt; here is used for string concatenation, since &lt;code&gt;escape()&lt;/code&gt; can't be wrapped in quotes. &lt;code&gt;escape()&lt;/code&gt; allows you to escape character in &lt;code&gt;commentChar&lt;/code&gt; that matches the arguments (in this case, &lt;code&gt;\&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt;) by prepending them with a &lt;code&gt;\&lt;/code&gt;. After this, we concatenate again with the end of our &lt;code&gt;substitute&lt;/code&gt; string, which has the &lt;code&gt;e&lt;/code&gt; flag. This flag lets us fail silently, meaning that if we do not find a match on a given line, we won't yell about it. As a whole, this line lets us put a comment character followed by a space just before the first text, meaning we keep our indentation level.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;execute '''&amp;lt;,''&amp;gt;s/\v(^\s*)'.escape(b:commentChar, '\/').'\v\s*/\1/e'&lt;/code&gt; : This is similar to our last huge long command. Unique to this one, we have &lt;code&gt;\v&lt;/code&gt;, which makes sure that we don't have to escape our &lt;code&gt;()&lt;/code&gt;, and &lt;code&gt;1&lt;/code&gt;, which refers to the group we made with our &lt;code&gt;()&lt;/code&gt;. Basically, we're matching a line that starts with any amount of whitespace and then our comment character followed by any amount of whitespace, and we are only keeping the first set of whitespace. Again, &lt;code&gt;e&lt;/code&gt; lets us fail silently if we don't have a comment character on that line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;let l:line=getpos(&quot;'&amp;lt;&quot;)[1]&lt;/code&gt; : this sets a variable much like we did with our comment character, but &lt;code&gt;l&lt;/code&gt; refers to the local scope (local to this function). &lt;code&gt;getpos()&lt;/code&gt; gets the position of, in this case, the start of our highlighting, and the &lt;code&gt;[1]&lt;/code&gt; means we only care about the line number, not other things like the column number.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;if match(getline(l:line), '^\s*'.b:commentChar)&amp;gt;-1&lt;/code&gt; : you know how &lt;code&gt;if&lt;/code&gt; works. &lt;code&gt;match()&lt;/code&gt; checks if the first thing contains the second thing, so we grab the line that we started our highlighting on, and check if it starts with whitespace followed by our comment character. &lt;code&gt;match()&lt;/code&gt; returns the index where this is true, and &lt;code&gt;-1&lt;/code&gt; if no matches were found. Since &lt;code&gt;if&lt;/code&gt; evaluates all nonzero numbers to be true, we have to compare our output to see if it's greater than -1. Comparison in &lt;code&gt;vim&lt;/code&gt; returns 0 if false and 1 if true, which is what &lt;code&gt;if&lt;/code&gt; wants to see to evaluate correctly.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;vnoremap &amp;lt;silent&amp;gt; &amp;lt;C-r&amp;gt; :&amp;lt;C-u&amp;gt;call Comment()&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt; : &lt;code&gt;vnoremap&lt;/code&gt; means map the following command in visual mode, but don't map it recursively (meaning don't change any other commands that might use  in other ways). Basically, if you're a vim novice, always use &lt;code&gt;noremap&lt;/code&gt; to make sure you don't break things. &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; means &quot;I don't want your words, just your actions&quot; and tells it not to print anything to the command line. &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; is the thing we're mapping, which is ctrl+r in this case (note that you can still use C-r normally for &quot;redo&quot; in normal mode with this mapping). &lt;code&gt;C-u&lt;/code&gt; is kinda confusing, but basically it makes sure you don't lose track of your visual highlighting (according to &lt;a href=&quot;https://vi.stackexchange.com/questions/9751/understanding-ctrl-u-combination&quot;&gt;this answer&lt;/a&gt; it makes your command start with &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; which is what we want). &lt;code&gt;call&lt;/code&gt; here just tells vim to execute the function we named, and &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; refers to hitting the &lt;code&gt;enter&lt;/code&gt; button. We have to hit it once to actually call the function (otherwise we've just typed &lt;code&gt;call function()&lt;/code&gt; on the command line, and we have to hit it again to get our substitutes to go through all the way (not really sure why, but whatever). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Anyway, hopefully this helps. This will take anything highlighted with &lt;code&gt;v&lt;/code&gt;, &lt;code&gt;V&lt;/code&gt;, or &lt;code&gt;C-v&lt;/code&gt;, check if the first line is commented, if yes, try to uncomment all highlighted lines, and if not, add an extra layer of comment characters to each line. This is my desired behavior; I did not just want it to toggle whether each line in the block was commented or not, so it works perfectly for me after &lt;a href=&quot;https://vi.stackexchange.com/questions/15955/how-to-match-pattern-with-buffer-scoped-variable&quot;&gt;asking&lt;/a&gt; &lt;a href=&quot;https://vi.stackexchange.com/questions/15971/invalid-match-arguments&quot;&gt;multiple&lt;/a&gt; questions on the subject. &lt;/p&gt;&#xA;" OwnerUserId="17205" LastActivityDate="2018-05-02T23:50:25.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16125" PostTypeId="1" CreationDate="2018-05-03T08:16:11.493" Score="1" ViewCount="936" Body="&lt;p&gt;I want to use &lt;code&gt;yapf&lt;/code&gt; to reformat parts of python buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yapf can take input from stdin &lt;code&gt;yapf -l 30-40&lt;/code&gt;. This would produce output that is the whole buffer but with lines 30-40 reformatted. I can then generate diff between the &lt;code&gt;file.py&lt;/code&gt; as it is in vim buffer and yapf output. But I don't know how to apply this diff to a current buffer inside of &lt;code&gt;formatexpr&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastEditorUserId="6634" LastEditDate="2018-05-03T12:03:04.273" LastActivityDate="2018-05-03T12:03:04.273" Title="How to apply patch to a buffer in place?" Tags="|vimdiff|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="16126" PostTypeId="2" ParentId="16125" CreationDate="2018-05-03T08:41:20.223" Score="2" Body="&lt;p&gt;Vim provides a &lt;code&gt;filter&lt;/code&gt; feature aimed at this sort of problem. This allows you to pass content from Vim into an external tool, and then replace that content with the tool's output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation can be found at &lt;code&gt;:help filter&lt;/code&gt;, but to replace the entire contents of your file with the output of your &lt;code&gt;yapf&lt;/code&gt; command you can use the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!yapf -l 30-40&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For commands that don't require the entire content of the buffer as input, you can use a range with a filter (See &lt;code&gt;:help :range!&lt;/code&gt;). e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:30,40!yapf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-05-03T11:05:56.647" LastActivityDate="2018-05-03T11:05:56.647" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="16128" PostTypeId="1" AcceptedAnswerId="16130" CreationDate="2018-05-03T09:57:48.607" Score="4" ViewCount="298" Body="&lt;p&gt;Typing &lt;code&gt;:buffers&lt;/code&gt; gives a list of loaded buffers. Can I switch to a viewport that views one of those buffers by name?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that &lt;code&gt;:buffer NAME&lt;/code&gt; will load the named buffer in the current viewport. But I would rather type something like &lt;code&gt;:viewport NAME&lt;/code&gt; and to have the cursor move to whatever viewport is currently viewing the named buffer, without changing which buffers are loaded. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="5803" LastActivityDate="2018-05-03T13:09:01.653" Title="Switch to viewport by name?" Tags="|vimscript|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16130" PostTypeId="2" ParentId="16128" CreationDate="2018-05-03T13:09:01.653" Score="9" Body="&lt;p&gt;You probably want to set the &lt;code&gt;switchbuf&lt;/code&gt; option to &quot;useopen&quot; and then use &lt;code&gt;:sbuffer NAME&lt;/code&gt; instead of &lt;code&gt;:buffer&lt;/code&gt; to move your cursor to a window that has this buffer loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help switchbuf&lt;/code&gt; for more information on valid values, this is definitely the setting that handles the behviour you want.&lt;/p&gt;&#xA;" OwnerUserId="17397" LastActivityDate="2018-05-03T13:09:01.653" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16131" PostTypeId="2" ParentId="15959" CreationDate="2018-05-03T15:39:47.113" Score="1" Body="&lt;p&gt;I think you should be able to achieve this by using the &lt;code&gt;'wildignore'&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildignore+=*/ignoredir1/**/*,*/ignoredir2/**/*,*/ignoredir3/**/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;CtrlP respects this by default, and NERDTree will if you tell it to in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let NERDTreeRespectWildIgnore=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this isn't a whitelist, so you will need to manually add in all the things you want to ignore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is impractical, because the contents of your CWD are too numerous or frequently changing, there's no reason you couldn't set it programmatically in a loop, using &lt;code&gt;glob()&lt;/code&gt; to get a list of directory contents, &lt;code&gt;isdirectory()&lt;/code&gt; to check if each path is a directory, and using &lt;code&gt;set wildignore+=&lt;/code&gt; to append anything that isn't in your whitelist to the option.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-05-03T15:39:47.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16134" PostTypeId="2" ParentId="15138" CreationDate="2018-05-03T19:55:06.127" Score="7" Body="&lt;h1&gt;Indent methods&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Vim has several indent methods, including&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'autoindent'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'smartindent'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'cindent'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'indentexpr'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Each one is unique and differently powerful.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;cindent&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;According to &lt;code&gt;:help cino-i&lt;/code&gt;, you want to use &lt;code&gt;'cindent'&lt;/code&gt;. This is already set for &lt;code&gt;cpp&lt;/code&gt; files in &lt;code&gt;$VIMRUNTIME/indent/cpp.vim&lt;/code&gt;, as found by doing &lt;code&gt;:verbose set cindent?&lt;/code&gt; from a &lt;code&gt;cpp&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Customizing cindent for this case&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;To change the indentation of &quot;C++ base class declarations and constructor initializations,&quot; you then want to change &lt;code&gt;'cinoptions'&lt;/code&gt; to include &lt;code&gt;i0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example in the help docs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                *cino-i*&#xA;iN    Indent C++ base class declarations and constructor&#xA;      initializations, if they start in a new line (otherwise they&#xA;      are aligned at the right side of the ':').&#xA;      (default 'shiftwidth').&#xA;&#xA;        cino=                     cino=i0 &amp;gt;&#xA;          class MyClass :           class MyClass :&#xA;              public BaseClass      public BaseClass&#xA;          {}                        {}&#xA;          MyClass::MyClass() :      MyClass::MyClass() :&#xA;              BaseClass(3)          BaseClass(3)&#xA;          {}                        {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to accomplish that, I would do the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Set up a &lt;code&gt;C++&lt;/code&gt; filetype plugin by creating the the file &lt;code&gt;~/.vim/ftplugin/cpp.vim&lt;/code&gt; (or wherever your vim directory is)&lt;/li&gt;&#xA;&lt;li&gt;Add the following line to it:&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;setlocal cinoptions=i0&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This works because &lt;code&gt;'cinoptions'&lt;/code&gt; defaults to an empty string, is not changed by a filetype plugin, and the values used when not provided include &lt;code&gt;is&lt;/code&gt; (use a &lt;code&gt;'shiftwidth'&lt;/code&gt;) as seen in the help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cinoptions=&amp;gt;s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,E0,ps,ts,is,+s,&#xA;        c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Caveat based on OP's vimrc (AKA How to enable filetype-settings)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The OP's post already has &lt;code&gt;cinoptions&lt;/code&gt; with &lt;code&gt;i0&lt;/code&gt; in it (although it is set globally in all files). However, it does not appear to be working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order for this solution (and indeed &lt;code&gt;cinoptions&lt;/code&gt;/&lt;code&gt;cindent&lt;/code&gt; in general) to work, you need to enable filetype detection, plugins, and indenting (at the very least). To do this, add the following line to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find some more similar information &lt;a href=&quot;https://vi.stackexchange.com/questions/15009/vim-never-shows-line-number-for-python-files-even-though-i-have-vimrc/15019#15019&quot;&gt;on this vi.stackexchange post&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/14019/highlight-exported-go-functions/14036#14036&quot;&gt;this one&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/15325/using-tabenter-and-filetype-in-the-same-autocmd/15329#15329&quot;&gt;this one&lt;/a&gt;.&lt;sup&gt;They're all mine, because they were easy to find and I have written extensively on the topic.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Further notes&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Some testing related the unfortunate experience that the precise snippet in the OP then becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Horse(Color color, HANDS height, int age):&#xA;Animal(age),&#xA;    itsColor(color),&#xA;    itsHeight(height) {&#xA;        cout &amp;lt;&amp;lt; &quot;text&quot; ;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is only a small step towards the solution requested by the OP. This can be corrected by not indenting continuation lines (&lt;code&gt;+0&lt;/code&gt; for &lt;code&gt;'cinoptions'&lt;/code&gt;). However, then continuation lines won't be indented (see &lt;code&gt;:help cino-+&lt;/code&gt;). I suppose these are technically continuations (hence the commas, hence the indent).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyClass :&#xA;itsColors(color),&#xA;Animal(age),&#xA;itsHeight(height) {&#xA;    cout &amp;lt;&amp;lt; &quot;text&quot; ;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A better solution remains to write and use &lt;code&gt;indentexpr&lt;/code&gt; (possibly falling back on &lt;code&gt;cindent()&lt;/code&gt; except in this case). I am not currently up to the task.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-05-03T19:55:06.127" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16136" PostTypeId="2" ParentId="16108" CreationDate="2018-05-03T20:25:05.597" Score="10" Body="&lt;h1&gt;A quick rundown on colorschemes&lt;/h1&gt;&#xA;&lt;p&gt;See &lt;code&gt;:help :colorscheme&lt;/code&gt;. Essentially it sources a file containing &lt;code&gt;:highlight&lt;/code&gt; commands.&lt;/p&gt;&#xA;&lt;h2&gt;What are highlight commands?&lt;/h2&gt;&#xA;&lt;p&gt;Statements of the form&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:hi[ghlight] [default] {group-name} {key}={arg} ..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;that highlight sections of code (when syntax highlighting is enabled with &lt;code&gt;syntax enable&lt;/code&gt;) and sections of the UI.&lt;/p&gt;&#xA;&lt;p&gt;They can set special attributes like &lt;em&gt;italics&lt;/em&gt;, colors, and even the foreground and background.&lt;/p&gt;&#xA;&lt;h2&gt;What is this background stuff ?&lt;/h2&gt;&#xA;&lt;p&gt;More than likely, it comes from a colorscheme using the &lt;code&gt;Normal&lt;/code&gt; highlighting group (&lt;code&gt;:help :hi-normal-cterm&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Essentially, &lt;a href=&quot;https://chat.stackexchange.com/transcript/message/44362236#44362236&quot;&gt;as mentioned in the chat conversation&lt;/a&gt;, some colorschemes do something like &lt;code&gt;:hi Normal ctermbg=...&lt;/code&gt; to change the color of the background of the terminal inside vim. This was happening for Dracula (and, as you noticed, it's not pretty. More on that in a second), and &lt;a href=&quot;https://chat.stackexchange.com/transcript/message/44361208#44361208&quot;&gt;Molokai as well&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h1&gt;How do I fix it?&lt;/h1&gt;&#xA;&lt;p&gt;I'm going to address this on a case-by-case basis, then give some broader options.&lt;/p&gt;&#xA;&lt;h3&gt;Dracula&lt;/h3&gt;&#xA;&lt;p&gt;It came up in the chat that the OP was using Dracula. As I mentioned &lt;a href=&quot;https://chat.stackexchange.com/transcript/message/44361786#44361786&quot;&gt;here&lt;/a&gt;, during a &lt;a href=&quot;https://github.com/dracula/vim/pull/62&quot; rel=&quot;nofollow noreferrer&quot;&gt;theme overhaul&lt;/a&gt; some &lt;a href=&quot;https://github.com/dracula/vim/issues/65&quot; rel=&quot;nofollow noreferrer&quot;&gt;issues&lt;/a&gt; were &lt;a href=&quot;https://github.com/dracula/vim/issues/69&quot; rel=&quot;nofollow noreferrer&quot;&gt;raised&lt;/a&gt; about the theme background.&lt;/p&gt;&#xA;&lt;p&gt;It was using a 256-color &lt;em&gt;approximation&lt;/em&gt; of the right color when it couldn't use truecolor (like a GUI hexcode). We &lt;a href=&quot;https://github.com/dracula/vim/blob/b34882be6ccca2cd795346be3ed4d35c3e4e7cf1/doc/dracula.txt#L76&quot; rel=&quot;nofollow noreferrer&quot;&gt;added in a way to disable this&lt;/a&gt;, restoring the terminal background color.&lt;/p&gt;&#xA;&lt;p&gt;Put this&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:dracula_colorterm = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;before &lt;code&gt;colorscheme dracula&lt;/code&gt; to use your own terminal background.&lt;/p&gt;&#xA;&lt;h3&gt;Molokai&lt;/h3&gt;&#xA;&lt;p&gt;The OP also wanted to adjust &lt;code&gt;molokai&lt;/code&gt;. After discussing a bit, it was decided that molokai too looked good with no colored background. The solution is to use an autocommand to modify the colorscheme, like so:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;au ColorScheme molokai hi Normal ctermbg=None&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;(As always, I suggest wrapping autocommands in an augroup—see &lt;code&gt;:help augroup&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;h2&gt;General Case&lt;/h2&gt;&#xA;&lt;p&gt;The next piece of discussion was, &amp;quot;Can this be done for &lt;em&gt;every&lt;/em&gt; colorscheme?&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;The answer is, &lt;strong&gt;yes&lt;/strong&gt;. Furthermore, you can customize &lt;em&gt;any&lt;/em&gt; colorscheme, with &lt;em&gt;any&lt;/em&gt; highlighting group, using this technique.&lt;/p&gt;&#xA;&lt;p&gt;For example, to disable background highlighting on all colorschemes, use&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;au ColorScheme * hi Normal ctermbg=None&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&lt;p&gt;Colorschemes are hard. But like everything else, they are customizable. Sometimes it helps to see if they have documentation; other times, check the GitHub repos and consider filing an issue. Further recourse includes customizing the scheme using autocommands.&lt;/p&gt;&#xA;&lt;p&gt;At the end of the day, the colors we stare at while we code matter! Don't let them hurt your eyes.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-08-12T12:29:54.167" LastActivityDate="2020-08-12T12:29:54.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16137" PostTypeId="1" AcceptedAnswerId="16141" CreationDate="2018-05-03T21:56:13.413" Score="1" ViewCount="4624" Body="&lt;p&gt;I'm using Neovim on Ubuntu 18.04 LTS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If possible, I would like the solution to work both in insert mode and command mode.&lt;/p&gt;&#xA;" OwnerUserId="12132" LastEditorUserId="343" LastEditDate="2018-05-04T08:34:20.153" LastActivityDate="2021-06-26T00:09:38.337" Title="How do I map undo and redo to ctrl-z and ctrl-y respectively?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16138" PostTypeId="1" CreationDate="2018-05-04T03:23:36.850" Score="0" ViewCount="2336" Body="&lt;p&gt;Install ale with pathogen.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; cd ~/.vim/bundle&#xA; git clone https://github.com/w0rp/ale.git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My setting for ale in &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_sign_column_always = 1&#xA;let g:ale_set_highlights = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The target html file named &lt;code&gt;test.html&lt;/code&gt; to check with ale.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&#xA;&amp;lt;html lang=&quot;en&quot;&amp;gt;&#xA;&amp;lt;head&amp;gt;&#xA;    &amp;lt;meta charset=&quot;UTF-8&quot;&amp;gt;&#xA;    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&#xA;    &amp;lt;link rel=&quot;stylesheet&quot; herf=&quot;&quot; /&amp;gt;&#xA;&amp;lt;/head&amp;gt;&#xA;&amp;lt;body&amp;gt;&#xA;&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The real wrong syntax is a simple word &lt;code&gt;herf&lt;/code&gt; whose right format is &lt;code&gt;href&lt;/code&gt;.&lt;br&gt;&#xA;Open with vim installed ale.&lt;br&gt;&#xA;It is no matter to let title empty.&lt;br&gt;&#xA;&lt;code&gt;ale&lt;/code&gt; can't check out the real wrong syntax,a wrong spelled word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AQsB3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AQsB3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="14340" LastEditDate="2020-10-09T01:30:22.070" LastActivityDate="2020-10-09T01:30:22.070" Title="How to lint HTML file using the vim ale plugin?" Tags="|syntax-highlighting|filetype-html|plugin-ale|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16139" PostTypeId="1" AcceptedAnswerId="16140" CreationDate="2018-05-04T04:32:43.687" Score="1" ViewCount="832" Body="&lt;p&gt;Neither of the following mappings do anything in neovim in iterm2 on mac&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-BS&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;Right&amp;gt;s&#xA;&#xA;inoremap &amp;lt;S-BS&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;Right&amp;gt;s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is mapping backspace like this even possible?&lt;/p&gt;&#xA;" OwnerUserId="11136" LastActivityDate="2018-05-04T05:52:38.833" Title="&lt;S-BS&gt; and &lt;C-BS&gt; mappings not working" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16140" PostTypeId="2" ParentId="16139" CreationDate="2018-05-04T05:52:38.833" Score="5" Body="&lt;p&gt;In general this isn't possible, or will have strange side effects due to the way special keys are handled, but it depends on exactly what your terminal emulator is sending.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find out the keys sent to vim by the terminal emulator with &lt;code&gt;&amp;lt;c-v&amp;gt;&lt;/code&gt; in insert mode&lt;br&gt;&#xA;(&lt;code&gt;:h i_ctrl-v&lt;/code&gt;). Press ctrl+v followed by the key sequence you want to check. For example, my terminal, emulating xterm sends the following sequences:&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; sends &lt;code&gt;^?&lt;/code&gt; (&lt;code&gt;&amp;lt;C-?&amp;gt;&lt;/code&gt;)&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;C-BS&amp;gt;&lt;/code&gt; also sends &lt;code&gt;^?&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;S-BS&amp;gt;&lt;/code&gt; sends &lt;code&gt;^H&lt;/code&gt; (&lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So vim cannot distinguish between backspace, ctrl+backspace and ctrl+?, nor can it distinguish between ctrl+h and shift+backspace. So to get those mappings to work I could remap &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-?&amp;gt;/&amp;lt;BS&amp;gt;&lt;/code&gt; but these would obviously override other important keys. This is due to historical reasons.&lt;/p&gt;&#xA;" OwnerUserId="16910" LastActivityDate="2018-05-04T05:52:38.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16141" PostTypeId="2" ParentId="16137" CreationDate="2018-05-04T08:24:06.523" Score="4" Body="&lt;p&gt;Key mapping is introduced in chapter 5 of the user manual: &lt;code&gt;:help 05.3&lt;/code&gt;, and this is elaborated upon at &lt;code&gt;:help 40.1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the following for normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-Z&amp;gt; u&#xA;nnoremap &amp;lt;C-Y&amp;gt; &amp;lt;C-R&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For insert mode, you still need to run a normal mode command. You can include &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; in mappings to leave insert mode, but in this case you can also use &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; to run a single normal mode command while remaining in insert mode (See &lt;code&gt;:help i_CTRL-O&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-Z&amp;gt; &amp;lt;C-O&amp;gt;u&#xA;inoremap &amp;lt;C-Y&amp;gt; &amp;lt;C-O&amp;gt;&amp;lt;C-R&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more details, see &lt;code&gt;:help mapping&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-05-04T08:31:14.973" LastActivityDate="2018-05-04T08:31:14.973" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="16143" PostTypeId="2" ParentId="16138" CreationDate="2018-05-04T13:26:34.907" Score="1" Body="&lt;p&gt;It's important to note that ALE is not itself a linter, it is an interface to &quot;supported [...] tools which have been correctly installed.&quot; Given that you've only described installing ALE, and that you refer to &quot;ALE [not checking] out the real wrong syntax,&quot; I think you may have missed a step. See &lt;a href=&quot;https://github.com/w0rp/ale#1-supported-languages-and-tools&quot; rel=&quot;nofollow noreferrer&quot;&gt;Supported Languages and Tools&lt;/a&gt; for a handful of HTML linters that ALE supports. &lt;/p&gt;&#xA;" OwnerUserId="14684" LastActivityDate="2018-05-04T13:26:34.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16145" PostTypeId="1" CreationDate="2018-05-04T14:10:37.790" Score="2" ViewCount="1705" Body="&lt;p&gt;When I have typed a commit message with vim and, in haste, typed &lt;code&gt;:Wq&lt;/code&gt; instead of &lt;code&gt;:wq&lt;/code&gt; I get an error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E492: Not an editor command: Wq&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;from which I can (falsly?) recover, meaning the editor seems to function as normal and I can try to properly write and quit the buffer with &lt;code&gt;:wq&lt;/code&gt;. However, git-commit fails with:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;error: There was a problem with the editor 'vi'.&lt;br&gt;&#xA;  Please supply the message using either -m or -F option.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What has happened? Is this a misinterpretation in git's part? Can I somehow recover and actually save the commit message after accidental &lt;code&gt;:Wq&lt;/code&gt;? Besides copy and pasting what I've written…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vi is actually symlinked to vim and version is 8.0&lt;/p&gt;&#xA;" OwnerUserId="1303" LastEditorUserId="1841" LastEditDate="2018-05-04T14:39:56.290" LastActivityDate="2018-09-14T02:56:49.843" Title="Why &quot;there was a problem with vi&quot; when saving a git commit message with :wq after accidental :Wq?" Tags="|error|git|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16146" PostTypeId="1" CreationDate="2018-05-04T21:10:01.807" Score="1" ViewCount="234" Body="&lt;p&gt;When writing or appending files using python inside vim, new files are not being created and existing files are not being changed. Creating and appending files in python script and atom text editor are working, it's only in vim where it doesn't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm guessing it could be a permission issue or a bad path but I've tried using an absolute path which didn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure where to look or where to change permission. &#xA;I can add my .vimrc if needed or plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the python code - i use &lt;code&gt;try&lt;/code&gt; to show there is no input/output error: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from pathlib2 import Path&#xA;&#xA;p = Path('/Users/plutonium/Documents/Programs/Python/File')&#xA;q = p / 'a.ext'&#xA;&#xA;try:&#xA;    with open(q,'w') as f:&#xA;        f.write('content')&#xA;except IOError:&#xA;    print('I/O Error...') # no error&#xA;finally:&#xA;    print('checked')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17417" LastActivityDate="2018-05-04T21:10:01.807" Title="Issue when creating files using python in vim" Tags="|filetype-python|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="16148" PostTypeId="1" CreationDate="2018-05-04T21:46:00.953" Score="27" ViewCount="17867" Body="&lt;p&gt;When I press &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; from insert mode, it delayed about 1 sec, &#xA;but if I just do &lt;code&gt;&amp;lt;ctrl+c&amp;gt;&lt;/code&gt; instead it is fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked if there were mapping with escape with &lt;code&gt;:verbose imap &amp;lt;Esc&amp;gt;&lt;/code&gt;,&#xA;but I didn't find any.&lt;/p&gt;&#xA;" OwnerUserId="17420" LastEditorUserId="5017" LastEditDate="2019-06-05T12:33:40.510" LastActivityDate="2022-10-19T19:58:58.753" Title="Slow vim escape from insert mode" Tags="|escape|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16150" PostTypeId="1" AcceptedAnswerId="16152" CreationDate="2018-05-04T23:47:40.480" Score="0" ViewCount="1428" Body="&lt;p&gt;I just installed neovim on a fresh Manjaro install and my &lt;code&gt;~/.config/nvim&lt;/code&gt; directory isn't being generated. I tried uninstalling and reinstalling and I still have the same issue. I also ran a search for init.vim and there was no file on my system, the only relevant file I could find was &lt;code&gt;sysinit.vim&lt;/code&gt; in &lt;code&gt;/usr/share/nvim&lt;/code&gt;.  My &lt;code&gt;$XDG_CONFIG_HOME&lt;/code&gt; is set to &lt;code&gt;~/.config&lt;/code&gt;. Can I just create a &lt;code&gt;~/.config/nvim&lt;/code&gt; directory that contains &lt;code&gt;init.vim&lt;/code&gt;, or is there a directory I should copy to that location? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="17421" LastEditorUserId="28" LastEditDate="2018-05-06T04:33:02.180" LastActivityDate="2018-05-08T23:36:58.693" Title="Neovim on Manjaro- No ~/.config/nvim file being created on install" Tags="|neovim|linux|installing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16151" PostTypeId="2" ParentId="16148" CreationDate="2018-05-05T00:02:26.787" Score="1" Body="&lt;p&gt;The latency you experience is most probably the consequence of some plugin.&#xA;See &lt;a href=&quot;https://stackoverflow.com/questions/12213597/how-to-see-which-plugins-are-making-vim-slow&quot;&gt;this&lt;/a&gt; post on how to track possible culprits :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In resume:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:profile start profile.log&#xA;:profile func *&#xA;:profile file *&#xA;&quot; Go into insert mode, do some editing (to force updates)&#xA;&quot; Exit Insert mode with ESC&#xA;:profile pause&#xA;:noautocmd qall!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17308" LastActivityDate="2018-05-05T00:02:26.787" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16152" PostTypeId="2" ParentId="16150" CreationDate="2018-05-05T00:48:05.797" Score="0" Body="&lt;p&gt;In short, yes. Just create &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt; and neovim will find it. Nothing magic happens; neovim simply looks for an init.vim file at that location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(You can check all the files installed by a package with e.g. &lt;code&gt;pacman -Ql neovim&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="16910" LastEditorUserId="16910" LastEditDate="2018-05-08T23:36:58.693" LastActivityDate="2018-05-08T23:36:58.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16153" PostTypeId="1" AcceptedAnswerId="16154" CreationDate="2018-05-05T16:00:03.353" Score="1" ViewCount="42" Body="&lt;p&gt;Is it possible to convert a character from printable to literal? (like &lt;code&gt;&quot;&amp;lt;c-o&amp;gt;&quot;&lt;/code&gt; to &lt;code&gt;&quot;\&amp;lt;c-o&amp;gt;&quot;&lt;/code&gt;, or &lt;code&gt;&quot;&amp;lt;F1&amp;gt;&quot;&lt;/code&gt; to &lt;code&gt;&quot;\&amp;lt;F1&amp;gt;&quot;&lt;/code&gt;), other than by using a dicionary with all special characters. What about the other way around?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My aim to pass a mapping extracted from &lt;code&gt;:maps&lt;/code&gt; to feedkeys, but feedkeys does not accept non-literal special characters.&lt;/p&gt;&#xA;" OwnerUserId="11125" LastActivityDate="2018-05-05T16:52:09.323" Title="Get literal character from printable character" Tags="|parsing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16154" PostTypeId="2" ParentId="16153" CreationDate="2018-05-05T16:52:09.323" Score="1" Body="&lt;p&gt;The following should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:literal = eval('&quot;'.escape('&amp;lt;c-o&amp;gt; &amp;lt;f1&amp;gt; &amp;lt;bar&amp;gt; &amp;lt;ll&amp;gt; \e &quot;', '\&amp;lt;&quot;').'&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When vim encounters &lt;code&gt;&quot;\&amp;lt;invalid&amp;gt;&quot;&lt;/code&gt; it simply replaces it with &lt;code&gt;&amp;lt;invalid&amp;gt;&lt;/code&gt;.  A side effect of using double quotes is you need to also escape the characters &lt;code&gt;\&lt;/code&gt; and &lt;code&gt;&quot;&lt;/code&gt;, but this is simple to do.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-05-05T16:52:09.323" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16155" PostTypeId="2" ParentId="12058" CreationDate="2018-05-05T17:15:34.680" Score="2" Body="&lt;p&gt;Per this Stackoverflow:4586628 Q/A, &lt;a href=&quot;https://stackoverflow.com/questions/4586628/how-do-you-pipe-a-vim-buffer-through-lpr/4586667#4586667&quot;&gt;How do you pipe a vim buffer through lpr?&lt;/a&gt;, I have this entry in my &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap PpP :%w !lpr -o lpi=8 -o cpi=14&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that replaces my old entry,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap PpP :ha&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;:ha&lt;/code&gt; = &lt;code&gt;:hardcopy&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:ha&lt;/code&gt;, Neovim was not printing Greek letters, ... even though my (Arch Linux) &lt;code&gt;locale&lt;/code&gt; was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LANG=en_US.UTF-8&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I have this line, near the top of my &lt;code&gt;~/.vimrc&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;scriptencoding utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[&lt;em&gt;Printing is system-dependent, not vim-dependent.&lt;/em&gt;]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added the &lt;code&gt;lpi&lt;/code&gt; (lines-per-inch) and &lt;code&gt;cpi&lt;/code&gt; (characters-per-inch) to jiggle my font size to that similar to as what I was getting with the &lt;code&gt;:ha&lt;/code&gt; command (I measured/counted with an actual ruler), and run it as a &lt;code&gt;PpP&lt;/code&gt; command/shortcut, added to my &lt;code&gt;~/.vimrc&lt;/code&gt;, whenever I want to print the current buffer.&lt;/p&gt;&#xA;" OwnerUserId="10749" LastEditorUserId="10749" LastEditDate="2018-05-05T17:22:59.330" LastActivityDate="2018-05-05T17:22:59.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16156" PostTypeId="1" CreationDate="2018-05-05T17:20:10.520" Score="1" ViewCount="5064" Body="&lt;p&gt;I recently did a fresh install of Neovim and I'm trying to get YouCompleteMe to work. I installed the plugin with vim-plug with no errors, and followed the instructions on the YCM github page step by step, but my python completion is not working correctly. I have Jedi installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a picture of what the current completion looks like. It doesn't show the function parameters, which YCM should be displaying&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Plqly.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Plqly.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the output of :YcmDebugInfo&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Printing YouCompleteMe debug information...&#xA;-- Client logfile: /tmp/ycm_mdkuez0_.log&#xA;-- Server Python interpreter: /usr/bin/python&#xA;-- Server Python version: 3.6.5&#xA;-- Server has Clang support compiled in: False&#xA;-- Clang version: None&#xA;-- No extra configuration file found&#xA;-- Python completer debug information:&#xA;--   JediHTTP running at: http://127.0.0.1:45829&#xA;--   JediHTTP process ID: 3114&#xA;--   JediHTTP executable: ~/.nvim_extensions/YouCompleteMe/third_party/ycmd/third_party/JediHTTP/jedihttp&#xA;--   JediHTTP logfiles:&#xA;--     /tmp/jedihttp_45829_stdout_dolu7lhk.log&#xA;--     /tmp/jedihttp_45829_stderr_hgbvicgz.log&#xA;--   Python interpreter: /usr/bin/python3&#xA;-- Server running at: http://127.0.0.1:60969&#xA;-- Server process ID: 3073&#xA;-- Server logfiles:&#xA;--   /tmp/ycmd_60969_stdout_peqrwtbw.log&#xA;--   /tmp/ycmd_60969_stderr__mr96bdw.log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Jedi server seems to be running fine. Here is my init.vim :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number&#xA;filetype on&#xA;let g:ycm_python_binary_path = '/usr/bin/python3'&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;call plug#begin('~/.nvim_extensions')&#xA;Plug 'tpope/vim-fugitive'&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'vim-syntastic/syntastic'&#xA;Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am on Manjaro and everything is up to date. If you need any other info about my config please ask. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="17421" LastActivityDate="2018-09-18T18:00:24.307" Title="Neovim- YouCompleteMe Python completion not working" Tags="|neovim|plugin-you-complete-me|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16157" PostTypeId="2" ParentId="16148" CreationDate="2018-05-05T21:21:33.050" Score="1" Body="&lt;p&gt;You might want to try changing &lt;strong&gt;&lt;code&gt;ttimeoutlen&lt;/code&gt;&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, Vim 8.0 introduces a &lt;code&gt;$VIMRUNTIME/defaults.vim&lt;/code&gt; file which configures vim using more sane/modern settings. It contains these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ttimeout        &quot; time out for key codes&#xA;set ttimeoutlen=100 &quot; wait up to 100ms after Esc for special key&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I personally have &lt;code&gt;ttimeoutlen=0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Disclaimer: I don't fully understand everything that's going on with vim's timeout logic.)&lt;/p&gt;&#xA;" OwnerUserId="8214" LastEditorUserId="8214" LastEditDate="2018-05-05T21:34:57.327" LastActivityDate="2018-05-05T21:34:57.327" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16158" PostTypeId="1" CreationDate="2018-05-06T05:28:56.060" Score="1" ViewCount="167" Body="&lt;p&gt;I'm new to vim and I'm trying to figure out the key mapping.&#xA;I've defined the following key map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap \i INSERT INTO &amp;lt;??&amp;gt; VALUES &amp;lt;??&amp;gt; ( &amp;lt;??&amp;gt; ); &amp;lt;??&amp;gt;&#xA;imap \j &amp;lt;Esc&amp;gt;/&amp;lt;??&amp;gt; &amp;lt;CR&amp;gt; ciw&#xA;map \j &amp;lt;Esc&amp;gt;/&amp;lt;??&amp;gt; &amp;lt;CR&amp;gt; ciw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I hit &lt;code&gt;\j&lt;/code&gt; vim is not able to find the &lt;code&gt;&amp;lt;??&amp;gt;&lt;/code&gt; pattern after the semicolon in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap \i INSERT INTO &amp;lt;??&amp;gt; VALUES &amp;lt;??&amp;gt; ( &amp;lt;??&amp;gt; ); &amp;lt;??&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E486: Pattern not found: &amp;lt;??&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;help will be appreciated :).&lt;/p&gt;&#xA;" OwnerUserId="17428" LastEditorUserId="51" LastEditDate="2018-05-06T18:16:51.217" LastActivityDate="2018-05-06T18:16:51.217" Title="Key mappings in vim cant find patterns" Tags="|key-bindings|" AnswerCount="0" CommentCount="4" ClosedDate="2018-05-06T18:17:32.200" ContentLicense="CC BY-SA 4.0" />
  <row Id="16160" PostTypeId="1" AcceptedAnswerId="16162" CreationDate="2018-05-06T10:29:45.203" Score="1" ViewCount="1991" Body="&lt;p&gt;I have multiple vim global variables declared in &lt;code&gt;.vimrc&lt;/code&gt; file like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:wiki_list = {some dictionary ...}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am able to echo its output in vim exec window using &lt;code&gt;:echo wiki_list&lt;/code&gt;  &lt;strong&gt;BUT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I read/insert the echoed output in vim text window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to print the output of &lt;code&gt;:echo some_vim_global_variable&lt;/code&gt; in vim text window under my cursor position?&lt;/p&gt;&#xA;" OwnerUserId="17317" LastActivityDate="2018-05-06T17:44:27.080" Title="How do I insert value of a 'vim global variable' or 'vim internal commands' in text?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16161" PostTypeId="1" CreationDate="2018-05-06T14:38:02.133" Score="11" ViewCount="2856" Body="&lt;p&gt;I want to remap &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt; to print markdown &lt;code&gt;*&lt;/code&gt; symbol around the previous word. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# user actions inside &amp;lt;...&amp;gt;&#xA;some text typed in vim insert mode&amp;lt;cursor_position&amp;gt; &amp;lt;C-I&amp;gt;&#xA;&#xA;# expected  vim output&#xA;some text typed in vim insert *mode*&amp;lt;cursor_position&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using the following line in my &lt;code&gt;.vimrc&lt;/code&gt; for remapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-i&amp;gt; &amp;lt;ESC&amp;gt;Bi*&amp;lt;ESC&amp;gt;ea*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem is, as per help &lt;code&gt;:h i_CTRL-I&lt;/code&gt;, &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt; in insert mode is already mapped to something and the mapping above &lt;strong&gt;doesn't&lt;/strong&gt; work for me. Pressing &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt; in insert mode leaves a &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; on editor.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; or CTRL-I Insert a tab.  If the 'expandtab' option is on, the&#xA;                  equivalent number of spaces is inserted (use CTRL-V  to&#xA;                  avoid the expansion; use CTRL-Q &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; if CTRL-V is mapped&#xA;                  i_CTRL-Q).  See also the 'smarttab' option and&#xA;                  ins-expandtab.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How do I make insert mode &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt; mapping work?&lt;/li&gt;&#xA;&lt;li&gt;How can I override global vim key-mapping with my own key-mapping defined in &lt;code&gt;.vimrc&lt;/code&gt; file?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="17317" LastEditorUserId="51" LastEditDate="2018-05-06T18:30:33.623" LastActivityDate="2020-06-21T15:12:47.227" Title="How to map &lt;C-i&gt; separate from &lt;Tab&gt;?" Tags="|key-bindings|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16162" PostTypeId="2" ParentId="16160" CreationDate="2018-05-06T17:44:27.080" Score="3" Body="&lt;p&gt;There are two different ways I can think of to do this.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use the &lt;code&gt;&quot;=&lt;/code&gt; register. This is like a mini vim calculator that evaluates a string as vimscript code, and returns it in a register. This register can be accessed in normal or insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;=&amp;lt;expr&amp;gt;&amp;lt;cr&amp;gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In insert:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;=&amp;lt;expr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; can be any string of vimscript that evaluates to a string. So in order to get your dictionary variable to evaluate to a string, your &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; should be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;string(g:wiki_list)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use the &lt;code&gt;redir&lt;/code&gt; command. This basically captures all command line output and stores it into a specified register. Here is sample usage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @a&#xA;:echo g:wiki_list&#xA;&quot;ap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not a huge fan of this approach because 1) you'll end up with a bunch of extra newlines, and 2) You have to remember to call &lt;code&gt;:redir end&lt;/code&gt; afterwards, otherwise your register will get cluttered with a bunch of extra output you don't necessarily want.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-05-06T17:44:27.080" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16163" PostTypeId="1" AcceptedAnswerId="16171" CreationDate="2018-05-06T19:39:47.063" Score="3" ViewCount="453" Body="&lt;p&gt;I know I can use the &lt;code&gt;:file&lt;/code&gt; command to change the name of the current buffer. Is there some way to change the name of an arbitrary buffer without switching to that buffer?&lt;/p&gt;&#xA;" OwnerUserId="13151" LastActivityDate="2018-05-07T14:59:40.970" Title="Change the name of a buffer in the background" Tags="|buffers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16164" PostTypeId="1" AcceptedAnswerId="16166" CreationDate="2018-05-06T20:00:32.430" Score="1" ViewCount="2173" Body="&lt;p&gt;I am editing a tex file using vim, searching for words starting with capital letters, as they are most likely proper names or names of works to which I'd like to add some formatting and/or indexing commands. Now &lt;code&gt;/\u\l\l&lt;/code&gt; will catch the beginning of words with a capital letter, but not if one of them has diacritics on them, such as &quot;Wṛhaspatitattwa&quot;, where the dot under the r breaks it. How can I extend my search to also match such kind of letters?&lt;/p&gt;&#xA;" OwnerUserId="2774" LastActivityDate="2018-05-06T21:28:56.247" Title="How to match for diacritic combinations" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16165" PostTypeId="2" ParentId="16164" CreationDate="2018-05-06T20:38:13.907" Score="2" Body="&lt;p&gt;It depends on exactly how careful you want to be with your matches, but there are many options. The simplest would be to just replace &lt;code&gt;\l&lt;/code&gt; with &lt;code&gt;\U&lt;/code&gt; (any non-uppercase character):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\u\U\U&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately this also catches Capitol letters followed by e.g. whitespace, so we could use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\u\(\U\U\)\&amp;amp;\(\S\S\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which requires the next two characters after the capitol letter be both non uppercase letters and non whitespace characters. I might use a solution such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\u[^A-Z[:space:][:punct:]]\{2,}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This matches an uppercase character followed by at least 2 of any character that isn't an uppercase character, whitespace character or punctuation mark, so it will match entire words. However there are many ways of getting almost the same goal with slightly different results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: As mentioned, none of these solutions take into account the possiblity of the first character having a diacritic mark.&lt;/p&gt;&#xA;" OwnerUserId="16910" LastEditorUserId="16910" LastEditDate="2018-05-06T21:28:56.247" LastActivityDate="2018-05-06T21:28:56.247" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16166" PostTypeId="2" ParentId="16164" CreationDate="2018-05-06T21:08:36.517" Score="4" Body="&lt;p&gt;If you are using the new regex engine (you most likely are), then &lt;code&gt;/[[:upper:]][[:lower:]][[:lower:]]&lt;/code&gt; will work for all of the following cases:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Śiva&#xA;Śiva&#xA;Wṛhaspatitattwa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the difference between the first and second- one is a single unicode code-point which is two bytes when encoded in utf-8, the other uses a combining acute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not all of the &lt;code&gt;[[]]&lt;/code&gt; character classes work as you'd expect with higher unicode characters, but &lt;code&gt;lower&lt;/code&gt; and &lt;code&gt;upper&lt;/code&gt; are documented as working under &lt;code&gt;:help [:upper:]&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-05-06T21:08:36.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16167" PostTypeId="1" CreationDate="2018-05-07T06:33:15.447" Score="2" ViewCount="1245" Body="&lt;p&gt;Is it possible to append a line break to the current line in normal-mode? Basically the opposite of what &lt;code&gt;J&lt;/code&gt; does.&lt;/p&gt;&#xA;" OwnerUserId="11490" LastActivityDate="2018-05-07T07:33:33.530" Title="Append line break to current line (opposite of `J`)" Tags="|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16168" PostTypeId="2" ParentId="16167" CreationDate="2018-05-07T07:33:33.530" Score="2" Body="&lt;p&gt;I think the closest to what you want would be to replace the character under your cursor by a new line which you can do with &lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use these mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;o o&amp;lt;Esc&amp;gt;0&quot;_D&#xA;nnoremap &amp;lt;Leader&amp;gt;O O&amp;lt;Esc&amp;gt;0&quot;_D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They will add a new line under or above the current line without changing your registers.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-05-07T07:33:33.530" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16170" PostTypeId="2" ParentId="5286" CreationDate="2018-05-07T12:58:16.360" Score="1" Body="&lt;p&gt;I have written a custom function for commenting in COBOL, you can use something similar for Python. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Comment(currmode) range&#xA;    let origpos=getpos('.')&#xA;    if a:currmode==&quot;visual&quot;&#xA;       if mode()==&quot;v&quot;&#xA;           let [linestart, colstart] = getpos(&quot;v&quot;)[1:2]&#xA;           let [lineend, colend] = getpos(&quot;.&quot;)[1:2]&#xA;       else&#xA;           let [linestart, colstart] = getpos(&quot;'&amp;lt;&quot;)[1:2]&#xA;           let [lineend, colend] = getpos(&quot;'&amp;gt;&quot;)[1:2]&#xA;       end&#xA;       if (line2byte(linestart)+colstart) &amp;gt; (line2byte(lineend)+colend)&#xA;           let [linestart, colstart, lineend, colend] =&#xA;           \   [lineend, colend, linestart, colstart]&#xA;       end&#xA;       let comcount=lineend - linestart + 1&#xA;       call setpos('.',[0,linestart,1])&#xA;    else&#xA;       let comcount=v:count1&#xA;       let linestart=line('.')&#xA;    endif&#xA;    if strpart(getline(linestart),6,1) == '*'&#xA;       let comment=0&#xA;       let label='uncomment'&#xA;    else&#xA;       let comment=1&#xA;       let label='comment'&#xA;    endif&#xA;    call inputsave()&#xA;    let tag = input('Tag for '.label.': ')&#xA;    call inputrestore()&#xA;    let tag=strpart(Pad(tag,6),0,6)&#xA;    let i=1&#xA;    while i &amp;lt;= comcount&#xA;       if !comment&#xA;          let newline=substitute(getline('.'),'^.......',tag.' ','')&#xA;          call setline('.',newline)&#xA;       else&#xA;          let newline=substitute(getline('.'),'^.......',tag.'*','')&#xA;          call setline('.',newline)&#xA;       endif&#xA;       let i = i+1&#xA;       call setpos('.',[0,linestart+i-1,1])&#xA;    endwhile&#xA;    call setpos('.',origpos)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And add the following mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt;cp   :&amp;lt;C-U&amp;gt;call Comment('normal')&amp;lt;CR&amp;gt;&#xA;vmap &amp;lt;silent&amp;gt;cp   :&amp;lt;C-U&amp;gt;call Comment('visual')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;COBOL commenting is very specific - comment is &lt;code&gt;*&lt;/code&gt; in the 7th column of the line. With this code I can comment code using - a range, visual block, single line and add custom Tag (1st 6 chars of the line) using input at run-time (you probably won't need this).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ex. If I want to comment 5 lines starting from current line I can-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a. &lt;code&gt;5cp&lt;/code&gt; in normal mode&#xA;   b. select 5 lines using visual block (V-LINE or V-BLOCK) and hit &lt;code&gt;cp&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly for un-commenting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function basically computes the first and last line of the range. For &lt;code&gt;visual mode&lt;/code&gt; I use &lt;code&gt;getpos&lt;/code&gt; and for &lt;code&gt;normal mode&lt;/code&gt; I use &lt;code&gt;v:count1&lt;/code&gt;. Once I get the range, I run the comment/uncomment code in loop to insert the tag and an * in the 7th column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this is helpful.&lt;/p&gt;&#xA;" OwnerUserId="16636" LastEditorUserId="16636" LastEditDate="2018-05-07T13:28:12.317" LastActivityDate="2018-05-07T13:28:12.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16171" PostTypeId="2" ParentId="16163" CreationDate="2018-05-07T14:59:40.970" Score="2" Body="&lt;p&gt;You could use the following function which is pretty simple:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First we save the current buffer and the cursor position to be able to restore them later&lt;/li&gt;&#xA;&lt;li&gt;Then we show the result of &lt;code&gt;buffers&lt;/code&gt; to help the user decide what buffer they want to change (this could be commented out)&lt;/li&gt;&#xA;&lt;li&gt;Then we get the user input of the buffer to change (by it's number) and the new name to use&lt;/li&gt;&#xA;&lt;li&gt;Once we have this information we can switch to the buffer to rename and rename it&lt;/li&gt;&#xA;&lt;li&gt;Finally we go back to the previous position.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So technically, it is not changing the buffer name without switching to that buffer, but the switch is made invisible to the user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is the following and can be used with &lt;code&gt;call ChangeBufferName()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ChangeBufferName() abort&#xA;    &quot; Save the current cursor position and the current buffer number&#xA;    let saveBuffer = bufnr('')&#xA;    let saveCursor = getpos('.')&#xA;&#xA;    &quot; List the available buffers&#xA;    buffers&#xA;&#xA;    &quot; Get the buffer to change and its new name&#xA;    let bufferToChange = input('buffer to rename ')&#xA;    let newName = input('new buffer name ')&#xA;&#xA;    &quot; Change the buffer name&#xA;    execute 'b' . bufferToChange&#xA;    execute 'file ' . newName&#xA;&#xA;    &quot; Return to the previous position&#xA;    execute 'b' . saveBuffer&#xA;    call setpos('.', saveCursor)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that we could easily change the function to take some arguments instead of waiting for user input.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-05-07T14:59:40.970" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16172" PostTypeId="2" ParentId="12602" CreationDate="2018-05-07T15:02:28.303" Score="4" Body="&lt;p&gt;In .vimrc use a leader key and specify as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;p li&amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;p&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(leader-P to insert buffer after the cursor, adding a single space before the buffer.)&lt;/p&gt;&#xA;" OwnerUserId="15150" LastActivityDate="2018-05-07T15:02:28.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16173" PostTypeId="1" CreationDate="2018-05-07T17:14:32.050" Score="0" ViewCount="291" Body="&lt;p&gt;I have a file-watcher system which triggers some compilations upon time-stamp changes in the source file I am editing. I have the obsessive habit of using &lt;code&gt;:w&lt;/code&gt; quite a few times during my editing session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to remap &lt;code&gt;:w&lt;/code&gt; to &lt;code&gt;:up&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="8408" LastActivityDate="2018-06-07T06:08:11.097" Title="How to remap :w to :up?" Tags="|save|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16174" PostTypeId="1" AcceptedAnswerId="16175" CreationDate="2018-05-07T19:01:50.960" Score="3" ViewCount="145" Body="&lt;p&gt;I am developing a vim plugin and I have set a default mapping this way.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !hasmapto('&amp;lt;Plug&amp;gt;DumpDebugString')&#xA;    nmap &amp;lt;unique&amp;gt; &amp;lt;Leader&amp;gt;ds  &amp;lt;Plug&amp;gt;DumpDebugString&#xA;    nmap &amp;lt;unique&amp;gt; &amp;lt;Leader&amp;gt;dS  &amp;lt;Plug&amp;gt;DumpDebugStringExpr&#xA;endif&#xA;&#xA;...&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;DumpDebugString :&amp;lt;C-U&amp;gt; :call &amp;lt;SID&amp;gt;debugFunctionWrapper(0)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;DumpDebugStringExpr :&amp;lt;C-U&amp;gt; :call &amp;lt;SID&amp;gt;debugFunctionWrapper(1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try invoking ds the DumpDebugString method runs correctly but takes some time actually get called in the first place. It is run instantly only if I map it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;ds &amp;lt;Plug&amp;gt;DumpDebugString&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the extra &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; shouldn't be needed since it already included in the &lt;code&gt;nnoremap&lt;/code&gt; call.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I don't think it has anything to do with the actual mapping characters or with the use of &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Substituting &lt;code&gt;:call &amp;lt;SID&amp;gt;debugFunctionWrapper(0)&amp;lt;CR&amp;gt;&lt;/code&gt; with something like &lt;code&gt;:call str2nr(&quot;1&quot;)&amp;lt;CR&amp;gt;&lt;/code&gt; doesn't seem to solve the problem&lt;/li&gt;&#xA;&lt;li&gt;Adding &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; doesn't do anything.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For the story, here's the plugin: &lt;a href=&quot;https://github.com/bergercookie/vim-debugstring&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/bergercookie/vim-debugstring&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6972" LastActivityDate="2018-05-07T19:55:37.027" Title="Execution of nnoremap takes significant time" Tags="|key-bindings|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16175" PostTypeId="2" ParentId="16174" CreationDate="2018-05-07T19:35:01.810" Score="6" Body="&lt;p&gt;When you press &lt;code&gt;Leader d s&lt;/code&gt;, Vim expands the keysequence into &lt;code&gt;&amp;lt;plug&amp;gt;DumpDebugString&lt;/code&gt;.&#xA;However, it doesn't expand the latter immediately, because it waits for you to maybe press &lt;code&gt;Expr&lt;/code&gt; afterwards.&#xA;This is due to the other &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;nowait&amp;gt; &amp;lt;unique&amp;gt; &amp;lt;Leader&amp;gt;dS  &amp;lt;Plug&amp;gt;DumpDebugStringExpr&#xA;                                                        ^^^^&#xA;                                                        Vim waits `&amp;amp;ttimeout` ms for these keys to be typed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One solution is to surround all your &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mappings with parentheses:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;unique&amp;gt; &amp;lt;Leader&amp;gt;ds  &amp;lt;Plug&amp;gt;(DumpDebugString)&#xA;nmap &amp;lt;unique&amp;gt; &amp;lt;Leader&amp;gt;dS  &amp;lt;Plug&amp;gt;(DumpDebugStringExpr)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, when you press &lt;code&gt;Leader d s&lt;/code&gt;, and it gets expanded into &lt;code&gt;&amp;lt;plug&amp;gt;(DumpDebugString)&lt;/code&gt;, there's no ambiguity anymore.&#xA;Vim doesn't wait for &lt;code&gt;Expr&lt;/code&gt; to be typed because there's no &lt;code&gt;&amp;lt;plug&amp;gt;(DumpDebugString)Expr&lt;/code&gt; mapping.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-05-07T19:55:37.027" LastActivityDate="2018-05-07T19:55:37.027" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16176" PostTypeId="1" CreationDate="2018-05-07T21:48:39.720" Score="1" ViewCount="531" Body="&lt;p&gt;I only recently realized that I have a &lt;code&gt;vimx&lt;/code&gt; binary installed that allows me to switch from terminal mode to gui mode with the &lt;code&gt;:gui&lt;/code&gt; command. This is nice but it has complicated my configuration somewhat, because there are some settings that I want to be different depending on whether I am running in terminal mode or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to run a set of commands when switching from terminal&#xA;mode to gui mode (and back again, if that's possible)?&lt;/p&gt;&#xA;" OwnerUserId="1776" LastActivityDate="2018-05-07T21:48:39.720" Title="Running commands when switching to gui mode?" Tags="|vimrc|gvim|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16178" PostTypeId="2" ParentId="2365" CreationDate="2018-05-08T02:06:54.303" Score="1" Body="&lt;p&gt;Based on Christian Brabandt's solution I came up with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; n 'Nn'[v:searchforward].(&amp;amp;fdo=~'search\\|all'?'zv':'')&#xA;nnoremap &amp;lt;expr&amp;gt; N 'nN'[v:searchforward].(&amp;amp;fdo=~'search\\|all'?'zv':'')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These mappings also obey the &lt;code&gt;foldopen&lt;/code&gt; setting&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-05-08T02:06:54.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16179" PostTypeId="2" ParentId="16173" CreationDate="2018-05-08T05:15:39.480" Score="2" Body="&lt;p&gt;I had added below in my .vimrc earlier based on &lt;a href=&quot;https://stackoverflow.com/questions/7513380/vim-change-x-function-to-delete-buffer-instead-of-save-quit&quot;&gt;this&lt;/a&gt; post.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev &amp;lt;expr&amp;gt; w getcmdtype() == &quot;:&quot; &amp;amp;&amp;amp; getcmdline() == 'w' ? 'up' : 'w'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, there is a &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=746&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt; which does this too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="16636" LastActivityDate="2018-05-08T05:15:39.480" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16180" PostTypeId="1" AcceptedAnswerId="16181" CreationDate="2018-05-08T07:59:19.960" Score="2" ViewCount="1673" Body="&lt;p&gt;I found &lt;a href=&quot;https://stackoverflow.com/questions/18196399/exclude-capitalized-words-from-vim-spell-check&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://stackoverflow.com/questions/7561603/vim-spell-check-ignore-capitalized-words/7569127&quot;&gt;here&lt;/a&gt; how to force Vim spell checker to ignore words with capital letters from being check. But my case is quite opposite. I want to ignore words that in corrected form include capital letters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in sentence:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;europe was chozen best&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;only word &lt;strong&gt;chozen&lt;/strong&gt; is the wrong one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to achieve that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any hint.&lt;/p&gt;&#xA;" OwnerUserId="13694" LastActivityDate="2018-05-08T15:54:29.937" Title="How to force vim spellchecker to ignore lowercase/uppercase errors" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16181" PostTypeId="2" ParentId="16180" CreationDate="2018-05-08T15:21:15.590" Score="5" Body="&lt;p&gt;I don't think that Vim has a setting for this. One workaround is to create a new spellfile that contains everything in your current spell file(s) but with lowercase letters only:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Create a new buffer containing everything from the spell file(s) currently in use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:spelldump&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Delete lines that don't contain any upper-case characters. This isn't strictly necessary, but there's no point keeping duplicate entries for lower-case words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:v/\u/d&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Convert the entire file to lower-case, ignoring lines that contain the locations of the spell files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:v/^#/norm gu$&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Save the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w ~/.vim/spell/lowercase.utf-8.add&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Start using this file in addition to the standard files in Vim's &lt;code&gt;$VIMRUNTIME&lt;/code&gt; directory. Note that Vim uses a default &lt;code&gt;'spellfile'&lt;/code&gt; value internally if the setting is empty, so if you already have any existing spell files, you will need to ensure that they are included in this setting (which accepts a comma-delimited list):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set spellfile=~/.vim/spell/lowercase.utf-8.add&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that if you set this option in a running instance of Vim, it doesn't seem to take effect for spell-checking until you interact with it (by, e.g. using the &lt;code&gt;zg&lt;/code&gt; command.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The above doesn't affect the way that Vim detects lower-case words at the start of a sentence as spelled incorrectly. You can disable this with the &lt;code&gt;'spellcapcheck'&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set spellcapcheck=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-05-08T15:54:29.937" LastActivityDate="2018-05-08T15:54:29.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16182" PostTypeId="2" ParentId="495" CreationDate="2018-05-09T05:09:10.817" Score="3" Body="&lt;p&gt;For completeness, &lt;code&gt;=&lt;/code&gt; could also be used to fix indentations, after you have specified that tabs are replaced with spaces. In normal mode, you can do so by typing &lt;code&gt;:set expandtab&lt;/code&gt;. Then &lt;code&gt;=&lt;/code&gt; could be used in two ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In Visual mode, a single &lt;code&gt;=&lt;/code&gt; would fix indentations of selected code blocks. &lt;/li&gt;&#xA;&lt;li&gt;In normal mode, &lt;code&gt;gg=G&lt;/code&gt; would fix the entire file, where &lt;code&gt;gg&lt;/code&gt; moves the cursor to the beginning of the file, then &lt;code&gt;=&lt;/code&gt; is applied, and &lt;code&gt;G&lt;/code&gt; moves the cursor to the end of the file. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Reference: &lt;a href=&quot;http://vim.wikia.com/wiki/Fix_indentation&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6328" LastEditorUserId="6328" LastEditDate="2018-05-09T21:06:12.860" LastActivityDate="2018-05-09T21:06:12.860" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16183" PostTypeId="2" ParentId="5286" CreationDate="2018-05-09T05:18:38.430" Score="0" Body="&lt;p&gt;I used to do it manually until I found &lt;a href=&quot;https://github.com/tpope/vim-commentary/blob/master/plugin/commentary.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Commentary Master&lt;/a&gt; which I now used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was in the process of writing a function but had got to use some mappings or a macro that I loaded when the &lt;code&gt;ft&lt;/code&gt; was right&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I used for something like the following, assuming ft=txt but using a sql format comment&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  This a a non comment line&#xA; This is  &#xA; So's this  &#xA; This isn't&#xA; This is  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for example recording a macro in &lt;code&gt;w&lt;/code&gt; i e&lt;code&gt;qw&lt;/code&gt; which goes to the beginning of th current line inserts a &lt;code&gt;/*&lt;/code&gt; then adds to the end of the line an &lt;code&gt;*/&lt;/code&gt; would look like this &lt;code&gt;0i/* ^[A */^[&lt;/code&gt; and when you &lt;code&gt;@w&lt;/code&gt; on each line does this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This a a non comment line&#xA;/* This is   */&#xA;/* So's this   */&#xA;This isn't&#xA;/* This is   */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However for me it was easier to set ft specific registers eg &lt;code&gt;autocmd FileType txt let @b='&amp;lt;!--'&lt;/code&gt; which a &lt;code&gt;C-Rb&lt;/code&gt; in insert mode put the &lt;code&gt;/*&lt;/code&gt; and a matching command mapping to &lt;code&gt;@e&lt;/code&gt; would put the close comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a matching command that removed them in one go, which I've deleted. :( &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer the plugin now as I didn't have time to write a function properly&lt;/p&gt;&#xA;" OwnerUserId="1313" LastActivityDate="2018-05-09T05:18:38.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16185" PostTypeId="1" AcceptedAnswerId="16188" CreationDate="2018-05-09T08:14:46.467" Score="0" ViewCount="55" Body="&lt;p&gt;I've been using the vim-surround plugin for as long as I can remember and have grown accustomed to typing &lt;code&gt;&amp;lt;c-g&amp;gt;s )&lt;/code&gt; when I want to insert text between brackets. I was writing with the atom editor recently and kind of liked the fact that the editor always inserts a closing bracket if you type an opening one. I realized that producing a similar effect in vim is trivial: I can just use the following mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap ( ()&amp;lt;c-o&amp;gt;i&#xA;imap [ []&amp;lt;c-o&amp;gt;i&#xA;imap { {}&amp;lt;c-o&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seemed so obvious that I started wondering why I haven't seen this done very often in people's vimrcs. Are there some possible conflicts / pitfalls related to this?&lt;/p&gt;&#xA;" OwnerUserId="7784" LastActivityDate="2018-05-09T09:59:57.180" Title="Is there possibly something wrong with (i)mapping the left bracket?" Tags="|vimrc|insert-mode|plugin-vim-surround|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16186" PostTypeId="1" AcceptedAnswerId="16200" CreationDate="2018-05-09T09:43:34.540" Score="9" ViewCount="5837" Body="&lt;p&gt;I have a bunch of really useful terminal programs which I use often while I am editing or writing. For example, dictionary is a popular one and I have aliased its usage to single character &lt;code&gt;d&lt;/code&gt; in &lt;code&gt;.zshrc&lt;/code&gt; file to save time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I am editing documentation pages in VIM, is there a way I can use &lt;code&gt;.zshrc&lt;/code&gt; aliases in &lt;code&gt;vim command mode&lt;/code&gt; and everything still works? Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# alias defined in .zshrc&#xA;alias d=&quot;dictionary-program&quot;&#xA;&#xA;# VIM command mode&#xA;:!d &amp;lt;some_word&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I tell vim to lookup alias in &lt;code&gt;.zshrc&lt;/code&gt; file before executing terminal commands from command mode?&lt;/p&gt;&#xA;" OwnerUserId="17317" LastEditorUserId="17317" LastEditDate="2018-05-09T14:35:48.497" LastActivityDate="2018-05-10T06:19:51.423" Title="How to run zsh aliased command from vim command mode?" Tags="|command-line|external-command|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16188" PostTypeId="2" ParentId="16185" CreationDate="2018-05-09T09:59:57.180" Score="3" Body="&lt;p&gt;Well, for one it does not work very well with Repeating using &lt;code&gt;.&lt;/code&gt;. That means, if you create a new buffer start insert mode and type &lt;code&gt;(foobar&lt;/code&gt; your buffer will show &lt;code&gt;(foobar)&lt;/code&gt;. How redo the thing using &lt;code&gt;.&lt;/code&gt;. It will redo only &lt;code&gt;foobar&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it would also break the undo sequence, but that does not seem to happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix the &lt;code&gt;.&lt;/code&gt; repeating issue, I suggest to use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap ( ()&amp;lt;c-g&amp;gt;U&amp;lt;left&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That needs support for &lt;code&gt;&amp;lt;C-G&amp;gt;U&lt;/code&gt; in insert mode which has been included in a late Vim 7.4 patch to work and has been requested a couple of years ago on vim_dev. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There might be other gotchas (or people in general just use a snippet/completion plugin instead) and do not care about the details :))&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-05-09T09:59:57.180" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16189" PostTypeId="1" AcceptedAnswerId="16194" CreationDate="2018-05-09T10:37:14.193" Score="21" ViewCount="37268" Body="&lt;p&gt;I have a vim's buffer and a terminal in the same vim's window but each time switch to terminal I can only exit it to go back to vim's buffer,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to keep terminal session but be able to switch to vim's buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used gvim 1-10802 on windows 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="10604" LastEditDate="2020-06-24T12:09:34.690" LastActivityDate="2023-04-20T17:00:53.933" Title="How to switch between buffer and terminal" Tags="|vim-windows|terminal-buffer|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16190" PostTypeId="1" AcceptedAnswerId="16191" CreationDate="2018-05-09T10:57:10.190" Score="7" ViewCount="566" Body="&lt;p&gt;I've been having trouble understanding the behavior defined in &lt;code&gt;GetRSTIndent()&lt;/code&gt; in &lt;code&gt;indent/rst.vim&lt;/code&gt;. I'm specifically using Neovim v0.2.2, but I believe this file has not changed between Vim/Neovim.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Background and Behavior&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The specific indent file I'm referring to is on the Neovim GitHub repo &lt;a href=&quot;https://github.com/neovim/neovim/blob/946c2a8ee85830c543e389724575ae531e89b170/runtime/indent/rst.vim&quot; rel=&quot;noreferrer&quot;&gt;at this location&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The effect is as follows: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I'm typing a list (numbered or bullet point), my indentation always carries over from the previous line, causing too much indentation. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- First item&amp;lt;Enter&amp;gt;&#xA;  | &amp;lt;-- Cursor here.&#xA;&#xA;- Item one&amp;lt;Enter&amp;gt;&#xA;  - Item two&amp;lt;Enter&amp;gt;&#xA;    - Item three&#xA;&#xA;1. This is list item one&amp;lt;Enter&amp;gt;&#xA;   2. This is list item two&amp;lt;Enter&amp;gt;&#xA;         3. This is three&amp;lt;Enter&amp;gt;&#xA;                     4. This is four&amp;lt;Enter&amp;gt;&#xA;                                             5. This is five&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, for me to continue with my list with a new bullet point, I have to press &lt;code&gt;&amp;lt;Backspace&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-D&amp;gt;&lt;/code&gt; to get back to the correct indentation level before typing my next item. (The situation is even more strange with numbered lists; I expect this is a bug.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked on the &lt;code&gt;&quot;markdown&quot;&lt;/code&gt; filetype and it does not have any of this strange indent behavior. In my opinion, the handling of the Markdown is as I would expect, but the handling of reStructuredText is counterintuitive (and, at least for me, a hassle).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;My question is two part:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Why might this behavior be explicitly hardcoded for the &lt;code&gt;rst&lt;/code&gt; filetype?&lt;/li&gt;&#xA;&lt;li&gt;Can anyone see a reason why I shouldn't submit this as a GitHub issue for the &lt;code&gt;indent/rst.vim&lt;/code&gt; file?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If this is this simply undesired/counterintuitive behavior, I'd like to open an issue on the GitHub repo. I just want to make sure I understand the issue clearly. At this point, I know &quot;what&quot; the indent file is doing, but I don't understand &quot;why.&quot; The code seems redundant to features (i.e. &lt;code&gt;':set formatoptions+=n'&lt;/code&gt;) already present in Vim.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Workarounds for Present&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For anyone who stumbles on this simply trying to fix the issue, here is how I have been able to do so at present:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;:set indentexpr=&quot;&quot;&lt;/code&gt; to avoid the behavior when editing reStructuredText (or edit the &lt;code&gt;indent/rst.vim&lt;/code&gt; file directly to avoid using &lt;code&gt;GetRSTIndent()&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If desired, the same affect can be obtained using &lt;code&gt;:set formatoptions+=n&lt;/code&gt;. This also has the benefit of &lt;em&gt;only&lt;/em&gt; wrapping when the line wraps automatically according to &lt;code&gt;'textwidth'&lt;/code&gt; (Instead, the &lt;code&gt;GetRSTIndent()&lt;/code&gt; increases indent every time you press &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; to start a new item--almost certainly not what you want!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For further ideas on how to handle RST indentation, please also see this question: &lt;a href=&quot;https://vi.stackexchange.com/q/12687/17423&quot;&gt;How to avoid indenting after a line that starts with a number?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17423" LastEditorUserId="17423" LastEditDate="2018-05-09T11:07:44.970" LastActivityDate="2018-05-09T15:12:08.347" Title="Why does the &quot;rst&quot; filetype automatically indent subsequent list items?" Tags="|indentation|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16191" PostTypeId="2" ParentId="16190" CreationDate="2018-05-09T11:34:20.327" Score="3" Body="&lt;p&gt;My hunch is that the author of the plugin always includes a blank line between their list items. Note that if you press &lt;kbd&gt;Enter&lt;/kbd&gt; a second time, without first entering any further text, the cursor moves back out to the indent level of the list item.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#bullet-lists&quot; rel=&quot;nofollow noreferrer&quot;&gt;the spec&lt;/a&gt;, this blank line is optional (although none of the examples in the &lt;a href=&quot;http://docutils.sourceforge.net/docs/user/rst/quickstart.html#lists&quot; rel=&quot;nofollow noreferrer&quot;&gt;primer&lt;/a&gt; omit it), so I think you can probably report this as a bug. (You should perhaps first check whether adding an issue to the GitHub repo is the mechanism for doing so that the Neovim maintainers favour: for Vim I believe it's suggested you should contact the plugin author directly, initially.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess I can see some utility in the current implementation: if you're willing to always include the extra vertical spacing, it allows you to either create a sublist (by typing a new bullet point) or not (by pressing &lt;kbd&gt;Enter&lt;/kbd&gt; and &lt;em&gt;then&lt;/em&gt; adding the bullet) without having to adjust indentation manually at all.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-05-09T15:12:08.347" LastActivityDate="2018-05-09T15:12:08.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16193" PostTypeId="2" ParentId="16186" CreationDate="2018-05-09T12:41:20.267" Score="6" Body="&lt;p&gt;&lt;em&gt;The question originally asked about a solution for &lt;strong&gt;bash&lt;/strong&gt;. I answered before I discovered that it was subsequently changed to be all about &lt;strong&gt;zsh&lt;/strong&gt;. Fortunately, that original answer is very similar to the answer for zsh. And because several people found value in that answer (based on their upvotes) I've decided to address both shells rather than totally overwrite the bash information.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;'shell'&lt;/code&gt; setting can be used to tell Vim how to start the shell used in terminal commands. The default value is the value of environment variable &lt;code&gt;$SHELL&lt;/code&gt; or, if that's not found, just &lt;code&gt;sh&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just set it to, say, &lt;code&gt;/bin/zsh&lt;/code&gt; your startup file won't be picked up. You can tell the shell which startup file to use with the &lt;code&gt;--rcs&lt;/code&gt; flag (bash: &lt;code&gt;--rcfile&lt;/code&gt;). Alternatively, if you specify &lt;code&gt;-i&lt;/code&gt; (for &quot;interactive&quot; shell) then the shell will read &lt;code&gt;$ZDOTDIR/.zshrc&lt;/code&gt; or &lt;code&gt;$HOME/.zshrc&lt;/code&gt; if &lt;code&gt;ZDOTDIR&lt;/code&gt; is not set (for bash it's always &lt;code&gt;$HOME/.bashrc&lt;/code&gt;). As it happens, you also need &lt;code&gt;-i&lt;/code&gt; if you want to pick up aliases so that makes the choice clear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together, you can add something like this to your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; zsh&#xA;let &amp;amp;shell='/bin/zsh -i'&#xA;&#xA;&quot; bash&#xA;let &amp;amp;shell='/bin/bash -i'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, something strange happens with zsh (bash works fine). Vim gets put in the background and you are dropped at your zsh prompt with this message: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;zsh: suspended (tty output)  vim&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The workaround I came up with is to defer the setting of &lt;code&gt;'shell'&lt;/code&gt; by adding this to vimrc instead of the line above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd vimenter * let &amp;amp;shell='/bin/zsh -i'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hopefully no other strange things happen but so far the testing I've done has gone well.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-05-10T06:19:51.423" LastActivityDate="2018-05-10T06:19:51.423" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16194" PostTypeId="2" ParentId="16189" CreationDate="2018-05-09T14:57:21.343" Score="22" Body="&lt;p&gt;From &lt;code&gt;:h terminal-typing&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;CTRL-W&lt;/code&gt; can be used to navigate between windows and other CTRL-W commands, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-W CTRL-W   move focus to the next window&#xA;CTRL-W :    enter an Ex command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2018-05-09T14:57:21.343" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16195" PostTypeId="1" AcceptedAnswerId="16198" CreationDate="2018-05-09T15:04:50.870" Score="2" ViewCount="302" Body="&lt;p&gt;I have two buffers, and would like one takes 1/4 of a window and other takes rest of the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normal behavior would be for example &lt;code&gt;sp&lt;/code&gt; or &lt;code&gt;vsp&lt;/code&gt; would split buffer to take 50/50 percent each, there would be some buffers more important than others so that I raise this question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case, I'd like to have a terminal buffer that takes 1/4 of a window and other takes the rest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used gvim 1-1802 on windows 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2018-05-09T17:01:54.563" Title="How to have a buffer takes 1/4 of a window and another takes all the rest?" Tags="|vimrc|gvim|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16196" PostTypeId="1" CreationDate="2018-05-09T15:52:25.283" Score="1" ViewCount="2696" Body="&lt;p&gt;This thing is driving me nuts&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to setup vim on my co-workers computer, and this is my .&lt;a href=&quot;https://github.com/abbood/.vimrc/blob/master/.vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimrc&lt;/a&gt; file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;everytime I run vim I get this error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /Users/toters/.vimrc:&#xA;line   10:&#xA;E518: Unknown option: termguicolors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however, If i simply run this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -U NONE -N ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then run these commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn on&#xA;:colorscheme Spacegray &#xA;:set termguicolors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;things work perfectly. What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running osx, here is my vim version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May  7 2018 03:54:08)&#xA;macOS version&#xA;Included patches: 1-1800&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               +farsi             +mouse_sgr         -tag_any_white&#xA;+arabic            +file_in_path      -mouse_sysmouse    -tcl&#xA;+autocmd           +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       +terminal&#xA;-balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;-browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    -gettext           +netbeans_intg     +timers&#xA;+byte_offset       -hangul_input      +num64             +title&#xA;+channel           +iconv             +packages          -toolbar&#xA;+cindent           +insert_expand     +path_extra        +user_commands&#xA;-clientserver      +job               +perl              +vertsplit&#xA;+clipboard         +jumplist          +persistent_undo   +virtualedit&#xA;+cmdline_compl     +keymap            +postscript        +visual&#xA;+cmdline_hist      +lambda            +printer           +visualextra&#xA;+cmdline_info      +langmap           +profile           +viminfo&#xA;+comments          +libcall           -python            +vreplace&#xA;+conceal           +linebreak         +python3           +wildignore&#xA;+cryptv            +lispindent        +quickfix          +wildmenu&#xA;+cscope            +listcmds          +reltime           +windows&#xA;+cursorbind        +localmap          +rightleft         +writebackup&#xA;+cursorshape       -lua               +ruby              -X11&#xA;+dialog_con        +menu              +scrollbind        -xfontset&#xA;+diff              +mksession         +signs             -xim&#xA;+digraphs          +modify_fname      +smartindent       -xpm&#xA;-dnd               +mouse             +startuptime       -xsmp&#xA;-ebcdic            -mouseshape        +statusline        -xterm_clipboard&#xA;+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save&#xA;+eval              -mouse_gpm         +syntax&#xA;+ex_extra          -mouse_jsbterm     +tag_binary&#xA;+extra_search      +mouse_netterm     +tag_old_static&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -D_DARWIN_C_SOURCE -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework AppKit   -mmacosx-version-min=10.12 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.26.2/lib/perl5/5.26.2/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin -lpython3.6m -framework CoreFoundation  -lruby.2.5.1 -lobjc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and on my ~/.bash_profile &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export TERM=xterm-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ideas?&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="51" LastEditDate="2018-05-09T16:53:10.623" LastActivityDate="2018-05-10T15:53:36.717" Title="E518: Unknown option: termguicolors" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16197" PostTypeId="2" ParentId="16186" CreationDate="2018-05-09T16:58:08.323" Score="1" Body="&lt;p&gt;Not exactly what is asked in question but I found an amazing workaround from VIM documentation. No extra setup or whatsoever required.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;1. Suspend and resume&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Like most Unix programs Vim can be suspended by pressing CTRL-Z.  This stops&#xA;Vim and takes you back to the shell it was started in.  You can then do any&#xA;other commands until you are bored with them.  Then bring back Vim with the&#xA;&quot;fg&quot; command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-Z&#xA;{any sequence of shell commands}&#xA;fg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are right back where you left Vim, nothing has changed.&#xA;   In case pressing CTRL-Z doesn't work, you can also use &quot;:suspend&quot;.&#xA;Don't forget to bring Vim back to the foreground, you would lose any changes&#xA;that you made!&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Only Unix has support for this.  On other systems Vim will start a&#xA;  shell for you.  This also has the functionality of being able to&#xA;  execute shell commands. But it's a new shell, not the one that you&#xA;  started Vim from.    When you are running the GUI you can't go back to&#xA;  the shell where Vim was started.  CTRL-Z will minimize the Vim window&#xA;  instead.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h1&gt;2. Starting new shell&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You can start a new shell this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:shell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is similar to using CTRL-Z to suspend Vim.  The difference is that a newnshell is started. Exit back to vim hitting &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;D&lt;/kbd&gt; &lt;/p&gt;&#xA;" OwnerUserId="17317" LastEditorUserId="17317" LastEditDate="2018-05-09T17:07:52.690" LastActivityDate="2018-05-09T17:07:52.690" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16198" PostTypeId="2" ParentId="16195" CreationDate="2018-05-09T17:01:54.563" Score="6" Body="&lt;p&gt;You can use the &lt;code&gt;&amp;amp;columns&lt;/code&gt; setting and some math to achieve this. Do you want to resize your existing splits, or make a new split at the right ratios? Since it's not entirely clear from your question, here's how you can do it both ways.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Resizing existing splits&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I used this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Quarter()&#xA;  exec &quot;vertical resize &quot;.(&amp;amp;columns / 4). &quot; N&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will resize the existing buffer to a quarter of the screen size. Of course, you can map this to a key, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;q :call Quarter()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;q :exec &quot;vertical resize &quot;.(&amp;amp;columns / 4). &quot; N&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can bind this function to the &lt;code&gt;VimResized&lt;/code&gt; event.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Making new splits&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec (&amp;amp;columns / 4).&quot; vsplit&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to make the current window 1/4 and the new window fill up the rest, or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec (&amp;amp;columns / 4 * 3).&quot; vsplit&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to make the new window 1/4 and the current window fill up the rest.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-05-09T17:01:54.563" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16199" PostTypeId="1" CreationDate="2018-05-09T17:13:17.893" Score="1" ViewCount="112" Body="&lt;p&gt;I am running Macvim 8.0.1633 (146) on macos 10.13.3&#xA;Weirdly, even with syntax on, the math highlighting is plain wrong:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ZFwkF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZFwkF.png&quot; alt=&quot;weird behavior&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, I didn't search for end{equation} Does anyone know what is going on?&lt;/p&gt;&#xA;" OwnerUserId="17470" LastActivityDate="2018-05-11T19:39:54.587" Title="macvim does not recognize math latex symbols anymore" Tags="|macvim|filetype-tex|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16200" PostTypeId="2" ParentId="16186" CreationDate="2018-05-09T17:31:33.790" Score="2" Body="&lt;p&gt;One possible workaround is to move these things out of &lt;code&gt;.zshrc&lt;/code&gt;. &lt;code&gt;.zshrc&lt;/code&gt; is only sourced for interactive terminals, but &lt;code&gt;.zshenv&lt;/code&gt; is sourced for &lt;em&gt;any&lt;/em&gt; invocation of &lt;code&gt;zsh&lt;/code&gt; (except with &lt;code&gt;-f&lt;/code&gt;). Creating aliases in &lt;code&gt;.zshenv&lt;/code&gt; will allow them to work when &lt;code&gt;zsh&lt;/code&gt; is called by &lt;code&gt;vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wouldn't necessarily recommend this approach, because again - now any and every invocation of &lt;code&gt;zsh&lt;/code&gt; has these aliases set. But, depending on how many tools you use that invoke &lt;code&gt;zsh&lt;/code&gt;, how likely you think an unexpected collision is to happen with your aliases, how concerned you are about startup times for noninteractive shells, etc., it could be an acceptable workaround (and it does work).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is briefly documented in the &lt;a href=&quot;http://zsh.sourceforge.net/Intro/intro_3.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation under Startup Files&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14684" LastEditorUserId="14684" LastEditDate="2018-05-09T17:54:01.303" LastActivityDate="2018-05-09T17:54:01.303" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16202" PostTypeId="1" CreationDate="2018-05-09T21:00:13.507" Score="0" ViewCount="289" Body="&lt;p&gt;I would like to create documentation just like vim-help system . Multiple .txt files with links and cross references and where I can jump foreward  &lt;code&gt;CTRL+]&lt;/code&gt; and back using &lt;code&gt;CTRL+T&lt;/code&gt;. How is it done?&lt;/p&gt;&#xA;" OwnerUserId="17317" LastActivityDate="2018-05-09T21:00:13.507" Title="How to create man-pages and link them like in vim help system?" Tags="|help-system|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16203" PostTypeId="1" CreationDate="2018-05-09T23:27:54.643" Score="1" ViewCount="483" Body="&lt;p&gt;I get what paste mode does for you, but I have never found it particularly useful.  I would like to completely deactivate it. I don't see an option to do so when looking at &lt;code&gt;:help paste&lt;/code&gt;.  However, I figure this is doable with some combination of an auto-command and pastetoggle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone help me write this autocommand?  I can't find clear instructions on the Internet for this use case.&lt;/p&gt;&#xA;" OwnerUserId="14882" LastEditorUserId="1430" LastEditDate="2018-05-10T18:34:17.703" LastActivityDate="2018-05-10T18:34:17.703" Title="Disable paste mode entirely" Tags="|cut-copy-paste|autocmd|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="16204" PostTypeId="1" AcceptedAnswerId="16205" CreationDate="2018-05-10T03:06:14.953" Score="0" ViewCount="386" Body="&lt;p&gt;After reading &lt;a href=&quot;https://stackoverflow.com/questions/7338794/vim-regex-replace-with-n-characters&quot;&gt;https://stackoverflow.com/questions/7338794/vim-regex-replace-with-n-characters&lt;/a&gt;, I've known how to replace tabs by spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\v(\t)*/\=repeat(repeat(' ',4),strlen(submatch(0)))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command above allows me to replace n tabs at the beginning of each line with n four-spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to inverse it: replace n four-spaces with n tabs, I think the command should be &lt;code&gt;:%s/^\v(    )*/\=repeat(&quot;\t&quot;,strlen(submatch(0)))/g&lt;/code&gt;, but it doesn't work: if there is one four-space, it will be replaced by four tabs after executing the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides, is it possible to get the length of tab of vim so that I can make the command as below?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\v(\t)*/\=repeat(repeat(' ',getSizeOfTab()),strlen(submatch(0)))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ATTENTION: I only want to replace the spaces at the beginning of each line.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2018-05-10T03:59:21.063" LastActivityDate="2018-05-10T08:43:02.353" Title="vim: replace n strings with another strings" Tags="|replace|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="16205" PostTypeId="2" ParentId="16204" CreationDate="2018-05-10T07:07:21.333" Score="2" Body="&lt;p&gt;I think you want a simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\s\{4\}/\t/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that matches 4 spaces and replaces them by a single tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want it to only appy to the beginning of the line, this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\(^\s*\)\@&amp;lt;=\(\s\{4\}\)/\t/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That uses a zero-width assertion to make sure it always matches Spaces at the beginning of a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other question: If you want to know the length of a tab you can access the &lt;code&gt;'tabstop'&lt;/code&gt; setting. However, since it usually depends on the position where the tab is on the screen, you might want to check the &lt;code&gt;strdisplaywidth()&lt;/code&gt; function.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-05-10T07:13:05.850" LastActivityDate="2018-05-10T07:13:05.850" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16206" PostTypeId="2" ParentId="16204" CreationDate="2018-05-10T08:33:42.613" Score="1" Body="&lt;p&gt;The problem with the command you've already tried is that you're calculating the number of tabs to add by using the length of the entire match. So if you have 4 spaces, which has a length of 4, you use 4 tabs. You can fix this simply by dividing the length by 4. In order not to confuse the &lt;code&gt;/&lt;/code&gt; division operator with the &lt;code&gt;/&lt;/code&gt; characters used for separating the &lt;code&gt;:substitute&lt;/code&gt; command, you will need to use a different character for the latter (See &lt;code&gt;:help E146&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :%s@^\v( )+@\=repeat(&quot;\t&quot;,strlen(submatch(0))/4)@g&#xA;           ^                                  ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. I made one other change to your command: switching the &lt;code&gt;*&lt;/code&gt; for a &lt;code&gt;+&lt;/code&gt;. There's no need to replace no spaces with no tabs!&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-05-10T08:43:02.353" LastActivityDate="2018-05-10T08:43:02.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16208" PostTypeId="2" ParentId="16189" CreationDate="2018-05-10T17:40:32.817" Score="25" Body="&lt;p&gt;A better way which I use (and love these days) to jump between terminal (interactive mode with all &lt;code&gt;alias&lt;/code&gt; and &lt;code&gt;path&lt;/code&gt; set) and vim is using &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;Z&lt;/kbd&gt; in &lt;code&gt;normal&lt;/code&gt; mode. Work on terminal, and when done type &lt;code&gt;fg&lt;/code&gt; to return back to vim right where I left.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;Z&lt;/kbd&gt; Suspend Vim, like &lt;code&gt;:stop&lt;/code&gt;. Works in&#xA;Normal and in Visual mode.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h1&gt;1. Suspend and resume&lt;/h1&gt;&#xA;&lt;p&gt;Like most Unix programs Vim can be suspended by pressing CTRL-Z.  This stops&#xA;Vim and takes you back to the shell it was started in.  You can then do any&#xA;other commands until you are bored with them.  Then bring back Vim with the&#xA;&amp;quot;fg&amp;quot; command.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-Z&#xA;{any sequence of shell commands}&#xA;fg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You are right back where you left Vim, nothing has changed.&#xA;In case pressing CTRL-Z doesn't work, you can also use &amp;quot;:suspend&amp;quot;.&#xA;Don't forget to bring Vim back to the foreground, you would lose any changes&#xA;that you made!&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Only Unix has support for this.  On other systems Vim will start a&#xA;shell for you.  This also has the functionality of being able to&#xA;execute shell commands. But it's a new shell, not the one that you&#xA;started Vim from.    When you are running the GUI you can't go back to&#xA;the shell where Vim was started.  CTRL-Z will minimize the Vim window&#xA;instead.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h1&gt;2. Starting new shell&lt;/h1&gt;&#xA;&lt;p&gt;You can start a new shell this way:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:term[inal]          //  for nvim users&#xA;:shell                // (depricated in nvim)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is similar to using CTRL-Z to suspend Vim.  The difference is that a newnshell is started. Exit back to vim hitting &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;D&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="17317" LastEditorUserId="17317" LastEditDate="2021-03-06T08:50:46.510" LastActivityDate="2021-03-06T08:50:46.510" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16209" PostTypeId="1" AcceptedAnswerId="16210" CreationDate="2018-05-10T17:41:00.020" Score="2" ViewCount="392" Body="&lt;p&gt;For example, if I want to run &lt;code&gt;tidy&lt;/code&gt; on a file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;r! tidy %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I have to save the file beforehand. Is there any way around this?&lt;/p&gt;&#xA;" OwnerUserId="13695" LastActivityDate="2020-10-05T18:58:44.477" Title="How to run shell commands on file without saving?" Tags="|external-command|save|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16210" PostTypeId="2" ParentId="16209" CreationDate="2018-05-10T18:30:18.720" Score="5" Body="&lt;pre&gt;&lt;code&gt;:range! command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will run an external command, pipe the lines specified in &lt;em&gt;range&lt;/em&gt; to it and replace &lt;em&gt;range&lt;/em&gt; with the output of the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a special case, &lt;code&gt;%&lt;/code&gt; as a range includes all lines in the buffer. (see &lt;code&gt;help :%&lt;/code&gt;) So this should do what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%! tidy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7995" LastEditorUserId="2920" LastEditDate="2018-05-10T18:45:11.427" LastActivityDate="2018-05-10T18:45:11.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16212" PostTypeId="1" CreationDate="2018-05-10T21:50:55.880" Score="2" ViewCount="837" Body="&lt;p&gt;I am connected to a Windows SSH server from a Linux client, on Windows I end up in a Powershell. For small,quick edits I use the &lt;a href=&quot;ftp://ftp.vim.org/pub/vim/pc/vim80-586w32.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;official vim windows console binary&lt;/a&gt;. It seems to work without additional asset files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Page-Up/Down works normally, cursors too, but when I scroll &quot;past&quot; the bottom or top of the screen one line at a time with the cursors, all lines but the current one get cleared, and I need to force a redraw with &lt;code&gt;^L&lt;/code&gt; to see them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect the fault here to not be with vim, but more with MS_OpenSSH/Powershell. However, I think this can be fixed by vim, by hooking something into the event that gets called when the entire page needs to be refreshed.&lt;/p&gt;&#xA;" OwnerUserId="3102" LastActivityDate="2018-05-10T21:50:55.880" Title="vim does not redraw the screen properly when scrolling the page up or down line-by-line" Tags="|terminal|scrolling|redraw|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16213" PostTypeId="1" AcceptedAnswerId="16214" CreationDate="2018-05-11T01:28:42.603" Score="2" ViewCount="68" Body="&lt;p&gt;Give a buffer each line contain a filename. how to use &lt;code&gt;r! cmd&lt;/code&gt; on the filename, within a &lt;code&gt;:g&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BEFORE PROCESSING:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;file1.txt  &#xA;file2.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;AFTER PROCESSING (with &lt;code&gt;wc -l&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;file1.txt  &#xA;12 file1.txt  &#xA;file2.txt  &#xA;23 file2.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;P.S.&lt;br&gt;&#xA;extra kudos for using a submatch instead of whole line in the solution.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="205" LastEditDate="2018-05-11T01:39:18.253" LastActivityDate="2018-05-11T05:20:56.247" Title=":global, how to use matched pattern in the cmd of :g/pat/cmd?" Tags="|command-line|external-command|global-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16214" PostTypeId="2" ParentId="16213" CreationDate="2018-05-11T04:26:30.437" Score="2" Body="&lt;p&gt;With a file on every line and assuming each file either has a path or can be found in the current directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/./ r !wc -l &amp;lt;cfile&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Per &lt;code&gt;:h :&amp;lt;cfile&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;cfile&amp;gt;&lt;/code&gt; is a special token that when encountered on the command line&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;is replaced with the path name under the cursor.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This might not be quite what you expected as your &quot;P.S.&quot; suggests you want to use backreferences or equivalent to find files that make up only part of each line. Well, I don't know about that but here's an approximation of that functionality...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say that our lines are made up of a word followed by whitespace followed by a filename:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo file1.txt&#xA;bar file2.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command above will not work because &lt;code&gt;:global&lt;/code&gt; just puts the cursor at the beginning of each line before processing it. So to use &lt;code&gt;&amp;lt;cfile&amp;gt;&lt;/code&gt; we need some way to demarcate the file name and get the cursor on it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\w\+\s\+\zs\S\+$/ exe &quot;norm! n&quot; | r !wc -l &amp;lt;cfile&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By using &lt;code&gt;\zs&lt;/code&gt; in the pattern where the filename begins and then Normal mode command &lt;code&gt;n&lt;/code&gt; (go to next match) the cursor is then in a position where we can make use of &lt;code&gt;&amp;lt;cfile&amp;gt;&lt;/code&gt;. (The pattern could be a bit simpler but I'm being explicit/verbose for the sake of clarity.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: we use &lt;code&gt;exe &quot;norm .. &quot;&lt;/code&gt; instead of plain &lt;code&gt;norm&lt;/code&gt; because otherwise we couldn't follow it with a non-Normal mode command.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-05-11T05:20:56.247" LastActivityDate="2018-05-11T05:20:56.247" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16215" PostTypeId="1" CreationDate="2018-05-11T07:45:46.510" Score="1" ViewCount="116" Body="&lt;p&gt;Right now I have a python (*.py) file buffer open in a vim session. I also have the plugin startify installed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when I run the Ex-command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &amp;amp;g:filetype`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get &lt;code&gt;startify&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, When I run &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &amp;amp;filetype&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get &lt;code&gt;python&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried doing &lt;code&gt;setl filetype?&lt;/code&gt; and &lt;code&gt;set filetype?&lt;/code&gt;, I get &lt;code&gt;python&lt;/code&gt; for both. &lt;del&gt;So it is not an issue of local vs global setting.&lt;/del&gt; I can't seem to find anything relevant the docs for &lt;code&gt;'filetype'&lt;/code&gt; or &lt;code&gt;:set&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once I run &lt;code&gt;set ft=python&lt;/code&gt; on the buffer, both &lt;code&gt;echo &amp;amp;ft&lt;/code&gt; and &lt;code&gt;echo &amp;amp;g:ft&lt;/code&gt; start displaying &lt;code&gt;python&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can this be explained? What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I am using vim 8.0(1-133) on windows 7.&lt;/p&gt;&#xA;" OwnerUserId="17487" LastEditorUserId="10604" LastEditDate="2020-06-22T14:35:53.147" LastActivityDate="2020-06-22T14:35:53.147" Title="Difference between &amp;g:filetype and &amp;filetype" Tags="|filetype|set|" AnswerCount="0" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16216" PostTypeId="1" CreationDate="2018-05-11T09:45:50.067" Score="1" ViewCount="7385" Body="&lt;p&gt;I am new to vim. As much as I love it, there seem to be a lot of bugs or errors every time I try doing something. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am unable to run the plugin &quot;browserlink.vim&quot; (&lt;a href=&quot;https://github.com/jaxbot/browserlink.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/jaxbot/browserlink.vim&lt;/a&gt;). It shows the following error: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Fatal Python error: Py_Initialize: unable to load the file system codec &#xA;ImportError: No module named 'encodings'&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have searched for fixing but I don't understand exactly what to do from the documentation found on StackOverflow and Github issues. For instance, when running the command &lt;code&gt;:py print(1)&lt;/code&gt; it throws the error &lt;code&gt;E887: Sorry, this command is disabled, the Python's site module could not be loaded&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim version is 8.0 and the python version I have installed is 3.6.5 (64bits) and I use Windows 10. Can anyone help me?  &lt;/p&gt;&#xA;" OwnerUserId="17490" LastActivityDate="2021-01-28T10:43:56.793" Title="Fatal Python error: Py_Initialize: unable to load the file system codec ImportError: No module named 'encodings'" Tags="|vim-windows|microsoft-windows|plugin-python-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16217" PostTypeId="1" AcceptedAnswerId="16219" CreationDate="2018-05-11T10:23:53.153" Score="3" ViewCount="800" Body="&lt;p&gt;I'm making a command that runs tests and opens coverage report for the currently opened file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap cov :!vendor/phpunit/phpunit/phpunit --coverage-html \&#xA;/tmp/coverage/ test/ &amp;amp;&amp;amp; google-chrome /tmp/coverage/&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I put the contents of filename register (&lt;code&gt;%&lt;/code&gt;) into the bash command I want to execute?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap cov :!vendor/phpunit/phpunit/phpunit --coverage-html \&#xA;/tmp/coverage/ test/ &amp;amp;&amp;amp; google-chrome /tmp/coverage/FILENAME_GOES_HERE&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also a closer try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function CoverageHtml(filename)&#xA;    execute '!vendor/phpunit/phpunit/phpunit' '--coverage-html' '/tmp/coverage/' 'test/'&#xA;    let f = &quot;/tmp/coverage&quot; + a:filename&#xA;    execute '!google-chrome' f&#xA;endfunction&#xA;&#xA;function CoverageHtmlInit()&#xA;    &quot;fails in the next line. &#xA;    let fn = :echo @%&#xA;    return CoverageHtml(fn)&#xA;endfunction&#xA;&#xA;nnoremap cov :call CoverageHtmlInit()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16700" LastEditorUserId="16700" LastEditDate="2018-05-11T12:18:52.503" LastActivityDate="2018-05-11T12:53:48.550" Title="Use current filename register in bash command ran from VIM" Tags="|vimscript|bash|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16218" PostTypeId="2" ParentId="16217" CreationDate="2018-05-11T12:40:32.627" Score="0" Body="&lt;p&gt;This was the partial solution based on janos' answer. Can't manipulate the %, so needed another test directory structure to make it work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function CoverageHtml(filename)&#xA;    execute '!vendor/phpunit/phpunit/phpunit' '--coverage-html' '/tmp/coverage/src/' 'test/'&#xA;    execute '!google-chrome' '/tmp/coverage/%.html'&#xA;endfunction&#xA;&#xA;nnoremap cov :let a=@% &amp;lt;CR&amp;gt;:call CoverageHtml(a)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16700" LastActivityDate="2018-05-11T12:40:32.627" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16219" PostTypeId="2" ParentId="16217" CreationDate="2018-05-11T12:53:48.550" Score="2" Body="&lt;p&gt;To refer to the current file, you can use &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can even use modified versions of the path, by applying one ore more of the modifiers as documented in &lt;code&gt;:help %:&lt;/code&gt;.&#xA;To highlight just a few interesting ones from the help page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:p  Make file name a full path.  Must be the first modifier.  Also&#xA;    changes &quot;~/&quot; (and &quot;~user/&quot; for Unix and VMS) to the path for&#xA;    the home directory.  If the name is a directory a path&#xA;    separator is added at the end.  For a file name that does not&#xA;    exist and does not have an absolute path the result is&#xA;    unpredictable.  On MS-Windows an 8.3 filename is expanded to&#xA;    the long name.&#xA;&#xA;:~  Reduce file name to be relative to the home directory, if&#xA;    possible.  File name is unmodified if it is not below the home&#xA;    directory.&#xA;&#xA;:t  Tail of the file name (last component of the name).  Must&#xA;    precede any :r or :e.&#xA;&#xA;:s?pat?sub?&#xA;    Substitute the first occurrence of &quot;pat&quot; with &quot;sub&quot;.  This&#xA;    works like the |:s| command.  &quot;pat&quot; is a regular expression.&#xA;    Any character can be used for '?', but it must not occur in&#xA;    &quot;pat&quot; or &quot;sub&quot;.&#xA;    After this, the previous modifiers can be used again.  For&#xA;    example &quot;:p&quot;, to make a full path after the substitution.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="135" LastActivityDate="2018-05-11T12:53:48.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16220" PostTypeId="2" ParentId="444" CreationDate="2018-05-11T13:19:18.707" Score="6" Body="&lt;p&gt;Nice plugin to improve &lt;code&gt;autoread&lt;/code&gt;&#xA;&lt;a href=&quot;https://github.com/djoshea/vim-autoread&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/djoshea/vim-autoread&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Automatically causes vim to reload files which have been written on&#xA;  disk but not modified in the buffer since the last write from vim.&#xA;  This enables a file open in vim to be edited using another application&#xA;  and saved. Upon returning to vim, as long as you haven't modified the&#xA;  file since the last change, the file will be automatically updated to&#xA;  reflect the changes made on disk, as though you had pressed :e&#xA;  manually.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="17497" LastEditorUserId="17497" LastEditDate="2018-05-12T21:19:02.687" LastActivityDate="2018-05-12T21:19:02.687" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16221" PostTypeId="1" CreationDate="2018-05-11T17:41:45.757" Score="2" ViewCount="95" Body="&lt;p&gt;Is it possible to highlight specific and arbitrary rectangles in a buffer? I want to implement a code scope highlight that groups code into a hierarchy of boxes. here is my mockup that I made: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wvgmC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wvgmC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;assuming that the coordinates of the boxes are computed for the buffer contents using a standalone script (to liberate it from any dependency on the syntax system and language semantics), I wonder how practical it could be to render the background colors inside vim to an arbitrary degree (many areas going beyond the end of lines need to be painted). &lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-05-11T17:41:45.757" Title="Highlight arbitrary rectangular regions" Tags="|syntax-highlighting|colorscheme|color|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16222" PostTypeId="1" CreationDate="2018-05-11T18:03:58.680" Score="1" ViewCount="61" Body="&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;after playing around with my vimrc file I discovered this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this won't work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd c:\myUsualFolder&#xA;set encoding=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this will:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=utf-8&#xA;cd c:\myUsualFolder&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If I launch Vim from powershell/cmd from different folder than &quot;myUsualFolder&quot; with a file (e.g &lt;code&gt;gvim myfile.txt&lt;/code&gt;) it will open a empty buffer located in &quot;myUsualFolder&quot; (or if the file exist ther the wrong one). I tracked it down to the first line of my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd c:\myUsualFolder&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this line is removed everything works fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone has an idea how to keep the change directory part while opening the right file as well? &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;About my system: windows 10; vim version 8.0.586&lt;/p&gt;&#xA;" OwnerUserId="17501" LastEditorUserId="17501" LastEditDate="2018-05-11T19:31:49.460" LastActivityDate="2018-05-11T20:58:34.187" Title="Launching Vim with a file as argument does not work, if my .vimrc contains a `:cd` command" Tags="|vimrc|invocation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16223" PostTypeId="2" ParentId="16222" CreationDate="2018-05-11T20:58:34.187" Score="3" Body="&lt;p&gt;If you want Vim to always start in a certain directory, then you should likely do that after it has finished handling normal startup.  You can do that with the &lt;code&gt;VimEnter&lt;/code&gt; autocommand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace &lt;code&gt;cd C:\myUsualFolder&lt;/code&gt; with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc&#xA;    autocmd!&#xA;    autocmd VimEnter * cd C:\myUsualFolder&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;augroup&lt;/code&gt; and &lt;code&gt;autocmd!&lt;/code&gt; ensure you're not creating duplicate autocmds if you re-source your vimrc while you're running Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.appspot.com/autocmd.txt.html#autocmd-define&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help autocmd-define&lt;/code&gt;&lt;/a&gt; gives more details on the behavior of autocmds.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2018-05-11T20:58:34.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16224" PostTypeId="1" CreationDate="2018-05-12T01:37:38.107" Score="0" ViewCount="58" Body="&lt;p&gt;windows 10/ gvim 1-1802.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Javascript and there are sometimes blocks of HTML code that need to be inside a particular region that can be indicated by &lt;code&gt;&quot;&quot;&quot;&lt;/code&gt;, for example .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a similar situation with Python files. I need to enable syntax highlighting for some block of text containing code from another programming language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am searching for how to to enable a new &lt;code&gt;syntax&lt;/code&gt; file from inside of a file that already uses a &lt;code&gt;syntax&lt;/code&gt; file.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="17549" LastEditDate="2018-05-23T08:57:28.040" LastActivityDate="2018-05-23T08:57:28.040" Title="Highlight block of injected code" Tags="|vimrc|syntax-highlighting|gvim|vim-windows|" AnswerCount="0" CommentCount="2" ClosedDate="2018-05-23T14:27:28.993" ContentLicense="CC BY-SA 4.0" />
  <row Id="16225" PostTypeId="1" CreationDate="2018-05-12T06:04:26.940" Score="1" ViewCount="95" Body="&lt;p&gt;Suppose I have &lt;code&gt;\frac{stuff}{matter}&lt;/code&gt; somewhere in a file I am editing. And I want to change &lt;code&gt;stuff&lt;/code&gt; and &lt;code&gt;matter&lt;/code&gt;. So at the trigger of a command, I'd like to see the following take place:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;stuff&lt;/code&gt; gets highlighted in red (say) and &lt;code&gt;matter&lt;/code&gt; gets highlighted in blue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will help me keep track of whether I am editing away at &lt;code&gt;stuff&lt;/code&gt; or &lt;code&gt;matter&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, of course, I'd like to trigger a command which disables the highlights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make this happen? &lt;/p&gt;&#xA;" OwnerUserId="2369" LastEditorUserId="2369" LastEditDate="2018-05-12T08:40:40.363" LastActivityDate="2018-05-12T08:40:40.363" Title="Color Stuff Inside Braces in a Desired Way With a Trigger" Tags="|syntax-highlighting|regular-expression|highlight|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16226" PostTypeId="2" ParentId="8887" CreationDate="2018-05-12T07:14:52.973" Score="0" Body="&lt;p&gt;The solution is &lt;a href=&quot;https://github.com/vim/vim/commit/06d2d38ab7564e1f784b1058&quot; rel=&quot;nofollow noreferrer&quot;&gt;that&lt;/a&gt; provided by @ChristianBrabandt.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastActivityDate="2018-05-12T07:14:52.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16227" PostTypeId="2" ParentId="16225" CreationDate="2018-05-12T08:27:36.477" Score="2" Body="&lt;p&gt;You're basically talking about syntax highlighting, a relatively deep topic. In simplest terms, you define syntax matches through patterns and link those matches to highlight groups which define text color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just about everything you need to know is in &lt;code&gt;:h syntax&lt;/code&gt;. You might want to start with a gentler introduction, though. This is one (though perhaps not ideal...I just have it handy): &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/45.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Basic Syntax Highlighting&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll admit that I'm not that well versed in this stuff (I keep meaning to spend the time needed to learn it!) And, unfortunately, yours is not a trivial case because you have different highlighting on the same line. That being said here's my crack at it...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region rFrac start=&quot;\frac&quot; end=&quot;$&quot; contains=rStuff,rMatter keepend&#xA;syntax region rStuff start=&quot;{stuff&quot; end=&quot;}&quot; contains=rMatter contained keepend&#xA;syntax region rMatter start=&quot;{matter&quot; end=&quot;}&quot; contained&#xA;&quot; arbitrarily chosen highlight groups...Error is usually red. :)&#xA;highlight link rStuff Error&#xA;highlight link rMatter Keyword&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: I am taking your example literally. If you actually meant &quot;stuff&quot; to be a substitute for arbitrary text then modify the pattern(s) (i.e. the start value) to fit whatever you have in mind.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just run these through the command line to test it out. Works for me...mostly. :) It's possible there may be &quot;false positives&quot;...that is, coloring text that should not be colored. (But don't worry...if there's a superior solution someone will post it soon.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now once you get this working we can get into some commands to quickly turn it on or off. That's not a problem.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-05-12T08:33:27.360" LastActivityDate="2018-05-12T08:33:27.360" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="16230" PostTypeId="1" CreationDate="2018-05-12T19:18:28.883" Score="1" ViewCount="294" Body="&lt;p&gt;I like Vim’s &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/digraph.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;digraph feature&lt;/a&gt; but I find the number of default digraphs overwhelming. Is there a way to clear all of these so that the only digraph definitions are the ones that I created myself (e.g. in my vimrc)?&lt;/p&gt;&#xA;" OwnerUserId="671" LastActivityDate="2024-02-23T17:09:01.193" Title="How can I remove the default digraphs?" Tags="|digraphs|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16232" PostTypeId="1" CreationDate="2018-05-13T13:30:30.793" Score="6" ViewCount="458" Body="&lt;p&gt;I am trying to write tests using &lt;a href=&quot;https://github.com/junegunn/vader.vim&quot; rel=&quot;noreferrer&quot;&gt;Vader plugin&lt;/a&gt; but unfortunately, every time I try to invoke a &lt;code&gt;command&lt;/code&gt;/&lt;code&gt;function&lt;/code&gt; in &lt;code&gt;Execute&lt;/code&gt;/&lt;code&gt;Do&lt;/code&gt; block it doesn't see seems to work on the text provided in &lt;strong&gt;Given&lt;/strong&gt; block!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# contents of myplugin.vim&#xA;&#xA;function! WrapLastWord(delimiter)&#xA;  execute &quot;normal! Bi&quot; . a:delimiter . &quot;\&amp;lt;ESC&amp;gt;ea&quot; . a:delimiter&#xA;endfunction&#xA;&#xA;command! -nargs=0 -buffer Bold :call WrapLastWord('*')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Contents of &lt;code&gt;.vader&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Given ('Sample sentence'):&#xA;  This is a sample&#xA;&#xA;Do ('bold'):&#xA;  A sentence\&amp;lt;ESC&amp;gt;&#xA;  :source ../myplugin.vim\&amp;lt;cr&amp;gt;&#xA;  :Bold\&amp;lt;CR&amp;gt;&#xA;&#xA;Expect ('Asterisk wrapping around last word'):&#xA;  This is a sample *sentence*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried some alternatives like below but none of them seems to be making any change on text provided in &lt;strong&gt;Given&lt;/strong&gt; block?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Execute:&#xA;  Bold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And Vader raises failures like below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  - Expected:&#xA;      This is a sample *sentence*&#xA;  - Got:&#xA;      This is a sample sentence&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I write the function's instructions in Vader &lt;strong&gt;Do&lt;/strong&gt; block (normal mode &lt;code&gt;Bi*\&amp;lt;esc&amp;gt;ea*&lt;/code&gt;) it works as expected and tests passes.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Why am I not able to run the same instructions when called from a function/ command written in another file? What am I doing wrong?&lt;/li&gt;&#xA;&lt;li&gt;How do I double check and make sure if Vader is able to source the file and function properly?&lt;/li&gt;&#xA;&lt;li&gt;Is there a better solution to testing vim plugins/scripts?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS:&lt;/strong&gt; Any additional help/resource/link to content on automated testing vim plugins would be highly appretiated&lt;/p&gt;&#xA;" OwnerUserId="17317" LastEditorUserId="17317" LastEditDate="2018-05-13T13:53:54.770" LastActivityDate="2018-05-13T13:53:54.770" Title="How do I call functions and commands from .vim files in Vader tests?" Tags="|vimscript|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16235" PostTypeId="1" CreationDate="2018-05-13T15:57:08.677" Score="0" ViewCount="41" Body="&lt;p&gt;I usually want to share my clipboard between vim and other applications (like a web browser) so that I can yank/paste the information easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So questions,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How do I set the default behavior of vim to &lt;strong&gt;always&lt;/strong&gt; use &lt;strong&gt;only&lt;/strong&gt; the system &lt;code&gt;X11 cut-buffer&lt;/code&gt; and &lt;strong&gt;never&lt;/strong&gt; use the selection buffer? means settig default &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;p&lt;/code&gt; keys to directly utilize &lt;code&gt;&quot;+&lt;/code&gt; register.&lt;/li&gt;&#xA;&lt;li&gt;Would it have any side-effects if I am totally deserting the use of &lt;code&gt;&quot;*&lt;/code&gt; register? Are there any significant use of &lt;code&gt;&quot;*&lt;/code&gt; register?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="17317" LastActivityDate="2018-05-13T15:57:08.677" Title="How to set system cut-buffer clipboard as default in vim?" Tags="|buffers|register|os-clipboard|" AnswerCount="0" CommentCount="2" ClosedDate="2018-05-17T09:58:16.117" ContentLicense="CC BY-SA 4.0" />
  <row Id="16238" PostTypeId="2" ParentId="10766" CreationDate="2018-05-14T05:46:04.660" Score="0" Body="&lt;p&gt;I solved this problem with adding &lt;code&gt;sleep&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function FzfRunning()&#xA;  let buffers = filter(range(1, bufnr('$')), 'bufname(v:val) =~# &quot;;#FZF&quot;')&#xA;  for i in buffers&#xA;    &quot; Delete buffer by ID&#xA;    execute 'bw! ' . i&#xA;  endfor&#xA;  &quot; we need to sleep here so fzf will be focused properly&#xA;  sleep 10m&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7820" LastActivityDate="2018-05-14T05:46:04.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16239" PostTypeId="1" CreationDate="2018-05-14T10:55:58.410" Score="1" ViewCount="379" Body="&lt;p&gt;I'm trying vimtex. Probably I haven't read the docs well enough, but in my system (linux ubuntu 14.04.4 LTS, gvim 7.4) the quickfix list is populated with every single line of the log file when compiling with &lt;code&gt;latexmk&lt;/code&gt;, from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex 2018.1.28)  14 MAY 2018 11:38&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;19 words of extra memory for PDF output out of 10000 (max. 10000000)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do we configure the parsing of the log file so that only errors and warnings are included in the quickfix list?&lt;/p&gt;&#xA;" OwnerUserId="17525" LastEditorUserId="1841" LastEditDate="2018-05-14T12:15:32.660" LastActivityDate="2018-05-17T13:17:19.097" Title="Quickfix list displays each line of log file" Tags="|quickfix|plugin-vimtex|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16240" PostTypeId="2" ParentId="6483" CreationDate="2018-05-14T22:50:29.620" Score="2" Body="&lt;p&gt;You cannot natively make &lt;code&gt;%&lt;/code&gt; a pagraph delimiter, as paragraph macros are nroff macros (a dot, two characters: &lt;code&gt;.xx&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can add &lt;code&gt;.%%&lt;/code&gt; (or any other combination you want) as a paragraph delimiter by adding it do the &lt;code&gt;paragraphs&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set paragraphs=IPLPPPQPP\ TPHPLIPpLpItpplpipbp%%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See: &lt;code&gt;:help paragraph&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A paragraph begins after each empty line, and also at each of a set of&#xA;paragraph macros, specified by the pairs of characters in the 'paragraphs'&#xA;option.  The default is &quot;IPLPPPQPP TPHPLIPpLpItpplpipbp&quot;, which corresponds to&#xA;the macros &quot;.IP&quot;, &quot;.LP&quot;, etc.  (These are nroff macros, so the dot must be in&#xA;the first column).  A section boundary is also a paragraph boundary.&#xA;Note that a blank line (only containing white space) is NOT a paragraph&#xA;boundary.&#xA;Also note that this does not include a '{' or '}' in the first column.  When&#xA;the '{' flag is in 'cpoptions' then '{' in the first column is used as a&#xA;paragraph boundary posix.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9182" LastActivityDate="2018-05-14T22:50:29.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16241" PostTypeId="1" CreationDate="2018-05-15T04:18:05.280" Score="3" ViewCount="251" Body="&lt;p&gt;In my system, &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; works really slowly compared to &lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt;. Is it just my experience or is there a subtle reason behind it?&lt;/p&gt;&#xA;&lt;p&gt;Is this in any way related to &lt;code&gt;ttimeoutlen&lt;/code&gt;? I saw &lt;code&gt;ttimeoutlen&lt;/code&gt; mentionned in a &lt;a href=&quot;https://vi.stackexchange.com/q/12779/17250&quot;&gt;question&lt;/a&gt; about slow (user defined) key bindings but I am not sure it is the same problem.&lt;/p&gt;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="17250" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-05-15T09:00:14.210" Title="^O (Ctrl+O) works slowly" Tags="|key-bindings|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="16242" PostTypeId="1" CreationDate="2018-05-15T18:50:50.143" Score="1" ViewCount="65" Body="&lt;p&gt;In the Vim terminal I want to be able to search history in bash and ipython but C-r is already bound to basic Vim functionality. Is there any general way to pass this and other characters to the terminal window?&lt;/p&gt;&#xA;" OwnerUserId="17540" LastActivityDate="2018-05-15T18:50:50.143" Title="How to pass C-r to Vim terminal window?" Tags="|vim-windows|terminal|" AnswerCount="0" CommentCount="3" ClosedDate="2018-05-16T08:00:13.893" ContentLicense="CC BY-SA 4.0" />
  <row Id="16243" PostTypeId="1" CreationDate="2018-05-15T21:04:32.720" Score="5" ViewCount="109" Body="&lt;p&gt;Ale does not always indicate an error when compilation fails. AFAICT, the reason is that ALE's parser can't find a reference to the current file in the compiler's error messages. This is because either the current file is not mentioned in compiler output, or, it is mentioned but not in a way the Ale parser recognizes. In such instances I can see that compilation failed by looking at &lt;code&gt;:ALEInfo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is not about how to get an error marker at the correct line. Instead, I would like to know the fastest and simplest way to get Ale to indicate that some error occurred (i.e. it doesn't know what line in the current file to associate the error with).&lt;/p&gt;&#xA;" OwnerUserId="17541" LastActivityDate="2018-05-15T21:04:32.720" Title="Can vim-ale emit an error when it fails to parse compiler output?" Tags="|filetype-c++|plugin-ale|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16246" PostTypeId="1" CreationDate="2018-05-16T17:03:34.777" Score="3" ViewCount="990" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xAQ0T.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xAQ0T.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently using tmux to have two terminals on the left and vim on the right. One terminal is running Django server, and the other one is for general usage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to find out if I can ditch tmux and use vim/neovim sessions as a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way for a vim session to automatically change to a specific directory, enable a virtualenv and start the server as I am currently doing with tmux?&lt;/p&gt;&#xA;" OwnerUserId="17538" LastActivityDate="2018-11-13T18:02:35.463" Title="Vim Session keeping terminal state" Tags="|terminal|tmux|sessions|terminal-buffer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16247" PostTypeId="2" ParentId="15739" CreationDate="2018-05-16T23:41:10.630" Score="2" Body="&lt;p&gt;I answered a similar question &lt;a href=&quot;https://superuser.com/a/1323375/347397&quot;&gt;here&lt;/a&gt;. The problem is that zsh (and other shells) only runs &lt;code&gt;~/.zshrc&lt;/code&gt; for interactive shells and &lt;code&gt;~/.zprofile&lt;/code&gt; for &quot;login&quot; shells.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To force running commands as a login shell, add the &lt;code&gt;-l&lt;/code&gt; flag to either the &lt;code&gt;shell&lt;/code&gt; option, or the &lt;code&gt;shellcmdflag&lt;/code&gt; option. That is (in your &lt;code&gt;~/.gvimrc&lt;/code&gt;),&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shell=/bin/zsh\ -l&#xA;&quot; or&#xA;set shellcmdflag=-l\ -c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to escape the spaces because of how the &lt;code&gt;set&lt;/code&gt; command works. Putting it in your &lt;code&gt;~/.gvimrc&lt;/code&gt; will prevent &lt;code&gt;$PATH&lt;/code&gt; from growing when running it from the terminal.&lt;/p&gt;&#xA;" OwnerUserId="17551" LastActivityDate="2018-05-16T23:41:10.630" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16248" PostTypeId="1" AcceptedAnswerId="22426" CreationDate="2018-05-17T11:42:59.937" Score="7" ViewCount="837" Body="&lt;p&gt;Is there a robust way to detect whether a window has a neighbour in a given direction? So far, the only solution I found uses &lt;code&gt;wincmd&lt;/code&gt;, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  let winnum = winnr()&#xA;  noautocmd wincmd h&#xA;  if winnum != winnr()&#xA;    noautocmd wincmd l&#xA;    return 0&#xA;  else &#xA;    return 1&#xA;  endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but is it robust? Ideally, I would like to find a way that does not use &lt;code&gt;wincmd&lt;/code&gt;; perhaps something similar to the following &lt;code&gt;tmux&lt;/code&gt; command: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tmux display-message -p #{pane_at_left}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11125" LastActivityDate="2020-01-04T03:54:10.887" Title="Detect if window has neighbour in given direction" Tags="|vim-windows|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16249" PostTypeId="2" ParentId="16248" CreationDate="2018-05-17T12:44:33.843" Score="5" Body="&lt;p&gt;You can do this by looking at the window positions.  Take &quot;right&quot; as an example. &#xA; If &lt;em&gt;any&lt;/em&gt; window has a left column position greater than the current window's rightmost column, then the current window has some right neighbor.  Think about this for a few minutes.  Of course, you would need to write similar functions for the other cardinal directions.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HasWinToRight()&#xA;    let l:rightedge = win_screenpos(0)[1] + winwidth(0) - 1&#xA;    for l:win in range(1, winnr('$'))&#xA;        if l:win != winnr() &amp;amp;&amp;amp; win_screenpos(l:win)[1] &amp;gt; l:rightedge&#xA;            return 1&#xA;        endif&#xA;    endfor&#xA;    return 0&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This solution is much more robust than any that switches windows, since window switching has unpredictable side-effects, even with &lt;code&gt;noautocmd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will not tell you &lt;em&gt;which&lt;/em&gt; window is to the immediate right, as defined by &lt;code&gt;wincmd l&lt;/code&gt;.  In general this would also depend on the cursor position and row positions of the other windows.  That is, a window may have many right neighbors but &lt;code&gt;wincmd l&lt;/code&gt; picks one.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-05-17T12:50:09.283" LastActivityDate="2018-05-17T12:50:09.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16250" PostTypeId="2" ParentId="16248" CreationDate="2018-05-17T13:06:12.420" Score="3" Body="&lt;p&gt;I am a little late after @Mass but I tried to do a more generic function which takes the direction to test as argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Values of the argument&#xA;&quot;   1 : Top&#xA;&quot;   2 : Right&#xA;&quot;   3 : Bottom&#xA;&quot;   4 : Left&#xA;function! HasNeighbour(direction)&#xA;    &quot; Position of the current window&#xA;    let currentPosition = win_screenpos(winnr())&#xA;&#xA;    if a:direction == 1&#xA;        &quot; if we are looking for a top neigbour simply test if we are on the first line&#xA;        return currentPosition[0] != 1&#xA;    elseif a:direction == 4&#xA;        &quot; if we are looking for a left neigbour simply test if we are on the first column&#xA;        return currentPosition[1] != 1&#xA;    endif&#xA;&#xA;    &quot; Number of windows on the screen&#xA;    let winNr = winnr('$')&#xA;&#xA;    while winNr &amp;gt; 0&#xA;        &quot; Get the position of each window&#xA;        let position = win_screenpos(winNr)&#xA;        let winNr = winNr - 1&#xA;&#xA;        &quot; Test for window on the right&#xA;        if ( a:direction == 2 &amp;amp;&amp;amp; ( currentPosition[1] + winwidth(0) ) &amp;lt; position[1] )&#xA;            return 1&#xA;        &quot; Test for windo on the bottom&#xA;        elseif ( a:direction == 3 &amp;amp;&amp;amp; ( currentPosition[0] + winheight(0) ) &amp;lt; position[0] )&#xA;            return 1&#xA;        endif&#xA;    endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way if you want to know if the current window has a right neighbour you can use &lt;code&gt;HasNeighbour(2)&lt;/code&gt;, to test for neighbour on the left &lt;code&gt;HasNeighbour(4)&lt;/code&gt; will do, etc...&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-05-17T14:37:34.107" LastActivityDate="2018-05-17T14:37:34.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16251" PostTypeId="2" ParentId="613" CreationDate="2018-05-17T13:36:50.337" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/genotrance/vire&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vire&lt;/a&gt; leverages the latest pack format to install plugins and supports Vim and Neovim. You don't need to know where anything goes. Just provide a vimrc and Vire will take care of the rest.&lt;/p&gt;&#xA;" OwnerUserId="17556" LastActivityDate="2018-05-17T13:36:50.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16252" PostTypeId="2" ParentId="16246" CreationDate="2018-05-17T14:15:19.970" Score="1" Body="&lt;p&gt;According to &lt;code&gt;:h terminal-session&lt;/code&gt; it will relaunch a terminal buffer with a session by running the command which was supplied to &lt;code&gt;:terminal&lt;/code&gt; to start with or you can modify it via &lt;code&gt;term_setrestore()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a way for a vim session to automatically change to a specific directory, enable a virtualenv and start the server as I am currently doing with tmux?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I do not use &lt;code&gt;:terminal&lt;/code&gt; or such a setup as you do, but I would hazard a guess that you could create a shell/python script which would change your current directory, enable virtualenv, and start your server. Combine it with a custom Vim command to execute it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! StartServer execute &quot;terminal start-server.sh &quot; . resolve(expand('%:h'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In theory doing something like this would allow it restore. That being said if you now have a nice command to start your server, you may not care as much if it restores as you can easily access it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h terminal&#xA;:h term_setrestore&#xA;:h :execute&#xA;:h resolve()&#xA;:h expand()&#xA;:h :terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-05-17T14:15:19.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16253" PostTypeId="1" AcceptedAnswerId="16284" CreationDate="2018-05-17T14:33:58.350" Score="7" ViewCount="410" Body="&lt;p&gt;If I type &lt;code&gt;:e foo/**/foo*.js&lt;/code&gt; and hit tab then vim replaces the *s with all possible suggestions in the filepath. What if I realized that I wasn't specific enough (there are too many results in autocomplete) and I want to go back from the autocomplete suggestions to &lt;code&gt;:e foo/**/foo*.js&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My wildmenu settings are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmenu&#xA;set wildmode=longest:full,full,full&#xA;set nowildignorecase&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a key that would let me get back to what I had before hitting tab?&lt;/p&gt;&#xA;" OwnerUserId="16698" LastEditorUserId="16280" LastEditDate="2018-05-21T11:20:10.023" LastActivityDate="2018-05-22T05:08:42.557" Title="Return from command autocomplete" Tags="|autocompletion|wildmenu|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16255" PostTypeId="1" AcceptedAnswerId="16269" CreationDate="2018-05-17T18:34:47.917" Score="1" ViewCount="1228" Body="&lt;p&gt;Whenever there are some git merge conflicts we would type &lt;code&gt;git mergetool&lt;/code&gt; and git would automatically launch a merge tool for us to merge the conflicts. I have been using vimdiff for a long time as my mergetool, but found it actually not efficient at all as using three-way merging won't provide more information but would occupy the precious screen space. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I am really interested in using pure vim (not in diff mode) as my git mergetool. But I can't configure it directly since git only accepts certain difftools as git mergetool(&lt;code&gt;opendiff kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse diffmerge ecmerge p4merge araxis bc codecompare emerge vimdiff&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I am wondering if there is way that I can configure pure vim as my tool to solve conflicts? Note using vim to open and edit the conflicted files directly is not desired here since you would lose a lot of conveniences provided by calling &lt;code&gt;git mergetool&lt;/code&gt;, including automatic file opening and automatic git staging.&lt;/p&gt;&#xA;" OwnerUserId="16146" LastActivityDate="2018-06-19T18:37:18.423" Title="How to use pure Vim as git mergetool?" Tags="|vimdiff|git|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="16256" PostTypeId="2" ParentId="388" CreationDate="2018-05-17T20:51:48.900" Score="7" Body="&lt;p&gt;Most of these plugin managers do a great job of managing plugins but leave the headache of managing the &lt;code&gt;vimrc&lt;/code&gt; to you. If you have multiple machines and want the same config across, &lt;a href=&quot;https://github.com/genotrance/vire&quot; rel=&quot;noreferrer&quot;&gt;Vire&lt;/a&gt; makes it super easy. You don't need git or figure out submodules or any extra effort to get setup or migrate.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Install Python, which is what most modern Vim plugins are written in and required anyway&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;pip install vire&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Post your existing &lt;code&gt;vimrc&lt;/code&gt; onto Github as a gist and maintain it there&lt;/li&gt;&#xA;&lt;li&gt;If on Windows, &lt;code&gt;vire -i&lt;/code&gt; to install the latest Vim or (Neovim with &lt;code&gt;-i -n&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Remove any existing plugin function calls and define commented out calls to install any plugins&#xA;&lt;code&gt;&quot; Plug 'tpope/vim-unimpaired'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vire gistID&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then run &lt;code&gt;vire&lt;/code&gt; anytime you want your &lt;code&gt;vimrc&lt;/code&gt; or plugins to be updated or with &lt;code&gt;-i&lt;/code&gt; to update the app as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vire leverages Vim / Neovim's &lt;code&gt;pack&lt;/code&gt; feature to load plugins. You can also continue to use your existing plugin manager but use Vire to only install Vim, the &lt;code&gt;vimrc&lt;/code&gt;, and the plugin manager itself if preferred.&lt;/p&gt;&#xA;" OwnerUserId="17556" LastActivityDate="2018-05-17T20:51:48.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16257" PostTypeId="2" ParentId="9522" CreationDate="2018-05-18T01:55:36.943" Score="2" Body="&lt;p&gt;The new format can be thought of as a Pathogen equivalent so there's still space for a manager that can download the plugins you want. There's a few new plugin managers who leverage this new pack format but I still made &lt;a href=&quot;https://github.com/genotrance/vire&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vire&lt;/a&gt; since they leave the headache of managing the &lt;code&gt;vimrc&lt;/code&gt; to you. If you have multiple machines and want the same config across, Vire makes it super easy.&lt;/p&gt;&#xA;" OwnerUserId="17556" LastActivityDate="2018-05-18T01:55:36.943" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16258" PostTypeId="1" AcceptedAnswerId="16263" CreationDate="2018-05-18T06:07:36.873" Score="1" ViewCount="224" Body="&lt;p&gt;If I type &lt;code&gt;:h gui-colors&lt;/code&gt;, a list of available color names pops up. Often times I just want to change the tone of a color. Assuming these are simple variables of some sort, can I redefine these somehow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: &lt;code&gt;let &amp;amp;red=&amp;amp;green&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-27T03:59:43.960" LastActivityDate="2019-02-27T03:59:43.960" Title="Change the colors provided in gui-colors" Tags="|color|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16259" PostTypeId="2" ParentId="16253" CreationDate="2018-05-18T08:31:29.863" Score="4" Body="&lt;p&gt;I don't think so, but perhaps using list as wildmode would suit you more. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set wildmode=list,full&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See more in &lt;a href=&quot;https://vi.stackexchange.com/questions/11411/is-there-a-version-of-vim-or-plugin-with-a-command-mode-auto-completion&quot;&gt;Is there a version of Vim or plugin with a Command Mode auto completion?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also help for more details and examples&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 'wildmode'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15660" LastActivityDate="2018-05-18T08:31:29.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16260" PostTypeId="1" AcceptedAnswerId="16285" CreationDate="2018-05-18T09:19:42.457" Score="0" ViewCount="437" Body="&lt;p&gt;so whenever I open a file be it from using FZF, NERDTree or directly using edit, IF I happen to be in the NERDTree buffer it will open the file in the buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I make it so that whenever a file is open (no matter how) it will open in the first non NERDTree buffer/window so that NERDTree remains open no matter what?&lt;/p&gt;&#xA;" OwnerUserId="11603" LastActivityDate="2019-11-21T02:05:32.707" Title="How to make the edit command open the file in the first non NERDTree buffer window" Tags="|neovim|buffers|plugin-nerdtree|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16262" PostTypeId="2" ParentId="16253" CreationDate="2018-05-18T09:58:34.807" Score="1" Body="&lt;p&gt;I just stumbled across this myself and &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/gL5DXac4NaU/sYTDeWctAwAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;argued&lt;/a&gt; to change the (in my opinion) wrong default for the 'wildmode' setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyhow, while discussing this, I was told, that &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt; can be pressed to let you return to from where you completed. This allows to go back and change what will be completed. An alternative would be to hit &lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;Tab&lt;/kbd&gt;, however that might not work in the terminal.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="205" LastEditDate="2018-05-22T05:08:42.557" LastActivityDate="2018-05-22T05:08:42.557" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="16263" PostTypeId="2" ParentId="16258" CreationDate="2018-05-18T11:53:03.860" Score="2" Body="&lt;p&gt;That is not easily possible. I think those colors mentioned there are predefined in the &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/term.c#L6836-L6867&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most other colors will be read from the distributed file &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/rgb.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;RGB.txt&lt;/a&gt; in the runtime directory. This file come originally from the X11 source and determines the color definitions for various names. (See also &lt;a href=&quot;https://en.wikipedia.org/wiki/X11_color_names&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not advisable, to change those definitions in the source because this will most likely cause confusion when working on a different system. Instead, define your own color names like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi MyGreen ctermfg=88 ctermbg=0 guifg=red guibg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then use the colorname &lt;code&gt;MyGreen&lt;/code&gt; consistently where you need it.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-05-18T11:53:03.860" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16265" PostTypeId="1" AcceptedAnswerId="19719" CreationDate="2018-05-18T19:10:37.687" Score="2" ViewCount="3217" Body="&lt;p&gt;Is there a way to temporarily disable/reenable the YouCompleteMe Plugin for vim? Syntastic has a nice way of doing so with the SyntasticToggleMode command (useful for when I know I'm writing code that won't compile and just don't want to see error messages at the moment).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried writing a quick Vim function that toggles the &lt;code&gt;g:ycm_show_diagnostics_ui&lt;/code&gt; variable but it doesn't seem to work as I'd like even though the value of the variable changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: this works statically (i.e. if I set the &lt;code&gt;g:ycm_show_diagnostics_ui&lt;/code&gt; variable to zero in my vimrc but doesn't work dynamically).&lt;/p&gt;&#xA;" OwnerUserId="13078" LastActivityDate="2022-03-17T20:11:58.113" Title="Temporarily Disable/Reenable YouCompleteMe Plugin" Tags="|plugin-you-complete-me|plugin-syntastic|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16269" PostTypeId="2" ParentId="16255" CreationDate="2018-05-20T17:35:08.583" Score="2" Body="&lt;p&gt;I think something like this in your &lt;code&gt;~/.gitconfig&lt;/code&gt; file should do what your asking.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[merge] &#xA;    tool = myvimdiff&#xA;[mergetool &quot;myvimdiff&quot;]&#xA;    cmd = vim &quot;$MERGED&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are lots of other options for the mergetool besides &lt;code&gt;cmd&lt;/code&gt;, search for &lt;code&gt;merge.&amp;lt;tool&amp;gt;.&lt;/code&gt; in &lt;code&gt;man git-config&lt;/code&gt; (and obviously you can customise &lt;code&gt;cmd&lt;/code&gt; how you like it. When merging 4 files are available: &lt;code&gt;$LOCAL&lt;/code&gt;, &lt;code&gt;$BASE&lt;/code&gt;, &lt;code&gt;$REMOTE&lt;/code&gt;, and &lt;code&gt;$MERGED&lt;/code&gt; (again look at the documentation for that). You can see how git sets up the default tools &lt;a href=&quot;https://github.com/git/git/blob/master/mergetools/vimdiff&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; if you want more inspiration.&lt;/p&gt;&#xA;" OwnerUserId="16910" LastEditorUserId="16910" LastEditDate="2018-05-20T17:40:25.383" LastActivityDate="2018-05-20T17:40:25.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16270" PostTypeId="1" CreationDate="2018-05-20T18:37:19.417" Score="1" ViewCount="949" Body="&lt;p&gt;&lt;em&gt;I know there is a ton of plugins and topics that discussing about auto-completion things in Vim!&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just need the Vim's native auto-completion to be automated! &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;auto-suggestion words, etc from buffers' cache.&lt;/li&gt;&#xA;&lt;li&gt;auto-suggestion for path.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've found vim can show a auto-suggestion drop-down menu when I pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;f&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;n&lt;/kbd&gt; after a word or path. Is there any &lt;code&gt;autocmd&lt;/code&gt; or a block of code to add in &lt;code&gt;$VIMRC&lt;/code&gt;to automate this process?   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;If it's impossible or there is no such way, so please introduce a plug-in that can just automate this process (not adding any other features!)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="17593" LastActivityDate="2018-05-20T18:37:19.417" Title="How to automate Vim's native auto-completion with a drop-down menu?" Tags="|vimrc|autocompletion|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16272" PostTypeId="1" AcceptedAnswerId="16278" CreationDate="2018-05-20T23:55:08.257" Score="1" ViewCount="120" Body="&lt;p&gt;I made a user command called &lt;code&gt;Type&lt;/code&gt; and would like it to appear first in the list of available commands when I type &lt;code&gt;:t&lt;/code&gt; and then hit tab. Currently, the first command is &lt;code&gt;TOhtml&lt;/code&gt;, which I've never used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than renaming the user command to something like &lt;code&gt;TAype&lt;/code&gt;, is there a way to change the order of vim commands?&lt;/p&gt;&#xA;" OwnerUserId="13078" LastActivityDate="2019-08-27T19:54:09.227" Title="Command Ordering" Tags="|vimrc|vimscript|command-line|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16273" PostTypeId="2" ParentId="514" CreationDate="2018-05-21T02:28:01.060" Score="9" Body="&lt;h2&gt;&lt;a href=&quot;https://vim.wikia.com/wiki/Resize_splits_more_quickly&quot; rel=&quot;nofollow noreferrer&quot;&gt;Resize splits more quickly&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;You can use the &lt;code&gt;:resize&lt;/code&gt; command or its shortcut &lt;code&gt;:res&lt;/code&gt; to change the height of the window. To change the height to 60 rows, use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:resize 60&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can also change the height in increments. To change the height by increments of 5, use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:res +5&#xA;:res -5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can use &lt;code&gt;:vertical resize&lt;/code&gt; to change the width of the current window. To change the width to 80 columns, use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:vertical resize 80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can also change the width in increments. To change the width by increments of 5, use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:vertical resize +5&#xA;:vertical resize -5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17598" LastEditorUserId="10360" LastEditDate="2021-04-04T14:40:38.393" LastActivityDate="2021-04-04T14:40:38.393" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16274" PostTypeId="2" ParentId="14421" CreationDate="2018-05-21T04:43:07.663" Score="2" Body="&lt;p&gt;I made a plugin that does this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/fent/vim-relative-indent&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/fent/vim-relative-indent&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't use the conceal feature. It instead scrolls the window to the right accordingly.&lt;/p&gt;&#xA;" OwnerUserId="16592" LastActivityDate="2018-05-21T04:43:07.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16275" PostTypeId="2" ParentId="10031" CreationDate="2018-05-21T09:51:09.993" Score="3" Body="&lt;p&gt;I variated &lt;strong&gt;statox&lt;/strong&gt; approach so it scrolls more consistent over the linewraps.&#xA;If you want a quarter step, change 0.618 back to 0.25 or whatever.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ScrollGolden(move)&#xA;    let height=winheight(0)&#xA;    if a:move == 'up'&#xA;        let prep='L'&#xA;        &quot; let key=&quot;^Y&quot;&#xA;        let key='gk'&#xA;        let post='zb'&#xA;    elseif a:move == 'down'&#xA;        let prep='H'&#xA;        &quot; let key=&quot;^E&quot;&#xA;        let key='gj'&#xA;        let post='zt'&#xA;    endif&#xA;    execute 'normal! ' . prep . float2nr(round(height*0.618)) . key . post&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;BS&amp;gt;    :call ScrollGolden('up')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Space&amp;gt; :call ScrollGolden('down')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16270" LastEditorUserId="16270" LastEditDate="2018-05-21T12:37:05.863" LastActivityDate="2018-05-21T12:37:05.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16276" PostTypeId="1" AcceptedAnswerId="16277" CreationDate="2018-05-21T09:57:51.403" Score="15" ViewCount="3845" Body="&lt;p&gt;This is what I get from the documentation: &lt;code&gt;\zs&lt;/code&gt; &amp;quot;starts the highlighted part&amp;quot; after matching the preceding &lt;em&gt;regex&lt;/em&gt;, and &lt;code&gt;\@&amp;lt;=&lt;/code&gt; &amp;quot;starts the highlighted part&amp;quot; after matching the preceding &lt;em&gt;atom&lt;/em&gt;. But I don't exactly understand the subtleties of this, so can anyone explain how they differ a bit more in depth?&lt;/p&gt;&#xA;&lt;p&gt;This is what made me curious: If I run&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/\_s\zsnnoremap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;i.e. select &lt;code&gt;nnoremap&lt;/code&gt; preceded by a space or a start-of-line (i.e. the newline from the preceding line, hence the &lt;code&gt;\_&lt;/code&gt; preceding the &lt;code&gt;s&lt;/code&gt;) and then run &lt;code&gt;gn&lt;/code&gt; to enter Visual Mode and visually select the next match, for some reason &lt;em&gt;only&lt;/em&gt; the first column (i.e. the first &lt;code&gt;n&lt;/code&gt; in &lt;code&gt;nnoremap&lt;/code&gt;) is selected -- despite the fact that the entire &lt;code&gt;nnoremap&lt;/code&gt; word is highlighted with &lt;code&gt;:hlsearch&lt;/code&gt; turned on.&lt;/p&gt;&#xA;&lt;p&gt;However, if I instead run the search&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/\_s\@&amp;lt;=nnoremap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and then try &lt;code&gt;gn&lt;/code&gt;, the entire &lt;code&gt;nnoremap&lt;/code&gt; is properly selected. What could be going on here? Did I discover some obscure bug?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2021-06-03T09:12:35.843" LastActivityDate="2022-12-14T02:04:42.347" Title="What's the difference between the '\zs' and '\@&lt;=' atoms in Vim regex?" Tags="|vimrc|regular-expression|search|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16277" PostTypeId="2" ParentId="16276" CreationDate="2018-05-21T12:22:53.850" Score="18" Body="&lt;p&gt;This looks like you indeed found an obscure bug. I have implemented the &lt;code&gt;gn&lt;/code&gt; textobject back in 2012 for Vim 7.3 something. It basically works in the following way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) It searches backwards for the last match of the current regular expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) It searches forward for the next match of the current regular expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should make clear, that the cursor will be on start of the next match, even if it was there already at the start of 1). &lt;del&gt;Finally&lt;/del&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;del&gt;3) it searches for the end of the current regular expression. and puts the cursor there.&lt;/del&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now what happens here is that the search for the end of the current match wraps around and moves back to the end of the previous match (because &lt;code&gt;wrapscan&lt;/code&gt; is already set, after being disabled for 1)). It then sets the Visual marker to the area from start (end of point 2) and the area moved to by the next search item 3).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll have a closer look at the problem and will probably submit a patch for Vim later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[Update 22.05.2018]&lt;/strong&gt; I have written and submitted a &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/IbWNTwpbkGQ/lXQcd8zWBQAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;patch&lt;/a&gt; to fix this behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[Update2 22.05.2018]&lt;/strong&gt;&#xA;And the patch has been merged as patch level &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.0018&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.0018&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[Update 22.10.2019]&lt;/strong&gt;&#xA;As of Vim patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.0629&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.629&lt;/a&gt; the third step is not performed anymore. Instead Vim can now determine the end of the match when finding the beginning of the match (Step 2)&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-10-22T10:35:59.733" LastActivityDate="2019-10-22T10:35:59.733" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16278" PostTypeId="2" ParentId="16272" CreationDate="2018-05-21T12:32:29.907" Score="4" Body="&lt;p&gt;This is not possible. Completion will always show all matches in alphabetical order (well minus the &lt;code&gt;wildignore&lt;/code&gt; and 'suffixes' settings, but those only affect file matches and not commands).&#xA;So the only way to hide the &lt;code&gt;TOhtml&lt;/code&gt; command is to undefine it (&lt;a href=&quot;http://vimhelp.org/map.txt.html#%3Adelcommand&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :delcom&lt;/code&gt;&lt;/a&gt;) but I wouldn't recommend it, since &lt;code&gt;TOhtml&lt;/code&gt; is a useful command that allows you to generate a html snapshot from the current document (and works beautifully for e.g. sharing diffs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read about the &lt;code&gt;:TOhtml&lt;/code&gt; command at &lt;a href=&quot;https://vimhelp.org/syntax.txt.html#%3ATOhtml&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h TOhtml&lt;/code&gt;&lt;/a&gt;, which is a default plugin that comes distributed with Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it is best to either accept the current state or name your command differently that will sort before the &lt;code&gt;:TOhtml&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="18609" LastEditDate="2019-08-27T19:54:09.227" LastActivityDate="2019-08-27T19:54:09.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16279" PostTypeId="2" ParentId="16276" CreationDate="2018-05-21T12:41:22.703" Score="9" Body="&lt;p&gt;Christian has completely addressed the question of buggy behavior of &lt;code&gt;gn&lt;/code&gt;, but there still are fundamental differences between &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\@&amp;lt;=&lt;/code&gt;.  One of these being &lt;code&gt;\@&amp;lt;=&lt;/code&gt; modifies a preceding atom, while &lt;code&gt;\zs&lt;/code&gt; is an atom in itself.&lt;/p&gt;&#xA;&lt;p&gt;Consider:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Xnnoremap&#xA;&#xA;\%1cX\zsnnoremap     (regex 1)&#xA;\%1cX\@&amp;lt;=nnoremap    (regex 2)&#xA;\%2cX\@&amp;lt;=nnoremap    (regex 3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Regex 1 matches, since &lt;code&gt;\%1c&lt;/code&gt; matches in column 1 and there is an X there.  &lt;code&gt;\zs&lt;/code&gt; merely causes the primary capture to be restarted at a position after the X.&lt;/p&gt;&#xA;&lt;p&gt;Regex 2 however does not match, because although &lt;code&gt;\%1c&lt;/code&gt; matches in the first column, &lt;code&gt;X\@&amp;lt;=&lt;/code&gt; is zero width as mentioned in the documentation.&#xA;&lt;code&gt;nnoremap&lt;/code&gt; starts at column 2, not 1, and besides, as @user938271 points out is no possible position before column 1.&lt;/p&gt;&#xA;&lt;p&gt;Regex 3 matches since &lt;code&gt;nnoremap&lt;/code&gt; starts at column 2, and is preceded by an X.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2022-12-14T02:04:42.347" LastActivityDate="2022-12-14T02:04:42.347" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16280" PostTypeId="2" ParentId="16276" CreationDate="2018-05-21T14:26:35.457" Score="5" Body="&lt;p&gt;&lt;code&gt;\zs&lt;/code&gt; applies to the entire regular expression, and sets the next character to be the first character of the entire match. Anything before the &lt;code&gt;\zs&lt;/code&gt; will not be included as part of the matching text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\@&amp;lt;=&lt;/code&gt;, on the other hand, only affects the atoms directly around it, allowing you to specify that the next atom will only match if it follows the preceding atom. So for example, the regular expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\vbar.*(foo)@&amp;lt;=bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will match all the text between two instances of &lt;code&gt;bar&lt;/code&gt; (including the instances themselves), but only if the second is preceded by &lt;code&gt;foo&lt;/code&gt;. i.e., it will match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;barbazfoobar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but not:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;barbazbazbar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because &lt;code&gt;\@&amp;lt;=&lt;/code&gt; is localized in this way, you can even use &lt;code&gt;\@&amp;lt;=&lt;/code&gt; multiple times in a single expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\vbar.*(foo)@&amp;lt;=bar.*(foo)@&amp;lt;=bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following will match &lt;em&gt;three&lt;/em&gt; instances of &lt;code&gt;bar&lt;/code&gt;, but only if the second two are each preceded by &lt;code&gt;foo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e. given the text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;barfoobarbazfoobar&#xA;barfoobarbazbazbar&#xA;barbazbarbazfoobar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will match the first line only.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-05-22T08:46:00.057" LastActivityDate="2018-05-22T08:46:00.057" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16281" PostTypeId="1" AcceptedAnswerId="16282" CreationDate="2018-05-21T14:44:56.450" Score="0" ViewCount="271" Body="&lt;h2&gt;Background&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I work a lot in the twig template language, and make use of path variables. For example, an include might look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{% include &quot;@my_path_var/my_folder/my-template.twig&quot; %}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;@my_path_var&lt;/code&gt; is shorthand for a full filesystem path, e.g. &lt;code&gt;/Users/me/Sites/project/twig/patterns/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Desire&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I would like to be able to follow these paths using &lt;code&gt;gf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Is there a way to enable this behavior, using Vim's native &lt;code&gt;path&lt;/code&gt; variables, or some other Vim configuration? Or would this need to be a plugin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="14" LastEditorUserId="51" LastEditDate="2018-08-22T16:52:28.907" LastActivityDate="2018-08-22T16:52:28.907" Title="Expanding variables in path" Tags="|path|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16282" PostTypeId="2" ParentId="16281" CreationDate="2018-05-21T15:16:38.610" Score="1" Body="&lt;p&gt;&lt;code&gt;gf&lt;/code&gt; and &lt;code&gt;CTRL-W_F&lt;/code&gt; are able to search for path under directories listed in &lt;code&gt;&amp;amp;path&lt;/code&gt; variable. Alas, I suspect that &lt;code&gt;@my_path_var&lt;/code&gt; is some kind of variable related to your current twig (?) project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim can't understand it natively. It has no idea &lt;code&gt;@my_path_var&lt;/code&gt; means something, nor what it means (for what we know, it could have been &lt;code&gt;%var%&lt;/code&gt;, &lt;code&gt;{var}&lt;/code&gt;, &lt;code&gt;@@var@@&lt;/code&gt;...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you'll have to implement your own version of &lt;code&gt;gf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;parse the line under the cursor, either with &lt;code&gt;expand('&amp;lt;cfile&amp;gt;)'&lt;/code&gt;, or analyse the result of &lt;code&gt;expand('&amp;lt;cWORD&amp;gt;')&lt;/code&gt; if the first doesn't return something that can be exploited because of the &lt;code&gt;@&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;split the path obtained to extract the &lt;code&gt;@varname&lt;/code&gt; part, resolve it to build the finalpathname&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and eventually open if with &lt;code&gt;exe 'e '.finalpathname&lt;/code&gt; or anything more advanced that'll reuse windows already opened (I have such a function in lh-vim-lib)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @Peter suggested (I did completely forget about that), we don't need to define a new mapping. We just have to set the options &lt;code&gt;'includeexpr'&lt;/code&gt; -- and &lt;code&gt;'include'&lt;/code&gt; which is not mandatory to answer the need you've expressed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I'm the lazy kind of guy regarding option evaluation, I'd use a function from my &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;toolbox library&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; To be defined in a ~/.vim/ftplugin/twig.vim file&#xA;&#xA;&quot; First we specify how include lines are recognized&#xA;setlocal inc={\%\ include&#xA;&#xA;&quot; then, we specify how variables are evaluated&#xA;setlocal includeexpr=substitute(v:fname,'\\v\\@(\\k+)','\\=lh\#option\#get(submatch(1))','g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: this version, doesn't properly notifies when a pathname isn't found: the call to &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/Options.md#lhoptiongetname-default--scope&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;lh#option#get()&lt;/code&gt;&lt;/a&gt; should be encapsulated to throw something if &lt;code&gt;lh#option#is_unset(lh#option#get(......))&lt;/code&gt; evaluates to true.&#xA;A simplified version could be defined with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; to be defined in ~/.vim/autoload/my/twig.vim&#xA;function my#twig#get_var(name) abort &quot; untested!&#xA;    let scopes = filter([b:, g:, t:], 'has_key(v:val, a:name)')&#xA;    if empty(scopes)&#xA;        throw &quot;No variable named '&quot;.a:name. &quot;' known in b:, g:, nor t:&quot;&#xA;    endif&#xA;    return scopes[0][a:name]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For visual modes mappings, I can't find anything with &lt;code&gt;:h v_CTRL-W_f&lt;/code&gt;, yet it seems to work correctly. In case this is an artefact of my configuration, visual mode mappings could be defined with: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; edit the buffer in the current window, &#xA;&quot; or jump to the first window where the buffer is already displayed&#xA;xnoremap &amp;lt;silent&amp;gt; gf &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;:call lh#buffer#jump(&#xA;           \ substitute(lh#visual#selection(), '\v\@(\k+)', '\=lh#option#get(submatch(1))', 'g'), &#xA;           \ 'e')&amp;lt;cr&amp;gt;&#xA;&#xA;xnoremap &amp;lt;silent&amp;gt; &amp;lt;c-w&amp;gt;f &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;:call lh#buffer#jump(&#xA;           \ substitute(lh#visual#selection(), '\v\@(\k+)', '\=lh#option#get(submatch(1))', 'g'), &#xA;           \ 'sp')&amp;lt;cr&amp;gt;&#xA;&#xA;xnoremap &amp;lt;silent&amp;gt; &amp;lt;c-w&amp;gt;v &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;:call lh#buffer#jump(&#xA;           \ substitute(lh#visual#selection(), '\v\@(\k+)', '\=lh#option#get(submatch(1))', 'g'), &#xA;           \ 'vert sp')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Last thing, you'll then need &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/Options.md#notes-on-how-options-could-be-set&quot; rel=&quot;nofollow noreferrer&quot;&gt;a way to define your variables in the scope of your current project&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-05-22T01:43:32.990" LastActivityDate="2018-05-22T01:43:32.990" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16284" PostTypeId="2" ParentId="16253" CreationDate="2018-05-21T19:28:08.060" Score="1" Body="&lt;p&gt;After setting wildmode=full, shift-tab takes me back to the original regex. The wildmode documentation for full is&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;full&quot; Complete the next full match.  After the last match, the &lt;strong&gt;&lt;em&gt;original string&lt;/em&gt;&lt;/strong&gt; is used and then the first match again.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Originally, my wildmode was wildmode=longest:full,full,full. To get back to the original regex I had to tab, tab, then shift-tab. The reason I had to do two tabs is because the first tab took me did the longest:full. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;longest:full&quot;  Like &quot;longest&quot;, but also start 'wildmenu' if it is enabled.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Based on this documentation it looks like longest:full doesn't have an option to go back to the original regex. The second time I tabbed, it took me to full, which will use the original string at the end of the wildmenu. This is why a shift-tab would take me back to the original regex after two tabs.&lt;/p&gt;&#xA;" OwnerUserId="16698" LastActivityDate="2018-05-21T19:28:08.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16285" PostTypeId="2" ParentId="16260" CreationDate="2018-05-21T20:03:19.167" Score="1" Body="&lt;p&gt;The same issue bothered me for a long time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For fzf there is a discussion about it on github. They came up with some keybindings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;&amp;lt;Leader&amp;gt; (expand('%') =~ 'NERD_tree' ? &quot;\&amp;lt;c-w&amp;gt;\&amp;lt;c-w&amp;gt;&quot; : '').&quot;:FZF\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this post is the most promising &lt;a href=&quot;https://github.com/junegunn/fzf/issues/453#issuecomment-366466757&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/junegunn/fzf/issues/453#issuecomment-366466757&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It's kind of hacky because I do &quot;code injection&quot; by adding the&#xA;  g:launching_fzf variable inside the layout configuration. There may be&#xA;  a more elegant solution but in the meantime it works and I didn't have&#xA;  to change the FZF plugin source code.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and this is his code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:fzf_layout = { 'window': 'let g:launching_fzf = 1 | keepalt topleft 100split enew' }&#xA;&#xA;autocmd FileType nerdtree let t:nerdtree_winnr = bufwinnr('%')&#xA;autocmd BufWinEnter * call PreventBuffersInNERDTree()&#xA;&#xA;function! PreventBuffersInNERDTree()&#xA;  if bufname('#') =~ 'NERD_tree' &amp;amp;&amp;amp; bufname('%') !~ 'NERD_tree'&#xA;    \ &amp;amp;&amp;amp; exists('t:nerdtree_winnr') &amp;amp;&amp;amp; bufwinnr('%') == t:nerdtree_winnr&#xA;    \ &amp;amp;&amp;amp; &amp;amp;buftype == '' &amp;amp;&amp;amp; !exists('g:launching_fzf')&#xA;    let bufnum = bufnr('%')&#xA;    close&#xA;    exe 'b ' . bufnum&#xA;  endif&#xA;  if exists('g:launching_fzf') | unlet g:launching_fzf | endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17497" LastEditorUserId="17549" LastEditDate="2018-05-23T08:54:45.347" LastActivityDate="2018-05-23T08:54:45.347" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16286" PostTypeId="1" CreationDate="2018-05-22T09:07:40.917" Score="0" ViewCount="71" Body="&lt;p&gt;For example, I'd like to map &lt;code&gt;&amp;lt;leader&amp;gt;l&lt;/code&gt; to enter command-line mode with a command (&lt;code&gt;AsyncRun&lt;/code&gt; followed by a space) partially typed in, so that I can continue to type to complete the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So typing &lt;code&gt;&amp;lt;leader&amp;gt;l&lt;/code&gt; will enter command-line mode with the following command waiting for further input:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:AsyncRun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then typing &lt;code&gt;echo hello&lt;/code&gt; will complete the full command and pressing &lt;kbd&gt;Enter&lt;/kbd&gt; will execute it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:AsyncRun echo hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way to create a mapping like this?&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="343" LastEditDate="2018-05-22T10:23:43.570" LastActivityDate="2018-05-22T12:36:52.150" Title="Invoke command-line mode in input waiting state" Tags="|key-bindings|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16287" PostTypeId="1" CreationDate="2018-05-22T09:26:11.913" Score="1" ViewCount="230" Body="&lt;p&gt;How can I map Ctrl and hyphen key? Usually when mapping Ctrl key with other keys there is a hypen key in the middle. But I would like to use this hypen key as my mapping, can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I tap Ctrl and Hyphen key I would like the vim doing the horizontal splits. (The vertical splits in my setting are Ctrl and backslash, therefore it make sense for me to do the horizontal vertical like so.)&lt;/p&gt;&#xA;" OwnerUserId="15958" LastEditorUserId="28" LastEditDate="2018-05-22T19:58:26.843" LastActivityDate="2018-05-22T19:58:26.843" Title="Can I map contrl and hyphen &lt;C--&gt;?" Tags="|vimrc|key-bindings|" AnswerCount="0" CommentCount="2" ClosedDate="2018-05-22T18:23:01.747" ContentLicense="CC BY-SA 4.0" />
  <row Id="16288" PostTypeId="2" ParentId="16286" CreationDate="2018-05-22T10:28:03.087" Score="1" Body="&lt;p&gt;You can use the following normal mode mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;l :AsyncRun&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. Instead of &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;, you could just type a literal space character, but it's easier to see what the above is doing at a glance. If you wanted to &lt;em&gt;start&lt;/em&gt; your &lt;code&gt;rhs&lt;/code&gt; with a space, then using the &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; notation is required. See &lt;code&gt;:help map_space_in_rhs&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-05-22T10:28:03.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16289" PostTypeId="2" ParentId="16286" CreationDate="2018-05-22T12:36:52.150" Score="0" Body="&lt;p&gt;You can request input form the user using &lt;code&gt;input(&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        :if input(&quot;Coffee or beer? &quot;) == &quot;beer&quot;&#xA;        :  echo &quot;Cheers!&quot;&#xA;        :endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This supports arbitrary completion (see &lt;code&gt;:help input(&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, &lt;code&gt;inputlist(&lt;/code&gt; will allow the user to select from a list of items, either by mouse or typing a number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also &lt;code&gt;inputdialog(&lt;/code&gt; for a GUI alternative.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-05-22T12:36:52.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16290" PostTypeId="2" ParentId="2696" CreationDate="2018-05-22T12:37:00.037" Score="2" Body="&lt;h3&gt;&lt;a href=&quot;https://github.com/andymass/vim-matchup&quot; rel=&quot;nofollow noreferrer&quot;&gt;Plugin Match-Up&lt;/a&gt;: &lt;code&gt;g:matchup_motion_override_Npercent&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This plugin offers the possibility to use &lt;code&gt;[count]%&lt;/code&gt; for both motions:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;code&gt;{count}%&lt;/code&gt; forwards &lt;code&gt;{count}&lt;/code&gt; times. Requires &lt;code&gt;{count} &amp;lt;= g:matchup_motion_override_Npercent&lt;/code&gt;.&lt;/li&gt;&#xA;  &lt;li&gt;For larger &lt;code&gt;{count}&lt;/code&gt;, &lt;code&gt;{count}%&lt;/code&gt; goes to the &lt;code&gt;{count}&lt;/code&gt; percentage in the file.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The default value is &lt;code&gt;6&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means&#xA;&lt;code&gt;5%&lt;/code&gt; would cycle five &lt;code&gt;b:match_words&lt;/code&gt;, e.g. in vimscript through &lt;code&gt;elseif&lt;/code&gt;.&#xA;But &lt;code&gt;50%&lt;/code&gt; would jump to the middle of the file.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-05-23T05:55:38.800" LastActivityDate="2018-05-23T05:55:38.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16291" PostTypeId="1" CreationDate="2018-05-22T16:53:05.820" Score="1" ViewCount="1451" Body="&lt;p&gt;How to get vim keybindings at terminal output so I can navigate/operate at terminal output like in vim or get smooth shell command processing in vim. For example I type:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ifconfig&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;an i want to make moves to &lt;code&gt;ipaddres&lt;/code&gt; location, then copy it and paste into command line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already know solution inside VIM like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;read ! ifconfig&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but it I am looking for more persistent solution that will work smoothly for a long run. &lt;/p&gt;&#xA;" OwnerUserId="16328" LastEditorUserId="16328" LastEditDate="2018-05-22T19:07:44.263" LastActivityDate="2018-05-22T23:59:26.537" Title="How to redirect terminal output to vim or get `vim like` behaviour in terminal output" Tags="|key-bindings|command-line|terminal|terminal-buffer|" AnswerCount="3" CommentCount="1" ClosedDate="2018-05-23T13:32:25.417" ContentLicense="CC BY-SA 4.0" />
  <row Id="16292" PostTypeId="2" ParentId="16291" CreationDate="2018-05-22T17:13:28.963" Score="1" Body="&lt;p&gt;one way is to simply issue &lt;code&gt;terminal ifconfig&lt;/code&gt; (vim8 or vim7 with a lot of patches).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will open a vim-buffer with the result.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-05-22T17:13:28.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16294" PostTypeId="2" ParentId="16291" CreationDate="2018-05-22T18:55:24.170" Score="1" Body="&lt;p&gt;How about using the Vi-mode in your terminal. You can do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set editing-mode vi&#xA;set keymap vi-command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can further customize keybindings, as described in this article:&#xA;&lt;a href=&quot;http://vim.wikia.com/wiki/Use_vi_shortcuts_in_terminal&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Use_vi_shortcuts_in_terminal&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way would be to probably pipe it out to something like &quot;less&quot; and then use a tool similar to vim-less:&#xA;&lt;a href=&quot;https://github.com/groenewege/vim-less&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/groenewege/vim-less&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16540" LastActivityDate="2018-05-22T18:55:24.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16295" PostTypeId="1" CreationDate="2018-05-22T19:02:08.463" Score="7" ViewCount="300" Body="&lt;p&gt;I'm using vim to edit LaTeX code, and I'm often writing intervals like &lt;code&gt;(a,b]&lt;/code&gt; but this messes with other vim features.  For instance, &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Jumping with &lt;kbd&gt;%&lt;/kbd&gt;: if I have something like &lt;code&gt;\phi((a,b])&lt;/code&gt;, the final &lt;code&gt;)&lt;/code&gt; will match the second &lt;code&gt;(&lt;/code&gt; and some closing parenthesis later in the code will match the first.&lt;/li&gt;&#xA;&lt;li&gt;There's a feature (I'm not sure if it's specific to vimtex or just a feature of vim) where &lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt; closes any open delimiters, and this makes that behave wrongly - it'll try to close the &lt;code&gt;)&lt;/code&gt; from many lines ago.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;kbd&gt;tsd&lt;/kbd&gt;/&lt;kbd&gt;csd&lt;/kbd&gt;/&lt;kbd&gt;dsd&lt;/kbd&gt; features of vimtex which toggle/change/delete surrounding delimiters don't work (I think &lt;kbd&gt;csd&lt;/kbd&gt; and &lt;kbd&gt;dsd&lt;/kbd&gt; are extensions of vim-surround but I'm not sure). In particular, either they select the wrong delimiters or do nothing at all.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Currently I'm putting &lt;code&gt;)&lt;/code&gt;s in comments to mitigate this. This solves the problem of parentheses later in the file matching wrongly, but matching in the same line doesn't work (and things like &lt;code&gt;tsd&lt;/code&gt; from vimtex don't work properly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any better solution, or a standard solution for this kind of problem? Ideally this would deal with &lt;code&gt;[a,b)&lt;/code&gt; also.&lt;/p&gt;&#xA;" OwnerUserId="14574" LastEditorUserId="14574" LastEditDate="2018-05-22T19:18:24.890" LastActivityDate="2019-10-26T06:01:30.183" Title="Matching interval brackets" Tags="|filetype-tex|plugin-vimtex|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16296" PostTypeId="2" ParentId="16291" CreationDate="2018-05-22T23:59:26.537" Score="1" Body="&lt;p&gt;With &lt;a href=&quot;https://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/&quot; rel=&quot;nofollow noreferrer&quot;&gt;tmux&lt;/a&gt; (terminal multiplexer) you can do select/copy/paste of terminal screen contents using Vim commands. When you're in a &lt;code&gt;tmux&lt;/code&gt; session run your command(s) outputting to terminal (stdout). Then hit &quot;prefix&quot; + &lt;code&gt;[&lt;/code&gt; to get in &quot;copy mode&quot;. From there you can navigate with Vim commands like &lt;code&gt;Ctrl-U&lt;/code&gt;, optionally select some text using Visual mode and yank with commands like &lt;code&gt;y&lt;/code&gt;. Quit copy mode and you can paste anywhere in the &lt;code&gt;tmux&lt;/code&gt; session (with &quot;prefix&quot; + &lt;code&gt;]&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: &quot;prefix&quot; is a special keystroke used to initiate most &lt;code&gt;tmux&lt;/code&gt; commands. It is &lt;code&gt;Ctrl-B&lt;/code&gt; by default but configurable.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-05-22T23:59:26.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16297" PostTypeId="2" ParentId="14137" CreationDate="2018-05-23T17:33:37.633" Score="1" Body="&lt;p&gt;At the time of this writing, it seems that the powerline plugin is still not compatible with NeoVim, check this github issue:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/powerline/powerline/issues/1287&quot; rel=&quot;nofollow noreferrer&quot;&gt;Add support for NeoVim #1287&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13089" LastActivityDate="2018-05-23T17:33:37.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16298" PostTypeId="1" AcceptedAnswerId="16299" CreationDate="2018-05-23T17:42:07.377" Score="0" ViewCount="1224" Body="&lt;p&gt;Can I map the Tab key as the same style as Control plus another key? For example ,&lt;code&gt;&amp;lt;c-k&amp;gt;&lt;/code&gt; means press the &lt;strong&gt;Control&lt;/strong&gt; and &lt;strong&gt;k&lt;/strong&gt; keys together. I've tried &lt;code&gt;&amp;lt;tab-k&amp;gt;&lt;/code&gt; but it didn't work.&lt;/p&gt;&#xA;" OwnerUserId="15958" LastEditorUserId="51" LastEditDate="2018-05-23T18:10:36.350" LastActivityDate="2018-05-24T08:38:20.963" Title="Mapping tab with another key" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16299" PostTypeId="2" ParentId="16298" CreationDate="2018-05-23T17:58:41.673" Score="3" Body="&lt;p&gt;&lt;em&gt;Assuming you mean &quot;tab&quot; not &quot;tap&quot;...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;No.&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This is not possible &lt;em&gt;purely&lt;/em&gt; in vim. You are basically asking vim to recognize &lt;kbd&gt;Tab&lt;/kbd&gt; as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Modifier_key&quot; rel=&quot;nofollow noreferrer&quot;&gt;modifier key&lt;/a&gt;. The only keys that vim recognize as a modifier key are &lt;kbd&gt;Shift&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;, &lt;kbd&gt;Alt&lt;/kbd&gt;/&lt;kbd&gt;Meta&lt;/kbd&gt;, and, on Mac, &lt;kbd&gt;Command&lt;/kbd&gt;. (See &lt;code&gt;:help keycodes&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And since vim cannot recognize &lt;a href=&quot;https://vi.stackexchange.com/a/7005/2920&quot;&gt;keyup/keydown events&lt;/a&gt;, you cannot use vimscript to handle tab presses and pretend it's a modifier key. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way you could achieve this would be by hacking your keyboard's firmware/drivers and making the tab button work differently, which is beyond my knowledge and way beyond the scope of a vim question. I don't know if you could bind it as a custom modifier or if you'd have to remap it to one of the existing modifier keys. &lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="343" LastEditDate="2018-05-24T08:38:20.963" LastActivityDate="2018-05-24T08:38:20.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16302" PostTypeId="1" AcceptedAnswerId="16304" CreationDate="2018-05-24T02:20:44.237" Score="2" ViewCount="2640" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ALE&lt;/a&gt; for linting my programming code, and I have following configuration part to specify lint tool for JavaScript.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_linters = {&#xA;\   'javascript': ['eslint'],&#xA;\}&#xA;&#xA;let g:ale_fixers = {&#xA;\   'javascript': ['eslint'],&#xA;\}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works pretty well if eslint could find there is a &lt;code&gt;.eslintrc&lt;/code&gt; or &lt;code&gt;.eslintrc.json&lt;/code&gt; under current project directory. However I wonder what if I just want to use Vim to edit an arbitrary JavaScript file, it will pop up a lint error message which says &lt;code&gt;aslant configuration error&lt;/code&gt; due to lack of the eslint configuration file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I wonder if there is a way to specify a default lint configuration file if there is no eslint configuration file could be found under current project folder.&lt;/p&gt;&#xA;" OwnerUserId="7971" LastActivityDate="2018-05-24T07:30:22.610" Title="Is there a way to specify a default eslint configuration file when using ALE plugin of Vim?" Tags="|plugin-ale|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16304" PostTypeId="2" ParentId="16302" CreationDate="2018-05-24T07:30:22.610" Score="3" Body="&lt;p&gt;From the eslint &lt;a href=&quot;https://eslint.org/docs/user-guide/configuring#configuration-file-formats&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; we can read&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: If you have a personal configuration file in your home directory (&lt;code&gt;~/.eslintrc&lt;/code&gt;), it will only be used if no other configuration files are found. Since a personal configuration would apply to everything inside of a user’s directory, including third-party code, this could cause problems when running ESLint.&lt;/p&gt;&#xA;&lt;p&gt;By default, ESLint will look for configuration files in all parent folders up to the root directory. This can be useful if you want all of your projects to follow a certain convention, but can sometimes lead to unexpected results. To limit ESLint to a specific project, place &lt;code&gt;&amp;quot;root&amp;quot;: true&lt;/code&gt; inside the &lt;code&gt;eslintConfig&lt;/code&gt; field of the &lt;code&gt;package.json&lt;/code&gt; file or in the &lt;code&gt;.eslintrc.*&lt;/code&gt; file at your project’s root level. ESLint will stop looking in parent folders once it finds a configuration with &lt;code&gt;&amp;quot;root&amp;quot;: true&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So I didn't test it but you should be able to put a &lt;code&gt;.eslintrc&lt;/code&gt; file in your home directory to create a default configuration.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-05-24T07:30:22.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16305" PostTypeId="1" CreationDate="2018-05-24T08:53:21.560" Score="1" ViewCount="4273" Body="&lt;p&gt;The following command will substitute all tabs in a file with four blank spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\t/    /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to run this command whenever I open a new file I included it in my .vimrc by adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile  *   exec &quot;%s/\t/    /g&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However this didn't work.  Does anyone know why?&lt;/p&gt;&#xA;" OwnerUserId="13416" LastEditorUserId="17549" LastEditDate="2018-07-02T12:29:47.310" LastActivityDate="2018-07-02T12:29:47.310" Title="Substitute all tabs with four blank spaces" Tags="|autocmd|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16306" PostTypeId="2" ParentId="16305" CreationDate="2018-05-24T09:05:12.327" Score="1" Body="&lt;pre&gt;&lt;code&gt;autocmd BufRead  *   exec &quot;%s/\t/    /g&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13416" LastActivityDate="2018-05-24T09:05:12.327" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16308" PostTypeId="2" ParentId="358" CreationDate="2018-05-24T15:55:15.040" Score="7" Body="&lt;p&gt;Another option that gets rid of the pesky extra &quot;new file&quot; tab is &#xA;&lt;code&gt;vim +&quot;tab help | -tabc&quot;&lt;/code&gt;.&#xA;This creates a help tab on vim start (&lt;code&gt;tab help&lt;/code&gt;) and removes the new file (&lt;code&gt;-tabc&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="17652" LastActivityDate="2018-05-24T15:55:15.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16309" PostTypeId="1" CreationDate="2018-05-24T17:46:36.940" Score="1" ViewCount="499" Body="&lt;p&gt;I know &lt;code&gt;gvim -c [command] samaple.txt&lt;/code&gt; might run command predefined in command body. How to paste text from windows clipboard at the end of sample.txt file?&lt;/p&gt;&#xA;" OwnerUserId="16328" LastEditorUserId="1292" LastEditDate="2019-11-19T10:33:33.520" LastActivityDate="2019-11-19T10:33:33.520" Title="How to start gvim from command line with predefine pasting from clipboard" Tags="|gvim|microsoft-windows|os-clipboard|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16310" PostTypeId="2" ParentId="16309" CreationDate="2018-05-24T18:21:19.437" Score="3" Body="&lt;p&gt;As far as I know &lt;a href=&quot;https://stackoverflow.com/questions/17819814/how-can-you-get-the-clipboard-contents-with-a-windows-command&quot;&gt;the clipboard cannot be accessed from the command line natively&lt;/a&gt;. So that's going to be the biggest problem here. If you put the data somewhere accessible like a text file you could certainly use &lt;code&gt;[command]&lt;/code&gt; to do the rest. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim +&quot;let @\&quot;= {someData}&quot; +&quot;normal! Gp&quot; sample.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, as Peter Rincker mentioned if vim is complied with the &lt;code&gt;+clipboard&lt;/code&gt; option this is actually quite possible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim +&quot;$put+&quot; sample.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;+&lt;/code&gt; is a special register that points to the clipboard. &lt;code&gt;$put+&lt;/code&gt; &quot;puts&quot; the &lt;code&gt;+&lt;/code&gt; register at the end of the file.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastEditorUserId="6489" LastEditDate="2018-05-24T22:00:59.083" LastActivityDate="2018-05-24T22:00:59.083" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="16311" PostTypeId="1" CreationDate="2018-05-24T19:00:22.003" Score="1" ViewCount="126" Body="&lt;p&gt;I've been unable to use surround within a global command, For example:&#xA;&lt;code&gt;g/^/ norm! yss&quot;&lt;/code&gt; seems to do nothing or replaces the entire line by the contents of the clipboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is consistent with experience reported on github (&lt;a href=&quot;https://github.com/tpope/vim-surround/issues/161&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tpope/vim-surround/issues/161&lt;/a&gt;). That report includes no solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running gvim 8.0 under Windows 10. Is anyone able to run surround within a global command? If so, what am I missing? If not, is anyone able to explain the limitation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: In view of comments received, I must conclude that the problem has to do with my configuration. For the record, I've upgraded to 8.1.1 but that hasn't helped. It seems that it's only the yss commands that fail under global (and those not consistently). ds and cs appear to work. yss works very occasionally (though I've been unable to establish a repeatable circumstance). Otherwise, sometimes the contents of the clipboard are inserted, sometimes there is no change: I cannot yet predict which. &lt;/p&gt;&#xA;" OwnerUserId="16868" LastEditorUserId="16868" LastEditDate="2018-05-26T08:53:38.907" LastActivityDate="2018-05-26T08:53:38.907" Title="surround plug-in within global command" Tags="|plugin-vim-surround|global-command|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="16313" PostTypeId="2" ParentId="16309" CreationDate="2018-05-25T05:18:07.850" Score="1" Body="&lt;p&gt;&lt;code&gt;&quot;+&lt;/code&gt; is a special register. It refers to system clipboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can paste the content of windows clipboard into current cursor position by using the below command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;+p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17659" LastActivityDate="2018-05-25T05:18:07.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16315" PostTypeId="1" AcceptedAnswerId="16337" CreationDate="2018-05-25T12:36:43.897" Score="2" ViewCount="95" Body="&lt;p&gt;I'm trying to add this rule:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match Keyword /{+.*+}/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I open a plain text file and run the above as a command, it works: stuff like &lt;code&gt;{+ asdf +}&lt;/code&gt; gets highlighted as a keyword.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I add this to a syntax file, or I run this after opening a syntax-highlighted file such as a Git diff, it does nothing. Try as I might, I can't get it to highlight the matched parts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do &lt;code&gt;:sy clear&lt;/code&gt; in a Git diff file and add the match rule as a command, it works. Is something in the existing syntax definition perhaps preventing further rules from working/being added?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can see (using &lt;a href=&quot;http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor&quot; rel=&quot;nofollow noreferrer&quot;&gt;this mapping&lt;/a&gt;) that the text I'm trying to highlight is not currently part of any syntax item—in other words, the text is the default text colour not because it is assigned that way, but because it is assigned to nothing at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For what it's worth, I'm using MacVim, which seems to have a built-in Git syntax definition that is loaded after all my other syntax files—not that editing that file makes any difference here. I just tried this with NeoVim as well, with no success.&lt;/p&gt;&#xA;" OwnerUserId="14849" LastEditorUserId="14849" LastEditDate="2018-05-25T13:34:53.423" LastActivityDate="2018-05-28T09:36:43.307" Title="Can't get syntax highlighting rule to work" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16316" PostTypeId="1" AcceptedAnswerId="16317" CreationDate="2018-05-25T13:22:13.387" Score="0" ViewCount="399" Body="&lt;p&gt;As the title stated&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead,BufNewFile not-py-file nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F3&amp;gt; :call some_func&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is what I want to acheive, but I don't know how to implement that &lt;code&gt;not-py-file&lt;/code&gt; logic.&#xA;Any help?&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2018-05-25T14:05:27.293" Title="autocmd buffer local mapping if not *.py file" Tags="|vimrc|key-bindings|autocmd|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16317" PostTypeId="2" ParentId="16316" CreationDate="2018-05-25T13:49:15.540" Score="2" Body="&lt;p&gt;One way you could achieve this is to create the mapping for &lt;em&gt;all&lt;/em&gt; files, and then remove it for &lt;code&gt;*.py&lt;/code&gt; files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead,BufNewFile * nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F3&amp;gt; :call some_func&amp;lt;CR&amp;gt;&#xA;autocmd BufRead,BufNewFile *.py nunmap &amp;lt;buffer&amp;gt; &amp;lt;F3&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim executes autocommands in the order they are created (See &lt;code&gt;:help :autocmd&lt;/code&gt;), so the two commands will always run in the correct order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that seems inelegant to you, you could instead have your autocommand check the filetype before it creates the mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CreateNonPyMapping(extension)&#xA;  if a:extension !=? 'py'&#xA;    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F3&amp;gt; :call some_func&amp;lt;CR&amp;gt;&#xA;  endif&#xA;endfunction&#xA;&#xA;augroup NonPyMapping&#xA;  autocmd!&#xA;  autocmd BufRead,BufNewFile * call CreateNonPyMapping(expand('&amp;lt;afile&amp;gt;:e'))&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-05-25T14:05:27.293" LastActivityDate="2018-05-25T14:05:27.293" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16318" PostTypeId="1" CreationDate="2018-05-25T14:24:16.467" Score="1" ViewCount="46" Body="&lt;p&gt;I have a gzip multiline json file that when unzipped takes few GB of data. Each line is a stand-alone JSON object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I quickly see it's content in a stream way?&lt;/p&gt;&#xA;" OwnerUserId="17666" LastActivityDate="2018-05-25T14:24:16.467" Title="How to see very large gziped json file in linux using vi" Tags="|filetype-json|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16319" PostTypeId="2" ParentId="12169" CreationDate="2018-05-25T14:30:38.253" Score="0" Body="&lt;p&gt;Here's a very short mapping that will achieve roughly what you're asking, by using the command-line window and select mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap : :&amp;lt;Up&amp;gt;&amp;lt;C-F&amp;gt;gH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It recalls the previous command with &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt;, opens the command-line window with &lt;code&gt;&amp;lt;C-F&amp;gt;&lt;/code&gt; and then enters linewise select mode with &lt;code&gt;gH&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you then press &lt;kbd&gt;Enter&lt;/kbd&gt; then the command is run, but if you type anything else, the current selection will be replaced.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-05-25T14:30:38.253" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16320" PostTypeId="1" AcceptedAnswerId="16321" CreationDate="2018-05-25T14:38:01.683" Score="2" ViewCount="656" Body="&lt;p&gt;The ftplugin &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt; provides the file &lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/indent/tex.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;indent/tex.vim&lt;/code&gt;&lt;/a&gt; with following line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal indentkeys+=[,(,{,),},],\&amp;amp;,=item,=else,=fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;&lt;code&gt;'indentkeys'&lt;/code&gt; &lt;code&gt;'indk'&lt;/code&gt;&lt;/strong&gt;  string  (default &lt;code&gt;&quot;0{,0},:,0#,!^F,o,O,e&quot;&lt;/code&gt;)&lt;br&gt;&#xA;     &lt;em&gt;local to buffer&lt;/em&gt;&lt;br&gt;&#xA;      A list of keys that, when typed in Insert mode, cause reindenting of&#xA;      the current line.  Only happens if &lt;code&gt;'indentexpr'&lt;/code&gt; isn't empty.&#xA;      The format is identical to &lt;code&gt;'cinkeys'&lt;/code&gt;, see &lt;a href=&quot;http://vimhelp.appspot.com/indent.txt.html#indentkeys-format&quot; rel=&quot;nofollow noreferrer&quot;&gt;|indentkeys-format|&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Consider this list environment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{itemize}&#xA;  \item &amp;lt;CURSOR&amp;gt; &#xA;\end{itemize} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you enter a newline and then a second &lt;code&gt;\item&lt;/code&gt;,&#xA;at first the cursor will be indented to the second level (&lt;code&gt;sw=2&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{itemize}&#xA;  \item &#xA;    &amp;lt;CURSOR&amp;gt;&#xA;\end{itemize} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then when you enter manually &lt;code&gt;\item&lt;/code&gt;, the line will be reindented and you get the desired indentation&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{itemize}&#xA;  \item &#xA;  \item &amp;lt;CURSOR&amp;gt;&#xA;\end{itemize} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if you do the same by using the UltiSnips snippet &lt;code&gt;it&lt;/code&gt; (from &lt;a href=&quot;https://github.com/honza/vim-snippets/blob/master/UltiSnips/tex.snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;honza/vim-snippets&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet it &quot;Individual item&quot; b&#xA;\item $0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you end up with an unintended second level indentation of the second &lt;code&gt;\item&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{itemize}&#xA;  \item &#xA;    \item &amp;lt;CURSOR&amp;gt;&#xA;\end{itemize} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to resolve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has already been raised on the &lt;a href=&quot;https://github.com/SirVer/ultisnips/issues/913&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue tracker of UltiSnips&lt;/a&gt;, but I hope to find here a wider audience for this issue. BTW &lt;a href=&quot;https://github.com/LucHermitte/mu-template&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/LucHermitte/mu-template&lt;/a&gt; claims to support reindentation.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-05-26T05:25:40.073" LastActivityDate="2018-05-26T05:25:40.073" Title="Trigger reindentation after snippet has expanded to word in 'indentkeys'" Tags="|indentation|filetype-tex|plugin-ultisnips|snippets|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16321" PostTypeId="2" ParentId="16320" CreationDate="2018-05-25T14:54:39.020" Score="5" Body="&lt;p&gt;You can manually fix the indent by typing &lt;code&gt;CTRL-F&lt;/code&gt; (this is documented at &lt;code&gt;:help indentkeys-format&lt;/code&gt;).  Thus, an autonomous solution would be to issue this key-press after snippet expansion.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global !p&#xA;def fix_indent(snip):&#xA;    vim.eval('feedkeys(&quot;\&amp;lt;c-f&amp;gt;&quot;)')&#xA;endglobal&#xA;&#xA;post_expand &quot;fix_indent(snip)&quot;&#xA;snippet it &quot;Individual item&quot; b&#xA;\item $0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-05-25T15:13:49.523" LastActivityDate="2018-05-25T15:13:49.523" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16323" PostTypeId="1" AcceptedAnswerId="16324" CreationDate="2018-05-25T20:12:09.683" Score="2" ViewCount="4142" Body="&lt;p&gt;Is there a way to match matching parentheses in vim regex?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I have a line like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function(&quot;test(with)parentheses&quot;); // (comment)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.s/\(function\)(\(.*\))/\1[\2]/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;turns it into &lt;code&gt;function[&quot;test(with]parentheses&quot;); // (comment)&lt;/code&gt;, and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.s/\(function\)(\([^)]*\))/\1[\2]/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;turns it into &lt;code&gt;function[&quot;test(with)parentheses&quot;); // (comment]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I get &lt;code&gt;function[&quot;test(with)parentheses&quot;]; // (comment)&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please, don't assume that the &lt;code&gt;)&lt;/code&gt; of interest is always followed by a &lt;code&gt;;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10391" LastActivityDate="2018-05-25T22:47:10.430" Title="Replace matching parentheses" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16324" PostTypeId="2" ParentId="16323" CreationDate="2018-05-25T22:47:10.430" Score="4" Body="&lt;h3&gt;TL;DR:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can not use regexp's to match infinitely nested patterns in Vim.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Regular Languages&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Regular expressions are modeled off a &lt;a href=&quot;https://en.wikipedia.org/wiki/Formal_language&quot; rel=&quot;nofollow noreferrer&quot;&gt;formal language theory&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Regular_language&quot; rel=&quot;nofollow noreferrer&quot;&gt;regular language&lt;/a&gt;. Some regular expression libraries even go a step further and use an &lt;a href=&quot;https://en.wikipedia.org/wiki/Nondeterministic_finite_automaton&quot; rel=&quot;nofollow noreferrer&quot;&gt;NFA&lt;/a&gt; (Nondeterministic finite automaton are regular) as the actual underlying model their regular expression engine. Vim has support for a NFA based regex engine for example. See &lt;code&gt;:h NFA&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Why is it important that Regexp are modeled off of Regular Languages?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;First and foremost nested matching parenthesis is not regular. Although regex engines are often not purely regular in what they can match, they must support recursion to match nested patterns. So the question becomes can the given regex engine use recursion to overcome this limit? &lt;a href=&quot;https://stackoverflow.com/questions/4445674/can-i-use-perl-regular-expressions-to-match-balanced-text&quot;&gt;Perl's regex engine&lt;/a&gt; can do this for example. Sadly, Vim does not have a regex engine that can use recursion.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Workarounds?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can anticipate the max depth and use branches to sort of accomplish this affect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;([^(]*([^)]*)[^)]*)\|([^)]*)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That pattern will match &lt;code&gt;(foo)&lt;/code&gt; as well as &lt;code&gt;(foo(bar)foo)&lt;/code&gt;. It will not match &lt;code&gt;(foo(bar(baz)bar)foo)&lt;/code&gt; as it is too deep. It will also fail if parens are not properly matched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to use something other than &lt;code&gt;:substitute&lt;/code&gt;. Like use the &lt;code&gt;%&lt;/code&gt; command or text objects.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f(mm%r]`mr[&#xA;f(yi)ca)[&amp;lt;c-r&amp;gt;0]&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may be able to use Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;surround.vim&lt;/a&gt; for this use case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cs(]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would &quot;change the surrounding&quot; &lt;code&gt;(&lt;/code&gt; pairs with &lt;code&gt;]&lt;/code&gt; pairs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More advanced techniques would be to use &lt;code&gt;searchpair()&lt;/code&gt; and/or sniffing Vim's syntax highlighting for a given word. See &lt;code&gt;:h searchpair()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-05-25T22:47:10.430" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16325" PostTypeId="2" ParentId="5178" CreationDate="2018-05-26T17:04:24.200" Score="2" Body="&lt;p&gt;I am fairly new here, so not allowed to comment and have to post this as an answer.&#xA;I guess romainl's answer is pretty definitive and there's this post that makes for a good 'beginner-friendly' version of it:&#xA;&lt;a href=&quot;https://dockyard.com/blog/2013/10/22/vim-buffers&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://dockyard.com/blog/2013/10/22/vim-buffers&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then there's this post, maybe a little biased, but lays out the argument pretty well:&#xA;&lt;a href=&quot;https://joshldavis.com/2014/04/05/vim-tab-madness-buffers-vs-tabs/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://joshldavis.com/2014/04/05/vim-tab-madness-buffers-vs-tabs/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16540" LastActivityDate="2018-05-26T17:04:24.200" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16326" PostTypeId="2" ParentId="2365" CreationDate="2018-05-26T18:52:38.973" Score="1" Body="&lt;p&gt;I’m using the &lt;a href=&quot;https://github.com/google/vim-searchindex&quot; rel=&quot;nofollow noreferrer&quot;&gt;SearchIndex&lt;/a&gt; plugin. To use Christian Brabandt’s answer but keep the plugin’s functionality of displaying the match number each time I type &lt;kbd&gt;n&lt;/kbd&gt; or &lt;kbd&gt;N&lt;/kbd&gt;, I put this in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; n (v:searchforward ? 'n' : 'N') . &quot;:SearchIndex&amp;lt;CR&amp;gt;&quot;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; N (v:searchforward ? 'N' : 'n') . &quot;:SearchIndex&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="671" LastActivityDate="2018-05-26T18:52:38.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16327" PostTypeId="1" CreationDate="2018-05-26T19:12:22.477" Score="1" ViewCount="252" Body="&lt;p&gt;I have operating system: Windows 7. Git bash works fine for me, and it uses the public key &lt;code&gt;id_rsa.pub&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can run git commands fine through window's command prompt as well - and it too uses the public key &lt;code&gt;id_rsa.pub&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trying to configure my Vim so that I can push to my repository without having to open git bash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;:!git push&lt;/code&gt; the following error message is shown:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dtRNB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dtRNB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17673" LastEditorUserId="28" LastEditDate="2018-05-27T12:08:16.783" LastActivityDate="2018-05-27T12:08:16.783" Title="Vim (Spacevim); :!git push == permission denied (publickey)" Tags="|command-line|gvim|git|spacevim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16328" PostTypeId="2" ParentId="16327" CreationDate="2018-05-26T22:11:39.480" Score="1" Body="&lt;p&gt;The problem is not with your vim. What is the responsibility of your vim, is to execute the command after the &lt;code&gt;!&lt;/code&gt;. It does it correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error message is from the git. However, it is still not the problem with your git. The responsibility of the git here, is to call another git process on your remote machine by ssh. Git only calls this ssh, and it does it correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't ssh to the remote machine, because your &lt;code&gt;id_rsa.pub&lt;/code&gt; is not allowed to authenticate on the remote server. What could be its reason, well... anything. Most likely there is a problem with the keys setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Considering the most typical usage of Windowses, I suspect your vim calls actually a different git or ssh install, which uses somehow different configs. Typically on Windows7's, there is a git from the so-named &quot;git bash&quot;&lt;sup&gt;1&lt;/sup&gt; and also a different one from another unix compat layer (cygwin, mingwin, SFU, anything).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; Disclaimer: in my opinion, it is a crap software and if you want to use working unix tools, including git, use cygwin64.&lt;/p&gt;&#xA;" OwnerUserId="28" LastActivityDate="2018-05-26T22:11:39.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16330" PostTypeId="1" AcceptedAnswerId="16331" CreationDate="2018-05-27T14:04:52.743" Score="4" ViewCount="810" Body="&lt;p&gt;I have this lines for my statusline&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; set statusline=%{&amp;amp;paste?'\ \ paste\ ':''}&#xA; set statusline+=\ %{expand('%:~:.')!=#''?expand('%:~:.'):'[No\ Name]'}&#xA; set statusline+=%{&amp;amp;readonly?'\ \ [RO]':!&amp;amp;modifiable?'\ \ [RO]':''}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I removed other parts for avoiding useless complexity. As you can see, I need to put two spaces before [RO] in the third/last line when I only get one in output. Why is that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: My version is &lt;code&gt;NVIM v0.3.0-dev&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-27T03:56:32.700" LastActivityDate="2019-02-27T03:56:32.700" Title="Why do I need two escaped spaces to insert one space in statusline" Tags="|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16331" PostTypeId="2" ParentId="16330" CreationDate="2018-05-27T15:13:18.833" Score="3" Body="&lt;p&gt;Inside a &lt;code&gt;%{}&lt;/code&gt; the first space character in the expression seems to be always removed.  For example, &lt;code&gt;let &amp;amp;statusline=&quot;%{'  ]'}&quot;&lt;/code&gt; displays the string &quot; ]&quot;.  It also seems to be independent of &lt;code&gt;fillchars&lt;/code&gt;.  That is, if &lt;code&gt;set fillchars=stl:^&lt;/code&gt;, &lt;code&gt;&quot;^]^^^^&quot;&lt;/code&gt; will be displayed.  Why this happens or if it's intentional is quite mysterious to me (hopefully someone else can answer this question).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A workaround is to use a different space character, e.g., a non breaking space 0xA0:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;statusline=&quot;%{'\ua0xyz'}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%{\&quot;\\ua0xyz\&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-05-27T15:13:18.833" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16332" PostTypeId="1" CreationDate="2018-05-27T16:07:47.020" Score="1" ViewCount="67" Body="&lt;p&gt;when developing for web (in Vim) I'm always using the &lt;a href=&quot;http://getbem.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;BEM&lt;/a&gt; methodology. I have identified that I always go through the same steps when adding a new block element, and I'm looking for ways to automate the whole/or parts of the process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I now have to do for each block being added:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using UltiSnips, &lt;code&gt;c-&lt;/code&gt; is expanded and edited into something like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!-- Component: Button --&amp;gt;&#xA;&amp;lt;div class=&quot;c-button&quot;&amp;gt;&#xA;  &amp;lt;div class=&quot;c-button__border&quot;&amp;gt;&#xA;    &amp;lt;img class=&quot;c-button__icon&quot; src=&quot;img/mic-off.svg&quot; /&amp;gt;&#xA;  &amp;lt;/div&amp;gt; &#xA;  &amp;lt;p class=&quot;c-button__title&quot;&amp;gt;Mic off&amp;lt;/p&amp;gt;  &#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I have to navigate to &lt;code&gt;src/sass/components/&lt;/code&gt; and add a file named &lt;code&gt;_c-button.sass&lt;/code&gt; with the content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.c-button&#xA;&#xA;  &amp;amp;__border&#xA;  &amp;amp;__icon&#xA;  &amp;amp;__title&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally edit &lt;code&gt;src/sass/main.sass&lt;/code&gt; and add &lt;code&gt;@import 'components/button'&lt;/code&gt; to the end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So any tips/ideas how to start to automate this process further? &lt;/p&gt;&#xA;" OwnerUserId="17277" LastActivityDate="2018-05-27T16:07:47.020" Title="Automatically create files based on expanding snippets?" Tags="|filetype-html|plugin-ultisnips|filetype-scss|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16337" PostTypeId="2" ParentId="16315" CreationDate="2018-05-28T09:36:43.307" Score="0" Body="&lt;p&gt;The problem was a broken &lt;code&gt;syn region&lt;/code&gt;. The pattern for that region was matching some but not all of the correct regions. Therefore adding my rule and specifying the containing region would highlight the matched regions only, whereas not specifying the containing region would highlight the unmatched regions only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to fix the &lt;code&gt;region&lt;/code&gt; matching.&lt;/p&gt;&#xA;" OwnerUserId="14849" LastActivityDate="2018-05-28T09:36:43.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16338" PostTypeId="1" AcceptedAnswerId="16353" CreationDate="2018-05-28T12:16:16.137" Score="2" ViewCount="1035" Body="&lt;p&gt;Vim 8.1 add a new :Termdebug command with a really good gdb integration.&#xA;If the &lt;code&gt;mouse&lt;/code&gt; option is set, there is also a visual bar appearing on vim.&#xA;Here is an extract of the man:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If 'mouse' is set the plugin adds a window toolbar with these entries:&#xA;  Step          :Step &#xA;  Next          :Over&#xA;  Finish        :Finish&#xA;  Cont          :Continue&#xA;  Stop          :Stop&#xA;  Eval          :Evaluate&#xA;This way you can use the mouse to perform the most common commands.  &#xA;You need to have the 'mouse' option set to enable mouse clicks.&#xA;                                                               :Winbar&#xA;You can add the window toolbar in other windows you open with: &#xA;  :Winbar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is, I would like to keep the mouse option on my configuration, but I would like to hide this bar, either at run-time with a command or preferably from the beginning in the &lt;em&gt;vimrc&lt;/em&gt;.&#xA;Is it possible to do so and how ?&lt;/p&gt;&#xA;" OwnerUserId="15134" LastActivityDate="2018-05-30T06:25:29.820" Title="hide the WinBar (TermDebug)" Tags="|terminal|mouse|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16339" PostTypeId="1" AcceptedAnswerId="16344" CreationDate="2018-05-28T14:15:18.577" Score="6" ViewCount="197" Body="&lt;p&gt;I am using Vim 7.3 for no particularly compelling reason on an old system I am forced to work on. It's an internal system and it will eventually be replaced by a more modern version of the same distro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when I start editing in a folder with 13 files, using &lt;code&gt;vim -p *&lt;/code&gt;, I end up seeing 10 of those in tabs, but three of them remain &quot;hidden&quot; (i.e. as ordinary buffers). When I go through these tabs one by one, I get - after closing the 10 tabs - the following message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E173: 3 more files to edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... is there a way with &lt;code&gt;-p&lt;/code&gt; to force all files into a tab (the horizontal terminal estate is more than enough to fit them) &lt;em&gt;or&lt;/em&gt; is there a way to move the remaining buffers into separate tabs once I hit the above message?&lt;/p&gt;&#xA;" OwnerUserId="1109" LastEditorUserId="343" LastEditDate="2018-05-29T09:27:55.990" LastActivityDate="2018-05-30T15:46:06.997" Title="How can I make sure all buffers end up as tab or force remaining buffers into tabs?" Tags="|tabbed-user-interface|invocation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16340" PostTypeId="1" CreationDate="2018-05-28T15:11:49.583" Score="2" ViewCount="879" Body="&lt;p&gt;Is there a way to clear the shell screen &lt;em&gt;everytime&lt;/em&gt; before running a terminal command within vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be most useful to me when running scripts while editing it as I have a binding for Python scripts (for now; looking for a general solution though).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I resort to &lt;code&gt;:!clear &amp;amp;&amp;amp; !&amp;lt;command&amp;gt;&lt;/code&gt; however I would like this to be automatic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this. Maybe remap &lt;code&gt;!&lt;/code&gt; to &lt;code&gt;!clear &amp;amp;&amp;amp; !&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;:&#xA;So it turned out that I already had a solution in my vimrc for my specific case of running python scripts. I already had a &lt;code&gt;!clear&lt;/code&gt; as part of the autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the question remains open for a general solution in which the screen is cleared before every terminal command executed particularly basic utilities like &lt;code&gt;grep&lt;/code&gt; &amp;amp; &lt;code&gt;ls&lt;/code&gt; which I prefer to execute in the terminal as I have color highlighting which is not present in vims' version.&lt;/p&gt;&#xA;" OwnerUserId="7703" LastEditorUserId="7703" LastEditDate="2018-05-30T10:40:25.647" LastActivityDate="2018-05-30T10:40:25.647" Title="Clear shell screen everytime a shell command is run" Tags="|terminal|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16341" PostTypeId="1" AcceptedAnswerId="16342" CreationDate="2018-05-28T15:25:09.637" Score="15" ViewCount="12550" Body="&lt;p&gt;I am using vim 8.1. When I need to change the default filetype for &lt;code&gt;.s&lt;/code&gt; extension to &lt;code&gt;gas&lt;/code&gt; (which by default is &lt;code&gt;asm&lt;/code&gt;), I first look for the default command to set filetype in &lt;code&gt;/usr/share/vim/vim81/filetype.vim&lt;/code&gt;. It contains &lt;a href=&quot;https://github.com/vim/vim/blob/v8.1.0022/runtime/filetype.vim#L157&quot; rel=&quot;noreferrer&quot;&gt;this line&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst   call dist#ft#FTasm()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, I tried to overwrite that in my &lt;code&gt;vimrc&lt;/code&gt; with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.s setfiletype gas&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, it doesn't work. Filetype still &lt;code&gt;asm&lt;/code&gt; when I open any &lt;code&gt;*.s&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, when I use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.s set ft=gas&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what is the difference between &lt;code&gt;set ft=&amp;lt;filetype&amp;gt;&lt;/code&gt; and &lt;code&gt;setfiletype &amp;lt;filetype&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1526" LastEditorUserId="18609" LastEditDate="2020-05-17T14:43:38.843" LastActivityDate="2020-05-17T14:43:38.843" Title="What is the difference between 'set ft=' and 'setfiletype'?" Tags="|filetype|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16342" PostTypeId="2" ParentId="16341" CreationDate="2018-05-28T16:04:04.790" Score="16" Body="&lt;p&gt;From the &lt;code&gt;:setfiletype&lt;/code&gt; help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setf[iletype] [FALLBACK] {filetype}                    :setf :setfiletype&#xA;                     Set the 'filetype' option to {filetype}, but only if&#xA;                     not done yet in a sequence of (nested) autocommands.&#xA;                     This is short for:&#xA;                             :if !did_filetype()&#xA;                             :  setlocal filetype={filetype}&#xA;                             :endif&#xA;                     This command is used in a filetype.vim file to avoid&#xA;                     setting the 'filetype' option twice, causing different&#xA;                     settings and syntax files to be loaded.&#xA;&#xA;                     When the optional FALLBACK argument is present, a&#xA;                     later :setfiletype command will override the&#xA;                     'filetype'.  This is to used for filetype detections&#xA;                     that are just a guess.  did_filetype() will return&#xA;                     false after this command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;:setfiletype&lt;/code&gt; does not override existing file type, when &lt;code&gt;:set ft&lt;/code&gt; does.&lt;/p&gt;&#xA;" OwnerUserId="15134" LastActivityDate="2018-05-28T16:04:04.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16344" PostTypeId="2" ParentId="16339" CreationDate="2018-05-29T09:27:24.303" Score="7" Body="&lt;p&gt;The documentation for this feature can be found at &lt;code&gt;:help -p&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Open N tab pages.  If [N] is not given, one tab page is opened for every file given as argument.  &lt;strong&gt;The maximum is set with 'tabpagemax' pages (default 10)&lt;/strong&gt;. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(emphasis mine)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to increase the number of tab pages, add a line to your &lt;code&gt;.vimrc&lt;/code&gt;, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabpagemax=20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't want to change the default in your &lt;code&gt;.vimrc&lt;/code&gt;, you can add it to your vim invocation. However, the setting is changed too late to affect the initial set of tab pages, so you also need to open tabs for the extra files using &lt;code&gt;:tab all&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c 'set tabpagemax=20' -c 'tab all' -p *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tested this in Vim 7.4, but as far as I can tell from &lt;code&gt;:help version7.txt&lt;/code&gt;, the &lt;code&gt;'tabpagemax'&lt;/code&gt; setting existed as of the introduction of tab pages in Vim 7.0.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-05-30T15:46:06.997" LastActivityDate="2018-05-30T15:46:06.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16345" PostTypeId="1" AcceptedAnswerId="16354" CreationDate="2018-05-29T11:10:42.707" Score="6" ViewCount="161" Body="&lt;p&gt;I write screenplays with &lt;a href=&quot;https://fountain.io&quot; rel=&quot;nofollow noreferrer&quot;&gt;fountain&lt;/a&gt;. Dialogue syntax looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;THE TERMINATOR&#xA;Hasta la vista. Baby.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to be able to select the sentence: &lt;code&gt;Hasta la vista.&lt;/code&gt;, without also selecting &lt;code&gt;THE TERMINATOR&lt;/code&gt; with a sentence motion, like with &lt;code&gt;vis&lt;/code&gt; or &lt;code&gt;das&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vis&lt;/code&gt; works exactly like I want when there is an empty line between &lt;code&gt;THE TERMINATOR&lt;/code&gt; and &lt;code&gt;Hasta la vista.&lt;/code&gt; But that breaks the fountain syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I need to do, to make this work? The plugin reedes/vim-textobj-sentence doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="13488" LastEditorUserId="13488" LastEditDate="2018-05-29T19:14:22.790" LastActivityDate="2018-06-02T23:34:41.093" Title="How can I delimit sentences by carriage return?" Tags="|visual-mode|object-motions|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16348" PostTypeId="2" ParentId="16345" CreationDate="2018-05-29T19:49:28.140" Score="4" Body="&lt;p&gt;If you tried reedes/vim-textobj-sentence, that (hopefully) means you have kana/vim-textobj-user installed. You can (mostly) trivially use this to define your own sentence. Treat this as a starting point for experimentation - it seems to work well enough, but clobbers search etc; I'm sure it can be handled more cleanly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LinewiseSentenceI()&#xA;  let ini_line = line('.')&#xA;  call search('\(^\|\.\_s\|\!\_s\|?\_s\)','b')&#xA;  call cursor(ini_line,getpos('.')[2])&#xA;  if getpos('.')[2] != 1&#xA;    normal! w&#xA;  endif&#xA;  let head_pos = getpos('.')&#xA;  normal! n&#xA;  let tail_pos = getpos('.')&#xA;  return ['v',head_pos,tail_pos]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This searches for sentence bounds by looking for the start of the line (&lt;code&gt;^&lt;/code&gt;), or a period, exclamation point, or question mark followed by whitespace or EOL (&lt;code&gt;|\.\_s\|\!\_s\|\?\_s\&lt;/code&gt;). If that position is not column one, then it's on the punctuation and we do a &lt;code&gt;w&lt;/code&gt; to get to the beginning of the sentence. Search in the other direction for tail boundary. Then we use kana/vim-textobj-user:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call textobj#user#plugin('lwsent',{'lwsent':{'select-i-function':'LinewiseSentenceI','select-i':'is',},})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read the documentation on kana/vim-textobj-user for ways to expand on this idea - this barebones demo only handles &lt;code&gt;is&lt;/code&gt; and not &lt;code&gt;as&lt;/code&gt;. And again, the function could likely be a lot cleaner, but this should be a good jumping-off point as to how to make kana/vim-textobj-user accomplish what you want. &lt;/p&gt;&#xA;" OwnerUserId="14684" LastEditorUserId="14684" LastEditDate="2018-05-30T01:27:34.220" LastActivityDate="2018-05-30T01:27:34.220" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="16349" PostTypeId="2" ParentId="16340" CreationDate="2018-05-29T20:37:38.763" Score="1" Body="&lt;p&gt;AFAIK you can't do this with an &lt;code&gt;autocmd&lt;/code&gt; since the only events that deal with shell commands occur &lt;em&gt;after&lt;/em&gt; the command executes. I can't think of a better way to do it than your solution. We can't easily overwrite it with &lt;code&gt;command!&lt;/code&gt; since &lt;code&gt;!&lt;/code&gt; isn't a valid command name (It would also might not be wise to completely remap it), but we can use a &lt;code&gt;cabbrev&lt;/code&gt;. Here's one way to do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev &amp;lt;expr&amp;gt; ! (getcmdtype() == ':' &amp;amp;&amp;amp; getcmdline() =~ '^!$')? '!clear &amp;amp;&amp;amp; !' : '!'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;getcmdtype() == ':'&lt;/code&gt;: Only works in for an Ex command (not in searches for example).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;getcmdline() =~ '^!$'&lt;/code&gt;: Only works at the beginning of the command line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Acnoreabbrev&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :cnoreabbrev&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getcmdtype%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help getcmdtype()&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getcmdline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help getcmdline()&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2018-05-29T20:37:38.763" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16350" PostTypeId="2" ParentId="16338" CreationDate="2018-05-29T21:09:54.080" Score="1" Body="&lt;p&gt;It doesn't look like this was made to be configurable unfortunately. This is from the plugin itself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('menu') &amp;amp;&amp;amp; &amp;amp;mouse != ''&#xA;    call s:InstallWinbar()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think your only options are to&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Make your own command that will quickly turn &lt;code&gt;mouse&lt;/code&gt; off and then back on again&lt;/li&gt;&#xA;&lt;li&gt;Comment out these two lines located in: &lt;code&gt;.../Vim/vim##/pack/dist/opt/termdebug/plugin/termdebug.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2018-05-29T21:09:54.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16351" PostTypeId="1" AcceptedAnswerId="16352" CreationDate="2018-05-30T00:40:19.483" Score="1" ViewCount="154" Body="&lt;p&gt;I am at a phase of cleaning up my choice of plugins and I want to read the documentation provided by a package through vim it self.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that in mind, I don't know a way to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;get to the top of the documentation for a specific package&lt;/li&gt;&#xA;&lt;li&gt;see find functions or 'g' settings for a package so that I can call &lt;code&gt;:h&lt;/code&gt; on them&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;An example of such is the package &lt;code&gt;elzr/vim-json&lt;/code&gt;. I don't know what functions or settings this package exposes. Auto-completing &lt;code&gt;:json&lt;/code&gt; or something gives nothing.&lt;/p&gt;&#xA;" OwnerUserId="14907" LastActivityDate="2018-05-30T01:50:32.643" Title="How do I get help for a specific package?" Tags="|functions|packages|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16352" PostTypeId="2" ParentId="16351" CreationDate="2018-05-30T01:50:32.643" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;A feature that isn't documented is a useless feature.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;:h design-documented&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In theory, you can do &lt;code&gt;:h local-additions&lt;/code&gt; (towards the bottom of &lt;code&gt;:h&lt;/code&gt;) which will show you an index of all local plugins that you have installed (if they included documentation).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;get to the top of the documentation for a specific package&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Most documentation you can do &lt;code&gt;:h {package-name}&lt;/code&gt; to get the documentation. You can use wildcards and tab completion to help you search. You may also like to use &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; list out completions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h win*(&amp;lt;tab&amp;gt;&#xA;:h win*(&amp;lt;c-d&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also search help files via &lt;code&gt;:helpgrep&lt;/code&gt; (similar to &lt;code&gt;:vimgrep&lt;/code&gt;). Use &lt;code&gt;:helpgrep /{pattern}/&lt;/code&gt; to search the helpfiles for &lt;code&gt;{pattern}&lt;/code&gt;. The results will be put into the quickfix list. Use &lt;code&gt;:cnext&lt;/code&gt;/&lt;code&gt;:cprev&lt;/code&gt; to go thought the list and &lt;code&gt;:copen&lt;/code&gt; to open the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;see find functions or 'g' settings for a package so that I can call :h on them&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is up to the documentation author to write good help tags otherwise you are at the mercy of reading the entire help file or searching.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An example of such is the package elzr/vim-json. I don't know what functions or settings this package exposes. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sadly, &lt;a href=&quot;https://github.com/elzr/vim-json&quot; rel=&quot;nofollow noreferrer&quot;&gt;elzr/vim-json&lt;/a&gt; does not ship with Vim help documentation. From what I can tell it only has a github readme file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I tend to avoid plugins that do not provide good Vim help documentation.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-05-30T01:50:32.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16353" PostTypeId="2" ParentId="16338" CreationDate="2018-05-30T06:18:46.927" Score="1" Body="&lt;p&gt;Don't know about hiding it from the start, but what works to remove it after it was added is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:aunmenu WinBar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I had one time where this did not work for some reason, but I cannot pinpoint the reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: It only works if you execute it in the window that has the toolbar&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note2: If you have other element in the window toolbar, those will get removed too. If you don't want this, you should explictly specify which elements to remove:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:aunmenu WinBar.Next&#xA;:aunmenu WinBar.Step&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc..&lt;/p&gt;&#xA;" OwnerUserId="14637" LastEditorUserId="14637" LastEditDate="2018-05-30T06:25:29.820" LastActivityDate="2018-05-30T06:25:29.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16354" PostTypeId="2" ParentId="16345" CreationDate="2018-05-30T13:38:06.600" Score="2" Body="&lt;p&gt;Update: Well, I made a plugin. Get it from &lt;a href=&quot;https://github.com/ctholho/vim-textobj-sentence-line&quot; rel=&quot;nofollow noreferrer&quot;&gt;ctholho/vim-textobj-sentence-line&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin supports &lt;code&gt;is&lt;/code&gt; and &lt;code&gt;as&lt;/code&gt; motions. I didn't test all possible conditions but it does the job reliably. It also remaps the &lt;code&gt;)&lt;/code&gt; and &lt;code&gt;(&lt;/code&gt; motion to behave in the same way. Thanks to brhfl whose answer provided the building blocks for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the answer of brhfl I cobbled something together that supports &lt;code&gt;is&lt;/code&gt; and &lt;code&gt;as&lt;/code&gt;. It still doesn't behave exactly like the old sentence text object and I post it here merely for completeness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;kana/vim-textobj-user&lt;/a&gt; and put this into your .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NewSentence_inner()&#xA;  call search('\(^\|\.\s\w\|\!\s\w\|?\s\w\)', 'bce')&#xA;  let head_pos = getpos('.')&#xA;  call search('\($\|\.\|\!\|?\)', 'ce')&#xA;  let tail_pos = getpos('.')&#xA;  return ['v',head_pos,tail_pos]&#xA;endfunction&#xA;&#xA;function! NewSentence_outer()&#xA;  call search('\(^\|\.\s\w\|\!\s\w\|?\s\w\)', 'bce')&#xA;  let head_pos = getpos('.')&#xA;  call search('\($\|\.\s\|\!\s\|?\s\)', 'e')&#xA;  let tail_pos = getpos('.')&#xA;  &quot; handle last sentence of line, except if it's the only one&#xA;  if col('.') == col('$') &amp;amp;&amp;amp; getline('.') =~ '\(.\+\(\.\|\!\|?\)\)\{2,}'&#xA;    let head_pos[2] = head_pos[2] - 1&#xA;    let tail_pos[2] = tail_pos[2] - 1&#xA;  endif&#xA;  return ['v',head_pos,tail_pos]&#xA;endfunction&#xA;&#xA;call textobj#user#plugin('fsent',{&#xA;\  'fsent':{&#xA;\     'select-i-function':'NewSentence_inner',&#xA;\     'select-i':'is',&#xA;\     'select-a-function':'NewSentence_outer',&#xA;\     'select-a':'as',&#xA;\   },&#xA;\})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;NewSentence_inner()&lt;/code&gt; looks for the beginning of a line, the end of a sentence. The flags &lt;code&gt;bce&lt;/code&gt; mean that it looks in reverse, accepts matches under the cursor and moves the cursor to the end of the match. To get &lt;code&gt;tail_pos&lt;/code&gt; it looks for punctiation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;NewSentence_outer()&lt;/code&gt; does the same but gives extra care to whitespace of the last sentence of a line.&#xA;&lt;code&gt;if col('.') == col('$') &amp;amp;&amp;amp; getline('.') =~ '\(.\+\(\.\|\!\|?\)\)\{2,}'&#xA;&lt;/code&gt; checks if it is at the last position of the line and if the line has at least two sentences. If that's the case the selection shifts one position to the left.&lt;/p&gt;&#xA;" OwnerUserId="13488" LastEditorUserId="13488" LastEditDate="2018-06-02T13:56:58.470" LastActivityDate="2018-06-02T13:56:58.470" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16355" PostTypeId="1" AcceptedAnswerId="16357" CreationDate="2018-05-30T17:42:28.823" Score="13" ViewCount="10175" Body="&lt;p&gt;I want to find the alternative to ctrl+R to search history in bash. I can enable vi mode in bash but I cannot make it search. When I do &lt;code&gt;/search&lt;/code&gt; or &lt;code&gt;?search&lt;/code&gt; nothing happens. Is there something more I should press? I tried press enter and then this happens:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ set -o vi&#xA;$ ls|grep f&#xA;$ /gr&#xA;-bash: /gr: No such file or directory&#xA;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7466" LastEditorUserId="7466" LastEditDate="2018-05-30T17:50:36.880" LastActivityDate="2020-03-08T11:37:47.643" Title="How to run the history search in Vi mode in bash" Tags="|bash|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16357" PostTypeId="2" ParentId="16355" CreationDate="2018-05-31T00:08:39.987" Score="27" Body="&lt;p&gt;There certainly is Vim style searching in bash/readline. In fact, your command line is essentially a scaled down version of the Vim editor with a significant number of Normal mode commands available to you. More on that in a sec but first Search. The key piece of information you need is that as you stare at that blinking cursor on your command line you are in the equivalent of Vim's Insert mode. So how do we get to Normal mode? By hitting &lt;kbd&gt;Esc&lt;/kbd&gt;, of course.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there hit &lt;kbd&gt;/&lt;/kbd&gt;, enter a search term and hit &lt;kbd&gt;Enter&lt;/kbd&gt;. Now you can use &lt;kbd&gt;n&lt;/kbd&gt; and &lt;kbd&gt;N&lt;/kbd&gt; to move back and forth through the results. (You'll effectively be searching backwards by default with &lt;code&gt;n&lt;/code&gt;...searching forwards from the start wouldn't give any results since there's no history in the future!)  To execute the current result as a command hit &lt;kbd&gt;Enter&lt;/kbd&gt; again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't forget that you're in Normal mode, though, so if you don't find what you're looking for and want to get back to entering text in Insert mode do what you usually do in Vim. Hitting &lt;kbd&gt;i&lt;/kbd&gt;, for example, will do it. Or you can use Vim command &lt;code&gt;C&lt;/code&gt; which will remove any text after the cursor and enter Insert mode, which is handy. (You can precede that with &lt;code&gt;0&lt;/code&gt; if you moved the cursor past the first column.) Or use &lt;code&gt;A&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;R&lt;/code&gt;, &lt;code&gt;s&lt;/code&gt;, &lt;code&gt;s&lt;/code&gt;, &lt;code&gt;I&lt;/code&gt;, &lt;code&gt;Ctrl-C&lt;/code&gt;...you get the picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides the various commands that enter Insert mode you get can navigate with &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;B&lt;/code&gt;, &lt;code&gt;e&lt;/code&gt;, &lt;code&gt;E&lt;/code&gt;, &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;W&lt;/code&gt;, &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;$&lt;/code&gt;, etc. Yank/delete/put are there, too, and you can use them in them in action+navigation commands like &lt;code&gt;yB&lt;/code&gt;, &lt;code&gt;c2e&lt;/code&gt;, &lt;code&gt;d$&lt;/code&gt;, etc.&lt;sup&gt;1&lt;/sup&gt; Finally, &lt;code&gt;u&lt;/code&gt;ndo works as well! Go ahead and try some other stuff yourself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and if you get a bit lost or, as happens to me once in a while, some funkiness with line wrapping scrambles your c/l you can drop the pretense and hit &lt;code&gt;v&lt;/code&gt;. This pulls your command line's contents into an actual instance of Vim so you can edit with a &lt;strong&gt;Fully Armed and Operational Text Editor&lt;/strong&gt;. Once done, &lt;code&gt;:wq&lt;/code&gt; to submit what you have to the shell for execution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;sub&gt;Alas, the operator+motion commands (&lt;code&gt;caw&lt;/code&gt;, &lt;code&gt;dis&lt;/code&gt;, &lt;code&gt;yap&lt;/code&gt;, etc.) aren't supported. But &lt;a href=&quot;https://vi.stackexchange.com/users/9020/ed-neville&quot;&gt;@EdNeville&lt;/a&gt;'s comment below has &lt;a href=&quot;http://www.usenix.org.uk/content/bash.html#input&quot; rel=&quot;noreferrer&quot;&gt;a link to some readline settings&lt;/a&gt; that will add seemingly every op-motion command there is as well as a number of others. You can really round out your command-line based Vim experience by adding them to your .inputrc file.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Additional Info&lt;/strong&gt;: You are not restricted to using just what &lt;code&gt;set -o vi&lt;/code&gt; or &lt;code&gt;set -o emacs&lt;/code&gt; gives you. You can use any of the available readline commands. I believe &lt;code&gt;Ctrl-R&lt;/code&gt; should be available even in Vim mode but if not you can try putting this in your &lt;code&gt;~/.inputrc&lt;/code&gt; ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set editing-mode vi&#xA;&quot;\C-r&quot;: reverse-search-history&#xA;&quot;\C-s&quot;: forward-search-history&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Better yet, you can add some otherwise unavailable commands like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;\C-o&quot;: operate-and-get-next&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this, once you have selected a command from history (e.g. via Vim search) hit &lt;code&gt;Ctrl-O&lt;/code&gt; instead of &lt;code&gt;Enter&lt;/code&gt; and Bash will run the command and insert the next command from history, ready to run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;em&gt;Readline Command Names&lt;/em&gt; section in the Bash manpage for complete list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(You can also configure these from the command line with the &lt;code&gt;bind&lt;/code&gt; command but I'm already getting too far afield here.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-03-08T11:37:47.643" LastActivityDate="2020-03-08T11:37:47.643" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="16358" PostTypeId="1" AcceptedAnswerId="16359" CreationDate="2018-05-31T13:36:39.617" Score="3" ViewCount="4230" Body="&lt;p&gt;Let's say, I want to search for email addresses and output them to a new file. What I can do so far with a help from another discussion is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/pattern/.w! &amp;gt;&amp;gt; output.txt &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that saves whole lines where search matches occur. Is it possible to extract just the matches (with possibility for them to be multiple on one line)? I would prefer a solution (if possible) without some additional plugins or macros.&lt;/p&gt;&#xA;" OwnerUserId="17702" LastEditorUserId="28" LastEditDate="2018-05-31T13:44:07.093" LastActivityDate="2020-10-15T12:15:34.690" Title="How to redirect search results into a new file?" Tags="|regular-expression|search|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16359" PostTypeId="2" ParentId="16358" CreationDate="2018-05-31T14:16:39.343" Score="7" Body="&lt;p&gt;This is a bit easier with &lt;code&gt;grep&lt;/code&gt; and the &lt;code&gt;--only-matching&lt;/code&gt;/&lt;code&gt;-o&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;grep -o 'pattern' file.txt &amp;gt; output.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use Vim's substitution as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.*\(pattern\).*/\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This approach will affect the current buffer though. It would probably be best to copy the file first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: these approachs assumes only 1 match per line&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-05-31T15:32:12.590" LastActivityDate="2018-05-31T15:32:12.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16360" PostTypeId="2" ParentId="16358" CreationDate="2018-05-31T14:24:26.977" Score="2" Body="&lt;p&gt;Peter's solution with &lt;code&gt;grep -o&lt;/code&gt; is the way to go IMO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet, for the sake of the exercise here is a 100% pure vim script solution&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; prepare the result variable to be of the right type&#xA;:let res = []&#xA;&quot; join all lines in a big string, and use `substitute` to fill the result with matches -- this is the only tricky part&#xA;:call substitute(join(getline(1,'$'), ' '), 'THE PATTERN', '\=add(res, submatch(0))', 'g')&#xA;&#xA;&quot; You can remove duplicates BTW with&#xA;:let res = uniq(sort(res))&#xA;&#xA;&quot; And save into a new file&#xA;:call writefile(res, 'FILENAME')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-06-01T11:28:30.203" LastActivityDate="2018-06-01T11:28:30.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16362" PostTypeId="1" CreationDate="2018-06-01T02:23:03.927" Score="3" ViewCount="245" Body="&lt;p&gt;So, I found &lt;a href=&quot;https://vi.stackexchange.com/a/10478/6108&quot;&gt;this useful answer&lt;/a&gt; about iterating &lt;em&gt;buffers&lt;/em&gt;; but due to the tabpage-specific duality of windows in Vim, I failed at adapting it to my needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus: how can I construct a boolean expression, determining whether or not &lt;em&gt;any&lt;/em&gt; (not just the current) window in the tabpage is in &lt;code&gt;&amp;amp;diff&lt;/code&gt;-mode?&lt;/p&gt;&#xA;" OwnerUserId="6108" LastEditorUserId="10604" LastEditDate="2021-01-10T23:22:06.303" LastActivityDate="2021-01-11T01:45:29.070" Title="How can I determine if *any* window in the current tabpage is in diff-mode?" Tags="|vimscript|vim-windows|vimdiff|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16363" PostTypeId="1" AcceptedAnswerId="16366" CreationDate="2018-06-01T03:16:46.340" Score="0" ViewCount="301" Body="&lt;p&gt;Whenever I run an :Ag search on my present working directory, the first entry in the returned results list is always automatically opened in the currently active pane. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to disable this from happening? I'd rather scroll through the result list then  to select which file, if any, I decide to open on screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help, if you need any more info please let me know!&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;VIM 8.0 &lt;/li&gt;&#xA;&lt;li&gt;Plug 'rking/ag.vim' &lt;/li&gt;&#xA;&lt;li&gt;sudo apt install silversearcher-ag&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14813" LastActivityDate="2018-06-01T06:43:58.390" Title="Any way to prevent :Ag search from automatically opening the first returned result?" Tags="|search|the-silver-searcher|plugin-ag.vim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16364" PostTypeId="2" ParentId="16362" CreationDate="2018-06-01T05:12:33.927" Score="7" Body="&lt;p&gt;You can sum up the values of &lt;code&gt;&amp;amp;diff&lt;/code&gt; for each window, and see if the total is &gt; 0:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let any_diff = 0&#xA;windo let any_diff += &amp;amp;diff&#xA;echo any_diff . ' windows in diff mode'&#xA;if any_diff &amp;gt; 0 | do stuff | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-06-01T05:12:33.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16366" PostTypeId="2" ParentId="16363" CreationDate="2018-06-01T06:43:58.390" Score="3" Body="&lt;p&gt;I don't have the plugin but if I'm reading &lt;a href=&quot;https://github.com/rking/ag.vim/blob/master/doc/ag.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;the docs&lt;/a&gt; correctly you just need to add bang &lt;code&gt;!&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Ag[!] [options] {pattern} [{directory}]                                  *:Ag*&#xA;&#xA;    Search recursively in {directory} (which defaults to the current&#xA;    directory) for the {pattern}. Behaves just like the |:grep| command, but&#xA;    will open the |Quickfix| window for you. **If [!] is not given the first&#xA;    error is jumped to.**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Seems to me that the inverse of the last sentence is the behavior you seek...IOW bang it.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-06-01T06:43:58.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16367" PostTypeId="1" AcceptedAnswerId="16368" CreationDate="2018-06-01T13:08:53.643" Score="0" ViewCount="158" Body="&lt;p&gt;When we have a buffer open, and we open a new one with &lt;code&gt;:split&lt;/code&gt; or &lt;code&gt;:vsplit&lt;/code&gt;, if in any opened window we execute &lt;code&gt;:bprev&lt;/code&gt; or &lt;code&gt;:bnext&lt;/code&gt;, we could have the same buffer open at the same time in both windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any option (if any I will try with a vimscript) to not have the same same buffer open in multiple windows (e.g. don't show it in the new window if it's already open in another one, all in the same tab) while cycling through buffer list ?&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="16280" LastEditDate="2018-06-01T20:18:55.003" LastActivityDate="2018-06-01T20:18:55.003" Title="Is it possible to not have the same buffer open in multiple windows?" Tags="|buffers|vim-windows|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16368" PostTypeId="2" ParentId="16367" CreationDate="2018-06-01T15:29:47.930" Score="2" Body="&lt;p&gt;You need these following functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BetterBufferNext() abort&#xA;&#xA;  for b in range(bufnr('%')+1, bufnr('$'))&#xA;    if buflisted(b) &amp;amp;&amp;amp; bufwinnr(b)==-1&#xA;      exe &quot;normal! :b&quot;.b.&quot;\&amp;lt;cr&amp;gt;&quot;&#xA;      return&#xA;    endif&#xA;  endfor&#xA;&#xA;  for b in range(1, bufnr('%')-1)&#xA;    if buflisted(b) &amp;amp;&amp;amp; bufwinnr(b)==-1&#xA;      exe &quot;normal! :b&quot;.b.&quot;\&amp;lt;cr&amp;gt;&quot;&#xA;      return&#xA;    endif&#xA;  endfor&#xA;&#xA;endfunction&#xA;&#xA;function! BetterBufferPrev() abort&#xA;&#xA;  for b in range(bufnr('%')-1, 1, -1)&#xA;    if buflisted(b) &amp;amp;&amp;amp; bufwinnr(b)==-1&#xA;      exe &quot;normal! :b&quot;.b.&quot;\&amp;lt;cr&amp;gt;&quot;&#xA;      return&#xA;    endif&#xA;  endfor&#xA;&#xA;  for b in range(bufnr('$'), bufnr('%')+1, -1)&#xA;    if buflisted(b) &amp;amp;&amp;amp; bufwinnr(b)==-1&#xA;      exe &quot;normal! :b&quot;.b.&quot;\&amp;lt;cr&amp;gt;&quot;&#xA;      return&#xA;    endif&#xA;  endfor&#xA;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;F7&amp;gt; :call BetterBufferPrev()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;F8&amp;gt; :call BetterBufferNext()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't use my horrible provided mappings, use your own. Maybe something like &lt;code&gt;[b&lt;/code&gt; and &lt;code&gt;]b&lt;/code&gt;. Or maybe even,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Bp call BetterBufferPrev()&#xA;command! Bn call BetterBufferNext()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2018-06-01T18:09:02.910" LastActivityDate="2018-06-01T18:09:02.910" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="16370" PostTypeId="1" CreationDate="2018-06-01T16:54:04.857" Score="5" ViewCount="347" Body="&lt;p&gt;I keep the &lt;code&gt;a&lt;/code&gt; formatoption in vim when I'm modifying markdown files, so my lines are automatically kept to &lt;code&gt;textwidth&lt;/code&gt; characters long, with automatic reformatting when I modify text. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make vim keep this behavior, but not reformat/join lines that are inside a triple-backtick code block? For example, consider the following file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Title&#xA;&#xA;Here's some content that vim is automatically wrapping to 60&#xA;characters long, because I have run :set textwidth=60 and&#xA;:set formatoptions+=a. However, when I'm in the codeblock&#xA;below, I would like vim to stop the automatic wrapping as&#xA;well as the line joining.  As it stands, this file would be&#xA;impossible to reproduce in vim with my current settings.&#xA;&#xA;```&#xA;def hello():&#xA;    print(&quot;Hello world&quot;)&#xA;```&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Trying to type that codeblock at the end gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;``` def hello(): print(&quot;Hello world&quot;) ```&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is my style of markdown abnormal? Do people just rely on manually turning off the &lt;code&gt;a&lt;/code&gt; formatoption when they're modifying a codeblock? Or am I missing an easy way of handling such codeblocks in markdown files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also recorded &lt;a href=&quot;https://asciinema.org/a/eBYB6hmd4JsN2Oy3XZtbZZzOD&quot; rel=&quot;noreferrer&quot;&gt;this asciinema video&lt;/a&gt; to illustrate the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="17718" LastActivityDate="2018-06-01T16:54:04.857" Title="How to stop vim from reformatting lines inside a codeblock in a markdown file?" Tags="|formatting|filetype-markdown|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16371" PostTypeId="2" ParentId="16345" CreationDate="2018-06-01T19:43:38.047" Score="0" Body="&lt;p&gt;For screenwriting formats you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vipoj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to select all the dialogue or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vipojvf.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{jjvf.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you really only want the first sentence.&lt;/p&gt;&#xA;" OwnerUserId="13731" LastEditorUserId="13731" LastEditDate="2018-06-01T19:48:38.850" LastActivityDate="2018-06-01T19:48:38.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16372" PostTypeId="1" CreationDate="2018-06-01T20:36:42.860" Score="1" ViewCount="90" Body="&lt;p&gt;I use the &lt;code&gt;a&lt;/code&gt; formatoption to make my text hard wrap, and the &lt;code&gt;n&lt;/code&gt; formatoption to recognize numbered lists.  The help says that the &lt;code&gt;n&lt;/code&gt; option should use the &lt;code&gt;formatlistpat&lt;/code&gt; regex to determine which lines not to mess with, but it doesn't seem to be working for me; vim is joining all my bulleted lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are the values of my options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;formatoptions=tqlran&#xA;textwidth=65&#xA;formatlistpat=^\s*\d\+\.\s\+\|^[-*+]\s\+\|^\[^\ze[^\]]\+\]:&#xA;filetype=markdown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, formatlistpat was &quot;Last set from usr/local/Cellar/vim/8.0.1650_1/share/vim/vim80/ftplugin/markdown.vim&quot;, so I know it's not just a matter of me not escaping the regex correctly when setting it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of the bad behavior can be seen &lt;a href=&quot;https://asciinema.org/a/KsfGZNBI48MNaAWhUmm1UV2dy?t=4&quot; rel=&quot;nofollow noreferrer&quot;&gt;in this video&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how I can make vim stop joining lines like this?&lt;/p&gt;&#xA;" OwnerUserId="17718" LastActivityDate="2018-06-01T20:36:42.860" Title="Why are my bulleted lines automatically joining?" Tags="|formatting|options|filetype-markdown|join|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16373" PostTypeId="1" AcceptedAnswerId="16374" CreationDate="2018-06-01T22:29:59.990" Score="3" ViewCount="303" Body="&lt;p&gt;Ok I must have missed something vital here. Can someone please tell me what the difference between using &lt;code&gt;&amp;quot;a&lt;/code&gt; and &lt;code&gt;@a&lt;/code&gt; is? All I know is that &lt;code&gt;@&lt;/code&gt; is used together with &lt;code&gt;:let&lt;/code&gt; and e.g. &lt;code&gt;:echo&lt;/code&gt; and &lt;code&gt;&amp;quot;&lt;/code&gt; is used when pasting.&lt;/p&gt;&#xA;&lt;p&gt;However I find no sources that explains the difference and what the prefixes mean.&lt;/p&gt;&#xA;" OwnerUserId="17720" LastEditorUserId="10604" LastEditDate="2020-06-24T21:14:49.623" LastActivityDate="2020-06-24T21:14:49.623" Title="Registers ” vs @" Tags="|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16374" PostTypeId="2" ParentId="16373" CreationDate="2018-06-01T23:33:38.820" Score="7" Body="&lt;p&gt;Note: all of the following information (and much more) can be found using &lt;code&gt;:help @&lt;/code&gt;, &lt;code&gt;:help &amp;quot;&lt;/code&gt;, &lt;code&gt;:help let-@&lt;/code&gt;, and &lt;code&gt;:help expr-register&lt;/code&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;quot;ap&lt;/code&gt;,&lt;code&gt;&amp;quot;ad&lt;/code&gt;, &amp;amp;c.: use register &lt;code&gt;a&lt;/code&gt; in a put from or delete to.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;@a&lt;/code&gt;: replay the contents of register &lt;code&gt;a&lt;/code&gt; as a sequence of normal commands&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:let @a = 'string'&lt;/code&gt;: assign a string to register a.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now, there is likely some confusion because &lt;code&gt;@&lt;/code&gt; and &lt;code&gt;&amp;quot;&lt;/code&gt; are occasionally interchangeable:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;quot;&amp;quot;p&lt;/code&gt;, &lt;code&gt;&amp;quot;@p&lt;/code&gt;, &lt;code&gt;p&lt;/code&gt;: put from register &lt;code&gt;&amp;quot;&lt;/code&gt;, this is called the &amp;quot;unnamed register,&amp;quot; but in fact it has at least two names, &lt;code&gt;&amp;quot;&lt;/code&gt; and &lt;code&gt;@&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;@&amp;quot;&lt;/code&gt;: replay the contents of register &lt;code&gt;&amp;quot;&lt;/code&gt; as a normal command (this is rarely done).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;@@&lt;/code&gt;: replay the previously used &lt;code&gt;@{reg}&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Then, there are the &lt;code&gt;let&lt;/code&gt; and expression usages:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:let @&amp;quot; = 'string'&lt;/code&gt;: &lt;code&gt;let @@ = 'string'&lt;/code&gt;: assign a string to register &lt;code&gt;&amp;quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:echo @@&lt;/code&gt;, &lt;code&gt;:echo @&amp;quot;&lt;/code&gt;: echo the value of register &lt;code&gt;&amp;quot;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:echo @&lt;/code&gt;: also echo the value of register &lt;code&gt;&amp;quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:echo &amp;quot;@&lt;/code&gt;, &lt;code&gt;:echo &amp;quot;&lt;/code&gt;: syntax error.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Finally, you can execute registers as an ex command (i.e., cmdline mode),&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:@a&lt;/code&gt;: execute contents of register &lt;code&gt;a&lt;/code&gt; as an ex command.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:@:&lt;/code&gt;: execute the previous command line&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:@@&lt;/code&gt;: execute the previous &lt;code&gt;:@{reg}&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="5439" LastEditDate="2020-06-24T17:02:16.737" LastActivityDate="2020-06-24T17:02:16.737" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16375" PostTypeId="2" ParentId="10814" CreationDate="2018-06-02T00:00:40.467" Score="0" Body="&lt;p&gt;I figured out how to solve this problem, more or less. I had a similar issue with some &lt;code&gt;CursorMoved&lt;/code&gt; autocommands that were rendering &lt;code&gt;CtrlP&lt;/code&gt; unusable; the author claims that &lt;a href=&quot;https://github.com/kien/ctrlp.vim/issues/543&quot; rel=&quot;nofollow noreferrer&quot;&gt;when CtrlP is opened all autocommands are disabled&lt;/a&gt; but it seems the suite of &lt;code&gt;Cursor*&lt;/code&gt; autocommands are not included in this list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my workaround:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EIoff()&#xA;  set eventignore=&#xA;endfunction&#xA;function! EIon()&#xA;  set eventignore=CursorHold,CursorHoldI,CursorMoved,CursorMovedI,TextChanged,TextChangedI&#xA;endfunction&#xA;function! EImap()&#xA;  nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;Esc&amp;gt; :q&amp;lt;CR&amp;gt;:EIoff&amp;lt;CR&amp;gt;&#xA;  nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;C-c&amp;gt; :q&amp;lt;CR&amp;gt;:EIoff&amp;lt;CR&amp;gt;&#xA;endfunction&#xA;command! EIon call EIon()&#xA;command! EIoff call EIoff()&#xA;command! EImap call EImap()&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-p&amp;gt; :EIon&amp;lt;CR&amp;gt;:CtrlP&amp;lt;CR&amp;gt;:EImap&amp;lt;CR&amp;gt;&#xA;let g:ctrlp_map=''&#xA;augroup eirestore&#xA;  au!&#xA;  au BufEnter * call EIoff()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, we override the default &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; mapping. The &lt;code&gt;EImap&lt;/code&gt; command sends a mapping to the CtrlP buffer (notice it comes after the &lt;code&gt;:CtrlP&lt;/code&gt;), so that if we re-enter the original buffer, the &lt;code&gt;Cursor*&lt;/code&gt; autocommands are turned back on. Cancelling CtrlP completion and re-entering the original buffer does not seem to trigger the &lt;code&gt;BufEnter&lt;/code&gt; autocommand. But if you open a &lt;em&gt;new&lt;/em&gt; file, the &lt;code&gt;BufEnter&lt;/code&gt; autocommand will indeed be triggered (hence the new autocommand). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using simply &lt;code&gt;:noautocmd CtrlP&lt;/code&gt; did not work. Using the enter/exit CtrlP functions  (for example, &lt;code&gt;let g:ctrlp_buffer_func={'enter':'EIon', 'exit':'EIoff'}&lt;/code&gt;; see documentation) did not work. Using &lt;code&gt;nnoremap &amp;lt;C-p&amp;gt; :CtrlP&amp;lt;CR&amp;gt;:setlocal eventignore=CursorMoved,CurHold...&amp;lt;CR&amp;gt;&lt;/code&gt; did not work for me because one of my autocommands was triggered right away upon entering the CtrlP buffer, resulting in an immediate error. Entering the buffer-local map of &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; as part of my &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; map à la &lt;code&gt;nnoremap &amp;lt;C-p&amp;gt; :CtrlP&amp;lt;CR&amp;gt;:nnoremap &amp;lt;Esc&amp;gt; &amp;lt;stuff&amp;gt;&lt;/code&gt; also doesn't work because the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; wants to be interpreted literally by the &quot;parent&quot; map of &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It was a pretty challenging/perplexing problem.&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2018-06-02T03:41:38.230" LastActivityDate="2018-06-02T03:41:38.230" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16376" PostTypeId="1" CreationDate="2018-06-02T06:49:43.033" Score="3" ViewCount="2264" Body="&lt;p&gt;I often write non-trivial mathematical formulas inside Markdown documents, and having them syntax-highlighted would really help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Markdown, LaTeX math formulae are denoted:&#xA;&lt;code&gt;$x^2$&lt;/code&gt; and &lt;code&gt;$$x^2$$&lt;/code&gt;, and are escaped as &lt;code&gt;\$x\$&lt;/code&gt;and &lt;code&gt;\$\$x\$\$&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Markdown math formulas are rendered via MathJax (to match future googlers' keywords).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use &lt;a href=&quot;https://github.com/plasticboy/vim-markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-markdown&lt;/a&gt; to syntax highlight the Markdown, how can I use &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt; to syntax highlight only the text inside the formulae?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I only want the text inside &lt;code&gt;$&lt;/code&gt; to be treated differently if the filetype is &lt;code&gt;markdown&lt;/code&gt; or &lt;code&gt;foobar&lt;/code&gt; (future proofing against my lack of VimL).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus:&lt;/strong&gt; I'd like the &lt;code&gt;$&lt;/code&gt; delimiters themselves to use the syntax highlight group &lt;code&gt;Statement&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Hints:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think these are along the right path, but I couldn't work out how the solution from them:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Perhaps &lt;a href=&quot;https://github.com/inkarkat/vim-SyntaxRange&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-SyntaxRange&lt;/a&gt; would help. (I couldn't work out how to set it up with the delimiters.)&lt;/li&gt;&#xA;&lt;li&gt;vim wikia's &lt;a href=&quot;http://vim.wikia.com/wiki/Different_syntax_highlighting_within_regions_of_a_file&quot; rel=&quot;nofollow noreferrer&quot;&gt;Different syntax highlighting within regions of a file&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://stsievert.com/blog/2016/01/06/vim-jekyll-mathjax/&quot; rel=&quot;nofollow noreferrer&quot;&gt;This code&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Block math. Look for &quot;$$[anything]$$&quot;&#xA;syn region math start=/\$\$/ end=/\$\$/&#xA;&quot; Inline math. Look for &quot;$[not $][anything]$&quot;&#xA;syn match math_block '\$[^$].\{-}\$'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2018-06-02T07:07:03.983" LastActivityDate="2018-06-02T12:44:24.367" Title="Syntax highlight Markdown formulas using LaTeX highlighting" Tags="|syntax-highlighting|filetype-tex|filetype-markdown|filetype-mathjax|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16379" PostTypeId="1" AcceptedAnswerId="16389" CreationDate="2018-06-02T12:11:27.177" Score="10" ViewCount="1206" Body="&lt;p&gt;Here is how I reproduce the behavior I am observing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I enter this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo aaaaa &amp;gt; a&#xA;vim a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Vim, I enter these commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls&#xA;:e #&#xA;:echo bufname('#')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the output of the above three commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls&#xA;  1 %a   &quot;a&quot;                            line 1&#xA;&#xA;:e #&#xA;E194: No alternate file name to substitute for '#'&#xA;&#xA;:echo bufname('#')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;bufname('#')&lt;/code&gt; command produces no output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I enter this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bd #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The current buffer is deleted and it is replaced with a &quot;[No Name]&quot; buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls&#xA;  2 %a   &quot;[No Name]&quot;                    line 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was expecting to get the &lt;code&gt;E194&lt;/code&gt; error on executing &lt;code&gt;:bd #&lt;/code&gt;. Why did it delete the current buffer instead?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;code&gt;VIM - Vi IMproved 8.0&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17725" LastActivityDate="2020-08-17T18:00:48.590" Title="Why does :bd # delete the current buffer when no alternate buffer exists?" Tags="|buffers|vim-windows|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16380" PostTypeId="2" ParentId="16376" CreationDate="2018-06-02T12:44:24.367" Score="1" Body="&lt;p&gt;I don't use &lt;em&gt;vim-Markdown&lt;/em&gt;, but just by skimming over its readme, I found its &lt;a href=&quot;https://github.com/plasticboy/vim-markdown/blob/master/README.md#latex-math&quot; rel=&quot;nofollow noreferrer&quot;&gt;syntax extension for LaTeX math&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Used as &lt;code&gt;$x^2$&lt;/code&gt;, &lt;code&gt;$$x^2$$&lt;/code&gt;, escapable as &lt;code&gt;\$x\$&lt;/code&gt; and &lt;code&gt;\$\$x\$\$&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vim_markdown_math = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The plugin code uses &lt;code&gt;:syntax include&lt;/code&gt; of the &lt;em&gt;tex&lt;/em&gt; syntax, just like you also could do with my &lt;a href=&quot;http://github.com/inkarkat/vim-SyntaxRange&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-SyntaxRange plugin&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-06-02T12:44:24.367" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16382" PostTypeId="1" CreationDate="2018-06-02T21:43:49.113" Score="1" ViewCount="594" Body="&lt;p&gt;Is there anything wrong with opening up a new vim tab (for scratch work) while authoring a git commit?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Update: This Seems to Be a Quirk With Vi vs. Vim&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;On further inspection prompted by &lt;a href=&quot;https://vi.stackexchange.com/users/205/muru&quot;&gt;@muru&lt;/a&gt;'s comment, it seems there are a couple of subtleties here.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The &lt;code&gt;EDITOR&lt;/code&gt; environment variable was actually unset, so it defaulted to &lt;code&gt;vi&lt;/code&gt; instead of &lt;code&gt;vim&lt;/code&gt; as originally posted. Edited.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In order for vi to exit with error, it is actually important to &lt;em&gt;attempt to quit first&lt;/em&gt; with &lt;code&gt;:q&lt;/code&gt; before using &lt;code&gt;:q!&lt;/code&gt;, and this behavior can be reproduced without using tabs:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Launch vi:&lt;br&gt;&#xA;&lt;code&gt;vi; echo $?&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Type something in insert mode&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Attempt to quit with &lt;code&gt;:q&lt;/code&gt; and get the error &lt;code&gt;E37: No write since last change (add ! to override)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Actually quit with &lt;code&gt;:q!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Observe that the exit code is &lt;code&gt;1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Oddly enough, modifying the above steps by (1) using vim instead of vi, or (2) using vi but quitting with &lt;code&gt;:q!&lt;/code&gt; directly without using &lt;code&gt;:q&lt;/code&gt; first, yields a &lt;code&gt;0&lt;/code&gt; exit code instead. Both &lt;code&gt;vi&lt;/code&gt; and &lt;code&gt;vim&lt;/code&gt; have the same exact &lt;code&gt;:version&lt;/code&gt; string on my system, so this is probably a difference in how vim behaves when started as &lt;code&gt;vi&lt;/code&gt; on the command-line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;Original Steps with Git + Vi&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Steps to reproduce:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Start making a new commit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ export EDITOR=vi  # goes without saying :)&#xA;$ git commit&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Open up a new tab with &lt;code&gt;:tabe&lt;/code&gt; and type something. Anything.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Switch back to the commit tab with &lt;code&gt;gt&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Type some message, and close the commit tab with &lt;code&gt;:x&lt;/code&gt; (writing changes).&lt;/li&gt;&#xA;&lt;li&gt;Now, attempt to quit the tab with &lt;code&gt;:q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Now, quit the scratch tab with &lt;code&gt;:q!&lt;/code&gt; (discarding changes).&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Recoil as vi tells you your meticulously-crafted commit message has &lt;em&gt;also&lt;/em&gt; been discarded: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: There was a problem with the editor 'vi'.&#xA;Please supply the message using either -m or -F option.&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;What is Git not happy with in this seemingly innocuous series of steps?&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;(This gets confusing because I'm testing Vim's behavior, not Vi's)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's exit code indicates success when repeating the above instructions, so it's not clear why Git thinks Vim quit in error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim a-file; echo &quot;exit code: $?&quot;&#xA;exit code: 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;^ This example is identical to how Git launches Vim, given its process entry in that state:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/bin/vi /path/to/git/repo/.git/COMMIT_EDITMSG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Also, swapping the tab exit order by closing the scratch tab first, then the commit tab, has exactly the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Coming back to the million-dollar question—why is this happening? Answers in the form of snarky references to the Vim/Git docs are most welcome &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;System:&lt;/strong&gt; macOS High Sierra 10.13.4&lt;br&gt;&#xA;&lt;strong&gt;vim :version:&lt;/strong&gt; &lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46)&lt;/code&gt;&lt;br&gt;&#xA;&lt;strong&gt;git --version:&lt;/strong&gt; &lt;code&gt;git version 2.15.1 (Apple Git-101)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="17188" LastEditorUserId="17188" LastEditDate="2018-06-04T17:06:48.827" LastActivityDate="2018-06-04T17:06:48.827" Title="Why does Git think Vi quit in error?" Tags="|git|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16383" PostTypeId="2" ParentId="16345" CreationDate="2018-06-02T23:34:41.093" Score="0" Body="&lt;p&gt;In normal mode use the visual area over the first sentence on the second line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This area now includes the the line above (as you know) and the cursor is at the bottom right of the area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now while in visual mode, move the curser to the beginning (other end) of the visual area and then move the cursor down to the beginning of the sentence you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;oj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first sentence on the second line is now in the visual area. So combined the commands are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;visoj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No plug in required.&lt;/p&gt;&#xA;" OwnerUserId="12736" LastActivityDate="2018-06-02T23:34:41.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16384" PostTypeId="1" CreationDate="2018-06-03T00:16:51.790" Score="0" ViewCount="641" Body="&lt;p&gt;Is there a way to call arbitrary vimscript functions when the first keypress is made by the user?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking to lazily start-up plug-in when the user starts using vim. This is to save resources when user may start up lots of vims and then not interact with it, for example when using &lt;code&gt;tmux-resurrect&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11136" LastActivityDate="2018-10-02T23:51:04.250" Title="Call vimscript function on first keypress" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16385" PostTypeId="1" CreationDate="2018-06-03T04:56:10.153" Score="1" ViewCount="247" Body="&lt;p&gt;I usually always have only two vertical splits open. One I use for actual coding and the other for reference. I would like to be able to search for tag  in Window1 and have the result appear in Window2. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="7260" LastActivityDate="2018-06-03T04:56:10.153" Title="How do I open a tag with &lt;C-]&gt; but open it in an existing split?" Tags="|vim-windows|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="16386" PostTypeId="1" CreationDate="2018-06-03T04:57:40.183" Score="3" ViewCount="5742" Body="&lt;p&gt;gvim 8 1-26 / windows 10&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to use Windows Subsystem Linux (WSL)'s bash shell as a gvim's terminal instead of &lt;code&gt;cmd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if I type in command potion of gvim: &lt;code&gt;:!.\test.sh&lt;/code&gt;, it will echo result inside of gvim terminal - wsl's bash shell (not open a &lt;code&gt;cmd&lt;/code&gt; window, login to bash, and then run &lt;code&gt;test.sh&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Expected result would be similar to run vim inside a terminal in a linux distribution (for i.e &lt;code&gt;vim&lt;/code&gt; under &lt;code&gt;urxvt-unicode&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="1292" LastEditDate="2018-08-30T09:08:34.220" LastActivityDate="2023-07-13T18:07:12.060" Title="How to use WSL's bash shell as default terminal of gvim/windows 10?" Tags="|gvim|terminal|microsoft-windows|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16387" PostTypeId="2" ParentId="16386" CreationDate="2018-06-03T11:12:15.913" Score="1" Body="&lt;p&gt;You should be able to accomplish this simply by assigning to the &lt;code&gt;'shell'&lt;/code&gt; setting the path of whatever Bash binary you are using. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a similar setup with Gvim + Cygwin and this is what I have in my &lt;code&gt;_vimrc&lt;/code&gt; file...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shell=c:\cygwin64\bin\bash.exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may need to add a bit extra if the bare shell launched by the above has, let's say, an empty PATH environment variable. For example, you could specify a bash init file like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shell='c:\cygwin64\bin\bash.exe --rcfile /foo/bar/mybashrc'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and define PATH in &lt;code&gt;mybashrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's &lt;a href=&quot;https://vi.stackexchange.com/a/16193/11054&quot;&gt;an earlier answer of mine&lt;/a&gt; that touches upon a somewhat related topic that you can read if you need more help choosing the correct bash parameters.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-06-03T11:12:15.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16388" PostTypeId="2" ParentId="16384" CreationDate="2018-06-03T11:40:44.457" Score="2" Body="&lt;p&gt;Okay, so the specific ask is how to avoid loading plugins if Vim is launched but not interacted with by a user or, IOW, how to do lazy-loading of plugins, triggered by user activity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most obvious way that comes to mind requires that you move all of the applicable plugin directories to &lt;code&gt;pack/plugins/opt&lt;/code&gt; under &lt;code&gt;~/.vim&lt;/code&gt; (or wherever you keep your personal vim configuration). Vim does not automatically load plugins unless they are in &lt;code&gt;pack/*/start&lt;/code&gt;. It will load plugins on-demand if they are located in &lt;code&gt;pack/*/opt&lt;/code&gt;. This is done with the &lt;code&gt;packadd&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So move the plugins and then add something like this autocommand to your vimrc...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorMoved,CursorMovedI * \&#xA;    packadd plugin-name-1 | \&#xA;    packadd plugin-name-2 | \&#xA;    ...&#xA;    packadd plugin-name-n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...meaning you have a &lt;code&gt;packadd&lt;/code&gt; line for each plugin that was moved. Specifically, replace &lt;code&gt;plugin-name-#&lt;/code&gt; with an actual plugin directory name (e.g. &lt;code&gt;vim-fugitive&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be pretty clear what this does. As soon as one of the specified events occurs (i.e. the user moves the cursor) each listed plugin will be loaded. You might need to play around with the actual event or events you use...the two &lt;code&gt;CursorMoved&lt;/code&gt; events seem like a good start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some refinements that you'll probably want to do if this involves a large number of plugins. For instance, put the packadd calls in a function and call the function from the auto command. Then you can guard the packadd calls with a flag and prevent them from being executed more than once. (Something to consider if there's a noticeable performance hit from running the group of &lt;code&gt;packadd&lt;/code&gt; commands repeatedly.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h packadd&lt;/code&gt;, &lt;code&gt;:h autocommand&lt;/code&gt;, &lt;code&gt;:h autocommand-events&lt;/code&gt; for some of the major pieces here.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-10-02T23:51:04.250" LastActivityDate="2018-10-02T23:51:04.250" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16389" PostTypeId="2" ParentId="16379" CreationDate="2018-06-03T12:02:05.127" Score="8" Body="&lt;h2&gt;Evidence&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Because there is no alternate file you're actually just running plain ol' &lt;code&gt;:bd&lt;/code&gt;, deleting the current buffer...try it without &lt;code&gt;#&lt;/code&gt; and you'll see the result is the same. A similar thing happens with &lt;code&gt;:buffer&lt;/code&gt;, &lt;code&gt;:sbuffer&lt;/code&gt; and at least a couple other commands that accept &lt;code&gt;#&lt;/code&gt; as an argument: they silently behave as if no arguments were passed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Along the same lines, if you try &lt;code&gt;:bunload #&lt;/code&gt; you get this error: &lt;code&gt;E90: Cannot unload last buffer&lt;/code&gt;. Run &lt;code&gt;:bunload&lt;/code&gt; with no arguments and, once again, you'll get the same result. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The Docs&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;So we have evidence that &lt;code&gt;#&lt;/code&gt; is being replaced by &quot;nothing&quot; (probably an empty string). Where do we go from here? I poked around the help files for a while trying to find mention of this behavior. There was nothing explicit but &lt;code&gt;:h cmdline-lines&lt;/code&gt; says (scroll down a page or two) ...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the character '%' or '#' is used where a file name is expected, they are expanded to the current and alternate file name. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I read that as Vim putting &lt;code&gt;#&lt;/code&gt; through the &lt;code&gt;expand()&lt;/code&gt; function (i.e. &lt;code&gt;expand('#')&lt;/code&gt;) or at least the same underlying code used there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h expand()&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Expand .. special keywords. .. When using '%' or '#', and the current or alternate file name is not defined, an empty string is used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sounds familiar.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The Code&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Now none of the above is definitive or gives a clue as to &lt;em&gt;Why?&lt;/em&gt; so I spent some more time digging...this time in the code. My C is very rusty and I don't have any good tools installed but I managed to find a function that does some setup for &lt;code&gt;:bdelete&lt;/code&gt; called &lt;code&gt;do_bufdel()&lt;/code&gt;. This sends command line arguments through &lt;code&gt;buflist_findpat()&lt;/code&gt; which, if &lt;code&gt;#&lt;/code&gt; is encountered, returns value &lt;code&gt;curwin-&amp;gt;w_alt_fnum&lt;/code&gt;. That's the &quot;buffer number&quot; of the alternate buffer...which can't be a positive value in our scenario. (There's no check for whether the alt file is valid/exists before that return value is selected.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Back out in &lt;code&gt;do_bufdel()&lt;/code&gt; a check is made against that return value for a buffer number less than 0 in which case the parameter processing loop is broken out of. That would result in no parameters being presented to the core &lt;code&gt;:bdelete&lt;/code&gt; code...which is right in line with my earlier intuitions.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What's Next?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It appears to be working as designed in that I didn't see anything that looked like a clear bug. Possibly sin of omission, though...a corner case that has been overlooked and thus has no graceful handling. But only the developers that wrote this know for sure. So the final step would be to try to get their input. As &lt;a href=&quot;https://vi.stackexchange.com/questions/16379/why-does-bd-delete-the-current-buffer-when-no-alternate-buffer-exists/16389#comment28214_16389&quot;&gt;Christian B. said&lt;/a&gt; asking on the vim-dev list is the way to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note that &lt;code&gt;buflist_findpat()&lt;/code&gt; is a utility function so it wouldn't require a stretch of the imagination to assume that &lt;code&gt;:bunload&lt;/code&gt;, &lt;code&gt;:buffer&lt;/code&gt;, etc. are using it, too...that would explain their common behavior with respect to &lt;code&gt;#&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-06-12T03:37:41.970" LastActivityDate="2018-06-12T03:37:41.970" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16390" PostTypeId="1" AcceptedAnswerId="16391" CreationDate="2018-06-03T19:53:37.860" Score="0" ViewCount="212" Body="&lt;p&gt;I am trying to set up vim so I can get different functions in with different files (i.e. x.lisp and x.scm) and in the manual it says starting with the option &quot;-u ufile&quot;  uses &quot;ufile&quot; as the vimrc &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that the &quot;-u ufile&quot; option does not work as expected. The shortcut for &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; , instead of executing the commands it literally prints out &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is the exact code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :inoremap &amp;lt;C-h&amp;gt; &amp;lt;C-X&amp;gt;&amp;lt;C-O&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;this works in the .vimrc file but does nothing on the -u ufile.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :inoremap ^^ &amp;lt;C-X&amp;gt;&amp;lt;C-O&amp;gt;   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;this works in the .vimrc file but literally prints out &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; on the -u ufile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something wrong with the -u option or am I not understanding the manual correctly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note:&#xA;I have managed to do what I want using the  &quot;-s sfile&quot; option, (even though it messes up my history somewhat) but to comment i need to use '| # &quot;comment ' otherwise it is read as well for some reason. I am still curious as to why the -u option does not work.&lt;/p&gt;&#xA;" OwnerUserId="16037" LastEditorUserId="16037" LastEditDate="2018-06-03T20:02:25.097" LastActivityDate="2018-06-04T01:18:05.883" Title="&quot;-u {vimrc}&quot; not working as expected" Tags="|vimrc|command-line|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16391" PostTypeId="2" ParentId="16390" CreationDate="2018-06-04T01:18:05.883" Score="0" Body="&lt;p&gt;if you start vim with -u {vimrc} then vim will not automatically switch off compatibility mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to have &lt;code&gt;set nocp&lt;/code&gt; in your ufile (best as the first line)&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-06-04T01:18:05.883" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16392" PostTypeId="1" AcceptedAnswerId="16393" CreationDate="2018-06-04T02:12:15.433" Score="6" ViewCount="5192" Body="&lt;p&gt;My version is : NVIM v0.3.0-dev&lt;/p&gt;&#xA;&lt;p&gt;I'm trying to replace  mappings with w mappings. Initially I came up with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;w &amp;lt;c-w&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;wb &amp;lt;c-w&amp;gt;s&#xA;nnoremap &amp;lt;leader&amp;gt;ws &amp;lt;nop&amp;gt;&#xA;unmap &amp;lt;c-w&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But it didn't work. I didn't have any  mappings with w. After a minute I came up with this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;w &amp;lt;c-w&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;wb &amp;lt;c-w&amp;gt;s&#xA;nnoremap &amp;lt;leader&amp;gt;ws &amp;lt;nop&amp;gt;&#xA;nnoremap &amp;lt;c-w&amp;gt; &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This works as I expect it to. I was just wondering why my previous attempt didn't bear fruit. What's the difference between unmap and nnoremap to &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; ?  And what is the convention to this sort of things.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;N.B&lt;/strong&gt;: I want to unmap cause I'm used to those default keymaps, but I'm having pinky issues with &lt;kbd&gt;ctrl&lt;/kbd&gt; lately. So, I want to train myself to use  mappings instead.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="10604" LastEditDate="2022-02-17T18:21:17.950" LastActivityDate="2022-02-21T02:58:44.620" Title="What is the difference between unmap and mapping to &lt;Nop&gt;?" Tags="|key-bindings|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16393" PostTypeId="2" ParentId="16392" CreationDate="2018-06-04T03:19:46.943" Score="7" Body="&lt;p&gt;It is important to first understand that &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; is not a map but a built-in command when vim is operating in a particular mode.  It is often referred to as a &quot;normal command&quot; since one uses it in normal mode&lt;sup&gt;1&lt;/sup&gt;, and it can be  triggered using the &lt;code&gt;:normal!&lt;/code&gt; command.  There is no mapping involved; the normal commands are hard coded in C.  If you open up &lt;a href=&quot;https://github.com/vim/vim/blob/c8523e2e6cd072d86a9412f465aa9eef53f5675e/src/normal.c#L244&quot; rel=&quot;noreferrer&quot;&gt;normal.c&lt;/a&gt;, you can see the character &lt;code&gt;^W&lt;/code&gt; is to associated with the function &lt;code&gt;nv_window&lt;/code&gt; in a large, fixed, data table of normal commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although mappings allow you to override default behavior, you cannot change the built-ins and they can always be accessed using &lt;code&gt;noremap&lt;/code&gt;, &lt;code&gt;:normal!&lt;/code&gt;, &lt;code&gt;feedkeys(..,'n')&lt;/code&gt;, etc.  When vim is processing input when mappings are allowed, such as in &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;:normal&lt;/code&gt;, &lt;code&gt;feedkeys(..,'m')&lt;/code&gt;, it first checks if there are any mappings which match, then continues processing normal commands or until an invalid sequence is encountered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This explains why you cannot &lt;code&gt;unmap&lt;/code&gt; a built-in normal command and why you &lt;em&gt;can&lt;/em&gt; &lt;code&gt;nnoremap&lt;/code&gt; to a &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt;, which is specifically designed for this purpose.  Why would you choose &lt;code&gt;nnoremap&lt;/code&gt; instead of &lt;code&gt;nmap&lt;/code&gt; in this case?  Well, there's not a great reason, but the convention is to use &lt;code&gt;*noremap&lt;/code&gt; always, unless you &lt;em&gt;really&lt;/em&gt; need remapping.  A good example of when to use an &lt;code&gt;nmap&lt;/code&gt; is those to &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mappings in a plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Side note: you might wonder why there are the &lt;code&gt;:map&lt;/code&gt; and &lt;code&gt;:map!&lt;/code&gt; forms in addition to &lt;code&gt;nmap&lt;/code&gt;, &lt;code&gt;vmap&lt;/code&gt;, etc.  Originally, in vi there were two main modes; (normal) command and insert, so having two forms made sense.  However, to write robust code, it is almost always better to spell it out in each mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;1. At one time normal mode was referred to as command mode and visual mode, but forget about this entirely.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-06-04T03:19:46.943" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16396" PostTypeId="1" AcceptedAnswerId="16467" CreationDate="2018-06-04T11:06:42.360" Score="2" ViewCount="10159" Body="&lt;p&gt;I installed &lt;strong&gt;&lt;a href=&quot;https://github.com/neovim/neovim/wiki/Installing-Neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neovim&lt;/a&gt;&lt;/strong&gt; on Windows 8.1 using Chocolatey. &#xA;But the problem is I cannot see any &lt;strong&gt;color scheme&lt;/strong&gt; as shown in the tutorials.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have cloned a &lt;a href=&quot;https://github.com/flazz/vim-colorschemes&quot; rel=&quot;nofollow noreferrer&quot;&gt;repo&lt;/a&gt; from &lt;code&gt;GitHub&lt;/code&gt; to &lt;code&gt;~/.config/nvim/colors/&lt;/code&gt; and it has all the colors including &lt;code&gt;hybrid&lt;/code&gt;.&#xA;But when I included it into &lt;code&gt;init.vim&lt;/code&gt; file this is the error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9kVy0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9kVy0.png&quot; alt=&quot;Nvim error&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17123" LastEditorUserId="17123" LastEditDate="2018-06-04T16:33:59.023" LastActivityDate="2018-06-11T15:36:15.637" Title="Cannot find color scheme error in Neovim" Tags="|neovim|microsoft-windows|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="16397" PostTypeId="2" ParentId="6366" CreationDate="2018-06-05T08:09:50.933" Score="1" Body="&lt;p&gt;If you add to your &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ffs=unix&#xA;set list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will always show &lt;code&gt;CR&lt;/code&gt; as &lt;code&gt;^M&lt;/code&gt; and &lt;code&gt;LF&lt;/code&gt; as &lt;code&gt;$&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, vim would interpret a file that only has &lt;code&gt;CRLF&lt;/code&gt; endings as a dos file and show &lt;code&gt;CRLF&lt;/code&gt; as &lt;code&gt;$&lt;/code&gt;. By setting &lt;code&gt;ffs=unix&lt;/code&gt;, you force vim to always open as a unix file, and therefore the CR is treated as an extra character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Be careful if modifying and saving dos files though. If you press &lt;code&gt;ENTER&lt;/code&gt;, it will only insert a &lt;code&gt;LF&lt;/code&gt;. You would need to manually insert a &lt;code&gt;CR&lt;/code&gt; by typing &lt;code&gt;CTRL+V, CTRL+M&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6610" LastActivityDate="2018-06-05T08:09:50.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16400" PostTypeId="1" CreationDate="2018-06-05T16:40:08.507" Score="2" ViewCount="53" Body="&lt;p&gt;In C, YouCompleteMe could autocomplte the function if I include the header file in code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4Dn2u.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4Dn2u.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want it work like C, when I write Go code and include the C header file in cgo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Yenkj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Yenkj.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how should I config YouCompleteMe? thx.&lt;/p&gt;&#xA;" OwnerUserId="17756" LastActivityDate="2018-09-13T23:15:15.747" Title="How to make YouCompleteMe work with cgo" Tags="|vimscript|plugin-you-complete-me|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16403" PostTypeId="1" AcceptedAnswerId="16407" CreationDate="2018-06-05T19:46:21.370" Score="11" ViewCount="6456" Body="&lt;p&gt;When using vim as my default editor, I (occasionally) accidentally pull up search (e.g. via &lt;code&gt;/wq&lt;/code&gt; instead of &lt;code&gt;:wq&lt;/code&gt;). Once I do, I escape out of search, and then exit correctly via &lt;code&gt;:wq&lt;/code&gt;. However, when that happens, I see the following error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; hint: Waiting for your editor to close the file... error: There was a problem with the editor 'vi'.&#xA; Please supply the message using either -m or -F option.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to understand why vi is not exiting correctly, or how I can fix it to exit correctly even after a failed search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using macOS High Sierra.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46)&#xA; Included patches: 1-503, 505-680, 682-1283&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Steps to reproduce:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &amp;gt; git commit&#xA; vim&amp;gt; i&#xA; vim&amp;gt; My Commit Message&#xA; vim&amp;gt; &amp;lt;Esc&amp;gt;&#xA; vim&amp;gt; /wq&#xA; vim&amp;gt; &amp;lt;Esc&amp;gt;&#xA; vim&amp;gt; :wq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help.&lt;/p&gt;&#xA;" OwnerUserId="17757" LastActivityDate="2023-05-21T03:37:29.037" Title="Vim Error for Git Commit Message" Tags="|save|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16404" PostTypeId="1" CreationDate="2018-06-05T20:30:16.637" Score="0" ViewCount="193" Body="&lt;p&gt;I have this in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:mapleader = &quot;,&quot;&#xA;nnoremap # ,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I use , as my leader, and want to use # for backwards search after f,t...But my # mapping does not work, so something is amiss&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks&lt;/p&gt;&#xA;" OwnerUserId="590" LastActivityDate="2018-06-05T21:55:18.857" Title="map something to the action of the leader key?" Tags="|key-bindings|search|leader|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16405" PostTypeId="2" ParentId="16404" CreationDate="2018-06-05T21:55:18.857" Score="1" Body="&lt;p&gt;To set your leader key, you must use &lt;code&gt;let mapleader = &quot;,&quot;&lt;/code&gt; not &lt;code&gt;let g:mapleader = &quot;,&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h &amp;lt;leader&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                    *&amp;lt;Leader&amp;gt;* *mapleader*&#xA;To define a mapping which uses the &quot;mapleader&quot; variable, the special string&#xA;&quot;&amp;lt;Leader&amp;gt;&quot; can be used.  It is replaced with the string value of &quot;mapleader&quot;.&#xA;If &quot;mapleader&quot; is not set or empty, a backslash is used instead.  Example: &amp;gt;&#xA;    :map &amp;lt;Leader&amp;gt;A  oanother line&amp;lt;Esc&amp;gt;&#xA;Works like: &amp;gt;&#xA;    :map \A  oanother line&amp;lt;Esc&amp;gt;&#xA;But after: &amp;gt;&#xA;    :let mapleader = &quot;,&quot;&#xA;It works like: &amp;gt;&#xA;    :map ,A  oanother line&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for using &lt;code&gt;nnoremap &amp;lt;something&amp;gt; &amp;lt;leader&amp;gt;&lt;/code&gt; like you did, this causes no issues for me. Make sure you don't have some other mapping by running the command: &lt;code&gt;nnoremap ,&lt;/code&gt;. It should print &lt;code&gt;No mapping found&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-06-05T21:55:18.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16406" PostTypeId="2" ParentId="358" CreationDate="2018-06-05T22:01:04.320" Score="14" Body="&lt;p&gt;You can move the help screen to its own tab with&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ctrl+w T&lt;/code&gt; (note the &lt;code&gt;T&lt;/code&gt; is upper case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can switch between the tabs with &lt;code&gt;gt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6610" LastActivityDate="2018-06-05T22:01:04.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16407" PostTypeId="2" ParentId="16403" CreationDate="2018-06-05T23:06:05.363" Score="12" Body="&lt;p&gt;It is possible that you have &lt;code&gt;EDITOR&lt;/code&gt; left unset or to its default value of &lt;code&gt;vi&lt;/code&gt;. Try making &lt;code&gt;vim&lt;/code&gt; your editor. Although both &lt;code&gt;vi&lt;/code&gt; and &lt;code&gt;vim&lt;/code&gt; are the same executable in mac, I guess, vim behaves in a minimalist way when invoked as vi than vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;git config --global core.editor /usr/bin/vim&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="15320" LastActivityDate="2018-06-05T23:06:05.363" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16408" PostTypeId="2" ParentId="2572" CreationDate="2018-06-06T00:02:47.353" Score="3" Body="&lt;p&gt;I tried &lt;code&gt;has('unix')&lt;/code&gt;, but I didn't find it helpful since all my Linux, Mac, and Windows Git Bash returned &lt;code&gt;true&lt;/code&gt; for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;code&gt;uname&lt;/code&gt; to be suitable as it distinguishes between Linux, Mac, Windows, without too much granularity.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let uname = substitute(system('uname'), '\n', '', '')&#xA;&quot; Example values: Linux, Darwin, MINGW64_NT-10.0, MINGW32_NT-6.1&#xA;&#xA;if uname == 'Linux' || uname == 'Darwin'&#xA;    &quot; do linux/mac command&#xA;else &quot; windows&#xA;    &quot; do windows command&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6610" LastActivityDate="2018-06-06T00:02:47.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16409" PostTypeId="1" AcceptedAnswerId="16410" CreationDate="2018-06-06T07:35:24.617" Score="12" ViewCount="1915" Body="&lt;p&gt;I was trying to write a string with all chars from &lt;code&gt;z&lt;/code&gt; to &lt;code&gt;a&lt;/code&gt; and I thought this would be much easier if I could write &lt;em&gt;backwards&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea would be like an INSERT mode in which the cursor doesn't step forward after every char inserted. I couldn't find anything like that so I'm wondering if this mode already exists or can be achieved in some way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I'm aware that I can &lt;a href=&quot;https://stackoverflow.com/questions/1680194/reverse-a-word-in-vim&quot;&gt;reverse the text&lt;/a&gt; but this is not the point.&lt;/p&gt;&#xA;" OwnerUserId="11899" LastEditorUserId="11357" LastEditDate="2018-06-06T16:20:02.920" LastActivityDate="2018-06-06T16:20:02.920" Title="Is there a prepend insert mode?" Tags="|insert-mode|cursor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16410" PostTypeId="2" ParentId="16409" CreationDate="2018-06-06T07:44:00.703" Score="14" Body="&lt;p&gt;If you set &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;revins&amp;#39;&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:set revins&lt;/code&gt;&lt;/a&gt; you can insert backwards. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;http://vimhelp.appspot.com/rileft.txt.html#ins-reverse&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h ins-reverse&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;o  Typing backwards                                     ins-reverse&#xA;   ----------------&#xA;   In lieu of using full-fledged the 'rightleft' option, one can opt for&#xA;   reverse insertion.  When the 'revins' (reverse insert) option is set,&#xA;   inserting happens backwards.  This can be used to type right-to-left&#xA;   text.  When inserting characters the cursor is not moved and the text&#xA;   moves rightwards.  A &amp;lt;BS&amp;gt; deletes the character under the cursor.&#xA;   CTRL-W and CTRL-U also work in the opposite direction.  &amp;lt;BS&amp;gt;, CTRL-W&#xA;   and CTRL-U do not stop at the start of insert or end of line, no matter&#xA;   how the 'backspace' option is set.&#xA;&#xA;   There is no reverse replace mode (yet).&#xA;&#xA;   If the 'showmode' option is set, &quot;-- REVERSE INSERT --&quot; will be shown&#xA;   in the status line when reverse Insert mode is active.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-06-06T07:44:00.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16411" PostTypeId="1" AcceptedAnswerId="16437" CreationDate="2018-06-06T09:31:58.250" Score="4" ViewCount="178" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;When i used following code to keep my folder view, it seemed that &lt;code&gt;vim -R&lt;/code&gt; and &lt;code&gt;view&lt;/code&gt; don't work at all (Only &lt;strong&gt;[readonly]&lt;/strong&gt; was shown but it didn't work at all). Is there any misunderstanding about it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; save and restore view automatically                                      &#xA;autocmd BufWinLeave * silent! mkview                                       &#xA;autocmd BufWinEnter * silent! loadview&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Thank you for all the people who can help me.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerDisplayName="user17761" LastEditorDisplayName="user17761" LastEditDate="2018-06-08T02:10:58.840" LastActivityDate="2018-06-09T00:11:43.347" Title="Is loadview conflicted with readonly mode?" Tags="|vimrc|vimscript|linux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16412" PostTypeId="1" CreationDate="2018-06-06T09:34:26.363" Score="1" ViewCount="748" Body="&lt;p&gt;I use &lt;a href=&quot;http://ctags.sourceforge.net&quot; rel=&quot;nofollow noreferrer&quot;&gt;exuberant ctags&lt;/a&gt; to find definitions of classes, methods and the like. Which packages find the usages of a specific tag? A &lt;code&gt;git grep&lt;/code&gt; does not work for me as the result is way to big; many method names are used in multiple locations but the corresponding tags are not related. Thanks for your help!&lt;/p&gt;&#xA;" OwnerUserId="17762" LastActivityDate="2018-06-06T09:34:26.363" Title="IDE-alike Find Usages" Tags="|ctags|ide|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16413" PostTypeId="1" AcceptedAnswerId="16414" CreationDate="2018-06-06T10:08:27.483" Score="2" ViewCount="681" Body="&lt;p&gt;I'm trying to lint my C files inside vim. I know that quickfix should help in this case. I found the following pc-lint file maintained by Craig Emery. I have this file in vim/vim80/compiler.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;current_compiler&quot;)&#xA;  finish&#xA;endif&#xA;let current_compiler = &quot;pc-lint&quot;&#xA;&#xA;if exists(&quot;:CompilerSet&quot;) != 2      &quot; older Vim always used :setlocal&#xA;  command -nargs=* CompilerSet setlocal &amp;lt;args&amp;gt;&#xA;endif&#xA;&#xA;CompilerSet makeprg=C:\Users\ahmes\PCLint\LIN.bat&#xA;&#xA;CompilerSet errorformat=%A%f(%l\\,%c):\ %t%*[^\ ]\ %n:\ %m,%C%p_,%Z%s,%t%*[\ ]\ %n:\ %m\ (line\ %l\\,\ file\ %f)%*[^`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open quickfix using &lt;code&gt;:copen&lt;/code&gt; after running &lt;code&gt;:make %&lt;/code&gt; and hit enter inside quickfix buffer, the current line is highlighted but it doesn't jump to the error location in the source file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing is that &lt;code&gt;:cp&lt;/code&gt; and &lt;code&gt;:cn&lt;/code&gt; just jump to the next/previous line in quickfix buffer and not to next/previous error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've read &lt;a href=&quot;https://superuser.com/questions/815416/hitting-enter-in-the-quickfix-window-doesnt-work&quot;&gt;this similar question&lt;/a&gt;, but this is not my case as  is not mapped to anything in my vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I jump to error location inside the source file using quickfix?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried playing arround with pc-lint file. I've changed &lt;code&gt;errorformat&lt;/code&gt; to be the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CompilerSet errorformat=%f:%m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After running &lt;code&gt;:make %&lt;/code&gt;, the opened source file was closed and a new empty buffer was opened. Then I run &lt;code&gt;:copen&lt;/code&gt;, and the quickfix list opened up and I could navigate between errors using &lt;code&gt;:cn&lt;/code&gt; and &lt;code&gt;:cp&lt;/code&gt;. When I hit enter on an error, the cursor moves to the empty new-opened buffer claiming in the status bar that it is the source file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, I'm working on a Windows OS.&lt;/p&gt;&#xA;" OwnerUserId="16800" LastEditorUserId="16800" LastEditDate="2018-06-06T10:32:18.203" LastActivityDate="2018-06-06T11:56:25.013" Title="Quickfix navigation not working properly" Tags="|vimrc|quickfix|makeprg|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16414" PostTypeId="2" ParentId="16413" CreationDate="2018-06-06T11:56:25.013" Score="1" Body="&lt;p&gt;After reading and trials, I understood where is the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PC-Lint (the linting tool I use) produces messages in specific format. For example, first comes the name of the file where the error is located &lt;code&gt;%f&lt;/code&gt;, then comes the line number &lt;code&gt;%l&lt;/code&gt;, then the message itself &lt;code&gt;%m&lt;/code&gt;. This message format can be configured in PC-Lint. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, quickfix should be configured so that the message format it expects is the same as the message format PC-Lint produces. This way, quickfix can know what is the file name, which line has the problem and so on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bottom line is, quickfix uses its &lt;code&gt;errorformat&lt;/code&gt; to &lt;em&gt;interpret&lt;/em&gt; the PC-Lint's messages and not to &lt;em&gt;display&lt;/em&gt; them (as I thought before).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the solution is to configure PC-Lint and Quickfix so that their message formats match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gimpel.com/html/pub90/env-vim.lnt&quot; rel=&quot;nofollow noreferrer&quot;&gt;This file&lt;/a&gt; is provided by Gimpel (PC-Lint developer) and it helps in clarifying the solution.&lt;/p&gt;&#xA;" OwnerUserId="16800" LastActivityDate="2018-06-06T11:56:25.013" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16415" PostTypeId="1" CreationDate="2018-06-06T12:37:00.693" Score="1" ViewCount="952" Body="&lt;p&gt;I have &lt;code&gt;:set hidden&lt;/code&gt; set in my &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First I did this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vim foo bar&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:bn&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;code&gt;hello&lt;/code&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:bp&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:bd#&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:bd#&lt;/code&gt; command leads to this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E89: No write since last change for buffer 2 (add ! to override)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is expected behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I did this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vim foo bar&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:bn&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;code&gt;hello&lt;/code&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:bp | bd#&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:ls&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This time &lt;code&gt;:bp | bd#&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; did not lead to any error. The output of &lt;code&gt;:ls&lt;/code&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; shows that the buffer for &lt;code&gt;bar&lt;/code&gt; is still present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why did the &lt;code&gt;E89&lt;/code&gt; error did not occur in the second set of steps?&lt;/p&gt;&#xA;" OwnerUserId="17765" LastActivityDate="2018-06-06T12:37:00.693" Title="Why does &quot;E89: No write since last change&quot; error not occur when commands are joined with bar?" Tags="|buffers|error|hidden-buffers|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16418" PostTypeId="1" AcceptedAnswerId="16419" CreationDate="2018-06-07T02:47:23.107" Score="1" ViewCount="496" Body="&lt;p&gt;In some editing senario, I want to do a series of deleting, and do not want to clutter with the system clipboard, which I use an external program to management the history of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The question is&lt;/strong&gt;, &#xA;how to make &lt;code&gt;dd&lt;/code&gt; act like &lt;code&gt;&quot;_dd&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe &lt;code&gt;set clipboard=some-value&lt;/code&gt; then restore the old value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my machine, &lt;code&gt;set clipboard?&lt;/code&gt; outputs &lt;code&gt;clipboard=unnamed&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2019-02-17T16:54:44.220" Title="disable clipboard: how to set clipboard option to Black hole register?" Tags="|cut-copy-paste|register|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16419" PostTypeId="2" ParentId="16418" CreationDate="2018-06-07T03:57:30.437" Score="1" Body="&lt;p&gt;I don't think clipboard can be set to anything other than unnamed or unnamedplus. Because, clipboard was introduced for associating vim's register with operating system's clipboard. But I'm not sure. Maybe someone can help me out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion would be to use a simple mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap d &quot;_d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and when you don't need it anymore just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unmap d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should get you started for now. I'll try and come up with a vimscript function to toggle the situation before you become bored with this solution. Afterwards I'll edit this answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I came up with this hideous function. I don't know if it should be used or if it will hamper any regular use cases. But it works for now. &lt;strong&gt;Maybe someone will help me out&lt;/strong&gt;. Here it is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;tb :call ToggleBlackHole()&amp;lt;cr&amp;gt;&#xA;function! ToggleBlackHole() abort&#xA;  if maparg(&quot;d&quot;, &quot;n&quot;) ==# ''&#xA;    nnoremap d &quot;_d&#xA;  else&#xA;    unmap d&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, OP should be able to use &lt;code&gt;&amp;lt;leader&amp;gt;tb&lt;/code&gt; to toggle blackhole register and unnamed register for deleting.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-17T16:54:44.220" LastActivityDate="2019-02-17T16:54:44.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16420" PostTypeId="1" AcceptedAnswerId="16421" CreationDate="2018-06-07T06:26:03.327" Score="1" ViewCount="259" Body="&lt;p&gt;Given a file with multiple lines matching this pattern (apologies for the length!)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$this-&amp;gt;execSQL('INSERT INTO `table_lowercase_and_underscores` (`id`, `field1`, `field2`, `field3`, `field4`, `field5`) VALUES (\'first-guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', 0, \'2018-04-09 03:58:59\', 0);');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to visually select multiple of these lines and apply a macro or regex replacement to yield the following pattern below each target line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$this-&amp;gt;execSQL('DELETE FROM `table_lowercase_and_underscores` WHERE id =  \'first-guuid-lowercase-numbers-hyphens\';');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know I can capture the first backtick contents with something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/`\([a-z_]*\)`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And could grab the first match of &lt;code&gt;\'something'\&lt;/code&gt; into 2 capture groups, but how would I then get those into a new line following the first? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would this be easier to tackle as a macro to duplicate the line and then replace a few parts?&lt;/p&gt;&#xA;" OwnerUserId="11715" LastActivityDate="2018-06-07T08:52:48.203" Title="Duplicating a row and modifying the duplicate as a macro or regex" Tags="|regular-expression|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16421" PostTypeId="2" ParentId="16420" CreationDate="2018-06-07T08:52:48.203" Score="2" Body="&lt;p&gt;I think this can be done with just a &lt;code&gt;:s&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v.{-}(`.{-}`).{-}(\\'.{-}\\').*/&amp;amp;\r$this-&amp;gt;execSQL('DELETE FROM \1 WHERE id = \2;');/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The regex &lt;code&gt;\v.{-}(&lt;/code&gt;.{-}&lt;code&gt;).{-}(\\'.{-}\\').*&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;enables very magic (&lt;code&gt;\v&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;uses &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#non-greedy&quot; rel=&quot;nofollow noreferrer&quot;&gt;lazy matching&lt;/a&gt; instead of greedy (&lt;code&gt;{-}&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;matches the table name in the first group &lt;code&gt;(`.{-}`)&lt;/code&gt;, and the first GUID in the second &lt;code&gt;(\\'.{-}\\')&lt;/code&gt;, by virtue of lazy matching.&lt;/li&gt;&#xA;&lt;li&gt;covers the entire line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So the replacement:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;replaces the line with itself, followed by a newline (&lt;code&gt;&amp;amp;\r&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;and constructs the new query with the two groups.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-06-07T08:52:48.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16422" PostTypeId="1" AcceptedAnswerId="16423" CreationDate="2018-06-07T09:15:49.987" Score="3" ViewCount="2623" Body="&lt;p&gt;Using Vim-fugitive plugin I open a commit with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Gedit HEAD~5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The buffer looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tree a75d4eea2207e408db6343a4869274b701b42135&#xA;parent 7fa89fec125ce60a341f7c37dd769a8a31c49359&#xA;author Takahiro Yoshihara &amp;lt;tacahiroy@gmail.com&amp;gt; Tue Feb 21 09:07:51 2017 +0900&#xA;committer Takahiro Yoshihara &amp;lt;tacahiroy@gmail.com&amp;gt; Sun Mar 19 18:16:51 2017 +0900&#xA;&#xA;Fix incorrect matching in buffer mode with by_filename (#346)&#xA;&#xA;&#xA;diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim&#xA;index 6558939..05196ae 100644&#xA;--- a/autoload/ctrlp.vim&#xA;+++ b/autoload/ctrlp.vim&#xA;@@ -2384,7 +2384,7 @@ endf&#xA; fu! s:matchbuf(item, pat)&#xA;    let bufnr = s:bufnrfilpath(a:item)[0]&#xA;    let parts = s:bufparts(bufnr)&#xA;-   let item = bufnr.parts[0].parts[2].s:lash().parts[3]&#xA;+   let item = s:byfname ? parts[2] : bufnr.parts[0].parts[2].s:lash().parts[3]&#xA;    retu match(item, a:pat)&#xA; endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(the diff part appears folded)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now putting the cursor on the first line of the diff, I would like to open that diff in a vertical split vim-diff mode like &lt;code&gt;:Gvdiff&lt;/code&gt; (in a new tab or in the same tab below the current window) viewing the changes made to the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently issuing &lt;code&gt;:Gvdiff&lt;/code&gt; compares the entire commit-buffer with something weird.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I would like to have the same diff-view, as I get with &lt;code&gt;dv&lt;/code&gt; in the &lt;code&gt;:Gstatus&lt;/code&gt; window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I open the vertical split diff on a selected file?&lt;/li&gt;&#xA;&lt;li&gt;How can I close that view going back to my commit buffer?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3230" LastEditorUserId="3230" LastEditDate="2018-06-07T09:31:50.623" LastActivityDate="2018-06-10T14:51:13.397" Title="How to open a split-diff for selected file out of the commit" Tags="|plugin-fugitive|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16423" PostTypeId="2" ParentId="16422" CreationDate="2018-06-07T14:05:10.347" Score="5" Body="&lt;p&gt;From &lt;code&gt;:h fugitive-mappings&lt;/code&gt; you can use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to open the diff in the current window&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&lt;/code&gt; open the diff in a horizontal split&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;O&lt;/code&gt; to open the diff in a new tab page&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;S&lt;/code&gt; open diff in a vertical split&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I imagine you want to use &lt;code&gt;S&lt;/code&gt; on the diff line. However as screen space can be a concern with diff-ing, &lt;code&gt;O&lt;/code&gt; might be a better option.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-06-07T14:05:10.347" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16424" PostTypeId="1" AcceptedAnswerId="16454" CreationDate="2018-06-07T14:12:18.470" Score="2" ViewCount="321" Body="&lt;p&gt;I have below autocmd in my &lt;code&gt;cobol.vim&lt;/code&gt; ftplugin file in &lt;code&gt;~/.vim/ftplugin/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup cobmods&#xA;    autocmd!&#xA;    autocmd BufNewFile * call s:CleanStart()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't work when I open a file using vim filename.cob.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I put the same in my .vimrc, it works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anybody with any insights on how I can change this autocmd to work from &lt;code&gt;cobol.vim&lt;/code&gt; as I really don't want to put cobol related mods in vimrc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also looks like, by the time program (vim) flow reaches cobol.vim, &lt;code&gt;BufNewFile&lt;/code&gt; event is no longer valid.&lt;/p&gt;&#xA;" OwnerUserId="16636" LastActivityDate="2018-06-10T06:15:11.983" Title="BufNewFile doesn't work from ftplugin" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16425" PostTypeId="1" AcceptedAnswerId="16427" CreationDate="2018-06-07T17:30:20.807" Score="1" ViewCount="203" Body="&lt;p&gt;I have my tab set to 4 spaces with &lt;code&gt;:set tabstop=4&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to highlight multiple lines and tab them, or indent all them 4 spaces. If I highlight the lines and do &lt;code&gt;&amp;gt;&lt;/code&gt;, it seems to indent them more than 4 spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I simply indent multiple lines a given number of spaces?&lt;/p&gt;&#xA;" OwnerUserId="17778" LastActivityDate="2018-06-07T18:36:15.317" Title="Tab multiple lines" Tags="|whitespace|tab-characters|" AnswerCount="1" CommentCount="1" ClosedDate="2018-06-08T07:55:17.707" ContentLicense="CC BY-SA 4.0" />
  <row Id="16426" PostTypeId="2" ParentId="10703" CreationDate="2018-06-07T18:23:41.453" Score="3" Body="&lt;p&gt;I had a similar problem when messing with my VIMRC file. Seems that these &lt;code&gt;let&lt;/code&gt; lines were causing the trouble, commenting them fixed the problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully it helps someone stumbling into this same problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot; Theme and colors   &#xA;set termguicolors&#xA;&#xA;&quot;let &amp;amp;t_8f=&quot;\&amp;lt;Esc&amp;gt;[38;2;%lu;%lu;%lum&quot;&#xA;&quot;let &amp;amp;t_8b=&quot;\&amp;lt;Esc&amp;gt;[48;2;%lu;%lu;%lum&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17781" LastActivityDate="2018-06-07T18:23:41.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16427" PostTypeId="2" ParentId="16425" CreationDate="2018-06-07T18:36:15.317" Score="0" Body="&lt;p&gt;The solution is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set shiftwidth=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will cause &lt;code&gt;&amp;gt;&lt;/code&gt; to result in a 4-space indent.&lt;/p&gt;&#xA;" OwnerUserId="17778" LastActivityDate="2018-06-07T18:36:15.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16428" PostTypeId="1" AcceptedAnswerId="16430" CreationDate="2018-06-08T01:56:04.523" Score="2" ViewCount="336" Body="&lt;p&gt;Given this search and replace expression, which works fine on one or multiple visually selected lines:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\v.{-}(`.{-}`).{-}(\\'.{-}\\').*/$this-&amp;gt;execSQL('DELETE FROM \1 WHERE id = \2;');\r&amp;amp;/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to stick this in a function to be &lt;code&gt;call&lt;/code&gt;'d or mapped to a key. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this works for a single line, but behaves differently on multiple lines than when I run the search and replace directly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; function! CreateDeleteStatements()&#xA;     :'&amp;lt;,'&amp;gt;s/\v.{-}(`.{-}`).{-}(\\'.{-}\\').*/$this-&amp;gt;execSQL('DELETE FROM \1 WHERE id = \2;');\r&amp;amp;/&#xA; endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit #1:&lt;/strong&gt; By &lt;code&gt;behaves differently on multiple lines&lt;/code&gt;, it seems to be a cursor position problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By removing the leading &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt; from the command within the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; function! CreateDeleteStatements()&#xA;     s/\v.{-}(`.{-}`).{-}(\\'.{-}\\').*/$this-&amp;gt;execSQL('DELETE FROM \1 WHERE id = \2;');\r&amp;amp;/&#xA; endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I then select 4 lines, it will run 4 times, but only at the position of the first line (I end up with 4 lines above this, rather than interleaved between each line of the selection). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have tried &lt;code&gt;getpost()&lt;/code&gt; and &lt;code&gt;setpos()&lt;/code&gt; and &lt;code&gt;winsaveview()&lt;/code&gt; and &lt;code&gt;winrestview()&lt;/code&gt;, but doesn't seem to be changing the cursor position after the substitution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit #2:&lt;/strong&gt; Adding sample text to work against&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example input text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$this-&amp;gt;execSQL('INSERT INTO `table_lowercase_and_underscores1` (`id`, `field1`, `field2`, `field3`, `field4`, `field5`) VALUES (\'first-guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', 0, \'2018-04-09 03:58:59\', 0);');&#xA;$this-&amp;gt;execSQL('INSERT INTO `table_lowercase_and_underscores2` (`id`, `field1`, `field2`, `field3`, `field4`, `field5`) VALUES (\'first-guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', 0, \'2018-04-09 03:58:59\', 0);');&#xA;$this-&amp;gt;execSQL('INSERT INTO `table_lowercase_and_underscores3` (`id`, `field1`, `field2`, `field3`, `field4`, `field5`) VALUES (\'first-guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', 0, \'2018-04-09 03:58:59\', 0);');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And expected output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$this-&amp;gt;execSQL('DELETE FROM `table_lowercase_and_underscores1` WHERE id =  \'first-guuid-lowercase-numbers-hyphens\';');&#xA;$this-&amp;gt;execSQL('INSERT INTO `table_lowercase_and_underscores1` (`id`, `field1`, `field2`, `field3`, `field4`, `field5`) VALUES (\'first-guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', 0, \'2018-04-09 03:58:59\', 0);');&#xA;$this-&amp;gt;execSQL('DELETE FROM `table_lowercase_and_underscores2` WHERE id =  \'first-guuid-lowercase-numbers-hyphens\';');&#xA;$this-&amp;gt;execSQL('INSERT INTO `table_lowercase_and_underscores2` (`id`, `field1`, `field2`, `field3`, `field4`, `field5`) VALUES (\'first-guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', 0, \'2018-04-09 03:58:59\', 0);');&#xA;$this-&amp;gt;execSQL('DELETE FROM `table_lowercase_and_underscores3` WHERE id =  \'first-guuid-lowercase-numbers-hyphens\';');&#xA;$this-&amp;gt;execSQL('INSERT INTO `table_lowercase_and_underscores3` (`id`, `field1`, `field2`, `field3`, `field4`, `field5`) VALUES (\'first-guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', \'guuid-lowercase-numbers-hyphens\', 0, \'2018-04-09 03:58:59\', 0);');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11715" LastEditorUserId="11715" LastEditDate="2018-06-08T03:24:01.500" LastActivityDate="2018-06-08T04:15:58.427" Title="Convert a search and replace to a function" Tags="|vimscript|visual-mode|replace|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16430" PostTypeId="2" ParentId="16428" CreationDate="2018-06-08T03:55:10.570" Score="2" Body="&lt;p&gt;The simplest way of doing what you want is probably not to use a function, but&#xA;instead use a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range MySubCmd &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;s/\v.{-}(`.{-}`).{-}(\\'.{-}\\').*/$this-&amp;gt;execSQL('DELETE FROM \1 WHERE id = \2;');\r&amp;amp;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We use the &lt;code&gt;-range&lt;/code&gt; attribute to pass the range we execute over through to&#xA;&lt;code&gt;&amp;lt;line1&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;line2&amp;gt;&lt;/code&gt; that get expanded to the range we set with &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; when&#xA;we selected visually. See &lt;code&gt;:h command-range&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to define a function for this the equivalent syntax is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MySubFunction() range&#xA;    execute a:firstline.','.a:lastline.'s/\v.{-}(`.{-}`).{-}(\\''.{-}\\'').*/$this-&amp;gt;execSQL(''DELETE FROM \1 WHERE id = \2;'');\r&amp;amp;/'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add &lt;code&gt;range&lt;/code&gt; after the function signature and then the range passed to &lt;code&gt;:call&lt;/code&gt;&#xA;will be available as &lt;code&gt;a:firstline&lt;/code&gt; and &lt;code&gt;a:lastline&lt;/code&gt;. We have to use execute&#xA;magic to evaluate those variables, and so we need to double up quotes in the&#xA;substitute expression. The reason that your original function wasn't&#xA;interleaving (I think), was that after the function was called on each line, vim helpfully&#xA;moved us back to our starting position before moving down to the next line,&#xA;disregarding the fact that things had changed positions - hence performing the substitute on the same line 3 times. See &lt;code&gt;:h function-range&lt;/code&gt; for details, but essentially the function will be called on each line if it doesn't handle the range itself, with vim saving and restoring the cursor postion afterwords - which is why nothing you tried inside the function changed anything. We just avoid this by making it handle the range iself, so it is only called once.&lt;/p&gt;&#xA;" OwnerUserId="16910" LastEditorUserId="16910" LastEditDate="2018-06-08T04:15:58.427" LastActivityDate="2018-06-08T04:15:58.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16431" PostTypeId="1" CreationDate="2018-06-08T12:02:52.643" Score="1" ViewCount="73" Body="&lt;p&gt;I'd like to lose focus when I'm in insert mode, to trigger auto-save on *.coffee buffers and also I need it to change mode from insert to normal mode to trigger Live compile feature of vim-coffee-script plguin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I achieved now:&#xA;&lt;code&gt;autocmd BufWritePost,FocusLost *.coffee  :wa&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how to bring it to normal mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2018-06-08T12:02:52.643" Title="How to auto save on *.coffee files when lose focus (in insert mode) then also back to normal mode" Tags="|vimrc|gvim|vim-windows|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16432" PostTypeId="1" AcceptedAnswerId="16472" CreationDate="2018-06-08T15:29:30.027" Score="8" ViewCount="520" Body="&lt;p&gt;&lt;a href=&quot;https://www.vim.org/vim-8.1-released.php&quot; rel=&quot;noreferrer&quot;&gt;Vim 8.1's release note&lt;/a&gt; seems to indicate that you can feed output from make running in a terminal window to a quickfix list, but I couldn't find any detailed explanation. Is there a way to do this automatically, or do I have to manually add to the quickfix list using &lt;code&gt;:caddbuffer&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="17795" LastActivityDate="2018-06-12T20:09:46.530" Title="How to capture errors from make in terminal window" Tags="|terminal|quickfix|makeprg|terminal-buffer|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16433" PostTypeId="1" CreationDate="2018-06-08T18:10:32.317" Score="0" ViewCount="51" Body="&lt;p&gt;@saginaw answered a question I asked a long time ago, in &lt;a href=&quot;https://vi.stackexchange.com/questions/5982/mapping-to-enclose-symbol-under-cursor-with-an-expression-that-contains-the-symb/5985#5985&quot;&gt;this thread&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a code snippit of his suggestions that illustrates my problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:PadMacro(type) abort&#xA;    if a:type ==# 'char'&#xA;        normal! `[v`]d&#xA;    elseif a:type ==# 'line'&#xA;        normal! '[V']d&#xA;    elseif a:type ==# 'v'&#xA;        normal! `&amp;lt;v`&amp;gt;d&#xA;    else&#xA;        return&#xA;    endif&#xA;    let string = '\Pad{' . @&quot; . '}'&#xA;    silent execute &quot;normal! i\&amp;lt;c-r&amp;gt;=string\r&quot;&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; ;P :set operatorfunc=&amp;lt;sid&amp;gt;PadMacro&amp;lt;cr&amp;gt;g@&#xA;vnoremap &amp;lt;silent&amp;gt; ;P :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;PadMacro(visualmode())&amp;lt;cr&amp;gt;&#xA;&#xA;a&#xA;aaa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are @saginaw's instructions&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Instructions:&#xA;    If you put the previous code in your vimrc, it should do what you want.&#xA;&#xA;    To use it, hit ;P{motion} and the PadMacro() function should enclose the characters covered by {motion} with \Pad{ and }.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem  I'm having is with the ;P{motion} command: If&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) on the last line of the snippet I highlight the three aaa's by hitting v and the spacebar, then hit ;P&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get the following error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;7_PaddingFunction:&#xA;line   10:&#xA;E121: Undefined variable: g:enclosure&#xA;E15: Invalid expression: '\' . g:enclosure . '{' . @&quot; . '}'&#xA;Press ENTER or type command to continu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;HOWEVER, if I first modify the single a in the line above, by putting the cursor over it and then typing ;P (no 'v' then spacebar required), and AFTER DOING SO, repeat the command sequence on the line that begins with (*), the ;P command works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ignorant guess is that something needs to be initialized in order for ;P, together with motion,  to work properly&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could somebody please advise how to get the (*) command sequence to work the first time?   Thanks for any advice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At @Christian_Brabandt's request I'm posting the output of &lt;code&gt;:scriptnames&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: ~/LOCALSVN/dotFiles/trunk/vimrc&#xA;  2: /usr/share/vim/vim74/syntax/syntax.vim&#xA;  3: /usr/share/vim/vim74/syntax/synload.vim&#xA;  4: /usr/share/vim/vim74/syntax/syncolor.vim&#xA;  5: /usr/share/vim/vim74/filetype.vim&#xA;  6: ~/LOCALSVN/multiSystem/trunk/vimPlugins/unicode.vim/ftdetect/unicode.vim&#xA;  7: /usr/share/vim/vim74/syntax/nosyntax.vim&#xA;  8: /usr/share/vim/vim74/colors/delek.vim&#xA;  9: ~/LOCALSVN/multiSystem/trunk/vimPlugins/unicode.vim/plugin/unicode.vim&#xA; 10: /usr/share/vim/vim74/plugin/getscriptPlugin.vim&#xA; 11: /usr/share/vim/vim74/plugin/gzip.vim&#xA; 12: /usr/share/vim/vim74/plugin/logiPat.vim&#xA; 13: /usr/share/vim/vim74/plugin/matchparen.vim&#xA; 14: /usr/share/vim/vim74/plugin/netrwPlugin.vim&#xA; 15: /usr/share/vim/vim74/plugin/rrhelper.vim&#xA; 16: /usr/share/vim/vim74/plugin/spellfile.vim&#xA; 17: /usr/share/vim/vim74/plugin/tarPlugin.vim&#xA; 18: /usr/share/vim/vim74/plugin/tohtml.vim&#xA; 19: /usr/share/vim/vim74/plugin/vimballPlugin.vim&#xA; 20: /usr/share/vim/vim74/plugin/zipPlugin.vim&#xA; 21: /usr/share/vim/vim74/scripts.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My vimrc file is posted &lt;a href=&quot;https://are.berkeley.edu/~leo1730simon/personal/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and a text file that generates the problem is &lt;a href=&quot;https://are.berkeley.edu/~leo1730simon/personal/padProblem&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4667" LastEditorUserId="4667" LastEditDate="2018-06-10T15:38:09.227" LastActivityDate="2018-06-10T15:38:09.227" Title="mapping to enclose symbol under cursor with an expression that contains the symbol (revisited)" Tags="|replace|macro|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="16434" PostTypeId="2" ParentId="16433" CreationDate="2018-06-08T18:28:10.973" Score="2" Body="&lt;p&gt;This seems like a job for Tim Pope's &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;surround.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following to &lt;code&gt;~/.vim/after/ftplugin/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:surround_{char2nr(&quot;P&quot;)} = &quot;\\Pad{\r}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can do &lt;code&gt;ys{motion}P&lt;/code&gt; or other surround operations (See &lt;code&gt;:h surround&lt;/code&gt;). See &lt;code&gt;:h surround-customizing&lt;/code&gt; for more information about customizing surround.vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;a href=&quot;https://github.com/machakann/vim-sandwich&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sandwich&lt;/a&gt; which is an alternative to surround.vim.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-06-08T18:28:10.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16435" PostTypeId="1" AcceptedAnswerId="16438" CreationDate="2018-06-08T20:46:20.620" Score="2" ViewCount="1101" Body="&lt;p&gt;So I have been writing a vim extension but it simply does not make sense to me. I am using nvim and &lt;a href=&quot;https://neovim.io/doc/user/eval.html#chansend()&quot; rel=&quot;nofollow noreferrer&quot;&gt;clearly see the function chansend in the documentation&lt;/a&gt; yet I get &quot;Unknown function: chansend&quot; when trying to call it. Seems trivial but simply does not exist, any help?&lt;/p&gt;&#xA;" OwnerUserId="17796" LastActivityDate="2018-06-09T01:59:59.227" Title="VimScript &quot;unknown function&quot; on a lot of functions" Tags="|vimscript|neovim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16436" PostTypeId="2" ParentId="16386" CreationDate="2018-06-08T20:54:25.567" Score="9" Body="&lt;p&gt;GVim is a 32-bit application and WSL must run on 64 bit. On Windows 10 you can use GVim with WSL if you add the following to your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;win32&quot;)&#xA;    set shell=C:\Windows\Sysnative\wsl.exe&#xA;    set shellpipe=|&#xA;    set shellredir=&amp;gt;&#xA;    set shellcmdflag=&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17797" LastEditorUserId="17797" LastEditDate="2020-04-02T13:41:43.453" LastActivityDate="2020-04-02T13:41:43.453" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16437" PostTypeId="2" ParentId="16411" CreationDate="2018-06-09T00:11:43.347" Score="2" Body="&lt;p&gt;By default, &lt;code&gt;:mkview&lt;/code&gt; saves the state of the &lt;code&gt;'readonly'&lt;/code&gt; option. This means if&#xA;you previously closed the file when it wasn't read only, then when you reopen it,&#xA;&lt;code&gt;:loadview&lt;/code&gt; sets &lt;code&gt;:set noreadonly&lt;/code&gt; and changes it back. From &lt;code&gt;:h :mkview&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The output of &quot;:mkview&quot; contains these items:&#xA;...&#xA;3. Restore mappings, abbreviations and options local to the window if&#xA;   'viewoptions' contains &quot;options&quot; or &quot;localoptions&quot;.  For the options it&#xA;   restores only values that are local to the current buffer and values local&#xA;   to the window.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So changing the value of &lt;code&gt;'viewoptions'&lt;/code&gt; will fix this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viewoptions-=options&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;but&lt;/strong&gt; this will also prevent &lt;code&gt;:mkview&lt;/code&gt; from saving almost every other option.&#xA;You can see what happens when you run &lt;code&gt;:loadview&lt;/code&gt; with different values of&#xA;&lt;code&gt;'viewoptions'&lt;/code&gt; by looking at the file that it generates - the files are in&#xA;&lt;code&gt;~/.vim/view&lt;/code&gt;, or &lt;code&gt;~/.local/share/nvim/view&lt;/code&gt; on neovim, and it's just a bunch of&#xA;ex commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you actually want to just restore the cursor position every time then there's&#xA;a much simpler method that doesn't involve writing any files, look at &lt;code&gt;:h restore-cursor&lt;/code&gt;. The example there registers its autocmd on BufReadPost, you&#xA;can easily change that to &lt;code&gt;autocmd BufWinEnter&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16910" LastActivityDate="2018-06-09T00:11:43.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16438" PostTypeId="2" ParentId="16435" CreationDate="2018-06-09T01:59:59.227" Score="1" Body="&lt;p&gt;&lt;code&gt;jobsend()&lt;/code&gt; is the previous name for &lt;code&gt;chansend()&lt;/code&gt; (changed in &lt;a href=&quot;https://github.com/neovim/neovim/commit/5af47031773fc647de867444693d1598d0da458d&quot; rel=&quot;nofollow noreferrer&quot;&gt;5af47031&lt;/a&gt;).  It will still work, but is not documented anymore to nudge people towards using &lt;code&gt;chansend()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can detect which is available and then use the appropriate one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('*chansend')&#xA;    let s:Send = function('chansend')&#xA;else&#xA;    let s:Send = function('jobsend')&#xA;endif&#xA;call s:Send(job, data)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2018-06-09T01:59:59.227" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16439" PostTypeId="2" ParentId="16432" CreationDate="2018-06-09T08:37:49.537" Score="2" Body="&lt;p&gt;I guess &lt;code&gt;caddbuffer&lt;/code&gt; is currently the best way to achieve what I want.&lt;/p&gt;&#xA;" OwnerUserId="17795" LastActivityDate="2018-06-09T08:37:49.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16440" PostTypeId="2" ParentId="839" CreationDate="2018-06-09T08:38:19.590" Score="0" Body="&lt;p&gt;The following functions and corresponding mappings solved this problem for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BreakMultlineString(quote)&#xA;let c = 100&#xA;while c == 100&#xA;    normal 100|&#xA;    let c = virtcol('.')&#xA;    if c == 100&#xA;        execute &quot;normal ,&quot; . a:quote&#xA;    endif&#xA;endwhile&#xA;endfunction&#xA;&#xA;function! JoinMultilineString()&#xA;    let c = &quot;'&quot;&#xA;    while c == &quot;'&quot; || c == '&quot;'&#xA;        normal gj^&#xA;        let c = matchstr(getline('.'), '\%' . col('.') . 'c.')&#xA;        normal k&#xA;        if c == &quot;'&quot; || c == '&quot;'&#xA;            normal ,j&#xA;        endif&#xA;    endwhile&#xA;endfunction&#xA;&#xA;&quot; break lines&#xA;nnoremap &amp;lt;Leader&amp;gt;&quot; 100\|Bi&quot;&amp;lt;CR&amp;gt;&quot;&amp;lt;Esc&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;&amp;lt;Leader&amp;gt;&quot; :call BreakMultlineString('&quot;')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;' 100\|Bi'&amp;lt;CR&amp;gt;'&amp;lt;Esc&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;&amp;lt;Leader&amp;gt;' :call BreakMultlineString(&quot;'&quot;)&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; join lines&#xA;nmap &amp;lt;Leader&amp;gt;j Jds'ds&quot;x&#xA;nnoremap &amp;lt;Leader&amp;gt;J :call JoinMultilineString()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11189" LastActivityDate="2018-06-09T08:38:19.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16441" PostTypeId="1" CreationDate="2018-06-09T08:56:11.757" Score="5" ViewCount="197" Body="&lt;p&gt;I'm trying to find out if it's possible to make the write &quot;:w&quot; command perform a forced validation for certain file types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My use case is that I want to prevent small typos and idention errors in python source code. So VIM should not even allow me to save a file with errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can run &quot;python -m py_compile &lt;code&gt;filename&lt;/code&gt;&quot; on a file to see if it compiles. &#xA;This command returns nothing, if all is well, otherwise and error message like&#xA;&quot;Sorry: IndentationError: expected an indented block (hello.py, line 2)&quot;&#xA;Alas this requires me to save the file &quot;&lt;code&gt;filename&lt;/code&gt;, which I only want done if it passes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'd need to automate these steps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;save the current file with a temporary filename,&#xA;like &lt;code&gt;filename.insert_uuid_here.py&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;run &quot;python -m py_compile &lt;em&gt;filename.insert_uuid_here.py&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;on success: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;remove both the &lt;em&gt;filename.insert_uuid_here.py&lt;/em&gt; and the&#xA;&lt;em&gt;__python_cache__/filename.insert_uuid_here.py&lt;/em&gt; file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;allow save&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;on fail:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;remove the &lt;code&gt;filename.insert_uuid_here.py&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;display error from compile attempt&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is this something, that's possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I link this to any &quot;:w&quot; attempt to write a python file?&lt;/p&gt;&#xA;" OwnerUserId="17801" LastEditorUserId="2347" LastEditDate="2018-06-13T03:42:59.397" LastActivityDate="2018-07-21T11:59:37.530" Title="Can I block vim from saving a file that isn't validated using an outside tool?" Tags="|vimscript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16442" PostTypeId="1" AcceptedAnswerId="16443" CreationDate="2018-06-09T09:23:51.280" Score="2" ViewCount="59" Body="&lt;p&gt;Following up on &lt;a href=&quot;https://unix.stackexchange.com/questions/141649/how-do-i-highlight-commas-not-followed-by-a-space-in-vim&quot;&gt;this&lt;/a&gt; question on how to highlight commas not followed by a space; the accepted answer provides a nice solution for problems like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(a, b,c,d)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it also highlights commas at the end of a line (after &lt;code&gt;longname2&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(longname1, longname2,&#xA;     longname3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There I would actually like to highlight the opposite case, i.e. if there actually was a space behind &lt;code&gt;longname2,&lt;/code&gt; (which is already handled by the highlighting of trailing spaces).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to extend/modify this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight SquishedCommas ctermbg=red guibg=red&#xA;match SquishedCommas /, \@!/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To only highlight the &lt;code&gt;SquishedCommas&lt;/code&gt; if they are not at the end of a line?&lt;/p&gt;&#xA;" OwnerUserId="17805" LastEditorUserId="17805" LastEditDate="2018-06-09T10:11:31.177" LastActivityDate="2018-06-09T10:11:31.177" Title="Highlight `SquishedCommas`, except at end of line" Tags="|vimrc|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16443" PostTypeId="2" ParentId="16442" CreationDate="2018-06-09T09:31:55.920" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;match SquishedCommas /, \@!/&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You are actively highlighting commas, that are not followed by a space. But in fact you want to only highlight commas that are not at the end of line and are not followed by a space. I think this change to your &lt;code&gt;:match&lt;/code&gt; command will achieve this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match SquishedCommas /,\%($\| \)\@!/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will highlight commas, that are not at the end of the line and not followed by a space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: the &lt;code&gt;:match&lt;/code&gt; function is a window local function. That means it won't work after splitting a new window.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-06-09T09:31:55.920" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16444" PostTypeId="1" AcceptedAnswerId="16446" CreationDate="2018-06-09T14:54:53.023" Score="2" ViewCount="618" Body="&lt;p&gt;I'm using Git's MINGW64 bash shell to run vim and vimtutor. I managed to change the movement key bindings via &lt;code&gt;e: $MYVIMRC&lt;/code&gt;, but the changes in keybindings do not apply to vimtutor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open vimtutor, all the keybindings are the default ones. When I use the &lt;code&gt;e: $MYVIMRC&lt;/code&gt; in vimtutor, it shows the same vimrc file that vim uses, but it does not change the keybindings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to apply vimrc to vimtutor?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Unrelated question, but the key binding change that I want is changing the navigation keys from &quot;hjlk&quot; to &quot;jkl;&quot;. The latter seems more natural to me; it makes more sense for my pointer finger to be on j because that's where the key bump is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A friend told me that you end up not using the left and right navigation buttons very much, so that this doesn't matter. Is this correct? Will switching the navigation buttons in this way hurt my overall vim experience?&lt;/p&gt;&#xA;" OwnerUserId="17809" LastActivityDate="2018-06-10T05:40:46.007" Title="Applying vimrc to vimtutor in Windows" Tags="|vimrc|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16446" PostTypeId="2" ParentId="16444" CreationDate="2018-06-09T16:07:03.253" Score="1" Body="&lt;p&gt;Simple answer, yes, all you need to do is run the &lt;code&gt;:so[urce]&lt;/code&gt; command from within vimtutor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:source ~/_vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(change the path to wherever your vimrc is located. Inside vim you can always use forward slashes as a path separator even on windows, they're less confusing because vim often uses &lt;code&gt;\&lt;/code&gt; as an escape character).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However vimtutor deliberately doesn't load personal configuration by default, because it's purpose is to teach you vim's default keybinings. I'd recommend learning the defaults first so you know what functionality you're changing/potentially loosing when you rebind keys (rebinding hjkl to jkl; will prevent use of &lt;code&gt;;&lt;/code&gt; for it's original meaning). Vim's keybindings come in patterns that make them easier to remember, and if you rebind stuff before learning said patterns you might not notice them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: there's no reason to move your hand when using hjkl, I use the same finger for both h and j, it's no problem because it's rare to have to suddenly transition between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; spelling, grammar&lt;/p&gt;&#xA;" OwnerUserId="16910" LastEditorUserId="16910" LastEditDate="2018-06-10T05:40:46.007" LastActivityDate="2018-06-10T05:40:46.007" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16447" PostTypeId="1" AcceptedAnswerId="16453" CreationDate="2018-06-09T18:41:28.213" Score="1" ViewCount="74" Body="&lt;p&gt;I am trying to use PYthon to interface with VIM in my vimrc. I am aware that&#xA;this can be done in &lt;code&gt;vimrc&lt;/code&gt; in VIML, but I don't want to learn VIML too much,&#xA;and am already familiar with &lt;code&gt;Python&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked into some of the examples here: &lt;a href=&quot;http://vimhelp.appspot.com/if_pyth.txt.html#python-window&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimhelp.appspot.com/if_pyth.txt.html#python-window&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its mentioned here the &lt;code&gt;width&lt;/code&gt; is a parameter of any &lt;code&gt;window&lt;/code&gt; object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I do &lt;code&gt;py3 print(dir(vim.current.window))&lt;/code&gt;, it gives me the&#xA;following output:&#xA;&lt;code&gt;['__dir__', 'buffer', 'col', 'cursor', 'height', 'number', 'options', 'row',&#xA;'tabpage', 'v alid', 'vars']&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This doesn't contain &lt;code&gt;width&lt;/code&gt; as one of the &lt;code&gt;attributes&lt;/code&gt; of &lt;code&gt;current.window&lt;/code&gt;,&#xA;however, when I use the following &lt;code&gt;ex&lt;/code&gt; command:&#xA;&lt;code&gt;:py3 print(vim.current.window.width)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does give me a output of &lt;code&gt;90&lt;/code&gt;, so it seems &lt;code&gt;width&lt;/code&gt; is indeed an attribute of&#xA;&lt;code&gt;vim.current.window&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a bug or how this is supposed to happen?&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-06-10T00:38:44.937" Title="Is `width` a parameter of the Python object `vim.current.window`?" Tags="|vimrc|vimscript-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16448" PostTypeId="2" ParentId="16355" CreationDate="2018-06-09T19:04:20.373" Score="3" Body="&lt;p&gt;what @B-Layer mentioned works pretty well in bash and similarly in zsh.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are already using VIM, and if you are using &lt;code&gt;neovim&lt;/code&gt; or &lt;code&gt;vim8&lt;/code&gt;, you can also try &lt;code&gt;:terminal&lt;/code&gt;, which will open the default terminal in &lt;code&gt;vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can use vim command to navigate the output of the termminal, as well as navigate the history of the terminal commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ref.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/episodes/neovim-terminal/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimcasts.org/episodes/neovim-terminal/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://neovim.io/doc/user/nvim_terminal_emulator.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://neovim.io/doc/user/nvim_terminal_emulator.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/doc/terminal.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/blob/master/runtime/doc/terminal.txt&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-06-09T19:04:20.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16449" PostTypeId="2" ParentId="16037" CreationDate="2018-06-09T19:17:05.177" Score="7" Body="&lt;p&gt;Personally, I have turned off swap and backup files, as it tends to create swap&#xA;files and backup files everywhere and frequently creates conflicts. Vim's&#xA;persistent-undo has been much more reliable and error-free.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim currently has persistent undo, its a much more fine grained method of&#xA;backup.  Every time, you press &lt;kbd&gt;Esc&lt;/kbd&gt;, the current state of the file is&#xA;captured.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:undolist&lt;/code&gt;, or plugins like &lt;a href=&quot;https://github.com/sjl/gundo.vim&quot; rel=&quot;noreferrer&quot;&gt;gundo&lt;/a&gt;,&#xA;or &lt;a href=&quot;https://github.com/mbbill/undotree&quot; rel=&quot;noreferrer&quot;&gt;undo-tree&lt;/a&gt; to browse your undo history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use vim this way:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;create a directory where you editing history for each file will be captured&lt;/li&gt;&#xA;&lt;li&gt;tell vim to use that directory&lt;/li&gt;&#xA;&lt;li&gt;enable persistent undo&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir ~/.vim/undodir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set undodir=~/.vim/undodir&#xA;set undofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To turn off swap files: &lt;code&gt;:set noswapfile&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13848" LastEditorUserId="10604" LastEditDate="2019-10-18T19:59:17.553" LastActivityDate="2019-10-18T19:59:17.553" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16450" PostTypeId="2" ParentId="16444" CreationDate="2018-06-09T19:36:40.097" Score="0" Body="&lt;p&gt;&lt;code&gt;vimtutor&lt;/code&gt; is really a shell script which starts &lt;code&gt;vim&lt;/code&gt; with no &lt;code&gt;vimrc&lt;/code&gt;-s and with the following vimscript &lt;code&gt;$VIMRUNTIME/tutor/tutor.vim'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On linux systems, you can find the location of this script using &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;which vimtutor&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find the location of &lt;code&gt;tutor.vim&lt;/code&gt; in Windows, and then change the line in the shell script &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$VIM -f -u NONE -c 'so $VIMRUNTIME/tutor/tutor.vim'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$VIM -f -c 'so $VIMRUNTIME/tutor/tutor.vim'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so that it loads it up with the default &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-06-09T19:36:40.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16451" PostTypeId="1" CreationDate="2018-06-09T19:52:40.020" Score="2" ViewCount="758" Body="&lt;p&gt;I am trying to search and replace certain pattern &quot;\x&quot; to REPLACE_counter. Where counter goes from $0$ to $N$. The text is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\x    &amp;amp; \x       &amp;amp; \x    &amp;amp; \x    &amp;amp; \x \\ \cline{1-1}&#xA;\x    &amp;amp; \x       &amp;amp; \x    &amp;amp; \x    &amp;amp; \x \\ \cline{1-1}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found the next command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let i=1 | g/\\x/.,.s//\='REPLACE_'.i/ | let i=i+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it only works for the first match in each line, i.e. I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;REPLACE_1   &amp;amp; \x       &amp;amp; \x    &amp;amp; \x    &amp;amp; \x \\ \cline{1-1}&#xA;REPLACE_2    &amp;amp; \x       &amp;amp; \x    &amp;amp; \x    &amp;amp; \x \\ \cline{1-1}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I modify that command to get &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;REPLACE_1   &amp;amp; REPLACE_2 &amp;amp; REPLACE_3&amp;amp; REPLACE_4&amp;amp; \xREPLACE_5 \\ \cline{1-1}&#xA;REPLACE_6    &amp;amp; REPLACE_7      &amp;amp; REPLACE_8    &amp;amp; REPLACE_9    &amp;amp; REPLACE_10 \\ \cline{1-1}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17152" LastActivityDate="2018-06-09T20:44:42.717" Title="Search and Replace in each PATTERN with counter" Tags="|search|" AnswerCount="1" CommentCount="1" ClosedDate="2018-06-11T08:25:24.140" ContentLicense="CC BY-SA 4.0" />
  <row Id="16452" PostTypeId="2" ParentId="16451" CreationDate="2018-06-09T20:01:09.160" Score="2" Body="&lt;p&gt;In vim 7.4.2008 and later, you can do this with substitute and &lt;code&gt;execute()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i = 1&#xA;:%s/\\x/\='REPLACE_'.i.execute('let i+=1')/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\=&lt;/code&gt; allows you to use an expression as the replacement string.  &lt;code&gt;execute()&lt;/code&gt; invokes an ex command (&lt;code&gt;let&lt;/code&gt;) in an expression.  In this case &lt;code&gt;execute()&lt;/code&gt; returns empty string.  We use &lt;code&gt;/g&lt;/code&gt; to replace multiple instances per line.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-06-09T20:44:42.717" LastActivityDate="2018-06-09T20:44:42.717" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16453" PostTypeId="2" ParentId="16447" CreationDate="2018-06-09T23:27:36.137" Score="1" Body="&lt;p&gt;&lt;em&gt;I had posted a couple theories as to why width, a valid field in &lt;code&gt;vim.current.window&lt;/code&gt;, wasn't showing up in the output of &lt;code&gt;dir()&lt;/code&gt;. The actual reason has been astutely uncovered by &lt;strong&gt;@Mass&lt;/strong&gt;...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Objects are allowed to provide hints to &lt;code&gt;dir()&lt;/code&gt; by listing the object's fields in an array. &lt;code&gt;vim.current.window&lt;/code&gt; does so but it's not accurate. It contains...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;buffer&quot;, &quot;cursor&quot;, &quot;height&quot;, &quot;vars&quot;, &quot;options&quot;, &quot;number&quot;, &quot;row&quot;, &quot;col&quot;, &quot;tabpage&quot;, &quot;valid&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yeah, those are exactly the fields &lt;code&gt;dir()&lt;/code&gt; is returning. See &lt;a href=&quot;https://github.com/vim/vim/blob/d79a26219d7161e9211fd144f0e874aa5f6d251e/src/if_py_both.h#L3839&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/blob/d79a26219d7161e9211fd144f0e874aa5f6d251e/src/if_py_both.h#L3839&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, regardless of that error, &lt;code&gt;width&lt;/code&gt; is a valid field and your best bet is to follow the Vim examples that you linked and access the fields like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py cw = vim.current.window&#xA;:py width = cw.width&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or just use &lt;code&gt;vim.current.window.width&lt;/code&gt; as you've done.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-06-10T00:38:44.937" LastActivityDate="2018-06-10T00:38:44.937" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="16454" PostTypeId="2" ParentId="16424" CreationDate="2018-06-10T06:15:11.983" Score="2" Body="&lt;p&gt;Problem was already diagnosed in the comments, and your current solution won't work if you try to start editing a file from within vim. If that's a problem, try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This goes directly in ~/.vim/ftplugin/cobol.vim - no autocommands needed&#xA;if line('$') == 1 &amp;amp;&amp;amp; getline(1) == ''&#xA;  call s:CleanStart()&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I tried adding this as a comment but I can't format newlines in comments as far as I know)&lt;/p&gt;&#xA;" OwnerUserId="16910" LastActivityDate="2018-06-10T06:15:11.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16455" PostTypeId="2" ParentId="16422" CreationDate="2018-06-10T14:51:13.397" Score="3" Body="&lt;p&gt;I love using vimdiff to compare commits side by side:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;git difftool --tool=vimdiff commit_id_01 commit_id_02 path/to/file&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="17816" LastActivityDate="2018-06-10T14:51:13.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16456" PostTypeId="1" AcceptedAnswerId="16458" CreationDate="2018-06-10T15:21:19.773" Score="1" ViewCount="144" Body="&lt;p&gt;So I am trying to send some json text to a python script with jobsend in neovim like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:json_msg = json_encode(a:msg)&#xA;call jobsend(s:vimwatcher_job, l:json_msg)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If i &lt;code&gt;echo l:json_msg&lt;/code&gt; I can see that the l:json_msg is a properly encoded string yet my program receives nothing from stdin at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run &lt;code&gt;echo jobsend(s:vimwatcher_job, l:json_msg)&lt;/code&gt; I can see that the return code is 1 so it seems to succeed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works fine however in normal vim like this (without the encoding and setting the in_mode on job_start to &quot;json&quot;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call ch_sendexpr(s:vimwatcher_job, a:msg)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea what could go wrong?&lt;/p&gt;&#xA;" OwnerUserId="17796" LastActivityDate="2018-06-10T20:35:49.780" Title="jobsend sends no data even though return code is 1?" Tags="|vimscript|neovim|job-control|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16457" PostTypeId="2" ParentId="5533" CreationDate="2018-06-10T17:05:35.753" Score="0" Body="&lt;p&gt;any possible solution is use a minimalist fold bar i used because i don't find the same solution, below i put a list of commands for make a minimalist fold bar that you can use for hidden comments, in each command i write what do it :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;set foldtext='+' &quot;for appear a + in text reference for fold&lt;/p&gt;&#xA;&#xA;&lt;p&gt;hi Folded ctermbg=NONE  &quot;change color fold bar for nothing&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:set fillchars=vert:\|,fold:\ &quot;(put a space) no put a ----- in the fold bar &lt;/p&gt;&#xA;&#xA;&lt;p&gt;optional&#xA;use for disappear comments&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:hi! link Comment Ignore&lt;/p&gt;&#xA;&#xA;&lt;p&gt;return use&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:hi! link Comment Comment &lt;/p&gt;&#xA;" OwnerUserId="15162" LastEditorUserId="15162" LastEditDate="2018-06-10T20:07:38.490" LastActivityDate="2018-06-10T20:07:38.490" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16458" PostTypeId="2" ParentId="16456" CreationDate="2018-06-10T20:35:49.780" Score="0" Body="&lt;p&gt;I was missing newlines, I assumed that jobsend appended newlines to each message since ch_sendexpr did but that was not the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading the documentation and stubling upon an example made me find the solution. When using ch_sendraw in normal vim I would also need newlines, so it all makes sense.&lt;/p&gt;&#xA;" OwnerUserId="17796" LastActivityDate="2018-06-10T20:35:49.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16459" PostTypeId="1" CreationDate="2018-06-11T01:06:05.463" Score="6" ViewCount="870" Body="&lt;p&gt;Often the mechanism to end up in the command line window is a transposition typo &lt;code&gt;q:&lt;/code&gt; instead of &lt;code&gt;:q&lt;/code&gt; when I intend to be closing Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can imagine the frustration at this point because the program state is now such that I have to (more carefully) type TWO more proper &lt;code&gt;:q&lt;/code&gt; to achieve my goal. Although I do have, and can use a nice easy normal mode chord bind &lt;code&gt;&amp;lt;s-q&amp;gt;&lt;/code&gt; for &lt;code&gt;:q&lt;/code&gt;, my muscle memory and habits (using non-augmented vims) lead me to continue to use &lt;code&gt;:q&lt;/code&gt;, so it is not a full solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In an effort to mitigate this situation, I have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap q: &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works, however, now the &lt;code&gt;q&lt;/code&gt; has an input delay (due to being bound now) and therefore causes the action of exiting from recording a macro/recording to be latent. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I remove my ability to enter the command line window without introducing such consequences?&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-10-11T14:18:59.177" Title="Is there a way to disable the command line window?" Tags="|key-bindings|command-line-window|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="16460" PostTypeId="2" ParentId="2280" CreationDate="2018-06-11T03:55:41.620" Score="26" Body="&lt;p&gt;[d]elete all lines not(!) matching patterns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g!/pattern/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or even simpler (thanks for the comments by 'B Layer'):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:v/pattern/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17821" LastEditorUserId="17821" LastEditDate="2019-05-28T00:55:56.337" LastActivityDate="2019-05-28T00:55:56.337" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16461" PostTypeId="1" AcceptedAnswerId="16464" CreationDate="2018-06-11T04:02:48.443" Score="5" ViewCount="901" Body="&lt;p&gt;Been to trying to figure out why pasting an emoji from the clipboard doesn't paste properly when using &lt;kbd&gt;⌘&lt;/kbd&gt; + &lt;kbd&gt;v&lt;/kbd&gt; on macOS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following key bindings in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;M-c&amp;gt; &quot;+y&#xA;nnoremap &amp;lt;M-v&amp;gt; &quot;+p&#xA;inoremap &amp;lt;M-v&amp;gt; &amp;lt;esc&amp;gt;&quot;+p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way to get a list of escape sequences so I can hopefully get the proper emoji to paste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://asciinema.org/a/186502&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://asciinema.org/a/186502.png&quot; alt=&quot;asciicast&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10550" LastActivityDate="2018-06-11T13:09:50.800" Title="Pasting emojis  in Vim or Neovim" Tags="|vimrc|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16462" PostTypeId="1" AcceptedAnswerId="16463" CreationDate="2018-06-11T10:22:36.410" Score="2" ViewCount="330" Body="&lt;p&gt;I am wondering what the way of copying a line and pasting it below my cursor in vi/vim might be?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current workflow (copy line 21 and paste it below cursor): &lt;code&gt;21ggyy''p&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something shorter like: &lt;code&gt;21gyp&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used emacs avy (&lt;a href=&quot;https://github.com/abo-abo/avy&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/abo-abo/avy&lt;/a&gt;) to do these kind of things before&lt;/p&gt;&#xA;" OwnerUserId="17824" LastActivityDate="2018-06-11T11:40:06.203" Title="copy line XX and paste it below my cursor (avy / ace jump style)" Tags="|key-bindings|cut-copy-paste|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16463" PostTypeId="2" ParentId="16462" CreationDate="2018-06-11T10:41:52.263" Score="5" Body="&lt;p&gt;I mean &lt;code&gt;21ggyy''p&lt;/code&gt; is pretty fast, but here's a simple ex command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:21t.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Act on line 21&lt;/li&gt;&#xA;&lt;li&gt;t for copy ( &lt;code&gt;:copy&lt;/code&gt; also works here)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt; Is special for the current line.&#xA;(&lt;code&gt;:h :t&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can also supply relative ranges for both the location and destination e.g. &lt;code&gt;-5t+7&lt;/code&gt; (copy the line 5 lines above the cursor to 7 below). Use &lt;code&gt;:m&lt;/code&gt; instead of &lt;code&gt;:t&lt;/code&gt; to move a line. Alternatively &lt;code&gt;:21y&lt;/code&gt; to yank the line and paste with &lt;code&gt;p&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim-easymotion seems to be similar to what avy is in emacs so you could also have a look at that.&lt;/p&gt;&#xA;" OwnerUserId="16910" LastEditorUserId="16910" LastEditDate="2018-06-11T11:40:06.203" LastActivityDate="2018-06-11T11:40:06.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16464" PostTypeId="2" ParentId="16461" CreationDate="2018-06-11T13:09:50.800" Score="3" Body="&lt;p&gt;It was totally an issue with iTerm2 and not mapping &lt;kbd&gt;⌘&lt;/kbd&gt; + &lt;kbd&gt;v&lt;/kbd&gt; to &lt;code&gt;^[v&lt;/code&gt; within the iTerm2 settings.&lt;/p&gt;&#xA;" OwnerUserId="10550" LastActivityDate="2018-06-11T13:09:50.800" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16465" PostTypeId="1" AcceptedAnswerId="16466" CreationDate="2018-06-11T13:29:00.293" Score="2" ViewCount="121" Body="&lt;p&gt;I want to figure out the bit-width of the built-in &lt;code&gt;Number&lt;/code&gt; (integer actually) of Vimscript . In particular, I want to tell whether a &lt;code&gt;32-bit&lt;/code&gt; or &lt;code&gt;64-bit&lt;/code&gt; integer is in use. Currently I test whether the maximum constants of both widths can be represented:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:INT32_MAX = 2147483647 &quot; 2^31-1&#xA;let s:INT64_MAX = 9223372036854775807 &quot; 2^63-1&#xA;&#xA;if s:INT64_MAX &amp;gt; 0&#xA;  let s:INT_WIDTH = 64&#xA;  let s:INT_MAX = s:INT64_MAX&#xA;else&#xA;  let s:INT_WIDTH = 32&#xA;  let s:INT_MAX = s:INT32_MAX&#xA;endif&#xA;let s:INT_MIN = -s:INT_MAX - 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This approach has the annoying magic numbers in code. Although it can be replaced by &lt;code&gt;float2nr(pow(2, 31))&lt;/code&gt;, which is exactly &lt;code&gt;s:INT_MAX&lt;/code&gt; above, this requires &lt;code&gt;has('float')&lt;/code&gt;. I wonder if there is any feature that can be tested like &lt;code&gt;has('num64')&lt;/code&gt;. I searched through the &lt;code&gt;:h +feature-list&lt;/code&gt; but found nothing more relevant than OS information like &lt;code&gt;+win32&lt;/code&gt;. Any insight on this question is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="17314" LastActivityDate="2018-06-11T16:55:20.127" Title="How to determine the bit-width of the Number type in Vimscript?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16466" PostTypeId="2" ParentId="16465" CreationDate="2018-06-11T13:57:31.590" Score="2" Body="&lt;p&gt;You can directly test for the 64-bit number support feature using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;has('num64')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The minimum and maximum numbers can be obtained using &lt;code&gt;0/0&lt;/code&gt; and &lt;code&gt;1/0&lt;/code&gt; respectively:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let VARNUM_MIN = 0/0&#xA;let VARNUM_MAX = 1/0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get the bit-depth of these numbers, you can use &lt;code&gt;printf&lt;/code&gt; with a binary format.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let bits = len(printf('%b', 1/0))         &quot; returns 63&#xA;let bits_nan = len(printf('%b', 0/0))     &quot; returns 64&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can just check if &lt;code&gt;bits&lt;/code&gt; is greater than 32, or less than or equal to 32.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-06-11T16:55:20.127" LastActivityDate="2018-06-11T16:55:20.127" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="16467" PostTypeId="2" ParentId="16396" CreationDate="2018-06-11T15:36:15.637" Score="2" Body="&lt;h1&gt;Colorschemes (in general)&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;When executing the &lt;code&gt;:colorscheme {name}&lt;/code&gt; command, vim&lt;sup&gt;1&lt;/sup&gt; searches &lt;code&gt;runtimepath&lt;/code&gt;&lt;sup&gt;2&lt;/sup&gt; for the file &lt;code&gt;colors/{name}.vim&lt;/code&gt;. This is explained under &lt;code&gt;:help :colorscheme&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Why We Care&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If I wanted to install the &lt;code&gt;molokai&lt;/code&gt; theme &lt;em&gt;by itself&lt;/em&gt;, I could conceivably grab the &lt;a href=&quot;https://github.com/tomasr/molokai/blob/master/colors/molokai.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;file&lt;/a&gt; form GitHub and put it in my vim&lt;sup&gt;3&lt;/sup&gt; directory under &lt;code&gt;colors&lt;/code&gt;. Then &lt;code&gt;:color molokai&lt;/code&gt; would work just fine. But then my only recourse to update it would be copying the file again whenever I felt like doing so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things like vim &lt;a href=&quot;http://vimcasts.org/episodes/packages/&quot; rel=&quot;nofollow noreferrer&quot;&gt;packages&lt;/a&gt;, &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow noreferrer&quot;&gt;pathogen&lt;/a&gt;, and other &lt;a href=&quot;https://github.com/gmarik/vundle&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin managers&lt;/a&gt; were born to help with this. They have the explicit goal of allowing an entire repository of code to become a part of the runtime path. Effectively, this means that a repo with &lt;code&gt;colors&lt;/code&gt;, &lt;code&gt;plugin&lt;/code&gt;, and &lt;code&gt;after&lt;/code&gt; can become a mini vim directory, having it's files loaded as within my personal vim directory.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Why We Care (part 2)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/flazz/vim-colorschemes&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;flazz/vim-colorschemes&lt;/code&gt;&lt;/a&gt; is a &lt;em&gt;repo&lt;/em&gt;. It's not one colorscheme, it's a whole bunch. So, either&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Clone it to &lt;code&gt;$MYVIMDIRECTORY/colors&lt;/code&gt;&lt;sup&gt;3&lt;/sup&gt; ; or&lt;/li&gt;&#xA;&lt;li&gt;Put it in a package; or&lt;/li&gt;&#xA;&lt;li&gt;Use a plugin manager of your choice.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The key here is that the colors directory provided by &lt;a href=&quot;https://github.com/flazz/vim-colorschemes&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;flazz/vim-colorschemes&lt;/code&gt;&lt;/a&gt; must be on your runtimepath&lt;sup&gt;4&lt;/sup&gt;. Again, packages, plugin managers, or simply the base colors directory are the options here, each with their merits and difficulties. I recommend packages, but to each his own.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Solving the OPs Problem&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I suspect that the OP's main problem is where to put the directory &lt;code&gt;colors&lt;/code&gt; from &lt;a href=&quot;https://github.com/flazz/vim-colorschemes&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;flazz/vim-colorschemes&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&quot;Standard&quot;: Put the colors directory in your vim&lt;sup&gt;3&lt;/sup&gt; directory (such that &lt;code&gt;vim/colors&lt;/code&gt; is the directory from the repo)&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Benefits: extremely backwards compatible&lt;/li&gt;&#xA;&lt;li&gt;Downsides: difficult to add new colorschemes to this directory, as it is now a git repository&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Packages: Put the whole repo in your vim&lt;sup&gt;3&lt;/sup&gt; directory under &lt;code&gt;pack/{your_package_name}/opt&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Benefits: keep one plugin repo isolated from another, builtin to vim&lt;/li&gt;&#xA;&lt;li&gt;Downsides: vim 8 required (not sure about nvim)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Plugin manager: Do what they tell you to do (e.g. with Pathogen it would be at &lt;code&gt;vim/bundle/vim-colorschemes&lt;/code&gt; or similar)&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Benefits: plugin manager does a lot of heavy-lifting for you (Pathogen is different--it was effectively packages before packages were created)&lt;/li&gt;&#xA;&lt;li&gt;Downsides: Learn a new tool, more requirements to making your vim config portable&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then make sure &lt;code&gt;color {name}&lt;/code&gt; is in your vimrc/init.vim.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Notes&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;For this post, &lt;code&gt;vim&lt;/code&gt; refers to both Vim and NeoVim&lt;/li&gt;&#xA;&lt;li&gt;Vim uses (effectively) &lt;code&gt;~/.vim, $VIMRUNTIME, ~/.vim/after&lt;/code&gt; (&lt;code&gt;:help rtp&lt;/code&gt;). NeoVim uses the &lt;a href=&quot;https://neovim.io/doc/user/starting.html#xdg&quot; rel=&quot;nofollow noreferrer&quot;&gt;XDG standard&lt;/a&gt;, so it's something like &lt;code&gt;~/.config/nvim&lt;/code&gt; for Unix and &lt;code&gt;~/AppData/Local/nvim&lt;/code&gt; for Windows&lt;/li&gt;&#xA;&lt;li&gt;See #2: This is going to be one of &lt;code&gt;~/.vim, ~/_vim, ~/.config/nvim, ~/AppData/Local/nvim&lt;/code&gt; depending on your vim and OS.&lt;/li&gt;&#xA;&lt;li&gt;Note that this is pretty much explicitly covered in the &lt;a href=&quot;https://github.com/flazz/vim-colorschemes/blob/master/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;README&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://unix.meta.stackexchange.com/questions/4086/psa-please-dont-post-images-of-text&quot;&gt;Based on the screenshot&lt;/a&gt; in the OP, the &lt;code&gt;AppData&lt;/code&gt; path is the right one for this Q&amp;amp;A. This can be verified with &lt;code&gt;:echo &amp;amp;rtp&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-06-11T15:36:15.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16468" PostTypeId="1" CreationDate="2018-06-11T17:03:02.163" Score="1" ViewCount="104" Body="&lt;p&gt;I have a binding that I use heavily and is very close to my heart. However, it tends to break (only a few) other functionality, primarily the command-line window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bind is normal mode : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; Highlighting()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For completionism, here is Highlighting: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:highlighting = 1&#xA;function! Highlighting()&#xA;    let l:word = expand('let')&#xA;    if g:highlighting == 1 &amp;amp;&amp;amp; @/ =~ '^\\&amp;lt;'.l:word.'\\&amp;gt;$'&#xA;        let g:highlighting = 0&#xA;        return &quot;:silent nohlsearch\&amp;lt;CR&amp;gt;&quot;&#xA;    endif&#xA;    let @/ = '\&amp;lt;'.l:word.'\&amp;gt;'&#xA;    &quot; add to history -- can clutter, but def helps&#xA;    &quot; NOTE! the item is added without /v so backspace first, then hunt&#xA;    call histadd('search', '\v&amp;lt;' . l:word . '&amp;gt;')&#xA;    let g:highlighting = 1&#xA;    &quot; save this to file system (!) for fast workflow -- disabled now because its &#xA;    &quot; visually distracting and i need an async way to deal with this...&#xA;    &quot; silent exe &quot;!echo &quot; . l:word . &quot; &amp;gt; $HOME/.vim/.search&quot;&#xA;    &quot; redraw!&#xA;    if has('python')&#xA;        python &amp;lt;&amp;lt; EOF&#xA;from os.path import expanduser&#xA;f = open(expanduser('~') + '/.vim/.search', 'w')&#xA;# print f&#xA;w = vim.eval(&quot;l:word&quot;)&#xA;f.write(w)&#xA;f.close()&#xA;EOF&#xA;    endif&#xA;    return &quot;:silent set hlsearch\&amp;lt;CR&amp;gt;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OK, so, again, this is very useful and I use it &lt;em&gt;heavily&lt;/em&gt;, so I cannot rebind it, but it actually prevents the command-line window from functioning because it means I can't actually run the command my cursor is on... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I mitigate this while still retaining the ease of use in normal mode in a regular buffer? For 5 years I've had this and avoided using the command-line window and now I am hoping to keep this functional and start being able to use the command-line window somehow.&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-06-11T17:03:02.163" Title="applying a map only to normal buffers" Tags="|key-bindings|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16469" PostTypeId="1" CreationDate="2018-06-11T17:43:19.403" Score="1" ViewCount="53" Body="&lt;p&gt;I remap Shift + k to &lt;code&gt;noh&lt;/code&gt;, but once I installed &lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ale&lt;/a&gt;, it is no longer working since one of the command on the package uses the shortcut.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At least as far as I know, I feel that it is related to docstring on Python (likely it outputs the content of the docstring in a file), but even though I searched on the documentation (&lt;code&gt;help ale&lt;/code&gt;) using seemingly relevant keywords, I failed to detect which command triggers the shortcut. Reading the documentation all from the top to the bottom is not a solution here (I wish you understand it...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there any way to find which function triggers the shortcut on a third-party library? What I want is prioritize my own custom key remapping over the third-party's.&lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2018-06-11T17:43:19.403" Title="How can I detect which command triggers a shortcut in a third-party package?" Tags="|key-bindings|plugin-ale|" AnswerCount="0" CommentCount="5" ClosedDate="2018-12-05T15:42:50.120" ContentLicense="CC BY-SA 4.0" />
  <row Id="16470" PostTypeId="1" AcceptedAnswerId="16471" CreationDate="2018-06-12T12:49:52.063" Score="11" ViewCount="3097" Body="&lt;p&gt;I’m trying to set the syntax of Processing files (*.pde) to &lt;code&gt;java&lt;/code&gt; with a ftplugin.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.vim/&#xA;  after/&#xA;    ftdetect/&#xA;        pde.vim&#xA;    ftplugin/&#xA;        processing.vim  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;after/ftdetect/pde.vim&lt;/code&gt; I detect the filetype:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufReadPost *.pde set filetype=processing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;after/ftplugin/processing.vim&lt;/code&gt; I set the syntax.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal syntax=java&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;When I open &lt;code&gt;file.pde&lt;/code&gt; &lt;code&gt;:set ft?&lt;/code&gt; says &lt;code&gt;processing&lt;/code&gt;. However, &lt;code&gt;:set syntax?&lt;/code&gt; gives &lt;code&gt;processing&lt;/code&gt; as well!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made sure  that &lt;code&gt;ftplugin on&lt;/code&gt; is set, and setting other options (like e.g. &lt;code&gt;tabstop=4&lt;/code&gt;) do take effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;code&gt;:scriptnames&lt;/code&gt; gives &lt;code&gt;~/.vim/after/ftplugin/processing.vim&lt;/code&gt; as the last entry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anybody an idea what’s going wrong?&lt;/p&gt;&#xA;" OwnerUserId="15716" LastActivityDate="2023-04-14T04:07:24.013" Title="Setting syntax in ftplugin" Tags="|syntax-highlighting|plugin-system|filetype|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16471" PostTypeId="2" ParentId="16470" CreationDate="2018-06-12T13:51:41.660" Score="5" Body="&lt;p&gt;It is unclear why you are using the &lt;code&gt;after&lt;/code&gt; directory. From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#after%2ddirectory&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help after-directory&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5. In the &quot;after&quot; directory in your home directory.  This is for&#xA;   personal preferences to overrule or add to the distributed defaults&#xA;   or system-wide settings (rarely needed).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So unless you are overwriting the &lt;code&gt;ftplugin&lt;/code&gt; preferences from a plugin, you should use the &lt;code&gt;.vim/ftplugin/processing.vim&lt;/code&gt;. For details you check &lt;a href=&quot;http://vimhelp.appspot.com/usr_43.txt.html#filetype%2dplugin&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help filetype-plugin&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#write%2dfiletype%2dplugin&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help write-filetype-plugin&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The filetype detection could also be done without the &lt;code&gt;after&lt;/code&gt;, as explained in &lt;a href=&quot;http://vimhelp.appspot.com/filetype.txt.html#new%2dfiletype&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help new-filetype&lt;/code&gt;&lt;/a&gt;. One of the recommend ways it to use the &lt;code&gt;filetype.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C. If your file type can be detected by the file name.&#xA;   1. Create your user runtime directory.  You would normally use the first&#xA;      item of the 'runtimepath' option.  Example for Unix: &amp;gt;&#xA;    :!mkdir ~/.vim&#xA;&#xA;   2. Create a file that contains autocommands to detect the file type.&#xA;      Example: &amp;gt;&#xA;    &quot; my filetype file&#xA;    if exists(&quot;did_load_filetypes&quot;)&#xA;      finish&#xA;    endif&#xA;    augroup filetypedetect&#xA;      au! BufRead,BufNewFile *.mine     setfiletype mine&#xA;      au! BufRead,BufNewFile *.xyz      setfiletype drawing&#xA;    augroup END&#xA;      Write this file as &quot;filetype.vim&quot; in your user runtime directory.  For&#xA;      example, for Unix: &amp;gt;&#xA;    :w ~/.vim/filetype.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I moved ftdetect and ftplugin out of ~/.vim/after/ to ~/.vim/ but it doesn’t change anything. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Indeed, I tried it here with the same results. As suggested in the comments, &lt;code&gt;:verbose set syntax?&lt;/code&gt; showed the culprit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set up the connection between FileType and Syntax autocommands.&#xA;&quot; This makes the syntax automatically set when the file type is detected.&#xA;augroup syntaxset&#xA;  au! FileType *    exe &quot;set syntax=&quot; . expand(&quot;&amp;lt;amatch&amp;gt;&quot;)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#FileType&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help FileType&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FileType            When the 'filetype' option has been set. (...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So despite you set the syntax correctly, after your &lt;code&gt;ftplugin&lt;/code&gt; is loaded the autocmd above overwrites it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As this is in the Vim runtime files, you shouldn't change it. So one option would be to set the filetype to java, and on the java &lt;code&gt;ftplugin&lt;/code&gt;check the file extension (e.g.: using &lt;code&gt;expand(&quot;%:e&quot;)&lt;/code&gt;) and set the pde options instead of the java options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach would be delaying the setting of the syntax until the filetype is finished:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/ftplugin/pde.vim&#xA;if exists(&quot;b:did_ftplugin&quot;)&#xA;   finish&#xA;endif&#xA;&#xA;augroup pdeSyntax&#xA;   au!&#xA;   autocmd Syntax          &amp;lt;buffer&amp;gt; call SetPdeSyntax()&#xA;augroup END&#xA;function! SetPdeSyntax()&#xA;   &quot; remove the augroup&#xA;   au! pdeSyntax&#xA;   set syntax=java&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1405" LastEditorUserId="1405" LastEditDate="2018-06-13T12:32:18.967" LastActivityDate="2018-06-13T12:32:18.967" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16472" PostTypeId="2" ParentId="16432" CreationDate="2018-06-12T19:59:08.557" Score="2" Body="&lt;p&gt;I have made a small plugin &lt;a href=&quot;https://github.com/chrisbra/vpager&quot; rel=&quot;nofollow noreferrer&quot;&gt;vpager&lt;/a&gt;. That allows to dump the terminal output back into Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last commit in addition allows to use the output and dump it into the quickfix list. So you can simply do &lt;code&gt;:make |vpager -Q&lt;/code&gt; and it should be loaded back in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(It might need adjustments for the errorformat setting, not sure).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;excerpt from the &lt;a href=&quot;https://github.com/chrisbra/vpager/blob/master/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;README&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git diff | vpager -nC 'ft=diff'&#xA;&#xA;  Copies the output of git diff into a buffer inside Vim. Any previous&#xA;  output in the buffer will be cleared and the filetype will be set&#xA;  to &quot;diff&quot;, for proper syntax highlighting.&#xA;&#xA;  grep -n &amp;lt;searchterm&amp;gt; files | vpager -Q&#xA;&#xA;  Parses the grep -n output, copies it back into the quickfix buffer&#xA;  and opens the first result in a new window.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-06-12T20:09:46.530" LastActivityDate="2018-06-12T20:09:46.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16473" PostTypeId="1" CreationDate="2018-06-12T23:44:35.353" Score="3" ViewCount="2106" Body="&lt;p&gt;Let's say I have text like this,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPAC     SPAC - Specific-Purpose Committee Campaign Finance Report &#xA;SPAC-SS  SPAC-SS - Specific-Purpose Committee Special Session Report          &#xA;SPAC-T   SPAC-T -  PAC Special Pre-election (Telegram) Report of Contributions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now how would I use vim-surround to surround to get,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'SPAC'     SPAC - Specific-Purpose Committee Campaign Finance Report &#xA;'SPAC-SS'  SPAC-SS - Specific-Purpose Committee Special Session Report          &#xA;'SPAC-T'   SPAC-T -  PAC Special Pre-election (Telegram) Report of Contributions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can use block surround entering visual-block mode with &lt;kbd&gt;CONTROL&lt;/kbd&gt; + &lt;kbd&gt;v&lt;/kbd&gt;, making the selection and using &lt;code&gt;S'&lt;/code&gt;, but I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'SPAC    ' SPAC - Specific-Purpose Committee Campaign Finance Report &#xA;'SPAC-SS ' SPAC-SS - Specific-Purpose Committee Special Session Report          &#xA;'SPAC-T  ' SPAC-T -  PAC Special Pre-election (Telegram) Report of Contributions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideally, I would have a better method that would do inner word. What would work in this situation, trimming the whitespace from both sides of the collection?&lt;/p&gt;&#xA;" OwnerUserId="5078" LastActivityDate="2022-10-11T21:13:17.973" Title="Visual block mode and vim surround?" Tags="|plugin-vim-surround|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16475" PostTypeId="2" ParentId="16459" CreationDate="2018-06-13T06:38:57.957" Score="1" Body="&lt;p&gt;I have not found a way to disable the command-line window, but, I have eliminated the need for the &lt;code&gt;q:&lt;/code&gt; bind of mine, by removing it and changing the rest of my vim config to allow my command-line window to work again as intended. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could say this is solved by application of the XY problem principle.&lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-06-13T06:38:57.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16476" PostTypeId="2" ParentId="16473" CreationDate="2018-06-13T07:54:26.697" Score="3" Body="&lt;p&gt;In my opinion the best way to do what you want is to use a substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/[^ ]\+/'\0'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is decomposed like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;                  the range of lines you want to treat (you could use % is you want to change all the lines of the buffer, or use line numbers e.g. 1,10)&#xA;     s/                the substitution command&#xA;       [^ ]\+          all the characters until the first white space&#xA;             /&#xA;              '\0'     \0 is what you matched before and it is surrounded by quotes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you really want to use vim-surround you could use a macro. First empty your register with &lt;code&gt;qaq&lt;/code&gt;, then on the first line use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa0ysW'jq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa           record a macro in the register a&#xA;  0          move to the beginning of the line&#xA;   ysW'      surround the word with simple quotes&#xA;       j     move one line down&#xA;        q    stop recording&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use &lt;code&gt;10@a&lt;/code&gt; to execute the macro 10 ten times (so on the ten next lines)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that even with a macro you don't need the surround plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qaI'&amp;lt;Esc&amp;gt;Ea'jq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa               record the macro&#xA;  I'             insert a quote at the beginning of the line&#xA;    &amp;lt;Esc&amp;gt;        exist insert mode&#xA;         E       go to the end of the first word&#xA;          a'     insert a quote after the word&#xA;            j    go down one line&#xA;             q   stop recording&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-06-13T08:27:26.083" LastActivityDate="2018-06-13T08:27:26.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16477" PostTypeId="1" AcceptedAnswerId="16478" CreationDate="2018-06-13T08:21:01.083" Score="1" ViewCount="47" Body="&lt;p&gt;I want to align commens on multiple lines neatly, and found &lt;a href=&quot;https://stackoverflow.com/questions/7248621/align-end-of-line-comments-in-vim&quot;&gt;the following question and answer&lt;/a&gt; (I used the tabular package), but then I found out that it needs the comment specifier NOT to be shown on the same line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if it is the following line to align the comment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call dein#add(&quot;vim-airline/vim-airline&quot;) &quot; more info on the bottom &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It breaks as the align happens on the &lt;code&gt;&quot;vim-airline...&lt;/code&gt; part, not on the end of the line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also found &lt;a href=&quot;https://vi.stackexchange.com/questions/13051/how-can-i-right-align-end-of-line-comments-with-the-tabular-plugin&quot;&gt;this question and answer&lt;/a&gt; but it only work if only one comment specifier is shown before the actual one (in this case there are two, as it quotes the string).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to only apply the alignment at the last element of a line? &lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2018-06-13T08:50:32.380" Title="How can I align the comment at the end of sentences when the comment predictor is already shown?" Tags="|formatting|alignment|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16478" PostTypeId="2" ParentId="16477" CreationDate="2018-06-13T08:50:32.380" Score="2" Body="&lt;p&gt;With &lt;a href=&quot;https://github.com/godlygeek/tabular&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tabular&lt;/a&gt; you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;Tabular / &quot;.\{-}$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will transform &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call dein#add(&quot;scrooloose/nerdcommenter&quot;) &quot; more info on the bottom&#xA;call dein#add(&quot;godlygeek/tabular&quot;) &quot; more info on the bottom&#xA;call dein#add(&quot;tpope/vim-surround&quot;) &quot; more info on the bottom&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call dein#add(&quot;scrooloose/nerdcommenter&quot;)  &quot; more info on the bottom&#xA;call dein#add(&quot;godlygeek/tabular&quot;)         &quot; more info on the bottom&#xA;call dein#add(&quot;tpope/vim-surround&quot;)        &quot; more info on the bottom&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pattern &lt;code&gt;/ &quot;.\{-}$&lt;/code&gt; will match a &lt;code&gt;&quot;&lt;/code&gt; character followed by as few as possible characters (&lt;code&gt;.\{-}&lt;/code&gt;) until the end of the line &lt;code&gt;$&lt;/code&gt;). If you don't use tabular but a similar plugin you should be able to use the same pattern.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-06-13T08:50:32.380" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16479" PostTypeId="2" ParentId="2796" CreationDate="2018-06-13T10:07:20.583" Score="1" Body="&lt;p&gt;I've found a solution to this issue which is surprisingly simple!&#xA;Start visual block mode from the bottom of the selection of the text you want to copy and select upwards! It will expand the block as you go up, whereas if you highlight downwards it appears to make the selection smaller.&lt;/p&gt;&#xA;" OwnerUserId="17857" LastActivityDate="2018-06-13T10:07:20.583" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16480" PostTypeId="1" CreationDate="2018-06-13T11:14:06.043" Score="1" ViewCount="69" Body="&lt;p&gt;I want to highlight all words that have been matched in another syntax region. Using something similar to regex capture groups, for example given a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{highlightme} asda asasd asd asd as hightlightme asd adsasd asd&#xA;asdaskj highlightme weqeqw (highlightme) {highlightme}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to be able to highlight all &lt;code&gt;highlightme&lt;/code&gt; IF any one of the &lt;code&gt;highlightme&lt;/code&gt; is surrounded with curly braces. What I have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region testSurr start=/{/ end=/}/ contains=testKey nextgroup=testAfter&#xA;syntax match testKey /\v\w+/ contained&#xA;syntax region testAfter start=/\v\_.*/ end=/\v\_.*/ contained contains=testKey&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works. It highlights all instances of a word if that word is ever matched in a curly brace. However, it also clears the highlighting of everything else in the file. How can I achieve the same result, but preserve the highlighting of everything else?&lt;/p&gt;&#xA;" OwnerUserId="17848" LastEditorUserId="17848" LastEditDate="2018-06-13T11:20:49.477" LastActivityDate="2024-03-14T16:06:20.920" Title="Syntax - Match word based on a previous match" Tags="|syntax-highlighting|regular-expression|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16481" PostTypeId="2" ParentId="9022" CreationDate="2018-06-13T12:22:47.287" Score="1" Body="&lt;p&gt;You can define a &lt;code&gt;function&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NextFileOrQuit()&#xA;  execute 'try | n | catch | try | wq! | catch | | endtry | endtry'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then setup a &lt;code&gt;normal mode&lt;/code&gt; mapping like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Tab&amp;gt; :call NextFileOrQuit()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this setup, pressing &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; will move through the files and then&#xA;&quot;quit&quot; once it reached the last one.&lt;/p&gt;&#xA;" OwnerUserId="17859" LastEditorUserId="17859" LastEditDate="2018-06-13T16:17:14.093" LastActivityDate="2018-06-13T16:17:14.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16482" PostTypeId="2" ParentId="16473" CreationDate="2018-06-13T14:26:55.957" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Ideally, I would have a better method that would do inner word.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can do that with &lt;code&gt;:normal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm ysiW'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I assume you want an inner WORD not word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also visually select the lines and then do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm ysiW'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :norm&#xA;:h :range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-06-13T14:26:55.957" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16483" PostTypeId="1" CreationDate="2018-06-13T14:37:16.067" Score="1" ViewCount="508" Body="&lt;p&gt;Why does one of Vim's autocomplete functions (ctrl+n) not work in html documents, while the other (ctrl+p) still does?&lt;/p&gt;&#xA;" OwnerUserId="17655" LastActivityDate="2018-08-12T21:01:40.847" Title="Question about autocompletion in Vim editor and html document" Tags="|vimrc|autocompletion|filetype-html|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16484" PostTypeId="1" CreationDate="2018-06-13T15:26:41.687" Score="6" ViewCount="1096" Body="&lt;p&gt;The Explorer context menu entry does not get created by the installer. Windows 10 Pro v1803 (64-bit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have already tried:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Installed Vim 8.1 using the stock Windows installer &lt;a href=&quot;https://ftp.nluug.nl/pub/vim/pc/gvim81.exe&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ftp.nluug.nl/pub/vim/pc/gvim81.exe&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Took the installer option &quot;Add an Edit-with-Vim context menu entry&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Used a Windows user profile with administrator rights. Also tried starting the installer &quot;Run as administrator&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Verified the registry entries, including correct path names, going by the articles:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;“&lt;a href=&quot;http://vim.wikia.com/wiki/Adding_Vim_to_MS-Windows_File_Explorer_Menu&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adding Vim to MS-Windows File Explorer Menu&lt;/a&gt;” at &lt;em&gt;Vim Tips Wiki&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;“&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/gui_w32.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim documentation: gui_w32&lt;/a&gt;” at &lt;em&gt;SourceForge&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These articles covered versions prior to 8.1 but still seemed relevant.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here are the registry entries called out by the articles above. These are the entries that I actually have on the problem PC.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Vim\Gvim]&#xA;&quot;path&quot;=&quot;C:\\Program Files (x86)\\Vim\\vim81\\gvim.exe&quot;&#xA;&#xA;[HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}]&#xA;@=&quot;Vim Shell Extension&quot;&#xA;[HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\InProcServer32]&#xA;@=&quot;C:\\Program Files (x86)\\Vim\\vim81\\GvimExt64\\gvimext.dll&quot;&#xA;&quot;ThreadingModel&quot;=&quot;Apartment&quot;&#xA;&#xA;[HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\gvim]&#xA;@=&quot;{51EEE242-AD87-11d3-9C1E-0090278BBD99}&quot;&#xA;&#xA;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved]&#xA;&quot;{51EEE242-AD87-11d3-9C1E-0090278BBD99}&quot;=&quot;Vim Shell Extension&quot;&#xA;&#xA;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Vim 8.1]&#xA;&quot;DisplayName&quot;=&quot;Vim 8.1 (self-installing)&quot;&#xA;&quot;UninstallString&quot;=&quot;C:\\Program Files (x86)\\Vim\\vim81\\uninstall-gui.exe&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are of course many other Vim related registry entries. Most are plainly nothing to do with the Edit-with-Vim context menu entry for the 64-bit OS. The ones I reproduce below are the ones I could not personally rule out as unrelated to the problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[HKEY_CLASSES_ROOT\*\OpenWithList\gvim.exe]&#xA;@=&quot;&quot;&#xA;&#xA;[HKEY_CLASSES_ROOT\Applications\gvim.exe\shell\edit\command]&#xA;@=&quot;\&quot;C:\\Program Files (x86)\\Vim\\vim81\\gvim.exe\&quot; \&quot;%1\&quot;&quot;&#xA;&#xA;[HKEY_CLASSES_ROOT\TypeLib\{0F0BFAE0-4C90-11D1-82D7-0004AC368519}\1.1]&#xA;@=&quot;Vim OLE Interface 1.1 Type Library&quot;&#xA;[HKEY_CLASSES_ROOT\TypeLib\{0F0BFAE0-4C90-11D1-82D7-0004AC368519}\1.1\0\win32]&#xA;@=&quot;C:\\Program Files (x86)\\Vim\\vim81\\gvim.exe&quot;&#xA;[HKEY_CLASSES_ROOT\TypeLib\{0F0BFAE0-4C90-11D1-82D7-0004AC368519}\1.1\FLAGS]&#xA;@=&quot;0&quot;&#xA;[HKEY_CLASSES_ROOT\TypeLib\{0F0BFAE0-4C90-11D1-82D7-0004AC368519}\1.1\HELPDIR]&#xA;@=&quot;C:\\Program Files (x86)\\Vim\\vim81&quot;&#xA;&#xA;[HKEY_CLASSES_ROOT\Vim.Application]&#xA;@=&quot;Vim&quot;&#xA;[HKEY_CLASSES_ROOT\Vim.Application\CLSID]&#xA;@=&quot;{0F0BFAE1-4C90-11D1-82D7-0004AC368519}&quot;&#xA;[HKEY_CLASSES_ROOT\Vim.Application\CurVer]&#xA;@=&quot;Vim.Application.1&quot;&#xA;[HKEY_CLASSES_ROOT\Vim.Application.1]&#xA;@=&quot;Vim&quot;&#xA;[HKEY_CLASSES_ROOT\Vim.Application.1\CLSID]&#xA;@=&quot;{0F0BFAE1-4C90-11D1-82D7-0004AC368519}&quot;&#xA;&#xA;[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0F0BFAE1-4C90-11D1-82D7-0004AC368519}]&#xA;@=&quot;Vim&quot;&#xA;[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0F0BFAE1-4C90-11D1-82D7-0004AC368519}\LocalServer32]&#xA;@=&quot;C:\\Program Files (x86)\\Vim\\vim81\\gvim.exe&quot;&#xA;[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0F0BFAE1-4C90-11D1-82D7-0004AC368519}\ProgID]&#xA;@=&quot;Vim.Application.1&quot;&#xA;[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0F0BFAE1-4C90-11D1-82D7-0004AC368519}\TypeLib]&#xA;@=&quot;{0F0BFAE0-4C90-11D1-82D7-0004AC368519}&quot;&#xA;[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0F0BFAE1-4C90-11D1-82D7-0004AC368519}\VersionIndependentProgID]&#xA;@=&quot;Vim.Application&quot;&#xA;[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}]&#xA;@=&quot;Vim Shell Extension&quot;&#xA;[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\InProcServer32]&#xA;@=&quot;C:\\Program Files (x86)\\Vim\\vim81\\GvimExt32\\gvimext.dll&quot;&#xA;&quot;ThreadingModel&quot;=&quot;Apartment&quot;&#xA;[HKEY_CLASSES_ROOT\Wow6432Node\TypeLib\{0F0BFAE0-4C90-11D1-82D7-0004AC368519}\1.1]&#xA;@=&quot;Vim OLE Interface 1.1 Type Library&quot;&#xA;[HKEY_CLASSES_ROOT\Wow6432Node\TypeLib\{0F0BFAE0-4C90-11D1-82D7-0004AC368519}\1.1\0\win32]&#xA;@=&quot;C:\\Program Files (x86)\\Vim\\vim81\\gvim.exe&quot;&#xA;[HKEY_CLASSES_ROOT\Wow6432Node\TypeLib\{0F0BFAE0-4C90-11D1-82D7-0004AC368519}\1.1\FLAGS]&#xA;@=&quot;0&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11600" LastEditorUserId="11600" LastEditDate="2018-06-13T19:51:11.960" LastActivityDate="2018-06-13T19:51:11.960" Title="How to create an Edit-with-Vim context menu entry for Vim 8.1 on Windows 10" Tags="|microsoft-windows|installing|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16485" PostTypeId="1" AcceptedAnswerId="16486" CreationDate="2018-06-13T19:12:40.993" Score="5" ViewCount="302" Body="&lt;p&gt;If I have a line say&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;`\\sfdas\lsdfjla\`&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I try to select the text inside the backtics using &lt;code&gt;yi`&lt;/code&gt;, I expect that the entire text inside the backtics should be selected. However, it seems that in VIM 8.0, it doesn't select the entire text &lt;code&gt;\\sfdas\lsdfjla\&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried this with &lt;code&gt;vim -u NONE&lt;/code&gt; to make sure its not a artifact from other plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this by design?&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-06-13T19:22:01.393" Title="Why does VIM not copy the entire text inside the backticks in `\\sfdas\lsdfjla\` if I use `yi``" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16486" PostTypeId="2" ParentId="16485" CreationDate="2018-06-13T19:22:01.393" Score="5" Body="&lt;p&gt;The problem you are seeing comes from the last part, the &lt;code&gt;\`&lt;/code&gt; makes Vim think it is an escaped accent and it will keep looking for another following accent. However since there is none, selecting the text object will fail. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this for your specific case, I would simple unset the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;quoteescape&amp;#39;&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;quoteescape&lt;/code&gt;&lt;/a&gt; option, e.g. &lt;code&gt;:set quoteescape=&lt;/code&gt;.&#xA;Alternatively, you can double the final backslash &lt;code&gt;\\`&lt;/code&gt; which should also work.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-06-13T19:22:01.393" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16487" PostTypeId="2" ParentId="16483" CreationDate="2018-06-13T19:25:38.990" Score="1" Body="&lt;p&gt;&lt;code&gt;ctrl-p&lt;/code&gt; and &lt;code&gt;ctrl-n&lt;/code&gt; does work in &lt;code&gt;html&lt;/code&gt; documents in &lt;code&gt;VIM8&lt;/code&gt;. Its probably something to do with a setting in your &lt;code&gt;vimrc&lt;/code&gt; or one of the plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;get a HTML document with: &lt;code&gt;wget http://www.lsu.edu/OCS/html-tutorials/writingHTML/tut/tut1.html&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;load vim without plugins using &lt;code&gt;vim -u NONE&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;open the &lt;code&gt;tut1.html&lt;/code&gt; file that you just downloaded.&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;ctrl-p&lt;/code&gt; or &lt;code&gt;ctrl-n&lt;/code&gt; and you will see that it works.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To debug:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;do a binary search: break up the number of plugins and their settings you have into 2 parts.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;add one set back in your vimrc, and check if you can &lt;code&gt;vimrc&lt;/code&gt; and default location. (if you are using &lt;code&gt;Vundle&lt;/code&gt;, you can just comment out the lines in your &lt;code&gt;vimrc&lt;/code&gt; to not load those plugins and their settings. If you are using Pathogen, move the 2nd set of plugins to a different location and comment out the settings corresponding to those plugins in your &lt;code&gt;vimrc&lt;/code&gt;.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you can reproduce the problem, do a binary search in those plugins following steps #1,2&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you cant reproduce the problem in step#2, go to the next set of plugins and their associated settings and repeat step #1-3.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-06-13T19:25:38.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16489" PostTypeId="1" AcceptedAnswerId="16491" CreationDate="2018-06-13T19:48:01.937" Score="5" ViewCount="1055" Body="&lt;p&gt;With vim script I can do &lt;code&gt;let found = matchstr(&quot;abbaba&quot;, 'a')&lt;/code&gt; and get back &lt;code&gt;&quot;a&quot;&lt;/code&gt; as a result. How would I matchstr to get back a list of all matches for the string? &lt;code&gt;found == [&quot;a&quot;, &quot;a&quot;, &quot;a&quot;]&lt;/code&gt; as in &lt;code&gt;g/a/&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="17848" LastActivityDate="2018-06-13T21:06:37.887" Title="How to get all/global match results for a string?" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16490" PostTypeId="2" ParentId="16489" CreationDate="2018-06-13T20:43:17.163" Score="2" Body="&lt;p&gt;You can use the &lt;code&gt;{count}&lt;/code&gt; parameter for &lt;code&gt;matchstr()&lt;/code&gt; to increment your way through the string and give you all the matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example &lt;code&gt;MatchStrAll()&lt;/code&gt; function doing just that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MatchStrAll(expr, pat, ...)&#xA;  let start = a:0 ? a:1 : 0&#xA;  let lst = []&#xA;  let cnt = 1&#xA;  let found = match(a:expr, a:pat, start, cnt)&#xA;  while found != -1&#xA;    call add(lst, matchstr(a:expr, a:pat, start, cnt))&#xA;    let cnt += 1&#xA;    let found = match(a:expr, a:pat, start, cnt)&#xA;  endwhile&#xA;  return lst&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo MatchStrAll(&quot;abbaba&quot;, 'a')&#xA;&quot; yields: ['a', 'a', 'a']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h match()&#xA;:h matchstr()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Something different&lt;/h3&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I meant trying to do something like this &lt;code&gt;MatchStrAll(join(getline(1, '$'), &quot;\n&quot;), pattern)&lt;/code&gt; and getting back a list of all matches&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This would be far easier with a substitution and a sub-replace-expression.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let lst = []&#xA;:%s/pattern/\=add(lst, submatch(0))/gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :s&#xA;:h sub-replace-expression&#xA;:h submatch()&#xA;:h List&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-06-13T21:04:44.970" LastActivityDate="2018-06-13T21:04:44.970" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16491" PostTypeId="2" ParentId="16489" CreationDate="2018-06-13T21:06:37.887" Score="9" Body="&lt;p&gt;An alternative to repeatedly calling &lt;code&gt;match(&lt;/code&gt; is to use &lt;code&gt;substitute(&lt;/code&gt; with a &lt;code&gt;\=&lt;/code&gt; expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MatchStrAll(str, pat)&#xA;    let l:res = []&#xA;    call substitute(a:str, a:pat, '\=add(l:res, submatch(0))', 'g')&#xA;    return l:res&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-06-13T21:06:37.887" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16493" PostTypeId="1" CreationDate="2018-06-14T06:32:06.127" Score="2" ViewCount="176" Body="&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Is there a way to control the indentation + comment leader input, when adding a new line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Details:&lt;/strong&gt; I am trying to set &lt;code&gt;formatoptions-=cro&lt;/code&gt; when inserting a new line (in specific syntax region). I tried using the autocommands &lt;code&gt;InsertEnter&lt;/code&gt; and &lt;code&gt;InsertCharPre&lt;/code&gt;, but both are too generic for my use case and I cannot figure out how to only operate on entering an &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; when in insert and &lt;code&gt;o&lt;/code&gt;/&lt;code&gt;O&lt;/code&gt; when in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;InsertCharPre&lt;/code&gt; does not trigger on new line insertions, and &lt;code&gt;InsertEnter&lt;/code&gt; also triggers on typing &lt;code&gt;a&lt;/code&gt;/&lt;code&gt;A&lt;/code&gt;/&lt;code&gt;i&lt;/code&gt;/&lt;code&gt;I&lt;/code&gt;.) What am I missing? Any pointers will be greatly appreciated. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I forgot to mention, that my intention is to dynamically add/suppress a comment-continuation insertion on new line insertions (depending on the syntax region).&lt;/p&gt;&#xA;" OwnerUserId="14393" LastEditorUserId="14393" LastEditDate="2018-06-14T06:55:52.510" LastActivityDate="2023-07-18T20:08:15.990" Title="Dynamically toggle formatoptions based on input" Tags="|indentation|autocmd|formatting|comments|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16494" PostTypeId="2" ParentId="16493" CreationDate="2018-06-14T07:11:44.923" Score="1" Body="&lt;p&gt;&lt;strong&gt;tl;dr:&lt;/strong&gt; I was looking for &lt;code&gt;:set comments+=f:{string}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Details:&lt;/strong&gt; My usecase is, that every time I have the following style starting comment (in a javascript file) and I type &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;/&lt;code&gt;o&lt;/code&gt;/&lt;code&gt;O&lt;/code&gt; it should not yield an auto-indented + auto-commented next line on enter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*::&amp;lt;Enter&amp;gt;&#xA; * &amp;lt;-- I wanted to suppress this&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The solution to this was to &lt;code&gt;:set comments+=f:/*::&lt;/code&gt;, which sets the comment to not be continued with any &lt;code&gt;mb:{string}&lt;/code&gt; comments on the next line. See &lt;code&gt;:help comments&lt;/code&gt; for further details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you still have an answer to &quot;How do I trigger a function on adding a new line?&quot; feel free to answer. ✌️&lt;/p&gt;&#xA;" OwnerUserId="14393" LastActivityDate="2018-06-14T07:11:44.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16495" PostTypeId="2" ParentId="39" CreationDate="2018-06-14T11:24:08.993" Score="12" Body="&lt;p&gt;In insert mode, type the first couple of characters of a word, then press:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;N&lt;/kbd&gt; to insert the next matching word; or&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;P&lt;/kbd&gt; to insert the previous matching word.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This is particularly useful when entering the names of variables in a program.&lt;/p&gt;&#xA;&lt;p&gt;The 'complete' option controls where the keywords are searched (include files, tag files, buffers, and more).&lt;/p&gt;&#xA;&lt;p&gt;The 'completeopt' option controls how the completion occurs (for example, whether a menu is shown).&lt;/p&gt;&#xA;&lt;p&gt;For help on &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;N&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;P&lt;/kbd&gt;, see &lt;code&gt;:help compl-generic&lt;/code&gt; .&lt;/p&gt;&#xA;" OwnerUserId="12265" LastEditorUserId="7244" LastEditDate="2021-09-17T16:56:32.733" LastActivityDate="2021-09-17T16:56:32.733" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16497" PostTypeId="1" CreationDate="2018-06-14T20:57:36.593" Score="0" ViewCount="394" Body="&lt;p&gt;I am interested in finding the faster way to edit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My monitor is rotated 90 degrees vertically. When I code, I can see more lines than a typical monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that using mouse to select is faster than:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Moving to the start of the copy region&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;v&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move the cursor to the end of the copy region&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;y&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Jump to the paste position&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;p&lt;/kbd&gt;/&lt;kbd&gt;P&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is obviously slower than using mouse. Am I missing something here? Can anyone share some insight?&lt;/p&gt;&#xA;" OwnerUserId="16105" LastEditorDisplayName="user25814" LastEditDate="2020-05-19T09:20:48.383" LastActivityDate="2020-05-19T09:20:48.383" Title="Is visual model selection really faster than using mouse?" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="3" ClosedDate="2018-06-15T08:01:35.057" ContentLicense="CC BY-SA 4.0" />
  <row Id="16499" PostTypeId="2" ParentId="16497" CreationDate="2018-06-15T04:53:03.893" Score="0" Body="&lt;p&gt;The main thing I like about vi is not having to move my hands from the keyboard. Even going to the arrow keys seems like a hassle to me. So switching my arm from keyboard to mouse seems like it'd be more exhausting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now regarding if it's faster or not. I guess it depends if there's an easy way to jump to the copy and paste positions but even if it's slow worst case scenario it won't be much slower.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also sometimes it's much easier to copy/paste without the mouse. Let's say you want to replace the contents of brackets that stretch on multiple lines and are also surrounded by brackets ie: ({{(             )}}). Copy/pasting with the mouse would be much more of a hassle than doing it with the keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if you're not copying/replacing something that's in some easily selectable object (brackets, tags, close to some rare symbol) using relative number numbers + movement I feel it's still pretty fast and convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have &lt;a href=&quot;https://vimawesome.com/plugin/vim-multiple-cursors&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vimawesome.com/plugin/vim-multiple-cursors&lt;/a&gt; which is pretty helpful when I want replace a few occurrences of the same text but not all of them and I wouldn't be able to do that using the mouse. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you don't need to be in visual mode to yank.&lt;/p&gt;&#xA;" OwnerUserId="12408" LastActivityDate="2018-06-15T04:53:03.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16500" PostTypeId="2" ParentId="16497" CreationDate="2018-06-15T05:03:26.890" Score="6" Body="&lt;p&gt;You are missing the main point here, keyboard based editing tools are supposed to be faster because you don't have to change your hand position every once in a while.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, seeing how you visually select, you are only starting to use vim. There are much more useful ways of visual selection. The last thing I learnt was this &lt;code&gt;vaB&lt;/code&gt;, which visually selects a block of code. In c/c++/java that means I can select a method with only 3 key presses; I don't even have to know where it started or ended. Stay with it, it'll change your editing style and make your life easier. But you have to stay with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And to bluntly answer your question, you're missing &lt;em&gt;everything useful&lt;/em&gt;. Think about it. You're doing what you were doing with mouse, but now with keyboard. That's not very different at all. You'll need to learn (if you haven't already) about text objects and command line uses and much more.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2018-06-15T05:03:26.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16501" PostTypeId="1" AcceptedAnswerId="16503" CreationDate="2018-06-15T13:18:51.920" Score="7" ViewCount="3176" Body="&lt;p&gt;As you see in the picture, this is the line I mean.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HzmHx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HzmHx.png&quot; alt=&quot;None&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;First off, I'm using Neovim. This line only appears when I try to edit python files. Everything is fine with any other language. I think it's because of Syntastic. If I recall correctly, Syntastic sets a maximum length for each line that is 79 characters. This red line delimits the 79th character. When any character exceeds this line, the &lt;code&gt;This line is too long&lt;/code&gt; warning appears.&lt;/p&gt;&#xA;&lt;p&gt;I tried to edit the maximum line length using this command&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_python_pylint_post_args=&amp;quot;--max-line-length=200&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I also tried to turn Syntastic off for python files but the line is still there even when Syntastic is not working. &lt;a href=&quot;https://pastebin.com/z2bW5DrE&quot; rel=&quot;nofollow noreferrer&quot;&gt;This is my init.vim file&lt;/a&gt;. It's generated by vim bootstrap but I added some edits to it.&lt;/p&gt;&#xA;&lt;p&gt;How to get rid of this red line? Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="17888" LastEditorUserId="16280" LastEditDate="2022-11-05T18:18:49.330" LastActivityDate="2022-11-05T18:18:49.330" Title="Why is there a red line splitting my terminal window into two parts when I open python files?" Tags="|neovim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16502" PostTypeId="1" AcceptedAnswerId="16589" CreationDate="2018-06-15T15:41:58.993" Score="4" ViewCount="728" Body="&lt;p&gt;I've created several keys and each key is working fine.&lt;br&gt;&#xA;Want to find a way to do multiple alignments with single command. Like to create a key mapping, when it's running it can align the specific characters in sequence.&lt;br&gt;&#xA;&lt;code&gt;map &amp;lt;leader&amp;gt;vga&lt;/code&gt; first align all &lt;code&gt;space&lt;/code&gt;, then align all &lt;code&gt;(&lt;/code&gt;, last align all &lt;code&gt;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;example example (&#xA;   .a (a),&#xA;   .ab (ab),&#xA;   .abc (abc)&#xA;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Expected output  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;example example (&#xA;   .a   ( a   ),&#xA;   .ab  ( ab  ),&#xA;   .abc ( abc )&#xA;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;easy_align_delimiters definitions:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let g:easy_align_delimiters = {&#xA;...&#xA;    \ '(': {&#xA;    \     'pattern':       '[(]',&#xA;    \     'left_margin':   1,&#xA;    \     'right_margin':  1,&#xA;    \     'stick_to_left': 0&#xA;    \   },&#xA;    \ ')': {&#xA;    \     'pattern':       '[)]',&#xA;    \     'left_margin':   1,&#xA;    \     'right_margin':  0,&#xA;    \     'stick_to_left': 0&#xA;    \   },&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="13402" LastEditDate="2018-06-18T08:05:39.587" LastActivityDate="2018-06-28T15:10:29.720" Title="vim-easy-align: How to align multiple characters with single command?" Tags="|alignment|plugin-easy-align|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16503" PostTypeId="2" ParentId="16501" CreationDate="2018-06-15T16:09:16.480" Score="4" Body="&lt;p&gt;Add this line to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set colorcolumn=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want colorcolumn to remain but with different color, then add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set colorcolumn=81 &quot; or something you want&#xA;hi ColorColumn cterm=none gui=none guibg=white ctermfg=white &quot; or whatever you like&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2018-06-15T16:09:16.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16504" PostTypeId="1" CreationDate="2018-06-15T17:47:19.867" Score="2" ViewCount="479" Body="&lt;p&gt;I have an &lt;code&gt;exe&lt;/code&gt; program that checks for certain errors in a text file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to create a shortcut (like &lt;code&gt;\+M&lt;/code&gt;) to run that &lt;code&gt;exe&lt;/code&gt; file against the text file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;exe&lt;/code&gt; file's path is &lt;code&gt;C:\Users\xyz\Documents\Checker\manager.exe&lt;/code&gt;, the text file's path is &lt;code&gt;C:\Users\xyz\Desktop\mytextfile.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The manager just needs the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;check [full filepath to the text file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is what I have tried in the VIM plugin file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ExecuteManagerCheck(file)&#xA;    execute ':!start cmd /k &quot;C:\Users\xyz\Documents\checker\manager check &quot; g:file'&#xA;endfunction&#xA;&#xA;nmap &amp;lt;leader&amp;gt;m :call ExecuteManagerCheck(expand('%:p')) &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can someone please help me get the full file path to the current text file open in Vim?&lt;/p&gt;&#xA;" OwnerDisplayName="user17890" LastEditorDisplayName="user579" LastEditDate="2018-09-13T10:22:34.860" LastActivityDate="2021-01-28T15:00:50.097" Title="How do I pass a full filepath to a function in a Vim plug-in?" Tags="|vimscript|microsoft-windows|plugin-vim-plug|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16508" PostTypeId="1" CreationDate="2018-06-16T08:57:05.277" Score="3" ViewCount="2392" Body="&lt;p&gt;My Mac crashed and was forced to restart. So I opened Terminal, try recovering the file, but struggle to correctly recover the file.&lt;/p&gt;&#xA;&lt;p&gt;Specifically, I tried the following command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nvim ~/.config/nvim/init.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then it popped up the following error:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Swap file &amp;quot;~/.local/share/nvim/swap//%Users%me%.config%nvim%init.vim.swp&amp;quot; already exists!&lt;/p&gt;&#xA;&lt;p&gt;[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I chose R (by typing in &lt;code&gt;R&lt;/code&gt;), but then got the following message:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;E305: No swap file found for /Users/me/.config/nvim/init.vim&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;But in &lt;code&gt;~/.local/share/nvim/swap&lt;/code&gt;, there is certainly the swap file, and I wonder why I get the error message above.&lt;/p&gt;&#xA;&lt;p&gt;Is this a bug or what am I missing here?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-08-22T16:53:00.113" Title="How to recover from swap files correctly on Neovim?" Tags="|neovim|swap-file|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16509" PostTypeId="1" AcceptedAnswerId="16511" CreationDate="2018-06-16T09:10:14.523" Score="7" ViewCount="2710" Body="&lt;p&gt;For example, I might accidentally type something like &lt;code&gt;:WQ&lt;/code&gt; and I want it to work like &lt;code&gt;:wq&lt;/code&gt; when a hit enter&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another case is where I am typing a longer command name, for example &lt;code&gt;NERDTreeTabsClose&lt;/code&gt;. (Note that I have the settings ignorecase and smartcase set)&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I might start by typing &lt;code&gt;:nerd&lt;/code&gt; and then hitting tab, which will auto complete to &lt;code&gt;:NERDTree&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;I might then type a little more so that the command mode shows &lt;code&gt;:NERDTreetab&lt;/code&gt; and then I hit tab again.&lt;/li&gt;&#xA;&lt;li&gt;Because I have smart case on, the auto complete will not work. The ideal scenario would be for the auto complete to work&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I would like to keep smartcase on, because that is useful for searches with &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to achieve the behaviour have described above&lt;/p&gt;&#xA;" OwnerUserId="11136" LastActivityDate="2019-04-25T13:12:58.423" Title="How do you make the command mode case insensitive?" Tags="|command-line|letter-case|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16511" PostTypeId="2" ParentId="16509" CreationDate="2018-06-16T14:05:09.713" Score="10" Body="&lt;p&gt;You can dynamically toggle smartcase using autocmds, so when in a &lt;code&gt;:&lt;/code&gt; command line, it is off and when in a &lt;code&gt;/&lt;/code&gt; command line it is on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; assumes set ignorecase smartcase&#xA;augroup dynamic_smartcase&#xA;    autocmd!&#xA;    autocmd CmdLineEnter : set nosmartcase&#xA;    autocmd CmdLineLeave : set smartcase&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-06-16T14:05:09.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16512" PostTypeId="2" ParentId="3359" CreationDate="2018-06-18T01:38:34.293" Score="12" Body="&lt;p&gt;This took hours to figure out, so here's more of a dummies guide for Fedora/Ubuntu, with a special section for Windows. I've created duplicates of this on &lt;a href=&quot;https://ianchanning.wordpress.com/2018/06/18/vim-airline-powerline-fonts-on-fedora-ubuntu-and-windows/&quot; rel=&quot;nofollow noreferrer&quot;&gt;my own blog&lt;/a&gt; and in the &lt;a href=&quot;https://github.com/vim-airline/vim-airline/wiki/Dummies-Guide-to-the-status-bar-symbols-(Powerline-fonts)-on-Fedora,-Ubuntu-and-Windows&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub Airline Wiki&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The first is figuring out what the hell are those strange but nice angle brackets that appear in the vim-airline status bar. The background is that airline is a pure vim version of powerline (which was python), and powerline uses UTF-8 characters to insert those angle brackets. So vim-airline just uses the same UTF-8 characters.&lt;/p&gt;&#xA;&lt;p&gt;Then even if you do manage to get one installed they look uglier than you'd hope because the fonts don't fully work.&lt;/p&gt;&#xA;&lt;h2&gt;&lt;code&gt;.vimrc&lt;/code&gt; settings&lt;/h2&gt;&#xA;&lt;p&gt;The final trick was forcing vim-airline to use the symbols it needs. Copy and paste the settings mentioned in &lt;a href=&quot;https://vi.stackexchange.com/a/3363/11986&quot;&gt;Alexander Myshov's accepted answer here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the &lt;a href=&quot;https://github.com/vim-airline/vim-airline#integrating-with-powerline-fonts&quot; rel=&quot;nofollow noreferrer&quot;&gt;official documentation&lt;/a&gt; it should just be adding &lt;code&gt;let g:airline_powerline_fonts = 1&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt;. However I did this and no luck. This was the final magic sauce that I needed. I don't know why this wasn't automatically created.&lt;/p&gt;&#xA;&lt;p&gt;This is opposite to the &lt;a href=&quot;https://github.com/vim-airline/vim-airline#integrating-with-powerline-fonts&quot; rel=&quot;nofollow noreferrer&quot;&gt;official instructions&lt;/a&gt; but I had this bit wrong at the end which made me question all the font installations. So I suggest you get this configured first and then if you get the fonts working it should magically appear.&lt;/p&gt;&#xA;&lt;p&gt;There's more information in &lt;code&gt;:help airline-customization&lt;/code&gt; and that gives you some simple config settings that you need, just in case.&lt;/p&gt;&#xA;&lt;h2&gt;Kitchen sinking it on Fedora and Ubuntu&lt;/h2&gt;&#xA;&lt;p&gt;This is probably an overkill solution, but first you need to get it consistently working before you can simplify it.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Install the general powerline font &lt;code&gt;sudo dnf install powerline-fonts&lt;/code&gt; (or &lt;code&gt;sudo apt install fonts-powerline&lt;/code&gt;) - this should mean that you can use any font you already have installed. If you don't have an easy way of installing like dnf/apt then there's instructions for manually doing it e.g. &lt;a href=&quot;https://www.tecmint.com/powerline-adds-powerful-statuslines-and-prompts-to-vim-and-bash/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.tecmint.com/powerline-adds-powerful-statuslines-and-prompts-to-vim-and-bash/&lt;/a&gt;, also the official documentation has instructions (&lt;a href=&quot;https://powerline.readthedocs.io/en/latest/installation/linux.html#fonts-installation&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://powerline.readthedocs.io/en/latest/installation/linux.html#fonts-installation&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Now close your terminal re-open and check that the Powerline symbols font is available if you edit the terminal preferences and set a custom font. &lt;strong&gt;You don't want to use the font directly, just check that it's available&lt;/strong&gt;. Now try opening Vim and see if you have nice symbols.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the general powerline font didn't work or if you're trying to improve things you can try installing individual 'patched' fonts, this took a while to figure out, but you can literally just go to the folder you want in &lt;a href=&quot;https://github.com/powerline/fonts/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/powerline/fonts/&lt;/a&gt; and download it, the font that I've liked the most from my tests is the &lt;a href=&quot;https://github.com/powerline/fonts/tree/master/SourceCodePro&quot; rel=&quot;nofollow noreferrer&quot;&gt;Source Code Pro patched font&lt;/a&gt;. Then just open the downloaded font file and click on 'Install'.&lt;/p&gt;&#xA;&lt;p&gt;If you'd rather the command line, you can install &lt;a href=&quot;https://github.com/vim-airline/vim-airline/wiki/FAQ#the-powerline-font-is-not-perfectly-lined-up-or-there-a-bit-of-whitespace-in-between-symbols-or-they-are-cut-off&quot; rel=&quot;nofollow noreferrer&quot;&gt;all patched fonts&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  $ git clone https://github.com/powerline/fonts.git --depth=1&#xA;  $ fonts/install.sh&#xA;  $ rm -rf fonts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will install &lt;strong&gt;all&lt;/strong&gt; the patched mono fonts, but then this gives you a chance to explore the possible fonts. The font list it installs is a pretty awesome list of the available source code fonts. It also means you don't have to faff around installing each of the individual fonts that get included.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Check that the font can be specified in the terminal preferences, re-open your terminal session if you're missing fonts, so note there could be two options here:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The general powerline font is working in which case you can just use the base font e.g. DejaVu Sans Mono&lt;/li&gt;&#xA;&lt;li&gt;If you can't get that working the patched font that you downloaded above should be correct e.g. the equivalent for DejaVu is 'DejaVu Sans Mono for Powerline'.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2&gt;Tweaking Linux&lt;/h2&gt;&#xA;&lt;p&gt;Once I actually got it working for the first time, it was really disappointing as the icons didn't fully match up. But as per the &lt;a href=&quot;https://github.com/vim-airline/vim-airline/wiki/FAQ#the-powerline-font-is-not-perfectly-lined-up-or-there-a-bit-of-whitespace-in-between-symbols-or-they-are-cut-off&quot; rel=&quot;nofollow noreferrer&quot;&gt;FAQ&lt;/a&gt; we need to do some tweaking. I started off with Inconsolata as this gives me a consistent font across Windows and Linux. You can install the general font easily on Ubuntu with &lt;code&gt;apt install fonts-inconsolata&lt;/code&gt; This is what I got:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QObBQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QObBQ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The arrows are too large and are shifted up in an ugly manner.&lt;/p&gt;&#xA;&lt;p&gt;Then I tried all the other default Ubuntu fonts.&lt;/p&gt;&#xA;&lt;p&gt;Ubuntu mono:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6O5aM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6O5aM.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;DejaVu Sans Mono:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ogv8M.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ogv8M.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This has the vertical position correct but the right hand side arrows have a space after them.&lt;/p&gt;&#xA;&lt;h3&gt;Why you use the patched fonts&lt;/h3&gt;&#xA;&lt;p&gt;Using the default fonts relies on the Powerline font to automatically patch existing fonts. However you can improve the look of the airline symbols by using the patched fonts. These are the equivalents using the patched fonts.&lt;/p&gt;&#xA;&lt;p&gt;I display these all at font size 16 as I like to use a larger font, plus it shows up minor issues.&lt;/p&gt;&#xA;&lt;p&gt;Inconsolata for Powerline:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3pSpp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3pSpp.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This still has issues, but they are almost all solved by the dz variation.&lt;/p&gt;&#xA;&lt;p&gt;Inconsolata-dz for Powerline dz:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2TCQN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2TCQN.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This has a hairline fracture on the right hand side arrows, but is otherwise perfect.&lt;/p&gt;&#xA;&lt;p&gt;Ubuntu Mono derivative Powerline Regular:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nX0d0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nX0d0.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This still has annoying issues.&lt;/p&gt;&#xA;&lt;p&gt;DejaVu Sans Mono for Powerline Book:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CJAh4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CJAh4.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This has a hairline fracture on the right hand side arrows, but is otherwise perfect. I actually prefer it to the Inconsolata-dz as the LN icon is more readable.&lt;/p&gt;&#xA;&lt;p&gt;On top of these regulars, I tried almost all the available fonts and my other favourite was Source Code Pro.&lt;/p&gt;&#xA;&lt;p&gt;Source Code Pro for Powerline Medium&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6Ifts.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6Ifts.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This does have issues at size 16 where the arrows are too big, but at size 14 it's almost unnoticeable. The branch and LN icons do overflow to the bottom, but somehow this doesn't annoy me.&lt;/p&gt;&#xA;&lt;p&gt;Source Code Pro for Powerline Light&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tPqbT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tPqbT.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This almost completely solves the issues of the medium font's arrow sizes and makes it about perfect, although there's still the icon overflow.&lt;/p&gt;&#xA;&lt;h3&gt;Source Code Pro&lt;/h3&gt;&#xA;&lt;p&gt;When I was investigating the options for fonts there's a couple of things you notice, some font patches have the absolute minimum in details, if you compare this to the Source Code Pro list it's quite significant. Source Code Pro is a very detailed and complete font that has been considered to work in a large range of scenarios. This kind of completeness matters for edge cases.&lt;/p&gt;&#xA;&lt;p&gt;Used as a patched font it almost perfectly displays the vim-airline bar. The benefit of so many alternatives is the use of the light font which has an even better display of the vim-airline bar.&lt;/p&gt;&#xA;&lt;p&gt;Source Code Pro is also under continued open development on &lt;a href=&quot;https://github.com/adobe-fonts/source-code-pro&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adobe's Github repository&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Handling the delicate flower of Windows (assuming GVim)&lt;/h2&gt;&#xA;&lt;p&gt;The Powerline Font doesn't work with Windows so your only choice is to use a patched font. Also the bash script to install all the fonts doesn't work, so you have to do the same &lt;code&gt;git clone&lt;/code&gt; but then go into each of the individual directories and install the fonts you want.&lt;/p&gt;&#xA;&lt;p&gt;I downloaded all of the &lt;a href=&quot;https://github.com/powerline/fonts/tree/master/SourceCodePro&quot; rel=&quot;nofollow noreferrer&quot;&gt;Source Code Pro patched fonts&lt;/a&gt; and installed them. Even though you install them as individual fonts they get added to Windows as a single font 'Source Code Pro for Powerline' with a separate attribute to specify the weight.&lt;/p&gt;&#xA;&lt;p&gt;Then (assuming &lt;strong&gt;GVim&lt;/strong&gt;) add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Source\ Code\ Pro\ for\ Powerline:h15:cANSI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you want to use the 'Light' font use this.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Source_Code_Pro_Light:h15:cANSI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It doesn't make much sense as it doesn't need to include the 'for Powerline', but that's how it works (I figured it out by setting the font in GVim and then using &lt;code&gt;set guifont?&lt;/code&gt; to check what GVim used). Also I spotted that when you use GVim to switch the font, the font rendering isn't very good. I initially discounted the Light font because when I switched using the GVim menu it rendered badly, but if you put the below into your &lt;code&gt;.vimrc&lt;/code&gt; and restart GVim it should look lovely.&lt;/p&gt;&#xA;&lt;p&gt;Also a nice thing is that you can set your DOS/Powershell prompt to the same font. Then with the patched font it is also possible to get Powerline working in regular Vim within DOS.&lt;/p&gt;&#xA;&lt;p&gt;If you don't believe me, here it is working in Vim in Powershell:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yyeK5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yyeK5.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/huI2x.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/huI2x.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11986" LastEditorUserId="11986" LastEditDate="2024-01-27T12:33:19.010" LastActivityDate="2024-01-27T12:33:19.010" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16513" PostTypeId="1" CreationDate="2018-06-18T06:10:24.477" Score="2" ViewCount="387" Body="&lt;p&gt;I'm trying to find out how to configure neovim in order to edit texts with accented latin characters. I usually set &lt;code&gt;ambiwidth&lt;/code&gt; to &lt;code&gt;double&lt;/code&gt; so Jananese symbols are displayed properly, but then neovim treats accented latin characters also as double-width. When, on the other hand, I set &lt;code&gt;ambiwidth&lt;/code&gt; to &lt;code&gt;single&lt;/code&gt;, the entire text gets completely disfigured, with parts of text not even displayed. Perhaps, I'm missing something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally, I happened to notice everything is fine with vim 8.1 when &lt;code&gt;ambiwidth&lt;/code&gt; is set to &lt;code&gt;single&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the latest neovim (v0.3.1-dev) with xfce4-terminal (0.6.3) on an Ubuntu-based system (14.04).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Solved)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was not familiar with different sorts of terminals, but the problem resolved itself when I switched xfce4-terminal for rxvt-unicode. Now accented latin characters are displayed properly as single-width when I set &lt;code&gt;ambiwidth&lt;/code&gt; to &lt;code&gt;single&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14025" LastEditorUserId="14025" LastEditDate="2018-07-23T05:16:46.837" LastActivityDate="2018-09-21T07:01:30.433" Title="How to deal with accented latin characters on neovim" Tags="|neovim|terminal|unicode|font|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16514" PostTypeId="2" ParentId="11058" CreationDate="2018-06-18T08:23:14.720" Score="7" Body="&lt;p&gt;Homebrew has an option &lt;code&gt;--with-override-system-vi&lt;/code&gt; that can be used with &lt;code&gt;brew install vim&lt;/code&gt; to do this.&lt;/p&gt;&#xA;" OwnerUserId="17916" LastActivityDate="2018-06-18T08:23:14.720" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16515" PostTypeId="1" CreationDate="2018-06-18T09:07:44.640" Score="2" ViewCount="41" Body="&lt;p&gt;I am using conque plugin in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I copy some content into conque, it seems only possible to edit at the end of the command. What I wish to do is to copy something into conque and change a little bit in the middle of the command (use input mode) and execute the whole command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a lot of search I am still lost in doing so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody know the trick?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thx!&lt;/p&gt;&#xA;" OwnerUserId="17917" LastActivityDate="2018-06-18T09:07:44.640" Title="how to edit the command when copy into conque" Tags="|insert-mode|plugin-conque|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16516" PostTypeId="1" CreationDate="2018-06-18T11:07:54.040" Score="1" ViewCount="318" Body="&lt;p&gt;I'm trying to find the right ex command to overwrite the current vim buffer with the system clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant system clipboard register is &lt;code&gt;&quot;+&lt;/code&gt; in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first guess was to use &lt;code&gt;:%+p&lt;/code&gt;; i.e. select the whole buffer &lt;code&gt;%&lt;/code&gt; and then &lt;em&gt;paste&lt;/em&gt; &lt;code&gt;p&lt;/code&gt; the &lt;code&gt;&quot;+&lt;/code&gt; register to the current buffer. But this doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other way around, &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_04.html#04.6&quot; rel=&quot;nofollow noreferrer&quot;&gt;yanking&lt;/a&gt; the current buffer into the system clipboard is accomplished by &lt;code&gt;:%y+&lt;/code&gt;; &lt;code&gt;%&lt;/code&gt; select the whole buffer; &lt;code&gt;y&lt;/code&gt; copy; &lt;code&gt;+&lt;/code&gt; to the system clipboard register.&lt;/p&gt;&#xA;" OwnerUserId="11449" LastEditorUserId="11449" LastEditDate="2018-06-18T11:23:21.767" LastActivityDate="2018-06-18T16:00:35.717" Title="Overwrite buffer with system clipboard by ex command" Tags="|buffers|ex-mode|register|os-clipboard|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16517" PostTypeId="2" ParentId="16516" CreationDate="2018-06-18T11:15:23.740" Score="0" Body="&lt;p&gt;By visual selection, one can (1) select the whole buffer by moving the start of the buffer, with the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;motion&lt;/a&gt; &lt;code&gt;gg&lt;/code&gt;; (2) pressing &lt;code&gt;v&lt;/code&gt;, to transfer to visual mode; (3) executing the motion &lt;code&gt;GG&lt;/code&gt;, to select the whole buffer; (4) accessing the system clipboard register &lt;code&gt;+&lt;/code&gt;, by pressing &lt;code&gt;&quot;+&lt;/code&gt;; and finally, (5) pasting the register into the current buffer, by pressing &lt;code&gt;p&lt;/code&gt;. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still don't know how to do this in the form of a self-contained ex-command though, in which I'm interested.&lt;/p&gt;&#xA;" OwnerUserId="11449" LastEditorUserId="11449" LastEditDate="2018-06-18T16:00:35.717" LastActivityDate="2018-06-18T16:00:35.717" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16518" PostTypeId="1" CreationDate="2018-06-18T11:41:09.830" Score="1" ViewCount="1337" Body="&lt;h1&gt;Current functionality&lt;/h1&gt;&#xA;&lt;p&gt;When I use &lt;code&gt;&amp;lt;C-P&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-Å&amp;gt;&lt;/code&gt; I can respectively search file names and contents. Everything works great.&lt;/p&gt;&#xA;&lt;h1&gt;Target functionality&lt;/h1&gt;&#xA;&lt;p&gt;When prepending either with &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;, I would like to pass the &lt;code&gt;--no-ignore&lt;/code&gt; flag to each command (ex. &lt;code&gt;&amp;lt;legend&amp;gt;&amp;lt;C-P&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;h2&gt;Here are the relevant parts of my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-P&amp;gt; :Files&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-Å&amp;gt; :Find&amp;lt;CR&amp;gt;&#xA;&#xA;Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }&#xA;Plug 'junegunn/fzf.vim' &amp;quot; Fuzzy search&#xA;&#xA;let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob &amp;quot;!{.git,node_modules}/*&amp;quot;' &amp;quot; Enable respecting .gitignore for files&#xA;command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob &amp;quot;!{.git,node_modules}/*&amp;quot; --color &amp;quot;always&amp;quot; '.shellescape(&amp;lt;q-args&amp;gt;), 1,&#xA;\ &amp;lt;bang&amp;gt;0 ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:60%')&#xA;\         : fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'right:50%:hidden', '?'),&#xA;\ &amp;lt;bang&amp;gt;0)&#xA;set grepprg=rg\ --vimgrep&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17919" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-10-19T22:00:51.060" Title="How can I pass extra flags to FZF/ripgrep commands with the leader key?" Tags="|normal-mode|filesystem|multiple-files|find|plugin-fzf|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16519" PostTypeId="2" ParentId="16516" CreationDate="2018-06-18T12:39:57.697" Score="1" Body="&lt;p&gt;You could add the following in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! ReplaceWithClipboard %d | put +&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way when you call the command &lt;code&gt;:ReplaceWithClipboard&lt;/code&gt; vim will&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%d&lt;/code&gt; delete all the lines in the buffer&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;put +&lt;/code&gt; put your clipboard register&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can have a look at&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#put&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h put&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#user-commands&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h user-commands&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-06-18T12:39:57.697" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16520" PostTypeId="1" AcceptedAnswerId="16521" CreationDate="2018-06-19T02:01:26.637" Score="0" ViewCount="531" Body="&lt;p&gt;As I am moving from Windows to Linux for my development machine, I have noticed a difference in vim between the Windows version and the Linux version. The windows will show you the number of highlighted columns at the bottom of the screen where the Linux version does not (or at least how I have it configured). I have looked at the differences between the two settings, and nothing sticks out. What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="17930" LastActivityDate="2018-06-21T16:11:38.453" Title="Number of columns highlighted" Tags="|gvim|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16521" PostTypeId="2" ParentId="16520" CreationDate="2018-06-19T10:31:08.543" Score="0" Body="&lt;p&gt;After opening vim, execute this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set showcmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, add this to your vimrc for permanent solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set showcmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the help docs, &lt;code&gt;:h showcmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'showcmd' 'sc'      boolean (Vim default: on, Vi default: off)&#xA;            global&#xA;Show (partial) command in the last line of the screen.  Set this&#xA;option off if your terminal is slow.&#xA;In Visual mode the size of the selected area is shown:&#xA;- When selecting characters within a line, the number of characters.&#xA;  If the number of bytes is different it is also displayed: &quot;2-6&quot;&#xA;  means two characters and six bytes.&#xA;- When selecting more than one line, the number of lines.&#xA;- When selecting a block, the size in screen characters:&#xA;  {lines}x{columns}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2018-06-19T10:31:08.543" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16522" PostTypeId="1" AcceptedAnswerId="16524" CreationDate="2018-06-19T11:44:38.153" Score="1" ViewCount="45" Body="&lt;p&gt;Hi Vi StackExchange,&lt;/p&gt;&#xA;&lt;h2&gt;A Picture of what I want&lt;/h2&gt;&#xA;&lt;p&gt;Say I have the following in my buffer:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;foo(&amp;quot;a&amp;quot;, &amp;quot;bar&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And I am in normal mode with my point on &lt;code&gt;b&lt;/code&gt; in &lt;code&gt;bar&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now I want to insert some characters, say &lt;code&gt;xyz&lt;/code&gt; before bar. So I press:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;ixyz&amp;lt;esc&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then that leaves my point on z.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;What I want is something that I can press to go to the &lt;em&gt;start&lt;/em&gt; of the last insert some magic key &lt;code&gt;&amp;lt;magic key&amp;gt;&lt;/code&gt; such that:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;ixyz&amp;lt;esc&amp;gt;&amp;lt;magic key&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Leaves me with my point at &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I will then proceed to map the composition &lt;code&gt;&amp;lt;esc&amp;gt;&amp;lt;magic key&amp;gt;&lt;/code&gt; as a secondary exit for me to use.&lt;/p&gt;&#xA;" OwnerUserId="17936" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-06-19T14:50:08.307" Title="Going to the start of insert command on exit" Tags="|insert-mode|escape|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16523" PostTypeId="1" AcceptedAnswerId="16525" CreationDate="2018-06-19T14:46:50.547" Score="2" ViewCount="1723" Body="&lt;p&gt;I'd like to search the current directory recursively for the word under cursor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I have now in my .vimrc (Note I'm on Windows):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;f :vimgrep! &amp;lt;cword&amp;gt; **.* &amp;lt;bar&amp;gt; :copen &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine but it searches all the files including object files, project files, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want &lt;code&gt;vimgrep&lt;/code&gt; to search only &lt;code&gt;.c&lt;/code&gt; &lt;code&gt;.h&lt;/code&gt; &lt;code&gt;.txt&lt;/code&gt; files&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I tried the following, it didn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;f :vimgrep! &amp;lt;cword&amp;gt; **.c **.h **.txt &amp;lt;bar&amp;gt; :copen &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the right way to do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another question: why adding &lt;code&gt;!&lt;/code&gt; after &lt;code&gt;vimgrep&lt;/code&gt; doesn't prevent it from automatically jumping to the first match?&lt;/p&gt;&#xA;" OwnerUserId="16800" LastEditorUserId="16800" LastEditDate="2018-06-19T14:55:58.130" LastActivityDate="2018-06-19T15:17:22.353" Title="How to use vimgrep recursively for specific file extensions?" Tags="|vimgrep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16524" PostTypeId="2" ParentId="16522" CreationDate="2018-06-19T14:50:08.307" Score="0" Body="&lt;p&gt;After performing an insert the marks &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt; are set to the start character and &lt;em&gt;just past the end&lt;/em&gt; of the inserted text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A map like this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-l&amp;gt; &amp;lt;esc&amp;gt;`[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which just leaves insert mode then goes to the &lt;code&gt;'[&lt;/code&gt; mark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also go to the mark without leaving insert mode;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-l&amp;gt; &amp;lt;c-o&amp;gt;`[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-06-19T14:50:08.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16525" PostTypeId="2" ParentId="16523" CreationDate="2018-06-19T15:00:05.640" Score="4" Body="&lt;p&gt;You can use &lt;code&gt;{}&lt;/code&gt; to specify different extensions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;f :vimgrep /&amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;/j **/*.{c,h,txt} &amp;lt;bar&amp;gt; :copen &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some suggestions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use &lt;code&gt;nnoremp&lt;/code&gt; unless you want to recursive mappings&lt;/li&gt;&#xA;&lt;li&gt;You may wanto to look into &lt;code&gt;'wildignore'&lt;/code&gt; to ignore object files and other files which should always be ignored&lt;/li&gt;&#xA;&lt;li&gt;You may want to look into faster project grepping tools. e.g. &lt;a href=&quot;https://github.com/BurntSushi/ripgrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;ripgrep&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://github.com/ggreer/the_silver_searcher&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Silver Searcher&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;You can use the &lt;code&gt;j&lt;/code&gt; flag to prevent &lt;code&gt;:vimgrep&lt;/code&gt; from jumping the first match. e.g. &lt;code&gt;:vimgrep /foo/j **/*&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Using &lt;code&gt;!&lt;/code&gt; with &lt;code&gt;:vimgrep&lt;/code&gt; will abandon the current buffer when jumping to another buffer. See &lt;code&gt;:h abandon&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :vimgrep&#xA;:h 'wildignore'&#xA;:h :grep&#xA;:h 'grepprg'&#xA;:h 'grepformat'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-06-19T15:17:22.353" LastActivityDate="2018-06-19T15:17:22.353" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16527" PostTypeId="1" AcceptedAnswerId="16537" CreationDate="2018-06-19T18:44:42.243" Score="3" ViewCount="673" Body="&lt;p&gt;I would like to start overwriting immediately visually selected text without any additional keystrokes such as &lt;code&gt;c&lt;/code&gt;. I am looking something similar to normal text editor where you can straightaway replace selected text by typing in new text. Thank you for your help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: My main concern is the extra keystroke of &lt;code&gt;c&lt;/code&gt; to start overwriting. Any tips/suggestions that can remove this extra keystroke in any other way are welcome :)&lt;/p&gt;&#xA;" OwnerUserId="17941" LastEditorUserId="17941" LastEditDate="2018-06-20T19:06:19.370" LastActivityDate="2018-06-20T19:43:16.243" Title="How do I start overwriting visually selected text without c" Tags="|visual-mode|replace|" AnswerCount="1" CommentCount="18" ContentLicense="CC BY-SA 4.0" />
  <row Id="16528" PostTypeId="1" CreationDate="2018-06-20T06:46:02.470" Score="8" ViewCount="2835" Body="&lt;p&gt;Here is the relevant content of my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vimwiki_global_ext=0&#xA;let g:vimwiki_list = [{'path': 'C:\Users\&amp;lt;USER&amp;gt;\vimwiki',&#xA;                     \ 'syntax': 'markdown', 'ext': '.md'}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The plugin mapping &lt;code&gt;&amp;lt;leader&amp;gt;ww&lt;/code&gt; creates a new file called &lt;code&gt;index.md&lt;/code&gt; in &lt;code&gt;C:\Users\&amp;lt;USER&amp;gt;\vimwiki&lt;/code&gt; as expected. So I suppose &lt;code&gt;path&lt;/code&gt; is correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that &lt;code&gt;:set ft?&lt;/code&gt; of the &lt;code&gt;index.md&lt;/code&gt; file is always set to &lt;code&gt;vimwiki&lt;/code&gt; (&lt;code&gt;filetype=vimwiki&lt;/code&gt;). I don't know what settings are wrong here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that vimwiki is in &lt;code&gt;/opt&lt;/code&gt; instead of &lt;code&gt;/start&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="1841" LastEditDate="2018-06-20T06:52:01.320" LastActivityDate="2023-04-30T10:49:47.680" Title="Mardown files always have vimwiki filetype (vimwiki plugin)" Tags="|filetype|filetype-markdown|plugin-vimwiki|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16529" PostTypeId="1" AcceptedAnswerId="16531" CreationDate="2018-06-20T07:00:05.360" Score="1" ViewCount="210" Body="&lt;p&gt;Given that I defined &lt;code&gt;let mapleader=&quot;\&amp;lt;Space&amp;gt;&quot;&lt;/code&gt;, I would like to get in the &lt;strong&gt;vimscript&lt;/strong&gt; the value of the &lt;code&gt;leader&lt;/code&gt; as &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; and not as &lt;code&gt;' '&lt;/code&gt;. The latter may be obtained by using &lt;code&gt;get(g:,&quot;mapleader&quot;,&quot;\\&quot;)&lt;/code&gt;, but how to get the former? I'm searching for a formal solution to get &lt;code&gt;Tab&lt;/code&gt; character as &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;, &lt;code&gt;escape&lt;/code&gt; as &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="17889" LastEditorUserId="17889" LastEditDate="2018-06-20T07:12:28.450" LastActivityDate="2018-06-20T07:12:28.450" Title="Get &lt;Leader&gt; value as &lt;Space&gt; and not ' '" Tags="|vimscript|string-manipulation|leader|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16530" PostTypeId="2" ParentId="16528" CreationDate="2018-06-20T07:00:13.797" Score="10" Body="&lt;p&gt;This is the expected behavior of the plugin when you create a file in your vimwiki the filetype is set to &lt;code&gt;vimwiki&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want files created outside of the wiki directory to have this filetype you can follow &lt;a href=&quot;https://github.com/vimwiki/vimwiki/issues/95&quot; rel=&quot;noreferrer&quot;&gt;this issue&lt;/a&gt; and add the following line to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vimwiki_global_ext = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-06-20T07:00:13.797" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16531" PostTypeId="2" ParentId="16529" CreationDate="2018-06-20T07:03:30.750" Score="1" Body="&lt;p&gt;You can simply use &lt;code&gt;substitute()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(get(g:,&quot;mapleader&quot;,&quot;\\&quot;), ' ', '&amp;lt;Space&amp;gt;', '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since there is only one case where &lt;code&gt;get(g:,&quot;mapleader&quot;,&quot;\\&quot;)&lt;/code&gt; will return a single whitespace this should work.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-06-20T07:03:30.750" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16532" PostTypeId="2" ParentId="16441" CreationDate="2018-06-20T08:21:38.040" Score="1" Body="&lt;p&gt;You can use &lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ALE&lt;/a&gt; to asynchronously lint (i.e. check for style/syntax errors) while you type. This will not prevent vim from saving the buffer when you instruct it to do so but that might be what actually you need/want.&lt;/p&gt;&#xA;" OwnerUserId="6357" LastEditorUserId="6357" LastEditDate="2018-07-21T11:59:37.530" LastActivityDate="2018-07-21T11:59:37.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16534" PostTypeId="5" CreationDate="2018-06-20T11:09:35.547" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/MattesGroeger/vim-bookmarks&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-bookmarks&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-06-20T11:09:35.547" LastActivityDate="2018-06-20T11:09:35.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16535" PostTypeId="4" CreationDate="2018-06-20T11:09:35.547" Score="0" Body="Questions about the plugin vim-bookmarks" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-06-20T11:09:35.547" LastActivityDate="2018-06-20T11:09:35.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16536" PostTypeId="1" AcceptedAnswerId="16541" CreationDate="2018-06-20T18:59:04.297" Score="1" ViewCount="648" Body="&lt;p&gt;I was wondering if, out of the box, one can move an entire column up- and downwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say, we have the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 a&#xA;    b&#xA;      c&#xA;2 d&#xA;    e&#xA;      f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My goal is to convert this into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 a b c&#xA;&#xA;&#xA;2 d e f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does not seem possible via &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html#blockwise-operators&quot; rel=&quot;nofollow noreferrer&quot;&gt;visual block operations&lt;/a&gt;, since we need to &lt;em&gt;operate&lt;/em&gt; on the column in the context of the rows above and below. In my case, I would need to &lt;em&gt;overwrite&lt;/em&gt; the (empty) row values above the selected column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or do we need to resort to writing macros to accomplish this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the last case, I was thinking of a macro in the line of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. &amp;lt;detect the first non-whitespace character&amp;gt; &#xA;2. &amp;lt;delete up to the last non-whitespace character&amp;gt; &#xA;3. &amp;lt;move up a row via insertion mode&amp;gt; &#xA;4. &amp;lt;append the row with the deleted characters from the previous row&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be applied consequtively for each column in the format given above. Only, I'm not sure how to do step (1) and (2) yet. :)&lt;/p&gt;&#xA;" OwnerUserId="11449" LastEditorUserId="11449" LastEditDate="2018-06-21T06:18:09.683" LastActivityDate="2018-06-21T13:57:26.400" Title="Move a column up-/downwards" Tags="|macro|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="16537" PostTypeId="2" ParentId="16527" CreationDate="2018-06-20T19:43:16.243" Score="1" Body="&lt;p&gt;I believe most experienced users employ visual mode in very few/specific cases. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use visual mode mainly as a tool to help learn the commands (like training wheels to learn to ride a bike). &#xA;For example: you type &lt;code&gt;vwwc&lt;/code&gt; to replace the next two words, until you feel comfortable to type &lt;code&gt;c2w&lt;/code&gt; and drop the visual aid. This &lt;a href=&quot;https://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118&quot;&gt;answer (&quot;Your problem with Vim is that you don't grok vi&quot;)&lt;/a&gt; has more information about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to the movement regarding large blocks explained on that answer, Vim provides lots of movements to use in the current line, such as &lt;code&gt;f/F/t/T&lt;/code&gt;. And most of them accepts a count. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you could replace up to the start of this sentence by typing &lt;code&gt;cFS&lt;/code&gt;, or &lt;code&gt;c2Fm&lt;/code&gt; to replace up to most on the previous sentence. Once you can avoid smaller steps such as j and l it becomes easier to drop visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has a really good documentation/help system, so it is probably the best way to learn such movements (just type &lt;a href=&quot;http://vimhelp.appspot.com/help.txt.html#doc%2dfile%2dlist&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help&lt;/code&gt;&lt;/a&gt;). Here are some other good resources:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://stevelosh.com/blog/2010/09/coming-home-to-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Coming Home to Vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.viemu.com/a-why-vi-vim.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;why use Vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://yehudakatz.com/2010/07/29/everyone-who-tried-to-convince-me-to-use-vim-was-wrong/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Everyone Who Tried to Convince Me to use Vim was Wrong&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://stackoverflow.com/questions/7579213/is-there-an-interactive-way-to-learn-vim/7579259#7579259&quot;&gt;Answer to &quot;Is there an interactive way to learn Vim?&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2018-06-20T19:43:16.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16538" PostTypeId="2" ParentId="16536" CreationDate="2018-06-21T07:20:18.070" Score="1" Body="&lt;p&gt;From vim helpdocs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;J           Join [count] lines, with a minimum of two lines.&#xA;            Remove the indent and insert up to two spaces (see&#xA;            below).  Fails when on the last line of the buffer.&#xA;            If [count] is too big it is reduce to the number of&#xA;            lines available.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For your specific purpose, I myself would prefer &lt;code&gt;3Jj3J&lt;/code&gt;, but you can do same with visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First visually select these first 3 lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 a&#xA;    b&#xA;      c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, press &lt;code&gt;J&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then do the same for the next 3 lines.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2018-06-21T07:20:18.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16539" PostTypeId="1" AcceptedAnswerId="16551" CreationDate="2018-06-21T08:33:04.483" Score="1" ViewCount="11967" Body="&lt;p&gt;When review code, it would be convenient if we can highlight multiple lines at the same time, instead of only current cursor line is highlighted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set cursorline&lt;/code&gt; only highlight current line.&lt;br&gt;&#xA;&lt;code&gt;:nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;l ml:execute 'match Search /\%'.line('.').'l/'&amp;lt;CR&amp;gt;&lt;/code&gt; can only highlight one extra line.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Want to keep all marked lines highlighted.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="13402" LastEditDate="2018-06-21T08:49:17.943" LastActivityDate="2021-03-09T13:38:53.490" Title="How to highlight multiple lines?" Tags="|highlight|" AnswerCount="4" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16540" PostTypeId="1" CreationDate="2018-06-21T08:51:14.340" Score="0" ViewCount="30" Body="&lt;p&gt;I have wsl - ubuntu installed under Windows 10. Some ubuntu's commands are proxied to use in cmd by create &lt;code&gt;.bat&lt;/code&gt; files and add them to &lt;code&gt;PATH&lt;/code&gt; environment of windows10, pattern like following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@echo off&#xA;bash.exe -c &quot;ls %*&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in cmd &lt;code&gt;ls&lt;/code&gt; work as expected, log in bash, run ls in current directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem is that, asyncrun throws an error output when I try to run, for i.e: &lt;code&gt;:AsyncRun ls&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using gVim 8.1 1-42&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: add error output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|| E&#xA;|| r&#xA;|| r&#xA;|| o&#xA;|| r&#xA;|| :&#xA;|| &#xA;|| 0&#xA;|| x&#xA;|| 8&#xA;|| 0&#xA;|| 0&#xA;|| 7&#xA;|| 0&#xA;|| 0&#xA;|| 0&#xA;|| 6&#xA;|| &#xA;|| &#xA;|| &#xA;|| [Finished in 0 seconds with code -1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="1841" LastEditDate="2018-06-22T08:37:50.693" LastActivityDate="2018-06-22T08:37:50.693" Title="error output when using commands proxied via WSL (asyncrun plugin)" Tags="|external-command|microsoft-windows|plugin-asyncrun|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16541" PostTypeId="2" ParentId="16536" CreationDate="2018-06-21T13:57:26.400" Score="1" Body="&lt;p&gt;You can use visual block mode if you are careful about the boundaries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, type &lt;code&gt;:set ve=all&lt;/code&gt; to turn on virtual edit mode.  Then on the b, press ctrl-v to enter block visual mode, and type G to put the range to the bottom.  Press y to yank this region.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 a&#xA;    [b]&#xA;    [ ] c&#xA;2 d [ ]&#xA;    [e]&#xA;    [ ] f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, type k to go up one character.  Since we're in virtual edit mode, the cursor goes to what is empty space.  Press 1v which means re-enter visual block mode with the same width and height as the last operation.  Press p to put.  This overwrites the text without changing anything else.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 a [b]&#xA;    [ ]&#xA;    [ ] c&#xA;2 d [e]&#xA;    [ ]&#xA;        f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Go to the c and type ctrl-v G y kk 1v p, similar to before&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 a b           1 a b [c] &#xA;                      [ ] &#xA;      [c]             [ ] &#xA;2 d e [ ]  -&amp;gt;   2 d e [f] &#xA;      [ ]              &#xA;      [f]              f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, this leaves an f which you can either delete afterwards or you could have originally extended your buffer a few blank lines down to grab extra whitespace to replace the f with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To turn off virtual edit afterwards, use &lt;code&gt;:set ve=&lt;/code&gt; or &lt;code&gt;:set ve=block&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-06-21T13:57:26.400" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16542" PostTypeId="1" AcceptedAnswerId="16543" CreationDate="2018-06-21T14:52:39.990" Score="2" ViewCount="239" Body="&lt;p&gt;I would like to search for a pattern in a range of lines and append additional text on another line that would include part of the search pattern. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[range]g/\(foo \)\(\w\{-}\)/normal! 2jibar \2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the callback to the capture group does not seem to work. It finds the pattern, moves two lines down, and inserts &quot;bar \2&quot; literally instead of &quot;bar &quot; + the result of the second capture group.&lt;/p&gt;&#xA;" OwnerUserId="17958" LastEditorUserId="17958" LastEditDate="2018-06-21T15:01:02.943" LastActivityDate="2018-06-21T15:31:02.257" Title="Insert text including capture group from search using global command" Tags="|global-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16543" PostTypeId="2" ParentId="16542" CreationDate="2018-06-21T15:25:02.727" Score="4" Body="&lt;p&gt;The &lt;code&gt;:global&lt;/code&gt; command does not make its capture groups available to the trailing command.  The simplest alternative is to use &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; to target the specific match and grab the pattern using the normal command;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/foo \zs\w\{-}\ze/normal! ygn2jp&#xA;g/foo \zs\w\{-}\ze/normal! ygn2jibar ^R&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where ^R is a literal ctrl-r, which you type ctrl-v ctrl-r to enter.  This uses &lt;code&gt;ygn&lt;/code&gt; to yank the next match, which is set appropriately due to the pattern in &lt;code&gt;:global&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also write your own commands to be used in the trailing command slot.  For instance,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CaptureNormal(qargs, bang)&#xA;    let l:list = matchlist(getline('.'), (&amp;amp;magic?'\m':'\M').@/)&#xA;    let l:args = substitute(a:qargs, '\\\(\d\)', '\=l:list[submatch(1)]', 'g')&#xA;    execute 'normal'.a:bang l:args&#xA;endfunction&#xA;&#xA;command! -bang -nargs=* CapNorm call CaptureNormal(&amp;lt;q-args&amp;gt;, '&amp;lt;bang&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All this does is 1) match the line using the previous pattern to grab the capture groups, 2) adjust the given string to replace &lt;code&gt;\2&lt;/code&gt; with the groups text, then 3) run the  pre-processed normal command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[range]g/\(foo \)\(\w\{-}\)/CapNorm! 2jibar \2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-06-21T15:31:02.257" LastActivityDate="2018-06-21T15:31:02.257" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16544" PostTypeId="2" ParentId="16539" CreationDate="2018-06-21T16:07:48.803" Score="-1" Body="&lt;p&gt;You press capital V and j or k to select other lines.&lt;/p&gt;&#xA;" OwnerUserId="15464" LastActivityDate="2018-06-21T16:07:48.803" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16545" PostTypeId="2" ParentId="16520" CreationDate="2018-06-21T16:11:38.453" Score="0" Body="&lt;p&gt;By the way, Windows has a default vimrc file called _vimrc. Most GNU/Linux distros do not have a default vimrc file. Look into the _vimrc file on Windows to change any options you want.&lt;/p&gt;&#xA;" OwnerUserId="15464" LastActivityDate="2018-06-21T16:11:38.453" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16546" PostTypeId="2" ParentId="16518" CreationDate="2018-06-21T19:43:35.877" Score="3" Body="&lt;p&gt;Please note that I changed your mapping to suit my keyboard. However this is what I got in terms of functionality:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-P&amp;gt; :MyFind0&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;&amp;lt;C-P&amp;gt; :MyFind1&amp;lt;CR&amp;gt;&#xA;command! -bang -nargs=* MyFind0 call MyFind(0, &amp;lt;q-args&amp;gt;, &amp;lt;bang&amp;gt;0)&#xA;command! -bang -nargs=* MyFind1 call MyFind(1, &amp;lt;q-args&amp;gt;, &amp;lt;bang&amp;gt;0)&#xA;function! MyFind(numArg, qArg, bangArg)&#xA;  let cmd='rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob &quot;!{.git,node_modules}/*&quot; --color &quot;always&quot; '&#xA;  if a:numArg == 1&#xA;    let cmd.='--no-ignore '&#xA;  endif&#xA;call fzf#vim#grep(cmd.shellescape(a:qArg), 1,&#xA;\ a:bangArg ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:60%')&#xA;\         : fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'right:50%:hidden', '?'),&#xA;\ a:bangArg)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17889" LastActivityDate="2018-06-21T19:43:35.877" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16547" PostTypeId="2" ParentId="12920" CreationDate="2018-06-21T20:57:30.490" Score="1" Body="&lt;p&gt;What works for me with neovim v0.2.2 on lubuntu 17.10 is the open-browser.vim plugin (&lt;a href=&quot;https://github.com/tyru/open-browser.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tyru/open-browser.vim&lt;/a&gt;) with the following settings in my &lt;code&gt;init.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_nogx = 1 &quot; disable netrw's gx mapping.&#xA;    nmap gx &amp;lt;Plug&amp;gt;(openbrowser-smart-search)&#xA;vmap gx &amp;lt;Plug&amp;gt;(openbrowser-smart-search)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14974" LastActivityDate="2018-06-21T20:57:30.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16548" PostTypeId="2" ParentId="16539" CreationDate="2018-06-21T22:37:55.270" Score="1" Body="&lt;p&gt;Thanks for below answer, find a way to highlight multiple lines.&#xA;&lt;a href=&quot;https://superuser.com/a/697070/366981&quot;&gt;https://superuser.com/a/697070/366981&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install plugin:&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=953&quot; rel=&quot;nofollow noreferrer&quot;&gt;multiselect-2.2.zip&lt;/a&gt;.&lt;br&gt;&#xA;&lt;code&gt;Ctrl and left click&lt;/code&gt; to select and highlight any line.&lt;br&gt;&#xA;&lt;code&gt;Ctrl and left click&lt;/code&gt; again to remove highlight.&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;leader&amp;gt;msc&lt;/code&gt;to clear all selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8cWL4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8cWL4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another method: &lt;a href=&quot;https://stackoverflow.com/a/50984553/3760602&quot;&gt;Highlight multiple words&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/OK5Ky.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OK5Ky.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="13402" LastEditDate="2018-06-22T09:16:23.930" LastActivityDate="2018-06-22T09:16:23.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16549" PostTypeId="2" ParentId="6184" CreationDate="2018-06-21T23:35:52.443" Score="3" Body="&lt;p&gt;I tried your sample (result below), so vim's html autoformat/indent definitely works with this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;    &amp;lt;span&amp;gt;&#xA;    &amp;lt;/span&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the steps to do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype plugin indent on &quot; enable the filetype indent plugin&#xA;:e                         &quot; re-open the file (very important!)&#xA;:scriptnames               &quot; make sure you see an &quot;.../indent/html.vim&quot;&#xA;:=G                        &quot; or whatever range you want&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;scriptnames&lt;/code&gt; is the key to identifying whether the &lt;code&gt;indent/html.vim&lt;/code&gt; is properly loaded. If not, then you probably need to re-open the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if you put &lt;code&gt;filetype plugin indent on&lt;/code&gt; in the &lt;code&gt;~/.vimrc&lt;/code&gt;, then you won't need to re-open the file since that plugin was already enabled before you opened the file.&lt;/p&gt;&#xA;" OwnerUserId="6610" LastActivityDate="2018-06-21T23:35:52.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16551" PostTypeId="2" ParentId="16539" CreationDate="2018-06-22T11:04:38.077" Score="4" Body="&lt;p&gt;As you mention in your question, the &lt;code&gt;:match&lt;/code&gt; command only allows a single match to be set up. For multiple matches, you can use the &lt;code&gt;matchadd()&lt;/code&gt; function. You can adapt your existing mapping to use this like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;l :call matchadd('Search', '\%'.line('.').'l')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For your expressed purpose of reviewing code, this should be sufficient. However, if you are adding/removing lines above the lines you have marked, this might not work as you desire: the marks will not move with the lines. There are ways around this, but all will result in much more complicated code.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-06-22T11:04:38.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16552" PostTypeId="1" AcceptedAnswerId="16553" CreationDate="2018-06-22T16:08:04.373" Score="4" ViewCount="253" Body="&lt;p&gt;I've run into the problem mentioned &lt;a href=&quot;https://vi.stackexchange.com/a/3961/17964&quot;&gt;here&lt;/a&gt;, but in a context in which I don't have an easy alternative that I can think of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to add a mapping to fix bad newline characters in a file. I would generally type: &lt;code&gt;:%s/^M//g&lt;/code&gt; to remove all of the &lt;code&gt;^M&lt;/code&gt; characters. My mapping attempt to do this (and save) is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;fix :%s/^M//g&amp;lt;Bar&amp;gt;w&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with my mapping is that the &lt;code&gt;^M&lt;/code&gt; gets automatically converted to &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; and the mapping breaks, of course. I have also tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;fix :%s/&amp;lt;c-v&amp;gt;&amp;lt;c-m&amp;gt;//g&amp;lt;Bar&amp;gt;w&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and that fails as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've noticed that if I leave off the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; at the end to debug the mapping, I get &lt;code&gt;//g|w&lt;/code&gt; as the only thing on the command prompt. Ideally, this would be &lt;code&gt;%s/^M//g|w&lt;/code&gt; to achieve the desired behavior.&lt;/p&gt;&#xA;" OwnerUserId="17964" LastActivityDate="2018-06-22T16:22:56.443" Title="Add ^M character in mapping without entering &lt;CR&gt;" Tags="|vimrc|key-bindings|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16553" PostTypeId="2" ParentId="16552" CreationDate="2018-06-22T16:22:56.443" Score="5" Body="&lt;p&gt;To match carriage return, &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;, &lt;code&gt;^M&lt;/code&gt;, ASCII value 13, you should use &lt;code&gt;\r&lt;/code&gt; in the pattern: &lt;code&gt;%s/\r//...&lt;/code&gt;.  This is documented at &lt;code&gt;:help /\r&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;\r&lt;/code&gt; in the &lt;em&gt;substitution&lt;/em&gt; part (&lt;code&gt;:s//&amp;lt;here&amp;gt;/&lt;/code&gt;), rather than in the &lt;em&gt;pattern&lt;/em&gt; part, has a completely different meaning which is &quot;split the line in two.&quot;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-06-22T16:22:56.443" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16554" PostTypeId="1" AcceptedAnswerId="16555" CreationDate="2018-06-23T12:07:42.097" Score="0" ViewCount="1225" Body="&lt;p&gt;I'm using vim on a Linux machine to write to a Windows 10 share and vim keeps slowing down and giving an error at the status line of &lt;code&gt;E297: Write error in swap file&lt;/code&gt;.  When I went into the directory to list it I got the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;leeand00@puppetmaster:/run/user/1000/gvfs/smb-share:server=leeand00-pc,share=temp$ ls -la&#xA;ls: cannot access '.reorder.py.swp': Invalid argument&#xA;total 273&#xA;drwx------ 1 leeand00 leeand00   4096 Jun 23 07:33 .&#xA;dr-x------ 3 leeand00 leeand00      0 Jun 21 09:48 ..&#xA;drwx------ 1 leeand00 leeand00      0 Jan  3  2017 firmware&#xA;-rwx------ 1 leeand00 leeand00 199516 Jul  6  2017 IMG_0002.jpg&#xA;-rwx------ 1 leeand00 leeand00     99 Jun 23 00:21 .~lock.NoHeaders.csv#&#xA;-rwx------ 1 leeand00 leeand00    208 Jan  2  2017 README.txt&#xA;-rwx------ 1 leeand00 leeand00    342 Jun 23 07:33 reorder.py&#xA;?????????? ? ?        ?             ?            ? .reorder.py.swp&#xA;-rwx------ 1 leeand00 leeand00  36688 Jun 22 14:23 Headers.csv&#xA;-rwx------ 1 leeand00 leeand00  36618 Jun 23 00:21 NoHeaders.csv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The swap file looks really strange...is there something else I can do about this?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2018-06-23T12:13:43.663" Title="Swapfile issues with vim when using remote Windows 10 SMB Share?" Tags="|swap-file|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16555" PostTypeId="2" ParentId="16554" CreationDate="2018-06-23T12:13:43.663" Score="1" Body="&lt;p&gt;&lt;code&gt;:set noswapfile&lt;/code&gt; seems to have taken care of the issue.&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2018-06-23T12:13:43.663" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16556" PostTypeId="2" ParentId="10296" CreationDate="2018-06-24T02:48:07.010" Score="4" Body="&lt;h2&gt;If you want to move more than ONE or TWO positions...&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;...the best choice is to hit &lt;code&gt;ESC&lt;/code&gt;, move around, and get back to insert mode again.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There's no point on create mappings like &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; to move left and then start hitting it too many times... as a vim user you're not supposed to hit the same key multiple times to achieve a smart movement.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;(If the &lt;strong&gt;&lt;code&gt;ESC&lt;/code&gt;&lt;/strong&gt; key isn't close to your fingers, it would be a good option to create a mapping for it.)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;h2&gt;If you want to move ONE or TWO posistions on insert mode...&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;...a good choice would be to define some movements using your &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; key:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;(I use &lt;strong&gt;&lt;code&gt;,&lt;/code&gt;&lt;/strong&gt; as &lt;strong&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;&lt;/strong&gt; key since it's feels close and confortable to my fingers)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;noremap! &amp;lt;Leader&amp;gt;h &amp;lt;left&amp;gt;   &amp;quot;move cursor left&#xA;noremap! &amp;lt;Leader&amp;gt;j &amp;lt;down&amp;gt;   &amp;quot;move cursor down&#xA;noremap! &amp;lt;Leader&amp;gt;k &amp;lt;up&amp;gt;     &amp;quot;move cursor up   &#xA;noremap! &amp;lt;Leader&amp;gt;l &amp;lt;right&amp;gt;  &amp;quot;move cursor right&#xA;noremap! &amp;lt;Leader&amp;gt;w &amp;lt;esc&amp;gt;wi  &amp;quot;move one word forward&#xA;noremap! &amp;lt;Leader&amp;gt;e &amp;lt;esc&amp;gt;ei  &amp;quot;move forward to the end of word&#xA;noremap! &amp;lt;Leader&amp;gt;b &amp;lt;esc&amp;gt;bi  &amp;quot;move one word backward&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15921" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-06-24T02:48:07.010" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16557" PostTypeId="1" CreationDate="2018-06-24T04:40:19.157" Score="2" ViewCount="3972" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;auto-pairs&lt;/a&gt; seems like a great feature for vim. As per instructions, I copied the &lt;code&gt;auto-pairs.vim&lt;/code&gt; file to &lt;code&gt;~/.vim/plugin/&lt;/code&gt; and sourced the &lt;code&gt;.vim&lt;/code&gt; file by executing &lt;code&gt;:source %&lt;/code&gt; in the &lt;code&gt;auto-pairs.vim&lt;/code&gt; file according to &lt;a href=&quot;https://vi.stackexchange.com/questions/613/how-do-i-install-a-plugin-in-vim-vi&quot;&gt;the most voted instructions&lt;/a&gt;. I restarted the terminal, but it doesn't seem to work. Am I missing something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using a Macbook, iterm2 and &lt;code&gt;VIM - Vi IMproved 7.4&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14185" LastEditorUserId="14185" LastEditDate="2018-06-24T04:46:15.677" LastActivityDate="2018-06-25T14:48:33.903" Title="How do I enable the auto-pairs plugin in vim?" Tags="|plugin-auto-pairs|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16558" PostTypeId="2" ParentId="16557" CreationDate="2018-06-24T08:35:43.753" Score="0" Body="&lt;p&gt;&lt;em&gt;You say &quot;it doesn't seem to work&quot; so I'm assuming this simple test fails: while in Insert mode enter &lt;code&gt;[&lt;/code&gt; and you should see &lt;code&gt;[|]&lt;/code&gt; where &lt;code&gt;|&lt;/code&gt; is the cursor. If not then let's look at the installation...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:source&lt;/code&gt; in the context of plugins is for &lt;em&gt;vimball&lt;/em&gt; files and you would do something like this, once, to install the plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    vim someplugin.vba&#xA;    :source %&#xA;    :q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Generally speaking &lt;code&gt;:source&lt;/code&gt; just executes the Ex commands in a file.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, of course, this plugin is not in a vimball. All you should need to do is copy the file to &lt;code&gt;~/.vim/plugin/&lt;/code&gt; then start vim. I just did exactly that with the current version of auto-pairs and everything is working fine. (I'm not on Mac, though.) Note that by sourcing it you may even be causing problems that wouldn't normally exist. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using a fairly up-to-date version of Vim you could also try copying the entire plugin directory (including &lt;code&gt;docs\&lt;/code&gt;, &lt;code&gt;plugin\&lt;/code&gt;, etc.) to the following (create the parent directories if you don't have them already):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/pack/bundle/start/auto-pairs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note: directory &quot;bundle&quot; can actually be named anything you want.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if you know &lt;code&gt;git&lt;/code&gt; you can clone the whole thing into the &lt;code&gt;start/&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next time you run vim the plugin will be available. One advantage of this is that you'll have local access to the help file.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-06-24T08:51:04.697" LastActivityDate="2018-06-24T08:51:04.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16559" PostTypeId="2" ParentId="16557" CreationDate="2018-06-24T16:31:16.437" Score="2" Body="&lt;p&gt;I'll break down my answer in two parts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I'll start with some guidelines:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;First of all, most of the time plugins have two or more directories where code resides, not only a &lt;code&gt;root/plugin&lt;/code&gt; directory.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Second, you need to place these plugins, in a specified directory and later set the &lt;code&gt;runtimepath&lt;/code&gt; from your &lt;code&gt;~/.vimrc&lt;/code&gt;. I've &lt;code&gt;~/.vim/bundle&lt;/code&gt; as my plugin directory and in my vimrc I have &lt;code&gt;set runtimepath+=~/.vim/bundle&lt;/code&gt;. Be sure to clone plugin repositories properly.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Observing your obvious lack of info of using plugins and then assuming you're new to vim, I suggest using a package manager for vim. Many would suggest &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-pathogen&lt;/a&gt;. But I'd suggest &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt;. But you should check others out for yourself. Just google it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now, to get back to the problem you currently have.&lt;br&gt;&#xA;So, if you want to use any plugin manager, then do that. But for first time's sake, do these following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;create &lt;code&gt;~/.vim/bundle&lt;/code&gt; : mkdir -p ~/.vim/bundle&lt;/li&gt;&#xA;&lt;li&gt;git clone &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs.git&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/jiangmiao/auto-pairs.git&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;add this line to vimrc : &lt;code&gt;set runtimepath+=~/.vim/bundle/auto-pairs&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Restart vim.&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;you should get the plugin working now. If you find out anything odd reply here.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2018-06-25T14:48:33.903" LastActivityDate="2018-06-25T14:48:33.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16560" PostTypeId="1" AcceptedAnswerId="16561" CreationDate="2018-06-24T23:11:34.163" Score="2" ViewCount="974" Body="&lt;p&gt;Once in visual line mode I'm looking for a way to move the selected area up and down in the file. Note I'm not looking to actually modify the content of the file in any way just moved the shaded (selected) region up and down one line.&lt;/p&gt;&#xA;" OwnerUserId="17996" LastActivityDate="2018-06-24T23:34:10.203" Title="Move Selected Lines in Visual Line Mode" Tags="|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16561" PostTypeId="2" ParentId="16560" CreationDate="2018-06-24T23:28:37.680" Score="1" Body="&lt;p&gt;You can move one side of the visual range using &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; as normal and use &lt;code&gt;o&lt;/code&gt; to switch from one side to the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, if you would like to move the whole range up or down in one key press, you can make mappings as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;up&amp;gt; koko&#xA;xnoremap &amp;lt;down&amp;gt; jojo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A slight refinement would be to respect the bottom and top of the buffer;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;expr&amp;gt; &amp;lt;up&amp;gt; min([line('.'),line('v')]) &amp;gt; 1 ? 'koko' : ''&#xA;xnoremap &amp;lt;expr&amp;gt; &amp;lt;down&amp;gt; max([line('.'),line('v')]) &amp;lt; line('$') ? 'jojo' : ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Further, if you would like to use counts,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;expr&amp;gt; &amp;lt;up&amp;gt; min([line('.'),line('v')])&#xA;                 \ &amp;gt; v:count1 ? 'ko'.v:count1.'ko' : ''&#xA;xnoremap &amp;lt;expr&amp;gt; &amp;lt;down&amp;gt; max([line('.'),line('v')])&#xA;                 \ &amp;lt;= line('$')-v:count1 ? 'jo'.v:count1.'jo' : ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-06-24T23:34:10.203" LastActivityDate="2018-06-24T23:34:10.203" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16562" PostTypeId="1" AcceptedAnswerId="16563" CreationDate="2018-06-25T01:19:23.107" Score="1" ViewCount="1122" Body="&lt;p&gt;When open gvim, there is a small icon &lt;code&gt;Vim&lt;/code&gt; in the title plus buffer name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to hack anything about vim, including being able to change this gvim's icon. Is there a way to do that?&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="1841" LastEditDate="2018-06-25T07:56:56.190" LastActivityDate="2018-06-25T07:56:56.190" Title="How to change gVim icon on Windows?" Tags="|gvim|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16563" PostTypeId="2" ParentId="16562" CreationDate="2018-06-25T01:47:51.420" Score="2" Body="&lt;p&gt;I solved my problem by reading the doc at &lt;a href=&quot;http://vimhelp.appspot.com/os_win32.txt.html#windows-icon&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h windows-icon&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;                  *windows-icon*&#xA;Q. I don't like the Vim icon, can I change it?&#xA;A. Yes, place your favorite icon in bitmaps/vim.ico in a directory of&#xA;   'runtimepath'.  For example ~/vimfiles/bitmaps/vim.ico.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="1841" LastEditDate="2018-06-25T07:54:52.350" LastActivityDate="2018-06-25T07:54:52.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16565" PostTypeId="1" AcceptedAnswerId="16566" CreationDate="2018-06-25T14:56:19.900" Score="3" ViewCount="389" Body="&lt;p&gt;I'm somewhat ashamed to admit, the main reason I chose neovim over vim was it's native feature of changing cursor shape in different modes. For example, it uses vertical-bar in insert mode, block-shape in normal mode and horizontal-bar in operator-pending mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Until recently, I didn't know there was a cursor shape for operator-pending mode. This was because I'm using &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-surround&lt;/a&gt;. So, I now don't get the horizontal-bar when pressing &lt;kbd&gt;c&lt;/kbd&gt; or &lt;kbd&gt;d&lt;/kbd&gt;. Again, I'm ashamed to admit that this little thing bothers me. I peeked around in the plugin, but honestly I understand very little of it. The best solution I came up with was to remap the &lt;code&gt;cs&lt;/code&gt; and &lt;code&gt;ds&lt;/code&gt; keymaps to some &lt;code&gt;Leader&lt;/code&gt; mappings, but that defeats the purpose of extending text objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I want to be able to see horizontal bar while I use default keymappings for vim-surround. How do I do that?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-27T03:52:35.143" LastActivityDate="2019-02-27T03:52:35.143" Title="Reclaim cursor shape in operator pending mode of neovim while using vim-surround" Tags="|neovim|cursor|plugin-vim-surround|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="16566" PostTypeId="2" ParentId="16565" CreationDate="2018-06-25T15:30:30.817" Score="6" Body="&lt;p&gt;If vim-surround were implemented as 's' and 'S' (pseudo-)text-objects instead of operators &lt;code&gt;ds&lt;/code&gt;, &lt;code&gt;dS&lt;/code&gt;, &lt;code&gt;cs&lt;/code&gt;, &lt;code&gt;cS&lt;/code&gt; etc, this wouldn't be an issue. I don't know if there's some technical reason for this design choice, but anyway one solution would be to write your own wrapper &lt;code&gt;omap&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:surround_no_mappings = 1&#xA;function! SurroundOp(char)&#xA;    if v:operator ==# 'd'&#xA;        return &quot;\&amp;lt;plug&amp;gt;D&quot; . a:char . &quot;urround&quot;&#xA;    elseif v:operator ==# 'c'&#xA;        return &quot;\&amp;lt;plug&amp;gt;C&quot; . a:char . &quot;urround&quot;&#xA;    elseif v:operator ==# 'y'&#xA;        return &quot;\&amp;lt;plug&amp;gt;Y&quot; . a:char . &quot;urround&quot;&#xA;    endif&#xA;    return ''&#xA;endfunction&#xA;omap &amp;lt;expr&amp;gt; s '&amp;lt;esc&amp;gt;'.SurroundOp('s')&#xA;omap &amp;lt;expr&amp;gt; S '&amp;lt;esc&amp;gt;'.SurroundOp('S')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't tested it thoroughly but it seems like this would work.  The first &lt;code&gt;'&amp;lt;esc&amp;gt;'&lt;/code&gt; serves to cancel the currently pending &lt;code&gt;s&lt;/code&gt; operator and the rest is just surround's normal mode mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This wouldn't work for &lt;code&gt;yss&lt;/code&gt; or &lt;code&gt;ySs&lt;/code&gt; (separate mapping for surrounding the current line), for that you can just use a plugin which provides a line textobject, e.g. &lt;a href=&quot;https://github.com/kana/vim-textobj-line&quot; rel=&quot;nofollow noreferrer&quot;&gt;kana/vim-textobj-line&lt;/a&gt;, for example with &lt;a href=&quot;https://github.com/junegunn/vim-plug/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'kana/vim-textobj-line'&#xA;Plug 'kana/vim-textobj-user'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way you can use &lt;code&gt;ysil&lt;/code&gt; in place of &lt;code&gt;yss&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This still doesn't cover &lt;a href=&quot;https://github.com/tpope/vim-surround/blob/597068870b8f093a8b2d11536c62ff31222ee8d0/plugin/surround.vim#L590-L608&quot; rel=&quot;nofollow noreferrer&quot;&gt;all the vim-surround mappings&lt;/a&gt;, there is still &lt;code&gt;xmap gS&lt;/code&gt; and the insert mode mappings. You could copy those mappings into your &lt;code&gt;vimrc&lt;/code&gt; to get them.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="10139" LastEditDate="2019-01-10T15:58:58.753" LastActivityDate="2019-01-10T15:58:58.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16567" PostTypeId="1" AcceptedAnswerId="16577" CreationDate="2018-06-25T19:05:15.050" Score="1" ViewCount="1361" Body="&lt;p&gt;I would like to insert a specific character after each instance of another character in a line. For example, inserting a '\' after each instance of another '\' on a line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, from this: &lt;code&gt;C:folder\folder2\folder3\folder4&lt;/code&gt;, &#xA;to this:&lt;code&gt;C:folder\\folder2\\folder3\\folder4&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking it may be a variation on the &lt;code&gt;s&lt;/code&gt; command, but I haven't found anything that works yet. Or maybe using search and replace is a better way.&lt;/p&gt;&#xA;" OwnerUserId="18004" LastActivityDate="2018-06-27T14:44:48.787" Title="Insert specific character after each instance of a character in a line" Tags="|substitute|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16568" PostTypeId="1" AcceptedAnswerId="16587" CreationDate="2018-06-25T20:02:48.107" Score="1" ViewCount="1030" Body="&lt;p&gt;Specifically, I have encountered this issue with the &lt;em&gt;lowercase a&lt;/em&gt; with an umlaut ä and the lowercase &lt;em&gt;scharfes s&lt;/em&gt; ß. Their (extended) ASCII values are &lt;code&gt;0xDF&lt;/code&gt; and &lt;code&gt;0xE4&lt;/code&gt;, respectively:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/exjpQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/exjpQ.png&quot; alt=&quot;(extended) ASCII table with the relevant characters highlighted&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be &lt;a href=&quot;http://vim.wikia.com/wiki/Showing_the_ASCII_value_of_the_current_character&quot; rel=&quot;nofollow noreferrer&quot;&gt;seen&lt;/a&gt;, in the lower left corner, by invoking &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set statusline=%&amp;lt;%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V\ %P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I insert the characters in one &lt;a href=&quot;https://gitforwindows.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;git-bash&lt;/a&gt; terminal shell, and both characters look the same upon opening the file again (in the same shell):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7Ihgv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7Ihgv.png&quot; alt=&quot;Opened in the same shell, characters show no change screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open the same file in a different shell, the two characters are changed to &lt;code&gt;Ã¤d&lt;/code&gt; and &lt;code&gt;Ã~_&lt;/code&gt; , respectively. In the second case &lt;code&gt;Ã~_&lt;/code&gt;, however, Vim points out that &lt;code&gt;~_&lt;/code&gt; is actually the character &lt;code&gt;Ÿ&lt;/code&gt;; since it recognizes it as the &lt;code&gt;0x9F&lt;/code&gt; (extended) ASCII character:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kaY2q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kaY2q.png&quot; alt=&quot;Bad digraphs in different shell example screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this same issue with many other extended ASCII characters. Does anybody know what causes these characters to change upon saving and opening in a different shell?&lt;/p&gt;&#xA;" OwnerUserId="11449" LastActivityDate="2018-08-26T21:00:55.150" Title="Extended ASCII characters changed upon opening Vim in different shell" Tags="|microsoft-windows|bash|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16569" PostTypeId="1" AcceptedAnswerId="16573" CreationDate="2018-06-25T22:13:14.830" Score="1" ViewCount="99" Body="&lt;p&gt;In vim, when highlighting and replacing individual words, I use: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;viwy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, I go to the next word and type: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;viwp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default behavior is to immediately replace the yanked word with the replaced word.  I figured this was advantageous, somehow, otherwise it would not have been implemented this way...and sure enough, after using it for a while, I like it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, after using it for a while, I have the memory for a mini stack: two words, the latest word in the register, and the previously yanked word. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How, in vim, would I implement a functionality where: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;starting text: &quot;hello world something&quot;&#xA;&#xA;viwyw (&quot;hello&quot; is yanked, cursor is at start of &quot;world&quot;)&#xA;viwpw (&quot;world&quot; is replaced with hello, &#xA;       &quot;world&quot; is now yanked, cursor is at &quot;something&quot;)&#xA;&#xA;and: &#xA;&#xA;tviwp (where 't' toggles or swaps the last two items yanked,&#xA;       and &quot;something&quot; is replaced by &quot;hello&quot;)&#xA;&#xA;resulting text: &#xA;&#xA;&quot;hello hello hello&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I do not lose the default behavior, so that I can still do this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello world &#xA;^ cursor location&#xA;&#xA;viwywviwpbviwp&#xA;&#xA;result:&#xA;&#xA;world hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15729" LastActivityDate="2019-02-17T16:44:21.563" Title="Vim: remember last two items highlighted, with toggle" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16570" PostTypeId="1" AcceptedAnswerId="16572" CreationDate="2018-06-26T08:53:30.670" Score="1" ViewCount="294" Body="&lt;p&gt;I have built a list containing the &quot;job&quot; object as returned by job_start. The code populating the list is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:sc_instances = get(g:, 'sc_instances', [])&#xA;let l:job = job_start('my command and args')&#xA;call add(g:sc_instances, l:job)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I try to filter out the instances which are no longer running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the following code in the function to clean up the list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:sc_instances = get(g:, 'sc_instances', [])&#xA;call filter(g:sc_instances, {idx, val -&amp;gt; job_status(val) != &quot;run&quot;})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it always leaves the list empty after execution (removes all the items). What's wrong with my code?&lt;/p&gt;&#xA;" OwnerUserId="13084" LastEditorUserId="17549" LastEditDate="2018-07-03T10:33:57.510" LastActivityDate="2018-07-03T10:33:57.510" Title="Filter list of jobs (started with job_start()) by status" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16571" PostTypeId="2" ParentId="16053" CreationDate="2018-06-26T09:22:56.080" Score="1" Body="&lt;p&gt;I recommend tpope's &lt;a href=&quot;https://github.com/tpope/vim-eunuch&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-eunuch&lt;/a&gt; for executing all these kinds of UNIX shell commands, which includes &lt;code&gt;Delete&lt;/code&gt;, &lt;code&gt;Move&lt;/code&gt;, &lt;code&gt;Rename&lt;/code&gt;, &lt;code&gt;Chmod&lt;/code&gt;, to just name a few of them. To install it, visit this &lt;a href=&quot;https://vimawesome.com/plugin/eunuch-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;page&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-06-26T09:22:56.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16572" PostTypeId="2" ParentId="16570" CreationDate="2018-06-26T09:27:18.437" Score="1" Body="&lt;p&gt;Ok shame on me, I have badly read the documentation about filter:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The function must return |TRUE| if the item should be kept.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I just have to invert my condition.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call filter(g:sc_instances, {idx, val -&amp;gt; job_status(val) == &quot;run&quot;})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13084" LastActivityDate="2018-06-26T09:27:18.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16573" PostTypeId="2" ParentId="16569" CreationDate="2018-06-26T11:42:59.263" Score="3" Body="&lt;p&gt;Extending comment from @Mass, I want to say, the functionality you want can be used with these keys in order &lt;code&gt;viwywviwpwviw&quot;0p&lt;/code&gt;. Here, &lt;code&gt;0&lt;/code&gt; is a register and &lt;code&gt;&quot;0&lt;/code&gt; is motion to yank to or put from &lt;code&gt;reg 0&lt;/code&gt;. See &lt;code&gt;:h registers&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;viwy&lt;/code&gt; would yank &lt;code&gt;hello&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt; would goto next word, &lt;code&gt;world&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;viwp&lt;/code&gt; would visual-select the word &lt;code&gt;world&lt;/code&gt; and put(paste) the content of register &lt;code&gt;&quot;&lt;/code&gt;, i.e. the word &lt;code&gt;something&lt;/code&gt;. And the content of the register &lt;code&gt;&quot;&lt;/code&gt; would get changed to &lt;code&gt;world&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w&lt;/code&gt; would goto next word, &lt;code&gt;something&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;viw&quot;0p&lt;/code&gt; would visual-select the word &lt;code&gt;something&lt;/code&gt; and put(paste) the content of the register &lt;code&gt;0&lt;/code&gt;, i.e. the word &lt;code&gt;hello&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now, that is an interesting matter. If you read through the help docs, you'll see that, the numbered register 0 contains the text from the most recent yank commands, unless another register was specified with [&quot;x&quot;]. So, when previously you yanked with &lt;code&gt;viwy&lt;/code&gt;, you used the &lt;code&gt;unnamed register&lt;/code&gt;. Then when you visual-selected a word and put the content of the reg &quot;, the content of the reg &quot; and the visual-selection of the buffer gets exchanged. But the &lt;code&gt;numbered register 0&lt;/code&gt; still holds the previously yanked word. This will remain the case until you yank with &lt;code&gt;y&lt;/code&gt; or change the content of reg 0 in some other way (e.g. &lt;code&gt;:let @0=blablabla&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, overall, the register 0 holds the most recent unspecified yank with &lt;code&gt;y&lt;/code&gt;, not when used &lt;code&gt;c&lt;/code&gt; or &lt;code&gt;d&lt;/code&gt;. Those operators change the content of registers 2-9.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I strongly suggest you read through the help docs of vim about the registers. In my opinion, they are the strongest side of vim over other editors, even stronger than modal editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I assumed that you know about vim text objects and motions. For example, you can do &lt;code&gt;yiw&lt;/code&gt; instead of &lt;code&gt;viwy&lt;/code&gt;. &lt;code&gt;yiw&lt;/code&gt; translates into &lt;code&gt;yank inner word&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-17T16:44:21.563" LastActivityDate="2019-02-17T16:44:21.563" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16574" PostTypeId="1" AcceptedAnswerId="16576" CreationDate="2018-06-26T12:41:01.510" Score="0" ViewCount="160" Body="&lt;p&gt;Is there a way to retrieve the current filepath, modify it, and open the result?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be more specific, let's say I'm editing &lt;code&gt;./some/file/awesome.controller.ts&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I'd like to automatically open &lt;code&gt;./some/file/awesome.html&lt;/code&gt; (same file name, where &lt;code&gt;controller.ts&lt;/code&gt; is replaced by &lt;code&gt;html&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now, the only thing I could come up with is something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;ac :e @%&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is of course, completely useless since it does not modify the path string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks !&lt;/p&gt;&#xA;" OwnerUserId="11972" LastEditorUserId="1841" LastEditDate="2018-06-26T13:20:53.023" LastActivityDate="2018-06-26T13:30:13.433" Title="How to open file based on current file path" Tags="|key-bindings|buffers|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16575" PostTypeId="1" CreationDate="2018-06-26T13:30:09.230" Score="10" ViewCount="4899" Body="&lt;p&gt;Want a simple way, like notepad++ plugin: &lt;code&gt;NppExport&lt;/code&gt; - &lt;code&gt;Export to RTF&lt;/code&gt;, to copy selected text with syntax highlighting.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notepad++, NppExport, Export to RTF example:  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Select text&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/H7iQi.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/H7iQi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Dx8sZ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Dx8sZ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Copy RTF&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/JQNVB.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JQNVB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Paste with syntax highlighting&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/aZHXa.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aZHXa.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="205" LastEditDate="2018-06-27T00:13:54.947" LastActivityDate="2020-12-01T17:05:15.913" Title="How to copy text with syntax highlighting?" Tags="|syntax-highlighting|cut-copy-paste|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16576" PostTypeId="2" ParentId="16574" CreationDate="2018-06-26T13:30:13.433" Score="3" Body="&lt;p&gt;First of all I think what you are ultimately looking for is the &lt;a href=&quot;https://github.com/tpope/vim-projectionist&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-projectionist plugin&lt;/a&gt; which lets you define how your files are named and allow you to easily switch between a controller and its view for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise you might want to read:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expand%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h expand()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#filename-modifiers&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h filename-modifiers&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For example when you are editing &lt;code&gt;./some/file/awesome.controller.ts&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;expand('%')&lt;/code&gt; will return &lt;code&gt;rootDir/some/file/awesome.controller.ts&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;expand('%:h')&lt;/code&gt; will return &lt;code&gt;rootDir/some/file&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So you can play with that and maybe create a function which will take a user input and append it to the result of &lt;code&gt;expand('%:h')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you might also want you get used to &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3afind&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :find&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-06-26T13:30:13.433" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16577" PostTypeId="2" ParentId="16567" CreationDate="2018-06-26T14:16:21.500" Score="1" Body="&lt;h2&gt;Extending the comment of @guillem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;you need a simple &lt;code&gt;:s/\\/\\\\/g&lt;/code&gt; for each line that you want to perform the substitution on. Or maybe visually select the lines and then &lt;code&gt;:'&amp;lt;,'&amp;gt;s/\\/\\\\/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, you need to escape each &lt;code&gt;\&lt;/code&gt; with another &lt;code&gt;\&lt;/code&gt; before it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I'm adding &lt;a href=&quot;http://vim.wikia.com/wiki/Find_and_Replace&quot; rel=&quot;nofollow noreferrer&quot;&gt;a link to vim substitution command&lt;/a&gt;. Moreover, vim's substitute command &lt;code&gt;:s/&amp;lt;pattern&amp;gt;/&amp;lt;change&amp;gt;/&lt;/code&gt; is the same as the &lt;code&gt;search and replace&lt;/code&gt; command. Look at the wiki page for using vim's substitute command.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2018-06-27T14:44:48.787" LastActivityDate="2018-06-27T14:44:48.787" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="16578" PostTypeId="2" ParentId="16575" CreationDate="2018-06-26T16:26:56.610" Score="13" Body="&lt;p&gt;It's a bit roundabout, but one way to achieve this with built-in tools is to use the &lt;code&gt;:TOhtml&lt;/code&gt; command to create an HTML file that contains the highlighted text, open that file in a browser, and then copy from there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:TOhtml&lt;/code&gt; takes a range, so you can use this method to &quot;copy&quot; the highlighted contents of a visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :TOhtml&lt;/code&gt; and &lt;code&gt;:help 2html&lt;/code&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-06-26T16:26:56.610" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16579" PostTypeId="2" ParentId="15722" CreationDate="2018-06-26T16:31:01.227" Score="5" Body="&lt;p&gt;I have this in my .vimrc, which works when running tmux in gnome-terminal&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;term =~ '^tmux'&#xA;  let &amp;amp;t_BE=&quot;\&amp;lt;Esc&amp;gt;[?2004h&quot;&#xA;  let &amp;amp;t_BD=&quot;\&amp;lt;Esc&amp;gt;[?2004l&quot;&#xA;  let &amp;amp;t_PS=&quot;\&amp;lt;Esc&amp;gt;[200~&quot;&#xA;  let &amp;amp;t_PE=&quot;\&amp;lt;Esc&amp;gt;[201~&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Terminal in tmux is set to tmux-256color; fragment from ~/.tmux.conf:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set -g default-terminal tmux-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18013" LastActivityDate="2018-06-26T16:31:01.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16582" PostTypeId="1" AcceptedAnswerId="16593" CreationDate="2018-06-27T01:24:35.677" Score="12" ViewCount="10164" Body="&lt;p&gt;I tried &lt;code&gt;export PAGER=&quot;nvim -R&quot;&lt;/code&gt;, however it does not work for man page, so I &lt;code&gt;export MANPAGER=&quot;nvim -c 'set ft=man' -&quot;&lt;/code&gt; again, it works. However it still does not work for git log, it looks like below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lSD6K.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lSD6K.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to solve all problems?&lt;/p&gt;&#xA;" OwnerUserId="5663" LastActivityDate="2023-03-11T10:38:25.120" Title="How to use NeoVim as a pager?" Tags="|neovim|pager|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16585" PostTypeId="1" AcceptedAnswerId="16586" CreationDate="2018-06-27T12:50:06.613" Score="1" ViewCount="1100" Body="&lt;p&gt;Recently I've been playing with my statusline and I'm coming to a point where I want to set a different highlighting group for the statusline of my quickfix window, location list window, and the other windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do so I need to programmatically determine what type of buffer I am in. To differentiate between the &quot;regular&quot; buffers and the quickfix/location buffers I can easily test if &lt;code&gt;&amp;amp;buftype&lt;/code&gt; returns &lt;code&gt;quickfix&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is to differentiate quickfix and location list since &lt;code&gt;&amp;amp;buftype&lt;/code&gt; returns &lt;code&gt;quickfix&lt;/code&gt; for both buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen &lt;a href=&quot;https://stackoverflow.com/q/18522086/4194289&quot;&gt;this SO question&lt;/a&gt; which provides three solutions that don't satisfy me:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;w:quickfix_title&lt;/code&gt; variable tells you what command was used to generate the list displayed in the window. This is not what I'm looking for since I can open my location list with different commands other than &lt;code&gt;lopen&lt;/code&gt; (&lt;code&gt;SyntasticCheck&lt;/code&gt; would be an example)&lt;/li&gt;&#xA;&lt;li&gt;Parsing the output of &lt;code&gt;ls&lt;/code&gt;, matching the buffer number and checking if the name of the buffer matches &lt;code&gt;Location List&lt;/code&gt; or &lt;code&gt;Quickfix List&lt;/code&gt;. That could be a solution but I use different versions of Vim in different languages, so matching against all the possible names (e.g. &lt;code&gt;Location List&lt;/code&gt; and &lt;code&gt;Liste des emplacements&lt;/code&gt;) is not ideal.&lt;/li&gt;&#xA;&lt;li&gt;The third answer is about closing and reopening the windows to test if you were in one of them, this is really not convenient for a statusline setting.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So here are my two questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there another way to easily differentiate the quickfix buffer from the location list one?&lt;/li&gt;&#xA;&lt;li&gt;If not what would be the best way to set a statusline background depending on the type of quickfix window you're in?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-06-27T13:09:02.173" Title="How to differentiate quickfix window buffers and location list buffers?" Tags="|statusline|quickfix|location-list|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16586" PostTypeId="2" ParentId="16585" CreationDate="2018-06-27T13:09:02.173" Score="3" Body="&lt;p&gt;Ah ah. I've just implemented a function on the subject very recently: &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/qf.vim#L125&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/qf.vim#L125&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your version of Vim is recent enough, the discriminating information is stored in &lt;code&gt;getwininfo()[some_winnr].loclist&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you'll have to execute &lt;code&gt;:ls!&lt;/code&gt; and check whether you see &lt;code&gt;&quot;[Quickfix List]&quot;&lt;/code&gt; or &lt;code&gt;&quot;[Locsomething List]&quot;&lt;/code&gt; after the buffer number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have i18n issues (does this means I've missed this problem because my vim flavours are much too recent?), again, in my library plugin, you'll find &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/po.vim#L75&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;lh#po#context(...).translate(...)&lt;/code&gt;&lt;/a&gt; -- that won't work on Windows though :(&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-06-27T13:09:02.173" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16587" PostTypeId="2" ParentId="16568" CreationDate="2018-06-27T19:55:04.757" Score="1" Body="&lt;p&gt;As suggested by @ChristianBrabandt, the issue with my minimal working example (MWE, in the post) was solved by changing my encoding to &lt;em&gt;utf-8&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set encoding=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, in my original file, the characters were still displayed incorrectly, even after changing the encoding setting. I had to manually re-insert the characters. Not sure why it worked straight away with my MWE, but not with my original file.&lt;/p&gt;&#xA;" OwnerUserId="11449" LastActivityDate="2018-06-27T19:55:04.757" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16588" PostTypeId="1" AcceptedAnswerId="16613" CreationDate="2018-06-28T02:37:43.910" Score="0" ViewCount="437" Body="&lt;p&gt;This is my .vimrc configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set columns=80&#xA;set linebreak&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works as expected but when call NerdTree Toggle the lines expand to fix the terminal window size. Even when NerdTree is deactivated the columns=80 settings doesn't come back. I have google it but just could find:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set winfixwidth&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However it doesn't solve the problem.&lt;/p&gt;&#xA;" OwnerUserId="18029" LastActivityDate="2018-07-01T17:17:26.677" Title="NerdTree Toggle seems to overwrite my set columns=80" Tags="|vimrc|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16589" PostTypeId="2" ParentId="16502" CreationDate="2018-06-28T09:48:40.617" Score="0" Body="&lt;p&gt;Below shortcut and function will do the job. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;vga :call Vhdl_GA_All()&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Alignment&#xA;function! Vhdl_GA_All()&#xA;   exe &quot;normal! \e&quot;&#xA;   exe &quot;:'&amp;lt;,'&amp;gt; EasyAlign *&amp;lt;space&amp;gt;&quot;&#xA;   exe &quot;:'&amp;lt;,'&amp;gt; EasyAlign (&quot;&#xA;   exe &quot;:'&amp;lt;,'&amp;gt; EasyAlign )&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="13402" LastEditDate="2018-06-28T15:10:29.720" LastActivityDate="2018-06-28T15:10:29.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16590" PostTypeId="1" AcceptedAnswerId="16596" CreationDate="2018-06-28T09:59:53.680" Score="-1" ViewCount="37" Body="&lt;p&gt;I have below shortcut and function to align code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;vga :call Vhdl_GA_All()&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Alignment&#xA;function! Vhdl_GA_All()&#xA;   exe &quot;:'&amp;lt;,'&amp;gt; EasyAlign *&amp;lt;space&amp;gt;&quot;&#xA;   exe &quot;:'&amp;lt;,'&amp;gt; EasyAlign (&quot;&#xA;   exe &quot;:'&amp;lt;,'&amp;gt; EasyAlign )&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code before alignment:&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/M0ZU6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/M0ZU6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Select line 2~4 and run &lt;code&gt;&amp;lt;leader&amp;gt;vga&lt;/code&gt;&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/c3Z3S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/c3Z3S.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why first line is not aligned?&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-06-28T15:09:26.530" Title="EasyAlign: Why first line is not aligned?" Tags="|alignment|plugin-easy-align|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16591" PostTypeId="1" AcceptedAnswerId="16592" CreationDate="2018-06-28T10:53:58.530" Score="0" ViewCount="52" Body="&lt;p&gt;First I will describe what I am trying to achieve:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general I use &lt;code&gt;set iskeyword+=-&lt;/code&gt; as I see this more usable (one should always put spaces around operators when needed). This is quite helpful, but has one significant disadvantage - it also causes &lt;code&gt;i_^w&lt;/code&gt; to behave not as expected. So I am trying to write function that would reset &lt;code&gt;'iskeyword'&lt;/code&gt; to default value, modify it a little and then fire the same functionality as &lt;code&gt;i_^w&lt;/code&gt;, however I cannot find how to handle &quot;deletion&quot; part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My attempt&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! smart#delete_word() abort&#xA;    let l:iskeyword = &amp;amp;iskeyword&#xA;&#xA;    try&#xA;        set iskeyword&amp;amp;vim&#xA;        set iskeyword-=_&#xA;&#xA;        if col('.') == col('$') - 1&#xA;            normal! dvb&#xA;        else&#xA;            normal! db&#xA;        end&#xA;    finally&#xA;        let &amp;amp;iskeyword = l:iskeyword&#xA;    endtry&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However &lt;code&gt;db&lt;/code&gt;/&lt;code&gt;dvb&lt;/code&gt; trick isn't always working as expected and sometimes there are some leftovers at the end of the line or some additional characters are deleted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So question is, how to achieve the same behaviour as &lt;code&gt;i_^w&lt;/code&gt; in function (worth mentioning that &lt;code&gt;i_^w&lt;/code&gt; itself will be remapped to this function, so it wouldn't be a solution to just &lt;code&gt;feedkeys(&quot;\&amp;lt;C-w&amp;gt;&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1259" LastActivityDate="2018-07-28T12:00:30.080" Title="How to invoke mapped `i_CTRL-W` in function" Tags="|key-bindings|vimscript|insert-mode|functions|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16592" PostTypeId="2" ParentId="16591" CreationDate="2018-06-28T11:46:29.470" Score="1" Body="&lt;p&gt;Ok, I have found the solution that seems to work without problems:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if col('.') == col('$') - 1&#xA;     exec &quot;norm! a\&amp;lt;C-w&amp;gt;\&amp;lt;right&amp;gt;&quot;&#xA;else&#xA;     exec &quot;norm! i\&amp;lt;C-w&amp;gt;\&amp;lt;right&amp;gt;&quot;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1259" LastActivityDate="2018-06-28T11:46:29.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16593" PostTypeId="2" ParentId="16582" CreationDate="2018-06-28T11:46:32.667" Score="10" Body="&lt;p&gt;For git, you may want to use the the following configuration:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;git config --global core.pager &quot;nvim -R&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be a good idea to tell git to disable colors as it would conflict with neovim colors:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;git config --global color.pager no&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This second command fix the bug of your screenshot&lt;/p&gt;&#xA;" OwnerUserId="15134" LastEditorUserId="15134" LastEditDate="2020-04-20T06:17:48.557" LastActivityDate="2020-04-20T06:17:48.557" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16594" PostTypeId="1" CreationDate="2018-06-28T12:31:55.203" Score="2" ViewCount="534" Body="&lt;p&gt;Is there a way that I can have the &lt;code&gt;:make&lt;/code&gt; command output itself to a terminal window in vim? In the 8.1 release, they added the &lt;code&gt;:term&lt;/code&gt; command, which allows you to run an external program in a vim window. I was wondering if there's some way to combine the two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want this because i use vim-latex for compiling my .tex files (which compiles using &lt;code&gt;:make&lt;/code&gt;), and it would actually be helpful for me to be able to deal with errors and stuff while still in vim. &lt;/p&gt;&#xA;" OwnerUserId="10421" LastEditorUserId="1292" LastEditDate="2018-10-02T07:47:30.833" LastActivityDate="2022-11-12T04:04:22.317" Title="Running vim's ':make' using ':term'" Tags="|plugin-vim-latex|terminal-buffer|makeprg|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16595" PostTypeId="2" ParentId="16594" CreationDate="2018-06-28T14:33:11.240" Score="1" Body="&lt;p&gt;On windows gvim only, you can use &lt;code&gt;set guioptions+=!&lt;/code&gt; to run &lt;code&gt;make&lt;/code&gt; in a terminal.  This isn't yet supported on other platforms so you will have to find an alternative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to create a new terminal each time,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=* Make execute 'terminal' &amp;amp;makeprg.(empty(&amp;lt;q-args&amp;gt;)?'':' '.&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-06-28T14:33:11.240" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16596" PostTypeId="2" ParentId="16590" CreationDate="2018-06-28T15:09:26.530" Score="0" Body="&lt;p&gt;Found need to add &lt;code&gt;exe &quot;normal! \e&quot;&lt;/code&gt; before EasyAlign.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-06-28T15:09:26.530" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16597" PostTypeId="1" CreationDate="2018-06-28T17:20:08.827" Score="1" ViewCount="142" Body="&lt;p&gt;I have set up the following list of commands to switch buffers: (in a &lt;code&gt;.vim&lt;/code&gt; file i &lt;code&gt;source&lt;/code&gt; from my &lt;code&gt;.vimrc&lt;/code&gt; to keep it organised)                                                                                                                               &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap &amp;lt;C-Left&amp;gt; &amp;lt;esc&amp;gt;:bnext&amp;lt;CR&amp;gt;                                                                                                                                                     &#xA;:noremap &amp;lt;C-Right&amp;gt; &amp;lt;esc&amp;gt;:bprev&amp;lt;CR&amp;gt;                                                                                                                                                    &#xA;:noremap &amp;lt;C-x&amp;gt; &amp;lt;esc&amp;gt;:bd&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(I am using airline to see buffers in top row when there aren't multiple tabs.)&lt;/em&gt;&lt;br&gt;&#xA;And whenever I switch to a different buffer, on some occasions (I have noticed this mostly when editing .dotfiles), on switching back the initial buffer loses all colour.&lt;br&gt;&#xA;Also, these bindings have since recently stopped working and show an                                                                                                                     &lt;code&gt;E338: Could not find definition.&lt;/code&gt;                                                                                                                                                           error.&lt;br&gt;&#xA;However, entering &lt;code&gt;:map &amp;lt;C-Left&amp;gt;&lt;/code&gt; only outputs my mapping and nothing else, and again, this used to work before. When I map the command to a different sequence, say &lt;code&gt;&amp;lt;escape&amp;gt;&amp;lt;left&amp;gt;&lt;/code&gt;, it does mostly end up working, though. (I would still prefer this one for convenience.)&lt;br&gt;&#xA;What gives?&#xA;(i am using &lt;code&gt;Gnome terminal (xterm)&lt;/code&gt; + &lt;code&gt;tmux&lt;/code&gt;)                                                                                                                                                                                   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Additional information:&lt;/strong&gt; I have recently accidentally replaced my                                                                                                                              &lt;code&gt;/etc/bin/bash/&lt;/code&gt;                                                                                                                                                                         with a single file and am experiencing some other strange behaviour with &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;xterm&lt;/code&gt; ever since. I have, however, never found out if the folder is supposed to be useful in any way and am not currently in a spot to reinstall my whole system. What should the folder contain on a healthy system?      &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My .vim folder is to be found on my git repo &lt;a href=&quot;http://github.com/OndraX/MyVimDir&quot; rel=&quot;nofollow noreferrer&quot;&gt;OndraX/MyVimDir&lt;/a&gt;.&lt;/strong&gt; &#xA; &lt;em&gt;(personal and for convenience, but feel no need to waste one of five slots on hiding it)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="17803" LastActivityDate="2018-06-28T17:20:08.827" Title="Strange behaviour when switching buffers in vim (syntax highlighting and keymaps cease to work until .vimrc source)" Tags="|vimrc|buffers|plugin-airline|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16598" PostTypeId="2" ParentId="16594" CreationDate="2018-06-28T22:16:12.520" Score="1" Body="&lt;p&gt;Not exactly what you asked for (using the terminal new vim 8.1 feature) but you should check asyncrun plugin which let you execute whatever you want asynchronously and get the output in quick fix (using errorformat to parse the output...). &#xA;&lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;asyncrun.vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13084" LastActivityDate="2018-06-28T22:16:12.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16599" PostTypeId="1" CreationDate="2018-06-29T03:34:16.160" Score="1" ViewCount="45" Body="&lt;p&gt;I have two closely related questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a plugin, or a combination of vim commands, that allow&#xA;something analogous to the insertion of a cell in a pseudo tabular&#xA;arrangment of a text file, by &quot;pushing&quot; the old cells down? (as one&#xA;might do  by using a program such as gnumeric).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it possible to edit a cell, within a pseudo tabular arrangement, &#xA;thereby increasing the size of the cell block so that it can contain &#xA;more lines of text?  Naturally, I would like this while preserving &#xA;the pseudo tabular structure.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My current, very primitive approach to achieving what I want consists in &#xA;putting each column into a separate file, then edit these files together,&#xA;side by side, using vim windows, so that one be able to take care of the &#xA;proper vertical alignment, and finally use unix &quot;paste&quot; to merge the &#xA;separate files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;paste col1.txt col2.txt col3.txt &amp;gt; table.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried a few plugins such as &quot;table-mode&quot;, which when adding&#xA;text to a cell preserves the tabular structure by simply increasing &#xA;the width of the cell, something which is not always satisfactory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried &quot;vim-multiedit&quot;, which allows the user to &quot;specify&#xA;regions of text&quot; and then edit them simultaneously. However the &#xA;emphasis is on doing the editing only once for all regions, and&#xA;not on preserving  the &quot;cell/tabular structure&quot;.&lt;/p&gt;&#xA;" OwnerUserId="18041" LastEditorUserId="18041" LastEditDate="2018-06-29T18:06:11.390" LastActivityDate="2018-06-29T18:06:11.390" Title="editing cell blocks of text, within a pseudo tabular arrangement" Tags="|plugin-tabular|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16600" PostTypeId="1" AcceptedAnswerId="16601" CreationDate="2018-06-29T16:02:00.350" Score="2" ViewCount="1593" Body="&lt;p&gt;I &lt;a href=&quot;https://stackoverflow.com/questions/9065941/how-can-i-change-vim-status-line-color&quot;&gt;tried&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi StatusLine ctermfg=red&#xA;highlight statisline ctermfg=red&#xA;hi! statusline ctermfg=008&#xA;hi statusline ctermfg=008&#xA;hi statusline cterm=bold&#xA;hi StatusLineNC ctermfg=2 ctermbg=8 cterm=NONE&#xA;hi StatusLineNC ctermfg=2 ctermbg=8 cterm=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nothing changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;macOS, the latest Vim 8 from Brew, in default terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;a href=&quot;https://bitbucket.org/vitaly-zdanevich/vim-config/raw/a92504e544c60e03344ce8b4d577dcf2886156ff/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimrc&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6038" LastEditorUserId="23502" LastEditDate="2022-09-16T16:11:44.863" LastActivityDate="2022-09-16T16:11:44.863" Title="Cannot change the color of status line" Tags="|statusline|macos|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16601" PostTypeId="2" ParentId="16600" CreationDate="2018-06-29T16:51:35.123" Score="1" Body="&lt;p&gt;Possible solutions, try them all:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Check if you're using &lt;code&gt;set termguicolors&lt;/code&gt; in your vimrc. If yes, then either disable it or use &lt;code&gt;guibg&lt;/code&gt; and &lt;code&gt;guifg&lt;/code&gt; instead of &lt;code&gt;ctermbg&lt;/code&gt; and &lt;code&gt;ctermfg&lt;/code&gt; respectively.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Check if you're calling for changing the colorscheme after you set your statusline highlights. You should call your colorscheme &lt;em&gt;before&lt;/em&gt; you set personalized statusline highlights.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That should do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You currently have groupwise highlight set to User{N}, i.e. your vimrc has:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%1*%F%h%m%=\ [%p%%]\ [%l/%L]:%c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;see the part with %1*? that's what I'm talking about. The solutions are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Remove it.&#xA;Or,&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Read through the help docs &lt;code&gt;:h statusline&lt;/code&gt; and learn to use User{N} highlight properly, specially the part about&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* -   Set highlight group to User{N}, where {N} is taken from the&#xA;  minwid field, e.g. %1*.  Restore normal highlight with %* or %0*.&#xA;  The difference between User{N} and StatusLine  will be applied&#xA;  to StatusLineNC for the statusline of non-current windows.&#xA;  The number N must be between 1 and 9.  See |hl-User1..9|&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2018-06-30T12:42:17.013" LastActivityDate="2018-06-30T12:42:17.013" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16602" PostTypeId="2" ParentId="10242" CreationDate="2018-06-29T18:05:31.767" Score="0" Body="&lt;p&gt;This is only for Windows guys who got the similar issure:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Windows 64-bit, you MUST install the same bit python version as your VIM. &#xA;etc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;32bit vim =&amp;gt; 32bit python&#xA;64bit vim =&amp;gt; 64bit python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Otherwise python2x.dll or python3x.dll will NOT be loaded. &lt;/p&gt;&#xA;" OwnerUserId="13836" LastEditorUserId="13836" LastEditDate="2018-07-17T21:03:26.073" LastActivityDate="2018-07-17T21:03:26.073" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16603" PostTypeId="1" AcceptedAnswerId="16604" CreationDate="2018-06-29T18:26:32.563" Score="1" ViewCount="99" Body="&lt;p&gt;I have the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Test]&#xA;public void Some_Unit_Test_Function()&#xA;{&#xA;   // some setup-test-assert code&#xA;   ...&#xA;   // end of code&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's the 'vim' way of copying the entire function (including the [Test] attribute), and pasting it below the original function with one line spacing in-between.  I want to end up with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Test]&#xA;public void Some_Unit_Test_Function()&#xA;{&#xA;   // some setup-test-assert code&#xA;   ...&#xA;   // end of code&#xA;}&#xA;&#xA;[Test]&#xA;public void Some_Unit_Test_Function()&#xA;{&#xA;   // some setup-test-assert code&#xA;   ...&#xA;   // end of code&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18027" LastActivityDate="2018-07-01T21:10:14.770" Title="Copy-Paste C# style function with attributes" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16604" PostTypeId="2" ParentId="16603" CreationDate="2018-06-29T22:41:01.457" Score="2" Body="&lt;h3&gt;&lt;code&gt;yapGo&amp;lt;C-o&amp;gt;p&lt;/code&gt;:&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;yap&lt;/code&gt; to copy the paragraph &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;G&lt;/code&gt; go to the end of file &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&lt;/code&gt; to insert a new line and enter insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; to enter another command, &lt;a href=&quot;http://vim.wikia.com/wiki/Use_Ctrl-O_instead_of_Esc_in_insert_mode_mappings&quot; rel=&quot;nofollow noreferrer&quot;&gt;more about this here&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;and &lt;code&gt;p&lt;/code&gt; to paste &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;Updated&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Thank you for your comment @DBenKnoble, this answer now reflects entering insert mode&lt;/li&gt;&#xA;&lt;li&gt;@Eternal21 step 3 shows a way to enter the new line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Hope this helps. Thank you for the feedback.&lt;/p&gt;&#xA;" OwnerUserId="8253" LastEditorUserId="8253" LastEditDate="2018-07-01T21:10:14.770" LastActivityDate="2018-07-01T21:10:14.770" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16605" PostTypeId="1" CreationDate="2018-06-30T04:54:08.787" Score="1" ViewCount="145" Body="&lt;p&gt;Could I just duplicate what &lt;code&gt;scrollbind&lt;/code&gt; does, and use &lt;code&gt;tmux&lt;/code&gt; to &lt;code&gt;send-keys&lt;/code&gt; to the other vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;code&gt;vim&lt;/code&gt; on an android device (in &lt;code&gt;termux&lt;/code&gt;), and want the effect of spreading &lt;code&gt;vim&lt;/code&gt; over another device's display, by scrollbinding with an offset. i.e. as text scrolls off the top of one, it scrolls onto the bottom of the other. In effect, a single terminal twice as high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW &lt;code&gt;client-server&lt;/code&gt; isn't available to me (on android, no MS or xwindows; not compiled on my vim executable anyway)&lt;/p&gt;&#xA;" OwnerUserId="3189" LastEditorUserId="3189" LastEditDate="2018-07-09T07:37:41.327" LastActivityDate="2018-07-09T07:37:41.327" Title="remote scrollbind with an offset (to increase the viewing area, over two screens)" Tags="|scrolling|tmux|clientserver|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16606" PostTypeId="1" AcceptedAnswerId="16608" CreationDate="2018-06-30T09:53:41.587" Score="1" ViewCount="559" Body="&lt;p&gt;I'm using vim-fugitive. However, I'm using a black and white colorscheme. So, I don't see any warning for the 50 char long subject line of git commit message. I want to know how I can add a highlight group for that setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any existing highlight group like 'Statement' or 'Special' for this setting? Or do I need to create one myself? If yes, then how do I do it?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2018-06-30T14:02:17.470" Title="How to get 50 char long warning color highlight in vim gitcommit message without fugitive" Tags="|syntax-highlighting|colorscheme|plugin-fugitive|color|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16607" PostTypeId="2" ParentId="8378" CreationDate="2018-06-30T13:06:49.127" Score="8" Body="&lt;p&gt;For completeness, I want to present this awesome functions that I collected (stole) from &lt;a href=&quot;https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7&quot; rel=&quot;nofollow noreferrer&quot;&gt;romainl&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; redirect the output of a Vim or external command into a scratch buffer&#xA;function! Redir(cmd)&#xA;  if a:cmd =~ '^!'&#xA;    execute &amp;quot;let output = system('&amp;quot; . substitute(a:cmd, '^!', '', '') . &amp;quot;')&amp;quot;&#xA;  else&#xA;    redir =&amp;gt; output&#xA;    execute a:cmd&#xA;    redir END&#xA;  endif&#xA;  tabnew&#xA;  setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile&#xA;  call setline(1, split(output, &amp;quot;\n&amp;quot;))&#xA;  put! = a:cmd&#xA;  put = '----'&#xA;endfunction&#xA;command! -nargs=1 Redir silent call Redir(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will take normal or system command output and put it in a new tab. Feel free to change the line &lt;code&gt;tabnew&lt;/code&gt; to &lt;code&gt;vnew&lt;/code&gt; or &lt;code&gt;new&lt;/code&gt; etc.&lt;/p&gt;&#xA;&lt;p&gt;(&lt;code&gt;new&lt;/code&gt; and &lt;code&gt;vnew&lt;/code&gt; are alternatives to &lt;code&gt;split&lt;/code&gt; and &lt;code&gt;vsplit&lt;/code&gt; as the output would otherwise be printed in your current file)&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="20416" LastEditDate="2021-01-23T13:44:16.960" LastActivityDate="2021-01-23T13:44:16.960" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16608" PostTypeId="2" ParentId="16606" CreationDate="2018-06-30T14:02:17.470" Score="3" Body="&lt;p&gt;The highlight group is &lt;code&gt;hi gitcommitOverflow&lt;/code&gt;. however it's part of vim's built-in &lt;code&gt;syntax&lt;/code&gt; file &lt;code&gt;gitcommit.vim&lt;/code&gt;, not in any way part of fugitive (besides having the same maintainer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strangely, it looks like it was intended to be linked to &lt;code&gt;Error&lt;/code&gt; by default but this was commented out.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;hi def link gitcommitOverflow      Error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Putting this line in your custom color scheme/syntax configuration would work, or you can assign different colors in the usual way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the future, if you want to see which highlight group is being used you can use a map such as this (from vim tip 99 and &lt;a href=&quot;https://vi.stackexchange.com/questions/13137/how-to-identify-the-highlight-groups-in-use-on-a-particular-character/13138#13138&quot;&gt;How to identify the highlight groups in use on a particular character?&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F10&amp;gt; :echo &quot;hi&amp;lt;&quot; . synIDattr(synID(line(&quot;.&quot;),col(&quot;.&quot;),1),&quot;name&quot;) . '&amp;gt; trans&amp;lt;'&#xA;    \ . synIDattr(synID(line(&quot;.&quot;),col(&quot;.&quot;),0),&quot;name&quot;) . &quot;&amp;gt; lo&amp;lt;&quot;&#xA;    \ . synIDattr(synIDtrans(synID(line(&quot;.&quot;),col(&quot;.&quot;),1)),&quot;name&quot;) . &quot;&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-06-30T14:02:17.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16609" PostTypeId="2" ParentId="16582" CreationDate="2018-06-30T14:45:31.430" Score="3" Body="&lt;p&gt;Using neovim and vim with &lt;code&gt;update-alternatives&lt;/code&gt;:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo update-alternatives --install /usr/bin/vi vi /usr/bin/nvim 60&#xA;sudo update-alternatives --config vi&#xA;sudo update-alternatives --install /usr/bin/vim vim /usr/bin/nvim 60&#xA;sudo update-alternatives --config vim&#xA;sudo update-alternatives --install /usr/bin/editor editor /usr/bin/nvim 60&#xA;sudo update-alternatives --config editor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the configuration of &lt;code&gt;update-alternatives&lt;/code&gt; print:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Selection    Path                Priority   Status&#xA;------------------------------------------------------------&#xA;  0            /usr/bin/nvim        60        auto mode&#xA;* 1            /usr/bin/nvim        60        manual mode&#xA;  2            /usr/bin/vim.basic   30        manual mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then exporting &lt;code&gt;MANPAGER&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export MANPAGER=&quot;/bin/sh -c \&quot;col -b | vim -c 'set ft=man ts=8 nomod nolist nonu noma' -\&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18046" LastActivityDate="2018-06-30T14:45:31.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16610" PostTypeId="1" CreationDate="2018-06-30T23:41:29.593" Score="2" ViewCount="1921" Body="&lt;p&gt;I'm looking for an approach, in Vimscript, to operate on the text lines of a buffer by looping through lines of a visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, my goal is very simple: I have a (vertical) list of words, which I want to convert into a table; the first word is in the first column, the second is the first word in the second column; the third word is the second word in the first column, the fourth is the second word in the second column; and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for the vertical list of letters below, I want to achieve this (in verbatim):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a --&amp;gt; 1. a b&#xA;b     2. c d&#xA;c     3. e f&#xA;d&#xA;e&#xA;f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;strong&gt;initial thought&lt;/strong&gt; was to find a way to loop over the lines of a visual selection, after which I apply a macro depending on the whether the current linenumber is even or odd. The iterator variable of the loop can then be used to insert the row numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does one loop through the lines of a visual selection and operate on the current line, through a Vimscript function?&lt;/p&gt;&#xA;" OwnerUserId="11449" LastActivityDate="2018-07-02T19:35:15.703" Title="Operate on a visual selection by looping through the lines" Tags="|vimscript|parsing|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16611" PostTypeId="1" CreationDate="2018-07-01T17:02:42.297" Score="2" ViewCount="5691" Body="&lt;p&gt;I installed VIM by compiling from source a while back following the instructions &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. At that time, for some reason, I didn't use &lt;code&gt;checkinstall&lt;/code&gt;, as a result I can't uninstall it using &lt;code&gt;sudo apt-get remove vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following the advice &lt;a href=&quot;https://superuser.com/questions/623040/uninstalling-vim-compiled-from-source&quot;&gt;here&lt;/a&gt;, I tried to remove VIM by &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/tmp&#xA;hub clone vim/vim&#xA;cd vim&#xA;make VIMRUNTIMEDIR=/usr/local/share/vim/vim80&#xA;sudo make uninstall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, I am using &lt;code&gt;make VIMRUNTIMEDIR=/usr/local/share/vim/vim80&lt;/code&gt; instead of &lt;code&gt;make VIMRUNTIMEDIR=/usr/share/vim/vim80&lt;/code&gt; as suggested by the other link. This is because that's where there is a &lt;code&gt;vim80&lt;/code&gt; directory. I have also confirmed this by looking through my command line history that I indeed used &lt;code&gt;make VIMRUNTIMEDIR=/usr/local/share/vim/vim80&lt;/code&gt; when installing vim at that time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After I ran the above set of commands, it seems that vim got removed, in that I can no longer start &lt;code&gt;vim&lt;/code&gt; by typing &lt;code&gt;vim&lt;/code&gt; in the command line. However, when I look at the output of the command, it seems its actually trying to remove the files from the non-existent directory at &lt;code&gt;/usr/local/share/vim/vim81&lt;/code&gt;. I have posted a snapshot of the output here but it's the same for the rest of the output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rmdir /usr/local/share/vim/vim81/doc /usr/local/share/vim/vim81/print /usr/local/share/vim/vim81/colors /usr/local/share/vim/vim81/syntax /usr/local/share/vim/vim81/indent&#xA;rmdir: failed to remove '/usr/local/share/vim/vim81/doc': No such file or directory&#xA;rmdir: failed to remove '/usr/local/share/vim/vim81/print': No such file or directory&#xA;rmdir: failed to remove '/usr/local/share/vim/vim81/colors': No such file or directory&#xA;rmdir: failed to remove '/usr/local/share/vim/vim81/syntax': No such file or directory&#xA;rmdir: failed to remove '/usr/local/share/vim/vim81/indent': No such file or directory&#xA;Makefile:2776: recipe for target 'uninstall_runtime' failed&#xA;make[1]: [uninstall_runtime] Error 1 (ignored)&#xA;rm -rf /usr/local/share/vim/vim81/ftplugin/*.vim /usr/local/share/vim/vim81/ftplugin/README.txt /usr/local/share/vim/vim81/ftplugin/logtalk.dict&#xA;rm -f /usr/local/share/vim/vim81/autoload/*.vim /usr/local/share/vim/vim81/autoload/README.txt&#xA;rm -f /usr/local/share/vim/vim81/autoload/dist/*.vim /usr/local/share/vim/vim81/autoload/xml/*.vim&#xA;rm -f /usr/local/share/vim/vim81/plugin/*.vim /usr/local/share/vim/vim81/plugin/README.txt&#xA;rmdir /usr/local/share/vim/vim81/ftplugin /usr/local/share/vim/vim81/autoload/dist /usr/local/share/vim/vim81/autoload/xml /usr/local/share/vim/vim81/autoload&#xA;rmdir: failed to remove '/usr/local/share/vim/vim81/ftplugin': No such file or directory&#xA;rmdir: failed to remove '/usr/local/share/vim/vim81/autoload/dist': No such file or directory&#xA;rmdir: failed to remove '/usr/local/share/vim/vim81/autoload/xml': No such file or directory&#xA;rmdir: failed to remove '/usr/local/share/vim/vim81/autoload': No such file or directory&#xA;Makefile:2776: recipe for target 'uninstall_runtime' failed&#xA;make[1]: [uninstall_runtime] Error 1 (ignored)&#xA;rmdir /usr/local/share/vim/vim81/plugin /usr/local/share/vim/vim81&#xA;rmdir: failed to remove '/usr/local/share/vim/vim81/plugin': No such file or directory&#xA;rmdir: failed to remove '/usr/local/share/vim/vim81': No such file or directory&#xA;Makefile:2776: recipe for target 'uninstall_runtime' failed&#xA;make[1]: [uninstall_runtime] Error 1 (ignored)&#xA;rmdir /usr/local/share/vim&#xA;rmdir: failed to remove '/usr/local/share/vim': Directory not empty&#xA;Makefile:2776: recipe for target 'uninstall_runtime' failed&#xA;make[1]: [uninstall_runtime] Error 1 (ignored)&#xA;rm -f /usr/local/bin/vim&#xA;rm -f /usr/local/bin/vimtutor&#xA;rm -f /usr/local/bin/gvimtutor&#xA;rm -f /usr/local/bin/ex /usr/local/bin/view&#xA;rm -f /usr/local/bin/gvim /usr/local/bin/gview&#xA;rm -f /usr/local/bin/rvim /usr/local/bin/rview&#xA;rm -f /usr/local/bin/rgvim /usr/local/bin/rgview&#xA;rm -f /usr/local/bin/vimdiff /usr/local/bin/gvimdiff&#xA;rm -f /usr/local/bin/evim /usr/local/bin/eview&#xA;rm -f /usr/local/bin/xxd&#xA;make[1]: Leaving directory '/home/dibya/tmp/vim/src'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I looked at the folder in &lt;code&gt;/usr/local/share/vim&lt;/code&gt;, I noticed that the directory &lt;code&gt;vim80&lt;/code&gt; is still present. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Is it enough to just delete the &lt;code&gt;vim80&lt;/code&gt; directory? Why is &lt;code&gt;make uninstall&lt;/code&gt; trying to remove &lt;code&gt;vim&lt;/code&gt; from &lt;code&gt;/usr/local/share/vim/vim81&lt;/code&gt; instead of &lt;code&gt;/usr/local/share/vim/vim80&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="13848" LastEditorUserId="1841" LastEditDate="2018-07-02T11:24:29.713" LastActivityDate="2019-02-12T05:44:07.373" Title="Unable to uninstall VIM installed from source" Tags="|linux|installing|compile-vim|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16612" PostTypeId="2" ParentId="15713" CreationDate="2018-07-01T17:13:14.340" Score="2" Body="&lt;p&gt;Vim doesn't keep a history of your normal mode commands. If you do wish to keep a history of your normal mode history, you can use the following to save that to a file: &lt;a href=&quot;https://vi.stackexchange.com/a/587/13848&quot;&gt;https://vi.stackexchange.com/a/587/13848&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normal mode commands are usually short, so people just type it out in normal mode and not try to create macros. However, if you do want to create macros out of normal mode commands, you can convert it into a &lt;code&gt;Ex&lt;/code&gt; mode command and then save it into a macro as @wmmso pointed out. You can do this by using the &lt;code&gt;norm&lt;/code&gt; command. So if you want to delete 2 word starting at the current cursor position, and use a normal mode command in &lt;code&gt;Ex&lt;/code&gt; mode use &lt;code&gt;:norm d2w&lt;/code&gt;. (Ref: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/various.html#:norm&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/various.html#:norm&lt;/a&gt;, &lt;a href=&quot;https://vi.stackexchange.com/questions/4418/execute-normal-command-over-range&quot;&gt;Execute normal command over range&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its better to use a &lt;code&gt;Ex&lt;/code&gt; mode command if it is a complicated command, as it allows you to type out the full command in a buffer, make sure that its actually correct and also saves it in the command line history. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that you have your normal mode command in ex mode, you can also browse your command like history using &lt;code&gt;q:&lt;/code&gt;, and then copy it into a register using &lt;code&gt;&quot;ay$&lt;/code&gt;, while on the line containing the command line you want to save to a macro. Then when you want to run the macro, you can execute it using &lt;code&gt;@a&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13848" LastEditorUserId="13848" LastEditDate="2018-07-01T22:19:42.323" LastActivityDate="2018-07-01T22:19:42.323" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16613" PostTypeId="2" ParentId="16588" CreationDate="2018-07-01T17:17:26.677" Score="0" Body="&lt;p&gt;If you want your lines to be set to a certain length, then use &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set textwidth=80&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will set the number of columns to display and works well with NERDTree for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ref:&#xA;1. &lt;a href=&quot;https://stackoverflow.com/questions/3033423/vim-command-to-restructure-force-text-to-80-columns&quot;&gt;https://stackoverflow.com/questions/3033423/vim-command-to-restructure-force-text-to-80-columns&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-07-01T17:17:26.677" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16614" PostTypeId="2" ParentId="11426" CreationDate="2018-07-01T17:23:18.297" Score="0" Body="&lt;p&gt;This happens sometimes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using &lt;code&gt;:NERDTreeToggle&lt;/code&gt;, use &lt;code&gt;:NERDTree&lt;/code&gt;. This will use the default settings of the window size to open a new &lt;code&gt;NERDTRee&lt;/code&gt; window.&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-07-01T17:23:18.297" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16615" PostTypeId="2" ParentId="10296" CreationDate="2018-07-01T17:29:17.000" Score="9" Body="&lt;p&gt;If you just need to modify a small amount of text or a word, you can use &lt;code&gt;&amp;lt;Ctrl-O&amp;gt;h/j/k/l&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;Ctrl-O&amp;gt;&lt;/code&gt; takes you back to Normal mode just for that command, and then drops you back into insert mode, so it saves you some amount of key presses, if you need to go into normal mode for a small movement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ref:&#xA;1. &lt;a href=&quot;http://vim.wikia.com/wiki/Use_Ctrl-O_instead_of_Esc_in_insert_mode_mappings&quot; rel=&quot;noreferrer&quot;&gt;http://vim.wikia.com/wiki/Use_Ctrl-O_instead_of_Esc_in_insert_mode_mappings&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-07-01T17:29:17.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16617" PostTypeId="1" CreationDate="2018-07-01T22:27:57.110" Score="5" ViewCount="1263" Body="&lt;p&gt;I have really two questions, sides of the same coin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) How exactly does vim evaluate whether the buffer is different from a file in order to determine the error&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;WARNING: The file has been changed since reading it!!!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;...and how can I replicate that test to get a clearer sense of what aspect of the file is causing the perceived change?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) How can I prevent these warnings when the file content is not what has changed?  Is this a Bad Idea for reasons I'm missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LONGER FORM EXPLANATION:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Background:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have a Linux Guest virtual machine (Arch/Manjaro-i3 64-bit) running on VirtualBox under a Windows 10 Host machine.&lt;/li&gt;&#xA;&lt;li&gt;The host machine has a partition formatted as NTFS that is intended to be shared between the two.&lt;/li&gt;&#xA;&lt;li&gt;The shared partition is shared via Samba (standard Windows 10 sharing), and mounted on the Linux guest as a cifs drive in /etc/fstab.&lt;/li&gt;&#xA;&lt;li&gt;The shared partition is populated and monitored by Google Backup &amp;amp; Sync.&lt;/li&gt;&#xA;&lt;li&gt;I'm editing files in that mount, using vim 8.1 on the Guest system.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Problem:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I get the aforementioned error the &lt;em&gt;second&lt;/em&gt; time I try to write to a file in a given session.&lt;/li&gt;&#xA;&lt;li&gt;re-editing the file after each write (':e') prevents the warning&lt;/li&gt;&#xA;&lt;li&gt;That's not a viable workaround.  It's annoying, but more importantly it wipes my undo history every time I save my work.&lt;/li&gt;&#xA;&lt;li&gt;I know the contents have not changed on disk between the two writes.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, I want to prevent the error, and also to understand how to examine its provenance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, immediately after I write a file to disk, something (Samba, Google Drive, or something else) is making a triggering modification to the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;suspect&lt;/em&gt; the issue is some latency between when vim thinks it timestamped the file, and what timestamp gets recorded by Samba when it eventually sees the write-op, such that vim thinks it might be out of date.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'm not sure...  And if that's true, I'm still not savvy enough to fix it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suggestions?&lt;/p&gt;&#xA;" OwnerUserId="18057" LastEditorUserId="18057" LastEditDate="2018-07-01T22:54:32.880" LastActivityDate="2018-07-02T21:35:07.703" Title="Suppress/bypass &quot;file has changed&quot; errors when editing cifs/Samba files" Tags="|save|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16618" PostTypeId="2" ParentId="16582" CreationDate="2018-07-02T01:35:19.860" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/lucc/nvimpager&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvimpager&lt;/a&gt; is an alternative solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;export PAGER=nvimpager&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;export MANPAGER=nvimpager&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;git config --global color.pager no&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;git config --global core.pager nvimpager&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5663" LastActivityDate="2018-07-02T01:35:19.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16619" PostTypeId="2" ParentId="16610" CreationDate="2018-07-02T03:02:13.513" Score="4" Body="&lt;p&gt;That would be a pretty straightforward function. I'll cover key parts of it but leave things like validation and error handling to you. For instance, there could be a check for Visual mode not being active or for &lt;code&gt;getline()&lt;/code&gt; not returning any lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! VisualToTable()&#xA;    let l:out = &quot;&quot;&#xA;    let l:idx = 1&#xA;&#xA;    &quot; '&amp;lt; and '&amp;gt; mark begin and end lines of most recent visually selected text.&#xA;    &quot; Using those we get text from visual selection and iterate over the lines.&#xA;    for l:line in getline(line(&quot;'&amp;lt;&quot;), line(&quot;'&amp;gt;&quot;))&#xA;        if l:idx % 2 == 0  &quot; even numbered lines to column 2&#xA;            let l:out .= &quot;\t&quot; . l:line . &quot;\n&quot;&#xA;        else&#xA;            let l:row = l:idx / 2 + 1&#xA;            let l:out .= l:row . &quot;. &quot; . l:line&#xA;        endif&#xA;&#xA;        let l:idx += 1&#xA;    endfor&#xA;&#xA;    if l:idx % 2 == 0&#xA;        &quot; If last col num was 1 we need a closing newline&#xA;        let l:out .= &quot;\n&quot;&#xA;    endif&#xA;&#xA;    return l:out&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This implementation is just building the table up in a string and returning it. The basic call is just &lt;code&gt;:echo VisualToTable()&lt;/code&gt; .. after you've selected some text. That'll print the table.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could put it in a register with &lt;code&gt;:let @x = VisToTable()&lt;/code&gt; and then paste wherever you want with &lt;code&gt;&quot;xp&lt;/code&gt;. If you want the function to actually place the text in the buffer that's something I'll also leave to you.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-07-02T03:37:16.447" LastActivityDate="2018-07-02T03:37:16.447" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16620" PostTypeId="2" ParentId="16610" CreationDate="2018-07-02T09:31:03.793" Score="2" Body="&lt;p&gt;You can easily join the lines with &lt;code&gt;:g[lobal]/^/join&lt;/code&gt;. If you also want to prepend line number, a substitution of the beginning of each line with a &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;sub-replace-expression&lt;/a&gt; calling &lt;code&gt;line('.')&lt;/code&gt; should work. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/join&#xA;:%s/^/\=line('.') . &quot;. &quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes that you want to opreate on all lines in the buffer. If you have other lines you can run &lt;code&gt;global&lt;/code&gt; and &lt;code&gt;substitute&lt;/code&gt; over a range, for example by visually selecting the lines before issuing the commands (and omitting &lt;code&gt;%&lt;/code&gt; from the substitution).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a table of three columns, pass a count to &lt;code&gt;join&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   :g/^/join 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1306" LastEditorUserId="1306" LastEditDate="2018-07-02T19:35:15.703" LastActivityDate="2018-07-02T19:35:15.703" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16621" PostTypeId="2" ParentId="2936" CreationDate="2018-07-02T13:05:10.663" Score="3" Body="&lt;p&gt;The program &lt;a href=&quot;https://github.com/rkitover/vimpager&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimpager&lt;/a&gt; includes a script called &amp;quot;vimcat&amp;quot;.  It can output a file with vim's syntax highlighing converted to ansi escape codes.&lt;/p&gt;&#xA;&lt;p&gt;(Additional self promotion: I wrote a fork for neovim: &lt;a href=&quot;https://github.com/lucc/nvimpager&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvimpager&lt;/a&gt;.  You can use &lt;code&gt;nvimpager -c&lt;/code&gt; to &amp;quot;cat&amp;quot; a file.)&lt;/p&gt;&#xA;" OwnerUserId="18062" LastEditorUserId="18062" LastEditDate="2021-05-18T11:20:16.357" LastActivityDate="2021-05-18T11:20:16.357" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16622" PostTypeId="1" AcceptedAnswerId="24617" CreationDate="2018-07-02T13:19:19.670" Score="17" ViewCount="10375" Body="&lt;p&gt;Being a user of GUI editors (mostly &lt;a href=&quot;https://www.sublimetext.com/&quot; rel=&quot;noreferrer&quot;&gt;Sublime Text&lt;/a&gt;) and one simple CLI editor (&lt;a href=&quot;https://www.nano-editor.org/&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;nano&lt;/code&gt;&lt;/a&gt;), and just having gVim (the GUI version of &lt;code&gt;vim&lt;/code&gt;) installed on my Windows 10, I can't figure out how to adjust this powerful editor to my &lt;a href=&quot;https://en.wikipedia.org/wiki/Pixel_density#Named_pixel_densities&quot; rel=&quot;noreferrer&quot;&gt;HiDPI&lt;/a&gt; (282.42 PPI eXtra High density &lt;a href=&quot;https://www.sven.de/dpi/&quot; rel=&quot;noreferrer&quot;&gt;according to calculator&lt;/a&gt;) display of size 15.6 inches with resolution 3840 x 2160 and scaling set on 250%?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It currently looks like this (scaled down to 40% of taken screenshot to reflect my display scaling, so it only looks blurry to you, but hopefully you get my point) - the text is so small that it is impossible to work with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/I1XZL.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/I1XZL.png&quot; alt=&quot;gVim on HiDPI&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to adjust gVim to my HiDPI display scaling on Windows 10?&lt;/p&gt;&#xA;" OwnerUserId="18061" LastEditorUserId="1841" LastEditDate="2018-07-02T15:06:44.727" LastActivityDate="2021-10-03T16:38:44.730" Title="How to adjust gVim to my HiDPI display scaling on Windows 10?" Tags="|gvim|microsoft-windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16623" PostTypeId="2" ParentId="16622" CreationDate="2018-07-02T13:19:19.670" Score="11" Body="&lt;p&gt;On Windows, the configuration file of gVim is named:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is placed in the installation directory, the default being:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Program Files (x86)\Vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To edit the file you first need to launch some text editor As Administrator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then open the above mentioned file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just add something similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('gui_running')&#xA;  set guifont=Consolas:h10&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the important parts are both:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The name of font, you may choose any suitable font except for the default, which is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fixedsys&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as this font can only be sized to 4 or 5.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;h10&lt;/code&gt; determines its size; in my case 10 is adequate.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="18061" LastActivityDate="2018-07-02T13:19:19.670" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16624" PostTypeId="1" CreationDate="2018-07-02T13:32:32.030" Score="9" ViewCount="2881" Body="&lt;p&gt;&lt;strong&gt;I want to display a file in Neovim with ansi terminal escape codes interpreted.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I created a file which contains ansi escape codes (only colors for now, we can think about others as a bonus):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;echo '\e[31mred\e[m other \e[32mgreen\e[m end' &amp;gt; file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now if I open this file in neovim I can see and edit the escape chars but the colors are not displayed: &lt;code&gt;nvim file&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GbSV3.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GbSV3.png&quot; alt=&quot;nvim plain&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I know about the &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=302&quot; rel=&quot;noreferrer&quot;&gt;AnsiEsc&lt;/a&gt; plugin and it can do the job pretty good: &lt;code&gt;nvim file +AnsiEsc&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WNkah.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WNkah.png&quot; alt=&quot;ansiesc&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;but it misses the point about my color scheme and it is an external plugin. Also it uses syntax groups and these are limited in number and have to be defined manually by the maintainer.  I am not sure if it even can interpret other stuff besides color escape codes.&#xA;&lt;sub&gt;(Edit: I have since reimplemented an advanced version of this approach inside &lt;a href=&quot;https://github.com/lucc/nvimpager&quot; rel=&quot;noreferrer&quot;&gt;Nvimpager&lt;/a&gt; in lua.  It generates the syntax groups dynamically by parsing the input file and can handle many terminal attributes (italics, bold, underline, ...) in addition to colors.  But it suffers from one restriction that is also present in AnsiEsc: It can not know the correct 24bit color of the default terminal colors, so like AnsiEsc it displayes them slightly of.  The code is &lt;a href=&quot;https://github.com/lucc/nvimpager/blob/56136029d710fb89e118227a2051e68fb0fea39f/lua/nvimpager.lua#L345-L593&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.)&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;Obviously the internal &lt;code&gt;:terminal&lt;/code&gt; should solve these restrictions, but if I use &lt;code&gt;:terminal cat file&lt;/code&gt; to view the file it adds extra text at the end and also adds extra empty lines to fill the window: &lt;code&gt;nvim '+term cat file'&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dTG5C.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dTG5C.png&quot; alt=&quot;nvim terminal&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;:terminal&lt;/code&gt; of plain vim does a better job in this regard: &lt;code&gt;vim +'term ++curwin cat file'&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PzaSU.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PzaSU.png&quot; alt=&quot;vim terminal&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It doesn't print extra text at the end of the command output (no message and no empty lines). &lt;em&gt;But then again I want to use neovim :(&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&#xA;Can something as close as possible as the vim version be achieved with neovim's &lt;code&gt;:terminal&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;EDIT: I since came half a step further: If I use &lt;code&gt;nvim '+term tail -f -n +1 file'&lt;/code&gt; the process never terminates (&lt;code&gt;tail -f&lt;/code&gt;) and hence the indicater that neovim normally prints is gone.  I did not see a problem with the running tail process in my use case but it would obviously be nicer if the process was finished.  That's why it is only half a step.  The additional lines at the end are still there:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RZbmL.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RZbmL.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18062" LastEditorUserId="18062" LastEditDate="2021-02-03T08:54:15.703" LastActivityDate="2024-01-06T08:07:40.923" Title="Use :terminal to display file with ansi escape codes" Tags="|neovim|terminal|terminal-buffer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16625" PostTypeId="1" CreationDate="2018-07-02T16:54:56.930" Score="7" ViewCount="1073" Body="&lt;p&gt;I often edit different files in vim, some of which use tabs, and some and different amounts of spaces.  With this, I have not found a combination of &lt;code&gt;set expandtab&lt;/code&gt;, &lt;code&gt;set shiftwidth&lt;/code&gt;, &lt;code&gt;set softtabstop&lt;/code&gt;, and &lt;code&gt;filetype plugin indent on&lt;/code&gt; that fit all use cases.  How does one get vim to automatically apply the correct indentation?  Some graphical editors on Windows including Notepad++ would use whatever indentation was present on the prior line, and would work with files that mixed tabs and spaces at different indentation levels, so I am asking if there is a way to implement this functionality in vim without using external plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;`&lt;/p&gt;&#xA;" OwnerUserId="18067" LastActivityDate="2018-07-03T06:11:32.880" Title="Automatically apply indentation using spaces or tabs" Tags="|vimrc|indentation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16626" PostTypeId="1" CreationDate="2018-07-02T18:25:41.040" Score="2" ViewCount="3120" Body="&lt;p&gt;I'm used to Ubuntu and know how to compile and edit vim. But how can i compile vim with python3 support on windows ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Prefer to do it from the terminal. But i don't mind if i need to do it with miniGW if thats a better option.&lt;/p&gt;&#xA;" OwnerUserId="16591" LastEditorUserId="1292" LastEditDate="2018-08-30T10:37:39.560" LastActivityDate="2018-08-30T10:37:39.560" Title="Compile vim with python3 support in Windows" Tags="|microsoft-windows|compile-vim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16627" PostTypeId="2" ParentId="16625" CreationDate="2018-07-02T18:26:53.527" Score="3" Body="&lt;p&gt;If you want vim to analyze the file and automatically find out how many and which indent chars (tabs, spaces) are used you will have to write some code or find a plugin.  To my knowledge there is no such &quot;automatic detection&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But&lt;/strong&gt; there are some partial solutions that might fit your needs:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Your files could declare modelines.  That's a special line inside the file you are editing that can set some options (like the ones you mention). See &lt;code&gt;:help modeline&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you can find a specific pattern about the indent of you files you could write an autocommand.  For example if all your C files use tabs but all python files use 4 spaces and so on. Eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType c,cpp set noet sw=8&#xA;autocmd FileType python set et sw=4&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;The ftplugin files can do the same but might be cleaner for more complex code. They are files that are sourced whenever the filetype for a buffer is set. See &lt;code&gt;:help ftplugins&lt;/code&gt; and &lt;code&gt;:help ftplugin&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you want to find out where an option was last set use &lt;code&gt;:verbose set OPTION?&lt;/code&gt; (with the question mark!).&lt;/p&gt;&#xA;" OwnerUserId="18062" LastEditorUserId="18062" LastEditDate="2018-07-03T06:11:32.880" LastActivityDate="2018-07-03T06:11:32.880" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16628" PostTypeId="2" ParentId="13219" CreationDate="2018-07-02T21:21:34.300" Score="1" Body="&lt;p&gt;There are some things hidden in the vim docs that can help you.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;read ! your shell command&lt;/code&gt;: read the output of &quot;your shell command&quot; into the current buffer (a tempfile is used to read the data!)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;let data = system('your shell command')&lt;/code&gt;: read data into a vim variable (I did not find any reference to tempfiles in the docs on this). Modern vim and neovim also have asynchronus variants of this.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;set buftype=acwrite&lt;/code&gt;: tell vim that the buffer should only be saved with an autocommand&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;autocmd BufWriteCmd &amp;lt;buffer&amp;gt; your-vim-command&lt;/code&gt;: write the contents of the current buffer by executing &lt;code&gt;:your-vim-command&lt;/code&gt;. This autocommand is triggered when you &lt;code&gt;:write&lt;/code&gt; the file in question. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In addition to the topics from the list above sou should also read about vim's use of tempfiles (&lt;code&gt;help tempfile&lt;/code&gt;) to decide if they are save enough for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a plugin to edit gpg encryped files that might implement some of the features you want (do you want to use gpg encryped files?). Otherwise the code could maybe be inspirational for you to write your own stuff: &lt;a href=&quot;https://github.com/jamessan/vim-gnupg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/jamessan/vim-gnupg&lt;/a&gt; (I know they don't have a readme and such but the plugin is good and actively maintained).&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-02T21:21:34.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16629" PostTypeId="2" ParentId="16617" CreationDate="2018-07-02T21:35:07.703" Score="2" Body="&lt;p&gt;This is something of a &quot;workaround&quot; for my problem, but worth noting, from the Unix &lt;a href=&quot;https://unix.stackexchange.com/questions/453049/suppress-bypass-file-has-changed-errors-when-editing-cifs-samba-files&quot;&gt;afterpost&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;add actimeo=0 to the /etc/fstab line for the cfis mount.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This adds some performance overhead for the Samba mount, but seems to eradicate the timestamp jitter that is freaking Vim out.  Good enough for now...&lt;/p&gt;&#xA;" OwnerUserId="18057" LastActivityDate="2018-07-02T21:35:07.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16631" PostTypeId="2" ParentId="16626" CreationDate="2018-07-03T07:56:51.613" Score="3" Body="&lt;p&gt;You can find the instructions to build Vim on windows in the source file &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/INSTALLpc.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;src/INSTALLpc.txt&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More specifically in the section &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/INSTALLpc.txt#L518-L546&quot; rel=&quot;nofollow noreferrer&quot;&gt;8. Building with Python3 support&lt;/a&gt; you can read:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;8. Building with Python3 support&#xA;================================&#xA;&#xA;For building with MSVC 2008 the &quot;Windows Installer&quot; from www.python.org&#xA;works fine.  Python 3.6 is recommended.&#xA;&#xA;When building, you need to set the following variables at least:&#xA;&#xA;    PYTHON3:         Where Python3 is installed. E.g. C:\Python36&#xA;    DYNAMIC_PYTHON3: Whether dynamic linking is used. Usually, set to yes.&#xA;    PYTHON3_VER:     Python3 version. E.g. 36 for Python 3.6.X.&#xA;&#xA;E.g. When using MSVC (as one line):&#xA;&#xA;    nmake -f Make_mvc.mak&#xA;        PYTHON3=C:\Python36 DYNAMIC_PYTHON3=yes PYTHON3_VER=36&#xA;&#xA;&#xA;When using msys2 and link with Python3 bundled with msys2 (as one line):&#xA;&#xA;    mingw32-make -f Make_ming.mak PYTHON3=c:/msys64/mingw64&#xA;        PYTHON3_HOME=c:/msys64/mingw64&#xA;        PYTHON3INC=-Ic:/msys64/mingw64/include/python3.6m&#xA;        DYNAMIC_PYTHON3=yes&#xA;        PYTHON3_VER=36&#xA;        DYNAMIC_PYTHON3_DLL=libpython3.6m.dll&#xA;        STATIC_STDCPLUS=yes&#xA;&#xA;(This is for 64-bit builds. For 32-bit builds, replace mingw64 with mingw32.)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You may also want to look at the instructions in &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/INSTALL&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;src/INSTALL.txt&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-07-03T07:56:51.613" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16632" PostTypeId="1" AcceptedAnswerId="16633" CreationDate="2018-07-03T09:16:38.643" Score="0" ViewCount="406" Body="&lt;p&gt;On Windows 10, I installed gVim 8.1, so far I have made the following progress to make it &lt;em&gt;usable&lt;/em&gt; for me:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I made changes directly to &lt;code&gt;_vimrc&lt;/code&gt; file, in spite I know there is also a gVim specific configuration file, because I like it in one place.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I downloaded a color theme I really liked, and use it like so (for CLI version, the #3 below should be applied too):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; load Atomified theme downloaded from:&#xA;&quot; http://vimcolors.com/797/atomified/dark&#xA;&quot; https://github.com/Siphalor/vim-atomified&#xA;&#xA;colorscheme atomified&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In CLI version, I found there is a limited number of colors used, this can be remedied with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; switch CLI to full color support&#xA;&#xA;set termguicolors&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I turned on line numbering with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; turn on line numbering&#xA;&#xA;set number&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Regarding the GUI only, I have set:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;to remove toolbar, as it is too small anyways on my HiDPI display, rendering it useless&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;to set proper font and its size for my HiDPI display&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;maximize gVim on startup&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Do the following only if launching GUI VIM&#xA;&#xA;if has('gui_running')&#xA;&#xA;  &quot; remove toolbar, as it is too small anyways on my HiDPI display, rendering it useless&#xA;  set guioptions-=T&#xA;&#xA;  &quot; set proper font and its size for my HiDPI display&#xA;  set guifont=Consolas:h10&#xA;&#xA;  &quot; maximize gVim on startup&#xA;  &quot; use ~x on an English Windows version, other languages see Alt + Spacebar for underlined character in your Close&#xA;  autocmd GUIEnter * simalt ~x&#xA;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Thus far no problem, but once I added the following code to remember and restore open files on startup, it won't maximize fully, and it is also strangely resizing the main window down the startup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Go to last file(s) if invoked without arguments.&#xA;autocmd VimLeave * nested if (!isdirectory($HOME . &quot;/.vim&quot;)) |&#xA;    \ call mkdir($HOME . &quot;/.vim&quot;) |&#xA;    \ endif |&#xA;    \ execute &quot;mksession! &quot; . $HOME . &quot;/.vim/Session.vim&quot;&#xA;&#xA;autocmd VimEnter * nested if argc() == 0 &amp;amp;&amp;amp; filereadable($HOME . &quot;/.vim/Session.vim&quot;) |&#xA;    \ execute &quot;source &quot; . $HOME . &quot;/.vim/Session.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What did I make wrong and how to remedy it?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="18061" LastEditorUserId="18061" LastEditDate="2018-07-04T05:50:00.683" LastActivityDate="2018-10-02T07:01:58.423" Title="Maximizing gVim on Windows 10 while also restoring all open files / tabs" Tags="|buffers|gvim|microsoft-windows|window-management|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16633" PostTypeId="2" ParentId="16632" CreationDate="2018-07-03T09:16:38.643" Score="0" Body="&lt;p&gt;I found working, but completely different code on &lt;a href=&quot;http://vim.wikia.com/wiki/Open_the_last_edited_file&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wiki&lt;/a&gt;, from where I also used the strangely working code in the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I don't fully understand it, I can't tell, if it's alright or not, but from today's testing it passed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Open last active file(s) if VIM is invoked without arguments&#xA;&#xA;&quot; This saves all open files / tabs on close&#xA;autocmd VimLeave * nested let buffernr = bufnr(&quot;$&quot;) |&#xA;    \ let buflist = [] |&#xA;    \ while buffernr &amp;gt; 0 |&#xA;    \ if buflisted(buffernr) |&#xA;    \     let buflist += [ bufname(buffernr) ] |&#xA;    \ endif |&#xA;    \   let buffernr -= 1 |&#xA;    \ endwhile |&#xA;    \ if (!isdirectory($HOME . &quot;/.vim&quot;)) |&#xA;    \ call mkdir($HOME . &quot;/.vim&quot;) |&#xA;    \ endif |&#xA;    \ call writefile(reverse(buflist), $HOME . &quot;/.vim/buflist.txt&quot;)&#xA;&#xA;&#xA;&quot; This restores all open files / tabs on startup&#xA;autocmd VimEnter * nested if argc() == 0 &amp;amp;&amp;amp; filereadable($HOME . &quot;/.vim/buflist.txt&quot;) |&#xA;    \ for line in readfile($HOME . &quot;/.vim/buflist.txt&quot;) |&#xA;    \     if filereadable(line) |&#xA;    \   execute &quot;tabedit &quot; . line |&#xA;    \   set bufhidden=delete |&#xA;    \     endif |&#xA;    \ endfor |&#xA;    \ tabclose 1 |&#xA;    \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18061" LastActivityDate="2018-07-03T09:16:38.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16634" PostTypeId="1" AcceptedAnswerId="16639" CreationDate="2018-07-03T10:05:05.563" Score="0" ViewCount="628" Body="&lt;p&gt;I have the following options set to non-default values, as reported by &lt;code&gt;:redir @+ | :set | @redir end&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Options ---&#xA;autochdir&#xA;cscopetag&#xA;foldcolumn=7&#xA;hlsearch&#xA;lazyredraw&#xA;relativenumber&#xA;sidescroll=1&#xA;tabstop=4&#xA;undofile&#xA;autoindent&#xA;cscopeverbose&#xA;foldlevel=20&#xA;ignorecase&#xA;list&#xA;ruler&#xA;sidescrolloff=10&#xA;tildeop&#xA;virtualedit=block&#xA;autoread&#xA;cursorline&#xA;foldmethod=indent&#xA;incsearch&#xA;mouse=a&#xA;scroll=25&#xA;smartcase&#xA;ttimeout&#xA;whichwrap=b,s,[,]&#xA;background=dark&#xA;diffexpr=MyDiff()&#xA;foldnestmax=6&#xA;langnoremap&#xA;mousemodel=popup&#xA;scrolloff=10&#xA;splitbelow&#xA;ttimeoutlen=100&#xA;wildmenu&#xA;belloff=esc&#xA;display=truncate&#xA;helplang=en&#xA;nolangremap&#xA;nrformats=bin,hex&#xA;shiftwidth=4&#xA;splitright&#xA;ttyfast&#xA;nowrap&#xA;comments=:#&#xA;filetype=zsh&#xA;history=200&#xA;laststatus=2&#xA;number&#xA;showcmd&#xA;syntax=zsh&#xA;ttymouse=xterm2&#xA;backspace=indent,eol,start&#xA;backupdir=~/vim-backup&#xA;commentstring=# %s&#xA;cscopeprg=/usr/bin/cscope&#xA;directory=~/vim-swap&#xA;fileencoding=utf-8&#xA;fileencodings=ucs-bom,utf-8,latin1&#xA;fileformats=unix,dos,mac&#xA;formatoptions=croql&#xA;guicursor=n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block,a:blinkon0&#xA;indentexpr=GetShIndent()&#xA;indentkeys=0{,0},!^F,o,O,e,0=then,0=do,0=else,0=elif,0=fi,0=esac,0=done,0=end,),0=;;,0=;&amp;amp;,0=fin,0=fil,0=fip,0=fir,0=fix&#xA;listchars=tab:⁞…,trail:·,extends:»,precedes:«,nbsp:¬&#xA;statusline=%!airline#statusline(1)&#xA;termencoding=utf-8&#xA;undodir=~/vim-undo&#xA;wildmode=list:longest,full&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;runtimepath&lt;/code&gt; is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim,~/.vim/bundle/argtextobj.vim,~/.vim/bundle/CamelCaseMotion,~/.vim/bundle/csv.vim,~/.vim/bundle/perldoc-vim,~/.vim/bundle/promptline.vim,~/.vim/bundle/vim-abolish,~/.vim/bundle/vim-airline,~/.vim/bundle/vim-airline-themes,~/.vim/bundle/vim-better-whitespace,~/.vim/bundle/vim-capslock,~/.vim/bundle/vim-commentary,~/.vim/bundle/vim-expand-region,~/.vim/bundle/vim-fugitive,~/.vim/bundle/vim-lua,~/.vim/bundle/vim-repeat,~/.vim/bundle/vim-rhubarb,~/.vim/bundle/vim-smartword,~/.vim/bundle/vim-speeddating,~/.vim/bundle/vim-surround,~/.vim/bundle/vim-tasks,~/.vim/bundle/vim-textobj-entire,~/.vim/bundle/vim-textobj-indent,~/.vim/bundle/vim-textobj-line,~/.vim/bundle/vim-textobj-user,~/.vim/bundle/vim-tf2,~/.vim/bundle/vim-unimpaired,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vim80/pack/dist/opt/matchit,/usr/share/vim/vimfiles/after,~/.vim/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I'm using a lot of plugins)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem started after a routine cygwin package update, &lt;em&gt;without&lt;/em&gt; me manually changing any configuration files. After much rage, I've found that apparently the scrollwheel only acts funny when my cursor is in a specific screen region on my terminal emulator (which is ConEmu) - everywhere else, it works as normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this region, scrolling gets various numbers, &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;&amp;lt;&lt;/code&gt;, and &lt;code&gt;&amp;gt;&lt;/code&gt;, with no discernable reason for the difference. I leave my emulator and focus a different window, then return, and the &quot;typed&quot; character may or may not be different. Possibly worth noting is that it doesn't force insert mode, it literally acts as if I had pressed the key in question. Definitely worth noting is that this doesn't happen when I'm in the plain command line.&lt;/p&gt;&#xA;" OwnerUserId="18070" LastEditorUserId="1841" LastEditDate="2018-07-03T13:47:46.923" LastActivityDate="2018-07-04T05:58:23.740" Title="Scroll wheel inserts seemingly-random characters in cygwin vim, depending on where on the screen the mouse cursor is" Tags="|terminal|scrolling|mouse|cygwin|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16635" PostTypeId="1" AcceptedAnswerId="16636" CreationDate="2018-07-03T15:36:54.743" Score="0" ViewCount="1122" Body="&lt;p&gt;I originally just wanted to change the context menu item:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Edit with Vim&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Edit with gVim Easy&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and adjust the respective command appropriately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But since I found out, some &lt;a href=&quot;http://vim.wikia.com/wiki/Adding_Vim_to_MS-Windows_File_Explorer_Menu&quot; rel=&quot;nofollow noreferrer&quot;&gt;DLL is responsible on the Wiki&lt;/a&gt;, I decided to leave the original item in place and create a new, separate one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Requirements to summarize:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;gVim has to be run in Easy mode&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The context menu item should have an icon&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I would like not to define file types, let's make it for all files&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18061" LastActivityDate="2018-10-01T17:00:51.607" Title="How to add &quot;Edit with gVim Easy&quot; context menu item in Windows 10" Tags="|microsoft-windows|installing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16636" PostTypeId="2" ParentId="16635" CreationDate="2018-07-03T15:36:54.743" Score="0" Body="&lt;h1&gt;Before you do this, ensure you have the right path to the executable on your system!&lt;/h1&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It is as easy as saving the following code with minor adjustments for your personal needs into a file with &lt;code&gt;.reg&lt;/code&gt; extension and running it, for this you will need administrator privileges:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Windows Registry Editor Version 5.00&#xA;&#xA;[HKEY_CLASSES_ROOT\*\shell\gVim]&#xA;@=&quot;Edit with &amp;amp;gVim Easy&quot;&#xA;&quot;Icon&quot;=&quot;C:\\Program Files (x86)\\Vim\\vim81\\gvim.exe&quot;&#xA;&#xA;[HKEY_CLASSES_ROOT\*\shell\gVim\command]&#xA;@=&quot;\&quot;C:\\Program Files (x86)\\Vim\\vim81\\gvim.exe\&quot; -y \&quot;%1\&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Parsing&lt;/h1&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;[HKEY_CLASSES_ROOT\*\shell\gVim]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The asterisk (&lt;code&gt;*&lt;/code&gt;) means it applies to all files&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can name it as you wish, I named it &lt;code&gt;gVim&lt;/code&gt;, this won't be visible anywhere&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;@=&quot;Edit with &amp;amp;gVim Easy&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;This on the contrary will be visible in all files' context menu&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can name it as you wish, just add the ampersand (&lt;code&gt;&amp;amp;&lt;/code&gt;) at some place, this will be the context menu keyboard key&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Icon&quot;=&quot;C:\\Program Files (x86)\\Vim\\vim81\\gvim.exe&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is the path to an icon-containing file, which I just wanted there, it is completely optional&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;[HKEY_CLASSES_ROOT\*\shell\gVim\command]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is self-explanatory sub-menu &lt;code&gt;command&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;@=&quot;\&quot;C:\\Program Files (x86)\\Vim\\vim81\\gvim.exe\&quot; -y \&quot;%1\&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Finally the executed command, you may adjust it with or without the easy mode switch (&lt;code&gt;-y&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18061" LastActivityDate="2018-07-03T15:36:54.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16637" PostTypeId="2" ParentId="15651" CreationDate="2018-07-03T18:21:57.163" Score="3" Body="&lt;p&gt;Custom config didn't work for me. So I did this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ find ~/.SpaceVim/ -type f | xargs grep spacevim_relativenumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And found the line in &lt;code&gt;.SpaceVim//autoload/SpaceVim.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:spacevim_relativenumber          = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I changed this setting to &lt;code&gt;0&lt;/code&gt;. It looks like little bit more generic way that can also be applied to other settings.&lt;/p&gt;&#xA;" OwnerUserId="18081" LastEditorUserId="18081" LastEditDate="2018-07-03T18:50:22.697" LastActivityDate="2018-07-03T18:50:22.697" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16638" PostTypeId="1" AcceptedAnswerId="16653" CreationDate="2018-07-04T02:23:06.273" Score="1" ViewCount="605" Body="&lt;p&gt;I have a syntax file with the following definitions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword pythonBuiltinFunc           __import__ abs all any&#xA;                                        \ bin bool bytearray&#xA;                                        \ callable chr classmethod compile complex&#xA;                                        \ delattr dict dir divmod&#xA;                                        \ enumerate eval&#xA;                                        \ filter float format frozenset&#xA;                                        \ getattr globals hasattr hash hex&#xA;                                        \ id input int isinstance issubclass iter&#xA;                                        \ len list locals&#xA;                                        \ map max min next&#xA;                                        \ object oct open ord pow property&#xA;                                        \ range repr reversed round&#xA;                                        \ set setattr slice sorted&#xA;                                        \ staticmethod str sum super&#xA;                                        \ tuple type vars zip&#xA;                                        \ nextgroup=pythonArgs skipwhite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that this matches occurrences of &lt;code&gt;next&lt;/code&gt; (e.g.) even when that name is referenced as an object's attribute, as in &lt;code&gt;obj.next&lt;/code&gt;, and this messes up the highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I might buy that it's useful to not shadow built-in names, I'm not sure that I buy this for bound names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does any one have thoughts on how to apply the above definitions, but exclude the pathological case I mentioned below? I guess I'd be allowing whitespace in the word pattern, but ignoring it in the match?&lt;/p&gt;&#xA;" OwnerUserId="18086" LastActivityDate="2018-07-04T22:13:27.320" Title="vim word boundaries in syntax files" Tags="|syntax-highlighting|regular-expression|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16639" PostTypeId="2" ParentId="16634" CreationDate="2018-07-04T05:47:08.023" Score="1" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nolazyredraw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was looking at your config and that setting caught my eye. The default is &lt;code&gt;false&lt;/code&gt; but you have it enabled. When I enable it in my Cygwin environment and then use the scrollwheel inside a Vim instance launched from within &lt;code&gt;tmux&lt;/code&gt; (a terminal emulator) I see behavior quite similar to what you describe (characters unexpectedly inserted into my buffer). Also, I don't see the problem outside of &lt;code&gt;tmux&lt;/code&gt;...same as you observe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless you have an explicit reason for setting it all the time you'll probably want to remove that setting from your vimrc. (Some folks enable it only when needed. E.g. to improve response time when running a complicated macro.) Otherwise, you'll at least have to find a way to disable it when you're in ConEmu barring someone producing a way to resolve the underlying issue.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-07-04T05:58:23.740" LastActivityDate="2018-07-04T05:58:23.740" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16640" PostTypeId="2" ParentId="16632" CreationDate="2018-07-04T05:47:52.643" Score="0" Body="&lt;p&gt;It seems the &lt;a href=&quot;https://vi.stackexchange.com/a/16633/18061&quot;&gt;original solution&lt;/a&gt; has one or more flaws. I noticed that the saving procedure writes relative paths and / or &lt;strong&gt;only file names&lt;/strong&gt;, which was a big problem, because when then loading the file list, of course it could not find the file(s).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This line is responsible for writing the file paths (names) into &lt;code&gt;buflist.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;\     let buflist += [ bufname(buffernr) ] |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have re-written it, so that it writes full path to the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\     let buflist += [ fnamemodify(bufname(buffernr), ':p') ] |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it so far, after an hour of testing, it works without error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will leave the original solution in place in order for you to be able to compare it, and if possible, revise it even better.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The whole, current, solution follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Open last active file(s) if VIM is invoked without arguments&#xA;&#xA;&quot; This saves the tabs on close&#xA;autocmd VimLeave * nested let buffernr = bufnr(&quot;$&quot;) |&#xA;    \ let buflist = [] |&#xA;    \ while buffernr &amp;gt; 0 |&#xA;    \ if buflisted(buffernr) |&#xA;    \     let buflist += [ fnamemodify(bufname(buffernr), ':p') ] |&#xA;    \ endif |&#xA;    \   let buffernr -= 1 |&#xA;    \ endwhile |&#xA;    \ if (!isdirectory($HOME . &quot;/.vim&quot;)) |&#xA;    \ call mkdir($HOME . &quot;/.vim&quot;) |&#xA;    \ endif |&#xA;    \ call writefile(reverse(buflist), $HOME . &quot;/.vim/buflist.txt&quot;)&#xA;&#xA;&#xA;&quot; This restores the tabs on startup&#xA;autocmd VimEnter * nested if argc() == 0 &amp;amp;&amp;amp; filereadable($HOME . &quot;/.vim/buflist.txt&quot;) |&#xA;    \ for line in readfile($HOME . &quot;/.vim/buflist.txt&quot;) |&#xA;    \     if filereadable(line) |&#xA;    \   execute &quot;tabedit &quot; . line |&#xA;    \   set bufhidden=delete |&#xA;    \     endif |&#xA;    \ endfor |&#xA;    \ tabclose 1 |&#xA;    \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18061" LastActivityDate="2018-07-04T05:47:52.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16641" PostTypeId="2" ParentId="16605" CreationDate="2018-07-04T09:51:48.637" Score="1" Body="&lt;p&gt;Hack-of-concept:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:autocmd CursorMoved * silent exe '!tmux send-keys Escape :' line(&amp;quot;w0&amp;quot;)-16: 'Enter' 'z Enter'&lt;/code&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;hook into &lt;code&gt;CursorMoved&lt;/code&gt; events (vim lacks scroll events; we could &lt;code&gt;map&lt;/code&gt; explicit scrolls commands, like &lt;code&gt;C-e&lt;/code&gt;, &lt;code&gt;C-y&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;get the line at the top of the window &lt;code&gt;line(&amp;quot;w0&amp;quot;)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;tell vim in the tmux session to move one screen higher than that (&lt;code&gt;-16&lt;/code&gt;), by putting the cursor there (&lt;code&gt;Escape :n Enter&lt;/code&gt;, where &lt;code&gt;n&lt;/code&gt; is the line, and tmux accepts special keys by their names, &lt;code&gt;Escape&lt;/code&gt;, &lt;code&gt;Enter&lt;/code&gt;), then scrolling to put the cursor at the top of the screen (&lt;code&gt;z Enter&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;To use this, edit a file in one window - this is where you control it from. In second window, start tmux, then edit the same file (readonly). Enter the above &lt;code&gt;autocmd&lt;/code&gt; in the first window. You can check that vim in the second window is now &amp;quot;remote scrollbound&amp;quot; to the first window.&lt;/p&gt;&#xA;&lt;p&gt;Now, on the other phone, ssh into the first phone, and attach to the tmux session. You will get a duplicate of the second window above. Place this phone above the other phone. BTW here's how I &lt;a href=&quot;https://unix.stackexchange.com/questions/443879/how-to-control-an-interactive-shell-e-g-vim-from-another-machine/444312#444312&quot;&gt;connected androids over bluetooth&lt;/a&gt;, which had lower latency for me.&lt;/p&gt;&#xA;&lt;h3&gt;Results&lt;/h3&gt;&#xA;&lt;p&gt;It works.&lt;/p&gt;&#xA;&lt;p&gt;There's 250ms latency or so before the other window scrolls, but it's OK.&lt;/p&gt;&#xA;&lt;p&gt;There are practical problems, putting one smartphone above another in a secure way. It's important for usability to have the screens at the same angle, to avoid glare from ceiling lights. If the screens are different dimensions, the text won't line up.&lt;/p&gt;&#xA;" OwnerUserId="3189" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-07-07T03:05:34.180" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="16643" PostTypeId="1" AcceptedAnswerId="16655" CreationDate="2018-07-04T11:42:47.833" Score="2" ViewCount="1286" Body="&lt;p&gt;How to check if my &lt;code&gt;.vim/buflist.txt&lt;/code&gt; file is empty or contains whitespace(s) in &lt;code&gt;_vimrc&lt;/code&gt; of my gVim on Windows 10?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let BufferListFile = $HOME . &quot;/.vim/buflist.txt&quot;&#xA;&#xA;echo BufferListFile&#xA;&#xA;&quot; This function SHOULD return true if the defined&#xA;&quot; buffer list file is empty = contains&#xA;&quot; either nothing, or white space&#xA;&quot; but is does not work&#xA;&#xA;function BufferListFileEmpty()&#xA;    return (empty(glob(g:BufferListFile)))&#xA;endfunction&#xA;&#xA;if (BufferListFileEmpty())&#xA;    echo &quot;Empty&quot;&#xA;else&#xA;    echo &quot;Not Empty&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I always get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Not Empty&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;no matter if the file contains literally nothing, what am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="18061" LastActivityDate="2018-07-05T06:42:48.683" Title="How to check if my .vim/buflist.txt file is empty or contains whitespace(s) in _vimrc" Tags="|vimrc|gvim|microsoft-windows|" AnswerCount="3" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16644" PostTypeId="1" CreationDate="2018-07-04T13:32:37.810" Score="1" ViewCount="628" Body="&lt;p&gt;I have both vim and nvim using the same configuration file (basically nvim's config is a symlink to vim's one) but vim shows current column when I press Ctrl-G, while nvim doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some configuration which is enabled by default in vim but not in nvim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the picture below nvim is on top, vim is on bottom.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/nnvjG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nnvjG.png&quot; alt=&quot;nvim is on top, vim is on bottom&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18091" LastActivityDate="2018-07-04T13:41:53.703" Title="Ctrl-G doesn't show column in Nvim" Tags="|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16645" PostTypeId="2" ParentId="16644" CreationDate="2018-07-04T13:41:53.703" Score="2" Body="&lt;p&gt;Setting &lt;code&gt;noruler&lt;/code&gt; makes the trick.&lt;/p&gt;&#xA;" OwnerUserId="18092" LastActivityDate="2018-07-04T13:41:53.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16646" PostTypeId="1" AcceptedAnswerId="16648" CreationDate="2018-07-04T15:10:42.917" Score="1" ViewCount="2470" Body="&lt;p&gt;I'm trying to configure vim for programming in &lt;code&gt;C&lt;/code&gt;. I currently use &lt;code&gt;YouCompleteMe&lt;/code&gt; and &lt;code&gt;Syntastic&lt;/code&gt; for programming auto-completion and syntax-checking. But I came up with a problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot jump to a definition in a header file. I cannot open header file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I installed  &lt;code&gt;sudo apt-get install exuberant-ctags&lt;/code&gt; and generated a tag file as follows &lt;code&gt;ctags -R --exclude=.git .&lt;/code&gt;. But this does not work for headers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you suggest a way to work with headers?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2019-03-06T18:17:31.850" Title="Is there a way to open header file in c?" Tags="|filetype-c++|filetype-c|original-vim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16647" PostTypeId="2" ParentId="16646" CreationDate="2018-07-04T15:36:48.237" Score="1" Body="&lt;p&gt;There is a dedicated plugin for switching to header files:&#xA;&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=31&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.vim.org/scripts/script.php?script_id=31&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-04T15:36:48.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16648" PostTypeId="2" ParentId="16646" CreationDate="2018-07-04T15:49:47.750" Score="1" Body="&lt;p&gt;We need more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Header files aren't supposed to contain function definitions, in C. Function declaration, yes, but definitions, unless they are inlined, no. Could it be related to YCM? YCM isn't able to jump to a function definition that isn't in the same translation unit as the current file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this, you'll need to index the files in your project. ctags is one way to do it. exhuberant-ctags is no longer maintained. For C projects, you shouldn't see any differences. For C++, there is a big one: use the fork: universal-ctags instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I index my C++ projects with a &lt;a href=&quot;https://github.com/LucHermitte/lh-tags/&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin of mine&lt;/a&gt; that takes care of the options &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctags  --tag-relative=yes --c++-kinds=+pf --fields=+imaSft --fields-c++=+{properties} --extras=+q   -f tags -R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you're in C, you should use cscope -- I cannot seriously use it in C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: if you just want to jump from one header file to its implementation file and the other way around, I've &lt;a href=&quot;https://github.com/LucHermitte/alternate-lite/&quot; rel=&quot;nofollow noreferrer&quot;&gt;forked the plugin &lt;em&gt;alternate&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-07-04T15:49:47.750" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="16649" PostTypeId="1" AcceptedAnswerId="16650" CreationDate="2018-07-04T16:04:19.517" Score="1" ViewCount="1076" Body="&lt;p&gt;This is part of my vimrc--&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Abbreviations()&#xA;    let a:code=input(&quot;Which Abbreviation: &quot;)&#xA;&#xA;    &quot;gen&#xA;    if(a:code==&quot;gen&quot;)&#xA;    source ~/.vim/Abbreviations/GeneralAbbreviations.vim&#xA;    endif&#xA;&#xA;    &quot;math&#xA;    if(a:code==&quot;math&quot;)&#xA;    source ~/.vim/Abbreviations/MathAbbreviations.vim&#xA;    endif&#xA;endfunction&#xA;&#xA;&#xA;function! SourceAbbreviations()&#xA;    :execute &quot;:normal! :source $MYVIMRC\&amp;lt;cr&amp;gt;:call Abbreviations()\&amp;lt;cr&amp;gt;gen\&amp;lt;cr&amp;gt;:call Abbreviations()\&amp;lt;cr&amp;gt;math\&amp;lt;cr&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;localleader&amp;gt;e :call SourceAbbreviations()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see the function &lt;code&gt;SourceAbbreviations()&lt;/code&gt; has to call other functions. When I do &lt;code&gt;:call SourceAbbreviations()&lt;/code&gt; it shows an error. However, if I remove &lt;code&gt;:source $MYVIMRC\&amp;lt;cr&amp;gt;&lt;/code&gt; from the function &lt;code&gt;SourceAbbreviations()&lt;/code&gt;, it works. So, what's actually wrong in this case?&lt;/p&gt;&#xA;" OwnerUserId="16884" LastActivityDate="2018-07-04T21:46:17.843" Title="How to source .vimrc inside a function in .vimrc?" Tags="|vimrc|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16650" PostTypeId="2" ParentId="16649" CreationDate="2018-07-04T21:46:17.843" Score="2" Body="&lt;p&gt;I would advise you to do the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First change the function &lt;code&gt;Abbreviations()&lt;/code&gt; to accept an argument and maybe not use the interactive mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Abbreviations(code)&#xA;  if a:code != 'gen' &amp;amp;&amp;amp; a:code != 'math'&#xA;    let l:code = input(&quot;Which Abbreviation: &quot;)&#xA;  else&#xA;    let l:code = a:code&#xA;  endif&#xA;  if l:code == &quot;gen&quot;&#xA;    source ~/.vim/Abbreviations/GeneralAbbreviations.vim&#xA;  endif&#xA;  if l:code == &quot;math&quot;&#xA;    source ~/.vim/Abbreviations/MathAbbreviations.vim&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can &lt;code&gt;:call Abbreviations(&quot;gen&quot;)&lt;/code&gt; or &lt;code&gt;:call Abbreviations(&quot;math&quot;)&lt;/code&gt; or &lt;code&gt;:call Abbreviations(&quot;&quot;)&lt;/code&gt; to get the old behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second simplify the function &lt;code&gt;SourceAbbreviations()&lt;/code&gt; like so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SourceAbbreviations()&#xA;  execute &quot;source&quot; $MYVIMRC&#xA;  call Abbreviations(&quot;gen&quot;)&#xA;  call Abbreviations(&quot;math&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if you are really keen on using your complex &lt;code&gt;:execute&lt;/code&gt; command you should take &lt;code&gt;$MYVIMRC&lt;/code&gt; out of the string as this is vimscript and not shell. So write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;:normal! :source &quot; . $MYVIMRC . &quot;\&amp;lt;cr&amp;gt;:call Abbreviations()\&amp;lt;cr&amp;gt;gen\&amp;lt;cr&amp;gt;:call Abbreviations()\&amp;lt;cr&amp;gt;math\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to understand this compare these two&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo $MYVIMRC&#xA;echo &quot;$MYVIMRC&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-04T21:46:17.843" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16651" PostTypeId="1" AcceptedAnswerId="17557" CreationDate="2018-07-04T21:51:00.550" Score="4" ViewCount="566" Body="&lt;p&gt;When the cursor is over a word that has multiple matches according to &lt;code&gt;ctags&lt;/code&gt;, the &lt;kbd&gt;Ctrl-]&lt;/kbd&gt; command on one machine I use gives me a list of matches to choose from, while on another it just populates the tag stack and takes me to the first match. I prefer the first behavior, because it lets me see up front how many matches there are and lets me jump into the middle of the list if the first match is not what I'm looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make Vim on the second machine default to the behavior of Vim on the first machine?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've diffed the &lt;code&gt;~/.vimrc&lt;/code&gt; between the two machines, and I don't see any customization differences that can account for the difference in behavior.&lt;/p&gt;&#xA;" OwnerUserId="6852" LastActivityDate="2018-10-02T23:16:50.373" Title="Make Ctrl-] give a list of matches to choose from instead of taking me to the first match" Tags="|key-bindings|tags|list|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16652" PostTypeId="2" ParentId="16651" CreationDate="2018-07-04T21:51:00.550" Score="2" Body="&lt;p&gt;You can map the &lt;kbd&gt;Ctrl-]&lt;/kbd&gt; command so that it uses the &lt;code&gt;:tselect&lt;/code&gt; command instead of &lt;code&gt;:tag&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap &amp;lt;C-]&amp;gt; :execute &quot;:tselect &quot; . expand(&quot;&amp;lt;cword&amp;gt;&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6852" LastActivityDate="2018-07-04T21:51:00.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16653" PostTypeId="2" ParentId="16638" CreationDate="2018-07-04T22:07:58.103" Score="1" Body="&lt;p&gt;You should use syn match instead of syn keyword for this kind of things:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match pythonBuiltinFunc &quot;\&amp;lt;next\&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For syn keyword, from syntax.txt:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It can only contain keyword characters, according to the 'iskeyword' option. It cannot contain other syntax items. It will only match with a complete word (there are no keyword characters before or after the match). The keyword &quot;if&quot; would match in &quot;if(a=b)&quot;, but not in &quot;ifdef x&quot;, because &quot;(&quot; is not a keyword character and &quot;d&quot; is.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="13084" LastEditorUserId="13084" LastEditDate="2018-07-04T22:13:27.320" LastActivityDate="2018-07-04T22:13:27.320" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16654" PostTypeId="2" ParentId="16643" CreationDate="2018-07-05T05:13:50.983" Score="1" Body="&lt;p&gt;I found the manual:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help empty&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;empty({expr})                                           empty()&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Return the Number 1 if {expr} is empty, zero otherwise.&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;A List or Dictionary is empty when it does not have any items.&lt;/li&gt;&#xA;  &lt;li&gt;A String is empty when its length is zero.&lt;/li&gt;&#xA;  &lt;li&gt;A Number and Float is empty when its value is zero.&lt;/li&gt;&#xA;  &lt;li&gt;v:false, v:none and v:null are empty, v:true is not.&lt;/li&gt;&#xA;  &lt;li&gt;A Job is empty when it failed to start.&lt;/li&gt;&#xA;  &lt;li&gt;A Channel is empty when it is closed.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;For a long List this is much faster than comparing the length with zero.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, it does not work, because &lt;code&gt;empty&lt;/code&gt; does not check the file contents at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;Still, I have not figured out, as to how to do this, if even possible.&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I am now able to determine if the file is completely empty with the following code, I structured it to functions, because they might be handy. This does not solve the problem of whitespace(s) in the buffer list file. So, I will be testing the other solution posted. And if working, accepting it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This defines the name and path of my buffer list file&#xA;let BufferListFile = $HOME . &quot;/.vim/buflist.txt&quot;&#xA;&#xA;&#xA;&quot; This function returns true if the defined&#xA;&quot; buffer list file exists&#xA;&quot; No matter if it is readable by the user&#xA;&quot; Gotten from https://stackoverflow.com/a/23496813/1997354&#xA;&quot; Needs verification&#xA;function BufferListFileExists()&#xA;    return (!empty(glob(g:BufferListFile)))&#xA;endfunction&#xA;&#xA;&#xA;&quot; This function returns true if the defined&#xA;&quot; buffer list file is readable by the user&#xA;function BufferListFileReadable()&#xA;    return (filereadable(g:BufferListFile))&#xA;endfunction&#xA;&#xA;&#xA;&quot; This function returns true if the defined&#xA;&quot; buffer list file is completely empty&#xA;function BufferListFileEmpty()&#xA;    return (getfsize(g:BufferListFile) == 0)&#xA;endfunction&#xA;&#xA;&#xA;&quot; Debugging&#xA;echom BufferListFileExists()&#xA;echom BufferListFileReadable()&#xA;echom BufferListFileEmpty()&#xA;&#xA;&#xA;if (BufferListFileExists() &amp;amp;&amp;amp; BufferListFileReadable() &amp;amp;&amp;amp; BufferListFileEmpty())&#xA;    echo &quot;Empty&quot;&#xA;else&#xA;    echo &quot;NotEmpty&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18061" LastEditorUserId="18061" LastEditDate="2018-07-05T06:42:48.683" LastActivityDate="2018-07-05T06:42:48.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16655" PostTypeId="2" ParentId="16643" CreationDate="2018-07-05T06:09:00.717" Score="5" Body="&lt;p&gt;As you found out you are only working with the file name. In order to check the &lt;em&gt;contents&lt;/em&gt; of the file you can use &lt;code&gt;readfile()&lt;/code&gt;. It will return a list with all the lines from the file. You can then iterate through the lines in a &lt;code&gt;:for&lt;/code&gt; loop and check for whatever you want.  Or you can filter the list items with &lt;code&gt;filter()&lt;/code&gt;. But I think the fastest way is to use &lt;code&gt;match()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BufferListEmpty()&#xA;  let BufferListFile = $HOME . &quot;/.vim/buflist.txt&quot;&#xA;  let lines = readfile(BufferListFile)    &quot; read the file *contents* into a list&#xA;  let matched_index = match(lines, '\S')  &quot; find the first entry with a non-space&#xA;  return matched_index == -1              &quot; if no match was found -1 was returned&#xA;endfunction&#xA;if BufferListEmpty()&#xA;  echo &quot;Empty&quot;&#xA;else&#xA;  echo &quot;Not&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might want to read these help topics:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;help readfile()&#xA;help match()&#xA;help filter()&#xA;help :for&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-05T06:09:00.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16656" PostTypeId="2" ParentId="16643" CreationDate="2018-07-05T06:11:57.113" Score="1" Body="&lt;p&gt;You can get the size of the file using &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getfsize%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getfsize()&lt;/code&gt;&lt;/a&gt;, but to check if it has whitespace in it, you'll either have to read the file in Vim, or use an external command (like &lt;code&gt;grep&lt;/code&gt;, or Windows' &lt;code&gt;find&lt;/code&gt;). Since you have to read the file anyway for the whitespace check anyway, you could perform both checks like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let BufferListFileContents = readfile(BufferListFile)&#xA;let BufferListFileIsEmpty = empty(BufferListFileContents)&#xA;let BufferListFileIsWS = ! empty(filter(BufferListFileContents, 'v:val =~ &quot;\\S&quot;')) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where the last line filters out lines containing only whitespace, and then checks if the result list is not empty.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-07-05T06:11:57.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16657" PostTypeId="2" ParentId="8835" CreationDate="2018-07-05T06:28:50.467" Score="1" Body="&lt;p&gt;I appreciate the answer provided by Christian Brabandt but I think a better answer would be to separate the quit command using another -c command like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c ':set t_ti= t_te= nomore' -c 'scriptnames' -c 'q!' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using this method means that you could string together a number of different commands together and then use the final 'q!' to exit out of vim. &lt;/p&gt;&#xA;" OwnerUserId="7226" LastEditorUserId="205" LastEditDate="2018-07-22T01:41:51.820" LastActivityDate="2018-07-22T01:41:51.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16658" PostTypeId="1" AcceptedAnswerId="16659" CreationDate="2018-07-05T09:20:05.470" Score="1" ViewCount="697" Body="&lt;p&gt;Because on Linux, there is possible that file exists but is not readable by the user (I rather don't think it is feasible on Windows, but...), I seek for VimL functions to differentiate between those two states, which I could put into my &lt;code&gt;_vimrc&lt;/code&gt; of my gVim.&lt;/p&gt;&#xA;" OwnerUserId="18061" LastActivityDate="2018-10-04T09:00:29.910" Title="VimL functions to differentiate between File Exists and File Readable" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16659" PostTypeId="2" ParentId="16658" CreationDate="2018-07-05T09:20:05.470" Score="1" Body="&lt;p&gt;I tried to write these functions myself, but feel free to correct me in your own answer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This defines the name and path of my buffer list file&#xA;&quot; For I am on Windows, I can use \\, i.e. escaping&#xA;&quot; But it is not necessary and also non-portable&#xA;&#xA;let BufferListFile = $HOME . &quot;/.vim/buflist.txt&quot;&#xA;&#xA;&quot;-----------------------------------------------------------------------------&#xA;&#xA;&quot; This function returns true if the defined file exists&#xA;&quot; No matter if it is readable by the user&#xA;&quot; Gotten from https://stackoverflow.com/a/23496813/1997354&#xA;&#xA;function FileExists(FileName)&#xA;&#xA;    return !empty(glob(a:FileName))&#xA;&#xA;endfunction&#xA;&#xA;&quot;-----------------------------------------------------------------------------&#xA;&#xA;&quot; This function returns true if the defined file&#xA;&quot; is readable by the user&#xA;&quot; There is no reason to define the function myself&#xA;&quot; as there already is the following built-in function&#xA;&#xA;&quot; filereadable()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18061" LastEditorUserId="18061" LastEditDate="2018-07-06T07:17:35.597" LastActivityDate="2018-07-06T07:17:35.597" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16660" PostTypeId="1" AcceptedAnswerId="16661" CreationDate="2018-07-05T11:43:34.257" Score="1" ViewCount="282" Body="&lt;p&gt;I'm trying to cerate a function who toggle a block of code into comments. I did this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Commenting blocks of code.&#xA;filetype on&#xA;augroup commentgroup&#xA;  autocmd FileType c,cpp,java,scala let b:comment_leader = '//'&#xA;  autocmd FileType sh,ruby,python   let b:comment_leader = '#'&#xA;  autocmd FileType conf,fstab       let b:comment_leader = '#'&#xA;  autocmd FileType tex              let b:comment_leader = '%'&#xA;  autocmd FileType mail             let b:comment_leader = '&amp;gt;'&#xA;  autocmd FileType vim              let b:comment_leader = '&quot;'&#xA;augroup END&#xA;&#xA;fun! TestFunc()&#xA;  if (synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 0), &quot;name&quot;) =~ 'comment\c')&#xA;    exe ':s/^'escape(b:comment_leader,'\/')'//e'&#xA;  else&#xA;    exe ':s/^/'escape(b:comment_leader,'\/')'/e'&#xA;  endif&#xA;endfun&#xA;map &amp;lt;C-t&amp;gt; :call TestFunc() &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's inspired from &lt;a href=&quot;https://stackoverflow.com/a/23063140/3616601&quot;&gt;this answer&lt;/a&gt; to get the comment character depending the file type, and &lt;a href=&quot;https://vi.stackexchange.com/a/8130&quot;&gt;this answer&lt;/a&gt; to get the condition who permit to know if we are in a commented line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, it add spaces around the &lt;code&gt;escape(...)&lt;/code&gt; part, and in &lt;code&gt;C&lt;/code&gt; language if the &lt;code&gt;//&lt;/code&gt; is not at the first column, it's not considered as commented. So, this function is always commenting, and never uncommenting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought to use a variable like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let var=escape(b:comment_leader,'\/')&#xA;exe ':s/^/var/e'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it's considered as text, not as a variable. And I don't know if we can use a variable in a command like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there a way to achieve what I'm trying to do ?&lt;/p&gt;&#xA;" OwnerUserId="18102" LastActivityDate="2018-07-05T12:09:31.650" Title="Toggle comments" Tags="|vimscript|comments|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16661" PostTypeId="2" ParentId="16660" CreationDate="2018-07-05T12:09:31.650" Score="2" Body="&lt;p&gt;There are several things to consider, so I'll try to provide an answer first and then elaborate on various choices you have at your disposal instead of doing this yourself in this crude manner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution to embedding your variable within your command while using &lt;code&gt;exec&lt;/code&gt; is straight forward, you can do this for the same :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec ':s/^/' . var . '/e'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should be fairly straight forward to understand what's going on, essentially we're just concatenating strings to form the actual command that we want to execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now with regards to how you've chosen to get this done I have a few pointers to add :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You should look up a few vim options that are at your disposal to get information with regards to how commenting works in the current filetype, which will enable you to avoid hard coding the comment characters the way you're doing right now. The options being : &lt;code&gt;commentstring&lt;/code&gt;, &lt;code&gt;comments&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You can leverage existing solutions in place of building your own, again for the reason as they would add support for a wider variety of programming languages etc out of the box, making your life easier. The one I would recommend being &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tpope/vim-commentary&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="74" LastActivityDate="2018-07-05T12:09:31.650" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16662" PostTypeId="1" AcceptedAnswerId="16666" CreationDate="2018-07-06T01:22:49.677" Score="0" ViewCount="3300" Body="&lt;p&gt;I run Neovim on tmux on iTerm2, but now I'm struggling to change the color of my Python code. I use python-mode library to change the syntax of the Python code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, many colors I try to set got me the error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Color name or number not recognized: ctermfg=DarkSeaGreen3&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;DarkSeaGreen3&lt;/code&gt; color is available according to &lt;a href=&quot;https://codeyarns.com/2011/07/29/vim-chart-of-color-names/&quot; rel=&quot;nofollow noreferrer&quot;&gt;the following website&lt;/a&gt;, but in my case it does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;$TERM&lt;/code&gt; is &lt;code&gt;xterm-256color&lt;/code&gt; and I set the following to my vim init script.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;syntax on&#xA;set t_Co=256&#xA;set background=dark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I make the color working on my vim? &lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2018-07-10T00:22:13.927" Title="How can I enable the 256 colors on Vim?" Tags="|vimrc|neovim|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16663" PostTypeId="1" CreationDate="2018-07-06T01:30:29.110" Score="0" ViewCount="1048" Body="&lt;p&gt;I want to  alter existing files automatically,to replace all tab with four blanks in existing file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim .gvimrc&#xA;autocmd BufRead  *  exec &quot;%s/\t/    /g&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error info pop up when to open a file without tab key in it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing BufRead Auto commands for &quot;*&quot;:&#xA;E486: Pattern not found: ^I&#xA;E486: Pattern not found: ^t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to suppress the error info ?&lt;br&gt;&#xA;Issue remain according to Naumann's answer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead  *  %s/\t/   /ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please watch the avi.&lt;br&gt;&#xA;&lt;a href=&quot;https://www.dropbox.com/s/uroznee7q1m567z/out.avi&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue remain&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="5181" LastEditDate="2018-07-07T02:17:47.980" LastActivityDate="2019-12-20T12:37:39.523" Title="How to suppress the error {Error detected while processing BufRead Auto commands for &quot;*&quot;}" Tags="|replace|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16664" PostTypeId="2" ParentId="16663" CreationDate="2018-07-06T01:56:25.383" Score="1" Body="&lt;p&gt;First: you don't need &lt;code&gt;exec&lt;/code&gt; here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;/e&lt;/code&gt; flag to avoid error messages, as in &lt;code&gt;autocmd BufRead  *  %s/\t/   /ge&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This flag is described in &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3As_e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :s_e&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="6698" LastEditDate="2019-12-20T12:37:39.523" LastActivityDate="2019-12-20T12:37:39.523" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16666" PostTypeId="2" ParentId="16662" CreationDate="2018-07-06T06:40:11.520" Score="3" Body="&lt;p&gt;That list is not proof that you have one particular color or another. Color availability is highly dependent on environment. If you follow the &lt;a href=&quot;http://vim.wikia.com/wiki/View_all_colors_available_to_gvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;link provided on that page&lt;/a&gt; you'll find scripts that allow you to generate your own list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said &lt;code&gt;ctermfg&lt;/code&gt; is for setting colors for &lt;em&gt;consoles&lt;/em&gt; which invariably can display just a fraction of the number of colors that are available to GUIs. It's unlikely that your console has a color mapped to &quot;DarkSeaGreen3&quot;. If you use gvim, on the other hand, then &lt;code&gt;guifg=DarkSeaGreen3&lt;/code&gt; will likely work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did that &lt;code&gt;ctermfg&lt;/code&gt; line come from a third party file, e.g. a color scheme, or is it just something you tried? If the former I suggest you find some schemes that are portable/console-friendly. (FYI, I have a handful of color schemes that reference DarkSeaGreen3 but none of them attempt to use it with the console.) If, on the other hand, you just entered that line yourself then rest assured that it won't work for a lot of other people either (including myself...same error message).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also &lt;code&gt;:h :colo&lt;/code&gt;, &lt;code&gt;:h highlight-args&lt;/code&gt;, &lt;code&gt;:h highlight-ctermfg&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-07-10T00:22:13.927" LastActivityDate="2018-07-10T00:22:13.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16668" PostTypeId="1" CreationDate="2018-07-06T10:57:53.180" Score="2" ViewCount="3419" Body="&lt;p&gt;I pulled all the source files, and then ran the following command to configure and tried to build vim with GUI support:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/configure --enable-gui=auto&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is some more information:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;checking --enable-gui argument... yes/auto - automatic GUI support&#xA;checking whether or not to look for GTK+ 2... yes&#xA;checking --disable-gtktest argument... gtk test enabled&#xA;checking for location of Motif GUI includes... &amp;lt;not found&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the vim I compiled still doesn't support GUI.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version&#xA;VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul  6 2018 16:24:24)&#xA;Included patches: 1-155&#xA;Compiled by coeus@debian9&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using Debian Stretch. Can anyone help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to follow up with INSTALL file, but it seems it doesn't work, and there are no error messages mentioning the GUI is not compiled... Very strange.&lt;/p&gt;&#xA;" OwnerUserId="18115" LastEditorUserId="1841" LastEditDate="2018-07-06T11:25:45.283" LastActivityDate="2018-11-04T15:00:04.687" Title="How to build vim GUI version with GTK" Tags="|compile-vim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16670" PostTypeId="1" AcceptedAnswerId="16673" CreationDate="2018-07-06T15:01:26.053" Score="1" ViewCount="916" Body="&lt;p&gt;I want to change the key mapping when I run CtrlP. For example, if I press &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;p&lt;/kbd&gt; to run CtrlP, type in something, and try to move the cursor to choose a file, I want to use &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt; to move down, and &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;k&lt;/kbd&gt; to move up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? How can I change the key mapping in the CtrlP window? &lt;/p&gt;&#xA;" OwnerUserId="1072" LastEditorUserId="18062" LastEditDate="2018-07-06T16:57:32.933" LastActivityDate="2018-07-06T16:57:32.933" Title="How can I change the cursor moving on ctrlp?" Tags="|key-bindings|neovim|plugin-ctrlp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16671" PostTypeId="1" CreationDate="2018-07-06T15:46:19.463" Score="0" ViewCount="325" Body="&lt;p&gt;I am compiling Vim on Linux (18.04 Ubuntu) on a new environment and I am experiencing an issue with a lot of my vimrc configuration, which has some inline python logic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically the python code just errors like this: &lt;code&gt;NameError: name 'vim' is not defined&lt;/code&gt;. My understanding is that the python integrated to vim automatically has the ability to import &lt;code&gt;vim&lt;/code&gt;, and it should &lt;em&gt;just work&lt;/em&gt;. Indeed &lt;code&gt;echo has('python')&lt;/code&gt; definitely returns 1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've confirmed that: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;package provided vim (which never has lua compiled in! argh!) works right. &lt;/li&gt;&#xA;&lt;li&gt;my compiled vim has the python issues, regardless of if I compile just python2, both python2 and python3, specify the x86_64-linux-gnu config path or not (and have the compiled vim report &lt;code&gt;python/dyn&lt;/code&gt; or &lt;code&gt;python&lt;/code&gt;). It never works. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;At this point I don't even care if I can find a properly compiled package of Vim that has everything I need in it. At this point now I need to get to the bottom what I am configuring wrong for the compilation.&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="51" LastEditDate="2018-08-22T17:01:09.330" LastActivityDate="2018-08-22T17:01:09.330" Title="Python integration not working as usual" Tags="|vimscript-python|compile-vim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16672" PostTypeId="2" ParentId="16671" CreationDate="2018-07-06T15:51:39.700" Score="1" Body="&lt;p&gt;This is really strange. Basically: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;in my compiled vims, as long as I run &lt;code&gt;py import vim&lt;/code&gt;, &lt;code&gt;vim&lt;/code&gt; becomes defined thereafter and everything works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I can probably just add this statement in my vimrc and move on with my life.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There must be some undocumented compile or config flag that makes this happen automatically by default or something.&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="51" LastEditDate="2018-07-09T15:01:45.590" LastActivityDate="2018-07-09T15:01:45.590" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16673" PostTypeId="2" ParentId="16670" CreationDate="2018-07-06T16:31:40.530" Score="1" Body="&lt;p&gt;You can use the dictonary variable &lt;code&gt;g:ctrlp_prompt_mappings&lt;/code&gt; that is read by CtrlP.  You just need to specify the keys you want to change. Read &lt;code&gt;:h g:ctrlp_prompt_mappings&lt;/code&gt; for more info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to get what you describe in your question try this in your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_prompt_mappings = {&#xA;  \ 'PrtSelectMove(&quot;j&quot;)':   ['&amp;lt;c-j&amp;gt;', '&amp;lt;down&amp;gt;'],&#xA;  \ 'PrtSelectMove(&quot;k&quot;)':   ['&amp;lt;c-k&amp;gt;', '&amp;lt;up&amp;gt;'],&#xA;  \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that is already the default. Maybe you want to switch j and k (did I misread your question?) so you can try it the other way round if you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_prompt_mappings = {&#xA;  \ 'PrtSelectMove(&quot;j&quot;)':   ['&amp;lt;c-k&amp;gt;', '&amp;lt;down&amp;gt;'],&#xA;  \ 'PrtSelectMove(&quot;k&quot;)':   ['&amp;lt;c-j&amp;gt;', '&amp;lt;up&amp;gt;'],&#xA;  \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-06T16:31:40.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16674" PostTypeId="2" ParentId="9543" CreationDate="2018-07-06T17:48:47.603" Score="3" Body="&lt;p&gt;I enable folding in markdown files by using the following in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod = manual&#xA;set foldcolumn = 1&#xA;highlight Folded ctermbg = NONE&#xA;highlight FoldColumn ctermbg = NONE&#xA;let g:markdown_folding = 1&#xA;let g:markdown_enable_folding = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet, folding was failing with the message &quot;no folding found&quot; until I removed the &lt;code&gt;vimwiki&lt;/code&gt; plugin.&lt;/p&gt;&#xA;" OwnerUserId="18119" LastActivityDate="2018-07-06T17:48:47.603" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16675" PostTypeId="1" CreationDate="2018-07-06T22:06:15.997" Score="2" ViewCount="4401" Body="&lt;p&gt;Similar to &lt;a href=&quot;https://vi.stackexchange.com/questions/16670/how-can-i-change-the-cursor-moving-on-ctrlp&quot;&gt;the question about ctrlp&lt;/a&gt;, I would like to know how to change the key remapping to move the cursor on fzf library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, only the ctrl + k works to move the cursor upward, but all the downside movement does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I define the key remapping?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2020-01-06T14:01:40.210" Title="How can I change the cursor moving on fzf?" Tags="|key-bindings|plugin-fzf|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16677" PostTypeId="2" ParentId="16575" CreationDate="2018-07-07T00:22:52.877" Score="4" Body="&lt;p&gt;I found an email discussion about the same topic: &lt;a href=&quot;http://vim.1045645.n5.nabble.com/convert-syntax-highlighted-text-to-RTF-td1177362.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.1045645.n5.nabble.com/convert-syntax-highlighted-text-to-RTF-td1177362.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;They also suggest &lt;code&gt;:TOhtml&lt;/code&gt; and also an alternative plugin to convert to html. And then they suggest &lt;a href=&quot;http://pandoc.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;pandoc&lt;/a&gt; to convert html → rtf.&lt;/p&gt;&#xA;&lt;p&gt;And also found a vim plugin that claims to export to rtf (OS X only): &lt;a href=&quot;https://github.com/zerowidth/vim-copy-as-rtf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/zerowidth/vim-copy-as-rtf&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It has been forked for Windows and Linux support too: &lt;a href=&quot;https://github.com/adah1972/vim-copy-as-rtf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/adah1972/vim-copy-as-rtf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18062" LastEditorUserId="12266" LastEditDate="2020-12-01T17:05:15.913" LastActivityDate="2020-12-01T17:05:15.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16678" PostTypeId="2" ParentId="16663" CreationDate="2018-07-07T00:35:54.277" Score="1" Body="&lt;p&gt;If you want to replace tabs with spaces in your file you could also use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:retab&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:retab&lt;/code&gt;&lt;/a&gt;.  It also depends on the options &lt;code&gt;'et'&lt;/code&gt; and &lt;code&gt;'ts'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage should be that you do not replace every tab with four spaces but only so many as are needed to fill the width of &lt;code&gt;'ts'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-07T00:35:54.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16680" PostTypeId="1" AcceptedAnswerId="16681" CreationDate="2018-07-07T05:37:11.317" Score="1" ViewCount="454" Body="&lt;p&gt;Suppose we do the following steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Visually select something&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;:some stuff&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;press escape&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;when we do the last step, the command mode is exited but also we are left in normal mode - not visual mode. How do I make Vim go back to visual mode with the current selection when pressing escape?&lt;/p&gt;&#xA;" OwnerUserId="11136" LastActivityDate="2018-07-07T06:44:28.723" Title="Stay in visual mode when in command mode and pressing escape" Tags="|command-line|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16681" PostTypeId="2" ParentId="16680" CreationDate="2018-07-07T06:19:11.827" Score="1" Body="&lt;p&gt;You can go back to the previous selection with &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;. So after you type &lt;kbd&gt;esc&lt;/kbd&gt; you can type &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; and the old selection is active again. (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html#gv&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;gv&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this automatically is a little difficult. I did not find a full working solution right away. My basic idea was to map &lt;kbd&gt;esc&lt;/kbd&gt; in command mode (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:cnoremap&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:cnoremap&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A plain &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;esc&amp;gt; &amp;lt;esc&amp;gt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does not really work well as it is &lt;em&gt;always&lt;/em&gt; used the pressing &lt;kbd&gt;esc&lt;/kbd&gt; in the command line. But I think it should only activate the last selection when you entered the command line from visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I thought about an expression mapping (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:map-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:map-expression&lt;/code&gt;&lt;/a&gt;).  But if I use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#mode()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;mode()&lt;/code&gt;&lt;/a&gt; like this it obviously doesn't work as we are always in command mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;esc&amp;gt; mode()=='v' ? &quot;\&amp;lt;esc&amp;gt;gv&quot; : &quot;\&amp;lt;esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if we can save the information that we have been in visual mode when pressing &lt;kbd&gt;:&lt;/kbd&gt; in the first place we can use it to do the right thing when pressing &lt;kbd&gt;esc&lt;/kbd&gt; later.  For this we need two functions and two mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:was_visual = 0&#xA;function! EnterCommandLineFromVisualMode()&#xA;  let s:was_visual = 1&#xA;  return ':'&#xA;endfunction&#xA;function! HandleEscapeInCommandLine()&#xA;  if s:was_visual&#xA;    let s:was_visual = 0&#xA;    return &quot;\&amp;lt;esc&amp;gt;gv&quot;&#xA;  endif&#xA;  return &quot;\&amp;lt;esc&amp;gt;&quot;&#xA;endfunction&#xA;vnoremap &amp;lt;expr&amp;gt; : EnterCommandLineFromVisualMode()&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;esc&amp;gt; HandleEscapeInCommandLine()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put this code into your vimrc or a new file in the plugin directory and it should work.  The result might be inconsistent when you press &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt; in the command line though as the &lt;code&gt;s:was_visual&lt;/code&gt; variable will not get updated. You will need an extra &lt;code&gt;cmap&lt;/code&gt; for this. Maybe there are other corner cases like this that I did not think of right now.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-07T06:19:11.827" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16683" PostTypeId="2" ParentId="16668" CreationDate="2018-07-07T11:44:03.843" Score="1" Body="&lt;p&gt;I assume that you don't have the needed libraries installed on your system to build a gui.  If you read the file &lt;a href=&quot;https://github.com/vim/vim/blob/master/src/INSTALL#L88-L134&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;src/INSTALL&lt;/code&gt;&lt;/a&gt; it explains the different &lt;code&gt;--enable-gui&lt;/code&gt; options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example for me I could run &lt;code&gt;./configure --enable-gui=kde &amp;amp;&amp;amp; make&lt;/code&gt; just fine but the resulting vim did not have a gui. When I checked &lt;code&gt;./configure --enable-gui=kde | grep gui&lt;/code&gt; I found that &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;checking --enable-gui argument... Sorry, kde GUI is not supported&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Only when I ran &lt;code&gt;./configure --enable-gui=gtk2 --with-features=huge &amp;amp;&amp;amp; make &amp;amp;&amp;amp; src/vim -g&lt;/code&gt; it worked properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bottom line:&lt;/strong&gt; check the output of the configure script and find out if you have the needed libs.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-07T11:44:03.843" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16684" PostTypeId="1" AcceptedAnswerId="16762" CreationDate="2018-07-07T12:33:05.890" Score="2" ViewCount="295" Body="&lt;p&gt;I would like to run some command on each .js file of project. Argument list seems like a perfect usecase for it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:arga **/*.js&#xA;:argdo 'some_command'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that using &lt;code&gt;:arga **/*.js&lt;/code&gt; adds all .js files also to buffer list, which is an unintended side effect for me. It is possible to add files to argument list without adding them to buffer list?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could write a script which remembers buffer list and restores it but there should be a better way.&lt;/p&gt;&#xA;" OwnerUserId="18126" LastActivityDate="2018-07-15T14:57:31.620" Title="How to add files to argument list without adding them to buffer list?" Tags="|buffers|argument-list|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16685" PostTypeId="1" AcceptedAnswerId="16689" CreationDate="2018-07-07T13:37:34.843" Score="0" ViewCount="554" Body="&lt;p&gt;I've discovered the wonder that is &lt;code&gt;colorcolumn&lt;/code&gt; but I haven't yet mastered the black art of Vim scripting. If I have &lt;code&gt;:set colorcolumn=80,132&lt;/code&gt; in my .vimrc, how can I a) discover that I have more than one value, and b) access that 2nd value?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a line completion function that uses &lt;code&gt;&amp;amp;cc&lt;/code&gt; to calculate a padding value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LinePadOut(c)&#xA;  exec 'norm A ^['.(&amp;amp;cc - virtcol('$')).'A'.nr2char(a:c)&#xA;endfunction&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-L&amp;gt;&amp;lt;C-L&amp;gt; ':call LinePadOut('.getchar().')^M'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This only takes into consideration the &quot;80.&quot; How can I get at the &quot;132&quot; or even know it's there? I'd like to write a &quot;long padding&quot; version that uses the 132.&#xA;(I take &lt;em&gt;no credit&lt;/em&gt; for this function. It was someone else's magic that I poked at until it did what I wanted.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="9987" LastActivityDate="2018-07-10T09:23:49.307" Title="How do I get a specific colorcolumn value?" Tags="|colorcolumn|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16686" PostTypeId="1" AcceptedAnswerId="16687" CreationDate="2018-07-07T13:41:38.997" Score="6" ViewCount="352" Body="&lt;p&gt;I am using vim to edit LaTeX files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Throughout the text, there are labels to equations, tables etc. for which an accepted convention among TeX writers is the following&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\label{eq:massenergy}&lt;/code&gt; , &lt;code&gt;\label{tbl:exptresults}&lt;/code&gt; etc.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These can be cross-referenced later in text, eg &lt;code&gt;referring to equation~\ref{eq:massenergy}, we can see that ..... blah ...blah ...&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes, I want to change the equation being referenced, say I want to replace &lt;code&gt;{eq:massenergy}&lt;/code&gt; with &lt;code&gt;{eq:workenergyequivalence}&lt;/code&gt;. If my cursor is already somewhere in the word  &lt;code&gt;massenergy&lt;/code&gt;, I can do &lt;code&gt;ciw&lt;/code&gt; and start typing the desired label. But in this case, it deletes the entire content within braces, i.e. becomes equivalent to &lt;code&gt;ci}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I set &lt;code&gt;:&lt;/code&gt; as a word separator?&lt;/strong&gt; Note that &lt;code&gt;iskeyword+=:&lt;/code&gt; did not make any difference. What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="8408" LastActivityDate="2018-07-07T14:28:28.953" Title="Unable to set iskeyword for colon ( : ) character" Tags="|cursor-motions|filetype-tex|plugin-vimtex|keyword|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16687" PostTypeId="2" ParentId="16686" CreationDate="2018-07-07T14:28:28.953" Score="8" Body="&lt;p&gt;You are looking for&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword-=:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, making &lt;code&gt;:&lt;/code&gt; explicitly &lt;em&gt;not&lt;/em&gt; a keyword character.  If &lt;code&gt;:&lt;/code&gt; is in &lt;code&gt;iskeyword&lt;/code&gt; it will be included in &lt;code&gt;ciw&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-07-07T14:28:28.953" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16688" PostTypeId="1" CreationDate="2018-07-07T18:55:46.293" Score="1" ViewCount="1161" Body="&lt;p&gt;I use vim-airline but the content of the &quot;additional sections&quot; on the status bar of the vim-airline are cut off due to the limited space of the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8eqWV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8eqWV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The space is too tiny to include the last section. The message seems to be &quot;tr(ailing...)&quot; or something like that. But is it possible to check the message, possibly by running a command (e.g. &lt;code&gt;:AirlineCheckAdditionalSection&lt;/code&gt;) on the command mode?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2018-07-08T01:17:00.530" Title="How can I check the &quot;additional sections&quot; of vim-airline in greater details?" Tags="|plugin-airline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16689" PostTypeId="2" ParentId="16685" CreationDate="2018-07-07T22:19:10.347" Score="3" Body="&lt;p&gt;One strange thing about vimscript is that it automatically converts string to numbers when some&#xA;operations are applied.&#xA;For example, if you try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if '123foo'&#xA;    echo 'hi'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will get 'hi' as the output, but if you try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if 'foo'&#xA;    echo 'hi'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will get nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This happens because the condition of an 'if' sentence has to be an int, so both strings are&#xA;automatically converted likewise and we get 123 and 0 respectively because the conversion stops&#xA;at any non digit char.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The value stored in colorcolumn option is a string as stated in the help (see 'colorcolumn'),&#xA;specifically a comma separate list of values with the type string that contain the column&#xA;numbers that are highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just like 'if' sentence, the minus sign '-' requires numbers to be its operands and strings will&#xA;be converted (until first non digit) in order to accomplish that.&#xA;So when you do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;amp;cc - virtcol('$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The value of &amp;amp;cc which is originally &quot;80,132&quot; automatically converts to 80&#xA;losing the 132 and any other value.&#xA;If you want to treat all the separated values, I would recommend you to split the contents of&#xA;colorcolumn with the split() function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let value_list = split(&amp;amp;cc, ',') &quot; Split values at ,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, you can use a for statement to treat all the values. You can also query the length by&#xA;using the len() function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for value in value_list&#xA;    echo 'The value is: ' . value&#xA;endfor&#xA;&#xA;let number_of_values = len(value_list)&#xA;&#xA;for i in range(number_of_values)&#xA;    echo 'The value in ' . i . ' position is: ' . value_list[i]&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18087" LastActivityDate="2018-07-07T22:19:10.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16690" PostTypeId="2" ParentId="16685" CreationDate="2018-07-07T22:35:35.287" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I a) discover that I have more than&#xA;  one value, and b) access that 2nd value?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;a). By checking if the option contains a comma. I'd do so with a regular expression comparison. See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-=~&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help =~&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;cc =~ ','&#xA;  echo 'Multiple colorcolumns'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;b). By splitting the option's value on the comma(s). See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#split()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help split()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for cc in split(&amp;amp;cc, ',')&#xA;  echo 'colorcolumn:' cc&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;c). To explain why your code ignores the second&#xA;colorcolumn in your setting, note that &lt;code&gt;&amp;amp;cc&lt;/code&gt;&#xA;is not a &lt;code&gt;Number&lt;/code&gt; but in fact a &lt;code&gt;String&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo type(&amp;amp;cc) == type(&quot;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(See also &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27colorcolumn%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;:help 'colorcolumn'&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when you attempt to subtract from it, it&#xA;is converted into a &lt;code&gt;Number&lt;/code&gt; with the&#xA;following technique:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Conversion from a String to a Number is done by converting the first digits&#xA;  to a number.  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;—&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#Number&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help Number&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, everything after and including the&#xA;first comma is ignored.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-07-10T09:23:49.307" LastActivityDate="2018-07-10T09:23:49.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16691" PostTypeId="2" ParentId="16688" CreationDate="2018-07-08T01:17:00.530" Score="1" Body="&lt;p&gt;You don't see the full message if you maximize the window containing Vim? Because I don't believe that section is &quot;hard&quot; truncated so if you have the screen real estate widening the window should reveal the messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But maybe you're on a small device and that's not an option. I'm not aware of a direct way to reveal the text other than changing screen geometry but based on the vim-airline help one should be able expose it indirectly. But I've not been able to get the commands to do anything. Maybe you'll have better luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first idea is to set the truncation width for all other sections to small values. Something like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline#extensions#default#section_truncate_width = {'a': 5, 'b': 5, 'x': 5, 'y': 5, 'z': 5, 'warning': 80, 'error': 80 }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;('warning' and/or 'error' are the sections that are cutoff for you)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, one should be able to make room by hiding most of the other sections...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline#extensions#default#layout = [ [ 'a' ], [ 'error', 'warning' ] ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Revert to default layout with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline#extensions#default#layout = [ [ 'a', 'b', 'c' ], [ 'x', 'y', 'z', 'error', 'warning' ] ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In any case what you are missing is most likely one or both of these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[X]trailing&#xA;[X:Y]mix-indent-file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first indicates that you have trailing whitespace on at least one line. The second indicates that you have both tab and space indentations in the same file. &lt;code&gt;X&lt;/code&gt; and &lt;code&gt;Y&lt;/code&gt; will be line numbers. I'm pretty sure they represent the closest occurrence(s) of the relevant state as the numbers change depending on what line the cursor is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't recall seeing anything but those two warnings.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-07-08T01:17:00.530" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16692" PostTypeId="1" AcceptedAnswerId="16693" CreationDate="2018-07-08T08:49:58.453" Score="2" ViewCount="118" Body="&lt;p&gt;Let's say I rename a augroup in my vimrc; what happens then? Do the autocmds inside that augroup get loaded twice? For example, let's say I rename the following augroup&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup testgroup&#xA;    autocmd!&#xA;    autocmd BufWrite * :sleep 200m&#xA;    autocmd BufWrite * :echom &quot;Foo&quot;&#xA;    autocmd BufWrite * :echom &quot;Bar&quot;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup TestGroup&#xA;    autocmd!&#xA;    autocmd BufWrite * :sleep 200m&#xA;    autocmd BufWrite * :echom &quot;Foo&quot;&#xA;    autocmd BufWrite * :echom &quot;Bar&quot;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16884" LastActivityDate="2018-07-08T10:03:38.253" Title="Renaming an augroup in vimrc" Tags="|vimrc|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16693" PostTypeId="2" ParentId="16692" CreationDate="2018-07-08T10:03:38.253" Score="3" Body="&lt;p&gt;Your vimrc file is normally only loaded once per vim session. So if you change the file and rename the augroup, nothing happens in your running vim instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;code&gt;:source $MYVIMRC&lt;/code&gt; after you changed it you will end up with two versions of each of these autocommands. One in each group.  To see which autocommands are defined you can execute&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au                &quot;lists all autocommands (potentially very many)&#xA;:au BufWrite      &quot; lists all autocommands for the BufWrite event&#xA;:au testgroup     &quot; lists all autocommands in the group &quot;testgroup&quot;    &#xA;:au TestGroup     &quot; lists all autocommands in the group &quot;TestGroup&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to remove all autocommads of the &quot;testgroup&quot; in a running vim instance you can execute &lt;code&gt;:au! testgroup&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can start reading at &lt;code&gt;:h :au&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-08T10:03:38.253" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16696" PostTypeId="1" CreationDate="2018-07-08T21:44:35.233" Score="1" ViewCount="1014" Body="&lt;p&gt;For some reasons when I'm editing my &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt;, it adds 8 spaces even though I set &lt;code&gt;set tabstop=4&lt;/code&gt; on the file. Actually, &lt;code&gt;:verbose set tabstop&lt;/code&gt; returns 4, so it should be 4 spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already read the questions &lt;a href=&quot;https://vi.stackexchange.com/questions/8382/vim-displaying-incorrect-indentation&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/13442/files-with-tabs-are-length-8-even-with-set-tabstop-4-in-vimrc&quot;&gt;here&lt;/a&gt;, and strangely, in Python I have no problem on adding 4 spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is causing the problem? How can I investigate the problem further and fix it up?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2018-07-08T21:44:35.233" Title="The tab adds 8 spaces even though `set tabstop?` returns 4" Tags="|tab-characters|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="16698" PostTypeId="1" AcceptedAnswerId="16699" CreationDate="2018-07-09T09:35:13.270" Score="1" ViewCount="2162" Body="&lt;p&gt;I'd like to know if a file uses LF or CRLF line endings. I'm on Windows with vim installed. I don't want to convert the files, just know which line endings they use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can get the file format (&lt;code&gt;dos&lt;/code&gt; or &lt;code&gt;unix&lt;/code&gt;) used by running &lt;code&gt;:set ff?&lt;/code&gt;, but I can't find a way to have the result printed on standard output. &lt;code&gt;:print&lt;/code&gt; seems to only print a range of lines, and &lt;code&gt;:echo&lt;/code&gt; doesn't print anything on stdout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using scripted ex mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -e -s myfile &amp;lt; ../script.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;code&gt;script.vim&lt;/code&gt; containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo ff?&#xA;1p&#xA;quit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output contains the first line of &lt;code&gt;myfile&lt;/code&gt;, so the &lt;code&gt;1p&lt;/code&gt; command is executed, but I can't see the result from &lt;code&gt;echo ff?&lt;/code&gt;. What's the right command to output something?&lt;/p&gt;&#xA;" OwnerUserId="15203" LastEditorUserId="1238" LastEditDate="2019-12-29T06:53:00.650" LastActivityDate="2019-12-29T06:53:00.650" Title="How to print an option's value to standard output?" Tags="|vimscript|echo|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16699" PostTypeId="2" ParentId="16698" CreationDate="2018-07-09T10:47:36.333" Score="3" Body="&lt;p&gt;Replace &lt;code&gt;echo&lt;/code&gt; with &lt;code&gt;set&lt;/code&gt; in your script, and your command works fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#-s-ex&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help -s-ex&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The output of these commands is displayed (to stdout):&lt;br&gt;&#xA;                          :print&lt;br&gt;&#xA;                          :list&lt;br&gt;&#xA;                          :number&lt;br&gt;&#xA;                          &lt;strong&gt;:set&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;to display option values.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(Emphasis mine.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.B. The following command also works*, and doesn't require the extra &lt;code&gt;script.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -e -s -c &quot;set ff?&quot; -c &quot;quit&quot; myfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For outputting the results of other commands to &lt;code&gt;stdout&lt;/code&gt;, you may want to look into the &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#:redir&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:redir&lt;/code&gt;&lt;/a&gt; command, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -es -c 'redir &amp;gt;&amp;gt; /dev/stdout' -c 'smile' -c 'q'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, note that getting this working in the &lt;code&gt;cmd.exe&lt;/code&gt; Windows Command Prompt will probably require writing the output into the buffer first and then outputting it via &lt;code&gt;:print&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I'm pretty sure you're already aware of this, but noting for future readers that the &lt;code&gt;fileformat&lt;/code&gt; option doesn't necessarily tell you what line endings the file &lt;em&gt;has&lt;/em&gt;, only how Vim is interpreting it: the value depends on your &lt;code&gt;fileformats&lt;/code&gt; setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* I'd actually write it like this: &lt;code&gt;vim -es -c &quot;set fileformat | q&quot; myfile&lt;/code&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-07-09T13:00:32.670" LastActivityDate="2018-07-09T13:00:32.670" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16700" PostTypeId="1" AcceptedAnswerId="16701" CreationDate="2018-07-09T13:40:04.610" Score="0" ViewCount="1500" Body="&lt;p&gt;I have multiple files with a string like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source /PATH/TO/OLD/ENV.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this needs to be replaced with:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source /PATH/TO/NEW/ENV1.sh&#xA;source /PATH/TO/NEW/ENV2.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usually, I use &lt;code&gt;sed&lt;/code&gt;  to replace strings. What's the 'vim-way' of doing this?&lt;br&gt;&#xA;Thanks. &lt;/p&gt;&#xA;" OwnerUserId="14185" LastActivityDate="2018-07-09T14:53:41.343" Title="Replace a line with two other lines" Tags="|substitute|replace|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16701" PostTypeId="2" ParentId="16700" CreationDate="2018-07-09T14:53:41.343" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;\r&lt;/code&gt; to represent a newline in &lt;code&gt;:substitute&lt;/code&gt; patterns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s,source /PATH/TO/OLD/ENV.sh,source /PATH/TO/NEW/ENV1.sh\rsource /PATH/TO/NEW/ENV2.sh/,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that in substitute patterns &lt;code&gt;\n&lt;/code&gt; means NULL byte, not newline. This is inconsistent and confusing (I'm not sure what the reason for it is, it's a vi quirk you'll just have to remember)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used &lt;code&gt;,&lt;/code&gt; instead of &lt;code&gt;/&lt;/code&gt; to avoid having to escape all the &lt;code&gt;/&lt;/code&gt;s in the path; see &lt;a href=&quot;https://vi.stackexchange.com/q/3156/51&quot;&gt;What does it mean to replace slashes (/) by exclamation marks (!) in a substitute command?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;code&gt;:bufdo&lt;/code&gt;, &lt;code&gt;:windo&lt;/code&gt;, and &lt;code&gt;:tabdo&lt;/code&gt; commands to run any command on multiple buffers, windows, or tabs. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo :%s,source /PATH/TO/OLD/ENV.sh,source /PATH/TO/NEW/ENV1.sh\rsource /PATH/TO/NEW/ENV2.sh,&#xA;:wa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which should do what you want.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2018-07-09T14:53:41.343" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16702" PostTypeId="2" ParentId="7966" CreationDate="2018-07-09T15:14:01.113" Score="3" Body="&lt;p&gt;I wrote my masters thesis using Vim, LaTeX and BibTeX.  To manage my BibTeX references, I used a program called &lt;a href=&quot;http://www.jabref.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;JabRef&lt;/a&gt;.  JabRef has a neat little feature where you can connect it to a Vim server instance, and then you can &quot;push&quot; the BibTeX reference from JabRef to the LaTeX document that you are editing in Vim.&lt;/p&gt;&#xA;" OwnerUserId="18147" LastActivityDate="2018-07-09T15:14:01.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16708" PostTypeId="1" CreationDate="2018-07-10T08:32:03.973" Score="4" ViewCount="725" Body="&lt;p&gt;I am using multiple files within the same tab and when I switch buffers using :bn I reach the terminal, at which point I have to issue the command again to move.&#xA;Here is the catch, I am using keymaps to do buffer switching instead of typing the entire command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is there a way to skip the terminal buffer and move on with this keymap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The possible solution I can think as of now is using a separate tab for the terminal while keeping the present one for code. this is not a huge deal, just keeping my laziness alive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any and all ideas are appreciated.&lt;/p&gt;&#xA;" OwnerUserId="11253" LastActivityDate="2022-03-21T10:58:50.077" Title="Switching buffers in VI while skipping any terminal in VI 8.1" Tags="|buffers|terminal|terminal-buffer|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16709" PostTypeId="2" ParentId="16708" CreationDate="2018-07-10T09:12:22.537" Score="6" Body="&lt;p&gt;This should work too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup termIgnore&#xA;    autocmd!&#xA;    autocmd TerminalOpen * set nobuflisted&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15134" LastEditorUserId="51" LastEditDate="2018-07-10T13:14:49.267" LastActivityDate="2018-07-10T13:14:49.267" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16710" PostTypeId="2" ParentId="16708" CreationDate="2018-07-10T09:12:31.940" Score="3" Body="&lt;p&gt;This should do the job:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BnSkipTerm()&#xA;  let start_buffer = bufnr('%')&#xA;  bn&#xA;  while &amp;amp;buftype ==# 'terminal' &amp;amp;&amp;amp; bufnr('%') != start_buffer&#xA;    bn&#xA;  endwhile&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;bn :call BnSkipTerm()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It just keeps invoking &lt;code&gt;:bn&lt;/code&gt; until it's not in a terminal window, by checking the &lt;code&gt;'buftype'&lt;/code&gt; setting.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-07-10T13:47:52.493" LastActivityDate="2018-07-10T13:47:52.493" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16711" PostTypeId="1" AcceptedAnswerId="16712" CreationDate="2018-07-10T09:33:38.133" Score="2" ViewCount="1714" Body="&lt;p&gt;Consider the following function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AbbreviationsOpen()&#xA;   &quot;go to the first word of the last line&#xA;   normal G &#xA;&#xA;   &quot;store the word in the register named a&#xA;   let @a = expand('&amp;lt;cword&amp;gt;') &#xA;&#xA;   &quot;display the word in the command line&#xA;   execute &quot;normal :&amp;lt;C-R&amp;gt;a&quot; &#xA;endfunction`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last line of the above function (execute ...) is not taking any effect. However, if I use the following function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AbbreviationsOpen()&#xA;    &quot;go to the first word of the last line&#xA;    normal G &#xA;&#xA;    &quot;store the word in the register named a&#xA;    let @a = expand('&amp;lt;cword&amp;gt;') &#xA;endfunction`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then press the following keys&#xA;&lt;code&gt;:&amp;lt;ctrl&amp;gt;ra&lt;/code&gt;&#xA;then I do get the word appearing on the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So can somebody help me as to why the above function does not work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I do not want to use a register. I'd like to achieve this using a variable. So the the function I want to write should look like.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AbbreviationsOpen()&#xA;    &quot;go to the first word of the last line&#xA;    normal G &#xA;&#xA;    &quot;store the word in the register named a&#xA;    let var = expand('&amp;lt;cword&amp;gt;') &#xA;&#xA;    SOMETHING&#xA;endfunction`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2369" LastActivityDate="2020-10-04T18:54:26.503" Title="How to use a value stored in a variable in the command mode?" Tags="|vimscript|cut-copy-paste|functions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16712" PostTypeId="2" ParentId="16711" CreationDate="2018-07-10T10:27:05.557" Score="4" Body="&lt;p&gt;The problem is that you can't use &lt;code&gt;:normal&lt;/code&gt; to enter command-line mode, because it expects a &quot;complete&quot; command. (Try a simple &lt;code&gt;:normal :&lt;/code&gt; to test this.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you're looking for &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#feedkeys()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help feedkeys()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Start command-line mode populated with contents of the &quot;a register&#xA;call feedkeys(':' . @a)&#xA;&#xA;&quot; Start command-line mode populated with contents of the var variable&#xA;call feedkeys(':' . var)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, presuming you're invoking your function from a mapping, you could also use an expression mapping to enter text into the command line. However, note that you cannot move the cursor in an expression mapping, so you would need to alter the rest of your function slightly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AbbreviationsOpen()&#xA;  let var = split(getline('$'), ' ')[0]&#xA;  return ':'.var&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;a AbbreviationsOpen()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#:map-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help map-expression&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-07-10T13:51:12.473" LastActivityDate="2018-07-10T13:51:12.473" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16713" PostTypeId="1" AcceptedAnswerId="16714" CreationDate="2018-07-10T12:15:36.583" Score="2" ViewCount="271" Body="&lt;p&gt;On Windows, Vim does &lt;code&gt;source $VIMRUNTIME\mswin.vim&lt;/code&gt; in its system-wide config and remaps many keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to have default Vim key bindings but I don't want to touch system-wide config. How do I do it in proper way?&lt;/p&gt;&#xA;" OwnerUserId="10514" LastEditorUserId="51" LastEditDate="2018-07-10T12:28:05.723" LastActivityDate="2018-07-10T12:28:36.850" Title="Revert effect of source $VIMRUNTIME\mswin.vim" Tags="|key-bindings|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16714" PostTypeId="2" ParentId="16713" CreationDate="2018-07-10T12:28:36.850" Score="3" Body="&lt;p&gt;The top of the file checks the variable &lt;code&gt;g:skip_loading_mswin&lt;/code&gt; which you can set to prevent it from running. Put this in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:skip_loading_mswin = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-10T12:28:36.850" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16715" PostTypeId="1" AcceptedAnswerId="16726" CreationDate="2018-07-10T16:35:55.897" Score="2" ViewCount="590" Body="&lt;p&gt;I have a function in my bashrc that checks if a file is writable with &lt;code&gt;[ -w &quot;$1&quot; ]&lt;/code&gt;. If it is, I open it with vim normally. If it's not, I open with sudo via &lt;code&gt;sudo env HOME=&quot;$HOME&quot; vim -u ~/.vimrc &quot;$1&quot;&lt;/code&gt; to make sure vim sources my &lt;code&gt;.vimrc&lt;/code&gt; and colorscheme correctly. I want to print a warning message on the message line (whatever that line is called) when I do this, so I know I've had to use sudo. I wrote a vimrc function to display the message how I want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;sudo warning label:&#xA;function! Sudowarn ()&#xA;  hi TempColor ctermfg=255 ctermbg=88&#xA;  echohl TempColor&#xA;  echo &quot;Automatically sudo'd to have write access!&quot;&#xA;  echohl None&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is that I don't know how to call this function when the file loads only when I've sudo'd. I know vim knows about the &lt;code&gt;$USER&lt;/code&gt; variable (&quot;root&quot; when sudo'd, &quot;jeremysprofile&quot; when not), and I know &lt;code&gt;autocmd&lt;/code&gt; has a &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#User&quot; rel=&quot;nofollow noreferrer&quot;&gt;User option&lt;/a&gt; but I don't know how to use these to solve my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone can at least tell me what I should be doing to solve my problem instead of asking internet questions, it would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="17205" LastEditorUserId="17205" LastEditDate="2018-07-10T17:47:59.667" LastActivityDate="2018-07-26T21:30:43.803" Title="Vim autocommand based on username - print message" Tags="|vimrc|vimscript|autocmd|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="16716" PostTypeId="1" AcceptedAnswerId="16739" CreationDate="2018-07-10T19:47:03.983" Score="1" ViewCount="278" Body="&lt;p&gt;Is there any way to save these files to automatically created subdirs? Google gave me no answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason is simple- I work on several computers which I keep synced via git, so having these files in the same directory structure is practical to me. If all these files could be in a single subfolder of the repo's root for extra neatness it'd be great, but just having a /.vimfiles folder in each directory wouldn't be bad either.&lt;/p&gt;&#xA;" OwnerUserId="18154" LastEditorUserId="18154" LastEditDate="2018-07-11T01:52:37.690" LastActivityDate="2018-07-13T07:46:28.783" Title="Saving .swp/.un~ files to subdirectories" Tags="|save|filesystem|options|git|undo-redo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16717" PostTypeId="1" CreationDate="2018-07-10T21:36:26.080" Score="2" ViewCount="729" Body="&lt;p&gt;Here is a sample of my .vimrc, that doesn't do a thing (the autocmd does not work) when I open a .md or .tex file, but works fine for .py files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetype_python&#xA;  autocmd FileType python nnoremap &amp;lt;buffer&amp;gt; &amp;lt;localleader&amp;gt;c I#&amp;lt;esc&amp;gt;&#xA;  autocmd FileType python set nu&#xA;  autocmd FileType python :iabbrev &amp;lt;buffer&amp;gt; iff if:&amp;lt;left&amp;gt;&#xA;  autocmd FileType python :iabbrev &amp;lt;buffer&amp;gt; forr for:&amp;lt;left&amp;gt;&#xA;  autocmd FileType python :iabbrev &amp;lt;buffer&amp;gt; while while:&amp;lt;left&amp;gt;&#xA;  autocmd BufWritePre,BufRead *.py :normal gg=G&#xA;augroup END&#xA;&#xA;augroup filetype_tex&#xA;  autocmd FileType tex set nu&#xA;augroup END&#xA;&#xA;augroup filetype_markdown&#xA;  autocmd FileType markdown onoremap i= :&amp;lt;c-u&amp;gt;execute &quot;normal! ?^==\\+$\r:nohlsearch\rkvg_&quot;&amp;lt;cr&amp;gt;&#xA;  autocmd FileType markdown onoremap i- :&amp;lt;c-u&amp;gt;execute &quot;normal! ?^--\\+$\r:nohlsearch\rkvg_&quot;&amp;lt;cr&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As if Vim didn't know about markdown and tex (but it's supposed to, I checked the list of all known FileTypes and they were there)... &#xA;Any ideas ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance !&lt;/p&gt;&#xA;" OwnerUserId="18171" LastActivityDate="2018-07-10T21:36:26.080" Title="Vim not recognizing markdown and tex files" Tags="|autocmd|filetype|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16718" PostTypeId="2" ParentId="16715" CreationDate="2018-07-10T22:13:05.970" Score="3" Body="&lt;p&gt;As @Martin pointed out, the &lt;code&gt;autocmd&lt;/code&gt; was a simple if statement. I didn't realize &lt;code&gt;autocmd&lt;/code&gt; could do do if or read variables the way &lt;code&gt;echom&lt;/code&gt; could. I also added &lt;code&gt;cmdheight&lt;/code&gt; so that the message would not block displaying the file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;sudo warning label:&#xA;function! Sudowarn ()&#xA;  &quot;cmdheight prevents vim from forcing 'push ENTER to continue'&#xA;  set cmdheight=2&#xA;  hi SudoColor ctermfg=255 ctermbg=88&#xA;  echohl SudoColor&#xA;  echo &quot;Automatically sudo'd to have write access!&quot;&#xA;  echohl None&#xA;  set cmdheight=1&#xA;endfunction&#xA;autocmd BufNewFile,BufRead * if $USER == &quot;root&quot; | call Sudowarn() | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17205" LastEditorUserId="17205" LastEditDate="2018-07-26T21:30:43.803" LastActivityDate="2018-07-26T21:30:43.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16719" PostTypeId="1" CreationDate="2018-07-10T23:51:09.590" Score="1" ViewCount="192" Body="&lt;p&gt;When I restore a session containing terminal buffers, terminal buffers (like other kinds of buffers) don't load while they're hidden. Is there any way to load them in background without making them active so that they run their processes? (I want to change their state from inactive to hidden without ever making their state active - &lt;code&gt;:help active-buffer&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="7153" LastEditorUserId="7153" LastEditDate="2018-07-11T12:26:48.787" LastActivityDate="2018-07-11T12:26:48.787" Title="Load a hidden terminal buffer" Tags="|neovim|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16720" PostTypeId="1" AcceptedAnswerId="16725" CreationDate="2018-07-11T01:05:17.160" Score="2" ViewCount="3807" Body="&lt;p&gt;I set the following on my &lt;code&gt;~/.vimrc&lt;/code&gt; which sets the current directory to the location of the file on the buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufEnter * silent! :lcd%:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I run the fzf command to search for a file, then the search starts on the current directory, althogh the file I like to get is often in other directories. So I want to set it to &lt;code&gt;~/&lt;/code&gt; whenever I run fzf.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'm not sure if it is possible. Is it possible to set it in fzf?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2021-04-08T23:22:42.323" Title="Can I set the default search directory on fzf?" Tags="|plugin-fzf|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16721" PostTypeId="1" AcceptedAnswerId="16722" CreationDate="2018-07-11T13:26:19.830" Score="1" ViewCount="2533" Body="&lt;p&gt;I've been thinking of ways to visualize git commits with vim. I would like to be able to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;run a command from the terminal such as: &lt;code&gt;vimdiff -c &amp;lt;commit id&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;vim opens with two windows on a vertical split layout, displaying a diff the changes introduced for one of the files on that particular commit.&lt;/li&gt;&#xA;&lt;li&gt;each file opens on a different tab, so I can press &lt;code&gt;gt&lt;/code&gt; to view the diff for the next file.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I can't possibly be the first to think of this issue, but I couldn't find any plugin or information out there. So how do you guys do it?&lt;/p&gt;&#xA;" OwnerUserId="14188" LastActivityDate="2018-07-11T14:15:45.580" Title="Visualize git commit diff similarly to mergetool" Tags="|vimdiff|git|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16722" PostTypeId="2" ParentId="16721" CreationDate="2018-07-11T14:04:01.137" Score="3" Body="&lt;p&gt;Git provides this functionality for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First set up git to use Vim as its &quot;difftool&quot;. (Depending on what you have installed, this step may be unnecessary: vimdiff is one of Git's default difftools.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git config diff.tool vimdiff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then run git's &lt;code&gt;difftool&lt;/code&gt; command with appropriate options. e.g. to view the changes introduced by commit &lt;code&gt;12345abc&lt;/code&gt;, you can use either&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git difftool 12345abc^..12345abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or its shorthand&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git difftool 12345abc^!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By default this will open the files one at a time. After you quit Vim, Git will open the next comparison. &lt;a href=&quot;https://superuser.com/questions/455944/vimdiff-and-git-all-at-once&quot;&gt;Here are a selection of ways&lt;/a&gt; to get Git instead to open all the diffs at once.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-07-11T14:15:45.580" LastActivityDate="2018-07-11T14:15:45.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16725" PostTypeId="2" ParentId="16720" CreationDate="2018-07-11T17:21:36.080" Score="2" Body="&lt;p&gt;The following info can be found in the &lt;a href=&quot;https://github.com/junegunn/fzf/blob/master/doc/fzf.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;official docs&lt;/a&gt; of fzf:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can execute &lt;code&gt;:FZF&lt;/code&gt; with an argument for the starting dir. So you can just run &lt;code&gt;:FZF ~&lt;/code&gt; instead of &lt;code&gt;:FZF&lt;/code&gt;.  If you open the fzf buffer from a mapping just change that mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;c-space&amp;gt; :FZF ~&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Unrelated to the question but related to the autocomand you mentioned: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;autochdir&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'autochdir'&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-11T17:21:36.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16726" PostTypeId="2" ParentId="16715" CreationDate="2018-07-11T18:34:26.417" Score="4" Body="&lt;p&gt;I would use the &lt;code&gt;VimEnter&lt;/code&gt; autocommand and move the conditional inside the function, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc&#xA;  autocmd!&#xA;  autocmd VimEnter * call SudoWarn()&#xA;augroup END&#xA;&#xA;function! SudoWarn()&#xA;  if $USER !=# 'root' | return | endif&#xA;  ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also moves the autocommand inside an autocommand group; &quot;vimrc&quot; is just an example name, it could be anything. The &lt;code&gt;autocmd!&lt;/code&gt; will remove all previous autocommands in this group, which is sensible if you should load the vimrc file multiple times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, with this approach, I don't think you need to change the &lt;code&gt;cmdheight&lt;/code&gt; option, since the &lt;code&gt;echo&lt;/code&gt; is issued at a later time.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-07-11T18:34:26.417" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16727" PostTypeId="1" AcceptedAnswerId="16738" CreationDate="2018-07-11T23:07:11.517" Score="1" ViewCount="59" Body="&lt;p&gt;Sometimes I want to get back and copy some old code that I deleted and use it. For example, I'll do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:earlier 12h&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and then yank the deleted code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get back to where I was, I'll issue a command like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:later 13h&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with the time argument for the &lt;code&gt;:later&lt;/code&gt; command being longer than the time argument I supplied for the &lt;code&gt;:earlier&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works, but it seems like there should be a cleaner way to jump back to the latest version of the code. I can't seem to find a command to do that, though.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2018-07-13T10:58:19.313" Title="Return to current state of file after issuing :earlier command?" Tags="|undo-redo|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16728" PostTypeId="1" CreationDate="2018-07-12T01:57:48.453" Score="1" ViewCount="661" Body="&lt;p&gt;Here is my situation. I launch tmux on iTerm2 and then split the window vertically (left and right), then make the right side of the window split horizontally. So now, there are 3 windows, one big at the left and two small at the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I launch neovim on the large window at the left side. This is my usual workflow but I found it is more comfortable to use neovim's terminal mode, instead of the tmux. So I rather put two terminal windows at the right side of the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then, if I manage buffers at tabs, the only one tab shows two terminal windows at the right; all the other tabs only show one buffer until and unless I split the window and launch the terminal mode there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I rather want to do is use two terminal mode at the right and whatever files at the left, which are managed by tabs and can be switched easily, with the two terminal windows are always fixed there. Is this possible in neovim?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2019-09-05T11:03:00.560" Title="Is it possible to manage tabs only within the single window in split mode?" Tags="|neovim|terminal|split|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16729" PostTypeId="2" ParentId="16727" CreationDate="2018-07-12T02:41:56.620" Score="2" Body="&lt;p&gt;How about, in Normal mode, &lt;kbd&gt;9&lt;/kbd&gt; &lt;kbd&gt;9&lt;/kbd&gt; &lt;kbd&gt;9&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;R&lt;/kbd&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h CTRL-R&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-R      Redo [count] changes which were undone.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you overshoot it's okay. You can't go past the most recent change. (To the future?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you can use any sufficiently high number. 999 is just a quick way to a number likely to do the job. If not add another &lt;kbd&gt;9&lt;/kbd&gt; or two. Just hammer on it until you feel good about it. ;)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-07-12T06:17:08.740" LastActivityDate="2018-07-12T06:17:08.740" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16730" PostTypeId="2" ParentId="16728" CreationDate="2018-07-12T06:46:36.213" Score="1" Body="&lt;p&gt;There is a plugin called &lt;a href=&quot;https://github.com/zefei/vim-wintabs&quot; rel=&quot;nofollow noreferrer&quot;&gt;wintabs&lt;/a&gt;. They claim to help you manage buffers on a per window basis.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-12T06:46:36.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16731" PostTypeId="1" AcceptedAnswerId="16734" CreationDate="2018-07-12T17:23:09.493" Score="6" ViewCount="2113" Body="&lt;p&gt;Been really loving the asynchronous terminal in Vim 8. Sometimes I have a large amount of output in the terminal, and when I enter normal mode in the terminal and use &lt;code&gt;gg&lt;/code&gt; to go to the top, I see that it is cut off. How can I increase the scrollback?&lt;/p&gt;&#xA;" OwnerUserId="18196" LastActivityDate="2018-07-12T18:03:51.133" Title="Scrollback in Vim 8 Terminal" Tags="|terminal|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16732" PostTypeId="1" AcceptedAnswerId="16735" CreationDate="2018-07-12T17:28:18.620" Score="1" ViewCount="356" Body="&lt;p&gt;I use MacVim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I write-to-file frequently using &quot;:w&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often have some lines selected visually when I do this, and get an annoying &quot;Write partial file&quot; dialogue (which more annoyingly doesn't tab out to &quot;No&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Writing a partial file is something I do very seldom. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are your recommendations to make the default skip &quot;Write partial file&quot; and just write the entire file? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course I'd like to develop a new mapping for the default functionality (in case I do need it). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command w &amp;lt;esc&amp;gt;w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I could not save that command because &quot;User defined commands must start with capital letters&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I tried this, but get &quot;Not an editor command ^[w&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! WriteIgnoreVisual &amp;lt;esc&amp;gt;w&#xA;cabbrev w &amp;lt;c-r&amp;gt;=(getcmdtype()==':' &amp;amp;&amp;amp; getcmdpos()==1 ? 'WriteIgnoreVisual' : 'w')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15150" LastEditorUserId="15150" LastEditDate="2018-07-12T19:05:38.910" LastActivityDate="2018-07-12T19:05:38.910" Title="Avoid &quot;write partial file&quot;?" Tags="|macvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16734" PostTypeId="2" ParentId="16731" CreationDate="2018-07-12T18:03:51.133" Score="7" Body="&lt;p&gt;See the option &lt;code&gt;termwinscroll&lt;/code&gt; as documented at &lt;code&gt;:help terminal-normal&lt;/code&gt; and &lt;code&gt;:help termwinscroll&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'termwinscroll' 'twsl'  number  (default 10000)&#xA;        local to buffer&#xA;        {not in Vi}&#xA;        {not available when compiled without the&#xA;        |+terminal| feature}&#xA;Number of scrollback lines to keep.  When going over this limit the&#xA;first 10% of the scrollback lines are deleted.  This is just to reduce&#xA;the memory usage.  See |Terminal-Normal|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus, you may increase the limit using for example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set termwinscroll=40000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-07-12T18:03:51.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16735" PostTypeId="2" ParentId="16732" CreationDate="2018-07-12T18:10:46.787" Score="3" Body="&lt;p&gt;You were pretty close.  It's easier to use an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping.  You just have to check that the cmdline equals the string &lt;code&gt;'&amp;lt;,'&amp;gt;w&lt;/code&gt;, and if so, delete the existing command line and replace it with a plain &lt;code&gt;:w&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cabbrev &amp;lt;expr&amp;gt; w getcmdtype()==':' &amp;amp;&amp;amp; getcmdline() == &quot;'&amp;lt;,'&amp;gt;w&quot; ? '&amp;lt;c-u&amp;gt;w' : 'w'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-07-12T18:10:46.787" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16736" PostTypeId="1" AcceptedAnswerId="16737" CreationDate="2018-07-12T18:48:39.417" Score="1" ViewCount="226" Body="&lt;p&gt;I want to make &lt;code&gt;:f&lt;/code&gt; do the same thing as &lt;code&gt;:find&lt;/code&gt; so if I type &lt;code&gt;:f abc.txt&lt;/code&gt;, it should run &lt;code&gt;:find abc.txt&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to do something like &lt;code&gt;cmap f find&lt;/code&gt; but that just make any f into find&lt;/p&gt;&#xA;" OwnerUserId="18204" OwnerDisplayName="usama8800" LastActivityDate="2018-07-12T22:26:35.847" Title="Make :f do the same thing as :find in Vim" Tags="|vimrc|gvim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16737" PostTypeId="2" ParentId="16736" CreationDate="2018-07-12T21:26:42.650" Score="1" Body="&lt;p&gt;try this maybe:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cabbrev f find&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="thrig" LastActivityDate="2018-07-12T21:26:42.650" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16738" PostTypeId="2" ParentId="16727" CreationDate="2018-07-13T07:09:44.537" Score="2" Body="&lt;p&gt;As long as you don't write the current buffer, and you probably don't need to if you are just looking back to yank some stuff, you can use &lt;code&gt;:edit!&lt;/code&gt; (or simply &lt;code&gt;:e!&lt;/code&gt;) to reload the file from disk, thus undoing all those changes.&lt;/p&gt;&#xA;" OwnerUserId="18187" LastEditorUserId="18187" LastEditDate="2018-07-13T10:58:19.313" LastActivityDate="2018-07-13T10:58:19.313" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16739" PostTypeId="2" ParentId="16716" CreationDate="2018-07-13T07:46:28.783" Score="1" Body="&lt;p&gt;&lt;strong&gt;Short answer&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;mkdir()&lt;/code&gt; function to create those subdirectories and then set &lt;code&gt;undodir&lt;/code&gt;, &lt;code&gt;backupdir&lt;/code&gt; and &lt;code&gt;directory&lt;/code&gt; to tell vim to use them. This snippet of code should work just fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Mkdir(path)&#xA;    if !isdirectory(resolve(a:path))&#xA;        try&#xA;            call mkdir(a:path, &quot;p&quot;, 0775)&#xA;        catch&#xA;            return ''&#xA;        endtry&#xA;    endif&#xA;    return a:path&#xA;endfunction&#xA;&#xA;&quot; Find the nearest .git directory&#xA;let s:repo_root = ''&#xA;let s:cwd = getcwd()&#xA;while getcwd() != '/'&#xA;    if isdirectory('.git')&#xA;        let s:repo_root = getcwd()&#xA;        break&#xA;    endif&#xA;    cd ..&#xA;endwhile&#xA;exec 'cd '.s:cwd&#xA;&#xA;&quot; If we found a .git/ directory somewhere, create directories there&#xA;if s:repo_root != ''&#xA;    set undofile&#xA;    set backup&#xA;    set swapfile&#xA;&#xA;    let s:dirpath = s:repo_root.&quot;/.vimfiles&quot;&#xA;    let &amp;amp;undodir = Mkdir(s:dirpath.&quot;/undo&quot;)&#xA;    let &amp;amp;backupdir = Mkdir(s:dirpath.&quot;/backup&quot;)&#xA;    let &amp;amp;directory = Mkdir(s:dirpath.&quot;/swp&quot;)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Long answer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's probably not a good idea to sync those files with git. Keep in mind that they will be constantly changing, and that will add a lot of clutter to your commits. Also there is no point in syncing &lt;code&gt;.swp&lt;/code&gt; files, since the whole point of having &lt;code&gt;.swp&lt;/code&gt; files is to avoid having two instances of the editor working on the same file at once. If you are syncing between different machines, these files stop making any sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest you don't put those files under your projects directory, but rather save them in subdirectories inside &lt;code&gt;~/.vim&lt;/code&gt;. In that case you only have to slightly modify the snippet above to remove the &lt;code&gt;.git/&lt;/code&gt; discovery part, and to replace &lt;code&gt;s:dir_path&lt;/code&gt; with &lt;code&gt;~/.vim/&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="18187" LastActivityDate="2018-07-13T07:46:28.783" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16740" PostTypeId="1" AcceptedAnswerId="16741" CreationDate="2018-07-13T07:56:56.927" Score="1" ViewCount="365" Body="&lt;p&gt;So I want to figure out the Operating System and execute a piece of code based on the operating system in my &lt;code&gt;.vimrc&lt;/code&gt;. However, I'm not able to understand where I'm going wrong.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let operating_system = system(&quot;awk -F= '/^NAME/{print $2}' /etc/os-release&quot;)&#xA;echon operating_system&#xA;echon operating_system &amp;gt; &quot;CentOS Linux&quot;&#xA;echon operating_system &amp;lt; &quot;CentOS Linux&quot;&#xA;echon operating_system ==? &quot;CentOS Linux&quot;&#xA;echon operating_system ==# &quot;CentOS Linux&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the output I get when I start vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;CentOS Linux&quot;&#xA;0100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Shouldn't &lt;code&gt;==?&lt;/code&gt; and &lt;code&gt;==#&lt;/code&gt; evaluate to 1? If not, why?&lt;/p&gt;&#xA;" OwnerUserId="13174" LastEditorUserId="1841" LastEditDate="2018-07-13T09:15:38.107" LastActivityDate="2018-07-13T11:27:13.417" Title="String comparison not working as expected!" Tags="|vimscript|string-manipulation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16741" PostTypeId="2" ParentId="16740" CreationDate="2018-07-13T08:49:51.767" Score="2" Body="&lt;p&gt;It's not working, because what you have inside &lt;code&gt;operating_system&lt;/code&gt; variable is a bit more, than just &lt;code&gt;CentOS Linux&lt;/code&gt;. First of all, those quotes &lt;code&gt;&quot;&lt;/code&gt; are part of the string. Checkout contents of that file. If you use &lt;code&gt;=&lt;/code&gt; as a separator, second field actually contains &lt;code&gt;&quot;&lt;/code&gt; characters (at least that's the case on my system). Also, there probably is some invisible magic character at the end of string - carrige return or new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should work if you change getting the &lt;code&gt;operating_system&lt;/code&gt; variable to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let operating_system = join(split(system(&quot;sed -n 's/^NAME=\&quot;\\([^\&quot;]\\+\\)\&quot;.*$/\\1/p' /etc/os-release&quot;)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sed&lt;/code&gt; will get everything inside &lt;code&gt;&quot; &quot;&lt;/code&gt; part (I don't know &lt;code&gt;awk&lt;/code&gt; that well to do this with it), and the &lt;code&gt;join&lt;/code&gt;/&lt;code&gt;split&lt;/code&gt; combo will remove those invisible characters.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2018-07-13T08:49:51.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16742" PostTypeId="2" ParentId="16740" CreationDate="2018-07-13T11:16:42.067" Score="2" Body="&lt;p&gt;Note that you don't need to execute external processes with &lt;code&gt;system()&lt;/code&gt; which adds trailing newlines &amp;amp; all.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let os = matchstr(filter(readfile('/etc/os-release'), 'v:val =~ &quot;^NAME&quot;')[0], '.*&quot;\zs.*\ze&quot;.*')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#readfile%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;readfile()&lt;/code&gt;&lt;/a&gt; to read the system file&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#filter%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;filter()&lt;/code&gt;&lt;/a&gt; to keep only the line with &lt;code&gt;NAME=&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#matchstr%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;matchstr()&lt;/code&gt;&lt;/a&gt; with extract the content of the &lt;em&gt;name&lt;/em&gt; field (in the first line &lt;code&gt;[0]&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;BTW, &lt;code&gt;/etc/redhat-release&lt;/code&gt; also has the information you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let is_centos = readfile('/etc/redhat-release')[0] =~ 'CentOS Linux'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-07-13T11:27:13.417" LastActivityDate="2018-07-13T11:27:13.417" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16743" PostTypeId="2" ParentId="457" CreationDate="2018-07-13T11:32:50.873" Score="7" Body="&lt;p&gt;Apart from the usages already mentioned here, ex is also a way to edit files on the linux console if that happens to be on the S/390 platform and the console happens to be line-oriented instead of screen-oriented.&lt;/p&gt;&#xA;" OwnerUserId="18202" LastActivityDate="2018-07-13T11:32:50.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16744" PostTypeId="1" AcceptedAnswerId="16745" CreationDate="2018-07-13T13:58:15.617" Score="1" ViewCount="191" Body="&lt;p&gt;I often use &lt;code&gt;#&lt;/code&gt; key to quickly search for a keyword. I want to change the case of the last searched pattern in the easiest possible way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to do this is to use &lt;code&gt;\U\1&lt;/code&gt; in the substitution part and pressing &lt;code&gt;Ctrl-r&lt;/code&gt; followed by &lt;code&gt;/&lt;/code&gt; in the search part of the standard substitution command, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(&amp;lt;Ctrl-r&amp;gt;/\)/\U\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this is too unwieldy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some fast way to do this? That is, I press &lt;code&gt;#&lt;/code&gt; key and then 4-5 keystrokes later, I have changed the case of all the matches.&lt;/p&gt;&#xA;" OwnerUserId="9173" LastActivityDate="2018-08-09T10:34:12.760" Title="Change Case of last searched pattern" Tags="|replace|letter-case|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="16745" PostTypeId="2" ParentId="16744" CreationDate="2018-07-13T14:41:34.663" Score="3" Body="&lt;p&gt;There are two little things to change&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First &lt;code&gt;:s&lt;/code&gt; (and well as other search commands) will search the last searched pattern if we double the separator (usually &lt;code&gt;/&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Then of course, there is no longer a group. So we cannot use &lt;code&gt;\1&lt;/code&gt;. Fortunately, there is the &lt;em&gt;match everything&lt;/em&gt; group: &lt;code&gt;\0&lt;/code&gt;, or its shortcut: &lt;code&gt;&amp;amp;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Hence:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s//\U&amp;amp;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-07-13T14:41:34.663" CommentCount="0" CommunityOwnedDate="2018-07-13T14:41:34.663" ContentLicense="CC BY-SA 4.0" />
  <row Id="16746" PostTypeId="2" ParentId="16744" CreationDate="2018-07-13T16:17:49.787" Score="4" Body="&lt;p&gt;You can use &lt;code&gt;gUgn&lt;/code&gt; to upper-case the next search match.  Then press &lt;code&gt;.&lt;/code&gt; repeatedly to keep changing more matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: This will not work with &lt;code&gt;'ignorecase'&lt;/code&gt; enabled (because the ignorecase setting will make &lt;code&gt;gn&lt;/code&gt; select the current match over and over again). You can toggle the setting with &lt;code&gt;:set ic!&lt;/code&gt; if needed (or add the &lt;code&gt;\C&lt;/code&gt; atom to your pattern, which will make sure that the 'ignorecase' option does not apply).&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="71" LastEditDate="2018-08-09T10:34:12.760" LastActivityDate="2018-08-09T10:34:12.760" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="16747" PostTypeId="2" ParentId="16663" CreationDate="2018-07-13T16:28:49.173" Score="0" Body="&lt;p&gt;Will adding &lt;code&gt;:silent!&lt;/code&gt; work? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead  *  silent! %s/\t/   /ge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll need to use &lt;code&gt;:silent!&lt;/code&gt;, as &lt;code&gt;:silent&lt;/code&gt; only removes normal messages (and only up to the first error).&lt;/p&gt;&#xA;" OwnerUserId="18206" LastEditorUserId="18062" LastEditDate="2018-07-13T17:23:26.407" LastActivityDate="2018-07-13T17:23:26.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16748" PostTypeId="1" AcceptedAnswerId="16749" CreationDate="2018-07-13T16:51:06.307" Score="2" ViewCount="211" Body="&lt;p&gt;I am able to do &#xA;&lt;code&gt;git log --pretty=format:&quot;%h&quot; --after=&quot;2018-06-7&quot; --until=&quot;2018-06-10&quot;&lt;/code&gt;, in the shell, but if I try to do it in vim with fugitive like this: &lt;code&gt;:Glog --after=&quot;2018-6-7&quot; --until=&quot;2018-06-10&quot; --&lt;/code&gt; nothing happens (the quickfix window is empty).  Am I passing the parameters incorrectly or is this not supported?&lt;/p&gt;&#xA;" OwnerUserId="7143" LastActivityDate="2018-07-13T17:05:18.097" Title="How to load commits in a certain date range with fugitive?" Tags="|git|plugin-fugitive|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16749" PostTypeId="2" ParentId="16748" CreationDate="2018-07-13T17:05:18.097" Score="2" Body="&lt;p&gt;Try to remove the quotes in your command.  The double quote character is the start of a comment in vimscript.  See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#:comment&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;help :comment&lt;/code&gt;&lt;/a&gt;.&#xA;So you should use &lt;code&gt;:Glog --after=2018-6-7 --until=2018-6-10&lt;/code&gt; instead.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the future: If you need to give a quoted string to a vim command you can try &lt;code&gt;'&lt;/code&gt; instead of &lt;code&gt;&quot;&lt;/code&gt; that might work better in general.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-13T17:05:18.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16750" PostTypeId="1" CreationDate="2018-07-13T23:19:54.633" Score="1" ViewCount="474" Body="&lt;p&gt;I'm setting up NeoFormat/ALEfix-style code reformatting, and I'd really like to have it automatically and fluidly reformat the code as the window is resized. This is possible for whole-viewport vim-windows with the &lt;code&gt;VimResized&lt;/code&gt; autocmd; but I see no corresponding &lt;code&gt;WinResized&lt;/code&gt; autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an efficient way to add some buffer-local behaviour (i.e. as mentioned above, running code through a width-aware reformatter) to be preformed every time a Vim &lt;em&gt;window&lt;/em&gt; is resized (i.e. &lt;code&gt;⌃w&lt;/code&gt; &lt;code&gt;=&lt;/code&gt;, &lt;code&gt;:vertical resize 100&lt;/code&gt;, et. al)&lt;/p&gt;&#xA;" OwnerUserId="6108" LastActivityDate="2018-07-14T02:08:58.210" Title="How can I automatically preform operations when a vim *window* is resized?" Tags="|vim-windows|autocmd|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16751" PostTypeId="2" ParentId="16750" CreationDate="2018-07-14T02:08:58.210" Score="1" Body="&lt;p&gt;Currently, there's no autocommand for this (although it would be very useful).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possible way to do this is to poll vim every &lt;code&gt;CursorHold&lt;/code&gt; event, and check to see if the window size has changed; the &lt;code&gt;winwidth()&lt;/code&gt; and &lt;code&gt;winheight()&lt;/code&gt; functions can give the current height of a window. By default &lt;code&gt;CursorHold&lt;/code&gt; is triggered after 4 seconds of vim receiving no input, but that can be reduced by changing the &lt;code&gt;'updatetime'&lt;/code&gt; option. Not exactly fluid but better than nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Everything marked in code blocks can be looked up in vim's help by passing it exactly as written to &lt;code&gt;:h&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="16910" LastActivityDate="2018-07-14T02:08:58.210" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16752" PostTypeId="1" CreationDate="2018-07-14T03:42:00.460" Score="0" ViewCount="285" Body="&lt;p&gt;I try to use IPython's &lt;code&gt;%cpaste&lt;/code&gt; to paste the clipboard content (Python code) to my Terminal which is launched via Neovim's terminal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I paste long lines of code, it freezes, and does not respond to my input at all. I'm forced to exit of it using keyboard interrupt, but then I could not run any code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result is like the following, and the code does not scroll toward the bottom (i.e. the part of code is cut off, as only the code that a page contains seems to be pasted).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is the &lt;code&gt;%cpaste&lt;/code&gt; command to paste my code not working and how can I fix it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/y9BEi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/y9BEi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1072" LastEditorUserId="54" LastEditDate="2023-07-28T07:19:32.883" LastActivityDate="2023-12-25T10:01:00.123" Title="IPython %cpaste command freezes in Terminal mode" Tags="|neovim|cut-copy-paste|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16753" PostTypeId="1" AcceptedAnswerId="16757" CreationDate="2018-07-14T13:30:47.443" Score="1" ViewCount="337" Body="&lt;p&gt;Also, how can I go about finding out what a sequence means? Lets say I see a command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) | exe &quot;normal! g'\&quot;&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to find  out what some sequences mean? Google does not allow searching for symbols, it just ignores them, so I rarely find anything.&lt;/p&gt;&#xA;" OwnerUserId="18213" LastActivityDate="2018-09-15T02:03:34.347" Title="What does g'\&quot;&quot; mean?" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16754" PostTypeId="1" CreationDate="2018-07-14T18:18:53.070" Score="1" ViewCount="290" Body="&lt;p&gt;I have a bunch of assembly code that needs commenting and I want to avoid having to space forward to make a comment every time just to align the comments.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;movq %rdi, %rdi      # comment&#xA;jne label            # comment&#xA;addl %esi, %esi      # comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there an easy way to do this with vanilla vim? Note the differing line lengths.&lt;/p&gt;&#xA;" OwnerUserId="18215" LastActivityDate="2018-07-14T21:01:15.393" Title="Align Righthand Side Comments" Tags="|comments|alignment|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16755" PostTypeId="2" ParentId="16754" CreationDate="2018-07-14T21:01:15.393" Score="1" Body="&lt;p&gt;I think this will accomplish what you want. During typing, press &lt;code&gt;&amp;lt;F1&amp;gt;&lt;/code&gt; to pad spaces to the 21st column as shown. You can add &lt;code&gt;#␣&lt;/code&gt; to either of these mappings to have the comment started automatically. Note that this will erase any existing comment.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F1&amp;gt; 21A &amp;lt;Esc&amp;gt;d21\|&#xA;imap &amp;lt;F1&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;F1&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The trick is taken from this question here: &lt;a href=&quot;https://stackoverflow.com/a/12412493/365478&quot;&gt;https://stackoverflow.com/a/12412493/365478&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13731" LastActivityDate="2018-07-14T21:01:15.393" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16756" PostTypeId="1" CreationDate="2018-07-14T21:57:06.577" Score="0" ViewCount="66" Body="&lt;p&gt;I am using a pluging &lt;code&gt;ctrlp-py-matcher&lt;/code&gt;, which is using the python interface to&#xA;vim. My VIM is compiled with &lt;code&gt;python3&lt;/code&gt; support&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 17, compiled Jul  1 2018 10:45:10) Included&#xA;patches: 1-42 Compiled by username@username-VirtualBox Huge version with GTK2&#xA;GUI.  Features included (+) or not (-): +acl               +farsi&#xA;+mouse_sgr         -tag_any_white +arabic            +file_in_path&#xA;-mouse_sysmouse    -tcl +autocmd           +find_in_path      +mouse_urxvt&#xA;+termguicolors -autoservername    +float             +mouse_xterm&#xA;+terminal +balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse +browse&#xA;+fork()            -mzscheme          +textobjects ++builtin_terms    +gettext&#xA;+netbeans_intg     +timers +byte_offset       -hangul_input      +num64&#xA;+title +channel           +iconv             +packages          +toolbar&#xA;+cindent           +insert_expand     +path_extra        +user_commands&#xA;+clientserver      +job               +perl              +vertsplit +clipboard&#xA;+jumplist          +persistent_undo   +virtualedit +cmdline_compl     +keymap&#xA;+postscript        +visual +cmdline_hist      +lambda            +printer&#xA;+visualextra +cmdline_info      +langmap           +profile           +viminfo&#xA;+comments          +libcall           -python            +vreplace +conceal&#xA;+linebreak         +python3           +wildignore +cryptv&#xA;+lispindent        +quickfix          +wildmenu +cscope            +listcmds&#xA;+reltime           +windows +cursorbind        +localmap          +rightleft&#xA;+writebackup +cursorshape       +lua               +ruby              +X11&#xA;+dialog_con_gui    +menu              +scrollbind        -xfontset +diff&#xA;+mksession         +signs             +xim +digraphs          +modify_fname&#xA;+smartindent       +xpm +dnd               +mouse             +startuptime&#xA;+xsmp_interact -ebcdic            +mouseshape        +statusline&#xA;+xterm_clipboard +emacs_tags        +mouse_dec         -sun_workshop&#xA;-xterm_save +eval              -mouse_gpm         +syntax +ex_extra&#xA;-mouse_jsbterm     +tag_binary +extra_search      +mouse_netterm&#xA;+tag_old_static system vimrc file: &quot;$VIM/vimrc&quot; user vimrc file: &quot;$HOME/.vimrc&quot;&#xA;2nd user vimrc file: &quot;~/.vim/vimrc&quot; user exrc file: &quot;$HOME/.exrc&quot; system gvimrc&#xA;file: &quot;$VIM/gvimrc&quot; user gvimrc file: &quot;$HOME/.gvimrc&quot; 2nd user gvimrc file:&#xA;&quot;~/.vim/gvimrc&quot; defaults file: &quot;$VIMRUNTIME/defaults.vim&quot; system menu file:&#xA;&quot;$VIMRUNTIME/menu.vim&quot; fall-back for $VIM: &quot;/usr/local/share/vim&quot; f-b for&#xA;$VIMRUNTIME: &quot;/usr/local/share/vim/vim81&quot; Compilation: gcc -c -I. -Iproto&#xA;-DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0&#xA;-I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/&#xA;-I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0&#xA;-I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12&#xA;-I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0&#xA;-I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0&#xA;-I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2   -g -O2&#xA;-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     Linking: gcc   -L.&#xA;-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic&#xA;-Wl,-export-dynamic -Wl,-E   -L/usr/local/lib -Wl,--as-needed -o vim&#xA;-lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0&#xA;-lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig&#xA;-lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl&#xA;-lselinux  -ldl  -L/usr/lib -llua5.1 -Wl,-E  -fstack-protector-strong&#xA;-L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.22/CORE -lperl -ldl -lm&#xA;-lpthread -lcrypt  -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnuconfig&#xA;-lpython3.5m  -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have this file in my folder:&#xA;&lt;a href=&quot;https://github.com/pallets/jinja/blob/master/jinja2/_identifier.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/pallets/jinja/blob/master/jinja2/_identifier.py&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I try to use &lt;code&gt;ctrlp&lt;/code&gt;, &lt;code&gt;ctrlp-py-matcher&lt;/code&gt; to navigate tags. I use &lt;code&gt;ctags&lt;/code&gt; to generate the tags files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I found that even though the correct tags were being generated, &lt;code&gt;:CtrlPTags&lt;/code&gt; wasn't showing any tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have traced it down to the file above&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/pallets/jinja/blob/master/jinja2/_identifier.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/pallets/jinja/blob/master/jinja2/_identifier.py&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which contains BOM UTF-8 header, &lt;code&gt;vim.eval&lt;/code&gt; in the &lt;code&gt;ctrlp-py-matcher&lt;/code&gt; fails.&#xA;&lt;code&gt;vim.eval('a:items')&lt;/code&gt;:&#xA;&lt;a href=&quot;https://github.com/FelikZ/ctrlp-py-matcher/blob/cf63fd546f1e80dd4db3db96afbeaad301d21f13/autoload/pymatcher.py#L7&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/FelikZ/ctrlp-py-matcher/blob/cf63fd546f1e80dd4db3db96afbeaad301d21f13/autoload/pymatcher.py#L7&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other people such as @ludovicchabant also found a similar problem and had to&#xA;work around it as shown in his fork of the &lt;code&gt;ctrlp-py-matcher&lt;/code&gt; repo, and also&#xA;post process the tags file(&lt;a href=&quot;https://ludovic.chabant.com/devblog/2017/02/25/aaa-gamedev-with-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ludovic.chabant.com/devblog/2017/02/25/aaa-gamedev-with-vim/&lt;/a&gt;) :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/ludovicchabant/ctrlp-py-matcher/blob/2f6947480203b734b069e5d9f69ba440db6b4698/autoload/pymatcher.py#L22&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ludovicchabant/ctrlp-py-matcher/blob/2f6947480203b734b069e5d9f69ba440db6b4698/autoload/pymatcher.py#L22&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further, I have verfied that I if I do remove the &lt;code&gt;BOM&lt;/code&gt; headers using the&#xA;following commands: &lt;a href=&quot;https://unix.stackexchange.com/a/381263/242983&quot;&gt;https://unix.stackexchange.com/a/381263/242983&lt;/a&gt;&#xA;from the file, &lt;code&gt;:CtrlPTag&lt;/code&gt; works fine again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I basically excluded the entire &lt;code&gt;python&lt;/code&gt; env folder to prevent these&#xA;issues. I can ofcourse, do some post-processing of &lt;code&gt;tags&lt;/code&gt; file after &lt;code&gt;ctags&lt;/code&gt;&#xA;generates the tags file and remove the BOM header, but it seems a bit hacky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best way would be if &lt;code&gt;vim.eval('a:items')&lt;/code&gt; doesn't error out, even if its&#xA;argument contains &lt;code&gt;BOM&lt;/code&gt; headers, or if there exists another function other than&#xA;&lt;code&gt;vim.eval&lt;/code&gt; which won't crash when the string it contains has &lt;code&gt;BOM&lt;/code&gt; headers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there another way or another function other than &lt;code&gt;vim.eval&lt;/code&gt; which can take&#xA;in strings which contain &lt;code&gt;BOM&lt;/code&gt; headers` and not error out?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this by design, or a bug?&lt;/p&gt;&#xA;" OwnerUserId="13848" LastEditorUserId="51" LastEditDate="2018-08-22T17:01:34.317" LastActivityDate="2018-08-22T17:01:34.317" Title="`vim.eval('a:items')` fails if 'a:items' contain `BOM HEADERs`" Tags="|vimscript|vimscript-python|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16757" PostTypeId="2" ParentId="16753" CreationDate="2018-07-14T23:04:31.887" Score="1" Body="&lt;pre&gt;&lt;code&gt;if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) | exe &quot;normal! g'\&quot;&quot; | endif`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is &lt;code&gt;if else&lt;/code&gt; statement which can be written as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) &#xA;  exe &quot;normal! g'\&quot;&quot; &#xA;endif`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The meaning of &lt;code&gt;au BufReadPost&lt;/code&gt; can be found here: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#BufReadPost&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#BufReadPost&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g'\&quot;&lt;/code&gt; means go to the mark &lt;code&gt;&quot;&lt;/code&gt;, but don't change the jumplist when                        jumping within the current buffer as pointed out here: &lt;a href=&quot;https://vimhelp.appspot.com/motion.txt.html#mark-motions&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vimhelp.appspot.com/motion.txt.html#mark-motions&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the mark &lt;code&gt;&quot;&lt;/code&gt; indicates: &lt;em&gt;jump to position where last exited current buffer&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you ran &lt;code&gt;g'&quot;&lt;/code&gt; in normal mode in VIM it would work fine, but you are running a normal mode command in &lt;code&gt;Ex&lt;/code&gt;mode, which is why you need to use the &lt;code&gt;\&lt;/code&gt; to escape the &lt;code&gt;&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13848" LastEditorUserId="13848" LastEditDate="2018-09-15T02:03:34.347" LastActivityDate="2018-09-15T02:03:34.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16758" PostTypeId="2" ParentId="16752" CreationDate="2018-07-14T23:13:14.787" Score="0" Body="&lt;p&gt;Have you tried &lt;code&gt;%paste&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried it in VIM terminal and &lt;code&gt;%paste&lt;/code&gt; works for me in &lt;code&gt;VIM-8 terminal&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-07-14T23:13:14.787" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16759" PostTypeId="2" ParentId="16675" CreationDate="2018-07-14T23:18:54.980" Score="-1" Body="&lt;p&gt;I use &lt;code&gt;Ctrlp&lt;/code&gt; as its likely to be much  more stable and bugfree and pretty comparable to fzf (with &lt;code&gt;ctrlp-py-matcher&lt;/code&gt;), and probably lot more options for customization: &lt;a href=&quot;https://github.com/weiliu89/dotfiles/blob/master/.vim/doc/ctrlp.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/weiliu89/dotfiles/blob/master/.vim/doc/ctrlp.txt&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;fzf.vim&lt;/code&gt; also seems to have default bindings: &lt;a href=&quot;https://github.com/junegunn/fzf.vim/issues/56&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/junegunn/fzf.vim/issues/56&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully, &lt;code&gt;fzf&lt;/code&gt; will be integrated to &lt;code&gt;ctrlp&lt;/code&gt; someday soon..&lt;/p&gt;&#xA;" OwnerUserId="13848" LastEditorUserId="13848" LastEditDate="2018-07-14T23:54:28.243" LastActivityDate="2018-07-14T23:54:28.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16760" PostTypeId="2" ParentId="16611" CreationDate="2018-07-14T23:30:08.493" Score="1" Body="&lt;p&gt;As @muru has suggested, I will post the solution here..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The situation happened, when I was trying to debug a issue related to a plugin. It seemed to work for a colleague, but not for me. So one of the hypothesis was that it was because of the differing versions of VIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the VIM version (8.0.1430) was compiled from source, I had the exact SHA id of the VIM version written down, and I also knew the SHA ID that I wanted to install.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My colleague was running VIM version (8.1.42).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first attempt at removing VIM, was to just get the source from GitHub, and follow the steps: &lt;a href=&quot;https://superuser.com/questions/623040/uninstalling-vim-compiled-from-source&quot;&gt;https://superuser.com/questions/623040/uninstalling-vim-compiled-from-source&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to uninstall VIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the command &lt;code&gt;vim&lt;/code&gt; was no longer working, I thought that &lt;code&gt;VIM&lt;/code&gt; had been properly installed. So I proceeded to install vim_v_8.1.0042. The vim source code from GitHub has tags associated with each release. So based on that I could figure out the SHA ide of the v_8.1.0042, and installed it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is when I realized the &lt;code&gt;VIM80&lt;/code&gt; folder is still present.. and pretty large.. and maybe indicates that &lt;code&gt;VIM8.0&lt;/code&gt; hasn't actually been completely removed. I also noticed that &lt;code&gt;VIM8.1&lt;/code&gt; was being installed in &lt;code&gt;VIM81&lt;/code&gt; directory. So I uninstalled &lt;code&gt;VIM8.1&lt;/code&gt; properly and then proceeded to install &lt;code&gt;VIM8.0.1430&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This left the same direction &lt;code&gt;VIM80&lt;/code&gt;.. which confirmed that the version number was determining what directory &lt;code&gt;VIM&lt;/code&gt; puts in the system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After I uninstalled &lt;code&gt;VIM8.0&lt;/code&gt;, the &lt;code&gt;VIM80&lt;/code&gt; directory was gone as well as &lt;code&gt;vim&lt;/code&gt; didn't startup the &lt;code&gt;vim&lt;/code&gt; editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By this process I was able to uninstall &lt;code&gt;VIM80&lt;/code&gt;, even though I couldn't uninstall it in the beginning.&lt;/p&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-07-14T23:30:08.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16761" PostTypeId="2" ParentId="363" CreationDate="2018-07-15T08:33:04.180" Score="12" Body="&lt;p&gt;&lt;strong&gt;If you don't want to install any plugins and you want to edit tables keeping the alignment:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;-- use the built in &lt;strong&gt;VREPLACE&lt;/strong&gt; mode, activated by &lt;code&gt;gR&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;(Make sure you has vim latest version, and check if it's compiled with &lt;code&gt;+vreplace&lt;/code&gt; feature, typing &lt;code&gt;vim --version&lt;/code&gt; on the terminal)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/d3oKl.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/d3oKl.gif&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;&lt;em&gt;(my statusline is set to show REPLACE for both REPLACE and VREPLACE modes)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you want to know more about the &lt;strong&gt;REPLACE&lt;/strong&gt; and &lt;strong&gt;VREPLACE&lt;/strong&gt; modes, check out &lt;a href=&quot;https://medium.com/vim-drops/replace-and-virtual-replace-modes-3e841b9161ca&quot; rel=&quot;nofollow noreferrer&quot;&gt;my article&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15921" LastEditorUserId="20012" LastEditDate="2022-07-05T20:48:20.513" LastActivityDate="2022-07-05T20:48:20.513" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16762" PostTypeId="2" ParentId="16684" CreationDate="2018-07-15T14:57:31.620" Score="4" Body="&lt;p&gt;&lt;code&gt;:h args&lt;/code&gt; has the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    `If you give more than one file name when starting Vim, this list is&#xA;    remembered as the argument list.  You can jump to each file in this&#xA;    list.&#xA;&#xA;    Do not confuse this with the buffer list, which you can see with the&#xA;    |:buffers| command.  The argument list was already present in Vi, the&#xA;    buffer list is new in Vim.  Every file name in the argument list will&#xA;    also be present&#xA;    in the buffer list (unless it was deleted with |:bdel| or |:bwipe|).  But it's&#xA;    common that names in the buffer list are not in the argument list.`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it seems adding files to a &lt;code&gt;args list&lt;/code&gt; also adds it to the &lt;code&gt;buffers list&lt;/code&gt;. As mentioned in the docs... perhaps you can use &lt;code&gt;:bdel&lt;/code&gt; to delete them from the &lt;code&gt;args&lt;/code&gt; list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ref:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#argument-list&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimhelp.appspot.com/editing.txt.html#argument-list&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13848" LastActivityDate="2018-07-15T14:57:31.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16763" PostTypeId="1" CreationDate="2018-07-15T19:07:20.517" Score="1" ViewCount="1209" Body="&lt;p&gt;A while back I started using &lt;code&gt;guioptions +=k&lt;/code&gt; to (from &lt;code&gt;help guioptions&lt;/code&gt;): &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Keep the GUI window size when adding/removing a scrollbar, or&#xA;        toolbar, tabline, etc.  Instead, the behavior is similar to         when&#xA;  the window is maximized and will adjust 'lines' and       'columns' to fit&#xA;  to the window.  Without the 'k' flag Vim will         try to keep 'lines'&#xA;  and 'columns' the same when adding and        removing GUI components.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, now I can't seem to turn it off, and it may (or may not) be responsible for a problem: If I use a command such as &lt;code&gt;:pwd&lt;/code&gt; the response immediately disappears as the bottom of the window does a little spasm and replaces the command output with the line that ends, e.g., &quot;1,0-1  All&quot; (dunno what that is called).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same goes for things such as error messages -- all I see is a red flash and there is no time to read them.  Fortunately, &lt;code&gt;:messages&lt;/code&gt; works, so I can find out what they were. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I notice &lt;code&gt;help error&lt;/code&gt; mentions there is a limit to how long some messages will appear, but no means to set that.  I don't have this problem in non-GUI vim, in which case the output remains visible until I access the command line again.&lt;/p&gt;&#xA;" OwnerUserId="4913" LastEditorUserId="4913" LastEditDate="2018-07-15T19:12:32.343" LastActivityDate="2018-10-01T18:16:40.877" Title="Command line messages disappear in a flash" Tags="|gvim|message|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16764" PostTypeId="1" CreationDate="2018-07-16T04:36:02.920" Score="6" ViewCount="3140" Body="&lt;p&gt;Here is a situation: I want to manage my working environment on multiple projects separately, and all of them should have its own session (&lt;code&gt;Session.vim&lt;/code&gt;) to save and restore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I would like to launch each project via &lt;code&gt;nvim -S SESSION_FILE&lt;/code&gt;. And in order to save and quit easily, I define the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;q :mksession! ~/.config/nvim/session.vim&amp;lt;cr&amp;gt;:wqa&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I want to set the &lt;code&gt;SESSION_FILE&lt;/code&gt; to some variable in the vimrc at the launch time automatically, and then quit via &lt;code&gt;&amp;lt;leader&amp;gt;q&lt;/code&gt; whatever the current project is, by replacing the &lt;code&gt;~/.config/nvim/session.vim&lt;/code&gt; to the variable I read via the command-line argument. However, I'm not sure how I can extract the command-line argument that is executed on Terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I read the command-line argument from the launch and set it in the vimrc while the vim is working, and then when it quits, it automatically save the session file that is specific to the current project?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2019-10-29T08:33:34.297" Title="How can I read a command-line argument in vimrc?" Tags="|invocation|sessions|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16766" PostTypeId="2" ParentId="16764" CreationDate="2018-07-16T06:09:03.277" Score="0" Body="&lt;p&gt;There might be an easier way than checking the command line arguments.  Depending on the value of &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;ssop&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;sessionoptions&lt;/code&gt;&lt;/a&gt; you can save vim variables in your session.vim file with &lt;code&gt;:mks&lt;/code&gt; so you just need to set your variable in the running session (instead of the vimrc file) and it will be restored together with the session:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:MySessionFile = '~/.config/nvim/session_foo.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can define the mapping in your vimrc like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;q :exe &quot;mksession! &quot; . g:MySessionFile &amp;lt;BAR&amp;gt; wqall&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&#xA;If you want to save your session file &lt;em&gt;every&lt;/em&gt; time you quit and do not want to learn your new mapping you can set up a &lt;code&gt;VimLeave&lt;/code&gt; autocmd to save the session file when the variable from above exists. Something like this (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au VimLeave * &#xA;  \ if exists('g:MySessionFile') |&#xA;  \   exe &quot;mksession! &quot; . g:MySessionFile |&#xA;  \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18062" LastEditorUserId="18062" LastEditDate="2018-07-16T06:15:56.893" LastActivityDate="2018-07-16T06:15:56.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16767" PostTypeId="1" CreationDate="2018-07-16T11:45:48.077" Score="0" ViewCount="48" Body="&lt;p&gt;I just noticed that my current box with vim is missing a crucial feature, but I am unable to bring it back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A long time ago I had a vim setup where I could press &lt;code&gt;Ctrl+J&lt;/code&gt; (IIRC) and then my cursor would jump to the next occurance of &lt;code&gt;&amp;lt;++&amp;gt;&lt;/code&gt;. Actually, this was sort of a template system where I could put a name between the &lt;code&gt;+&lt;/code&gt; signs, to tell me/the user about the information that has to go there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance I could copy paste the following text to any new document:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hello &amp;lt;+name+&amp;gt;,&#xA;how are you today? I am feeling &amp;lt;+feeling+&amp;gt;.&#xA;Hope to hear from you soon&#xA;&amp;lt;+signature+&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then I could &lt;code&gt;Ctrl+J&lt;/code&gt; and vim would jump to &lt;code&gt;&amp;lt;+name+&amp;gt;&lt;/code&gt; in insert mode and with my typing I would overwrite &lt;code&gt;&amp;lt;+name+&amp;gt;&lt;/code&gt;. Then I'd press &lt;code&gt;Ctrl+J&lt;/code&gt; again and vim would jump to &lt;code&gt;&amp;lt;+feeling+&amp;gt;&lt;/code&gt; in insert mode so that I could overwrite that and so on and so forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody know that functionality and how I can install it on my current machine? I am fairly certain I did not code that myself ...&lt;/p&gt;&#xA;" OwnerUserId="5959" LastActivityDate="2018-07-16T11:53:13.863" Title="Template plugin(?) to jump to next occurance of '&lt;++&gt;'" Tags="|cursor-movement|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16768" PostTypeId="2" ParentId="16767" CreationDate="2018-07-16T11:53:13.863" Score="1" Body="&lt;p&gt;I remember two plugins with this feature:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vim-latex implements jump on &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;li&gt;my &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-brackets&lt;/a&gt; plugin implements jump on &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt; with vim, or on &lt;code&gt;&amp;lt;m-del&amp;gt;&lt;/code&gt; with gvim -- default keybindings can be changed. &lt;a href=&quot;https://github.com/LucHermitte/mu-template&quot; rel=&quot;nofollow noreferrer&quot;&gt;mu-template&lt;/a&gt; that relies on lh-brackets exploits this feature to implement its placeholders.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;PS: I don't provide here the underlying code as it's quite complex, and not that trivial to implement correctly.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-07-16T11:53:13.863" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16769" PostTypeId="1" AcceptedAnswerId="16771" CreationDate="2018-07-16T16:30:07.383" Score="3" ViewCount="1631" Body="&lt;p&gt;I'm using Vim on Fedora 28 and Python seems to be enabled:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version&#xA;VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul 11 2018 10:00:51)&#xA;Included patches: 1-177&#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               +farsi             +mouse_sgr         -tag_any_white&#xA;+arabic            +file_in_path      -mouse_sysmouse    -tcl&#xA;+autocmd           +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       +terminal&#xA;-balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;-browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    +gettext           +netbeans_intg     +timers&#xA;+byte_offset       -hangul_input      +num64             +title&#xA;+channel           +iconv             +packages          -toolbar&#xA;+cindent           +insert_expand     +path_extra        +user_commands&#xA;-clientserver      +job               +perl/dyn          +vartabs&#xA;-clipboard         +jumplist          +persistent_undo   +vertsplit&#xA;+cmdline_compl     +keymap            +postscript        +virtualedit&#xA;+cmdline_hist      +lambda            +printer           +visual&#xA;+cmdline_info      +langmap           +profile           +visualextra&#xA;+comments          +libcall           +python/dyn        +viminfo&#xA;+conceal           +linebreak         +python3/dyn       +vreplace&#xA;+cryptv            +lispindent        +quickfix          +wildignore&#xA;+cscope            +listcmds          +reltime           +wildmenu&#xA;+cursorbind        +localmap          +rightleft         +windows&#xA;+cursorshape       +lua/dyn           +ruby/dyn          +writebackup&#xA;+dialog_con        +menu              +scrollbind        -X11&#xA;+diff              +mksession         +signs             -xfontset&#xA;+digraphs          +modify_fname      +smartindent       -xim&#xA;-dnd               +mouse             +startuptime       -xpm&#xA;-ebcdic            -mouseshape        +statusline        -xsmp&#xA;+emacs_tags        +mouse_dec         -sun_workshop      -xterm_clipboard&#xA;+eval              +mouse_gpm         +syntax            -xterm_save&#xA;+ex_extra          -mouse_jsbterm     +tag_binary        &#xA;+extra_search      +mouse_netterm     +tag_old_static    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hovewer, when I open Vim and issue &lt;code&gt;:echo has('python')&lt;/code&gt; it returns 0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both Python 2.x and 3.x version are installed on Fedora by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestion?&lt;/p&gt;&#xA;" OwnerUserId="18231" LastEditorUserId="51" LastEditDate="2018-08-22T17:01:46.353" LastActivityDate="2023-05-04T03:20:00.200" Title="Vim is unable to find Python" Tags="|linux|vimscript-python|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16770" PostTypeId="2" ParentId="15682" CreationDate="2018-07-16T18:25:28.300" Score="3" Body="&lt;p&gt;I recently wrote a plugin for this called &lt;a href=&quot;https://github.com/mogelbrod/vim-jsonpath&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-jsonpath&lt;/a&gt;. It currently provides the following (mappable) commands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:JsonPath&lt;/code&gt;: Echoes the path to the identifier under the cursor.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:JsonPath path.to.prop&lt;/code&gt;: Searches the active buffer for the given path, placing the cursor on it if found.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18233" LastActivityDate="2018-07-16T18:25:28.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16771" PostTypeId="2" ParentId="16769" CreationDate="2018-07-16T18:52:38.827" Score="5" Body="&lt;p&gt;Have a look at &lt;code&gt;:help python3&lt;/code&gt; and the subsequent sections on &lt;code&gt;python-2-and-3&lt;/code&gt; and &lt;code&gt;pythonx&lt;/code&gt;. If python is compiled with &lt;code&gt;+python/dyn, +python3/dyn&lt;/code&gt;, then it effectively has support for Python 2 and 3.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Checking available version.&lt;/h2&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can test what Python version is available with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   if has('python')&#xA;    echo 'there is Python 2.x'&#xA;   endif&#xA;   if has('python3')&#xA;     echo 'there is Python 3.x'&#xA;   endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h2&gt;Checking the version which was compiled with Vim without loading Python&lt;/h2&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note however, that when Python 2 and 3 are both available and loaded&#xA;  dynamically, these has() calls will try to load them.  If only one can be&#xA;  loaded at a time, just checking if Python 2 or 3 are available will prevent&#xA;  the other one from being available.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;To avoid loading the dynamic library, only check if Vim was compiled with&#xA;  python support:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if has('python_compiled')&#xA;   echo 'compiled with Python 2.x support'&#xA;   if has('python_dynamic')&#xA;     echo 'Python 2.x dynamically loaded'&#xA;   endif&#xA; endif&#xA; if has('python3_compiled')&#xA;   echo 'compiled with Python 3.x support'&#xA;   if has('python3_dynamic')&#xA;     echo 'Python 3.x dynamically loaded'&#xA;   endif&#xA; endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h2&gt;Using pyx&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;pyx&lt;/code&gt; in the place of &lt;code&gt;python2&lt;/code&gt; or &lt;code&gt;python3&lt;/code&gt; will automatically select the version set by &lt;code&gt;pyxversion&lt;/code&gt;.&#xA;This also provides another way to check the version.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To see what version of Python is being used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :pyx import sys&#xA; :pyx print(sys.version)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="17170" LastEditorUserId="18062" LastEditDate="2018-07-16T18:59:33.813" LastActivityDate="2018-07-16T18:59:33.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16773" PostTypeId="1" AcceptedAnswerId="16775" CreationDate="2018-07-16T20:28:52.817" Score="1" ViewCount="721" Body="&lt;p&gt;I changed my &lt;kbd&gt;Caps Lock&lt;/kbd&gt; key to &lt;kbd&gt;Ctrl&lt;/kbd&gt;, and as I'm still getting used to it I sometimes enter combinations I didn't intend to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While in insert mode typing, having already written most of a long sentence, I accidentally pressed &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;U&lt;/kbd&gt;, which deleted all the characters I had typed so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to undo this and get those characters back, without retyping them?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="4472" LastEditDate="2018-07-17T02:07:05.700" LastActivityDate="2018-07-17T02:07:05.700" Title="How to undo the deletion of characters in insert mode caused by Ctrl-U?" Tags="|undo-redo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16774" PostTypeId="1" AcceptedAnswerId="16777" CreationDate="2018-07-16T20:51:52.283" Score="1" ViewCount="2774" Body="&lt;p&gt;Suppose I want to search for things like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\todo{English sentence}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the regex&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\\todo{\_.\{-}}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;works (I don't know why. I copied it from somewhere long time ago (embarrassed)).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But suppose I want to match things like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\todo{anything whatsoever}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the above regex is no good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I have&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\todo{The problem is caused because of {another} pair of braces inside}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The previous regex just matches&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\todo{The problem is caused because of {another}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the correct regex, and if possible, can someone break it down a little bit? Things like &lt;code&gt;\_.\{-}&lt;/code&gt; already seem to make no sense!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Big thanks.&lt;/p&gt;&#xA;" OwnerUserId="2369" LastActivityDate="2018-07-23T07:14:46.857" Title="How to match braces or brackets?" Tags="|regular-expression|search|delimiter-matching|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16775" PostTypeId="2" ParentId="16773" CreationDate="2018-07-16T22:15:14.487" Score="3" Body="&lt;p&gt;You can't recover the words you've already lost, but we can make &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; an undo-able motion by remapping it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-u&amp;gt; &amp;lt;c-g&amp;gt;u&amp;lt;c-u&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is from &lt;a href=&quot;https://github.com/tpope/vim-sensible/blob/c82c6d4978be28adcf85dc1e61fa428e801bd525/plugin/sensible.vim#L96&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sensible&lt;/a&gt;. See &lt;code&gt;:h i_CTRL-G_u&lt;/code&gt;; essentially, the &lt;code&gt;&amp;lt;c-g&amp;gt;u&lt;/code&gt; causes vim to 'break' the change at that point, meaning you can undo back to that point.&lt;/p&gt;&#xA;" OwnerUserId="16910" LastActivityDate="2018-07-16T22:15:14.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16777" PostTypeId="2" ParentId="16774" CreationDate="2018-07-17T15:48:13.803" Score="3" Body="&lt;p&gt;Per the help pages in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\{-}    matches 0 or more of the preceding atom, as few as possible&#xA;*       Matches 0 or more of the preceding atom, as many as possible.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my small test case replacing the former with the latter matched your example string. That is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\\todo{\_.*}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="599" LastActivityDate="2018-07-17T15:48:13.803" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16779" PostTypeId="1" AcceptedAnswerId="16781" CreationDate="2018-07-17T18:11:22.070" Score="1" ViewCount="83" Body="&lt;p&gt;I want to be able to write my own custom escape method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I want to paste the contents of register &lt;code&gt;s&lt;/code&gt; while in insert mode, I can type &lt;code&gt;&amp;lt;C-R&amp;gt;s&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I want to escape all occurrences of &lt;code&gt;\&lt;/code&gt;, I can type &lt;code&gt;&amp;lt;C-R&amp;gt;=escape(@s, '\')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I paste the contents of register &lt;code&gt;s&lt;/code&gt; while executing an arbitrary formatting function?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Extra information:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The end goal is to be able to hit a key and append a function declaration from a &lt;code&gt;.c&lt;/code&gt; file to a register. &lt;code&gt;void MyClass::foo() {&lt;/code&gt; will turn into &lt;code&gt;void foo();&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I plan to solve this by writing an &lt;code&gt;=escape&lt;/code&gt;-esque function that deletes words starting with capital letters, and does the equivalent of &lt;code&gt;:substitute/ *{$/;/&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14861" LastActivityDate="2018-07-18T05:20:37.817" Title="How to edit a register in normal mode from a script" Tags="|register|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16780" PostTypeId="2" ParentId="16764" CreationDate="2018-07-17T20:50:42.713" Score="1" Body="&lt;p&gt;If you're willing to roll your own argument parsing by abusing file names, then &lt;code&gt;vim&lt;/code&gt; has the functions &lt;code&gt;argc&lt;/code&gt; and &lt;code&gt;argv&lt;/code&gt; that mimic the API of &lt;code&gt;main&lt;/code&gt; in C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;argc&lt;/code&gt; returns the number of arguments (besides the 0th one, the name under which &lt;code&gt;vim&lt;/code&gt; was invoked).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;argv()&lt;/code&gt; returns the arguments as an array of strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;argv(n)&lt;/code&gt; returns the nth element of the array of strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim a b c d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;within &lt;code&gt;vim&lt;/code&gt;, if you run the following commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo argc()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also &lt;code&gt;:help arglist&lt;/code&gt;.&#xA;    4&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo argv()&#xA;['a', 'b', 'c', 'd']&#xA;&#xA;:echo argv(0)&#xA;a&#xA;&#xA;:echo argv(27)&#xA;&amp;lt;empty string&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you cannot use this to implement options beginning with &lt;code&gt;-&lt;/code&gt; because those are handled before vimscript gets a chance to see the arguments. But you can pick another convention like &lt;code&gt;key=value&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2018-07-17T20:50:42.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16781" PostTypeId="2" ParentId="16779" CreationDate="2018-07-17T21:00:21.070" Score="1" Body="&lt;p&gt;If you can define it all in one &lt;code&gt;substitute&lt;/code&gt; all then replace the &lt;code&gt;escape&lt;/code&gt;, since that can be any function. &lt;code&gt;&amp;lt;C-R&amp;gt;=substitute(@s, '\m\(\w\+\) \w\+::\([^{]\+\) {', '\1 \2;', '')&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to do it all in one &lt;code&gt;substitute&lt;/code&gt;, or to give it a descriptive name, you can write your own function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FunctionDeclaration(snip)&#xA;  return substitute(a:snip, '\m\(\w\+\) \w\+::\([^{]\+\) {', '\1 \2;', '')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then invoke it with &lt;code&gt;&amp;lt;C-R&amp;gt;=FunctionDeclaration(@s)&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help user-functions&lt;/code&gt; for defining your own function like &lt;code&gt;FunctionDeclaration&lt;/code&gt; above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help substitute()&lt;/code&gt; for how to perform a regex substitution against a variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The breakdown of the regex suggested above:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\m&lt;/code&gt; - Enable &lt;code&gt;magic&lt;/code&gt; so that the regex behavior is not impacted by user settings. See &lt;code&gt;:help magic&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(\w\+\)&lt;/code&gt; - Match a series of one or more &quot;word characters&quot;. Matches the &lt;code&gt;void&lt;/code&gt; in the example. See &lt;code&gt;:help \w&lt;/code&gt;. Capture the result of that part of the match into the first match group. See &lt;code&gt;:help pattern-overview&lt;/code&gt;. This can be referenced with &lt;code&gt;\1&lt;/code&gt; in the replacement.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\w\+::&lt;/code&gt; - Match a series of one or more &quot;word characters&quot; followed by &lt;code&gt;::&lt;/code&gt;. This matches the &lt;code&gt;MyClass::&lt;/code&gt; in the example. This is not matched in a subgroup so it will be dropped in the replacement.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\([^{]+\)&lt;/code&gt; - Match a series of characters which are not &lt;code&gt;{&lt;/code&gt; in a subgroup. This matches the &lt;code&gt;foo()&lt;/code&gt; in the example. Can be reference by &lt;code&gt;\2&lt;/code&gt; in the replacement.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;{&lt;/code&gt; - Match the literal &lt;code&gt;{&lt;/code&gt; at the end. Not matched in a subgroup&#xA;so it is dropped.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11135" LastEditorUserId="11135" LastEditDate="2018-07-18T05:20:37.817" LastActivityDate="2018-07-18T05:20:37.817" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16782" PostTypeId="1" CreationDate="2018-07-17T23:15:42.517" Score="1" ViewCount="266" Body="&lt;pre&gt;&lt;code&gt;&amp;lt;S-DOWN&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Moves the cursor back a few characters. But not always by the same amount.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;S-UP&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Moves the cursor to the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;S-LEFT&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Deletes the next two lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;S-RIGHT&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Deletes the next two lines, adds empty line, enters insert mode at said empty line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This happens in any mode, visual, insert and normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at h:index, it says noting about this behavior. If I enter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unmap &amp;lt;S-LEFT&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or any other mentioned command, I am prompted with the &quot;no mapping&quot; message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea what is happening, and how to prevent it?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;EDIT&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I also tried adding&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map ^[[1;2B &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where ^[[1;2B is the result of pressing Ctrl+v . But than, upon pressing  I am prompted with&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E486: Pattern not found: &#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Also note that after adding such mapping for all the combinations, the&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;S-UP&amp;gt;&#xA;&amp;lt;S-LEFT&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;work, meaning, they do nothing. But for&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;S-DOWN&amp;gt;&#xA;&amp;lt;S-LEFT&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am prompted with the message&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E486: Pattern not found: &#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18213" LastEditorUserId="18213" LastEditDate="2018-07-17T23:30:36.243" LastActivityDate="2018-08-17T00:01:05.970" Title="&lt;S-Arrows&gt; weird behavior (&lt;S-UP&gt;,&lt;S-DOWN&gt;,&lt;S-LEFT&gt;,&lt;S-RIGHT&gt;)" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16783" PostTypeId="2" ParentId="16782" CreationDate="2018-07-17T23:42:35.703" Score="1" Body="&lt;p&gt;As I have found the solution in the mean time, I will post it here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One should set for vim what the correct escape keys are. In my sitution, this means that I had to add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;S-UP&amp;gt;=[1;2A&#xA;set &amp;lt;S-DOWN&amp;gt;=[1;2B&#xA;set &amp;lt;S-LEFT&amp;gt;=[1;2D&#xA;set &amp;lt;S-RIGHT&amp;gt;=[1;2C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into the .vimrc. The rhs is generated by pressing Ctrl+v+. Now the sequences behave as specified in the h:index.&lt;/p&gt;&#xA;" OwnerUserId="18213" LastActivityDate="2018-07-17T23:42:35.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16785" PostTypeId="1" AcceptedAnswerId="16796" CreationDate="2018-07-18T10:20:37.863" Score="1" ViewCount="317" Body="&lt;p&gt;Say I want to search for multiple lines (or do anything with them in the command line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I yank some lines and enter search mode (&lt;kbd&gt;/&lt;/kbd&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I press &lt;kbd&gt;Ctrl + r&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt; to paste what I just yanked, but I get &lt;code&gt;^M&lt;/code&gt; for the line breaks so the search is unsuccessful unless I change the &lt;code&gt;^M&lt;/code&gt; to &lt;code&gt;\n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is on ubuntu using awesomewm and st terminal.&#xA;I suspect it could be an issue with my terminal as opposed to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a gif illustrating this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/H3vyH.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/H3vyH.gif&quot; alt=&quot;Here is a gif illustrating this&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18247" LastEditorUserId="1841" LastEditDate="2018-07-18T11:36:18.970" LastActivityDate="2018-07-19T10:02:22.137" Title="Pasting from register to command line inserts ^M instead of new line" Tags="|search|command-line|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16786" PostTypeId="1" CreationDate="2018-07-18T11:31:46.227" Score="0" ViewCount="2893" Body="&lt;p&gt;I can resize horizontal split windows by &lt;code&gt;ctrl-w-shift-&amp;lt;&lt;/code&gt; and &lt;code&gt;ctrl-w-shift-&amp;gt;&lt;/code&gt;. I would like to have a shortcut for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Close to the topic, recently I learned about the following maps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-j&amp;gt; &amp;lt;C-w&amp;gt;j&#xA;nnoremap &amp;lt;C-k&amp;gt; &amp;lt;C-w&amp;gt;k&#xA;nnoremap &amp;lt;C-h&amp;gt; &amp;lt;C-w&amp;gt;h&#xA;nnoremap &amp;lt;C-l&amp;gt; &amp;lt;C-w&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-\&amp;lt;&amp;gt; &amp;lt;C-w&amp;gt;\&amp;lt;&#xA;nnoremap &amp;lt;C-\&amp;gt;&amp;gt; &amp;lt;C-w&amp;gt;\&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it seems not to be working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While waiting for an answer I'm using &lt;a href=&quot;https://vi.stackexchange.com/users/227/john-om&quot;&gt;@john-mo&lt;/a&gt; mouse approach from &lt;a href=&quot;https://vi.stackexchange.com/questions/514/how-do-i-change-the-current-splits-width-and-height&quot;&gt;How do I change the current split&amp;#39;s width and height?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18250" LastEditorUserId="18250" LastEditDate="2018-07-18T11:45:55.310" LastActivityDate="2018-12-17T22:04:04.670" Title="vim split horizontal resize shortcut" Tags="|key-bindings|vim-windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16789" PostTypeId="1" CreationDate="2018-07-18T20:34:29.587" Score="0" ViewCount="169" Body="&lt;p&gt;If I issue the following command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ls  sb.ovpn | xargs  vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The classic vim opens the sb.ovpn file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if I do the same but with neovim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ls  sb.ovpn | xargs nvim -&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That does not work as I expected, opens a new file instead (without dash does not work either). ¿Why? ¿Is that the expected behavior of nvim?&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2018-07-20T10:15:13.443" Title="neovim does not work after a &quot;| xargs&quot;" Tags="|neovim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16795" PostTypeId="1" CreationDate="2018-07-19T06:15:34.473" Score="20" ViewCount="30533" Body="&lt;p&gt;I could create a terminal with vim by running &lt;code&gt;:term&lt;/code&gt; in the vim normal mode. However, this terminal is opened at the top of the window and I would like to open it in the bottom. How could I open it at the bottom?&#xA; By the way, how could I change the height of this window?&lt;/p&gt;&#xA;" OwnerUserId="18259" LastActivityDate="2021-08-14T20:41:19.127" Title="How could I create a terminal at the bottom" Tags="|terminal|terminal-buffer|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16796" PostTypeId="2" ParentId="16785" CreationDate="2018-07-19T10:02:22.137" Score="0" Body="&lt;p&gt;You can edit the contents of the register like this to escape the newlines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @0=substitute(@0, '\n', '\\n', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then just do your command like normal using Ctrl-R.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I rarely run into this use case so I guess this is good enough, but I still don't understand why vim behaves like this so would be great if someone else has a better solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could add this to a function in your vimrc to do the substitution and then search if you liked, but I prefer not to add too much custom stuff so that when I log onto other systems I don't need to depend on having my vimrc.&lt;/p&gt;&#xA;" OwnerUserId="18247" LastActivityDate="2018-07-19T10:02:22.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16797" PostTypeId="2" ParentId="12004" CreationDate="2018-07-19T10:10:08.010" Score="3" Body="&lt;p&gt;You can also copy your content and create a new window&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ctrl-w n ........... create a new window&#xA;p .................. paste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can save as you want&lt;/p&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2018-07-19T10:10:08.010" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16798" PostTypeId="2" ParentId="12255" CreationDate="2018-07-19T12:00:29.377" Score="2" Body="&lt;p&gt;Function name should start from capital letter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:is_tagbar=0&#xA;&#xA;function Adjust_tagbar_width()&#xA;&#xA;    if (g:is_tagbar==0)&#xA;      let g:is_tagbar=1&#xA;      set columns=120&#xA;    else&#xA;      let g:is_tagbar=0&#xA;      set columns=80&#xA;    endif&#xA;endfunction&#xA;&#xA;nmap &amp;lt;F9&amp;gt; :TagbarToggle&amp;lt;CR&amp;gt; :exec Adjust_tagbar_width() &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18264" LastEditorUserId="25" LastEditDate="2018-07-19T16:48:39.107" LastActivityDate="2018-07-19T16:48:39.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16799" PostTypeId="1" AcceptedAnswerId="16802" CreationDate="2018-07-19T13:50:43.947" Score="1" ViewCount="41" Body="&lt;p&gt;Imagine a situation, where you remember, that you want to re-use something&#xA;you have deleted a while ago. Most likely the thing that has been deleted is stored in one of the numeric registers. Usually it's not a big deal to just type &lt;code&gt;:reg&lt;/code&gt; and start looking through the list. However, I often find myself in a situation, where many of the registers are similar, and finding the register I want to use is difficult. Or it might be the case that I have yanked something to a permanent register but just can't remember which one it was. In these kind of situations I would find it quite useful to &#xA;be able to search the registers: if I remember that the line I want to re-use contains the word &lt;code&gt;function&lt;/code&gt; I would like be able get a list of just the registers containing that word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? Perhaps with a plugin I'm not aware of?&lt;/p&gt;&#xA;" OwnerUserId="7784" LastActivityDate="2018-07-19T14:38:30.360" Title="Limiting the output of `reg` to only those matching a string" Tags="|register|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16800" PostTypeId="2" ParentId="16795" CreationDate="2018-07-19T13:59:25.303" Score="14" Body="&lt;p&gt;In your ~/.vimrc add the line&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set splitbelow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will cause all splits to happen below (including terminal).&lt;/p&gt;&#xA;&lt;p&gt;To change the height of the terminal (row x col)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set termwinsize=10x0 &amp;quot; 'termsize' didn't work - this did for me (GVIM 8.2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18265" LastEditorUserId="34870" LastEditDate="2021-08-14T20:41:19.127" LastActivityDate="2021-08-14T20:41:19.127" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16801" PostTypeId="2" ParentId="16799" CreationDate="2018-07-19T14:07:18.227" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/Shougo/denite.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;denite plugin&lt;/a&gt; can give you a list off all registers and you can type keys to narrow it down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant command is &lt;code&gt;Denite register&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has many more lists/sources where you can select one and expect a reasonable action to be taken (buffers, files, commands, colorschemes, help topics, ...)&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-19T14:07:18.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16802" PostTypeId="2" ParentId="16799" CreationDate="2018-07-19T14:13:41.763" Score="0" Body="&lt;p&gt;First, we need the list of all registers. It can be generated with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let regs=split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-&quot;', '\zs')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, it can be filtered to keep only the register names that contain a given pattern&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let pattern = 'function'&#xA;echo filter(copy(regs), 'match(getreg(v:val), pattern) &amp;gt;= 0')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be transformed to produce a result similar to &lt;code&gt;:register&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo join(map(filter(copy(regs), 'match(getreg(v:val), pattern) &amp;gt;= 0'), '&quot;~&quot;.v:val.&quot;   &quot;.strtrans(getreg(v:val))[:&amp;amp;co-1]'), &quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Unfortunately , it requires more work than just &lt;code&gt;[:&amp;amp;co]&lt;/code&gt; to limit the number of characters printed on each line)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as a command, it becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Registers  &#xA;    \ echo join(map(&#xA;    \   filter(&#xA;    \      split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-&quot;', '\zs'), &#xA;    \      'match(getreg(v:val), &amp;lt;q-args&amp;gt;) &amp;gt;= 0'), &#xA;    \   '&quot;~&quot;.v:val.&quot;   &quot;.strtrans(getreg(v:val))[:&amp;amp;co-1]'), &quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-07-19T14:38:30.360" LastActivityDate="2018-07-19T14:38:30.360" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16803" PostTypeId="2" ParentId="16789" CreationDate="2018-07-19T14:22:40.047" Score="2" Body="&lt;p&gt;This is a (side?)effect of the changes from nvim v0.2.2 -&gt; v0.3.  Nvim did switch the default behaviour for text that is piped into it via stdin.  Before it was used as commands (unless &lt;code&gt;-&lt;/code&gt; was given as an argument), now it is used as text in the initial buffer (even without the &lt;code&gt;-&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your file argument should be there just as the next buffer in the &lt;em&gt;internal&lt;/em&gt; argument list of neovim.  Try &lt;code&gt;:ls&lt;/code&gt; inside neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can verify that this behaviour is new with neovim v0.3 when you download the &lt;a href=&quot;https://github.com/neovim/neovim/releases/tag/v0.2.2&quot; rel=&quot;nofollow noreferrer&quot;&gt;appimage for v0.2.2&lt;/a&gt; and try the same with that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: I confirmed that for version 0.3.1 it works as expected, you get file in the first buffer.  You can download v0.3.1 from &lt;a href=&quot;https://github.com/neovim/neovim/releases/tag/v0.3.1&quot; rel=&quot;nofollow noreferrer&quot;&gt;the release page&lt;/a&gt;. (thanks @jamessan for mentioning)&lt;/p&gt;&#xA;" OwnerUserId="18062" LastEditorUserId="18062" LastEditDate="2018-07-20T10:15:13.443" LastActivityDate="2018-07-20T10:15:13.443" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16804" PostTypeId="1" AcceptedAnswerId="16807" CreationDate="2018-07-19T15:25:30.190" Score="2" ViewCount="2476" Body="&lt;p&gt;I run my &lt;code&gt;make&lt;/code&gt; commands asynchronously in vim with the &lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;asyncrun&lt;/a&gt; plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use this code in my &lt;code&gt;.vimrc&lt;/code&gt; to open the quickfix window automatically everytime I run an asynchronous make command in order to see the output. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc&#xA;    autocmd QuickFixCmdPost * botright copen 8&#xA;augroup END&#xA;nnoremap &amp;lt;leader&amp;gt;m :AsyncRun -cwd=&amp;lt;root&amp;gt; make&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I usually don't want to jump into the quickfix window, but only open it and see the output. I couldn't find a way how to achieve this.&lt;/p&gt;&#xA;" OwnerUserId="18267" LastActivityDate="2018-08-16T11:41:45.573" Title="Open quickfix window without focusing it" Tags="|vimrc|quickfix|makeprg|plugin-asyncrun|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16805" PostTypeId="2" ParentId="16804" CreationDate="2018-07-19T20:30:24.723" Score="2" Body="&lt;p&gt;Running &lt;code&gt;wincmd p&lt;/code&gt; after the copen should work; you jump to the quickfix window and then right back to the window you were in e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd QuickFixCmdPost * botright copen 8 | wincmd p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;see &lt;code&gt;:h wincmd&lt;/code&gt;, &lt;code&gt;:h CTRL-W_p&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16910" LastActivityDate="2018-07-19T20:30:24.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16806" PostTypeId="1" AcceptedAnswerId="16839" CreationDate="2018-07-19T23:29:32.343" Score="9" ViewCount="4950" Body="&lt;p&gt;I'm now using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! let l:status = system(l:command . ' &amp;gt; /dev/null')&#xA;&#xA;if match(l:status, '\cunknown') != -1 || match(l:status, '\cnot') != -1&#xA;    echo 'command not found'&#xA;    return 0`enter code here`&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i know it's not complete but is there any better way to check?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;edit&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;i'm now using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! let l:status = system('which espeak')&#xA;&#xA;if l:status !~ '\w\+'&#xA;    echo 'command not found'&#xA;    return 0&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;edit&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;changed from &lt;code&gt;which&lt;/code&gt; to &lt;code&gt;command&lt;/code&gt; &lt;a href=&quot;https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then&quot;&gt;https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18254" LastEditorUserId="18254" LastEditDate="2018-07-20T08:55:22.653" LastActivityDate="2018-07-21T21:01:12.493" Title="How to check if a shell command exists" Tags="|vimscript|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16807" PostTypeId="2" ParentId="16804" CreationDate="2018-07-20T00:10:10.610" Score="1" Body="&lt;p&gt;I had the same thinking for a solution as the other answer here has (&lt;code&gt;wincmd p&lt;/code&gt;). But I found it was not 100% reliable depending on what quickfix command type is being used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have issues with that solution you might have some better luck with a solution that uses explicit window/buffer references. An easy approach is to save the current buffer name in a global variable and jump to its &quot;buffer window number&quot; after the QF command runs...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd QuickFixCmdPre * let g:mybufname=bufname('%')&#xA;autocmd QuickFixCmdPost * botright copen 8 | exec bufwinnr(g:mybufname) . 'wincmd w'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-07-20T00:10:10.610" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16808" PostTypeId="2" ParentId="6637" CreationDate="2018-07-20T01:31:06.663" Score="0" Body="&lt;p&gt;Run gVim as an administrator, e.g. by right-clicking on, or using the &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;F10&lt;/kbd&gt; keyboard shortcut on, the gVim shortcut in your Start menu and picking &lt;em&gt;Run as an administrator&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open the file you want to edit and save your changes using &lt;code&gt;:w&lt;/code&gt; as normal.&lt;/p&gt;&#xA;" OwnerUserId="2629" LastActivityDate="2018-07-20T01:31:06.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16809" PostTypeId="1" CreationDate="2018-07-20T05:37:36.273" Score="0" ViewCount="36" Body="&lt;p&gt;By the normal mode command &lt;code&gt;:vs&lt;/code&gt;, I split the current buffer into two equally sized buffers. Then I resize the whole terminal window and only find the left portion of the screen remains the same as before resizing, while the right portion changes its size. Consequently, the splitted buffers no longer take the same size. How could I make them keep the same size when I resize the window?&lt;/p&gt;&#xA;" OwnerUserId="18259" LastActivityDate="2018-11-17T13:01:10.173" Title="How come the splitted window failed to update its shapes along with the whole window" Tags="|buffers|vim-windows|terminal-buffer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16810" PostTypeId="2" ParentId="9287" CreationDate="2018-07-20T06:09:22.377" Score="2" Body="&lt;p&gt;Invoking netrw can be achieved in three ways&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:Explore&lt;/code&gt; - opens netrw in the current window&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:Sexplore&lt;/code&gt; - opens netrw in a horizontal split&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:Vexplore&lt;/code&gt; - opens netrw in a vertical split&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can also snigger by typing &lt;code&gt;:Sex&lt;/code&gt; to invoke a horizontal split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more Information check it here:&#xA;&lt;a href=&quot;https://shapeshed.com/vim-netrw/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://shapeshed.com/vim-netrw/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18278" LastEditorUserId="1841" LastEditDate="2018-07-20T08:04:44.913" LastActivityDate="2018-07-20T08:04:44.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16813" PostTypeId="1" AcceptedAnswerId="16816" CreationDate="2018-07-20T09:50:39.570" Score="3" ViewCount="256" Body="&lt;p&gt;I want the piece of text &lt;code&gt;std::string&lt;/code&gt; to be highlighted in vim according to the style defined in 'Type'. I can do that with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd('Type','std::string')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works. However, &lt;code&gt;std::string&lt;/code&gt; is also highlighted in comments. In my code, comments follow a double slash &lt;code&gt;//&lt;/code&gt;. How can I avoid highlights in comments?&lt;/p&gt;&#xA;" OwnerUserId="6023" LastActivityDate="2018-07-20T11:46:52.963" Title="Avoid highlighting defined by 'matchadd' in comments" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16814" PostTypeId="1" CreationDate="2018-07-20T10:25:19.817" Score="2" ViewCount="503" Body="&lt;p&gt;I tried &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-airline&lt;/a&gt; and it looks nice, while editing on single window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When in split view, with multiple files open, I noticed it focus on current window. By focus I mean the other windows keep lights off (I mean I cannot see the infos on the bar, or at least is very difficult). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Comparing to what I had before. This is good because I can imidiatelly see where I am (in which window). Previously I had to look down on the left side to i.e. check the mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, I'm missing one thing. I can't even see the filename on the other windows. So if I need to jump to file1.txt I have to look on the contents of the other windows to find it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I change it so that at least the file name on the other split views (windows) becomes easier to see from distance?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KXk8A.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KXk8A.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have other plugins also: Mark--Karkat  conoline.vim  nerdcommenter tabular&lt;/p&gt;&#xA;" OwnerUserId="18250" LastEditorUserId="18250" LastEditDate="2018-07-20T10:43:27.257" LastActivityDate="2018-07-20T10:43:27.257" Title="Vim vim-airline on split view, change colors" Tags="|plugin-airline|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="16815" PostTypeId="2" ParentId="16809" CreationDate="2018-07-20T11:31:10.730" Score="1" Body="&lt;p&gt;When you have several split you can equalize their size with &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;+&lt;kbd&gt;=&lt;/kbd&gt; or with the equivalent command &lt;code&gt;:wincmd =&lt;/code&gt;. So you could use that manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I you want to use the command each time Vim's window is resized you can use an autocommand like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimResized * wincmd =&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means when the &lt;code&gt;VimResized&lt;/code&gt; event is received, no matter what buffer you are editing (&lt;code&gt;*&lt;/code&gt;) use the command &lt;code&gt;wincmd =&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some related help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3awincmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :wincmd&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h autocmd.txt&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-events&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h autocmd-events&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-07-20T11:31:10.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16816" PostTypeId="2" ParentId="16813" CreationDate="2018-07-20T11:46:52.963" Score="4" Body="&lt;p&gt;Unfortunately, the &lt;code&gt;match()&lt;/code&gt; functions are not aware of the syntax regions. So you need to fallback to change your pattern and exclude the comment pattern. Luckily for your case this is &quot;quite easy&quot; (well more or less) using a &lt;a href=&quot;https://www.regular-expressions.info/lookaround.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;negative lookbehind assertion&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to use the &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%40%3C%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;/\@&amp;lt;!&lt;/code&gt;&lt;/a&gt;, which is the negative lookbehind atom used by Vims regexp engine. That would make your pattern something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^\s*\(\/\/.*\)\@&amp;lt;!std::string&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which comes down to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^        - start of line&#xA;\s*      - any number of whitespace&#xA;\(       - start group&#xA;  \/\/   - Start of your Comment&#xA;  .*     - Anything&#xA; \)      - End group&#xA; \@&amp;lt;!    - negative lookbehind assertion&#xA; std::string  - Finally the search string you actually want to have highlighted ;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-07-20T11:46:52.963" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16817" PostTypeId="2" ParentId="16786" CreationDate="2018-07-20T11:53:55.837" Score="2" Body="&lt;p&gt;Your mappings have two problems:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One problem can be solved easily: you don't need to escape &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; in the right-hand part of the mappings, for example, these ones work properly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-a&amp;gt; &amp;lt;C-w&amp;gt;&amp;gt;&#xA;nnoremap &amp;lt;C-b&amp;gt; &amp;lt;C-w&amp;gt;&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your second problem, which can't really be solved is that you're trying to map &lt;kbd&gt;Ctrl + &amp;lt;&lt;/kbd&gt;, which is not possible. So you should try to use another key combination. (I already wrote an answer about how to debug a mapping which could have been useful to you in this case: &lt;a href=&quot;https://vi.stackexchange.com/q/7722/1841&quot;&gt;How to debug a mapping?&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-07-20T11:53:55.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16819" PostTypeId="1" CreationDate="2018-07-20T12:17:46.570" Score="1" ViewCount="387" Body="&lt;p&gt;I am trying to install plugin for python in vim,but i am unable to do that. I removed vi tiny from Raspberry pi and installed vi 8.0 I followed instruction from this site&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://realpython.com/vim-and-python-a-match-made-in-heaven/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://realpython.com/vim-and-python-a-match-made-in-heaven/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I updated my vimrc file from sudo user in folder /home/etc/vim/vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;added these lines in vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'gmarik/Vundle.vim'&#xA;&#xA;&quot; add all your plugins here (note older versions of Vundle&#xA;&quot; used Bundle instead of Plugin)&#xA;&#xA;&quot; ...&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;whenever I trying to install plugin I get an error E942: Not an editor command: PluginInstall &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/z3Hcw.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/z3Hcw.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Scriptname&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;show this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wC31k.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wC31k.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18281" LastEditorUserId="18281" LastEditDate="2018-07-20T13:10:09.183" LastActivityDate="2018-07-20T13:10:09.183" Title="Unable to install vim plugin in raspberry pi" Tags="|vimrc|plugin-python-mode|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16820" PostTypeId="2" ParentId="16786" CreationDate="2018-07-20T12:18:47.277" Score="1" Body="&lt;p&gt;While you can't use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;&amp;lt;&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;&gt;&lt;/kbd&gt;, many terminals will support &lt;kbd&gt;alt&lt;/kbd&gt;+&lt;kbd&gt;,&lt;/kbd&gt; (comma) and &lt;kbd&gt;alt&lt;/kbd&gt;+&lt;kbd&gt;.&lt;/kbd&gt; (period), although it's not obvious at first how to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;set &amp;lt;a-,&amp;gt;=\&amp;lt;esc&amp;gt;,&quot;&#xA;execute &quot;set &amp;lt;a-.&amp;gt;=\&amp;lt;esc&amp;gt;.&quot;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;a-,&amp;gt; :&amp;lt;c-u&amp;gt;vert res -&amp;lt;c-r&amp;gt;=v:count?v:count1:5&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;a-.&amp;gt; :&amp;lt;c-u&amp;gt;vert res +&amp;lt;c-r&amp;gt;=v:count?v:count1:5&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can supply a count or use the default of 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With alt maps I recommend using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ttimeout ttimeoutlen=10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;otherwise there can be a delay when pressing &lt;kbd&gt;esc&lt;/kbd&gt; as vim waits to see if a , or . is coming.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-12-17T22:04:04.670" LastActivityDate="2018-12-17T22:04:04.670" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16821" PostTypeId="1" AcceptedAnswerId="16847" CreationDate="2018-07-20T14:59:07.163" Score="3" ViewCount="8573" Body="&lt;p&gt;I'd like to run make and display the output when I press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;m&lt;/kbd&gt; in Vim. I know how to run make and display the output while in command mode, thanks to &lt;a href=&quot;https://stackoverflow.com/a/6549828/1876983&quot;&gt;this StackOverflow answer&lt;/a&gt;, namely with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:make | copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but how do I bind this to a keyboard shortcut? I managed this when I was just running make and not displaying the output namely with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C-m&amp;gt; :make&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my ~/.vimrc file. Unfortunately, adding &lt;code&gt;| copen&lt;/code&gt; after &lt;code&gt;:make&lt;/code&gt; and before &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; results in this Vim start up error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/fusion809/.vimrc:&#xA;line  157:&#xA;E488: Trailing characters:  copen &amp;lt;CR&amp;gt;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11076" LastEditorUserId="1292" LastEditDate="2018-08-01T16:21:55.333" LastActivityDate="2018-08-02T08:22:50.283" Title="How to set a shortcut to run make in Vim and show the output" Tags="|key-bindings|quickfix|ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16822" PostTypeId="1" AcceptedAnswerId="16837" CreationDate="2018-07-20T15:16:42.030" Score="0" ViewCount="31" Body="&lt;p&gt;Is it possible to automatically return to where the cursor was before running &lt;code&gt;:cdo&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, the cursor ends in the last file in the quickfix, then I have to navigate back to where I was before running the command. &lt;/p&gt;&#xA;" OwnerUserId="16800" LastActivityDate="2018-07-21T12:59:07.640" Title="How to automatically return to where the cursor was before executing cdo?" Tags="|replace|quickfix|navigation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16824" PostTypeId="1" CreationDate="2018-07-20T15:52:50.283" Score="2" ViewCount="63" Body="&lt;p&gt;I know the &lt;code&gt;ci&quot;&lt;/code&gt; motion and others &lt;code&gt;:change&lt;/code&gt;s, but I need something like a &lt;code&gt;ci\&quot;&lt;/code&gt; in order to change inner a backslashed quotes. Assuming &lt;code&gt;*&lt;/code&gt; as the cursor position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = &quot;message says: \&quot;fo*o bar\&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to perform a &lt;code&gt;ci&lt;/code&gt; which gives me a:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = &quot;message says: \&quot;*\&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then start writing inside the backslashed quotes.&lt;/p&gt;&#xA;" OwnerUserId="18287" LastEditorUserId="1292" LastEditDate="2019-01-24T12:50:27.493" LastActivityDate="2019-01-24T12:50:27.493" Title="change inner backslashed quotes" Tags="|cursor-movement|cursor-motions|map-operator|custom-text-object|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16825" PostTypeId="2" ParentId="16806" CreationDate="2018-07-20T16:56:10.020" Score="2" Body="&lt;p&gt;thanks for the comments above, i'm using this code right now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! let l:status = system('command -v ' . l:cmd)&#xA;&#xA;if l:status !~ '\w\+'&#xA;    echo 'command not found'&#xA;    return -1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18254" LastActivityDate="2018-07-20T16:56:10.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16826" PostTypeId="1" AcceptedAnswerId="16866" CreationDate="2018-07-20T16:59:42.463" Score="3" ViewCount="936" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NRH9w.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NRH9w.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I paste something within normal mode, vim ignores &lt;code&gt;autoindent&lt;/code&gt;. I copy and paste with &lt;code&gt;y&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt;. As mentioned &lt;code&gt;autoindent&lt;/code&gt; is on. It works fine when I manually indent or type something before pasting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also if I exit insert mode to normal mode right after the autoindent, the indent is lost.&lt;/p&gt;&#xA;" OwnerUserId="18254" LastEditorUserId="1292" LastEditDate="2018-07-24T17:30:26.373" LastActivityDate="2019-07-27T19:07:45.053" Title="Paste in normal mode ignores autoindent" Tags="|indentation|cut-copy-paste|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="16827" PostTypeId="2" ParentId="2849" CreationDate="2018-07-20T17:06:52.773" Score="1" Body="&lt;p&gt;For corporative environments usually is set the &lt;code&gt;%HOMEDRIVE&lt;/code&gt; and &lt;code&gt;%HOMEPATH%&lt;/code&gt; and the GVIM use it (version 8.1 at least) .  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;option.txt help file : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *$HOME-windows*&#xA;On MS-Windows, if $HOME is not defined as an environment variable, then&#xA;at runtime Vim will set it to the expansion of $HOMEDRIVE$HOMEPATH.&#xA;If $HOMEDRIVE is not set then $USERPROFILE is used.&#xA;&#xA;This expanded value is not exported to the environment, this matters when&#xA;running an external command: &amp;gt;&#xA;    :echo system('set | findstr ^HOME=')&#xA;and &amp;gt;&#xA;    :echo luaeval('os.getenv(&quot;HOME&quot;)')&#xA;should echo nothing (an empty string) despite exists('$HOME') being true.&#xA;When setting $HOME to a non-empty string it will be exported to the&#xA;subprocesses.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18285" LastEditorUserId="18285" LastEditDate="2018-07-20T17:34:40.750" LastActivityDate="2018-07-20T17:34:40.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16828" PostTypeId="2" ParentId="16156" CreationDate="2018-07-20T17:46:33.287" Score="1" Body="&lt;p&gt;I just ran into the same problem, and the fix is actually &lt;a href=&quot;http://valloric.github.io/YouCompleteMe/#python-semantic-completion&quot; rel=&quot;nofollow noreferrer&quot;&gt;in the docs&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If the value of g:ycm_python_binary_path is an absolute path like above it will be used as-is, but if it's an executable name it will be searched through the PATH. So for example if you set:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_python_binary_path = 'python'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;YCM will use the first python executable it finds in the PATH to run jedi. This means that &lt;strong&gt;if you are in a virtual environment and you start vim in that directory, the first python that YCM will find will be the one in the virtual environment, so jedi will be able to provide completions for every package you have in the virtual environment&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18288" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-07-20T17:46:33.287" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16829" PostTypeId="1" CreationDate="2018-07-20T18:22:29.833" Score="13" ViewCount="5430" Body="&lt;p&gt;Does anybody know the command for moving to an outer block of brackets/parentheses?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say that my cursor is in the innermost bracket. I know that &lt;code&gt;%&lt;/code&gt; moves to a matching bracket, but is there a command to move from say, bracket 1 to bracket 2?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3   {&#xA;2     {&#xA;1        { }&#xA;2     }&#xA;3   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18290" LastEditorUserId="18290" LastEditDate="2018-07-20T19:07:47.177" LastActivityDate="2021-10-09T08:56:08.507" Title="Moving to an outer block" Tags="|cursor-movement|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16830" PostTypeId="2" ParentId="16829" CreationDate="2018-07-20T18:50:44.747" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;[m&lt;/code&gt; to move to beginning of &lt;code&gt;match&lt;/code&gt;ed brackets, then sequentially up levels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;]m&lt;/code&gt; goes to next inner brackets, but not to the innermost level (in my tests anyway).&lt;/p&gt;&#xA;" OwnerUserId="2303" LastActivityDate="2018-07-20T18:50:44.747" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16831" PostTypeId="2" ParentId="16829" CreationDate="2018-07-20T19:19:45.320" Score="7" Body="&lt;p&gt;Use &lt;code&gt;[{&lt;/code&gt; and &lt;code&gt;]}&lt;/code&gt; to go to the next outer curly braces.  You can use a count such as &lt;code&gt;3[{&lt;/code&gt;.  See &lt;code&gt;:help [{&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-07-23T13:50:10.247" LastActivityDate="2018-07-23T13:50:10.247" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16832" PostTypeId="1" AcceptedAnswerId="16834" CreationDate="2018-07-20T21:15:25.847" Score="1" ViewCount="212" Body="&lt;p&gt;My .vimrc includes the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if filereadable(&quot;my_source&quot;)&#xA;    :source my_source&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, if the file 'my_source' exists in the folder where I open vim and it is readable, it is loaded automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I am editing a file in that folder and open another file (also in that same folder) via &lt;code&gt;:tabe&lt;/code&gt;, the source file 'my_source' is not loaded in the latter. Why? How can I have it automatically loaded when I open a new tab?&lt;/p&gt;&#xA;" OwnerUserId="6023" LastActivityDate="2018-07-22T03:12:22.967" Title="Loading source file with :tabe" Tags="|vimrc|tabbed-user-interface|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16833" PostTypeId="2" ParentId="16832" CreationDate="2018-07-20T21:23:23.600" Score="1" Body="&lt;p&gt;the statements in &lt;code&gt;.vimrc&lt;/code&gt; are executed only once.&#xA;You could create an &lt;code&gt;autocommand&lt;/code&gt; for this matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Find details in &lt;code&gt;:help autocommand&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-07-20T21:23:23.600" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16834" PostTypeId="2" ParentId="16832" CreationDate="2018-07-20T22:21:48.243" Score="2" Body="&lt;p&gt;You need to use an &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;autocommand&lt;/code&gt;&lt;/a&gt; to accomplish this, as your &lt;code&gt;.vimrc&lt;/code&gt; is only sourced once on startup. As their name would suggest, &lt;code&gt;autocmd&lt;/code&gt;s allow for defining a series of commands that should occur automatically when certain events are fired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend you read about them in Vim's help pages, as they are a ubiquitous and incredibly useful component. In the meantime, this should cover your needs adequately:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyAutoCmds&#xA;    autocmd!&#xA;    autocmd BufNewFile,BufRead,VimEnter *&#xA;      \ if filereadable('my_source') | source my_source | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I highly recommend that you read &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/14.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/9455/why-should-i-use-augroup&quot;&gt;this&lt;/a&gt; on why &lt;code&gt;augroup&lt;/code&gt; is used here, and why you should be sure to use it yourself. In short, the main reason is to act as a guard when you re-source your &lt;code&gt;.vimrc&lt;/code&gt;, otherwise the autocommands would be defined multiple times, and thus run multiple times!&lt;/p&gt;&#xA;" OwnerUserId="1452" LastEditorUserId="1452" LastEditDate="2018-07-22T03:12:22.967" LastActivityDate="2018-07-22T03:12:22.967" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16835" PostTypeId="1" CreationDate="2018-07-21T10:01:37.727" Score="5" ViewCount="4531" Body="&lt;p&gt;Is there a way to change which terminal emulator &lt;code&gt;neovim&lt;/code&gt; uses for its &lt;code&gt;:terminal&lt;/code&gt; command? I am running &lt;code&gt;neovim&lt;/code&gt; on Windows 10, and it used &lt;code&gt;cmd&lt;/code&gt; by default; however, I would rather use &lt;a href=&quot;http://cmder.net/&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;cmder&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;https://www.slant.co/topics/1552/~terminal-emulators-for-windows&quot; rel=&quot;noreferrer&quot;&gt;another linux-style emulator&lt;/a&gt; if I can.&lt;/p&gt;&#xA;" OwnerUserId="7853" LastActivityDate="2018-07-21T11:19:23.750" Title="Change the terminal emulater neovim uses" Tags="|neovim|terminal-buffer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16836" PostTypeId="2" ParentId="16835" CreationDate="2018-07-21T11:19:23.750" Score="4" Body="&lt;p&gt;Neovim uses its own internal terminal emulator for &lt;code&gt;:term&lt;/code&gt;.  You can not change that (as far as I know).  The thing you can change is the command interpreter/shell that runs in that terminal.   See Wikipedia for the difference: &lt;a href=&quot;https://en.wikipedia.org/wiki/Terminal_emulator&quot; rel=&quot;nofollow noreferrer&quot;&gt;Terminal&lt;/a&gt; vs &lt;a href=&quot;https://en.wikipedia.org/wiki/Command-line_interface#Command-line_interpreter&quot; rel=&quot;nofollow noreferrer&quot;&gt;Shell&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can start any command (that you have installed) in the terminal if you just specify it as the argument: &lt;code&gt;:terminal bash&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how to do that by default but you can read the docs in order to find out if that's possible: &lt;a href=&quot;https://neovim.io/doc/user/various.html#:terminal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :terminal&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can define a custom command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command MyTerm terminal bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you instead want to start &lt;code&gt;cmder&lt;/code&gt; in its own window from within Neovim just run &lt;code&gt;:!cmder &amp;amp;&lt;/code&gt; (I suppose the &lt;code&gt;&amp;amp;&lt;/code&gt; also works in windows?).&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-21T11:19:23.750" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16837" PostTypeId="2" ParentId="16822" CreationDate="2018-07-21T12:59:07.640" Score="1" Body="&lt;p&gt;It turned out that pressing &lt;code&gt;C-o&lt;/code&gt; after the &lt;code&gt;:cdo&lt;/code&gt; command ends, returns the cursor to its position before running the command. I can now add this &lt;code&gt;C-o&lt;/code&gt; to the &lt;code&gt;:cdo&lt;/code&gt; command keybinding.&lt;/p&gt;&#xA;" OwnerUserId="16800" LastActivityDate="2018-07-21T12:59:07.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16838" PostTypeId="2" ParentId="16013" CreationDate="2018-07-21T18:55:25.473" Score="1" Body="&lt;p&gt;&lt;em&gt;If you don't need Vim itself but can do with Neovim&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also try &lt;a href=&quot;https://neovim.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;neovim&lt;/a&gt;.  It is a (mostly) compatible fork of vim.  It supports the same python interfaces from a users (or plugins) perspective but due to the internal implementation it is easier to use two versions of python simultaneously and also to use a custom python interpreter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be downloaded as an appimage (no sudo required, I hope they work on ubuntu 16.04) from &lt;a href=&quot;https://github.com/neovim/neovim/releases&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to use use your virtual environment you should install the &lt;code&gt;neovim&lt;/code&gt; pip package:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source /my/pyX/virtual/env/activate&#xA;pip install neovim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And also set the following variables in your &lt;code&gt;~/.config/neovim/init.vim&lt;/code&gt; file  (the &lt;code&gt;vimrc&lt;/code&gt; of neovim):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:python_host_prog = '/my/py2/virtual/env/bin/python'&#xA;let g:python3_host_prog = '/my/py3/virtual/env/bin/python'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read &lt;a href=&quot;https://neovim.io/doc/user/provider.html#provider-python&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help python-provider&lt;/code&gt;&lt;/a&gt; for the full documentation of python in neovim.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-21T18:55:25.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16839" PostTypeId="2" ParentId="16806" CreationDate="2018-07-21T21:01:12.493" Score="19" Body="&lt;p&gt;Incidentally vim has a special function just for this: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#executable()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;executable()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-21T21:01:12.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16841" PostTypeId="1" CreationDate="2018-07-22T03:04:29.683" Score="5" ViewCount="1308" Body="&lt;p&gt;I opened 5 buffers and in one of them I use the command &lt;code&gt;:vs&lt;/code&gt; to split the current buffer screen into two.&lt;br&gt;&#xA;When I use the command &lt;code&gt;&amp;lt;leader&amp;gt;d&lt;/code&gt; to close one of the splitted buffers, the consequence is that the splitted window is also closed along with the buffer to be closed. I would like to close the buffer without impacting the split pattern of my screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &quot;buffer #1&quot; and &quot;buffer #2&quot; are displayed in my current screen, I would like to close &quot;buffer #1&quot; with &lt;code&gt;&amp;lt;leader&amp;gt;d&lt;/code&gt; and leave the screen to be a split of &quot;buffer #3&quot; and &quot;buffer #2&quot; instead of a not splitted screen with only &quot;buffer #2&quot; on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that requirement accessible?&lt;/p&gt;&#xA;" OwnerUserId="18259" LastEditorUserId="1238" LastEditDate="2018-09-16T19:18:43.193" LastActivityDate="2018-09-17T04:31:51.337" Title="How could I maintain split layout when deleting buffers?" Tags="|buffers|split|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="16842" PostTypeId="2" ParentId="4436" CreationDate="2018-07-22T08:30:34.927" Score="0" Body="&lt;h3&gt;Plugin &lt;em&gt;ZoomWin&lt;/em&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;by &lt;em&gt;Charles Campbell&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin remaps &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;w&lt;/kbd&gt; &lt;kbd&gt;o&lt;/kbd&gt; to do both: maximize and restore previous layout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin can be downloaded from two locations&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=508&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.vim.org/scripts/script.php?script_id=508&lt;/a&gt; (v24)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#ZOOMWIN&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#ZOOMWIN&lt;/a&gt; (v25)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2018-07-22T08:30:34.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16843" PostTypeId="1" AcceptedAnswerId="16846" CreationDate="2018-07-22T10:22:36.343" Score="12" ViewCount="8459" Body="&lt;p&gt;I hear somewhere that if &lt;code&gt;backup&lt;/code&gt; is disabled and &lt;code&gt;writebackup&lt;/code&gt; is enabled, Vim will create backup files for the duration of the edit session and will delete these backup files afterward. However, even with these settings, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nobackup&#xA;set writebackup &quot; Enabled!&#xA;set noswapfile&#xA;set noundofile  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't see any additional files created.&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="1841" LastEditDate="2018-07-22T13:58:45.203" LastActivityDate="2019-04-28T11:49:12.900" Title="What does `nowritebackup` actually do?" Tags="|backup|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16844" PostTypeId="2" ParentId="16841" CreationDate="2018-07-22T11:49:38.520" Score="4" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/moll/vim-bbye&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-bbye&lt;/a&gt; does exactly what you're looking for. It provides &lt;code&gt;:Bdelete&lt;/code&gt; and &lt;code&gt;:Bwipeout&lt;/code&gt;, which are variants of &lt;code&gt;:bdelete&lt;/code&gt; and &lt;code&gt;:bwipeout&lt;/code&gt; that will delete the buffer &lt;strong&gt;but maintain the split and switch to another buffer&lt;/strong&gt;, preserving your current split layout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally mapped &lt;code&gt;:Bdelete&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;d :Bdelete&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's a terrific and simple plugin; I've been using it for over a year now.&lt;/p&gt;&#xA;" OwnerUserId="1452" LastActivityDate="2018-07-22T11:49:38.520" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16845" PostTypeId="2" ParentId="16843" CreationDate="2018-07-22T12:14:19.950" Score="4" Body="&lt;p&gt;As @ZeroKnight said with &lt;code&gt;:set nobackup writebackup&lt;/code&gt; the backup file will be used during &lt;code&gt;:write&lt;/code&gt; but will be deleted afterwards.  The official documentation is here: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;bk&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;backup&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;writebackup&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;writebackup&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the question (my emphasis)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What does &lt;code&gt;nowritebackup&lt;/code&gt; &lt;strong&gt;actually&lt;/strong&gt; do?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://linux.die.net/man/1/inotifywait&quot; rel=&quot;nofollow noreferrer&quot;&gt;inotify&lt;/a&gt; to find out.  Make a test dir and save the settings you specified above as a test vimrc file, then write a file to that test directory and watch the output of inotify.  Like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;first terminal window&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir test-dir&#xA;cat &amp;gt; test-dir/vimrc &amp;lt;&amp;lt;EOF&#xA;set nobackup&#xA;set writebackup &quot; Enabled!&#xA;set noswapfile&#xA;set noundofile&#xA;EOF&#xA;inotifywait -m -r test-dir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;second terminal window&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim test-dir/foo&#xA;:w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For me the output looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Setting up watches.  Beware: since -r was given, this may take a while!&#xA;Watches established.&#xA;test-dir/ OPEN foo&#xA;test-dir/ CREATE foo~&#xA;test-dir/ OPEN foo~&#xA;test-dir/ ATTRIB foo~&#xA;test-dir/ CLOSE_WRITE,CLOSE foo~&#xA;test-dir/ ATTRIB foo~&#xA;test-dir/ CLOSE_NOWRITE,CLOSE foo&#xA;test-dir/ OPEN foo&#xA;test-dir/ MODIFY foo&#xA;test-dir/ ATTRIB foo&#xA;test-dir/ CLOSE_WRITE,CLOSE foo&#xA;test-dir/ DELETE foo~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18062" LastEditorUserId="1452" LastEditDate="2018-07-22T12:59:46.063" LastActivityDate="2018-07-22T12:59:46.063" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16846" PostTypeId="2" ParentId="16843" CreationDate="2018-07-22T12:34:24.337" Score="21" Body="&lt;p&gt;&lt;code&gt;backup&lt;/code&gt; and &lt;code&gt;writebackup&lt;/code&gt; are two separate yet intertwined options; they are essentially two halves of the same whole. I think the easiest way to explain these two options is by detailing what happens when you attempt to overwrite a file with some combination of these options.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Scenario Breakdown&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Assume you have an existing file &lt;code&gt;foo.txt&lt;/code&gt;. You make some changes to it (beyond just appending to it) and issue a &lt;code&gt;:write&lt;/code&gt; command...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If either &lt;code&gt;backup&lt;/code&gt; or &lt;code&gt;writebackup&lt;/code&gt; (or both) are enabled, then &lt;em&gt;before&lt;/em&gt; writing the file, Vim will create a backup (location depends on the &lt;code&gt;backupdir&lt;/code&gt; setting). Afterwards, Vim will attempt to write the original file. At this point, behavior depends on the &lt;code&gt;backup&lt;/code&gt; setting:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;code&gt;nobackup&lt;/code&gt;, then the backup file is &lt;strong&gt;immediately deleted&lt;/strong&gt; upon successfully writing the original file.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;code&gt;backup&lt;/code&gt;, then the backup file is &lt;strong&gt;kept&lt;/strong&gt; afterwards and will be overwritten on future backups.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And that's it; behavior really depends on the &lt;code&gt;backup&lt;/code&gt; setting. It should be noted that &lt;code&gt;backup&lt;/code&gt; will override &lt;code&gt;writebackup&lt;/code&gt; in the case that the former is enabled and the latter is disabled, e.g. &lt;code&gt;:set backup nowritebackup&lt;/code&gt;. In other words, it is identical to &lt;code&gt;:set backup writebackup&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This table from &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#backup-table&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h backup-table&lt;/code&gt;&lt;/a&gt; outlines the same thing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *backup-table*&#xA;'backup' 'writebackup'  action&#xA;   off       off    no backup made&#xA;   off       on     backup current file, deleted afterwards (default)&#xA;   on        off    delete old backup, backup current file&#xA;   on        on     delete old backup, backup current file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Regarding the option names&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You may be thinking that the names of these options should be swapped, as each option's name seems to describe the other's more accurately. I originally held this same opinion, but I'm going to mirror KRyan's insightful comment here:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To help understand the naming convention, consider this: &lt;code&gt;backup&lt;/code&gt; always produces a backup, while &lt;code&gt;writebackup&lt;/code&gt; produces a backup &lt;em&gt;during a write procedure&lt;/em&gt;. In other words, &lt;em&gt;write&lt;/em&gt; is not used as a verb, but as an adjective describing the type of backup you’re enabling.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1452" LastEditorUserId="1452" LastEditDate="2018-07-22T22:46:49.220" LastActivityDate="2018-07-22T22:46:49.220" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16847" PostTypeId="2" ParentId="16821" CreationDate="2018-07-22T13:04:42.583" Score="2" Body="&lt;p&gt;When you want to map to a key sequence that contains &lt;code&gt;|&lt;/code&gt; you have to be careful.  See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#map_bar&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help map_bar&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should probably use this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C-m&amp;gt; :make&amp;lt;BAR&amp;gt;copen&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-22T13:04:42.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16848" PostTypeId="1" AcceptedAnswerId="16849" CreationDate="2018-07-22T18:22:34.000" Score="2" ViewCount="125" Body="&lt;p&gt;I've started using &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; instead of &lt;kbd&gt;ESC&lt;/kbd&gt; in vim because of its position on the keyboard and better responsiveness. It mostly behaves the same except when exiting visual block replacements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am hoping someone can explain why and  possibly propose a fix/workaround.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;jjjsmy replacement text&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;versus&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;jjjsmy replacement text&amp;lt;C-c&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;kbd&gt;ESC&lt;/kbd&gt;, &lt;code&gt;my replacement text&lt;/code&gt; appears on all 4 lines. With &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt;, &lt;code&gt;my replacement text&lt;/code&gt; only shows up on the first line. What is going on here?&lt;/p&gt;&#xA;" OwnerUserId="8683" LastEditorUserId="1238" LastEditDate="2018-09-16T19:18:48.357" LastActivityDate="2018-09-16T19:18:48.357" Title="Why does ^C behave differently from ESC when exiting visual block substitution?" Tags="|visual-block|escape|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16849" PostTypeId="2" ParentId="16848" CreationDate="2018-07-22T20:51:16.703" Score="5" Body="&lt;p&gt;At first they might do the same but internally they are interpreted differently.  In layman's terms they mean something like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;: &quot;OK I am done (with whatever I was doing).&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt;: &quot;Stop that as fast as possible!&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It is not clearly documented (as far as I can see) but there are some indications:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-[&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;i_&amp;lt;esc&amp;gt;&lt;/code&gt;&lt;/a&gt; says &quot;End ... mode&quot; whereas &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-C&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;i_CTRL-C&lt;/code&gt;&lt;/a&gt; says &quot;Quit insert mode&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-C&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;i_CTRL-C&lt;/code&gt;&lt;/a&gt; does not expand abbreviations and does not fire the &lt;code&gt;InserLeave&lt;/code&gt; autocommand.&lt;/li&gt;&#xA;&lt;li&gt;Sadly &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html#v_CTRL-C&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;v_CTRL-C&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_%3CEsc%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;ì_&amp;lt;Esc&amp;gt;&lt;/code&gt;&lt;/a&gt; are less clear, both say &quot;quit&quot;.&lt;/li&gt;&#xA;&lt;li&gt;When you are in block insert mode (like in the question) you only see the characters you type on the first line.  Only later when you finish (with &lt;kbd&gt;Esc&lt;/kbd&gt;) will the text appear in the other lines.  And &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt; seems to &quot;abort&quot; before that.&lt;/li&gt;&#xA;&lt;li&gt;You might know &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt; from the shell where it sends&#xA;&lt;code&gt;SIGINT&lt;/code&gt; which normally terminates a command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18062" LastEditorUserId="18062" LastEditDate="2018-07-23T06:32:47.527" LastActivityDate="2018-07-23T06:32:47.527" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16850" PostTypeId="2" ParentId="16513" CreationDate="2018-07-23T05:15:16.900" Score="1" Body="&lt;p&gt;At last, I guess I managed to figure out what was really at the bottom of the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Older xfce4-termnal determines how to deal with ambiguous-width characters depending on the value of environment variable VTE_CJK_WIDTH (I usually set VTE_CJK_WIDTH=1), while recent xfce4-terminal has a specific setting that affects ambiguous-width characters. When I set either of these appropriately (i.e. VTE_CJK_WIDTH to 0 or 'ambiguous-width characters' to 'narrow') and also set &lt;code&gt;ambiwidth&lt;/code&gt; to &lt;code&gt;single&lt;/code&gt; with neovim, then everything goes well and neovim treats accented latin characters as single-width.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I understand, rxvt-unicode cannot properly deal with ambiguous-width characters and always treats these characters as single-width. So this may not be a proper solution to the problem.&lt;/p&gt;&#xA;" OwnerUserId="14025" LastActivityDate="2018-07-23T05:15:16.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16851" PostTypeId="1" AcceptedAnswerId="16855" CreationDate="2018-07-23T06:49:54.390" Score="1" ViewCount="679" Body="&lt;p&gt;I don't understand why is Vim pasting after the cursor; for example in this example (where the cursor is at the start):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|The quick brown fox jumps over a lazy dog&#xA;^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to exchange &lt;code&gt;fox&lt;/code&gt; and &lt;code&gt;dog&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ff&lt;/code&gt; – Find fox&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yw&lt;/code&gt; – Yank fox&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;fd&lt;/code&gt; – Find dog&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; – Paste&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Which gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The quick brown fox jumps over a lazy dfo|xog&#xA;                                         ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the same vein, if I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i&amp;lt;Esc&amp;gt;i&amp;lt;Esc&amp;gt;i&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The cursor goes backward. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I improve on this? Because I find the this behaviour very awkward.&lt;/p&gt;&#xA;" OwnerUserId="2548" LastEditorUserId="51" LastEditDate="2018-07-23T19:27:36.257" LastActivityDate="2018-07-23T19:27:36.257" Title="Why is Vim pasting after the cursor?" Tags="|cursor-movement|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16852" PostTypeId="2" ParentId="16774" CreationDate="2018-07-23T07:14:46.857" Score="1" Body="&lt;p&gt;As @LucHermite already mentioned &lt;a href=&quot;https://vi.stackexchange.com/questions/16774/how-to-match-braces-or-brackets#comment28766_16774&quot;&gt;in a comment&lt;/a&gt;, regular expressions are not meant for recursive patterns. The solution by @Vitor does not work, as was already confirmed &lt;a href=&quot;https://vi.stackexchange.com/questions/16774/how-to-match-braces-or-brackets#comment28767_16777&quot;&gt;in the comment&lt;/a&gt;, because it will match beyond the last &lt;code&gt;}&lt;/code&gt; of the &lt;code&gt;\todo&lt;/code&gt; command if possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you did not write anything about what your end goal is, it is difficult to give further concrete tips here. But I would think that you could solve your initial problem e.g. with something like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Search for &lt;code&gt;\\todo&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Do &lt;code&gt;vf{&lt;/code&gt; to select up until the first &lt;code&gt;{&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Do &lt;code&gt;%&lt;/code&gt; to increase the selection up until the closing &lt;code&gt;}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you need some sort of repeated action, you can combine these things with a macro, e.g. &lt;code&gt;qa/\\todo&amp;lt;cr&amp;gt;vf{% ... q&lt;/code&gt; where &lt;code&gt;...&lt;/code&gt; is the action you want to perform. Then you can run the macro with &lt;code&gt;@a&lt;/code&gt; to repeat.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-07-23T07:14:46.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16853" PostTypeId="2" ParentId="16851" CreationDate="2018-07-23T07:21:04.110" Score="6" Body="&lt;p&gt;If you read &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#p&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h p&lt;/code&gt;&lt;/a&gt; you'll see the next section &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#P&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h P&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *p* *put* *E353*&#xA;[&quot;x]p           Put the text [from register x] after the cursor&#xA;            [count] times.  {Vi: no count}&#xA;&#xA;                            *P*&#xA;[&quot;x]P           Put the text [from register x] before the cursor&#xA;            [count] times.  {Vi: no count}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the second part of your question maybe you're looking for &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#a&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h a&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-07-23T07:21:04.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16854" PostTypeId="2" ParentId="16829" CreationDate="2018-07-23T08:08:58.113" Score="14" Body="&lt;h2&gt;&lt;code&gt;[%&lt;/code&gt; and &lt;code&gt;]%&lt;/code&gt; provided by &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/pack/dist/opt/matchit/doc/matchit.txt&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;matchit&lt;/em&gt;&lt;/a&gt; or &lt;a href=&quot;https://github.com/andymass/vim-matchup&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;match-up&lt;/em&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vi.stackexchange.com/a/16831/1292&quot;&gt;answer by Mass&lt;/a&gt; suggesting &lt;code&gt;[{&lt;/code&gt; and &lt;code&gt;]}&lt;/code&gt; works perfectly for unmatched curly brackets but only for curly brackets. This should be considered as an advantage. However, not all blocks are defined by curly brackets and the wish to handle other situations is also important.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Parentheses&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim provides additionally &lt;code&gt;[(&lt;/code&gt; and &lt;code&gt;])&lt;/code&gt; to do the same for parentheses (e.g. useful for lisp):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3   (&#xA;2     (&#xA;1        ( )&#xA;2     )&#xA;3   )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note also the text objects &lt;code&gt;ib&lt;/code&gt; and &lt;code&gt;ab&lt;/code&gt; (analogue to &lt;code&gt;iB&lt;/code&gt; and &lt;code&gt;aB&lt;/code&gt; for curly brackets).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Square Brackets&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the situation for square brackets is different. Consider following python matrix using nested lists&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matrix = [&#xA;     [1, 2, 3, 4],&#xA;     [5, 6, 7, 8],&#xA;     [9, 10, 11, 12],&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One might guess &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt; would move to an unmatched square bracket, but they do something different (see &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%5D%5D&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h ]]&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/a/14115/1292&quot;&gt;https://vi.stackexchange.com/a/14115/1292&lt;/a&gt;). There is actually no builtin motion for unmatched square brackets. However, the builtin text objects &lt;code&gt;i[&lt;/code&gt; and &lt;code&gt;a[&lt;/code&gt; to operate on blocks defined by square brackets exist.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Blocks specific to languages&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Also if you want to move to other types of blocks often specific to languages (e.g. nested xml/html tags, nested if-blocks, nested LaTeX environments), there is no builtin motion for this. Again note the existence of the dedicated text objects for xml/html tags &lt;code&gt;it&lt;/code&gt; and &lt;code&gt;at&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;em&gt;Swiss Army knife&lt;/em&gt;: &lt;code&gt;[%&lt;/code&gt; and &lt;code&gt;]%&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The plugins &lt;em&gt;matchit&lt;/em&gt; and &lt;em&gt;match-up&lt;/em&gt; provide the motions &lt;code&gt;[%&lt;/code&gt; and &lt;code&gt;]%&lt;/code&gt; which can handle &lt;strong&gt;all&lt;/strong&gt; situations and IMHO perfectly enhance the builtin set of motions together with the text objects &lt;code&gt;i%&lt;/code&gt; and &lt;code&gt;a%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A drawback is that they consider all types of blocks and also matched brackets which can mean that you have to press &lt;code&gt;[%&lt;/code&gt; more often and is less precise than &lt;code&gt;[{&lt;/code&gt; and &lt;code&gt;[(&lt;/code&gt; which therefore have their place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note &lt;em&gt;matchit&lt;/em&gt; is distributed with vim and can be loaded with &lt;code&gt;:packadd! matchit&lt;/code&gt; (&lt;code&gt;:h matchit-install&lt;/code&gt;). &lt;em&gt;match-up&lt;/em&gt; has to be installed from the internet available on &lt;a href=&quot;https://github.com/andymass/vim-matchup&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt; and &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=5624&quot; rel=&quot;noreferrer&quot;&gt;vim.org&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Ninja-feet&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Another interesting vim plugin for this situation is &lt;a href=&quot;https://github.com/tommcdo/vim-ninja-feet&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/tommcdo/vim-ninja-feet&lt;/a&gt;. If you want to add a new first/last row to the python matrix, you can press &lt;code&gt;z[2i[&lt;/code&gt;/&lt;code&gt;z]2i]&lt;/code&gt; to immediately jump to the outer square bracket block and open a new line.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Summary&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;========================================================================================&#xA;  Block Type       Move to previous   Move to next   Inner text obj.   Outer text obj.  &#xA;========================================================================================&#xA;  curly bracket    [{                 ]}             iB                aB               &#xA;----------------------------------------------------------------------------------------&#xA;  parentheses      [(                 ])             ib                ab               &#xA;----------------------------------------------------------------------------------------&#xA;  square bracket                                     i[                a[               &#xA;----------------------------------------------------------------------------------------&#xA;  xml/html                                           it                at               &#xA;----------------------------------------------------------------------------------------&#xA;  paragraph        {                  }              ip                ap               &#xA;----------------------------------------------------------------------------------------&#xA;  section          [[ []              ]] ][                                             &#xA;----------------------------------------------------------------------------------------&#xA;  method           [m [M              ]m ]M                                             &#xA;----------------------------------------------------------------------------------------&#xA;  matchit/-up      [%                 ]%             i%                a%               &#xA;----------------------------------------------------------------------------------------&#xA;  ninja-feet       z[&amp;lt;text object&amp;gt;    z]&amp;lt;text obj&amp;gt;                                      &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-08-27T16:16:01.390" LastActivityDate="2018-08-27T16:16:01.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16855" PostTypeId="2" ParentId="16851" CreationDate="2018-07-23T08:09:43.460" Score="7" Body="&lt;p&gt;See @statox answer for &lt;code&gt;p&lt;/code&gt;, &lt;code&gt;P&lt;/code&gt;, &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Background:  This has to do with the way the cursor works in a terminal (and hence originally the typewriter).  The terminal is a grid of character cells and the cursor is on one of these cells. It is never between two cells.  This is handled differently in modern GUIs where the cursor in a text field normally is &lt;em&gt;between&lt;/em&gt; two characters (and there are no character cells).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when you live in a world of character cells on a grid and the cursor is on one of these cells, where does the next character you type go?  The answer that people came up with was: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;either you overwrite the cell you are on, this is what a typewriter does (and this is replace mode)&lt;/li&gt;&#xA;&lt;li&gt;or you push the contents of the current cell and all the cells right of it one cell to the right and insert the character at the current cell, this is a logical extension of what a typewriter feels like when the cursor is just after the last typed character on a line with only blanks to the right (this is insert mode)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Afterwards the cursor might be moved one cell to the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Link: &lt;a href=&quot;https://en.wikipedia.org/wiki/Insert_key&quot; rel=&quot;noreferrer&quot;&gt;Wiki page&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastEditorUserId="18062" LastEditDate="2018-07-23T13:14:01.387" LastActivityDate="2018-07-23T13:14:01.387" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16856" PostTypeId="2" ParentId="2970" CreationDate="2018-07-23T09:51:32.783" Score="10" Body="&lt;p&gt;From the comments: since version 8.1.105, vim has &lt;code&gt;+vartabs&lt;/code&gt; compile-time feature, thanks to &lt;a href=&quot;/users/71/christian-brabandt&quot;&gt;Christian Brabandt&lt;/a&gt; !&lt;/p&gt;&#xA;&lt;p&gt;As far as I can see, this allows implementing elastic tabstops. See &lt;a href=&quot;https://github.com/vim/vim/pull/2711&quot; rel=&quot;nofollow noreferrer&quot;&gt;the actual pull request&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18316" LastEditorUserId="18316" LastEditDate="2021-01-15T17:09:10.233" LastActivityDate="2021-01-15T17:09:10.233" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16857" PostTypeId="1" CreationDate="2018-07-23T18:54:55.707" Score="3" ViewCount="277" Body="&lt;p&gt;From the help file for showcmd:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Show (partial) command in the last line of the screen&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is it possible to have the commands displayed on the first line instead? I can't find anything in the help or on the web on this subject.&lt;/p&gt;&#xA;" OwnerUserId="18319" LastEditorUserId="51" LastEditDate="2018-07-23T19:25:28.817" LastActivityDate="2023-01-22T04:13:54.650" Title="showcmd on first line instead of last line" Tags="|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16858" PostTypeId="2" ParentId="16857" CreationDate="2018-07-23T19:25:08.063" Score="3" Body="&lt;p&gt;Since &lt;a href=&quot;https://github.com/vim/vim/pull/11684&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim 9.0.1061&lt;/a&gt; (Dec 2022) you can use &lt;code&gt;showcmdloc=tabline&lt;/code&gt; to display the showcmd in the tabline (assuming that is what's intended with &amp;quot;first line&amp;quot;). You can also use &lt;code&gt;showcmd=statusline&lt;/code&gt;, or use &lt;code&gt;%S&lt;/code&gt; in the 'statusline' or 'tabline' settings.&lt;/p&gt;&#xA;&lt;p&gt;Neovim seems to &lt;a href=&quot;https://github.com/neovim/neovim/pull/21202&quot; rel=&quot;nofollow noreferrer&quot;&gt;have ported this patch&lt;/a&gt;, but it's not in any release at the time of writing. Presumably it will be in the upcoming 0.9 release.&lt;/p&gt;&#xA;&lt;p&gt;For older versions you're out of luck, as it's all hard-coded.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2023-01-22T04:13:54.650" LastActivityDate="2023-01-22T04:13:54.650" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16859" PostTypeId="2" ParentId="373" CreationDate="2018-07-23T23:42:25.033" Score="5" Body="&lt;p&gt;In Neovim there also is the &lt;a href=&quot;https://neovim.io/doc/user/options.html#%27inccommand%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'inccommand'&lt;/code&gt;&lt;/a&gt; option which lets you preview the result of the &lt;code&gt;:s&lt;/code&gt; command while you type it.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-23T23:42:25.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16860" PostTypeId="1" AcceptedAnswerId="16861" CreationDate="2018-07-24T04:45:39.123" Score="4" ViewCount="390" Body="&lt;p&gt;Given the word &lt;code&gt;foo&lt;/code&gt; in a text, if I type &lt;code&gt;ciwbar&amp;lt;ESC&amp;gt;&lt;/code&gt; while recording it as a macro in &lt;code&gt;w&lt;/code&gt; register and then type in the command line&#xA;&lt;code&gt;:&amp;lt;C-r&amp;gt;w&lt;/code&gt; it will brings me &lt;code&gt;:ciwbar^[&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if i type &lt;code&gt;:&amp;lt;C-r&amp;gt;.&lt;/code&gt; it will only brings me &lt;code&gt;bar&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But both commands, the &lt;code&gt;@w&lt;/code&gt; and &lt;code&gt;dot&lt;/code&gt;, are able to perform the &lt;strong&gt;change inner word bar&lt;/strong&gt; in other parts of my text&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to get all the content from the dot as I got the &lt;code&gt;w&lt;/code&gt; register? I would like to paste it and work to automate the last command in macros in some steps forward&lt;/p&gt;&#xA;" OwnerUserId="18287" LastActivityDate="2018-07-24T08:23:28.923" Title="How to paste the content from dot . command" Tags="|register|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16861" PostTypeId="2" ParentId="16860" CreationDate="2018-07-24T08:23:28.923" Score="4" Body="&lt;p&gt;As you said yourself there is a difference between a register like &lt;code&gt;@w&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt; which is a command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;.&lt;/code&gt; command is meant to repeat only simple, unit changes (as the doc says &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#.&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h .&lt;/code&gt;&lt;/a&gt;: &lt;code&gt;Simple changes can be repeated with the &quot;.&quot; command.&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, macros recorded in registers are meant to repeat more complex and longer changes (see help is at &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#complex-repeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h complex-repeat&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior of the dot command is hard coded and does not use a register or a buffer which can be accessed by the user so there is no way to get what it will do as a vimscript string.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-07-24T08:23:28.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16862" PostTypeId="2" ParentId="16824" CreationDate="2018-07-24T09:05:15.643" Score="2" Body="&lt;p&gt;This could be implemented using:&#xA;&lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kana/vim-textobj-user&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lots of existing plugins are close to this behavior, but none seems to answer the question yet.&lt;/p&gt;&#xA;" OwnerUserId="15134" LastActivityDate="2018-07-24T09:05:15.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16863" PostTypeId="2" ParentId="16826" CreationDate="2018-07-24T15:18:56.923" Score="1" Body="&lt;h2&gt;&lt;code&gt;=p&lt;/code&gt; from &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-unimpaired&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;pre class=&quot;lang-lua prettyprint-override&quot;&gt;&lt;code&gt;function Scene:get(...)&#xA;&#xA;    local l = {}&#xA;&#xA;    for i, e in ipaires(self.nodelist) do&#xA;        if (e:is(...)) then&#xA;            l[#l +1] = e&#xA;        end&#xA;    end&#xA;&#xA;    return l&#xA;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Yank word &lt;code&gt;function&lt;/code&gt; with &lt;code&gt;yiw&lt;/code&gt;    &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;=p&lt;/code&gt; from unimpaired inserts with reindentation after the current line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fix missing blank line with &lt;kbd&gt;[&lt;/kbd&gt;-&lt;kbd&gt;Space&lt;/kbd&gt; (also only with vim-unimpaired)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is more impressive if you insert several lines from a register. For example, yank full function with &lt;code&gt;yG&lt;/code&gt; in step 1 and then do steps 2 and 3.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-07-24T18:33:33.713" LastActivityDate="2018-07-24T18:33:33.713" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16864" PostTypeId="2" ParentId="16826" CreationDate="2018-07-24T16:27:32.343" Score="0" Body="&lt;h2&gt;&lt;code&gt;gV=&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Using custom mapping &lt;code&gt;gV&lt;/code&gt; to select last changed (pasted) or yanked text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A typical related question is how can I select a just pasted text.&#xA;This would allow you to fix conveniently the indentation afterwards.&#xA;By default there is no builtin keybinding for this. However, it is not difficult to define your own keybinding. &#xA;IMHO &lt;code&gt;gV&lt;/code&gt; is a good choice. Add to your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; gV     &quot;`[&quot; . getregtype(v:register)[0].&quot;`]&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now you can fix it with &lt;code&gt;gV=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mapping is similar to &lt;code&gt;gv&lt;/code&gt; which reselects the last selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, if you yank something else and you want to select your pasted text again, &lt;code&gt;gV&lt;/code&gt; selects the most recent yanked text and does not help you here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find the question several times on the web&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Selecting_your_pasted_text&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Selecting_your_pasted_text&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/4312664/is-there-a-vim-command-to-select-pasted-text&quot;&gt;https://stackoverflow.com/questions/4312664/is-there-a-vim-command-to-select-pasted-text&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/4775088/vim-how-to-select-pasted-block&quot;&gt;https://stackoverflow.com/questions/4775088/vim-how-to-select-pasted-block&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/31/how-do-i-visually-select-the-block-of-text-i-just-pasted-in-vim&quot;&gt;How do I visually select the block of text I just pasted in Vim?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2018-07-24T16:27:32.343" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16865" PostTypeId="1" AcceptedAnswerId="26279" CreationDate="2018-07-24T16:44:31.153" Score="2" ViewCount="656" Body="&lt;p&gt;I have assigned the macro &lt;code&gt;!clear &amp;amp;&amp;amp; gcc % &amp;amp;&amp;amp; ./a.out&lt;/code&gt; to the key 'r'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when I press '@r', I expect vim to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Clear the shell&lt;/li&gt;&#xA;&lt;li&gt;compile the current C file &lt;/li&gt;&#xA;&lt;li&gt;run the output&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The problem is that it does all three but does not wait at the output screen where it shows &quot;Press ENTER or type command to continue&quot; and comes back to command mode.&lt;/p&gt;&#xA;" OwnerUserId="15724" LastEditorUserId="15724" LastEditDate="2018-07-24T18:47:47.043" LastActivityDate="2020-06-29T20:05:41.637" Title="How to make vim shell command wait for keypress?" Tags="|command-line|external-command|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="16866" PostTypeId="2" ParentId="16826" CreationDate="2018-07-24T17:20:51.767" Score="1" Body="&lt;h2&gt;Paste from insert mode &lt;code&gt;&amp;lt;Ctrl-r&amp;gt;0&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can also insert the yanked text from insert mode when &lt;code&gt;autoindent&lt;/code&gt; has added the correct indentation:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;yiw&lt;/code&gt; yank&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&amp;lt;CR&amp;gt;&lt;/code&gt; switch to insert mode and add new line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Ctrl-r&amp;gt;0&lt;/code&gt; paste text from register &lt;code&gt;0&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Drew Neil has created a vimcast&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/episodes/pasting-from-insert-mode/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Episode 55: Pasting from insert mode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would also recommend two articles by Drew Neil:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/blog/2013/11/the-copypaste-series-a-retrospective/&quot; rel=&quot;nofollow noreferrer&quot;&gt;The copy/paste series - a retrospective&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/blog/2013/11/registers-the-good-the-bad-and-the-ugly-parts/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Registers: the Good, the Bad, and the Ugly Parts&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note pasting a code block in insert mode&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to paste not a single word but a code block,&#xA;this answer might not be satisfactory. Replace in step 1 &lt;code&gt;yiw&lt;/code&gt; with &lt;code&gt;yG&lt;/code&gt; and then execute steps 2 and 3, you will end up with&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-lua prettyprint-override&quot;&gt;&lt;code&gt;function Scene:get(...)&#xA;&#xA;    function Scene:get(...)&#xA;&#xA;            local l = {}&#xA;&#xA;                for i, e in ipaires(self.nodelist) do&#xA;                            if (e:is(...)) then&#xA;                                            l[#l +1] = e&#xA;                                                    end&#xA;                                                        end&#xA;&#xA;                                                            return l&#xA;&#xA;                                                        end&#xA;&#xA;&#xA;    local l = {}&#xA;&#xA;    for i, e in ipaires(self.nodelist) do&#xA;        if (e:is(...)) then&#xA;            l[#l +1] = e&#xA;        end&#xA;    end&#xA;&#xA;    return l&#xA;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To fix this you would have to set &lt;code&gt;paste&lt;/code&gt; after you switched to insert mode to take advantage of the autoindentation because &lt;code&gt;paste&lt;/code&gt; disables autoindentation.&#xA;I do not know a simple way to do this and would recommend to paste from normal mode with the help of vim-unimpaired (&lt;code&gt;=p&lt;/code&gt;). Also note yanking into the system clipboard and using the bracketed paste feature does not work for me flawlessly (macOS, Terminals: iTerm2.app v3.1.7 or Terminal.app v2.7.4). &lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-08-14T08:38:18.090" LastActivityDate="2018-08-14T08:38:18.090" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="16867" PostTypeId="1" AcceptedAnswerId="16868" CreationDate="2018-07-24T21:14:37.507" Score="4" ViewCount="1413" Body="&lt;p&gt;I frequently have inline comments for variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var1 = 0    # Var 1&#xA;var2 = 0    # Var 2&#xA;var3 = 0    # Var 3&#xA;var4 = 0    # Var 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(This is in python, for example, but this question applies to C-Style &lt;code&gt;//&lt;/code&gt; just the same.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes it happens that as I develop I have to add new variables and they may end up being longer than the previous variables. I then have to refactor my white space from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var1 = 0    # Var 1&#xA;var2 = 0    # Var 2&#xA;var3 = 0    # Var 3&#xA;var4 = 0    # Var 4&#xA;variable = 234 # Var&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var1 = 0        # Var 1&#xA;var2 = 0        # Var 2&#xA;var3 = 0        # Var 3&#xA;var4 = 0        # Var 4&#xA;variable = 234  # Var&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or thereabouts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I line-by-line it &lt;code&gt;ciw&lt;/code&gt; with the cursor in the white space and then tab a lot. Is there a simpler way to do this? &lt;code&gt;&amp;gt;w&lt;/code&gt; and &lt;code&gt;&amp;gt;W&lt;/code&gt; just indent the line (it honestly seems like &lt;code&gt;&amp;gt;&lt;/code&gt; only indents line by line so I don't understand the 'subject-verb' point of it (it almost seems like &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; is redundant)).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would really like something built-in, like I would have expected &lt;code&gt;&amp;gt;w&lt;/code&gt; to have worked, but if that's not the case, I suppose a plug in will do.&lt;/p&gt;&#xA;" OwnerUserId="17830" LastEditorUserId="17830" LastEditDate="2018-07-24T21:31:40.133" LastActivityDate="2020-09-24T11:20:59.747" Title="How can I easily indent inline comments?" Tags="|indentation|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16868" PostTypeId="2" ParentId="16867" CreationDate="2018-07-24T21:45:34.637" Score="5" Body="&lt;p&gt;&lt;code&gt;&amp;gt;w&lt;/code&gt; doesn't work because &lt;code&gt;&amp;gt;&lt;/code&gt; is a line-wise operator no matter what motion you give it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few ways to accomplish the edit you're looking for:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;1. insertion with repeat&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;After you've inserted tabs/spaces to get the alignment you want, press &lt;code&gt;.&lt;/code&gt; on the remaining lines.  No need to insert again.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;2. visual block insert&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Again visually select a block (&lt;code&gt;ctrl-v3j&lt;/code&gt;) then type &lt;code&gt;I&lt;/code&gt; to insert.  Press &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; to make up the spaces, then press &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;. The insertion will apply to all the lines within the selection. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;3. visual block shift (&lt;code&gt;:help v_b_&amp;lt;&lt;/code&gt;)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Visually select a block (press &lt;code&gt;ctrl-v&lt;/code&gt;) downwards from the first # (&lt;code&gt;3j&lt;/code&gt;).  Now type &lt;code&gt;&amp;gt;&lt;/code&gt;.  This will shift only the text to the right of the start of the visual block selection.  This operation has downsides though, if the space needed isn't a multiple of shiftwidth, and the corresponding &lt;code&gt;&amp;lt;&lt;/code&gt; doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;4. plugin tabular.vim&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Visually select the lines you want to align then type &lt;code&gt;:Tabularize /#/&lt;/code&gt;.  This will look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;Tabularize /#/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the cmdline.  Then the comments will become aligned.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-07-24T21:45:34.637" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16869" PostTypeId="2" ParentId="16867" CreationDate="2018-07-24T21:45:58.427" Score="1" Body="&lt;p&gt;You can use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html#CTRL-V&quot; rel=&quot;nofollow noreferrer&quot;&gt;visual block mode&lt;/a&gt;: Move to the first &lt;code&gt;#&lt;/code&gt; which you want to indent, press &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;, select all the lines you care about and the use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html#blockwise-operators&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;kbd&gt;I&lt;/kbd&gt; or &lt;kbd&gt;A&lt;/kbd&gt;&lt;/a&gt; so insert text before or after the block you selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The text will only appear on the first line until you press &lt;kbd&gt;Esc&lt;/kbd&gt;, then it will also appear on the other lines.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-24T21:45:58.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16870" PostTypeId="1" AcceptedAnswerId="16871" CreationDate="2018-07-25T01:11:04.397" Score="5" ViewCount="1054" Body="&lt;p&gt;Reading the manuals, seems to me that marks and tags are the same thing, only difference is that mark names can be [a-zA-Z] values, while tags can be alphanumeric. If I'm wrong, what is the difference between them?&lt;/p&gt;&#xA;" OwnerUserId="18332" LastActivityDate="2018-07-25T06:57:37.373" Title="difference between marks and tags?" Tags="|tags|mark|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16871" PostTypeId="2" ParentId="16870" CreationDate="2018-07-25T06:57:37.373" Score="5" Body="&lt;p&gt;Both specify certain points in a file and give you commands to jump there and as such they are the same. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#mark-motions&quot; rel=&quot;noreferrer&quot;&gt;marks&lt;/a&gt; are created by vim. Either explicitly by hand with &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#Mark&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;m&lt;/code&gt;&lt;/a&gt; or automatically by vim (for the last selected text, the last position where you entered insert mode and so on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/tagsrch.html#tag-commands&quot; rel=&quot;noreferrer&quot;&gt;Tags&lt;/a&gt; on the other hand are read from the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;tags&amp;#39;&quot; rel=&quot;noreferrer&quot;&gt;tags file&lt;/a&gt; which is normally created by an external command. The idea is that you have some sofisticated program like &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/tagsrch.html#ctags&quot; rel=&quot;noreferrer&quot;&gt;ctags&lt;/a&gt; that parses your source code and writes positions for declarations and definitions into the tags file. Vim reads the tags file and lets you easily jump to intresting points in your code base.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim uses the tags feature for &quot;links&quot; in the documentation. So when you jump from one help topic to the next or execute some &lt;code&gt;:help&lt;/code&gt; command it looks for tags in the &lt;code&gt;doc/&lt;/code&gt; folders in &lt;code&gt;&amp;amp;runtimepath&lt;/code&gt;. If you execute &lt;code&gt;echo globpath(&amp;amp;rtp, 'doc/tags')&lt;/code&gt; you should see the names of these help-tags files.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-25T06:57:37.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16872" PostTypeId="2" ParentId="6208" CreationDate="2018-07-25T08:59:06.167" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Searching_for_expressions_which_include_slashes&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Searching_for_expressions_which_include_slashes&lt;/a&gt; points out that the search register can be set directly, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @/='/abc/def/ghi/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows search on the line and works even when the line includes slashes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to make, say, &lt;code&gt;\*&lt;/code&gt; map to a line search:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;* :set hlsearch&amp;lt;cr&amp;gt;:let @/=getline('.')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18337" LastActivityDate="2018-07-25T08:59:06.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16873" PostTypeId="1" AcceptedAnswerId="16876" CreationDate="2018-07-25T09:20:57.937" Score="2" ViewCount="1279" Body="&lt;p&gt;Should be straight-foward but cannot get it working. I have a text file that has numbers at the beginning of some lines. For e.g:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. Some text....&#xA;running to many lines&#xA;2. Some more text ...&#xA;3. A long line...&#xA;that spans...&#xA;many more..&#xA;lines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to add a prefix &lt;code&gt;3.&lt;/code&gt; to each of the numbers. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s,^\d\+,3\.\1,g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't work. &lt;/p&gt;&#xA;" OwnerUserId="4699" LastActivityDate="2018-07-26T11:11:30.043" Title="Add prefix to numbers at beginning of each line" Tags="|replace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16874" PostTypeId="1" AcceptedAnswerId="16877" CreationDate="2018-07-25T09:58:19.947" Score="3" ViewCount="217" Body="&lt;p&gt;I know it's not a bug, since the &lt;code&gt;help&lt;/code&gt; page explains it cleary, but is there any reason why &lt;code&gt;gt&lt;/code&gt; is still kept different from the majority of commands that accept a &lt;code&gt;{count}&lt;/code&gt; prepended? I mean, isn't it in contrast with &lt;code&gt;vi(m)&lt;/code&gt; phylosophy?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What annoys me the most is that &lt;code&gt;gt&lt;/code&gt; and &lt;code&gt;gT&lt;/code&gt; are not the opposite of each other when a &lt;code&gt;{count}&lt;/code&gt; is prepended (unlike many others, &lt;em&gt;e.g.&lt;/em&gt; &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt;, &lt;code&gt;w&lt;/code&gt; and &lt;code&gt;W&lt;/code&gt;, and so on), so, for instance, I can't &quot;undo&quot; a &lt;code&gt;2gT&lt;/code&gt; by typing &lt;code&gt;2gt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="1841" LastEditDate="2018-07-25T12:00:45.960" LastActivityDate="2022-02-03T06:36:18.900" Title="`gt` is not consistent with `gT` (and many other commands) when `{count}` is prepended" Tags="|tabbed-user-interface|count|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16875" PostTypeId="2" ParentId="16873" CreationDate="2018-07-25T10:11:32.403" Score="3" Body="&lt;p&gt;You can do this with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\ze\d/3.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5cze&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\ze&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\ze Matches at any position, and sets the end of the match there: The&#xA;    previous char is the last char of the whole match. |/zero-width|&#xA;    Can be used multiple times, the last one encountered in a matching&#xA;    branch is used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="1841" LastEditDate="2018-07-26T11:11:30.043" LastActivityDate="2018-07-26T11:11:30.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16876" PostTypeId="2" ParentId="16873" CreationDate="2018-07-25T10:24:13.840" Score="5" Body="&lt;p&gt;Firstly, you don't need to escape the dot in the replacement section (because in that part of the command it doesn't have another possible meaning).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, that's not the cause of your problem, which is instead that you're using &lt;code&gt;\1&lt;/code&gt; (the first captured group), but your expression doesn't contain any groups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can fix this either by adding one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s,^\(\d\),3.\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or more simply by using &lt;code&gt;\0&lt;/code&gt; (the entire match) instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s,^\d,3.\0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note also that the &lt;code&gt;g&lt;/code&gt; flag is unnecessary and so is the &lt;code&gt;\+&lt;/code&gt; repeat. Your expression can only match at the start of the line, so there can only ever be a single match to replace. And &lt;code&gt;^\d&lt;/code&gt; will match the correct position in e.g. &quot;30.&quot; just as well as &lt;code&gt;^\d\+&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-07-25T10:40:15.143" LastActivityDate="2018-07-25T10:40:15.143" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16877" PostTypeId="2" ParentId="16874" CreationDate="2018-07-25T12:00:00.433" Score="4" Body="&lt;p&gt;I can't really explain why it works like this, my best guess is that you more often need to go a tab by its index rather than going 3 tabs forwards.&lt;/p&gt;&#xA;&lt;p&gt;However, if you really don't like how Vim works and want to be able to &amp;quot;undo&amp;quot; a &lt;code&gt;2gT&lt;/code&gt; with &lt;code&gt;2gt&lt;/code&gt; you can add the following to your vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! Mygt(forward, count)&#xA;    let loop = a:count&#xA;    while loop &amp;gt; 0&#xA;        if a:forward&#xA;            normal! gt&#xA;        else&#xA;            normal! gT&#xA;        endif&#xA;        let loop = loop -1&#xA;    endwhile&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; gt :&amp;lt;C-U&amp;gt;execute &amp;quot;call Mygt(1, &amp;quot; . v:count1 . &amp;quot;)&amp;quot;&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; gT :&amp;lt;C-U&amp;gt;execute &amp;quot;call Mygt(0, &amp;quot; . v:count1 . &amp;quot;)&amp;quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The function &lt;code&gt;Mygt()&lt;/code&gt; is pretty straightforward: it takes 2 arguments, the first one is used to define if you want to go forward or backward in the list of tabs and the second one is how many tabs you want to skip. So it loops on the given count and repeats &lt;code&gt;gt&lt;/code&gt; or &lt;code&gt;gT&lt;/code&gt; according to the first parameter.&lt;/p&gt;&#xA;&lt;p&gt;You can try it with &lt;code&gt;:call Mygt(1, 2)&lt;/code&gt; or &lt;code&gt;:call Mygt(0, 4)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;To make it easier to use, we also remap &lt;code&gt;gt&lt;/code&gt; and &lt;code&gt;gT&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; is used to avoid prompting the function called by the mapping. (see &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3amap-%3csilent%3e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :map-&amp;lt;silent&amp;gt;&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; is used to remove characters on the command line, it is used to allow a count to the mapping (see &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-U&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h c_CTRL-U&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;We build the string which will contain the command to execute (e.g. &lt;code&gt;call Mygt(1, 3)&lt;/code&gt; and execute it with &lt;code&gt;execute&lt;/code&gt; (see &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#execute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h execute()&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;And finally, we use the count given to the mapping with &lt;code&gt;v:count1&lt;/code&gt; which will default to &lt;code&gt;1&lt;/code&gt; if no count is given. (see &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#v%3acount&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h v:count&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#v%3acount1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h v:count1&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;All of this allows us to use &lt;code&gt;gt&lt;/code&gt;, &lt;code&gt;gT&lt;/code&gt;, &lt;code&gt;3gt&lt;/code&gt; and &lt;code&gt;5gT&lt;/code&gt; and get a &amp;quot;consistent&amp;quot; behavior.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="6498" LastEditDate="2022-02-02T22:47:57.403" LastActivityDate="2022-02-02T22:47:57.403" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="16878" PostTypeId="1" AcceptedAnswerId="16886" CreationDate="2018-07-25T13:32:18.070" Score="0" ViewCount="514" Body="&lt;p&gt;I'm trying to do two things involving &lt;strong&gt;blank&lt;/strong&gt; lines (empty lines or lines with only white-space on them).&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Move to the next &lt;strong&gt;blank&lt;/strong&gt; line (or EOF if none)&lt;/li&gt;&#xA;&lt;li&gt;Filter (using &lt;code&gt;!&lt;/code&gt;) to the next &lt;strong&gt;blank&lt;/strong&gt; line (or EOF if none)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Number 1 is similar to &lt;code&gt;}&lt;/code&gt;, but allows for lines with only white-space.  I thought number 2 would be easy if I could do number 1.  But unfortunately, reality has intervened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the &lt;code&gt;.vimrc&lt;/code&gt; that I have so far to test my mapping (using &lt;code&gt;nl -ba&lt;/code&gt; as a test filter):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;set list       &quot; to distinguish empty lines from blank lines&#xA;map } :&amp;lt;C-u&amp;gt;call search('^\s*$\\|\%$', 'W')&amp;lt;CR&amp;gt;&#xA;map - !}nl -ba&amp;lt;CR&amp;gt;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Creating a test file with some data, some empty lines and some white-space only lines, I notice the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;My new &lt;code&gt;}&lt;/code&gt; motion command seems to work just as I would like.&lt;/li&gt;&#xA;&lt;li&gt;The filter command (&lt;code&gt;-&lt;/code&gt;) works fine, &lt;strong&gt;except&lt;/strong&gt; if the last line of the file has only a single character on it, which is treated as its own independent &quot;paragraph&quot; and not included along with the previous lines.  This is unlike the way the &lt;code&gt;}&lt;/code&gt; motion command works.&lt;/li&gt;&#xA;&lt;li&gt;However, the filter command hangs for many seconds (or indefinitely?) on some machines which are running different versions of vim 7.4 (I never did get an opportunity to isolate this hanging issue and it ended up disappearing in my solution below).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I've tried various combinations of &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;noremap&lt;/code&gt;, etc. but that doesn't seem to help, except to prevent my &lt;code&gt;}&lt;/code&gt; motion mapping from being recognized inside the filter mapping, which is obviously not what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how can I map &lt;code&gt;}&lt;/code&gt; to also find blank lines and still use it properly in a filter (&lt;code&gt;!&lt;/code&gt;) command.  Hopefully the changes will also avoid the hanging that I'm experiencing on some machines (which obviously makes those solutions unusable).  Lacking the ability to make &lt;code&gt;}&lt;/code&gt; work reliably inside filter commands, I would be willing to use something else in those filter commands that would accomplish what I'm looking for.&lt;/p&gt;&#xA;" OwnerUserId="9490" LastEditorUserId="9490" LastEditDate="2018-07-25T22:15:46.037" LastActivityDate="2018-07-26T06:11:08.020" Title="Move/filter to next *blank* line" Tags="|key-bindings|command-line|filter|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16879" PostTypeId="1" AcceptedAnswerId="16880" CreationDate="2018-07-25T13:44:11.807" Score="1" ViewCount="154" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FtLEb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FtLEb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;My problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Consider a code block prefixed with a few words (function name, for example). The vim cursor is in the middle of the prefix word. The line ends with a &lt;code&gt;{&lt;/code&gt;, which declares a block which spans a few more lines, till a matching &lt;code&gt;}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to delete the entire block - from the line marked as &quot;24&quot; to the line marked as &quot;7&quot;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What have I tried&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;d%&lt;/code&gt; deletes from the cursor position onwards, till the end of the block, but keeps the &lt;code&gt;subgraph c&lt;/code&gt; part intact.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d8d&lt;/code&gt; works, but I need to know how many lines does the block span.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d%dd&lt;/code&gt; works, but I hope there's a more elegant way that I'm missing&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;My Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;How can I delete an entire block, including the entire line in which the block starts, with any prefixes before the opening braces?&lt;/p&gt;&#xA;" OwnerUserId="13179" LastEditorUserId="1292" LastEditDate="2018-07-25T19:06:42.293" LastActivityDate="2020-10-01T16:38:41.207" Title="Delete entire block, with the prefixes before the opening {" Tags="|cursor-motions|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16880" PostTypeId="2" ParentId="16879" CreationDate="2018-07-25T13:55:07.587" Score="7" Body="&lt;p&gt;With the cursor on the first line, the proper operation is &lt;code&gt;dV%&lt;/code&gt;.  The &lt;code&gt;d%&lt;/code&gt; means delete from the next &lt;code&gt;{&lt;/code&gt; to the matching &lt;code&gt;}&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;V&lt;/code&gt; forces the &lt;code&gt;d&lt;/code&gt; operator to work &lt;strong&gt;linewise&lt;/strong&gt;, rather than &lt;strong&gt;characterwise&lt;/strong&gt;.  See (&lt;code&gt;:h o_v&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="8953" LastEditDate="2020-10-01T16:38:41.207" LastActivityDate="2020-10-01T16:38:41.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16881" PostTypeId="2" ParentId="16879" CreationDate="2018-07-25T14:20:25.080" Score="3" Body="&lt;p&gt;Press &lt;code&gt;V&lt;/code&gt;, which highlights the line under cursor, then repeatedly &lt;code&gt;cursor-down&lt;/code&gt; until the block ends (which highlights more lines), then &lt;code&gt;d&lt;/code&gt; to delete this block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage is, that you have a visual feedback on what gets deleted.&lt;/p&gt;&#xA;" OwnerUserId="18342" LastActivityDate="2018-07-25T14:20:25.080" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16882" PostTypeId="1" CreationDate="2018-07-25T16:43:41.850" Score="2" ViewCount="68" Body="&lt;p&gt;When I'm using vim to edit files in a django application that is running in developer mode I sometimes encounter this crash coming from the auto-reload utility:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;File &quot;/home/zefciu/.virtualenvs/15five/lib/python3.6/site-packages/django/utils/autoreload.py&quot;, line 207, in code_changed&#xA;    stat = os.stat(filename)&#xA;FileNotFoundError: [Errno 2] No such file or directory:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I understand is, that django is trying to check for a file that due to the way vim handles saving doesn't exist in that moment. This causes django to crash instead of reloading the application as it is meant to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to provide a patch for this crash, so in this situation, django would wait and retry the operation. I have no idea, however, what should be a sensible timeout for this? How long should I wait for the file to appear again?&lt;/p&gt;&#xA;" OwnerUserId="264" LastEditorUserId="1841" LastEditDate="2018-07-25T19:04:49.187" LastActivityDate="2018-07-25T19:04:49.187" Title="How long can a file be non-existent when I'm saving it in vim" Tags="|save|filesystem|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16883" PostTypeId="1" AcceptedAnswerId="16889" CreationDate="2018-07-25T20:39:28.310" Score="4" ViewCount="1878" Body="&lt;p&gt;I really like &lt;code&gt;Ctrl-E&lt;/code&gt; and &lt;code&gt;Ctrl-Y&lt;/code&gt; in normal mode, which expose additional lines at the bottom or top of the screen (respectively) without moving the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to do the same thing in insert mode sometimes when I'm writing and want to look at some earlier text a few lines up at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Ctrl-E&lt;/code&gt; and &lt;code&gt;Ctrl-Y&lt;/code&gt; in insert mode don't do this (although what they do is actually incredibly interesting and useful, especially while modifying config files or markdown tables—see &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-E&lt;/code&gt;&lt;/a&gt;), and I don't know what keywords to search for to find what I'm looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware of &lt;code&gt;Ctrl-O Ctrl-E&lt;/code&gt;, and &lt;code&gt;Ctrl-O Ctrl-Y&lt;/code&gt;, but those seem kind of unwieldy for regular use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any shorter keybinding that exists in Vim to do this, without special configuration?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastEditorUserId="1841" LastEditDate="2018-07-26T07:51:59.120" LastActivityDate="2018-07-26T07:51:59.120" Title="Scroll view up or down while in insert mode" Tags="|insert-mode|scrolling|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16884" PostTypeId="2" ParentId="16883" CreationDate="2018-07-25T21:09:12.033" Score="1" Body="&lt;p&gt;If you &lt;code&gt;set mouse=a&lt;/code&gt; the mouse can also scroll in insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the &lt;kbd&gt;↑&lt;/kbd&gt; and &lt;kbd&gt;↓&lt;/kbd&gt; keys also work in insert mode. But they do not scroll but move the cursor just like the shifted versions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And with extra configuration you can obviously do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-Up&amp;gt; &amp;lt;C-O&amp;gt;&amp;lt;C-E&amp;gt;&#xA;inoremap &amp;lt;C-Down&amp;gt; &amp;lt;C-O&amp;gt;&amp;lt;C-Y&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or similar things.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-25T21:09:12.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16886" PostTypeId="2" ParentId="16878" CreationDate="2018-07-25T22:43:10.310" Score="0" Body="&lt;p&gt;I ended up using something like this solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map } :&amp;lt;C-u&amp;gt;call search('^\s*$\\|\%$', 'W')&amp;lt;CR&amp;gt;&#xA;map - mx}!'x nl -ba&amp;lt;CR&amp;gt;}&#xA;map = mx}my!'x nl -ba&amp;lt;CR&amp;gt;'y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note:  These two solutions use different ways of moving the cursor after the operation.  Different commands may need different techniques, depending on how the external command in question modifies the block of lines being filtered through it (e.g. does it return fewer lines than it was given as input?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ended up exploring different motion commands, based on the suggestion from @Mass in his comments to the question.  The relevant information is in the motion.txt help page.&lt;/p&gt;&#xA;" OwnerUserId="9490" LastActivityDate="2018-07-25T22:43:10.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16887" PostTypeId="2" ParentId="16878" CreationDate="2018-07-26T06:11:08.020" Score="0" Body="&lt;p&gt;You should also be able to do this in command mode where it might be more readable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap - /\v^\s*$&amp;lt;BAR&amp;gt;%$&amp;lt;CR&amp;gt;&#xA;nnoremap = :.,/\v^\s*$&amp;lt;BAR&amp;gt;%$/ ! nl -ba&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-26T06:11:08.020" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16888" PostTypeId="1" AcceptedAnswerId="16890" CreationDate="2018-07-26T07:44:41.133" Score="4" ViewCount="2300" Body="&lt;p&gt;I find and replace a pattern in all the files in my project (which is a big one). After the search is done, quickfix window is opened with the matches. The matches are in different files in different directories/sub-directories. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I want to replace all the matches in the quickfix list, I run the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cfdo %s/old/new/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sometimes I want to replace only the matches in files that are in a specific directory (e.g., &lt;code&gt;DPUST&lt;/code&gt;) and don't touch the matches in the files in the other directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried running the following command while the cursor is in quickfix window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/DPUST/cfdo %s/old/new/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I found that this tries to replace the matches in every quickfix entry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing to get this to work?&lt;/p&gt;&#xA;" OwnerUserId="16800" LastEditorUserId="16800" LastEditDate="2018-07-26T08:53:53.283" LastActivityDate="2019-04-25T15:20:19.753" Title="Using global command on Quickfix entries" Tags="|replace|quickfix|global-command|" AnswerCount="2" CommentCount="3" ClosedDate="2018-07-30T07:14:22.770" ContentLicense="CC BY-SA 4.0" />
  <row Id="16889" PostTypeId="2" ParentId="16883" CreationDate="2018-07-26T07:49:25.127" Score="4" Body="&lt;p&gt;The built-in way to scroll while in insert mode is described at &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-X_CTRL-E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-X_CTRL-E&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *i_CTRL-X_CTRL-E*&#xA;CTRL-X CTRL-E       scroll window one line up.&#xA;            When doing completion look here: |complete_CTRL-E|&#xA;&#xA;                        *i_CTRL-X_CTRL-Y*&#xA;CTRL-X CTRL-Y       scroll window one line down.&#xA;            When doing completion look here: |complete_CTRL-Y|&#xA;&#xA;After CTRL-X is pressed, each CTRL-E (CTRL-Y) scrolls the window up (down) by&#xA;one line unless that would cause the cursor to move from its current position&#xA;in the file.  As soon as another key is pressed, CTRL-X mode is exited and&#xA;that key is interpreted as in Insert mode.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I particularly like the fact that once you pressed &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt; you can keep pressing &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt; or &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt; without having to press &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt; again.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-07-26T07:49:25.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16890" PostTypeId="2" ParentId="16888" CreationDate="2018-07-26T08:09:06.167" Score="8" Body="&lt;h2&gt;Update: New official vim plugin &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/pack/dist/opt/cfilter/plugin/cfilter.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;cfilter&lt;/em&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Since &lt;a href=&quot;https://github.com/vim/vim/commit/8c5e0093c9badced73e382915fb024a5c3ea463b&quot; rel=&quot;nofollow noreferrer&quot;&gt;21.8.2018 (patch: 8.1.0311)&lt;/a&gt; the plugin &lt;em&gt;cfilter&lt;/em&gt; is distributed with vim in &lt;code&gt;$VIMRUNTIME&lt;/code&gt;. It is documented under &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#cfilter-plugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h cfilter-plugin&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Load plugin &lt;em&gt;cfilter&lt;/em&gt; when needed or load it always in your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:packadd cfilter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using abbreviations in case of a vanilla vim this can be as short as &lt;code&gt;:pa c&amp;lt;tab&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Filter quickfix list with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Cfilter DPUST&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, using abbreviations in case of vanilla vim the command &lt;code&gt;:Cfilter&lt;/code&gt; can be shortened to &lt;code&gt;:Cf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run &lt;code&gt;:cfdo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cfdo %s/old/new/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original Answer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I see it, &lt;code&gt;:cfdo&lt;/code&gt; works on the quickfix list. This will not be changed by prefixing the command with &lt;code&gt;:g/DPUST/&lt;/code&gt;. You could have come up with &lt;code&gt;:v/DPUST/delete&lt;/code&gt; and then &lt;code&gt;:cfdo %s/old/new/gc&lt;/code&gt;. However, the quickfix list cannot be changed easily. There are quite a few plugins which provide support for this&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tommcdo/vim-lister&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-lister&lt;/a&gt; &lt;code&gt;:Qfilter DPUST&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/romainl/vim-qf&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-qf&lt;/a&gt; &lt;code&gt;:Keep DPUST&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/sk1418/QFGrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;QFGrep&lt;/a&gt; &lt;code&gt;:QFGrepPat DPUST&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Following plugins allow to remove lines from the quickfix list with vim commands e.g. &lt;code&gt;:v/DPUST/d&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/stefandtw/quickfix-reflector.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;quickfix-reflector&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/itchyny/vim-qfedit&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-qfedit&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If do not want a full plugin, add following  lines to your vimrc to get the command &lt;code&gt;:Qfilter&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; From https://github.com/dhruvasagar/dotfiles/blob/master/vim/plugin/filter_list.vim&#xA;function! s:FilterList(list, bang, pattern)&#xA;  let list = deepcopy(a:list)&#xA;  let [cmp, and_or] = a:bang ? ['!~#', '&amp;amp;&amp;amp;'] : ['=~#', '||']&#xA;  return filter(a:list, &quot;bufname(v:val.bufnr) &quot; . cmp . &quot; a:pattern &quot; . and_or . &quot; v:val.text &quot; . cmp . &quot; a:pattern&quot;)&#xA;endfunction&#xA;function! s:FilterQuickfixList(bang, pattern)&#xA;  call setqflist(s:FilterList(getqflist(), a:bang, a:pattern))&#xA;endfunction&#xA;command! -bang -nargs=1 -complete=file Qfilter call s:FilterQuickfixList(&amp;lt;bang&amp;gt;0, &amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has already been asked:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/15406138/is-it-possible-to-grep-vims-quickfix&quot;&gt;Is it possible to grep Vim's quickfix?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/6511/how-do-i-make-list-of-search-results-editable&quot;&gt;How do I make list of search results editable?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/42905008/quickfix-list-how-to-add-and-remove-entries&quot;&gt;Quickfix list, how to add and remove entries&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note &lt;code&gt;grep&lt;/code&gt; stands for &lt;code&gt;global/regular expression/print&lt;/code&gt;. Questions using the term &lt;code&gt;grep&lt;/code&gt; or &lt;code&gt;global&lt;/code&gt; are referring possibly to identical tasks.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-04-25T15:20:19.753" LastActivityDate="2019-04-25T15:20:19.753" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16891" PostTypeId="2" ParentId="16888" CreationDate="2018-07-26T08:49:57.800" Score="2" Body="&lt;p&gt;If you need the quickfix list to decide what directory you want to use/exclude why do you not just execute another search just before the &lt;code&gt;:cfdo&lt;/code&gt;? Like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;first you search &lt;code&gt;:RIPGREP search-term&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;look at the result and decide what to include&lt;/li&gt;&#xA;&lt;li&gt;rerun the last command with some explicit directory &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;↑&lt;/kbd&gt;&lt;code&gt;some-dir&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;then run your replace command: &lt;code&gt;:cfdo %s/foo/bar/gc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If your custom &lt;code&gt;:RIPGREP&lt;/code&gt; command supports command chaining you can type 3 and 4 on one line and if you use this really often you can try to turn it into a custom command (retrieve the last command from history with &lt;code&gt;histget()&lt;/code&gt;). &lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-26T08:49:57.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16893" PostTypeId="1" AcceptedAnswerId="16894" CreationDate="2018-07-26T16:05:55.830" Score="1" ViewCount="78" Body="&lt;p&gt;Essentially, what if I want the markdown color scheme for a file not ending in .md? Sometimes I create files conforming to the markdown standard, but they don't have a .md extension.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, this would be a single option I could pass when calling &lt;code&gt;vim&lt;/code&gt;, but the manpage doesn't seem to say how this can be achieved. &lt;/p&gt;&#xA;" OwnerUserId="18355" LastActivityDate="2018-07-26T19:58:03.900" Title="How do I manually set the colorscheme for a single editing session?" Tags="|color|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16894" PostTypeId="2" ParentId="16893" CreationDate="2018-07-26T16:10:07.670" Score="3" Body="&lt;p&gt;You can execute &lt;code&gt;:setfiletype markdown&lt;/code&gt; inside vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you edit this file often and always want it to be recognized as markdown you can add a &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#modeline&quot; rel=&quot;nofollow noreferrer&quot;&gt;modeline&lt;/a&gt; to it.  Put this like at the top or bottom of the file (yes it should be a HTML comment):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!-- vim: set ft=markdown: --&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to understand more about these concepts you can read&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_06.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help usr_06&lt;/code&gt;&lt;/a&gt; an introduction to using the syntax feature&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_44.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help usr_44&lt;/code&gt;&lt;/a&gt; how all the different elements are detected in your source code&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help syntax.txt&lt;/code&gt;&lt;/a&gt; the documentation for all the related commands, includeing&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#:colorscheme&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :colorscheme&lt;/code&gt;&lt;/a&gt; the command to change the colors used by vim&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Short overview:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole concept roughly works like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vim detects the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/filetype.html#filetype&quot; rel=&quot;nofollow noreferrer&quot;&gt;filetype&lt;/a&gt; of a file, either from the extension of the file, from its contents or from a &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#modeline&quot; rel=&quot;nofollow noreferrer&quot;&gt;modeline&lt;/a&gt; in the file&lt;/li&gt;&#xA;&lt;li&gt;based on the filetype a syntax file can (automatically) be sourced, this will define which part of your text belongs to what group (like if it is a command, a number, a string a comment and so on)&lt;/li&gt;&#xA;&lt;li&gt;the different syntax groups can get different colors (and other display attributes) assigned to them by the colorscheme&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18062" LastEditorUserId="18062" LastEditDate="2018-07-26T19:58:03.900" LastActivityDate="2018-07-26T19:58:03.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16895" PostTypeId="1" AcceptedAnswerId="16897" CreationDate="2018-07-27T01:07:34.030" Score="0" ViewCount="80" Body="&lt;p&gt;In command mode, &lt;code&gt;r&lt;/code&gt; replaces the character under the cursor by the one pressed right after typing &lt;code&gt;r&lt;/code&gt; without going into insert mode, so there's no &lt;code&gt;esc&lt;/code&gt; to press.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;5r&lt;/code&gt; replaces the 5 characters starting from the one under the cursor by the &lt;strong&gt;same&lt;/strong&gt; single character typed after &lt;code&gt;5r&lt;/code&gt; (the new character is repeated 5 times).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to replace N characters by N other characters (some or all of them different from each other) without having to press &lt;code&gt;Esc&lt;/code&gt; &lt;em&gt;(or any other key)&lt;/em&gt; after I typed the N characters, that is, I'd like to avoid using e.g. &lt;code&gt;5s&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't find any way to do so. Is it possible? If there's no existing pre-defined command, what key binding could provide this functionality?&lt;/p&gt;&#xA;" OwnerUserId="12085" LastEditorUserId="12085" LastEditDate="2018-07-27T02:08:11.907" LastActivityDate="2018-07-27T23:47:54.040" Title="how to replace N characters without having to press &lt;esc&gt;, is it possible?" Tags="|key-bindings|substitute|replace|repeated-commands|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16896" PostTypeId="2" ParentId="16895" CreationDate="2018-07-27T01:41:42.367" Score="1" Body="&lt;p&gt;This is obviously hardcoded to 5. But it should be possible to generalize it to &lt;code&gt;n&lt;/code&gt; if you need. It demonstrates the trick. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F1&amp;gt; :execute &quot;normal c5l&quot;.nr2char(getchar()).nr2char(getchar()).nr2char(getchar()).nr2char(getchar()).nr2char(getchar())&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13731" LastActivityDate="2018-07-27T01:41:42.367" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16897" PostTypeId="2" ParentId="16895" CreationDate="2018-07-27T03:21:23.077" Score="1" Body="&lt;p&gt;To meet all your requirements a function will probably be needed in addition to a mapping. Put both of these in your Vim start-up file (e.g. &lt;code&gt;.vimrc&lt;/code&gt;) and the functionality will be available each time you launch Vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! ReplaceNChars(n)&#xA;    let inchars = &quot;&quot;&#xA;    let idx = a:n&#xA;    echom 'Enter ' . a:n . ' characters: '&#xA;    while idx &amp;gt; 0&#xA;        let inchars .= nr2char(getchar())&#xA;        let idx -= 1&#xA;    endwhile&#xA;    exec 'norm! R' . inchars&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function takes a number and then waits for that many characters to be entered by the user. Then Normal mode &lt;code&gt;R&lt;/code&gt; is used to replace whatever is currently under the cursor with the entered text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is very straightforward so I won't go into the details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the mapping...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;R ':&amp;lt;C-U&amp;gt;call ReplaceNChars(' . v:count1 . ')&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use it, in Normal mode enter the number of characters to replace, then, assuming you have the default leader key, enter &lt;code&gt;\R&lt;/code&gt;. (Replace this part with whatever you want.) You'll be taken to the command line. Enter the appropriate number of characters and then the replacement will occur. No extra keys like &lt;kbd&gt;Esc&lt;/kbd&gt; or &lt;kbd&gt;Enter&lt;/kbd&gt; are required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unlike the code this mapping uses some constructs that may not be well known. Some details (with Vim help links):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap-%3Cexpr%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt; : The right side of the mapping is an expression that is evaluated and the result is the actual mapping. &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap-%3Csilent%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt;&lt;/a&gt; : Prevents the mapped command from being echoed on the command line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-U&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt;&lt;/a&gt; : Clears the command line before inserting the rest of our command.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#v%3Acount&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;v:count1&lt;/code&gt;&lt;/a&gt; : Variable that contains the last user-entered count. If no count has been entered defaults to 1. In our case the default will mean that the mapping will behave much like the &lt;code&gt;r&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I haven't done any negative testing or tried any corner case input. Just normal use cases.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-07-27T23:47:54.040" LastActivityDate="2018-07-27T23:47:54.040" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16898" PostTypeId="1" CreationDate="2018-07-27T03:47:45.913" Score="0" ViewCount="1913" Body="&lt;p&gt;On my Raspberry Pi, I have a global configuration file at &lt;code&gt;/etc/vim/vimrc&lt;/code&gt;. I also have a file at &lt;code&gt;/etc/vimrc&lt;/code&gt;. I've tried modifying this second file, probably because I read somewhere that this is where to modify a global vimrc file for the system, but it hasn't made the expected changes. (Specifically, &lt;code&gt;set hlsearch&lt;/code&gt;.) I'd prefer not to modify that giant global file located at the first filepath, but rather to modify the 'next' configuration file that takes effect globally. How would I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus points: is the file at &lt;code&gt;/etc/vimrc&lt;/code&gt; in completely the wrong spot? If so, where should I put it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extra info: I want to modify the global configuration file so that I have identical behaviors if I'm modifying files as root (via sudo or su).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit to add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May  7 2017 07:53:41)&#xA;Included patches: 1-488, 576&#xA;Extra patches: 8.0.0378, 8.0.0377, 8.0.0322, 8.0.0056&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by buildd@&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +comments        +ex_extra        +jumplist        -mouseshape      +path_extra      +signs           +textobjects     +writebackup&#xA;+arabic          +conceal         +extra_search    +keymap          +mouse_dec       -perl            +smartindent     +title           -X11&#xA;+autocmd         +cryptv          +farsi           +langmap         +mouse_gpm       +persistent_undo -sniff           -toolbar         -xfontset&#xA;-balloon_eval    +cscope          +file_in_path    +libcall         -mouse_jsbterm   +postscript      +startuptime     +user_commands   -xim&#xA;-browse          +cursorbind      +find_in_path    +linebreak       +mouse_netterm   +printer         +statusline      +vertsplit       -xsmp&#xA;++builtin_terms  +cursorshape     +float           +lispindent      +mouse_sgr       +profile         -sun_workshop    +virtualedit     -xterm_clipboard&#xA;+byte_offset     +dialog_con      +folding         +listcmds        -mouse_sysmouse  -python          +syntax          +visual          -xterm_save&#xA;+cindent         +diff            -footer          +localmap        +mouse_urxvt     -python3         +tag_binary      +visualextra     -xpm&#xA;-clientserver    +digraphs        +fork()          -lua             +mouse_xterm     +quickfix        +tag_old_static  +viminfo&#xA;-clipboard       -dnd             +gettext         +menu            +multi_byte      +reltime         -tag_any_white   +vreplace&#xA;+cmdline_compl   -ebcdic          -hangul_input    +mksession       +multi_lang      +rightleft       -tcl             +wildignore&#xA;+cmdline_hist    +emacs_tags      +iconv           +modify_fname    -mzscheme        -ruby            +terminfo        +wildmenu&#xA;+cmdline_info    +eval            +insert_expand   +mouse           +netbeans_intg   +scrollbind      +termresponse    +windows&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation:&#xA;gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux -lacl -lattr -lgpm -ldl&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help system-vimrc&#xA;                                                    *system-vimrc*&#xA; b. For Unix, MS-DOS, MS-Windows, OS/2, VMS, Macintosh, RISC-OS and Amiga&#xA;    the system vimrc file is read for initializations.  The path of this&#xA;    file is shown with the &quot;:version&quot; command.  Mostly it's &quot;$VIM/vimrc&quot;.&#xA;    Note that this file is ALWAYS read in 'compatible' mode, since the&#xA;    automatic resetting of 'compatible' is only done later.  Add a &quot;:set&#xA;    nocp&quot; command if you like.&#xA;    For the Macintosh the $VIMRUNTIME/macmap.vim is read.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;cd $VIM&lt;/code&gt; pwd moves to &lt;code&gt;/usr/share/vim&lt;/code&gt;... but on a whim I checked that directory...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;user@raspberrypi:~ $ ls -la /usr/share/vim/&#xA;total 20&#xA;drwxr-xr-x   5 root root 4096 Feb 20 22:33 .&#xA;drwxr-xr-x 193 root root 4096 Jul 19 17:51 ..&#xA;drwxr-xr-x   4 root root 4096 Apr  8  2017 addons&#xA;drwxr-xr-x   2 root root 4096 Feb 20 22:33 registry&#xA;drwxr-xr-x  16 root root 4096 Feb 20 22:33 vim74&#xA;lrwxrwxrwx   1 root root    8 Apr 12  2015 vimfiles -&amp;gt; /etc/vim&#xA;lrwxrwxrwx   1 root root   14 May  7  2017 vimrc -&amp;gt; /etc/vim/vimrc&#xA;lrwxrwxrwx   1 root root   19 May  7  2017 vimrc.tiny -&amp;gt; /etc/vim/vimrc.tiny&#xA;user@raspberrypi:~ $ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and tada: &lt;code&gt;$VIM/vimrc&lt;/code&gt; is symlinked to &lt;code&gt;/etc/vim/vimrc&lt;/code&gt;. So now I know which file is being sourced as the &lt;code&gt;$VIMRC&lt;/code&gt; file. Unfortunately, the next help section below &lt;code&gt;system-vimrc&lt;/code&gt; tells me...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  *VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc* *$MYVIMRC*&#xA;c. Four places are searched for initializations.  The first that exists&#xA;    is used, the others are ignored.  The $MYVIMRC environment variable is&#xA;    set to the file that was first found, unless $MYVIMRC was already set&#xA;    and when using VIMINIT.&#xA;    -  The environment variable VIMINIT (see also |compatible-default|) (*)&#xA;       The value of $VIMINIT is used as an Ex command line.&#xA;    -  The user vimrc file(s):&#xA;                &quot;$HOME/.vimrc&quot;         (for Unix and OS/2) (*)&#xA;                &quot;$HOME/.vim/vimrc&quot;     (for Unix and OS/2) (*)&#xA;                &quot;s:.vimrc&quot;             (for Amiga) (*)&#xA;                &quot;home:.vimrc&quot;          (for Amiga) (*)&#xA;                &quot;home:vimfiles:vimrc&quot;  (for Amiga) (*)&#xA;                &quot;$VIM/.vimrc&quot;          (for OS/2 and Amiga) (*)&#xA;                &quot;$HOME/_vimrc&quot;         (for MS-DOS and Win32) (*)&#xA;                &quot;$HOME/vimfiles/vimrc&quot; (for MS-DOS and Win32) (*)&#xA;                &quot;$VIM/_vimrc&quot;          (for MS-DOS and Win32) (*)&#xA;            Note: For Unix, OS/2 and Amiga, when &quot;.vimrc&quot; does not exist,&#xA;            &quot;_vimrc&quot; is also tried, in case an MS-DOS compatible file&#xA;            system is used.  For MS-DOS and Win32 &quot;.vimrc&quot; is checked&#xA;            after &quot;_vimrc&quot;, in case long file names are used.&#xA;            Note: For MS-DOS and Win32, &quot;$HOME&quot; is checked first.  If no&#xA;            &quot;_vimrc&quot; or &quot;.vimrc&quot; is found there, &quot;$VIM&quot; is tried.&#xA;            See |$VIM| for when $VIM is not set.&#xA;    -  The environment variable EXINIT.&#xA;       The value of $EXINIT is used as an Ex command line.&#xA;    -  The user exrc file(s).  Same as for the user vimrc file, but with&#xA;       &quot;vimrc&quot; replaced by &quot;exrc&quot;.  But only one of &quot;.exrc&quot; and &quot;_exrc&quot; is&#xA;       used, depending on the system.  And without the (*)!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... that &lt;code&gt;The first that exists is used, the others are ignored.&lt;/code&gt; when it comes to configuration files. So it would seem, then, that there is no way for a file to be sourced by &lt;em&gt;all&lt;/em&gt; instances of vim, &lt;em&gt;after&lt;/em&gt; the global vim config file is sourced, aside from the user's vim configuration file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So then the question becomes: is it poor practice to symlink multiple users' .vimrc files to one user's .vimrc file? Because that seems to be the only way to modify a configuration file which is not the &lt;code&gt;/etc/vim/vimrc&lt;/code&gt; gargantuan monster which I want to avoid touching (and thus risk breaking).&lt;/p&gt;&#xA;" OwnerUserId="16795" LastEditorUserId="16795" LastEditDate="2018-07-27T17:07:00.453" LastActivityDate="2018-07-27T18:09:02.013" Title="Can I add configuration to /etc/vimrc that takes effect after the configuration in /etc/vim/vimrc?" Tags="|vimrc|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16899" PostTypeId="2" ParentId="16898" CreationDate="2018-07-27T05:18:39.393" Score="1" Body="&lt;p&gt;You can take a look at the man page or at &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/starting.html#system-vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help system-vimrc&lt;/code&gt;&lt;/a&gt; or &lt;code&gt;:version&lt;/code&gt; to find out which is your &lt;em&gt;real&lt;/em&gt; system wide vimrc file. It should probably source the other one (if it doesn't then it is clear why your changes take no effect if you put them there).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember that the system vimrc file is sourced in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27cp%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'compatible'&lt;/code&gt;&lt;/a&gt; mode and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27hlsearch%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'hlsearch'&lt;/code&gt;&lt;/a&gt; is only available in vim but not vi so you might need to &lt;code&gt;:set nocp&lt;/code&gt; first.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-27T05:18:39.393" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16900" PostTypeId="1" CreationDate="2018-07-27T14:12:20.423" Score="1" ViewCount="307" Body="&lt;p&gt;I'm trying to set up Dein to load the &lt;a href=&quot;https://github.com/jsfaint/gen_tags.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;gen_tags&lt;/a&gt; plugin. However, if Universal/Exuberant Ctags or GNU Global aren't found on the path, I get the following error message when trying to start &lt;code&gt;nvim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ctags not found&lt;br&gt;&#xA;  gen_tags.vim need ctags to generate tags&lt;br&gt;&#xA;  GNU Global not found&lt;br&gt;&#xA;  gen_gtags.vim need GNU Global&lt;br&gt;&#xA;  Press ENTER or type command to continue  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Pressing enter does nothing. Sometimes I can get the prompt back with &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt;. Sometimes it locks up and I have to crash the shell. I haven't found what controls that behavior yet. If &lt;code&gt;ctags&lt;/code&gt; and &lt;code&gt;global&lt;/code&gt; are on the &lt;code&gt;$PATH&lt;/code&gt;, everything works great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But ideally I would like Dein to only attempt to load the plugin if &lt;code&gt;ctags&lt;/code&gt; or &lt;code&gt;global&lt;/code&gt; are available so I don't encounter this error message when setting up a new machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are three different options that I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call dein#add('jsfaint/gen_tags.vim', { 'depends': ['ctags', 'global']})             &quot;tag maintainer&#xA;call dein#add('jsfaint/gen_tags.vim', { 'on_cmd': ['ctags', 'global']})             &quot;tag maintainer&#xA;call dein#add('jsfaint/gen_tags.vim', { 'on_if': 'empty(glob($VIM.&quot;/exe/ctags&quot;))'})             &quot;tag maintainer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What are the correct options to pass to Dein to conditionally load this plugin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm doing this on Windows 10 and PowerShell with neovim. I haven't tried this on a Linux system yet but eventually I would like this to work cross platform.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've tried Christian's solution as well as another Dein option. Both fail to load the plugin when it is first added to the path and only &lt;code&gt;nvim&lt;/code&gt; is run. Launching &lt;code&gt;nvim-qt&lt;/code&gt; will load the plugin and both will load the plugin on subsequent launches. Occasionally (but not reliably) using the Dein option will cause the error noted above when the programs are not in the path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;*NOTE: when I say &quot;Open&quot; or &quot;Close&quot; below, I mean all associated windows. There are 3 or 4 windows to go through to change the path and leaving some open or leaving PowerShell open seems to change the behavior.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;To reproduce:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Remove programs from path&lt;/li&gt;&#xA;&lt;li&gt;Close all path related windows&lt;/li&gt;&#xA;&lt;li&gt;Open PowerShell&lt;/li&gt;&#xA;&lt;li&gt;Test &lt;code&gt;ctags&lt;/code&gt; and &lt;code&gt;global&lt;/code&gt; to make sure they are &lt;em&gt;not&lt;/em&gt; executable&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run &lt;code&gt;nvim&lt;/code&gt; from PowerShell&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Using: &lt;code&gt;if executable('ctags') || executable('global')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;No error&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Using dein options: &lt;code&gt;{ 'if': 'executable(&quot;ctags&quot;) || executable(&quot;global&quot;)' })&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Sometimes causes an error that requires &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt; to get back to prompt&lt;/li&gt;&#xA;&lt;li&gt;Sometimes no error&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If no error, test that &lt;code&gt;:GenCtags&lt;/code&gt; and &lt;code&gt;:GenGTAGS&lt;/code&gt; are &lt;em&gt;not&lt;/em&gt; available&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Close &lt;code&gt;nvim&lt;/code&gt; and &lt;code&gt;PowerShell&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Add programs back to path&lt;/li&gt;&#xA;&lt;li&gt;Open PowerShell&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Test &lt;code&gt;ctags&lt;/code&gt; and &lt;code&gt;global&lt;/code&gt; to make sure they &lt;em&gt;are&lt;/em&gt; executable&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Using: &lt;code&gt;if executable('ctags') || executable('global')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:GenCtags&lt;/code&gt; and &lt;code&gt;:GenGTAGS&lt;/code&gt; are &lt;em&gt;not&lt;/em&gt; available&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Using dein options: &lt;code&gt;{ 'if': 'executable(&quot;ctags&quot;) || executable(&quot;global&quot;)' })&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:GenCtags&lt;/code&gt; and &lt;code&gt;:GenGTAGS&lt;/code&gt; are &lt;em&gt;not&lt;/em&gt; available&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Close &lt;code&gt;nvim&lt;/code&gt; and PowerShell&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;These can be closed and reopened many times with the same result&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Open &lt;code&gt;nvim-qt&lt;/code&gt; using Cortana&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Test that &lt;code&gt;:GenCtags&lt;/code&gt; and &lt;code&gt;:GenGTAGS&lt;/code&gt; &lt;em&gt;are&lt;/em&gt; available&lt;/li&gt;&#xA;&lt;li&gt;Plugin will be loaded from now on in both &lt;code&gt;nvim&lt;/code&gt; and &lt;code&gt;nvim-qt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1154" LastEditorUserId="1154" LastEditDate="2018-07-31T20:41:12.833" LastActivityDate="2018-07-31T20:41:12.833" Title="Dein options to only load plugin if dependent program found" Tags="|vimrc|plugin-system|plugin-managers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16901" PostTypeId="2" ParentId="16900" CreationDate="2018-07-27T14:18:51.240" Score="2" Body="&lt;p&gt;You can do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if executable('ctags') || executable('global')&#xA;    call dein#add('...')&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-07-27T14:18:51.240" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="16902" PostTypeId="2" ParentId="16898" CreationDate="2018-07-27T18:09:02.013" Score="0" Body="&lt;p&gt;TL;DR: Use &lt;code&gt;source&lt;/code&gt; in the main global config file to source another global config file - tie to an &lt;code&gt;if&lt;/code&gt; statement for robustness.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Thanks to @Lucas's suggestion, I looked into &lt;code&gt;:help system-vimrc&lt;/code&gt; and the surrounding sections. I found that &lt;code&gt;$VIM/vimrc&lt;/code&gt; was a symbolic link pointing to &lt;code&gt;/etc/vim/vimrc&lt;/code&gt;. This is the base file sourced in my case for vim configuration across the entire system. I thought that since the help file specifies vim uses &lt;code&gt;The first that exists is used, the others are ignored&lt;/code&gt; that I was out of luck, until I looked at the end of this configuration file and found the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Source a global configuration file if available&#xA;if filereadable(&quot;/etc/vim/vimrc.local&quot;)&#xA;  source /etc/vim/vimrc.local&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I created the file &lt;code&gt;/etc/vim/vimrc.local&lt;/code&gt; and added my global config parameters there. User &lt;code&gt;.vimrc&lt;/code&gt; files are still sourced (confirmed by listing different configs in root and user files, comparing operation in sudo and standard vim instances) as appropriate, so users can still have their own configs.&lt;/p&gt;&#xA;" OwnerUserId="16795" LastActivityDate="2018-07-27T18:09:02.013" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16903" PostTypeId="1" AcceptedAnswerId="16918" CreationDate="2018-07-28T04:57:57.287" Score="1" ViewCount="877" Body="&lt;p&gt;Lets say I have the following cmake file (with | being the cursor).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmake_minimum_required(3.2)&#xA;project(myapp)&#xA;add_exe|cutable(myapp main.cpp)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I go to terminal and consult cmake documentation with &lt;code&gt;cmake --help add_executable&lt;/code&gt; I get a really nice help message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to bring that help message to vim preview window (or something similar) much like how &lt;code&gt;:help keyword&lt;/code&gt; works in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that possible?&lt;/p&gt;&#xA;" OwnerUserId="18372" LastActivityDate="2018-07-29T14:33:30.563" Title="Show external command output in preview window" Tags="|key-bindings|vimscript|previewing|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16904" PostTypeId="1" CreationDate="2018-07-28T05:48:47.197" Score="0" ViewCount="385" Body="&lt;p&gt;I'm working with a terminal emulator, and want to send the right key presses/escape sequences to vim, so it inteprets them as the left/right scroll wheel buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;64/65 works for up/down:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;ScrollWheelUp&amp;gt;   printf(&quot;\033[&amp;lt;%d;%d;%d&quot;, 64, row, col)&#xA;&amp;lt;ScrollWheelDown&amp;gt; printf(&quot;\033[&amp;lt;%d;%d;%d&quot;, 65, row, col)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what does vim expect for left/right scroll wheel buttons? I've tried 66/67 and 62...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a different style of sequence altogether? I might need to delve into the vim source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess I could just make up a code, and then map it within vim... but I'd like to follow the standard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make vim tell you what a symbol like &lt;code&gt;&amp;lt;ScrollWheelLeft&amp;gt;&lt;/code&gt; represents?&lt;/p&gt;&#xA;" OwnerUserId="3189" LastEditorUserId="3189" LastEditDate="2018-07-29T04:11:55.573" LastActivityDate="2018-07-31T09:32:14.057" Title="What key presses/escape codes does vim expect for &lt;ScrollWheelLeft&gt; and &lt;ScrollWheelRight&gt;?" Tags="|scrolling|key-bindings|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16905" PostTypeId="2" ParentId="15431" CreationDate="2018-07-28T09:20:48.743" Score="4" Body="&lt;p&gt;I am myself pretty new to vim in general, but I guess you can easily do this. Here is my version of it, which will create a horizontal split, create a terminal buffer and then run the current python file in it and then you can create a another mapping which can close the terminal buffer for you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-R&amp;gt; :sp &amp;lt;CR&amp;gt; :term python % &amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-W&amp;gt; :bd!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18373" LastEditorUserId="28" LastEditDate="2018-07-29T23:45:45.350" LastActivityDate="2018-07-29T23:45:45.350" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16906" PostTypeId="1" AcceptedAnswerId="19950" CreationDate="2018-07-28T11:48:25.630" Score="158" ViewCount="108981" Body="&lt;p&gt;Given a file with a large JSON object all on one line like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{&amp;quot;versions&amp;quot;:[{&amp;quot;count&amp;quot;:2,&amp;quot;version&amp;quot;:&amp;quot;&amp;quot;},{&amp;quot;count&amp;quot;:1,&amp;quot;version&amp;quot;:&amp;quot;1.1.1&amp;quot;},{&amp;quot;count&amp;quot;:14,&amp;quot;version&amp;quot;:&amp;quot;2.9&amp;quot;},{...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How can I format this to be human readable in Vim?&lt;/p&gt;&#xA;" OwnerUserId="11715" LastEditorUserId="34453" LastEditDate="2023-02-17T18:00:00.570" LastActivityDate="2023-02-17T18:00:00.570" Title="How to format JSON file in Vim" Tags="|formatting|filetype-json|" AnswerCount="10" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16907" PostTypeId="1" AcceptedAnswerId="17625" CreationDate="2018-07-28T11:48:27.013" Score="5" ViewCount="478" Body="&lt;p&gt;Let say I want to run a command that uses a matched group of a pattern for each line matching the pattern.&lt;br&gt;&#xA;The natural choice is &lt;code&gt;:g&lt;/code&gt;. &#xA;With the command &lt;code&gt;:s&lt;/code&gt;, there is no problem. If i would do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/aaa\(.*\)/s//X\1X&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for example, then it would work. &#xA;But if I would try &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/aaa\(.*\)/echo \1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It won't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder why, and what are the alternatives. I mainly want to run python code, something like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/aaa\(.*\)/python3 print(&quot;\1&quot;*3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18062" LastEditDate="2018-07-29T14:12:50.143" LastActivityDate="2018-10-13T10:51:03.817" Title="How to run a python command based on a matched group of a pattern?" Tags="|regular-expression|replace|vimscript-python|global-command|" AnswerCount="4" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16908" PostTypeId="2" ParentId="16906" CreationDate="2018-07-28T11:49:27.870" Score="96" Body="&lt;p&gt;This one-liner works well to format JSON in Vim into a human readable form:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%!python -m json.tool&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11715" LastActivityDate="2018-07-28T11:49:27.870" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="16909" PostTypeId="1" CreationDate="2018-07-28T14:18:24.007" Score="0" ViewCount="55" Body="&lt;p&gt;&lt;strong&gt;Task:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;on key press, lets say &lt;code&gt;&amp;lt;C-G&amp;gt;&lt;/code&gt; print a basic skeleton, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 99 control '&amp;lt;++&amp;gt;' do&#xA;100   impact '&amp;lt;++&amp;gt;'&#xA;101   title '&amp;lt;++&amp;gt;'&#xA;102   desc '&amp;lt;++&amp;gt;'&#xA;103   describe &amp;lt;++&amp;gt;(&amp;lt;++&amp;gt;) do&#xA;104 &#xA;105    end&#xA;106  end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a tone of info for how to do that on a file creation but I'm not interested in that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Attempt:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I've done:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  4 set nocompatible&#xA;  5 filetype plugin on&#xA;  6 syntax on&#xA; 10 inoremap &amp;lt;C-G&amp;gt; control '&amp;lt;++&amp;gt;' do&amp;lt;Esc&amp;gt;&quot;_o&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;impact '&amp;lt;++&amp;gt;'&amp;lt;Esc&amp;gt;&quot;_o&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;title&amp;lt;Space&amp;gt;'&amp;lt;++&amp;gt;'&amp;lt;Esc&amp;gt;&quot;_o&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;desc&amp;lt;Space&amp;gt;'&amp;lt;++&amp;gt;'&amp;lt;Esc&amp;gt;&quot;&#xA;    _o&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;describe&amp;lt;Space&amp;gt;&amp;lt;++&amp;gt;(&amp;lt;++&amp;gt;)&amp;lt;Space&amp;gt;do&amp;lt;Esc&amp;gt;&quot;_o&amp;lt;Esc&amp;gt;&quot;_o &amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;end&amp;lt;Esc&amp;gt;&quot;_o end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works but it's ugly. Is there a way to do it better?&lt;/p&gt;&#xA;" OwnerUserId="18376" LastActivityDate="2018-11-25T16:02:10.530" Title="importing skeleton on keybind" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16910" PostTypeId="2" ParentId="16909" CreationDate="2018-07-28T14:54:11.413" Score="1" Body="&lt;p&gt;As this probably won't be the only part of code you'll repeat, and you'll probably want to replace the &lt;code&gt;&amp;lt;++&amp;gt;&lt;/code&gt; with some other text, a snippet plugin will be most useful to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plug in &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt;, open the file you want to add the skeleton to, and use &lt;code&gt;:UltiSnipsEdit&lt;/code&gt;. This will open you a buffer where you can add all sorts of snippets. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet s &quot;My skeleton&quot;&#xA; control '&amp;lt;++&amp;gt;' do&#xA;   impact '&amp;lt;++&amp;gt;'&#xA;   title '&amp;lt;++&amp;gt;'&#xA;   desc '&amp;lt;++&amp;gt;'&#xA;   describe &amp;lt;++&amp;gt;(&amp;lt;++&amp;gt;) do&#xA;&#xA;    end&#xA;  end&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;code&gt;s&lt;/code&gt; is the activator for the following snippet, the string in quotes is a description (shown e.g. by YCM). The activator can be a word, if it will be easier to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Save that buffer from above and enter the activator string in your file. Hit enter and you'll get your snippet in your buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read more here - &lt;code&gt;:help UltiSnips-plaintext-snippets&lt;/code&gt; about how to setup more sophisticated snippets to fit all of your needs, including a visual placeholder e.g. to quickly switch between the &lt;code&gt;&amp;lt;++&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3280" LastActivityDate="2018-07-28T14:54:11.413" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16913" PostTypeId="2" ParentId="621" CreationDate="2018-07-28T17:04:54.170" Score="4" Body="&lt;p&gt;I know this is old but I came across it and thought a different option might be useful for other people searching for this question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would yank to the system register and then open the new file and paste from the system register. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First find out what symbol represents your system clipboard. In Linux you have two options &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;*&lt;/code&gt;. I use &lt;code&gt;+&lt;/code&gt; but more info can be found here: &lt;a href=&quot;https://superuser.com/questions/624231/in-vim-what-is-the-difference-between-and-registers&quot;&gt;https://superuser.com/questions/624231/in-vim-what-is-the-difference-between-and-registers&lt;/a&gt;. For Windows Mac &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; are the same thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then instead of yanking with &lt;code&gt;y&lt;/code&gt; yank with &lt;code&gt;&quot;+y&lt;/code&gt; and instead of paste &lt;code&gt;p&lt;/code&gt; use &lt;code&gt;&quot;+p&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="18379" LastActivityDate="2018-07-28T17:04:54.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16914" PostTypeId="1" AcceptedAnswerId="16915" CreationDate="2018-07-29T07:15:14.347" Score="3" ViewCount="1851" Body="&lt;p&gt;Previously (as far as I remember), &lt;code&gt;e!&lt;/code&gt; used to drop undo history. Now, I'm using vim 8.0, and &lt;code&gt;e!&lt;/code&gt; doesn't drop it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to drop undo history in vim 8.0?&lt;/p&gt;&#xA;" OwnerUserId="18384" LastActivityDate="2022-01-27T17:49:29.447" Title="How to drop undo history?" Tags="|undo-redo|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="16915" PostTypeId="2" ParentId="16914" CreationDate="2018-07-29T09:06:12.660" Score="8" Body="&lt;p&gt;I don't recall anything like that with &lt;code&gt;e!&lt;/code&gt;. At least not since 'persistent undo' was added back in 2010 as part of v7.3(b?). (I confirmed that the command sequence discussed below was in the documentation from that point forward.) I think when the feature was first added a lot of people wouldn't have had it enabled (i.e. &lt;code&gt;:set undofile&lt;/code&gt;). In that case &lt;code&gt;e!&lt;/code&gt; would certainly wipe undo entries recorded since the last save. Perhaps this is what you are recalling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI, the way it works (with persistent undo enabled) is that a new &quot;undo block&quot; is added that reverses changes made since the last save. If you hit undo after &lt;code&gt;e!&lt;/code&gt; the state will be back to where it was immediately before &lt;code&gt;e!&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, you can clear undo history, including the persistent copy kept in a buffer's undo file, with the command sequence provided by &lt;code&gt;:h clear-undo&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let old_undolevels = &amp;amp;undolevels&#xA;:set undolevels=-1&#xA;:exe &quot;normal a \&amp;lt;BS&amp;gt;\&amp;lt;Esc&amp;gt;&quot;&#xA;:let &amp;amp;undolevels = old_undolevels&#xA;:unlet old_undolevels&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets &lt;code&gt;'undolevels'&lt;/code&gt; to -1, indicating there should be 0 undo levels, and does a non-visible &quot;dummy&quot; operation on the buffer to force immediate overwriting of the history. (The next time the history is written to disk the undo file will be cleared, too.) Then the previous &lt;code&gt;'undolevels'&lt;/code&gt; setting is restored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously if you intend to use this on a recurring basis you'll want to put it in a function/mapping or some such.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Side note: Vim doesn't provide a way to &lt;em&gt;delete&lt;/em&gt; undo files. You'd have to do that manually. The file name for current buffer can be seen with &lt;code&gt;:echo undofile('.')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; You might want to look at the &lt;a href=&quot;https://github.com/mbbill/undotree&quot; rel=&quot;noreferrer&quot;&gt;undotree plugin&lt;/a&gt;. Besides allowing easy navigation of the undo tree it has a &lt;em&gt;clear history&lt;/em&gt; function (which I just noticed despite having used the plugin for a long time).&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-07-31T01:48:37.880" LastActivityDate="2018-07-31T01:48:37.880" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16916" PostTypeId="1" AcceptedAnswerId="16917" CreationDate="2018-07-29T13:21:28.213" Score="0" ViewCount="55" Body="&lt;p&gt;I've been reading through &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; and trying some exercises. When I got into the autocommands/autogroups part, I've thought of creating an autocommand to automatically trim trailing white spaces from my C files. So I created the appropriate section on my &lt;code&gt;.vimrc&lt;/code&gt; file and tested with a simple &lt;code&gt;test.c&lt;/code&gt; program. The behavior is that when I write the file, the trailing spaces get deleted correctly. But if I write and quit Vim with &lt;code&gt;ZZ&lt;/code&gt; or &lt;code&gt;:wq&lt;/code&gt;, and then open the file again with &lt;code&gt;vim test.c&lt;/code&gt; to check the results, the next key press deletes some characters. With I press &lt;code&gt;j&lt;/code&gt;, it will delete to the next line, if I press &lt;code&gt;k&lt;/code&gt; to the previous one. It's like I've just pressed &lt;code&gt;d&lt;/code&gt; and I'm in operator pending mode for deletion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number relativenumber&#xA;set hlsearch incsearch nowrapscan nowrap&#xA;set showcmd&#xA;set wildmenu wildignorecase complete+=d&#xA;set path+=**&#xA;set sidescroll=1 sidescrolloff=10&#xA;&#xA;nnoremap &amp;lt;Leader&amp;gt;ev :split $MYVIMRC&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;sv :source $MYVIMRC&amp;lt;CR&amp;gt;&#xA;inoremap jk &amp;lt;Esc&amp;gt;&#xA;map &amp;lt;Leader&amp;gt;y &quot;+y&#xA;&#xA;noremap &amp;lt;Esc&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&#xA;augroup Ccfg&#xA;    autocmd!&#xA;    autocmd FileType c setlocal listchars=trail:.,tab:&amp;gt;-,extends:&amp;gt;,precedes:&amp;lt; list&#xA;    autocmd FileType c setlocal tabstop=4 shiftwidth=4 shiftround expandtab&#xA;    autocmd FileType c setlocal textwidth=80 colorcolumn=+1&#xA;    autocmd FileType c setlocal tagcase=match&#xA;    autocmd FileType c setlocal cscopetag&#xA;    autocmd FileType c setlocal breakindent&#xA;    autocmd FileType c iabbrev /*-*/ /*----------------------------------------------------------------------------*/&#xA;    autocmd BufWrite *.c,*.cpp,*.h %s/\v\s+$//e&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;test.c&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;&#xA;int main(void)&#xA;{&#xA;    printf(&quot;Hello world!\n&quot;);    &#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice the trailing spaces after the &lt;code&gt;printf&lt;/code&gt; call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to find a way to record my terminal session, but since I'm on Windows using Git Bash and it's Vim, I can't use &lt;a href=&quot;https://asciinema.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;asciinema&lt;/a&gt; or other solutions.&lt;/p&gt;&#xA;" OwnerUserId="10482" LastEditorUserId="10482" LastEditDate="2018-07-29T13:27:14.317" LastActivityDate="2018-07-29T14:25:20.327" Title="What is making my configuration enter operator pending mode on new session?" Tags="|vimrc|autocmd|" AnswerCount="1" CommentCount="3" ClosedDate="2018-07-30T23:51:53.997" ContentLicense="CC BY-SA 4.0" />
  <row Id="16917" PostTypeId="2" ParentId="16916" CreationDate="2018-07-29T14:25:20.327" Score="1" Body="&lt;p&gt;I've found out by trying different configurations that the culprit is the &lt;code&gt;noremap &amp;lt;Esc&amp;gt; &amp;lt;Nop&amp;gt;&lt;/code&gt; line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to @D. Ben Knoble for finding &lt;a href=&quot;https://stackoverflow.com/questions/15530851/why-does-the-combination-of-remapping-esc-to-nop-cause-strange-characters-to&quot;&gt;Why does the combination of remapping  to  cause strange characters to be automatically inserted when starting vim with startinsert?&lt;/a&gt; that explains that &lt;code&gt;Esc&lt;/code&gt; is part of many special key combinations and remapping it to &lt;code&gt;Nop&lt;/code&gt; interfere with those.&lt;/p&gt;&#xA;" OwnerUserId="10482" LastActivityDate="2018-07-29T14:25:20.327" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16918" PostTypeId="2" ParentId="16903" CreationDate="2018-07-29T14:33:30.563" Score="2" Body="&lt;h1&gt;Getting terminal output into vim&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;We have several options to do this, which I will describe below. Note that some may depend on the version of &lt;code&gt;vim&lt;/code&gt; or &lt;code&gt;nvim&lt;/code&gt; you're using, or on external code.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;code&gt;:read !&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:read&lt;/code&gt; command (&lt;code&gt;:r&lt;/code&gt;) is typically used to read in files to the current buffer. This has let users create many wonderful templating systems, among other uses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in typical Unix style, external command output can we treated like a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;End result: &lt;code&gt;:read !cmake --help &amp;lt;cword&amp;gt;&lt;/code&gt; will put the output in your current buffer. You could create a function to put it in a new window, if you like.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;code&gt;:term&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Built-in terminal support was developed in vim 8 (though I think it only stabilized in 8.1).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;open a terminal and run the command separately, in which case we might want to use &lt;code&gt;:term ++noclose&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;or&lt;/em&gt; tell vim to run exactly the command we want&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'll show the latter: &lt;code&gt;:term cmake --help &amp;lt;cword&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should put the output in a terminal buffer (no longer running), much like a preview window.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Clam&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I started using &lt;a href=&quot;https://github.com/sjl/clam.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;clam&lt;/a&gt; before vim got terminal support. It's a nifty little plugin that basically implements the 'read command output into a new window' piece I described above, with a couple of bonus mappings for manipulating it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install it, and, as the OP mentioned in comments, set up a mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would place the following code in &lt;code&gt;~/.vim/after/ftplugin/cmake.vim&lt;/code&gt;, to take advantage of the filetype mechanism and not clutter my &lt;code&gt;vimrc&lt;/code&gt; with autocommands.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap K :Clam cmake --help &amp;lt;cword&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The original from the comment was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype cmake nnoremap K :Clam cmake --help &amp;lt;cword&amp;gt;&amp;lt;cr&amp;gt;:set filetype=cmake&amp;lt;cr&amp;gt;gg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-07-29T14:33:30.563" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16919" PostTypeId="2" ParentId="5110" CreationDate="2018-07-29T14:42:36.533" Score="14" Body="&lt;h1&gt;Built in compiler plugin &lt;code&gt;pyunit&lt;/code&gt;&lt;/h1&gt;&#xA;&lt;p&gt;As already suggested by &lt;a href=&quot;https://vi.stackexchange.com/a/10147/17998&quot;&gt;jamessan&lt;/a&gt;, one option is to use the built in compiler plugin &lt;code&gt;pyunit&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:compiler pyunit&#xA;:set makeprg=python3\ %&#xA;:make&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This has the downside, that it collapses the stack trace to a single error message. For example the following python script:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def lumberjack():&#xA;    bright_side_of_death()&#xA;&#xA;def bright_side_of_death():&#xA;    return tuple()[0]&#xA;&#xA;lumberjack()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;... produces this error message:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|| Traceback (most recent call last):&#xA;lumberjack.py|7|  IndexError: tuple index out of range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Writing your own compiler plugin&lt;/h1&gt;&#xA;&lt;p&gt;As an alternative, you can provide your own compiler plugin in&#xA;&lt;code&gt;~/.vim/compiler/python.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&amp;quot;current_compiler&amp;quot;)&#xA;  finish&#xA;endif&#xA;let current_compiler = &amp;quot;python&amp;quot;&#xA;&#xA;let s:cpo_save = &amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;&#xA;CompilerSet errorformat=&#xA;      \%*\\sFile\ \&amp;quot;%f\&amp;quot;\\,\ line\ %l\\,\ %m,&#xA;      \%*\\sFile\ \&amp;quot;%f\&amp;quot;\\,\ line\ %l,&#xA;CompilerSet makeprg=python3\ %&#xA;&#xA;let &amp;amp;cpo = s:cpo_save&#xA;unlet s:cpo_save&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Select the plugin manually with &lt;code&gt;:compiler python&lt;/code&gt;, or load it automatically by adding this to &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(&amp;quot;current_compiler&amp;quot;)&#xA;  compiler python&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With the python script from above, Vim populates the quickfix window with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|| Traceback (most recent call last):&#xA;lumberjack.py|7| in &amp;lt;module&amp;gt;&#xA;||     lumberjack()&#xA;lumberjack.py|2| in lumberjack&#xA;||     bright_side_of_death()&#xA;lumberjack.py|5| in bright_side_of_death&#xA;||     return tuple()[0]&#xA;|| IndexError: tuple index out of range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/usr_51.txt.html#write-compiler-plugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help write-compiler-plugin&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="17998" LastEditorUserId="17998" LastEditDate="2022-11-11T08:44:03.907" LastActivityDate="2022-11-11T08:44:03.907" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16920" PostTypeId="2" ParentId="16907" CreationDate="2018-07-29T14:49:59.680" Score="5" Body="&lt;h1&gt;TL;DR&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;There is no simple way to get capture groups into other commands. They simply don't see them.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;About the &lt;code&gt;:s&lt;/code&gt; command&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;As many vim users know, &lt;code&gt;:s&lt;/code&gt; is the &lt;code&gt;:substitute&lt;/code&gt; command, and it deals in vim's flavor of regular expressions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As many &quot;frequent flyers&quot; know, &lt;code&gt;:s&lt;/code&gt; can re-use previous patterns by not providing them. This has lead me to a workflow wherein I will search (&lt;code&gt;/&lt;/code&gt;), perfect my pattern, and then &quot;replace&quot; with &lt;code&gt;:%s//&amp;lt;replace&amp;gt;/g&lt;/code&gt;--I'm re-using the pattern I searched for.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Global substitute&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:g/pattern/s//replacement&lt;/code&gt; is pretty much equivalent to &lt;code&gt;:%s/pattern/replacement/&lt;/code&gt;--by default, &lt;code&gt;:s&lt;/code&gt; only performs substitutions on lines where pattern matches. By using &lt;code&gt;:g&lt;/code&gt; instead, you're performing the narrowing of lines first and then invoking the replace. But either way, it accomplishes the same goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the help docs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The global command sets both the last used search pattern and the last used&#xA;substitute pattern (this is vi compatible).  This makes it easy to globally&#xA;replace a string:&#xA;    :g/pat/s//PAT/g&#xA;This replaces all occurrences of &quot;pat&quot; with &quot;PAT&quot;.  The same can be done with:&#xA;    :%s/pat/PAT/g&#xA;Which is two characters shorter!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Why &lt;code&gt;\1&lt;/code&gt; works here, and not anywhere else&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;As I just mentioned, &lt;code&gt;:s//replacement&lt;/code&gt; will re-use the last search pattern. See &lt;code&gt;:help last-pattern&lt;/code&gt; for more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately, the &lt;code&gt;:g&lt;/code&gt; command also sets this &quot;last pattern&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, we can translate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/aaa\(.*\)/s//X\1X &amp;lt;=&amp;gt; :g/aaa\(.*\)/s/aaa\(.*\)/X\1X&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The capture group exists &lt;em&gt;during&lt;/em&gt; the substitute. But,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/aaa\(.*\)/echo \1 &amp;lt;=&amp;gt; :g/aaa\(.*\)/echo \1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's no capturing done in the second part of the global command. Vim just runs the literal &lt;code&gt;:echo \1&lt;/code&gt; on every line matching the pattern.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-07-29T14:49:59.680" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16921" PostTypeId="1" AcceptedAnswerId="17288" CreationDate="2018-07-29T19:49:01.370" Score="0" ViewCount="275" Body="&lt;p&gt;I used &lt;a href=&quot;https://exvim.github.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;exvim&lt;/a&gt; as session manager, it uses a project file with extension &lt;strong&gt;.exvim&lt;/strong&gt;. The session is auto-loaded when double click the &lt;strong&gt;.exvim&lt;/strong&gt;, and auto-saved on exit. But there're bugs and the dev is inactive for years, now I switch to use &lt;a href=&quot;https://github.com/xolox/vim-session&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-session&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like the '.exvim' idea, I'm trying to implement '.proj' with vim-session in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:session_autosave = 'yes' &quot;auto saved&#xA;let g:session_autoload = 'no' &quot;load by myself as below&#xA;function! s:open_proj_session()&#xA;    &quot; if the buffer is /a/b/mars.proj, just get the 'mars'&#xA;    let session_name = fnamemodify(fnamemodify(bufname('%'), &quot;:t&quot;), ':r')&#xA;    &quot; try to open it first&#xA;    call xolox#session#open_cmd(session_name, '', 'OpenSession') &#xA;&#xA;    &quot; if it's not opened then it's not created, let's create it&#xA;    let cur_sess = xolox#session#find_current_session()&#xA;    if cur_sess != session_name&#xA;        call xolox#session#save_cmd(session_name, '', 'SaveSession')&#xA;    endif&#xA;endfunction&#xA;augroup MyProj&#xA;    autocmd!&#xA;    autocmd! BufRead,BufNewFile *.proj set filetype=proj &quot;register .proj filetype&#xA;    autocmd FileType proj nested call s:open_proj_session()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once I open a &lt;strong&gt;.proj&lt;/strong&gt; file, session loaded successfully, but buffers has no &lt;code&gt;filetype&lt;/code&gt;, try to print filetype in some &lt;strong&gt;.cpp&lt;/strong&gt; buffer with &lt;code&gt;:set filetype&lt;/code&gt;, results in: &lt;code&gt;filetype=conf&lt;/code&gt; or &lt;code&gt;filetype=&lt;/code&gt;.  And the syntax highlight is not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see the official dev is also inactive for years so I decide to post it here, how to fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code updated, add a &lt;code&gt;nested&lt;/code&gt; keyword works. Now only the active buffer not syntax highlighted. Its ``filetype=cpp` is already set, but has no syntax(&lt;em&gt;'No Syntax items defined for this buffer'&lt;/em&gt;), all other buffer are syntax highlighted, why?&lt;/p&gt;&#xA;" OwnerUserId="6971" LastEditorUserId="6971" LastEditDate="2018-08-01T14:10:48.467" LastActivityDate="2018-09-05T00:07:21.230" Title="how to set filetype after session restored with vim-session plugin" Tags="|gvim|filetype|sessions|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16924" PostTypeId="1" AcceptedAnswerId="16943" CreationDate="2018-07-30T02:16:06.907" Score="1" ViewCount="575" Body="&lt;p&gt;System: gvim 8.1 1-116 / windows10&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A file that I'd like to use modeline (enabled): &lt;code&gt;# vim: ft=python&lt;/code&gt; but disable &lt;code&gt;ale&lt;/code&gt; plugin that will trigger &lt;code&gt;on save&lt;/code&gt; - the file contains some python codes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Command that I'd like to run by vim before parse the file: &lt;code&gt;:ALEDisable&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here I just want to disbale ALE on a specific file that comes with clear declaration in modeline.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="1292" LastEditDate="2018-10-09T14:25:27.683" LastActivityDate="2018-10-09T14:25:27.683" Title="Run command to disable a plugin in modeline" Tags="|vimrc|gvim|microsoft-windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16925" PostTypeId="2" ParentId="16924" CreationDate="2018-07-30T02:25:24.070" Score="0" Body="&lt;p&gt;Silly me, I just want to have highlight of &lt;code&gt;python&lt;/code&gt; while keep &lt;code&gt;ft=conf&lt;/code&gt; because this is a note that contains python code, I'd like to have &lt;code&gt;python&lt;/code&gt; code highlighted properly, so just set modeline: &lt;code&gt;# vim: syntax=python&lt;/code&gt; I can achieve the purpose.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2018-07-30T02:25:24.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16927" PostTypeId="1" AcceptedAnswerId="16928" CreationDate="2018-07-30T08:41:37.840" Score="0" ViewCount="820" Body="&lt;p&gt;I have :SyntasticCheck mapped to F8 in my .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F8&amp;gt; :SyntasticCheck&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This open the Syntastic window on a split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to close it with the same mapping.&#xA;Closing is done with &lt;code&gt;:SyntasticReset&lt;/code&gt;, but it only works if the Synastic window is open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I create a mapping that only open Synastic windows if it's not visible and close it if it exists ?&lt;/p&gt;&#xA;" OwnerUserId="496" LastActivityDate="2018-07-30T11:32:49.453" Title="Open and Close Syntastic window with one mapping" Tags="|vimrc|vimscript|plugin-syntastic|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16928" PostTypeId="2" ParentId="16927" CreationDate="2018-07-30T11:32:49.453" Score="1" Body="&lt;p&gt;You could use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleSyntastic()&#xA;    for i in range(1, winnr('$'))&#xA;        let bnum = winbufnr(i)&#xA;        if getbufvar(bnum, '&amp;amp;buftype') == 'quickfix'&#xA;            lclose&#xA;            return&#xA;        endif&#xA;    endfor&#xA;    SyntasticCheck&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;F8&amp;gt; :call ToggleSyntastic()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As Syntastic populates the location list, the function iterates through the different open windows. If it finds the quickfix window which contains the location list, then it closes it. If no quickfix window was found, then it runs &lt;code&gt;SyntasticCheck&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can simply call &lt;kbd&gt;F8&lt;/kbd&gt; to call the function.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-07-30T11:32:49.453" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16929" PostTypeId="2" ParentId="2764" CreationDate="2018-07-30T11:40:46.080" Score="2" Body="&lt;p&gt;In addition to the answers here I have implemented a plugin for this purpose: &lt;a href=&quot;https://github.com/KKPMW/vim-sendtowindow&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sendtowindow&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It provides a &lt;strong&gt;send-to-window&lt;/strong&gt; operator that can be combined with any vim motion in order to select text for sending to the adjacent window. In addition it conveniently positions the cursor after the sent text and is dot repeatable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A small example below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jOzxG.gif&quot; alt=&quot;example&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="307" LastEditorUserId="307" LastEditDate="2019-02-24T18:44:21.810" LastActivityDate="2019-02-24T18:44:21.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16930" PostTypeId="1" AcceptedAnswerId="16931" CreationDate="2018-07-30T14:17:29.327" Score="3" ViewCount="2390" Body="&lt;p&gt;I am using vim and simply want to disable auto indent when I paste text into my terminal vim session. I have tried numerous solutions including various incantations of below to &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set nopaste&#xA;&#xA;&amp;quot;  https://kb.iu.edu/d/afcw&#xA;&amp;quot;  set noautoindent&#xA;&#xA;&#xA;&amp;quot;   https://vi.stackexchange.com/questions/5310/how-can-i-stop-vim-automatically-inserting-a-tab-in-css-files&#xA;&amp;quot;  set indentexpr=&amp;quot;&amp;quot;&#xA;&#xA;&#xA;filetype indent off&#xA;&#xA;&#xA;&amp;quot;  set pastetoggle=&#xA;set pastetoggle=&#xA;&#xA;&amp;quot; set paste&#xA;&#xA;&#xA;&amp;quot; se paste&#xA;&#xA;&#xA;&amp;quot; au FileType html,htmldjango setlocal indentexpr=&#xA;&#xA;&#xA;&amp;quot; set nosmartindent&#xA;&amp;quot; set cindent&#xA;&amp;quot; filetype plugin indent on&#xA;&amp;quot; set cinkeys-=0#&#xA;&amp;quot; set indentkeys-=0#&#xA;&amp;quot; autocmd FileType * set cindent &amp;quot;some file types override it&#xA;&#xA;&#xA;&amp;quot;  https://unix.stackexchange.com/questions/106526/stop-vim-from-messing-up-my-indentation-on-comments&#xA;set nosmartindent&#xA;set cindent&#xA;set cinkeys-=0#&#xA;set indentkeys-=0#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As you can see bad advice is easily obtained. I am on Ubuntu 18.04 and have not customized anything so its stock vim. I see the vim package has given me&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/bundle/Vundle.vim/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which I have not modified&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)&#xA;Included patches: 1-1689&#xA;Extra patches: 8.0.0056&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here is an example of badness when I paste properly formatted code into vim  &lt;code&gt;vim blah.go&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import (&#xA;            &amp;quot;bufio&amp;quot;&#xA;                &amp;quot;fmt&amp;quot;&#xA;                    &amp;quot;os&amp;quot;&#xA;                        &amp;quot;bytes&amp;quot;&#xA;                            &amp;quot;io&amp;quot;&#xA;                    )&#xA;&#xA;                    func read_stdin(io_reader io.Reader) (string, error) {&#xA;&#xA;                                var buffer bytes.Buffer&#xA;&#xA;                                    scanner := bufio.NewScanner( io_reader )&#xA;&#xA;                                        for scanner.Scan() {&#xA;                                                        buffer.WriteString( scanner.Text() + &amp;quot;\n&amp;quot; )&#xA;                                                            }&#xA;                                                                if err := scanner.Err(); err != nil {&#xA;&#xA;                                                                                return &amp;quot;&amp;quot;, err&#xA;                                                                                    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This auto indent issue pervades many filename suffixes so I am not looking for any suffix specific or source code editing language specific addons.&lt;/p&gt;&#xA;&lt;p&gt;PS this was never an issue until about a year ago&lt;/p&gt;&#xA;" OwnerUserId="15795" LastEditorUserId="15795" LastEditDate="2020-10-12T18:38:43.213" LastActivityDate="2020-10-12T18:40:42.407" Title="How to disable bad indentation when pasting text?" Tags="|indentation|cut-copy-paste|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16931" PostTypeId="2" ParentId="16930" CreationDate="2018-07-30T14:35:50.027" Score="5" Body="&lt;p&gt;You are looking for &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27paste%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'paste'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27pastetoggle%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'pastetoggle'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not really a good idea to set &lt;code&gt;paste&lt;/code&gt; in your vimrc since most of the time you don't want to have it set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to use &lt;code&gt;set paste&lt;/code&gt; just before you copy your text and go back to &lt;code&gt;nopaste&lt;/code&gt; right after.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way to do that is to put something like this in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set pastetoggle=&amp;lt;F11&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can simply press &lt;code&gt;&amp;lt;F11&amp;gt;&lt;/code&gt; before and after you paste and you should be good.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-07-30T14:35:50.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16932" PostTypeId="2" ParentId="16904" CreationDate="2018-07-30T14:53:06.693" Score="1" Body="&lt;p&gt;As the commenters have already pointed out, the escape sequences used can vary depending on your configuration, but these key codes can be set and queried by the &lt;code&gt;:set&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following command will output what Vim is currently expecting your terminal to send for &lt;code&gt;&amp;lt;ScrollWheelLeft&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set &amp;lt;ScrollWheelLeft&amp;gt;?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help terminal-options&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-07-30T14:53:06.693" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16934" PostTypeId="2" ParentId="16907" CreationDate="2018-07-30T16:15:27.073" Score="2" Body="&lt;p&gt;It ain't pretty, but it &lt;em&gt;is&lt;/em&gt; possible. The following achieves your pseudo code of &lt;code&gt;:g/aaa\(.*\)/python3 print(&quot;\1&quot;*3)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/aaa\(.*\)/\=submatch(0) . execute('python print(&quot;'.submatch(1).'&quot;*3)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. Note that, for some reason, when run in this command, while the &lt;code&gt;python print&lt;/code&gt; commands are run, their output doesn't seem to make it onto the screen. If you &lt;em&gt;need&lt;/em&gt; the output to be displayed, then you can extract the &lt;code&gt;print&lt;/code&gt; into a function, which might be nicer for complicated Python code, anyway:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RunPython(match)&#xA;  python print vim.eval(&quot;a:match&quot;)*3&#xA;  return &quot;&quot;&#xA;endfunction&#xA;&#xA;:%s/aaa\(.*\)/\=submatch(0) . RunPython(submatch(1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Note that in the function, I'm using Python 2, because that's what I have installed.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How it Works&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;We can actually run arbitrary Vimscript from within a &lt;code&gt;:substitute&lt;/code&gt; command, as explained by &lt;code&gt;:help sub-replace-special&lt;/code&gt;. If you start your replacement string with &lt;code&gt;\=&lt;/code&gt;, then it is evaluated as an expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such, all (sic) you need to do is construct an expression that executes some Python code but then evaluates to the value of the entire match (because we don't actually want to perform a replacement). The code above does this by the &quot;elegant&quot; means of concatenating &lt;code&gt;submatch(0)&lt;/code&gt; (the whole match) with an execute command that actually runs the Python code but doesn't return any value.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-07-31T16:12:32.740" LastActivityDate="2018-07-31T16:12:32.740" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16936" PostTypeId="1" CreationDate="2018-07-30T22:44:02.947" Score="2" ViewCount="1290" Body="&lt;p&gt;I'm trying to find a good configuration for ctags with C#. I know I can use OmniSharp, but I'd like to have tags for other plugins and when OmniSharp is broken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I started with something based on &lt;a href=&quot;http://web.archive.org/web/20141116094657/http://www.mad-computer-scientist.com:80/blog/2011/10/06/in-search-of-c-omnicomplete-for-vim/comment-page-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;this old blog post&lt;/a&gt;. It didn't include structs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also want namespace kind for &lt;a href=&quot;https://github.com/idbrii/vim-inclement&quot; rel=&quot;nofollow noreferrer&quot;&gt;inclement&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added almost all kinds and have been using this for a while:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# all C# kinds except:&#xA;# e  enumerators (enumeration values) -- just jump to enum instead&#xA;# f  fields -- adds 70% more bytes&#xA;# l  local variables -- adds 90% more bytes&#xA;ctags --c#-kinds=cismpdngtE --fields=+ianmzS --extra=+fq -L $tagfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Size values are based on a ~10 MB tag file and I find larger tag files result in slower jumps.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm unsatisfied. &lt;a href=&quot;https://github.com/search?l=Vim+script&amp;amp;p=1&amp;amp;q=ctags+%22--c%23-kinds%22&amp;amp;type=Code&quot; rel=&quot;nofollow noreferrer&quot;&gt;Searching github&lt;/a&gt; is unhelpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now, I'm trying adding minimal fields info and removing extra info (not entirely sure how extra is used if I don't have vimscript processing it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctags --c#-kinds=cismpdngtEf --fields=kst -L $tagfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you have a better ctag solution for C#?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Please no lsp/OmniSharp-based solutions.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="2045" LastEditorUserId="51" LastEditDate="2018-08-20T16:11:10.243" LastActivityDate="2018-08-20T16:11:10.243" Title="C# ctags configuration for use with vim?" Tags="|ctags|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16937" PostTypeId="1" CreationDate="2018-07-30T23:13:14.860" Score="1" ViewCount="88" Body="&lt;p&gt;So I installed &lt;code&gt;vim-go&lt;/code&gt; and &lt;code&gt;gocode&lt;/code&gt; and &lt;code&gt;Blackrush/vim-gocode.git&lt;/code&gt; (the latter because I use pathogen).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far so good! I am fine, I can type &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; in &lt;code&gt;insert&lt;/code&gt; mode and I get completion suggestions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to not only be fine, but really happy. For this, I'd like to see that autocompletion works after pressing just &lt;code&gt;.&lt;/code&gt; (dot) for example, maybe after a short delay. Or, if that's asking too much, I would like to reduce the &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; keybinding to just one, not two, combinations while still being in &lt;code&gt;insert&lt;/code&gt; mode. For example &lt;code&gt;&amp;lt;C-Up&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this be done? I am also interested in suggestions for other approaches.&lt;/p&gt;&#xA;" OwnerUserId="17891" LastActivityDate="2018-07-31T14:19:03.637" Title="remap keybinding for vim gocode autocomplete feature? (remap keybinding in insert mode)" Tags="|key-bindings|autocompletion|insert-mode|filetype-go|" AnswerCount="0" CommentCount="3" ClosedDate="2018-08-02T00:44:36.117" ContentLicense="CC BY-SA 4.0" />
  <row Id="16938" PostTypeId="2" ParentId="34" CreationDate="2018-07-31T00:48:36.177" Score="11" Body="&lt;p&gt;Two points that are not yet addressed by other answers and might be interesting for a user, even or especially new users without a (or with a small) config file:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;NeoVim &lt;a href=&quot;https://neovim.io/doc/user/vim_diff.html#&amp;#39;cp&amp;#39;&quot; rel=&quot;noreferrer&quot;&gt;does &lt;em&gt;not&lt;/em&gt; try to be Vi compatible&lt;/a&gt; by default. They changed many &lt;a href=&quot;https://neovim.io/doc/user/vim_diff.html#nvim-defaults&quot; rel=&quot;noreferrer&quot;&gt;default values&lt;/a&gt; for the settings and are actively discussing such changes: &lt;a href=&quot;https://github.com/neovim/neovim/issues/2676&quot; rel=&quot;noreferrer&quot;&gt;#2676&lt;/a&gt;, &lt;a href=&quot;https://github.com/neovim/neovim/issues/6289&quot; rel=&quot;noreferrer&quot;&gt;#6289&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;It can be &lt;a href=&quot;https://neovim.io/doc/user/starting.html#--embed&quot; rel=&quot;noreferrer&quot;&gt;embedded&lt;/a&gt; in another process (remember &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/netbeans.html&quot; rel=&quot;noreferrer&quot;&gt;netbeans integration&lt;/a&gt;?) and has &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Related-projects#gui&quot; rel=&quot;noreferrer&quot;&gt;many different GUIs&lt;/a&gt; so MacVim is no longer the fanciest GUI you can find for your &lt;code&gt;$EDITOR&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-31T00:48:36.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16940" PostTypeId="2" ParentId="16904" CreationDate="2018-07-31T06:15:31.537" Score="1" Body="&lt;p&gt;The only place in vim source code where the internal &lt;code&gt;int&lt;/code&gt; constants for left and right mouse scroll wheel events (&lt;code&gt;KE_MOUSELEFT&lt;/code&gt; and &lt;code&gt;KE_MOUSERIGHT&lt;/code&gt;) are set is for the GUI (&lt;a href=&quot;https://github.com/vim/vim/blob/master/src/gui.c&quot; rel=&quot;nofollow noreferrer&quot;&gt;gui.c&lt;/a&gt;).&#xA;Specifically: the code for xterm never produces these events.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: Out of interest, the xterm code does produce mouse scroll wheel up/down events (&lt;code&gt;KE_MOUSEUP&lt;/code&gt;, &lt;code&gt;KE_MOUSEDOWN&lt;/code&gt;). It is a little difficult to follow in the source, because of all the preprocessor conditionals, but for &lt;code&gt;SGR&lt;/code&gt; DECSET 1006, I already know the code for up/down is 64/65 (hex &lt;code&gt;40&lt;/code&gt;/&lt;code&gt;41&lt;/code&gt; - does not appear in vim source). Vim adds 32 (hex &lt;code&gt;20&lt;/code&gt;), then later tests for =&gt; hex &lt;code&gt;60&lt;/code&gt;, to interpret &lt;code&gt;wheel_code&lt;/code&gt; as a &lt;code&gt;wheel_code&lt;/code&gt;. Finally, it produces &lt;code&gt;KE_MOUSEUP&lt;/code&gt; or &lt;code&gt;KE_MOUSEDOWN&lt;/code&gt; by masking for the lowest bit. (&lt;a href=&quot;https://github.com/vim/vim/blob/master/src/term.c&quot; rel=&quot;nofollow noreferrer&quot;&gt;term.c&lt;/a&gt;:5739).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't traced this up/down &#xA;event for other terminal settings (e.g. &lt;code&gt;set ttymouse=xterm&lt;/code&gt; also works), but the code looks like to handles many inputs in this section (it converts concrete mouse events into an internal standard of psuedo-mouse events, and then works with that).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be nice for vim to extend the standards with escape codes for left/right scroll wheel events, but it looks like it wouldn't fit neatly into the present code base (perhaps needing an extra variable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Motivation: It's useful for vim on phones (using terminal-ide or termux) with limited screen size. Turn off onscreen keyboard to double the available screen. Then rotate device to portrait mode to increases the number of lines, and turn off line wrapping (&lt;code&gt;:set nowrap&lt;/code&gt;) to increase the number of lines much further. Most lines will fit on the screen... but viewing long lines is where a touch screen swipe (sending a horizontal mouse scroll wheel event) comes in handy, because it doesn't require the on-screen keyboard.&#xA;It's possible that over time, viewing code on smartphones may become more common.&lt;/p&gt;&#xA;" OwnerUserId="3189" LastEditorUserId="3189" LastEditDate="2018-07-31T09:32:14.057" LastActivityDate="2018-07-31T09:32:14.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16942" PostTypeId="2" ParentId="16907" CreationDate="2018-07-31T07:43:27.123" Score="2" Body="&lt;p&gt;As said by the other answers you can not reuse the search pattern and the subgroups with every command. So here is another general way that works with every command: use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#:execute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:execute&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#getline()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getline()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#substitute()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;substitute()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global /aaa/ execute 'python3 print(&quot;' . substitute(getline('.'), 'aaa(.*)', '\1', '') . '&quot;*3)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-31T07:43:27.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16943" PostTypeId="2" ParentId="16924" CreationDate="2018-07-31T10:39:01.070" Score="2" Body="&lt;p&gt;You've already solved your problem, but for the benefit of future readers, I'll paste a couple of bits from &lt;code&gt;:help modeline&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;No other commands than &quot;set&quot; are supported, for security reasons (somebody&#xA;  might create a Trojan horse text file with modelines).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Hint: If you would like to do something else than setting an option, you could define an autocommand that checks the file for a specific string.  For&#xA;  example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufReadPost * if getline(1) =~ &quot;VAR&quot; | call SetVar() | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;And define a function SetVar() that does something with the line containing&#xA;  &quot;VAR&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Similarly, you could use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufReadPost your_file.conf AleDisable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could remove the modeline altogether with an autocommand along the lines of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufReadPost your_file.conf AleDisable | set ft=python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-07-31T10:39:01.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16944" PostTypeId="2" ParentId="4186" CreationDate="2018-07-31T11:10:21.927" Score="4" Body="&lt;p&gt;You state that your current workflow is &quot;inaccurate&quot; and &quot;less usable&quot;. You can solve the former (but arguably not the latter) by replacing your current &lt;code&gt;j&lt;/code&gt; mapping with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; j v:count == 0 ? 'gj' : &quot;\&amp;lt;Esc&amp;gt;&quot;.v:count.'j'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this mapping, you can still use a plain &lt;kbd&gt;j&lt;/kbd&gt; to move down one screen line at a time, but if you use a count, then you will move down to the line indicated by the corresponding &lt;code&gt;'relativenumber'&lt;/code&gt; marker. Accurate! :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, because there are no markers on the later screen lines of single wrapped lines, you still cannot use &lt;code&gt;Nj&lt;/code&gt; to jump to those lines. Still less usable :(.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;How it works&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This is an expression mapping, which maps to different commands depending on the current count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is no count, it simply performs a &lt;code&gt;gj&lt;/code&gt;. If there &lt;code&gt;is&lt;/code&gt; a count it first clears the existing count with &lt;kbd&gt;Esc&lt;/kbd&gt;, and then performs a regular &lt;code&gt;j&lt;/code&gt; using the value of that count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :map-expr&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help v:count&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help expr1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-07-31T11:10:21.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16945" PostTypeId="5" CreationDate="2018-07-31T14:10:38.623" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2018-07-31T14:10:38.623" LastActivityDate="2018-07-31T14:10:38.623" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16946" PostTypeId="4" CreationDate="2018-07-31T14:10:38.623" Score="0" Body="For questions about words/terms that are specific to Vi and/or Vim." OwnerUserId="11357" LastEditorUserId="11357" LastEditDate="2018-07-31T15:09:49.633" LastActivityDate="2018-07-31T15:09:49.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16948" PostTypeId="1" AcceptedAnswerId="16949" CreationDate="2018-07-31T16:34:23.663" Score="0" ViewCount="1095" Body="&lt;p&gt;&lt;code&gt;:ls&lt;/code&gt; shows my buffers and lists flags for each buffer, but doesn't list whether &lt;code&gt;&amp;amp;diff&lt;/code&gt; is set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plugins like unite's buffer source just rely on &lt;code&gt;:ls&lt;/code&gt; output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an easy way to list and manage which buffers are in diff mode (for those times when &lt;code&gt;:diffget&lt;/code&gt; fails due to more than two buffers in diff mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I'd like something like &lt;code&gt;:Unite buffer&lt;/code&gt; that includes 'diff' for buffers with &lt;code&gt;&amp;amp;l:diff&lt;/code&gt;. A unite source that showed which buffers have certain variables would be cool: &lt;code&gt;:Unite var diff scrollbind&lt;/code&gt; that works like &lt;code&gt;:Unite buffer&lt;/code&gt; but appends 'diff' or 'scrollbind' to files with those options enabled.&lt;/p&gt;&#xA;" OwnerUserId="2045" LastActivityDate="2018-07-31T17:10:33.273" Title="How can I see which buffers are in diff mode?" Tags="|buffers|vimdiff|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16949" PostTypeId="2" ParentId="16948" CreationDate="2018-07-31T17:04:23.033" Score="1" Body="&lt;p&gt;Something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo join(&#xA;\          filter(&#xA;\                 map(&#xA;\                     range(1, winnr('$')), &#xA;\                     'getwinvar(v:val, &quot;&amp;amp;diff&quot;) ? &quot;window:&quot;.v:val.&quot;  buffer:&quot;.winbufnr(v:val).&quot; -&amp;gt; &quot;.bufname(winbufnr(v:val)) : &quot;&quot;'), &#xA;\                 '!empty(v:val)'),&#xA;\           &quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will return you the information you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, &lt;code&gt;&amp;amp;diff&lt;/code&gt; is a window-local option. This means you can fetch its value with &lt;code&gt;getwinvar(winnr, '&amp;amp;diff')&lt;/code&gt;, on all windows with &lt;code&gt;range(1, winnr('$'))&lt;/code&gt;. From there, if true, you have the window number, you can extract the buffer number with &lt;code&gt;winbufnr(winnr)&lt;/code&gt; and display the name of the associated buffer with &lt;code&gt;bufname(bufnr)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;join&lt;/code&gt; + &lt;code&gt;filter&lt;/code&gt; part helps to keep only what matters and print one result per line.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-07-31T17:10:33.273" LastActivityDate="2018-07-31T17:10:33.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16950" PostTypeId="2" ParentId="8011" CreationDate="2018-07-31T17:39:17.320" Score="2" Body="&lt;p&gt;I have a file that was installed as part of neovim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/nvim/runtime/filetype.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That file lists all the default filetypes defined in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for example I wanted to know what files vim considers to be of &lt;code&gt;cpp&lt;/code&gt; type.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Cynlib&#xA;&quot; .cc and .cpp files can be C++ or Cynlib.&#xA;au BufNewFile,BufRead *.cc&#xA;    \ if exists(&quot;cynlib_syntax_for_cc&quot;)|setf cynlib|else|setf cpp|endif&#xA;au BufNewFile,BufRead *.cpp&#xA;    \ if exists(&quot;cynlib_syntax_for_cpp&quot;)|setf cynlib|else|setf cpp|endif&#xA;&#xA;&quot; C++&#xA;au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.ipp,*.moc,*.tcc,*.inl setf cpp&#xA;if has(&quot;fname_case&quot;)&#xA;  au BufNewFile,BufRead *.C,*.H setf cpp&#xA;endif&#xA;&#xA;&quot; .h files can be C, Ch C++, ObjC or ObjC++.&#xA;&quot; Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is&#xA;&quot; detected automatically.&#xA;au BufNewFile,BufRead *.h           call dist#ft#FTheader()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;FTheader is defined in &lt;code&gt;/usr/share/nvim/runtime/autoload/dist/ft.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func dist#ft#FTheader()&#xA;  if match(getline(1, min([line(&quot;$&quot;), 200])), '^@\(interface\|end\|class\)') &amp;gt; -1&#xA;    if exists(&quot;g:c_syntax_for_h&quot;)&#xA;      setf objc&#xA;    else&#xA;      setf objcpp&#xA;    endif&#xA;  elseif exists(&quot;g:c_syntax_for_h&quot;)&#xA;    setf c&#xA;  elseif exists(&quot;g:ch_syntax_for_h&quot;)&#xA;    setf ch&#xA;  else&#xA;    setf cpp&#xA;  endif&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18405" LastActivityDate="2018-07-31T17:39:17.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16951" PostTypeId="1" CreationDate="2018-07-31T20:09:23.803" Score="7" ViewCount="7881" Body="&lt;p&gt;I use CentOS 7 which has VIM 7.4 installed. By default the &lt;code&gt;background&lt;/code&gt; property of VIM here is set to &lt;code&gt;light&lt;/code&gt; irrespective of the colourscheme of my terminal. Although I can always force the desired &lt;code&gt;background&lt;/code&gt; property in my &lt;code&gt;vimrc&lt;/code&gt;, I do not want this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Ubuntu (18.04 which has VIM 8), &lt;code&gt;background&lt;/code&gt; property automatically changes between &lt;code&gt;light&lt;/code&gt; and &lt;code&gt;dark&lt;/code&gt; based on the colourscheme of my terminal. This is true even when I am ssh-ing to the Ubuntu machine from my CentOS machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, I would like to know whether the ability of VIM changing &lt;code&gt;background&lt;/code&gt; property automatically is specific to newer versions. And if this is not true, then how do I achieve the same effect in CentOS?&lt;/p&gt;&#xA;" OwnerUserId="16582" LastEditorUserId="16582" LastEditDate="2018-08-18T20:24:53.283" LastActivityDate="2019-02-14T23:23:39.303" Title="How to set VIM's background based on terminal's background colour?" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16952" PostTypeId="1" CreationDate="2018-07-31T21:28:44.113" Score="3" ViewCount="3103" Body="&lt;p&gt;If i've got the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello &#xA;hellllo&#xA;hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i can insert code before or after all of the lines by using I or A in visual block mode, respectively. How can I delete the last x characters? I'm aware that I can do it with s/o// (where o would require more specific text realistically) but isn't there visual block command?&lt;/p&gt;&#xA;" OwnerUserId="17655" LastActivityDate="2019-04-28T13:03:45.750" Title="Delete from end of line in visual block mode" Tags="|replace|visual-block|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16953" PostTypeId="2" ParentId="16952" CreationDate="2018-07-31T22:58:21.423" Score="5" Body="&lt;p&gt;You can use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#v_x&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;x&lt;/code&gt; and &lt;code&gt;d&lt;/code&gt;&lt;/a&gt; in visual (block, line) mode. They will delete exactly the selected text.  This means you can normally not do things like &quot;delete the last three chars of all selected line&quot; (unless all the lines are the same length, then you can with visual block mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But&lt;/strong&gt; according to &lt;a href=&quot;https://vi.stackexchange.com/questions/8370/how-do-you-change-the-last-n-characters-for-a-range-of-lines&quot;&gt;How do you change the last n characters for a range of lines?&lt;/a&gt; there is a trick: Use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:right&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:right&lt;/code&gt;&lt;/a&gt; to first right align the text, remove your chars with visual block mode and the &lt;code&gt;:left&lt;/code&gt; align the text again.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-07-31T22:58:21.423" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16954" PostTypeId="2" ParentId="8142" CreationDate="2018-08-01T01:55:00.523" Score="1" Body="&lt;p&gt;I was able to solve this exact same issue by editing my &quot;my_custom_color_file.vim&quot; file and commenting out the &quot;hi clear&quot; line near the top. I don't know at all why this fixed it, but it seems to not impact any of the colors that show up in &quot;:so $VIMRUNTIME/syntax/hitest.vim&quot;, at least.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone wants to suggest a better fix, please do. My setup includes bg=dark, and I, like the OP, was not having any of my custom colors respected during the swap file message. In my ~/.vimrc, I have a line reading &quot;colo my_custom_color_file&quot;. It was a direct copy of ron.vim originally. I hope this helps someone else who just wants to open their vim in peace and tranquility.&lt;/p&gt;&#xA;" OwnerUserId="18413" LastActivityDate="2018-08-01T01:55:00.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16956" PostTypeId="2" ParentId="16951" CreationDate="2018-08-01T13:32:21.040" Score="2" Body="&lt;p&gt;Vim has a few mechanisms for detecting the background colour of your terminal, which are described in &lt;code&gt;:help 'background'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the |t_RB| option is set, Vim will use it to request the background&#xA;      color from the terminal.  If the returned RGB value is dark/light and&#xA;      'background' is not dark/light, 'background' will be set and the&#xA;      screen is redrawn.  This may have side effects, make t_BG empty in&#xA;      your .vimrc if you suspect this problem.  The response to |t_RB| can&#xA;      be found in |v:termrbgresp|.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;For MS-DOS, Windows and OS/2 the default is &quot;dark&quot;.&#xA;      For other systems &quot;dark&quot; is used when 'term' is &quot;linux&quot;,&#xA;      &quot;screen.linux&quot;, &quot;cygwin&quot; or &quot;putty&quot;, or $COLORFGBG suggests a dark&#xA;      background.  Otherwise the default is &quot;light&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;By looking at the repository history, it seems as though the mechanism using a terminal query/response was first added in version 7.4.757 in 2015, although it looks as though it was still being tweaked as late as version 8.0.1129, in 2017.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your version of Vim is older than that, then you should be able to get Vim to detect the background by setting an appropriate value of &lt;code&gt;COLORFGBG&lt;/code&gt; in your shell. (e.g. &lt;code&gt;7;0&lt;/code&gt;. The first number is the foreground, the second is the background. Vim sets &lt;code&gt;'background'&lt;/code&gt; to &lt;code&gt;dark&lt;/code&gt; if the second value is &lt;code&gt;0-6&lt;/code&gt; or &lt;code&gt;8&lt;/code&gt;.) This variable is automatically set by some shells, and it looks like Vim has been using it for background-detection since around 2011.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details on how Vim (and other apps) detect background colours can be found in the answers to &lt;a href=&quot;https://unix.stackexchange.com/q/245378/63001&quot;&gt;this question on the Unix Stack Exchange&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-08-01T13:32:21.040" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16957" PostTypeId="1" CreationDate="2018-08-01T14:19:41.420" Score="2" ViewCount="4674" Body="&lt;p&gt;I am facing huge slowness when i start the neovim for the first time in a session, and then next time i open it the startup time is little better relatively but not as fast as vim is. I looked at the issue tracker on official neovim git repo as well but couldn't find any solution for my problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So i profiled it a bit using startuptime and below are the log files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1st time startup&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; times in msec&#xA;  clock   self+sourced   self:  sourced script&#xA;  clock   elapsed:              other lines&#xA;&#xA; 000.009  000.009: --- NVIM STARTING ---&#xA; 009.986  009.977: locale set&#xA; 018.750  008.764: inits 1&#xA; 018.764  000.014: window checked&#xA; 018.842  000.078: parsing arguments&#xA; 020.031  001.189: expanding arguments&#xA; 020.081  000.051: inits 2&#xA; 020.591  000.510: init highlight&#xA; 2162.962  446.040  446.040: sourcing /apps/nttech/rbhanot/.config/nvim/autoload/plug.vim&#xA; 4363.032  265.956  265.956: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/filetype.vim&#xA; 4374.207  000.761  000.761: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/ftplugin.vim&#xA; 4384.176  000.624  000.624: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/indent.vim&#xA; 4511.851  000.251  000.251: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/syntax/syncolor.vim&#xA; 4559.538  048.912  048.661: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/syntax/synload.vim&#xA; 4559.623  174.580  125.668: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/syntax/syntax.vim&#xA; 4719.856  019.373  019.373: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/custom.vim&#xA; 4818.131  095.671  095.671: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/util.vim&#xA; 4865.563  044.503  044.503: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/init.vim&#xA; 5553.428  086.264  086.264: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/configure.vim&#xA; 5625.453  068.322  068.322: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/config.vim&#xA; 5766.744  138.128  138.128: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/log.vim&#xA; 5880.082  023.316  023.316: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/core.vim&#xA; 5880.362  110.428  087.112: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/utils.vim&#xA; 5881.801  4591.203  3140.554: sourcing /apps/nttech/rbhanot/.config/nvim/plugins.vim&#xA; 6131.604  000.196  000.196: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/syntax/syncolor.vim&#xA; 6131.941  246.633  246.437: sourcing /apps/nttech/rbhanot/.config/nvim/settings.vim&#xA; 8233.645  2099.276  2099.276: sourcing /apps/nttech/rbhanot/.config/nvim/mappings.vim&#xA; 8667.321  000.210  000.210: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/syntax/syncolor.vim&#xA; 8667.962  000.184  000.184: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/syntax/syncolor.vim&#xA; 9128.201  057.730  057.730: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/onedark.vim/autoload/onedark.vim&#xA; 9143.354  893.845  835.721: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/onedark.vim/colors/onedark.vim&#xA; 9143.363  906.383  012.538: sourcing /apps/nttech/rbhanot/.config/nvim/colors.vim&#xA; 9143.367  9112.849  1269.354: sourcing /apps/nttech/rbhanot/.config/nvim/init.vim&#xA; 9143.370  009.931: sourcing vimrc file(s)&#xA; 9500.542  168.125  168.125: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete.vim&#xA; 9500.640  248.886  080.761: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/plugin/deoplete.vim&#xA; 9837.148  000.064  000.064: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/filetype.vim&#xA; 9837.393  000.032  000.032: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/ftplugin.vim&#xA; 9837.551  314.860  314.764: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/jedi-vim/plugin/jedi.vim&#xA; 10110.528  254.186  254.186: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/nerdcommenter/plugin/NERD_commenter.vim&#xA; 10327.254  138.892  138.892: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/ctrlp.vim/autoload/ctrlp/mrufiles.vim&#xA; 10327.400  178.883  039.991: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/ctrlp.vim/plugin/ctrlp.vim&#xA; 10448.190  101.616  101.616: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neoformat/plugin/neoformat.vim&#xA; 10758.798  197.868  197.868: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/plugin/neomake.vim&#xA; 10846.685  065.937  065.937: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/vim-highlightedyank/plugin/highlightedyank.vim&#xA; 12296.180  830.588  830.588: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/plugin/lightline.vim&#xA; 12300.560  002.324  002.324: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/gzip.vim&#xA; 12300.621  000.021  000.021: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/health.vim&#xA; 12300.702  000.055  000.055: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/man.vim&#xA; 12301.157  000.429  000.429: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/matchit.vim&#xA; 12301.336  000.151  000.151: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/matchparen.vim&#xA; 12301.754  000.390  000.390: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/netrwPlugin.vim&#xA; 12710.640  002.290  002.290: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/autoload/remote/host.vim&#xA; 12711.174  000.242  000.242: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/autoload/remote/define.vim&#xA; 12711.269  407.030  404.497: sourcing /apps/nttech/rbhanot/.local/share/nvim/rplugin.vim&#xA; 12711.279  409.492  002.462: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/rplugin.vim&#xA; 12711.429  000.110  000.110: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/rrhelper.vim&#xA;12711.642  000.151  000.151: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/shada.vim&#xA;12711.741  000.065  000.065: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/spellfile.vim&#xA;12711.919  000.144  000.144: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/tarPlugin.vim&#xA;12712.068  000.100  000.100: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/tohtml.vim&#xA;12712.151  000.033  000.033: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/tutor.vim&#xA;12712.329  000.149  000.149: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/zipPlugin.vim&#xA;12712.341  962.533: loading plugins&#xA;12712.501  000.161: loading packages&#xA;12713.280  000.779: loading after plugins&#xA;12713.289  000.008: inits 3&#xA;13329.357  616.069: reading ShaDa&#xA;13330.852  001.494: clearing screen&#xA;13471.229  132.012  132.012: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake.vim&#xA;13522.013  048.045  048.045: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/compat.vim&#xA;13614.739  083.898  083.898: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/autoload/lightline.vim&#xA;13726.571  100.799  100.799: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/autoload/lightline/tab.vim&#xA;14180.150  201.807  201.807: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/autoload/lightline/colorscheme.vim&#xA;14180.879  324.479  122.672: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/onedark.vim/autoload/lightline/colorscheme/onedark.vim&#xA;14183.512  163.427: opening buffers&#xA;14183.638  000.127: BufEnter autocommands&#xA;14183.641  000.003: editing files in windows&#xA;14194.265  002.221  002.221: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/autoload/provider/pythonx.vim&#xA;14194.736  000.253  000.253: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/autoload/provider/python3.vim&#xA;14201.950  000.095  000.095: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/autoload/provider.vim&#xA;24842.491  422.066  422.066: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/mapping.vim&#xA;25118.676  265.119  265.119: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/handler.vim&#xA;25119.092  10245.697: VimEnter autocommands&#xA;25122.433  003.006  003.006: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/autoload/provider/clipboard.vim&#xA;25122.454  000.356: before starting main loop&#xA;25123.773  001.319: first screen update&#xA;25123.776  000.003: --- NVIM STARTED ---&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3rd/4th time startup of nvim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;times in msec&#xA; clock   self+sourced   self:  sourced script&#xA; clock   elapsed:              other lines&#xA;&#xA;000.008  000.008: --- NVIM STARTING ---&#xA;008.448  008.441: locale set&#xA;015.910  007.461: inits 1&#xA;015.921  000.012: window checked&#xA;016.028  000.107: parsing arguments&#xA;016.109  000.081: expanding arguments&#xA;016.152  000.043: inits 2&#xA;016.650  000.498: init highlight&#xA;026.381  001.913  001.913: sourcing /apps/nttech/rbhanot/.config/nvim/autoload/plug.vim&#xA;044.812  005.863  005.863: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/filetype.vim&#xA;045.537  000.476  000.476: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/ftplugin.vim&#xA;046.166  000.472  000.472: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/indent.vim&#xA;048.404  000.243  000.243: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/syntax/syncolor.vim&#xA;049.201  001.197  000.954: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/syntax/synload.vim&#xA;049.233  002.965  001.768: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/syntax/syntax.vim&#xA;053.277  000.102  000.102: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/custom.vim&#xA;055.590  000.149  000.149: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/util.vim&#xA;057.983  000.177  000.177: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/init.vim&#xA;064.724  000.342  000.342: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/configure.vim&#xA;067.375  000.141  000.141: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/config.vim&#xA;070.249  000.138  000.138: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/log.vim&#xA;075.618  000.084  000.084: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/core.vim&#xA;075.902  002.931  002.846: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/utils.vim&#xA;076.079  052.397  036.729: sourcing /apps/nttech/rbhanot/.config/nvim/plugins.vim&#xA;079.099  000.202  000.202: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/syntax/syncolor.vim&#xA;079.445  001.058  000.856: sourcing /apps/nttech/rbhanot/.config/nvim/settings.vim&#xA;082.170  000.243  000.243: sourcing /apps/nttech/rbhanot/.config/nvim/mappings.vim&#xA;089.026  000.213  000.213: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/syntax/syncolor.vim&#xA;089.647  000.194  000.194: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/syntax/syncolor.vim&#xA;095.374  000.134  000.134: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/onedark.vim/autoload/onedark.vim&#xA;110.779  022.549  022.007: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/onedark.vim/colors/onedark.vim&#xA;110.786  026.078  003.529: sourcing /apps/nttech/rbhanot/.config/nvim/colors.vim&#xA;110.791  091.349  011.573: sourcing /apps/nttech/rbhanot/.config/nvim/init.vim&#xA;110.793  002.795: sourcing vimrc file(s)&#xA;118.587  000.094  000.094: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete.vim&#xA;118.682  002.464  002.370: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/plugin/deoplete.vim&#xA;123.330  000.061  000.061: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/filetype.vim&#xA;123.554  000.038  000.038: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/ftplugin.vim&#xA;123.702  000.657  000.559: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/jedi-vim/plugin/jedi.vim&#xA;133.354  003.378  003.378: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/nerdcommenter/plugin/NERD_commenter.vim&#xA;141.299  000.244  000.244: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/ctrlp.vim/autoload/ctrlp/mrufiles.vim&#xA;141.452  003.535  003.291: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/ctrlp.vim/plugin/ctrlp.vim&#xA;146.006  000.065  000.065: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neoformat/plugin/neoformat.vim&#xA;150.843  000.251  000.251: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/plugin/neomake.vim&#xA;155.332  000.136  000.136: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/vim-highlightedyank/plugin/highlightedyank.vim&#xA;159.743  000.105  000.105: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/plugin/lightline.vim&#xA;161.497  000.602  000.602: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/gzip.vim&#xA;161.543  000.018  000.018: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/health.vim&#xA;161.617  000.052  000.052: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/man.vim&#xA;162.059  000.418  000.418: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/matchit.vim&#xA;162.236  000.150  000.150: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/matchparen.vim&#xA;162.666  000.403  000.403: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/netrwPlugin.vim&#xA;166.553  000.604  000.604: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/autoload/remote/host.vim&#xA;167.037  000.220  000.220: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/autoload/remote/define.vim&#xA;167.125  001.624  000.800: sourcing /apps/nttech/rbhanot/.local/share/nvim/rplugin.vim&#xA;167.132  004.425  002.801: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/rplugin.vim&#xA;167.205  000.039  000.039: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/rrhelper.vim&#xA;167.324  000.093  000.093: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/shada.vim&#xA;167.388  000.036  000.036: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/spellfile.vim&#xA;167.548  000.132  000.132: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/tarPlugin.vim&#xA;167.676  000.101  000.101: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/tohtml.vim&#xA;167.736  000.030  000.030: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/tutor.vim&#xA;167.914  000.144  000.144: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/plugin/zipPlugin.vim&#xA;167.923  039.895: loading plugins&#xA;168.051  000.128: loading packages&#xA;168.136  000.085: loading after plugins&#xA;168.144  000.008: inits 3&#xA;1942.969  1774.825: reading ShaDa&#xA;1944.427  001.458: clearing screen&#xA;1958.795  000.098  000.098: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/autoload/provider/pythonx.vim&#xA;1958.918  000.831  000.733: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/autoload/provider/python3.vim&#xA;1959.199  000.027  000.027: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/autoload/provider.vim&#xA;2391.237  433.879  433.021: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/jedi-vim/autoload/jedi.vim&#xA;2391.475  436.849  002.970: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/jedi-vim/ftplugin/python/jedi.vim&#xA;2392.999  000.873  000.873: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/ftplugin/python.vim&#xA;2398.721  000.044  000.044: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/jedi-vim/after/ftplugin/python/jedi.vim&#xA;2399.764  000.632  000.632: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/indent/python.vim&#xA;2401.409  001.087  001.087: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/syntax/python.vim&#xA;2403.871  000.167  000.167: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/jedi-vim/after/syntax/python.vim&#xA;2409.454  000.228  000.228: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/makers/ft/python.vim&#xA;2409.636  001.301  001.073: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/makers/ft/python.vim&#xA;2414.306  001.269  001.269: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake.vim&#xA;2417.206  000.236  000.236: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/compat.vim&#xA;2432.229  000.397  000.397: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/autoload/lightline.vim&#xA;2435.793  000.090  000.090: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/autoload/lightline/tab.vim&#xA;2443.641  000.198  000.198: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/autoload/lightline/colorscheme.vim&#xA;2444.239  003.260  003.062: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/onedark.vim/autoload/lightline/colorscheme/onedark.vim&#xA;2450.882  000.214  000.214: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/ctrlp.vim/autoload/ctrlp/utils.vim&#xA;2460.957  070.110: opening buffers&#xA;2461.065  000.108: BufEnter autocommands&#xA;2461.069  000.004: editing files in windows&#xA;2558.750  000.144  000.144: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/mapping.vim&#xA;2561.381  000.204  000.204: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/handler.vim&#xA;2561.877  100.461: VimEnter autocommands&#xA;2562.950  000.749  000.749: sourcing /tmp/.mount_nvimX5THMT/usr/share/nvim/runtime/autoload/provider/clipboard.vim&#xA;2562.959  000.333: before starting main loop&#xA;2566.608  003.649: first screen update&#xA;2566.611  000.003: --- NVIM STARTED ---&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So i see &lt;code&gt;VimEnter autocommands&lt;/code&gt; to be a bottleneck here but i don't have any autocommands defined in my init.vim. Second i see &lt;code&gt;mappings.vim&lt;/code&gt; and &lt;code&gt;plugins.vim&lt;/code&gt; being the other culprits. So below are my config files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;init.vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')&#xA;if !filereadable(vimplug_exists)&#xA;  if !executable(&quot;curl&quot;)&#xA;    echoerr &quot;You have to install curl or first install vim-plug yourself!&quot;&#xA;    execute &quot;q!&quot;&#xA;  endif&#xA;  echo &quot;Installing Vim-Plug...&quot;&#xA;  echo &quot;&quot;&#xA;  silent !\curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;  let g:not_finish_vimplug = &quot;yes&quot;&#xA;  autocmd VimEnter * PlugInstall&#xA;endif&#xA;source ~/.config/nvim/plugins.vim&#xA;source ~/.config/nvim/settings.vim&#xA;source ~/.config/nvim/mappings.vim&#xA;source ~/.config/nvim/colors.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Plugins.vim&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.config/nvim/plugged')&#xA;Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins'}&#xA;Plug 'zchee/deoplete-jedi', { 'do': ':UpdateRemotePlugins'  }&#xA;Plug 'davidhalter/jedi-vim'&#xA;Plug 'scrooloose/nerdcommenter'&#xA;Plug 'ctrlpvim/ctrlp.vim'&quot;&#xA;Plug 'sbdchd/neoformat'&#xA;Plug 'neomake/neomake'&#xA;Plug 'machakann/vim-highlightedyank'&#xA;Plug 'itchyny/lightline.vim'&#xA;Plug 'joshdick/onedark.vim'&#xA;call plug#end()&#xA;inoremap &amp;lt;expr&amp;gt;&amp;lt;tab&amp;gt; pumvisible() ? &quot;\&amp;lt;c-n&amp;gt;&quot; : &quot;\&amp;lt;tab&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; pumvisible() ? &quot;\&amp;lt;C-Y&amp;gt;&quot; : &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;call deoplete#custom#source('_', 'converters', ['converter_auto_paren'])&#xA;let g:deoplete#enable_at_startup = 1&#xA;let g:deoplete#enable_ignore_case = 1&#xA;let g:deoplete#enable_smart_case = 1&#xA;let g:context_filetype#same_filetypes = {}&#xA;let g:context_filetype#same_filetypes._ = '_'&#xA;let g:python_host_prog  = '/usr/bin/python'&#xA;let g:python3_host_prog = '/usr/bin/python3'&#xA;let g:jedi#completions_enabled = 0&#xA;let g:jedi#goto_command = &quot;,,d&quot;&#xA;let g:jedi#usages_command = &quot;,,o&quot;&#xA;let g:jedi#goto_assignments_command = ',,a'&#xA;let g:jedi#rename_command = &quot;,,r&quot;&#xA;let g:jedi#documentation_command = &quot;K&quot;&#xA;let g:jedi#use_splits_not_buffers = &quot;right&quot;&#xA;call neomake#configure#automake('nrwi', 200)&#xA;let g:neomake_python_enabled_makers = ['flake8']&#xA;let g:neomake_open_list = 0&#xA;nnoremap ,, :Neoformat&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;C-_&amp;gt; :call NERDComment(0,&quot;toggle&quot;)&amp;lt;CR&amp;gt;&#xA;let g:NERDSpaceDelims = 1&#xA;let g:NERDCompactSexyComs = 1&#xA;let g:NERDDefaultAlign = 'left'&#xA;let g:NERDAltDelims_java = 1&#xA;let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }&#xA;let g:NERDCommentEmptyLines = 1&#xA;let g:NERDTrimTrailingWhitespace = 1&#xA;let g:NERDToggleCheckAllLines = 1&#xA;let g:lightline = {'colorscheme':'onedark'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;mappings.vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;\&amp;lt;Space&amp;gt;&quot;&#xA;noremap &amp;lt;leader&amp;gt;r :source $MYVIMRC&amp;lt;cr&amp;gt;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; pumvisible() ? &quot;\&amp;lt;C-Y&amp;gt;&quot; : &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;noremap &amp;lt;left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;noremap &amp;lt;down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;vnoremap &amp;lt;left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;vnoremap &amp;lt;right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;vnoremap &amp;lt;up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;vnoremap &amp;lt;down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;cmap W w&#xA;cmap Q q&#xA;nnoremap ci/ f/cT/&#xA;nnoremap di/ f/dT/&#xA;nnoremap ci, f,cT,&#xA;nnoremap di, f,dT,&#xA;noremap &amp;lt;leader&amp;gt;h :nohl&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;leader&amp;gt;h :nohl&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;C-N&amp;gt;&amp;lt;C-N&amp;gt; :set invnumber&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-x&amp;gt; :b#&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;leader&amp;gt;, :bd&amp;lt;CR&amp;gt; &#xA;noremap &amp;lt;c-j&amp;gt; &amp;lt;c-w&amp;gt;j&#xA;noremap &amp;lt;c-k&amp;gt; &amp;lt;c-w&amp;gt;k&#xA;noremap &amp;lt;c-l&amp;gt; &amp;lt;c-w&amp;gt;l&#xA;noremap &amp;lt;c-h&amp;gt; &amp;lt;c-w&amp;gt;h&#xA;noremap &amp;lt;a-h&amp;gt; :sp&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;a-v&amp;gt; :vsp&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;a-h&amp;gt; &amp;lt;ESC&amp;gt;:sp&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;a-v&amp;gt; &amp;lt;ESC&amp;gt;:vsp&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;Leader&amp;gt;t &amp;lt;ESC&amp;gt;:tabnew %:h&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;S-Tab&amp;gt; &amp;lt;ESC&amp;gt;:tabnext&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;leader&amp;gt;o :vertical wincmd f&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt; &amp;lt;gv &quot; better indentation&#xA;vnoremap &amp;gt; &amp;gt;gv &quot; better indentation&#xA;set pastetoggle=&amp;lt;F2&amp;gt;&#xA;nnoremap j gj&#xA;nnoremap k gk&#xA;nnoremap Y y$&#xA;nnoremap ,o o&amp;lt;ESC&amp;gt;k&#xA;nnoremap ,O O&amp;lt;ESC&amp;gt;j&#xA;noremap &amp;lt;Leader&amp;gt;c &quot;*y&#xA;noremap &amp;lt;Leader&amp;gt;v &quot;*p&#xA;nnoremap &amp;lt;leader&amp;gt;- :wincmd _&amp;lt;cr&amp;gt;:wincmd \|&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;= :wincmd =&amp;lt;cr&amp;gt;&#xA;if has(&quot;nvim&quot;)&#xA;    nnoremap &amp;lt;C-Q&amp;gt; :sp &amp;lt;CR&amp;gt; :term python % &amp;lt;CR&amp;gt;a&#xA;  tnoremap &amp;lt;Esc&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;   &quot;tnoremap stands for terminal mode mappings in neovim&quot;&#xA;  tnoremap &amp;lt;c-h&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;&amp;lt;C-w&amp;gt;h&#xA;  tnoremap &amp;lt;c-j&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;&amp;lt;C-w&amp;gt;j&#xA;  tnoremap &amp;lt;c-k&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;&amp;lt;C-w&amp;gt;k&#xA;  tnoremap &amp;lt;c-j&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;&amp;lt;C-w&amp;gt;j&#xA;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;settings.vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=dark&#xA;set encoding=utf-8&#xA;set t_Co=256&#xA;set visualbell    &quot; stop that ANNOYING beeping&#xA;set textwidth=100&#xA;set wrap&#xA;set linebreak&#xA;set nolist&#xA;set cursorline              &quot; highlight current line&#xA;set showmatch               &quot; highlight matching [{()}]&#xA;set wildmode=list:longest,full&#xA;set lazyredraw              &quot; redraw only when we need to.&#xA;set relativenumber number&#xA;set ignorecase              &quot; ignore case when searching&#xA;set smartcase                               &quot; make search case Sensitive if it contains an Uppercase letter otherwise search is case insensitive&#xA;set nofoldenable              &quot; enable folding&#xA;set foldmethod=indent&#xA;set foldlevel=10&#xA;set foldlevelstart=0   &quot; open most folds by default&#xA;set nobackup&#xA;set nowritebackup&#xA;set noswapfile&#xA;set clipboard=unnamed &quot; copy to system clipboard&#xA;set splitbelow&#xA;set splitright&#xA;set tabstop=2&#xA;set softtabstop=2&#xA;set shiftwidth=2&#xA;au BufNewFile,BufRead *.py&#xA;    \ set tabstop=4         &quot; number of visual spaces per TAB&#xA;    \ set softtabstop=4     &quot; number of spaces in tab when editing&#xA;    \ set shiftwidth=4      &quot; when using the &amp;gt;&amp;gt; or &amp;lt;&amp;lt; commands, shift lines by 4 spaces&#xA;    \ set textwidth=100&#xA;    \ set expandtab         &quot; expand tabs into spaces&#xA;    \ set autoindent&#xA;    \ set fileformat=unix&#xA;au BufNewFile,BufRead *.js, *.html, *.css&#xA;    \ set tabstop=2&#xA;    \ set softtabstop=2&#xA;    \ set shiftwidth=2&#xA;if has(&quot;nvim&quot;)&#xA;    set guicursor=&#xA;    let $NVIM_TUI_ENABLE_CURSOR_SHAPE = 0&#xA;    set inccommand=nosplit&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;colors.vim&lt;/strong&gt;&#xA;&lt;code&gt;colo onedark&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I tried running nvim with a minimal.vim as config file and in that startup is really really fast and below is my minimal.init and then the log for the same&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;minimal.vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=dark&#xA;set encoding=utf-8&#xA;set t_Co=256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;=============================&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; times in msec&#xA;  clock   self+sourced   self:  sourced script&#xA;  clock   elapsed:              other lines&#xA;&#xA; 000.025  000.025: --- NVIM STARTING ---&#xA; 009.055  009.030: locale set&#xA; 016.067  007.012: inits 1&#xA; 016.079  000.011: window checked&#xA; 016.184  000.106: parsing arguments&#xA; 016.258  000.074: expanding arguments&#xA; 016.304  000.046: inits 2&#xA; 016.761  000.457: init highlight&#xA; 019.408  000.440  000.440: sourcing minimal.vim&#xA; 019.417  002.216: sourcing vimrc file(s)&#xA; 025.897  005.561  005.561: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/filetype.vim&#xA; 026.752  000.507  000.507: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/ftplugin.vim&#xA; 027.320  000.454  000.454: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/indent.vim&#xA; 028.282  000.209  000.209: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/syntax/syncolor.vim&#xA; 028.390  000.428  000.219: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/syntax/synload.vim&#xA; 028.418  000.951  000.523: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/syntax/syntax.vim&#xA; 029.743  000.581  000.581: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/gzip.vim&#xA; 029.789  000.019  000.019: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/health.vim&#xA; 029.859  000.048  000.048: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/man.vim&#xA; 030.293  000.409  000.409: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/matchit.vim&#xA; 030.465  000.145  000.145: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/matchparen.vim&#xA; 030.856  000.364  000.364: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/netrwPlugin.vim&#xA; 033.225  000.575  000.575: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/autoload/remote/host.vim&#xA; 033.552  000.174  000.174: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/autoload/remote/define.vim&#xA; 033.639  001.145  000.397: sourcing /apps/nttech/rbhanot/.local/share/nvim/rplugin.vim&#xA; 033.646  002.748  001.603: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/rplugin.vim&#xA; 033.720  000.039  000.039: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/rrhelper.vim&#xA; 033.833  000.087  000.087: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/shada.vim&#xA; 033.896  000.032  000.032: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/spellfile.vim&#xA; 034.051  000.127  000.127: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/tarPlugin.vim&#xA; 034.175  000.094  000.094: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/tohtml.vim&#xA; 034.229  000.026  000.026: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/tutor.vim&#xA; 034.392  000.137  000.137: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/plugin/zipPlugin.vim&#xA; 034.400  002.655: loading plugins&#xA; 034.518  000.118: loading packages&#xA; 034.585  000.068: loading after plugins&#xA; 034.592  000.006: inits 3&#xA; 652.960  618.369: reading ShaDa&#xA; 654.446  001.486: clearing screen&#xA; 665.205  000.840  000.840: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/ftplugin/python.vim&#xA; 666.358  000.526  000.526: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/indent/python.vim&#xA; 667.725  001.050  001.050: sourcing /tmp/.mount_nvimslfgXy/usr/share/nvim/runtime/syntax/python.vim&#xA; 668.134  011.271: opening buffers&#xA;668.154  000.020: BufEnter autocommands&#xA;668.156  000.002: editing files in windows&#xA;668.236  000.080: VimEnter autocommands&#xA;668.238  000.002: before starting main loop&#xA;671.087  002.849: first screen update&#xA;671.091  000.004: --- NVIM STARTED --&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even i tried running nvim with noplugins option as well but even that also does not do much improvement which makes me think there is some setting that is causing the issue but i am not able to figure it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be much appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I am new to vim/neovim and i really want to learn and work on it but this is somehow being a roadblock for me to use neovim. And i really want to use neovim because the advantage of having a built in terminal helps to get away from tmux+vim combo..&lt;/p&gt;&#xA;" OwnerUserId="18373" LastEditorUserId="18373" LastEditDate="2018-08-08T17:44:41.343" LastActivityDate="2021-08-27T23:45:55.860" Title="Vim/neoVim really slow startup" Tags="|vimrc|neovim|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16959" PostTypeId="2" ParentId="10814" CreationDate="2018-08-01T15:17:54.807" Score="1" Body="&lt;p&gt;The CtrlP buffer has the name &lt;code&gt;ControlP&lt;/code&gt;, so you should just be able to check this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorHold * if bufname(&quot;%&quot;) != 'ControlP' | call TagbarCurrentTag() | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-08-01T15:17:54.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16960" PostTypeId="1" AcceptedAnswerId="16962" CreationDate="2018-08-01T15:37:48.010" Score="2" ViewCount="399" Body="&lt;p&gt;I have a &lt;code&gt;.bin&lt;/code&gt; file which has a size of 8192. If I open the file in Vi, then use &lt;code&gt;:wq&lt;/code&gt; without making any changes, the file size becomes 8193. What's happening? It's a HEX file if that makes any difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what was added to the file by Vi:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0a                                    |.|&#xA;00002001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18429" LastEditorUserId="1841" LastEditDate="2018-08-01T16:21:13.160" LastActivityDate="2018-08-03T06:14:11.530" Title="Why does Vi change the size of my .bin file?" Tags="|binary-file|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16961" PostTypeId="2" ParentId="16821" CreationDate="2018-08-01T15:46:34.133" Score="3" Body="&lt;h3&gt;&lt;code&gt;&amp;lt;Ctrl-M&amp;gt;&lt;/code&gt; is equivalent to &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;First of all, please note that &lt;code&gt;&amp;lt;Ctrl-M&amp;gt;&lt;/code&gt; is equivalent to &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; which you might not use in normal mode and therefore is ok for you.&#xA;If you use the mapping, you can also press &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in normal mode to trigger make.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you like to use a different mapping, have a look at the plugin &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-dispatch&lt;/a&gt; by Tim Pope&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This plugin provides following mappings&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;enter&lt;/kbd&gt; &lt;code&gt;:Make&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;space&lt;/kbd&gt; &lt;code&gt;:Make&amp;lt;Space&amp;gt;&lt;/code&gt; (enter arguments)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;!&lt;/kbd&gt;+&lt;kbd&gt;enter&lt;/kbd&gt; &lt;code&gt;:Make!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;?&lt;/kbd&gt; Show &lt;code&gt;'makeprg'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and the new command &lt;code&gt;:Make&lt;/code&gt; works as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                *dispatch-:Make*&#xA;:Make [arguments]       Using the current |:compiler| settings, dispatch a&#xA;                        build in the foreground.  Adapter strategies vary, but&#xA;                        the goal is visibility without stealing focus.  When&#xA;                        the build is complete, load the results into the&#xA;                        |quickfix| list and call |:cwindow|.  This command is&#xA;                        preferred for shorter tasks like &quot;build this file.&quot;&#xA;&#xA;:Make! [arguments]      Using the current compiler settings, dispatch a build&#xA;                        in the background.  Use |:Copen| to load the results.&#xA;                        This command is preferred for longer tasks like &quot;run&#xA;                        the entire test suite.&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the difference between &lt;code&gt;:copen&lt;/code&gt; and &lt;code&gt;:cwindow&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *:cw* *:cwindow*&#xA;:cw[indow] [height] Open the quickfix window when there are recognized&#xA;            errors.  If the window is already open and there are&#xA;            no recognized errors, close the window.&#xA;&#xA;                        *:cope* *:copen* *w:quickfix_title*&#xA;:cope[n] [height]   Open a window to show the current list of errors.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-08-02T08:22:50.283" LastActivityDate="2018-08-02T08:22:50.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16962" PostTypeId="2" ParentId="16960" CreationDate="2018-08-01T15:47:53.030" Score="7" Body="&lt;p&gt;Most likely, Vi adds a trailing linefeed. There used to be whole flame wars whether editors should add a trailing linefeed for the content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a convention, that differs between Windows (there you would usually talk about line separators) while on Unix like operating systems one usually speaks about line terminators. (The most convincing argument for using terminators for me was using something like &lt;code&gt;cat file1 file2&lt;/code&gt; so that the when the lines from the second file are output, they start at a new line.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, to disable this behaviour, you can start Vim in binary mode (which as the name suggest should be used for editing binary files and resets quite a couple of options that might unintentionally change your file, which you can read at the documentation: &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;binary&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'binary'&lt;/a&gt;). For normal files however, you can nowadays also set the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27endofline%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;'endofline'&lt;/a&gt; or &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27fixeol%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;'fixendofline'&lt;/a&gt; option, which simply disables writing the final line termination character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note: the 'endofline' option only works when the 'binary' option is set, which is usually suboptimal, so if you really need this, I would recommend unsetting the 'fixeol' option).&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-08-03T06:14:11.530" LastActivityDate="2018-08-03T06:14:11.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16963" PostTypeId="1" AcceptedAnswerId="16969" CreationDate="2018-08-01T17:21:20.063" Score="34" ViewCount="80956" Body="&lt;p&gt;Is it possible to remap the &lt;kbd&gt;Esc&lt;/kbd&gt; key to another key in Vim?  When I'm using Vim in a full screen VMware vSphere web client console window and I press the &lt;kbd&gt;Esc&lt;/kbd&gt; key to exit edit mode, it also takes me out of full screen mode in the console window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the Vim that comes from the RHEL YUM repo. (RHEL 7.5; Vim 7.4).&lt;/p&gt;&#xA;" OwnerUserId="18415" LastEditorUserId="4472" LastEditDate="2018-08-06T14:46:55.323" LastActivityDate="2024-02-29T10:37:53.017" Title="Remap Esc key in Vim" Tags="|vimrc|key-bindings|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16964" PostTypeId="1" AcceptedAnswerId="16966" CreationDate="2018-08-01T18:03:20.903" Score="0" ViewCount="930" Body="&lt;p&gt;Currently, I set the following keymap to my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-z&amp;gt; :NERDTreeToggle ~/Dropbox/jupyter/&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I sometimes want to trigger it with different directory, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:NERDTreeToggle CURRENT_DIR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I tried the following command &lt;a href=&quot;https://unix.stackexchange.com/questions/8233/vim-get-current-directory&quot;&gt;with the following answer&lt;/a&gt;, but it did not work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:NERDTreeToggle getcwd()&#xA;:NERDTreeToggle pwd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get the current directory to insert into the command-line mode?&lt;/p&gt;&#xA;" OwnerUserId="1072" LastEditorUserId="1072" LastEditDate="2018-08-01T18:15:07.103" LastActivityDate="2018-08-02T11:19:44.747" Title="What command can I use to insert the current directory in the command-line mode?" Tags="|command-line|" AnswerCount="3" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16965" PostTypeId="2" ParentId="16964" CreationDate="2018-08-01T18:12:44.097" Score="0" Body="&lt;p&gt;&lt;code&gt;getcwd()&lt;/code&gt;, so the command you want would be &lt;code&gt;:NERDTreeToggle getcwd()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You just exchanged one character. &lt;code&gt;pwd&lt;/code&gt; means print working directory. &lt;code&gt;cwd&lt;/code&gt; means current working directory. That's why the function name is a bit different.&lt;/p&gt;&#xA;" OwnerUserId="10482" LastActivityDate="2018-08-01T18:12:44.097" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16966" PostTypeId="2" ParentId="16964" CreationDate="2018-08-01T18:25:03.407" Score="3" Body="&lt;p&gt;The arguments you pass to a command are used as text, not as expressions, so unless a command specifically evaluates the expression in its implementation, passing an expression such as &lt;code&gt;getcwd()&lt;/code&gt; won’t function how you’re hoping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you can write a command where the expression is evaluated before being passed to the argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute 'NERDTreeToggle' getcwd()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might need to add a bit more handling for paths that contain spaces to stop them being passed as separate arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute 'NERDTreeToggle' escape(getcwd(), ' ')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can use the expression register to add the result of a function directly. While in command-line mode press &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt; and then type your function &lt;code&gt;getcwd()&lt;/code&gt; and press &lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-08-02T11:19:44.747" LastActivityDate="2018-08-02T11:19:44.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16969" PostTypeId="2" ParentId="16963" CreationDate="2018-08-01T21:04:47.500" Score="33" Body="&lt;p&gt;Usually, &lt;code&gt;C-[&lt;/code&gt; is also a way to get out of insert mode. Some people like to map &lt;code&gt;jj&lt;/code&gt; in insert mode as a way to exit and return to normal mode. I personally prefer &lt;code&gt;jh&lt;/code&gt; as my fingers 'slide' better with this and I don't strain my middle finger much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From somewhere in my neovim settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap jh &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This remaps &lt;code&gt;jh&lt;/code&gt; to escape in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this what you wanted?&lt;/p&gt;&#xA;" OwnerUserId="14779" LastActivityDate="2018-08-01T21:04:47.500" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="16970" PostTypeId="1" AcceptedAnswerId="16971" CreationDate="2018-08-01T21:09:15.177" Score="0" ViewCount="185" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/Shougo/denite.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;denite&lt;/a&gt; seems to use the cmdline like ctrlp instead of a buffer like Unite. Is there a way to edit your query with normal mode commands?&lt;/p&gt;&#xA;" OwnerUserId="2045" LastEditorUserId="51" LastEditDate="2018-08-20T16:11:24.017" LastActivityDate="2021-04-07T02:02:00.157" Title="Is it possible to use normal mode type editing in denite?" Tags="|plugin-denite|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16971" PostTypeId="2" ParentId="16970" CreationDate="2018-08-01T21:09:15.177" Score="0" Body="&lt;p&gt;Use &lt;code&gt;C-o&lt;/code&gt; to jump to normal mode. This mode works in two ways: you can navigate the candidates buffer and you can issue some normal mode commands to modify your query.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You won't have a cursor when it's at the end and some commands don't work as expected (you can't &lt;code&gt;dw&lt;/code&gt; to remove a word), but a bunch of functionality is there. It's always going to be a bit weird since the inputs are doing two things at once (should &lt;code&gt;e&lt;/code&gt; to move to the end of a word or edit the selected file?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can customize the mode switching mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    &quot; Switch modes with C-l (like esc but won't quit)&#xA;    call denite#custom#map(&#xA;            \ 'normal',&#xA;            \ '&amp;lt;C-l&amp;gt;',&#xA;            \ '&amp;lt;denite:enter_mode:insert&amp;gt;',&#xA;            \ 'noremap'&#xA;            \)&#xA;    call denite#custom#map(&#xA;            \ 'insert',&#xA;            \ '&amp;lt;C-l&amp;gt;',&#xA;            \ '&amp;lt;denite:enter_mode:normal&amp;gt;',&#xA;            \ 'noremap'&#xA;            \)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2045" LastActivityDate="2018-08-01T21:09:15.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16972" PostTypeId="1" CreationDate="2018-08-01T23:24:07.267" Score="2" ViewCount="359" Body="&lt;p&gt;Suppose I have a variable &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:f_themes=&quot;./themes/**&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Suppose I want to map this command to a key:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;vimgrep /&quot;.expand(&quot;&amp;lt;cword&amp;gt;&quot;).&quot;/g &quot;.g:f_themes.&quot; | copen&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That works, even though it may complain about not finding &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;. I can deal with that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what if I want to instead place that string onto the command line and NOT execute it, which allows me to inspect and edit the command before hitting &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;. I can't use :execute because it will go ahead and execute. And I can't get the value of &lt;code&gt;g:f_themes&lt;/code&gt; to expand to &lt;code&gt;./themes/**&lt;/code&gt; if I just type the command without the :execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to place a string onto the command line so that a simple &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; would go ahead and execute the line?&lt;/p&gt;&#xA;" OwnerUserId="18439" OwnerDisplayName="BSM" LastEditorUserId="11357" LastEditDate="2018-08-31T10:22:10.623" LastActivityDate="2018-08-31T10:22:10.623" Title="Place a string onto the command line without execution" Tags="|command-line|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16973" PostTypeId="2" ParentId="16972" CreationDate="2018-08-02T01:54:38.193" Score="0" Body="&lt;p&gt;I think I got part of the answer: how to map a key to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, declare this one-line function (1):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe &quot;function! Temp(cword) \n return ':vimgrep /'.a:cword.'/ '.g:f_themes.' | copen' \n endfunction&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then do this key mapping (2):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;gt ':'.Temp(expand(&quot;&amp;lt;cword&amp;gt;&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It puts this on the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /mycword/ ./themes/** | copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just what I wanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple of points:&#xA;(1): You can't use bars (&lt;code&gt;|&lt;/code&gt;) to separate lines in a compressed function.&#xA;(2): You need &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;. Learn something new every day.&#xA;You need to quote the &lt;code&gt;:&lt;/code&gt;.&#xA;You need to use &lt;code&gt;expand()&lt;/code&gt;.&#xA;Or it won't work.&#xA;I don't know if &lt;code&gt;Temp()&lt;/code&gt; could directly refer to &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now there is another question.&#xA;What if one wanted to pump the command line directly from a function. Is it possible to do that?&lt;/p&gt;&#xA;" OwnerUserId="18439" LastActivityDate="2018-08-02T01:54:38.193" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16974" PostTypeId="2" ParentId="14378" CreationDate="2018-08-02T02:17:31.723" Score="2" Body="&lt;p&gt;I recommend the use of vim extension &lt;a href=&quot;https://github.com/mattn/webapi-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;webapi&lt;/a&gt;. The best way to install it is using any package manager and follow &lt;a href=&quot;https://vimawesome.com/plugin/webapi-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimawesome&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library contains various parser for different formats and is very easy to use with little configuration. Enjoy.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-08-02T02:17:31.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16975" PostTypeId="2" ParentId="16964" CreationDate="2018-08-02T08:12:14.043" Score="1" Body="&lt;p&gt;Looks like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:NERDTreeToggle .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is doing what you're looking for -- several other commands work this way &lt;code&gt;:sp&lt;/code&gt;, &lt;code&gt;:e&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use &lt;code&gt;getcwd()&lt;/code&gt;, you would have needed to play with &lt;code&gt;:execute&lt;/code&gt;, or &lt;code&gt;c_CTRL-R_=&lt;/code&gt; in that case. I prefer the later when I can (from mappings, or from the command-line e.g.).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap µ :NERDTreeToggle &amp;lt;c-r&amp;gt;=getcwd()&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Interactively, this means you'd have to type CTRL+R and conclude with ENTER, twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your question was &lt;em&gt;&quot;the directory from the current file&quot;&lt;/em&gt;, interactively I usually type  &lt;code&gt;CTRL+R % CTRL-W&lt;/code&gt; (^W once or twice depending &lt;code&gt;.&lt;/code&gt; is in the &lt;code&gt;&amp;amp;isk&lt;/code&gt; list or not). In a mapping/script/..., instead of &lt;code&gt;getcwd()&lt;/code&gt;, I call &lt;code&gt;expand('%:h')&lt;/code&gt;, or &lt;code&gt;expand('%:p:h')&lt;/code&gt; to have an absolute path.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-08-02T08:12:14.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16976" PostTypeId="2" ParentId="16972" CreationDate="2018-08-02T08:37:32.753" Score="1" Body="&lt;p&gt;You can insert the evaluations of expressions into the command-line (or a buffer) with the expression register, by pressing &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;. You can also use this in a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;gt :vimgrep /&amp;lt;C-R&amp;gt;=expand(&quot;&amp;lt;cword&amp;gt;&quot;)&amp;lt;CR&amp;gt;/g &amp;lt;C-R&amp;gt;=g:f_themes&amp;lt;CR&amp;gt; &amp;lt;bar&amp;gt; copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help quote_=&lt;/code&gt; for more details on the expression register and &lt;code&gt;:help c_CTRL-R&lt;/code&gt; for specific notes on using it in command-line mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: You mention in a comment that you'd like to be able to do this without any mapping being involved. You can use &lt;code&gt;feedkeys()&lt;/code&gt; for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call feedkeys(':vimgrep /' . expand(&quot;&amp;lt;cword&amp;gt;&quot;) . '/g ' . g:f_themes . ' | copen')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be run from the command-line, or directly within a function (that has not been invoked by a mapping).&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-08-02T22:03:15.857" LastActivityDate="2018-08-02T22:03:15.857" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16979" PostTypeId="1" CreationDate="2018-08-02T18:16:40.897" Score="1" ViewCount="130" Body="&lt;p&gt;I use YouComplete plugin to do language completion but I can't seem to get tags to work for my own files/functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use xolox/vim-misc and xolox/vim-easytags and installed Exhuberant ctags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my .vimrc setup for easy tags as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Amazing code completion&#xA;Plugin 'Valloric/YouCompleteMe'&#xA;&#xA;&quot;tags&#xA;Plugin 'xolox/vim-misc'&#xA;Plugin 'xolox/vim-easytags'&#xA;&#xA;&quot; ----- xolox/vim-easytags settings -----&#xA;set tags=~/.vimtags&#xA;let g:easytags_events = ['BufReadPost', 'BufWritePost']&#xA;let g:easytags_async = 1&#xA;let g:easytags_dynamic_files = 2&#xA;let g:easytags_resolve_links = 1&#xA;let g:easytags_suppress_ctags_warning = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What do I have to do to make my custom functions show up in auto complete with YouComplete plugin&lt;/p&gt;&#xA;" OwnerUserId="12964" LastActivityDate="2018-08-02T18:16:40.897" Title="How to set up vim tags for JavaScript using vim-easytags" Tags="|vimrc|plugin-you-complete-me|ctags|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16981" PostTypeId="2" ParentId="6112" CreationDate="2018-08-02T23:12:37.713" Score="67" Body="&lt;p&gt;As of Vim &lt;a href=&quot;https://github.com/vim/vim/commit/072687032683b1994d25a114893d9a6f8bc36612&quot; rel=&quot;noreferrer&quot;&gt;8.0.1554&lt;/a&gt;, you can use &lt;strong&gt;&lt;code&gt;vim --clean&lt;/code&gt;&lt;/strong&gt; (or &lt;strong&gt;&lt;code&gt;nvim --clean&lt;/code&gt;&lt;/strong&gt; for Neovim). This method is recommended by &lt;a href=&quot;https://vimhelp.appspot.com/intro.txt.html#bugs&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help bugs&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.appspot.com/starting.txt.html#--clean&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help --clean&lt;/code&gt;&lt;/a&gt; docs:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Similar to &amp;quot;-u DEFAULTS -U NONE -i NONE&amp;quot;:&lt;br /&gt;&#xA;- initializations from files and environment variables is&#xA;skipped&lt;br /&gt;&#xA;- &lt;strong&gt;'runtimepath' and 'packpath' are set to exclude home&#xA;directory entries&lt;/strong&gt; (does not happen with -u DEFAULTS).&lt;br /&gt;&#xA;- the |defaults.vim| script is loaded, which implies&#xA;'nocompatible': use Vim defaults&lt;br /&gt;&#xA;- no |gvimrc| script is loaded&lt;br /&gt;&#xA;- no viminfo file is read or written&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerDisplayName="user4779" LastEditorUserId="33861" LastEditDate="2021-03-03T15:26:06.323" LastActivityDate="2021-03-03T15:26:06.323" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16982" PostTypeId="1" AcceptedAnswerId="16983" CreationDate="2018-08-03T00:52:14.577" Score="1" ViewCount="125" Body="&lt;p&gt;I can customize some error display in my file like highlight all white space at the end of each line by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:match ErrorMsg /\s\+$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I put all the error I found into quickfix windows that I can go through it one by one?&lt;/p&gt;&#xA;" OwnerUserId="18452" LastEditorUserId="18452" LastEditDate="2018-08-03T02:03:24.283" LastActivityDate="2018-08-03T04:56:40.583" Title="Put error into quickfix window" Tags="|vimrc|autocmd|quickfix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16983" PostTypeId="2" ParentId="16982" CreationDate="2018-08-03T04:56:40.583" Score="1" Body="&lt;p&gt;You can use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:vimgrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:vimgrep /pattern/ %&lt;/code&gt;&lt;/a&gt; to search the current file for &lt;code&gt;pattern&lt;/code&gt; and put the results in the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:grep&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:grep&lt;/code&gt;&lt;/a&gt; which works in the same way but uses an external program to do the search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You did not ask for it but in simple situations (like removing trailing spaces) you can also use the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#:s&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:substitute&lt;/code&gt;&lt;/a&gt; command. For example with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\s\+$//ec&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you will be walked through every match in the file and can confirm if you want it removed. (&lt;code&gt;e&lt;/code&gt; is to ignore errors like &quot;no matches found&quot; and &lt;code&gt;c&lt;/code&gt; is for interactive confirming every replacement)&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-08-03T04:56:40.583" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16984" PostTypeId="1" AcceptedAnswerId="16985" CreationDate="2018-08-03T09:07:01.103" Score="1" ViewCount="910" Body="&lt;p&gt;I use to be able to resize my vim splits using the mouse in the terminal by clicking on the borders and dragging. Now I can't. How can I make it work again?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: still works in gvim but doesn't work in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: It doesn't work not because of ubuntu 18.04 itself but because the terminal emulator is gnome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: Well turns out it's not a problem of gnome terminal but some user setting for my ubuntu user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: After much wasted time debugging I found the problem was this setting &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set term=screen-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also had this in my .bashrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TERM=screen-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both these settings break the mouse resizing for some reason. If I recall I added them because tmux wouldn't be able to display vim's themes properly in ubuntu 16. Seems to be working now even without them. The only other problem I found is that now I can't use my mouse to resize within tmux but this was solved with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;term =~ '^screen'&#xA;    &quot; tmux knows the extended mouse mode&#xA;    set ttymouse=xterm2&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12408" LastEditorUserId="12408" LastEditDate="2018-08-10T07:24:53.623" LastActivityDate="2018-08-10T07:24:53.623" Title="Split resizing with mouse not working after upgrade from ubuntu 16.04 to 18" Tags="|split|mouse|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16985" PostTypeId="2" ParentId="16984" CreationDate="2018-08-03T13:51:58.070" Score="0" Body="&lt;p&gt;At a minimum, you need the &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27mouse%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'mouse'&lt;/code&gt;&lt;/a&gt; option enabled (using either the &lt;code&gt;a&lt;/code&gt; or &lt;code&gt;n&lt;/code&gt; value) for Vim to respond to the mouse.  Check &lt;code&gt;:verbose set mouse?&lt;/code&gt; to see if it's being set and by which script.  Vim 8 will enable it by default, unless you have your own vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your terminal also needs to support sending the mouse clicks and movements to Vim.  If Vim detects your terminal supports that, it should be reflected in Vim by &lt;code&gt;:set ttymouse?&lt;/code&gt; being non-empty.  The value will most likely be one of &lt;code&gt;xterm&lt;/code&gt;, &lt;code&gt;xterm2&lt;/code&gt;, &lt;code&gt;sgr&lt;/code&gt;, or &lt;code&gt;urxvt&lt;/code&gt; depending on the terminal you're using.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2018-08-03T13:51:58.070" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16987" PostTypeId="2" ParentId="9366" CreationDate="2018-08-03T18:33:54.867" Score="3" Body="&lt;p&gt;I had a similar experience as OP. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that &lt;code&gt;t&lt;/code&gt; was being added to my &lt;code&gt;formatoptions&lt;/code&gt; despite deliberately attempting to disable it.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After using &lt;code&gt;:verbose set fo&lt;/code&gt; to be certain it was coming from .vimrc, I noticed that the behavior seemed to be dependent on where I put the formatoptions in my .vimrc file. I discovered that it was happening because of where I had placed &lt;code&gt;set nocompatible&lt;/code&gt; in my file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set formatoptions=qj&#xA;set nocompatible&#xA;&#xA;:set fo?&#xA;  formatoptions=tcq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It turns out that this is specifically called out in &lt;code&gt;:help nocompatible&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                   'compatible' 'cp' 'nocompatible' 'nocp'&#xA;'compatible' 'cp'   boolean (default on, off when a |vimrc| or |gvimrc|&#xA;                    file is found, reset in |defaults.vim|)&#xA;            global&#xA;            {not in Vi}&#xA;    This option has the effect of making Vim either more Vi-compatible, or&#xA;    make Vim behave in a more useful way.&#xA;&#xA;    This is a special kind of option, because when it's set or reset,&#xA;    other options are also changed as a side effect.&#xA;    NOTE: Setting or resetting this option can have a lot of unexpected&#xA;    effects: Mappings are interpreted in another way, undo behaves&#xA;    differently, etc.  If you set this option in your vimrc file, you&#xA;    should probably put it at the very start.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After following this good advice, my &lt;code&gt;formatoptions&lt;/code&gt; were preserved as desired.  I don't know if OP was running into this exact problem or if it was some other interaction, but I was happy to find out what was causing it.  Hopefully this helps someone else figure out what's (initially inexplicably) changing their settings.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also like theonlygusti's autocmd- there are some options I just never want set no matter the file type. I'm looking at you, &lt;code&gt;t&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18459" LastActivityDate="2018-08-03T18:33:54.867" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16989" PostTypeId="1" AcceptedAnswerId="16990" CreationDate="2018-08-03T21:53:45.383" Score="3" ViewCount="426" Body="&lt;p&gt;I write comments of the form&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#############&#xA;## Example ##&#xA;#############&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Always one line, always just like that. It's a way of breaking up code more visually. I have lately taken to the following way of typing them out:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Type double #, space, the comment, space, double #.&lt;/li&gt;&#xA;&lt;li&gt;Look at the ruler in right hand corner for the horizontal position.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;esc&amp;gt;ki#&amp;lt;esc&amp;gt;&amp;lt;the_number_from_step_2_minus_one&amp;gt;.&amp;lt;esc&amp;gt;yyjp&lt;/code&gt; to enter &lt;code&gt;n&lt;/code&gt; #'s, yank it, and paste it at the bottom.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But even this seems redundant. I would like to define a macro of the form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a='k&amp;lt;n&amp;gt;#i&amp;lt;esc&amp;gt;&amp;lt;esc&amp;gt;yyjp&amp;lt;esc&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;&amp;lt;n&amp;gt;&lt;/code&gt; is the length of the line I will execute the macro on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;## Example ##&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I do not know how to record and store the position of the last character on the particular line. Suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found &lt;a href=&quot;http://vim.wikia.com/wiki/Put_boxes_around_comments_in_code&quot; rel=&quot;nofollow noreferrer&quot;&gt;this suggestion from the vim wikia&lt;/a&gt; but I don't want a plugin, and &lt;a href=&quot;https://stackoverflow.com/questions/21118249/vim-script-to-surround-multiline-comment-with-comment-character&quot;&gt;this from Stack Overflow&lt;/a&gt; but this seems like overkill again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I don't use any plugins and would prefer not to. I literally have none. And a fairly short vimrc (&amp;lt;50 lines after a recent doubling).&lt;/p&gt;&#xA;" OwnerUserId="17830" LastActivityDate="2018-08-03T22:04:33.683" Title="Vim Comment Box Macro" Tags="|macro|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16990" PostTypeId="2" ParentId="16989" CreationDate="2018-08-03T21:59:09.173" Score="5" Body="&lt;p&gt;You don’t need to know the length of the line. This ought to do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a = 'yyPVr#jpVr#'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I’d also automate the adding of the hashes at the start and end of the middle line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a = &quot;I## \&amp;lt;Esc&amp;gt;A ##\&amp;lt;Esc&amp;gt;yyPVr#jpVr#&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-08-03T22:04:33.683" LastActivityDate="2018-08-03T22:04:33.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16991" PostTypeId="1" CreationDate="2018-08-04T09:49:25.523" Score="2" ViewCount="975" Body="&lt;p&gt;In normal mode, I tried &lt;code&gt;CTRL-H&lt;/code&gt; and &lt;code&gt;CTRL-L&lt;/code&gt;, and I found that the former worked while the latter didn't do anything at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder why their behaviors are not the same?&lt;/p&gt;&#xA;" OwnerUserId="18467" LastActivityDate="2019-01-03T12:40:29.247" Title="why ctrl-h and ctrl-l behaves differently in normal mode?" Tags="|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16992" PostTypeId="1" CreationDate="2018-08-04T12:27:47.600" Score="1" ViewCount="287" Body="&lt;p&gt;What is happening under the hood when we type &lt;code&gt;:w !python3&lt;/code&gt; in VIM. Does it invoke the system-wide &lt;code&gt;python3&lt;/code&gt; or the one present in the virtual environment?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import sys&#xA;sys.path.append('./extnsn/')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This appends the &lt;code&gt;./extnsn/&lt;/code&gt; directory to the &lt;code&gt;sys.path&lt;/code&gt; variable. However, I am prompted with &lt;code&gt;module extnsn not found&lt;/code&gt; error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error is the same when executing the script with &lt;code&gt;python-mode&lt;/code&gt; enabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having tough time importing a module from another directory. Any help is much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="18442" LastEditorUserId="18442" LastEditDate="2018-09-02T15:21:23.320" LastActivityDate="2018-09-02T15:21:23.320" Title="How vim invokes and executes python interpreter" Tags="|vimscript-python|plugin-python-mode|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16993" PostTypeId="2" ParentId="588" CreationDate="2018-08-04T12:53:34.097" Score="5" Body="&lt;p&gt;Proportional fonts are supported in Neovim GUIs such as &lt;a href=&quot;https://github.com/yatli/fvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;FVim&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The discontinued &lt;a href=&quot;https://github.com/onivim/oni&quot; rel=&quot;nofollow noreferrer&quot;&gt;Oni&lt;/a&gt; project also supported this with its &amp;quot;webgl&amp;quot; renderer (see &lt;a href=&quot;https://github.com/onivim/oni/issues/2359&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/onivim/oni/issues/2359&lt;/a&gt;):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; &amp;quot;editor.renderer&amp;quot;: &amp;quot;webgl&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="578" LastEditorUserId="578" LastEditDate="2023-10-09T08:52:44.037" LastActivityDate="2023-10-09T08:52:44.037" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16995" PostTypeId="2" ParentId="16991" CreationDate="2018-08-04T17:37:30.637" Score="2" Body="&lt;p&gt;In normal mode &lt;kbd&gt;Ctrl-H&lt;/kbd&gt; is same as &lt;kbd&gt;h&lt;/kbd&gt; -- that is 'move to the left' while &lt;kbd&gt;Ctrl-L&lt;/kbd&gt; means 'clear and redraw the screen', not 'move to the right'. This  &lt;kbd&gt;Ctrl-L&lt;/kbd&gt; behavior is very similar to bash shell. This is useful for example when you have background process printing some stuff while you are using vim in terminal. &lt;/p&gt;&#xA;" OwnerUserId="1782" LastActivityDate="2018-08-04T17:37:30.637" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16996" PostTypeId="1" AcceptedAnswerId="17299" CreationDate="2018-08-04T18:33:09.723" Score="1" ViewCount="696" Body="&lt;p&gt;I would like to add, say, the next three characters to the current visual selection. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;Do not select. &lt;b&gt;Select from here.&#xA;Select this too. Select until the&lt;/b&gt;re. Do not select.&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If bold represents the selection, I would like to expand it by three characters at the end. If I know that the cursor is &lt;i&gt;at the end&lt;/i&gt; of the selection, I can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I know that the cursor is &lt;i&gt;at the beginning&lt;/i&gt; of the selection, I can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;o&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I want to write a visual-mode command that works in both situations. How would I do that? Restoring the cursor position afterwards would be a plus.&lt;/p&gt;&#xA;" OwnerUserId="18470" LastActivityDate="2018-09-05T15:56:12.950" Title="Expand the visual selection independently of the cursor position" Tags="|visual-mode|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16997" PostTypeId="1" CreationDate="2018-08-04T19:35:54.483" Score="1" ViewCount="41" Body="&lt;p&gt;I tried &lt;code&gt;let @q = '&amp;lt;return&amp;gt;'&lt;/code&gt; and it obviously won't work&lt;/p&gt;&#xA;" OwnerUserId="18254" LastEditorUserId="18254" LastEditDate="2018-08-04T19:45:04.403" LastActivityDate="2018-09-04T14:01:11.577" Title="How to insert special keys (like &lt;return&gt;, &lt;m-r&gt;) into macro registers with script?" Tags="|key-bindings|vimscript|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16998" PostTypeId="1" AcceptedAnswerId="17910" CreationDate="2018-08-04T20:47:06.253" Score="3" ViewCount="275" Body="&lt;p&gt;I would like to type &lt;code&gt;begin!&lt;/code&gt; in insert mode and having it immediately replaced by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;begin &lt;i&gt;[cursor here]&lt;/i&gt; end&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I considered mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap begin! begin  end&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and abbreviations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:iabbrev begin! begin  end&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But both have caveats.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) The mapping functionally does exactly what I want, but it displays characters typed in a very confusing way. For example, if I type &lt;code&gt;beginning&lt;/code&gt;, the apparent contents of my buffer evolves like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b&#xA;e&#xA;g&#xA;i&#xA;n&#xA;beginn&#xA;beginni&#xA;beginnin&#xA;beginning&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to see the same thing as if there was no mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) The substitution only happens after typing the next character. Furthermore, which characters trigger the substitution and which ones block it is a bit obscure¹, and does not suits my needs (most often, I would need to type an alphabetic character next).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get the behaviour I want?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;¹: The substitution is triggered by characters not in the &lt;code&gt;'iskeyword'&lt;/code&gt; option (which includes alphanumeric characters), by &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; (which is an awful key for most non-QWERTY layouts), or by escaping from the insert mode.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="18470" LastActivityDate="2018-11-10T15:39:33.077" Title="Substitute an insert-mode input immediately" Tags="|key-bindings|insert-mode|abbreviations|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16999" PostTypeId="2" ParentId="16998" CreationDate="2018-08-05T00:06:55.920" Score="2" Body="&lt;p&gt;I found a kind of solution by reading &lt;code&gt;:help abbreviations&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! EatBlank()&#xA;  let c = nr2char(getchar(0))&#xA;  return (c =~ '\s' || c == &quot;\r&quot;) ? '' : c&#xA;endfun&#xA;&#xA;iabbrev &amp;lt;buffer&amp;gt; begin! begin  end&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;C-R&amp;gt;=EatBlank()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will consume the next character if it is a blank character (including &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;). This way, I can type a space to trigger the substitution, and it will not be inserted. Not exactly what I was looking for, but good enough.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After hacking for a while, I could achieve the exact behaviour I was looking for, by making &lt;code&gt;!&lt;/code&gt; the character that triggers the substitution instead of being part of the abbreviation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! BeginEnd()&#xA;  let c = nr2char(getchar(0))&#xA;  return (c == '!') ? &quot;begin  end\&amp;lt;Left&amp;gt;\&amp;lt;Left&amp;gt;\&amp;lt;Left&amp;gt;\&amp;lt;Left&amp;gt;&quot; : 'begin' . c&#xA;endfun&#xA;&#xA;iabbrev &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; begin BeginEnd()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18470" LastActivityDate="2018-08-05T00:06:55.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17000" PostTypeId="1" CreationDate="2018-08-05T01:12:07.117" Score="1" ViewCount="722" Body="&lt;pre&gt;&lt;code&gt;:imap mmm &amp;lt;Esc&amp;gt;&#xA;vmap '=y :w !pbcopy&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I copied two lines of vim map scripts. The first one has a leading colon while the latter one doesn't have. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what's the purpose of the leading colon?&lt;/p&gt;&#xA;" OwnerUserId="18467" LastEditorUserId="18467" LastEditDate="2018-08-05T08:34:18.300" LastActivityDate="2018-10-04T10:00:15.250" Title="what's the purpose of leading colon in key map?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17001" PostTypeId="2" ParentId="17000" CreationDate="2018-08-05T06:15:09.077" Score="3" Body="&lt;p&gt;The colons don’t do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same commands can be typed into Vim interactively, in which case you need the colon to switch from normal mode to command-line mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When executing Vimscript from a file, the colons are not necessary, so it’s usual to omit them, but if they are included the commands will still work.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-08-05T06:15:09.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17002" PostTypeId="2" ParentId="16997" CreationDate="2018-08-05T13:59:58.530" Score="1" Body="&lt;p&gt;&lt;code&gt;&amp;lt;return&amp;gt;&lt;/code&gt; is not completely wrong. You just need to use double-quote and add backslash. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @q = &quot;ihello\&amp;lt;Return&amp;gt;vim\&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1782" LastActivityDate="2018-08-05T13:59:58.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17003" PostTypeId="1" CreationDate="2018-08-05T17:33:17.277" Score="1" ViewCount="1022" Body="&lt;p&gt;Here is a situation. I use deoplete but since the pop-up menu when I type in something already puts the cursor at the first item on the list, when I type in return, it inserts a new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I want to type in return + shift to insert a new line (move the cursor to the next line on insert mode) and typing in just return key adds the completion target.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? I use neovim 0.3.1.&lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2019-12-14T01:02:05.493" Title="Is it possible to type &quot;return + shift&quot; to insert a new line in deoplete?" Tags="|neovim|autocompletion|plugin-deoplete|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17004" PostTypeId="2" ParentId="16996" CreationDate="2018-08-05T18:38:06.563" Score="1" Body="&lt;p&gt;I finally figured it out. The keys are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the marks for the starting (&lt;code&gt;'&amp;lt;&lt;/code&gt;) and ending (&lt;code&gt;'&amp;gt;&lt;/code&gt;) positions of the visual selection;¹&lt;/li&gt;&#xA;&lt;li&gt;functions &lt;code&gt;getpos()&lt;/code&gt; and &lt;code&gt;setpos()&lt;/code&gt; to manipulate marks from vimscript.&lt;/li&gt;&#xA;&lt;li&gt;(the normal-mode command &lt;code&gt;gv&lt;/code&gt; to reselect the active visual selection.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Mixing these ingredients is less straightforward than one might expect, because of oddities of Vim. Also, column numbers are bytewise, so this will break with multibyte characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The (much expanded) code looks like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; These functions will not work as intended in the presence of multibyte&#xA;&quot; characters.&#xA;&#xA;fun! ExpandVisualBefore(by_lines, by_cols)&#xA;  let [start_buf, start_line, start_col, start_off] = getpos(&quot;'&amp;lt;&quot;)&#xA;  let end_pos                                       = getpos(&quot;'&amp;gt;&quot;)&#xA;  if start_off != 0&#xA;    throw 'function ExpandVisualBefore(): ''virtualedit'' is not supported'&#xA;  endif&#xA;  &quot; Note: “:help getpos()” says that the column of '&amp;lt; should be 0 when in&#xA;  &quot; visual-line mode, but my tests indicate that it is set to 1 instead.&#xA;  &quot; the column of '&amp;gt; should be set to a “large number”, which my tests confirm.&#xA;  if end_pos[2] &amp;gt;= 2147483647 &amp;amp;&amp;amp; a:by_cols != 0&#xA;    echohl WarningMsg&#xA;    echo 'function ExpandVisualBefore(): cannot add or remove columns in visual-line mode'&#xA;    echohl None&#xA;  endif&#xA;  if setpos(&quot;'&amp;lt;&quot;, [start_buf, start_line-a:by_lines, start_col-a:by_cols, 0]) == -1&#xA;    throw 'function ExpandVisualBefore(): setpos() failed'&#xA;  endif&#xA;  &quot; Note: For some obscure reason, when the cursor is at the start of the&#xA;  &quot; selection, changing '&amp;lt; apparently sets '&amp;gt; to the former value of '&amp;lt;. Below,&#xA;  &quot; we fix that by restoring '&amp;gt; to its initial value.&#xA;  &quot; Under the same circumstances, the cursor is moved to the end of the&#xA;  &quot; selection, we should fix that as well…&#xA;  if setpos(&quot;'&amp;gt;&quot;, end_pos) == -1&#xA;    throw 'function ExpandVisualAfter(): setpos() failed'&#xA;  endif&#xA;endfun&#xA;&#xA;fun! ExpandVisualAfter(by_lines, by_cols)&#xA;  let start_pos                             = getpos(&quot;'&amp;lt;&quot;)&#xA;  let [end_buf, end_line, end_col, end_off] = getpos(&quot;'&amp;gt;&quot;)&#xA;  if end_off != 0&#xA;    throw 'function ExpandVisualAfter(): ''virtualedit'' is not supported'&#xA;  endif&#xA;  if end_col &amp;gt;= 2147483647 &amp;amp;&amp;amp; a:by_cols != 0&#xA;    echohl WarningMsg&#xA;    echo 'function ExpandVisualAfter(): cannot add or remove columns in visual-line mode'&#xA;    echohl None&#xA;  endif&#xA;  if setpos(&quot;'&amp;gt;&quot;, [end_buf, end_line+a:by_lines, end_col+a:by_cols, 0]) == -1&#xA;    throw 'function ExpandVisualAfter(): setpos() failed'&#xA;  endif&#xA;  &quot; Note: For some obscure reason, when the cursor is at the start of the&#xA;  &quot; selection, changing '&amp;gt; apparently sets '&amp;lt; to the former value of '&amp;gt;. Below,&#xA;  &quot; we fix that by restoring '&amp;lt; to its initial value.&#xA;  &quot; Under the same circumstances, the cursor is moved to the end of the&#xA;  &quot; selection, we should fix that as well…&#xA;  if setpos(&quot;'&amp;lt;&quot;, start_pos) == -1&#xA;    throw 'function ExpandVisualAfter(): setpos() failed'&#xA;  endif&#xA;endfun&#xA;&#xA;vnoremap &amp;lt;silent&amp;gt; \- :call ExpandVisualBefore(0,-v:count1)&amp;lt;CR&amp;gt;gv&#xA;vnoremap &amp;lt;silent&amp;gt; \+ :call ExpandVisualBefore(0,v:count1)&amp;lt;CR&amp;gt;gv&#xA;vnoremap &amp;lt;silent&amp;gt; - :call ExpandVisualAfter(0,-v:count1)&amp;lt;CR&amp;gt;gv&#xA;vnoremap &amp;lt;silent&amp;gt; + :call ExpandVisualAfter(0,v:count1)&amp;lt;CR&amp;gt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, in visual mode, typing &lt;code&gt;3+&lt;/code&gt; (resp. &lt;code&gt;3\+&lt;/code&gt;) extends the selection by three characters to the right (resp. left); typing &lt;code&gt;3-&lt;/code&gt; (resp. &lt;code&gt;3\-&lt;/code&gt;) shrinks it by three characters to the right (resp. left).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;¹ Notation are inconsistent here: in range and movements, &lt;code&gt;`&amp;lt;&lt;/code&gt; and &lt;code&gt;`&amp;gt;&lt;/code&gt; are the starting and ending positions of the selection, whereas &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; are &lt;em&gt;linewise&lt;/em&gt; (they only mean the &lt;em&gt;line&lt;/em&gt; where the selection begins or ends); but as far as &lt;code&gt;getpos()&lt;/code&gt; / &lt;code&gt;setpos()&lt;/code&gt; is concerned, &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; must be used to manipulate the full positions.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="18470" LastActivityDate="2018-08-05T18:38:06.563" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17005" PostTypeId="2" ParentId="5371" CreationDate="2018-08-05T23:49:04.007" Score="1" Body="&lt;p&gt;Easiest stable solution&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a shell function to open a vim session and source your &lt;code&gt;.vimrc&lt;/code&gt; after session finish loading, so you'll have all your seetings back:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open you shell configuration file (&lt;code&gt;.bashrc&lt;/code&gt; or &lt;code&gt;.zshrc&lt;/code&gt;, etc) and write this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vims() {&#xA;  vim -S &quot;$1&quot; -c 'source ~/.vimrc'&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After saving and sourcing the shell config file (or restarting the shell) you'll be always able to open a vim session with the command...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vims mysession.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...and it's done!  :)&lt;/p&gt;&#xA;" OwnerUserId="15921" LastEditorUserId="15921" LastEditDate="2018-08-06T01:45:40.937" LastActivityDate="2018-08-06T01:45:40.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17006" PostTypeId="1" CreationDate="2018-08-06T01:13:56.560" Score="1" ViewCount="783" Body="&lt;p&gt;On my main machine Neovim is my go-to terminal editor. I find it much superior to Vim (I have also tweaked it a bit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fact is, I'm the only developer who will be connecting to the servers I talked about in the question, but there is a great chance that in 3 to 6 months I will be employing 2/3 developers that will work directly on the servers as part of their work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I knew for sure that I would be the only one using those servers, I would install Neovim &lt;strong&gt;and&lt;/strong&gt; upload my configuration. But since I want to keep things simple and standard, I figured I would keep the text editor vanilla.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the question still remains, should I use Vim or Neovim? I've been using standard Vim on the servers for now, as it's more widespread, but I'm pretty sure that Neovim would make Vim users feel right at home, while also providing a better experience.&lt;/p&gt;&#xA;" OwnerUserId="12132" LastEditorUserId="12132" LastEditDate="2018-08-06T02:24:46.950" LastActivityDate="2018-08-06T02:24:46.950" Title="Should I install Vim or Neovim in a Docker image used on servers?" Tags="|neovim|" AnswerCount="0" CommentCount="4" ClosedDate="2018-08-06T07:55:53.207" ContentLicense="CC BY-SA 4.0" />
  <row Id="17007" PostTypeId="1" CreationDate="2018-08-06T01:27:21.437" Score="2" ViewCount="1031" Body="&lt;p&gt;I'm not talking about &lt;a href=&quot;https://vi.stackexchange.com/questions/4762/how-do-i-get-back-to-the-previous-line-after-moving&quot;&gt;the previous line I was on while still editing a file&lt;/a&gt; but &lt;em&gt;after&lt;/em&gt; I close a file and then enter vim again, I want to go to that line. How do I enable this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps to 'reproduce':&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim filename.txt&#xA;:234&#xA;:q&#xA;vim filename.txt&#xA;## I want to be on line 234 now, not line 1.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18477" LastActivityDate="2018-08-13T01:37:02.450" Title="After closing a file, how do I remember/return to the previous line?" Tags="|vimrc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17009" PostTypeId="1" CreationDate="2018-08-06T06:40:13.203" Score="1" ViewCount="377" Body="&lt;p&gt;Consider following autocommand&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('##OptionSet')&#xA;  augroup update_netrw_window&#xA;    autocmd!&#xA;    autocmd OptionSet wildignore&#xA;            \ let currwin=winnr()&#xA;            \ | windo&#xA;            \ | if &amp;amp;ft=='netrw'&#xA;            \ |   execute &quot;normal \&amp;lt;c-l&amp;gt;&quot;&#xA;            \ | else&#xA;            \ |   let a = 1&#xA;            \ | endif&#xA;            \ | execute currwin . 'wincmd w'&#xA;  augroup END&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do not want to execute &lt;code&gt;&quot;normal \&amp;lt;c-l&amp;gt;&quot;&lt;/code&gt; for non-netrw windows.&#xA;As a workaround I have added a simple assignment &lt;code&gt;let a = 1&lt;/code&gt;.&#xA;However, I would like to replace this with something that truely does nothing.&#xA;I cannot remove the else branch because &lt;code&gt;:windo&lt;/code&gt; expects a &lt;code&gt;{cmd}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is in vimscript a &lt;code&gt;{cmd}&lt;/code&gt; which does nothing (similar to &lt;code&gt;pass&lt;/code&gt; in Python)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATED VERSION&lt;/strong&gt;&#xA;As Luc Hermitte pointed out there is no need for an else branch: &lt;code&gt;:windo&lt;/code&gt; does not complain. However, the &lt;code&gt;:windo&lt;/code&gt; command had to be inside an &lt;code&gt;:execute&lt;/code&gt; to avoid calling the placement of the cursor more often than needed, namely only once after &lt;code&gt;:windo&lt;/code&gt; has finished:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('##OptionSet')&#xA;  augroup Vinegar_redraw_netrw_windows&#xA;    autocmd!&#xA;    autocmd OptionSet wildignore,suffixes let s:currwin=winnr() |&#xA;            \ | execute &quot;windo if &amp;amp;ft=='netrw' | execute \&quot;normal \&amp;lt;C-L&amp;gt;\&quot; | endif&quot;&#xA;            \ | execute s:currwin . 'wincmd w'&#xA;  augroup END&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-08-07T06:16:53.020" LastActivityDate="2018-08-07T06:16:53.020" Title="Do nothing in :windo if condition does not apply" Tags="|vimscript|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17011" PostTypeId="1" AcceptedAnswerId="17016" CreationDate="2018-08-06T10:12:02.237" Score="7" ViewCount="1860" Body="&lt;p&gt;Is there a way to programmatically check if Vim is currently in the recording mode triggered by &lt;kbd&gt;q&lt;/kbd&gt;?&lt;/p&gt;&#xA;" OwnerUserId="18254" LastEditorUserId="927" LastEditDate="2018-08-07T02:07:59.683" LastActivityDate="2018-08-07T02:07:59.683" Title="How do I check if Vim is currently recording a macro?" Tags="|vimscript|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17012" PostTypeId="1" CreationDate="2018-08-06T11:27:51.303" Score="1" ViewCount="892" Body="&lt;h1&gt;My Problem&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I am editing a markdown file with some links in a &lt;code&gt;[link text](url)&lt;/code&gt; format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of these links lack a space after the closing parens, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...fit the [Single Responsibility Principle](https://link...)and can ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which renders to a missing space after the link:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...fit the &lt;a href=&quot;https://link...&quot; rel=&quot;nofollow noreferrer&quot;&gt;Single Responsibility Principle&lt;/a&gt;and can ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I am trying to build a regex search-replace to add a missing space after the closing parens where necessary.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;What have I (naively) tried&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Tried search-replacing with a regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s#\)(\S)#\) (\1)#gc&#xA;&#xA;%s#\)                 - Closing parens&#xA;%s#\)(\S)             - Followed by a non-space&#xA;%s#\)(\S)#            - Replaced with...&#xA;%s#\)(\S)#\)          - The closing parens followed by a space&#xA;%s#\)(\S)#\) (\1)#gc  - And the original character&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And, of course, Googled the problem.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;My question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I add a space after every closing parens that has a non-space character just after it?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="13179" LastActivityDate="2019-09-04T04:05:55.787" Title="Add space after parens" Tags="|regular-expression|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17013" PostTypeId="2" ParentId="17011" CreationDate="2018-08-06T11:33:56.860" Score="4" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; I wasn't aware of &lt;code&gt;reg_recording()&lt;/code&gt; but if you have a newer version of Vim Luc's answer is clearly the best answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not aware of a built-in way to check if Vim is recording but you could use the following workaround in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:isRecording = get(g:, 'isRecording', 0)&#xA;nnoremap q :let g:isRecording = !g:isRecording&amp;lt;CR&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first line will create a global variable &lt;code&gt;g:isRecording&lt;/code&gt; which is falsy by default or takes its existing value if you re-source your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you remap &lt;kbd&gt;q&lt;/kbd&gt; to toggle the value of &lt;code&gt;g:isRecording&lt;/code&gt; when it toggles the recording mode and you can then test &lt;code&gt;g:isRecording&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's not the most elegant solution but as &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#recording&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h recording&lt;/code&gt;&lt;/a&gt; doesn't seem to mention a variable which would change with &lt;kbd&gt;q&lt;/kbd&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-events&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h autocmd-events&lt;/code&gt;&lt;/a&gt; doesn't mention an event related to recording, I guess that the easiest way to do.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-08-06T13:32:58.597" LastActivityDate="2018-08-06T13:32:58.597" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17014" PostTypeId="2" ParentId="17012" CreationDate="2018-08-06T11:37:26.237" Score="1" Body="&lt;p&gt;What about&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s#)\zs\ze\S# #g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By default unless you change the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27magic%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'magic'&lt;/code&gt;&lt;/a&gt; option, a closing parenthesis is matched by just &lt;code&gt;)&lt;/code&gt;. BTW, here I've cheated with &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5czs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\zs&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5cze&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\ze&lt;/code&gt;&lt;/a&gt; to mark the in between characters that we want to expand with a single space.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-08-06T11:37:26.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17015" PostTypeId="2" ParentId="17012" CreationDate="2018-08-06T11:41:49.977" Score="0" Body="&lt;p&gt;Try these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# match ) followed by zero or more spaces and replace with ) and space&#xA;s/) */) /&#xA;&#xA;# match ) followed by optional space and replace with ) and space&#xA;s/) \?/) /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;)&lt;/code&gt; is not escaped here, because by default &lt;code&gt;(&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt; are not special&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add &lt;code&gt;g&lt;/code&gt; flag if you need to replace multiple occurrences in a line&lt;/p&gt;&#xA;" OwnerUserId="1616" LastActivityDate="2018-08-06T11:41:49.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17016" PostTypeId="2" ParentId="17011" CreationDate="2018-08-06T12:06:19.247" Score="15" Body="&lt;p&gt;Since Vim 8.1-0020, there is a &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#reg_recording%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;reg_recording()&lt;/code&gt;&lt;/a&gt; function that'll return the name of the current register being recorded. An empty string is returned if we are not recording.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-08-06T12:06:19.247" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17018" PostTypeId="2" ParentId="14996" CreationDate="2018-08-06T14:01:05.363" Score="7" Body="&lt;p&gt;B Layer's solution works. Another option: Since TODOs are often in comments, if you want the TODO to end up having the same highlighting as regular comments, you can do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:hi link Todo Comment&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="18484" LastActivityDate="2018-08-06T14:01:05.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17019" PostTypeId="1" AcceptedAnswerId="17021" CreationDate="2018-08-06T15:05:53.800" Score="6" ViewCount="335" Body="&lt;p&gt;I've noticed this only on long running vims in my Linux server. I've narrowed down the E484s to lines of my vimscript that call &lt;code&gt;system&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just wonder if there is a way to deal with this because so far i have just been closing and restarting vim if this happens. But since the problem is so specific, it would be nice if it could be addressed so i can continue to use the running instance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's tricky to test and iterate on this because it takes at least 3 weeks before a vim instance gets into this state. &lt;/p&gt;&#xA;" OwnerUserId="390" LastActivityDate="2018-08-06T21:00:56.567" Title="In Linux, on an extremely long running vim session, calls to system() fail with E484 &quot;can't open file /tmp/&lt;tempfile&gt;&quot;" Tags="|linux|error|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17020" PostTypeId="2" ParentId="17009" CreationDate="2018-08-06T16:11:06.833" Score="1" Body="&lt;p&gt;If you want to redraw only if there is a netrw windows, instead, I'd &lt;code&gt;filter()&lt;/code&gt; the windows (&lt;code&gt;range(1, winnr('$'))&lt;/code&gt;) with a &lt;code&gt;getwinvar(v:val, &quot;&amp;amp;ft&quot;) == &quot;netrw&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !empty(&#xA;\     filter(&#xA;\       range(1, winnr('$')),&#xA;\       'getwinvar(v:val, &quot;&amp;amp;ft&quot;) == &quot;netrw&quot; &amp;amp;&amp;amp; .......'&#xA;\   ))&#xA;   redraw&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, no need to remember the current window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Given the need to execute &lt;code&gt;&amp;lt;Plug&amp;gt;NetrwRefresh&lt;/code&gt; in the netrw window, it becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let netrw_win = filter(&#xA;\       range(1, winnr('$')),&#xA;\       'getwinvar(v:val, &quot;&amp;amp;ft&quot;) == &quot;netrw&quot; &amp;amp;&amp;amp; .......'&#xA;\   )&#xA;&quot; a for loop may be a better choice in case there are several netrw windows&#xA;if !empty(netrw_win)&#xA;    let crt_win = winnr()&#xA;    try&#xA;        &quot; I'm not sure about the quotes in the next line&#xA;        execute netrw_win[0] . &quot;windo normal \&amp;lt;Plug&amp;gt;NetrwRefresh&quot;&#xA;    finally&#xA;        execute crt_win . 'wincmd w'&#xA;    endtry&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Given the complexity, it'd be best to put that code into a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: another advantage of such solutions: it'll trigger less events.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-08-06T16:38:10.177" LastActivityDate="2018-08-06T16:38:10.177" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17021" PostTypeId="2" ParentId="17019" CreationDate="2018-08-06T16:42:54.250" Score="8" Body="&lt;p&gt;This happens when some system cron job cleans out &quot;unused&quot; files from /tmp. The solutions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Find that cron job and stop it from rm'ing your Vim /tmp files.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Recreate Vim's temporary directory.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Given the temporary directory name from the error message, you can recreate the directory manually with &quot;!mkdir &amp;lt;dirname&amp;gt;&quot;, or you can use this command which you can put in your ~/.vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Mktmpdir call mkdir(fnamemodify(tempname(),&quot;:p:h&quot;),&quot;&quot;,0700)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That command was contributed to the vim_use list by Ben Schmidt.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="2055" LastEditDate="2018-08-06T21:00:56.567" LastActivityDate="2018-08-06T21:00:56.567" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17022" PostTypeId="1" CreationDate="2018-08-06T21:51:42.230" Score="0" ViewCount="877" Body="&lt;p&gt;By simply calling &lt;code&gt;:(range)g/bob/norm Axxx&lt;/code&gt; I can add &lt;code&gt;xxx&lt;/code&gt; to the to the end of all lines in &lt;code&gt;range&lt;/code&gt; containing &lt;code&gt;bob&lt;/code&gt;. Is there a way to return to normal mode after having used A/I/a/i to enter insert  mode, all within a command, in order to perform more actions to the matching lines without starting another command?&lt;/p&gt;&#xA;" OwnerUserId="17655" LastActivityDate="2018-10-08T12:00:54.183" Title="Is it possible to return to normal mode in the middle of a vim command?" Tags="|regular-expression|visual-mode|replace|range|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17024" PostTypeId="1" AcceptedAnswerId="17026" CreationDate="2018-08-06T22:34:40.107" Score="0" ViewCount="62" Body="&lt;p&gt;If I wanted to start recording a macro using command-line mode, how would I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, if I wanted to bind this action to a key, how would I do that in my &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2018-08-07T03:20:33.697" Title="How to start recording a macro, using commandline mode?" Tags="|vimrc|key-bindings|command-line|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17025" PostTypeId="1" AcceptedAnswerId="17028" CreationDate="2018-08-06T23:15:34.400" Score="2" ViewCount="982" Body="&lt;p&gt;In visual mode, how do I bind a key so that the selected text generates &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/&amp;lt;SELECTEDTEXT&amp;gt;/&amp;lt;CURSORHERE&amp;gt;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;?&#xA;Preferably &lt;code&gt;;&lt;/code&gt; considering I never use it otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2018-08-07T05:52:55.290" Title="In visual mode, how do I bind a key so that the selected text generates &quot;%s/&lt;SELECTEDTEXT&gt;/&lt;CURSORHERE&gt;/g&quot;?" Tags="|vimrc|key-bindings|command-line|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17026" PostTypeId="2" ParentId="17024" CreationDate="2018-08-07T03:20:33.697" Score="1" Body="&lt;p&gt;For the first question&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:normal! qa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That would start recording a macro to the &quot;a&quot; register. You may change that to any lower case letter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To map F3 to it, for example, you could use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F3&amp;gt; :normal! qz&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10482" LastActivityDate="2018-08-07T03:20:33.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17028" PostTypeId="2" ParentId="17025" CreationDate="2018-08-07T05:07:36.517" Score="2" Body="&lt;pre&gt;&lt;code&gt;xnoremap ; y&amp;lt;Esc&amp;gt;:%s/&amp;lt;C-R&amp;gt;&quot;//g&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;xnoremap&lt;/code&gt; visual mode mapping, non-recursive&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vnoremap&lt;/code&gt; includes select mode as well, see &lt;a href=&quot;https://vi.stackexchange.com/questions/4891/what-is-the-select-mode-and-when-is-it-relevant-to-use-it&quot;&gt;What is the select mode and when is it relevant to use it?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;&lt;/code&gt; key to be mapped&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt; yank the selected text&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; visual mode to normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s/&lt;/code&gt; substitute command, all lines as range&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-R&amp;gt;&quot;&lt;/code&gt; paste contents of selected text&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;//g&lt;/code&gt; rest of substitute command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&lt;/code&gt; move cursor to the left twice&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1616" LastEditorUserId="1616" LastEditDate="2018-08-07T05:52:55.290" LastActivityDate="2018-08-07T05:52:55.290" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17029" PostTypeId="1" CreationDate="2018-08-07T09:32:42.280" Score="1" ViewCount="1364" Body="&lt;p&gt;I just switched to iTerm2 on macOS and found some of its options go to Vim as well. That's the case for fonts, I was able to select a Vim font that I like from iTerm options. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems iTerm color options also apply to Vim highligh. But in this case highlight situation is not good enogh for my taste. So I tried to change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi Comment ctermfg=gray&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Changes font color of comments. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to change &lt;code&gt;=&lt;/code&gt;, &lt;code&gt;::&lt;/code&gt;, &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt; color, I think these are Operators, so I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi Operator ctermfg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it seems nothing changes. How should I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it matters I'm playing with .cpp/.h files.&lt;/p&gt;&#xA;" OwnerUserId="18250" LastActivityDate="2018-08-08T08:58:08.040" Title="How to change Operator highlight color in Vim?" Tags="|syntax-highlighting|colorscheme|highlight|filetype-c++|color|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17030" PostTypeId="1" AcceptedAnswerId="17034" CreationDate="2018-08-07T10:46:33.707" Score="3" ViewCount="505" Body="&lt;p&gt;I want the indentation in markdown file as follows &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; - [ ] Here is some text. When I press enter&#xA; - [ ] &amp;lt;--- This entire thing should get populated. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It means &lt;code&gt;- [ ]&lt;/code&gt; should be copied onto the next line. I have tried setting comments variable in vim to accommodate the indentation for the same. I have tried installing multiple markdown plugins, but they don't seem to fix the indentation issue. Is there anyway we could do this ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also be great if someone knows a plugin which could accomplish this too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:-&lt;/strong&gt; It should also work for nested lists as well.&lt;/p&gt;&#xA;" OwnerUserId="18499" LastActivityDate="2018-08-07T12:33:45.047" Title="vim specific indentation for markdown" Tags="|comments|filetype-markdown|plugin-vim-autoformat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17031" PostTypeId="2" ParentId="17029" CreationDate="2018-08-07T11:21:23.077" Score="4" Body="&lt;p&gt;It indeed looks like &lt;code&gt;cppOperator&lt;/code&gt; links to &lt;code&gt;Operator&lt;/code&gt; which links to &lt;code&gt;Statement&lt;/code&gt; (-&gt; &lt;code&gt;:hi cppOperator&lt;/code&gt;), but I've never seen these operators displayed differently...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's just for the keywords. See &lt;code&gt;syn list cppOperator&lt;/code&gt;. I guess you'd have to add these symbols to the &lt;code&gt;cppOperator&lt;/code&gt; list. You may need a &lt;code&gt;syn match&lt;/code&gt; that takes care of not overlapping with &lt;code&gt;cFloat&lt;/code&gt; and some other syntax groups. Indeed, if we look closely at &lt;code&gt;$VIMRUNTIME/syntax/c.vim&lt;/code&gt; we see that &lt;code&gt;cFloat&lt;/code&gt; can match &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;-&lt;/code&gt; in the possible patterns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's experiment on&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;42 + 12;&#xA;42 foobar 12;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:syn keyword cOperator +&lt;/code&gt; has no visible effect&lt;/li&gt;&#xA;&lt;li&gt;yet &lt;code&gt;:syn keyword cOperator foobar&lt;/code&gt; has a visible effect =&gt; &lt;code&gt;syn keyword&lt;/code&gt; is not what we're looking for&lt;/li&gt;&#xA;&lt;li&gt;however &lt;code&gt;:syn match cOperator &quot;+&quot;&lt;/code&gt; has the effect we are looking for: now we have a match for &lt;code&gt;+&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;better yet, we can have &lt;code&gt;:syn match cOperator &quot;[+/*%^&amp;amp;|&amp;lt;&amp;gt;-]&quot;&lt;/code&gt;, we can observe:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;there is no interaction with &lt;code&gt;cFloat&lt;/code&gt;: check &lt;code&gt;12 * 1e-1&lt;/code&gt; -- my fears were unfounded&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;pointers and addresses will also be highlighted -- excluding these cases will require more tweaking.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void * p = &amp;amp;var;&#xA;12 * *p;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Notes: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Before the modification, the operators belonged to &lt;code&gt;cBlock&lt;/code&gt;, now they belong to &lt;code&gt;cOperator&lt;/code&gt;. We can change the highlighting of &lt;code&gt;Operator&lt;/code&gt;, it will now also affect these operators.&lt;/li&gt;&#xA;&lt;li&gt;Put the new &lt;code&gt;:syn...&lt;/code&gt; commands into &lt;code&gt;{rtp}/syntax/c/c-highlight-operator.vim&lt;/code&gt; for instance. -- by &lt;code&gt;{rtp}&lt;/code&gt;, understand any path in your &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27rtp%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'rtp'&lt;/code&gt;&lt;/a&gt; option.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-08-08T08:58:08.040" LastActivityDate="2018-08-08T08:58:08.040" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17032" PostTypeId="1" CreationDate="2018-08-07T11:46:07.900" Score="1" ViewCount="44" Body="&lt;p&gt;I OCRed a document but has this problem: some spaces between &quot;of&quot; and the word after are gone and I need to add a space between &quot;of&quot; and &quot;word&quot;. Is there any way to do it? And also to avoid adding space after of in the words such as offer, off, often, office etc which start with &quot;of&quot;.&lt;/p&gt;&#xA;" OwnerUserId="18501" LastEditorUserId="18501" LastEditDate="2018-08-07T12:33:25.343" LastActivityDate="2018-08-07T12:33:25.343" Title="change ofWord to of Word, and ignore offer, office, off etc" Tags="|search|replace|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17034" PostTypeId="2" ParentId="17030" CreationDate="2018-08-07T12:21:52.033" Score="3" Body="&lt;p&gt;A plugin that will accomplish what you are looking for is &lt;a href=&quot;https://github.com/jceb/vim-orgmode&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-orgmode&lt;/a&gt;. This will let you check and uncheck boxes in a convenient way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also be able to achieve (most of) the functionality in question using Vim comments. Try clearing your comment settings if necessary&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set comments=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatoptions+=cro&#xA;:set comments+=:-\ [\ ] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the backslashes before the spaces, which you were probably missing. This will handle nested lists automatically based on the indent.&lt;/p&gt;&#xA;" OwnerUserId="13731" LastEditorUserId="13731" LastEditDate="2018-08-07T12:33:45.047" LastActivityDate="2018-08-07T12:33:45.047" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17035" PostTypeId="1" CreationDate="2018-08-07T14:37:03.157" Score="0" ViewCount="442" Body="&lt;p&gt;I created below mappings for delete/change inner word for &quot;/&quot; and &quot;,&quot; and the mappings work just fine, however the side effect is that it makes the normal dd/cc commands slow, almost approx by 1 sec. Below are my mappins&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap ci/ f/cT/ &#xA;noremap di/ f/dT/ &#xA;&#xA;noremap ci, f,cT, &#xA;noremap di, f,dT, &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And i kind of expected this because creating a mapping that starts with c/d which are already bound some other vim commands vim waits to check the key pressed after c/d. So what am i missing here, can this be fixed anyhow ?&lt;/p&gt;&#xA;" OwnerUserId="18373" LastActivityDate="2018-08-08T07:32:21.833" Title="dd/cc command getting slow after custom mappings" Tags="|neovim|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17037" PostTypeId="2" ParentId="17022" CreationDate="2018-08-08T01:51:09.923" Score="1" Body="&lt;p&gt;Let's say that we're using the global command to surround each matching line with brackets. (&lt;em&gt;This is not really a good way to bracket text. It's just for illustration here.&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You hinted at maybe inserting an &lt;kbd&gt;Esc&lt;/kbd&gt; somewhere in there. Perhaps like this... &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/bob/ norm! A}&amp;lt;ESC&amp;gt;I{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that approach won't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Others might have a first instinct to try something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/bob/ norm! A} | norm! I{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alas, this won't work either. Both these cases see everything after the opening &lt;code&gt;A&lt;/code&gt; as text to be appended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Digging deeper into the second approach, if we look at &lt;code&gt;:h :norm&lt;/code&gt; we'll find the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This command cannot be followed by another command, since any '|' is considered part of the command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Fortunately we can get around this by embedding that first &lt;code&gt;:norm&lt;/code&gt; command in an &lt;code&gt;execute&lt;/code&gt; call (&lt;code&gt;:h :exe&lt;/code&gt;)...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/bob/ exe &quot;norm! A}&quot; | norm! I{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That does the trick. Using &lt;code&gt;:exe&lt;/code&gt; allows us to implicitly signal the end of the first &lt;code&gt;:norm&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this is a generally applicable solution that answers the question &quot;How do I follow &lt;code&gt;:norm&lt;/code&gt; with another command?&quot;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-08-09T09:12:19.287" LastActivityDate="2018-08-09T09:12:19.287" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17038" PostTypeId="2" ParentId="17035" CreationDate="2018-08-08T07:32:21.833" Score="1" Body="&lt;p&gt;I changed the mapping from noremap to nnoremap and it worked for me.&lt;/p&gt;&#xA;" OwnerUserId="18373" LastActivityDate="2018-08-08T07:32:21.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17039" PostTypeId="1" AcceptedAnswerId="17040" CreationDate="2018-08-08T08:49:00.120" Score="0" ViewCount="239" Body="&lt;p&gt;The cursor is on line 20. After pressing &lt;code&gt;o&lt;/code&gt; the cursor (here depicted with a &lt;code&gt;|&lt;/code&gt;) is placed below the &lt;code&gt;e&lt;/code&gt; of &lt;code&gt;ext&lt;/code&gt; as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;18 # set default extension&#xA;19 if [ -z &quot;$2&quot; ]; then&#xA;20   ext='pdf'&#xA;     |&#xA;21 else&#xA;22   ext=&quot;$2&quot;&#xA;23 fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I now type a &lt;code&gt;#&lt;/code&gt;, it is placed at the beginning of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;18 # set default extension&#xA;19 if [ -z &quot;$2&quot; ]; then&#xA;20   ext='pdf'&#xA;   #|&#xA;21 else&#xA;22   ext=&quot;$2&quot;&#xA;23 fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but expected is below the &lt;code&gt;e&lt;/code&gt; of &lt;code&gt;ext&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;18 # set default extension&#xA;19 if [ -z &quot;$2&quot; ]; then&#xA;20   ext='pdf'&#xA;     #|&#xA;21 else&#xA;22   ext=&quot;$2&quot;&#xA;23 fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;comments&lt;/code&gt; are&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:&amp;gt;,fb:-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b:#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be responsible for indent-aware comment repetition, but apparently the whitespace indentation (two blanks) is not recognized as such.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same happens for me in Python files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are related settings in &lt;code&gt;.vimrc&lt;/code&gt; (A &lt;code&gt;.vimrc&lt;/code&gt; containing just these lines should reproduce the problem):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoindent&#xA;set expandtab&#xA;set shiftwidth=2&#xA;set smartindent&#xA;set smarttab&#xA;set softtabstop=2&#xA;set tabstop=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, &lt;code&gt;set autoindent&lt;/code&gt; should produce the expected behavior, but does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a bug or a feature? :-)&lt;/p&gt;&#xA;" OwnerUserId="18342" LastActivityDate="2018-08-08T09:13:53.233" Title="Comment character is not auto-indented in Bash and Python scripts" Tags="|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17040" PostTypeId="2" ParentId="17039" CreationDate="2018-08-08T09:13:53.233" Score="1" Body="&lt;p&gt;I suppose your problem comes from setting 'smartindent'. The help has a short &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;smartindent&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;explanation on your problem&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When typing '#' as the first character in a new line, the indent for&#xA;  that line is removed, the '#' is put in the first column.  The indent&#xA;  is restored for the next line.  If you don't want this, use this&#xA;  mapping: &quot;:inoremap # X^H#&quot;, where ^H is entered with CTRL-V CTRL-H.&#xA;  When using the &quot;&gt;&gt;&quot; command, lines starting with '#' are not shifted&#xA;  right.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I believe this comes from the fact, that the '#' in the C language denotes a &lt;a href=&quot;https://en.wikipedia.org/wiki/C_preprocessor&quot; rel=&quot;nofollow noreferrer&quot;&gt;pre-processor statement&lt;/a&gt; (macro like), however that is only valid if it starts at the beginning of a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since Vim patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v7.4.069&quot; rel=&quot;nofollow noreferrer&quot;&gt;7.4.069&lt;/a&gt;, this behaviour has been slightly adjusted with the &lt;a href=&quot;http://vimhelp.appspot.com/indent.txt.html#cino-#&quot; rel=&quot;nofollow noreferrer&quot;&gt;'cino-#'&lt;/a&gt; option value for C-indenting which allows to shift '#' comment lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general however, I would not recommend going with either &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;smartindent&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;'smartindent'&lt;/a&gt; (which is not so smart) or &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;autoindent&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;'autoindent'&lt;/a&gt;. Instead, I recommend using filetype specific indenting which is enabled using &lt;code&gt;:filetype plugin indent on&lt;/code&gt; (see &lt;a href=&quot;http://vimhelp.appspot.com/filetype.txt.html#%3Afiletype&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :filetype&lt;/code&gt;&lt;/a&gt;) in your vimrc and uses indenting specific for the filetype you are editing (which often is a custom 'indentexpr' function, but can also be C like indenting, autoindent or anything else).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-08-08T09:13:53.233" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17041" PostTypeId="1" CreationDate="2018-08-08T11:12:12.527" Score="1" ViewCount="3584" Body="&lt;p&gt;I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;ScrollWheelUp&amp;gt; k&#xA;nnoremap &amp;lt;S-ScrollWheelUp&amp;gt; k&#xA;nnoremap &amp;lt;C-ScrollWheelUp&amp;gt; k&#xA;nnoremap &amp;lt;ScrollWheelDown&amp;gt; j&#xA;nnoremap &amp;lt;S-ScrollWheelDown&amp;gt; j&#xA;nnoremap &amp;lt;C-ScrollWheelDown&amp;gt; j&#xA;inoremap &amp;lt;ScrollWheelUp&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-y&amp;gt;&#xA;inoremap &amp;lt;S-ScrollWheelUp&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-y&amp;gt;&#xA;inoremap &amp;lt;C-ScrollWheelUp&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-y&amp;gt;&#xA;inoremap &amp;lt;ScrollWheelDown&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-e&amp;gt;&#xA;inoremap &amp;lt;S-ScrollWheelDown&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-e&amp;gt;&#xA;inoremap &amp;lt;C-ScrollWheelDown&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-e&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this works on iTerm but doesn't overwrite the default scroll behavior (applying my maps but still applies the default behaviors which is scrolling 3 lines up/down). I tried on macvim and that successfully replaced the default behavior.&lt;/p&gt;&#xA;" OwnerUserId="18254" LastEditorUserId="205" LastEditDate="2018-08-08T14:42:46.783" LastActivityDate="2019-05-06T12:03:00.597" Title="How to disable default mouse wheel behavior in iTerm?" Tags="|scrolling|mouse|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17042" PostTypeId="1" AcceptedAnswerId="17043" CreationDate="2018-08-08T12:20:34.760" Score="0" ViewCount="360" Body="&lt;p&gt;I'm playing with Vim highlight, so I made the following (&lt;code&gt;syntax.vim&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Comment ctermfg=DarkGray&#xA;hi LineNR ctermfg=DarkGray&#xA;hi CursorLineNR ctermfg=Red&#xA;hi String ctermfg=Gray&#xA;hi PreProc ctermfg=Brown&#xA;&#xA;syn match MyOp /+/&#xA;syn match MyOp /-/&#xA;syn match MyOp /*/  containedin=comment contained&#xA;syn match MyOp /\// containedin=comment contained&#xA;syn match MyOp /&amp;amp;/&#xA;syn match MyOp /:/&#xA;syn match MyOp /\./&#xA;syn match MyOp /=/&#xA;hi MyOp ctermfg=LightBlue&#xA;&#xA;syn match MyBrakets /&amp;lt;/&#xA;syn match MyBrakets /&amp;gt;/&#xA;syn match MyBrakets /(/&#xA;syn match MyBrakets /)/&#xA;syn match MyBrakets /{/&#xA;syn match MyBrakets /}/&#xA;syn match MyBrakets /\[/&#xA;syn match MyBrakets /\]/&#xA;hi MyBrakets ctermfg=Yellow&#xA;&#xA;syn keyword MyNSutl utl &#xA;hi MyNSutl ctermfg=Gray&#xA;&#xA;syn keyword MyNSmmi mmi&#xA;hi MyNSmmi ctermfg=DarkBlue&#xA;&#xA;syn match MySend /send_\w*/&#xA;hi MySend ctermfg=Red&#xA;&#xA;syn match MyGet /get_\w*/&#xA;hi MyGet ctermfg=Magenta&#xA;&#xA;syn match MyPrint /print_\w*/&#xA;hi MyPrint ctermfg=Gray&#xA;&#xA;syn match MyMPI /MPI_\w*/&#xA;hi MyMPI ctermfg=LightGray&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was testing it with a single file, while in Vim with my .cpp file open I did &lt;code&gt;so syntax.vim&lt;/code&gt; and the magic happened. So far so good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next step was to use it in the session I was working, &lt;code&gt;Vim -S session.vim&lt;/code&gt; to open some files in split view, and &lt;code&gt;so syntax.vim&lt;/code&gt;. Problem. Syntax applies to just one file, current split. So I have to repeat that to all files -  not good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some googling I found that correct way to proceed was to rename it to i.e. &lt;code&gt;cpp_my.vim&lt;/code&gt; and put in ~/.vim/ftplugin/myplugin/. Did that, and it workds partially, some settings don't get applied. Then I went to Vim doc section 41.11 Writing a plugin. Things are getting complicated and here I'm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hack I did isn't general purpose, its just for the project I'm working these days. So making it a plugin don't smell good to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in order to use it, the best approach is to manually &lt;code&gt;so syntax.vim&lt;/code&gt; to each file? Or is there some clever alternative?&lt;/p&gt;&#xA;" OwnerUserId="18250" LastActivityDate="2018-08-10T09:05:20.520" Title="How to apply a custom highlight file?" Tags="|vimrc|vimscript|syntax-highlighting|highlight|macvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17043" PostTypeId="2" ParentId="17042" CreationDate="2018-08-08T12:49:31.743" Score="1" Body="&lt;p&gt;The correct way is to drop the file in &lt;code&gt;{rtp}/syntax/{ft}.vim&lt;/code&gt;. Given the proximity between C and C++, I'd say in &lt;code&gt;$HOME/.vim/after/syntax/c.vim&lt;/code&gt; -- in &lt;code&gt;after/&lt;/code&gt; to be sure to source the standard configuration before the &lt;em&gt;improvements&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: IIRC my experiments, the less &lt;code&gt;syn match&lt;/code&gt; you have, the fastest highlighting will be. &lt;code&gt;match&lt;/code&gt; is made to support regexes, you can then merge several of your single character patterns into a single pattern =&gt; &lt;code&gt;&quot;[+=^&amp;amp;~&amp;lt;&amp;gt;:-]&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-08-10T09:05:20.520" LastActivityDate="2018-08-10T09:05:20.520" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17044" PostTypeId="1" CreationDate="2018-08-08T18:30:23.947" Score="3" ViewCount="606" Body="&lt;p&gt;I want all my folds to be expanded when I open a LaTeX file. As per web search I added the following at the end of .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nofoldenable&#xA;set foldlevelstart=99&#xA;set foldlevel=99&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But even now its folding. I also added this is to my &lt;code&gt;ftplugin/tex.vim&lt;/code&gt; but the results are the same. I am also using the plugin &lt;code&gt;vim-latex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea on how to fix/ debug this problem?&lt;/p&gt;&#xA;" OwnerUserId="18524" LastEditorUserId="1841" LastEditDate="2018-11-13T17:10:35.010" LastActivityDate="2019-08-10T20:01:35.223" Title="Expand all folds created by vim-latex when opening a LaTeX file" Tags="|folding|plugin-vim-latex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17045" PostTypeId="1" AcceptedAnswerId="17046" CreationDate="2018-08-09T08:41:47.197" Score="0" ViewCount="603" Body="&lt;p&gt;I'm trying to disable &lt;code&gt;autochdir&lt;/code&gt; in &lt;code&gt;nvim&lt;/code&gt; by adding the following in &lt;code&gt;init.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autochdir!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when I start &lt;code&gt;nvim&lt;/code&gt;, I check the value of this option by &lt;code&gt;echo &amp;amp;autochdir&lt;/code&gt; and find it equals to &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I though it may be overwritten by &lt;code&gt;Python filetype&lt;/code&gt; as mentioned these two posts (&lt;a href=&quot;https://vi.stackexchange.com/questions/13537/why-is-set-noexpandtab-in-my-vimrc-ignored-when-i-open-a-file/13538#13538&quot;&gt;Why is “set noexpandtab” in my ~/.vimrc ignored when I open a file?&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/8382/vim-displaying-incorrect-indentation&quot;&gt;Vim displaying incorrect indentation&lt;/a&gt;).So I tried adding the following to my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup python&#xA;    autocmd!&#xA;    autocmd FileType python set autochdir!&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it doesn't solve the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this option overwritten and how can I force it?&lt;/p&gt;&#xA;" OwnerUserId="16800" LastEditorUserId="16800" LastEditDate="2018-08-09T08:52:24.623" LastActivityDate="2018-08-09T09:20:38.730" Title="Option set in vimrc is overwritten - nvim" Tags="|vimrc|neovim|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17046" PostTypeId="2" ParentId="17045" CreationDate="2018-08-09T09:20:38.730" Score="1" Body="&lt;p&gt;Something funny is going on here. If you want to disable the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;autochdir&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;'autochdir'&lt;/a&gt;, use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set noautochdir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use the the &lt;code&gt;!&lt;/code&gt;, this means it basically toggles the option. So whenever you happen to resource your .vimrc (or init.vim) file it silently toggles the value, which might be unexpected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you read the help for that setting, it clearly indicates this option is off by default. So you can also just skip the whole command at all ;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup python&#xA;    autocmd!&#xA;    autocmd FileType python set autochdir!&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Secondly your autocommand may work fine and disable the autochdir. Sadly, this might come to late so that Nvim already switched to the specified directory and only afterwards it turns off the setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can always check the option value when it was set and by what script by using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set autochdir?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In general I would always recommend to either leave this global option off, or on. But do not toggle it often within a session. It might be confusing, but your mileage may vary.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-08-09T09:20:38.730" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17047" PostTypeId="2" ParentId="17041" CreationDate="2018-08-09T09:47:00.680" Score="2" Body="&lt;p&gt;Found a workaround:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('gui_macvim')&#xA;&#xA;    nnoremap &amp;lt;ScrollWheelUp&amp;gt; 2k&#xA;    nnoremap &amp;lt;S-ScrollWheelUp&amp;gt; 2k&#xA;    nnoremap &amp;lt;C-ScrollWheelUp&amp;gt; 2k&#xA;    nnoremap &amp;lt;ScrollWheelDown&amp;gt; 2j&#xA;    nnoremap &amp;lt;S-ScrollWheelDown&amp;gt; 2j&#xA;    nnoremap &amp;lt;C-ScrollWheelDown&amp;gt; 2j&#xA;    inoremap &amp;lt;ScrollWheelUp&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-y&amp;gt;&#xA;    inoremap &amp;lt;S-ScrollWheelUp&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-y&amp;gt;&#xA;    inoremap &amp;lt;C-ScrollWheelUp&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-y&amp;gt;&#xA;    inoremap &amp;lt;ScrollWheelDown&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-e&amp;gt;&#xA;    inoremap &amp;lt;S-ScrollWheelDown&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-e&amp;gt;&#xA;    inoremap &amp;lt;C-ScrollWheelDown&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-e&amp;gt;&#xA;&#xA;&quot; how to check if vim is running on iTerm?&#xA;else&#xA;&#xA;    noremap &amp;lt;up&amp;gt; k&#xA;    noremap &amp;lt;down&amp;gt; j&#xA;    inoremap &amp;lt;up&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-y&amp;gt;&#xA;    inoremap &amp;lt;down&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-e&amp;gt;&#xA;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and 2 iTerm settings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Profiles &amp;gt; Terminal &amp;gt; Report mouse wheel events&lt;/code&gt; to false&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Advanced &amp;gt; Scroll wheel sends arrow keys when in alternate screen mode&lt;/code&gt; to true&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Makes iTerm works expectedly&lt;/p&gt;&#xA;" OwnerUserId="18254" LastActivityDate="2018-08-09T09:47:00.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17048" PostTypeId="1" CreationDate="2018-08-09T09:55:02.550" Score="1" ViewCount="380" Body="&lt;p&gt;I run Vim in terminal and it was keeping to override the background color using it's own, so I added this lines to my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight Normal ctermbg=NONE&#xA;highlight nonText ctermbg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and everything works fine except for the cursor line that is still using the color it was using with the overridden background which is barely visible. I've tried to add this line to .vimrc &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight CursorLine ctermbg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but what happen is that the line disappear completely. Is there a way to make Vim to use the color from the terminal theme instead of it's own to highlight the cursor line without type the color value in .vimrc which I should change with every new theme I will use?&lt;/p&gt;&#xA;" OwnerUserId="18533" LastActivityDate="2018-08-09T09:55:02.550" Title="Vim CursorLine default color" Tags="|cursorline|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17049" PostTypeId="2" ParentId="16957" CreationDate="2018-08-09T10:09:17.630" Score="2" Body="&lt;p&gt;Okay it looks like those logfiles have been changed since the last time I looked&#xA;at them (I remember some provider plugin to be particularly bad, but I do not&#xA;see it here now, which was the reason I suggested moving this to the neovim&#xA;bugtracker).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Okay, you need to figure out what makes start up so small. Here is an example&#xA;how I would proceed, note, you'll have to do the final work and analysis I am&#xA;not going to do that for your ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trying with the first startuptime logfile for the first session:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        clock   self+sourced   self:  sourced script&#xA;        clock   elapsed:              other lines&#xA;&#xA;    000.009  000.009: --- NVIM STARTING ---&#xA;    009.986  009.977: locale set&#xA;    018.750  008.764: inits 1&#xA;    018.764  000.014: window checked&#xA;    018.842  000.078: parsing arguments&#xA;    020.031  001.189: expanding arguments&#xA;    020.081  000.051: inits 2&#xA;    020.591  000.510: init highlight&#xA;    2162.962  446.040  446.040: sourcing /apps/nttech/rbhanot/.config/nvim/autoload/plug.vim&#xA;    4363.032  265.956  265.956: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/filetype.vim&#xA;    4374.207  000.761  000.761: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/ftplugin.vim&#xA;    4384.176  000.624  000.624: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/indent.vim&#xA;    4511.851  000.251  000.251: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/syntax/syncolor.vim&#xA;    4559.538  048.912  048.661: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/syntax/synload.vim&#xA;    4559.623  174.580  125.668: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/syntax/syntax.vim&#xA;    4719.856  019.373  019.373: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/custom.vim&#xA;    4818.131  095.671  095.671: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/util.vim&#xA;    4865.563  044.503  044.503: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/init.vim&#xA;    5553.428  086.264  086.264: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/configure.vim&#xA;    5625.453  068.322  068.322: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/config.vim&#xA;    5766.744  138.128  138.128: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/log.vim&#xA;    5880.082  023.316  023.316: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/core.vim&#xA;    5880.362  110.428  087.112: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/utils.vim&#xA;    5881.801  4591.203  3140.554: sourcing /apps/nttech/rbhanot/.config/nvim/plugins.vim&#xA;    6131.604  000.196  000.196: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/syntax/syncolor.vim&#xA;    6131.941  246.633  246.437: sourcing /apps/nttech/rbhanot/.config/nvim/settings.vim&#xA;    8233.645  2099.276  2099.276: sourcing /apps/nttech/rbhanot/.config/nvim/mappings.vim&#xA;    8667.321  000.210  000.210: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/syntax/syncolor.vim&#xA;    8667.962  000.184  000.184: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/syntax/syncolor.vim&#xA;    9128.201  057.730  057.730: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/onedark.vim/autoload/onedark.vim&#xA;    9143.354  893.845  835.721: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/onedark.vim/colors/onedark.vim&#xA;    9143.363  906.383  012.538: sourcing /apps/nttech/rbhanot/.config/nvim/colors.vim&#xA;    9143.367  9112.849  1269.354: sourcing /apps/nttech/rbhanot/.config/nvim/init.vim&#xA;    9143.370  009.931: sourcing vimrc file(s)&#xA;    9500.542  168.125  168.125: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete.vim&#xA;    9500.640  248.886  080.761: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/plugin/deoplete.vim&#xA;    9837.148  000.064  000.064: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/filetype.vim&#xA;    9837.393  000.032  000.032: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/ftplugin.vim&#xA;    9837.551  314.860  314.764: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/jedi-vim/plugin/jedi.vim&#xA;    10110.528  254.186  254.186: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/nerdcommenter/plugin/NERD_commenter.vim&#xA;    10327.254  138.892  138.892: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/ctrlp.vim/autoload/ctrlp/mrufiles.vim&#xA;    10327.400  178.883  039.991: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/ctrlp.vim/plugin/ctrlp.vim&#xA;    10448.190  101.616  101.616: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neoformat/plugin/neoformat.vim&#xA;    10758.798  197.868  197.868: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/plugin/neomake.vim&#xA;    10846.685  065.937  065.937: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/vim-highlightedyank/plugin/highlightedyank.vim&#xA;    12296.180  830.588  830.588: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/plugin/lightline.vim&#xA;    12300.560  002.324  002.324: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/gzip.vim&#xA;    12300.621  000.021  000.021: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/health.vim&#xA;    12300.702  000.055  000.055: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/man.vim&#xA;    12301.157  000.429  000.429: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/matchit.vim&#xA;    12301.336  000.151  000.151: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/matchparen.vim&#xA;    12301.754  000.390  000.390: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/netrwPlugin.vim&#xA;    12710.640  002.290  002.290: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/autoload/remote/host.vim&#xA;    12711.174  000.242  000.242: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/autoload/remote/define.vim&#xA;    12711.269  407.030  404.497: sourcing /apps/nttech/rbhanot/.local/share/nvim/rplugin.vim&#xA;    12711.279  409.492  002.462: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/rplugin.vim&#xA;    12711.429  000.110  000.110: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/rrhelper.vim&#xA;    12711.642  000.151  000.151: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/shada.vim&#xA;    12711.741  000.065  000.065: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/spellfile.vim&#xA;    12711.919  000.144  000.144: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/tarPlugin.vim&#xA;    12712.068  000.100  000.100: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/tohtml.vim&#xA;    12712.151  000.033  000.033: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/tutor.vim&#xA;    12712.329  000.149  000.149: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/plugin/zipPlugin.vim&#xA;    12712.341  962.533: loading plugins&#xA;    12712.501  000.161: loading packages&#xA;    12713.280  000.779: loading after plugins&#xA;    12713.289  000.008: inits 3&#xA;    13329.357  616.069: reading ShaDa&#xA;    13330.852  001.494: clearing screen&#xA;    13471.229  132.012  132.012: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake.vim&#xA;    13522.013  048.045  048.045: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/neomake/autoload/neomake/compat.vim&#xA;    13614.739  083.898  083.898: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/autoload/lightline.vim&#xA;    13726.571  100.799  100.799: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/autoload/lightline/tab.vim&#xA;    14180.150  201.807  201.807: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/autoload/lightline/colorscheme.vim&#xA;    14180.879  324.479  122.672: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/onedark.vim/autoload/lightline/colorscheme/onedark.vim&#xA;    14183.512  163.427: opening buffers&#xA;    14183.638  000.127: BufEnter autocommands&#xA;    14183.641  000.003: editing files in windows&#xA;    14194.265  002.221  002.221: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/autoload/provider/pythonx.vim&#xA;    14194.736  000.253  000.253: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/autoload/provider/python3.vim&#xA;    14201.950  000.095  000.095: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/autoload/provider.vim&#xA;    24842.491  422.066  422.066: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/mapping.vim&#xA;    25118.676  265.119  265.119: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/deoplete.nvim/autoload/deoplete/handler.vim&#xA;    25119.092  10245.697: VimEnter autocommands&#xA;    25122.433  003.006  003.006: sourcing /tmp/.mount_nvimPMuxUu/usr/share/nvim/runtime/autoload/provider/clipboard.vim&#xA;    25122.454  000.356: before starting main loop&#xA;    25123.773  001.319: first screen update&#xA;    25123.776  000.003: --- NVIM STARTED ---&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are a couple of things to notice here. First, looking at the path, it&#xA;looks like some of your runtime files are mounted. I hope not you are using a&#xA;remote filesystem, because just scanning those files may take longer than&#xA;expected. I used to have my $VIMRUNTIME environment on a samba share and that&#xA;made loading all those files really slow. So you might want to reconsider this&#xA;option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I see that syncolor.vim and filetype.vim is loaded several times. This&#xA;shouldn't be too bad, since there is a guard at that file, that should&#xA;preventing it from being loaded several times. But nevertheless this looks&#xA;suspicious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third, let's sort the startupfile logfile by the self time. Use visual mode and&#xA;select those lines with a leading number and use the following vim command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;sort! fr /^\s*[0-9.]\+\s\+[0-9.]\+\s\+\zs[0-9.]\+/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means, reverse sort by float numbers in the third column when there are&#xA;some. Check the help for the various flags and options of the&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Asort&quot; rel=&quot;nofollow noreferrer&quot;&gt;:sort&lt;/a&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will likely come up with a list like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    5881.801  4591.203  3140.554: sourcing /apps/nttech/rbhanot/.config/nvim/plugins.vim&#xA;    8233.645  2099.276  2099.276: sourcing /apps/nttech/rbhanot/.config/nvim/mappings.vim&#xA;    9143.367  9112.849 1269.354: sourcing /apps/nttech/rbhanot/.config/nvim/init.vim&#xA;    9143.354 893.845 835.721: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/onedark.vim/colors/onedark.vim&#xA;    12296.180  830.588  830.588: sourcing /apps/nttech/rbhanot/.config/nvim/plugged/lightline.vim/plugin/lightline.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means that your &lt;code&gt;plugins.vim&lt;/code&gt; file took 3 seconds to load, your&#xA;&lt;code&gt;mappings.vim&lt;/code&gt; file 2 seconds, your &lt;code&gt;init.vim&lt;/code&gt; file 1.2 seconds and the onedark&#xA;colorscheme almost a second and the lightline plugin also almost a second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now inspect your files:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;plugins.vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    call plug#begin('~/.config/nvim/plugged')&#xA;    Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins'}&#xA;    Plug 'zchee/deoplete-jedi', { 'do': ':UpdateRemotePlugins'  }&#xA;[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know Plug.vim very well, but it looks like it calls&#xA;&lt;code&gt;:UpdateRemotePlugins&lt;/code&gt; everytime and that twice. Do you really need to do this&#xA;every time?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[...]&#xA;    let g:deoplete#enable_at_startup = 1&#xA;    let g:deoplete#enable_ignore_case = 1&#xA;    let g:deoplete#enable_smart_case = 1&#xA;    let g:context_filetype#same_filetypes = {}&#xA;    let g:context_filetype#same_filetypes._ = '_'&#xA;    call neomake#configure#automake('nrwi', 200)&#xA;    [...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#autoload&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help autoload&lt;/code&gt;&lt;/a&gt;&#xA;syntax (foobar#variable) means, those plugins will be loaded. Is this really&#xA;needed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For mappings.vim I see nothing obvious which makes it so slow. You need to find&#xA;out by commenting one half out and check if this makes a difference. Do this&#xA;some kind of bisecting until you find the offending problematic part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, have a look at your lightline and onedark.vim plugin. Read the&#xA;documentation or try to find out (check the issue tracker) why those plugins are&#xA;slow and if it can be made faster. Most likely this will also mean, bisecting&#xA;different plugin settings and check if that makes a noticable difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to do this also with the startup logfile for the 3rd time, which looks&#xA;totally different. Not sure what could cause the difference here. So you need to&#xA;do the work your self.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And at last, let me give you a recommendation to always think whether you really&#xA;need all those plugins. As you have noticed they may slow down your startup time&#xA;down considerably. Perhaps you don't need to have them loaded each and every&#xA;time you start vim? Perhaps they can be loaded on demand using e.g. the&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%3Apackadd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:packadd&lt;/code&gt;&lt;/a&gt; command?&#xA;This is not an easy decision, but may well be worth it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Slow startuptime is usually a tricky problem, but no one except you can go through your own configuration files and check them.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-08-09T10:09:17.630" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17050" PostTypeId="1" AcceptedAnswerId="17051" CreationDate="2018-08-09T12:21:20.970" Score="0" ViewCount="33" Body="&lt;p&gt;Given code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;option id='Nicole' data-language='en-AU'&amp;gt;Australian English - female - Nicole&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Russell' data-language='en-AU'&amp;gt;Australian English - female - Russell&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Ricardo' data-language='pt-BR'&amp;gt;Brazilian Portuguese - female - Ricardo&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Vitoria' data-language='pt-BR'&amp;gt;Brazilian Portuguese - female - Vitória&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Amy' data-language='en-GB'&amp;gt;British English - female - Amy&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Brian' data-language='en-GB'&amp;gt;British English - female - Brian&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Emma' data-language='en-GB'&amp;gt;British English - female - Emma&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Chantal' data-language='fr-CA'&amp;gt;Canadian French - female - Chantal&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Conchita' data-language='es-ES'&amp;gt;Castilian Spanish - female - Conchita&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Enrique' data-language='es-ES'&amp;gt;Castilian Spanish - female - Enrique&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Mads' data-language='da-DK'&amp;gt;Danish - female - Mads&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Naja' data-language='da-DK'&amp;gt;Danish - female - Naja&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Lotte' data-language='nl-NL'&amp;gt;Dutch - female - Lotte&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Ruben' data-language='nl-NL'&amp;gt;Dutch - female - Ruben&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Celine' data-language='fr-FR'&amp;gt;French - female - Céline&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Lea' data-language='fr-FR'&amp;gt;French - female - Léa&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Mathieu' data-language='fr-FR'&amp;gt;French - female - Mathieu&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Hans' data-language='de-DE'&amp;gt;German - female - Hans&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Marlene' data-language='de-DE'&amp;gt;German - female - Marlene&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Vicki' data-language='de-DE'&amp;gt;German - female - Vicki&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Dora' data-language='is-IS'&amp;gt;Icelandic - female - Dóra&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Karl' data-language='is-IS'&amp;gt;Icelandic - female - Karl&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Aditi' data-language='en-IN'&amp;gt;Indian English - female - Aditi&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Raveena' data-language='en-IN'&amp;gt;Indian English - female - Raveena&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Carla' data-language='it-IT'&amp;gt;Italian - female - Carla&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Giorgio' data-language='it-IT'&amp;gt;Italian - female - Giorgio&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Mizuki' data-language='ja-JP'&amp;gt;Japanese - female - Mizuki&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Takumi' data-language='ja-JP'&amp;gt;Japanese - female - Takumi&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Seoyeon' data-language='ko-KR'&amp;gt;Korean - female - Seoyeon&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Liv' data-language='nb-NO'&amp;gt;Norwegian - female - Liv&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Ewa' data-language='pl-PL'&amp;gt;Polish - female - Ewa&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Jacek' data-language='pl-PL'&amp;gt;Polish - female - Jacek&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Jan' data-language='pl-PL'&amp;gt;Polish - female - Jan&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Maja' data-language='pl-PL'&amp;gt;Polish - female - Maja&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Cristiano' data-language='pt-PT'&amp;gt;Portuguese - female - Cristiano&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Ines' data-language='pt-PT'&amp;gt;Portuguese - female - Inês&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Carmen' data-language='ro-RO'&amp;gt;Romanian - female - Carmen&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Maxim' data-language='ru-RU'&amp;gt;Russian - female - Maxim&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Tatyana' data-language='ru-RU'&amp;gt;Russian - female - Tatyana&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Astrid' data-language='sv-SE'&amp;gt;Swedish - female - Astrid&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Filiz' data-language='tr-TR'&amp;gt;Turkish - female - Filiz&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Ivy' data-language='en-US'&amp;gt;US English - female - Ivy&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Joanna' data-language='en-US' selected&amp;gt;US English - female - Joanna&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Joey' data-language='en-US'&amp;gt;US English - female - Joey&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Justin' data-language='en-US'&amp;gt;US English - female - Justin&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Kendra' data-language='en-US'&amp;gt;US English - female - Kendra&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Kimberly' data-language='en-US'&amp;gt;US English - female - Kimberly&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Matthew' data-language='en-US'&amp;gt;US English - female - Matthew&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Salli' data-language='en-US'&amp;gt;US English - female - Salli&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Miguel' data-language='es-US'&amp;gt;US Spanish - female - Miguel&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Penelope' data-language='es-US'&amp;gt;US Spanish - female - Penélope&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Gwyneth' data-language='cy-GB'&amp;gt;Welsh - female - Gwyneth&amp;lt;/option&amp;gt;&#xA;&amp;lt;option id='Geraint' data-language='en-GB-WLS'&amp;gt;Welsh English - female - Geraint&amp;lt;/option&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to get this?&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/sFleM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sFleM.png&quot; alt=&quot;vim html formatting&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6038" LastActivityDate="2018-08-09T12:31:13.047" Title="Automatic format: how to insert needed amount of spaces for vertical aligning?" Tags="|formatting|filetype-html|" AnswerCount="1" CommentCount="1" ClosedDate="2018-08-09T12:32:29.650" ContentLicense="CC BY-SA 4.0" />
  <row Id="17051" PostTypeId="2" ParentId="17050" CreationDate="2018-08-09T12:31:13.047" Score="0" Body="&lt;p&gt;Try the &lt;a href=&quot;https://github.com/godlygeek/tabular&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tabular plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're going to need some kind of plugin for this. The tools Vim has natively are not powerful enough by themselves and not really powerful enough to create simple mappings. So you'll need some kind of scripting.&lt;/p&gt;&#xA;" OwnerUserId="13731" LastActivityDate="2018-08-09T12:31:13.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17052" PostTypeId="1" CreationDate="2018-08-09T17:32:09.540" Score="1" ViewCount="53" Body="&lt;p&gt;For example suppose i have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 the cat jumps&#xA;2 over the moon&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like the result &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 the cat jumps over the moon&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In general how can I move line X onto the end of line Y. A solution that would alllow something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 The fat cat   &#xA;2 jumps high&#xA;3 over the sky&#xA;4 is well behaved&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a command that takes line X line Y as input and appends the content of line Y onto line X. In this example if X=1 and Y =4 we get&lt;/p&gt;&#xA;&#xA;&lt;p&gt;command(1,4)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 The fat cat is well behaved&#xA;2 jumps high&#xA;3 over the sky&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18539" LastEditorUserId="18539" LastEditDate="2018-08-09T20:54:46.290" LastActivityDate="2018-08-09T21:42:32.987" Title="How to move a line onto the end of some other line" Tags="|cursor-motions|normal-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17053" PostTypeId="1" AcceptedAnswerId="17062" CreationDate="2018-08-09T18:15:50.267" Score="1" ViewCount="4769" Body="&lt;p&gt;If I understood it correctly gruvbox has it's own airline and you don't need vim-airline installed. I followed the easy install with Vundle but for some reason the airline just doesn't load. I'm using Konsole as a terminal. Thank you.&lt;/p&gt;&#xA;" OwnerDisplayName="user18540" LastActivityDate="2018-08-10T15:35:22.553" Title="How do I enable the gruvbox airline after installing gruvbox with Vundle?" Tags="|colorscheme|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17054" PostTypeId="1" AcceptedAnswerId="17066" CreationDate="2018-08-09T18:47:58.077" Score="1" ViewCount="2980" Body="&lt;p&gt;In my .vimrc file I have&#xA;&lt;code&gt;set noshowmode&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, upon starting vim, &lt;code&gt;:set noshowmode?&lt;/code&gt; returns &lt;code&gt;showmode&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something must be adjusting this setting upon startup (perhaps a plugin?). What's the best way to go about diagnosing something like this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the record, I've tried starting vim with the following command:&#xA;&lt;code&gt;vim -V9verbose.log&lt;/code&gt; but for some reason it still outputs the results to the command line rather than to the named file. I have to quit vim to save myself from being caught in a seemingly never ending verbose hell. Am I not using that command properly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance for any help, please let me know if you need any more info!&lt;/p&gt;&#xA;" OwnerUserId="14813" LastActivityDate="2018-08-10T20:24:45.180" Title="How to isolate what is changing `set noshowmode` to `showmode` upon startup?" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17056" PostTypeId="2" ParentId="17052" CreationDate="2018-08-09T20:37:14.840" Score="1" Body="&lt;p&gt;For the following, I am assuming that the numbers &lt;code&gt;1&lt;/code&gt; to &lt;code&gt;4&lt;/code&gt; indicate the line numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not aware of a one-shot command of moving an arbitrary line to the end of another line. &lt;code&gt;J&lt;/code&gt; can be used to join the next line to the current line. Else one can do something like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;4G&lt;/code&gt; (move to line 4)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dd&lt;/code&gt; (delete the line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1G&lt;/code&gt; (move to line 1)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;pkJ&lt;/code&gt; (insert line and join them)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can create a custom command that does this for you, similar to what you ask:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* Join call Join(&amp;lt;f-args&amp;gt;)&#xA;function! Join(...)&#xA;  if a:0 != 2 | return | endif&#xA;  execute 'normal!' a:2 . 'Gdd'&#xA;  execute 'normal!' (a:2 &amp;gt; a:1 ? a:1 : a:1 - 1) . 'GpkJ'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can do things like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Join line 4 to line 1&#xA;:Join 1 4&#xA;&#xA;&quot; Join line 2 to line 4&#xA;:Join 4 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the behaviour of &lt;code&gt;J&lt;/code&gt; depends on your &lt;code&gt;formatoptions&lt;/code&gt; setting, see &lt;code&gt;:h formatoptions&lt;/code&gt; and &lt;code&gt;:h fo-table&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastEditorUserId="21" LastEditDate="2018-08-09T21:42:32.987" LastActivityDate="2018-08-09T21:42:32.987" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17057" PostTypeId="1" CreationDate="2018-08-09T21:30:46.447" Score="2" ViewCount="541" Body="&lt;p&gt;When vim is split into different panes horizontally, each pane has its own statusline. It's easy to &lt;strong&gt;highlight&lt;/strong&gt; the statuslines differently based on current and non-current panes. BUT, I cannot figure out how to set different values for &lt;code&gt;StatusLine&lt;/code&gt; and &lt;code&gt;StatusLineNC&lt;/code&gt;. Only the former is recognized by vim/neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My plan is replace the values of non-active statuslines with em-dashes, making it look like a line-divider between panes. The active pane will have a conventional statusline with the a filepath, columns, row, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do you set separate values for them? Is this possible? Suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus question:&lt;/strong&gt; how can you repeat a single char through a statusline?&lt;/p&gt;&#xA;" OwnerUserId="18541" LastActivityDate="2020-04-28T04:49:40.023" Title="Set different values for non-current and current statuslines" Tags="|vimrc|neovim|statusline|set|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17058" PostTypeId="2" ParentId="14486" CreationDate="2018-08-10T02:33:06.947" Score="1" Body="&lt;p&gt;Visual-blocking pasting with &lt;code&gt;set clipboard=unnamed&lt;/code&gt; works for me in Vim 8 but not in Neovim. I'm pretty sure the issue you're describing related to this longstanding &lt;a href=&quot;https://github.com/neovim/neovim/issues/1822&quot; rel=&quot;nofollow noreferrer&quot;&gt;bug&lt;/a&gt; in Neovim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/neovim/neovim/issues/1822#issuecomment-233152833&quot; rel=&quot;nofollow noreferrer&quot;&gt;Workaround from the thread&lt;/a&gt; that worked for me (Neovim 0.3.1):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install &lt;a href=&quot;https://github.com/bfredl/nvim-miniyank&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvim-miniyank&lt;/a&gt; and add this to your config. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map p &amp;lt;Plug&amp;gt;(miniyank-autoput)&#xA;map P &amp;lt;Plug&amp;gt;(miniyank-autoPut)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user4779" LastActivityDate="2018-08-10T02:33:06.947" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17059" PostTypeId="2" ParentId="13539" CreationDate="2018-08-10T03:44:51.273" Score="2" Body="&lt;p&gt;I found after finding the above answer, that my paste was set, but my compatible wasn't set. Although after I moved set ruler to a place below the set paste I was able to get my ruler back, and have paste enabled for justified pasting of code.&lt;/p&gt;&#xA;" OwnerUserId="18546" LastActivityDate="2018-08-10T03:44:51.273" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17062" PostTypeId="2" ParentId="17053" CreationDate="2018-08-10T15:35:22.553" Score="1" Body="&lt;p&gt;Gruvbox is a colorscheme, and comes packaged with an airline theme as can be seen by the inclusion of an &lt;a href=&quot;https://github.com/morhetz/gruvbox/blob/master/autoload/airline/themes/gruvbox.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;autoload/airline/themes/gruvbox.vim&lt;/a&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gruvbox itself does not come with airline, but it supports it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use airline, you will need to install it; then, you may &lt;code&gt;let g:airline_theme = 'gruvbox'&lt;/code&gt; in your vimrc.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-08-10T15:35:22.553" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17063" PostTypeId="1" CreationDate="2018-08-10T17:11:48.280" Score="4" ViewCount="263" Body="&lt;p&gt;I am comforable with using history of edited files that is kept in viminfo,&#xA;the one that sets the limit in the first setting of &lt;code&gt;set viminfo='100,...&lt;/code&gt; variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After I've started using mutt as email client and using vim as its editor,&#xA;and that makes multiple temporary files created in /tmp/dir. These are of no interest and spoil the history of &lt;code&gt;:browse old&lt;/code&gt;.&#xA;I am trying to figure out the way of excluding those so they could be skipped or at least wiped in some hook procedure. &#xA;They all can be easily identified by &lt;code&gt;/tmp/mutt-.*&lt;/code&gt; path regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some natural/doable way to implement this?&lt;/p&gt;&#xA;" OwnerUserId="18356" LastActivityDate="2020-06-30T21:26:16.313" Title="Exclude file pattern from keeping it in viminfo history?" Tags="|viminfo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17064" PostTypeId="2" ParentId="17063" CreationDate="2018-08-10T17:23:52.287" Score="4" Body="&lt;p&gt;I guess I found a good solution for my use case. &#xA;&lt;code&gt;-i&lt;/code&gt; option allows to specify alternative locoation of viminfo file.&#xA;So I can specifey &lt;code&gt;vim -i /tmp/blackhole&lt;/code&gt; for cases where I do not care of file history. In my case that is specifying&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set editor = &quot;vim -i /tmp/idontcare&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my .muttrc&lt;/p&gt;&#xA;" OwnerUserId="18356" LastActivityDate="2018-08-10T17:23:52.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17066" PostTypeId="2" ParentId="17054" CreationDate="2018-08-10T20:12:46.650" Score="2" Body="&lt;p&gt;The easiest thing to do is to run the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set showmode?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should tell you from where the option was last set. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For many command types prepending &lt;code&gt;:verbose&lt;/code&gt; is the same as &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3Averbose-cmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;setting &lt;code&gt;'verbose'&lt;/code&gt; to 1&lt;/a&gt; and...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...when 'verbose' is non-zero, &lt;strong&gt;listing the value of a Vim option&lt;/strong&gt; or a key map or an abbreviation or a user-defined function or a command or a highlight group or an autocommand &lt;strong&gt;will also display where it was last defined&lt;/strong&gt;.  If it was defined manually then there will be no &quot;Last set&quot; message.  When it was defined while executing a function, user command or autocommand, the script in which it was defined is reported.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If this doesn't help for some reason then some general advice can be found in &lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;How do I debug my vimrc&lt;/a&gt;. (E.g. if you want to rule out any plugins as the cause.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As for your use of &lt;code&gt;-V&lt;/code&gt; that looks perfectly fine to me. You might want to check that you have file system permissions set up correctly to allow the Vim process to create/write a file in that directory and/or make sure there isn't already a file with that name with restricted permissions. That's all I can think of at this point. Oh, and use &lt;code&gt;-V1&lt;/code&gt; rather than &lt;code&gt;-V9&lt;/code&gt; while you're trying to figure it out. :)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-08-10T20:24:45.180" LastActivityDate="2018-08-10T20:24:45.180" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17067" PostTypeId="1" AcceptedAnswerId="17070" CreationDate="2018-08-10T20:21:54.063" Score="7" ViewCount="4926" Body="&lt;p&gt;how do I search/substitute in every other line.&#xA;:s/pattern1/pattern2{2}/g&lt;/p&gt;&#xA;&#xA;&lt;p&gt;file looks like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 pattern1 text&#xA;2 pattern1 text&#xA;3 pattern1 text&#xA;4 pattern1 text&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output file should look like&#xA;1 pattern1 text&#xA;2 pattern2 text&#xA;3 pattern1 text&#xA;4 pattern2 text&lt;/p&gt;&#xA;" OwnerUserId="18562" LastEditorUserId="343" LastEditDate="2019-10-16T09:23:16.940" LastActivityDate="2019-10-16T09:23:16.940" Title="substitution in every other line" Tags="|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17068" PostTypeId="1" CreationDate="2018-08-10T20:30:13.410" Score="1" ViewCount="49" Body="&lt;p&gt;I am using neovim with the gruvbox colorscheme. On its github page, you can see the &lt;code&gt;buffers&lt;/code&gt; word on the top right is colored in orange: &#xA;&lt;a href=&quot;https://i.stack.imgur.com/LpI3r.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LpI3r.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my installation, it grey/brown:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/eQ98V.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eQ98V.png&quot; alt=&quot;tabbar&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I find out what that object is? &lt;/li&gt;&#xA;&lt;li&gt;Once I know what it is, how can I color it?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18542" LastEditorUserId="18542" LastEditDate="2018-08-11T17:51:34.057" LastActivityDate="2018-08-11T17:51:34.057" Title="Coloring Piece of Tabbar" Tags="|colorscheme|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17069" PostTypeId="1" CreationDate="2018-08-10T20:33:21.833" Score="1" ViewCount="107" Body="&lt;p&gt;I have the following in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set colorcolumn=81&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets the background color of every window's 81st column to red.&#xA;I would like to disable this for &quot;pop-up&quot; windows like syntastic's error display window or jedi's docstring window. Since buffers similar to these are usually non-modifiable I thought I might be able to only active colorcolumn for modifiable buffers but I can not figure out how.&lt;/p&gt;&#xA;" OwnerUserId="11495" LastEditorUserId="11495" LastEditDate="2018-08-10T21:36:12.987" LastActivityDate="2019-05-08T03:03:05.770" Title="Do not apply settings for non-modifiable popup windows" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17070" PostTypeId="2" ParentId="17067" CreationDate="2018-08-10T20:52:47.210" Score="7" Body="&lt;p&gt;First thing I thought of is to just inject a conditional in a &lt;code&gt;:global&lt;/code&gt; command. Something like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/./ if getcurpos()[1] % 2 == 0 | s/foo/bar/g | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &quot;global&quot; command &lt;code&gt;:g/./&lt;/code&gt; will stop at every line that has at least one character and run the following command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;getcurpos()&lt;/code&gt; returns a list where the second element is the current line number. We do a modulo operation on that number and if the result is 0 we know we're on an even numbered line. In that case we do the substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want this to substitute on odd numbered lines instead change the &lt;code&gt;==&lt;/code&gt; to &lt;code&gt;!=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; @D.BenKnoble &lt;a href=&quot;https://vi.stackexchange.com/questions/17067/substitution-in-every-other-line/17070?noredirect=1#comment29269_17070&quot;&gt;identified an optimization&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/foo/ if getcurpos()[1] % 2 == 0 | s//bar/g | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We put the pattern to be replaced in the global command. That way we don't bother processing lines that wouldn't result in a substitution. As an extra touch we can then do &lt;code&gt;s//bar&lt;/code&gt; because leaving the pattern empty will do the substitution against the most recently used search expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; @ChristianBrabandt notes that &lt;code&gt;getcurpos()&lt;/code&gt; is relatively new (v7.4.313) and offers &lt;a href=&quot;https://vi.stackexchange.com/questions/17067/substitution-in-every-other-line/17070?noredirect=1#comment29272_17070&quot;&gt;a legacy function for fetching the current line number&lt;/a&gt; for those with earlier versions of Vim: replace &lt;code&gt;getcurpos()[1]&lt;/code&gt; with &lt;code&gt;line('.')&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-08-15T04:12:19.323" LastActivityDate="2018-08-15T04:12:19.323" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17071" PostTypeId="2" ParentId="17069" CreationDate="2018-08-10T21:35:49.460" Score="1" Body="&lt;p&gt;I'm adding my solution as an answer, the following snippet solves my problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWinEnter * call SetColorColumn()&#xA;&#xA;function! SetColorColumn()&#xA;    if &amp;amp;modifiable&#xA;        set colorcolumn=81&#xA;    else&#xA;        set colorcolumn&amp;amp;&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11495" LastActivityDate="2018-08-10T21:35:49.460" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17072" PostTypeId="2" ParentId="17067" CreationDate="2018-08-11T07:14:01.937" Score="6" Body="&lt;p&gt;Here is an alternative. Let Vim run a &lt;code&gt;:s&lt;/code&gt; command only on those specific lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(2, line('$'),2)| :exe i.'s/pattern1/pattern2/g'|endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This creates a loop, and iterating over each line and for each even line number executes a &lt;code&gt;:&amp;lt;nr&amp;gt;s/pattern1/pattern2/g&lt;/code&gt; command, replacing pattern1 by pattern2. If you have &lt;code&gt;pattern1&lt;/code&gt; in your search register already, you can even further shorten it to &lt;code&gt;for i in range(2, line('$'),2)| :exe i.'s//pattern2/g'|endfor&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-08-11T07:14:01.937" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17073" PostTypeId="1" CreationDate="2018-08-11T10:20:00.050" Score="3" ViewCount="3494" Body="&lt;p&gt;I have a vim configuration file (~/.vimrc) with the following settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colo delek&#xA;syntax on&#xA;&#xA;highlight clear CursorLine&#xA;highlight clear CursorLineNR&#xA;highlight clear LineNR&#xA;&#xA;highlight LineNR cterm=none ctermfg=Yellow ctermbg=none&#xA;highlight CursorLineNR cterm=bold ctermfg=Black ctermbg=none&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This used to work fine, highlighting the current line number in Black, while the others remained Yellow. After I read about &lt;code&gt;syntax enable&lt;/code&gt;, I tried it, replacing the &lt;code&gt;syntax on&lt;/code&gt; command. Since then, the CursorLineNR highlighting has refused to work. I have tried changing changing the &lt;code&gt;syntax&lt;/code&gt; command to &lt;code&gt;off&lt;/code&gt;, &lt;code&gt;enable&lt;/code&gt; and &lt;code&gt;on&lt;/code&gt; in all orders but to no avail. I even tried changing the CursorLineNR from the command-line mode but that too doesn't work. It has to be noted though that the LineNR functionality works perfectly fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I work on a Macbook Air, with the following vim version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46)&#xA;Included patches: 1-503, 505-680, 682-1283&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18565" LastActivityDate="2020-04-29T00:27:32.030" Title="CursorLineNR highlight not working" Tags="|vimrc|highlight|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17074" PostTypeId="1" AcceptedAnswerId="21074" CreationDate="2018-08-11T10:32:07.160" Score="0" ViewCount="1174" Body="&lt;p&gt;By &lt;code&gt;:set hl&lt;/code&gt;, the search result of a &lt;code&gt;/&lt;/code&gt; expression is highlighted, for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wkevu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wkevu.png&quot; alt=&quot;Vim search highlight in action&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if one wants to replace one substring distinguished by its surrounding, one can do so elegantly using regex capture groups:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0h2FY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0h2FY.png&quot; alt=&quot;replace not with and&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the search highlight does not reflect this capture group. Sometimes, it would be very helpful if it did, so you can feel more confident about your attempted regex. Does Vim have such a feature?&lt;/p&gt;&#xA;" OwnerUserId="2082" LastActivityDate="2019-09-01T21:34:12.967" Title="Highlighting a search capture group" Tags="|regular-expression|search|highlight|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17075" PostTypeId="1" AcceptedAnswerId="17078" CreationDate="2018-08-12T05:27:34.490" Score="1" ViewCount="351" Body="&lt;p&gt;I changed vim backup directory to be stored on  &lt;code&gt;.backup&lt;/code&gt; folder in my dotfiles local repo&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set undodir=$HOME/.dotfiles/backup//&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it works well as expected but i want to separate actual dotfiles backups to be saved in a new directory named &lt;code&gt;dot-files&lt;/code&gt; inside of &lt;code&gt;.backup&lt;/code&gt;( &lt;code&gt;.backup/dot-files&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg: if the file is &lt;code&gt;.tmux.conf&lt;/code&gt;, &lt;code&gt;.vimrc&lt;/code&gt;, &lt;code&gt;.bashrc&lt;/code&gt; etc.. it will be saved in the &lt;code&gt;backup/dot-files&lt;/code&gt; but if it is an ordinary file just save it in the &lt;code&gt;backup&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is this doable with vimscript?&lt;/p&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-08-12T08:01:36.657" Title="how to know if the current file in the buffer is a (.)dotfile using vimscript?" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17076" PostTypeId="1" AcceptedAnswerId="17077" CreationDate="2018-08-12T06:09:27.287" Score="0" ViewCount="78" Body="&lt;p&gt;I added the following command to my .vimrc, which is designed to insert a blank line below the cursor&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;o mzo&amp;lt;esc&amp;gt;`z &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The sequence of this command is&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;mark the cursor position&lt;/li&gt;&#xA;&lt;li&gt;use the &lt;code&gt;o&lt;/code&gt; command to create a new line&lt;/li&gt;&#xA;&lt;li&gt;use the escape key to go back to normal mode&lt;/li&gt;&#xA;&lt;li&gt;move the cursor back to its original marked position&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, after executing this command, the cursor ends up one character to the right of where it started. Why doesn't the cursor return to its original position?&lt;/p&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2018-08-13T19:36:13.510" Title="Why doesn't the cursor return to its original position in this command to create a new line?" Tags="|key-bindings|mark|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17077" PostTypeId="2" ParentId="17076" CreationDate="2018-08-12T06:16:32.727" Score="0" Body="&lt;p&gt;There was one character of trailing whitespace at the end of the command, which had the effect of moving the cursor one character to the right (since the space bar moves the cursor to the right in normal mode).&lt;/p&gt;&#xA;" OwnerUserId="16602" LastEditorUserId="16602" LastEditDate="2018-08-13T19:36:13.510" LastActivityDate="2018-08-13T19:36:13.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17078" PostTypeId="2" ParentId="17075" CreationDate="2018-08-12T08:01:36.657" Score="0" Body="&lt;p&gt;You can test &lt;code&gt;expand('%:p')&lt;/code&gt; against the directory you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check the help from &lt;code&gt;expand()&lt;/code&gt;, from there, follow the link to the filename modifiers.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-08-12T08:01:36.657" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17079" PostTypeId="1" AcceptedAnswerId="17081" CreationDate="2018-08-12T17:20:26.397" Score="3" ViewCount="753" Body="&lt;h2&gt;CASE 1:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Have your autocmd command be setup like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd User ALELintPost call SayHello() &quot; ALELintPost is async&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And your &lt;strong&gt;SayHello&lt;/strong&gt; function set up like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SayHello() abort&#xA;    echo &quot;Hello World!&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function correctly executes, but the message isn't echoed.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;CASE 2:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SayHello2() abort&#xA;    echo &quot;Hello World!&quot;&#xA;endfunction&#xA;&#xA;function! SayHello() abort&#xA;    let timer=timer_start(500, { timer -&amp;gt; execute('call SayHello2()') }) &quot; Or however you wanna call, really... It doesn't work&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There is a library called Echodoc who seems to be dedicated to printing stuff there (it's also a plugin). It uses the typical echo methods like I'm currently trying to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/Shougo/echodoc.vim/blob/master/autoload/echodoc.vim#L200&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Shougo/echodoc.vim/blob/master/autoload/echodoc.vim#L200&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps it's able to echo directly because the methods aren't asynchronous?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some register/buffer/place I can write to in order to cheat this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or am I doing something wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please let me know!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I found out a solution and posted the answer below.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="18574" LastEditorUserId="18574" LastEditDate="2018-08-13T03:19:19.293" LastActivityDate="2018-08-13T03:30:59.843" Title="Can't echo messages from inside async functions" Tags="|vimscript|plugin-system|echo|async|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17080" PostTypeId="2" ParentId="17007" CreationDate="2018-08-13T01:37:02.450" Score="2" Body="&lt;p&gt;add this to your .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 0 &amp;amp;&amp;amp; line (&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) | exe &quot;normal! g'\&quot;&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2018-08-13T01:37:02.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17081" PostTypeId="2" ParentId="17079" CreationDate="2018-08-13T03:30:59.843" Score="0" Body="&lt;h2&gt;The solution for my case is to use Vim's sandbox command.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#sandbox&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/eval.html#sandbox&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how it works internally, but it solves my problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SayHello2()&#xA;    let g:GLOBAL_VAR='WORKS!' &quot; Sandboxed functions accesses the global context normally&#xA;    echo &quot;Hello World!&quot;&#xA;endfunction&#xA;&#xA;function! SayHello()&#xA;    sandbox call SayHello2()&#xA;endfunction&#xA;&#xA;autocmd User ALELintPost call SayHello()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As it can be seen in the example above, you can still access the global scope, execute commands and perform most &quot;function stuff&quot; inside of the sandboxed context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, since Vim claims it controls the evaluation's side-effects in some way, &lt;em&gt;it might not work exactly as a regular function call for every single case&lt;/em&gt;. It works for mine. : - ]&lt;/p&gt;&#xA;" OwnerUserId="18574" LastActivityDate="2018-08-13T03:30:59.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17082" PostTypeId="1" AcceptedAnswerId="17083" CreationDate="2018-08-13T07:08:12.133" Score="0" ViewCount="722" Body="&lt;p&gt;Note: I am not looking for a working substitution for my command (allready have that), but for an explanation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;include &amp;lt;stdio.h&amp;gt;&#xA;&#xA;char ga[] = &quot;abcdefghijklm&quot;;&#xA;&#xA;void my_array_func(char ca[10]);&#xA;void my_pointer_func(char *pa);&#xA;&#xA;int main()&#xA;{&#xA;   /* code */&#xA;&#xA;   return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and use the following search on it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^$\n\(^.*\n\)\{-}\ze$\nint main&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which should match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void my_array_func(char ca[10]);&#xA;void my_pointer_func(char *pa);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't. It does match all possible lines above.&#xA;In this case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char ga[] = &quot;abcdefghijklm&quot;;&#xA;&#xA;void my_array_func(char ca[10]);&#xA;void my_pointer_func(char *pa);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I add more lines which are fitting to the pattern it matches them too.&#xA;So it behaves exactly the same if I replace &lt;code&gt;\{-}&lt;/code&gt; with &lt;code&gt;*&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use the count directly (&lt;code&gt;\{2}&lt;/code&gt; instead of &lt;code&gt;\{-}&lt;/code&gt;) I get the result as expected.&lt;/p&gt;&#xA;" OwnerUserId="11316" LastEditorUserId="11316" LastEditDate="2018-08-13T10:36:35.967" LastActivityDate="2018-08-13T10:36:35.967" Title="Non-greedy regex quantifier is greedy" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17083" PostTypeId="2" ParentId="17082" CreationDate="2018-08-13T09:52:29.570" Score="1" Body="&lt;p&gt;This greedyness comes from &lt;code&gt;*&lt;/code&gt; that is inside parenthesis. It matches also empty lines. If you change that to &lt;code&gt;\+&lt;/code&gt; it should work as you expect it to.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2018-08-13T09:52:29.570" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17084" PostTypeId="2" ParentId="17044" CreationDate="2018-08-13T12:22:56.813" Score="1" Body="&lt;p&gt;I checked with a minimal example the proposed solution from &lt;a href=&quot;https://stackoverflow.com/q/16711143&quot;&gt;https://stackoverflow.com/q/16711143&lt;/a&gt; and they work&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Put the following into &lt;code&gt;~/.vim/after/ftplugin/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal foldlevel=999&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Alternatively, you could define in &lt;code&gt;$MYVIMRC&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup latex&#xA;  autocmd!&#xA;  autocmd Filetype tex setlocal foldlevel=999&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Question missed mentioning of plugin vim-latex which changes &lt;a href=&quot;http://vim-latex.sourceforge.net/documentation/latex-suite/latex-folding.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;how folding is done&lt;/a&gt; and the question has already been raised on stackoverflow &#xA;&lt;a href=&quot;https://stackoverflow.com/q/16711143/&quot;&gt;https://stackoverflow.com/q/16711143/&lt;/a&gt;.&#xA;Please consider following advice for new questions &lt;a href=&quot;https://vi.meta.stackexchange.com/a/15/1292&quot;&gt;https://vi.meta.stackexchange.com/a/15/1292&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-10-14T16:04:21.047" LastActivityDate="2018-10-14T16:04:21.047" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="17085" PostTypeId="1" AcceptedAnswerId="17086" CreationDate="2018-08-13T20:21:39.343" Score="0" ViewCount="410" Body="&lt;p&gt;I tried to make a function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! WrapSelect (front, back)&#xA;    &quot;puts characters around the selected text.&#xA;    execute '''&amp;lt;, ''&amp;gt;s/\%V\(\_.*\)\%V\(\_.\)/'.a:front.'\1\2'.a:back.'/'&#xA;    nohl&#xA;endfunction&#xA;vnoremap &amp;lt;C-l&amp;gt; :call WrapSelect('[',']')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason there's a second group is to make it behave like yank: I want to put the brackets around the selected text, including the character under the cursor, the way yank copies selected text. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example input (where | denotes highlighted section):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a|nd then some words&#xA;and some other wor|ds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Expected output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a[nd then some words&#xA;and some other wor]ds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Actual output: an error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Error detected while processing function WrapSelect:&#xA; line   15:&#xA; E19: Mark has invalid line number&#xA; Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the text becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; a[nd then some words&#xA; and some other wor][ds&#xA; ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With more lines in the file unselected the output becomes more garbage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a[[nd then some words&#xA;and some other wor][ds&#xA;third line&#xA;]&#xA;fifth line&#xA;]sixth line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reading about substitute says that it does the search on each line in the selected range, and I don't see a way to turn that off and just do it on the whole block once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also saw &lt;a href=&quot;https://vi.stackexchange.com/a/15482/17205&quot;&gt;here&lt;/a&gt; that there's a visual mode command I could possibly use, and you can &lt;a href=&quot;https://stackoverflow.com/a/5084487/5889131&quot;&gt;make visual commands work with functions&lt;/a&gt;, so I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! WrapSelect (front, back)&#xA;    &quot;puts characters around the selected text.&#xA;    execute &quot;normal gv&quot; . 'c'.a:front.'^R&quot;'.a:back&#xA;endfunction&#xA;vnoremap &amp;lt;C-l&amp;gt; :call WrapSelect('[',']')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where ^R is the literal C-r from Ctrl+v Ctrl+r (it didn't paste into SE)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This produces different wrong output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a[[nd then some words]&#xA;and some other wor]ds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This one seemed more promising from reading the help docs (&lt;code&gt;:h v_c&lt;/code&gt;, &lt;code&gt;:h i_CTRL-R&lt;/code&gt;), but still did not do what I expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know plugins exist that can do cooler things than I can, but I would like to understand how to do this from my &lt;code&gt;vimrc&lt;/code&gt; if possible.&lt;/p&gt;&#xA;" OwnerUserId="17205" LastActivityDate="2018-08-14T22:28:25.910" Title="Vim multi-line substitute/insert once on selected text" Tags="|vimrc|vimscript|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17086" PostTypeId="2" ParentId="17085" CreationDate="2018-08-14T04:04:55.097" Score="1" Body="&lt;p&gt;I can think of a number of ways to do this but I'll just focus on what you tried. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, there is a fundamental problem with the mappings. If you have visually selected text when the command line is opened with &lt;code&gt;:&lt;/code&gt; the selection's line range, &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt;, will be automatically inserted. You won't notice this when it's used in a mapping but it's there and it will interfere with the function's logic. Solution: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;C-l&amp;gt; :&amp;lt;C-U&amp;gt;call WrapSelect('[',']')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Upon opening the command line, before inserting anything we clear any existing text with Ctrl-U by way of the equivalent keycode &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On to the function code. Using your second approach I tweaked a couple things and it worked fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'norm! gvc' . a:front. &quot;\&amp;lt;C-R&amp;gt;\&quot;&quot;  . a:back&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;norm!&lt;/code&gt; to ensure there are no user mappings interfering with what we want to do. And I'm using &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; instead of &lt;code&gt;Ctrl-V&lt;/code&gt;+&lt;code&gt;Ctrl-R&lt;/code&gt;. If you look at the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#:exe&quot; rel=&quot;nofollow noreferrer&quot;&gt;help for &lt;code&gt;:execute&lt;/code&gt;&lt;/a&gt; you'll find this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        &quot;:execute&quot; is also a nice way to avoid having to type&#xA;        control characters in a Vim script for a &quot;:normal&quot;&#xA;        command: &#xA;    :execute &quot;normal ixxx\&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The backslash before the keycode is required per &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-quote&quot; rel=&quot;nofollow noreferrer&quot;&gt;expression strings&lt;/a&gt; where it also says &quot;double quotes [must be] used&quot; (which also means we need to escape the double quote signifying the &lt;code&gt;&quot;&lt;/code&gt; register).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides, keycodes are more readable and less error prone than Ctrl-V sequences.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-08-14T22:28:25.910" LastActivityDate="2018-08-14T22:28:25.910" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17087" PostTypeId="1" CreationDate="2018-08-14T05:43:05.233" Score="0" ViewCount="48" Body="&lt;p&gt;The two registers &lt;code&gt;&quot;*&lt;/code&gt; and &lt;code&gt;&quot;+&lt;/code&gt;, what is the difference between them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe they are all about OS clipboard?&lt;/p&gt;&#xA;" OwnerUserId="18467" LastActivityDate="2018-08-14T06:10:53.950" Title="what is the difference between &quot;* and &quot;+?" Tags="|register|expression-register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17088" PostTypeId="2" ParentId="17087" CreationDate="2018-08-14T06:10:53.950" Score="1" Body="&lt;p&gt;&lt;code&gt;&quot;*&lt;/code&gt; is for &lt;code&gt;PRIMARY&lt;/code&gt; buffer/store/selection in X11 world and &lt;code&gt;&quot;+&lt;/code&gt; is for &lt;code&gt;CLIPBOARD&lt;/code&gt;.&#xA;There are 3 separate selections for X11 apps to use for data exchange:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;PRIMARY&lt;/li&gt;&#xA;&lt;li&gt;SECONDARY&lt;/li&gt;&#xA;&lt;li&gt;CLIPBOARD&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Vim uses only &lt;code&gt;PRIMARY&lt;/code&gt; and &lt;code&gt;CLIPBOARD&lt;/code&gt;. You can read more in Vim's help: &lt;code&gt;:h x11-selection&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also &lt;code&gt;set clipboard=unnamedplus&lt;/code&gt;, which will alias &lt;code&gt;&quot;*&lt;/code&gt; register to &lt;code&gt;&quot;+&lt;/code&gt; (&lt;code&gt;:h clipboard-unnamedplus&lt;/code&gt;, &lt;a href=&quot;http://vim.wikia.com/wiki/Accessing_the_system_clipboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;Using the clipboard as the default register&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how it exactly works on Windows and Mac, since there is no such separation as in Linux/X11&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2018-08-14T06:10:53.950" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17089" PostTypeId="2" ParentId="3655" CreationDate="2018-08-14T07:30:07.380" Score="3" Body="&lt;p&gt;One neat trick is to use &lt;code&gt;feedkeys(&quot;/pattern\&amp;lt;CR&amp;gt;&quot;)&lt;/code&gt;.&#xA;This works differently than using :normal because the keys being fed into vim gets evaluated after the function returns so the problem with search direction and search pattern being reset goes away. ;-)&#xA;This actually lets you control both search pattern AND search direction from your function. I have found no other way to do this.&lt;/p&gt;&#xA;" OwnerUserId="18590" LastActivityDate="2018-08-14T07:30:07.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17090" PostTypeId="1" CreationDate="2018-08-14T07:59:30.317" Score="0" ViewCount="265" Body="&lt;p&gt;I am having a very long line file, I have to break the line into number of small lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt; this&amp;gt;is a testing&amp;lt; /this&amp;gt;&amp;lt; next&amp;gt;testing&amp;lt; /next&amp;gt;&amp;lt; tested&amp;gt;successfully&amp;lt; /tested&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to break it into as of below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt; this&amp;gt;is a testing&amp;lt; / this&amp;gt; &#xA;&#xA;&amp;lt; next&amp;gt;testing&amp;lt; / next&amp;gt; &#xA;&#xA;&amp;lt; tested&amp;gt;successfully&amp;lt; /tested&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for this I am trying to search for &lt;code&gt;&amp;lt;&lt;/code&gt; and add new line, but this results in: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt; this&amp;gt;is a testing&#xA;&#xA;&amp;lt; /this&amp;gt;&#xA;&#xA;&amp;lt; next&amp;gt;testing&#xA;&#xA;&amp;lt; /next&amp;gt;&#xA;&#xA;&amp;lt; tested&amp;gt;successfully&#xA;&#xA;&amp;lt; /tested&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What would be the correct command to fix this?&lt;/p&gt;&#xA;" OwnerUserId="18591" LastEditorUserId="15871" LastEditDate="2018-12-14T01:04:35.007" LastActivityDate="2018-12-14T01:04:35.007" Title="Search and replace a pattern with new line except for a pattern" Tags="|substitute|formatting|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17091" PostTypeId="1" CreationDate="2018-08-14T13:13:38.180" Score="1" ViewCount="229" Body="&lt;p&gt;Marks are saved in .viminfo&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to have separate marks saved per session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an easy setting to make this switch? I know I could write some vimscript to save my session marks somewhere and reload them to overwrite whatever viminfo is doing, but I don't want to spend the time if I don't have to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm particularly interested in the A-Z marks. I often have a few sessions open for different projects and some functions that help me jump between them quickly, and to my chagrin I discovered viminfo, not sessions, is where marks are saved. I see the use of this, but it doesn't fit my workflow.&lt;/p&gt;&#xA;" OwnerUserId="8483" LastActivityDate="2018-08-14T15:26:33.320" Title="Can capitalized marks be saved in session INSTEAD of viminfo?" Tags="|save|sessions|mark|viminfo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17092" PostTypeId="2" ParentId="17090" CreationDate="2018-08-14T14:51:03.570" Score="1" Body="&lt;p&gt;If for some reason you can't check those tools that statox recommended, you can use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s;\(&amp;lt; */[^&amp;gt;]\+&amp;gt;\);\1^M;g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will look at every line for every closing tag (&lt;code&gt;\(&amp;lt; */[^&amp;gt;]\+&amp;gt;\)&lt;/code&gt;) and replace it by itself and then a new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first part (to identify the closing tag) will search for&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a &lt;code&gt;&amp;lt;&lt;/code&gt; character &lt;/li&gt;&#xA;&lt;li&gt;followed by any number of spaces (&lt;code&gt; *&lt;/code&gt;),&lt;/li&gt;&#xA;&lt;li&gt;then a slash (&lt;code&gt;/&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;and any (positive) number of any character different from a closing tag sign (&lt;code&gt;[^&amp;gt;]\+&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;and finally a close tag sign (&lt;code&gt;&amp;gt;&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To insert a new line (&lt;code&gt;^M&lt;/code&gt; above) you should press &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;V&lt;/kbd&gt; (or &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;Q&lt;/kbd&gt; if you are on on Windows) and then press the &lt;kbd&gt;Enter&lt;/kbd&gt; key.&lt;/p&gt;&#xA;" OwnerUserId="11384" LastEditorUserId="10604" LastEditDate="2018-12-14T01:04:05.280" LastActivityDate="2018-12-14T01:04:05.280" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17093" PostTypeId="2" ParentId="17091" CreationDate="2018-08-14T15:26:33.320" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there an easy setting to make this switch?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Nope&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I know I could write some vimscript to save my session marks somewhere and reload them to overwrite whatever viminfo is doing, but I don't want to spend the time if I don't have to.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is exactly how you would do this.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example code:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bang -complete=file -nargs=? Mksession mksession&amp;lt;bang&amp;gt; &amp;lt;args&amp;gt; |&#xA;      \ let [s:viminfofile, s:viminfo] = [&amp;amp;viminfofile, &amp;amp;viminfo] |&#xA;      \ try |&#xA;      \   let [&amp;amp;viminfofile, &amp;amp;viminfo] = [v:this_session . '.viminfo', 'f'] |&#xA;      \   wviminfo! |&#xA;      \ finally |&#xA;      \   let [&amp;amp;viminfofile, &amp;amp;viminfo] = [s:viminfofile, s:viminfo] |&#xA;      \ endtry&#xA;&#xA;augroup ViminfoSessionRestore&#xA;  autocmd!&#xA;  autocmd SessionLoadPost * |&#xA;        \ let [s:viminfofile, s:viminfo] = [&amp;amp;viminfofile, &amp;amp;viminfo] |&#xA;        \ try |&#xA;        \   let [&amp;amp;viminfofile, &amp;amp;viminfo] = [v:this_session . '.viminfo', 'f'] |&#xA;        \   rviminfo! |&#xA;        \ finally |&#xA;        \   let [&amp;amp;viminfofile, &amp;amp;viminfo] = [s:viminfofile, s:viminfo] |&#xA;        \ endtry&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;NOTE&lt;/em&gt;: I have not tested this, so use at your own risk.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This provides &lt;code&gt;:Mksession&lt;/code&gt; which will write out a new &lt;code&gt;viminfo&lt;/code&gt; files named after the &lt;code&gt;v:this_session&lt;/code&gt; variable with a suffix of &lt;code&gt;.viminfo&lt;/code&gt;. This &lt;code&gt;viminfo&lt;/code&gt; file only contains file marks (&lt;code&gt;f&lt;/code&gt; option). After a session is loaded the &lt;code&gt;SessionLoadPost&lt;/code&gt; event is triggered. Attempt to read the session's &lt;code&gt;viminfo&lt;/code&gt; file via &lt;code&gt;:rviminfo&lt;/code&gt; on &lt;code&gt;SessionLoadPost&lt;/code&gt; event.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Other thoughts:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I would imagine creating another file in addition to the session file would become annoying. It might be better to append the file-mark data to the session file directly, but that would be more involved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also want to look into some session plugins to make your session creation and management simpler, e.g. &lt;a href=&quot;https://github.com/tpope/vim-obsession&quot; rel=&quot;nofollow noreferrer&quot;&gt;obsession.vim&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://github.com/dhruvasagar/vim-prosession&quot; rel=&quot;nofollow noreferrer&quot;&gt;VIM ProSession&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;For more help see:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h 'viminfo'&#xA;:h 'viminfofile'&#xA;:h this_session&#xA;:h SessionLoadPost&#xA;:h :mksession&#xA;:h :rviminfo&#xA;:h :wviminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-08-14T15:26:33.320" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17094" PostTypeId="1" AcceptedAnswerId="17095" CreationDate="2018-08-14T20:25:26.780" Score="6" ViewCount="966" Body="&lt;p&gt;If there is some text between quotations, such as&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;x = 5&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can type &lt;code&gt;ci&quot;&lt;/code&gt; in normal mode to delete the text inside the quotations and switch to insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often want to perform this same action on text between two dollar signs, such as&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$x = 5$&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But typing &lt;code&gt;ci$&lt;/code&gt; has no effect. Is there a way to configure vim for treating dollar signs like quotations?&lt;/p&gt;&#xA;" OwnerUserId="11931" LastEditorUserId="1292" LastEditDate="2019-01-24T12:46:50.300" LastActivityDate="2019-01-24T12:46:50.300" Title="Change text between two $ symbols" Tags="|normal-mode|custom-text-object|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17095" PostTypeId="2" ParentId="17094" CreationDate="2018-08-15T03:24:32.080" Score="10" Body="&lt;p&gt;If you want only &lt;code&gt;$&lt;/code&gt; to be a text object, then do the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap i$ :&amp;lt;C-u&amp;gt; normal! T$vt$&amp;lt;CR&amp;gt;&#xA;onoremap i$ :normal vi$&amp;lt;CR&amp;gt;&#xA;xnoremap a$ :&amp;lt;C-u&amp;gt; normal!F$vf$&amp;lt;CR&amp;gt;&#xA;onoremap a$ :normal va$&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will add some more text objects in your vim config.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for s:char in [ '_', '.', ':', ',', ';', '&amp;lt;bar&amp;gt;', '/', '&amp;lt;bslash&amp;gt;', '*', '+', '%', '$' ]&#xA;  execute 'xnoremap i' . s:char . ' :&amp;lt;C-u&amp;gt;normal! T' . s:char . 'vt' . s:char . '&amp;lt;CR&amp;gt;'&#xA;  execute 'onoremap i' . s:char . ' :normal vi' . s:char . '&amp;lt;CR&amp;gt;'&#xA;  execute 'xnoremap a' . s:char . ' :&amp;lt;C-u&amp;gt;normal! F' . s:char . 'vf' . s:char . '&amp;lt;CR&amp;gt;'&#xA;  execute 'onoremap a' . s:char . ' :normal va' . s:char . '&amp;lt;CR&amp;gt;'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The four commands in the for loop will add operator-pending and visual mode mappings for each of the characters in the dictionary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the above commands in your vimrc for consistent behavior over all sessions.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2018-08-16T04:26:04.250" LastActivityDate="2018-08-16T04:26:04.250" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17096" PostTypeId="2" ParentId="17094" CreationDate="2018-08-15T08:16:39.073" Score="1" Body="&lt;p&gt;If you do not mind installing a plugin, you have several options you can choose from&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/rbonvall/vim-textobj-latex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-latex&lt;/a&gt; (depends on &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-user&lt;/a&gt;) defines &lt;code&gt;i$&lt;/code&gt; and &lt;code&gt;a$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/gibiansky/vim-latex-objects&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-latex-objects&lt;/a&gt; defines &lt;code&gt;im&lt;/code&gt; and &lt;code&gt;am&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt; defines &lt;code&gt;i$&lt;/code&gt; and &lt;code&gt;a$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/machakann/vim-sandwich&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sandwich&lt;/a&gt; defines &lt;code&gt;ib&lt;/code&gt; and &lt;code&gt;ab&lt;/code&gt; by default. However, vim-sandwich can easily be customized to provide &lt;code&gt;i$&lt;/code&gt; and &lt;code&gt;a$&lt;/code&gt;. Add following to &lt;code&gt;~/.vim/after/ftplugin/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! omap &amp;lt;unique&amp;gt; i$ &amp;lt;Plug&amp;gt;(textobj-sandwich-query-i)$&#xA;silent! xmap &amp;lt;unique&amp;gt; i$ &amp;lt;Plug&amp;gt;(textobj-sandwich-query-i)$&#xA;silent! omap &amp;lt;unique&amp;gt; a$ &amp;lt;Plug&amp;gt;(textobj-sandwich-query-a)$&#xA;silent! xmap &amp;lt;unique&amp;gt; a$ &amp;lt;Plug&amp;gt;(textobj-sandwich-query-a)$&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note, the classic plugin &lt;a href=&quot;http://vim-latex.sf.net&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-latex&lt;/a&gt; (&lt;a href=&quot;https://github.com/vim-latex/vim-latex&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;) (aka &lt;em&gt;latex-suite&lt;/em&gt;) does not provide this text object.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2018-08-15T08:16:39.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17097" PostTypeId="2" ParentId="2607" CreationDate="2018-08-15T10:02:53.977" Score="-1" Body="&lt;p&gt;Obvious , but not listed above - example find all the sql files having the create_table string in their name&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args **/*create_table*sql&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and check them&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and open the first one&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:b 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10526" LastActivityDate="2018-08-15T10:02:53.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17098" PostTypeId="1" CreationDate="2018-08-15T13:58:34.320" Score="2" ViewCount="1352" Body="&lt;p&gt;How do I remap key combinations with a free variable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's say I want to be able to insert a single letter without leaving normal mode. I would want something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;i[variable] i[variable]&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;such that pressing &lt;code&gt;&amp;lt;leader&amp;gt;iy&lt;/code&gt; inserts &lt;code&gt;y&lt;/code&gt;, pressing &lt;code&gt;&amp;lt;leader&amp;gt;iu&lt;/code&gt; inserts &lt;code&gt;u&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(this is a stupid example because it doesn't reduce the number of keystrokes)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; For a more practical example, consider a command that surrounds the current word with the pressed character, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;s[variable] viws[variable][variable]&amp;lt;Esc&amp;gt;P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;such that &lt;code&gt;&amp;lt;leader&amp;gt;s&quot;&lt;/code&gt; turns &lt;code&gt;word&lt;/code&gt; into &lt;code&gt;&quot;word&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment I have such a command (and an equivalent for visual mode surroundings) for &lt;code&gt;&quot;&lt;/code&gt;, &lt;code&gt;'&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I also have extended commands that surround selections with two different characters, i.e. &lt;code&gt;()&lt;/code&gt;, &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; &lt;code&gt;[]&lt;/code&gt; &lt;code&gt;{}&lt;/code&gt; &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; upon pressing only the first of these. For these I can also imagine having the same command and simply looking up the closing surrounding letter as a function of the input opening character)&lt;/p&gt;&#xA;" OwnerUserId="18613" LastEditorUserId="18613" LastEditDate="2018-08-16T08:24:34.357" LastActivityDate="2018-08-16T08:53:55.713" Title="Create remap with variable" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17099" PostTypeId="1" AcceptedAnswerId="17100" CreationDate="2018-08-15T23:42:48.567" Score="1" ViewCount="98" Body="&lt;p&gt;I would like to replace every number &lt;code&gt;n&lt;/code&gt; in my document with &lt;code&gt;n+1&lt;/code&gt;. Easy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\([0-9]\+\)/\=(submatch(0)+1)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I would like to replace every number &lt;code&gt;n&lt;/code&gt; with &lt;code&gt;n+1&lt;/code&gt;, only when the number has exactly three digits. Look behind/ahead to the rescue!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/[0-9]\@&amp;lt;!\([0-9]\{3}\)[0-9]\@!/\=(submatch(0)+1)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But now I would like to replace every number &lt;code&gt;n&lt;/code&gt; with &lt;code&gt;n+1&lt;/code&gt;, only when the number is between 42 and 1337. Can it be done?&lt;/p&gt;&#xA;" OwnerUserId="6154" LastActivityDate="2018-08-16T06:27:11.843" Title="Match and replace very specific number" Tags="|regular-expression|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17100" PostTypeId="2" ParentId="17099" CreationDate="2018-08-16T01:21:00.393" Score="7" Body="&lt;p&gt;Instead of moving more logic into the regular expression, move more logic into the replacement.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! IncrementIf(fn, n)&#xA;    if a:fn(a:n)&#xA;        return n + 1&#xA;    endif&#xA;    return n&#xA;endfunction&#xA;:%s/\(\d\+\)/\=IncrementIf({x -&amp;gt; x &amp;gt;= 42 &amp;amp;&amp;amp; x &amp;lt;= 1337}, submatch(0))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can even generalize this a bit by using &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#Partial&quot; rel=&quot;noreferrer&quot;&gt;partials&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! If(fn, t, f, ...)&#xA;    if call(a:fn, a:000)&#xA;        return call(a:t, a:000)&#xA;    endif&#xA;    return call(a:f, a:000)&#xA;endfunction&#xA;&#xA;let Inc = function('If', [{x -&amp;gt; x &amp;gt;= 42 &amp;amp;&amp;amp; x &amp;lt;= 1337}, {x -&amp;gt; x + 1}, {x -&amp;gt; x}])&#xA;&#xA;:%s/\([0-9]\+\)/\=Inc(submatch(0))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastEditorUserId="21" LastEditDate="2018-08-16T06:27:11.843" LastActivityDate="2018-08-16T06:27:11.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17101" PostTypeId="1" CreationDate="2018-08-16T03:34:42.593" Score="1" ViewCount="117" Body="&lt;p&gt;I want to change the behavior of &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; when the popup menu is open using this map&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;Space&amp;gt; pumvisible() ? &quot;\&amp;lt;Down&amp;gt;\&amp;lt;Enter&amp;gt;&quot; : &quot;\&amp;lt;Space&amp;gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, with this map my abbreviations no longer get triggered when terminated by a &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway to get around this?&lt;/p&gt;&#xA;" OwnerUserId="18621" LastActivityDate="2018-08-16T03:34:42.593" Title="Abbreviations do not work when space is conditionally remapped" Tags="|abbreviations|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17102" PostTypeId="2" ParentId="17098" CreationDate="2018-08-16T05:21:49.287" Score="2" Body="&lt;p&gt;If you're using Vim, you can use the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#getchar()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getchar()&lt;/code&gt; function&lt;/a&gt; to get a single keystroke and take its numeric value, and then the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#nr2char()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;nr2char()&lt;/code&gt; function&lt;/a&gt; to convert that into a character string again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your example above, inserting a single character, this does the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;i :execute &quot;normal i&quot; . nr2char(getchar()) . &quot;\&amp;lt;lt&amp;gt;esc&amp;gt;&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: To handle the specific case you mentioned (surrounding word with characters, such as quote), this would work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Surround()&#xA;  let chr = nr2char(getchar())&#xA;  return &quot;viws&quot; . chr . chr . &quot;\&amp;lt;esc&amp;gt;P&quot;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;s&amp;lt;esc&amp;gt; &amp;lt;nop&amp;gt;&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;s &amp;lt;SID&amp;gt;Surround()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using a function and calling &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#:map-%3Cexpr%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;nnoremap&lt;/code&gt; with &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt; to execute a function and produce the expansion for the map.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside a function, you can store the result of &lt;code&gt;getchar()&lt;/code&gt; in a variable and use that multiple times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other mapping &lt;code&gt;&amp;lt;leader&amp;gt;s&amp;lt;esc&amp;gt;&lt;/code&gt; takes care of the trick to prevent moving the cursor. Since the mapping uses the same prefix, Vim will wait for another key to decide which mapping to use, so it will only call &lt;code&gt;Surround()&lt;/code&gt; when it already knows which key to use. The mapping using &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; will be a &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt;, which is also a somewhat convenient way to cancel the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps &lt;code&gt;Surround()&lt;/code&gt; could use more error checking, possibly looking at whether &lt;code&gt;chr&lt;/code&gt; is actually a printable character, to avoid weird effects in case &lt;code&gt;nr2char()&lt;/code&gt; can't make a printable character of the pressed key combination.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2018-08-16T08:53:55.713" LastActivityDate="2018-08-16T08:53:55.713" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17105" PostTypeId="1" AcceptedAnswerId="17111" CreationDate="2018-08-16T11:07:23.303" Score="0" ViewCount="900" Body="&lt;p&gt;I'm currently learning Vimscript, but I'm stuck at a particular problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm creating a statusline which shows the full path (~) of the file currently displayed in the buffer. Instead of just using %F, I'm creating two separate highlight groups to show the difference between the cwd and the active file. Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;~/projects/projName/&lt;strong&gt;subDir/file.md&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let file = fnamemodify(expand(&quot;%:p&quot;), &quot;:~&quot;)&#xA;let pwd = system('print -P %~')&#xA;&#xA;hi pwd guifg=#FFFFFF&#xA;hi file guifg=#FFF093 gui=bold&#xA;&#xA;set statusline=&#xA;set statusline+=%#pwd#[%{pwd}/&#xA;set statusline+=%#file#%{file[len(pwd):]}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works …until you switch files, and nothing updates, which makes sense given the above code. I'm just not sure to continue from here. I've tried to wrap the variables inside autocommands for different buffer events, but that doesn't help. Neither does assigning &lt;code&gt;fnamemodify&lt;/code&gt; or &lt;code&gt;system&lt;/code&gt; directly to the statusline, as that gives an error when trying to source my vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thoughts?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ben Knoble has suggested a function returning a string, and that the statusline should simply call that function. This works with the exception of highlight groups now being outputted as just plain strings&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi pwd guifg=#BADA55&#xA;hi file guifg=#FFF093 gui=bold&#xA;&#xA;function! SetStatusLine()&#xA;  return&#xA;    \ &quot;%#pwd#&quot; . system('print -P %~') .&#xA;    \ &quot;%#file#&quot; . fnamemodify(expand(&quot;%:p&quot;), &quot;:~&quot;)[len(system('print -P %~')):]&#xA;endfunction&#xA;&#xA;set statusline=%{SetStatusLine()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The statusline now updates as it should, but highlight groups don't work. My statsline currently shows the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;%#pwd#~%#file#.vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Close! Any other ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;…Minor brainfart, you just use multiple functions for each highlight group. It works now!&lt;/p&gt;&#xA;" OwnerUserId="18541" LastEditorUserId="18541" LastEditDate="2018-08-16T14:57:13.337" LastActivityDate="2020-07-28T22:18:29.603" Title="Statusline – update variables on file change" Tags="|vimscript|autocmd|statusline|variables|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17106" PostTypeId="1" CreationDate="2018-08-16T11:28:00.353" Score="1" ViewCount="1254" Body="&lt;p&gt;I'm running neovim from a uxterm on arch linux with the solarized color scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is that on scrolling only the characters which are non-whitespace are displaying the correct background. &lt;a href=&quot;https://i.stack.imgur.com/y05sj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/y05sj.png&quot; alt=&quot;error screen&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This fixes itself on any redraw of the screen - resizing, etc. However scrolling doesn't fix it (I actually produced this image by getting it to display correctly and the scrolled up).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another issue is that when I close vim the bash terminal's background is white apart from where text is. This issue resolves itself when the background is redrawn - eg switching workspaces in i3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt;&#xA;    &quot; Plugins will be downloaded under the specified directory.&#xA;    call plug#begin('~/.vim/plugged')&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Declare the list of plugins.&#xA;&#xA;&quot; List ends here. Plugins become visible to Vim after this call.&#xA;call plug#end()&#xA;&#xA;syntax on&#xA;&#xA;set noerrorbells&#xA;set novisualbell&#xA;set t_vb=&#xA;set tm=500&#xA;&#xA;set ai&#xA;set smartindent&#xA;&#xA;set shiftwidth=4&#xA;set tabstop=4&#xA;&#xA;if (has(&quot;nvim&quot;))&#xA;  &quot;For Neovim 0.1.3 and 0.1.4 &amp;lt; https://github.com/neovim/neovim/pull/2198 &amp;gt;&#xA;  let $NVIM_TUI_ENABLE_TRUE_COLOR=1&#xA;endif&#xA;&#xA;&quot;For Neovim &amp;gt; 0.1.5 and Vim &amp;gt; patch 7.4.1799 &amp;lt; https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 &amp;gt;&#xA;&quot;Based on Vim patch 7.4.1770 (`guicolors` option) &amp;lt; https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd &amp;gt;&#xA;&quot; &amp;lt; https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 &amp;gt;&#xA;if (has(&quot;termguicolors&quot;))&#xA;  set termguicolors&#xA;endif&#xA;&#xA;set background=dark&#xA;colorscheme onedark &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And my &lt;code&gt;.bashrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# ~/.bashrc: executed by bash(1) for non-login shells.&#xA;# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)&#xA;# for examples&#xA;&#xA;# If not running interactively, don't do anything&#xA;case $- in&#xA;    *i*) ;;&#xA;      *) return;;&#xA;esac&#xA;&#xA;# don't put duplicate lines or lines starting with space in the history.&#xA;# See bash(1) for more options&#xA;HISTCONTROL=ignoreboth&#xA;&#xA;# append to the history file, don't overwrite it&#xA;shopt -s histappend&#xA;&#xA;# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)&#xA;HISTSIZE=1000&#xA;HISTFILESIZE=2000&#xA;&#xA;# check the window size after each command and, if necessary,&#xA;# update the values of LINES and COLUMNS.&#xA;shopt -s checkwinsize&#xA;&#xA;# If set, the pattern &quot;**&quot; used in a pathname expansion context will&#xA;# match all files and zero or more directories and subdirectories.&#xA;#shopt -s globstar&#xA;&#xA;# make less more friendly for non-text input files, see lesspipe(1)&#xA;[ -x /usr/bin/lesspipe ] &amp;amp;&amp;amp; eval &quot;$(SHELL=/bin/sh lesspipe)&quot;&#xA;&#xA;# set variable identifying the chroot you work in (used in the prompt below)&#xA;if [ -z &quot;${debian_chroot:-}&quot; ] &amp;amp;&amp;amp; [ -r /etc/debian_chroot ]; then&#xA;    debian_chroot=$(cat /etc/debian_chroot)&#xA;fi&#xA;&#xA;# set a fancy prompt (non-color, unless we know we &quot;want&quot; color)&#xA;case &quot;$TERM&quot; in&#xA;    xterm-color|*-256color) color_prompt=yes;;&#xA;esac&#xA;&#xA;# uncomment for a colored prompt, if the terminal has the capability; turned&#xA;# off by default to not distract the user: the focus in a terminal window&#xA;# should be on the output of commands, not on the prompt&#xA;#force_color_prompt=yes&#xA;&#xA;if [ -n &quot;$force_color_prompt&quot; ]; then&#xA;    if [ -x /usr/bin/tput ] &amp;amp;&amp;amp; tput setaf 1 &amp;gt;&amp;amp;/dev/null; then&#xA;    # We have color support; assume it's compliant with Ecma-48&#xA;    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such&#xA;    # a case would tend to support setf rather than setaf.)&#xA;    color_prompt=yes&#xA;    else&#xA;    color_prompt=&#xA;    fi&#xA;fi&#xA;&#xA;if [ &quot;$color_prompt&quot; = yes ]; then&#xA;    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '&#xA;else&#xA;    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '&#xA;fi&#xA;unset color_prompt force_color_prompt&#xA;&#xA;# If this is an xterm set the title to user@host:dir&#xA;case &quot;$TERM&quot; in&#xA;xterm*|rxvt*)&#xA;    PS1=&quot;\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1&quot;&#xA;    ;;&#xA;*)&#xA;    ;;&#xA;esac&#xA;&#xA;# enable color support of ls and also add handy aliases&#xA;if [ -x /usr/bin/dircolors ]; then&#xA;    test -r ~/.dircolors &amp;amp;&amp;amp; eval &quot;$(dircolors -b ~/.dircolors)&quot; || eval &quot;$(dircolors -b)&quot;&#xA;    alias ls='ls --color=auto'&#xA;    #alias dir='dir --color=auto'&#xA;    #alias vdir='vdir --color=auto'&#xA;&#xA;    alias grep='grep --color=auto'&#xA;    alias fgrep='fgrep --color=auto'&#xA;    alias egrep='egrep --color=auto'&#xA;fi&#xA;&#xA;# colored GCC warnings and errors&#xA;#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'&#xA;&#xA;# some more ls aliases&#xA;alias ll='ls -alF'&#xA;alias la='ls -A'&#xA;alias l='ls -CF'&#xA;&#xA;# Add an &quot;alert&quot; alias for long running commands.  Use like so:&#xA;#   sleep 10; alert&#xA;alias alert='notify-send --urgency=low -i &quot;$([ $? = 0 ] &amp;amp;&amp;amp; echo terminal || echo error)&quot; &quot;$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&amp;amp;|]\s*alert$//'\'')&quot;'&#xA;&#xA;# Alias definitions.&#xA;# You may want to put all your additions into a separate file like&#xA;# ~/.bash_aliases, instead of adding them here directly.&#xA;# See /usr/share/doc/bash-doc/examples in the bash-doc package.&#xA;&#xA;if [ -f ~/.bash_aliases ]; then&#xA;    . ~/.bash_aliases&#xA;fi&#xA;&#xA;# enable programmable completion features (you don't need to enable&#xA;# this, if it's already enabled in /etc/bash.bashrc and /etc/profile&#xA;# sources /etc/bash.bashrc).&#xA;if ! shopt -oq posix; then&#xA;  if [ -f /usr/share/bash-completion/bash_completion ]; then&#xA;    . /usr/share/bash-completion/bash_completion&#xA;  elif [ -f /etc/bash_completion ]; then&#xA;    . /etc/bash_completion&#xA;  fi&#xA;fi&#xA;&#xA;export PATH=$PATH:~/go/bin&#xA;export PATH=$PATH:/usr/lib/go-1.9/bin&#xA;export GOPATH=~/go&#xA;export GOBIN=$GOPATH/bin&#xA;&#xA;export TERM=xterm-256color&#xA;&#xA;# Add colors to Terminal&#xA;export CLICOLOR=1&#xA;export LSCOLORS=GxFxCxDxBxegedabagaced&#xA;source /usr/share/nvm/init-nvm.sh&#xA;&#xA;alias vim=nvim&#xA;&#xA;export PATH=$PATH:/usr/local/MATLAB/R2018a/bin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18403" LastEditorUserId="10604" LastEditDate="2018-08-16T16:33:22.113" LastActivityDate="2018-08-16T16:33:22.113" Title="Neovim not showing correct background color" Tags="|vimrc|neovim|terminal|linux-arch|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="17107" PostTypeId="1" AcceptedAnswerId="17109" CreationDate="2018-08-16T11:40:54.687" Score="0" ViewCount="279" Body="&lt;p&gt;I have a config file that have placeholder &lt;code&gt;PKG&lt;/code&gt;, in workflow, I need to replace this &lt;code&gt;PKG&lt;/code&gt; with a string but typing &lt;code&gt;:%s/blah/blah/g&lt;/code&gt; cost time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need a quick map key that asks for a string to replace then replace all &lt;code&gt;PKG&lt;/code&gt; with that string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can vim do that? :)&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="1841" LastEditDate="2018-08-16T12:12:48.267" LastActivityDate="2018-08-16T12:12:48.267" Title="Quick find and replace a fixed placeholder" Tags="|key-bindings|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17108" PostTypeId="2" ParentId="16804" CreationDate="2018-08-16T11:41:45.573" Score="4" Body="&lt;p&gt;Actually &lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;asyncrun&lt;/a&gt; has that feature. According to the &lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim#quickfix-window&quot; rel=&quot;nofollow noreferrer&quot;&gt;document&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AsyncRun displays its output in quickfix window, so if you don't use &lt;code&gt;:copen {height}&lt;/code&gt; to open quickfix window, you won't see any output. For convenience there is an option &lt;code&gt;g:asyncrun_open&lt;/code&gt; for you.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you just put this code &lt;code&gt;:let g:asyncrun_open = 8&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you press &lt;code&gt;&amp;lt;leader&amp;gt;m&lt;/code&gt;, &lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;asyncrun&lt;/a&gt; will open quickfix window automatically. &#xA;I've tested that it will only open the quickfix window but still focus you r current window. Enjoy~&lt;/p&gt;&#xA;" OwnerUserId="17515" LastActivityDate="2018-08-16T11:41:45.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17109" PostTypeId="2" ParentId="17107" CreationDate="2018-08-16T12:11:20.487" Score="3" Body="&lt;p&gt;Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;KEY&amp;gt; :%s/PKG//g&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It populates the command line with &lt;code&gt;:%s/PKG//g&lt;/code&gt; with the cursor between &lt;code&gt;//&lt;/code&gt;. You can then simply type the new string and &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-08-16T12:11:20.487" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17110" PostTypeId="1" CreationDate="2018-08-16T13:46:37.893" Score="3" ViewCount="419" Body="&lt;p&gt;Suppose, I have a .jar file &lt;code&gt;a.jar&lt;/code&gt;, which I can view via &lt;code&gt;vim a.jar&lt;/code&gt;, giving a list of the content like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a1.txt&#xA;a2.txt&#xA;b.jar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can press enter and load the content of each file; however, for .jars inside this archive, I am more interested in the content listing than the binary content. In this case, I want enter to show me a similar view of &lt;code&gt;b.jar&lt;/code&gt;, rather than it's binary content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, how can I show list of files of nested .jar files in vim?&lt;/p&gt;&#xA;" OwnerUserId="18630" LastEditorUserId="11357" LastEditDate="2020-09-13T17:48:41.123" LastActivityDate="2022-10-03T22:05:35.667" Title="How to list content of nested jars" Tags="|binary-file|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17111" PostTypeId="2" ParentId="17105" CreationDate="2018-08-16T16:47:32.003" Score="2" Body="&lt;p&gt;Finally got it going thanks to some simple functions!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi pwd guifg=#BADA55&#xA;hi file guifg=#FFF093 gui=bold&#xA;hi line guifg=#FFFFFF&#xA;hi statuslinenc gui=none&#xA;hi statusline gui=none&#xA;&#xA;function! SetStatusLinePath()&#xA;     return system('print -P %~')[:-2] . &quot;/&quot;&#xA;endfunction&#xA;&#xA;function! SetStatusLineFile()&#xA;     return fnamemodify(expand(&quot;%:p&quot;), &quot;:~&quot;)[len(system('print -P %~')):]&#xA;endfunction&#xA;&#xA;set statusline=–––⎜&#xA;set statusline+=%#pwd#%{SetStatusLinePath()}&#xA;set statusline+=%#file#%{SetStatusLineFile()}&#xA;set statusline+=%#line#⎟&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's a picture of my statusline as of now, just to visually show what I was trying to accomplish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qWDBn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qWDBn.png&quot; alt=&quot;Statusline-picture&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18541" LastActivityDate="2018-08-16T16:47:32.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17113" PostTypeId="1" AcceptedAnswerId="17114" CreationDate="2018-08-16T22:20:53.227" Score="2" ViewCount="502" Body="&lt;p&gt;I love the keybindings &lt;code&gt;zt&lt;/code&gt; &lt;code&gt;zb&lt;/code&gt; and &lt;code&gt;zz&lt;/code&gt;. They redraw the current window such that your cursor stays at the same place in the document, but it moves on your screen. The cursor will now be at the &lt;strong&gt;t&lt;/strong&gt;op, the &lt;strong&gt;b&lt;/strong&gt;ottom, or, well, ..., the &lt;strong&gt;z&lt;/strong&gt;enter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the same keybings exist for horizontal movement?&lt;/p&gt;&#xA;" OwnerUserId="6154" LastActivityDate="2018-08-17T00:32:58.430" Title="zt for horizontal scrolling" Tags="|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17114" PostTypeId="2" ParentId="17113" CreationDate="2018-08-17T00:32:58.430" Score="5" Body="&lt;p&gt;I think &lt;code&gt;zs&lt;/code&gt; and &lt;code&gt;ze&lt;/code&gt; may be helpful. Try &lt;code&gt;help: zs&lt;/code&gt; &lt;code&gt;help ze&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                    zs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;zs&lt;/code&gt;                      Scroll the text horizontally to position the cursor&#xA;                          at the start (left side) of the screen.  This only&#xA;                          works when 'wrap' is off.  {not in Vi}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                    ze&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;ze&lt;/code&gt;                      Scroll the text horizontally to position the cursor&#xA;                          at the end (right side) of the screen.  This only&#xA;                          works when 'wrap' is off.  {not in Vi}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Additionally, these two commands let the cursor still stay at the original place in the text.&lt;/p&gt;&#xA;" OwnerUserId="17515" LastActivityDate="2018-08-17T00:32:58.430" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17115" PostTypeId="1" CreationDate="2018-08-17T01:14:28.087" Score="1" ViewCount="336" Body="&lt;p&gt;When navigating in normal mode by &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt;, I want to skip commented lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible? Is there a vimscript snippet for that?&lt;/p&gt;&#xA;" OwnerUserId="18467" LastActivityDate="2018-08-17T11:48:04.433" Title="how to skip commented lines when navigating?" Tags="|key-bindings|navigation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17116" PostTypeId="1" AcceptedAnswerId="17127" CreationDate="2018-08-17T03:31:49.703" Score="0" ViewCount="463" Body="&lt;p&gt;I need to match &lt;code&gt;Issue&lt;/code&gt; in &lt;code&gt;.conf&lt;/code&gt; filetype and highlight it with custom color but set in mode line instead of a fix in &lt;code&gt;syntax/conf.vim&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use-case is for each kind of document I need to highlight a specific pattern, &lt;code&gt;Issue&lt;/code&gt; in this file, and other may be &lt;code&gt;NOTE&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2018-08-17T19:30:12.287" Title="Match pattern and highlight it in modeline for a specific filetype" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17117" PostTypeId="1" AcceptedAnswerId="17125" CreationDate="2018-08-17T05:27:10.280" Score="1" ViewCount="767" Body="&lt;p&gt;I guess many of you are like me, and even if they have been using ViM for years, still learn new features regularly. The last that I learned was &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:diffp[atch] patch/name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I want to combine it with git to compare the current version and a previous version. I can do, from ViM,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!git diff &amp;lt;hash&amp;gt; filename &amp;gt; git.patch&#xA;:vert diffp git.patch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ViM will automatically recognise the direction of the patch, and I get to see the older file as a temporary file (&lt;code&gt;/tmp/file&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I have tried to get that in a single command, without having to write a patch file. In particular, I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vert diffp &amp;lt; git diff &amp;lt;hash&amp;gt; filename&#xA;:vert diffp `&amp;lt; git diff &amp;lt;hash&amp;gt; filename`&#xA;:vert diffp `git diff &amp;lt;hash&amp;gt; filename`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but to no success. Is it at all possible, and if it is, how should one do it?&lt;/p&gt;&#xA;" OwnerUserId="2170" LastActivityDate="2018-08-17T20:28:29.253" Title="diffpatch using the output of git diff directly" Tags="|vimdiff|git|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17118" PostTypeId="2" ParentId="13581" CreationDate="2018-08-17T05:40:30.080" Score="0" Body="&lt;h3&gt;Plugin &lt;a href=&quot;https://github.com/andymass/vim-matchup&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-matchup&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Mass has written the plugin &lt;em&gt;match-up&lt;/em&gt; which allows you to press:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;v&lt;/code&gt; &lt;code&gt;a%&lt;/code&gt; &lt;code&gt;a%&lt;/code&gt; &lt;code&gt;a%&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/O54pB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/O54pB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4BXLQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4BXLQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Mdtey.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Mdtey.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/TU411.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TU411.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there are many more plugins which provide a single command to expand over different types of brackets:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/terryma/vim-expand-region&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-expand-region&lt;/a&gt; &lt;code&gt;+++&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/gcmt/wildfire.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;wildfire.vim&lt;/a&gt; &lt;code&gt;&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/machakann/vim-sandwich&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sandwich&lt;/a&gt; &lt;code&gt;vababab&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/gorkunov/smartpairs.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;smartpairs.vim&lt;/a&gt; &lt;code&gt;vavavav&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/machakann/vim-textobj-delimited&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-delimited&lt;/a&gt; &lt;code&gt;vadadad&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A &lt;a href=&quot;https://github.com/AlDanial/cloc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;cloc&lt;/em&gt;&lt;/a&gt; comparison if you look for a lightweight plugin&#xA;&lt;a href=&quot;https://i.stack.imgur.com/rxD6X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rxD6X.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;(code size by number of source code and comment lines)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note plugins which depend on &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-user&lt;/a&gt; cannot be expanded, e.g. &lt;a href=&quot;https://github.com/rhysd/vim-textobj-anyblock&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-anyblock&lt;/a&gt;. This is documented under &lt;a href=&quot;https://github.com/kana/vim-textobj-user/blob/master/doc/textobj-user.txt#L543-L548&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h textobj-user-known-issues&lt;/code&gt;&lt;/a&gt; (second item).&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-08-17T08:21:16.953" LastActivityDate="2018-08-17T08:21:16.953" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17120" PostTypeId="2" ParentId="17115" CreationDate="2018-08-17T09:49:44.187" Score="1" Body="&lt;p&gt;Firstly I think it would be important that you learn how to move around with motions other than &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt;. Being able to use wide range motions, marks and tags is a good way to avoid comments and move efficiently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can use the following function and mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyVerticalMotions(up)&#xA;    &quot; Get the motion to execute based on the parameter&#xA;    let motion = a:up ? &quot;k&quot; : &quot;j&quot;&#xA;&#xA;    &quot; Execute the original motion&#xA;    execute &quot;normal! &quot; . motion&#xA;&#xA;    &quot; Repeat until we are not on a comment anymore or we reached the end of the buffer&#xA;    while synIDattr(synIDtrans(synID(line(&quot;.&quot;),col(&quot;.&quot;),1)),&quot;name&quot;) == &quot;Comment&quot; &amp;amp;&amp;amp; line('.') &amp;lt; line('$') &amp;amp;&amp;amp; line('.') &amp;gt; 1&#xA;        execute &quot;normal! &quot; . motion&#xA;    endwhile&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; j :call MyVerticalMotions(0)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; k :call MyVerticalMotions(1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function takes one argument indicating if you want to move up or down, it will then repeat &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt; until the current line is not a comment or you reach the top or the bottom of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mappings simply call the function with the correct parameter. Also, you can still use &lt;code&gt;gj&lt;/code&gt; and &lt;code&gt;gk&lt;/code&gt; if you want to move on the comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used &lt;a href=&quot;http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor&quot; rel=&quot;nofollow noreferrer&quot;&gt;this Wikia post&lt;/a&gt; to get the syntax group of the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I tested this code quickly on a Vimscript file and a JS file and it seems like it's working but I may have forgotten some edge cases.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-08-17T11:48:04.433" LastActivityDate="2018-08-17T11:48:04.433" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17121" PostTypeId="1" CreationDate="2018-08-17T10:47:59.530" Score="2" ViewCount="4677" Body="&lt;p&gt;I use vim a lot to edit tex files. &#xA;When I have lines spanning multiple display lines, most of the time I want to navigate through them with &lt;code&gt;gj&lt;/code&gt; not &lt;code&gt;j&lt;/code&gt; (i.e. according to displayed lines, not physical lines).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried putting the following lines in my &lt;code&gt;.vimrc&lt;/code&gt; but, not surprisingly, got an error message &lt;code&gt;recursive mapping&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap j gj&#xA;nmap gj j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I properly swap the effects of two commands?&lt;/p&gt;&#xA;" OwnerUserId="18613" LastActivityDate="2018-08-17T20:41:21.407" Title="Swap `j` and `gj`" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ClosedDate="2018-08-17T17:30:56.123" ContentLicense="CC BY-SA 4.0" />
  <row Id="17123" PostTypeId="2" ParentId="17121" CreationDate="2018-08-17T11:21:20.803" Score="4" Body="&lt;p&gt;There are a couple of ways you can do this. My first thought was to do it this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap j :normal! gj&amp;lt;CR&amp;gt;&#xA;nnoremap gj :normal! j&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Call the original &lt;code&gt;gj&lt;/code&gt; or &lt;code&gt;j&lt;/code&gt; using normal mode; the exclamation mark prevents them from being associated with any current mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help normal&lt;/code&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simpler method was provided in the comments by &lt;a href=&quot;https://vi.stackexchange.com/users/1841/statox&quot;&gt;@statox&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap j gj&#xA;nnoremap gj j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A non-recursive mapping is also prevented from being recognised during subsequent mappings.&lt;/p&gt;&#xA;" OwnerUserId="18583" LastEditorUserId="18583" LastEditDate="2018-08-17T20:41:21.407" LastActivityDate="2018-08-17T20:41:21.407" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17124" PostTypeId="1" CreationDate="2018-08-17T13:21:56.603" Score="2" ViewCount="118" Body="&lt;p&gt;Is it possible to override an autoloaded plugin-function? I want to customize an &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;nofollow noreferrer&quot;&gt;airline&lt;/a&gt;-internal function just like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diff --git a/autoload/airline/extensions/default.vim b/autoload/airline/extensions/default.vim&#xA;index f9ca3d4..8ce3b00 100644&#xA;--- a/autoload/airline/extensions/default.vim&#xA;+++ b/autoload/airline/extensions/default.vim&#xA;@@ -92,7 +92,7 @@ function! airline#extensions#default#apply(builder, context)&#xA;&#xA;   call a:builder.split(s:get_section(winnr, 'gutter', '', ''))&#xA;&#xA;-  if airline#util#getwinvar(winnr, 'airline_render_right', 1)&#xA;+  if airline#util#getwinvar(winnr, 'airline_render_right', active)&#xA;     call s:build_sections(a:builder, a:context, s:layout[1])&#xA;   endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sure, I could fork the plugin and customize it, but is there also slim, vim-like solution I can simply apply to my &lt;code&gt;vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="18642" LastActivityDate="2018-08-17T13:21:56.603" Title="Monkey-patch plugin function" Tags="|vimscript|functions|plugin-airline|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17125" PostTypeId="2" ParentId="17117" CreationDate="2018-08-17T14:17:15.507" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Now, I want to combine it with git to compare the current version and a previous version.&lt;/p&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;Now, I have tried to get that in a single command, without having to write a patch file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You can easily create a custom command to do this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=? PreviousVersion diffthis |&#xA;      \ vnew |&#xA;      \ set buftype=nofile |&#xA;      \ set bufhidden=wipe |&#xA;      \ set noswapfile |&#xA;      \ execute &amp;quot;r!git show &amp;quot;.(!&amp;quot;&amp;lt;args&amp;gt;&amp;quot;?'head^':&amp;quot;&amp;lt;args&amp;gt;&amp;quot;).&amp;quot;:&amp;quot;.expand('#') |&#xA;      \ 1d_ |&#xA;      \ let &amp;amp;filetype=getbufvar('#', '&amp;amp;filetype') |&#xA;      \ execute 'autocmd BufWipeout &amp;lt;buffer&amp;gt; diffoff!' |&#xA;      \ diffthis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can now do &lt;code&gt;:PreviousVersion&lt;/code&gt; to get the changes between the current buffer and the last commit (&lt;code&gt;head^&lt;/code&gt;) or some arbitrary revision, e.g. &lt;code&gt;:PreviousVersion {revision}&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note: you may want to use &lt;code&gt;&amp;lt;mods&amp;gt;&lt;/code&gt; and &lt;code&gt;:new&lt;/code&gt; if you want more control over the splitting.&lt;/p&gt;&#xA;&lt;h3&gt;Fugitive.vim&lt;/h3&gt;&#xA;&lt;p&gt;Alternatively, I would recommend using &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow noreferrer&quot;&gt;fugitive.vim&lt;/a&gt;'s &lt;code&gt;:Gdiff&lt;/code&gt; command.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I'm not going to lie to you; fugitive.vim may very well be the best Git wrapper of all time.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Use &lt;code&gt;:Gvdiff&lt;/code&gt; to do the &lt;code&gt;:Gdiff&lt;/code&gt; vertically.&lt;/p&gt;&#xA;&lt;p&gt;Diff between the current file and the previous commit&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Gdiff head^&#xA;:Gvdiff head^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Diff between current file and the index&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Gdiff :0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Diff between current file and some other [revision]&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Gdiff [revision]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Diff between current file and current file 3 commits ago:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Gdiff ~3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;While &lt;code&gt;:Gdiff&lt;/code&gt; is useful, I find &lt;code&gt;:Gblame&lt;/code&gt; to be more useful. I can &amp;quot;re-blame&amp;quot; at on a certain line or open a commit to see the patch. This article explains how useful &lt;code&gt;git blame&lt;/code&gt; can be: &lt;a href=&quot;https://mislav.net/2014/02/hidden-documentation/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Every line of code is always documented&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Vimcasts&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimcasts.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimcasts&lt;/a&gt; has a &lt;a href=&quot;http://vimcasts.org/blog/2011/05/the-fugitive-series/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fugitive series&lt;/a&gt; which I highly recommend. I would suggest looking at episodes: &lt;a href=&quot;http://vimcasts.org/e/32&quot; rel=&quot;nofollow noreferrer&quot;&gt;Working with the git index&lt;/a&gt; and &lt;a href=&quot;http://vimcasts.org/episodes/fugitive-vim-resolving-merge-conflicts-with-vimdiff/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Resolving merge conflicts with vimdiff&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;For more help see&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;:h :diffthis&#xA;:h :vnew&#xA;:h :execute&#xA;:h :read&#xA;:h :delete&#xA;:h :_#&#xA;:h expand()&#xA;:h fugitive-:Gdiff&#xA;:h fugitive-revision&#xA;:h fugitive-:Gblame&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-08-17T20:28:29.253" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17127" PostTypeId="2" ParentId="17116" CreationDate="2018-08-17T19:30:12.287" Score="2" Body="&lt;p&gt;There is no way to do this using modelines, but based on the &lt;a href=&quot;/questions/tagged/vimrc&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;vimrc&amp;#39;&quot; rel=&quot;tag&quot;&gt;vimrc&lt;/a&gt; tag, I assume a solution that involves adding code to your &lt;code&gt;.vimrc&lt;/code&gt; is acceptable. If so, you could try something like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;function! s:confhighlight()&#xA;    let l:matches = matchlist(getline('$'), '^# highlight: \(.*\)$')&#xA;    if len(l:matches)&#xA;        let s:matchid = matchadd('Todo', l:matches[1])&#xA;    endif&#xA;endfunction&#xA;&#xA;function! s:confunhighlight()&#xA;    if exists('s:matchid')&#xA;        call matchdelete(s:matchid)&#xA;        unlet s:matchid&#xA;    endif&#xA;endfunction&#xA;&#xA;augroup confhighlight&#xA;    autocmd!&#xA;    au BufEnter *.conf call s:confhighlight()&#xA;    au BufLeave *.conf call s:confunhighlight()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will search for a line matching the pattern &lt;code&gt;# highlight: foo&lt;/code&gt; at the bottom of every .conf file, and highlight &lt;code&gt;foo&lt;/code&gt; within that file if such a line is found. (Note that this treats &lt;code&gt;foo&lt;/code&gt; as a case-sensitive regex pattern.)&lt;/p&gt;&#xA;" OwnerUserId="88" LastActivityDate="2018-08-17T19:30:12.287" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17128" PostTypeId="1" AcceptedAnswerId="31804" CreationDate="2018-08-17T22:44:34.453" Score="2" ViewCount="1380" Body="&lt;p&gt;When working in the C language, sometimes you have to write multi line macros like the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SOME_FUNCTION_LIKE_MACRO(a,b)     \&#xA;   foo(a);                                \&#xA;   bar(b);                                \&#xA;   baz(a+b);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typically, after a few iterations of editing your code, the backslashes end up unaligned like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SOME_FUNCTION_LIKE_MACRO(a,b)             \&#xA;   foo(a);                 \&#xA;   bar(b);                                  \&#xA;   baz(a+b);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it drives me crazy. I always end up wasting a lot of time manually aligning them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin/mapping/function/whatever for automatically aligning the line continuation characters? Something like select lines in visual line mode, hit a key combination and voila, you have aligned backslashes at the end. &lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2021-07-10T06:50:58.443" Title="Working with line continuations (\)." Tags="|alignment|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17129" PostTypeId="2" ParentId="17128" CreationDate="2018-08-17T23:16:16.093" Score="1" Body="&lt;p&gt;I came up with this a few minutes after asking the question here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You hit  if you want to add backslashes at the end of a line, or multiple selected lines. You hit \ if you want to align all backslashes in the whole file or in the selected lines. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Aligns backslash characters at the end of lines. &#xA;&quot; Useful when writing multiline macros or multiline strings.&#xA;function AlignBackslash()&#xA;  :silent! s@\s\+\\$@ \\@&#xA;  :silent! s/s*\\$/\=repeat(' ', 80-col('.')).'\'&#xA;  :let @/ = &quot;&quot;&#xA;endfunction&#xA;&#xA;function RemoveDuplicateBackslash()&#xA;  :silent! s/\\\\$/\\/g&#xA;endfunction&#xA;&#xA;&quot; In normal mode align the whole file. &#xA;nmap \\ mxggVG:call RemoveDuplicateBackslash()&amp;lt;cr&amp;gt;ggVG:call AlignBackslash()&amp;lt;cr&amp;gt;'x&#xA;&#xA;&quot; In visual select mode align selected lines.&#xA;vmap \\ :call RemoveDuplicateBackslash()&amp;lt;cr&amp;gt;gv:call AlignBackslash()&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; Insert backslash at the end of current line and align it&#xA;nmap &amp;lt;c-\&amp;gt; A\&amp;lt;esc&amp;gt;:call AlignBackslash()&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; Insert backslash at the end of selected lines and align them&#xA;vmap &amp;lt;c-\&amp;gt; :norm A\&amp;lt;esc&amp;gt;gv:call AlignBackslash()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2018-08-17T23:16:16.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17130" PostTypeId="2" ParentId="17128" CreationDate="2018-08-18T09:15:29.367" Score="5" Body="&lt;h2&gt;Plugin &lt;a href=&quot;https://github.com/tommcdo/vim-lion&quot; rel=&quot;noreferrer&quot;&gt;vim-lion&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;by Tom McDonald&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install and add following line to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:lion_squeeze_spaces = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can change &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SOME_FUNCTION_LIKE_MACRO(a,b)             \&#xA;   foo(a);                 \&#xA;   bar(b);                                  \&#xA;   baz(a+b);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by pressing &lt;code&gt;glip\&lt;/code&gt; to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SOME_FUNCTION_LIKE_MACRO(a,b) \&#xA;   foo(a);                            \&#xA;   bar(b);                            \&#xA;   baz(a+b);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Alternatives to vim-lion&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim-lion is a very small plugin (190 sloc) and has a few limitations (see example given by the plugin &lt;em&gt;Align&lt;/em&gt;). There are more feature rich alternatives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/junegunn/vim-easy-align&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;vim-easy-align&lt;/strong&gt;&lt;/a&gt; (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4520&quot; rel=&quot;noreferrer&quot;&gt;#4520&lt;/a&gt;) by Junegunn Choi. It has no default rule for &lt;code&gt;\&lt;/code&gt;. However, it is not difficult to define one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:easy_align_delimiters = {&#xA;  \ '\': {&#xA;  \     'pattern': '\\$',&#xA;  \ },&#xA;  \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the default mapping &lt;code&gt;ga&lt;/code&gt; you can re-align your code now with &lt;code&gt;gaip\&lt;/code&gt;. Note, &lt;code&gt;ga&lt;/code&gt; overwrites a builtin mapping (&lt;code&gt;:h ga&lt;/code&gt;) (and competes with &lt;a href=&quot;https://github.com/tpope/vim-characterize&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;vim-characterize&lt;/em&gt;&lt;/a&gt;). The choice &lt;code&gt;gl&lt;/code&gt; of vim-lion might be better:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xmap gl &amp;lt;Plug&amp;gt;(EasyAlign)&#xA;nmap gl &amp;lt;Plug&amp;gt;(EasyAlign)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/godlygeek/tabular&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;Tabular&lt;/strong&gt;&lt;/a&gt; by Matt Wozniski.  By default no mappings exist, only the command &lt;code&gt;:Tab[ularize] /\\$&amp;lt;CR&amp;gt;&lt;/code&gt;. Note that you do not need a visual selection or to specify a range before &lt;code&gt;:[range]Tab[ularize]&lt;/code&gt; (but you can), &lt;em&gt;Tabular&lt;/em&gt; tries to be smart to figure out the correct range (&lt;code&gt;:h :Tabularize&lt;/code&gt;). See e.g. this &lt;a href=&quot;http://vimcasts.org/episodes/aligning-text-with-tabular-vim/&quot; rel=&quot;noreferrer&quot;&gt;vimcast&lt;/a&gt; for an introduction and suggestions for mappings. You can also use following from the plugin &lt;em&gt;Align&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;:Tabularize&quot;)&#xA;  nmap &amp;lt;Leader&amp;gt;tml :Tabularize /\\$&amp;lt;CR&amp;gt;&#xA;  vmap &amp;lt;Leader&amp;gt;tml :Tabularize /\\$&amp;lt;CR&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://drchip.org/astronaut/vim/index.html#ALIGN&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;Align&lt;/strong&gt;&lt;/a&gt; (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=294&quot; rel=&quot;noreferrer&quot;&gt;#294&lt;/a&gt;) by DrChip (Charles Campbell) with default mapping &lt;code&gt;\tml&lt;/code&gt;. From the documentation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Original:  illustrates aligning multi-line continuation marks&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;one \&#xA;two three \&#xA;four five six \&#xA;seven \\ \&#xA;eight \nine \&#xA;ten \&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;one           \&#xA;two three     \&#xA;four five six \&#xA;seven \\      \&#xA;eight \nine   \&#xA;ten           \&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, vim-lion struggles with this example. My &lt;code&gt;vim-easy-align&lt;/code&gt; and &lt;code&gt;Tabular&lt;/code&gt; proposals work fine.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I personally use &lt;code&gt;vim-easy-align&lt;/code&gt; with the mapping &lt;code&gt;gl&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-08-18T11:45:43.963" LastActivityDate="2018-08-18T11:45:43.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17131" PostTypeId="2" ParentId="5723" CreationDate="2018-08-18T11:48:41.453" Score="30" Body="&lt;p&gt;As akshay pointed out, Vim's documentation explains, that &lt;code&gt;:x&lt;/code&gt; and &lt;code&gt;ZZ&lt;/code&gt; are equivalent and only save a file if the associated buffer has been changed. &#xA;Whereas &lt;code&gt;:wq&lt;/code&gt; saves the buffer to the corresponding file, even if it is unchanged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In both cases, the contents of the buffer will be saved to disk. Obviously the outcome is the same, so why bother, right? But wait... There is a subtle, but not irrelevant difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you exit Vim via &lt;code&gt;:x&lt;/code&gt; and there has been no change to the buffer, there will be no change to the modification time of that file. On the other hand, if you quit via &lt;code&gt;:wq&lt;/code&gt;, the modification time will change, as the file is technically rewritten (saved again).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can have some impact in certain situations. For example a backup process that is dependent on modification time, could store this file (and potentially send it over the network) even if no additional information has been included. Or some monitoring process could ring an alarm if it detects that (for it) the file has been changed...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I forgot to mention, in order to leave an modified buffer/file without changing the modification time, a &lt;code&gt;:q&lt;/code&gt; (without the &lt;code&gt;w&lt;/code&gt;) will work, too.&lt;/p&gt;&#xA;" OwnerUserId="18646" LastEditorUserId="18646" LastEditDate="2018-08-19T07:26:50.417" LastActivityDate="2018-08-19T07:26:50.417" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="17133" PostTypeId="1" CreationDate="2018-08-18T22:39:14.003" Score="3" ViewCount="782" Body="&lt;p&gt;I'm using &lt;code&gt;flake8&lt;/code&gt; to check my code with &lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ale&lt;/a&gt; plugin. I found a way to make it work with Python 3, but it seems it does not recognize Cython file (&lt;code&gt;.pyx&lt;/code&gt;) even if we set as follows.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_linters = {&#xA;\   'cython': ['flake8']&#xA;\}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_command_wrapper = &quot;source activate py36; %* --filetype=*.py,*.pyx &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way to set it?&lt;/p&gt;&#xA;" OwnerUserId="18649" LastActivityDate="2024-03-20T17:03:45.487" Title="Use flake8 for Cython with w0rp/ale" Tags="|plugin-ale|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17134" PostTypeId="2" ParentId="17133" CreationDate="2018-08-19T03:38:45.730" Score="0" Body="&lt;p&gt;I have never worked on cython, so really don't know if it has a different syntax or something. If the syntax is the same as python, it should be as easy as telling vim to interpret the cython file as a normal python file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set filetype=python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, instead of setting the filetype on each file, you can define an autocommand in your vimrc as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocommand BufEnter *.pyx setlocal filetype=python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18087" LastActivityDate="2018-08-19T03:38:45.730" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17135" PostTypeId="2" ParentId="15090" CreationDate="2018-08-19T05:47:45.700" Score="4" Body="&lt;p&gt;If you want to turn off this behavior in general, add following to your vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:tex_no_error=1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation found under &lt;code&gt;:h g:tex_no_error&lt;/code&gt;: is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                    *tex-error* *g:tex_no_error*&#xA; Tex: Excessive Error Highlighting?&#xA;&#xA;The &amp;lt;tex.vim&amp;gt; supports lexical error checking of various sorts.  Thus,&#xA;although the error checking is ofttimes very useful, it can indicate&#xA;errors where none actually are.  If this proves to be a problem for you,&#xA;you may put in your &amp;lt;.vimrc&amp;gt; the following statement: &amp;gt;&#xA;    let g:tex_no_error=1&#xA;and all error checking by &amp;lt;syntax/tex.vim&amp;gt; will be suppressed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2018-08-19T05:47:45.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17136" PostTypeId="1" AcceptedAnswerId="17173" CreationDate="2018-08-19T08:52:51.953" Score="3" ViewCount="1313" Body="&lt;p&gt;I began to get the error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing BufRead Auto commands for &quot;*.sh&quot;:&#xA;E117: Unknown function: dist#ft#SetFileTypeSH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I opened shell scripts (*.sh)&#xA;I think it happened after updating from a 7.x version to 8.0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can it be fixed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As suggested, I did a search for the function in &lt;code&gt;/usr/share/vim/vim80/autoload/dist/ft.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Called from filetype.vim and scripts.vim.&#xA;func dist#ft#SetFileTypeSH(name)&#xA;  if expand(&quot;&amp;lt;amatch&amp;gt;&quot;) =~ g:ft_ignore_pat&#xA;    return&#xA;  endif&#xA;  if a:name =~ '\&amp;lt;csh\&amp;gt;'&#xA;    &quot; Some .sh scripts contain #!/bin/csh.&#xA;    call dist#ft#SetFileTypeShell(&quot;csh&quot;)&#xA;    return&#xA;  elseif a:name =~ '\&amp;lt;tcsh\&amp;gt;'&#xA;    &quot; Some .sh scripts contain #!/bin/tcsh.&#xA;    call dist#ft#SetFileTypeShell(&quot;tcsh&quot;)&#xA;    return&#xA;  elseif a:name =~ '\&amp;lt;zsh\&amp;gt;'&#xA;    &quot; Some .sh scripts contain #!/bin/zsh.&#xA;    call dist#ft#SetFileTypeShell(&quot;zsh&quot;)&#xA;    return&#xA;  elseif a:name =~ '\&amp;lt;ksh\&amp;gt;'&#xA;    let b:is_kornshell = 1&#xA;    if exists(&quot;b:is_bash&quot;)&#xA;      unlet b:is_bash&#xA;    endif&#xA;    if exists(&quot;b:is_sh&quot;)&#xA;      unlet b:is_sh&#xA;    endif&#xA;  elseif exists(&quot;g:bash_is_sh&quot;) || a:name =~ '\&amp;lt;bash\&amp;gt;' || a:name =~ '\&amp;lt;bash2\&amp;gt;'&#xA;    let b:is_bash = 1&#xA;    if exists(&quot;b:is_kornshell&quot;)&#xA;      unlet b:is_kornshell&#xA;    endif&#xA;    if exists(&quot;b:is_sh&quot;)&#xA;      unlet b:is_sh&#xA;    endif&#xA;  elseif a:name =~ '\&amp;lt;sh\&amp;gt;'&#xA;    let b:is_sh = 1&#xA;    if exists(&quot;b:is_kornshell&quot;)&#xA;      unlet b:is_kornshell&#xA;    endif&#xA;    if exists(&quot;b:is_bash&quot;)&#xA;      unlet b:is_bash&#xA;    endif&#xA;  endif&#xA;  call dist#ft#SetFileTypeShell(&quot;sh&quot;)&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is anything wrong with it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also noticed that syntax highlighting stopped working too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed that if I don't use the session file vim can open shell scripts without errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the session file is the culprit. There must be some backwards compatibility problems between versions 8 and 7 as the session file worked fine in VIM 7. But how to locate the error... I don't want to create the session file from scratch.&lt;/p&gt;&#xA;" OwnerUserId="18651" LastEditorUserId="18651" LastEditDate="2018-08-25T09:11:39.593" LastActivityDate="2018-09-27T01:38:59.307" Title="Error when opening shell scripts" Tags="|bash|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17137" PostTypeId="1" CreationDate="2018-08-19T12:32:26.070" Score="0" ViewCount="100" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fyP3X.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fyP3X.jpg&quot; alt=&quot;example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;now the cursorline leaves a hideous gap between the number column and the wrapped text, is there any way or trick to make the cursorline take care of the whole part of the wrapped line including the visual tabs generated by &lt;code&gt;'breakindent'&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="18254" LastEditorUserId="18254" LastEditDate="2018-08-19T23:51:56.803" LastActivityDate="2018-08-23T09:27:46.077" Title="Is there anyway to let cursorline take care of the visual tabs generated by 'breakindent'?" Tags="|wrapping|cursorline|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17140" PostTypeId="1" AcceptedAnswerId="17142" CreationDate="2018-08-20T04:56:19.137" Score="2" ViewCount="1404" Body="&lt;p&gt;When we call &lt;code&gt;:Gdiff&lt;/code&gt; on a file, fugitive will create a buffer with a name &lt;code&gt;fugitive:///path/to/file/&lt;/code&gt;. The &lt;code&gt;modifiable&lt;/code&gt; option is off and &lt;code&gt;readonly&lt;/code&gt; option is on. Most importantly, the file does not exist on the disk so that the function &lt;code&gt;filereadonly(FILENAME)&lt;/code&gt; returns false. How to setup such a temporary file? &lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-08-20T16:10:04.447" Title="how to create a buffer like a fugitive temporary buffer" Tags="|buffers|plugin-fugitive|scratch-buffer|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17142" PostTypeId="2" ParentId="17140" CreationDate="2018-08-20T11:50:03.463" Score="4" Body="&lt;p&gt;You can create a buffer like this with the &lt;code&gt;'buftype'&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set buftype=nofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27buftype%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'buftype'&lt;/code&gt;&lt;/a&gt; explains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The value of this option specifies the type of a buffer:&#xA;&#xA;  &amp;lt;empty&amp;gt;       normal buffer&#xA;  nofile        buffer which is not related to a file and will not be&#xA;                written&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help special-buffers&lt;/code&gt; for more background on this and other, related, options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.B. As far as I can tell, the fugitive plugin doesn't actually set this value of &lt;code&gt;'buftype'&lt;/code&gt; anywhere. It does use &lt;code&gt;buftype=nowrite&lt;/code&gt; in a few places but not, for me, in the &lt;code&gt;:Gdiff&lt;/code&gt; buffer. (But then, for me, it also doesn't set &lt;code&gt;'nomodifiable'&lt;/code&gt; or &lt;code&gt;'readonly'&lt;/code&gt; as you describe in your question, so possibly you're just using a different version.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-08-20T16:10:04.447" LastActivityDate="2018-08-20T16:10:04.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17145" PostTypeId="2" ParentId="17003" CreationDate="2018-08-20T18:28:13.903" Score="1" Body="&lt;p&gt;&quot;return + shift&quot; (AKA &lt;code&gt;&amp;lt;S-Enter&amp;gt;&lt;/code&gt;) cannot be mapped in Nvim, unless you're using a GUI that captures &quot;shift&quot; and separately. But &quot;alt + return&quot; (&lt;code&gt;&amp;lt;A-Enter&amp;gt;&lt;/code&gt;) can be mapped.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;A-Enter&amp;gt; &amp;lt;C-e&amp;gt;&amp;lt;Enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="578" LastActivityDate="2018-08-20T18:28:13.903" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17146" PostTypeId="2" ParentId="13279" CreationDate="2018-08-20T18:48:54.450" Score="2" Body="&lt;p&gt;It is not entirely clear from your question+comments if you want to remove the original control sequences bofore applying syntax highlighting in vim. Here are some solutions/alternatives.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;From inside the editor:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/neovim/neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neovim&lt;/a&gt; ships with a &lt;code&gt;:Man&lt;/code&gt; command that displays man pages and does all the magic for you. (This one removes the original control characters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For plain vim you might use a plugin like &lt;a href=&quot;https://github.com/vim-utils/vim-man&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-man&lt;/a&gt; to achive the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;From the command line:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use vim or neovim as a pager from the command line you can use &lt;a href=&quot;https://github.com/rkitover/vimpager&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimpager&lt;/a&gt; or &lt;a href=&quot;https://github.com/lucc/nvimpager&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvimpager&lt;/a&gt;.  Both can handle and highlight man pages by default (nvimpager relies on the code from neovim for that).  Vimpager works with vim and neovim, nvimpager is faster but only for neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Disclosure: I am the developer of &lt;a href=&quot;https://github.com/lucc/nvimpager&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvimpager&lt;/a&gt; and have also helped in development with &lt;a href=&quot;https://github.com/rkitover/vimpager&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimpager&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;DIY:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can look up the implementation in &lt;a href=&quot;https://github.com/neovim/neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neovim&lt;/a&gt; or &lt;a href=&quot;https://github.com/vim-utils/vim-man&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-man&lt;/a&gt; to see how they do it and adapt to your needs.&lt;/p&gt;&#xA;" OwnerUserId="18062" LastActivityDate="2018-08-20T18:48:54.450" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17147" PostTypeId="2" ParentId="137" CreationDate="2018-08-20T19:36:00.580" Score="3" Body="&lt;p&gt;@Martin's self-answer is correct. A variation though, for people like myself who try to limit populating their &lt;code&gt;vimrc&lt;/code&gt; file with &lt;strong&gt;occasional exceptions&lt;/strong&gt; -- here editing a crontab, is to use modelines. This allows to place the exceptions directly in the target file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is my crontab modeline:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;# vim: nu et tw=130 ts=8 sts=4 sw=4 ff=unix fo-=l fo+=tcroq2 bkc=yes&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The important bit here is the &lt;code&gt;bkc=yes&lt;/code&gt; which matches @Martin's &lt;code&gt;vimrc&lt;/code&gt; configuration. The rest are personal convenience settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This said for completeness and food for thought, @Martin's initial answer is the most adequate in the majority of cases.&lt;/p&gt;&#xA;" OwnerUserId="17308" LastActivityDate="2018-08-20T19:36:00.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17148" PostTypeId="1" AcceptedAnswerId="17150" CreationDate="2018-08-21T18:10:33.217" Score="2" ViewCount="356" Body="&lt;p&gt;So I am pretty new to vim, but I have started using it as my Latex editor to help get more efficient. Anyways I have a recording that I would like to prompt a user for input on that will change how the recording goes. I am looking for some way of doing the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;qa&#xA;i &#xA;\begin{theorem}[XXX] #where XXX is the name of the theorem given by the user&#xA;&#xA;\end{theorem}&#xA;ESC&#xA;&amp;lt;C-o&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The idea would be that @a would wait for a prompt like &amp;quot;Pythagorean Theorem&amp;quot;, and replace XXX above, and otherwise would leave [ ] blank. Is there an easy way to do this? Thanks in advance for anything you can recommend.&lt;/p&gt;&#xA;&lt;h1&gt;EDIT 1:&lt;/h1&gt;&#xA;&lt;p&gt;I have tried using functions outside of the file that take an input like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! GetTheorem()&#xA;   let curline = getline('.')&#xA;   call inputsave()&#xA;   let thm = input('Theorem Name: ')&#xA;   call inputrestore()&#xA;   call setline('.', curline . '[' . thm . ']')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Which is stored in GetTheorem.vim. But when I set that as the source file for the code I end up getting only to the point where vim outputs:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\begin{theorem}[XXX]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And just ignores the rest of the macro commands even though it still says that it is &amp;quot;recording&amp;quot; as I was putting it together. Any Ideas how to fix that issue?&lt;/p&gt;&#xA;" OwnerUserId="18687" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-08-21T19:32:37.087" Title="User Input in a Recording" Tags="|macro|plugin-vim-latex|user-input|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17149" PostTypeId="1" CreationDate="2018-08-21T19:15:00.247" Score="3" ViewCount="2235" Body="&lt;p&gt;I thought this would be a 10 second google search, but no. I found a bazillion sources how to disable cursor blinking in GVim. But I would like to disable it in terminal vim. My terminal cursor is set to no-blink globally already. It does not blink in any shell program. But it does in vim. How can I turn this off?&lt;/p&gt;&#xA;" OwnerUserId="18689" LastActivityDate="2018-08-21T19:15:00.247" Title="disable cursor blinking in terminal-vim" Tags="|terminal|cursor|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17150" PostTypeId="2" ParentId="17148" CreationDate="2018-08-21T19:32:37.087" Score="4" Body="&lt;p&gt;I'll give an answer, but not the one you are looking for. Hopefully, you will find it even better. Note that it does rely on you installing a plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, what you are trying to do is to simplify the process of creating a new theorem environment. You want to apply a template and to fill out some parts automatically. You are in luck, because this is the main motivation behind the concept of snippets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There exists several snippet plugins for Vim, where the most popular ones are probably &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt; and &lt;a href=&quot;https://github.com/Shougo/neosnippet.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;neosnippet&lt;/a&gt;. Both of these plugins are very well documented. In addition, a lot of people use a community maintained default set of snippets: &lt;a href=&quot;https://github.com/honza/vim-snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;Honza's vim-snippets&lt;/a&gt;. This will contain a lot of LaTeX snippets as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a snippet engine, you will typically define a trigger key such that when you type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;theorem&amp;lt;trigger-key&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will expand to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{theorem}[|&amp;lt;name&amp;gt;]&#xA;  &amp;lt;next&amp;gt;&#xA;\end{theorem}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here you can immediately insert the name, and a new key (which may often be set to the same key as the trigger key) can be used to go to the next input field &lt;code&gt;&amp;lt;next&amp;gt;&lt;/code&gt; inside the environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;&amp;lt;next&amp;gt;&lt;/code&gt; above is not a part of the snippet, I just used it to explain/indicate that a snippet may contain several &quot;jump targets&quot; that may be used during expansion of the snippet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I propose that you spend an hour or two reading the introductions for the documentation to the snippet engines and then select one of these to try out.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-08-21T19:32:37.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17151" PostTypeId="1" CreationDate="2018-08-22T05:46:40.467" Score="1" ViewCount="126" Body="&lt;p&gt;I installed Vim 8.1.1 on Windows 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;_vimrc&lt;/code&gt; in &lt;code&gt;C:\Users\Maggyero&lt;/code&gt; has the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set spell&#xA;set spelllang=en,fr&#xA;set spellsuggest=5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open Vim, I get the following message:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Alerte : Liste de mots &quot;fr.utf-8.spl&quot; ou &quot;fr.ascii.spl&quot; introuvable&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After clicking on &quot;Ok&quot;, I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I get the following message:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Cannot find spell file for &quot;fr&quot; in utf-8&#xA;  Do you want me to try downloading it?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After clicking on &quot;Yes&quot;, I get the following message:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Downloading fr.utf-8.spl...&lt;br&gt;&#xA;  **error** (netrw) Illegal PORT command.^M&lt;br&gt;&#xA;  **warning** (netrw) file &amp;lt;C:\Users\MAGGYERO\AppData\Local\Temp\VIA45B2.spl&amp;gt; not readable&lt;br&gt;&#xA;  Could not find it, trying fr.ascii.spl...&lt;br&gt;&#xA;  **error** (netrw) Illegal PORT command.^M&lt;br&gt;&#xA;  **warning** (netrw) file &amp;lt;C:\Users\MAGGYERO\AppData\Local\Temp\VIA45B2.spl&amp;gt; not readable&lt;br&gt;&#xA;  Sorry, downloading failed&lt;br&gt;&#xA;  Alerte : Liste de mots &quot;fr.utf-8.spl&quot; ou &quot;fr.ascii.spl&quot; introuvable&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="9600" LastEditorUserId="9600" LastEditDate="2018-08-22T10:48:48.867" LastActivityDate="2018-12-17T13:01:35.287" Title="Netrw error: &quot;Illegal PORT command&quot;" Tags="|netrw|spell-checking|error|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="17152" PostTypeId="2" ParentId="6511" CreationDate="2018-08-22T07:56:46.743" Score="3" Body="&lt;h2&gt;New official vim plugin &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/pack/dist/opt/cfilter/plugin/cfilter.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;cfilter&lt;/em&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Since &lt;a href=&quot;https://github.com/vim/vim/commit/8c5e0093c9badced73e382915fb024a5c3ea463b&quot; rel=&quot;nofollow noreferrer&quot;&gt;21.8.2018 (patch: 8.1.0311)&lt;/a&gt; the plugin &lt;em&gt;cfilter&lt;/em&gt; is distributed with vim in &lt;code&gt;$VIMRUNTIME&lt;/code&gt;. It is documented under &lt;code&gt;:h cfilter-plugin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Load plugin &lt;em&gt;cfilter&lt;/em&gt; when needed or load it always in your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:packadd cfilter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Filter quickfix list with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Cfilter DPUST&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2018-08-22T07:56:46.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17153" PostTypeId="1" CreationDate="2018-08-22T09:40:45.927" Score="1" ViewCount="40" Body="&lt;p&gt;I program in both C and Lua and therefore sometimes add a semicolmn in my Lua files. This is allowed by the standard, but my company's guidelines forbid semicolmns in lua code. Therefore, I would like vim to highlight any semicolmn it finds in a lua file. To achieve this, I tried adding the following to my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if _curfile =~ &quot;.*\.lua&quot;&#xA;    syntax match semicolmn &quot;;&quot;&#xA;    highlight semicolmn guibg=red ctermbg=1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this has some very weird effects: it does not actually work on any Lua file until I run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:so %MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After which it works, but only for the current tab. So I suspect that the entire .vimrc file might be broken, this is it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let _curfile = expand(&quot;%:t&quot;)&#xA;if _curfile =~ &quot;Makefile&quot; || _curfile =~ &quot;makefile&quot; || _curfile =~ &quot;.*\.mk&quot; || _curfile =~ &quot;.*\.mcrl2&quot;&#xA;    set noexpandtab&#xA;else&#xA;    set expandtab&#xA;endif&#xA;&#xA;if _curfile =~ &quot;.*\.vhd&quot;&#xA;    let g:vhdl_indent_genportmap = 0&#xA;    set tabstop=2&#xA;    set shiftwidth=2&#xA;    set softtabstop=2&#xA;else&#xA;    set tabstop=4&#xA;    set shiftwidth=4&#xA;    set softtabstop=4&#xA;endif&#xA;&#xA;if _curfile =~ &quot;.*\.tex&quot;&#xA;    set tw=120&#xA;endif&#xA;&#xA;colorscheme molokai&#xA;set shiftround&#xA;set autoread&#xA;set mouse=a&#xA;set clipboard=unnamedplus&#xA;set scrolloff=5&#xA;let g:rehash256 = 1&#xA;highlight Cursor guifg=white guibg=blue&#xA;&#xA;set backspace=indent,eol,start&#xA;&#xA;syntax on&#xA;set hlsearch&#xA;&#xA;&quot; Special save hotkey&#xA;noremap &amp;lt;Leader&amp;gt;s :update&amp;lt;CR&amp;gt;&#xA;&quot; Remove whitespace&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;F5&amp;gt; :let _s=@/&amp;lt;Bar&amp;gt;:%s/\s\+$//e&amp;lt;Bar&amp;gt;:let @/=_s&amp;lt;Bar&amp;gt;:nohl&amp;lt;CR&amp;gt;&#xA;&quot; Fixes copy paste behaviour for gvim&#xA;vmap &amp;lt;C-c&amp;gt; &quot;+y&#xA;vmap &amp;lt;C-x&amp;gt; &quot;+c&#xA;vmap &amp;lt;C-v&amp;gt; c&amp;lt;ESC&amp;gt;&quot;+p&#xA;imap &amp;lt;C-v&amp;gt; &amp;lt;C-r&amp;gt;&amp;lt;C-o&amp;gt;+&#xA;&#xA;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'gmarik/Vundle.vim'&#xA;Plugin 'bling/vim-airline'&#xA;&#xA;let g:syntastic_vhdl_checkers = ['vimhdl']&#xA;&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&#xA;au BufRead,BufNewFile *.S set filetype=armasm&#xA;au BufRead,BufNewFile *.h set filetype=c&#xA;cnoreabbrev X x&#xA;set keymodel=startsel&#xA;&#xA;if _curfile =~ &quot;.*\.lua&quot;&#xA;    syntax match semicolmn &quot;;&quot;&#xA;    highlight semicolmn guibg=red ctermbg=1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, the actual question is: how do I modify my .vimrc so that any semicolmn in a lue file gets highlighted?&lt;/p&gt;&#xA;" OwnerUserId="18698" LastActivityDate="2018-08-22T09:40:45.927" Title="Highlight semicolmns when editting lua files" Tags="|vimrc|highlight|" AnswerCount="0" CommentCount="3" ClosedDate="2018-08-22T10:48:44.250" ContentLicense="CC BY-SA 4.0" />
  <row Id="17154" PostTypeId="2" ParentId="17151" CreationDate="2018-08-22T13:56:49.447" Score="1" Body="&lt;p&gt;It seems that &lt;code&gt;netrw&lt;/code&gt; invokes &lt;code&gt;wget&lt;/code&gt; or &lt;code&gt;fetch&lt;/code&gt; (via &lt;code&gt;cmd&lt;/code&gt;, not &lt;code&gt;powershell&lt;/code&gt; which aliases &lt;code&gt;wget&lt;/code&gt; for the built-in &lt;code&gt;Invoke-WebRequest&lt;/code&gt; command) for retrieving the spell file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\WINDOWS\system32\cmd.exe /c (wget ^&quot;http://ftp.vim.org/pub/vim/runtime/spell/fr.utf-8.spl^&quot; -q -O ^&quot;C:\Users\MAGGYERO\AppData\Local\Temp\VIA77E3.spl^&quot;)&#xA;SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc&#xA;syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the suggestion file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Windows\system32\cmd.exe /c (wget ^&quot;http://ftp.vim.org/pub/vim/runtime/spell/fr.utf-8.sug^&quot; -q -O ^&quot;C:\Users\MAGGYERO\AppData\Local\Temp\VIA126E.sug^&quot;)&#xA;SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc&#xA;syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;wget&lt;/code&gt; or &lt;code&gt;fetch&lt;/code&gt; is not in the PATH environment variable (which was my case), &lt;code&gt;netrw&lt;/code&gt; invokes &lt;code&gt;ftp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;em&gt;active mode&lt;/em&gt; (the default), &lt;code&gt;ftp&lt;/code&gt; opens a T.C.P. control connection to the server port 21 and accepts a T.C.P. data connection opened by the server to a client port between 1024 and 65635—so if the &lt;em&gt;client&lt;/em&gt; has a firewall or a NAT gateway it must be correctly set up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;em&gt;passive mode&lt;/em&gt;, &lt;code&gt;ftp&lt;/code&gt; opens a T.C.P. control connection to the server port 21 and opens a T.C.P. data connection to a server port between 1024 and 65635—so if the &lt;em&gt;server&lt;/em&gt; has a firewall or a NAT gateway it must be correctly set up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As we are behind a NAT gateway (and maybe a firewall) at the office, it might be the reason why &lt;code&gt;ftp&lt;/code&gt; failed. Switching to passive mode (&lt;code&gt;:let g:netrw_ftp_cmd= &quot;ftp -p&quot;&lt;/code&gt;) removed the errors but kept the warnings so the downloading is still failing, for a reason that I ignore (maybe because the server has a firewall or a NAT gateway that is not correctly set up, or simply because the server does not allow passive mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So simply installing GNU Wget from Sourceforge and adding it to the PATH environment variable solved the issue: &lt;a href=&quot;http://gnuwin32.sourceforge.net/packages/wget.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://gnuwin32.sourceforge.net/packages/wget.htm&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="9600" LastEditorUserId="9600" LastEditDate="2018-11-17T12:56:28.650" LastActivityDate="2018-11-17T12:56:28.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17155" PostTypeId="1" AcceptedAnswerId="17160" CreationDate="2018-08-22T20:33:07.403" Score="0" ViewCount="67" Body="&lt;p&gt;I keep a &lt;code&gt;sys.md&lt;/code&gt; file where I record a dated entry of every modification I make to my system (mostly installations of software, sometimes configuration changes) and based on an old &lt;a href=&quot;https://news.ycombinator.com/item?id=17538697&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hacker News&lt;/a&gt; &lt;a href=&quot;https://theptrk.com/2018/07/11/did-txt-file/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link about a did file&lt;/a&gt; I came up with the idea of an alias that would auto-insert the date and set me up with exactly the prompt I want for an entry to &lt;code&gt;sys.md&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command opens my &lt;code&gt;sys.md&lt;/code&gt; file and inserts the date and the bottom:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim +'normal Go' +r!date' ~/notes/sys.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to copy that line, paste it below, replace it with &lt;code&gt;-&lt;/code&gt;'s as a markdown h2 heading, insert a new line and begin it with a dash-space &lt;code&gt;-_&lt;/code&gt; to start a bullet.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yypVr-o-_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim +'normal Go' +'r!date' -c 'yypVr-o-_' ~/notes/sys.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does not work. How can I auto-execute those commands?&lt;/p&gt;&#xA;" OwnerUserId="17830" LastActivityDate="2018-08-23T14:08:15.737" Title="Command line argument for lengthy command" Tags="|invocation|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17156" PostTypeId="2" ParentId="13996" CreationDate="2018-08-23T09:10:03.820" Score="1" Body="&lt;p&gt;&lt;code&gt;equalprg&lt;/code&gt; specifies an external program, there is no way for the external program to know your specific indenting settings, except for parsing your various configuration files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general it is better to go with the &lt;code&gt;indentexpr&lt;/code&gt; setting, which can use various VimScript to perform your indentation (as well as call an external program).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-08-23T09:10:03.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17157" PostTypeId="2" ParentId="15899" CreationDate="2018-08-23T09:23:25.603" Score="2" Body="&lt;p&gt;It is actually quite easy. IF you want to have all flexibility and be able to use a plugin wherever it resides on your local filesystem, you need to go with setting up the &lt;code&gt;runtimepath&lt;/code&gt; setting yourself (e.g. using &lt;code&gt;:set rtp+=...&lt;/code&gt;). This might make sense for having the plugin reside somewhere locally, where it can be used by different users on your system (e.g. NFS share or something).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you are okay with placing a local plugin in a package directory of your local configuration directory (e.g. &lt;code&gt;~/.vim/pack/opt/&lt;/code&gt;), then Vim will load the package automatically (if it was placed below the &lt;code&gt;start&lt;/code&gt; subdirectory) or you can load it manually on demand, by placing it below the &lt;code&gt;opt&lt;/code&gt; subdirectory). &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-08-23T09:23:25.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17158" PostTypeId="2" ParentId="17137" CreationDate="2018-08-23T09:27:46.077" Score="1" Body="&lt;p&gt;This is not possible as of today. The reason most likely is, that the non-highlighted indented part is actually only a representation and does not really exist in the file. I am not sure it makes sense, to color that for the cursorline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, this question has made it to a Vim Ticket: &lt;a href=&quot;https://github.com/vim/vim/issues/3355&quot; rel=&quot;nofollow noreferrer&quot;&gt;#3355&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-08-23T09:27:46.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17160" PostTypeId="2" ParentId="17155" CreationDate="2018-08-23T14:08:15.737" Score="2" Body="&lt;p&gt;&lt;code&gt;yypVr-o-_&lt;/code&gt; are not ex-commands, but normal. Use &lt;code&gt;:normal&lt;/code&gt; to execute normal commands.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +'normal Go' +'r!date' +'yypVr-o-_' ~/notes/sys.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm&#xA;:h -c&#xA;:h :r!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-08-23T14:08:15.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17161" PostTypeId="1" CreationDate="2018-08-23T16:06:52.510" Score="0" ViewCount="499" Body="&lt;p&gt;For example, a tcl file, how to analyse the file and get each variable's value?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be done by reading each line, check if there is &quot;set XXX ...&quot;, then get variable name and its value.&#xA;After analysing the whole file, we will get a list of variables and its definition.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently only need to support tcl file.&lt;br&gt;&#xA;Not sure if there is an easy way to do this.  &lt;/p&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="51" LastEditDate="2018-08-23T17:16:07.837" LastActivityDate="2018-10-30T07:00:45.093" Title="How to analyse file and get variable definition?" Tags="|variables|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17164" PostTypeId="1" CreationDate="2018-08-23T19:35:12.720" Score="2" ViewCount="839" Body="&lt;p&gt;If there is no variable in path, gf can open the file.&lt;br&gt;&#xA;Added &lt;code&gt;sfname+={,}&lt;/code&gt; to .vimrc to support ${VARIABLE}.&lt;br&gt;&#xA;&lt;code&gt;:!echo ${VAR}/test/file&lt;/code&gt; can correctly print full path with ${VAR} expanded.&lt;br&gt;&#xA;But if run 'gf' on it, it gives error: &lt;code&gt;E447: Can't find file &quot;${VAR}/test/file&quot; in path&lt;/code&gt;&lt;br&gt;&#xA;How to fix this?&lt;/p&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="13402" LastEditDate="2018-08-28T09:18:19.250" LastActivityDate="2018-08-28T09:18:19.250" Title="Why gf is not working with variable?" Tags="|variables|cursor|environment-variables|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17165" PostTypeId="1" CreationDate="2018-08-24T11:24:09.660" Score="2" ViewCount="1181" Body="&lt;p&gt;P4EDITOR is set to gvim in .p4enviro.&lt;br&gt;&#xA;When run command &lt;code&gt;p4 client&lt;/code&gt; in terminal, it will pop an empty tmp file.&lt;br&gt;&#xA;But if change editor config to &lt;code&gt;P4EDITOR=vim&lt;/code&gt;, it works fine.&lt;br&gt;&#xA;How to fix this?&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2022-10-26T21:07:25.813" Title="Why gvim can't work with command: p4 client?" Tags="|gvim|terminal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17166" PostTypeId="1" AcceptedAnswerId="17182" CreationDate="2018-08-24T15:25:00.520" Score="2" ViewCount="196" Body="&lt;p&gt;For example, I've mapped &lt;code&gt;inoremap ( ()&lt;/code&gt;, and if I do &lt;code&gt;iabbrev if if(then&lt;/code&gt; it will expand to &lt;code&gt;if(then)&lt;/code&gt; instead of &lt;code&gt;if()then&lt;/code&gt; (the &lt;code&gt;inoremap&lt;/code&gt; is executed after the &lt;code&gt;iabbrev&lt;/code&gt;). Is it possible to make &lt;code&gt;iabbrev&lt;/code&gt; ignore my custom keymappings so I can make &lt;code&gt;iabbrev if if()then&lt;/code&gt; correctly expand to &lt;code&gt;if()then&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="18254" LastEditorUserId="18254" LastEditDate="2018-08-24T15:38:33.143" LastActivityDate="2018-08-26T09:15:41.453" Title="How to make abbrev ignore my custom keybindings?" Tags="|key-bindings|abbreviations|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17167" PostTypeId="1" AcceptedAnswerId="17172" CreationDate="2018-08-24T18:45:40.613" Score="3" ViewCount="1220" Body="&lt;p&gt;Want to read variable definitions from a tcl file, then dynamically define vim global variables.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set PATH_A /full/path/a&#xA;set PATH_B /full/path/b&#xA;other_tcl_commands&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read one line, split by space and save to list.&lt;br&gt;&#xA;Use list[1] as variable name and list[2] as variable value.&lt;br&gt;&#xA;Like &lt;code&gt;let g:PATH_A = /full/path/a&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-08-27T08:07:25.973" Title="How to dynamically define variables?" Tags="|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17168" PostTypeId="1" AcceptedAnswerId="17171" CreationDate="2018-08-24T21:30:48.690" Score="1" ViewCount="410" Body="&lt;p&gt;I would like to copy the first letters of paper titles in a bib file and set that as entry name.&lt;br&gt;&#xA;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@article{Cqmdoprbcc,&#xA;  title={Can quantum-mechanical description of physical reality be considered complete?},&#xA;  author={Einstein, Albert and Podolsky, Boris and Rosen, Nathan},&#xA;  journal={Physical review},&#xA;  volume={47},&#xA;  number={10},&#xA;  pages={777},&#xA;  year={1935},&#xA;  publisher={APS}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that the bibtex entry, &lt;code&gt;Cqmdoprbcc&lt;/code&gt;, is the first letters of each word in the title.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am clueless as how to do it and I was hoping I could learn from masters of vim here.&lt;/p&gt;&#xA;" OwnerUserId="13751" LastEditorUserId="1292" LastEditDate="2018-08-25T22:52:22.747" LastActivityDate="2018-08-25T22:52:22.747" Title="Copy first letter of each word in a line" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17169" PostTypeId="1" CreationDate="2018-08-24T22:19:25.080" Score="1" ViewCount="43" Body="&lt;p&gt;I have the following bit of text in a vim file with cursor where the asterisk is while in insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{document}&#xA;[latex]&#xA;Some text*&#xA;[\latex]&#xA;\end{document}&#xA;&#xA;\begin{document}&#xA;[latex]&#xA;[\latex]&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to hit ctrl-A to search for the next instance of &lt;code&gt;[latex&lt;/code&gt; and insert a new line after that with this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap ^A &amp;lt;esc&amp;gt;execute &quot;normal! /^[latex\&amp;lt;cr&amp;gt;o&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, what happens instead is the first instance of &lt;code&gt;[\latex]&lt;/code&gt; gets changed to &lt;code&gt;[latex]&lt;/code&gt; with the cursor over the x. What has me baffled is that this works fine when I type in the keystrokes manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get vim to do it what I want?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2018-08-24T22:36:19.643" Title="Search not behaving as expected" Tags="|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17170" PostTypeId="2" ParentId="17169" CreationDate="2018-08-24T22:36:19.643" Score="2" Body="&lt;p&gt;Solved with this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;C-A&amp;gt; &amp;lt;esc&amp;gt;/[latex&amp;lt;cr&amp;gt;o&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess &lt;code&gt;execute&lt;/code&gt; doesn't work when mapping keys.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2018-08-24T22:36:19.643" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17171" PostTypeId="2" ParentId="17168" CreationDate="2018-08-24T23:54:09.237" Score="2" Body="&lt;p&gt;Assuming your initial text looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@article{some name,&#xA;  title={Can quantum-mechanical description of physical reality be considered complete?},&#xA;  author={Einstein, Albert and Podolsky, Boris and Rosen, Nathan},&#xA;  journal={Physical review},&#xA;  volume={47},&#xA;  number={10},&#xA;  pages={777},&#xA;  year={1935},&#xA;  publisher={APS}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you could try this substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/^\s*@article{\zs.*\ze,/\=substitute(matchstr(getline(search('^\s*title=', 'nW')), '{\zs.\{-}\ze}'), '\(\k\)\k*\%(\k\@!.\)*', '\1', 'g')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you execute it in your file, it should look for all the lines starting with &lt;code&gt;@article{&lt;/code&gt; and replace the following name with the first letter of each word on the next line beginning with &lt;code&gt;title=&lt;/code&gt;.&lt;br&gt;&#xA;IOW, it should perform the following substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@article{some name,&#xA;  title={Can quantum-mechanical description of physical reality be considered complete?},&#xA;→&#xA;@article{Cqmdoprbcc,&#xA;  title={Can quantum-mechanical description of physical reality be considered complete?},&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The syntax of this substitution is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/pat/\=expr/&#xA;│  │   ├┘│&#xA;│  │   │ └ the expression to be evaluated&#xA;│  │   │&#xA;│  │   └ replace it by the evaluation of the following expression&#xA;│  │     (see `:h :s\=`)&#xA;│  │&#xA;│  └ every time you find a first occurrence of the pattern&#xA;│    described by the string 'pat' on a line&#xA;│&#xA;└ operate on all the lines of the file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the pattern is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^\s*@article{\zs.*\ze,&#xA;│├┘│├───────┘├─┘││├─┘│&#xA;││ ││        │  │││  └ the text `,`&#xA;││ ││        │  │││&#xA;││ ││        │  ││└ look for everything I will describe afterwards,&#xA;││ ││        │  ││  but don't replace it when doing the substitution (`:h \ze`)&#xA;││ ││        │  ││&#xA;││ ││        │  │└ as many as possible&#xA;││ ││        │  │&#xA;││ ││        │  └ any character (from the old entry name) (`:h /.`)&#xA;││ ││        │&#xA;││ ││        └ look for everything I've described thus far,&#xA;││ ││          but don't replace it when doing the substitution (`:h /\zs`)&#xA;││ ││&#xA;││ │└ the text `@article{`&#xA;││ │&#xA;││ └ as many as possible (`:h /*`)&#xA;││&#xA;│└ a whitespace (`:h /\s`)&#xA;│&#xA;└ a beginning of line (see `:h /^`)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the expression is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(matchstr(getline(search('^\s*title=', 'nW')), '{\zs.\{-}\ze}'), '\(\k\)\k*\%(\k\@!.\)*', '\1', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The evaluation of &lt;code&gt;search('^\s*title=', 'nW')&lt;/code&gt; is the numerical address of the next line (relative to where &lt;code&gt;:s&lt;/code&gt; command is performing a substitution at the moment) described by the pattern &lt;code&gt;^\s*title=&lt;/code&gt;. IOW, it's the address of the next line beginning with &lt;code&gt;title=&lt;/code&gt;. Let's call it &lt;code&gt;S&lt;/code&gt;.&#xA;During the evaluation of &lt;code&gt;S&lt;/code&gt;, the cursor won't move because of the &lt;code&gt;n&lt;/code&gt; flag passed in the 2nd argument (&lt;code&gt;:h search()&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;code&gt;S&lt;/code&gt; symbol, the expression can be re-written like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(matchstr(getline(S), '{\zs.\{-}\ze}'), '\(\k\)\k*\%(\k\@!.\)*', '\1', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The evaluation of &lt;code&gt;getline(S)&lt;/code&gt; is a string, matching the contents of the next line beginning with &lt;code&gt;title=&lt;/code&gt; (&lt;code&gt;:h getline()&lt;/code&gt;).&#xA;Let's call it &lt;code&gt;G&lt;/code&gt;.&#xA;Using the &lt;code&gt;G&lt;/code&gt; symbol, the expression can be re-written like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(matchstr(G, '{\zs.\{-}\ze}'), '\(\k\)\k*\%(\k\@!.\)*', '\1', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The evaluation of &lt;code&gt;matchstr(G, '{\zs.\{-}\ze}')&lt;/code&gt; is a substring of the previous string. Let's call it &lt;code&gt;M&lt;/code&gt;. More specifically, it's the part between 2 CONSECUTIVE (because you used the LAZY quantifier &lt;code&gt;\{-}&lt;/code&gt;, instead of the greedy &lt;code&gt;*&lt;/code&gt;; see &lt;code&gt;:h /\{-&lt;/code&gt;) curly brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;code&gt;M&lt;/code&gt; symbol, the expression can be re-written like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(M, '\(\k\)\k*\%(\k\@!.\)*', '\1', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The evaluation of this last expression is what you want, i.e. the first letter of each word in your original title.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could re-write it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(M, pat, rep, 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;pat&lt;/code&gt; is a pattern that &lt;code&gt;substitute()&lt;/code&gt; has to look for, here &lt;code&gt;\(\k\)\k*\%(\k\@!.\)*&lt;/code&gt;, and &lt;code&gt;rep&lt;/code&gt; is the replacement string, here &lt;code&gt;\1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pattern can be broken down like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(\k\)\k*\%(\k\@!.\)*&#xA;├────┘├─┘├──────────┘&#xA;│     │  └ a sequence of NON-keyword characters, as long as possible (see `:h /\@!`)&#xA;│     │&#xA;│     └ a sequence of other keyword characters, as long as possible&#xA;│&#xA;└ look for a keyword character (`:h /\k`), and remember it (`:h /\(`)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The replacement string is special, and not a literal string. &lt;code&gt;\1&lt;/code&gt; refers to the first capturing group in your pattern, which here is the first keyword character of every word in your original title (&lt;code&gt;:h /\1&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could also turn it into a custom command (&lt;code&gt;:SetEntryName&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! -bar -range=% SetEntryName  call s:set_entry_name(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;)&#xA;&#xA;fu! s:set_entry_name(line1, line2) abort&#xA;    let range = a:line1.','.a:line2&#xA;    exe range.'s/^\s*@article{\zs.*\ze,/\=s:get_entry_name()/'&#xA;endfu&#xA;&#xA;fu! s:get_entry_name() abort&#xA;    let entry = getline(search('^\s*title=', 'nW'))&#xA;    let entry = matchstr(entry, '{\zs.\{-}\ze}')&#xA;    let entry = substitute(entry, '\(\k\)\k*\%(\k\@!.\)*', '\1', 'g')&#xA;    return entry&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command accepts a range, thus works on a visual selection.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-08-25T10:17:21.313" LastActivityDate="2018-08-25T10:17:21.313" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17172" PostTypeId="2" ParentId="17167" CreationDate="2018-08-25T06:30:33.367" Score="2" Body="&lt;p&gt;We can base a solution on these two commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let m = matchlist(getline(&quot;.&quot;), PATTERN)&#xA;exec &quot;let g:&quot; . m[1] . &quot; = '&quot; . m[2] . &quot;'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The first command processes the current buffer line into a list of pattern (sub)matches. I don't know anything about tcl variable definitions so I'm not sure exactly what your matching requirements are but if you only want to match lines like &quot;set foo baz&quot; then you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^\s*set\s\+\(\S\+\)\s\+\(\S\+\)\s*$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I'm allowing whitespace before and after the text of interest. Modify the pattern as you see fit.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, if you run the following line through the &lt;code&gt;matchlist&lt;/code&gt; function..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set PATH_A /full/path/a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The returned list will contain:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['set PATH_A /full/path/a', 'PATH_A', '/full/path/a']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The second command uses the second and third element of the list to execute the appropriate &lt;code&gt;let&lt;/code&gt; expression, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:PATH_A = '/full/path/a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Putting this into practice, we can process an entire file with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent! g/./ let m=matchlist(getline(&quot;.&quot;), '^\s*set\s\+\(\S\+\)\s\+\(\S\+\)\s*$') | exec &quot;let g:&quot; . m[1] . &quot; = '&quot; . m[2] . &quot;'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Besides the stuff we already discussed, &lt;code&gt;silent!&lt;/code&gt; is there to ignore any lines that don't match the pattern and &lt;code&gt;g/./&lt;/code&gt; executes the following command(s) for every line in the buffer that matches &lt;code&gt;.&lt;/code&gt; (IOW, every non-blank line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If you want to process part of a file you can put a range in front of &lt;code&gt;g/./&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After running this on your sample text we'd see, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo g:PATH_B&#xA;/full/path/b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of the various approaches to this problem that I pondered I think this one is pretty straightforward, if a little brute force. (I was originally planning something with lambdas/funcrefs.) &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; A slightly optimized variation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\s*set\s\+\(\S\+\)\s\+\(\S\+\)\s*$/ let m=matchlist(getline(&quot;.&quot;), @/) | exec &quot;let g:&quot; . m[1] . &quot; = '&quot; . m[2] . &quot;'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By using the &lt;code&gt;matchlist&lt;/code&gt; pattern with &lt;code&gt;:global&lt;/code&gt; we only stop at lines that will be processed into var defs. Instead of repeating the pattern for the function parameter we just use the contents of the &lt;code&gt;/&lt;/code&gt; register which will now contain the pattern. We can drop &lt;code&gt;silent!&lt;/code&gt;, too, since we don't expect any non-matching lines with this version.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-08-27T08:07:25.973" LastActivityDate="2018-08-27T08:07:25.973" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17173" PostTypeId="2" ParentId="17136" CreationDate="2018-08-25T09:16:51.870" Score="2" Body="&lt;p&gt;The solution was to recreate the session file. As I didn't want to create it from scratch I copied the crucial parts from it - open files/buffers.&lt;/p&gt;&#xA;" OwnerUserId="18651" LastActivityDate="2018-08-25T09:16:51.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17174" PostTypeId="1" CreationDate="2018-08-25T10:12:01.003" Score="0" ViewCount="431" Body="&lt;p&gt;I am trying to persist some state about my buffers, specifically terminal buffers, over vim sessions with &lt;code&gt;:mksession&lt;/code&gt; through the plugin &lt;code&gt;vim-session&lt;/code&gt; by Xolox.&lt;/p&gt;&#xA;&lt;p&gt;The goal is to assign labels to the terminal buffers (for usage with the terminal JSON API, implementing a source/sink based dynamic coupling), but for the future, I would like to have arbitrary data coupled tightly with my buffers. Terminals already restore nicely over sessions if their invocation command captures all behavior. It would maybe be possible to capture a label in those commands, but I don't like that as a system as it only solves the issue for terminals, but not for buffers in general.&lt;/p&gt;&#xA;&lt;p&gt;The buffer number does not stay constant over session instances, so a global variable that I may persist to index the buffers (the Xolox session-plugin allows this) is out of the question.&lt;/p&gt;&#xA;&lt;p&gt;I have scoured the :opt list of buffer options for something that is designed to store some arbitrary data, but found none.&lt;/p&gt;&#xA;&lt;p&gt;How would I go about achieving that goal of attaching metadata to a buffer for permanent identification?&lt;/p&gt;&#xA;" OwnerUserId="17075" LastEditorUserId="23502" LastEditDate="2023-04-02T05:45:28.167" LastActivityDate="2023-12-28T08:07:20.890" Title="How to tag/enrich buffers with custom information (that persist naturally)?" Tags="|buffers|sessions|terminal-buffer|persistent-state|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17176" PostTypeId="2" ParentId="17174" CreationDate="2018-08-25T18:43:34.433" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The buffer number does not stay constant over session instances, &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:mksession&lt;/code&gt; reloads the buffer list: the buffer numbers will be same.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;so a global variable that I may persist to index the buffers (the xolox session-plugin allows this) is out of the question.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm note sure what you mean/want, since I have never used the plugin before. However, &lt;code&gt;:mksession&lt;/code&gt; does restore global variables. You can take a look at &lt;code&gt;:h :mksession&lt;/code&gt; (specially point '1' and point '7':&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;1 - Restores global mappings and options, if 'sessionoptions' contains&#xA;        &quot;options&quot;.  Script-local mappings will not be written.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;7 - Reloads the buffer list, with the last cursor positions.  If&#xA;        'sessionoptions' contains &quot;buffers&quot; then all buffers are restored,&#xA;        including hidden and unloaded buffers.  Otherwise only buffers in windows&#xA;        are restored.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It seems to me that what you are looking for is already built-in. Are you sure it&#xA;is not an issue with the plugin? The &lt;code&gt;xolox/vim-session&lt;/code&gt; I've found received its&#xA;last 3 years ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, in case you need more control on the name of your terminal buffers, you&#xA;can change the buffers name with &lt;code&gt;:file [filename]&lt;/code&gt;. E.g. you could have one terminal&#xA;named &quot;&lt;strong&gt;term_one&lt;/strong&gt;: &lt;code&gt;:file term_one&lt;/code&gt; and another one named &quot;&lt;strong&gt;term_two&lt;/strong&gt;&quot;: &lt;code&gt;:file term_two&lt;/code&gt;.&#xA;This way next time you come back your session, they will have the same buffer numbers and names (more on &lt;code&gt;:h file_f&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="10493" LastActivityDate="2018-08-25T18:43:34.433" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17177" PostTypeId="1" CreationDate="2018-08-25T18:54:49.687" Score="1" ViewCount="6970" Body="&lt;p&gt;In my current environment, I open a file with return key in NERDTree, but sometimes I want to open it in a new tab. That being said, there is still more case where I want to open a file in the current buffer, so I don't like to swap it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I rather want to open it in a new tab with a separate key, possibly ctrl + return. Is it possible in NERDTree? &lt;/p&gt;&#xA;" OwnerUserId="1072" LastActivityDate="2020-05-08T19:18:59.310" Title="Can I open a file in a new tab with ctrl + return in NERDTree?" Tags="|plugin-nerdtree|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17178" PostTypeId="1" CreationDate="2018-08-25T21:17:12.823" Score="4" ViewCount="631" Body="&lt;p&gt;I want to use Vim to write markdown in a sort-of-WYSIWYG manner (for use with an audience). For example, typing &lt;code&gt;**Bold**&lt;/code&gt; should display &lt;strong&gt;Bold&lt;/strong&gt; in bold font, with the asterisks automatically hidden as soon as I move the cursor away from the word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've figured out &lt;em&gt;almost&lt;/em&gt; how to do this with several markdown syntax-highlighting plugins that offer concealing (vim-pandoc-syntax and plasticboy's markdown-vim-mode). The issue I'm encountering is that the markdown symbols (for example, the asterisks around the word &quot;Bold&quot;) are visible until I start a new &lt;em&gt;paragraph&lt;/em&gt; or otherwise exit the current paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I'd like the asterisks to be concealed as soon as I start a new &lt;em&gt;word&lt;/em&gt; or move on from the current word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas? I'm flexible as to which Markdown plugin I use, as long as I can achieve the desired result.&lt;/p&gt;&#xA;" OwnerUserId="7546" LastEditorUserId="4472" LastEditDate="2018-08-31T03:53:18.197" LastActivityDate="2018-08-31T03:53:18.197" Title="How to conceal Markdown syntax per-word, rather than per-paragraph?" Tags="|syntax-highlighting|filetype-markdown|conceal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17179" PostTypeId="2" ParentId="17178" CreationDate="2018-08-26T00:55:02.587" Score="2" Body="&lt;p&gt;After some research and advice from another forum, it appears that it is not possible to have both concealable text concealaed and other concealable text &lt;em&gt;unconcealed&lt;/em&gt; on the same line at the same time in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could split my paragraphs into separate lines, instead of using the Pencil plugin's soft-wrapping to have each paragraph on a single line. With each line on its own line, only one line's markdown formatting would be revealed at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to &lt;code&gt;:set concealcursor=nvic&lt;/code&gt;, which hides all markdown symbols entirely -- they don't show up even when the word is being edited, but the bold/italic formatting is there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that this might be my best option unless I choose a different tool entirely.&lt;/p&gt;&#xA;" OwnerUserId="7546" LastEditorUserId="7546" LastEditDate="2018-08-27T20:20:48.820" LastActivityDate="2018-08-27T20:20:48.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17180" PostTypeId="2" ParentId="17177" CreationDate="2018-08-26T08:18:53.427" Score="3" Body="&lt;p&gt;It's right there in the NERDTree help. Like it says at the top of the NERDTree window: &lt;code&gt;Press ? for help&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; File node mappings~&#xA;&quot; double-click,&amp;lt;CR&amp;gt;,o: open in prev window&#xA;&quot; t: open in new tab&#xA;&quot; T: open in new tab silently&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-08-26T08:18:53.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17181" PostTypeId="2" ParentId="17167" CreationDate="2018-08-26T08:48:29.437" Score="1" Body="&lt;p&gt;This can be done with a macro. (q[register] to begin a macro, then q to end it).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0W&quot;ayiWW&quot;by$:let g:&amp;lt;C-r&amp;gt;a = &quot;&amp;lt;C-r&amp;gt;b&quot;&amp;lt;cr&amp;gt;0j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am unsure of how to insert the special characters here but replace C-r and cr with their respective codes ^R and ^M using Ctrl-V (or Ctrl-Q on windows) in insert mode when writing the macro directly, or just replace with the actual key sequences (cr : enter) when recording the macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What this does is goes to the beginning of the line, to the next WORD of the line, then yanks the WORD into the a-register. Then, to the next WORD, it yanks the rest of the line into the b-register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, in command mode, it will run the command to define a global variable with variable name equal to the contents of the a-register (using C-r a) and value equal to the contents of the b-register (using C-r b).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the macro moves the cursor to the beginning of the line and moves down one line so it can easily be repeated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, you may want to take a file and execute this macro on all matching lines.&#xA;You can go to command mode and run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%g/^set /normal! @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses the global command over the given range, running a command on all matching lines (lines starting with &quot;set &quot;). If there are other lines you don't want to match that also start with &quot;set &quot; you will need to fiddle with the regex. The command that is run executes a normal-mode command which executes the macro stored in the q-register, which will define the global variable according to the contents of the line (if it is correctly formed, with incorrectly formed lines the macro may mess up and create bad behaviour).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now this is a lot of work to go through each time, if you overwrite the q-register and lose the macro. So a function would be nice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your ~/.vimrc or ~/_vimrc or equivalent, include:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TCLLineToVariable()&#xA;    execute &quot;normal! 0W\&quot;ayiWW\&quot;by$:let g:\&amp;lt;C-r&amp;gt;a = \&quot;\&amp;lt;C-r&amp;gt;b\&quot;\&amp;lt;cr&amp;gt;0j&quot;&#xA;endfunction&#xA;function! CreateTCLGlobals()&#xA;    %g/^set /call TCLLineToVariable()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Escape sequences and execute &quot;normal! ...&quot; are needed because execute preprocesses the escape sequences to pass to a normal! command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This function, when run, will operate on all lines in the file (% range), creating globals dynamically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want this to happen with any tcl file, use autocommands in your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead *.tcl call CreateTCLGlobals()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are using an extension other than .tcl, replace this part with your extension. Add BufEnter, BufWritePost, as well if you want all globals to be updated while you are editing the file (when you switch to the buffer or write it, at least). You may also want to surround this with an autocommand group so you don't duplicate the autocmd every time you source your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup TCL&#xA;    autocmd!&#xA;    autocmd BufRead,BufEnter,BufWritePost *.tcl call CreateTCLGlobals()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18654" LastEditorUserId="18654" LastEditDate="2018-08-26T08:55:19.363" LastActivityDate="2018-08-26T08:55:19.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17182" PostTypeId="2" ParentId="17166" CreationDate="2018-08-26T09:15:41.453" Score="3" Body="&lt;p&gt;&lt;code&gt;inoreabbrev&lt;/code&gt; (insert-mode non-recursive abbreviation) is the command that will ignore custom mappings when executing the abbreviations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To remove abbreviations without leaving vim use &lt;code&gt;iunabbrev [lhs]&lt;/code&gt;. Now &lt;code&gt;inoreabbrev if if()then&lt;/code&gt; should work correctly.&lt;/p&gt;&#xA;" OwnerUserId="18654" LastActivityDate="2018-08-26T09:15:41.453" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17183" PostTypeId="1" AcceptedAnswerId="17184" CreationDate="2018-08-26T12:16:00.013" Score="4" ViewCount="521" Body="&lt;p&gt;I'm trying to use &lt;code&gt;matchadd&lt;/code&gt; to highlight different occurrences of whitespace. However, sometimes it doesn't work for some reason. Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  highlight GroupA guibg=lightgreen&#xA;  highlight GroupB guifg=white                &quot; For default Vim color scheme&#xA;  highlight GroupC guibg=red&#xA;  highlight GroupD guibg=gray&#xA;  highlight GroupE guibg=blue&#xA;&#xA;  call matchadd(&quot;GroupA&quot;, &quot;\t&quot;, 11)           &quot; Highlight tabs&#xA;  call matchadd(&quot;GroupB&quot;, &quot; &quot;, 12)            &quot; Don't highlight single spaces&#xA;&#xA;&quot; Highlight initial spaces&#xA;&quot; call matchadd(&quot;GroupC&quot;, &quot;^ \+&quot;, 13)         &quot; Why it doesn't work?&#xA;  call matchadd(&quot;GroupC&quot;, &quot;^    &quot;, 13)        &quot; Current workaround&#xA;&#xA;&quot; Highlight 2 or more consequal spaces&#xA;  call matchadd(&quot;GroupD&quot;, &quot;\S\zs\s\{2,}&quot;, 14) &quot; Why it doesn't work?&#xA;                                              &quot; I haven't found any workaround&#xA;&#xA;&quot; Highlight trailing spaces&#xA;&quot; call matchadd(&quot;GroupE&quot;, &quot; \+$&quot;, 15)         &quot; Why it doesn't work?&#xA;  call matchadd(&quot;GroupE&quot;, &quot;    $&quot;, 15)        &quot; Current workaround&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The regular expressions themselves are seems to be correct. If we try to avoid &lt;code&gt;matchadd&lt;/code&gt;, everything works. So, here it is, just to show the correct behaviour:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;test 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight GroupA guibg=lightgreen&#xA;match GroupA /\t/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;test 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight GroupC guibg=red&#xA;highlight GroupD guibg=gray&#xA;highlight GroupE guibg=blue&#xA;&#xA; match GroupC /^ \+/&#xA;2match GroupD /\S\zs\s\{2,}/&#xA;3match GroupE / \+$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Test file (&lt;code&gt;&amp;gt;---&lt;/code&gt; is for tab, &lt;code&gt;.&lt;/code&gt; is for space):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;---aaaa&amp;gt;---&#xA;....bbbb....&#xA;&#xA;foo.bar..baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="7200" LastEditDate="2018-08-26T13:12:57.980" LastActivityDate="2018-08-26T13:15:04.083" Title="Highlight whitespace using matchadd" Tags="|vimrc|regular-expression|formatting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17184" PostTypeId="2" ParentId="17183" CreationDate="2018-08-26T13:07:40.177" Score="5" Body="&lt;p&gt;Inside double-quoted strings some special characters are automatically replaced (see &lt;code&gt;:h expr-quote&lt;/code&gt;).&#xA;For example, the string &lt;code&gt;&quot;\t&quot;&lt;/code&gt;, containing the two characters &lt;code&gt;\&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt;  is automatically transformed into a string containing a single literal tab character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a result, any backslash is automatically removed.&#xA;This is undesirable if your string must be passed to Vim's regex engine.&#xA;For example, if you want to pass the regex &lt;code&gt;\s\+&lt;/code&gt; to Vim's regex engine via &lt;code&gt;matchadd()&lt;/code&gt;, it won't work when using double quotes to surround your string, because &lt;code&gt;\s\+&lt;/code&gt; will be replaced by &lt;code&gt;s+&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to either use single quotes (see &lt;code&gt;:h expr-'&lt;/code&gt;) because it will prevent the interpolation, or double the backslashes, so that even after Vim removes a backslash, another one still remains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually it's &lt;a href=&quot;https://google.github.io/styleguide/vimscriptguide.xml?showone=Strings#Strings&quot; rel=&quot;nofollow noreferrer&quot;&gt;recommended&lt;/a&gt; to use single quotes, unless you really need the double quotes:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Prefer single quoted strings&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Double quoted strings are semantically different in vimscript, and you&#xA;  probably don't want them (they break regexes).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Use double quoted strings when you need an escape sequence (such as&#xA;  &quot;\n&quot;) or if you know it doesn't matter and you need to embed single&#xA;  quotes.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-08-26T13:15:04.083" LastActivityDate="2018-08-26T13:15:04.083" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17185" PostTypeId="1" CreationDate="2018-08-26T16:41:27.180" Score="1" ViewCount="333" Body="&lt;p&gt;I have a plugin under &lt;code&gt;nvim/plugin/foo&lt;/code&gt;,  but the syntax file &lt;code&gt;nvim/plugin/foo/syntax/foo.vim&lt;/code&gt; is not automatically applied when the filetype change, but if I put it under &lt;code&gt;nvim/syntax/foo.vim&lt;/code&gt; it works&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm now manually doing this in &lt;code&gt;nvim/plugin/foo/autoload/foo.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:srcdir = expand('&amp;lt;sfile&amp;gt;:h:h:p')&#xA;&#xA;func! foo#open()&#xA;&#xA;    &quot; plugin stuff&#xA;    exec 'source ' . fnameescape(s:srcdir . '/syntax/foo.vim')&#xA;&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which I don't know if it's the right way to deal with plugin syntax&lt;/p&gt;&#xA;" OwnerUserId="18254" LastEditorUserId="18254" LastEditDate="2018-08-26T17:28:57.033" LastActivityDate="2019-12-19T23:02:55.460" Title="Syntax folder under plugin/foo/syntax/foo.vim not automatically applied when filetype change?" Tags="|syntax-highlighting|plugin-system|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17186" PostTypeId="1" CreationDate="2018-08-27T01:56:04.143" Score="1" ViewCount="739" Body="&lt;p&gt;I am using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-Space&amp;gt; i&#xA;&#xA;inoremap &amp;lt;C-Space&amp;gt; &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to map  to Esc. It works for all file with any extension but it doesn't work for the files with &quot;.tex&quot; extension ( I am using Vim-latex suite). I don't know why?&lt;/p&gt;&#xA;" OwnerUserId="14011" LastActivityDate="2018-08-27T19:59:45.630" Title="How to map &lt;C-Space&gt; to ESC" Tags="|key-bindings|filetype-tex|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="17187" PostTypeId="1" AcceptedAnswerId="17188" CreationDate="2018-08-27T06:53:48.377" Score="2" ViewCount="321" Body="&lt;p&gt;I know of 4 commands I can use in Vim's insert mode.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;C-w&lt;/code&gt; delete word&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C-k&lt;/code&gt; delete line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C-d&lt;/code&gt; delete one 'shiftwidth' worth of indent&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C-t&lt;/code&gt; add one 'shiftwidth' worth of indent&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C-O&lt;/code&gt; begin a &lt;a href=&quot;http://vim.wikia.com/wiki/Quick_command_in_insert_mode&quot; rel=&quot;nofollow noreferrer&quot;&gt;quick command&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My results from googling have been saturated with answers on how to switch from insert mode to normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The page for &lt;code&gt;:help &amp;lt;C-d&amp;gt;&lt;/code&gt; and the other insert mode commands is not what I'm looking for, it's always just the keystroke. How do I search for the specific commands available in insert mode? I don't know how to look it up...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;More generally, how do I look up commands specific to a single mode?&lt;/p&gt;&#xA;" OwnerUserId="14861" LastEditorUserId="14861" LastEditDate="2018-08-27T17:37:38.047" LastActivityDate="2018-08-27T17:44:24.280" Title="How do I find commands that're available in insert mode?" Tags="|insert-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17188" PostTypeId="2" ParentId="17187" CreationDate="2018-08-27T06:53:48.377" Score="4" Body="&lt;p&gt;All the documentation you're looking for can be found on the &lt;code&gt;:help insert&lt;/code&gt; page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything you're looking for will be under &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ins-special-keys&lt;/code&gt;&lt;/a&gt; section. As you can see from there, you can look up these commands using &lt;code&gt;:help&lt;/code&gt; by prefixing the keystroke with a shorthand for the mode followed by an underscore - which is &lt;code&gt;i_&lt;/code&gt; in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, to look up what &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; does in insert mode is, type &lt;code&gt;:help i_CTRL-]&lt;/code&gt;. To look up what &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; does in visual mode, type &lt;code&gt;:help v_CTRL-]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is one exception to this, though. If you want to look up what a normal mode keystroke does, then you don't need to add a prefix. That's a design choice that I agree with. So just type &lt;code&gt;:help CTRL-]&lt;/code&gt; to look up what &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; does in normal mode.&lt;/p&gt;&#xA;" OwnerUserId="14861" LastEditorUserId="14861" LastEditDate="2018-08-27T17:44:24.280" LastActivityDate="2018-08-27T17:44:24.280" CommentCount="2" CommunityOwnedDate="2018-08-27T06:53:48.377" ContentLicense="CC BY-SA 4.0" />
  <row Id="17189" PostTypeId="1" CreationDate="2018-08-27T13:42:25.923" Score="1" ViewCount="376" Body="&lt;p&gt;Is there a succinct way to separate folds, open or closed, by the same number of newlines throughout the buffer? I'm using fold by indent. The goal is two visible blank lines between each fold (actually, after the end of a fold, since folds will abut non-folds). So if there is one blank line it adds another, and if there are three or more blank lines, it removes blank lines down to two. I would like these as actual inserted or removed characters as opposed to mere visual updates. Enforcing this automatically would be nice but I'm fine having it mapped to a command for manual reformatting. Spaces between a final fold and the EOF are nice but optional.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before, with non-uniform spacing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HEADER 1&#xA;--------&#xA;- closed fold -----------------------------------------------------------&#xA;HEADER 2&#xA;--------&#xA;  opened fold&#xA;  opened fold&#xA;HEADER 3&#xA;--------&#xA;- closed fold -----------------------------------------------------------&#xA;&#xA;&#xA;&#xA;HEADER 4&#xA;--------&#xA;  opened fold&#xA;  opened fold&#xA;  opened fold&#xA;&#xA;&#xA;&#xA;HEADER 5&#xA;--------&#xA;- closed fold -----------------------------------------------------------&#xA;~ EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After, with uniform spacing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HEADER 1&#xA;--------&#xA;- closed fold -----------------------------------------------------------&#xA;&#xA;&#xA;HEADER 2&#xA;--------&#xA;  opened fold&#xA;  opened fold&#xA;&#xA;&#xA;HEADER 3&#xA;--------&#xA;- closed fold -----------------------------------------------------------&#xA;&#xA;&#xA;HEADER 4&#xA;--------&#xA;  opened fold&#xA;  opened fold&#xA;  opened fold&#xA;&#xA;&#xA;HEADER 5&#xA;--------&#xA;- closed fold -----------------------------------------------------------&#xA;&#xA;&#xA;~ EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13731" LastEditorUserId="13731" LastEditDate="2018-08-30T12:29:21.727" LastActivityDate="2018-08-30T12:29:21.727" Title="separating folds with constant amount of newlines" Tags="|key-bindings|formatting|folding|functions|line-breaks|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17192" PostTypeId="1" AcceptedAnswerId="17193" CreationDate="2018-08-27T23:58:46.483" Score="3" ViewCount="158" Body="&lt;p&gt;I don't usually have this much trouble debugging issues, but I'm starting to get stumped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The line doesn't happen when typing the macro out (running it by hand). In fact, it's part of something I recorded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This doesn't happen when using &lt;code&gt;vim -u NONE&lt;/code&gt;, which leads me to believe it's due to something in my configuration. I tried to find the issue by deleting my configuration by sections until I found the one that caused it. However, I've moved and deleted &lt;strong&gt;all&lt;/strong&gt; run-time loaded vim code (I even moved &lt;code&gt;/usr/share/vim/&lt;/code&gt; elsewhere) as well as my &lt;code&gt;~/.viminfo&lt;/code&gt; files and the problem still persists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I listed all vim related files that vim referred to in system calls:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ strace -fe trace=file vim +q |&amp;amp; grep -Po '[^&quot;]*vim[^&quot;]*(?=&quot;)' | sort | uniq&#xA;/etc/vimrc&#xA;/home/jol/.vim/after/pack/&#xA;/home/jol/.vim/after/plugin/&#xA;/home/jol/.viminfo&#xA;/home/jol/.vim/pack/&#xA;/home/jol/.vim/plugin/&#xA;/home/jol/.vimrc&#xA;/usr/bin/vim&#xA;/usr/share/vim&#xA;/usr/share/vim/lang/en/LC_MESSAGES/vim.mo&#xA;/usr/share/vim/lang/en_US/LC_MESSAGES/vim.mo&#xA;/usr/share/vim/lang/en_US.utf8/LC_MESSAGES/vim.mo&#xA;/usr/share/vim/lang/en_US.UTF-8/LC_MESSAGES/vim.mo&#xA;/usr/share/vim/lang/en.utf8/LC_MESSAGES/vim.mo&#xA;/usr/share/vim/lang/en.UTF-8/LC_MESSAGES/vim.mo&#xA;/usr/share/vim/pack/&#xA;/usr/share/vim/plugin/&#xA;/usr/share/vim/runtime&#xA;/usr/share/vim/vim81&#xA;/usr/share/vim/vimfiles/after/pack/&#xA;/usr/share/vim/vimfiles/after/plugin/&#xA;/usr/share/vim/vimfiles/pack/&#xA;/usr/share/vim/vimfiles/plugin/&#xA;vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/etc/vimrc&lt;/code&gt; and &lt;code&gt;~/.vimrc&lt;/code&gt; exist, but are empty. &lt;code&gt;~/.viminfo&lt;/code&gt; was generated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim -D&lt;/code&gt; in these circumstances only results in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Entering Debug mode.  Type &quot;cont&quot; to continue.&#xA;/etc/vimrc&#xA;line 2: End of sourced file&#xA;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea for further debugging is appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Hmm. I found something interesting. Apparently, &lt;code&gt;ofoo^[Obar^[&lt;/code&gt; works perfectly.... &lt;code&gt;ofoo^[Orar^[&lt;/code&gt; fails by making new line &quot;foo2ar&quot;. Running &lt;code&gt;:abbrev&lt;/code&gt; returns &quot;No abbreviation found&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 2: Macro &lt;code&gt;^[Orx^[&lt;/code&gt; deletes 2 letters from the cursor position. I guess it's evaluated like &lt;code&gt;2x&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 3: Macro &lt;code&gt;^[Otx^[&lt;/code&gt; works like &lt;code&gt;4x&lt;/code&gt;, and &lt;code&gt;ofoo^[Otx^[&lt;/code&gt; does indeed print &lt;code&gt;foo4x&lt;/code&gt; in a new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 4: Macro &lt;code&gt;ofoo^[Oyx^[&lt;/code&gt; only prints &lt;code&gt;foo&lt;/code&gt;, but &lt;code&gt;ofoo^[Oux^[&lt;/code&gt; prints &lt;code&gt;foo5x&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14283" LastEditorUserId="14283" LastEditDate="2018-08-28T01:46:51.837" LastActivityDate="2019-03-05T23:05:56.850" Title="Macro &quot;oend^[Ores^[&quot; results in new line &quot;end2es&quot;. How?" Tags="|macro|original-vim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17193" PostTypeId="2" ParentId="17192" CreationDate="2018-08-28T00:25:39.053" Score="3" Body="&lt;p&gt;When vim encounters &lt;code&gt;^[Or&lt;/code&gt; it interprets it as some kind of special key, for instance a function key.  Which specific one vim thinks it is I'm not sure, but for comparison the &lt;code&gt;&amp;lt;f3&amp;gt;&lt;/code&gt; key is often &lt;code&gt;^[OR&lt;/code&gt;.  These escape codes are interpreted in insert mode as keys to allow using function keys and arrow keys.  Ordinarily, it's not an issue because one types more slowly than a macro executes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution is to &lt;code&gt;set noesckeys&lt;/code&gt; prior to executing the macro.  This option is enabled by vim by default in nocompatible mode.  You can choose to re-enable it after or just keep it always off if you never use special keys in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative is to use the &lt;code&gt;&amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;&lt;/code&gt; method of exiting insert mode.  So the macro would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;oend^\^NOres^\^N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other control characters could be used, such as &lt;code&gt;ctrl-@&lt;/code&gt;, which is a no-op in normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;oend^[^@Ores^[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will separate the &lt;code&gt;^[Or&lt;/code&gt; into an unambiguous sequence of commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also insert a sleep command (&lt;code&gt;gs&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;oend^[gsOres^[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^[gs&lt;/code&gt; is not usually recognized as an escape sequence.&#xA;However, this will also cause the macro to sleep for one second.  To get around this, we can remap &lt;code&gt;gs&lt;/code&gt; to a similar &quot;no operation&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gs &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; gs :&amp;lt;c-u&amp;gt;sleep 10m&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you would like a shorter sleep.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2019-03-05T23:05:56.850" LastActivityDate="2019-03-05T23:05:56.850" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="17194" PostTypeId="1" CreationDate="2018-08-28T02:41:26.053" Score="3" ViewCount="730" Body="&lt;p&gt;I'm trying to define an insert mapping like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; ; (Test(expand('&amp;lt;cWORD&amp;gt;'))).&amp;quot;;&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;in which the &lt;code&gt;Test&lt;/code&gt; function is defined as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func! Test(a)&#xA;    echom &amp;quot;cword: &amp;quot;.&amp;quot;\&amp;quot;&amp;quot;.a:a.&amp;quot;\&amp;quot;&amp;quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For example, if the current position of the cursor is like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;apple|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I type &lt;code&gt;;&lt;/code&gt;, I'm expecting a message saying: &lt;code&gt;cword: &amp;quot;apple&amp;quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But currently, I can only get an empty result like: &lt;code&gt;cword: &amp;quot;&amp;quot;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The question is why does the &lt;code&gt;expand()&lt;/code&gt; function here always returns an empty string?&lt;/p&gt;&#xA;" OwnerUserId="18764" LastEditorUserId="1841" LastEditDate="2021-04-27T09:49:38.910" LastActivityDate="2021-04-27T09:49:38.910" Title="expand('&lt;cWORD&gt;') returns empty string in inoremap" Tags="|vimrc|key-bindings|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17195" PostTypeId="1" CreationDate="2018-08-28T07:56:40.050" Score="0" ViewCount="285" Body="&lt;p&gt;I got a strange behavior of vim 8.1 1-279 / archlinux 4.17.14&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is vim under console but I believe there's no different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim force create &lt;code&gt;~/.cache/vim/{backup,swap,undo}&lt;/code&gt; folders even I &lt;code&gt;set noundofile nobackup noswapfile&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something that I missed?&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2018-08-28T07:56:40.050" Title="Vim still create backup/swap/undo folder under .cache when set nobackup/noswapfile/noundofile" Tags="|vimrc|vimscript|" AnswerCount="0" CommentCount="5" ClosedDate="2018-08-29T08:31:06.693" ContentLicense="CC BY-SA 4.0" />
  <row Id="17196" PostTypeId="2" ParentId="17194" CreationDate="2018-08-28T08:06:11.847" Score="2" Body="&lt;p&gt;As others have said, if you stay in insert mode, the cursor will be one character too far for &lt;code&gt;expand('&amp;lt;cword&amp;gt;')&lt;/code&gt; to return anything useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why a long time ago I wrote &lt;a href=&quot;http://hermitte.free.fr/vim/general.php#expl_words_tools&quot; rel=&quot;nofollow noreferrer&quot;&gt;these functions&lt;/a&gt;, now &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/ui.vim#L52&quot; rel=&quot;nofollow noreferrer&quot;&gt;part of lh-vim-lib&lt;/a&gt;. Typically you'd be interested in &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! lh#ui#GetCurrentWord()&#xA;  let c = col ('.')-1&#xA;  let l = line('.')&#xA;  let ll = getline(l)&#xA;  let ll1 = strpart(ll,0,c)&#xA;  let ll1 = matchstr(ll1,'\S*$')&#xA;  if strlen(ll1) == 0&#xA;    return ll1&#xA;  else&#xA;    let ll2 = strpart(ll,c,strlen(ll)-c+1)&#xA;    let ll2 = strpart(ll2,0,match(ll2,'$\|\s'))&#xA;    return ll1.ll2&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code is quite old and could be simplified.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-08-29T10:24:09.467" LastActivityDate="2018-08-29T10:24:09.467" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17198" PostTypeId="1" AcceptedAnswerId="17201" CreationDate="2018-08-28T11:06:15.290" Score="2" ViewCount="593" Body="&lt;p&gt;every now and then my neovim just stops the correct indenting and i have to restart the session.&#xA;Besides the indenting, some plugins seem to stop working as well as some built in function like the &lt;kbd&gt;o&lt;/kbd&gt; key. It then places the cursor to the very beginning of the next line. Very annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've already tried to remove all the plugins and install only the basic and necessary ones, and it seemed to work. Than I've added one after one to narrow this issue. After I thought I've found the bad plugin I removed it but some days later the issue showed up again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to get the reason for this kind of issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find &lt;a href=&quot;https://github.com/Artem-Schander/dotfiles&quot; rel=&quot;nofollow noreferrer&quot;&gt;my dotfiles at my github account&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I know, there is a &lt;a href=&quot;https://vi.stackexchange.com/questions/15152/vim-auto-indent-suddenly-stopped-working&quot;&gt;similar issue&lt;/a&gt; at this Q&amp;amp;A. But I don't think it's the same. And besides that, it has no answer.&lt;/p&gt;&#xA;" OwnerUserId="12115" LastEditorUserId="12115" LastEditDate="2018-08-28T12:50:25.457" LastActivityDate="2018-08-28T18:09:23.940" Title="vim suddenly stops indenting and uses tabs instead of spaces" Tags="|neovim|indentation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17199" PostTypeId="1" CreationDate="2018-08-28T11:51:22.763" Score="1" ViewCount="244" Body="&lt;p&gt;Yesterday, I Installed vim and some colorscheme like gruvbox, monokai, molokai.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set it in &lt;code&gt;~/.vimrc&lt;/code&gt; and turned on the syntax highlight, everything work well on HTML but in ruby files (&lt;code&gt;.rb&lt;/code&gt;) it still have colorscheme but few keywords like &lt;code&gt;puts&lt;/code&gt; and &lt;code&gt;print&lt;/code&gt; are still in grey color, it looks weird and boring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is two syntax I'd using alot during the time I learning. Can anyone help me?&lt;/p&gt;&#xA;" OwnerUserId="18767" LastEditorUserId="1841" LastEditDate="2018-08-28T12:00:27.877" LastActivityDate="2018-12-05T16:01:30.253" Title="Installed and set colorscheme but method puts and print not working on ruby" Tags="|syntax-highlighting|colorscheme|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17201" PostTypeId="2" ParentId="17198" CreationDate="2018-08-28T18:09:23.940" Score="3" Body="&lt;p&gt;I also get this from time to time when I paste into vim. I usually do &lt;code&gt;:set nopaste&lt;/code&gt; and reindent (with &lt;code&gt;gg=G&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="15295" LastActivityDate="2018-08-28T18:09:23.940" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17202" PostTypeId="2" ParentId="12058" CreationDate="2018-08-28T18:10:42.597" Score="4" Body="&lt;p&gt;Send the buffer to the browser by converting to HTML, then print from there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:TOhtml | w | !open -a Safari %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example I have this in vim:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/mjkJy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mjkJy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I type &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ha&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/1wP2f.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1wP2f.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I send it to the browser I get this (with color scheme!):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5DjG7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5DjG7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this in my .vimrc, which deletes the new html buffer and stored file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; &amp;lt;ESC&amp;gt; :TOhtml &amp;lt;bar&amp;gt; w &amp;lt;bar&amp;gt; !open -a Safari % &amp;lt;CR&amp;gt; &amp;lt;bar&amp;gt; ZQ &amp;lt;CR&amp;gt; &amp;lt;bar&amp;gt; execute '!rm %:p.html' &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15070" LastActivityDate="2018-08-28T18:10:42.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17203" PostTypeId="2" ParentId="17189" CreationDate="2018-08-29T00:00:03.383" Score="1" Body="&lt;p&gt;An easy way to append lines is by using the append() function, that takes the&#xA;a line number and a list of lines to append. As append() also accepts the string&#xA;'.' as a synonym for the current line, a simple map to insert two blank lines is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Ctrl-L can be changed according to your preferences&#xA;nnoremap &amp;lt;C-L&amp;gt; :call append('.', ['', ''])&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for the folding, you can set 'foldmethod' to &quot;expr&quot; and define your own fold&#xA;expression to suit your specific problem. In this case, you could do something&#xA;like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldminlines=0      &quot; Allows folding a single line&#xA;set foldmethod=expr     &quot; Use custom expression to define foldsj&#xA;set foldexpr=FoldAfterTwoEmptyLines(v:lnum) &quot; The expression&#xA;&#xA;function! FoldAfterTwoEmptyLines(lnum) abort&#xA;    if getline(a:lnum - 1) =~# '^-\+$'&#xA;        &quot; If the line is just a series of ------&#xA;        return '&amp;gt;1'     &quot; Starts fold with depth 1&#xA;    elseif getline(a:lnum) =~# '\S'&#xA;        &quot; If the line has contents&#xA;        if getline(a:lnum + 1) =~# '^\s*$' &amp;amp;&amp;amp; getline(a:lnum + 2) =~# '^\s*$'&#xA;            &quot; If the next two lines are empty&#xA;            return '&amp;lt;1' &quot; Ends fold with depth 1&#xA;        else&#xA;            return '-1' &quot; Use fold of surroundings&#xA;        endif&#xA;    else&#xA;        return '0'      &quot; No fold&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18087" LastActivityDate="2018-08-29T00:00:03.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17204" PostTypeId="1" CreationDate="2018-08-29T02:27:50.710" Score="2" ViewCount="223" Body="&lt;p&gt;my mapping is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.vimrc&#xA;inoremap &amp;lt;C-h&amp;gt; &amp;lt;left&amp;gt;&#xA;inoremap &amp;lt;c-l&amp;gt; &amp;lt;right&amp;gt;&#xA;inoremap &amp;lt;c-j&amp;gt; &amp;lt;up&amp;gt;&#xA;inoremap &amp;lt;c-k&amp;gt; &amp;lt;down&amp;gt;&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, if I press &lt;code&gt;ctrl+h&lt;/code&gt; in insert mode, vim will delete character on the left of cursor, which function is same as &lt;code&gt;backspace&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16299" LastActivityDate="2018-08-29T02:27:50.710" Title="inoremap ctrl h to move left in insert mode not work (it delete the left character exactly)" Tags="|vimrc|key-bindings|" AnswerCount="0" CommentCount="1" ClosedDate="2018-08-29T08:18:49.367" ContentLicense="CC BY-SA 4.0" />
  <row Id="17205" PostTypeId="2" ParentId="17189" CreationDate="2018-08-29T10:03:29.533" Score="1" Body="&lt;h2&gt;Ad-hoc macro solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I couldn't be bothered doing maths, so I implemented this with normal editing&#xA;commands in a recursive macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg2zjqqqqqzko&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;d/^.&amp;lt;CR&amp;gt;zjzj@qq@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read on to see how this works, or skip to the bottom for a mapping you can paste into your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;How it works&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;First move to the top of the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Move to the start of the second fold:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2zj&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Start recording a recursive macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqqqq&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Move to the end of the previous fold:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;zk&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add &lt;em&gt;three&lt;/em&gt; blank lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;o&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Delete the third blank line, and any others that may already have existed&#xA;before the header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d/^.&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Move down to the third fold (N.B. We cannot use &lt;code&gt;zj&lt;/code&gt; here because we need&#xA;the failed movement to terminate the recursive macro. If you run &lt;code&gt;2zj&lt;/code&gt; when&#xA;there is only one more fold, the movement still succeeds: it just moves down&#xA;a single fold):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;zjzj&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Replay the macro (Currently, because of step 3, register &lt;code&gt;&quot;q&lt;/code&gt; is empty, so&#xA;this has no effect):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@q&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;End recording and play the recursive macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;q@q&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This works for the sample given, but might need some tweaks for a robust&#xA;solution. (e.g. What if the first fold starts on the first line of the file? What do you want it to do for nested folds? etc.)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;A Proper Solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Of course, you don't want to have to keep this permanently in one of your&#xA;registers, so let's wrap it in a function and create a mapping to invoke it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SpaceFolds() abort&#xA;  &quot; Save the current window view state&#xA;  let saved_view = winsaveview()&#xA;&#xA;  &quot; Save the current contents of register q&#xA;  let register_contents = @q&#xA;&#xA;  &quot; Run the preamble commands&#xA;  normal! gg2zj&#xA;&#xA;  &quot; Set up the macro&#xA;  let @q = &quot;zko\&amp;lt;CR&amp;gt;\&amp;lt;CR&amp;gt;\&amp;lt;Esc&amp;gt;d/^.\&amp;lt;CR&amp;gt;zjzj@q&quot;&#xA;&#xA;  &quot; Run it&#xA;  normal! @q&#xA;&#xA;  &quot; Restore register q and window state&#xA;  let @q = register_contents&#xA;  call winrestview(saved_view)&#xA;endfunction&#xA;&#xA;nnoremap zs :call SpaceFolds()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-08-29T10:03:29.533" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17206" PostTypeId="1" AcceptedAnswerId="17208" CreationDate="2018-08-29T13:16:31.330" Score="0" ViewCount="167" Body="&lt;p&gt;I do use Ag as my grep replacement. My problem is that when I search for something that does not exist (search result empty) my quick fix windows closes automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that normal? Would it be possible to keep it open with something like &quot;No results found&quot; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my config&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; bind \ (backward slash) to grep shortcut&#xA;&quot; https://robots.thoughtbot.com/faster-grepping-in-vim&#xA;&quot; https://vi.stackexchange.com/questions/14923/my-ag-shortcut-chokes-on-spaces&#xA;function! Ag(args) abort&#xA;  execute &quot;silent! grep!&quot; shellescape(a:args)&#xA;  cwindow&#xA;  redraw!&#xA;endfunction&#xA;command! -nargs=+ -complete=file Ag call Ag(&amp;lt;q-args&amp;gt;)&#xA;nnoremap \ :Ag&amp;lt;SPACE&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help&lt;/p&gt;&#xA;" OwnerUserId="18780" LastActivityDate="2018-08-29T14:26:56.453" Title="How to keep Ag (the silver searcher) open when no matches are found?" Tags="|vimrc|the-silver-searcher|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17207" PostTypeId="1" AcceptedAnswerId="17212" CreationDate="2018-08-29T13:50:10.130" Score="3" ViewCount="112" Body="&lt;p&gt;I'm wondering, if there's a way to move with &lt;code&gt;%&lt;/code&gt; in  CMakeLists.txt files between &lt;code&gt;foreach&lt;/code&gt; and &lt;code&gt;endforeach&lt;/code&gt;, &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;endif&lt;/code&gt;, &lt;code&gt;function&lt;/code&gt; and &lt;code&gt;endfunction&lt;/code&gt;, …&lt;/p&gt;&#xA;&#xA;&lt;p&gt;googeling I only found plugins that allow calling cmake from within vim, but not for editing &lt;code&gt;CMakeLists.txt&lt;/code&gt; files.&lt;/p&gt;&#xA;" OwnerUserId="6044" LastActivityDate="2018-08-29T16:35:25.310" Title="cmake movement plugin" Tags="|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17208" PostTypeId="2" ParentId="17206" CreationDate="2018-08-29T13:57:19.650" Score="3" Body="&lt;p&gt;This is because you are using &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#:cwindow&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:cwindow&lt;/code&gt;&lt;/a&gt; to open the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :cwindow&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Open the quickfix window when there are recognized&#xA;              errors.  If the window is already open and there are&#xA;              no recognized errors, &lt;strong&gt;close the window.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(Emphasis mine.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change this to &lt;code&gt;:copen&lt;/code&gt; to always open the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the window to display &quot;No results found&quot; instead of just being empty, you will also need an autocommand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup AgQuickfix&#xA;  autocmd!&#xA;  autocmd BufReadPost quickfix setlocal modifiable&#xA;        \ | if line('$') == 1 &amp;amp;&amp;amp; empty(getline(1))&#xA;        \ |   call setline(1, &quot;No results found&quot;) &#xA;        \ | endif&#xA;        \ | setlocal nomodifiable&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is described in &lt;code&gt;:help quickfix.txt&lt;/code&gt; (search for &lt;code&gt;BufReadPost&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-08-29T14:26:56.453" LastActivityDate="2018-08-29T14:26:56.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17209" PostTypeId="2" ParentId="17207" CreationDate="2018-08-29T16:07:04.900" Score="2" Body="&lt;p&gt;I didn't find an existing solution, but the way to implement that doesn't seem too hard. One needs the matchit plugin (cf &lt;a href=&quot;https://vi.stackexchange.com/a/784/6044&quot;&gt;https://vi.stackexchange.com/a/784/6044&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; in .vimrc&#xA;runtime macros/matchit.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And can then define &lt;code&gt;b:match_words&lt;/code&gt; e.g. in &lt;a href=&quot;https://github.com/pseyfert/vim/commit/e2cab48637c3a04a502724e26c80d6b602c17a55&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;.vim/ftplugin/cmake.vim&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;loaded_matchit&quot;)&#xA;  let b:match_words =  '^[^#]*\&amp;lt;if\&amp;gt;\s*(:^[^#]*\&amp;lt;else\&amp;gt;\s*(:^[^#]*\&amp;lt;elseif\&amp;gt;\s*(:^[^#]*\&amp;lt;endif\&amp;gt;\s*(\c'&#xA;  let b:match_words .= ',^[^#]*\&amp;lt;function\&amp;gt;\s*(:^[^#]*\&amp;lt;endfunction\&amp;gt;\s*(\c'&#xA;  let b:match_words .= ',^[^#]*\&amp;lt;foreach\&amp;gt;\s*(:^[^#]*\&amp;lt;endforeach\&amp;gt;\s*(\c'&#xA;  let b:match_words .= ',^[^#]*\&amp;lt;macro\&amp;gt;\s*(:^[^#]*\&amp;lt;endmacro\&amp;gt;\s*(\c'&#xA;  let b:match_words .= ',^[^#]*\&amp;lt;while\&amp;gt;\s*(:^[^#]*\&amp;lt;endwhile\&amp;gt;\s*(\c'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to be honest I bodged this quickly and didn't go through the entire &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/pack/dist/opt/matchit/doc/matchit.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;matchit documentation&lt;/a&gt;, but so far it seems to do the job.&lt;/p&gt;&#xA;" OwnerUserId="6044" LastEditorUserId="6044" LastEditDate="2018-08-29T16:30:31.347" LastActivityDate="2018-08-29T16:30:31.347" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17210" PostTypeId="1" CreationDate="2018-08-29T16:13:17.027" Score="21" ViewCount="10748" Body="&lt;p&gt;I have a few packages installed in my &lt;code&gt;~/.vim/pack/default/start&lt;/code&gt; directory, for example &lt;a href=&quot;https://github.com/godlygeek/tabular&quot; rel=&quot;noreferrer&quot;&gt;Tabular&lt;/a&gt; and &lt;a href=&quot;https://github.com/godlygeek/tabular&quot; rel=&quot;noreferrer&quot;&gt;Unicode&lt;/a&gt;.  After starting up vim I can use these packages but cannot access their help information.  Issuing &lt;code&gt;helptags ~/.vim/pack/default/start/tabular.vim/doc&lt;/code&gt; doesn't resolve this; neither does &lt;code&gt;helptags ALL&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I've been starting vim with the same session file (i.e. &lt;code&gt;vim -S path/to/session.vim&lt;/code&gt;) for a few years.  When I start vim without specifying a session file, I can access documentation for these packages.  It would be nice to be able to keep my session and still access docs for packages but starting a new session is a usable workaround.&lt;/p&gt;&#xA;&lt;h2&gt;EDIT&lt;/h2&gt;&#xA;&lt;p&gt;Originally posted the below solution as an answer but for reasons unclear to me it was deleted.  It's not optimal but it fixed my problem, unlike the only other posted answer.&lt;/p&gt;&#xA;&lt;p&gt;I've been starting vim with the same session file (i.e. vim -S path/to/session.vim) for a few years. When I start vim without specifying a session file, I can access documentation for these packages. It would be nice to be able to keep my session and still access docs for packages but starting a new session is a usable workaround.&lt;/p&gt;&#xA;" OwnerUserId="9412" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2023-02-07T17:30:29.027" Title="Generating help tags for packages that are loaded by Vim 8's package management" Tags="|help-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17212" PostTypeId="2" ParentId="17207" CreationDate="2018-08-29T16:35:25.310" Score="5" Body="&lt;p&gt;You can achieve this easily using either the plugin matchit (distributed with vim, just use &lt;code&gt;packadd! matchit&lt;/code&gt;) or &lt;a href=&quot;https://github.com/andymass/vim-matchup&quot; rel=&quot;noreferrer&quot;&gt;match-up&lt;/a&gt; (external plugin).  The latter provides enhanced text objects and also enables highlighting of the words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To define the matches for cmake, create a file &lt;code&gt;.vim/after/ftplugin/cmake.vim&lt;/code&gt; containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('loaded_matchit')&#xA;    let b:match_words = '\&amp;lt;if\&amp;gt;:\&amp;lt;elseif\&amp;gt;\|\&amp;lt;else\&amp;gt;:\&amp;lt;endif\&amp;gt;'&#xA;      \ . ',\&amp;lt;foreach\&amp;gt;\|\&amp;lt;while\&amp;gt;:\&amp;lt;break\&amp;gt;:\&amp;lt;endforeach\&amp;gt;\|\&amp;lt;endwhile\&amp;gt;'&#xA;      \ . ',\&amp;lt;macro\&amp;gt;:\&amp;lt;endmacro\&amp;gt;'&#xA;      \ . ',\&amp;lt;function\&amp;gt;:\&amp;lt;endfunction\&amp;gt;'&#xA;    let b:match_ignorecase = 1&#xA;&#xA;    let b:undo_ftplugin .= &quot;| unlet b:match_words&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should work with either plugin.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-08-29T16:35:25.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17213" PostTypeId="2" ParentId="17210" CreationDate="2018-08-29T17:09:14.430" Score="29" Body="&lt;p&gt;Using &lt;code&gt;:helptags ALL&lt;/code&gt; should re-generate all helptags for all &lt;code&gt;doc&lt;/code&gt; directories in &lt;code&gt;runtimepath&lt;/code&gt;; which should include the &lt;code&gt;~/.vim/pack/default/start/*&lt;/code&gt; directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will probably get an error similar to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E152: Cannot open /usr/share/vim/vim81/doc/tags for writing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is safe to ignore. Vim will continue generating helptags after this error (check the output of &lt;code&gt;:100verbose :helptags ALL&lt;/code&gt; if you don't believe me).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For adding packages in the &lt;code&gt;opt&lt;/code&gt; directory as well, you can use (based on Peter Rincker's comment):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=0 -bar Helptags&#xA;    \  for p in glob('~/.vim/pack/bundle/opt/*', 1, 1)&#xA;    \|     exe 'packadd ' . fnamemodify(p, ':t')&#xA;    \| endfor&#xA;    \| helptags ALL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2018-08-29T18:04:36.413" LastActivityDate="2018-08-29T18:04:36.413" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17214" PostTypeId="1" AcceptedAnswerId="17217" CreationDate="2018-08-29T20:35:13.550" Score="4" ViewCount="390" Body="&lt;p&gt;Vim has a handy feature in &lt;code&gt;:syntax sync fromstart&lt;/code&gt; which allows me to fix syntax highlighting when it gets confused during an extended editing session. I map it to &lt;code&gt;&amp;lt;leader&amp;gt;ss&lt;/code&gt; (reSync from Start) because I use it so often.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I achieve the same effect with code folding that uses a fold expression? From time-to-time, especially when commenting out areas of code, the folds will get out of sync with the actual buffer contents, and I'd be more than happy to wait the fraction of a second it would take Vim to recalculate the folds from scratch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm happy for a short script if that's what it would take. I'm developing my vimscript-fu and would be happy for the exercise :)&lt;/p&gt;&#xA;" OwnerUserId="10196" LastActivityDate="2018-08-30T03:21:11.537" Title="Re-sync _folds_ from start" Tags="|vimscript|syntax-highlighting|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17215" PostTypeId="1" CreationDate="2018-08-30T00:24:09.707" Score="2" ViewCount="61" Body="&lt;p&gt;I am looking to insert list items&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;to-buy&#xA;&amp;gt; apple&#xA;&amp;gt; milk&#xA;&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I would like to insert a constant string (&quot; &gt; &quot;) on each newline&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is there a way to do this?&lt;/p&gt;&#xA;" OwnerUserId="18789" LastActivityDate="2018-10-01T13:25:58.377" Title="Can I substitute the value of enter/return?" Tags="|key-bindings|list|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17216" PostTypeId="2" ParentId="17215" CreationDate="2018-08-30T02:24:22.440" Score="0" Body="&lt;p&gt;You can remap the behaviour of &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; in insert-mode to a custom function that checks whether you are on a line starting with any amount of whitespace, then &lt;code&gt;&amp;gt;&lt;/code&gt; then any other characters. If so, enter a new-line and start with &lt;code&gt;&amp;gt;&lt;/code&gt;, otherwise enter a new-line as normal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MakeNewLine()&#xA;    if getline(line('.')) =~# &quot;^\s*&amp;gt;.*$&quot;&#xA;        execute &quot;normal! a\&amp;lt;cr&amp;gt;&amp;gt; &quot;&#xA;        startinsert!&#xA;    else&#xA;        execute &quot;normal! a\&amp;lt;cr&amp;gt;&quot;&#xA;        normal! ^&#xA;        startinsert&#xA;    endif&#xA;endfunction&#xA;inoremap &amp;lt;cr&amp;gt; &amp;lt;esc&amp;gt;:call MakeNewLine()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put this in your &lt;code&gt;~/.vimrc&lt;/code&gt;, &lt;code&gt;~/_vimrc&lt;/code&gt; or equivalent so it is run every time you run vim. When you enter a new-line in a &lt;code&gt;&amp;gt;&lt;/code&gt; list in the middle of an entry, this also has the effect of splitting it into two entries.&lt;/p&gt;&#xA;" OwnerUserId="18654" LastEditorUserId="18654" LastEditDate="2018-08-30T02:46:26.103" LastActivityDate="2018-08-30T02:46:26.103" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17217" PostTypeId="2" ParentId="17214" CreationDate="2018-08-30T03:21:11.537" Score="5" Body="&lt;p&gt;It sounds like you're looking for &lt;code&gt;zx&lt;/code&gt; or &lt;code&gt;zX&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the Vim documentation on &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/fold.html&quot; rel=&quot;noreferrer&quot;&gt;fold&lt;/a&gt;,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;zx&lt;br&gt;&#xA;  Update folds: Undo manually opened and closed folds: re-apply&#xA;  'foldlevel', then do &quot;zv&quot;: View cursor line. Also forces recomputing&#xA;  folds. This is useful when using 'foldexpr' and the buffer is changed&#xA;  in a way that results in folds not to be updated properly.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;zX&lt;br&gt;&#xA;  Undo manually opened and closed folds: re-apply 'foldlevel'. Also&#xA;  forces recomputing folds, like |zx|.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2018-08-30T03:21:11.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17218" PostTypeId="1" CreationDate="2018-08-30T03:47:39.483" Score="0" ViewCount="139" Body="&lt;p&gt;I have two opening buffers and one has &lt;code&gt;foldenable&lt;/code&gt; and &lt;code&gt;foldmethod=indent&lt;/code&gt;, other has &lt;code&gt;nofoldenable&lt;/code&gt; and &lt;code&gt;foldmethod=syntax&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need that when I move between buffers, each buffer has it own &lt;code&gt;fold&lt;/code&gt; settings and for example a buffer keeps folded even I move to other buffer that has &lt;code&gt;nofoldenable&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can we achieve this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim 8.1 / Archlinux&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2020-09-18T08:01:15.117" Title="[no]foldenable / foldmethod for each buffer but keep those settings persist for each buffer" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17219" PostTypeId="2" ParentId="17218" CreationDate="2018-08-30T03:57:55.687" Score="0" Body="&lt;p&gt;We can achieve this by set &lt;code&gt;setlocal&lt;/code&gt; for &lt;code&gt;python&lt;/code&gt; file and &lt;code&gt;nofoldenable&lt;/code&gt; in global in &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2018-08-30T03:57:55.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17220" PostTypeId="1" CreationDate="2018-08-30T04:55:16.080" Score="0" ViewCount="197" Body="&lt;p&gt;When I setup vim for colors in terminal, I'd like it has the same as in console, so Does console support 256color? as I'm using xterm-256color in a terminal right now?&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2018-08-30T04:55:16.080" Title="Does Vim in console/tty have same colors set as in terminal/xterm-256color?" Tags="|vimrc|terminal|console|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17221" PostTypeId="2" ParentId="17161" CreationDate="2018-08-30T06:32:42.260" Score="1" Body="&lt;p&gt;In command mode enter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep &quot;^\s*set\s&quot; % || :copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This produces an output like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;desktop/a.tcl|11 col 1| set set&#xA;desktop/a.tcl|14 col 1| set example {1 2 3}&#xA;desktop/a.tcl|21 col 1| set pos [lsearch -exact $set $el]&#xA;desktop/a.tcl|22 col 1| set set [lreplace $set $pos $pos]&#xA;desktop/a.tcl|25 col 1| set set&#xA;desktop/a.tcl|32 col 1| set res {}&#xA;desktop/a.tcl|34 col 1| set res  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It extracts all lines starting with optional whitespace (&lt;code&gt;^\s&lt;/code&gt;), the word &lt;code&gt;set&lt;/code&gt;, and at least one whitespace (&lt;code&gt;\s&lt;/code&gt;) into the quickfix list, then opens the quickfix window (&lt;code&gt;|| :copen&lt;/code&gt;) to show the list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Source code is the &quot;Sets as lists&quot; example from &lt;a href=&quot;https://en.wikibooks.org/wiki/Tcl_Programming/Examples&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikibooks.org/wiki/Tcl_Programming/Examples&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make things more generic, you can put this line in your Vim configuration file (&lt;code&gt;~/.vimrc&lt;/code&gt; if you are on Linux):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 FindFirstWord :vimgrep &quot;^\s*&amp;lt;args&amp;gt;\s&quot; % || :copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can search any &quot;first word&quot; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:FindFirstWord proc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 desktop/a.tcl|1 col 1| proc set'contains {set el} {expr {[lsearch -exact $set $el]&amp;gt;=0}}&#xA;2 desktop/a.tcl|6 col 1| proc set'add {_set args} {&#xA;3 desktop/a.tcl|18 col 1| proc set'remove {_set args} {&#xA;4 desktop/a.tcl|30 col 1| proc set'intersection {a b} {&#xA;5 desktop/a.tcl|38 col 1| proc set'union {a b} {&#xA;6 desktop/a.tcl|46 col 1| proc set'difference {a b} {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for the same sample code from above.&lt;/p&gt;&#xA;" OwnerUserId="18342" LastEditorUserId="18342" LastEditDate="2018-08-31T05:01:15.587" LastActivityDate="2018-08-31T05:01:15.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17222" PostTypeId="2" ParentId="17161" CreationDate="2018-08-30T08:39:04.877" Score="1" Body="&lt;p&gt;LSP approaches are likely to be better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If no LSP server for Tcl exists, check whether universal-ctags supports local variables in Tcl -- I've just checked that exuberant-ctags doesn't. Once universal-ctags has been properly installed, you can check this with &lt;code&gt;ctags --list-kinds | less&lt;/code&gt; + &lt;code&gt;/Tcl&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, you can then run &lt;code&gt;ctags&lt;/code&gt; on your local file with &lt;code&gt;--kinds-Tcl=l&lt;/code&gt; (if &lt;code&gt;l&lt;/code&gt; is the right kind), make sure that within Vim the tag file produced is registered to the &lt;code&gt;&amp;amp;tags&lt;/code&gt; option, then &lt;code&gt;filter()&lt;/code&gt; the tag entries (&lt;code&gt;taglist()&lt;/code&gt;) to extract those with the &lt;code&gt;l&lt;/code&gt; (?) kind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I almost forgot, you'll also need to extract the &lt;a href=&quot;https://github.com/LucHermitte/lh-dev/blob/OO-lhtags/autoload/lh/dev.vim#L87&quot; rel=&quot;nofollow noreferrer&quot;&gt;boundaries of function definitions&lt;/a&gt; (there is a &lt;code&gt;end&lt;/code&gt; &lt;em&gt;field&lt;/em&gt; that universal-ctags can provide, unlike ex-ctags) in order to know the functions your local variables belong to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I'm providing an already fully integrated way to extract local variables though my &lt;a href=&quot;https://github.com/LucHermitte/lh-dev/blob/OO-lhtags/autoload/lh/dev.vim#L129&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-dev&lt;/a&gt; and &lt;a href=&quot;https://github.com/LucHermitte/lh-tags/tree/OO&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-tags&lt;/a&gt; plugins -- as I'm in the process of refactoring these two, if you're interested, drop me an email.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-08-30T15:38:38.520" LastActivityDate="2018-08-30T15:38:38.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17225" PostTypeId="1" AcceptedAnswerId="17250" CreationDate="2018-08-30T15:42:04.220" Score="3" ViewCount="778" Body="&lt;p&gt;&lt;strong&gt;Foreword&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use UltiSnips and have the following definitions in my &lt;code&gt;.vimrc&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;F8&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;F8&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;S-F8&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third definition doesn't work; the strange behavior I witness is that &lt;kbd&gt;⇧&lt;/kbd&gt;+&lt;kbd&gt;F8&lt;/kbd&gt; switches the case of the letter under the cursor and that after it and move to the next char just as I had hit &lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;~&lt;/kbd&gt; in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Troubleshooting&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mindful of &lt;a href=&quot;https://github.com/junegunn/fzf/issues/1238&quot; rel=&quot;nofollow noreferrer&quot;&gt;another strange keyboard behavior I experienced in the bash with fzf&lt;/a&gt;, I decided to investigate which escape sequence is sent when I press (shifted) function keys, by issuing them in the terminal prepended by &lt;kbd&gt;⇧&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt;.&#xA;What I &quot;discovered&quot; is that &lt;kbd&gt;⇧&lt;/kbd&gt;+&lt;kbd&gt;F8&lt;/kbd&gt; sends &lt;code&gt;^[[32~&lt;/code&gt;, which is the same escape sequence sent by &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt;&lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;~&lt;/kbd&gt;, which indeed does the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; exits UltiSnips' select mode, thus returning to normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;[&lt;/kbd&gt;&lt;kbd&gt;3&lt;/kbd&gt; do nothing since the latter &quot;kills&quot; the former, which doesn't expect a digit after it&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;~&lt;/kbd&gt; switch the case of under-cursor and immediately-after-cursor letters and moves to next character&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;which is what I see happening everytime.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, I've checked that function keys from &lt;kbd&gt;F1&lt;/kbd&gt; to &lt;kbd&gt;F4&lt;/kbd&gt; send &lt;code&gt;^[[11~ ^[[12~ ^[[13~ ^[[14~&lt;/code&gt; whereas combinations from &lt;kbd&gt;⇧&lt;/kbd&gt;+&lt;kbd&gt;F1&lt;/kbd&gt; to &lt;kbd&gt;⇧&lt;/kbd&gt;+&lt;kbd&gt;F4&lt;/kbd&gt; send &lt;code&gt;^[[23~ ^[[24~ ^[[25~ ^[[26~&lt;/code&gt;; based on these escape sequences I'd expect all these keys to misbehave (in the same way too, except for the count), but they don't! &#xA;Of the aforementioned 8 combinations, only &lt;kbd&gt;⇧&lt;/kbd&gt;+&lt;kbd&gt;F3&lt;/kbd&gt; switches the case of the following 5 letters (as the &lt;code&gt;^[[5~&lt;/code&gt; escape sequence implies), and the others do nothing (they don't even exit the select mode!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Info&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use URxvt, &lt;code&gt;$TERM&lt;/code&gt; is &lt;code&gt;rxvt-unicode-256color&lt;/code&gt; and Vim version is 8.1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Related question(s) and pages&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first time I had this problem was long ago and I searched for an answer already; since then I've forgotted I had found a related (actually exactly the same) &lt;a href=&quot;https://vi.stackexchange.com/questions/8461/shiftf8-changes-letter-case-for-2-letters-how-to-unmap-this&quot;&gt;question&lt;/a&gt; but it was and is still &lt;strong&gt;unanswered&lt;/strong&gt; (maybe this is way I've forgotten it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is a related wikipage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/vim-vdebug/vdebug/issues/359&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is a related issue on GitHub.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="51" LastEditDate="2018-09-02T17:16:40.937" LastActivityDate="2018-09-02T17:16:40.937" Title="Some function keys switch cases of letters under and after the cursor" Tags="|key-bindings|plugin-ultisnips|escape|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17226" PostTypeId="1" AcceptedAnswerId="17306" CreationDate="2018-08-30T16:19:30.123" Score="7" ViewCount="9795" Body="&lt;p&gt;When I type &lt;code&gt;:terminal&lt;/code&gt; to vim8.1, it splits the window and I use it split window. I want to open a new buffer and open the terminal inside it. Basically, like neovim's terminal emulator. Is there a way to do like this?&lt;/p&gt;&#xA;" OwnerUserId="18674" LastActivityDate="2018-09-06T08:22:20.523" Title="Opening :terminal window in new buffer" Tags="|terminal|terminal-buffer|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17227" PostTypeId="1" AcceptedAnswerId="17260" CreationDate="2018-08-31T01:36:56.780" Score="5" ViewCount="2575" Body="&lt;p&gt;I renamed a big folder that contains a lot of files I recently edited.&#xA;After changing the name, my neovim's &lt;code&gt;v:oldfiles&lt;/code&gt; list contains the old names that is no longer accessible. How can I clean the list or fix the list to reflect the renaming. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;fzf&lt;/code&gt; to access the mru files.&#xA;I tried to set the variable directly but it doesn't work&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I followed the selected answer to solve the problem for &lt;code&gt;neovim&lt;/code&gt;. But when I write the file, even without any change and directly do &lt;code&gt;:w&lt;/code&gt;, I encounter the following error and have no idea how to solve it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &#xA;shada#get_binstrings[1]..shada#strings_to_sd[9]..&#xA;&amp;lt;SNR&amp;gt;184_shada_convert_strings[87]..&#xA;&amp;lt;SNR&amp;gt;184_shada_eval[1]..msgpack#eval:&#xA;line   65: &#xA;E716: Key not present in Dictionary: &quot;py&#xA;E116: Invalid arguments for function add&#xA;Error detected while processing BufWriteCmd Auto commands for &quot;*.shada&quot;: &#xA;E686: Argument of writefile() must be a List&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt; The error is reported to &lt;a href=&quot;https://github.com/neovim/neovim/issues/8956&quot; rel=&quot;nofollow noreferrer&quot;&gt;neovim&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possible fix is to change line 609 of &lt;code&gt;runtime/autoload/msgpack.vim&lt;/code&gt; from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;elseif s =~# '-\?\%(inf\|nan\)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;elseif s =~# '^-\?\(inf\|nan\)$'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code affects all versions of neovim. &lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2020-06-16T04:58:26.603" LastActivityDate="2022-01-21T15:32:03.733" Title="How to remove entries from v:oldfiles list in neovim" Tags="|neovim|plugin-fzf|viminfo|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17228" PostTypeId="1" AcceptedAnswerId="17231" CreationDate="2018-08-31T02:06:33.610" Score="2" ViewCount="659" Body="&lt;p&gt;I'm trying to put the output of a command into a QuickFix list when a particular key is pressed. That command takes as its argument the word under the cursor, so my function looks basically like this (example; &lt;code&gt;ls&lt;/code&gt; is not actually my command):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set makeprg=ls\ $*&#xA;&#xA;function MyFunction()&#xA;    let word = expand(&quot;&amp;lt;cword&amp;gt;&quot;)&#xA;    silent make word&#xA;    copen&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And what it does is call with the literal word &lt;code&gt;word&lt;/code&gt;. If I use a &lt;code&gt;$&lt;/code&gt; before it, then the literal &lt;code&gt;$&lt;/code&gt; is used also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I put the value of &lt;code&gt;word&lt;/code&gt; into &lt;code&gt;make&lt;/code&gt; instead of those four letters?&lt;/p&gt;&#xA;" OwnerUserId="7559" LastActivityDate="2018-08-31T06:44:27.843" Title="Give variable to makeprg" Tags="|vimscript|quickfix|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17229" PostTypeId="2" ParentId="14079" CreationDate="2018-08-31T02:33:58.313" Score="0" Body="&lt;p&gt;I finally got this solution: that is to check the &lt;code&gt;&amp;amp;grepprg&lt;/code&gt;, which is a string. For &lt;code&gt;Glog&lt;/code&gt;, it should match &lt;code&gt;^git\&amp;gt;.*\&amp;lt;grep\&amp;gt;&lt;/code&gt;. (has exceptions since &lt;code&gt;grep&lt;/code&gt; may appear as filename)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function will look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function func()&#xA;    if &amp;amp;grepprg =~ 'git.*log'&#xA;        nnoremap &amp;lt;buffer&amp;gt; v &amp;lt;c-w&amp;gt;&amp;lt;cr&amp;gt;&amp;lt;C-w&amp;gt;L&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-08-31T02:56:39.633" LastActivityDate="2018-08-31T02:56:39.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17230" PostTypeId="1" AcceptedAnswerId="17240" CreationDate="2018-08-31T04:41:52.830" Score="4" ViewCount="672" Body="&lt;p&gt;I can use &lt;code&gt;getqflist()&lt;/code&gt; to get the whole list. But how can I know which is the currently selected item in the list? It is used if &lt;code&gt;:cc [nr]&lt;/code&gt; without specifying &lt;code&gt;nr&lt;/code&gt;. It is also used for &lt;code&gt;cnext&lt;/code&gt; and &lt;code&gt;cprev&lt;/code&gt;. But I have no way to extract this info.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-08-31T15:50:01.983" Title="how to get the index of the current item in quickfix list" Tags="|quickfix|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17231" PostTypeId="2" ParentId="17228" CreationDate="2018-08-31T06:44:27.843" Score="3" Body="&lt;p&gt;Most ex commands (except for :echo and :exe) take their arguments literally and do not evaluate VimScript expressions. To make that work, you need to wrap your command into an &lt;code&gt;:exe&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you would need to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;sil make&quot; word&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Have also a look the help &lt;code&gt;:h :exe&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-08-31T06:44:27.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17233" PostTypeId="1" AcceptedAnswerId="17267" CreationDate="2018-08-31T10:40:17.777" Score="2" ViewCount="400" Body="&lt;p&gt;I want to spellcheck a bunch of files with vim, so I run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for a in *.txt&#xA;do&#xA;  vim -c 'set spell' $a&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, in each file, I use &lt;code&gt;]s&lt;/code&gt; to find the next unknown word, and fix the typo or add it to my dictionary; and when I'm done I close the current file with &lt;code&gt;ZZ&lt;/code&gt; and the next one automatically opens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's fine, but for the vast majority of files, there are no typos to report, so I end up doing a lot of &lt;code&gt;ZZ&lt;/code&gt;, &lt;code&gt;ZZ&lt;/code&gt;, &lt;code&gt;ZZ&lt;/code&gt;, etc. It would be better if I could somehow do the following: start vim, but if there are no words in the file that the spellchecker doesn't know about, exit immediately. That way I wouldn't have to close files where there are no changes to make.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to run vim and immediately exit when the spellchecker has no complaint about the file?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4819" LastEditorUserId="51" LastEditDate="2018-09-03T21:33:32.437" LastActivityDate="2018-09-04T00:02:02.177" Title="Spellchecking multiple files with vim" Tags="|spell-checking|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17234" PostTypeId="1" AcceptedAnswerId="17239" CreationDate="2018-08-31T11:57:54.403" Score="3" ViewCount="534" Body="&lt;p&gt;How can I get Tabular.vim to only consider and affect lines that match &lt;code&gt;/^item\s/&lt;/code&gt;, to use &lt;code&gt;/\s\+/&lt;/code&gt; as the delimiter, to left-align everything, and to use at least three spaces between words?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;thing      ...&#xA;item Aaaaaaaaaaaaa &quot;aaa&quot;                    Bbb&#xA;  aaa             ...&#xA;  ...&#xA;item    Aaaa &quot;aaaa&quot;  Bbb&#xA;  ...&#xA;  ...&#xA;&#xA;&#xA;item   Aaa    &quot;aaa&quot; Bbb&#xA;  ...&#xA;  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should change to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;thing      ...&#xA;item   Aaaaaaaaaaaaa   &quot;aaa&quot;    Bbb&#xA;  aaa             ...&#xA;  ...&#xA;item   Aaaa            &quot;aaaa&quot;   Bbb&#xA;  ...&#xA;  ...&#xA;&#xA;&#xA;item   Aaa             &quot;aaa&quot;    Bbb&#xA;  ...&#xA;  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've been trying to use &lt;code&gt;AddTabularPipeline&lt;/code&gt; without success and with much confusion, and I'd like to throw my attempts out and figure out how the solutions here work.&lt;/p&gt;&#xA;" OwnerUserId="18802" LastEditorUserId="1292" LastEditDate="2018-08-31T15:21:05.810" LastActivityDate="2018-08-31T16:13:12.643" Title="How can I get Tabular to only work with certain lines and to use spaces as a delimiter?" Tags="|regular-expression|alignment|plugin-tabular|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17235" PostTypeId="1" CreationDate="2018-08-31T12:28:18.673" Score="1" ViewCount="193" Body="&lt;p&gt;This can be super simple stuff but i am not able to figure it out, i have to mappings in my config file &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gh ^&#xA;nnoremap gl g_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These mappings work just fine and behave as expected when i use them in normal mode, but as soon as i combine them with yank command like &lt;code&gt;ygl&lt;/code&gt; to yank the text from cursor to last non-white space character and same way &lt;code&gt;ygh&lt;/code&gt; to first non-white space character, it simply does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am i missing something here ?&lt;/p&gt;&#xA;" OwnerUserId="18373" LastActivityDate="2018-08-31T12:45:04.530" Title="custom mapping not working with yank command" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17236" PostTypeId="2" ParentId="17235" CreationDate="2018-08-31T12:45:04.530" Score="1" Body="&lt;p&gt;Mappings are of different types. The ones you have mapped are &lt;code&gt;normal mode&lt;/code&gt; mappings. And the ones that you claim not to work are &lt;code&gt;operator-pending mode&lt;/code&gt; mappings. I suggest you take a look at &lt;code&gt;:h vim-modes&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, put these in your $MYVIMRC, to get operator-pending mode mappings, to work as you asked:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap gh ^&#xA;onoremap gl g_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice, the only change is the letter &lt;code&gt;o&lt;/code&gt; from &lt;code&gt;n&lt;/code&gt; which, unsurprisingly, indicates &lt;code&gt;operator-pending mode&lt;/code&gt; while &lt;code&gt;n&lt;/code&gt; indicates &lt;code&gt;normal mode&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For better flexbility, I suggest you also map visual mode mappings, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap gh ^&#xA;xnoremap gl g_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These will work when you are in visual-selection mode. &lt;strong&gt;Note&lt;/strong&gt; that, there are two kinds of mappings in &lt;code&gt;visual mode&lt;/code&gt; mappings, visual mode and select mode. And I suggest, you nearly always use select mode mappings with letter &lt;code&gt;x&lt;/code&gt; in your config. If you want to know more, &lt;a href=&quot;https://vi.stackexchange.com/questions/4891/what-is-the-select-mode-and-when-is-it-relevant-to-use-it&quot;&gt;here is a q/a thread&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2018-08-31T12:45:04.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17237" PostTypeId="1" CreationDate="2018-08-31T13:26:21.940" Score="2" ViewCount="77" Body="&lt;p&gt;I want to have a simple alias to take quick notes. Each note starts with the current date and time (ISO 8601). The alias should:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Start &lt;code&gt;vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Add the current date and time&lt;/li&gt;&#xA;&lt;li&gt;Position the cursor in the next line&lt;/li&gt;&#xA;&lt;li&gt;Switch to &lt;em&gt;Insert mode&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I tried to use &lt;em&gt;Ex mode&lt;/em&gt;. So far I was able to do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:i&#xA;&amp;lt;empty line&amp;gt;&#xA;&amp;lt;empty line&amp;gt;&#xA;.&#xA;:1!date --iso-8601=seconds&#xA;:2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I saved it in a file so I can source it when I run Vim using the &lt;code&gt;-S&lt;/code&gt; option. Together with my new alias &lt;code&gt;alias log=&quot;vim .notes -S .notes-source&quot;&lt;/code&gt; it works quite well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I'd like to improve it a bit. After the last Ex command &lt;code&gt;2&lt;/code&gt;, &lt;strong&gt;can I tell Vim to automatically go to &lt;em&gt;Insert mode&lt;/em&gt;&lt;/strong&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Out of curiosity, can I put multiple Ex commands in one or more &lt;code&gt;-c/--cmd&lt;/code&gt; options? Something like this (yep, it does not work):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;i\n\n.&quot; -c &quot;1!date --iso-8601=seconds&quot; -c &quot;2&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The main problem I see is that the &lt;code&gt;i&lt;/code&gt; Ex command requires new lines, and I'm not sure how to add them.&lt;/p&gt;&#xA;" OwnerUserId="18810" LastEditorUserId="18810" LastEditDate="2018-08-31T13:49:39.277" LastActivityDate="2018-08-31T13:50:52.873" Title="How to source an Ex file and automatically go to Insert mode" Tags="|insert-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17238" PostTypeId="2" ParentId="17237" CreationDate="2018-08-31T13:50:52.873" Score="3" Body="&lt;p&gt;You can run following command at your command prompt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;normal i`date --iso-8601=seconds`&quot; -c &quot;normal o&quot; -c startinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is how it works:&#xA;We are using three &lt;code&gt;-c&lt;/code&gt; commands here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First command runs &lt;code&gt;normal i&lt;/code&gt; followed by current actual date obtained using back tick shell operator. This basically &lt;em&gt;inserts&lt;/em&gt; current date when vim is launched. Naturally the date gets added to first line, as you want.&lt;/li&gt;&#xA;&lt;li&gt;Second command adds one blank line.&lt;/li&gt;&#xA;&lt;li&gt;Third command switches vim to insert mode upon launch.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you need more blank lines, you can pass a count to second &lt;code&gt;-c&lt;/code&gt; command, something like below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;normal i`date --iso-8601=seconds`&quot; -c &quot;normal 5o&quot; -c startinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command will insert 5 blank lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH.&lt;/p&gt;&#xA;" OwnerUserId="18813" LastActivityDate="2018-08-31T13:50:52.873" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17239" PostTypeId="2" ParentId="17234" CreationDate="2018-08-31T15:12:13.257" Score="1" Body="&lt;h3&gt;&lt;a href=&quot;https://github.com/junegunn/vim-easy-align&quot; rel=&quot;nofollow noreferrer&quot;&gt;Plugin EasyAlign&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;by Junegunn&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to give you an answer for &lt;em&gt;Tabular.vim&lt;/em&gt;. However, I could only figure it out how to do it with vim-easy-align:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%EasyAlign */\s\+/g/item\s/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have used the shorthand notation for the &lt;code&gt;filter&lt;/code&gt; option for the command &lt;a href=&quot;https://github.com/junegunn/vim-easy-align#easyalign-command&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:EasyAlign&lt;/code&gt;&lt;/a&gt;. The non-shorthand version looks like &lt;code&gt;:%EasyAlign */\s\+/ { 'filter': 'g/item\s/'}&lt;/code&gt;.&lt;br&gt;&#xA;More details about the filter option can be found &lt;a href=&quot;https://github.com/junegunn/vim-easy-align#filtering-lines&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and under &lt;code&gt;:h easy-align-filtering-lines&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim-easy-align provides a second way to use it, called the interactive mode: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Visual mode&amp;gt;ga*&amp;lt;CTRL-F&amp;gt;g/\item\s/&amp;lt;CR&amp;gt;&amp;lt;Space&amp;gt;                &quot; visual mode&#xA;ga&amp;lt;Text Object or Motion&amp;gt;*&amp;lt;CTRL-F&amp;gt;g/\item\s/&amp;lt;CR&amp;gt;&amp;lt;Space&amp;gt;      &quot; operator mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not entirely convinced the interactive mode is here more intuitive or easier to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was hoping to use IMHO the more naive approach &lt;code&gt;:g/item\s/EasyAlign */\s\+/&amp;lt;CR&amp;gt;&lt;/code&gt; but this does not work as well similar to &lt;em&gt;Tabular.vim&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note your question has been raised on stackoverflow and on the issue tracker of &lt;em&gt;Tabular.vim&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/6797837/vim-tabularize-how-to-ignore-lines-containing-curly-braces&quot;&gt;https://stackoverflow.com/q/6797837/vim-tabularize-how-to-ignore-lines-containing-curly-braces&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/godlygeek/tabular/issues/10&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/godlygeek/tabular/issues/10&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There seems to be the undocumented function &lt;code&gt;:GTabularize /pattern[/format]&lt;/code&gt; which, however, does not exactly do what you want. But was added to &lt;em&gt;Tabular.vim&lt;/em&gt; after someone raised the wish to combine &lt;code&gt;:global&lt;/code&gt; with &lt;code&gt;:Tabularize&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another vim alignment plugin is &lt;a href=&quot;https://github.com/tommcdo/vim-lion&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-lion&lt;/a&gt; which cannot help you here either.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;:global&lt;/code&gt; applies &lt;code&gt;[cmd]&lt;/code&gt; on each marked line separately&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If I read &lt;code&gt;:h :global&lt;/code&gt; correctly, the naive expectation, all filtered lines are provided for &lt;code&gt;[cmd]&lt;/code&gt;, is not true! I think this should be learned from this as well.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-08-31T16:13:12.643" LastActivityDate="2018-08-31T16:13:12.643" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17240" PostTypeId="2" ParentId="17230" CreationDate="2018-08-31T15:12:35.813" Score="4" Body="&lt;p&gt;If your Vim version is greater than &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.0.1112&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.0.1112&lt;/a&gt;, then you could ask the value of the &lt;code&gt;'idx'&lt;/code&gt; property of the quickfix list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo get(getqflist({'idx': 0}), 'idx', 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h getqflist()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If the optional {what} dictionary argument is supplied, then&#xA;returns only the items listed in {what} as a dictionary. The&#xA;following string items are supported in {what}:&#xA;&#xA;...&#xA;idx     index of the current entry in the list&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;'idx'&lt;/code&gt; seems to be &lt;a href=&quot;https://github.com/neovim/neovim/blob/e30ccd56d9543afd5e66feec984a9dc8bc6be38e/runtime/doc/eval.txt#L4334-L4344&quot; rel=&quot;nofollow noreferrer&quot;&gt;missing from Neovim&lt;/a&gt; at the moment, along with &lt;a href=&quot;https://github.com/neovim/neovim/issues/8363#issuecomment-386873748&quot; rel=&quot;nofollow noreferrer&quot;&gt;a few other properties&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-08-31T15:50:01.983" LastActivityDate="2018-08-31T15:50:01.983" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17241" PostTypeId="1" AcceptedAnswerId="17244" CreationDate="2018-08-31T18:40:20.550" Score="0" ViewCount="121" Body="&lt;p&gt;How can I write a function that can be invoked in normal mode with regular keystrokes like &lt;code&gt;{myNumber}&amp;lt;Leader&amp;gt;p&lt;/code&gt;, and prints &lt;code&gt;{myNumber}&lt;/code&gt; into the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For example: here's a command to format highlighted text to a variable width (dubiously useful, but an effective POC)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vnoremap 80w &amp;lt;ESC&amp;gt;:set textwidth=80&amp;lt;CR&amp;gt;'&amp;lt;gq'&amp;gt;&lt;/code&gt;, which turns the visual mode keystroke &lt;code&gt;80w&lt;/code&gt; to a command: &lt;code&gt;wrap the visually selected text to 80 columns&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to make this a function that takes user input instead of the hard-coded value of 80. Furthermore, as a function I wouldn't have to clobber the value of &lt;code&gt;textwidth&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I ask: how do I read the number that comes before a keystroke as a argument to a function?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;edit: here's the setup that I'm now using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SetTabs(num)&#xA;  let myCommand = printf(&quot;set tabstop=%d softtabstop=%d shiftwidth=%d&quot;,&#xA;\   a:num, a:num, a:num)&#xA;  execute l:myCommand&#xA;  echo &quot;Changed tabs to be worth &quot; . a:num&#xA;endfunction&#xA;&#xA;noremap &amp;lt;Leader&amp;gt;tab :&amp;lt;C-u&amp;gt;call SetTabs(v:count1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14861" LastEditorUserId="14861" LastEditDate="2018-10-01T02:28:16.493" LastActivityDate="2018-10-01T02:28:16.493" Title="How to get the number used before a command as an argument?" Tags="|key-bindings|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17243" PostTypeId="1" AcceptedAnswerId="17266" CreationDate="2018-08-31T21:04:07.327" Score="2" ViewCount="269" Body="&lt;p&gt;I'm having trouble selecting sections in a file in a visual mode macro to separately perform some action on each section. Here's an example file:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;[insert introduction here] ...&#xA;....&#xA;&#xA;------&#xA;section ...&#xA;------&#xA;&#xA;...&#xA;... ...&#xA;&#xA;...... ....&#xA;&#xA;...   ...&#xA;&#xA;------&#xA;section .......&#xA;------&#xA;&#xA;... ....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can get to the top of each section, but then I have to manually figure out whether I'm in the last section of the file to decide whether to go to the next section or to the end of the file. How can I automate that for use in a macro?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, are there better methods than visual mode that can be used in a macro that let me separately do the same action to each section in the file but not to the whole file at once?&lt;/p&gt;&#xA;" OwnerUserId="18802" LastActivityDate="2018-09-03T21:08:05.387" Title="In visual mode, how can I select to either the next section or the end of the file?" Tags="|cursor-movement|visual-mode|macro|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17244" PostTypeId="2" ParentId="17241" CreationDate="2018-08-31T22:10:38.553" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;v:count&lt;/code&gt;/&lt;code&gt;v:count1&lt;/code&gt; to get the current count. Use &lt;code&gt;execute&lt;/code&gt;/&lt;code&gt;let&lt;/code&gt; to accomplish these type of mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;leader&amp;gt;w :&amp;lt;c-u&amp;gt;execute 'set textwidth='.v:count&amp;lt;cr&amp;gt;gvgq&#xA;xnoremap &amp;lt;leader&amp;gt;w :&amp;lt;c-u&amp;gt;let &amp;amp;textwidth=v:count&amp;lt;cr&amp;gt;gvgq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h v:count&#xA;:h v:count1&#xA;:h :execute&#xA;:h c_CTRL-U&#xA;:h :let-&amp;amp;&#xA;:h gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-08-31T22:10:38.553" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17245" PostTypeId="1" CreationDate="2018-09-01T01:00:16.580" Score="2" ViewCount="56" Body="&lt;p&gt;I have several indentkeys (like &lt;code&gt;end&lt;/code&gt;, &lt;code&gt;elseif&lt;/code&gt;...), all of the works fine but typing &lt;code&gt;}&lt;/code&gt; triggers the reindentation with a 1s delay. It behaves the same if I disabled my &lt;code&gt;'indentexpr'&lt;/code&gt; and use &lt;code&gt;'cindent'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18254" LastActivityDate="2018-09-02T05:49:42.977" Title="indentkey '}' triggers with delay?" Tags="|indentation|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17247" PostTypeId="2" ParentId="17226" CreationDate="2018-09-01T06:17:14.220" Score="0" Body="&lt;p&gt;I think you can use &lt;code&gt;call term_open()&lt;/code&gt; instead. if you want to open shell in current win, it is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call term_start($SHELL, {'curwin' : 1})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW, if you think this command is too long, you can create custom command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Terminal call term_start($SHELL, {'curwin' : 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7942" LastEditorUserId="51" LastEditDate="2018-09-06T08:22:20.523" LastActivityDate="2018-09-06T08:22:20.523" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17248" PostTypeId="1" AcceptedAnswerId="17263" CreationDate="2018-09-01T07:14:53.653" Score="2" ViewCount="2355" Body="&lt;p&gt;I want to run powershell from vim and I have achieved it using the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;cd :cd %:p:h&amp;lt;cr&amp;gt;:silent !powershell&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that I can't do anything inside vim until I close the powershell window which somehow defeats the purpose. How can I tell vim to let go of the opened powershell so I could make changes in the file open in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe I am searching with wrong keywords and that's why I couldn't find a solution.&#xA;Any help is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="13751" LastEditorUserId="1292" LastEditDate="2018-09-02T17:15:05.900" LastActivityDate="2018-09-03T05:42:54.220" Title="opening powershell from inside vim" Tags="|gvim|vim-windows|external-command|microsoft-windows|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17249" PostTypeId="1" AcceptedAnswerId="17255" CreationDate="2018-09-01T16:07:11.233" Score="4" ViewCount="735" Body="&lt;p&gt;I would like to sort some lines, ignoring a leading part of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example from my &lt;code&gt;.spacemacs&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'(&#xA;     better-defaults&#xA;     elixir&#xA;     emacs-lisp&#xA;     erlang&#xA;     evil-commentary&#xA;     finance&#xA;     git&#xA;     haskell&#xA;     html&#xA;     ivy&#xA;     javascript&#xA;     lua&#xA;     markdown&#xA;     my-eshell&#xA;     my-org&#xA;     nginx&#xA;     nixos&#xA;     (org :variables org-projectile-file &quot;TODO.org&quot;)&#xA;     python&#xA;     (ruby :variables ruby-test-runner 'rspec)&#xA;     shell-scripts&#xA;     spell-checking&#xA;     (syntax-checking :variables syntax-checking-enable-tooltips nil)&#xA;     vinegar&#xA;     yaml&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to sort these, but I need to ignore the leading &lt;code&gt;(&lt;/code&gt; for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, here's an excerpt from my &lt;code&gt;configuration.nix&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;packages = with pkgs; [&#xA;      ## Basics&#xA;      atool&#xA;      bashInteractive&#xA;      entr&#xA;      ethtool&#xA;      fasd&#xA;      fd&#xA;      file&#xA;      fzf&#xA;      git&#xA;      git-crypt&#xA;      gitAndTools.hub&#xA;      google-cloud-sdk&#xA;      gparted&#xA;      hdparm&#xA;      htop&#xA;      i7z&#xA;      inotify-tools&#xA;      iperf&#xA;      lm_sensors&#xA;      neovim&#xA;      p7zip&#xA;      parted&#xA;      pwgen&#xA;      ripgrep&#xA;      sshfs&#xA;      # tarsnap&#xA;      tmux&#xA;      tree&#xA;      unzip&#xA;      wget&#xA;      xclip&#xA;      zip&#xA;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, I would like to sort the lines, ignoring the leading &lt;code&gt;#&lt;/code&gt; part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I do this in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware of &lt;code&gt;:sort /\v# /&lt;/code&gt;, but that would only sort lines that match the pattern, then ignore the pattern for sorting.&lt;/p&gt;&#xA;" OwnerUserId="18830" LastEditorUserId="10604" LastEditDate="2018-09-01T16:59:13.470" LastActivityDate="2018-09-04T14:18:16.093" Title="Sort lines ignoring leading component" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17250" PostTypeId="2" ParentId="17225" CreationDate="2018-09-01T19:10:48.747" Score="6" Body="&lt;p&gt;The codes which keys produce varies wildly by terminal.  vim tries to&#xA;guess which escape sequences corresponds to which keycodes (&lt;code&gt;&amp;lt;f1&amp;gt;&lt;/code&gt; etc)&#xA;based on the $TERM variable and terminfo.  The shifted f-keys are not&#xA;standardized and they do not have termcap/terminfo entries. In this case,&#xA;vim falls back to the xterm ones.  Note, wherever &lt;code&gt;^[&lt;/code&gt; is written, this means a literal escape character.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Changing vim's key codes&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;For many keys, vim has a key code for it of the form &lt;code&gt;&amp;lt;..&amp;gt;&lt;/code&gt;.  This includes the shifted f-keys, &lt;code&gt;&amp;lt;s-f1&amp;gt;&lt;/code&gt;..&lt;code&gt;&amp;lt;s-f37&amp;gt;&lt;/code&gt;.  The way to change this for your terminal is through &lt;code&gt;set&lt;/code&gt; (the following are equivalent):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;s-f1&amp;gt;=^[[23~&#xA;execute &quot;set &amp;lt;s-f1&amp;gt;=\&amp;lt;esc&amp;gt;[23~&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some keys do not have a named key code, such as &lt;code&gt;&amp;lt;s-enter&amp;gt;&lt;/code&gt;.  In this case, vim provides many extra function keys, up to &lt;code&gt;&amp;lt;f37&amp;gt;&lt;/code&gt; which you can use, if your terminal supports it.  As usual, you can grab the key code by typing it after &lt;kbd&gt;ctrl-v&lt;/kbd&gt; or with &lt;code&gt;cat&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;f37&amp;gt;=^[OM&#xA;execute &quot;set &amp;lt;f37&amp;gt;=\&amp;lt;esc&amp;gt;OM&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can use &lt;code&gt;&amp;lt;f37&amp;gt;&lt;/code&gt; in place of &lt;code&gt;&amp;lt;s-enter&amp;gt;&lt;/code&gt; whenever you want to use that key.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Explaining the original behavior&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Below is a list of the keys in urxvt and xterm, produced by running cat in a shell then typing each key (except for f13/f14 which comes from &lt;code&gt;infocmp&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In urxvt, &lt;kbd&gt;shift-f1&lt;/kbd&gt; and &lt;kbd&gt;shift-f2&lt;/kbd&gt; are exactly&#xA;  identical to &lt;kbd&gt;f11&lt;/kbd&gt; and &lt;kbd&gt;f12&lt;/kbd&gt;.  Therefore, by default,&#xA;  you cannot use both for different things.  This also explains why&#xA;  &lt;kbd&gt;shift-f1&lt;/kbd&gt; and &lt;kbd&gt;shift-f2&lt;/kbd&gt; did not produce the case&#xA;  changing behavior you saw- vim thought they were some other key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Likewise, &lt;kbd&gt;shift-f4&lt;/kbd&gt; in urvt is the same as &lt;kbd&gt;f14&lt;/kbd&gt;.&#xA;I'm not sure why but vim thinks this is the &lt;code&gt;&amp;lt;undo&amp;gt;&lt;/code&gt; key, which is &lt;code&gt;t_&amp;amp;8=^[[26;*~&lt;/code&gt;, close but not quite the same as &lt;kbd&gt;f14&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Table&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;              urxvt       xterm&#xA;&#xA;f1           ^[[11~       ^[OP&#xA;f2           ^[[12~       ^[OQ&#xA;f3           ^[[13~       ^[OR&#xA;f4           ^[[14~       ^[OS&#xA;&#xA;f5           ^[[15~       ^[[15~&#xA;f6           ^[[17~       ^[[17~&#xA;f7           ^[[18~       ^[[18~&#xA;f8           ^[[19~       ^[[19~&#xA;&#xA;f9           ^[[20~       ^[[20~&#xA;f10          ^[[21~       ^[[21~&#xA;f11          ^[[23~       ^[[23~&#xA;f12          ^[[24~       ^[[24~&#xA;f13          ^[[25~&#xA;f14          ^[[26~&#xA;&#xA;shift-f1     ^[[23~       ^[[1;2P &#xA;shift-f2     ^[[24~       ^[[1;2Q &#xA;shift-f3     ^[[25~       ^[[1;2R &#xA;shift-f4     ^[[26~       ^[[1;2S &#xA;&#xA;shift-f5     ^[[28~       ^[[15;2~&#xA;shift-f6     ^[[29~       ^[[17;2~&#xA;shift-f7     ^[[31~       ^[[18;2~&#xA;shift-f8     ^[[32~       ^[[19;2~&#xA;&#xA;shift-f9     ^[[33~       ^[[20;2~&#xA;shift-f10    ^[[34~       ^[[21;2~&#xA;shift-f11    ^[[23$       ^[[23;2~&#xA;shift-f12    ^[[24$       ^[[24;2~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-09-01T19:10:48.747" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17251" PostTypeId="2" ParentId="9303" CreationDate="2018-09-01T20:10:25.360" Score="1" Body="&lt;p&gt;What I suggest is to save the result of the g into a register. You should use append.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;that can be done by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/pattern/A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Afterwards, save the register to a file &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :new file | $put a | x &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From here, you are free. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;you can also try to run columns directly, but I wasn't really successful.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;!columns ,ts &quot; . @a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;maybe with a proper escaping, it would work.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2018-09-01T20:10:25.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17252" PostTypeId="1" AcceptedAnswerId="17253" CreationDate="2018-09-01T20:53:44.073" Score="0" ViewCount="1848" Body="&lt;p&gt;I installed Vundle via &lt;code&gt;git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim&lt;/code&gt;, and have my &lt;code&gt;.vimrc&lt;/code&gt; as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;&#xA;&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'vim-latex/vim-latex'&#xA;&#xA;&#xA;&#xA;&#xA;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I hit &lt;code&gt;:PluginInstall (!)&lt;/code&gt;, it shows the plugin screen but only Vundle is installed. Hitting &lt;code&gt;l&lt;/code&gt; for the log gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[2018-09-01 22:42:44]                               |&#xA;[2018-09-01 22:42:44] Plugin VundleVim/Vundle.vim   |~                                                                                                                                                              &#xA;[2018-09-01 22:42:44] $ cd '/home/name/.vim/bundle/|~                                                                                                                                                              &#xA;Vundle.vim' &amp;amp;&amp;amp; git pull &amp;amp;&amp;amp; git submodule update --in|~                                                                                                                                                              &#xA;it --recursive                                      |~                                                                                                                                                              &#xA;[2018-09-01 22:42:44] &amp;gt; Already up-to-date.         |~                                                                                                                                                              &#xA;[2018-09-01 22:42:44] &amp;gt;                             |~                                                                                                                                                              &#xA;[2018-09-01 22:42:44]                               |~                                                                                                                                                              &#xA;[2018-09-01 22:42:44] Helptags:                     |~                                                                                                                                                              &#xA;[2018-09-01 22:42:44] :helptags /home/name/.vim/bun|~                                                                                                                                                              &#xA;dle/Vundle.vim/doc                                  |~                                                                                                                                                              &#xA;[2018-09-01 22:42:44] Helptags: 1 plugins processed |~                                                                                                                                                              &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've checked the &lt;code&gt;.vimrc&lt;/code&gt; path with &lt;code&gt;:echo $MYVIMRC&lt;/code&gt; and it points to the above file. I've also tried to install plugins with the command: &lt;code&gt;vim +PluginInstall +qall&lt;/code&gt;, and for a millisecond or so it flashes a screen which seems to have a red line, however I can't follow up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both &lt;code&gt;curl&lt;/code&gt; and &lt;code&gt;git&lt;/code&gt; work and are installed. How do I find out where it goes wrong? I've seen similar questions and they are not helpful. I've restarted Vim.&lt;/p&gt;&#xA;" OwnerUserId="18831" LastActivityDate="2018-09-01T21:46:18.167" Title="Vundle not instaling Plugins / Ignoring" Tags="|vimrc|installing|plugin-vundle|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17253" PostTypeId="2" ParentId="17252" CreationDate="2018-09-01T21:46:18.167" Score="2" Body="&lt;p&gt;In your &lt;code&gt;.vimrc&lt;/code&gt; you're calling &lt;code&gt;vundle#begin()&lt;/code&gt; twice and after the second one you're only loading the Vundle plugin. That's probably why it's ignoring the other plugins you have outside that block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're also missing the call to &lt;code&gt;vundle#end()&lt;/code&gt; and re-enabling the filetype detection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim/blob/master/README.md#quick-start&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vundle's quick start&lt;/a&gt; again to see what your &lt;code&gt;.vimrc&lt;/code&gt; should look like.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2018-09-01T21:46:18.167" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17254" PostTypeId="1" AcceptedAnswerId="17257" CreationDate="2018-09-01T22:04:25.160" Score="2" ViewCount="84" Body="&lt;p&gt;I want to do filter through an external program without actually filtering the lines (but to keep them). For example :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%!grep aa &amp;gt; newfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I do this, all the lines are deleted and I need to do undo&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a more neat way to run an external program with args without changing the current buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2018-09-04T14:35:30.570" Title="How can I pass a text to an external program without changing the current buffer?" Tags="|external-command|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17255" PostTypeId="2" ParentId="17249" CreationDate="2018-09-01T22:14:32.223" Score="5" Body="&lt;p&gt;You can do this with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sort /^\s*\(# \)\?/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This skips the &lt;code&gt;#&lt;/code&gt; if it exists, and then sorts on the remainder of the line. However, the pattern matches every line, so all lines are sorted into a single group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will want to add a range to the start of the command to apply this to the appropriate lines in your file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following command also works, coming at it from the opposite direction:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sort r /\s*\(# \)\?\zs.*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of skipping the matched part of the line, this sorts on the matched part, but we use &lt;code&gt;\zs&lt;/code&gt; to exclude the &lt;code&gt;#&lt;/code&gt; from the match, if it exists.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-09-04T14:18:16.093" LastActivityDate="2018-09-04T14:18:16.093" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17257" PostTypeId="2" ParentId="17254" CreationDate="2018-09-01T22:37:12.350" Score="5" Body="&lt;p&gt;I think you’re looking for &lt;code&gt;:help :write_c&lt;/code&gt;. Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !grep aa &amp;gt; newfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-09-01T22:37:12.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17258" PostTypeId="2" ParentId="17245" CreationDate="2018-09-02T05:49:42.977" Score="1" Body="&lt;p&gt;The delay is caused by &lt;code&gt;'showmatch'&lt;/code&gt; and &lt;code&gt;'matchtime'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set noshowmatch&lt;/code&gt; or &lt;code&gt;:set matchtime=0&lt;/code&gt; negates the delay.&lt;/p&gt;&#xA;" OwnerUserId="18254" LastActivityDate="2018-09-02T05:49:42.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17259" PostTypeId="2" ParentId="13689" CreationDate="2018-09-02T07:46:04.040" Score="0" Body="&lt;p&gt;As other have already pointed, if you have your cursor positioned on top of&#xA;your word you can use Ctrl+r family of commands, being Ctrl+r Ctrl+w&#xA;probably the most suitable to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That method, however, only works for inserting one word (the one just below&#xA;the cursor), but what if the there are&#xA;several several portions of text in the buffer that we want to use? As you&#xA;cant move your cursor while in the command line.&#xA;The best way to do this is&#xA;to copy portions of text you will need into different registers, which you&#xA;can do by prefixing &quot;{reg_letter} (quote and the letter from the register)&#xA;to the copy operator. This way it will be possible to insert various words&#xA;in the command line later with Ctrl+r{reg_letter}. This is a little awkward&#xA;but works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But returning to the previous idea, it would be great if the we would move&#xA;the cursor position over the buffer while writing a pattern. That way we&#xA;could &quot;pick&quot; text from different positions with Ctrl+r Ctrl+w, so I created&#xA;a plugin that does just that: &lt;a href=&quot;https://github.com/saulaxel/EXtend.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;EXtend.vim&lt;/a&gt;&#xA;The plugin also have much other features to make substitution operations.&lt;/p&gt;&#xA;" OwnerUserId="18087" LastActivityDate="2018-09-02T07:46:04.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17260" PostTypeId="2" ParentId="17227" CreationDate="2018-09-02T10:05:04.017" Score="7" Body="&lt;h2&gt;Fix entries in &lt;em&gt;ShaDa&lt;/em&gt; File (neovim-specific)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Neovim does not use anymore the plaintext file &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#viminfo&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;viminfo&lt;/code&gt;&lt;/a&gt; (used by vim) to store this but uses a &lt;a href=&quot;https://msgpack.org/&quot; rel=&quot;noreferrer&quot;&gt;msgpack&lt;/a&gt; formatted file called ShaDa (short for shared data, &lt;a href=&quot;https://neovim.io/doc/user/starting.html#shada&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h shada&lt;/code&gt;&lt;/a&gt;). If you do not know where this file is, see &lt;a href=&quot;https://neovim.io/doc/user/starting.html#shada-file-name&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h shada-file-name&lt;/code&gt;&lt;/a&gt; and this tells you&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The default name of the ShaDa file is &lt;code&gt;&quot;$XDG_DATA_HOME/nvim/shada/main.shada&quot;&lt;/code&gt; &#xA;    for Unix. Default for &lt;code&gt;$XDG_DATA_HOME&lt;/code&gt; is &lt;code&gt;~/.local/share&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Neovim provides special support to edit the binary Shada file (&lt;a href=&quot;https://neovim.io/doc/user/filetype.html#ft-shada&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;&lt;code&gt;:h ft-shada&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt;). When you open this file in neovim with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e ~/.local/share/nvim/shada/main.shada&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the plugin file &lt;a href=&quot;https://github.com/neovim/neovim/blob/master/runtime/plugin/shada.vim&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;$VIMRUNTIME/plugin/shada.vim&lt;/code&gt;&lt;/a&gt; automatically converts the binary file to a human readable plaintext representation for convenient modification:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Global mark with timestamp 2018-09-02T11:32:44:&#xA;  % Key  Description  Value&#xA;  + n    name         '3'&#xA;  + f    file name    &quot;/Users/Hotschke/oldpath/file.log&quot;&#xA;  + l    line number  1&#xA;  + c    column       0&#xA;Jump with timestamp 2018-09-02T11:32:44:&#xA;  % Key  Description  Value&#xA;  + f    file name    &quot;/Users/Hotschke/unaffected/doc.pdf&quot;&#xA;  + l    line number  1&#xA;  + c    column       0&#xA;History entry with timestamp 2018-09-02T11:34:26:&#xA;  @ Description_  Value&#xA;  - history type  CMD&#xA;  - contents      &quot;e /Users/Hotschke/oldpath/file.log&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For comparison, open the file in vim and you will see the content of a binary file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Back in neovim: you can run &lt;code&gt;:%s/oldpath/newpath/c&lt;/code&gt; to replace the oldpath with a newpath to adjust for the change on your drive.&#xA;If you type &lt;code&gt;:write&lt;/code&gt;, neovim runs a conversion of the buffer to msgpack and saves correctly the file. You do not have to worry about the details.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Remove entries&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;However, if you simply want to remove outdated entries, delete the complete entry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The custom text object indent &lt;code&gt;ai&lt;/code&gt; from github &lt;a href=&quot;https://github.com/michaeljsmith/vim-indent-object&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/michaeljsmith/vim-indent-object&lt;/a&gt; can make this easier since the current representation uses indentation with a header line. To remove all entries which point to outdated files, e.g. in the above given snippet in global marks and in the cmd history, you can now run &lt;code&gt;:g/oldpath/norm dai&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I would recommend to read &lt;a href=&quot;https://neovim.io/doc/user/starting.html#shada-format&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;&lt;code&gt;:h shada-format&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt; to better understand the ShaDa file, in particular when you make changes to it.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-11-17T08:49:22.503" LastActivityDate="2018-11-17T08:49:22.503" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17261" PostTypeId="1" AcceptedAnswerId="17264" CreationDate="2018-09-02T17:26:50.983" Score="2" ViewCount="257" Body="&lt;p&gt;Vim has the option to automatically continue comments when a new line is entered as described &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#format-comments&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. This currently works perfectly for &lt;code&gt;//&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; in .cpp and .python files respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to add the following line to the .vimrc for lisp&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd filetype lisp,clojure           setlocal comments+=:;;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried to set it manually in a file via &lt;code&gt;:set comments=:;;&lt;/code&gt;. All to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have checked that vim is compiled with the &lt;code&gt;comments&lt;/code&gt; flag set.&lt;/p&gt;&#xA;" OwnerUserId="14023" LastActivityDate="2018-09-03T08:12:26.350" Title="Unable to repeat comment string for new line" Tags="|autocompletion|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17262" PostTypeId="1" AcceptedAnswerId="17268" CreationDate="2018-09-03T00:29:34.723" Score="2" ViewCount="475" Body="&lt;p&gt;For Emacs there is &lt;a href=&quot;https://github.com/victorhge/iedit&quot; rel=&quot;nofollow noreferrer&quot;&gt;idedit&lt;/a&gt;. It Allows you to select some text, then hit one button, which automatically select all other occurrences of the selected text in the current buffer. Then you can edit the primary selection and the text in the secondary selections will be modified accordingly as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something like that for Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can do what the answers describe here: &lt;a href=&quot;https://vi.stackexchange.com/questions/6693/replace-current-selection-and-all-identical-occurrences-in-a-file?answertab=active#tab-top&quot;&gt;Replace current selection and all identical occurrences in a file&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But those are way to many key strokes. It only needs one keystroke (or 2, if you include the modifier key) in Emacs. And the answer by statox requires 8! Is there some way to put those 8 keystrokes into a function with VimScript or a plugin that does this?&lt;/p&gt;&#xA;" OwnerUserId="18689" LastEditorUserId="18689" LastEditDate="2018-09-03T23:37:08.467" LastActivityDate="2018-09-04T07:30:08.943" Title="iedit behaviour in Vim?" Tags="|substitute|visual-mode|replace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17263" PostTypeId="2" ParentId="17248" CreationDate="2018-09-03T05:42:54.220" Score="1" Body="&lt;p&gt;Try using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent !start powershell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which should run a new powershell command in its own window, detached from the current vim instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/os_win32.txt.html#%3A%21start&quot; rel=&quot;nofollow noreferrer&quot;&gt;Q&amp;amp;A on &lt;code&gt;:!start&lt;/code&gt; on Windows&lt;/a&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://ss64.com/nt/start.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Documentation of the Windows &lt;code&gt;start&lt;/code&gt; command&lt;/a&gt;, in particular you might want to look into &lt;code&gt;/D&lt;/code&gt; to specify the startup directory for the command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2018-09-03T05:42:54.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17264" PostTypeId="2" ParentId="17261" CreationDate="2018-09-03T08:12:26.350" Score="1" Body="&lt;p&gt;Check your &lt;code&gt;filetype&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set filetype?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should show&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype=lisp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it is empty, then auto-comments would not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same applies to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatoptions?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The should look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;formatoptions=croql&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and not be empty.&lt;/p&gt;&#xA;" OwnerUserId="18342" LastActivityDate="2018-09-03T08:12:26.350" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17265" PostTypeId="1" AcceptedAnswerId="17291" CreationDate="2018-09-03T18:35:37.813" Score="3" ViewCount="169" Body="&lt;p&gt;I have these abbreviations in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iab seq sequent&#xA;iab seqs sequents&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;seqs&lt;/code&gt; expands to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sequents&#xA;i seq sequent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in a tex file (I have installed vim-latex).&#xA;In an empty buffer &lt;code&gt;seqs&lt;/code&gt; expands correctly to&#xA;&lt;code&gt;sequents&lt;/code&gt;. How could I get the correct expansion in a tex file? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I addition, abbreviations are not expanding at all in a line of a tex buffer, if, e. g., left movements of cursor were made in that line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've noticed that all abbreviations work correct in a .tex buffer if triggered with &lt;kbd&gt;Tab&lt;/kbd&gt; or &lt;kbd&gt;CR&lt;/kbd&gt;. One simple way out is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;f2&amp;gt; &amp;lt;Tab&amp;gt;&amp;lt;BS&amp;gt; &#xA;&quot; One space after &amp;lt;BS&amp;gt; in f2&#xA;imap &amp;lt;f3&amp;gt; &amp;lt;Tab&amp;gt;&amp;lt;BS&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and trigger abbreviations with &lt;kbd&gt;f2&lt;/kbd&gt; or &lt;kbd&gt;f3&lt;/kbd&gt;. Please let me know if you find ` better solution.&lt;/p&gt;&#xA;" OwnerUserId="18851" LastEditorUserId="4472" LastEditDate="2018-09-06T18:47:19.643" LastActivityDate="2018-09-11T05:38:30.067" Title="Wrong abbreviation expansion" Tags="|abbreviations|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="17266" PostTypeId="2" ParentId="17243" CreationDate="2018-09-03T21:08:05.387" Score="1" Body="&lt;p&gt;So this might not be perfect but I found it already does a lot of what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#end-of-file&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\%$&lt;/code&gt; pattern&lt;/a&gt; to match the end of the file. (Also, &lt;code&gt;\%^&lt;/code&gt; to match the start of the file.) Which should help you match either two lines above the start of the next section, or the end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, this search should match what you're looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\n--*\nsection \|\%$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Breaking it down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\n&lt;/code&gt; matches the end of a line, followed by&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;--*&lt;/code&gt; a line with one or more dashes (nothing else), then&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\n&lt;/code&gt; another end of line, right after the dashes and finally&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;section&lt;/code&gt; the next line starting with the word &quot;section&quot; and a space.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All this, OR (&lt;code&gt;\|&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\%$&lt;/code&gt; matches the end of the file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you use this pattern, you'll see it cycle through the end of sections or the end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a mapping to select a whole section, something like this might work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap \s :&amp;lt;c-u&amp;gt;execute &quot;normal! ?\\v^section \|%^\rv/\\v\\n--*\\nsection \|%$\r&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works in normal, visual and operator-pending mode. The mapping uses the &lt;code&gt;\s&lt;/code&gt; key sequence (&lt;code&gt;s&lt;/code&gt; for &quot;section&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The searches are using the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5Cv&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\v&lt;/code&gt; option for &lt;code&gt;'verymagic'&lt;/code&gt; mode in patterns&lt;/a&gt; to ensure consistency. The &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; at the start is to erase the implicit range &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt; when executing this macro in visual mode. It's using &lt;code&gt;execute &quot;normal! ...&quot;&lt;/code&gt; so the whole expression is executed as a single command, which is important in operator-pending mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This macro works as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Typing &lt;code&gt;\s&lt;/code&gt; in normal mode, will switch to visual mode and highlight the section around where the cursor currently is.&lt;/li&gt;&#xA;&lt;li&gt;Typing &lt;code&gt;\s&lt;/code&gt; in visual mode, will highlight the section around where the current visual highlighting starts (visual mapping.)&lt;/li&gt;&#xA;&lt;li&gt;Typing &lt;code&gt;&amp;gt;\s&lt;/code&gt; will indent the current section, or &lt;code&gt;d\s&lt;/code&gt; will delete the current section (operator-pending mapping.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is not perfect, as the &lt;code&gt;------&lt;/code&gt; preceding a &lt;code&gt;section ...&lt;/code&gt; does not belong to either the current or the next section, which can be easily seen when using &lt;code&gt;d\s&lt;/code&gt;, which will leave two lines with dashes in a row. It should be possible to adjust the regular expressions to account for that, by either including it in the start of the section or in the end of the section (I think start of the section makes more sense, since the beginning or end of the file don't have any lines with dahses in them.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps a slightly more complete macro is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap \s :&amp;lt;c-u&amp;gt;execute &quot;normal! g_?\\v^--*\\nsection \|%^\rv/\\v\\n--*\\nsection \|%$\r&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The additional &lt;code&gt;g_&lt;/code&gt; makes the selection work when you're in the first line of the section (either the line with dashes, or the first line of the file, with the introduction.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope you'll find this useful!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/16.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;More Operator-Pending Macros&lt;/a&gt; in &quot;Learn Vimscript the Hard Way&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#end-of-file&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\%$&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5Cv&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\v&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :normal&lt;/code&gt;, &lt;code&gt;:help :execute&lt;/code&gt;, &lt;code&gt;:help c_CTRL-U&lt;/code&gt;, &lt;code&gt;:help g_&lt;/code&gt;, etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2018-09-03T21:08:05.387" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17267" PostTypeId="2" ParentId="17233" CreationDate="2018-09-03T21:57:14.647" Score="2" Body="&lt;p&gt;A simple script to look for a misspelled word and to quit Vim if it doesn't exist might look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! SpellNext()&#xA;    &quot; Go to start of buffer and enable spell checking.&#xA;    normal! gg&#xA;    set spell&#xA;&#xA;    &quot; Record cursor position.&#xA;    let l:pos = getpos('.')&#xA;&#xA;    &quot; Special case: first word is misspelled.&#xA;    if spellbadword()[1] isnot# ''&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; Try to find a misspelled word.&#xA;    normal! ]s&#xA;&#xA;    &quot; No more words left if the position is unchanged from last&#xA;    &quot; time, so quit Vim.&#xA;    if getpos('.') == l:pos&#xA;        quit&#xA;    endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As an extra bonus this will also put your cursor on the first misspelled word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can load this script when Vim starts with the &lt;code&gt;-S&lt;/code&gt; commandline flag, and call the function with &lt;code&gt;-c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -S spell.vim  -c &quot;:call SpellNext()&quot; file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;All of that being said; it is probably easier to load multiple files in one go:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -p *.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then call this on every tab:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabdo :call SpellNext()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will close all the tabs without spelling errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can probably also do the same with buffers; but I'm in the &quot;use-tabs-as-buffers&quot; crowd, so I don't know how to do that from the top of my head &gt;_&amp;lt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2018-09-04T00:02:02.177" LastActivityDate="2018-09-04T00:02:02.177" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17268" PostTypeId="2" ParentId="17262" CreationDate="2018-09-03T22:12:39.700" Score="3" Body="&lt;p&gt;You can apply &lt;a href=&quot;https://vi.stackexchange.com/a/6695/51&quot;&gt;Peter Rincker's solution&lt;/a&gt;&#xA;in a loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ReplaceAll()&#xA;    &quot; Don't do anything if there isn't a search pattern.&#xA;    if @/ is# '' &#xA;        return&#xA;    endif&#xA;&#xA;    &quot; Save view state and wrapscan setting.&#xA;    let l:save = winsaveview()&#xA;    let l:old_ws = &amp;amp;wrapscan&#xA;&#xA;    try&#xA;        &quot; Make sure search won't wrap around.&#xA;        set nowrapscan&#xA;&#xA;        while 1&#xA;            &quot; Go to next match and select.&#xA;            let l:pos = getpos('.')&#xA;            try&#xA;                normal! n&#xA;            catch&#xA;                &quot; E385: search hit BOTTOM without match for: xzxxx&#xA;                &quot; Also catch other errors.&#xA;                break&#xA;            endtry&#xA;&#xA;            &quot; Position unchanged; shoudn't happen AFAIK, but better&#xA;            &quot; check otherwise you're going to end up in an infinite&#xA;            &quot; loop!&#xA;            if getpos('.') == l:pos&#xA;                break&#xA;            endif&#xA;&#xA;            &quot; Apply last edit command.&#xA;            normal! .&#xA;        endwhile&#xA;    finally&#xA;        &quot; Restore view.&#xA;        call winrestview(l:save)&#xA;        let &amp;amp;wrapscan = l:old_ws&#xA;    endtry&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the workflow with this is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Search for &lt;code&gt;/foo&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Apply change with &lt;code&gt;c&lt;/code&gt; operator, e.g. to change &lt;code&gt;foo&lt;/code&gt; to &lt;code&gt;XXX&lt;/code&gt; use &lt;code&gt;cwXXX&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:call ReplaceAll()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;PROFIT!&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can map &lt;code&gt;ReplaceAll()&lt;/code&gt; to a command or binding as well, of course.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2018-09-03T22:12:39.700" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17269" PostTypeId="1" AcceptedAnswerId="17293" CreationDate="2018-09-04T01:27:24.270" Score="6" ViewCount="1534" Body="&lt;p&gt;I use &lt;code&gt;neovim 0.3.1&lt;/code&gt; only.&#xA;I define the following function and map to do a test for &lt;code&gt;getpos&lt;/code&gt; in visual mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! show_position()&#xA;  echo getpos(&quot;'&amp;lt;&quot;) getpos(&quot;'&amp;gt;&quot;) getpos(&quot;.&quot;) getpos(&quot;v&quot;) getcurpos()&#xA;endfunction&#xA;vmap ;j :&amp;lt;c-u&amp;gt;call show_position()&amp;lt;cr&amp;gt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The test file contains (please ignore &lt;code&gt;:&lt;/code&gt; and &lt;code&gt;|&lt;/code&gt; for now)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0123456789&#xA;11234:56789&#xA;2123456789&#xA;3123456789&#xA;4123456789&#xA;51234|56789&#xA;6123456789&#xA;7123456789&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then enter visual mode using &lt;code&gt;v&lt;/code&gt;, &lt;code&gt;V&lt;/code&gt; or &lt;code&gt;&amp;lt;c-v&amp;gt;&lt;/code&gt;, move around and then press &lt;code&gt;;j&lt;/code&gt; to get the position of various markers. I have two cases tested (we can press &lt;code&gt;o&lt;/code&gt; in visual mode to switch the case):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;When &lt;code&gt;:&lt;/code&gt; is the place I started the visual selection and &lt;code&gt;|&lt;/code&gt; is the current cursor place, &lt;/li&gt;&#xA;&lt;li&gt;When &lt;code&gt;|&lt;/code&gt; is the place I started the visual selection and &lt;code&gt;:&lt;/code&gt; is the current cursor place, &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In both cases, the result shows that &lt;code&gt;getcurpos() == getpos(&quot;.&quot;) == getpos(&quot;v&quot;) == upper left corner of the selection&lt;/code&gt;, which I feel contradicts with common sense as well as the doc &lt;code&gt;:h line&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;      .   the cursor position&#xA;      $   the last line in the current buffer&#xA;      'x  position of mark x (if the mark is not set, 0 is&#xA;          returned)&#xA;      v   In Visual mode: the start of the Visual area (the&#xA;          cursor is the end).  When not in Visual mode&#xA;          returns the cursor position.  Differs from |'&amp;lt;| in&#xA;          that it's updated right away.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How to get the current cursor position in visual mode?&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2020-05-14T00:34:50.377" LastActivityDate="2020-05-14T00:34:50.377" Title="getpos(&quot;.&quot;) in visual mode equals getpos(&quot;v&quot;)" Tags="|visual-mode|cursor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17272" PostTypeId="2" ParentId="17262" CreationDate="2018-09-04T06:03:18.103" Score="0" Body="&lt;p&gt;I have a solution using operators and text objects, also working with visual-mode. I believe it uses less keystrokes and is more vim-like than the idedit solution, and becomes intuitive and quick to use.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetTextObject(type, is_visual)&#xA;    let sel_save = &amp;amp;selection&#xA;    let &amp;amp;selection = &quot;inclusive&quot;&#xA;    let reg_save = @@&#xA;    if a:is_visual&#xA;      silent execute &quot;normal! gvy&quot;&#xA;    elseif a:type == 'line'&#xA;      silent execute &quot;normal! '[V']y&quot;&#xA;    else&#xA;      silent execute &quot;normal! `[v`]y&quot;&#xA;    endif&#xA;    let text = @@&#xA;    let &amp;amp;selection = sel_save&#xA;    let @@ = reg_save&#xA;    return text&#xA;endfunction&#xA;&#xA;function! ReplaceOperator(type, ...)&#xA;    let text = GetTextObject(a:type, a:0)&#xA;    call feedkeys(&quot;:%s/&quot;.text.&quot;//g\&amp;lt;left&amp;gt;\&amp;lt;left&amp;gt;&quot;, &quot;n&quot;)&#xA;endfunction&#xA;nnoremap gr :set opfunc=ReplaceOperator&amp;lt;cr&amp;gt;g@&#xA;vnoremap gr :&amp;lt;C-u&amp;gt;call ReplaceOperator(visualmode(), 1)&amp;lt;cr&amp;gt;&#xA;&#xA;function! AppendReplaceOperator(type, ...)&#xA;    let text = GetTextObject(a:type, a:0)&#xA;    call feedkeys(&quot;:%s/&quot;.text.&quot;/&quot;.text.&quot;/g\&amp;lt;left&amp;gt;\&amp;lt;left&amp;gt;&quot;, &quot;n&quot;)&#xA;endfunction&#xA;nnoremap gA :set opfunc=AppendReplaceOperator&amp;lt;cr&amp;gt;g@&#xA;vnoremap gA :&amp;lt;C-u&amp;gt;call AppendReplaceOperator(visualmode(), 1)&amp;lt;cr&amp;gt;&#xA;&#xA;function! PrependReplaceOperator(type, ...)&#xA;    let text = GetTextObject(a:type, a:0)&#xA;    call feedkeys(&quot;:%s/&quot;.text.&quot;/&quot;.text.&quot;/g&quot;.repeat(&quot;\&amp;lt;left&amp;gt;&quot;, len(text) + 2), &quot;n&quot;)&#xA;endfunction&#xA;nnoremap gI :set opfunc=PrependReplaceOperator&amp;lt;cr&amp;gt;g@&#xA;vnoremap gI :&amp;lt;C-u&amp;gt;call PrependReplaceOperator(visualmode(), 1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inserting this into your &lt;code&gt;~/.vimrc&lt;/code&gt; or &lt;code&gt;~/_vimrc&lt;/code&gt; or equivalent, this should give you three operators which work on text-objects in normal-mode, and selections in visual-mode. These operators are &lt;code&gt;gr&lt;/code&gt;, &lt;code&gt;gA&lt;/code&gt;, and &lt;code&gt;gI&lt;/code&gt; standing respectively for &quot;go replace&quot;, &quot;go Append replace&quot;, and &quot;go Insert before replace&quot;. These may be intuitive because many operators are under the prefix &lt;code&gt;g&lt;/code&gt;, and &lt;code&gt;r&lt;/code&gt; replaces characters, &lt;code&gt;A&lt;/code&gt; appends and &lt;code&gt;I&lt;/code&gt; inserts before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, you can simply move the cursor over the word you want to replace over the whole buffer, and type in normal-mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;griwThing&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to replace all instances of the word with &quot;Thing&quot;. The other operators work similarly but put you in a substitute command with the text being replaced already there, with the cursor placed after or before the text.&#xA;So, for example, select your text in visual mode, for example the current Word until the end of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;viW$hgA_1&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;selects the text giving you a visual of what you will replace, then puts you in a substitute command letting you add, for example &quot;_1&quot; to the end of the replacement. You can also use this to easily remove characters from the end of each instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation of the vimscript code:&#xA;Operators are implemented in a strange way in vim, using a setting called &lt;code&gt;operatorfunc&lt;/code&gt; or &lt;code&gt;opfunc&lt;/code&gt; which is called whenever you type &lt;code&gt;@g&lt;/code&gt; in normal-mode, passing in a &lt;code&gt;type&lt;/code&gt; of the text-object and some other parameters. Then, vim will set the bracket marks referencing the start and end of the text-object. The &lt;code&gt;GetTextObject&lt;/code&gt; function just simplifies this, pulled mostly directly from &lt;code&gt;:help map-operator&lt;/code&gt;, so operators can be made easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, for each operator there is a function for &lt;code&gt;opfunc&lt;/code&gt; to be set to, with the correct parameters, and they use &lt;code&gt;feedkeys&lt;/code&gt; to open up the command-mode with the correct text to define a substitute command, with the cursor placed correctly. Then the normal-mode mapping sets the &lt;code&gt;opfunc&lt;/code&gt; then activates it with &lt;code&gt;g@&lt;/code&gt;, while the visual-mode mapping opens the command-mode and clears the auto-inserted visual range using &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt;, then just calls it and tells it is being called from visual-mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One problem is that if there are any special characters (including newlines) or escape sequences recognized by the substitute command, then something may mess up, so I will expand on the answer soon to fix that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Also, it may not be neccessary to have &lt;code&gt;gA&lt;/code&gt; and &lt;code&gt;gI&lt;/code&gt;, if you don't mind using &lt;code&gt;&amp;amp;&lt;/code&gt; in a substitute command to reference the replaced text, so &lt;code&gt;griw&amp;amp;_1&amp;lt;cr&amp;gt;&lt;/code&gt; does the same as &lt;code&gt;gAiw_1&amp;lt;cr&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="18654" LastEditorUserId="18654" LastEditDate="2018-09-04T07:30:08.943" LastActivityDate="2018-09-04T07:30:08.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17273" PostTypeId="1" AcceptedAnswerId="17274" CreationDate="2018-09-04T06:18:41.173" Score="1" ViewCount="266" Body="&lt;p&gt;I just learned about vimscript. I'm trying to write a small vimscript that'll kinda copy what &lt;a href=&quot;https://stackoverflow.com/questions/21316727/automatic-closing-brackets-for-vim&quot;&gt;this&lt;/a&gt; does, but more verbosely and very explicitly. (The first case would case typing a &lt;code&gt;(&lt;/code&gt; will insert &lt;code&gt;()&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; make keymappings&#xA;for [opener, closer] in {'(': ')'}&#xA;  inoremap l:opener &amp;lt;C-r&amp;gt;=InsertPair(opener, closer)&amp;lt;CR&amp;gt;&#xA;endfor&#xA;&#xA;&amp;quot; Typing the opener will also insert the closer&#xA;function! InsertPair(open, close)&#xA;  return a:open . a:close . &amp;quot;\&amp;lt;Left&amp;gt;&amp;quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I ran into a problem. The &lt;code&gt;inoremap&lt;/code&gt;s aren't working as planned - they're remapping the literal chars &lt;code&gt;l&lt;/code&gt; &lt;code&gt;:&lt;/code&gt; &lt;code&gt;o&lt;/code&gt; &lt;code&gt;p&lt;/code&gt; &lt;code&gt;e&lt;/code&gt; &lt;code&gt;n&lt;/code&gt; &lt;code&gt;e&lt;/code&gt; &lt;code&gt;r&lt;/code&gt; instead of the value of the local variable named opener (&lt;code&gt;(&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;h3&gt;Is dereferencing a variable in a call to map possible in vimscript?&lt;/h3&gt;&#xA;" OwnerUserId="14861" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-04-23T19:19:12.413" Title="How to &quot;dereference&quot; variables in keymappings?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17274" PostTypeId="2" ParentId="17273" CreationDate="2018-09-04T06:29:57.543" Score="2" Body="&lt;p&gt;So close! Use the &lt;code&gt;&quot;=&lt;/code&gt; register again. What that looks like for your question is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-r&amp;gt;=opener&amp;lt;CR&amp;gt; &amp;lt;C-r&amp;gt;=InsertPair(opener, closer)&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to lock in the values of the variable at runtime then you can also do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;inoremap &quot; . opener . &quot; &amp;lt;C-r&amp;gt;=InsertPair('&quot; . opener . &quot;', '&quot; . closer . &quot;')&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14861" LastEditorUserId="14861" LastEditDate="2020-04-23T19:19:12.413" LastActivityDate="2020-04-23T19:19:12.413" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17275" PostTypeId="1" AcceptedAnswerId="17276" CreationDate="2018-09-04T09:21:22.973" Score="1" ViewCount="91" Body="&lt;p&gt;For example, I've used &lt;code&gt;redir&lt;/code&gt; command to redirect command output to register a.&lt;br&gt;&#xA;Register a contains several lines of text.&lt;br&gt;&#xA;How to remove a line from register a or substitute a string from it?&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-09-04T11:05:02.923" Title="How to edit variable's content?" Tags="|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17276" PostTypeId="2" ParentId="17275" CreationDate="2018-09-04T09:34:44.650" Score="2" Body="&lt;p&gt;The register a is stored in variable &lt;code&gt;@a&lt;/code&gt;. If you need a little bit more control you can access the register through the functions &lt;code&gt;setreg()&lt;/code&gt; and &lt;code&gt;getreg()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Substitution can be accomplished though the function &lt;code&gt;substitute()&lt;/code&gt;, filtering can be done with &lt;code&gt;filter()&lt;/code&gt; (but you may need to convert the string into a list first with &lt;code&gt;split(str, &quot;\n&quot;)&lt;/code&gt;)...&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-09-04T09:34:44.650" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17277" PostTypeId="1" AcceptedAnswerId="17298" CreationDate="2018-09-04T09:56:17.760" Score="1" ViewCount="2087" Body="&lt;h3&gt;Problem&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I'm finally getting around to upgrading from Vim 7.4 to Vim 8.1, but my global custom &#xA;highlight colors have stopped working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I am aware similar questions (&lt;a href=&quot;https://vi.stackexchange.com/questions/12796/vim-8-0-not-honoring-custom-colors&quot;&gt;such as this one&lt;/a&gt;) have been asked, but these all seem to be related to the closed &lt;a href=&quot;https://github.com/vim/vim/issues/542&quot; rel=&quot;nofollow noreferrer&quot;&gt;Issue #542&lt;/a&gt;, and none of the solutions there seem to work for me.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Version Info&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;8.1 from the &lt;a href=&quot;https://launchpad.net/~jonathonf/+archive/ubuntu/vim-daily&quot; rel=&quot;nofollow noreferrer&quot;&gt;jonathonf/vim&lt;/a&gt; ppa repository on Ubuntu 18.04.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 22 2018 11:42:48)&#xA;Included patches: 1-346&#xA;Modified by jonathonf.fernyhough@york.ac.uk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://pastebin.com/raw/HD8c6Ynr&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Full `--version` text&quot;&gt;Full &lt;code&gt;--version&lt;/code&gt; text&lt;/a&gt; (Pastebin link)&#xA;I also tried &lt;a href=&quot;https://pastebin.com/raw/EpT0yzkw&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim 8.0&lt;/a&gt; from Ubuntu 18.04's &lt;code&gt;vim&lt;/code&gt; package&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Minimum steps to reproduce&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Create the following &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;Read the correct vimrc&quot;&#xA;hi Comment ctermfg=green cterm=none&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit any file with comments; &quot;Read the correct vimrc&quot; is displayed, but the comment color is not green.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, sometimes I can see the color change a few milliseconds after the file is opened, suggesting something may indeed be overriding my settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:hi Comment ...&lt;/code&gt; from within vim works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;vim&lt;/code&gt; with/without &lt;code&gt;-u .vimrc&lt;/code&gt; does not make a difference.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Other things I've tried&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I've tried using the &lt;code&gt;autocmd&lt;/code&gt; suggestion from the above linked answer, to no avail. In short, that looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup customhighlight&#xA;        autocmd!&#xA;        autocmd ColorScheme * hi Comment ctermfg=green&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I then went down the rabbit hole of vimrc defaults:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, unless I missed something, there doesn't appear to be anything in the default/Debian vim defaults that would override a user &lt;code&gt;.vimrc&lt;/code&gt;, and, indeed, that would be silly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have &lt;em&gt;not&lt;/em&gt; gone down the route of implementing custom color schemes, which was another suggestion. Reason being, I work with &lt;em&gt;a lot&lt;/em&gt; of different filetypes on a regular basis, and there has always been a way to globally customize colors, so I'm hoping there's a solution.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:verbose hi Comment&lt;/code&gt; reports:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Comment        xxx term=bold ctermfg=14 guifg=#80a0ff&#xA;        Last set from /usr/share/vim/vim81/syntax/syncolor.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:colorscheme&lt;/code&gt; reports &lt;code&gt;default&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Summary&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;What is the best practice to set global syntax highlight color preferences in Vim 8.x?&lt;/p&gt;&#xA;" OwnerUserId="18854" LastEditorUserId="18854" LastEditDate="2018-09-05T04:42:31.773" LastActivityDate="2018-09-05T14:50:22.100" Title="Vim 8.1 Globally custom highlight colors" Tags="|vimrc|linux-ubuntu|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17278" PostTypeId="2" ParentId="17275" CreationDate="2018-09-04T11:05:02.923" Score="1" Body="&lt;p&gt;You can also make edits interactively by:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;pasting the register contents into your buffer: &lt;code&gt;&quot;ap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;editing with whatever Vim commands you like&lt;/li&gt;&#xA;&lt;li&gt;and then yanking or deleting back into the register with e.g. &lt;code&gt;&quot;adip&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-09-04T11:05:02.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17282" PostTypeId="1" CreationDate="2018-09-04T12:43:03.620" Score="2" ViewCount="896" Body="&lt;p&gt;I currently use 'junegunn/fzf.vim', along with the homebrew version of fzf in the command line to search within projects. My setup uses Neovim and Tmux, and I'm getting intermittent freezing when navigating to files using both &lt;code&gt;:GFiles&lt;/code&gt; and &lt;code&gt;:Ag&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;When&lt;/em&gt; it happens, it happens like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I run &lt;code&gt;GFiles&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Search split appears&lt;/li&gt;&#xA;&lt;li&gt;I navigate to a particular file and press enter&lt;/li&gt;&#xA;&lt;li&gt;Vim is now &lt;em&gt;completely&lt;/em&gt; unresponsive&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I know that I should really isolate the issue using a minimal &lt;code&gt;.vimrc&lt;/code&gt;, but it is so intermittent I've been completely unable to do that. Sometimes it happens (usually when I'm pairing with another dev, lol) and sometimes it doesn't, despite following the exact same steps. I'm therefore including my full &lt;code&gt;.vimrc&lt;/code&gt; below - please don't hate me. If anyone has any tips on how to debug the issue it would be greatfully received because I'm completely at a loss...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Allows the system keyboard to interact with yank etc&#xA;set clipboard=unnamed&#xA;&#xA;set encoding=UTF-8&#xA;&#xA;set hidden&#xA;&#xA;&quot; Store swap files here&#xA;set directory^=$HOME/.vim/tmp//&#xA;&#xA;&quot; Indenting&#xA;set expandtab&#xA;set tabstop=2&#xA;set shiftwidth=2&#xA;&#xA;&quot; Highlight search hits&#xA;set hlsearch&#xA;&#xA;&quot; Search as chars are added to search&#xA;set incsearch&#xA;&#xA;set ignorecase&#xA;set smartcase&#xA;&#xA;set laststatus=2&#xA;&#xA;&quot; Turn on syntax highlightingg&#xA;syntax enable&#xA;&#xA;&quot;set 'nocompatible' to ward off unexpected things that your distro might&#xA;&quot; have made, as well as sanely reset options when re-sourcing .vimrc&#xA;set nocompatible&#xA;&#xA;set wildmenu&#xA;&#xA;set showcmd&#xA;&#xA;set ruler&#xA;&#xA;&quot; Actual confirm box rather than dialog box on errors (such as if you quit&#xA;&quot; without write)&#xA;set confirm&#xA;&#xA;set cursorline&#xA;&quot; attempt to determine the type of a file based on its name and possibly its&#xA;&quot; contents. Use this to allow intelligent auto-indenting for each filetype,&#xA;&quot; &quot; and for plugins that are filetype specific.&#xA;&quot; filetype indent plugin on&#xA;&#xA;set number relativenumber &quot; Turn on relative line numbering&#xA;&#xA;augroup numbertoggle&#xA;  autocmd!&#xA;  autocmd BufEnter,FocusGained,InsertLeave * set relativenumber&#xA;  autocmd BufLeave,FocusLost,InsertEnter   * set norelativenumber&#xA;augroup END&#xA;&#xA;&quot; Install vim-plug if it is missing&#xA;if empty(glob('~/.vim/autoload/plug.vim'))&#xA;  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs&#xA;    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC&#xA;endif&#xA;&#xA;let g:rbpt_max = 16&#xA;let g:rbpt_loadcmd_toggle = 0 &#xA;&#xA;&quot; Declare plugins&#xA;call plug#begin('~/.vim/plugged') &#xA;Plug 'vim-scripts/git-log'&#xA;Plug 'kien/rainbow_parentheses.vim'&#xA;Plug 'junegunn/fzf.vim'&#xA;Plug '/usr/local/opt/fzf'&#xA;Plug 'airblade/vim-gitgutter'&#xA;Plug 'flazz/vim-colorschemes'&#xA;Plug 'tpope/vim-cucumber'&#xA;Plug 'tpope/vim-surround'&#xA;Plug 'christoomey/vim-tmux-navigator'&#xA;Plug 'tpope/vim-fugitive'&#xA;Plug 'tpope/vim-rhubarb'&#xA;Plug 'tpope/vim-commentary'&#xA;Plug 'altercation/vim-colors-solarized'&#xA;Plug 'easymotion/vim-easymotion'&#xA;Plug 'aklt/plantuml-syntax'&#xA;Plug 'Shougo/deoplete.nvim'&#xA;Plug 'carlitux/deoplete-ternjs'&#xA;Plug 'mustache/vim-mustache-handlebars'&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'ternjs/tern_for_vim'&#xA;Plug 'vim-scripts/AutoComplPop'&#xA;Plug 'jacoborus/tender.vim'&#xA;Plug 'drewtempelmeyer/palenight.vim'&#xA;Plug 'ryanoasis/vim-devicons'&#xA;Plug 'junkblocker/patchreview-vim'&#xA;&quot; This is not the original plugin but a fork that adds Github enterprise support&#xA;Plug 'jamietanna/vim-codereview' &#xA;Plug 'janko-m/vim-test'&#xA;Plug 'w0rp/ale'&#xA;Plug 'gioele/vim-autoswap'&#xA;Plug 'ekalinin/Dockerfile.vim'&#xA;Plug 'vim-airline/vim-airline'&#xA;Plug 'tpope/vim-dispatch'&#xA;Plug 'junegunn/gv.vim'&#xA;Plug 'arkwright/vim-whiplash'&#xA;Plug 'SirVer/ultisnips'&#xA;Plug 'honza/vim-snippets'&#xA;Plug 'martinda/Jenkinsfile-vim-syntax'&#xA;Plug 'ruanyl/vim-gh-line'&#xA;Plug 'tpope/vim-unimpaired'&#xA;call plug#end()&#xA;&#xA;let g:ale_linters = {'javascript': ['eslint']}&#xA;let g:ale_javascript_eslint_use_global = 1&#xA;let g:airline#extensions#ale#enabled = 1&#xA;let g:airline#extensions#tabline#enabled = 1&#xA;&quot; If the plugged directory hasn't been created, install all plugins&#xA;if empty(glob('~/.vim/plugged'))&#xA;  PlugInstall&#xA;endif&#xA;&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;c-b&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-z&amp;gt;&quot;&#xA;&#xA;colorscheme Gruvbox&#xA;set background=dark&#xA;&#xA;&quot; Key mappings&#xA;&#xA;&quot; Map leader key to be the space bar&#xA;let mapleader = &quot;\&amp;lt;Space&amp;gt;&quot;&#xA;&#xA;let g:airline_powerline_fonts = 1&#xA;&#xA;if !exists('g:airline_symbols')&#xA;    let g:airline_symbols = {}&#xA;endif&#xA;&#xA;&quot; unicode symbols&#xA;let g:airline_left_sep = '»'&#xA;let g:airline_left_sep = '▶'&#xA;let g:airline_right_sep = '«'&#xA;let g:airline_right_sep = '◀'&#xA;let g:airline_symbols.linenr = '␊'&#xA;let g:airline_symbols.linenr = '␤'&#xA;let g:airline_symbols.linenr = '¶'&#xA;let g:airline_symbols.branch = '⎇'&#xA;let g:airline_symbols.paste = 'ρ'&#xA;let g:airline_symbols.paste = 'Þ'&#xA;let g:airline_symbols.paste = '∥'&#xA;let g:airline_symbols.whitespace = 'Ξ'&#xA;&#xA;let test#strategy = &quot;vimux&quot;&#xA;&#xA;&quot; airline symbols&#xA;let g:airline_left_sep = ''&#xA;let g:airline_left_alt_sep = ''&#xA;let g:airline_right_sep = ''&#xA;let g:airline_right_alt_sep = ''&#xA;let g:airline_symbols.branch = ''&#xA;let g:airline_symbols.readonly = ''&#xA;let g:airline_symbols.linenr = ''&#xA;&#xA;&quot; Tern mappings&#xA;nmap &amp;lt;leader&amp;gt;td :TernDef&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;tdp :TernDefPreview&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;tds :TernDefSplit&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;tdt :TernDefTab&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;tr :TernRefs&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;trn :TernRename&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;tt :TernType&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Mapping selecting mappings&#xA;nmap &amp;lt;leader&amp;gt;&amp;lt;tab&amp;gt; &amp;lt;plug&amp;gt;(fzf-maps-n)&#xA;xmap &amp;lt;leader&amp;gt;&amp;lt;tab&amp;gt; &amp;lt;plug&amp;gt;(fzf-maps-x)&#xA;omap &amp;lt;leader&amp;gt;&amp;lt;tab&amp;gt; &amp;lt;plug&amp;gt;(fzf-maps-o)&#xA;&#xA;&quot; Insert mode completion&#xA;imap &amp;lt;c-x&amp;gt;&amp;lt;c-k&amp;gt; &amp;lt;plug&amp;gt;(fzf-complete-word)&#xA;imap &amp;lt;c-x&amp;gt;&amp;lt;c-f&amp;gt; &amp;lt;plug&amp;gt;(fzf-complete-path)&#xA;imap &amp;lt;c-x&amp;gt;&amp;lt;c-j&amp;gt; &amp;lt;plug&amp;gt;(fzf-complete-file-ag)&#xA;imap &amp;lt;c-x&amp;gt;&amp;lt;c-l&amp;gt; &amp;lt;plug&amp;gt;(fzf-complete-line)&#xA;&#xA;nmap &amp;lt;silent&amp;gt; t&amp;lt;C-n&amp;gt; :TestNearest&amp;lt;CR&amp;gt; &quot; t Ctrl+n&#xA;nmap &amp;lt;silent&amp;gt; t&amp;lt;C-f&amp;gt; :TestFile&amp;lt;CR&amp;gt;    &quot; t Ctrl+f&#xA;nmap &amp;lt;silent&amp;gt; t&amp;lt;C-s&amp;gt; :TestSuite&amp;lt;CR&amp;gt;   &quot; t Ctrl+s&#xA;nmap &amp;lt;silent&amp;gt; t&amp;lt;C-l&amp;gt; :TestLast&amp;lt;CR&amp;gt;    &quot; t Ctrl+l&#xA;nmap &amp;lt;silent&amp;gt; t&amp;lt;C-g&amp;gt; :TestVisit&amp;lt;CR&amp;gt;   &quot; t Ctrl+g&#xA;&#xA;nnoremap &amp;lt;C-n&amp;gt; :bprevious&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-p&amp;gt; :bnext&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Advanced customization using autoload functions&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-k&amp;gt; fzf#vim#complete#word({'left': '15%'})&#xA;&#xA;&quot; Map fzf commands&#xA;nmap &amp;lt;leader&amp;gt;k :Ag&#xA;nmap &amp;lt;leader&amp;gt;K :Ag!&#xA;nmap &amp;lt;leader&amp;gt;f :GitFiles&#xA;nmap &amp;lt;leader&amp;gt;F :GitFiles!&#xA;nmap &amp;lt;leader&amp;gt;g :GitFiles?&#xA;nmap &amp;lt;leader&amp;gt;b :Buffers&#xA;nmap &amp;lt;leader&amp;gt;c :Commits&#xA;nmap &amp;lt;leader&amp;gt;C :BCommits&#xA;nmap &amp;lt;leader&amp;gt;s :Gstatus&#xA;&#xA;map&amp;lt;C-s&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;map&amp;lt;C-w&amp;gt; :Gblame&amp;lt;CR&amp;gt;&#xA;&#xA;au VimEnter * RainbowParenthesesToggle&#xA;au Syntax * RainbowParenthesesLoadRound&#xA;au Syntax * RainbowParenthesesLoadSquare&#xA;au Syntax * RainbowParenthesesLoadBraces&#xA;&#xA;let g:GITLOG_default_mode = 2&#xA;map &amp;lt;silent&amp;gt; &amp;lt;f7&amp;gt; :call GITLOG_ToggleWindows()&amp;lt;cr&amp;gt;&#xA;map &amp;lt;silent&amp;gt; &amp;lt;f5&amp;gt; :call GITLOG_FlipWindows()&amp;lt;cr&amp;gt;&#xA;&#xA;let g:ale_sign_error = '✗'&#xA;let g:ale_sign_warning = ''&#xA;&#xA;let g:gitgutter_sign_added = ''&#xA;let g:gitgutter_sign_modified = ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18857" LastActivityDate="2018-09-04T12:43:03.620" Title="Neovim freezes with FZF" Tags="|neovim|plugin-fzf|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17284" PostTypeId="2" ParentId="17254" CreationDate="2018-09-04T14:23:03.660" Score="3" Body="&lt;p&gt;@Rich answered your question very well. However, judging by your example you may want to look into &lt;code&gt;:vimgrep&lt;/code&gt;/&lt;code&gt;:grep&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /pat/ %&#xA;:grep 'pat' %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both &lt;code&gt;:vimgrep&lt;/code&gt; &amp;amp; &lt;code&gt;:grep&lt;/code&gt; will put the results into the quickfix list. Here are a few quickfix list commands to get you up and running fast:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:cnext&lt;/code&gt; and &lt;code&gt;:cprev&lt;/code&gt; to move between your errors/matches. I suggest you &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;map these commands&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:cfirst&lt;/code&gt; and &lt;code&gt;:clast&lt;/code&gt; to go to the first and last error/matches respectively.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:copen&lt;/code&gt; to open up the quickfix list in a window (&lt;code&gt;:cclose&lt;/code&gt; to close)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:cwindow&lt;/code&gt; to open quickfix list window only if there are errors&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:cc&lt;/code&gt; to display the current error/match.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:cdo {cmd}&lt;/code&gt; to run a command, &lt;code&gt;{cmd}&lt;/code&gt; on each quickfix entry.&lt;/li&gt;&#xA;&lt;li&gt;You can use &lt;code&gt;%&lt;/code&gt; on the command-line to supply the current filename.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Vimcast episodes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the following &lt;a href=&quot;http://vimcasts.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimcasts&lt;/a&gt; episode: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/episodes/project-wide-find-and-replace/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Project-wide find and replace&lt;/a&gt; Note: &lt;code&gt;:cdo&lt;/code&gt; is available in Vim 8.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/episodes/search-multiple-files-with-vimgrep/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Search multiple files with :vimgrep&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more help see the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h quickfix&#xA;:h :cnext&#xA;:h :cfirst&#xA;:h :cope&#xA;:h :cwindow&#xA;:h :cc&#xA;:h :cdo&#xA;:h :_%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-09-04T14:35:30.570" LastActivityDate="2018-09-04T14:35:30.570" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17285" PostTypeId="1" AcceptedAnswerId="17286" CreationDate="2018-09-04T15:11:28.023" Score="1" ViewCount="201" Body="&lt;p&gt;Want to exactly matching current word with below function.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! My_Exact_Search ()&#xA;   let CurrentWord = expand(&quot;&amp;lt;cword&amp;gt;&quot;)&#xA;   exec &quot;/\&amp;lt;&quot;.CurrentWord.&quot;\&amp;gt;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But get error: &lt;code&gt;E486: Pattern not found: &amp;lt;word&amp;gt;&lt;/code&gt;.&lt;br&gt;&#xA;How to fix it?&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2018-09-04T18:22:54.587" Title="How to exactly search current word?" Tags="|search|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17286" PostTypeId="2" ParentId="17285" CreationDate="2018-09-04T15:17:58.880" Score="1" Body="&lt;p&gt;The &lt;code&gt;*&lt;/code&gt; command does this natively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with your function is you need to escape your &lt;code&gt;/&lt;/code&gt; or use literal-string (I recommend).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @/ = '/\&amp;lt;'.CurrentWord.'\&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You also should be using &lt;code&gt;:normal&lt;/code&gt; to create the search.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal! /\\&amp;lt;&quot;.expand('&amp;lt;cword&amp;gt;').&quot;\\&amp;gt;\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h *&#xA;:h literal-string&#xA;:h quote/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-09-04T18:22:54.587" LastActivityDate="2018-09-04T18:22:54.587" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17287" PostTypeId="2" ParentId="5201" CreationDate="2018-09-04T23:56:23.033" Score="1" Body="&lt;p&gt;One could also have: &lt;code&gt;au BufRead,BufNewFile *.tpp setlocal filetype=cpp&lt;/code&gt; in their &lt;code&gt;.vimrc&lt;/code&gt; such that upon opening a file with &lt;code&gt;.tpp&lt;/code&gt; extension, filetype is set for &lt;em&gt;C++&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="5525" LastEditorUserId="5298" LastEditDate="2018-09-05T10:09:21.413" LastActivityDate="2018-09-05T10:09:21.413" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17288" PostTypeId="2" ParentId="16921" CreationDate="2018-09-05T00:07:21.230" Score="0" Body="&lt;p&gt;This works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'xolox/vim-session'&#xA;let g:session_autosave = 'yes' &quot;auto saved&#xA;let g:session_autoload = 'no' &quot;load by myself as below&#xA;function! s:open_proj_session()&#xA;    let sess_name = expand('%:t:r')&#xA;&#xA;    let &amp;amp;titlestring = sess_name&#xA;    call xolox#session#open_cmd(sess_name, '', 'OpenSession') &quot; open it first&#xA;&#xA;    let cur_sess = xolox#session#find_current_session() &quot; if it's not opened then it's not created, let's create it&#xA;    if cur_sess != sess_name&#xA;        call xolox#session#save_cmd(sess_name, '', 'SaveSession')&#xA;    endif&#xA;&#xA;    &quot; close the .proj buffer&#xA;    if bufnr(sess_name.'.proj') &amp;gt; 0&#xA;        exec 'bd '.sess_name.'.proj'&#xA;    endif&#xA;&#xA;    &quot;close the .vim buffer (session file)&#xA;    if bufnr(sess_name.'.vim') &amp;gt; 0&#xA;        exec 'bd '.sess_name.'.vim'&#xA;    endif&#xA;endfunction&#xA;augroup MyProj&#xA;    autocmd!&#xA;    autocmd! BufEnter *.proj nested call s:open_proj_session()&#xA;augroup END&#xA;set ssop+=resize,winpos,winsize,blank,folds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6971" LastActivityDate="2018-09-05T00:07:21.230" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17289" PostTypeId="1" AcceptedAnswerId="17292" CreationDate="2018-09-05T02:49:45.413" Score="2" ViewCount="65" Body="&lt;p&gt;I want to batch change 50+ files in a folder in Windows10. the original name style: 'how to install the software - softwareA user manual p1.pdf', the new file name will be 'softwareA user manual p1 - how to install the software.pdf'. I am using a .bat file to do the job and exported a list of all the file names into a .txt file. I want to change each line from 'filename' to 'move filename new_filename'. I can add 'move ' in front of all the lines, but don't know how to generate new filename (swap 2 parts before and after - in the old filename) and append the new filename at the end of each line. &lt;/p&gt;&#xA;" OwnerUserId="18501" LastEditorUserId="1292" LastEditDate="2018-09-11T16:02:21.427" LastActivityDate="2018-09-11T16:02:21.427" Title="Batch change name from ABC - DEF.pdf to DEF - ABC.pdf" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17291" PostTypeId="2" ParentId="17265" CreationDate="2018-09-05T05:26:33.243" Score="2" Body="&lt;p&gt;So this is a bug of vim-latex v1.9.0 that is fixed in v1.10.0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I finally managed to reproduce the issue you reported and after using &lt;a href=&quot;https://git-scm.com/book/en/v2/Git-Tools-Debugging-with-Git#_binary_search&quot; rel=&quot;nofollow noreferrer&quot;&gt;git bisect&lt;/a&gt; on the &lt;a href=&quot;https://github.com/vim-latex/vim-latex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-latex sources&lt;/a&gt;, I managed to narrow it down to &lt;a href=&quot;https://github.com/vim-latex/vim-latex/commit/ba140b1bd2d8c77e2818772a10338cce72f789d4&quot; rel=&quot;nofollow noreferrer&quot;&gt;commit ba140b1bd2d8&lt;/a&gt; which fixes this issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I didn't see a bug report or a pull request for that commit, so not really sure whether it was meant to fix a bug, or just using a better API and ended up fixing the bug as a side effect.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion is that you should upgrade to &lt;a href=&quot;https://github.com/vim-latex/vim-latex/releases/tag/v1.10.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;v1.10.0&lt;/a&gt;, but applying that patch to v1.9.0 seems to work as well (if for some reason you prefer to cherry-pick a single fix.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2018-09-05T05:26:33.243" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17292" PostTypeId="2" ParentId="17289" CreationDate="2018-09-05T06:20:49.823" Score="3" Body="&lt;p&gt;This should do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(.*\) - \(.*\)\.pdf$/move &quot;&amp;amp;&quot; &quot;\2 - \1.pdf&quot;                                                                                                                         &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you have a file with lines with only file names:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;how to install the software - softwareA user manual p1.pdf&#xA;how to test the software - softwareA user manual p1.pdf&#xA;how to use the software - softwareB user manual p2.pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That substitute command will turn them into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;move &quot;how to install the software - softwareA user manual p1.pdf&quot; &quot;softwareA user manual p1 - how to install the software.pdf&quot;&#xA;move &quot;how to test the software - softwareA user manual p1.pdf&quot; &quot;softwareA user manual p1 - how to test the software.pdf&quot;&#xA;move &quot;how to use the software - softwareB user manual p2.pdf&quot; &quot;softwareB user manual p2 - how to use the software.pdf&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which should actually do everything you're trying to accomplish, including adding the &lt;code&gt;move&lt;/code&gt; command and quoting the file names, considering they contain spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trying to disect that regex a bit:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\(.*\)&lt;/code&gt; matches a group and saves it in a &quot;group&quot; such as &lt;code&gt;\1&lt;/code&gt;, &lt;code&gt;\2&lt;/code&gt;, etc.&lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;-&lt;/code&gt; will match a dash surrounded by spaces, in the middle of the name.&lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;\.pdf&lt;/code&gt; will match a literal &quot;.pdf&quot; extension.&lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt; anchors make sure this only matches full lines.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And the expansion:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;&lt;/code&gt; expands to the entire text matched, which is the whole filename.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\2&lt;/code&gt; and &lt;code&gt;\1&lt;/code&gt; will expand to the matched groups, but in reverse order.&lt;/li&gt;&#xA;&lt;li&gt;so &lt;code&gt;\2 - \1.pdf&lt;/code&gt; will expand to the new filename you want.&lt;/li&gt;&#xA;&lt;li&gt;adding literal quotes with the &lt;code&gt;&quot;&lt;/code&gt;s.&lt;/li&gt;&#xA;&lt;li&gt;and finally including a &lt;code&gt;move&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Finally, the &lt;code&gt;%&lt;/code&gt; (right after &lt;code&gt;:&lt;/code&gt;) acts on the whole file (equivalent to a &lt;code&gt;1,$&lt;/code&gt; range) and &lt;code&gt;s&lt;/code&gt; is the substitute command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Save the resulting file as a &lt;code&gt;.bat&lt;/code&gt; and run it to batch rename all your files. Good luck!&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2018-09-05T06:20:49.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17293" PostTypeId="2" ParentId="17269" CreationDate="2018-09-05T08:33:05.950" Score="8" Body="&lt;p&gt;The problem you're having here is that by the time &lt;code&gt;show_position()&lt;/code&gt; is running you're already &lt;em&gt;out&lt;/em&gt; of visual mode, since the &lt;code&gt;:&lt;/code&gt; switched to command-line mode before that function gets called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you call &lt;code&gt;getpos(&quot;v&quot;)&lt;/code&gt; before you leave visual mode, it will correctly return where you actually started the visual selection, instead of the top of the selection (&lt;code&gt;'&amp;lt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use a &lt;code&gt;vmap &amp;lt;expr&amp;gt; ...&lt;/code&gt; to be able to evaluate the expressions before leaving visual mode. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! show_position()&#xA;  return &quot;:\&amp;lt;c-u&amp;gt;echo 'start=&quot; . string(getpos(&quot;v&quot;)) . &quot; end=&quot; . string(getpos(&quot;.&quot;)) . &quot;'\&amp;lt;cr&amp;gt;gv&quot;&#xA;endfunction&#xA;vmap &amp;lt;expr&amp;gt; ;j show_position()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I start the visual selection on &lt;code&gt;:&lt;/code&gt; and end it at &lt;code&gt;|&lt;/code&gt;, &lt;code&gt;;j&lt;/code&gt; tells me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;start=[0, 2, 6, 0] end=[0, 6, 6, 0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the other hand, starting at &lt;code&gt;|&lt;/code&gt; and going up to &lt;code&gt;:&lt;/code&gt; gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;start=[0, 6, 6, 0] end=[0, 2, 6, 0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note: I'm on VIM 8.0, but I'd expect NeoVim would behave the same here.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2018-09-05T08:33:05.950" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17295" PostTypeId="1" CreationDate="2018-09-05T12:11:31.450" Score="3" ViewCount="128" Body="&lt;p&gt;&lt;em&gt;Discl.&lt;/em&gt; I'm perfectly aware of &lt;code&gt;:silent :delete&lt;/code&gt; or &lt;code&gt;silent :normal dd&lt;/code&gt;, I'm also aware of &lt;code&gt;execute()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My context is that I run unit tests with vimrunner on travis, with the version of Vim currently available on travis (7.4.152). vimrunner uses +clientserver feature and &lt;code&gt;:redir&lt;/code&gt; to execute the commands sent to the Vim server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately while &lt;code&gt;:silent :delete&lt;/code&gt; perfectly works when using interactively the code I'm testing, within a &lt;code&gt;:redir&lt;/code&gt; I end-up with &lt;code&gt;&quot;nn fewer lines&quot;&lt;/code&gt; that messes the test. While I could use &lt;code&gt;setline()&lt;/code&gt; or &lt;code&gt;append()&lt;/code&gt; to add or change lines, there is no &lt;code&gt;deleteline()&lt;/code&gt; to silently remove lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an option somewhere that I've missed, that completely silences these interactive commands?&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-09-05T12:11:31.450" Title="Completly silencing commands like `dd`, `:delete` of old vim versions (7.4.152)" Tags="|vimscript|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17296" PostTypeId="1" AcceptedAnswerId="17317" CreationDate="2018-09-05T13:56:33.190" Score="9" ViewCount="5031" Body="&lt;p&gt;&lt;strong&gt;behave&lt;/strong&gt; test language need to execute different lines of the behave feature file, for example, if I want to test the line number 99, I'll need to input the following line in the terminal&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;behave features/target.feature:99 -k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently I'm using Tmux and vim as my IDE. I have 2 tmux panes and A and B, vim editor is opened in pane A (as the editing/developing environment). pane B is simply a terminal used as the running the test&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want' to achieve is: Get the current cursor-marked line number in the file open by vim in pane A(ex. 99) and send this line information to create a shell command: &#xA;&lt;strong&gt;behave features/target.feature:99 -k&lt;/strong&gt; and send this command to Tmux pane B to excut&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I've tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let runLine = line('.')&#xA;&quot;autocmd FileType text nnoremap &amp;lt;space&amp;gt;r !sh -xc 'behave features/navmemory.feature:&amp;amp;runLine -k'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the part for sending it to pane B and execute is missing and I don't know how can I do it  &lt;/p&gt;&#xA;" OwnerUserId="15958" LastActivityDate="2024-04-03T23:12:51.697" Title="Sending command to different tmux pane from vim" Tags="|vimrc|vimscript|tmux|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17298" PostTypeId="2" ParentId="17277" CreationDate="2018-09-05T14:50:22.100" Score="3" Body="&lt;p&gt;I don't know what changed between Vim 7.4 and 8.1 that caused this change in behavior, but the output of &lt;code&gt;:verbose hi Comment&lt;/code&gt; that you posted provided a clue to a solution. &lt;code&gt;:help syncolor&lt;/code&gt; suggests overriding the default highlighting colors by creating a file named &lt;code&gt;~/.vim/after/syntax/syncolor.vim&lt;/code&gt; (&lt;code&gt;~\vimfiles\after\syntax\syncolor.vim&lt;/code&gt; on Windows) and putting in that file highlight commands like the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;background == &quot;light&quot;&#xA;    highlight Comment ctermfg=darkgreen guifg=darkgreen&#xA;else&#xA;    highlight Comment ctermfg=green guifg=green&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2018-09-05T14:50:22.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17299" PostTypeId="2" ParentId="16996" CreationDate="2018-09-05T15:44:24.917" Score="1" Body="&lt;p&gt;Here's another solution, which solves the problems with multibyte characters (and a &lt;a href=&quot;https://vi.stackexchange.com/questions/16996/expand-the-visual-selection-independently-of-the-cursor-position/17299#comment29643_17004&quot;&gt;couple of issues with visual block mode&lt;/a&gt;). It works by using motions to expand the visual selection by moving the cursor, instead of setting the ends of the selection directly in Vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also differs from your solution in that if the visual selection is linewise, the commands expand the selection vertically instead of displaying an error. If you really don't want that, it should be fairly easy to adapt the code to revert to your version's behaviour.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ExpandVisualWrapper(count, expand_after) abort&#xA;  &quot; Save cursor position, count and expansion type&#xA;  let s:cursor_pos = getpos('.')&#xA;  let s:count = a:count&#xA;  let s:expand_after = a:expand_after&#xA;&#xA;  &quot; Return a string that will save the current visual selection (by yanking it&#xA;  &quot; into the black hole register) and then call the real function.&#xA;  return &quot;\&quot;_y:call ExpandVisual()\&amp;lt;CR&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;function! ExpandVisual() abort&#xA;    &quot; Check which end we want to expand&#xA;    if s:expand_after&#xA;        let visual_pos = getpos(&quot;'&amp;gt;&quot;)&#xA;    else&#xA;        let visual_pos = getpos(&quot;'&amp;lt;&quot;)&#xA;    endif&#xA;&#xA;    &quot; Check which end the cursor is at&#xA;    if&#xA;    \     visualmode() == 'v' &quot; Characterwise&#xA;    \     &amp;amp;&amp;amp;&#xA;    \     s:cursor_pos == visual_pos&#xA;    \ ||&#xA;    \     visualmode() == 'V' &quot; Linewise&#xA;    \     &amp;amp;&amp;amp;&#xA;    \     s:cursor_pos[1] == visual_pos[1]&#xA;    \ ||&#xA;    \     visualmode() == &quot;\&amp;lt;C-V&amp;gt;&quot; Blockwise&#xA;    \     &amp;amp;&amp;amp;&#xA;    \     xor(getpos(&quot;'&amp;lt;&quot;)[2] &amp;gt; getpos(&quot;'&amp;gt;&quot;)[2], s:cursor_pos[2] == visual_pos[2])&#xA;&#xA;        &quot; Cursor is at the correct end&#xA;        let change_end = ''&#xA;    else&#xA;        &quot; We'll need to hop to the other end of the selection&#xA;        let change_end = 'o'&#xA;    endif&#xA;&#xA;    &quot; Which direction do we want to move the cursor?&#xA;    if (s:expand_after &amp;amp;&amp;amp; s:count &amp;gt; 0) || (!s:expand_after &amp;amp;&amp;amp; s:count &amp;lt; 0)&#xA;        let motion = visualmode() == &quot;V&quot; ? &quot;\&amp;lt;Down&amp;gt;&quot; : &quot;\&amp;lt;Space&amp;gt;&quot;&#xA;    else&#xA;        let motion = visualmode() == &quot;V&quot; ? &quot;\&amp;lt;Up&amp;gt;&quot; : &quot;\&amp;lt;BS&amp;gt;&quot;&#xA;    endif&#xA;&#xA;    &quot; Build the commands&#xA;    let commands = 'gv'&#xA;    let commands .= change_end&#xA;    let commands .= abs(s:count) . motion&#xA;    let commands .= change_end&#xA;&#xA;    &quot; Run the commands&#xA;    execute 'normal!' commands&#xA;endfunction&#xA;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; \- ExpandVisualWrapper(-v:count1, 0)&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; \+ ExpandVisualWrapper(v:count1, 0)&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; - ExpandVisualWrapper(-v:count1, 1)&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; + ExpandVisualWrapper(v:count1, 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I saw your solution, I read the explanation at the top and instead of actually reading the code, just looked at the length of it before jumping to the conclusion, &amp;ldquo;That looks overly complicated. Surely this would be easier to implement just by using normal motion commands.&amp;rdquo;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arguably, my solution is even more complex. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is for three reasons:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I didn't really think about how many different behaviours you'd implemented,&lt;/li&gt;&#xA;&lt;li&gt;I failed to realise that most of your code is actually error handling,&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It's not possible to implement this with a simple &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#:map-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;expression mapping&lt;/a&gt; because when such a mapping is invoked, the &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; marks are set to the &lt;em&gt;previous&lt;/em&gt; visual selection&amp;#8202;&amp;mdash;&amp;#8202;not the current one. However, it's also not possible to implement it with a regular mapping, because as soon as you enter command-line mode to invoke a function via &lt;code&gt;:call&lt;/code&gt;, the cursor moves to the start of the visual selection, so it's not possible to discern which end you were at.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's therefore necessary to implement two functions. The first, invoked by an expression mapping, saves the state of the visual selection by means of yanking it into the &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#quote_&quot; rel=&quot;nofollow noreferrer&quot;&gt;black hole&lt;/a&gt; register. The second, invoked by the return value of the first, actually does the work.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-09-05T15:56:12.950" LastActivityDate="2018-09-05T15:56:12.950" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17300" PostTypeId="2" ParentId="16998" CreationDate="2018-09-05T16:12:22.997" Score="1" Body="&lt;p&gt;Here's an alternative solution that triggers on a plain &lt;code&gt;!&lt;/code&gt; and then inspects the characters before the cursor to decide whether to insert an exclamation point or your expansion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; ! getline('.')[getpos('.')[2] - 6 : getpos('.')[2] - 2] == 'begin' ? &quot;  end\&amp;lt;Left&amp;gt;\&amp;lt;Left&amp;gt;\&amp;lt;Left&amp;gt;\&amp;lt;Left&amp;gt;&quot; : '!'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think I prefer yours :).&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-09-05T16:12:22.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17301" PostTypeId="2" ParentId="17199" CreationDate="2018-09-05T19:23:55.400" Score="1" Body="&lt;p&gt;There are two different things going on here that prevent colorization of the word &lt;code&gt;puts&lt;/code&gt; in ruby files. I examine them (and what led to their discovery) separately.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Setup&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;First, create the temporary file &lt;code&gt;some.rb&lt;/code&gt;, which &lt;code&gt;vim&lt;/code&gt; will rightfully detect as ruby code. I gave it the contents&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;puts &quot;stuff&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Initial thoughts&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Next, I ran &lt;code&gt;vim -u DEFAULTS some.rb&lt;/code&gt;. To my surprise, &lt;code&gt;puts&lt;/code&gt; wasn't highlighted. Time for further investigation! (To eliminate it being something in the defaults script, I also used &lt;code&gt;vim -u NONE some.rb&lt;/code&gt; and slowly enabled filetype detection, syntax, &amp;amp;c. I noticed the same results.)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Finding the syntax group&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I use my plugin &lt;a href=&quot;https://github.com/benknoble/vim-synstax&quot; rel=&quot;nofollow noreferrer&quot;&gt;synstax&lt;/a&gt; and the mapping &lt;code&gt;&amp;lt;Leader&amp;gt;&amp;lt;Leader&amp;gt;s&lt;/code&gt; to get the value of the syntax element under the cursor. The &lt;a href=&quot;https://github.com/benknoble/vim-synstax/blob/6d24f658c6fe21ef6ac2f84c3f91e52d5670ff9f/autoload/synstax.vim#L12-L28&quot; rel=&quot;nofollow noreferrer&quot;&gt;relevant code&lt;/a&gt; is reproduced in &lt;em&gt;Notes&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The highlight group is: &lt;code&gt;rubyLocalVariableOrMethod&lt;/code&gt;. Don't ask me why, that's just how the syntax file defines it.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The highlight&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:verbose highlight rubyLocalVariableOrMethod&lt;/code&gt; gives, unsurprisingly, &lt;code&gt;cleared&lt;/code&gt;. Alright, I think, the colors are just getting cleared. We can track that down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;$VIMRUNTIME/syntax/ruby.vim&lt;/code&gt;, we find at line 122:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match rubyLocalVariableOrMethod &quot;\&amp;lt;[_[:lower:]][_[:alnum:]]*[?!=]\=&quot; contains=NONE display transparent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At line 515:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi def link rubyCapitalizedMethod   rubyLocalVariableOrMethod&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are the only two occurrences in the entire &lt;code&gt;$VIMRUNTIME&lt;/code&gt; directory. So no colorscheme even makes use of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it's not getting 'cleared' so much as never being &lt;code&gt;:highlight&lt;/code&gt;ed. Alright, switch back to &lt;code&gt;some.rb&lt;/code&gt; and &lt;code&gt;:highlight link rubyLocalVariableOrMethod Statement&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hint: it won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:verbose highlight ...&lt;/code&gt; idiom gives the expected results: colors, linked to &lt;code&gt;Statement&lt;/code&gt;. But why isn't it showing up on the screen?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Syntax &amp;amp; highlight attributes&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Take another look at the definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match rubyLocalVariableOrMethod &quot;\&amp;lt;[_[:lower:]][_[:alnum:]]*[?!=]\=&quot; contains=NONE display transparent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We have the standard &lt;code&gt;syn match &amp;lt;name&amp;gt;&lt;/code&gt;, followed by a pattern to match. Sounds good. &lt;code&gt;contains=NONE&lt;/code&gt;... a little weird, if you're not familiar, but it seems to indicate things matching this pattern don't contain other syntax groups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's easy to miss, being at the end of a longer line, but &lt;code&gt;display&lt;/code&gt; and &lt;code&gt;transparent&lt;/code&gt; come next. Hmm, I think, this could be relevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;display&lt;/code&gt; simply indicates that no highlighting need be done when the syntax element is off screen; it's a tiny optimization for vim which can reduce it's overall memory consumption (cf. &lt;code&gt;:help :syn-display&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;transparent&lt;/code&gt;, on the other hand, is the culprit. &lt;em&gt;It effectively &lt;strong&gt;disables&lt;/strong&gt; colors!&lt;/em&gt; See &lt;code&gt;:help :syn-transparent&lt;/code&gt; for an explanation.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is useful for syntax items that don't need any highlighting but are used only to skip over a part of the text.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h3&gt;End result&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;No matter what highlighting you try to apply to &lt;code&gt;rubyLocalVariableOrMethod&lt;/code&gt;, it won't show up.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Where do I go from here?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;File a bug with the syntax maintainers, possibly with a patch that would fix it: you might&#xA;- remove &lt;code&gt;transparent&lt;/code&gt;, or&#xA;- add &lt;code&gt;puts&lt;/code&gt; and other special words to a different group that has highlighting&#xA;- something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, you could monkey-patch your own copy of vim, deleting the &lt;code&gt;transparent&lt;/code&gt; word and putting special highlighting in your vimrc. You'd need to do this with every update as well though, since your changes are liable to be blown away.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;em&gt;Notes&lt;/em&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The synstax code, as referenced above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! synstax#UnderCursor() abort&#xA;  let l:stack = synstax#Stack(line('.'), col('.'))&#xA;  if empty(l:stack)&#xA;    return &quot;No syntax highlight groups under cursor&quot;&#xA;  endif&#xA;  let l:names = synstax#Attributes(l:stack, 'name')&#xA;  return l:names&#xA;endfunction&#xA;&#xA;function! synstax#Stack(line, col) abort&#xA;  return synstack(a:line, a:col)&#xA;endfunction&#xA;&#xA;function! synstax#Attributes(stack, attr) abort&#xA;  let l:attr_func = printf('synIDattr(v:val, &quot;%s&quot;)', a:attr)&#xA;  return map(a:stack, l:attr_func)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-09-05T19:23:55.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17302" PostTypeId="1" AcceptedAnswerId="17304" CreationDate="2018-09-05T23:03:36.383" Score="11" ViewCount="1781" Body="&lt;p&gt;I have a very long vimrc mapping to deal with for example &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;space&amp;gt;e :exe &quot;!tmux send-keys -t.- 'cd $TEST' Enter&quot;&amp;lt;Cr&amp;gt; :exe &quot;!tmux send-keys -t.- 'source $TEST_NT/bin/activate' Enter&quot;&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;how can I break this long line into several short lines so that I can see everything in one screen&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like the following style: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; nnoremap &amp;lt;space&amp;gt;e &#xA;     :exe &quot;!tmux send-keys -t.- 'cd $TEST' Enter&quot;&amp;lt;Cr&amp;gt; &#xA;     :exe &quot;!tmux send-keys -t.- 'source $TEST_NT/bin/activate' Enter&quot;&amp;lt;Cr&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15958" LastActivityDate="2018-09-06T11:40:54.087" Title="How to break a long mapping line into several short lines in vimrc mapping" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17303" PostTypeId="1" AcceptedAnswerId="17311" CreationDate="2018-09-05T23:15:13.750" Score="1" ViewCount="73" Body="&lt;p&gt;I need to mapping some action only for the feature file (which end with .feature)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried &lt;code&gt;autocmd FileType feature nnoremap ....&lt;/code&gt; in the vimrc, but it won't work when I editing the feature file meanwhile I did the same action for tex file by &lt;code&gt;autocmd FileType tex nnoremap ....&lt;/code&gt; and everything is fine there. What's the issue out here? Vim has no idea what feature file is? &lt;/p&gt;&#xA;" OwnerUserId="15958" LastActivityDate="2018-09-06T16:32:29.647" Title="Does FileType only works when vim acctually knowns the type by default?" Tags="|vimrc|autocmd|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17304" PostTypeId="2" ParentId="17302" CreationDate="2018-09-06T06:40:49.233" Score="15" Body="&lt;p&gt;You can split your long line by inserting a Vim line continuation character (backslash) at the beginning of each continued line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;space&amp;gt;e &#xA;       \ :exe &quot;!tmux send-keys -t.- 'cd $TEST' Enter&quot;&amp;lt;Cr&amp;gt; &#xA;       \ :exe &quot;!tmux send-keys -t.- 'source $TEST_NT/bin/activate' Enter&quot;&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is explained here: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html#line-continuation&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help line-continuation&lt;/code&gt;&lt;/a&gt;.&#xA;You should note the comment on leading whitespace, i.e.:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;All leading whitespace characters in the line before a backslash are ignored.&lt;br&gt;&#xA;  &lt;strong&gt;Note&lt;/strong&gt; however that trailing whitespace in the line before it cannot be&#xA;  inserted freely; it depends on the position where a command is split up&#xA;  whether additional whitespace is allowed or not.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18342" LastEditorUserId="21" LastEditDate="2018-09-06T11:40:54.087" LastActivityDate="2018-09-06T11:40:54.087" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17306" PostTypeId="2" ParentId="17226" CreationDate="2018-09-06T07:49:35.453" Score="14" Body="&lt;p&gt;Thanks to Christian Brabandt, &lt;code&gt;:ter ++curwin&lt;/code&gt; was the thing that I want.&lt;/p&gt;&#xA;" OwnerUserId="18674" LastActivityDate="2018-09-06T07:49:35.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17307" PostTypeId="1" AcceptedAnswerId="17308" CreationDate="2018-09-06T09:36:57.353" Score="0" ViewCount="52" Body="&lt;p&gt;My copy of Vim has the &lt;code&gt;+clipboard&lt;/code&gt; feature compiled in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version | grep clipboard&#xA;+clipboard       +job             +path_extra      +user_commands&#xA;+eval            +mouse_dec       +statusline      +xterm_clipboard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to copy 1 and 2 lines into system clipboard with the command &lt;code&gt;1,2y&quot;+&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bey3T.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bey3T.png&quot; alt=&quot;An HTML file&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I check the &lt;code&gt;+&lt;/code&gt; register with &lt;code&gt;:reg +&lt;/code&gt;, I get the following output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZbRID.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZbRID.png&quot; alt=&quot;A random snippet of Vimscript&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why aren't the lines copied into my system register?&lt;/p&gt;&#xA;" OwnerUserId="5181" LastEditorUserId="343" LastEditDate="2018-09-06T13:56:17.597" LastActivityDate="2018-09-06T13:56:17.597" Title="Why aren't the lines copied into my system register?" Tags="|register|os-clipboard|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17308" PostTypeId="2" ParentId="17307" CreationDate="2018-09-06T09:54:30.513" Score="4" Body="&lt;p&gt;The problem is, &lt;code&gt;&quot;&lt;/code&gt; means start of a comment for :ex commands. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you actually want &lt;code&gt;:1,2y +&lt;/code&gt; as this is the correct syntax for the &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#:y&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:y&lt;/code&gt; command&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-09-06T09:54:30.513" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17309" PostTypeId="2" ParentId="17199" CreationDate="2018-09-06T14:58:05.377" Score="2" Body="&lt;p&gt;D.Ben Knoble has given a &lt;a href=&quot;https://vi.stackexchange.com/a/17301/343&quot;&gt;terrific explanation&lt;/a&gt; of exactly what happens in the default Ruby syntax configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I don't care for his two proposed solutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Complain to the Ruby syntax maintainers, &lt;/li&gt;&#xA;&lt;li&gt;Edit the Ruby syntax file in your local Vim installation, which may then be overwritten when you update Vim.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Vim offers two much simpler solutions:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;1. Define your own &lt;code&gt;keyword&lt;/code&gt; syntax items&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You can define syntax &lt;em&gt;keyword&lt;/em&gt; items (&lt;code&gt;:help :syn-keyword&lt;/code&gt;) for the strings you want to highlight. These will be used in preference to the existing &lt;code&gt;rubyLocalVariableOrMethod&lt;/code&gt; item because that is a lower-priority &lt;code&gt;match&lt;/code&gt; item. (See &lt;code&gt;:help :sy-priority&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;From your terminal, start editing a new file inside your &lt;code&gt;.vim&lt;/code&gt; directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ~/.vim/after/syntax&#xA;vim ~/.vim/after/syntax/ruby.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add the following contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax keyword Error puts&#xA;syntax keyword Error print&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These highlight the literal strings listed with the &lt;code&gt;Error&lt;/code&gt; highlight group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I picked this group simply because it's likely to show up in a bright colour in most colour schemes. You will probably want to pick a more appropriate group by viewing the output of the &lt;code&gt;:hi&lt;/code&gt; command.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;2. Override the existing syntax item&lt;/h1&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Same as before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ~/.vim/after/syntax&#xA;vim ~/.vim/after/syntax/ruby.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match rubyLocalVariableOrMethod &quot;\&amp;lt;[_[:lower:]][_[:alnum:]]*[?!=]\=&quot; contains=NONE display&#xA;highlight link rubyLocalVariableOrMethod Error&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Because the code in the &lt;code&gt;after/syntax&lt;/code&gt; directory runs &lt;em&gt;after&lt;/em&gt; Vim's standard syntax files, this overwrites the existing &lt;code&gt;rubyLocalVariableOrMethod&lt;/code&gt; syntax item replacing it with a copy of it that does not contain the &lt;code&gt;transparent&lt;/code&gt; argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second line then sets up a link to highlight the item with the existing &lt;code&gt;Error&lt;/code&gt; highlight colours. (&lt;code&gt;:help hi-link&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which of these solutions you decide to use will depend on your specific requirements.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-09-06T14:58:05.377" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17310" PostTypeId="1" AcceptedAnswerId="17314" CreationDate="2018-09-06T16:01:03.807" Score="2" ViewCount="157" Body="&lt;p&gt;I have installed vim-latex v1.10.0 on Fedora 28, using vim-plug:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'vim-latex/vim-latex'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've defined an insert mode abbreviation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:iab bd text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can trigger &lt;code&gt;bd&lt;/code&gt; to expand to &quot;text&quot; only with &lt;kbd&gt;Tab&lt;/kbd&gt; or &lt;kbd&gt;CR&lt;/kbd&gt; in a line of the type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rrrrr bd tttttt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in a tex buffer. Neither &lt;kbd&gt;Space&lt;/kbd&gt; nor punctuation characters work (but they work in an empty buffer). Why?&lt;/p&gt;&#xA;" OwnerUserId="18851" LastEditorUserId="343" LastEditDate="2018-09-06T16:27:11.187" LastActivityDate="2018-09-11T05:12:33.750" Title="vim-latex: sometimes abbreviations do not expand in tex buffers" Tags="|plugin-vim-latex|abbreviations|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ClosedDate="2018-09-11T05:08:51.210" ContentLicense="CC BY-SA 4.0" />
  <row Id="17311" PostTypeId="2" ParentId="17303" CreationDate="2018-09-06T16:32:29.647" Score="1" Body="&lt;p&gt;Vim determines the file type primarily by the set of rules in &lt;code&gt;$VIMRUNTIME/filetype.vim&lt;/code&gt;. The Vim 8.1.347 version of that file sets the filetype to &quot;cucumber&quot; for any file whose suffix is &quot;.feature&quot;. So, if your .feature files are associated with the Cucumber tool, then just change the file type argument of your FileType autocommand from &quot;feature&quot; to &quot;cucumber&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's not what you're doing, you can still have Vim automatically detect the file type, but it's a little more complicated. See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help new-filetype&#xA;:help filetype.txt&#xA;:help 43.2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2018-09-06T16:32:29.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17312" PostTypeId="1" AcceptedAnswerId="17313" CreationDate="2018-09-06T17:06:15.383" Score="1" ViewCount="435" Body="&lt;p&gt;Suppose, I have  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abcd&#xA;efgh&#xA;ijkl&#xA;mnop&#xA;qrst&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to delete the first 2 character of each even numbered line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abcd&#xA;gh&#xA;ijkl&#xA;op&#xA;qrst&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9498" LastEditorUserId="2347" LastEditDate="2018-09-07T23:08:09.897" LastActivityDate="2021-10-29T15:42:32.473" Title="How do I remove first 2 characters of each even numbered line?" Tags="|cut-copy-paste|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17313" PostTypeId="2" ParentId="17312" CreationDate="2018-09-06T17:34:07.320" Score="6" Body="&lt;p&gt;You can use &lt;code&gt;sed&lt;/code&gt; to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sed 'n;s/..//' file.txt &amp;gt; output.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or inside of Vim via:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!sed 'n;s/..//'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A native solution in Vim can be accomplished with a sub-replace-expression&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/../\=line('.')%2==0?'':submatch(0)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works by replacing the first 2 character each line with either itself for odd lines or nothing for even lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :range!&#xA;:h :s&#xA;:h sub-replace-expression&#xA;:h line()&#xA;:h submatch()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2018-09-06T17:34:07.320" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17314" PostTypeId="2" ParentId="17310" CreationDate="2018-09-06T21:58:35.680" Score="0" Body="&lt;p&gt;This is indeed a bug in vim-latex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I filed &lt;a href=&quot;https://github.com/vim-latex/vim-latex/issues/141&quot; rel=&quot;nofollow noreferrer&quot;&gt;Issue #141&lt;/a&gt; at GitHub to report the issue, and prepared &lt;a href=&quot;https://github.com/vim-latex/vim-latex/pull/142&quot; rel=&quot;nofollow noreferrer&quot;&gt;PR #142&lt;/a&gt; with a possible fix.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: The PR has been accepted upstream, so you might be able to get it fixed by updating your local plug-in, with a command such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PlugUpdate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(And you might need to restart vim afterwards.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be nice if you could confirm this does indeed fix your issue.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2018-09-07T17:19:10.107" LastActivityDate="2018-09-07T17:19:10.107" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17315" PostTypeId="2" ParentId="17312" CreationDate="2018-09-07T02:54:51.230" Score="2" Body="&lt;p&gt;You can record a recursive macro and run it from the start of the file as macros&#xA;stop when some action cannot be performed. In this case, it would be something&#xA;like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;qqqqqj$xxj@qq@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Edit: Should use ^ instead of $ to delete from the start of line.&lt;/p&gt;&#xA;&lt;p&gt;Now, by parts:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;qqq   -  Start and immediately end recording of register &amp;quot;q&amp;quot;. This is only&#xA;         needed in recursive macros.&#xA;&#xA;qq    -  Start recording in register q&#xA;&#xA;j$xxj -  One line down, end of line, delete two characters and down again&#xA;&#xA;@q    -  Run the contents of the macro @q (empty for now)&#xA;&#xA;q     -  End recording of macro&#xA;&#xA;@q    -  Run the contents of @q (not empty anymore)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18087" LastEditorUserId="18087" LastEditDate="2021-10-29T15:42:32.473" LastActivityDate="2021-10-29T15:42:32.473" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17316" PostTypeId="2" ParentId="17312" CreationDate="2018-09-07T04:21:06.857" Score="3" Body="&lt;p&gt;Another native Vim command line solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^../ if line(&quot;.&quot;) % 2 == 0 | s///&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pretty straightforward. The &lt;code&gt;g&lt;/code&gt;lobal command takes us to every line in the file that has at least two characters. Check modulo 2 of the current line number returned by &lt;code&gt;line(&quot;.&quot;)&lt;/code&gt; and if it indicates an even line then substitute nothing for the first two characters. We don't have to specify a pattern with the substitution command as it defaults to the last search term, i.e. &lt;code&gt;^..&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you like compact this version is nice and short...about 10 chars shorter than the other native c/l solution posted here. ;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^../if line(&quot;.&quot;)%2==0|s///&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-09-07T04:31:16.930" LastActivityDate="2018-09-07T04:31:16.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17317" PostTypeId="2" ParentId="17296" CreationDate="2018-09-07T04:43:17.317" Score="10" Body="&lt;p&gt;To send to another pane you'll need to call &lt;em&gt;tmux&lt;/em&gt; from Vim. Specifically, you'll need the &lt;code&gt;send-keys&lt;/code&gt; command (alias: &lt;code&gt;send&lt;/code&gt;). For example, this will cause the current line number in Vim to be printed to the terminal in pane 2 using &lt;code&gt;echo&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:exe &amp;quot;!tmux send -t 2 'echo &amp;quot; . line(&amp;quot;.&amp;quot;) . &amp;quot;' Enter&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Applying the same form to your command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:exe &amp;quot;!tmux send -t 2 'behave features/target.feature:&amp;quot; . line(&amp;quot;.&amp;quot;) . &amp;quot; -k' Enter&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A few notes on &lt;code&gt;-t&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;-t&lt;/code&gt; flag, in its simplest form, takes the target pane index as argument.&lt;/li&gt;&#xA;&lt;li&gt;Since you are sending your command to another pane in the same window that's the only form we need to know.&lt;/li&gt;&#xA;&lt;li&gt;You can display pane indexes in the current window with &lt;em&gt;tmux-prefix&lt;/em&gt; + &lt;code&gt;q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;FYI, that spelled-out &lt;code&gt;Enter&lt;/code&gt; at the end of the command tells &lt;em&gt;tmux&lt;/em&gt; to emit an actual carriage return at that point...submitting the command to the shell for execution, in these examples.&lt;/p&gt;&#xA;&lt;p&gt;If you want to put this in a mapping the RHS is simply the full command from above followed by &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;. So...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:MAPCMD LHS :exe &amp;quot;!tmux send -t 2 'behave features/target.feature:&amp;quot; . line(&amp;quot;.&amp;quot;) . &amp;quot; -k' Enter&amp;quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;(I like to follow the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; with &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; to eliminate the need to hit Enter when the command is done.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update - What if the pane was moved?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;@JDG asked, &lt;em&gt;How [do I send] a command to a particular pane, despite the fact that the pane may have changed position and thus has a different index?&lt;/em&gt; It's a good question so I'm relocating my reply here...&lt;/p&gt;&#xA;&lt;p&gt;I would suggest you use the pane ID rather than the index.&lt;/p&gt;&#xA;&lt;p&gt;Every tmux pane is assigned both an &amp;quot;index&amp;quot; and an &amp;quot;ID&amp;quot;. The former can change if the pane is moved but the latter is fixed for the life of the pane. In addition to accepting an index, &lt;code&gt;-t&lt;/code&gt; also accepts an ID. You just need to prepend &lt;code&gt;%&lt;/code&gt; to indicate this. Example: &lt;code&gt;tmux send -t %8 ...&lt;/code&gt;. Consult &lt;code&gt;man tmux&lt;/code&gt; to learn how to get a pane's ID.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2024-04-03T23:12:51.697" LastActivityDate="2024-04-03T23:12:51.697" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17320" PostTypeId="2" ParentId="17312" CreationDate="2018-09-07T22:28:29.883" Score="0" Body="&lt;p&gt;My suggestion&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/./if line('.') % 2 == 0 | normal! xx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2018-09-07T22:28:29.883" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17321" PostTypeId="1" CreationDate="2018-09-07T23:23:54.180" Score="2" ViewCount="316" Body="&lt;p&gt;As a test, I have created a one line &lt;code&gt;.vimrc&lt;/code&gt; file and have an empty &lt;code&gt;.vim/&lt;/code&gt; directory. The &lt;code&gt;.vimrc&lt;/code&gt; file is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;fed :e ~/vimrc.test&amp;lt;CR&amp;gt; | echom &quot;opening vimrc . . .&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On &lt;code&gt;vim&lt;/code&gt; startup, it displays the &lt;code&gt;opening vimrc&lt;/code&gt; text, then waits for input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this expected behavior?&lt;/p&gt;&#xA;" OwnerUserId="18899" LastEditorDisplayName="user579" LastEditDate="2018-09-12T06:48:32.367" LastActivityDate="2018-09-12T06:48:32.367" Title="Why does placing echom in vimrc as part of a mapping cause it to echo on load?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17322" PostTypeId="2" ParentId="17321" CreationDate="2018-09-07T23:46:05.807" Score="2" Body="&lt;p&gt;You need a backslash before your pipe &lt;code&gt;\|&lt;/code&gt; in order for it all to be considered part of the &lt;code&gt;nnoremap&lt;/code&gt; command. Also, you'll want to add a colon before &lt;code&gt;echom&lt;/code&gt; and add another &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; at the end. Try:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;fed :e ~/vimrc.test&amp;lt;CR&amp;gt;\|:echom &quot;opening vimrc . . .&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10196" LastEditorUserId="10196" LastEditDate="2018-09-08T04:31:26.440" LastActivityDate="2018-09-08T04:31:26.440" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17323" PostTypeId="1" AcceptedAnswerId="17326" CreationDate="2018-09-08T10:18:08.853" Score="3" ViewCount="8193" Body="&lt;p&gt;Since Vim and NeoVIM defaults to UTF-8, does it make any sense to specify the same option explicitly in vimrc? set encoding=&quot;utf-8&quot;&lt;/p&gt;&#xA;" OwnerUserId="18231" LastActivityDate="2018-09-08T22:38:37.373" Title="Specify UTF-8 encoding in Vimrc" Tags="|encoding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17324" PostTypeId="1" CreationDate="2018-09-08T15:39:41.383" Score="0" ViewCount="220" Body="&lt;p&gt;I am using TI compiler and when I build and errors appear in quick fix, they are not identified.  The errors look like this &lt;strong&gt;in terminal&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;/home/sporty/HydroGuardFW/hw_2_0/hg_os/coap_resources/system_session.h&quot;, line 79: error #136: class &quot;Sessions&quot; has no member &quot;session_success&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is how it looks in &lt;strong&gt;VIM&lt;/strong&gt;, its the second line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|| &quot;/home/sporty/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430&quot; -vmspx --data_model=large --near_data=none -O2 --opt_for_speed=1 --use_hw_mpy=F5 --include_path=&quot;/home/sporty/ti/ccsv8/ccs_base/msp430/include&quot; --include_path=&quot;/home/sporty/HydroGuardFW/hw_2_0/hg_os&quot; --include_path=&quot;/home/sporty/HydroGuardFW/hw_2_0&quot; --include_path=&quot;/home/sporty/HydroGuardFW/hw_2_0&quot; --include_path=&quot;/home/sporty/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include&quot; --define=__MSP430F5359__ --define=HYDRO_GUARD --define=NDEBUG -g --symdebug:dwarf_version=4 --c++14 --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --preproc_with_compile --preproc_dependency=&quot;hg_os/cli/commands.d_raw&quot; --obj_directory=&quot;hg_os/cli&quot;  &quot;../hg_os/cli/commands.cpp&quot;&#xA;|| &quot;/home/sporty/HydroGuardFW/hw_2_0/hg_os/coap_resources/system_session.h&quot;, line 79: error #136: class &quot;Sessions&quot; has no member &quot;session_success&quot;&#xA;|| &quot;../hg_os/cli/commands.cpp&quot;, line 195: error #136: class &quot;Modem&quot; has no member &quot;session_success&quot;&#xA;|| &quot;../hg_os/cli/commands.cpp&quot;, line 201: error #141: too many arguments in function call&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried using the following &lt;em&gt;errorformat&lt;/em&gt; configruation&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set errorformat=\&quot;%f\&quot;\\,\ line\ %l:\ %m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3050" LastActivityDate="2018-09-08T15:39:41.383" Title="Errors are not identified in quickfix window" Tags="|errorformat|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17326" PostTypeId="2" ParentId="17323" CreationDate="2018-09-08T22:38:37.373" Score="6" Body="&lt;p&gt;It would be &lt;code&gt;set encoding=utf-8&lt;/code&gt;, no quotes.  &lt;code&gt;set encoding=&quot;utf-8&quot;&lt;/code&gt; would be an error because &lt;code&gt;&quot;utf-8&quot;&lt;/code&gt; would be considered a comment, thus it would be the same as &lt;code&gt;set encoding=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Vim does not actually default &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27encoding%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'encoding'&lt;/code&gt;&lt;/a&gt; to UTF-8.  It defaults to latin1, but will change based on the locale of your environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, since changing &lt;code&gt;'encoding'&lt;/code&gt; at runtime is dangerous (as in, it can cause a crash -- see below), Neovim decided to &lt;em&gt;only&lt;/em&gt; support &lt;code&gt;encoding=utf-8&lt;/code&gt;.  This vastly simplifies the code, since now everything is working with UTF-8 internally, and only has to encode/decode when interfacing with the outside world (saving files in specific encodings, converting input from the locale's encoding, etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMHO, it's a good idea to always put &lt;code&gt;set encoding=utf-8&lt;/code&gt; in your vimrc.  It automatically enables saner encoding detection settings for &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#&amp;#39;fileencodings&amp;#39;&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'fileencodings'&lt;/code&gt;&lt;/a&gt; and supports any characters that you'll need to store.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The crash example I gave in 2009 when I &lt;a href=&quot;https://groups.google.com/d/msg/vim_dev/up1KslPRGzk/9xwHeIb6WWgJ&quot; rel=&quot;noreferrer&quot;&gt;suggested&lt;/a&gt; changing Vim's default value for &lt;code&gt;'encoding'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE --cmd 'set enc=utf8 list' -c 'let &amp;amp;lcs=&quot;nbsp:&quot;.nr2char(&quot;8215&quot;)'&#xA;:put =nr2char(&quot;160&quot;)&#xA;:set enc=latin1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2018-09-08T22:38:37.373" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17327" PostTypeId="1" AcceptedAnswerId="17328" CreationDate="2018-09-10T06:11:47.957" Score="1" ViewCount="340" Body="&lt;p&gt;I want to retrieve a &lt;code&gt;t:varible&lt;/code&gt; for a different tabpage that is not the current tabpage. How can I do it &lt;strong&gt;without switching to that tabpage&lt;/strong&gt;? I know its &lt;code&gt;tabpagenr&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about window local variables &lt;code&gt;w:&lt;/code&gt; and buffer local ones &lt;code&gt;b:&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-09-10T06:43:54.330" Title="Is there a way to get a tab-local variable for a tabpage that is not currently activated" Tags="|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17328" PostTypeId="2" ParentId="17327" CreationDate="2018-09-10T06:43:54.330" Score="3" Body="&lt;p&gt;Just realize there are &lt;code&gt;getwinvar()&lt;/code&gt;, &lt;code&gt;getbufvar()&lt;/code&gt;, &lt;code&gt;gettabvar()&lt;/code&gt; etc.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-09-10T06:43:54.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17329" PostTypeId="1" AcceptedAnswerId="17338" CreationDate="2018-09-10T09:54:29.983" Score="4" ViewCount="1852" Body="&lt;p&gt;What is the best way to indent multiple lines in insert mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I have currently:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;Tab&amp;gt; &amp;gt;&#xA;vmap &amp;lt;S-Tab&amp;gt; &amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that it doesn't properly handle selection area: the selection will shrink on each Tab press (Shift-Tab to unindent doesn't have any problems).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;Tab&amp;gt; &amp;gt;&amp;lt;C-O&amp;gt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work for some reason. (Why?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(To answer your questions: yes, I need to implement indenting in insert mode. I understand, it's against Vim way, but I'm trying to configure Vim for non-IT person, and therefore it will be used with &lt;code&gt;-y&lt;/code&gt; flag, i.e. any modes except &quot;insert&quot; will not be available).&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="2920" LastEditDate="2018-09-10T21:21:22.553" LastActivityDate="2018-09-10T21:26:41.557" Title="Keep the full visual selection after indenting in easy mode vim" Tags="|vimrc|indentation|multiple-lines|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17330" PostTypeId="1" AcceptedAnswerId="17334" CreationDate="2018-09-10T10:47:35.267" Score="1" ViewCount="337" Body="&lt;p&gt;I am pretty new to vim and hence trying to learn some of its powerful features and ofcourse top of the list is macros.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So i am trying to create a pattern like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;tag&amp;gt;var 1&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 2&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 3&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 4&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 5&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 6&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 7&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 8&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 9&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 10&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 11&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 12&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 13&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 14&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 15&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 16&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 17&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 18&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 19&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 20&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 21&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 22&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 23&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 24&amp;lt;/tag&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So i created the 1st line manually and then created a macro to do the rest, and i was able to do so, the problem is pressing &lt;code&gt;@@&lt;/code&gt; just creates one line and if i have hold down the &lt;code&gt;@&lt;/code&gt; to keep on creating new lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this is a little different problem because usually with macros we edit something in a line and then repeat it across multiple &lt;strong&gt;&lt;em&gt;existing&lt;/em&gt;&lt;/strong&gt; lines like &lt;code&gt;n@&amp;lt;reg&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However in my case the file is empty and i am creating new lines, so how can i do this. This is what the contents of the register looks like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;q   yypfr2l&amp;lt;80&amp;gt;&amp;lt;fc&amp;gt;^Haghj&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well what i did was &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First yank the current line&lt;/li&gt;&#xA;&lt;li&gt;Paste it below&lt;/li&gt;&#xA;&lt;li&gt;Jump to next &lt;code&gt;r&lt;/code&gt; which is in &lt;code&gt;var&lt;/code&gt; and then move 2 characters left which puts me at the number i want to change&lt;/li&gt;&#xA;&lt;li&gt;Increment the number by 1&lt;/li&gt;&#xA;&lt;li&gt;Move to beginning of the line and then go down&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So can i repeat this macro so that i can use it like &lt;code&gt;10@q&lt;/code&gt; and so on. Please if i need to change my macro to meet the needs.&lt;/p&gt;&#xA;" OwnerUserId="18373" LastEditorUserId="18373" LastEditDate="2018-09-10T14:47:32.650" LastActivityDate="2018-09-10T16:09:44.997" Title="Repeating a macro to create lines of text" Tags="|vimscript|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17331" PostTypeId="1" AcceptedAnswerId="17332" CreationDate="2018-09-10T13:42:54.010" Score="2" ViewCount="308" Body="&lt;p&gt;&lt;code&gt;vim&lt;/code&gt; provides a nice way to complete the Ex commands, which uses the &lt;code&gt;-complete=custom,Func&lt;/code&gt; or &lt;code&gt;complete=customlist,Func&lt;/code&gt;. It also provides many predefined completion methods such as &lt;code&gt;-complete=dir&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is is it possible to reuse these predefined completion methods in a user defined complete method? For example, I want to first extract the list of possible command and suffix them with a user defined string &lt;code&gt;suffix&lt;/code&gt;. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=1 -complete=customlist,UserComplete CreateGitFile&#xA;function! UserComplete(ArgLead, CmdLine, CursorPos)&#xA;    let list = GetCompletionListFor_Dir()   &quot; &amp;lt;--- what to do here&#xA;    let list1 = map(copy(list), 'v:val . &quot;/.gitignore&quot;')&#xA;    let list2 = map(copy(list), 'v:val . &quot;/.gitconfig&quot;')&#xA;    return list1 + list2&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="51" LastEditDate="2018-09-20T17:45:04.130" LastActivityDate="2018-09-20T17:45:04.130" Title="customize Ex command completion" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17332" PostTypeId="2" ParentId="17331" CreationDate="2018-09-10T14:19:29.307" Score="3" Body="&lt;p&gt;Try &lt;code&gt;getcompletion()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo getcompletion('*', 'dir')&#xA;                     │    │&#xA;                     │    └ looking for completion of directories&#xA;                     │&#xA;                     └ no filtering&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Used in your code, it would give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=1 -complete=customlist,UserComplete CreateGitFile&#xA;function! UserComplete(ArgLead, CmdLine, CursorPos)&#xA;    let list = getcompletion('*', 'dir')&#xA;    let list1 = map(copy(list), 'v:val . &quot;/.gitignore&quot;')&#xA;    let list2 = map(copy(list), 'v:val . &quot;/.gitconfig&quot;')&#xA;    return list1 + list2&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h getcompletion()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;More generally, when you're looking for a built-in function, whose exact name you don't know yet, have a look at &lt;code&gt;:h function-list&lt;/code&gt;.&lt;br&gt;&#xA;Or, on the command-line, use wildcards surrounding a relevant keyword.&lt;br&gt;&#xA;For example, in your issue, you're looking for a function which gives completion candidates, so it should probably contain  &lt;code&gt;compl&lt;/code&gt;.&lt;br&gt;&#xA;In this case, type this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h *compl*()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But don't execute it, press &lt;code&gt;C-d&lt;/code&gt; instead of &lt;code&gt;Enter&lt;/code&gt; so that Vim lists all functions whose name contains &lt;code&gt;compl&lt;/code&gt;.&#xA;It should give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h *compl*()&#xA;complete()        complete_add()    getcompletion()   complete_check()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From there, you only have 4 functions to check in the help.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-09-10T14:34:10.563" LastActivityDate="2018-09-10T14:34:10.563" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17333" PostTypeId="2" ParentId="17330" CreationDate="2018-09-10T15:51:14.257" Score="2" Body="&lt;p&gt;I think your macro is not quite correct. If you look at the output of your recorded output it looks a bit strange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I tried to do what you wanted and started with a single line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;tag&amp;gt;var 1&amp;lt;/tag&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I recorded the macro like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;qqyypf l^A0&lt;/code&gt; (e.g. start recording into register &lt;code&gt;q&lt;/code&gt;, duplicate the current line &lt;code&gt;yy&lt;/code&gt;, paste &lt;code&gt;p&lt;/code&gt;, go one character after the space &lt;code&gt;f l&lt;/code&gt;, increment, &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;A&lt;/kbd&gt;, go to start of line &lt;code&gt;0&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I replayed the whole thing 10 times. The result was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;tag&amp;gt;var 1&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 2&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 3&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 4&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 5&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 6&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 7&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 8&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 9&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 10&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 11&amp;lt;/tag&amp;gt;&#xA;&amp;lt;tag&amp;gt;var 12&amp;lt;/tag&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So everything as expected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the following part in your mapping suspicious:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;80&amp;gt;&amp;lt;fc&amp;gt;^H&lt;/code&gt; that is most likely a (special) key pressed (since those begin with &amp;lt;80&gt;) and corrected by using a backspace. &lt;/li&gt;&#xA;&lt;li&gt;aghj (pressing a, then &lt;code&gt;gh&lt;/code&gt; which starts select mode, and then j does not seem to make much sense)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;BTW: you can simply initialize your macro register (in this case q) by using e.g. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @q=&quot;yypf l\&amp;lt;C-A&amp;gt;0&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so you don't have to re-record it, if you made a mistake. By similar means, you can correct your register:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:let @q=&quot;&lt;/code&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;R&lt;/kbd&gt;&lt;code&gt;q&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which meams, enter the content of the Q register after the &lt;code&gt;=&lt;/code&gt; by using &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; on the commandline (see also the &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;help c_CTRL-R&lt;/a&gt;). Then you can move the cursor and correct any wrong key.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-09-10T15:51:14.257" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17334" PostTypeId="2" ParentId="17330" CreationDate="2018-09-10T15:59:49.190" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/17333/343&quot;&gt;Christian's answer&lt;/a&gt; is of course correct, but I can also explain why your macro won't work without actually looking at the register contents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In step 5, you move down. If there is no blank line at the end of the file, you cannot move the cursor down, so the macro will fail at this point and playback will stop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there &lt;em&gt;is&lt;/em&gt; a blank line to move down into, then when you play back the macro, you start by yanking and pasting an empty line. Then you do &lt;code&gt;fr&lt;/code&gt;, which will fail, because there is no &lt;code&gt;r&lt;/code&gt; to jump to, and the macro playback will stop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can fix the macro simply by removing step 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll note also that step 3 is unnecessary, because the increment command &lt;kbd&gt;Ctrl-A&lt;/kbd&gt; jumps to the first number after the cursor (on the line) before it increments.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-09-10T16:09:44.997" LastActivityDate="2018-09-10T16:09:44.997" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17335" PostTypeId="2" ParentId="17330" CreationDate="2018-09-10T16:07:54.683" Score="1" Body="&lt;p&gt;You can also achieve this goal without a macro by using &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;Ctrl-A&lt;/kbd&gt; (See &lt;code&gt;:help v_g_CTRL-A&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;Shift-V&lt;/kbd&gt;&lt;kbd&gt;G&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;Ctrl-A&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This yanks the line, pastes 23 copies, visually selects to the end of the file, and then increments the numbers in the way you desire.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-09-10T16:07:54.683" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17337" PostTypeId="2" ParentId="17329" CreationDate="2018-09-10T21:21:18.820" Score="3" Body="&lt;p&gt;You want to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;tab&amp;gt; &amp;gt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this not-quite-Vim mode, a vmap'ed key briefly puts you in normal mode before returning you to insert mode.  The &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; part of your map was performing the normal mode version of that command (jump list navigation).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I understand, it's against Vim way, but I'm trying to configure Vim for non-IT person, and therefore it will be used with -y flag, i.e. any modes except &quot;insert&quot; will not be available.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I totally sympathize with you if you're trying to make it possible for a non-technical person to edit text in a terminal.  In this regard, all I can offer you is years of my own experience with this particular scenario: just tell them to use &lt;code&gt;nano&lt;/code&gt;.  If you want them to learn Vim, let them learn Vim.  Don't hinder them from the very beginning by making it &quot;not Vim&quot;.  At least with &lt;code&gt;nano&lt;/code&gt;, things are &lt;em&gt;actually simple&lt;/em&gt;, not an illusion of simplicity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim is a modal editor by design and it's very difficult to get it to act like a reliable modeless editor.  The &lt;code&gt;-y&lt;/code&gt; option seems like a nice compromise for people who aren't used to Vim, but I can't imagine it being a good way to teach the benefits of modal editing.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;To clarify for anyone that's confused:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim's &lt;code&gt;-y&lt;/code&gt; flag will cause Vim to always be in insert mode like a modeless editor, which is why &quot;insert mode&quot; is mentioned.  Mouse selection or shift+arrows puts the buffer in visual mode.  Pressing keys that aren't in a vmap in visual mode clears the selected text, replaces it with the keys that were pressed, and returns to insert mode.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2018-09-10T21:21:18.820" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17338" PostTypeId="2" ParentId="17329" CreationDate="2018-09-10T21:26:41.557" Score="5" Body="&lt;p&gt;Think of it like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaaa&#xA;bbbb&#xA;cccc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you select these 3 lines, then each line has 4 characters selected. Now, you indent them and use &lt;code&gt;gv&lt;/code&gt; to reselect the whole thing. Here is the new text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;tab&amp;gt;aaaa&#xA;&amp;lt;tab&amp;gt;bbbb&#xA;&amp;lt;tab&amp;gt;cccc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which selection does vim see you used to have? 3 lines, each with 4 characters (including the tab). So vim selects that, and you lose the last &quot;c&quot; on the third line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That should be what's causing this. Here's how to fix it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;tab&amp;gt; &amp;gt;gvV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gv&lt;/code&gt; tells vim to reselect that last visual selection, but causes this &quot;&lt;em&gt;shrinking&lt;/em&gt;&quot; behavior. Using &lt;code&gt;V&lt;/code&gt; while in visual mode will switch you over to linewise visual mode, where entire lines are selected rather than individual characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this will slightly change your selection if you have partial lines selected, but since indenting is really a linewise operation in concept, I don't think that's necessarily a bad thing. If you'd really like to keep the exact same characters selected and not go to linewise mode, this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;tab&amp;gt; &amp;gt;gvolloll&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-09-10T21:26:41.557" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17339" PostTypeId="1" AcceptedAnswerId="17340" CreationDate="2018-09-10T21:36:51.477" Score="4" ViewCount="691" Body="&lt;p&gt;I tried the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:abb sm Summary:\n&#xA;:abb sm Summary:\\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it didn't work, nothing escaped, I ended up with the long form instead of a break.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do that from &lt;code&gt;ex&lt;/code&gt; mode? Is it something with one of those &lt;kbd&gt;^M&lt;/kbd&gt; characters? I can't remember how to do that.&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorDisplayName="user579" LastEditDate="2018-09-12T06:43:40.500" LastActivityDate="2018-09-12T06:44:59.060" Title="How to put a new line character in an abbreviation?" Tags="|abbreviations|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17340" PostTypeId="2" ParentId="17339" CreationDate="2018-09-10T21:41:13.250" Score="7" Body="&lt;p&gt;Use &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; instead of &lt;code&gt;\n&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev sm Summary&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You use generally use key notation in these cases, something you can find out more about by entering &lt;code&gt;:h key-notation&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorDisplayName="user579" LastEditDate="2018-09-12T06:44:59.060" LastActivityDate="2018-09-12T06:44:59.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17341" PostTypeId="6" CreationDate="2018-09-10T22:30:46.247" Score="0" Body="&lt;p&gt;My name is ILikeTurtles and I would like to nominate myself for the Vi and Vim moderator position because I would bring a positive attitude to the table and work towards improving the community. I feel that my professionalism and respect for others could bring people joy and I care about how this sub functions because I have a passion for Vim and Vi. A moderator is worthless without a community and my only goal is to support you all in making Vi and Vim the best exchange it could be by supporting you all with all the tools afforded me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vote! For knowledge! For community! For ILikeTurtles!&lt;/p&gt;&#xA;" OwnerUserId="1417" LastEditorUserId="1417" LastEditDate="2018-09-10T22:30:46.247" LastActivityDate="2018-09-10T22:30:46.247" CommentCount="6" CommunityOwnedDate="2018-09-10T22:30:46.247" ContentLicense="CC BY-SA 4.0" />
  <row Id="17342" PostTypeId="6" CreationDate="2018-09-11T01:29:10.027" Score="0" Body="&lt;p&gt;Hey there, my moniker is &lt;code&gt;paxdiablo&lt;/code&gt; and, while &lt;em&gt;far&lt;/em&gt; more prolific over on SO, I think I can make a decent contribution here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that the &lt;em&gt;total&lt;/em&gt; number of questions here since conception is about the same number that show up in the first hour each Monday over at SO, the workload here will be a little more manageable for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd expect to be able to spend about an hour each day, more on the weekends, and believe this will allow me to put my skills, such as they are, to good use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I won't bore you with campaign promises; if you really want to get a feel of my suitability, start by having a look at the questions and answers here, then head on over to SO and do likewise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've always tried to be open to other people's viewpoints (as long as they're reasonable, of course&lt;sup&gt;(a)&lt;/sup&gt;) and intend, if accepted, to be as fair as possible. As the guidelines state, moderators are meant to be the exception handlers of the community so, mostly, I'll expect I'll be monitoring flagged posts and acting on them appropriately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Feel free to ask any questions you wish, I'll endeavour to answer them to your satisfaction.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;(a)&lt;/sup&gt; Often they're not :-)&lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastEditorDisplayName="user579" LastEditDate="2018-09-11T07:54:14.923" LastActivityDate="2018-09-11T07:54:14.923" CommentCount="4" CommunityOwnedDate="2018-09-11T01:29:10.027" ContentLicense="CC BY-SA 4.0" />
  <row Id="17343" PostTypeId="6" CreationDate="2018-09-11T06:39:33.143" Score="0" Body="&lt;p&gt;I'm Caleb. I have used vi based editors in nearly all their flavors for everything (this nomination being composed in Neovim-GTK via GhostText) for 25+ years. My beard is only flecked with grey and my wife makes me trim it short, but when it comes to editor habits I'm a classic Unix grey-beard. My &lt;a href=&quot;https://github.com/alerque/que-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;RC files&lt;/a&gt; are available for review.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for moderation experience, I started out as a pro-tem then was elected as a moderator on &lt;a href=&quot;https://christianity.meta.stackexchange.com/users/30/caleb&quot;&gt;Christianity&lt;/a&gt; and am also a pro-tem on &lt;a href=&quot;https://hermeneutics.meta.stackexchange.com/users/36/caleb&quot;&gt;Hermeneutics&lt;/a&gt;. My history on those sites should speak to how I deal with conflict and contribute to the inner workings of SE sites.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not been particularly active on this site but I have been consistent with moderator duties through the years on other sites even during seasons when I didn't have time to contribute content. I think I'll be able to handle contributing to moderation needs here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will be traveling internationally and unreachable during this election cycle, but I will be back. If you'd like to have me on the other end of your flags then I'm game!&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="267" LastEditDate="2018-09-11T06:39:33.143" LastActivityDate="2018-09-11T06:39:33.143" CommentCount="3" CommunityOwnedDate="2018-09-11T06:39:33.143" ContentLicense="CC BY-SA 4.0" />
  <row Id="17344" PostTypeId="1" CreationDate="2018-09-11T08:35:59.917" Score="0" ViewCount="128" Body="&lt;p&gt;Is there a way to format numbers as per a precision format in Vi?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a log file with a huge list of hexadecimal numbers, I would like to&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;remove the '0x' prefix; then&lt;/li&gt;&#xA;&lt;li&gt;make the numbers show up with 8 digit precision (32-bit hex).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x12345678 =&amp;gt; 12345678&#xA;0xABCDF    =&amp;gt; 000ABCDF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need to add those preceding zeros since the output is then used by a diff tool and secondary scripts.&lt;/p&gt;&#xA;" OwnerUserId="11253" LastEditorDisplayName="user579" LastEditDate="2018-09-12T06:41:38.953" LastActivityDate="2018-09-12T08:02:34.763" Title="Precision format in Vi" Tags="|regular-expression|number-formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17345" PostTypeId="1" CreationDate="2018-09-11T08:38:06.367" Score="3" ViewCount="68" Body="&lt;p&gt;I'd like to have rich syntax highlighting (using, say, markdown syntax) inside (single-line) comments (as is done in Rust). For now, I'm using the following code, which is not satisfactory.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn include @markdown syntax/markdown.vim&#xA;syn region Comment start=&quot;///&quot; end=&quot;$&quot; contains=@markdown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does handle syntax such as the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/// Comment with **bold** inside.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first problem is that some markdown syntax (e.g., headings) match the beginning of line, so I would need to match markdown syntax after having removed the comment mark &lt;code&gt;///&lt;/code&gt; (and a single following space). Otherwise, comments such as the following are not highlighted as desired.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/// # Markdown heading (i.e., HTML h1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second, markdown syntax may span multiple lines, as in the case of titles. And separate comments lead to the contents being parsed separately.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a title&#xA;===============&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a simple way to do what I want?&lt;/p&gt;&#xA;" OwnerUserId="18928" LastActivityDate="2018-09-11T08:38:06.367" Title="Syntax highlighting in consecutive single-line comments" Tags="|syntax-highlighting|include|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17346" PostTypeId="1" CreationDate="2018-09-11T08:50:40.147" Score="6" ViewCount="96" Body="&lt;p&gt;Whenever I have to edit Perl Mason files, I always have problems indenting lines due to Perl code starting with &lt;code&gt;%&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;    &amp;lt;div&amp;gt;&#xA;%       if( !$something ) {&#xA;            &amp;lt;strong&amp;gt;&amp;lt;% $title %&amp;gt;&amp;lt;/strong&amp;gt;&#xA;%       }&#xA;    &amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea how I can tell Vim to ignore the &lt;code&gt;%&lt;/code&gt; at the beginning of the line and indent like it wasn't there?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/aming/vim-mason&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/aming/vim-mason&lt;/a&gt; to support the mixed Perl/HTLM syntax, but I don't think it changes anything.&lt;/p&gt;&#xA;" OwnerUserId="18933" LastEditorUserId="18933" LastEditDate="2018-09-11T11:10:59.733" LastActivityDate="2018-09-11T11:10:59.733" Title="Make Vim ignore first character in line while indenting" Tags="|indentation|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17347" PostTypeId="1" CreationDate="2018-09-11T09:25:32.837" Score="1" ViewCount="211" Body="&lt;p&gt;I have installed &lt;code&gt;vim-latex v1.10.0&lt;/code&gt; on &lt;code&gt;Fedora 28&lt;/code&gt;, using &lt;code&gt;vim-plug&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'vim-latex/vim-latex'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;F9&lt;/kbd&gt; does not work with &lt;code&gt;\cite{&lt;/code&gt;. It works with &lt;code&gt;\ref{&lt;/code&gt;,  but &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt; cycle through the results of the last search command.&lt;/p&gt;&#xA;" OwnerUserId="18851" LastEditorDisplayName="user579" LastEditDate="2018-09-12T06:34:21.803" LastActivityDate="2021-11-25T13:04:45.437" Title="How can I make F9 with vim-latex work with &quot;\cite{&quot;?" Tags="|plugin-vim-latex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17348" PostTypeId="2" ParentId="17347" CreationDate="2018-09-11T12:11:29.547" Score="1" Body="&lt;p&gt;I found the solution: &lt;code&gt;:h cite&lt;/code&gt; gives&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;By disabling the setting Tex_UseCiteCompletionVer2 [ls_a_dA],&#xA;  Latex-Suite will also look for .bbl files (if no .bib file is found) or a&#xA;  \begin{thebibliography} environment. However, a filtering of the results&#xA;  (as described above) will not be available.&quot;  (latex-suite.txt)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This was exactly my case, since I used &lt;code&gt;\begin{thebibliography}&lt;/code&gt;. Thus the solution was to add the line &lt;code&gt;let Tex_UseCiteCompletionVer2=0&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18851" LastEditorUserId="21" LastEditDate="2018-09-12T06:28:57.177" LastActivityDate="2018-09-12T06:28:57.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17349" PostTypeId="1" AcceptedAnswerId="17350" CreationDate="2018-09-11T14:24:07.953" Score="1" ViewCount="926" Body="&lt;p&gt;I'm editing pandoc markdown text with inline math. Since that uses underscores, vim will helpfully highlight everything after the first underscore, but there will be no matching one. &#xA;&lt;a href=&quot;https://i.stack.imgur.com/HPHlC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HPHlC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I turn off highlighting for this syntax element?&#xA;In &lt;code&gt;~/.vim/syntax/markdown.vim&lt;/code&gt; I find elements like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region markdownItalic start=&quot;\S\@&amp;lt;=\*\|\*\S\@=&quot; end=&quot;\S\@&amp;lt;=\*\|\*\S\@=&quot; keepend contains=markdownLineStart&#xA;syn region markdownItalic start=&quot;\S\@&amp;lt;=_\|_\S\@=&quot; end=&quot;\S\@&amp;lt;=_\|_\S\@=&quot; keepend contains=markdownLineStart&#xA;syn region markdownBold start=&quot;\S\@&amp;lt;=\*\*\|\*\*\S\@=&quot; end=&quot;\S\@&amp;lt;=\*\*\|\*\*\S\@=&quot; keepend contains=markdownLineStart,markdownItalic&#xA;syn region markdownBold start=&quot;\S\@&amp;lt;=__\|__\S\@=&quot; end=&quot;\S\@&amp;lt;=__\|__\S\@=&quot; keepend contains=markdownLineStart,markdownItalic&#xA;syn region markdownBoldItalic start=&quot;\S\@&amp;lt;=\*\*\*\|\*\*\*\S\@=&quot; end=&quot;\S\@&amp;lt;=\*\*\*\|\*\*\*\S\@=&quot; keepend contains=markdownLineStart&#xA;syn region markdownBoldItalic start=&quot;\S\@&amp;lt;=___\|___\S\@=&quot; end=&quot;\S\@&amp;lt;=___\|___\S\@=&quot; keepend contains=markdownLineStart&#xA;syn region markdownCode matchgroup=markdownCodeDelimiter start=&quot;`&quot; end=&quot;`&quot; keepend contains=markdownLineStart&#xA;syn region markdownCode matchgroup=markdownCodeDelimiter start=&quot;`` \=&quot; end=&quot; \=``&quot; keepend contains=markdownLineStart&#xA;syn region markdownCode matchgroup=markdownCodeDelimiter start=&quot;^\s*```.*$&quot; end=&quot;^\s*```\ze\s*$&quot; keepend&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I tried &lt;code&gt;:hi clear markdownItalic&lt;/code&gt; and the same with &lt;code&gt;markdownBold&lt;/code&gt; and &lt;code&gt;markdownBoldItalic&lt;/code&gt;. None of those do the trick.&lt;/p&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2018-09-11T19:40:46.050" Title="How can I turn off syntax highlighting for one specific element?" Tags="|syntax-highlighting|filetype-markdown|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17350" PostTypeId="2" ParentId="17349" CreationDate="2018-09-11T14:31:05.397" Score="0" Body="&lt;p&gt;It seems that the &lt;code&gt;markdownItalic&lt;/code&gt; syntax element is a link to &lt;code&gt;htmlItalic&lt;/code&gt; (could someone elaborate what that means?), so setting &lt;code&gt;hi clear htmlItalic&lt;/code&gt; does the trick for me.&#xA;The downside is that this breaks all other sort of highlighting within the region vim thinks is italic text.&lt;/p&gt;&#xA;" OwnerUserId="1066" LastEditorUserId="1066" LastEditDate="2018-09-11T14:36:12.117" LastActivityDate="2018-09-11T14:36:12.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17351" PostTypeId="2" ParentId="17349" CreationDate="2018-09-11T14:50:35.150" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/17350/343&quot;&gt;As you've discovered&lt;/a&gt;, &lt;code&gt;markdownItalic&lt;/code&gt; is a link to &lt;code&gt;htmlItalic&lt;/code&gt;, which just means the former uses the highlighting configured for the latter group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can remove a highlight link with a command like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight link markdownItalic NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :highlight-link&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-09-11T19:40:46.050" LastActivityDate="2018-09-11T19:40:46.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17352" PostTypeId="1" CreationDate="2018-09-11T16:09:48.403" Score="2" ViewCount="45" Body="&lt;p&gt;This is not firmly reproducible but when I run ctrl+wv to create a vertical split window, I sometimes lose visibility to the colon command prompt. Command prompt still works invisibly. Sometimes I can see the thin red bar of the top of an error message at the very bottom of the window, but there is no way to scroll it into view.  Some commands will restore its visibility, :so=2 and also if I select Help/Version from the gnome command bar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am getting used to this but it is slowing me down...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running gvim 8.0.1453 on ubuntu 18.04.1 LTS gnome 3.28.2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed &lt;a href=&quot;https://vi.stackexchange.com/questions/4725/gvim-cmd-line-offset-issue-when-doing-horizontal-splits?rq=1&quot;&gt;this&lt;/a&gt; related question but it relates to horizontal splits.  It is similar in that window split commands seem unreliable with respect to command line visibility while fullscreen gvim.&lt;/p&gt;&#xA;" OwnerUserId="12439" LastEditorUserId="12439" LastEditDate="2018-09-12T16:47:00.793" LastActivityDate="2018-09-12T16:47:00.793" Title="gvim gnome hides command prompt" Tags="|gvim|linux-ubuntu|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17353" PostTypeId="6" CreationDate="2018-09-11T16:44:45.147" Score="0" Body="&lt;p&gt;Hello vi.se! I'm DJ, and I would be honored to be a moderator on this site that I love so much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been regularly using Stack Exchange for right around 4 years, and this site for around 3. Most of my SE contribution has been related to vim in one way or another. Even on the site I spend most of my time on, &lt;a href=&quot;https://codegolf.stackexchange.com/&quot;&gt;code-golf&lt;/a&gt;, most of my answers have been written using vim in ways it was never intended to be used, which is a bit unorthodox, but I find incredibly satisfying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have spent a lot of time using moderation tools. I'm a member of &lt;a href=&quot;https://charcoal-se.org/people.html#members&quot; rel=&quot;nofollow noreferrer&quot;&gt;Charcoal&lt;/a&gt;, an organization that hunts down spam across the network, and currently an elected moderator on code-golf. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that I would make a good moderator on this site since I have a passion for both SE and vim, and I've been around on this site for a while, answering, reviewing, and editing to keep the site high-quality. I'm also very active in chat, which means it would always be easy to get a hold of me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have any questions or concerns for me, feel free to bring them up, either here or in chat! I'd be happy to hear and address them. --DJ&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2018-09-11T16:44:45.147" LastActivityDate="2018-09-11T16:44:45.147" CommentCount="1" CommunityOwnedDate="2018-09-11T16:44:45.147" ContentLicense="CC BY-SA 4.0" />
  <row Id="17355" PostTypeId="2" ParentId="2003" CreationDate="2018-09-11T23:16:00.257" Score="1" Body="&lt;p&gt;Here is a vey simple procedure to get you started.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;comment out contents of your entire .vimrc file&lt;/li&gt;&#xA;&lt;li&gt;reload your .vimrc by running &lt;code&gt;:source %&lt;/code&gt; or &lt;code&gt;:so $MYVIMRC&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;uncomment a discreet part of the file (generally starting from the top)&lt;/li&gt;&#xA;&lt;li&gt;Repeat steps 2 and 3 until you find the error.&lt;/li&gt;&#xA;&lt;li&gt;fix the error.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="18945" LastEditorUserId="18945" LastEditDate="2018-09-18T19:51:52.763" LastActivityDate="2018-09-18T19:51:52.763" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17356" PostTypeId="1" AcceptedAnswerId="17357" CreationDate="2018-09-12T00:29:05.560" Score="1" ViewCount="535" Body="&lt;p&gt;I am trying to use the &lt;code&gt;join&lt;/code&gt; command to join multiple strings. The &lt;code&gt;join&lt;/code&gt; command seems to add one character of space in between each of the strings. But I don't want any space added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, I'm working on a function that finds the associated .pdf file of a .tex file. So if I'm editing the file &lt;em&gt;/home/user/paper.tex&lt;/em&gt;, I would like to create the string &lt;em&gt;/home/user/paper.pdf&lt;/em&gt;. My attempt is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;join([expand('%:p:r'), '.pdf'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which returns &lt;code&gt;/home/user/paper .pdf&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2018-09-12T01:07:06.963" Title="Preventing the join() command from adding extra space" Tags="|whitespace|join|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17357" PostTypeId="2" ParentId="17356" CreationDate="2018-09-12T01:07:06.963" Score="4" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#join%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help join()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;join({list} [, {sep}])&#xA;&#xA;            [..]&#xA;&#xA;            When {sep} is specified it is put in between the items.  If&#xA;            {sep} is omitted a single space is used.&#xA;&#xA;            [..]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the solution is to add an empty string in the second &lt;code&gt;sep&lt;/code&gt; parameter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo join([expand('%:p:r'), '.pdf'])&#xA;/usr/share/vim/vim81/doc/eval .pdf&#xA;&#xA;:echo join([expand('%:p:r'), '.pdf'], '')&#xA;/usr/share/vim/vim81/doc/eval.pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case you don't really need to use &lt;code&gt;join()&lt;/code&gt; by the way, and could just use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo expand('%:p:r') . '.pdf'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2018-09-12T01:07:06.963" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17358" PostTypeId="2" ParentId="17344" CreationDate="2018-09-12T08:02:34.763" Score="1" Body="&lt;p&gt;This substitution should do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/0x[0-9a-fA-F]*/\=printf('%08X', str2nr(submatch(0), 16))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The regex &lt;code&gt;0x[0-9a-fA-F]*&lt;/code&gt; is straightforward, matching hex numbers as you describe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The replacement string uses an expression, since it starts with &lt;code&gt;\=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The expression is &lt;code&gt;printf('%08X', str2nr(expand(submatch(0)), 16))&lt;/code&gt;, which starts by taking the matched text &lt;code&gt;submatch(0)&lt;/code&gt;, then converting it to an integer, using base 16 (&lt;code&gt;str2nr(..., 16)&lt;/code&gt;) and finally formatting it as an hex string of length (at least) 8, padded with zeroes, using uppercase hex digits for A-F (&lt;code&gt;%08X&lt;/code&gt; format string).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:%&lt;/code&gt; makes this match the whole buffer and the &lt;code&gt;/g&lt;/code&gt; makes it match multiple hex digits on the same line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A buffer containing a line with these contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x12345678 0xABCDF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Gets converted to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12345678 000ABCDF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which seems to match what you describe.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2018-09-12T08:02:34.763" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17359" PostTypeId="1" AcceptedAnswerId="17360" CreationDate="2018-09-12T12:44:56.113" Score="4" ViewCount="539" Body="&lt;p&gt;Before I came here, I went to &lt;a href=&quot;http://web.physics.ucsb.edu/~pcs/apps/editors/vi/vi_unix.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;executing command from within Vim&lt;/a&gt; and learned it can be done using:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:!command&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then I went to &lt;a href=&quot;https://vi.stackexchange.com/questions/1942/how-to-execute-shell-commands-silently&quot;&gt;executing it silently&lt;/a&gt; and figured how that I need to run:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:silent exec &quot;!command&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now I want to do it periodically like every 5 seconds or so. Can anyone help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The requirement is that I need to generate tags on the go as I write the code using Ctags. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll prefer OG answers if possible over the Plugins and some other tools/utilities.&lt;/p&gt;&#xA;" OwnerUserId="18443" LastEditorDisplayName="user579" LastEditDate="2018-09-14T10:49:05.503" LastActivityDate="2018-09-14T10:49:05.503" Title="How do I run a shell command periodically and silently from within Vi?" Tags="|repeated-commands|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17360" PostTypeId="2" ParentId="17359" CreationDate="2018-09-12T14:59:36.067" Score="5" Body="&lt;p&gt;As @ChristianBrabandt mentions in the comments, presuming you're using a reasonably recent version of Vim, you could do this with a timer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, you can virtually just copy-paste the example in from &lt;code&gt;:help timer-start&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func MyHandler(timer)&#xA;  silent exec &quot;!command&quot;&#xA;endfunc&#xA;let timer = timer_start(500, 'MyHandler', {'repeat': -1})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wouldn't recommend this though. I think you're better of using an &lt;a href=&quot;https://www.reddit.com/r/vim/comments/5cv5ge/how_do_you_manage_your_ctags/&quot; rel=&quot;nofollow noreferrer&quot;&gt;alternative method&lt;/a&gt; such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;generate tags on file save by using an autocommand,&lt;/li&gt;&#xA;&lt;li&gt;generate the tags outside of Vim with something like &lt;code&gt;watch&lt;/code&gt;, &lt;code&gt;inotify&lt;/code&gt; or &lt;a href=&quot;http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;git hooks&lt;/a&gt;,&lt;/li&gt;&#xA;&lt;li&gt;use a plugin. I use &lt;a href=&quot;https://github.com/ludovicchabant/vim-gutentags&quot; rel=&quot;nofollow noreferrer&quot;&gt;gutentags&lt;/a&gt;, but there are several others.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-09-14T09:33:23.223" LastActivityDate="2018-09-14T09:33:23.223" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17361" PostTypeId="1" CreationDate="2018-09-12T15:39:06.307" Score="1" ViewCount="149" Body="&lt;p&gt;I used to be able to navigate vim splits using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-j&amp;gt; &amp;lt;C-w&amp;gt;j&#xA;nnoremap &amp;lt;C-k&amp;gt; &amp;lt;C-w&amp;gt;k&#xA;nnoremap &amp;lt;C-l&amp;gt; &amp;lt;C-w&amp;gt;l&#xA;nnoremap &amp;lt;C-h&amp;gt; &amp;lt;C-w&amp;gt;h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but now I cannot map the &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; sequence to any other command. Is this key combination not allowed to be remapped anymore?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried an empty .vimrc file (apart from the 4 lines above) and it does not work when using &lt;code&gt;:sp&lt;/code&gt; for a horizontal split. All other navigation mappings work as expected. If I use other keys instead of &lt;code&gt;j&lt;/code&gt; it also works. I tried on both gnome-terminal and the termite terminal emulators, running on Arch Linux.&#xA;Im using vim 8.1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:version&#xA;VIM - Vi IMproved 8.1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: If I log into vim and type &lt;code&gt;:nnoremap&lt;/code&gt; I see a list of the mappings for &lt;code&gt;h&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt;, but &lt;em&gt;not&lt;/em&gt; for &lt;code&gt;j&lt;/code&gt;. If I then type &lt;code&gt;:nnoremap &amp;lt;C-j&amp;gt; &amp;lt;C-w&amp;gt;j&lt;/code&gt; everything works fine. For some reason, vim is not loading the &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; map from the &lt;code&gt;.vimrc&lt;/code&gt; file...&lt;/p&gt;&#xA;" OwnerUserId="18953" LastEditorUserId="18953" LastEditDate="2018-09-12T17:10:10.053" LastActivityDate="2018-09-12T17:10:10.053" Title="Cannot map &lt;C-j&gt; sequence in vim" Tags="|vimrc|key-bindings|" AnswerCount="0" CommentCount="4" ClosedDate="2018-09-13T16:12:59.763" ContentLicense="CC BY-SA 4.0" />
  <row Id="17363" PostTypeId="1" CreationDate="2018-09-12T16:33:08.390" Score="3" ViewCount="221" Body="&lt;p&gt;I'm writing a vim script. When &lt;code&gt;fun()&lt;/code&gt; is called, I want a new window of 3 lines height is opened, with the content of register &lt;code&gt;h&lt;/code&gt; displayed. And then, when the user moved the cursor, like &lt;code&gt;hjkl&lt;/code&gt;, the window is closed automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code just like below. But I found the CursorMoved event is tiggered unexpected. Therefore, The window which was supposed to display and wait for user input is just flashed and closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why the autocmd in &lt;code&gt;fun()&lt;/code&gt; is executed as soon as it is installed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything I missed or wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let t:tmpname = tempname()&#xA;&#xA;function! s:CloseWin()&#xA;    let l:c_nr = bufnr(&quot;&quot;)&#xA;    let l:p_nr = bufwinnr(t:tmpname)&#xA;    exec l:p_nr . &quot; wincmd w&quot;&#xA;    close&#xA;    exec bufwinnr(l:c_nr) . &quot; wincmd w&quot;&#xA;    autocmd! vgroup&#xA;endfunction&#xA;&#xA;&#xA;function! s:fun()&#xA;    let @h = 'xxxx'&#xA;    silent! topleft 3 new&#xA;    silent! exec &quot;edit &quot; . t:tempname&#xA;    silent! 1,$delete _&#xA;    silent! put h&#xA;    silent! call cursor(1, 0, 0)&#xA;    silent! delete _&#xA;&#xA;    silent! setlocal noswapfile&#xA;    silent! setlocal buftype=nofile&#xA;    silent! setlocal bufhidden=hide&#xA;    silent! setlocal nowrap&#xA;    silent! setlocal foldcolumn=0&#xA;    silent! setlocal foldmethod=manual&#xA;    silent! setlocal nofoldenable&#xA;    silent! setlocal nobuflisted&#xA;    silent! setlocal nospell&#xA;    silent! wincmd p&#xA;&#xA;    augroup vgroup&#xA;        autocmd!&#xA;        autocmd CursorMoved * call s:CloseWin()&#xA;    augroup end&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18955" LastEditorUserId="21062" LastEditDate="2019-08-08T15:38:57.927" LastActivityDate="2019-08-08T15:38:57.927" Title="Why does vim CursorMoved event triggered in this script?" Tags="|vimscript|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17365" PostTypeId="1" AcceptedAnswerId="17366" CreationDate="2018-09-12T21:55:52.100" Score="2" ViewCount="1227" Body="&lt;p&gt;Is there a setting I could add to my vimrc file that would hide the last entered colon-command that stays visible on the bottom of the screen after I hit enter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I type &quot;:3&quot; to go to line 3 of the current file, then the &quot;:3&quot; stays visible on the bottom of the screen even after I hit enter. I already have my manager on my back. Now, I have a little guy with a mustache at the bottom of my screen staring at me while I'm trying to get my work done. (I know there are other ways to go to line 3—for example, by entering &quot;3G&quot;—that keep the command-line clear, but you get the point.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I'd like to hide the last entered command because I like to keep things clean. I'm not very experienced with Vim, however, so if keeping the last command visible is actually more useful than I realize, please do enlighten me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, what about for searches? Maybe if I enter &quot;/hello&quot; (to search for all occurrences of &quot;hello&quot;), for example, then I could type &quot;Esc&quot; (or something) to clear &quot;/hello&quot; from the command-line when I'm done searching. How could I make something like that possible? Or, is there already a setting or plugin that does this?&lt;/p&gt;&#xA;" OwnerUserId="18935" LastEditorUserId="18935" LastEditDate="2018-09-12T23:54:58.467" LastActivityDate="2021-11-03T00:21:21.947" Title="Is there a setting that hides the last colon-command entered?" Tags="|vimrc|command-line|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17366" PostTypeId="2" ParentId="17365" CreationDate="2018-09-12T23:48:30.160" Score="6" Body="&lt;p&gt;You can press &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; to force a redraw, which will clear this line, among some other things.&lt;/p&gt;&#xA;&lt;p&gt;If you want, you can use the &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#CmdlineLeave&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;CmdlineLeave&lt;/code&gt;&lt;/a&gt; autocommand to echo an empty string upon leaving the commandline:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup cmdline&#xA;    autocmd!&#xA;    autocmd CmdlineLeave : echo ''&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There isn't a &lt;code&gt;setcmdline()&lt;/code&gt;, so as far as I know this is the best way.&lt;/p&gt;&#xA;&lt;p&gt;This won't work for search, as searching for text will always set the commandline window (e.g. &lt;code&gt;n&lt;/code&gt; will set it). I don't know of any way to automatically clear that outside of pressing &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; or remapping all search keys:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap n n:echo ''&amp;lt;CR&amp;gt;&#xA;&amp;quot; same for N, *, etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-08-27T07:40:33.940" LastActivityDate="2020-08-27T07:40:33.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17367" PostTypeId="1" CreationDate="2018-09-13T02:39:57.237" Score="1" ViewCount="1349" Body="&lt;p&gt;I'd use Homebrew to install Vim on macOS, with &lt;code&gt;brew install vim&lt;/code&gt;, but the &lt;a href=&quot;https://formulae.brew.sh/formula/vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Homebrew Formula for Vim&lt;/a&gt; seems to install many additional features that I don't need. For example, while I do plan on using Vim to edit Ruby files, I don't plan on using the Ruby interface to Vim. (See &lt;code&gt;:help ruby&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, when compiling Vim on macOS, what features should I include or leave out (that aren't already included or left out by default), and are there any other custom configuration options I should set?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly, many people seem to share the settings &amp;amp; plugins they use when running Vim, but not many seem to share the configurations &amp;amp; features they use when compiling Vim.&lt;/p&gt;&#xA;" OwnerUserId="18935" LastEditorUserId="51" LastEditDate="2018-09-13T02:44:43.897" LastActivityDate="2020-09-01T08:24:01.590" Title="How to install the latest version of Vim on macOS?" Tags="|macos|compile-vim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17368" PostTypeId="1" AcceptedAnswerId="17370" CreationDate="2018-09-13T07:50:50.793" Score="1" ViewCount="1628" Body="&lt;p&gt;I want to show line number in the editor, thus I use &lt;code&gt;set nu&lt;/code&gt; in my &lt;code&gt;vimrc&lt;/code&gt;. But when I open the embedded terminal with &lt;code&gt;:ter&lt;/code&gt;, there are also line numbers there which I feel not comfortable. How could I switch off the line numbers in the terminal while still keep the line numbers of the editor window ?&lt;/p&gt;&#xA;" OwnerUserId="18259" LastActivityDate="2018-09-13T10:16:45.377" Title="How could I turn off the terminal line number while keep the editor line number in vimrc" Tags="|vimrc|terminal|line-numbers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17369" PostTypeId="1" AcceptedAnswerId="25753" CreationDate="2018-09-13T08:45:55.630" Score="9" ViewCount="15087" Body="&lt;p&gt;I like to use the vim embedded terminal, but I do not know how I could adjust its height. Sometimes, I need it to be lower so that I could concentrate on my editor how could I adjust it ?&lt;/p&gt;&#xA;" OwnerUserId="18259" LastActivityDate="2023-01-02T20:17:00.280" Title="How could I adjust terminal height" Tags="|terminal|terminal-buffer|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17370" PostTypeId="2" ParentId="17368" CreationDate="2018-09-13T08:50:47.697" Score="4" Body="&lt;p&gt;Thanks the helpful comment provided by Christian Brabandt. The answer is to add a line in the &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd TerminalOpen * set nonu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18259" LastEditorUserId="51" LastEditDate="2018-09-13T10:16:45.377" LastActivityDate="2018-09-13T10:16:45.377" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17371" PostTypeId="2" ParentId="17367" CreationDate="2018-09-13T11:28:47.923" Score="2" Body="&lt;h3&gt;Compile Vim via MacPorts&lt;/h3&gt;&#xA;&lt;p&gt;Macports provides currently a more granular installation approach for vim than homebrew:&lt;/p&gt;&#xA;&lt;p&gt;It offers the feature variants &lt;code&gt;tiny&lt;/code&gt;, &lt;code&gt;small&lt;/code&gt;, &lt;code&gt;big&lt;/code&gt;, and &lt;code&gt;huge&lt;/code&gt;.&#xA;You can add specifically the interfaces for &lt;code&gt;ruby&lt;/code&gt;, &lt;code&gt;perl&lt;/code&gt;, &lt;code&gt;lua&lt;/code&gt;, &lt;code&gt;python&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For all variants see&#xA;&lt;a href=&quot;https://ports.macports.org/port/vim/summary&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ports.macports.org/port/vim/summary&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, you can add this functionality to the homebrew formula as well (&lt;a href=&quot;https://docs.brew.sh/Formula-Cookbook#specifying-other-formulae-as-dependencies&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.brew.sh/Formula-Cookbook#specifying-other-formulae-as-dependencies&lt;/a&gt;).  Others might appreciate it.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand as it has been mentioned: compiling with &lt;code&gt;huge&lt;/code&gt; by default and adding all interfaces is not really a performance problem. Also you can notice later on that you miss something. You will not run into this situation for the current build and therefore works for everyone.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2020-09-01T08:24:01.590" LastActivityDate="2020-09-01T08:24:01.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17372" PostTypeId="2" ParentId="3327" CreationDate="2018-09-13T11:39:29.177" Score="4" Body="&lt;p&gt;Actually, while this isn't a solution to your &lt;em&gt;specific&lt;/em&gt; problem (improving syntax highlighting for massive files), you may want to actually think about refactoring your source code so that you &lt;em&gt;don't&lt;/em&gt; have tens of thousands of line in a single file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This scenario generally has impacts &lt;em&gt;beyond&lt;/em&gt; your editor, things like changing one line of code meaning that you have to compile a rather large chunk of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would probably be far better off figuring out how to modularise your code so that each source file is more manageable (both for editing &lt;em&gt;and&lt;/em&gt; other purposes).&lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastActivityDate="2018-09-13T11:39:29.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17373" PostTypeId="2" ParentId="17369" CreationDate="2018-09-13T11:41:30.533" Score="2" Body="&lt;p&gt;There are several options:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) The simple way is to drag the bar separating the two split windows using the mouse. As far as I know this works by default, but I've only been using neovim, not standard vim so you may need to enable the mouse first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) In normal mode, type &lt;code&gt;10&amp;lt;C-W&amp;gt;+&lt;/code&gt; to increase the size of the current split by 10 lines. Or make a binding for this, e.g. &lt;code&gt;nmap &amp;lt;Leader&amp;gt;b 10&amp;lt;C-W&amp;gt;+&amp;lt;CR&amp;gt;&lt;/code&gt; (b for bigger; Leader is &lt;code&gt;\&lt;/code&gt; by default but should be rebound to space in my opinion)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(3) A more automatic solution to the problem of the current split being too small is to add this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set winheight=38&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will make the currently active window 38 lines tall, with the terminal filling the remaining space. But when you switch to the terminal, this is swapped around so that you can see the command output better.&lt;/p&gt;&#xA;" OwnerUserId="18875" LastEditorUserId="18875" LastEditDate="2018-12-12T08:54:32.397" LastActivityDate="2018-12-12T08:54:32.397" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17374" PostTypeId="1" AcceptedAnswerId="17385" CreationDate="2018-09-13T16:52:38.933" Score="0" ViewCount="313" Body="&lt;p&gt;I saw an &lt;a href=&quot;https://medium.com/@jovica/the-power-of-recursive-macros-in-vim-1ecfa35c1183&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt; of a recursive vim macro, and it stops, but I don't quite understand why.  My guess is that it stops because it can't find any more &lt;code&gt;:&lt;/code&gt;, but I'm unsure if I am correct; does anyone know why it stops?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Macro contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i&amp;lt;Tab&amp;gt;'&amp;lt;Esc&amp;gt;f:C',&amp;lt;Esc&amp;gt;j^@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Register &lt;code&gt;a&lt;/code&gt; is first empties with &lt;code&gt;qaq&lt;/code&gt; and then recorded into with &lt;code&gt;qa{...}q&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="10604" LastEditDate="2018-09-14T02:30:20.740" LastActivityDate="2018-09-14T15:53:28.630" Title="Why does this recursive vim macro stop?" Tags="|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17376" PostTypeId="1" CreationDate="2018-09-13T18:17:17.310" Score="0" ViewCount="215" Body="&lt;p&gt;Basically, I want to compare which features were enabled when each installation of Vim was compiled. If there's also other significant differences between the two installations, besides their feature-lists, please let me know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apple compiled one installation of Vim, the one that came with macOS, and I compiled the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;a href=&quot;https://www.vim.org/download.php#unix&quot; rel=&quot;nofollow noreferrer&quot;&gt;compiled Vim from source using Git&lt;/a&gt; with the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/vim/vim.git&#xA;cd vim/src&#xA;make&#xA;make install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the version information for Apple's installation of Vim: &lt;code&gt;/usr/bin/vim --version&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46)&#xA;Included patches: 1-503, 505-680, 682-1283&#xA;Compiled by root@apple.com&#xA;Normal version without GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    -mouse_sgr       +tag_old_static&#xA;-arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           -mouse_urxvt     -tcl&#xA;-balloon_eval    +folding         +mouse_xterm     -termguicolors&#xA;-browse          -footer          +multi_byte      -terminal&#xA;+builtin_terms   +fork()          +multi_lang      +terminfo&#xA;+byte_offset     -gettext         -mzscheme        +termresponse&#xA;+channel         -hangul_input    +netbeans_intg   +textobjects&#xA;+cindent         +iconv           +num64           +timers&#xA;-clientserver    +insert_expand   +packages        +title&#xA;-clipboard       +job             +path_extra      -toolbar&#xA;+cmdline_compl   +jumplist        -perl            +user_commands&#xA;+cmdline_hist    -keymap          +persistent_undo +vertsplit&#xA;+cmdline_info    +lambda          +postscript      +virtualedit&#xA;+comments        -langmap         +printer         +visual&#xA;-conceal         +libcall         -profile         +visualextra&#xA;+cryptv          +linebreak       +python/dyn      +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             -rightleft       +windows&#xA;+diff            +menu            +ruby/dyn        +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;-emacs_tags      -mouseshape      +startuptime     -xpm&#xA;+eval            -mouse_dec       +statusline      -xsmp&#xA;+ex_extra        -mouse_gpm       -sun_workshop    -xterm_clipboard&#xA;+extra_search    -mouse_jsbterm   +syntax          -xterm_save&#xA;-farsi           -mouse_netterm   +tag_binary      &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the version information for my installation of Vim: &lt;code&gt;/usr/local/bin/vim --version&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Sep 12 2018 18:04:14)&#xA;macOS version&#xA;Included patches: 1-374&#xA;Compiled by me@my.home&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               +extra_search      +mouse_netterm     +tag_old_static&#xA;+arabic            +farsi             +mouse_sgr         -tag_any_white&#xA;+autocmd           +file_in_path      -mouse_sysmouse    -tcl&#xA;+autochdir         +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       +terminal&#xA;-balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;-browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    -gettext           +netbeans_intg     +timers&#xA;+byte_offset       -hangul_input      +num64             +title&#xA;+channel           +iconv             +packages          -toolbar&#xA;+cindent           +insert_expand     +path_extra        +user_commands&#xA;-clientserver      +job               -perl              +vartabs&#xA;+clipboard         +jumplist          +persistent_undo   +vertsplit&#xA;+cmdline_compl     +keymap            +postscript        +virtualedit&#xA;+cmdline_hist      +lambda            +printer           +visual&#xA;+cmdline_info      +langmap           +profile           +visualextra&#xA;+comments          +libcall           -python            +viminfo&#xA;+conceal           +linebreak         -python3           +vreplace&#xA;+cryptv            +lispindent        +quickfix          +wildignore&#xA;-cscope            +listcmds          +reltime           +wildmenu&#xA;+cursorbind        +localmap          +rightleft         +windows&#xA;+cursorshape       -lua               -ruby              +writebackup&#xA;+dialog_con        +menu              +scrollbind        -X11&#xA;+diff              +mksession         +signs             -xfontset&#xA;+digraphs          +modify_fname      +smartindent       -xim&#xA;-dnd               +mouse             +startuptime       -xpm&#xA;-ebcdic            -mouseshape        +statusline        -xsmp&#xA;+emacs_tags        +mouse_dec         -sun_workshop      -xterm_clipboard&#xA;+eval              -mouse_gpm         +syntax            -xterm_save&#xA;+ex_extra          -mouse_jsbterm     +tag_binary        &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -O2   -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework AppKit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's a lot to look through. Is there an easy way to see a list of features my installation supports that Apple's doesn't and a list of features Apple's installation supports that mine doesn't?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried doing it with &lt;code&gt;diff&lt;/code&gt; and &lt;code&gt;git diff --color-words --no-index&lt;/code&gt;, but neither command really helped. Maybe there's a script that diffs version information for two different Vim installations?&lt;/p&gt;&#xA;" OwnerUserId="18935" LastActivityDate="2018-09-13T19:20:06.500" Title="How to compare two different Vim installs?" Tags="|vimdiff|installing|compile-vim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17377" PostTypeId="2" ParentId="17376" CreationDate="2018-09-13T19:20:06.500" Score="1" Body="&lt;p&gt;To get a one column list of Vim's compile options you could use this script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1 #! /bin/bash&#xA; 2 &#xA; 3 splitme()&#xA; 4 {&#xA; 5   while read -r line || [[ -n &quot;$line&quot; ]]; do&#xA; 6     line4=$(echo $line | perl -p -e 's/ +/ /g')&#xA; 7     for one in $line4&#xA; 8     do&#xA; 9       echo $one&#xA;10     done&#xA;11   done&#xA;12 }&#xA;13&#xA;14 vim --version | grep '^[+-]' | splitme | sort --key=1.2 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;14 &lt;code&gt;grep&lt;/code&gt; filters all lines that start with &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;-&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;14 &lt;code&gt;splitme&lt;/code&gt; makes one column from four columns&lt;/li&gt;&#xA;&lt;li&gt;14 &lt;code&gt;sort&lt;/code&gt; sorts the result ignoring column 1 (&lt;code&gt;+&lt;/code&gt; or &lt;code&gt;-&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;5 read output of grep line by line&lt;/li&gt;&#xA;&lt;li&gt;6 replace all multiple spaces by single spaces&lt;/li&gt;&#xA;&lt;li&gt;7 walk through line by column&lt;/li&gt;&#xA;&lt;li&gt;8 output column&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Partial sample output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+statusline&#xA;-sun_workshop&#xA;+syntax&#xA;-tag_any_white&#xA;+tag_binary&#xA;+tag_old_static&#xA;-tcl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then redirect the output to files and &lt;code&gt;diff&lt;/code&gt; them.&lt;/p&gt;&#xA;" OwnerUserId="18342" LastActivityDate="2018-09-13T19:20:06.500" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17378" PostTypeId="1" AcceptedAnswerId="17471" CreationDate="2018-09-13T22:37:17.037" Score="2" ViewCount="170" Body="&lt;p&gt;How can I enable 'cursorline' in the preview window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;:ptag&lt;/code&gt; to show the preview and like that it shows several lines, but for short functions or member lists it's hard to see the line containing my tag. Using cursorline would help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd WinEnter * if &amp;amp;previewwindow | setlocal cursorline | endif &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The preview window opens without a cursorline (even after &lt;code&gt;C-L&lt;/code&gt; or &lt;code&gt;:redraw&lt;/code&gt;), but when I switch to it cursorline activates. I want it to work without moving the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried WinNew instead of WinEnter, but that doesn't work at all. I'm not sure why.&lt;/p&gt;&#xA;" OwnerUserId="2045" LastEditorUserId="2045" LastEditDate="2018-09-13T22:43:43.543" LastActivityDate="2018-09-24T18:14:58.070" Title="Enable cursorline only in preview window?" Tags="|cursorline|previewwindow|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17380" PostTypeId="2" ParentId="10983" CreationDate="2018-09-14T01:56:03.027" Score="1" Body="&lt;p&gt;You can run &lt;code&gt;:checkhealth&lt;/code&gt; (&lt;code&gt;:CheckHealth&lt;/code&gt; in older versions) to find any problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also need &lt;a href=&quot;https://github.com/zchee/deoplete-go&quot; rel=&quot;nofollow noreferrer&quot;&gt;deoplete-go&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastEditorUserId="8233" LastEditDate="2018-11-14T04:54:54.630" LastActivityDate="2018-11-14T04:54:54.630" CommentCount="0" CommunityOwnedDate="2018-09-14T01:56:03.027" ContentLicense="CC BY-SA 4.0" />
  <row Id="17381" PostTypeId="2" ParentId="16145" CreationDate="2018-09-14T02:56:49.843" Score="3" Body="&lt;p&gt;Git actually checks the exit code of whatever editor you have configured and outputs that error message if it's non-zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't replicate the problem with your commands but you may have better luck. Simply run &lt;code&gt;vim&lt;/code&gt; normally (i.e., &lt;em&gt;not&lt;/em&gt; via &lt;code&gt;git&lt;/code&gt;), enter the &lt;code&gt;:Wq&lt;/code&gt; and &lt;code&gt;:wq&lt;/code&gt; commands (and whatever else you did in between those two), then check the exit code with (for Linux) &lt;code&gt;echo $?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's not zero, you at least have a repeatable test you can use for further investigation, at which point you can start experimenting with &lt;code&gt;vim&lt;/code&gt; options (as shown in &lt;a href=&quot;https://unix.stackexchange.com/questions/14497/why-would-vim-return-non-zero-exit-code-if-i-exit-immediately-after-opening&quot;&gt;this question&lt;/a&gt; for example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also opt for a different editor which &lt;em&gt;doesn't&lt;/em&gt; return non-zero. There's probably no reason to need the &lt;em&gt;massive&lt;/em&gt; power of Vim for composing what are (hopefully) one-liner commit messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, I don't use &lt;em&gt;any&lt;/em&gt; editor, instead relying on the command-line bevaviour only. For one-liners:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pax$ git commit -m &quot;Fixed my co-worker's atrocious code :-)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or, more more complex messages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pax$ git commit -F - &#xA;(reading log message from standard input)&#xA;Fixed my co-worker's atrocious code, specifically:&#xA;- no comments;&#xA;- unreadable formatting;&#xA;- bad variable names.&#xA;&amp;lt;CTRL-D&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As to how you easily get at the comment you just tried to use, that should be stored in &lt;code&gt;.git/COMMIT_EDITMSG&lt;/code&gt; so you can just use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git commit -F .git/COMMIT_EDITMSG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(or &lt;code&gt;-eF&lt;/code&gt; if you want to check or further edit the message).&lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastActivityDate="2018-09-14T02:56:49.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17382" PostTypeId="1" AcceptedAnswerId="17383" CreationDate="2018-09-14T06:37:16.810" Score="1" ViewCount="36" Body="&lt;p&gt;I am editing at the bottom of a file, but I want the line I'm editing to appear in the middle of the screen. Is this possible without adding a bunch of spurious newlines at the end of the file?&lt;/p&gt;&#xA;" OwnerUserId="6310" LastActivityDate="2018-09-14T07:18:12.147" Title="How to show cursor in the middle of the window despite being at the end of the file?" Tags="|cursor-movement|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17383" PostTypeId="2" ParentId="17382" CreationDate="2018-09-14T07:18:12.147" Score="4" Body="&lt;p&gt;Of course. Just use &lt;code&gt;zz&lt;/code&gt; to move current line to the middle of your vim window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally you can use &lt;code&gt;ctrl-e&lt;/code&gt; and &lt;code&gt;ctrl-y&lt;/code&gt; to scroll-up and down.&lt;/p&gt;&#xA;" OwnerUserId="1782" LastActivityDate="2018-09-14T07:18:12.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17384" PostTypeId="2" ParentId="11116" CreationDate="2018-09-14T11:07:59.727" Score="1" Body="&lt;p&gt;An empty line can be recognized by two consecutive newlines.  You can match everything that is &lt;em&gt;not&lt;/em&gt; two newlines with the following pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\([^\n]\|\n[^\n]\)*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Place this between the &quot;start&quot; and &quot;end&quot; patterns to match the whole italicized region at once.  It will require that your &lt;code&gt;syntax&lt;/code&gt; item is a &lt;code&gt;match&lt;/code&gt; rather than a &lt;code&gt;region&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match markdownItalic &quot;\*\S\@=\([^\n]\|\n[^\n]\)\{-}\S\@&amp;lt;=\*&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\{-}&lt;/code&gt; ensures that the match ends at the first possible end-marker.  Alternatively, you could include &lt;code&gt;*&lt;/code&gt; in the negated character list.&lt;/p&gt;&#xA;" OwnerUserId="7600" LastActivityDate="2018-09-14T11:07:59.727" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17385" PostTypeId="2" ParentId="17374" CreationDate="2018-09-14T12:11:26.827" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#%40&quot; rel=&quot;nofollow noreferrer&quot;&gt;repeat.txt&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The register is executed like a mapping&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#map-error&quot; rel=&quot;nofollow noreferrer&quot;&gt;map.txt&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that when an error is encountered (that causes an error message or beep)&#xA;  the rest of the mapping is not executed. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So there's been some kind of error before reaching the &lt;code&gt;@a&lt;/code&gt;.  The documentation doesn't give an exhaustive list of all the possible errors for each action, but the most likely options are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;f&lt;/code&gt; didn't find a &lt;code&gt;:&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j&lt;/code&gt; couldn't move down (because there were no more lines in the buffer)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7600" LastActivityDate="2018-09-14T12:11:26.827" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17386" PostTypeId="1" CreationDate="2018-09-14T13:17:36.470" Score="1" ViewCount="1154" Body="&lt;p&gt;I am using NERDTree to open files. If I am on a file path in vim and I hit &lt;code&gt;gf&lt;/code&gt; this works fine for files. For folders, &lt;code&gt;gf&lt;/code&gt; opens a new NERDTree buffer in this folder which is fine. I can then choose a file.&#xA;I am having a hard time to make this NERDTree buffer disappear again: Hitting &lt;code&gt;:bd&lt;/code&gt; as suggested &lt;a href=&quot;https://vi.stackexchange.com/questions/3066/close-and-unload-a-buffer-without-exiting-vim&quot;&gt;here&lt;/a&gt; does not do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently, I found out the following:&#xA;When doing &lt;code&gt;:buffers&lt;/code&gt; I can find the number of the buffer that I want to delete. Suppose the NERDTree buffer is 5, I can do then &lt;code&gt;:5bd&lt;/code&gt;, and the NERDTree buffer is gone. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works fine. However, when I try to make it easier by getting the number of the current buffer, from &lt;code&gt;:execute bufnr(&quot;%&quot;) &quot;bd&quot; &amp;lt;CR&amp;gt;&lt;/code&gt;, it does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that context, I saw that the numbers from &lt;code&gt;:buffer&lt;/code&gt; and &lt;code&gt;:echo bufnr(&quot;%&quot;)&lt;/code&gt; are different for these NERDTree buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did anyone ever encounter this and/or has a solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers and many thanks,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tim&lt;/p&gt;&#xA;" OwnerUserId="18983" LastActivityDate="2018-09-18T14:09:35.810" Title="VIM: bufnr(&quot;%&quot;) not matching number from :buffers for NERDTree buffers" Tags="|buffers|plugin-nerdtree|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17387" PostTypeId="2" ParentId="17374" CreationDate="2018-09-14T15:53:28.630" Score="1" Body="&lt;p&gt;It depends what data you run it on. In the animated gif in the linked page, you're correct that it stops because the &lt;code&gt;f&lt;/code&gt; command cannot find a colon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If instead every line in the file from the cursor on downwards contained a colon, the macro would stop when the &lt;code&gt;j&lt;/code&gt; command cannot move down, i.e. at the bottom of the file.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-09-14T15:53:28.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17388" PostTypeId="2" ParentId="10292" CreationDate="2018-09-14T15:59:47.273" Score="4" Body="&lt;p&gt;This is my solution for closing terminal windows automatically when the terminal process completes with &lt;code&gt;0&lt;/code&gt; exit status.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using Martin Tournoij's answer as a starting point I did some investigating on how to get the terminal process exit code in a &lt;code&gt;TermClose&lt;/code&gt; event handler. You can examine buffer content to parse the &lt;code&gt;[Process exited ?]&lt;/code&gt; line that is appended to the terminal buffer - the problem is that line is not appended until &lt;em&gt;after&lt;/em&gt; the &lt;code&gt;TermClose&lt;/code&gt; event runs. What you can do is to use &lt;code&gt;timer_start&lt;/code&gt; to run a function after a short delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;&quot; Get the exit status from a terminal buffer by looking for a line near the end&#xA;&quot; of the buffer with the format, '[Process exited ?]'.&#xA;func! s:getExitStatus() abort&#xA;  let ln = line('$')&#xA;  &quot; The terminal buffer includes several empty lines after the 'Process exited'&#xA;  &quot; line that need to be skipped over.&#xA;  while ln &amp;gt;= 1&#xA;    let l = getline(ln)&#xA;    let ln -= 1&#xA;    let exitCode = substitute(l, '^\[Process exited \([0-9]\+\)\]$', '\1', '')&#xA;    if l != '' &amp;amp;&amp;amp; l == exitCode&#xA;      &quot; The pattern did not match, and the line was not empty. It looks like&#xA;      &quot; there is no process exit message in this buffer.&#xA;      break&#xA;    elseif exitCode != ''&#xA;      return str2nr(exitCode)&#xA;    endif&#xA;  endwhile&#xA;  throw 'Could not determine exit status for buffer, ' . expand('%')&#xA;endfunc&#xA;&#xA;func! s:afterTermClose() abort&#xA;  if s:getExitStatus() == 0&#xA;    bdelete!&#xA;  endif&#xA;endfunc&#xA;&#xA;augroup MyNeoterm&#xA;  autocmd!&#xA;  &quot; The line '[Process exited ?]' is appended to the terminal buffer after the&#xA;  &quot; `TermClose` event. So we use a timer to wait a few milliseconds to read the&#xA;  &quot; exit status. Setting the timer to 0 or 1 ms is not sufficient; 20 ms seems&#xA;  &quot; to work for me.&#xA;  autocmd TermClose * call timer_start(20, { -&amp;gt; s:afterTermClose() })&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can target the event handler using a pattern in the &lt;code&gt;autocmd&lt;/code&gt;. For example if you only want the terminal window to close automatically when you run tests, and your test command is &lt;code&gt;make test&lt;/code&gt; then you can change the &lt;code&gt;autocmd&lt;/code&gt; to look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;autocmd TermClose *:make\ test call timer_start(20, { -&amp;gt; s:afterTermClose() })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you want the window to close when you exit your shell you can use this pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;autocmd TermClose *:$SHELL call timer_start(20, { -&amp;gt; s:afterTermClose() })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use multiple patterns separated by commas.&lt;/p&gt;&#xA;" OwnerUserId="18985" LastActivityDate="2018-09-14T15:59:47.273" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17389" PostTypeId="1" CreationDate="2018-09-16T01:40:08.527" Score="3" ViewCount="410" Body="&lt;p&gt;Yesterday I decided to encrypt my diary since it has some info that is private. My diary was a plain text doc called &lt;code&gt;diary&lt;/code&gt;.  There was no file called &lt;code&gt;d&lt;/code&gt; so I did the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vi -x d&#xA;Enter password: **********&#xA;Repeat password: **********&#xA;:r diary&#xA;:wq&#xA;$ vi d&#xA;Enter password: **********&#xA;:set cm=blowfish2&#xA;:wq&#xA;$ mv d diary&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All seemed fine, but today I tried &lt;code&gt;vi diary&lt;/code&gt; and entered the same password, and I get garbage.  What in the world could have happened?!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I doubt I could have mistyped my intended password &lt;strong&gt;3 times&lt;/strong&gt; (see above).  But perhaps I did... so I ran a script (&lt;a href=&quot;https://gist.github.com/lnolte/4135705&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gist.github.com/lnolte/4135705&lt;/a&gt;) that generated about 65 perturbations of my password in case I somehow mistyped it.  Then I tried all of these variants with a script I wrote, but nothing worked.  I also tried renaming &lt;code&gt;diary&lt;/code&gt; back to &lt;code&gt;d&lt;/code&gt; to see if the filename itself somehow mattered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that the above sequence of commands is really what I typed because they are still in my bash history. What else could be wrong?!  Perhaps the file is corrupted, but that's hard to imagine.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46)&#xA;Mac OS X&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18987" LastActivityDate="2018-09-19T07:32:44.467" Title="Lost an important doc with &quot;vi -x&quot;" Tags="|encryption|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17390" PostTypeId="1" AcceptedAnswerId="17413" CreationDate="2018-09-16T09:38:22.470" Score="1" ViewCount="1497" Body="&lt;p&gt;When I :q vim on my debian root account (not even writing), it always displays an error message:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E138: Can't write viminfo file $HOME/.viminfo!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.viminfo&lt;/code&gt; didn't exist, so I created it and checked the permissions of &lt;code&gt;/root&lt;/code&gt; and the file, but they were fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;drwx------  3 root root 4.0K Sep 16 11:13 .&#xA;-rw-r--r-- 1 root root 0 Sep 16 11:13 /root/.viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$HOME&lt;/code&gt; exists as an environment variable: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~ # echo $HOME&#xA;/root&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in vim &lt;code&gt;:!echo $HOME&lt;/code&gt; returns empty output. How can I get rid off this error, why isn't vim accepting $HOME?&lt;/p&gt;&#xA;" OwnerUserId="19008" LastActivityDate="2020-07-09T10:35:05.743" Title="E138: Can't write viminfo file $HOME/.viminfo! root $HOME not set in vim" Tags="|viminfo|linux-debian|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="17391" PostTypeId="1" CreationDate="2018-09-16T12:24:42.613" Score="2" ViewCount="539" Body="&lt;p&gt;I have a style element in an HTML file. When I type, NeoVim continuously indents each successive line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oO6BR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oO6BR.png&quot; alt=&quot;bad indentation&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my Vim, it works correctly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2q4GR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2q4GR.png&quot; alt=&quot;correct indentation&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;a href=&quot;https://github.com/zoliky/dotfiles/blob/master/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimrc&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be grateful for any suggestion. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="18231" LastEditorDisplayName="user579" LastEditDate="2018-09-20T13:19:57.740" LastActivityDate="2018-09-20T13:19:57.740" Title="NeoVim indents each property:value in CSS" Tags="|indentation|filetype-html|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17393" PostTypeId="1" CreationDate="2018-09-16T14:58:41.613" Score="1" ViewCount="711" Body="&lt;p&gt;I'm using basic version vimrc from &lt;a href=&quot;https://github.com/amix/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/amix/vimrc&lt;/a&gt;. No problem if I put my vimrc at &lt;code&gt;/home/{user}/.vimrc&lt;/code&gt;, but if I put it in &lt;code&gt;/etc/vimrc&lt;/code&gt; (arch) or &lt;code&gt;/etc/vim/vimrc&lt;/code&gt; (debian), it becomes a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is: I cannot use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;,&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then make a mapping that uses &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;tf :tabnew **/*    &quot;fuzzy search file and open in new tab&#xA;map &amp;lt;leader&amp;gt;tn :tabnew&amp;lt;cr&amp;gt;     &quot;open a blank new tab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or just mapping a &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;space&amp;gt; /&#xA;map &amp;lt;c-space&amp;gt; ?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At my arch workstation, I open vim from konsole. In my debian server, I ssh-ed to open it (so, a tty).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit (more information) with command &lt;code&gt;:map&lt;/code&gt; with global vimrc (from @statox link):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   0             ^&#xA;   &amp;lt;Leader&amp;gt;m   * mmHmt:%s/&amp;lt;C-V&amp;gt;&amp;lt;cr&amp;gt;//ge&amp;lt;cr&amp;gt;'tzt'm&#xA;v  &amp;lt;C-S-k&amp;gt;       :m'&amp;lt;-2&amp;lt;cr&amp;gt;`&amp;gt;my`&amp;lt;mzgv`yo`z&#xA;v  &amp;lt;C-S-j&amp;gt;       :m'&amp;gt;+&amp;lt;cr&amp;gt;`&amp;lt;my`&amp;gt;mzgv`yo`z&#xA;n  &amp;lt;C-S-k&amp;gt;       mz:m-2&amp;lt;cr&amp;gt;`z&#xA;n  &amp;lt;C-S-j&amp;gt;       mz:m+&amp;lt;cr&amp;gt;`z&#xA;   &amp;lt;leader&amp;gt;cd    :cd %:p:h&amp;lt;cr&amp;gt;:pwd&amp;lt;cr&amp;gt;&#xA;   &amp;lt;leader&amp;gt;te    :tabedit &amp;lt;c-r&amp;gt;=expand(&quot;%:p:h&quot;)&amp;lt;cr&amp;gt;/&#xA;   &amp;lt;leader&amp;gt;tf    :call fzf#run({'sink': 'tabedit'})&amp;lt;cr&amp;gt;&#xA;   &amp;lt;leader&amp;gt;tc    :tabclose&amp;lt;cr&amp;gt;&#xA;   &amp;lt;leader&amp;gt;tn    :tabnew&amp;lt;cr&amp;gt;&#xA;   &amp;lt;leader&amp;gt;tz    :tabnew **/*&#xA;n  &amp;lt;c-space&amp;gt;   * ?&#xA;n  &amp;lt;space&amp;gt;     * /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, most of the keys are not mapped correctly except a few like &lt;code&gt;map 0 ^&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;And this is &lt;code&gt;:map&lt;/code&gt; command when I drop the vimrc to &lt;code&gt;~/.vim/vimrc&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   0             ^&#xA;   ,m   * mmHmt:%s/&amp;lt;C-V&amp;gt;&amp;lt;cr&amp;gt;//ge&amp;lt;cr&amp;gt;'tzt'm&#xA;v  &amp;lt;C-S-k&amp;gt;       :m'&amp;lt;-2&amp;lt;cr&amp;gt;`&amp;gt;my`&amp;lt;mzgv`yo`z&#xA;v  &amp;lt;C-S-j&amp;gt;       :m'&amp;gt;+&amp;lt;cr&amp;gt;`&amp;lt;my`&amp;gt;mzgv`yo`z&#xA;n  &amp;lt;C-S-k&amp;gt;       mz:m-2&amp;lt;cr&amp;gt;`z&#xA;n  &amp;lt;C-S-j&amp;gt;       mz:m+&amp;lt;cr&amp;gt;`z&#xA;   ,cd    :cd %:p:h&amp;lt;cr&amp;gt;:pwd&amp;lt;cr&amp;gt;&#xA;   ,te    :tabedit &amp;lt;c-r&amp;gt;=expand(&quot;%:p:h&quot;)&amp;lt;cr&amp;gt;/&#xA;   ,tf    :call fzf#run({'sink': 'tabedit'})&amp;lt;cr&amp;gt;&#xA;   ,tc    :tabclose&amp;lt;cr&amp;gt;&#xA;   ,tn    :tabnew&amp;lt;cr&amp;gt;&#xA;   ,tz    :tabnew **/*&#xA;n  &amp;lt;c-space&amp;gt;   * ?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19014" OwnerDisplayName="tonny" LastEditorUserId="10604" LastEditDate="2019-12-11T22:08:38.267" LastActivityDate="2020-01-10T23:02:45.397" Title="Cannot set (let) mapleader and use &lt;leader&gt; in global vimrc" Tags="|vimrc|key-bindings|linux-arch|linux-debian|" AnswerCount="2" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="17394" PostTypeId="1" CreationDate="2018-09-17T03:41:09.087" Score="3" ViewCount="83" Body="&lt;p&gt;If I want to setup a &lt;code&gt;TabClosed&lt;/code&gt; autocmd for a specific tab page only, what should I do? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I use the &lt;code&gt;autocmd {pat}&lt;/code&gt; argument? Is this &lt;code&gt;{pat}&lt;/code&gt; still matched against the filename?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover, the &lt;code&gt;t:&lt;/code&gt; variable is associated with the tab page that is going to be entered, not the tab page that is closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I know that &lt;code&gt;&amp;lt;afile&amp;gt;&lt;/code&gt; can be used as the tab page number, but tab page can be moved around after the &lt;code&gt;autocmd&lt;/code&gt; is set. So a tab page nr may not work. Is there a concept as &lt;code&gt;tab page id&lt;/code&gt; like the &lt;code&gt;winid&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-09-18T00:43:40.087" LastActivityDate="2018-09-18T00:43:40.087" Title="the matching pattern for TabClosed autocmd" Tags="|autocmd|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17395" PostTypeId="2" ParentId="16841" CreationDate="2018-09-17T04:26:39.480" Score="2" Body="&lt;p&gt;Try the following solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Leader&amp;gt;d  :enew \| bd#&amp;lt;Return&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Limitation: you can not run this on unnamed buffer without affecting the split. If this is a concern, you may want to replace &lt;code&gt;enew&lt;/code&gt; with &lt;code&gt;e .&lt;/code&gt; etc.&lt;/p&gt;&#xA;" OwnerUserId="1782" LastEditorUserId="1782" LastEditDate="2018-09-17T04:31:51.337" LastActivityDate="2018-09-17T04:31:51.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17396" PostTypeId="1" AcceptedAnswerId="17421" CreationDate="2018-09-17T18:00:06.103" Score="3" ViewCount="77" Body="&lt;p&gt;I would like to make Vim behave a little more like the less(1) pager: if I scroll to the bottom of the document (e.g. using &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;F&lt;/kbd&gt;), I want the last line of the file to be displayed at the bottom of the screen, not any higher. Is there a setting that will get me this behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there isn’t a setting, I imagine I could rig up some kind of mapping where &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;F&lt;/kbd&gt; behaves like &lt;kbd&gt;G&lt;/kbd&gt;&lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;b&lt;/kbd&gt; when the last line is visible after scrolling. But of course a built-in setting would be preferable!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This is sort of the opposite of &lt;a href=&quot;https://vi.stackexchange.com/q/7699/671&quot;&gt;this question&lt;/a&gt; and &lt;a href=&quot;https://stackoverflow.com/questions/7406814/in-vim-how-do-you-scroll-a-buffer-so-the-cursor-location-is-centered-in-the-scr&quot;&gt;this question&lt;/a&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="671" LastActivityDate="2018-12-18T18:04:00.733" Title="Keeping the window filled with the document" Tags="|scrolling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17397" PostTypeId="2" ParentId="17393" CreationDate="2018-09-17T20:06:06.770" Score="0" Body="&lt;p&gt;I'll list my alternative ideas that doesn't solve the actual problem:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;put the vimrc file elsewhere (prefer in &lt;code&gt;/etc/skel/.vim/vimrc&lt;/code&gt;) then make a softlink to local &lt;code&gt;.vim/vimrc&lt;/code&gt;. The command: &lt;code&gt;mkdir .vim &amp;amp;&amp;amp; sudo ln -s /etc/skel/.vim/vimrc .vim/vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19014" LastActivityDate="2018-09-17T20:06:06.770" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17398" PostTypeId="1" AcceptedAnswerId="17406" CreationDate="2018-09-17T21:33:55.290" Score="4" ViewCount="1700" Body="&lt;p&gt;When I start vi/vim as &lt;code&gt;ex&lt;/code&gt;, I can use the &lt;code&gt;-c&lt;/code&gt; option to provide the set of &lt;em&gt;ex&lt;/em&gt; commands to apply to a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo Yes | ex -sc 's/Y/y/|%p|q!' /dev/stdin&#xA;yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how can I use &lt;em&gt;normal mode&lt;/em&gt; commands like the &lt;code&gt;~&lt;/code&gt; (switch case command) with &lt;code&gt;ex&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="19031" LastEditorUserId="19031" LastEditDate="2018-09-18T08:44:51.867" LastActivityDate="2018-09-18T09:02:40.600" Title="How to use normal mode commands in ex mode?" Tags="|normal-mode|ex-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17399" PostTypeId="2" ParentId="5205" CreationDate="2018-09-17T21:40:03.217" Score="19" Body="&lt;p&gt;The &lt;a href=&quot;https://vimhelp.appspot.com/various.txt.html#:filter&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:filter&lt;/code&gt;&lt;/a&gt; command is a simple, one-line approach to this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:filter /indent/ scriptnames&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This would show &lt;em&gt;only&lt;/em&gt; lines matching the pattern &lt;code&gt;indent&lt;/code&gt; from the output of the &lt;code&gt;:scriptnames&lt;/code&gt; command.&lt;/p&gt;&#xA;&lt;p&gt;Unusually, &lt;code&gt;:filter&lt;/code&gt; does &lt;strong&gt;not&lt;/strong&gt; observe either &lt;code&gt;'ignorecase'&lt;/code&gt; or &lt;code&gt;'smartcase'&lt;/code&gt; and will always search in a case-&lt;strong&gt;sensitive&lt;/strong&gt; manner. To override this, prepend &lt;code&gt;\c&lt;/code&gt; to your search pattern, e.g.:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:filter /\cindent/ scriptnames&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2Fignorecase&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h \c&lt;/code&gt;&lt;/a&gt; for more info.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I see &lt;code&gt;:redir&lt;/code&gt;-oriented solutions to questions like these often, which are fine and offer a lot of power and options, but I feel they're a bit overkill when more often than not, you just need to quickly check if something is there. &lt;code&gt;:filter&lt;/code&gt; is convenient to use in the moment and dead simple.&lt;/p&gt;&#xA;" OwnerUserId="1452" LastEditorUserId="1452" LastEditDate="2020-09-22T20:01:21.467" LastActivityDate="2020-09-22T20:01:21.467" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17400" PostTypeId="1" AcceptedAnswerId="17402" CreationDate="2018-09-17T23:10:25.833" Score="3" ViewCount="917" Body="&lt;p&gt;I would like to know if there is some way to color different comments in python inside VIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Today I use wombat256mod and I would like to color in red comments that start with double ## and color with gray the ones that start with a single #&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, it would differentiate to me that a ## means an English comment to help understand the code, while the # would just disable a statement in python.&lt;/p&gt;&#xA;" OwnerUserId="19033" LastActivityDate="2018-09-18T04:35:21.597" Title="Different color for comments with one # and two ## in python" Tags="|colorscheme|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17401" PostTypeId="1" CreationDate="2018-09-18T02:16:10.773" Score="1" ViewCount="32" Body="&lt;p&gt;I am trying to  map the key Alt+j in vimrc to adjust the height of the window: &#xA;&lt;code&gt;&#xA;tnoremap &amp;lt;A-j&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;5&amp;lt;C-w&amp;gt;-i&#xA;nnoremap &amp;lt;A-j&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;5&amp;lt;C-w&amp;gt;-&#xA;&lt;/code&gt;&#xA;But it seems not to work. What is the correct way to do this?&lt;/p&gt;&#xA;" OwnerUserId="18259" LastActivityDate="2018-09-18T02:16:10.773" Title="How could I map Alt on linux" Tags="|vimrc|key-bindings|" AnswerCount="0" CommentCount="2" ClosedDate="2018-09-18T06:57:30.037" ContentLicense="CC BY-SA 4.0" />
  <row Id="17402" PostTypeId="2" ParentId="17400" CreationDate="2018-09-18T04:35:21.597" Score="1" Body="&lt;p&gt;You could do this with the &lt;code&gt;syntax&lt;/code&gt; and &lt;code&gt;highlight&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Step 1&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;First, we need to give a regex to match the correct lines, and name each &quot;group&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match comment /^##.*/ &#xA;syn match disabled /^##\@!.*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first regex is pretty simple. &quot;Any line starting with two '#' characters&quot;. The second regex is slightly more complicated. &quot;Any line starting with a '#', and not followed by another '#'&quot;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Step 2&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Now we just tell vim what to color text that matches these groups.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi disabled guifg=gray ctermfg=gray&#xA;hi comment guifg=red ctermfg=red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;guifg&quot; means &quot;the color of the text (foreground) in the gui&quot;, and &quot;ctermfg&quot; means &quot;the color of the text (foreground) in the terminal&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you could choose a different name then &quot;disabled&quot; and &quot;comment&quot;. That's up to you.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-09-18T04:35:21.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17403" PostTypeId="1" AcceptedAnswerId="17408" CreationDate="2018-09-18T07:35:04.427" Score="0" ViewCount="1064" Body="&lt;p&gt;In my code, something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;whatever&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is highlighted: &lt;code&gt;#include&lt;/code&gt; (which belongs to the group 'cInclude') in pink; and &lt;code&gt;&amp;lt;whatever&amp;gt;&lt;/code&gt; (belonging to the group 'cIncluded') in red.&#xA;(&lt;strong&gt;Edit&lt;/strong&gt;: &lt;code&gt;whatever&lt;/code&gt; is any word.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, to highlight the word &lt;code&gt;vector&lt;/code&gt; according to the 'Type' style (in green) I do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd('Type','\&amp;lt;vector\&amp;gt;',0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;code&gt;0&lt;/code&gt; sets the priority to a low value. With this, my intention is that in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;vector&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;, &lt;code&gt;&amp;lt;vector&amp;gt;&lt;/code&gt; is highlighted according to the group 'cIncluded', and &lt;strong&gt;not&lt;/strong&gt; according to the group 'Type'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unexpectedly, I do not get that result. The highlight for &lt;code&gt;&amp;lt;vector&amp;gt;&lt;/code&gt; in &lt;code&gt;#include &amp;lt;vector&amp;gt;&lt;/code&gt; turns out to be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;&lt;/code&gt; in red (as in the group 'cIncluded')&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vector&lt;/code&gt; in green (as in the group 'Type')&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;gt;&lt;/code&gt; in red (as in the group 'cIncluded')&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why?&lt;/p&gt;&#xA;" OwnerUserId="6023" LastEditorUserId="6023" LastEditDate="2018-09-18T09:25:07.967" LastActivityDate="2018-09-18T12:17:35.210" Title="Priority highlighting" Tags="|syntax-highlighting|highlight|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17404" PostTypeId="1" AcceptedAnswerId="17405" CreationDate="2018-09-18T08:07:18.367" Score="2" ViewCount="109" Body="&lt;p&gt;They both seem to move the cursor to the first non-blank character of the current line and I wonder what was the reason for duplicating this functionality&lt;/p&gt;&#xA;" OwnerUserId="19035" LastActivityDate="2018-09-18T08:20:39.960" Title="What is the difference between ^ and _ for cursor movement" Tags="|cursor-movement|normal-mode|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17405" PostTypeId="2" ParentId="17404" CreationDate="2018-09-18T08:20:39.960" Score="5" Body="&lt;p&gt;Hello and welcome to this site!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help left-right-motions&lt;/code&gt; is your friend here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference is that &lt;code&gt;_&lt;/code&gt; accepts a &lt;code&gt;[count]&lt;/code&gt; &lt;em&gt;before&lt;/em&gt; it, citing the manual:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_  &amp;lt;underscore&amp;gt;         [count] - 1 lines downward, on the first non-blank&#xA;                        character linewise.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;while:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^                       To the first non-blank character of the line.&#xA;                        exclusive motion.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, &lt;code&gt;_&lt;/code&gt; by itself is equivalent to &lt;code&gt;1_&lt;/code&gt;, so the outcome is &lt;em&gt;0 lines downward, on the first non-blank character linewise&lt;/em&gt;, which means the current line (just like &lt;code&gt;^&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="7881" LastActivityDate="2018-09-18T08:20:39.960" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17406" PostTypeId="2" ParentId="17398" CreationDate="2018-09-18T08:49:12.567" Score="5" Body="&lt;p&gt;Based on a comment by @statox, I found a solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo 'Élève' | ex -sc 'norm! g~w' -c '%p|q!' /dev/stdin&#xA;éLÈVE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/various.html#:normal&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;norm&lt;/code&gt;&lt;/a&gt; command allows executing Normal mode commands.&#xA;And I had to use two &lt;code&gt;-c&lt;/code&gt; option since, after &lt;code&gt;norm&lt;/code&gt;, the rest of the line is considered part of the normal-mode command to execute.&lt;/p&gt;&#xA;" OwnerUserId="19031" LastEditorUserId="19031" LastEditDate="2018-09-18T09:02:40.600" LastActivityDate="2018-09-18T09:02:40.600" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17407" PostTypeId="2" ParentId="5050" CreationDate="2018-09-18T09:02:56.813" Score="6" Body="&lt;p&gt;I've created a &lt;a href=&quot;https://github.com/micarmst/vim-spellsync&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim plugin&lt;/a&gt; for this. It finds the path to the spell folders automatically and then calls &lt;code&gt;mkspell&lt;/code&gt; on any word lists it finds at startup to regenerate the spell files.  It also creates &lt;code&gt;.gitignore&lt;/code&gt; and &lt;code&gt;.gitattributes&lt;/code&gt; files in the spell directories to exclude binary spell files and to use Git's &lt;a href=&quot;https://web.archive.org/web/20181009034917/https://krlmlr.github.io/using-gitattributes-to-avoid-merge-conflicts/&quot; rel=&quot;nofollow noreferrer&quot;&gt;union merge driver&lt;/a&gt; to avoid conflicts when merging spell files from two different machines. Thanks to &lt;a href=&quot;https://vi.stackexchange.com/a/5052/19028&quot;&gt;Sato Katsura&lt;/a&gt; for the &lt;code&gt;mkspell&lt;/code&gt; example.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/micarmst/vim-spellsync&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/micarmst/vim-spellsync&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19028" LastEditorUserId="19028" LastEditDate="2022-05-15T15:02:46.770" LastActivityDate="2022-05-15T15:02:46.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17408" PostTypeId="2" ParentId="17403" CreationDate="2018-09-18T09:14:10.257" Score="3" Body="&lt;p&gt;From &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#matchadd()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;help matchadd&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Syntax highlighting (see 'syntax') is a separate&#xA;  mechanism, and regardless of the chosen priority a match will&#xA;  always overrule syntax highlighting.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To match everywhere except certain contexts, you can use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/zero-width&quot; rel=&quot;nofollow noreferrer&quot;&gt;zero-width atoms&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd('Type', '\(#include &amp;lt;\)\@&amp;lt;!\&amp;lt;vector\&amp;gt;')&#xA;:call matchadd('Type', '\&amp;lt;vector\&amp;gt;\(&amp;gt;\)\@!')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first matches the complete word &lt;code&gt;vector&lt;/code&gt; if not preceded by &lt;code&gt;#include &amp;lt;&lt;/code&gt;, and the second matches when it's not followed by &lt;code&gt;&amp;gt;&lt;/code&gt;.  Together, these should cover all occurrences of the word other than inside &lt;code&gt;#include &amp;lt;vector&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7600" LastEditorUserId="7600" LastEditDate="2018-09-18T09:32:05.253" LastActivityDate="2018-09-18T09:32:05.253" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17410" PostTypeId="2" ParentId="17403" CreationDate="2018-09-18T12:17:35.210" Score="4" Body="&lt;p&gt;I would consider using syntax matching instead of &lt;code&gt;matchadd()&lt;/code&gt; for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match Type /\&amp;lt;vector\&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because you are &lt;em&gt;not&lt;/em&gt; specifying &lt;code&gt;containedin&lt;/code&gt;, this will not match inside the &lt;code&gt;cIncluded&lt;/code&gt; group that already exists. See &lt;code&gt;:help :syn-containedin&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-09-18T12:17:35.210" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17411" PostTypeId="2" ParentId="17386" CreationDate="2018-09-18T14:00:45.427" Score="1" Body="&lt;p&gt;NERDTree provides two command that basically can be used to make it disappear: &lt;code&gt;:NERDTreeClose&lt;/code&gt; and &lt;code&gt;:NERDTreeToggle&lt;/code&gt;. Can you try them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NERDTree buffer is unlisted -- which can be confirmed by indicator &lt;code&gt;u&lt;/code&gt; when you type &lt;code&gt;:buffers!&lt;/code&gt; . That means it is normally not included in &lt;code&gt;:bprevious&lt;/code&gt; and &lt;code&gt;:bnext&lt;/code&gt;. So just by  making its window disappear using two commands above is sufficient I guess.&lt;/p&gt;&#xA;" OwnerUserId="1782" LastEditorUserId="1782" LastEditDate="2018-09-18T14:09:35.810" LastActivityDate="2018-09-18T14:09:35.810" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17413" PostTypeId="2" ParentId="17390" CreationDate="2018-09-18T18:02:06.617" Score="0" Body="&lt;p&gt;I guess this is some kind of weird bug in the vim stable release, since I installed vim from testing and it just works without further ado.&lt;/p&gt;&#xA;" OwnerUserId="19008" LastActivityDate="2018-09-18T18:02:06.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17415" PostTypeId="2" ParentId="17389" CreationDate="2018-09-19T05:23:08.893" Score="3" Body="&lt;p&gt;With Blowfish2, you may well be screwed. While the &lt;code&gt;zip&lt;/code&gt; cryptmethod has been shown to be relatively insecure, Blowfish2 is almost certainly going to be much harder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can't figure out which password you used, my only suggestion would be to revert to your most recent backup and go from there. And, if you don't &lt;em&gt;have&lt;/em&gt; a backup, use this as a learning opportunity (sorry if I sound harsh here, it's not my intent).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mac OS (which you appear to be on) make this very easy by providing &lt;code&gt;Time Machine&lt;/code&gt; for exactly this purpose, and setting this up with a 1TB external drive was the &lt;em&gt;first&lt;/em&gt; thing I did when my son broke my heart by wanting a Mac for his school work :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the bare &lt;em&gt;minimum,&lt;/em&gt; it would have been wise to keep the unencrypted file for a few day.&lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastEditorDisplayName="user579" LastEditDate="2018-09-19T07:32:44.467" LastActivityDate="2018-09-19T07:32:44.467" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17416" PostTypeId="1" AcceptedAnswerId="17417" CreationDate="2018-09-19T08:20:04.673" Score="1" ViewCount="878" Body="&lt;p&gt;I am new to vim and I want to code in vim. I have installed the necessary plugins for syntax highlighting JSX in TypeScript and everything works fine for GUI version of Vim but not for terminal-based Vim. Please help me figure out the issue. Below are the plugins that I am using for syntax highlighting:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;For TypeScript: &lt;a href=&quot;https://github.com/leafgarland/typescript-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/leafgarland/typescript-vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;For JSX in TypeScript: &lt;a href=&quot;https://github.com/peitalin/vim-jsx-typescript&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/peitalin/vim-jsx-typescript&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I am using Vundle to install plugins. I tried to make some customizations in the colors as given in the README section of the second plugin mentioned above. According to that when I used the &lt;code&gt;hi&lt;/code&gt; command, it did not have any effect on terminal-based Vim but it worked perfectly fine on GUI based Vim. I am trying to setup syntax highlight for JSX in TypeScript for React Development and I have installed above plugins to achieve that. Below is the content of my .vimrc file.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible                &amp;quot; choose no compatibility with legacy vi syntax enable&#xA;set encoding=utf-8&#xA;set showcmd                     &amp;quot; display incomplete commands&#xA;set t_Co=256&#xA;filetype plugin indent on       &amp;quot; load file type plugins + indentation&#xA;&#xA;&amp;quot;&amp;quot; monkai theme&#xA;syntax enable&#xA;colorscheme monokai&#xA;&#xA;set nu&#xA;set guifont=monacob\ bold\ 9&#xA;&#xA;highlight ColorColumn ctermbg=gray&#xA;set colorcolumn=80&#xA;&#xA;&amp;quot;&amp;quot; Whitespace&#xA;set nowrap                      &amp;quot; don't wrap lines&#xA;set tabstop=2 shiftwidth=2      &amp;quot; a tab is two spaces (or set this to 4)&#xA;set expandtab                   &amp;quot; use spaces, not tabs (optinal)&#xA;set backspace=indent,eol,start  &amp;quot; backspace through everything in insert mode&#xA;&#xA;&amp;quot;&amp;quot; Searching&#xA;set hlsearch                    &amp;quot; highlight matches&#xA;set incsearch                   &amp;quot; incremental searching&#xA;set ignorecase                  &amp;quot; searches are case insensitive...&#xA;set smartcase                   &amp;quot; ... unless they contain at least one capital letter&#xA;&#xA;&amp;quot; set the runtime path to include Vundle and initialize&#xA;set rtp +=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&amp;quot; alternatively, pass a path where Vundle should install plugins&#xA;&amp;quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&amp;quot; let Vundle manage Vundle, required&#xA;Plugin 'gmarik/Vundle.vim'&#xA;Plugin 'tpope/vim-fugitive.git'&#xA;Plugin 'tpope/vim-rails'&#xA;Plugin 'leafgarland/typescript-vim'&#xA;Plugin 'peitalin/vim-jsx-typescript'&#xA;&amp;quot; The following are examples of different formats supported.&#xA;&amp;quot; Keep Plugin commands between vundle#begin/end.&#xA;&#xA;&amp;quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &amp;quot; required&#xA;filetype plugin indent on    &amp;quot; required&#xA;&amp;quot; autocmd FileType typescript.tsx setlocal commentstring={/*\ %s\ */}&#xA;autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescript.tsx&#xA;autocmd BufNewFile,BufRead *.ts,*.js set filetype=typescript.jsx&#xA;&#xA;&amp;quot; dark red&#xA;hi tsxTagName guifg=#E06C75&#xA;&#xA;&amp;quot; orange&#xA;hi tsxCloseString guifg=#F99575&#xA;hi tsxCloseTag guifg=#F99575&#xA;hi tsxAttributeBraces guifg=#F99575&#xA;hi tsxEqual guifg=#F99575&#xA;&#xA;&amp;quot; yellow&#xA;hi tsxAttrib guifg=#F8BD7F cterm=italic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Below is the screenshot of the JSX syntax highlight in GUI version of Vim&#xA;&lt;a href=&quot;https://i.stack.imgur.com/kkpZL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kkpZL.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Below is the screenshot of the JSX syntax highlight in terminal version Vim&#xA;&lt;a href=&quot;https://i.stack.imgur.com/LetCR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LetCR.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As we can see in the .vimrc and screenshots, the JSX tag colors etc.. declared at the end of the file are working fine for Gvim but not working for terminal-based vim. Please help me understand what wrong I am doing here.&lt;/p&gt;&#xA;" OwnerUserId="19047" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-01-11T14:06:54.677" Title="Syntax highlight works for gvim but not for terminal vim" Tags="|syntax-highlighting|gvim|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17417" PostTypeId="2" ParentId="17416" CreationDate="2018-09-19T08:57:41.873" Score="4" Body="&lt;p&gt;&lt;code&gt;guifg&lt;/code&gt; or &lt;code&gt;guibg&lt;/code&gt; only works for GUI vim. For terminal version you will need to add other attributes: &lt;code&gt;ctermfg&lt;/code&gt;, &lt;code&gt;ctermbg&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Type &lt;code&gt;:highlight&lt;/code&gt; without any attributes in your vim to show currenly set color settings. &lt;/p&gt;&#xA;" OwnerUserId="1782" LastEditorUserId="343" LastEditDate="2018-09-19T09:05:33.877" LastActivityDate="2018-09-19T09:05:33.877" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17418" PostTypeId="1" AcceptedAnswerId="17420" CreationDate="2018-09-19T09:57:41.220" Score="2" ViewCount="569" Body="&lt;p&gt;I have line to split window at start:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au VimEnter * vsplit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But sometimes it's annoying because I'm opening vim in small terminal, in this case I'd like to not split my window. I've tried this construction but it's not executing at start&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if winwidth('%') &amp;gt;= 100&#xA;  au VimEnter * vsplit&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to execute spit window depending on window size?&lt;/p&gt;&#xA;" OwnerUserId="8709" LastEditorUserId="8709" LastEditDate="2018-09-19T20:08:53.683" LastActivityDate="2018-09-19T20:08:53.683" Title="Conditional window split" Tags="|neovim|vim-windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17419" PostTypeId="2" ParentId="17418" CreationDate="2018-09-19T10:22:29.663" Score="7" Body="&lt;p&gt;You need to check the 'winwidth' result at the time the hook is run, not when it's defined.  You can do this by putting it in a new function and calling that from the hook:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Widevsplit()&#xA;  if winwidth('%') &amp;gt;= 100&#xA;    vsplit&#xA;  endif&#xA;endfunction&#xA;&#xA;au VimEnter * call Widevsplit()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7600" LastActivityDate="2018-09-19T10:22:29.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17420" PostTypeId="2" ParentId="17418" CreationDate="2018-09-19T10:23:15.437" Score="7" Body="&lt;p&gt;Try moving the &lt;code&gt;if&lt;/code&gt; into the autocommand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au VimEnter * if winwidth('%') &amp;gt;= 100 | vsplit | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-09-19T10:23:15.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17421" PostTypeId="2" ParentId="17396" CreationDate="2018-09-19T17:16:22.943" Score="1" Body="&lt;p&gt;There is a &lt;em&gt;workaround&lt;/em&gt; to achieve this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set scrolloff=999&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1782" LastActivityDate="2018-09-19T17:16:22.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17422" PostTypeId="1" CreationDate="2018-09-19T20:24:50.887" Score="1" ViewCount="203" Body="&lt;p&gt;How can I change the color scheme of an installed Theme?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently have gruvbox installed and I would like to change the color of node.js keyword 'import' from aqua to orange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To no avail, I have edited the gruvbox.vim file to include: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi! link javascriptImport GruvboxOrange&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi! link javascriptImport GruvboxAqua&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19057" LastEditorUserId="2920" LastEditDate="2018-09-19T21:32:12.017" LastActivityDate="2018-09-19T21:32:12.017" Title="Overwrite Vim theme color scheme" Tags="|colorscheme|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17423" PostTypeId="1" AcceptedAnswerId="17440" CreationDate="2018-09-19T21:32:48.313" Score="4" ViewCount="124" Body="&lt;p&gt;I often am editing a file (e.g., a zone file) where I have things like: &lt;code&gt;Whatever-AP-1&lt;/code&gt; and want to quickly change it to &lt;code&gt;Whatever-AP-2&lt;/code&gt;. It feels right to hit Control-A (increment), but of course Control-X (decrement) is required, because Vim sees that as a negative number. Just swapping the mapping, however, won't work because then e.g., IP addresses would be backwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can think of two solutions that would be fine, and (at least for me) not really break Control-A/X elsewhere:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Have increment increase the absolute value, decrement decrease it (control-X on 0 would do nothing — or I guess skip to the next number). Control-A on -1 givces -2; on +1, gives +2.&lt;/li&gt;&#xA;&lt;li&gt;Not treat hyphenated numbers as negative. Only recognize a hyphen/minus character as a negative sign if its preceded by whitespace, a symbol, or beginning of line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think I'd prefer the later; but either is OK—especially if there is just an option I missed, not having to re-implement increment/decrement in vimscript (like swapit, monday, speeddating, etc. all do).&lt;/p&gt;&#xA;" OwnerUserId="31" LastActivityDate="2018-09-20T23:47:56.400" Title="Make Control-A and Control-X work better for host names and the like" Tags="|normal-mode|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17424" PostTypeId="2" ParentId="17391" CreationDate="2018-09-19T22:39:52.563" Score="3" Body="&lt;p&gt;This particular issue seems to have come up more than once:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/1912132/messy-css-indentation-in-vim&quot;&gt;A 2009 Stack Overflow question&lt;/a&gt;*&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.reddit.com/r/vim/comments/8ptng4/broken_css_indenting_inside_stylestyle_tags_in_vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;A post&lt;/a&gt; in &lt;a href=&quot;https://reddit.com/r/vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;the Vim subreddit&lt;/a&gt; from just a few months ago&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Unfortunately the replies and answers mostly consist of non-solutions (suggesting to turn off &lt;code&gt;filetype&lt;/code&gt; entirely) or workarounds (&lt;code&gt;set indentkeys+=;&lt;/code&gt;). After a lot of digging, I gained more useful knowledge.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Quick History&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The current &lt;code&gt;indent/html.vim&lt;/code&gt; that ships with the (Neo)Vim runtime is a fork of &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2075&quot; rel=&quot;nofollow noreferrer&quot;&gt;Andy Wokula's indent file&lt;/a&gt;. This fork was &lt;a href=&quot;https://github.com/vim/vim/commit/8bb1c3e53ef0ee259cfa5f9b3a3a91ec1fa90fb0#diff-c5802b9fe6ca7e175ecf7f5f3bea690e&quot; rel=&quot;nofollow noreferrer&quot;&gt;originally created and is currently maintained by Bram himself&lt;/a&gt; in 2014. &lt;strong&gt;It is this overhaul where this CSS-indentation bug was first introduced;&lt;/strong&gt; Andy's original HTML indent file did not have this indentation issue. Ever since then, it has remained.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;...Until very recently!&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A &lt;a href=&quot;https://github.com/vim/vim/commit/fc65cabb15d0236bce001ad78e12a40511caf941#diff-c5802b9fe6ca7e175ecf7f5f3bea690e&quot; rel=&quot;nofollow noreferrer&quot;&gt;very recent upstream commit&lt;/a&gt; (22 days ago from the time of writing) included an update to &lt;code&gt;indent/html.vim&lt;/code&gt; &lt;strong&gt;that fixes the CSS-indentation&lt;/strong&gt;. Adding this upstream version to &lt;code&gt;~/&amp;lt;vimfiles&amp;gt;/indent&lt;/code&gt; and reproducing the example in your question gives the desired behavior.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Solution&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Add the &lt;a href=&quot;https://github.com/vim/vim/blob/fc65cabb15d0236bce001ad78e12a40511caf941/runtime/indent/html.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;indent/html.vim&lt;/code&gt;&lt;/a&gt; from the current Vim upstream to your vimfiles:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Neovim&lt;/strong&gt;: &lt;code&gt;~/.config/nvim/indent&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Vim&lt;/strong&gt;: &lt;code&gt;~/.vim/indent&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And of course, make sure that &lt;code&gt;filetype plugin indent on&lt;/code&gt; exists somewhere in your configuration.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;* This question predates the overhaul fork in 2014, but presents the same symptoms. Perhaps the &lt;a href=&quot;https://github.com/vim/vim/blob/9964e468c0209f6b8286e0b08109817c845a3079/runtime/indent/html.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;2007 version&lt;/a&gt; happened to have the same issue?&lt;/p&gt;&#xA;" OwnerUserId="1452" LastActivityDate="2018-09-19T22:39:52.563" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17425" PostTypeId="2" ParentId="184" CreationDate="2018-09-19T22:48:33.393" Score="4" Body="&lt;p&gt;I added a autocmd to my .vimrc that removes the highlighting anytime you enter insert mode. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; autocmd InsertEnter * :let @/=&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19060" LastActivityDate="2018-09-19T22:48:33.393" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17426" PostTypeId="2" ParentId="10613" CreationDate="2018-09-20T00:22:07.300" Score="0" Body="&lt;p&gt;If you have &lt;code&gt;bling/vim-bufferline&lt;/code&gt; installed, you can disable the echoing of the buffer line to command line, by setting:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:bufferline_echo = 0&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;in your .vimrc. This is set to 1 by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, to hide the file mode and ruler from command line, you can just set:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set shortmess=F&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in your .vimrc.&lt;/p&gt;&#xA;" OwnerUserId="18646" LastActivityDate="2018-09-20T00:22:07.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17427" PostTypeId="2" ParentId="7694" CreationDate="2018-09-20T01:26:36.190" Score="1" Body="&lt;p&gt;This is &lt;em&gt;possibly&lt;/em&gt; an issue with &lt;a href=&quot;https://en.wikipedia.org/wiki/Dead_key&quot; rel=&quot;nofollow noreferrer&quot;&gt;dead keys&lt;/a&gt;, a way of using a &quot;regular&quot; keyboard to provide a way to generate diacrtics such as: &lt;code&gt;á&lt;/code&gt;, &lt;code&gt;í&lt;/code&gt;, or &lt;code&gt;ó&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to test this would be to enter &lt;code&gt;'a&lt;/code&gt; in your terminal proper (rather than &lt;code&gt;vim&lt;/code&gt; &lt;em&gt;within&lt;/em&gt; your terminal) and see what character is produced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it &lt;em&gt;does&lt;/em&gt; produce a diacritic, that means the terminal may well be getting to the keyboard stream before &lt;code&gt;vim&lt;/code&gt; does, and all &lt;code&gt;vim&lt;/code&gt; will see is the diacritic rather than the expected key sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that is the case, you could opt to &lt;a href=&quot;https://stackoverflow.com/questions/455799/how-can-i-eliminate-dead-keys-on-mac-os-x-with-international-keyboard&quot;&gt;switch to another terminal&lt;/a&gt; which better allows you to control this, or there is at least one &lt;a href=&quot;https://vi.stackexchange.com/questions/803/using-marks-with-dead-keys&quot;&gt;solution&lt;/a&gt; here which sneakily map the diacritic back into the correct key sequence that &lt;code&gt;vim&lt;/code&gt; will process.&lt;/p&gt;&#xA;" OwnerDisplayName="user579" LastActivityDate="2018-09-20T01:26:36.190" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17428" PostTypeId="1" AcceptedAnswerId="17429" CreationDate="2018-09-19T15:47:32.477" Score="1" ViewCount="530" Body="&lt;p&gt;I have a few hotkeys mapped in my .vimrc (see below) for compiling and running autohotkey scripts but I can either be annoyed by the quest for the &lt;kbd&gt;any&lt;/kbd&gt; key or I can run them &lt;code&gt;silent&lt;/code&gt; and be unaware if there are errors.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd filetype autohotkey nnoremap &amp;lt;S-F5&amp;gt; :w &amp;lt;bar&amp;gt; silent exec '!&quot;C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe&quot; /in '.shellescape('%')&amp;lt;CR&amp;gt;&#xA;autocmd filetype autohotkey nnoremap &amp;lt;C-F5&amp;gt; :w &amp;lt;bar&amp;gt; silent exec '!&quot;C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe&quot; /in '.shellescape('%').' &amp;amp;&amp;amp; start .\'.shellescape('%:r')&amp;lt;CR&amp;gt;&#xA;autocmd filetype autohotkey nnoremap &amp;lt;S-F6&amp;gt; :silent exec '!Taskkill /IM '.shellescape('%:r').'.exe /F'&amp;lt;CR&amp;gt;&#xA;autocmd filetype autohotkey nnoremap &amp;lt;C-S-F5&amp;gt; :silent exec '!Taskkill /IM '.shellescape('%:r').'.exe /F' &amp;lt;bar&amp;gt; silent exec '!&quot;C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe&quot; /in '.shellescape('%').' &amp;amp;&amp;amp; start .\'.shellescape('%:r')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;How do I have these &lt;code&gt;exec&lt;/code&gt; commands keep the cmd window open &lt;em&gt;only&lt;/em&gt; if there is an error?&lt;/b&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(e.g. if I run the &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;F5&lt;/kbd&gt; and the compiled version is already running, the compile will fail because it can't write to the .exe. (Yes, I know in that particular case there's an evil modal popup but in other cases, there's not good feedback of failure.))&lt;/p&gt;&#xA;" OwnerUserId="17361" OwnerDisplayName="Still.Tony" LastEditorUserId="51" LastEditDate="2018-09-20T17:42:10.013" LastActivityDate="2018-09-20T17:42:10.013" Title="How to un-silent exec in vim only if there is an error?" Tags="|autocmd|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17429" PostTypeId="2" ParentId="17428" CreationDate="2018-09-19T16:19:04.647" Score="4" Body="&lt;p&gt;If the AutoHotkey compiler properly reports its success via the &lt;em&gt;exit status&lt;/em&gt; (I haven't checked), you can keep the &lt;code&gt;:silent&lt;/code&gt; and just delay the closing of the command prompt by executing the &lt;code&gt;pause&lt;/code&gt; command (which waits for a keypress) in case compilation fails:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent exec '!&quot;C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe&quot; /in '.shellescape('%') . ' || pause'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and here's a &lt;a href=&quot;https://ss64.com/nt/syntax-redirection.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;reference for the command failed redirect&lt;/a&gt; (double pipe &lt;code&gt;||&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Alternatives&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You could invoke the external command via &lt;code&gt;:let output = system(...)&lt;/code&gt;, and then conditionally &lt;code&gt;:echo&lt;/code&gt; or discard the output based on &lt;code&gt;v:shell_error&lt;/code&gt; (or even by inspecting the output by matching &quot;interesting&quot; strings, if you want to ignore some compiler errors or as a solution if the exit status always is &lt;code&gt;0&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, you then should go the whole round and write a proper &lt;em&gt;compiler plugin&lt;/em&gt; (&lt;a href=&quot;https://vimhelp.appspot.com/quickfix.txt.html#%3Acompiler&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :compiler&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://vimhelp.appspot.com/usr_41.txt.html#write-compiler-plugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help write-compiler-plugin&lt;/code&gt;&lt;/a&gt;). With this, you can trigger via &lt;code&gt;:make&lt;/code&gt;, and can use the &lt;em&gt;quickfix list&lt;/em&gt; to view and navigate to compiler errors (assuming the error output is properly structured and parsable).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Additional critique&lt;/h3&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;S-F5&amp;gt; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As these mappings only apply to AutoHotkey buffers, you should limit the scope of those mappings via &lt;code&gt;:nnoremap &amp;lt;buffer&amp;gt; ...&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I would recommend putting any settings, mappings, and filetype-specific autocmds into &lt;code&gt;~/.vim/ftplugin/{filetype}_whatever.vim&lt;/code&gt; (or &lt;code&gt;{filetype}/whatever.vim&lt;/code&gt;; cp. &lt;code&gt;:help ftplugin-name&lt;/code&gt;) instead of defining lots of &lt;code&gt;:autocmd FileType {filetype}&lt;/code&gt;; it's cleaner and scales better; requires that you have &lt;code&gt;:filetype plugin on&lt;/code&gt;, though. Settings that &lt;em&gt;override&lt;/em&gt; stuff in default filetype plugins should go into &lt;code&gt;~/.vim/after/ftplugin/{filetype}.vim&lt;/code&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="970" OwnerDisplayName="Ingo Karkat" LastActivityDate="2018-09-20T02:20:54.583" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17430" PostTypeId="1" AcceptedAnswerId="17442" CreationDate="2018-09-20T09:36:57.017" Score="1" ViewCount="874" Body="&lt;p&gt;In Ex mode, &lt;code&gt;##&lt;/code&gt; can be expanded to the files in the &lt;code&gt;args&lt;/code&gt; list when files are &lt;strong&gt;expected&lt;/strong&gt;, see &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#cmdline-special&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h cmdline-special&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In Ex commands, at places where a file name can be &lt;strong&gt;used&lt;/strong&gt;, the following characters have a special meaning.  These can also be used in the expression function expand().&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Like &lt;code&gt;!ls ##&lt;/code&gt; will expand &lt;code&gt;##&lt;/code&gt; But &lt;code&gt;echo ##&lt;/code&gt; will not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I am going to define my own command, how to tell &lt;code&gt;vim&lt;/code&gt; that I want files here so please expand my &lt;code&gt;##&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to expand them in place (like how &lt;code&gt;zsh&lt;/code&gt; expands &lt;code&gt;*&lt;/code&gt; when you press &lt;kbd&gt;Tab&lt;/kbd&gt; after it)?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;An example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Echo :exe &quot;echo '&quot; . &amp;lt;q-args&amp;gt; . &quot;'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to run &lt;code&gt;Echo I am here ##&lt;/code&gt; with &lt;code&gt;##&lt;/code&gt; expanded. &lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-09-21T06:45:21.063" LastActivityDate="2018-09-21T06:45:21.063" Title="cmdline: how to expand `##` in-place?" Tags="|cmdline|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17431" PostTypeId="2" ParentId="17430" CreationDate="2018-09-20T10:03:11.137" Score="5" Body="&lt;p&gt;You could use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expand%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h expand()&lt;/code&gt;&lt;/a&gt; in your command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ Test echo expand(&quot;&amp;lt;args&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way &lt;code&gt;:Test foo bar&lt;/code&gt; will echo &lt;code&gt;foo bar&lt;/code&gt; and &lt;code&gt;:Test ##&lt;/code&gt; will echo your argument list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About the in-place expansion as far as I know this is not possible out of the box.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-09-20T10:03:11.137" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17432" PostTypeId="1" AcceptedAnswerId="17434" CreationDate="2018-09-20T11:12:40.050" Score="0" ViewCount="685" Body="&lt;p&gt;I am trying to use &lt;code&gt;wordcount().cursor_chars&lt;/code&gt; to determine the character offset of the cursor in the buffer – but I am getting off-by-one errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The docs for &lt;code&gt;wordcount()&lt;/code&gt; say that &lt;code&gt;cursor_chars&lt;/code&gt; is the &quot;Number of chars before cursor position (not in Visual mode)&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;open a new buffer &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:autocmd CursorMoved,CursorMovedI * echo wordcount()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;insert &lt;code&gt;abc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;return to normal mode and place the cursor on the &lt;code&gt;a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The echoed &lt;code&gt;wordcount().cursor_chars&lt;/code&gt; is &lt;code&gt;1&lt;/code&gt;.  However I would expect this to be &lt;code&gt;0&lt;/code&gt; as there are no characters before the cursor.  Is the documentation wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related, pressing &lt;code&gt;A&lt;/code&gt; to go into insert mode with the cursor after the &lt;code&gt;c&lt;/code&gt; gives a cursor offset of &lt;code&gt;4&lt;/code&gt; in a file with unix EOLs and &lt;code&gt;5&lt;/code&gt; in a file with dos EOLs.  Is that because the cursor is actually on the last character of the EOL regardless of whether the EOL is one or two characters?&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2018-09-20T13:27:59.097" Title="How to determine character offset of cursor in buffer?" Tags="|cursor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17433" PostTypeId="1" AcceptedAnswerId="17455" CreationDate="2018-09-20T12:31:23.177" Score="3" ViewCount="11608" Body="&lt;p&gt;I compiled vim8.1 with the following options :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 8.1 (2018 May 18, compiled Sep 18 2018 09:50:18)&#xA;Included patches: 1-320&#xA;Compiled by mohsen@ns1&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl               +extra_search      +mouse_netterm     +tag_old_static&#xA;+arabic            +farsi             +mouse_sgr         -tag_any_white&#xA;+autocmd           +file_in_path      -mouse_sysmouse    -tcl&#xA;+autochdir         +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       -terminal&#xA;+balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;+browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    +gettext           +netbeans_intg     +timers&#xA;+byte_offset       -hangul_input      +num64             +title&#xA;+channel           +iconv             +packages          +toolbar&#xA;+cindent           +insert_expand     +path_extra        +user_commands&#xA;+clientserver      +job               +perl              +vartabs&#xA;+clipboard         +jumplist          +persistent_undo   +vertsplit&#xA;+cmdline_compl     +keymap            +postscript        +virtualedit&#xA;+cmdline_hist      +lambda            +printer           +visual&#xA;+cmdline_info      +langmap           +profile           +visualextra&#xA;+comments          +libcall           +python/dyn        +viminfo&#xA;+conceal           +linebreak         +python3/dyn       +vreplace&#xA;+cryptv            +lispindent        +quickfix          +wildignore&#xA;+cscope            +listcmds          +reltime           +wildmenu&#xA;+cursorbind        +localmap          +rightleft         +windows&#xA;+cursorshape       +lua               +ruby              +writebackup&#xA;+dialog_con_gui    +menu              +scrollbind        +X11&#xA;+diff              +mksession         +signs             -xfontset&#xA;+digraphs          +modify_fname      +smartindent       +xim&#xA;+dnd               +mouse             +startuptime       +xpm&#xA;-ebcdic            +mouseshape        +statusline        +xsmp_interact&#xA;+emacs_tags        +mouse_dec         -sun_workshop      +xterm_clipboard&#xA;+eval              +mouse_gpm         +syntax            -xterm_save&#xA;+ex_extra          -mouse_jsbterm     +tag_binary        &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/opt/vim8/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: gcc   -L. -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux   -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lcrypt    -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, When I put the following line in my vimrc, I get error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;YouCompleteMe unavailable: requires Vim compiled with Python (2.7.1+ or 3.4+) support.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I compiled with python, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The line of &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bundle 'YouCompleteMe'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Where's my problem?&lt;/strong&gt;&#xA;My vimrc is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Bundle 'YouCompleteMe'&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'command-t'&#xA;Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}&#xA;&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&#xA;Plugin 'tmhedberg/SimpylFold'&#xA;filetype plugin on&#xA;set splitbelow&#xA;set splitright&#xA;nnoremap &amp;lt;C-J&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-J&amp;gt;&#xA;nnoremap &amp;lt;C-K&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-K&amp;gt;&#xA;nnoremap &amp;lt;C-L&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-L&amp;gt;&#xA;nnoremap &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-H&amp;gt;&#xA;set foldmethod=indent&#xA;set foldlevel=99&#xA;nnoremap &amp;lt;space&amp;gt; za&#xA;&#xA;let g:SimpylFold_docstring_preview=1&#xA;au BufNewFile,BufRead *.py&#xA;    \ set tabstop=4&#xA;    \ set softtabstop=4&#xA;    \ set shiftwidth=4&#xA;    \ set textwidth=79&#xA;    \ set expandtab&#xA;    \ set autoindent&#xA;    \ set fileformat=unix&#xA;au BufNewFile,BufRead *.js, *.html, *.css&#xA;    \ set tabstop=2&#xA;    \ set softtabstop=2&#xA;    \ set shiftwidth=2&#xA;Plugin 'vim-scripts/indentpython.vim'&#xA;au BufRead,BufNewFile *.py,*.pyw,*.c,*.h &quot;match BadWhitespace /\s\+$/&#xA;set encoding=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4680" LastEditorUserId="51" LastEditDate="2018-09-20T12:56:40.680" LastActivityDate="2018-09-23T16:19:26.770" Title="requires Vim compiled with Python (2.7.1+ or 3.4+) support" Tags="|vimscript-python|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17434" PostTypeId="2" ParentId="17432" CreationDate="2018-09-20T13:27:59.097" Score="2" Body="&lt;p&gt;I think you are correct. The documentation is not very clear on that, but if you do start &lt;code&gt;vim --clean -c ':set ls=2 stl=%{wordcount().cursor_chars}'&lt;/code&gt;&#xA;you will see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In an empty buffer, that statusline will be zero&lt;/li&gt;&#xA;&lt;li&gt;as soon as you got to insert mode and a letter, the statusline will switch to 2 (note the cursor is technically after the letter)&lt;/li&gt;&#xA;&lt;li&gt;if you go back into normal mode, the statusline will be 1&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think this means, that the &lt;code&gt;cursor_chars&lt;/code&gt; returns the number of characters up to and &lt;strong&gt;including&lt;/strong&gt; the position of the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you press &lt;kbd&gt;A&lt;/kbd&gt; from normal mode to append a character into a buffer with the single line &lt;code&gt;abc&lt;/code&gt;, I think technically vim treats the current position as a new character at the cursor position, so it increments it already to 4. That would also explain, why you see a 1 after entering &lt;code&gt;a&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclaimer: I have not verified it in the source, just how I would explain what you noticed.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-09-20T13:27:59.097" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17435" PostTypeId="2" ParentId="4575" CreationDate="2018-09-20T15:26:20.127" Score="1" Body="&lt;p&gt;I've just seen &lt;a href=&quot;https://stackoverflow.com/a/52414896/2571881&quot;&gt;another similar question&lt;/a&gt; and the solution consists of:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Jump to the middle plus one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Mj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:,$g/./exe 'm' 2*line('.')-line('$')-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2018-09-20T15:26:20.127" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17436" PostTypeId="1" CreationDate="2018-09-20T16:39:34.557" Score="2" ViewCount="1482" Body="&lt;p&gt;for one single word, the job is quite easy: we just do a 'cw' &lt;/p&gt;&#xA;&#xA;&lt;p&gt;what if I select a certain text and I want to replace this block with one word?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;obviously I can do a 'x' and then 'i', is there a one key-stoke solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in other words, after I select the block in visual mode, what is the fastest way to do 'delete' and then enter insert mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;any idea?&lt;/p&gt;&#xA;" OwnerUserId="16105" LastActivityDate="2020-10-28T02:06:43.893" Title="How to select a block in visual mode and delete this block and immediately enter insert mode?" Tags="|visual-mode|replace|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17437" PostTypeId="2" ParentId="17436" CreationDate="2018-09-20T17:21:52.010" Score="3" Body="&lt;p&gt;You can do the selection using visual mode and then hit &lt;kbd&gt;s&lt;/kbd&gt; or &lt;kbd&gt;c&lt;/kbd&gt; to remove the selected text and directly enter insert mode.&lt;/p&gt;&#xA;" OwnerUserId="18841" LastActivityDate="2018-09-20T17:21:52.010" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17438" PostTypeId="2" ParentId="17436" CreationDate="2018-09-20T17:21:59.740" Score="4" Body="&lt;p&gt;You can do exactly this with &lt;kbd&gt;c&lt;/kbd&gt;. From &lt;code&gt;:help v_c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{Visual}[&quot;x]c   or                  *v_c* *v_s*&#xA;{Visual}[&quot;x]s       Delete the highlighted text [into register x] and&#xA;            start insert (for {Visual} see |Visual-mode|).  {not&#xA;            in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In general, most commands that work in normal mode will work the same way in visual mode. So since you can do &lt;code&gt;cw&lt;/code&gt;, you can do &lt;code&gt;c&lt;/code&gt; in visual mode and it will have the same effect. Same for &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;gu&lt;/code&gt;, etc.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-09-20T17:21:59.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17439" PostTypeId="1" AcceptedAnswerId="17443" CreationDate="2018-09-20T23:23:56.643" Score="5" ViewCount="1737" Body="&lt;p&gt;Recently I found myself in a situation that need to type in quite a number of matrices to LaTeX by hand, so I was wondering if there are some tools that can help me to save some keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The desired tool would work as follows. Whenever I need to insert a matrix, I trigger the plugin, then it prompts to ask me about the dimension of the matrix (for example, 4 by 3). Then it generates the following template:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{bmatrix}&#xA;&amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt;\\&#xA;&amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt;\\&#xA;&amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt;\\&#xA;&amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt;\\&#xA;\end{bmatrix}&amp;lt;++&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am following the LaTeX-suite convention here, but the actual format doesn't really matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there such tools? If not, I'd be very interested in &lt;em&gt;implementing&lt;/em&gt; one myself, so are there any tools that have a similar function that I can refer to?&lt;/p&gt;&#xA;" OwnerUserId="16146" LastEditorDisplayName="user579" LastEditDate="2018-09-21T00:20:31.320" LastActivityDate="2023-04-05T07:25:22.670" Title="Easiest way to insert LaTeX matrix?" Tags="|autocompletion|plugin-system|plugin-vim-latex|snippets|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17440" PostTypeId="2" ParentId="17423" CreationDate="2018-09-20T23:47:56.400" Score="4" Body="&lt;p&gt;I've been annoyed by this for as long as I can remember.  Your question prompted me to scratch this itch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This script remaps &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; to perform custom incrementing/decrementing, but only when the number is preceded by a keyword character &lt;em&gt;and&lt;/em&gt; a dash, or just preceded by a period.  If those conditions aren't met, the default &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; keys are used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case with &lt;code&gt;Whatever-AP-1&lt;/code&gt;, pressing &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; on the &lt;code&gt;1&lt;/code&gt; would make it &lt;code&gt;2&lt;/code&gt;.  Pressing &lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; would make it &lt;code&gt;0&lt;/code&gt;, and pressing &lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; on the &lt;code&gt;0&lt;/code&gt; would leave it at &lt;code&gt;0&lt;/code&gt;.  With the script also recognizing numbers preceded with a period, adjusting floating point numbers will work as expected, too.  That would also apply to IP addresses (except for the first octet since it doesn't meet the conditions mentioned above).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The limitation is that this won't work in visual mode.  I guess it's also worth mentioning that it updates the &lt;code&gt;.&lt;/code&gt; register, since the default keys don't.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've added comments to the script to make it a learning experience.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:incr(dir) abort&#xA;  &quot; Search backwards from the cursor for digits preceded by a keyword&#xA;  &quot; character and a dash/period, restricted to the current line.  Characters&#xA;  &quot; that come after the cursor must only be digits.&#xA;  &quot;&#xA;  &quot; This is slightly different from how &amp;lt;c-a&amp;gt; and &amp;lt;c-x&amp;gt; works since they&#xA;  &quot; search forward by default.&#xA;  &quot;&#xA;  &quot; If there are no matches, return the default incr/decr key.&#xA;  if search('\%(\%(\k-\)\|\.\)\@&amp;lt;=\d\+\&amp;amp;\%#\d*\&amp;gt;', 'cbW', line('.')) == 0&#xA;    return (a:dir &amp;gt; 0 ? &quot;\&amp;lt;c-a&amp;gt;&quot; : &quot;\&amp;lt;c-x&amp;gt;&quot;)&#xA;  endif&#xA;&#xA;  &quot; Get the current number under the cursor.&#xA;  &quot;&#xA;  &quot; Because of the search() call above, the cursor should now be placed at&#xA;  &quot; the beginning of the number allowing us to use &amp;lt;cword&amp;gt; expansion.&#xA;  let n = expand('&amp;lt;cword&amp;gt;') + 0&#xA;&#xA;  &quot; If the number is already zero and we are subtracting, return nothing to&#xA;  &quot; avoid creating an undo point.&#xA;  if n == 0 &amp;amp;&amp;amp; a:dir &amp;lt; 0&#xA;    return ''&#xA;  endif&#xA;&#xA;  &quot; Clear pending mode if we started with a count&#xA;  let seq = &quot;\&amp;lt;esc&amp;gt;&quot;&#xA;&#xA;  &quot; The cursor will reset once the function exits.  We retain it by using a&#xA;  &quot; column jump.&#xA;  let seq .= col('.') . '|'&#xA;&#xA;  &quot; Begin a change, throwing the &amp;lt;cword&amp;gt; into the black hole register.&#xA;  let seq .= '&quot;_cw'&#xA;&#xA;  &quot; Incr or decr the number by v:count1, without going negative, then type it.&#xA;  let seq .= max([0, n + (v:count1 * a:dir)])&#xA;&#xA;  &quot; Press escape&#xA;  return seq . &quot;\&amp;lt;esc&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt;&amp;lt;silent&amp;gt; &amp;lt;c-a&amp;gt; &amp;lt;sid&amp;gt;incr(1)&#xA;nnoremap &amp;lt;expr&amp;gt;&amp;lt;silent&amp;gt; &amp;lt;c-x&amp;gt; &amp;lt;sid&amp;gt;incr(-1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2018-09-20T23:47:56.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17441" PostTypeId="1" AcceptedAnswerId="17445" CreationDate="2018-09-20T23:54:48.113" Score="1" ViewCount="1471" Body="&lt;p&gt;Does &lt;code&gt;hi link XXX Normal&lt;/code&gt; provide any benefits? For example the syntax file included by default &lt;code&gt;syntax/vim.vim&lt;/code&gt; includes the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi def link vimUserFunc Normal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This often conflicts with &lt;code&gt;CursorLine&lt;/code&gt; highlighting since &lt;code&gt;Normal&lt;/code&gt; often sets a different background color than &lt;code&gt;CursorLine&lt;/code&gt; e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Normal guifg=#ffffff guibg=#000000&#xA;hi CursorLine guibg=#111111&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Removing the link does not seem to have any immediately obvious adverse effects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any benefits that I am not aware of?&lt;/p&gt;&#xA;" OwnerUserId="3354" LastActivityDate="2018-09-21T06:26:04.047" Title="Does `hi link XXX Normal` provide any benefits?" Tags="|syntax-highlighting|colorscheme|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17442" PostTypeId="2" ParentId="17430" CreationDate="2018-09-21T01:14:33.690" Score="2" Body="&lt;p&gt;I ended in using &lt;code&gt;cabbr&lt;/code&gt;. This is one way.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev &amp;lt;expr&amp;gt; ##; getcmdtype()==':'?expand('##'):'##;'&#xA;cnoreabbrev &amp;lt;expr&amp;gt; #; getcmdtype()==':'?expand('#'):'#;'&#xA;cnoreabbrev &amp;lt;expr&amp;gt; %; getcmdtype()==':'?expand('%'):'%;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another way is to use &lt;code&gt;cnoremap &amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:expand()&#xA;  let line = getcmdline()&#xA;  let pos = getcmdpos()  &quot; cursor pos&#xA;  if pos &amp;lt;= 1&#xA;    return ';;'&#xA;  endif&#xA;  let line = line[0:(pos-2)]&#xA;  let match = matchlist(line, '\s\(\(%\|#\|#&amp;lt;\?[0-9]\+\|##\)\(:\S\+\)\?\)$')&#xA;  if len(match) &amp;lt; 2 || match[1] == ''&#xA;    return ';;'&#xA;  else&#xA;    return repeat(&quot;\&amp;lt;bs&amp;gt;&quot;, len(match[1])) . expand(match[1])&#xA;  endif&#xA;endfunction&#xA;cnoremap &amp;lt;expr&amp;gt; ;; &amp;lt;SID&amp;gt;expand()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-09-21T01:14:33.690" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17443" PostTypeId="2" ParentId="17439" CreationDate="2018-09-21T03:07:15.677" Score="5" Body="&lt;p&gt;You could probably implement this as a snippet by leveraging &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ultisnips'&lt;/a&gt; &lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/aec91caefec10741722927cf073703a528fe7a8f/doc/UltiSnips.txt#L820&quot; rel=&quot;nofollow noreferrer&quot;&gt;Interpolation&lt;/a&gt; feature (&lt;a href=&quot;http://vimcasts.org/episodes/ultisnips-python-interpolation/&quot; rel=&quot;nofollow noreferrer&quot;&gt;VimCasts demo&lt;/a&gt;). As an alternative, I whipped up a simplistic function to generate a matrix template on the current line per your sample:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! CreateMatrix(rows, ...) abort&#xA;  let cols = a:0 ? a:1 : 3&#xA;  let matrix = ['\begin{bmatrix}']&#xA;  call extend(matrix, repeat([repeat('&amp;lt;++&amp;gt; &amp;amp; ', cols - 1) . '&amp;lt;++&amp;gt;\\'], a:rows))&#xA;  call add(matrix, '\end{bmatrix}&amp;lt;++&amp;gt;')&#xA;  call append(line('.') - 1, matrix)&#xA;endfunction&#xA;command! -nargs=+ Matrix silent call CreateMatrix(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The provided command takes as arguments &lt;strong&gt;rows&lt;/strong&gt; and optionally &lt;strong&gt;columns&lt;/strong&gt;. If columns is left unspecified, it defaults to 3. For example, calling &lt;code&gt;:Matrix 3&lt;/code&gt; would add the following to the current buffer:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\begin{bmatrix}&#xA;&amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt;\\&#xA;&amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt;\\&#xA;&amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt;\\&#xA;\end{bmatrix}&amp;lt;++&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Invoking &lt;code&gt;:Matrix 5 8&lt;/code&gt; would add:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\begin{bmatrix}&#xA;&amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt;\\&#xA;&amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt;\\&#xA;&amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt;\\&#xA;&amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt;\\&#xA;&amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt; &amp;amp; &amp;lt;++&amp;gt;\\&#xA;\end{bmatrix}&amp;lt;++&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It should be easy enough to modify the function and/or command to your liking.&lt;/p&gt;&#xA;" OwnerUserId="1452" LastEditorUserId="21251" LastEditDate="2021-07-05T21:12:39.423" LastActivityDate="2021-07-05T21:12:39.423" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17445" PostTypeId="2" ParentId="17441" CreationDate="2018-09-21T06:26:04.047" Score="2" Body="&lt;p&gt;Without a highlight, it could be highlighted by a different syntax group that might contain it.  My guess is that &lt;code&gt;vimUserFunc&lt;/code&gt; was meant to look like normal text so it wouldn't be highlighted like built-in functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If by removing it, you mean deleting the line in &lt;code&gt;$VIMRUNTIME/syntax/vim.vim&lt;/code&gt;, you shouldn't.  You can clear it with &lt;code&gt;:highlight clear vimUserFunc&lt;/code&gt; in a script like &lt;code&gt;after/syntax/vim.vim&lt;/code&gt;.  I doubt this will be the only occurrence of this, though.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This often conflicts with CursorLine highlighting since Normal often sets a different background color than CursorLine e.g.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Getting &lt;code&gt;CursorLine&lt;/code&gt; to look &quot;right&quot; is an uphill battle.  By default &lt;code&gt;Normal&lt;/code&gt; isn't set.  Most of the stock themes don't actually set a background for anything unless its meant to stand out (e.g. &lt;code&gt;Error&lt;/code&gt;, &lt;code&gt;Search&lt;/code&gt;, etc.), in which case, inconsistency with the &lt;code&gt;CursorLine&lt;/code&gt; background shouldn't be a concern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anything, setting a background color on &lt;code&gt;Normal&lt;/code&gt; is creating your issue.&lt;/p&gt;&#xA;" OwnerUserId="5229" LastActivityDate="2018-09-21T06:26:04.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17446" PostTypeId="1" CreationDate="2018-09-21T07:11:48.923" Score="4" ViewCount="4675" Body="&lt;p&gt;OK so I would like to change the way that my yaml gets indented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now my vim indents a yaml list like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;list:&#xA;  - this&#xA;  - is&#xA;  - a list&#xA;dict:&#xA;  this: is a dict&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like it to indent like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;test:&#xA;- this&#xA;- is&#xA;- a list&#xA;dict:&#xA;  this: is a dict&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13876" LastEditorUserId="13876" LastEditDate="2018-09-21T07:40:14.450" LastActivityDate="2019-12-30T15:59:35.693" Title="How do I make the yaml indent not indent lists?" Tags="|indentation|filetype-yaml|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17447" PostTypeId="1" AcceptedAnswerId="17448" CreationDate="2018-09-21T09:18:27.943" Score="0" ViewCount="369" Body="&lt;p&gt;I'd like to display some characters in left side of the line number gutter just like the vim-syntastic plugin does to show the errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;back when I was starting to learn vim I saw a plugin doing just that (it displayed the marks per line) I don't really remember which plugin it was as I was just blindly installing everything back then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this doable using vimscirpt or should I use other scripting language like python or something?&lt;/p&gt;&#xA;" OwnerUserId="18514" LastEditorUserId="1841" LastEditDate="2018-09-21T10:00:27.047" LastActivityDate="2018-09-21T10:00:27.047" Title="How to display a sign before the line number gutter?" Tags="|line-numbers|signs|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17448" PostTypeId="2" ParentId="17447" CreationDate="2018-09-21T09:23:32.307" Score="2" Body="&lt;p&gt;I think you are looking for &lt;a href=&quot;http://vimhelp.appspot.com/sign.txt.html#%3asign&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :sign&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Here is an example that places a sign &quot;piet&quot;, displayed with the text &quot;&amp;gt;&amp;gt;&quot;, in    &#xA;line 23 of the current file: &amp;gt;&#xA;    :sign define piet text=&amp;gt;&amp;gt; texthl=Search&#xA;    :exe &quot;:sign place 2 line=23 name=piet file=&quot; . expand(&quot;%:p&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example these two lines give this on my setup (notice the sign &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; on the 23rd line):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1jMtB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1jMtB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-09-21T09:33:31.660" LastActivityDate="2018-09-21T09:33:31.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17449" PostTypeId="1" AcceptedAnswerId="17458" CreationDate="2018-09-21T11:01:33.733" Score="1" ViewCount="496" Body="&lt;p&gt;Folks,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running my &lt;code&gt;vim-8.1.1&lt;/code&gt; compiled in my debian stretch system. The &lt;code&gt;vim&lt;/code&gt; process slowly eats up to 40% of my system memory in about 4-5hours. No big files opened. ~4 tabs opened (each with 2 split panes). I am having hard time troubleshooting. Could someone shed some light?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Configure options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --prefix=/opt/VIM/ --disable-darwin --enable-python3interp=yes --with-vim-name=vem --with-modified-by=XXX --with-compiledby=xxx --with-python3-command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Enables options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~~&amp;gt; vem --version&#xA;VIM - Vi IMproved 8.1 (2018 May 18, compiled Sep 21 2018 16:51:39)&#xA;Included patches: 1&#xA;Modified by XXX&#xA;Compiled by xxx&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               +farsi             +mouse_sgr         -tag_any_white&#xA;+arabic            +file_in_path      -mouse_sysmouse    -tcl&#xA;+autocmd           +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       +terminal&#xA;-balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;-browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    +gettext           +netbeans_intg     +timers&#xA;+byte_offset       -hangul_input      +num64             +title&#xA;+channel           +iconv             +packages          -toolbar&#xA;+cindent           +insert_expand     +path_extra        +user_commands&#xA;-clientserver      +job               -perl              +vertsplit&#xA;-clipboard         +jumplist          +persistent_undo   +virtualedit&#xA;+cmdline_compl     +keymap            +postscript        +visual&#xA;+cmdline_hist      +lambda            +printer           +visualextra&#xA;+cmdline_info      +langmap           +profile           +viminfo&#xA;+comments          +libcall           -python            +vreplace&#xA;+conceal           +linebreak         +python3           +wildignore&#xA;+cryptv            +lispindent        +quickfix          +wildmenu&#xA;+cscope            +listcmds          +reltime           +windows&#xA;+cursorbind        +localmap          +rightleft         +writebackup&#xA;+cursorshape       -lua               -ruby              -X11&#xA;+dialog_con        +menu              +scrollbind        -xfontset&#xA;+diff              +mksession         +signs             -xim&#xA;+digraphs          +modify_fname      +smartindent       -xpm&#xA;-dnd               +mouse             +startuptime       -xsmp&#xA;-ebcdic            -mouseshape        +statusline        -xterm_clipboard&#xA;+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save&#xA;+eval              -mouse_gpm         +syntax            &#xA;+ex_extra          -mouse_jsbterm     +tag_binary        &#xA;+extra_search      +mouse_netterm     +tag_old_static    &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/opt/VIM/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vem        -lm -ltinfo -lnsl   -ldl     -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18442" LastEditorUserId="18442" LastEditDate="2018-09-21T11:28:54.847" LastActivityDate="2020-05-27T10:14:43.553" Title="vim process memory consumption increase with time" Tags="|vimrc|installing|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17450" PostTypeId="1" AcceptedAnswerId="17463" CreationDate="2018-09-21T12:19:16.663" Score="9" ViewCount="3404" Body="&lt;p&gt;I often find the need to start a new file by making a copy of another similar file within the same directory.  &lt;code&gt;netrw&lt;/code&gt; has several commands for copying files from one directory to another (ie: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#netrw-mc&quot; rel=&quot;noreferrer&quot;&gt;:h netrw-mc:&lt;/a&gt;), but there appears to no means to copy a file to a new name within the same directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got excited when I stumbled across &lt;code&gt;&amp;lt;C-R&amp;gt;&amp;lt;C-F&amp;gt;&lt;/code&gt; which copies the current file under the cursor and thought about trying:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!cp &amp;lt;C-R&amp;gt;&amp;lt;C-R&amp;gt; new-file-name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, netrw doesn't include the full path of the copy, so if you've navigated to directory in netrw before attempting the copy, the above command will fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know if copying a file to a different name in the same directory is possible with netrw?&lt;/p&gt;&#xA;" OwnerUserId="19082" LastEditorUserId="11986" LastEditDate="2018-10-12T04:59:33.333" LastActivityDate="2018-10-12T04:59:33.333" Title="copy a file in netrw" Tags="|netrw|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17451" PostTypeId="2" ParentId="11601" CreationDate="2018-09-21T16:57:56.217" Score="9" Body="&lt;p&gt;You could use an environment variable defined within your current shell session.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $myvimdir = '/home/abc/vimfiles'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way you can use other variables to compose the path as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $myvimdir = $HOME.'/vimfiles'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And set the runtime path:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp+=$myvimdir/bundle/Vundle.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More information on environment variables within vim &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#expr-env&quot; rel=&quot;noreferrer&quot; title=&quot;:help expr-env&quot;&gt;:help expr-env&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19087" LastActivityDate="2018-09-21T16:57:56.217" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17452" PostTypeId="1" CreationDate="2018-09-22T10:30:05.133" Score="3" ViewCount="347" Body="&lt;p&gt;I'm trying to configure vim to understand the jest output error format to be able to include it in the quickfix list. Although it does work partly (at least getting the file name and line/column number), I don't know why the quick fix list is displaying the other lines that are not matched&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my error format:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CompilerSet makeprg=node_modules/.bin/jest &lt;br&gt;&#xA;CompilerSet errorformat=%.%#\ at\ %.%#(%f:%l:%c)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a sample error output for jest&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;‚óè But parseInt accepts radix as second argument&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expect(received).toBe(expected) // Object.is equality&#xA;&#xA;Expected: 4&#xA;Received: 3&#xA;&#xA;  16 |     // parseInt uses the second argument to indicate radix&#xA;  17 |     expect(parseInt('3', 2)).toBe(NaN); // eslint-disable-line prefer-numeric-literals&#xA;&amp;gt; 18 |     expect(parseInt('11', 2)).toBe(4); // eslint-disable-line prefer-numeric-literals&#xA;     |                               ^&#xA;  19 |   });&#xA;  20 | &#xA;  21 |   test('It could create problems when used as part of an higher-order function like map', () =&amp;gt; {&#xA;&#xA;  at Object.toBe (managing.functions.input.test.js:18:31)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I do this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:compiler jest &lt;br&gt;&#xA;:make&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when I do :copen after this, it opens the quick fix list and jumps to the first error -- all good here.. but it also shows me all the lines above from the output. Ideally, I expect only one line per error in the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Admittedly, I haven't encoded the error message (%m) yet, but to start with I don't want all the output lines to be shown in the quick fix window. My understanding is that if a line doesn't match any format, it should be skipped ..isn't it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can somebody help me how to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if I type :clist, it does show me only the error line(s) - I expect similar output in quick fix list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance &lt;/p&gt;&#xA;" OwnerUserId="18901" LastActivityDate="2018-11-21T11:01:50.307" Title="Errorformat for jest output" Tags="|errorformat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17453" PostTypeId="2" ParentId="17452" CreationDate="2018-09-22T10:50:47.960" Score="2" Body="&lt;p&gt;After going through other options, I realised that the default of quickfix is to capture all the output and use %- prefix to skip any lines&lt;/p&gt;&#xA;&#xA;&lt;p&gt;after modifying the errorformat to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  CompilerSet errorformat=%.%#\ at\ %.%#(%f:%l:%c),%-G%.%#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it worked. But this worked only in vanilla vim - compiler,make combo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was using this as part of vim-dispatch and neo-vim adapter plugins and looks like neo-vim doesn't recognize the %-G option. so for this case converting it to %-A solved the problem for now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="18901" LastActivityDate="2018-09-22T10:50:47.960" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17455" PostTypeId="2" ParentId="17433" CreationDate="2018-09-22T17:47:47.427" Score="8" Body="&lt;p&gt;When you want to run &lt;code&gt;./configure&lt;/code&gt;, You have 3 options for python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--enable-pythoninterp=yes&#xA;--with-python-command=/usr/bin/python&#xA;--with-python-config-dir=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;last parameter is deprecated, You have to don't use &lt;code&gt;--with-python-config-dir&lt;/code&gt; then recompile and reinstall &lt;code&gt;vim&lt;/code&gt;, After reinstall, You can test via &lt;code&gt;:echo has(&quot;python&quot;)&lt;/code&gt;, if it return 1, it means true.&#xA;&lt;strong&gt;Note:&lt;/strong&gt;&#xA;You have the following options for python 3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--enable-python3interp=yes&#xA;--with-python3-command=/usr/bin/python3&#xA;--with-python3-config-dir=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4680" LastEditorUserId="4680" LastEditDate="2018-09-23T16:19:26.770" LastActivityDate="2018-09-23T16:19:26.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17456" PostTypeId="1" CreationDate="2018-09-22T18:47:04.443" Score="2" ViewCount="4463" Body="&lt;p&gt;I'm new to NeoVim and just getting started.&lt;br&gt;&#xA;My init.vim file under &lt;code&gt;NeoVim\share\nvim\runtime\plugin\init.vim&lt;/code&gt; successfully sets everything except for the colorscheme and background.&lt;br&gt;&#xA;As seen in the image below, the numbers, color column, etc are all being set correctly, but the colorscheme and background commands are not occurring.&lt;br&gt;&#xA;&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/DHtrQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DHtrQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;However, upon typing the commands &lt;code&gt;:colorscheme default&lt;/code&gt; and &lt;code&gt;:set background=dark&lt;/code&gt;, everything works fine.&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/MlTjs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MlTjs.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;Here's my init.vim file:&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader=&quot;`&quot;&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;set number&#xA;set cursorline&#xA;filetype indent on&#xA;set wildmenu&#xA;set showmatch&#xA;set hlsearch&#xA;set incsearch&#xA;set colorcolumn=80&#xA;vmap &amp;lt;C-S-C&amp;gt; &quot;+y&#xA;map &amp;lt;C-S-V&amp;gt; &quot;+p&#xA;noremap V &amp;lt;C-V&amp;gt;&#xA;map &amp;lt;F5&amp;gt; :!j @%&#xA;syntax enable&#xA;colorscheme default&#xA;set background=dark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm running NVIM v0.3.1 through CMD on Windows 10.&lt;br&gt;&#xA;Other than the init.vim file, this is a fresh install.&lt;br&gt;&#xA;Is this a known issue with NeoVim?&lt;br&gt;&lt;/p&gt;&#xA;" OwnerUserId="19097" LastEditorUserId="19097" LastEditDate="2018-09-22T22:27:48.497" LastActivityDate="2024-04-02T15:09:26.207" Title="NeoVim: colorscheme won't work in init.vim; requires command to be typed" Tags="|vimrc|neovim|colorscheme|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17458" PostTypeId="2" ParentId="17449" CreationDate="2018-09-23T09:47:34.620" Score="2" Body="&lt;p&gt;Following up with the suggestions from &lt;code&gt;Christian&lt;/code&gt;, I have found the plugin that causes this issue. It is &lt;code&gt;YouCompleteMe&lt;/code&gt; Plugin that creates a new log file after 30 minutes of inactivity in any of vim instance.&lt;/p&gt;&#xA;" OwnerUserId="18442" LastEditorUserId="-1" LastEditDate="2020-05-27T10:14:43.553" LastActivityDate="2020-05-27T10:14:43.553" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17459" PostTypeId="2" ParentId="15535" CreationDate="2018-09-23T10:58:10.747" Score="4" Body="&lt;p&gt;I ran into a similar (the same?) issue on two different installs:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;NVIM v0.2.0&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;NVIM v0.3.1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/users/16690/quanta&quot;&gt;quanta&lt;/a&gt; &lt;a href=&quot;https://vi.stackexchange.com/a/15556/19100&quot;&gt;already mentions&lt;/a&gt; this change in behavior might be due to the changes introduced in &lt;code&gt;NVIM v0.2.1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a shortcut for running things from within nvim, that splits the window, launches the terminal emulator in the new split view and executes there. After execution had completed in the terminal I used to be able to hit any key to close the terminal &amp;amp; split view and return to the original buffer, i.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;Leader&amp;gt;p :w&amp;lt;CR&amp;gt;:split \| terminal python %&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and this is still the case with the &lt;code&gt;NVIM v0.2.0&lt;/code&gt; install I refer to above but just pressing a key to close and return does not work any more on the &lt;code&gt;v0.3.1&lt;/code&gt; install.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What fixed this for me was to append a &lt;strong&gt;&lt;code&gt;:startinsert&lt;/code&gt;&lt;/strong&gt; command to the end of the key binding macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;Leader&amp;gt;p :w&amp;lt;CR&amp;gt;:split \| terminal python %&amp;lt;CR&amp;gt;:startinsert&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That puts the cursor into insert mode on the terminal view and closes it on key press right away - seems to do the trick!&lt;/p&gt;&#xA;" OwnerUserId="19100" LastEditorUserId="19100" LastEditDate="2018-09-24T00:28:10.983" LastActivityDate="2018-09-24T00:28:10.983" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17460" PostTypeId="2" ParentId="17450" CreationDate="2018-09-23T11:02:48.710" Score="11" Body="&lt;p&gt;According to following thread on the mailing list &lt;em&gt;vim_use&lt;/em&gt;  from 03.10.15&#xA;(&lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_use/6yqU3RX2CWA&quot; rel=&quot;noreferrer&quot;&gt;https://groups.google.com/forum/#!topic/vim_use/6yqU3RX2CWA&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;How to copy and rename a file with netrw where the target and source directory are the same?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;answered by the author of netrw DrChip himself:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Copy a file using the usual netrw method for copying:  (assuming cursor &#xA;  is atop the file to be copied, and that the file is a file, not a director) &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; mt (mark target) &#xA; mf (mark file) &#xA; mc &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;You'll be given a prompt:  &lt;code&gt;Copy [filename] to : [filename]&lt;/code&gt; &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Just edit the 2nd instance of &lt;code&gt;[filename]&lt;/code&gt; to whatever you want, then hit &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Regards, &#xA;  Chip Campbell &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can confirm that the issue raised on the mailing list also still exist for me. Sorry for not testing before mentioning this thread! The error message is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;**error** (netrw) tried using g:netrw_localcopycmd&amp;lt;cp&amp;gt;; it doesn't work!  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OS: macOS 10.12&lt;br&gt;&#xA;Vim: 8.1.0280 (MacVim Release 151)&lt;br&gt;&#xA;Netrw: v156 (doc claims v162, but file is still v156)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As described you should be able to avoid the issue by either setting in general&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;let g:netrw_keepdir=0&lt;/code&gt; (default value is &lt;code&gt;1&lt;/code&gt;) in your vimrc, or &lt;/li&gt;&#xA;&lt;li&gt;press first &lt;code&gt;cd&lt;/code&gt; (netrw v162) (formerly &lt;code&gt;c&lt;/code&gt; v156) and then &lt;code&gt;mt mf mc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I still experience an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;**error** (netrw) copy failed; perhaps due to vim's current directory&amp;lt;/Users/hotschke/.vim-configs/main&amp;gt; not matching netrw's (/Users/hotschke/.vim-configs/main/) (see :help netrw-c)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The obvious difference is a missing final slash and the surrounding brackets. I would really hope that netrw could be improved to support this regardless of the setting &lt;code&gt;g:netrw_keepdir&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;newer netrw versions can be downloaded from &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;noreferrer&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#NETRW&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;for installation hints of netrw see &lt;a href=&quot;https://vi.stackexchange.com/questions/11604/vim-8-packages-how-do-i-overwrite-a-default-package&quot;&gt;Vim 8 packages, how do I overwrite a default package?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-09-24T13:17:57.310" LastActivityDate="2018-09-24T13:17:57.310" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17461" PostTypeId="2" ParentId="17439" CreationDate="2018-09-23T11:19:25.723" Score="10" Body="&lt;h2&gt;Honza's UltiSnips Snippet &lt;code&gt;gentbl&amp;lt;number&amp;gt;x&amp;lt;number&amp;gt;&lt;/code&gt;&lt;/h2&gt;&#xA;&lt;p&gt;available in the repository &lt;a href=&quot;https://github.com/honza/vim-snippets/blob/master/UltiSnips/tex.snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/honza/vim-snippets/blob/master/UltiSnips/tex.snippets&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Using this snippet which uses the python interpolation feature of UltiSnips, you can enter e.g.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;gentbl5x3&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which will expand to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\begin{tabular}{||||}&#xA;   &amp;amp;  &amp;amp;  \\&#xA;   &amp;amp;  &amp;amp;  \\&#xA;   &amp;amp;  &amp;amp;  \\&#xA;   &amp;amp;  &amp;amp;  \\&#xA;   &amp;amp;  &amp;amp;  \\&#xA;\end{tabular}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note the jump marks of UltiSnips are not visible.&lt;/p&gt;&#xA;&lt;p&gt;For a possibility to adapt this for matrix environments, see the update of this answer.&lt;/p&gt;&#xA;&lt;p&gt;Additionally rows can be added afterwards with the snippet &lt;code&gt;tr&amp;lt;number&amp;gt;&amp;lt;tab&amp;gt;&lt;/code&gt;. Having three columns you would enter&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;tr3&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to get&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; &amp;amp;  &amp;amp;  \\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Update due to request in comment&lt;/h2&gt;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;global !p&#xA;def create_matrix(snip):&#xA;&#xA;        matrix_str = (snip.buffer[snip.line].split('mat')[0]+'matrix').strip()&#xA;&#xA;        rows = 'x'.join(snip.buffer[snip.line].split(&amp;quot;x&amp;quot;, 2)[:-1])&#xA;        cols = 'x'.join(snip.buffer[snip.line].split(&amp;quot;x&amp;quot;, 2)[-1:])&#xA;&#xA;        int_val = lambda string: int(''.join(s for s in string if s.isdigit()))&#xA;&#xA;        rows = int_val(rows)&#xA;        cols = int_val(cols)&#xA;&#xA;        offset = cols + 1&#xA;        old_spacing = snip.buffer[snip.line][:snip.buffer[snip.line].rfind('\t') + 1]&#xA;&#xA;        snip.buffer[snip.line] = ''&#xA;&#xA;        final_str = old_spacing + &amp;quot;\\begin{&amp;quot;+matrix_str+&amp;quot;}\n&amp;quot;&#xA;        for i in range(rows):&#xA;                final_str += old_spacing + '\t'&#xA;                final_str += &amp;quot; &amp;amp; &amp;quot;.join(['$' + str(i * cols + j + offset) for j in range(cols)])&#xA;&#xA;                final_str += &amp;quot; \\\\\\\n&amp;quot;&#xA;&#xA;        final_str += old_spacing + &amp;quot;\\end{&amp;quot;+matrix_str+&amp;quot;}\n$0&amp;quot;&#xA;&#xA;        snip.expand_anon(final_str)&#xA;endglobal&#xA;&#xA;pre_expand &amp;quot;create_matrix(snip)&amp;quot;&#xA;snippet &amp;quot;(small|[bBpvV])?mat(rix)?(\d+)x(\d+)&amp;quot; &amp;quot;Generate (small|[bBpvV])?matrix of *rows* by *columns*&amp;quot; br&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This adds following snippet variants&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;matrix&amp;lt;N&amp;gt;x&amp;lt;M&amp;gt;&amp;lt;Tab&amp;gt;&#xA;bmatrix&amp;lt;N&amp;gt;x&amp;lt;M&amp;gt;&amp;lt;Tab&amp;gt;&#xA;Bmatrix&amp;lt;N&amp;gt;x&amp;lt;M&amp;gt;&amp;lt;Tab&amp;gt;&#xA;pmatrix&amp;lt;N&amp;gt;x&amp;lt;M&amp;gt;&amp;lt;Tab&amp;gt;&#xA;vmatrix&amp;lt;N&amp;gt;x&amp;lt;M&amp;gt;&amp;lt;Tab&amp;gt;&#xA;Vmatrix&amp;lt;N&amp;gt;x&amp;lt;M&amp;gt;&amp;lt;Tab&amp;gt;&#xA;smallmatrix&amp;lt;N&amp;gt;x&amp;lt;M&amp;gt;&amp;lt;Tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Additionally, all of them can be shortened by replacing &lt;code&gt;matrix&lt;/code&gt; with &lt;code&gt;mat&lt;/code&gt;, e.g.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;bmat4x3&amp;lt;Tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which will give you&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;\begin{bmatrix}&#xA;   &amp;amp;  &amp;amp;  \\&#xA;   &amp;amp;  &amp;amp;  \\&#xA;   &amp;amp;  &amp;amp;  \\&#xA;   &amp;amp;  &amp;amp;  \\&#xA;\end{bmatrix}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;LuaSnip&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;for a &lt;a href=&quot;https://github.com/L3MON4D3/LuaSnip&quot; rel=&quot;nofollow noreferrer&quot;&gt;LuaSnip&lt;/a&gt; version you can find a definition here:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/evesdropper/luasnip-latex-snippets.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/evesdropper/luasnip-latex-snippets.nvim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2023-04-05T07:25:22.670" LastActivityDate="2023-04-05T07:25:22.670" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17463" PostTypeId="2" ParentId="17450" CreationDate="2018-09-23T13:30:30.033" Score="2" Body="&lt;p&gt;First, I want to thank Hotcshke for sharing his link to DrChip. If I could up-vote home more, I would. Using the very latest version of netrw and following DrChip's guidance we still experienced the same issues described by the OP in &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_use/6yqU3RX2CWA&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://groups.google.com/forum/#!topic/vim_use/6yqU3RX2CWA&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT, DrChip provided an important setting that allows a simple &lt;code&gt;cp&lt;/code&gt; to work as expected.&#xA;According to the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#:Explore&quot; rel=&quot;nofollow noreferrer&quot;&gt;pi_netrw&lt;/a&gt; docs&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;MAKING THE BROWSING DIRECTORY THE CURRENT DIRECTORY&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;By default, |g:netrw_keepdir| is 1.  This setting means that the&#xA;  current directory will not track the browsing directory.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Setting g:netrw_keepdir to 0 tells netrw to make vim's current&#xA;  directory to track netrw's browsing directory.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Add &lt;code&gt;g:netrw_keepdir=0&lt;/code&gt; to your .vimrc. You can then use an os shell to perform the copy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!cp old-filename new-file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;---- FOLLOWUP INFORMATION ----&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As suggested by Hotcshke, I reported this issue Dr Campbell (the author of the netrw plugin).  Dr. Campbell graciously responded with the following&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Hello:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;I'm working out bugs now; when they (seem to be|are) gone, I'll do a &#xA;  release.  I think I'll try to make a copy mechanism easier for files&#xA;  in  the same directory; I'll have to try to do the same for remotely &#xA;  accessed files, too.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Regards, Chip Campbell&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="19082" LastEditorUserId="19082" LastEditDate="2018-10-11T12:19:23.897" LastActivityDate="2018-10-11T12:19:23.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17464" PostTypeId="1" AcceptedAnswerId="17588" CreationDate="2018-09-23T20:59:45.673" Score="9" ViewCount="10633" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/vim/vim-win32-installer/releases/tag/v8.1.0428&quot; rel=&quot;noreferrer&quot;&gt;64-bit Vim 8.1.0428&lt;/a&gt; on Windows 10 release 1803.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://blogs.msdn.microsoft.com/commandline/2016/09/22/24-bit-color-in-the-windows-console/&quot; rel=&quot;noreferrer&quot;&gt;Windows 10 console now has 24-bit colours&lt;/a&gt;, and &lt;a href=&quot;https://github.com/vim/vim/commit/cafafb381a04e33f3ce9cd15dd9f94b73226831f&quot; rel=&quot;noreferrer&quot;&gt;Vim 8 has been patched&lt;/a&gt; to handle 24-bit colours in the Windows console (i.e. using &lt;code&gt;vim.exe&lt;/code&gt; inside &lt;code&gt;cmd.exe&lt;/code&gt; &lt;strong&gt;not&lt;/strong&gt; gVim) using &lt;code&gt;termguicolors&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can get reasonable colours using the Console &lt;a href=&quot;https://github.com/Microsoft/console/tree/master/tools/ColorTool&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;ColorTool&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However &lt;code&gt;termguicolors&lt;/code&gt; appears to make no difference and I cannot tell if a full 24-bit colour display is being used. Changing the Vim &lt;code&gt;colorscheme&lt;/code&gt; has no impact, the colours are almost entirely defined by the console colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example the &lt;a href=&quot;https://github.com/jacoborus/tender.vim&quot; rel=&quot;noreferrer&quot;&gt;tender&lt;/a&gt; colorscheme is definitely 24-bit, but I cannot see how to get it to work with &lt;code&gt;vim.exe&lt;/code&gt; in a dos/console prompt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have examples of how they have used &lt;code&gt;termguicolors&lt;/code&gt; / 24-bit &lt;code&gt;colorscheme&lt;/code&gt;s in the Windows console?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit: I think I'm more asking is it possible to get a 256 colour &lt;code&gt;colorscheme&lt;/code&gt; working in Vim in a DOS prompt? Even though you can choose from a palette of 24-bit colours, you can still only choose 16 of them&quot;&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I've achieved so far, you can see the blatant issues with the Airline Theme colours but I'm not so bothered about that, I'm just trying to figure out what impact the &lt;code&gt;termguicolors&lt;/code&gt; should have:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bCAq2.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bCAq2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I have used the &lt;a href=&quot;http://github.com/guns/xterm-color-table.vim&quot; rel=&quot;noreferrer&quot;&gt;xterm-color-table.vim plugin&lt;/a&gt; to inspect what colours that I do have:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3ZGkU.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3ZGkU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;termguicolors&lt;/code&gt; changes all colours to white.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would appear that I have 16 colours. &lt;code&gt;set t_Co=8&lt;/code&gt; reduces the colour palette, where as &lt;code&gt;set t_Co=16&lt;/code&gt; and &lt;code&gt;set t_Co=256&lt;/code&gt; give the same result. &lt;/p&gt;&#xA;" OwnerUserId="11986" LastEditorUserId="11986" LastEditDate="2020-01-10T20:19:56.763" LastActivityDate="2020-01-10T20:19:56.763" Title="24-bit / 256 colorscheme in Windows console" Tags="|colorscheme|microsoft-windows|color|console|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17465" PostTypeId="1" AcceptedAnswerId="17474" CreationDate="2018-09-24T07:28:35.300" Score="14" ViewCount="5331" Body="&lt;p&gt;Does vim allow for searching raw strings?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If what I want to search is in the variable &lt;code&gt;string&lt;/code&gt;, does the following code work? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call search('\V' . escape(string, '\'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or are there other more direct ways?&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="1292" LastEditDate="2018-09-25T10:19:50.343" LastActivityDate="2019-07-18T09:39:07.040" Title="How to search literally without any regex pattern?" Tags="|regular-expression|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17466" PostTypeId="1" AcceptedAnswerId="17467" CreationDate="2018-09-24T14:36:45.057" Score="-1" ViewCount="1339" Body="&lt;p&gt;I have the following &lt;code&gt;vimrc&lt;/code&gt; file :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;if has(&quot;autocmd&quot;)&#xA;  au BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) | exe &quot;normal! g'\&quot;&quot; | endif&#xA;endif&#xA;&#xA;&#xA;if &amp;amp;compatible&#xA;  set nocompatible               &quot; Be iMproved&#xA;endif&#xA;&#xA;set runtimepath+=/home/mohsen/.vim/bundle/neobundle.vim/&#xA;&#xA;call neobundle#begin(expand('/home/mohsen/.vim/bundle'))&#xA;&#xA;NeoBundleFetch 'Shougo/neobundle.vim'&#xA;&#xA;NeoBundle 'rdnetto/YCM-Generator'&#xA;NeoBundle 'Shougo/neosnippet.vim'&#xA;NeoBundle 'Shougo/neosnippet-snippets'&#xA;NeoBundle 'tpope/vim-fugitive'&#xA;NeoBundle 'ctrlpvim/ctrlp.vim'&#xA;NeoBundle 'flazz/vim-colorschemes'&#xA;&#xA;NeoBundle 'Shougo/vimshell', { 'rev' : '3787e5' }&#xA;&#xA;call neobundle#end()&#xA;&#xA;filetype plugin indent on&#xA;&#xA;NeoBundleCheck&#xA;&#xA;&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Bundle 'YouCompleteMe'&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'command-t'&#xA;Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}&#xA;&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&#xA;Plugin 'tmhedberg/SimpylFold'&#xA;filetype plugin on&#xA;set splitbelow&#xA;set splitright&#xA;nnoremap &amp;lt;C-J&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-J&amp;gt;&#xA;nnoremap &amp;lt;C-K&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-K&amp;gt;&#xA;nnoremap &amp;lt;C-L&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-L&amp;gt;&#xA;nnoremap &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-H&amp;gt;&#xA;set foldmethod=indent&#xA;set foldlevel=99&#xA;nnoremap &amp;lt;space&amp;gt; za&#xA;&#xA;let g:SimpylFold_docstring_preview=1&#xA;au BufNewFile,BufRead *.py&#xA;    \ set tabstop=4 |&#xA;    \ set softtabstop=4 |&#xA;    \ set shiftwidth=4 |&#xA;    \ set textwidth=79 |&#xA;    \ set expandtab |&#xA;    \ set autoindent |&#xA;    \ set fileformat=unix&#xA;au BufNewFile,BufRead *.js, *.html, *.css&#xA;    \ set tabstop=2 |&#xA;    \ set softtabstop=2 |&#xA;    \ set shiftwidth=2&#xA;Plugin 'vim-scripts/indentpython.vim'&#xA;au BufRead,BufNewFile *.py,*.pyw,*.c,*.h &quot;match BadWhitespace /\s\+$/&#xA;set encoding=utf-8&#xA;&#xA;let g:ycm_autoclose_preview_window_after_completion=1&#xA;map &amp;lt;leader&amp;gt;g  :YcmCompleter GoToDefinitionElseDeclaration&amp;lt;CR&amp;gt;&#xA;&#xA;&#xA;&#xA;&#xA;execute pathogen#infect()&#xA;&#xA;&#xA;Plugin 'vim-syntastic/syntastic'&#xA;Plugin 'nvie/vim-flake8'&#xA;let python_highlight_all=1&#xA;&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 0&#xA;&#xA;&#xA;let g:syntastic_python_checkers = ['pylint']&#xA;let g:syntastic_php_checkers = ['php', 'phpcs', 'phpmd']&#xA;let g:syntastic_tex_checkers = ['lacheck', 'text/language_check']&#xA;let g:syntastic_aggregate_errors = 1&#xA;let g:syntastic_enable_perl_checker = 1&#xA;&#xA;&#xA;Plug 'rdnetto/YCM-Generator' , { 'branch': 'stable'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And my bundle dir is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ls -l .vim/bundle/&#xA;total 68&#xA;drwxr-xr-x  6 mohsen mohsen 4096 Sep 19 15:12 command-t&#xA;drwxr-xr-x  6 mohsen mohsen 4096 Sep 23 21:23 ctrlp.vim&#xA;drwxr-xr-x  4 mohsen mohsen 4096 Sep 19 17:16 indentpython.vim&#xA;-rw-r--r--  1 mohsen mohsen  552 Sep 23 21:23 NeoBundle.lock&#xA;drwxr-xr-x  8 mohsen mohsen 4096 Sep 23 21:18 neobundle.vim&#xA;drwxr-xr-x  4 mohsen mohsen 4096 Sep 23 21:21 neosnippet-snippets&#xA;drwxr-xr-x 12 mohsen mohsen 4096 Sep 23 21:22 neosnippet.vim&#xA;drwxr-xr-x  7 mohsen mohsen 4096 Sep 19 17:09 SimpylFold&#xA;drwxr-xr-x  6 mohsen mohsen 4096 Sep 19 15:05 sparkup&#xA;drwxr-xr-x  8 mohsen mohsen 4096 Sep 22 20:46 syntastic&#xA;drwxr-xr-x  5 mohsen mohsen 4096 Sep 23 21:22 vim-colorschemes&#xA;drwxr-xr-x  5 mohsen mohsen 4096 Sep 24 16:26 vim-flake8&#xA;drwxr-xr-x  7 mohsen mohsen 4096 Sep 19 15:12 vim-fugitive&#xA;drwxr-xr-x  7 mohsen mohsen 4096 Sep 23 21:23 vimshell_3787e5&#xA;drwxr-xr-x  8 mohsen mohsen 4096 Sep 19 14:42 Vundle.vim&#xA;drwxr-xr-x  5 mohsen mohsen 4096 Sep 23 19:55 YCM-Generator&#xA;drwxr-xr-x 11 mohsen mohsen 4096 Sep 20 17:50 YouCompleteMe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run vim I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/mohsen/.vim/vimrc:&#xA;line  164:&#xA;E464: Ambiguous use of user-defined command: Plug 'rdnetto/YCM-Generator' , { 'branch': 'stable'}&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's my problem?&lt;/p&gt;&#xA;" OwnerUserId="4680" LastActivityDate="2018-09-24T15:43:17.383" Title="E464: Ambiguous use of user-defined command: Plug 'rdnetto/YCM-Generator' , { 'branch': 'stable'}" Tags="|vimrc|plugin-you-complete-me|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17467" PostTypeId="2" ParentId="17466" CreationDate="2018-09-24T15:43:17.383" Score="4" Body="&lt;p&gt;The error message comes from the last line of your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'rdnetto/YCM-Generator' , { 'branch': 'stable'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a call to the &lt;code&gt;Plug&lt;/code&gt; command of the &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim-plug&lt;/a&gt; plugin manager. To work, this line should be surrounded by the following lines as it's stated &lt;a href=&quot;https://github.com/junegunn/vim-plug#usage&quot; rel=&quot;nofollow noreferrer&quot;&gt;in the readme&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;Plug 'rdnetto/YCM-Generator' , { 'branch': 'stable'}&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now your &lt;em&gt;real&lt;/em&gt; problem is that you try to use three or four different plugins managers: that is totally unnecessary. Instead you should have a read at our question &lt;a href=&quot;https://vi.stackexchange.com/q/388/1841&quot;&gt;What is the difference between the vim plugin managers?&lt;/a&gt;, decide which plugin manager you want to use and use only this one for all of your plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At a second reading of your vimrc: you have plugins that you're trying to install several time (i.e. &lt;code&gt;vim-fugitive&lt;/code&gt;) I guess it means that you blindly copied the vimrc of other people and mixed them together without understanding every line. That is not a good idea (your question is the proof of what I'm saying). You would probably loose less time crafting your own vimrc to fit your own needs than debugging someone else's config.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-09-24T15:43:17.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17468" PostTypeId="2" ParentId="14022" CreationDate="2018-09-24T17:10:21.510" Score="2" Body="&lt;h3&gt;Builtin command &lt;code&gt;:setfiletype&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;For setting the filetype there is additionally a dedicated vim command &lt;code&gt;:setfiletype&lt;/code&gt; which supports tab completion and &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setfiletype mar&amp;lt;tab&amp;gt;&#xA;:setfiletype &amp;lt;C-d&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command can be abbreviated as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setf mar&amp;lt;tab&amp;gt;&#xA;:setf &amp;lt;C-d&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Plugin fzf.vim&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The plugin &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf.vim&lt;/a&gt; provides furthermore the command &lt;code&gt;:Filetypes&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Filet[ypes]&amp;lt;CR&amp;gt;&#xA;&amp;gt; prompt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the prompt you can enter a filetype with fuzzy matching e.g. &lt;code&gt;mkd&lt;/code&gt; for &lt;code&gt;markdown&lt;/code&gt; or &lt;code&gt;jsc&lt;/code&gt; for &lt;code&gt;javascript&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2018-09-24T17:10:21.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17469" PostTypeId="1" AcceptedAnswerId="17470" CreationDate="2018-09-24T17:16:02.707" Score="2" ViewCount="762" Body="&lt;p&gt;When I press &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; in visual mode, I don't immediately return to normal mode (the selection persists). I think that is because I have a mapping defined in visual mode shat starts from &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. I tried doing the following to find that mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir! &amp;gt; vim_keys.txt&#xA;:silent verbose map&#xA;:redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But there are no mappings that start with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v  [&quot;          *@:&amp;lt;C-U&amp;gt;exe &quot;normal! gv&quot;|call search('\%(^\s*&quot;.*\n\)\%(^\s*&quot;\)\@!', &quot;bW&quot;)&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/ftplugin/vim.vim&#xA;n  [&quot;          *@:call search('\%(^\s*&quot;.*\n\)\%(^\s*&quot;\)\@!', &quot;bW&quot;)&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/ftplugin/vim.vim&#xA;v  []          *@m':&amp;lt;C-U&amp;gt;exe &quot;normal! gv&quot;|call search('^\s*endf*\%[unction]\&amp;gt;', &quot;bW&quot;)&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/ftplugin/vim.vim&#xA;n  []          *@m':call search('^\s*endf*\%[unction]\&amp;gt;', &quot;bW&quot;)&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/ftplugin/vim.vim&#xA;v  [[          *@m':&amp;lt;C-U&amp;gt;exe &quot;normal! gv&quot;|call search('^\s*fu\%[nction]\&amp;gt;', &quot;bW&quot;)&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/ftplugin/vim.vim n  [[          *@m':call search('^\s*fu\%[nction]\&amp;gt;', &quot;bW&quot;)&amp;lt;CR&amp;gt; Last set from /usr/share/vim/vim80/ftplugin/vim.vim&#xA;v  ]&quot;          *@:&amp;lt;C-U&amp;gt;exe &quot;normal! gv&quot;|call search('^\(\s*&quot;.*\n\)\@&amp;lt;!\(\s*&quot;\)', &quot;W&quot;)&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/ftplugin/vim.vim&#xA;n  ]&quot;          *@:call search('^\(\s*&quot;.*\n\)\@&amp;lt;!\(\s*&quot;\)', &quot;W&quot;)&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/ftplugin/vim.vim&#xA;v  ][          *@m':&amp;lt;C-U&amp;gt;exe &quot;normal! gv&quot;|call search('^\s*endf*\%[unction]\&amp;gt;', &quot;W&quot;)&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/ftplugin/vim.vim&#xA;n  ][          *@m':call search('^\s*endf*\%[unction]\&amp;gt;', &quot;W&quot;)&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/ftplugin/vim.vim&#xA;v  ]]          *@m':&amp;lt;C-U&amp;gt;exe &quot;normal! gv&quot;|call search('^\s*fu\%[nction]\&amp;gt;', &quot;W&quot;)&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/ftplugin/vim.vim&#xA;n  ]]          *@m':call search('^\s*fu\%[nction]\&amp;gt;', &quot;W&quot;)&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/ftplugin/vim.vim&#xA;v  &amp;lt;C-Z&amp;gt;       * &amp;lt;Nop&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  &amp;lt;Space&amp;gt;     * zR&#xA;    Last set from ~/.vimrc&#xA;n  ,bd         * :Bclose&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.dotfiles/.vim/plugin/bclose.vim&#xA;   ,             &amp;lt;Plug&amp;gt;(easymotion-prefix)&#xA;    Last set from ~/.vimrc&#xA;n  ,gl         * :!git log&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ,gp         * :!git push&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ,gc         * :!git commit -m '&#xA;    Last set from ~/.vimrc&#xA;n  ,ga         * :!git add&#xA;    Last set from ~/.vimrc&#xA;n  ,gs         * :!git status&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ,rs         * :so $MYVIMRC&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ,rr         * :vsplit $MYVIMRC&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ,sc         * :SessionClose&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ,ss         * :SessionSave&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ,sl         * :SessionList&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  =A          * gg=G&amp;lt;C-O&amp;gt;&amp;lt;C-O&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  H           * ^&#xA;    Last set from ~/.vimrc&#xA;n  L           * $&#xA;    Last set from ~/.vimrc&#xA;n  Q           * :q&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;v  gx            &amp;lt;Plug&amp;gt;NetrwBrowseXVis&#xA;    Last set from /usr/share/vim/vim80/plugin/netrwPlugin.vim&#xA;n  gx            &amp;lt;Plug&amp;gt;NetrwBrowseX&#xA;    Last set from /usr/share/vim/vim80/plugin/netrwPlugin.vim&#xA;o  p           * i(&#xA;    Last set from ~/.vimrc&#xA;v  &amp;lt;Plug&amp;gt;NetrwBrowseXVis * :&amp;lt;C-U&amp;gt;call netrw#BrowseXVis()&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/plugin/netrwPlugin.vim&#xA;n  &amp;lt;Plug&amp;gt;NetrwBrowseX * :call netrw#BrowseX(expand((exists(&quot;g:netrw_gx&quot;)? g:netrw_gx : '&amp;lt;cfile&amp;gt;')),netrw#CheckIfRemote())&amp;lt;CR&amp;gt;&#xA;    Last set from /usr/share/vim/vim80/plugin/netrwPlugin.vim&#xA;n  &amp;lt;F2&amp;gt;        * :wq&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  &amp;lt;F1&amp;gt;        * &amp;lt;Nop&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ´           * :set list!&amp;lt;CR&amp;gt;:echo &quot;List is &quot;.&amp;amp;expandtab&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ³           * :set expandtab!&amp;lt;CR&amp;gt;:echo &quot;Expand tab is &quot;.&amp;amp;expandtab&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ö           * :vs&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ó           * :%s/&#xA;    Last set from ~/.vimrc&#xA;n  ÷           * :set wrap!&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  î           * :tabnext&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ð           * :tabprevious&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  ì           * :!ls&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;n  æ           * :Grep&#xA;    Last set from ~/.vimrc&#xA;n  å           * :e&#xA;    Last set from ~/.vimrc&#xA;n  ï           * :b&#xA;    Last set from ~/.vimrc&#xA;n  ô           * :call ReportFileSaveMark()&amp;lt;CR&amp;gt;&#xA;    Last set from ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I find out why my Vim doesn't immediately exit visual mode when I press &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2119" LastEditorUserId="2119" LastEditDate="2018-09-24T17:33:47.713" LastActivityDate="2018-09-24T18:14:40.633" Title="How to find why esc doesn't work right away in visual mode?" Tags="|key-bindings|visual-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17470" PostTypeId="2" ParentId="17469" CreationDate="2018-09-24T18:14:40.633" Score="3" Body="&lt;p&gt;It's possible that you had a mapping in visual mode whose &lt;code&gt;{lhs}&lt;/code&gt; produces a sequence of key codes beginning with &lt;code&gt;Escape&lt;/code&gt;.&#xA;You can check what is the sequence of key codes produced by a key by pressing on the command-line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C-v &amp;lt;key&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, on my machine, &lt;code&gt;F1&lt;/code&gt; produces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[OP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^[&lt;/code&gt; is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Caret_notation&quot; rel=&quot;nofollow noreferrer&quot;&gt;caret notation&lt;/a&gt; of the &lt;code&gt;Escape&lt;/code&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a visual-mode mapping whose &lt;code&gt;{lhs}&lt;/code&gt; is &lt;code&gt;F1&lt;/code&gt;, when you press &lt;code&gt;Escape&lt;/code&gt; in visual mode, Vim may wait for &lt;code&gt;OP&lt;/code&gt; to come.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can tweak the amount of time Vim waits for a sequence of key codes to complete with the option &lt;code&gt;'ttimeoutlen'&lt;/code&gt;.&#xA;By default, its value is &lt;code&gt;-1&lt;/code&gt;, which means that Vim uses the value of &lt;code&gt;'timeoutlen'&lt;/code&gt;.&lt;br&gt;&#xA;This other option controls the amount of time Vim waits for the &lt;code&gt;{lhs}&lt;/code&gt; of a mapping to complete.&#xA;The default value of the latter is &lt;code&gt;1000&lt;/code&gt;ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The help at &lt;code&gt;:h 'ttm&lt;/code&gt; suggests the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set timeout timeoutlen=3000 ttimeoutlen=100&#xA;     ├─────┘ ├─────────────┘ ├─────────────┘&#xA;     │       │               └ wait 0.1s for a sequence of key codes to complete&#xA;     │       │&#xA;     │       └ waits 3s for a mapping to complete&#xA;     │&#xA;     └ don't wait indefinitely for the `{lhs}` a mapping or a sequence of key code to complete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2018-09-24T18:14:40.633" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17471" PostTypeId="2" ParentId="17378" CreationDate="2018-09-24T18:14:58.070" Score="2" Body="&lt;p&gt;&lt;code&gt;:h BufWinEnter&lt;/code&gt; is the event:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd! BufWinEnter * if &amp;amp;previewwindow | setlocal cursorline | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess the discrepancy is because WinEnter is triggered before 'previewwindow' is set. Possibly what's meant by this note in the help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        Note: For split and tabpage commands the&#xA;        WinEnter event is triggered after the split&#xA;        or tab command but before the file is loaded.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks to @romainl for the solution!&lt;/p&gt;&#xA;" OwnerUserId="2045" LastActivityDate="2018-09-24T18:14:58.070" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17474" PostTypeId="2" ParentId="17465" CreationDate="2018-09-25T06:27:24.947" Score="9" Body="&lt;p&gt;Vim does not have an (easy) native way to search for text literally. However, I find that the default of using regular expressions makes the search quite a bit more powerful, if you have grokked at least the basics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the few times I have needed to search for text literally, I use basically what you have shown here: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call search('\V' . escape(string, '\'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which you can wrap into a custom command to make searching text literally more easy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Search literally!&#xA;com! -nargs=1 Search :let @/='\V'.escape(&amp;lt;q-args&amp;gt;, '\\')| normal! n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can search literally by using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Search my literal text with \\ and . and ^ and more regexpes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to search for the text &quot;my literal text with \ and . and ^ and more regexpes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command I have taken from my .vimrc but I can't remember if I ever actually used that command, besides showing how to make searching for a literal text more easily available.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-09-25T06:27:24.947" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17475" PostTypeId="1" CreationDate="2018-09-25T07:53:08.147" Score="1" ViewCount="177" Body="&lt;p&gt;I have this following mapping in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Toggle search next with blink and without blink&#xA;let s:enabled = 0&#xA;&#xA;function! NextMatchToggle()&#xA;    if s:enabled&#xA;        unmap &amp;lt;buffer&amp;gt; n&#xA;        unmap &amp;lt;buffer&amp;gt; N&#xA;        let s:enabled = 0&#xA;    else&#xA;        nnoremap &amp;lt;buffer&amp;gt; n nzvzz&#xA;        nnoremap &amp;lt;buffer&amp;gt; N Nzvzz&#xA;        let s:enabled = 1&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;localleader&amp;gt;nmt :call NextMatchToggle()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It helps me toggle between two different behaviours of &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want this similar thing with &lt;code&gt;UltiSnips&lt;/code&gt;[&lt;a href=&quot;https://github.com/SirVer/ultisnips]&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/SirVer/ultisnips]&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I could do is to add two snippets with same string &quot;describing&quot; these snippets, and when I type this &quot;describing&quot; string followed by &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; I will be asked which snippet I want to use, then I could choose which one to use. I don't want this, I want the same &quot;describing&quot; string to act differently at different times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am mainly going to use any solution to this problem (if exists) to &lt;code&gt;.tex&lt;/code&gt; files. Here's an example, it may be dull, but it'll explain what I mean: I'm writing some maths sets, say &lt;code&gt;$SL(n, \mathbb{R}$&lt;/code&gt;, but for some other &lt;code&gt;.tex&lt;/code&gt; document I might want to write this same set like this- &lt;code&gt;$SL_n(\mathbb{R})$&lt;/code&gt; (maybe I am a coauthor and the other author has already written it like this). But I want &lt;code&gt;slnr&lt;/code&gt; to be the string &quot;describing&quot; both the snippets. That's why I wanted a mechanism to switch between these two. Could this be done some other way?&lt;/p&gt;&#xA;" OwnerUserId="16884" LastEditorUserId="16884" LastEditDate="2018-09-30T12:41:45.367" LastActivityDate="2018-10-03T20:53:48.690" Title="Toggle UltiSnips" Tags="|vimscript|plugin-ultisnips|" AnswerCount="0" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17476" PostTypeId="2" ParentId="17446" CreationDate="2018-09-25T08:39:14.077" Score="1" Body="&lt;h2&gt;Python module &lt;a href=&quot;https://pypi.org/project/ruamel.yaml/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;ruamel.yaml&lt;/code&gt;&lt;/a&gt; as &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27equalprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;equalprg&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Installation of &lt;code&gt;ruamel.yaml&lt;/code&gt; is possible with &lt;a href=&quot;https://pip.pypa.io/en/stable/quickstart/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ pip install ruamel.yaml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ruamel.yaml&lt;/code&gt; is python3 compatible, i.e. &lt;code&gt;pip3 install ruamel.yaml&lt;/code&gt; works as well.&#xA;If you want to install it only in your home directory, use &lt;code&gt;pip install --user ruamel.yaml&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ensure that &lt;code&gt;import ruamel.yaml&lt;/code&gt; works for the python version vim sees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Configure &lt;code&gt;equalprg&lt;/code&gt; of vim for yaml files with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup myequalprograms&#xA;  autocmd!&#xA;  autocmd FileType yaml setlocal equalprg=python\ -c\ \'import\ sys;\ from\ ruamel.yaml\ import\ YAML;yaml=YAML();yaml.dump(yaml.load(sys.stdin),sys.stdout)\'&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, place following line in &lt;code&gt;~/.vim/after/ftplugin/yaml.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal equalprg=python\ -c\ \'import\ sys;\ from\ ruamel.yaml\ import\ YAML;yaml=YAML();yaml.dump(yaml.load(sys.stdin),sys.stdout)\'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you should be able to press &lt;code&gt;=ip&lt;/code&gt; for your example to get the desired output.&#xA;I have tried it on my machine with python3 and it works.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Note you could also use &lt;a href=&quot;https://pyyaml.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;pyyaml&lt;/code&gt;&lt;/a&gt; with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal equalprg=python\ -c\ \'import\ yaml,sys;print(yaml.dump(yaml.safe_load(sys.stdin),default_flow_style=False))\'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;pyyaml&lt;/code&gt; changes order, removes comments and other things. &lt;code&gt;ruamel.yaml&lt;/code&gt; explicitly tries to support the roundtrip of parsing and emitting without modifying these things.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There is also the project &lt;a href=&quot;https://github.com/mk-fg/pretty-yaml&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;pretty-yaml&lt;/code&gt;&lt;/a&gt; with a convenient command line interface&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ python -m pyaml demo.yaml&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the unfortunate similarity of the name &lt;code&gt;pyaml&lt;/code&gt; to &lt;code&gt;pyyaml&lt;/code&gt;. The author has made the decision that lists should be indented and therefore does not help you:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;List items get indented, as they should be.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finally, you could contact the maintainer of &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/indent/yaml.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;$VIMRUNTIME/indent/yaml.vim&lt;/code&gt;&lt;/a&gt; to ask him whether he would consider to add an option to achieve your style:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Vim indent file&#xA;&quot; Language:         YAML&#xA;&quot; Maintainer:       Nikolai Pavlov &amp;lt;zyx.vim@gmail.com&amp;gt;&#xA;&quot; Last Change:      2017 Jun 13&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-09-25T13:37:56.150" LastActivityDate="2018-09-25T13:37:56.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17477" PostTypeId="1" CreationDate="2018-09-25T09:41:29.720" Score="2" ViewCount="55" Body="&lt;p&gt;I have following command: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;Leader&amp;gt;ntd :execute &quot;:tabe! &quot;. g:path .&quot;l_todo.txt&quot;&amp;lt;CR&amp;gt;&amp;lt;ESC&amp;gt; :execute &quot;:vsplit! &quot;.g:path .&quot;u_todo.txt&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both &lt;code&gt;tabe!&lt;/code&gt; and &lt;code&gt;vsplit!&lt;/code&gt; commands works fine as separate remapings. I want to join those commands into one remaping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to make the above command to work?&lt;/p&gt;&#xA;" OwnerUserId="16328" LastEditorUserId="1841" LastEditDate="2018-09-25T09:52:09.157" LastActivityDate="2018-09-25T15:17:54.527" Title="Remaping leader with :execute cannot run two commands at once" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17478" PostTypeId="2" ParentId="17477" CreationDate="2018-09-25T13:17:53.860" Score="4" Body="&lt;p&gt;You don't need to use two different &lt;code&gt;execute()&lt;/code&gt; calls, you can simply call both commands in &lt;code&gt;execute()&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;ntd :execute &quot;tabe! &quot;. g:path . &quot;l_todo.txt \| vsplit! &quot; . g:path . &quot;u_todo.txt&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the escaped piped character (&lt;code&gt;\|&lt;/code&gt;) it is escaped so that vim understands that it is part of the command fed to &lt;code&gt;execute&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, when you source your vimrc, Vim would try to execute first &lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;ntd :execute &quot;:tabe! &quot;. g:path . &quot;l_todo.txt&lt;/code&gt; followed by &lt;code&gt;vsplit! &quot; . g:path . &quot;u_todo.txt&quot;&amp;lt;CR&amp;gt;&lt;/code&gt; which is not what you want.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could also improve the readability of your code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let firstCommand=&quot;tabe! &quot;. getcwd() . &quot;/l_todo.txt&quot;&#xA;let secondCommand=&quot;vsplit! &quot; . getcwd() . &quot;/u_todo.txt&quot;&#xA;nnoremap &amp;lt;Leader&amp;gt;ntd :execute firstCommand . &quot;\|&quot; . secondCommand&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here we separate the different part of the string give to &lt;code&gt;execute()&lt;/code&gt; to see the two actions executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We also use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getcwd%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getcwd()&lt;/code&gt;&lt;/a&gt; to get the current working directory so that we don't need a global variable to get the path.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Several other points about your code:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You don't need the &lt;code&gt;:&lt;/code&gt; in the commands you feed to &lt;code&gt;execute()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Always use the non recurcive version of &lt;code&gt;map&lt;/code&gt; (i.e. &lt;code&gt;noremap&lt;/code&gt;) unless &lt;a href=&quot;https://vi.stackexchange.com/a/10130/1841&quot;&gt;you know what you're doing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Always specify a mode to &lt;code&gt;map&lt;/code&gt; (see &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#map-modes&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h map-modes&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-09-25T15:17:54.527" LastActivityDate="2018-09-25T15:17:54.527" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17479" PostTypeId="1" AcceptedAnswerId="17511" CreationDate="2018-09-25T13:44:12.960" Score="0" ViewCount="318" Body="&lt;p&gt;I installed both mvim(macvim) and vim through brew. vim was installed using &quot;brew install vim &quot; (with python3, doesn't matter ). The OS is High Sierra.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While mvim is completely fine, vim is completely messed up. For example, when I type gg, it goes to the top of the page instead of to the start. And I can't progress upwards. It sometimes overrides things like --insert--.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I disabled powerline and many other features. It still happens. &#xA;It works fine in terminal (as far as I could judge). It just doesn't work in iterm (also after changing the fonts back to default).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2018-09-26T23:23:27.830" Title="vim is messed up in iterm" Tags="|macvim|iterm2|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17480" PostTypeId="1" AcceptedAnswerId="17481" CreationDate="2018-09-25T16:42:28.293" Score="1" ViewCount="3598" Body="&lt;p&gt;The following code shows &lt;code&gt;invalid syntax&lt;/code&gt;. I assume syntastic is looking at Python2 for syntax-checking. I need it to look at Python3 instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def x():&#xA;  x = 42&#xA;  def y():&#xA;    nonlocal x&#xA;    x = 8&#xA;    return x&#xA;  return y&#xA;&#xA;print( x()() )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nonlocal&lt;/code&gt; is the method of telling Python3 that you do not want to shadow &lt;code&gt;x&lt;/code&gt;. It's a great and powerful feature that let's me quick and easily obscure code, and one of the many benefits of lacking &lt;code&gt;my&lt;/code&gt;, &lt;code&gt;let&lt;/code&gt;, &lt;code&gt;dim&lt;/code&gt;, and the like on variable declaration.&lt;/p&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="5078" LastEditDate="2018-09-25T17:11:58.507" LastActivityDate="2018-09-25T18:26:04.230" Title="How do I configure syntastic to use Python3 in Ubuntu?" Tags="|filetype-python|plugin-syntastic|linux-ubuntu|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17481" PostTypeId="2" ParentId="17480" CreationDate="2018-09-25T16:42:28.293" Score="4" Body="&lt;p&gt;Using Ubuntu, I couldn't figure out what was calling python or to change the default environment for all instances of syntastic. That would have been desirable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead what I did was install &lt;code&gt;flake8&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pip3 install flake8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can easily configure this to work by adding the following line to your &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_python_checkers=['flake8']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Beware though this has a lot of stuff that isn't just syntax checking, including a style-guide. I'm not sure why this just be as changing the default in a vim conf, but this seems to work.&lt;/p&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="5078" LastEditDate="2018-09-25T18:26:04.230" LastActivityDate="2018-09-25T18:26:04.230" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17482" PostTypeId="2" ParentId="17185" CreationDate="2018-09-25T18:37:44.377" Score="3" Body="&lt;h1&gt;Difference between vim plugins &amp;amp; packages&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help plugin&lt;/code&gt; tells us&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vim's functionality can be extended by adding plugins.  A plugin is nothing&#xA;more than a Vim script file that is loaded automatically when Vim starts.  You&#xA;can add a plugin very easily by dropping it in your plugin directory.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help packages&lt;/code&gt; gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A Vim package is a directory that contains one or more plugins.  The&#xA;advantages over normal plugins:&#xA;- A package can be downloaded as an archive and unpacked in its own directory.&#xA;  Thus the files are not mixed with files of other plugins.  That makes it&#xA;  easy to update and remove.&#xA;- A package can be a git, mercurial, etc. repository.  That makes it really&#xA;  easy to update.&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;em&gt;vim&lt;/em&gt; calls &lt;em&gt;'plugins'&lt;/em&gt; single script files that execute commands. &lt;em&gt;'Packages'&lt;/em&gt;, on the other hand, contain one or more plugins. Unfortunately, vim doesn't distinguish here where perhaps it should.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugins you and I are familiar with are the GitHub repos and vim.org compressed directories where the structure matches that of the runtime path:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a list of directories which will be searched for runtime&#xA;    files:&#xA;      filetype.vim  filetypes by file name |new-filetype|&#xA;      scripts.vim   filetypes by file contents |new-filetype-scripts|&#xA;      autoload/ automatically loaded scripts |autoload-functions|&#xA;      colors/   color scheme files |:colorscheme|&#xA;      compiler/ compiler files |:compiler|&#xA;      doc/      documentation |write-local-help|&#xA;      ftplugin/ filetype plugins |write-filetype-plugin|&#xA;      indent/   indent scripts |indent-expression|&#xA;      keymap/   key mapping files |mbyte-keymap|&#xA;      lang/     menu translations |:menutrans|&#xA;      menu.vim  GUI menus |menu.vim|&#xA;      pack/     packages |:packadd|&#xA;      plugin/   plugin scripts |write-plugin|&#xA;      print/    files for printing |postscript-print-encoding|&#xA;      spell/    spell checking files |spell|&#xA;      syntax/   syntax files |mysyntaxfile|&#xA;      tutor/    files for vimtutor |tutor|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, what you and I conceive of as plugins are really mini-runtime directories. But, we just said a plugin is a single script?!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, no. A &lt;code&gt;plugin script&lt;/code&gt; lives in &lt;code&gt;&amp;amp;rtp/plugin&lt;/code&gt; and is just executed. A &lt;em&gt;plugin&lt;/em&gt; in the more usual sense is a collection of scripts organized into this mini-runtime directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And each of &lt;em&gt;those&lt;/em&gt; directories can live in a package. See &lt;a href=&quot;https://github.com/benknoble/Dotfiles/tree/master/links/vim/pack&quot; rel=&quot;nofollow noreferrer&quot;&gt;my dotfiles&lt;/a&gt; for some examples of package organization.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;What do I do?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Your question deals specifically with a (new) filetype and its accompanying syntax files. But, to play nicely in the vim plugin ecosystem, you still want to mimic the &lt;code&gt;runtimepath&lt;/code&gt; structure.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ftdetect&lt;/code&gt; can hold vimscript to detect the filetype, as below; and &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;syntax&lt;/code&gt; can hold vimscript to define the syntax for the filetype&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So you might have the following files&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; myplugin/ftdetect/foo.vim&#xA;au BufNewFile,BufRead *.foo set filetype=foo&#xA;&#xA;&quot; myplugin/syntax/foo.vim&#xA;if exists(&quot;b:current_syntax&quot;)&#xA;     finish&#xA;endif&#xA;&#xA;echom &quot;Our syntax highlighting code will go here.&quot;&#xA;&#xA;let b:current_syntax = &quot;foo&quot;&#xA;&#xA;&quot; myplugin/autoload/myplugin.vim&#xA;function! myplugin#utility()&#xA;     &quot; do something useful&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;myplugin&lt;/code&gt; can then be a git repo (or similar) that is &quot;installed&quot; to &lt;code&gt;~/.vim/pack/some_fancy_name/start/myplugin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Notes&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hardway&lt;/a&gt; from Steve Losh contains a much deeper introduction to this material than I can present here.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-09-25T18:37:44.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17483" PostTypeId="2" ParentId="5015" CreationDate="2018-09-25T18:54:30.417" Score="1" Body="&lt;h3&gt;Simply ask the pupil to swap two &lt;em&gt;words&lt;/em&gt; with their Word™ processor…&lt;/h3&gt;&#xA;&lt;p&gt;…then show how the master does this with &lt;code&gt;vim&lt;/code&gt;. (Here is the &lt;a href=&quot;https://superuser.com/a/1117633/219226&quot;&gt;mapping&lt;/a&gt; to do so; more &lt;a href=&quot;http://vim.wikia.com/wiki/Swapping_characters,_words_and_lines&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.)&lt;/p&gt;&#xA;&lt;p&gt;Finally, let the pupil contemplate whether he/she truly has been working with a &lt;strong&gt;word&lt;/strong&gt; processor so far.&lt;/p&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="28" LastEditDate="2021-01-27T13:45:34.353" LastActivityDate="2021-01-27T13:45:34.353" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17484" PostTypeId="2" ParentId="5015" CreationDate="2018-09-25T19:38:02.273" Score="1" Body="&lt;h3&gt;Vim is also a programming language of one-letter commands&lt;/h3&gt;&#xA;&lt;p&gt;In conjunction with the &lt;code&gt;vimrc&lt;/code&gt; configuration file, this allows you to make this editor do what is truly important to you.&lt;/p&gt;&#xA;&lt;h3&gt;Vim is also about revaluing plain text files&lt;/h3&gt;&#xA;&lt;p&gt;In the context of document creation, the value of &lt;code&gt;vim&lt;/code&gt; is not only in its fabulous word editing skills. Vim is also a path to reinstating the value of the ubiquitous plain text file and its &lt;strong&gt;guarantee of timeless backwards compatibility.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Vim is also about focusing exclusively on content; not format&lt;/h3&gt;&#xA;&lt;p&gt;If one is not into web page editing, &lt;strong&gt;the separation of content from format&lt;/strong&gt; might be a paradigm shattering concept to any regular office worker. For this reason, I like to show off &lt;code&gt;gvim&lt;/code&gt; as a &lt;a href=&quot;https://daringfireball.net/projects/markdown/syntax#overview&quot; rel=&quot;nofollow noreferrer&quot;&gt;Markdown&lt;/a&gt; editor in combination with &lt;a href=&quot;https://pandoc.org/MANUAL.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pandoc&lt;/a&gt; and perhaps a &lt;a href=&quot;https://www.gnu.org/software/make/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;makefile&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This happens also to be a good demonstration of the Unix or GNU/Linux philosophy of combining and piping &lt;strong&gt;programs that are extremely good at just one thing.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;As a bonus, you will see that the basic &lt;code&gt;vim&lt;/code&gt; key combinations are used throughout many other GNU/Linux programs.&lt;/p&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="28" LastEditDate="2021-01-27T13:45:26.797" LastActivityDate="2021-01-27T13:45:26.797" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17485" PostTypeId="2" ParentId="6196" CreationDate="2018-09-25T20:59:48.647" Score="2" Body="&lt;h1&gt;Word swap mappings for Latin languages&lt;/h1&gt;&#xA;&lt;p&gt;The word swap mappings from the &lt;a href=&quot;http://vim.wikia.com/wiki/Swapping_characters,_words_and_lines&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim wiki&lt;/a&gt; will not operate correctly on &lt;strong&gt;words with accented characters.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;These mappings are adapted to work with (European) &lt;a href=&quot;https://en.wikipedia.org/wiki/ISO/IEC_8859-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;ISO/IEC_8859-1 Latin-1 Supplement characters&lt;/a&gt;. This is done by substituting all instances of &lt;code&gt;\w&lt;/code&gt; with &lt;code&gt;[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-]&lt;/code&gt; and all instances of &lt;code&gt;\_W&lt;/code&gt; with &lt;code&gt;\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h1&gt;Clearing of search highlighting&lt;/h1&gt;&#xA;&lt;p&gt;Furthermore, &lt;a href=&quot;https://stackoverflow.com/a/33580359/2192488&quot;&gt;the search highlighting is cleared&lt;/a&gt; where needed.&#xA;This is achieved by adding &lt;code&gt;:nohlsearch&amp;lt;return&amp;gt;&lt;/code&gt; at the end of each mapping when needed.&lt;/p&gt;&#xA;&lt;p&gt;Here is the end result:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Use gc to swap the current CHARACTER with the next, WITHOUT changing the cursor position.&#xA;nnoremap &amp;lt;silent&amp;gt; gc xph&#xA;&#xA;&amp;quot; Use gw to swap the current WORD with the next, WITHOUT changing the cursor position.&#xA;nnoremap &amp;lt;silent&amp;gt; gw &amp;quot;_yiw:s/\(\%#[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\(\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\([0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)/\3\2\1/&amp;lt;CR&amp;gt;&amp;lt;c-o&amp;gt;&amp;lt;c-l&amp;gt;:nohlsearch&amp;lt;return&amp;gt;&#xA;&#xA;&amp;quot; Disable Alt+[menukey] menu keys (i.e. Alt+h for help)&#xA;set winaltkeys=no&#xA;&#xA;&amp;quot; Use Alt + ← or Alt + h to swap the current WORD with the previous, keeping the cursor on the current word. This feels like &amp;quot;PUSHING&amp;quot; the word to the left.&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;A-Left&amp;gt; &amp;quot;_yiw?[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-]\+\%#&amp;lt;CR&amp;gt;:s/\(\%#[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\(\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\([0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)/\3\2\1/&amp;lt;CR&amp;gt;&amp;lt;c-o&amp;gt;&amp;lt;c-l&amp;gt;:nohlsearch&amp;lt;return&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;A-h&amp;gt;    &amp;quot;_yiw?[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-]\+\%#&amp;lt;CR&amp;gt;:s/\(\%#[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\(\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\([0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)/\3\2\1/&amp;lt;CR&amp;gt;&amp;lt;c-o&amp;gt;&amp;lt;c-l&amp;gt;:nohlsearch&amp;lt;return&amp;gt;&#xA;&amp;quot; &amp;lt;A-h&amp;gt; corresponds to è&#xA;&#xA;&amp;quot; Use Alt + → or Alt + l to swap the current WORD with the next, keeping the cursor on the current word. This feels like &amp;quot;PUSHING&amp;quot; the word to the right.&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;A-Right&amp;gt; &amp;quot;_yiw:s/\(\%#[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\(\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\([0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)/\3\2\1/&amp;lt;CR&amp;gt;&amp;lt;c-o&amp;gt;/[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+&amp;lt;CR&amp;gt;&amp;lt;c-l&amp;gt;:nohlsearch&amp;lt;return&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;A-l&amp;gt;     &amp;quot;_yiw:s/\(\%#[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\(\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\([0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)/\3\2\1/&amp;lt;CR&amp;gt;&amp;lt;c-o&amp;gt;/[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+&amp;lt;CR&amp;gt;&amp;lt;c-l&amp;gt;:nohlsearch&amp;lt;return&amp;gt;&#xA;&amp;quot; &amp;lt;A-l&amp;gt; corresponds to ì&#xA;&#xA;&amp;quot; Use g{ to swap the current PARAGRAPH with the next.&#xA;nnoremap g{ {dap}p{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-11-13T13:17:16.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17486" PostTypeId="1" CreationDate="2018-09-25T22:01:00.717" Score="0" ViewCount="326" Body="&lt;p&gt;I would like to create a custom mapping for the &lt;code&gt;&amp;lt;A-h&amp;gt;&lt;/code&gt;, i.e. &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;h&lt;/kbd&gt; key combination.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;A-h&amp;gt; …&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However unlike &lt;code&gt;&amp;lt;A-l&amp;gt;&lt;/code&gt;, this particular key combination &lt;strong&gt;opens the &lt;code&gt;gvim&lt;/code&gt; Help menu.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I overwrite this standard &lt;code&gt;gvim&lt;/code&gt;/window manager behaviour and still use a &lt;code&gt;&amp;lt;A-h&amp;gt;&lt;/code&gt; mapping?&lt;/p&gt;&#xA;" OwnerUserId="3168" LastActivityDate="2018-10-25T23:00:14.167" Title="How to map &lt;A-h&gt; without opening gvim help?" Tags="|key-bindings|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17487" PostTypeId="2" ParentId="17486" CreationDate="2018-09-25T22:07:12.770" Score="1" Body="&lt;pre&gt;&lt;code&gt;&quot; Disable Alt+[menukey] menu keys (i.e. Alt+h for help)&#xA;set winaltkeys=no&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3168" LastActivityDate="2018-09-25T22:07:12.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17488" PostTypeId="1" CreationDate="2018-09-25T23:31:45.890" Score="1" ViewCount="573" Body="&lt;p&gt;I'm trying to write a vimscript function that will allow me to map a key to select a regex match on the line my cursor is on. This will help with selecting strings for use with ctags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I have the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0 def hello&#xA;1   My::Fancy::Klass.call(args)&#xA;2 end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming my cursor is on line &lt;code&gt;1&lt;/code&gt;, I would like to bind a key to select only the &lt;code&gt;My::Fancy:Klass&lt;/code&gt; text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was able to achieve this like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;] V /\%V\(\(\u\l\+\)\+:\{2}\(\u\l\+\)\+\)\+&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I would like to do the same with vimscript and am not having any luck.&lt;/p&gt;&#xA;" OwnerUserId="19130" LastActivityDate="2019-08-22T05:00:55.140" Title="How to visually select a pattern only on current line using vimscript?" Tags="|vimscript|regular-expression|ctags|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17489" PostTypeId="1" AcceptedAnswerId="17753" CreationDate="2018-09-26T00:47:56.300" Score="2" ViewCount="57" Body="&lt;p&gt;Assuming I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;My::Cool::Klass.call(args)&#xA;Cool::Klass.call(args)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there anyway I can visually select either the &lt;code&gt;My::Cool::Klass&lt;/code&gt; or the &lt;code&gt;Cool::Klass&lt;/code&gt; with a quick command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: These are examples, so the strings could be different with two or more nodes (i.e. constants surrounding the &lt;code&gt;::&lt;/code&gt; symbols)&lt;/p&gt;&#xA;" OwnerUserId="19130" LastActivityDate="2018-10-27T15:14:07.417" Title="How can I visual select a ruby module?" Tags="|visual-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17490" PostTypeId="2" ParentId="17488" CreationDate="2018-09-26T02:01:40.320" Score="1" Body="&lt;p&gt;As I mention in my comment it's not clear what you're trying to do. But I can give you an Ex command sequence (vimsript) that does the same thing as your mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec 'norm! V' | let @/ = '\v%V((\u\l+)+:{2}(\u\l+)+)+' | exec &quot;norm! \&amp;lt;C-C&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's how these three commands match up to your mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec 'norm! V'  ==&amp;gt;  V&#xA;let @/ = '\v%V((\u\l+)+:{2}(\u\l+)+)+' ==&amp;gt; /\%V\(\(\u\l\+\)\+:\{2}\(\u\l\+\)\+\)\+&amp;lt;cr&amp;gt;&#xA;exec &quot;norm! \&amp;lt;C-C&amp;gt;&quot;  ==&amp;gt; &amp;lt;esc&amp;gt;  (Ctrl-C and Escape do the same thing)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even though your mapping leaves Visual mode your comment implies you want to remain in it. If that's true remove the third part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec 'norm! V' | let @/ = '\v%V((\u\l+)+:{2}(\u\l+)+)+'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-09-26T02:01:40.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17491" PostTypeId="2" ParentId="17136" CreationDate="2018-09-26T02:42:08.263" Score="2" Body="&lt;p&gt;This happens because your &lt;code&gt;.vimrc&lt;/code&gt; file is not upgraded when you upgrade your vim version. It still contain old runtime path. The easiest way to fix it will be to update &lt;code&gt;runtimepath&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, In vim 8.0 the runtimetimepath should be like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if you just upgraded from Vim 7.4 to Vim 8.0 the line will look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In that case changing the &lt;code&gt;vim74&lt;/code&gt; to &lt;code&gt;vim80&lt;/code&gt; will solve the problem&lt;/p&gt;&#xA;" OwnerUserId="13868" LastEditorUserId="13868" LastEditDate="2018-09-27T01:38:59.307" LastActivityDate="2018-09-27T01:38:59.307" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17492" PostTypeId="1" CreationDate="2018-09-26T06:59:31.957" Score="1" ViewCount="131" Body="&lt;p&gt;When I call &lt;code&gt;jobstop&lt;/code&gt; on a running script waiting for input, the &lt;code&gt;on_exit&lt;/code&gt; callback is invoked. But the exit code is always 0.&#xA;Is this the correct behavior? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;code&gt;:h jobstop&lt;/code&gt; it should be killed by &lt;code&gt;SIGTERM&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;jobstop({id})                     &lt;em&gt;jobstop()&lt;/em&gt;&#xA;        Stop |job-id| {id} by sending SIGTERM to the job process. If&#xA;        the process does not terminate after a timeout then SIGKILL&#xA;        will be sent. When the job terminates its |on_exit| handler&#xA;        (if any) will be invoked.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Shouldn't it have some nonzero exit code?&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-09-26T06:59:31.957" Title="neovim: exit code for jobs terminated by jobstop" Tags="|neovim|job-control|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17493" PostTypeId="1" AcceptedAnswerId="17495" CreationDate="2018-09-26T08:14:18.560" Score="13" ViewCount="12525" Body="&lt;p&gt;I am searching some pattern, navigate between search results, and at the same time I want some other pattern to be highlighted. For example, I jump between invocations of some function in my project, usually there is a variable named &quot;session&quot; around and I want this word to be highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I do is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:match StatusLineTerm /session/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;StatusLineTerm&lt;/code&gt; is just a name of existing highlight group having the color I like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is: how to create some key combination that would call this &lt;code&gt;match&lt;/code&gt; command using the word under cursor as a match pattern? Something like &lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :match StatusLineTerm /.expand(&amp;lt;cword&amp;gt;)/&lt;/code&gt;, but actually working?&lt;/p&gt;&#xA;" OwnerUserId="6194" LastActivityDate="2021-01-20T18:31:24.387" Title="How to highlight/match (but not search!) the word under cursor" Tags="|highlight|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17494" PostTypeId="2" ParentId="17493" CreationDate="2018-09-26T08:39:10.293" Score="6" Body="&lt;p&gt;I use a plugin for that: &lt;a href=&quot;https://github.com/lfv89/vim-interestingwords&quot; rel=&quot;noreferrer&quot;&gt;interesting words&lt;/a&gt;. It's not big, since it's only feature is to highligh words with defined or random colors, advantage is that you can have more than one color/highligh under single key. You can easly clear all the highlights done with that plugin if needed as well.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2018-09-26T08:39:10.293" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17495" PostTypeId="2" ParentId="17493" CreationDate="2018-09-26T09:07:11.477" Score="10" Body="&lt;p&gt;For a quick solution, try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;F5&amp;gt; :match StatusLineTerm /&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;/&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;Ctrl-W&lt;/kbd&gt; to insert the word under the cursor into the command line. See &lt;code&gt;:help c_CTRL-R_CTRL-W&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-09-26T09:07:11.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17496" PostTypeId="1" CreationDate="2018-09-26T11:14:01.567" Score="2" ViewCount="370" Body="&lt;p&gt;Does vim/neovim have the ability to manually disable screen updating? I run a function that jumps between a few tabs, update the content, and then go back to the original tab. The screen then flash several times. Is there a way to freeze screen until I execute redraw later? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see there is a command noautocmd to disable autocommands temporarily, but did find a similar mechanism for noredraw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Isn't this function easy to implement and also very useful for many cases?&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-09-26T11:14:01.567" Title="stop updating screen until function finishes or manually call redraw" Tags="|vim-windows|" AnswerCount="0" CommentCount="3" ClosedDate="2023-08-10T12:47:34.647" ContentLicense="CC BY-SA 4.0" />
  <row Id="17497" PostTypeId="2" ParentId="17493" CreationDate="2018-09-26T11:27:35.357" Score="5" Body="&lt;p&gt;I use the &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1238&quot; rel=&quot;noreferrer&quot;&gt;mark.vim&lt;/a&gt;-plugin for this. It can handle many interesting words at the same time and allows to jump between highlighted words.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-09-26T11:27:35.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17498" PostTypeId="1" AcceptedAnswerId="17499" CreationDate="2018-09-26T12:35:21.573" Score="0" ViewCount="124" Body="&lt;p&gt;I've been using vim for a little while and I'm doing some LaTeX with it, using &lt;a href=&quot;https://github.com/tectonic-typesetting/tectonic&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tectonic&lt;/a&gt; as the engine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I was doing to generate the pdf (without leaving the editor)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call system(&quot;tectonic main.tex&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this works but it's extremely repetitive. After reading a little about it, I've managed to create a simple mapping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;C-t&amp;gt; :call system(&quot;tectonic main.tex&quot;) &amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is less repetitive, but still has a hard-coded filename. Is there a way to specify that the map should be applied to the current file? Also can one concatenate operations so it saves (&lt;code&gt;:w&lt;/code&gt;) first then applies &lt;code&gt;tectonic&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="15524" LastEditorUserId="1841" LastEditDate="2018-09-26T12:43:42.260" LastActivityDate="2018-09-26T12:43:42.260" Title="How to map a call to a system function using the current filename?" Tags="|key-bindings|external-command|filetype-tex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17499" PostTypeId="2" ParentId="17498" CreationDate="2018-09-26T12:42:01.103" Score="3" Body="&lt;p&gt;You are looking for &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expand%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h expand()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expand({expr} [, {nosuf} [, {list}]])               *expand()*&#xA;        Expand wildcards and the following special keywords in {expr}.&#xA;        'wildignorecase' applies.&#xA;&#xA;        When {expr} starts with '%', '#' or '&amp;lt;', the expansion is done&#xA;        like for the |cmdline-special| variables with their associated&#xA;        modifiers.  Here is a short overview:&#xA;&#xA;            %       current file name&#xA;            #       alternate file name&#xA;            #n      alternate file name n&#xA;            &amp;lt;cfile&amp;gt;     file name under the cursor&#xA;            &amp;lt;cword&amp;gt;     word under the cursor&#xA;            &amp;lt;cWORD&amp;gt;     WORD under the cursor&#xA;&#xA;        Modifiers:&#xA;            :p      expand to full path&#xA;            :h      head (last path component removed)&#xA;            :t      tail (last path component only)&#xA;            :r      root (one extension removed)&#xA;            :e      extension only&#xA;&#xA;        Example:&#xA;            :let &amp;amp;tags = expand(&quot;%:p:h&quot;) . &quot;/tags&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-t&amp;gt; :call system(&quot;tectonic &quot; . expand('%'))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To chain it with the &lt;code&gt;:w&lt;/code&gt; command you can use an escaped pipe like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-t&amp;gt; :w \| call system(&quot;tectonic &quot; . expand('%'))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also remember to use &lt;code&gt;nore&lt;/code&gt; in your mapping and to give a mode (here &lt;code&gt;n&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-09-26T12:42:01.103" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17500" PostTypeId="2" ParentId="4919" CreationDate="2018-09-26T12:47:11.460" Score="8" Body="&lt;h1&gt;Exit &amp;amp; close&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;tnoremap &amp;lt;Esc&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;:q!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In Vim 8, this also works:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;tnoremap &amp;lt;ESC&amp;gt; &amp;lt;C-w&amp;gt;:q!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-09-26T14:59:20.227" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17501" PostTypeId="2" ParentId="9100" CreationDate="2018-09-26T14:08:53.573" Score="-1" Body="&lt;h1&gt;Without breaking &lt;code&gt;:help&lt;/code&gt;, nor &lt;code&gt;NERDTree&lt;/code&gt;&lt;/h1&gt;&#xA;&lt;p&gt;The problem with &lt;code&gt;BufEnter * if (!&amp;amp;modifiable || &amp;amp;ro)&lt;/code&gt; or &lt;code&gt;BufRead * if (!&amp;amp;modifiable || &amp;amp;ro)&lt;/code&gt; is that these do not distinguish file buffers from buffers created by &lt;code&gt;:help&lt;/code&gt; or &lt;code&gt;NERDTree&lt;/code&gt;; potentially breaking these latter.&lt;/p&gt;&#xA;&lt;p&gt;Hence, below solution rather employs &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#VimEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;VimEnter&lt;/code&gt;&lt;/a&gt; for creating for example a Vim-based Markdown &lt;a href=&quot;https://unix.stackexchange.com/a/314184/39845&quot;&gt;viewer&lt;/a&gt; or &lt;a href=&quot;https://stackoverflow.com/a/39836959/2192488&quot;&gt;pager&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup ReadOnly&#xA;    au!&#xA;    au VimEnter * if (!&amp;amp;modifiable || &amp;amp;ro) | setl wrap | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-10-03T10:50:31.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17502" PostTypeId="2" ParentId="11526" CreationDate="2018-09-26T14:22:28.340" Score="11" Body="&lt;h1&gt;Solution 1 :&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Install &lt;code&gt;vim-gtk&lt;/code&gt; package  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt install vim-gtk   &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Set Vim as a default editor  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim.gtk 1   &#xA;sudo update-alternatives --set editor /usr/bin/vim.gtk   &#xA;sudo update-alternatives --install /usr/bin/vi vi /usr/bin/vim.gtk 1  &#xA;sudo update-alternatives --set vi /usr/bin/vim.gtk   &#xA;sudo update-alternatives --install /usr/bin/vi vim /usr/bin/vim.gtk 1  &#xA;sudo update-alternatives --set vim /usr/bin/vim.gtk    &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Solution 2 :&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Otherwise you need to compile Vim from source code(assuming you're using Debian based system)  &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Prepare your system&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Install   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt install libncurses5-dev \&#xA;libgtk2.0-dev libatk1.0-dev \&#xA;libcairo2-dev python-dev \&#xA;python3-dev git&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Remove Vim if you already have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt remove vim vim-runtime gvim  &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;configure and make&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /usr &amp;amp;&amp;amp; sudo git clone https://github.com/vim/vim.git &amp;amp;&amp;amp; cd vim  &#xA;&#xA;sudo ./configure --with-features=huge \&#xA;--enable-multibyte \&#xA;--enable-pythoninterp=yes \&#xA;--with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/ \  # pay attention here check directory correct&#xA;--enable-python3interp=yes \&#xA;--with-python3-config-dir=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/ \  # pay attention here check directory correct&#xA;--enable-gui=gtk2 \&#xA;--enable-cscope \ &#xA;--prefix=/usr/local/&#xA;&#xA;sudo make VIMRUNTIMEDIR=/usr/local/share/vim/vim81 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Preparing deb package using &lt;a href=&quot;https://wiki.debian.org/CheckInstall&quot; rel=&quot;noreferrer&quot;&gt;checkinstall&lt;/a&gt;&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;And install that package   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /usr/vim &amp;amp;&amp;amp; sudo checkinstall&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or, if want to just create a package use &lt;code&gt;--install=no&lt;/code&gt; option with checkinstall&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Set Vim as a default editor&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1&#xA;sudo update-alternatives --set editor /usr/local/bin/vim&#xA;sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/vim 1&#xA;sudo update-alternatives --set vi /usr/local/bin/vim   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Verify that you're running the new Vim binary by looking&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version | grep python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Reference :&lt;/strong&gt;&lt;br&gt;&#xA;  - &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&quot; rel=&quot;noreferrer&quot;&gt;Building Vim from Source&lt;/a&gt;&lt;br&gt;&#xA;  - &lt;a href=&quot;https://manpages.debian.org/stretch/checkinstall/checkinstall.8.en.html&quot; rel=&quot;noreferrer&quot;&gt;checkinstall&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18867" LastEditorUserId="18867" LastEditDate="2018-09-26T22:06:54.750" LastActivityDate="2018-09-26T22:06:54.750" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17503" PostTypeId="1" AcceptedAnswerId="17504" CreationDate="2018-09-26T14:54:59.830" Score="0" ViewCount="314" Body="&lt;p&gt;I have the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc07&#xA;bca08&#xA;xyz17&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I would like to transform it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    [0]=&quot;abc07&quot; \&#xA;    [1]=&quot;bca08&quot; \&#xA;    [2]=&quot;xyz17&quot; \&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Based on &lt;a href=&quot;https://vi.stackexchange.com/questions/3109/insert-an-incrementing-number-to-each-line-in-either-a-selection-or-a-match&quot; title=&quot;this question&quot;&gt;this question&lt;/a&gt;, I can do the first part and the end part separately, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FIRST PART&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i=0 | g/^/execute &quot;normal! I&quot; . printf(&quot;^I[%d]=\&quot;&quot;, i) | let i+=1&#xA;&#xA;OR&#xA;&#xA;:let i=0 | g/^/s/^/\=printf(&quot;^I[%d]=\&quot;&quot;, i)/ | let i+=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;SECOND PART&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/$/\&quot;\ \\/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I am unable to combine these two in the same command. (Yes, I know, I overcomplicate things...)&#xA;Can you help me out to combine the two parts in one command?&#xA;An entirely different solution is also OK for me.&lt;/p&gt;&#xA;" OwnerUserId="19142" LastEditorUserId="19142" LastEditDate="2018-09-26T15:14:11.513" LastActivityDate="2018-09-27T04:37:59.153" Title="Transform lines: prepend with incrementing number and string and append with string for each line in one step" Tags="|regular-expression|substitute|ex-mode|global-command|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17504" PostTypeId="2" ParentId="17503" CreationDate="2018-09-26T15:13:48.553" Score="3" Body="&lt;p&gt;If you want to do this with a single command, I would recommend the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.*/\='    ['.(line('.')-1).']=&quot;'.submatch(0).'&quot; \'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses the &lt;code&gt;\=&lt;/code&gt; to evaluate the following strings joined together (remember, &lt;code&gt;'.'&lt;/code&gt; means concatenation in vimscript):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'    ['&#xA;(line('.')-1)&#xA;']=&quot;'&#xA;submatch(0)&#xA;'&quot; \'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;line('.')&lt;/code&gt; returns the current line number, and &lt;code&gt;submatch(0)&lt;/code&gt; is like &lt;code&gt;\0&lt;/code&gt; in regex (it captures the entire text).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I were the one editing this, I'd probably do it in normal mode (assuming vim 7.4+). For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;GI    [-1]=&quot;&amp;lt;esc&amp;gt;gvwwg&amp;lt;C-a&amp;gt;gv$A&quot; \&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Rather than explaining each part of this, it would be easier to just type these out and see the effects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, neither of these solutions will work if you are trying to do this to only certain lines in the buffer, rather than the whole thing. In that case, you could modify each one. For example, the first one could be modified by changing &lt;code&gt;:%&lt;/code&gt; to &lt;code&gt;:a,b&lt;/code&gt;, where &lt;strong&gt;a&lt;/strong&gt; and &lt;strong&gt;b&lt;/strong&gt; are you start/end lines. And then change &lt;code&gt;line('.')-1&lt;/code&gt; to &lt;code&gt;line('.')-a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second solution would just require changing your visual block selection, so not using &lt;code&gt;gg&lt;/code&gt; or &lt;code&gt;G&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As a side note, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^/s/^/\=printf(&quot;^I[%d]=\&quot;&quot;, i)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is unnecessary because &lt;code&gt;:g/^/s/^&lt;/code&gt; is exactly the same as &lt;code&gt;:%s/^&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2018-09-27T04:37:59.153" LastActivityDate="2018-09-27T04:37:59.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17505" PostTypeId="1" CreationDate="2018-09-26T15:23:01.500" Score="5" ViewCount="542" Body="&lt;p&gt;Vim 8 &lt;code&gt;:term&lt;/code&gt; colours in &lt;code&gt;gvim&lt;/code&gt; happen to be different from those seen in plain &lt;code&gt;vim :term&lt;/code&gt; or &lt;code&gt;bash&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How come? How does one obtain the same &lt;code&gt;bash&lt;/code&gt; colours in &lt;code&gt;gvim&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I have been reading a bit more about &lt;a href=&quot;http://vim.wikia.com/wiki/Using_GUI_color_settings_in_a_terminal&quot; rel=&quot;nofollow noreferrer&quot;&gt;Using GUI color settings in a terminal&lt;/a&gt;, but applying these plugins do not seem to change anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My main issue with &lt;code&gt;gvim :terminal&lt;/code&gt; is that it is employing a dark blue on a black background, both for the directory in the command prompt and the headers of &lt;code&gt;dfc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5yuRs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5yuRs.png&quot; alt=&quot;blue on black in gvim terminal&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If only I could get a handle on that dark blue in &lt;code&gt;gvim :terminal&lt;/code&gt;, that would solve my issue.&lt;/p&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="3168" LastEditDate="2020-01-15T18:57:39.830" LastActivityDate="2020-01-15T18:57:39.830" Title="Why are Vim 8 :term colours with gvim different from those in plain vim :term or bash?" Tags="|gvim|terminal|bash|color|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17506" PostTypeId="1" AcceptedAnswerId="17508" CreationDate="2018-09-26T20:11:33.017" Score="0" ViewCount="100" Body="&lt;p&gt;I have a file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0,3,&#xA;7,2,0,&#xA;1,2,3,&#xA;1,2,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which should be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0,3,0,&#xA;7,2,0,&#xA;1,2,3,&#xA;1,2,0,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So how can I append each line with two commas with &lt;code&gt;0,&lt;/code&gt;? I am interested in the most elegant solution and particularly interested if some script exists to help with such tasks, often required in manipulating CSV files.&lt;/p&gt;&#xA;" OwnerUserId="10986" LastEditorUserId="2920" LastEditDate="2018-09-26T20:40:39.883" LastActivityDate="2018-09-27T11:29:14.757" Title="Append `0,` to all lines having 2 commas and not more than 2 commas?" Tags="|regular-expression|search|replace|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17507" PostTypeId="2" ParentId="17506" CreationDate="2018-09-26T20:20:34.947" Score="0" Body="&lt;p&gt;&lt;em&gt;A solution&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g!/[0-9],[0-9],[0-9],/ s/$/0,/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where it matches all lines with two commas and three numbers. Then the bang &lt;code&gt;!&lt;/code&gt; reverses it to get what wanted.&lt;/p&gt;&#xA;" OwnerUserId="10986" LastEditorUserId="10986" LastEditDate="2018-09-27T11:29:14.757" LastActivityDate="2018-09-27T11:29:14.757" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17508" PostTypeId="2" ParentId="17506" CreationDate="2018-09-26T20:49:10.873" Score="1" Body="&lt;p&gt;The most elegant way I could think of would be with a substitute command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either of these would do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v^(\d,){2}$/\00,&#xA;:%s/^\d,\d,$/\00,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will replace any line containing two digits and commas with that whole line followed by &quot;0,&quot;. If you would like to modify it to work with numbers more than 1-digit long, you could change it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v^(\d+,){2}$/\00,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\d\+,\d\+,$/\00,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-09-26T20:49:10.873" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17509" PostTypeId="1" CreationDate="2018-09-26T21:41:05.760" Score="3" ViewCount="1659" Body="&lt;p&gt;I'd like to disable the popup menu scroll mappings &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt;, so that I can use &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; instead. However, when I enter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;C-p&amp;gt; &amp;lt;Nop&amp;gt;&#xA;imap &amp;lt;C-n&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the mappings are still active! How do I disable or override them permanently? Is it not possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be clear, when I call &lt;code&gt;:verb imap &amp;lt;C-p&amp;gt;&lt;/code&gt; I see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i  &amp;lt;C-P&amp;gt;         &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;yet the shortcut still works.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Here is the output of &lt;code&gt;:version&lt;/code&gt;, if that helps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Sep 20 2018 03:49:43)&#xA;macOS version&#xA;Included patches: 1-400&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               +conceal           +folding           +menu              +packages          -sun_workshop      +visual&#xA;+arabic            +cryptv            -footer            +mksession         +path_extra        +syntax            +visualextra&#xA;+autocmd           +cscope            +fork()            +modify_fname      +perl              +tag_binary        +viminfo&#xA;+autochdir         +cursorbind        -gettext           +mouse             +persistent_undo   +tag_old_static    +vreplace&#xA;-autoservername    +cursorshape       -hangul_input      -mouseshape        +postscript        -tag_any_white     +wildignore&#xA;-balloon_eval      +dialog_con        +iconv             +mouse_dec         +printer           -tcl               +wildmenu&#xA;+balloon_eval_term +diff              +insert_expand     -mouse_gpm         +profile           +termguicolors     +windows&#xA;-browse            +digraphs          +job               -mouse_jsbterm     -python            +terminal          +writebackup&#xA;++builtin_terms    -dnd               +jumplist          +mouse_netterm     +python3           +terminfo          -X11&#xA;+byte_offset       -ebcdic            +keymap            +mouse_sgr         +quickfix          +termresponse      -xfontset&#xA;+channel           +emacs_tags        +lambda            -mouse_sysmouse    +reltime           +textobjects       -xim&#xA;+cindent           +eval              +langmap           +mouse_urxvt       +rightleft         +timers            -xpm&#xA;-clientserver      +ex_extra          +libcall           +mouse_xterm       +ruby              +title             -xsmp&#xA;+clipboard         +extra_search      +linebreak         +multi_byte        +scrollbind        -toolbar           -xterm_clipboard&#xA;+cmdline_compl     +farsi             +lispindent        +multi_lang        +signs             +user_commands     -xterm_save&#xA;+cmdline_hist      +file_in_path      +listcmds          -mzscheme          +smartindent       +vartabs&#xA;+cmdline_info      +find_in_path      +localmap          +netbeans_intg     +startuptime       +vertsplit&#xA;+comments          +float             +lua               +num64             +statusline        +virtualedit&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -&#xA;L/usr/local/lib -o vim        -lncurses -liconv -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.12 -fstack-protector-&#xA;strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.28.0/lib/perl5/5.28.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/&#xA;python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation  -lruby.2.5.1 -lobjc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2018-10-03T01:38:09.027" LastActivityDate="2018-10-03T01:38:09.027" Title="How to disable insert-mode popup-menu mappings?" Tags="|vimrc|key-bindings|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17510" PostTypeId="1" AcceptedAnswerId="17512" CreationDate="2018-09-26T23:06:47.263" Score="3" ViewCount="1391" Body="&lt;p&gt;I have the following file (I used 4 spaces instead of tabs here):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc123   abc123    abc123    abc123    abc123&#xA;&#xA;abc123   abc123    kaskls    abc123    kaskls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The alphanumeric entries are separated by tabs, and I want to get rid of the first 3 columns.&#xA;Here's what I have tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\(.*\{-}\t\)\{3}//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this gives the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E871: Can't have a multi follow a multi !&#xA;E62: Nested \{&#xA;E476: Invalid Command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="19148" LastActivityDate="2018-09-27T00:46:55.237" Title="Adding a quantifier to group" Tags="|regular-expression|replace|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17511" PostTypeId="2" ParentId="17479" CreationDate="2018-09-26T23:23:27.830" Score="0" Body="&lt;p&gt;The FAQ was really helpful at troubleshooting. I had these lines in .vimrc, so I added the if.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('gui_running')&#xA;   set lines=75&#xA;   set scrolloff=3&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2018-09-26T23:23:27.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17512" PostTypeId="2" ParentId="17510" CreationDate="2018-09-27T00:46:55.237" Score="3" Body="&lt;p&gt;The following command works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\([^\t]*\t\)\{3}//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We match on not tabs then tabs.&#xA;This gets rid of the first 3 columns from a table.&lt;/p&gt;&#xA;" OwnerUserId="19148" LastActivityDate="2018-09-27T00:46:55.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17513" PostTypeId="2" ParentId="17506" CreationDate="2018-09-27T01:37:15.810" Score="1" Body="&lt;p&gt;&lt;em&gt;I don't know if this qualifies as elegant or overkill but anyways... :)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an idealistic software dude whenever I see a problem like this I tend to think in terms of a general solution. Here's a script I just wrote that will determine the arbitrarily maximum number of columns in a CSV file and then pad out all the lines with fewer columns so they are the same size.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Recursively look for line with most columns and return that number&#xA;func! MaxCsvCols(maxcols)&#xA;    &quot; find next line with equal to or greater than maxcols columns&#xA;    let line = search('^\([^,]\+,\)\{' . a:maxcols . ',}$', 'W')&#xA;    if line != 0&#xA;        return MaxCsvCols(len(split(getline(&quot;.&quot;), &quot;,&quot;)))&#xA;    else&#xA;        return a:maxcols&#xA;    endif&#xA;endfunc&#xA;&#xA;func! PadCsv()&#xA;    call cursor(1, 1)&#xA;    let maxcols = MaxCsvCols(1)&#xA;    if maxcols &amp;lt; 2 | return | endif&#xA;&#xA;    call cursor(1, 1)&#xA;    let linenum = 1&#xA;    while linenum &amp;gt; 0&#xA;        let newcols = maxcols - len(split(getline(&quot;.&quot;), &quot;,&quot;))&#xA;        let newtext = getline(&quot;.&quot;) . repeat(&quot;0,&quot;, newcols)&#xA;        call setline(linenum, newtext)&#xA;        &quot; find next line that has less-than maxcols columns&#xA;        let linenum = search('^\([^,]\+,\)\{,' . eval(maxcols-1) . '}$', 'W')&#xA;    endwhile&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the cursor somewhere in this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0,3,&#xA;7,2,0,&#xA;1,2,3,&#xA;7,2,0,9,&#xA;6,&#xA;1,2,3,2,2,&#xA;1,2,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...do &lt;code&gt;:call PadCsv()&lt;/code&gt; and you get this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0,3,0,0,0,&#xA;7,2,0,0,0,&#xA;1,2,3,0,0,&#xA;7,2,0,9,0,&#xA;6,0,0,0,0,&#xA;1,2,3,2,2,&#xA;1,2,0,0,0,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course this will work with your example, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;If there's a much easier way to do this in Vim I'd love to see it...but I probably would have written this anyways. I like to code. ;)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-09-27T02:02:27.300" LastActivityDate="2018-09-27T02:02:27.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17514" PostTypeId="1" CreationDate="2018-09-27T05:33:22.067" Score="1" ViewCount="241" Body="&lt;p&gt;I can't seem to figure out how to implement auto tag completion for html.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a plug-in or something else you guys use that works? Is there just one thing I can download that will handle indentation, html syntax and other bare bones stuff as well?&lt;/p&gt;&#xA;" OwnerUserId="19150" LastEditorUserId="1841" LastEditDate="2018-09-27T09:51:19.330" LastActivityDate="2018-09-27T09:51:19.330" Title="How to get html tag auto completion?" Tags="|indentation|autocompletion|filetype-html|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17516" PostTypeId="1" CreationDate="2018-09-27T06:36:34.370" Score="0" ViewCount="268" Body="&lt;p&gt;I need some help with writing a python plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know how to create a plugin but I can't find a way to run a forward or any normal mode stuff. I know I can run commands like echo with &lt;code&gt;self.vim.command('echo &quot;Hello&quot;')&lt;/code&gt;. But how can I run a forward like &lt;code&gt;fc&lt;/code&gt; to find the nearest &lt;code&gt;c&lt;/code&gt; character in the line with python? Also, I would like to run a search with &lt;code&gt;/&lt;/code&gt;, how can I do that?.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only solution that comes to my mind is writing a vimscript function and call it in python with &lt;code&gt;exec function()&lt;/code&gt;. But I would have to write one function for each thing I need. I would call it a workaround. I need a solution. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="15393" LastActivityDate="2019-08-25T02:02:25.317" Title="Neovim - Run a forward command with python" Tags="|neovim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17517" PostTypeId="2" ParentId="17509" CreationDate="2018-09-27T09:40:44.677" Score="1" Body="&lt;p&gt;You are looking for these help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3amap-%3cexpr%3e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :map-&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#pumvisible%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h pumvisible()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And the resulting mappings should be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-n&amp;gt; pumvisible() ? &quot;&quot; : &quot;\&amp;lt;C-n&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-j&amp;gt; pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;C-j&amp;gt;&quot;&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-p&amp;gt; pumvisible() ? &quot;&quot; : &quot;\&amp;lt;C-p&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-k&amp;gt; pumvisible() ? &quot;\&amp;lt;C-p&amp;gt;&quot; : &quot;\&amp;lt;C-k&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;pumvisible()&lt;/code&gt; returns a boolean indication if the completion menu is on or not. The &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; tag of the mappings allows to execute vimscript expressions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So we remap &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; so that is acts as itself when the completion menu is off and to do nothing when we are in the completion menu. Reciprocally we remap &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; to act like &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; when the completion menu is out and as itself when it's not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you should not remap &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; inconditionnaly because it is &lt;a href=&quot;https://vi.stackexchange.com/q/5233/1841&quot;&gt;equivalent to &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mappings for &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; follow the same idea.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also, as often, you forgot the &lt;code&gt;nore&lt;/code&gt; part of the &lt;code&gt;imap&lt;/code&gt; command which is a &lt;a href=&quot;https://vi.stackexchange.com/a/10130/1841&quot;&gt;bad practice&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-09-27T10:12:23.777" LastActivityDate="2018-09-27T10:12:23.777" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17518" PostTypeId="2" ParentId="17489" CreationDate="2018-09-27T12:01:08.280" Score="0" Body="&lt;p&gt;I don't know ruby very well so I'm not sure what you are exactly trying to do, but if you want to search for strings which are always in the form of &lt;code&gt;aword&lt;/code&gt; followed one time or more by &lt;code&gt;::anotherword&lt;/code&gt; you can use the following search pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\w\+\(::\w\+\)\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should be pretty straightforward to read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\w\+              One or more (\+) word characters (\w)&#xA;    \(      \)\+  Followed by at least one capture group...&#xA;      ::          ...containing two litteral ':'...&#xA;        \w\+      ...followed by one or more (\+) word characters (\w)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-09-27T12:01:08.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17519" PostTypeId="1" CreationDate="2018-09-27T14:46:26.190" Score="1" ViewCount="202" Body="&lt;p&gt;I have the following options setup for C++ and Python development in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter *.cpp setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=80 noexpandtab cindent cinoptions=:0,l1,t0,g0,(0&#xA;autocmd BufEnter *.py  setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=79 expandtab   cindent cinoptions=:0,l1,t0,g0,(0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Python, when I am manually creating continuation lines (i.e. to keep code from spilling past a certain column number), auto-indenting and auto-alignment (i.e. visual selection, &lt;kbd&gt;g&lt;/kbd&gt;,&lt;kbd&gt;q&lt;/kbd&gt;), I encounter very different behavior for Python versus C++ code. For example:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example: Works in C++ and Python Code.&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;val = some_class.some_function(this_is_a_variable_1, this_is_a_variable_2, this_is_a_variable_3, this_is_a_variable_4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;val = some_class.some_function(this_is_a_variable_1, this_is_a_variable_2,&#xA;                               this_is_a_variable_3, this_is_a_variable_4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, there is different behavior for C++ and Python code with the following example(s):&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example: Python Behavior (Desired).&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If I insert a newline after the bracket &lt;code&gt;(&lt;/code&gt; character, the following continuation format occurs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;val = some_class.some_function(this_is_a_variable_1, this_is_a_variable_2, this_is_a_variable_3, this_is_a_variable_4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;val = some_class.some_function(&#xA;    this_is_a_variable_1, this_is_a_variable_2, this_is_a_variable_3,&#xA;    this_is_a_variable_4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Example: C++ Behavior (Not Desired).&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If I insert a newline after the bracket &lt;code&gt;(&lt;/code&gt; character, the following continuation format occurs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;val = some_class.some_function(this_is_a_variable_1, this_is_a_variable_2, this_is_a_variable_3, this_is_a_variable_4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;val = some_class.some_function(&#xA;                               this_is_a_variable_1, this_is_a_variable_2,&#xA;                               this_is_a_variable_3, this_is_a_variable_4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This behavior is desirable for function prototypes/declarations, but not for general code.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;How do I get C++ auto-indentation/auto-formatting to behave the same as Python does (given the above examples) in VIM (i.e. have the continuation line use a single-tab or double-tab, rather than aligning with the opening bracket)?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Thoughts/Work So Far&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Since the above indentation for C++ is only used for function declarations/prototypes, maybe I could write a macro to apply that specific indentation to a visual selection, and disable that formatting option in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="14282" LastActivityDate="2018-09-27T17:10:59.963" Title="C++: different auto-indentation for function protoypes versus continuation lines" Tags="|indentation|autocmd|filetype-python|filetype-c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17520" PostTypeId="2" ParentId="17519" CreationDate="2018-09-27T16:18:10.543" Score="1" Body="&lt;p&gt;I figured it out. &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/indent.html#cinoptions-values&quot; rel=&quot;nofollow noreferrer&quot;&gt;From the documentation&lt;/a&gt;: &lt;strong&gt;&lt;code&gt;(0,W8&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/699313/1022889&quot;&gt;I found the following somewhat related answer on another SE site&lt;/a&gt;, to explain why I use a double-indent (i.e. &lt;code&gt;(0,W8&lt;/code&gt; instead of &lt;code&gt;(0,W4&lt;/code&gt;) for continuation lines (i.e. Google and Oracle style guides encourage it).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WN    When in unclosed parentheses and N is non-zero and either&#xA;      using &quot;(0&quot; or &quot;u0&quot;, respectively and the unclosed parentheses is&#xA;      the last non-white character in its line and it is not the&#xA;      closing parentheses, indent the following line N characters&#xA;      relative to the outer context (i.e. start of the line or the&#xA;      next unclosed parentheses).  (default: 0).&#xA;&#xA;        cino=(0                    cino=(0,W4&#xA;          a_long_line(              a_long_line(&#xA;                      argument,         argument,&#xA;                      argument);        argument);&#xA;          a_short_line(argument,    a_short_line(argument,&#xA;                       argument);                argument);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14282" LastEditorUserId="14282" LastEditDate="2018-09-27T17:10:59.963" LastActivityDate="2018-09-27T17:10:59.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17521" PostTypeId="1" CreationDate="2018-09-27T18:44:09.963" Score="1" ViewCount="659" Body="&lt;p&gt;I have a very weird situation with my tags file not working as expected. My tag file is sorted case-insensitively (starts with &lt;code&gt;!_TAG_FILE_SORTED\t2\t/foldcase/&lt;/code&gt;), and ignorecase is set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I put my cursor over &lt;code&gt;Word_I_Am_Looking_For&lt;/code&gt; and hit &lt;code&gt;CTRL-]&lt;/code&gt; I get &lt;code&gt;E257: cstag: tag not found&lt;/code&gt;. However when I type &lt;code&gt;:ta /&amp;lt;C-W&amp;gt;&lt;/code&gt; to fill out &lt;code&gt;:ta /Word_I_Am_Looking_For&lt;/code&gt; it finds my tag no problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To diagnose the issue I opened the tag file itself and jumped to the line in question. When I turned on &lt;code&gt;set list&lt;/code&gt; I saw: &lt;code&gt;Word_I_Am_Looking_For^I/path/to/word/i/am/looking/for^I/\%123l\%456c/$&lt;/code&gt; which looks right to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is causing vim to miss the tag?&lt;/p&gt;&#xA;" OwnerUserId="10127" LastEditorUserId="10127" LastEditDate="2018-09-27T18:52:20.907" LastActivityDate="2018-09-27T18:52:20.907" Title="Tag not found unless searched for" Tags="|tags|ctags|letter-case|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17522" PostTypeId="1" CreationDate="2018-09-28T00:49:54.440" Score="1" ViewCount="102" Body="&lt;p&gt;I'm getting some odd behavior from langmap.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set langmap=hjki;ihjk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap k u&lt;/code&gt; works as expected,&lt;br&gt;&#xA;&lt;code&gt;inoremap jk u&lt;/code&gt; maps to &lt;code&gt;ji&lt;/code&gt;,&lt;br&gt;&#xA;&lt;code&gt;inoremap kik u&lt;/code&gt; maps to &lt;code&gt;khi&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I say 'maps' I mean that's what I have to press to get the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems, for making keymaps, the langmap applies to every character but the first.&lt;br&gt;&#xA;Setting &lt;code&gt;langremap&lt;/code&gt; or &lt;code&gt;nolangremap&lt;/code&gt; doesn't seem to have an effect.&lt;br&gt;&#xA;I tried this with a clean init.vim, so there shouldn't be any other options or plugins affecting it.&lt;br&gt;&#xA;I wanted to check here, to see if there's some langmap option I'm missing, before filing a bug report.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NVIM v0.3.1&#xA;Build type: Release&#xA;LuaJIT 2.0.5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19164" LastEditorUserId="19164" LastEditDate="2018-10-03T19:53:00.050" LastActivityDate="2018-10-03T19:53:00.050" Title="Odd langmap behavior with multi-key bindings" Tags="|key-bindings|neovim|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17523" PostTypeId="1" AcceptedAnswerId="22211" CreationDate="2018-09-28T12:34:34.980" Score="2" ViewCount="761" Body="&lt;p&gt;I want to format a multiline string according to a textwidth of 32.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;group:&#xA;  - normal: scalar&#xA;  - multiline: &quot;Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.&quot;&#xA;  - normal: &quot;text&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;group:&#xA;  - normal: scalar&#xA;  - multiline: &quot;Lorem ipsum&#xA;      dolor sit amet, consetetur&#xA;      sadipscing elitr, sed diam&#xA;      nonumy eirmod tempor&#xA;      invidunt ut labore et&#xA;      dolore magna aliquyam&#xA;      erat, sed diam voluptua.&quot;&#xA;  - normal: &quot;text&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My vim settings for this file are&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set sw=2 tw=32 et&#xA;set formatoptions=tjcroq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For re-flowing paragraphs I frequently use &lt;code&gt;gwap&lt;/code&gt; and formatoptions for on-the-fly formatting. In this case, autoformat is only turned on when in such a section with: &lt;code&gt;fo+=a&lt;/code&gt; but this only works for paragraphs with an empty line before and after the string and does not respect full indentation. My workaround is to add empty lines before and after and delete them afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This must be a frequent task for most coders here but I don't know how to do it. My guess was to use the marks from the start and end of the current syntax highlighting tag, which is &lt;code&gt;&amp;lt;yamlFlowString&amp;gt;&lt;/code&gt; here, for constraining the auto-formatting to it. Is there any solution to this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see&#xA;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#formatting&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimhelp.appspot.com/change.txt.html#formatting&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8162" LastEditorUserId="1577" LastEditDate="2018-10-15T08:11:40.993" LastActivityDate="2019-12-09T12:12:02.420" Title="How to autoformat a multi-line string" Tags="|formatting|multiple-lines|string-manipulation|filetype-yaml|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17524" PostTypeId="1" CreationDate="2018-09-28T13:17:54.400" Score="3" ViewCount="689" Body="&lt;p&gt;I have run into an escaping problem with the &lt;code&gt;path&lt;/code&gt; argument to &lt;code&gt;findfile({name}, {path})&lt;/code&gt; / &lt;code&gt;finddir({name}, {path})&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my &lt;a href=&quot;https://github.com/airblade/vim-rooter/blob/42a97c624f4f9465703558bf004b013bc36facdb/plugin/rooter.vim#L81-L90&quot; rel=&quot;nofollow noreferrer&quot;&gt;code&lt;/a&gt; &lt;code&gt;path&lt;/code&gt; is a directory, obtained via &lt;code&gt;fnamemodify(&amp;lt;file&amp;gt;, ':h')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Until recently I used &lt;code&gt;fnameescape()&lt;/code&gt; to escape this path, before appending a semi-colon and passing it into &lt;code&gt;findfile()&lt;/code&gt; / &lt;code&gt;finddir()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However it turned out to &lt;a href=&quot;https://github.com/airblade/vim-rooter/issues/80&quot; rel=&quot;nofollow noreferrer&quot;&gt;break&lt;/a&gt; &lt;code&gt;findfile()&lt;/code&gt; / &lt;code&gt;finddir()&lt;/code&gt; with filenames containing &lt;code&gt;#&lt;/code&gt;, because the &lt;code&gt;#&lt;/code&gt; was escaped but evidently &lt;code&gt;findfile()&lt;/code&gt; / &lt;code&gt;finddir()&lt;/code&gt; don't unescape the &lt;code&gt;#&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The docs for &lt;code&gt;findfile()&lt;/code&gt; / &lt;code&gt;finddir()&lt;/code&gt; don't talk about escaping.  However they do say if the path argument is omitted, they use the value of the &lt;code&gt;path&lt;/code&gt; option.  The docs for the &lt;code&gt;path&lt;/code&gt; option say spaces, commas, and backslashes have to be escaped with a backslash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I updated my code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- fnameescape(dir)&#xA;+ escape(dir, ' ,\')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this now breaks on Windows because it escapes backslashes (I think that's why).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the correct way to escape file paths for the &lt;code&gt;findfile()&lt;/code&gt; / &lt;code&gt;finddir()&lt;/code&gt; functions?&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2018-09-28T14:29:00.250" Title="How to escape paths for findfile() and finddir()?" Tags="|vimscript|filesystem|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17526" PostTypeId="1" AcceptedAnswerId="17527" CreationDate="2018-09-28T20:24:24.600" Score="1" ViewCount="135" Body="&lt;p&gt;I include &lt;code&gt;set number&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; file to have line numbers automatically displayed upon opening a file. I also use the following &lt;a href=&quot;https://til.hashrocket.com/posts/17c44eda91-persistent-folds-between-vim-sessions&quot; rel=&quot;nofollow noreferrer&quot;&gt;code block&lt;/a&gt; to automatically save and load the view when closing and opening buffers, mainly for the purpose of saving folds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup AutoSaveFolds&#xA;  autocmd!&#xA;  autocmd BufWinLeave * mkview&#xA;  autocmd BufWinEnter * silent loadview&#xA;augroup END &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, one view setting that I wish to avoid saving is line numbering. Currently, if I hide line numbering and then close a file, line numbering is unset when that file is reopened. This is true even if &lt;code&gt;set number&lt;/code&gt; is placed after the &lt;code&gt;augroup&lt;/code&gt; block in my &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I circumvent this limitation, such that line numbering will automatically be enabled any time a buffer is opened while still allowing fold settings to be persistent?&lt;/p&gt;&#xA;" OwnerUserId="19170" LastActivityDate="2018-09-28T21:44:27.397" Title="excluding line numbering from mkview/loadview" Tags="|folding|line-numbers|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17527" PostTypeId="2" ParentId="17526" CreationDate="2018-09-28T21:44:27.397" Score="2" Body="&lt;p&gt;From &lt;code&gt;:h :mkview&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The output of &quot;:mkview&quot; contains these items:&#xA;  ...&lt;/p&gt;&#xA;  &#xA;  &lt;ol start=&quot;3&quot;&gt;&#xA;  &lt;li&gt;Restore mappings, abbreviations and options local to the window if&#xA;  'viewoptions' contains &quot;options&quot; or &quot;localoptions&quot;.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The global option &lt;code&gt;'viewoptions'&lt;/code&gt; controls what will be saved/restored when you execute &lt;code&gt;:mkview&lt;/code&gt;, &lt;code&gt;:loadview&lt;/code&gt;.&#xA;Its default value contains the item &lt;code&gt;options&lt;/code&gt;.&#xA;So maybe yours contained &lt;code&gt;options&lt;/code&gt; as well, and/or &lt;code&gt;localoptions&lt;/code&gt;.&#xA;Here are how these items are described in &lt;code&gt;:h 'vop&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;options&lt;/code&gt; options and mappings local to a window or buffer (not&#xA;                global values for local options)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;localoptions&lt;/code&gt;  same as &quot;options&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This may be the reason why your &lt;code&gt;'number'&lt;/code&gt; option was saved/restored.&#xA;To prevent this, you can remove the items from &lt;code&gt;'vop'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set vop-=options vop-=localoptions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or reset &lt;code&gt;'vop'&lt;/code&gt; entirely:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set vop=folds,cursor,curdir&#xA;        │     │      │&#xA;        │     │      └ save the local working directory&#xA;        │     └ save the cursor position&#xA;        └ save the folds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2018-09-28T21:44:27.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17528" PostTypeId="1" AcceptedAnswerId="17531" CreationDate="2018-09-28T22:55:01.570" Score="0" ViewCount="89" Body="&lt;p&gt;What's the Vim equivalent of Emacs's &lt;a href=&quot;https://www.gnu.org/software/emacs/manual/html_node/emacs/Other-Window.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;other-window&lt;/a&gt; command?&lt;/p&gt;&#xA;" OwnerUserId="5224" LastActivityDate="2018-11-02T18:00:12.480" Title="What's the Vim equivalent of Emacs's other-window command?" Tags="|key-bindings|split|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17529" PostTypeId="2" ParentId="5225" CreationDate="2018-09-28T23:13:33.103" Score="2" Body="&lt;pre&gt;&lt;code&gt;:execute 'bufdo :e' | source $VIMRUNTIME/syntax/syntax.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;execute is a workaround, so that the command following &lt;code&gt;|&lt;/code&gt; is not included in the &lt;code&gt;bufdo&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;sourcing this file is mentioned in &lt;code&gt;:he :syntax-enable&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="14026" LastActivityDate="2018-09-28T23:13:33.103" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17530" PostTypeId="2" ParentId="17516" CreationDate="2018-09-29T00:26:04.350" Score="1" Body="&lt;p&gt;you can use the “normal! fc” in as an ex command to run a normal mode command. The ! sign diasables mapping, so will use the command’s original difinition in vim. &lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-09-29T00:26:04.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17531" PostTypeId="2" ParentId="17528" CreationDate="2018-09-29T03:42:43.663" Score="3" Body="&lt;p&gt;&lt;code&gt;&amp;lt;C-w&amp;gt;w&lt;/code&gt; cycles through windows in a similar manner. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2018-11-02T18:00:12.480" LastActivityDate="2018-11-02T18:00:12.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17532" PostTypeId="1" AcceptedAnswerId="17538" CreationDate="2018-09-29T08:31:39.613" Score="4" ViewCount="1035" Body="&lt;p&gt;I come about this regularly and still do it manually.  Consider this example - say it's inside a text.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; first 3,2,17,198,232,1,999 and some other text&#xA; second 1,2,3,71,98,4,5 and some more text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need these values sorted (usually for easier read, or to find duplicates).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; first 1,2,3,17,198,232,999 and some other text&#xA; second 1,2,3,4,5,71,98 and some more text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far I always do it the &quot;pedestrian&quot; way - in my head where possible, or yank out sort there and paste back.  I keep thinking there should be a more efficient way in vim.  (I also tried splitting those into lines, &lt;code&gt;sort -n&lt;/code&gt;, join, adjust commas,... - but this was even less efficient.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Preferable without needing me to install a plugin as I sometimes work on other machines.&lt;/p&gt;&#xA;" OwnerUserId="1120" LastEditorUserId="1120" LastEditDate="2018-09-29T08:51:01.227" LastActivityDate="2018-10-02T11:08:28.603" Title="Is there an efficient way to sort a selection of comma separated values in a single line?" Tags="|sort|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17533" PostTypeId="1" CreationDate="2018-09-29T08:52:36.093" Score="0" ViewCount="2050" Body="&lt;p&gt;I want to find the most elegant way to replace every second space on each line with Vim. Most elegant solution accepted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example input&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;123 1234 1345 123456 12344567 12345678&#xA;123 1234 1345 123456 12344567 12345678 123 1234 1345 123456 12344567 12345678&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Intended output&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1231234 1345123456 1234456712345678&#xA;1231234 1345123456 1234456712345678 1231234 1345123456 1234456712345678&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10986" LastActivityDate="2018-11-09T05:56:58.803" Title="Replace every second space on each line?" Tags="|regular-expression|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17534" PostTypeId="2" ParentId="17533" CreationDate="2018-09-29T09:14:15.457" Score="1" Body="&lt;p&gt;A solution candidate with a regular expression and with the magic directive is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.s@\v(\d+) (\d+)@\1\2 @g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where matching numbers in the groups. It can be improved with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.s@\v([^ ]+) ([^ ]+)@\1\2 @g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so matching everything else except spaces in the groups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Input&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 2 3 4 5 6 7 8 9 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Its Output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12  34  56  78  910&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10986" LastEditorUserId="205" LastEditDate="2018-10-01T03:01:19.217" LastActivityDate="2018-10-01T03:01:19.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17535" PostTypeId="1" CreationDate="2018-09-29T11:29:35.080" Score="0" ViewCount="407" Body="&lt;p&gt;I want to use &lt;code&gt;vimtex&lt;/code&gt; and enable highlighting for all filetypes, except &lt;code&gt;tex&lt;/code&gt; files. For &lt;code&gt;tex&lt;/code&gt; files I explicitly want to disable highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Important: The solution should allow to use &lt;code&gt;&amp;lt;leader&amp;gt;ll&lt;/code&gt; for compilation of the tex files, without enabling highlighting again!&lt;/p&gt;&#xA;" OwnerUserId="14053" LastActivityDate="2018-09-30T06:35:45.470" Title="Disable highlighting for tex files with texvim" Tags="|vimrc|syntax-highlighting|plugin-vimtex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17536" PostTypeId="2" ParentId="17535" CreationDate="2018-09-30T06:35:45.470" Score="1" Body="&lt;p&gt;I would install a personal syntax file, e.g. in &lt;code&gt;.vim/syntax/tex.vim&lt;/code&gt;, to override the default with the content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:current_syntax = 'tex'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In addition, you should add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vimtex_syntax_enabled = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to prevent vimtex from patching the syntax script.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-09-30T06:35:45.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17537" PostTypeId="2" ParentId="17532" CreationDate="2018-09-30T08:47:33.557" Score="3" Body="&lt;h2&gt;Plugin &lt;a href=&quot;https://github.com/christoomey/vim-sort-motion&quot; rel=&quot;nofollow noreferrer&quot;&gt;sort-motion.vim&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;IMO the most convenient method to achieve this is to use a plugin or a self-written vim function linked to a mapping. Both need a customized vim and are obviously not available in vanilla vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the plugin &lt;code&gt;sort-motion.vim&lt;/code&gt; provides a flexible, very convenient solution for your question.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Position the cursor anywhere on the comma-separated list&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gsiW&lt;/code&gt; &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is &lt;strong&gt;dot-repeatable&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Position on next list which you want to sort&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;IMHO minimal mental effort required which means less &quot;mental energy&quot; depletion. If your list exceeds one line, I would recommend to join them, sort and then re-flow the paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am pretty confident that there is no shorter vimgolf solution for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also tools from the command line do not provide this level of convenience (e.g. &lt;code&gt;tr , &quot;\n&quot; | sort | tr &quot;\n&quot; ,&lt;/code&gt; from  &lt;a href=&quot;https://unix.stackexchange.com/questions/140388/sort-comma-separated-fields-on-each-line-by-numeric-value&quot;&gt;Unix &amp;amp; Linux: Sort comma-separated fields on each line by numeric value&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related command line solutions can be found here&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/47665195/how-to-sort-comma-separated-values-in-bash&quot;&gt;Stackoverflow: How to sort comma separated values in bash?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://askubuntu.com/questions/447420/how-to-sort-by-row-from-terminal&quot;&gt;Askubuntu: How to sort by row from terminal&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.commandlinefu.com/commands/view/7737/sort-a-list-of-comma-separated-numbers-sort_csn&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.commandlinefu.com/commands/view/7737/sort-a-list-of-comma-separated-numbers-sort_csn&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://csvkit.rtfd.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;csvkit&lt;/code&gt;&lt;/a&gt; with &lt;code&gt;csvsort&lt;/code&gt; and &lt;code&gt;csvtool transpose&lt;/code&gt; offer no easy solution as well.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-10-02T11:08:28.603" LastActivityDate="2018-10-02T11:08:28.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17538" PostTypeId="2" ParentId="17532" CreationDate="2018-09-30T09:46:51.467" Score="4" Body="&lt;h2&gt;Vanilla Vim: Via Expression Register&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;And now a solution for vanilla vim:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Position cursor on list&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ciW&lt;/code&gt; (removes unsorted list and puts it into register &lt;code&gt;&quot;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;=join(sort([&amp;lt;C-r&amp;gt;&quot;]), ',')&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Done. I think it is actually not that bad. An even more useful variant would be&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;=join(sort(split(expand(@&quot;), ',')), ',')&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can re-use this expression the next time you want to sort a different list via the expression history (&lt;code&gt;:h history&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;Position cursor on the different list&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ciW&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Cycle through the history with the arrow keys to find the expression:&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;6&quot;&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;=&amp;lt;Up&amp;gt;&amp;lt;Up&amp;gt;...&amp;lt;CR&amp;gt;&lt;/code&gt; or&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;C-r&amp;gt;=join&amp;lt;Up&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There is an additional convenience feature at the expression prompt:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you do not enter an expression, Vim uses the previous expression (like with the &quot;/&quot; command)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ol start=&quot;6&quot;&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;=&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you use the expression register quite often and you want to avoid losing older expressions, you should make sure that the value of &lt;code&gt;'history'&lt;/code&gt; is large enough: &lt;code&gt;:set history?&lt;/code&gt;. If you have not set this value by yourself (vanilla vim), the current setting could be one of&lt;br&gt;&#xA;vi-&lt;code&gt;'compatible'&lt;/code&gt;: &lt;code&gt;0&lt;/code&gt;, vim default: &lt;code&gt;50&lt;/code&gt;, &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/defaults.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;defaults.vim&lt;/code&gt; since vim8&lt;/a&gt;: &lt;code&gt;200&lt;/code&gt;, &lt;a href=&quot;https://github.com/tpope/vim-sensible/blob/master/plugin/sensible.vim#L72-L74&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-sensible&lt;/code&gt;&lt;/a&gt;: &lt;code&gt;1000&lt;/code&gt; (e.g. &lt;a href=&quot;https://aur.archlinux.org/packages/vim-sensible/&quot; rel=&quot;nofollow noreferrer&quot;&gt;arch&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, define a short vimscript function to avoid typing the 'advanced' command at the expression register prompt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Mysort()&#xA;   return join(sort(split(@&quot;, ',')), ',')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-r&amp;gt;=Mysort()&amp;lt;CR&amp;gt;&lt;/code&gt; (tab-completion might help to ease the typing)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;IMHO this vanilla vim solution would be almost as good as the plugin if you could dot-repeat step 2 and 3. Afaik, this is not possible. You could record steps two and three to a macro (e.g. &lt;code&gt;qq&lt;/code&gt;) and then replay it (with &lt;code&gt;@q&lt;/code&gt; (1st replay), &lt;code&gt;@@&lt;/code&gt; (2nd and more replays)). &lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-10-02T08:25:13.503" LastActivityDate="2018-10-02T08:25:13.503" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="17540" PostTypeId="2" ParentId="17533" CreationDate="2018-10-01T03:21:00.363" Score="2" Body="&lt;p&gt;Assuming you want to remove all the odd-numbered spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v (\S*( |$))/\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;with magic (&lt;code&gt;\v&lt;/code&gt;) to reduce the escaping needed&lt;/li&gt;&#xA;&lt;li&gt;matches space followed by (non-whitespace (&lt;code&gt;\S*&lt;/code&gt;) followed by (another space or end-of-line))&lt;/li&gt;&#xA;&lt;li&gt;and replaces it with the matched part after the leading space&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For each space matched at the start of the regex, the next space is eaten by the regex match and can't be part of another match. So this only affects the odd-numbered spaces.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-10-01T03:21:00.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17541" PostTypeId="2" ParentId="17215" CreationDate="2018-10-01T12:17:56.497" Score="1" Body="&lt;p&gt;Well maybe it is not exactly what you want, but why not use such subst command after insert finished:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'[+1,']s/^/&amp;gt; /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'[+1&lt;/code&gt; is second inserted line number&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;']&lt;/code&gt; is last inserted line number&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s&lt;/code&gt; - subst command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; - start of line (position after &quot;enter&quot;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;  - replacement text&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can map this to key for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F4&amp;gt; :'[+1,']s/^/&amp;gt; /&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17271" LastEditorUserId="1841" LastEditDate="2018-10-01T13:25:58.377" LastActivityDate="2018-10-01T13:25:58.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17542" PostTypeId="2" ParentId="2003" CreationDate="2018-10-01T13:17:21.910" Score="1" Body="&lt;p&gt;My vimrc loading time was very slow, around 400ms, and i reduced it to 20ms only by removing this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent !mkdir ~/.config/nvim/backups &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure you don't have calls to external commands like that.&lt;/p&gt;&#xA;" OwnerUserId="19200" LastEditorUserId="343" LastEditDate="2018-10-03T10:23:17.290" LastActivityDate="2018-10-03T10:23:17.290" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17543" PostTypeId="2" ParentId="17509" CreationDate="2018-10-01T14:58:15.197" Score="1" Body="&lt;p&gt;I can't reproduce your behavior. I'm suspecting that you have other mappings for the autocomplete menu and that your &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; sequences are not being used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check that try the following command:&#xA;&lt;code&gt;&#xA;:verbose imap ^V^N&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;^V&lt;/code&gt; is Ctrl-V and &lt;code&gt;^N&lt;/code&gt; is Ctrl-N. This will insert the literal key sequence that Vim is receiving when pressing Ctrl-N on your setup. I'm guessing that this and &lt;code&gt;^V^P&lt;/code&gt; are being remapped to the autocomplete functions (&lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt;) as well.&lt;/p&gt;&#xA;" OwnerUserId="10482" LastActivityDate="2018-10-01T14:58:15.197" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17544" PostTypeId="1" AcceptedAnswerId="17546" CreationDate="2018-10-01T15:40:22.900" Score="1" ViewCount="2701" Body="&lt;p&gt;When I use the colorscheme &lt;a href=&quot;https://github.com/morhetz/gruvbox&quot; rel=&quot;nofollow noreferrer&quot;&gt;gruvbox&lt;/a&gt; (installed with &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt;), it overrides my configuration of the Cursorline highlight, eg&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cursorline&#xA;hi CursorLine cterm=NONE ctermbg=black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the same color as the statusbar, which makes it easy to confuse the cursorline with the statusline of a horizontally split buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to set the cursorline background color to pure black, or at least to the black defined by the gruvbox colorscheme, but I can't change the highlight using the &lt;code&gt;hi(ghlight) CursorLine&lt;/code&gt; command when using gruvbox. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't find how to configure this in the &lt;a href=&quot;https://github.com/morhetz/gruvbox/wiki/Configuration&quot; rel=&quot;nofollow noreferrer&quot;&gt;gruvbox wiki&lt;/a&gt;, does anybody have a solution to this?&lt;/p&gt;&#xA;" OwnerUserId="17840" LastActivityDate="2020-04-24T18:03:55.373" Title="How to set CursorLine highlight color for the gruvbox colorscheme" Tags="|colorscheme|highlight|color|cursorline|" AnswerCount="2" CommentCount="1" ClosedDate="2020-04-26T11:25:29.647" ContentLicense="CC BY-SA 4.0" />
  <row Id="17545" PostTypeId="2" ParentId="16763" CreationDate="2018-10-01T18:16:40.877" Score="2" Body="&lt;p&gt;So the issue wasn't &lt;code&gt;guioptions&lt;/code&gt;, it was &lt;code&gt;guiheadroom&lt;/code&gt;; I finally noticed this because while I keep my config files synced, the stub &lt;code&gt;~/.vimrc&lt;/code&gt; which sources them isn't, to accomodate local settings. One of which, on another system where I do not have the problem, is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guiheadroom=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I added this here, restarted gvim and problem solved.  From &lt;code&gt;:help guiheadroom&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;'guiheadroom' 'ghr'&lt;/strong&gt;   number  (default 50)            global&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;em&gt;{not in Vi} {only for GTK and X11 GUI}&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The number of pixels subtracted from the screen&#xA;  height when fitting   the GUI window on the screen.  Set this before&#xA;  the GUI is started,   e.g., in your &lt;code&gt;gvimrc&lt;/code&gt; file.  When zero, the&#xA;  whole screen height will  be used by the window.  When positive, the&#xA;  specified number of pixel     lines will be left for window decorations&#xA;  and other items on the    screen.  Set it to a negative value to allow&#xA;  windows taller than the   screen.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that this didn't actually change the base appearance; the window still fills the screen exactly like before and the titlebar and decorations are evident.  However, messages at the bottom no longer disappear in a blur.&lt;/p&gt;&#xA;" OwnerUserId="4913" LastActivityDate="2018-10-01T18:16:40.877" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17546" PostTypeId="2" ParentId="17544" CreationDate="2018-10-01T19:08:45.263" Score="1" Body="&lt;p&gt;Appearently this line    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set termguicolors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;overrides the highlight color. &#xA;removing it let me configure the CursorLine highlight color again.&lt;/p&gt;&#xA;" OwnerUserId="17840" LastActivityDate="2018-10-01T19:08:45.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17547" PostTypeId="1" AcceptedAnswerId="17548" CreationDate="2018-10-01T22:01:12.810" Score="0" ViewCount="1412" Body="&lt;p&gt;When I'm running syntastic, I always see the NASM error,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;binary output format does not support external references                                                                                            &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is because I'm assembling with &lt;code&gt;nasm -f elf64&lt;/code&gt;. How do I instruct syntastic to test the syntax with &lt;code&gt;-f elf64&lt;/code&gt;? Unfortunately, it doesn't seem like I can skirt this issue with an in-file directive.&lt;/p&gt;&#xA;" OwnerUserId="5078" LastActivityDate="2018-10-01T22:25:58.460" Title="NASM and syntastic: binary output format does not support external references" Tags="|plugin-syntastic|filetype-assembly|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17548" PostTypeId="2" ParentId="17547" CreationDate="2018-10-01T22:25:58.460" Score="0" Body="&lt;p&gt;I got this done with,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_nasm_nasm_args = '-f elf64'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks to &lt;a href=&quot;https://vi.stackexchange.com/users/1577/lcd047&quot;&gt;lcd047&lt;/a&gt; who referenced me in the comments to &lt;code&gt;:h syntastic-config-makeprg&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5078" LastActivityDate="2018-10-01T22:25:58.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17549" PostTypeId="1" AcceptedAnswerId="17550" CreationDate="2018-10-02T11:25:36.403" Score="3" ViewCount="1165" Body="&lt;p&gt;I am trying to define a keymapping in &lt;code&gt;vimrc&lt;/code&gt; to compile my markdown file with Pandoc.&#xA;So I am using this:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown nmap &amp;lt;F9&amp;gt; :!pandoc % -o %:r.pdf &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, in markdown file when I am pressing F9 nothing is happening.&#xA;I am not sure if this is the line I need to add in my &lt;code&gt;vimrc&lt;/code&gt; file. Right now I don't want to install any plugins like &lt;code&gt;vim-pandoc&lt;/code&gt; or something like that.&lt;/p&gt;&#xA;" OwnerUserId="19211" LastActivityDate="2018-10-02T12:24:37.027" Title="Using Pandoc with vim keybindings" Tags="|vimrc|key-bindings|autocmd|filetype|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17550" PostTypeId="2" ParentId="17549" CreationDate="2018-10-02T12:13:39.240" Score="7" Body="&lt;p&gt;Your mapping has a few issues:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown nmap &amp;lt;F9&amp;gt; :!pandoc % -o %:r.pdf &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You use a recursive command &lt;code&gt;:nmap&lt;/code&gt;, but you don't need recursiveness, so you should &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/05.html&quot; rel=&quot;noreferrer&quot;&gt;prefer &lt;code&gt;:nnoremap&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown nnoremap &amp;lt;F9&amp;gt; :!pandoc % -o %:r.pdf &amp;lt;cr&amp;gt;&#xA;                          ^^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There's an unneeded space at the end:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown nnoremap &amp;lt;F9&amp;gt; :!pandoc % -o %:r.pdf &amp;lt;cr&amp;gt;&#xA;                                                             ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You use the &lt;code&gt;:!&lt;/code&gt; bang command, without prefixing it with the keycode &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; (see &lt;code&gt;:h c^u&lt;/code&gt;).&lt;br&gt;&#xA;As a result, if you press a count before &lt;code&gt;&amp;lt;F9&amp;gt;&lt;/code&gt;, it will be automatically translated into a range.&lt;br&gt;&#xA;And a range before &lt;code&gt;:!&lt;/code&gt; means that Vim will filter some lines in your buffer (see &lt;code&gt;:h :range!&lt;/code&gt;), which you probably don't want here.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown nnoremap &amp;lt;F9&amp;gt; :&amp;lt;c-u&amp;gt;!pandoc % -o %:r.pdf&amp;lt;cr&amp;gt;&#xA;                                         ^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your filename may contain some special characters which are automatically expanded on Vim's (see &lt;code&gt;:h cmdline-special&lt;/code&gt;) or the shell's command-line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prevent Vim and the shell from interpreting them, you could use the &lt;code&gt;:S&lt;/code&gt; filename modifier (see &lt;code&gt;:h filename-modifiers&lt;/code&gt;), and just to be safe you could also add the &lt;code&gt;:p&lt;/code&gt; modifier so that the paths passed to &lt;code&gt;$ pandoc&lt;/code&gt; are absolute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown nnoremap &amp;lt;F9&amp;gt; :&amp;lt;c-u&amp;gt;!pandoc %:p:S -o %:p:r:S.pdf&amp;lt;cr&amp;gt;&#xA;                                                       ^^^^     ^^  ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that if you use multiple filename modifiers, &lt;code&gt;:S&lt;/code&gt; must be the last one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:!&lt;/code&gt; is good for an interactive use, but usually in a script you use &lt;code&gt;system()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown nnoremap &amp;lt;F9&amp;gt; :&amp;lt;c-u&amp;gt;silent call system('pandoc '.expand('%:p:S').' -o '.expand('%:p:r:S').'.pdf')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this form, Vim doesn't expand the special character &lt;code&gt;%&lt;/code&gt; so you have to invoke &lt;code&gt;expand()&lt;/code&gt; (see &lt;code&gt;:h expand()&lt;/code&gt;).&lt;br&gt;&#xA;The purpose of &lt;code&gt;:silent&lt;/code&gt; is to avoid stray characters showing up on your screen (see &lt;code&gt;:h system()&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When prepended by |:silent| the terminal will not be set to&#xA;  cooked mode.  This is meant to be used for commands that do&#xA;  not need the user to type.  It avoids stray characters showing&#xA;  up on the screen which require |CTRL-L| to remove.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You should wrap your autocmds into a self-clearing augroup so that they aren't duplicated if you resource your &lt;code&gt;vimrc&lt;/code&gt; (see &lt;code&gt;:h autocmd-remove&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup my_markdown&#xA;    autocmd!&#xA;    autocmd FileType markdown nnoremap &amp;lt;F9&amp;gt; :&amp;lt;c-u&amp;gt;silent call system('pandoc '.expand('%:p:S').' -o '.expand('%:p:r:S').'.pdf')&amp;lt;cr&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/17549/using-pandoc-with-vim-keybindings#comment30069_17549&quot;&gt;@statox explained&lt;/a&gt;, your mapping is global, but you probably want it only in a markdown buffer, so you should pass the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; argument to &lt;code&gt;:nnoremap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, autocmds in your &lt;code&gt;vimrc&lt;/code&gt; don't scale well passed a certain point, so you could use a filetype plugin.&#xA;For markdown, you could use the file &lt;code&gt;~/.vim/after/ftplugin/markdown.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that by using a filetype plugin you don't need an autocmd anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And in addition to &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;, you probably want to pass the arguments &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; to &lt;code&gt;:nnoremap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt;&amp;lt;nowait&amp;gt;&amp;lt;silent&amp;gt; &amp;lt;F9&amp;gt; :&amp;lt;c-u&amp;gt;silent call system('pandoc '.expand('%:p:S').' -o '.expand('%:p:r:S').'.pdf')&amp;lt;cr&amp;gt;&#xA;                 ^^^^^^^^^^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; is to prevent Vim from displaying the &lt;code&gt;rhs&lt;/code&gt; of your mapping on the command-line when you press &lt;code&gt;F9&lt;/code&gt;.&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; is to prevent Vim from waiting a few seconds if another mapping begin with &lt;code&gt;F9&lt;/code&gt;.&#xA;Usually, when that happens, it's a conflict between a local and global mapping, and you probably want to give the priority to the local one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In your filetype plugin, you could tell Vim to remove the mapping if you change the filetype of your buffer by including a &lt;code&gt;:nunmap&lt;/code&gt; command in the buffer-local variable &lt;code&gt;b:undo_ftplugin&lt;/code&gt; (see &lt;code&gt;:h undo_ftplugin&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')&#xA;    \ . (empty(get(b:, 'undo_ftplugin', '')) ? '' : '|')&#xA;    \ . &quot;&#xA;    \       exe 'nunmap &amp;lt;buffer&amp;gt; &amp;lt;F9&amp;gt;'&#xA;    \ &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-10-02T12:24:37.027" LastActivityDate="2018-10-02T12:24:37.027" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17551" PostTypeId="1" AcceptedAnswerId="17555" CreationDate="2018-10-02T14:10:24.083" Score="1" ViewCount="490" Body="&lt;p&gt;In Vim, what characters are allowed in identifiers, such as variable names and function names?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked up the help for both variables and functions and neither one defines the allowable character set or syntax for valid identifiers.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="51" LastEditDate="2021-01-27T03:09:27.663" LastActivityDate="2021-01-27T03:09:27.663" Title="What are the allowable characters in identifiers?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17552" PostTypeId="2" ParentId="625" CreationDate="2018-10-02T14:12:02.237" Score="48" Body="&lt;p&gt;If you are editing an open file and want to compare it to another file without closing the current one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open the new file in split screen: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For vertical split:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vs otherFile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or horizontal split:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:split otherFile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Switch cursors to different split screen:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctrl+w ctrl+w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Invoke &quot;diff mode&quot; in file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:diffthis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Switch to other file and invoke &quot;diff mode&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:diffthis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To turn off &quot;diff mode&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:diffoff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19213" LastActivityDate="2018-10-02T14:12:02.237" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17553" PostTypeId="2" ParentId="17544" CreationDate="2018-10-02T14:14:25.057" Score="2" Body="&lt;p&gt;What works for me, in your &lt;code&gt;.vimrc&lt;/code&gt; first set your colorscheme, then your desired highlight:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme gruvbox&#xA;highlight Cursorline whatever_you_like&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way your colorscheme won't clobber your highlight.&lt;/p&gt;&#xA;" OwnerUserId="11066" LastActivityDate="2018-10-02T14:14:25.057" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17554" PostTypeId="1" AcceptedAnswerId="17649" CreationDate="2018-10-02T14:19:46.017" Score="1" ViewCount="385" Body="&lt;p&gt;I use &lt;code&gt;alias lvim='vim -c &quot;normal '\''0&quot;'&lt;/code&gt; for reopen last files in my vim. But the questions is how exit &lt;code&gt;vim&lt;/code&gt; without close any tabs or files, When I use &lt;code&gt;:wq&lt;/code&gt; it close tab or files.&lt;/p&gt;&#xA;" OwnerUserId="4680" LastActivityDate="2018-10-22T12:10:04.493" Title="exiting vim without close tabs or files" Tags="|command-line|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17555" PostTypeId="2" ParentId="17551" CreationDate="2018-10-02T14:47:00.997" Score="3" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#41.2&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 41.2&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*41.2*  Variables&#xA;&#xA;A variable name consists of ASCII letters, digits and the underscore.  It&#xA;cannot start with a digit.  Valid variable names are:&#xA;&#xA;    counter&#xA;    _aap3&#xA;    very_long_variable_name_with_underscores&#xA;    FuncLength&#xA;    LENGTH&#xA;&#xA;Invalid names are &quot;foo+bar&quot; and &quot;6var&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I think it's the same for functions, note that user defined functions must start with an uppercase letter (except from scriptlocal functions beginning with &lt;code&gt;s:&lt;/code&gt; as pointed out @D. Ben Knoble in the comments)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-10-03T07:41:14.187" LastActivityDate="2018-10-03T07:41:14.187" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17557" PostTypeId="2" ParentId="16651" CreationDate="2018-10-02T23:16:50.373" Score="3" Body="&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27cscopetag%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:set cscopetag&lt;/code&gt;&lt;/a&gt; to get that effect.  When this setting is enabled, it uses &lt;a href=&quot;https://vimhelp.appspot.com/if_cscop.txt.html#%3Acstag&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:cstag&lt;/code&gt;&lt;/a&gt; whenever &lt;code&gt;:tag&lt;/code&gt;, &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;, or &lt;code&gt;vim -t&lt;/code&gt; is used.  &lt;code&gt;:cstag&lt;/code&gt; will use a cscope database if present, but if not it falls back to &lt;code&gt;:tjump&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As far as why you see it on one system and not another, I'm pretty sure CentOS (and possibly RedHat) enable &lt;code&gt;'cscopetag'&lt;/code&gt; by default in the system vimrc.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2018-10-02T23:16:50.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17558" PostTypeId="1" CreationDate="2018-10-03T03:29:43.140" Score="10" ViewCount="2099" Body="&lt;p&gt;I would like to have another pane active when debugging a Vimscript function which would show the values of chosen local variables and function arguments dynamically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I have to echo or let to see variable values. It would be more convenient to have them display automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this without a plugin? Is there an easy way to script this with, say, an autocommand for example?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2022-03-08T16:21:31.130" Title="How can I watch variables when debugging Vimscript?" Tags="|vimscript|debugging|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17559" PostTypeId="2" ParentId="10242" CreationDate="2018-10-03T04:49:38.443" Score="6" Body="&lt;h1&gt;Solution 1 :&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Install VIM Editor(Install any one of them of vim variant) :    &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;vim-gtk3&lt;/strong&gt; :-  This package contains a version of vim compiled with a GTK3 GUI and support for scripting with Lua, Perl, Python, Ruby, and Tcl. In order to install this package :  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt install vim-gtk3   &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;vim-gtk&lt;/strong&gt; :- This package contains a version of vim compiled with a GTK2 GUI and support for scripting with Lua, Perl, Python, Ruby, and Tcl. In order to install this package : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt install vim-gtk   &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;vim-nox&lt;/strong&gt; :- enhanced vi editor&#xA;Like vim-tiny, vim-nox is a minimal vim installation and support for&#xA;scripting with Lua, Perl, Python, Ruby, and Tcl but no GUI. It comes with mouse support, but no clipboard support, IIRC. In order to install this package :   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt install vim-nox&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Set Vim as a default editor(assuming installed variant is &lt;strong&gt;vim-gtk3&lt;/strong&gt;)  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim.gtk3 1   &#xA;sudo update-alternatives --set editor /usr/bin/vim.gtk3   &#xA;sudo update-alternatives --install /usr/bin/vi vi /usr/bin/vim.gtk3 1  &#xA;sudo update-alternatives --set vi /usr/bin/vim.gtk3   &#xA;sudo update-alternatives --install /usr/bin/vi vim /usr/bin/vim.gtk3 1  &#xA;sudo update-alternatives --set vim /usr/bin/vim.gtk3    &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Solution 2 :&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you can compile Vim from source code (assuming you're using Debian based system)  &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Prepare your system&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Install   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt install libncurses5-dev \&#xA;libgtk2.0-dev libatk1.0-dev \&#xA;libcairo2-dev python-dev \&#xA;python3-dev git&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Remove Vim if you already have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt remove vim vim-runtime gvim  &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;configure and make&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /usr &amp;amp;&amp;amp; sudo git clone https://github.com/vim/vim.git &amp;amp;&amp;amp; cd vim  &#xA;&#xA;sudo ./configure --with-features=huge \&#xA;--enable-multibyte \&#xA;--enable-pythoninterp=yes \&#xA;--with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/ \  # pay attention here check directory correct&#xA;--enable-python3interp=yes \&#xA;--with-python3-config-dir=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/ \  # pay attention here check directory correct&#xA;--enable-gui=gtk2 \&#xA;--enable-cscope \ &#xA;--prefix=/usr/local/&#xA;&#xA;sudo make VIMRUNTIMEDIR=/usr/local/share/vim/vim81 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Preparing deb package using &lt;a href=&quot;https://wiki.debian.org/CheckInstall&quot; rel=&quot;nofollow noreferrer&quot;&gt;checkinstall&lt;/a&gt;&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;And install that package   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /usr/vim &amp;amp;&amp;amp; sudo checkinstall&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or, if want to just create a package use &lt;code&gt;--install=no&lt;/code&gt; option with checkinstall&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Set Vim as a default editor&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1&#xA;sudo update-alternatives --set editor /usr/local/bin/vim&#xA;sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/vim 1&#xA;sudo update-alternatives --set vi /usr/local/bin/vim   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Verify that you're running the new Vim binary by looking&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version | grep python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;References :&lt;/strong&gt;&lt;br&gt;&#xA;  - &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&quot; rel=&quot;nofollow noreferrer&quot;&gt;Building Vim from Source&lt;/a&gt;&lt;br&gt;&#xA;  - &lt;a href=&quot;https://manpages.debian.org/stretch/checkinstall/checkinstall.8.en.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;checkinstall&lt;/a&gt;&lt;br&gt;&#xA;- &lt;a href=&quot;https://askubuntu.com/questions/281886/what-are-the-differences-between-the-different-vim-packages-available-in-ubuntu&quot;&gt;VIM variants&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18867" LastEditorUserId="18867" LastEditDate="2019-03-19T16:11:06.460" LastActivityDate="2019-03-19T16:11:06.460" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17560" PostTypeId="2" ParentId="17523" CreationDate="2018-10-03T10:52:22.940" Score="0" Body="&lt;h3&gt;Via External Tool &lt;a href=&quot;https://pypi.org/project/pyaml/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pretty-Yaml (pyaml)&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Install &lt;code&gt;pyaml&lt;/code&gt; with pip&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ pip install pyaml &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or to your home directory&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ pip install --user pyaml&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Filter all lines through &lt;code&gt;pyaml&lt;/code&gt; and give width option &lt;code&gt;-w/--width&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!python -m pyaml -w 32&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note there is a limitation to the width option according to their help message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;❯ python -m pyaml -h&#xA;usage: __main__.py [-h] [-w chars] [path]&#xA;&#xA;Process and dump prettified YAML to stdout.&#xA;&#xA;positional arguments:&#xA;  path                  Path to YAML to read (default: use stdin).&#xA;&#xA;optional arguments:&#xA;  -h, --help            show this help message and exit&#xA;  -w chars, --width chars&#xA;                        Max line width hint to pass to pyyaml for the dump.&#xA;                        Only used to format scalars and collections (e.g.&#xA;                        lists).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add following to &lt;code&gt;~/.vim/after/ftplugin/yaml.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal textwidth=32&#xA;let &amp;amp;l:formatprg = 'python -m pyaml -w' . &amp;amp;l:textwidth&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you change &lt;code&gt;textwidth&lt;/code&gt; during runtime and &lt;code&gt;formatprg&lt;/code&gt; should pick up the new value, see &lt;a href=&quot;https://vi.stackexchange.com/q/12993/1292&quot;&gt;set formatprg dynamically based on textwidth?&lt;/a&gt;. Note there are also plugins to help you here, e.g. &lt;a href=&quot;https://github.com/Chiel92/vim-autoformat&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-autoformat&lt;/a&gt;, &lt;a href=&quot;https://github.com/sbdchd/neoformat&quot; rel=&quot;nofollow noreferrer&quot;&gt;neoformat&lt;/a&gt;, or &lt;a href=&quot;https://github.com/google/vim-codefmt&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-codefmt&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-10-15T09:13:31.973" LastActivityDate="2018-10-15T09:13:31.973" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17561" PostTypeId="2" ParentId="2761" CreationDate="2018-10-03T11:33:51.740" Score="0" Body="&lt;p&gt;I tried some of the other answers listed here and the solution &lt;a href=&quot;https://vi.stackexchange.com/a/13551/19227&quot;&gt;here&lt;/a&gt; but found them distracting and prone to error messages. timakro has written a &lt;a href=&quot;https://github.com/timakro/vim-searchant&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt; that solves the problem and is working well for me so far.&lt;/p&gt;&#xA;" OwnerUserId="19227" LastEditorUserId="19227" LastEditDate="2018-10-04T14:12:31.330" LastActivityDate="2018-10-04T14:12:31.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17562" PostTypeId="1" CreationDate="2018-10-03T19:10:17.387" Score="1" ViewCount="110" Body="&lt;p&gt;Vim functions do not seem to be able to fail without spitting out 3 unnecessary lines. For example, take this set of functions and maps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; NEXT / PREVIOUS&#xA;&quot; ~~~~~~~~~~~~~~~&#xA;&quot; n and N always search for matched pattern forwards and backwards (resp.)&#xA;&quot; no more guessing!&#xA;function! s:searchNext(forward)&#xA;    try&#xA;        execute 'normal! '.(a:forward ? 'n' : 'N')&#xA;    catch /^Vim\%((\a\+)\)\=:E486/&#xA;        echohl ErrorMsg&#xA;        echon &quot;\rE486: Pattern not found: &quot;.@/&#xA;        echohl None&#xA;        &quot; echoerr 'E486: Pattern not found: '.@/&#xA;        return&#xA;    endtry&#xA;    normal! zv&#xA;    redraw&#xA;    echon (a:forward ? '/' : '?').@/&#xA;endfunction&#xA;nnoremap n :call &amp;lt;sid&amp;gt;searchNext(v:searchforward ? 1 : 0)&amp;lt;bar&amp;gt;set hlsearch&amp;lt;cr&amp;gt;&#xA;nnoremap N :call &amp;lt;sid&amp;gt;searchNext(v:searchforward ? 0 : 1)&amp;lt;bar&amp;gt;set hlsearch&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now try opening a file with this in it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar keepme 1&#xA;&#xA;foo&#xA;bar&#xA;&#xA;foo&#xA;bar keepme 2&#xA;&#xA;foo&#xA;bar&#xA;&#xA;foo&#xA;bar&#xA;&#xA;foo&#xA;keepme bar 3&#xA;&#xA;foo&#xA;bar&#xA;&#xA;1 | let @a = '' | let @/ = 'keep'.'me' | let @q = 'n&quot;Ad2k'&#xA;keepme .. run on previous line: ^y$:&amp;lt;c-r&amp;gt;&quot;&amp;lt;cr&amp;gt;  then press @q at least 5 times&#xA;&#xA;on the 5th time, the macro does not fail on the &quot;n&quot;, so the text that would not&#xA;be yanked into @a with norm! n IS cut/yanked into @a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Follow the instructions.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The issue is that &lt;code&gt;:echon&lt;/code&gt; doesn't fail. So, I tried to &lt;code&gt;return 0&lt;/code&gt; and &lt;code&gt;return 1&lt;/code&gt;. This doesn't seem to make the function fail. I tried replacing the 3 lines (&lt;code&gt;echohl ..&lt;/code&gt;, &lt;code&gt;echon ..&lt;/code&gt;, &lt;code&gt;echohl ..&lt;/code&gt;) with &lt;code&gt;echoerr ..&lt;/code&gt; (the commented out bit), but this takes up three lines with two error messages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;24_searchNext:&#xA;line    7:&#xA;E486: Pattern not found: keepme&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and that--to me--is just unacceptable.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So, is there:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;a way to make a function fail without &lt;code&gt;:echoerr&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it thouroughly annoys me that &lt;code&gt;:echoerr&lt;/code&gt; throws an error itself .. ridiculous .. there should at least be an &lt;code&gt;:echoerr&lt;/code&gt; that doesn't throw an error&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;or&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;a way to &lt;code&gt;:echoerr&lt;/code&gt; without throwing an error or some way to achieve something similar&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;or&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;any other way of making the macro (or another &lt;code&gt;nmap&lt;/code&gt;) fail when using a map that is bound to a function like this (restriction: you can only make it fail from within this function, itself).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thanks,&lt;/p&gt;&#xA;" OwnerUserId="5108" LastActivityDate="2018-10-05T06:47:32.183" Title="Function Unable to Fail: Breaks Macros" Tags="|vimscript|functions|macro|key-bindings|error|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17563" PostTypeId="1" AcceptedAnswerId="17564" CreationDate="2018-10-03T21:09:52.003" Score="8" ViewCount="1099" Body="&lt;p&gt;Occasionally when I type &lt;code&gt;:&lt;/code&gt; to quit or write my file the prompt already contains the characters &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt; without me typing anything. It causes an error if I type &lt;code&gt;w&lt;/code&gt; or &lt;code&gt;q&lt;/code&gt;. I cannot replicate this problem. It happens at the oddest times and I have not been able to determine what is causing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It took me forever to figure out that my accidentally typing &lt;code&gt;q:&lt;/code&gt; instead of &lt;code&gt;:q&lt;/code&gt; was causing me to have trouble quitting. Now that I know about that little quirk, I'm trying to figure out what causes this other behavior. I can't find anything on it, though I've seen it somewhere in someone's colon command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this an expected behavior? What could be causing it?&lt;/p&gt;&#xA;" OwnerUserId="17830" LastEditorUserId="17830" LastEditDate="2018-10-03T21:20:24.503" LastActivityDate="2018-10-04T15:00:40.820" Title="'&lt;,'&gt; in command prompt" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17564" PostTypeId="2" ParentId="17563" CreationDate="2018-10-03T21:15:18.967" Score="15" Body="&lt;p&gt;Seeing &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; in the command line when you press &lt;kbd&gt;:&lt;/kbd&gt; indicates that you currently have a &lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;visual&lt;/a&gt; range selected (e. g. with &lt;kbd&gt;v&lt;/kbd&gt;, &lt;kbd&gt;V&lt;/kbd&gt;, or &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;v&lt;/kbd&gt;), and vim is helpfully prefixing the markers for 'beginning of selection' through 'end of selection' in order to apply those limitations to the scope of the command you are presumably about to enter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#visual-operators&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h visual-operators&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that the &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; will appear automatically when you press &lt;code&gt;:&lt;/code&gt; in&#xA;  Visual mode.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since you can't &quot;quit&quot; only a certain part of a file, that is why you get an &lt;code&gt;Invalid address&lt;/code&gt; when you try to &lt;code&gt;:'&amp;lt;,'&amp;gt;q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do want to run a command not suchly limited, you can press &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;U&lt;/kbd&gt; to erase everything to the left of the cursor before entering &lt;code&gt;q&lt;/code&gt;, or simply use the &lt;code&gt;ZZ&lt;/code&gt; or &lt;code&gt;ZQ&lt;/code&gt; alias.&lt;/p&gt;&#xA;" OwnerUserId="5284" LastEditorUserId="5284" LastEditDate="2018-10-04T15:00:40.820" LastActivityDate="2018-10-04T15:00:40.820" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17565" PostTypeId="1" CreationDate="2018-10-04T13:04:05.043" Score="0" ViewCount="308" Body="&lt;p&gt;Sometimes I copy 'compressed' HTML from TEXTAREA an I get code for ex. like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;header1&amp;lt;/h1&amp;gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&#xA;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&#xA;&amp;lt;div&amp;gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but GVim after command &lt;code&gt;gg=G&lt;/code&gt; indent only lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;header1&amp;lt;/h1&amp;gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&#xA;    &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&#xA;    &amp;lt;div&amp;gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what I need is unfold(in a sense that tags are not in one line) all tags like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&#xA;&#xA;&amp;lt;body&amp;gt;&#xA;    &amp;lt;h1&amp;gt;header1&amp;lt;/h1&amp;gt;&#xA;    &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&#xA;    &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&#xA;    &amp;lt;div&amp;gt;&#xA;        &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&#xA;    &amp;lt;/div&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have installed Syntastic plugin and newest Tidy &#xA;I try also &#xA;&lt;code&gt;:!tidy -mi -html -wrap 0 %&lt;/code&gt;&#xA;but somehow nothing works.&lt;/p&gt;&#xA;" OwnerUserId="16328" LastEditorUserId="16328" LastEditDate="2018-10-04T14:49:26.903" LastActivityDate="2018-10-05T18:05:27.373" Title="Indentation command `gg=G` for 'compressed' HTML doesn't unfold tags" Tags="|indentation|gvim|plugin-syntastic|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17566" PostTypeId="1" CreationDate="2018-10-04T14:52:50.040" Score="5" ViewCount="954" Body="&lt;p&gt;Vim has the command &lt;code&gt;:goto&lt;/code&gt; to go to a byte offset in a buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an equivalent for a character offset?  If not, is there a better way to implement it than repeatedly testing the cursor's character offset and moving backward/forward until you reach the right place?&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2018-10-08T12:04:03.810" Title="How to jump to a character offset in a buffer?" Tags="|vimscript|cursor-movement|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17568" PostTypeId="2" ParentId="6598" CreationDate="2018-10-04T16:24:36.223" Score="1" Body="&lt;p&gt;I had this problem when I had multiple versions of it, one for gvim and other for vim. Please check if it works for one version or the other. For me it was &lt;code&gt;set nocompatible&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt; that forbid the &lt;code&gt;cwindow&lt;/code&gt; for non-gvim version.&lt;/p&gt;&#xA;" OwnerUserId="16482" LastActivityDate="2018-10-04T16:24:36.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17569" PostTypeId="1" AcceptedAnswerId="17570" CreationDate="2018-10-04T19:05:56.587" Score="0" ViewCount="576" Body="&lt;p&gt;I have configured .dotfiles. Eg. see here &lt;a href=&quot;https://wiki.archlinux.org/index.php/Dotfiles&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://wiki.archlinux.org/index.php/Dotfiles&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now I can do dgit push or dgit pull on whichever computer I want, and I have all my config files (including .vimrc) with me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I wish to share vim history across all my accounts on different computers. I suppose that there can be many different solutions to this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I am doing this manually by storing vim history inside a ~/.vim_history_manual.txt file. I do this by typing exactly this inside gvim (version 8.0.707):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;q:ggVGY:q&amp;lt;CR&amp;gt;:e ~/.vim_history_manual.txt&amp;lt;CR&amp;gt;PggVG!sort|uniq&amp;lt;CR&amp;gt;:wq&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These commands followed by a dgit push will make my vim history available on other computers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to make it more automatic. However I have never written such advanced functions in gvim :) I started typing in .vimrc this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ExportVimHistoryManually()&#xA;...?&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;only to realize that, I suppose, putting these commands there verbatim would not work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;q:ggVGY:q&amp;lt;CR&amp;gt;:e ~/.vim_history_manual.txt&amp;lt;CR&amp;gt;PggVG!sort|uniq&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So could you tell me:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;how to solve this problem in general - share vim history across different accounts, using vim / gvim version 8.0.707&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;or how to solve this problem in particular - how to write this function ExportVimHistoryManually() which I started?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Perhaps then this function could be supplemented by a second function ImportVimHistoryManually() ? Because currently, when I want to check some of my old commands, I open ~/.vim_history_manual.txt file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;or maybe there is some vim plugin for this which I missed?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;EDIT: I didn't mention it before, but only now (after seeing B Layer's answer, and earlier discussion) I realized, that it would be most useful when invoked from inside a running vim session. This is because usually I have multiple instances of gvim opened, and the instance which has quit last is overwriting the viminfo file. So it seems to me, that the best way to preserve history of other instances is to export it manually without ever quitting. The other way is to save session then quit, run B Layer's command, then start it again and restore session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: I am using devuan linux ascii release.&lt;/p&gt;&#xA;" OwnerUserId="14986" LastEditorUserId="14986" LastEditDate="2018-10-05T10:27:05.350" LastActivityDate="2018-10-07T02:25:26.000" Title="Sharing vim commands history across different users and computers" Tags="|command-line|gvim|functions|command-history|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17570" PostTypeId="2" ParentId="17569" CreationDate="2018-10-05T01:53:51.393" Score="1" Body="&lt;p&gt;Originally I proposed a simple solution for extracting the command line history out of the &quot;viminfo&quot; file using standard command line tools. I'll cover that first. Then based on pop-up requirements from OP I proposed a solution that does everything from within Vim using some viminfo management commands and settings. That's in the second section below.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;External (Command Line) Solution&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can get the Vim command line history from the &quot;viminfo&quot; file (usually ~/.viminfo for Linux)...no need to be in Vim at all. Here's one command that will extract it...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;awk 'h==1 &amp;amp;&amp;amp; /^[^|]/ { if (/^#/) exit; print; } /# Command Line History/ { h=1; } ~/.viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be put through &lt;code&gt;sort&lt;/code&gt;, &lt;code&gt;uniq&lt;/code&gt;, etc...whatever you need...then saved to your target file with &lt;code&gt;&amp;gt; ~/.vmi_history_manual.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a Vim site, though, so in that vein here is an alternative:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -es -c '/# Command Line History/+1;/^$/-1 g/^:/p' -c 'q' ~/.viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses the &lt;code&gt;ex&lt;/code&gt; line editor mode of Vim. Those are just Vim commands so there shouldn't be any mystery to this but here's a description of the main command...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/# Command Line History/+1;/^$/-1 g/^:/p&lt;/code&gt; : Run the global command (&lt;code&gt;:g&lt;/code&gt;) against a range in the buffer. It starts after (&lt;code&gt;+1&lt;/code&gt;) the comment that opens the history section and stops before (&lt;code&gt;-1&lt;/code&gt;) the terminating blank line. The global command prints lines starting with colon (IOW, it skips those lines starting with &lt;code&gt;|&lt;/code&gt; as you indicated you need to do).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As with the previous command, you can pump the output through post-processing utils and send it to the target file.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Internal (In-Vim) Solution&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can leverage Vim's own mechanism for mangaging the viminfo file.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The contents of viminfo are determined by the &lt;code&gt;'viminfo'&lt;/code&gt; settings. You can set that so only the parts you care about are saved (e.g. command line history).&lt;/li&gt;&#xA;&lt;li&gt;You can tell Vim to write to the viminfo file with &lt;code&gt;:wv [file]&lt;/code&gt;. Yes that's an optional filename parameter. You can use your &lt;code&gt;~/.vim_history_manual.txt&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Do this for all running Vim instances. The data will be merged and only if there's a conflict will anything be lost. (Last Vim instance to write wins.)&lt;/li&gt;&#xA;&lt;li&gt;You can then read that new viminfo file into whatever Vim instances you want, whenever you want with &lt;code&gt;:rv [file]&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A function to do the writing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! SaveCmdHist(filename)&#xA;    &quot; Save current config so we can restore after our custom write.&#xA;    let l:oldconfig = &amp;amp;viminfo&#xA;&#xA;    &quot; Turn off all viminfo except command line history&#xA;    let &amp;amp;viminfo = &quot;'0,/0,&amp;lt;0,@0,f0,s0&quot;&#xA;&#xA;    &quot; Now write out the info. The bang (!) says to skip reading in&#xA;    &quot; the info to this Vim instance. In this context we don't want that.&#xA;    exec &quot;wv! &quot; . a:filename&#xA;&#xA;    &quot; Restore original config&#xA;    let &amp;amp;viminfo = l:oldconfig&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that we don't explicitly configure command history in the &lt;code&gt;'viminfo'&lt;/code&gt; value as we can just rely on defaults (limit is in &lt;code&gt;'history'&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Call with &lt;code&gt;:call SaveCmdHist('~/.vim_history_manual.txt')&lt;/code&gt;, for instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It'd be a good idea for you to read this help section about manual reads (and writes): &lt;code&gt;:h viminfo-read-write&lt;/code&gt;. Heck, while you're there you might as well read that entire section (&lt;code&gt;:h viminfo&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-10-07T02:25:26.000" LastActivityDate="2018-10-07T02:25:26.000" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17571" PostTypeId="1" CreationDate="2018-10-05T06:18:31.360" Score="0" ViewCount="567" Body="&lt;p&gt;Is there a way to make vim not close the current fold I'm in when I close a file? For example: I am typing inside a fold, I save and close the file (without presing zc to close the fold), and then when I reopen the file the fold I was in is now closed and I have to open it again and scroll to where I was. Is there any way to prevent this from happening? I would like to be able to open the file and have the fold just how I left it, open, with my cursor in the same place it was. Here is my vimrc for folds and keeping the cursor where is was on the last closing of the file: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; set foldmethod=manual                                                           &#xA; set foldnestmax=10                                                              &#xA; set foldlevel=2                                                                 &#xA;&#xA; &quot;---- Auto save folding when closing file ----&quot;                                 &#xA; augroup AutoSaveFolds                                                           &#xA;   autocmd!                                                                      &#xA;   autocmd BufWinLeave * mkview                                                  &#xA;   autocmd BufWinEnter * silent loadview                                         &#xA; augroup END  &#xA;&#xA;&quot;---- Jump to last cursor location upon opening file ----&quot;                      &#xA;&#xA; if has(&quot;autocmd&quot;)                                                               &#xA;   au BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 0 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;)               &#xA;     \| exe &quot;normal! g'\&quot;&quot; | endif                                               &#xA; endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19251" LastActivityDate="2022-03-22T05:41:41.707" Title="Vim: Don't close fold when closing file" Tags="|folding|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17572" PostTypeId="2" ParentId="17562" CreationDate="2018-10-05T06:40:01.327" Score="1" Body="&lt;p&gt;&lt;em&gt;...:echoerr without throwing an error or some way to achieve something similar?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Call it outside of a try block. Per &lt;code&gt;:h :echoerr&lt;/code&gt; you're seeing this behavior...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When used inside a try conditional, the message is raised as an error exception &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;...make a function fail without :echoerr?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;:throw&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you read all of the applicable Vim documentation? Besides the help for individual commands like &lt;code&gt;:echoerr&lt;/code&gt;, &lt;code&gt;:throw&lt;/code&gt;, &lt;code&gt;:try&lt;/code&gt;, &lt;code&gt;:catch&lt;/code&gt;, etc. there's this whole section: &lt;code&gt;:h exception-handling&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-10-05T06:47:32.183" LastActivityDate="2018-10-05T06:47:32.183" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="17573" PostTypeId="1" AcceptedAnswerId="17574" CreationDate="2018-10-05T10:35:54.657" Score="6" ViewCount="2260" Body="&lt;p&gt;I like the &lt;code&gt;set colorcolumn=80&lt;/code&gt; option which highlights the column at 80 characters, however I find it annoying when working with multiple split windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to have an option to enable or disable the colored column by using  the &lt;code&gt;&amp;lt;leader&amp;gt;c&lt;/code&gt; shortcut. I wrote a function, however my Vimscript knowledge is very limited. My only question is do you see anything wrong with this function or approach? or should I go with it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Show a colored column at 80 characters&#xA;function! ColorColumn()&#xA;if &amp;amp;colorcolumn == &quot;&quot;&#xA;    set colorcolumn=80&#xA;else&#xA;    set colorcolumn=&#xA;endif&#xA;endfunction&#xA;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;c :call ColorColumn()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18231" LastEditorUserId="1841" LastEditDate="2018-10-05T17:09:22.847" LastActivityDate="2018-10-05T17:21:43.800" Title="Function to toggle set colorcolumn" Tags="|vimscript|colorcolumn|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17574" PostTypeId="2" ParentId="17573" CreationDate="2018-10-05T15:35:52.303" Score="11" Body="&lt;p&gt;The only big flaw I see in your code is the fact that you don't use the non recursive version of &lt;code&gt;nmap&lt;/code&gt; (See &lt;a href=&quot;https://vi.stackexchange.com/a/10130/1841&quot;&gt;here&lt;/a&gt; for more details).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also just for the sake to not use a function and make it a one liner I came up with this mapping which should do the same job:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;c :execute &quot;set colorcolumn=&quot; . (&amp;amp;colorcolumn == &quot;&quot; ? &quot;80&quot; : &quot;&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We use &lt;code&gt;execute&lt;/code&gt; to execute the command created on the fly and a ternary expression to return &lt;code&gt;&quot;&quot;&lt;/code&gt; or &lt;code&gt;80&lt;/code&gt; depending on the current state of &lt;code&gt;colorcolumn&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to keep it under 80 characters you could use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;c :execute &quot;set colorcolumn=&quot;&#xA;                  \ . (&amp;amp;colorcolumn == &quot;&quot; ? &quot;80&quot; : &quot;&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I think it's less readable than the one line version.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-10-05T17:21:43.800" LastActivityDate="2018-10-05T17:21:43.800" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17575" PostTypeId="2" ParentId="17571" CreationDate="2018-10-05T15:47:32.000" Score="1" Body="&lt;p&gt;Since your cursor should be where you left it last, you could try &lt;code&gt;zv&lt;/code&gt; to open enough folds to see your cursor (bonus: it doesn’t move the cursor). &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-10-05T15:47:32.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17576" PostTypeId="2" ParentId="17565" CreationDate="2018-10-05T18:05:27.373" Score="1" Body="&lt;p&gt;A full vimscript solution could be to put each tag on its own line with a substitution and then rely on the built-in formatter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;gt;&amp;lt;/&amp;gt;\r&amp;lt;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&#xA;&amp;lt;body&amp;gt;&#xA;&amp;lt;h1&amp;gt;header1&amp;lt;/h1&amp;gt;&#xA;&amp;lt;p&amp;gt;&#xA;&amp;lt;/p&amp;gt;&#xA;&amp;lt;p&amp;gt;&#xA;&amp;lt;/p&amp;gt;&#xA;&amp;lt;div&amp;gt;&#xA;&amp;lt;p&amp;gt;&#xA;&amp;lt;/p&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;G&lt;/kbd&gt; gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&#xA;    &amp;lt;body&amp;gt;&#xA;        &amp;lt;h1&amp;gt;header1&amp;lt;/h1&amp;gt;&#xA;        &amp;lt;p&amp;gt;&#xA;        &amp;lt;/p&amp;gt;&#xA;        &amp;lt;p&amp;gt;&#xA;        &amp;lt;/p&amp;gt;&#xA;        &amp;lt;div&amp;gt;&#xA;            &amp;lt;p&amp;gt;&#xA;            &amp;lt;/p&amp;gt;&#xA;        &amp;lt;/div&amp;gt;&#xA;    &amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I think that it would be better to use a specialized tool as you already tried.&#xA;I think the problem in your command is that you used the &lt;code&gt;-m̀&lt;/code&gt; tag and misused &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want to put the &lt;code&gt;%&lt;/code&gt; sign before &lt;code&gt;!&lt;/code&gt;. This way it doesn't refers to the name of the currently edited file, it means that all the lines of the current buffer will be piped to the command written after &lt;code&gt;!&lt;/code&gt;, and the standard output of the command will be put in the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you don't need to give the &lt;code&gt;-m&lt;/code&gt; tag to tidy since it will not modify an original file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did not test it but the following command should work properly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!tidy -i -html -wrap 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-10-05T18:05:27.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17577" PostTypeId="1" CreationDate="2018-10-05T22:23:50.713" Score="2" ViewCount="71" Body="&lt;p&gt;Newbie question: Are counts commutative?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;2d2w&lt;/code&gt; is the same as &lt;code&gt;4dw&lt;/code&gt;, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it the case for all commands that &lt;code&gt;(count1)(verb)(count2)(whatever)&lt;/code&gt; the same as &lt;code&gt;(count1+count2)(verb)(whatever)&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If counts are commutative, why are there two places to give a count?&lt;/p&gt;&#xA;" OwnerUserId="19264" LastActivityDate="2018-10-06T05:44:45.900" Title="Are counts commutative?" Tags="|count|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17578" PostTypeId="2" ParentId="17571" CreationDate="2018-10-06T05:33:37.380" Score="1" Body="&lt;p&gt;&lt;em&gt;Due to some airheadedness combined with looking at different but related questions while answering, I wrote this as if OP didn't already use &lt;code&gt;:mkview&lt;/code&gt;. I'd delete it but the thing is I tested it and it preserved folds just fine. So I'm going to leave this for now while I investigate a bit more.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:mkview&lt;/code&gt;. This saves various information about the state of a single file, including fold status. The details...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You need to have &quot;folds&quot; in the value of &lt;code&gt;'viewoptions'&lt;/code&gt;. It's there by default. Otherwise, &lt;code&gt;:set vop+=folds&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Before you close the file: &lt;code&gt;:mkview&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;After reopening the file: &lt;code&gt;:loadview&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Per the documentation it restores...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;manually created folds, opened/closed folds and local fold options&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you want to use this all the time you might consider creating an autocommand for a buffer/file close event and do &lt;code&gt;:mkview&lt;/code&gt; there. Similarly for file open + &lt;code&gt;:loadview&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h :mkview&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;:h :loadview&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;:h 'viewoptions'&lt;/code&gt;  &lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-10-07T02:35:17.190" LastActivityDate="2018-10-07T02:35:17.190" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17579" PostTypeId="2" ParentId="17577" CreationDate="2018-10-06T05:44:45.900" Score="2" Body="&lt;p&gt;[please forgive me for the poor formatting, I typed it in my cell phone]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally speaking, it is not necessarily always the case. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;User can define new operators, which sets the operatorfunc and then run normal command g@. For example &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap D :let g:count=v:count1 &amp;lt;cr&amp;gt;:set operatorfunc=MyD&amp;lt;cr&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is the user’s responsibility to capture the count (v:count1) pressed before pressing D, save it and then handle it inside function MyD&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After pressing D, vim then enters the operator pending mode, waiting for a motion. This motion can also handle it own count.  For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;omap &amp;lt;expr&amp;gt; D v:count . “j”&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That means pressing 3D in operator pending mode means the same as 3j, which selects 4 lines. But how does the operator D handles these 4 lines? It actually don’t know here 3j is pressed. Inside MyD, the marks ‘[ and ‘] are set to the start and end of the selection. This is the info passed to MyD from the motion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If user press 2D5D,  inside MyD, it knows the marks and knows the count g:count  and perform the real action. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From all these, you know that generally it doesn’t need to be commutative. A lot logics can be defined. &lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-10-06T05:44:45.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17580" PostTypeId="1" CreationDate="2018-10-06T19:31:51.843" Score="4" ViewCount="163" Body="&lt;p&gt;If I &lt;code&gt;set spell&lt;/code&gt;, Vim seems to only recognise some ordinal numbers: &lt;code&gt;1st&lt;/code&gt;, &lt;code&gt;2nd&lt;/code&gt;, etc. are fine, but anything from &lt;code&gt;10th&lt;/code&gt; to &lt;code&gt;20th&lt;/code&gt; is apparently misspelled. Then &lt;code&gt;21st&lt;/code&gt;, &lt;code&gt;22nd&lt;/code&gt; and &lt;code&gt;23rd&lt;/code&gt; are fine, but then they're all misspellings until &lt;code&gt;31st&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ey2qF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ey2qF.png&quot; alt=&quot;image as described above&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim 8.1.290.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is Vim so inconsistent here, and how can I fix it (ideally without adding &lt;code&gt;th&lt;/code&gt; to my spellfile)?&lt;/p&gt;&#xA;" OwnerUserId="12447" LastActivityDate="2018-10-10T22:44:07.037" Title="How can I make Vim recognise ordinal numbers (1st, 2nd) as valid spellings?" Tags="|spell-checking|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17581" PostTypeId="1" AcceptedAnswerId="17587" CreationDate="2018-10-06T20:54:54.173" Score="0" ViewCount="781" Body="&lt;p&gt;I would think this would work to make backspace delete the entire previous word in insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;BS&amp;gt; &amp;lt;C-W&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it doesn't. Tried in vim 8.0 and neovim 0.2.2 iterm2 if that matters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way to accomplish this?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Per comments below (and after reading the linked question) I've done the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;switched to &lt;code&gt;inoremap&lt;/code&gt; (didn't fix)&lt;/li&gt;&#xA;&lt;li&gt;tested the output of &lt;code&gt;:imap &amp;lt;BS&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The output was the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i &amp;lt;BS&amp;gt;    *@&amp;lt;RC&amp;gt;=AutoPairsDelete()&amp;lt;CR&amp;gt;&#xA;i &amp;lt;BS&amp;gt;    * &amp;lt;C-W&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Removing the &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;autopairs plugin&lt;/a&gt; makes backspacing over words work correctly, but I like that plugin and would like to have both behaviors.&lt;/p&gt;&#xA;" OwnerUserId="14048" LastEditorUserId="14048" LastEditDate="2018-10-07T18:51:05.227" LastActivityDate="2018-10-07T18:51:05.227" Title="Mapping backspace to delete previous word" Tags="|key-bindings|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="17582" PostTypeId="1" CreationDate="2018-10-07T15:45:40.150" Score="1" ViewCount="509" Body="&lt;p&gt;I usually open files one in a single vim application. Occasionally, I open multiple files at once to fix some mistakes in batch, for example, after static analyzer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I was edited files in the order &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt;, and run from a command line &lt;code&gt;vim a b c&lt;/code&gt;, I'll see that my current buffer is &lt;code&gt;b&lt;/code&gt;, previos buffer is &lt;code&gt;c&lt;/code&gt;, but buffers will be opened and assigned their numbers sequentially in the order &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;. In other words, the order of &lt;em&gt;numbered&lt;/em&gt; buffer list is the same as the order in the command line, but the order in which buffers are actually opened (starting buffer, &lt;code&gt;:bn&lt;/code&gt; and &lt;code&gt;:bp&lt;/code&gt;) is the same as I previously opened individual files, starting from the last one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I heavily use &lt;code&gt;w | bw&lt;/code&gt; sequence and I rely on what previous/next buffer is. It's become even more annoying when you open 50+ files and you have to read output from an analyzer upside-down or in a random order, because &lt;code&gt;vim&lt;/code&gt; desided to order buffers this way. The command example I use to run a &quot;mass fix session&quot; is &lt;code&gt;vim $(awk -F: '{print $1}' analyzer.out | uniq)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To manually override this behaviour I have to remove &lt;code&gt;.viminfo&lt;/code&gt; file, but from time to time it contains useful information like last used commands which I use a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to prevent Vim to have this behaviour? Or any command I could run to reset it? When using session management, it's quite fine to restore a file I previously was, but it's quite useless and annoing in my case. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I use MacVim 8.1.280 (151) in GUI mode, but, unfortunately, it's not a MacVim-specific issue and running vim on Linux or FreeBSD have the same behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Different installations share only YCM and I don't believe that it responsible for this odd behavior.&lt;/p&gt;&#xA;" OwnerUserId="15205" LastEditorUserId="15205" LastEditDate="2018-10-07T23:35:25.007" LastActivityDate="2018-10-07T23:35:25.007" Title="Last buffer order" Tags="|buffers|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17583" PostTypeId="2" ParentId="10242" CreationDate="2018-10-07T16:05:20.317" Score="1" Body="&lt;p&gt;Just checked, the vim-nox (v. 8.1) available from the PPA had been compiled with Python 3 (only, not both, if you &lt;em&gt;really&lt;/em&gt; need both I would advise to switch to Neovim).&lt;/p&gt;&#xA;" OwnerUserId="19278" LastActivityDate="2018-10-07T16:05:20.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17584" PostTypeId="1" CreationDate="2018-10-07T16:12:32.473" Score="0" ViewCount="927" Body="&lt;p&gt;For example, I wish to change &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;1&#xA;2&#xA;3&#xA;5&#xA;8&#xA;13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1&#xA; 1&#xA; 2&#xA; 3&#xA; 5&#xA; 8&#xA;13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where this is not necessarily at the start of the line. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="18355" LastActivityDate="2018-11-12T01:43:58.140" Title="How do I insert a single space into the same column of a group of lines?" Tags="|visual-block|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17585" PostTypeId="2" ParentId="17584" CreationDate="2018-10-07T17:39:26.553" Score="2" Body="&lt;p&gt;Move your cursor to the first single-digit number, the first &lt;code&gt;1&lt;/code&gt; in this case. Type &lt;code&gt;Ctrl-v&lt;/code&gt;. Then move your cursor to the last single-digit number, the &lt;code&gt;8&lt;/code&gt; in this case. There are several ways to move the cursor. &lt;code&gt;5j&lt;/code&gt; will work. Then type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; is the &lt;code&gt;Esc&lt;/code&gt; key and there is a single space between the &lt;code&gt;I&lt;/code&gt; and the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. That inserts a space in front of the visually-selected block. See&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help 10.5&#xA;:help CTRL-V&#xA;:help visual.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2018-10-07T17:39:26.553" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17587" PostTypeId="2" ParentId="17581" CreationDate="2018-10-07T18:50:23.160" Score="1" Body="&lt;p&gt;Figured it out. First, need to turn off the plugin's handling of backspace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:AutoPairsMapBS = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will cause it not to remap backspace when it loads because of the conditional check in the plugin's code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if g:AutoPairsMapBS&#xA;  &quot; Use &amp;lt;C-R&amp;gt; instead of &amp;lt;expr&amp;gt; for issue #14 sometimes press BS output strange words&#xA;  execute 'inoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;BS&amp;gt; &amp;lt;C-R&amp;gt;=AutoPairsDelete()&amp;lt;CR&amp;gt;'&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I can substitute my own remapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;BS&amp;gt; &amp;lt;C-R&amp;gt;=AutoPairsDelete()&amp;lt;CR&amp;gt;&amp;lt;C-W&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That does both. Note that it is necessary to include the plugin's function if you want it to work properly, otherwise typing e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main () {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the backspace over the &lt;code&gt;{&lt;/code&gt; instead of the matching brace being deleted it just gets orphaned and left on screen.&lt;/p&gt;&#xA;" OwnerUserId="14048" LastActivityDate="2018-10-07T18:50:23.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17588" PostTypeId="2" ParentId="17464" CreationDate="2018-10-07T20:36:32.050" Score="10" Body="&lt;p&gt;&lt;strong&gt;tl;dr&lt;/strong&gt;: My path was using the an old Vim version, with v8.1.428 we have full 24-bit glorious colours in Vim in the Windows Console! See below for screenshots.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Err, so there was a basic mistake on my part. I still had my system environment path pointing to my Git SCM installation &lt;code&gt;C:\Program Files\Git\usr\bin&lt;/code&gt; (which contains an older version of Vim) and on top of that I had the same directory before my new Vim installation directory of &lt;code&gt;C:\Program Files\vim\vim81&lt;/code&gt; in the user environment path. I should have noticed that the Vim version was incorrect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that I've solved that mistake I've got the following &lt;code&gt;:version&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:version&#xA;VIM - Vi IMproved 8.1 (2018 May 18, compiled Sep 22 2018 22:02:51)&#xA;MS-Windows 64-bit console version&#xA;Included patches: 1-428&#xA;Compiled by appveyor@APPVYR-WIN&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl                +cryptv             +gettext/dyn        -mouseshape         +scrollbind         +user_commands&#xA;+arabic             +cscope             -hangul_input       +multi_byte_ime/dyn +signs              +vartabs&#xA;+autocmd            +cursorbind         +iconv/dyn          +multi_lang         +smartindent        +vertsplit&#xA;+autochdir          +cursorshape        +insert_expand      +mzscheme/dyn       +startuptime        +virtualedit&#xA;+autoservername     +dialog_con         +job                -netbeans_intg      +statusline         +visual&#xA;-balloon_eval       +diff               +jumplist           +num64              -sun_workshop       +visualextra&#xA;+balloon_eval_term  +digraphs           +keymap             +packages           +syntax             +viminfo&#xA;-browse             -dnd                +lambda             +path_extra         +tag_binary         +vreplace&#xA;++builtin_terms     -ebcdic             +langmap            +perl/dyn           +tag_old_static     +vtp&#xA;+byte_offset        +emacs_tags         +libcall            +persistent_undo    -tag_any_white      +wildignore&#xA;+channel            +eval               +linebreak          -postscript         +tcl/dyn            +wildmenu&#xA;+cindent            +ex_extra           +lispindent         +printer            +termguicolors      +windows&#xA;+clientserver       +extra_search       +listcmds           +profile            +terminal           +writebackup&#xA;+clipboard          +farsi              +localmap           +python/dyn         -tgetent            -xfontset&#xA;+cmdline_compl      +file_in_path       +lua/dyn            +python3/dyn        -termresponse       -xim&#xA;+cmdline_hist       +find_in_path       +menu               +quickfix           +textobjects        -xpm_w32&#xA;+cmdline_info       +float              +mksession          +reltime            +timers             -xterm_save&#xA;+comments           +folding            +modify_fname       +rightleft          +title&#xA;+conceal            -footer             +mouse              +ruby/dyn           -toolbar&#xA;   system vimrc file: &quot;$VIM\vimrc&quot;&#xA;     user vimrc file: &quot;$HOME\_vimrc&quot;&#xA; 2nd user vimrc file: &quot;$HOME\vimfiles\vimrc&quot;&#xA; 3rd user vimrc file: &quot;$VIM\_vimrc&quot;&#xA;      user exrc file: &quot;$HOME\_exrc&quot;&#xA;  2nd user exrc file: &quot;$VIM\_exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME\defaults.vim&quot;&#xA;Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL  -DFEAT_JOB_CHANNEL&#xA;-DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG  /Zl /MT -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_MBYTE -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\&quot;tcl86t.dll\&quot; -DDYNAMIC_TCL_VER=\&quot;8.6\&quot;&#xA;-DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\&quot;lua53.dll\&quot; -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\&quot;python27.dll\&quot; -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\&quot;python37.dll\&quot; -DFEAT_MZSCHEME -I &quot;C:\Program Files\Racket\include&quot; -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\&quot;libracket3m_a36fs8.dll\&quot; -DDYNAMIC_MZGC_DLL=\&quot;libracket3m_a36fs8.dll\&quot; -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\&quot;perl528.dll\&quot; -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=24 -DDYNAMIC_RUBY_DLL=\&quot;x64-msvcrt-ruby240.dll\&quot; -DFEAT_HUGE /Fd.\ObjCULYHTRZAMD64/&#xA;/Zi&#xA;Linking: link  /nologo /subsystem:console,5.02 /opt:ref /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib netapi32.lib uuid.lib /machine:AMD64   libcmt.lib  user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python37.lib   &quot;C:\Tcl\lib\tclstub86.lib&quot; WSock32.lib /PDB:vim.pdb -debug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the magic happens! Running &lt;code&gt;has(&quot;termguicolors&quot;)&lt;/code&gt; returns &lt;code&gt;1&lt;/code&gt;. So &lt;code&gt;set termguicolors&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt; works and suddenly the colours of my &lt;code&gt;:AirlineTheme&lt;/code&gt; convert to the correct colours. If I set &lt;code&gt;:AirlineTheme solarized&lt;/code&gt;, I get AirlineTheme colours that match GVim exactly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sDjIa.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sDjIa.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The disappointment is that the main &lt;code&gt;colorscheme solarized&lt;/code&gt; colours are now ruined, however setting &lt;code&gt;colorscheme default&lt;/code&gt; gets us a reasonable range of colours (this is with solarized set as my console colours). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2Kd9V.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2Kd9V.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I've got &lt;a href=&quot;https://github.com/jacoborus/tender.vim&quot; rel=&quot;noreferrer&quot;&gt;tender&lt;/a&gt; a 24-bit theme for me to test with. Setting &lt;code&gt;colorscheme tender&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; gives some lovely omg-Ive-got-real-proper-syntax-highlighting-in-vim-in-dos colours!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LsZDx.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LsZDx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XpD96.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XpD96.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now testing again with &lt;a href=&quot;http://github.com/guns/xterm-color-table.vim&quot; rel=&quot;noreferrer&quot;&gt;xterm-color-table.vim&lt;/a&gt; gives a lovely range as I'd hoped it would.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5fp7Q.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5fp7Q.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks to the &lt;a href=&quot;https://blogs.msdn.microsoft.com/commandline/2016/09/22/24-bit-color-in-the-windows-console/&quot; rel=&quot;noreferrer&quot;&gt;Windows console team&lt;/a&gt; and the people &lt;a href=&quot;https://github.com/vim/vim/commit/cafafb381a04e33f3ce9cd15dd9f94b73226831f&quot; rel=&quot;noreferrer&quot;&gt;doing the work to get this into Vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Using the &lt;a href=&quot;https://github.com/lifepillar/vim-solarized8&quot; rel=&quot;noreferrer&quot;&gt;vim-solarized8 theme&lt;/a&gt; which is optimised for 24-bit terminals I now have full glorious solarized too:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/R3DQS.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/R3DQS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11986" LastEditorUserId="11986" LastEditDate="2018-10-11T07:08:11.233" LastActivityDate="2018-10-11T07:08:11.233" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17589" PostTypeId="2" ParentId="17582" CreationDate="2018-10-07T23:16:05.873" Score="1" Body="&lt;p&gt;I'm having a little trouble following your use case but based on reference to buffers and the viminfo file it seems that you must be talking about the &quot;Buffer list&quot; section of viminfo. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can tell Vim to not save that particular set of data but otherwise continue saving the rest of the data as before by altering the &lt;code&gt;'viminfo'&lt;/code&gt; setting. In particular, if you exclude the character &lt;code&gt;%&lt;/code&gt; from the value list the Buffer list section will go away. An easy way to do it: &lt;code&gt;:set viminfo-=%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Weird thing is that saving that Buffer list section is not default behavior. Are you sure it isn't being set in a vimrc file or plugin or something? If it is then just edit the line and remove the &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and if I guessed wrong and you're talking about a different section of viminfo then just go to &lt;code&gt;:h 'viminfo'&lt;/code&gt; and find the proper symbol to set/update/remove as prescribed.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-10-07T23:16:05.873" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="17590" PostTypeId="1" CreationDate="2018-10-08T10:52:20.460" Score="5" ViewCount="1162" Body="&lt;p&gt;I'm wondering if it is possible to check in vimscript if a key (or key combination) is already bound?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know about the &lt;code&gt;:map&lt;/code&gt; command which lets me see visually which keys are bound to what actions, but what I am looking for is a way to check it programmatically and perform actions conditionally.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My concrete scenario is the following: I like the the possibility to dynamically/manually map &lt;code&gt;&amp;lt;leader&amp;gt;&amp;lt;leader&amp;gt;&lt;/code&gt; to what I need in different cases. (eg. while programming python: run the script. Or compile while programming c++). I usually do it by typing &lt;code&gt;:nmap &amp;lt;leader&amp;gt;&amp;lt;leader&amp;gt; :!make &amp;amp;&amp;amp; run program&lt;/code&gt; manually while editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to check in my &lt;code&gt;.vimrc&lt;/code&gt; if the combination is already bound (by a plugin, or manually) and if not map it to a default action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short words: How can I map a key only if it is not already bound?&lt;/p&gt;&#xA;" OwnerUserId="19019" LastActivityDate="2018-10-08T16:37:57.320" Title="Check if key is already bound in vimscript / Map key only if not mapped already" Tags="|vimrc|key-bindings|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17591" PostTypeId="2" ParentId="17566" CreationDate="2018-10-08T12:04:03.810" Score="2" Body="&lt;p&gt;This is working for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;&quot; Similar to the goto command, but for characters.&#xA;&quot; index is 1-based, the start of the file.&#xA;function! GotoCharacter(index)&#xA;  call search('\m\%^\_.\{'.a:index.'}', 'es')&#xA;&#xA;  &quot; The search() function above counts a newline as 1 character even if it is&#xA;  &quot; actually 2.  Therefore adjust the cursor position when newlines are&#xA;  &quot; 2 characters.&#xA;  if &amp;ff ==# 'dos'&#xA;    let [_whichwrap, &amp;whichwrap] = [&amp;whichwrap, &quot;h,l&quot;]&#xA;    let delta = wordcount().cursor_chars - a:index&#xA;    while delta != 0&#xA;      &quot; Cannot land on a newline character.&#xA;      if (delta == -1 || delta == -2) &amp;&amp; col('.') == col('$') - 1&#xA;        break&#xA;      endif&#xA;      execute &quot;normal! &quot;.delta.(delta &gt; 0 ? 'h' : 'l')&#xA;      let delta = wordcount().cursor_chars - a:index&#xA;    endwhile&#xA;    let &amp;whichwrap = _whichwrap&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2018-10-08T12:04:03.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17592" PostTypeId="2" ParentId="17590" CreationDate="2018-10-08T16:37:57.320" Score="8" Body="&lt;p&gt;You've got:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#maparg%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h maparg()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#mapcheck%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h mapcheck()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;that, respectively permit to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;get the exact mapping bound to the exact keybinding passed as parameter&lt;/li&gt;&#xA;&lt;li&gt;check whether there is any mapping bound to a keybinding starting as the parameter&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On the other way around (get which keybinding could be bound to an action), so far I've only found the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! lh#mapping#who_maps(rhs, mode) abort&#xA;  &quot; lh#askvim#execute  =~ split(execute(...), &quot;\n&quot;)&#xA;  let maps = filter(lh#askvim#execute(a:mode . 'map'), 'v:val =~ a:rhs.&quot;$&quot;')&#xA;  &quot; Unfortunatelly, knowing exactly what mapping is associated to a&#xA;  &quot; keybinding, it's best to use maparg()&#xA;  let lhs_list = map(maps, 'split(v:val)[1]')&#xA;  let mappings = map(lhs_list, 'maparg(v:val, a:mode, 0, 1)')&#xA;  call filter(mappings, 'v:val.rhs == a:rhs')&#xA;  return mappings&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-10-08T16:37:57.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17593" PostTypeId="1" CreationDate="2018-10-08T22:43:10.390" Score="2" ViewCount="345" Body="&lt;p&gt;Let's say I have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Foo BAR Baz   Quxxx     Foo&#xA;Baar Asd      Duxxxxx   Bar Foo&#xA;Baazzz        Kuxx      Baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would ideally like to be to highlight the first, second, or third column. Then I would like to able to quote them such that they're like this,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'Foo BAR Baz'   'Quxxx'     'Foo'&#xA;'Baar Asd'      'Duxxxxx'   'Bar Foo'&#xA;'Baazzz'        'Kuxx'      'Baz'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the easiest way to do that. I've asked this question before but none of those solutions covered these kinds of use cases,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can't skip over by using &lt;code&gt;W&lt;/code&gt;, because the first column may have more than one &lt;code&gt;WORD&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;I would like the &lt;code&gt;WORD&lt;/code&gt; to be delimited by the last non-whitespace character highlighted on the line in block mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Ideally this would work in visual mode.&lt;/p&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="5078" LastEditDate="2018-10-08T23:26:36.407" LastActivityDate="2018-10-09T18:30:02.867" Title="Quoting blocks but ignoring whitespace" Tags="|visual-mode|plugin-vim-surround|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17594" PostTypeId="2" ParentId="17593" CreationDate="2018-10-08T23:37:34.757" Score="2" Body="&lt;p&gt;This answer is based on the &lt;a href=&quot;https://github.com/vim-scripts/vis&quot; rel=&quot;nofollow noreferrer&quot;&gt;vis&lt;/a&gt; plugin. That plugin provides the ability to run ex commands on just the visually-selected text. In this case, it can be used to execute a substitute command on just the selected column of text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First visually select the column to be quoted. That is, move the cursor to the upper-left corner of the column, type &lt;code&gt;Ctrl-V&lt;/code&gt;, then move the cursor to the lower-right corner of the column (don't worry about whitespace preceding or trailing the text). Then type the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;B s/\(\s*\)\(\S.*\S\|\S\)\(\s*\)/\1'\2'\3/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;B&lt;/code&gt; command executes the ex command that follows it on the visually-selected block. The substitute command finds three patterns: leading whitespace, one or more words, and trailing whitespace. It replaces the matching text with the leading whitespace, a single quote, the matched words, another single quote, and the trailing whitespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a bug in this answer, but I'm going to leave it anyway. Maybe someone else can fix it or maybe the solution will come to me later. The replacement tokens &lt;code&gt;\1&lt;/code&gt; and &lt;code&gt;\3&lt;/code&gt; insert an additional space. The cleanup required is minor, but it's still annoying. I was using gvim 8.1.351 on Windows and vis v20.&lt;/p&gt;&#xA;" OwnerUserId="2055" LastEditorUserId="2055" LastEditDate="2018-10-09T18:30:02.867" LastActivityDate="2018-10-09T18:30:02.867" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17596" PostTypeId="2" ParentId="11426" CreationDate="2018-10-09T04:14:37.350" Score="2" Body="&lt;p&gt;Some related posts are posted &lt;a href=&quot;https://github.com/scrooloose/nerdtree/issues/400&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://github.com/vim-airline/vim-airline/issues/460&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. Basically if you use &lt;code&gt;bd&lt;/code&gt;, vim will close the window the current buffer is in, causing Nerdtree window to take the whole screen. The simple mapping below prevent the window from closing after using &lt;code&gt;bd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap \d :bp&amp;lt;cr&amp;gt;:bd #&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Feel free to change the mapped key as you wish.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastEditorUserId="1841" LastEditDate="2018-10-09T08:06:04.083" LastActivityDate="2018-10-09T08:06:04.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17597" PostTypeId="2" ParentId="17593" CreationDate="2018-10-09T08:20:34.683" Score="2" Body="&lt;p&gt;Your question is pretty hard to answer in a meaningful way because it is a very specific use case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can be sure that the different columns are separated by more than one white space (like in your example) you could use the following substitution commands:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First use &lt;code&gt;:%s/\s\{2,}/'&amp;amp;'/g&lt;/code&gt; to surround every string of two or more white spaces with quotes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Foo BAR Baz'   'Quxxx'     'Foo&#xA;Baar Asd'      'Duxxxxx'   'Bar Foo&#xA;Baazzz'        'Kuxx'      'Baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then with &lt;code&gt;:%s/^\|$/'/g&lt;/code&gt; add a quote at the beginning and at the end of the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'Foo BAR Baz'   'Quxxx'     'Foo'&#xA;'Baar Asd'      'Duxxxxx'   'Bar Foo'&#xA;'Baazzz'        'Kuxx'      'Baz'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-10-09T08:20:34.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17598" PostTypeId="1" CreationDate="2018-10-09T12:01:00.047" Score="1" ViewCount="263" Body="&lt;p&gt;I'm using vim for my matlab editor. And It works nicely, except I cannot get folding to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found my syntax file on github: &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/syntax/matlab.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;matlab.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I wanted to add folding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I changed the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region matlabMultilineComment   start=+%{+ end=+%}+ contains=matlabTodo,matlabTab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region matlabMultilineComment   start=+%{+ end=+%}+ fold contains=matlabTodo,matlabTab &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this works, &lt;code&gt;zm&lt;/code&gt; now folds multiline comments!. So now I wanted to add folding for blocks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting on:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;if&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;for&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;switch&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;while&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;ending on:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;end&lt;/code&gt;&#xA;and also between &lt;code&gt;%%&lt;/code&gt; and &lt;code&gt;%%&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So I went from having&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword matlabLabel         case switch&#xA;syn keyword matlabConditional       else elseif end if otherwise&#xA;syn keyword matlabRepeat        do for while&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword matlabLabel         case switch&#xA;syn keyword matlabConditional       else elseif if otherwise&#xA;syn keyword matlabEnd           end&#xA;syn keyword matlabRepeat        do for while&#xA;syn region matlabSection &#xA;            \start=+%%+ &#xA;            \end=+%%+ &#xA;            \fold &#xA;syn region matlabIfBlock        &#xA;            \matchgroup=matlabConditional &#xA;            \start=&quot;if&quot; &#xA;            \end=&quot;end&quot; &#xA;            \transparent &#xA;            \fold &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This however, does not fold neither my if statement, nor my &lt;code&gt;%%&lt;/code&gt; section (my &lt;code&gt;%{&lt;/code&gt; &lt;code&gt;%}&lt;/code&gt; multiline comment is folding nicely)&lt;/p&gt;&#xA;" OwnerUserId="15685" LastEditorUserId="15685" LastEditDate="2018-10-09T12:22:26.607" LastActivityDate="2021-08-24T21:04:20.503" Title="folding in matlab" Tags="|folding|matlab|keyword|syntax|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17599" PostTypeId="2" ParentId="17593" CreationDate="2018-10-09T12:45:23.773" Score="4" Body="&lt;p&gt;The single substitution command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\S\+\( \S\+\)*/'&amp;amp;'/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works under the assumptions&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;different columns are separated by &lt;strong&gt;more than one white space&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;only a &lt;strong&gt;single space&lt;/strong&gt; separates words within cells.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It changes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Foo BAR Baz   Quxxx     Foo&#xA;Baar Asd      Duxxxxx   Bar Foo&#xA;Baazzz        Kuxx      Baz&#xA;Baazzz        K         Baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'Foo BAR Baz'   'Quxxx'     'Foo'&#xA;'Baar Asd'      'Duxxxxx'   'Bar Foo'&#xA;'Baazzz'        'Kuxx'      'Baz'&#xA;'Baazzz'        'K'         'Baz'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2018-10-09T12:45:23.773" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17600" PostTypeId="2" ParentId="17598" CreationDate="2018-10-09T13:08:36.010" Score="1" Body="&lt;p&gt;This answer is not complete, but might help:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;coolword&lt;/code&gt; in &lt;code&gt;start=&quot;coolword&quot;&lt;/code&gt; apparently cannot be a &lt;code&gt;keyword&lt;/code&gt; to ommit this use the &lt;code&gt;matchgroup&lt;/code&gt; ability, to mark the start word as a certain group. The endword can however be a keyword.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, ensure to use the &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; flags as described here: &lt;a href=&quot;https://vi.stackexchange.com/questions/5418/syntax-file-keywords-within-context&quot;&gt;Syntax file: keywords within context&lt;/a&gt;&#xA;Such that the words will not be taken out of context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword matlabLabel         case&#xA;syn keyword matlabConditional       else elseif  otherwise&#xA;syn keyword matlabRepeat        do&#xA;syn keyword matlabFunction      error eval &#xA;syn region matlabSection&#xA;            \ start=&quot;%%&quot;&#xA;            \ end=&quot;%%&quot;&#xA;            \ fold&#xA;syn region matlabIfBlock&#xA;            \ matchgroup=matlabConditional&#xA;            \ start=&quot;\&amp;lt;if\&amp;gt;&quot;&#xA;            \ end=&quot;\&amp;lt;end\&amp;gt;&quot;&#xA;            \ transparent&#xA;            \ fold&#xA;syn region matlabForLoop&#xA;            \ matchgroup=matlabRepeat&#xA;            \ start=&quot;\&amp;lt;for\&amp;gt;&quot;&#xA;            \ end=&quot;\&amp;lt;end\&amp;gt;&quot;&#xA;            \ transparent&#xA;            \ fold&#xA;syn region matlabForLoop&#xA;            \ matchgroup=matlabRepeat&#xA;            \ start=&quot;\&amp;lt;while\&amp;gt;&quot;&#xA;            \ end=&quot;\&amp;lt;end\&amp;gt;&quot;&#xA;            \ transparent&#xA;            \ fold&#xA;syn region matlabForLoop&#xA;            \ matchgroup=matlabRepeat&#xA;            \ start=&quot;\&amp;lt;parfor\&amp;gt;&quot;&#xA;            \ end=&quot;\&amp;lt;end\&amp;gt;&quot;&#xA;            \ transparent&#xA;            \ fold&#xA;&#xA;syn region matlabSwitch&#xA;            \ matchgroup=matlabLabel&#xA;            \ start=&quot;\&amp;lt;switch\&amp;gt;&quot;&#xA;            \ end=&quot;\&amp;lt;end\&amp;gt;&quot;&#xA;            \ transparent&#xA;            \ fold&#xA;syn region matlabFunctionBlock&#xA;            \ matchgroup=matlabFunction&#xA;            \ start=&quot;\&amp;lt;function\&amp;gt;&quot;&#xA;            \ end=&quot;\&amp;lt;end\&amp;gt;&quot;&#xA;            \ transparent&#xA;            \ fold&#xA;&quot;syn match matlabCellComment     &quot;^.*$&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the last line is commented out. It used to include &lt;code&gt;%%&lt;/code&gt; and thus make the folding of &lt;code&gt;%%&lt;/code&gt; sections impossible (And I'm too much of a vim noob to know what letting the remains be would do, so I eradicated it).&lt;/p&gt;&#xA;" OwnerUserId="15685" LastActivityDate="2018-10-09T13:08:36.010" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17601" PostTypeId="1" CreationDate="2018-10-09T14:15:21.570" Score="2" ViewCount="250" Body="&lt;p&gt;For a longer running vim session, the number of buffers increases. However, often &lt;code&gt;$VIMRUNTIME&lt;/code&gt; files, system files and netrw buffers can usually be closed with “closed” eyes. These are typically read-only. Currently, I close once in a while vim and reopen the interesting files via &lt;code&gt;CtrlPMRU&lt;/code&gt; (configured to ignore many files as those just mentioned). This seems to be a suboptimal workflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found following question with a good answer on stackoverflow on how to close multiple buffers in a single step:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/q/3155461/how-to-delete-multiple-buffers-in-vim&quot;&gt;https://stackoverflow.com/q/3155461/how-to-delete-multiple-buffers-in-vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you have to come up with a globbing expression to select the ones you wish to close. In my case I want to close all read-only buffers which cannot be adressed this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to close read-only buffers conveniently?&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-10-09T14:21:23.287" LastActivityDate="2018-10-09T21:59:30.923" Title="How can I conveniently close all read-only buffers?" Tags="|command-line|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17602" PostTypeId="1" CreationDate="2018-10-09T19:10:59.490" Score="1" ViewCount="279" Body="&lt;p&gt;I just finished reading &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt;, and I am working right now with neovim&#xA;And I had a bulky config file with a lot of stuff, that really slowed down vim, when I was handling &lt;em&gt;heavy&lt;/em&gt; searches, or dealing with &lt;em&gt;long&lt;/em&gt; files, and now I switched to Neovim, and the same config, flys which is cool. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I wanted to put my configs into separate plugins for my self, and also expand my functionality with some plugins written in Python. But I haven't found any concrete hint (or at least to my understanding) that &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pathogen works well on Neovim?&lt;/li&gt;&#xA;&lt;li&gt;It keeps in different threads all the processes, so It won't hit performance having external plugins? &lt;/li&gt;&#xA;&lt;li&gt;I don't understand the excitement about Plugs, should I consider it?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I like pathogen because It as simple as it can get, and It's not intrusive in your config files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anyone help me out, or point me in the right direction with this? &lt;/p&gt;&#xA;" OwnerUserId="19307" LastActivityDate="2018-10-09T19:10:59.490" Title="Using pathogen, will allow me to exploit neovim capabilities when developing a plugin?" Tags="|neovim|plugin-pathogen|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17603" PostTypeId="2" ParentId="17601" CreationDate="2018-10-09T21:26:01.983" Score="6" Body="&lt;p&gt;This command should output the number of the last buffer in the buffer list (see &lt;code&gt;:h bufnr()&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo bufnr('$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This command should output the range of buffer numbers, from the first one to the last one (see &lt;code&gt;:h range()&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo range(1, bufnr('$'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This command should output the &lt;code&gt;'readonly'&lt;/code&gt; option of the buffer &lt;code&gt;123&lt;/code&gt; (see &lt;code&gt;:h getbufvar()&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo getbufvar(123, '&amp;amp;l:ro')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This command should remove from the list of buffer numbers &lt;code&gt;[1,2,3,4,5]&lt;/code&gt;, the ones whose &lt;code&gt;'readonly'&lt;/code&gt; option is unset (see &lt;code&gt;:h filter()&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo filter([1,2,3,4,5], {i,v -&amp;gt; getbufvar(v, '&amp;amp;l:ro') == 1})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This command should output the whole range of buffer numbers, whose &lt;code&gt;'readonly'&lt;/code&gt; option is set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo filter(range(1, bufnr('$')), {i,v -&amp;gt; getbufvar(v, '&amp;amp;l:ro') == 1})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could join the numbers of the last command, and pass them to &lt;code&gt;:bd&lt;/code&gt; (see &lt;code&gt;:h :exe&lt;/code&gt; and &lt;code&gt;:h join()&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 'bd '.join(filter(range(1, bufnr('$')), {i,v -&amp;gt; getbufvar(v, '&amp;amp;l:ro') == 1}))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And to make this simpler to execute, you could install a custom &lt;code&gt;:BdReadOnly&lt;/code&gt; command (see &lt;code&gt;:h :com&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! -bar  BdReadOnly  exe 'bd '.join(filter(range(1, bufnr('$')), {i,v -&amp;gt; getbufvar(v, '&amp;amp;l:ro') == 1}))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There may be “holes” in the range. That is, some index may have been used in the past for a buffer, but the latter may have been deleted since then. In this case, the index is not re-used for another buffer.&#xA;For such non-existing buffer, &lt;code&gt;getbufvar()&lt;/code&gt; should then return an empty string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo getbufvar(999999999, '&amp;amp;l:ro') is# ''&#xA;    → 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, the previous test in the lambda expression should fail:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getbufvar(v, '&amp;amp;l:ro') == 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And, I think, the index should be correctly filtered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if the buffers which are deleted are not exactly the ones you want, you may need to tweak the condition &lt;code&gt;getbufvar(v, '&amp;amp;l:ro') == 1&lt;/code&gt; in the lambda expression, and build a more complex one.&lt;br&gt;&#xA;In this case, you could be interested in some other functions (see &lt;code&gt;:h buffer-functions&lt;/code&gt;).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To name a few:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;bufexists(123)&lt;/code&gt; will tell you whether the buffer &lt;code&gt;123&lt;/code&gt; exists&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;buflisted(123)&lt;/code&gt; will tell you whether the buffer &lt;code&gt;123&lt;/code&gt; is currently listed&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;bufname(123)&lt;/code&gt; will give you the name of the buffer &lt;code&gt;123&lt;/code&gt;, and &lt;code&gt;empty(bufname(123))&lt;/code&gt; will test whether it has one in the first place&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;win_findbuf(123)&lt;/code&gt; will tell you in which window(s) the buffer &lt;code&gt;123&lt;/code&gt; is being displayed, and &lt;code&gt;empty(win_findbuf(123))&lt;/code&gt; will tell you whether it is displayed anywhere in the first place&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-10-09T21:59:30.923" LastActivityDate="2018-10-09T21:59:30.923" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17604" PostTypeId="1" CreationDate="2018-10-10T11:24:40.963" Score="2" ViewCount="72" Body="&lt;p&gt;Consider the text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A&#xA;B&#xA;# C&#xA;# D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a text object or motion that will select lines A and B if the cursor is on either, but not select lines C and D?  &lt;code&gt;ap&lt;/code&gt; or &lt;code&gt;ip&lt;/code&gt; with the cursor on any of those four lines will select all four, since there is not a blank line between C and D.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use case: git commit messages.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Added glob tests; bugfix in fnmatch&#xA;&#xA;Run `CTEST_OUTPUT_ON_FAILURE=1 ctest .` to see the inputs for glob tests&#xA;that fail.&#xA;# Please enter the commit message for your changes. Lines starting&#xA;# with '#' will be ignored, and an empty message aborts the commit.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I put the cursor on the &lt;code&gt;Run...&lt;/code&gt; line and wrap it with &lt;code&gt;gqap&lt;/code&gt;, all of the &lt;code&gt;#...&lt;/code&gt; comment lines get wrapped in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Run `CTEST_OUTPUT_ON_FAILURE=1 ctest .` to see the inputs for glob tests&#xA;that fail.  # Please enter the commit message for your changes. Lines&#xA;starting # with '#' will be ignored, and an empty message aborts the&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like &lt;code&gt;gq&amp;lt;something&amp;gt;&lt;/code&gt; to select only the non-&lt;code&gt;#&lt;/code&gt; lines and wrap them.  The only workaround I can think of so far is &lt;code&gt;v/^#&amp;lt;CR&amp;gt;jgq&lt;/code&gt;, which seems rather tedious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another use case:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Being able to distinguish comment lines from non-comment lines would also help me select Doxygen comments before functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/// Comment here                      A&#xA;/// More comment here                 B&#xA;void do_something_interesting() {     C&#xA;}                                     D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Same deal: I'd like to be able to select A+B without C+D or vice versa.&lt;/p&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="1292" LastEditDate="2019-01-24T13:05:20.987" LastActivityDate="2019-01-24T13:05:20.987" Title="Is there a text object or motion for non-comment lines are not separated from comment lines by blank lines? E.g., in git commit messages" Tags="|cut-copy-paste|visual-mode|cursor-motions|object-motions|custom-text-object|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17605" PostTypeId="1" AcceptedAnswerId="17610" CreationDate="2018-10-10T16:30:14.497" Score="1" ViewCount="123" Body="&lt;p&gt;I'm trying to create a function to make editing TSV files easier. The function changes spacing settings, turns off wrapping, and creates a 1 row tall split at the top so that the column headers are always visible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I'm having trouble getting the two windows to bind on horizontal scroll. I can get them to bind when executing the commands manually but it doesn't work when I call the function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! TSV()&#xA;  execute &quot;setlocal nowrap&quot;&#xA;  execute &quot;setlocal noexpandtab&quot;&#xA;  execute &quot;setlocal shiftwidth=20&quot;&#xA;  execute &quot;setlocal softtabstop=20&quot;&#xA;  execute &quot;setlocal tabstop=20&quot;&#xA;  &quot; always visible header&#xA;  execute &quot;sp&quot;&#xA;  execute &quot;0&quot;&#xA;  call feedkeys(&quot;\&amp;lt;C-W&amp;gt;K&quot;)&#xA;  call feedkeys(&quot;1\&amp;lt;C-W&amp;gt;_&quot;)&#xA;  call feedkeys(&quot;\&amp;lt;C-W&amp;gt;j&quot;)&#xA;  &quot; bind horizontal scrolling&#xA;  execute &quot;set scrollopt=hor&quot;&#xA;  execute &quot;set scrollbind&quot;&#xA;  call feedkeys(&quot;\&amp;lt;C-W&amp;gt;k&quot;)&#xA;  execute &quot;set scrollbind&quot;&#xA;  call feedkeys(&quot;\&amp;lt;C-W&amp;gt;j&quot;)&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13896" LastActivityDate="2018-10-11T00:01:08.653" Title="Binding horizontal scroll in a function with feedkeys" Tags="|vim-windows|functions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17606" PostTypeId="1" AcceptedAnswerId="17608" CreationDate="2018-10-10T21:47:19.937" Score="8" ViewCount="3569" Body="&lt;p&gt;I'm trying to write a simple function that wraps a visual selection of lines with Markdown &lt;kbd&gt;```&lt;/kbd&gt; lines. Here's what I currently have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MarkCodeBlock()&#xA;    &quot; Add Markdown code-block delimiters to begin and end of current visual group.&#xA;    execute &quot;normal! `&amp;lt;O```\&amp;lt;esc&amp;gt;yy`&amp;gt;p&quot;&#xA;endfunction&#xA;&#xA;vnoremap &amp;lt;leader&amp;gt;_ :call MarkCodeBlock()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It &lt;em&gt;mostly&lt;/em&gt; works, but it appears to invoke &lt;code&gt;MarkCodeBlock()&lt;/code&gt; once for each line in the visual selection. As an example, suppose I have the following block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is not a code line&#xA;This is a code line&#xA;This is a code line&#xA;This is a code line&#xA;This is not a code line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the middle three lines are visually selected. On invoking the map sequence, I end up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is not a code line&#xA;```&#xA;```&#xA;```&#xA;This is a code line&#xA;This is a code line&#xA;This is a code line&#xA;```&#xA;```&#xA;```&#xA;This is not a code line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I want this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is not a code line&#xA;```&#xA;This is a code line&#xA;This is a code line&#xA;This is a code line&#xA;```&#xA;This is not a code line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="19075" LastActivityDate="2020-03-27T12:31:45.253" Title="vmap and visual block: how do I write a function to operate once for the entire block?" Tags="|vimscript|visual-block|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17607" PostTypeId="2" ParentId="17580" CreationDate="2018-10-10T22:44:07.037" Score="1" Body="&lt;p&gt;This is an &lt;code&gt;aspell&lt;/code&gt; problem; not a &lt;code&gt;vim&lt;/code&gt; problem.  &lt;code&gt;aspell&lt;/code&gt; itself has these deficiencies.  You need simply to add the missing ordinal numbers to the dictionary.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo &quot;1st 21st 31st 5th 25th 35th&quot; | aspell -a&#xA;@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.7-20110707)&#xA;*&#xA;*&#xA;*&#xA;&amp;amp; th 50 15: Th, Thu, the, tho, thy, THC, Rh, HT, ht, H, T, h, t, nth, Ch, OH, TA, Ta, Te, Ti, Tu, Ty, ah, ch, eh, oh, pH, sh, ta, ti, to, uh, DH, NH, TB, TD, TM, TN, TV, TX, Tb, Tc, Tl, Tm, tb, tn, tr, ts, Th's, T's&#xA;&amp;amp; th 50 20: Th, Thu, the, tho, thy, THC, Rh, HT, ht, H, T, h, t, nth, Ch, OH, TA, Ta, Te, Ti, Tu, Ty, ah, ch, eh, oh, pH, sh, ta, ti, to, uh, DH, NH, TB, TD, TM, TN, TV, TX, Tb, Tc, Tl, Tm, tb, tn, tr, ts, Th's, T's&#xA;&amp;amp; th 50 25: Th, Thu, the, tho, thy, THC, Rh, HT, ht, H, T, h, t, nth, Ch, OH, TA, Ta, Te, Ti, Tu, Ty, ah, ch, eh, oh, pH, sh, ta, ti, to, uh, DH, NH, TB, TD, TM, TN, TV, TX, Tb, Tc, Tl, Tm, tb, tn, tr, ts, Th's, T's&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5284" LastActivityDate="2018-10-10T22:44:07.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17608" PostTypeId="2" ParentId="17606" CreationDate="2018-10-10T22:44:07.313" Score="20" Body="&lt;p&gt;When you press &lt;code&gt;leader _&lt;/code&gt;, you enter command-line mode from visual mode.&lt;br&gt;&#xA;If you try to enter command-line mode from visual mode manually, you'll see that Vim automatically inserts this range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;&#xA; ├┘ ├┘&#xA; │  └ mark put automatically on the last line of the visual selection&#xA; └ mark put automatically on the first line of the visual selection (see `:h '&amp;lt;`)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, when &lt;code&gt;:call&lt;/code&gt; calls your &lt;code&gt;MarkCodeBlock()&lt;/code&gt; function, Vim has automatically prefixed it with a range.&lt;br&gt;&#xA;And, from &lt;code&gt;:h func-range&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If &lt;code&gt;[range]&lt;/code&gt; is excluded, &quot;:{range}call&quot; will call the function for each line in&#xA;  the range, with the cursor on the start of each line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Because of this, your function is called once for every line in the range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have 2 possibilities:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Eliminate the range by making your mapping press &lt;code&gt;C-u&lt;/code&gt; (see &lt;code&gt;:h c^u&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;leader&amp;gt;_ :&amp;lt;c-u&amp;gt;call MarkCodeBlock()&amp;lt;CR&amp;gt;&#xA;                    ^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Make Vim know that the function can handle the range itself and doesn't need &lt;code&gt;:call&lt;/code&gt; to re-invoke it for every  line in the range. You can do so by passing the &lt;code&gt;range&lt;/code&gt; argument to &lt;code&gt;:function&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MarkCodeBlock() range&#xA;                          ^^^^^&#xA;    ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A few possible improvements/suggestions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:vnoremap&lt;/code&gt; is applied in 2 modes: visual and select.&lt;br&gt;&#xA;But you're probably interested only in visual mode, because (from &lt;code&gt;:h mapmode-s&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;NOTE: Mapping a printable character in Select mode may confuse the user.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And the &lt;code&gt;lhs&lt;/code&gt; of your mapping contains printable characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want your mapping to be applied only in visual mode, use &lt;code&gt;:xnoremap&lt;/code&gt; instead of &lt;code&gt;:vnoremap&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;leader&amp;gt;_ :&amp;lt;c-u&amp;gt;call MarkCodeBlock()&amp;lt;CR&amp;gt;&#xA;^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If your &lt;code&gt;leader&lt;/code&gt; namespace becomes too crowded, and you need to offload some of the mappings to another namespace, you could use &lt;code&gt;m&lt;/code&gt; in visual mode. A &lt;code&gt;m&amp;lt;key&amp;gt;&lt;/code&gt; mapping won't shadow any Vim's built-in command, since you can't put a mark in visual mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap m_ :&amp;lt;c-u&amp;gt;call MarkCodeBlock()&amp;lt;CR&amp;gt;&#xA;         ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your &lt;code&gt;MarkCodeBlock()&lt;/code&gt; function is public, which means that its definition could collide with another public function with the same name. You could make it “private” (local to the script) by prefixing its name with &lt;code&gt;s:&lt;/code&gt; in your definition, and with &lt;code&gt;&amp;lt;sid&amp;gt;&lt;/code&gt; in your mapping. From &lt;code&gt;:h &amp;lt;sid&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When defining a function in a script, &quot;s:&quot; can be prepended to the name to&#xA;  make it local to the script.  But when a mapping is executed from outside of&#xA;  the script, it doesn't know in which script the function was defined.  To&#xA;  avoid this problem, use &quot;&lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt;&quot; instead of &quot;s:&quot;.  The same translation is done&#xA;  as for mappings.  This makes it possible to define a call to the function in&#xA;  a mapping.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap m_ :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;MarkCodeBlock()&amp;lt;CR&amp;gt;&#xA;                       ^^^^^&#xA;&#xA;function! s:MarkCodeBlock()&#xA;          ^^&#xA;    ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If an error is raised while the statements in your function are being executed, you may want Vim to stop executing the next ones (this gives shorter stack traces). In this case, you can pass the &lt;code&gt;abort&lt;/code&gt; argument to &lt;code&gt;:function&lt;/code&gt; (see &lt;code&gt;:h :func-abort&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:MarkCodeBlock() abort&#xA;                            ^^^^^&#xA;    ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Instead of using &lt;code&gt;:normal&lt;/code&gt; to add lines in your buffer, you could use &lt;code&gt;append()&lt;/code&gt; (and &lt;code&gt;line()&lt;/code&gt;; see &lt;code&gt;:h append()&lt;/code&gt; and &lt;code&gt;:h line()&lt;/code&gt;). In general, the latter has the benefit of not making the cursor move.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal! `&amp;lt;O```\&amp;lt;esc&amp;gt;yy`&amp;gt;p&quot;&#xA;&#xA;⇔&#xA;&#xA;call append(line(&quot;'&amp;lt;&quot;)-1, '```')&#xA;call append(line(&quot;'&amp;gt;&quot;), '```')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your Vim version includes the patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.0037&quot; rel=&quot;noreferrer&quot;&gt;8.1.0037&lt;/a&gt;, you can do the same to any buffer, not just the current one, using the &lt;code&gt;appendbufline()&lt;/code&gt; function instead of &lt;code&gt;append()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;All in all, this would give:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:MarkCodeBlock() abort&#xA;    &quot; Add Markdown code-block delimiters to begin and end of current visual group.&#xA;    call append(line(&quot;'&amp;lt;&quot;)-1, '```')&#xA;    call append(line(&quot;'&amp;gt;&quot;), '```')&#xA;endfunction&#xA;xnoremap m_ :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;MarkCodeBlock()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="7747" LastEditDate="2020-03-27T12:31:45.253" LastActivityDate="2020-03-27T12:31:45.253" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17609" PostTypeId="1" CreationDate="2018-10-10T23:14:48.760" Score="2" ViewCount="406" Body="&lt;p&gt;This works fine in vim 8:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CursorHoldI * stopinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After about 5 seconds or so of inactivity in insert mode it automatically returns to normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in neovim I use the deoplete autocompletion plugin, which is great... except it stops this from working. Any way to have my cake and eat it too?&lt;/p&gt;&#xA;" OwnerUserId="14048" LastEditorUserId="14048" LastEditDate="2018-10-12T14:38:49.833" LastActivityDate="2018-10-12T14:38:49.833" Title="How do I get neovim to automatically return to normal mode when idle?" Tags="|neovim|plugin-deoplete|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17610" PostTypeId="2" ParentId="17605" CreationDate="2018-10-10T23:23:15.770" Score="3" Body="&lt;p&gt;I think that your &lt;code&gt;feedkeys()&lt;/code&gt; invocations write keys in the typeahead buffer, but they're not pressed immediately. Vim probably waits for the whole mapping and the function it calls to be processed.&lt;br&gt;&#xA;You can tell &lt;code&gt;feedkeys()&lt;/code&gt; to make Vim press the keys immediately by passing it the &lt;code&gt;x&lt;/code&gt; flag (see &lt;code&gt;:h feedkeys()&lt;/code&gt;).&#xA;You may also want to pass the &lt;code&gt;n&lt;/code&gt; flag to prevent custom mapping from interfering:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, instead of writing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call feedkeys(&quot;\&amp;lt;C-W&amp;gt;K&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call feedkeys(&quot;\&amp;lt;C-W&amp;gt;K&quot;, 'nx')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But usually, to execute commands which affect windows, you use &lt;code&gt;:wincmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call feedkeys(&quot;\&amp;lt;C-W&amp;gt;K&quot;, 'nx')&#xA;→&#xA;wincmd K&#xA;&#xA;call feedkeys(&quot;1\&amp;lt;C-W&amp;gt;_&quot;, 'nx')&#xA;→&#xA;1wincmd _&#xA;&#xA;call feedkeys(&quot;\&amp;lt;C-W&amp;gt;j&quot;, 'nx')&#xA;→&#xA;wincmd j&#xA;&#xA;call feedkeys(&quot;\&amp;lt;C-W&amp;gt;k&quot;, 'nx')&#xA;→&#xA;wincmd k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, you could try this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! TSV()&#xA;    setlocal nowrap&#xA;    setlocal noexpandtab&#xA;    setlocal shiftwidth=20&#xA;    setlocal softtabstop=20&#xA;    setlocal tabstop=20&#xA;    &quot; always visible header&#xA;    sp&#xA;    0&#xA;    wincmd K&#xA;    1wincmd _&#xA;    wincmd j&#xA;    &quot; bind horizontal scrolling&#xA;    set scrollopt=hor&#xA;    set scrollbind&#xA;    wincmd k&#xA;    set scrollbind&#xA;    wincmd j&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-10-11T00:01:08.653" LastActivityDate="2018-10-11T00:01:08.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17611" PostTypeId="2" ParentId="17604" CreationDate="2018-10-11T07:09:10.480" Score="3" Body="&lt;h2&gt;Define syntax match &lt;code&gt;gitcommitBody&lt;/code&gt; for the custom text object &lt;em&gt;syntax&lt;/em&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Install &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-user&lt;/a&gt; and &lt;a href=&quot;https://github.com/kana/vim-textobj-syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-syntax&lt;/a&gt;. The default syntax file for &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/syntax/gitcommit.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;gitcommit&lt;/a&gt; does not define &lt;code&gt;gitcommitBody&lt;/code&gt;. Place following line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match   gitcommitBody   &quot;\%&amp;gt;2l[^#].*&quot; contains=@Spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into the file &lt;code&gt;~/.vim/after/ftplugin/gitcommit.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This defines for all lines except the first two and comment lines of a gitcommit buffer the syntax match &lt;code&gt;gitcommitBody&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also add it to your vimrc with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup Mysyntax&#xA;  autocmd!&#xA;  autocmd FileType gitcommit syn match   gitcommitBody  &quot;\%&amp;gt;2l[^#].*&quot; contains=@Spell&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if you have many autocommands, filetype is tested for each autocommand, which is not efficient. Furthermore, you replicate something that Vim already does automatically anyway (see also the reddit post &lt;a href=&quot;https://www.reddit.com/r/vim/wiki/where_to_put_filetype_specific_stuff&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;where_to_put_filetype_specific_stuff&lt;/em&gt;&lt;/a&gt; by romainl).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a typical gitcommit buffer, the syntax groups are now :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TrBKS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TrBKS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without the additional syntax definition the body would belong to no syntax group at all and could not be adressed by the custom text object &lt;em&gt;vim-textobj-syntax&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can press&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gqiy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to reflow the &lt;code&gt;gitcommitBody&lt;/code&gt; to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Qib07.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qib07.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-10-11T11:42:56.693" LastActivityDate="2018-10-11T11:42:56.693" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17613" PostTypeId="1" CreationDate="2018-10-11T22:19:58.610" Score="-1" ViewCount="238" Body="&lt;p&gt;Why does :new create a split? What is the use case for that functionality?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally when I open a new scratch buffer, I don't want it to be in a split.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-10-12T14:26:53.333" Title="Why does :new create a split?" Tags="|buffers|split|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17614" PostTypeId="2" ParentId="17613" CreationDate="2018-10-11T22:27:55.487" Score="4" Body="&lt;p&gt;By definition &lt;code&gt;:new&lt;/code&gt; creates a new buffer in a new window (aka split). From &lt;code&gt;:h :new&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Create a new window and start editing an empty file in it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I imagine &lt;code&gt;:enew&lt;/code&gt; might be more appropriate if you just want a new/scratch buffer in the current window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :new&#xA;:h window&#xA;:h :enew&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2018-10-12T14:26:53.333" LastActivityDate="2018-10-12T14:26:53.333" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="17616" PostTypeId="2" ParentId="7457" CreationDate="2018-10-12T07:50:29.430" Score="1" Body="&lt;h3&gt;You can get pure Vim in DOS!&lt;/h3&gt;&#xA;&lt;p&gt;A further fairly small but no-less major update happened to Windows 10 for the 1803 build. They added 24-bit support for the console (cmd/powershell prompt). In Vim 8.1 (&lt;a href=&quot;https://www.vim.org//download.php/#pc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.vim.org//download.php/#pc&lt;/a&gt;) they &lt;a href=&quot;https://github.com/vim/vim/issues/1270&quot; rel=&quot;nofollow noreferrer&quot;&gt;added support&lt;/a&gt; for &lt;code&gt;termguicolors&lt;/code&gt; which means you can get the full 24-bit colour support inside the Vim console. I recently posted an &lt;a href=&quot;https://vi.stackexchange.com/a/17588/11986&quot;&gt;answer of getting the colour support working&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But what it means is that there is pretty much full support for running Vim in the DOS prompt - so you don't need to install any Linux subsystem or any other dependencies beyond Vim itself to get pure Vim working. I find it still somewhat slow, but it's great to see the progress.&lt;/p&gt;&#xA;&lt;p&gt;The fonts and colours render wonderfully inside Vim (Click on this screenshot to see it properly):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/R3DQS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/R3DQS.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Things that work in Vim console (in Windows 10 build 1803+):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Airline with Powerline fonts&lt;/li&gt;&#xA;&lt;li&gt;24-bit &lt;code&gt;colortheme&lt;/code&gt; (e.g. vim-solarized8, tender)&lt;/li&gt;&#xA;&lt;li&gt;Pretty much any plugin (e.g. any Tim Pope plugin, FZF and Ripgrep)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vimdiff&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The console Window snaps with correctly with the text flowing correctly - this is better handled than GVim&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Things that don't work / problems:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It's slower than GVim&lt;/li&gt;&#xA;&lt;li&gt;Bold / italic fonts&lt;/li&gt;&#xA;&lt;li&gt;UTF-8 characters are a limited - e.g. some of the default Airline icons don't display&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11986" LastEditorUserId="11986" LastEditDate="2021-02-11T16:23:47.770" LastActivityDate="2021-02-11T16:23:47.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17617" PostTypeId="1" CreationDate="2018-10-12T10:17:05.183" Score="0" ViewCount="85" Body="&lt;p&gt;Is it possible to see what arguments vim was invoked with when it was run?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -O foo bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To show &lt;code&gt;-O foo bar&lt;/code&gt;, but especially if there are configurations set like &lt;code&gt;-Z&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5078" LastActivityDate="2018-10-12T10:17:05.183" Title="How can I see what arguments vim was invoked with?" Tags="|argument-list|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17618" PostTypeId="1" CreationDate="2018-10-12T13:19:19.353" Score="0" ViewCount="64" Body="&lt;p&gt;Since dot (.) is the range indicator for the current line I was expecting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.co&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to copy the current line, but it does not do this. What am I doing wrong? In contrast&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.w my_line.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will write the current line to a file. Why does the range work with this command, but not copy?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-10-12T13:46:15.517" Title="Unable to copy line with .co" Tags="|cut-copy-paste|range|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17619" PostTypeId="2" ParentId="17618" CreationDate="2018-10-12T13:46:15.517" Score="2" Body="&lt;p&gt;Reading &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3aco&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :co&lt;/code&gt;&lt;/a&gt; you can see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]co[py] {address}                *:co* *:copy*&#xA;            Copy the lines given by [range] to below the line&#xA;            given by {address}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you need to give an address (a line where you want to copy the current line). For example to put the current line on the last line of the buffer, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.co $&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to get the line in a register you might want to use &lt;code&gt;getline()&lt;/code&gt; and &lt;code&gt;setreg()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg(&quot;*&quot;, getline('.'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getline()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#setreg%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h setreg()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-10-12T13:46:15.517" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17620" PostTypeId="1" AcceptedAnswerId="17629" CreationDate="2018-10-12T14:03:08.913" Score="1" ViewCount="188" Body="&lt;p&gt;I'm looking for a way to precisely set the cursor position given a virtual column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there only &lt;code&gt;:exe &quot;normal! &quot;.vcol.&quot;|&quot;&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: I need virtual columns as they're the only thing that I'm able to compute correctly in a context where there are multi-byte characters that occupy only one column, and tab characters that spawns over several columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the context, I should be more explicit. If I'm looking for a function, it's partly out of curiosity, partly to avoid translating a tuple of coordinates (that I already have thanks to &lt;code&gt;getpos(a_mark)&lt;/code&gt;) into something else, partly for style consistency: I'm trying to fix/enhance a plugin where I try to use functions. This implies I cannot expect something as the virtual editing mode to be in a state or in another: plugins need to work whatever the end-user choose for her/his vim options. Yet, it's true I could change it momentarily and restore it in a &lt;code&gt;finally&lt;/code&gt; statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I'm not in the general case where I may end up in the middle of a tabulation. Any position, I want to jump to, is accessible without &lt;code&gt;'virtualedit'&lt;/code&gt; being set. The (computed) position matches a placeholder in an expanded and re-indented code snippet.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-10-23T12:39:09.657" LastActivityDate="2018-10-23T12:39:09.657" Title="Is there any `setvirtcol()`?" Tags="|vimscript|cursor-movement|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="17621" PostTypeId="2" ParentId="5921" CreationDate="2018-10-12T15:51:06.313" Score="3" Body="&lt;p&gt;The answer provided by @kubek2k is so phenomenal.  That solution is better than I could have imagined and implemented in in less lines of code that I could have imaged.  It opened the door to help me understand the powerful personalization use of 'fzf'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have slightly modified it to additionally provide:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Makes use of fugitive to get the refs instead of the command line, (better support for windows)&lt;/li&gt;&#xA;&lt;li&gt;List tags along with branches&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here is the slight modification:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:gitCheckoutRef(ref) &#xA;    execute('Git checkout ' . a:ref)&#xA;    &quot; call feedkeys(&quot;i&quot;)&#xA;endfunction&#xA;function! s:gitListRefs()&#xA;   let l:refs = execute(&quot;Git for-each-ref --format='\\%(refname:short)'&quot;)&#xA;   return split(l:refs,'\r\n*')[1:] &quot;jump past the first line which is the git command&#xA;endfunction&#xA;command! -bang Gbranch call fzf#run({ 'source': s:gitListRefs(), 'sink': function('s:gitCheckoutRef'), 'dir':expand('%:p:h') })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6119" LastActivityDate="2018-10-12T15:51:06.313" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17622" PostTypeId="1" CreationDate="2018-10-12T17:06:38.430" Score="0" ViewCount="37" Body="&lt;p&gt;When using the ex command change (c), carriage returns become part of the input, so how do you indicate that you are done entering text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I notice that if I hit the backspace, it finishes the command, but I suspect there is a more regular method.)&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-10-12T17:06:38.430" Title="How do you end the command when using :c?" Tags="|ex-mode|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17623" PostTypeId="1" CreationDate="2018-10-12T19:21:39.650" Score="2" ViewCount="112" Body="&lt;p&gt;I have a presentation to make for a conference and I'm not allowed to use slides, only live coding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a tool in vim which will help me avoid typos ? :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like &lt;a href=&quot;https://doitlive.readthedocs.io/en/stable/&quot; rel=&quot;nofollow noreferrer&quot;&gt;doitlive&lt;/a&gt; which you can click on any key on the keyboard and it will print the next right letter from the provided file.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;doitlive is a tool for live presentations in the terminal. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;It reads a file of shell commands and replays the commands in a fake terminal session as you type random characters.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="19351" LastActivityDate="2018-10-12T19:21:39.650" Title="vim recorded session like doitlive" Tags="|autocompletion|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17624" PostTypeId="1" AcceptedAnswerId="17630" CreationDate="2018-10-12T21:07:13.223" Score="1" ViewCount="1086" Body="&lt;h1&gt;The issue&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;My custom highlighting styles for Visual mode selection of text is not as it was. It use to be yellow background with black text. Now it is just underlined.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Environment&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;vim 8.0 term, not the gui version. Mac OS 10.12.6, iTerm2 3.2.3, Terminal 2.7.3&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Troubleshooting&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have tried iTerm2 and Terminal&lt;/li&gt;&#xA;&lt;li&gt;I have tried zsh and bash&lt;/li&gt;&#xA;&lt;li&gt;I have tried in and out of a Tmux session (I pretty much live in a tmux session)&lt;/li&gt;&#xA;&lt;li&gt;I have started it with no rc file &lt;code&gt;vim -u NONE&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;I have tried different themes (I use a custom theme)&lt;/li&gt;&#xA;&lt;li&gt;I have unset every environment variable I can think of that might be messing with it; &lt;code&gt;TERM&lt;/code&gt;, &lt;code&gt;EDITOR&lt;/code&gt;, &lt;code&gt;SHELL&lt;/code&gt;, and many many more.&lt;/li&gt;&#xA;&lt;li&gt;Manually set &lt;code&gt;:highlight Visual cterm=reverse ctermbg=NONE&lt;/code&gt; (no change at all)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:verbose hi Visual?&lt;/code&gt; returns &lt;code&gt;highlight group not found: Visual?&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;I manually set &lt;code&gt;:set sessionoptions-=options&lt;/code&gt; and &lt;code&gt;:set sessionoptions-=folds&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;I manually set the syntax and have played with different file types, and they are all the same. (python, dockerfile, json, yml, js, css, etc)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;When this happened&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;After a crash. I had it up for 100+ days, and was overworking it like crazy and it just went blank and rebooted.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Current conclusion based on troubleshooting results&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;So based on the troubleshooting I have done, I think it is safe to say it is not the terminal or terminal configuration/themes/colors/etc, it is not the type of shell, it is not tmux, it is not the vimrc file, it is not the colorscheme, or it is doesn't seem to be environment variable related. I could be wrong, maybe I was not thorough enough with my tests. But I literally saw 0 difference with all of the listed troubleshooting.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Next steps / Remaining questions&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;What confuses me and I'm very suspicious of is the &lt;code&gt;:verbose hi Visual?&lt;/code&gt; returns &lt;code&gt;highlight group not found: Visual?&lt;/code&gt;. What would cause this? I can't seem to find it from searching here and google.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something? Do you guys have any further suggestions? I do have an additional question for troubleshooting. I have used this for designing my custom colorscheme. Where you can set your cursor over some text and get vim to tell you what the highlight syntax is. Is there a way to do that for when you are in Visual mode and have selected text? Because if &lt;code&gt;Visual&lt;/code&gt; is missing and manually setting is not changing it, I'm thinking that it is possibly just styled based on another highlight.&lt;/p&gt;&#xA;" OwnerUserId="10431" LastActivityDate="2018-10-14T19:33:11.303" Title="Visual Select highlighting not working anymore" Tags="|syntax-highlighting|terminal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17625" PostTypeId="2" ParentId="16907" CreationDate="2018-10-12T23:57:29.493" Score="1" Body="&lt;p&gt;After some time, where I am more experienced, I decided to write a generic solution for this problem. It is based on the answer of &lt;a href=&quot;https://vi.stackexchange.com/users/343/rich&quot;&gt;Rich&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usage: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:&amp;lt;range&amp;gt;GL/pat/py python code &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Passes over a range that is filtered by [pat]. Executes python code, where the first matched group is stored in a variable called match. Doesn't change anything...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OR:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:&amp;lt;range&amp;gt;GL/pat/rpy python expression &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Passes over a range that is filtered by [pat]. Evaluates a python expression, where the first matched group is stored in a variable called match. Changes the entire match expression to the returned value from the expression. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%GL/lst=\(.*\)/rpy 'lst = ' + match &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;changes &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lst=['aaa']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lst = ['aaa']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use it, you may add the following lines to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RunPython2(match,run)&#xA;  py3 import vim&#xA;  py3 match=vim.eval(&quot;a:match&quot;)&#xA;  py3 retval=eval(vim.eval(&quot;a:run&quot;),globals())&#xA;  py3 if retval==None: retval=match&#xA;  py3 vim.command(&quot;let retInVim='&quot; + retval + &quot;'&quot;) &#xA;  return retInVim&#xA;endfunction&#xA;&#xA;function! RunPython(match,run)&#xA;  py3 import vim&#xA;  py3 match=vim.eval(&quot;a:match&quot;)&#xA;  exec &quot;py3 &quot; . a:run &#xA;  return &quot;&quot;&#xA;endfunction&#xA;&#xA;function! GL(arg) range&#xA;    let lst=matchlist(a:arg,'/\(.*\)/\(.\{-}\) \(.*\)$')&#xA;    if lst[2]==#&quot;rpy&quot;&#xA;        exec a:firstline. &quot;,&quot; . a:lastline . &quot;:s\/&quot; . lst[1] . &quot;/\\=RunPython2(submatch(1),\&quot;&quot;. escape(lst[3],&quot;\&quot;&quot;) . &quot;\&quot;)&quot;&#xA;    elseif lst[2]==#&quot;py&quot;&#xA;        exec a:firstline. &quot;,&quot; . a:lastline . &quot;:s\/&quot; . lst[1] . &quot;/\\=submatch(0) . RunPython(submatch(1),\&quot;&quot;. escape(lst[3],&quot;\&quot;&quot;) . &quot;\&quot;)&quot;&#xA;    endif&#xA;endfunction &#xA;command! -nargs=1 -range GL &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call GL(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2018-10-13T10:51:03.817" LastActivityDate="2018-10-13T10:51:03.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17626" PostTypeId="1" AcceptedAnswerId="17631" CreationDate="2018-10-13T00:00:33.017" Score="1" ViewCount="198" Body="&lt;p&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/475187/how-to-start-vim-in-insert-mode-at-end-of-first-line-when-committing-git-changes?noredirect=1#comment868010_475187&quot;&gt;&lt;code&gt;call feedkeys('gg', 'int')&lt;/code&gt;&lt;/a&gt; seems to work, but what would be the Vim configuration language equivalent?&lt;/p&gt;&#xA;" OwnerUserId="19355" LastActivityDate="2018-10-13T23:39:14.873" Title="What is the configuration equivalent to `gg`?" Tags="|plugin-system|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17627" PostTypeId="1" AcceptedAnswerId="17628" CreationDate="2018-10-13T02:11:58.153" Score="1" ViewCount="208" Body="&lt;p&gt;Lets pretend I have a Vim session with buffers that look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+-------------+--------------+&#xA;|             |              |&#xA;|             |              |&#xA;|             |              |&#xA;|             |              |&#xA;|             |              |&#xA;|      1      |       2      |&#xA;|             |              |&#xA;|             |              |&#xA;|             |              |&#xA;|             |              |&#xA;|             |              |&#xA;+-------------+--------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to query which buffer is to the right of buffer #1?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I'd want something like this (Obviously this isn't Vimscript but I hope it gives you the idea):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;get_neighboring_buffers(current_buffer=1, direction=&quot;right&quot;)&#xA;# Result: [2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then consider this window layout&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+-------------+--------------+&#xA;|             |              |&#xA;|             |              |&#xA;|             |      2       |&#xA;|             |              |&#xA;|             |              |&#xA;|      1      +--------------+&#xA;|             |              |&#xA;|             |              |&#xA;|             |      3       |&#xA;|             |              |&#xA;|             |              |&#xA;+-------------+--------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, the same function might return more than one buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;get_neighboring_buffers(current_buffer=1, direction=&quot;right&quot;)&#xA;# Result: [2, 3]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, is there a way to check which buffer is more &quot;on-top&quot; of another?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;get_topmost_buffer([2, 3])&#xA;# Result: 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to find the nearest-right buffer for a script I'm writing but am&#xA;having trouble finding resources about this online.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, the solution should be able to handle the 3-buffer setup I showed but&#xA;if it only works with the first example (the vertical split) then that's fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="16073" LastActivityDate="2018-10-14T00:12:53.287" Title="How to get neighboring buffer numbers" Tags="|buffers|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17628" PostTypeId="2" ParentId="17627" CreationDate="2018-10-13T03:20:01.580" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a way to query which buffer is to the right of buffer #1?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not sure it's reliable, but you could try this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! Get_right_buffers() abort&#xA;    let right_edge = win_screenpos(0)[1] + winwidth(0)&#xA;    return filter(map(filter(getwininfo(),&#xA;        \ {i,v -&amp;gt; v.tabnr == tabpagenr()}),&#xA;        \ {i,v -&amp;gt; v.wincol == right_edge + 1 ? getwininfo()[i].bufnr : -1}),&#xA;        \ {i,v -&amp;gt; v != -1})&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;getwininfo()&lt;/code&gt; gives you information about all the windows of all the tabpages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The purpose of the innermost &lt;code&gt;filter()&lt;/code&gt; invocation is to remove the information about the windows in the other tabpages.&lt;br&gt;&#xA;The purpose of the &lt;code&gt;map()&lt;/code&gt; invocation is to convert those information into the numbers of the buffers whose left edge is next to the right edge of the current window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h win_screenpos()&#xA;:h winwidth()&#xA;:h filter()&#xA;:h map()&#xA;:h getwininfo()&#xA;:h tabpagenr()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if your Vim version includes the patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.0307&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.0307&lt;/a&gt; you could try to use the &lt;code&gt;winlayout()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would have to parse the nested list it returns to get the information you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h winlayout()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;winlayout([{tabnr}])                                        *winlayout()*&#xA;            The result is a nested List containing the layout of windows&#xA;            in a tabpage.&#xA;&#xA;            Without {tabnr} use the current tabpage, otherwise the tabpage&#xA;            with number {tabnr}. If the tabpage {tabnr} is not found,&#xA;            returns an empty list.&#xA;&#xA;            For a leaf window, it returns:&#xA;                    ['leaf', {winid}]&#xA;            For horizontally split windows, which form a column, it&#xA;            returns:&#xA;                    ['col', [{nested list of windows}]]&#xA;            For vertically split windows, which form a row, it returns:&#xA;                    ['row', [{nested list of windows}]]&#xA;&#xA;            Example:&#xA;                    &quot; Only one window in the tab page&#xA;                    :echo winlayout()&#xA;                    ['leaf', 1000]&#xA;                    &quot; Two horizontally split windows&#xA;                    :echo winlayout()&#xA;                    ['col', [['leaf', 1000], ['leaf', 1001]]]&#xA;                    &quot; Three horizontally split windows, with two&#xA;                    &quot; vertically split windows in the middle window&#xA;                    :echo winlayout(2)&#xA;                    ['col', [['leaf', 1002], ['row', ['leaf', 1003],&#xA;                                         ['leaf', 1001]]], ['leaf', 1000]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Alternatively, is there a way to check which buffer is more &quot;on-top&quot; of another?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could try this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! Get_topmost_buffer(a,b) abort&#xA;    if bufwinnr(a:a) == -1&#xA;        return 'buffer '.a:a.' is not displayed in this tabpage'&#xA;    elseif bufwinnr(a:b) == -1&#xA;        return 'buffer '.a:b.' is not displayed in this tabpage'&#xA;    elseif win_screenpos(bufwinnr(a:a))[0] == win_screenpos(bufwinnr(a:b))[0]&#xA;        return 'the windows of buffer '.a:a.' and '.a:b.' are at the same level'&#xA;    else&#xA;        return win_screenpos(bufwinnr(a:a))[0] &amp;gt; win_screenpos(bufwinnr(a:b))[0]&#xA;            \ ? a:b&#xA;            \ : a:a&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h bufwinnr()&#xA;:h win_screenpos()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-10-14T00:12:53.287" LastActivityDate="2018-10-14T00:12:53.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17629" PostTypeId="2" ParentId="17620" CreationDate="2018-10-13T06:43:51.263" Score="1" Body="&lt;p&gt;Using the Tab example, let's say my line number 10 starts with a tab character (denoted by &lt;code&gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt; for each of the three virtual columns that follow):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10: &amp;gt;---foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will place the cursor in (virtual) column 3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set virtualedit=all&#xA;call cursor([10, 1, 2])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The list is &lt;code&gt;[lnum, col, off]&lt;/code&gt;. &lt;code&gt;lnum&lt;/code&gt; is line number. &lt;code&gt;col&lt;/code&gt; is non virtual column and &lt;code&gt;off&lt;/code&gt; is offset beyond &lt;code&gt;col&lt;/code&gt; (this is the secret sauce to get to a virtual column).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10: &amp;gt;---foo&#xA;      ^&#xA;      |_____ cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that without the &lt;code&gt;virtualedit&lt;/code&gt; setting the cursor would be placed in column 1.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;My first submission used &lt;code&gt;setpos()&lt;/code&gt; instead until I realized that &lt;code&gt;cursor()&lt;/code&gt; is more straightforward...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setpos(&quot;.&quot;, [0, 10, 1, 2])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;.&quot;&lt;/code&gt; means &quot;set cursor position&quot; (as opposed to a mark). The list is &lt;code&gt;[bufnum, lnum, col, off]&lt;/code&gt;. A &lt;code&gt;bufnum&lt;/code&gt; value of 0 indicates current buffer. The rest is identical to the parameters for &lt;code&gt;cursor()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-10-13T07:22:15.260" LastActivityDate="2018-10-13T07:22:15.260" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17630" PostTypeId="2" ParentId="17624" CreationDate="2018-10-13T23:03:01.680" Score="0" Body="&lt;p&gt;XQuartz was not running after the reboot. I launched XQuartz and opened a new fresh vim session and viola. It worked like normal. I didn't have to change anything. I am curious to know as to why exactly having a X window server running impacts vim's visual selection highlight settings. If anyone could explain that it would be much appreciated&lt;/p&gt;&#xA;" OwnerUserId="10431" LastEditorUserId="10431" LastEditDate="2018-10-14T19:33:11.303" LastActivityDate="2018-10-14T19:33:11.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17631" PostTypeId="2" ParentId="17626" CreationDate="2018-10-13T23:21:25.100" Score="4" Body="&lt;p&gt;Don't you mean &lt;code&gt;ggA&lt;/code&gt;? Anyways, there's no separate language for Vim configuration. Everything is &quot;Vim script&quot;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Your first experience with Vim scripts is the vimrc file.  Vim reads it when&#xA;  it starts up and executes the commands.  You can set options to values you&#xA;  prefer.  And you can use any colon command in it (commands that start with a&#xA;  &quot;:&quot;; these are sometimes referred to as Ex commands or command-line commands).&#xA;     Syntax files are also Vim scripts.  As are files that set options for a specific file type.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(from &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#vim-script-intro&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h vim-script-intro&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the literal answer to your literal question is: &lt;code&gt;call feedkeys('ggA', 'int')&lt;/code&gt;. A slightly more thoughtful answer would also mention that if you want to execute Normal mode commands from a script (or from the command line) then you typically would use &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3Anormal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:norm&lt;/code&gt;&lt;/a&gt;. E.g. &lt;code&gt;norm! ggA&lt;/code&gt;. (The &lt;code&gt;!&lt;/code&gt; is used to prevent interference from existing mappings.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: someone answered your question on the other site with an &lt;code&gt;autocommand&lt;/code&gt; based solution and I think that's the right approach. Have you followed through on that?&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-10-13T23:39:14.873" LastActivityDate="2018-10-13T23:39:14.873" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17633" PostTypeId="2" ParentId="17584" CreationDate="2018-10-14T13:34:54.483" Score="1" Body="&lt;pre&gt;&lt;code&gt;:set number &#xA;&amp;lt;Enter&amp;gt;&#xA;&amp;lt;ESC&amp;gt;&#xA;:1,6s/^/ /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Turn numbering on to make it easier to see what lines need to be changed.&lt;br&gt;&#xA;In  colon mode, enter the number of the first line, comma, and the last line to be changed.&lt;br&gt;&#xA;Follow with s for substitution,&lt;br&gt;&#xA;/^/ the ^caret searches for the beginning of the line,&lt;br&gt;&#xA;/ / and insert a space (there is a space between the slashes).  &lt;/p&gt;&#xA;" OwnerUserId="1977" LastEditorUserId="1977" LastEditDate="2018-11-12T01:02:20.123" LastActivityDate="2018-11-12T01:02:20.123" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17634" PostTypeId="1" CreationDate="2018-10-15T04:46:49.803" Score="1" ViewCount="298" Body="&lt;p&gt;In one version of VIM that I run, when I hit the &quot;tab&quot; key in insert mode, it indents the whole line, regardless of the cursors position in the line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I believe to be the only modified parts of the config, however I can include more as necessary (the whole file is 296 lines so I'll need to cut it down).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nowrap&#xA;&#xA;set shiftwidth=4&#xA;set expandtab&#xA;set autoindent&#xA;set tabstop=4&#xA;&#xA;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19380" LastActivityDate="2019-08-12T05:02:25.643" Title="How to stop &quot;tab&quot; key indenting whole line" Tags="|vimrc|indentation|insert-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17635" PostTypeId="1" CreationDate="2018-10-15T09:21:23.647" Score="1" ViewCount="157" Body="&lt;p&gt;I have digraph enabled&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set digraph&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I really like the digraph setting in vim, but I often find it changes my keystrokes to some foreign character without my intention. I can see that there are around 13.000 characters defined, and the chance of hitting a combination, and a backspace in between, is just too high. In the end I will only use around 10 of these characters anyway. So my question is, can I enable digraph only for a set of predefined characters? Or do I need to resort to the CTRL-k option? Or define my own mappings?&lt;/p&gt;&#xA;" OwnerUserId="6154" LastActivityDate="2018-10-15T13:31:08.877" Title="Enable digraph only for certain characters" Tags="|digraphs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17636" PostTypeId="2" ParentId="17635" CreationDate="2018-10-15T13:31:08.877" Score="3" Body="&lt;p&gt;If there are literally only ten, then a simple, albeit inelegant, solution would be to leave &lt;code&gt;'digraph'&lt;/code&gt; switched off and just hard code the desired behaviour with ten insert mode mappings, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap e&amp;lt;BS&amp;gt;' é&#xA;:inoremap i&amp;lt;BS&amp;gt;: ï&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's not a perfect solution, because it results in slightly delayed/odd redraw while you are halfway through typing the mapping, but at the speed most people type in insert mode you might not find it a big issue in practice.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-10-15T13:31:08.877" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17637" PostTypeId="1" AcceptedAnswerId="17638" CreationDate="2018-10-15T14:35:45.743" Score="3" ViewCount="236" Body="&lt;p&gt;&lt;strong&gt;underlying question:&lt;/strong&gt; Is there a way to operate on text within a regex match?&#xA;I.e. is there an analog to the 'g' command that operates on match substrings instead of lines&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;usecases:&lt;/strong&gt;&#xA;One example of this would be if you replace a pattern within a pattern without a huge amount of regex gymnastics (which are often possible with much effort). A specific example might be replace spaces with tabs but only in text matching a regex.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;field1 field2 field3 field4 field with spaces&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another specific example would be if you wanted to replace - with _ but only in text inside quotes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;You should name your file [something something something]&#xA;and name their file [a b c d] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11024" LastActivityDate="2018-10-15T15:37:28.270" Title="replace or operate within regex match" Tags="|regular-expression|substitute|global-command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17638" PostTypeId="2" ParentId="17637" CreationDate="2018-10-15T15:37:28.270" Score="6" Body="&lt;p&gt;Maybe your solution is to use a sub-replace-expression (&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-expression&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h sub-replace-expression&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example in your first example let's say that I want to replace spaces with underscores (because it's more visual in this answer) but only in the last field &lt;code&gt;field with spaces&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;field1 field2 field3 field4 field with spaces&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could use this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/field w.*/\=substitute(submatch(0), '_', ' ', 'g')/&#xA;&#xA; s/                                                     Substitution command&#xA;   field w.*                                            Make the substitution only on the part of the string you want to match&#xA;            /&#xA;             \=                                         Replace with an expression&#xA;               substitute(           , ' ', '_', 'g')   Use the substitution() function to replace spaces with underscore&#xA;                          submatch(0)                   Give the matched string as parameter of substitute()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will result in &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;field1 field2 field3 field4 field_with_spaces&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This idea is to use the &lt;code&gt;substitute()&lt;/code&gt; function inside the replacement part of the &lt;code&gt;:s&lt;/code&gt; command. &lt;code&gt;submatch(0)&lt;/code&gt; is a reference to the pattern matched by &lt;code&gt;:s&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the same idea to replace &lt;code&gt;something something something&lt;/code&gt; by &lt;code&gt;something_something_something&lt;/code&gt; in your second example you could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\[.*\]/\=substitute(submatch(0), ' ', '_', 'g')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might want to read the following help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-expression&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h sub-replace-expression&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#submatch%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h submatch()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#substitute%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h substitute()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-10-15T15:37:28.270" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17639" PostTypeId="2" ParentId="17634" CreationDate="2018-10-16T02:18:03.823" Score="1" Body="&lt;p&gt;Based on the comment from @statox♦ I was able to find the line of my code causing this. Using the debug method in the link showed me that it was the line (which was close to @statox♦'s original suggestion):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Tab&amp;gt; &amp;lt;C-T&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Commenting this out fixed my issue.&lt;/p&gt;&#xA;" OwnerUserId="19380" LastActivityDate="2018-10-16T02:18:03.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17640" PostTypeId="1" CreationDate="2018-10-16T02:38:53.883" Score="2" ViewCount="267" Body="&lt;p&gt;Are there simple tweaks that I can visual select everything with in a pair of fold markers? Just like what &lt;code&gt;vi&quot;&lt;/code&gt; will do for a pair of double quotes. Preferably &lt;code&gt;vi&lt;/code&gt; plus some other keys.&lt;/p&gt;&#xA;" OwnerUserId="16146" LastActivityDate="2018-10-16T07:55:08.843" Title="How to visual select everything within a pair of fold markers" Tags="|visual-mode|folding|visual-block|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17641" PostTypeId="1" AcceptedAnswerId="17642" CreationDate="2018-10-16T06:55:33.110" Score="11" ViewCount="1389" Body="&lt;p&gt;I'm using Vim to develop C on Linux.&#xA;When I press &lt;kbd&gt;K&lt;/kbd&gt; in order to open man page for the underlying word, I don't have control on which man section is opened.&#xA;Is there a way to specify that somewhere ?&lt;/p&gt;&#xA;" OwnerUserId="496" LastEditorUserId="205" LastEditDate="2018-10-16T10:20:18.490" LastActivityDate="2018-10-16T10:34:56.040" Title="Open man section 3" Tags="|key-bindings|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17642" PostTypeId="2" ParentId="17641" CreationDate="2018-10-16T07:44:54.013" Score="19" Body="&lt;p&gt;Quoting from the &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#K&quot; rel=&quot;noreferrer&quot;&gt;documentation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  When 'keywordprg' is equal to &quot;man -s&quot;, a count&#xA;  before &quot;K&quot; is inserted after the &quot;-s&quot;.  If there is&#xA;  no count, the &quot;-s&quot; is removed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;man -s&lt;/code&gt; seems to be the default for the &lt;code&gt;'keywordprg'&lt;/code&gt; setting, so simplying using a count before typing &lt;kbd&gt;K&lt;/kbd&gt; seems to do the trick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Tested successfully with &lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;K&lt;/kbd&gt; and &lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;K&lt;/kbd&gt; and the cursor being on &lt;code&gt;open&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-10-16T07:53:07.483" LastActivityDate="2018-10-16T07:53:07.483" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17643" PostTypeId="2" ParentId="17641" CreationDate="2018-10-16T07:45:37.213" Score="9" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#K&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h K&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *K*&#xA;K           Run a program to lookup the keyword under the&#xA;            cursor.  [...]&#xA;            Special cases:&#xA;            - When 'keywordprg' is equal to &quot;man&quot; or starts with&#xA;              &quot;:&quot;, a [count] before &quot;K&quot; is inserted after&#xA;              keywordprg and before the keyword.  For example,&#xA;              using &quot;2K&quot; while the cursor is on &quot;mkdir&quot;, results&#xA;              in: &#xA;                !man 2 mkdir&#xA;            - When 'keywordprg' is equal to &quot;man -s&quot;, a count&#xA;              before &quot;K&quot; is inserted after the &quot;-s&quot;.  If there is&#xA;              no count, the &quot;-s&quot; is removed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;K&lt;/kbd&gt; should do the trick&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-10-16T07:45:37.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17644" PostTypeId="2" ParentId="17640" CreationDate="2018-10-16T07:55:08.843" Score="3" Body="&lt;p&gt;What you are looking for is called a &quot;text-object&quot; in Vim terminology and you can find the list of these text-objects at &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#text-objects&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h text-objects&lt;/code&gt;&lt;/a&gt;. As you can see there is not a built-in text-object for the folds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However you might be interested in this plugin: &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-user&lt;/a&gt;. It allows you to define your own text-objects easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if you don't want to use a plugin you can simply use an operator pending mode mapping (see &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#omap-info&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h omap-info&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-10-16T07:55:08.843" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17645" PostTypeId="1" AcceptedAnswerId="17646" CreationDate="2018-10-16T08:52:10.467" Score="3" ViewCount="298" Body="&lt;p&gt;At every opening of a special file I want vim to automatically highlight all the lines, where the 7th character is a &lt;code&gt;1&lt;/code&gt;. How do I do that?&lt;/p&gt;&#xA;" OwnerUserId="19395" LastActivityDate="2018-10-16T11:25:18.463" Title="Highlighting only in a certain file" Tags="|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17646" PostTypeId="2" ParentId="17645" CreationDate="2018-10-16T09:06:18.620" Score="5" Body="&lt;p&gt;First you probably want to create your own syntax file, you can read &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#mysyntaxfile&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h mysyntaxfile&lt;/code&gt;&lt;/a&gt; for more details&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ mkdir -p ~/.vim/syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you want to define your own filetype for the file you are editing, you could do that with a modeline (&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#modeline&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h modeline&lt;/code&gt;&lt;/a&gt;) e.g. adding this line as the first or last line of your file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim: ft=myownfiletype&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the file already has a filetype you can set several ones, for example if this is a C file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//vim: ft=c.myownfiletype&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you can't add a modeline to your file you can use other ways to define a file type (see &lt;a href=&quot;http://vimhelp.appspot.com/filetype.txt.html#ftdetect&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ftdetect&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;http://vim.wikia.com/wiki/Filetype.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you need to create the syntax file for this new filetype (see &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3asyn-files&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :syn-files&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ touch ~/.vim/syntax/myownfiletype.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally in this file you can put your commands, a basic example would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Error /^.\{6}1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;syntax match&lt;/code&gt; create a new highlighting for line which will match what follows (&lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3asyn-match&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :syn-match&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Error&lt;/code&gt; Use the &lt;code&gt;Error&lt;/code&gt; highlighting group. Note that you could use another one or define your own one (see &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#highlight-groups&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h highlight-groups&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/^.\{6}1/&lt;/code&gt; match the lines beginning (&lt;code&gt;^&lt;/code&gt;) with 6 characters &lt;code&gt;.\{6}&lt;/code&gt; followed by &lt;code&gt;1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-10-16T11:25:18.463" LastActivityDate="2018-10-16T11:25:18.463" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17647" PostTypeId="2" ParentId="17641" CreationDate="2018-10-16T10:34:56.040" Score="4" Body="&lt;p&gt;If you're on Linux, you're likely using mandb's &lt;code&gt;man&lt;/code&gt;, and you can control the order in which sections are searched. See &lt;a href=&quot;http://man7.org/linux/man-pages/man1/man.1.html#ENVIRONMENT&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;man 1 man&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;MANSECT&lt;br&gt;&#xA;  If $MANSECT is set, its value is a colon-delimited list of sections&#xA;  and it is used to determine which manual sections to search and in&#xA;  what order. The default is &quot;1 n l 8 3 2 3posix 3pm 3perl 3am 5 4 9 6&#xA;  7&quot;, unless overridden by the SECTION directive in /etc/manpath.config.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So another option is to set in your shell initialisation files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MANSECT=3:3posix:3pm:3perl:3am:1:n:l:8:2:5:4:9:6:7&#xA;export MANSECT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $MANSECT=&quot;3:3posix:3pm:3perl:3am:1:n:l:8:2:5:4:9:6:7&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Also, depending on what you're programming, section 2 might also need a higher priority.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Or, as the manpage says, set system-wide in &lt;code&gt;/etc/manpath.config&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also works for &lt;a href=&quot;https://www.freebsd.org/cgi/man.cgi?query=man&amp;amp;apropos=0&amp;amp;sektion=0&amp;amp;manpath=FreeBSD%2011.2-RELEASE%20and%20Ports&amp;amp;arch=default&amp;amp;format=html&quot; rel=&quot;nofollow noreferrer&quot;&gt;FreeBSD's man&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-10-16T10:34:56.040" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17649" PostTypeId="2" ParentId="17554" CreationDate="2018-10-17T01:55:12.513" Score="1" Body="&lt;p&gt;This code restores the exact state you were in on a newly opened vim (no arguments). That is if you remembered to exit vim using SQ(a newly defined key sequence). It also saves the files you were working on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to add this to your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap SQ &amp;lt;ESC&amp;gt;:mksession! ~/.vim/Session.vim&amp;lt;CR&amp;gt;:wqa&amp;lt;CR&amp;gt;&#xA;&#xA;function! RestoreSession()&#xA;    if argc() == 0 &amp;amp;&amp;amp; filereadable($HOME . '/.vim/Session.vim')  &quot;vim called without arguments&#xA;        execute 'source ~/.vim/Session.vim'&#xA;    endif&#xA;endfunction&#xA;&#xA;&#xA;autocmd VimEnter * call RestoreSession()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Taken from here with a minor change &#xA;&lt;a href=&quot;https://askubuntu.com/questions/28614/gvim-configuration-does-not-work-like-it-should&quot;&gt;https://askubuntu.com/questions/28614/gvim-configuration-does-not-work-like-it-should&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this is the answer you were looking for.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2018-10-22T12:10:04.493" LastActivityDate="2018-10-22T12:10:04.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17650" PostTypeId="1" CreationDate="2018-10-17T07:54:19.107" Score="1" ViewCount="8457" Body="&lt;p&gt;I am trying to master VI and found some nice tricks to replace a letter with a single &lt;code&gt;:%s/&lt;/code&gt; command and this works. If I'd like to replace for example &lt;code&gt;word&lt;/code&gt; with &lt;code&gt;wardos&lt;/code&gt; I can use &lt;code&gt;:%s/word/wardos/g&lt;/code&gt; and then hit enter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how do I replace those accented characters like &lt;code&gt;é&lt;/code&gt;, &lt;code&gt;á&lt;/code&gt;, &lt;code&gt;Á&lt;/code&gt; etc?&lt;/p&gt;&#xA;" OwnerUserId="19417" LastEditorUserId="1841" LastEditDate="2018-10-17T07:58:42.223" LastActivityDate="2021-06-29T03:30:09.443" Title="How do I replace all accented characters like &quot;á&quot;, &quot;ő&quot; and &quot;é&quot;?" Tags="|substitute|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17652" PostTypeId="2" ParentId="17650" CreationDate="2018-10-17T08:28:35.230" Score="5" Body="&lt;p&gt;If you want to match just a single character that has an accent, you can simply include it in a search:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/café/restaurant/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can type the accented character either using your operating system's input features, or with Vim's &lt;strong&gt;digraphs&lt;/strong&gt; feature (see &lt;code&gt;:help  c_CTRL-k&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to &lt;em&gt;ignore&lt;/em&gt; the accents, you can use an &lt;strong&gt;equivalence class&lt;/strong&gt; (See &lt;code&gt;:help /[[=&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. Replace both &lt;code&gt;cafe&lt;/code&gt; and &lt;code&gt;café&lt;/code&gt; with restaurant:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/caf[[=e=]]/restaurant/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace all e-like characters with ASCII &lt;code&gt;e&lt;/code&gt; characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/[[=e=]]/e/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-10-17T08:36:57.927" LastActivityDate="2018-10-17T08:36:57.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17653" PostTypeId="2" ParentId="17650" CreationDate="2018-10-17T12:24:54.430" Score="2" Body="&lt;p&gt;You can chain the substitutions with the pipe &lt;code&gt;|&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/é/e/e | %s/à/a/e | %s/....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, you could replace several accentuated chars in one line&lt;/p&gt;&#xA;" OwnerUserId="19423" LastEditorUserId="1841" LastEditDate="2018-10-17T13:19:44.070" LastActivityDate="2018-10-17T13:19:44.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17654" PostTypeId="2" ParentId="17650" CreationDate="2018-10-17T12:57:20.103" Score="5" Body="&lt;p&gt;The accents are part of the word's spelling. You're asking us how to use &lt;code&gt;vi&lt;/code&gt; to take a document with correctly-spelled words and introduce spelling errors.&lt;/p&gt;&#xA;&lt;p&gt;The days where you could get away with ignoring &lt;a href=&quot;https://en.wikipedia.org/wiki/Unicode&quot; rel=&quot;nofollow noreferrer&quot;&gt;Unicode&lt;/a&gt; are long past.&lt;/p&gt;&#xA;&lt;p&gt;There are languages without a J, such as classical Latin. Would you not be annoyed if people called you &amp;quot;&lt;code&gt;Iason335&lt;/code&gt;&amp;quot; on this site?&lt;/p&gt;&#xA;&lt;p&gt;Of the &lt;code&gt;vi&lt;/code&gt; clones, Vim has by far the best Unicode support. Vim likes &lt;a href=&quot;https://en.wikipedia.org/wiki/UTF-8&quot; rel=&quot;nofollow noreferrer&quot;&gt;UTF-8&lt;/a&gt; best, though on Windows &lt;a href=&quot;https://en.wikipedia.org/wiki/UTF-16&quot; rel=&quot;nofollow noreferrer&quot;&gt;UTF-16&lt;/a&gt; is &lt;em&gt;sometimes&lt;/em&gt; a better idea. See &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/mbyte.html#unicode&quot; rel=&quot;nofollow noreferrer&quot;&gt;the &lt;code&gt;unicode&lt;/code&gt; section of the Vim manual&lt;/a&gt; for more information.&lt;/p&gt;&#xA;&lt;p&gt;If you absolutely must crush Unicode back to a legacy encoding such as the &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII#History&quot; rel=&quot;nofollow noreferrer&quot;&gt;ancient 7-bit ASCII standard&lt;/a&gt;, there are several options I'd choose before resorting to a blind &lt;code&gt;vi&lt;/code&gt; substitution command:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Replace the words on a case-by-case basis using human intelligence, since accented letters don't have the same meaning in all human languages, so there is no dumb repetitive rule you can run that works in all cases:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The Germanic name Jörg is best spelled Joerg in ASCII, not &amp;quot;Jorg&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;But please beware: the &amp;quot;ö&amp;quot; → &amp;quot;oe&amp;quot; rule only applies to German. It doesn't apply even to closely-related languages like Dutch, though &lt;a href=&quot;https://en.wikipedia.org/wiki/Germanic_umlaut&quot; rel=&quot;nofollow noreferrer&quot;&gt;the same process exists&lt;/a&gt; with different &lt;a href=&quot;https://en.wikipedia.org/wiki/Orthography&quot; rel=&quot;nofollow noreferrer&quot;&gt;orthography&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;English is largely German-derived, but in properly-spelled English, the two-dot accent on top of a letter is almost always a &lt;a href=&quot;https://en.wikipedia.org/wiki/Diaeresis_(diacritic)&quot; rel=&quot;nofollow noreferrer&quot;&gt;diaeresis&lt;/a&gt;, not an &lt;a href=&quot;https://en.wikipedia.org/wiki/Umlaut_(linguistics)&quot; rel=&quot;nofollow noreferrer&quot;&gt;umlaut&lt;/a&gt;.¹&lt;/p&gt;&#xA;&lt;p&gt;For instance, the English word &amp;quot;cooperate&amp;quot; is &lt;a href=&quot;https://www.newyorker.com/culture/culture-desk/the-curse-of-the-diaeresis&quot; rel=&quot;nofollow noreferrer&quot;&gt;sometimes spelled &amp;quot;coöperate&amp;quot;&lt;/a&gt; to indicate that the first syllable is &amp;quot;co,&amp;quot; not &amp;quot;coop,&amp;quot; as in &amp;quot;chicken coop.&amp;quot; The proper ASCII-ization is therefore not &amp;quot;cooeperate&amp;quot;.²&lt;/p&gt;&#xA;&lt;p&gt;For another example, the English surname Brontë uses a diaeresis to indicate that the &amp;quot;e&amp;quot; isn't silent, as an English speaker may well expect, causing it to be pronounced as if it were spelled &amp;quot;Bront&amp;quot;. The diaeresis tells us that the final &amp;quot;e&amp;quot; is a separate syllable, so the name must be properly pronounced &amp;quot;BRONT-ay&amp;quot;. The proper ASCII-ization is &amp;quot;Bronte&amp;quot;, not &amp;quot;Brontee&amp;quot; or something else.³&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In &lt;a href=&quot;https://en.wikipedia.org/wiki/Swedish_alphabet&quot; rel=&quot;nofollow noreferrer&quot;&gt;the Swedish alphabet&lt;/a&gt;, &amp;quot;ä&amp;quot; and &amp;quot;ö&amp;quot; are considered separate letters in their own right rather than accented versions of other letters; there is no umlaut as such in Swedish. The ASCII transliteration rule for German is simply incorrect for Swedish. For example, the Swedish name Ångström is best ASCII-ized as &amp;quot;Angstrom&amp;quot; not &amp;quot;Angstroem&amp;quot;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;a href=&quot;https://linux.die.net/man/1/iconv&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;iconv(1)&lt;/code&gt;&lt;/a&gt; to convert the file automatically.&lt;/p&gt;&#xA;&lt;p&gt;This is likely to do less damage to your file than a blind &lt;code&gt;vi&lt;/code&gt; substitution because the conversion routines were written by experts in the topic, who have thought through issues like the above and more.&lt;/p&gt;&#xA;&lt;p&gt;If your target is plain ASCII, you will have to use the &lt;a href=&quot;https://spin.atomicobject.com/2011/07/13/some-useful-iconv-functionality/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;//translit&lt;/code&gt;&lt;/a&gt; modifier, the &lt;code&gt;//ignore&lt;/code&gt; modifier, or the &lt;code&gt;-c&lt;/code&gt; flag to make this work. I recommend trying them in that order. For example, on the input text &amp;quot;Please coöperate with Jörg.&amp;quot;, &lt;code&gt;iconv -f utf-8 -t ascii//translit&lt;/code&gt; gives&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Please coo&amp;quot;perate with Jo&amp;quot;rg.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;as output. It is doing its best to show that the input text once had dots over the letters.&lt;/p&gt;&#xA;&lt;p&gt;A better plan would be to use an 8-bit extension to ASCII that also works on your system, such as &lt;a href=&quot;https://en.wikipedia.org/wiki/ISO/IEC_8859&quot; rel=&quot;nofollow noreferrer&quot;&gt;ISO 8859-1&lt;/a&gt;, which can encode the examples I've given so far directly: &lt;code&gt;iconv -f utf-8 -t iso-8851-1&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can use &lt;code&gt;iconv&lt;/code&gt; from within &lt;code&gt;vi&lt;/code&gt; using the various pipe commands. For example, to read a UTF-8-encoded file &lt;code&gt;x&lt;/code&gt; as ASCII into the current buffer:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:r !iconv -t ascii//translit x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or, you could open a file as Unicode, then mark a section of it using normal &lt;code&gt;vi&lt;/code&gt; commands (e.g. &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/visual.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim's &lt;code&gt;V&lt;/code&gt; block selection command&lt;/a&gt;) then convert it in place using &lt;code&gt;iconv&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!iconv -t ascii//translit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You don't have to type the first part if starting from a Vim block selection: the first character you type is the &lt;code&gt;!&lt;/code&gt;, and the rest is filled in automatically. You do have to type it all if using other types of &lt;code&gt;vi&lt;/code&gt; marks.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the Perl module &lt;a href=&quot;https://metacpan.org/pod/Text::Unidecode&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Text::Unidecode&lt;/code&gt;&lt;/a&gt; instead of &lt;code&gt;iconv&lt;/code&gt;. Because it isn't part of the Perl core, you'll have to &lt;a href=&quot;https://cpan.metacpan.org/modules/INSTALL.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;install it by hand&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Beware that it merely provides a different sort of &amp;quot;wrong&amp;quot; than &lt;code&gt;iconv //translit&lt;/code&gt;. Its documentation is well worth reading, particularly the section &amp;quot;&lt;a href=&quot;https://metacpan.org/pod/Text::Unidecode#WHEN-YOU-DON%27T-LIKE-WHAT-UNIDECODE-DOES&quot; rel=&quot;nofollow noreferrer&quot;&gt;When You Don't Like What Unidecode Does&lt;/a&gt;&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;You can use that from within Vim using this mapping in your &lt;code&gt;~/.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F6&amp;gt; !}perl -C -MText::Unidecode -ne 'print unidecode( $_)'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;F6&lt;/kbd&gt; will convert the current paragraph.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Asides:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Excepting &lt;a href=&quot;https://en.wikipedia.org/wiki/Loanword&quot; rel=&quot;nofollow noreferrer&quot;&gt;loanwords&lt;/a&gt;, of course.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Some people spell the word &amp;quot;co-operate&amp;quot; to side-step this problem.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There is no &amp;quot;ë&amp;quot; in German, so an &amp;quot;ö&amp;quot; → &amp;quot;oe&amp;quot; type of rule could not properly come into effect here anyway.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6852" LastEditorUserId="6852" LastEditDate="2021-06-29T03:30:09.443" LastActivityDate="2021-06-29T03:30:09.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17656" PostTypeId="1" CreationDate="2018-10-17T15:51:10.297" Score="5" ViewCount="907" Body="&lt;p&gt;I &quot;inherited&quot; a custom syntax script and I want to update it since it's a little out of date.&#xA;The text file for which the syntax highlighting is written contains several blocks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{Group1&#xA;key1 value1&#xA;key2 = value2&#xA;key3=value3&#xA;#A Comment&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What's going wrong:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, that only &lt;code&gt;key1 value1&lt;/code&gt; is highlighted correctly, i.e. if an &quot;=&quot; sign is present only the key is highlighted but not the value.&#xA;It seems like a trivial problem, but I could not manage to solve it for the last 3h (I should probably mention that this is my first syntax script).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming &lt;code&gt;key1&lt;/code&gt; is a boolean variable, the corresponding commands in the syntax file are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn case ignore&#xA;syn keyword groupkey key1 nextgroup=group1vars skipwhite&#xA;syn match group1vars &quot;true&quot; contained&#xA;syn match group1vars &quot;false&quot; contained&#xA;syn match groupcomment &quot;#.*$&quot;&#xA;syn region groupsection start=&quot;{&quot; end=&quot;}&quot; contains=groupkey,groupcomment&#xA;&#xA;&quot; Highlighting&#xA;hi def link groupcomment Comment&#xA;hi def link groupkey Type&#xA;hi def link group1vars Constant&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By the way, I'm pretty sure the guy who was working on it followed &lt;a href=&quot;http://vim.wikia.com/wiki/Creating_your_own_syntax_files&quot; rel=&quot;noreferrer&quot;&gt;this tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I think I understand why it is not working in case a &quot;=&quot; sign is in the same line: &lt;code&gt;nextgroup=&lt;/code&gt; tells the editor to look for a match after the specified keyword ignoring whitespace due to the &lt;code&gt;skipwhite&lt;/code&gt;. It works perfectly for &lt;code&gt;key1 value1&lt;/code&gt;, but as soon as there's an &quot;=&quot; in between no match is found and therefore no highlighting of &lt;code&gt;value2&lt;/code&gt; and &lt;code&gt;value3&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I would like to achieve:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Functioning highlighting of values even if there's an&#xA;equal sign present,&lt;/li&gt;&#xA;&lt;li&gt;preferably &lt;strong&gt;no&lt;/strong&gt; highlighting of the equal sign itself&lt;/li&gt;&#xA;&lt;li&gt;(optional) solution that's easily applicable for 100+ cases. For some&#xA;of the keys there are 30-50 values to choose from.&#xA;I'd like to avoid two versions for each value (one with and one without &#xA;equal sign), but if necessary I can always script it.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I tried:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Creating a specific match for the separator&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match groupsep &quot;=&quot; contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and adding it to &lt;code&gt;contains=&lt;/code&gt; of the region definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region groupsection start=&quot;{&quot; end=&quot;}&quot; contains=groupkey,groupcomment,groupsep&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, that had no effect, so I tried adding the separator match&#xA;to the keyword definition instead&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword groupkey key1 nextgroup=group1vars,groupsep skipwhite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which also showed no change. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;using &lt;code&gt;contains=&lt;/code&gt; in the keyword definition&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword groupkey key1 contains=group1vars,groupsep&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which threw me an error (apparently &lt;code&gt;contains=&lt;/code&gt; cannot be used with&#xA;&lt;code&gt;syn keyword&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;using a regular expression for the match, e.g. &lt;code&gt;&quot;=\=\s*true&quot;&lt;/code&gt;, which&#xA;did work, but also highlighted the equal sign in the same color (see &#xA;point 2). Also I feel it would be a bit of an overkill if I would have&#xA;to write it in front of every match.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have a feeling that the solution to my problem would be a nested match, i.e. the editor finds the keyword first, then tries to match &lt;code&gt;= value&lt;/code&gt; and finally matches &lt;code&gt;value&lt;/code&gt;, but unfortunately I have no idea how to write that. &#xA;Perhaps even the &lt;em&gt;keyword-then-match&lt;/em&gt; protocol has to be replaced by using matches only?&#xA;Or could it be possible to skip the &quot;=&quot; similar to how it is done with &lt;code&gt;skipwhite&lt;/code&gt;?&#xA;Does someone have an idea what strategy I should use here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated!&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="19425" LastActivityDate="2018-10-18T09:49:20.860" Title="Syntax highlighting of key = value pairs" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17659" PostTypeId="1" AcceptedAnswerId="17660" CreationDate="2018-10-17T21:12:46.810" Score="3" ViewCount="285" Body="&lt;p&gt;I've been going through &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;learn vim the hard way&lt;/a&gt;  and am currently adding abbreviations via autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've added the following to my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup outputs&#xA;    autocmd!&#xA;    autocmd FileType php        :iabbrev &amp;lt;buffer&amp;gt; sout echo &quot;&quot;;&#xA;    autocmd FileType javascript :iabbrev &amp;lt;buffer&amp;gt; sout console.log();&amp;lt;esc&amp;gt;hi&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works, but only for new files. If I edit an existing .js or .php file it uses a cached version(I'm assuming) of the command before I editted it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was under the impression autocmd! would clear any existing commands. I've also tried adding abclear or running :abclear neither of which are allowing changes to the abbreviations to work on existing files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additonal troubleshooting:&#xA;if I run :abbreviate on an existing file it shows the older version of the abbreviation.&#xA;However, doing :abclear or :unabbreviate sout does not remove the entry on :abbreviate&lt;/p&gt;&#xA;" OwnerUserId="19430" LastEditorUserId="19430" LastEditDate="2018-10-17T21:41:15.660" LastActivityDate="2018-10-17T22:35:15.197" Title="autocmd changes only applying to new files" Tags="|autocmd|abbreviations|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17660" PostTypeId="2" ParentId="17659" CreationDate="2018-10-17T22:29:44.333" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;If I edit an existing .js or .php file it uses a cached version(I'm assuming) of the command before I editted it.&#xA;  I was under the impression autocmd! would clear any existing commands.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd!&lt;/code&gt; will clear the autocmds in the current augroup, but it will not undo any abbreviation, command, mapping, match, option they installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To install your buffer-local abbreviation via your autocmd, you can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;reload the buffer by executing &lt;code&gt;:e&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;reassign the value of the &lt;code&gt;'filetype'&lt;/code&gt; option by executing &lt;code&gt;:let &amp;amp;ft=&amp;amp;ft&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;apply your autocmd manually by executing &lt;code&gt;:doautocmd outputs filetype&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Additonal troubleshooting: if I run :abbreviate on an existing file it shows the older version of the abbreviation. However, doing :abclear or :unabbreviate sout does not remove the entry on :abbreviate&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:abclear&lt;/code&gt;, and &lt;code&gt;:unabbreviate&lt;/code&gt;, will remove global abbreviations.&lt;br&gt;&#xA;If you want to remove the buffer-local ones instead, you should use the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; remove all buffer-local abbreviations&#xA;:abclear &amp;lt;buffer&amp;gt;&#xA;&#xA;&quot; remove all buffer-local abbreviations in insert mode only (but not in command-line mode)&#xA;:iabclear &amp;lt;buffer&amp;gt;&#xA;&#xA;&quot; remove all the 'sout' buffer-local abbreviations&#xA;:unabbreviate &amp;lt;buffer&amp;gt; sout&#xA;&#xA;&quot; remove the 'sout' buffer-local abbreviation in insert mode only&#xA;:iunabbrev &amp;lt;buffer&amp;gt; sout&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you don't want the rhs of your abbreviation to be affected by mappings, use the non-recursive version of &lt;code&gt;:iabbrev&lt;/code&gt;, i.e. &lt;code&gt;:inoreabbrev&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In the abbreviations table printed by &lt;code&gt;:abbreviate&lt;/code&gt;, you can check whether an abbreviation is local to a buffer and whether its rhs can be remapped by looking at the symbol(s) between the lhs and rhs.&lt;br&gt;&#xA;If you can read &lt;code&gt;@&lt;/code&gt;, it means the abbreviation is local to the buffer.&lt;br&gt;&#xA;If you can read &lt;code&gt;*&lt;/code&gt;, it means the rhs of the abbreviation can't be remapped.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could also move your abbreviations in filetype plugins.&lt;br&gt;&#xA;For javascript, you could use &lt;code&gt;~/.vim/after/ftplugin/javascript.vim&lt;/code&gt; and for php &lt;code&gt;~/.vim/after/ftplugin/php.vim&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a filetype plugin, you don't need autocmds anymore, you can write your abbreviations directly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoreabbrev &amp;lt;buffer&amp;gt; sout echo &quot;&quot;;&#xA;inoreabbrev &amp;lt;buffer&amp;gt; sout console.log();&amp;lt;esc&amp;gt;hi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, it would allow you to make Vim remove the abbreviations automatically if you changed the filetype of your buffer.&lt;br&gt;&#xA;To do that, you would need to include a command such as &lt;code&gt;:iunabbrev&lt;/code&gt; in &lt;code&gt;b:undo_ftplugin&lt;/code&gt; (see &lt;code&gt;:h undo_ftplugin&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')&#xA;    \ .(empty(get(b:, 'undo_ftplugin', '')) ? '' : '|')&#xA;    \ .&quot;&#xA;    \   exe 'iuna &amp;lt;buffer&amp;gt; sout'&#xA;    \ | exe 'iuna &amp;lt;buffer&amp;gt; ...'&#xA;    \ | ...&#xA;    \ &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-10-17T22:35:15.197" LastActivityDate="2018-10-17T22:35:15.197" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17661" PostTypeId="1" AcceptedAnswerId="17664" CreationDate="2018-10-18T00:08:36.197" Score="2" ViewCount="411" Body="&lt;p&gt;I want to create a simple notes file and manager it with vim. The system is really easy (plain text rules):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- [ ] new entry&#xA;- [x] done entry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well, in my &lt;code&gt;.vimrc&lt;/code&gt; I only have the keybind for add new entries, always on NORMAL MODE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map tn i- [ ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I can't create a keybind for to remplace &lt;code&gt;- []&lt;/code&gt; for &lt;code&gt;- [x]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to make it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S.: I found a guide with a commands with similar behavior (but here add the date, useful for someone):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; check off a todo item and time stamp it&#xA;map gd ^rx: &amp;lt;Esc&amp;gt;:r! date +&quot; [\%H:\%M]&quot;&amp;lt;ENTER&amp;gt;kJA&amp;lt;Esc&amp;gt;$&#xA;&quot; create a new todo item&#xA;map gt &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19432" LastActivityDate="2018-10-23T06:33:52.400" Title="Create a custom keybind for a notes file on vim" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17662" PostTypeId="2" ParentId="17661" CreationDate="2018-10-18T04:02:50.360" Score="2" Body="&lt;p&gt;I started by suggesting you use the first part of the example command you included since it does what you want but it's totally broken as far as I can tell...certainly it's not compatible with your format. So let's see what we can do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you accomplish the same thing manually if the cursor was somewhere on the line you want to &quot;check&quot;? This is one way: &lt;code&gt;02f rx&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; :: Move cursor to the beginning of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2f&lt;/code&gt; :: Go forward to the second occurrence of Space&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;rx&lt;/code&gt; :: Change the character under the cursor to 'x'.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These are all done while in &quot;Normal mode&quot;. How do we create mappings that are available in Normal mode? With &lt;code&gt;:nmap&lt;/code&gt;. Or, more precisely, with this variation of that command: &lt;code&gt;:nnoremap&lt;/code&gt; (see paragraph under &lt;code&gt;:h :nnoremap&lt;/code&gt; for explanation)...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap \x 02f rx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's it. Or not. It would be nice to do nothing if there's already a 'x' in the column...or if we're not even on an item type of line...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here's a better command: &lt;code&gt;:s/^- \[\zs /x/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a substituion that replaces the character in the &quot;check&quot; column with &lt;code&gt;x&lt;/code&gt;...but only if there's a space there. Otherwise it does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pattern is a little mysterious so here's a breakdown:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; :: match the beginning of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;- \[&lt;/code&gt; :: eat up the three characters that start an item&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs&lt;/code&gt; :: this says that we don't actually do substitution against characters that have been matched before this point&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&lt;/code&gt; :: match a space&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Mapping it, again with &lt;code&gt;:nnoremap&lt;/code&gt;, we just need to &quot;hit Enter&quot; (&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;) at the end...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap \x :s/^- \[\zs /x/&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For good measure, here's a mapping to do the reverse (&quot;un-check&quot; an item):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap \o :s/^- \[\zsx/ /&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can, of course, use whatever unassigned keys you want in place of &lt;code&gt;\x&lt;/code&gt; and &lt;code&gt;\o&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-10-18T17:11:58.220" LastActivityDate="2018-10-18T17:11:58.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17664" PostTypeId="2" ParentId="17661" CreationDate="2018-10-18T09:48:51.557" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Now, I can't create a keybind for to remplace &lt;code&gt;- []&lt;/code&gt; for &lt;code&gt;- [x]&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;x :s/^- \[\]/\- \[x\]/&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; is by default &lt;code&gt;\&lt;/code&gt;, so if you didn't make any change to it than put your cursor on the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- [] hello world&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and press &lt;code&gt;\x&lt;/code&gt; to make it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- [x] hello world&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the following you will be able to toggle &lt;code&gt;x&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ToggleCheckBox()&#xA;    if getline('.') =~ '^- \[\]'&#xA;        :s/^- \[\]/\- \[x\]/&#xA;    elseif getline('.') =~ '^- \[x\]'&#xA;        :s/^- \[x\]/- \[\]/&#xA;    endif&#xA;endfun&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;x :call ToggleCheckBox()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PPS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I end up using the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! ListToggleCheckBox()&#xA;    let rx_bullets = '^\(\s*[-*]\+\s*\)'&#xA;    let rx_empty_checkbox = '\(\s*\[ \?\]\+\s*\)'&#xA;    let rx_marked_checkbox = '\(\s*\[[Xx]\]\+\s*\)'&#xA;    let line = getline('.')&#xA;    if line =~ rx_bullets &amp;amp;&amp;amp; line !~ rx_bullets.rx_empty_checkbox.'\|'.rx_marked_checkbox&#xA;        exe ':s/'.rx_bullets.'/\1\[ \] /'&#xA;    elseif line =~ rx_bullets.rx_empty_checkbox&#xA;        exe ':s/'.rx_bullets.rx_empty_checkbox.'/\1\[x\] /'&#xA;    elseif line =~ rx_bullets.rx_marked_checkbox&#xA;        exe ':s/'.rx_bullets.rx_marked_checkbox.'/\1\[ \] /'&#xA;    endif&#xA;endfun&#xA;&#xA;command! ListToggleCheckBox :call ListToggleCheckBox()&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;x :ListToggleCheckBox&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;work for the list items starting with &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;**(*)&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;if no checkboxes, it will create empty one&lt;/li&gt;&#xA;&lt;li&gt;otherwise it toggles them between &lt;code&gt;[ ]&lt;/code&gt; and &lt;code&gt;[x]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2018-10-23T06:33:52.400" LastActivityDate="2018-10-23T06:33:52.400" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="17665" PostTypeId="2" ParentId="17656" CreationDate="2018-10-18T09:49:20.860" Score="2" Body="&lt;p&gt;This set of syntax rules:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn case ignore&#xA;syn region assignment oneline matchgroup=groupkey start=/\k\+\(\s*[[:space:]=]\)\@=/ skip=/\s*=\s*/ matchgroup=groupval end=/\S.*/&#xA;syn match groupcomment &quot;#.*$&quot;&#xA;syn region groupsection start=&quot;{&quot; end=&quot;}&quot; contains=assignment,groupcomment&#xA;&#xA;&quot; Highlighting&#xA;hi! link groupcomment Comment&#xA;hi! link groupkey Type&#xA;hi! link groupval Constant&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Provides this highlighting for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WqHNK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WqHNK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I threw out the existing key/val settings, and used a new match for assignments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region assignment oneline matchgroup=groupkey start=/\k\+\(\s*[[:space:]=]\)\@=/ skip=/\s*=\s*/ matchgroup=groupval end=/\S.*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;groupkey&lt;/code&gt; is used for highlighting the key:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;which is a string of keyword characters (&lt;code&gt;\k\+&lt;/code&gt;) followed by&lt;/li&gt;&#xA;&lt;li&gt;at least a space or an &lt;code&gt;=&lt;/code&gt; (&lt;code&gt;\s*[[:space:]=]&lt;/code&gt;) with zero-width lookahead (&lt;code&gt;\@=&lt;/code&gt;), to keep this delimiting space/&lt;code&gt;=&lt;/code&gt; outside the key.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;any space and &lt;code&gt;=&lt;/code&gt; in the middle are skipped&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;groupval&lt;/code&gt; highlights the value, which is a non-whitespace character followed by anything.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-10-18T09:49:20.860" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17667" PostTypeId="1" AcceptedAnswerId="17716" CreationDate="2018-10-18T20:34:04.417" Score="1" ViewCount="765" Body="&lt;p&gt;Result of auto-indent in vim (filetype indent on)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;main() {&#xA;    case $1 in  &#xA;        --ssh)&#xA;        echo &quot;sshing into ${aws_ips[$1]}&quot;&#xA;        ssh -i VPN_NODE_1.pem ${aws_ips[$1]}&#xA;    ;;  &#xA;    --scp)&#xA;        echo &quot;scping $2 from ${aws_ips[$1]} to $3&quot;&#xA;        scp -r -i VPN_NODE_1.pem ${aws_ips[$1]}:$2 $3  &#xA;        ;;  &#xA;    esac &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;main()&#xA;{&#xA;    case $1 in  &#xA;        --ssh)&#xA;            echo &quot;sshing into ${aws_ips[$1]}&quot;&#xA;            ssh -i VPN_NODE_1.pem ${aws_ips[$1]}&#xA;            ;;&#xA;        --scp)&#xA;            echo &quot;scping $2 from ${aws_ips[$1]} to $3&quot;&#xA;            scp -r -i VPN_NODE_1.pem ${aws_ips[$1]}:$2 $3&#xA;            ;;&#xA;    esac&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: My original post was &lt;em&gt;incorrect&lt;/em&gt;. I was not using filetype indent on in my .vimrc, I was using it in the vim command prompt&lt;/p&gt;&#xA;" OwnerUserId="19448" LastEditorUserId="19448" LastEditDate="2018-10-25T13:45:28.970" LastActivityDate="2018-10-25T13:45:28.970" Title="Incorrect auto-indent bash" Tags="|indentation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17668" PostTypeId="1" CreationDate="2018-10-18T21:14:06.160" Score="3" ViewCount="1280" Body="&lt;p&gt;There is a bit in YouCompleteMe that I do not understanding. It is the following bit from the documentation:&#xA;&lt;a href=&quot;https://github.com/Valloric/YouCompleteMe#configuring-through-vim-options&quot; rel=&quot;nofollow noreferrer&quot;&gt;Configuring through Vim Options&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;--- EDIT ---&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to clarify the question: How different is the &quot;&lt;em&gt;Configuring through Vim Options&lt;/em&gt;&quot; approach to &quot;&lt;em&gt;Having a &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt; inside your project's root&lt;/em&gt;&quot; approach?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you please help me understand the mechanics and the purpose behind this &lt;code&gt;client_data&lt;/code&gt; and the concept of &quot;configuring through vim options.&quot;&lt;/p&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="205" LastEditDate="2018-10-19T19:37:26.913" LastActivityDate="2018-10-19T19:39:21.320" Title="Understanding YouCompleteMe's 'Configuring through Vim Options' Mechanics" Tags="|plugin-you-complete-me|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17669" PostTypeId="1" CreationDate="2018-10-18T23:57:52.533" Score="1" ViewCount="51" Body="&lt;p&gt;How can 2-space indenting be shown as 6 column tab-style indents when editing, while remaining as 2-spaces?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Background:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a team uses a convention of 2 spaces for indenting code&lt;/li&gt;&#xA;&lt;li&gt;I prefer indenting of 6 columns (and in my own separate work OUTSIDE this project use tab characters)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have attempted something like:&#xA;&lt;code&gt;autocmd BufNewFile,BufRead **project*/*,*project* setlocal expandtab shiftwidth=2 softtabstop=2 tabstop=6 autoindent&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;restated:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;2-real-space-characters&amp;gt;teh code&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;should show as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;6-space-characters, so 3x more indentation visually&amp;gt;teh code&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot figure out how to have 2-space indenting display as 6 columns for greater code-block differentiation, if this is even possible. Thanks for any answers, comments, redirects, insights shared.&lt;/p&gt;&#xA;" OwnerUserId="15878" LastActivityDate="2018-10-18T23:57:52.533" Title="expandtab tab as 2 spaces show visually as 6 columns" Tags="|indentation|formatting|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17670" PostTypeId="2" ParentId="17668" CreationDate="2018-10-19T09:32:54.067" Score="3" Body="&lt;p&gt;So, I did a bit of research and they were very helpful at the YouCompleteMe gist chat room. Here is what I know now. Also this is probably only python-completion specific, but I am sure the mechanics are applicable to all kind of completion tasks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Answer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;YouCompleteMe offers two ways to pass data to the completer engine:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Through a &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt; located inside your project.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Through a global &lt;code&gt;global_extra_conf.py&lt;/code&gt; file that provides hooks so that you can take care of what goes into the completer yourself (the name of the file is something you define and can be anything, see below).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The confusing bit here was that I was not able to understand how the second (2) scenario works. This second case is known as the &lt;em&gt;&lt;a href=&quot;https://github.com/Valloric/YouCompleteMe#configuring-through-vim-options&quot; rel=&quot;nofollow noreferrer&quot;&gt;Configuring through Vim options&lt;/a&gt;&lt;/em&gt; approach. So here it is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You set this up at VIM start up (in your &lt;code&gt;.vimrc&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_python_interpreter_path = ''&#xA;let g:ycm_python_sys_path = []&#xA;let g:ycm_extra_conf_vim_data = [&#xA;  \  'g:ycm_python_interpreter_path',&#xA;  \  'g:ycm_python_sys_path'&#xA;  \]&#xA;let g:ycm_global_ycm_extra_conf = '~/global_extra_conf.py'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The lines above prepare your hooks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the above example, the most important bit is the &lt;code&gt;g:ycm_extra_conf_vim_data&lt;/code&gt; variable. The other variables, &lt;code&gt;g:ycm_python_interpreter_path&lt;/code&gt; and &lt;code&gt;g:ycm_python_sys_path&lt;/code&gt;, you can name them whatever you want, as long as you keep it consistent across your workflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now you have two access points, whatever goes into these variables (&lt;code&gt;g:ycm_python_interpreter_path&lt;/code&gt;, &lt;code&gt;g:ycm_python_sys_path&lt;/code&gt;) gets passed to the completer engine through the &lt;code&gt;client_data[]&lt;/code&gt; API. This API bridging happens inside the global configuration file that you have defined in the stage above, the one called &lt;code&gt;~/global_extra_conf.py&lt;/code&gt;. The following is what goes into your &lt;code&gt;~/global_extra_conf.py&lt;/code&gt; file. This is from the &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe#configuring-through-vim-options&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; by the way.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def Settings( **kwargs ):&#xA;  client_data = kwargs[ 'client_data' ]&#xA;  return {&#xA;    'interpreter_path': client_data[ 'g:ycm_python_interpreter_path' ],&#xA;    'sys_path': client_data[ 'g:ycm_python_sys_path' ]&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's all, you are all set. So now, ever time you load your project (well, this case study is focusing on a python workflow - so, every time you load your python project), you can set the &lt;code&gt;g:ycm_python_interpreter_path&lt;/code&gt; to your virtual environment's or your project's python binary. And if you need any third party modules that are outside your project's python binary's scope, you can introduce them through the &lt;code&gt;g:ycm_python_sys_path&lt;/code&gt; variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please do not forget, this case is only if you would like to NOT have a &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt; file in the root of every one of your projects. This gives you the flexibility to manage what you pass to the completer yourself, on the fly, without dealing with extra config files. So you just do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ycm_python_interpreter_path='/some/path/to/my/project's/python'&#xA;let g:ycm_python_sys_path='/some/path/to/a/third/party/module'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you sould get the completion working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;One Important Thing&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first mistake I made, when I was looking into this, was that I tried to work with the &lt;code&gt;g:ycm_server_python_interpreter&lt;/code&gt; option, thinking that this was what was controlling the scope of my autocompletion. THAT IS NOT THE CASE! The &lt;code&gt;g:ycm_server_python_interpreter&lt;/code&gt; option is designed to guide ycm when it comes to choosing the python used to run the actual completer, it has nothing to do with the completion scope and the completion process itself. In most cases, you will not be even touching that option. I used the &lt;code&gt;g:ycm_server_python_interpreter&lt;/code&gt; option only once, when YouCompleteMe has accidentally picked my System Python on OSX. My MacVim relied on a different Python and this was causing YouCompleteMe to crash. I updated the &lt;code&gt;g:ycm_server_python_interpreter&lt;/code&gt; option to point to the correct python and that fixed my issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What we are using here is &lt;code&gt;g:ycm_python_interpreter_path&lt;/code&gt; and this is a variable we have named ourselves anyway. Just keep that in mind :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;One Final Important Thing&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pyhton that is used to run YouCompleteMe, has nothing to do with your project's python scope. My MacVim and YouCompleteMe python is the same install with no extra modules in there. But when I work on a project, I usually work with a python that has many modules installed in there, possibly even a totally different python version. These two python scopes are enterly different, please make sure to understand that bit very well, it will save you some pain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this was helpful.&lt;/p&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="205" LastEditDate="2018-10-19T19:39:21.320" LastActivityDate="2018-10-19T19:39:21.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17672" PostTypeId="1" CreationDate="2018-10-19T13:30:16.277" Score="2" ViewCount="291" Body="&lt;p&gt;I am running an Ubuntu Subsystem for Windows 10. Within Ubuntu, I worked on a small file via vim and backgrounded it (&lt;code&gt;CTRL-Z&lt;/code&gt;) and foregrounded it (&lt;code&gt;% job #&lt;/code&gt;) multiple times over a couple day period. Out of nowhere I was alerted by Windows to running out of Disk Space. Upon investigating, it turned out the swap file for the file I worked on had grown to 187 GB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I understand, vim creates a swap file to keep track of changes in the event that it crashes; but, there's no way it could have contained that many changes! For my own edification/knowledge, I am hoping to get possible explanations for how this could have happened. Ideally, I could then try to recreate it.&lt;/p&gt;&#xA;" OwnerUserId="19457" LastEditorUserId="1841" LastEditDate="2018-10-19T14:19:20.953" LastActivityDate="2018-10-19T14:19:20.953" Title="Vim Swap File Became 187 GB, What are Possible Explanations?" Tags="|swap-file|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17673" PostTypeId="1" AcceptedAnswerId="17680" CreationDate="2018-10-19T21:22:44.150" Score="3" ViewCount="117" Body="&lt;p&gt;I'm trying to setup a simple environment which would allow me to work on a local file and it's remote counterpart.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both files are accessible on my filesystem. So let's say I have :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;File 1 : /home/john/petshop/categories/animals/fluffy/cats.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;File 2 : /mnt/sshfs/petshop/categories/animals/fluffy/cats.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once I have File 1 opened in vim, how can I quickly open file 2 without having to type out the whole path ? I'd prefer an answer that doesn't involve a fuzzy finder.&lt;/p&gt;&#xA;" OwnerUserId="19461" LastActivityDate="2018-10-20T19:41:35.550" Title="How can I easily open two similar files?" Tags="|multiple-files|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17674" PostTypeId="2" ParentId="17673" CreationDate="2018-10-19T21:49:59.237" Score="3" Body="&lt;p&gt;You can get the full path of the file you're editing with &lt;code&gt;expand('%:p')&lt;/code&gt;. Unfortunately, we need to edit the path slightly, so this isn't enough on its own, but it gets us closer to where we're going. We need to evaluate that vimscript and put it into the command line as text so we could edit it. Thankfully, we have the &lt;a href=&quot;https://stackoverflow.com/a/7029030/3524982&quot;&gt;expression register&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I would do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Open up the command line, and start off your command with &lt;code&gt;:e&amp;lt;space&amp;gt;&lt;/code&gt;. Now press &lt;kbd&gt;ctrl-r&lt;/kbd&gt; &lt;kbd&gt;=&lt;/kbd&gt; to open up the expression register. You should see an &lt;code&gt;=&lt;/code&gt; where you normally see the colon.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Type &lt;code&gt;expand('%:p')&lt;/code&gt; and press &lt;kbd&gt;Enter&lt;/kbd&gt;. You should now see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e /home/john/petshop/categories/animals/fluffy/cats.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your command line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the arrow keys (or &lt;kbd&gt;ctrl+left&lt;/kbd&gt;) to navigate to the beginning of the path, and edit it to the path you want, then press enter.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I decided that this is something really useful, so I'd like to have it in my config as well. While creating a mapping for it, I realized you could do something much simpler if you use an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping. I did this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;F &quot;:e &quot;.expand('%:p')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Of course, you can pick whatever you want in place of &lt;code&gt;&amp;lt;leader&amp;gt;F&lt;/code&gt;) This works be evaluating everything after the mapping as a string, and returning those keystrokes as if you typed them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;:e &quot;&lt;/code&gt; Obviously corresponds to &lt;code&gt;:e&amp;lt;space&amp;gt;&lt;/code&gt; since that's the beginning of the command you'll use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.&lt;/code&gt; is the string concatenation operator&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;expand('%:p')&lt;/code&gt; evaluates to the full path like before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is overall simpler since it doesn't require the &lt;code&gt;&quot;=&lt;/code&gt; register.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2018-10-20T19:13:28.927" LastActivityDate="2018-10-20T19:13:28.927" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17675" PostTypeId="1" AcceptedAnswerId="17727" CreationDate="2018-10-19T22:12:48.640" Score="3" ViewCount="10237" Body="&lt;p&gt;I have two tabs open, file1.txt and file2.txt, each with different content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I copy the whole content of file1.txt and overwrite file2.txt with it, resulting in both files having the same content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is obviously doable with yanking manually, but I figured there's probably a nice combo that does it all in one go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; : Based on &lt;a href=&quot;https://vi.stackexchange.com/a/17727/19461&quot;&gt;Rich's answer&lt;/a&gt;, I ended up doing this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; SplitOverwrite()&#xA;&quot; Yanks all content of the current window and pastes it &#xA;&quot; into the adjascent window, overwriting all existing content&#xA;function! SplitOverwrite()&#xA;&#xA;    &quot; Yank the whole file content&#xA;    %yank&#xA;&#xA;    &quot; Move cursor to the window right&#xA;    wincmd w&#xA;&#xA;    &quot; Delete the whole file content&#xA;    %delete&#xA;&#xA;    &quot; Puts the text from register O after the current line&#xA;    put 0&#xA;&#xA;    &quot; Deletes the first (empty) line of the file&#xA;    1delete&#xA;&#xA;    &quot; Save the file&#xA;    w&#xA;&#xA;    &quot; Short version&#xA;    &quot;%y|winc w|%d|pu0|1d|w&#xA;&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;so :call SplitOverwrite()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19461" LastEditorUserId="19461" LastEditDate="2018-10-29T20:40:34.117" LastActivityDate="2018-10-31T07:50:35.363" Title="How can I overwrite a whole file with the content of another?" Tags="|cut-copy-paste|multiple-files|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17676" PostTypeId="2" ParentId="17675" CreationDate="2018-10-19T23:39:51.660" Score="3" Body="&lt;p&gt;From the &lt;code&gt;file1.txt&lt;/code&gt; buffer, say &lt;code&gt;:w! file2.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then either:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;In the &lt;code&gt;file2.txt&lt;/code&gt; buffer, say &lt;code&gt;:e!&lt;/code&gt; to manually reload that buffer with the new content.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use one of the &quot;autoread&quot; plugins to make Vim do this automatically and reliably: [&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=5206&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;] [&lt;a href=&quot;https://github.com/djoshea/vim-autoread&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;]&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6852" LastEditorUserId="6852" LastEditDate="2018-10-22T13:24:44.063" LastActivityDate="2018-10-22T13:24:44.063" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17677" PostTypeId="2" ParentId="17493" CreationDate="2018-10-20T04:57:36.697" Score="3" Body="&lt;p&gt;You indicate that you were trying to get the mapping to work with &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;. Though the answer you accepted is just fine I'm surprised no one answered with a corrected use of that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally the string on the RHS of a mapping is executed  literally as an Ex command. No pre- expansion/evaluation/processing of the string occurs. So &lt;code&gt;:match&lt;/code&gt; in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;F5&amp;gt; :match StatusLineTerm /.expand(&amp;lt;cword&amp;gt;)./&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(along the lines of your attempt) will try to literally match the string '&lt;i&gt;.expand(&amp;lt;cword&gt;).&lt;/i&gt;'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we want the string or some portion of it to be expanded/evaluated we have to do it ourselves by passing it to the &lt;code&gt;:exec&lt;/code&gt; command as an expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec 'match StatusLineTerm /' . expand('&amp;lt;cword&amp;gt;') . '/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that we surround with quotes any parts that we want to use literally and append them with &lt;code&gt;.&lt;/code&gt;. The rest is evaluated. (Also note that &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; is a special string and needs to be quoted before being passed to &lt;code&gt;expand()&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the mapping you were originally going for is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;F5&amp;gt; :exec 'match StatusLineTerm /' . expand('&amp;lt;cword&amp;gt;') . '/'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-10-20T04:57:36.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17678" PostTypeId="1" AcceptedAnswerId="17687" CreationDate="2018-10-20T11:36:05.173" Score="6" ViewCount="566" Body="&lt;p&gt;Is it possible to narrow the text to a region, or function, and widen it as needed, as is possible in emacs via &lt;code&gt;narrow-to-region&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="19357" LastActivityDate="2018-10-22T05:38:06.740" Title="Emacs like narrow to region" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17680" PostTypeId="2" ParentId="17673" CreationDate="2018-10-20T19:41:35.550" Score="5" Body="&lt;p&gt;Some characters are special on Vim's command-line (see &lt;code&gt;:h cmdline-special&lt;/code&gt;), including &lt;code&gt;%&lt;/code&gt; which is automatically replaced by the path to the current file relative to the current working directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of them may be followed by filename-modifiers (see &lt;code&gt;:h filename-modifiers&lt;/code&gt;).&#xA;Those can be combined, and among them are &lt;code&gt;:p&lt;/code&gt; which makes Vim expands &lt;code&gt;%&lt;/code&gt; into an absolute file path instead of a relative one, and &lt;code&gt;:s?pat?rep?&lt;/code&gt; which allows you to replace a pattern with an arbitrary replacement string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This could be useful in your case to make Vim replace &lt;code&gt;/home/john&lt;/code&gt; with &lt;code&gt;/mnt/sshfs&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e %:p:s?/home/john?/mnt/sshfs?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that if the pattern or the replacement contains a question mark, you can use another delimiter between the fields of the substitution command, like &lt;code&gt;;&lt;/code&gt; for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e %:p:s;/home/john;/mnt/sshfs;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, the substitution will only affect the first occurrence of the pattern.&#xA;If you need to replace all of them, use &lt;code&gt;gs&lt;/code&gt; (the &lt;code&gt;g&lt;/code&gt; is for &lt;code&gt;Global&lt;/code&gt;) instead of &lt;code&gt;s&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e %:p:gs?/home/john?/mnt/sshfs?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2018-10-20T19:41:35.550" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17681" PostTypeId="1" AcceptedAnswerId="17683" CreationDate="2018-10-21T07:43:22.613" Score="0" ViewCount="532" Body="&lt;p&gt;Currently I have the line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;c :w&amp;lt;CR&amp;gt;:!arara %&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;$MYVIMRC&lt;/code&gt;. If I press &lt;code&gt;&amp;lt;leader&amp;gt;c&lt;/code&gt;, it will save the current file and run the command &lt;code&gt;arara&lt;/code&gt; on it. However I would like its behavior to be the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;Save the current file&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;IF the first line has the form &quot;%!TeX root = &amp;lt;something&amp;gt;&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;THEN run the command &quot;arara &amp;lt;something&amp;gt;&quot; instead&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ELSE run &quot;arara &amp;lt;current file&amp;gt;&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For this it is required that vim reads the first line of the current file to process it in a command. I don't know how or &lt;em&gt;if&lt;/em&gt; this is possible since I am rather new to vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above behavior is rather standard in TeX editors and I would like to emulate it in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case it is important, I am using neovim rather than plain vim.&lt;/p&gt;&#xA;" OwnerDisplayName="user17723" LastActivityDate="2018-10-21T09:34:53.347" Title="Read the first line of the current file to process it in a command (Emulating %TeX root)" Tags="|vimrc|vimscript|neovim|filetype-tex|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17682" PostTypeId="1" CreationDate="2018-10-21T07:51:14.790" Score="0" ViewCount="502" Body="&lt;p&gt;Randomly, my &lt;code&gt;nvim&lt;/code&gt; will hang.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally, it seems to happen in command mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The latest one has hung with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set paste! paste?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the status line. I have &lt;code&gt;map &amp;lt;F2&amp;gt; :set paste! paste?&amp;lt;CR&amp;gt;&lt;/code&gt; and I just pressed &lt;kbd&gt;F2&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this is just one example: it happens seemingly randomly, sometimes on cursor movement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When hung, there is always a 100% CPU usage by the process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This doesn't tell me too much:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% sudo strace -fs200 -p 18878  |&amp;amp; uniq&#xA;strace: Process 18878 attached with 2 threads&#xA;strace: [ Process PID=18878 runs in x32 mode. ]&#xA;[pid 18894] epoll_pwait(15, strace: [ Process PID=18878 runs in 64 bit mode. ]&#xA; &amp;lt;unfinished ...&amp;gt;&#xA;[pid 18878] epoll_pwait(9, [], 1024, 0, NULL, 8) = 0&#xA;[pid 18878] madvise(0x7f54d8401000, 33562624, MADV_FREE) = 0&#xA;[pid 18878] madvise(0x7f54d8401000, 33562624, MADV_DONTNEED) = 0&#xA;[pid 18878] epoll_pwait(9, [], 1024, 0, NULL, 8) = 0&#xA;[pid 18878] madvise(0x7f54d7400000, 16781312, MADV_FREE) = 0&#xA;[pid 18878] epoll_pwait(9, [], 1024, 0, NULL, 8) = 0&#xA;[pid 18878] madvise(0x7f54d8401000, 33562624, MADV_FREE) = 0&#xA;[pid 18878] madvise(0x7f54d8401000, 33562624, MADV_DONTNEED) = 0&#xA;[pid 18878] epoll_pwait(9, [], 1024, 0, NULL, 8) = 0&#xA;[pid 18878] madvise(0x7f54d7400000, 16781312, MADV_FREE) = 0&#xA;[pid 18878] epoll_pwait(9, [], 1024, 0, NULL, 8) = 0&#xA;[pid 18878] madvise(0x7f54d8401000, 33562624, MADV_FREE) = 0&#xA;[pid 18878] madvise(0x7f54d8401000, 33562624, MADV_DONTNEED) = 0&#xA;[... &amp;lt;repeats&amp;gt;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I checked out fd 9 in &lt;code&gt;/proc/$PID/fd&lt;/code&gt;, and it was: &lt;code&gt;9 -&amp;gt; 'anon_inode:[eventpoll]'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can have nvim dump stack?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I debug what is causing neovim to hang when it won't respond to any key presses?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd prefer to avoid needing to bisect through all my plugins to find out what's causing it. The random element means not knowing if I've waited long to declare a particular set of plugins &quot;good&quot;.&lt;/p&gt;&#xA;" OwnerUserId="5324" LastEditorUserId="5324" LastEditDate="2018-10-21T08:00:42.013" LastActivityDate="2018-10-27T07:21:56.737" Title="Cause of random hangs" Tags="|neovim|debugging|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17683" PostTypeId="2" ParentId="17681" CreationDate="2018-10-21T08:21:26.813" Score="0" Body="&lt;p&gt;Following command assumes that &lt;code&gt;%!TeX root = &amp;lt;mainfile with path&amp;gt;&lt;/code&gt; is in the first line&lt;br&gt;&#xA;(and it does not contain a second &lt;code&gt;=&lt;/code&gt; in &lt;code&gt;&amp;lt;mainfile with path&amp;gt;&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;c :w&amp;lt;CR&amp;gt;:!arara &amp;lt;C-r&amp;gt;=trim(split(getline(1), '=')[1])&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without extensive testing, following matches the first line against &lt;code&gt;'\ctexroot'&lt;/code&gt; (&lt;code&gt;\c&lt;/code&gt; means ignore case) and chooses accordingly the argument for arara:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Myarara()&#xA;    if match(getline(1), '\ctex root') &amp;gt;= 0&#xA;        echo system(&quot;arara &quot;.trim(split(getline(1), '=')[1]))&#xA;    else&#xA;        echo system(&quot;arara &quot;.@%)&#xA;    endif&#xA;endfunction&#xA;nnoremap &amp;lt;leader&amp;gt;c :w&amp;lt;CR&amp;gt;:call Myarara()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I personally would not be satisfied with this for following reasons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;no use of quickfix list and error parsing (if you are not interested in this, you could use something like &lt;a href=&quot;https://emcrisostomo.github.io/fswatch/&quot; rel=&quot;nofollow noreferrer&quot;&gt;fswatch&lt;/a&gt; or &lt;a href=&quot;http://entrproject.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;entr&lt;/a&gt; in the shell which means you are not blocked in vim, no need for a normal mode mapping, a simple &lt;code&gt;:w&lt;/code&gt; is enough)&lt;/li&gt;&#xA;&lt;li&gt;it blocks vim while running (compiling latex documents can take a while)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would consider using one of &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt;, &lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-dispatch&lt;/a&gt;, or &lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;asyncrun.vim&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-10-21T09:34:53.347" LastActivityDate="2018-10-21T09:34:53.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17684" PostTypeId="2" ParentId="10988" CreationDate="2018-10-21T09:55:15.017" Score="11" Body="&lt;p&gt;I followed this script (&lt;a href=&quot;https://www.reddit.com/r/vim/comments/6jcyfj/toggle_lexplore_properly/djdmsal/&quot; rel=&quot;noreferrer&quot;&gt;https://www.reddit.com/r/vim/comments/6jcyfj/toggle_lexplore_properly/djdmsal/&lt;/a&gt;) and it works as expected.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:NetrwIsOpen=0&#xA;&#xA;function! ToggleNetrw()&#xA;    if g:NetrwIsOpen&#xA;        let i = bufnr(&quot;$&quot;)&#xA;        while (i &amp;gt;= 1)&#xA;            if (getbufvar(i, &quot;&amp;amp;filetype&quot;) == &quot;netrw&quot;)&#xA;                silent exe &quot;bwipeout &quot; . i &#xA;            endif&#xA;            let i-=1&#xA;        endwhile&#xA;        let g:NetrwIsOpen=0&#xA;    else&#xA;        let g:NetrwIsOpen=1&#xA;        silent Lexplore&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot; Add your own mapping. For example:&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;C-E&amp;gt; :call ToggleNetrw()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19477" LastEditorUserId="19477" LastEditDate="2018-10-21T11:19:16.933" LastActivityDate="2018-10-21T11:19:16.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17686" PostTypeId="1" AcceptedAnswerId="17688" CreationDate="2018-10-22T04:15:03.570" Score="5" ViewCount="1345" Body="&lt;p&gt;When I add &lt;code&gt;\textbf{}&lt;/code&gt; or &lt;code&gt;\textit{}&lt;/code&gt; before a word in &lt;code&gt;vimtex&lt;/code&gt; the terminal shows the word but strangely hides the commands. I can only see them in the visual mode (see pictures below). Is there a way to force vim to always show &lt;code&gt;\emph{}&lt;/code&gt; before the text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Vim 8.1 on iTerm2 with the gruvbox theme if that's helpful. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ga9Up.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ga9Up.png&quot; alt=&quot;This is what vimtex shows in insert/normal mode&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AU689.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AU689.png&quot; alt=&quot;This is what I see in visual mode&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19102" LastEditorUserId="1292" LastEditDate="2020-01-02T23:03:57.830" LastActivityDate="2020-01-02T23:03:57.830" Title="How to force vimtex to display \textbf and \textit in insert/normal mode?" Tags="|filetype-tex|conceal|plugin-vimtex|iterm2|" AnswerCount="2" CommentCount="0" ClosedDate="2020-01-05T01:46:46.337" ContentLicense="CC BY-SA 4.0" />
  <row Id="17687" PostTypeId="2" ParentId="17678" CreationDate="2018-10-22T05:38:06.740" Score="2" Body="&lt;p&gt;Thank you hotsche for user938271 for guiding me in the right direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NarrwRgn is the plugin that did the trick for me. It's very simple to use: &lt;a href=&quot;https://vimawesome.com/plugin/nrrwrgn&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vimawesome.com/plugin/nrrwrgn&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="19357" LastActivityDate="2018-10-22T05:38:06.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17688" PostTypeId="2" ParentId="17686" CreationDate="2018-10-22T06:43:10.247" Score="8" Body="&lt;p&gt;This is not due to &lt;code&gt;vimtex&lt;/code&gt; directly, but due to the conceal feature in Vim. &lt;code&gt;vimtex&lt;/code&gt; only adds to the syntax plugin that ships with Vim/neovim, and it adhers to the relevant option, see &lt;code&gt;:help g:tex_conceal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For direct control of the conceal feature itself, see &lt;code&gt;:help conceallevel&lt;/code&gt;, &lt;code&gt;:help concealcursor&lt;/code&gt; and &lt;code&gt;:help syn-conceal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Short answer, you can put the following in your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; To prevent conceal in LaTeX files&#xA;let g:tex_conceal = ''&#xA;&#xA;&quot; To prevent conceal in any file&#xA;set conceallevel = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-10-22T06:43:10.247" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17689" PostTypeId="1" AcceptedAnswerId="17690" CreationDate="2018-10-22T12:06:46.303" Score="1" ViewCount="217" Body="&lt;p&gt;When updating vundle-managed plugins with: &lt;code&gt;:PluginUpdate&lt;/code&gt; in buffer, I get the following error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing&#xA;~/.vim/bundle/LaTeX-Suite-aka-Vim-LaTeX/plugin/remoteOpen.vim: line 33&#xA;E174: Command already exists: add ! to replace it&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nijRX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nijRX.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the queasy feeling that I may well have installed this the wrong way. I did:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;git-cloned &lt;a href=&quot;https://github.com/vim-scripts/LaTeX-Suite-aka-Vim-LaTeX.git&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;LaTeX-Suite-aka-Vim-LaTeX&lt;/code&gt;&lt;/a&gt; in &lt;code&gt;~/.vim/bundle/&lt;/code&gt; and then ran &lt;code&gt;:PluginInstall&lt;/code&gt; in a vim buffer.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;added the line: &lt;code&gt;Plugin 'vim-scripts/LaTeX-Suite-aka-Vim-LaTeX'&lt;/code&gt;&lt;br&gt;&#xA;between &lt;code&gt;call vundle#begin()&lt;/code&gt; and &lt;code&gt;call vundle#end()&lt;/code&gt; in my &lt;code&gt;~/.vimrc&lt;/code&gt; and sourced &lt;code&gt;.vimrc&lt;/code&gt;,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;ran &lt;code&gt;:PluginUpdate&lt;/code&gt; in buffer&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Can someone please help me with this issue?&lt;/p&gt;&#xA;" OwnerUserId="4547" LastEditorUserId="4547" LastEditDate="2018-10-22T12:59:13.630" LastActivityDate="2018-10-22T15:45:52.860" Title="Error detected during LaTeX-Suite-aka-Vim-LaTeX plugin update with Vundle" Tags="|plugin-vim-latex|plugin-vundle|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17690" PostTypeId="2" ParentId="17689" CreationDate="2018-10-22T15:45:52.860" Score="2" Body="&lt;p&gt;When you read the error message you can see that the problem comes from &lt;code&gt;~/.vim/bundle/LaTeX-Suite-aka-Vim-LaTeX/plugin/remoteOpen.vim&lt;/code&gt; on line 33. This line is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com -nargs=1 RemoteOpen :call RemoteOpen('&amp;lt;args&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3acommand&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :command&lt;/code&gt;&lt;/a&gt; to create the user defined command &lt;code&gt;:RemoteOpen&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What Vim says is &lt;code&gt;Command already exists: add ! to replace it&lt;/code&gt;. It says that because when you do &lt;code&gt;:PluginUpdate&lt;/code&gt; the plugin is sourced again and as &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#E174&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h E174&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:com[mand][!] [{attr}...] {cmd} {rep}&#xA;            Define a user command.  The name of the command is&#xA;            {cmd} and its replacement text is {rep}.  The command's&#xA;            attributes (see below) are {attr}.  If the command&#xA;            already exists, an error is reported, unless a ! is&#xA;            specified, in which case the command is redefined.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So an easy fix for you is to replace the line by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! -nargs=1 RemoteOpen :call RemoteOpen('&amp;lt;args&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also maybe it would be worth it to contact the mainteners and see if they can fix that.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-10-22T15:45:52.860" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17691" PostTypeId="1" AcceptedAnswerId="17726" CreationDate="2018-10-22T22:25:59.627" Score="1" ViewCount="2024" Body="&lt;p&gt;I'm a big noob to vim here. I was trying to change the colorscheme of vim by editing the &lt;code&gt;.vimrc&lt;/code&gt; file, but as I was playing around with different color schemes (&lt;a href=&quot;https://github.com/ayu-theme/ayu-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;ayu&lt;/a&gt; and &lt;a href=&quot;https://github.com/morhetz/gruvbox/&quot; rel=&quot;nofollow noreferrer&quot;&gt;gruvbox&lt;/a&gt;, for example) I noticed that only the lines that have actual text on them get highlighted, everything else stays the same black command line background color as before (see screenshots below).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am assuming this has something to do with the fact that I am using the Windows command line and am SSH'ing to a remote Linux machine, but I have no idea how to have vim change the &lt;em&gt;entire&lt;/em&gt; background instead of just where the text is. Does anyone know what to do/if it is possible to get the whole background highlighted?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks so much!&#xA;&lt;a href=&quot;https://i.stack.imgur.com/miIKK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/miIKK.png&quot; alt=&quot;An example of the strange highlighting&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/lEsJO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lEsJO.png&quot; alt=&quot;The .vimrc file with the strange highlighting&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19491" LastEditorUserId="19491" LastEditDate="2018-10-22T22:37:55.217" LastActivityDate="2018-11-23T20:01:35.317" Title="Changing the vim color scheme only highlights lines of text?" Tags="|command-line|colorscheme|microsoft-windows|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="17692" PostTypeId="1" AcceptedAnswerId="17693" CreationDate="2018-10-23T07:29:28.013" Score="2" ViewCount="516" Body="&lt;p&gt;I'm trying to create an abbreviations to insert a comment and to insert a &lt;code&gt;TODO&lt;/code&gt; comment. I wrote them as following: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iab co /*__*/&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This one produces the following (where it has three spaces)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*__|_*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And for the &lt;code&gt;TODO&lt;/code&gt; comment, I wrote it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iab td /*_TODO:_*/&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This one produces&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* TODO:____|_*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason, vim adds extra spaces when interpreting the abbreviations. Could someone tell me why does it do this and how can I solve it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I replaced spaces with underscores for clarity.&lt;/p&gt;&#xA;" OwnerUserId="16800" LastActivityDate="2018-10-23T07:40:28.440" Title="Abbreviations add spaces when they shouldn't" Tags="|abbreviations|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17693" PostTypeId="2" ParentId="17692" CreationDate="2018-10-23T07:40:28.440" Score="4" Body="&lt;p&gt;This happens usually, because the abbreviation is triggered once you type a final space after the characters that trigger the abbreviation, e.g. after &lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;, so that the final space gets added at the cursor position after your expanded abbreviation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way around it is to make use of the &lt;code&gt;Eatchar&lt;/code&gt; function mentioned at the &lt;a href=&quot;https://github.com/vim/vim/blob/eda9e9c2fe4577ad451418253b990a3f60b70444/runtime/doc/map.txt#L960-L966&quot; rel=&quot;nofollow noreferrer&quot;&gt;help&lt;/a&gt; (there is no actual helptag for it, you can do &lt;code&gt;:helpgrep Eatchar&lt;/code&gt; to find it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the definition from the help together with your TODO abbreviation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func Eatchar(pat)&#xA;   let c = nr2char(getchar(0))&#xA;   return (c =~ a:pat) ? '' : c&#xA;endfunc&#xA;iab td /* TODO: */&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;c-r&amp;gt;=Eatchar('\s')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-10-23T07:40:28.440" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17694" PostTypeId="1" AcceptedAnswerId="17701" CreationDate="2018-10-23T08:27:54.993" Score="6" ViewCount="4428" Body="&lt;p&gt;I sometimes type (by accident) shift-space, inserting unbreakable space into code. With c++, I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: stray ‘\302’ in program&#xA;error: stray ‘\240’ in program&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;while in other formats (like RestructuredText), I am hunting mysterious errors of syntax without any visible cause.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;always highlight unbreakable spaces (and perhaps other type of &quot;illegal&quot; whitespace, i.e. any whitespace besides space and tab)&lt;/li&gt;&#xA;&lt;li&gt;map shift-space to space, so that these characters are not inserted in the first place?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="19495" LastEditorUserId="1841" LastEditDate="2018-10-23T12:45:31.723" LastActivityDate="2018-10-23T14:24:38.060" Title="How to show illegal whitespace (such as unbreakable space) in source code?" Tags="|highlight|unicode|whitespace|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17695" PostTypeId="2" ParentId="17694" CreationDate="2018-10-23T08:39:44.163" Score="2" Body="&lt;p&gt;I don't think you can use the &lt;code&gt;&amp;lt;S-Space&amp;gt;&lt;/code&gt; notation in a mapping* but I think you should be able to map it by pressing &lt;kbd&gt;Shift+Space&lt;/kbd&gt; when typing in the mapping where I've written &lt;code&gt;[lhs]&lt;/code&gt; below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap [lhs] &amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, when reading your &lt;code&gt;.vimrc&lt;/code&gt;, this will be a bit confusing, so you might be better off using an &lt;code&gt;:execute&lt;/code&gt; command and Vim's notation for adding Unicode characters to a string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;inoremap \u00A0 &amp;lt;Space&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(N.B. I'm not entirely sure which character you are inserting when you press &lt;kbd&gt;Shift+Space&lt;/kbd&gt;: you may need to adjust the Unicode value accordingly.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* I think that the keystrokes are probably converted in your terminal and never make it to Vim. So Vim only sees the unbreakable space: it doesn't know you pressed &lt;code&gt;Shift+Space&lt;/code&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-10-23T08:51:38.857" LastActivityDate="2018-10-23T08:51:38.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17696" PostTypeId="2" ParentId="17694" CreationDate="2018-10-23T08:39:56.143" Score="3" Body="&lt;p&gt;You can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax match ErrorMsg &quot; &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;while inserting an unbreakable space between the &lt;code&gt;&quot;&lt;/code&gt;'s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To automatically load the rule, you can simply add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au VimEnter,BufWinEnter * syn match ErrorMsg &quot; &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to customize the highlighting, create a custom rule before the &lt;code&gt;syn match&lt;/code&gt;, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight UnbreakableSpace ctermbg=red guibg=red&#xA;au VimEnter,BufWinEnter * syn match UnbreakableSpace &quot; &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7881" LastActivityDate="2018-10-23T08:39:56.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17697" PostTypeId="2" ParentId="17694" CreationDate="2018-10-23T08:40:26.047" Score="2" Body="&lt;p&gt;I do have this in my custom vimrc file, which highlights git conflict markers as well as special whitespace characters.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; highlight VCS conflict markers&#xA;&quot; highlight strange Whitespace&#xA;aug CustomHighlighting&#xA;  au!&#xA;  au WinEnter * if !exists(&quot;w:custom_hi1&quot;) | let w:custom_hi1 = matchadd('ErrorMsg', '^\(&amp;lt;\|=\|&amp;gt;\)\{7\}\([^=].\+\)\?$') | endif&#xA;  au WinEnter * if !exists(&quot;w:custom_hi2&quot;) | let w:custom_hi2 = matchadd('ErrorMsg', '[\x0b\x0c\u00a0\u1680\u180e\u2000-\u200a\u2028\u202f\u205f\u3000\ufeff]') |  endif&#xA;aug END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;kudos to Benjamin Haskell via the &lt;a href=&quot;https://groups.google.com/d/msg/vim_use/FuEGojGwKCM/V1K8VAWWKrEJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim_use mailinglist&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-10-23T08:40:26.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17698" PostTypeId="1" CreationDate="2018-10-23T10:58:29.767" Score="4" ViewCount="195" Body="&lt;p&gt;I have a file opened and I know I can do &lt;code&gt;:diffsplit&lt;/code&gt; to open the file in a diff view.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also know that I can do something like &lt;code&gt;:earlier 30m&lt;/code&gt; to see how the file was 30 minutes ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: how do I combine them and open a diff in a split to see the differences between now and 30 minutes ago?&lt;/p&gt;&#xA;" OwnerUserId="19340" LastActivityDate="2023-03-17T13:02:55.360" Title="&quot;diff&quot;-ing current with &quot;earlier&quot; time" Tags="|vimdiff|undo-redo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17699" PostTypeId="1" CreationDate="2018-10-23T12:09:04.167" Score="0" ViewCount="91" Body="&lt;p&gt;I want to do wht is asked here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/43693204/making-esc-key-toggle-command-insert-modes-in-vim&quot;&gt;https://stackoverflow.com/questions/43693204/making-esc-key-toggle-command-insert-modes-in-vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I follow the answer there, every time I run vim it starts in insert mode and inserts &lt;code&gt;[2;2R&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using vim8.0 on Ubuntu 18 in the GNOME terminal running the Bash shell.&lt;/p&gt;&#xA;" OwnerUserId="18613" LastActivityDate="2018-10-23T12:09:04.167" Title="Mapping ESC key to toggle command/insert modes" Tags="|key-bindings|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17700" PostTypeId="1" AcceptedAnswerId="17702" CreationDate="2018-10-23T12:38:43.827" Score="1" ViewCount="42" Body="&lt;p&gt;I need to reformat the kegg reconstruct pathway output, I have something like this in file1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00550 Peptidoglycan biosynthesis (2)&#xA;&#xA;K01000&#xA;&#xA;K02563&#xA;&#xA;00511 Other glycan degradation (8)&#xA;&#xA;K01190&#xA;&#xA;K01191&#xA;&#xA;K01192&#xA;&#xA;K01201&#xA;&#xA;K01227&#xA;&#xA;K12309&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00550 Peptidoglycan biosynthesis (2)   K01000   K02563&#xA;00511 Other glycan degradation (6)   K01190   K01191   K01192   K01201   K01227   K12309&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How could I reformat this  like that in vim or linux&lt;/p&gt;&#xA;" OwnerUserId="19494" LastEditorUserId="19494" LastEditDate="2018-10-23T14:05:50.360" LastActivityDate="2018-10-23T17:19:15.250" Title="how reformat kegg reconstruct pathway in vim?" Tags="|formatting|linux|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17701" PostTypeId="2" ParentId="17694" CreationDate="2018-10-23T14:24:38.060" Score="10" Body="&lt;h1&gt;List &amp;amp; Listchars&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'list'&lt;/code&gt; is a boolean option that, when &lt;code&gt;set&lt;/code&gt;, instructs vim to display whitespace characters. And it is completely customizable using &lt;code&gt;'listchars'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to show non-breaking spaces as &lt;code&gt;!&lt;/code&gt; (you can use whatever character you like, especially with digraphs and unicode support):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list listchars=nbsp:!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;'listchars'&lt;/code&gt; extensively, since it supports tabs, trailing whitespace, and more. It helps provide little background indicators that things aren't really what they seem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;a href=&quot;https://github.com/benknoble/Dotfiles/blob/master/links/vim/vimrc#L120-#L121&quot; rel=&quot;noreferrer&quot;&gt;current settings&lt;/a&gt;, for example, are&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list listchars=tab:»\ ,trail:·,nbsp:⎵,precedes:&amp;lt;,extends:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Meaning:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;tabs show as &lt;code&gt;»&lt;/code&gt; followed by spaces ; &lt;/li&gt;&#xA;&lt;li&gt;trailing white spaces show up as dots ;&lt;/li&gt;&#xA;&lt;li&gt;non-breaking spaces show up as that weird unicode space character ;&lt;/li&gt;&#xA;&lt;li&gt;if the line wraps to the left or the right, I get angle-bracket notifiers&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Further Reading:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h 'list'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h 'listchars'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-10-23T14:24:38.060" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17702" PostTypeId="2" ParentId="17700" CreationDate="2018-10-23T14:51:11.557" Score="1" Body="&lt;p&gt;This can be done using a &lt;code&gt;:g&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^0/,/^0\|\%$/-j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will mark each line (e.g. on which lines to act) starting with &lt;code&gt;0&lt;/code&gt; and join until the next line starting with &lt;code&gt;0&lt;/code&gt; (or end of line). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it will miss the last line, so you need to add a final &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$-j &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;command to fix this&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-10-23T14:51:11.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17703" PostTypeId="1" CreationDate="2018-10-23T15:22:20.233" Score="0" ViewCount="210" Body="&lt;p&gt;I currently have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt; G&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;.vimrc&lt;/code&gt; so I can go to line 123 by typing &lt;code&gt;123&amp;lt;leader&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, since I have other leader combinations, such as &lt;code&gt;&amp;lt;leader&amp;gt;u&lt;/code&gt;, the line jump happens only after a second. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know how to reduce this timeout, but I don't really want to do that since it would make it harder for me to use &lt;code&gt;&amp;lt;leader&amp;gt;u&lt;/code&gt; when I actually want to. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also be happy to type &lt;code&gt;&amp;lt;leader&amp;gt;123&lt;/code&gt; if that is easier to accomplish.&lt;/p&gt;&#xA;" OwnerUserId="18613" LastActivityDate="2018-11-22T02:24:34.123" Title="Go to line with `&lt;line&gt;&lt;leader&gt;` without timeout" Tags="|leader|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17704" PostTypeId="1" AcceptedAnswerId="17707" CreationDate="2018-10-23T15:23:10.030" Score="6" ViewCount="1581" Body="&lt;p&gt;When I call this function inside vim statusline it returns this &lt;code&gt;nvim^@&lt;/code&gt;.weird character, What is the meaning of &lt;code&gt;^@&lt;/code&gt; in returned value and how to get rid of it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetEditor()&#xA;  let s:name = system(&quot;echo $EDITOR&quot;)&#xA;  return s:name&#xA;endfunction&#xA;&#xA;set statusline+=%0*\ %{GetEditor()}\ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-10-23T18:48:33.253" Title="How to remove ^@ character returned by `system()`?" Tags="|vimscript|statusline|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17705" PostTypeId="2" ParentId="17703" CreationDate="2018-10-23T15:35:07.143" Score="1" Body="&lt;p&gt;You may do &#xA;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;&amp;lt;leader&amp;gt; G&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then just type the linenumber and double click the leaderkey.&lt;/p&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-10-23T15:35:07.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17706" PostTypeId="1" AcceptedAnswerId="17708" CreationDate="2018-10-23T16:03:39.917" Score="1" ViewCount="202" Body="&lt;p&gt;First, apologies for attempting to ask a complicated question since I would not be able to provide a lot of details, however, one might catch something that I am missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a vim script, that is a series of stages that prepare &lt;code&gt;dein.vim&lt;/code&gt; as a plugin loader. The problem I am experiencing is that if I put my script (single file) inside &lt;code&gt;$HOME/.vim/plugin/my_dein_bridge.vim&lt;/code&gt; it is not working properly. I know that I should be explaining the errors etc., however, there are fundamental problems, so let's say that the script is not doing what it is intended to do and acts buggy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, If I just put that very same script file somewhere, let's say inside &lt;code&gt;/some/path/my_dein_bridge.vim&lt;/code&gt; and simply source it at the end of my &lt;code&gt;.vimrc&lt;/code&gt; file. It is working perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe, someone can point to something that I need to be careful about, in regards to scripts running from the &lt;code&gt;$HOME/.vim/plugin&lt;/code&gt; folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;--- EDIT ---&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to provide some additional information as much as I can. The script is intended to function as a bridge between the &lt;code&gt;.vimrc&lt;/code&gt; file and the &lt;code&gt;rest of vim's start-up&lt;/code&gt;, providing a safe environment for the plugin loaders.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) &lt;code&gt;bridge-boiler-plate&lt;/code&gt;: (this is us)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make sure the &lt;code&gt;plugin manager&lt;/code&gt; is installed&lt;/li&gt;&#xA;&lt;li&gt;Run &lt;code&gt;plugin manager&lt;/code&gt;'s prep stages&lt;/li&gt;&#xA;&lt;li&gt;Load some low-level plugins using the &lt;code&gt;plugin manager&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Create a list of active plugins plus some other stages etc.&lt;/li&gt;&#xA;&lt;li&gt;Pass control over to the &lt;code&gt;plugin manager&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;3) &lt;code&gt;plugin manager&lt;/code&gt; takes on, loads the standard plugins&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Proceed into &lt;code&gt;vim-start up.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought having a &lt;code&gt;source /some/path/my_boulerplate_bridge.vim&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; is a bit ugly, so I tried to come up with a more elegant way.&lt;/p&gt;&#xA;" OwnerUserId="5328" LastEditorUserId="5328" LastEditDate="2018-10-23T16:48:37.200" LastActivityDate="2018-10-23T16:48:37.200" Title="The difference between a plugin script and a sourced script" Tags="|vimscript|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17707" PostTypeId="2" ParentId="17704" CreationDate="2018-10-23T16:21:01.223" Score="9" Body="&lt;p&gt;The &lt;code&gt;^@&lt;/code&gt; is a NUL character, 0x00, which Vim uses in certain cases to store a newline, 0x0a.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unix commands usually terminate their output with a newline, and the system() function captures that newline in the output of your echo command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get rid of that terminating newline, use substitute():&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:name = substitute(system(&quot;echo $EDITOR&quot;), '\n', '', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That substitute() call replaces newlines ('\n') in the output of system() with nothing (''), and does so globally ('g'), i.e., to all newlines in the output of system().&lt;/p&gt;&#xA;" OwnerUserId="2055" LastActivityDate="2018-10-23T16:21:01.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17708" PostTypeId="2" ParentId="17706" CreationDate="2018-10-23T16:25:37.070" Score="2" Body="&lt;p&gt;Everything which is in &lt;code&gt;{rtp}/plugin&lt;/code&gt; is automatically sourced after the &lt;code&gt;.vimrc&lt;/code&gt; has been sourced in the order specified by &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27rtp%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'rtp'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, you may observe interferences. If your plugin isn't properly isolated and depends-on/defines global variables and/or global functions, you may observe troubles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did provide best practices on SU: &lt;a href=&quot;https://superuser.com/questions/147069/vim-plugin-creation-tutorial&quot;&gt;https://superuser.com/questions/147069/vim-plugin-creation-tutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, be sure to prevent &lt;em&gt;recursivity&lt;/em&gt;, i.e. to prefer &lt;code&gt;:normal!&lt;/code&gt; over &lt;code&gt;:normal&lt;/code&gt;, to prefer &lt;code&gt;nore&lt;/code&gt; forms for mappings and abbreviations, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now without the exact error message, it'll be quite complex to provide more assistance.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-10-23T16:25:37.070" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17710" PostTypeId="2" ParentId="17704" CreationDate="2018-10-23T18:48:33.253" Score="8" Body="&lt;p&gt;You got an answer already. However, for your specific case, you don't need the &lt;code&gt;system()&lt;/code&gt; call, since you want an environment variable to be expanded. In that case you could simply use &lt;code&gt;echo $EDITOR&lt;/code&gt; or in case of a function call do: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetEditor()&#xA;    return $EDITOR&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now, suppose you still need a &lt;code&gt;system()&lt;/code&gt; function call, because you need to return the output of a system specific command. If you know, the output will only have a simple line (e.g. only one single linebreak), you could simply return the output with the last byte (the linebreak) removed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return system(&quot;yes |head -1&quot;)[:-2]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which uses the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-%5B%3A%5D&quot; rel=&quot;noreferrer&quot;&gt;expr[] syntax&lt;/a&gt; to strip the last byte from the output. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could make use of the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#systemlist%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;systemlist() function&lt;/code&gt;&lt;/a&gt; which automatically converts the output of the system command into a vim list, so you do not have to take care of those trailing linebreaks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return systemlist(&quot;echo $EDITOR&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See also the similar &lt;a href=&quot;https://superuser.com/a/935646/85228&quot;&gt;answer on superuser&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-10-23T18:48:33.253" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17711" PostTypeId="1" AcceptedAnswerId="17718" CreationDate="2018-10-23T21:24:32.463" Score="4" ViewCount="760" Body="&lt;p&gt;I have two files open, each one is in a split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From file one, how can I get the filename of the file in split two ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In command mode, I can get the reference of the filename I'm currently editing by using &lt;code&gt;%f&lt;/code&gt;, is there something similar that would return the filename of the file opened in my second split?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt; : Following &lt;a href=&quot;https://vi.stackexchange.com/a/17718/19461&quot;&gt;Christian Brabandt's advice&lt;/a&gt;, I ended up doing this, from the first window :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo bufname(2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19461" LastEditorUserId="19461" LastEditDate="2018-10-30T19:23:49.897" LastActivityDate="2018-10-31T18:04:21.517" Title="From one split, how can I get the filename of the file in another split?" Tags="|split|multiple-files|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17713" PostTypeId="1" AcceptedAnswerId="17714" CreationDate="2018-10-24T01:29:54.827" Score="0" ViewCount="49" Body="&lt;p&gt;I'm using OS X 10.14/Vim 8.0.1283 and iTerm2. Every time when I'm copying things from clipboard to terminal, in specific iTerm2, there will be some unexpected characters injected in. &#xA;Say I'm copying &lt;code&gt;Explore Our Questions&lt;/code&gt; from clipboard to terminal, it ends up being &lt;code&gt;[200~Explore Our Questions[201~]]&lt;/code&gt;. &#xA;I'm very confused about where are these &lt;code&gt;[200~&lt;/code&gt; and &lt;code&gt;[201~]]&lt;/code&gt; from. Can anyone help? Much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="7971" LastActivityDate="2018-10-24T01:59:00.767" Title="Unexpected characters injected when copying from clipboard to vim in terminal" Tags="|terminal|iterm2|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17714" PostTypeId="2" ParentId="17713" CreationDate="2018-10-24T01:59:00.767" Score="0" Body="&lt;p&gt;Have you tried &lt;code&gt;:set paste&lt;/code&gt; before pasting?&#xA;see &lt;code&gt;help paste&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-10-24T01:59:00.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17715" PostTypeId="2" ParentId="17711" CreationDate="2018-10-24T02:04:04.907" Score="0" Body="&lt;p&gt;focus the split &lt;code&gt;&amp;lt;C-w&amp;gt;h/j/k/l&lt;/code&gt; then hit &lt;code&gt;&amp;lt;C-g&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-10-24T02:04:04.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17716" PostTypeId="2" ParentId="17667" CreationDate="2018-10-24T03:33:59.133" Score="1" Body="&lt;p&gt;I asked in comments for some of your settings and you replied with &lt;code&gt;filetype=sh autoindent nocindent indentexpr=&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If for &lt;code&gt;indentexpr&lt;/code&gt; you instead had value &lt;code&gt;GetShIndent()&lt;/code&gt; you'd have the indent scheme you want. You can manually set it up with &lt;code&gt;:source $VIMRUNTIME/indent/sh.vim&lt;/code&gt;. But that's not what we want. With the proper configuration this should be picked up automatically when you open a shell file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's missing in your configuration? My best guess is that you need to add this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check the current &quot;indent&quot; value (as well as a couple others, &quot;plugin&quot; and &quot;detection&quot; ) with plain &lt;code&gt;:filetype&lt;/code&gt;. If you see &lt;code&gt;indent:OFF&lt;/code&gt; then I'm on the right track and you should update your vimrc as suggested.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-10-24T03:33:59.133" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17717" PostTypeId="1" CreationDate="2018-10-24T03:53:53.200" Score="0" ViewCount="194" Body="&lt;p&gt;When I lose power, I have a lot of maybe-useful swap files (4 &lt;code&gt;vim&lt;/code&gt; instances running now, 103 swap files currently in &lt;code&gt;~/.cache/vim/swap&lt;/code&gt;). I am fine with manual recovery of swapfiles &lt;em&gt;with changes&lt;/em&gt; - I'd just like a way to either:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;delete all lock-only swapfiles post-reboot or other times I know there are no running &lt;code&gt;vim&lt;/code&gt; instances&lt;/li&gt;&#xA;&lt;li&gt;minimize the number of lock-only swapfiles to 1 per open instance of &lt;code&gt;vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I opened &lt;a href=&quot;https://github.com/vim/vim/issues/3505&quot; rel=&quot;nofollow noreferrer&quot;&gt;an issue on Github&lt;/a&gt; to see if &lt;code&gt;vim&lt;/code&gt; could manage 2 without any plugins, etc, but unfortunately it was not deemed worthy of support hours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I request a solution to either 1 or 2 which:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;is easy to remember - short, small, easy to copy-paste between computers&lt;/li&gt;&#xA;&lt;li&gt;and is &lt;em&gt;not&lt;/em&gt; instructions for the computer to download or call a special dependency - ie, no &lt;code&gt;vim&lt;/code&gt; plugins, Java programs, etc. The &lt;em&gt;entire&lt;/em&gt; solution needs to be short enough to match the above criterion. So, ie, 5 lines of &lt;code&gt;python&lt;/code&gt;/&lt;code&gt;perl&lt;/code&gt;/&lt;code&gt;awk&lt;/code&gt;/&lt;code&gt;vimscript&lt;/code&gt;/etc would be great.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Attempted solutions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Haven't found a &lt;code&gt;vim&lt;/code&gt; command-line flag to tell me if a swapfile is only a lockfile instead of a recovery file&lt;/li&gt;&#xA;&lt;li&gt;Haven't found a &lt;code&gt;vimscript&lt;/code&gt; instruction to store lock and recovery files separately.&lt;/li&gt;&#xA;&lt;li&gt;Have read the source to 3-4 different vimscript plugins - one removes &lt;code&gt;set hidden&lt;/code&gt; on buffer switch, another diffs swap files, another deletes swap files without regard for if they're lock files, etc. None (so far) are simple enough to be easily portable.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim/issues/3505&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub issue&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;rm ~/.cache/vim/swap/*&lt;/code&gt; - destroys recovery files along with the lock files&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Have not yet tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;reading the swap file format to see if there's something I can hook to w/eg &lt;code&gt;grep&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;installing/testing various &lt;code&gt;vimscript&lt;/code&gt; plugins - not very portable&lt;/li&gt;&#xA;&lt;li&gt;setting read-only mode by default, then setting it again when I save a buffer. I'm looking for something I do at most once per boot, not on every file access - if every file access that's why we have software.&lt;/li&gt;&#xA;&lt;li&gt;as the above, but w/o &lt;code&gt;set hidden&lt;/code&gt; by default&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8846" LastActivityDate="2018-10-30T15:33:13.510" Title="Minimal swap file use or deleting only swapfiles without changes" Tags="|swap-file|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17718" PostTypeId="2" ParentId="17711" CreationDate="2018-10-24T05:40:20.050" Score="3" Body="&lt;p&gt;To get the buffer name in a different window, you will have to use a Vimscript solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can refer to different splits using the window number or the winid. The window number is not stable and will change, if you modify the window layout, therefore the winid exists, which will never change (but was not available in older Vim versions). The window number starts with 1 from the top left window and is incremented for each window going from top left to bottom right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Back to your question, in a Vim window with 2 split windows, you can use &lt;code&gt;echo bufname(winbufnr(1))&lt;/code&gt; to get the buffer name of the first split window and subsequently use &lt;code&gt;echo bufname(winbufnr(2))&lt;/code&gt; for the second window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Making use of winids is left as an excercise to the reader ;)&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-10-31T18:04:21.517" LastActivityDate="2018-10-31T18:04:21.517" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17719" PostTypeId="1" CreationDate="2018-10-24T08:18:51.190" Score="1" ViewCount="858" Body="&lt;p&gt;The following search command will make a range and search/replace within it. Specifically, it looks for 'first' in the text, then stops when it finds 'second' across multiple lines.  Then, within that range of selected things, it will replace foo with bar.  What I'm not sure how to do is to replace &lt;em&gt;all&lt;/em&gt; occurrences of foo on each line with bar.  I've tried using /%s/ instead of /s/  What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/first/;/second/s/foo/bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2018-10-25T15:30:46.510" Title="Search and replace multiple line items within a range?" Tags="|search|range|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17720" PostTypeId="1" CreationDate="2018-10-24T10:12:16.803" Score="1" ViewCount="460" Body="&lt;p&gt;How can I deal with the colored outputs of shell commands when inputing them with &lt;code&gt;:read&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, I have a self-defined &lt;code&gt;git log&lt;/code&gt; command, and I would like to see it in a split window. That works well enough using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new | read !git log-command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the command outputs has some colours. And thus the result looks like&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;^[[33mac74ef4^[[m 2018-10-22 [me, N] - some text&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I guess I could just use as &lt;code&gt;:substitute&lt;/code&gt; command to clean it up afterwards, or maybe pipe it through &lt;code&gt;sed&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I wanted to know if there was a better way to handle it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a minimum, I would like to remove those &lt;code&gt;^[[m&lt;/code&gt; characters. But even better would be to recognise them and adapt it to color the buffer accordingly.&lt;/p&gt;&#xA;" OwnerUserId="2170" LastActivityDate="2019-09-04T13:03:15.420" Title="Shell coloring handling with :read command" Tags="|external-command|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17721" PostTypeId="2" ParentId="17719" CreationDate="2018-10-24T13:25:51.240" Score="2" Body="&lt;h2&gt;UPDATE&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;So I have found simpler solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/first/,/second/g/bar/s/foo/bar/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/first/,/second/&lt;/code&gt; take a range between &lt;code&gt;first&lt;/code&gt; and &lt;code&gt;second&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g/bar/&lt;/code&gt; filter out lines that do not have &lt;code&gt;bar&lt;/code&gt; (keep lines that has &lt;code&gt;bar&lt;/code&gt;s)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s/foo/bar/g&lt;/code&gt; substitute all &lt;code&gt;foo&lt;/code&gt;s with &lt;code&gt;bar&lt;/code&gt;s within filtered lines.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Old solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It is kind of tricky and probably would be much easier if &lt;code&gt;:g&lt;/code&gt; command could be used recursively with the ranges. But it can't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/first/,/second/s/\(bar.*\zsfoo\ze\)\|\(\zsfoo\ze .*bar\)/bar/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;range from &lt;code&gt;first&lt;/code&gt; to &lt;code&gt;second&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;substitute &lt;code&gt;foo&lt;/code&gt;s only if the line has &lt;code&gt;bar&lt;/code&gt; before &lt;code&gt;foo&lt;/code&gt; or after &lt;code&gt;foo&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have tested it with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar foo bar bar&#xA;&#xA;first&#xA;foo bar foo bar bar&#xA;hello foo foo world&#xA;hello foo hlkj sdklfj bar fooworld&#xA;foo bar foo bar bar&#xA;foo bar foo bar bar&#xA;second&#xA;&#xA;foo bar foo bar bar&#xA;foo bar foo bar bar&#xA;foo bar foo bar bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After the substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar foo bar bar&#xA;&#xA;first&#xA;bar bar bar bar bar&#xA;hello foo foo world&#xA;hello bar hlkj sdklfj bar barworld&#xA;bar bar bar bar bar&#xA;bar bar bar bar bar&#xA;second&#xA;&#xA;foo bar foo bar bar&#xA;foo bar foo bar bar&#xA;foo bar foo bar bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2018-10-25T15:30:46.510" LastActivityDate="2018-10-25T15:30:46.510" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17722" PostTypeId="2" ParentId="17719" CreationDate="2018-10-24T13:39:43.800" Score="0" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/17719/search-and-replace-multiple-line-items-within-a-range/17722#comment30398_17719&quot;&gt;@ChristianBrabandt mentioned in a comment&lt;/a&gt;, you need to use the &lt;code&gt;g&lt;/code&gt; flag to the &lt;code&gt;:substitute&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/first/;/second/s/foo/bar/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h :s_flags&lt;/code&gt; for details on this and other flags you can use with &lt;code&gt;:s&lt;/code&gt; commands.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-10-24T13:39:43.800" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17723" PostTypeId="1" AcceptedAnswerId="17724" CreationDate="2018-10-24T15:22:31.193" Score="3" ViewCount="1383" Body="&lt;p&gt;Everytime I open a file vim displays the filename in the command bar, for example I run this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim test.test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim will start with a statusline like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;test.test&quot; [New File]                                            0,0-1        All&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm already using an statusline that displays file name so how can I get rid of it?&lt;/p&gt;&#xA;" OwnerUserId="18514" LastEditorUserId="71" LastEditDate="2018-10-24T15:48:29.923" LastActivityDate="2018-10-24T15:48:29.923" Title="how to disable displaying of filename in the command bar when opening files in vim/nvim?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17724" PostTypeId="2" ParentId="17723" CreationDate="2018-10-24T15:41:56.620" Score="5" Body="&lt;p&gt;You can use &lt;code&gt;:set shortmess+=F&lt;/code&gt; to prevent Vim from echoing the current filename into the commandline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the documentation, e.g. &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27shortmess%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'shortmess'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, this might need a recent Vim, since the 'F' flag was always correctly respected. Some recent patches changed that, e.g. &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.0310&quot; rel=&quot;noreferrer&quot;&gt;8.1.310&lt;/a&gt; or &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.0110&quot; rel=&quot;noreferrer&quot;&gt;8.1.110&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-10-24T15:41:56.620" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17725" PostTypeId="1" CreationDate="2018-10-24T18:36:04.973" Score="1" ViewCount="1010" Body="&lt;p&gt;I am a relative new user to vim. I started using it along with a newly set up arch installation.&#xA;So when I created different netctl profiles in vim, it highlighted the parameters like shown in the image, without having defined a filetype. But from  one moment, it stopped doing so, the plain text profiles are now unicolored and I cant get it back working, e.g. by switching on syntax highlighting manually.&lt;img src=&quot;https://i.stack.imgur.com/HOCWO.png&quot; alt=&quot;highlighting as it worked out of the box&quot;&gt;&#xA;Edit: the shown profile is named like in the description, htw_eduroam. No file extension.&lt;/p&gt;&#xA;" OwnerUserId="19521" LastEditorUserId="19522" LastEditDate="2018-10-24T21:42:52.357" LastActivityDate="2018-10-27T17:11:33.477" Title="Vim highlighting in textfiles" Tags="|highlight|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17726" PostTypeId="2" ParentId="17691" CreationDate="2018-10-24T19:24:38.157" Score="2" Body="&lt;p&gt;This can sometimes results from drawing errors or misconfigured terms (or misconfigured colorschemes). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good diagnostic checklist is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Check the environment variable &lt;code&gt;$TERM&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Check the vim option &lt;code&gt;'t_Co'&lt;/code&gt; (it is usually set based on &lt;code&gt;$TERM&lt;/code&gt; and should not need changed)&lt;/li&gt;&#xA;&lt;li&gt;and try doing a &lt;code&gt;:redraw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Often, if the values are misaligned (or smaller than expected), colorschemes won't be able to use their full range of values (256 or truecolor/20-bit, depending).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Screen&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;By default, the &lt;code&gt;$TERM=screen&lt;/code&gt; that screen uses is not 256-color. One can fix this with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# /etc/.screenrc (or ~/.screenrc)&#xA;screen-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this is only 256 color support (the same amount the typical &lt;code&gt;xterm-256color&lt;/code&gt; supports). If your terminal (like iTerm2, for example) supports truecolor, then you should &lt;a href=&quot;https://arstechnica.com/civis/viewtopic.php?f=16&amp;amp;t=1425567&quot; rel=&quot;nofollow noreferrer&quot;&gt;use the &lt;code&gt;--truecolor&lt;/code&gt; option to screen&lt;/a&gt;. Then you can use &lt;code&gt;termguicolors&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Tmux&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;By default, the &lt;code&gt;$TERM=screen&lt;/code&gt; that tmux uses is not 256-color. One can fix this with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# ~/.tmux.conf&#xA;set -g default-terminal &quot;screen-256color&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;xterm-256color&lt;/code&gt; may work as well (untested).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, this is again 256 color. If you want truecolor (and &lt;code&gt;termguicolors&lt;/code&gt;) support, you'll need to &lt;a href=&quot;https://stackoverflow.com/questions/41783367/tmux-tmux-true-color-is-not-working-properly&quot;&gt;set the overrides correctly&lt;/a&gt; (apparently this can be tricky to get right).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If often goes something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# ~/.tmux.conf&#xA;# OLDTERM=TERM from outside of tmux&#xA;set-option -sa terminal-overrides &quot;,$OLDTERM*:Tc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure to restart tmux.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-10-24T19:24:38.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17727" PostTypeId="2" ParentId="17675" CreationDate="2018-10-24T20:00:39.087" Score="2" Body="&lt;p&gt;Try running this unholy ex command in your first tab:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%y|tabn|%d|pu0|1d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It’s certainly a combo that does it all in one go, but is it nice?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That’s a rhetorical question: it’s clearly not.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Further details&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is a maximally abbreviated version of the following sequence of commands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:%yank&lt;/code&gt;: Yank the entire file by using the &lt;code&gt;:yank&lt;/code&gt; command with the &lt;code&gt;%&lt;/code&gt; range. (See &lt;code&gt;:help cmdline-ranges&lt;/code&gt;.)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabnext&lt;/code&gt;: Move to the next tab.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:%delete&lt;/code&gt;: Delete the entire buffer by passing the &lt;code&gt;%&lt;/code&gt; range to the &lt;code&gt;:delete&lt;/code&gt; command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:put 0&lt;/code&gt;: Put the contents of the yank register (See &lt;code&gt;:help &quot;0&lt;/code&gt;) after the current line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:1delete&lt;/code&gt;: The commands above will leave a blank line at the top of the file. We can remove this by passing a different range to the &lt;code&gt;:delete&lt;/code&gt; command. (N.B. A previous&amp;#8202;&amp;mdash;&amp;#8202;less efficient&amp;#8202;&amp;mdash;&amp;#8202;version of this answer instead used &lt;code&gt;norm!ggdd&lt;/code&gt; to remove this line by using the &lt;code&gt;:normal&lt;/code&gt; command to emulate typing &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These have been consolidated into a one-liner by using a &lt;code&gt;|&lt;/code&gt; character to run multiple commands on a single line. (See &lt;code&gt;:help :bar&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can view the documentation for each of these commands by inserting them into a &lt;code&gt;:help&lt;/code&gt; query. e.g. &lt;code&gt;:help :yank&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-10-29T16:36:35.850" LastActivityDate="2018-10-29T16:36:35.850" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="17728" PostTypeId="1" AcceptedAnswerId="17746" CreationDate="2018-10-24T20:02:31.457" Score="3" ViewCount="1761" Body="&lt;p&gt;This does NOT work with files opened in several tabs (put in &lt;code&gt;~/.vimrc&lt;/code&gt; obviously):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F5&amp;gt; :wa&amp;lt;CR&amp;gt; &amp;lt;bar&amp;gt; :!global_stack_build_run.sh&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Neither it works when I use &lt;code&gt;|&lt;/code&gt; instead of &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears to run only &lt;code&gt;:wa&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19525" LastActivityDate="2018-10-26T11:17:12.743" Title="vim: mapping several commands to one shortcut" Tags="|key-bindings|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17729" PostTypeId="1" AcceptedAnswerId="17730" CreationDate="2018-10-24T20:46:42.847" Score="1" ViewCount="579" Body="&lt;p&gt;I want to switch between tabs, but this works only in command mode. Is it possible to make this work in edit (insert?) mode too?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C-k&amp;gt; :tabprevious&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;C-l&amp;gt; :tabnext&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;F10&amp;gt; :tabnew&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19525" LastEditorUserId="2920" LastEditDate="2018-10-24T21:34:32.507" LastActivityDate="2018-10-24T21:40:57.100" Title="How to make this work in insert/edit mode too?" Tags="|key-bindings|insert-mode|normal-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17730" PostTypeId="2" ParentId="17729" CreationDate="2018-10-24T21:40:57.100" Score="3" Body="&lt;p&gt;Let's look at &lt;code&gt;:help :noremap&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:no[remap]  {lhs} {rhs}     |mapmode-nvo|   *:no*  *:noremap* *:nor*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's not super helpful, but it links us to where we need to go next:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            *mapmode-nvo* *mapmode-n* *mapmode-v* *mapmode-o*&#xA;&#xA;There are six sets of mappings&#xA;- For Normal mode: When typing commands.&#xA;- For Visual mode: When typing commands while the Visual area is highlighted.&#xA;- For Select mode: like Visual mode but typing text replaces the selection.&#xA;- For Operator-pending mode: When an operator is pending (after &quot;d&quot;, &quot;y&quot;, &quot;c&quot;,&#xA;  etc.).  See below: |omap-info|.&#xA;- For Insert mode.  These are also used in Replace mode.&#xA;- For Command-line mode: When entering a &quot;:&quot; or &quot;/&quot; command.&#xA;&#xA;Special case: While typing a count for a command in Normal mode, mapping zero&#xA;is disabled.  This makes it possible to map zero without making it impossible&#xA;to type a count with a zero.&#xA;&#xA;                        *map-overview* *map-modes*&#xA;Overview of which map command works in which mode.  More details below.&#xA;     COMMANDS                    MODES ~&#xA;:map   :noremap  :unmap     Normal, Visual, Select, Operator-pending&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That last line is the most relevant one. What all of this means is that when you run &lt;code&gt;:noremap &amp;lt;something&amp;gt;&lt;/code&gt; you're only remapping for normal, visual, select, and operator pending mode. And if you look a bit further in that help page, you'll see that there is no command that maps to both normal and insert mode. So you'll just have to use two mappings. Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C-k&amp;gt; :tabprevious&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;C-l&amp;gt; :tabnext&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;F10&amp;gt; :tabnew&#xA;&#xA;inoremap &amp;lt;C-k&amp;gt; &amp;lt;C-o&amp;gt;:tabprevious&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;C-l&amp;gt; &amp;lt;C-o&amp;gt;:tabnext&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;F10&amp;gt; &amp;lt;C-o&amp;gt;:tabnew&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; in insert mode is used to run a single normal command and then return to insert mode. Of course, you could achieve the same thing with &lt;code&gt;inoremap &amp;lt;C-k&amp;gt; &amp;lt;esc&amp;gt;:tabprevious&amp;lt;cr&amp;gt;gi&lt;/code&gt;, but with &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; is neater and easier.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-10-24T21:40:57.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17732" PostTypeId="2" ParentId="4682" CreationDate="2018-10-25T08:43:22.040" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;With vim of version &lt;em&gt;8.0.1387&lt;/em&gt; and newer you can use &lt;code&gt;--not-a-term&lt;/code&gt; option.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For older version use the following trick:&#xA;&lt;code&gt;&#xA;$ echo foo | bash -c 'vim &amp;lt; /dev/tty &amp;lt;(cat)'&#xA;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The first argument &lt;code&gt;/dev/tty&lt;/code&gt; somehow tricks Vim to think the input comes from the keyboard. I guess, that's because &lt;strong&gt;isatty(3)&lt;/strong&gt; returns True for that file. And the second argument simply passes-through everything from its standard input to Vim's standard input. Finally, &lt;code&gt;bash -c&lt;/code&gt; prefix is required for the special construct &lt;code&gt;&amp;lt;(...)&lt;/code&gt; to work if the shell doesn't support it. In &lt;em&gt;bash&lt;/em&gt; the original solution can be simplified to&#xA;&lt;code&gt;&#xA;$ echo foo | vim &amp;lt; /dev/tty &amp;lt;(cat)&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14707" LastActivityDate="2018-10-25T08:43:22.040" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17733" PostTypeId="2" ParentId="15140" CreationDate="2018-10-25T13:14:15.507" Score="0" Body="&lt;p&gt;You can use a global command with optional regex, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/a\|b/norm! @z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command above will run the macro &quot;z&quot; only on the lines that have 'a' or 'b'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TIP: when setting your macro you can use double quotes to be able to use special keys like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=&quot;iHello World\&amp;lt;CR&amp;gt;bye!\&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2018-10-25T13:19:35.380" LastActivityDate="2018-10-25T13:19:35.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17735" PostTypeId="2" ParentId="15944" CreationDate="2018-10-25T16:07:17.853" Score="6" Body="&lt;p&gt;If you use the &lt;a href=&quot;https://github.com/vim-airline/vim-airline/&quot; rel=&quot;noreferrer&quot;&gt;vim-airline&lt;/a&gt; Plugin together with the &lt;a href=&quot;https://github.com/osyo-manga/vim-anzu&quot; rel=&quot;noreferrer&quot;&gt;vim-anzu&lt;/a&gt; Plugin, the search statistics are already displayed in the statusline. See the below screenshot (and note the &lt;code&gt;[1/3]&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZFrk4.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZFrk4.png&quot; alt=&quot;Airline with vim-anzu&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-10-25T16:07:17.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17737" PostTypeId="1" AcceptedAnswerId="17873" CreationDate="2018-10-25T22:45:03.320" Score="4" ViewCount="185" Body="&lt;p&gt;Well, I try to use the following convention. &#xA;± (as unused key) is used for increase search where / is used for regular search. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The implementation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noincsearch&#xA;&#xA;nmap  ± &amp;lt;esc&amp;gt;:set incsearch&amp;lt;CR&amp;gt;/&#xA;&#xA;augroup vimrc-noincsearch-highlight&#xA;  autocmd!&#xA;  autocmd CmdlineLeave / :set noincsearch |  :noh &#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything works fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only tiny problem is that I get a beep every time I use it! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use other keys as well, but I get the same anonying beep. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Temporary solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set visualbell t_vb=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2018-10-25T23:00:37.613" LastActivityDate="2019-06-04T01:55:41.237" Title="Beep upon using a mapping" Tags="|key-bindings|autocmd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17738" PostTypeId="2" ParentId="17717" CreationDate="2018-10-26T01:26:39.147" Score="0" Body="&lt;p&gt;In &lt;code&gt;fish&lt;/code&gt; syntax: &lt;code&gt;for file in ~/.cache/vim/swap/*; [ (cat &quot;$file&quot; | dd ibs=1 skip=1007 count=1 2&amp;gt; /dev/null) != 'U' ]; and rm &quot;$file&quot;; end;&lt;/code&gt; - this &lt;em&gt;works&lt;/em&gt;, but seems to me fragile - ie, if the &lt;code&gt;vim&lt;/code&gt; swap file format changes, this would fail (and possibly lead to data loss equivalent to removing all swap files).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't bother with this (in the &quot;have not tried yet&quot; section of my question) because I feel it is too risky/fragile, until a comment angered me enough to make it worth the bother to prove that it &lt;em&gt;is&lt;/em&gt;, in fact, possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe there exist other, better solutions. Please help me find one.&lt;/p&gt;&#xA;" OwnerUserId="8846" LastActivityDate="2018-10-26T01:26:39.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17739" PostTypeId="2" ParentId="1983" CreationDate="2018-10-26T02:19:33.233" Score="3" Body="&lt;p&gt;Add this in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufEnter * set fo-=c fo-=r fo-=o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;FileType&lt;/code&gt; won't work since other plugins set &lt;code&gt;formatoption&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2018-10-26T02:19:33.233" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17740" PostTypeId="1" AcceptedAnswerId="17741" CreationDate="2018-10-26T05:26:53.950" Score="0" ViewCount="1279" Body="&lt;p&gt;Neovim from the command line works great in Linux, and I have been using it as a drop in replacement for vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am forced to work with windows (7) at my workplace. I am using vim8 which lacks some of my favourite features and also comes out as unreliable with some of the modern plugins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to install neovim several times on my windows machine and have never got the qt gui to work. I have tried to install by download and by chocolatey. I have also tried installing on windows 10. Neovim has never worked for me, and I always get a small window with the message that &quot;Neovim is taking too long to respond&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am just wondering, is it just me who is incompetent or does it betray everyone?&lt;/p&gt;&#xA;" OwnerUserId="17487" LastEditorUserId="17487" LastEditDate="2018-10-26T07:04:00.863" LastActivityDate="2018-10-26T07:23:49.513" Title="Has nvim ever worked on windows for anyone?" Tags="|neovim|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17741" PostTypeId="2" ParentId="17740" CreationDate="2018-10-26T07:16:53.840" Score="2" Body="&lt;p&gt;I have it installed on my Win10 using scoop. Neovim-qt works better than nvim on cmd but still vim8 is more reliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Issue with &quot;Neovim is taking too long to respond&quot; happens when you have smth wrong in your init.vim. Console nvim shows the error and you can continue, neovim-qt on the other hand just hangs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I add the &lt;code&gt;messssagae &quot;hello world&quot;&lt;/code&gt; as the first line of &lt;code&gt;init.vim&lt;/code&gt; I got the behaviour you describe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest to try run nvim using cmd first, fix the errors that it shows and then try neovim-qt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally like the idea of neovim, but on windows still use vim8 most of the time.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2018-10-26T07:23:49.513" LastActivityDate="2018-10-26T07:23:49.513" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17742" PostTypeId="2" ParentId="17725" CreationDate="2018-10-26T08:07:38.943" Score="1" Body="&lt;p&gt;Vim generally identifies the filetype(and therefore the syntax higlighting) from the extension of a file. &lt;code&gt;one.py&lt;/code&gt; would imply that it's a Python file. But in your case, since your file &lt;code&gt;netctl&lt;/code&gt; does not have an extension, it is not able to ascertain the filetype. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the syntax of assignments in &lt;code&gt;netctl&lt;/code&gt; is very similar to Python, you can type &lt;code&gt;:set syntax=python&lt;/code&gt; in the normal mode. You could also do the same with &lt;code&gt;:set filetype=python&lt;/code&gt;. Though it would do the trick, I do not recommend the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you extensively work with these files, you could make your own vim syntax files . Have a look at &lt;code&gt;:help syntax&lt;/code&gt; in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit : As @Christian mentioned in comment,&lt;code&gt;:set syntax=dosini&lt;/code&gt; will set the syntax highlighting as it's an &lt;code&gt;ini&lt;/code&gt; file&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="16789" LastEditorUserId="16789" LastEditDate="2018-10-27T17:11:33.477" LastActivityDate="2018-10-27T17:11:33.477" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17743" PostTypeId="1" AcceptedAnswerId="17751" CreationDate="2018-10-26T10:13:24.340" Score="0" ViewCount="1112" Body="&lt;p&gt;I'm using this setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F2&amp;gt; :tabnext&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;F2&amp;gt; :tabnext&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it just moves cursor down one line like &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; does...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I map F2 to moving to next tab?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Environment: Debian 9.5 amd64, KDE&lt;/p&gt;&#xA;" OwnerUserId="19525" LastActivityDate="2018-10-27T09:09:16.743" Title="Cannot remap F2 in vim (vim.gtk)" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17745" PostTypeId="2" ParentId="17743" CreationDate="2018-10-26T11:06:56.290" Score="2" Body="&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F2&amp;gt; :tabnext&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should work from within normal mode. And it works for me. Check the output of &lt;code&gt;:verbose noremap &amp;lt;F2&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;F2&amp;gt; :tabnext&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will not work. You have to add &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;F2&amp;gt; &amp;lt;ESC&amp;gt;:tabnext&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is because you will invoke it from insert mode and without escape it will just issue &lt;code&gt;:tabnext&amp;lt;CR&amp;gt;&lt;/code&gt; as a text.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2018-10-26T11:06:56.290" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17746" PostTypeId="2" ParentId="17728" CreationDate="2018-10-26T11:17:12.743" Score="2" Body="&lt;p&gt;According to the documentation &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#map_bar&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help map_bar&lt;/code&gt;&lt;/a&gt; using  should work. A simple mapping I tried did just work. So try removing the &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; from your mapping and see if it will be put into the command line&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-10-26T11:17:12.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17747" PostTypeId="1" AcceptedAnswerId="17750" CreationDate="2018-10-26T11:42:51.343" Score="3" ViewCount="67" Body="&lt;p&gt;I use auto completion in my shell (zsh) and I'm often a bit sloppy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt;&#xA;Imagine I have the files &lt;code&gt;sourcecode.c&lt;/code&gt; and &lt;code&gt;sourcecode.h&lt;/code&gt; in the current directory.&#xA;I type &lt;code&gt;vim sour&amp;lt;TAB&amp;gt;&amp;lt;ENTER&amp;gt;&lt;/code&gt; and get &lt;code&gt;vim sourcecode.&amp;lt;ENTER&amp;gt;&lt;/code&gt; autocompleted. Vim opens a new file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like vim to ask me, if I forgot to mention the suffix and maybe even suggest the possible files (like in the directory open mode).&#xA;Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;You opened sourcecode.&#xA;Did you mean: sourcecode.c&#xA;              sourcecode.h&#xA;            &amp;gt; create new file sourcecode.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this possible? Does a plugin exist that does something like that?&lt;/p&gt;&#xA;" OwnerUserId="19550" LastActivityDate="2018-10-26T15:19:28.053" Title="Ask if file extension is missing when opening new file" Tags="|filetype|filesystem|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17748" PostTypeId="2" ParentId="11320" CreationDate="2018-10-26T13:00:08.637" Score="1" Body="&lt;p&gt;&lt;code&gt;matchit&lt;/code&gt; will most probably not do this for you.  You probably want to write a small wrapper function for &lt;code&gt;%&lt;/code&gt;, which identifies the character under your cursor with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let curChar = char2nr(matchstr(getline('.'), '\%' . col('.') . 'c.'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;followed by a couple of simple nested tests such that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;test-1: if curChar is not `&amp;lt;`, then&#xA;     act simply the way `%` would&#xA;else &#xA;    test-2:  if whatever lies between current `&amp;lt;` and following `&amp;gt;` contains one of ( or ) or { or } or [ or ], then&#xA;        do not jump or highlight&#xA;    else&#xA;        jump or highlight&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which means , &lt;strong&gt;&lt;em&gt;get scripting in vim&lt;/em&gt;&lt;/strong&gt; ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let us know how this goes.&lt;/p&gt;&#xA;" OwnerUserId="4547" LastEditorUserId="4547" LastEditDate="2018-10-26T13:59:27.687" LastActivityDate="2018-10-26T13:59:27.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17749" PostTypeId="1" AcceptedAnswerId="17758" CreationDate="2018-10-26T14:57:06.960" Score="2" ViewCount="179" Body="&lt;p&gt;&lt;em&gt;[Vim 8.0.1 / Syntastic 3.9.0-19 / Vundle 0.5 / vint 0.3.19 on Arch Linux]&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim linter seems to be broken and I don't quite understand why. &lt;BR&gt;&#xA;It's been working fine in its present configuration, until this morning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get the following error message, when I write any buffer identified&#xA;as &lt;code&gt;vim&lt;/code&gt; filetype to disk:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;syntastic: warning: checker vim/vint: unrecognized error format&#xA;  (crashed checker?)&lt;BR&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is also the content of &lt;code&gt;:messages&lt;/code&gt; in buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Startpage&quot;-ing it returned zero relevant result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pertinent &lt;code&gt;~/.vimrc&lt;/code&gt; section ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype off&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'vim-syntastic/syntastic'&#xA;Plugin 'Valloric/YouCompleteMe.git'&#xA;Plugin 'Townk/vim-autoclose' &#xA;Plugin 'dougireton/vim-chef'&#xA;Plugin 'jimhester/lintr'&#xA;Plugin 'vim-scripts/LaTeX-Suite-aka-Vim-LaTeX'&#xA;Plugin 'Kuniwak/vint'&#xA;call vundle#end()&#xA;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Syntastic is aware of $USER $PATH:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo syntastic#util#system('echo &quot;$PATH&quot;')&#xA;/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/opt/bin:/opt/scripts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The runtime path includes Vundle:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set runtimepath?&#xA;runtimepath=~/.vim,~/.vim/bundle/Vundle.vim,~/.vim/bundle/syntastic,~/.vim/bundle/YouCompleteMe,~/.vim/bundle/vim-autoclose,~/.vim/bundle/vim-chef,~/.vim/bundle/lintr,~/.vim/bundle/LaTeX-Suite-aka-Vim-LaTeX,~/.vim/bundle/vint,/usr/share/vim/vimfiles,/usr/share/vim/vim81,/usr/share/vim/vim81/pack/dist/opt/matchit,/usr/share/vim/vimfiles/after,~/.vim/after,~.vim/bundle/Vundle.vim,~/.vim/bundle/Vundle.vim/after,~/.vim/bundle/syntastic/after,~/.vim/bundle/YouCompleteMe/after,~/.vim/bundle/vim-autoclose/after,~/.vim/bundle/vim-chef/after,~/.vim/bundle/lintr/after,~/.vim/bundle/LaTeX-Suite-aka-Vim-LaTeX/after,~/.vim/bundle/vint/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The cloned git repo in &lt;code&gt;~/.vim/bundle/Vundle.vim&lt;/code&gt; is up to date.&#xA;The &lt;code&gt;vint&lt;/code&gt; executable is correctly located at &lt;code&gt;/usr/bin/vint&lt;/code&gt; and I inserted the following in &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  let g:syntastic_vim_checkers = ['vint']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so that issuing ex cmd &lt;code&gt;:SyntasticInfo [vim]&lt;/code&gt; does yield &lt;code&gt;vint&lt;/code&gt; and the correct filetype, &quot;vim&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am stumped. Has anybody seen this before ?&lt;/p&gt;&#xA;" OwnerUserId="4547" LastEditorUserId="4547" LastEditDate="2018-11-14T17:18:20.510" LastActivityDate="2018-11-14T17:18:20.510" Title="`vint` linter just quits due to a vim plugin incompatibility" Tags="|linux|plugin-syntastic|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17750" PostTypeId="2" ParentId="17747" CreationDate="2018-10-26T15:19:28.053" Score="3" Body="&lt;p&gt;You may be interested in the &lt;a href=&quot;https://github.com/EinfachToll/DidYouMean&quot; rel=&quot;nofollow noreferrer&quot;&gt;didyoumean&lt;/a&gt; plugin, whose description is the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you're like me and you want to edit a specific file with Vim, say, &lt;code&gt;test.py&lt;/code&gt;, you type vim te into the terminal, then you hit &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; immediately because you think your shell expands the characters to the right file name. But if there's another file starting with te, Vim fires up with an empty file called te, laughing at you. That's annoying. This simple plugin makes Vim ask for the right file to open.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2018-10-26T15:19:28.053" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17751" PostTypeId="2" ParentId="17743" CreationDate="2018-10-27T09:09:16.743" Score="0" Body="&lt;p&gt;I found the culprit - it was KDE + Gnome Terminator's fault (&lt;a href=&quot;https://gnometerminator.blogspot.com/p/introduction.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gnometerminator.blogspot.com/p/introduction.html&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="19525" LastActivityDate="2018-10-27T09:09:16.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17753" PostTypeId="2" ParentId="17489" CreationDate="2018-10-27T15:14:07.417" Score="2" Body="&lt;p&gt;If your cursor is at the start of the class, then &lt;code&gt;vt.&lt;/code&gt; should work. If it’s anywhere else in the example text then just jump to the start first: &lt;code&gt;Bvt.&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-10-27T15:14:07.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17754" PostTypeId="1" CreationDate="2018-10-27T16:34:50.177" Score="1" ViewCount="246" Body="&lt;p&gt;I recently discovered &lt;code&gt;iskeyword&lt;/code&gt; as in &lt;code&gt;set iskeyword-=_&lt;/code&gt; so that I can change just part of a snake case word, like changing &lt;code&gt;character_idx&lt;/code&gt; to &lt;code&gt;char_idx&lt;/code&gt; using &lt;code&gt;ciw&lt;/code&gt;. This was working great, except sometimes I want to change the &lt;em&gt;entire&lt;/em&gt; word, so I turned it off (it also was causing havoc with the syntax highlighting). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am wondering if there is a way to define a new text object that is essentially &lt;code&gt;w&lt;/code&gt; with &lt;code&gt;iskeyword-=_&lt;/code&gt; set so that I could execute &lt;code&gt;ci\&lt;/code&gt; (or something, I am not sure how to prevent collisions with vim commands already in existence) and change just part of a snake case word, while retaining &lt;code&gt;ciw&lt;/code&gt; for whole snake case words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not even sure how to tag this.&lt;/p&gt;&#xA;" OwnerUserId="17830" LastEditorUserId="1292" LastEditDate="2019-01-24T13:03:35.660" LastActivityDate="2019-01-24T13:03:35.660" Title="Define new text object for snake case" Tags="|vimrc|custom-text-object|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17755" PostTypeId="1" AcceptedAnswerId="18993" CreationDate="2018-10-27T17:48:44.537" Score="6" ViewCount="826" Body="&lt;p&gt;In tmux if you have alot of panes open, you can press CTRL+B, z to zoom into that terminal pane.  Is there a way to do the same thing in vim, to zoom into / out of the selected pane?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="1065" LastEditDate="2019-02-22T02:17:12.990" LastActivityDate="2022-09-15T18:55:06.167" Title="Equivalent to tmux CTRL+B z in vim?" Tags="|tmux|navigation|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17756" PostTypeId="1" AcceptedAnswerId="17762" CreationDate="2018-10-27T18:27:01.583" Score="4" ViewCount="353" Body="&lt;p&gt;I am trying to replace all quotes (&quot;) with escaped quotes (\&quot;) and simultaneously all escaped quotes with normal quotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the following solution to a similar problem &lt;a href=&quot;https://stackoverflow.com/questions/3578549/easiest-way-to-swap-occurrences-of-two-strings-in-vim&quot;&gt;here&lt;/a&gt; for swapping 'foo' to 'bar' and vice versa:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(foo|bar)/\={'foo':'bar','bar':'foo'}[submatch(0)]/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I cannot translate it to my particular case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem being that every escaped quote contains also a normal quote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking forward to your suggestions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I want to avoid first replacing all escaped quotes with a different (and hopefully unique) pattern, then replacing all remaining normal quotes with escaped quotes, and then replacing the different pattern with normal quotes - but rather do it in one go.&lt;/p&gt;&#xA;" OwnerUserId="19565" LastEditorUserId="19565" LastEditDate="2018-10-27T20:48:19.460" LastActivityDate="2020-07-31T22:37:55.743" Title="Replace all quotes with escaped quotes and vice versa" Tags="|substitute|replace|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17757" PostTypeId="2" ParentId="10598" CreationDate="2018-10-28T01:10:51.370" Score="6" Body="&lt;p&gt;LEI is right; and the &lt;code&gt;neovim&lt;/code&gt; help instructions give this as a &lt;a href=&quot;https://neovim.io/doc/user/starting.html#shada-read-write&quot; rel=&quot;noreferrer&quot;&gt;specific use case&lt;/a&gt; for that feature:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Two commands can be used to read and write the ShaDa file manually. &#xA;  This can be used to exchange registers between two running Vim&#xA;  programs: First type &quot;:wsh&quot; in one and then &quot;:rsh&quot; in the other.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="19569" LastActivityDate="2018-10-28T01:10:51.370" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17758" PostTypeId="2" ParentId="17749" CreationDate="2018-10-28T09:35:36.053" Score="0" Body="&lt;p&gt;The &lt;code&gt;Kuniwak/vint&lt;/code&gt; lint checker breaks (im my setup) when parsing non-ASCII characters. It happens as soon as even one character outside the 0-127 ASCII range (plus a few such as &quot;_&quot;, etc. ) appear in the vim-script, no matter where, i.e. inside or outside comments. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As suggested by @lcd047, I added debug option flags to my &lt;code&gt;~/.vimrc&lt;/code&gt; to catch more verbose messages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;let g:syntastic_debug = 3&#xA;&quot;let g:syntastic_debug_file = '~/.vim/syntastic.log'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The content of &lt;code&gt;:messages&lt;/code&gt; revealed:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;/usr/lib/python3.7/site-packages/vint/encodings/decoding_strategy.py&quot;,&#xA;  line 77, in decode', ' return&#xA;  bytes_seq.decode(encoding=encoding_part.decode(encoding=''ascii''))',&#xA;  'UnicodeDecodeError: ''ascii'' codec can''t decode byte 0xc2 in&#xA;  position 33: ordinal not in range(128)', '']&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;syntastic: warning:&#xA;  checker vim/vint: unrecognized error format (crashed checker?)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As it turns out, byte 0xc2 is the first byte of the two-byte non-ASCII character &quot;º&quot; that I had just mapped as in: &lt;code&gt;inoremap &amp;lt;C-º&amp;gt; &amp;lt;Esc&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mapping worked just fine ... and &lt;code&gt;vint&lt;/code&gt; just quit.  In retrospect I find it curious that in support of the suspicion that &lt;code&gt;vint&lt;/code&gt; was at fault, running &lt;code&gt;:echo system('vint $USER/.vimrc --json')&lt;/code&gt; in-buffer, and &lt;code&gt;$ vint $USER/.vimrc&lt;/code&gt; from console, produced the exact same error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I opened an &lt;a href=&quot;https://github.com/Kuniwak/vint/issues/292&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue&lt;/a&gt; at the &lt;code&gt;vint&lt;/code&gt; GitHub repo.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In the end the &lt;code&gt;Kuniwak/vint&lt;/code&gt; lint checker works fine. Another plugin causes an incompatibility and is at fault: &lt;code&gt;Townk/vim-autoclose&lt;/code&gt;.  It somehow makes &lt;code&gt;vint&lt;/code&gt; crash when parsing non-ASCII characters. Also for instance, syntax highlighting groups targeting those same non-ASCIIs do not work when &lt;code&gt;autoclose&lt;/code&gt; is loaded. It also causes weird results when used in conjunction with YouCompleteMe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution: replace &lt;code&gt;Townk/vim-autoclose&lt;/code&gt; with &lt;code&gt;Raimondi/delimitMate&lt;/code&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="4547" LastEditorUserId="4547" LastEditDate="2018-11-14T17:15:30.643" LastActivityDate="2018-11-14T17:15:30.643" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17759" PostTypeId="1" CreationDate="2018-10-28T10:13:34.580" Score="11" ViewCount="1028" Body="&lt;p&gt;Vim supports syntax highlighting for embedded languages or fenced code in markdown (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-include&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :syn-include&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;However, you usually want that other vim settings and mappings are adjusted for embedded languages as well. These are for example&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;load/unload ftplugins containing settings for example for&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;b:match_words&lt;/code&gt; used by matchit's &lt;code&gt;%&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;commentstring&lt;/code&gt; (e.g. for vim-commentary)&lt;/li&gt;&#xA;&lt;li&gt;square bracket motions (e.g. done in &lt;code&gt;VIMRUNTIME/ftplugin/[vim,ruby,python,...].vim&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;folds (&lt;code&gt;foldmethod&lt;/code&gt; or &lt;code&gt;foldexpr&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;indentation scripts in &lt;code&gt;$VIMRUNTIME/indent/&amp;lt;language&amp;gt;.vim&lt;/code&gt; (&lt;code&gt;indentexpr&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;formatting (&lt;code&gt;formatprg&lt;/code&gt; or dedicated plugins autoformat, neoformat)&lt;/li&gt;&#xA;&lt;li&gt;'intellisense' completion (&lt;code&gt;omnifunc&lt;/code&gt; or dedicated plugins ycm, deoplete, ncm2)&lt;/li&gt;&#xA;&lt;li&gt;linting (run compiler for code region or dedicated plugins ale, neomake or syntastic)&lt;/li&gt;&#xA;&lt;li&gt;ft snippets (ultisnips or snipmate)&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Plugins&lt;/h3&gt;&#xA;&lt;p&gt;I know which are dedicated to this or have builtin support are&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/suy/vim-context-commentstring&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-context-commentstring&lt;/a&gt; (defines autocmd for the event &lt;code&gt;CursorMoved&lt;/code&gt; and uses the current syntax group to adjust the &lt;code&gt;commentstring&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/JoosepAlviste/nvim-ts-context-commentstring&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvim-ts-context-commentstring&lt;/a&gt; Neovim treesitter plugin for setting the commentstring based on the cursor location in a file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tomtom/tcomment_vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;tcomment&lt;/a&gt; (see &lt;code&gt;g:tcomment#filetype#guess&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;ncm2 subscopes, e.g. &lt;a href=&quot;https://github.com/ncm2/ncm2-markdown-subscope&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ncm2/ncm2-markdown-subscope&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Shougo/context_filetype.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;context_filetype.vim&lt;/a&gt;, e.g. for deoplete&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Relevant Tools&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;universal ctags can use several parsers for one file, &lt;a href=&quot;https://docs.ctags.io/en/latest/running-multi-parsers.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.ctags.io/en/latest/running-multi-parsers.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;It is one thing to adjust a single setting as done by &lt;a href=&quot;https://github.com/suy/vim-context-commentstring&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/suy/vim-context-commentstring&lt;/a&gt; but I miss support for the adjustments done in &lt;code&gt;$VIMRUNTIME/ftplugin&lt;/code&gt; and the &lt;code&gt;$VIMRUNTIME/indent/&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Afaik, this is something which vim does not really cover. For example, I use the plugin SimpylFold which defines folds for python as I want it and vimtex for LaTeX files. However, I would not know if vim can combine this for a single latex file using pythontex.&lt;/p&gt;&#xA;&lt;p&gt;I am not familiar with other editors and their solutions for this. A quick search revealed for &lt;a href=&quot;https://code.visualstudio.com/docs/extensions/themes-snippets-colorizers#_embedded-languages&quot; rel=&quot;nofollow noreferrer&quot;&gt;Visual Studio Code&lt;/a&gt; that vscode supports out of the box adjusted syntax highlighting and commenting.&lt;/p&gt;&#xA;&lt;p&gt;Did I miss something in vim itself supporting loading/unloading ftplugin/indent or do you occasionally change the filetype by yourself?&lt;/p&gt;&#xA;&lt;p&gt;Today many tasks (e.g. autocompletion, linting, snippets, formatting) are provided by dedicated plugins: Which of the major plugins i.e. ycm, deoplete, ale, syntastic, tagbar, ultisnips, snipmate, autoformat and neoformat support this?&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2022-11-04T07:31:49.430" LastActivityDate="2022-11-04T07:31:49.430" Title="Support for embedded languages" Tags="|filetype|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17760" PostTypeId="1" CreationDate="2018-10-28T12:02:28.457" Score="3" ViewCount="1247" Body="&lt;p&gt;I have the following configuration for OCaml development which works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; --------------- OCaml -----------------------------&#xA;&quot; Merlin&#xA;let g:opamshare = substitute(system('opam config var share'),'\n$','','''')&#xA;execute 'set rtp+=' . g:opamshare . '/merlin/vim'&#xA;&quot; ocp-indent&#xA;execute 'set rtp^=' . g:opamshare . '/ocp-indent/vim'&#xA;&quot; enable deoplete&#xA;let g:deoplete#enable_at_startup = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Given that I use differents languages, I want to just use this configuration with OCaml files so I tried to create a function and to call it if the FileType is ocaml:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup OCaml_Environment&#xA;  autocmd!&#xA;  autocmd FileType ocaml :call OCamlEnvSetup()&#xA;augroup END&#xA;&#xA;function! OCamlEnvSetup()&#xA;  let g:opamshare = substitute(system('opam config var share'),'\n$','','''')&#xA;  execute 'set rtp+=' . g:opamshare . '/merlin/vim'&#xA;  &quot; ocp-indent&#xA;  execute 'set rtp^=' . g:opamshare . '/ocp-indent/vim'&#xA;  &quot; enable deoplete&#xA;  let g:deoplete#enable_at_startup = 1&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But now I can not access to commands defined in merlin/vim for example. What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the answers I modified my function: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup OCaml_Environment&#xA;    autocmd!&#xA;    autocmd FileType ocaml :call OCamlEnvSetup()&#xA;augroup END&#xA;&#xA;&#xA;function! OCamlEnvSetup()    &#xA;   let g:opamshare = substitute(system('opam config var share'),'\n$','','''')&#xA;   execute 'set rtp+=' . g:opamshare . '/merlin/vim'&#xA;   execute 'runtime ' . g:opamshare . '/merlin/vim'&#xA;   &quot; ocp-indent&#xA;   execute 'set rtp^=' . g:opamshare . '/ocp-indent/vim'&#xA;   execute 'runtime ' . g:opamshare . '/ocp-indent/vim'&#xA;endfunction&#xA;&#xA;let g:deoplete#enable_at_startup = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this I have the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[deoplete] Merlin not found, make sure ocamlmerlin is in your path and merlin's vim plugin is installed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After that I tried to use a filetype-plugin too, creating the file &lt;em&gt;~/.config/nvim/ftplugin/ocaml.vim&lt;/em&gt; with the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:opamshare = substitute(system('opam config var share'),'\n$','','''')&#xA;execute 'set rtp+=' . g:opamshare . '/merlin/vim'&#xA;execute 'runtime ' . g:opamshare . '/merlin/vim/plugin/**/*.vim'&#xA;&quot; ocp-indent&#xA;execute 'set rtp^=' . g:opamshare . '/ocp-indent/vim'&#xA;execute 'runtime ' . g:opamshare . '/ocp-indent/vim/plugin/**/*.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But now it looks like the configuration is not loaded, because for example, I can not use the &lt;code&gt;:MerlinTypeOf&lt;/code&gt; that is available with merlin.vim. &lt;/p&gt;&#xA;" OwnerUserId="8475" LastEditorUserId="8475" LastEditDate="2018-11-03T08:32:32.557" LastActivityDate="2018-11-03T09:48:38.257" Title="set rtp in a function does not work" Tags="|vimrc|vimscript|neovim|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17761" PostTypeId="1" CreationDate="2018-10-28T12:32:47.230" Score="-1" ViewCount="507" Body="&lt;p&gt;I want to include a new highlight group and autocommand that will automatically highlight non-ASCIIs as soon as either a vimscript or a Python file is loaded in buffer (i.e. any file with filetype 'vim').&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I included what follows in my ~/.vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight NonASCII ctermbg=Black ctermfg=Red cterm=italic&#xA;                    &quot; guibg=Black guifg=Red&#xA;autocmd BufReadPost * if  count(['vim','python'],&amp;amp;filetype) &#xA;            \ | syntax match Nonascii &quot;[^\u0000-\u007F]&quot;  containedin=ALL &#xA;            \ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... does not highlight anything. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried replacing &lt;code&gt;&quot;[^\u0000-\u007F]&quot;&lt;/code&gt; with the equivalent &lt;code&gt;&quot;[^\x00-\x7F]&quot;&lt;/code&gt; and &lt;code&gt;&quot;[^\d0-\d127]&quot;&lt;/code&gt; without any more success. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Any help on this much welcome.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;BR&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The syntax highlight group &lt;code&gt;Nonascii&lt;/code&gt; does show up in output of &lt;code&gt;:hi&lt;/code&gt; along with others I tweaked or created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The complete content of my &lt;code&gt;~/.vimrc&lt;/code&gt; is available as the file &lt;code&gt;vimrc&lt;/code&gt; &lt;a href=&quot;https://github.com/Cbhihe/vim.git&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. So is output of &lt;code&gt;:syntax&lt;/code&gt; in file &lt;code&gt;syn.out&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created file &lt;code&gt;test.vim&lt;/code&gt; whose content is simply:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/vim&#xA;set encoding=utf-8&#xA;scriptencoding=utf-8&#xA;set termencoding=utf-8&#xA;inoremap &amp;lt;C-º&amp;gt; &amp;lt;Esc&amp;gt; &#xA;&quot;  é è ä&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... then executed &lt;code&gt;$ vim -V13debug.log test.vim&lt;/code&gt;.  &lt;BR&gt;&#xA;For those (as I) new to this, a good tutorial to get started with debugging vimscripts is &lt;a href=&quot;http://inlehmansterms.net/2014/10/31/debugging-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4547" LastEditorUserId="4547" LastEditDate="2018-10-28T20:20:32.883" LastActivityDate="2018-12-15T20:41:40.623" Title="Automatic highlighting non ASCII character when loading 'vim' filetype buffer" Tags="|autocmd|highlight|filetype|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17762" PostTypeId="2" ParentId="17756" CreationDate="2018-10-28T12:41:18.547" Score="4" Body="&lt;p&gt;I was able to use the method you found without issue. Perhaps you missed something with the escaping.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v(\\&amp;quot;|&amp;quot;)/\={'\&amp;quot;':'&amp;quot;','&amp;quot;':'\&amp;quot;'}[submatch(0)]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I &amp;quot;escape the escape&amp;quot; in the substitution pattern but not in the dictionary since the latter uses single quotes within which the text is interpreted literally.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; FYI, you can simplify the pattern a little, in this particular case, by using &lt;code&gt;\\\?&amp;quot;&lt;/code&gt; (though that strays from the generalized solution that you found).&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-07-31T22:37:55.743" LastActivityDate="2020-07-31T22:37:55.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17763" PostTypeId="2" ParentId="17761" CreationDate="2018-10-28T13:24:41.680" Score="1" Body="&lt;p&gt;As we discussed in comments you can restrict this to specific file patterns in place of &lt;code&gt;*&lt;/code&gt;. For vim type files &lt;code&gt;*.vim&lt;/code&gt; is usually sufficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I tried it with a known highlighting, &lt;code&gt;ErrorMsg&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead *.vim,*.python,*.py syntax match ErrorMsg &quot;[^\x00-\x7F]&quot; containedin=all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine for me. I opened &lt;code&gt;foo.vim&lt;/code&gt; and added a couple digraphs and they were colored as expected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next I tried your highlighting command and that also works. Still, terminals and coloring can be finicky so you should verify that it works for you outside of the syntax matching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All in all things work for me as specified above so you might have a typo or other small error somewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;From a previous comment...&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assumed syntax highlighting is working for you in general and you therefore have all correct configuration, generally speaking. So what to try next...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Are your entries showing up in &lt;code&gt;:syn&lt;/code&gt; and &lt;code&gt;:hi&lt;/code&gt; (or &lt;code&gt;:verbose hi&lt;/code&gt; to show origin) listings? (&lt;em&gt;OP already checked this.&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Speaking of &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#:verbose&quot; rel=&quot;nofollow noreferrer&quot;&gt;:verbose&lt;/a&gt; you might want to think about setting that and stepping through initialization&lt;/li&gt;&#xA;&lt;li&gt;Try a stripped down vimrc with only the relevant parts&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;a href=&quot;http://vimhelp.appspot.com/starting.txt.html#--noplugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;--noplugin&lt;/a&gt; to rule out any interference from installed plugins&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; OP observes that everything works fine when Vim is started with &lt;code&gt;--noplugin&lt;/code&gt;. They tracked the issue down to a &lt;em&gt;vim-autoclose&lt;/em&gt; plugin, reported a bug (though the plugin may no longer be under maintenance), and switched to alternative plugin &lt;em&gt;delimitMate&lt;/em&gt;. That's probably the end-of-the-road for this Q&amp;amp;A.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-12-15T20:41:40.623" LastActivityDate="2018-12-15T20:41:40.623" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17764" PostTypeId="1" AcceptedAnswerId="17766" CreationDate="2018-10-28T19:22:53.243" Score="4" ViewCount="488" Body="&lt;p&gt;In vim, how can I display the &lt;code&gt;rwx&lt;/code&gt; (i.e., permissions) of files and/or directories using &lt;code&gt;netrw&lt;/code&gt;? For example, I'd like to do this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;vim&lt;/li&gt;&#xA;&lt;li&gt;:Ex&lt;/li&gt;&#xA;&lt;li&gt;(see output like ls -l)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The closest thing I know is, in step 3, to press &lt;code&gt;i&lt;/code&gt;, which shows this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;USR3SA9P89W.TXT*                    14830 Tue 14 Mar 2017 08:03:48 AM CDT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15006" LastEditorUserId="51" LastEditDate="2018-10-28T22:47:02.023" LastActivityDate="2018-10-28T23:40:24.560" Title="How to display rwx permissions with netrw?" Tags="|netrw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17765" PostTypeId="1" CreationDate="2018-10-28T21:28:42.390" Score="5" ViewCount="173" Body="&lt;p&gt;When I'm using &lt;code&gt;:make&lt;/code&gt;, the output doesn't have any color. The text is only white. &#xA;But when I'm using &lt;code&gt;:!make&lt;/code&gt; for a C project or &lt;code&gt;:Cargo run&lt;/code&gt; for a rust project ( I also use rust.vim ) , there are colors on the output. ( the colors that the c compiler or the rust compiler have by default) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make the output of &lt;code&gt;make&lt;/code&gt; colorful ? &lt;/p&gt;&#xA;" OwnerUserId="19572" LastActivityDate="2018-10-28T21:28:42.390" Title="Have colors when using :make" Tags="|color|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17766" PostTypeId="2" ParentId="17764" CreationDate="2018-10-28T23:40:24.560" Score="1" Body="&lt;p&gt;I'm not aware of any way to do this such that the full listing will show file permissions. However you can see extra information, including permissions, for individual files. Put the cursor on a file/directory and type &lt;code&gt;qf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a simple, non-netrw solution you could always run &lt;code&gt;ls -l&lt;/code&gt; through the shell. For instance, to &quot;long-list&quot; the directory in which the current buffer resides...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!ls -l %:p:h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2018-10-28T23:40:24.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17767" PostTypeId="1" AcceptedAnswerId="17768" CreationDate="2018-10-29T09:23:45.973" Score="4" ViewCount="572" Body="&lt;p&gt;I want to map &lt;code&gt;:e file.txt&lt;/code&gt; to &lt;code&gt;:tabnew file.txt&lt;/code&gt;, or the equivalent setting for editing file in a new tab. What do I need to put into my vimrc?&lt;/p&gt;&#xA;" OwnerUserId="18929" LastEditorUserId="343" LastEditDate="2018-10-29T20:13:09.567" LastActivityDate="2018-10-29T20:21:21.983" Title="How to edit a file in a new tab?" Tags="|command-line|user-commands|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17768" PostTypeId="2" ParentId="17767" CreationDate="2018-10-29T10:59:30.720" Score="4" Body="&lt;p&gt;You probably want to read &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#user-commands&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h user-commands&lt;/code&gt;&lt;/a&gt; and put the following in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=file E tabnew &amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can't override &lt;code&gt;:e&lt;/code&gt; but you can create the command &lt;code&gt;:E&lt;/code&gt; which will take one argument (&lt;code&gt;-nargs=1&lt;/code&gt;), complete this argument as &lt;code&gt;tabnew&lt;/code&gt; does (&lt;code&gt;-complete=file&lt;/code&gt;) and executes &lt;code&gt;tabnew&lt;/code&gt; with the argument it took.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However as @Hotschke said in comments you probably don't need such a command.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-10-29T10:59:30.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17769" PostTypeId="1" AcceptedAnswerId="17798" CreationDate="2018-10-29T15:54:27.993" Score="1" ViewCount="945" Body="&lt;p&gt;I open a file with vim, vim creates a swap file. Though I have not done any single edit on my file, the swap file has significant size, sometimes bigger than the size of the original file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, original file = 1.4K, swap = 12K.&#xA;What's written inside the swap file that makes it bigger than the original file?&lt;/p&gt;&#xA;" OwnerUserId="19583" LastActivityDate="2018-11-01T10:43:41.100" Title="Why are swap files so big?" Tags="|swap-file|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17770" PostTypeId="1" CreationDate="2018-10-29T17:43:24.117" Score="1" ViewCount="154" Body="&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The changes I make in files before closing are not saved in .swp files&#xA;As I understand it, the swap file should save any changes if they are at least 200 characters long or nothing has been typed for 4 seconds&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Steps to Reproduce:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Create new file tmp.sql&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Write some text as a comment:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;/* This is the comment I wrote. I did not save after I wrote it*/&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Close window after about 10 seconds have passed&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Restart Vim and open file using “:e”&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I get the usual .swp message from vim&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I type “r” to recover&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Error Message:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error: “Unable to read block 0 from /home/csarraille/docs/qua/tmp.sql&#xA;&#xA;Maybe no changes were made or Vim did not update the swap file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Environment:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;My .swp files are stored in their own folder. I specify this in my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:set directory=$HOME/.vim/swapfiles//&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I use Cygwin on a Windows machine to run Vim 8.0&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Included Patches: 1-1567&lt;/p&gt;&#xA;" OwnerUserId="19586" LastEditorUserId="19586" LastEditDate="2018-10-29T18:07:06.213" LastActivityDate="2020-08-20T02:05:20.507" Title="Why is my small SQL comment not backed up in the .swp file?" Tags="|vimrc|swap-file|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17771" PostTypeId="2" ParentId="17767" CreationDate="2018-10-29T20:21:21.983" Score="2" Body="&lt;p&gt;Like everyone else, I recommend pretty strongly against doing this, but if you're dead set on the idea (and for future readers who might be doing something slightly different) you could use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cabbrev &amp;lt;expr&amp;gt; e getcmdline() == 'e' &amp;amp;&amp;amp; getcmdtype() == ':' ? 'tabnew' : 'e'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will replace &lt;code&gt;:e&lt;/code&gt; with &lt;code&gt;:tabnew&lt;/code&gt; as soon as you type the space after the &lt;code&gt;e&lt;/code&gt;. If you find the change too visually jarring, you could perhaps instead set up the the &lt;code&gt;E&lt;/code&gt; command from &lt;a href=&quot;https://vi.stackexchange.com/a/17768/343&quot;&gt;statox's answer&lt;/a&gt; and convert &lt;code&gt;:e&lt;/code&gt; into &lt;code&gt;:E&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :cabbrev&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-10-29T20:21:21.983" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17772" PostTypeId="2" ParentId="17769" CreationDate="2018-10-29T22:25:10.127" Score="1" Body="&lt;p&gt;Vim stores the things you changed in a swap file. Using the original file you started from plus the swap file you can mostly recover your work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/177/what-is-the-purpose-of-swap-files&quot;&gt;For a detail of What is the purpose of swap files?&lt;/a&gt;, follow the link.&lt;/p&gt;&#xA;" OwnerUserId="19587" LastActivityDate="2018-10-29T22:25:10.127" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17773" PostTypeId="2" ParentId="17770" CreationDate="2018-10-29T23:10:31.777" Score="1" Body="&lt;p&gt;I'm not sure why, but rather than what I had in my .vimrc for .swp file management, which was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set directory=$HOME/.vim/swapfiles//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...The error described below has resolved by using this, placed at the very end of my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set directory=/tmp//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For users of Cygwin, perhaps placing the swapfile directory within the .vim directory does not work.&lt;/p&gt;&#xA;" OwnerUserId="19586" LastActivityDate="2018-10-29T23:10:31.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17774" PostTypeId="1" AcceptedAnswerId="17775" CreationDate="2018-10-30T06:44:11.593" Score="8" ViewCount="3642" Body="&lt;p&gt;How can I delete the block&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int Test()&#xA;{&#xA;//&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when my cursor is before &lt;code&gt;int&lt;/code&gt; (or even better when it is anywhere on that line)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shortest I could come up with is &lt;code&gt;d&amp;lt;line&amp;gt;G&lt;/code&gt; where &lt;code&gt;&amp;lt;line&amp;gt;&lt;/code&gt; is the line number of the closing brace, or &lt;code&gt;d&amp;lt;diff&amp;gt;j&lt;/code&gt; where &lt;code&gt;&amp;lt;diff&amp;gt;&lt;/code&gt; is the difference of the line number. I am not happy with either.&lt;/p&gt;&#xA;" OwnerUserId="18613" LastActivityDate="2022-07-27T14:06:30.053" Title="How to delete entire function definition (C style)" Tags="|cursor-motions|normal-mode|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17775" PostTypeId="2" ParentId="17774" CreationDate="2018-10-30T09:07:17.290" Score="16" Body="&lt;h2&gt;Motion &lt;code&gt;][&lt;/code&gt;: next &lt;code&gt;}&lt;/code&gt; in the first column&lt;/h2&gt;&#xA;&lt;p&gt;&lt;code&gt;V][d&lt;/code&gt; does what you want. More details can be found under &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%5D%5B&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ][&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#section&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h section&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;                            *section*&#xA;[...]&#xA;The &amp;quot;]&amp;quot; and &amp;quot;[&amp;quot; commands stop at the '{' or '}' in the first column.  This is&#xA;useful to find the start or end of a function in a C program.  Note that the&#xA;first character of the command determines the search direction and the&#xA;second character the type of brace found.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Furthermore, vim's user manual has dedicated a paragraph about them within section  &lt;em&gt;29.3 Moving through a program&lt;/em&gt; (&lt;a href=&quot;http://vimhelp.appspot.com/usr_29.txt.html#29.3&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 29.3&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/50.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Chapt. 50 Section Movement Theory&lt;/em&gt;&lt;/a&gt; in the free ebook &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Learn Vimscript the Hard Way&lt;/em&gt;&lt;/a&gt; by Steve Losh gives you more background about them and explains in a subsequent chapter how to adapt them for a new language.&lt;/p&gt;&#xA;&lt;h3&gt;Memorizing&lt;/h3&gt;&#xA;&lt;p&gt;If you are not familiar with the set of square bracket motions &lt;code&gt;[[&lt;/code&gt;, &lt;code&gt;[]&lt;/code&gt;, &lt;code&gt;]]&lt;/code&gt;, &lt;code&gt;][&lt;/code&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/6459/make-sense-of?noredirect=1&amp;amp;lq=1&quot;&gt;you struggle memorizing&lt;/a&gt;, maybe following grouping and hints help:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt; jump to the &lt;em&gt;beginning&lt;/em&gt; (i.e. &lt;code&gt;{&lt;/code&gt;) of the current/previous and next function&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[]&lt;/code&gt; and &lt;code&gt;][&lt;/code&gt; jump to the &lt;em&gt;end&lt;/em&gt; (i.e. &lt;code&gt;}&lt;/code&gt;) of the previous and current/next function&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;As mentioned in the vim help page: the &lt;em&gt;first&lt;/em&gt; square bracket you type determines the &lt;em&gt;direction&lt;/em&gt; you move and the &lt;em&gt;second&lt;/em&gt; bracket the &lt;em&gt;type&lt;/em&gt; you are looking for. The second bracket is more difficult to grasp because the meaning can be seen as inconsistent: &lt;code&gt;[&lt;/code&gt; relates not to &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; not to &lt;code&gt;}&lt;/code&gt;.&lt;br /&gt;&#xA;I memorize it as&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;em&gt;beginning&lt;/em&gt; of function: square bracket must be &lt;em&gt;repeated&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;end&lt;/em&gt; of function: square bracket must be &lt;em&gt;alternated&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h3&gt;Are these not too specific to be generally useful aka exotic?&lt;/h3&gt;&#xA;&lt;p&gt;I think it is worthwhile to learn them: many languages use curly braces. Additionally, ftplugins in &lt;code&gt;$VIMRUNTIME/ftplugin&lt;/code&gt; override them for many languages, which are not curly brace based, most prominently &lt;em&gt;python&lt;/em&gt;, &lt;em&gt;ruby&lt;/em&gt;, &lt;em&gt;sql&lt;/em&gt;, and &lt;em&gt;vimscript&lt;/em&gt;. They offer semantic equivalents for the respective languages.&lt;/p&gt;&#xA;&lt;p&gt;Also third party ftplugins for &lt;em&gt;latex&lt;/em&gt; (&lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt;), &lt;em&gt;markdown&lt;/em&gt; (&lt;a href=&quot;https://github.com/plasticboy/vim-markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-markdown by plasticboy&lt;/a&gt;), &lt;em&gt;html/xml&lt;/em&gt; (&lt;a href=&quot;https://github.com/othree/xml.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;xml.vim&lt;/a&gt;), &lt;em&gt;manpages&lt;/em&gt; (&lt;a href=&quot;https://github.com/vim-utils/vim-man&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-man&lt;/a&gt;) and more remap them (&lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow noreferrer&quot;&gt;fugitive&lt;/a&gt;, &lt;a href=&quot;https://github.com/arp242/jumpy.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;jumpy.vim&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Note there are different expectations of what the equivalents should be. For instance, &lt;a href=&quot;https://github.com/jeetsukumaran/vim-pythonsense&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;pythonsense&lt;/em&gt;&lt;/a&gt; provides alternatives for python. For markdown there are also several plugins which offer different versions: &lt;a href=&quot;https://github.com/plasticboy/vim-markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;plasticboy/vim-markdown&lt;/a&gt;, &lt;a href=&quot;https://github.com/vim-pandoc/vim-pandoc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-pandoc&lt;/a&gt;, &lt;a href=&quot;https://github.com/gabrielelana/vim-markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;gabrielelana/vim-markdown&lt;/a&gt;, &lt;a href=&quot;https://github.com/gbgar/pandoc-sections.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;pandoc-sections.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&#xA;&lt;a href=&quot;https://github.com/nvim-treesitter/nvim-treesitter-textobjects&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvim-treesitter-textobjects&lt;/a&gt; suggests to use them for &lt;a href=&quot;https://github.com/nvim-treesitter/nvim-treesitter-textobjects#text-objects-move&quot; rel=&quot;nofollow noreferrer&quot;&gt;movement in classes&lt;/a&gt;. IMHO this limits the usefulness of them: they should apply to classes and methods since pressing &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt; is quick and navigating functions is more common.&lt;/p&gt;&#xA;&lt;h3&gt;&lt;em&gt;Egyptian&lt;/em&gt; Brackets&lt;/h3&gt;&#xA;&lt;p&gt;For code which uses &lt;a href=&quot;https://google.github.io/styleguide/javaguide.html#s4.1.2-blocks-k-r-style&quot; rel=&quot;nofollow noreferrer&quot;&gt;Egyptian Brackets&lt;/a&gt; for functions and classes, vim help suggests to customize &lt;code&gt;[[, [], ]], ][&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;If your '{' or '}' are not in the first column, and you would like to use &amp;quot;[[&amp;quot;&#xA;and &amp;quot;]]&amp;quot; anyway, try these mappings: &amp;gt;&#xA;   :map [[ ?{&amp;lt;CR&amp;gt;w99[{&#xA;   :map ][ /}&amp;lt;CR&amp;gt;b99]}&#xA;   :map ]] j0[[%/{&amp;lt;CR&amp;gt;&#xA;   :map [] k$][%?}&amp;lt;CR&amp;gt;&#xA;[type these literally, see |&amp;lt;&amp;gt;|]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Typical languages are java, rust and go. Actually, the end of function motions could be left unchanged. &lt;code&gt;$VIMRUNTIME/ftplugin/rust.vim&lt;/code&gt; and the third-party plugin &lt;a href=&quot;https://github.com/fatih/vim-go&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-go&lt;/a&gt; remap only &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt; for you. Also &lt;code&gt;$VIMRUNTIME/ftplugin/php.vim&lt;/code&gt; remaps only &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt; to jump to keywords like &lt;code&gt;function&lt;/code&gt; or &lt;code&gt;class&lt;/code&gt; regardless whether Egyptian style is used.&lt;/p&gt;&#xA;&lt;p&gt;Also the plugin &lt;a href=&quot;https://github.com/LucHermitte/lh-dev/#function&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-dev&lt;/a&gt; by Luc Hermitte tries to help here.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2022-07-27T13:43:31.997" LastActivityDate="2022-07-27T13:43:31.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17777" PostTypeId="2" ParentId="16952" CreationDate="2018-10-30T11:11:03.870" Score="6" Body="&lt;p&gt;One way would be to select the lines (using any of the visual modes: block, line, or regular characterwise) and then type the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm! $xxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will pre-populate the command line with a range when you press &lt;kbd&gt;:&lt;/kbd&gt; so the actual command you will execute is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;norm! $xxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This acts like visiting each line and typing &lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;. (See &lt;code&gt;:help :normal&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that, because of the way the &lt;code&gt;x&lt;/code&gt; command handles a range, &lt;code&gt;:norm!$3x&lt;/code&gt; won't work. (However, if your &lt;code&gt;virtualedit&lt;/code&gt; setting contains &lt;code&gt;onemore&lt;/code&gt; or &lt;code&gt;all&lt;/code&gt; then you can use a count with a command like &lt;code&gt;:norm!$ld3h&lt;/code&gt;: the original command given won't work.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-10-30T11:11:03.870" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17778" PostTypeId="2" ParentId="17774" CreationDate="2018-10-30T13:46:57.347" Score="2" Body="&lt;p&gt;The paragraph (&lt;code&gt;ip, ap&lt;/code&gt;) and curly brace (&lt;code&gt;i{, a{&lt;/code&gt;) motions are good for this. The curly braces may need to be forced linewise with &lt;code&gt;Va}&lt;/code&gt;, but they still wont capture the method declaration.&lt;/p&gt;&#xA;&lt;p&gt;If, like me, you put blank lines between methods, the paragraph motion is suitable and succinct (and does not require memorization of which square bracket does what). &lt;code&gt;dap&lt;/code&gt; (or &lt;code&gt;dVap&lt;/code&gt;) rolls off my fingers because I use it so frequently.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2021-05-23T23:42:44.677" LastActivityDate="2021-05-23T23:42:44.677" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17779" PostTypeId="2" ParentId="17717" CreationDate="2018-10-30T15:33:13.510" Score="1" Body="&lt;p&gt;I've often found myself in a similar situation and, this past weekend, wrote the beginnings of a solution.  Take a look at the Go library &lt;a href=&quot;https://github.com/tep/file-viminfo&quot; rel=&quot;nofollow noreferrer&quot;&gt;toolman.org/file/viminfo&lt;/a&gt; -- with this I'll be able to write a solution for your #1 (or similar), hopefully in the next week or so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Stay tuned.&lt;/p&gt;&#xA;" OwnerUserId="19597" LastActivityDate="2018-10-30T15:33:13.510" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17781" PostTypeId="2" ParentId="17675" CreationDate="2018-10-31T07:26:41.587" Score="1" Body="&lt;p&gt;Another version that uses functions more and avoids messing up the registers&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SplitOverwrite()&#xA;&#xA;    &quot; get the whole file content&#xA;    let x = getline(1, '$')&#xA;&#xA;    &quot; Move cursor to the window right&#xA;    wincmd w&#xA;&#xA;    &quot; Delete the whole file content to black hole register&#xA;    %delete _&#xA;&#xA;    &quot; set the contents&#xA;    call setline(1, x)&#xA;&#xA;    &quot; Save the file&#xA;    w&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;so :call SplitOverwrite()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-10-31T07:26:41.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17782" PostTypeId="2" ParentId="17675" CreationDate="2018-10-31T07:39:24.030" Score="4" Body="&lt;p&gt;based on @Warren's answer, there are actually two other alternatives&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;running from the source file: &lt;code&gt;:w !cat &amp;gt; dest_file&lt;/code&gt;  (note the space between &lt;code&gt;w&lt;/code&gt; and &lt;code&gt;!&lt;/code&gt;, which runs an external program and uses the content written as &lt;code&gt;stdin&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;running from the destination: &lt;code&gt;:%! cat &amp;lt; source_file&lt;/code&gt; (this uses filter and the contents of the destination is discarded since the external program redirected its input)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-10-31T07:50:35.363" LastActivityDate="2018-10-31T07:50:35.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17784" PostTypeId="1" CreationDate="2018-10-31T14:59:58.787" Score="3" ViewCount="956" Body="&lt;p&gt;I am trying to use &lt;code&gt;:Termdebug&lt;/code&gt; in Vim 8.1 on a CentOS machine. The default version of GDB at &lt;code&gt;/usr/bin/gdb&lt;/code&gt; is less than the required v7.12. However, I have newer versions of GDB within &lt;code&gt;devtoolset&lt;/code&gt; distributions I have installed with &lt;code&gt;yum&lt;/code&gt;. To enable newer GDB versions, I need to run &lt;code&gt;source /opt/rh/devtoolset-{version}/enable&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to source that script in my &lt;code&gt;.bashrc&lt;/code&gt; and disrupt my default environment. Is there anyway I can run that command on running &lt;code&gt;:Termdebug&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible with &lt;code&gt;:TermdebugCommand&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="19608" LastActivityDate="2020-08-11T15:05:49.380" Title="Specify GDB version for Termdebug" Tags="|startup|debugging|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17785" PostTypeId="1" AcceptedAnswerId="17786" CreationDate="2018-10-31T16:19:50.517" Score="0" ViewCount="113" Body="&lt;p&gt;I just want to learn how vim regexp works and to be able to compose my own regexp for example, I have found this on google which searches for matching .sh files&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#^\s\+.*sh$#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How does this work?&lt;/p&gt;&#xA;" OwnerUserId="18514" LastEditorUserId="1841" LastEditDate="2018-10-31T16:36:46.930" LastActivityDate="2018-10-31T16:36:46.930" Title="How does the following regex works" Tags="|regular-expression|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17786" PostTypeId="2" ParentId="17785" CreationDate="2018-10-31T16:35:45.037" Score="5" Body="&lt;p&gt;All you need to know about Vim regex can be found directly in the doc with &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#regexp&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h regexp&lt;/code&gt;&lt;/a&gt;. You can read all the file until &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#perl-patterns&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h perl-patterns&lt;/code&gt;&lt;/a&gt;, that's a long read but it is worth it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you read the doc (&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#pattern-atoms&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h pattern-atoms&lt;/code&gt;&lt;/a&gt;) you can find the meaning of the different atom used :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#^\s\+.*sh$#&#xA; ^                  The beginning of the line&#xA;  \s\+              At least one (\+) whitespace (\s)&#xA;      .*            Zero or more (*) character (.), any character&#xA;        sh          Literraly the characters 's' then 'h'&#xA;          $         The end of the line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the &lt;code&gt;#&lt;/code&gt; character at the beginning and end of the regex were probably used as delimiters in a substitution command like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s#^\s\+.*sh$#foo.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will rename every &lt;code&gt;.sh&lt;/code&gt; file name to &lt;code&gt;foo.sh&lt;/code&gt;, see &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3as&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :s&lt;/code&gt;&lt;/a&gt; (Note that people often use &lt;code&gt;;&lt;/code&gt; as delimiters but you can also use &lt;code&gt;#&lt;/code&gt; or almost any other character)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-10-31T16:35:45.037" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17787" PostTypeId="1" AcceptedAnswerId="17790" CreationDate="2018-10-31T17:23:02.803" Score="1" ViewCount="97" Body="&lt;p&gt;I am very much annoyed by this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vi abc.sh&#xA;Error detected while processing /home/DELL/.virc:&#xA;line    1:&#xA;E518: Unknown option: incompatible&#xA;Press ENTER or type command to continue&#xA;/bin/bash: line 2: \: command not found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know, how it is affecting my programs and how this error occurred in my laptop?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried reinstalling the package, too.&lt;/p&gt;&#xA;" OwnerUserId="19610" LastEditorUserId="28" LastEditDate="2018-11-01T03:16:21.647" LastActivityDate="2018-11-01T03:16:21.647" Title="Why do I get &quot;incompatible error&quot; while opening .sh files using vi in cygwin?" Tags="|bash|error|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17788" PostTypeId="1" AcceptedAnswerId="17789" CreationDate="2018-10-31T17:39:40.993" Score="0" ViewCount="60" Body="&lt;p&gt;I'm trying to make a List variable that contains all the globbed files's filename as it's value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so far, I'm able to get the file names but I can't seem to make a List out of it. here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:test = {}&#xA;let g:test+=glob(&quot;~/Projects/js/*&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What seems to be wrong?&lt;/p&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-10-31T18:00:11.050" Title="How can I append every filename as a List value in a variable?" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17789" PostTypeId="2" ParentId="17788" CreationDate="2018-10-31T18:00:11.050" Score="2" Body="&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#glob%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h glob()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you see a third optional parameter named &lt;code&gt;{list}&lt;/code&gt;, then your version of Vim can directly return a List. If you pass 1 here, you'll have a list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, you'll have to &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#split%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:split()&lt;/code&gt;&lt;/a&gt; &lt;code&gt;glob()&lt;/code&gt; result.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-10-31T18:00:11.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17790" PostTypeId="2" ParentId="17787" CreationDate="2018-10-31T18:40:21.830" Score="4" Body="&lt;p&gt;The option name is &lt;code&gt;nocompatible&lt;/code&gt;. Replace  &lt;code&gt;incompatible&lt;/code&gt; with &lt;code&gt;nocompatible&lt;/code&gt; to solve your problem. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-10-31T18:40:21.830" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17791" PostTypeId="1" AcceptedAnswerId="17792" CreationDate="2018-10-31T23:04:43.427" Score="2" ViewCount="511" Body="&lt;p&gt;In my &lt;code&gt;.vimrc&lt;/code&gt;, I want to execute a bash file &lt;code&gt;test.sh&lt;/code&gt; when I save a specific file, say &lt;code&gt;test.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, both files are in &lt;code&gt;/long/list/of/folders/which/makes/an/ugly/looking/line/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence I would like to have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let fold=&quot;/long/list/of/folders/which/makes/an/ugly/looking/line/&quot;&#xA;autocmd BufWritePost fold.&quot;test.tex&quot; execute &quot;!&quot;.fold.&quot;test.sh&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or that second line won't work because &lt;code&gt;fold.&quot;test.tex&quot;&lt;/code&gt; is supposed to be a pattern matcher and not a vim variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to achieve my desired result ?&lt;/p&gt;&#xA;" OwnerUserId="13266" LastActivityDate="2018-10-31T23:53:34.953" Title="In autocmd-patterns, how to match a vim variable?" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17792" PostTypeId="2" ParentId="17791" CreationDate="2018-10-31T23:53:34.953" Score="0" Body="&lt;p&gt;If I’m interpreting your question correctly, you want to use the value of the variable at the time that you define the autocommand, so you should be able just to move your &lt;code&gt;execute&lt;/code&gt; further out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'autocmd BufWritePost '.fold.'test.tex !'.fold.'test.sh'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If instead you want to use the value at the time the autocommand is run, you’ll need to fire the autocommand for every file but then manually check the buffer name as part of your action and exit immediately if it’s not the matching file.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-10-31T23:53:34.953" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17794" PostTypeId="1" CreationDate="2018-11-01T04:46:19.253" Score="0" ViewCount="97" Body="&lt;p&gt;Ref to :h foldtext()&#xA;&lt;code&gt;&#xA;The number of leading dashes depends on the foldlevel.&#xA;&lt;/code&gt;&#xA;As follow, I think the foldlevel of &lt;code&gt;printf&lt;/code&gt; is 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/59pa9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/59pa9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, you can see as follow, the number of dashes is 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kxtqI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kxtqI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't understand why inconsist&lt;/p&gt;&#xA;" OwnerUserId="19615" LastActivityDate="2018-11-01T09:14:42.427" Title="Is the number of foldtext dashes incorrect?" Tags="|folding|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17795" PostTypeId="2" ParentId="17794" CreationDate="2018-11-01T07:50:43.417" Score="2" Body="&lt;p&gt;The documentation does not say how many dashes are there per foldlevel. As can be seen in the &lt;a href=&quot;https://github.com/vim/vim/blob/f080d70a82f3a4477f346d9efcdfaec1bc1e1d58/src/evalfunc.c#L3989-L4002&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;txt = NGETTEXT(&quot;+-%s%3ld line: &quot;, &quot;+-%s%3ld lines: &quot;, count);&#xA;r = alloc((unsigned)(STRLEN(txt)&#xA;        + STRLEN(dashes)        /* for %s */&#xA;        + 20            /* for %3ld */&#xA;        + STRLEN(s)));      /* concatenated */&#xA;if (r != NULL)&#xA;{&#xA;    sprintf((char *)r, txt, dashes, count);&#xA;    len = (int)STRLEN(r);&#xA;    STRCAT(r, s);&#xA;    /* remove 'foldmarker' and 'commentstring' */&#xA;    foldtext_cleanup(r + len);&#xA;    rettv-&amp;gt;vval.v_string = r;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can see, the number of dashes is actually equal to the &lt;strong&gt;foldlevel + 1&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-11-01T07:50:43.417" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17796" PostTypeId="2" ParentId="14856" CreationDate="2018-11-01T08:44:46.783" Score="2" Body="&lt;p&gt;Here is the temporary solution I've found so far.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let lowercase = 'abcdefghijklmnopqrstuvwxyz'&#xA;let uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'&#xA;let numbers = '0123456789'&#xA;let punctuation = &quot;&amp;lt;&amp;gt;`@#~!\&quot;$%^&amp;amp;/()=+*-_.,;:?\\\'{}[] &quot; &quot; and space&#xA;for str in [lowercase, uppercase, numbers, punctuation]&#xA;    for key in split(str, '\zs')&#xA;        execute printf(&quot;noremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;nowait&amp;gt; %s :call DO_SOMETHING_OR_NOTHING&amp;lt;cr&amp;gt;&quot;, key)&#xA;    endfor&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically this snippet will remap all the normal mappings for local buffer.&lt;/p&gt;&#xA;" OwnerUserId="6859" LastActivityDate="2018-11-01T08:44:46.783" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17797" PostTypeId="2" ParentId="17794" CreationDate="2018-11-01T09:14:42.427" Score="1" Body="&lt;p&gt;As @Christian Brabandt showed from the source code, the string used for folding has a &quot;+-&quot; at the beginning of the string, resulting in the &lt;code&gt;foldlevel+1&lt;/code&gt; dashes. I can't answer whether this is intentional or a bug. You could &lt;a href=&quot;https://github.com/vim/vim/issues/new&quot; rel=&quot;nofollow noreferrer&quot;&gt;open an issue on the vim github&lt;/a&gt; if you feel that this is a bug, and you will hopefully receive either justification for the extra dash or the &quot;bug&quot; will be fixed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like a &quot;fix&quot; for this, you can add the following to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyFoldText()&#xA;    let line = getline(v:foldstart)&#xA;    let sub = substitute(line, '^\s*\|//\s*\|/\*\|\*/\|{{{\d\=', '', 'g')&#xA;    let oneLessDash = strpart(string(v:folddashes),1,len(string(v:folddashes))-2)&#xA;    let foldlinecount = foldclosedend(v:foldstart) - foldclosed(v:foldstart) + 1&#xA;    let lineCount = &quot; &quot; . string(foldlinecount) . &quot; lines: &quot;&#xA;    return &quot;+&quot; . oneLessDash . lineCount . sub&#xA;endfunction&#xA;set foldtext=MyFoldText()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will print the same &lt;code&gt;foldtext&lt;/code&gt; as before with just one less dash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. Welcome to the community!&lt;/p&gt;&#xA;" OwnerUserId="14380" LastActivityDate="2018-11-01T09:14:42.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17798" PostTypeId="2" ParentId="17769" CreationDate="2018-11-01T10:43:41.100" Score="2" Body="&lt;p&gt;Swap files appear to contain some basic information about your computer (try opening the swap file in vim! I found the vim version, pc name, file path&amp;amp;name, utf encoding and some other &quot;settings&quot; stored) as well as a whole lot of &quot;nothing&quot;.&#xA;The &quot;nothing&quot; is actually a significant amount of padded null characters &lt;code&gt;^@&lt;/code&gt; (which I presume is used as a placeholder for the swap file to include other relevant information).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such, swap files aren't actually &quot;big&quot;, they just have some base information making them a bit bigger than the original file. As your files get larger, the % difference between the original file and the swap file becomes less significant.&lt;/p&gt;&#xA;" OwnerUserId="14380" LastActivityDate="2018-11-01T10:43:41.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17799" PostTypeId="1" AcceptedAnswerId="17808" CreationDate="2018-11-01T14:26:25.710" Score="1" ViewCount="2378" Body="&lt;p&gt;I'm trying to make a vimscript that will read the &lt;code&gt;.gitignore&lt;/code&gt; file, return it's values as a List and check for paths that has wildcards eg: &lt;code&gt;/vim/snippets/*&lt;/code&gt;, &lt;code&gt;vim/**/*&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ignored = readfile(&quot;/home/user/Projects/dotfiles/.gitignore&quot;)&#xA;&#xA;let c=0&#xA;while c &amp;lt; len(g:ignored)&#xA;&#xA;  let g:ignoredPath = ignored[c]&#xA;  let c += 1&#xA;&#xA;  echo g:ignoredPath&#xA;&#xA;endwhile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to check &lt;code&gt;g:ignored&lt;/code&gt; variable for possible values with wildcards but how can I do that? I'm guessing I have to use regex in an execute or something. But I don't know the right syntax at all.&lt;/p&gt;&#xA;" OwnerUserId="18514" LastEditorDisplayName="user5791" LastEditDate="2019-01-21T05:10:45.993" LastActivityDate="2019-01-21T05:10:45.993" Title="How to check if the value of a variable has a specific character?" Tags="|vimscript|regular-expression|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17800" PostTypeId="2" ParentId="4056" CreationDate="2018-11-01T15:29:59.667" Score="4" Body="&lt;p&gt;Another option that automatically closes the preview window and that should work with multiple completion plugins was &lt;a href=&quot;https://github.com/Shougo/deoplete.nvim/issues/115#issuecomment-170237485&quot; rel=&quot;nofollow noreferrer&quot;&gt;suggested by deoplete's author in an issue&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The downside is that you won't be able to focus the scratch window, so no scrolling. But for quick lookups it's the most convenient.&lt;/p&gt;&#xA;" OwnerUserId="19618" LastActivityDate="2018-11-01T15:29:59.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17801" PostTypeId="1" AcceptedAnswerId="17802" CreationDate="2018-11-01T16:39:51.980" Score="1" ViewCount="225" Body="&lt;p&gt;I currently have &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; mapped to &lt;code&gt;:nohlsearch&lt;/code&gt; in normal mode. This allows me to leave search highlighting on for all new searches, but easily turn it off when it (soon after usually) becomes a distraction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works great usually, the exception is when I'm using &lt;code&gt;q:&lt;/code&gt; to edit the command history to produce a closely related ex command or whatever. The behavior of Enter in that context is to execute the command (or search in search history edit), but the normal-mode remapping overrides that. Consequently, I need to hit enter from insert mode to execute the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I map Enter to &lt;code&gt;:nohlsearch&lt;/code&gt; in normal mode but retain the &quot;execute&quot; behavior of Enter in the command-history edit window?&lt;/p&gt;&#xA;" OwnerUserId="10196" LastActivityDate="2018-11-01T17:40:28.923" Title="Remap Enter in command history edit window only" Tags="|key-bindings|normal-mode|command-history|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17802" PostTypeId="2" ParentId="17801" CreationDate="2018-11-01T17:40:28.923" Score="4" Body="&lt;p&gt;I have the following in my vimrc to force regular behavior of enter in certain situations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc_CRfix&#xA;  au!&#xA;&#xA;  &quot; Quickfix, Location list, &amp;amp;c. remap &amp;lt;CR&amp;gt; to work as expected&#xA;  autocmd BufReadPost quickfix nnoremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;&#xA;  autocmd CmdwinEnter * nnoremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;&#xA;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I cannot remember why I’m using &lt;code&gt;nnoremap&lt;/code&gt; and not &lt;code&gt;unmap &amp;lt;buffer&amp;gt;&lt;/code&gt;; it’s possible the latter works. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-11-01T17:40:28.923" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17803" PostTypeId="1" CreationDate="2018-11-01T19:24:19.033" Score="1" ViewCount="109" Body="&lt;p&gt;For .js files, I set a particular filetype in order to enable snippets, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup project&#xA;    autocmd!&#xA;    autocmd BufRead,BufNewFile *.js set filetype=javascript.javascript-es6-react.jsx&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, I get the section_x that then reads all of the filetype. I wanted to set up sexction_x for *.js files to &quot;js&quot; or &quot;javascript&quot; only and added the following to the augroup: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.js let g:airline_section_x='js'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it kind of works. When I load the file via NERDTree, section_x stays the same, but when I switch from buffer to NERDTree and back to buffer, it then registers the new section_x and it works... but, airline doesn't do the 'normal' thing if I load any other filetype then. It stays 'js' throughout the vim session. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware that I am most probably doing the stupid thing here, but I'm asking how should I do the right thing. How can I make this happen only for 'js' files and have it all work?&lt;/p&gt;&#xA;" OwnerUserId="19621" LastActivityDate="2018-11-01T19:24:19.033" Title="Airline section_x for particular filetype" Tags="|filetype|statusline|plugin-airline|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17805" PostTypeId="1" AcceptedAnswerId="17809" CreationDate="2018-11-02T02:09:59.683" Score="7" ViewCount="1701" Body="&lt;p&gt;I mean like &lt;code&gt;CTRL-O&lt;/code&gt; (repeatedly) but limited to the current file only.&#xA;Sometimes I check stuff in another file(say using goto definition). And it loads it into the same window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still, I want to focus on the current file only. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2018-11-02T20:30:19.703" LastActivityDate="2018-11-07T12:15:08.280" Title="How to jump to the previous location in the same file?" Tags="|navigation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17806" PostTypeId="2" ParentId="17805" CreationDate="2018-11-02T04:05:33.717" Score="7" Body="&lt;p&gt;&lt;em&gt;FYI I wrote this before the question was updated to make it clear that OP wants to jump to the previous location repeatedly. Given that this answer still addresses the question asked in the subject line and has been upvoted a bit I think it's worth leaving here. Cheers.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally speaking, &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#mark-motions&quot; rel=&quot;nofollow noreferrer&quot;&gt;marks&lt;/a&gt; are used to jump to previously visited locations in the current file.&lt;sup&gt;1&lt;/sup&gt; To go back to the last visited line or &quot;the position before the last jump&quot; use either &lt;code&gt;``&lt;/code&gt;, which jumps to the &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%60%60&quot; rel=&quot;nofollow noreferrer&quot;&gt;backtick mark&lt;/a&gt;, or &lt;code&gt;''&lt;/code&gt;, jumping to the &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#&amp;#39;&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;tick/apostrophe mark&lt;/a&gt;. The difference between these two commands is that the former takes you to the last line &lt;em&gt;and column&lt;/em&gt; you had been on while the latter takes you to the &lt;em&gt;first non-blank character&lt;/em&gt; of that line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to see where these marks are currently located you can use &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#:marks&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:marks&lt;/code&gt;&lt;/a&gt;, i.e. &lt;code&gt;:marks '&lt;/code&gt; or &lt;code&gt;:marks `&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you can actually override these marks, e.g. with &lt;code&gt;m'&lt;/code&gt;, but I'd wager that very few people do that...the defaults are too useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BONUS: Tangentially related to your question is this little goody in help: &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#last-position-jump&quot; rel=&quot;nofollow noreferrer&quot;&gt;last position jump&lt;/a&gt;. It presents an autocommand that you can utilize that upon opening a file will put the cursor at the position it had last been when you last visited that file. (If you are using &lt;code&gt;source $VIMRUNTIME/defaults.vim&lt;/code&gt; in your vimrc file the autocommand is already set up for you.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; &lt;sub&gt;Marks can also be used to jump file-to-file if uppercase letters are used, e.g. &lt;code&gt;mA&lt;/code&gt; and &lt;code&gt;`A&lt;/code&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-11-07T12:15:08.280" LastActivityDate="2018-11-07T12:15:08.280" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17807" PostTypeId="1" AcceptedAnswerId="17810" CreationDate="2018-11-02T04:32:45.613" Score="0" ViewCount="1764" Body="&lt;p&gt;I am using cygwin to run &quot;linux command line&quot; on windows 10. But here, backspace key doesn't work in insert mode. I had to edit my .vimrc file by setting &quot;nocompatible and &quot;bs=2&quot; to make it work (by watching a youtube tutorial). But why it doesn't work by default? Is this normal behavior of Vim?&#xA;Do backspace doesnt work on actual linux also??&lt;/p&gt;&#xA;" OwnerUserId="19610" LastEditorUserId="1292" LastEditDate="2018-11-02T09:42:52.610" LastActivityDate="2018-11-02T13:18:26.833" Title="Why Backspace key do not work in insert mode in shell file by default in Cygwin?" Tags="|vimrc|microsoft-windows|cygwin|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17808" PostTypeId="2" ParentId="17799" CreationDate="2018-11-02T06:47:13.003" Score="2" Body="&lt;p&gt;The Function you are searching is &lt;code&gt;matchstr&lt;/code&gt; it returns the matched string or if the pattern is not found, an empty string. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your example you should note: if the expression given to &lt;code&gt;matchstr&lt;/code&gt; is a &lt;code&gt;List&lt;/code&gt; the matching item is returned and the type isn't changed. So it is possible that the returned item isn't a string if your list consist of other datatypes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but as always you can read all that in &lt;code&gt;:h matchstr&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: There is also &lt;code&gt;:h matchlist&lt;/code&gt; which can work with capturing groups (in vim called submatches) and &lt;code&gt;:h matchstrpost&lt;/code&gt; which also returns the start and end position of the match.&lt;/p&gt;&#xA;" OwnerUserId="11316" LastActivityDate="2018-11-02T06:47:13.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17809" PostTypeId="2" ParentId="17805" CreationDate="2018-11-02T13:10:36.497" Score="5" Body="&lt;p&gt;The built-in &lt;a href=&quot;https://vimhelp.appspot.com/motion.txt.html#jump-motions&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;jump-motions&lt;/code&gt;&lt;/a&gt; do not differentiate betweeen buffer-local and &quot;remote&quot; jumps, they just move along the jumplist. You need a custom solution that parses and filters the jumplist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2695&quot; rel=&quot;noreferrer&quot;&gt;EnhancedJumps plugin&lt;/a&gt; extends the built-in &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; commands with variants that move only within the current buffer (this is what you're asking for), or directly jump to the next position in a different buffer.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-02T13:10:36.497" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17810" PostTypeId="2" ParentId="17807" CreationDate="2018-11-02T13:18:26.833" Score="1" Body="&lt;p&gt;Backwards compatibility (with vi, and also with earlier Vim releases) is a big thing in Vim. However, there have been many complaints like yours in the past, so Vim 8.0 introduced a &lt;a href=&quot;https://vimhelp.appspot.com/starting.txt.html#defaults.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help defaults.vim&lt;/code&gt;&lt;/a&gt; configuration that gets activated if there's no user configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see in &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27backspace%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'backspace'&lt;/code&gt;&lt;/a&gt;, the default is an empty option, and defaults.vim sets this to &lt;code&gt;indent,eol,start&lt;/code&gt; (which you should use instead of the deprecated and difficult to understand value &lt;code&gt;2&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;'backspace' 'bs'        string  (default &quot;&quot;, set to &quot;indent,eol,start&quot;&#xA;                                                            in |defaults.vim|)&#xA;                        global&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;defaults.vim&lt;/code&gt; has other sensible settings, and can be combined with customizations in your own &lt;code&gt;~/.vimrc&lt;/code&gt;; it's worth to have a look!&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-02T13:18:26.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17811" PostTypeId="2" ParentId="17760" CreationDate="2018-11-02T13:49:53.443" Score="3" Body="&lt;p&gt;Have a look at &lt;a href=&quot;https://vimhelp.appspot.com/starting.txt.html#startup&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help startup&lt;/code&gt;&lt;/a&gt;. If you set up &lt;code&gt;'runtimepath'&lt;/code&gt; in your &lt;code&gt;~/.vimrc&lt;/code&gt;, Vim will later load the plugins found there (&lt;a href=&quot;https://vimhelp.appspot.com/starting.txt.html#load-plugins&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help load-plugins&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you do the &lt;code&gt;'runtimepath'&lt;/code&gt; setup later, Vim is ready to source any autoload functions from there, but the plugin configuration itself (that would make use of the autoload functions), has never been loaded! Therefore, you need to explicitly &lt;code&gt;:runtime&lt;/code&gt; any plugins and filetype detections yourself. In the comments, you've indicated that you've tried that via &lt;code&gt;runtime g:opamshare . '/merlin/vim'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vim's evaluation rules are different than most programming languages. You need to use &lt;code&gt;:execute&lt;/code&gt; in order to evaluate a variable (or expression); otherwise, it's taken literally; i.e. Vim uses the variable name itself as the argument.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:runtime&lt;/code&gt; needs a list of files / file glob, and you want to get all plugin files (i.e. from the &lt;code&gt;plugin&lt;/code&gt; subdirectory).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute 'runtime' g:opamshare . '/merlin/vim/plugin/**/*.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Wait, there are also filetype plugins&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Please note that your approach is only recommended for &lt;em&gt;general plugins&lt;/em&gt; that you however only want to &lt;em&gt;use in the context of a certain filetype&lt;/em&gt;. For plugins that truly are specific to a filetype, there's &lt;a href=&quot;https://vimhelp.appspot.com/filetype.txt.html#filetype-plugins&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help filetype-plugins&lt;/code&gt;&lt;/a&gt; built into Vim, and that is far more elegant that the approach described here.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-02T13:49:53.443" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17812" PostTypeId="2" ParentId="5299" CreationDate="2018-11-02T16:17:50.487" Score="3" Body="&lt;p&gt;&lt;em&gt;For those having french AZERTY keyboard, try&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;CTRL&lt;/kbd&gt; + &lt;kbd&gt;$&lt;/kbd&gt; (&lt;kbd&gt;$,£,¤&lt;/kbd&gt; key) &lt;/p&gt;&#xA;" OwnerUserId="19638" LastActivityDate="2018-11-02T16:17:50.487" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17813" PostTypeId="2" ParentId="410" CreationDate="2018-11-02T20:40:30.450" Score="8" Body="&lt;p&gt;The reason is that &lt;code&gt;xargs&lt;/code&gt; sets &lt;code&gt;stdin&lt;/code&gt; to &lt;code&gt;/dev/null&lt;/code&gt;, whereas &lt;code&gt;vim&lt;/code&gt; needs &lt;code&gt;stdin&lt;/code&gt; to be &lt;code&gt;/dev/tty&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;BSD &lt;code&gt;xargs&lt;/code&gt; (e.g. Mac) solution:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo -e 'file1\nfile2' | xargs -o vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;-o&lt;/code&gt; sets the &lt;code&gt;stdin&lt;/code&gt; of xarg's child process (&lt;code&gt;vim&lt;/code&gt; in this case) to &lt;code&gt;dev/tty&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;GNU &lt;code&gt;xargs&lt;/code&gt; (e.g. Linux) solution:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GNU &lt;code&gt;xargs&lt;/code&gt; does not have the &lt;code&gt;-o&lt;/code&gt; option. Instead you will have to use a more complicated workaround. (Note: It is very important to have the trailing &lt;code&gt;zero&lt;/code&gt; string, don't forget it.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo -e 'file1\nfile2' | xargs bash -c '&amp;lt;/dev/tty vim &quot;$@&quot;' zero&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also make it an alias:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vimin='xargs bash -c '\''&amp;lt;/dev/tty vim &quot;$@&quot;'\'' zero'&#xA;echo -e 'file1\nfile2' | vimin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Detailed explanation of GNU xargs solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's break it down step by step:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo -e 'file1\nfile2' | xargs bash -c '&amp;lt;/dev/tty vim &quot;$@&quot;' zero&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;1. &lt;code&gt;xargs&lt;/code&gt; simply appends the &lt;code&gt;stdin&lt;/code&gt; to the end of the string, so &lt;code&gt;xargs&lt;/code&gt; will be executing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    bash -c '&amp;lt;/dev/tty vim &quot;$@&quot;' zero file1 file2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2. The format for &lt;code&gt;bash -c&lt;/code&gt; is &lt;code&gt;bash -c 'COMMAND_STRING' $0 $1 $2 etc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;$@&quot;&lt;/code&gt; expands to the positional parameters &lt;code&gt;&quot;$1&quot;, &quot;$2&quot;&lt;/code&gt;, etc. It does not include &quot;$0&quot; because that is a special parameter for the script name, not a positional parameter. &lt;strong&gt;This is why we need to add the dummy string &lt;code&gt;zero&lt;/code&gt; (it can be any string) to take the place for &lt;code&gt;$0&lt;/code&gt;. Otherwise, you will lose the first file.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So after you expand &lt;code&gt;&quot;$@&quot;&lt;/code&gt;, you end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    bash -c '&amp;lt;/dev/tty vim file1 file2' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;3. &lt;code&gt;bash -c&lt;/code&gt; will execute the COMMAND_STRING:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    &amp;lt;/dev/tty vim file1 file2 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;/dev/tty&lt;/code&gt; sets the &lt;code&gt;stdin&lt;/code&gt; to &lt;code&gt;/dev/tty&lt;/code&gt; so that &lt;code&gt;vim&lt;/code&gt; can work in interactive mode.&lt;/p&gt;&#xA;" OwnerUserId="6610" LastActivityDate="2018-11-02T20:40:30.450" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17814" PostTypeId="1" AcceptedAnswerId="17826" CreationDate="2018-11-02T22:21:50.433" Score="1" ViewCount="606" Body="&lt;p&gt;Actually, I am unable to do so when I am using MacVim Application. But inside iterm using Vim (the same MacVim release), I am able to. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They also both use the same .vimrc .&#xA;Both versions compiled with  -xterm_clipboard and +clipboard&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Macos version is 10.13.2 . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The version info of the MacVim application:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 14 2018 05:28:49)&#xA;macOS version&#xA;Included patches: 1-280&#xA;Compiled by travis@Traviss-Mac-1044.local&#xA;Huge version with MacVim GUI.  Features included (+) or not (-):&#xA;+acl               +cmdline_compl     +emacs_tags        +iconv             +mksession         -mzscheme          +reltime           +termguicolors     +visualextra&#xA;+arabic            +cmdline_hist      +eval              +insert_expand     +modify_fname      +netbeans_intg     +rightleft         +terminal          +viminfo&#xA;+autocmd           +cmdline_info      +ex_extra          +job               +mouse             +num64             +ruby/dyn          +terminfo          +vreplace&#xA;+autochdir         +comments          +extra_search      +jumplist          +mouseshape        +odbeditor         +scrollbind        +termresponse      +wildignore&#xA;-autoservername    +conceal           +farsi             +keymap            +mouse_dec         +packages          +signs             +textobjects       +wildmenu&#xA;+balloon_eval      +cryptv            +file_in_path      +lambda            -mouse_gpm         +path_extra        +smartindent       +timers            +windows&#xA;+balloon_eval_term +cscope            +find_in_path      +langmap           -mouse_jsbterm     +perl/dyn          +startuptime       +title             +writebackup&#xA;+browse            +cursorbind        +float             +libcall           +mouse_netterm     +persistent_undo   +statusline        +toolbar           -X11&#xA;++builtin_terms    +cursorshape       +folding           +linebreak         +mouse_sgr         +postscript        -sun_workshop      +transparency      -xfontset&#xA;+byte_offset       +dialog_con_gui    -footer            +lispindent        -mouse_sysmouse    +printer           +syntax            +user_commands     +xim&#xA;+channel           +diff              +fork()            +listcmds          +mouse_urxvt       +profile           +tag_binary        +vartabs           -xpm&#xA;+cindent           +digraphs          +fullscreen        +localmap          +mouse_xterm       +python/dyn        +tag_old_static    +vertsplit         -xsmp&#xA;+clientserver      +dnd               -gettext           +lua/dyn           +multi_byte        +python3/dyn       -tag_any_white     +virtualedit       -xterm_clipboard&#xA;+clipboard         -ebcdic            -hangul_input      +menu              +multi_lang        +quickfix          -tcl               +visual            -xterm_save&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/Applications/MacVim.app/Contents/Resources/vim&quot;&#xA;Compilation:&#xA;clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector -L/usr/loca&#xA;l/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -l&#xA;iconv -framework AppKit   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have the following line in .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; set clipboard+=unnamed,unnamedplus &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set paste&lt;/code&gt; doesn't help. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suggestions will be welcomed.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2018-11-03T20:57:57.267" LastActivityDate="2018-11-05T02:16:03.850" Title="Unable to use the clipboard when inside terminal (:term) on macOS" Tags="|terminal|macvim|os-clipboard|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17815" PostTypeId="2" ParentId="17760" CreationDate="2018-11-03T09:48:38.257" Score="1" Body="&lt;p&gt;As you apparently struggle with setting this up yourself, an alternative may be delegating the implementation to a plugin:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt; is a fully-featured plugin manager (that offers much more than just runtimepath manipulation); it explicitly supports &lt;em&gt;On-demand loading for faster startup time&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=5101&quot; rel=&quot;nofollow noreferrer&quot;&gt;enabler.vim&lt;/a&gt; is a more dedicated plugin to load plugins/bundles as needed&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-03T09:48:38.257" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17816" PostTypeId="1" CreationDate="2018-11-03T11:33:21.957" Score="5" ViewCount="1117" Body="&lt;p&gt;In Vim, when I run, for example, :terminal python3, and, when I'm done, exit python, the terminal window stays open as a readonly buffer, which I can inspect freely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Neovim, I always get &quot;[Process exited with {Number}]&quot;, and when I press any key, it just closes the Terminal window. Is there any way to prevent this? The documentation doesn't list anything, is there a patch I could apply to the source code for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I can inspect the terminal buffer by exiting terminal mode (&lt;code&gt;&amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&lt;/code&gt;), however, I'd like that to happen automatically when the process exits. Is there a way to achieve that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT EDIT: After spending some more time, I've worked up this au-hack, which makes :terminal behave more like I'm used to from Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('nvim')&#xA;    tnoremap &amp;lt;Esc&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&#xA;    au TermOpen  * setlocal nonumber | startinsert&#xA;    au TermClose * setlocal   number | call feedkeys(&quot;\&amp;lt;C-\&amp;gt;\&amp;lt;C-n&amp;gt;&quot;)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19651" LastEditorUserId="19651" LastEditDate="2018-11-03T12:21:57.183" LastActivityDate="2018-11-03T12:21:57.183" Title="(Solved-ish) neovim: Don't close :terminal buffer after process exit" Tags="|neovim|terminal|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17817" PostTypeId="2" ParentId="11526" CreationDate="2018-11-03T20:41:41.760" Score="5" Body="&lt;p&gt;For a server instalation without GUI use &lt;code&gt;vim-nox&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&#xA;apt install vim-nox&#xA;&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="13653" LastActivityDate="2018-11-03T20:41:41.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17818" PostTypeId="1" AcceptedAnswerId="17824" CreationDate="2018-11-03T23:13:25.340" Score="3" ViewCount="902" Body="&lt;p&gt;On Xubuntu LTS, I already managed to &lt;a href=&quot;https://askubuntu.com/a/758165/164341&quot;&gt;remap &lt;kbd&gt;CapsLock&lt;/kbd&gt; to &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, now I discovered some Vim users are &lt;a href=&quot;https://www.reddit.com/r/linux/comments/5p2w90/does_anyone_use_their_scroll_lock_light_for/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lighting the &lt;kbd&gt;Scroll Lock&lt;/kbd&gt; LED&lt;/a&gt;, &lt;kbd&gt;Caps Lock&lt;/kbd&gt; LED or even the &lt;a href=&quot;https://www.youtube.com/watch?v=7vlr74B3mDA&quot; rel=&quot;nofollow noreferrer&quot;&gt;entire keyboard&lt;/a&gt; &lt;strong&gt;to indicate that (g)Vim is in the insert mode.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9Qr0p.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9Qr0p.jpg&quot; alt=&quot;Varmilo Caps Lock with LED&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, explanations about how to accomplish this Vim feat (under GNU/Linux) are nowhere to be found.&lt;/p&gt;&#xA;&lt;p&gt;Can some good Vim soul show me the light?&lt;/p&gt;&#xA;&lt;h1&gt;Fun fact&lt;/h1&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Bill_Joy&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bill Joy&lt;/a&gt; developed &lt;code&gt;vi&lt;/code&gt; from June through October 1977 on a &lt;a href=&quot;https://en.wikipedia.org/wiki/ADM-3A&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lear Siegler ADM-3A terminal&lt;/a&gt;. On this terminal, the &lt;kbd&gt;Esc&lt;/kbd&gt; key was at the location now occupied by the &lt;kbd&gt;Tab&lt;/kbd&gt; key on the IBM PC keyboard. This is somewhat the rationale behind converting the current IBM PC &lt;kbd&gt;Caps Lock&lt;/kbd&gt; into an &lt;kbd&gt;Esc&lt;/kbd&gt; key.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/a/a0/KB_Terminal_ADM3A.svg&quot; alt=&quot;ADM-3A keyboard layout&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/7/77/Adm3aimage.jpg&quot; alt=&quot;The Lear Siegler ADM-3A terminal&quot; /&gt;&lt;/p&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-02-21T19:24:29.853" Title="How to light the Caps Lock LED when in insert mode (on GNU/Linux)?" Tags="|key-bindings|insert-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17819" PostTypeId="1" CreationDate="2018-11-04T07:43:05.253" Score="1" ViewCount="760" Body="&lt;p&gt;On my work project VM, I have a relatively common Vim set-up, with various files a in ~/.vim folder and a medium size ~/.vimrc file. Plugins installed from &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;VimPlug&lt;/a&gt; store files in various folders, such as ~/.fzf.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, should a co-worker want to use Vim on my system, or I want to be-able to quickly transfer my set-up to another VM (or put it on Git for my own keeping), they are currently forced to use my set-up. Currently the configuration and relevant files are spread out across the system which is not ideal for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I set up my Vim to keep it completely &quot;self-contained&quot; within a given folder, aside from the executable itself?&lt;/p&gt;&#xA;" OwnerUserId="19660" LastActivityDate="2018-11-06T17:20:09.297" Title="How can I make my Vim setup (with plugins) portable without leaving artefacts on a given system?" Tags="|vimrc|linux|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17821" PostTypeId="2" ParentId="17818" CreationDate="2018-11-04T09:57:23.937" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Unfortunately, explanations about how to accomplish this Vim feat (under GNU/Linux) are nowhere to be found.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can craft your own solution, using building blocks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim can execute external commands. Try &lt;code&gt;:!ls&lt;/code&gt; if you are not familiar with this feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim can also map keys to other keys, or key sequences. If you are not familiar with this feature, try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap i iLOL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After having issued this mapping, every time you go into insert mode, Vim will insert LOL, as if you typed it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last building block you need is a command to control the lights on your keyboard. The command you need might differ from system to system. My keyboard does not have a caps lock light, for instance (Lenovo T440s). Instead I used the keyboard backlight. I recommend you create your own command, say, in your home directory, &lt;code&gt;~/light_on&lt;/code&gt; and &lt;code&gt;~/light_off&lt;/code&gt;. (Feel free to choose another path.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't forget to &lt;code&gt;chmod +x lights_o*&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Contents of &lt;code&gt;lights_on&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;echo 2 | tee &amp;gt; /sys/class/leds/tpacpi\:\:kbd_backlight/brightness&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Contents of &lt;code&gt;lights_off&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;echo 0 | tee &amp;gt; /sys/class/leds/tpacpi\:\:kbd_backlight/brightness&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These work for my computer. It may or may not work on yours. You should edit these files to your computer's requirements. Make sure you look into the directory &lt;code&gt;/sys/class/leds/&lt;/code&gt;. There are other lights as well. Caution: In that directory &lt;code&gt;echo 0 &amp;gt; file&lt;/code&gt; does not work. Instead you should use &lt;code&gt;echo 0 | tee &amp;gt; file&lt;/code&gt;. I don't know why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, you understandably need superuser rights to control the lights in this manner. In order to run these scripts, you need to &lt;code&gt;sudo ./lights_on&lt;/code&gt; and then type the sudo password. This is inconvenient. (&lt;code&gt;xset&lt;/code&gt; might not need sudo rights, see below.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can authorize users to run certain privileged commands without needing a password by editing &lt;code&gt;/etc/sudoers&lt;/code&gt;. I did this by following &lt;a href=&quot;https://unix.stackexchange.com/questions/215412/allow-certain-guests-to-execute-certain-commands&quot;&gt;https://unix.stackexchange.com/questions/215412/allow-certain-guests-to-execute-certain-commands&lt;/a&gt;. I added lines 18 and 28. See image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2QHD4.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2QHD4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Caution: I had to write line 28 after line 27 to get it working, unlike the instructions in the link.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you cannot get the &lt;code&gt;echo | tee&lt;/code&gt; trick working, here's another suggestion: I have also come across &lt;code&gt;xset led on&lt;/code&gt; and &lt;code&gt;xset led off&lt;/code&gt;. Try if these work for you, or try to find out more on &lt;code&gt;xset&lt;/code&gt;. (I personally could not get &lt;code&gt;xset&lt;/code&gt; to control my keyboard lights.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point you should be able to control your keyboard lights by &lt;code&gt;sudo ~/lights_on&lt;/code&gt; and &lt;code&gt;sudo ~/lights_off&lt;/code&gt;, without a sudo password.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you could do &lt;code&gt;:nnoremap i :!sudo ~/light_on&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;i&lt;/code&gt;. But there is more than one way to enter insert mode - &lt;code&gt;i&lt;/code&gt; &lt;code&gt;I&lt;/code&gt; &lt;code&gt;a&lt;/code&gt; &lt;code&gt;A&lt;/code&gt; &lt;code&gt;o&lt;/code&gt; &lt;code&gt;O&lt;/code&gt; and maybe more. So instead you should use &lt;code&gt;autocmd&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd! InsertEnter * execute ('!sudo ~/light_on &amp;amp;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And of course, upon leaving the insert mode, the lights should go off:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd! InsertLeave * execute ('!sudo ~/light_off &amp;amp;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could add this to your vimrc once you are satisfied with the behavior. &lt;/p&gt;&#xA;" OwnerUserId="19662" LastEditorUserId="19662" LastEditDate="2018-11-04T11:08:17.910" LastActivityDate="2018-11-04T11:08:17.910" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17822" PostTypeId="1" CreationDate="2018-11-04T12:40:54.980" Score="0" ViewCount="127" Body="&lt;p&gt;I would like to have commands like :ce and :ctabe that open a tab with a vertical split with the .c file on one site and the corresponding .h file on the other. How can i accomplish this behaviour?&lt;/p&gt;&#xA;" OwnerUserId="19663" LastActivityDate="2018-12-06T18:01:45.537" Title="Make a command to open c files next to the corresponding header" Tags="|vimrc|command-line|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17823" PostTypeId="1" AcceptedAnswerId="17827" CreationDate="2018-11-04T18:45:42.477" Score="1" ViewCount="469" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;how to have foldtext() for each filetype, because each filetype has a different kind of fold so multiple foldtext() in &lt;code&gt;vimrc&lt;/code&gt; and enable for each filetype.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I'm thinking about multiple foldtext() functions in &lt;code&gt;vimrc&lt;/code&gt; and enable that &lt;code&gt;customfunc()&lt;/code&gt; to foldtext() via &lt;code&gt;local&lt;/code&gt; of &lt;code&gt;au&lt;/code&gt; command for &lt;code&gt;that&lt;/code&gt; filetype. Is it possible and how would be an elegant way to achieve this?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;EDIT: from @D.BenKnobl comment, I make it more visual, I'm not good with VimL and still the examples are pretty clear, I still need some clarification, so I'll add what I think and do here:&lt;/p&gt;&#xA;&lt;p&gt;vim files in &lt;code&gt;/after/ftplugin&lt;/code&gt; will alter the default behavior of vim filetype or append function. Because I don't see the calling of function in &lt;code&gt;folding.vim&lt;/code&gt;, I understand that &lt;code&gt;vim&lt;/code&gt; will automatically recognize that &lt;code&gt;folding.vim&lt;/code&gt; contains all things for foldtext() or the whole file is foldtext() function and will be overwritten or alter the default foldtext() function for that filetype.&lt;/p&gt;&#xA;&lt;p&gt;In &lt;code&gt;vim/after/ftplugin/markdown/folding.vim&lt;/code&gt; I see &lt;code&gt;MarkdownFoldText&lt;/code&gt; function that make firm about above conclusion. Basically &lt;code&gt;setlocal foldtext()&lt;/code&gt;, define &lt;code&gt;MyMarkdownFoldFtpluginUndo&lt;/code&gt; and &lt;code&gt;let b:undo_ftplugin&lt;/code&gt; once leave that filetype with set local foldtext to &lt;code&gt;&amp;lt;&lt;/code&gt;. Do I understand that correct?&lt;/p&gt;&#xA;&lt;p&gt;So as my understanding, I should put foldtext() in &lt;code&gt;vim/after/ftplugin/rust.vim&lt;/code&gt; like below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if exists('b:undo_ftplugin')&#xA;  let b:undo_ftplugin .= ' | '&#xA;else&#xA;  let b:undo_ftplugin = ''&#xA;endif&#xA;&#xA;&amp;quot; This is where my local foldtext() function for rust.vim&#xA;foldtext() &amp;lt;...&amp;gt;&#xA;&#xA;if !exists(&amp;quot;*MyRustFtpluginUndo&amp;quot;)&#xA;  function MyCFtpluginUndo()&#xA;    setlocal tags&amp;lt;&#xA;    setlocal path&amp;lt;&#xA;    silent! nunmap &amp;lt;buffer&amp;gt; &amp;lt;LocalLeader&amp;gt;tr&#xA;  endfunction&#xA;endif&#xA;&#xA;let b:undo_ftplugin .= 'call MyRustFtpluginUndo()'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="36863" LastEditDate="2021-09-14T17:44:31.630" LastActivityDate="2021-09-14T17:44:31.630" Title="Fold: foldtext() for each filetype" Tags="|folding|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17824" PostTypeId="2" ParentId="17818" CreationDate="2018-11-04T18:58:13.520" Score="6" Body="&lt;h1&gt;Caps Lock LED without &lt;code&gt;root&lt;/code&gt; privileges&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9Qr0p.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9Qr0p.jpg&quot; alt=&quot;Varmilo Caps Lock with LED&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;1) Making &lt;kbd&gt;Caps Lock&lt;/kbd&gt; act like &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The full path to below &lt;code&gt;bash&lt;/code&gt; script was added to &lt;code&gt;Session and Startup&lt;/code&gt; → &lt;code&gt;Application Autostart&lt;/code&gt; in Xubuntu LTS.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env bash&#xA;sleep 4&#xA;xmodmap -e &quot;clear Lock&quot;&#xA;xmodmap -e &quot;keysym Caps_Lock = Escape&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;2) Edit &lt;code&gt;/usr/share/X11/xkb/compat/ledcaps&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sudo sed -i 's|\!allowExplicit|allowExplicit|g' /usr/share/X11/xkb/compat/ledcaps&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Logging out and in again&lt;/strong&gt; will allow these X settings to take effect.&#xA;For more information, &lt;a href=&quot;https://unix.stackexchange.com/a/179378/39845&quot;&gt;see here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;3) Add an &lt;code&gt;augroup&lt;/code&gt; to &lt;code&gt;$MYVIMRC&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;$MYVIMRC&lt;/code&gt; add the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Light the Caps Lock LED when in Insert mode.&#xA;&quot; https://vi.stackexchange.com/a/17824/3168&#xA;if has(&quot;gui_running&quot;)&#xA;    augroup CapsLockLED&#xA;        autocmd!&#xA;        autocmd InsertEnter * :silent !xset  led named 'Caps Lock'&#xA;        autocmd InsertLeave * :silent !xset -led named 'Caps Lock'&#xA;        autocmd VimLeave    * :silent !xset -led named 'Caps Lock'&#xA;    augroup END&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After sourcing &lt;code&gt;$MYVIMRC&lt;/code&gt; or restarting &lt;code&gt;vim&lt;/code&gt;, the &lt;kbd&gt;Caps Lock&lt;/kbd&gt; LED will light whenever &lt;code&gt;vim&lt;/code&gt; is in insert mode, by whatever means. Hitting the lit &lt;kbd&gt;Caps Lock&lt;/kbd&gt; key will return &lt;code&gt;vim&lt;/code&gt; to the normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my &lt;a href=&quot;http://en.varmilo.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Varmilo&lt;/a&gt; VA88M keyboard this LED is built into the &lt;kbd&gt;Caps Lock&lt;/kbd&gt; key, which results in a nice effect.&lt;/p&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="3168" LastEditDate="2019-10-22T11:34:02.130" LastActivityDate="2019-10-22T11:34:02.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17826" PostTypeId="2" ParentId="17814" CreationDate="2018-11-05T02:16:03.850" Score="1" Body="&lt;p&gt;According to the vim terminal documentation, there is a special key binding for pasting in a terminal window. From the &lt;a href=&quot;https://github.com/vim/vim/blob/9e353b5265bd7fa103caf4e5a9b3c99f344f548e/runtime/doc/terminal.txt#L79-L81&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim terminal window support documentation&lt;/a&gt; on the Vim git repo.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-W &amp;quot; {reg}  paste register {reg}        *CTRL-W_quote*&#xA;        Also works with the = register to insert the result of&#xA;        evaluating an expression.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Other than using the middle mouse button, this is the only reference to copy/pasting I could see.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sup&gt;NB: I don't have a mac so this is untested, hope it helps!&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="14380" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-11-05T02:16:03.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17827" PostTypeId="2" ParentId="17823" CreationDate="2018-11-05T03:26:37.323" Score="2" Body="&lt;h2&gt;Example&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/after/ftplugin/rust.vim&#xA;if exists('b:undo_ftplugin')&#xA;  let b:undo_ftplugin .= ' | '&#xA;else&#xA;  let b:undo_ftplugin = ''&#xA;endif&#xA;&#xA;function! RustFoldText()&#xA;  &quot; cf. :help fold-foldtext&#xA;  return &quot;text to display for foldtext&quot;&#xA;endfunction&#xA;&#xA;setlocal foldtext=RustFoldText()&#xA;&#xA;if !exists(&quot;*MyRustFtpluginUndo&quot;)&#xA;  function MyRustFtpluginUndo()&#xA;    &quot; reset options, undefine functions/commands, etc&#xA;    setlocal foldtext&amp;lt;&#xA;  endfunction&#xA;endif&#xA;&#xA;let b:undo_ftplugin .= 'call MyRustFtpluginUndo()'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Explanation of example&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First, the file: &lt;code&gt;~/.vim/after/ftplugin/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; can contain custom vimscript to execute for filetypes. cf. &lt;code&gt;:help ftplugin&lt;/code&gt;, &lt;code&gt;:help after&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;b:undo_ftplugin&lt;/code&gt; boilerplate is responsible coding; it ensures that, when switching filetypes (such as editing a new buffer), &lt;code&gt;vim&lt;/code&gt; restores changed options to sensible values. You can also use it to clean up cruft (like removing mappings). cf. &lt;code&gt;:help b:undo_ftplugin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The meat is of course the function &lt;code&gt;RustFoldText&lt;/code&gt;, which the option &lt;code&gt;'foldtext'&lt;/code&gt; takes on locally. I've never written a foldtext function, but the vim help doc I reference above has good information on how to. So does this site, probably. It &lt;em&gt;must&lt;/em&gt; return the text for the fold, and can make use of some magic variables to assist with that. cf. &lt;code&gt;:help fold-foldtext&lt;/code&gt;, &lt;code&gt;:help setlocal&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Notes&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if &lt;code&gt;foldtext&lt;/code&gt; will allow &lt;code&gt;s:&lt;/code&gt; script-local functions or not; you could experiment with that by using &lt;code&gt;function! s:RustFoldText()&lt;/code&gt; and &lt;code&gt;setlocal foldtext=&amp;lt;SID&amp;gt;RustFoldText()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-11-05T03:26:37.323" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17828" PostTypeId="1" CreationDate="2018-11-05T03:55:19.467" Score="0" ViewCount="203" Body="&lt;p&gt;Extend of this question of fold: &lt;a href=&quot;https://vi.stackexchange.com/q/17823/14274&quot;&gt;Fold: foldtext() for each filetype&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have fold for each filetype now but each fold need different highlight style of color, because &lt;code&gt;highlight&lt;/code&gt; is global I tried to set it in &lt;code&gt;after/ftplugin/rust/folding.vim&lt;/code&gt; and then reset it back to my favor default one but it doesn't effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inconsistent behavior like if vim enter buffer of rust it set to new &lt;code&gt;hi&lt;/code&gt; and then if leave &lt;code&gt;rust&lt;/code&gt; buffer file it still persist the rust's &lt;code&gt;hi&lt;/code&gt; for other buffers, that is not expected, leave &lt;code&gt;rust&lt;/code&gt; buffer should set &lt;code&gt;hi&lt;/code&gt; back to default and other buffers should take the default one instead of the new rust &lt;code&gt;hi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('b:undo_ftplugin')&#xA;  let b:undo_ftplugin .= ' | '&#xA;else&#xA;  let b:undo_ftplugin = ''&#xA;endif&#xA;&#xA;&quot; set highlight here for this specific fold&#xA;hi Fold ctermfg=10 ctermbg=12&#xA;&#xA;&quot; This is where my local foldtext() function for rust.vim&#xA;foldtext() &amp;lt;...&amp;gt;&#xA;&#xA;if !exists(&quot;*MyRustFtpluginUndo&quot;)&#xA;  function MyCFtpluginUndo()&#xA;    setlocal tags&amp;lt;&#xA;    setlocal path&amp;lt;&#xA;    silent! nunmap &amp;lt;buffer&amp;gt; &amp;lt;LocalLeader&amp;gt;tr&#xA;&#xA;    &quot; set highlight back to default one&#xA;    hi Fold ctermfg=5 ctermbg=6&#xA;  endfunction&#xA;endif&#xA;&#xA;let b:undo_ftplugin .= 'call MyRustFtpluginUndo()'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note about: &lt;code&gt;hi Fold ctermfg=10 ctermbg=12&lt;/code&gt; and &lt;code&gt;hi Fold ctermfg=5 ctermbg=6&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2023-12-09T16:02:55.423" Title="Fold: Different highlight style for fold of each filetype" Tags="|syntax-highlighting|highlight|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17829" PostTypeId="2" ParentId="17828" CreationDate="2018-11-05T04:29:58.347" Score="0" Body="&lt;p&gt;Solution: we just need to set this &lt;code&gt;hi Fold ctermfg=10 ctermbg=12&lt;/code&gt; in each fold file of each filetype, because of this set global, make sure to set to your favor hi of &lt;code&gt;Folded&lt;/code&gt;, if not set, &lt;code&gt;Folded&lt;/code&gt; of previous &lt;code&gt;folding&lt;/code&gt; will take place.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2018-11-05T04:29:58.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17832" PostTypeId="1" AcceptedAnswerId="17833" CreationDate="2018-11-05T10:00:02.347" Score="23" ViewCount="3236" Body="&lt;p&gt;Apologies if &quot;composite&quot; is not the technical term. I mean the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hi, I-am-a-composite-word and we are not&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to delete only the composite word. In command mode, if I move the cursor to &lt;code&gt;I&lt;/code&gt;, then repeating &lt;code&gt;dw&lt;/code&gt; a few times, or better typing &lt;code&gt;dw&lt;/code&gt; once, followed by a few &lt;code&gt;.&lt;/code&gt; presses, will do the trick. However, for various reasons I find myself doing this quite often during the day, thus I was wondering if there's any simpler way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS I would &lt;strong&gt;NOT&lt;/strong&gt; consider the command &lt;code&gt;d9w&lt;/code&gt; to be a simpler way. Counting a long sequence of words and dashes is not my idea of &quot;simpler&quot;.&lt;/p&gt;&#xA;" OwnerUserId="19675" LastEditorUserId="1841" LastEditDate="2018-11-05T10:08:32.503" LastActivityDate="2018-11-06T09:01:16.813" Title="Simplest way to delete a &quot;composite&quot; word?" Tags="|cursor-motions|normal-mode|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17833" PostTypeId="2" ParentId="17832" CreationDate="2018-11-05T10:06:40.613" Score="35" Body="&lt;p&gt;What you are calling a composite word is actually a WORD (by opposition to a word). Reading &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#word&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h word&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#WORD&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h WORD&lt;/code&gt;&lt;/a&gt; should be helpful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *word*&#xA;A word consists of a sequence of letters, digits and underscores, or a&#xA;sequence of other non-blank characters, separated with white space (spaces,&#xA;tabs, &amp;lt;EOL&amp;gt;).  This can be changed with the 'iskeyword' option.  An empty line&#xA;is also considered to be a word.&#xA;                            *WORD*&#xA;A WORD consists of a sequence of non-blank characters, separated with white&#xA;space.  An empty line is also considered to be a WORD.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What you are looking for here is &lt;code&gt;dW&lt;/code&gt; when you are on the &lt;code&gt;I&lt;/code&gt; or &lt;code&gt;diW&lt;/code&gt; when you are anywhere in the word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe in the future you will also need to read &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27iskeyword%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'iskeyword'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-11-05T10:06:40.613" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17834" PostTypeId="2" ParentId="17832" CreationDate="2018-11-05T14:17:57.530" Score="4" Body="&lt;p&gt;If you want to keep using &lt;code&gt;dw&lt;/code&gt; and the like, and also want to let it work with double-clicking a word, you can add &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword+=-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your &lt;code&gt;.vimrc&lt;/code&gt;, which adds &lt;code&gt;-&lt;/code&gt; as a word character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Double-clicking any character in &lt;code&gt;ab-cd&lt;/code&gt; visually highlights &lt;code&gt;ab-cd&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18342" LastActivityDate="2018-11-05T14:17:57.530" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17835" PostTypeId="2" ParentId="17832" CreationDate="2018-11-05T14:33:06.300" Score="5" Body="&lt;p&gt;Don't forget the &lt;code&gt;f&lt;/code&gt; (find) and &lt;code&gt;t&lt;/code&gt; (to) commands. I'd probably just &lt;code&gt;dt &lt;/code&gt; or &lt;code&gt;df &lt;/code&gt; (note the space at the end).&lt;/p&gt;&#xA;" OwnerUserId="19679" LastEditorUserId="19679" LastEditDate="2018-11-05T14:44:01.573" LastActivityDate="2018-11-05T14:44:01.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17836" PostTypeId="2" ParentId="17832" CreationDate="2018-11-05T14:37:51.863" Score="11" Body="&lt;p&gt;Another more general solution is to delete up to the whitespace character using &lt;code&gt;dt &lt;/code&gt; (with a space after the &lt;code&gt;t&lt;/code&gt;), which means &quot;delete to [character]. This often is useful for things like &lt;code&gt;dt:&lt;/code&gt; and similar as well.&lt;/p&gt;&#xA;" OwnerUserId="16938" LastEditorUserId="16938" LastEditDate="2018-11-06T09:01:16.813" LastActivityDate="2018-11-06T09:01:16.813" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17837" PostTypeId="1" AcceptedAnswerId="17838" CreationDate="2018-11-06T04:24:10.113" Score="5" ViewCount="620" Body="&lt;p&gt;I have enjoyed coding not too large projects in one single file. This way I can press &lt;code&gt;*&lt;/code&gt; on an identifier and find it without having to hop across buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But naturally this doesn't scale and at some point I need to isolate code into multiple files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a dream use-case for which I wonder what is the best way to accomplish:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit one buffer with multiple sections, each titled with the name of a file. Upon saving, each section is saved into the appropriate file. Upon loading/reading files, each file is incorporated into the buffer into a section titled with its name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By &quot;section&quot; I do not mean any special construct. Just some convention, perhaps file name underlined by &lt;code&gt;=====&lt;/code&gt; to denote a boundary in text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;main.py&#xA;=======&#xA;&#xA;import util&#xA;&#xA;print(util.rnd())&#xA;&#xA;util.py&#xA;=======&#xA;&#xA;def rnd ():&#xA;    return 7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: please excuse the diminished entropy of the random generator in this example&lt;/p&gt;&#xA;" OwnerUserId="12298" LastActivityDate="2018-11-06T16:52:19.653" Title="edit many files in one buffer" Tags="|buffers|multiple-files|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17838" PostTypeId="2" ParentId="17837" CreationDate="2018-11-06T08:32:18.770" Score="1" Body="&lt;p&gt;I don't thinks it's doable in pure Vim, or easly doable, but you can write a little script, in Python for example. Let's call it &lt;code&gt;split.py&lt;/code&gt;. You can have a file, let's call it &lt;code&gt;code.py&lt;/code&gt;, which will be the one that you edit. You can then call your script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./split.py code.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then also automate it in Vim with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost code.py !./split.py %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will call your &lt;code&gt;split.py&lt;/code&gt; whenever you will save a file called &lt;code&gt;code.py&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or have it in &lt;code&gt;$PATH&lt;/code&gt; somewhere, and call it without &lt;code&gt;./&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To merge files, you could write another script - &lt;code&gt;merge.py&lt;/code&gt; - and call it manually or try to use &lt;code&gt;BufReadPre&lt;/code&gt; autocommand in similar way as above with &lt;code&gt;BufWritePost&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On the other hand, since you're using Python in the example, why not try &lt;a href=&quot;http://github.com/python-mode/python-mode&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python-mode&lt;/a&gt; plugin, which provides really nice experience while working with Python code (you will need also some kind of completion plugin, like neocomplete, YouCompleteMe, deoplete, etc..). I'm using this setup at work as a Python developer. It contains refactoring tools, go to definition, linters, checkers&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2018-11-06T08:32:18.770" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17839" PostTypeId="2" ParentId="17837" CreationDate="2018-11-06T08:51:48.053" Score="2" Body="&lt;p&gt;You can achieve the functionality you're looking for through the use of multiple windows. This allows for search and highlighting across windows. To save all files &lt;code&gt;:wa&lt;/code&gt; to save and close &lt;code&gt;:wqa&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open new windows using &lt;code&gt;:split&lt;/code&gt;/&lt;code&gt;&amp;lt;C-w&amp;gt;S&lt;/code&gt; for horizontal splitting or &lt;code&gt;:vsplit&lt;/code&gt;/&lt;code&gt;&amp;lt;C-w&amp;gt;v&lt;/code&gt; for vertical splitting. You can then navigate between using &lt;code&gt;&amp;lt;C-w&amp;gt;[h/j/k/l]&lt;/code&gt; or &lt;code&gt;&amp;lt;C-w&amp;gt;w&lt;/code&gt; to cycle through windows. To open the desired files use &lt;code&gt;:e /path/to/file&lt;/code&gt; (relative to directory you opened vim from)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW didn't know you could push &lt;code&gt;*&lt;/code&gt; to highlight all occurrences of an identifier, its a neat trick. A fine addition to my collection ;) &lt;/p&gt;&#xA;" OwnerUserId="14380" LastActivityDate="2018-11-06T08:51:48.053" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17840" PostTypeId="2" ParentId="17012" CreationDate="2018-11-06T10:02:08.690" Score="1" Body="&lt;p&gt;You can use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/)\([^ ]\)/s//) \1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where the &lt;code&gt;[^ ]&lt;/code&gt; means any character except space, the &lt;code&gt;\(\)&lt;/code&gt; surrounding it is to group it and reference it later in the substitution as &lt;code&gt;\1&lt;/code&gt;. Thus, it effectively adds a space after a &lt;code&gt;)&lt;/code&gt; followed by any character except a space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the above command does not add a space if the &lt;code&gt;)&lt;/code&gt; is at the end of a line. To also add spaces to those too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/)\([^ ]\|$\)/s//) \1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;$&lt;/code&gt; represents end of line and the &lt;code&gt;\|&lt;/code&gt; adds it to the match-any-character-except-space as an &quot;or&quot;&lt;/p&gt;&#xA;" OwnerUserId="12298" LastEditorUserId="12298" LastEditDate="2018-11-08T03:09:21.437" LastActivityDate="2018-11-08T03:09:21.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17842" PostTypeId="1" CreationDate="2018-11-06T13:07:16.853" Score="0" ViewCount="914" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u8t7u.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u8t7u.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I expected the folded text highlighted as below picture (ignore &lt;code&gt;red&lt;/code&gt; rectangle):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/WsiSA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WsiSA.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Like the above picture, I'd like to have something to recognize that &lt;code&gt;red&lt;/code&gt; region of a fold and highlight it only, do not have &lt;code&gt;ctermbg&lt;/code&gt; apply to the region of the redundant space.&lt;/p&gt;&#xA;&lt;p&gt;This question is kind of general, I don't have much experience so I try to explain from the user's perspective, I'd like to have that &lt;code&gt;red&lt;/code&gt; region highlighted only that is a folded block of text.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="36863" LastEditDate="2021-09-14T13:23:10.407" LastActivityDate="2021-09-14T13:23:10.407" Title="Fold: highlight folded text only" Tags="|highlight|folding|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17843" PostTypeId="2" ParentId="17842" CreationDate="2018-11-06T13:48:28.287" Score="1" Body="&lt;p&gt;That is not possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The folded text always uses the highlighting group &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#hl-Folded&quot; rel=&quot;nofollow noreferrer&quot;&gt;Folded&lt;/a&gt; for the complete screen line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can of course change the highlighting group so that it doesn't stand out so much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example remove the background attribute of the Folded group to make only the text standout (or you could use a background attribute that doesn't have such a big contrast to the Normal highlighting group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Folded ctermfg=102 guifg=#878787 guibg=NONE ctermbg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, that this might make it hard to realize that this is actually folded text as can be seen here:&lt;a href=&quot;https://i.stack.imgur.com/6RCfU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6RCfU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-11-06T13:48:28.287" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17844" PostTypeId="1" AcceptedAnswerId="17847" CreationDate="2018-11-06T13:51:30.990" Score="3" ViewCount="377" Body="&lt;p&gt;I try to extend the cmake syntax highlighting by our in-house cmake functions. For this I drafted a file to be saved in &lt;code&gt;~/.vim/after/syntax/cmake.vim&lt;/code&gt;, such that one extends the default cmake syntax highlighting, as suggested in &lt;a href=&quot;https://stackoverflow.com/questions/16224423/extending-javascript-syntax-highlighting-in-vim&quot;&gt;this stackoverflow&lt;/a&gt; post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am struggeling with is that we use &lt;code&gt;INCLUDE_DIRS&lt;/code&gt; as keyword, whereas standard cmake uses &lt;code&gt;INCLUDE_DIRECTORIES&lt;/code&gt;, and I want the syntax highlighting to point out to a developer that they used the wrong convention for the function at hand. (Yes, I could also try to push towards fixing our inhouse style, but the general problem of what-are-possible-keywords-here would remain).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The standard cmake syntax file I'm testing against is &lt;a href=&quot;https://github.com/Kitware/CMake/blob/master/Auxiliary/vim/syntax/cmake.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I want&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;add_library( # this is a standard cmake function&#xA;          ....&#xA;          INCLUDE_DIRECTORIES somepath # highlight the first word here, it's spelled right&#xA;          INCLUDE_DIRS  otherpath      # don't highlight this, it's spelled wrong&#xA; )&#xA;&#xA;fancy_wrapper( # this is from the inhouse modules&#xA;           ...&#xA;           INCLUDE_DIRECTORIES   somepath   # don't highlight&#xA;           INCLUDE_DIRS otherpath)          # highlight&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My understanding was that I can use in my extension the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;b:current_syntax&quot;)&#xA;  if b:current_syntax != &quot;cmake&quot;&#xA;    finish&#xA;  endif&#xA;endif&#xA;let s:keepcpo= &amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;&#xA;syn region OurArgs start=&quot;(&quot; end=&quot;)&quot; contains=OurArguments&#xA;&#xA;syn case match&#xA;&#xA;syn keyword OurArguments contained&#xA;        \ INCLUDE_DIRS&#xA;&#xA;syn case ignore&#xA;&#xA;syn keyword cmakeOurs&#xA;            \ fancy_wrapper&#xA;            \ nextgroup=OurArgs&#xA;&#xA;hi def link cmakeOurs Function&#xA;hi def link OurArguments ModeMsg&#xA;&#xA;let &amp;amp;cpo = s:keepcpo&#xA;unlet s:keepcpo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;my understanding is that &lt;code&gt;fancy_wrapper&lt;/code&gt; now gets recognised as an inhouse function and the next group will be a &lt;code&gt;OurArgs&lt;/code&gt; region instead of the normal &lt;code&gt;cmakeArguments&lt;/code&gt;. And for the normal &lt;code&gt;add_library&lt;/code&gt; the official cmake style should kick in (copy and pasting their code):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword cmakeCommand&#xA;...&#xA;        \ add_library&#xA;...&#xA;        \ nextgroup=cmakeArguments&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Such that the parentheses thereafter are a &lt;code&gt;cmakeArguments&lt;/code&gt; region and &lt;code&gt;INCLUDE_DIRECTORIES&lt;/code&gt; gets recognized therein.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, what I observe is that &lt;code&gt;INCLUDE_DIRECTORIES&lt;/code&gt; never gets highlighted and &lt;code&gt;INCLUDE_DIRS&lt;/code&gt; always gets highlighted. Using the &lt;a href=&quot;http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor&quot; rel=&quot;nofollow noreferrer&quot;&gt;debugging hints here&lt;/a&gt;) I see that the region after &lt;code&gt;add_library&lt;/code&gt; is recognized as &lt;code&gt;OurArgs&lt;/code&gt; (last definition taking precedence, afaiu. instead of - what i had hoped - the &lt;code&gt;nextgroup&lt;/code&gt; deciding what happens).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I highlight different sets of keywords within parentheses regions, that all look the same in &lt;code&gt;start=&lt;/code&gt; and &lt;code&gt;end=&lt;/code&gt;? Is that not what &lt;code&gt;nextgroup&lt;/code&gt; is good for?&lt;/li&gt;&#xA;&lt;li&gt;Ideally (depending how the answer on the first turns out), can I still do that without modifying kitware's cmake.vim file?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6044" LastActivityDate="2018-11-06T16:41:03.343" Title="define two syntax regions with same pattern" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17845" PostTypeId="1" CreationDate="2018-11-06T14:20:27.450" Score="3" ViewCount="1245" Body="&lt;p&gt;I generated tags files and I'm using the following command in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set tags=./tags;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt; I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E433: No tags file&#xA;E426: tag not found: poll_wait&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure that the tag file is actually loaded.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set tags?&#xA;  tags=./tags;&#xA;        Last set from ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I debug it further ?&lt;/p&gt;&#xA;" OwnerUserId="496" LastEditorUserId="5395" LastEditDate="2018-11-06T14:24:17.450" LastActivityDate="2018-11-06T16:19:32.003" Title="vim can't process tags" Tags="|tags|ctags|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17846" PostTypeId="2" ParentId="17845" CreationDate="2018-11-06T16:19:32.003" Score="2" Body="&lt;p&gt;Your &lt;code&gt;'tags'&lt;/code&gt; setting should search for tags named &lt;code&gt;tags&lt;/code&gt; in the current directory:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When a file name starts with &quot;./&quot;, the '.' is replaced with the path&#xA;  of the current file.  But only when the 'd' flag is not included in&#xA;  'cpoptions'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could check the compatibility options that they don't include &lt;code&gt;d&lt;/code&gt; with &lt;code&gt;:set cpo?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, files named &lt;code&gt;tags&lt;/code&gt; would be found in parent directories (according to &lt;a href=&quot;https://vimhelp.appspot.com/editing.txt.html#file-searching&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help file-searching&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The stop-directories are appended to the path (for the 'path' option) or to the filename (for the 'tags' option) with a ';'.  If you want no stop-directory (&quot;search upward till the root directory) just use ';'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, all is looking fine (assuming a tags file actually is there). &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27tags%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'tags'&lt;/code&gt;&lt;/a&gt; also provides a great troubleshooting tip:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The tagfiles() function can be used to get a list of the file names actually used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use that one with &lt;code&gt;:echo&lt;/code&gt;. Good luck!&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-06T16:19:32.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17847" PostTypeId="2" ParentId="17844" CreationDate="2018-11-06T16:41:03.343" Score="2" Body="&lt;p&gt;Superficially, all that is missing is the &lt;code&gt;contained&lt;/code&gt; attribute for the &lt;code&gt;OurArgs&lt;/code&gt; definition. Without it, that may match anywhere, not just after &lt;code&gt;cmakeOurs&lt;/code&gt; via the &lt;code&gt;nextgroup=&lt;/code&gt;. Very often, when you explicitly ask for parsing to continue with &lt;code&gt;nextgroup&lt;/code&gt;, you want that syntax to be &lt;code&gt;contained&lt;/code&gt;, to avoid accidental matches elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region OurArgs start=&quot;(&quot; end=&quot;)&quot; contains=OurArguments contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, it's not that easy with the &lt;code&gt;cmake&lt;/code&gt; syntax. Looking at the &quot;competing&quot; &lt;code&gt;cmakeArguments&lt;/code&gt; region, it has this definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region cmakeArguments start=&quot;(&quot; end=&quot;)&quot;&#xA;\ contains=ALLBUT,cmakeCommand,cmakeCommandConditional,cmakeCommandRepeat,&#xA;\ cmakeCommandDeprecated,cmakeArguments,cmakeTodo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is the &lt;code&gt;ALLBUT&lt;/code&gt;, which indirectly again introduces &lt;code&gt;OurArgs&lt;/code&gt; and &lt;code&gt;OurArguments&lt;/code&gt; into the regular cmake block, which causes the matching that you don't want there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if &lt;code&gt;syntax/cmake.vim&lt;/code&gt; were written with extension in mind, it would include an (empty) &lt;a href=&quot;https://vimhelp.appspot.com/syntax.txt.html#%3Asyn-cluster&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :syn-cluster&lt;/code&gt;&lt;/a&gt; in that &lt;code&gt;contains&lt;/code&gt; clause, allowing you to add your groups to the exclusion list. As it does not, you need to override the original definition, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn clear cmakeArguments&#xA;syn region cmakeArguments start=&quot;(&quot; end=&quot;)&quot;&#xA;\ contains=ALLBUT,cmakeCommand,cmakeCommandConditional,cmakeCommandRepeat,&#xA;\ cmakeCommandDeprecated,cmakeArguments,cmakeTodo,OurArgs,OurArguments&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With that, the coloring will only apply to the &lt;code&gt;fancy_wrapper&lt;/code&gt; block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: The &lt;code&gt;OurArgs&lt;/code&gt; and &lt;code&gt;OurArguments&lt;/code&gt; are not very expressive (hopefully just because you've obfuscated them for us), and should also start with the &lt;code&gt;cmake&lt;/code&gt; prefix like the original syntax items.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-06T16:41:03.343" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17848" PostTypeId="2" ParentId="17837" CreationDate="2018-11-06T16:52:19.653" Score="0" Body="&lt;p&gt;I think you're approaching that from the wrong direction: Instead of artificially joining and splitting multiple files into a single buffer, you should instead adjust your searching to cover multiple buffers (or windows, if you &lt;code&gt;:sbuffer&lt;/code&gt; them). That means that you can't simply use &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;n&lt;/code&gt;/&lt;code&gt;N&lt;/code&gt; to go through all matches, but:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use &lt;code&gt;:vimgrep&lt;/code&gt; and the &lt;em&gt;quickfix list&lt;/em&gt; and corresponding commands (e.g. &lt;code&gt;:cnext&lt;/code&gt;) to iterate over matches&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set nowrapscan&lt;/code&gt; and switch to the next window (&lt;code&gt;&amp;lt;C-w&amp;gt;&amp;lt;C-w&amp;gt;&lt;/code&gt;) before continuing searching with &lt;code&gt;n&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;use a combination of &lt;code&gt;:bufdo&lt;/code&gt; and &lt;code&gt;:global&lt;/code&gt; to show matches&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-06T16:52:19.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17849" PostTypeId="2" ParentId="17822" CreationDate="2018-11-06T17:06:13.650" Score="1" Body="&lt;p&gt;Custom commands cannot start with lowercase letters, but you can define for example &lt;code&gt;:Ce&lt;/code&gt; and &lt;code&gt;:Ctabe&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a custom function that does the same as &lt;code&gt;:edit {file}&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=file Ce edit &amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to open another related file, you would use &lt;code&gt;:vsplit&lt;/code&gt;; the current file can be referenced via the &lt;a href=&quot;https://vimhelp.appspot.com/cmdline.txt.html#cmdline-special&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help cmdline-special&lt;/code&gt;&lt;/a&gt; notation &lt;code&gt;%&lt;/code&gt;. &lt;code&gt;%:r&lt;/code&gt; gives you the current file without its file extension. So the following will open the corresponding header file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -complete=file Ce edit &amp;lt;args&amp;gt; | vsplit %:r.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: There are several plugins that do something like that, too. A very old one is &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=31&quot; rel=&quot;nofollow noreferrer&quot;&gt;a.vim&lt;/a&gt;. A modern one is &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4989&quot; rel=&quot;nofollow noreferrer&quot;&gt;projectionist.vim&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-06T17:06:13.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17850" PostTypeId="2" ParentId="17819" CreationDate="2018-11-06T17:20:09.297" Score="1" Body="&lt;p&gt;If you and co-worker(s) want to continuously work on the same systems, I'd recommend to use &lt;strong&gt;different user accounts&lt;/strong&gt;, so that each has a different home directory. Unix was designed that way from the start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is just for a short session, and your colleague would be confused by your customizations and remappings, you can quickly start up a vanilla Vim instance with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -u NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This isn't completely identical to a clean Vim installation, because default plugins (like netrw and matchparen) won't be loaded, neither. For that, the following command (best put to an alias) can be used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --cmd 'set rtp=$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after | if exists(&quot;+packpath&quot;) | let &amp;amp;packpath = &amp;amp;rtp | endif' -N -u NORC -c 'set rtp&amp;amp; | if exists(&quot;+packpath&quot;) | set packpath&amp;amp; | endif'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this sharing happens a lot (because you're avid pair programmers), it might be worthwhile to separate your configuration into &quot;standard&quot; plugins (shared) and your personal remappings and tweaks. If you diligently separate these in your &lt;code&gt;~/.vimrc&lt;/code&gt; and surround the latter with &lt;code&gt;if ! exists('g:sharedconfig')&lt;/code&gt;, you can launch a &quot;cleaner&quot; variant via&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --cmd 'let g:sharedconfig = 1'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Going even further, your whole team could put their configurations / home directories on a network share, so that these are accessible from anywhere. This would also help with quickly setting up new systems with your own configuration (which I think is a different question, and has already been covered in depth elsewhere).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-06T17:20:09.297" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17851" PostTypeId="1" AcceptedAnswerId="17855" CreationDate="2018-11-06T18:39:13.203" Score="0" ViewCount="2259" Body="&lt;p&gt;I built vim from source. But for some reason I can no longer underline my current line when vim loads .vimrc. I have to type underline commands manually which makes it work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the output of my version command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Nov  5 2018 21:28:01)&#xA;Included patches: 1-510&#xA;Compiled by user@user-fedora-PC0PVGAT&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               +extra_search      +mouse_netterm     +tag_old_static&#xA;+arabic            +farsi             +mouse_sgr         -tag_any_white&#xA;+autocmd           +file_in_path      -mouse_sysmouse    -tcl&#xA;+autochdir         +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       +terminal&#xA;-balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;-browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    +gettext           +netbeans_intg     +timers&#xA;+byte_offset       -hangul_input      +num64             +title&#xA;+channel           +iconv             +packages          -toolbar&#xA;+cindent           +insert_expand     +path_extra        +user_commands&#xA;+clientserver      +job               +perl              +vartabs&#xA;+clipboard         +jumplist          +persistent_undo   +vertsplit&#xA;+cmdline_compl     +keymap            +postscript        +virtualedit&#xA;+cmdline_hist      +lambda            +printer           +visual&#xA;+cmdline_info      +langmap           +profile           +visualextra&#xA;+comments          +libcall           +python/dyn        +viminfo&#xA;+conceal           +linebreak         +python3/dyn       +vreplace&#xA;+cryptv            +lispindent        +quickfix          +wildignore&#xA;+cscope            +listcmds          +reltime           +wildmenu&#xA;+cursorbind        +localmap          +rightleft         +windows&#xA;+cursorshape       +lua               +ruby              +writebackup&#xA;+dialog_con        +menu              +scrollbind        +X11&#xA;+diff              +mksession         +signs             +xfontset&#xA;+digraphs          +modify_fname      +smartindent       -xim&#xA;-dnd               +mouse             +startuptime       -xpm&#xA;-ebcdic            -mouseshape        +statusline        +xsmp_interact&#xA;+emacs_tags        +mouse_dec         -sun_workshop      +xterm_clipboard&#xA;+eval              -mouse_gpm         +syntax            -xterm_save&#xA;+ex_extra          -mouse_jsbterm     +tag_binary&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/home/user/myfs/opt/vim/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -fPIC -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -L. -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld   -L/usr/local/lib -Wl,--as-needed -o vim    -lSM -lICE -lXt -lX11 -lSM -lICE  -lm -ltinfo -lelf  -lselinux   -ldl  -L/usr/lib -llua -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -L/usr/local/lib  -L/usr/lib64/perl5/CORE -lperl -lpthread -lresolv -ldl -lm -lcrypt -lutil -lc    -lruby -lpthread -ldl -lcrypt -lm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;Plugin 'tpope/vim-sensible.git'&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'christoomey/vim-system-copy.git'&#xA;Plugin 'tpope/vim-surround'&#xA;Plugin 'majutsushi/tagbar'&#xA;Plugin 'ctrlpvim/ctrlp.vim'&#xA;Plugin 'tomtom/tcomment_vim'&#xA;Plugin 'Valloric/YouCompleteMe'&#xA;Plugin 'rdnetto/YCM-Generator'&#xA;Plugin 'godlygeek/tabular.git'&#xA;Plugin 'jiangmiao/auto-pairs.git'&#xA;Plugin 'mileszs/ack.vim'&#xA;Plugin 'Yggdroot/indentLine.git'&#xA;Plugin 'vim-scripts/xoria256.vim.git'&#xA;Plugin 'itchyny/lightline.vim.git'&#xA;Plugin 'kana/vim-textobj-user.git'&#xA;Plugin 'kana/vim-textobj-line.git'&#xA;Plugin 'edkolev/tmuxline.vim.git'&#xA;Plugin 'jeaye/color_coded.git'&#xA;Plugin 'christoomey/vim-tmux-navigator.git'&#xA;Plugin 'tpope/vim-vinegar.git'&#xA;Plugin 'vim-scripts/Conque-GDB.git'&#xA;&quot; Plugin 'w0rp/ale.git'&#xA;&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&#xA;colorscheme xoria256&#xA;&#xA;&quot; To ignore plugin indent changes, instead use:&#xA;&quot;filetype plugin on&#xA;&#xA;&quot; Highlight the search pattern.&#xA;let mapleader=&quot;\&amp;lt;Space&amp;gt;&quot;&#xA;&#xA;set directory=/tmp&#xA;set history=1000&#xA;set hlsearch&#xA;set incsearch&#xA;set ignorecase&#xA;set smartcase&#xA;set showbreak=…&#xA;set linebreak&#xA;set listchars=tab:►-,eol:¬,trail:●&#xA;set relativenumber&#xA;set number&#xA;set tabstop=4 softtabstop=4 shiftwidth=4 expandtab&#xA;retab&#xA;&quot; Underline current cursor line&#xA;set cursorline&#xA;hi clear CursorLine&#xA;hi CursorLine gui=underline cterm=underline&#xA;&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;l :set list!&amp;lt;cr&amp;gt;&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;F8&amp;gt; :nohlsearch&amp;lt;cr&amp;gt;&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;vv :vsp&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;ss :sp&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; Toggle the Tlist window using &amp;lt;F4&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;F4&amp;gt; :TagbarToggle&amp;lt;cr&amp;gt;&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;fb :CtrlPBuffer&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;fm :CtrlPMixed&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;ff :CtrlP getcwd()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;ft :CtrlPTag&amp;lt;cr&amp;gt;&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;sv :source ~/.vimrc&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;ev :edit ~/.vimrc&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;et :edit ~/.tmux.conf&amp;lt;cr&amp;gt;&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;F9&amp;gt;       :cprev&amp;lt;cr&amp;gt;zz&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;F10&amp;gt;      :cnext&amp;lt;cr&amp;gt;zz&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;C-F9&amp;gt;     :lprev&amp;lt;cr&amp;gt;zz&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;C-F10&amp;gt;    :lnext&amp;lt;cr&amp;gt;zz&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;M-F9&amp;gt;     :cfirst&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;M-F10&amp;gt;    :clast&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;mm :set lines=10000 columns=1000&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;mn :set lines=999 columns=90&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; ================ Plugin Configuraiton  ====================&#xA;&#xA;&quot; -------------- YouCompleteMe  -----------------&#xA;let g:ycm_always_populate_location_list            = 1&#xA;let g:ycm_autoclose_preview_window_after_insertion = 1&#xA;let g:ycm_error_symbol                             = 'E&amp;gt;'&#xA;let g:ycm_warning_symbol                           = 'W&amp;gt;'&#xA;let g:ycm_confirm_extra_conf                       = 0&#xA;&#xA;&quot; -------------- lightline  -----------------&#xA;&#xA;&quot; display the plugin name at the mode component?&#xA;function! LightlineMode()&#xA;  return expand('%:t') ==# '__Tagbar__' ? 'Tagbar':&#xA;        \ expand('%:t') ==# 'ControlP' ? 'CtrlP' :&#xA;        \ &amp;amp;filetype ==# 'unite' ? 'Unite' :&#xA;        \ &amp;amp;filetype ==# 'vimfiler' ? 'VimFiler' :&#xA;        \ &amp;amp;filetype ==# 'vimshell' ? 'VimShell' :&#xA;        \ lightline#mode()&#xA;endfunction&#xA;&#xA;let g:lightline = {&#xA;      \ 'active': {&#xA;      \   'left': [ [ 'mode', 'paste' ],&#xA;      \             [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]&#xA;      \ },&#xA;      \ 'component_function': {&#xA;      \   'gitbranch': 'fugitive#head',&#xA;      \   'mode': 'LightlineMode',&#xA;      \ },&#xA;      \ }&#xA;&#xA;&#xA;&#xA;&quot; -------------- indentLine -----------------&#xA;let g:indentLine_char = '|'&#xA;&#xA;&quot; -------------- tagbar -----------------&#xA;let g:tagbar_autoclose        = 1&#xA;let g:tagbar_autofocus        = 1&#xA;let g:tagbar_sort             = 1&#xA;let g:tagbar_autoshowtag      = 1&#xA;let g:tagbar_foldlevel        = 99&#xA;let g:tagbar_show_linenumbers = -1&#xA;&#xA;&quot; -------------- Ack -----------------&#xA;let g:ackprg = 'ag --nogroup --nocolor --column'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These are the lines I'm talking about:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Underline current cursor line&#xA;set cursorline&#xA;hi clear CursorLine&#xA;hi CursorLine gui=underline cterm=underline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is what it looks like now&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aTQBT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aTQBT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I expect it to look like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ntaz5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ntaz5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it look as I expect it, I need to enter the following commands manually&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cursorline&#xA;hi clear CursorLine&#xA;hi CursorLine gui=underline cterm=underline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is why vim no longer reacts to these commands from vimrc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my system description:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ uname -a&#xA;Linux user-fedora-PC0PVGAT 4.18.16-200.fc28.x86_64 #1 SMP Sat Oct 20 23:53:47 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux&#xA;&#xA;$ cat /etc/os-release&#xA;NAME=Fedora&#xA;VERSION=&quot;28 (Workstation Edition)&quot;&#xA;ID=fedora&#xA;VERSION_ID=28&#xA;PLATFORM_ID=&quot;platform:f28&quot;&#xA;PRETTY_NAME=&quot;Fedora 28 (Workstation Edition)&quot;&#xA;ANSI_COLOR=&quot;0;34&quot;&#xA;CPE_NAME=&quot;cpe:/o:fedoraproject:fedora:28&quot;&#xA;HOME_URL=&quot;https://fedoraproject.org/&quot;&#xA;SUPPORT_URL=&quot;https://fedoraproject.org/wiki/Communicating_and_getting_help&quot;&#xA;BUG_REPORT_URL=&quot;https://bugzilla.redhat.com/&quot;&#xA;REDHAT_BUGZILLA_PRODUCT=&quot;Fedora&quot;&#xA;REDHAT_BUGZILLA_PRODUCT_VERSION=28&#xA;REDHAT_SUPPORT_PRODUCT=&quot;Fedora&quot;&#xA;REDHAT_SUPPORT_PRODUCT_VERSION=28&#xA;PRIVACY_POLICY_URL=&quot;https://fedoraproject.org/wiki/Legal:PrivacyPolicy&quot;&#xA;VARIANT=&quot;Workstation Edition&quot;&#xA;VARIANT_ID=workstation&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After I started vim I ran a following command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose hi CursorLine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CursorLine     xxx term=underline ctermbg=237 guibg=#3a3a3a&#xA;    Last set from ~/.vim/bundle/xoria256.vim/colors/xoria256.vim line 42&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Given that &lt;code&gt;CursorLine&lt;/code&gt; was set from the plugin, my question is why this is happening? I didn't have any issues using a standard &lt;code&gt;vim&lt;/code&gt; package, i.e. one installed with a package manager, &lt;code&gt;dnf&lt;/code&gt; in this particular case&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should say that my vim is located in an nonstandard location, &lt;code&gt;~/myfs/opt/vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2865" LastEditorUserId="2865" LastEditDate="2018-11-07T06:49:11.300" LastActivityDate="2018-11-07T18:21:18.627" Title="no longer can underline current cursor" Tags="|vimrc|cursorline|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17853" PostTypeId="1" CreationDate="2018-11-07T01:33:10.040" Score="0" ViewCount="189" Body="&lt;p&gt;EDIT. The cause of the problem has been found: the problem only appears when Tamas Kovacs' Paredit plugin is enabled.&lt;/p&gt;&#xA;&lt;p&gt;I have a lisp file containing comments and strings written using Chinese characters. The file is named &lt;code&gt;chinese.scm&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;;; 華文。&#xA;(display &amp;quot;一二三。&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried to delete a character using &lt;code&gt;x&lt;/code&gt; in normal mode. Positioning my cursor on &lt;code&gt;文&lt;/code&gt;, I pressed &lt;code&gt;x&lt;/code&gt; once, but this is what I see on the screen:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;;; 華&amp;lt;96&amp;gt;&amp;lt;87&amp;gt;。&#xA;(display &amp;quot;一二三。&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Vim appears to be deleting a byte instead of the entire Chinese character. The same problem appears when I try to delete a character within the string above. This problem only appears with lisp files (i.e. Scheme, Common Lisp, Clojure), and not with non-code files.&lt;/p&gt;&#xA;&lt;p&gt;Surprisingly, deleting the Chinese character here works perfectly:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(印 &amp;quot;Dire bonjour à la dame.&amp;quot;)  ; After deletion: ( &amp;quot;Dire bonjour à la dame.&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Questions are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Why does this happen?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How can this problem be fixed? i.e. How can I delete one Chinese character in comments and strings using &lt;code&gt;x&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19712" LastEditorUserId="36863" LastEditDate="2023-03-13T13:57:27.833" LastActivityDate="2023-03-13T13:57:27.833" Title="How to delete Chinese characters in Lisp code (solved)" Tags="|cut-copy-paste|comments|filetype-clojure|filetype-lisp|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17855" PostTypeId="2" ParentId="17851" CreationDate="2018-11-07T06:51:52.407" Score="3" Body="&lt;p&gt;As you can see from the output of &lt;code&gt;:verbose :hi CursorLine&lt;/code&gt;, your CursorLine setting is reset by the colorscheme you are using. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a couple of approaches you can use to change that. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Simply comment out the line in the colorscheme. &lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a &lt;code&gt;VimEnter&lt;/code&gt; autocommand, to have your configuration setting set after Vim has startup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup CustomCursorLine&#xA;au!    &#xA;au VimEnter * :hi! CursorLine gui=underline cterm=underline&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;(Note: The autogroup is there so that the autocommand is reset whenever your vimrc file is read. That why, after re-sourcing your vimrc the same event won't accumulate multiple times).&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the &lt;code&gt;ColorScheme&lt;/code&gt; autocommand to reset your Cursorline setting whenever a different colorscheme is sourced. That should work like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup CustomCursorLine&#xA;au!    &#xA;au ColorScheme * :hi! CursorLine gui=underline cterm=underline&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Option 3 is the one I personally would recommend. Using a &lt;code&gt;VimEnter&lt;/code&gt; autocommand often feels a bit like a hack, so I personally try to avoid it. Changing the colorscheme might ask for trouble later, if you update your plugin (however the vim-scripts repository is unmaintained, so there most likely won't be any updates anyhow).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-11-07T06:51:52.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17856" PostTypeId="1" AcceptedAnswerId="17858" CreationDate="2018-11-07T07:53:29.633" Score="3" ViewCount="338" Body="&lt;p&gt;In many cases I have one spare window which contains garbage and when I am in my main window, I'd like to close all other (with &lt;code&gt;&amp;lt;C-W&amp;gt;o&lt;/code&gt;), but I am getting E445 for those that are not saved. &#xA;Is there a relatively sort key combination that can close all other saved and not saved windows? &lt;/p&gt;&#xA;" OwnerUserId="19715" LastActivityDate="2018-11-07T10:19:33.783" Title="Is there a shortcut like &lt;C-W&gt;o that ignores the E445" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17857" PostTypeId="2" ParentId="17853" CreationDate="2018-11-07T09:16:33.823" Score="2" Body="&lt;p&gt;You mentioned you are using the &lt;a href=&quot;https://github.com/vim-scripts/paredit.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;paredit plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look into the plugin, you can see, that the &lt;kbd&gt;DEL&lt;/kbd&gt; Key is mapped to the function &lt;a href=&quot;https://github.com/vim-scripts/paredit.vim/blob/791c3a0cc3155f424fba9409a9520eec241c189c/plugin/paredit.vim#L125&quot; rel=&quot;nofollow noreferrer&quot;&gt;PareditEraseFwd&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This function will later call &lt;a href=&quot;https://github.com/vim-scripts/paredit.vim/blob/master/plugin/paredit.vim#L1030&quot; rel=&quot;nofollow noreferrer&quot;&gt;s:EraseFw&lt;/a&gt; and if you look closely into the definition you see that in your case it will do &lt;a href=&quot;https://github.com/vim-scripts/paredit.vim/blob/791c3a0cc3155f424fba9409a9520eec241c189c/plugin/paredit.vim#L1069-L1072&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    elseif pos &amp;lt; len(line) &amp;amp;&amp;amp; pos &amp;gt;= a:startcol&#xA;        &quot; Erasing a non-special character&#xA;        let reg = reg . line[pos]&#xA;        let line = strpart( line, 0, pos ) . strpart( line, pos+1 )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, the &lt;code&gt;strpart()&lt;/code&gt; function works with byte indices, so it will just remove a single byte instead of a single letter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should most likely contact the maintainer of the plugin mentioned at the top of the file to have this fixed (one could for example use a combination of &lt;code&gt;split()&lt;/code&gt; and &lt;code&gt;join()&lt;/code&gt; using the &lt;code&gt;.&lt;/code&gt; to get character indices). When you talk to the maintainer, you should probably also mention that it would be desirable to let the user configure, whether or not he wants certain keys to be mapped (so you could prevent the plugin from mapping the &lt;kbd&gt;DEL&lt;/kbd&gt; key at all, unfortunately, this is not possible currently).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Unrelated, to that, it looks like the plugin should be rather distributed as filetype specific plugin instead of a general purpose plugin. So this is something else to be considered by the maintainer of the plugin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However for a quick solution, you could create a file ~/.vim/after/ftplugin/scheme.vim (create non existing directories) and add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; prevent errors, in case of del being not mapped&#xA;&quot; a nicer solution would just check if the key is being mapped&#xA;&quot; using `mapcheck(&quot;&amp;lt;del&amp;gt;&quot;, 'n')&#xA;:sil! unmap &amp;lt;buffer&amp;gt; &amp;lt;del&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could disable the whole plugin by setting &lt;code&gt;:let g:paredit_mode=0&lt;/code&gt; into your &lt;code&gt;.vimrc&lt;/code&gt; file (which effectively disables the plugin completely. But then you could also just uninstall the plugin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note, that the vim-scripts mirror on github is currently unmaintained and the latest version of the paredit plugin on &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=3998&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim.org&lt;/a&gt; is actually 0.9.13 while the github mirror only has the [0.9.12 version].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&#xA;Actually, it looks like version 0.9.13 fixes your problem. Quoting from the changes of the vim.org page (emphasized by myself):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Always leave cursor to opening char's pos after wrapping selection.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Fix possible cursor move problem caused by &amp;amp;indentexpr when using the&#xA;  c operator.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Bugfix: 2 keymaps assumed g:paredit_leader is identical to ','.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Fix for paredit 'x' and 'X' when clipboard=unnamed.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Added support for hy.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Use  instead of mapleader.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Enhanced detection of forms balanced state.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Unescaped square brackets in balance detection.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Bugfix: pressing  (for completion) followed by ')'.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Remove invalid uses of &lt;code&gt;call&lt;/code&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Fixed problem with 'x' and 'X' commands when erasing multi-byte unicode character.&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Fix Paredit burfing (by moving parens left or right) when there are&#xA;  stings as elements.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Added paredit support for shen language.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Do not skip parens after \ when searching for pairs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-11-07T09:22:05.163" LastActivityDate="2018-11-07T09:22:05.163" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17858" PostTypeId="2" ParentId="17856" CreationDate="2018-11-07T10:19:33.783" Score="6" Body="&lt;p&gt;If you want to dispose of the unpersisted buffers right away, you'd need to write a custom function that iterates over all visible buffers and &lt;code&gt;:bdelete!&lt;/code&gt;s them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I think it's better to postpone the problem until Vim is eventually closed. This behavior is built-in via the &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27hidden%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'hidden'&lt;/code&gt;&lt;/a&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to set this permanently, you could just temporarily set it (I'm using the upper-case &lt;code&gt;O&lt;/code&gt; key to avoid overriding the original mapping; you could also use the alternative &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-w&amp;gt;O :set hidden&amp;lt;CR&amp;gt;&amp;lt;C-w&amp;gt;o:set nohidden&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's ugly, we can use &lt;code&gt;:wincmd&lt;/code&gt; to make a single, concatenated command-line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-w&amp;gt;O :set hidden&amp;lt;Bar&amp;gt;wincmd o&amp;lt;Bar&amp;gt;set nohidden&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But wait, there's a special &lt;a href=&quot;https://vimhelp.appspot.com/windows.txt.html#%3Aonly&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:only&lt;/code&gt;&lt;/a&gt; command that does the same:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-w&amp;gt;O :set hidden&amp;lt;Bar&amp;gt;only&amp;lt;Bar&amp;gt;set nohidden&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And reading the documentation, this takes an optional &lt;code&gt;!&lt;/code&gt; to force hiding &lt;em&gt;without having to set the option&lt;/em&gt;. I think that's a winner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-w&amp;gt;O :only!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-07T10:19:33.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17859" PostTypeId="1" AcceptedAnswerId="17861" CreationDate="2018-11-07T10:39:42.100" Score="8" ViewCount="1794" Body="&lt;p&gt;I have this coding in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/A3N4k.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/A3N4k.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If any line contains trailing whitespace, then this function terminates silently, but otherwise I get this error message:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FDT7s.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FDT7s.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could add &lt;code&gt;silent!&lt;/code&gt; to the autocmd, but I have other code in this function, for which I do not want any error output to be suppressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I suppress the error message for just this single &lt;code&gt;substitute&lt;/code&gt; command?&lt;/p&gt;&#xA;" OwnerUserId="18342" LastActivityDate="2018-11-07T14:43:48.047" Title="Suppress error message from &quot;substitute&quot; if string not found" Tags="|substitute|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17860" PostTypeId="1" CreationDate="2018-11-07T12:56:43.220" Score="1" ViewCount="610" Body="&lt;p&gt;The vim-airline documentation addresses statusline sections as &quot;airline_section_[a-z]&quot; and mentions &quot;additional sections&quot; ([...]).  I have searched in vain to figure out what letter/number could be used to address these sections (to make them empty or just change their contents).  Tried capital letters in vain.  Any hints?&lt;/p&gt;&#xA;" OwnerUserId="19719" LastActivityDate="2018-11-07T12:56:43.220" Title="How to access &quot;additional sections&quot; in vim-airline?" Tags="|statusline|plugin-airline|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17861" PostTypeId="2" ParentId="17859" CreationDate="2018-11-07T14:43:48.047" Score="10" Body="&lt;p&gt;You can silence individual commands inside a function by prepending &lt;code&gt;:silent!&lt;/code&gt; just as well, so either &lt;code&gt;:silent! execute&lt;/code&gt; or &lt;code&gt;:execute 'silent! %s...&lt;/code&gt; would do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you don't need any of this, because &lt;code&gt;:substitute&lt;/code&gt; understands a &lt;code&gt;/e&lt;/code&gt; flag that suppresses any errors resulting from no pattern matches (cp. &lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#%3As_e&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :s_e&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you only need &lt;code&gt;:execute&lt;/code&gt; when you need to interpolate variable contents into a command. Your substitution uses a constant pattern, so you're just making the command more complex (because of the doubling of backslashes) without any benefit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\s\+$//e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Additional comments on style&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You don't need the &lt;code&gt;:&lt;/code&gt; in &lt;code&gt;:call&lt;/code&gt;; this is only needed in (interactive or in a mapping) normal mode to switch to command-line mode. As &lt;code&gt;:autocmd&lt;/code&gt; already takes an Ex command, it's superfluous.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;== 0&lt;/code&gt; is superfluous as well. &lt;code&gt;'readonly'&lt;/code&gt; is a boolean flag that evaluates to &lt;code&gt;0&lt;/code&gt; if unset, and &lt;code&gt;0&lt;/code&gt; evaluates to &lt;em&gt;false&lt;/em&gt; in a conditional.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-07T14:43:48.047" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17862" PostTypeId="2" ParentId="17851" CreationDate="2018-11-07T18:21:18.627" Score="0" Body="&lt;p&gt;Suggestion by @ChristianBrabandt didn't exactly work. I had to modify it slightly to the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cursorline&#xA;augroup CustomCursorLine&#xA;    au!    &#xA;    au ColorScheme * :hi clear CursorLine&#xA;    au ColorScheme * :hi! CursorLine gui=underline cterm=underline&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I will still accept his answer since this is what led to a solution.&lt;/p&gt;&#xA;" OwnerUserId="2865" LastActivityDate="2018-11-07T18:21:18.627" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17864" PostTypeId="1" AcceptedAnswerId="17870" CreationDate="2018-11-08T05:24:19.120" Score="4" ViewCount="94" Body="&lt;p&gt;The marks in &lt;code&gt;vim&lt;/code&gt; knows the deletion and insertion of lines before it and their positions will keep updated. Is there a way to achieve these pragmatically? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running an async task which is supposed to update the &lt;strong&gt;current line&lt;/strong&gt; when the task finishes. Here the &lt;strong&gt;current line&lt;/strong&gt; means the cursor line at the time the task is launched. After launching it, I may need to move the cursor around; make modifications to the buffer. How can I get the correct position when the task finishes &lt;strong&gt;without using a mark&lt;/strong&gt;? If marks are used, they may be accidentally reset by user or by other third party plugins.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;example&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Given the text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1&#xA;line2&#xA;fix me please&#xA;line4&#xA;line5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assume my cursor is now at line 3, I am going to run &lt;code&gt;:Fixme&lt;/code&gt; which is to replace &lt;code&gt;fix me please&lt;/code&gt; with &lt;code&gt;line3&lt;/code&gt; but at a much later time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If during this waiting period, I delete &lt;code&gt;line1&lt;/code&gt; or inserte more lines before line 3, I hope &lt;code&gt;:Fixme&lt;/code&gt; is aware of this change and still updates the line &lt;code&gt;fix me please&lt;/code&gt;. How to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-11-08T06:51:24.277" LastActivityDate="2018-11-08T08:08:39.163" Title="track deletion and insertion of lines" Tags="|buffers|cursor|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="17866" PostTypeId="1" AcceptedAnswerId="17871" CreationDate="2018-11-08T06:32:48.480" Score="11" ViewCount="3322" Body="&lt;p&gt;Consider a script local function in a &lt;code&gt;plugin/myplugin.vim&lt;/code&gt; file. For example &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;myplugin.vim:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! s:someFunction()&#xA;    return 4&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to unit test this function. &#xA;In the simplest example I would like to execute something like the following in ANOTHER script. Without modifying the original script. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;test_myplugin.vim:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if s:someFunction() != 4&#xA;    throw &quot;Error&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This obviously does not work because &lt;code&gt;s:someFunction&lt;/code&gt; is not visible from outside of the &lt;code&gt;myplugin.vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to unit test these script local functions? &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some options that come to mind:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Move the function to be unit tested to &lt;code&gt;autoload&lt;/code&gt; directory and rename it &lt;code&gt;myplugin#someFunction()&lt;/code&gt;. Inspiration is from &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#write-library-script&quot; rel=&quot;noreferrer&quot;&gt;:help write-library-script&lt;/a&gt;.  I do not prefer this approach. The function(s) are not reused they are not supposed to be a library. I also do not own the &lt;code&gt;plugin/myplugin.vim&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Apparently &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_41.html#using-%3CPlug%3E&quot; rel=&quot;noreferrer&quot;&gt;vim prepends&lt;/a&gt; a &lt;code&gt;&amp;lt;SNR&amp;gt;123_&lt;/code&gt; like string to script-local-functions. (&lt;code&gt;123&lt;/code&gt; can be any number). I could get the list of all functions with the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#:function&quot; rel=&quot;noreferrer&quot;&gt;:function&lt;/a&gt; command. Then find the full function name that matches &lt;code&gt;&amp;lt;SNR&amp;gt;\d+_someFunction&lt;/code&gt; and call that function by name. Looking at this &lt;a href=&quot;https://vi.stackexchange.com/q/4717/13792&quot;&gt;question&lt;/a&gt; it looks like calling functions is possible once you know their string name. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone is interested in an implementation of the hacky approach in @IngoKarkat's &lt;a href=&quot;https://vi.stackexchange.com/a/17871/13792&quot;&gt;answer&lt;/a&gt;, you can take a look at my take on it &lt;a href=&quot;https://github.com/ruanyl/vim-gh-line/pull/20/files#diff-96a3cf1912494e1f40b17b83bb33d74bR87&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13792" LastEditorUserId="13792" LastEditDate="2018-11-11T07:05:31.847" LastActivityDate="2018-11-11T07:05:31.847" Title="Are script local functions (s:funcName()) unit testable?" Tags="|vimscript|functions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17867" PostTypeId="2" ParentId="17866" CreationDate="2018-11-08T07:25:19.757" Score="4" Body="&lt;p&gt;I think there are two different possibilities to achieve what you want.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You can create a global &lt;code&gt;funcref&lt;/code&gt; to your script local function and then call that funcref. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:MyCustomFuncref=funcref(&quot;&amp;lt;sid&amp;gt;MyScriptLocalFunction&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;(Note, a funcref variable must start with a capital letter).&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Parse the script number inside your s:Function and make it available so other functions can call it, even when not defined inside your script-local file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  :fu! &amp;lt;sid&amp;gt;GetSID() &quot;{{{1&#xA;       return matchstr(expand('&amp;lt;sfile&amp;gt;'), '&amp;lt;SNR&amp;gt;\zs\d\+\ze_GetSID$')&#xA;  endfu&#xA;  let g:mysid = &amp;lt;sid&amp;gt;GetSID()&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have done this in my &lt;a href=&quot;https://github.com/chrisbra/changesPlugin/blob/ee473b864481107a61146b976ef443be2bcb0252/autoload/changes.vim#L15-L20&quot; rel=&quot;nofollow noreferrer&quot;&gt;changes Plugin&lt;/a&gt;. You can then dynamically construct the function name and call it. That is because script-local functions are not really script-local, they are just namespaced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my &lt;a href=&quot;https://github.com/chrisbra/csv.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;csv plugin&lt;/a&gt; I used to set the &lt;code&gt;foldexpr&lt;/code&gt; to a &lt;a href=&quot;https://github.com/chrisbra/csv.vim/blob/14eb57c0e781daac16608216de11a8443bf0b4e9/ftplugin/csv.vim#L1785&quot; rel=&quot;nofollow noreferrer&quot;&gt;script local function&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now either possibility will possibly create a new global variable which you might want to avoid. What I have been doing in the past is to only allow access to those variable, if the plugin has been run in debug mode. (So set a configuration variable to enable debug mode, after which you have access to those special variable and can dynamically call all needed script-local functions).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-11-08T07:25:19.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17868" PostTypeId="2" ParentId="605" CreationDate="2018-11-08T07:36:36.367" Score="0" Body="&lt;p&gt;Other than generate the &lt;code&gt;cscope.out&lt;/code&gt;, you need to run &lt;code&gt;ctags -L cscope.files&lt;/code&gt; to generate the &lt;code&gt;tags&lt;/code&gt; file. With both of that you can move back and force in the cscope tagstack&lt;/p&gt;&#xA;" OwnerUserId="19650" LastActivityDate="2018-11-08T07:36:36.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17870" PostTypeId="2" ParentId="17864" CreationDate="2018-11-08T08:08:39.163" Score="2" Body="&lt;p&gt;Currently, only &lt;em&gt;marks&lt;/em&gt; are automatically adapted to changes in the buffer by Vim. You can record arbitrary positions via &lt;code&gt;getpos()&lt;/code&gt;, but these would have to be adapted to changes on your own (and that is not generally possible if you have no control over the changes that are done).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plugins usually &quot;reserve&quot; some marks for their use, either by documenting it (&lt;em&gt;&quot;this mapping uses mark z&quot;&lt;/em&gt;), or by taking unused marks (cp. &lt;a href=&quot;https://github.com/inkarkat/vim-ingo-library/blob/3307d27ffd15d906355cefcb48f1304ef4fb1379/autoload/ingo/plugin/marks.vim#L82&quot; rel=&quot;nofollow noreferrer&quot;&gt;ingo#plugin#marks#Reserve()&lt;/a&gt; in my &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4433&quot; rel=&quot;nofollow noreferrer&quot;&gt;ingo-library plugin&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It indeed would be great if there were a low-level function to use &quot;unnamed marks&quot; for plugins, similar to the distinction between &lt;code&gt;:match&lt;/code&gt; (user) and &lt;code&gt;matchadd()&lt;/code&gt; (plugins). You can raise this idea in &lt;a href=&quot;https://github.com/vim/vim/issues/3573&quot; rel=&quot;nofollow noreferrer&quot;&gt;this poll&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-08T08:08:39.163" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17871" PostTypeId="2" ParentId="17866" CreationDate="2018-11-08T08:35:56.737" Score="8" Body="&lt;p&gt;&lt;strong&gt;TL;DR: Yes, but you probably shouldn't (in general)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Other answers&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Christian's answer offers two approaches that modify &lt;code&gt;myplugin.vim&lt;/code&gt; in order to expose the script-local function (either as a Funcref or just the SID that allows you to obtain a Funcref).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having to extend a plugin just for testing purposes is not nice, and as I understand, you're reluctant to change &lt;code&gt;myplugin.vim&lt;/code&gt;, too.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The hacky way&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;What I have done occasionally for testing is parsing the output of &lt;code&gt;:scriptnames&lt;/code&gt;, matching &lt;code&gt;plugin/myplugin.vim&lt;/code&gt; in order to obtain the SID. With this, you can build a Funcref and invoke any script-local function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let sid = ... &quot; Parse :scriptnames output&#xA;:let MyFuncref = function(&quot;&amp;lt;SNR&amp;gt;&quot; . sid . &quot;_someFunction&quot;)&#xA;:echo call(MyFuncref, [])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;The purist's answer&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Script-local functions are equivalent to &lt;em&gt;private methods&lt;/em&gt; in other languages (e.g. Java). There, there are similar discussions about lifting access restrictions (e.g. to &lt;code&gt;protected&lt;/code&gt;) for unit testing, and many people think that this is a bad idea, that unit tests should only rely on the object's public API, and that testing private implementation details leads to brittle tests and impedes refactoring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, my first impulse would be to expose the function as an &lt;em&gt;autoload function&lt;/em&gt;. (In fact, I almost never put functions in the plugin script; everything is (script-local or public) in an autoload script.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't agree with your apprehension of turning these into &quot;library functions&quot;. Most Vim plugins don't expose a Vimscript API at all (just mappings and custom commands). Even if you have a public API, you can still differentiate between official public functions and autoload functions exposed for unit testing via other means:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Only have API documentation for the official functions, or mention the intended &quot;visibility&quot; (public / private) in the attached function documentation.&lt;/li&gt;&#xA;&lt;li&gt;Segregate into different autoload scripts, e.g. &lt;code&gt;autoload/myplugin.vim&lt;/code&gt; for the public API and &lt;code&gt;autoload/myplugin/impl.vim&lt;/code&gt; for the functions to be unit-tested.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2018-11-08T08:45:52.480" LastActivityDate="2018-11-08T08:45:52.480" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17872" PostTypeId="1" CreationDate="2018-11-08T08:53:24.670" Score="3" ViewCount="2779" Body="&lt;p&gt;I'm trying to setup ALE with clang but apparently clang has no idea about my source files - it cannot find included files for a start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I tell ALE/clang were are all my sources?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you already use ALE with clang(or other C/C++ related) it would be helpful to see other setups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="2710" LastActivityDate="2018-11-08T08:53:24.670" Title="How to setup ALE with clang?" Tags="|filetype-c++|plugin-ale|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17873" PostTypeId="2" ParentId="17737" CreationDate="2018-11-08T12:15:37.253" Score="4" Body="&lt;pre&gt;&lt;code&gt;nmap  ± &amp;lt;esc&amp;gt;:set incsearch&amp;lt;CR&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; in &lt;em&gt;normal mode&lt;/em&gt; issues a beep. Your &lt;code&gt;:nmap&lt;/code&gt; is a normal mode mapping; no &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; is necessary here. You could use &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; to swallow any accidental &lt;code&gt;[count]&lt;/code&gt;, though. And &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/05.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;you should use &lt;code&gt;:noremap&lt;/code&gt;&lt;/a&gt;; it makes the mapping immune to remapping and recursion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap  ± :&amp;lt;C-u&amp;gt;set incsearch&amp;lt;CR&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Though not needed here, there is a special mapping that ensures normal mode without a beep: &lt;a href=&quot;https://vimhelp.appspot.com/intro.txt.html#CTRL-%5C_CTRL-N&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help CTRL-\_CTRL-N&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Additionally the command CTRL-\ CTRL-N or  can be used to go to&#xA;  Normal mode from any other mode.  This can be used to make sure Vim is in&#xA;  Normal mode, without causing a beep like  would.  However, this does not&#xA;  work in Ex mode.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="970" LastEditorUserId="9267" LastEditDate="2019-06-04T01:55:41.237" LastActivityDate="2019-06-04T01:55:41.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17874" PostTypeId="2" ParentId="17720" CreationDate="2018-11-08T12:52:59.140" Score="2" Body="&lt;p&gt;Best way is to avoid the output of these &lt;a href=&quot;https://en.wikipedia.org/wiki/ANSI_escape_code&quot; rel=&quot;nofollow noreferrer&quot;&gt;ANSI escape codes&lt;/a&gt;. Some commands to this automatically when the output is not to a terminal, others have a command-line argument, e.g. &lt;code&gt;--no-color&lt;/code&gt; or &lt;code&gt;--color=never&lt;/code&gt; (even moderately outdated Git versions understand this). Some also react to the terminal type, so prepending &lt;code&gt;TERM=dumb git ...&lt;/code&gt; might work, too (it does for me).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can strip off the codes, e.g. with &lt;code&gt;sed&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git ... | sed 's#\x1b\[[0-9;]*[mK]##g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can do the same inside Vim, too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%substitute#\e\[[0-9;]*[mK]##g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, there are plugins which translate (but not remove) the ANSI escape codes to Vim colors (via syntax highlighting and concealing of the sequences):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=302&quot; rel=&quot;nofollow noreferrer&quot;&gt;AnsiEsc&lt;/a&gt; via &lt;code&gt;:AnsiEsc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/chrisbra/Colorizer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Colorizer&lt;/a&gt; via &lt;code&gt;:ColorToggle&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-08T12:52:59.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17875" PostTypeId="1" AcceptedAnswerId="17876" CreationDate="2018-11-08T15:17:24.187" Score="6" ViewCount="1445" Body="&lt;p&gt;I have a vim script function &lt;code&gt;MyFunction&lt;/code&gt; that returns a string value. I want to display this output in the statusline and so I have set the statusline as follows &lt;code&gt;statusline +=\ %{MyFunction()}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want this function to be called periodically (say every second) and display the updated value in the statusline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, If I'm in the window and move the cursor around, the statusline is updated but when the cursor is not moving or if the window is inactive, it just stays at one value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I update it periodically?&lt;/p&gt;&#xA;" OwnerUserId="5481" LastActivityDate="2018-11-08T16:50:08.873" Title="How to update the statusline continuously even if the window becomes inactive" Tags="|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17876" PostTypeId="2" ParentId="17875" CreationDate="2018-11-08T16:50:08.873" Score="3" Body="&lt;p&gt;There is an easy way to trigger re-evaluating your statusline. Simply reset the option value. E.g.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:let &amp;amp;stl=&amp;amp;stl&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which basically means to set the statusline option to the current value. It should force a redraw then. You could plug this even into a timer, so e.g. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :call timer_start(1000, {-&amp;gt; execute(':let &amp;amp;stl=&amp;amp;stl')}, {'repeat': -1})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets up a timer that triggers every second and will re-evaluate your statusline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, that redraws are sometimes not desired (because they might overwrite a status message or remove the intro screen). So I wouldn't not recommend this to do in general unless you know what you are doing.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-11-08T16:50:08.873" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17877" PostTypeId="1" AcceptedAnswerId="17882" CreationDate="2018-11-08T20:33:48.910" Score="0" ViewCount="102" Body="&lt;p&gt;I'd like to prepend the line below the current line to the current line. In other words, I want to &quot;join&quot; (like with &lt;code&gt;J&lt;/code&gt; in normal mode) but instead of putting the line below the current line at the end of the current line, I'd like to put it at the front of the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;▋lorem ipsum amet dolor&lt;br&gt;&#xA;  blue green orange yellow&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;▋blue green orange yellow lorem ipsum amet dolor    &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;with the position of the cursor--shown by the solid, black rectangle--at the beginning of the prepended snippet or at its end.&lt;/p&gt;&#xA;" OwnerUserId="14480" LastActivityDate="2018-11-09T05:25:12.610" Title="Prepend line underneath current line (or &quot;join&quot; to front of line)" Tags="|join|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17878" PostTypeId="2" ParentId="17877" CreationDate="2018-11-08T21:12:17.960" Score="3" Body="&lt;p&gt;Just swap the lines before you join them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ddpkJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, if you would like to override &lt;code&gt;J&lt;/code&gt;'s behavior, you could map this with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap J ddpkJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or if you want a new mapping so that you have both options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;J ddpkJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-11-08T21:12:17.960" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17879" PostTypeId="1" AcceptedAnswerId="17880" CreationDate="2018-11-08T22:28:03.387" Score="5" ViewCount="323" Body="&lt;p&gt;I wanted to delete every 2 lines and then skip one, so I tried recording a macro. I did &lt;code&gt;q1&lt;/code&gt; then &lt;code&gt;d2dj&lt;/code&gt; to delete 2 lines and go one down, then &lt;code&gt;q&lt;/code&gt; and &lt;code&gt;@1&lt;/code&gt; to execute it. The first time it worked well. However the next time I type &lt;code&gt;@1&lt;/code&gt; weird stuff happens. I go down a lot of lines and get into insert mode, instead of doing the same. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does this happen? How should I have typed it?&lt;/p&gt;&#xA;" OwnerUserId="19742" LastEditorUserId="2920" LastEditDate="2018-11-08T22:36:03.823" LastActivityDate="2022-11-02T17:07:08.997" Title="Weird behaviour when repeating macro" Tags="|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17880" PostTypeId="2" ParentId="17879" CreationDate="2018-11-08T22:46:41.737" Score="10" Body="&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; if you're going to make a macro, choose a letter to record to instead of any symbol.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;This is very odd behavior, but it &lt;em&gt;does&lt;/em&gt; make sense. To understand why, first we need to back up a little bit and explain how registers and macros really work.&lt;/p&gt;&#xA;&lt;p&gt;Try this.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;qqiHello World&amp;lt;esc&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and then&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;qp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This second command tells vim to paste &lt;em&gt;from register 'q'&lt;/em&gt;, rather than from the default register. You should see&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;iHello World^[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;in your buffer. This is because when you run &lt;code&gt;q&amp;lt;reg&amp;gt;&amp;lt;commands&amp;gt;q&lt;/code&gt;, you're not really recording keystrokes for later use, but you are sending those keystrokes to a particular buffer name, in this case 'q', in your case '1'. The &lt;code&gt;@&lt;/code&gt; command will run whatever is in a particular register. Try this too:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;iYp&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and then delete that line with &lt;code&gt;dd&lt;/code&gt;. Now, that really deleted the text to the unnamed register, so we can run it as if it was a macro with &lt;code&gt;@&amp;quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So on to your example. Set up everything exactly the same. Do the same steps. But when you get to&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;However the next time I type &lt;code&gt;@1&lt;/code&gt; weird stuff happens.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Instead of typing &lt;code&gt;@1&lt;/code&gt;, run the &lt;code&gt;:reg&lt;/code&gt; command. This will tell you the contents of every register. Note the contents of &lt;code&gt;&amp;quot;1&lt;/code&gt;. That should have the last two lines you deleted. When you run &lt;code&gt;@1&lt;/code&gt; the second time, it's like you typed out each character from those lines, which explains why you get weird stuff. From &lt;code&gt;:h &amp;quot;1&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;2. Numbered registers &amp;quot;0 to &amp;quot;9      *quote_number* *quote0* *quote1*&#xA;                    *quote2* *quote3* *quote4* *quote9*&#xA;Vim fills these registers with text from yank and delete commands.&#xA;   Numbered register 0 contains the text from the most recent yank command,&#xA;unless the command specified another register with [&amp;quot;x].&#xA;   Numbered register 1 contains the text deleted by the most recent delete or&#xA;change command, unless the command specified another register or the text is&#xA;less than one line (the small delete register is used then).  An exception is&#xA;made for the delete operator with these movement commands: |%|, |(|, |)|, |`|,&#xA;|/|, |?|, |n|, |N|, |{| and |}|.  Register &amp;quot;1 is always used then (this is Vi&#xA;compatible).  The &amp;quot;- register is used as well if the delete is within a line.&#xA;Note that these characters may be mapped.  E.g. |%| is mapped by the matchit&#xA;plugin.&#xA;   With each successive deletion or change, Vim shifts the previous contents&#xA;of register 1 into register 2, 2 into 3, and so forth, losing the previous&#xA;contents of register 9.&#xA;{Vi: numbered register contents are lost when changing files; register 0 does&#xA;not exist}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2022-11-02T17:07:08.997" LastActivityDate="2022-11-02T17:07:08.997" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17882" PostTypeId="2" ParentId="17877" CreationDate="2018-11-09T05:25:12.610" Score="4" Body="&lt;p&gt;If you don't want to use any register, you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:+m- | normal J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or use mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;J :&amp;lt;c-u&amp;gt;+m-&amp;lt;cr&amp;gt;J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:+m-&lt;/code&gt; is to move the next line to be after the previous line, so eventually the order of the two lines are exchanged.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-11-09T05:25:12.610" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17884" PostTypeId="2" ParentId="17703" CreationDate="2018-11-09T05:48:22.590" Score="0" Body="&lt;p&gt;You can use &lt;code&gt;map &amp;lt;buffer&amp;gt; &amp;lt;nowait&amp;gt;&lt;/code&gt; to stop receiving more keys and execute the map immediately. Note &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; only has effect when defined for buffer-local maps. See &lt;code&gt;:h map-nowait&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap ff :echo 'ff'&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;buffer&amp;gt; &amp;lt;nowait&amp;gt; f +&#xA;set timeout&#xA;set timeoutlen=3000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can feel the difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To run &lt;code&gt;ff&lt;/code&gt;, you need to use &lt;code&gt;:normal ff&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-11-22T02:24:34.123" LastActivityDate="2018-11-22T02:24:34.123" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17887" PostTypeId="1" CreationDate="2018-11-09T10:32:42.103" Score="1" ViewCount="622" Body="&lt;p&gt;I there a way to remap &lt;code&gt;/&lt;/code&gt; that trigger builtin search function of vim to another search &lt;code&gt;fuzzy&lt;/code&gt; function and how to achieve that?&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2020-01-03T18:00:50.173" Title="Remap / to a another search function?" Tags="|key-bindings|search|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17888" PostTypeId="1" AcceptedAnswerId="17925" CreationDate="2018-11-09T11:29:37.067" Score="1" ViewCount="2180" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Z2qGK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Z2qGK.png&quot; alt=&quot;Screenshot of my Vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see in my case, I can barely see my cursor when it is on an error highlighted by You Complete Me as an error. How do I make my cursor more visible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My GTK+ theme is Numix, I use Gnome and this is the Gnome Terminal in XTerm colors, if that helps.&lt;/p&gt;&#xA;" OwnerUserId="19752" LastEditorUserId="1841" LastEditDate="2018-11-09T13:16:41.467" LastActivityDate="2018-11-18T14:56:44.683" Title="Solve cursor invisible on some highlights" Tags="|colorscheme|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17889" PostTypeId="1" AcceptedAnswerId="17932" CreationDate="2018-11-09T14:34:35.743" Score="0" ViewCount="168" Body="&lt;p&gt;I got this regexp from google which is for matching specific glyphs in vim-nerdtree.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType nerdtree syntax match {hl-group} /\v{glyph}/ containedin=ALL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But obviously it won't work on custom statusline/tabline. What events should I use for it to work?&lt;/p&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-11-12T10:57:30.137" Title="How to use a regexp to search/match specific pattern only for the custom statusline and/or tabline?" Tags="|vimscript|regular-expression|autocmd|statusline|syntax|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17890" PostTypeId="2" ParentId="17887" CreationDate="2018-11-09T15:24:25.417" Score="1" Body="&lt;p&gt;I use plugin that expose &lt;code&gt;FuzzySearch&lt;/code&gt; to call its function, we overwrite builtin search function of vim that triggered by press &lt;code&gt;/&lt;/code&gt; by this remap: &lt;code&gt;nnoremap / :FuzzySearch&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap&lt;/code&gt;: Only apply in normal mode, no remap allowed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;: Because this function need to be called before accept the next argument that is a search string, so we don't have to explicitly press enter.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2018-11-09T15:24:25.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17891" PostTypeId="1" CreationDate="2018-11-09T15:49:36.333" Score="0" ViewCount="1802" Body="&lt;p&gt;Is there any ways to change the font color and background of the working directory as seen in Sublime text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sublime Text&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rRLEj.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neovim with NERDTree&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/5ZaIc.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="19753" LastActivityDate="2018-12-09T17:00:50.153" Title="Change working directory color in NERDTree" Tags="|neovim|highlight|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17892" PostTypeId="2" ParentId="17891" CreationDate="2018-11-09T16:09:06.657" Score="1" Body="&lt;p&gt;From their &lt;a href=&quot;https://github.com/scrooloose/nerdtree/issues/858&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue #858&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The colors are not configurable NERDTree settings. [...] Try using a different colorscheme. If you don't like any of the default colorschemes, you can always download others as additional plugins.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you might not be able to do what you want.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt; Actually the directories has the highlighting group &lt;code&gt;NERDTreeCWD&lt;/code&gt; so you could try to change the value of this group. For example something like this might work (I didn't test it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight NERDTreeCWD ctermfg=white&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-11-09T16:18:23.513" LastActivityDate="2018-11-09T16:18:23.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17893" PostTypeId="2" ParentId="1922" CreationDate="2018-11-09T16:12:36.590" Score="25" Body="&lt;p&gt;There’s &lt;code&gt;\%V&lt;/code&gt; for that, see &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#/%5C%25V&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h %V&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;h3&gt;%V&lt;/h3&gt;&#xA;&lt;p&gt;Match inside the Visual area.  When Visual mode has already been&#xA;stopped match in the area that gv would reselect.   This is a&#xA;/zero-width match.  &lt;strong&gt;To make sure the whole pattern is   inside the&#xA;Visual area put it at the start and end of the pattern&lt;/strong&gt;,     e.g.: &amp;gt;&#xA;/%Vfoo.*bar%V&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;To replace &lt;code&gt;foo&lt;/code&gt; by &lt;code&gt;bar&lt;/code&gt; in the selection only, use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%Vfoo\%V/bar/&#xA;:'&amp;lt;,'&amp;gt;s/\%Vfoo\%V/bar/g&#xA;:'&amp;lt;,'&amp;gt;s/\%Vfoo\%V/bar/cg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In this particular case:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V\ \%V/\,0x/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15871" LastEditorUserId="15871" LastEditDate="2021-03-19T07:28:42.587" LastActivityDate="2021-03-19T07:28:42.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17896" PostTypeId="1" CreationDate="2018-11-09T18:48:09.397" Score="3" ViewCount="779" Body="&lt;p&gt;When I'm browsing folders in &lt;a href=&quot;https://github.com/Yggdroot/LeaderF&quot; rel=&quot;nofollow noreferrer&quot;&gt;LeaderF&lt;/a&gt; is there a way to move to the parent folder?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Background: I'm building a vim (Neovim) profile and looking at file/buffer explorers, and LeaderF seems useful. (I've used CtrlP previously and liked it; I can't make heads or tails of denite.) It makes sense that LeaderF starts in the same directory as the current file (I have &lt;code&gt;set autochdir&lt;/code&gt;): this is usually what I want. However it seems to me that in many cases I would want to broaden the scope of my search by moving to the parent folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I expected that LeaderF would provide a binding for this and the fact that the functionality doesn't exist makes me think that I'm using it wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do others typically use LeaderF?&lt;/p&gt;&#xA;" OwnerUserId="14777" LastEditorUserId="1452" LastEditDate="2018-11-10T10:38:18.023" LastActivityDate="2020-08-03T15:02:35.213" Title="How to move to parent directory with LeaderF?" Tags="|vimrc|neovim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17897" PostTypeId="1" AcceptedAnswerId="17907" CreationDate="2018-11-09T19:55:46.383" Score="0" ViewCount="85" Body="&lt;p&gt;Somehow my cursor jumps to the right in some filetypes (html, vue, json, maybe others...) when I switch lines with j or k&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dRAjv.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dRAjv.gif&quot; alt=&quot;Jumpy cursor...&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .vimrc is kinda messy atm...but I've seen worse... :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Basics {{{&#xA;syntax on&#xA;&#xA;let mapleader = &quot;,&quot;&#xA;&#xA;set shell=/bin/bash&#xA;set nocompatible&#xA;set t_Co=256&#xA;set noswapfile&#xA;set nobackup&#xA;set encoding=utf-8&#xA;set backspace=indent,eol,start&#xA;set hidden&#xA;set laststatus=2&#xA;set relativenumber&#xA;set number&#xA;set switchbuf=usetab,newtab&#xA;set helplang=de&#xA;set ffs=unix,dos&#xA;set autoindent&#xA;set ttyfast&#xA;set wildmenu&#xA;set noshowmode&#xA;set showcmd&#xA;set cmdheight=1&#xA;set updatetime=100&#xA;set modeline&#xA;set modelines=1&#xA;set foldmethod=indent&#xA;set foldlevel=0&#xA;set foldnestmax=1&#xA;set foldminlines=100&#xA;set conceallevel=0&#xA;set concealcursor=&#xA;set tabstop=2&#xA;set softtabstop=2&#xA;set noexpandtab&#xA;&quot; }}}&#xA;&quot; Mappings {{{&#xA;&quot;========================= [MAPPINGS] =========================&#xA;&#xA;map &amp;lt;silent&amp;gt; &amp;lt;F2&amp;gt; :call fzf#run({'source': 'rg --files --column --no-heading --hidden --follow --glob &quot;!.git/*&quot;', 'sink': 'e', 'down': '~30%'})&amp;lt;cr&amp;gt;&#xA;let g:fzf_colors =&#xA;\ {&#xA;\ 'fg': ['fg', 'Normal'],&#xA;\ 'bg': ['bg', 'Normal']&#xA;\}&#xA;map &amp;lt;silent&amp;gt; &amp;lt;F3&amp;gt; :NERDTreeToggle&amp;lt;cr&amp;gt;&#xA;no &amp;lt;Leader&amp;gt;ws :ToggleWorkspace&amp;lt;cr&amp;gt;&#xA;no &amp;lt;Leader&amp;gt;bw :bwipeout&amp;lt;cr&amp;gt;&#xA;no &amp;lt;Space&amp;gt; za&#xA;no &amp;lt;Leader&amp;gt;we &amp;lt;C-W&amp;gt;=&#xA;ino &amp;lt;C-e&amp;gt; &amp;lt;C-o&amp;gt;$&#xA;ino &amp;lt;C-q&amp;gt; &amp;lt;C-o&amp;gt;0&#xA;&quot; ino kj &amp;lt;Esc&amp;gt;&#xA;&quot; ino jk &amp;lt;Esc&amp;gt;&#xA;&quot; }}}&#xA;&#xA;&quot; Plugins {{{&#xA;&quot; Vundle Setup {{{&#xA;set runtimepath=$HOME/vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/vimfiles/after,$HOME/.vim/bundle/Vundle.vim,$HOME/.vim/bundle/,$HOME/.vim/&#xA;filetype off&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&quot; }}}&#xA;Plugin 'tpope/vim-fugitive'&#xA;&#xA;Plugin 'scrooloose/nerdtree.git'&#xA;Plugin 'ryanoasis/vim-devicons'&#xA;Plugin 'Xuyuanp/nerdtree-git-plugin'&#xA;&#xA;Plugin 'flazz/vim-colorschemes'&#xA;colorscheme donbass&#xA;set background=light&#xA;&#xA;Plugin 'benmills/vimux'&#xA;Plugin 'jtdowney/vimux-cargo'&#xA;&#xA;Plugin 'tpope/vim-commentary.git'&#xA;Plugin 'tpope/vim-surround.git'&#xA;Plugin 'jiangmiao/auto-pairs.git'&#xA;&#xA;Plugin 'thaerkh/vim-workspace'&#xA;Plugin 'tpope/vim-obsession'&#xA;&#xA;Plugin 'rust-lang/rust.vim'&#xA;Plugin 'racer-rust/vim-racer'&#xA;&#xA;Plugin 'w0rp/ale'&#xA;&#xA;Plugin 'mattn/emmet-vim'&#xA;&#xA;Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}&#xA;&#xA;Plugin 'ap/vim-css-color'&#xA;&#xA;Plugin 'junegunn/fzf'&#xA;&#xA;&quot;============================================================&#xA;&#xA;Plugin 'junegunn/goyo.vim'&#xA;Plugin 'godlygeek/tabular'&#xA;Plugin 'plasticboy/vim-markdown'&#xA;let g:markdown_folding=1&#xA;&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&#xA;&quot; ==================== [YouCompleteMe] =====================&#xA;Plugin 'Valloric/YouCompleteMe'&#xA;&quot; ==================== [Airline] =========================&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;let g:airline_theme = 'solarized'&#xA;let g:airline_powerline_fonts = 1&#xA;let g:airline#extensions#tabline#enabled = 1&#xA;let g:airline#extensions#tabline#fnamemod = ':t'&#xA;&#xA;let g:airline#enable#fugitive = 1&#xA;let g:airline#enable#bufferline = 1&#xA;let g:airline#enable#syntastic = 1&#xA;&#xA;let g:airline#extensions#tabline#buffer_idx_mode = 1&#xA;nmap &amp;lt;leader&amp;gt;1 &amp;lt;Plug&amp;gt;AirlineSelectTab1&#xA;nmap &amp;lt;leader&amp;gt;2 &amp;lt;Plug&amp;gt;AirlineSelectTab2&#xA;nmap &amp;lt;leader&amp;gt;3 &amp;lt;Plug&amp;gt;AirlineSelectTab3&#xA;nmap &amp;lt;leader&amp;gt;4 &amp;lt;Plug&amp;gt;AirlineSelectTab4&#xA;nmap &amp;lt;leader&amp;gt;5 &amp;lt;Plug&amp;gt;AirlineSelectTab5&#xA;nmap &amp;lt;leader&amp;gt;6 &amp;lt;Plug&amp;gt;AirlineSelectTab6&#xA;nmap &amp;lt;leader&amp;gt;7 &amp;lt;Plug&amp;gt;AirlineSelectTab7&#xA;nmap &amp;lt;leader&amp;gt;8 &amp;lt;Plug&amp;gt;AirlineSelectTab8&#xA;nmap &amp;lt;leader&amp;gt;9 &amp;lt;Plug&amp;gt;AirlineSelectTab9&#xA;nmap &amp;lt;leader&amp;gt;n &amp;lt;Plug&amp;gt;AirlineSelectPrevTab&#xA;nmap &amp;lt;leader&amp;gt;m &amp;lt;Plug&amp;gt;AirlineSelectNextTab&#xA;&#xA;Plugin 'jeetsukumaran/vim-buffergator'&#xA;&quot;================== [vim-vue] ===================&#xA;Plugin 'posva/vim-vue'&#xA;let g:vue_disable_pre_processor = 0&#xA;&#xA;&quot;================== [GitGutter] =================&#xA;Plugin 'airblade/vim-gitgutter'&#xA;let g:gitgutter_grep='grep'&#xA;&#xA;&quot;================== [UltiSnips] =================&#xA;&quot; Track the engine.&#xA;Plugin 'SirVer/ultisnips'&#xA;&#xA;&quot; Snippets are separated from the engine. Add this if you want them:&#xA;Plugin 'honza/vim-snippets'&#xA;&#xA;&quot; Trigger configuration. Do not use &amp;lt;tab&amp;gt; if you use&#xA;&quot; https://github.com/Valloric/YouCompleteMe.&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;s-tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;c-b&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-z&amp;gt;&quot;&#xA;&#xA;&quot; If you want :UltiSnipsEdit to split your window.&#xA;let g:UltiSnipsEditSplit=&quot;vertical&quot;&#xA;&#xA;&quot;================== [Syntastic] =================&#xA;Plugin 'vim-syntastic/syntastic'&#xA;&#xA;&quot; }}}&#xA;&quot; AutoCMDs {{{&#xA;&quot; ========================================================&#xA;&quot; ===== AUTOCMDs&#xA;&quot; ========================================================&#xA;autocmd FileType c,cpp,java,php,vimrc,vue,javascript,js  autocmd BufWritePre &amp;lt;buffer&amp;gt; %s/\s\+$//e&#xA;autocmd FileType vue setl sw=2 sts=2 ts=2  expandtab&#xA;autocmd FileType javascript,js setl sw=2 sts=2 ts=2 noexpandtab&#xA;autocmd FileType json set sw=2 sts=2 ts=2 noexpandtab&#xA;autocmd FileType md setl sw=2 sts=2 ts=2 noexpandtab&#xA;autocmd BufNewFile,BufRead *.vue setf vue&#xA;&quot; }}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Really hoping for a solution, I guess it's a plugin but I've disabled most of them one by one, still the same &quot;error&quot;.... So I'm out of ideas really. &lt;/p&gt;&#xA;" OwnerUserId="19334" LastEditorUserId="19334" LastEditDate="2018-11-09T21:00:04.073" LastActivityDate="2018-11-10T10:05:40.060" Title="Cursor jumps 1 or 2 columns to the right after line up / down ( j / k )" Tags="|cursor|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17898" PostTypeId="1" AcceptedAnswerId="17899" CreationDate="2018-11-09T20:11:08.283" Score="7" ViewCount="3803" Body="&lt;p&gt;I am trying to do some window management in VIM where I create certain windows such as two or three vertical splits with different sizes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment, I only know how to change panes with &lt;code&gt;&amp;lt;C-w&amp;gt;h/j/k/l&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How am I meant to tell my &lt;code&gt;~/.vimrc&lt;/code&gt; to automatically go to the pane to the right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried &lt;code&gt;autocmd VimEnter * &amp;lt;C-w&amp;gt;l&lt;/code&gt; but that does not do anything.&lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="10604" LastEditDate="2018-11-12T08:39:40.327" LastActivityDate="2018-11-12T08:39:40.327" Title="How do I execute normal commands from an autocmd?" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17899" PostTypeId="2" ParentId="17898" CreationDate="2018-11-09T21:12:44.060" Score="6" Body="&lt;p&gt;If you want to run commands as if you had typed keys automatically when you start vim, you'll need to use the &lt;code&gt;normal&lt;/code&gt; command (to run a &lt;em&gt;normal mode&lt;/em&gt; command).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm[al][!] {commands}                 *:norm* *:normal*&#xA;            Execute Normal mode commands {commands}.  This makes&#xA;            it possible to execute Normal mode commands typed on&#xA;            the command-line.  {commands} are executed like they&#xA;            are typed.  For undo all commands are undone together.&#xA;            Execution stops when an error is encountered.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you'd need &lt;code&gt;autocmd VimEnter * normal &amp;lt;C-w&amp;gt;l&lt;/code&gt;. &lt;strong&gt;However&lt;/strong&gt;, vim is really dumb about the &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; family of commands. &lt;a href=&quot;https://vi.stackexchange.com/questions/14457/tabbing-between-files/14458#14458&quot;&gt;For example this answer&lt;/a&gt; of mine. I still don't know why this happens, I just know it's a quirk of vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thankfully, there's an easy way around this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[count]winc[md] {arg}&#xA;        Like executing CTRL-W [count] {arg}.  Example: &amp;gt;&#xA;            :wincmd j&#xA;&amp;lt;       Moves to the window below the current one.&#xA;        This command is useful when a Normal mode cannot be used (for&#xA;        the |CursorHold| autocommand event).  Or when a Normal mode&#xA;        command is inconvenient.&#xA;        The count can also be a window number.  Example: &amp;gt;&#xA;            :exe nr . &quot;wincmd w&quot;&#xA;&amp;lt;       This goes to window &quot;nr&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you should be able to do what you want with &lt;code&gt;autocmd VimEnter * wincmd l&lt;/code&gt;. Although this might not do very much, since typically there would only be one split open when you open up vim for the first time.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2018-11-09T21:19:25.433" LastActivityDate="2018-11-09T21:19:25.433" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17900" PostTypeId="1" AcceptedAnswerId="17943" CreationDate="2018-11-10T01:22:33.740" Score="2" ViewCount="277" Body="&lt;p&gt;When I insert a &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Zero-width_non-joiner&quot; rel=&quot;nofollow noreferrer&quot;&gt;ZWNJ&lt;/a&gt; character into text, vim displays &lt;code&gt;&amp;lt;200c&amp;gt;&lt;/code&gt; instead of it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to make vim to behave normally with this character, like GUI editors? Or is it possible to hide (and not remove) this character in vim's display?&lt;/p&gt;&#xA;" OwnerUserId="19391" LastEditorUserId="1841" LastEditDate="2018-11-12T08:51:52.950" LastActivityDate="2018-11-13T07:37:02.587" Title="How to make vim display ZWNJ characters correctly?" Tags="|formatting|font|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17901" PostTypeId="1" CreationDate="2018-11-10T02:03:35.297" Score="3" ViewCount="1427" Body="&lt;p&gt;When quitting the terminal it always shows the &lt;code&gt;[Process exited 2]&lt;/code&gt;, how can I disable it so that when I quit the terminal buffer should just close silently?&lt;/p&gt;&#xA;" OwnerUserId="18514" LastEditorUserId="51" LastEditorDisplayName="user5791" LastEditDate="2019-05-25T04:09:59.197" LastActivityDate="2020-02-19T06:01:40.203" Title="How to make Neovim to not show the &quot;[Process exited {num}]&quot; when quitting a term?" Tags="|neovim|terminal-buffer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17902" PostTypeId="1" CreationDate="2018-11-10T03:11:46.237" Score="0" ViewCount="297" Body="&lt;p&gt;I often see vim function with function definition written like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction(...)&#xA;&quot; function body...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does the &lt;code&gt;...&lt;/code&gt; do within the function?&lt;/p&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-11-16T21:39:15.047" Title="What does it mean by `...` parameters in a function?" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17903" PostTypeId="1" AcceptedAnswerId="18003" CreationDate="2018-11-10T04:33:54.640" Score="0" ViewCount="1003" Body="&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&#xA;I've managed to get the top part of the file fixed with &lt;code&gt;syn region pugJavascriptLine start=/^\s*-/ end=/$/ contains=@htmlJavascript&lt;/code&gt; from this programmer: &lt;a href=&quot;https://github.com/digitaltoad/vim-pug/issues/98#issuecomment-296461439&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/digitaltoad/vim-pug/issues/98#issuecomment-296461439&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the template strings still don't recognize their contents as JavaScript:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FFQmX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FFQmX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps there's another line I could add to the pug syntax file that would let it know how template strings work. The file is here: &lt;a href=&quot;https://github.com/digitaltoad/vim-pug/blob/master/syntax/pug.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/digitaltoad/vim-pug/blob/master/syntax/pug.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone with better Regex skills than me out there?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update end&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using neovim for lots of web dev, and I'm having trouble with pug syntax highlighting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't seem to get it to display JavaScript in the pug files (which it was doing just fine before I switched to a new Thinkpad).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/L3Fh1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/L3Fh1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The JS is just in plain white text. Here's my vimrc: &lt;a href=&quot;https://gist.github.com/wamoyo/34405c4672c89dbfded62ea34134003b&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gist.github.com/wamoyo/34405c4672c89dbfded62ea34134003b&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I haven't edited the pug.vim file or anything like that. But I have messed around a bit with the xoria256.vim colorscheme file, adding this to the bottom:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; hi jsBooleanTrue ctermfg=41&#xA;&quot; hi jsBooleanFalse ctermfg=174&#xA;&quot; hi jsString ctermfg=229&#xA;&quot; hi jsComment ctermfg=244&#xA;hi jsGlobalObjects ctermfg=256&#xA;hi jsGlobalNodeObjects ctermfg=256&#xA;&quot; hi jsExceptions ctermfg=256&#xA;&quot; hi jsThis ctermfg=256&#xA;&quot; hi jsPrototype ctermfg=256&#xA;&quot; hi jsHtmlEvents ctermfg=256&#xA;&quot; hi jsDecorator ctermfg=146&#xA;&quot; hi jsSpecial ctermfg=180&#xA;&quot; hi jsFloat ctermfg=180&#xA;&quot; hi jsNan ctermfg=180&#xA;&quot; hi jsTemplateVar ctermfg=251&#xA;&quot; hi jsTemplateBraces ctermfg=146&#xA;&quot; hi jsDecoratorFunction ctermfg=182&#xA;&quot; hi jsRegexpString ctermfg=180&#xA;&quot; hi jsRegexpBoundary ctermfg=180&#xA;&quot; hi jsRegexpQuantifier ctermfg=180&#xA;&quot; hi jsRegexpOr ctermfg=180&#xA;&quot; hi jsRegexpMod ctermfg=180&#xA;&quot; hi jsRegexpBackRef ctermfg=180&#xA;&quot; hi jsRegexpGroup ctermfg=180&#xA;&quot; hi jsRegexpCharClass ctermfg=180&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the old laptop, I didn't have any of those commented out, but the new laptop seems to support more colors in the gnome terminal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This line from &lt;code&gt;pug.vim&lt;/code&gt; seems relevant:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region pugJavascript matchgroup=pugJavascriptChar start=&quot;-&quot; skip=&quot;,\s*$&quot; end=&quot;$&quot; contained contains=@htmlJavascript keepend&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Lines 6-16 above are using the syntax group &lt;code&gt;pugTagInlineText&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, I know it's not those edits in the xoria256.vim file, because I have the same issue with other colorschemes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also happy to switch colorschemes if there's one that handles html5, css, and ES6 really nicely.&lt;/p&gt;&#xA;" OwnerUserId="1596" LastEditorUserId="1596" LastEditDate="2018-11-17T21:41:11.497" LastActivityDate="2018-11-17T21:52:33.123" Title="Fixing pug syntax highlighting" Tags="|syntax-highlighting|colorscheme|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="17904" PostTypeId="1" AcceptedAnswerId="17908" CreationDate="2018-11-10T07:18:00.547" Score="1" ViewCount="502" Body="&lt;p&gt;I am quite new to Vim and am trying to configure gVim with some of the behaviour that I like from notepad++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I disabled text wrapping with &lt;code&gt;:set nowrap&lt;/code&gt;, then added the horizontal scrollbar with &lt;code&gt;:set guioptions+=b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I scroll horizontally to the right, scrolling vertically then forces the horizontal scrollbar all the way back to the left. I would like the horizontal position to stay fixed while I scroll vertically. Is there some way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get the same behaviour under both linux (CentOS 6) and Windows 7 (64-bit).&lt;/p&gt;&#xA;" OwnerUserId="19761" LastActivityDate="2018-11-10T12:35:50.287" Title="gVim: How to prevent horizonal scrollbar from resetting when scrolling vertically?" Tags="|gvim|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17905" PostTypeId="1" CreationDate="2018-11-10T09:02:51.577" Score="4" ViewCount="729" Body="&lt;p&gt;If I have a diff file open in vim (not vimdiff), is there a way to jump to the line under the cursor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Detect the hunk of text under the cursor.&lt;/li&gt;&#xA;&lt;li&gt;Open a buffer for the file containing the hunk&lt;br&gt;&lt;em&gt;(perhaps an existing buffer if one is already open, although this is a detail).&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move to the line which was under the cursor.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this in vim?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've seen this in other software.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;QtCreator supports this by double-clicking on the line of the diff.&lt;/li&gt;&#xA;&lt;li&gt;Emacs diff viewer has &lt;code&gt;diff-goto-source&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="301" LastEditorUserId="301" LastEditDate="2018-11-10T09:10:44.980" LastActivityDate="2018-11-10T13:04:09.157" Title="How to jump to the line of a diff?" Tags="|vimdiff|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17906" PostTypeId="2" ParentId="17902" CreationDate="2018-11-10T09:07:52.360" Score="5" Body="&lt;h3&gt;Explanation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;It means variadic arguments (see &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#...&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ...&lt;/code&gt;&lt;/a&gt;). To get all the extra arguments as a list, you use &lt;code&gt;a:000&lt;/code&gt;. To get the i-th extra arguments use &lt;code&gt;a:i&lt;/code&gt; where &lt;code&gt;i&lt;/code&gt; is the integer (equivalent to &lt;code&gt;a:000[i-1]&lt;/code&gt;). &lt;code&gt;a:0&lt;/code&gt; represents the number of extra arguments &lt;code&gt;a:0 == len(a:000)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;To check whether an extra argument is supplied you do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if a:0&#xA;    let arg1 = a:1  &quot; let a:000[0]&#xA;else&#xA;    let arg1 = arg1_default&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More conveniently, the previous snippet is equivalent to (Note that the second parameter is &lt;code&gt;0&lt;/code&gt; to denote the first element in the list &lt;code&gt;a:000&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let arg1 = get(a:000, 0, arg1_default)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Forward the variadic parameters&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Some times you may need to forward the variadic parameters to another function using the same order. For example, if &lt;code&gt;MyFunc&lt;/code&gt; should call &lt;code&gt;s:MyFuncImpl&lt;/code&gt; with all the variadic parameters passed, you can do the following in &lt;code&gt;MyFunc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call call('s:MyFuncImpl', a:000)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the first call is the command &lt;code&gt;call&lt;/code&gt;, see &lt;code&gt;:h :call&lt;/code&gt;, the second call is a function, see &lt;code&gt;:h call()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Handle a large amount of extra arguments&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Personally, if the potential number of extra arguments is large or when I anticipate to have more and more extra arguments to the function when the plugin evolves, I will use a single &lt;code&gt;dict&lt;/code&gt; to represent the extra arguments. So I use the following pattern&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunc(x, y, ...)&#xA;    let opts   = get(a:000, 0, {})&#xA;    let method = get(opts, 'method', 'default')&#xA;    let buf    = get(opts, 'buf', buf('%'))&#xA;    &quot; other statements&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, the function &lt;code&gt;get&lt;/code&gt; can deal with both &lt;code&gt;list&lt;/code&gt; and &lt;code&gt;dict&lt;/code&gt;. Now, you call it using &lt;code&gt;call MyFunc(x, y, {'method': 'best'})&lt;/code&gt; if &lt;code&gt;method&lt;/code&gt; is different from the default and &lt;code&gt;buf&lt;/code&gt; should use the default. This makes the function more adaptable and more readable.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="11477" LastEditDate="2018-11-16T21:39:15.047" LastActivityDate="2018-11-16T21:39:15.047" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17907" PostTypeId="2" ParentId="17897" CreationDate="2018-11-10T10:05:40.060" Score="1" Body="&lt;p&gt;Okay, so &lt;em&gt;in my case&lt;/em&gt; disabling &lt;code&gt;thaerkh/vim-workspace&lt;/code&gt; solved the issue. If it's the fault of the plugin or a combination of plugins and settings, I don't know. I might investigate that further at a later point and post my findings here. I really love that plugin, it's like vim-obsession, but fully automated...so yeah...disabling it is somewhat annoying. :/&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also: &lt;a href=&quot;https://github.com/thaerkh/vim-workspace/issues/9&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/thaerkh/vim-workspace/issues/9&lt;/a&gt; (&gt;_&amp;lt;)&lt;/p&gt;&#xA;" OwnerUserId="19334" LastActivityDate="2018-11-10T10:05:40.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17908" PostTypeId="2" ParentId="17904" CreationDate="2018-11-10T12:01:40.073" Score="3" Body="&lt;p&gt;By default the cursor is always on a column that contains real text. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 2 3 4 5 6 7 8 9&#xA;1 2 3 4 5&#xA;1 2 3 4 5 6 7 8 9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your cursor is in line 1 on the character '9' and you move down, the cursor &quot;jumps&quot; to the character '5' in the second line. If you move down again, it jumps to the '9' in the third line. Because of this change of the cursor column, the horizontal scrollbar changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the cursor always on the column of the character '9' (even when there is no text), you have to do &lt;code&gt;set virtualedit=all&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help virtualedit&lt;/code&gt; and read the entire section. It contains a warning that this setting might break plugins or Vim scripts.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2018-11-10T12:35:50.287" LastActivityDate="2018-11-10T12:35:50.287" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17909" PostTypeId="2" ParentId="17905" CreationDate="2018-11-10T13:04:09.157" Score="3" Body="&lt;p&gt;I'm a little surprised that &lt;code&gt;gf&lt;/code&gt; doesn't already support this, but it doesn't. There's a plugin that does, though: &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=3892&quot; rel=&quot;nofollow noreferrer&quot;&gt;gf-diff&lt;/a&gt; (&lt;a href=&quot;https://github.com/kana/vim-gf-diff&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub mirror&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Someone also wrote a &lt;a href=&quot;https://whileimautomaton.net/2011/03/02212116&quot; rel=&quot;nofollow noreferrer&quot;&gt;blog post&lt;/a&gt; with a more ad-hoc solution, reproduced below. Credit to the blog author, Kana Natsuno.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; git-diff-aware version of gf commands.&#xA;nnoremap &amp;lt;expr&amp;gt; gf  &amp;lt;SID&amp;gt;do_git_diff_aware_gf('gf')&#xA;nnoremap &amp;lt;expr&amp;gt; gF  &amp;lt;SID&amp;gt;do_git_diff_aware_gf('gF')&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-w&amp;gt;f  &amp;lt;SID&amp;gt;do_git_diff_aware_gf('&amp;lt;C-w&amp;gt;f')&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-w&amp;gt;&amp;lt;C-f&amp;gt;  &amp;lt;SID&amp;gt;do_git_diff_aware_gf('&amp;lt;C-w&amp;gt;&amp;lt;C-f&amp;gt;')&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-w&amp;gt;F  &amp;lt;SID&amp;gt;do_git_diff_aware_gf('&amp;lt;C-w&amp;gt;F')&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-w&amp;gt;gf  &amp;lt;SID&amp;gt;do_git_diff_aware_gf('&amp;lt;C-w&amp;gt;gf')&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-w&amp;gt;gF  &amp;lt;SID&amp;gt;do_git_diff_aware_gf('&amp;lt;C-w&amp;gt;gF')&#xA;&#xA;function! s:do_git_diff_aware_gf(command)&#xA;  let target_path = expand('&amp;lt;cfile&amp;gt;')&#xA;  if target_path =~# '^[ab]/'  &quot; with a peculiar prefix of git-diff(1)?&#xA;    if filereadable(target_path) || isdirectory(target_path)&#xA;      return a:command&#xA;    else&#xA;      &quot; BUGS: Side effect - Cursor position is changed.&#xA;      let [_, c] = searchpos('\f\+', 'cenW')&#xA;      return c . '|' . 'v' . (len(target_path) - 2 - 1) . 'h' . a:command&#xA;    endif&#xA;  else&#xA;    return a:command&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8233" LastActivityDate="2018-11-10T13:04:09.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17910" PostTypeId="2" ParentId="16998" CreationDate="2018-11-10T15:39:33.077" Score="3" Body="&lt;p&gt;As a follow-up: an actual answer is to use a &lt;strong&gt;snippet plugin&lt;/strong&gt;, such as &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt;. Snippet plugins are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;already done;&lt;/li&gt;&#xA;&lt;li&gt;designed precisely for that kind of things;&lt;/li&gt;&#xA;&lt;li&gt;much easier to set up (just write templates as plain text in some config file);&lt;/li&gt;&#xA;&lt;li&gt;much more comfortable to use (you can have several holes, placeholders and so on);&lt;/li&gt;&#xA;&lt;li&gt;much more powerful (you can run arbitrary Python scripts);&lt;/li&gt;&#xA;&lt;li&gt;fast (UltiSnips is, at least).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Crafting a square wheel was a waste of time. ;-)&lt;/p&gt;&#xA;" OwnerUserId="18470" LastActivityDate="2018-11-10T15:39:33.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17911" PostTypeId="1" CreationDate="2018-11-10T16:55:12.173" Score="2" ViewCount="484" Body="&lt;p&gt;I'm trying to build a vimscript can be used with the Dvorak Simplified Layout. I.e., given that the keys on the keyboard plugged into the computer are laid out in the Dovark Simplified Layout (and the system's keyboard settings are set accordingly), I want to write a vimscript that will make vim use the Dvorak layout only in Insert mode: in all other modes, the keyboard layout will be QWERTY.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Keys between the 0 and the backspace&#xA;noremap [ -&#xA;noremap { _&#xA;noremap ] =&#xA;noremap } +&#xA;&#xA;&quot;Keys from the tab till the end of the row&#xA;noremap ' q&#xA;noremap &quot; Q&#xA;noremap , w&#xA;noremap &amp;lt; W&#xA;noremap . e&#xA;noremap &amp;gt; E&#xA;noremap p r&#xA;noremap P R&#xA;noremap y t&#xA;noremap Y T&#xA;noremap f y&#xA;noremap F Y&#xA;noremap g u&#xA;noremap G U&#xA;noremap c i&#xA;noremap C I&#xA;noremap r o&#xA;noremap R O&#xA;noremap l p&#xA;noremap L P&#xA;noremap / [&#xA;noremap ? {&#xA;noremap = ]&#xA;noremap + }&#xA;&#xA;&quot;Home row keys&#xA;noremap o s&#xA;noremap O S&#xA;noremap e d&#xA;noremap E D&#xA;noremap u f&#xA;noremap U F&#xA;noremap i g&#xA;noremap I G&#xA;noremap d h&#xA;noremap D H&#xA;noremap h j&#xA;noremap H J&#xA;noremap t k&#xA;noremap T K&#xA;noremap n l&#xA;noremap N L&#xA;noremap s ;&#xA;noremap S :&#xA;noremap - ,&#xA;noremap _ &quot;&#xA;&#xA;&quot;Keys for the row below the home row&#xA;noremap ; z&#xA;noremap : Z&#xA;noremap q x&#xA;noremap Q X&#xA;noremap j c&#xA;noremap J C&#xA;noremap k v&#xA;noremap K V&#xA;noremap x b&#xA;noremap X B&#xA;noremap b n&#xA;noremap B N&#xA;noremap w ,&#xA;noremap W &amp;lt;&#xA;noremap v .&#xA;noremap v &amp;gt;&#xA;noremap z /&#xA;noremap Z ?&#xA;&#xA;&quot;Same as above but now for the console&#xA;&#xA;&quot;Keys between the 0 and the backspace&#xA;cnoremap [ -&#xA;cnoremap { _&#xA;cnoremap ] =&#xA;cnoremap } +&#xA;&#xA;&quot;Keys from the tab till the end of the row&#xA;cnoremap ' q&#xA;cnoremap &quot; Q&#xA;cnoremap , w&#xA;cnoremap &amp;lt; W&#xA;cnoremap . e&#xA;cnoremap &amp;gt; E&#xA;cnoremap p r&#xA;cnoremap P R&#xA;cnoremap y t&#xA;cnoremap Y T&#xA;cnoremap f y&#xA;cnoremap F Y&#xA;cnoremap g u&#xA;cnoremap G U&#xA;cnoremap c i&#xA;cnoremap C I&#xA;cnoremap r o&#xA;cnoremap R O&#xA;cnoremap l p&#xA;cnoremap L P&#xA;cnoremap / [&#xA;cnoremap ? {&#xA;cnoremap = ]&#xA;cnoremap + }&#xA;&#xA;&quot;Home row keys&#xA;cnoremap o s&#xA;cnoremap O S&#xA;cnoremap e d&#xA;cnoremap E D&#xA;cnoremap u f&#xA;cnoremap U F&#xA;cnoremap i g&#xA;cnoremap I G&#xA;cnoremap d h&#xA;cnoremap D H&#xA;cnoremap h j&#xA;cnoremap H J&#xA;cnoremap t k&#xA;cnoremap T K&#xA;cnoremap n l&#xA;cnoremap N L&#xA;cnoremap s ;&#xA;cnoremap S :&#xA;cnoremap - ,&#xA;cnoremap _ &quot;&#xA;&#xA;&quot;Keys for the row below the home row&#xA;cnoremap ; z&#xA;cnoremap : Z&#xA;cnoremap q x&#xA;cnoremap Q X&#xA;cnoremap j c&#xA;cnoremap J C&#xA;cnoremap k v&#xA;cnoremap K V&#xA;cnoremap x b&#xA;cnoremap X B&#xA;cnoremap b n&#xA;cnoremap B N&#xA;cnoremap w ,&#xA;cnoremap W &amp;lt;&#xA;cnoremap v .&#xA;cnoremap v &amp;gt;&#xA;cnoremap z /&#xA;cnoremap Z ?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But for some reason, pressing &quot;ii&quot; on the physical keyboard, which ought to jump to the beginning of the document (since in both Normal mode and Operator-Pending modes the &quot;i&quot; key maps to a &quot;g&quot;), vim goes into Insert mode. However, pressing &quot;ig&quot; on the physical keyboard does jump to the beginning of the document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem persists whether on Linux or on Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why are the operating-pending mode maps not working? Vim help says that &quot;noremap&quot; remaps all modes except Insert, Console, Terminal-Job, and Lang-Arg.&lt;/p&gt;&#xA;" OwnerUserId="19768" LastActivityDate="2019-08-04T13:37:04.327" Title="Operator pending mode remaps not working" Tags="|key-bindings|vimscript|map-operator|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17912" PostTypeId="1" AcceptedAnswerId="17914" CreationDate="2018-11-10T21:37:17.157" Score="1" ViewCount="436" Body="&lt;p&gt;I am trying to create my own C++ environment inside of VIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, this is my setup when I run &lt;code&gt;$ vim ~/shape.cpp&lt;/code&gt;: for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sQvHs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sQvHs.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, only NERDTree has full syntax highlighting (which isn't too important) and the .cpp only has limited header colours (should be different) and none on the hpp file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get syntax to work on my c++ file with this setup?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do not create the header window, syntax highlighting does work as shown below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n4Y4M.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n4Y4M.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the following information may help as it may affect configuration.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This machine is running macOS&lt;/li&gt;&#xA;&lt;li&gt;Tmux is used to create the bottom window&lt;/li&gt;&#xA;&lt;li&gt;The top section is one pane and three vim vertical splits&lt;/li&gt;&#xA;&lt;li&gt;I am using &lt;a href=&quot;https://github.com/vim-scripts/a.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;a.vim&lt;/a&gt; to create the .hpp split&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The vimrc does the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Creates the NERDTree window&lt;/li&gt;&#xA;&lt;li&gt;Goes to the second pane (NERDTree is the first window)&lt;/li&gt;&#xA;&lt;li&gt;Executes a.vim command :AV which creates a &lt;code&gt;vertical splits and switches&lt;/code&gt;. This opens .hpp in the second window and .cpp in third&lt;/li&gt;&#xA;&lt;li&gt;Resizes window one (cpp) to 50 width&lt;/li&gt;&#xA;&lt;li&gt;Swaps hpp and cpp around so the order is now NERDTree, cpp, hpp&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Finally, here is my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}&#xA;Plugin 'dart-lang/dart-vim-plugin'&#xA;&#xA;Plugin 'MarcWeber/vim-addon-mw-utils'&#xA;Plugin 'tomtom/tlib_vim'&#xA;Plugin 'garbas/vim-snipmate'&#xA;Plugin 'vim-scripts/a.vim'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'altercation/vim-colors-solarized'&#xA;&#xA;&quot;Optional:&#xA;Plugin 'honza/vim-snippets'&#xA;&#xA;call vundle#end()            &quot; required&#xA;syntax on&#xA;filetype plugin indent on    &quot; required&#xA;filetype on&#xA;let g:solarized_termcolors = 256&#xA;colorscheme solarized&#xA;&#xA;set number&#xA;&#xA;set tabstop=2&#xA;set shiftwidth=2&#xA;set expandtab&#xA;&#xA;autocmd FileType python setlocal noexpandtab shiftwidth=2 softtabstop=2&#xA;&#xA;set background=dark&#xA;&#xA;let mapleader = &quot;:&quot;&#xA;&#xA;&quot;Map keys to create new window&#xA;nmap nvw &amp;lt;c-w&amp;gt;v&#xA;nmap nhw &amp;lt;c-w&amp;gt;s&#xA;&#xA;&quot;Mak keys to change window&#xA;nmap + &amp;lt;C-w&amp;gt;&amp;lt;Up&amp;gt;&#xA;nmap = &amp;lt;C-w&amp;gt;&amp;lt;Down&amp;gt;&#xA;nmap _ &amp;lt;C-w&amp;gt;&amp;lt;Left&amp;gt;&#xA;nmap - &amp;lt;C-w&amp;gt;&amp;lt;Right&amp;gt;&#xA;&#xA;&quot;Map key to Open NERDTree&#xA;map &amp;lt;leader&amp;gt;fs :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;Close VIM if NERDTree is final window&#xA;autocmd BufEnter * if (winnr(&quot;$&quot;) == 1 &amp;amp;&amp;amp; exists(&quot;b:NERDTree&quot;) &amp;amp;&amp;amp; b:NERDTree.isTabTree()) | q | endif&#xA;&#xA;&quot;Run NERDTree automaticly on VIM start&#xA;autocmd VimEnter * NERDTree&#xA;autocmd VimEnter * wincmd l&#xA;autocmd VimEnter * normal &amp;lt;C-w&amp;gt;l&#xA;autocmd FileType cpp :AV&#xA;autocmd FileType cpp 50 wincmd |&#xA;autocmd FileType cpp wincmd x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;Output of &lt;code&gt;:syntax&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Syntax items ---&#xA;confTodo       xxx contained XXX FIXME TODO&#xA;                   links to Todo&#xA;confComment    xxx match /^#.*/  contains=confTodo&#xA;                   match /\s#.*/ms=s+1  contains=confTodo&#xA;                   links to Comment&#xA;confString     xxx start=/&quot;/ skip=/\\\\\|\\&quot;/ end=/&quot;/  oneline&#xA;                   start=/'/ skip=/\\\\\|\\'/ end=/'/  oneline&#xA;                   links to String&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And of &lt;code&gt;:highlight&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SpecialKey     xxx term=bold cterm=bold ctermfg=240 ctermbg=235 guifg=Cyan&#xA;EndOfBuffer    xxx links to NonText&#xA;NonText        xxx term=bold cterm=bold ctermfg=240 gui=bold guifg=Blue&#xA;Directory      xxx ctermfg=33 guifg=Cyan&#xA;ErrorMsg       xxx term=reverse cterm=reverse ctermfg=124 guifg=White guibg=Red&#xA;IncSearch      xxx term=standout cterm=standout ctermfg=166 gui=reverse&#xA;Search         xxx term=reverse cterm=reverse ctermfg=136 guifg=Black guibg=Yellow&#xA;MoreMsg        xxx ctermfg=33 gui=bold guifg=SeaGreen&#xA;ModeMsg        xxx ctermfg=33 gui=bold&#xA;LineNr         xxx ctermfg=239 ctermbg=235 guifg=Yellow&#xA;CursorLineNr   xxx term=bold ctermfg=11 gui=bold guifg=Yellow&#xA;Question       xxx term=bold cterm=bold ctermfg=37 gui=bold guifg=Green&#xA;StatusLine     xxx term=reverse cterm=reverse ctermfg=245 ctermbg=235 gui=bold,reverse&#xA;StatusLineNC   xxx term=reverse cterm=reverse ctermfg=240 ctermbg=235 gui=reverse&#xA;VertSplit      xxx ctermfg=240 ctermbg=240 gui=reverse&#xA;Title          xxx term=bold cterm=bold ctermfg=166 gui=bold guifg=Magenta&#xA;Visual         xxx term=reverse cterm=reverse ctermfg=239 ctermbg=234 guibg=DarkGrey&#xA;VisualNOS      xxx term=reverse cterm=reverse ctermbg=235&#xA;WarningMsg     xxx term=bold cterm=bold ctermfg=124 guifg=Red&#xA;WildMenu       xxx term=reverse cterm=reverse ctermfg=187 ctermbg=235 guifg=Black guibg=Yellow&#xA;Folded         xxx term=bold,underline cterm=bold,underline ctermfg=244 ctermbg=235 guifg=Cyan guibg=DarkGrey&#xA;FoldColumn     xxx ctermfg=244 ctermbg=235 guifg=Cyan guibg=Grey&#xA;DiffAdd        xxx ctermfg=64 ctermbg=235 guibg=DarkBlue&#xA;DiffChange     xxx ctermfg=136 ctermbg=235 guibg=DarkMagenta&#xA;DiffDelete     xxx ctermfg=124 ctermbg=235 gui=bold guifg=Blue guibg=DarkCyan&#xA;DiffText       xxx ctermfg=33 ctermbg=235 gui=bold guibg=Red&#xA;SignColumn     xxx ctermfg=244 ctermbg=242 guifg=Cyan guibg=Grey&#xA;Conceal        xxx ctermfg=33&#xA;SpellBad       xxx term=undercurl cterm=undercurl gui=undercurl guisp=Red&#xA;SpellCap       xxx term=undercurl cterm=undercurl gui=undercurl guisp=Blue&#xA;SpellRare      xxx term=undercurl cterm=undercurl gui=undercurl guisp=Magenta&#xA;SpellLocal     xxx term=undercurl cterm=undercurl gui=undercurl guisp=Cyan&#xA;Pmenu          xxx term=reverse cterm=reverse ctermfg=244 ctermbg=235 guibg=Magenta&#xA;PmenuSel       xxx term=reverse cterm=reverse ctermfg=239 ctermbg=187 guibg=DarkGrey&#xA;PmenuSbar      xxx term=reverse cterm=reverse ctermfg=187 ctermbg=244 guibg=Grey&#xA;PmenuThumb     xxx term=reverse cterm=reverse ctermfg=244 ctermbg=234 guibg=White&#xA;TabLine        xxx term=underline cterm=underline ctermfg=244 ctermbg=235 gui=underline guibg=DarkGrey&#xA;TabLineSel     xxx term=underline,reverse cterm=underline,reverse ctermfg=239 ctermbg=187 gui=bold&#xA;TabLineFill    xxx term=underline cterm=underline ctermfg=244 ctermbg=235 gui=reverse&#xA;CursorColumn   xxx ctermbg=235 guibg=Grey40&#xA;CursorLine     xxx ctermbg=235 guibg=Grey40&#xA;ColorColumn    xxx ctermbg=235 guibg=DarkRed&#xA;QuickFixLine   xxx links to Search&#xA;StatusLineTerm xxx cleared&#xA;StatusLineTermNC xxx cleared&#xA;MatchParen     xxx term=bold cterm=bold ctermfg=124 ctermbg=239 guibg=DarkCyan&#xA;ToolbarLine    xxx term=underline ctermbg=242 guibg=Grey50&#xA;ToolbarButton  xxx cterm=bold ctermfg=0 ctermbg=7 gui=bold guifg=Black guibg=LightGrey&#xA;Error          xxx term=bold cterm=bold ctermfg=124 guifg=White guibg=Red&#xA;Comment        xxx ctermfg=239 guifg=#80a0ff&#xA;Constant       xxx ctermfg=37 guifg=#ffa0a0&#xA;Special        xxx ctermfg=124 guifg=Orange&#xA;Identifier     xxx ctermfg=33 guifg=#40ffff&#xA;Statement      xxx ctermfg=64 gui=bold guifg=#ffff60&#xA;PreProc        xxx ctermfg=166 guifg=#ff80ff&#xA;Type           xxx ctermfg=136 gui=bold guifg=#60ff60&#xA;Underlined     xxx ctermfg=61 gui=underline guifg=#80a0ff&#xA;Ignore         xxx guifg=bg&#xA;Todo           xxx term=bold cterm=bold ctermfg=125 guifg=Blue guibg=Yellow&#xA;String         xxx links to Constant&#xA;Character      xxx links to Constant&#xA;Number         xxx links to Constant&#xA;Boolean        xxx links to Constant&#xA;Float          xxx links to Number&#xA;Function       xxx links to Identifier&#xA;Conditional    xxx links to Statement&#xA;Repeat         xxx links to Statement&#xA;Label          xxx links to Statement&#xA;Operator       xxx links to Statement&#xA;Keyword        xxx links to Statement&#xA;Exception      xxx links to Statement&#xA;Include        xxx links to PreProc&#xA;Define         xxx links to PreProc&#xA;Macro          xxx links to PreProc&#xA;PreCondit      xxx links to PreProc&#xA;StorageClass   xxx links to Type&#xA;Structure      xxx links to Type&#xA;Typedef        xxx links to Type&#xA;Tag            xxx links to Special&#xA;SpecialChar    xxx links to Special&#xA;Delimiter      xxx links to Special&#xA;SpecialComment xxx links to Special&#xA;Debug          xxx links to Special&#xA;Normal         xxx ctermfg=244 ctermbg=234&#xA;Cursor         xxx ctermfg=234 ctermbg=244&#xA;lCursor        xxx links to Cursor&#xA;vimVar         xxx links to Identifier&#xA;vimFunc        xxx links to Function&#xA;vimUserFunc    xxx links to Function&#xA;helpSpecial    xxx links to Special&#xA;vimSet         xxx links to Normal&#xA;vimSetEqual    xxx links to Normal&#xA;vimCommentString xxx ctermfg=61&#xA;vimCommand     xxx ctermfg=136&#xA;vimCmdSep      xxx term=bold cterm=bold ctermfg=33&#xA;helpExample    xxx ctermfg=245&#xA;helpOption     xxx ctermfg=37&#xA;helpNote       xxx ctermfg=125&#xA;helpVim        xxx ctermfg=125&#xA;helpHyperTextJump xxx term=underline cterm=underline ctermfg=33&#xA;helpHyperTextEntry xxx ctermfg=64&#xA;vimIsCommand   xxx ctermfg=240&#xA;vimSynMtchOpt  xxx ctermfg=136&#xA;vimSynType     xxx ctermfg=37&#xA;vimHiLink      xxx ctermfg=33&#xA;vimHiGroup     xxx ctermfg=33&#xA;vimGroup       xxx term=bold,underline cterm=bold,underline ctermfg=33&#xA;diffAdded      xxx links to Statement&#xA;diffLine       xxx links to Identifier&#xA;gitcommitComment xxx ctermfg=239&#xA;gitcommitUntracked xxx links to gitcommitComment&#xA;gitcommitDiscarded xxx links to gitcommitComment&#xA;gitcommitSelected xxx links to gitcommitComment&#xA;gitcommitUnmerged xxx term=bold cterm=bold ctermfg=64&#xA;gitcommitOnBranch xxx term=bold cterm=bold ctermfg=239&#xA;gitcommitBranch xxx term=bold cterm=bold ctermfg=125&#xA;gitcommitNoBranch xxx links to gitcommitBranch&#xA;gitcommitDiscardedType xxx ctermfg=124&#xA;gitcommitSelectedType xxx ctermfg=64&#xA;gitcommitHeader xxx ctermfg=239&#xA;gitcommitUntrackedFile xxx term=bold cterm=bold ctermfg=37&#xA;gitcommitDiscardedFile xxx term=bold cterm=bold ctermfg=124&#xA;gitcommitSelectedFile xxx term=bold cterm=bold ctermfg=64&#xA;gitcommitUnmergedFile xxx term=bold cterm=bold ctermfg=136&#xA;gitcommitFile  xxx term=bold cterm=bold ctermfg=244&#xA;gitcommitDiscardedArrow xxx links to gitcommitDiscardedFile&#xA;gitcommitSelectedArrow xxx links to gitcommitSelectedFile&#xA;gitcommitUnmergedArrow xxx links to gitcommitUnmergedFile&#xA;htmlTag        xxx ctermfg=239&#xA;htmlEndTag     xxx ctermfg=239&#xA;htmlTagN       xxx term=bold cterm=bold ctermfg=245&#xA;htmlTagName    xxx term=bold cterm=bold ctermfg=33&#xA;htmlSpecialTagName xxx ctermfg=33&#xA;htmlArg        xxx ctermfg=240&#xA;javaScript     xxx ctermfg=136&#xA;perlHereDoc    xxx ctermfg=245 ctermbg=234&#xA;perlVarPlain   xxx ctermfg=136 ctermbg=234&#xA;perlStatementFileDesc xxx ctermfg=37 ctermbg=234&#xA;texStatement   xxx ctermfg=37 ctermbg=234&#xA;texMathZoneX   xxx ctermfg=136 ctermbg=234&#xA;texMathMatcher xxx ctermfg=136 ctermbg=234&#xA;texRefLabel    xxx ctermfg=136 ctermbg=234&#xA;rubyDefine     xxx term=bold cterm=bold ctermfg=245 ctermbg=234&#xA;cPreCondit     xxx ctermfg=166&#xA;VarId          xxx ctermfg=33&#xA;ConId          xxx ctermfg=136&#xA;hsImport       xxx ctermfg=125&#xA;hsString       xxx ctermfg=240&#xA;hsStructure    xxx ctermfg=37&#xA;hs_hlFunctionName xxx ctermfg=33&#xA;hsStatement    xxx ctermfg=37&#xA;hsImportLabel  xxx ctermfg=37&#xA;hs_OpFunctionName xxx ctermfg=136&#xA;hs_DeclareFunction xxx ctermfg=166&#xA;hsVarSym       xxx ctermfg=37&#xA;hsType         xxx ctermfg=136&#xA;hsTypedef      xxx ctermfg=37&#xA;hsModuleName   xxx term=underline cterm=underline ctermfg=64&#xA;hsModuleStartLabel xxx ctermfg=125&#xA;                   links to hsStructure&#xA;hsImportParams xxx links to Delimiter&#xA;hsDelimTypeExport xxx links to Delimiter&#xA;hsModuleWhereLabel xxx links to hsModuleStartLabel&#xA;hsNiceOperator xxx ctermfg=37&#xA;pandocTitleBlock xxx ctermfg=33&#xA;pandocTitleBlockTitle xxx term=bold cterm=bold ctermfg=33&#xA;pandocTitleComment xxx term=bold cterm=bold ctermfg=33&#xA;pandocComment  xxx ctermfg=239&#xA;pandocVerbatimBlock xxx ctermfg=136&#xA;pandocVerbatimBlockDeep xxx links to pandocVerbatimBlock&#xA;pandocCodeBlock xxx links to pandocVerbatimBlock&#xA;pandocCodeBlockDelim xxx links to pandocVerbatimBlock&#xA;pandocBlockQuote xxx ctermfg=33&#xA;pandocBlockQuoteLeader1 xxx ctermfg=33&#xA;pandocBlockQuoteLeader2 xxx ctermfg=37&#xA;pandocBlockQuoteLeader3 xxx ctermfg=136&#xA;pandocBlockQuoteLeader4 xxx ctermfg=124&#xA;pandocBlockQuoteLeader5 xxx ctermfg=244&#xA;pandocBlockQuoteLeader6 xxx ctermfg=239&#xA;pandocListMarker xxx ctermfg=125&#xA;pandocListReference xxx term=underline cterm=underline ctermfg=125&#xA;pandocDefinitionBlock xxx ctermfg=61&#xA;pandocDefinitionTerm xxx term=standout cterm=standout ctermfg=61&#xA;pandocDefinitionIndctr xxx term=bold cterm=bold ctermfg=61&#xA;pandocEmphasisDefinition xxx ctermfg=61&#xA;pandocEmphasisNestedDefinition xxx term=bold cterm=bold ctermfg=61&#xA;pandocStrongEmphasisDefinition xxx term=bold cterm=bold ctermfg=61&#xA;pandocStrongEmphasisNestedDefinition xxx term=bold cterm=bold ctermfg=61&#xA;pandocStrongEmphasisEmphasisDefinition xxx term=bold cterm=bold ctermfg=61&#xA;pandocStrikeoutDefinition xxx term=reverse cterm=reverse ctermfg=61&#xA;pandocVerbatimInlineDefinition xxx ctermfg=61&#xA;pandocSuperscriptDefinition xxx ctermfg=61&#xA;pandocSubscriptDefinition xxx ctermfg=61&#xA;pandocTable    xxx ctermfg=33&#xA;pandocTableStructure xxx ctermfg=33&#xA;pandocTableStructureTop xxx links to pandocTableStructre&#xA;pandocTableStructre xxx cleared&#xA;pandocTableStructureEnd xxx links to pandocTableStructre&#xA;pandocTableZebraLight xxx ctermfg=33 ctermbg=234&#xA;pandocTableZebraDark xxx ctermfg=33 ctermbg=235&#xA;pandocEmphasisTable xxx ctermfg=33&#xA;pandocEmphasisNestedTable xxx term=bold cterm=bold ctermfg=33&#xA;pandocStrongEmphasisTable xxx term=bold cterm=bold ctermfg=33&#xA;pandocStrongEmphasisNestedTable xxx term=bold cterm=bold ctermfg=33&#xA;pandocStrongEmphasisEmphasisTable xxx term=bold cterm=bold ctermfg=33&#xA;pandocStrikeoutTable xxx term=reverse cterm=reverse ctermfg=33&#xA;pandocVerbatimInlineTable xxx ctermfg=33&#xA;pandocSuperscriptTable xxx ctermfg=33&#xA;pandocSubscriptTable xxx ctermfg=33&#xA;pandocHeading  xxx term=bold cterm=bold ctermfg=166&#xA;pandocHeadingMarker xxx term=bold cterm=bold ctermfg=136&#xA;pandocEmphasisHeading xxx term=bold cterm=bold ctermfg=166&#xA;pandocEmphasisNestedHeading xxx term=bold cterm=bold ctermfg=166&#xA;pandocStrongEmphasisHeading xxx term=bold cterm=bold ctermfg=166&#xA;pandocStrongEmphasisNestedHeading xxx term=bold cterm=bold ctermfg=166&#xA;pandocStrongEmphasisEmphasisHeading xxx term=bold cterm=bold ctermfg=166&#xA;pandocStrikeoutHeading xxx term=reverse cterm=reverse ctermfg=166&#xA;pandocStrikeoutHeading xxx term=reverse cterm=reverse ctermfg=166&#xA;pandocVerbatimInlineHeading xxx term=bold cterm=bold ctermfg=166&#xA;pandocSuperscriptHeading xxx term=bold cterm=bold ctermfg=166&#xA;pandocSubscriptHeading xxx term=bold cterm=bold ctermfg=166&#xA;pandocLinkDelim xxx ctermfg=239&#xA;pandocLinkLabel xxx term=underline cterm=underline ctermfg=33&#xA;pandocLinkText xxx term=bold,underline cterm=bold,underline ctermfg=33&#xA;pandocLinkURL  xxx term=underline cterm=underline ctermfg=240&#xA;pandocLinkTitle xxx term=underline cterm=underline ctermfg=240&#xA;pandocLinkTitleDelim xxx term=underline cterm=underline ctermfg=239&#xA;pandocLinkDefinition xxx term=underline cterm=underline ctermfg=37&#xA;pandocLinkDefinitionID xxx term=bold cterm=bold ctermfg=33&#xA;pandocImageCaption xxx term=bold,underline cterm=bold,underline ctermfg=61&#xA;pandocFootnoteLink xxx term=underline cterm=underline ctermfg=64&#xA;pandocFootnoteDefLink xxx term=bold cterm=bold ctermfg=64&#xA;pandocFootnoteInline xxx term=bold,underline cterm=bold,underline ctermfg=64&#xA;pandocFootnote xxx ctermfg=64&#xA;pandocCitationDelim xxx ctermfg=125&#xA;pandocCitation xxx ctermfg=125&#xA;pandocCitationID xxx term=underline cterm=underline ctermfg=125&#xA;pandocCitationRef xxx ctermfg=125&#xA;pandocStyleDelim xxx ctermfg=239&#xA;pandocEmphasis xxx ctermfg=244&#xA;pandocEmphasisNested xxx term=bold cterm=bold ctermfg=244&#xA;pandocStrongEmphasis xxx term=bold cterm=bold ctermfg=244&#xA;pandocStrongEmphasisNested xxx term=bold cterm=bold ctermfg=244&#xA;pandocStrongEmphasisEmphasis xxx term=bold cterm=bold ctermfg=244&#xA;pandocStrikeout xxx term=reverse cterm=reverse ctermfg=239&#xA;pandocVerbatimInline xxx ctermfg=136&#xA;pandocSuperscript xxx ctermfg=61&#xA;pandocSubscript xxx ctermfg=61&#xA;pandocRule     xxx term=bold cterm=bold ctermfg=33&#xA;pandocRuleLine xxx term=bold cterm=bold ctermfg=33&#xA;pandocEscapePair xxx term=bold cterm=bold ctermfg=124&#xA;pandocNonBreakingSpace xxx term=reverse cterm=reverse ctermfg=124&#xA;pandocEscapedCharacter xxx links to pandocEscapePair&#xA;pandocLineBreak xxx links to pandocEscapePair&#xA;pandocMetadataDelim xxx ctermfg=239&#xA;pandocMetadata xxx term=bold cterm=bold ctermfg=33&#xA;pandocMetadataKey xxx ctermfg=33&#xA;pandocMetadataTitle xxx links to pandocMetadata&#xA;cStatement     xxx links to Statement&#xA;cLabel         xxx links to Label&#xA;cConditional   xxx links to Conditional&#xA;cRepeat        xxx links to Repeat&#xA;cTodo          xxx links to Todo&#xA;cBadContinuation xxx links to Error&#xA;cSpecial       xxx links to SpecialChar&#xA;cFormat        xxx links to cSpecial&#xA;cString        xxx links to String&#xA;cCppString     xxx links to cString&#xA;cSpaceError    xxx links to cError&#xA;cCppSkip       xxx cleared&#xA;cCharacter     xxx links to Character&#xA;cSpecialError  xxx links to cError&#xA;cSpecialCharacter xxx links to cSpecial&#xA;cBadBlock      xxx cleared&#xA;cCurlyError    xxx links to cError&#xA;cErrInParen    xxx links to cError&#xA;cCppParen      xxx cleared&#xA;cErrInBracket  xxx links to cError&#xA;cCppBracket    xxx cleared&#xA;cBlock         xxx cleared&#xA;cParenError    xxx links to cError&#xA;cIncluded      xxx links to cString&#xA;cCommentSkip   xxx links to cComment&#xA;cCommentString xxx links to cString&#xA;cComment2String xxx links to cString&#xA;cCommentStartError xxx links to cError&#xA;cUserLabel     xxx links to Label&#xA;cBitField      xxx cleared&#xA;cOctalZero     xxx links to PreProc&#xA;cNumber        xxx links to Number&#xA;cFloat         xxx links to Float&#xA;cOctal         xxx links to Number&#xA;cOctalError    xxx links to cError&#xA;cNumbersCom    xxx cleared&#xA;cParen         xxx cleared&#xA;cBracket       xxx cleared&#xA;cNumbers       xxx cleared&#xA;cCommentL      xxx links to cComment&#xA;cCommentStart  xxx links to cComment&#xA;cComment       xxx links to Comment&#xA;cCommentError  xxx links to cError&#xA;cOperator      xxx links to Operator&#xA;cType          xxx links to Type&#xA;cStructure     xxx links to Structure&#xA;cStorageClass  xxx links to StorageClass&#xA;cConstant      xxx links to Constant&#xA;cPreConditMatch xxx links to cPreCondit&#xA;cCppInIf       xxx cleared&#xA;cCppInElse     xxx cleared&#xA;cCppInElse2    xxx links to cCppOutIf2&#xA;cCppOutIf      xxx cleared&#xA;cCppOutIf2     xxx links to cCppOut&#xA;cCppOutElse    xxx cleared&#xA;cCppInSkip     xxx cleared&#xA;cCppOutSkip    xxx links to cCppOutIf2&#xA;cCppOutWrapper xxx links to cPreCondit&#xA;cCppInWrapper  xxx links to cCppOutWrapper&#xA;cPreProc       xxx links to PreProc&#xA;cInclude       xxx links to Include&#xA;cDefine        xxx links to Macro&#xA;cMulti         xxx cleared&#xA;cUserCont      xxx cleared&#xA;cError         xxx links to Error&#xA;cCppOut        xxx links to Comment&#xA;cppStatement   xxx links to Statement&#xA;cppAccess      xxx links to cppStatement&#xA;cppModifier    xxx links to Type&#xA;cppType        xxx links to Type&#xA;cppExceptions  xxx links to Exception&#xA;cppOperator    xxx links to Operator&#xA;cppCast        xxx links to cppStatement&#xA;cppStorageClass xxx links to StorageClass&#xA;cppStructure   xxx links to Structure&#xA;cppBoolean     xxx links to Boolean&#xA;cppConstant    xxx links to Constant&#xA;cppRawStringDelimiter xxx links to Delimiter&#xA;cppRawString   xxx links to String&#xA;cppNumber      xxx links to Number&#xA;cppMinMax      xxx cleared&#xA;confTodo       xxx links to Todo&#xA;confComment    xxx links to Comment&#xA;confString     xxx links to String&#xA;NERDTreeIgnore xxx links to Ignore&#xA;NERDTreeUp     xxx links to Directory&#xA;NERDTreeHelpKey xxx links to Identifier&#xA;NERDTreeHelpTitle xxx links to Macro&#xA;NERDTreeToggleOn xxx links to Question&#xA;NERDTreeToggleOff xxx links to WarningMsg&#xA;NERDTreeHelpCommand xxx links to Identifier&#xA;NERDTreeHelp   xxx links to String&#xA;NERDTreeDir    xxx links to Directory&#xA;NERDTreeFile   xxx links to Normal&#xA;NERDTreeLinkTarget xxx links to Type&#xA;NERDTreeLinkFile xxx links to Macro&#xA;NERDTreeLinkDir xxx links to Macro&#xA;NERDTreeDirSlash xxx links to Identifier&#xA;NERDTreeClosable xxx links to Directory&#xA;NERDTreeOpenable xxx links to Directory&#xA;NERDTreeRO     xxx links to WarningMsg&#xA;NERDTreeBookmark xxx links to Normal&#xA;NERDTreeExecFile xxx links to Title&#xA;NERDTreeLink   xxx cleared&#xA;NERDTreeFlags  xxx links to Number&#xA;And a few others that belong to nerd tree.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="1168" LastEditDate="2018-11-10T22:27:39.517" LastActivityDate="2018-11-11T09:13:41.100" Title="Why do windows not have syntax after split?" Tags="|syntax-highlighting|split|macos|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="17913" PostTypeId="2" ParentId="8406" CreationDate="2018-11-11T01:30:01.177" Score="3" Body="&lt;p&gt;To set your bash terminal title to your short hostname when exiting vim, add this to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;set titleold=&quot;.hostname()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At least on Arch, bash's default is the short hostname, so unless you have something else changing it sometimes, this will emulate restoring it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All credit goes to a google search which found: &lt;a href=&quot;https://gist.github.com/charlesthomas/9915977&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gist.github.com/charlesthomas/9915977&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8071" LastActivityDate="2018-11-11T01:30:01.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17914" PostTypeId="2" ParentId="17912" CreationDate="2018-11-11T09:13:41.100" Score="2" Body="&lt;p&gt;What you are doing here is a little bit &quot;catch-22&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A autocmd is calling &lt;code&gt;:AV&lt;/code&gt; which loads a file. This again triggers auto commands. By default this is disabled. See &lt;code&gt;:help autocmd-nested&lt;/code&gt;.&#xA;You could enable nested autocmd by using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType cpp nested :AV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately this triggers a error in a.vim, which is solvable. But this doesn't help, as the real problem is the cascade of autocmds. As soon as the hpp file is opened it again triggers the autocmd for the FileType cpp. Not what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I played around and found the following workaround (I don't want to call it &quot;solution&quot;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:DoingCppSplit=0&#xA;function CppSplit()&#xA;    if (g:DoingCppSplit == 0)&#xA;        let g:DoingCppSplit = 1&#xA;        AV&#xA;        vertical resize 50&#xA;        wincmd x&#xA;        let g:DoingCppSplit = 0&#xA;    endif&#xA;endfunction&#xA;&#xA;autocmd VimEnter * NERDTree&#xA;autocmd VimEnter * wincmd l&#xA;autocmd FileType cpp nested :call CppSplit()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This just handles your described situation. Play around with it. Maybe it is better to trigger the function on the event &lt;code&gt;BufEnter&lt;/code&gt;. Like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter *.cpp nested :call CppSplit()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2018-11-11T09:13:41.100" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17915" PostTypeId="1" CreationDate="2018-11-11T11:48:47.250" Score="1" ViewCount="611" Body="&lt;p&gt;I am trying to create my own IDE like setup inside of VIM. This is what I have. I am also using Tmux here if you wonder about the bottom terminal screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hpALz.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hpALz.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I change file to another CPP within NERDTree, I get the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8LPje.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8LPje.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How am I meant to close the rightmost window when editing a new file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried a few options however it remove the rightmost window whenever I change window, instead of opening a new file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}&#xA;Plugin 'dart-lang/dart-vim-plugin'&#xA;&#xA;Plugin 'MarcWeber/vim-addon-mw-utils'&#xA;Plugin 'tomtom/tlib_vim'&#xA;Plugin 'garbas/vim-snipmate'&#xA;Plugin 'vim-scripts/a.vim'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'altercation/vim-colors-solarized'&#xA;&#xA;&quot;Optional:&#xA;Plugin 'honza/vim-snippets'&#xA;&#xA;call vundle#end()            &quot; required&#xA;syntax on&#xA;filetype plugin indent on    &quot; required&#xA;filetype on&#xA;let g:solarized_termcolors = 256&#xA;colorscheme solarized&#xA;&#xA;set number&#xA;&#xA;set tabstop=2&#xA;set shiftwidth=2&#xA;set expandtab&#xA;&#xA;autocmd FileType python setlocal noexpandtab shiftwidth=2 softtabstop=2&#xA;&#xA;set background=dark&#xA;&#xA;let mapleader = &quot;:&quot;&#xA;&#xA;&quot;Map keys to create new window&#xA;nmap nvw &amp;lt;c-w&amp;gt;v&#xA;nmap nhw &amp;lt;c-w&amp;gt;s&#xA;&#xA;&quot;Mak keys to change window&#xA;nmap + &amp;lt;C-w&amp;gt;&amp;lt;Up&amp;gt;&#xA;nmap = &amp;lt;C-w&amp;gt;&amp;lt;Down&amp;gt;&#xA;nmap _ &amp;lt;C-w&amp;gt;&amp;lt;Left&amp;gt;&#xA;nmap - &amp;lt;C-w&amp;gt;&amp;lt;Right&amp;gt;&#xA;&#xA;&quot;Map key to Open NERDTree&#xA;map &amp;lt;leader&amp;gt;fs :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;Close VIM if NERDTree is final window&#xA;autocmd BufEnter * if (winnr(&quot;$&quot;) == 1 &amp;amp;&amp;amp; exists(&quot;b:NERDTree&quot;) &amp;amp;&amp;amp; b:NERDTree.isTabTree()) | q | endif&#xA;&#xA;&quot;Run NERDTree automaticly on VIM start&#xA;&#xA;let g:DoingCppSplit=0&#xA;function CppSplit()&#xA;    if (g:DoingCppSplit == 0)&#xA;        let g:DoingCppSplit = 1&#xA;        AV&#xA;        vertical resize 50&#xA;        wincmd x&#xA;        let g:DoingCppSplit = 0&#xA;    endif&#xA;endfunction&#xA;&#xA;autocmd VimEnter * NERDTree&#xA;autocmd VimEnter * wincmd l&#xA;autocmd FileType cpp nested :call CppSplit()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it helps, I am using a.vim to open the header split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:hasOpenedFirstFile = 0&#xA;function g:QuitThisFile()&#xA;  if (g:hasOpenedFirstFile == 1)&#xA;    wincmd l&#xA;    :wq&#xA;  endif&#xA;endfunction&#xA;&#xA;function g:SetHasOpenedFile()&#xA;  let g:hasOpenedFirstFile = 1&#xA;endfunc&#xA;&#xA;nmap &amp;lt;leader&amp;gt;x :call QuitThisFile()&amp;lt;cr&amp;gt;&#xA;&#xA;autocmd FileType cpp nested :call QuitThisFile()&#xA;autocmd FileType cpp nested :call SetHasOpenedFile()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is at the end of the vimrc and some reason, it closes one window when vim opens up. I thought the &lt;code&gt;hasOpenedFirstFile&lt;/code&gt; would have fixed that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit: (no NERDTree)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As NERDTree is apparently difficult to script with as it's a draw instead of split window spaced, I disabled NERDTree and started to use the built in vim editor via &lt;code&gt;:e.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I am getting now is although I only have my cpp and header file open, the above code closes the right split and the cpp file but keeps a new blank buffer open instead of quitting the window. Why is this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now, I have set up a map to open the hpp file in another tab and another to write and save all tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I have done:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function g:OpenHeadderFile()&#xA;  tabnew %:t:r.hpp&#xA;endfunc&#xA;&#xA;function g:WriteAllTabs()&#xA;  wa&#xA;endfunc&#xA;&#xA;function g:QuitAllTabs()&#xA;  qa&#xA;endfunc&#xA;&#xA;function g:SaveAndQuitTabs()&#xA;  wqa&#xA;endfunc&#xA;&#xA;autocmd BufAdd *.cpp call OpenHeadderFile()&#xA;&#xA;imap &amp;lt;leader&amp;gt;hpp &amp;lt;esc&amp;gt;:call OpenHeadderFile()&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;leader&amp;gt;hpp :call OpenHeadderFile()&amp;lt;cr&amp;gt;&#xA;&#xA;nmap tn :tabNext&amp;lt;cr&amp;gt;&#xA;nmap tp :tabprevious&amp;lt;cr&amp;gt;&#xA;&#xA;nmap qat :call QuitAllTabs()&amp;lt;cr&amp;gt;&#xA;nmap wat :call WriteAllTabs()&amp;lt;cr&amp;gt;&#xA;nmap saq :call SaveAndQuitTabs()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a doable work around as I can still easily access my hpp files without having to leave vim or having to manually open my vim file. I can also quit vim with one command. If possible, I would still like to have the hpp side by side and be able to quit vim when I exit from the cpp file. I would also still like to close the hpp slit when editing a new file.&lt;/p&gt;&#xA;" OwnerUserId="1168" LastEditorUserId="1168" LastEditDate="2018-11-14T13:36:10.183" LastActivityDate="2018-11-14T13:36:10.183" Title="How to close splits automatically when changing file or closing VIM?" Tags="|vimrc|split|window-management|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17916" PostTypeId="1" CreationDate="2018-11-11T13:15:26.230" Score="2" ViewCount="163" Body="&lt;p&gt;In GVIM I use vertical thin line as my cursor by adding following line to my .gvimrc&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set guicursor=a:ver13-Cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This works perfectly as long as window remained focused. As soon as GVIM window lost it focus cursor change to bad ugly transparent block. How can I prevent that. (This happens in all modes like insert, visual, ...)&lt;/p&gt;&#xA;&lt;p&gt;I'm on linux-arch-gnome3-gvim&lt;/p&gt;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5P9OC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5P9OC.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h3&gt;EDIT1&lt;/h3&gt;&#xA;&lt;p&gt;As suggested by cristian there may be a autocmd that create this effect&#xA;&lt;a href=&quot;https://i.stack.imgur.com/a1VKj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/a1VKj.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19777" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-11-12T07:19:16.863" Title="Cursor change when GVIM lost focus" Tags="|gvim|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17917" PostTypeId="2" ParentId="8406" CreationDate="2018-11-11T14:16:31.337" Score="2" Body="&lt;p&gt;As of &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.0253&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.0253&lt;/a&gt;, Vim will use the terminal's title stack to push/pop the title.  This is more robust than trying to query the title from X, but not all terminals may support this functionality.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2018-11-11T14:16:31.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17918" PostTypeId="1" CreationDate="2018-11-11T15:24:35.143" Score="1" ViewCount="22" Body="&lt;p&gt;I just upgraded Vim to 8.1.1, and the behavior of &lt;code&gt;:bro w&lt;/code&gt; seems changed: it occasionally (!?) does not open the pwd for browsing.  (I checked &lt;code&gt;:pwd&lt;/code&gt;.)  This in on Win 10.  Does something other than the pwd determine which directory should be browsed?  I still get the expected behavior if I specify a directory, and if I do that once, the old behavior (i.e., following the pwd) is restored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As possible context, I &lt;code&gt;set autochdir&lt;/code&gt; in my _vimrc, so my current buffer sets my pwd.  I checked &lt;code&gt;browsedir&lt;/code&gt; and it says &lt;code&gt;buffer&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After closing and relaunching GVim, I can no longer produce this behavior.  So my question changes to: has anyone else experienced this behavior?&lt;/p&gt;&#xA;" OwnerUserId="19779" LastEditorUserId="19779" LastEditDate="2018-11-11T17:17:19.173" LastActivityDate="2018-11-11T17:17:19.173" Title="`:bro w` initially opens wrong directory in 8.1.1" Tags="|working-directory|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17919" PostTypeId="1" AcceptedAnswerId="17933" CreationDate="2018-11-11T17:43:23.580" Score="1" ViewCount="393" Body="&lt;p&gt;I am designing a syntax rule (for R code) that highlights if I do not start a function with a curly all by itself.  For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   A &amp;lt;- function(x,&#xA;                 y){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would be match but I do not want to match &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   A &amp;lt;- function(x,&#xA;                 y)&#xA;   {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do NOT watch the regular expression to match occurrences of &lt;code&gt;){&lt;/code&gt; later on in the file, so I want to exclude &lt;code&gt;^\s*{&lt;/code&gt; from occurring within my match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I have an expression that works well if all of this is one one line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/function\s*(.*)\s*{$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I am aware that in vim you can use &lt;code&gt;\_.&lt;/code&gt; to do a multiline match, but I don't know how to do a multiline match the EXCLUDES some characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also looked at using &lt;code&gt;syntax region&lt;/code&gt; instead but I don't see a way to exclude regions that have &lt;code&gt;){&lt;/code&gt; in them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do you think?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;======================= A little more detail ====================&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify, I'm trying to prevent putting the curly bracket on the same line as the close paren in my function definition.  Kerninghan and Ritchie always start functions (but not conditionals or loops) with a curly bracket on its own line.  This practice is helpful for vim's built in movement (going from one function to another) and my custom folding code.  I've historically placed the curly in both locations, but want the syntax highlighter to mark it red if I put the curly on the same line as the close paren in order to discipline me to do it K&amp;amp;R style.  In vim (using the tip I got below) I can write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match MyError /function\s*(\_[^{]*)\s*{/ contains=Function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it will highlight cases like my first example above but not K&amp;amp;R-compliant code like my second example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's necessary to exclude &lt;code&gt;{&lt;/code&gt; as a possible match because otherwise the &lt;code&gt;\_.*&lt;/code&gt; will greedily match with something lower in the file not related to this function (like the beginning of an &lt;code&gt;if&lt;/code&gt; statement).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably there are multiple ways of solving this problem, but what I needed was an expression to do the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Match any number of characters including newlines but excluding &lt;code&gt;{&lt;/code&gt;&quot;. &lt;/p&gt;&#xA;" OwnerUserId="19782" LastEditorUserId="19782" LastEditDate="2018-11-12T18:49:30.060" LastActivityDate="2018-11-12T18:49:30.060" Title="Multiline regular expression excluding characters" Tags="|syntax-highlighting|regular-expression|multiple-lines|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17920" PostTypeId="2" ParentId="17919" CreationDate="2018-11-11T18:04:39.640" Score="0" Body="&lt;p&gt;I figured out a brute-force solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/function\s*([abcdefghijklmnopqrstuvwxyz ,=()!ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\n]*)\s*{$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that allows only charachters you would normally find in a function definition in R. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone has a more elegant solution, I'd love to have it.&lt;/p&gt;&#xA;" OwnerUserId="19782" LastEditorUserId="19782" LastEditDate="2018-11-11T18:23:21.673" LastActivityDate="2018-11-11T18:23:21.673" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17921" PostTypeId="2" ParentId="17911" CreationDate="2018-11-12T00:09:37.777" Score="2" Body="&lt;p&gt;Well, &lt;code&gt;gg&lt;/code&gt; is a full command by itself, so operator mode is not involved here at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not like the first &lt;code&gt;g&lt;/code&gt; is a command and then  the second &lt;code&gt;g&lt;/code&gt; is an operator. The &lt;code&gt;g&lt;/code&gt;-&lt;em&gt;something&lt;/em&gt; family of commands are simply two-character commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to have &lt;code&gt;ii&lt;/code&gt; to map to &lt;code&gt;gg&lt;/code&gt;, you actually need:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap ii gg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Though you'll probably need to map all the other &lt;code&gt;i&lt;/code&gt;-&lt;em&gt;something&lt;/em&gt; commands to their non-dvorak counterparts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As recommended by @DBenKnoble in the comments, check out the &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/keymap/dvorak.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;dvorak.vim&lt;/a&gt; which is probably already installed in your vim, it probably does what you want and, if not, you can probably use it as a starting point.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-08-04T13:37:04.327" LastActivityDate="2019-08-04T13:37:04.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17922" PostTypeId="2" ParentId="17584" CreationDate="2018-11-12T01:35:34.683" Score="0" Body="&lt;p&gt;In case the lines with two chars and the lines with one char is interleaved, such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;2&#xA;13&#xA;3&#xA;8&#xA;13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The visual block selection will not work. However, the following method still works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\ze.\%2c$/ /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;\ze&lt;/code&gt; marks the end of match so that only the part before it is to be substituted (with a space) (see &lt;code&gt;:h /\ze&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt; takes away one char&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%2c&lt;/code&gt; matches the second column&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\%2c$&lt;/code&gt; means the end of line is at the second column, so that the line only contains one char&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-11-12T01:43:58.140" LastActivityDate="2018-11-12T01:43:58.140" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17923" PostTypeId="2" ParentId="17901" CreationDate="2018-11-12T01:59:42.267" Score="2" Body="&lt;p&gt;You can use the autocmd &lt;code&gt;TermClose&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au TermClose * :q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this is generally not recommended since you will not be able the see the output and error. You can narrow the file pattern so that it only works for certain external commands that you don't care about the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if you launch the terminal using &lt;code&gt;:term&lt;/code&gt;, it will reuse the current window so that after finishing the current window will be closed. You may consider other alternatives like &lt;code&gt;:b#&lt;/code&gt; instead of &lt;code&gt;:q&lt;/code&gt;; or to launch the terminal in a split &lt;code&gt;:new term://you-command&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-11-12T01:59:42.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17924" PostTypeId="2" ParentId="16675" CreationDate="2018-11-12T04:48:03.087" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;--bind&lt;/code&gt; to change mappings to everything you like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So something along the lines of this should work for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; &amp;lt;F2&amp;gt; :call fzf#run({'source': 'rg --files --column --no-heading --hidden --follow --glob &quot;!.git/*&quot;', 'sink': 'e', 'down': '~30%', 'options': '--bind ctrl-o:up,ctrl-l:down'})&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course only the &lt;code&gt;options&lt;/code&gt; part is important for your question, but I wanted to keep the context. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For every keymap option available check &lt;code&gt;man fzf&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="19334" LastEditorUserId="1841" LastEditDate="2018-11-12T08:41:34.630" LastActivityDate="2018-11-12T08:41:34.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17925" PostTypeId="2" ParentId="17888" CreationDate="2018-11-12T09:03:01.927" Score="1" Body="&lt;p&gt;What fixed my problem, was setting background option to dark, as @ChristianBrabandt suggested in comments on my original post. &lt;code&gt;:set background=dark&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What it basically does is adjusting the background colors without changing the syntax highlighting colors. I won't go into much detail, as &lt;a href=&quot;https://vi.stackexchange.com/a/13089/19752&quot;&gt;this&lt;/a&gt; explains it way better than I ever could.&lt;/p&gt;&#xA;" OwnerUserId="19752" LastEditorUserId="19752" LastEditDate="2018-11-18T14:56:44.683" LastActivityDate="2018-11-18T14:56:44.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17926" PostTypeId="2" ParentId="17896" CreationDate="2018-11-12T09:14:27.897" Score="1" Body="&lt;p&gt;I have similar setup (&lt;code&gt;set autochdir&lt;/code&gt;) and sometimes I face the same issue for the folders without root markers (.git, .hg ...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was using workaround described in comment to your question -- close and reopen leaderf with parent folder:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:LeaderfFile ..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have &lt;code&gt;cnoremap lf LeaderfFile&lt;/code&gt; defined, so it is easy to type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But today I have come up with the other solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change &quot;normal&quot; mappings of leadefF:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let g:Lf_NormalMap = {&#xA;    \ &quot;File&quot;:   [[&quot;u&quot;, ':LeaderfFile ..&amp;lt;CR&amp;gt;']]&#xA;    \}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you can press &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; to go to LeaderfFile normal mode and then press &lt;code&gt;u&lt;/code&gt; to reopen LeadefFile with parent folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;code&gt;g:Lf_CommandMap&lt;/code&gt; that is used to remap some bindings in the prompt but I am not sure if I can run ex commands there.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2018-11-12T09:14:27.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17927" PostTypeId="1" AcceptedAnswerId="17929" CreationDate="2018-11-12T09:48:30.177" Score="0" ViewCount="316" Body="&lt;p&gt;I often find myself jotting notes in Vim using an empty buffer which in this case has 'no ft' (status line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I could set the filetype with &lt;code&gt;:setfiletype text&lt;/code&gt; but I honestly wonder what that would buy me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now my questions is: How can I get help about file type specifics. &lt;a href=&quot;https://vi.stackexchange.com/questions/5780/list-known-filetypes&quot;&gt;List known filetypes&lt;/a&gt; gives me a listing about known file types but &lt;code&gt;:help text&lt;/code&gt; for example doesn't give me a clue about highlighting, specific key bindings, text objects, ect.  for this specific file type.&lt;/p&gt;&#xA;" OwnerUserId="11633" LastActivityDate="2018-11-12T10:16:53.697" Title="Help for filetype specifics" Tags="|filetype|help-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17928" PostTypeId="2" ParentId="17927" CreationDate="2018-11-12T10:01:25.217" Score="2" Body="&lt;p&gt;If you want to know what options are enabled when specifying a file type you can follow this procedure:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:scriptnames&lt;/code&gt; and take note of the number of the last line.&lt;/li&gt;&#xA;&lt;li&gt;Set the file type e.g. &lt;code&gt;set filetype=text&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:scriptnames&lt;/code&gt; and look at the new entries: this will be the scripts executed by the commands. On my setup I get &lt;code&gt;/usr/share/vim/vim80/ftplugin/text.vim&lt;/code&gt; which is the default ft-plugin script which comes with vim. If I use &lt;code&gt;set ft=javascript&lt;/code&gt; I also get other scripts because I have custom ft plugins and also indent and syntax scripts for this filetype.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want to get a list of all the default filetype specific scripts and what they do, you can use &lt;code&gt;:echo $VIMRUNTIME&lt;/code&gt;, this will give you a directory that you can then browse looking for its subdirectories &lt;code&gt;ftplugin&lt;/code&gt;, &lt;code&gt;indent&lt;/code&gt; and &lt;code&gt;syntax&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-11-12T10:01:25.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17929" PostTypeId="2" ParentId="17927" CreationDate="2018-11-12T10:16:53.697" Score="3" Body="&lt;p&gt;Filetype relevant options are available in the help and follow the following pattern:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For filetype specific options, see &lt;code&gt;ft-&amp;lt;filetype&amp;gt;-plugin&lt;/code&gt; (e.g. &lt;a href=&quot;http://vimhelp.appspot.com/filetype.txt.html#ft-vim-plugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ft-vim-plugin&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;For indent specific filetype options, see &lt;code&gt;ft-&amp;lt;filetype&amp;gt;-indent&lt;/code&gt; (e.g. &lt;a href=&quot;http://vimhelp.appspot.com/indent.txt.html#ft-vim-indent&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ft-vim-indent&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;For syntax specific filetype options, see &lt;code&gt;ft-&amp;lt;filetype&amp;gt;-syntax&lt;/code&gt; (e.g. &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#ft-vim-syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ft-vim-syntax&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Those might not always exists for all specific filetypes that Vim comes with. But if there are options available for changing the behaviour, it should be documented and follow the mentioned pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For external filetype plugins (once you install separately and that do not come with Vim bundled), they should follow a similar rule. For example my &lt;a href=&quot;https://github.com/chrisbra/csv.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;csv filetype plugin&lt;/a&gt; comes with a help file, that is called &lt;a href=&quot;https://github.com/chrisbra/csv.vim/blob/master/doc/ft-csv.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;ft-csv.txt&lt;/a&gt; and covers all commands, options and settings related to the CSV filetype.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-11-12T10:16:53.697" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17930" PostTypeId="1" CreationDate="2018-11-12T10:21:17.117" Score="0" ViewCount="191" Body="&lt;p&gt;With milliseconds; before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;64.173&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00:01.04.173&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another example: from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;23032.3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;06:23:52.3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6038" LastActivityDate="2018-11-12T11:04:01.070" Title="How to replace seconds with hours:minutes:seconds?" Tags="|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17931" PostTypeId="2" ParentId="17930" CreationDate="2018-11-12T10:21:37.757" Score="1" Body="&lt;pre&gt;&lt;code&gt;:%s#\d\+\ze\.#\=system('printf &quot;%02d:%02d:%02d&quot; $(('.submatch(0).'/3600)) $(('.submatch(0).'%3600/60)) $(('.submatch(0).'%60))')#g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\d\+&lt;/code&gt; mean one or more digits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5Cze&quot; rel=&quot;nofollow noreferrer&quot;&gt;\ze&lt;/a&gt; mean the end of search pattern, &lt;code&gt;\.&lt;/code&gt; after that is analog of look-forward for the dot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also here we use &lt;code&gt;#&lt;/code&gt; as an &lt;a href=&quot;http://vim.wikia.com/wiki/Alternate_delimiters_for_the_replace_command&quot; rel=&quot;nofollow noreferrer&quot;&gt;alternative delimiter&lt;/a&gt; - because we already use &lt;code&gt;/&lt;/code&gt; for division.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\=&lt;/code&gt; in the replace part mean that we will use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;sub-replace-expression&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h sub-replace-expression&lt;/code&gt; is copied below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Substitute with an expression           *sub-replace-expression*&#xA;                        *sub-replace-\=*&#xA;When the substitute string starts with &quot;\=&quot; the remainder is interpreted as an&#xA;expression.  This does not work recursively: a substitute() function inside&#xA;the expression cannot use &quot;\=&quot; for the substitute string.&#xA;&#xA;The special meaning for characters as mentioned at |sub-replace-special| does&#xA;not apply except for &quot;&amp;lt;CR&amp;gt;&quot;, &quot;\&amp;lt;CR&amp;gt;&quot; and &quot;\\&quot;.  Thus in the result of the&#xA;expression you need to use two backslashes to get one, put a backslash before a&#xA;&amp;lt;CR&amp;gt; you want to insert, and use a &amp;lt;CR&amp;gt; without a backslash where you want to&#xA;break the line.&#xA;&#xA;For convenience a &amp;lt;NL&amp;gt; character is also used as a line break.  Prepend a&#xA;backslash to get a real &amp;lt;NL&amp;gt; character (which will be a NUL in the file).&#xA;&#xA;When the result is a |List| then the items are joined with separating line&#xA;breaks.  Thus each item becomes a line, except that they can contain line&#xA;breaks themselves.&#xA;&#xA;The whole matched text can be accessed with &quot;submatch(0)&quot;.  The text matched&#xA;with the first pair of () with &quot;submatch(1)&quot;.  Likewise for further&#xA;sub-matches in ().&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;printf&lt;/code&gt; syntax: &lt;code&gt;02d&lt;/code&gt; mean two digits: in will add leading zero when one digit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%60&lt;/code&gt; mean reminder after division to 60.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See good article &lt;a href=&quot;https://jeffkreeftmeijer.com/vim-reformat-dates/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Find, convert and replace dates with Vim substitutions&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6038" LastEditorUserId="6038" LastEditDate="2018-11-12T11:04:01.070" LastActivityDate="2018-11-12T11:04:01.070" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17932" PostTypeId="2" ParentId="17889" CreationDate="2018-11-12T10:27:08.733" Score="1" Body="&lt;p&gt;The &lt;code&gt;:syntax&lt;/code&gt; command only covers actual buffer contents. Both statusline and (terminal) tabline, though displayed with the same font and highlighting possibilities as the windows that contain buffer contents, are different: They belong to the editor UI elements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main reason for syntax highlighting is highlighting parts of the text with different colors or text attributes, through &lt;em&gt;highlight groups&lt;/em&gt;. For the tabline, there's a fixed set of highlight groups (&lt;a href=&quot;https://vimhelp.appspot.com/tabpage.txt.html#setting-tabline&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help setting-tabline&lt;/code&gt;&lt;/a&gt;), for the statuslines there are two different groups for active and inactive (&lt;a href=&quot;https://vimhelp.appspot.com/syntax.txt.html#hl-StatusLine&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help hl-StatusLine&lt;/code&gt;&lt;/a&gt;). Inside both, you  can include 9 different user highlightings via the &lt;code&gt;%1*...%*&lt;/code&gt; items, cp. &lt;a href=&quot;https://vimhelp.appspot.com/syntax.txt.html#hl-User1..9&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help hl-User1..9&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You cannot use this for &lt;em&gt;concealing&lt;/em&gt; characters, but this can be done by including a custom Vimscript expression (&lt;code&gt;%{...}&lt;/code&gt;) and translating / removing the characters in there.&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2018-11-12T10:57:30.137" LastActivityDate="2018-11-12T10:57:30.137" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17933" PostTypeId="2" ParentId="17919" CreationDate="2018-11-12T16:00:14.473" Score="0" Body="&lt;p&gt;I'm a bit unclear about what you're trying to achieve, but perhaps this is what you're looking for?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/function\s*(\_[^)]*)\s*{$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the same as the regular expression you supplied, except I've replaced &lt;code&gt;.*&lt;/code&gt; (match any number of any characters but not including newlines) with &lt;code&gt;\_[^)]*&lt;/code&gt; (match any number of characters including newlines but excluding &lt;code&gt;)&lt;/code&gt; close parentheses).&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-11-12T16:27:35.123" LastActivityDate="2018-11-12T16:27:35.123" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17934" PostTypeId="1" AcceptedAnswerId="17940" CreationDate="2018-11-12T18:37:50.120" Score="6" ViewCount="1933" Body="&lt;p&gt;For example I have many numbers like &lt;code&gt;111.222&lt;/code&gt;, I want to decrease them to 0.1 (to get &lt;code&gt;111.122&lt;/code&gt;), how to do that? I tried:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s#\d\+\.\d\+#\=submatch(0)-0.1#&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But as a result I have &lt;code&gt;110.9&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6038" LastActivityDate="2018-11-13T05:44:44.363" Title="Search and replace: float arithmetic" Tags="|regular-expression|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17935" PostTypeId="2" ParentId="10575" CreationDate="2018-11-12T21:10:51.933" Score="1" Body="&lt;h2&gt;Check if a path has a symlink anywhere in it, and if so return 1, otherwise 0&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Pseudocode:  Use the shell to convert the symlink path to the path it points to.  If the two paths are identical then it's not a symlink.  Otherwise it is.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! IsPathSymlinkPath(foo)&#xA;    &quot;Sorry for the incantations.  Level 9 hax required.&#xA;    if ( substitute( &#xA;        \ system('readlink -f ' . &#xA;        \ a:foo), '^\s*\(.\{-}\)\_s*$', '\1', '') == &#xA;        \ substitute(a:foo, '^\s*\(.\{-}\)\s*$', '\1', '') &#xA;        \ )&#xA;        return 1&#xA;    endif&#xA;endfunction&#xA;&#xA;echo IsPathSymlinkPath(&quot;/home/el/symlink/somefile&quot;)&#xA;&quot;returns 1&#xA;&#xA;echo IsPathSymlinkPath(&quot;/home/el/normal/somefile&quot;)&#xA;&quot;returns 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could do it using vimscript's resolve and expand code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! IsSymlinkPath(mypath)&#xA;    let resolved_expanded = resolve(expand(a:mypath))&#xA;    let trim_and_flatten_path = substitute(&#xA;        \ resolved_expanded, '^\s*\(.\{-}\)\s*$', '\1', '')&#xA;    let trim_original_mypath  = substitute(&#xA;        \ a:mypath, '^\s*\(.\{-}\)\s*$', '\1', '') &#xA;    if ( trim_and_flatten_path == trim_original_mypath )&#xA;        return 1&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6775" LastEditorUserId="6775" LastEditDate="2018-11-12T21:38:37.673" LastActivityDate="2018-11-12T21:38:37.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17937" PostTypeId="1" AcceptedAnswerId="17941" CreationDate="2018-11-13T01:13:53.273" Score="0" ViewCount="138" Body="&lt;p&gt;I'm trying to find a pattern that will match for any digits, except &quot;:3&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v(:3)@!&amp;amp;\d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work and I've no idea why&lt;/p&gt;&#xA;" OwnerUserId="19793" LastActivityDate="2018-11-13T07:15:19.280" Title="Match all digits but not string" Tags="|search|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17938" PostTypeId="1" AcceptedAnswerId="17939" CreationDate="2018-11-13T03:34:11.163" Score="1" ViewCount="1557" Body="&lt;p&gt;Suppose I have a dictionary declared like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g:dict = {&#xA;  \ 'foo' : ['foobar'],&#xA;  \ 'bar' : ['barfoo']&#xA;\}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;how can I get the key for &lt;code&gt;barfoo&lt;/code&gt; using just the value(&lt;code&gt;barfoo&lt;/code&gt;) itself?&lt;/p&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-11-13T10:51:53.807" Title="How to get the specific key in a dictionary using the just the key's value?" Tags="|vimscript|dictionary|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17939" PostTypeId="2" ParentId="17938" CreationDate="2018-11-13T03:57:25.403" Score="4" Body="&lt;p&gt;There's no function to get a dictionary key from a value, so you'll have to loop over the keys. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for [key, value] in items(g:dict)&#xA;    if index(value, &quot;barfoo&quot;) &amp;gt;= 0&#xA;        let g:mykey = key&#xA;        break&#xA;    endif&#xA;endfor&#xA;&#xA;echo g:mykey&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-11-13T03:57:25.403" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17940" PostTypeId="2" ParentId="17934" CreationDate="2018-11-13T05:44:44.363" Score="8" Body="&lt;p&gt;In short, you need to convert the string to a Float explicitly, using &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#str2float()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;str2float()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s#\d\+\.\d\+#\=str2float(submatch(0))-0.1#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To explain what you're seeing without the explicit conversion, vim has two numeric types: Number (for integers) and Float (for floating point numbers.) When using a string in numeric context (for example, with an arithmetic operation such as &lt;code&gt;-&lt;/code&gt;), vim will do an implicit conversion, but it only converts strings to &lt;em&gt;Number&lt;/em&gt;, not Float. Trailing characters are ignored in the conversion, so it just stops at &lt;code&gt;.&lt;/code&gt;, the decimal point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The end result is that &lt;code&gt;111.222&lt;/code&gt; will be converted to the Number 111.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, when performing an arithmetic operation between a Number and a Float, vim will first coerce the Number into a Float. So, in your case, it will get to &lt;code&gt;111.0-0.1&lt;/code&gt;, finally yielding &lt;code&gt;110.9&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2018-11-13T05:44:44.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17941" PostTypeId="2" ParentId="17937" CreationDate="2018-11-13T07:15:19.280" Score="2" Body="&lt;p&gt;Match all digits if there is no &lt;code&gt;:&lt;/code&gt; before them&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v:@&amp;lt;!\d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add all digits except 3&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v:@&amp;lt;!\d|[0124-9]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/21JRU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/21JRU.png&quot; alt=&quot;Results of the last regexp&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2018-11-13T07:15:19.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17942" PostTypeId="1" CreationDate="2018-11-13T07:24:18.313" Score="2" ViewCount="78" Body="&lt;p&gt;Vim is outstanding. It holds a lot of potential for blind users.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still have one out-of-the-box problem when using vim with screen readers (tested with both NVDA and System Access). But that surely must have a quick and easy workaround, such as placing a single line in the vimrc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When moving to a line longer than what appears to be a hard-coded maximum width of around eighty characters, there is no reading past that preset width.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, vim seems somehow to hide whatever doesn't fit on the screen, and that is where the screen reader stops reading. This is similar to Microsoft Notepad, in which there are about a thousand characters before a line break is imposed, although with Notepad the line is truly wrapped without inserting any kind of newline sequence (so that the text can be copied and pasted in its original form), and arrowing down in the Notepad window allows reading to continue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With vim, regardless of the combinations of &lt;code&gt;wrap&lt;/code&gt;, &lt;code&gt;linebreak&lt;/code&gt;, and so on, that I have experimented with, the screen reading simply stops at that maximum line length. The screen reader will actually echo the column position when arrowing through a line (not with the movement commands unfortunately), so that starting from the beginning of the line and arrowing right states position 80 is reached, then counting starts over at 1 for the longer lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two major problems here: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most obvious is that a blind user will have to jump to that last column position, arrow up or down, then back to the long line, which will then continue reading from that position (odds are in the middle of a word), and repeat the process to read the next &quot;screen width&quot; for as many screens worth of text the line might flow into.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;textwidth&lt;/code&gt; will move the overflow text to the next line, but only after Inserting a newline character. Inserting newlines is not an option for code which will not compile when lines are broken up with newlines, or for writing that needs to have defined paragraphs delimited by newline characters as with normal word processing. (If wrap or other methods give only a visual appearance of line wrapping, this of course does nothing for a blind user, whose screen reader still sees only the first eighty characters.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also experimented using the screen command (ubuntu 16) from a cygwin window, which interestingly does show the long lines reflowed in a way that is visible to screen readers when scrolling up after using screen's &lt;code&gt;C-a [&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a standard program like screen would be great in combination with vim if anyone knows a way around what vim is doing with the text or window, or please advise about whether something like &lt;code&gt;columns=10000&lt;/code&gt; can be placed in the configuration to easily solve the problem. I am not familiar with vim scripting language but could learn enough to get by, and I have recently discovered that vim can be used with python3, so that would be an option too, though I would also like a simple solution that I can teach to others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you to anyone who can provide feedback.&lt;/p&gt;&#xA;" OwnerUserId="19797" LastEditorUserId="1841" LastEditDate="2018-11-13T10:27:29.897" LastActivityDate="2018-11-13T10:27:29.897" Title="Extending the true line width to enable screen readers to see what blind users cannot" Tags="|vimrc|wrapping|line-breaks|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17943" PostTypeId="2" ParentId="17900" CreationDate="2018-11-13T07:25:36.137" Score="2" Body="&lt;p&gt;What you can do, is conceal characters that you want to be displayed differently. Concealing means to change how a character (or a pattern) looks like in your current window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your specific case, you can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd('Conceal', '‌\%u200c', 10, -1, {'conceal':''})&#xA;:set conceallevel=2 concealcursor=nv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first statement sets up a conceal rule for your character &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Zero-width_non-joiner&quot; rel=&quot;nofollow noreferrer&quot;&gt;ZWNJ&lt;/a&gt; and uses the regular expression atom &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5C%25u&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;/\%u&lt;/code&gt;&lt;/a&gt; (by matching a character against its Unicode codepoint value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second statement sets up the actual conceal setting for your window. So it will make sure that concealed characters will be hidden in normal and visual mode (even if the cursor is on that line). For more information have a look at &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27concealcursor%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'concealcursor'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27conceallevel%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'conceallevel'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note however, this is a mere visual feature and it won't change the actual text. In fact, even the text wrapping will occur only on the physical text representation which might let the text wrapping look a bit strange. However this has been classified as no bug and probably won't change in the future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also, this is a window specific setting. So it would have to be done in each window, where you like to change the visual representation. For specific filetypes, you could even convert this to a specific filetype plugin. But that is the topic of another question/answer :)&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2018-11-13T07:37:02.587" LastActivityDate="2018-11-13T07:37:02.587" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17944" PostTypeId="2" ParentId="17938" CreationDate="2018-11-13T07:32:42.520" Score="5" Body="&lt;p&gt;&lt;code&gt;echo keys(filter(copy(dict), 'index(v:val, &quot;foobar&quot;)&amp;gt;=0'))[0]&lt;/code&gt; should do it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note it'll be much more efficient than a loop &lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-11-13T10:51:53.807" LastActivityDate="2018-11-13T10:51:53.807" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17945" PostTypeId="1" AcceptedAnswerId="17946" CreationDate="2018-11-13T10:10:36.437" Score="5" ViewCount="1334" Body="&lt;p&gt;I am a long time user of latex and I have been searching for a good editor to use it with. I have been using TexStudio but recently I feel I need the no distractions feel of using vim. So I stumbled upon vim-latex and here is where my problems started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I went on their site and followed the instructions but I don't think they are complete or clear enough. I copied everything as per instructions but I can't make it work. Then there is the problem of usage. How does one use vim-latex? Is there a command, a key press? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is vim-latex the best option for using latex in vim? Or should I look elsewhere?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: The details&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Downloaded the archive from &lt;a href=&quot;http://sourceforge.net/projects/vim-latex/files/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Unpacked the archive and ended up with a dir called &lt;code&gt;vim-latex-1.10.0&lt;/code&gt; which I then copied to my &lt;code&gt;.vim&lt;/code&gt; dir&#xA;3) Then I went and did the changes in the &lt;code&gt;.vimrc&lt;/code&gt; file, but I had to stop at the &lt;code&gt;tex.vim&lt;/code&gt; because it wasn't where the instructions said it was supposed to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) I started vim regardless and issued the &lt;code&gt;helptags ~/.vim/doc&lt;/code&gt; command which didn't work. The output was &lt;code&gt;E150: Not a directory: ~/.vim/doc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5) Regarding compilation:&#xA;I know about reading the manuals and I usually do, but this particular one is not very clear at least to a noob like me when it comes to vim. Here is what it says at&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting Compilation rules:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;In order to compile LaTeX files into various formats, Latex-Suite needs to know which external programs to call and in which way they need to be called. This information is provided to Latex-Suite via a number of &quot;rules&quot;. For each format you want to compile to, you need to specify a rule. A rule is specified by defining a variable of the form:&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where do you put these rules?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now what should I do?&lt;/p&gt;&#xA;" OwnerUserId="19798" LastEditorUserId="19798" LastEditDate="2018-11-13T11:13:13.060" LastActivityDate="2018-11-15T17:55:18.347" Title="vim-latex installation confusion" Tags="|plugin-vim-latex|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="17946" PostTypeId="2" ParentId="17945" CreationDate="2018-11-13T11:59:54.110" Score="6" Body="&lt;h2&gt;Installation into a Vim 8 packpath and an example vimrc&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;❯ git clone https://github.com/vim-latex/vim-latex ~/.vim/pack/my_latex_plugins/start/vim-latex&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vim-latex.sourceforge.net/documentation/latex-suite/recommended-settings.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Typically&lt;/a&gt;, you want at least following settings in your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;❯ cat ~/.vim/vimrc&#xA;filetype plugin on&#xA;filetype indent on&#xA;let g:tex_flavor='latex'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;A minimal installation would look like visualized with &lt;a href=&quot;http://mama.indstate.edu/users/ice/tree/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;tree&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim&#xA;❯ tree -L 5&#xA;.&#xA;├── pack&#xA;│   └── my_latex_plugins&#xA;│       └── start&#xA;│           └── vim-latex&#xA;│               ├── Makefile&#xA;│               ├── Makefile.in&#xA;│               ├── README.md&#xA;│               ├── compiler&#xA;│               ├── doc&#xA;│               ├── ftplugin&#xA;│               ├── indent&#xA;│               ├── latextags&#xA;│               ├── ltags&#xA;│               ├── plugin&#xA;│               └── vim-latex.metainfo.xml&#xA;└── vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Mini Tutorial: Compile a &lt;code&gt;Hello World&lt;/code&gt; in LaTeX to pdf&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Create a new file with extension tex as following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;❯ vim demo.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;switch to insert mode (type &lt;code&gt;i&lt;/code&gt;) and type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EDO&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will trigger a snippet and the buffer should now look like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LVTnY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LVTnY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can jump around with &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; to adjust the placeholders &lt;code&gt;&amp;lt;++&amp;gt;&lt;/code&gt; for the documentclass options, the documentclass and begin typing the document:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I entered a &lt;em&gt;Hello World&lt;/em&gt; equivalent for LaTeX with&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;Backspace&amp;gt;&lt;/code&gt; + &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; + &lt;code&gt;article&lt;/code&gt; + &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; + &lt;code&gt;Hello World!&lt;/code&gt; which gives you:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mHJXH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mHJXH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now press &lt;code&gt;:w&lt;/code&gt; for saving the file and start compilation with &lt;code&gt;&amp;lt;leader&amp;gt;ll&lt;/code&gt;. This is by default &lt;code&gt;\ll&lt;/code&gt;. Note these are lower case &lt;code&gt;L&lt;/code&gt; (not &lt;code&gt;\11&lt;/code&gt;). Right now this starts &lt;code&gt;latex&lt;/code&gt; on windows/linux which generates a dvi file (on a mac &lt;code&gt;pdflatex&lt;/code&gt; is called by default). To get immediately a pdf on windows/linux, you have to configure vim-latex a little bit more. But first you should get acquainted with the manual of vim-latex:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to read the manual of vim-latex, you need to run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helptags ALL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helptags ~/.vim/pack/my_latex_plugins/start/vim-latex/doc &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to generate a so-called &lt;code&gt;tags&lt;/code&gt; file so vim can find the manual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can now open the manual with &lt;code&gt;:h latex-suite&lt;/code&gt; (not &lt;code&gt;:h vim-latex&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a second help file, the quickstart tutorial under&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h latex-suite-quickstart&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;As a beginner you should take the time (30-40 min.) to go through the quickstart tutorial. It covers the basics of this feature rich plugin.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The settings for adjusting the compilation can be found under &lt;code&gt;:h customizing-compiling&lt;/code&gt; which will tell you about&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g:Tex_DefaultTargetFormat                                  *ls_11_6_1* *ls_a_dF*&#xA;                                                       *Tex_DefaultTargetFormat*&#xA;&#xA;&#xA;Type             String&#xA;Default Value    dvi for windows/*nix and pdf for mac&#xA;&#xA;Use this setting to choose the default target format. For example, setting this&#xA;to pdf makes Latex-Suite compile a pdf file when you press \ll and fire up the&#xA;pdf viewer on pressing \lv. Make sure that a rules for compiling and viewing&#xA;have been defined for this target format as described here [|ls_a_dG|] and here&#xA;[|ls_a_dO|].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So on windows/linux you have to add following line to your vimrc to compile directly to pdf:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Tex_DefaultTargetFormat = 'pdf'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am on a mac where 'pdf' is already the default.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;More questions about installation of vim-latex&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If this answer does not help, consider also following questions with answers:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://tex.stackexchange.com/questions/112698/how-to-install-vim-latex&quot;&gt;https://tex.stackexchange.com/questions/112698/how-to-install-vim-latex&lt;/a&gt; (detailed answer about installing with pathogen (useful for vim7 user))&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/12537/problems-in-installing-vim-latex&quot;&gt;Problems in installing vim-latex&lt;/a&gt; (manual installation with explanation that the extracted folder has to be merged with &lt;code&gt;~/.vim&lt;/code&gt;; however, merging with &lt;code&gt;~/.vim&lt;/code&gt; is not recommended: if you have vim8, use packpath (this answer); if you have vim7, use pathogen; or if you want an actual plugin manager, see &lt;a href=&quot;https://vi.stackexchange.com/q/388&quot;&gt;What is the difference between the vim plugin managers?&lt;/a&gt; to choose one for yourself)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-11-15T17:55:18.347" LastActivityDate="2018-11-15T17:55:18.347" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="17947" PostTypeId="1" CreationDate="2018-11-13T12:40:22.350" Score="1" ViewCount="1033" Body="&lt;p&gt;I'm using Vim primarily for rails projects, and have found a fairly significant difference in the start up time between a couple of my projects. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's one project's startuptime log, while opening a single .rb file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;185.767  002.679  002.679: sourcing /usr/share/vim/vim81/syntax/ruby.vim          &#xA;190.811  004.781  004.781: sourcing /home/thomas/.vim/bundle/vim-rails/autoload/rails.vim&#xA;478.080  000.275  000.275: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions.vim&#xA;478.257  000.061  000.061: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/quickfix.vim&#xA;478.484  000.156  000.156: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline.vim&#xA;478.645  000.035  000.035: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/netrw.vim&#xA;478.782  000.024  000.024: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/term.vim&#xA;478.944  000.059  000.059: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/ctrlp.vim&#xA;479.145  000.069  000.069: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/hunks.vim&#xA;479.471  000.120  000.120: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/whitespace.vim&#xA;479.853  000.054  000.054: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/po.vim&#xA;480.050  000.089  000.089: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/wordcount.vim&#xA;480.242  000.024  000.024: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/keymap.vim&#xA;482.185  000.073  000.073: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/section.vim&#xA;482.524  000.188  000.188: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/highlighter.vim&#xA;484.883  000.101  000.101: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/themes.vim&#xA;486.300  001.637  001.536: sourcing /home/thomas/.vim/bundle/gruvbox/autoload/airline/themes/gruvbox.vim&#xA;504.566  000.141  000.141: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/builder.vim&#xA;504.970  000.089  000.089: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/default.vim&#xA;576.879  389.599: opening buffers                                                 &#xA;577.160  000.126  000.126: sourcing /home/thomas/.vim/bundle/ctrlp.vim/autoload/ctrlp/utils.vimode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the big jump in clock after vim-rails, but unless I'm being dumb the self+sourced &amp;amp; self times are in ms right? So the clock appears to jump but without a corresponding 300ms time. Then, further down, 'opening buffers' appears to maybe account for that 300ms? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other project is far, far worse - again, opening a single .rb file: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;181.187  004.675  004.675: sourcing /home/thomas/.vim/bundle/vim-rails/autoload/rails.vim&#xA;4782.456  000.270  000.270: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions.vim&#xA;4782.607  000.053  000.053: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/quickfix.vim&#xA;4782.829  000.148  000.148: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline.vim&#xA;4782.985  000.035  000.035: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/netrw.vim&#xA;4783.113  000.024  000.024: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/term.vim&#xA;4783.280  000.059  000.059: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/ctrlp.vim&#xA;4783.479  000.070  000.070: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/hunks.vim&#xA;4783.797  000.114  000.114: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/whitespace.vim&#xA;4784.180  000.056  000.056: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/po.vim&#xA;4784.399  000.095  000.095: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/wordcount.vim&#xA;4784.598  000.026  000.026: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/keymap.vim&#xA;4786.604  000.072  000.072: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/section.vim&#xA;4786.961  000.204  000.204: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/highlighter.vim&#xA;4789.168  000.047  000.047: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/themes.vim&#xA;4790.483  001.470  001.423: sourcing /home/thomas/.vim/bundle/gruvbox/autoload/airline/themes/gruvbox.vim&#xA;4809.004  000.138  000.138: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/builder.vim&#xA;4809.359  000.078  000.078: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/default.vim&#xA;4867.585  4686.103: opening buffers                                               &#xA;4867.862  000.126  000.126: sourcing /home/thomas/.vim/bundle/ctrlp.vim/autoload/ctrlp/utils.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;same deal - the elapsed times don't seem to match the clock time. Looking at what's going on with the clock time it seems like vim-rails could be the culprit, but disabling it doesn't do the job, the apparent 5s jump is now at 'opening buffers':&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;177.576  000.045  000.045: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/themes.vim&#xA;178.888  001.464  001.419: sourcing /home/thomas/.vim/bundle/gruvbox/autoload/airline/themes/gruvbox.vim&#xA;202.604  000.145  000.145: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/builder.vim&#xA;202.975  000.074  000.074: sourcing /home/thomas/.vim/bundle/vim-airline/autoload/airline/extensions/default.vim&#xA;5496.540  5327.812: opening buffers        &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim -u NONE on the same files loads blazing fast, with no particular difference between the projects, as you'd expect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the following plugins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctrlp.vim/                 gruvbox/                  vim-bundler/        vim-pug/       vim-vue/&#xA;DeleteTrailingWhitespace/  ShowTrailingWhitespace~/  vim-coffee-script/  vim-rails/&#xA;delimitMate/               typescript-vim/           vim-endwise/        vim-slim/&#xA;emmet-vim/                 vim-airline/              vim-indent-guides/  vim-surround/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with Pathogen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the next step in debugging this? &lt;/p&gt;&#xA;" OwnerUserId="19801" LastEditorUserId="1292" LastEditDate="2018-11-14T07:29:45.070" LastActivityDate="2020-08-05T09:04:30.490" Title="Vim slow to open buffers, but not specifically in any sourcing plugin step" Tags="|startup|performance|debugging|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17948" PostTypeId="2" ParentId="17947" CreationDate="2018-11-13T15:10:12.340" Score="1" Body="&lt;p&gt;Okay, so the startup log wasn't actually very helpful here. There wasn't really any indication in the log that this was the culprit, but it turns out it was vim-bundler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I actually didn't even paste the line for it, because its timestamps seemed so inconsequential, but:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 20 048.261  001.317  001.317: sourcing /home/thomas/.vim/bundle/vim-bundler/plugin/bundler.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I had this plugin at &lt;code&gt;48abb77&lt;/code&gt;. upgrading to &lt;code&gt;a996611&lt;/code&gt; has dramatically sped up my startup time in all rails projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My approach for figuring this out was just to start with a fresh &lt;code&gt;.vim/bundle&lt;/code&gt; and reintroduce each plugin one at a time. &lt;/p&gt;&#xA;" OwnerUserId="19801" LastActivityDate="2018-11-13T15:10:12.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17949" PostTypeId="2" ParentId="7388" CreationDate="2018-11-13T15:57:36.913" Score="2" Body="&lt;p&gt;Create a temporary mapping for such replacements. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnoremap qq c&amp;lt;C-R&amp;gt;=system('wc -c | perl -pe chomp', @&quot;)&amp;lt;CR&amp;gt;&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in visual mode you can select text, type &lt;code&gt;qq&lt;/code&gt; and it'll be replaced by the command output. In this example &lt;code&gt;wc -c&lt;/code&gt; will process your selection, which is the &lt;code&gt;@&quot;&lt;/code&gt; parameter. &lt;code&gt;perl -pe chomp&lt;/code&gt; is needed to remove a trailing  newline from the output.&lt;/p&gt;&#xA;" OwnerUserId="19804" LastEditorUserId="1841" LastEditDate="2018-11-13T16:05:04.860" LastActivityDate="2018-11-13T16:05:04.860" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17950" PostTypeId="2" ParentId="14406" CreationDate="2018-11-13T21:01:44.930" Score="2" Body="&lt;p&gt;For your cursor in insert mode and command-line insert mode use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guicursor=i-ci:hor10-Search&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;i-ci&lt;/code&gt; : insert and  command-line insert&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;hor10&lt;/code&gt;: Horizontal bar, 10% of height&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Search&lt;/code&gt;: Yellow, the background color from the &quot;Search&quot; highlight group.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2018-11-13T21:01:44.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17951" PostTypeId="1" CreationDate="2018-11-14T01:56:42.587" Score="1" ViewCount="122" Body="&lt;p&gt;The thing that slows me down the most when using VIM is getting my cursor to where I want it to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I practise improving this? Are there tools that teach you movement tricks and force you to navigate efficiently?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or do I need to force myself? How can I make sure I'm being efficient every time? Maybe there are better ways to get from point A to point B than the best I thought of in that situation, how can I learn them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or can anyone recommend general things I should pay attention to to make sure I am moving around efficiently, people have tips and tricks?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2018-11-14T01:56:42.587" Title="I want to improve my cursor movement" Tags="|cursor-movement|" AnswerCount="0" CommentCount="10" ClosedDate="2018-11-15T08:56:42.720" ContentLicense="CC BY-SA 4.0" />
  <row Id="17952" PostTypeId="1" AcceptedAnswerId="17953" CreationDate="2018-11-14T13:44:40.720" Score="0" ViewCount="570" Body="&lt;p&gt;I have this snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:git_file_prefix = ['M','A','R','D','U','?']&#xA;&#xA;function! Colorize(str)&#xA;  let index = 0&#xA;  for file in a:str&#xA;   call add(a:str[index], '$(tput 37)')&#xA;   let index = index + 1&#xA; endfor&#xA;endfunction&#xA;&#xA;call Colorize(g:git_file_prefix)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, the global variable &lt;code&gt;git_file_prefix&lt;/code&gt; has already been defined as a list.&#xA;Yet vim returns &lt;code&gt;E714 List required&lt;/code&gt; on line calling the &lt;code&gt;add()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What might be wrong in this snippet?&lt;/p&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-11-14T13:50:20.670" Title="Why vim keeps returning error &quot;E714: List required&quot; when I'm already feeding a list to it?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17953" PostTypeId="2" ParentId="17952" CreationDate="2018-11-14T13:50:20.670" Score="2" Body="&lt;p&gt;As the doc &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#add%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h add()&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;add({list}, {expr})                 *add()*&#xA;        Append the item {expr} to {list}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first argument of the function &lt;code&gt;add()&lt;/code&gt; should be a list but you give it &lt;code&gt;a:str[index]&lt;/code&gt; which is an &lt;em&gt;element&lt;/em&gt; of the list (so a string) not the list itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to concatenate &lt;code&gt;'$(tput 37)'&lt;/code&gt; to the element of the list you probably want to use &lt;code&gt;let a:str[index] .= '$(tput 37)'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-11-14T13:50:20.670" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17954" PostTypeId="1" AcceptedAnswerId="17956" CreationDate="2018-11-14T15:52:50.970" Score="1" ViewCount="269" Body="&lt;p&gt;Is it possible to press and hold the 'x' and just delete all characters after the cursor? currently when I hold the 'x' and all the characters after the cursor were deleted, it also deletes characters before the cursor.&lt;/p&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-11-14T16:05:46.640" Title="Press and hold 'x' and delete just until the cursor" Tags="|neovim|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17955" PostTypeId="1" AcceptedAnswerId="17958" CreationDate="2018-11-14T15:56:38.907" Score="1" ViewCount="145" Body="&lt;p&gt;Let's say I want to jump to a particular position in a file in an existing Vim server:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command jumps to the correct line, but &lt;em&gt;not&lt;/em&gt; the correct column, leaving the cursor at the start of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim.exe --servername VimServer --remote-silent +&quot;normal! 5G5|&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I add in an &lt;code&gt;:execute&lt;/code&gt;, however, the command works as desired:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim.exe --servername VimServer --remote-silent +&quot;execute 'normal! 5G5|'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that removing the &lt;code&gt;5G&lt;/code&gt; line movement does not affect the issue. &lt;code&gt;normal! 5|&lt;/code&gt; jumps to the start of the current line. &lt;code&gt;execute 'normal! 5|'&lt;/code&gt; jumps to the fifth column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried a few other motions. These will all leave the cursor at the start of the (correct) line unless run with &lt;code&gt;:execute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! w&#xA;normal! l&#xA;normal! j&#xA;normal! )&#xA;normal! %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's going on?&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-11-14T16:20:47.653" Title="Why is :execute required in this --remote-silent command?" Tags="|cursor-motions|clientserver|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17956" PostTypeId="2" ParentId="17954" CreationDate="2018-11-14T15:57:24.077" Score="5" Body="&lt;p&gt;I think you are looking for &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#D&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h D&lt;/code&gt;&lt;/a&gt; and more generally for &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#change.txt&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h change.txt&lt;/code&gt;&lt;/a&gt; which might help you using the right command for the right action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;x&lt;/kbd&gt; is meant to suppress the characters individually (the one under the cursor), &lt;kbd&gt;D&lt;/kbd&gt; is meant to suppress all the characters until the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you really want to remap &lt;kbd&gt;x&lt;/kbd&gt; to behave like you described in your question, it is possible but that would be pretty over-engineered when you already have a built-in action which does what you want. &lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-11-14T15:57:24.077" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17957" PostTypeId="2" ParentId="17954" CreationDate="2018-11-14T16:05:46.640" Score="0" Body="&lt;p&gt;&lt;code&gt;D&lt;/code&gt; will delete the rest of the line, and &lt;code&gt;dw&lt;/code&gt; will delete the word starting with the character in front of your cursor.&lt;/p&gt;&#xA;" OwnerUserId="19823" LastActivityDate="2018-11-14T16:05:46.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17958" PostTypeId="2" ParentId="17955" CreationDate="2018-11-14T16:20:47.653" Score="2" Body="&lt;p&gt;I haven't looked deeply into it, but reading &lt;a href=&quot;https://vimhelp.appspot.com/remote.txt.html#--remote&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help --remote&lt;/code&gt;&lt;/a&gt;, it mentions this about &lt;code&gt;+{cmd}&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This must be an Ex command that can be followed by &quot;|&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your &lt;code&gt;:normal&lt;/code&gt; interprets the remainder as normal mode commands; you'd need a &lt;code&gt;:{cmd}&lt;/code&gt; to execute &lt;code&gt;{cmd}&lt;/code&gt; as an Ex command. By wrapping this in &lt;code&gt;:execute&lt;/code&gt;, only the quoted string is executed, and the normal mode initiated by &lt;code&gt;:normal&lt;/code&gt; ends after that, and additional Ex commands can follow after a &lt;code&gt;|&lt;/code&gt;, as requested.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-14T16:20:47.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17960" PostTypeId="1" AcceptedAnswerId="17961" CreationDate="2018-11-14T21:46:05.050" Score="2" ViewCount="538" Body="&lt;p&gt;Suppose my cursor is at the beginning of the line of code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;def f(a, b, c, d, e):&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I want to change inside the parenthesis using the text object command &lt;code&gt;ci(&lt;/code&gt;, I need to first navigate to some position in the parenthesis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like it if I could just jump to the first relevant text object after my cursor when I type &lt;code&gt;ci(&lt;/code&gt; (and analogous commands). How would I configure vim to do this?&lt;/p&gt;&#xA;" OwnerUserId="19193" LastEditorUserId="2920" LastEditDate="2018-11-14T22:16:22.187" LastActivityDate="2018-11-14T22:16:22.187" Title="Automatically jump to text object during `ci(`" Tags="|cursor-motions|object-motions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17961" PostTypeId="2" ParentId="17960" CreationDate="2018-11-14T21:53:33.050" Score="6" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/wellle/targets.vim&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;wellle/targets.vim&lt;/code&gt; plugin&lt;/a&gt; should do what you're looking for (and much more). This allows you to explicitly tell vim to go to the next parenthesis (with &lt;code&gt;cin(&lt;/code&gt;, &lt;strong&gt;n&lt;/strong&gt; for &lt;em&gt;next parenthesis&lt;/em&gt;), or the last parenthesis (with &lt;code&gt;cil(&lt;/code&gt;), but it also overrides the default so that you jump to the next or last if you don't specify. From the README:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This overrides Vim's default text object to allow seeking for the next pair in the current line to the right or left when the cursor is not inside a pair. This behavior is similar to Vim's seeking behavior of &lt;code&gt;di'&lt;/code&gt; when not inside of quotes, but it works both ways.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;Next and Last Pair&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;in( an( In( An( il( al( Il( Al( ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Work directly on distant pairs without moving there separately.&lt;/p&gt;&#xA;&lt;p&gt;All the above pair text objects can be shifted to the next pair by including the letter n. The command in) selects inside of the next pair. Use the letter l instead to work on the previous (last) pair. Uses a count to skip multiple pairs. Skipping works over multiple lines.&lt;/p&gt;&#xA;&lt;p&gt;See our Cheat Sheet for two charts summarizing all pair mappings.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This also adds the &amp;quot;argument&amp;quot; text object. For example, &lt;code&gt;dana&lt;/code&gt; to delete the next argument. And many other text objects as well.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-11-14T21:53:33.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17962" PostTypeId="1" AcceptedAnswerId="28260" CreationDate="2018-11-14T21:59:35.307" Score="11" ViewCount="28006" Body="&lt;p&gt;Is it possible to debug Python scripts line by line using &lt;code&gt;:Termdebug&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help termdebug-customizing&lt;/code&gt; says, that you need a debugger that is &quot;fully compatible with gdb&quot;. Is there a debugger for Python that is compatible (using the GDB/MI interface)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or are there other alternatives?&lt;/p&gt;&#xA;" OwnerUserId="7877" LastActivityDate="2021-02-16T13:15:46.803" Title="Python debugging" Tags="|filetype-python|debugging|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17963" PostTypeId="2" ParentId="5475" CreationDate="2018-11-14T23:51:05.007" Score="0" Body="&lt;p&gt;I wrote up a solution for this. It has two parts, a shell function that launches Vim and changes to its directory when Vim exits, and a &lt;code&gt;vimrc&lt;/code&gt; edit that writes the current directory to a temp file when Vim quits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following to your &lt;code&gt;vimrc&lt;/code&gt;, to write the current directory to a temp file when you exit Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Write directory to temp file&#xA;let s:temporary_directory = &quot;/tmp/vimtmpfiles/&quot;&#xA;let s:chdirectory_directory = s:temporary_directory . &quot;chdir&quot;&#xA;let s:chdirectory_file = s:chdirectory_directory . &quot;/chdir&quot;&#xA;if !isdirectory(s:chdirectory_directory)&#xA;  call mkdir(s:chdirectory_directory, 'p')&#xA;endif&#xA;function! s:isdir(dir)&#xA;  return !empty(a:dir) &amp;amp;&amp;amp; (isdirectory(a:dir) ||&#xA;        \ (!empty($SYSTEMDRIVE) &amp;amp;&amp;amp; isdirectory('/'.tolower($SYSTEMDRIVE[0]).a:dir)))&#xA;endfunction&#xA;augroup write_chdir&#xA;  autocmd!&#xA;  autocmd VimLeavePre *&#xA;        \ if &amp;lt;SID&amp;gt;isdir(expand('%'))&#xA;        \ | call writefile([expand('%:p')], s:chdirectory_file)&#xA;        \ | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add the following to your &lt;code&gt;bashrc&lt;/code&gt; and launch Vim with it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim_cd() {&#xA;  local tempfile='/tmp/vim.robenkleene/chdir/chdir'&#xA;  $VIM_COMMAND .&#xA;  test -f &quot;$tempfile&quot; &amp;amp;&amp;amp;&#xA;    if [ &quot;$(cat -- &quot;$tempfile&quot;)&quot; != &quot;$(echo -n `pwd`)&quot; ]; then&#xA;      cd -- &quot;$(cat &quot;$tempfile&quot;)&quot;&#xA;    fi&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This was assembled by combining this Stackoverflow answer  &lt;a href=&quot;https://vi.stackexchange.com/a/10474&quot;&gt;https://vi.stackexchange.com/a/10474&lt;/a&gt; and this function for Ranger &lt;a href=&quot;https://github.com/ranger/ranger/blob/master/examples/bash_automatic_cd.sh&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ranger/ranger/blob/master/examples/bash_automatic_cd.sh&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19828" LastEditorUserId="1841" LastEditDate="2018-11-15T09:00:21.280" LastActivityDate="2018-11-15T09:00:21.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17964" PostTypeId="1" AcceptedAnswerId="17965" CreationDate="2018-11-15T03:22:14.243" Score="0" ViewCount="895" Body="&lt;p&gt;Suppose I have this string variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let foo = [&#xA;      \ 'no you are not foo',&#xA;      \ 'hi you must be foo?'&#xA;    \]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to enclose all the first 2 characters in foo with '&amp;lt; ' and ' &gt;' resulting to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt; no &amp;gt; you are not foo'&#xA;'&amp;lt; hi &amp;gt; you must be foo?'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-11-15T09:31:54.330" Title="how to insert a character string between the first two letters of all the list value?" Tags="|vimscript|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="17965" PostTypeId="2" ParentId="17964" CreationDate="2018-11-15T06:36:04.533" Score="1" Body="&lt;p&gt;You can do it with this vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! EncloseString(str)&#xA;    return '&amp;lt; '.strcharpart(a:str, 0, 2).' &amp;gt;'.strcharpart(a:str, 2)&#xA;endfun&#xA;&#xA;let foo = [ 'no you are not foo', 'hi you must be foo?']&#xA;call map(foo, {key, val -&amp;gt; EncloseString(val)})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;EncloseString&lt;/code&gt; function is the helper one to use in a &lt;code&gt;map&lt;/code&gt; function. &lt;code&gt;map&lt;/code&gt; function updates &lt;code&gt;foo&lt;/code&gt; list in-place using anonymous function aka lambda.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without helper function you can use &lt;code&gt;substitute&lt;/code&gt; (as in @Christian Brabandt answer):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call map(foo, {key, val -&amp;gt; substitute(val, '^..', '&amp;lt; &amp;amp; &amp;gt;', '')})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of &lt;code&gt;map&lt;/code&gt; you can traverse the list in imperative way with &lt;code&gt;for&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let result = []&#xA;for str in foo&#xA;    call add(result, substitute(str, '^..', '&amp;lt; &amp;amp; &amp;gt;', ''))&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2018-11-15T08:59:21.640" LastActivityDate="2018-11-15T08:59:21.640" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17966" PostTypeId="2" ParentId="17964" CreationDate="2018-11-15T06:42:13.643" Score="1" Body="&lt;p&gt;With a recent enough Vim you can use lambda (&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#lambda&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help lambda&lt;/code&gt;&lt;/a&gt;) expressions in conjunction with the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#map%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;map()&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you could use: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call map(foo, { k,v -&amp;gt; substitute(v, '^\w\+', '&amp;lt;&amp;amp;&amp;gt;', '')})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which basically changes the list in place replacing the first word by &lt;code&gt;&amp;lt;word&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do it with older Vims using just plain map(), but than the quoting is usually nasty.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-11-15T06:42:13.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17967" PostTypeId="2" ParentId="17964" CreationDate="2018-11-15T08:14:21.763" Score="1" Body="&lt;p&gt;For tasks like that many people use the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1697&quot; rel=&quot;nofollow noreferrer&quot;&gt;surround plugin&lt;/a&gt;. To add brackets, you press &lt;code&gt;ys&lt;/code&gt;, then the Vim motion (&lt;code&gt;e&lt;/code&gt;), then the character (&lt;code&gt;&amp;lt;&lt;/code&gt;). With the repeat.vim plugin, this can then be easily applied to other places via &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, your particular use case (angle brackets with inner space) isn't handled by the plugin, because it has a special case for HTML tags on that. (But you could do it without the spaces, and then add spaces: &lt;code&gt;yse&amp;gt;lyse&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also &lt;a href=&quot;https://github.com/machakann/vim-sandwich&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sandwich&lt;/a&gt;, a more configurable alternative.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-15T08:14:21.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17968" PostTypeId="1" CreationDate="2018-11-15T08:23:36.643" Score="0" ViewCount="739" Body="&lt;p&gt;On Linux, when I exit Neovim, the content in the Neovim window is cleared. But on Windows 10, when I exit Neovim, the content is still shown and is not cleared, leaving a lot of empty space (see image below). By the way, I am using Neovim inside &lt;a href=&quot;http://cmder.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;cmder&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have searched with Goolgle, but can not find useful info. A related question is post &lt;a href=&quot;https://unix.stackexchange.com/questions/60499/how-to-set-the-bash-display-to-not-show-the-vim-text-after-exit&quot;&gt;here&lt;/a&gt;, but it is for Linux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how to clear the content of Neovim when I exit on Windows 10? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tu7Xg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tu7Xg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15292" LastEditorUserId="15292" LastEditDate="2018-11-15T09:51:11.463" LastActivityDate="2018-12-09T15:34:06.390" Title="How do I clear Neovim window after exiting Neovim on Window 10" Tags="|neovim|microsoft-windows|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17969" PostTypeId="2" ParentId="17964" CreationDate="2018-11-15T09:31:54.330" Score="1" Body="&lt;p&gt;If this is for a one time use, you can also look for a simple solution without a plugin and without a complicated command to write.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first in your particular use case I would go for a substitution command:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First visually select all the lines you want to modify. For example with your cursor on &lt;code&gt;no&lt;/code&gt; you could use &lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then the substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;s/\w\w/&amp;lt; &amp;amp; &amp;gt;&#xA;&#xA;'&amp;lt;,'&amp;gt;              the lines you want to act on, when you press : in visual mode it is directly inserted&#xA;     s/            start the substitution&#xA;       \w\w        match two alphanumerical characters (the first one on the line)&#xA;           /       second part of the substitution&#xA;            &amp;lt; &amp;amp; &amp;gt;  insert a literal &quot;&amp;lt; &quot; followed by what you matched followed by &quot; &amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Still for this particular use case I would also use the visual block mode:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;With your cursor on the &lt;code&gt;n&lt;/code&gt; of &lt;code&gt;no&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; to start visual block&lt;/li&gt;&#xA;&lt;li&gt;Go down one line with &lt;code&gt;j&lt;/code&gt;, now you have &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;h&lt;/code&gt; selected&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;I&lt;/kbd&gt; to start inserting in front of your selection&lt;/li&gt;&#xA;&lt;li&gt;Insert &lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Quit insert mode and go to the end of &lt;code&gt;no&lt;/code&gt; (with &lt;kbd&gt;e&lt;/kbd&gt; or &lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;o&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; to start visual block&lt;/li&gt;&#xA;&lt;li&gt;Go down one line with &lt;code&gt;j&lt;/code&gt;, now you have &lt;code&gt;o&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt; selected&lt;/li&gt;&#xA;&lt;li&gt;Press A&lt;/kbd&gt; to start inserting after your selection&lt;/li&gt;&#xA;&lt;li&gt;Insert &lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think these solutions are interesting because they don't require you to think much before you can use them, they are really basic features. Of course the drawback is that if your input is more complex than what you gave as an example they might not scale well.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-11-15T09:31:54.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17970" PostTypeId="1" CreationDate="2018-11-15T09:51:20.473" Score="0" ViewCount="551" Body="&lt;p&gt;I have recently managed to install and configure vim-latex and started using it. I used to use TexStudio for writing my file and in it I used to have several setting that were tailored for my workflow:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I had a key combination (Shift+F1) that automatically inserted the inline equation &lt;code&gt;$|$&lt;/code&gt; and moved the cursor between the dolar signs. Is there a way to do the same in vim-latex? Maybe add an extra Alt Key Macro such that when I type $ then press &lt;code&gt;&amp;lt;Alt+L&amp;gt;&lt;/code&gt; it will insert and do what I want.&lt;/li&gt;&#xA;&lt;li&gt;I had a similar shortcut to inser the english quotes in the text (I like them because they look better). So when I press Shift+F2 it will insert ``|''. Can I do the same thing with vim-latex?&lt;/li&gt;&#xA;&lt;li&gt;This one is a bit weird: I like to have every phrase in a different row in my latex document. So I have TexStudio to automatically insert a space and  after I inserted a full stop.&lt;/li&gt;&#xA;&lt;li&gt;Another one setting was to automatically insert curly brackets when in math mode for subscript and superscript and move the cursor inside the curly brackets.&lt;/li&gt;&#xA;&lt;li&gt;Is vim-latex able to recognize the \newcommand definitions in the document preamble? I usually have several defined and they don't seem to work.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Are these things possible with vim-latex? &lt;/p&gt;&#xA;" OwnerUserId="19798" LastEditorUserId="1292" LastEditDate="2018-11-15T17:41:05.083" LastActivityDate="2022-07-28T01:00:05.040" Title="Shortcuts for math and quotes with vim-latex &amp; insert space after fullstop" Tags="|plugin-vim-latex|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17971" PostTypeId="2" ParentId="17968" CreationDate="2018-11-15T09:59:37.183" Score="1" Body="&lt;p&gt;After more search about related issues. I have finally found a solution which works for Cmder. Open Cmder settings and go to &lt;code&gt;Startup -&amp;gt; Environment&lt;/code&gt;, add the following settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set TERM=xterm-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/q60Hi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/q60Hi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Restart Cmder and the issue should disappear.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2018-11-15T09:59:37.183" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17972" PostTypeId="1" AcceptedAnswerId="17981" CreationDate="2018-11-15T13:59:53.630" Score="0" ViewCount="1219" Body="&lt;p&gt;I have been trying out FZF with Neovim. I installed it via a nvim plugin package manager. I have not installed it for the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When trying to see file previews &lt;code&gt;:FZF --preview=&quot;head -$LINES {}&quot;&lt;/code&gt;&#xA;I get the following error: &lt;code&gt;Unknown option $LINES&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that Zshell doesn't like anything I add between the double-quotes e.g.: &lt;code&gt;head -n 10&lt;/code&gt; and will throw an error. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible from Vim without the FZF command line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for your time and help.&lt;/p&gt;&#xA;" OwnerUserId="19836" LastActivityDate="2018-11-16T07:40:19.607" Title="FZF --preview in Vim returns zsh shell error" Tags="|neovim|command-line|plugin-fzf|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17973" PostTypeId="2" ParentId="17970" CreationDate="2018-11-15T14:01:12.793" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;Type &lt;code&gt;$$&lt;/code&gt; (predefined by vim-latex)&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;&quot;&quot;&lt;/code&gt; (predefined by vim-latex)&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Unclear (row=line?). &lt;code&gt;...&lt;/code&gt; is automatically converted by vim-latex to &lt;code&gt;\ldots&lt;/code&gt;. You probably have to disable this functionality with &lt;code&gt;let g:Tex_SmartKeyDot=0&lt;/code&gt;.  Also &lt;code&gt;:iabbrev&lt;/code&gt; seems not to help since you still have to type a space; e.g. &lt;code&gt;:ia teh the&lt;/code&gt; fixes the typo &lt;code&gt;teh&lt;/code&gt; automatically in insert mode when typing &lt;code&gt;teh&amp;lt;space&amp;gt;&lt;/code&gt;. BTW I am not convinced this is a huge time saver. Pressing the &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; key requires no hand movement at all. However, you are not alone, someone else has asked this already:&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/9828/insert-a-newline-after-punctuations&quot;&gt;Insert a newline after punctuations&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim&#xA;❯ cat after/ftplugin/tex.vim&#xA;let g:Tex_SmartKeyDot=0&#xA;inoremap &amp;lt;buffer&amp;gt; .  .&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Type &lt;code&gt;^^&lt;/code&gt; and &lt;code&gt;__&lt;/code&gt; (&lt;code&gt;:h lsq-keyboard-shortcuts&lt;/code&gt;) (predefined by vim-latex)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I think vim-latex does not parse the preamble for newcommand.  What does not work? If these are math environments and the syntax is messed up, see &lt;a href=&quot;https://tex.stackexchange.com/q/412862/&quot;&gt;https://tex.stackexchange.com/q/412862/&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For the record &lt;code&gt;$$&lt;/code&gt;, &lt;code&gt;&quot;&quot;&lt;/code&gt;, &lt;code&gt;^^&lt;/code&gt;, &lt;code&gt;__&lt;/code&gt; do not occur in the main helpfile. But&#xA;&lt;code&gt;^^&lt;/code&gt; is mentioned in the &lt;a href=&quot;http://vim-latex.sourceforge.net/documentation/latex-suite-quickstart/lsq-keyboard-shortcuts.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;quickstart tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;List all imaps of vim-latex with (assuming installation into the given vim8 packpath)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vim 'call IMAP'  ~/.vim/pack/my_latex_plugins/start/vim-latex/ftplugin/**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and open the list with &lt;code&gt;:copen&lt;/code&gt; (so called quickfix list).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As already mentioned in the comments: please split your questions and use the search engines.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-11-15T18:01:10.523" LastActivityDate="2018-11-15T18:01:10.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17974" PostTypeId="1" CreationDate="2018-11-15T16:30:21.557" Score="-3" ViewCount="783" Body="&lt;p&gt;I want to append every value of list1 in every value of list2, so that this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let list1 = ['one', 'two', 'three']&#xA;let list2 = [' wan', ' tu', ' tri']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will become like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo result&#xA;['one wan', 'two tu', 'three tri']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How could this be done?&lt;/p&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-11-17T02:09:48.523" Title="how to append a list value to another list value?" Tags="|vimscript|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17975" PostTypeId="1" AcceptedAnswerId="17977" CreationDate="2018-11-15T16:39:34.437" Score="1" ViewCount="164" Body="&lt;p&gt;I use gvim8.1. My settings file contains these 2 lines: &lt;code&gt;set expandtab, set shiftwidth = 4&lt;/code&gt;. I have a file 'html.vim' in '~\vimfiles\after\ftplugin\'. The file is listed below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set expandtab&#xA;setlocal shiftwidth=2&#xA;setlocal tabstop=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this file changes shiftwidth option when I'm working with vimwiki files, which have a .md extension. I've checked this with &lt;code&gt;:verbose set shiftwidth?&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I change this behaviour?&lt;/p&gt;&#xA;" OwnerUserId="18295" LastActivityDate="2018-11-15T16:58:45.720" Title="Different shiftwidth in .html and .md files" Tags="|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17976" PostTypeId="2" ParentId="17975" CreationDate="2018-11-15T16:48:24.333" Score="0" Body="&lt;p&gt;You can set the option for .md filetypes upon opening the file like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead,BufNewFile *.md set shiftwidth = 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18514" LastActivityDate="2018-11-15T16:48:24.333" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17977" PostTypeId="2" ParentId="17975" CreationDate="2018-11-15T16:58:45.720" Score="4" Body="&lt;p&gt;The Markdown &lt;em&gt;filetype&lt;/em&gt; is based on the HTML one, because some HTML elements are also allowed in Markdown. This has the side effect that your HTML filetype settings are applied to Markdown, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can use the &lt;em&gt;after directory&lt;/em&gt; for the Markdown filetype to override the settings. Even as the HTML customization also uses the after directory, as a subordinate filetype this should be sourced before the Markdown ones (you can verify with &lt;code&gt;:scriptnames&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, put the following into &lt;code&gt;~\vimfiles\after\ftplugin\markdown.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal shiftwidth=4 tabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-15T16:58:45.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17978" PostTypeId="1" AcceptedAnswerId="17979" CreationDate="2018-11-15T17:04:01.587" Score="6" ViewCount="1876" Body="&lt;p&gt;edit: Solution found! At the bottom of the post&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I installed vim 8.1 via brew on macos Sierra yesterday, and I think that broke some of the filetype setting stuff.  When I open a shell script, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /usr/local/share/vim/vim81/scripts.vim:&#xA;line   69:&#xA;E117: Unknown function: dist#ft#SetFileTypeSH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The closest answer I could find was &lt;a href=&quot;https://vi.stackexchange.com/questions/17136/error-when-opening-shell-scripts&quot;&gt;here&lt;/a&gt;, but I'm not using a session (and the error message is a little different)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also see a different error if I put my cursor over a parenthesis in a vim script. I don't know if it's related:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;50_Highlight_Matching_Pair:&#xA;line   97:&#xA;E475: Invalid argument: 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried disabling all my plugins (Just commented out the Vundle lines in my .vimrc and launched vim in a new shell), but it didn't seem to help.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;runtimepath&lt;/code&gt; looks ok, referencing &lt;code&gt;/usr/local/share/vim/vim81&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what to do next.  It seems like that function (SetFileTypeSH) is missing from Vim 8.1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bit of extra background: I &lt;em&gt;think&lt;/em&gt; I was using vim 8.1 last week without issue, but a macos update broke my brew links, so I had to reinstall it and tinker with some symlinks to make it work again.  So the problem is probably related to that in some way, I just don't know what to do next to debug it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem was that the autoload directory ($VIM_INSTALL_PATH/vim81/autoload) was empty, so a bunch of scripts were missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Somehow the autoload directory was owned by root , and was not writable by group users.  I solved it by uninstalling vim via brew (&lt;code&gt;brew uninstall vim&lt;/code&gt;), then deleting the vim81 directory manually (&lt;code&gt;sudo rm -rf $VIM_INSTALL_PATH/vim81&lt;/code&gt;), then reinstalled with brew. (&lt;code&gt;brew install vim&lt;/code&gt;), followed by re-linking (&lt;code&gt;brew link vim&lt;/code&gt;) to get it all working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seemed to fix the Highlight_Matching_Pair issue too!&lt;/p&gt;&#xA;" OwnerUserId="19837" LastEditorUserId="19837" LastEditDate="2018-11-15T18:33:46.233" LastActivityDate="2018-11-15T18:33:46.233" Title="How to debug &quot;Unknown function: dist#ft#SetFileTypeSH&quot; after upgrade to 8.1" Tags="|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17979" PostTypeId="2" ParentId="17978" CreationDate="2018-11-15T17:43:57.760" Score="2" Body="&lt;p&gt;If your &lt;code&gt;'runtimepath'&lt;/code&gt; is correct, then you seem to be missing the &lt;code&gt;/usr/local/share/vim/vim81/autoload/dist/ft.vim&lt;/code&gt; file; it ships with Vim 8.1. Check the file system and reinstall if necessary.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That error in &lt;code&gt;&amp;lt;SNR&amp;gt;50_Highlight_Matching_Pair&lt;/code&gt; seems to be in the &lt;em&gt;matchparen++&lt;/em&gt; plugin. I had submitted a patch for that problem to the author; you can download the fixed version 1.0.3 from &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2059&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim.org&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-15T17:43:57.760" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="17980" PostTypeId="2" ParentId="17974" CreationDate="2018-11-15T17:46:11.717" Score="2" Body="&lt;p&gt;I don't like loops -- they are slow and a pain to debug as there is no &quot;continue until the end of the current loop&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo map(range(len(list1)), 'list1[v:val].list2[v:val]')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: a &lt;code&gt;zip()&lt;/code&gt; function is missing, but it can be emulated if we produce a range of indexes into both arrays. We could also simply transform a copy of &lt;code&gt;list1&lt;/code&gt; and use &lt;code&gt;v:key&lt;/code&gt; (Vim 7.2.???) for looping over indices, but I prefer &lt;code&gt;range(len(list1))&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-11-15T17:51:21.120" LastActivityDate="2018-11-15T17:51:21.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17981" PostTypeId="2" ParentId="17972" CreationDate="2018-11-16T07:40:19.607" Score="2" Body="&lt;p&gt;I don't have &lt;code&gt;$LINES&lt;/code&gt; defined in my Vim environment, and I'm using Zsh, so it's probably not exported to child processes. However, to make this work you need to remove quotes and escape spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:FZF --preview=head\ -10\ {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Making &lt;code&gt;$LINES&lt;/code&gt; working is more tricky, for basic you could probably add &lt;code&gt;export LINES&lt;/code&gt; to your &lt;code&gt;.zshrc&lt;/code&gt;, but this won't handle situations, when you resize your terminal window, exported value will still be on the original value. Also, preview window is much smaller than terminal, so this will still be truncated to the size of the preview window.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2018-11-16T07:40:19.607" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17982" PostTypeId="1" AcceptedAnswerId="17983" CreationDate="2018-11-16T07:42:41.757" Score="4" ViewCount="596" Body="&lt;p&gt;I want to set an option to a string containing full path of current working directory. For example&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set tags=getcwd().&amp;quot;\tags&amp;quot;    &amp;quot; retrieve the full path of the tags file in current working directory &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, vim seems only accept expansion for &lt;code&gt;let&lt;/code&gt; variables, it don't expand the function in &lt;code&gt;set&lt;/code&gt; context.&lt;/p&gt;&#xA;&lt;p&gt;Is there way to achieve expand things in &lt;code&gt;set&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="19650" LastEditorUserId="18609" LastEditDate="2020-10-16T16:25:16.273" LastActivityDate="2020-10-16T16:25:16.273" Title="How can I use the return value of a function in a :set command?" Tags="|variables|set|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17983" PostTypeId="2" ParentId="17982" CreationDate="2018-11-16T08:32:27.770" Score="11" Body="&lt;p&gt;You can use &lt;code&gt;:let&lt;/code&gt; with Vim options as well, by prefixing the option name with a &lt;code&gt;&amp;amp;&lt;/code&gt; sigil; cp. &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#%3Alet-option&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :let-option&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;tags = getcwd().'\tags'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; that the literal string must be in &lt;strong&gt;single quotes&lt;/strong&gt; (or the backslash doubled); else, the &lt;code&gt;\t&lt;/code&gt; will expand to a tab character.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The other way would be by using &lt;code&gt;:execute&lt;/code&gt;, but then you'd have to take care of escaping, so this is not recommended:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'set tags='.escape(getcwd(), '\ ').'\tags'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-16T08:32:27.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17984" PostTypeId="1" CreationDate="2018-11-16T16:40:39.153" Score="7" ViewCount="4980" Body="&lt;p&gt;Vim's new &lt;code&gt;:terminal&lt;/code&gt; feature is pretty neat, but when I run something like a rails server, I want to be able to clear logging output every now and then.&lt;/p&gt;&#xA;&lt;p&gt;The usual methods in a non-vim term window don't seem to work, like &lt;code&gt;&amp;lt;D-k&amp;gt;&lt;/code&gt; (&lt;kbd&gt;Cmd&lt;/kbd&gt;-&lt;kbd&gt;k&lt;/kbd&gt; clears scrollback in Terminal.app on macOS), etc.&lt;/p&gt;&#xA;&lt;p&gt;I've tried &lt;code&gt;&amp;lt;C-w&amp;gt;:Clear&amp;lt;CR&amp;gt;&lt;/code&gt;, but it seems to be for something different as well.&lt;/p&gt;&#xA;&lt;p&gt;If I weren't running a rails server, I could just type &lt;code&gt;clear&lt;/code&gt; in the terminal.&lt;/p&gt;&#xA;&lt;p&gt;I glanced through &lt;code&gt;:help :term&lt;/code&gt;, and I'm not seeing what I want jump out at me.&lt;/p&gt;&#xA;" OwnerUserId="8483" LastEditorUserId="10604" LastEditDate="2023-03-29T19:18:56.610" LastActivityDate="2023-03-29T19:18:56.610" Title="Clear Vim Terminal window" Tags="|terminal|" AnswerCount="4" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="17985" PostTypeId="2" ParentId="15140" CreationDate="2018-11-16T18:38:00.907" Score="9" Body="&lt;p&gt;Since you're using the &lt;code&gt;s&lt;/code&gt; command, you could simply use the &lt;code&gt;e&lt;/code&gt; flag. From &lt;code&gt;:help :s_flags&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the search pattern fails, do not issue an error message and, in particular, continue in maps as if no error occurred.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, each of the &lt;code&gt;s&lt;/code&gt; commands in your macro would look something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/bar/food/e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12641" LastActivityDate="2018-11-16T18:38:00.907" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17986" PostTypeId="1" CreationDate="2018-11-16T20:32:56.280" Score="4" ViewCount="408" Body="&lt;p&gt;I have a text file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ge-0/0/45.0,First-Floor-Security,13&#xA;,Voice_First_Floor,18&#xA;ge-0/0/46.0,First-Floor-Security,13&#xA;,Voice_First_Floor,18&#xA;ge-0/0/47.0,AV-Media,155&#xA;,Building-Automation,75&#xA;,CobraNet,156&#xA;,First-Floor-Management,19&#xA;,First-Floor-Pavilion,11&#xA;,First-Floor-Security,13&#xA;,First-Floor-Users,10&#xA;,Guest-Wired,3&#xA;,Video,150&#xA;,Voice_First_Floor,18&#xA;,Wireless-Corp,410&#xA;,Wireless-Guest,420&#xA;,Wireless-Mtg,400&#xA;,Wireless-Voice,430&#xA;ge-1/0/0.0,First-Floor-Users,10&#xA;,Voice_First_Floor,18&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I looking for a command to grab the first field of the line above and insert it into the line below.  So for example, my resulting file would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ge-0/0/45.0,First-Floor-Security,13&#xA;ge-0/0/45.0,Voice_First_Floor,18&#xA;ge-0/0/46.0,First-Floor-Security,13&#xA;ge-0/0/46.0,Voice_First_Floor,18&#xA;ge-0/0/47.0,AV-Media,155&#xA;ge-0/0/47.0,Building-Automation,75&#xA;ge-0/0/47.0,CobraNet,156&#xA;ge-0/0/47.0,First-Floor-Management,19&#xA;ge-0/0/47.0,First-Floor-Pavilion,11&#xA;ge-0/0/47.0,First-Floor-Security,13&#xA;ge-0/0/47.0,First-Floor-Users,10&#xA;ge-0/0/47.0,Guest-Wired,3&#xA;ge-0/0/47.0,Video,150&#xA;ge-0/0/47.0,Voice_First_Floor,18&#xA;ge-0/0/47.0,Wireless-Corp,410&#xA;ge-0/0/47.0,Wireless-Guest,420&#xA;ge-0/0/47.0,Wireless-Mtg,400&#xA;ge-0/0/47.0,Wireless-Voice,430&#xA;ge-1/0/0.0,First-Floor-Users,10&#xA;ge-1/0/0.0,Voice_First_Floor,18&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have some understanding about grouping and backreferences but cannot seem to find a way to search, create a backreference, and then use that backreference in a different line.  Is this possible?  If so, would you please point me in the right direction?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Drew&lt;/p&gt;&#xA;" OwnerUserId="19852" LastActivityDate="2018-11-16T20:57:33.153" Title="Replace With Text From The Line Above?" Tags="|search|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17987" PostTypeId="2" ParentId="17986" CreationDate="2018-11-16T20:57:33.153" Score="4" Body="&lt;p&gt;Here's a command you could use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^,/norm 0kyt,jP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses the &quot;global&quot; command. Here's what it basically does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/&amp;lt;regex&amp;gt;/&amp;lt;command&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will run &quot;command&quot; on every single line that matches the &quot;regex&quot;. Our regex is pretty simple: Any line that starts with (&lt;code&gt;^&lt;/code&gt;) a comma (&lt;code&gt;,&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;norm 0kyt,jP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;norm&lt;/code&gt; means &quot;run these characters like I typed them in normal mode&quot;. So &lt;code&gt;0k&lt;/code&gt; goes to the beginning of the last line with a comma. &lt;code&gt;yt,&lt;/code&gt; is &lt;strong&gt;y&lt;/strong&gt;ank un&lt;strong&gt;t&lt;/strong&gt;il &lt;code&gt;,&lt;/code&gt;. &lt;code&gt;jP&lt;/code&gt; goes back to the line we matched on and pastes from the clipboard before the comma.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conveniently, this runs each line in order, so it works on multiple entryless lines in a row, such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;,Building-Automation,75&#xA;,CobraNet,156&#xA;,First-Floor-Management,19&#xA;,First-Floor-Pavilion,11&#xA;,First-Floor-Security,13&#xA;,First-Floor-Users,10&#xA;,Guest-Wired,3&#xA;,Video,150&#xA;,Voice_First_Floor,18&#xA;,Wireless-Corp,410&#xA;,Wireless-Guest,420&#xA;,Wireless-Mtg,400&#xA;,Wireless-Voice,430&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because on the &quot;building automation&quot; line, it will grab the &quot;ge-0/0/47.0&quot; from the previous line, and then paste it on this line. Then, on the &quot;cobraNet&quot; line, it will grab the &lt;em&gt;new&lt;/em&gt; &quot;ge-0/0/47.0&quot; from the &quot;building automation&quot; line, etc.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-11-16T20:57:33.153" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17988" PostTypeId="1" AcceptedAnswerId="18012" CreationDate="2018-11-16T21:25:11.043" Score="2" ViewCount="356" Body="&lt;p&gt;Part of a macro I'm writing deletes any blank lines, and then does some more work (joining the expected two remaining lines and then appending to them). Simplified version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @m=':g/^$/d^MggJA ^['&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Where of course ^M and ^[ are the CR and ESC literals.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, sometimes my input doesn't include any blank lines, and I can't get the macro to proceed when the &lt;code&gt;:g&lt;/code&gt; command fails:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Pattern not found: ^$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Same happens with different message when I try &lt;code&gt;:v/./d&lt;/code&gt; instead: &lt;code&gt;Pattern found in every line: .&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got my hopes up when I found &lt;a href=&quot;https://vi.stackexchange.com/questions/15140/how-to-force-macro-keep-running-even-pattern-is-not-found/&quot;&gt;How to force macro keep running even pattern is not found?&lt;/a&gt;, where the answers suggest using &lt;code&gt;:try&lt;/code&gt;, but this doesn't seem to work with &lt;code&gt;:g&lt;/code&gt; or &lt;code&gt;:v&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @m=':try|:g/^$/d|catch||endtry^MggJA ^['&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this is run on input with no blank lines, it leaves the editor in command-line mode and I have to type &lt;code&gt;endtry&lt;/code&gt; to get out of it. I try adding an additional &lt;code&gt;endtry&lt;/code&gt; to the macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @m=':try|:g/^$/d|catch||endtry^Mendtry^MggJA ^['&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works for input with no blank lines. But when I go back and try this on input that contains blank lines, I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E603: :catch without :try&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any hope to be had here?&lt;/p&gt;&#xA;" OwnerUserId="12641" LastActivityDate="2018-11-19T17:09:24.747" Title="How to ignore a failed :g (global) command in a macro?" Tags="|macro|global-command|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17989" PostTypeId="1" AcceptedAnswerId="17990" CreationDate="2018-11-17T00:45:04.603" Score="1" ViewCount="38" Body="&lt;p&gt;In my file, I have many instances of &lt;code&gt;grid[X][Y]&lt;/code&gt; where &lt;code&gt;X&lt;/code&gt; and &lt;code&gt;Y&lt;/code&gt; are variables. I would like to swap all instances to &lt;code&gt;grid[Y][X]&lt;/code&gt; (preferably one by one so I can check them).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples (especially note the second example):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;grid[row][col]&#xA;grid[row + 1][col]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Swap to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;grid[col][row]&#xA;grid[col][row + 1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;X&lt;/code&gt;/&lt;code&gt;Y&lt;/code&gt; are guarenteed to contain only A-Z, a-z, 1-9, + - (if that helps)&lt;/p&gt;&#xA;" OwnerUserId="17770" LastEditorUserId="17770" LastEditDate="2018-11-17T00:51:36.803" LastActivityDate="2018-11-17T06:16:44.240" Title="Swap grid[X][Y] to grid[Y][X] in full file" Tags="|regular-expression|search|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17990" PostTypeId="2" ParentId="17989" CreationDate="2018-11-17T01:09:47.017" Score="1" Body="&lt;p&gt;This should do what you want&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/\[\(.\+\)\]\[\(.\+\)\]/[\2][\1]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And yes, I guess all these toothpicks are really needed.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-11-17T01:09:47.017" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17991" PostTypeId="2" ParentId="17974" CreationDate="2018-11-17T02:09:48.523" Score="1" Body="&lt;p&gt;Because you want to &quot;:echo result&quot;, my way would be straightforward:&#xA;&lt;code&gt;&#xA;:let result = list1&#xA;:map(result, 'result[v:key].list2[v:key]')&#xA;:echo result&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Because map() does in-place replacement, it requires a little trick for one-liner, like @LucHermitte's answer.)&lt;/p&gt;&#xA;" OwnerUserId="19850" LastActivityDate="2018-11-17T02:09:48.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17992" PostTypeId="2" ParentId="17984" CreationDate="2018-11-17T06:07:24.963" Score="0" Body="&lt;p&gt;Going through Vim's terminal.txt, I don't think you have a chance to clear the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's because Vim doesn't do anything about &lt;code&gt;&amp;lt;c-l&amp;gt;&lt;/code&gt;, just passing it as well as other typed keys to the running job, like bash or rails server. (when your focus is in the window)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;c-w&amp;gt;:clear&lt;/code&gt; doesn't do the trick, either. The command is abbreviation of &lt;code&gt;:clearjumps&lt;/code&gt; for newer Vim versions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For normal terminal, like gnome-terminal or mac's terminal, it's the terminal dealing with your &lt;code&gt;&amp;lt;c-l&amp;gt; or &amp;lt;cmd-l&amp;gt;, &amp;lt;cmd-k&amp;gt;&lt;/code&gt;. Vim's terminal looks not doing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I happened to try out a workaround. You can try it for your environment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:tmap &amp;lt;c-l&amp;gt; &amp;lt;c-w&amp;gt;s&amp;lt;c-w&amp;gt;c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;tmap is mapping specific for terminal job mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;s&lt;/code&gt; creates a new window, and when &lt;code&gt;&amp;lt;c-w&amp;gt;c&lt;/code&gt; closes it and gets back, the terminal is cleared.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19850" LastEditorUserId="19850" LastEditDate="2018-11-17T07:08:06.673" LastActivityDate="2018-11-17T07:08:06.673" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17993" PostTypeId="2" ParentId="17989" CreationDate="2018-11-17T06:16:44.240" Score="1" Body="&lt;p&gt;This does what you want&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(\[.+\])(\[.+\])/\2\1/gc&#xA;    \v                         Very magic mode&#xA;      (\[.+\])                 First group of [...]&#xA;              (\[.+\])         Second group of [...]&#xA;                            g  Global flag - substitute every instance on each line&#xA;                             c Ask flag - ask before each occurence&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-11-17T06:16:44.240" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17995" PostTypeId="2" ParentId="17988" CreationDate="2018-11-17T10:25:53.793" Score="3" Body="&lt;p&gt;It's at this point where you ought to consider alternatives to using a macro. For instance, a function and mapping. Off the top of my head...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! DelEmptyAndStuff()&#xA;    if search('^$', 'n') != 0&#xA;        exec 'g//d'&#xA;    endif&#xA;    exec 'norm! ggJA '&#xA;endfunc&#xA;&#xA;nnoremap \m :call DelEmptyAndStuff()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note: without a pattern &lt;code&gt;:global&lt;/code&gt; will use the last used pattern. That's why &lt;code&gt;g//d&lt;/code&gt; works here.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even a mapping alone with the above code stuffed in it will be easier/cleaner than the equivalent macro...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap \m if search('^$', 'n') != 0 \| exec 'g//d' \| endif \| norm! ggJA &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, okay, let's say you are &quot;contractually bound&quot; to use a macro. We could use a modified version of the above code...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @m=&quot;:if search('^$', 'n') != 0^Mexec 'g//d'^Mendif^M^[ggJA ^[&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not pretty but since &quot;the halt on error&quot; behavior of macros probably isn't meant to be defeated...at least this works.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-11-17T10:43:05.620" LastActivityDate="2018-11-17T10:43:05.620" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17996" PostTypeId="1" AcceptedAnswerId="17997" CreationDate="2018-11-17T11:37:55.550" Score="0" ViewCount="209" Body="&lt;p&gt;I have following xml file:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-xml prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&#xA;&amp;lt;graph id=&quot;G&quot; edgedefault=&quot;undirected&quot;&amp;gt;&#xA;    &amp;lt;edge id=&quot;e6&quot; source=&quot;n5&quot; target=&quot;n4&quot;&amp;gt; &amp;lt;data key=&quot;d1&quot;&amp;gt;1.1&amp;lt;/data&amp;gt; &amp;lt;data key=&quot;d2&quot;&amp;gt;1.1&amp;lt;/data&amp;gt; &amp;lt;/edge&amp;gt;&#xA;&amp;lt;/graph&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have reconfigured &lt;code&gt;formatprg&lt;/code&gt; for xml in &lt;code&gt;~/.vim/after/ftplugin/xml.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal formatprg=tidy\ -xml\ -quiet\ --indent\ auto\ --tidy-mark\ no\ --indent-spaces\ 2\ --vertical-space\ yes\ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I now press &lt;code&gt;gqq&lt;/code&gt; on line 3, I get&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-xml prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&#xA;&amp;lt;graph id=&quot;G&quot; edgedefault=&quot;undirected&quot;&amp;gt;&#xA;&amp;lt;edge id=&quot;e6&quot; source=&quot;n5&quot; target=&quot;n4&quot;&amp;gt;&#xA;  &amp;lt;data key=&quot;d1&quot;&amp;gt;1.1&amp;lt;/data&amp;gt;&#xA;  &amp;lt;data key=&quot;d2&quot;&amp;gt;1.1&amp;lt;/data&amp;gt;&#xA;&amp;lt;/edge&amp;gt;&#xA;&amp;lt;/graph&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to fix the indentation automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first try was &lt;code&gt;:'[,']norm =&lt;/code&gt; which does not work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;=at&lt;/code&gt; does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I want to extend &lt;code&gt;gq&amp;lt;text object/motion&amp;gt;&lt;/code&gt; and &lt;code&gt;gqq&lt;/code&gt; so re-indentation (&lt;code&gt;=&lt;/code&gt;, &lt;code&gt;indentexpr&lt;/code&gt;) is done on the newly formatted lines.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-11-17T15:40:02.567" LastActivityDate="2018-11-17T15:40:02.567" Title="Automatically reindent lines filtered through formatprg" Tags="|key-bindings|indentation|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17997" PostTypeId="2" ParentId="17996" CreationDate="2018-11-17T12:51:47.817" Score="0" Body="&lt;h2&gt;Linewise &lt;code&gt;gqq&lt;/code&gt; with support for counts&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have come up with following solution for the linewise operator &lt;code&gt;gqq&lt;/code&gt; by putting&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-viml prettyprint-override&quot;&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; gqq gqq$='[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into &lt;code&gt;~/.vim/after/ftplugin/xml.vim&lt;/code&gt; (the &lt;code&gt;$&lt;/code&gt; was important). Counts work already:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-xml prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&#xA;&amp;lt;graph id=&quot;G&quot; edgedefault=&quot;undirected&quot;&amp;gt;&#xA;    &amp;lt;edge id=&quot;e6&quot; source=&quot;n5&quot; target=&quot;n4&quot;&amp;gt; &amp;lt;data key=&quot;d1&quot;&amp;gt;1.1&amp;lt;/data&amp;gt; &amp;lt;data key=&quot;d2&quot;&amp;gt;1.1&amp;lt;/data&amp;gt; &amp;lt;/edge&amp;gt;&#xA;    &amp;lt;edge id=&quot;e7&quot; source=&quot;n3&quot; target=&quot;n4&quot;&amp;gt; &amp;lt;data key=&quot;d1&quot;&amp;gt;1.1&amp;lt;/data&amp;gt; &amp;lt;data key=&quot;d2&quot;&amp;gt;1.1&amp;lt;/data&amp;gt; &amp;lt;/edge&amp;gt;&#xA;&amp;lt;/graph&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again cursor on line 3 and then press &lt;code&gt;2gqq&lt;/code&gt;. The result is &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-xml prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&#xA;&amp;lt;graph id=&quot;G&quot; edgedefault=&quot;undirected&quot;&amp;gt;&#xA;    &amp;lt;edge id=&quot;e6&quot; source=&quot;n5&quot; target=&quot;n4&quot;&amp;gt;&#xA;        &amp;lt;data key=&quot;d1&quot;&amp;gt;1.1&amp;lt;/data&amp;gt;&#xA;        &amp;lt;data key=&quot;d2&quot;&amp;gt;1.1&amp;lt;/data&amp;gt;&#xA;    &amp;lt;/edge&amp;gt;&#xA;    &amp;lt;edge id=&quot;e7&quot; source=&quot;n3&quot; target=&quot;n4&quot;&amp;gt;&#xA;        &amp;lt;data key=&quot;d1&quot;&amp;gt;1.1&amp;lt;/data&amp;gt;&#xA;        &amp;lt;data key=&quot;d2&quot;&amp;gt;1.1&amp;lt;/data&amp;gt;&#xA;    &amp;lt;/edge&amp;gt;&#xA;&amp;lt;/graph&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;&lt;a href=&quot;https://github.com/kana/vim-operator-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim-operator-user&lt;/a&gt; re-mappings of &lt;code&gt;gq&amp;lt;text object/motion&amp;gt;&lt;/code&gt; and &lt;code&gt;{VISUAL}gq&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Install the plugin &lt;a href=&quot;https://github.com/kana/vim-operator-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-operator-user&lt;/a&gt; and put &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-viml prettyprint-override&quot;&gt;&lt;code&gt;map &amp;lt;buffer&amp;gt; gq &amp;lt;Plug&amp;gt;(operator-myformat)&#xA;call operator#user#define('myformat', 'Op_format_and_reindent')&#xA;function! Op_format_and_reindent(motion_wiseness)&#xA;  exe &quot;normal! '[V']gq$='[&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into &lt;code&gt;~/.vim/after/ftplugin/xml.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should also work for other files with a &lt;code&gt;'formatprg'&lt;/code&gt; and the desire to reindent automatically afterwards.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-11-17T14:56:15.367" LastActivityDate="2018-11-17T14:56:15.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17998" PostTypeId="1" AcceptedAnswerId="18000" CreationDate="2018-11-17T13:33:13.177" Score="0" ViewCount="97" Body="&lt;p&gt;I have tags (generated with &lt;code&gt;ctag&lt;/code&gt;) of the form&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&#xA;eq:local-canonical-form&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;because of the &lt;code&gt;:&lt;/code&gt; I cannot use &lt;code&gt;eq:loc&amp;lt;c-x&amp;gt;&amp;lt;c-]&amp;gt;&lt;/code&gt; to expand the tag.&lt;/li&gt;&#xA;&lt;li&gt;because of the &lt;code&gt;:&lt;/code&gt; and the &lt;code&gt;-&lt;/code&gt; I cannot use &lt;code&gt;&amp;lt;c-]&amp;gt;&lt;/code&gt; to jump to its definition...&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any ideas how to overcome this?&lt;/p&gt;&#xA;" OwnerUserId="8648" LastActivityDate="2018-11-17T16:51:58.127" Title="non-word characters in tags" Tags="|autocompletion|ctags|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="17999" PostTypeId="1" CreationDate="2018-11-17T14:06:10.613" Score="0" ViewCount="47" Body="&lt;p&gt;I have a number of aliased commands in my .bashrc and they work fine on the command line. However, if I use them in Vim, they do not work. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!mycommand&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;results in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/binbash: mycommand: command not found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the explanation?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2018-11-17T14:06:10.613" Title="aliased commands don't work with the shell ex command?" Tags="|shell|" AnswerCount="0" CommentCount="3" ClosedDate="2018-11-17T18:26:50.133" ContentLicense="CC BY-SA 4.0" />
  <row Id="18000" PostTypeId="2" ParentId="17998" CreationDate="2018-11-17T16:07:24.570" Score="1" Body="&lt;p&gt;By default, in vim (and most other editors) &lt;code&gt;:&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt; separate words. This means word/tag completion do not complete &lt;code&gt;eq:loc&amp;lt;c-x&amp;gt;&amp;lt;c-]&amp;gt;&lt;/code&gt; but only &lt;code&gt;loc&amp;lt;c-x&amp;gt;&amp;lt;c-]&amp;gt;&lt;/code&gt;. If there is no tag &lt;code&gt;loc...&lt;/code&gt;, nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can fix this by placing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal iskeyword+=:&#xA;setlocal iskeyword+=-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;~/.vim/after/ftplugin/tex.vim&lt;/code&gt; and/or &lt;code&gt;~/.vim/after/ftplugin/rmd.vim&lt;/code&gt; (rmd=rmarkdown).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this might have surprising side effects. For instance, if you have the equation &lt;code&gt;a-b:2&lt;/code&gt;, it is now treated as a single word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The situation in latex is known to be complicated:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can't get all LaTeX strings right using iskeyword, that is because the iskeyword works on characters and some characters may have different meanings in different contexts. (from &lt;em&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/12117/iskeyword-for-latex&quot;&gt;iskeyword for latex&lt;/a&gt;&lt;/em&gt;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Someone already asked the question &lt;em&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/13830/iskeyword-with-context&quot;&gt;iskeyword with context&lt;/a&gt;&lt;/em&gt;. But the answer is not affirmative to solve this issue.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-11-17T16:51:58.127" LastActivityDate="2018-11-17T16:51:58.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18001" PostTypeId="1" AcceptedAnswerId="18009" CreationDate="2018-11-17T18:53:34.037" Score="8" ViewCount="4797" Body="&lt;p&gt;I've been using vi for 40 years.  A week ago I upgraded; Disaster struck!&#xA;The upgrade was to&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar  4 2018 23:38:28)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I run this on xterm under Cygwin (under Windows 10).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that I can insert text from the clipboard by pressing, e.g. 'a' followed by a middle-click of the mouse.  Fine.  That still works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for the last three decades, when in vi command mode I can execute a string of vi commands from the clipboard by pressing middle-click. THAT NO LONGER WORKS.  If vi is not in insert mode it immediately goes into insert mode (as if 'a' were pressed) when I middle-click to paste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's happening?  What's the workaround?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On another board, someone mentioned commands like&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:set paste&lt;br&gt;&#xA;     :set nopaste&lt;br&gt;&#xA;     :set mouse=&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't know what those commands are supposed to do, but none of them solves my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="19858" LastEditorUserId="1292" LastEditDate="2018-11-17T20:36:41.520" LastActivityDate="2018-11-19T18:58:50.830" Title="Why can't I paste commands into vi?" Tags="|vimrc|cut-copy-paste|autocmd|visual-mode|microsoft-windows|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18002" PostTypeId="2" ParentId="18001" CreationDate="2018-11-17T19:57:29.020" Score="-2" Body="&lt;pre&gt;&lt;code&gt;q:&quot;+p&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping should paste from your clipboard and execute. Map it to whatever you want and you are done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way the answer you posted seems to be for an entirely different purpose, and the first two lines contradict, so one of them is redundant.&lt;/p&gt;&#xA;" OwnerUserId="19752" LastEditorUserId="51" LastEditDate="2018-11-18T23:24:51.810" LastActivityDate="2018-11-18T23:24:51.810" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18003" PostTypeId="2" ParentId="17903" CreationDate="2018-11-17T21:52:33.123" Score="0" Body="&lt;p&gt;Issue is solved. It took a couple lines in the pug syntax file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding the third line here for template strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region  pugJavascriptString start=+&quot;+  skip=+\\\(&quot;\|$\)+  end=+&quot;\|$+ contained&#xA;syn region  pugJavascriptString start=+'+  skip=+\\\('\|$\)+  end=+'\|$+ contained&#xA;&quot; TODO my patch for template strings&#xA;syn region  pugJavascriptString start=+`+  skip=+\\\(`\|$\)+  end=+`\|$+ contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the single line for single lines of JS: &lt;code&gt;syn region pugJavascriptLine start=/^\s*-/ end=/$/ contains=@htmlJavascript&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Github issues here: &lt;a href=&quot;https://github.com/digitaltoad/vim-pug/issues/109&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/digitaltoad/vim-pug/issues/109&lt;/a&gt;&#xA;and here: &lt;a href=&quot;https://github.com/digitaltoad/vim-pug/issues/108&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/digitaltoad/vim-pug/issues/108&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1596" LastActivityDate="2018-11-17T21:52:33.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18004" PostTypeId="1" AcceptedAnswerId="18005" CreationDate="2018-11-18T04:03:47.283" Score="26" ViewCount="17789" Body="&lt;p&gt;What is the simplest way to rename variables in Vim, without adding any new packages? Is there a way without using regexps, too?&lt;/p&gt;&#xA;" OwnerUserId="5224" LastEditorUserId="5224" LastEditDate="2018-11-18T04:34:25.003" LastActivityDate="2020-10-27T23:24:51.090" Title="Renaming variables" Tags="|refactor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18005" PostTypeId="2" ParentId="18004" CreationDate="2018-11-18T04:04:02.510" Score="38" Body="&lt;p&gt;Place cursor at name to rename and type&lt;/p&gt;&#xA;&lt;p&gt;&lt;kbd&gt;gd&lt;/kbd&gt; (or &lt;kbd&gt;gD&lt;/kbd&gt; if you're renaming a global variable).&lt;/p&gt;&#xA;&lt;pre&gt;gd         Goto local Declaration.  When the cursor is on a local&#xA;            variable, this command will jump to its declaration.&#xA;            First Vim searches for the start of the current&#xA;            function, just like &quot;[[&quot;.  If it is not found the&#xA;            search stops in line 1.  If it is found, Vim goes back&#xA;            until a blank line is found.  From this position Vim&#xA;            searches for the keyword under the cursor, like with&#xA;            &quot;*&quot;, but lines that look like a comment are ignored&#xA;            (see 'comments' option).&#xA;            Note that this is not guaranteed to work, Vim does not&#xA;            really check the syntax, it only searches for a match&#xA;            with the keyword.  If included files also need to be&#xA;            searched use the commands listed in |include-search|.&#xA;            After this command |n| searches forward for the next&#xA;            match (not backward).&#xA;            {not in Vi}&#xA;&#xA;gD          Goto global Declaration.  When the cursor is on a&#xA;            global variable that is defined in the file, this&#xA;            command will jump to its declaration.  This works just&#xA;            like &quot;gd&quot;, except that the search for the keyword&#xA;            always starts in line 1.  {not in Vi}&lt;/pre&gt;&#xA;&lt;p&gt;Then&lt;/p&gt;&#xA;&lt;p&gt;&lt;kbd&gt;c&lt;/kbd&gt; (change) + &lt;kbd&gt;gn&lt;/kbd&gt; new_name &lt;kbd&gt;esc&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;pre&gt;gn         Search forward for the last used search pattern, like&#xA;            with `n`, and start Visual mode to select the match.&#xA;            If the cursor is on the match, visually selects it.&#xA;            If an operator is pending, operates on the match.&#xA;            E.g., &quot;dgn&quot; deletes the text of the next match.&#xA;            If Visual mode is active, extends the selection&#xA;            until the end of the next match.&lt;/pre&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;p&gt;&lt;kbd&gt;.&lt;/kbd&gt; (repeat) one or more times to rename next occurrence(s)&lt;/p&gt;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&lt;p&gt;&lt;kbd&gt;:%norm .&lt;/kbd&gt; to rename all occurrences in the buffer at once.&lt;/p&gt;&#xA;" OwnerUserId="5224" LastEditorUserId="5224" LastEditDate="2020-10-27T23:24:51.090" LastActivityDate="2020-10-27T23:24:51.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18006" PostTypeId="1" CreationDate="2018-11-18T08:19:59.910" Score="0" ViewCount="49" Body="&lt;p&gt;I'm using vim for C programming and I have a question about jumping to the next/previous character. I can use &lt;kbd&gt;f&lt;/kbd&gt; or &lt;kbd&gt;F&lt;/kbd&gt; to jump to the next or previous character correspondingly. But this does not work with multiline. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I'm trying to solve is to jump to the previous &lt;code&gt;{&lt;/code&gt; or next &lt;code&gt;}&lt;/code&gt; to quickly get to the function signature I'm currently looking at.&lt;/p&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2018-11-18T08:19:59.910" Title="Multiline search like with f and F" Tags="|vimrc|normal-mode|" AnswerCount="0" CommentCount="5" ClosedDate="2018-11-18T09:26:09.227" ContentLicense="CC BY-SA 4.0" />
  <row Id="18007" PostTypeId="2" ParentId="7388" CreationDate="2018-11-18T12:35:53.850" Score="1" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a = system('date +\%Y\%m\%d')[:-2]&#xA;:'&amp;lt;,'&amp;gt;g/XXXX/s/XXXX/\=@a/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first line saves the output of &lt;code&gt;date&lt;/code&gt; command into register a, with the ending newline removed.&lt;/li&gt;&#xA;&lt;li&gt;The second line globally inspect your selection and mark the lines containing &lt;code&gt;XXXX&lt;/code&gt; (&lt;code&gt;g/XXXX/&lt;/code&gt;), and&lt;/li&gt;&#xA;&lt;li&gt;replace all the instances of the &lt;code&gt;XXXX&lt;/code&gt; with the content of register a (&lt;code&gt;s/XXXX/\=@a/g&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h let-@&lt;/code&gt; and &lt;code&gt;:h :global&lt;/code&gt; as well as the &quot;Sublist&quot; section in &lt;code&gt;:h list-index&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="19850" LastActivityDate="2018-11-18T12:35:53.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18008" PostTypeId="2" ParentId="7388" CreationDate="2018-11-18T13:35:00.310" Score="0" Body="&lt;h2&gt;Plugin: &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#VIS&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Visual Block Commands&lt;/em&gt;&lt;/a&gt; (vis) by DrChip&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Installation of &lt;code&gt;vis.vba.gz&lt;/code&gt; and dependency &lt;code&gt;cecutil.vba.gz&lt;/code&gt; into vim8 packpath&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# shell brace expansion (bash &amp;gt;=3.0, zsh&amp;gt;=2.6)&#xA;$ mkdir -p ~/.vim/pack/manual/start/{vis,cecutil}&#xA;$ vim http://www.drchip.org/astronaut/vim/vbafiles/vis.vba.gz&#xA;:UseVimball ~/.vim/pack/manual/start/vis&#xA;:e http://www.drchip.org/astronaut/vim/vbafiles/cecutil.vba.gz&#xA;:UseVimball ~/.vim/pack/manual/start/cecutil&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OP example becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;B !date +\%Y\%m\%d &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-11-18T13:46:41.313" LastActivityDate="2018-11-18T13:46:41.313" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18009" PostTypeId="2" ParentId="18001" CreationDate="2018-11-18T14:58:03.070" Score="9" Body="&lt;p&gt;&lt;code&gt;set mouse=&lt;/code&gt; is the fix for the problem, with &lt;code&gt;set t_BE=&lt;/code&gt; substituted in an &lt;em&gt;xterm&lt;/em&gt; environment.  The 'bug' these fixes solve was actually intended as a 'feature': creating an obstacle to pasting vi commands would be good if malicious code were somehow inserted onto user's clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kudos to a guy named Elijah, on another message-board, who researched and solved this problem.&lt;/p&gt;&#xA;" OwnerUserId="19858" LastEditorUserId="19858" LastEditDate="2018-11-19T18:58:50.830" LastActivityDate="2018-11-19T18:58:50.830" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18010" PostTypeId="1" CreationDate="2018-11-19T13:24:41.233" Score="0" ViewCount="119" Body="&lt;p&gt;I am using Neovim on Windows using &lt;a href=&quot;http://cmder.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cmder&lt;/a&gt; console emulator. I find that using &lt;code&gt;[NUM]&amp;lt;Ctrl-6&amp;gt;&lt;/code&gt; to change to buffer &lt;code&gt;[NUM]&lt;/code&gt; does not work on Windows. Following discussions &lt;a href=&quot;https://github.com/onivim/oni/issues/2002&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. I have set up a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremp &amp;lt;C-6&amp;gt; &amp;lt;C-^&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I still can not switch buffers using &lt;code&gt;Ctrl-6&lt;/code&gt;. Any ideas what is wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: After going through the &lt;a href=&quot;https://vi.stackexchange.com/questions/7722/how-to-debug-a-mapping&quot;&gt;post here&lt;/a&gt;. I find that &lt;code&gt;&amp;lt;C-6&amp;gt;&lt;/code&gt; is correctly mapped to &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;. So the reason may be that some application intercept &lt;code&gt;&amp;lt;C-6&amp;gt;&lt;/code&gt; before vim can receive it. But it is hard to find the real cause.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastEditorUserId="15292" LastEditDate="2019-01-10T13:23:51.453" LastActivityDate="2019-02-09T16:03:05.677" Title="mapping does not work even if I have set it up in config file" Tags="|key-bindings|neovim|microsoft-windows|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18011" PostTypeId="1" AcceptedAnswerId="18013" CreationDate="2018-11-19T15:24:00.573" Score="1" ViewCount="554" Body="&lt;p&gt;How could VIM (script?) insert ^L (page break) and /r  on an empty line, automatically after every 30 Lines OR 1800 characters while writing? Any ideas? &lt;/p&gt;&#xA;" OwnerUserId="19878" LastActivityDate="2018-11-21T09:26:28.863" Title="Insert Page break ^L automatically after specific number of lines/characters?" Tags="|vimscript|insert-mode|line-breaks|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18012" PostTypeId="2" ParentId="17988" CreationDate="2018-11-19T17:09:24.747" Score="4" Body="&lt;p&gt;I agree with @BLayer that you're crossing into territory where putting this into a function would be a good idea. A nice short way to suppress errors is &lt;code&gt;:silent!&lt;/code&gt; (with &lt;code&gt;!&lt;/code&gt;). It'll work in your macro like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @m=':silent! g/^$/d^MggJA ^['&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is shorter than &lt;code&gt;try...catch&lt;/code&gt;; one side effect is that it silences &lt;em&gt;any&lt;/em&gt; output (errors or normal output). With &lt;code&gt;:global&lt;/code&gt;, that shouldn't be a problem; elsewhere, it can be avoided via the (somewhat funny) &lt;code&gt;:silent! unsilent {cmd}&lt;/code&gt; expression.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-19T17:09:24.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18013" PostTypeId="2" ParentId="18011" CreationDate="2018-11-19T17:24:19.703" Score="1" Body="&lt;p&gt;Your idea might not work how you want it to, because if you go back and earlier parts of your file, your page breaks are going to end up in the wrong places.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think a better idea would be to set up an autocommand that resets the page breaks whenever you save the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a quick one that sets them every 30 lines whenever you save a file with a  &lt;code&gt;.txt&lt;/code&gt; extension. If you also want it to work for every 1800 characters you're going to need to write a more iterative function that steps through the file keeping track of characters and and newlines and places the page breaks in the appropriate places.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ResetPageBreaks() abort&#xA;  &quot; Remove existing page breaks&#xA;  execute &quot;g/^\&amp;lt;C-L&amp;gt;$/d&quot;&#xA;  &quot; Add a page break every 30 lines&#xA;  %s/^/\= !(line('.') % 30) ? &quot;\&amp;lt;C-L&amp;gt;\r&quot; : ''&#xA;endfunction&#xA;&#xA;augroup PageBreaks&#xA;  autocmd!&#xA;  autocmd BufWritePre *.txt call ResetPageBreaks()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-11-21T09:26:28.863" LastActivityDate="2018-11-21T09:26:28.863" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18014" PostTypeId="1" CreationDate="2018-11-20T06:27:31.210" Score="1" ViewCount="485" Body="&lt;p&gt;The &lt;code&gt;:changes&lt;/code&gt; command listed the change history of current file. However when I work with multiple buffers, I want to list changes to all the buffers I opened in current vim-server, like the behavior of &lt;code&gt;tags&lt;/code&gt; and &lt;code&gt;jumplist&lt;/code&gt;. Is there such facility available?&lt;/p&gt;&#xA;" OwnerUserId="19650" LastActivityDate="2018-11-20T11:32:08.483" Title="changes command only display current file change history" Tags="|navigation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18015" PostTypeId="2" ParentId="18014" CreationDate="2018-11-20T11:32:08.483" Score="1" Body="&lt;p&gt;No, if you're looking for a combined change list; unlike &lt;code&gt;:jumps&lt;/code&gt;, changes are not global, but local to each buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is iterate over all open buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo changes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2018-11-20T11:32:08.483" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18016" PostTypeId="1" AcceptedAnswerId="18018" CreationDate="2018-11-20T12:16:01.567" Score="3" ViewCount="2396" Body="&lt;p&gt;If I have the cursor placed on &quot;word1&quot; and wanted to select &quot;word1 word2 word3&quot; (i.e. with no trailing space after &quot;word3&quot;) what is the easiest command?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;word1 word2 word3 word4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am currently using &lt;code&gt;v5iw&lt;/code&gt;. Is this easiest command?&lt;/p&gt;&#xA;" OwnerUserId="19889" LastActivityDate="2018-11-20T13:01:35.087" Title="What is the easiest way to select multiple words in visual mode?" Tags="|visual-mode|vi-words|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18017" PostTypeId="2" ParentId="18016" CreationDate="2018-11-20T12:57:29.823" Score="2" Body="&lt;p&gt;You want 3 words, and this key combination uses number 5, so not so straight-forward in my opinion. I would possition cursor on the start of &lt;code&gt;word1&lt;/code&gt; if needed - with &lt;kbd&gt;b&lt;/kbd&gt; - and then used &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt; (or even &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;E&lt;/kbd&gt; - if the words would include for example &lt;code&gt;-&lt;/code&gt; in them)&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2018-11-20T12:57:29.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18018" PostTypeId="2" ParentId="18016" CreationDate="2018-11-20T12:59:29.233" Score="2" Body="&lt;p&gt;I would go with &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;3&lt;/kbd&gt; (with the cursor at the beginning of the first word) because it doesn't require you to count anything you just have to think &quot;I want to put my cursor in this character&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway I think what you should really read is &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#motion.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h motion.txt&lt;/code&gt;&lt;/a&gt; to understand which motion exist and for which range they are useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also asking for the best way to visually select these word might be a &lt;a href=&quot;https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem&quot;&gt;XY Problem&lt;/a&gt;: There is a good chance that what you want to do would be more efficient without a visual selection (for example &lt;code&gt;df3&lt;/code&gt; would deleted the words in only 3 keystrokes)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-11-20T12:59:29.233" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18019" PostTypeId="2" ParentId="18016" CreationDate="2018-11-20T13:01:35.087" Score="2" Body="&lt;p&gt;For me personally, counting stuff and apply counts is not the easiest thing to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer to do several repeats like with &lt;code&gt;viwee&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or if the ending word is quite away from the cursor position I would go with &lt;code&gt;v/3/e&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2018-11-20T13:01:35.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18020" PostTypeId="1" CreationDate="2018-11-20T14:08:08.747" Score="1" ViewCount="371" Body="&lt;p&gt;I have &lt;a href=&quot;https://github.com/ervandew/supertab&quot; rel=&quot;nofollow noreferrer&quot;&gt;supertab&lt;/a&gt; installed alongside with &lt;a href=&quot;https://github.com/fatih/vim-go&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-go&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I'd like to have autocomplete when writing in Go, but when I press &lt;kbd&gt;tab&lt;/kbd&gt; its literally inserts a tab character instead of showing the autocomplete prompt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to add the following in my &lt;code&gt;vimrc&lt;/code&gt; but it didn't help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:SuperTabDefaultCompletionType = &quot;context&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:SuperTabContextDefaultCompletionType = &quot;&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; works fine to start autocomplete, but I can't get anything with &lt;code&gt;tab&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD&lt;/strong&gt; &lt;code&gt;:verbose imap &amp;lt;Tab&amp;gt;&lt;/code&gt; result is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i  &amp;lt;Tab&amp;gt;         &amp;lt;Plug&amp;gt;SuperTabForward&#xA;        Last set from ~/.vim/plugged/supertab/plugin/supertab.vim line &#xA;1011&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19818" LastEditorUserId="19818" LastEditDate="2018-11-20T21:04:19.150" LastActivityDate="2018-11-21T08:34:41.870" Title="Supertab inserts tabulation instead of autocompleting" Tags="|autocompletion|plugin-supertab|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="18021" PostTypeId="1" AcceptedAnswerId="18022" CreationDate="2018-11-20T15:33:22.083" Score="1" ViewCount="1302" Body="&lt;p&gt;I have a C program where I have to change a 2D array into a 1D array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want is to change this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;temp[i][j] = (Grid[i][j-1] + Grid[i][j] + Grid[i+1][j] + Grid[i][j+1])/5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;temp[i*PPE+j] = (Grid[i*PPE+j-1] + Grid[i*PPE+j] + Grid[(i+1)*PPE+j] + Grid[i*PPE+j+1])/5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because I'm new to Vimscript I split the problem into two parts and tried to tackle the first one:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[i][j]&lt;/code&gt; -&gt; &lt;code&gt;[i*PPE+j]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[i+1][j+1]&lt;/code&gt; -&gt; &lt;code&gt;[(i+1)*PPE+j+1]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I tried the following until now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s#\v[^0-9](\]\[)[a-z][^-+]#\=substitute(&quot;\1&quot;,&quot;*PPE+&quot;, &quot;&quot;, &quot;&quot;)#gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My reasoning behind this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s#\v&lt;/code&gt;:  go through whole file and use magic&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^0-9](\]\[)[a-z][^-+]&lt;/code&gt;: match &lt;code&gt;&amp;lt;nonumber&amp;gt;][&amp;lt;char&amp;gt;&amp;lt;not+or-&amp;gt;&lt;/code&gt; and () for establishing a group&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\=substitute(&quot;\1&quot;,&quot;*PPE+&quot;, &quot;&quot;, &quot;&quot;)&lt;/code&gt;: substitute the first group ( &lt;code&gt;][&lt;/code&gt; ) with *PPE+&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gc&lt;/code&gt;: &lt;code&gt;g&lt;/code&gt; for all matches in one line and &lt;code&gt;c&lt;/code&gt; for confirmation query&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Unfortunately this doesn't seem to work as it replaces &lt;code&gt;i][j]&lt;/code&gt; with &lt;code&gt;^A&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help with this would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="19891" LastEditorUserId="19891" LastEditDate="2018-11-20T15:44:06.517" LastActivityDate="2018-11-20T17:21:17.773" Title="Search and replace: Replace substring of match (with substitute(...))" Tags="|substitute|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18022" PostTypeId="2" ParentId="18021" CreationDate="2018-11-20T16:20:16.520" Score="3" Body="&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, I'm not sure if I fully understand your goal, but the following two commands convert your &quot;before&quot; into your &quot;after&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Handle the &lt;code&gt;i+1&lt;/code&gt; case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(\D[+-]\d)\]\[/(\1)*PPE+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do all the rest:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/]\[/*PPE+/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first command replaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;not-a-digit&amp;gt;&amp;lt;plus-or-minus&amp;gt;&amp;lt;digit&amp;gt;][&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(&amp;lt;captured-group&amp;gt;)*PPE+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second command simply replaces all remaining instances of &lt;code&gt;][&lt;/code&gt; with &lt;code&gt;*PPE+&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original Answer regarding &lt;code&gt;[i][j]&lt;/code&gt; only&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I understand your question rightly, I'm not sure if using a &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;sub-replace-expression&lt;/a&gt; is the best tool for this job. Perhaps &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5Czs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\zs&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5Cze&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\ze&lt;/code&gt;&lt;/a&gt; are better suited to the task?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v\D\zs\]\[\ze\D\]/*PPE+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It converts this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[i][j]&#xA;[i+1][j]&#xA;[i][j+1]&#xA;[i+1][j+1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[i*PPE+j]&#xA;[i+1][j]&#xA;[i][j+1]&#xA;[i+1][j+1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...by matching &lt;code&gt;&amp;lt;not-a-digit&amp;gt;][&amp;lt;not-a-digit&amp;gt;]&lt;/code&gt;, but setting only the &lt;code&gt;][&lt;/code&gt; to be included in the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2F%5CD&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\D&lt;/code&gt;&lt;/a&gt; is easier to type than &lt;code&gt;[^0-9]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;I'm matching a closing &lt;code&gt;]&lt;/code&gt; rather than &lt;code&gt;&amp;lt;not-plus-or-minus&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-11-20T17:21:17.773" LastActivityDate="2018-11-20T17:21:17.773" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18023" PostTypeId="1" CreationDate="2018-11-20T19:03:38.073" Score="2" ViewCount="183" Body="&lt;p&gt;Say I have a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// vim: syntax=rust fdm=syntax&#xA;{&#xA;  blah blah&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's say that lines 2 through 4 are folded:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// vim: syntax=rust fdm=syntax&#xA;+ { ... }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I am in insert mode. I insert a newline on line 2, and begin typing &lt;code&gt;{&lt;/code&gt;, then &lt;code&gt;}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I type &lt;code&gt;{&lt;/code&gt;, and the folded block updates to being a deeper nesting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// vim: syntax=rust fdm=syntax&#xA;{&#xA;+- { ... }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I type &lt;code&gt;}&lt;/code&gt;, and the previously folded block recognizes it's gone up a nesting level, and opens:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// vim: syntax=rust fdm=syntax&#xA;{}&#xA;{&#xA;  blah&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The behavior is also inconsistent with blocks that follow later in the file, wherein typing &lt;code&gt;{&lt;/code&gt; opens them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This occurs whether I'm using &lt;code&gt;fdm=syntax&lt;/code&gt; or &lt;code&gt;fdm=marker fmr={,}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I stop previously unfolded/folded blocks from closing/opening every time I write fold-markers earlier in the file?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been using the &lt;code&gt;setlocal&lt;/code&gt; trick in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&amp;amp;foldmethod | setlocal foldmethod=manual | endif&#xA;autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &amp;amp;l:foldmethod=w:last_fdm | unlet w:last_fdm | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it works great for files that don't have modelines setting the syntax and the fold method. For some strange reason it doesn't work when I have the modeline as described above.&lt;/p&gt;&#xA;" OwnerUserId="19896" LastEditorUserId="19896" LastEditDate="2018-11-28T21:57:57.653" LastActivityDate="2018-11-28T21:57:57.653" Title="Setup to not automatically open/close folds when writing fold-markers (in the presence of a modeline)" Tags="|folding|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18025" PostTypeId="2" ParentId="18020" CreationDate="2018-11-20T21:03:57.020" Score="3" Body="&lt;p&gt;Thanks to @Hotschke's comments.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;run vim without any plugins/options excepting &lt;code&gt;supertab&lt;/code&gt; and &lt;code&gt;vim-go&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;enable options/plugins one-by-one&lt;/li&gt;&#xA;&lt;li&gt;find that the &lt;code&gt;set paste&lt;/code&gt; option was the cause&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Useful links related to this &quot;issue&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/ervandew/supertab/blob/master/README.rst&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ervandew/supertab/blob/master/README.rst&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;make sure you don't have the paste option enabled in your vimrc or elsewhere&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file/2004#2004&quot;&gt;How do I debug my vimrc file?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19818" LastEditorUserId="19818" LastEditDate="2018-11-21T08:34:41.870" LastActivityDate="2018-11-21T08:34:41.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18027" PostTypeId="1" AcceptedAnswerId="18028" CreationDate="2018-11-21T07:00:36.817" Score="13" ViewCount="5231" Body="&lt;p&gt;If I want to format a few lines, should I choose &lt;code&gt;equalprg&lt;/code&gt; (using &lt;code&gt;=&lt;/code&gt; operator) or &lt;code&gt;formatprg&lt;/code&gt; (using &lt;code&gt;gq&lt;/code&gt; operator)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both of them are for some kind of formatting. But what are the differences.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-11-21T07:47:02.553" Title="what are the usage of equalprg and formatprg" Tags="|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18028" PostTypeId="2" ParentId="18027" CreationDate="2018-11-21T07:47:02.553" Score="9" Body="&lt;p&gt;From &lt;code&gt;:help equalprg&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;'equalprg' 'ep'               string  (default &quot;&quot;)&#xA;                      global or local to buffer |global-local|&#xA;      External program to use for &quot;=&quot; command. ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help =&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;={motion}               Filter {motion} lines through the external program&#xA;                        given with the 'equalprg' option.  When the 'equalprg'&#xA;                        option is empty (this is the default), use the&#xA;                        internal formatting function |C-indenting| and&#xA;                        |'lisp'|.  But when 'indentexpr' is not empty, it will&#xA;                        be used instead |indent-expression|.  When Vim was&#xA;                        compiled without internal formatting then the &quot;indent&quot;&#xA;                        program is used as a last resort.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I agree that it would be nice if the &quot;intent&quot; of the motion was written more clearly, but it does seem relatively clear that the intent of &lt;code&gt;=&lt;/code&gt; and thus &lt;code&gt;equalprg&lt;/code&gt; is indentation.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Similarly we can find from &lt;code&gt;:help formatprg&lt;/code&gt; and &lt;code&gt;:help gq&lt;/code&gt; that this is a more general purpose formatting feature. It allows to use external programs or internal methods based on the &lt;code&gt;formatexpr&lt;/code&gt; and &lt;code&gt;formatprg&lt;/code&gt; settings. With internal formatting it typically just reflows text within a given textwidth, i.e. the &lt;code&gt;textwidth&lt;/code&gt; setting.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-11-21T07:47:02.553" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18029" PostTypeId="1" AcceptedAnswerId="18041" CreationDate="2018-11-21T10:46:19.783" Score="3" ViewCount="240" Body="&lt;p&gt;Is there a way to immediately get feedback about a search string with no matches?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment I have to press Enter first to get &lt;code&gt;Pattern not found&lt;/code&gt;. I'd like if the background (of the search line or of vim itself) turned red the moment there are no matches anymore. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The scenario that bugs me is the following: I type &lt;code&gt;/&lt;/code&gt; and start entering a complicated string/regexp.  Since I have &lt;code&gt;set incsearch&lt;/code&gt; the screen starts jumping around until at some point it settles. At this point I have to scan my entire screen to see if something was found or not. This takes a while even with &lt;code&gt;set hlsearch&lt;/code&gt;. I have attached a screen recording of an example where a search string doesn't give any results because of a typo (entering 5 instead of 6) but it takes me a second or so to realize that typo. Then I fix the search and it again takes me a second or so to realize that I did find something this time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://streamable.com/v5w31&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://streamable.com/v5w31&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18613" LastActivityDate="2018-11-22T14:26:54.997" Title="Get immediate feedback about a search string with no matches in vim" Tags="|search|highlight|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18031" PostTypeId="1" CreationDate="2018-11-21T21:25:46.377" Score="1" ViewCount="312" Body="&lt;p&gt;I would like to hard wrap XML files during editing. In every other filetype my &lt;code&gt;set textwidth=80&lt;/code&gt; works fine. But in XML something overrides the insertion of line breaks. I tried adding &lt;code&gt;t&lt;/code&gt; to &lt;code&gt;formatoptions&lt;/code&gt; but that doesn't make a difference. I believe there is an automatic formatting command being called from the default xml filetype plugin, which overrides all else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I set up vim to do automatic line breaking in XML?&lt;/p&gt;&#xA;" OwnerUserId="11041" LastActivityDate="2020-08-13T02:01:05.120" Title="xml ftplugin overrides textwidth" Tags="|formatting|wrapping|line-breaks|filetype-xml|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18032" PostTypeId="2" ParentId="18031" CreationDate="2018-11-21T22:23:13.173" Score="2" Body="&lt;p&gt;Yes, the xml filetype plugin disables auto wrapping text using textwidth with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal formatoptions-=t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This removes the option &lt;code&gt;t&lt;/code&gt; (= &quot;Auto-wrap text using textwidth&quot;) from formatoptions. See &lt;code&gt;:help formatoptions&lt;/code&gt; and &lt;code&gt;:help fo-table&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To overwrite do the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create the file &lt;code&gt;~/.vim/after/ftplugin/xml.vim&lt;/code&gt; (or &lt;code&gt;$HOME/vimfiles/after/ftplugin/xml.vim&lt;/code&gt; on Windows) with the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; prevent multiple loading&#xA;if exists(&quot;b:did_my_ftplugin&quot;) | finish | endif&#xA;let b:did_my_ftplugin = 1&#xA;&#xA;setlocal formatoptions+=t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The files in &lt;code&gt;~/.vim/after&lt;/code&gt; are loaded after the default plugins are loaded. So this can be used to overwrite settings done in the default ftplugin. See &lt;code&gt;:help after-directory&lt;/code&gt;.&#xA;Here the option &lt;code&gt;t&lt;/code&gt; is readded to &lt;code&gt;formatoptions&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2018-11-21T22:23:13.173" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18034" PostTypeId="1" AcceptedAnswerId="18035" CreationDate="2018-11-21T23:53:26.637" Score="0" ViewCount="198" Body="&lt;p&gt;what is the most efficient regex (vim/perl) to replace 100 'a' characters with 300 'b' characters. I can get the search part correct :%s/a\{100}/?????? but the 'replace' portion eludes me.&lt;/p&gt;&#xA;" OwnerUserId="19916" LastActivityDate="2018-11-22T00:21:46.377" Title="regex vim multiple characters in search, multiple characters in replace" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18035" PostTypeId="2" ParentId="18034" CreationDate="2018-11-22T00:21:46.377" Score="1" Body="&lt;p&gt;This can be done with &lt;code&gt;:%s/a\{100}/\=repeat('b',100)/&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-11-22T00:21:46.377" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18037" PostTypeId="1" AcceptedAnswerId="18039" CreationDate="2018-11-22T06:15:29.643" Score="0" ViewCount="295" Body="&lt;pre&gt;&lt;code&gt;&quot; As above, but curry the arguments so only the buffer number is required.&#xA;function! ale#VarFunc(variable_name) abort&#xA;    return {buf -&amp;gt; ale#Var(buf, a:variable_name)}&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does &lt;code&gt;{ buf -&amp;gt; ... }&lt;/code&gt; mean? It seems like a kind of function closure, but I can't find any document about this... :(&lt;/p&gt;&#xA;" OwnerUserId="11934" LastEditorUserId="11934" LastEditDate="2018-11-22T07:29:36.413" LastActivityDate="2018-11-22T07:29:36.413" Title="What does `{ buf -&gt; ... }` mean in vim script?" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18039" PostTypeId="2" ParentId="18037" CreationDate="2018-11-22T06:59:06.370" Score="4" Body="&lt;p&gt;It is a lambda expression, see &lt;code&gt;:h lambda&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The type of it is &lt;code&gt;v:t_func&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be used where a Funcref is needed, see &lt;code&gt;:h Funcref&lt;/code&gt;. For example, as the parameter of &lt;code&gt;map()&lt;/code&gt; and &lt;code&gt;filter()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-11-22T06:59:06.370" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18040" PostTypeId="1" CreationDate="2018-11-22T11:34:28.883" Score="1" ViewCount="2546" Body="&lt;p&gt;I am starting to work with vim in iterm2 on macOS. &#xA;Whenever I am in insert mode and try to type a backslash, the cursor jumps to the buttom of the Terminal-window and a forward slash appears.&#xA;I have no problem typing a forward slash..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to find a solution, but couldn't find anything that would help me so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have an idea for a solution?&#xA;Thank you so much!&lt;/p&gt;&#xA;" OwnerUserId="19928" LastActivityDate="2018-11-22T11:34:28.883" Title="Cannot type backslash (\) in Vim" Tags="|macos|iterm2|" AnswerCount="0" CommentCount="3" ClosedDate="2018-11-22T16:31:28.010" ContentLicense="CC BY-SA 4.0" />
  <row Id="18041" PostTypeId="2" ParentId="18029" CreationDate="2018-11-22T13:15:45.150" Score="3" Body="&lt;p&gt;I came up with a vimscript solution which seems to work (at least according to my quick tests). This is a workaround and it clearly has a lot of place for improvements.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It changes the color of the status line using the &lt;code&gt;:highlight&lt;/code&gt; command so obviously you need to have &lt;code&gt;set laststatus=2&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;It uses some global variables, theirs scope could be limited and I think they could even be eliminated.&lt;/li&gt;&#xA;&lt;li&gt;It also uses the autocommand events &lt;code&gt;CmdlineEnter&lt;/code&gt; and &lt;code&gt;CmdlineLeave&lt;/code&gt; which are included only in recent vim version.&lt;/li&gt;&#xA;&lt;li&gt;I haven't tested the code with complex searches I don't know how well it behaves with complex regexes and escaped characters.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Anyway the idea was mainly to create a proof of concept, not a complete feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add this to your &lt;code&gt;vimrc&lt;/code&gt; (actually you should put the function in an autoload directory but that's not the point of the question):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HighlightSearch(timer)&#xA;    &quot; When it is the first call to the function we save the current status of&#xA;    &quot; the StatusLine HL group so that we can restore it when we are done searching&#xA;    if (g:firstCall)&#xA;        let g:originalStatusLineHLGroup = execute(&quot;hi StatusLine&quot;)&#xA;        let g:firstCall = 0&#xA;    endif&#xA;&#xA;    if (exists(&quot;g:searching&quot;) &amp;amp;&amp;amp; g:searching)&#xA;        &quot; The variable g:searching is set to 1, we are in the search command line&#xA;        &quot; make the highlighting and call the function again after a delay&#xA;        let searchString = escape(getcmdline(), ' \')&#xA;        let newBG = search(searchString) != 0 ? &quot;green&quot; : &quot;red&quot;&#xA;        execute(&quot;hi StatusLine ctermbg=&quot; . newBG)&#xA;        let g:highlightTimer = timer_start(300, 'HighlightSearch')&#xA;    else&#xA;        &quot; The variable g:searching is either not set or set to 0, we stopped searching&#xA;        &quot; restore the hightlighting and stop calling the function&#xA;        let originalBG = matchstr(g:originalStatusLineHLGroup, 'ctermbg=\zs[^ ]\+')&#xA;        execute(&quot;hi StatusLine ctermbg=&quot; . originalBG)&#xA;&#xA;        if exists(&quot;g:highlightTimer&quot;)&#xA;            call timer_stop(g:highlightTimer)&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot; Define an autocmd to call the HighLightSearch function when we enter the search command line&#xA;&quot; And a second one to stop the function when we are done searching&#xA;augroup betterSeachHighlighting&#xA;    autocmd!&#xA;    autocmd CmdlineEnter * if (index(['?', '/'], getcmdtype()) &amp;gt;= 0) | let g:searching = 1 | let g:firstCall = 1 | call timer_start(1, 'HighlightSearch') | endif&#xA;    autocmd CmdlineLeave * let g:searching = 0&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to create two autocommands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first one is triggered when you enter the command line, it test if you are searching for something (&lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt; in opposition to &lt;code&gt;:&lt;/code&gt;), it sets two variables used by the function and call the function.&lt;/li&gt;&#xA;&lt;li&gt;The second one is triggered when you leave the command line, it is used to unset a variable which is used by the function.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The function does three things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It keeps in memory the original highlighting group of the status line to be able to restore it (Using &lt;a href=&quot;https://vi.stackexchange.com/a/12294/1841&quot;&gt;this answer&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;li&gt;If you are searching for something it looks for a match, updates the background of the status line accordingly and set a timer to call itself again a few milliseconds later to update the background again.&lt;/li&gt;&#xA;&lt;li&gt;If you are not searching for something anymore it resets the status line highlighting.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here are some relevant help topic (I'll try to upload a gif of the code in action when I can):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3ahighlight&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :highlight&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getcmdline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getcmdline()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#search%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h search()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#timer_start%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h timer_start()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#timer_stop%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h timer_stop()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#CmdlineEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h CmdlineEnter&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#CmdlineLeave&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h CmdlineLeave&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getcmdtype%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getcmdtype()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-11-22T14:26:54.997" LastActivityDate="2018-11-22T14:26:54.997" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="18042" PostTypeId="1" CreationDate="2018-11-22T13:36:42.300" Score="1" ViewCount="1514" Body="&lt;p&gt;I am using SpaceVim 1.0.0-dev with the following layers in my config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[[layers]]&#xA;name = 'autocomplete'&#xA;auto-completion-return-key-behavior = &quot;complete&quot;&#xA;auto-completion-tab-key-behavior = &quot;cycle&quot;&#xA;&#xA;[[layers]]&#xA;name = 'shell'&#xA;default_position = 'top'&#xA;default_height = 30&#xA;&#xA;[[layers]]&#xA;name = 'lsp'&#xA;filetypes = [&quot;python&quot;]&#xA;&#xA;[[layers]]&#xA;name = 'unite'&#xA;&#xA;[[layers]]&#xA;name = 'git'&#xA;&#xA;[[layers]]&#xA;name = 'lang#python'&#xA;&#xA;[[layers]]&#xA;name = 'lang#markdown'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried supressing the line-too-long warning with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# noqa: E501&#xA;# pylint: disable=line-too-long&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;towards the top of the source file, but it does not work. I am very new to SpaceVim, and very confused by the whole layers thing... I cannot even find out which linter is used (although i suspect that pylint is used).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointer would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="17847" LastActivityDate="2020-02-28T15:02:45.383" Title="How to disable line-too-long warning in SpaceVim" Tags="|spacevim|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18043" PostTypeId="1" CreationDate="2018-11-22T15:08:34.853" Score="1" ViewCount="28" Body="&lt;p&gt;I am editing a java file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;]m&lt;/code&gt; takes me from one class to the next, instead of to the next method definition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get it to take me between methods?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public class Baz {&#xA;    public class Foo {&#xA;        public Foo() {&#xA;        }&#xA;&#xA;        public void doFooOne() {&#xA;        }&#xA;&#xA;        public void doFooTwo() {&#xA;        }&#xA;    }&#xA;&#xA;    public class Bar {&#xA;        public Bar() {&#xA;        }&#xA;&#xA;        public void doBarOne() {&#xA;        }&#xA;&#xA;        public void doBarTwo() {&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Putting cursor on &lt;code&gt;doFooOne&lt;/code&gt; and typing &lt;code&gt;]m&lt;/code&gt; jumps the cursor to &lt;code&gt;public class Bar {&lt;/code&gt; instead of to &lt;code&gt;doFooTwo&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="9024" LastEditDate="2018-11-22T18:35:23.167" LastActivityDate="2018-11-22T18:35:23.167" Title="]m moves to class definitions not method definitions inside nested classes" Tags="|cursor-movement|cursor-motions|filetype-java|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18044" PostTypeId="1" CreationDate="2018-11-22T16:23:28.593" Score="0" ViewCount="59" Body="&lt;p&gt;I'm using a simple text file in Vim as a task manager and am keeping completed tasks in an archive section of the same file. I'd like to compress that section of the buffer when saving changes to a file, but have it visible (uncompressed) in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way of achieving this in Vim?&lt;/p&gt;&#xA;" OwnerUserId="599" LastEditorUserId="51" LastEditDate="2021-01-27T03:16:13.460" LastActivityDate="2021-01-27T03:16:13.460" Title="Automatically uncompress section of buffer" Tags="|filetype|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18045" PostTypeId="1" CreationDate="2018-11-23T09:17:50.403" Score="0" ViewCount="157" Body="&lt;p&gt;Assume I am inside a function and currently in visual mode (&lt;code&gt;mode()&lt;/code&gt; returns &lt;code&gt;v&lt;/code&gt; or &lt;code&gt;V&lt;/code&gt; or &lt;code&gt;&quot;\&amp;lt;c-v&amp;gt;&quot;&lt;/code&gt;, such as when you run &lt;code&gt;vmap-expr&lt;/code&gt;) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I quit the visual mode? Should I call &lt;code&gt;feedkeys(&quot;\&amp;lt;esc&amp;gt;&quot;, 'ni')&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to run a mapping in the visual mode, like &lt;code&gt;4&amp;gt;&lt;/code&gt; to indent the lines 4 times. It seems &lt;code&gt;normal 4&amp;gt;&lt;/code&gt; does not work.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-11-23T10:12:01.657" LastActivityDate="2020-04-19T22:03:30.390" Title="in function how to stop visual mode and how to run a mapping" Tags="|visual-mode|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18046" PostTypeId="1" CreationDate="2018-11-23T11:56:41.150" Score="5" ViewCount="3344" Body="&lt;p&gt;I'm trying to set gVim to be the default text editor on Windows but it won't work. It works with notepad++, editor... but not with Vim. Any ideas how to fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screenshot: &lt;a href=&quot;http://prntscr.com/lm069a&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://prntscr.com/lm069a&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried to choose &lt;code&gt;gvim.exe&lt;/code&gt; with the option that opens the explorer. if I open it it works, but it doesn't save Vim as the default text editor.&lt;/p&gt;&#xA;" OwnerUserId="19942" LastEditorUserId="343" LastEditDate="2018-11-23T13:51:46.403" LastActivityDate="2019-10-23T14:02:25.527" Title="How to set vim as the default Text editor?" Tags="|gvim|microsoft-windows|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18051" PostTypeId="1" CreationDate="2018-11-23T15:04:24.897" Score="0" ViewCount="366" Body="&lt;p&gt;I have the following strings (whitespace and line wise separated) in a file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mks asksö askndl&#xA;ebre nakkl sadj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and would like to have it formatted as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&quot;mks&quot;, &quot;asksö&quot;, &quot;askndl&quot;],&#xA;[&quot;ebre&quot;, &quot;nakkl&quot;, &quot;sadj&quot;],&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What shortcut sequence is suitable?&lt;/p&gt;&#xA;" OwnerUserId="19824" LastEditorUserId="1841" LastEditDate="2018-11-23T15:12:43.263" LastActivityDate="2018-11-23T17:32:57.400" Title="How to convert a sequence of words to a list?" Tags="|formatting|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18052" PostTypeId="1" AcceptedAnswerId="18053" CreationDate="2018-11-23T15:44:01.407" Score="0" ViewCount="335" Body="&lt;p&gt;what is the most efficient regex (vim/perl) to replace 10 'a' characters with 1 'c' character followed by 100 'b' characters?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this does not work:&#xA;:%s/a{10}/\=repeat('c',1)\=repeat('b',100)/g&lt;/p&gt;&#xA;" OwnerUserId="19916" LastActivityDate="2018-11-23T15:51:33.493" Title="regex characters replace multiple characters" Tags="|regular-expression|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18053" PostTypeId="2" ParentId="18052" CreationDate="2018-11-23T15:51:33.493" Score="1" Body="&lt;p&gt;This can be done with &lt;code&gt;:%s/a\{10}/\=repeat('c',1).repeat('b',100)/g&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-11-23T15:51:33.493" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18054" PostTypeId="2" ParentId="18051" CreationDate="2018-11-23T16:15:45.980" Score="2" Body="&lt;p&gt;There are so many ways to proceed...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;the simple 2-steps solution&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\s\+/', '/g&#xA;:%s/.*/['&amp;amp;'],/&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;or, in one step&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.*/\=&quot;['&quot;.substitute(submatch(0), '\s\+', &quot;', '&quot;, 'g').&quot;'],&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;or also&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.*/\=string(split(submatch(0), '\s\+')).','&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;or, my preferred one (in Vim script contexts)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setline(1, map(getline(1,'$'), 'string(split(v:val, &quot;\\s\\+&quot;)).&quot;,&quot;'))&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And I'm quite sure that macros-oriented-people could VimGolf this &lt;em&gt;problem&lt;/em&gt; in very few key strokes&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-11-23T17:32:57.400" LastActivityDate="2018-11-23T17:32:57.400" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18055" PostTypeId="1" AcceptedAnswerId="18056" CreationDate="2018-11-23T16:35:57.467" Score="0" ViewCount="93" Body="&lt;p&gt;I wonder is there any pipeline style combination key mapping in vimrc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command to open the NERDTree is &lt;code&gt;:NERDTree&lt;/code&gt; and press capital &lt;strong&gt;B&lt;/strong&gt; will open the bookmark list. How can I combine them into one action when I type the key storks of &lt;code&gt;nb&lt;/code&gt; in .vimrc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My trying: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap nb :NERDTree&amp;lt;Cr&amp;gt;B&amp;lt;Cr&amp;gt;  //not working&#xA;nnoremap nb :NERDTree&amp;lt;Cr&amp;gt; | B&amp;lt;Cr&amp;gt;  //not working&#xA;nnoremap nb :NERDTree&amp;lt;Cr&amp;gt;&amp;lt;Esc&amp;gt;B&amp;lt;Cr&amp;gt;  //not working&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15958" LastActivityDate="2018-11-23T16:46:09.080" Title="How to combine 2 actions for different mode into one mapping" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18056" PostTypeId="2" ParentId="18055" CreationDate="2018-11-23T16:46:09.080" Score="2" Body="&lt;p&gt;you cannot use nnoremap here. Use nmap instead. &#xA;This is because B is a mapping that NERDtree provides and nore means to not use an existing mapping.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-11-23T16:46:09.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18057" PostTypeId="2" ParentId="18051" CreationDate="2018-11-23T16:55:41.860" Score="2" Body="&lt;p&gt;Since @LucHermitte alluded to a macro-based solution, I thought I'd provide one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqqqqciw&quot;&amp;lt;C-R&amp;gt;&quot;&quot;,&amp;lt;Esc&amp;gt;w@qq@q&#xA;qqqqqi]&amp;lt;Esc&amp;gt;I[&amp;lt;Esc&amp;gt;&amp;lt;BS&amp;gt;@qq@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First line adds in the quotes and commas, the second line adds the brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(N.B. in the above, &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; means press &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;, &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; means press &lt;kbd&gt;Esc&lt;/kbd&gt;, and &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; means press &lt;kbd&gt;Backspace&lt;/kbd&gt;.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could write a long explanation of how this works but honestly, it will be quicker and easier for you just to try typing it in. If you're still not sure what's happening, you might need to read up on &lt;a href=&quot;https://vi.stackexchange.com/a/691/343&quot;&gt;recursive macros&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/insert.txt.html#i_CTRL-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-R&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this is not remotely VimGolf'ed. I've no doubt the good people at &lt;a href=&quot;https://vimgolf.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimgolf.com&lt;/a&gt; could come up with a solution that did the same thing in a quarter of the keystrokes.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-11-23T17:20:29.097" LastActivityDate="2018-11-23T17:20:29.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18058" PostTypeId="1" AcceptedAnswerId="18989" CreationDate="2018-11-23T17:04:59.693" Score="1" ViewCount="72" Body="&lt;p&gt;I need to define variables who can hold number or strings. Those variables would be used later in the key mapping&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for example &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let bookMark=Lib7 //:echo boomMark do give out Lib7&#xA;nmap gb :&amp;lt;c-u&amp;gt;NERDTree&amp;lt;CR&amp;gt;:OpenBookMark 'bookmark'&amp;lt;Cr&amp;gt; //not working&#xA;nmap gb :&amp;lt;c-u&amp;gt;NERDTree&amp;lt;CR&amp;gt;:OpenBookMark bookmark&amp;lt;Cr&amp;gt; //not working&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NB:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an typo here, it shall be &lt;code&gt;OpenBookmark&lt;/code&gt;,&lt;/p&gt;&#xA;" OwnerUserId="15958" LastEditorUserId="15958" LastEditDate="2019-02-22T10:18:14.137" LastActivityDate="2019-02-22T10:18:14.137" Title="How to define a varialbe and refer to it later" Tags="|vimrc|variables|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18063" PostTypeId="2" ParentId="8972" CreationDate="2018-11-24T13:14:25.720" Score="-2" Body="&lt;p&gt;In Windows 10 nowadays you have to edit (with admin privileges) the file _vimrc located in &lt;code&gt;%ProgramFiles(x86)%\Vim\_vimrc&lt;/code&gt; &#xA;And add the line: &#xA;&lt;code&gt;colorscheme &amp;lt;colorscheme&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Font where i found the way to solve this: &lt;a href=&quot;http://vim.wikia.com/wiki/Change_the_color_scheme&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Change_the_color_scheme&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19951" LastActivityDate="2018-11-24T13:14:25.720" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18064" PostTypeId="2" ParentId="18046" CreationDate="2018-11-24T14:15:57.987" Score="4" Body="&lt;p&gt;I can't comment, so here's a workaround I used: use &lt;code&gt;cmd.exe&lt;/code&gt; in admin mode for this!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, type in the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ftype VimFile=&quot;C:\Program Files (x86)\Vim\vim81\gvim.exe&quot; --remote-silent &quot;%1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This ensures that any filetype (extension) associated to the &lt;code&gt;VimFile&lt;/code&gt; we've set will, by double-click, open in gVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, choose a file extension (I chose &lt;code&gt;.vim&lt;/code&gt; and &lt;code&gt;.tex&lt;/code&gt; for trial) to associate with &lt;code&gt;VimFile&lt;/code&gt;, and type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;assoc .extension=VimFile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This associates &lt;code&gt;.extension&lt;/code&gt; to &lt;code&gt;VimFile&lt;/code&gt;, and therefore is opened by the &lt;code&gt;gvim.exe&lt;/code&gt; path we set before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this workaround doesn't work with the &lt;code&gt;NERDTree&lt;/code&gt; plugin, so I didn't add the option of &lt;code&gt;--remote-silent &quot;%1&quot;&lt;/code&gt;; bear in mind though that this option only shows the &lt;code&gt;NERDTree&lt;/code&gt; tree indicating the directory of the file you have chosen to double-click.&lt;/p&gt;&#xA;" OwnerDisplayName="user19950" LastActivityDate="2018-11-24T14:15:57.987" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18066" PostTypeId="2" ParentId="18046" CreationDate="2018-11-24T21:24:36.030" Score="0" Body="&lt;p&gt;Actually, you can set vim as your default editor by setting the path of the GVim in your &lt;strong&gt;PATH&lt;/strong&gt; variable. For setting of GVim in &lt;strong&gt;PATH&lt;/strong&gt; follow &lt;a href=&quot;https://stackoverflow.com/a/5402776&quot;&gt;these&lt;/a&gt; steps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can set any application as default for you. The only thing you have to do is add the application path to the PATH variable.&lt;/p&gt;&#xA;" OwnerUserId="16364" LastActivityDate="2018-11-24T21:24:36.030" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18067" PostTypeId="1" CreationDate="2018-11-25T05:23:40.643" Score="0" ViewCount="123" Body="&lt;p&gt;I want to use the &lt;a href=&quot;https://github.com/vim-scripts/nuweb.vim/blob/master/syntax/nuweb.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;nuweb.vim&lt;/a&gt; extension for syntax highlighting &lt;a href=&quot;http://nuweb.sourceforge.net/nuwebdoc.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;nuweb files&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long story short, nuweb files are basically a super-set of latex files. There is added syntax and markers to embed code-snippets in Latex so that one can do literate programming in the style of Knuth. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have not been able to get the nuweb.vim file to get to work &#xA;for nuweb files. (These typically have extensions .nw)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here a sample nuweb file, titled &lt;code&gt;fun.nw&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$\alpha + \beta=\gamma$&#xA;&#xA;@o output.cpp&#xA;@{# /* C++*/&#xA;#include&amp;lt;iostream&amp;gt;&#xA;int main(void){&#xA;  std::cout &amp;lt;&amp;lt; &quot;Hello World&quot; &amp;lt;&amp;lt; std::endl;&#xA;  return 0;&#xA;}&#xA;&#xA;@}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My .vimrc file looks like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme torte&#xA;set guifont=Inconsolata\ 14&#xA;set laststatus=2&#xA;&#xA;filetype on&#xA;filetype plugin on&#xA;&#xA;set runtimepath^=/home/smilingbuddha/.vim/bundle/nuweb.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On opening the nuweb files, I don't get the necessary syntax highlightin. Doing &lt;code&gt;:set syntax?&lt;/code&gt; I get output &lt;code&gt;syntax=conf&lt;/code&gt; in the mode-line at the bottom. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where am I going wrong? I am not used to Vim so I am pretty much a newbie. &lt;/p&gt;&#xA;" OwnerUserId="13566" LastActivityDate="2020-09-16T00:04:20.340" Title="Installing a Vim package. syntax highlighting does not turn on" Tags="|syntax-highlighting|installing|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18068" PostTypeId="1" AcceptedAnswerId="18069" CreationDate="2018-11-25T17:04:01.117" Score="7" ViewCount="3343" Body="&lt;p&gt;I'm trying to fully understand the following command in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;grep -R &quot; . shellescape(expand(&quot;&amp;lt;cWORD&amp;gt;&quot;)) . &quot; .&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I got the use of expand function (force the expansion of into the actual string before it gets passed to shellescape) and shellescape command itself ( from Vim help page: Escape {string} for use as a shell command argument).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I do not understand, from help itself either, is that use of dots, one before and one after shellescape command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, both of the dots are preceeded and followed by an empty space. And if I use :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;grep -R &quot;shellescape(expand(&quot;&amp;lt;cWORD&amp;gt;&quot;))&quot; .&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is the same command without those dots, I (apparently) get the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody give a detailed explanation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="15040" LastEditorUserId="10604" LastEditDate="2023-11-19T01:04:32.630" LastActivityDate="2023-11-19T01:04:32.630" Title="What is the &quot;.&quot; (period/dot) operator in Vim?" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18069" PostTypeId="2" ParentId="18068" CreationDate="2018-11-25T17:48:21.927" Score="9" Body="&lt;p&gt;If you pass multiple strings to the &lt;code&gt;:execute&lt;/code&gt; command it will join them together, adding a space between each string. The &lt;code&gt;.&lt;/code&gt; operator concatenates strings without adding a space. In this command, adding an extra space won’t break it, so either way works fine. See &lt;code&gt;:help :execute&lt;/code&gt; and &lt;code&gt;:help expr-.&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-11-25T17:48:21.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18070" PostTypeId="2" ParentId="18067" CreationDate="2018-11-25T19:47:31.513" Score="0" Body="&lt;p&gt;Simply put &lt;code&gt;syntax on&lt;/code&gt; on your vimrc&lt;/p&gt;&#xA;" OwnerUserId="19961" LastActivityDate="2018-11-25T19:47:31.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18072" PostTypeId="2" ParentId="17962" CreationDate="2018-11-26T11:52:26.897" Score="10" Body="&lt;p&gt;There are alternatives.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plain ol' &lt;a href=&quot;https://docs.python.org/3/library/pdb.html&quot; rel=&quot;noreferrer&quot;&gt;pdb&lt;/a&gt; can be integrated into vim with&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/gotcha/vimpdb&quot; rel=&quot;noreferrer&quot;&gt;vimpdb&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.raditha.com/blog/archives/vim-and-python-debug/&quot; rel=&quot;noreferrer&quot;&gt;vebugger, etc&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(My own favourite) &lt;a href=&quot;https://pypi.org/project/pudb/&quot; rel=&quot;noreferrer&quot;&gt;pudb&lt;/a&gt; can be integrated with &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/SkyLeach/pudb.vim&quot; rel=&quot;noreferrer&quot;&gt;pudb.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/KangOl/vim-pudb&quot; rel=&quot;noreferrer&quot;&gt;vim-pudb&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And the popular &lt;a href=&quot;https://pypi.org/project/ipdb/&quot; rel=&quot;noreferrer&quot;&gt;ipdb&lt;/a&gt; can be &lt;a href=&quot;https://github.com/gotcha/ipdb/blob/master/README.rst&quot; rel=&quot;noreferrer&quot;&gt;integrated&lt;/a&gt; with&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim-vdebug/vdebug&quot; rel=&quot;noreferrer&quot;&gt;vdebug&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://gist.github.com/berinhard/523420&quot; rel=&quot;noreferrer&quot;&gt;ipdb_breakpoint&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="182" LastActivityDate="2018-11-26T11:52:26.897" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18073" PostTypeId="1" CreationDate="2018-11-26T12:24:31.330" Score="6" ViewCount="1922" Body="&lt;p&gt;When I open a file (either from dolphin or terminal) a window of nvim-qt is created.&#xA;Is there a way to open the file in the existing nvim-qt window and raise/focus to the window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I know there is a way for gvim using silent server option, but couldn't make that work with nvim-qt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks.&lt;/p&gt;&#xA;" OwnerUserId="19966" LastActivityDate="2022-11-30T00:15:32.853" Title="neovim-qt : Is it possible open files in the existing window?" Tags="|neovim-qt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18074" PostTypeId="1" AcceptedAnswerId="18075" CreationDate="2018-11-26T12:36:18.863" Score="3" ViewCount="536" Body="&lt;p&gt;I have a Jinja2 template which I'd like Vim to syntax-highlight as a Jinja2 template, but the file - once rendered - will be an Nginx configuration file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way of getting Vim to use modelines &quot;conditionally&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that I cannot tinker with one modeline alone, because even though I could use a template variable, that would invalidate the modeline as far as Vim is concerned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So essentially when I open the file as Jinja2 template I want the modeline to be treated as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: set autoindent smartindent ts=4 sw=4 sts=4 noet filetype=jinja2:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and once rendered as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: set autoindent smartindent ts=4 sw=4 sts=4 noet filetype=nginx:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is Vim capable of doing something like that?&lt;/p&gt;&#xA;" OwnerUserId="1109" LastActivityDate="2018-11-27T14:10:07.743" Title="Having two modelines in one file, is that possible?" Tags="|modeline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18075" PostTypeId="2" ParentId="18074" CreationDate="2018-11-26T13:47:59.623" Score="7" Body="&lt;p&gt;According to the second modeline format (the one with &lt;code&gt;set&lt;/code&gt;) listed in &lt;code&gt;:help modeline&lt;/code&gt;, you can put any text after the second &lt;code&gt;:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: set autoindent smartindent ts=4 sw=4 sts=4 noet :&#xA;{# vim: set ft=jinja2: #}# vim: set ft=nginx:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the template source code, the last line is parsed by vim as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[text][white]vim: set ft=jinja2: [text]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the trailing text discarded.  However, in the rendered output, this appears as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: set ft=nginx:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note also that you can use multiple modelines as in the example above, up to the value of &lt;code&gt;set modelines&lt;/code&gt; (by default 5).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Processing order&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Another detail to keep in mind is that vim processes modelines in the following order:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;5 lines from the top down.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;then of the file lines that have not been processed yet,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;5 lines from the &lt;em&gt;bottom&lt;/em&gt; up.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thus, the order of processing of the above code  will depend on if the modeline is placed at the top or bottom of the file, so the result could be different if the filetype overrides indentation settings.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2018-11-27T14:10:07.743" LastActivityDate="2018-11-27T14:10:07.743" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18076" PostTypeId="2" ParentId="18045" CreationDate="2018-11-26T20:46:48.250" Score="1" Body="&lt;p&gt;Instead of another comment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I understand you want to work with &lt;code&gt;vmap &amp;lt;expr&amp;gt;&lt;/code&gt; Like mapping &lt;code&gt;,&quot;&lt;/code&gt; to a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;expr&amp;gt; ,&quot; MyFunction()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case the the function has to return the keystrokes that should be executed by Vim. Lets assume you want to surround visually selected text with something (function hardly tested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ExecSurround(pre, post)&#xA;    let mode = mode()&#xA;    if(mode == &quot;V&quot;)&#xA;        &quot; line: Put it above and below the selected lines&#xA;        return &quot;V`&amp;gt;o&quot; . a:post . &quot;\e`&amp;lt;O&quot; . a:pre . &quot;\e&quot;&#xA;    elseif(mode == &quot;\&amp;lt;C-V&amp;gt;&quot;)&#xA;        &quot; block: Put it before and after selection on every line&#xA;        return &quot;A&quot; . a:post . &quot;\egvI&quot; . a:pre . &quot;\e&quot;&#xA;    else&#xA;        &quot; char: put it before first and after last char&#xA;        return &quot;v`&amp;gt;a&quot; . a:post . &quot;\e`&amp;lt;i&quot; . a:pre . &quot;\e&quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;vmap &amp;lt;expr&amp;gt; ,&quot; ExecSurround('&quot;', '&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as I understand &lt;code&gt;:help :map-expression&lt;/code&gt;, the things you can do in the function are limited. You have to return the keystrokes, that change your text. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As said in my comment, I would choose another way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Surround(pre, post)&#xA;    let mode = visualmode()&#xA;    if(mode == &quot;V&quot;)&#xA;        call execute(&quot;normal `&amp;gt;o&quot; . a:post . &quot;\e`&amp;lt;O&quot; . a:pre . &quot;\e&quot;)&#xA;    elseif(mode == &quot;\&amp;lt;C-V&amp;gt;&quot;)&#xA;        call execute(&quot;normal gvA&quot; . a:post . &quot;\egvI&quot; . a:pre . &quot;\e&quot;)&#xA;    else&#xA;        call execute(&quot;normal `&amp;gt;a&quot; . a:post . &quot;\e`&amp;lt;i&quot; . a:pre . &quot;\e&quot;)&#xA;    endif   &#xA;endfunction&#xA;&#xA;vmap ,&quot; :&amp;lt;C-U&amp;gt;call Surround('&quot;', '&quot;')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way you are not limited by the restrictions from &quot;map-expression&quot; and could easily add additional functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whatever you want to do might be more complex than this, but perhaps it helps to go on.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2018-11-26T20:46:48.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18078" PostTypeId="1" CreationDate="2018-11-27T01:38:47.787" Score="2" ViewCount="159" Body="&lt;p&gt;&lt;code&gt;@:&lt;/code&gt; repeats the last colon command I entered, but also seems to include &lt;code&gt;:write&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so often I go through this kind of workflow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/foo/bar&#xA;:w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I go to another line and want to run &lt;code&gt;:s/foo/bar&lt;/code&gt; again, but &lt;code&gt;@:&lt;/code&gt; runs &lt;code&gt;:w&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I get &lt;code&gt;@:&lt;/code&gt; to ignore &lt;code&gt;:w&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2018-11-27T08:01:35.360" Title="repeat last command but not write" Tags="|command-line|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18079" PostTypeId="1" AcceptedAnswerId="18090" CreationDate="2018-11-27T02:48:56.727" Score="4" ViewCount="1326" Body="&lt;p&gt;Using &lt;code&gt;getwininfo&lt;/code&gt; it is possible to determine whether an window is a quickfix window or location list window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But once a location list window is found, how can I know which window it is associated with? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a more straightforward way to know whether the current window has a location list window opened&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-11-27T03:31:36.863" LastActivityDate="2018-11-27T19:19:30.713" Title="how to check whether the location list for the current window is open" Tags="|quickfix|location-list|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18080" PostTypeId="2" ParentId="2350" CreationDate="2018-11-27T03:18:18.133" Score="14" Body="&lt;p&gt;Similar to Kossak's answer but a bit simpler, by mapping literal key presses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either in normal mode after pressing &lt;kbd&gt;:&lt;/kbd&gt;, or inserted into your &lt;code&gt;.vimrc&lt;/code&gt;, map the input directly by starting the mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then hitting &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;V&lt;/kbd&gt; then the keystroke to record, e.g. &lt;kbd&gt;Alt&lt;/kbd&gt; + &lt;kbd&gt;←&lt;/kbd&gt;. This will show as something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ^[[1;3D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but each &lt;code&gt;^[&lt;/code&gt; is a single, literal escape character and syntax highlighting should show this. Replace the literal escape(s) with the text &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, and append the command you wish to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Esc&amp;gt;[1;3D &amp;lt;C-w&amp;gt;h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I know OP was mapping &lt;kbd&gt;Alt&lt;/kbd&gt; + letters, but I used arrows to show how do it for something that may not be mapped by default.&lt;/p&gt;&#xA;" OwnerUserId="8520" LastEditorUserId="8520" LastEditDate="2018-11-27T04:26:41.790" LastActivityDate="2018-11-27T04:26:41.790" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18081" PostTypeId="2" ParentId="16963" CreationDate="2018-11-27T03:27:55.003" Score="25" Body="&lt;h1&gt;TL;DR&lt;/h1&gt;&#xA;&lt;p&gt;It's actually nice to remap &lt;kbd&gt;esc&lt;/kbd&gt; to the home row. Here's how you decide what to map it to: pick a hand and roll your 4 fingers across your desktop as fast as you can in whichever direction is fastest. Use that to choose what keys to remap.&lt;/p&gt;&#xA;&lt;p&gt;For me it's more natural to roll from pinky to index finger. Therefore I chose to use &lt;code&gt;kj&lt;/code&gt;. Also, I did a &lt;code&gt;grep -rHin kj ~/src&lt;/code&gt; (recursive grep on the parent directory of all my source code) and found no matches.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; esc in insert &amp;amp; visual mode&#xA;inoremap kj &amp;lt;esc&amp;gt;&#xA;vnoremap kj &amp;lt;esc&amp;gt;&#xA;&#xA;&amp;quot; esc in command mode&#xA;cnoremap kj &amp;lt;C-C&amp;gt;&#xA;&amp;quot; Note: In command mode mappings to esc run the command for some odd&#xA;&amp;quot; historical vi compatibility reason. We use the alternate method of&#xA;&amp;quot; exiting which is Ctrl-C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note: If you do need to type a literal &lt;code&gt;kj&lt;/code&gt; (or whatever your mapping is) just type them with 2 seconds in between. (You'll see the cursor hesitate to move after the 1st char. Wait for it to move before typing the 2nd.)&lt;/p&gt;&#xA;&lt;p&gt;You can shorten this delay by setting a shorter timeout to &lt;code&gt;timeoutlen&lt;/code&gt;. For example, to have a timeout of 500ms add the following to your vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set timeoutlen=500&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I have been using &lt;code&gt;vim&lt;/code&gt; for 19 years. I was horrified when Apple updated their MacBook Pros to have a touch bar and no physical &lt;kbd&gt;esc&lt;/kbd&gt; key. &lt;a href=&quot;https://csswizardry.com/2017/01/preparing-vim-for-apples-touch-bar/&quot; rel=&quot;nofollow noreferrer&quot;&gt;I saw a post&lt;/a&gt; that suggested mapping &lt;code&gt;jj&lt;/code&gt; and &lt;code&gt;jk&lt;/code&gt; to &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; and hated it. But I patiently jotted down on an index card every time it annoyed me. About 15 minutes later I reviewed my notes and came up with the &lt;strong&gt;TL;DR&lt;/strong&gt; above to address the following:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I tend to hit &lt;kbd&gt;esc&lt;/kbd&gt; a lot when I'm not in insert mode just to &amp;quot;be sure&amp;quot; and &lt;code&gt;jj&lt;/code&gt; would drop me 2 lines.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;jk&lt;/code&gt; is a no-op (down, up) but &lt;code&gt;kj&lt;/code&gt; is more natural for my hands.&lt;/li&gt;&#xA;&lt;li&gt;I also need to use &lt;kbd&gt;esc&lt;/kbd&gt; to exit command mode without completing the command.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;It's my hope that I can finally break my habit of hitting &lt;kbd&gt;esc&lt;/kbd&gt; in other applications and closing windows when I'm several minutes into writing. I'd much rather insert stray &lt;strong&gt;kj&lt;/strong&gt; characters than lose my work!&lt;/p&gt;&#xA;&#xA;" OwnerUserId="10672" LastEditorUserId="27038" LastEditDate="2024-02-29T10:37:53.017" LastActivityDate="2024-02-29T10:37:53.017" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="18082" PostTypeId="2" ParentId="18078" CreationDate="2018-11-27T08:01:35.360" Score="6" Body="&lt;p&gt;It seems you basically understand correctly: &lt;code&gt;&quot;:&lt;/code&gt; is a readonly register that contains the last executed command. &lt;code&gt;@:&lt;/code&gt; will execute this register. Feel free to read up on this: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#quote:&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help &quot;:&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/repeat.html#@&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help @&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further, your issue is that you want to repeat a command but you are issuing a new command in between, &lt;code&gt;:write&lt;/code&gt;, which obviously overwrites &lt;code&gt;&quot;:&lt;/code&gt;. You ask: &quot;Can I get &lt;code&gt;@:&lt;/code&gt; to ignore &lt;code&gt;:w&lt;/code&gt;?&quot;. Of course, yes, you can define a new command that uses &lt;code&gt;histget()&lt;/code&gt; and map it to &lt;code&gt;@:&lt;/code&gt;, as is suggested by @Ralf in the comments. However, I will advice that you instead reconsider your own workflow. Instead of changing &lt;code&gt;@:&lt;/code&gt;, try to compose repeatable commands. For instance, instead of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/foo/bar&#xA;:w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/foo/bar/e | update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here I've added the &lt;code&gt;e&lt;/code&gt; flag, which prevents the substitute command from failing if there are no &lt;code&gt;foo&lt;/code&gt;s found. Then I use &lt;code&gt;|&lt;/code&gt; (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#:bar&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help bar&lt;/code&gt;&lt;/a&gt;) to add a new command to be executed after, and I use &lt;code&gt;:update&lt;/code&gt; instead of &lt;code&gt;:write&lt;/code&gt; to only write the file if there is a change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion, this is a better solution than changing how Vim works.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-11-27T08:01:35.360" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18083" PostTypeId="2" ParentId="18079" CreationDate="2018-11-27T08:11:40.123" Score="0" Body="&lt;p&gt;I think that quickfix/loclist windows are not really associated with any other windows/buffers, and that what you ask is not really possible out of the box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if we assume that a quickfix/loclist window is associated with the window that was active when opening, then you could use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup qfidentifier&#xA;  autocmd!&#xA;  autocmd QuickFixCmdPre [c]* let g:quicklist_buffer = bufnr('.')&#xA;  autocmd QuickFixCmdPre [l]* let g:loclist_buffer = bufnr('.')&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should set the &lt;code&gt;g:quicklist_buffer&lt;/code&gt; and &lt;code&gt;g:loclist_buffer&lt;/code&gt; variables to the buffer number that was active when the relevant quickfix or loclist command was executed. I think that should provide the relevant information that you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: I did not test this, so it might need some adjustments.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-11-27T08:11:40.123" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18084" PostTypeId="2" ParentId="5213" CreationDate="2018-11-27T09:06:24.223" Score="11" Body="&lt;h1&gt;Plethora of Plugins&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Toggling &lt;code&gt;true&lt;/code&gt;/&lt;code&gt;false&lt;/code&gt; and similar has been implemented by many plugin authors. Two of them have already been mentioned:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;switch.vim&lt;/em&gt; by Andrew Radev (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4172&quot; rel=&quot;noreferrer&quot;&gt;#4172&lt;/a&gt;, &lt;a href=&quot;https://github.com/AndrewRadev/switch.vim&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;)  and &lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;toggle-bool&lt;/em&gt; by Sagar Rakshe (&lt;a href=&quot;https://github.com/sagarrakshe/toggle-bool&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Others are &lt;em&gt;toggle&lt;/em&gt; by Timo Teifel (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=895&quot; rel=&quot;noreferrer&quot;&gt;#895&lt;/a&gt;), &lt;em&gt;monday&lt;/em&gt; by Stefan Karlsson (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1046&quot; rel=&quot;noreferrer&quot;&gt;#1046&lt;/a&gt;), &lt;em&gt;toggle_words&lt;/em&gt; by Vincent Wang (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1676&quot; rel=&quot;noreferrer&quot;&gt;#1676&lt;/a&gt;), &lt;em&gt;toggle_word&lt;/em&gt; by Alexandru Ungur (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1748&quot; rel=&quot;noreferrer&quot;&gt;#1748&lt;/a&gt;), &lt;em&gt;incbool.vim&lt;/em&gt; by Dmitry Petrov (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4361&quot; rel=&quot;noreferrer&quot;&gt;#4361&lt;/a&gt;, &lt;a href=&quot;https://github.com/can3p/incbool.vim&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;), &lt;em&gt;nextval&lt;/em&gt; by Michael Arlt (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4536&quot; rel=&quot;noreferrer&quot;&gt;#4536&lt;/a&gt;, &lt;a href=&quot;https://github.com/qwertologe/nextval.vim&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just in case you want to increase numbers according to a custom series, e.g. the Fibonacci series, check out &lt;em&gt;nexus&lt;/em&gt; by Barry Arthur (&lt;a href=&quot;https://github.com/dahu/Nexus&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Plugins Supercharging &lt;code&gt;Ctrl-A/X&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;However, not all of them follow by default the idea to extend &lt;code&gt;Ctrl-A/X&lt;/code&gt; but define a new command and/or a new mapping (incl. &lt;em&gt;switch.vim&lt;/em&gt; and &lt;em&gt;toggle-bool&lt;/em&gt;). I want to highlight those plugins which 'supercharge' &lt;code&gt;Ctrl-A/X&lt;/code&gt; out of the box and, therefore, provide by default what the OP has asked:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;SwapIt&lt;/strong&gt; by Michael Brown (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2294&quot; rel=&quot;noreferrer&quot;&gt;#2294&lt;/a&gt;, &lt;a href=&quot;https://github.com/mjbrownie/swapit&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;),&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Increment-activator&lt;/strong&gt; by Takuya Nishigori (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4817&quot; rel=&quot;noreferrer&quot;&gt;#4817&lt;/a&gt;, &lt;a href=&quot;https://github.com/nishigori/increment-activator&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;),&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;CtrlXA&lt;/strong&gt; by Konfekt (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=5600&quot; rel=&quot;noreferrer&quot;&gt;#5600&lt;/a&gt;, &lt;a href=&quot;https://github.com/Konfekt/vim-CtrlXA&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;),&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Cycle&lt;/strong&gt; by Zef Houssney (&lt;a href=&quot;https://github.com/zef/vim-cycle&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;),&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Cycle&lt;/strong&gt; by bootleq (&lt;a href=&quot;https://github.com/bootleq/vim-cycle&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A related plugin which also extends &lt;code&gt;Ctrl-A/X&lt;/code&gt; is &lt;em&gt;speeddating&lt;/em&gt; by Tim Pope (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2120&quot; rel=&quot;noreferrer&quot;&gt;#2120&lt;/a&gt;, &lt;a href=&quot;https://github.com/tpope/vim-speeddating&quot; rel=&quot;noreferrer&quot;&gt;github&lt;/a&gt;) which allows you to increment dates.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Fallback&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Some plugins allow to combine a second &lt;code&gt;Ctrl-A/X&lt;/code&gt; incrementor plugin as a fallback, e.g.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;SwapIt&lt;/em&gt; by Michael Brown:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;Plug&amp;gt;SwapItFallbackIncrement &amp;lt;Plug&amp;gt;SpeedDatingUp&#xA;nmap &amp;lt;Plug&amp;gt;SwapItFallbackDecrement &amp;lt;Plug&amp;gt;SpeedDatingDown&#xA;vmap &amp;lt;Plug&amp;gt;SwapItFallbackIncrement &amp;lt;Plug&amp;gt;SpeedDatingUp&#xA;vmap &amp;lt;Plug&amp;gt;SwapItFallbackDecrement &amp;lt;Plug&amp;gt;SpeedDatingDown&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;cycle&lt;/em&gt; by bootleq:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;CycleFallbackNext &amp;lt;Plug&amp;gt;SpeedDatingUp&#xA;map &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;CycleFallbackPrev &amp;lt;Plug&amp;gt;SpeedDatingDown&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;switch.vim&lt;/em&gt; by Andrew Radev:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-a&amp;gt; :if !switch#Switch()&amp;lt;bar&amp;gt;call speeddating#increment()&amp;lt;bar&amp;gt;endif&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;c-x&amp;gt; :if !switch#Switch({'reverse': 1})&amp;lt;bar&amp;gt;call speeddating#decrement()&amp;lt;bar&amp;gt;endif&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note&lt;br&gt;&#xA;If you use the seek behavior of the builtin &lt;code&gt;Ctrl-A/X&lt;/code&gt; (find next possible value in line to increment), supercharging them can interfere.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2020-02-20T17:06:18.227" LastActivityDate="2020-02-20T17:06:18.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18085" PostTypeId="1" AcceptedAnswerId="18088" CreationDate="2018-11-27T09:40:14.620" Score="3" ViewCount="1622" Body="&lt;p&gt;&lt;strong&gt;How can I create a keymap to send the visual selection/current line to a &lt;a href=&quot;https://www.vim.org/vim-8.1-released.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim terminal window&lt;/a&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I opened a normal vim window (containing only the line &lt;code&gt;echo test&lt;/code&gt;) and a vim terminal window and tried recording a macro and figuring it out from there, but ran into problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I ran &lt;code&gt;qqY&amp;lt;C-W&amp;gt;w&amp;lt;C-Shift-V&amp;gt;&amp;lt;C-W&amp;gt;wq&lt;/code&gt; but the resulting macro simple contained &lt;code&gt;echo test&lt;/code&gt; as opposed to a paste command (I got &lt;code&gt;Y^Ww&amp;lt;80&amp;gt;PSecho test^M&amp;lt;80&amp;gt;PE^Ww&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I tried to paste in the terminal window normal mode via &lt;code&gt;qqY&amp;lt;C-W&amp;gt;w&amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;p&amp;lt;C-W&amp;gt;wq&lt;/code&gt; but the paste didn't work and I got the error message &lt;code&gt;Cannot make changes, 'modifiable' is off&lt;/code&gt;. Trying &lt;code&gt;set modifiable&lt;/code&gt; I got &lt;code&gt;Cannot make a terminal with running job modifiable: modifiable&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following the answer by Christian Brabandt below, I added the lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F9&amp;gt; Y&amp;lt;C-W&amp;gt;w&amp;lt;C-W&amp;gt;&quot;0&amp;lt;C-W&amp;gt;w&#xA;xnoremap &amp;lt;F9&amp;gt; y&amp;lt;C-W&amp;gt;w&amp;lt;C-W&amp;gt;&quot;0&amp;lt;C-W&amp;gt;w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to my &lt;code&gt;.vimrc&lt;/code&gt;. This works almost as desired but has problems with whitespace and multiple lines. For example, if I select  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if False:&#xA;    pass&#xA;print('Done')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in VISUAL LINE mode, and press F9 to execute it in a terminal window running &lt;code&gt;ipython&lt;/code&gt;, the ipython terminal shows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In [1]: if False: &#xA;   ...:         pass &#xA;   ...:         print('Done') &#xA;   ...:     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is due to &lt;code&gt;ipython&lt;/code&gt;'s autoindentation, which can be turned off via &lt;code&gt;%autoindent&lt;/code&gt; or by starting &lt;code&gt;ipython&lt;/code&gt; with the option &lt;code&gt;--no-autoindent&lt;/code&gt;. Alternatively, &lt;code&gt;ipython&lt;/code&gt;'s &lt;code&gt;%paste&lt;/code&gt; command could be used. I would be nonetheless interested in a vim hack that behaves more like &lt;code&gt;&amp;lt;C-Shift-V&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18613" LastEditorUserId="18613" LastEditDate="2018-11-27T14:58:29.827" LastActivityDate="2018-11-27T14:58:29.827" Title="Execute visual selection/current line in Vim terminal via keymap" Tags="|terminal|terminal-buffer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18086" PostTypeId="1" AcceptedAnswerId="18091" CreationDate="2018-11-27T10:34:54.720" Score="2" ViewCount="438" Body="&lt;p&gt;The &lt;code&gt;BufWinLeave&lt;/code&gt; event is not trigger when the buffer is still visible in another window, which includes the case &lt;strong&gt;when it is shown in a window in another tab&lt;/strong&gt;. This is a annoying since only &lt;strong&gt;visible in the current tab&lt;/strong&gt; is truly visible; and you cannot see a buffer in the screen when it is &lt;strong&gt;only &quot;displayed&quot; in another tab&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want an autocmd to be executed when a buffer goes invisible from the &lt;strong&gt;screen (current tab)&lt;/strong&gt;. What is the best approach to achieve this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Let me make it more specific. I want an autocmd for this&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;a window's (W) buffer (B1) is changed to another one (B2) or that window is destroyed;&lt;/li&gt;&#xA;&lt;li&gt;B1 is not displayed in other windows of the current tabpage&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is equivalent to say:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;B1 disappears from the current tabpage (i.e. the screen)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that if the whole current tabpage is closed, the entering tabpage becomes the current tabpage. So &quot;disappears from the screen&quot; is the more accurate statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not care about whether B1 is shown in other tabpages; and it should not be triggered when the cursor moves between splits of the current tabpage, like what &lt;code&gt;BufLeave&lt;/code&gt; and &lt;code&gt;WinLeave&lt;/code&gt; do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Originally, I thought this might be described by &lt;code&gt;BufWinLeave&lt;/code&gt;, but I realized today that &lt;code&gt;BufWinLeave&lt;/code&gt; does not work like this. &lt;code&gt;BufWinLeave&lt;/code&gt; is not triggered when the buffer is displayed in another tabpage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, in my understanding, &lt;code&gt;BufWinLeave&lt;/code&gt; works exactly the same as &lt;code&gt;BufHidden&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;when a buffer turns to be not shown in any of the window in any tabpage.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Please tell me if my understanding is wrong.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-11-28T02:46:59.673" LastActivityDate="2018-11-28T02:55:25.410" Title="alternative of `BufWinLeave` autocmd that triggers when buffer goes invisible from the screen" Tags="|autocmd|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18088" PostTypeId="2" ParentId="18085" CreationDate="2018-11-27T13:11:27.400" Score="4" Body="&lt;p&gt;If you want to paste something into the terminal window, you can use the command &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;W&lt;/kbd&gt;&lt;kbd&gt;Reg&lt;/kbd&gt; (if you are in &lt;a href=&quot;http://vimhelp.appspot.com/terminal.txt.html#Terminal-mode&quot; rel=&quot;nofollow noreferrer&quot;&gt;terminal job mode&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your macro, that would be something along:&#xA;&lt;code&gt;qqY&amp;lt;C-W&amp;gt;w&amp;lt;C-W&amp;gt;&quot;0&amp;lt;C-W&amp;gt;wq&lt;/code&gt; (provided that the cursor is at the start of the line in the other window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error message &lt;code&gt;Cannot make changes, 'modifiable' is off&lt;/code&gt; happens because the job inside the terminal is still running and you simply cannot paste anything into the buffer in Terminal Normal mode. You can do it, once the job finished (but that might close the terminal window) and you issue the &lt;code&gt;:set modifiable&lt;/code&gt; command. But since the job (shell) is not running anymore, it cannot process the pasted content.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-11-27T13:11:27.400" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18089" PostTypeId="1" CreationDate="2018-11-27T15:18:56.903" Score="1" ViewCount="497" Body="&lt;p&gt;Sometimes I accidentally type &lt;code&gt;ma&lt;/code&gt; instead of &lt;code&gt;'a&lt;/code&gt; and overwrite the mark I had at &lt;code&gt;a&lt;/code&gt; instead of jumping there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that by default vim has no way to undo an &lt;code&gt;ma&lt;/code&gt;, but how can I add this functionality?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to undo an accidental mark overwrite.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2018-11-27T23:19:48.970" Title="undo mark overwrite" Tags="|mark|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ClosedDate="2018-11-28T09:14:02.010" ContentLicense="CC BY-SA 4.0" />
  <row Id="18090" PostTypeId="2" ParentId="18079" CreationDate="2018-11-27T16:33:20.770" Score="7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;how to check whether the location list for the current window is open&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could try to inspect the &lt;code&gt;'winid'&lt;/code&gt; property of the location list. If the location window is open, the value of the property should be different than zero:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if get(getloclist(0, {'winid':0}), 'winid', 0)&#xA;    &quot; the location window is open&#xA;    ...&#xA;else&#xA;    &quot; the location window is closed&#xA;    ...&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;once a location list window is found, how can I know which window it is associated with?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could try to inspect the &lt;code&gt;'filewinid'&lt;/code&gt; property of the location list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo get(getloclist(0, {'filewinid':0}), 'filewinid', 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This requires the Vim patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.0345&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.0345&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your Vim version doesn't include this patch, or if you use Neovim which &lt;a href=&quot;https://github.com/neovim/neovim/blob/3348eea429d67fdb3942a9e60d60deb8f59b3ec8/runtime/doc/eval.txt#L4260-L4271&quot; rel=&quot;nofollow noreferrer&quot;&gt;doesn't implement&lt;/a&gt; &lt;a href=&quot;https://github.com/neovim/neovim/blob/3348eea429d67fdb3942a9e60d60deb8f59b3ec8/runtime/doc/eval.txt#L4349-L4373&quot; rel=&quot;nofollow noreferrer&quot;&gt;this property&lt;/a&gt; at the moment, you could try this code instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! Get_associated_window() abort&#xA;    let win_ids = get(gettabinfo(tabpagenr())[0], 'windows', {})&#xA;    let loc_id = win_getid()&#xA;    return get(filter(win_ids, {i,v -&amp;gt; get(getloclist(v, {'winid': 0}), 'winid', 0) ==# loc_id &amp;amp;&amp;amp; v !=# loc_id }) , 0, 0)&#xA;endfu&#xA;echo Get_associated_window()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h getloclist()&#xA;:h getqflist()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-11-27T19:19:30.713" LastActivityDate="2018-11-27T19:19:30.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18091" PostTypeId="2" ParentId="18086" CreationDate="2018-11-27T17:55:27.873" Score="2" Body="&lt;p&gt;When you close the window of a buffer &lt;code&gt;B1&lt;/code&gt; which is still displayed in another tabpage, &lt;code&gt;QuitPre&lt;/code&gt;, &lt;code&gt;BufLeave&lt;/code&gt; and &lt;code&gt;WinLeave&lt;/code&gt; are fired in the context of &lt;code&gt;B1&lt;/code&gt;. Then, &lt;code&gt;WinEnter&lt;/code&gt; and &lt;code&gt;BufEnter&lt;/code&gt; are fired in the context of the buffer where the focus goes (&lt;code&gt;B2&lt;/code&gt;).&#xA;None of these events matches your description:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;B1 disappears from the current tabpage (i.e. the screen)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, you could listen to &lt;code&gt;BufLeave&lt;/code&gt; to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;capture the number of the current buffer (&lt;code&gt;B1&lt;/code&gt;) and the one of the current tabpage&lt;/li&gt;&#xA;&lt;li&gt;install a fire-once autocmd listening to &lt;code&gt;BufEnter&lt;/code&gt; to, later, check whether &lt;code&gt;B1&lt;/code&gt; is still displayed in the current tabpage&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And when &lt;code&gt;B1&lt;/code&gt; does become invisible, you could fire a custom &lt;code&gt;BufInvisible&lt;/code&gt; event (using &lt;code&gt;:doautocmd&lt;/code&gt;, see &lt;code&gt;:h :do&lt;/code&gt;).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you could listen to this new event to execute an arbitrary command.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup will_buffer_become_invisible&#xA;    au!&#xA;    au BufLeave * call s:will_buffer_become_invisible()&#xA;augroup END&#xA;&#xA;fu! s:will_buffer_become_invisible() abort&#xA;    let s:bufnr = bufnr('%')&#xA;    let s:tabnr = tabpagenr()&#xA;    augroup has_buffer_become_invisible&#xA;        au!&#xA;        au TabClosed * exe 'au! has_buffer_become_invisible'&#xA;            \ | aug! has_buffer_become_invisible&#xA;        au BufEnter * call s:has_buffer_become_invisible()&#xA;            \ | exe 'au! has_buffer_become_invisible'&#xA;            \ | aug! has_buffer_become_invisible&#xA;    augroup END&#xA;endfu&#xA;&#xA;fu! s:has_buffer_become_invisible() abort&#xA;    let other_winids = filter(win_findbuf(s:bufnr), {i,v -&amp;gt; get(get(getwininfo(v), 0, {}), 'tabnr', 0) == s:tabnr})&#xA;    if empty(other_winids) &amp;amp;&amp;amp; exists('#User#BufInvisible')&#xA;        do &amp;lt;nomodeline&amp;gt; User BufInvisible&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To listen to &lt;code&gt;BufInvisible&lt;/code&gt;, you would write something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup test_BufInvisible&#xA;    au!&#xA;    au User BufInvisible echom 'a buffer has become invisible'&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In &lt;code&gt;#User#BufInvisible&lt;/code&gt;, is (1) &lt;code&gt;User&lt;/code&gt; interpreted as group and &lt;code&gt;BufInvisible&lt;/code&gt;&#xA;  as event; or (2) &lt;code&gt;User&lt;/code&gt; as event and &lt;code&gt;BufInvisible&lt;/code&gt; as pattern?&#xA;  (see the syntax for &lt;code&gt;exists()&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Technically, &lt;code&gt;User&lt;/code&gt; is an event. It's listed among other events at &lt;code&gt;:h User&lt;/code&gt;, and the help refers to it as an event at &lt;code&gt;:h :do&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You probably want to use &amp;lt;nomodeline&gt; for events that are not used when loading&#xA;  a buffer, such as &lt;code&gt;|User|&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's a special kind of event, because it's never fired by Vim automatically. You have to fire it yourself by executing &lt;code&gt;:doautocmd&lt;/code&gt;. It allows to create your own event.&#xA;As a result, &lt;code&gt;BufInvisible&lt;/code&gt; is a pattern in:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;exists('#User#BufInvisible')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:do &amp;lt;nomodeline&amp;gt; User BufInvisible&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;au User BufInvisible&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Although, if you look at &lt;code&gt;:h :do&lt;/code&gt;, what follows the event is not a pattern, but a file name:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:do[autocmd] [&amp;lt;nomodeline&amp;gt;] [group] {event} [fname]&#xA;                                            ^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But here, &lt;code&gt;BufInvisible&lt;/code&gt; is just a pattern, not a file name. It's matched against the name of the custom &lt;code&gt;User&lt;/code&gt; event which has been fired.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If &lt;code&gt;BufInvisible&lt;/code&gt; is the not a pattern, can I add a pattern to the &lt;code&gt;au&lt;/code&gt;? I do not know the syntax for &lt;code&gt;au User&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;BufInvisible&lt;/code&gt; is the pattern, so you can't add another one after &lt;code&gt;:au&lt;/code&gt;.&#xA;The syntax for &lt;code&gt;:au User&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au User &amp;lt;your custom event&amp;gt; &amp;lt;your command&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As an example, if your custom event is &lt;code&gt;MyNewEvent&lt;/code&gt;, and you want to log a message in &lt;code&gt;:messages&lt;/code&gt; whenever it's fired, you could write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au User MyNewEvent echom 'MyNewEvent has been fired'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;why do you use &lt;code&gt;exe 'au! has_buffer_become_invisible'&lt;/code&gt; instead of &lt;code&gt;au! has_buffer_become_invisible&lt;/code&gt;? Is it because au handles &lt;code&gt;|&lt;/code&gt; by itself.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You're right, &lt;code&gt;:autocmd&lt;/code&gt; considers the bar as being part of its argument, and can't be followed by another Vim command. It's explained at &lt;code&gt;:h :bar&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:execute&lt;/code&gt; prevents &lt;code&gt;:autocmd&lt;/code&gt; from seeing what's outside the string, so it should leave &lt;code&gt;:aug!&lt;/code&gt; alone. The purpose of the latter is to remove the augroup, once &lt;code&gt;:au!&lt;/code&gt; has cleared it (you can't remove an augroup when it's not empty; see &lt;code&gt;:h :augroup-delete&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-11-28T02:55:25.410" LastActivityDate="2018-11-28T02:55:25.410" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18092" PostTypeId="1" AcceptedAnswerId="24676" CreationDate="2018-11-27T20:13:43.990" Score="12" ViewCount="9196" Body="&lt;p&gt;I can search for whole words like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\&amp;lt;search term\&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; match left and right word boundaries respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how can I insert those automatically? They are awkward to type out.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="2920" LastEditDate="2018-11-27T21:29:06.547" LastActivityDate="2020-04-18T18:20:27.897" Title="Faster way to search for whole words" Tags="|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18093" PostTypeId="2" ParentId="18092" CreationDate="2018-11-27T21:28:38.310" Score="12" Body="&lt;p&gt;There are two different ways to do this.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You can insert those &lt;em&gt;and&lt;/em&gt; the word currently under your cursor with &lt;code&gt;*&lt;/code&gt;. So for example, if your cursor is on &quot;hello&quot;, and you press asterisk, vim will treat that the same as &lt;code&gt;/\&amp;lt;hello\&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt;. This is generally going to be the fastest way (&lt;a href=&quot;https://vi.stackexchange.com/a/13690/2920&quot;&gt;more info&lt;/a&gt;). However, there's one downside. If you don't have the word you want to search for in your buffer, then you can't really navigate to that word and press &lt;code&gt;*&lt;/code&gt;. And doing something like &lt;code&gt;iHello&amp;lt;esc&amp;gt;*u&lt;/code&gt; isn't really that much better than just &lt;code&gt;/\&amp;lt;Hello\&amp;gt;&lt;/code&gt;. So this is only more efficient when you are near that word. If that happens a lot, you could try method 2:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create a mapping. Since we don't want to overwrite &lt;code&gt;/&lt;/code&gt;, this is the perfect use case for &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;. I personally would do this (put in &lt;code&gt;.vimrc&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;/ /\&amp;lt;\&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will insert the brackets &lt;em&gt;and&lt;/em&gt; position your cursor between them so you can type out the word you want to search.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2020-04-18T15:35:24.513" LastActivityDate="2020-04-18T15:35:24.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18094" PostTypeId="2" ParentId="18089" CreationDate="2018-11-27T21:41:59.363" Score="1" Body="&lt;p&gt;I am not sure this is a solution, as this might have too many nasty side effects. But one way to reset lost marks, is to re-read the viminfo file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So after you have accidentally pressed &lt;code&gt;ma&lt;/code&gt;, you can issue &lt;code&gt;:rviminfo!&lt;/code&gt; to re-read the viminfo file. The &lt;code&gt;!&lt;/code&gt; causes it to overwrite all marks, registers, command-line histories, search history... from the current session (so this solution might not work all the time).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, it should be possible to edit the viminfo file, just keeping the marks section, save it as a temporary file and then using &lt;code&gt;:rviminfo! temp_viminfo_with_marks&lt;/code&gt; to just restore the marks for each particular file.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-11-27T21:41:59.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18095" PostTypeId="2" ParentId="18089" CreationDate="2018-11-27T23:19:48.970" Score="2" Body="&lt;p&gt;Here's some Vimscript that achieves your goal. To undo mark &lt;code&gt;a&lt;/code&gt;, type &lt;code&gt;&amp;lt;leader&amp;gt;ma&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's various ways this could be tweaked/polished, but it should be a good starting point for a more robust solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap m :call UndoableMark()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;m :call UndoMark()&amp;lt;CR&amp;gt;&#xA;&#xA;function! UndoableMark() abort&#xA;    let mark = nr2char(getchar())&#xA;    if mark =~ '\a'&#xA;        try&#xA;            execute 'let s:save_mark_' . mark . ' = getpos(&quot;''' . mark . '&quot;)'&#xA;        catch&#xA;        endtry&#xA;    endif&#xA;    execute 'normal! m' . mark&#xA;endfunction&#xA;&#xA;function! UndoMark() abort&#xA;    let mark = nr2char(getchar())&#xA;    execute 'call setpos(&quot;''' . mark . '&quot;, s:save_mark_' . mark . ')'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-11-27T23:19:48.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18096" PostTypeId="1" CreationDate="2018-11-27T23:43:16.003" Score="2" ViewCount="675" Body="&lt;p&gt;I'm developing a GUI client of Neovim, and looking for the way to get the text in command input area using msgpack-rpc.&#xA;I mean that the 'text in command input area' is the bottom of Neovim window. &#xA;(Sorry, I'm not sure how to express it.)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/0ve3N.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0ve3N.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does Neovim have any APIs to get it like &lt;code&gt;buffer_get_line()&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="19984" LastEditorUserId="2920" LastEditDate="2018-11-27T23:49:32.703" LastActivityDate="2018-12-04T23:14:41.370" Title="Can Neovim API get the text in command input area?" Tags="|neovim|macos|vim-development|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18097" PostTypeId="2" ParentId="18086" CreationDate="2018-11-28T02:10:46.860" Score="1" Body="&lt;p&gt;Based on @user938271's answer, I slightly changed the code so that it is more concise:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup will_buffer_become_invisible&#xA;    au! BufLeave * call s:will_buffer_become_invisible()&#xA;augroup END&#xA;&#xA;fu! s:will_buffer_become_invisible() abort&#xA;    augroup has_buffer_become_invisible&#xA;        exe printf('au! BufEnter * call s:has_buffer_become_invisible(%d)', bufnr('%'))&#xA;    augroup END&#xA;endfu&#xA;&#xA;fu! s:has_buffer_become_invisible(bufnr)&#xA;    try&#xA;        let other_wins = filter(range(1, winnr('$')), {i,v-&amp;gt;winbufnr(v) == a:bufnr})&#xA;        if empty(other_wins) &amp;amp;&amp;amp; exists('#User#BufInvisible')&#xA;            do &amp;lt;nomodeline&amp;gt; User BufInvisible&#xA;        endif&#xA;    finally&#xA;        au! has_buffer_become_invisible&#xA;        aug! has_buffer_become_invisible&#xA;    endtry&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: here if you close a tabpage it will check whether the entering tabpage will have the buffer shown.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-11-28T02:39:06.350" LastActivityDate="2018-11-28T02:39:06.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18098" PostTypeId="2" ParentId="1942" CreationDate="2018-11-28T10:08:22.760" Score="8" Body="&lt;p&gt;Vim 8 introduced jobs support. One can run external command in the background without relying on plugins. For example, to run a markdown server (&lt;a href=&quot;https://github.com/markserv/markserv&quot; rel=&quot;noreferrer&quot;&gt;markserv&lt;/a&gt;) at current location and not block vim session:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call job_start('markserv .')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This starts markserv process as a sub-process of current vim process. You can verify this with &lt;code&gt;pstree&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/channel.txt.html#job-start&quot; rel=&quot;noreferrer&quot;&gt;job_start&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3114" LastActivityDate="2018-11-28T10:08:22.760" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18099" PostTypeId="1" CreationDate="2018-11-28T12:54:20.253" Score="3" ViewCount="294" Body="&lt;h2&gt;Background&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;:h motion.txt&lt;/code&gt;, it says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FORCING A MOTION TO BE LINEWISE, CHARACTERWISE OR BLOCKWISE&#xA;&#xA;When a motion is not of the type you would like to use, you can force another&#xA;type by using &quot;v&quot;, &quot;V&quot; or CTRL-V just after the operator.&#xA;Example: &amp;gt;&#xA;    dj&#xA;deletes two lines &amp;gt;&#xA;    dvj&#xA;deletes from the cursor position until the character below the cursor &amp;gt;&#xA;    d&amp;lt;C-V&amp;gt;j&#xA;deletes the character under the cursor and the character below the cursor. &amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;:h omap-info&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;To ignore the starting cursor position and select different text, you can have&#xA;the omap start Visual mode to select the text to be operated upon.  Example&#xA;that operates on a function name in the current line: &amp;gt;&#xA;    onoremap &amp;lt;silent&amp;gt; F :&amp;lt;C-U&amp;gt;normal! 0f(hviw&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;:h movement&lt;/code&gt; for what can be used as a motion&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    - Ex commands can be used to move the cursor.  This can be&#xA;      used to call a function that does some complicated motion.&#xA;      The motion is always characterwise exclusive, no matter&#xA;      what &quot;:&quot; command is used.  This means it's impossible to&#xA;      include the last character of a line without the line break&#xA;      (unless 'virtualedit' is set).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when these are combined:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the motion is an Ex command; and&lt;/li&gt;&#xA;&lt;li&gt;the Ex command select an visual area;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;the &lt;strong&gt;overwrite&lt;/strong&gt; will not has an effect; e.g. the overwrite &lt;code&gt;V&lt;/code&gt; in the following command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dV:normal hvl&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will not be able to change the motion to be linewise.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Now I want to define an textobject, for example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:motion()&#xA;  &quot; set the marks here&#xA;  return &quot;:\&amp;lt;c-u&amp;gt;normal! `[v`]\&amp;lt;cr&amp;gt;&quot;&#xA;endfunction&#xA;omap &amp;lt;expr&amp;gt; X s:motion()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to visually select the area. But I still want the motion wiseness of the textobject can be overwritten by &lt;code&gt;v&lt;/code&gt;, &lt;code&gt;V&lt;/code&gt;, &lt;code&gt;&amp;lt;C-V&amp;gt;&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dX       &quot; to work characterwise&#xA;dvX      &quot; to work characterwise, exclusive&#xA;dVX      &quot; to work linewise&#xA;d&amp;lt;c-v&amp;gt;X  &quot; to work blockwise&#xA;&#xA;&quot; can we get the overwrite v or V or &amp;lt;c-v&amp;gt; inside s:motion()? so that we can do&#xA;function! s:motion()&#xA;  &quot; set the marks here&#xA;  let overwrite = ??&#xA;  return printf(&quot;:\&amp;lt;c-u&amp;gt;normal! `[%s`]\&amp;lt;cr&amp;gt;&quot;, overwrite)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is it possible to achieve this &lt;strong&gt;without defining four different maps for &lt;code&gt;X&lt;/code&gt;, &lt;code&gt;vX&lt;/code&gt;, &lt;code&gt;VX&lt;/code&gt;, and &lt;code&gt;&amp;lt;c-v&amp;gt;X&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If the overwritten mode &lt;code&gt;v&lt;/code&gt; or &lt;code&gt;V&lt;/code&gt; or &lt;code&gt;&amp;lt;c-v&amp;gt;&lt;/code&gt; can be returned by a function, then the problem solves. But I cannot find such a function.&lt;/li&gt;&#xA;&lt;li&gt;Alternatively, can we select an area without using Ex command such as &lt;code&gt;:normal xxVxx&amp;lt;cr&amp;gt;&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-11-28T14:42:34.707" LastActivityDate="2018-11-29T01:17:01.037" Title="overwrite motion-wiseness of operator pending mode" Tags="|map-operator|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18100" PostTypeId="2" ParentId="18099" CreationDate="2018-11-28T14:35:31.717" Score="3" Body="&lt;p&gt;@christian had referred a very useful &lt;a href=&quot;https://github.com/vim/vim/issues/3490&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt; to me, which already provided a solution in the future release of vim. Specifically: &lt;code&gt;mode(1)&lt;/code&gt; will return &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;no&quot;         &quot; for operator-pending&#xA;&quot;nov&quot;        &quot; for operator-pending forced to characterwise&#xA;&quot;noV&quot;        &quot; for operator-pending forced to linewise&#xA;&quot;no\&amp;lt;c-v&amp;gt;&quot;   &quot; for operator-pending forced to blockwise&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the patched provided, I will be able to do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:motion()&#xA;  &quot; set the marks here&#xA;  let motion_force = mode(1)[2:]&#xA;  let motion_force = motion_force == ''? 'v' : motion_force&#xA;  return printf(&quot;:\&amp;lt;c-u&amp;gt;normal! `[%s`]\&amp;lt;cr&amp;gt;&quot;, motion_force)&#xA;endfunction&#xA;onoremap &amp;lt;expr&amp;gt; X s:motion()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-11-29T01:17:01.037" LastActivityDate="2018-11-29T01:17:01.037" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18102" PostTypeId="2" ParentId="15011" CreationDate="2018-11-28T16:13:27.153" Score="1" Body="&lt;p&gt;Maybe this function will help you? I use it in my neovim configuration. With it :bprev works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ToggleNetrw display netrw explorer in current window (with command :Ntree) on specified directory (or parent directory of current opened file) and cleanup excess buffer to fix unexpected :bprev behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second call of ToggleNetrw hide explorer and show previous buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleNetrw(...)&#xA;  if &amp;amp;filetype ==# 'netrw'&#xA;    execute 'Rexplore'&#xA;  else&#xA;    if a:0 ==# 1&#xA;      let path = fnamemodify(expand(a:1), ':p')&#xA;    else&#xA;      let path = fnamemodify(expand('%'), ':p:h')&#xA;    endif&#xA;    execute 'Ntree' path&#xA;    let excess_buffer = bufnr(path)&#xA;    if excess_buffer != -1&#xA;      execute 'bdelete' excess_buffer&#xA;    endif&#xA;  endif&#xA;endf&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;ee :call ToggleNetrw()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;ec :call ToggleNetrw('.')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;eh :call ToggleNetrw($HOME)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19999" LastEditorUserId="19999" LastEditDate="2018-11-29T11:03:51.473" LastActivityDate="2018-11-29T11:03:51.473" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18103" PostTypeId="2" ParentId="18099" CreationDate="2018-11-28T16:25:36.267" Score="1" Body="&lt;p&gt;If your desired operator is a motion rather than a text object (i.e., does not need to alter the starting position), and it is exclusive, you can instead use absolute positioning.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:motion()&#xA;  &quot; ... compute cursor position for motion ...&#xA;  call cursor(28, 10)&#xA;endfunction&#xA;onoremap X :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;motion()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;dvX&lt;/code&gt;, &lt;code&gt;dVX&lt;/code&gt; and &lt;code&gt;d&amp;lt;c-v&amp;gt;X&lt;/code&gt; work as expected.  Thus it is not a problem to use ex commands, it is only bad to enter visual mode, as in your example maps.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2018-11-28T16:25:36.267" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18104" PostTypeId="1" CreationDate="2018-11-29T02:53:20.883" Score="1" ViewCount="56" Body="&lt;p&gt;In my understanding, the return value of &lt;code&gt;execute(command)&lt;/code&gt; should be what &lt;code&gt;command&lt;/code&gt; outputs. (The second parameter of &lt;code&gt;execute&lt;/code&gt; is to affect whether this output will also be displayed in vim.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;command&lt;/code&gt; runs a function and inside the function there is &lt;code&gt;silent! echo 3&lt;/code&gt;. so command itself does not have output. Shouldn't the result of &lt;code&gt;execute&lt;/code&gt; be empty?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:x()&#xA;  silent! echo 3&#xA;endfunction&#xA;let x = execute('call s:x()') &#xA;&quot; let x = execute('call s:x()', '')  does not alter the output&#xA;&quot; this means `call s:x()` itself has no output&#xA;echo 'x is' x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;shows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x is&#xA;3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x is    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is this a bug?&lt;/strong&gt; How to explain the phenomenon in the comment?&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-11-29T02:53:20.883" Title="return value of execute(command) when command has &quot;silent!&quot;" Tags="|echo|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18105" PostTypeId="1" AcceptedAnswerId="18108" CreationDate="2018-11-29T03:13:30.110" Score="1" ViewCount="409" Body="&lt;p&gt;I want &lt;code&gt;:nohl&lt;/code&gt; to be run automatically whenever I run &lt;code&gt;:w&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I set this up?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWrite * :nohl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my vimrc but that's not working&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Apparently (from comments, thanks &lt;a href=&quot;https://vi.stackexchange.com/users/10604/d-ben-knoble&quot;&gt;D. Ben Knoble&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Theres a note in the help somewhere about how you cant use nohl in autocmds&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So how can I do it without autocmds?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="205" LastEditDate="2019-11-06T06:52:25.373" LastActivityDate="2019-11-06T06:52:25.373" Title="Make :w automatically run :nohl" Tags="|command-line|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18106" PostTypeId="1" AcceptedAnswerId="18107" CreationDate="2018-11-29T03:25:40.767" Score="20" ViewCount="6126" Body="&lt;p&gt;&lt;code&gt;&amp;amp;&lt;/code&gt; repeats the last &lt;code&gt;:s&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it doesn't repeat with flags, e.g. a global sub:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/&quot;/'/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;won't replace in the same way on consecutive lines with &lt;code&gt;&amp;amp;&lt;/code&gt;, running &lt;code&gt;:s/&quot;/'/g&lt;/code&gt; on the first line here and then &lt;code&gt;&amp;amp;&lt;/code&gt; on the second&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&quot;first&quot;, &quot;second&quot;]&#xA;[&quot;third&quot;, &quot;fourth&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;produces&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['first', 'second']&#xA;['third&quot;, &quot;fourth&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the global option has been forgotten about when using &lt;code&gt;&amp;amp;&lt;/code&gt; on the second line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I quickly repeat last substitute command &lt;em&gt;with&lt;/em&gt; flags?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;not&lt;/em&gt;  &lt;code&gt;@:&lt;/code&gt; because I may have other commands run after &lt;code&gt;:s&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="9024" LastEditDate="2018-11-29T03:41:18.810" LastActivityDate="2021-05-21T09:52:37.717" Title="How can I repeat last substitution and with the same flags" Tags="|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18107" PostTypeId="2" ParentId="18106" CreationDate="2018-11-29T03:55:37.423" Score="22" Body="&lt;p&gt;This is exactly what &lt;code&gt;:&amp;amp;&amp;amp;&lt;/code&gt; does:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;                            *:&amp;amp;&amp;amp;*&#xA;[&amp;amp;] Must be the first one: Keep the flags from the previous substitute&#xA;    command.  Examples: &amp;gt;&#xA;        :&amp;amp;&amp;amp;&#xA;        :s/this/that/&amp;amp;&#xA;&amp;lt;   Note that `:s` and `:&amp;amp;` don't keep the flags.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There are also the &lt;code&gt;&amp;amp;&lt;/code&gt; and &lt;code&gt;g&amp;amp;&lt;/code&gt; commands:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;                                *&amp;amp;*&#xA;&amp;amp;           Synonym for `:s` (repeat last substitute).  Note&#xA;            that the flags are not remembered, thus it might&#xA;            actually work differently.  You can use `:&amp;amp;&amp;amp;` to keep&#xA;            the flags.&#xA;&#xA;                                *g&amp;amp;*&#xA;g&amp;amp;          Synonym for `:%s//~/&amp;amp;` (repeat last substitute with&#xA;            last search pattern on all lines with the same flags).&#xA;            For example, when you first do a substitution with&#xA;            `:s/pattern/repl/flags` and then `/search` for&#xA;            something else, `g&amp;amp;` will do `:%s/search/repl/flags`.&#xA;            Mnemonic: global substitute.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And you could map &lt;code&gt;&amp;amp;&lt;/code&gt; to be more like &lt;code&gt;:&amp;amp;&amp;amp;&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;amp; :&amp;amp;&amp;amp;&amp;lt;CR&amp;gt;&#xA;xnoremap &amp;amp; :&amp;amp;&amp;amp;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="10604" LastEditDate="2021-05-12T14:54:25.457" LastActivityDate="2021-05-12T14:54:25.457" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18108" PostTypeId="2" ParentId="18105" CreationDate="2018-11-29T06:54:59.427" Score="6" Body="&lt;p&gt;Indeed there is this note at &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#function-search-undo&quot; rel=&quot;noreferrer&quot;&gt;:h function-search-undo&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The last used search pattern and the redo command &quot;.&quot;&#xA;will not be changed by the function.  This also&#xA;implies that the effect of :nohlsearch is undone&#xA;when the function returns.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which also applies to auto commands, so as you noted, &lt;code&gt;:au BufWritePre * :nohls&lt;/code&gt; won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can trick Vim with using the &lt;code&gt;feedkeys()&lt;/code&gt; function. I think the following should work (and does from my limited testing):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWritePre * :call feedkeys(&quot;:nohls\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will inject the command directly into Vims typeahead buffer and won't be marked as coming from a function that needs to be undone once the auto command returns.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-11-29T06:54:59.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18109" PostTypeId="2" ParentId="13020" CreationDate="2018-11-29T09:54:01.550" Score="1" Body="&lt;p&gt;My experience in terminal Vim is the same as noted by Rich; trying to use &lt;kbd&gt;Shift&lt;/kbd&gt; and &lt;kbd&gt;Alt&lt;/kbd&gt; were equally fruitless.  So this isn't a direct answer, because it appears no one-size-fits-all answer exists due to technical limitations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end I compromised by using &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; as the modifier (usually set as &lt;kbd&gt;\&lt;/kbd&gt;).  I should note that this doesn't work quite the same as a normal modifier key combo, as you must strike &lt;kbd&gt;\&lt;/kbd&gt; before each press of &lt;kbd&gt;Backspace&lt;/kbd&gt;.  With the caveats above in mind, I think these mappings should broadly work for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Leader&amp;gt;&amp;lt;BS&amp;gt; &amp;lt;C-o&amp;gt;dd&#xA;nnoremap &amp;lt;Leader&amp;gt;&amp;lt;BS&amp;gt; dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may also want to look at your &lt;code&gt;timeoutlen&lt;/code&gt; value, depending on how long you want the Leader to wait for your next key strike.&lt;/p&gt;&#xA;" OwnerUserId="20007" LastEditorUserId="20007" LastEditDate="2018-11-29T15:42:41.967" LastActivityDate="2018-11-29T15:42:41.967" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18112" PostTypeId="1" AcceptedAnswerId="18113" CreationDate="2018-11-29T19:25:36.457" Score="1" ViewCount="407" Body="&lt;p&gt;I'm using Vim, installed from the Arch Linux repo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried adding &lt;code&gt;set fileencodings=utf-8&lt;/code&gt; and &lt;code&gt;set encoding=utf-8&lt;/code&gt;. I've tried with all caps (UTF instead of utf) and putting it in &lt;code&gt;/etc/vimrc&lt;/code&gt; and &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More over, I tried writing a file as UTF-8 using &lt;code&gt;:write ++enc=utf-8&lt;/code&gt; but that didn't work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm testing the files with &lt;code&gt;file test&lt;/code&gt; and it keeps telling me it's ASCII text. This is a problem since I use non-ASCII characters.&lt;/p&gt;&#xA;" OwnerUserId="18462" LastEditorUserId="2920" LastEditDate="2018-11-29T22:15:23.893" LastActivityDate="2018-11-29T22:15:23.893" Title="Vim not encoding with UTF-8" Tags="|encoding|linux-arch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18113" PostTypeId="2" ParentId="18112" CreationDate="2018-11-29T19:43:27.440" Score="3" Body="&lt;p&gt;I feel like an idiot. The test file doesn't have any non-ASCII characters in it, so there is nothing for &lt;code&gt;file&lt;/code&gt; to look for that would tell it the encoding Vim is using. So I repeated the test with &lt;code&gt;ä&lt;/code&gt; in it and it returns &quot;utf-8&quot; as desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, &lt;code&gt;file&lt;/code&gt; was doing its best, and Vim was doing what I wanted it to do.&lt;/p&gt;&#xA;" OwnerUserId="18462" LastActivityDate="2018-11-29T19:43:27.440" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18114" PostTypeId="1" AcceptedAnswerId="18125" CreationDate="2018-11-29T22:20:54.283" Score="3" ViewCount="1876" Body="&lt;p&gt;I'm currently using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;silent&amp;gt; &amp;lt;C-c&amp;gt; &amp;lt;/&amp;lt;C-X&amp;gt;&amp;lt;C-O&amp;gt;&amp;lt;C-X&amp;gt;&amp;lt;Esc&amp;gt;F&amp;lt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as per &lt;a href=&quot;https://stackoverflow.com/questions/130734/how-can-one-close-html-tags-in-vim-quickly&quot;&gt;this post&lt;/a&gt; and &lt;a href=&quot;http://vim.wikia.com/wiki/Auto_closing_an_HTML_tag&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt; to close &lt;code&gt;&amp;lt;&amp;gt;&amp;lt;/&amp;gt;&lt;/code&gt; tags of any kind with &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt;, which works a treat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am stuck coming up with a way to enter a new line indented and have the closing tag on the line below automatically placed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As follows (&lt;code&gt;|&lt;/code&gt; being the cursor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;body&amp;gt;|&amp;lt;/body&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... hit &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;body&amp;gt;&#xA;    |&#xA;&amp;lt;/body&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I notice this happens with just &lt;code&gt;&amp;lt;body&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt; (no closing tag) but I cannot get it to behave as required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any assistance would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="17531" LastActivityDate="2020-12-13T14:00:36.697" Title="Indent on New Line between HTML/XML Tags" Tags="|vimscript|indentation|filetype-html|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18116" PostTypeId="1" CreationDate="2018-11-30T05:02:36.490" Score="1" ViewCount="138" Body="&lt;p&gt;&lt;code&gt;yyp&lt;/code&gt; pastes the current line underneath itself and moves the cursor to the start of the new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I start with my cursor on X:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ysiml yuipXedicious&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after &lt;code&gt;yyp&lt;/code&gt; I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ysiml yuipXedicious&#xA;Ysiml yuipXedicious&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But now my cursor is on &lt;code&gt;Y&lt;/code&gt; (of the second line)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I paste so that my cursor will be on the &lt;code&gt;X&lt;/code&gt; of the second line (same column it was on when I pressed &lt;code&gt;p&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="1452" LastEditDate="2018-11-30T05:56:02.677" LastActivityDate="2018-11-30T05:56:02.677" Title="p (paste) but keep cursor same column" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18117" PostTypeId="2" ParentId="18116" CreationDate="2018-11-30T05:52:01.583" Score="2" Body="&lt;p&gt;The function name is terrible, but this works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Pcol(...) abort&#xA;  let a:above = get(a:, 1, 0)&#xA;  let l:col = virtcol('.')&#xA;  execute 'normal!' a:above ? 'P' : 'p'&#xA;  call cursor('.', l:col)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;Pcol()&lt;/code&gt; is called with &lt;code&gt;0&lt;/code&gt; or no argument, it will paste below the cursor, like &lt;kbd&gt;p&lt;/kbd&gt;. If called with &lt;code&gt;1&lt;/code&gt;, it will paste above the cursor, like &lt;kbd&gt;P&lt;/kbd&gt;. If the current cursor position lies beyond the length of the pasted line, it simply moves to the end of the pasted line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Map the function to whatever you like. You could even just remap &lt;kbd&gt;p&lt;/kbd&gt; and &lt;kbd&gt;P&lt;/kbd&gt; if you always want this behavior:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; p :call Pcol(0)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; P :call Pcol(1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1452" LastActivityDate="2018-11-30T05:52:01.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18118" PostTypeId="1" AcceptedAnswerId="18120" CreationDate="2018-11-30T07:40:34.523" Score="3" ViewCount="5097" Body="&lt;p&gt;File:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1111&#xA;2222&#xA;3333&#xA;4444&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I &lt;code&gt;yyP&lt;/code&gt; on 2222, the system clipboard is pasted in, not 2222 as expected. However, &lt;code&gt;:reg&lt;/code&gt; shows that 2222 was saved to register &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;&quot;&lt;/code&gt;. I expected it to save to th&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I &lt;code&gt;ddP&lt;/code&gt; on 4444, everything works as expected: That line is deleted and then 4444 is pasted. So, it seems delete is working as expected, but yank is not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current solution is to use &lt;code&gt;delete&lt;/code&gt; then &lt;code&gt;undo&lt;/code&gt; until I figure out why yanks aren't working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vim version 8.1&lt;/li&gt;&#xA;&lt;li&gt;Windows 10&lt;/li&gt;&#xA;&lt;li&gt;_vimrc does &lt;em&gt;not&lt;/em&gt; have &lt;code&gt;set clipboard=unnamed&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Also, interestingly, delete not only saves to a vim register, but also to the system clipboard. My impression is that this is abnormal, but I do prefer it this way.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="20016" LastActivityDate="2018-11-30T08:27:03.417" Title="Paste not working" Tags="|cut-copy-paste|paste|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18120" PostTypeId="2" ParentId="18118" CreationDate="2018-11-30T08:27:03.417" Score="5" Body="&lt;p&gt;For some reason, editing &lt;code&gt;_vimrc&lt;/code&gt; in the Vim file wasn't working. From within vim, if I used &lt;code&gt;:e! $MYVIMRC&lt;/code&gt; to change the file, everything worked out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I removed &lt;code&gt;set clipboard=unnamedplus&lt;/code&gt; and the behavior is now back to normal. Whew!&lt;/p&gt;&#xA;" OwnerUserId="20016" LastActivityDate="2018-11-30T08:27:03.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18121" PostTypeId="1" CreationDate="2018-11-30T18:56:11.393" Score="0" ViewCount="144" Body="&lt;p&gt;The vim documentation of the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/if_pyth.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python interface to vim&lt;/a&gt; mentions:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The height attribute is writable only if the screen is split horizontally.&#xA;  The width attribute is writable only if the screen is split vertically.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It seems to assume that a split has already been made. But I did not find on that page is how to split a window using python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is how does one split a python window horizontally/vertically using python?&lt;/p&gt;&#xA;" OwnerUserId="20023" LastActivityDate="2019-08-27T20:02:05.277" Title="How do I split a vim Window using python?" Tags="|vimscript-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18123" PostTypeId="2" ParentId="18121" CreationDate="2018-11-30T19:04:11.177" Score="1" Body="&lt;p&gt;&lt;code&gt;:py vim.command(&quot;sp&quot;)&lt;/code&gt; did it for me.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2018-11-30T19:04:11.177" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18124" PostTypeId="1" AcceptedAnswerId="18131" CreationDate="2018-12-01T10:04:07.507" Score="2" ViewCount="563" Body="&lt;p&gt;Whenever I want to record complex macro between &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; and &lt;kbd&gt;q&lt;/kbd&gt;, I have to remember that, for instance, I can't use &lt;kbd&gt;Tab&lt;/kbd&gt;-completion while type some &lt;code&gt;ex&lt;/code&gt; command, otherwise the macro will not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have I really to teach myself avoiding &lt;kbd&gt;Tab&lt;/kbd&gt;-completion (which is so aggressive in my muscle memory) while recording a macro? Or is there a way to make it work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(BTW, &lt;kbd&gt;Tab&lt;/kbd&gt;-completion is not even available when I enter Vim by &lt;code&gt;vi -u NONE&lt;/code&gt; (but it is if I simply delete my &lt;code&gt;.vimrc&lt;/code&gt; file), so maybe the problem is an obvious consequence of how the &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; mapping works.)&lt;/p&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="6498" LastEditDate="2018-12-02T09:40:16.790" LastActivityDate="2018-12-28T05:05:16.123" Title="`q` does not record tab completion correctly" Tags="|autocompletion|macro|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="18125" PostTypeId="2" ParentId="18114" CreationDate="2018-12-01T13:01:41.113" Score="2" Body="&lt;h2&gt;Plugin &lt;em&gt;xml.vim&lt;/em&gt; by Rene de Zwart (&lt;a href=&quot;https://github.com/othree/xml.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;, &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1397&quot; rel=&quot;nofollow noreferrer&quot;&gt;#1397&lt;/a&gt;)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This plugin defines two relevant insert mode mappings &lt;code&gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;;;&lt;/code&gt;. They work as following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When you have already &lt;code&gt;&amp;lt;body&amp;gt;|&amp;lt;/body&amp;gt;&lt;/code&gt;, type &lt;code&gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When you have &lt;code&gt;body&lt;/code&gt;, type &lt;code&gt;;;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For both you should end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;body&amp;gt;&#xA;    |&#xA;&amp;lt;/body&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similar insert mode behavior are provided by the plugins&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;xmledit&lt;/strong&gt; by &lt;em&gt;Devin Weaver&lt;/em&gt; (&lt;a href=&quot;https://github.com/sukima/xmledit&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;, &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=301&quot; rel=&quot;nofollow noreferrer&quot;&gt;#301&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When in insert mode and you finish a tag&#xA;  (pressing &lt;code&gt;&amp;gt;&lt;/code&gt;) the tag will be completed. If you press &lt;code&gt;&amp;gt;&lt;/code&gt; twice, it will&#xA;  complete the tag and place the cursor in the middle of the tags on it's own&#xA;  line (helps with nested tags).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Closetag&lt;/strong&gt; by alvan (&lt;a href=&quot;https://github.com/alvan/vim-closetag&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;) (Based on xml.vim)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;table|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Now you press &lt;code&gt;&amp;gt;&lt;/code&gt;, the content will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;table&amp;gt;|&amp;lt;/table&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;And now if you press &lt;code&gt;&amp;gt;&lt;/code&gt; again, the content will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;table&amp;gt;&#xA;    |&#xA;&amp;lt;/table&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;The following tags will not be closed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;area&amp;gt;, &amp;lt;base&amp;gt;, &amp;lt;br&amp;gt;, &amp;lt;col&amp;gt;, &amp;lt;command&amp;gt;, &amp;lt;embed&amp;gt;, &amp;lt;hr&amp;gt;, &amp;lt;img&amp;gt;, &#xA;&amp;lt;input&amp;gt;, &amp;lt;keygen&amp;gt;, &amp;lt;link&amp;gt;, &amp;lt;meta&amp;gt;, &amp;lt;param&amp;gt;, &amp;lt;source&amp;gt;, &amp;lt;track&amp;gt;, &amp;lt;wbr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;HTML AutoCloseTag&lt;/strong&gt; by Michael Sanders (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2591&quot; rel=&quot;nofollow noreferrer&quot;&gt;#2591&lt;/a&gt;) with remapping of &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;ino &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt; &amp;lt;&amp;gt;&amp;lt;left&amp;gt;&#xA;ino &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;gt; &amp;lt;c-r&amp;gt;=&amp;lt;SID&amp;gt;CloseTag()&amp;lt;cr&amp;gt;&#xA;ino &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; &amp;lt;SID&amp;gt;Return()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Return()&lt;/code&gt; remaps &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;\&amp;lt;up&amp;gt;&lt;/code&gt; which does no autoindentation. Following patch changes this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- orig_html_autoclosetag.vim  2018-12-03 10:57:54.000000000 +0100&#xA;+++ html_autoclosetag.vim   2018-12-03 10:57:10.000000000 +0100&#xA;@@ -24,7 +24,7 @@&#xA; fun s:Return()&#xA;    let tag = s:GetCurrentTag()&#xA;    return tag != '' &amp;amp;&amp;amp; match(getline('.'), '&amp;lt;/'.tag.'&amp;gt;') &amp;gt; -1 ?&#xA;-               \ &quot;\&amp;lt;cr&amp;gt;\&amp;lt;cr&amp;gt;\&amp;lt;up&amp;gt;&quot; : &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;+               \ &quot;\&amp;lt;cr&amp;gt;\&amp;lt;esc&amp;gt;O&quot; : &quot;\&amp;lt;cr&amp;gt;&quot;&#xA; endf&#xA;&#xA; fun s:InComment()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you would enter &lt;code&gt;&amp;lt;body&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to get the desired result.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-12-03T10:10:48.323" LastActivityDate="2018-12-03T10:10:48.323" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18126" PostTypeId="2" ParentId="18114" CreationDate="2018-12-01T13:12:22.303" Score="2" Body="&lt;h2&gt;Plugin &lt;em&gt;vim-ragtag&lt;/em&gt; by Tim Pope (&lt;a href=&quot;https://github.com/tpope/vim-ragtag&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;, &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1896&quot; rel=&quot;nofollow noreferrer&quot;&gt;#1896&lt;/a&gt;)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This plugin defines following insert mode mappings which are useful after you have only typed &lt;code&gt;body&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;Space&amp;gt;  &amp;lt;foo&amp;gt;^&amp;lt;/foo&amp;gt;                              *ragtag-CTRL-X_&amp;lt;Space&amp;gt;*&#xA;&amp;lt;C-X&amp;gt;&amp;lt;CR&amp;gt;     &amp;lt;foo&amp;gt;\n^\n&amp;lt;/foo&amp;gt;                          *ragtag-CTRL-X_&amp;lt;CR&amp;gt;*&#xA;&amp;lt;C-X&amp;gt;/        Last HTML tag closed                      *ragtag-CTRL-X_/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it does not provide a mapping to change &lt;code&gt;&amp;lt;body&amp;gt;|&amp;lt;/body&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;body&amp;gt;\n|\n&amp;lt;/body&amp;gt;&lt;/code&gt;.&#xA;On the other side, the mappings can be considered less intrusive.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2020-05-03T15:44:37.633" LastActivityDate="2020-05-03T15:44:37.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18127" PostTypeId="2" ParentId="18114" CreationDate="2018-12-01T13:20:02.297" Score="2" Body="&lt;h3&gt;Plugin &lt;em&gt;splitjoin.vim&lt;/em&gt; by Andrew Radev (&lt;a href=&quot;https://github.com/AndrewRadev/splitjoin.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;, &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=3613&quot; rel=&quot;nofollow noreferrer&quot;&gt;#3613&lt;/a&gt;) for Normal Mode&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you want to change the style afterwards in normal mode, the plugin &lt;code&gt;splitjoin.vim&lt;/code&gt; makes this possible with the mapping &lt;code&gt;gS&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The idea of this plugin is to introduce a single key binding (default: &lt;code&gt;gS&lt;/code&gt;) for&#xA;  transforming a line like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div id=&quot;foo&quot;&amp;gt;bar&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div id=&quot;foo&quot;&amp;gt;&#xA;  bar&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The other direction is also possible with &lt;code&gt;gJ&lt;/code&gt; when the cursor is on the opening or closing tag.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-12-02T11:20:30.057" LastActivityDate="2018-12-02T11:20:30.057" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18128" PostTypeId="2" ParentId="18114" CreationDate="2018-12-01T13:37:41.820" Score="1" Body="&lt;h3&gt;Plugin Lexima &lt;a href=&quot;https://github.com/deathlyfrantic/lexima-template-rules&quot; rel=&quot;nofollow noreferrer&quot;&gt;Rules for HTML &amp;amp; Templates&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The plugin &lt;a href=&quot;https://github.com/cohama/lexima.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;lexima.vim&lt;/a&gt; provides smart behaviour when entering an opening expression, pressing &lt;code&gt;&amp;lt;backspace&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default rules e.g. for &lt;code&gt;(,[,{&lt;/code&gt; exist. However, someone else has written a few rules for html/xml and template languages such as jinja and has published them in a separate github repository under the title &lt;em&gt;lexima-template-rules&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/deathlyfrantic/lexima-template-rules&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/deathlyfrantic/lexima-template-rules&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant rules are described as following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;Before                      Input                   After&#xA;----------------------------------------------------------------------------&#xA;|                           &amp;lt;                       &amp;lt;|&amp;gt;&#xA;----------------------------------------------------------------------------&#xA;&amp;lt;|&amp;gt; or &amp;lt;|/&amp;gt;                 &amp;lt;Backspace&amp;gt;             |&#xA;----------------------------------------------------------------------------&#xA;&amp;lt;tag&amp;gt;| or &amp;lt;tag/&amp;gt;|           &amp;lt;Backspace&amp;gt;             &amp;lt;tag|&amp;gt; or &amp;lt;tag|/&amp;gt;&#xA;----------------------------------------------------------------------------&#xA;&amp;lt;tag foo=&quot;bar&quot;|&amp;gt;            /                       &amp;lt;tag foo=&quot;bar&quot;/&amp;gt;|&#xA;----------------------------------------------------------------------------&#xA;&amp;lt;tag|/&amp;gt;                     /                       &amp;lt;tag/&amp;gt;|&#xA;----------------------------------------------------------------------------&#xA;&amp;lt;tag&amp;gt;|&amp;lt;/tag&amp;gt;                &amp;lt;Enter&amp;gt;                 &amp;lt;tag&amp;gt;&#xA;                                                        |&#xA;                                                    &amp;lt;/tag&amp;gt;&#xA;----------------------------------------------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Together with the mapping already used by OP using &lt;code&gt;inoremap&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;❯ cat ~/.vim/vimrc&#xA;source $VIMRUNTIME/defaults.vim&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;C-c&amp;gt; &amp;lt;/&amp;lt;C-X&amp;gt;&amp;lt;C-O&amp;gt;&amp;lt;C-X&amp;gt;&amp;lt;Esc&amp;gt;F&amp;lt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would type &lt;code&gt;&amp;lt;body&amp;gt;&amp;lt;C-c&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-12-03T10:23:55.217" LastActivityDate="2018-12-03T10:23:55.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18129" PostTypeId="2" ParentId="18114" CreationDate="2018-12-01T14:23:07.223" Score="1" Body="&lt;h2&gt;Plugin &lt;em&gt;emmet-vim&lt;/em&gt; by Yasuhiro Matsumoto (&lt;a href=&quot;https://github.com/mattn/emmet-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;, &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2981&quot; rel=&quot;nofollow noreferrer&quot;&gt;#2981&lt;/a&gt;)&lt;/h2&gt;&#xA;&lt;p&gt;This plugin is quite powerful. Unfortunately, there is only a global switch to insert newlines for all childless tags:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:user_emmet_settings = {&#xA;\ 'html' : {&#xA;\     'block_all_childless' : 1,&#xA;\   }&#xA;\ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then you can type&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;body&amp;lt;C-y&amp;gt;,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to get the desired result.&lt;/p&gt;&#xA;&lt;p&gt;Related issues on github are &lt;a href=&quot;https://github.com/mattn/emmet-vim/issues/378&quot; rel=&quot;nofollow noreferrer&quot;&gt;#378&lt;/a&gt; and &lt;a href=&quot;https://github.com/mattn/emmet-vim/issues/270&quot; rel=&quot;nofollow noreferrer&quot;&gt;#270&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can merge multi-line tags into a single line with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-y&amp;gt;m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2020-12-13T14:00:36.697" LastActivityDate="2020-12-13T14:00:36.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18130" PostTypeId="1" CreationDate="2018-12-01T19:49:47.973" Score="1" ViewCount="118" Body="&lt;p&gt;I need to repeat the following workflow multiple times:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have a repository with two branches&lt;/li&gt;&#xA;&lt;li&gt;I need to work simultaneously with two revisions of the same file, each revision belonging to one of the branches:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I need to be able to see the differences by using diff mode&lt;/li&gt;&#xA;&lt;li&gt;I need to be able to make changes in each version&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'd like to know what approach should I use and what eventually useful vim plugins could help me. I did not mention the version control on purpose because I'd like some version control agnostic suggestions: I need to do this in repositories handled by misc vcs tools - at least git, fossil and darcs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: adding what I have in mind now (and what I don't really like, hence looking for better suggestions)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could make two clones of the repository, check out needed revision from first branch in one, check out other needed revision from second branch in another repository. Then just use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff /full/path/to/file/in/first/repo /full/path/to/file/in/second/repo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But to me this looks like too much being done outside of vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I'd probably like a vim plugin that understands many different version control repository formats and can do this workflow for me behind the curtain, so I only pass revision1, revision2, filename to it (inside vim) and I can get a vimdiff window with two versions of the same file so I could work on them.&lt;/p&gt;&#xA;" OwnerUserId="19475" LastEditorUserId="19475" LastEditDate="2018-12-02T07:30:51.593" LastActivityDate="2018-12-02T07:30:51.593" Title="How to diff/edit two versions of the same file with vim?" Tags="|vimdiff|" AnswerCount="0" CommentCount="4" ClosedDate="2018-12-12T06:41:58.660" ContentLicense="CC BY-SA 4.0" />
  <row Id="18131" PostTypeId="2" ParentId="18124" CreationDate="2018-12-02T09:34:19.190" Score="4" Body="&lt;p&gt;There are no actual questions in your submission but one can be inferred: Why doesn't Tab do wildcard expansion with &lt;code&gt;-u NONE&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;-u NONE&lt;/code&gt; prevents any vimrc files from being loaded. That results in default values being used for settings and that includes the Vi compatibility setting &lt;code&gt;'compatible'&lt;/code&gt;. This will be enabled per &lt;code&gt;:h 'compatible'&lt;/code&gt;. Further, the wildcard expansion key is specified in &lt;code&gt;'wildchar'&lt;/code&gt;. The Vim default is, of course, &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; but, per &lt;code&gt;:h 'wc'&lt;/code&gt;, the Vi default (applicable because of &lt;code&gt;'compatible'&lt;/code&gt;) is &lt;code&gt;CTRL-E&lt;/code&gt;. Enter &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;E&lt;/kbd&gt; instead of &lt;kbd&gt;TAB&lt;/kbd&gt; and expansion should work in that scenario.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, wildcard expansion is really an interactive feature while  macros are non-interactive. Except for muscle-memory mistakes there shouldn't be any reason command-line Tabs get entered in your macros.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Addressing questions added after I wrote the preceding...between something that will help you avoid typing &lt;kbd&gt;TAB&lt;/kbd&gt; or something that will make expansion work the latter is the most realistic (though ill-advised, IMO, except for some specific use cases). In fact, @user938271 gave you &lt;a href=&quot;https://vi.stackexchange.com/questions/18124/q-does-not-record-tab-completion-correctly/18131#&quot;&gt;a hint about this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I talked about &lt;code&gt;'wildchar'&lt;/code&gt; above. Expansion can't reliably be done in deferred/non-interactive contexts (i.e. a macro/mapping) using this mechanism but there is a related setting &lt;code&gt;'wildcharm'&lt;/code&gt; that provides a means to do so as indicated in the associated help:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'wildcharm' works exactly like 'wildchar', except that it is&#xA;    recognized when used inside a macro &lt;sup&gt;1&lt;/sup&gt;. ... Normally  you'll never actually type 'wildcharm',&#xA;  just use it in mappings [and macros].&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;wildcharm&lt;/code&gt;/&lt;code&gt;wcm&lt;/code&gt; is not set by default so we need to do &lt;code&gt;:set wcm=XXX&lt;/code&gt; replacing &lt;code&gt;XXX&lt;/code&gt; with whatever unused key you prefer, e.g. &lt;code&gt;:set wcm=&amp;lt;Tab&amp;gt;&lt;/code&gt;. (Note: &lt;code&gt;'wcm'&lt;/code&gt; is supposed to be set to a number but the &lt;code&gt;&amp;lt;FOO&amp;gt;&lt;/code&gt; notation is a legal substitute.) Your issue with macros should be taken care of now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;sub&gt;Note that Vim documentation has a broader definition of &quot;macro&quot; than some are accustomed to. The term is popularly used most commonly to refer to commands recorded into a register and played back with &lt;code&gt;@&lt;/code&gt;. Vim help files, though, sometimes refer to the RHS of key mappings as macros, too.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-12-28T05:05:16.123" LastActivityDate="2018-12-28T05:05:16.123" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18132" PostTypeId="2" ParentId="18114" CreationDate="2018-12-02T11:19:08.657" Score="1" Body="&lt;h3&gt;Plugin &lt;em&gt;UltiSnips&lt;/em&gt; by Holger Rapp (&lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;, &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2715&quot; rel=&quot;nofollow noreferrer&quot;&gt;#2715&lt;/a&gt;) and &lt;a href=&quot;https://github.com/honza/vim-snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;Honza's Snippet Repository&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You find in honza's snippet repository &lt;a href=&quot;https://github.com/honza/vim-snippets/blob/master/UltiSnips/html.snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;most html&lt;/a&gt; tags as a trigger word. This means following works for those:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;body&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;expands to a predefined style (inline or multi-line):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;body&amp;gt;&#xA;    |&#xA;&amp;lt;/body&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you do not agree, you can easily customize the default style. If you need both styles you need two different trigger words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, two general purpose trigger words are defined &lt;code&gt;t&lt;/code&gt; and &lt;code&gt;ti&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Block style:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t&amp;lt;tab&amp;gt;body&amp;lt;tab&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Inline style:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ti&amp;lt;tab&amp;gt;body&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-12-02T11:25:41.633" LastActivityDate="2018-12-02T11:25:41.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18133" PostTypeId="1" CreationDate="2018-12-02T14:20:59.093" Score="1" ViewCount="2887" Body="&lt;p&gt;I am using vim-airline and buffer tabline. I want to make the tab name become &lt;code&gt;dirname/filename&lt;/code&gt;. How to achieve it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:ec fnamemodify('/usr/lib/abc/file.sh', '&amp;lt;something&amp;gt;')&lt;/code&gt; should return &lt;code&gt;abc/file.sh&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried many combinations &lt;code&gt;:p:.&lt;/code&gt;, &lt;code&gt;:t&lt;/code&gt;, &lt;code&gt;:r&lt;/code&gt;, &lt;code&gt;:h&lt;/code&gt; etc.. None of them works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot. &lt;/p&gt;&#xA;" OwnerUserId="20026" LastActivityDate="2018-12-03T09:49:44.573" Title="How to use fnamemodify to return dirname/filename?" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18134" PostTypeId="1" AcceptedAnswerId="18135" CreationDate="2018-12-02T15:16:02.150" Score="1" ViewCount="3845" Body="&lt;p&gt;How to execute Vim commands from shell? For ex I want to see man pages of grep command in vim typing command from shell(bash,zsh) command something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim ':Man grep'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible?&lt;/p&gt;&#xA;" OwnerUserId="16328" LastActivityDate="2018-12-02T15:36:02.323" Title="Execute Vim commands from shell" Tags="|bash|shell|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18135" PostTypeId="2" ParentId="18134" CreationDate="2018-12-02T15:36:02.323" Score="6" Body="&lt;p&gt;From vim manpage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  -c {command}&#xA;               {command} will be executed after the first file has been read.  {command} is  interpreted  as  an  Ex&#xA;               command.   If the {command} contains spaces it must be enclosed in double quotes (this depends on the&#xA;               shell that is used).  Example: Vim &quot;+set si&quot; main.c&#xA;               Note: You can use up to 10 &quot;+&quot; or &quot;-c&quot; commands.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From vim help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;To start using the &quot;:Man&quot; command before any manual page was loaded, source     &#xA;this script from your startup vimrc file:                                       &#xA;&#xA;    runtime ftplugin/man.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming you don't have man.vim sourced in vimrc, the following should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c 'runtime ftplugin/man.vim' -c 'Man grep'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you do have man.vim already sourcerd in vimrc, you can skip the explicit sourcing command argument to vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you'll probably want a shell script wrapper that will accept an argument so you'll be able to do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ m ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with content of m script being&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;&#xA;vim -c 'runtime ftplugin/man.vim' -c &quot;Man $1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice the usage of double quotes so &lt;strong&gt;$1&lt;/strong&gt; gets understood properly by bash as the passed argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course you can always hit K on current word in vim to open the manpage for that word, but since you're explicitly telling that you want to do it from shell, I assume you know about this.&lt;/p&gt;&#xA;" OwnerUserId="19475" LastActivityDate="2018-12-02T15:36:02.323" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18136" PostTypeId="1" AcceptedAnswerId="18138" CreationDate="2018-12-02T16:31:08.573" Score="1" ViewCount="84" Body="&lt;p&gt;How can I create mappings that work only if the cursor is enclosed by certain characters?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, I want to map &lt;code&gt;ja&lt;/code&gt; to &lt;code&gt;\alpha&lt;/code&gt; if the cursor is enclosed by &lt;code&gt;$$&lt;/code&gt; or by &lt;code&gt;\[\]&lt;/code&gt; so as to make&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This jar has an $ja$ engraved on it.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;be remapped to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This jar has an $\alpha$ engraved on it.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This \alphar has an $\alpha$ engraved on it.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So, how can I ask vim to check if the cursor is enclosed by &lt;code&gt;$$&lt;/code&gt;'s and &lt;code&gt;\[\]&lt;/code&gt;'s?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An immediate complication that I can think of is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The jar has an $ja$ engraved on it (note: $ja$ is a greek character).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, the check should work just like vim does for checking unclosed parentheses, where there may be several closed ones back too. (Or like LaTeX for checking mathmode). This would be done only on the current line, for scalability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a scheme of how I would do it for &lt;code&gt;$$&lt;/code&gt; (if only I knew how to actually check these using vim syntax):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Take position of cursor;&lt;/li&gt;&#xA;&lt;li&gt;Scan to the left for the number of &lt;code&gt;$&lt;/code&gt;'s;&lt;/li&gt;&#xA;&lt;li&gt;Do the same for the right;&lt;/li&gt;&#xA;&lt;li&gt;If these are even, work as if in normal text (e.g. &lt;code&gt;A jar&lt;/code&gt; becomes &lt;code&gt;A jar&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;If these are odd, do the mappings (e.g. &lt;code&gt;A jar&lt;/code&gt; becomes &lt;code&gt;A \alphar&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;\[\]&lt;/code&gt; I think it could be done in the same way as a check for balanced paratheses...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since, this question is asked having LaTeX in mind, is there a shortcut when using vim-latex, vim-tex, or other TeX plugins for vim?&lt;/p&gt;&#xA;" OwnerUserId="20038" LastEditorUserId="20038" LastEditDate="2018-12-02T23:27:31.010" LastActivityDate="2018-12-02T23:27:31.010" Title="Make conditional imap to text being enclosed in certain characters" Tags="|insert-mode|filetype-tex|key-bindings|plugin-vim-latex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18137" PostTypeId="1" AcceptedAnswerId="18175" CreationDate="2018-12-02T16:46:24.973" Score="0" ViewCount="273" Body="&lt;p&gt;How to determine if the cursor is placed on the last character of the word under the cursor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can get information about the word under cursor like determining if the length of the word under the cursor is 1 character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strlen(expand('&amp;lt;cword&amp;gt;'))==1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But as far as I see the expression &lt;code&gt;expand('&amp;lt;cword&amp;gt;')&lt;/code&gt; only returns the word itself with no information about the cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help pointing towards a potential solution is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="307" LastActivityDate="2018-12-05T22:14:51.170" Title="Determine if the cursor is on the first/last character of word" Tags="|cursor|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18138" PostTypeId="2" ParentId="18136" CreationDate="2018-12-02T18:14:40.050" Score="4" Body="&lt;p&gt;This is actually a complicated matter. &lt;code&gt;$...$&lt;/code&gt; is a difficult construct to parse, because it has no clear beginning or end. That is, in &lt;code&gt;math here? $ or math here? $ math here?&lt;/code&gt;, how do you know which region is really a math region? You need to search further back to know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there are some possibilities. In particular, I would take advantage of the fact that there is already a good syntax file for LaTeX that detects these inner match structures. Thus, you can check if you are inside a math environment by looking at the syntax groups. I've implemented this in &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt;. The solution is basically as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; ja MyFunc('ja', '\alpha')&#xA;&#xA;function! MyFunc(lhs, rhs) abort&#xA;  return s:is_math() ? a:rhs : a:lhs&#xA;endfunction&#xA;&#xA;function! s:is_math() abort&#xA;  return match(map(synstack(line('.'), max([col('.') - 1, 1])),&#xA;        \ 'synIDattr(v:val, ''name'')'), '^texMathZone[A-Z]S\?$') &amp;gt;= 0&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to use vimtex directly, than you can read &lt;code&gt;:help vimtex-imaps&lt;/code&gt;. There are already a bunch of such mappings defined by default. See &lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/autoload/vimtex.vim#L113&quot; rel=&quot;nofollow noreferrer&quot;&gt;VIMTEX/autoload/vimtex.vim&lt;/a&gt; for the complete list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also add your own, custom maps, see &lt;code&gt;:help vimtex#imaps#add_map&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-12-02T18:14:40.050" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18139" PostTypeId="2" ParentId="18137" CreationDate="2018-12-02T18:28:33.873" Score="2" Body="&lt;p&gt;I would get the characters on the current line from the cursor and on and check if they match the end-of-word atom, i.e. something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; q :call Test()&amp;lt;cr&amp;gt;&#xA;&#xA;function! Test() abort&#xA;  return strcharpart(getline('.'), virtcol('.')-1, 3) =~# '^\w\&amp;gt;'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here I've added a map for making it easy to test. You can adjust the function, resource the file and then use &lt;code&gt;q&lt;/code&gt; to test the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;virtcol&lt;/code&gt; and &lt;code&gt;strcharpart&lt;/code&gt; to support multibyte characters.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-12-02T18:28:33.873" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18141" PostTypeId="2" ParentId="18133" CreationDate="2018-12-03T02:49:55.127" Score="1" Body="&lt;p&gt;The following answer is from @osse at IRC. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let name = '/usr/lib/abc/file.sh'&#xA;fnamemodify(name, ':p:h:t') . '/' . fnamemodify(name, ':t')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See help docs that I found interesting:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help filename-modifiers&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help fnamemodify&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help getcwd&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help globpath&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help split&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help substitute&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help wildcards&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="20026" LastEditorUserId="20026" LastEditDate="2018-12-03T09:49:44.573" LastActivityDate="2018-12-03T09:49:44.573" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18144" PostTypeId="1" CreationDate="2018-12-03T09:34:29.647" Score="1" ViewCount="47" Body="&lt;p&gt;For a buffer containing text &quot;กขค&quot; with UTF-8 encoding:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:perldo s/ข/x/g&lt;/code&gt; =&gt; &quot;กxค&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but &lt;code&gt;:perldo s/[ข]/x/g&lt;/code&gt; =&gt; &quot;xx�xxxxx�&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to specify Perl's encoding?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Currently I have to use &lt;code&gt;%:!perl -C -Mutf8 -pe 's/[ข]/x/g'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="20044" LastEditorUserId="20044" LastEditDate="2018-12-03T09:40:03.713" LastActivityDate="2018-12-03T12:37:44.593" Title="How to specify Perl encoding in Vim?" Tags="|regular-expression|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18146" PostTypeId="1" AcceptedAnswerId="18148" CreationDate="2018-12-03T13:00:50.747" Score="0" ViewCount="241" Body="&lt;p&gt;I want some abbreviations for common things typed in e-mails want to start them with a semicolon.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;iabbrev ;ph 555123467&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But this gives me an error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E474: Invalid argument&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I can have semicolon later in the abbreviation, but not as the first character. Is there a way to escape the semicolon or otherwise allow it as the first character in my abbreviation?&lt;/p&gt;&#xA;" OwnerUserId="7222" LastActivityDate="2018-12-03T13:10:28.133" Title="iabbrev starting with semicolon" Tags="|abbreviations|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18148" PostTypeId="2" ParentId="18146" CreationDate="2018-12-03T13:10:28.133" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#abbreviations&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h abbreviations&lt;/code&gt;&lt;/a&gt; we can read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;There are three types of abbreviations:&#xA;&#xA;full-id     The &quot;full-id&quot; type consists entirely of keyword characters (letters&#xA;            and characters from 'iskeyword' option).  This is the most common&#xA;            abbreviation.&#xA;&#xA;            Examples: &quot;foo&quot;, &quot;g3&quot;, &quot;-1&quot;&#xA;&#xA;end-id      The &quot;end-id&quot; type ends in a keyword character, but all the other&#xA;            characters are not keyword characters.&#xA;&#xA;            Examples: &quot;#i&quot;, &quot;..f&quot;, &quot;$/7&quot;&#xA;&#xA;non-id      The &quot;non-id&quot; type ends in a non-keyword character, the other&#xA;            characters may be of any type, excluding space and tab.  {this type&#xA;            is not supported by Vi}&#xA;&#xA;            Examples: &quot;def#&quot;, &quot;4/7$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it seems that the only solution is to add &lt;code&gt;;&lt;/code&gt; to &lt;code&gt;iskeyword&lt;/code&gt; with &lt;code&gt;set iskeyword+=;&lt;/code&gt;, note that it might not be the best solution since it will change the behavior of a lot of other things (see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27iskeyword%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'iskeyword'&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So personally I would recommend not to use abbreviations beginning with &lt;code&gt;;&lt;/code&gt; or setting &lt;code&gt;;&lt;/code&gt; as a part of &lt;code&gt;iskeyword&lt;/code&gt; but only on filetype-specific configurations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution is to create a &quot;non-id&quot; abbrev and simply add another &lt;code&gt;;&lt;/code&gt; at the end of the left hand part like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev ;ph; 555123467&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-12-03T13:10:28.133" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18150" PostTypeId="1" CreationDate="2018-12-03T17:35:29.587" Score="1" ViewCount="52" Body="&lt;p&gt;When choosing a location suggested by &lt;code&gt;:cs find s&lt;/code&gt;, the home path is appended twice as seen in the picture so cscope can't recognize it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Type number and &amp;lt;Enter&amp;gt; (empty cancels): 4E429: File &quot;/home/dafna/media_tree//home/dafna/media_tree/blabla&quot; does not exist&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ttlLV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ttlLV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20051" LastEditorUserId="2920" LastEditDate="2018-12-03T18:13:22.067" LastActivityDate="2018-12-03T18:13:22.067" Title="cscope adds home directory twice to a file and can't find it" Tags="|cscope|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18151" PostTypeId="1" AcceptedAnswerId="18152" CreationDate="2018-12-03T19:59:32.113" Score="0" ViewCount="158" Body="&lt;p&gt;Is there a way to bind &lt;code&gt;I&lt;/code&gt; and &lt;code&gt;A&lt;/code&gt; in visual mode and visual line mode to switch the selected region to a visual block selection with the same boundaries?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to use visual line mode to select a group of lines and then use &lt;code&gt;I&lt;/code&gt; or &lt;code&gt;A&lt;/code&gt; to add text before or after all of the lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, in the following file (with line numbers)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1 a&#xA;  2 b&#xA;  3 c&#xA;  4 d&#xA;  5 e&#xA;  6 f&#xA;  7 g&#xA;  8 h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The sequence &lt;code&gt;&amp;lt;esc&amp;gt; gg V G I # &amp;lt;space&amp;gt; &amp;lt;esc&amp;gt;&lt;/code&gt; produces&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1 # a&#xA;  2 b&#xA;  3 c&#xA;  4 d&#xA;  5 e&#xA;  6 f&#xA;  7 g&#xA;  8 h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'd like it to produce this, just as visual block would.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1 # a&#xA;  2 # b&#xA;  3 # c&#xA;  4 # d&#xA;  5 # e&#xA;  6 # f&#xA;  7 # g&#xA;  8 # h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried using the following keybinding to switch to visual block mode right before inserting in every mode except visual block, but it loses the selection region.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;expr&amp;gt; I   mode()=~?'\cv' ? 'I' : '&amp;lt;c-v&amp;gt;I'&#xA;vnoremap &amp;lt;expr&amp;gt; A   mode()=~?'\cv' ? 'A' : '&amp;lt;c-v&amp;gt;A'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2018-12-03T20:12:46.740" LastActivityDate="2018-12-03T20:30:08.777" Title="Bind visual mode 'I' and 'A' to always use visual block mode before inserting" Tags="|visual-block|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18152" PostTypeId="2" ParentId="18151" CreationDate="2018-12-03T20:30:08.777" Score="2" Body="&lt;p&gt;Your attempt was close, but there are two problems I see:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I'm sure you already know this, since you mentioned it in your comment, but &lt;code&gt;mode()&lt;/code&gt; will return &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; in visual block mode, not &lt;code&gt;\cv&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Pressing &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; from visual line mode will always leave the cursor where it is. And &lt;code&gt;&amp;lt;C-v&amp;gt;I&lt;/code&gt; will not put the text at the beginning of the line, but right before the cursor. Similarly with &lt;code&gt;&amp;lt;C-v&amp;gt;A&lt;/code&gt;. So you'll want to use either &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;$&lt;/code&gt; to make sure your cursor is where you want it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This should do what you're looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;expr&amp;gt; I mode()=~? '&amp;lt;C-v&amp;gt;' ? 'I' : '&amp;lt;c-v&amp;gt;0I'&#xA;vnoremap &amp;lt;expr&amp;gt; A mode()=~? '&amp;lt;C-v&amp;gt;' ? 'A' : '&amp;lt;c-v&amp;gt;$A'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-12-03T20:30:08.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18154" PostTypeId="1" CreationDate="2018-12-04T03:16:37.310" Score="1" ViewCount="666" Body="&lt;p&gt;I want to write a plugin that will watch a buffer for changes and execute different functions depending on the change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can use &lt;code&gt;nvim_buf_attach()&lt;/code&gt; to subscribe to buffer events, but they are sent to &quot;the current channel&quot;. For a moment I thought perhaps calling &lt;code&gt;vim.api.nvim_buf_attach(current_buffer, true, {})&lt;/code&gt; might work in my plugin – maybe it would auto set some channel context but the call fails &lt;code&gt;attempt to call field 'nvim_buf_attach' (a nil value)&lt;/code&gt; – it seems that the event api isn't exposed to the built in lua client?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The docs describe how to &lt;a href=&quot;https://neovim.io/doc/user/channel.html#channel&quot; rel=&quot;nofollow noreferrer&quot;&gt;create a channel&lt;/a&gt; but none of them seem appropriate for a plugin, they're all for IPC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like the plugin functions to run async, so I'm not against spawning a &quot;event consumer&quot; process that runs alongside the static plugin bits. I'm just not sure how to do that with neovims compiled-in lua client, i.e. without making some OS installed lua package an external dependency of the plugin.&lt;/p&gt;&#xA;" OwnerUserId="20041" LastActivityDate="2018-12-04T03:16:37.310" Title="Subscribe to a buffer event in a lua plugin" Tags="|neovim|plugin-development|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18156" PostTypeId="1" CreationDate="2018-12-04T07:48:05.660" Score="2" ViewCount="330" Body="&lt;pre&gt;&lt;code&gt;%s///n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;show number of matching pattern like &lt;code&gt;102 matches on 102 lines.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to copy this output to a register?&lt;/p&gt;&#xA;" OwnerUserId="20057" LastEditorUserId="1841" LastEditDate="2018-12-04T13:39:35.150" LastActivityDate="2018-12-04T13:39:35.150" Title="How to yank count of matches of a pattern to a register?" Tags="|vimscript|search|counting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18157" PostTypeId="2" ParentId="18156" CreationDate="2018-12-04T08:15:24.210" Score="4" Body="&lt;pre&gt;&lt;code&gt;:redir @a | %s///n | redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An alternative is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=execute('%s///n')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;%s///n&lt;/code&gt; is the last command, you can type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=execute('&amp;lt;Ctrl-r&amp;gt;:')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or if you want to paste it immediately into the document, switch to insert mode and type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Ctrl-r&amp;gt;=execute('&amp;lt;Ctrl-r&amp;gt;:')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Relevant Links&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3Aredir&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :redir&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#execute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h execute()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Gist &lt;code&gt;:Redir&lt;/code&gt; &lt;a href=&quot;https://gist.github.com/intuited/362802&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gist.github.com/intuited/362802&lt;/a&gt; &lt;code&gt;:R %s///n @a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/mhinz/vim-galore#redir-and-execute&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/mhinz/vim-galore#redir-and-execute&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Capture_ex_command_output&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Capture_ex_command_output&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/8453211/how-do-i-capture-the-output-of-a-vim-command-in-a-register-without-the-newlines&quot;&gt;https://stackoverflow.com/questions/8453211/how-do-i-capture-the-output-of-a-vim-command-in-a-register-without-the-newlines&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2018-12-04T10:32:23.663" LastActivityDate="2018-12-04T10:32:23.663" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18158" PostTypeId="1" AcceptedAnswerId="18160" CreationDate="2018-12-04T16:21:42.953" Score="0" ViewCount="36" Body="&lt;p&gt;I have the file with below content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char  abc[35+1];&#xA;char  abc[35+1];&#xA;[123];&#xA;char a_wo_011[35+1];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to replace the &lt;code&gt;[35+1]&lt;/code&gt; with say &lt;code&gt;ABC&lt;/code&gt;&#xA;But its not working.&#xA;I am able to search the pattern with below command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/[35+1\]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I try to replace it , it is not working:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/[35+1\]/ABC/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I even tried tripple \\ from other post.&#xA;Can you please advise what am I doing wrong and how to fix it? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="16404" LastActivityDate="2018-12-04T16:29:13.827" Title="How to match and replace the pattern [35+1] in vim version 7.4.160?" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18160" PostTypeId="2" ParentId="18158" CreationDate="2018-12-04T16:29:13.827" Score="1" Body="&lt;p&gt;You need to escape &lt;code&gt;[&lt;/code&gt; instead of &lt;code&gt;]&lt;/code&gt; to indicate to Vim that you are not matching a collection of atoms but a litteral &lt;code&gt;[&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should do the job:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\[35+1]/ABC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2fcollection&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /collection&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-12-04T16:29:13.827" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18161" PostTypeId="2" ParentId="13566" CreationDate="2018-12-04T18:58:31.910" Score="61" Body="&lt;p&gt;You should add the following two lines at the end of /etc/vim/vimrc :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=&#xA;set ttymouse=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20068" LastActivityDate="2018-12-04T18:58:31.910" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18162" PostTypeId="1" AcceptedAnswerId="18173" CreationDate="2018-12-04T21:56:16.447" Score="4" ViewCount="509" Body="&lt;p&gt;I know that similar things were asked here several times. I know that to repeat a motion &lt;code&gt;;&lt;/code&gt; works. Unless it doesn't(in case there is count for example), but then &lt;code&gt;repmo.vim&lt;/code&gt; usually works. And I know that &lt;code&gt;.&lt;/code&gt; works for changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is that &lt;code&gt;repmo.vim&lt;/code&gt; is stupid, and thus provides no solution for complicated things such as &lt;code&gt;[m&lt;/code&gt;,&lt;code&gt;[c&lt;/code&gt;, &lt;code&gt;[M&lt;/code&gt;. When I tried to do so(add this motion to its list), it didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, any solution for this that I missed? &#xA;Doing &lt;code&gt;norm ']m'&lt;/code&gt; and then &lt;code&gt;@:&lt;/code&gt; is an option, but I don't really like it. The forward and rev capability of &lt;code&gt;repmo.vim&lt;/code&gt; is nice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2023-10-19T15:13:10.413" Title="Repeat complicated motions" Tags="|cursor-motions|repeated-commands|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18163" PostTypeId="2" ParentId="18096" CreationDate="2018-12-04T23:14:41.370" Score="1" Body="&lt;p&gt;I found a solution.&#xA;&lt;a href=&quot;https://github.com/neovim/neovim/blob/master/runtime/doc/ui.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neovim/neovim/blob/master/runtime/doc/ui.txt&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attaching the ui by |nvim_ui_attach()| method with option `ext_cmdline=true',&#xA;then the cmdline_xxxx methods are callback from neovim.&lt;/p&gt;&#xA;" OwnerUserId="19984" LastActivityDate="2018-12-04T23:14:41.370" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18164" PostTypeId="1" AcceptedAnswerId="18168" CreationDate="2018-12-05T04:15:10.107" Score="-1" ViewCount="365" Body="&lt;p&gt;How do I insert C/C++-type loops and statements templates automatically in Vim?&lt;/p&gt;&#xA;" OwnerUserId="5224" LastEditorUserId="5224" LastEditDate="2018-12-05T18:17:23.567" LastActivityDate="2018-12-05T18:48:21.607" Title="Insert C/C++ loops and statements templates automatically" Tags="|snippets|filetype-c|filetype-c++|" AnswerCount="1" CommentCount="4" ClosedDate="2018-12-07T03:12:08.893" ContentLicense="CC BY-SA 4.0" />
  <row Id="18165" PostTypeId="1" AcceptedAnswerId="18166" CreationDate="2018-12-05T05:11:34.370" Score="1" ViewCount="162" Body="&lt;p&gt;&lt;code&gt;[I&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Display[s] all lines that contain the keyword under the cursor.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When I do so, it shows the matching files and lines and says&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Press ENTER or type command to continue.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What command(s) can I type here, if any? Can I quickly jump to the file and line &lt;code&gt;[I&lt;/code&gt; outputs (without doing &lt;code&gt;:e filename&lt;/code&gt; etc.)?&lt;/p&gt;&#xA;" OwnerUserId="5224" LastActivityDate="2018-12-06T06:26:29.927" Title="How do I jump to a file:line displayed by [I?" Tags="|jumplist|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18166" PostTypeId="2" ParentId="18165" CreationDate="2018-12-05T05:28:27.020" Score="4" Body="&lt;p&gt;Looks like &lt;code&gt;:&amp;lt;line number&amp;gt;&lt;/code&gt; or &lt;code&gt;:e filename&lt;/code&gt; is the best you can do. (&lt;em&gt;Well, except for the convenience mapping that I found in Vim help. Jump to the &quot;update&quot; at the end of this post if you're not interested in the context.&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't believe there are any commands specific to &lt;code&gt;[I&lt;/code&gt;. That's the standard message for paged results so the available commands are mostly related to moving up and down in case the results take up more than the window can contain at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you have more than a page worth of results you'll see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- More --&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you then type &lt;code&gt;?&lt;/code&gt; (or any unrecognized command, I think) you'll see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPACE/d/j: screen/page/line down, b/u/k: up, q: quit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The &lt;code&gt;'more'&lt;/code&gt; option must be enabled to see this.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few more such as &lt;code&gt;:&lt;/code&gt; which will take you to command line &lt;em&gt;while the page of results is still displayed&lt;/em&gt;. And therein lies the best answer I have for your specific question. Hit &lt;code&gt;:&lt;/code&gt; and enter in the command with the line number or filename or whatever which is displayed next to the line of interest. Hey at least you won't forget it and have to bring the results back up. (Though if you did, note &lt;code&gt;g&amp;lt;&lt;/code&gt; described next.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/message.txt.html#pager&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h pager&lt;/code&gt;&lt;/a&gt; for a complete list of available commands. It's worth a read and includes explanation of the somewhat obscure &lt;code&gt;g&amp;lt;&lt;/code&gt; command...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...used to see the last page of previous command output.&#xA;  This is especially useful if you accidentally typed &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; at the &#xA;  hit-enter prompt.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I know I often accidentally exit out of the last page of output so &lt;code&gt;g&amp;lt;&lt;/code&gt; is a nice little command to get back there without having to think much about it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; &lt;a href=&quot;http://vimhelp.appspot.com/tagsrch.txt.html#include-search&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h include-search&lt;/code&gt;&lt;/a&gt; (scroll down a bit) has the following mapping using &lt;code&gt;[I&lt;/code&gt; that could make jumping to lines a little easier...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;F4&amp;gt; [I:let nr = input(&quot;Which one: &quot;)&amp;lt;Bar&amp;gt;exe &quot;normal &quot; . nr .&quot;[\t&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use &lt;kbd&gt;F4&lt;/kbd&gt; instead of &lt;code&gt;[I&lt;/code&gt; and on the last screen a prompt will say &quot;Which one:&quot;. Select the result number (not the line number) and hit Enter and you will be taken to that line. Not earth shattering stuff but nominally more convenient.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-12-06T06:26:29.927" LastActivityDate="2018-12-06T06:26:29.927" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18168" PostTypeId="2" ParentId="18164" CreationDate="2018-12-05T10:44:05.593" Score="1" Body="&lt;p&gt;There exist many ways to define snippets for control statements: via abbreviations or via snippets. I remember a &lt;a href=&quot;https://stackoverflow.com/a/30279618/15934&quot;&gt;Q/A about abbreviations versus snippet plugins&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TL;DR: We can achieve the same things with both. The main difference is that snippet plugins provide a much simpler way to define maintainable code snippets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, in my &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-cpp plugin&lt;/a&gt; you could find some truly complex abbreviation definitions of control-statement code snippets, and also code snippet definitions for my &lt;a href=&quot;https://github.com/LucHermitte/mu-template&quot; rel=&quot;nofollow noreferrer&quot;&gt;mu-template plugin&lt;/a&gt;, plus many truly advanced skeletons/snippets and wizards for C++. c.vim plugin provides other snippets and abbreviations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most snippet plugin users prefer &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2540&quot; rel=&quot;nofollow noreferrer&quot;&gt;snipmate&lt;/a&gt; &amp;amp; co over mu-template and lh-cpp.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-12-05T18:48:21.607" LastActivityDate="2018-12-05T18:48:21.607" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18169" PostTypeId="1" CreationDate="2018-12-05T13:55:03.463" Score="2" ViewCount="960" Body="&lt;p&gt;Is it possible to surround a selected part of a line with &lt;code&gt;/*&lt;/code&gt; and &lt;code&gt;*/&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;start COMMENT ME end&#xA;start /*COMMENT ME*/ end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19811" LastEditorUserId="1292" LastEditDate="2018-12-07T12:43:03.610" LastActivityDate="2018-12-07T12:43:03.610" Title="Surround part of line with comment /* .. */" Tags="|visual-mode|plugin-vim-surround|" AnswerCount="3" CommentCount="3" ClosedDate="2018-12-08T21:31:33.443" ContentLicense="CC BY-SA 4.0" />
  <row Id="18170" PostTypeId="2" ParentId="18169" CreationDate="2018-12-05T14:00:26.870" Score="0" Body="&lt;p&gt;The simple (redoable version, that messes &lt;code&gt;*&lt;/code&gt; register) is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap µ s/* &amp;lt;c-r&amp;gt;&quot; */&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: this is quite certainly a duplicate&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2018-12-05T14:00:26.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18171" PostTypeId="1" AcceptedAnswerId="18172" CreationDate="2018-12-05T15:03:30.723" Score="0" ViewCount="44" Body="&lt;p&gt;Evidently Ubuntu 18.10 is using a new version of vim ( 8.0.1766 ) which gives cool defaults I really like ( immediately jump to search matches while I type in more characters when doing a :/mysearchhere ) however once I create a new file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and give it&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ts=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that new vim behavior goes away - how to keep new defaults yet define the tab size ?   I use no custom vim settings at all on a fresh Ubuntu 18.10 install&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apt-cache policy vim&#xA;vim:&#xA;  Installed: 2:8.0.1766-1ubuntu1&#xA;  Candidate: 2:8.0.1766-1ubuntu1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after I delete ~/.vimrc  those new default behaviors return&lt;/p&gt;&#xA;" OwnerUserId="15795" LastActivityDate="2018-12-05T15:24:39.530" Title="defaults for version 8.0.1766 go away once I define ~/.vimrc" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ClosedDate="2018-12-05T17:41:03.917" ContentLicense="CC BY-SA 4.0" />
  <row Id="18172" PostTypeId="2" ParentId="18171" CreationDate="2018-12-05T15:24:39.530" Score="1" Body="&lt;p&gt;Seems like Vim now has some &lt;code&gt;defaults.vim&lt;/code&gt; located at &lt;code&gt;$VIMRUNTIME&lt;/code&gt;. It is loaded only if user doesn't have &lt;code&gt;~/.vimrc&lt;/code&gt; file. If you wan't to keep those defaults you can probably add something like this to the beggining of your &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if filereadable(&quot;$VIMRUNTIME/defaults.vim&quot;)&#xA;    source $VIMRUNTIME/defaults.vim&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2018-12-05T15:24:39.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18173" PostTypeId="2" ParentId="18162" CreationDate="2018-12-05T15:45:05.927" Score="4" Body="&lt;h2&gt;Plugin &lt;a href=&quot;https://github.com/Houl/repmo-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;repmo-vim&lt;/em&gt;&lt;/a&gt; by Andy Wakula&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The plugin &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2174&quot; rel=&quot;nofollow noreferrer&quot;&gt;#2174&lt;/a&gt; listed on &lt;a href=&quot;https://www.vim.org/scripts&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.vim.org/scripts&lt;/a&gt; is, according to the description, outdated:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2016 Nov 22 started a new script at &lt;a href=&quot;https://github.com/Houl/vim-repmo&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Houl/vim-repmo&lt;/a&gt; &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The new plugin on github works for me when repeating, e.g. &lt;code&gt;]m&lt;/code&gt;/&lt;code&gt;[m&lt;/code&gt; and &lt;code&gt;]M&lt;/code&gt;/&lt;code&gt;[M&lt;/code&gt; with &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt;. My minimal configuration looks like using vim8 packages (vim 8.1.560 on macOS 10.12):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim&#xA;❯ tree&#xA;.&#xA;├── pack&#xA;│   └── repeat-complicated-motions&#xA;│       └── start&#xA;│           └── repmo-vim&#xA;│               ├── README.markdown&#xA;│               └── autoload&#xA;│                   └── repmo.vim&#xA;└── vimrc&#xA;&#xA;5 directories, 3 files&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/vimrc&#xA;source $VIMRUNTIME/defaults.vim&#xA;&#xA;map &amp;lt;expr&amp;gt; ; repmo#LastKey(';')|sunmap ;&#xA;map &amp;lt;expr&amp;gt; , repmo#LastRevKey(',')|sunmap ,&#xA;&#xA;&quot; Still repeat fFtT (now with counts):&#xA;noremap &amp;lt;expr&amp;gt; f repmo#ZapKey('f')|sunmap f&#xA;noremap &amp;lt;expr&amp;gt; F repmo#ZapKey('F')|sunmap F&#xA;noremap &amp;lt;expr&amp;gt; t repmo#ZapKey('t')|sunmap t&#xA;noremap &amp;lt;expr&amp;gt; T repmo#ZapKey('T')|sunmap T&#xA;&#xA;&quot; Now following can also be repeated with `;` and `,`:&#xA;for keys in [ ['[[', ']]'], ['[]', ']['], ['[m', ']m'], ['[M', ']M'], ['[c', ']c'] ]&#xA;    execute 'noremap &amp;lt;expr&amp;gt; '.keys[0].&quot; repmo#SelfKey('&quot;.keys[0].&quot;', '&quot;.keys[1].&quot;')|sunmap &quot;.keys[0]&#xA;    execute 'noremap &amp;lt;expr&amp;gt; '.keys[1].&quot; repmo#SelfKey('&quot;.keys[1].&quot;', '&quot;.keys[0].&quot;')|sunmap &quot;.keys[1]&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example java file:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public class Factorial&#xA;{&#xA;    public static void main(String[] args)&#xA;    {   final int NUM_FACTS = 100;                                 // ; after [m&#xA;        for(int i = 0; i &amp;lt; NUM_FACTS; i++)&#xA;            System.out.println( i + &quot;! is &quot; + factorial(i));&#xA;    }                                                              // , after ]M&#xA;&#xA;    public static int factorial(int n)&#xA;    {   int result = 1;                                            // [m&#xA;        for(int i = 2; i &amp;lt;= n; i++)&#xA;            result *= i;                                           // CURSOR&#xA;        return result;&#xA;    }                                                              // ]M&#xA;}&#xA;// vim: ft=java&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also when I open a diff (e.g. with &lt;code&gt;:Gdiff&lt;/code&gt; from vim-fugitive), repeating &lt;code&gt;]c&lt;/code&gt; and &lt;code&gt;[c&lt;/code&gt; are possible.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mappings of ftplugins&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Another possible issue with &lt;code&gt;[m&lt;/code&gt;, &lt;code&gt;[M&lt;/code&gt; is that you have to remap them for filetypes with overwrites and you want to use the overwrites. Examples are python, vimscript, and ruby.&#xA;Unfortunately, many ftplugins do not provide them as &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mappings &lt;a href=&quot;https://github.com/Houl/repmo-vim#foreign-scripts-support&quot; rel=&quot;nofollow noreferrer&quot;&gt;which repmo-vim needs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ftplugin &lt;a href=&quot;https://github.com/jeetsukumaran/vim-pythonsense&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-pythonsense&lt;/a&gt; provides them as &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/after/ftplugin/python.vim&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; ]] repmo#Key('&amp;lt;plug&amp;gt;(PythonsenseStartOfNextPythonClass)', '&amp;lt;plug&amp;gt;(PythonsenseStartOfPythonClass)')|sunmap &amp;lt;buffer&amp;gt; ]]&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; [[ repmo#Key('&amp;lt;plug&amp;gt;(PythonsenseStartOfPythonClass)', '&amp;lt;plug&amp;gt;(PythonsenseStartOfNextPythonClass)')|sunmap &amp;lt;buffer&amp;gt; [[&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; ][ repmo#Key('&amp;lt;plug&amp;gt;(PythonsenseEndOfPythonClass)', '&amp;lt;plug&amp;gt;(PythonsenseEndOfPreviousPythonClass)')|sunmap &amp;lt;buffer&amp;gt; ][&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; [] repmo#Key('&amp;lt;plug&amp;gt;(PythonsenseEndOfPreviousPythonClass)', '&amp;lt;plug&amp;gt;(PythonsenseEndOfPythonClass)')|sunmap &amp;lt;buffer&amp;gt; []&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; ]m repmo#Key('&amp;lt;plug&amp;gt;(PythonsenseStartOfNextPythonFunction)', '&amp;lt;plug&amp;gt;(PythonsenseStartOfPythonFunction)')|sunmap &amp;lt;buffer&amp;gt; ]m&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; [m repmo#Key('&amp;lt;plug&amp;gt;(PythonsenseStartOfPythonFunction)', '&amp;lt;plug&amp;gt;(PythonsenseStartOfNextPythonFunction)')|sunmap &amp;lt;buffer&amp;gt; [m&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; ]M repmo#Key('&amp;lt;plug&amp;gt;(PythonsenseEndOfPythonFunction)', '&amp;lt;plug&amp;gt;(PythonsenseEndOfPreviousPythonFunction)')|sunmap &amp;lt;buffer&amp;gt; ]M&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; [M repmo#Key('&amp;lt;plug&amp;gt;(PythonsenseEndOfPreviousPythonFunction)', '&amp;lt;plug&amp;gt;(PythonsenseEndOfPythonFunction)')|sunmap &amp;lt;buffer&amp;gt; [M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also the ftplugin &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt; provides them as &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mappings and the configuration becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/after/ftplugin/tex.vim&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; ]] repmo#Key('&amp;lt;plug&amp;gt;(vimtex-]])', '&amp;lt;plug&amp;gt;(vimtex-[[)')|sunmap &amp;lt;buffer&amp;gt; ]]&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; [[ repmo#Key('&amp;lt;plug&amp;gt;(vimtex-[[)', '&amp;lt;plug&amp;gt;(vimtex-]])')|sunmap &amp;lt;buffer&amp;gt; [[&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; ][ repmo#Key('&amp;lt;plug&amp;gt;(vimtex-][)', '&amp;lt;plug&amp;gt;(vimtex-[])')|sunmap &amp;lt;buffer&amp;gt; ][&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; [] repmo#Key('&amp;lt;plug&amp;gt;(vimtex-[])', '&amp;lt;plug&amp;gt;(vimtex-][)')|sunmap &amp;lt;buffer&amp;gt; []&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; ]m repmo#Key('&amp;lt;plug&amp;gt;(vimtex-]m)', '&amp;lt;plug&amp;gt;(vimtex-[m)')|sunmap &amp;lt;buffer&amp;gt; ]m&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; [m repmo#Key('&amp;lt;plug&amp;gt;(vimtex-[m)', '&amp;lt;plug&amp;gt;(vimtex-]m)')|sunmap &amp;lt;buffer&amp;gt; [m&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; ]M repmo#Key('&amp;lt;plug&amp;gt;(vimtex-]M)', '&amp;lt;plug&amp;gt;(vimtex-[M)')|sunmap &amp;lt;buffer&amp;gt; ]M&#xA;map &amp;lt;expr&amp;gt;&amp;lt;buffer&amp;gt; [M repmo#Key('&amp;lt;plug&amp;gt;(vimtex-[M)', '&amp;lt;plug&amp;gt;(vimtex-]M)')|sunmap &amp;lt;buffer&amp;gt; [M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to use the ones in &lt;code&gt;$VIMRUNTIME/ftplugin/{&lt;/code&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/ftplugin/python.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;python&lt;/code&gt;&lt;/a&gt;&lt;code&gt;,&lt;/code&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/ftplugin/ruby.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;ruby&lt;/code&gt;&lt;/a&gt;&lt;code&gt;,&lt;/code&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/ftplugin/vim.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim&lt;/code&gt;&lt;/a&gt;&lt;code&gt;}.vim&lt;/code&gt; you have to rewrite them as &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mappings and put them into &lt;code&gt;repmo#Key&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What file types are you interested in?&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-01-12T06:47:30.160" LastActivityDate="2019-01-12T06:47:30.160" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18174" PostTypeId="1" AcceptedAnswerId="18176" CreationDate="2018-12-05T21:32:31.680" Score="1" ViewCount="160" Body="&lt;p&gt;I am making a table which has chemical formulas in the first column so I need the integers as subscripts to use it in a LaTex file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to transform &lt;code&gt;CH4 &amp;amp;&lt;/code&gt; to &lt;code&gt;CH$_4$ &amp;amp;&lt;/code&gt;, &lt;code&gt;C2H5 &amp;amp;&lt;/code&gt; to &lt;code&gt;C$_2$H$_5$ &amp;amp;&lt;/code&gt; and so on. How do I select all integers before the occurrence of &lt;code&gt;&amp;amp;&lt;/code&gt; in a line and add the suffix and a prefix to it?&lt;/p&gt;&#xA;" OwnerUserId="14185" LastEditorUserId="14185" LastEditDate="2018-12-05T23:40:44.767" LastActivityDate="2018-12-06T08:00:17.037" Title="Replace all integers until a certain character" Tags="|substitute|replace|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18175" PostTypeId="2" ParentId="18137" CreationDate="2018-12-05T22:14:51.170" Score="1" Body="&lt;p&gt;I'd take a more experimental approach that @Karl Yngve Lervåg does in &lt;a href=&quot;https://vi.stackexchange.com/a/18139/343&quot;&gt;his answer&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works by moving the cursor back a word and then forwards again and then seeing if the cursor is in the same place. If it is, then the cursor was on the end of a &lt;code&gt;&amp;lt;word&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this technique saves you having to reverse-engineer and reimplement Vim's &lt;code&gt;&amp;lt;word&amp;gt;&lt;/code&gt; algorithm in VimScript.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EndWord() abort&#xA;  let pos = getpos('.')&#xA;  normal! gee&#xA;  if pos == getpos('.')&#xA;    return v:true&#xA;  else&#xA;    call setpos('.', pos)&#xA;    return v:false&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-12-05T22:14:51.170" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18176" PostTypeId="2" ParentId="18174" CreationDate="2018-12-05T22:28:56.140" Score="3" Body="&lt;p&gt;Presuming you are only interested in replacing the numbers before the &lt;em&gt;first&lt;/em&gt; ampersand on each line, one fairly crude way to do it is to first split the lines on the first ampersand, then perform the substitutions, and then rejoin the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\&amp;amp;/norm! f&amp;amp;i^M&#xA;:g/^[^&amp;amp;]/s/\d\+/$_\0$/g&#xA;:g/^&amp;amp;/norm! kJ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the first line, the &lt;code&gt;^M&lt;/code&gt; is a literal carriage return which you can enter by pressing: &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;. A more copy-and-pastable version of that line is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;g/\&amp;amp;/norm! f&amp;amp;i\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If, on the other hand, you want to replace any integers that come before &lt;em&gt;any&lt;/em&gt; ampersand, or if each line is guaranteed only to have one ampersand, then a one-liner is possible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\d\+\ze.*&amp;amp;/$_\0$/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-12-06T00:40:50.737" LastActivityDate="2018-12-06T00:40:50.737" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18177" PostTypeId="1" AcceptedAnswerId="18178" CreationDate="2018-12-06T04:09:22.003" Score="2" ViewCount="480" Body="&lt;p&gt;Something that's bothered me for about a decade now is that when I switch from command line into the command-line-history window (by pressing &lt;code&gt;&amp;lt;c-f&amp;gt;&lt;/code&gt;) and then switch back (by pressing &lt;code&gt;&amp;lt;c-c&amp;gt;&lt;/code&gt;), the command line history window remains visible.  I noticed that if I force a refresh by changing the size of the gVim window then the history window goes away so I think it just needs a redraw.  Is there a way to force a redraw to occur when hitting &lt;code&gt;&amp;lt;c-c&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="132" LastActivityDate="2018-12-06T06:00:34.687" Title="How to force redraw when returning to command line from command line history window?" Tags="|command-line|redraw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18178" PostTypeId="2" ParentId="18177" CreationDate="2018-12-06T04:23:51.063" Score="1" Body="&lt;p&gt;Try this autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup my_cmdline_window&#xA;    au!&#xA;    au CmdWinEnter * nno  &amp;lt;buffer&amp;gt;&amp;lt;expr&amp;gt;&amp;lt;nowait&amp;gt;  &amp;lt;c-c&amp;gt;  '&amp;lt;c-c&amp;gt;'.timer_start(0, {-&amp;gt; execute('redraw')})[-1]&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The timer is necessary to delay &lt;code&gt;:redraw&lt;/code&gt;. Without it, &lt;code&gt;:redraw&lt;/code&gt; would be executed before &lt;code&gt;C-c&lt;/code&gt; is pressed, that is before the command line window is left, which is too soon. Vim needs to redraw the screen after the command line window has been left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h CmdWinEnter&#xA;:h map-&amp;lt;buffer&amp;gt;&#xA;:h map-&amp;lt;expr&amp;gt;&#xA;:h map-&amp;lt;nowait&amp;gt;&#xA;:h timer_start()&#xA;:h lambda&#xA;:h execute()&#xA;:h :redraw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-12-06T06:00:34.687" LastActivityDate="2018-12-06T06:00:34.687" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18179" PostTypeId="2" ParentId="18174" CreationDate="2018-12-06T08:00:17.037" Score="2" Body="&lt;p&gt;For this particular problem, the better solution is to instead use the LaTeX package &lt;a href=&quot;https://ctan.org/pkg/mhchem&quot; rel=&quot;nofollow noreferrer&quot;&gt;mhchem&lt;/a&gt; for typesetting the formulas. A good solution is similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\documentclass{article}&#xA;\usepackage{mhchem}&#xA;\usepackage{array}&#xA;&#xA;% This is only used for pretty rules (\toprule, etc)&#xA;\usepackage{booktabs}&#xA;&#xA;\def\zzz#1\relax{\ce{#1}}&#xA;\newcolumntype{F}{&amp;gt;{\zzz}l&amp;lt;{\relax}@{}}&#xA;&#xA;\begin{document}&#xA;&#xA;\begin{tabular}{Fl}&#xA;  \toprule&#xA;  Formula &amp;amp; More \\&#xA;  \midrule&#xA;  CH4 &amp;amp; 1 \\&#xA;  C2H5 &amp;amp; 2 \\&#xA;  \bottomrule&#xA;\end{tabular}&#xA;&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more info, see &lt;a href=&quot;https://tex.stackexchange.com/questions/332042/using-mhchem-with-array&quot;&gt;this tex.stackexchange.com question&lt;/a&gt; and the &lt;a href=&quot;http://ctan.uib.no/macros/latex/contrib/mhchem/mhchem.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;mhchem documentation&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-12-06T08:00:17.037" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18180" PostTypeId="2" ParentId="18169" CreationDate="2018-12-06T10:56:33.847" Score="1" Body="&lt;p&gt;There is a plugin name NerdCommenter provide many ways of commenting, includes &lt;code&gt;/*  */&lt;/code&gt;: &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/scrooloose/nerdcommenter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just need a quick solution, here is the macro which does the trick:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&#xA;&lt;code&gt;&#xA;let @j=&quot;viws/*&amp;lt;esc&amp;gt;pa */&amp;lt;esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let save it to your &lt;code&gt;.vimrc&lt;/code&gt; file then using by moving the cursor at the word then &lt;code&gt;@j&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="20074" LastEditorUserId="20074" LastEditDate="2018-12-07T08:16:04.253" LastActivityDate="2018-12-07T08:16:04.253" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18181" PostTypeId="2" ParentId="18105" CreationDate="2018-12-06T11:07:59.183" Score="0" Body="&lt;p&gt;For the convenient, I usually save the file whenever I press the ESC so that I mapped ESC like this: &lt;code&gt;map &amp;lt;esc&amp;gt; :w\|:noh&amp;lt;cr&amp;gt;&lt;/code&gt;&#xA;The ESC functionality still working normally.&lt;/p&gt;&#xA;" OwnerUserId="20074" LastActivityDate="2018-12-06T11:07:59.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18183" PostTypeId="1" AcceptedAnswerId="18184" CreationDate="2018-12-06T11:27:43.243" Score="9" ViewCount="8388" Body="&lt;p&gt;Below example, first line is shorter than the other lines.&lt;br&gt;&#xA;I want to insert \ to all lines at the highlighted place.&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/0Pede.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0Pede.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;C&lt;/kbd&gt;, &lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;(select all lines) , &lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;, &lt;kbd&gt;\&lt;/kbd&gt;, only first line changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7DnT0.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7DnT0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to get below result?&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/eBJL6.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eBJL6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice: Don't want to use :s substitute command.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2020-02-01T18:43:22.557" Title="Visual Block Mode: How to insert text to multiple lines after line ending?" Tags="|visual-block|multiple-lines|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18184" PostTypeId="2" ParentId="18183" CreationDate="2018-12-06T11:50:41.110" Score="10" Body="&lt;p&gt;It could be done with &lt;code&gt;virtualedit=ALL&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;set virtualedit=all&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;select visually vertical part of the text&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A\&amp;lt;ESC&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;return &lt;code&gt;set virtualedit=block&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;See the screen:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2h7fv.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2h7fv.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2018-12-06T11:50:41.110" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18185" PostTypeId="1" AcceptedAnswerId="18192" CreationDate="2018-12-06T14:55:02.053" Score="7" ViewCount="2209" Body="&lt;p&gt;How can I open the result of &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;]&lt;/kbd&gt; in a new split?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;similar: &lt;a href=&quot;https://vi.stackexchange.com/q/16385/5224&quot;&gt;How do I open a tag with ctrl+] but open it in an existing split?&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="5224" LastActivityDate="2018-12-07T03:54:18.317" Title="Open ctrl+] in a new split?" Tags="|split|jump|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18186" PostTypeId="1" AcceptedAnswerId="18187" CreationDate="2018-12-06T15:25:51.460" Score="0" ViewCount="279" Body="&lt;p&gt;I am editing a HTML document (filetype=html) in vim. &lt;code&gt;foldmarker&lt;/code&gt; is set to &lt;code&gt;{,}&lt;/code&gt;, &lt;code&gt;foldmethod&lt;/code&gt; to &lt;code&gt;marker&lt;/code&gt; and &lt;code&gt;commentstring&lt;/code&gt; to &lt;code&gt;&amp;lt;!--%s--&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I visually select a region and use &lt;code&gt;zf&lt;/code&gt; to create a folding, vim inserts a &lt;code&gt;{&lt;/code&gt; at the beginning and a &lt;code&gt;}&lt;/code&gt; at the end of the region.&#xA;However, with my settings, I expected vim to insert &lt;code&gt;&amp;lt;!--{--&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;!--}--&amp;gt;&lt;/code&gt;, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is vim ignoring &lt;code&gt;commentstring&lt;/code&gt; when folding?&lt;/p&gt;&#xA;" OwnerUserId="985" LastEditorUserId="205" LastEditDate="2019-11-06T06:46:39.990" LastActivityDate="2019-11-06T06:46:39.990" Title="Why does vim ignore commentstring when folding (foldmethod=marker)" Tags="|folding|comments|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="18187" PostTypeId="2" ParentId="18186" CreationDate="2018-12-06T16:51:58.960" Score="1" Body="&lt;p&gt;This answer probably should be deleted. Answering here to show it @ChristianBrabandt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is kind of strange but for some text it works, for the other it doesn't:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CpEUW.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CpEUW.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if you change the first paragraph to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;blablabla a&#xA;lkjsdlfkj&#xA;lksjdflksdj&#xA;lksjdflksja&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it will not work for the first row. Looks like if there are more than 1 word on the line it doesn't insert commentstring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec  5 2018 23:02:23)&#xA;MS-Windows 64-bit GUI version with OLE support&#xA;Included patches: 1-565&#xA;Compiled by appveyor@APPVYR-WIN&#xA;Huge version with GUI.  Features included (+) or not (-):&#xA;+acl                +comments           +file_in_path       +listcmds           +persistent_undo    +tag_binary         +visualextra&#xA;+arabic             +conceal            +find_in_path       +localmap           -postscript         +tag_old_static     +viminfo&#xA;+autocmd            +cryptv             +float              +lua/dyn            +printer            -tag_any_white      +vreplace&#xA;+autochdir          +cscope             +folding            +menu               +profile            +tcl/dyn            -vtp&#xA;+autoservername     +cursorbind         -footer             +mksession          +python/dyn         -termguicolors      +wildignore&#xA;+balloon_eval       +cursorshape        +gettext/dyn        +modify_fname       +python3/dyn        +terminal           +wildmenu&#xA;-balloon_eval_term  +dialog_con_gui     -hangul_input       +mouse              +quickfix           -tgetent            +windows&#xA;+browse             +diff               +iconv/dyn          +mouseshape         +reltime            -termresponse       +writebackup&#xA;++builtin_terms     +digraphs           +insert_expand      +multi_byte_ime/dyn +rightleft          +textobjects        -xfontset&#xA;+byte_offset        +directx            +job                +multi_lang         +ruby/dyn           +timers             -xim&#xA;+channel            -dnd                +jumplist           +mzscheme/dyn       +scrollbind         +title              +xpm_w32&#xA;+cindent            -ebcdic             +keymap             +netbeans_intg      +signs              +toolbar            -xterm_save&#xA;+clientserver       +emacs_tags         +lambda             +num64              +smartindent        +user_commands      &#xA;+clipboard          +eval               +langmap            +ole                +startuptime        +vartabs            &#xA;+cmdline_compl      +ex_extra           +libcall            +packages           +statusline         +vertsplit          &#xA;+cmdline_hist       +extra_search       +linebreak          +path_extra         -sun_workshop       +virtualedit        &#xA;+cmdline_info       +farsi              +lispindent         +perl/dyn           +syntax             +visual             &#xA;   system vimrc file: &quot;$VIM\vimrc&quot;&#xA;     user vimrc file: &quot;$HOME\_vimrc&quot;&#xA; 2nd user vimrc file: &quot;$HOME\vimfiles\vimrc&quot;&#xA; 3rd user vimrc file: &quot;$VIM\_vimrc&quot;&#xA;      user exrc file: &quot;$HOME\_exrc&quot;&#xA;  2nd user exrc file: &quot;$VIM\_exrc&quot;&#xA;  system gvimrc file: &quot;$VIM\gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME\_gvimrc&quot;&#xA;2nd user gvimrc file: &quot;$HOME\vimfiles\gvimrc&quot;&#xA;3rd user gvimrc file: &quot;$VIM\_gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME\defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME\menu.vim&quot;&#xA;Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL -DFEAT_NETBEANS_INTG -DFEAT_JOB_CHANNEL   -DFEAT_XPM_W32   -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG  /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_MBYTE -DFEAT_GUI_W32 -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DFEAT_DIRECTX_COLOR_EMOJI -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\&quot;tcl86t.dll\&quot; -DDYNAMIC_TCL_VER=\&quot;8.6\&quot; -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\&quot;lua53.dll\&quot; -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\&quot;python27.dll\&quot; -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\&quot;python37.dll\&quot; -DFEAT_MZSCHEME -I &quot;C:\Program Files\Racket\include&quot; -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\&quot;libracket3m_a36fs8.dll\&quot; -DDYNAMIC_MZGC_DLL=\&quot;libracket3m_a36fs8.dll\&quot; -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\&quot;perl528.dll\&quot; -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=24 -DDYNAMIC_RUBY_DLL=\&quot;x64-msvcrt-ruby240.dll\&quot; -DFEAT_HUGE /Fd.\ObjGXOULYHTRZAMD64/ /Zi&#xA;Linking: link  /nologo /subsystem:windows,5.02 /opt:ref /LTCG:STATUS /HIGHENTROPYVA:NO oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib netapi32.lib uuid.lib /machine:AMD64 gdi32.lib version.lib   winspool.lib comctl32.lib advapi32.lib shell32.lib netapi32.lib  /machine:AMD64  libcmt.lib oleaut32.lib user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python37.lib   &quot;C:\Tcl\lib\tclstub86.lib&quot; WSock32.lib xpm\x64\lib-vc14\libXpm.lib /PDB:gvim.pdb -debug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2018-12-06T17:06:19.797" LastActivityDate="2018-12-06T17:06:19.797" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18188" PostTypeId="1" AcceptedAnswerId="18209" CreationDate="2018-12-06T17:29:41.360" Score="1" ViewCount="3178" Body="&lt;p&gt;I am trying to install gvim81.exe on multiple computers. The /s switch isn't working and /? doesn't give any results. Does anyone know how to silently install this version?&lt;/p&gt;&#xA;" OwnerUserId="20099" LastEditorUserId="1292" LastEditDate="2019-01-13T15:05:47.983" LastActivityDate="2021-10-22T01:12:04.017" Title="How to install Vim 8.1 Silently on Windows?" Tags="|microsoft-windows|installing|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18189" PostTypeId="2" ParentId="18183" CreationDate="2018-12-06T17:45:24.370" Score="6" Body="&lt;p&gt;The short answer is: In &lt;em&gt;Visual Block&lt;/em&gt; mode select lines to their ends (&lt;code&gt;$&lt;/code&gt;) and use &lt;code&gt;A&lt;/code&gt; to append some text at the end of &lt;strong&gt;each&lt;/strong&gt; line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The longer answer:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;gg&lt;/code&gt; to go the beginning of the first line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;CTRL-V&lt;/code&gt; (or the proper alternative &lt;code&gt;CTRL-Q&lt;/code&gt; in e.g. gVim) to start blockwise visual selection.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;jjj$&lt;/code&gt; select all four lines down (&lt;code&gt;jjj&lt;/code&gt;) &lt;em&gt;and&lt;/em&gt; to the right until their individual ends (&lt;code&gt;$&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A&lt;/code&gt; start appending some text ('&lt;code&gt;\&lt;/code&gt;' in your case).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ESC&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In fact this is not exactly your desired result, but functually equal and achievable with a minimum effort and time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;short line \&#xA;very long line \&#xA;very very long line \&#xA;short line \&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20098" LastActivityDate="2018-12-06T17:45:24.370" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18190" PostTypeId="2" ParentId="14800" CreationDate="2018-12-06T21:51:57.940" Score="3" Body="&lt;p&gt;I would imagine, as &lt;a href=&quot;https://vi.stackexchange.com/questions/14800/use-the-arglist-without-opening-the-files#comment25380_14800&quot;&gt;D. Ben Knoble&lt;/a&gt; suggests, that if you don't anticipate a lot of interaction with the files, a different tool would be the way to go. &lt;code&gt;find . -name \*.html -exec sed -i.bak 's/replace/withthis/g' {} +&lt;/code&gt; (or &lt;code&gt;perl -i.bak -pe&lt;/code&gt; if your pattern is more complex than sed can accommodate).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are determined to do this in vim, I would probably use something like xargs -n to restrict the number of files loaded at once, e.g. &lt;code&gt;find . -name \*.html | xargs -n4 vim +'argdo s/replace/withthis/g'&lt;/code&gt; will load only 4 at a time (it may warn you about STDIN not being a terminal but it still works for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Warning, this may become very messy if you decide to stop early: i.e. if you decide to stop at the second of 20 batches, you may have to :qall or ^C a whole 19 times. Telling xargs to stop in the middle does not appear to be a simple matter. (If somebody knows differently I'll update the answer.)&lt;/p&gt;&#xA;" OwnerUserId="9376" LastActivityDate="2018-12-06T21:51:57.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18191" PostTypeId="2" ParentId="18169" CreationDate="2018-12-06T23:26:16.380" Score="0" Body="&lt;p&gt;You can use either of the following sequences of keystrokes from visual mode to comment out the currently selected text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;c/**/&amp;lt;Esc&amp;gt;hP&#xA;&#xA;c/*&amp;lt;C-R&amp;gt;&quot;*/&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that the second of these is essentially the same as in &lt;a href=&quot;https://vi.stackexchange.com/a/18170/343&quot;&gt;Luc Hermitte's mapping&lt;/a&gt;. See &lt;code&gt;:help i_CTRL-R&lt;/code&gt; if you're not sure how it works.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-12-06T23:26:16.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18192" PostTypeId="2" ParentId="18185" CreationDate="2018-12-07T03:54:18.317" Score="7" Body="&lt;p&gt;This will do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-W ]                    *CTRL-W_]* *CTRL-W_CTRL-]*&#xA;CTRL-W CTRL-]   Split current window in two.  Use identifier under cursor as a&#xA;        tag and jump to it in the new upper window.&#xA;        In Visual mode uses the Visually selected text as a tag.&#xA;        Make new window N high.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;courtesy: &lt;a href=&quot;https://vi.stackexchange.com/questions/18185/open-ctrl-in-a-new-split/18192#comment31327_18185&quot;&gt;D. Ben Knoble&lt;/a&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="5224" LastActivityDate="2018-12-07T03:54:18.317" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18193" PostTypeId="1" AcceptedAnswerId="18194" CreationDate="2018-12-07T11:19:30.437" Score="2" ViewCount="54" Body="&lt;h1&gt;Length of tabs after initial char&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Start &lt;code&gt;gvim&lt;/code&gt; with the &lt;code&gt;--clean&lt;/code&gt; option, to get a clean slate, and then do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set noet ts=5 sts=3 sw=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then enter the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1234567890&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and on the next line, press tab twice. The cursor will end up between the 6 and the seven (I use two bars to make it more obvious):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;123456|7890&#xA;      |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and if you replace spaces with a dot (to see where they are), doing &lt;code&gt;:%s/ /./g&lt;/code&gt; you will get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;123456|7890&#xA;     .|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Meaning there will be a tab with the length of five spaces, before that last space, that is now a dot. This is how I expected things to function: you add &lt;code&gt;sts&lt;/code&gt; spaces until there is more than &lt;code&gt;ts&lt;/code&gt; spaces, at which point you replace &lt;code&gt;ts&lt;/code&gt; spaces with an actual tab (and keep any remaining spaces).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now suppose you add a character before the tab (let us say an &lt;code&gt;a&lt;/code&gt;). Pressing tab twice will still move the cursor in the same way, i.e., first after the 3, then after the 6. But if you now do the same substitution, you will get a tab that has length &lt;strong&gt;4&lt;/strong&gt;! (from indexes 2 to 5)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;123456|7890&#xA;a    .|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Repeating with the experiment with two starting characters will produce a tab with length 3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;123456|7890&#xA;ab   .|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this seems to only happen with the first substitution: for any subsequent ones, the tab will indeed have length 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is: &lt;strong&gt;why&lt;/strong&gt; does &lt;code&gt;vim&lt;/code&gt; behave in this manner? In could not find an explanation for this in the docs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;" OwnerUserId="20108" LastEditorUserId="1292" LastEditDate="2018-12-07T17:09:30.460" LastActivityDate="2018-12-07T17:09:30.460" Title="On the length of tabs after an initial character" Tags="|whitespace|tab-characters|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18194" PostTypeId="2" ParentId="18193" CreationDate="2018-12-07T11:33:00.263" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;tabstop&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;'tabstop'&lt;/a&gt; setting in Vim works a bit differently then what you expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In classical typewrites at tabstop is a location where the carriage movement is halted. See also the the &lt;a href=&quot;https://en.wikipedia.org/wiki/Tab_stop&quot; rel=&quot;nofollow noreferrer&quot;&gt;wikipedia&lt;/a&gt;. That means, that the actual character width of a tab can be different, since it depends on from where the tab has been pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So with a tabstop setting of 8, the default, the cursor will be moved to position 8. It does not matter, where exactly the cursor is before that column, meaning depending on the text in this line, the tab might be either 8 chars wide, or 7 or 6, ... or even 1. After column 8, the cursor will be moved to the next column that is a multiple of your tabstop setting (so 8 for the default).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-12-07T11:33:00.263" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18195" PostTypeId="1" CreationDate="2018-12-07T14:12:39.573" Score="1" ViewCount="1613" Body="&lt;p&gt;I have a &lt;code&gt;.gvimrc&lt;/code&gt; file created to configure &lt;code&gt;MacVim&lt;/code&gt;. I'm using &lt;code&gt;Plug&lt;/code&gt; for package management.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.gvimrc&lt;/code&gt; looks as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin()&#xA;&#xA;Plug 'tpope/vim-sensible' &quot; sensible defaults&#xA;Plug 'joshdick/onedark.vim'&#xA;Plug 'sheerun/vim-polyglot' &quot; syntax highlight&#xA;Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }&#xA;Plug 'Xuyuanp/nerdtree-git-plugin'&#xA;Plug 'airblade/vim-gitgutter'&#xA;Plug '/usr/local/opt/fzf'&#xA;Plug 'junegunn/fzf.vim' &quot; fuzzy search&#xA;Plug 'w0rp/ale' &quot; linting&#xA;Plug 'itmammoth/run-rspec.vim'&#xA;Plug 'tpope/vim-rails'&#xA;Plug 'itchyny/lightline.vim' &#xA;Plug 'terryma/vim-multiple-cursors' &quot; cmd + d&#xA;Plug 'tpope/vim-fugitive'&#xA;Plug 'slim-template/vim-slim'&#xA;Plug 'scrooloose/nerdcommenter'&#xA;Plug 'sgur/vim-editorconfig'&#xA;Plug 'tpope/vim-endwise'&#xA;Plug 'ervandew/supertab'&#xA;&#xA;call plug#end()&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot; Settings&#xA;&quot;&#xA;&#xA;syntax on&#xA;colorscheme onedark&#xA;&#xA;&quot; Font settings&#xA;set guifont=Monaco:h13&#xA;set linespace=2&#xA;&#xA;set number &quot; display line numbers&#xA;&#xA;set cursorcolumn &quot; display vertical cursor line&#xA;set cursorline &quot; display horizontal cursor line&#xA;&#xA;&quot; More natural split direction&#xA;set splitright&#xA;&#xA;&quot; Disable scrolls&#xA;set guioptions=&#xA;&#xA;&quot; Needed by nerdcommenter&#xA;filetype plugin on&#xA;&#xA;&quot; NERDTree options&#xA;let NERDTreeMinimalUI = 1&#xA;let NERDTreeDirArrows = 1&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot; Key bindings&#xA;&#xA;&quot; Spec runner&#xA;map &amp;lt;Leader&amp;gt;t :RunSpec&amp;lt;CR&amp;gt;&#xA;map &amp;lt;Leader&amp;gt;tl :RunSpecLine&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; NERDtree&#xA;map &amp;lt;Leader&amp;gt;nt :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;map &amp;lt;D-\&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Fuzzy search (FZF)&#xA;macmenu File.Print key=&amp;lt;nop&amp;gt;&#xA;map &amp;lt;Leader&amp;gt;p :FZF&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;A-p&amp;gt; :FZF&amp;lt;CR&amp;gt;&#xA;map &amp;lt;D-p&amp;gt; :FZF&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the thing is - i need to run &lt;code&gt;PlugInstall&lt;/code&gt; after each editor open as running &lt;code&gt;:FZF&lt;/code&gt; without it throws &lt;code&gt;Not an editor command: FZF&lt;/code&gt;. Running &lt;code&gt;PlugInstall&lt;/code&gt; fixes it till i close the editor. This issue applies &lt;strong&gt;only&lt;/strong&gt; to &lt;code&gt;fzf&lt;/code&gt;, no any other plugin behaves like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit:&lt;/strong&gt; it applies to run-rspec as well&lt;/p&gt;&#xA;" OwnerUserId="5165" LastActivityDate="2020-05-30T23:02:30.320" Title="Need to run PlugInstall on each open" Tags="|vimrc|gvim|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18196" PostTypeId="2" ParentId="18195" CreationDate="2018-12-07T14:24:18.597" Score="0" Body="&lt;p&gt;Not sure if this is a good idea -- I think it is better to find out root cause of the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway to run a command after vim has started you can use autocommands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * PlugInstall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know if &lt;code&gt;PlugInstall&lt;/code&gt; is a command or a function. If it is a function then you should use &lt;code&gt;call PlugInstall()&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also suggest to move all your settings to .vimrc instead of .gvimrc. At least everything that is non-gui related, like all plugs and sets.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2018-12-07T14:24:18.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18197" PostTypeId="1" CreationDate="2018-12-07T17:55:34.653" Score="4" ViewCount="629" Body="&lt;p&gt;I currently have this in my vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword+=-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I press &lt;code&gt;w&lt;/code&gt; or &lt;code&gt;b&lt;/code&gt; my cursor skips over hyphens. Am I misunderstanding iskeyword?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I get word and back commands to treat hyphens (and underscores) like spaces stopping at the word after the hyphen or underscore?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;code&gt;set iskeyword?&lt;/code&gt; returns &lt;code&gt;iskeyword=@,48-57,_,192-255,-,#&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1596" LastEditorUserId="1596" LastEditDate="2018-12-07T19:28:24.943" LastActivityDate="2018-12-07T19:28:24.943" Title="How to get w word and b back to treat hyphens and underscores like spaces?" Tags="|cursor-movement|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18198" PostTypeId="1" AcceptedAnswerId="18201" CreationDate="2018-12-07T18:23:24.037" Score="2" ViewCount="178" Body="&lt;p&gt;A lot of languages use curly braces &lt;code&gt;{}&lt;/code&gt; to enclose code blocks, so it's nice to have a mapping something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap  &amp;lt;buffer&amp;gt;  {&amp;lt;CR&amp;gt;    {&amp;lt;CR&amp;gt;}&amp;lt;Esc&amp;gt;O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have this mapping in my &lt;code&gt;c.vim&lt;/code&gt; &lt;code&gt;ftplugin&lt;/code&gt;, but also in: &lt;code&gt;r.vim&lt;/code&gt;, &lt;code&gt;scala.vim&lt;/code&gt;, and &lt;code&gt;json.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this forces me to duplicate it four times. If I come up with an improvement, or I want to rebind the keys, I have to do it in each place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sourcing a shared script in each &lt;code&gt;ftplugin&lt;/code&gt; seems like a good solution, but I'm not sure where the right place to put those shared scripts is. Putting them in &lt;code&gt;plugin/&lt;/code&gt; means they are loaded every time, which is not what I want. &lt;code&gt;autoload/&lt;/code&gt; seems to be designed for functions more than mappings, but perhaps there is a way to use it that way?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So, in short:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I define these mappings (but more generally, any part of an &lt;code&gt;ftplugin&lt;/code&gt;) once, and then use them in multiple &lt;code&gt;ftplugin&lt;/code&gt; files?&lt;/p&gt;&#xA;" OwnerUserId="1402" LastActivityDate="2018-12-08T01:37:21.360" Title="Share configuration across `ftplugin` files without duplicating code" Tags="|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18199" PostTypeId="2" ParentId="18197" CreationDate="2018-12-07T19:05:37.597" Score="5" Body="&lt;p&gt;It looks like your understanding is inverted. By adding &lt;code&gt;-&lt;/code&gt; to &lt;code&gt;iskeyword&lt;/code&gt;, you're telling Vim that it's just a regular &lt;code&gt;word&lt;/code&gt; character that should be skipped over by things like &lt;code&gt;w&lt;/code&gt; or &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you want to remove it&lt;sup&gt;1&lt;/sup&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword-=-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Based on your posted &lt;code&gt;iskeyword&lt;/code&gt;, that should do the trick, but it's possible that others (or future you) might have a range that includes &lt;code&gt;-&lt;/code&gt;. You can explicitly exclude a character (or range) by prepending it with &lt;code&gt;^&lt;/code&gt; when &lt;em&gt;adding&lt;/em&gt; it (and making sure it's to the right of the range that would otherwise include it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword+=^-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;1) The fact that the hyphen was not the last thing in your &lt;code&gt;set iskeyword?&lt;/code&gt; might be a hint that it was already in there, meaning your &lt;code&gt;set iskeyword+=-&lt;/code&gt; was a noop.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2018-12-07T19:05:37.597" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="18201" PostTypeId="2" ParentId="18198" CreationDate="2018-12-08T00:08:30.123" Score="3" Body="&lt;p&gt;I see several ways to proceed&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When I want to store code to load and execute on demand, I use the old &lt;code&gt;macros/&lt;/code&gt; directories.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime macros/some_script.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another approach is to put the mappings you which to define in a series of functions in an autoload plugin and to call the functions from the various ftplugins.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call ns1#ns2#my_init_function1(args)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A third approach, which is the one I've chosen in &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-brackets&lt;/a&gt; in to have very generic mappings I use quite everywhere in a &lt;code&gt;plugin/&lt;/code&gt;, and specialized &lt;code&gt;&amp;lt;buffer&amp;gt;-mappings&lt;/code&gt; in buffers where I desire a different behaviour (in ftplugins). Of course, this works only when the &lt;em&gt;specialized&lt;/em&gt; behaviour is not &lt;em&gt;do nothing which is not standard&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;PS: By experience, a mapping on &lt;code&gt;{&amp;lt;cr&amp;gt;&lt;/code&gt; is a bad idea as it'll introduce a delay every time you'll type &lt;code&gt;{&lt;/code&gt;. Having a contextual mapping on &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; that detects whether there is a &lt;code&gt;{&lt;/code&gt; before the cursor, or even if the cursor is between a pair of curly brackets, will give a much better user experience. See what I've done in lh-brackets.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if get(g:, 'cb_newline_within_empty_brackets', 1)&#xA;  &quot; The following function will fall back to an existing previous&#xA;  &quot; mapping definition, if any, or to default behaviour if the &#xA;  &quot; condition isn't met&#xA;  call lh#brackets#enrich_imap('&amp;lt;cr&amp;gt;',&#xA;        \ {'condition': 'getline(&quot;.&quot;)[col(&quot;.&quot;)-2:col(&quot;.&quot;)-1]==&quot;{}&quot;',&#xA;        \   'action': 'lh#brackets#_add_newline_between_brackets()'},&#xA;        \ 0&#xA;        \ )&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-12-08T01:37:21.360" LastActivityDate="2018-12-08T01:37:21.360" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18202" PostTypeId="1" AcceptedAnswerId="18380" CreationDate="2018-12-08T00:48:33.133" Score="4" ViewCount="390" Body="&lt;h3&gt;Context&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Some time ago, I added the following line to &lt;code&gt;~/.vim/after/ftplugin/sh.vim&lt;/code&gt; to make working with parameter expansions easier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal iskeyword+=$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is nice to be able to e.g. &lt;code&gt;ysiw&quot;&lt;/code&gt; via surroud.vim to surround a parameter expansion in quotes. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Problem&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;However, I've noticed that when doing keyword-local completion (&lt;code&gt;i_&amp;lt;C-n&amp;gt;&lt;/code&gt;), typing &lt;code&gt;$partial_var_name&lt;/code&gt; will not complete to &lt;code&gt;full_var_name&lt;/code&gt; unless &lt;code&gt;$full_var_name&lt;/code&gt; is also present in the file already. This I sort of expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to fix it.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Attempted Solution&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I tried the following (there is no &lt;code&gt;CompleteStart&lt;/code&gt; event, unfortunately):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &quot; Fix keywords&#xA; setlocal iskeyword+=$&#xA;&#xA;augroup sh_ftplugin&#xA;  au!&#xA;  au MenuPopup setlocal iskeyword-=$&#xA;  au CompleteDone setlocal iskeyword+=$&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It did not work.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;TL;DR&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;My question is thus, how can I make insert-mode completion work the way I would like?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My thoughts&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;by ignoring &lt;code&gt;iskeyword&lt;/code&gt; in completion,&lt;/li&gt;&#xA;&lt;li&gt;modifying it during completion&lt;/li&gt;&#xA;&lt;li&gt;defining a text object for parameter expansions—neat plugin idea, by the way&lt;/li&gt;&#xA;&lt;li&gt;changing how I use &lt;code&gt;iskeyword&lt;/code&gt; as a last resort (that is, removing &lt;code&gt;$&lt;/code&gt; permanently)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2018-12-27T17:51:56.130" LastActivityDate="2021-02-24T14:26:50.833" Title="Modify `iskeyword` for keyword-local completion only" Tags="|key-bindings|cursor-motions|map-operator|filetype-sh|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18203" PostTypeId="1" AcceptedAnswerId="18204" CreationDate="2018-12-08T03:14:15.050" Score="4" ViewCount="4154" Body="&lt;p&gt;I find that when running &lt;code&gt;:echo message&lt;/code&gt; with a message variable that contains newlines, it displays the newline character as &lt;code&gt;^@&lt;/code&gt;.  Often I'd prefer it to actually be split on a new line though.  Do I have to split up the string manually and then make multiple calls to echo or is there a simpler way to do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit:&#xA;Here's an example that reproduces what I'm talking about: &lt;code&gt;:echom &quot;foo\nbar&quot;&lt;/code&gt;.  I'm running gvim on windows&lt;/p&gt;&#xA;" OwnerUserId="132" LastEditorUserId="132" LastEditDate="2018-12-08T03:25:19.780" LastActivityDate="2021-01-17T16:50:22.403" Title="How to have the echo command process newline characters?" Tags="|command-line|echo|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18204" PostTypeId="2" ParentId="18203" CreationDate="2018-12-08T03:38:38.617" Score="6" Body="&lt;p&gt;You originally mention &lt;code&gt;:echo&lt;/code&gt; but  based on your example it's &lt;code&gt;:echom&lt;/code&gt; that is causing you issues so assuming that's right...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some choices depending on your specific needs (e.g. do you care about the message being saved to the message history)...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo &quot;foo\nbar&quot;&#xA;&#xA;:echon &quot;foo\nbar&quot;&#xA;&#xA;:echom &quot;foo&quot; | echom &quot;bar&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All of these will produce&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Likely due to it's primary purpose being to print messages to be read by the user interactively, &lt;code&gt;echom&lt;/code&gt; parses things a bit differently from the others. &quot;Unprintable characters are displayed not interpreted&quot;. (Similar to the &lt;code&gt;strtrans()&lt;/code&gt; function which also prints newlines as &lt;code&gt;^@&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-12-08T03:47:32.493" LastActivityDate="2018-12-08T03:47:32.493" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18205" PostTypeId="2" ParentId="11484" CreationDate="2018-12-08T06:31:41.827" Score="5" Body="&lt;p&gt;&lt;code&gt;has('gui')&lt;/code&gt; return True if Vim has a GUI compiled in (regardless of whether you're running the terminal vim or not). A better option is &lt;code&gt;has('gui_running')&lt;/code&gt;, which only returns True if the GUI is actually running.&lt;/p&gt;&#xA;" OwnerUserId="4501" LastEditorUserId="51" LastEditDate="2018-12-09T00:48:49.860" LastActivityDate="2018-12-09T00:48:49.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18206" PostTypeId="1" AcceptedAnswerId="18207" CreationDate="2018-12-08T07:02:30.627" Score="6" ViewCount="3344" Body="&lt;p&gt;In vimscript, how can I get the column that the cursor is currently on? I would like to save this value in a variable.&lt;/p&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2018-12-15T22:55:16.250" Title="Get the column that the cursor is on in vimscript" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18207" PostTypeId="2" ParentId="18206" CreationDate="2018-12-08T10:34:42.547" Score="9" Body="&lt;p&gt;You've got &lt;code&gt;col('.')&lt;/code&gt; and &lt;code&gt;virtcol('.')&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first one is to be used most of the time. It doesn't return the actual column number, but the byte index the cursor is on in the current line.&lt;/li&gt;&#xA;&lt;li&gt;The second one returns the actual column number&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The tricky part is that sometimes a tab (1 byte) expand up to &lt;code&gt;&amp;amp;ts&lt;/code&gt; columns, and a multibyte character have more than 1 byte that expand over only one column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need to read their documentation to know what you exactly need depending on what you do with that number after.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2018-12-15T22:55:16.250" LastActivityDate="2018-12-15T22:55:16.250" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18208" PostTypeId="1" CreationDate="2018-12-08T12:08:33.797" Score="1" ViewCount="297" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SNCcb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SNCcb.png&quot; alt=&quot;Weird border&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get weird border form gnome-terminal when i run Vim fullscreen. It never&#xA;happened before. I'm confused. How to repair it without changing my terminal &#xA;background colour?&lt;/p&gt;&#xA;" OwnerUserId="20116" LastActivityDate="2018-12-08T12:08:33.797" Title="Vim: a weird background problem in gnome-terminal" Tags="|linux|linux-ubuntu|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18209" PostTypeId="2" ParentId="18188" CreationDate="2018-12-08T14:31:21.347" Score="0" Body="&lt;p&gt;You can consider to use a gvim msi package, e.g. from &lt;a href=&quot;https://github.com/petrkle/vim-msi/releases&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/petrkle/vim-msi/releases&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;msiexec&lt;/code&gt; supports a wide variety command line options. &lt;code&gt;/passive&lt;/code&gt; seams to be one you are looking for (&lt;a href=&quot;https://docs.microsoft.com/en-us/windows/desktop/msi/standard-installer-command-line-options&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.microsoft.com/en-us/windows/desktop/msi/standard-installer-command-line-options&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;code&gt;msiexec /package vim-8.1.55.msi /passive&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="20098" LastActivityDate="2018-12-08T14:31:21.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18211" PostTypeId="1" AcceptedAnswerId="18225" CreationDate="2018-12-08T19:18:58.180" Score="0" ViewCount="497" Body="&lt;p&gt;I'm trying to configure VIM with Python support in order to use the You Complete Me pluggin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question has been asked before. Unfortunately none of the answers have worked for me. Any suggestions or insights would be great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running a Google VM Instance, Debian 9.4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first step was to clone the repo for vim, cd into it, and run this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;./configure --enable-python3interp=yes --with-python3-config-dir=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then run &lt;code&gt;make&lt;/code&gt; followed by &lt;code&gt;sudo make install&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried setting this configuration 30 different ways and every time it's done installing and I run &lt;code&gt;vim --version&lt;/code&gt; I still get &lt;code&gt;-python -python3&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware that you cannot have python and python3, I've tried both of them. So far nothing has worked.&lt;/p&gt;&#xA;" OwnerUserId="20122" LastActivityDate="2019-05-09T06:02:40.540" Title="configure VIM with Python support for Debian 9.4 VM Instance" Tags="|plugin-you-complete-me|vimscript-python|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18212" PostTypeId="1" AcceptedAnswerId="18221" CreationDate="2018-12-08T23:34:41.813" Score="4" ViewCount="4061" Body="&lt;p&gt;I've got a sick terminal colorscheme, and i'm using vim-one colorscheme for neovim, what i'd like to do is stop it from changing the background color (since i like my terminals background color more)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i don't have my terminals background color i was hoping i could just make neovim not change it. i can find it if need be but i'd rather neovim just does not change it&lt;/p&gt;&#xA;" OwnerUserId="20126" LastActivityDate="2018-12-11T14:47:02.197" Title="Prevent colorscheme from changing background color" Tags="|neovim|linux-arch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18213" PostTypeId="1" AcceptedAnswerId="18217" CreationDate="2018-12-09T01:03:40.350" Score="1" ViewCount="514" Body="&lt;p&gt;I'm trying to unmap some key sequences mapped by &lt;code&gt;python&lt;/code&gt; filetype plugin. While I know a better way, I'm still curious if it can be done with autocommands. Here's what I've got so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup python_ftplugin&#xA;    autocmd!&#xA;&quot;\       for m in ['[[', '[]', '[m', '[M', ']]', '][', ']m', ']M']&#xA;    autocmd BufNewFile,BufRead *.py&#xA;\       for m in ['[[']&#xA;\           | if !empty(maparg(m, 'n'))&#xA;\               | execute 'nunmap &amp;lt;buffer&amp;gt; ' . m&#xA;\               | echom expand('%') . ': unmapped ' . m&#xA;\           | else&#xA;\               | echom expand('%') . ': not unmapped ' . m&#xA;\           | endif&#xA;\       | endfor&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The thing is, when I do &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:lvimgrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:lvimgrep ... *.py&lt;/code&gt;&lt;/a&gt;, filetype plugin gets executed after my autocommand for the first matched file. Is there a way to remedy this?&lt;/p&gt;&#xA;" OwnerUserId="1553" LastEditorUserId="1553" LastEditDate="2018-12-11T00:33:26.153" LastActivityDate="2019-03-25T08:12:31.673" Title="Unmapping filetype mappings" Tags="|vimscript|autocmd|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18215" PostTypeId="1" AcceptedAnswerId="18216" CreationDate="2018-12-09T05:55:38.013" Score="2" ViewCount="81" Body="&lt;p&gt;I am using a .vimrc file cribbed from Github.  I am trying to understand what each line is doing.  I have installed Syntastic using Vundle.  I have typed&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:PluginInstall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it has loaded.  But it doesn't seem to work.  Looking at the documentation for Syntastic I am supposed to add which syntax checkers I want by putting a line in the .vimrc file like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_c_checkers=['c']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, in the .vimrc I am cribbing there is the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup mySyntastic&#xA;  au!&#xA;  au FileType tex let b:syntastic_mode = &quot;passive&quot;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know what this does?  Does is automatically pick what syntax checker to use?  What does it mean?  What is it doing?&lt;/p&gt;&#xA;" OwnerUserId="20127" LastActivityDate="2018-12-09T06:43:05.923" Title="What does this code snippet mean for Syntastic" Tags="|plugin-syntastic|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18216" PostTypeId="2" ParentId="18215" CreationDate="2018-12-09T06:43:05.923" Score="1" Body="&lt;p&gt;That sets the mode of checking. From &lt;a href=&quot;https://github.com/vim-syntastic/syntastic/blob/master/doc/syntastic.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;the syntastic docs&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When set to &quot;passive&quot; syntastic only checks when the user&#xA;  calls &lt;code&gt;:SyntasticCheck&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, instead of automatically running (say, when you save the file), it runs only when you explicitly tell it to. The entire autocommand, then, sets the checking mode to passive for TeX files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the checker isn't set elsewhere, then it will use the default (I don't know what that is for TeX files).&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-12-09T06:43:05.923" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18217" PostTypeId="2" ParentId="18213" CreationDate="2018-12-09T09:30:25.453" Score="4" Body="&lt;h3&gt;UPDATE 24.3.2019&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim has updated its Python runtime file &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/ftplugin/python.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;$VIMRUNTIME/ftplugin/python.vim&lt;/a&gt; in commit &lt;a href=&quot;https://github.com/vim/vim/commit/63b74a8362b14576b21d342dc424d0396ca8ea27&quot; rel=&quot;nofollow noreferrer&quot;&gt;63b74a8&lt;/a&gt; (vim patch should be at least &lt;code&gt;8.1.1048&lt;/code&gt;) which now respects the variables&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;g:no_plugin_maps&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g:no_python_maps&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you set one of them in your vimrc to &lt;code&gt;1&lt;/code&gt;, the mappings will not be created.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Unmap via autocmd Filetype python&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup python_ftplugin&#xA;    autocmd!&#xA;    autocmd Filetype python&#xA;\       for m in ['[[', '[]', '[m', '[M', ']]', '][', ']m', ']M']&#xA;\       | execute('silent! unmap &amp;lt;buffer&amp;gt; '.m)&#xA;\       | endfor&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have used &lt;code&gt;unmap&lt;/code&gt; instead of &lt;code&gt;nunmap&lt;/code&gt; because there are also &lt;code&gt;xmap&lt;/code&gt; and &lt;code&gt;omap&lt;/code&gt; which you might also want to unmap.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Order of events and when &lt;code&gt;$VIMRUNTIME/ftplugin/python.vim&lt;/code&gt; is sourced&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup python_ftplugin&#xA;    autocmd!&#xA;    autocmd Filetype python echom &quot;Event Filetype python&quot;&#xA;    autocmd BufNewFile,BufRead *.py echom &quot;Event BufNewFile,BufRead *.py&quot;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and add following echom to &lt;code&gt;$VIMRUNTIME/ftplugin/python.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Vim filetype plugin file&#xA;&quot; Language: python&#xA;&quot; ...&#xA;&#xA;echom &quot;Sourcing $VIMRUNTIME/ftplugin/python.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is very interesting to see that there is a difference between&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim myfile.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/THRBo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/THRBo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:lvimgrep class *.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/W9r6g.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/W9r6g.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/4493/what-is-the-order-of-winenter-bufenter-bufread-syntax-filetype-events?noredirect=1&amp;amp;lq=1#comment6681_4495&quot;&gt;Sato Katsura has expressed this&lt;/a&gt; as following&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Contrary to the popular belief, the order of applying autocmds across multiple files is not well-defined.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h3&gt;Unmap in &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;However, if you have many autocommands, filetype is tested for each autocommand, which is not efficient. Furthermore, you replicate something that Vim already does automatically anyway (see the reddit post &lt;a href=&quot;https://www.reddit.com/r/vim/wiki/where_to_put_filetype_specific_stuff&quot; rel=&quot;nofollow noreferrer&quot;&gt;where_to_put_filetype_specific_stuff&lt;/a&gt; by romainl).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, it is recommended to do this in &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for m in ['[[', '[]', '[m', '[M', ']]', '][', ']m', ']M']&#xA;  execute('silent! unmap &amp;lt;buffer&amp;gt; '.m)&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Add variable to &lt;code&gt;$VIMRUNTIME/ftplugin/python.vim&lt;/code&gt; to disable mappings&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt; This section is outdated; upstream has incorporated this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, &lt;code&gt;$VIMRUNTIME/ftplugin/python.vim&lt;/code&gt; should follow the recommendation given in &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h write-filetype-plugin&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The user must have a chance to disable the mappings in a filetype&#xA;  plugin, without disabling everything.  Here is an example of how this&#xA;  is done for a plugin for the mail filetype: &gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Add mappings, unless the user didn't want this.&#xA;if !exists(&quot;no_plugin_maps&quot;) &amp;amp;&amp;amp; !exists(&quot;no_mail_maps&quot;)&#xA;  &quot; Quote text by inserting &quot;&amp;gt; &quot;&#xA;  if !hasmapto('&amp;lt;Plug&amp;gt;MailQuote')&#xA;    vmap &amp;lt;buffer&amp;gt; &amp;lt;LocalLeader&amp;gt;q &amp;lt;Plug&amp;gt;MailQuote&#xA;    nmap &amp;lt;buffer&amp;gt; &amp;lt;LocalLeader&amp;gt;q &amp;lt;Plug&amp;gt;MailQuote&#xA;  endif&#xA;  vnoremap &amp;lt;buffer&amp;gt; &amp;lt;Plug&amp;gt;MailQuote :s/^/&amp;gt; /&amp;lt;CR&amp;gt;&#xA;  nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Plug&amp;gt;MailQuote :.,$s/^/&amp;gt; /&amp;lt;CR&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you can convince the current maintainer (&lt;a href=&quot;https://github.com/tpict/vim-ftplugin-python&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tpict/vim-ftplugin-python&lt;/a&gt;) to make the mappings optional, you only have to place &lt;code&gt;let no_python_maps = 1&lt;/code&gt; to your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Do you really need the builtin &lt;code&gt;[[,[],]],][,[m,[M,]m,]M&lt;/code&gt; for python?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I would highly appreciate if you could add a python code snippet to your question illustrating where you want to use the builtin motions. Otherwise I consider your question unmotivated. Do you know the motions &lt;code&gt;[{&lt;/code&gt; and &lt;code&gt;]}&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an illustration what the mappings of the filetype plugin python do, see here &lt;a href=&quot;https://vi.stackexchange.com/questions/7262/end-of-python-block-motion/14115#14115&quot;&gt;End of python block motion&lt;/a&gt;. IMHO they are &lt;em&gt;very&lt;/em&gt; useful &lt;a href=&quot;https://vi.stackexchange.com/questions/17774/how-to-delete-entire-function-definition-c-style&quot;&gt;not only for python&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Update: Convenient Cycling Through Quickfix/Location List&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As it has turned out the OP is using &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; to cycle through the location list. As I said in the comments I would not advice to use them for this because &lt;a href=&quot;http://vimhelp.appspot.com/index.txt.html#%5B&quot; rel=&quot;nofollow noreferrer&quot;&gt;they&lt;/a&gt; are &lt;a href=&quot;http://vimhelp.appspot.com/index.txt.html#index&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;namespace&lt;/em&gt;&lt;/a&gt; keys similar to &lt;a href=&quot;http://vimhelp.appspot.com/index.txt.html#z&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;z&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/index.txt.html#g&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g&lt;/code&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suggested alternatives:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-unimpaired&lt;/a&gt; &lt;code&gt;[l&lt;/code&gt; and &lt;code&gt;]l&lt;/code&gt; (&lt;code&gt;[q&lt;/code&gt; and &lt;code&gt;]q&lt;/code&gt; for quickfix) (maybe with &lt;a href=&quot;https://github.com/Houl/repmo-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;repmo-vim&lt;/a&gt;)&lt;br&gt;&#xA;Pros: no known conflicts with others&lt;br&gt;&#xA;Cons: too much weak finger movement and keys&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/romainl/vim-qf&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-qf&lt;/a&gt; &lt;code&gt;&amp;lt;C-Home&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-End&amp;gt;&lt;/code&gt; (&lt;code&gt;&amp;lt;Home&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;End&amp;gt;&lt;/code&gt; for quickfix)&lt;br&gt;&#xA;Pros: no known conflicts with others&lt;br&gt;&#xA;Cons: too much hand movement&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Short_mappings_for_common_tasks#Quickfix&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.wikia.com/wiki/Short_mappings_for_common_tasks#Quickfix&lt;/a&gt; (function key)&lt;br&gt;&#xA;Pros: common scheme (e.g. &lt;code&gt;F3&lt;/code&gt; in PyCharm &amp;amp; &lt;code&gt;F4&lt;/code&gt; in Sublime Text) and less conflicts&lt;br&gt;&#xA;Cons: too much hand movement  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/w0rp/ale#5ix-how-can-i-navigate-between-errors-quickly&quot; rel=&quot;nofollow noreferrer&quot;&gt;ale-inspired&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;C-k&amp;gt; :lprevious&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;C-j&amp;gt; :lnext&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pros: home row keys (in particular when capslock is remapped to ctrl)&lt;br&gt;&#xA;Cons: already used by others (e.g. &lt;a href=&quot;https://github.com/w0rp/ale#faq-navigation&quot; rel=&quot;nofollow noreferrer&quot;&gt;ale&lt;/a&gt;, &lt;a href=&quot;http://vim.wikia.com/wiki/Switch_between_Vim_window_splits_easily#Ctrl.2Bkjhl_Navigation&quot; rel=&quot;nofollow noreferrer&quot;&gt;switch between splits&lt;/a&gt;, &lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-tmux-navigator&lt;/a&gt;/&lt;a href=&quot;https://github.com/urbainvaes/vim-tmux-pilot&quot; rel=&quot;nofollow noreferrer&quot;&gt;pilot&lt;/a&gt;, &lt;a href=&quot;https://github.com/haya14busa/vim-edgemotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;edgemotion&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/vim-syntastic/syntastic#faqlnext&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-syntastic&lt;/a&gt; does not dare to suggest any specific mapping (except mentioning vim-unimpaired) but certainly sees a motivation for this.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Leader to space plus &lt;code&gt;j/k&lt;/code&gt; (or &lt;code&gt;n/p&lt;/code&gt;) &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;\&amp;lt;space&amp;gt;&quot;&#xA;nnoremap &amp;lt;leader&amp;gt;j :lnext&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;k :lprevious&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pros: space bar by strongest finger and jk are home row keys&lt;br&gt;&#xA;Cons: possibly already used but others are also available (e.g. &lt;code&gt;ln/lp&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;macOS:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MacVim: &lt;code&gt;&amp;lt;Ctrl-Cmd-Left/Right&amp;gt;&lt;/code&gt; for quickfix (default)&lt;br&gt;&#xA;&lt;code&gt;&amp;lt;Alt-Cmd-Left/Right&amp;gt;&lt;/code&gt; for location list (add to gvimrc)&lt;/li&gt;&#xA;&lt;li&gt;Xcode-inspired: &lt;code&gt;&amp;lt;Ctrl-Cmd-G&amp;gt;/&amp;lt;Ctrl-Shift-Cmd-G&amp;gt;&lt;/code&gt; Find next/previous in workspace&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-03-25T08:12:31.673" LastActivityDate="2019-03-25T08:12:31.673" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18219" PostTypeId="1" AcceptedAnswerId="18229" CreationDate="2018-12-09T13:27:02.197" Score="4" ViewCount="1115" Body="&lt;p&gt;I am using the Google Cloud Shell and wanted to &lt;a href=&quot;https://github.com/mhartington/oceanic-next#installation&quot; rel=&quot;nofollow noreferrer&quot;&gt;install a theme&lt;/a&gt; for Vim. Adding the following to my &lt;code&gt;.vimrc&lt;/code&gt; (using &lt;code&gt;vim-plug&lt;/code&gt; as a plugin manager):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'mhartington/oceanic-next'&#xA;&#xA;syntax enable&#xA;&#xA;if (has(&quot;termguicolors&quot;))&#xA; set termguicolors&#xA;endif&#xA;&#xA;colorscheme OceanicNext&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But after doing so, everything appears in black and white:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4LHT8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4LHT8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Ksfya.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ksfya.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has someone an Idea why that happens and how to solve this?&lt;/p&gt;&#xA;" OwnerDisplayName="user20129" LastEditorDisplayName="user20129" LastEditDate="2018-12-10T00:29:56.683" LastActivityDate="2018-12-10T17:24:17.507" Title="No color in Vim while using Google Cloud Shell" Tags="|shell|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18220" PostTypeId="2" ParentId="17968" CreationDate="2018-12-09T15:34:06.390" Score="1" Body="&lt;p&gt;It worked for me in PowerShell Core by adding&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$env:TERM='xterm-256color'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;code&gt;$PROFILE&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13721" LastActivityDate="2018-12-09T15:34:06.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18221" PostTypeId="2" ParentId="18212" CreationDate="2018-12-09T16:32:32.493" Score="10" Body="&lt;p&gt;If the background is changing, then the colorscheme is changing it.  You can either choose a colorscheme that doesn't do that, or try overriding the colorscheme.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd ColorScheme * highlight Normal ctermbg=NONE guibg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The colorscheme may be designed around a particular background color, though, and there may be other highlight groups which need adjustment.&lt;/p&gt;&#xA;" OwnerUserId="15" LastEditorUserId="15" LastEditDate="2018-12-11T14:47:02.197" LastActivityDate="2018-12-11T14:47:02.197" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18222" PostTypeId="1" CreationDate="2018-12-10T00:15:15.500" Score="3" ViewCount="2664" Body="&lt;p&gt;I have been trying to &lt;strong&gt;compile Vim with python3&lt;/strong&gt; on my Mac for many hours, as a result, it looks fine now, as the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 9 2018 00:37:54) macOS version Included patches: 1-573 Huge version without GUI.&#xA;+python/dyn +python3/dyn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when I tried to test using &lt;code&gt;:echo(has('python3'))&lt;/code&gt;, it gives 0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And command like &lt;code&gt;:python3 print('aha!')&lt;/code&gt; gives &lt;strong&gt;error&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E370: Could not load library libpython3.7m.a&#xA;E263: Sorry, this command is disabled, the Python library could not be loaded.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While python2 works fine. Can anyone help me with mercy?!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you so so much!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;p.s. this is my .configure used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --with-features=huge \&#xA;--enable-multibyte \&#xA;--enable-rubyinterp=yes \&#xA;--enable-python3interp=yes \&#xA;--with-python3-config-dir=/Users/mac/anaconda3/lib/python3.7/config-3.7m-darwin \&#xA;--enable-pythoninterp=yes --with-python-config-dir=/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config \&#xA;--enable-luainterp=yes \&#xA;--enable-hangulinput=yes \&#xA;--enable-cscope \&#xA;--prefix=/usr/local/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by the way, &lt;code&gt;--with-python3-config-dir=/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin \&lt;/code&gt; works the same.&lt;/p&gt;&#xA;" OwnerUserId="20138" LastEditorUserId="1841" LastEditDate="2018-12-10T10:18:10.107" LastActivityDate="2020-09-22T13:15:33.017" Title="Compiling Vim with python3 showing E370: Could not load library libpython3.7m.a" Tags="|installing|plugin-python-mode|compile-vim|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18223" PostTypeId="1" AcceptedAnswerId="18228" CreationDate="2018-12-10T03:13:28.283" Score="0" ViewCount="356" Body="&lt;p&gt;I'm trying to use the following regex to match 'Capitalized' words:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;\l\@&amp;lt;!\&amp;lt;\u\w\+&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which matches 'Main' and 'Canvas' in:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;public class Main extends Canvas&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or another example, matches all occurrences of 'Bitmap':&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;public Bitmap b = new Bitmap();&lt;/code&gt;&#xA;And InputHandler in:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;addKeyListener(new InputHandler())&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works fairly nice when used in search mode but not completely when using &lt;code&gt;syntax match&lt;/code&gt; in a syntax file, where the command would be: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;syntax match Capitalized &quot;\l\@&amp;lt;!\&amp;lt;\u\w\+&quot;&lt;/code&gt;&#xA;This does not match anything that is inside parenthesis. Take one example from above: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;addKeyListener(new InputHandler())&lt;/code&gt;&#xA;InputHandler is matched in search mode, but not from a syntax match command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something?&lt;/p&gt;&#xA;" OwnerUserId="20140" LastEditorDisplayName="user5791" LastEditDate="2019-01-29T05:47:53.927" LastActivityDate="2019-01-29T05:47:53.927" Title="Matching 'Capitalized' words in Vim" Tags="|regular-expression|gvim|syntax|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18224" PostTypeId="1" AcceptedAnswerId="18226" CreationDate="2018-12-10T03:15:58.780" Score="0" ViewCount="196" Body="&lt;p&gt;It seems like running the Goyo command (a distraction free editing plugin) on loading a pandoc document should be really simple, but&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;Goyo&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;.config/nvim/ftplugin/pandoc.vim&lt;/code&gt; leads the shell to produce the error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;“nvim test.md” terminated by signal SIGSEGV (Address boundary error)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The filetype is correctly detected (&lt;code&gt;echo 'hello'&lt;/code&gt; works), but for some reason it doesn't like executing Goyo. I think the problem is that Goyo is being executed before the buffer is fully loaded, but I'm not sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="17699" LastEditorUserId="1841" LastEditDate="2018-12-10T10:12:26.797" LastActivityDate="2018-12-10T10:12:26.797" Title="execute 'Goyo' on loading pandoc document" Tags="|neovim|filetype|plugin-vim-pandoc|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18225" PostTypeId="2" ParentId="18211" CreationDate="2018-12-10T04:15:51.117" Score="2" Body="&lt;p&gt;Here is what ended up working for me&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;./configure --enable-python3interp / --with-python3-command=/usr/bin/python3&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Between this &lt;a href=&quot;https://vi.stackexchange.com/a/17455/20122&quot;&gt;link&lt;/a&gt; and a suggested answer which has since been deleted, I cleaned and redid it, and it finally worked. Now running &lt;code&gt;vim --version&lt;/code&gt; shows &lt;code&gt;+python3&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="20122" LastActivityDate="2018-12-10T04:15:51.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18226" PostTypeId="2" ParentId="18224" CreationDate="2018-12-10T09:13:06.583" Score="1" Body="&lt;p&gt;Thanks to D. Ben Knoble above. Moving the file from ~/.config/nvim/ftplugins/pandoc.vim to ~/.config/nvim/&lt;strong&gt;after&lt;/strong&gt;/ftplugins/pandoc.vim made it work. Not that it explains why it didn't work before.&lt;/p&gt;&#xA;" OwnerUserId="17699" LastActivityDate="2018-12-10T09:13:06.583" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18227" PostTypeId="1" CreationDate="2018-12-10T13:30:21.643" Score="1" ViewCount="65" Body="&lt;p&gt;I am not precisely able to reproduce the exact conditions under which this occurs, but sometimes, when I press &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;u&lt;/kbd&gt;, I get the errors below. I cannot even exit vim with &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;c&lt;/kbd&gt; or suspend. I haven't been able to figure out why this is happening, and would appreciate any help, thank you! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/me60x.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/me60x.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18275" LastEditorUserId="18275" LastEditDate="2018-12-10T13:38:15.643" LastActivityDate="2018-12-10T13:38:15.643" Title="Pressing CTRL-U combination gives invalid arguments for function timer_stop?" Tags="|key-bindings|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18228" PostTypeId="2" ParentId="18223" CreationDate="2018-12-10T15:14:22.390" Score="0" Body="&lt;p&gt;Thank you so very much @KarlYngveLervåg for pointing out &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3asyn-containedin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :syn-containedin&lt;/code&gt;&lt;/a&gt;, it leaded me towards the solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Capitalized &quot;\l\@&amp;lt;!\&amp;lt;\u\w\+&quot; containedin=parenGroup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;parenGroup&lt;/code&gt; in my case is a 'syntax region' that also contains the top cluster. More specifically the exact solution was (for java.vim):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Capitalized &quot;\l\@&amp;lt;!\&amp;lt;\u\w\+&quot; containedin=javaParenT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No need to define a new region or crazy parenthesis matching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: If your parent region definition doesn't include the top cluster this might not work outside parenthesis!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Summarizing, vim syntax definitions has some gotchas!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again , thanks!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update!&#xA;My previous solution would not match &lt;code&gt;KeyEvent&lt;/code&gt; in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (input.keys[KeyEvent.VK_A])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now changing the syntax specification to (java only!):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match capitalInParen transparent matchgroup=javaParen start=&quot;(&quot; end=&quot;\]\w\+)&quot; contains=@javaTop&#xA;syntax match Capitalized &quot;\l\@&amp;lt;!\&amp;lt;\u\w\+&quot; containedin=capitalInParent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not perfect but still much better than the last one.&lt;/p&gt;&#xA;" OwnerUserId="20140" LastEditorUserId="1841" LastEditDate="2018-12-11T10:43:46.390" LastActivityDate="2018-12-11T10:43:46.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18229" PostTypeId="2" ParentId="18219" CreationDate="2018-12-10T17:24:17.507" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;Christian Brabandt&lt;/a&gt; mentioned the right answer in &lt;a href=&quot;https://vi.stackexchange.com/questions/18219/no-color-in-vim-while-using-google-cloud-shell?noredirect=1#comment31411_18219&quot;&gt;his comment&lt;/a&gt;. It was the &lt;code&gt;t_Co&lt;/code&gt; option I needed to set. And remove the &lt;code&gt;termguicolors&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .vimrc looks now like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Loading Plugin&#xA;call plug#begin('~/.vim/plugged')&#xA;Plug ('mhartington/oceanic-next')&#xA;call plug#end()&#xA;&#xA;&quot; Theme&#xA;syntax enable&#xA;set t_Co=256&#xA;colorscheme OceanicNext&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The confusion came cause I followed the &lt;a href=&quot;https://github.com/mhartington/oceanic-next#installation&quot; rel=&quot;nofollow noreferrer&quot;&gt;installation instructions on GitHub&lt;/a&gt; which say, that I should use &lt;code&gt;set termguicolors&lt;/code&gt; with vim 8. And I have vim 8 installed but needed to use the instructions for vim 7.&lt;/p&gt;&#xA;" OwnerDisplayName="user20129" LastActivityDate="2018-12-10T17:24:17.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18230" PostTypeId="1" CreationDate="2018-12-10T21:47:09.137" Score="2" ViewCount="180" Body="&lt;p&gt;To format text in LaTeX you need to surround it with curly brackets, e.g. &lt;code&gt;\emph{}&lt;/code&gt; to render it emphasized. I often need to add commands like that to selected text fragments, nothing that could be covered with a simple &lt;code&gt;:%s/foo/bar/g&lt;/code&gt; substitution. I already figured out how to do the substitution for &lt;strong&gt;one&lt;/strong&gt; selection with the help of &lt;a href=&quot;https://vi.stackexchange.com/a/17893/15871&quot;&gt;Replace in Visual Selection&lt;/a&gt;, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\v%V.*%V/\\emph{&amp;amp;}/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To do this for multiple words, I repeat:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;select&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;:&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;press &lt;kbd&gt;↑&lt;/kbd&gt; followed by &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Take this as an example, let’s say I want to replace “bayc’” in the first, “minč’der̊” in the second and “oč’ t’e” and “ayl” in the third sentence – and can’t type those special characters easily:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Irenk’ miayn bołok’ kar-oł en nerkaya-c’n-el bayc’ da hayec’akarg č’-i kar-oł {hamar-v-el. (Ar̊avot 06.04.2006)} \\&lt;br&gt;&#xA;  Agah mecaharust-n ayr-v-um ēr džoxk’-i krak-ner-i meǰ minč’der̊ Ałk’at Łazaros-ě bazm-el ēr hayr Abraham-i {kołk’-i-n. (Nazaryan 2006: 170)} \\&lt;br&gt;&#xA;  Na naew ěndgc-el ē or hakamartut’yun-ě kar-oł en luc-el oč’ t’e mijnord-ner-ě ayl {kołm-er-ě. (Armenpress 25.03.2006)} \\&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is there an easier way to either do a substitution for multiple selections at once or repeat the command faster (something like &lt;kbd&gt;.&lt;/kbd&gt; for ex-mode commands)?&lt;/p&gt;&#xA;" OwnerUserId="15871" LastEditorUserId="15871" LastEditDate="2018-12-11T12:42:16.783" LastActivityDate="2018-12-11T16:07:15.423" Title="How can I quickly replace multiple selections one after another?" Tags="|substitute|visual-mode|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18231" PostTypeId="1" AcceptedAnswerId="18232" CreationDate="2018-12-10T22:00:58.980" Score="17" ViewCount="13691" Body="&lt;p&gt;As I am setting .vimrc, I found these two code blocks have the same functionality.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au Filetype python set&#xA;     \ tabstop=4&#xA;     \ softtabstop=4&#xA;     \ shiftwidth=4&#xA;     \ textwidth=79&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.py&#xA;    \ set tabstop=4&#xA;    \ set softtabstop=4&#xA;    \ set shiftwidth=4&#xA;    \ set textwidth=79&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I reckon that there is a very subtle difference between them, but cannot figure it out. Like, vim interprets Filetype when opening the file etc.&lt;/p&gt;&#xA;" OwnerUserId="20138" LastEditorDisplayName="user5791" LastEditDate="2019-01-29T05:48:20.343" LastActivityDate="2021-09-01T15:07:57.530" Title="What is the difference of using `au BufNewFile,BufRead *.py` and `au Filetype python` in .vimrc?" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18232" PostTypeId="2" ParentId="18231" CreationDate="2018-12-10T23:25:54.663" Score="20" Body="&lt;p&gt;Your intuition is correct: the two autocommands are very similar.&lt;/p&gt;&#xA;&lt;p&gt;The second autocommand runs when you read or start editing a new file with a name that ends in the &lt;code&gt;.py&lt;/code&gt; extension. The first runs when the file type is set to Python, which Vim will generally do automatically for &lt;code&gt;.py&lt;/code&gt; files.&lt;/p&gt;&#xA;&lt;p&gt;However, try running the following commands with each of the two autocommands in place:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:new&#xA;:w new.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You will find that the &lt;code&gt;Filetype&lt;/code&gt; autocommand runs, but the other does not. For this reason, you should probably use the first version if you want to use an autocommand for this.&lt;/p&gt;&#xA;&lt;p&gt;However, in my opinion, there is an even better solution. Create a file in the location:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/after/ftplugin/python.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And enter the contents:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4&#xA;set softtabstop=4&#xA;set shiftwidth=4&#xA;set textwidth=79&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you don't already have filetype plugins enabled, you will need to do so by adding &lt;code&gt;plugin&lt;/code&gt; to the &lt;code&gt;filetype&lt;/code&gt; command in your vimrc file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will have the same effect, no autocommands required!&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2021-09-01T15:07:57.530" LastActivityDate="2021-09-01T15:07:57.530" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18233" PostTypeId="2" ParentId="9626" CreationDate="2018-12-11T01:21:32.340" Score="7" Body="&lt;p&gt;The usual way to concatenate two commands in one line in Vim is to use a pipe &lt;code&gt;|&lt;/code&gt;. Unlike shells, &lt;code&gt;|&lt;/code&gt; in Vim is for sequential, conditional execution - it's more like a &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; in shells.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in this case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/}$/\r}\r/g | %s/^\s*([a-zA-Z\#\.\:\s\(\)-\[\]'=]*)\s*\{/$1 \{/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additional notes from &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3Abar&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :|&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;You can also use &amp;lt;NL&amp;gt; to separate commands in the same way as with '|'.  To&#xA;insert a &amp;lt;NL&amp;gt; use CTRL-V CTRL-J.  &quot;^@&quot; will be shown.  Using '|' is the&#xA;preferred method.  But for external commands a &amp;lt;NL&amp;gt; must be used, because a&#xA;'|' is included in the external command.  To avoid the special meaning of &amp;lt;NL&amp;gt;&#xA;it must be preceded with a backslash.  Example: &#xA;        :r !date&amp;lt;NL&amp;gt;-join&#xA;This reads the current date into the file and joins it with the previous line.&#xA;&#xA;Note that when the command before the '|' generates an error, the following&#xA;commands will not be executed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2018-12-11T01:21:32.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18234" PostTypeId="2" ParentId="5475" CreationDate="2018-12-11T04:33:47.993" Score="0" Body="&lt;p&gt;You can use netrw to navigate to a directory, then &lt;code&gt;c&lt;/code&gt; to set browsing directory to the current directory. You can then &lt;code&gt;:shell&lt;/code&gt; to do some work in that directory, then &lt;code&gt;exit&lt;/code&gt; back to netrw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find this handy when I work on git repos located in different places in my filesystem (I have a script that shows my repos, their status, and conflicted files which I then pump into vim and use netrw to get to them and do the work).&lt;/p&gt;&#xA;" OwnerUserId="19745" LastActivityDate="2018-12-11T04:33:47.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18235" PostTypeId="1" AcceptedAnswerId="18236" CreationDate="2018-12-11T09:16:04.150" Score="0" ViewCount="23" Body="&lt;p&gt;If I do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim&#xA;i&#xA;# Write some tmp text&#xA;# This tmp file served it's purpose, want to quit this one and open a new one&#xA;:e newfile&#xA;# E37: No write since last change (add ! to override)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To avoid that I end up doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim&#xA;i&#xA;# Write some tmp text&#xA;:q!&#xA;vim newfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am looking for a way to do it without the need to quit vim.&lt;/p&gt;&#xA;" OwnerUserId="7129" LastEditorUserId="1841" LastEditDate="2018-12-11T09:22:30.987" LastActivityDate="2018-12-11T09:22:30.987" Title="Open a second file and quit the previously opened one without saving" Tags="|buffers|hidden-buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18236" PostTypeId="2" ParentId="18235" CreationDate="2018-12-11T09:21:51.407" Score="2" Body="&lt;p&gt;You want to add the following line to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set hidden&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27hidden%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'hidden'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'hidden' 'hid'      boolean (default off)&#xA;            global&#xA;            {not in Vi}&#xA;    When off a buffer is unloaded when it is abandoned.  When on a&#xA;    buffer becomes hidden when it is abandoned.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This option allows you to change of buffer even if the modifications were not saved.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-12-11T09:21:51.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18237" PostTypeId="1" AcceptedAnswerId="18239" CreationDate="2018-12-11T09:59:57.900" Score="1" ViewCount="246" Body="&lt;p&gt;This is my first-post and question here so please be gentle (but also tell me if, it I wasn't specific enough etc...) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my questions seems rather simple to me, but still blocks me and I can't find anything in the net helping me (for the first time in my life kind of..)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I simply have to edit many (~100) files. I have to search a certain string, change it and copy a certain amount of lines after that string to another file.&lt;br&gt;&#xA;Instead of writing some sort of parser that reads the whole file (with python or similar) I found it quite convenient to use the &lt;code&gt;-E&lt;/code&gt; mode of vim inside a bash script to do the job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I do is, to write all the commands that I want vim to execute to a script and then source it to vim. The script looks like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/string/string$i/g #Search the string append a running number to it &#xA;V      # Go to visiual line mode &#xA;19j    # Jump 19 lines &#xA;y      # yank the lines&#xA;:vs output.file # open the file where I need to copy the lines&#xA;G      # go to the end&#xA;p      # pass the lines&#xA;:wqa   # save and close everything&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this works only in the normal vim mode e.G. if I execute vim like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -s vim.scr file-to-edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is quite annoying because every time a file is edited a vim window is opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't work, if I use -E mode like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -E -s file-to-edit &amp;lt; vim.scr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -E -s -c &quot;source vim.scr&quot; file-to-edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the documentation I understand that the Ex modes only executes colon commands (which makes sense, that it doesn't execute the visual ones..) &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; *41.1* Introduction                *vim-script-intro* *script* &#xA;&#xA;Your first experience with Vim scripts is the vimrc file.  Vim reads it when&#xA;it starts up and executes the commands.  You can set options to values you&#xA;prefer.  And you can use any colon command in it (commands that start with a&#xA;&quot;:&quot;; these are sometimes referred to as Ex commands or command-line commands).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So my question basically is, how can I replace all the non-colon commands in my script above to make &lt;code&gt;vim -E -s [...]&lt;/code&gt;, to do what I want? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers, &#xA;Marcus&lt;/p&gt;&#xA;" OwnerUserId="20157" LastEditorUserId="1841" LastEditDate="2018-12-11T10:47:24.350" LastActivityDate="2018-12-11T15:37:26.500" Title="How to yank a specified amount of lines in vim -E mode?" Tags="|cut-copy-paste|ex-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18238" PostTypeId="1" CreationDate="2018-12-11T10:07:22.000" Score="3" ViewCount="412" Body="&lt;p&gt;If I create a file without an EOL, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo -n &quot;1&quot; &amp;gt; test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and then open it in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --clean test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...the left hand side of the statusline looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;test&quot; [noeol] 1L, 1C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet when I open the file with my own statusline there is no [noeol] flag.  I cannot see any information in the docs for statusline about how to get this flag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I configure my statusline to see this flag?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks!&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2020-11-14T10:14:52.533" Title="How to show [noeol] flag in custom statusline?" Tags="|statusline|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18239" PostTypeId="2" ParentId="18237" CreationDate="2018-12-11T10:26:02.917" Score="1" Body="&lt;p&gt;I didn't test it but you need to use &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3anorm&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :norm&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm[al][!] {commands}                 *:norm* *:normal*&#xA;            Execute Normal mode commands {commands}.  This makes&#xA;            it possible to execute Normal mode commands typed on&#xA;            the command-line.  {commands} are executed like they&#xA;            are typed.  For undo all commands are undone together.&#xA;            Execution stops when an error is encountered.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which would give you the following file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/string/string$i/g&#xA;norm! V&#xA;norm! 19j&#xA;norm! y&#xA;vs output.file&#xA;norm! G&#xA;norm! p&#xA;wqa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also note that you don't need to put &lt;code&gt;:&lt;/code&gt; in front of your normal mode command when they are written in a script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, for what it's worth I would not use Vim for what you are trying to do. I think &lt;a href=&quot;https://linux.die.net/man/1/grep&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;grep&lt;/code&gt;&lt;/a&gt; with the &lt;code&gt;-A&lt;/code&gt; parameter would be enough to get only the 19 lines after your matched string. And you can pipe it to &lt;a href=&quot;https://linux.die.net/man/1/sed&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;sed&lt;/code&gt;&lt;/a&gt; to do you substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably something along the lines of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;grep -A 19 &quot;string&quot; file-to-edit | sed 's/string/string$i/' &amp;gt; output.file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you have many files this should me faster because &lt;code&gt;grep&lt;/code&gt; and &lt;code&gt;sed&lt;/code&gt; are specialized for these tasks and should be better than Vim. Also since you are now in the terminal you can use the &lt;code&gt;*&lt;/code&gt; joker to treat all of your files.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2018-12-11T10:51:12.800" LastActivityDate="2018-12-11T10:51:12.800" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18240" PostTypeId="2" ParentId="18230" CreationDate="2018-12-11T14:56:57.120" Score="2" Body="&lt;p&gt;Vim offers at least a couple of different solutions to this problem.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Repeating an Ex Command&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;When you issue an ex command, Vim stores that command in the &lt;code&gt;&quot;:&lt;/code&gt; register. You can then repeat this command in the same way you play back a macro: by typing &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Subsequently, just like when playing back macros, you can repeat the command even faster &lt;code&gt;@&lt;/code&gt; by typing &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Using a Macro&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;An alternative is not to use a &lt;code&gt;:substitute&lt;/code&gt; command at all, and instead to make the edits with a recorded macro. When you are in visual mode, type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqc\emph{}&amp;lt;Esc&amp;gt;Pq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, make another visual selection and press &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; to playback the&#xA;macro. Like in the above, subsequent playbacks can be initiated with &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-12-11T16:07:15.423" LastActivityDate="2018-12-11T16:07:15.423" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18241" PostTypeId="1" CreationDate="2018-12-11T14:57:41.413" Score="0" ViewCount="299" Body="&lt;p&gt;&lt;strong&gt;Context:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are 2 and only windows in vim. I want when I press &lt;kbd&gt;F2&lt;/kbd&gt;, cursor remain in the same window, the other window behave like &lt;kbd&gt;PgDn&lt;/kbd&gt;pressed.&lt;/p&gt;&#xA;&lt;p&gt;How to achieve that behavior?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;P.S.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;motivation: used in a preview mode, one window containing a &lt;code&gt;dirvish&lt;/code&gt; buffer.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2018-12-11T15:12:23.420" Title="vim how to page down/up in another window" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18242" PostTypeId="2" ParentId="18241" CreationDate="2018-12-11T15:12:23.420" Score="1" Body="&lt;p&gt;I think the following mapping should to the trick&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; &amp;lt;C-w&amp;gt;p&amp;lt;C-f&amp;gt;&amp;lt;C-w&amp;gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It remaps &lt;code&gt;F2&lt;/code&gt; to change to the previously accessed window (&lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#CTRL-W_CTRL-P&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h CTRL-W_p&lt;/code&gt;&lt;/a&gt;), scroll down (&lt;a href=&quot;http://vimhelp.appspot.com/scroll.txt.html#CTRL-F&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h CTRL-F&lt;/code&gt;&lt;/a&gt;) and come back to the previous window.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-12-11T15:12:23.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18243" PostTypeId="2" ParentId="18237" CreationDate="2018-12-11T15:37:26.500" Score="1" Body="&lt;p&gt;You can yank and put lines directly from the command-line without using any normal-mode commands:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/string/string$i/g&#xA;.,+19y           # yank the current line and the 19 lines that follow&#xA;vs output.file&#xA;$pu              # put the lines at the end of the buffer&#xA;wqa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :yank&lt;/code&gt;, &lt;code&gt;:help :put&lt;/code&gt; and &lt;code&gt;:help [range]&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-12-11T15:37:26.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18244" PostTypeId="2" ParentId="18238" CreationDate="2018-12-11T16:20:53.723" Score="2" Body="&lt;p&gt;I had thought that &lt;code&gt;[noeol]&lt;/code&gt; was one of Vim's built in statusline flags, like &lt;code&gt;[+]&lt;/code&gt; for modified.  But @muru pointed out that it isn't; it's a message from Vim when you write a buffer (without an eol).  This answers the question I thought I asked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if one does want to add &lt;code&gt;[noeol]&lt;/code&gt; to the statusline then, as @ChristianBrabandt said, one can simply check the &lt;code&gt;eol&lt;/code&gt; option and display &lt;code&gt;[noeol]&lt;/code&gt; as appropriate.  This answers the question I seem to have asked.&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2018-12-11T16:20:53.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18245" PostTypeId="1" AcceptedAnswerId="18262" CreationDate="2018-12-11T17:27:01.090" Score="0" ViewCount="183" Body="&lt;p&gt;I'm using &lt;code&gt;breakindent&lt;/code&gt; to make long lines wraparound to the same indentation level as the start of the line.  Unfortunately, with this setting on system copy and paste (in this case, out of the macOS Terminal) includes a bunch of extra spaces.  When I paste into another window, the result looks like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;We distinguish between training AI systems to identify what humans consider good and           identifying actions that are &quot;good&quot; in some more universal sense, even if humans do not consider them so.  Whether     there are actions that are good in this sense is controversial.  Regardless of      what position one takes on this philosophical question, general good is not yet available as a target for AI           training.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to fix copy and paste when &lt;code&gt;breakindent&lt;/code&gt; is on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Clarification&lt;/strong&gt;: I am copy and pasting by selecting with the mouse and hitting Cmd-C, in order to get text into a different application.&lt;/p&gt;&#xA;" OwnerUserId="19555" LastEditorUserId="19555" LastEditDate="2018-12-12T16:23:59.503" LastActivityDate="2018-12-12T16:56:27.350" Title="Copy and paste with breakindent set" Tags="|indentation|cut-copy-paste|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18246" PostTypeId="1" CreationDate="2018-12-11T17:29:13.003" Score="0" ViewCount="85" Body="&lt;p&gt;I'm not really sure how to describe this behavior better than with the example I'm dealing with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to write a custom completion using &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf-vim&lt;/a&gt; ... and as I'm looking through the documentation, &lt;a href=&quot;https://github.com/junegunn/fzf.vim/blob/master/doc/fzf-vim.txt#L303&quot; rel=&quot;nofollow noreferrer&quot;&gt;there is a section that describes how to do it briefly&lt;/a&gt;, but since I don't understand it fully, I wanted to play with the API.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So naturally I thought I'd be able to just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call fzf#vim#complete('cat /usr/share/dict/words')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of binding it to a binding and using that binding like they show with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-k&amp;gt; fzf#vim#complete('cat /usr/share/dict/words')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the problem is, while the binding does pop up fzf, the &lt;code&gt;:call fzf#vim#complete(...)&lt;/code&gt; seems to do nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what is causing this behavior, and if there is some other way I should be invoking the function? I don't mind reading stuff up in the documentation and learning about vimscript, but at this point I really don't know where to look anymore&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As a side note, what I'm actually trying to do is create a fzf wrapper around &lt;code&gt;:digraph&lt;/code&gt;. I wasn't sure if this would be possible with just the output of &lt;code&gt;:digraph&lt;/code&gt;, so I found &lt;a href=&quot;https://github.com/chrisbra/unicode.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;unicode.vim&lt;/a&gt; which even provides a function &lt;a href=&quot;https://github.com/chrisbra/unicode.vim/blob/master/autoload/unicode.vim#L31&quot; rel=&quot;nofollow noreferrer&quot;&gt;FindUnicodeBy&lt;/a&gt; which seems I should be able to just pass into the &lt;code&gt;fzf#vim#complete&lt;/code&gt; wrapper, but I can't even figure out how to test the completion function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any tips are very welcome, as well as references to stuff to read to be able to work better with vimscript!&lt;/p&gt;&#xA;" OwnerUserId="11916" LastActivityDate="2018-12-12T08:12:35.207" Title="Why does `:call f(...)` do nothing while mapping it to a binding works?" Tags="|vimscript|functions|plugin-fzf|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18247" PostTypeId="1" CreationDate="2018-12-11T18:29:21.247" Score="1" ViewCount="37" Body="&lt;p&gt;Based on the documentation of &lt;code&gt;digraphs-use&lt;/code&gt; (&lt;code&gt;:help digraphs-use&lt;/code&gt;) it should be possible to do both &lt;code&gt;&amp;lt;C-k&amp;gt; {char1} {char2}&lt;/code&gt; and &lt;code&gt;{char1} &amp;lt;BS&amp;gt; {char2}&lt;/code&gt;, but the second one does nothing and &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; simply deletes the first character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; and pressing the backspace key and it does put in &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt;, which makes me think I am indeed pressing the right key.&lt;/p&gt;&#xA;" OwnerUserId="11916" LastActivityDate="2018-12-11T18:29:21.247" Title="Why does `&lt;C-k&gt; {char1} {char2}` work for digraphs but `{char1} &lt;BS&gt; {char2}?" Tags="|key-bindings|digraphs|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18249" PostTypeId="1" CreationDate="2018-12-11T21:03:28.033" Score="7" ViewCount="3451" Body="&lt;p&gt;&lt;strong&gt;First, I'm not asking about performance.&lt;/strong&gt; I'm looking for something that will help me, mentally, get into large C source code files that I'm not yes accustomed to. Take for example &lt;a href=&quot;https://github.com/bminor/binutils-gdb/blob/master/binutils/readelf.c&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;readelf.c&lt;/code&gt;&lt;/a&gt;. This file is 20,000 lines. I can read the code and make sense of it, but I'd rather not. &lt;a href=&quot;https://softwareengineering.stackexchange.com/questions/343357/why-are-some-c-programs-written-in-one-huge-source-file&quot;&gt;This is only ever a problem in my experience with C.&lt;/a&gt; For some reason, in C the file size is absurdly big, and &lt;code&gt;readelf.c&lt;/code&gt; isn't alone in this. Is there anything that can virtualize a C file into something sane like a structured project -- I know that's asking for a lot, but it would seem with all the C code in existence someone would have done something like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My laptop's terminal can hold ~50 lines. What tools and plugins does vim offer to help navigating files that are in excess of 10k but less than 100k lines?&lt;/p&gt;&#xA;" OwnerUserId="5078" LastActivityDate="2018-12-15T19:09:30.463" Title="How do you navigate large source files with VIM?" Tags="|large-documents|filetype-c|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18252" PostTypeId="2" ParentId="16216" CreationDate="2018-12-12T06:38:46.923" Score="1" Body="&lt;p&gt;Add an environment variable &quot;PYTHONPATH&quot; which points to the installation location of Python and restart the editor.&lt;/p&gt;&#xA;" OwnerUserId="20169" LastEditorUserId="343" LastEditDate="2018-12-12T07:31:49.923" LastActivityDate="2018-12-12T07:31:49.923" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18253" PostTypeId="2" ParentId="18246" CreationDate="2018-12-12T08:05:53.530" Score="1" Body="&lt;p&gt;This touches the implementation details of &lt;code&gt;fzf#complete&lt;/code&gt;. If you look into the source code of &lt;code&gt;fzf#vim#complete&lt;/code&gt;, you will see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call feedkeys(&quot;\&amp;lt;Plug&amp;gt;(-fzf-complete-trigger)&quot;)&#xA;return ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when you do &lt;code&gt;imap &amp;lt;expr&amp;gt; xxxx fzf#vim#complete()&lt;/code&gt;, what returns from the expression is &lt;code&gt;''&lt;/code&gt;, and the key &lt;code&gt;\&amp;lt;Plug&amp;gt;(-fzf-complete-trigger)&lt;/code&gt; stored in a buffer and is to be processed later. This key is actually defined by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;Plug&amp;gt;(-fzf-complete-trigger) &amp;lt;c-o&amp;gt;:call s:_complete_trigger()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no &lt;code&gt;nmap&lt;/code&gt; defined for it. So you won't get anything if you do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call fzf#vim#complete('cat /usr/share/dict/words')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I actually didn't get your purpose to run it in normal mode. But if just want to have this ability, you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;expr&amp;gt; xxx 'i' . fzf#vim#complete('cat /usr/share/dict/words')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or (this method adds key &lt;code&gt;i&lt;/code&gt; before &lt;code&gt;\&amp;lt;Plug&amp;gt;(-fzf-complete-trigger)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call feedkeys(&quot;i&quot;) | call fzf#vim#complete('cat /usr/share/dict/words')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or to modify fzf source code to expose s:_complete_trigger as a global function and call that function.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2018-12-12T08:12:35.207" LastActivityDate="2018-12-12T08:12:35.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18254" PostTypeId="1" AcceptedAnswerId="18256" CreationDate="2018-12-12T08:53:25.583" Score="1" ViewCount="901" Body="&lt;p&gt;I think it is possible but can not figure how one can highlight only the first match of contained syntax?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn clear&#xA;syntax cluster TitleParts contains=TitleNum,TitleType,TitleRest&#xA;syntax match MyTitle /\v^\s+\d+\)\s+.*$/ contains=@TitleParts&#xA;syntax match TitleNum /\v\s+\d+\)\s*/ contained nextgroup=TitleType&#xA;syntax match TitleType /\v(this|that)/ contained&#xA;syntax match TitleRest /\v\(.+\)/ contained&#xA;hi link MyTitle Title&#xA;hi link TitleNum Statement&#xA;hi link TitleType Type&#xA;hi link TitleRest Comment&#xA;&#xA;  1) this Hello World this (Bla bla bla 1 2 3 4 5)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VVDD7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VVDD7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2018-12-12T09:54:23.770" Title="Syntax highlighting (contains, contained) of only the first match" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18255" PostTypeId="2" ParentId="17369" CreationDate="2018-12-12T09:03:40.230" Score="6" Body="&lt;p&gt;To open a terminal for running &lt;code&gt;command&lt;/code&gt; with height 20 you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new +resize20 term://command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the terminal is ready created, you either use &lt;code&gt;:resize 20&lt;/code&gt; or &lt;code&gt;20&amp;lt;c-w&amp;gt;_&lt;/code&gt; for height. &lt;code&gt;:vertical resize 20&lt;/code&gt; or &lt;code&gt;20&amp;lt;c-w&amp;gt;|&lt;/code&gt; for width.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-12-12T09:03:40.230" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18256" PostTypeId="2" ParentId="18254" CreationDate="2018-12-12T09:54:23.770" Score="1" Body="&lt;p&gt;Well, I've found the answer while experimenting... not sure if this is the best one :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn clear&#xA;syntax cluster TitleParts contains=TitleFront,TitleTail&#xA;syntax match TitleFront /\v^\s+\d+\)\s((this|that)\s)?/ contains=TitleNum,TitleType containedin=@TitleParts&#xA;syntax match MyTitle /\v^\s+\d+\)\s+.*$/ contains=@TitleParts&#xA;syntax match TitleNum /\v\s+\d+\)\s*/ contained containedin=TitleFront&#xA;syntax match TitleType /\v(this|that)/ contained containedin=TitleFront&#xA;syntax match TitleTail /\v\(\d+\)\s\(.{-}\)$/ contained containedin=MyTitle&#xA;hi link MyTitle Title&#xA;hi link TitleNum Statement&#xA;hi link TitleType Type&#xA;hi link TitleTail Comment&#xA;&#xA;  123) this Hello World this (1) (Bla bla bla 1 2 3 4 5)&#xA;&#xA;  1) that Hello World this (22) (Bla bla bla 1 2 3 4 5)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fi8Hw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fi8Hw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2018-12-12T09:54:23.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18257" PostTypeId="1" AcceptedAnswerId="18258" CreationDate="2018-12-12T11:07:56.527" Score="2" ViewCount="225" Body="&lt;p&gt;The shebang line has an annoying background color, how to change it to have the same color of comments. This is a Haskell file.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/756Zl.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/756Zl.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17299" LastEditorUserId="17299" LastEditDate="2018-12-12T11:14:48.977" LastActivityDate="2018-12-12T15:51:02.780" Title="How to change one syntax behaviour in vim" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18258" PostTypeId="2" ParentId="18257" CreationDate="2018-12-12T11:59:00.150" Score="3" Body="&lt;p&gt;The shebang line is considered as an error by the default haskell syntax plugin (&lt;code&gt;$VIMRUNTIME/syntax/haskell.vim&lt;/code&gt;), and as a result highlighted by the syntax group &lt;a href=&quot;https://github.com/vim/vim/blob/295471920def98ce84bc96e5d97c16d250c81621/runtime/syntax/haskell.vim#L107&quot; rel=&quot;nofollow noreferrer&quot;&gt;cError&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can customize the behavior of the haskell syntax plugin by writing additional statements inside the file &lt;code&gt;~/.vim/after/syntax/haskell.vim&lt;/code&gt;.&#xA;For example, you could write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match hsLineComment '^#!/usr/bin/env stack$'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This statement tells Vim that whenever it finds a line matching the regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^#!/usr/bin/env stack$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should highlight it with the syntax group &lt;code&gt;hsLineComment&lt;/code&gt;.&#xA;The latter is the syntax group used to highlight the comment that was written below your shebang line in your picture. You may need to tweak the regex to make it more permissive if you want to highlight other kinds of shebang lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to find the syntax group highlighting the text under your cursor, you can use this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno  &amp;lt;silent&amp;gt;  !s  :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;print_syntax_group_stack(v:count)&amp;lt;cr&amp;gt;&#xA;&#xA;fu! s:print_syntax_group_stack(count) abort&#xA;    if a:count&#xA;        let name = get(s:get_syntax_group_stack(), a:count-1, '')&#xA;        if !empty(name)&#xA;            exe 'syntax list '.name&#xA;        endif&#xA;    else&#xA;        echo join(s:get_syntax_group_stack())&#xA;    endif&#xA;endfu&#xA;&#xA;fu! s:get_syntax_group_stack()&#xA;    return reverse(map(synstack(line('.'), col('.')), {i,v -&amp;gt; synIDattr(v, 'name')}))&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use it, you need to press &lt;code&gt;!s&lt;/code&gt; on the text you're interested in. For example, if you press &lt;code&gt;!s&lt;/code&gt; while your cursor is on the comment shown in your picture, Vim should print &lt;code&gt;hsLineComment&lt;/code&gt; on the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, there is only one syntax group. But sometimes, there may be several (a stack of syntax groups). If that happens, they will all be printed on the command line from the innermost group to the outermost one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may get additional information about a syntax group printed on the command line, by prefixing &lt;code&gt;!s&lt;/code&gt; with a count. For example, if you want more information about the first syntax group in the stack, you could press &lt;code&gt;1!s&lt;/code&gt;.&#xA;For the haskell comment, Vim would print:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Syntax items ---&#xA;hsLineComment  xxx match &quot;---*\([^-!#$%&amp;amp;\*\+./&amp;lt;=&amp;gt;\?@\\^|~].*\)\?$&quot;  contains=@Spell&#xA;                   links to hsComment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This tells you that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;code&gt;hsLineComment&lt;/code&gt; syntax group contains only 1 item, matching the regex &lt;code&gt;---*\([^-!#$%&amp;amp;\*\+./&amp;lt;=&amp;gt;\?@\\^|~].*\)\?$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;it may contain any item from a syntax group in the cluster &lt;code&gt;@Spell&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;it's highlighted by the highlight group &lt;code&gt;hsComment&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;hsComment&lt;/code&gt; is linked to the highlight group &lt;code&gt;Comment&lt;/code&gt; in &lt;code&gt;$VIMRUNTIME/syntax/haskell.vim&lt;/code&gt;, which is confirmed by the output of &lt;code&gt;:verb hi hsComment&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verb hi hsComment&#xA;&#xA;    hsComment      xxx links to Comment&#xA;            Last set from /usr/local/share/vim/vim81/syntax/haskell.vim:155&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you have other issues with the default haskell syntax plugin, there may be a global variable which you could set in your &lt;code&gt;vimrc&lt;/code&gt;. See &lt;code&gt;:h ft-haskell-syntax&lt;/code&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The command does not work, it gives an error bash: &lt;code&gt;!/usr/bin/env: event not found&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think that was because bash processes the &lt;code&gt;!&lt;/code&gt; character as the beginning of an event designator (see &lt;code&gt;$ man bash&lt;/code&gt;, and look for the section &lt;code&gt;HISTORY EXPANSION&lt;/code&gt; and the subsection &lt;code&gt;Event Designators&lt;/code&gt;).&#xA;So, it tried to expand &lt;code&gt;!/usr/bin/env&lt;/code&gt; into the previous command in the history beginning with the string &lt;code&gt;/usr/bin/env&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command would probably have avoided the issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat &amp;lt;&amp;lt;'EOF' &amp;gt;~/.vim/after/syntax/haskell.vim&#xA;syn match hsLineComment '^#!/usr/bin/env stack$'&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo 'syn match hsLineComment +^#!/usr/bin/env stack$+' &amp;gt;~/.vim/after/syntax/haskell.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You don't have to use a single quote to surround the pattern of a regex.&#xA;See &lt;code&gt;:h 44.3&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The part at the end is a pattern, like it's used for searching.  The // is&#xA;  used to surround the pattern (like how it's done in a &quot;:substitute&quot; command).&#xA;  You can use any other character, like a plus or a quote.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In the last command, &lt;code&gt;+&lt;/code&gt; is used because it allows you to use only single quotes around the argument passed to &lt;code&gt;$ echo&lt;/code&gt;. Single quotes, contrary to double quotes, suppress the shell history expansion. And since the &lt;code&gt;+&lt;/code&gt; character is not in the regex you don't have to escape it (which would make the regex a little less readable).&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2018-12-12T15:51:02.780" LastActivityDate="2018-12-12T15:51:02.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18260" PostTypeId="1" AcceptedAnswerId="18261" CreationDate="2018-12-12T15:52:25.600" Score="3" ViewCount="79" Body="&lt;p&gt;I have added the following the mappings to my vimrc.&#xA;I want &lt;code&gt;K&lt;/code&gt; to take me to the top line of the window and &lt;code&gt;H&lt;/code&gt; to take me to the first non-empty character of the line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap K H&#xA;nmap H ^&#xA;nmap J L&#xA;nmap L g_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does not do what I want it to.&#xA;Since &lt;code&gt;K&lt;/code&gt; performs &lt;code&gt;H&lt;/code&gt; and &lt;code&gt;H&lt;/code&gt; is mapped to (under the above mapping) take me to the first non-empty character of the line, &lt;code&gt;K&lt;/code&gt; takes me to the first non-empty character of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to achieve what I want to do? I could not think of anything.&lt;/p&gt;&#xA;" OwnerUserId="16884" LastActivityDate="2018-12-12T15:58:11.637" Title="Swapping two vim mappings" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18261" PostTypeId="2" ParentId="18260" CreationDate="2018-12-12T15:58:11.637" Score="4" Body="&lt;p&gt;Your question is the opposite problem of &lt;a href=&quot;https://vi.stackexchange.com/q/10127/1841&quot;&gt;this one&lt;/a&gt;. You need to use the non recursive version of the &lt;code&gt;map&lt;/code&gt; commands &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3anore&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :nore&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap K H&#xA;nnoremap H ^&#xA;nnoremap J L&#xA;nnoremap L g_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And as a general rule always use the non recursive version unless you know what you're doing.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-12-12T15:58:11.637" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18262" PostTypeId="2" ParentId="18245" CreationDate="2018-12-12T16:56:27.350" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Clarification: I am copy and pasting by selecting with the mouse and hitting Cmd-C, in order to get text into a different application.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Okay, so you are basically copying the visual representation on your terminal. Since there is whitespace added, it will be copied as well. There is no way around that (it will also copy e.g. line numbers, signs or concealed characters, since those are visual representation of the text on the screen, but does not really exists inside the buffer/file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want this, use e.g. the yank commands, e.g. like &lt;code&gt;:y +&lt;/code&gt; to copy the current cursor line into the clipboard (this needs a vim with system clipboard support, e.g. with &lt;code&gt;+clipboard&lt;/code&gt; in the &lt;code&gt;:version&lt;/code&gt; output). Or use the normal mode &lt;code&gt;yank&lt;/code&gt; command, e.g. &lt;code&gt;&quot;+yy&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-12-12T16:56:27.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18263" PostTypeId="2" ParentId="8074" CreationDate="2018-12-12T17:36:55.230" Score="1" Body="&lt;p&gt;I couldn't find a specific setting for disabling the wheel while leaving the other mouse features active, but as a workaround, you could map wheel events to do nothing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;ScrollWheelUp&amp;gt; &amp;lt;Nop&amp;gt;&#xA;map &amp;lt;ScrollWheelDown&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may also need to disable the shift- and control-modified events, and &lt;code&gt;Left&lt;/code&gt; and &lt;code&gt;Right&lt;/code&gt; if you have a device that sends those.  See &lt;code&gt;:help scroll-mouse-wheel&lt;/code&gt; for a complete list of the default bindings.&lt;/p&gt;&#xA;" OwnerUserId="7600" LastActivityDate="2018-12-12T17:36:55.230" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18264" PostTypeId="2" ParentId="18249" CreationDate="2018-12-13T01:19:17.010" Score="5" Body="&lt;p&gt;I think what you are looking for is a plugin like &lt;a href=&quot;https://github.com/majutsushi/tagbar&quot; rel=&quot;noreferrer&quot;&gt;tagbar&lt;/a&gt;, which can create a sidebar to display all the functions, struct/class, macros, etc. It also allow you to click (or press enter on) the tag and then jump to the definition.&lt;/p&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-12-13T01:19:17.010" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18265" PostTypeId="1" CreationDate="2018-12-13T02:09:37.657" Score="12" ViewCount="6384" Body="&lt;p&gt;When I run &lt;code&gt;:Gbrowse&lt;/code&gt; from vim-fugitive, I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fugitive: No Gbrowse handler found for 'https://github.com/dbcli/mssql-cli'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can it just spool that out to &lt;code&gt;xdg-open&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="5078" LastEditDate="2018-12-13T03:47:39.627" LastActivityDate="2020-01-29T15:51:15.123" Title="Getting &quot;fugitive: No Gbrowse handler found&quot;" Tags="|plugin-fugitive|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18267" PostTypeId="2" ParentId="18249" CreationDate="2018-12-13T05:01:47.447" Score="4" Body="&lt;p&gt;You can enable code folding using the vim option:&#xA;&lt;code&gt;set foldmethod=syntax&lt;/code&gt;&#xA;This reduces the amount of code you see at once and makes it manageable.&#xA;After enabling code folding, use below commands for opening and closing folds:&#xA;The commands zc (close), zo (open), and za (toggle) operate on one level of folding, at the cursor. The commands zC, zO and zA are similar, but operate on all folding levels (for example, the cursor line may be in an open fold, which is inside another open fold; typing zC would close all folds at the cursor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command zr reduces folding by opening one more level of folds throughout the whole buffer (the cursor position is not relevant). Use zR to open all folds.&lt;/p&gt;&#xA;" OwnerUserId="20178" LastActivityDate="2018-12-13T05:01:47.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18268" PostTypeId="2" ParentId="17090" CreationDate="2018-12-13T06:48:03.680" Score="0" Body="&lt;p&gt;What you need to find all &lt;code&gt;&amp;gt;&amp;lt;&lt;/code&gt; patterns and to insert two new lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the simplest is to do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/&amp;gt;&amp;lt;/&amp;gt;\r\r&amp;lt;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/&amp;gt;\zs\ze&amp;lt;/\r\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-12-13T06:48:03.680" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18269" PostTypeId="2" ParentId="15076" CreationDate="2018-12-13T08:04:51.020" Score="1" Body="&lt;p&gt;Using &lt;code&gt;call&lt;/code&gt; you are not able to get the return value of the function, regardless whether &lt;code&gt;range&lt;/code&gt; is used or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aside from @Karl's answer, you can set some variable instead of using &lt;code&gt;return&lt;/code&gt;. Such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Range() range abort&#xA;  let toreturn = 'my value'&#xA;  let s:retval = toreturn&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13302" LastActivityDate="2018-12-13T08:04:51.020" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18270" PostTypeId="1" AcceptedAnswerId="18274" CreationDate="2018-12-13T10:24:07.117" Score="1" ViewCount="522" Body="&lt;p&gt;Non-AA font rendering seems available everywhere except for &lt;em&gt;Windows&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In &lt;em&gt;MacVim&lt;/em&gt;, this is possivle via &lt;code&gt;noantialias&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;When using GTK2 front-end, the same can be achieved by adding &lt;code&gt;antialias=false&lt;/code&gt; to the &lt;em&gt;fontconfig&lt;/em&gt; query, e.g.: &lt;code&gt;Courier New:size=12:antialias=false:rgba=rgb&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For Motif, Athena and GTK1 front-ends, aliased rendering is the only option.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But how do I request it in the GUI version of &lt;em&gt;Vim&lt;/em&gt; on Windows (&lt;code&gt;gui_win32&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="18684" LastEditorUserId="1292" LastEditDate="2019-01-13T15:05:16.840" LastActivityDate="2019-01-13T15:05:16.840" Title="Requesting aliased :guifont rendering on Windows" Tags="|microsoft-windows|font|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18271" PostTypeId="2" ParentId="18249" CreationDate="2018-12-13T10:35:06.137" Score="2" Body="&lt;p&gt;Something that I am doing is using &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Plugin Gutentags : Used for creating tags across the project from root folder.&lt;/li&gt;&#xA;&lt;li&gt;Plugin Tagbar    : Used for navigating within the files.&lt;/li&gt;&#xA;&lt;li&gt;Plugin Ack       : Used to search within whole project.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can find my whole set up @ &lt;a href=&quot;https://manyyack.github.io/Linux-Set-up/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18443" LastEditorUserId="18443" LastEditDate="2018-12-13T10:41:11.153" LastActivityDate="2018-12-13T10:41:11.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18272" PostTypeId="1" CreationDate="2018-12-13T11:19:05.777" Score="0" ViewCount="141" Body="&lt;p&gt;I noticed that when functions in &lt;code&gt;plugin/myplugin.vim&lt;/code&gt; are named using the autoload convention, &lt;code&gt;function! myplugin#myfunction()&lt;/code&gt;, the file &lt;code&gt;autoload/myplugin.vim&lt;/code&gt; gets sourced on &lt;code&gt;vim&lt;/code&gt; startup, even though no function of that file is ever called during the startup process. This happens for example with &lt;a href=&quot;https://github.com/junegunn/vim-peekaboo/blob/master/plugin/peekaboo.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-peekaboo&lt;/a&gt;. Changing the functions &lt;code&gt;peekaboo#{on,off}&lt;/code&gt; to e.g. &lt;code&gt;Peekaboo_{on,off}&lt;/code&gt; fixes the issue, but I was wondering whether this was documented behavior? Also, is there a canonical way of naming functions in &lt;code&gt;plugin/myplugin.vim&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="11125" LastActivityDate="2018-12-13T16:20:01.247" Title="Why does autoload/myplugin.vim get sourced?" Tags="|plugin-system|autoload|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18274" PostTypeId="2" ParentId="18270" CreationDate="2018-12-13T14:41:42.790" Score="2" Body="&lt;p&gt;Have you tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; set gfn=Courier_New:h14:qNONANTIALIASED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works for me in Win10&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4HzCG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4HzCG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2018-12-13T14:41:42.790" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18276" PostTypeId="2" ParentId="18272" CreationDate="2018-12-13T16:20:01.247" Score="1" Body="&lt;p&gt;Untested, but my theory is that during startup the definition of a function (particularly using &lt;code&gt;function!&lt;/code&gt;) causes vim to check if a function by that name is defined, and this in turn causes the autoload search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Feedback from contributors to vim would be welcome, in order to decide whether this is a bug or a feature.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-12-13T16:20:01.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18277" PostTypeId="2" ParentId="18249" CreationDate="2018-12-13T20:42:46.193" Score="2" Body="&lt;p&gt;In addition to &lt;a href=&quot;http://ctags.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ctags&lt;/a&gt;-based plugins like &lt;a href=&quot;http://vim-taglist.sourceforge.net/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Taglist&lt;/a&gt; i use &lt;a href=&quot;http://cscope.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;cscope&lt;/a&gt;. Some plugins may be useful: like &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=51&quot; rel=&quot;nofollow noreferrer&quot;&gt;cscope_macros&lt;/a&gt; and &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2368&quot; rel=&quot;nofollow noreferrer&quot;&gt;CCTree&lt;/a&gt;. Before using ctags or cscope you have to make tags file and cscope database, see links above. Although these tools are pretty old, they work just fine with many modern C implementations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also don't forget about marks you can set on important places, folding unwanted parts, &lt;code&gt;gD&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;]]&lt;/code&gt; and similar motions. If you do not want to use any external programs or plugins you can get some preview of file by this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set foldmethod=syntax&#xA;zM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;foldmethod&lt;/code&gt; sets folding based on C syntax (you can write it in .vimrc) and &lt;code&gt;zM&lt;/code&gt; command (in normal mode) folds everything to max level. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help tags&#xA;:help ctags&#xA;:help cscope&#xA;:help mark-motions&#xA;:help folding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17271" LastActivityDate="2018-12-13T20:42:46.193" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18279" PostTypeId="2" ParentId="14587" CreationDate="2018-12-14T07:35:23.563" Score="12" Body="&lt;p&gt;For Windows it's &lt;code&gt;%UserProfile%\AppData\Local\nvim\colors&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="20195" LastEditorUserId="51" LastEditDate="2019-07-28T00:20:12.263" LastActivityDate="2019-07-28T00:20:12.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18280" PostTypeId="2" ParentId="9760" CreationDate="2018-12-14T08:57:35.023" Score="15" Body="&lt;p&gt;&lt;a href=&quot;https://askubuntu.com/a/353944/900107&quot;&gt;This answer&lt;/a&gt; solved the exact same problem for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;~/.vimrc&lt;/code&gt; add the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After restarting vim the problem has gone&lt;/p&gt;&#xA;" OwnerUserId="20196" LastActivityDate="2018-12-14T08:57:35.023" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18281" PostTypeId="1" AcceptedAnswerId="18288" CreationDate="2018-12-14T12:43:08.730" Score="0" ViewCount="4229" Body="&lt;p&gt;How much space does vim take up in for example Ubuntu 18.04.1? I'm not sure how to check, I don't want to &lt;code&gt;apt purge&lt;/code&gt; and then install again&lt;/p&gt;&#xA;" OwnerUserId="6793" LastActivityDate="2018-12-15T10:11:38.813" Title="what is the installation size of vim?" Tags="|installing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18282" PostTypeId="1" AcceptedAnswerId="18283" CreationDate="2018-12-14T15:59:20.693" Score="0" ViewCount="762" Body="&lt;p&gt;Is there a way in Vim to do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let S = '[''123'', ''456'', ''789'']'&#xA;let L = parseStringToList(S)&#xA;&quot; L is a list containing the string '123', '456', and '789'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2018-12-14T16:19:24.867" Title="How to parse a string to a list?" Tags="|vimscript|parsing|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18283" PostTypeId="2" ParentId="18282" CreationDate="2018-12-14T16:19:24.867" Score="3" Body="&lt;p&gt;You can do this with eval:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let S = '[''123'', ''456'', ''789'']'&#xA;let L = eval(S)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Generally, using &lt;code&gt;eval&lt;/code&gt; is something you should be wary of. Don't run it on untrusted data. But this does solve your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's possible there's a completely different approach you should be using, but without context, it's hard to say.&lt;/p&gt;&#xA;" OwnerUserId="8233" LastActivityDate="2018-12-14T16:19:24.867" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18284" PostTypeId="1" CreationDate="2018-12-15T00:32:51.067" Score="0" ViewCount="63" Body="&lt;p&gt;In insert mode &lt;code&gt;&amp;lt;c-e&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-y&amp;gt;&lt;/code&gt; copy a character at a time from the above line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I generally use these when working with aligned bits of text inside a program and want to copy to the end of the line more often than anything else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I've been using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-e&amp;gt; &amp;lt;esc&amp;gt;lj&quot;py$hk&quot;pp`[&#xA;inoremap &amp;lt;c-y&amp;gt; &amp;lt;esc&amp;gt;lk&quot;py$hj&quot;pp`[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and a slightly better version to that doesn’t stop executing at the &lt;code&gt;h&lt;/code&gt; when running at the 0th column.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-e&amp;gt; &amp;lt;c-o&amp;gt;:stopinsert&amp;lt;cr&amp;gt;j&quot;py$kv&quot;pp`[&#xA;inoremap &amp;lt;c-y&amp;gt; &amp;lt;c-o&amp;gt;:stopinsert&amp;lt;cr&amp;gt;k&quot;py$jv&quot;pp`[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'm not thrilled with either of those bindings since it clobbers a named register, seems dependent on &lt;code&gt;set virtualedit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simpler/more elegant way to copy the trailing portion of the above line?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2018-12-15T02:25:25.527" LastActivityDate="2018-12-15T02:25:25.527" Title="i&lt;c-e&gt; and i&lt;c-y&gt; copy to end of line" Tags="|insert-mode|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18285" PostTypeId="1" CreationDate="2018-12-15T09:40:24.467" Score="0" ViewCount="483" Body="&lt;p&gt;I want to write the contents of a buffer with &lt;code&gt;writefile()&lt;/code&gt;.  However I do not want to use binary mode because I suspect it has (undocumented) side effects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question concerns noeol files, i.e. files whose last line isn't terminated by an EOL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I set the &lt;code&gt;nofixeol&lt;/code&gt; option, open a noeol file, and write it with &lt;code&gt;:w&lt;/code&gt;, Vim writes the file as-is, i.e. without adding an EOL to the last line.  This is what I expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if I use &lt;code&gt;writefile()&lt;/code&gt; instead of &lt;code&gt;:w&lt;/code&gt;, Vim does add an EOL to the last line despite &lt;code&gt;nofixeol&lt;/code&gt;.  This isn't what I expect or want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:w&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo -n abc &amp;gt; foo&#xA;$ vim --cmd 'set nofixeol' foo&#xA;:wq bar&#xA;$ od -c bar&#xA;0000000    a   b   c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;writefile()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ echo -n abc &amp;gt; foo&#xA;$ vim --cmd 'set nofixeol' foo&#xA;:call writefile(getline(1,'$'), 'bar')&#xA;:q&#xA;$ od -c bar&#xA;0000000    a   b   c  \n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to use &lt;code&gt;writefile()&lt;/code&gt; on noeol files so it doesn't add an EOL to the last line (avoiding binary mode)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, what side effects does binary mode have?  For one thing it adjusts &lt;code&gt;expandtab&lt;/code&gt;, according to &lt;code&gt;:h edit-binary&lt;/code&gt;.  What else might it do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2018-12-17T03:36:52.847" Title="How to get writefile() to pay attention to &amp;nofixeol?" Tags="|vimscript|save|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18286" PostTypeId="1" CreationDate="2018-12-15T09:51:52.653" Score="0" ViewCount="705" Body="&lt;p&gt;I have these lines in a script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; go to start of file and search until the end&#xA;call cursor([1,1])&#xA;let moreLinesToGo = v:true&#xA;let b:qtags = []&#xA;&#xA;while (moreLinesToGo)&#xA;  &quot; search for lines like &quot;:344f:&quot;, &quot;:2:&quot;, &quot;:234hello:&quot;&#xA;  let lineWithTag = search('^:\d\{1,4\}\a*:$')&#xA;&#xA;  if lineWithTag == 0&#xA;    let moreLinesToGo = v:false&#xA;  else&#xA;    let qtag = getbufline(bufname('.'), lineWithTag)&#xA;    &quot; put only the numbers into b:qtags, e.g. &quot;344&quot;, &quot;2&quot;, &quot;234&quot;&#xA;    let b:qtags += [matchstr(qtag, '\d\+')]&#xA;  endif&#xA;&#xA;endwhile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What happens that when I execute this file, &quot;:344f:&quot; is put into the list. However when I execute it manually (in cmdline mode), I get &quot;344&quot;.&#xA;How can this happen? '\d+' seems to match everything??&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2018-12-17T03:39:48.320" Title="matchstr() acts differently when used in script?" Tags="|vimscript|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18288" PostTypeId="2" ParentId="18281" CreationDate="2018-12-15T10:11:38.813" Score="2" Body="&lt;p&gt;I build my own Vim (Version 8.1) from the sources and install it to a custom directory. The build is with feature &quot;huge&quot;, so a lot of features are compiled in. This installs around 37 MB (including runtime files, help files, man page in different languages, ...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you install from deb packages it depends on the packages you install. Installing the package &quot;vim&quot; would also install the dependencies &quot;vim-common&quot; and &quot;vim-runtime&quot;. This gives you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; apt show vim vim-common vim-runtime | grep Installed-Size:&#xA;Installed-Size: 2.458 kB&#xA;Installed-Size: 377 kB&#xA;Installed-Size: 27,5 MB&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this is on Ubuntu 16.04 and the installed version of Vim is 7.4. Check on your own machine.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2018-12-15T10:11:38.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18289" PostTypeId="2" ParentId="18286" CreationDate="2018-12-15T11:07:29.820" Score="3" Body="&lt;p&gt;The problem is that &lt;code&gt;getbufline(...)&lt;/code&gt; returns a list of lines. In your case the list only contains one element. Then the second to last line from &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#matchstr%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help matchstr()&lt;/code&gt;&lt;/a&gt; is important:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When {expr} is a List then the matching item is returned.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;let qtag = getline(lineWithTag)&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another idea:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:myTags=map(filter(getline(1, line('$')), { idx, val -&amp;gt; match(val, '^:\d\{1,4\}\a*:$') &amp;gt;= 0 } ), { idx, val -&amp;gt; matchstr(val, '\d\+')})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;getline(1, line('$'))&lt;/code&gt; returns a list containing all lines in the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;filter(...)&lt;/code&gt; filters the list with the given lambda&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;map(...)&lt;/code&gt; maps the entries to only contain the matched digits.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="205" LastEditDate="2018-12-17T03:39:48.320" LastActivityDate="2018-12-17T03:39:48.320" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18290" PostTypeId="1" AcceptedAnswerId="18292" CreationDate="2018-12-15T11:50:23.927" Score="1" ViewCount="105" Body="&lt;p&gt;I can’t find how to save &lt;code&gt;modifiable&lt;/code&gt; and &lt;code&gt;readonly&lt;/code&gt; states with &lt;code&gt;:mksession&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it even possible?&lt;/p&gt;&#xA;" OwnerUserId="20213" LastActivityDate="2018-12-15T19:12:56.443" Title="How to save modifiable and readonly states in session file?" Tags="|sessions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18292" PostTypeId="2" ParentId="18290" CreationDate="2018-12-15T19:05:16.310" Score="0" Body="&lt;p&gt;Did you look at the help for &lt;code&gt;:mksession&lt;/code&gt;? There it mentions an option &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;sessionoptions&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'sessionoptions&lt;/code&gt;'&lt;/a&gt; and if you read that help section you'll see there are various values that dictate what kind of information &lt;code&gt;:mksession&lt;/code&gt; saves. In your case you need the &lt;em&gt;options&lt;/em&gt; value:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;options&lt;/em&gt;  : all options and mappings (also global values for local options)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(I tested it with your two examples, &lt;code&gt;'modifiable'&lt;/code&gt; and &lt;code&gt;'readonly'&lt;/code&gt;, fyi.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set sessionoptions+=options&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's odd, though, is that &lt;em&gt;options&lt;/em&gt; is one of the defaults (along with &lt;em&gt;blank, buffers, curdir, folds, help, tabpages&lt;/em&gt; and &lt;em&gt;winsize&lt;/em&gt;). Is &lt;code&gt;'sessionsoptions'&lt;/code&gt; (or &lt;code&gt;'ssop'&lt;/code&gt;) getting modified in your vimrc or something?&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-12-15T19:12:56.443" LastActivityDate="2018-12-15T19:12:56.443" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="18293" PostTypeId="2" ParentId="18249" CreationDate="2018-12-15T19:09:30.463" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://majutsushi.github.io/tagbar/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tagbar&lt;/a&gt; can help to navigate through a large number of functions in one single file. Among other features, it supports sorting by name or line number, which I find very helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;marks&lt;/code&gt; can also be a great help in navigating back and forth in a large file. See &lt;code&gt;:h marks&lt;/code&gt; or &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#mark&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/motion.html#mark&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you see the need to constantly jump between multiple (large) files, &lt;a href=&quot;https://github.com/vim-scripts/gtags.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gtags&lt;/a&gt; might help you in finding definitions/references across the project.&lt;/p&gt;&#xA;" OwnerUserId="20098" LastActivityDate="2018-12-15T19:09:30.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18295" PostTypeId="1" AcceptedAnswerId="18298" CreationDate="2018-12-15T19:20:13.323" Score="6" ViewCount="4886" Body="&lt;h1&gt;How to set a colorscheme that still shows spelling errors?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I am looking for two combined effects that I can acquire separately but not yet together. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Set Colorscheme alone: OK&lt;/strong&gt;. If I want highlights on spelling mistakes I can use a &lt;code&gt;.vimrc&lt;/code&gt; file with this single line: &lt;code&gt;set spell&lt;/code&gt;. So if I write a mwe file (mwe.vim) with a name in it as text content: John Morelock. Then the result is that vim recognizes John as a proper word, and does not highlight it, but then &lt;em&gt;does&lt;/em&gt; properly highlight the last name. All OK up to here.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Set Spelling alone: OK&lt;/strong&gt;. As another task I would like to add a colorscheme, for example &lt;code&gt;solarized&lt;/code&gt;. So I set &lt;code&gt;colorscheme solarized&lt;/code&gt; as a single line in the &lt;code&gt;.vimrc&lt;/code&gt;. All fine here. I open up the same previous file, and it shows the file with specific colorscheme. If I put both lines together, setting colors and spelling, all is OK here. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Set Colorscheme and Spelling together: not always OK&lt;/strong&gt;. The issue is that both previous procedures working together works under certain circumstances, such as with the mentioned &lt;code&gt;colorscheme solarized&lt;/code&gt;, but not with another half of colors, at least in my specific case. I would like, for instance to use &lt;code&gt;colorscheme adrian&lt;/code&gt; with spelling, but as soon as I use these two together, all of it stops working. To make &lt;code&gt;adrian&lt;/code&gt;work, the colorscheme line alone is not enough. Instead I have to add the line `set termguicolors', but this may be cancelling out my spelling to not show.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;One hack is to &lt;a href=&quot;https://vi.stackexchange.com/questions/8751/how-to-completely-turn-off-colorscheme&quot;&gt;eliminate schemecolors and fiddle with my terminal colors&lt;/a&gt;. Useful, but still my ideal solution would be to be able to choose colorschemes: adrian, matrix, onedark, or whatever. However, I would point out that many people seem to be asking questions about how to set coloring and highlights, so I would ask both a specific and a general question. I have browsed extensively, both in &lt;code&gt;:h colorscheme&lt;/code&gt; and &lt;em&gt;StackExchange&lt;/em&gt;. Where should one prioritize a search to begin solving this simple problem? &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Where could I start looking for my specific problem? Both via web, and my pc.&lt;/h3&gt;&#xA;&#xA;&lt;h3&gt;How to set good practices for setting colors, spelling and in general?&lt;/h3&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: I should add that I am not being able to use the &lt;code&gt;adrian&lt;/code&gt; colorscheme with &lt;a href=&quot;https://www.cyberciti.biz/faq/turn-on-or-off-color-syntax-highlighting-in-vi-or-vim/&quot; rel=&quot;noreferrer&quot;&gt;a single line invocation of setting colorscheme&lt;/a&gt;. To make it valid I have to add an extra line such as &lt;code&gt;set termguicolors&lt;/code&gt; but this does &lt;em&gt;not&lt;/em&gt; keep the spelling working properly.&lt;/p&gt;&#xA;" OwnerUserId="12815" LastEditorUserId="12815" LastEditDate="2018-12-15T19:41:23.703" LastActivityDate="2019-09-11T12:53:23.183" Title="How to set a colorscheme that still shows spelling errors?" Tags="|vimrc|syntax-highlighting|terminal|colorscheme|spell-checking|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18296" PostTypeId="2" ParentId="18285" CreationDate="2018-12-15T19:50:48.567" Score="2" Body="&lt;p&gt;The word &lt;em&gt;binary&lt;/em&gt; here may be &quot;scaring&quot; you more than it should. The flag, the command line argument (&lt;code&gt;-b&lt;/code&gt;)  and the &lt;code&gt;'binary'&lt;/code&gt; option are closely related and have nothing to do with binary files except for setting up Vim so as to avoid accidentally corrupting such files. You can use them with non-binary files, too, if so inclined. It just disables certain options that can (possibly transparently) modify text/formatting. E.g. looking at &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#&amp;#39;bin&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'bin'&lt;/code&gt;&lt;/a&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'textwidth'  will be set to 0&#xA;'wrapmargin' will be set to 0&#xA;'modeline'   will be off&#xA;'expandtab'  will be off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Plus, &lt;code&gt;'fileformat'&lt;/code&gt; and &lt;code&gt;'fileformats'&lt;/code&gt; are disabled while reading files to prevent conversion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than causing the side effects you mention this state is meant to prevent them. So if you're just avoiding it because of such concerns my suggestion is to go ahead and use the &lt;code&gt;writefile()&lt;/code&gt; &quot;b&quot; flag...it will prevent any unexpected edits from occurring as the file is written.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="205" LastEditDate="2018-12-17T03:36:52.847" LastActivityDate="2018-12-17T03:36:52.847" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18297" PostTypeId="1" CreationDate="2018-12-16T00:42:26.560" Score="3" ViewCount="115" Body="&lt;p&gt;I'd like to see where page breaks are going to occur when I print (either using &lt;code&gt;:hardcopy&lt;/code&gt; or &lt;code&gt;a2ps&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something analogous to &lt;code&gt;:set colorcolumn=78&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Except that the line count should get reset if a &lt;code&gt;^L&lt;/code&gt; (formfeed character) is encountered.&lt;/p&gt;&#xA;" OwnerUserId="20216" LastEditorUserId="21062" LastEditDate="2019-08-08T15:38:41.303" LastActivityDate="2019-08-08T15:38:41.303" Title="Can vim mark (highlight) page breaks?" Tags="|printing|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18298" PostTypeId="2" ParentId="18295" CreationDate="2018-12-16T10:43:06.047" Score="8" Body="&lt;p&gt;I'm going to take a stab in the dark and suggest that your configuration is probably resulting in no highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check this with the command &lt;code&gt;:verbose highlight SpellBad&lt;/code&gt;: if the &lt;code&gt;xxx&lt;/code&gt; at the start of the line is not highlighted, then badly spelled words won't be highlighted, either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is the problem, then spelling &lt;em&gt;commands&lt;/em&gt; should still work correctly: you should still be able to jump to the next and previous error with &lt;code&gt;]s&lt;/code&gt; and &lt;code&gt;[s&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can fix this by setting the highlighting yourself. You can simply add &lt;code&gt;:highlight&lt;/code&gt; commands to your &lt;code&gt;vimrc&lt;/code&gt;, but a better way is probably to use a &lt;code&gt;ColorScheme&lt;/code&gt; autocommand. e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup my_colours&#xA;  autocmd!&#xA;  autocmd ColorScheme adrian hi SpellBad cterm=reverse&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put this before the &lt;code&gt;colorscheme&lt;/code&gt; line in your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :highlight&lt;/code&gt; and &lt;code&gt;:help ColorScheme&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-12-16T11:27:36.167" LastActivityDate="2018-12-16T11:27:36.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18299" PostTypeId="1" CreationDate="2018-12-16T10:58:47.650" Score="3" ViewCount="2563" Body="&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#undercurl&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help undercurl&lt;/code&gt;&lt;/a&gt; states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;undercurl&quot; is a curly underline. &lt;strong&gt;&lt;em&gt;When &quot;undercurl&quot; is not possible then &quot;underline&quot; is used.&lt;/em&gt;&lt;/strong&gt; In general &quot;undercurl&quot; and &quot;strikethrough&quot; is only available in the GUI.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But if I run Vim with &lt;code&gt;vim --clean&lt;/code&gt; and then issue the following commands, then the text &lt;code&gt;curl&lt;/code&gt; is not highlighted in any way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi Curl cterm=undercurl&#xA;:match Curl /curl/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I change &lt;code&gt;undercurl&lt;/code&gt; to &lt;code&gt;underline&lt;/code&gt;, then &lt;code&gt;curl&lt;/code&gt; is now underlined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi Curl cterm=underline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is the documentation wrong? Or am I just misinterpreting it?*&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is the problem that Vim thinks that undercurl &lt;em&gt;is&lt;/em&gt; possible and is therefore (unsuccessfully) attempting to use it? If this is the case, then what causes this? &lt;code&gt;:set t_Cs?&lt;/code&gt; and &lt;code&gt;:set t_Ce?&lt;/code&gt; both report that the settings are not set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t_Cs=&#xA;t_Ce=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm running Vim 8.0.1420 inside iTerm2 v3.2.6 on macOS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* It &lt;em&gt;could&lt;/em&gt; be read to mean that there are some circumstances when undercurl is &lt;em&gt;available&lt;/em&gt; but isn't &lt;em&gt;possible&lt;/em&gt; and only in those cases will it be replaced with an underline.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="205" LastEditDate="2018-12-17T03:36:01.827" LastActivityDate="2018-12-17T03:36:01.827" Title="Why doesn't undercurl use underline in my terminal?" Tags="|syntax-highlighting|terminal|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18300" PostTypeId="2" ParentId="18299" CreationDate="2018-12-16T11:23:12.850" Score="3" Body="&lt;p&gt;Looks like this is &lt;a href=&quot;https://github.com/vim/vim/issues/2424&quot; rel=&quot;nofollow noreferrer&quot;&gt;just a bug&lt;/a&gt;, which was fixed just after the version I'm using, in &lt;a href=&quot;https://github.com/adizero/vim/commit/2fe5a21852705932719e6b7acd80c1b275103797&quot; rel=&quot;nofollow noreferrer&quot;&gt;patch 8.0.1422&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-12-16T21:52:52.427" LastActivityDate="2018-12-16T21:52:52.427" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18301" PostTypeId="1" CreationDate="2018-12-16T15:41:22.853" Score="2" ViewCount="245" Body="&lt;p&gt;When I open the vim in the xterm (ubuntu) there's always a space on the right and bottom part of terminal which is not fully occupied by the vim. What could be the reason behind it? And what are the solutions for this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Those violet area on the right and bottom of the vim are the area from the terminal.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/z4Mqp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/z4Mqp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20218" LastEditorUserId="20218" LastEditDate="2018-12-17T00:07:12.097" LastActivityDate="2018-12-17T07:44:41.700" Title="Occupy the remaining space in terminal" Tags="|terminal|linux-ubuntu|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18302" PostTypeId="1" CreationDate="2018-12-16T19:18:28.767" Score="1" ViewCount="105" Body="&lt;p&gt;I have to change strings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;fetchrandomData&lt;/code&gt; to &lt;code&gt;fetchReportingData&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;FETCH_RANDOM_DATA&lt;/code&gt; to &lt;code&gt;FETCH_REPORTING_DATA&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I can change &lt;code&gt;ca_z&lt;/code&gt; and &lt;code&gt;CA_Z&lt;/code&gt; to &lt;code&gt;ca_t&lt;/code&gt; and &lt;code&gt;CA_T&lt;/code&gt; respectively with command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%s/\v([Cc])([Az])(_)?([Tt])/\1\2\3\4/gci&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a string with 3 or more characters this method seems unfeasible, let alone for string &lt;code&gt;FETCH_RANDOM_DATA&lt;/code&gt; of length 17 characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is more a feasible way to do something like this in vim?&lt;/p&gt;&#xA;" OwnerUserId="18304" LastEditorUserId="18304" LastEditDate="2018-12-16T20:00:36.983" LastActivityDate="2018-12-16T20:00:36.983" Title="search and replace: remember case in substitute" Tags="|regular-expression|substitute|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18304" PostTypeId="2" ParentId="18301" CreationDate="2018-12-17T07:44:41.700" Score="1" Body="&lt;p&gt;That is the default behaviour. The reason is, Vim can only show complete character cells, however if your terminal is slightly bigger that what can be displayed by multiples of character cells, it will show such a frame. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is nothing you can do about it, but you can slightly resize your terminal. &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-12-17T07:44:41.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18306" PostTypeId="1" AcceptedAnswerId="18307" CreationDate="2018-12-17T13:15:25.073" Score="0" ViewCount="28" Body="&lt;p&gt;Run &lt;code&gt;vim --clean&lt;/code&gt;, &lt;code&gt;:nnoremap K ko&lt;/code&gt;, and press &lt;code&gt;K&lt;/code&gt; -&gt; Nothing happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run &lt;code&gt;vim --clean&lt;/code&gt; and press &lt;code&gt;ko&lt;/code&gt; -&gt; Vim enters insert mode on second line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I know about big-&lt;code&gt;O&lt;/code&gt;, this is just out of curiousity, it appeared in debugging a more complicated map)&lt;/p&gt;&#xA;" OwnerUserId="18613" LastActivityDate="2018-12-17T14:31:12.390" Title="Why does `nnoremap K ko` not work on first line" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18307" PostTypeId="2" ParentId="18306" CreationDate="2018-12-17T14:31:12.390" Score="2" Body="&lt;p&gt;This happens, because a macro usually aborts, if not all of the typed keys work. In your case, the &lt;code&gt;k&lt;/code&gt; in the first line is an error, so the macro won't try to run the &lt;code&gt;o&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-12-17T14:31:12.390" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18308" PostTypeId="1" CreationDate="2018-12-17T14:49:01.940" Score="0" ViewCount="3414" Body="&lt;p&gt;If I use &lt;code&gt;set cursorline&lt;/code&gt;, then lines that have some background color set (like in quickfix windows in vimtex) lose that color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I prevent that? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: In the first picture, the cursor is on the second line of the quickfix window. Then I press &lt;code&gt;k&lt;/code&gt; to go to the first line and the yellow highlighting disappears.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7mKzQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7mKzQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mx9HV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mx9HV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18613" LastEditorUserId="18613" LastEditDate="2018-12-18T08:22:20.040" LastActivityDate="2018-12-18T10:16:58.163" Title="How do I use `set cursorline` but keep background color highlights e.g. in quickfix window" Tags="|cursorline|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18309" PostTypeId="1" CreationDate="2018-12-17T15:04:28.840" Score="1" ViewCount="124" Body="&lt;p&gt;Based on the accepted answer  &lt;a href=&quot;https://vi.stackexchange.com/questions/18029/get-immediate-feedback-about-a-search-string-with-no-matches-in-vim&quot;&gt;to this previous question&lt;/a&gt;, I put the code below in my &lt;code&gt;.vimrc&lt;/code&gt;, which changes the color of my statusline depending on whether my search (started with &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;) yields results or not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I don't understand vimscript, so I cannot fix a simple problem with this code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I press &lt;code&gt;/&lt;/code&gt; and then immediately cancel the search with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, the cursor jumps to the first match of whatever previous search term was used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, assume I do &lt;code&gt;/foo&amp;lt;CR&amp;gt;&lt;/code&gt;. I move around for a while and think I want to search again, press &lt;code&gt;/&lt;/code&gt; but then remember I need to fix something where I am and press &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. This takes me back to &lt;code&gt;foo&lt;/code&gt; instead of leaving me where I was.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with the code is also apparent in the fact that the status line immediately turns red or green when I press &lt;code&gt;/&lt;/code&gt;, depending on whether the previous search was successful or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I change the code to 'forget' about the previous search? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Define an autocmd to call the HighLightSearch function when we enter the search command line&#xA;function! HighlightSearch(timer)&#xA;    &quot; When it is the first call to the function we save the current status of&#xA;    &quot; the StatusLine HL group so that we can restore it when we are done searching&#xA;    if (g:firstCall)&#xA;        let g:originalStatusLineHLGroup = execute(&quot;hi StatusLine&quot;)&#xA;        let g:firstCall = 0&#xA;    endif&#xA;&#xA;    if (exists(&quot;g:searching&quot;) &amp;amp;&amp;amp; g:searching)&#xA;        &quot; The variable g:searching is set to 1, we are in the search command line&#xA;        &quot; make the highlighting and call the function again after a delay&#xA;        let searchString = escape(getcmdline(), ' \')&#xA;        let newBG = search(searchString) != 0 ? &quot;green&quot; : &quot;red&quot;&#xA;        execute(&quot;hi StatusLine ctermfg=&quot; . newBG)&#xA;        let g:highlightTimer = timer_start(300, 'HighlightSearch')&#xA;    else&#xA;        &quot; The variable g:searching is either not set or set to 0, we stopped searching&#xA;        &quot; restore the hightlighting and stop calling the function&#xA;        let originalBG = matchstr(g:originalStatusLineHLGroup, 'ctermfg=\zs[^ ]\+')&#xA;        execute(&quot;hi StatusLine ctermfg=&quot; . originalBG)&#xA;&#xA;        if exists(&quot;g:highlightTimer&quot;)&#xA;            call timer_stop(g:highlightTimer)&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&quot; And a second one to stop the function when we are done searching&#xA;augroup betterSeachHighlighting&#xA;    autocmd!&#xA;    autocmd CmdlineEnter * if (index(['?', '/'], getcmdtype()) &amp;gt;= 0) | let g:searching = 1 | let g:firstCall = 1 | call timer_start(1, 'HighlightSearch') | endif&#xA;    autocmd CmdlineLeave * let g:searching = 0&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18613" LastEditorUserId="18613" LastEditDate="2018-12-17T17:45:30.587" LastActivityDate="2020-01-13T14:21:00.773" Title="How do I make this vimscript function (taken from another question here) 'forget' about a previous search term?" Tags="|vimscript|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18310" PostTypeId="1" AcceptedAnswerId="18340" CreationDate="2018-12-17T15:44:00.387" Score="3" ViewCount="515" Body="&lt;p&gt;Can I setup &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; to keep the relative cursor position?&#xA;For example, assuming the line is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def fun(&amp;lt;cursor&amp;gt;):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can I make &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; result in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    def fun(&amp;lt;cursor&amp;gt;):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously, with &lt;code&gt;set startofline&lt;/code&gt;, the cursor goes to the beginning of the line after indenting. &#xA;But even with  &lt;code&gt;set nostartofline&lt;/code&gt;, the cursor moves erratically,  and changes both its relative position within the line as well as its absolute position in the line, depending on how the line looks like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tiPkn.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tiPkn.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18613" LastEditorUserId="18613" LastEditDate="2018-12-19T10:36:33.140" LastActivityDate="2018-12-19T13:06:37.987" Title="Keep relative cursor position after indenting with &gt;&gt;" Tags="|indentation|cursor-movement|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18311" PostTypeId="2" ParentId="18309" CreationDate="2018-12-17T18:05:24.627" Score="0" Body="&lt;pre&gt;&lt;code&gt;if searchString != &quot;&quot;&#xA;    let newBG = search(searchString) != 0 ? &quot;green&quot; : &quot;red&quot;&#xA;    execute(&quot;hi StatusLine ctermfg=&quot; . newBG)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation: It seems vim's &lt;code&gt;search&lt;/code&gt; function is the culprit (note that the function in question continuously runs vim's &lt;code&gt;search&lt;/code&gt; to update the color of the statusline). It automatically uses the previous search term if nothing is entered. This can be tested in a clean vim:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;vim --clean&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ia&amp;lt;CR&amp;gt;b&amp;lt;CR&amp;gt;a&amp;lt;esc&amp;gt;&lt;/code&gt; (enter three lines, each with a single letter, end at third line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/a&amp;lt;CR&amp;gt;&lt;/code&gt; (jumps to first line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&amp;lt;CR&amp;gt;&lt;/code&gt; (jumps to third line, because it uses the search term &lt;code&gt;a&lt;/code&gt;) &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;WARNING:&#xA;This introduces another problem: The hlsearch-highlight skips one match now. What is highlighted before pressing Enter is not the closed match (which is what the search actually ends up presenting at pressing Enter).&lt;/p&gt;&#xA;" OwnerUserId="18613" LastEditorUserId="18613" LastEditDate="2018-12-18T15:32:04.340" LastActivityDate="2018-12-18T15:32:04.340" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18312" PostTypeId="1" CreationDate="2018-12-17T18:49:29.990" Score="2" ViewCount="679" Body="&lt;p&gt;This ~/.vimrc excerpt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('syntastic')&#xA;    let g:syntastic_sh_shellcheck_args=&quot;-x&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is always false. What is the correct condition to check?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('*syntastic*')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without conditional code in vimrc it becomes non-portable and I get errors like this;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; vim .vimrc&#xA;Error detected while processing /root/.vimrc:&#xA;line    7:&#xA;E185: Cannot find color scheme 'PaperColor'&#xA;line   15:&#xA;E117: Unknown function: pathogen#infect&#xA;E15: Invalid expression: pathogen#infect()&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from a .vimrc like this;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax enable&#xA;set number&#xA;set laststatus=2&#xA;set background=dark&#xA;set foldmethod=syntax&#xA;let g:PaperColor_Theme_Options = {'theme':{'default.dark':{'transparent_background':1}}}&#xA;colorscheme PaperColor&#xA;if has('cmdline_info')&#xA;    set ruler&#xA;    set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%)&#xA;    set showcmd&#xA;    set hlsearch&#xA;endif&#xA;&#xA;execute pathogen#infect()&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_auto_loc_list = 1&#xA;let g:syntastic_check_on_open = 1&#xA;autocmd VimEnter * redraw!&#xA;let g:syntastic_check_on_wq = 0&#xA;let g:syntastic_java_javac_config_file_enabled = 1&#xA;let g:syntastic_sh_shellcheck_args=&quot;-x&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17479" LastEditorUserId="17479" LastEditDate="2018-12-18T13:14:38.773" LastActivityDate="2019-01-17T14:03:10.623" Title="vimrc if syntastic use" Tags="|vimrc|plugin-syntastic|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18313" PostTypeId="1" AcceptedAnswerId="18330" CreationDate="2018-12-17T21:39:33.567" Score="0" ViewCount="613" Body="&lt;p&gt;For some markup and programming languages I use VIM and the usual procedure for me checking if my code works is &lt;code&gt;:w&lt;/code&gt; and &lt;code&gt;!&amp;lt;compile&amp;gt;&lt;/code&gt;. Depending on the filetype &lt;code&gt;&amp;lt;compile&amp;gt;&lt;/code&gt; can be very different programs, for example &lt;code&gt;pdflatex %&lt;/code&gt; for .tex files, &lt;code&gt;cargo run&lt;/code&gt; for rust code or simply a general &lt;code&gt;make&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to define a shortcut (e.g. &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Enter&lt;/kbd&gt;) for VIM to safe the currently open file and compile the project dependent on the filetype opened?&lt;/p&gt;&#xA;" OwnerUserId="19395" LastActivityDate="2019-01-22T13:50:11.150" Title="set shortcut depending on filetype" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="2" ClosedDate="2019-01-19T18:54:08.907" ContentLicense="CC BY-SA 4.0" />
  <row Id="18315" PostTypeId="1" CreationDate="2018-12-18T00:22:09.830" Score="4" ViewCount="1499" Body="&lt;p&gt;I am trying to get ranger working inside neovim in a sensible way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/ranger/ranger/blob/master/examples/vim_file_chooser.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;official vim plugin provided by ranger&lt;/a&gt; works perfectly in ordinary vim: &lt;code&gt;&amp;lt;Leader&amp;gt;r&lt;/code&gt; launches ranger in full screen, &lt;code&gt;q&lt;/code&gt; exits ranger without changing the opened buffers, and it respects tabs and windows. However, when I try to use it with neovim, ranger fails to even launch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/airodactyl/neovim-ranger&quot; rel=&quot;nofollow noreferrer&quot;&gt;This plugin&lt;/a&gt; from the neovim &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Related-projects&quot; rel=&quot;nofollow noreferrer&quot;&gt;related projects&lt;/a&gt; works... somewhat. After evaluating &lt;code&gt;:edit .&lt;/code&gt;, ranger launches in full screen, but there are several problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Before ranger becomes interactive, you have to enter insert mode.&lt;/li&gt;&#xA;&lt;li&gt;It displays the vim line numbers (if enabled), which is ugly.&lt;/li&gt;&#xA;&lt;li&gt;When you open a file or exit ranger with &lt;code&gt;q&lt;/code&gt;, you're greeted with a terminal with &lt;code&gt;[Process exited 0]&lt;/code&gt; which you must dismiss every time.&lt;/li&gt;&#xA;&lt;li&gt;It doesn't respect your windows or tabs at all. I experimented with various combinations of windows and tabs and exiting ranger either by opening a file or with &lt;code&gt;q&lt;/code&gt; and couldn't see any rhyme or reason as to what state your windows and tabs would be in afterward.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Finally I tried and got the furthest with &lt;a href=&quot;https://github.com/Mizuchi/vim-ranger/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this plugin&lt;/a&gt;, of which the previous plugin is a fork. Again, you launch ranger with &lt;code&gt;:edit .&lt;/code&gt;, but it is immediately interactive without needing to enter insert mode, which is nice. It also respects tabs and windows. I swear I had to &lt;code&gt;let g:ranger_open_mode = 'edit'&lt;/code&gt; to get that to work, but I have it set to &lt;code&gt;tabe&lt;/code&gt; (the default) right now and it seems to be working. There are still some problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It also displays the undesired vim line numbers while ranger is active.&lt;/li&gt;&#xA;&lt;li&gt;It does not launch ranger in full screen, but inside whatever window it was launched from.&lt;/li&gt;&#xA;&lt;li&gt;Whenever you launch ranger, it launches in a buffer with a name like &lt;code&gt;&quot;term://.//24736:ranger --choosefiles=/tmp/nvimLMWwKJ/2 '/path/to/current/working/directory'&quot;&lt;/code&gt;. Each subsequent time ranger is launched, the integer at the end of the &lt;code&gt;--choosefiles&lt;/code&gt; path is incremented. This name is visible while ranger is launched (ugly), but once a file is opened the buffer is made hidden and unmodifiable and its contents are changed to &lt;code&gt;[Process exited 0]&lt;/code&gt;. It's annoying that these buffers are created and not cleaned up every time ranger is launched, but the worst part is that when ranger is exited using &lt;code&gt;q&lt;/code&gt;, rather than returning the window to whatever buffer it previously had displayed, it displays the alternate buffer, which is one of these annoying terminals buffers.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've tried several things to fix this last deficiency to no avail. Some close misses:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;let g:ranger_on_exit = 'bw!'&lt;/code&gt; causes ranger to launch in the current window, but closes that window when you exit ranger and displays the new file (if any) in the window displaying the alternate buffer.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;let g:ranger_on_exit = 'bnext'&lt;/code&gt; seems to work as intended when opening a file with ranger, but exiting ranger &lt;code&gt;q&lt;/code&gt; disturbs the active window undesirably.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to either get the first plugin working in neovim or getting one of the other plugins to replicate its functionality?&lt;/p&gt;&#xA;" OwnerDisplayName="user20228" LastActivityDate="2022-07-08T01:13:01.650" Title="Integrating ranger into neovim" Tags="|vimscript|neovim|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18316" PostTypeId="1" AcceptedAnswerId="19140" CreationDate="2018-12-18T01:30:44.967" Score="0" ViewCount="97" Body="&lt;p&gt;Suppose I have some Python code with a “block comment” (i.e. multiple consecutive comment lines) in the middle of a paragraph:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = function1()&#xA;# Remember: if you pass an even number to function2, your&#xA;# computer will explode.&#xA;b = function2(7)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the cursor is on one of these comment lines and I want to use the &lt;code&gt;gq&lt;/code&gt; command (for example) on just the comment, but not the surrounding lines, I first need to enter linewise visual mode and select the appropriate lines. This can take several keystrokes if the comment is long and the cursor starts out in the middle of it. It would be easier if there were a text object corresponding to the comment. (If the entire paragraph were a comment, I could just type &lt;code&gt;gqap&lt;/code&gt;, for example.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I define a new text object corresponding to the current block comment? I’m defining a block comment as “the longest sequence of consecutive lines that match the regular expression &lt;code&gt;^\s*#&lt;/code&gt;”.&lt;/p&gt;&#xA;" OwnerUserId="671" LastEditorUserId="1292" LastEditDate="2019-01-24T13:03:56.757" LastActivityDate="2019-03-09T00:24:17.900" Title="How can I create a text object for a Python block comment?" Tags="|object-motions|custom-text-object|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18317" PostTypeId="1" CreationDate="2018-12-18T02:59:41.710" Score="1" ViewCount="105" Body="&lt;p&gt;I have set up an autocommand, that makes some changes to the file I'm working on, whenever I save. Everything works nice and dandy, except one thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever I save, and press &lt;code&gt;.&lt;/code&gt; afterwards, or undo some commands with &lt;code&gt;u&lt;/code&gt;, I also undo whatever was done by the  the save autocommand!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to use &lt;code&gt;execute normal&lt;/code&gt; or a similar command, without saving it to the vim history?&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2018-12-18T02:59:41.710" Title="How can I make Vim not remember a command?" Tags="|autocmd|undo-redo|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18319" PostTypeId="2" ParentId="18312" CreationDate="2018-12-18T07:24:14.333" Score="2" Body="&lt;p&gt;The &lt;code&gt;has()&lt;/code&gt;  always checks for features compiled into Vim (e.g. mostly what you can see in the output of &lt;code&gt;:version&lt;/code&gt; with either a &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;-&lt;/code&gt; prepended). It won't work to test for loaded plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would work, is checking if the script loading guards, that usually every well-defined plugin has. For &lt;a href=&quot;https://github.com/vim-syntastic/syntastic&quot; rel=&quot;nofollow noreferrer&quot;&gt;syntastic&lt;/a&gt; this would be the variable &lt;a href=&quot;https://github.com/vim-syntastic/syntastic/blob/master/plugin/syntastic.vim#L15&quot; rel=&quot;nofollow noreferrer&quot;&gt;g:loaded_syntastic_plugin&lt;/a&gt;, so you would need to check:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if get(g:, 'loaded_syntastic_plugin', 0)&#xA;    let g:syntastic_sh_shellcheck_args=&quot;-x&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, there is one gotcha. Usually the vimrc file is loaded before all plugins, to be able to set plugin specific configuration variable before the plugin is active. So this means, even for a Vim that has syntastic installed, the above check wouldn't work (since the plugin hasn't yet set the corresponding &lt;code&gt;loaded_&lt;/code&gt; variable yet).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a couple of ways around it, usually &lt;code&gt;globbing&lt;/code&gt; your runtime path and checking for the syntastic plugin manually. That could be slow however if your vim runtime is on a network path for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also put the check into an &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#VimEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;VimEnter&lt;/a&gt; autocommand which will then evaluate once Vim has started up correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would suggest, getting rid of the check altogether, and simply set the variable whether syntastic is loaded or not. After all, simply setting a global variable won't hurt even if you do not have syntastic installed.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-12-18T07:24:14.333" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18320" PostTypeId="1" CreationDate="2018-12-18T07:40:35.970" Score="1" ViewCount="304" Body="&lt;p&gt;Thank Vim's folding, I can hide irrelevant parts of code/document and work on a small spot of the file. More and more I organize the folded first lines as an outline of the whole file, in each level. Therefore I wonder if I can selectively highlight some text over the appearance of folded parts?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think to modify(overload) the syntax pattern of the group Folded with something like &quot;contains=...&quot; so that some embedded text in the headers can be highlighted differently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I can't get the syntax pattern of Folded with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:syn list Folded&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;, although I can see all the highlight groups for the current file type. (e.g. helpHeader)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I went searching in &lt;code&gt;/usr/share/vim/vim74/syntax/&lt;/code&gt; but in vain. Folded is not defined there. (neither in the neighborhood)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I really have a chance to highlight my fully folded document and make it more interesting? (Vim 8 or future plan?) &lt;/p&gt;&#xA;" OwnerUserId="19850" LastActivityDate="2018-12-18T07:47:48.380" Title="Vim: Is it possible to modify syntax rule of the Folded group?" Tags="|syntax-highlighting|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18321" PostTypeId="2" ParentId="18320" CreationDate="2018-12-18T07:47:48.380" Score="1" Body="&lt;p&gt;No you cannot. The Folded syntax highlighting is a single highlighting group that will apply to all folded text inside your file. You can neither modify it to highlight certain parts of a folded line differently, nor can you make different folds appear in a different style not can you highlight different folds in different buffers differently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the same reason, folded text cannot be syntax highlighted, because basically syntax highlighting rules would have to apply on top of the folded text part and that is simply not possible.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-12-18T07:47:48.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18322" PostTypeId="2" ParentId="13433" CreationDate="2018-12-18T07:49:55.337" Score="3" Body="&lt;p&gt;Add this to your &lt;code&gt;.vimrc&lt;/code&gt; file and you're all set up. This adds files from &lt;code&gt;git diff&lt;/code&gt; to the &lt;code&gt;quick fix&lt;/code&gt; list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:git_status_dictionary = {&#xA;            \ &quot;A&quot;: &quot;Added&quot;,&#xA;            \ &quot;B&quot;: &quot;Broken&quot;,&#xA;            \ &quot;C&quot;: &quot;Copied&quot;,&#xA;            \ &quot;D&quot;: &quot;Deleted&quot;,&#xA;            \ &quot;M&quot;: &quot;Modified&quot;,&#xA;            \ &quot;R&quot;: &quot;Renamed&quot;,&#xA;            \ &quot;T&quot;: &quot;Changed&quot;,&#xA;            \ &quot;U&quot;: &quot;Unmerged&quot;,&#xA;            \ &quot;X&quot;: &quot;Unknown&quot;&#xA;            \ }&#xA;function! s:get_diff_files()&#xA;  let list = map(split(system(&#xA;              \ 'git diff --name-status HEAD'), '\n'),&#xA;              \ '{&quot;filename&quot;:matchstr(v:val, &quot;\\S\\+$&quot;),&quot;text&quot;:s:git_status_dictionary[matchstr(v:val, &quot;^\\w&quot;)]}'&#xA;              \ )&#xA;  call setqflist(list)&#xA;  copen&#xA;endfunction&#xA;&#xA;command! -nargs=0 DiffRev call s:get_diff_files()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-fugitive/issues/132#issuecomment-290644034&quot; rel=&quot;nofollow noreferrer&quot;&gt;Credits&lt;/a&gt;:  slightly edited&lt;/p&gt;&#xA;" OwnerUserId="19908" LastActivityDate="2018-12-18T07:49:55.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18324" PostTypeId="2" ParentId="18308" CreationDate="2018-12-18T10:16:58.163" Score="1" Body="&lt;p&gt;The CursorLine highlighting group defines how the current line will be highlighted, once &lt;code&gt;:set cursorline&lt;/code&gt; is enabled. As you have noticed, it contains an option for setting the background color. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do not want that and basically just want the underlining to take place, I would suggest to change the highlighting group to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi CursorLine cterm=underline term=underline ctermbg=NONE guibg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will set the background color for the gui and the terminal to be transparent (e.g. use the color that is defined by the corresponding syntax highlighting group).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The CursorLine highlighting group is usually set whenever you source a color scheme. To overwrite your custom CursorLine setting, you can use the &lt;code&gt;ColorScheme&lt;/code&gt; autocommand like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au Colorscheme * :hi CursorLine cterm=underline term=underline ctermbg=NONE guibg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will make sure, the CursorLine highlighting will always be redefined even if a color scheme has set it differently.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-12-18T10:16:58.163" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18325" PostTypeId="1" CreationDate="2018-12-18T11:32:37.487" Score="2" ViewCount="538" Body="&lt;p&gt;I looked around for a long time but did not find any solution for that. On my Unix system (Ubuntu), using LaTeX-suite, I need to escape some characters in file names for compilation, say parenthesis (,) and comma ,. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I modified a bit my compilation script following &#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/9141/latex-vim-cannot-compile-files-with-spaces-in-name&quot;&gt;LaTex-vim cannot compile files with spaces in name&lt;/a&gt;&#xA;and now spaces are indeed escaped. The problem is that fnameescape() does not escape commas or parenthesis. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way I could add ( ) and , as new characters to be escaped by that function ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, is there any way I can change my line&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;let mainfname = fnameescape(Tex_GetMainFileName(':p:t'))&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;in compiler.vim to also escape commas and parenthesis ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot !&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; : Here is a temporary solution I found, seems to work but since I'm not an expert it might lead to further problems at some point. For the moment, it worked with the following filename &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;DM8 - Devoir libre (fonctions, probas).tex&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In ftplugin/latex-suite/compiler.vim at line 112 I added the two times three subsitute() lines by hand : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('b:fragmentFile')&#xA;    let mainfname = fnameescape(expand('%:p:t'))&#xA;&#xA;    let mainfname = substitute(mainfname,'(', '\\(','g')&#xA;    let mainfname = substitute(mainfname,')', '\\)','g')&#xA;    let mainfname = substitute(mainfname,',', '\\,','g')&#xA;&#xA;    call Tex_CD(expand('%:p:h'))&#xA;else&#xA;    let mainfname = fnameescape(Tex_GetMainFileName(':p:t'))&#xA;&#xA;    let mainfname = substitute(mainfname,'(', '\\(','g')&#xA;    let mainfname = substitute(mainfname,')', '\\)','g')&#xA;    let mainfname = substitute(mainfname,',', '\\,','g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20230" LastEditorUserId="20230" LastEditDate="2018-12-18T11:47:07.293" LastActivityDate="2018-12-18T13:42:04.783" Title="fnameescape() : add other characters to be escaped (parenthesis, commas etc)" Tags="|filetype-tex|escape|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18326" PostTypeId="2" ParentId="18325" CreationDate="2018-12-18T13:42:04.783" Score="3" Body="&lt;p&gt;I think you're looking for &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#escape%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h escape()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;escape({string}, {chars})               *escape()*&#xA;        Escape the characters in {chars} that occur in {string} with a&#xA;        backslash.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So your line could be something like this (and you can remove the &lt;code&gt;substitute&lt;/code&gt; calls)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mainfname = escape(fnameescape(expand('%:p:t')), '(),')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I still use &lt;code&gt;fnameescape()&lt;/code&gt; because according to &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#fnameescape%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h fnameescape()&lt;/code&gt;&lt;/a&gt; the characters escaped by function are system specific and you probably don't want to maintain that by yourself.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2018-12-18T13:42:04.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18327" PostTypeId="1" AcceptedAnswerId="18329" CreationDate="2018-12-18T13:50:52.970" Score="0" ViewCount="988" Body="&lt;p&gt;The rightmost entry of the status line changes erratically. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reproduce:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;vim --clean&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set number&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&amp;lt;Esc&amp;gt;98.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Press and hold &lt;code&gt;k&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The rightmost entry of the status line first says &lt;code&gt;Bot&lt;/code&gt; and only switches to &lt;code&gt;98%&lt;/code&gt; when I am at line 82. It then keeps decreasing until it reaches &lt;code&gt;1%&lt;/code&gt; at line 7 and then switches to &lt;code&gt;Top&lt;/code&gt; at line 6. If you now press and hold &lt;code&gt;j&lt;/code&gt; to go back, it only switches to &lt;code&gt;1%&lt;/code&gt; at line 19, then increases and reaches &lt;code&gt;Bot&lt;/code&gt; at line 95.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of this depends on the terminal window size. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this behavior desired? If yes, how is the right most entry useful then?&lt;/p&gt;&#xA;" OwnerUserId="18613" LastEditorUserId="18613" LastEditDate="2018-12-18T14:50:36.230" LastActivityDate="2018-12-18T14:52:11.387" Title="Statusline percentage is erratic" Tags="|statusline|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18328" PostTypeId="2" ParentId="18327" CreationDate="2018-12-18T14:37:25.757" Score="1" Body="&lt;p&gt;This percentage doesn't show percent of where the cursor is, but rather buffer view. Like in the docs (from &lt;code&gt;:h 'statusline'&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Percentage through file of displayed window&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note, that this changes when you reach top or bottom of the visible lines in a window, and when that window starts to scroll when you move up or down. It's easier to see when you &lt;code&gt;:set scrolloff=40&lt;/code&gt; (or anything larger then half of lines visible in Vim instance)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;how is right most entry useful then?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I find it usefull with larger files, it shows more or less where you are in the document while travelling across it, or in manuals, since I use Vim as &lt;code&gt;man&lt;/code&gt; viewier.&lt;/p&gt;&#xA;" OwnerUserId="5395" LastActivityDate="2018-12-18T14:37:25.757" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18329" PostTypeId="2" ParentId="18327" CreationDate="2018-12-18T14:52:11.387" Score="4" Body="&lt;p&gt;This information comes from the function &lt;code&gt;get_rel_pos&lt;/code&gt; from the buffer.c of the Vim source file. What it does, it calculates the window position of the current view with respect to the complete buffer content. The function itself is rather short, as you can see:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0HhOB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0HhOB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What it does, it checks the line above the current top window line and below the current bottom window for its values. If there is no line above and below, it will print &lt;code&gt;All&lt;/code&gt;, if there is no line above it will print &lt;code&gt;Top&lt;/code&gt; and if there is not line below it will print &lt;code&gt;Bot&lt;/code&gt; (all of which will might be translated), else it will calculate the percentage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That also means, that using &lt;code&gt;H&lt;/code&gt;, &lt;code&gt;M&lt;/code&gt; and &lt;code&gt;L&lt;/code&gt; for moving the cursor within the current window, won't change the positional info.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-12-18T14:52:11.387" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18330" PostTypeId="2" ParentId="18313" CreationDate="2018-12-18T20:54:06.347" Score="0" Body="&lt;p&gt;Ben and Christian pointed to the important parts of help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give you a example, try this. I just tested it with a simple TeX file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let tex_flavor = 'pdflatex'&#xA;autocmd FileType tex  compiler tex&#xA;&#xA;set autowrite&#xA;map ,c :make %&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets the compiler for TeX. See &lt;code&gt;:help compiler-tex&lt;/code&gt;, there are a few options to set. I just chose &lt;code&gt;tex_flavor&lt;/code&gt;, so pdflatex is run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After loading a tex file, just hit &lt;code&gt;,c&lt;/code&gt; and the file will be saved (because of &lt;code&gt;autowrite&lt;/code&gt;) and &lt;code&gt;:make&lt;/code&gt; is called. This will run pdflatex. For me it just created a dvi file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a different call to &lt;code&gt;:make&lt;/code&gt; for tex files add something like this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType tex map &amp;lt;buffer&amp;gt; ,c :make -draftmode % &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;,c&lt;/code&gt; is mapped different in a text file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Rust: There is a &lt;code&gt;:compiler cargo&lt;/code&gt;, but unfortunately no help file. &lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-22T13:50:11.150" LastActivityDate="2019-01-22T13:50:11.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18331" PostTypeId="1" AcceptedAnswerId="18332" CreationDate="2018-12-18T21:04:23.217" Score="1" ViewCount="163" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/chr4/nginx.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;a syntax highlight plugin&lt;/a&gt; for Nginx files. Its &lt;code&gt;ftdetect&lt;/code&gt; looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.nginx set ft=nginx&#xA;au BufRead,BufNewFile nginx*.conf set ft=nginx&#xA;au BufRead,BufNewFile *nginx.conf set ft=nginx&#xA;au BufRead,BufNewFile */etc/nginx/* set ft=nginx&#xA;au BufRead,BufNewFile */usr/local/nginx/conf/* set ft=nginx&#xA;au BufRead,BufNewFile */nginx/*.conf set ft=nginx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works well with local configuration files, but when I open a file which is outside the list of predefined directories, there is no syntax highlighting, even when the file ends by the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: syntax=nginx ts=4 sw=4 sts=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If, inside vim, I run &lt;code&gt;:setf nginx&lt;/code&gt;, then the syntax is back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I change &lt;code&gt;ftdetect&lt;/code&gt; to be able to benefit from syntax highlighting automatically based on the presence of &lt;code&gt;# vim: syntax=nginx&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="18833" LastActivityDate="2018-12-19T20:38:03.230" Title="How do I make ftdetect rule recognize syntax statement at the end of a file?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18332" PostTypeId="2" ParentId="18331" CreationDate="2018-12-18T21:46:05.277" Score="2" Body="&lt;p&gt;The correct modeline syntax sets options, so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: filetype=nginx ts=4 sw=4 sts=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or the short version &lt;code&gt;ft&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2018-12-19T20:38:03.230" LastActivityDate="2018-12-19T20:38:03.230" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18333" PostTypeId="1" AcceptedAnswerId="18337" CreationDate="2018-12-18T22:23:01.110" Score="2" ViewCount="2493" Body="&lt;p&gt;I want a way in which we can access a history of commands in terminal mode (and Vim/NeoVim's internal command line), just like in a normal bash terminal; i.e. if I press the up key it will scroll through previously executed commands. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently if I press any directional keys in terminal mode, it will close the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any guidance on this would be greatly appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe I have to write a new plugin? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: For :term/:terminal mode, the answer is to Use ConqueTerm from &lt;a href=&quot;https://github.com/lrvick/Conque-Shell&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; repo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: As you can see the above is not the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT (problem solved): I had previously mapped the  key in terminal mode, so that I could exit terminal with a simple keystroke. &lt;/p&gt;&#xA;" OwnerUserId="20231" LastEditorUserId="20231" LastEditDate="2018-12-26T11:10:30.693" LastActivityDate="2018-12-26T11:10:30.693" Title="Commands history for vim commandline and :terminal" Tags="|command-line|terminal|terminal-buffer|command-history|command-line-window|" AnswerCount="1" CommentCount="4" ClosedDate="2018-12-26T16:57:24.163" ContentLicense="CC BY-SA 4.0" />
  <row Id="18334" PostTypeId="1" CreationDate="2018-12-18T23:51:27.967" Score="1" ViewCount="197" Body="&lt;p&gt;I use vim inside tmux over an ssh session and I often run into the issue where the &lt;code&gt;$DISPLAY&lt;/code&gt; variable gets changed, screwing up my copy-paste. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I log in, $DISPLAY gets assigned to something new: &lt;code&gt;localhost:B.0&lt;/code&gt; let's say. When this happens, any open tmux pane still has the old DISPLAY saved &lt;code&gt;localhost:A.0&lt;/code&gt;. Inside tmux that's easy enough to change, just &lt;code&gt;export DISPLAY=localhost:B.0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, any open VIM sessions will also have the old display, &lt;code&gt;localhost:A.0&lt;/code&gt;. Now, I can quit out, change DISPLAY, and reopen vim, but that's a nuisance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to change OS environment variables from inside of vim?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried:&lt;br&gt;&#xA;- Suspending vim, &lt;code&gt;ctr+z&lt;/code&gt;, setting the environment variable and bringing vim back to the foreground, &lt;code&gt;fg&lt;/code&gt;&lt;br&gt;&#xA;- Setting the vim DISPLAY via &lt;code&gt;:let $DISPLAY='localhost:B.0'&lt;/code&gt;&lt;br&gt;&#xA;- Running shell commands from vim &lt;code&gt;:!export DISPLAY=localhost:B.0&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But these don't work. Are there any other options?&lt;/p&gt;&#xA;" OwnerUserId="20233" LastActivityDate="2018-12-18T23:51:27.967" Title="Update OS enviroment variables from inside VIM" Tags="|cut-copy-paste|tmux|ssh|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18335" PostTypeId="1" AcceptedAnswerId="18407" CreationDate="2018-12-19T02:33:43.883" Score="3" ViewCount="1019" Body="&lt;p&gt;I do not mean to let vim check my spell automatically, so please do not tell me to add a &lt;code&gt;autocmd ...&lt;/code&gt; line in my &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created a &lt;code&gt;.md&lt;/code&gt; file and put these contents in it: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;8) good fftowndn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I run the command &lt;code&gt;:setlocal spell!&lt;/code&gt; in the normal mode, but this does not check the wrong spell token of &lt;code&gt;fftowndn&lt;/code&gt; in my contents. However, the spell checking works well if I comment the contents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I make spell checking work with &lt;code&gt;.md&lt;/code&gt; please ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: in other file types such as &lt;code&gt;txt&lt;/code&gt; file, after I run &lt;code&gt;:setlocal spell!&lt;/code&gt;, the error tokens of &lt;code&gt;fftowndn&lt;/code&gt; will be highlighted but here I do not see this highlight in the markdown file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit2: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I come to find that the spell checking works well for the title marked with &lt;code&gt;#&lt;/code&gt;, &lt;code&gt;##&lt;/code&gt;, ..., &lt;code&gt;######&lt;/code&gt;, and from &lt;code&gt;#######&lt;/code&gt; on there will be no checking. It is the same with my markdown contents. If I do not mark my contents, there will be no spell checkings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit3:&lt;br&gt;&#xA;after various trying, I got to find the problem is likely to be with this line in my &lt;code&gt;.vimrc&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:markdown_fenced_languages = [&#xA;        \ 'vim',&#xA;        \  'html',&#xA;        \  'css',&#xA;        \  'erb=eruby',&#xA;        \  'go',&#xA;        \  'java',&#xA;        \  'javascript',&#xA;        \  'js=javascript',&#xA;        \  'json=javascript',&#xA;        \  'ruby',&#xA;        \  'sass',&#xA;        \  'sql',&#xA;        \  'xml',&#xA;        \  'cpp',&#xA;        \  'python',&#xA;        \  'bash=sh',&#xA;        \  'cmake'&#xA;        \]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just need markdown to show highlight for me code in the block between '```' and '```' pairs, but I did not expect it will affect my spell check, how could I solve this?&lt;/p&gt;&#xA;" OwnerUserId="18259" LastEditorUserId="18259" LastEditDate="2018-12-28T03:25:17.987" LastActivityDate="2018-12-28T09:06:16.313" Title="vim cannot check markdown spell" Tags="|spell-checking|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="18336" PostTypeId="1" CreationDate="2018-12-19T04:28:12.790" Score="0" ViewCount="213" Body="&lt;p&gt;When the number of text lines is less than a window height,&#xA;tilde (~) lines are displayed until the bottom of the window.&#xA;I want to decrease the window height just enough to display&#xA;all the lines and not to show any tilde lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution is to calculate how many visible lines are required&#xA;to display all. However, it is difficult because there are a lot of&#xA;options to take care, such as number, wrap, foldmethod, showbreak.&#xA;Other solution is to count how many tilde lines are displayed,&#xA;which would be simpler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you let me know how I can count the tilde lines?&lt;/p&gt;&#xA;" OwnerUserId="1641" LastActivityDate="2018-12-19T09:32:18.170" Title="How to count the number of tilde lines in a window?" Tags="|vim-windows|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18337" PostTypeId="2" ParentId="18333" CreationDate="2018-12-19T04:53:47.927" Score="2" Body="&lt;p&gt;As a brief start at an answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has command-line history on the Ex command line (what you get from &lt;code&gt;:&lt;/code&gt;). You can access it many ways; e.g.,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; and its cousin &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; to search forward and backward in history&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q:&lt;/code&gt; to access the command line window, a vim window with lots of power. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In a split provided by &lt;code&gt;:terminal&lt;/code&gt;, however, it depends entirely on the program running and in general becomes off-topic for this site. Consult the man pages. For example, in bash, there exist &lt;code&gt;history&lt;/code&gt;, history expansions via &lt;code&gt;!&lt;/code&gt;, and &lt;code&gt;fc&lt;/code&gt;, useful tricks to know. Combine with &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; recursive search for more fun. In &lt;code&gt;vi&lt;/code&gt; input mode, the &lt;code&gt;&amp;lt;C-n/p&amp;gt;&lt;/code&gt; trick works as well. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Addendum&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your arrow keys dont work in a &lt;code&gt;:terminal&lt;/code&gt; split, there are lots of potential sources. Check e.g. &lt;code&gt;$TERM&lt;/code&gt; and possibly open a new question focused on just this issue. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-12-19T04:53:47.927" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18338" PostTypeId="2" ParentId="18336" CreationDate="2018-12-19T07:11:01.480" Score="1" Body="&lt;p&gt;I think this is not easily to calculate, since you have to consider e.g. wrapped lines and the winbar. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest I can think of (without taking care of wrapping and a possible winbar), is something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo winheight(0) - (line('w$')-line('w0')+1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This calculates the height of the current window and subtracts the number of visible lines in there (&lt;code&gt;line('w$')&lt;/code&gt; is the last visible line in the current window and &lt;code&gt;line('w0')&lt;/code&gt; is the first visible line in the current window.)&#xA;But this will be wrong for wrapped lines, as you would have to add one for each wrapped line to the second half of the equation. But I don't know a good way to do this programmatically. Also if you have installed a &lt;a href=&quot;http://vimhelp.appspot.com/gui.txt.html#WinBar&quot; rel=&quot;nofollow noreferrer&quot;&gt;WinBar&lt;/a&gt;, you would have to add 1 in addition (because this is a line not visible in the current window).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-12-19T07:11:01.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18339" PostTypeId="2" ParentId="18336" CreationDate="2018-12-19T07:43:31.407" Score="0" Body="&lt;p&gt;This might work (not tested with all scenarios):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call cursor(line('$'), 99999)&#xA;let &amp;amp;lines=winline()+1&#xA;normal zb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;+1&lt;/code&gt; is to handle the status line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disadvantage: It moves the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or are you talking about a split? Then try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call cursor(line('$'), 99999)&#xA;execute &quot;resize &quot; . winline()&#xA;normal zb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2018-12-19T09:32:18.170" LastActivityDate="2018-12-19T09:32:18.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18340" PostTypeId="2" ParentId="18310" CreationDate="2018-12-19T13:06:37.987" Score="4" Body="&lt;p&gt;Okay, let me first explain, what is happening here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When indenting lines, Vim will indent the line, which means depending on the 'shiftwidth', 'tabstop', 'expandtab' and possibly also the 'vartabstop' options determine whether to insert leading tabs or blanks into the line. When the 'startofline' option is at its default value, the cursor will be moved to the first non-blank on the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The interesting thing is what happens, if the 'startofline' option is switched off. Well, basically the cursor stays at the exact same position, as it was before something was inserted. But since shifted right, the cursor appears to move. Now remember, that depending on a bunch of options, several blanks might actually be replaced by a single tab, so that technically the byte column might even decrease(!), while the line still appears to be shifted to the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can verify this, by comparing the output of &lt;code&gt;:echo virtcol('.')&lt;/code&gt; before and after you have (de-)indented your line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So according to the documentation, the line will always be shifted by the amount of &lt;code&gt;shiftwidth()&lt;/code&gt; spaces. So you need to adjust the cursor position (but not the byte column). This can be done like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! Indent(ind)&#xA;  if &amp;amp;sol&#xA;    set nostartofline&#xA;  endif&#xA;  let vcol = virtcol('.')&#xA;  if a:ind&#xA;    norm! &amp;gt;&amp;gt;&#xA;    exe &quot;norm!&quot;. (vcol + shiftwidth()) . '|'&#xA;  else&#xA;    norm! &amp;lt;&amp;lt;&#xA;    exe &quot;norm!&quot;. (vcol - shiftwidth()) . '|'&#xA;  endif&#xA;endfunc&#xA;&#xA;nnoremap &amp;gt;&amp;gt; :call Indent(1)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;&amp;lt; :call Indent(0)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will map the &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; in normal mode to perform the normal &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; comamnds and will afterwards re-adjust the cursor positioning. &#xA;Error management, range handling and handling e.g. visual mode has been intentionally left out. Those cases should probably be handled if a plugin is made out of it.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2018-12-19T13:06:37.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18341" PostTypeId="1" AcceptedAnswerId="18343" CreationDate="2018-12-19T14:07:27.447" Score="1" ViewCount="134" Body="&lt;p&gt;Given the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 2 3 4 5&#xA;1 2 3 4 5&#xA;1 2 3 4 5&#xA;1 2 3 4 5&#xA;1 2 3 4 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can each line be shifted left/right an amount related to their line number?  Desired outputs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 2 3 4 5&#xA;  1 2 3 4 5&#xA;    1 2 3 4 5&#xA;      1 2 3 4 5&#xA;        1 2 3 4 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        1 2 3 4 5&#xA;      1 2 3 4 5&#xA;    1 2 3 4 5&#xA;  1 2 3 4 5&#xA;1 2 3 4 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried setting up a macro with visual block mode with varying degrees of success, but I'd ideally like a one liner that lets me select a block and execute it.&lt;/p&gt;&#xA;" OwnerUserId="3209" LastActivityDate="2018-12-20T13:24:41.100" Title="How can I stagger text in vim?" Tags="|visual-block|multiple-lines|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18342" PostTypeId="1" AcceptedAnswerId="18345" CreationDate="2018-12-19T14:23:50.397" Score="3" ViewCount="754" Body="&lt;p&gt;&lt;strong&gt;How do I replace a visual selection with some register content without overwriting the unnamed (&quot;&quot;) register by the visual selection?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/3837772/vim-replace-selection-with-default-buffer-without-overwriting-the-buffer&quot;&gt;https://stackoverflow.com/questions/3837772/vim-replace-selection-with-default-buffer-without-overwriting-the-buffer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is basically the same, however the answer &lt;code&gt;xnoremap p &quot;_dP&lt;/code&gt; provided there doesn't work properly if applied to a selection that includes the last character of the line (not even the end of line character &lt;code&gt;$&lt;/code&gt;). Furthermore, with this solution, the paste register is hardcoded (to the unnamed one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a partial solution using &lt;code&gt;c&lt;/code&gt;, namely &lt;code&gt;&quot;_c&amp;lt;C-R&amp;gt;&quot;&amp;lt;Esc&amp;gt;&lt;/code&gt;. This still has the problem that the paste register is hard coded. Furthermore, I don't know how to use this in a vimscript function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(My main goal is to write a command that takes a motion and then replaces everything between the current cursor position to the motion target by a given register. I currently have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap s :set opfunc=SensibleSubstitute&amp;lt;CR&amp;gt;g@&#xA;function! SensibleSubstitute(type)&#xA;    normal `[v`]&#xA;    normal &quot;_c&amp;lt;C-R&amp;gt;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the &lt;code&gt;&amp;lt;C-R&amp;gt;&quot;&lt;/code&gt; is not recognized and just inserted verbally. Furthermore I don't know how to use the selected register if the user for example types &lt;code&gt;&quot;asiw&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(PS: the accepted answer &lt;a href=&quot;https://stackoverflow.com/questions/290465/how-to-paste-over-without-overwriting-register&quot;&gt;here&lt;/a&gt; has the same problems with selections at the end of hte line)&lt;/p&gt;&#xA;" OwnerUserId="18613" LastActivityDate="2023-02-17T01:19:11.190" Title="Vim: Replace visual selection without overwriting the unnamed register" Tags="|vimscript|cut-copy-paste|visual-mode|register|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18343" PostTypeId="2" ParentId="18341" CreationDate="2018-12-19T14:43:24.897" Score="4" Body="&lt;h2&gt;vimscript option&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 2 3 4 5&#xA;  1 2 3 4 5&#xA;    1 2 3 4 5&#xA;      1 2 3 4 5&#xA;        1 2 3 4 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next &quot;commands&quot; solves it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:for i in range(6)|call setline(i, repeat(' ', (i-1)*2).getline(i))|endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        1 2 3 4 5&#xA;      1 2 3 4 5&#xA;    1 2 3 4 5&#xA;  1 2 3 4 5&#xA;1 2 3 4 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not really sure about the &quot;rule&quot; :)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Another option with &quot;macro&quot;&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;step one, create macro&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;qq:exe &quot;normal &quot;.((line('.')-1)*2).&quot;I &quot;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;step two apply to 2nd to the last row (visually select it first)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;norm @q&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;PS, as asked in comment&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;to make it work for other line range apart started from line 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:for i in range(5,9)|call setline(i, repeat(' ', (i-1)*2).getline(i))|endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Fgj2m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Fgj2m.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2018-12-20T13:24:41.100" LastActivityDate="2018-12-20T13:24:41.100" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18344" PostTypeId="1" CreationDate="2018-12-19T15:02:07.607" Score="14" ViewCount="2421" Body="&lt;p&gt;See the following example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; open a file with 20+ lines.&#xA;1gg    &amp;quot; jump to line 1&#xA;3gg    &amp;quot; jump to line 3&#xA;5gg    &amp;quot; jump to line 5&#xA;7gg    &amp;quot; jump to line 7&#xA;ctrl+O &amp;quot; back to line 5&#xA;ctrl+O &amp;quot; back to line 3&#xA;20gg   &amp;quot; jump to line 20&#xA;ctrl+O &amp;quot; back to line 3&#xA;ctrl+O &amp;quot; back to line 7!!!! But what I expected is back to line 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I read &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#jumplist&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h jumplist&lt;/code&gt;&lt;/a&gt; and know why I get this result.&#xA;But this behavior is really annoying for me (I use Vim to read c++ code and jump through function call stack frequently), what I want is:&lt;/p&gt;&#xA;&lt;p&gt;After &lt;code&gt;ctrl+O&lt;/code&gt; and make a new jump, vim can erases jump tags that are later than current position in the jumplist.&lt;/p&gt;&#xA;" OwnerUserId="20239" LastEditorUserId="23502" LastEditDate="2023-09-21T04:22:41.520" LastActivityDate="2023-09-21T06:28:54.733" Title="How to change jumplist behavior?" Tags="|jumplist|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18345" PostTypeId="2" ParentId="18342" CreationDate="2018-12-19T16:26:26.063" Score="2" Body="&lt;p&gt;There are a lot of weird workarounds, but I do have an answer.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;but the &lt;code&gt;&amp;lt;C-R&amp;gt;&quot;&lt;/code&gt; is not recognized and just inserted verbally.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you want &lt;kbd&gt;ctrl-r&lt;/kbd&gt;, you'll need &lt;code&gt;&quot;\&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt;. (Note: &lt;em&gt;Specifically&lt;/em&gt; with double quotes, not single. Try &lt;code&gt;:echo &quot;\&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt; and &lt;code&gt;:echo '\&amp;lt;C-r&amp;gt;'&lt;/code&gt;) Which unfortunately means you'll need the whole thing to be a rather convoluted &lt;code&gt;exec&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec 'normal &quot;_c'.&quot;\&amp;lt;C-r&amp;gt;&quot;.'&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Furthermore I don't know how to use the selected register if the user for example types &lt;code&gt;&quot;asiw&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can get this in the &lt;code&gt;v:register&lt;/code&gt; variable. Unfortunately, it's not quite that simple in your example. Try this for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap s :set opfunc=SensibleSubstitute&amp;lt;CR&amp;gt;g@&#xA;function! SensibleSubstitute(type)&#xA;  echo v:register&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try something like &lt;code&gt;&quot;asiw&lt;/code&gt;. This &lt;em&gt;always&lt;/em&gt; prints &lt;code&gt;&quot;&lt;/code&gt; instead of &lt;code&gt;a&lt;/code&gt;. Why is that? Because of your remapping, you're effectively running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;a:set opfunc=SensibleSubstitute&amp;lt;CR&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you &lt;em&gt;really&lt;/em&gt; want to run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set opfunc=SensibleSubstitute&amp;lt;CR&amp;gt;&quot;ag@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you'll have to use an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting this all together, this should work for you (though I haven't tested it a whole lot):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;expr&amp;gt; s &quot;:set opfunc=SensibleSubstitute\&amp;lt;CR&amp;gt;&quot;.'&quot;'.v:register.&quot;g@&quot;&#xA;function! SensibleSubstitute(type)&#xA;  normal `[v`]&#xA;  exec 'normal &quot;_c'.&quot;\&amp;lt;C-r&amp;gt;&quot;.v:register&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-12-19T16:26:26.063" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18346" PostTypeId="1" AcceptedAnswerId="18793" CreationDate="2018-12-19T17:43:32.163" Score="2" ViewCount="596" Body="&lt;p&gt;On my laptop, I frequently swap between a dark and a bright colorscheme for my terminal. I do this by symlinking its configuration file and asking it (termite) to read it without closing using &lt;code&gt;killall -USR1 termite&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like my running neovims to pick up the change somehow, and set &lt;code&gt;background&lt;/code&gt; to either dark or light. I've visited &lt;a href=&quot;https://vi.stackexchange.com/a/16956/1027&quot;&gt;this answer&lt;/a&gt; and &lt;a href=&quot;https://github.com/neovim/neovim/issues/6279&quot; rel=&quot;nofollow noreferrer&quot;&gt;this issue&lt;/a&gt; and other places in an effort to find out how to &quot;refresh&quot; neovim. And I'd like to avoid using packages like neovim-remote if possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nvim --version&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NVIM v0.3.2-964-g7e97587da&#xA;Build type: RelWithDebInfo&#xA;LuaJIT 2.0.5&#xA;Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe&#xA;  -fstack-protector-strong -fno-plt -Wconversion -O2 -g -DMIN_LOG_LEVEL=3 &#xA;  -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes &#xA;  -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong &#xA;  -fdiagnostics-color=auto -Wno-array-bounds &#xA;  -DINCLUDE_GENERATED_DECLARATIONS &#xA;  -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM &#xA;  ...&#xA;&#xA;Features: +acl +iconv +jemalloc +tui &#xA;See &quot;:help feature-compile&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1027" LastActivityDate="2019-02-04T08:18:41.320" Title="updating running neovim's setting `background` using a terminal response" Tags="|neovim|terminal|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18347" PostTypeId="1" AcceptedAnswerId="18349" CreationDate="2018-12-19T18:48:34.327" Score="0" ViewCount="60" Body="&lt;p&gt;So Fugitive defines &lt;code&gt;:Glog&lt;/code&gt;. This is, apparently, aliased to a call to the script-local &lt;code&gt;s:Log()&lt;/code&gt; function (according to &lt;code&gt;:command Glog&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My muscle-memory has been using &lt;code&gt;glog&lt;/code&gt; at the command-line, for years, to invoke my custom git-log TUI; and I'd really like to remap the &lt;code&gt;:Glog&lt;/code&gt; command to a different tool (&lt;a href=&quot;https://github.com/gregsexton/gitv&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gitv&lt;/a&gt;, specifically); but I'd like to retain Fugitive's available quickfix-list-based-log-navigation for special circumstances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way for me to &lt;em&gt;remap&lt;/em&gt; a call to a script-local function, like that? Or am I doomed to overwrite Fugitive's pre-defined &lt;code&gt;:Glog&lt;/code&gt; and never have access to it, if I want it back?&lt;/p&gt;&#xA;" OwnerUserId="6108" LastActivityDate="2018-12-19T23:14:21.623" Title="Is it possible to non-recursively remap a command?" Tags="|command-line|functions|plugin-fugitive|user-commands|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18349" PostTypeId="2" ParentId="18347" CreationDate="2018-12-19T19:35:33.373" Score="3" Body="&lt;p&gt;I don't believe it's possible to redefine &lt;code&gt;:Glog&lt;/code&gt; without losing access to the script-local function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, bearing in mind your muscle memory is for &lt;code&gt;glog&lt;/code&gt;, not &lt;code&gt;Glog&lt;/code&gt;, I propose another approach:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoreabbrev &amp;lt;expr&amp;gt; glog (getcmdtype() == ':' &amp;amp;&amp;amp; getcmdpos() == 5) ? 'Gitv' : 'glog'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This abbreviation will convert your &lt;code&gt;:glog&lt;/code&gt; commands into &lt;code&gt;:Gitv&lt;/code&gt; commands, leaving &lt;code&gt;:Glog&lt;/code&gt; intact for when you need it.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-12-19T23:14:21.623" LastActivityDate="2018-12-19T23:14:21.623" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18350" PostTypeId="1" AcceptedAnswerId="18351" CreationDate="2018-12-19T21:40:19.797" Score="6" ViewCount="7120" Body="&lt;p&gt;I'm trying to adjust my &lt;code&gt;vimrc&lt;/code&gt; to be portable and also run under Gvim 8 on Windows 10. I use Vundle as my package manager and it works perfectly on my Ubuntu machine. However, on Windows, it won't load. I've traced the problem to this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp+=&quot;$HOME\\vimfiles\\bundle\\Vundle.vim\\&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After exploring the situation, I discovered that &lt;em&gt;any&lt;/em&gt; path I give to &lt;code&gt;runtimepath&lt;/code&gt; turns into the empty string. I've tried every combination of path separator characters, I've tried absolute paths, relative paths, paths using environment variables, everything. I've tried to set it to various paths on my machine which are simple enough that there's no possibility of typos. Regardless of what I set, &lt;code&gt;rtp&lt;/code&gt; doesn't get changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After failing with the above, I started setting &lt;code&gt;rtp&lt;/code&gt; using &lt;code&gt;=&lt;/code&gt; instead of &lt;code&gt;+=&lt;/code&gt;. When doing this, no matter what I set, &lt;code&gt;echo &amp;amp;rtp&lt;/code&gt; is empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I need to do to convince vim to &lt;strong&gt;really&lt;/strong&gt; set the runtime path?&lt;/p&gt;&#xA;" OwnerUserId="20217" LastActivityDate="2018-12-21T07:11:39.270" Title="Why does setting runtimepath do nothing?" Tags="|vimrc|gvim|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18351" PostTypeId="2" ParentId="18350" CreationDate="2018-12-19T22:37:09.150" Score="9" Body="&lt;p&gt;In this case the double quote &lt;code&gt;&quot;&lt;/code&gt; starts a comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After removing the comment you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp+=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While double (or single) quotes are normally used to enclose strings, the syntax for setting options is different.&#xA;The &lt;code&gt;set&lt;/code&gt; command predates Vim and was available in the original Vi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: You can use forward slashes for runtimepath.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2018-12-21T07:11:39.270" LastActivityDate="2018-12-21T07:11:39.270" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18352" PostTypeId="1" CreationDate="2018-12-20T01:49:32.023" Score="0" ViewCount="257" Body="&lt;p&gt;I have two tabs on my terminal. The first one is where I'm doing my project (&lt;code&gt;html&lt;/code&gt; &amp;amp; &lt;code&gt;css&lt;/code&gt;). On the other tab I'm working on my &lt;code&gt;.vimrc&lt;/code&gt;. I added a new plugin (&lt;code&gt;nerdcommenter&lt;/code&gt;) and it works on the &lt;code&gt;.vimrc&lt;/code&gt; when I tested it because I also set the following &lt;code&gt;augroup&lt;/code&gt; inside of it to make sure it will always source the &lt;code&gt;~/.vimrc&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup myrefresh&#xA;    au!&#xA;    au bufwritepost .vimrc source ~/.vimrc&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nerdcommenter&lt;/code&gt; works on the tab where the &lt;code&gt;.vimrc&lt;/code&gt; is but it didn't work to other tab where the &lt;code&gt;html&lt;/code&gt; and &lt;code&gt;css&lt;/code&gt; located. I tried to run &lt;code&gt;:e&lt;/code&gt; in the &lt;code&gt;html&lt;/code&gt; file to test if the &lt;code&gt;nerdcommenter&lt;/code&gt; functionality will work on it but still it didn't work. What could be the problem?&lt;/p&gt;&#xA;" OwnerUserId="20218" LastEditorUserId="20218" LastEditDate="2018-12-20T07:37:04.453" LastActivityDate="2018-12-20T08:30:44.923" Title="Apply the new setup of .vimrc to the file open to the other tab in the terminal" Tags="|vimrc|" AnswerCount="1" CommentCount="5" ClosedDate="2018-12-20T15:17:38.063" ContentLicense="CC BY-SA 4.0" />
  <row Id="18353" PostTypeId="1" AcceptedAnswerId="18359" CreationDate="2018-12-20T07:42:18.833" Score="2" ViewCount="1018" Body="&lt;p&gt;&lt;strong&gt;Context&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say in vim, after &lt;code&gt;:grep text *&lt;/code&gt;, then &lt;code&gt;:copen&lt;/code&gt;, then cursor in a quickfix window, which has contents like below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some-very-very-very-long-path/file1.txt|1 col 46| some text&#xA;some-very-very-very-long-path/file2.txt|84 col 34| another text&#xA;some-very-very-very-long-path/file3.txt|243 col 29| yetanother text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to conceal the filename and line column number at the beginning of each line?&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2023-08-18T22:11:34.873" Title="how to conceal filename and line number in quickfix window" Tags="|conceal|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18354" PostTypeId="1" CreationDate="2018-12-20T07:47:02.283" Score="1" ViewCount="69" Body="&lt;p&gt;I want to be able to make the changes that I’m making to certain files a lot more visible while I’m editing them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does any plugin or functionality of vim allow for viewing the editing history of the document as a patch file? (Similar to the “track changes” visualization feature in Microsoft Word.) I know there are git plugins that can show you which lines are modified/not committed, but I want to be able to view what I’ve deleted inline as well, in case I might need to glance at it again.&lt;/p&gt;&#xA;" OwnerUserId="20248" LastActivityDate="2018-12-20T08:31:23.223" Title="Editing diffs in-line in vim" Tags="|insert-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18355" PostTypeId="2" ParentId="18352" CreationDate="2018-12-20T08:30:44.923" Score="0" Body="&lt;p&gt;The Vim running in the other tab is an entirely separate instance. In order for the changes to be picked up in that tab you will need to source your &lt;code&gt;.vimrc&lt;/code&gt; there too, by running the following command in that Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:source $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2018-12-20T08:30:44.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18356" PostTypeId="2" ParentId="18354" CreationDate="2018-12-20T08:31:23.223" Score="1" Body="&lt;p&gt;There is &lt;code&gt;mbbill/undotree&lt;/code&gt; plugin that can do it as far as I understood you:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pYAml.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pYAml.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2018-12-20T08:31:23.223" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18357" PostTypeId="1" AcceptedAnswerId="21951" CreationDate="2018-12-20T08:38:29.677" Score="1" ViewCount="485" Body="&lt;p&gt;Is there a way to select multiple files not one by one (with &lt;code&gt;mf&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I can see in the docs &lt;code&gt;:MF&lt;/code&gt; command that do nothing for me. (&lt;code&gt;:MF *.vim&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;I also have tried &lt;code&gt;mr&lt;/code&gt; supplying it &lt;code&gt;*.vim$&lt;/code&gt; in the folder full of vim files -- nothing happens&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Or they do not work in windows?&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-11-18T22:12:22.620" Title="Netrw multiple files selection" Tags="|netrw|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18358" PostTypeId="1" CreationDate="2018-12-20T09:17:01.650" Score="3" ViewCount="167" Body="&lt;p&gt;Specs:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vim 8.0 patch 500&lt;/li&gt;&#xA;&lt;li&gt;gnome-terminal 3.18.3 on Ubuntu 16.04 running Unity&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Function keys in my vim &lt;em&gt;slightly&lt;/em&gt; misbehave, however, in an annoying way: I can't completely use them in my macros. After much trial and error I have given up and think I need help here. Please? :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mapping Function keys works&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nmap &amp;lt;F2&amp;gt;&amp;lt;F2&amp;gt; :echo 'works!'&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;also works: &lt;code&gt;nmap &amp;lt;Leader&amp;gt;2 &amp;lt;F2&amp;gt;&amp;lt;F2&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But if I record a macro with function keys in it, it sometimes works, sometimes not. This is what I get when I record a macro with an &lt;code&gt;&amp;lt;F9&amp;gt;&lt;/code&gt; in it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The macro is typed as &lt;code&gt;&quot;w&amp;lt;F9&amp;gt;p&lt;/code&gt; (put style invocation of something with register &lt;code&gt;w&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;replaying the macro however, leads to the invocation of my ex command at the receiving end of the  mapping with &lt;code&gt;v:register&lt;/code&gt; set to &lt;code&gt;a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Pasting the macro register yields &lt;code&gt;&quot;w�k9p&lt;/code&gt;, which vim renders as &lt;a href=&quot;https://i.stack.imgur.com/6nS2W.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6nS2W.png&quot; alt=&quot;vim rendering of pasted macro register&quot;&gt;&lt;/a&gt; and which xxd tells me is the byte string &lt;code&gt;2277 806b 3970&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Typing &lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;F9&amp;gt;&lt;/code&gt; in insert mode yields &lt;code&gt;^[[20~&lt;/code&gt; and I think that is what vim is also expecting to see when &lt;code&gt;&amp;lt;F9&amp;gt;&lt;/code&gt; is used in a mapping. It is also what I see when I type &lt;code&gt;F9&lt;/code&gt; into plain &lt;code&gt;cat&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Many of my mappings involve function keys and I want to fix this once and for all. My attempts to date involved the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap ?k9 &amp;lt;F9&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the &lt;code&gt;?&lt;/code&gt; is the literal pasted &lt;code&gt;&amp;lt;80&amp;gt;&lt;/code&gt; thingy from before. Upon loading that file again, the bracketed representation did not appear again; however, I have confirmed with xxd that the exact byte representation of the symbol in .vimrc is still &lt;code&gt;80&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another one through the use of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;F9&amp;gt;=^[[20~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(inserted literally with &lt;code&gt;&amp;lt;C-V&amp;gt;&lt;/code&gt; as you'd expect)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To no avail. Please help me so that I can use the F9 key in a macro! thanks!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In GVim, I get the exact same behavior. This means, it is not the fault of my terminal emulator, right?&lt;/p&gt;&#xA;" OwnerUserId="17075" LastEditorUserId="1841" LastEditDate="2018-12-20T15:25:51.140" LastActivityDate="2018-12-20T15:25:51.140" Title="Function keys: won't work with macros (I tried a lot)" Tags="|terminal|key-bindings|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18359" PostTypeId="2" ParentId="18353" CreationDate="2018-12-20T09:45:49.980" Score="9" Body="&lt;p&gt;You can use the &lt;code&gt;conceal&lt;/code&gt; feature for this.&lt;/p&gt;&#xA;&lt;p&gt;Add the following to the file &lt;code&gt;~/.vim/after/syntax/qf.vim&lt;/code&gt; (first creating the file if necessary):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;syntax match ConcealedDetails /\v^[^|]*\|[^|]*\| / conceal&#xA;setlocal conceallevel=2&#xA;setlocal concealcursor=nvic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The first line sets up a syntax item to conceal anything that matches the regular expression.&lt;/p&gt;&#xA;&lt;p&gt;The second line informs Vim that you want to hide any concealed items that don't have a replacement &lt;code&gt;cchar&lt;/code&gt; set.&lt;/p&gt;&#xA;&lt;p&gt;The third line makes it so that the text is &lt;em&gt;always&lt;/em&gt; concealed, whatever mode you are in.&lt;/p&gt;&#xA;&lt;p&gt;The regular expression I used presumes that your file names/paths won't ever contain a &lt;code&gt;|&lt;/code&gt; character. If they do, you'll need to adjust your regular expression to account for this.&lt;/p&gt;&#xA;&lt;p&gt;Further details:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/syntax.txt.html#conceal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help conceal&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/options.txt.html#%27conceallevel%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'conceallevel'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/options.txt.html#%27concealcursor%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'concealcursor'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2021-05-21T09:43:38.153" LastActivityDate="2021-05-21T09:43:38.153" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18360" PostTypeId="1" CreationDate="2018-12-20T12:08:19.973" Score="2" ViewCount="36" Body="&lt;p&gt;I am using vim to replace with simple regex:&#xA;&lt;code&gt;%s/Foo\(.\)/Bar\1Biz/gc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanna to confirm each occurence and Vim asks:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;replace with Bar\1Biz (y/n/a/q/l/^E/^Y)?&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to substitute group (&lt;code&gt;\1&lt;/code&gt;) in prompt to see resulting sting for each occurrence?&lt;/p&gt;&#xA;" OwnerUserId="20252" LastActivityDate="2018-12-20T12:08:19.973" Title="Substitute regex group in prompt when replace with confirmation" Tags="|regular-expression|replace|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18361" PostTypeId="1" CreationDate="2018-12-20T15:11:47.930" Score="1" ViewCount="978" Body="&lt;p&gt;When I'm in the terminal and I press &lt;code&gt;&amp;lt;C-w&amp;gt;s&lt;/code&gt; the screen is split vertically and the terminal buffer is shown twice. Then I have to do &lt;code&gt;:terminal&lt;/code&gt; if I want a separate terminal instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typing something in one window is in real time shown in the other. This is a &lt;em&gt;feature&lt;/em&gt; if I was editing a file but is an &lt;em&gt;inconvenience&lt;/em&gt; when working with terminal buffers.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How do I conditionally run &lt;code&gt;&amp;lt;C-w&amp;gt;S:terminal&lt;/code&gt; depending on whether the current window is a terminal buffer?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="7129" LastEditorUserId="16280" LastEditDate="2019-04-01T10:51:47.183" LastActivityDate="2019-04-01T15:16:53.113" Title="Start a new terminal instance if window splitting was initiated from a terminal buffer" Tags="|neovim|terminal|terminal-buffer|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18362" PostTypeId="1" AcceptedAnswerId="18363" CreationDate="2018-12-20T19:16:56.143" Score="0" ViewCount="411" Body="&lt;p&gt;1) I need to capture the next key press from the keyboard, if there are any in 200 millisecond. Which function should I use to achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Basically I need to re-send the captured key, with some prefix key added. How can I check the code of key press properly? (I only need to check letter &lt;code&gt;[a-zA-Z]&lt;/code&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;letter&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="2920" LastEditDate="2018-12-20T19:23:11.260" LastActivityDate="2018-12-20T19:43:44.310" Title="Capture the next keypress under 200ms" Tags="|vimscript|functions|user-input|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18363" PostTypeId="2" ParentId="18362" CreationDate="2018-12-20T19:43:44.310" Score="1" Body="&lt;p&gt;1) This should work for you, though it isn't perfect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetKeyUnder200ms()&#xA;  let l:start = reltimefloat(reltime())&#xA;  let l:char = getchar()&#xA;&#xA;  if reltimefloat(reltime()) - l:start &amp;lt; 0.200&#xA;    echo l:char&#xA;  else&#xA;    echo &quot;Too slow!&quot;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only downside to this approach is that you'll have to press a button regardless of whether you press it within 200 milliseconds or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, change &lt;code&gt;echo l:char&lt;/code&gt; and &lt;code&gt;echo &quot;Too slow!&quot;&lt;/code&gt; to whatever you're actually trying to accomplish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) You can check that with this expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if nr2char(l:char) =~ &quot;\a&quot; || l:char &amp;lt; 32&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if 'a' =~ '[\x00-\xFFa-zA-Z]'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if 'a' =~ '[\x00-\xFF]\|\a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-12-20T19:43:44.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18364" PostTypeId="1" AcceptedAnswerId="18365" CreationDate="2018-12-21T06:40:36.903" Score="0" ViewCount="572" Body="&lt;p&gt;Say, with 2 windows open in vim, cursor is window 2, how can I get the current buffer of the alternate window (window 1 in this case)?&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2018-12-21T07:42:17.630" Title="vimL, how to get alternate window's current buffer number" Tags="|vimscript|vim-windows|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18365" PostTypeId="2" ParentId="18364" CreationDate="2018-12-21T07:42:17.630" Score="4" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; current window buffer number&#xA;:echo winbufnr(winnr())&#xA;&#xA;&quot; 'previous' window buffer number&#xA;:echo winbufnr(winnr('#'))&#xA;&#xA;&quot; Name of the 'previous' window buffer number&#xA;:echo bufname(winbufnr(winnr('#')))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;Previous&quot; here means the window you have switched from to the current with, for example, &lt;code&gt;&amp;lt;C-w&amp;gt;w&lt;/code&gt;. So if you have 3+ windows opened then the last command will show you buffer name of the window you were in &quot;previously&quot; :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it more &quot;generic&quot; you can try to play with &lt;code&gt;winnr()&lt;/code&gt; function and friends. &lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2018-12-21T07:42:17.630" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18366" PostTypeId="2" ParentId="11883" CreationDate="2018-12-21T09:28:54.773" Score="3" Body="&lt;p&gt;Check the syntax id of the text not spell checked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First define the command SynID:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command SynID  echo synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 1), &quot;name&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then move the cursor to the text that is not spell checked and execute &lt;code&gt;:SynID&lt;/code&gt;. For &quot;normal&quot; text it returns nothing.&#xA;I tested your markdown snippet and it returned &lt;code&gt;markdownCodeBlock&lt;/code&gt; for the third level. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just indent by 2 spaces, the third level is spell checked, but the fourth level is detected as &lt;code&gt;markdownCodeBlock&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looks like it was already &lt;a href=&quot;https://github.com/tpope/vim-markdown/issues/125&quot; rel=&quot;nofollow noreferrer&quot;&gt;reported&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2018-12-21T09:28:54.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18367" PostTypeId="1" AcceptedAnswerId="18370" CreationDate="2018-12-21T10:36:39.693" Score="1" ViewCount="193" Body="&lt;p&gt;I want to implement something similar to Org mode M-RET into neovim. In Org mode it creates new list item or heading depending on what line the point is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking of a mapping in neovim that copies everything from the beginning of the current line until the first alphanumeric character of the line and puts it on a new line. For example, with cursor at the end, it would transform this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* list item&#xA;    * inner list item&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* list item&#xA;    * inner list item&#xA;    * &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think it could be done with &lt;code&gt;:s&lt;/code&gt; but i couldn't make it work (&lt;code&gt;:s/(^[^\w]*)(.*)/\1\2\n\1&lt;/code&gt;) and it would replace the whole line, which is unnecessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally it should work in insert mode and shouldn't rewrite any registers.&lt;/p&gt;&#xA;" OwnerUserId="20258" LastActivityDate="2018-12-21T15:19:01.027" Title="How to copy all non-alphanumeric characters at the begining of the line to the next line?" Tags="|key-bindings|insert-mode|filetype-markdown|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18369" PostTypeId="2" ParentId="18367" CreationDate="2018-12-21T12:32:08.697" Score="1" Body="&lt;h2&gt;&lt;code&gt;:substitute&lt;/code&gt; Command&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The problem with the command you tried is that you used &lt;code&gt;\n&lt;/code&gt; where you needed to use &lt;code&gt;\r&lt;/code&gt;. (See &lt;code&gt;:help s/\r&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't really share your aversion to substituting the entire line, but we'll avoid that too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v^(\W*).*\zs/\r\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Insert Mode Mapping&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To use this from insert mode, you can include it in an insert mode mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;F1&amp;gt; &amp;lt;Esc&amp;gt;:s/\v^(\W*).*\zs/\r\1&amp;lt;CR&amp;gt;A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;How It Works&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; &amp;ndash; using &quot;very magic&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; &amp;ndash; the start of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(\W*)&lt;/code&gt; &amp;ndash; as many non-alphanumeric characters* as possible, grouped into a capture group.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*&lt;/code&gt; &amp;ndash; as many characters as possible (i.e. the rest of the line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs&lt;/code&gt; &amp;ndash; set the start of the match (and thus the start of the replacement) to here &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The replacement:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\r&lt;/code&gt; &amp;ndash; A newline&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\1&lt;/code&gt; &amp;ndash; The captured group.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* &lt;code&gt;\W&lt;/code&gt; is equivalent to [0-9A-Za-z_] which is close enough to &quot;non-alphanumeric&quot; for your purposes.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Avoid &lt;code&gt;:substitute&lt;/code&gt; Entirely&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It's also possible just to use regular editing commands to perform this task:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;F1&amp;gt; &amp;lt;Esc&amp;gt;0y/\w&amp;lt;CR&amp;gt;o&amp;lt;Esc&amp;gt;pA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To see how this works, just try typing out the commands in the mapping's &lt;code&gt;rhs&lt;/code&gt; manually!&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2018-12-21T13:14:26.040" LastActivityDate="2018-12-21T13:14:26.040" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18370" PostTypeId="2" ParentId="18367" CreationDate="2018-12-21T15:10:00.023" Score="1" Body="&lt;p&gt;You could start with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NewBullet()&#xA;    let l = getline('.')&#xA;    let l = substitute(l, '\w.*$','', '')&#xA;    return &quot;\n&quot; . l&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;F1&amp;gt; NewBullet()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Map-expression calls the function and inserts the returned text. Here a newline and the prefix of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :map-expression&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2018-12-21T15:19:01.027" LastActivityDate="2018-12-21T15:19:01.027" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18371" PostTypeId="1" AcceptedAnswerId="18383" CreationDate="2018-12-21T16:11:11.243" Score="0" ViewCount="743" Body="&lt;p&gt;On macbook keyboard, there is only one ctrl key on the left.  I am so used to  for half page down using the right ctrl key that it is driving me crazy.   Any way to remap the left key to ctrl? &lt;/p&gt;&#xA;" OwnerUserId="3050" LastActivityDate="2018-12-26T14:53:56.570" Title="Remap left arrow to ctrl key in vim" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18372" PostTypeId="1" AcceptedAnswerId="18378" CreationDate="2018-12-21T18:55:31.433" Score="5" ViewCount="2536" Body="&lt;p&gt;I've been using Neovim to do the majority of my dev work for most of 2018 however something that has eluded me is being able to quickly toggle JSX comments&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{/* JSX */}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and regular Javascript comments in the same &lt;code&gt;.js&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// single line JavaScript comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Until last night I had been using &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;noreferrer&quot;&gt;vim-commentary&lt;/a&gt; to quickly toggle / comment a line of source in whatever language I was working with using the below mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;leader&amp;gt;c :Commentary&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works great for 99% of the languages I work with, however when I have to work with a JavaScript file that is a react based component and has JSX in it, &lt;code&gt;&amp;lt;leader&amp;gt;c&lt;/code&gt; will place &lt;code&gt;//&lt;/code&gt; when trying to comment a line of JSX within the render method.  I scanned through some of the issues of vim-commentary over at GitHub, and didn't really see a concrete example on how a single &lt;code&gt;.js&lt;/code&gt; file could use &lt;code&gt;//&lt;/code&gt; and &lt;code&gt;{/* JSX */}&lt;/code&gt; within the same file using the same mapping.  However, I did come across this &lt;a href=&quot;https://github.com/tpope/vim-commentary/issues/68&quot; rel=&quot;noreferrer&quot;&gt;issue&lt;/a&gt; and didn't really see a solution presented within the issue thread.  One of the posters suggested &lt;a href=&quot;https://github.com/tomtom/tcomment_vim&quot; rel=&quot;noreferrer&quot;&gt;tcomment_vim&lt;/a&gt; which oddly enough has this open &lt;a href=&quot;https://github.com/tomtom/tcomment_vim/issues/159&quot; rel=&quot;noreferrer&quot;&gt;issue&lt;/a&gt; but once again the author of the plugin suggests &lt;a href=&quot;https://github.com/tomtom/tcomment_vim/issues/159#issuecomment-175809947&quot; rel=&quot;noreferrer&quot;&gt;reading the source&lt;/a&gt; of the plugin which references a &lt;a href=&quot;https://github.com/tomtom/tcomment_vim/blob/master/autoload/tcomment.vim#L200&quot; rel=&quot;noreferrer&quot;&gt;deprecated method&lt;/a&gt; in the plugin source.  Anyways, not really sure where to go from here ‍♂️, as always, any and all help would greatly be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="10550" LastActivityDate="2018-12-24T10:53:48.030" Title="How to add JavaScript and JSX comments in the same .js file" Tags="|comments|plugin-vim-commentary|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18373" PostTypeId="2" ParentId="18361" CreationDate="2018-12-21T19:08:40.757" Score="0" Body="&lt;p&gt;Adding this to &lt;code&gt;~/.config/init.vim&lt;/code&gt; solved it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Split into a new terminal instance                       &#xA;tnoremap &amp;lt;C-w&amp;gt;s &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&amp;lt;C-w&amp;gt;&amp;lt;C-s&amp;gt; :terminal &amp;lt;CR&amp;gt;&#xA;tnoremap &amp;lt;C-w&amp;gt;v &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&amp;lt;C-w&amp;gt;&amp;lt;C-v&amp;gt; :terminal &amp;lt;CR&amp;gt;&#xA;set splitbelow                                     &#xA;set splitright                                     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It maps the split commands (&lt;code&gt;&amp;lt;C-w&amp;gt;s&lt;/code&gt; and &lt;code&gt;&amp;lt;C-w&amp;gt;v&lt;/code&gt;) to the following action:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; - exit insert mode in terminal&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-w&amp;gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; - run the actual split command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:terminal&lt;/code&gt; - unter the terminal command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; - press enter&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The additional two commands make the newly opened terminal doesn't appear on the location of the previous one.&lt;/p&gt;&#xA;" OwnerUserId="7129" LastEditorUserId="7129" LastEditDate="2018-12-21T19:14:29.283" LastActivityDate="2018-12-21T19:14:29.283" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18374" PostTypeId="1" AcceptedAnswerId="18377" CreationDate="2018-12-21T22:57:41.280" Score="1" ViewCount="790" Body="&lt;p&gt;I like to see my indentation level with &lt;code&gt;listchars=tab:\|\&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sDFGk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sDFGk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But one project uses two spaces instead. Is there any way to show indentation level lines then?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question seems to the opposite of &lt;a href=&quot;https://vi.stackexchange.com/questions/4302/show-listchars-tab-as-spaces&quot;&gt;Show listchars tab as spaces&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And differently from &lt;a href=&quot;https://stackoverflow.com/questions/40498265/show-space-character-via-listchars-only-for-leading-spaces&quot;&gt;https://stackoverflow.com/questions/40498265/show-space-character-via-listchars-only-for-leading-spaces&lt;/a&gt; i would not like to show all spaces, but just the indentation level. e.g. two spaces &lt;code&gt;|&lt;/code&gt;, four spaces &lt;code&gt;| |&lt;/code&gt;, and not &lt;code&gt;..&lt;/code&gt;, &lt;code&gt;....&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="19402" LastEditorUserId="19402" LastEditDate="2018-12-21T23:04:46.450" LastActivityDate="2018-12-22T13:57:52.147" Title="How to show 2 spaces as tabs in listchar?" Tags="|indentation|tab-characters|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18375" PostTypeId="2" ParentId="16020" CreationDate="2018-12-21T23:42:20.107" Score="1" Body="&lt;p&gt;You could create a mapping and use it instead of using zi. Create a mark for the current position and one for the top of the visible buffer, apply zi, move to the top, move the buffer, then move back to the original position.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;zi maHmb'azi'bzt`a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10482" LastActivityDate="2018-12-21T23:42:20.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18377" PostTypeId="2" ParentId="18374" CreationDate="2018-12-22T13:57:52.147" Score="0" Body="&lt;p&gt;Option 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim-indent-guides&lt;/code&gt; on &lt;a href=&quot;https://github.com/nathanaelkane/vim-indent-guides&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin uses two alternating colors to show guiding lines (see the screenshot there).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thickness of these lines can also be varied, as well as you could use just one color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;indentLine&lt;/code&gt; on &lt;a href=&quot;https://github.com/Yggdroot/indentLine&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin uses customizable vertical tab characters for the guide lines. See the screenshots further down on the github page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, that the leftmost guide is not displayed on the screenshots. This is not mentioned in the documentation, but if you want to have it displayed as well, you need to change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/vim/after/plugin/indentLine.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and change the assignment of variable &lt;code&gt;indentLine_showFirstIndentLevel&lt;/code&gt; from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note further, that the guideline is broken, if an empty line is passed. This is caused by the underlying technique of using vim's &lt;code&gt;conceal&lt;/code&gt; feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For both options, read the respective github pages for the minimum requirements.&lt;/p&gt;&#xA;" OwnerUserId="18342" LastActivityDate="2018-12-22T13:57:52.147" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18378" PostTypeId="2" ParentId="18372" CreationDate="2018-12-22T17:56:25.800" Score="4" Body="&lt;p&gt;You need the following plugins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-commentary&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/mxw/vim-jsx&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-jsx&lt;/a&gt;, to distinguish javascript and jsx files &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/suy/vim-context-commentstring&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-context-commentstring&lt;/a&gt;, to change &lt;code&gt;commentstring&lt;/code&gt; depending on the (syntax?) region.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now, depending of the position within the file, either &lt;code&gt;//&lt;/code&gt; or &lt;code&gt;{/* */}&lt;/code&gt; style comments are used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: Note that this sometimes tricky. Assume you have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const element = (&#xA;  &amp;lt;div&amp;gt;&#xA;    &amp;lt;h1&amp;gt;Hello!&amp;lt;/h1&amp;gt;&#xA;  &amp;lt;/div&amp;gt;&#xA;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the cursor is on the word Hello and you hit &lt;code&gt;gci)&lt;/code&gt; to comment the inner part of the () you get &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const element = (&#xA;  {/* &amp;lt;div&amp;gt; */}&#xA;  {/*   &amp;lt;h1&amp;gt;Hello!&amp;lt;/h1&amp;gt; */}&#xA;  {/* &amp;lt;/div&amp;gt; */}&#xA;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you would want the entire element commented you could hit &lt;code&gt;gca)&lt;/code&gt;. You get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{/* const element = ( */}&#xA;{/*   &amp;lt;div&amp;gt; */}&#xA;{/*     &amp;lt;h1&amp;gt;Hello!&amp;lt;/h1&amp;gt; */}&#xA;{/*   &amp;lt;/div&amp;gt; */}&#xA;{/* ); */}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the cursor is on the opening bracket in the first line and you hit &lt;code&gt;gca)&lt;/code&gt; you get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// const element = (&#xA;//   &amp;lt;div&amp;gt;&#xA;//     &amp;lt;h1&amp;gt;Hello!&amp;lt;/h1&amp;gt;&#xA;//   &amp;lt;/div&amp;gt;&#xA;// );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2018-12-24T10:53:48.030" LastActivityDate="2018-12-24T10:53:48.030" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18380" PostTypeId="2" ParentId="18202" CreationDate="2018-12-23T02:14:26.903" Score="5" Body="&lt;p&gt;I wrote my own solution by creating a parameter-expansion text object, something I'd been meaning to do for a while anyway.&lt;/p&gt;&#xA;&lt;p&gt;I include the full code at the very end, which I place in &lt;code&gt;~/.vim/autoload/sh.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then, in my &lt;code&gt;~/.vim/after/ftplugin/sh.vim&lt;/code&gt;, I remove the &lt;code&gt;setlocal iskeyword+=$&lt;/code&gt; line. &lt;strong&gt;This is the key step&lt;/strong&gt;, since it allows completion to work again.&lt;/p&gt;&#xA;&lt;p&gt;I add&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; iv :&amp;lt;C-u&amp;gt;call sh#in_parameter_expansion()&amp;lt;CR&amp;gt;&#xA;onoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; iv :&amp;lt;C-u&amp;gt;call sh#in_parameter_expansion()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This allows me to do things like &lt;code&gt;viv&lt;/code&gt; and &lt;code&gt;div&lt;/code&gt; to modify parameter expansions. &lt;code&gt;iv&lt;/code&gt; stands for &amp;quot;in variable&amp;quot; (&lt;code&gt;ip&lt;/code&gt; and &lt;code&gt;ap&lt;/code&gt; are taken for paragraphs)—one can easily use whatever mappings they wish.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Bonus&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I also created the following mapping to make use of &lt;code&gt;surround.vim&lt;/code&gt; as mentioned in the question:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Relies on surround.vim and custom text object above&#xA;nmap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;LocalLeader&amp;gt;qv ysiv&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;We need &lt;code&gt;nmap&lt;/code&gt; here because we &lt;em&gt;want&lt;/em&gt; recursive mapping expansion. But now a simple &lt;code&gt;&amp;lt;LocalLeader&amp;gt;qv&lt;/code&gt; (read: quote variable) will quote a parameter expansion (this is a common refactor for me).&lt;/p&gt;&#xA;&lt;p&gt;In the most up-to-date version, I include a text-object for subshells (&lt;code&gt;$(...)&lt;/code&gt;). It handles nested expansions and arithmetic as well. See the link under &lt;strong&gt;Code&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Well commented, with some patterns generalized.&lt;/p&gt;&#xA;&lt;p&gt;You can find the most up-to-date version &lt;a href=&quot;https://github.com/benknoble/Dotfiles/blob/master/links/vim/autoload/bk/sh.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;in my dotfiles on github&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; ~/.vim/autoload/sh.vim&#xA;&amp;quot; Based on https://vimways.org/2018/transactions-pending/&#xA;&#xA;&amp;quot; Text object for shell parameter expansions&#xA;&amp;quot; Definitions:&#xA;&amp;quot;   Parameter: An entity that stores values. It can be a name, a number, or one&#xA;&amp;quot;   of the special characters listed below. A variable is a parameter denoted by&#xA;&amp;quot;   a name.&#xA;&amp;quot;   Name: A word consisting solely of letters, numbers, and underscores, and&#xA;&amp;quot;   beginning with a letter or underscore. Names are used as shell variable and&#xA;&amp;quot;   function names. Also referred to as an identifier.&#xA;&amp;quot;   Positional Parameters: Any parameter denoted by one or more digits. Those&#xA;&amp;quot;   with multiple digits require braces.&#xA;&amp;quot;   Special Parameters: The following list:&#xA;&amp;quot;     - *&#xA;&amp;quot;     - @&#xA;&amp;quot;     - #&#xA;&amp;quot;     - ?&#xA;&amp;quot;     - -&#xA;&amp;quot;     - $&#xA;&amp;quot;     - !&#xA;&amp;quot;     - 0&#xA;&amp;quot;     - _&#xA;&amp;quot;  Expansion: Any usage of a parameter's value in place of its name: the common&#xA;&amp;quot;  forms include $var and ${var}. The more 'esoteric' options are documented&#xA;&amp;quot;  under 'Parameter Expansion' in bash(1).&#xA;&amp;quot;&#xA;&amp;quot;  In general, one wants to select the entire expansion construct in order to&#xA;&amp;quot;  e.g. surround in quotes (a common idiom). This means:&#xA;&amp;quot;    - $&#xA;&amp;quot;    - a parameter (name or special); or,&#xA;&amp;quot;    - a brace construction:&#xA;&amp;quot;      - {&#xA;&amp;quot;      - !, optionally                               -+&#xA;&amp;quot;      - parameter (name or special)                  |-basically 'anything'&#xA;&amp;quot;      - an expansion option (see above), optionally -+&#xA;&amp;quot;      - }&#xA;&amp;quot;&#xA;&amp;quot;  In the case of the braces, we can simply select the ${...}. Sans braces, we&#xA;&amp;quot;  have to match exactly the definition of a parameter. We construct a regex for&#xA;&amp;quot;  this purpose.&#xA;&#xA;function! s:branchify_atoms(atoms)&#xA;  return join(a:atoms, '\|')&#xA;endfunction&#xA;&#xA;function! s:group_atoms(atoms)&#xA;  return map(copy(a:atoms), 'printf(&amp;quot;\\(%s\\)&amp;quot;, v:val)')&#xA;endfunction&#xA;&#xA;&amp;quot; matches a name (no braces)&#xA;let s:name_pattern = '\m' &amp;quot; magic mode&#xA;let s:name_pattern .= '\(\a\|_\)' &amp;quot; begins with alpha or underscore&#xA;let s:name_pattern .= '\(\a\|\d\|_\)*' &amp;quot; letters, numbers, underscores&#xA;&#xA;&amp;quot; matches a positional parameter (no braces)&#xA;let s:positional_pattern = '\m' &amp;quot; magic&#xA;let s:positional_pattern .= '[1-9]' &amp;quot; a single digit&#xA;&#xA;&amp;quot; matches any of the special parameters (no braces)&#xA;let s:special_pattern = '\m' &amp;quot; magic&#xA;let s:special_pattern .= s:branchify_atoms(&#xA;      \ [&#xA;      \ '\*',&#xA;      \ '@',&#xA;      \ '#',&#xA;      \ '?',&#xA;      \ '-',&#xA;      \ '\$',&#xA;      \ '!',&#xA;      \ '0',&#xA;      \ '_'&#xA;      \ ]&#xA;      \ ) &amp;quot; special params as branches&#xA;&#xA;let s:parameter_pattern = '\m' &amp;quot; magic&#xA;let s:parameter_pattern .= s:branchify_atoms(&#xA;      \ s:group_atoms(&#xA;      \   [s:name_pattern, s:positional_pattern, s:special_pattern],&#xA;      \   )&#xA;      \ )&#xA;&#xA;&amp;quot; matches anything in braces&#xA;let s:brace_pattern = '\m' &amp;quot; magic&#xA;let s:brace_pattern .= '{' &amp;quot; opening brace&#xA;let s:brace_pattern .= '.\{-}' &amp;quot; anything, but non-greedy: there may be two braces in one line&#xA;let s:brace_pattern .= '}' &amp;quot; closing brace&#xA;&#xA;&amp;quot; matches a $ followed by a parameter or a brace construction&#xA;let s:expansion_pattern = '\m' &amp;quot; magic&#xA;let s:expansion_pattern .= '\$' &amp;quot; literal '$'&#xA;let s:expansion_pattern .= s:group_atoms(&#xA;      \ [s:branchify_atoms(&#xA;      \   s:group_atoms(&#xA;      \     [s:parameter_pattern, s:brace_pattern],&#xA;      \     )&#xA;      \   )]&#xA;      \ )[0] &amp;quot; extract the one and only element&#xA;&#xA;function! sh#in_parameter_expansion() abort&#xA;  let l:line = line('.')&#xA;  if !search(s:expansion_pattern, 'ce', l:line)&#xA;    return&#xA;  endif&#xA;  normal! v&#xA;  call search(s:expansion_pattern, 'cb', l:line)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2021-02-24T14:26:50.833" LastActivityDate="2021-02-24T14:26:50.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18382" PostTypeId="1" CreationDate="2018-12-23T07:05:48.947" Score="1" ViewCount="853" Body="&lt;p&gt;I am using NVIM v0.3.2-208-g2841e89 on Ubuntu 16.04 LTS and using ALE as my Linting Engine plugin. I am having issue with formatting for jinja template html files with &lt;code&gt;prettier&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The html files which start with  &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; tag and contains jinja code are not being formatted at all. When i run &lt;code&gt;ALEFix&lt;/code&gt; on these files nothing happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The html files that start with &lt;code&gt;{% extends %}&lt;/code&gt; line are getting formatted but not the correct way. When i run &lt;code&gt;ALEFix&lt;/code&gt; on these files, this is how the code starts to look. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original File&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{% extends &quot;home.html&quot; %}&#xA;{% block body %}&#xA;&amp;lt;div class=&quot;jumbotron&quot;&amp;gt;&#xA;&amp;lt;p&amp;gt;Thank you {{ session['username'] }} for signing up !!&amp;lt;/p&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&#xA;{% endblock %}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Formatted File&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{% extends &quot;home.html&quot; %} {% block body %}&#xA;&amp;lt;div class=&quot;jumbotron&quot;&amp;gt;&#xA;  &amp;lt;p&amp;gt;Thank you {{ session['username'] }} for signing up !!&amp;lt;/p&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&#xA;{% endblock %}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is another example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original File&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; {% extends &quot;home.html&quot; %}&#xA;{% block body %}&#xA;&amp;lt;form method=&quot;POST&quot;&amp;gt;&#xA;    {{ form.hidden_tag() }}&#xA;    {{ form.username.label }} {{ form.username }}&#xA;    {{ form.password.label }} {{ form.password }}&#xA;    {{ form.submit }}&#xA;&amp;lt;/form&amp;gt;&#xA;{% endblock %}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Formatted File&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{% extends &quot;home.html&quot; %} {% block body %}&#xA;&amp;lt;form method=&quot;POST&quot;&amp;gt;&#xA;  {{ form.hidden_tag() }} {{ form.username.label }} {{ form.username }} {{&#xA;  form.password.label }} {{ form.password }} {{ form.submit }}&#xA;&amp;lt;/form&amp;gt;&#xA;{% endblock %}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not sure if this is the correct formatting of the jinja file but it does not look very readable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how my config looks&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_fixers = {&#xA;                    \ '*': ['remove_trailing_lines', 'trim_whitespace'],&#xA;                    \ 'html': ['prettier'],&#xA;                    \ 'javascript': ['eslint', 'prettier'],&#xA;                    \ 'css' : ['stylelint', 'prettier'],&#xA;                    \ 'python' : ['yapf', 'isort', 'autopep8']&#xA;                    \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Below is what ALEInfo reports for a jinja template file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Current Filetype: jinja.html                                                                                                                                                                                      &#xA;Available Linters: ['alex', 'htmlhint', 'proselint', 'stylelint', 'tidy', 'writegood']                                                                                                                             &#xA;   Linter Aliases:                                                                                                                                                                                                 &#xA;'writegood' -&amp;gt; ['write-good']                                                                                                                                                                                      &#xA;  Enabled Linters: ['alex', 'htmlhint', 'proselint', 'stylelint', 'tidy', 'writegood']                                                                                                                             &#xA; Suggested Fixers:                                                                                                                                                                                                 &#xA;  'prettier' - Apply prettier to a file.                                                                                                                                                                           &#xA;  'remove_trailing_lines' - Remove all blank lines at the end of a file.                                                                                                                                           &#xA;  'tidy' - Fix HTML files with tidy.                                                                                                                                                                               &#xA;  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.                                                                                                                          &#xA; Linter Variables:                                                                                                                                                                                                 &#xA;let g:ale_html_htmlhint_executable = 'htmlhint'                                                                                                                                                                    &#xA;let g:ale_html_htmlhint_options = ''                                                                                                                                                                               &#xA;let g:ale_html_htmlhint_use_global = 0                                                                                                                                                                             &#xA;let g:ale_html_stylelint_executable = 'stylelint'                                                                                                                                                                  &#xA;let g:ale_html_stylelint_options = ''                                                                                                                                                                              &#xA;let g:ale_html_stylelint_use_global = 0                                                                                                                                                                            &#xA;let g:ale_html_tidy_executable = 'tidy'                                                                                                                                                                            &#xA;let g:ale_html_tidy_options = '-q -e -language en'                                                                                                                                                                 &#xA; Global Variables:                                                                                                                                                                                                 &#xA;let g:ale_cache_executable_check_failures = v:null                                                                                                                                                                 &#xA;let g:ale_change_sign_column_color = 0                                                                                                                                                                             &#xA;let g:ale_command_wrapper = ''                                                                                                                                                                                     &#xA;let g:ale_completion_delay = v:null                                                                                                                                                                                &#xA;let g:ale_completion_enabled = 0                                                                                                                                                                                   &#xA;let g:ale_completion_max_suggestions = v:null                                                                                                                                                                      &#xA;let g:ale_echo_cursor = 1                                                                                                                                                                                          &#xA;let g:ale_echo_msg_error_str = 'E'                                                                                                                                                                                 &#xA;let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'                                                                                                                                                           &#xA;let g:ale_echo_msg_info_str = 'Info'                                                                                                                                                                               &#xA;let g:ale_echo_msg_warning_str = 'W'                                                                                                                                                                               &#xA;let g:ale_enabled = 1                                                                                                                                                                                              &#xA;let g:ale_fix_on_save = 1                                                                                                                                                                                          &#xA;let g:ale_fixers = {'html': ['prettier'], '*': ['remove_trailing_lines', 'trim_whitespace'], 'javascript': ['eslint', 'prettier'], 'css': ['stylelint', 'prettier'], 'python': ['yapf', 'isort', 'autopep8']}      &#xA;let g:ale_history_enabled = 1                                                                                                                                                                                      &#xA;let g:ale_history_log_output = 1                                                                                                                                                                                   &#xA;let g:ale_keep_list_window_open = 0                                                                                                                                                                                &#xA;let g:ale_lint_delay = 200                                                                                                                                                                                         &#xA;let g:ale_lint_on_enter = 1                                                                                                                                                                                        &#xA;let g:ale_lint_on_filetype_changed = 1                                                                                                                                                                             &#xA;let g:ale_lint_on_insert_leave = 0                                                                                                                                                                                 &#xA;let g:ale_lint_on_save = 1                                                                                                                                                                                         &#xA;let g:ale_lint_on_text_changed = 'always'                                                                                                                                                                          &#xA;let g:ale_linter_aliases = {}                                                                                                                                                                                      &#xA;let g:ale_linters = {'css': ['stylelint'], 'python': ['flake8']}                                                                                                                                                   &#xA;let g:ale_linters_explicit = 0                     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18373" LastEditorUserId="18373" LastEditDate="2018-12-23T15:28:10.003" LastActivityDate="2018-12-23T15:28:10.003" Title="Jinja html templates formatting with ALE and Prettier in Vim" Tags="|neovim|plugin-ale|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18383" PostTypeId="2" ParentId="18371" CreationDate="2018-12-23T22:23:57.900" Score="1" Body="&lt;p&gt;While (post-experimentation and reading) I have found no way to remap &lt;code&gt;&amp;lt;Left&amp;gt;&lt;/code&gt; to send &lt;kbd&gt;Ctrl&lt;/kbd&gt;, I can at least point you in two different directions:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Simple mapping&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can &quot;simulate&quot; this with some mappings for common tasks, like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Left&amp;gt;d &amp;lt;C-d&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The downside is that you'll need to do this for any and all commands you want to map.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;OS Keymap&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;While off-topic here, the internet and other stackexchange sites have lots of information on changing your keyboard layout (especially for modifier keys).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I use &lt;kbd&gt;CapsLock&lt;/kbd&gt; to send &lt;kbd&gt;Ctrl&lt;/kbd&gt;: it saves me a lot of pinky strain.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2018-12-26T14:53:56.570" LastActivityDate="2018-12-26T14:53:56.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18384" PostTypeId="1" AcceptedAnswerId="18393" CreationDate="2018-12-24T08:32:14.120" Score="0" ViewCount="110" Body="&lt;p&gt;With the minimal vimrc (with vimtex plugin):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocp&#xA;filetype plugin indent on&#xA;syntax on&#xA;set st=2&#xA;set acd&#xA;set wildmenu&#xA;set wildmode=longest,list,full&#xA;let $USRPLUGD=$HOME.'\vimfiles\myvim\plugged'&#xA;let $USRTEMPD=$HOME.'\vimfiles\myvim\vimtemp'&#xA;call plug#begin( $USRPLUGD )&#xA;&quot; for latex&#xA;Plug 'lervag/vimtex'&#xA;call plug#end()&#xA;&#xA;let g:tex_flavor = &quot;latex&quot;&#xA;let g:vimtex_quickfix_open_on_warning = 0&#xA;let g:vimtex_quickfix_mode = 2&#xA;let g:vimtex_view_general_viewer='sumatrapdf'&#xA;&#xA;&#xA;let g:vimtex_compiler_latexmk = {&#xA;            \ 'backend' : 'process',&#xA;            \ 'background' : 1,&#xA;            \ 'build_dir' : $USRTEMPD,&#xA;            \ 'callback' : 1,&#xA;            \ 'continuous' : 1,&#xA;            \ 'executable' : 'latexmk',&#xA;            \ 'options' : [&#xA;            \   '-verbose',&#xA;            \   '-file-line-error',&#xA;            \   '-synctex=1',&#xA;            \   '-interaction=nonstopmode',&#xA;            \ ],&#xA;            \}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found that the indent of tex source file is not work properly for &lt;code&gt;\iff&lt;/code&gt;. Suppose we have a &lt;code&gt;test.tex&lt;/code&gt; then after &lt;code&gt;gg=G&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\documentclass{amsart}&#xA;\begin{document}&#xA;\section{Test}&#xA;\[&#xA;    a&amp;gt;b&#xA;\]&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this indent scheme seems not work properly for &lt;code&gt;\iff&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\documentclass{amsart}&#xA;\begin{document}&#xA;\section{Test}&#xA;\[&#xA;    a&amp;gt;b \Longleftrightarrow a-b&amp;gt;0.&#xA;\]&#xA;Not work for \verb|\iff|&#xA;    \[&#xA;        a&amp;gt;b \iff a-b&amp;gt;0.&#xA;        \]&#xA;        \end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As I have observed, we can replace &lt;code&gt;\iff&lt;/code&gt; by &lt;code&gt;\Longleftrightarrow&lt;/code&gt;. Is there any other solution such that the indention works for &lt;code&gt;\iff&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10430" LastActivityDate="2018-12-25T21:53:01.277" Title="LaTeX indent for \iff error in vim" Tags="|vimrc|indentation|filetype-tex|plugin-vimtex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18385" PostTypeId="1" AcceptedAnswerId="18386" CreationDate="2018-12-24T14:45:45.677" Score="1" ViewCount="277" Body="&lt;p&gt;What would be the best way to delete / change the inner block of an xml element? I could use &lt;code&gt;df&amp;lt;&lt;/code&gt; when my cursor is inside the block, i.e. when I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;elem&amp;gt;foo bar&amp;lt;\elem&amp;gt;&#xA;      ^&#xA;cursor location&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;df&amp;lt;&lt;/code&gt; from here should do it, but is there an inner block trick for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;noob here, so not sure what tags to use&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="20287" LastEditorUserId="205" LastEditDate="2019-11-06T06:46:54.960" LastActivityDate="2019-11-06T06:46:54.960" Title="(how) can I use di&lt; / di&gt; to delete inner block of xml" Tags="|cursor-motions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18386" PostTypeId="2" ParentId="18385" CreationDate="2018-12-24T14:49:47.120" Score="6" Body="&lt;p&gt;Try the text-object &lt;code&gt;it&lt;/code&gt; for in tag: &lt;code&gt;dit&lt;/code&gt;, &lt;code&gt;cit&lt;/code&gt;, &amp;amp;c. all do what you would expect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There’s also &lt;code&gt;at&lt;/code&gt; for a (whole) tag.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-12-24T14:49:47.120" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18387" PostTypeId="1" AcceptedAnswerId="19637" CreationDate="2018-12-25T02:02:14.723" Score="4" ViewCount="5282" Body="&lt;p&gt;I am looking for a way to toggle between these two layouts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-------&#xA;|  |  |&#xA;-------&#xA;&#xA;-------&#xA;|     |&#xA;-------&#xA;|     |&#xA;-------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I only have two windows and I need to switch the layout often. I need a solution that will preserve the aspect ratio of windows in both horizontal and vertical split layouts, so I don't end with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---------&#xA;|  |    |&#xA;---------&#xA;&#xA;-------&#xA;|     |&#xA;-------&#xA;|     |&#xA;-------&#xA;&#xA;---------&#xA;|    |  |&#xA;---------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after toggling twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this isn't possible with some oneliner in vimrc, I am willing to start using a plugin that offers this functionality, so feel free to suggest it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I am familiar with Ctrl-W + H/J/K/L but that doesn't preserve aspect ratio of windows.&lt;/p&gt;&#xA;" OwnerUserId="19475" LastEditorUserId="19475" LastEditDate="2018-12-25T12:24:57.650" LastActivityDate="2019-04-18T18:02:34.957" Title="How to toggle between split window layouts?" Tags="|split|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18388" PostTypeId="1" CreationDate="2018-12-25T07:16:31.290" Score="0" ViewCount="481" Body="&lt;p&gt;I know how to and I have used it for a long time on Mac. But in Ubuntu whenever I press &lt;code&gt;Alt+V&lt;/code&gt;, it goes to the system calendar instead of entering visual mode &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't see it as a shortcut in Ubuntu too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make sure it enters the visual mode?&lt;/p&gt;&#xA;" OwnerUserId="20291" LastActivityDate="2018-12-26T08:11:19.583" Title="How can I enter visual mode in Ubuntu?" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18389" PostTypeId="1" CreationDate="2018-12-25T10:57:46.340" Score="0" ViewCount="284" Body="&lt;p&gt;I want to edit text files with vim, I would love&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To work like normal, and open &lt;code&gt;file.txt&lt;/code&gt; in vim, like normal, and allow me to edit it &lt;em&gt;seemingly&lt;/em&gt; like normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only difference is, all writes &lt;code&gt;:w&lt;/code&gt; or anything, don't re-write file.txt, instead they write to some patch file that shows the differences between the original file and the edited one I am writing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So after I have finished editing, i should have &lt;code&gt;file.txt&lt;/code&gt; and &lt;code&gt;file.txt.diff&lt;/code&gt;, and &lt;code&gt;file.txt&lt;/code&gt; is identical to how it was before I started editing and &lt;code&gt;file.txt.diff&lt;/code&gt;, if patched onto &lt;code&gt;file.txt&lt;/code&gt;, would make &lt;code&gt;file.txt&lt;/code&gt; look like it did after my edits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next time I run &lt;code&gt;vim file.txt&lt;/code&gt; it would load the file with the patch, and I can continue editing from how it last &quot;was&quot;.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2018-12-25T10:57:46.340" Title="make vim produce patch files without editing originals" Tags="|vimdiff|swap-file|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18390" PostTypeId="2" ParentId="18388" CreationDate="2018-12-25T12:31:52.343" Score="3" Body="&lt;p&gt;3 types of &lt;code&gt;visual-mode&lt;/code&gt;, While being in normal mode,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;press &lt;code&gt;v&lt;/code&gt;, this will take you to &lt;code&gt;visual-mode&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;press &lt;code&gt;V&lt;/code&gt; ( capital V ), this will take you to &lt;code&gt;visual-line&lt;/code&gt; mode where you can visually select whole lines in a go.&lt;/li&gt;&#xA;&lt;li&gt;press &lt;code&gt;Ctrl-v&lt;/code&gt;, this will take you to &lt;code&gt;visual-block&lt;/code&gt; mode in which you can visually select blocks of text. If vim is compiled with the clipboard option, use &lt;code&gt;Ctrl-q&lt;/code&gt; instead (&lt;code&gt;:help ctrl-v-alternative&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Try each of them, you'll see the difference&lt;/p&gt;&#xA;" OwnerUserId="19211" LastEditorUserId="18342" LastEditDate="2018-12-26T08:11:19.583" LastActivityDate="2018-12-26T08:11:19.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18391" PostTypeId="1" CreationDate="2018-12-25T18:19:57.043" Score="0" ViewCount="50" Body="&lt;p&gt;I tend to use a lot of vertical splits in my vim (version 8.1, via Arch Linux official repos) usage (on top of tabs, horizontal splits, tmux, etc.), and it gets frustrating when many of my lines wrap and eat up vertical real-estate when there's plenty of indent-borne whitespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to read the tail of my code, but I also don't want those indents to eat up proportionally huge amounts of real-estate when I have vertical splits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I know I can use horizontal scroll commands (e.g. &lt;code&gt;zh&lt;/code&gt;, &lt;code&gt;zl&lt;/code&gt;) when I have &lt;code&gt;nowrap&lt;/code&gt; set in Vim. These commands, however, seem to be disabled when I set &lt;code&gt;wrap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get the same effect with &lt;code&gt;wrap&lt;/code&gt; set (or similar)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e. having the tail of the text wrap to the first visible column and still have horizontal scroll commands&lt;/p&gt;&#xA;" OwnerUserId="19896" LastEditorUserId="19896" LastEditDate="2018-12-25T22:57:23.630" LastActivityDate="2018-12-25T22:57:23.630" Title="Using horizontal scroll commands without setting `nowrap`" Tags="|scrolling|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18392" PostTypeId="1" CreationDate="2018-12-25T21:50:42.563" Score="2" ViewCount="385" Body="&lt;p&gt;I have a thesaurus file which contains synonyms for the word &lt;code&gt;iterate&lt;/code&gt;. I would like to add an alternative phrase for &lt;code&gt;iterate&lt;/code&gt; like &lt;code&gt;loop over&lt;/code&gt; so I added it to the thesaurus. Unfortunately, this doesn't work. Vim displays &quot;loop over&quot; as two entries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is from &lt;code&gt;:help thesaurus&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'thesaurus' 'tsr'   string  (default &quot;&quot;)&#xA;        global or local to buffer |global-local|&#xA;        {not in Vi}&#xA;List of file names, separated by commas, that are used to lookup words&#xA;for thesaurus completion commands |i_CTRL-X_CTRL-T|.&#xA;&#xA;Each line in the file should contain words with similar meaning,&#xA;separated by non-keyword characters (white space is preferred).&#xA;Maximum line length is 510 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks like whitespace is used to separate entries of the thesaurus. Which is weird because, up until this point, I had only been using a comma-separated list for the thesaurus and that worked fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Escaping the space character doesn't work unfortunately. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how I can get a phrase as a thesaurus option for a specific word?&lt;/p&gt;&#xA;" OwnerUserId="16073" LastActivityDate="2020-01-18T12:02:30.337" Title="autocompletion - How to add phrases as thesaurus synonyms" Tags="|autocompletion|thesaurus|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18393" PostTypeId="2" ParentId="18384" CreationDate="2018-12-25T21:53:01.277" Score="1" Body="&lt;p&gt;The problem you are describing seems to be clearly concerning the &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex plugin&lt;/a&gt;. The proper solution is therefore to raise this issue where it should be raised, i.e. at &lt;a href=&quot;https://github.com/lervag/vimtex/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex's issue tracker&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, no need, I just fixed the issue, so if you update your plugins, then this indentation issue should be resolved. Please open an issue at the issue tracker if the problem should persist, or if you have other issures relating to vimtex.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2018-12-25T21:53:01.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18395" PostTypeId="1" CreationDate="2018-12-26T11:48:01.070" Score="1" ViewCount="657" Body="&lt;p&gt;What does &lt;code&gt;cpoptions&lt;/code&gt; setting &lt;code&gt;'o'&lt;/code&gt; does?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The doc &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#cpo-o&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h cpo-o&lt;/code&gt;&lt;/a&gt; reads&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Line offset to search command is not remembered for next search.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="17560" LastEditorUserId="1841" LastEditDate="2018-12-26T16:55:49.663" LastActivityDate="2018-12-26T16:55:49.663" Title="What is 'cpoptions' += o?" Tags="|set|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18396" PostTypeId="2" ParentId="18395" CreationDate="2018-12-26T12:54:10.747" Score="2" Body="&lt;p&gt;Assuming you have the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Test Case&#xA;First&#xA;&#xA;Test Case&#xA;Second&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you search with &lt;code&gt;/Case/+1&lt;/code&gt; from the beginning of the file. The cursor will end up on the text &lt;code&gt;First&lt;/code&gt;. You searched for &lt;code&gt;Case&lt;/code&gt; and gave the &quot;line offset&quot; +1. (See &lt;code&gt;:help search-offset&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If cpoptions does &lt;strong&gt;not&lt;/strong&gt; contain &lt;code&gt;o&lt;/code&gt; and you press &lt;code&gt;n&lt;/code&gt;, the cursor ends up on the text &lt;code&gt;Second&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If cpoptions does contain &lt;code&gt;o&lt;/code&gt; and you press &lt;code&gt;n&lt;/code&gt; and the cursor ends up on the text &lt;code&gt;Case&lt;/code&gt;. So the line offset was not remembered.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2018-12-26T12:54:10.747" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18397" PostTypeId="1" CreationDate="2018-12-26T18:04:56.630" Score="4" ViewCount="515" Body="&lt;p&gt;I like to format my arrays like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myArray = [ &quot;lorem&quot;&#xA;          , &quot;ipsum&quot;&#xA;          , &quot;dolor&quot;&#xA;          , &quot;sit&quot;&#xA;          , &quot;amet&quot;&#xA;          ];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I open a new line below the &quot;amet&quot; line, I would like vim to automatically insert a comma so that I end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myArray = [ &quot;lorem&quot;&#xA;          , &quot;ipsum&quot;&#xA;          , &quot;dolor&quot;&#xA;          , &quot;sit&quot;&#xA;          , &quot;amet&quot;&#xA;          , &#xA;          ];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similar to how vim automatically insert comments with &lt;code&gt;set formatoptions=ro&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14994" LastActivityDate="2019-01-27T18:01:20.267" Title="Insert comma on new line in array" Tags="|insert-mode|formatting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18398" PostTypeId="1" AcceptedAnswerId="18399" CreationDate="2018-12-26T18:52:16.577" Score="1" ViewCount="78" Body="&lt;p&gt;I'm going nuts trying to get this mapping to work. It's so simple yet doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with the mapping removed  moves me off of nerd tree to the main window to it's right. Great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I added the following mapping, nothing happens with &lt;code&gt;z;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ; l &#xA;nnoremap l k &#xA;nnoremap k j &#xA;nnoremap j h &#xA;&#xA;nnoremap &amp;lt;C-W&amp;gt;&amp;lt;Up&amp;gt; zl&#xA;nnoremap &amp;lt;C-W&amp;gt;&amp;lt;Down&amp;gt; zk&#xA;nnoremap &amp;lt;C-W&amp;gt;&amp;lt;Left&amp;gt; zj&#xA;nnoremap &amp;lt;C-W&amp;gt;&amp;lt;Right&amp;gt; z; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: I've pasted my entire vimrc below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=2&#xA;set softtabstop=2&#xA;set shiftwidth=2&#xA;set expandtab&#xA;set textwidth=0&#xA;set backspace=indent,eol,start&#xA;set laststatus=1&#xA;set winwidth=9&#xA;set backupcopy=yes&#xA;syntax on&#xA;filetype plugin on&#xA;colorscheme molokai&#xA;set wildignore+=*/node_modules/*,*/migrations/*,*.swp,&#xA;set t_Co=256&#xA;&#xA;nnoremap ; l&#xA;nnoremap l k&#xA;nnoremap k j&#xA;nnoremap j h&#xA;&#xA;nmap &amp;lt;C-W&amp;gt;&amp;lt;Down&amp;gt; zk&#xA;nnoremap &amp;lt;C-W&amp;gt;&amp;lt;Right&amp;gt; zl&#xA;&#xA;set number&#xA;set nowrap&#xA;set cursorline&#xA;set autoindent&#xA;set splitright&#xA;set splitbelow&#xA;set copyindent&#xA;set preserveindent&#xA;&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'scrooloose/nerdtree'&#xA;Plug 'vim-syntastic/syntastic'&#xA;Plug 'nvie/vim-flake8'&#xA;Plug 'vim-airline/vim-airline'&#xA;Plug 'vim-airline/vim-airline-themes'&#xA;Plug 'scrooloose/nerdcommenter'&#xA;Plug 'ntpeters/vim-better-whitespace'&#xA;Plug 'ap/vim-css-color'&#xA;Plug 'pangloss/vim-javascript'&#xA;Plug 'mxw/vim-jsx'&#xA;Plug 'ctrlpvim/ctrlp.vim'&#xA;Plug 't9md/vim-choosewin'&#xA;Plug 'tikhomirov/vim-glsl'&#xA;&#xA;call plug#end()&#xA;&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;set statusline+=%*&#xA;&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_loc_list_height = 5&#xA;let g:syntastic_auto_loc_list = 0&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_check_on_wq = 1&#xA;let g:syntastic_check_on_w = 1&#xA;let g:syntastic_javascript_checkers = ['eslint']&#xA;&#xA;let g:syntastic_error_symbol = 'x'&#xA;let g:syntastic_warning_symbol = '~'&#xA;let g:syntastic_style_error_symbol = '⚠️'&#xA;let g:syntastic_style_warning_symbol = ''&#xA;&#xA;let NERDTreeShowHidden=1&#xA;autocmd vimenter * NERDTree&#xA;let g:NERDTreeDirArrowExpandable = '&amp;gt;'&#xA;let g:NERDTreeDirArrowCollapsible = 'v'&#xA;&#xA;highlight link SyntasticErrorSign SignColumn&#xA;highlight link SyntasticWarningSign SignColumn&#xA;highlight link SyntasticStyleErrorSign SignColumn&#xA;highlight link SyntasticStyleWarningSign SignColumn&#xA;&#xA;&quot; ---- PEP8 ----&#xA;&quot;&quot; Ignore module level import, and line too long.&#xA;let g:pymode_lint_ignore=&quot;E402,E501&quot;&#xA;&#xA;&quot; choosewin&#xA;nmap - &amp;lt;Plug&amp;gt;(choosewin)&#xA;let g:choosewin_overlay_enable = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20308" LastEditorUserId="20308" LastEditDate="2018-12-26T22:42:14.833" LastActivityDate="2018-12-27T03:49:32.617" Title="Why won't my mapping work &lt;C-W&gt;&lt;Right&gt; z;" Tags="|vimrc|key-bindings|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18399" PostTypeId="2" ParentId="18398" CreationDate="2018-12-26T22:00:59.127" Score="1" Body="&lt;p&gt;If you expect &lt;code&gt;&amp;lt;C-w&amp;gt;&amp;lt;Right&amp;gt;&lt;/code&gt; to do the equivalent of &lt;code&gt;zl&lt;/code&gt; when all is said and done (that is, if you want the &lt;code&gt;;&lt;/code&gt; map recursively expanded), you need &lt;code&gt;nmap&lt;/code&gt; in place of &lt;code&gt;nnoremap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, I would prefer to just&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-W&amp;gt;&amp;lt;Right&amp;gt; zl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that everything is clear; I don’t have to hunt down the semicolon mapping this way. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-12-26T22:00:59.127" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18400" PostTypeId="2" ParentId="18398" CreationDate="2018-12-27T03:49:32.617" Score="1" Body="&lt;p&gt;I had the mapping reversed. I was taking the command &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;Right&amp;gt;&lt;/code&gt; and turning it into &lt;code&gt;z;&lt;/code&gt;, but what i wanted to do was take &lt;code&gt;z;&lt;/code&gt; and turn it into &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;Right&amp;gt;&lt;/code&gt; so &lt;code&gt;z;&lt;/code&gt; switched screens to the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks D. Ben Knoble for pointing out the canonical &quot;how to debug a mapping&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ran &lt;code&gt;:map z;&lt;/code&gt; and found nothing... confused i ran &lt;code&gt;:map &amp;lt;c-w&amp;gt;&amp;lt;Right&amp;gt;&lt;/code&gt; and got back &lt;code&gt;z;&lt;/code&gt; and that's when i realized my mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gotta remember:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;what you want to press&amp;gt; &amp;lt;what you want to do&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not the opposite.&lt;/p&gt;&#xA;" OwnerUserId="20308" LastActivityDate="2018-12-27T03:49:32.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18401" PostTypeId="1" CreationDate="2018-12-27T08:05:11.283" Score="1" ViewCount="196" Body="&lt;p&gt;In my .vimrc file, I add few lines to it so that some file could have nice auto indent, such as .f90 and  .c file, but it also cause autoindent for .plt file. Is there some way like if statement that could fix the problem such that the&#xA;lines are working when I am working on .c or .f90 file and not working when I am working on .plt file?&lt;/p&gt;&#xA;" OwnerUserId="12488" LastEditorUserId="205" LastEditDate="2019-11-06T06:52:19.090" LastActivityDate="2019-11-06T06:52:19.090" Title="How to stop auto indent for some file with particular suffix" Tags="|indentation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18403" PostTypeId="1" CreationDate="2018-12-27T10:55:00.233" Score="1" ViewCount="34" Body="&lt;p&gt;I have some code that I want to 'censor'. For example, I have secret token in a source code &lt;code&gt;1f85ez&lt;/code&gt; and I want to replace it with &lt;code&gt;xxxxxx&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I do it with &lt;code&gt;viwrx&lt;/code&gt; command. Is there way to make such a substitution without visual mode?&lt;/p&gt;&#xA;" OwnerUserId="20314" LastActivityDate="2018-12-27T10:55:00.233" Title="Change a word with a N repating characters where N = word length" Tags="|replace|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18404" PostTypeId="1" CreationDate="2018-12-28T00:13:26.283" Score="3" ViewCount="691" Body="&lt;p&gt;I'm trying to execute simple commands in the vim terminal mode, but cannot get it to work. For example, I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F12&amp;gt; :let $VIM_DIR=expand('%:p:h')&amp;lt;CR&amp;gt;:terminal&amp;lt;CR&amp;gt;cd $VIM_DIR&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to open a terminal in the directory of the current file, but the final &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is ignored. I also tried &lt;code&gt;term_sendkeys(&quot;&quot;,&quot;\&amp;lt;CR&amp;gt;&quot;)&lt;/code&gt; but that didn't have any noticeable effect at all.&lt;/p&gt;&#xA;" OwnerUserId="18613" LastEditorUserId="18613" LastEditDate="2018-12-28T11:27:16.557" LastActivityDate="2021-01-12T06:44:54.053" Title="Execute command in terminal mode at terminal startup" Tags="|terminal-buffer|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18405" PostTypeId="1" AcceptedAnswerId="18409" CreationDate="2018-12-28T03:37:32.657" Score="0" ViewCount="781" Body="&lt;p&gt;I have configured my &lt;code&gt;.vimrc&lt;/code&gt; to make my vim work, and then I renamed my &lt;code&gt;.vimrc&lt;/code&gt; to be &lt;code&gt;.vimrc2&lt;/code&gt;. After that my vim can run as clean mode, but when I run my vim with &lt;code&gt;vim -u .vimrc2&lt;/code&gt;, there are errors like this:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E10: \ should be followed by /, ? or &amp;amp;&#xA;line   59:&#xA;E10: \ should be followed by /, ? or &amp;amp;&#xA;line   60:&#xA;E10: \ should be followed by /, ? or &amp;amp;&#xA;line   61:&#xA;E10: \ should be followed by /, ? or &amp;amp;&#xA;line   73:&#xA;E117: Unknown function: pathogen#infect&#xA;E15: Invalid expression: pathogen#infect()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How could I make it work? My &lt;code&gt;.vimrc2&lt;/code&gt; works well if it is renamed to be &lt;code&gt;.vimrc&lt;/code&gt; and no &lt;code&gt;-u&lt;/code&gt; options are used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;my vimrc is here: &lt;a href=&quot;https://github.com/CoinCheung/learn-coding-notes/blob/master/vim/00-vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/CoinCheung/learn-coding-notes/blob/master/vim/00-vimrc&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18259" LastEditorUserId="18259" LastEditDate="2018-12-28T11:32:48.200" LastActivityDate="2018-12-28T12:18:42.967" Title="how could I use different `.vimrc` with `-u` option" Tags="|vimrc|options|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18406" PostTypeId="1" CreationDate="2018-12-28T05:18:48.157" Score="0" ViewCount="61" Body="&lt;p&gt;I run this command in a common terminal: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ps aux | grep work | grep python | awk '{print $2}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I have three different pids, however, in the vim-term window, the same line gave me two pids. From observation, it seems that it has ignored the first one, what is the cause of this ?&lt;/p&gt;&#xA;" OwnerUserId="18259" LastEditorUserId="51" LastEditDate="2018-12-28T12:21:03.743" LastActivityDate="2018-12-28T12:38:18.257" Title="terminal shell behaves differently from normal shell" Tags="|terminal|shell|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18407" PostTypeId="2" ParentId="18335" CreationDate="2018-12-28T09:06:16.313" Score="3" Body="&lt;p&gt;You have two possible workarounds:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Change the order of entries in &lt;code&gt;g:markdown_fenced_languages&lt;/code&gt; so that &lt;code&gt;'java'&lt;/code&gt; is mentioned before &lt;code&gt;'html'&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Set the global variable &lt;code&gt;java_ignore_javadoc&lt;/code&gt; to some value (like &lt;code&gt;let java_ignore_javadoc=1&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Background:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Java syntax file includes the HTML syntax file to do highlighting of HTML in javadoc comments. After this include, it sets &lt;code&gt;syntax spell default&lt;/code&gt; to prevent spell checking on all texts. See &lt;a href=&quot;https://github.com/vim/vim/blob/c8c8849267503b2d2d6d821047ee8619c7821728/runtime/syntax/java.vim#L158-L161&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By disabling spell checking for &quot;all text&quot; it disables the spell checking for markdown text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the global variable &lt;code&gt;java_ignore_javadoc&lt;/code&gt; is set (workaround 2), the java syntax does not include the html syntax file and does not reset the &lt;code&gt;syntax spell&lt;/code&gt; setting. Then spell checking works, but special highlighting for javadoc is disabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By reloading the html syntax after the java syntax (workaround 1), the setting &lt;code&gt;syntax spell default&lt;/code&gt; (from java) is again overwritten with &lt;code&gt;syntax spell toplevel&lt;/code&gt; from the html syntax. Hence spell checking works again.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2018-12-28T09:06:16.313" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18408" PostTypeId="1" CreationDate="2018-12-28T09:35:52.280" Score="3" ViewCount="366" Body="&lt;p&gt;I am trying to come up with a Vim syntax for python function call, e.g.:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;foo(notarg==0, arg2, kwarg='a', kwarg2='b')&#xA;dict(a=1, b=2, c=3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where we want to highlight&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(i) function name &lt;code&gt;foo&lt;/code&gt;, &lt;code&gt;dict&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;(ii) keyword parameters, e.g. &lt;code&gt;kwarg&lt;/code&gt;, &lt;code&gt;kwarg2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I know there is &lt;a href=&quot;https://vi.stackexchange.com/a/6963/6748&quot;&gt;a great answer&lt;/a&gt; on a similar question. To repeat:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;syn region FCall matchgroup=FName start='[[:alpha:]_]\i*\s*(' end=')' contains=FCall,FCallKeyword&#xA;syn match FCallKeyword /\i*\ze\s*=[^=]/ contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or, alternatively, in &lt;a href=&quot;https://github.com/wookayin/vim-python-enhanced-syntax/blob/master/syntax/python.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;my own vim syntax file for python&lt;/a&gt;, I could manage to achieve a similar behavior:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;syn match   pythonCall   /\&amp;lt;\h\i*\ze\s*(/    contains=pythonBuiltin,pythonBuiltinFunc,pythonBuiltinType&#xA;                                           \ nextgroup=pythonCallRegion skipwhite keepend&#xA;syn region  pythonCallRegion        contained matchgroup=pythonParamsDelim start=/(/  end=/)/ keepend extend&#xA;                                      \ contains=pythonCallComma,pythonCall,@pythonCallArgument,pythonCallArgKeyword&#xA;syn match   pythonCallArgKeyword    contained /\h\i*\ze\s*==\@!/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, the problem is that when &lt;strong&gt;a previously existing syntax group&lt;/strong&gt; (e.g. &lt;code&gt;pythonBuiltinType&lt;/code&gt;) matches function name, the entire highlight for keyword arguments would not work:&lt;/p&gt;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dict(a=1, b=2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where we have the following highlighting rule somewhere (&lt;a href=&quot;https://github.com/python-mode/python-mode/blob/develop/syntax/python.vim#L270&quot; rel=&quot;nofollow noreferrer&quot;&gt;e.g. python-mode&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword pythonBuiltinType dict ....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Given this, &lt;code&gt;dict&lt;/code&gt; matches &lt;code&gt;pythonBuiltinType&lt;/code&gt;, but not matches &lt;code&gt;pythonCall&lt;/code&gt;. This happens for the both ways I just described. A screenshot:&lt;/p&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/vwJEo.png&quot; width=&quot;300&quot;&gt;&#xA;&lt;p&gt;What did I wrong here? Vim syntax is quite difficult, so your help would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="6748" LastEditorUserId="23502" LastEditDate="2023-10-15T20:06:50.360" LastActivityDate="2024-03-13T21:08:25.987" Title="Vim syntax for python call and keyword arguments: issues with built-in keyword" Tags="|syntax-highlighting|filetype-python|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18409" PostTypeId="2" ParentId="18405" CreationDate="2018-12-28T12:18:42.967" Score="5" Body="&lt;p&gt;Vim will automatically set &lt;code&gt;nocompatible&lt;/code&gt; when loading &lt;code&gt;~/.vimrc&lt;/code&gt; or &lt;code&gt;~/.vim/vimrc&lt;/code&gt;. But it's &lt;em&gt;not&lt;/em&gt; set automatically when loading a file with the &lt;code&gt;-u&lt;/code&gt; option, or using &lt;code&gt;:source&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to add &lt;code&gt;set nocompatible&lt;/code&gt; to the &lt;code&gt;.vimrc2&lt;/code&gt; file, or use the &lt;code&gt;-N&lt;/code&gt; flag to set it (&lt;code&gt;vim -N -u .vimrc2&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I think it's always a good idea to add &lt;code&gt;set nocompatible&lt;/code&gt; to vimrc files exactly to avoid this confusion, even if it's not strictly needed when loading from the default locations. But some people are dead-set against it ‍&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2018-12-28T12:18:42.967" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18411" PostTypeId="1" AcceptedAnswerId="18413" CreationDate="2018-12-28T13:27:50.880" Score="1" ViewCount="465" Body="&lt;p&gt;I have a long data line:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/X4267.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/X4267.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;When I switch off wrapping and place the cursor somewhere in the middle, it looks like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uUiVb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uUiVb.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here I see the &amp;quot;extends' listchar, but not the &amp;quot;precedes&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;I also made the window smaller and larger (up to fullscreen), tried various intervals within the line, started vim with &lt;code&gt;.vimrc&lt;/code&gt; and &lt;code&gt;.vim/&lt;/code&gt; removed, and used &lt;code&gt;set listchars=precedes:a,extends:b&lt;/code&gt;: nothing revealed the missing &amp;quot;precedes&amp;quot; char.&lt;/p&gt;&#xA;&lt;p&gt;Is this a bug or do I have to do more than setting the listchars?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;(Debian 9.6, Vim 8.0)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Update on 2023-07-06:&lt;/p&gt;&#xA;&lt;p&gt;I am now on Debian 12.0, Vim 9.0&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;precedes&amp;quot; and &amp;quot;extends&amp;quot; now show either both or not at all:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Gcalf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Gcalf.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you want to see &amp;quot;precedes&amp;quot; and &amp;quot;extends&amp;quot; generally, but are not interested in the rest of the &lt;code&gt;listchars&lt;/code&gt; functionality, add this to your &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZmRVZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZmRVZ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then you have:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/urAjC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/urAjC.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18342" LastEditorUserId="18342" LastEditDate="2023-07-06T08:01:51.107" LastActivityDate="2023-07-07T08:20:38.283" Title="Listchar &quot;precedes&quot; does not show up" Tags="|listchars|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18412" PostTypeId="2" ParentId="2403" CreationDate="2018-12-28T13:40:51.637" Score="0" Body="&lt;p&gt;Use deoplete and &lt;a href=&quot;https://github.com/zchee/deoplete-jedi&quot; rel=&quot;nofollow noreferrer&quot;&gt;deoplete-jedi&lt;/a&gt; if you are open to neovim. In my experience this works quite well, where YCM has a bit of hassles. &lt;/p&gt;&#xA;" OwnerUserId="6748" LastActivityDate="2018-12-28T13:40:51.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18413" PostTypeId="2" ParentId="18411" CreationDate="2018-12-28T13:48:29.057" Score="2" Body="&lt;p&gt;The &quot;extends&quot; char is always visible when wrapping is off and there are additional chars to the right. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other listchars (including &quot;precedes&quot;) are only visible when the option &lt;code&gt;list&lt;/code&gt; is set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't know why.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2018-12-28T13:48:29.057" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18414" PostTypeId="1" AcceptedAnswerId="18434" CreationDate="2018-12-28T14:55:37.137" Score="1" ViewCount="238" Body="&lt;p&gt;I have quickly skimmed through &lt;code&gt;:h user-functions&lt;/code&gt; and a couple random vim plugins and all I could find were patterns like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; one-line short function description&#xA;function foo()&#xA;  &amp;lt;function body here&amp;gt;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I'm not happy with this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any tools / vim plugins that offer the following features:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;a standard syntax that allows verbose documentation of functions, including info about arguments, their type, their meaning, as well as returned values of functions&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;can process vim scripts looking for said docs and generate vim help files&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am looking for something similar to sphinx of python and jsdoc of javascript, but for vim code&lt;/p&gt;&#xA;" OwnerUserId="19475" LastEditorUserId="11357" LastEditDate="2019-07-16T16:03:13.617" LastActivityDate="2019-07-16T16:03:13.617" Title="Best practices and tools for documenting vimscript functions?" Tags="|help-system|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18416" PostTypeId="2" ParentId="18397" CreationDate="2018-12-28T15:31:03.360" Score="1" Body="&lt;p&gt;This works by checking if there is an opening and closing bracket inside the result of a &lt;code&gt;yip&lt;/code&gt;. &lt;code&gt;O&lt;/code&gt; does nothing if used at the top of the document.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CommaInList (eol)&#xA;  &quot; enforce eol?&#xA;  let curLine = getline ('.')&#xA;  let curPos  = getpos  ('.')&#xA;  if a:eol &amp;amp;&amp;amp; (curPos[2] &amp;lt; len(curLine))&#xA;    norm! a^M&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; current line must contain , or [&#xA;  if (match(curLine, '^ *,[^,]*$') != 0) &amp;amp;&amp;amp; (match(curLine, '\[[^\],]*$') == -1)&#xA;    norm! o&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; Cursor must be inside an array&#xA;  norm! m&quot;&quot;ayip'&quot;&#xA;  if match(@a, '[^\[\]]*\[[^,\n]*\n[^\]]*\]') != 0&#xA;    norm! o&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; Comma!&#xA;  let line = repeat(' ', match (curLine, '[,\[][^,\[]*$')).&quot;, &quot;&#xA;  exec ('norm! &quot;=&quot;'.line.'\n&quot;^Mp$')&#xA;endfunction&#xA;&#xA;nmap &amp;lt;silent&amp;gt;o :call CommaInList(0)&amp;lt;cr&amp;gt;a&#xA;nmap &amp;lt;silent&amp;gt;O k:call CommaInList(0)&amp;lt;cr&amp;gt;a&#xA;imap &amp;lt;silent&amp;gt;&amp;lt;cr&amp;gt; &amp;lt;esc&amp;gt;:call CommaInList(1)&amp;lt;cr&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14994" LastEditorUserId="14994" LastEditDate="2018-12-28T17:09:16.017" LastActivityDate="2018-12-28T17:09:16.017" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18417" PostTypeId="1" AcceptedAnswerId="18432" CreationDate="2018-12-28T16:29:51.420" Score="3" ViewCount="3859" Body="&lt;p&gt;I have set my sign column background using&#xA;&lt;code&gt;hi SignColumn ctermbg=236&lt;/code&gt; in my colorscheme file. However, it seems that the background colors for where there are signs has not been changed, and is the same as my default background color. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way of changing the background (and if possible, foreground) colors of signs?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ze9q3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ze9q3.png&quot; alt=&quot;The signcolumn/gutter with mismatched background colors&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: For further clarification I'm using Syntastic to get these signs in my sign column, in case that's relevant.&lt;/p&gt;&#xA;" OwnerUserId="4962" LastEditorUserId="4962" LastEditDate="2018-12-28T16:39:32.883" LastActivityDate="2020-03-08T01:24:27.183" Title="Change color of signs in SignColumn/Gutter" Tags="|colorscheme|plugin-syntastic|color|signs|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18418" PostTypeId="1" AcceptedAnswerId="18419" CreationDate="2018-12-28T16:39:34.510" Score="1" ViewCount="142" Body="&lt;p&gt;Whenever I write &lt;code&gt;];&lt;/code&gt;, in VIM-80 under Cygwin, these symbols get highlighted in yellow. This is a bit annoying and I want it removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following the on-line help I found the file &quot;usr_44.txt&quot;, regarding syntax highlighting. I tried the command &lt;code&gt;:syntax clear&lt;/code&gt;, but no luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It may well be the case that this stems from me learning VIM, pressing keys frustrated while stuck in the editor. Anyway, how can I remove it ?&lt;/p&gt;&#xA;" OwnerUserId="20331" LastActivityDate="2018-12-29T22:46:17.920" Title="Why is this particular keystroke (shown inline) highlighted in VIM version 8.0 under Cygwin, and how to remove it?" Tags="|cygwin|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18419" PostTypeId="2" ParentId="18418" CreationDate="2018-12-29T22:46:17.920" Score="1" Body="&lt;p&gt;As determined in the comments, &lt;code&gt;];&lt;/code&gt; formed the last search pattern (as set by &lt;code&gt;:global&lt;/code&gt;, &lt;code&gt;:substitute&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, or &lt;code&gt;?&lt;/code&gt;—cf. &lt;code&gt;:help quote_/&lt;/code&gt;), and &lt;code&gt;'hlsearch'&lt;/code&gt; was &lt;code&gt;set&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, the characters were highlighted (usually a distinct yellow).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution to (temporarily) stop the highlight is &lt;code&gt;:nohlsearch&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-12-29T22:46:17.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18420" PostTypeId="1" AcceptedAnswerId="18421" CreationDate="2018-12-30T07:30:21.467" Score="-1" ViewCount="1544" Body="&lt;p&gt;I know when you see &lt;code&gt;^M&lt;/code&gt; you can insert it with &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;Enter&lt;/kbd&gt;; and &lt;code&gt;^I&lt;/code&gt; with &lt;kbd&gt;Control&lt;/kbd&gt;+&lt;kbd&gt;Tab&lt;/kbd&gt;. How do you generate a Form Feed &lt;code&gt;^L&lt;/code&gt; for use in &lt;code&gt;:s&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt;? &lt;/p&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="5078" LastEditDate="2018-12-30T08:06:10.477" LastActivityDate="2018-12-30T08:06:18.513" Title="VIM and Carrot L (^L)?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18421" PostTypeId="2" ParentId="18420" CreationDate="2018-12-30T07:30:21.467" Score="0" Body="&lt;p&gt;To generate a Form Feed you can do &lt;kbd&gt;Control&lt;/kbd&gt; + &lt;kbd&gt;L&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="5078" LastEditDate="2018-12-30T08:06:18.513" LastActivityDate="2018-12-30T08:06:18.513" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18422" PostTypeId="2" ParentId="18417" CreationDate="2018-12-30T10:23:22.703" Score="2" Body="&lt;p&gt;&lt;em&gt;Note: Written before OP added the relatively important detail that the signs are generated by Syntastic. Ergo, a general tossing of things against the wall to see what sticks rather than a quick honing in on the actual solution à la the subsequent, accepted answer. It's fine, though.&lt;/em&gt; :P&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems you are at least partially aware of how this works but let's lay it out formally...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you define the sign you specify the &lt;em&gt;highlighting group&lt;/em&gt; to be used when that sign is displayed. (Run &lt;code&gt;:hi&lt;/code&gt; to see all of your currently defined groups.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, a sign that will have the same background color (&lt;em&gt;and&lt;/em&gt; foreground color!) as one's &lt;code&gt;'colorcolumn'&lt;/code&gt; columns could be defined like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sign define mysign text=|&amp;gt; texthl=ColorColumn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From there you don't need to do anything special. When you place a sign it should have the expected coloring. So let's check off some boxes. Are you/have you...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using a recent version of Vim?&lt;/li&gt;&#xA;&lt;li&gt;Making sure the highlight group has set &lt;code&gt;guibg&lt;/code&gt; if you are using GUI vim or &lt;code&gt;ctermbg&lt;/code&gt; if you're using terminal vim?&lt;/li&gt;&#xA;&lt;li&gt;Defined a sign manually with a &quot;clean&quot; version of vim and known-to-be-working highlight group (check it with &lt;code&gt;:hi HlGroupName&lt;/code&gt;)?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(By &quot;clean&quot; I mean you can, for example, start vim without any plugins using &lt;code&gt;vim --noplugin&lt;/code&gt; and/or try it without any vimrc file using &lt;code&gt;vim -u NONE&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-03-08T01:24:27.183" LastActivityDate="2020-03-08T01:24:27.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18423" PostTypeId="1" AcceptedAnswerId="18424" CreationDate="2018-12-30T11:25:52.287" Score="1" ViewCount="237" Body="&lt;p&gt;I'm trying to write a command for adding a Python import line. The problem is that what's added it &lt;code&gt;import a:name&lt;/code&gt; and not the module name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! PyImport(name)&#xA;    w&#xA;    silent !isort -q -a a:name %&#xA;    e&#xA;endfunc&#xA;comm! -nargs=1 PyImport call PyImport(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess I need to someone expand &lt;code&gt;a:name&lt;/code&gt;, couldn't find how to do it.&#xA;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20342" LastActivityDate="2018-12-30T12:33:25.453" Title="Function arguments + shell" Tags="|vimscript|external-command|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18424" PostTypeId="2" ParentId="18423" CreationDate="2018-12-30T12:23:53.147" Score="2" Body="&lt;p&gt;Try it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent execute('!isort -q -a ' . a:name . ' ' . expand(&quot;%:p&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This executes the given string. The &lt;code&gt;expand(&quot;%:p&quot;)&lt;/code&gt; creates the fully qualified file name for the current file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: I would recommend to add &lt;code&gt;set autoload&lt;/code&gt; before executing and &lt;code&gt;set noautoload&lt;/code&gt; after it. That way the file will automatically be reloaded after execute. No need for &lt;code&gt;e&lt;/code&gt; then.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2018-12-30T12:33:25.453" LastActivityDate="2018-12-30T12:33:25.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18425" PostTypeId="1" AcceptedAnswerId="18427" CreationDate="2018-12-30T12:33:20.647" Score="-2" ViewCount="57" Body="&lt;p&gt;I want to sort my database by regex, but don't know exactly how to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The editor I use is Atom&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's example of input (the entire file has 10,000 lines)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x1.83&#xA;30.12.2018, 12:05:29&#xA;1386834&#xA;30&#xA;x2.66&#xA;30.12.2018, 12:05:01&#xA;1386833&#xA;30&#xA;x2.12&#xA;30.12.2018, 12:04:36&#xA;1386832&#xA;30&#xA;x2.51&#xA;30.12.2018, 12:04:09&#xA;1386831&#xA;30&#xA;x2.19&#xA;30.12.2018, 12:03:44&#xA;1386830&#xA;30&#xA;x1.04&#xA;30.12.2018, 12:03:31&#xA;1386829&#xA;30&#xA;x4.18&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I want, as a output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x1.83&#xA;x2.66&#xA;x2.12&#xA;x2.51&#xA;x2.19&#xA;x1.04&#xA;x4.18&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can someone help me with this ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;P.S.&lt;/strong&gt; On the other hand - is it possible to copy values from specific class by chrome inspector ?  &lt;/p&gt;&#xA;" OwnerUserId="20348" LastActivityDate="2018-12-30T15:49:30.303" Title="Deleting 3 lines of code every 4" Tags="|regular-expression|" AnswerCount="1" CommentCount="6" ClosedDate="2019-01-02T17:17:04.977" ContentLicense="CC BY-SA 4.0" />
  <row Id="18426" PostTypeId="1" AcceptedAnswerId="18429" CreationDate="2018-12-30T14:55:51.453" Score="1" ViewCount="1707" Body="&lt;p&gt;Is it possible to show all changes made to a buffer since the buffer was opened?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question &lt;a href=&quot;https://stackoverflow.com/questions/749297/can-i-see-changes-before-i-save-my-file-in-vim&quot;&gt;https://stackoverflow.com/questions/749297/can-i-see-changes-before-i-save-my-file-in-vim&lt;/a&gt; is related, but asks for changes since the last write, which can easily be accomplished by looking at the file on the file system. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using persistent undo (&lt;code&gt;set undofile&lt;/code&gt;), so I cannot use &lt;code&gt;:earlier &amp;lt;reallylargenumber&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18613" LastActivityDate="2019-01-15T21:25:03.280" Title="Show changes since buffer was opened" Tags="|vimdiff|undo-redo|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18427" PostTypeId="2" ParentId="18425" CreationDate="2018-12-30T15:12:18.633" Score="3" Body="&lt;h3&gt;The Vim way&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Basically, you are trying to delete lines which starts with numbers and to select only those lines you can use a simple regex like this: &lt;code&gt;^\d.\+$&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find the matches by prefixing the regex with a &lt;code&gt;/&lt;/code&gt;, i.e, &lt;code&gt;/^\d.\+$&lt;/code&gt;. This will only match the lines starting with a number, you can delete those lines with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\d.\+$/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will produce your preferred output. For more info see &lt;code&gt;:help :global&lt;/code&gt; and &lt;code&gt;:help pattern.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In command line you can directly do this without opening vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim datafile -es +&quot;g/^\d.\+$/d&quot; +&quot;w\! new_datafile&quot; +&quot;qa\!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Other ways&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sed&lt;/code&gt; way : &lt;code&gt;sed -nre '/^x[0-9]+\.[0-9]+$/p' datafile&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;grep&lt;/code&gt; way: &lt;code&gt;grep -v &quot;^[0-9].*$&quot; datafile&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;awk&lt;/code&gt; way : &lt;code&gt;awk '/^x[0-9]+\.[0-9]+$/' datafile&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;perl&lt;/code&gt; way: &lt;code&gt;perl -ne &quot;print if /^x[0-9]+\.[0-9]+$/&quot; datafile&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To save it I usually redirect the output to a new file ( there is also in-place editing mode you can check ), like this &lt;code&gt;cmd &amp;gt; new_datafile&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="19211" LastEditorUserId="19211" LastEditDate="2018-12-30T15:49:30.303" LastActivityDate="2018-12-30T15:49:30.303" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18428" PostTypeId="2" ParentId="18426" CreationDate="2018-12-30T15:35:00.743" Score="-1" Body="&lt;p&gt;This will do what you're looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !diff % -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20323" LastActivityDate="2018-12-30T15:35:00.743" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18429" PostTypeId="2" ParentId="18426" CreationDate="2018-12-30T16:49:13.057" Score="2" Body="&lt;p&gt;I played around. Could you try the following (rarely tested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost * let b:undo_seq_load=changenr()&#xA;&#xA;function! DiffSinceLoad()&#xA;    let tmpa = tempname()&#xA;    let tmpb = tempname()&#xA;    let curchange=changenr()&#xA;    exe &quot;undo &quot; . b:undo_seq_load&#xA;    exec 'w '.tmpa&#xA;    exe &quot;undo &quot; . curchange&#xA;    exec 'w '.tmpb&#xA;    update&#xA;    exec 'tabnew '.tmpa&#xA;    diffthis&#xA;    vert split&#xA;    exec 'edit '.tmpb&#xA;    diffthis&#xA;endfunction&#xA;command! -nargs=0 DiffSinceLoad call DiffSinceLoad()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is based on &lt;a href=&quot;https://stackoverflow.com/a/749338/7369280&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second iteration: This is now in my vimrc.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use only one temporary file&lt;/li&gt;&#xA;&lt;li&gt;If the buffer with the temporary file gets hidden, it is deleted.&lt;/li&gt;&#xA;&lt;li&gt;When the buffer with the temporary file is deleted, &lt;code&gt;:diffoff&lt;/code&gt; is called via autocmd.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; store the changenr at file load&#xA;autocmd BufReadPost * let b:changenr_on_load=changenr()&#xA;function! DiffSinceLoad()&#xA;    let tmpa = tempname()&#xA;    let curchange=changenr()&#xA;    exe &quot;undo &quot; . b:changenr_on_load&#xA;    exe 'w ' . tmpa&#xA;    exe 'undo ' . curchange&#xA;    &quot;diffthis&#xA;    exe 'vertical diffsplit ' . tmpa&#xA;    &quot; when buffer gets hidden, delete it and reset diff settings&#xA;    setlocal bufhidden=delete&#xA;    autocmd BufDelete &amp;lt;buffer&amp;gt; diffoff&#xA;    &quot; return to edited file&#xA;    wincmd p&#xA;endfunction&#xA;command! -nargs=0 DiffSinceLoad silent call DiffSinceLoad()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-15T21:25:03.280" LastActivityDate="2019-01-15T21:25:03.280" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18430" PostTypeId="1" CreationDate="2018-12-30T18:04:53.867" Score="2" ViewCount="3226" Body="&lt;p&gt;If my cursor is at position * below, how can I enter insert mode at the beginning of the next line &lt;em&gt;without&lt;/em&gt; creating a newline? &lt;code&gt;o&lt;/code&gt; does what I want, except that it adds an additional unwanted line into the block that I then have to delete.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*let(:foo) do&#xA;&#xA; end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20351" LastEditorUserId="2920" LastEditDate="2018-12-30T20:36:17.527" LastActivityDate="2018-12-30T20:41:59.473" Title="How to enter insert mode on the next line without creating a new line?" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18431" PostTypeId="2" ParentId="18430" CreationDate="2018-12-30T20:41:59.473" Score="3" Body="&lt;p&gt;As Ralf said in the comments, there is no built-in command that does this. I would recommend using either &lt;code&gt;ji&lt;/code&gt;, &lt;code&gt;jI&lt;/code&gt;, or &lt;code&gt;jA&lt;/code&gt; for this purpose, since those are all only two keys, and they're fairly normal vim idioms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you'd really like to do this with a single keystroke, you could always overwrite the &lt;code&gt;o&lt;/code&gt; command to not make a newline. To do this, add &lt;em&gt;one of&lt;/em&gt; the following lines to your &lt;code&gt;.vimrc&lt;/code&gt; (depending on which behavior you want):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Enter insert mode at the beginning of the next line&#xA;nnoremap o j0i&#xA;&#xA;&quot; Enter insert mode at the end of the next line&#xA;nnoremap o jA&#xA;&#xA;&quot; Enter insert mode at the first non-whitespace character&#xA;nnoremap o jI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that the lines starting with &lt;code&gt;&quot;&lt;/code&gt; are just comments)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this overwrites &lt;code&gt;o&lt;/code&gt; which I think is a very useful command. Normally, to add your own shortcuts without overwriting the default ones, it's standard to use &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;. However in this case, something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;o ji&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would be pretty pointless since it's not any shorter than just manually doing it with &lt;code&gt;ji&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2018-12-30T20:41:59.473" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18432" PostTypeId="2" ParentId="18417" CreationDate="2018-12-31T04:55:32.083" Score="1" Body="&lt;p&gt;From the docs (&lt;code&gt;:help syntastic-error-signs&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Signs are colored using the Error and Todo syntax highlight groups by default&#xA;(see |group-name|). If you wish to customize the colors for the signs, you&#xA;can use the following groups:&#xA;    SyntasticErrorSign - For syntax errors, links to &quot;error&quot; by default&#xA;    SyntasticWarningSign - For syntax warnings, links to &quot;todo&quot; by default&#xA;    SyntasticStyleErrorSign - For style errors, links to &quot;SyntasticErrorSign&quot;&#xA;                              by default&#xA;    SyntasticStyleWarningSign - For style warnings, links to&#xA;                                &quot;SyntasticWarningSign&quot; by default&#xA;&#xA;Example: &amp;gt;&#xA;    highlight SyntasticErrorSign guifg=white guibg=red&#xA;&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2018-12-31T04:55:32.083" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18433" PostTypeId="1" AcceptedAnswerId="18509" CreationDate="2018-12-31T06:46:06.707" Score="15" ViewCount="29212" Body="&lt;p&gt;I've got Vim installed on MacOS using Brew and it installs with &lt;code&gt;+python3&lt;/code&gt; support for Python 3.7.2 by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm writing a Vim plugin which utilises some Python 3.7 and would like this to be able to work on parity with Linux with how it works on MacOS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a Docker container with Ubuntu Bionic I've tried installing Python 3.7.2 and Vim; and it installs Python 3.6 and links to this version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried installing Vim from source in the container and it will build for 3.6 but not for 3.7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Linux, running the following to configure the build:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --with-features=huge --enable-cscope --enable-multibyte \&#xA;  --enable-rubyinterp --enable-pythoninterp --enable-python3interp \&#xA;  --with-python3-config-dir=/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu \&#xA;  --enable-fail-if-missing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;fails with the message:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;checking if compile and link flags for Python 3 are sane... no&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've thought of downgrading the MacOS Vim version to 3.6 and coding the plugin to that version but thought I would explore options to get it working on Linux with Python 3.7 first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if this is not the appropriate forum for this question, please let me know and I will move it to a stack-exchange site more appropriate.&lt;/p&gt;&#xA;" OwnerUserId="7119" LastEditorUserId="23502" LastEditDate="2022-09-16T16:13:06.783" LastActivityDate="2022-09-16T16:13:06.783" Title="Installing or building vim with +python3 support for Python 3.7.x on linux" Tags="|macos|vimscript-python|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18434" PostTypeId="2" ParentId="18414" CreationDate="2018-12-31T18:35:58.663" Score="1" Body="&lt;p&gt;I've never encountered anything that matches both of the specific specs you mention but I know of a &lt;a href=&quot;https://wolfgangmehner.github.io/vim-plugins/vimsupport.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim plugin&lt;/a&gt; that offers some of what you mention in the first item, i.e. documentation assistance. For instance, you can easily insert a template-based, verbose function doc/comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given this Vim function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! compare ( thee, summers_day )&#xA;    &quot; something&#xA;endfunction   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can put the cursor on the first line and hit &lt;code&gt;\ca&lt;/code&gt; and this will be generated:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;===  FUNCTION  ================================================================&#xA;&quot;          NAME:  compare&#xA;&quot;   DESCRIPTION:  &amp;lt;+DESC+&amp;gt;&#xA;&quot;    PARAMETERS:  thee - &amp;lt;+DESCRIPTION+&amp;gt;&#xA;&quot;                 summers_day - &amp;lt;+DESCRIPTION+&amp;gt;&#xA;&quot;       RETURNS:  &#xA;&quot;===============================================================================&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think the cursor is put on the first &quot;form field&quot; and you can hit &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;J&lt;/kbd&gt; to move to subsequent fields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin is called &lt;a href=&quot;https://wolfgangmehner.github.io/vim-plugins/vimsupport.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Support&lt;/a&gt; and, FYI, they have similar Vim plugins that support other languages such as Bash, Perl and C/C++. They are linked to that same page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of other key mappings that will insert file header, date-times, if/else/elseif, try/catch, for, etc. outlines, iterator templates, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One more example...given&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let x = sqrt ( y )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Select this with Visual mode and hit &lt;code&gt;\sie&lt;/code&gt; and you'll get...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if |&#xA;  let x = sqrt ( y )&#xA;else&#xA;  &amp;lt;+ELSE_PART+&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The tag in the &lt;code&gt;else&lt;/code&gt; block can be jumped and overwritten with your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also create custom &quot;snippets&quot;; personal templates that include anything you can think of. They're tied to a key mapping + menu selection.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2018-12-31T18:46:57.097" LastActivityDate="2018-12-31T18:46:57.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18435" PostTypeId="1" AcceptedAnswerId="18492" CreationDate="2019-01-01T00:54:04.333" Score="0" ViewCount="285" Body="&lt;p&gt;I would like to have a file extension aware &lt;code&gt;:FZF&lt;/code&gt; command, so that when I choose a file with enter from the fzf prompt, and that file has an extension that matches a list (say &lt;code&gt;(pdf|mp3|jpg)&lt;/code&gt;), it opens the file with some external bash command (say &lt;code&gt;open&lt;/code&gt;, I'm on mac), and otherwhise just opens it in vim buffer ar normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:fzf_action = {&#xA;  \ 'ctrl-t': 'tab split',&#xA;  \ 'ctrl-x': '!open',&#xA;  \ 'ctrl-v': 'vsplit', }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which lets me open files with an external program with &lt;code&gt;ctrl-x&lt;/code&gt; from the prompts, but my brain can't handle this very well and I often press enter instead of &lt;code&gt;ctrl-x&lt;/code&gt;. One single context aware command would be much better.&lt;/p&gt;&#xA;" OwnerUserId="3316" LastEditorUserId="2920" LastEditDate="2019-01-01T02:05:55.870" LastActivityDate="2019-01-08T15:34:18.733" Title="Context aware fzf command" Tags="|plugin-fzf|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18436" PostTypeId="1" CreationDate="2019-01-01T07:52:53.627" Score="2" ViewCount="88" Body="&lt;p&gt;Is there an analog of &lt;a href=&quot;https://www.emacswiki.org/emacs/MultipleModes#toc8&quot; rel=&quot;nofollow noreferrer&quot;&gt;mmm&lt;/a&gt; mode for vim? This would allow me to have syntax highlighting of several modes in the same file.  &lt;/p&gt;&#xA;" OwnerUserId="13566" LastActivityDate="2019-01-01T13:45:13.143" Title="Analog of mmm mode" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18437" PostTypeId="2" ParentId="18436" CreationDate="2019-01-01T13:45:13.143" Score="2" Body="&lt;p&gt;This is typically done using &lt;a href=&quot;https://vimhelp.appspot.com/syntax.txt.html#%3asyn-include&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:syn-include&lt;/code&gt;&lt;/a&gt; to include another language's syntax rules for a specified region of a parent syntax file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The child syntax needs to be included as its own cluster:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn include @otherLang path/to/syntax/otherLang.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then a region in the parent syntax is defined where the child syntax should apply:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region otherLangRegion start=startRegex end=endRegex contains=@otherLang&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see this pattern in the syntax file for &lt;a href=&quot;https://github.com/vim/vim/blob/bbea47075cc4e7826e9f8c203e4272ba023ed7b0/runtime/syntax/vim.vim#L624-L794&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim script itself&lt;/a&gt; (which includes highlighting for lua, perl, ruby, python, tcl, and mzscheme) as well as the &lt;a href=&quot;https://github.com/vim/vim/blob/bbea47075cc4e7826e9f8c203e4272ba023ed7b0/runtime/syntax/html.vim#L207-L250&quot; rel=&quot;nofollow noreferrer&quot;&gt;html syntax file&lt;/a&gt; (which allows highlighting javascript, css, and vb).&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2019-01-01T13:45:13.143" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18441" PostTypeId="2" ParentId="4902" CreationDate="2019-01-01T23:04:32.327" Score="3" Body="&lt;p&gt;Take a look at this post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Combine it with @romainl answer and you can do whatever you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&#xA;Let's say I want to add a &lt;code&gt;const&lt;/code&gt; to the functions which doesn't have them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    handleChange = value =&amp;gt; {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;VIM script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\([ ]*\)\(\w* = .*$\)\&amp;amp;^\(\&amp;amp;\(.*const.*\)\@!.\)*$/\1const \2/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    const handleChange = value =&amp;gt; {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\([ ]*\)\(\w* = .*$\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;- get me all lines which has &lt;code&gt;word =&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;- combine rules&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^\(\&amp;amp;\(.*const.*\)\@!.\)*$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;- the line shouldn't contain &lt;code&gt;const&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3001" LastActivityDate="2019-01-01T23:04:32.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18442" PostTypeId="2" ParentId="15082" CreationDate="2019-01-02T06:14:22.133" Score="0" Body="&lt;pre&gt;&lt;code&gt;autocmd FileType cpp syntax region doxygenComment start=&quot;/\*\!&quot; end=&quot;\*/&quot; fold&#xA;autocmd FileType cpp syntax sync fromstart&#xA;autocmd FileType cpp setlocal foldmethod=syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help syn-fold&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be able to use &lt;code&gt;syntax sync ccomment doxygenComment&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6857" LastActivityDate="2019-01-02T06:14:22.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18443" PostTypeId="2" ParentId="16991" CreationDate="2019-01-02T11:56:51.527" Score="0" Body="&lt;p&gt;In fact &lt;kbd&gt;Ctrl-h&lt;/kbd&gt; is ASCII &lt;code&gt;0x08&lt;/code&gt;. If you look this up in a ASCII table, it is defined as &quot;backspace&quot;. The &lt;kbd&gt;Backspace&lt;/kbd&gt; is ASCII &lt;code&gt;0x7f&lt;/code&gt; (127dec). In ASCII this is defined as &quot;DEL&quot;. In UNIX-like environments both keys delete the character to the left of the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim insert mode, both keys delete the character to the left of the cursor. In normal mode both keys just move the cursor to the left (without deleting). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how &lt;kbd&gt;Ctrl-h&lt;/kbd&gt; was handled in normal mode of the original Vi, but i think that &lt;kbd&gt;h&lt;/kbd&gt; and &lt;kbd&gt;Ctrl-h&lt;/kbd&gt; leads to the same cursor movement is just a coincident.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Wikipedia &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII&quot; rel=&quot;nofollow noreferrer&quot;&gt;ASCII&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Wikipedia &lt;a href=&quot;https://en.wikipedia.org/wiki/Delete_character&quot; rel=&quot;nofollow noreferrer&quot;&gt;Delete Character&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Why was hjkl used for cursor movement? See keyboard layout of the &lt;a href=&quot;https://en.wikipedia.org/wiki/ADM-3A&quot; rel=&quot;nofollow noreferrer&quot;&gt;ADM-3A terminal&lt;/a&gt; or &lt;a href=&quot;http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;BTW: What code the key &lt;kbd&gt;Backspace&lt;/kbd&gt; actually sends might be defined &#xA;  by the terminal. In GNOME-Terminal it can be defined to send &lt;code&gt;Ctrl-H&lt;/code&gt;, &#xA;  &quot;ASCII DEL&quot;, &quot;Escape Sequence&quot; or &quot;TTY Erase&quot;. &#xA;  AFAIK &quot;ASCII DEL&quot; is the default.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-03T12:40:29.247" LastActivityDate="2019-01-03T12:40:29.247" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18444" PostTypeId="1" AcceptedAnswerId="18445" CreationDate="2019-01-03T14:12:58.863" Score="0" ViewCount="178" Body="&lt;p&gt;I have been trying to make a macro to allow me to check in/out files via the vim command line. Currently what I have which &quot;sort of&quot; works is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap :checkout :! cleartool checkout -nc %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see there is a bit of redundancy using nmap.  I was under the impression that cmap created a macro which only functioned in the command line, so I thought I could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmap checkout ! cleartool checkout -nc %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however this seems to be creating a recursive loop which crashes vim.  Is there something I'm missing?  would I want to use a different map or is my syntax wrong?&lt;/p&gt;&#xA;" OwnerUserId="18199" LastActivityDate="2019-01-03T15:08:31.920" Title="cmap macros not working as expected" Tags="|key-bindings|macro|cmdline|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18445" PostTypeId="2" ParentId="18444" CreationDate="2019-01-03T14:24:18.733" Score="2" Body="&lt;p&gt;I guess that you want to create a new command. Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command Checkout :!cleartool checkout -nc %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows you to run &lt;code&gt;cleartool checkout&lt;/code&gt; from Vim with the command &lt;code&gt;:Checkout&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: User defined commands must start with a upper case letter.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-03T15:08:31.920" LastActivityDate="2019-01-03T15:08:31.920" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18446" PostTypeId="1" AcceptedAnswerId="18447" CreationDate="2019-01-03T14:58:12.193" Score="7" ViewCount="1409" Body="&lt;p&gt;I'm appending text to &quot;a&quot; register with:&lt;code&gt;&quot;AyW&lt;/code&gt;.&lt;br&gt;&#xA;If I wanted to repeat last change I would use:&lt;code&gt;.&lt;/code&gt; But in this case I would like to repeat the last &lt;strong&gt;yank&lt;/strong&gt; command.&lt;br&gt;&#xA;Is there a command to repeat the last yank (append)? or should I use &lt;code&gt;q&lt;/code&gt; to record a macro instead?&lt;/p&gt;&#xA;" OwnerUserId="20393" LastActivityDate="2019-01-03T15:29:51.160" Title="Repeat last yank" Tags="|cut-copy-paste|register|repeated-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18447" PostTypeId="2" ParentId="18446" CreationDate="2019-01-03T15:29:51.160" Score="11" Body="&lt;p&gt;If you include the flag &lt;code&gt;y&lt;/code&gt; in the &lt;code&gt;cpoptions&lt;/code&gt; option;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cpoptions+=y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then yanks may be repeated using &lt;code&gt;.&lt;/code&gt;.  See &lt;code&gt;:help cpo-y&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *cpo-y*&#xA;    y   A yank command can be redone with &quot;.&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-01-03T15:29:51.160" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18448" PostTypeId="1" AcceptedAnswerId="18508" CreationDate="2019-01-03T16:30:12.790" Score="0" ViewCount="1010" Body="&lt;p&gt;In gvim normal mode, the &lt;code&gt;*&lt;/code&gt; key searches for the word under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say I have a file with the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;life&#xA;alifexea a_life_xea&#xA;a life x&#xA;a=life&#xA;life=a&#xA;b=life;&#xA;c=b?life:a;&#xA;life?&#xA;?life&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The cursor is in first line. I press &lt;code&gt;*&lt;/code&gt; in normal mode. I expect and want all &quot;life&quot; to get highlighted except the 2nd line which has &quot;alifexea a_life_xea&quot;. But it doesn't highlight the last 3 lines since the &lt;code&gt;?&lt;/code&gt; is probably considered a normal character. If I search using &lt;code&gt;/life&lt;/code&gt; then all lines get highlighted which I do not want. Is there a way around (some setting) to make sure my expectation is satisfied when I search using &lt;code&gt;*&lt;/code&gt;?.&lt;/p&gt;&#xA;" OwnerUserId="20395" LastEditorUserId="2920" LastEditDate="2019-01-03T16:33:04.130" LastActivityDate="2019-01-09T15:27:29.230" Title="Asterisk search does not find text with question marks" Tags="|search|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18450" PostTypeId="1" CreationDate="2019-01-04T02:52:41.373" Score="1" ViewCount="196" Body="&lt;p&gt;I want to extend the &lt;a href=&quot;https://github.com/easymotion/vim-easymotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;easymotion&lt;/a&gt; Plugin to take some action after the jump. To explain to those who are not familiar with this plugin, I will use the following simplified example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say in a plugin &lt;em&gt;UsefulPlugin&lt;/em&gt; the following map is defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Goto()&#xA;    let char = nr2char(getchar())&#xA;    return &quot;f&quot; . char&#xA;endfunction&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Plug&amp;gt;(goto) s:Goto()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which does almost the same as the unmapped &lt;code&gt;f&lt;/code&gt;: jump to the next char input by &lt;code&gt;getchar&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now as a user, I want to define a map that uses &lt;code&gt;&amp;lt;Plug&amp;gt;(goto)&lt;/code&gt; and after the user input the char, jump to that char and delete until end of line. &#xA;&lt;em&gt;As an illustration: the effect of this mapping should be equivalent to&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:GotoAndMore()&#xA;    let char = nr2char(getchar())&#xA;    return &quot;f&quot; . char . &quot;D&quot;&#xA;endfunction&#xA;nnoremap &amp;lt;expr&amp;gt; fD s:GotoAndMore()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question is: how can I achieve this with &lt;code&gt;&amp;lt;Plug&amp;gt;(goto)&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2019-01-04T03:12:39.777" LastActivityDate="2019-01-04T23:34:33.120" Title="remap to a map calling getchar() internally" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18452" PostTypeId="2" ParentId="18450" CreationDate="2019-01-04T08:29:23.090" Score="2" Body="&lt;p&gt;This is hackish and I'm not sure how this works if &lt;code&gt;s:Goto&lt;/code&gt; calls another script-internal function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume that the &lt;code&gt;s:Goto()&lt;/code&gt; is already defined in another script.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GotoAndMore()&#xA;    &quot; Get the mapping for &amp;lt;Plug&amp;gt;(goto)&#xA;    redir =&amp;gt; xx | silent map &amp;lt;Plug&amp;gt;(goto) | redir end&#xA;    &quot; extract the function name (incl script number)&#xA;    let funcName = matchstr(xx, &quot;&amp;lt;SNR&amp;gt;[^(]*&quot;)&#xA;    &quot; create a funcref for it&#xA;    let Func = function(funcName)&#xA;    &quot; return function return value with following &quot;D&quot; &#xA;    return Func() . &quot;D&quot;&#xA;endfunction&#xA;nnoremap &amp;lt;expr&amp;gt; fD GotoAndMore()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Test thoroughly! &lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-04T08:29:23.090" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18453" PostTypeId="1" CreationDate="2019-01-04T09:34:34.950" Score="6" ViewCount="5867" Body="&lt;p&gt;I'm using vim 8.1 on windows.&#xA;The IT department has set $HOME to a slow network drive.&#xA;Every time a file gets written to $HOME vim slows down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have $VIM/vimrc with the following content.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $HOME = $USERPROFILE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This used to work, but now netrw still creates files on the network drive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I change $HOME so that no slowdown occurs?&lt;/p&gt;&#xA;" OwnerDisplayName="user20406" LastActivityDate="2022-08-16T15:55:13.230" Title="Change $HOME before it gets accessed" Tags="|vimrc|microsoft-windows|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18454" PostTypeId="1" AcceptedAnswerId="18455" CreationDate="2019-01-04T09:45:26.103" Score="5" ViewCount="1631" Body="&lt;p&gt;Vim highlights the &lt;em&gt;background&lt;/em&gt; of certain words (e.g. when doing spellchecking) in a way that I would like to change (because the background and the word itself are almost of the same color, which makes the whole thing illegible). How is it possible to determine which &quot;background&quot; (?) highlighting group (?) vim is using, so that it can be customized?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did find an &lt;a href=&quot;https://vi.stackexchange.com/questions/13137/how-to-identify-the-highlight-groups-in-use-on-a-particular-character&quot;&gt;apparently similar-looking question&lt;/a&gt;, but its answer does not offer the simplest response (Ralf's answer below is simpler already), and more importantly, it doesn't cover the colors of the &lt;em&gt;background&lt;/em&gt; (it displays the highlighting group of the text &lt;em&gt;foreground&lt;/em&gt;).&lt;/p&gt;&#xA;" OwnerUserId="16967" LastEditorUserId="16967" LastEditDate="2019-01-04T16:50:24.930" LastActivityDate="2019-01-04T22:34:43.557" Title="How to know which highlighting group is used for the background of a word?" Tags="|syntax-highlighting|terminal|highlight|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="18455" PostTypeId="2" ParentId="18454" CreationDate="2019-01-04T10:08:25.627" Score="7" Body="&lt;p&gt;I have the following in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command SynID  echo synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 1), &quot;name&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Move the cursor to the word you are interested in and then execute &lt;code&gt;:SynID&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The spell checker can set the background of the word independently. It uses the names &quot;SpellBad&quot;, &quot;SpellCap&quot;, &quot;SpellLocal&quot; and &quot;SpellRare&quot;. Definition can be printed with &lt;code&gt;:highlight SpellBad&lt;/code&gt;, etc., so that you can probably recognize which style is used by the spell checker that causes a problem for you. Also see &lt;code&gt;:help hl-SpellBad&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="16967" LastEditDate="2019-01-04T22:34:43.557" LastActivityDate="2019-01-04T22:34:43.557" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18456" PostTypeId="1" AcceptedAnswerId="18457" CreationDate="2019-01-04T11:35:04.000" Score="0" ViewCount="1309" Body="&lt;p&gt;Reason for my question: It's not the first time I have cancelled my arrow keys in vim, and the improvments in my typing is again &lt;strong&gt;tremendous&lt;/strong&gt;. I wish to keep arrow keys non effective inside vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HOWEVER: Like the last time, I stumble on the same thing that made me remove the arrow disabling. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot navigate between the proposals of autocompletion. I simply can't if my arrows are &quot;cancelled&quot;. Hjkl are taken as letters, not move commands here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what should be corrected in my &lt;code&gt;.vimrc&lt;/code&gt; file ?:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap  &amp;lt;Up&amp;gt; &quot;&quot;&#xA;noremap! &amp;lt;Up&amp;gt; &amp;lt;Esc&amp;gt;&#xA;noremap  &amp;lt;Down&amp;gt; &quot;&quot;&#xA;noremap! &amp;lt;Down&amp;gt; &amp;lt;Esc&amp;gt;&#xA;noremap  &amp;lt;Left&amp;gt; &quot;&quot;&#xA;noremap! &amp;lt;Left&amp;gt; &amp;lt;Esc&amp;gt;&#xA;noremap  &amp;lt;Right&amp;gt; &quot;&quot;&#xA;noremap! &amp;lt;Right&amp;gt; &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1682" LastEditorUserId="1682" LastEditDate="2019-01-04T11:48:05.443" LastActivityDate="2023-06-04T05:44:36.023" Title="How to navigate in auto completion menu, when arrows are disabled in .vimrc" Tags="|key-bindings|autocompletion|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18457" PostTypeId="2" ParentId="18456" CreationDate="2019-01-04T11:39:24.547" Score="3" Body="&lt;p&gt;You should be able to use &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; and &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt; for the previous/next item on the list.&lt;/p&gt;&#xA;" OwnerUserId="15134" LastEditorUserId="1682" LastEditDate="2019-01-04T15:39:12.227" LastActivityDate="2019-01-04T15:39:12.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18458" PostTypeId="2" ParentId="18453" CreationDate="2019-01-04T11:45:27.793" Score="0" Body="&lt;p&gt;You can use the &lt;code&gt;-u&lt;/code&gt; option to give an alternate &lt;em&gt;.vimrc&lt;/em&gt; file of your choice when starting vim. As stated &lt;a href=&quot;https://stackoverflow.com/a/4618301/4211238&quot;&gt;here&lt;/a&gt;, you can also use the &lt;code&gt;$MYVIMRC&lt;/code&gt; variable to automate this (this takes precedence over &lt;code&gt;$HOME&lt;/code&gt;), which should answer your question.&lt;/p&gt;&#xA;" OwnerUserId="15134" LastActivityDate="2019-01-04T11:45:27.793" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18459" PostTypeId="2" ParentId="18453" CreationDate="2019-01-04T13:07:03.980" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Turns out the culprit was &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/vimrc_example.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;in my $HOME/_vimrc. After removing it no files were created anymore.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Never mind. After more testing it didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a vimrc in $VIM with following content&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $HOME = $USERPROFILE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This however is not a perfect solution.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the documentation it first searches $HOME and then $VIM. This means there is a slow access to the network drive to check if there exists a vimrc. This is quite noticeable. To fix that you either have to somehow undo the work of the IT guys or open Vim with -u everywhere. Or just keep Vim open forever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you use an editor with manners that saves its configuration in %appdata% like it's supposed to. I'm out.&lt;/p&gt;&#xA;" OwnerDisplayName="user20406" LastEditorDisplayName="user20406" LastEditDate="2019-01-04T13:44:31.017" LastActivityDate="2019-01-04T13:44:31.017" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18460" PostTypeId="2" ParentId="18453" CreationDate="2019-01-04T13:45:09.590" Score="8" Body="&lt;p&gt;After you answered the question yourself, the focus shifted. It seems the Question is now &quot;How can I prevent Vim from checking for &lt;code&gt;$HOME/_vimrc&lt;/code&gt;?&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Create the file &lt;code&gt;$USERPROFILE/vimrc&lt;/code&gt; with all your configuration.&lt;/li&gt;&#xA;&lt;li&gt;Create the environment variable &lt;code&gt;VIMINIT&lt;/code&gt; with the value &lt;code&gt;source $USERPROFILE/vimrc&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On startup the variable &lt;code&gt;VIMINIT&lt;/code&gt; is checked first. If it is set, the value of &lt;code&gt;$VIMINIT&lt;/code&gt; is used as an Ex command line. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update (I know that the questioner is not interested anymore):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also check your &lt;code&gt;runtimepath&lt;/code&gt;. Most likely it still points to &lt;code&gt;$HOME/vimfiles&lt;/code&gt; (on Windows). So you should create the directory &lt;code&gt;$USERPROFILE/vimfiles&lt;/code&gt; to store extended configuration and plugins etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the beginning of &lt;code&gt;$USERPROFILE/vimrc&lt;/code&gt; you have to fix the &lt;code&gt;runtimepath&lt;/code&gt;. &#xA;I would try it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath-=~/vimfiles&#xA;set runtimepath^=$USERPROFILE/vimfiles&#xA;set runtimepath-=~/vimfiles/after&#xA;set runtimepath+=$USERPROFILE/vimfiles/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;After that&lt;/strong&gt; you should still change &lt;code&gt;$HOME&lt;/code&gt;, as others (like netrw) still uses it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $HOME=$USERPROFILE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm on Linux, so someone should test this on Windows.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-05T10:07:38.083" LastActivityDate="2019-01-05T10:07:38.083" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18461" PostTypeId="2" ParentId="120" CreationDate="2019-01-04T13:48:26.850" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/jeetsukumaran/vim-indentwise&quot; rel=&quot;nofollow noreferrer&quot;&gt;jeetsukumaran/vim-indentwise&lt;/a&gt; works well for relative, absolute, or block-scope movements across indented blocks. &lt;/p&gt;&#xA;" OwnerUserId="16055" LastActivityDate="2019-01-04T13:48:26.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18462" PostTypeId="1" AcceptedAnswerId="18463" CreationDate="2019-01-04T14:38:05.377" Score="0" ViewCount="4412" Body="&lt;p&gt;I can place the following code into my &lt;code&gt;_vimrc&lt;/code&gt; file on &lt;em&gt;Windows 7/10&lt;/em&gt; and the font will default to 'Consolas - size 11' when I launch gVim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;gui_running&quot;)&#xA;  if has(&quot;gui_gtk2&quot;)&#xA;    set guifont=Ubuntu Mono\ 15&#xA;  elseif has(&quot;gui_macvim&quot;)&#xA;    set guifont=Menlo\ Regular:h14&#xA;  elseif has(&quot;gui_win32&quot;)&#xA;    set guifont=Consolas:h11:cANSI&#xA;  endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I place this same code into my &lt;em&gt;Ubuntu 18.04&lt;/em&gt; &lt;code&gt;vimrc&lt;/code&gt; file I don't get the expected 'Ubuntu Mono - size 15'. I just get the default font and size, as if my new &lt;code&gt;vimrc&lt;/code&gt; code did nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I need to change in my code?&lt;/p&gt;&#xA;" OwnerUserId="20413" LastActivityDate="2019-01-04T19:16:05.833" Title="Setting default gVim font via `vimrc`, conditional on the operating system" Tags="|vimrc|gvim|linux|font|default-settings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18463" PostTypeId="2" ParentId="18462" CreationDate="2019-01-04T14:58:57.727" Score="2" Body="&lt;p&gt;I don't have a Linux machine with graphical interface here to test it, but I'd say the correct syntax for that line would be something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set guifont=Ubuntu\ Mono\ 15&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11384" LastEditorUserId="11384" LastEditDate="2019-01-04T19:16:05.833" LastActivityDate="2019-01-04T19:16:05.833" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18464" PostTypeId="1" AcceptedAnswerId="18470" CreationDate="2019-01-04T15:26:05.417" Score="2" ViewCount="455" Body="&lt;p&gt;I love the quickfix feature in vim. It also works flawlessly in most cases. But when I work with LaTeX documents, it leads to funny behavior. I don't think it's relevant, but I have the &lt;a href=&quot;http://vim-latex.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;LaTeX suite&lt;/a&gt; installed, and &lt;code&gt;makeprg&lt;/code&gt; is set to &lt;code&gt;makeprg=xelatex -interaction=nonstopmode&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume I have a LaTeX document open. When I now run &lt;code&gt;:make&lt;/code&gt; in vim, the document is compiled and a quickfix window is opened. I do not necessarily intend to fix those warnings. Being lazy, I leave the quickfix window open, do some changes, and compile again. What now happens to the quickfix window for a LaTeX document is different from my experience when working with other languages. Instead of updating the quickfix window, it opens another one, taking up more and more pixels from my working area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A screenshot can be seen here. My actual work area are the five lines at the top.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E0SM2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E0SM2.png&quot; alt=&quot;quickfix-hell&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can close the first quickfix window with &lt;code&gt;:cclose&lt;/code&gt;, but then I have to move to the other windows and close them one by one. Or I can close vim and open it again. None of these workflows is particularly sensible or efficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I close &lt;em&gt;all&lt;/em&gt; quickfix windows with one command? Can I prevent additional quickfix windows to be opened? Or can I sanitize my settings in such a way, that it won't open more than one quickfix window?&lt;/p&gt;&#xA;" OwnerUserId="6154" LastActivityDate="2019-08-28T21:49:28.790" Title="Close multiple quickfix windows" Tags="|quickfix|plugin-vim-latex|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18465" PostTypeId="1" AcceptedAnswerId="18466" CreationDate="2019-01-04T17:40:17.443" Score="1" ViewCount="237" Body="&lt;p&gt;When I enabled &lt;code&gt;expandtab&lt;/code&gt; in vim by putting these in .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tw=4&#xA;set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim comverted every space typed by me to a newline character.&lt;br&gt;&#xA;Like with the above settings whenever I type a new word and hit space&lt;br&gt;&#xA;I get a new line.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;What I want to type:&#xA;while (x &amp;lt; y):&#xA;&#xA;What I get:&#xA;while&#xA;(x&#xA;&amp;lt;&#xA;y):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20018" LastActivityDate="2019-01-04T18:14:51.530" Title="Expandtab converts spaces to newline character?" Tags="|whitespace|tab-characters|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18466" PostTypeId="2" ParentId="18465" CreationDate="2019-01-04T18:14:51.530" Score="3" Body="&lt;p&gt;You set the textwith (&lt;code&gt;tw&lt;/code&gt;) to 4. So Vim breaks the lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess you want shiftwidth:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shiftwidth=4&#xA;set tabstop=4&#xA;set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-04T18:14:51.530" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18467" PostTypeId="1" CreationDate="2019-01-04T20:44:55.487" Score="0" ViewCount="560" Body="&lt;p&gt;I've recently refactored &lt;code&gt;vim-colors-solarized&lt;/code&gt; and I've stumbled on a code like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:foo = s:bar &quot; used in multiple places&#xA;&quot; ... many lines&#xA;let s:goo = s:boo &quot; used in multiple places&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I inline all usages of such variables automatically easily. Of course I can write a function to do that. But maybe something like &lt;code&gt;g/let s:.&quot;=\s*s:.*/normal dw&quot;adWdW&quot;vdW&quot; | exe &quot;g/@v/s/@a/@v/g&quot; | d&lt;/code&gt; in which I mean find all lines matching a pattern, yank variable name to be inlined into register &lt;code&gt;a&lt;/code&gt; it's value into register &lt;code&gt;v&lt;/code&gt;. Then inside of this global command execute another global command on all lines after the match substituting variable with its value and removing initially matched line.&lt;/p&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2021-03-10T15:58:18.923" Title="What's the simplest way of inlining a variable?" Tags="|global-command|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18468" PostTypeId="1" AcceptedAnswerId="18469" CreationDate="2019-01-05T22:09:11.817" Score="4" ViewCount="335" Body="&lt;p&gt;I have the following mapping in &lt;code&gt;tnoremap &amp;lt;Esc&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; init.conf  to exit insert mode while in the terminal. &#xA;In certain terminal buffers I would like to not have that global mapping applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;:tunmap &amp;lt;buffer&amp;gt; &amp;lt;Esc&amp;gt;&lt;/code&gt; doesn't effect globally set mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;:tunmap &amp;lt;buffer&amp;gt;&lt;/code&gt; will remove the mapping for all buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to not apply global config to a certain buffer only?&lt;/p&gt;&#xA;" OwnerUserId="7129" LastActivityDate="2019-01-05T23:03:32.703" Title="Unmapping the global mappings on a per-buffer basis" Tags="|key-bindings|global-command|terminal-buffer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18469" PostTypeId="2" ParentId="18468" CreationDate="2019-01-05T23:03:32.703" Score="7" Body="&lt;p&gt;You could overwrite the mapping by a buffer-local mapping. Just map &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tnoremap &amp;lt;buffer&amp;gt; &amp;lt;ESC&amp;gt; &amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-05T23:03:32.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18470" PostTypeId="2" ParentId="18464" CreationDate="2019-01-05T23:23:14.257" Score="2" Body="&lt;p&gt;I have written a code that is pretty similar to the &lt;code&gt;:only&lt;/code&gt; command. But it closes also unsaved buffers. It keeps the only the active window in the current tab. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CloseAllWindowsButCurrent()&#xA;  let tabnr= tabpagenr()&#xA;  let tabinfo=gettabinfo(tabnr)&#xA;  let windows=tabinfo[0]['windows']&#xA;&#xA;  for winid in windows&#xA;    let curwin=winnr() &quot;could change&#xA;    let winnr=win_id2win(winid)&#xA;    if winnr!=curwin&#xA;           execute ':'.winnr.'q!'&#xA;    endif&#xA;  endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have mapped &lt;code&gt;&amp;lt;leader&amp;gt;c&lt;/code&gt; to call this. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;c :call CloseAllBuffersButCurrent()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-08-28T21:49:28.790" LastActivityDate="2019-08-28T21:49:28.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18471" PostTypeId="1" AcceptedAnswerId="18473" CreationDate="2019-01-06T02:29:34.317" Score="5" ViewCount="2545" Body="&lt;p&gt;I'm using Kramdown-flavored Markdown in several of my Jekyll websites. Vim highlights all the underscores in those documents as errors, coloring them (in my color scheme) with bright red backgrounds. For those who don't know, Jekyll Markdown pages begin with a Yaml document containing metadata before the main document starts. Thus, at the top of an example file I have something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---&#xA;layout: v4_main&#xA;date: Fall 1999&#xA;permalink: /music/effects_of_music.htm&#xA;# etc for many more lines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where all the underscores have bright red backgrounds. Throughout the actual Markdown portion of the document I have similar issues related to Kramdown's extensions to Markdown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following &lt;a href=&quot;https://stackoverflow.com/a/19137899/713735&quot;&gt;this advice&lt;/a&gt;, I managed to fix most of the issues by creating &lt;code&gt;$HOME/.vim/after/syntax/markdown.vim&lt;/code&gt; with this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn match markdownIgnore &quot;\v\w_\w&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the fix is incomplete, and I don't understand why. My documents have a number of headings that look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;## General Effects of Music {#general_effects_of_music}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The part in the curly braces is Kramdown's way of setting the header's &lt;code&gt;id&lt;/code&gt; when rendering to HTML. Despite my updated Vim syntax rule, the underscores in the &lt;code&gt;id&lt;/code&gt; are still labeled as errors. Any idea why, or how I can silence those errors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; I've tested my regex in a search (&lt;code&gt;/\v\w_\w&lt;/code&gt;) and it matched everything I want it to match, so clearly the issue isn't a bug in my regex.&lt;/p&gt;&#xA;" OwnerUserId="20217" LastActivityDate="2019-01-06T16:20:18.523" Title="Make Vim stop highlighting certain underscores in my Markdown as errors" Tags="|syntax-highlighting|filetype-markdown|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18472" PostTypeId="2" ParentId="16148" CreationDate="2019-01-06T10:08:05.923" Score="7" Body="&lt;p&gt;You could try &lt;code&gt;set noesckeys&lt;/code&gt;.  Here are its docs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Function keys that start with an &amp;lt;Esc&amp;gt; are recognized in Insert&#xA;mode.  When this option is off, the cursor and function keys cannot be&#xA;used in Insert mode if they start with an &amp;lt;Esc&amp;gt;.  The advantage of&#xA;this is that the single &amp;lt;Esc&amp;gt; is recognized immediately, instead of&#xA;after one second.  Instead of resetting this option, you might want to&#xA;try changing the values for 'timeoutlen' and 'ttimeoutlen'.  Note that&#xA;when 'esckeys' is off, you can still map anything, but the cursor keys&#xA;won't work by default.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2019-01-06T10:08:05.923" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18473" PostTypeId="2" ParentId="18471" CreationDate="2019-01-06T16:20:18.523" Score="2" Body="&lt;p&gt;I didn't find a way to suppress the error markings in the kramdown ids. So why not highlight them differently? Perhaps like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match kramdownId &quot;{#[^}]*}&quot;&#xA;syn cluster markdownInline add=kramdownId&#xA;highlight def link kramdownId Identifier&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This highlights &lt;code&gt;{#...}&lt;/code&gt; in light blue (in my color scheme). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I have no full kramdown file to test if there are any side effects.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-06T16:20:18.523" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18474" PostTypeId="1" CreationDate="2019-01-06T18:38:49.877" Score="2" ViewCount="230" Body="&lt;p&gt;For my terminal Vim 8.0, I have downloaded this plugin that makes changing font size on the fly easy:&#xA;&lt;a href=&quot;https://github.com/drmikehenry/vim-fontsize&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/drmikehenry/vim-fontsize&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following the instructions, here is how I decided to define my mappings for changing fonts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;C&amp;gt;+ &amp;lt;Plug&amp;gt;FontsizeInc&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;C-kPlus&amp;gt; &amp;lt;Plug&amp;gt;FontsizeDec&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;C&amp;gt;- &amp;lt;Plug&amp;gt;FontsizeDec&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;C-kMinus&amp;gt; &amp;lt;Plug&amp;gt;FontsizeDec&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;C&amp;gt;0 &amp;lt;Plug&amp;gt;FontsizeDefault&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, to my surprise, the functionalities are only working for the &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt; characters that are &lt;em&gt;not&lt;/em&gt; in the NumPad are of my keyboard. When I hit the combinations using &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;-&lt;/code&gt; form the NumPad, nothing happens. And otherwise, my Vim recognizes the NumPad just normally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I perhaps solve this issue?&lt;/p&gt;&#xA;" OwnerUserId="20408" LastEditorUserId="20408" LastEditDate="2019-01-06T19:17:06.650" LastActivityDate="2019-01-06T20:06:49.953" Title="Numpad characters don't work in keybindings mappings (but work in general)" Tags="|key-bindings|keyboard-layout|map-operator|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18475" PostTypeId="2" ParentId="18474" CreationDate="2019-01-06T19:13:02.690" Score="2" Body="&lt;p&gt;If I understand your question right, you are working in a terminal. Vim can't change the font size in a terminal. What you see, when pressing &lt;kbd&gt;Ctrl-+&lt;/kbd&gt; and &lt;kbd&gt;Ctrl--&lt;/kbd&gt; is a functionality  of the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try it without starting vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin you downloaded just changes the &lt;code&gt;guifont&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this I have the following in my gvimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar -nargs=0 BiggerFont  :let &amp;amp;guifont = substitute(&amp;amp;guifont,'\d\+$','\=submatch(0)+1','')&#xA;command! -bar -nargs=0 SmallerFont :let &amp;amp;guifont = substitute(&amp;amp;guifont,'\d\+$','\=submatch(0)-1','')&#xA;nnoremap &amp;lt;M--&amp;gt;        :SmallerFont&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;M-+&amp;gt;        :BiggerFont&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Stolen from &lt;a href=&quot;https://github.com/tpope/tpope/blob/master/.vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;tpope&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: The {lhs} of the mappings &lt;code&gt;&amp;lt;C&amp;gt;+&lt;/code&gt;, &lt;code&gt;&amp;lt;C&amp;gt;-&lt;/code&gt; and &lt;code&gt;&amp;lt;C&amp;gt;0&lt;/code&gt; all map a sequence of 4 characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW-2: I'm not sure that &lt;kbd&gt;Ctrl-+&lt;/kbd&gt; and &lt;kbd&gt;Ctrl--&lt;/kbd&gt; is mappable at all. If I go into insert mode in gVim and enter &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; + &lt;kbd&gt;Ctrl-+&lt;/kbd&gt; I just get a single &lt;code&gt;+&lt;/code&gt;. If I use &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; + &lt;kbd&gt;Ctrl-L&lt;/kbd&gt; I get &lt;code&gt;^L&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-06T20:06:49.953" LastActivityDate="2019-01-06T20:06:49.953" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18477" PostTypeId="1" AcceptedAnswerId="18518" CreationDate="2019-01-07T07:47:09.493" Score="2" ViewCount="206" Body="&lt;p&gt;Is there a way to make vim behave like the app &lt;a href=&quot;http://hailoverman.com/flowstate&quot; rel=&quot;nofollow noreferrer&quot;&gt;flowstate&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What this app does is forces the user to type continuously without pause for a certain period of time (which is very useful for brainstorming). The moment the user stops typing before the time is up, it deletes everything on the page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The app is only for Mac OS and there doesn't seem to be an alternative for windows/UNIX systems. Is there any way to implement this kind of functionality into vim?&lt;/p&gt;&#xA;" OwnerUserId="20443" LastActivityDate="2019-01-10T18:17:40.950" Title="A vim plugin like FLOWSTATE" Tags="|vimscript|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18478" PostTypeId="2" ParentId="18477" CreationDate="2019-01-07T08:30:45.430" Score="1" Body="&lt;p&gt;VimRoom, inspired by writeroom gives the same appearance&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://mikewest.github.io/vimroom/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://mikewest.github.io/vimroom/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could combine that with a pomodoro timer such as &lt;a href=&quot;https://github.com/carlmjohnson/pomodoro&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/carlmjohnson/pomodoro&lt;/a&gt; or Tomighty (available for windows)&#xA;to get a similar effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(There are also pomodoro plugins that you can use within VIM.)&lt;/p&gt;&#xA;" OwnerUserId="20444" LastActivityDate="2019-01-07T08:30:45.430" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18480" PostTypeId="1" CreationDate="2019-01-07T16:24:44.327" Score="0" ViewCount="19" Body="&lt;p&gt;I copied and pasted a .php file and edited it. It went from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;    class Foo&#xA;    {&#xA;        const RESET = 'reset';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;    class Foo&#xA;    {&#xA;        const RESET = 'reset';&#xA;        const USERBIKE = 'userbike';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, it's just literally a like-for-like line using a different var name and value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, despite their 98% match, &lt;code&gt;vim&lt;/code&gt; displays them differently:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BolkC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BolkC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How and why does it do this? How do I go about resolving?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quick details&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Framework being used here: Magento2 (PHP7)&lt;/li&gt;&#xA;&lt;li&gt;Standard Vim on CentOS7&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="20316" LastActivityDate="2019-01-07T16:24:44.327" Title="Why does second const VARNAME not have syntax highlighting?" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18481" PostTypeId="1" CreationDate="2019-01-07T16:59:30.267" Score="0" ViewCount="31" Body="&lt;p&gt;...with confirmation that is somewhat similar to the &quot;you are in RO mode&quot; that you get as a layer of security if you run the command as &lt;code&gt;view&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want a single command [that I may alias to something simple] that says, &quot;Automatically make the backup directory for the back up files that will be created every time a save is made of the data before it was written. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be cool if there was also a way to write to another file that this file was opened in &lt;em&gt;&quot;Uncertain I won't regret these changes&quot;&lt;/em&gt; mode, so that if that file is ever opened outside of that mode... vim will know that that might have been a mistake, ask, and allow a Y/n that will keep the file name or delete it from the list of &quot;uncertain&quot; mode files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, I don't want the backups to replace the backup. I want a new backup to be added, numbered. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could build this... but if there is already a set of commands and switches and aliased things that can produce an effect that is similar, I'd be interested to know.&lt;/p&gt;&#xA;" OwnerUserId="20455" LastActivityDate="2019-01-07T16:59:30.267" Title="Are there already a series of switches/commands/aliases to initiate vim and auto backup to new file when writing out" Tags="|backup|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18482" PostTypeId="1" AcceptedAnswerId="18483" CreationDate="2019-01-07T20:42:38.150" Score="2" ViewCount="239" Body="&lt;p&gt;The default &lt;code&gt;vim&lt;/code&gt; filetype commands create new bindings beginning with &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt;. Is there a way to prevent them from doing so or control which bindings are created?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like using &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; to scroll up and down by half pages, by analogy with &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; for paragraph navigation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ] &amp;lt;c-d&amp;gt;&#xA;vnoremap ] &amp;lt;c-d&amp;gt;&#xA;xnoremap ] &amp;lt;c-d&amp;gt;&#xA;&#xA;nnoremap [ &amp;lt;c-u&amp;gt;&#xA;vnoremap [ &amp;lt;c-u&amp;gt;&#xA;xnoremap [ &amp;lt;c-u&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works well for the &lt;code&gt;text&lt;/code&gt; filetype, but programming language filetypes typically have bindings beginning with &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt;, for instance for Python files there are many structural navigation commands that I tend not to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;n  [M          *@:call &amp;lt;SNR&amp;gt;25_Python_jump('n', '\v\S\n*(^(\s*\n*)*(class|def|async def)|^\S)', 'Wb', 0, v:count1)&amp;lt;CR&amp;gt;&#xA;n  [m          *@:call &amp;lt;SNR&amp;gt;25_Python_jump('n', '\v^\s*(class|def|async def)&amp;gt;', 'Wb', v:count1)&amp;lt;CR&amp;gt;&#xA;n  []          *@:call &amp;lt;SNR&amp;gt;25_Python_jump('n', '\v\S.*\n+(def|class)', 'Wb', 0, v:count1)&amp;lt;CR&amp;gt;&#xA;n  [[          *@:call &amp;lt;SNR&amp;gt;25_Python_jump('n', '\v^(class|def|async def)&amp;gt;', 'Wb', v:count1)&amp;lt;CR&amp;gt;&#xA;...&#xA;n  ]M          *@:call &amp;lt;SNR&amp;gt;25_Python_jump('n', '\v\S\n*(%$|^(\s*\n*)*(class|def|async def)|^\S)', 'W', 0, v:count1)&amp;lt;CR&amp;gt;&#xA;n  ]m          *@:call &amp;lt;SNR&amp;gt;25_Python_jump('n', '\v%$|^\s*(class|def|async def)&amp;gt;', 'W', v:count1)&amp;lt;CR&amp;gt;&#xA;n  ][          *@:call &amp;lt;SNR&amp;gt;25_Python_jump('n', '\v%$|\S.*\n+(def|class)', 'W', 0, v:count1)&amp;lt;CR&amp;gt;&#xA;n  ]]          *@:call &amp;lt;SNR&amp;gt;25_Python_jump('n', '\v%$|^(class|def|async def)&amp;gt;', 'W', v:count1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The file that defines this is located at&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/vim/vim81/ftplugin/python.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and does not &lt;em&gt;appear&lt;/em&gt; to check the value of a &quot;configuration variable&quot; to determine whether it should bind keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a creative way to overrule it?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="927" LastEditDate="2019-01-08T03:08:45.403" LastActivityDate="2019-01-08T06:45:14.337" Title="Disable filetype-specific `[`/`]` bindings like `[[` and `[m`" Tags="|key-bindings|" AnswerCount="2" CommentCount="1" ClosedDate="2019-01-08T08:59:40.597" ContentLicense="CC BY-SA 4.0" />
  <row Id="18483" PostTypeId="2" ParentId="18482" CreationDate="2019-01-07T21:46:49.987" Score="4" Body="&lt;p&gt;You can unmap these within a file called &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt; or &lt;code&gt;$HOME/vimfiles/after/ftplugin/python.vim&lt;/code&gt; on windows, etc. containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! nunmap &amp;lt;buffer&amp;gt; ]]&#xA;silent! nunmap &amp;lt;buffer&amp;gt; [[&#xA;silent! nunmap &amp;lt;buffer&amp;gt; ][&#xA;silent! nunmap &amp;lt;buffer&amp;gt; []&#xA;&quot; and so on ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim executes scripts of the form &lt;code&gt;after/ftplugin/{filetype}.vim&lt;/code&gt; &lt;em&gt;after&lt;/em&gt; &lt;code&gt;ftplugin/{filetype}.vim&lt;/code&gt; so you cna provide arbitrary overrides to the defaults.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can use autocmds within your vimrc as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PythonUnmaps()&#xA;    silent! nunmap &amp;lt;buffer&amp;gt; ]]&#xA;    silent! nunmap &amp;lt;buffer&amp;gt; [[&#xA;    silent! nunmap &amp;lt;buffer&amp;gt; ][&#xA;    silent! nunmap &amp;lt;buffer&amp;gt; []&#xA;    &quot; and so on...&#xA;endfunction&#xA;augroup my_python_overrides&#xA;    au!&#xA;    autocmd FileType python call PythonUnmaps()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both of these approaches are general, you can replace python with whichever filetype you want to alter the settings for.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2019-01-07T22:21:33.417" LastActivityDate="2019-01-07T22:21:33.417" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18484" PostTypeId="1" CreationDate="2019-01-07T22:56:58.740" Score="2" ViewCount="146" Body="&lt;p&gt;I often &quot;unignore&quot; files in &lt;code&gt;.gitignore&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*&#xA;!.gitignore&#xA;!file.txt&#xA;!dir&#xA;!dir/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I modify the pattern for which insert mode file name completion would work? In this case, instead of &lt;code&gt;./&lt;/code&gt; I'd like the exclamation mark to suffice. I know &lt;a href=&quot;https://stackoverflow.com/questions/50041137/&quot;&gt;this qustion on stackoverflow&lt;/a&gt; sort of deals with the problem, but I'd like to know if there's a way without &lt;a href=&quot;http://vim.wikia.com/wiki/Omni_completion&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;omnifunc&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NVIM v0.3.2-964-g7e97587da&#xA;Linux 4.20.0-arch1-1-ARCH #1 SMP PREEMPT Mon Dec 24 03:00:40 UTC 2018 x86_64 GNU/Linux&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1027" LastEditorUserId="4472" LastEditDate="2019-01-13T20:26:39.473" LastActivityDate="2019-01-13T20:26:39.473" Title="file name completion in .gitignore" Tags="|autocompletion|git|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18485" PostTypeId="2" ParentId="18484" CreationDate="2019-01-07T23:23:05.520" Score="3" Body="&lt;p&gt;how do you trigger file-name completion.&#xA;completing with &lt;code&gt;^X^F&lt;/code&gt; should do it if '!' does not show up in &lt;code&gt;set isfname?&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2019-01-07T23:23:05.520" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18487" PostTypeId="1" CreationDate="2019-01-08T02:20:11.370" Score="2" ViewCount="154" Body="&lt;p&gt;Is there a way to display output at the bottom of the screen like &lt;code&gt;ls&lt;/code&gt; does, but without &lt;em&gt;scrolling down to accomodate the output&lt;/em&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vim.wikia.com/wiki/Cycle_through_buffers_including_hidden_buffers&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Wiki (no https)&lt;/a&gt; has the following snippet&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;A-n&amp;gt; :bnext&amp;lt;CR&amp;gt;:redraw&amp;lt;CR&amp;gt;:ls&amp;lt;CR&amp;gt;&#xA;:nnoremap &amp;lt;A-p&amp;gt; :bprevious&amp;lt;CR&amp;gt;:redraw&amp;lt;CR&amp;gt;:ls&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried binding this as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;tab&amp;gt;   :bnext&amp;lt;cr&amp;gt;:redraw&amp;lt;cr&amp;gt;:ls&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;S-tab&amp;gt; :bprevious&amp;lt;cr&amp;gt;:redraw&amp;lt;cr&amp;gt;:ls&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however, when moving to the next buffer and displaying &lt;code&gt;ls&lt;/code&gt;, vim truncates the top &lt;code&gt;n&lt;/code&gt; lines of the buffer, with &lt;code&gt;n&lt;/code&gt; being the number of lines needed to display &lt;code&gt;ls&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if I have the following file &lt;code&gt;b.tex&lt;/code&gt; with line numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1 \documentclass{article}&#xA;  2&#xA;  3 \begin{document}&#xA;  4&#xA;  5 Lorem ipsem&#xA;  6&#xA;  7 $$ \frac{a}{b} $$&#xA;  8&#xA;  9 \end{document}   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the files &lt;code&gt;a.tex b.tex c.tex&lt;/code&gt; open, then pressing &lt;code&gt;tab&lt;/code&gt; and navigating to  &lt;code&gt;b.tex&lt;/code&gt; produces the following output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      5 Lorem ipsem&#xA;      6&#xA;      7 $$ \frac{a}{b} $$&#xA;      8&#xA;      9 \end{document}&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;&quot;./tmp/b.tex&quot; 9 lines --11%-- ((1) of 3)&#xA;  1 #h   &quot;./tmp/a.tex&quot;      line 1&#xA;  2 %a   &quot;./tmp/b.tex&quot;      line 1&#xA;  3  h   &quot;./tmp/c.tex&quot;      line 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to direct vim to &lt;em&gt;take the four lines needed to display the output of &lt;code&gt;ls&lt;/code&gt; from the bottom of the buffer rather than the top&lt;/em&gt;?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2019-01-08T02:20:11.370" Title="display list of buffers `ls` without scrolling down" Tags="|vimrc|vimscript|buffers|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18488" PostTypeId="2" ParentId="18482" CreationDate="2019-01-08T06:45:14.337" Score="2" Body="&lt;p&gt;According to the help &lt;a href=&quot;https://vimhelp.org/filetype.txt.html#no_mail_maps&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h no_mail_maps&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/filetype.txt.html#no_plugin_maps&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h no_plugin_maps&lt;/a&gt;, it should be possible to prevent the creation of a filetype specific mapping by setting the variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:no_&amp;lt;filetype&amp;gt;_maps = 1`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your .vimrc, with &lt;code&gt;&amp;lt;filetype&amp;gt;&lt;/code&gt; being replaced by &lt;code&gt;python&lt;/code&gt; in your case. Unfortunately, the &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/ftplugin/python.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;official python filetype plugin&lt;/a&gt; does not support this guard yet. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the upstream &lt;a href=&quot;https://github.com/tpict/vim-ftplugin-python&quot; rel=&quot;nofollow noreferrer&quot;&gt;python Vim filetype repository&lt;/a&gt; does already support that as of commit &lt;a href=&quot;https://github.com/tpict/vim-ftplugin-python/commit/db75a4614ffef7700620498f46166b9730ecde8f&quot; rel=&quot;nofollow noreferrer&quot;&gt;db75a4614ffef770&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you could simply clone that plugin locally and use that, until the maintainer has sent update runtime files to Bram for inclusion with Vim (and Bram has committed it to the Vim repository).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-01-08T06:45:14.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18489" PostTypeId="2" ParentId="9967" CreationDate="2019-01-08T12:08:42.027" Score="7" Body="&lt;p&gt;This would do exactly what you've asked for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;F6&amp;gt; g:NERDTree.IsOpen() ? &quot;\:NERDTreeClose&amp;lt;CR&amp;gt;&quot; : bufexists(expand('%')) ? &quot;\:NERDTreeFind&amp;lt;CR&amp;gt;&quot; : &quot;\:NERDTree&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20464" LastActivityDate="2019-01-08T12:08:42.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18490" PostTypeId="1" AcceptedAnswerId="18494" CreationDate="2019-01-08T12:40:45.593" Score="4" ViewCount="2362" Body="&lt;p&gt;For best experience, I want to enable some snippets to be expanded only in Tex Math environments. A wonderful person, lacygoill helped me on GitHub to achieve just this with the following setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let the context function and a snippet using the context be given by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global !p&#xA;def isMath():&#xA;    return int(vim.eval(&quot;get(reverse(map(synstack(line('.'), col('.')), {i,v -&amp;gt; synIDattr(v, 'name')})), 0, '') =~# 'texMathZone\%(X\|Y\|V\)'&quot;))&#xA;endglobal&#xA;&#xA;context &quot;isMath()&quot;&#xA;snippet pow &quot;&quot; iA&#xA;^{$1}$0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;isMath&lt;/code&gt; above doesn't work on cases when there's no space inbetween the math delimiters such as &lt;code&gt;$|$&lt;/code&gt; or &lt;code&gt;\(|\)&lt;/code&gt;, it only works on cases like &lt;code&gt;$ | $&lt;/code&gt; or &lt;code&gt;$\( | \)$&lt;/code&gt;, so the other version of &lt;code&gt;isMath&lt;/code&gt; that is derived is: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def isMath():&#xA;    return int(vim.eval(&quot;get(reverse(map(synstack(line('.'), col('.') - (col('.')&amp;gt;=2 ? 1 : 0)), {i,v -&amp;gt; synIDattr(v, 'name')})), 0, '') =~# 'texMathZone\%(X\|Y\)'&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both seem to work 99% of the time. There's one time that they doesn't work which is important too. Consider the following tex code: &lt;code&gt;$e|$&lt;/code&gt;, type pow to expand to &lt;code&gt;e^{|}&lt;/code&gt;, now type &lt;code&gt;x&lt;/code&gt; followed by &lt;code&gt;pow&lt;/code&gt;. I expect it to expand to &lt;code&gt;e^{x^{|}}&lt;/code&gt;, instead it doesn't expand &lt;code&gt;pow&lt;/code&gt; anymore, it stays as &lt;code&gt;e^{xpow}&lt;/code&gt;. (all the expansions should happen automatically because of &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;|&lt;/code&gt; stands for cursor position). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second variation of &lt;code&gt;isMath&lt;/code&gt; fails in an additional case too, consider the following snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet __ &quot;subscript&quot; iA&#xA;_{$1}$0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will not expand in &lt;code&gt;$|$&lt;/code&gt; or &lt;code&gt;$ | $&lt;/code&gt; at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can the two python functions above for context be adjusted to consider the nested curly brace &lt;code&gt;{}&lt;/code&gt; cases? I don't understand why this is happening at all either, because even in &lt;code&gt;e{|}&lt;/code&gt; position, the cursor is located in &lt;code&gt;texMathZoneV&lt;/code&gt; syntax group. I'd prefer to see an adjustment made to the second &lt;code&gt;isMath&lt;/code&gt; because it's convenient to expand in &lt;code&gt;$|$&lt;/code&gt; where there are no spaces inbetween &lt;code&gt;$$&lt;/code&gt;. However, if that's impossible to achieve, it's not a problem to write &lt;code&gt;$ | $&lt;/code&gt; either so adjustments to the first &lt;code&gt;isMath&lt;/code&gt; are very welcome too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum up, I'm looking for a function that correctly identifies it is in math environment and as &lt;code&gt;lacygoill&lt;/code&gt; suggested it's a good idea to use syntax groups as they're always right. The &lt;code&gt;isMath()&lt;/code&gt; functions above have been doing it well so far, with the nested &lt;code&gt;{}&lt;/code&gt; being an exception as described for both functions and with &lt;code&gt;$__$&lt;/code&gt; not expanding at all for the second function. A new function with a different approach is also welcome that'd be working as expected, I think there are more issues than meet the eye with the current ones. If anyone's been through this, I'd really appreciate a hand!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;texMathTextZones = ['texMathText']&#xA;texMathTextZoneIds = vim.eval('map('+str(texMathTextZones )+&quot;, 'hlID(v:val)')&quot;)&#xA;...&#xA;return not set(texMathZoneIds).isdisjoint(synstackids) and set(texMathTextZoneIds).isdisjoint(synstackids)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I added these lines to ignore some scopes. Is there a better way to do it?&lt;/p&gt;&#xA;" OwnerUserId="20299" LastEditorUserId="20299" LastEditDate="2019-01-09T05:54:35.617" LastActivityDate="2022-10-23T19:13:08.107" Title="UltiSnips, Context and Tex" Tags="|vimscript|filetype-tex|plugin-ultisnips|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18491" PostTypeId="1" CreationDate="2019-01-08T13:10:04.673" Score="1" ViewCount="57" Body="&lt;p&gt;I am using the &lt;code&gt;]&lt;/code&gt; commands (e.g. &lt;code&gt;]]&lt;/code&gt;) a lot and have a bunch of custom ones too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command that repeats the last such command, similar to how &lt;code&gt;.&lt;/code&gt; repeats the last edit?&lt;/p&gt;&#xA;" OwnerUserId="18613" LastActivityDate="2019-01-08T13:10:04.673" Title="Repeat previous square bracket command" Tags="|cursor-motions|repeated-commands|" AnswerCount="0" CommentCount="1" FavoriteCount="0" ClosedDate="2019-01-13T17:54:03.627" ContentLicense="CC BY-SA 4.0" />
  <row Id="18492" PostTypeId="2" ParentId="18435" CreationDate="2019-01-08T15:34:18.733" Score="1" Body="&lt;p&gt;Based on what I read at &lt;a href=&quot;https://vimways.org/2018/opening-non-vim-file-formats/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimways&lt;/a&gt;, I would do something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, we need filetype-detection working, so for every filetype you need, in &lt;code&gt;~/.vim/ftdetect/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt;, put&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocommand BufRead,BufNewFile *.&amp;lt;ext&amp;gt;[,*.&amp;lt;ext&amp;gt;] set filetype=&amp;lt;filetype&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The example in the article uses &lt;code&gt;video&lt;/code&gt; as a filetype, with a plethora of extensions matching.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, we must execute the appropriate actions, so in &lt;code&gt;~/.vim/after/ftplugin/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; you'll want to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent execute &quot;!&amp;lt;external commands to view the file&amp;gt;&quot; | buffer# | bdelete# | redraw! | syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If, like me, you prefer to reorganize the code a bit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:command() abort&#xA;  &quot; execute the external viewing command&#xA;endfunction&#xA;&#xA;function! s:nextfile() abort&#xA;  buffer #&#xA;  bdelete #&#xA;  redraw!&#xA;  &quot; this may or may not be necessary...&#xA;  &quot; it might also be 'syntax enable' or even just 'edit'&#xA;  syntax on&#xA;endfunction&#xA;&#xA;silent call s:command()&#xA;silent call s:nextfile()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-01-08T15:34:18.733" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18493" PostTypeId="2" ParentId="18401" CreationDate="2019-01-08T15:49:19.380" Score="1" Body="&lt;p&gt;The short answer (since I feel like &lt;a href=&quot;https://vi.stackexchange.com/questions/15009/vim-never-shows-line-number-for-python-files-even-though-i-have-vimrc/15019#15019&quot;&gt;I've written plenty about ftplugins before&lt;/a&gt;) is to use filetype plugins.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You need &lt;code&gt;filetype plugin on&lt;/code&gt; at minimum for this to work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Create e.g. &lt;code&gt;~/.vim/after/ftplugin/c.vim&lt;/code&gt; and put e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal autoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also do this for fortran (&lt;code&gt;.f90&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take out the &lt;code&gt;autodindent&lt;/code&gt; things from your vimrc, and you should be good to go.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I don't recognize the &lt;code&gt;.plt&lt;/code&gt; extension, and neither does my vim, but you could give it a filetype by doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/ftdetect/&amp;lt;name&amp;gt;.vim&#xA;autocommand BufRead,BufNewFile *.plt set filetype=&amp;lt;name&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then put more filetype-plugin commands in &lt;code&gt;~/.vim/after/ftplugin/&amp;lt;name&amp;gt;.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some might advocate for putting &lt;code&gt;indent&lt;/code&gt; related settings in &lt;code&gt;~/.vim/after/indent/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; (and I would argue they are wrong; see &lt;code&gt;:help indent-expression&lt;/code&gt;, which says indent files are for setting &lt;code&gt;'indentexpr'&lt;/code&gt;). If you do so, you'll need &lt;code&gt;filetype plugin indent on&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-01-08T15:49:19.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18494" PostTypeId="2" ParentId="18490" CreationDate="2019-01-08T17:12:55.337" Score="3" Body="&lt;p&gt;&lt;strong&gt;UPDATED UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed that checking simply for &lt;code&gt;texMathZone...&lt;/code&gt; at the beginning or end of the synstack is not sufficient. Every element has to be checked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the OP has requested there should be a possibility to disable the autoexpansion for &lt;code&gt;\text{...}&lt;/code&gt; within math zones (updated update). This is done by checking first if the Id of a &lt;code&gt;texIgnoreMathZones&lt;/code&gt; matches.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global !p&#xA;texMathZones = ['texMathZone'+x for x in ['A', 'AS', 'B', 'BS', 'C', 'CS', 'D', 'DS', 'V', 'W', 'X', 'Y', 'Z']]&#xA;# If you have http://www.drchip.org/astronaut/vim/vbafiles/amsmath.vba.gz,&#xA;# you want to add:&#xA;# texMathZones += ['texMathZone'+x for x in ['E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS', 'J', 'JS', 'K', 'KS', 'L', 'LS']]&#xA;texIgnoreMathZones = ['texMathText']&#xA;&#xA;texMathZoneIds = vim.eval('map('+str(texMathZones)+&quot;, 'hlID(v:val)')&quot;)&#xA;texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+&quot;, 'hlID(v:val)')&quot;)&#xA;&#xA;def isMath():&#xA;    synstackids = vim.eval(&quot;synstack(line('.'), col('.') - (col('.')&amp;gt;=2 ? 1 : 0))&quot;)&#xA;    if not set(texIgnoreMathZoneIds).isdisjoint(synstackids):&#xA;        return False&#xA;    return not set(texMathZoneIds).isdisjoint(synstackids)&#xA;    # isdisjoint() can short-circuit as soon as a match is found&#xA;&#xA;endglobal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note you could remove a few letters when you follow &lt;a href=&quot;https://ctan.org/pkg/l2tabu-english&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ctan.org/pkg/l2tabu-english&lt;/a&gt;. This means that you do not use &lt;code&gt;eqnarray&lt;/code&gt; and &lt;code&gt;$$ ... $$&lt;/code&gt; which are the letters &lt;code&gt;B&lt;/code&gt;, &lt;code&gt;BS&lt;/code&gt;, and &lt;code&gt;Y&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;FIRST REPLY&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did a little bit of debugging of your code by adding a few print statements to see what is going on. I have considered your second &lt;code&gt;isMath()&lt;/code&gt; function which takes a column offset of &lt;code&gt;-1&lt;/code&gt; if the cursor is not in the first column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code with print statements looks like following which contains a modification: the call of &lt;code&gt;reverse()&lt;/code&gt; has been removed when the value for &lt;code&gt;syntaxgroup&lt;/code&gt; is eventually determined. Both syntaxgroups (with or without &lt;code&gt;reverse()&lt;/code&gt;), however, are printed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global !p&#xA;def isMath():&#xA;    # DEBUGGING&#xA;    synstack = vim.eval(&quot;map(synstack(line('.'), col('.') - (col('.')&amp;gt;=2 ? 1 : 0)), {i,v -&amp;gt; synIDattr(v, 'name')})&quot;)&#xA;    print(&quot;synstack: &quot; + str(synstack))&#xA;    syntaxgroup = vim.eval(&quot;get(reverse(map(synstack(line('.'), col('.') - (col('.')&amp;gt;=2 ? 1 : 0)), {i,v -&amp;gt; synIDattr(v, 'name')})), 0, '')&quot;)&#xA;    print(&quot;syntaxgroup (rev): &quot;+ syntaxgroup)&#xA;    # MODIFICATION reverse() is not necessary since texMathZone is the outer group anyway.&#xA;    syntaxgroup = vim.eval(&quot;get(map(synstack(line('.'), col('.') - (col('.')&amp;gt;=2 ? 1 : 0)), {i,v -&amp;gt; synIDattr(v, 'name')}), 0, '')&quot;)&#xA;    print(&quot;syntaxgroup: &quot;+ syntaxgroup)&#xA;    return int(vim.eval(&quot;'&quot;+syntaxgroup+&quot;' =~# 'texMathZone\%(X\|Y\|V\)'&quot;))&#xA;endglobal&#xA;&#xA;context &quot;isMath()&quot;&#xA;snippet ^^ &quot;^{ }&quot; iA&#xA;^{$1}$0&#xA;endsnippet&#xA;&#xA;context &quot;isMath()&quot;&#xA;snippet __ &quot;_{ }&quot; iA&#xA;_{$1}$0&#xA;endsnippet&#xA;&#xA;snippet $$ &quot;$ $&quot; iA&#xA;$$1$$0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have used &lt;code&gt;^^&lt;/code&gt; instead of &lt;code&gt;pow&lt;/code&gt; as trigger word for superscript as personal preference.&#xA;Additionally, there is the snippet &lt;code&gt;$$&lt;/code&gt; for starting an inline math expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I enter following sequence of characters in a tex file&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;$$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;__&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I get in my buffer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$_{}$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The messages generated by the print statements are&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9sGj8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9sGj8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am suprised about is, that the function &lt;code&gt;isMath()&lt;/code&gt; is also triggered after pressing &lt;code&gt;$&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, the reason for this is clear: the autotrigger feature requires this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;After snippet is defined as being autotriggered, snippet condition will be&#xA;  checked on every typed character and if condition matches, then the snippet&#xA;  will be triggered.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have also tested the modification for math environments such as &lt;code&gt;equation&lt;/code&gt; and it also works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMHO your approach is good and I could not suggest anything better. If someone encounters a delay when fast typing, I would recommend to remove &lt;code&gt;A&lt;/code&gt; to disable the autotrigger.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-01-09T10:25:06.730" LastActivityDate="2019-01-09T10:25:06.730" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="18495" PostTypeId="2" ParentId="6633" CreationDate="2019-01-08T17:44:54.983" Score="0" Body="&lt;p&gt;I think now you can just do&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:AirlineTheme base16&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to temporarily set the theme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure to have Airline and AirlineThemes installed&lt;/p&gt;&#xA;" OwnerUserId="20468" LastActivityDate="2019-01-08T17:44:54.983" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18496" PostTypeId="2" ParentId="9542" CreationDate="2019-01-08T17:49:42.820" Score="2" Body="&lt;p&gt;At least on neovim, something like this should work. It uses &lt;a href=&quot;https://github.com/neovim/neovim/commit/868b84199ef321834022c19d9ba1d1d04cb77570&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;stdpath()&lt;/code&gt;&lt;/a&gt; in order to handle XDG env variables and &lt;code&gt;filereadable()&lt;/code&gt; which is more &lt;em&gt;readable&lt;/em&gt; that &lt;code&gt;empty(glob())&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Bootstrap Plug &#xA;let autoload_plug_path = stdpath('data') . '/site/autoload/plug.vim'&#xA;if !filereadable(autoload_plug_path)&#xA;  silent execute '!curl -fLo ' . autoload_plug_path . ' --create-dirs&#xA;      \ &quot;https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&quot;'&#xA;  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC&#xA;endif&#xA;unlet autoload_plug_path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20469" LastEditorUserId="20469" LastEditDate="2019-01-10T15:46:28.773" LastActivityDate="2019-01-10T15:46:28.773" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18497" PostTypeId="1" AcceptedAnswerId="18507" CreationDate="2019-01-08T19:18:30.683" Score="0" ViewCount="216" Body="&lt;p&gt;I'm working long time with my own &lt;code&gt;vimrc&lt;/code&gt; and lots of adjustments for different file types, ... in the macOS terminal (Vim 7.4.8056)and (the same config-files) on a rented Apache Server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I just copied the &lt;code&gt;.vimrc&lt;/code&gt; and my &lt;code&gt;.vim&lt;/code&gt;-directory to a new Ubuntu-System (Vim 8). And it doesn't work. Just typing in &lt;code&gt;vi&lt;/code&gt; returns lots of errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the mysterious thing is that these errors don't make any sense for me. There are difficulties with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;syntax on&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;filetype plugin on&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;au BufNewFile,BufRead&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All these commands are used in Vim 8, too. Do you have an idea what I can do to solve the problems instead of installing Vim 7? Or is there another configuration file working against mine?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you'll find the answers of Ralf's questions (I translated as best as possible from German to English):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Does the same error occur if you start it as vim instead of vi? Answer: &lt;code&gt;vim cannot be found&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;What is the output of &lt;code&gt;update-alternatives --display vi&lt;/code&gt; and &lt;code&gt;update-alternatives --display vim&lt;/code&gt;? Answer: &lt;code&gt;Best version of the link = /usr/bin/vim.tiny&#xA;Link &quot;links&quot; at the moment to /usr/bin/vim.tiny&#xA;Link vi is /usr/bin/vi&#xA;/usr/bin/vim.tiny - priority 15&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The output of &lt;code&gt;vim-version&lt;/code&gt; on Ubuntu? Answer: &lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 10 2018 21:31:58)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="20470" LastEditorDisplayName="user5791" LastEditDate="2019-01-29T05:47:30.027" LastActivityDate="2019-01-29T05:47:30.027" Title="Configuration from Vim 7 (macOS) to Vim 8 (Ubuntu) results in errors" Tags="|vimrc|error|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18498" PostTypeId="2" ParentId="444" CreationDate="2019-01-08T19:59:42.110" Score="2" Body="&lt;p&gt;I had the problem of looking at contents of a file, update the file externally, display the changed file and have the option to edit it when needed. I solved it with the Vim server/remote command line options, inspired by &lt;a href=&quot;https://stackoverflow.com/a/10327423&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;With the following commands a file can be reloaded via an external command. First, open the file in question with Vim, while starting a server instance.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --servername JABBERWOCKY /tmp/alice.log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's assume the file has been changed externally, e.g. by a &lt;code&gt;echo &quot;Curiouser and curiouser&quot; &amp;gt;&amp;gt; /tmp/alice.log&lt;/code&gt;. When necessary, send a command to the server instance to reload the file. This command will finish quickly and not spawn a new editor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --servername JABBERWOCKY --remote-send &quot;:e&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the opened file was changed in Vim and externally, there will be a conflict during reload (a warning message will appear). For that case a decision has to be made: Leave it with that and keep changes in Vim, or &lt;a href=&quot;https://vi.stackexchange.com/a/445/20471&quot;&gt;discard local changes and force a reload&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The command with &lt;code&gt;--remote-send&lt;/code&gt; above requires manual reloading. However, that command could be tied to a simple loop, using Bash's &lt;code&gt;for&lt;/code&gt;/&lt;code&gt;while&lt;/code&gt;, or using a hacky one-liner in Linux/Unix:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;watch -n 1 'vim --servername JABBERWOCKY --remote-send &quot;:e&amp;lt;CR&amp;gt;&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although not tested, I'm certain that something like this could be realized in PowerShell, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Linux/Unix an event-driven approach can be realized by listening to file system events using e.g. the &lt;a href=&quot;https://linux.die.net/man/7/inotify&quot; rel=&quot;nofollow noreferrer&quot;&gt;inotify&lt;/a&gt; library, if your not using too crazy file systems. Personally I like using the tool &lt;a href=&quot;https://github.com/clibs/entr&quot; rel=&quot;nofollow noreferrer&quot;&gt;entr&lt;/a&gt; a lot, which seems to be included in major Linux distributions. Then I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo /tmp/alice.log | entr vim --servername JABBERWOCKY --remote-send &quot;:e&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20471" LastEditorUserId="20471" LastEditDate="2019-01-08T20:09:54.287" LastActivityDate="2019-01-08T20:09:54.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18499" PostTypeId="1" AcceptedAnswerId="18500" CreationDate="2019-01-08T20:03:38.043" Score="1" ViewCount="205" Body="&lt;p&gt;I'm working on &lt;a href=&quot;https://metacpan.org/pod/Open::This&quot; rel=&quot;nofollow noreferrer&quot;&gt;Open::This&lt;/a&gt;, which provides a command line utility that acts as a wrapper around &lt;code&gt;vim&lt;/code&gt;, &lt;code&gt;emacs&lt;/code&gt; and &lt;code&gt;nano&lt;/code&gt;.  The utility is called &lt;code&gt;ot&lt;/code&gt;.  It does things like translating &lt;code&gt;ot lib/Foo/Bar.pm:99&lt;/code&gt; into &lt;code&gt;vim +99 lib/Foo/Bar.pm&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like to be able to do is translate &lt;code&gt;ot lib/Foo/Bar.pm:99:50&lt;/code&gt; into a &lt;code&gt;vim&lt;/code&gt; command which will open &lt;code&gt;lib/Foo/Bar.pm&lt;/code&gt; at line 99 and column 50.  Is this possible to do &lt;em&gt;without&lt;/em&gt; using a &lt;code&gt;vim&lt;/code&gt; plugin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum up, I know the command line syntax to open a file at an arbitrary line.  Is it possible to do this &lt;em&gt;and&lt;/em&gt; move the cursor to an arbitrary column at the same time?&lt;/p&gt;&#xA;" OwnerUserId="13055" LastEditorUserId="13055" LastEditDate="2019-01-08T20:22:03.243" LastActivityDate="2019-01-08T20:22:03.243" Title="Can I open a file at an arbitrary line and column via the command line?" Tags="|command-line|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18500" PostTypeId="2" ParentId="18499" CreationDate="2019-01-08T20:12:52.283" Score="1" Body="&lt;p&gt;You can have vim execute arbitrary commands (i.e., not just a line number) after loading the first file on the command line using &lt;code&gt;+'{cmd}'&lt;/code&gt; or &lt;code&gt;-c '{cmd}'&lt;/code&gt;.  This is documented in vim's man page.  For example, to load file &lt;code&gt;Foo/Bar.pm&lt;/code&gt; then go to line 99, column 50, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +'call cursor(99,50)' Foo/Bar.pm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this uses byte position for the column number, starting from one.  If your file has multi-byte characters and you wish to use vim's understanding of column numbers instead, you can instead do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +'normal! 99G50|' Foo/Bar.pm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses the normal commands &lt;code&gt;G&lt;/code&gt; for go-to line and &lt;code&gt;|&lt;/code&gt; meaning go to screen column (starting at one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which to use depends on how your tool emits column numbers.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-01-08T20:12:52.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18501" PostTypeId="2" ParentId="18499" CreationDate="2019-01-08T20:13:09.850" Score="1" Body="&lt;p&gt;You can do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;call cursor(19, 11)&quot; .bashrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This opens &lt;code&gt;.bashrc&lt;/code&gt; and puts the cursor on line 19, column 11.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; is one character!&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-08T20:13:09.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18503" PostTypeId="1" CreationDate="2019-01-08T22:37:55.660" Score="0" ViewCount="1528" Body="&lt;p&gt;I'm trying to write a Vim script function to toggle between &lt;code&gt;-&amp;gt;&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt; but searching for &lt;code&gt;.&lt;/code&gt; is seemingly impossible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to search using ASCII (decimal and hex) and it doesn't work. It all works from normal mode and when I do my experiments it let's me cycle between the dots using &lt;code&gt;n&lt;/code&gt; etc but the cursor either doesn't move or goes forward once or goes to the beginning of the line etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest I got just sets my cursor to the start of the next line with a dot occurring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How is this meant to be done? I've even upgraded to the latest version to try to fix it assuming it's some bug, but it still doesn't let me just search for a dot. Why would it be this difficult? I can't find anything when I Google. I loaded Vim without my &lt;code&gt;.vimrc&lt;/code&gt; and it still results the same. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I just want a search that puts the cursor on the next dot. Something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec &quot;normal /\.&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec &quot;normal /\%d46&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;only that works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those are typed from memory and I'm away from the computer with a headache, so I'm not sure those are good examples of what I've been trying but some of what I've tried was to that ilk.&lt;/p&gt;&#xA;" OwnerUserId="20477" LastEditorUserId="2920" LastEditDate="2019-01-08T23:14:17.340" LastActivityDate="2019-01-08T23:38:26.047" Title="Vim can't search for dot" Tags="|vimscript|search|external-command|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18504" PostTypeId="2" ParentId="18503" CreationDate="2019-01-08T23:29:12.667" Score="3" Body="&lt;p&gt;Are you looking for &lt;code&gt;search()&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call search('\.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help search()&lt;/code&gt; for all the details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or with &lt;code&gt;:exec&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec &quot;normal /\\.\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I would prefer &lt;code&gt;search()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the differences between single and double quotes. With single quotes a single backslash escapes the dot, with double quotes a double backslash is needed. Also &lt;code&gt;\&amp;lt;CR&amp;gt;&lt;/code&gt; does only work in double quotes. &#xA;See &lt;code&gt;:help string&lt;/code&gt; and &lt;code&gt;:help literal-string&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-08T23:38:26.047" LastActivityDate="2019-01-08T23:38:26.047" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18505" PostTypeId="1" AcceptedAnswerId="18506" CreationDate="2019-01-09T04:16:11.657" Score="0" ViewCount="789" Body="&lt;p&gt;In my current machine, I use Vim 8.1 in a Ubuntu 18's default terminal (Vim is running with TERM=xterm256-color, which is a requirement for me). Everything works perfectly, with the exception of the fact that the keyboard's Numpad numerical keys do not work Vim's &lt;code&gt;Normal Mode&lt;/code&gt; (as a test, I see that they do work in GVim). For instance, it does not matter what mappings I try to use them in, nothing happens. But if I open GVim and try there, they work perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found multiple questions in multiple Stackexchange sites and also eslewhere, but they all talk about very particular cases. For instance, &lt;a href=&quot;https://superuser.com/questions/565178/how-do-i-get-the-numpad-to-work-in-vim-using-iterm2-on-osx-with-term-xterm/939832#939832&quot;&gt;this one&lt;/a&gt; has seemingly good solutions for Mac OS users of Vim with TERM=xterm, while &lt;a href=&quot;https://stackoverflow.com/questions/15160855/numpad-keys-dont-work&quot;&gt;this one&lt;/a&gt; teaches how to solve this problem in case it appears when using Ubuntu in a virtual machine. &lt;a href=&quot;https://www.netsarang.com/forum/xshell/1719/Number_keypad_in_vim_insert_mode&quot; rel=&quot;nofollow noreferrer&quot;&gt;This one&lt;/a&gt; teaches how to solve the problem when using Vim in SecureCRT terminals. Many describe how to solve the problem for PuTTy (e.g. &lt;a href=&quot;http://vim.wikia.com/wiki/PuTTY_numeric_keypad_mappings&quot; rel=&quot;nofollow noreferrer&quot;&gt;this Vim Wiki&lt;/a&gt;). Also, it is easy to find online many suggestions of crazy keybindings that are supposed to solve the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of those worked for me. What is more surprising, I see no mention anywhere about how one would solve this problem when using Vim Ubuntu's default terminal (with Vim's TERM=xTerm256-color).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence me asking for help on that task. How could I try solving this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: One example that might be informative is the following. Suppose that I include in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set showcmd&#xA;nnoremap &amp;lt;k4&amp;gt; :echom &quot;4-left&quot;&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;k8&amp;gt; :echom &quot;8-up&quot;&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;k6&amp;gt; :echom &quot;6-right&quot;&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;k2&amp;gt; :echom &quot;2-down&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, suppose that I start GVim and hit the Numpad keys 4, 8, 8 and 6, in that order. In the left of the bottom bar I will see &quot;4-left&quot;, &quot;8-up&quot;, &quot;8-up&quot; and 6-right&quot; (i.e. mappings worked), in that order and in the right of the bottom bar I will see 4, 8, 8 and then 6 appearing, in that order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, suppose that I open Vim and again hit the Numpad keys 4, 8, 8 and 6, in that order. Nothing shows up in the left of the bottom bar (no command is issued) and in the right of the bottom bar the number 4886 appears.&lt;/p&gt;&#xA;" OwnerUserId="20408" LastEditorUserId="20408" LastEditDate="2019-01-09T09:23:03.567" LastActivityDate="2019-01-09T10:34:27.777" Title="Making Numpad numerical keys work in Vim using Ubuntu 18's terminal" Tags="|key-bindings|terminal|keyboard-layout|linux-ubuntu|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18506" PostTypeId="2" ParentId="18505" CreationDate="2019-01-09T10:34:27.777" Score="1" Body="&lt;p&gt;I think that GNOME-Terminal does not distinguish between a numpad key and the corresponding &quot;normal&quot; key. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just open a terminal and switch the numpad off, so that numbers are disabled, but &lt;kbd&gt;Numpad-Home&lt;/kbd&gt; etc are active. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then press &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; followed by &lt;kbd&gt;Numpad-HOME&lt;/kbd&gt;. This will output &lt;code&gt;^[[H&lt;/code&gt;. Now press &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; followed by &lt;kbd&gt;HOME&lt;/kbd&gt;. This will also output &lt;code&gt;^[[H&lt;/code&gt;. So GNOME-Terminal emits the same codes for the key on the numpad and the corresponding &quot;normal key&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe the center key (5) is different, as I don't know the corresponding &quot;normal key&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems also be true for Ctrl-Keys (&lt;kbd&gt;Ctrl-HOME&lt;/kbd&gt; and &lt;kbd&gt;Ctrl-Numpad-HOME&lt;/kbd&gt; both result in &lt;code&gt;^[[1;5H&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if there is any setting, so GNOME-Terminal sends different codes for the numpad keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I also tested with XTerm, same result.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-09T10:34:27.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18507" PostTypeId="2" ParentId="18497" CreationDate="2019-01-09T13:49:59.020" Score="0" Body="&lt;p&gt;On your Ubuntu system you have Vim installed in the &quot;tiny&quot; version. Vim can be compiled in different &quot;sizes&quot; from &quot;tiny&quot; to &quot;huge&quot;. &quot;Tiny&quot; comes with a absolute minimum set of features, while &quot;Huge&quot; contains nearly everything. For example, the tiny build does not support syntax highlighting, hence the error on &lt;code&gt;syntax on&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend to install the package &quot;vim-gtk3&quot;. This is a &quot;huge&quot; build with all bells an whistles, including syntax highlighting, gui etc.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-09T13:49:59.020" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18508" PostTypeId="2" ParentId="18448" CreationDate="2019-01-09T15:27:29.230" Score="1" Body="&lt;p&gt;This comes from your &lt;code&gt;isk&lt;/code&gt; setting. This tells vim what is considered part of a word and what isn't, which is important for the asterisk command since searches for the word under the cursor. If &lt;code&gt;isk&lt;/code&gt; includes &lt;code&gt;?&lt;/code&gt; or &lt;code&gt;63&lt;/code&gt; (The code point of &lt;code&gt;?&lt;/code&gt;), then &lt;code&gt;?&lt;/code&gt; is treated just like letters, so &lt;code&gt;life&lt;/code&gt; is a different word from &lt;code&gt;life?&lt;/code&gt; just as &lt;code&gt;lifex&lt;/code&gt; would be different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, the setting of &lt;code&gt;isk&lt;/code&gt; is &lt;code&gt;&quot;@,48-57,_,192-255&quot;&lt;/code&gt;. Which doesn't include &lt;code&gt;?&lt;/code&gt;. However, if you open up a new file with the &lt;code&gt;.sv&lt;/code&gt; extension, and you have &lt;code&gt;filetype plugin on&lt;/code&gt;, then vim will know what kind of file &lt;code&gt;.sv&lt;/code&gt; is. Presumably, in this type of file, &lt;code&gt;?&lt;/code&gt; are treated different with this filetype, so vim adds it to &lt;code&gt;isk&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get around this, add the following line to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.sv set isk=@,48-57,_,192-255,#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-01-09T15:27:29.230" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18509" PostTypeId="2" ParentId="18433" CreationDate="2019-01-10T00:31:43.737" Score="12" Body="&lt;p&gt;Probably your default &lt;code&gt;python3&lt;/code&gt; is &lt;code&gt;3.6&lt;/code&gt;. You need, then, tell the build process to use &lt;code&gt;python3.7&lt;/code&gt;. You can do that with the parameters &lt;code&gt;--with-python3-command&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --with-python3-command=python3.7 \&#xA;            --with-python3-config-dir=/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu \&#xA;            ... (other config params) ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-01-10T00:31:43.737" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18510" PostTypeId="1" CreationDate="2019-01-10T01:11:14.103" Score="0" ViewCount="242" Body="&lt;p&gt;Writing &lt;code&gt;:set noremap ö :&lt;/code&gt; in vim works fine, but with my .vimrc file containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noremap ö :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/anna/.vimrc:&#xA;line    1:&#xA;E518: Unknown option: ö &#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerDisplayName="user20488" LastActivityDate="2019-01-10T02:04:33.203" Title="How to remap ö in .vimrc?" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ClosedDate="2019-01-10T02:04:16.647" ContentLicense="CC BY-SA 4.0" />
  <row Id="18511" PostTypeId="2" ParentId="18510" CreationDate="2019-01-10T01:17:38.220" Score="2" Body="&lt;p&gt;&lt;em&gt;It appears the OP was actually trying to define a mapping as opposed to doing a set on &lt;code&gt;'remap'&lt;/code&gt;. That was unexpected and, unfortunately, I had written a good part of the dissertation below before finding out. Ah well, in for a penny, in for a pound...I finished it in case it might be useful to someone.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;The option &lt;code&gt;'remap'&lt;/code&gt; takes a boolean value. If you want to disable recursive mapping globally (you really shouldn't do this, see below) then you want &lt;code&gt;:set noremap&lt;/code&gt;. To enable it's &lt;code&gt;:set remap&lt;/code&gt;. To toggle the value &lt;code&gt;:set remap!&lt;/code&gt;. To set it to the default value (enabled) &lt;code&gt;:set remap&amp;amp;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Please note the help for this setting &lt;code&gt;:h 'remap'&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Allows for mappings to work recursively...NOTE: To avoid portability problems&#xA;with Vim scripts, always keep this option at the default &amp;quot;on&amp;quot;.  Only switch it&#xA;off when working with old Vi scripts.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What that means is you will want to do, for example,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap lhs rhs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;...instead of...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:nmap lhs rhs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In fact, there's almost no reason to ever use the recursive/&lt;code&gt;:map&lt;/code&gt; variations. So it's understandable why one would want to use the global setting. But it's better to follow Vim's advice and get in the habit of using non-recursive commands when defining each mapping.&lt;/p&gt;&#xA;&lt;p&gt;Note: there are a lot of entries already on this site that talk about why recursive can be an issue. Here are a couple that do so and are also high quality, useful answers about mapping in general:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/2089/what-are-the-differences-between-the-map-noremap-abbrev-and-noreabbrev-command/2092#2092&quot;&gt;What are the differences between the map, noremap, abbrev and noreabbrev commands?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/7723/11054&quot;&gt;How to debug a mapping?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There's also this chapter in the excellent guide &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/05.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript The Hard Way&lt;/a&gt;. To quote part of it...&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When should you use these nonrecursive variants instead of their normal counterparts?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Always.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;No, seriously, always.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Take this with a small grain of salt. They're rare but there are legitimate reasons for using recursive mapping. (And by the time one recognizes such a use case one is likely to have a good understanding of the risks and use the feature wisely, if at all. &lt;em&gt;With a nod to @DBenKnoble.&lt;/em&gt;)&lt;/p&gt;&#xA;&lt;p&gt;(BTW depending on your level of experience you might want to read the two chapters that precede the linked one while you're at it as they discuss mapping starting with the basics.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-01-10T02:04:33.203" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18512" PostTypeId="1" CreationDate="2019-01-10T07:00:33.770" Score="3" ViewCount="245" Body="&lt;p&gt;By default, vim seems to save a backup file ending in a tilde (see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#backup&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help backup&lt;/code&gt;&lt;/a&gt;). For example, when editing &lt;code&gt;foobar.txt&lt;/code&gt;, a backup file &lt;code&gt;foobar.txt~&lt;/code&gt; is saved. I would like to have it saved to &lt;code&gt;.foobar.txt~&lt;/code&gt; instead. On Linux, a file starting with a dot is considered a hidden file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't use the option &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;backupext&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;backupext&lt;/code&gt;&lt;/a&gt; because it only allows use to set an extension and not a prefix.&lt;/p&gt;&#xA;" OwnerUserId="7244" LastActivityDate="2019-01-12T10:18:41.457" Title="How can I make backup files start with a dot to make them hidden? (not just tilde)" Tags="|backup|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18513" PostTypeId="2" ParentId="15092" CreationDate="2019-01-10T07:56:23.903" Score="1" Body="&lt;p&gt;The following works elegantly without the need for too many bindings.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:CRComplete()&#xA;  if empty(v:completed_item)&#xA;    execute &quot;norm! i\&amp;lt;CR&amp;gt;&quot;&#xA;  endif endfunction&#xA;inoremap &amp;lt;CR&amp;gt; &amp;lt;LEFT&amp;gt;&amp;lt;RIGHT&amp;gt;&amp;lt;C-O&amp;gt;:call &amp;lt;SID&amp;gt;CRComplete()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edits: In view of Hotschke's answer, the check for &lt;code&gt;v:completed_item&lt;/code&gt; in my function above is simplified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;LEFT&amp;gt;&amp;lt;RIGHT&amp;gt;&lt;/code&gt; is added for the situation in which omni-complete returns a &lt;code&gt;Pattern not found&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="20193" LastEditorUserId="20193" LastEditDate="2019-01-10T22:24:28.057" LastActivityDate="2019-01-10T22:24:28.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18514" PostTypeId="2" ParentId="15092" CreationDate="2019-01-10T08:52:39.370" Score="0" Body="&lt;p&gt;My version works as following&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;When pum is visible &amp;amp; entry selected which is a snippet, expand snippet.&lt;/li&gt;&#xA;&lt;li&gt;When pum is visible &amp;amp; entry selected which is not a snippet, only close pum.&lt;/li&gt;&#xA;&lt;li&gt;When pum is visible &amp;amp; no entry selected, close pum and insert newline.&lt;/li&gt;&#xA;&lt;li&gt;When pum is not visible, insert newline.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:ExpandSnippetOrClosePumOrReturnNewline()&#xA;    if pumvisible()&#xA;        if !empty(v:completed_item)&#xA;            let snippet = UltiSnips#ExpandSnippet()&#xA;            if g:ulti_expand_res &amp;gt; 0&#xA;                return snippet&#xA;            else&#xA;                return &quot;\&amp;lt;C-y&amp;gt;&quot;&#xA;            endif&#xA;        else&#xA;            return &quot;\&amp;lt;C-y&amp;gt;\&amp;lt;CR&amp;gt;&quot;&#xA;        endif&#xA;    else&#xA;        return &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;CR&amp;gt; &amp;lt;C-r&amp;gt;=&amp;lt;SID&amp;gt;ExpandSnippetOrClosePumOrReturnNewline()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;see also &lt;a href=&quot;https://github.com/vim/vim/issues/2004&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/issues/2004&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-01-10T08:52:39.370" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18515" PostTypeId="1" AcceptedAnswerId="18529" CreationDate="2019-01-10T13:21:45.250" Score="3" ViewCount="2466" Body="&lt;p&gt;I use the following setting for automatic line number toggle.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup numbertoggle&#xA;  autocmd!&#xA;  autocmd BufEnter,FocusGained,InsertLeave * set relativenumber&#xA;  autocmd BufLeave,FocusLost,InsertEnter   * set norelativenumber&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it seems that this setting does not work inside tmux.  If I open two tmux panes side by side and open  a file with Neovim in one pane and then switch to another tmux pane, the relative line number in Neovim does not change to absolute number. How to fix this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides, I use &lt;code&gt;set -g mouse on&lt;/code&gt; inside &lt;code&gt;~/.tmux.conf&lt;/code&gt; so that I can use mouse clicks to change tmux panes, if that information is relevant.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastEditorUserId="15292" LastEditDate="2019-01-14T02:29:06.760" LastActivityDate="2020-01-25T03:56:53.480" Title="Nvim can not detect focus change inside tmux sessions" Tags="|neovim|line-numbers|tmux|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18516" PostTypeId="2" ParentId="18010" CreationDate="2019-01-10T13:46:10.320" Score="1" Body="&lt;p&gt;Perhaps &lt;kbd&gt;Ctrl-6&lt;/kbd&gt; is not recognized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open (neo)vim and go into insert mode. Then enter &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; followed by &lt;kbd&gt;Ctrl-6&lt;/kbd&gt;. See what it prints. &#xA;For me on Ubuntu (GNOME-Terminal) this prints &lt;code&gt;^^&lt;/code&gt;. So here &lt;kbd&gt;Ctrl-6&lt;/kbd&gt; is &lt;kbd&gt;Ctrl-^&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See what it prints for you, then you are able to fix your mapping.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In the way described above, you can check if a control-key is mappable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check if &lt;kbd&gt;Ctrl-X&lt;/kbd&gt; is mappable, you go to insert mode and hit &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; followed by &lt;kbd&gt;Ctrl-X&lt;/kbd&gt;. This prints &lt;code&gt;^X&lt;/code&gt; (this is one character). So  &lt;kbd&gt;Ctrl-X&lt;/kbd&gt; is mappable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we would like to map &lt;kbd&gt;Ctrl-#&lt;/kbd&gt;: Again &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; followed by &lt;kbd&gt;Ctrl-#&lt;/kbd&gt;. This just prints &lt;code&gt;#&lt;/code&gt;. So &lt;kbd&gt;Ctrl-#&lt;/kbd&gt; is not mappable, as it is identical to &lt;kbd&gt;#&lt;/kbd&gt;. (Tested with GNOME-Terminal.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some keys might already be used as shortcut by the terminal. In that case the terminal consumes the key and does not send it to Vim. If this is the case, check if you can reconfigure shortcuts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the terminal is in control here. (Neo)Vim only get those keys, that the terminal sends to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that gVim has more capabilities. E.g. gVim is able to distinguish between &lt;kbd&gt;Home&lt;/kbd&gt; and &lt;kbd&gt;kHome&lt;/kbd&gt; (NumPad). Vim in GNOME-terminal is not.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-10T15:50:24.070" LastActivityDate="2019-01-10T15:50:24.070" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18518" PostTypeId="2" ParentId="18477" CreationDate="2019-01-10T18:17:40.950" Score="0" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#CursorHold&quot; rel=&quot;nofollow noreferrer&quot;&gt;CursorHold&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#CursorHoldI&quot; rel=&quot;nofollow noreferrer&quot;&gt;CursorHoldI&lt;/a&gt; events of &lt;code&gt;autocmd&lt;/code&gt; to implement this easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;code&gt;autocmd&lt;/code&gt; is sufficient to enable this for the current buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd CursorHold,CursorHoldI &amp;lt;buffer&amp;gt; %d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will run the &lt;code&gt;%d&lt;/code&gt; command (delete whole buffer) once no key is pressed for the duration of &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27updatetime%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'updatetime'&lt;/code&gt;&lt;/a&gt;, which defaults to 4 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to update that to a shorter or longer interval, just set that option (it takes a number of milliseconds.) To erase after 10s of inactivity, for instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setlocal updatetime=10000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using both &lt;code&gt;CursorHoldI&lt;/code&gt; and &lt;code&gt;CursorHold&lt;/code&gt; means this works whether you're in insert mode or normal mode. There are some limitations though, it doesn't trigger in Visual mode, when waiting for a command to be typed or in operator-pending mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also undo the deletion using &lt;code&gt;u&lt;/code&gt;, or just paste back from the default buffer... So it's not foolproof (it all depends on what you're trying to accomplish, I guess.) It's probably a good start though, it's pretty simple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If you're looking for something more robust and you don't mind depending on Vim 8 or nvim features, you can probably build something better using &lt;a href=&quot;https://vimhelp.org/eval.txt.html#timer_start%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;timer_start()&lt;/code&gt;&lt;/a&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-01-10T18:17:40.950" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18519" PostTypeId="2" ParentId="18512" CreationDate="2019-01-10T18:39:55.633" Score="1" Body="&lt;p&gt;I'd recommend to keep all of Vim's backup and state files in their own directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set directory=$HOME/tmp/vim//&#xA;set backupdir=$HOME/tmp/vim//&#xA;set undodir=$HOME/tmp/vim//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The two slashes at the end are important to ensure names are unique:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;For Unix and Win32, if a directory ends in two path separators, the swap file name will be built from the complete path to the file with all path separators substituted to percent '%' signs. This will ensure file name uniqueness in the preserve directory.&lt;/em&gt;&#xA;(&lt;code&gt;:help directory&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to store these file in the current directory as well -- see the documentation &lt;code&gt;:help directory&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7687" LastEditorUserId="7687" LastEditDate="2019-01-12T10:18:41.457" LastActivityDate="2019-01-12T10:18:41.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18521" PostTypeId="2" ParentId="18515" CreationDate="2019-01-10T21:46:40.273" Score="2" Body="&lt;p&gt;As  D. Ben Knoble said in his comment, &quot;you haven't left the buffer or entered insert mode when you switch, so it makes sense those don't trigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the help for FocusGained / Lost says: &quot;Only for the GUI version and a few console versions where this can be detected.&quot; I guess the console never lost/gained focus as you switch tmux panes. So even if the console you use could detect focus lost/gained, it would not trigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the source of Vim, the comment on the function &lt;code&gt;ui_focus_change&lt;/code&gt; in &lt;code&gt;ui.c&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * Called when focus changed.  Used for the GUI or for systems where this can&#xA; * be done in the console (Win32).&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-11T07:08:05.023" LastActivityDate="2019-01-11T07:08:05.023" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18522" PostTypeId="1" AcceptedAnswerId="18523" CreationDate="2019-01-10T21:49:43.110" Score="0" ViewCount="257" Body="&lt;p&gt;When I open a Gnome terminal in my Ubuntu 18 and execute the command &lt;code&gt;ipython&lt;/code&gt;, I start an Anaconda IPython terminal version 5.8.0. Within Vim 8.1, that is what I also get if I first open a Vim terminal buffer with &lt;code&gt;:term&lt;/code&gt;, navigate to the terminal and then execute the &lt;code&gt;ipython&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zyPwn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zyPwn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if instead I use the command &lt;code&gt;:term ipython&lt;/code&gt;, I get a different non-Anaconda version of the IPython terminal:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Qzrb5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qzrb5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why would that be the case and how could one make sure that &lt;code&gt;:term ipython&lt;/code&gt; gives the same version as is given by executing &lt;code&gt;ipython&lt;/code&gt; on the terminal (in my case, the Anaconda one in the first picture)?&lt;/p&gt;&#xA;" OwnerUserId="20492" LastActivityDate="2019-01-10T22:27:24.450" Title="In Vim 8.1, &quot;:term ipython&quot; gives a different version of IPython than typing &quot;ipython&quot; on an already open terminal" Tags="|terminal|terminal-buffer|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18523" PostTypeId="2" ParentId="18522" CreationDate="2019-01-10T22:27:24.450" Score="0" Body="&lt;p&gt;Thanks to @Ralf's comment to my question, I was able to identify that within Vim the system's &lt;code&gt;$PATH&lt;/code&gt; did not contain Anaconda2's path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This appears to happen because when Anaconda2 is installed, by default its path gets added to the &lt;code&gt;.baschrc&lt;/code&gt; file, but that only affects whatever is opened via bash terminal - and I was opening Vim via a Desktop shortcut to Gnome-terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence, a simple solution is to add Anaconda2's path to the Profile system's &lt;code&gt;$PATH&lt;/code&gt; variable. To do that, open your profile:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gedit ~/.profile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add a line to the file like the following (but of course substituting with your own Anaconda2's path):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PATH=&quot;/home/username/Programs/anaconda2/bin:$PATH&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20492" LastActivityDate="2019-01-10T22:27:24.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18524" PostTypeId="1" AcceptedAnswerId="18525" CreationDate="2019-01-11T02:07:20.187" Score="1" ViewCount="151" Body="&lt;p&gt;In Vim wrapping lines at 80 characters without breaking words&#xA;can be done with the following commands according to this &lt;a href=&quot;http://vim.wikia.com/wiki/80_character_line_wrap_without_broken_words&quot; rel=&quot;nofollow noreferrer&quot;&gt;article&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatoptions+=w&#xA;:set tw=80&#xA;gggqG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setting 80 char wrap is accomplished by typing &lt;code&gt;gggqG&lt;/code&gt; after the two &lt;code&gt;:set ...&lt;/code&gt; commands. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to change &lt;code&gt;gggqG&lt;/code&gt; to &lt;code&gt;gqG&lt;/code&gt; or &lt;code&gt;ggq&lt;/code&gt; and if so how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The article also mentions: &quot;Use the following mapping to format the current paragraph&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap Q gqip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does &quot;mapping&quot; mean in this case, and what are the advantages between the two approaches?&lt;/p&gt;&#xA;" OwnerUserId="20504" LastActivityDate="2019-01-11T02:20:23.663" Title="How to create or modify vim commands?" Tags="|vimrc|vimscript|gvim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18525" PostTypeId="2" ParentId="18524" CreationDate="2019-01-11T02:20:23.663" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What does &quot;mapping&quot; mean in this case, and what are the advantages between the two approaches?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It means that when you press &lt;code&gt;Q&lt;/code&gt;, vim reacts as if you had typed &lt;code&gt;gqip&lt;/code&gt;. The advantage of this is that you can create whatever keyboard shortcuts you like and use vim the way that feels most naturally to you.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to change &lt;code&gt;gggqG&lt;/code&gt; to &lt;code&gt;gqG&lt;/code&gt; or &lt;code&gt;ggq&lt;/code&gt; and if so how?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, absolutely. Either one of these should do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap gqG gggqG&#xA;:nnoremap ggq gggqG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, I would recommend putting both this mapping and the &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatoptions+=w&#xA;:set tw=80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that you mention in your &lt;code&gt;.vimrc&lt;/code&gt;. Basically just add all of these lines to a file named &lt;code&gt;.vimrc&lt;/code&gt; and save it in your home directory, then vim will automatically run those commands when you launch it, so you won't need to run those commands everytime you open vim. Then you can format with just &lt;code&gt;gggqG&lt;/code&gt; or whatever you map that to rather than typing it all out each time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that you won't need the colon if you add these lines to your vimrc. This:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set formatoptions+=w&#xA;set tw=80&#xA;nnoremap gqG gggqG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is sufficient.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-01-11T02:20:23.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18526" PostTypeId="2" ParentId="9522" CreationDate="2019-01-11T06:55:12.163" Score="23" Body="&lt;p&gt;The answer provided by @statox is very descriptive, but for a new user that can be overwhelming. Instead I want to outline what you need to do in step-by-step pointers.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Create &lt;code&gt;pack/*/start&lt;/code&gt; directory under any of the directories provided by &lt;code&gt;set packpath&lt;/code&gt;. I did in &lt;code&gt;~/.config/nvim/pack/*/start&lt;/code&gt;. &lt;strong&gt;Note&lt;/strong&gt; that you can use any directory name you want in place of &lt;code&gt;*&lt;/code&gt; but you can't omit it totally. For example, you can use directory &lt;code&gt;~/.config/nvim/pack/foo/start&lt;/code&gt; or &lt;code&gt;~/.config/nvim/pack/bar/start&lt;/code&gt; but not &lt;code&gt;~/.config/nvim/pack/start&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to the &lt;code&gt;pack/*/start&lt;/code&gt; directory and clone the package there.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fire up n/vim and do &lt;code&gt;:scriptnames&lt;/code&gt; to check if everything is loaded. Don't worry if not every part is loaded, because some files are meant to loaded after some hook, e.g. &lt;code&gt;autoload/plugin.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To uninstall, just remove the directory where you cloned the package. Don't need to do anything else.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Do &lt;code&gt;:helptags ALL&lt;/code&gt; to generate tags for all the help docs. Do &lt;code&gt;:helptags {dir}&lt;/code&gt; for generating tags for the help docs under directory &lt;code&gt;dir&lt;/code&gt;. For example, if you put your plugin in &lt;code&gt;~/.config/nvim/pack/foo/plugin_name&lt;/code&gt;, then do &lt;code&gt;:helptags ~/.config/nvim/pack/foo/plugin_name/doc&lt;/code&gt;. That will generate a &lt;code&gt;tags&lt;/code&gt; file in the doc directory of the plugin. If you remove the plugin from the directory, the tags file will be gone and vim will not find the help file, so you don't need to uninstall the doc file manually.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2022-10-06T15:49:53.583" LastActivityDate="2022-10-06T15:49:53.583" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18527" PostTypeId="1" CreationDate="2019-01-11T08:16:36.140" Score="0" ViewCount="66" Body="&lt;p&gt;i want to write a makro and need to know how i can move to the end and to the beginning of a string, respektively i want to visually select the link so that i can surround it with brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my line in vim looks like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- test test http://www.test.tets/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the cursor is positioned somewhere in the link.&#xA;this case is somehow special, because the link ends on the end of the line. i need a general solution, which also runs, when the link is in the middle of a line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- test http://test.test   tset and so on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i want to visually select the link and than surround it with brackets.&#xA;this is for a markdown file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i already tried to use the word movements, but they do not work in links.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thx in advance!&lt;/p&gt;&#xA;" OwnerUserId="20506" LastEditorUserId="20506" LastEditDate="2019-01-11T08:37:00.837" LastActivityDate="2022-10-31T04:11:01.340" Title="how to move to the end of a string / beginning of string for a macro" Tags="|cursor-movement|visual-mode|macro|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18528" PostTypeId="1" CreationDate="2019-01-11T11:30:14.690" Score="0" ViewCount="56" Body="&lt;p&gt;If I look in the documentation for Vim, &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/various.html#+feature-list&quot; rel=&quot;nofollow noreferrer&quot;&gt;it lists the compilable features&lt;/a&gt;, but: this list shows the feature as the help output, not how the feature is actually configured during the build. For example, it lists:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+cscope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but to actually compile this feature, you use a different switch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--enable-cscope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get documentation on the actual switches?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2019-10-09T12:02:50.450" Title="Where are the compile options documented with the actual switches?" Tags="|compile-vim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18529" PostTypeId="2" ParentId="18515" CreationDate="2019-01-11T12:19:31.223" Score="7" Body="&lt;p&gt;I opened &lt;a href=&quot;https://github.com/neovim/neovim/issues/9486&quot; rel=&quot;noreferrer&quot;&gt;an issue&lt;/a&gt; on Neovim repo and get the right answer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We need to turn on the &lt;code&gt;focus-events&lt;/code&gt; for tmux. Edit the tmux config file &lt;code&gt;~/.tmux.conf&lt;/code&gt; and add the following setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set -g focus-events on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Refresh the tmux session and the automatic relative line number toggle should work as expected now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;For some users using some terminal, setting &lt;code&gt;focus-events&lt;/code&gt; for tmux solely does not work. You may also need to install the vim plugin &lt;a href=&quot;https://vi.stackexchange.com/a/18537/11054&quot;&gt;described in B Layer's answer&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15292" LastEditorUserId="11054" LastEditDate="2019-01-21T11:20:50.813" LastActivityDate="2019-01-21T11:20:50.813" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18530" PostTypeId="2" ParentId="17416" CreationDate="2019-01-11T14:06:54.677" Score="1" Body="&lt;p&gt;Try &lt;a href=&quot;https://github.com/maxmellon/vim-jsx-pretty&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;maxmellon/vim-jsx-pretty&lt;/code&gt;&lt;/a&gt;. The best React JSX/TSX syntax plugin for vim I have ever used.&lt;/p&gt;&#xA;" OwnerUserId="11309" LastActivityDate="2019-01-11T14:06:54.677" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18531" PostTypeId="1" CreationDate="2019-01-11T14:44:54.793" Score="0" ViewCount="102" Body="&lt;p&gt;I am compiling vim under Arch linux and it is failing the test &quot;test_netbeans.vim&quot; even though I did not ask for netbeans to be enabled for the build.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried editing the shared.vim file and removing the test files but it does not work because the compilation system apparently rewrites the test files every time it compiles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I either ignore the test or delete it?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2019-02-10T16:01:35.310" Title="How can I delete or ignore a test when compiling vim?" Tags="|compile-vim|linux-arch|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18533" PostTypeId="2" ParentId="18531" CreationDate="2019-01-11T15:37:54.893" Score="1" Body="&lt;p&gt;I worked around this problem by using the compile switch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--disable-netbeans&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, obviously it is just a workaround and the test failure will be a problem for anyone that wants to use netbeans with compiled vim.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2019-01-11T15:37:54.893" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18534" PostTypeId="1" AcceptedAnswerId="18566" CreationDate="2019-01-11T16:19:09.643" Score="0" ViewCount="69" Body="&lt;p&gt;I use fzf.vim (with rg) to search through (grep) my project.&lt;br&gt;&#xA;The problem with this implementation is that (from what I understand) fzf.vim joins all the files (adding filename at the beginning of the line) and then fzf does the fuzzy search, so 'test' will find all the occurance of 'test' in all files but also will show all the lines from the file that have 'test' in its name (e.g. test.txt).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin/patch/etc that have grep (ag/rg etc.) that is lazy?&lt;br&gt;&#xA;What I mean by that is:&lt;br&gt;&#xA;Command is executed on type and there is delay to prevent executing command too frequently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best regards&lt;/p&gt;&#xA;" OwnerUserId="20509" LastActivityDate="2019-01-14T16:23:17.897" Title="Grep on type with delay. Scripting / Looking for plugin" Tags="|search|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18535" PostTypeId="1" AcceptedAnswerId="18536" CreationDate="2019-01-11T21:41:03.953" Score="1" ViewCount="1200" Body="&lt;p&gt;I really like not having my cursor at the bottom part of the screen. Using &lt;code&gt;:set scrolloff=20&lt;/code&gt; does help when scrolling down a file, but it doesn't work when I reach the bottom (unless I &lt;code&gt;zz&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another problem (and the main question) is how to get vim to show the virtual space when opening a file? I have it setup to set the cursor at the last line where I was editing, and if that line is at the end of the file, it will open at the bottom.&lt;/p&gt;&#xA;" OwnerUserId="11916" LastActivityDate="2019-01-12T08:49:24.177" Title="How do I make vim display virtual space at the bottom when opening a file?" Tags="|vimrc|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18536" PostTypeId="2" ParentId="18535" CreationDate="2019-01-12T00:03:57.130" Score="1" Body="&lt;p&gt;Perhaps&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWinEnter * exe &quot;normal zz&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I guess there will be side effects. Test thoroughly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One side effect: Assume you have 2 buffers loaded and Vim has only one (&quot;full terminal&quot;) window. So one buffer is displayed. The other is hidden. If you switch to the hidden buffer, &lt;code&gt;zz&lt;/code&gt; will be executed.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-12T08:49:24.177" LastActivityDate="2019-01-12T08:49:24.177" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18537" PostTypeId="2" ParentId="18515" CreationDate="2019-01-12T06:07:34.690" Score="3" Body="&lt;p&gt;My understanding of this issue is that xterm-compatible terminals (at least...there may be others) emit a certain control sequence when focus is gained/lost from a terminal window. Rather than Vim, say, intercepting said sequences and triggering &lt;code&gt;FocusGained&lt;/code&gt;/&lt;code&gt;FocusLost&lt;/code&gt; events in response it ignores them. Fortunately someone wrote a vim/neovim plugin that will do exactly that called &lt;a href=&quot;https://github.com/tmux-plugins/vim-tmux-focus-events&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-tmux-focus-events&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems not all terminals need the plugin to solve the problem. As OP notes in their answer it was enough in their case to simply enable the tmux &lt;code&gt;focus-events&lt;/code&gt; setting in their &lt;code&gt;tmux.conf&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; set -g focus-events on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And actually this is required regardless; the plugin's README instructs one to enable same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So try the tmux setting alone first. If &lt;em&gt;no-joy&lt;/em&gt; try the plugin, too. (I'm trying to confirm it but I believe one must be using tmux 1.8 or later for all this.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(As a bonus the plugin also helps with getting &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;autoread&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;autoread&lt;/code&gt;&lt;/a&gt; to work in terminals/tmux, too.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Just noticed that someone submitted back in '13 &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_dev/ASn8QqQqVe0&quot; rel=&quot;nofollow noreferrer&quot;&gt;a patch for Vim&lt;/a&gt; that would obviate the need for the plugin. Doesn't look to be getting much love.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-01-12T07:11:40.963" LastActivityDate="2019-01-12T07:11:40.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18538" PostTypeId="1" AcceptedAnswerId="18541" CreationDate="2019-01-12T06:37:46.683" Score="1" ViewCount="135" Body="&lt;p&gt;Open a &lt;code&gt;c&lt;/code&gt; file and then type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int&#xA;main&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then hit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;gg=G&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    int&#xA;main&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this an intended behavior? Is there a way to change this? I prefer it to be retained as is because most projects have it like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some settings that I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fr          # c&#xA;set cindent     # cindent&#xA;set ai          # autoindent&#xA;set si          # smartindent&#xA;set indentexpr  #    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8178" LastEditorUserId="8178" LastEditDate="2019-01-17T06:56:50.670" LastActivityDate="2019-01-17T06:56:50.670" Title="Indenting a c file adds spaces before function's type?" Tags="|indentation|filetype-c|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18539" PostTypeId="1" AcceptedAnswerId="18540" CreationDate="2019-01-12T07:14:18.477" Score="3" ViewCount="592" Body="&lt;p&gt;I like using marks, but I wouldn't mind having a visual indicator of some sort that maybe shows me &quot;you've dropped mark x here&quot;, perhaps a letter in the gutter or some sort of line or character highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin or something for that that works well? I didn't come up with anything on search.&lt;/p&gt;&#xA;" OwnerUserId="10196" LastEditorUserId="2920" LastEditDate="2019-01-12T07:27:12.993" LastActivityDate="2019-01-14T14:36:58.607" Title="Can I get a visual indicator when I drop a mark?" Tags="|mark|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18540" PostTypeId="2" ParentId="18539" CreationDate="2019-01-12T07:29:34.110" Score="7" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Is there a plugin or something for that that works well?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Why yes there is! I use &lt;a href=&quot;https://github.com/kshenoy/vim-signature&quot; rel=&quot;noreferrer&quot;&gt;kshenoy/vim-signature&lt;/a&gt;, and highly recommend it.&lt;/p&gt;&#xA;&lt;p&gt;From the README:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;vim-signature is a plugin to place, toggle and display marks.&lt;/p&gt;&#xA;&lt;p&gt;Apart from the above, you can also&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Navigate forward/backward by position/alphabetical order&lt;/li&gt;&#xA;&lt;li&gt;Displaying multiple marks (upto 2, limited by the signs feature)&lt;/li&gt;&#xA;&lt;li&gt;Placing custom signs &lt;code&gt;!@#$%^&amp;amp;*()&lt;/code&gt; as visual markers&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;And here is an example of what it looks like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/O2OvH.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/O2OvH.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Although I don't typically use the more advanced features, I just use it for the visual display of marks.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-01-12T07:29:34.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18541" PostTypeId="2" ParentId="18538" CreationDate="2019-01-12T09:35:14.280" Score="2" Body="&lt;p&gt;Open a C file and have a look at &lt;code&gt;cinoptions&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cinoptions?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Most likely this is empty. Now add &lt;code&gt;t0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cinoptions+=t0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reformat your C code, and the type should not be indented anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'cinoptions'&lt;/code&gt; and &lt;code&gt;:help cinoptions-values&lt;/code&gt;. There you find that indenting the type by one &lt;code&gt;'shiftwidth'&lt;/code&gt; is the default (when on line for it own).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;cinoptions&lt;/code&gt; is not empty and already contains a entry &lt;code&gt;tN&lt;/code&gt; (&lt;code&gt;N&lt;/code&gt; is a number),&#xA;you have to remove it first:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cinoptions-=tN    &quot;replace N with actual number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-12T09:35:14.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18542" PostTypeId="2" ParentId="18528" CreationDate="2019-01-12T10:12:44.973" Score="1" Body="&lt;p&gt;To configure the build the script &lt;code&gt;configure&lt;/code&gt; in the root of the source tree is used.&#xA;This script supports the option &lt;code&gt;--help&lt;/code&gt;. It will print the available options with explanation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So: &lt;code&gt;cd&lt;/code&gt; to the root of the source tree and run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ./configure --help&#xA;`configure' configures this package to adapt to many kinds of systems.&#xA;&#xA;Usage: auto/configure [OPTION]... [VAR=VALUE]...&#xA;&#xA;...&#xA;  --enable-cscope         Include cscope interface.&#xA;  --enable-workshop       Include Sun Visual Workshop support.&#xA;  --disable-netbeans      Disable NetBeans integration support.&#xA;  --disable-channel       Disable process communication support.&#xA;  --enable-terminal       Enable terminal emulation support.&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: Output is about 150 lines.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-12T10:12:44.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18543" PostTypeId="2" ParentId="2162" CreationDate="2019-01-12T11:25:22.390" Score="4" Body="&lt;pre&gt;&lt;code&gt;set backspace=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is used with v5.4 and earlier. worked for me on mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;looks like on mac i have v3.2:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ bash --version&#xA;GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)&#xA;Copyright (C) 2007 Free Software Foundation, Inc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All versions past 3.2 use the GNU General Public License v3 (GPLv3), which Apple isn't in favor of supporting. A discussion on reddit about this is &lt;a href=&quot;https://www.reddit.com/r/apple/comments/7v97ls/why_doesnt_apple_use_any_gpl_v3_unix_packages_in/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can upgrade to the newest Bash with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;brew install bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this allows to take advantage of programmable completion highlighted &lt;a href=&quot;https://itnext.io/programmable-completion-for-bash-on-macos-f81a0103080b&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="20514" LastEditorUserId="20514" LastEditDate="2019-01-20T19:08:20.653" LastActivityDate="2019-01-20T19:08:20.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18544" PostTypeId="1" AcceptedAnswerId="18545" CreationDate="2019-01-12T14:40:07.210" Score="0" ViewCount="172" Body="&lt;p&gt;My text file looks like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lastname, Firstname&#xA;Doe, John&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to get it to end like this using find replace regex&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Firstname Lastname&#xA;John Doe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This regex throws the error, although using find/replace in atom editor with same pattern works fine.  What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/(\w+),\s(\w+)/$1 $2/:g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20517" LastActivityDate="2019-01-13T22:19:57.550" Title="regex find and replace all with capture groups throws E488: Trailing characters" Tags="|regular-expression|replace|find|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18545" PostTypeId="2" ParentId="18544" CreationDate="2019-01-12T15:40:24.853" Score="1" Body="&lt;p&gt;Try it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(\w\+\),\s\(\w\+\)/\2 \1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or for simpler syntax without all the escapes use &lt;code&gt;\v&lt;/code&gt; for &lt;a href=&quot;http://vim.wikia.com/wiki/Simplifying_regular_expressions_using_magic_and_no-magic&quot; rel=&quot;nofollow noreferrer&quot;&gt;very-magic&lt;/a&gt; ( thanks to @D.BenKnoble )&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(\w+),\s(\w+)/\2 \1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20323" LastEditorUserId="20517" LastEditDate="2019-01-13T22:19:57.550" LastActivityDate="2019-01-13T22:19:57.550" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="18546" PostTypeId="1" AcceptedAnswerId="18555" CreationDate="2019-01-12T15:49:03.647" Score="5" ViewCount="1153" Body="&lt;p&gt;In the screencast below I searched &lt;code&gt;statusline&lt;/code&gt; and then cycle through the results with &lt;code&gt;n&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is it possible to highlight the selected match with a different color than the other matches&lt;/strong&gt;, instead of having them all highlighted in yellow and relying only on the user to notice that the very first character of the match has the usual background color (purple in my case) instead of yellow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EPMOj.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EPMOj.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18613" LastEditorUserId="18613" LastEditDate="2019-01-13T16:59:32.210" LastActivityDate="2021-02-10T15:23:44.490" Title="Can I use a different color for the selected match than for other matches" Tags="|search|highlight|" AnswerCount="4" CommentCount="3" ClosedDate="2021-02-11T09:37:36.690" ContentLicense="CC BY-SA 4.0" />
  <row Id="18547" PostTypeId="1" CreationDate="2019-01-12T17:11:20.793" Score="0" ViewCount="67" Body="&lt;p&gt;Example: I tried finding out about &lt;a href=&quot;https://stackoverflow.com/questions/24711212/vim-auto-fold-when-leaving-fold&quot;&gt;&lt;code&gt;foldclose&lt;/code&gt;&lt;/a&gt; because it sounded strange to me that it isn't a binary setting but still only knows the value &lt;code&gt;&quot;all&quot;&lt;/code&gt;.  I typed &lt;code&gt;:h foldclose&lt;/code&gt; and landed on a description of the command &lt;code&gt;:foldc[lose]&lt;/code&gt;. How do I find the help entry that describes the vim setting &lt;code&gt;foldclose&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="18613" LastActivityDate="2019-01-12T18:41:03.093" Title="How to go to different matching entry in vim's help" Tags="|help-system|" AnswerCount="2" CommentCount="0" ClosedDate="2019-01-12T20:56:27.907" ContentLicense="CC BY-SA 4.0" />
  <row Id="18548" PostTypeId="2" ParentId="18547" CreationDate="2019-01-12T17:49:33.590" Score="1" Body="&lt;p&gt;you can use &lt;code&gt;:help 'foldclose&lt;/code&gt; to get the help for the option foldclose.&#xA;Find details about possible contexts in &lt;code&gt;:help help-context&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2019-01-12T17:49:33.590" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18550" PostTypeId="2" ParentId="18547" CreationDate="2019-01-12T18:41:03.093" Score="1" Body="&lt;p&gt;Use &lt;code&gt;helpgrep&lt;/code&gt; and then navigate through the matches either directly in the quickfix window that is opened or use &lt;code&gt;:lnext&lt;/code&gt; and &lt;code&gt;:lprevious&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="18613" LastActivityDate="2019-01-12T18:41:03.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18551" PostTypeId="2" ParentId="18546" CreationDate="2019-01-12T21:22:48.267" Score="3" Body="&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; &lt;em&gt;For those in a hurry, not interested in the process/context, etc...jump to the last two code blocks, &lt;code&gt;augroup procsearch&lt;/code&gt; and &lt;code&gt;function ProcSearch&lt;/code&gt;. Copy those to your vimrc for a complete solution that works seamlessly with native search (as demonstrated in the GIF).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Haven't considered this before but I think I have the seed of a solution...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you run this command after you've started the search then the match that the cursor is on should be highlighted differently (I've tested that this is so while cycling through matches with &lt;code&gt;n&lt;/code&gt;/&lt;code&gt;N&lt;/code&gt;)...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec 'match HI /\%#' . @/ . '/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key is &lt;code&gt;\%#&lt;/code&gt; which is pattern representing cursor position. (Note: if you enable &lt;code&gt;'ignorecase'&lt;/code&gt; I think you'll need to add &lt;code&gt;\c&lt;/code&gt; to the beginning of this pattern.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace &lt;code&gt;HI&lt;/code&gt; with whatever highlight group you prefer. (For testing with something highly visible you can try &lt;code&gt;Error&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disable the behavior with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:match none&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously you don't want to type that all in whenever you need it. The easiest thing to do is map it. Something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;n  exec 'match HI /\%#' . @/ . '/'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Okay so we've established that you want this behavior every time you do a search. We need to overload the search operation so that the match command is invoked immediately after the usual business. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I removed my previous attempts at a solution since I've got a much better approach and this thing had gotten too long. Feel free to look at the history...if you're so inclined.&lt;/em&gt; ;) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though I earlier bemoaned the lack of an autocommand event for search turns out there is such a thing it's just more general: &lt;code&gt;CmdLineEnter&lt;/code&gt;/&lt;code&gt;CmdLineLeave&lt;/code&gt;. And there is a way, once those events trigger, to distinguish between &lt;code&gt;:&lt;/code&gt; commands and search commands (&lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;) using special string &lt;code&gt;&amp;lt;afile&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now all we need is an autocommand that will call a function each time a search command is completed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup procsearch&#xA;  autocmd!&#xA;  au CmdLineLeave * let b:cmdtype = expand('&amp;lt;afile&amp;gt;') | if (b:cmdtype == '/' || b:cmdtype == '?') | call timer_start(200, 'ProcessSearch') | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did the call asynchronously (&lt;code&gt;timer_start()&lt;/code&gt;) because otherwise the &lt;code&gt;/&lt;/code&gt; register wasn't set yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the callback that calls the &lt;code&gt;:match&lt;/code&gt; command per usual, including proper &lt;code&gt;'ignorecase'&lt;/code&gt; handling:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ProcessSearch(timerid)&#xA;    let l:patt = '\%#' . @/&#xA;    if &amp;amp;ic | let l:patt = '\c' . l:patt | endif&#xA;    exe 'match SpellRare /' . l:patt . '/'&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can unmap &lt;code&gt;&amp;lt;leader&amp;gt;/&lt;/code&gt;...we don't need it anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't always use the functional enhancements that I post as answers in my own config but this is useful enough that I believe I will. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dFuoq.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dFuoq.gif&quot; alt=&quot;demo video&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: next steps would be to make this a little more robust. For instance, the event is triggered even when user aborts out of search with, e.g. &lt;code&gt;Ctrl-C&lt;/code&gt;, so we should check for that. Also, using a delay before calling the function is a little sketchy so that could be tightened up a bit. I'll probably leave these to readers...StackExchange is not about posting production-ready code it's about providing specific answers to specific question, IMO.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-02-08T13:42:31.130" LastActivityDate="2019-02-08T13:42:31.130" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="18552" PostTypeId="2" ParentId="13794" CreationDate="2019-01-13T07:46:21.507" Score="4" Body="&lt;p&gt;You should use  instead of &#xA;So&#xA;&lt;code&gt;imap jj &amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt; :tabnew &amp;lt;cfile&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="20526" LastActivityDate="2019-01-13T07:46:21.507" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18553" PostTypeId="1" AcceptedAnswerId="18554" CreationDate="2019-01-13T10:00:07.560" Score="0" ViewCount="62" Body="&lt;p&gt;I am working with &lt;code&gt;markdown&lt;/code&gt; and writing snippets like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    ```c&#xA;    int&#xA;    main()&#xA;    {&#xA;        return 0;&#xA;    }&#xA;    ```&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is highlighted as a &lt;code&gt;code&lt;/code&gt; in &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eRcK2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eRcK2.png&quot; alt=&quot;Vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However would it possible for the &lt;code&gt;c&lt;/code&gt; section to have the syntax of a normal &lt;code&gt;c&lt;/code&gt; file? I was checking out &lt;code&gt;pyvim&lt;/code&gt; and it has such a feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/a3pUl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/a3pUl.png&quot; alt=&quot;Pyvim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wondering if I can bring it in &lt;code&gt;vim&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8178" LastEditorUserId="8178" LastEditDate="2019-01-13T16:07:00.473" LastActivityDate="2019-01-13T16:07:00.473" Title="Is it possible to make a specific section have a different syntax?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ClosedDate="2019-01-13T12:44:01.110" ContentLicense="CC BY-SA 4.0" />
  <row Id="18554" PostTypeId="2" ParentId="18553" CreationDate="2019-01-13T10:38:25.157" Score="3" Body="&lt;p&gt;Upstream repo for the runtime files for markdown has a &lt;a href=&quot;https://github.com/tpope/vim-markdown#vim-markdown-runtime-files&quot; rel=&quot;nofollow noreferrer&quot;&gt;README&lt;/a&gt; which describes this. Add to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:markdown_fenced_languages = ['c']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Yv2Jg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Yv2Jg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-01-13T10:38:25.157" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18555" PostTypeId="2" ParentId="18546" CreationDate="2019-01-13T17:01:32.153" Score="1" Body="&lt;p&gt;Here is my solution, based on the answer of B Layer and those of many other stackexchange heroes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It supports incremental search highlighting as well and keeps the highlight color of the incremental search highlight after pressing Enter and after pressing &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rtw9Q.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rtw9Q.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the responsible code. (It includes changing the statusline color according to whether there are any matches at all or not. For example, you can see it switch to red when I type &lt;code&gt;statuslim&lt;/code&gt; accidentally. Not included is the code that highlights the linenumber column in red and &#xA;the fact that I am using the plugin &lt;code&gt;romainl/vim-cool&lt;/code&gt; to remove search highlights when the cursor isn't on a match)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HighlightSearch(timer)&#xA;    if (g:firstCall)&#xA;        let g:originalStatusLineHLGroup = execute(&quot;hi StatusLine&quot;)&#xA;        let g:firstCall = 0&#xA;    endif&#xA;    if (exists(&quot;g:searching&quot;) &amp;amp;&amp;amp; g:searching)&#xA;        let searchString = getcmdline()&#xA;        if searchString == &quot;&quot; &#xA;            let searchString = &quot;.&quot;&#xA;        endif&#xA;        let newBG = search(searchString) != 0 ? &quot;green&quot; : &quot;red&quot;&#xA;        if searchString == &quot;.&quot;&#xA;            set whichwrap+=h&#xA;            normal h&#xA;            set whichwrap-=h&#xA;        endif&#xA;        execute(&quot;hi StatusLine ctermfg=&quot; . newBG)&#xA;        let g:highlightTimer = timer_start(50, 'HighlightSearch')&#xA;        let g:searchString = searchString&#xA;    else&#xA;        let originalBG = matchstr(g:originalStatusLineHLGroup, 'ctermfg=\zs[^ ]\+')&#xA;        execute(&quot;hi StatusLine ctermfg=&quot; . originalBG)&#xA;        if exists(&quot;g:highlightTimer&quot;)&#xA;            call timer_stop(g:highlightTimer)&#xA;            call HighlightCursorMatch()&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;function! HighlightCursorMatch() &#xA;    try&#xA;        let l:patt = '\%#'&#xA;        if &amp;amp;ic | let l:patt = '\c' . l:patt | endif&#xA;        exec 'match IncSearch /' . l:patt . g:searchString . '/'&#xA;    endtry&#xA;endfunction&#xA;nnoremap n n:call HighlightCursorMatch()&amp;lt;CR&amp;gt;&#xA;nnoremap N N:call HighlightCursorMatch()&amp;lt;CR&amp;gt;&#xA;augroup betterSeachHighlighting&#xA;    autocmd!&#xA;    autocmd CmdlineEnter * if (index(['?', '/'], getcmdtype()) &amp;gt;= 0) | let g:searching = 1 | let g:firstCall = 1 | call timer_start(1, 'HighlightSearch') | endif&#xA;    autocmd CmdlineLeave * let g:searching = 0&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18613" LastActivityDate="2019-01-13T17:01:32.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18556" PostTypeId="2" ParentId="18527" CreationDate="2019-01-13T18:08:28.580" Score="1" Body="&lt;p&gt;You should probably begin with reading the help topics suggested by @Ralf along with &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#word&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h word&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#WORD&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h WORD&lt;/code&gt;&lt;/a&gt;. This should lead you to &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h E&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#B&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h B&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So without any plugin you macro could use the following commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ea&quot;&amp;lt;Esc&amp;gt;Bi&quot;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which means:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E                  Go to the end of the WORD (i.e. http://www.test.tets/)&#xA; a&quot;                Append a double quote after the word&#xA;   &amp;lt;Esc&amp;gt;           Go back to normal mode&#xA;        B          Move to the beginning of the WORD&#xA;         i&quot;        Insert a double quote before the WORD&#xA;           &amp;lt;Esc&amp;gt;   Go back to normal mode again and continue your macro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also as suggested in the comments Tim Pope's vim-surround is a very good plugin which allows you to use built-in text objects and visual selection to surround some text with different characters.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-01-13T18:08:28.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18557" PostTypeId="1" CreationDate="2019-01-13T21:36:29.873" Score="1" ViewCount="647" Body="&lt;p&gt;I opened a large file, didn't make a modification, and pressed &lt;code&gt;:w&lt;/code&gt;. Then Vim was frozen for a while. Was it simply rewriting the whole file? Is it possible to make it understand that there was no change so that it could just quit? To generalize a little bit, is it possible to let it not rewrite the whole file if I only modified a small part of it?&lt;/p&gt;&#xA;" OwnerUserId="10448" LastActivityDate="2019-01-14T11:54:40.023" Title="Vim rewrite whole file on save?" Tags="|save|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18558" PostTypeId="2" ParentId="18557" CreationDate="2019-01-13T23:21:59.247" Score="6" Body="&lt;p&gt;Instead of &lt;code&gt;:write&lt;/code&gt; you should use &lt;code&gt;:update&lt;/code&gt;.  According to vim's help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *:up* *:update*&#xA;:[range]up[date][!] [++opt] [&amp;gt;&amp;gt;] [file]&#xA;            Like &quot;:write&quot;, but only write when the buffer has been&#xA;            modified.  {not in Vi}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As stated, this will only write out the file to disk if there have been modifications known to vim.  You would use &lt;code&gt;:write&lt;/code&gt; instead if, for example, you have changed or corrupted the file on disk and would like to write vim's buffer contents again.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-01-13T23:21:59.247" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18559" PostTypeId="1" CreationDate="2019-01-14T03:48:58.833" Score="2" ViewCount="348" Body="&lt;p&gt;I can use the powerful &lt;code&gt;:g&lt;/code&gt; command to delete lines that contain a certain pattern like  this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\va pattern/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought I should paste the deleted content to a new place but I cannot find all those lines that have been removed by checking the registers: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:register&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&quot;&lt;/code&gt; register only remembered the one line of them which I thought would only be the last line deleted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I gather all the deleted lines in one register and use them elsewhere?&lt;/p&gt;&#xA;" OwnerUserId="1788" LastEditorUserId="1292" LastEditDate="2019-01-23T14:30:55.777" LastActivityDate="2019-01-23T14:30:55.777" Title="How can I delete lines fit a pattern to a register or a new file?" Tags="|register|global-command|multiple-lines|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18560" PostTypeId="1" AcceptedAnswerId="18562" CreationDate="2019-01-14T07:31:50.647" Score="1" ViewCount="2071" Body="&lt;p&gt;I'm using &lt;code&gt;ctags&lt;/code&gt; to generate tag file so that I can jump to declaration or to definition while working with C/C++ project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make &lt;code&gt;ctags&lt;/code&gt; work automatically while entering vim, I add such a line in my  &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * silent! !eval 'ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -o newtags; mv newtags .tags;' &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you see, this command won't block because of &lt;code&gt;&amp;amp;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I want to make sure that a message will be printed at the bottom of the window of vim after this command is done. How could I do this?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2019-01-14T10:04:55.390" Title="How to print a message after `autocmd` is done" Tags="|vimrc|vimscript|autocmd|ctags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18561" PostTypeId="2" ParentId="18559" CreationDate="2019-01-14T07:35:43.153" Score="5" Body="&lt;h3&gt;Use a Dedicated Register to Which You Append&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Note &lt;code&gt;delete&lt;/code&gt; overwrites the unnamed register &lt;code&gt;&quot;&quot;&lt;/code&gt; for each match. Therefore, only the last line matching the pattern is still available in &lt;code&gt;&quot;&quot;&lt;/code&gt;. Also the numbered registers &lt;code&gt;&quot;0-&quot;9&lt;/code&gt; are not helpful because there are only 10 of them. However, you can append each line to one of the named registers &lt;code&gt;&quot;a-&quot;z&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h quote_alpha&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;4&quot;&gt;&#xA;  &lt;li&gt;Named registers &lt;code&gt;&quot;a&lt;/code&gt; to &lt;code&gt;&quot;z&lt;/code&gt; or &lt;code&gt;&quot;A&lt;/code&gt; to &lt;code&gt;&quot;Z&lt;/code&gt;           &lt;code&gt;*quote_alpha*&lt;/code&gt; &lt;code&gt;*quotea*&lt;/code&gt;&lt;br&gt;&#xA;  Vim fills these registers only when you say so.  Specify them as lowercase&#xA;  letters to replace their previous contents &lt;strong&gt;or as uppercase letters to append&#xA;  to their previous contents.&lt;/strong&gt;&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The steps would be&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Clear target register by &lt;code&gt;qaq&lt;/code&gt; (here illustrated for &lt;code&gt;&quot;a&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Find lines matching a pattern, append line to register &lt;code&gt;&quot;a&lt;/code&gt; when deleting the line (use capitalized letter for appending instead of overwriting)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\va pattern/d A&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Paste at new location with &lt;code&gt;&quot;ap&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Power_of_g&quot; rel=&quot;noreferrer&quot;&gt;http://vim.wikia.com/wiki/Power_of_g&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-01-14T07:35:43.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18562" PostTypeId="2" ParentId="18560" CreationDate="2019-01-14T08:18:21.417" Score="1" Body="&lt;p&gt;Try it as a background job (&lt;code&gt;:help job&lt;/code&gt;). Maybe like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function CtagsExit(cwd, job_id, exit_code)&#xA;    if a:exit_code == 0&#xA;        call rename(a:cwd . '/newtags', a:cwd . '/.tags')&#xA;        echo &quot;Ctags finished with 0&quot;&#xA;    else&#xA;        echo &quot;Ctags finished with &quot; . a:exit_code . &quot; (execute :messages to see output)&quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;function CtagsOutput(channel, data)&#xA;    echomsg a:data&#xA;endfunction&#xA;&#xA;function CtagsStartup()&#xA;    let cmdline='ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -o newtags'&#xA;    let options = {&#xA;                \   'in_io': &quot;null&quot;,&#xA;                \   'out_cb': &quot;CtagsOutput&quot;,&#xA;                \   'err_cb': &quot;CtagsOutput&quot;,&#xA;                \   'exit_cb': function('CtagsExit', [ getcwd() ])&#xA;                \ }&#xA;    call job_start(cmdline, options)&#xA;endfunction&#xA;&#xA;autocmd VimEnter * call CtagsStartup()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Update: Handle changing directory while &lt;code&gt;ctags&lt;/code&gt; is running.&#xA;Update 2: Handle output.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-14T10:04:55.390" LastActivityDate="2019-01-14T10:04:55.390" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18563" PostTypeId="2" ParentId="18557" CreationDate="2019-01-14T11:54:40.023" Score="4" Body="&lt;p&gt;I did a short check with &lt;code&gt;strace&lt;/code&gt; on Linux. I edit &lt;code&gt;README.md&lt;/code&gt; and add one character to the last line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the relevant part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;01: stat(&quot;README.md&quot;, {st_mode=S_IFREG|0644, st_size=5986, ...}) = 0&#xA;02: stat(&quot;README.md~&quot;, {st_mode=S_IFREG|0644, st_size=5988, ...}) = 0&#xA;03: unlink(&quot;README.md~&quot;)                    = 0&#xA;04: rename(&quot;README.md&quot;, &quot;README.md~&quot;)       = 0&#xA;05: open(&quot;README.md&quot;, O_WRONLY|O_CREAT, 0644) = 3&#xA;06: ftruncate(3, 0)                         = 0&#xA;07: write(3, &quot;![Vim Logo](https://github.com/v&quot;..., 5987) = 5987&#xA;08: fsync(3)                                = 0&#xA;09: stat(&quot;README.md&quot;, {st_mode=S_IFREG|0644, st_size=5987, ...}) = 0&#xA;10: stat(&quot;README.md&quot;, {st_mode=S_IFREG|0644, st_size=5987, ...}) = 0&#xA;11: fchmod(3, 0100644)                      = 0&#xA;12: close(3)                                = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The lines 02-04 show how the backup file is created. Here the original file is moved to &lt;code&gt;README.md~&lt;/code&gt; (a already existing &lt;code&gt;README.md~&lt;/code&gt; is deleted in in line 03).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the new file &lt;code&gt;README.md&lt;/code&gt; is written line 05-12. In line 06 the call to &lt;code&gt;ftruncate&lt;/code&gt; truncates the file to zero (irrelevant here, as this is a new file) and then the complete content is written (5987 byte).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that depending on the option &lt;code&gt;backupcopy&lt;/code&gt;, the backup file &lt;code&gt;README.md~&lt;/code&gt; might be written, instead of just renaming &lt;code&gt;README.md&lt;/code&gt; to &lt;code&gt;README.md~&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here with &lt;code&gt;set nobackup&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;01: open(&quot;README.md&quot;, O_WRONLY|O_CREAT, 0644) = 3&#xA;02: ftruncate(3, 0)                         = 0&#xA;03: write(3, &quot;![Vim Logo](https://github.com/v&quot;..., 5987) = 5987&#xA;04: fsync(3)                                = 0&#xA;05: stat(&quot;README.md&quot;, {st_mode=S_IFREG|0644, st_size=5987, ...}) = 0&#xA;06: stat(&quot;README.md&quot;, {st_mode=S_IFREG|0644, st_size=5987, ...}) = 0&#xA;07: fchmod(3, 0100644)                      = 0&#xA;08: close(3)                                = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here no backup file is created, but also the file &lt;code&gt;README.md&lt;/code&gt; is first truncated to size zero and then the complete content is written (5987  byte).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My conclusion: Vim always writes the entire file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not aware that there is any option to just write changed parts. Also this would be not trivial to implement.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-14T11:54:40.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18565" PostTypeId="1" AcceptedAnswerId="18567" CreationDate="2019-01-14T16:02:17.527" Score="1" ViewCount="169" Body="&lt;p&gt;I have the following mapping in my &lt;code&gt;~/.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; map &amp;lt;F3&amp;gt; my0v$&quot;+y`y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works correctly, but I'd like some visual feedback or some other indication to show that I've pressed the key. Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="2932" LastActivityDate="2019-01-15T15:05:49.100" Title="Visual feedback after executing mapping" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18566" PostTypeId="2" ParentId="18534" CreationDate="2019-01-14T16:23:17.897" Score="0" Body="&lt;h3&gt;Make &lt;code&gt;:Rg&lt;/code&gt; match only file contents not file names&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bang -nargs=* Rg call fzf#vim#grep(&quot;rg --column --line-number --no-heading --color=always --smart-case &quot;.shellescape(&amp;lt;q-args&amp;gt;), 1, {'options': '--delimiter : --nth 4..'}, &amp;lt;bang&amp;gt;0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(from &lt;a href=&quot;https://github.com/junegunn/fzf.vim/issues/714&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/junegunn/fzf.vim/issues/714&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you also want this for &lt;code&gt;:Ag&lt;/code&gt;, add as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bang -nargs=* Ag call fzf#vim#ag(&amp;lt;q-args&amp;gt;, {'options': '--delimiter : --nth 4..'}, &amp;lt;bang&amp;gt;0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The author of fzf.vim junegunn recommends:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You should always try to provide an initial query to &lt;code&gt;rg&lt;/code&gt; or &lt;code&gt;ag&lt;/code&gt; and use &lt;code&gt;fzf&lt;/code&gt; only as the secondary filter as it's much more efficient that way especially when your project is large.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-01-14T16:23:17.897" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18567" PostTypeId="2" ParentId="18565" CreationDate="2019-01-14T17:40:46.527" Score="5" Body="&lt;p&gt;You have options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Explicitly put an &lt;code&gt;:echo&lt;/code&gt; at the end of your mapping. &lt;code&gt;map &amp;lt;key&amp;gt; foo:echo &quot;done&quot;&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;'showcmd'&lt;/code&gt; which will show partial commands. This will give you a slight clue that something happened for multi-key mappings/commands. (Not really helpful here)&lt;/li&gt;&#xA;&lt;li&gt;Use a plugin like &lt;a href=&quot;https://github.com/machakann/vim-highlightedyank&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-highlightedyank&lt;/a&gt; to quickly highlight the last yank&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;General rule of thumbs for &lt;a href=&quot;https://vimways.org/2018/for-mappings-and-a-tutorial/&quot; rel=&quot;nofollow noreferrer&quot;&gt;mappings&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Supply a mode for mappings. e.g. &lt;code&gt;nmap&lt;/code&gt; for normal mode&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;*noremap&lt;/code&gt; variants unless you want remapping to occur or using a &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mapping&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This means your mapping would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F3&amp;gt; my0v$&quot;+y`y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some more thoughts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is very similar to &lt;code&gt;&quot;+yy&lt;/code&gt;/&lt;code&gt;&quot;+Y&lt;/code&gt;, &lt;code&gt;:yank +&lt;/code&gt;, or &lt;code&gt;V&quot;+y&lt;/code&gt;. There is another newline in the register, but that is easy to reason about.&lt;/li&gt;&#xA;&lt;li&gt;You may not want the ending newline at all, so use &lt;code&gt;g_&lt;/code&gt; instead of &lt;code&gt;$&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;This mutates the &lt;code&gt;y&lt;/code&gt; mark. This could be surprising, consider using a &lt;code&gt;:yank&lt;/code&gt; or &lt;code&gt;yy&lt;/code&gt;/&lt;code&gt;Y&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Could &lt;a href=&quot;https://github.com/vim-scripts/UnconditionalPaste&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;cast&quot;&lt;/a&gt; put/paste or change the register type to accomplish the same effect. e.g. &lt;code&gt;nnoremap &amp;lt;f3&amp;gt; &quot;+yy:call setreg('+', @+, 'v')&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Personally, I lean toward using &lt;a href=&quot;https://github.com/machakann/vim-highlightedyank&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-highlightyank&lt;/a&gt; and the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;f3&amp;gt; &quot;+yy:call setreg('+', @+, 'v')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2019-01-15T15:05:49.100" LastActivityDate="2019-01-15T15:05:49.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18568" PostTypeId="2" ParentId="18559" CreationDate="2019-01-14T22:37:34.663" Score="1" Body="&lt;p&gt;Adding to Hotschke's answer above, once all the lines of interest are in a register (&quot;a&quot; in this example), here's how to write the contents to a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;:new filename | $put a | x&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vim.1045645.n5.nabble.com/Write-register-contents-to-file-td5610081.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Write register contents to file&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17418" LastActivityDate="2019-01-14T22:37:34.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18569" PostTypeId="1" CreationDate="2019-01-15T00:10:24.447" Score="1" ViewCount="27" Body="&lt;p&gt;How do you copy/paste a piece of text across different terminals in &lt;code&gt;nvim&lt;/code&gt; (neovim)?&lt;/p&gt;&#xA;" OwnerUserId="3393" LastActivityDate="2019-01-15T00:10:24.447" Title="Copy/paste across terminals in nvim?" Tags="|neovim|os-clipboard|" AnswerCount="0" CommentCount="0" ClosedDate="2019-01-15T23:56:00.170" ContentLicense="CC BY-SA 4.0" />
  <row Id="18570" PostTypeId="1" CreationDate="2019-01-15T02:03:22.537" Score="1" ViewCount="33" Body="&lt;p&gt;I write a lot of C/C++ and get highlighting for my Doxygen docs in my comments. It's not perfect, but it sure helps avoiding many very simple mistakes on the spot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To handle that, I simply have the following in my own c.vim file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/syntax/cpp.vim&#xA;source $VIMRUNTIME/syntax/doxygen.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I'm writing a lot of Node.js code and thus I'm writing jsdoc docs. Is there a way to get the comments highlighted with markdown?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following after loading a JS file and nothing happened:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/syntax/markdown.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which I'm not surprised because markdown doesn't expect to mark things in comments...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a ready made solution or would it require extending the JavaSript highlighting to support the jsdoc syntax?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is an example of comment where I would like to get markdown highlighting (or even better, jsdoc and markdown)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/**&#xA; * Check whether `value` represents a valid filename.&#xA; *&#xA; * This function checks whether `value` represents a valid filename.&#xA; * The `param` option is used to determine which type of check you&#xA; * want to perform with `value`.&#xA; *&#xA; * Here are the currently supported `param` values:&#xA; *&#xA; * * `exists` -- whether that file currently exists.&#xA; *&#xA; * @todo&#xA; * Look into local filenames handling.&#xA; *&#xA; * @param {any} value  The value being checked.&#xA; * @param {string} param  The type of test on `value`.&#xA; *&#xA; * @returns true if the value is considered valid.&#xA; *&#xA; * @private&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9276" LastEditorUserId="9276" LastEditDate="2019-01-15T03:32:14.287" LastActivityDate="2019-01-15T03:32:14.287" Title="My C like Comments include markdown, can I have vim highlight those in my JavaScript (Node.js) code?" Tags="|syntax-highlighting|comments|filetype-markdown|filetype-javascript|" AnswerCount="0" CommentCount="2" ClosedDate="2019-01-22T10:03:04.593" ContentLicense="CC BY-SA 4.0" />
  <row Id="18571" PostTypeId="2" ParentId="12607" CreationDate="2019-01-15T05:16:19.113" Score="5" Body="&lt;p&gt;It seems that we can also set the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;selection&amp;#39;&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;selection&lt;/code&gt;&lt;/a&gt; option to achieve what you want. If we use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set selection=exclusive&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the newline character will not be included the selected characters.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-01-15T05:16:19.113" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18572" PostTypeId="1" CreationDate="2019-01-15T07:48:47.470" Score="2" ViewCount="63" Body="&lt;p&gt;I use and love the plugin &lt;a href=&quot;https://github.com/itchyny/calendar.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;calendar.vim&lt;/a&gt;. Those days, I decided to add the following to my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter *.tex,*.md call matchdelete(4)&#xA;autocmd BufLeave *.tex,*.md call matchadd(&quot;ErrorMsg&quot;, &quot;\\%&amp;gt;80v.\\+&quot;, 10, 4)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, if I alternate to a buffer that contains a &lt;code&gt;.tex&lt;/code&gt; or a &lt;code&gt;.md&lt;/code&gt; file, the error after 80chars becomes disabled. If I alternate to a buffer with any other type of file, it's enabled again. The problem is, it makes most of the calendar buffer become marked with error highlighting. Simply adding &lt;code&gt;calendar&lt;/code&gt; as file extension in the above code does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Searching through the issues of the plugin's github, I found the following issue raised: &lt;a href=&quot;https://github.com/itchyny/calendar.vim/issues/98&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/itchyny/calendar.vim/issues/98&lt;/a&gt;. There, the plugin's author give a code snippet for making it so that the above type of error message for long lines does not display over the calendar:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter,FileType *&#xA;  \   if &amp;amp;l:filetype ==# 'calendar'&#xA;  \ |   match&#xA;  \ | else&#xA;  \ |   match ErrorMsg '\%&amp;gt;80v.\+'&#xA;  \ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But with only that, I loose the ability of also having the error highlighting disabled with &lt;code&gt;tex&lt;/code&gt; and &lt;code&gt;md&lt;/code&gt; files. I tried the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter,FileType *&#xA;  \   if &amp;amp;l:filetype ==# 'calendar' || &amp;amp;l:filetype ==# 'tex' || &amp;amp;l:filetype ==# 'md'&#xA;  \ |   match&#xA;  \ | else&#xA;  \ |   match ErrorMsg '\%&amp;gt;80v.\+'&#xA;  \ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, that also does not work well. It disables the error highilghting only on the calendar buffer, not on buffers displaying tex or md files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, my question. Is there a way I can have the above code modified such that I could have the error highlighting for over 80chars lines when I navigate my cursor to buffers containing any other files than tex, md or the buffer calendar?&lt;/p&gt;&#xA;" OwnerUserId="20492" LastActivityDate="2019-01-16T08:04:36.480" Title="Not displaying ErrorMsg for long lines only with tex, md and calendar buffers" Tags="|vimrc|vimscript|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18573" PostTypeId="2" ParentId="18572" CreationDate="2019-01-15T08:24:44.360" Score="1" Body="&lt;p&gt;&lt;code&gt;&amp;amp;l:filetype&lt;/code&gt; is not equal to file extension. For &lt;code&gt;.md&lt;/code&gt; files, filetype is &lt;code&gt;markdown&lt;/code&gt;, not sure what it will be for &lt;code&gt;.tex&lt;/code&gt; (my Vim show &lt;code&gt;plaintext&lt;/code&gt;) - so this one you will have to check in Your Vim with &lt;code&gt;:set filetype?&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this should look something like this (change filetype for &lt;code&gt;tex&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter,FileType *&#xA;  \   if index(['calendar', 'tex', 'markdown'], &amp;amp;filetype) &amp;gt; -1&#xA;  \ |   setlocal cc=&#xA;  \ | else&#xA;  \ |   setlocal cc=80&#xA;  \ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit: Shorten if statement using @Martin Tournoij comment&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="5395" LastEditorUserId="5395" LastEditDate="2019-01-16T08:04:36.480" LastActivityDate="2019-01-16T08:04:36.480" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18574" PostTypeId="1" CreationDate="2019-01-15T09:41:38.943" Score="1" ViewCount="7971" Body="&lt;p&gt;The python I want to use is located at &lt;code&gt;C:\randomplace\python&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a dev machine that has multiple instances of python (so relying on finding python in&lt;code&gt;$PATH&lt;/code&gt; is unreliable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I configure vim to use just the before mentioned for the purpose of vim plugins etc?&lt;/p&gt;&#xA;" OwnerUserId="20548" LastEditorUserId="28" LastEditDate="2019-01-15T13:25:27.817" LastActivityDate="2021-04-04T10:00:35.073" Title="How do I configure the python location?" Tags="|vimscript-python|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18575" PostTypeId="1" AcceptedAnswerId="18577" CreationDate="2019-01-15T11:06:59.273" Score="4" ViewCount="1944" Body="&lt;p&gt;I'm using &lt;code&gt;ctags&lt;/code&gt; to code C++ with vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set two shortcuts of &lt;code&gt;ctags&lt;/code&gt; as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * silent! !eval 'ctags -R --c++-kinds=+p --fields=+iaS --extras=+q --language-force=C++ -o newtags; mv newtags .tags' &amp;amp;&#xA;function! Jump(type)&#xA;    if filereadable(&quot;.tags&quot;)&#xA;        if a:type == &quot;single&quot;&#xA;            execute &quot;normal! 2\&amp;lt;C-]&amp;gt;&quot;&#xA;            execute &quot;normal :NERDTreeFind\&amp;lt;CR&amp;gt;&quot;&#xA;            execute &quot;normal :wincmd p\&amp;lt;CR&amp;gt;&quot;&#xA;        else&#xA;            execute &quot;normal! g\&amp;lt;C-]&amp;gt;&quot;&#xA;            &quot;execute &quot;normal :redraw!&quot;&#xA;        endif&#xA;    else&#xA;        execute &quot;normal :echo 'tags file not ready'\&amp;lt;CR&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;nnoremap &amp;lt;C-]&amp;gt; :call Jump('single')&amp;lt;CR&amp;gt;&#xA;nnoremap g&amp;lt;C-]&amp;gt; :call Jump('multi')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As the &lt;code&gt;autocmd&lt;/code&gt; command may need some time to finish, I write a function &lt;code&gt;Jump&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now, everything works well except that I always get a &lt;code&gt;Press ENTER or type command to continue&lt;/code&gt; after typing &lt;code&gt;g&amp;lt;C-]&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to add &lt;code&gt;execute &quot;normal :redraw!&quot;&lt;/code&gt; but it doesn't seem to work...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I cannot use &lt;code&gt;silent&lt;/code&gt; too, because &lt;code&gt;g&amp;lt;C-]&amp;gt;&lt;/code&gt; has some necessary output:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/RoXfT.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RoXfT.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use &lt;code&gt;silent&lt;/code&gt;, all the output above will disappear.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2019-01-15T11:50:53.107" LastActivityDate="2019-01-15T12:38:25.080" Title="How to get rid of &quot;Press ENTER or type command to continue&quot;" Tags="|vimscript|ctags|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18577" PostTypeId="2" ParentId="18575" CreationDate="2019-01-15T12:38:25.080" Score="3" Body="&lt;p&gt;Could you try the following. It directly uses &lt;code&gt;:tag&lt;/code&gt; and &lt;code&gt;:tjump&lt;/code&gt; instead of using the mappings. I also removed the unneeded &lt;code&gt;execute ...&lt;/code&gt; stuff.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Jump(type)&#xA;    if filereadable(&quot;.tags&quot;)&#xA;        if a:type == &quot;single&quot;&#xA;            execute &quot;tag &quot; . expand(&quot;&amp;lt;cword&amp;gt;&quot;)&#xA;            NERDTreeFind&#xA;            wincmd p&#xA;        else&#xA;            execute &quot;tjump &quot; . expand(&quot;&amp;lt;cword&amp;gt;&quot;)&#xA;        endif&#xA;    else&#xA;        echo 'tags file not ready'&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-15T12:38:25.080" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18578" PostTypeId="1" AcceptedAnswerId="18579" CreationDate="2019-01-15T22:47:47.403" Score="3" ViewCount="4902" Body="&lt;p&gt;On Ubuntu, when I do &lt;code&gt;vim --version&lt;/code&gt; in the terminal I get:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Jan  6 2019 14:05:44)&lt;/p&gt;&#xA;&lt;p&gt;Included patches: 1-699&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;However, when I do &lt;code&gt;gvim --version&lt;/code&gt; I get:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 10 2018 21:31:58)&lt;/p&gt;&#xA;&lt;p&gt;Included patches: 1-1453&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In trying to update the Vim version underneath my gvim installation, I thought it would be as simple as re-installing gvim with &lt;code&gt;sudo apt-get install gvim&lt;/code&gt;. However, that gives me:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Reading package lists... Done&lt;br /&gt;&#xA;Building dependency tree&lt;br /&gt;&#xA;Reading state information... Done&lt;br /&gt;&#xA;Package gvim is a virtual package provided by:&lt;br /&gt;&#xA;vim-gtk 2:8.0.1453-1ubuntu1&lt;br /&gt;&#xA;vim-athena 2:8.0.1453-1ubuntu1&lt;br /&gt;&#xA;vim-gtk3 2:8.0.1453-1ubuntu1&lt;br /&gt;&#xA;You should explicitly select one to install.&lt;/p&gt;&#xA;&lt;p&gt;E: Package 'gvim' has no installation candidate&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;That is, only the gvim version that I already have installed appears as available to me. At the &lt;a href=&quot;https://www.vim.org/download.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;official page&lt;/a&gt; I found mentions of how to install gvim8.1 for Windows, but not for Linux.&lt;/p&gt;&#xA;&lt;p&gt;So, how could I update gvim to 8.1? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20492" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-01-16T02:16:09.380" Title="Unable to install most recent gvim 8.1 on Ubuntu" Tags="|gvim|installing|linux-ubuntu|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18579" PostTypeId="2" ParentId="18578" CreationDate="2019-01-16T02:16:09.380" Score="4" Body="&lt;p&gt;I was actually able to update gvim to 8.1 on Ubuntu 18 by following the same as this question asked in the past about older versions: &lt;a href=&quot;https://askubuntu.com/questions/875003/ubuntu-16-10-repository-providing-vim-8&quot;&gt;https://askubuntu.com/questions/875003/ubuntu-16-10-repository-providing-vim-8&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I followed the first option pointed by that answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo add-apt-repository ppa:jonathonf/vim&#xA;sudo apt update&#xA;sudo apt install vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After doing the above, &lt;code&gt;gvim --version&lt;/code&gt; gives me:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Jan 07 2019 10:34:10)&lt;br&gt;&#xA;  Included patches: 1-744&lt;br&gt;&#xA;  Modified by jonathon.fernyhough@york.ac.uk&lt;br&gt;&#xA;  Compiled by jonathon.fernyhough@york.ac.uk&lt;br&gt;&#xA;  Huge version with GTK3 GUI.  Features included  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="20492" LastActivityDate="2019-01-16T02:16:09.380" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18580" PostTypeId="1" CreationDate="2019-01-16T03:52:47.317" Score="1" ViewCount="436" Body="&lt;p&gt;In my &lt;code&gt;.vimrc&lt;/code&gt;, I set a shortcut:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command Q call delete('.ycm_extra_conf.py')|call delete('.tags')|qa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I can type &lt;code&gt;:Q&lt;/code&gt; + &lt;code&gt;[enter]&lt;/code&gt; to delete the two files and quit all plugins and vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I forget to save before &lt;code&gt;:Q&lt;/code&gt; + &lt;code&gt;[enter]&lt;/code&gt;, I will get the message as below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rlZuC.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rlZuC.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to type a &lt;code&gt;[enter]&lt;/code&gt; because of the &lt;code&gt;Press ENTER or type command to continue&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I avoid this message so that I don't need to type a &lt;code&gt;[enter]&lt;/code&gt; anymore?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2019-01-16T03:52:47.317" Title="command: how to avoid &quot;Press ENTER or type command to continue&quot;" Tags="|vimscript|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="18581" PostTypeId="1" CreationDate="2019-01-16T04:39:52.183" Score="0" ViewCount="63" Body="&lt;p&gt;Coding C++ in Visual Studio, if you type &lt;code&gt;;&lt;/code&gt;, this line will be formatted. For example, typing a &lt;code&gt;;&lt;/code&gt; after &lt;code&gt;int i= 1+ 2&lt;/code&gt; will make this line as &lt;code&gt;int i = 1 + 2;&lt;/code&gt;, which means that each operator is surrounded by two spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm asking if there is such a vim plugin to do so? I've tried &lt;code&gt;astyle&lt;/code&gt;, it does format my c++ code but it can't add spaces around operator.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2019-01-16T04:39:52.183" Title="Is there a C++ format plugin just like Visual Studio" Tags="|vimscript|plugin-vim-autoformat|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18582" PostTypeId="1" CreationDate="2019-01-16T05:54:24.843" Score="1" ViewCount="45" Body="&lt;p&gt;I'm trying to see the  verilog and systemverilog programing codes on linux by using VIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but some codes are defined with so many 'ifdef~'endif syntax.&#xA;so I'd like to see only the code related with define code within 'ifdef~'endif except else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to see only defined related code except else in VIM on linux?&lt;/p&gt;&#xA;" OwnerUserId="20563" LastEditorUserId="20563" LastEditDate="2019-01-16T07:15:38.623" LastActivityDate="2019-01-16T07:15:38.623" Title="Is it possible to see only defined code except else in vim on linux?" Tags="|vimrc|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18583" PostTypeId="1" CreationDate="2019-01-16T13:14:51.567" Score="0" ViewCount="50" Body="&lt;p&gt;I'm calling &lt;code&gt;normal! n&lt;/code&gt; in a vimscript function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a match, I don't get the message &lt;code&gt;/foobar match 1 of 3&lt;/code&gt; in the commandline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is no match, my commandline shortly flickers up and down and calling &lt;code&gt;:messages&lt;/code&gt; reveals the output &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;1_contextn:&#xA;line    6:&#xA;E486: Pattern not found: foobar&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I show the success message and the last line of that error message just as they are shown when &lt;code&gt;n&lt;/code&gt; is pressed normally?&lt;/p&gt;&#xA;" OwnerUserId="18613" LastEditorUserId="18613" LastEditDate="2019-01-16T13:24:30.830" LastActivityDate="2019-01-16T13:24:30.830" Title="How to show &quot;/foobar match 1 of &quot; or &quot;E486: Pattern not found: foobar&quot; in commandline when calling `normal! n` in function" Tags="|vimscript|command-line|normal-mode|echo|" AnswerCount="0" CommentCount="4" ClosedDate="2019-01-27T21:38:50.320" ContentLicense="CC BY-SA 4.0" />
  <row Id="18584" PostTypeId="1" CreationDate="2019-01-16T14:43:02.413" Score="1" ViewCount="704" Body="&lt;p&gt;I use vimtex, latexmk and neovim in order to edit .tex files in Vim, but for some reason my local leader does not work in .tex files, though the leader works and the local leader works for other filetypes (e.g. .py files). Any idea where this problem may be coming from ?&lt;/p&gt;&#xA;" OwnerUserId="18171" LastActivityDate="2019-01-16T14:43:02.413" Title="&lt;localleader&gt; not working in .tex files, but working for the other filetypes" Tags="|neovim|plugin-vimtex|leader|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18585" PostTypeId="2" ParentId="18574" CreationDate="2019-01-16T14:49:28.197" Score="2" Body="&lt;p&gt;Add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set pythonhome=C:\randomplace\python&#xA;set pythondll=C:\randomplace\python\python27.dll&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For python3 use &lt;code&gt;pythonthreehome&lt;/code&gt; and &lt;code&gt;pythonthreedll&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this to work python dynamic support must be compiled in. The following command must print &lt;code&gt;1&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo has(&quot;python_dynamic&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For python3: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo has(&quot;python3_dynamic&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help python-dynamic&lt;/code&gt; and help for the named options.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-16T16:11:35.430" LastActivityDate="2019-01-16T16:11:35.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18586" PostTypeId="1" AcceptedAnswerId="18587" CreationDate="2019-01-16T18:55:44.177" Score="2" ViewCount="8238" Body="&lt;p&gt;On a &lt;code&gt;.python&lt;/code&gt; file, I see the following for &lt;code&gt;:ALEInfo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ALEInfo&#xA; Current Filetype: python&#xA;Available Linters: ['flake8', 'mypy', 'prospector', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylint', 'pyls', 'pyre', 'vulture']&#xA;  Enabled Linters: ['flake8', 'mypy', 'pylint']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is &lt;code&gt;pycodestyle&lt;/code&gt; not enabled? Is there a way I can automatically enable it for all python files? I have &lt;code&gt;pycodestyle&lt;/code&gt; already installed with pip, from the command line I can do &lt;code&gt;pycodestyle .&lt;/code&gt; and it works.&lt;/p&gt;&#xA;" OwnerUserId="7596" LastActivityDate="2020-05-03T14:47:48.327" Title="ALE Linter is available but not enabled" Tags="|plugin-ale|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18587" PostTypeId="2" ParentId="18586" CreationDate="2019-01-16T19:05:34.823" Score="5" Body="&lt;p&gt;I just found out that only &lt;code&gt;flake8&lt;/code&gt;, &lt;code&gt;mypy&lt;/code&gt; and &lt;code&gt;pylint&lt;/code&gt; are enabled by default. I was trying to find out before but couldn't until someone pointed to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/w0rp/ale/blob/master/doc/ale.txt#L1438&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/w0rp/ale/blob/master/doc/ale.txt#L1438&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or &lt;code&gt;:help ale_linters&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to enable new linters, I need to set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_linters = {'python': ['pycodestyle']}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The doc above has this part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  The |g:ale_linters| option sets a |Dictionary| mapping a filetype to a&#xA;  |List| of linter programs to be run when checking particular filetypes.&#xA;&#xA;  This |Dictionary| will be merged with a default dictionary containing the&#xA;  following values: &amp;gt;&#xA;&#xA;  {&#xA;  \   'csh': ['shell'],&#xA;  \   'elixir': ['credo', 'dialyxir', 'dogma', 'elixir-ls'],&#xA;  \   'go': ['gofmt', 'golint', 'go vet'],&#xA;  \   'hack': ['hack'],&#xA;  \   'help': [],&#xA;  \   'perl': ['perlcritic'],&#xA;  \   'perl6': [],&#xA;  \   'python': ['flake8', 'mypy', 'pylint'],&#xA;  \   'rust': ['cargo'],&#xA;  \   'spec': [],&#xA;  \   'text': [],&#xA;  \   'vue': ['eslint', 'vls'],&#xA;  \   'zsh': ['shell'],&#xA;  \}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7596" LastActivityDate="2019-01-16T19:05:34.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18588" PostTypeId="1" CreationDate="2019-01-16T22:28:20.703" Score="0" ViewCount="164" Body="&lt;p&gt;When I'm in vim on tmux with terminal and I scroll up, the cursor will jump to where my mouse is and show a &lt;code&gt;[0/0]&lt;/code&gt; on the right corner of my window. When that happens, I can't type or move the cursor at all with my hjkl keys. The only way to get it back is to scroll down and the cursor will go back to where it was and the &lt;code&gt;[0/0]&lt;/code&gt; will go away. Why does this happen and what exactly is it doing? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gKY85.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gKY85.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what it looks like. &lt;/p&gt;&#xA;" OwnerUserId="20580" LastActivityDate="2019-01-16T22:28:20.703" Title="What is the [0/0] that pops up in corner of tmux vim if I try to scroll up?" Tags="|macvim|scrolling|tmux|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18589" PostTypeId="2" ParentId="13095" CreationDate="2019-01-16T22:40:05.190" Score="0" Body="&lt;p&gt;To add to what statox mentioned above, if you want to avoid matching against the &quot;not existing&quot; space, use &lt;code&gt;\+&lt;/code&gt; instead of &lt;code&gt;*&lt;/code&gt; to match one or more instances of the non-word character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\_W\+/-/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1600" LastActivityDate="2019-01-16T22:40:05.190" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18590" PostTypeId="1" CreationDate="2019-01-16T23:54:01.543" Score="1" ViewCount="1571" Body="&lt;p&gt;I might not have discovered everything about it, but the &lt;code&gt;smartindent&lt;/code&gt; option has given me much more trouble than usefulness. For example, it indents a line beginning with &lt;code&gt;for&lt;/code&gt; or &lt;code&gt;if&lt;/code&gt;, and won't shift a line beginning with &lt;code&gt;#&lt;/code&gt;. Probably I'm wrong having this option on when editing normal text files (not programs). But I'm wondering where this option can ever be useful, given the fact that you have &lt;code&gt;cindent&lt;/code&gt; for C programs and various plugins for other specific languages.&lt;/p&gt;&#xA;" OwnerUserId="10448" LastActivityDate="2019-01-17T20:59:13.333" Title="What is valid use case for `smartindent`?" Tags="|indentation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18592" PostTypeId="1" CreationDate="2019-01-17T08:13:12.957" Score="0" ViewCount="1299" Body="&lt;p&gt;question for CtrlP users&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have ctrl-p mapped to open file from the filesystem. I want to map ctrl-y to open a buffer that is already opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;how should I change my vimrc? does anyone know?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20588" LastActivityDate="2019-07-05T20:50:44.477" Title="how to set shortcut for CtrlPBuffer, just like ctrl-p for CtrlP" Tags="|buffers|plugin-ctrlp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18594" PostTypeId="2" ParentId="9418" CreationDate="2019-01-17T10:45:56.827" Score="0" Body="&lt;p&gt;In cmder setting page &lt;code&gt;Startup -&amp;gt; Environment&lt;/code&gt;, add the following setting:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set LANG=en_US.utf8&#xA;chcp utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It should solve your problem.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Z7PDa.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Z7PDa.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15292" LastEditorUserId="15292" LastEditDate="2021-02-07T09:29:06.100" LastActivityDate="2021-02-07T09:29:06.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18595" PostTypeId="1" AcceptedAnswerId="18596" CreationDate="2019-01-17T11:40:45.473" Score="3" ViewCount="609" Body="&lt;p&gt;I am not sure if it is even possible but, when I am working with vertical splits, sometimes, I want both of them to scroll up/down at the same time rather than using this combination:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;scroll down &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;focus on left split&lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;L&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;scroll down &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;focus on right &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; + &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;H&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It would be amazing to use &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;E&lt;/kbd&gt; and achive to same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks! :)&lt;/p&gt;&#xA;" OwnerUserId="7621" LastActivityDate="2019-01-17T12:11:18.060" Title="How to scroll two vertical splits at the same time?" Tags="|cursor-movement|split|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18596" PostTypeId="2" ParentId="18595" CreationDate="2019-01-17T12:11:18.060" Score="4" Body="&lt;p&gt;You want scrollbind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;:set scb&lt;/code&gt; on each window you which to bind together, then it should be possible to scroll them together. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally this command may come in handy:  &lt;code&gt;:windo set scrollbind!&lt;/code&gt; - this toggles scrollbind all windows&lt;/p&gt;&#xA;&#xA;&lt;p&gt;see &lt;code&gt;:h scroll-binding&lt;/code&gt;, and &lt;code&gt;:h scrollbind&lt;/code&gt; for full details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that &lt;code&gt;cursorbind&lt;/code&gt;, &lt;code&gt;diff&lt;/code&gt; and &lt;code&gt;scrollopt&lt;/code&gt; settings are somewhat related to what you are doing.&lt;/p&gt;&#xA;" OwnerUserId="20591" LastActivityDate="2019-01-17T12:11:18.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18597" PostTypeId="1" CreationDate="2019-01-17T13:15:12.527" Score="0" ViewCount="39" Body="&lt;p&gt;I'm having trouble putting to words what I'm looking for, please mark as duplicate if appropriate&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a key binding that launches a search based on a fuzzy finder (specifically bindings to fzf and fzf.vim for searching for files, based on &lt;a href=&quot;https://statico.github.io/vim3.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this blog&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap ; :Buffers&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;Leader&amp;gt;t :Files&amp;lt;CR&amp;gt;&#xA;nmap &amp;lt;Leader&amp;gt;r :Tags&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The trouble is, sometimes I press &lt;code&gt;&amp;lt;Leader&amp;gt;t&lt;/code&gt; ... &lt;em&gt;some search string&lt;/em&gt;, and the beginning of my search string is apparently a keybinding somewhere which is messing up my search. As a workaround, I press space as if it were part of the keybinding to start up the search, but that is not ideal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to disable all keybindings that start with &lt;code&gt;&amp;lt;Leader&amp;gt;t&lt;/code&gt; or possibly tell vim to immediately execute the binding (greedily?) instead of waiting for more bindings?&lt;/p&gt;&#xA;" OwnerUserId="15268" LastActivityDate="2019-01-17T13:15:12.527" Title="How to limit a key binding to a single key" Tags="|key-bindings|neovim|plugin-fzf|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18599" PostTypeId="1" CreationDate="2019-01-17T15:29:59.880" Score="1" ViewCount="134" Body="&lt;p&gt;Is there a way i can repeat an emmet command in vim. Below is the sample text file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Hello World&amp;lt;/h1&amp;gt;&#xA;&amp;lt;h1&amp;gt;Hello World&amp;lt;/h1&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So i use emmet to wrap the the first line inside a &lt;code&gt;div&lt;/code&gt; and then wanted to repeat the same on the second line. But when i press &lt;code&gt;.&lt;/code&gt; it kind of deletes the second line and file looks like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;    &amp;lt;h1&amp;gt;Hello World&amp;lt;/h1&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know i can do this stuff with macros, but in my view macros is an over kill for just this thing. So is there any way i can repeat this with &lt;code&gt;.&lt;/code&gt;. I tried &lt;code&gt;repeat.vim&lt;/code&gt; plugin as well but it didn't work.&lt;/p&gt;&#xA;" OwnerUserId="18373" LastEditorUserId="1292" LastEditDate="2019-01-17T17:50:58.173" LastActivityDate="2019-01-17T17:50:58.173" Title="Repeat Emmet commands in vim with dot operator" Tags="|vimrc|repeated-commands|plugin-emmet-vim|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18602" PostTypeId="1" AcceptedAnswerId="18606" CreationDate="2019-01-17T18:51:49.603" Score="2" ViewCount="90" Body="&lt;p&gt;I wrote a syntax highlighting .vim file. One of the expressions is used to color the label in a JavaScript object declaration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name: 'value'&#xA;^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to see the &lt;code&gt;name&lt;/code&gt; in a different color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My expression looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match label &quot;\&amp;lt;[a-zA-Z_$][a-zA-Z_$0-9]*[ \t]*:[^=:]\=&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to avoid seeing &lt;code&gt;name&lt;/code&gt; as a &lt;code&gt;label&lt;/code&gt; if the colon is immediately followed by an equal (&lt;code&gt;=&lt;/code&gt;) or a colon (&lt;code&gt;:&lt;/code&gt;) as in these two lines, the highlight should not happen:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name:=assignment&#xA;name::space&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, my current expression fails in this situation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name:'value'&#xA;     ^&#xA;     |&#xA;     +---  no space here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The effect is that the string (&lt;code&gt;'value'&lt;/code&gt;) doesn't get highlighted as expected since the first quote (&lt;code&gt;'&lt;/code&gt;) is viewed as being part of the &lt;code&gt;label&lt;/code&gt; expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I test that an expression is not followed by another without &lt;em&gt;eating&lt;/em&gt; that expression?&lt;/p&gt;&#xA;" OwnerUserId="9276" LastEditorUserId="9276" LastEditDate="2019-01-17T19:11:09.690" LastActivityDate="2019-01-17T19:48:15.027" Title="Pattern to match the label of a JavaScript object field when the colon is not followed by another colon or an equal sign" Tags="|syntax-highlighting|regular-expression|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18603" PostTypeId="1" AcceptedAnswerId="18605" CreationDate="2019-01-17T18:57:06.863" Score="1" ViewCount="217" Body="&lt;p&gt;I am trying &lt;code&gt;Vim&lt;/code&gt; capabilities and stuck with this task - addition the incrementing number to the end of each line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Testing lines:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text&#xA;text&#xA;text&#xA;text&#xA;text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command works partially:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let n=1 | g/text/s/$/\=n/ | let n+=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text1 &#xA;text2 &#xA;text3 &#xA;text4 &#xA;text5 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I want to have space between the added numbers and the 'text'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The adding of space ' ' before the &lt;code&gt;\=&lt;/code&gt;doesn't work, because the &lt;code&gt;\=&lt;/code&gt; should be in the beginning of substitute expression, else it is not parsed as an expression, but inserted literally - &lt;code&gt;text =n&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let n=1 | g/text/s/$/ \=n/ | let n+=1 ### doesn't work as expected&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So, the questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is it possible to insert a string in the substitute expression?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Like this (the &lt;code&gt;n&lt;/code&gt; is the variable):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/$/string\=n/&#xA;s/$/'string'\=n/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/$/\='string'n/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Can I use multiple variables in the substitute expression by separating them from each other like in the &lt;code&gt;bash&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/$/\={var_1}{var_2}{var_3}/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;3. Do you know more suitable/simple way for solving this task?&lt;/p&gt;&#xA;" OwnerUserId="14024" LastActivityDate="2019-01-18T11:22:05.180" Title="How to add a space or a string into the substitute expression?" Tags="|substitute|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18604" PostTypeId="2" ParentId="18603" CreationDate="2019-01-17T19:25:14.433" Score="1" Body="&lt;p&gt;&lt;strong&gt;Answer to the question №1:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let n=1 | g/text/s/$/\=printf(&quot; %d&quot;, n)/ | let n+=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text 1 &#xA;text 2 &#xA;text 3 &#xA;text 4 &#xA;text 5 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Answer to the question №2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The substitute expression can contain multiple variables separated (concatenated) by dot &lt;code&gt;.&lt;/code&gt; operator.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let a = 'one'&#xA;:let b = 'two'&#xA;:let c = 'three'&#xA;:g/text/s/$/\=a.b.c/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;textonetwothree &#xA;textonetwothree &#xA;textonetwothree &#xA;textonetwothree &#xA;textonetwothree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it is needed separate them by space, then do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/text/s/$/\=' '.a.' '.b.' '.c/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/text/s/$/\=printf(' %s %s %s', a, b, c)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text one two three &#xA;text one two three &#xA;text one two three &#xA;text one two three &#xA;text one two three &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14024" LastEditorUserId="14024" LastEditDate="2019-01-18T11:22:05.180" LastActivityDate="2019-01-18T11:22:05.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18605" PostTypeId="2" ParentId="18603" CreationDate="2019-01-17T19:33:04.380" Score="4" Body="&lt;p&gt;For your answer specifically, you could get around this by concatenating a space with the number, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let n=1 | g/text/s/$/\=&quot; &quot;.n/ | let n+=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to do this to every line, there are some much shorter ways to do this. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/$/\=&quot; &quot;.line('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you only want to number the lines matching &quot;text&quot;, then either of these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/text/\=submatch(0).&quot; &quot;.line('.')&#xA;:%s/text\zs/\=&quot; &quot;.line('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could even do the entire thing in normal mode. For example, you could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg&amp;lt;C-v&amp;gt;G$A 0&amp;lt;esc&amp;gt;gvg&amp;lt;C-a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; means &lt;kbd&gt;ctrl-v&lt;/kbd&gt; and &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; means &lt;kbd&gt;ctrl-a&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2019-01-17T20:23:47.940" LastActivityDate="2019-01-17T20:23:47.940" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18606" PostTypeId="2" ParentId="18602" CreationDate="2019-01-17T19:48:15.027" Score="3" Body="&lt;p&gt;Here's what I would do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match label &quot;\&amp;lt;[a-zA-Z_$][a-zA-Z_$0-9]*\s*:[:=]\@!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First off, general comments. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[ \t]&lt;/code&gt; could be &lt;code&gt;\s&lt;/code&gt;, which match the exact same things.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;[:=]\@!&lt;/code&gt; is called a &lt;em&gt;negative lookahead&lt;/em&gt;. So if you have &lt;code&gt;&amp;lt;atom&amp;gt;\@!&lt;/code&gt; then it only matches if &lt;code&gt;&amp;lt;atom&amp;gt;&lt;/code&gt; does not match at that position, but it also doesn't &quot;eat&quot; that atom. So it's like saying &quot;all that stuff, &lt;em&gt;not&lt;/em&gt; followed by a colon or an equals.&quot;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This could also be a bit shorter by taking advantage of character classes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match label &quot;\v(\h|\$)(\w|\$)*\s*:[:=]@!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\h&lt;/code&gt; is the same as &lt;code&gt;[a-zA-Z_]&lt;/code&gt;, and &lt;code&gt;\w&lt;/code&gt; is the same as &lt;code&gt;[a-zA-Z0-9_]&lt;/code&gt;. And &lt;a href=&quot;http://vim.wikia.com/wiki/Simplifying_regular_expressions_using_magic_and_no-magic&quot; rel=&quot;nofollow noreferrer&quot;&gt;using &lt;code&gt;\v&lt;/code&gt; at the beginning&lt;/a&gt; allows us to make a bit shorter by removing some backslashes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-01-17T19:48:15.027" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18607" PostTypeId="2" ParentId="18590" CreationDate="2019-01-17T20:17:44.647" Score="0" Body="&lt;p&gt;According to &lt;code&gt;:help 'smartindent'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Do smart autoindenting when starting a new line.  Works for C-like&#xA;      programs, but can also be used for other languages.  'cindent' does&#xA;      something like this, works better in most cases, but is more strict,&#xA;      see |C-indenting|.  When 'cindent' is on or 'indentexpr' is set,&#xA;      setting 'si' has no effect.  'indentexpr' is a more advanced&#xA;      alternative.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus, there are several options that work in the same context. I suspect that this is primarily for historical reasons. Vim tries very hard not to break backwards compatibility. Thus, if a setting is improved in a way that might break things, the Vim way is to introduce a new setting. Perhaps some users prefer the old way. Thus, judging from the documentation, it appears that &lt;code&gt;smartindent&lt;/code&gt; is an earlier approach to indenting C-like code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the documented behavior tells us that it's specifically aimed at C and similar languages. Thus, it's to be expected that it would cause problems in plain text files, Python, Javascript, etc. Better to set it in a filetype autocommand if you want it. Personally, I find that &lt;code&gt;:set autoindent&lt;/code&gt; meets my needs just fine, since I never write C code.&lt;/p&gt;&#xA;" OwnerUserId="20217" LastActivityDate="2019-01-17T20:17:44.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18608" PostTypeId="2" ParentId="18590" CreationDate="2019-01-17T20:59:13.333" Score="1" Body="&lt;p&gt;Here is an example typing the following into &lt;code&gt;vim --clean&lt;/code&gt;, with each option set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello {&#xA;world&#xA;foo;&#xA;bar&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;smartindent&lt;/code&gt; only:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello {&#xA;    world&#xA;    foo;&#xA;    bar&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;cindent&lt;/code&gt; only:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello {&#xA;    world&#xA;        foo;&#xA;    bar&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see with &lt;code&gt;cindent&lt;/code&gt;, vim tries to continue lines that are incomplete (i.e., without semicolon).  If your language is c-like, this behavior is smart.  On the other hand, if your language uses braces but no semicolons, this would be undesirable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;cindent&lt;/code&gt; has many more options via &lt;code&gt;cinoptions&lt;/code&gt; and can be configured to suit many languages.  This example demonstrates just the default behavior with no additional configuration.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-01-17T20:59:13.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18609" PostTypeId="1" CreationDate="2019-01-17T21:23:31.427" Score="3" ViewCount="1440" Body="&lt;p&gt;I nearly always have a terminal window open when I'm doing extensive editing in Vim. I've used &lt;code&gt;tnoremap&lt;/code&gt; to set mappings for the three heights I want the terminal window to be able to take.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, when splitting a window or quitting a window, Vim resizes all windows (effectively doing a &lt;code&gt;^W=&lt;/code&gt;). I want my terminal window to be exempt from all such resizing. If as a consequence all resizing except for adjusting the adjacent windows to close up the space is disabled, I can live with that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I tell Vim to never resize my terminal window unless I explicitly request it? Better yet, in addition to my last question, is it possible to make my terminal window keep its size even when I issue &lt;code&gt;^W_&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="20217" LastActivityDate="2019-01-18T01:57:28.427" Title="Prevent a window from resizing" Tags="|terminal|vim-windows|" AnswerCount="1" CommentCount="0" ClosedDate="2019-01-18T12:01:34.900" ContentLicense="CC BY-SA 4.0" />
  <row Id="18610" PostTypeId="2" ParentId="3600" CreationDate="2019-01-17T22:39:08.490" Score="0" Body="&lt;p&gt;Thanks for the hint from the &lt;a href=&quot;https://vi.stackexchange.com/a/3601&quot;&gt;other answer here&lt;/a&gt;. It largely works. But keep typing all those &quot;:cd ...; bash ...; cd -&quot; MULTIPLE TIMES are so bothersome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case, I was going to do a bunch of shell commands. More precisely, I started my vim in repo_foo, AND also open some files in helper repo_bar. Later I realized I would need to do several git commands in that helper repo_bar. I ended up shell out to the repo_bar's directory, by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!cd %:p:h; bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do NOT need to do &lt;code&gt;cd -&lt;/code&gt; to go back to my original working directory, because when I later &lt;code&gt;exit&lt;/code&gt; the sub-shell, it will automatically go back to the parent shell with the original working directory intact.&lt;/p&gt;&#xA;" OwnerUserId="9189" LastActivityDate="2019-01-17T22:39:08.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18611" PostTypeId="1" AcceptedAnswerId="18612" CreationDate="2019-01-17T23:45:20.303" Score="4" ViewCount="6038" Body="&lt;p&gt;My ideal editing layout would look like this (in Gvim):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----------------------------------------------------------&#xA;|       |                      |                         |&#xA;|   N   |                                                |&#xA;|   E   |                      |                         |&#xA;|   R   |                Editing Area                    |&#xA;|   D   |-   -   -   -   -   -   -   -   -   -   -   -   |&#xA;|       |  (various splits, horizontal and/or vertical)  |&#xA;|   T   |                      |                         |&#xA;|   r   |                                                |&#xA;|   e   |                      |                         |&#xA;|   e   |------------------------------------------------|&#xA;|       |                                                |&#xA;|       | Terminal window (:terminal)                    |&#xA;|       |                                                |&#xA;|       |                                                |&#xA;----------------------------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note in particular:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I want the terminal window to open at the bottom. Setting &lt;code&gt;splitbelow&lt;/code&gt; might work for this, but it would affect all splits, not only the terminal window.&lt;/li&gt;&#xA;&lt;li&gt;I can move the terminal to the bottom with &lt;code&gt;&amp;lt;C-W&amp;gt;J&lt;/code&gt;, but this puts it below NERDTree, requiring me to then toggle NERDTree.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm looking to create a mapping that will allow me to open a terminal and place it where indicated in my diagram. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="20217" LastActivityDate="2019-07-28T19:44:24.563" Title="Always open terminal window at the bottom" Tags="|vim-windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18612" PostTypeId="2" ParentId="18611" CreationDate="2019-01-18T00:06:52.820" Score="2" Body="&lt;p&gt;We start with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bel terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;:bel[owright]&lt;/code&gt; is followed by a command that splits a window the new window is opened below the current one. That means we first need to get to the bottom right window of the existing layout and then do &lt;code&gt;:bel&lt;/code&gt;. &lt;code&gt;Ctrl-W b&lt;/code&gt; is how we'd go to the bottom right in Normal mode. The Ex command equivalent is &lt;code&gt;:wincmd b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Combining into a mapping...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;t :wincmd b \| bel terminal&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-01-18T00:49:50.853" LastActivityDate="2019-01-18T00:49:50.853" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18613" PostTypeId="1" AcceptedAnswerId="18616" CreationDate="2019-01-18T00:42:50.493" Score="1" ViewCount="1271" Body="&lt;p&gt;In the following image, you can see that 79 has a darker background than other numbers... I tried to see where to change the background color for that but couldn't... Could anyone help?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/xRR83.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xRR83.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20416" LastActivityDate="2019-01-18T03:18:32.290" Title="Background color not transparent under current line number" Tags="|colorscheme|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18614" PostTypeId="1" CreationDate="2019-01-18T01:19:45.063" Score="1" ViewCount="2234" Body="&lt;p&gt;My machines have Python 3.7 installed. On my Ubuntu machine I have no issues, but on my Windows 10 machine, I can't run Python plugins in Vim. The reason is that the Windows Vim as distributed has been compiled for Python 3.6, and Vim will only use the Python version that was specified at compilation time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is this: Why does it matter which Python version I use, as long as the scripts are compatible? Why try to embed a part of Python in the program (a DLL on Windows), instead of either embedding the whole thing or--better yet--just calling out to the python executable? Then the version doesn't matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI: I've tried to build my own Vim on Windows, but it seems that the documentation on how to do so is quite outdated and building software on Windows is incredibly difficult (install a text editor to get a compiler?!).&lt;/p&gt;&#xA;" OwnerUserId="20217" LastActivityDate="2019-01-19T08:53:35.360" Title="Why is Vim's Python version compiled in?" Tags="|vimscript-python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18615" PostTypeId="2" ParentId="18609" CreationDate="2019-01-18T01:57:28.427" Score="7" Body="&lt;p&gt;In researching something else, I stumbled across the answer to this question:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noequalalways&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20217" LastActivityDate="2019-01-18T01:57:28.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18616" PostTypeId="2" ParentId="18613" CreationDate="2019-01-18T03:18:32.290" Score="1" Body="&lt;p&gt;I finally managed to solve it using &lt;code&gt;highlight clear CursorLineNR&lt;/code&gt; since my terminal colorscheme was the one which had some transparency to it's background.&lt;/p&gt;&#xA;" OwnerUserId="20416" LastActivityDate="2019-01-18T03:18:32.290" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18617" PostTypeId="1" AcceptedAnswerId="18619" CreationDate="2019-01-18T06:05:12.673" Score="1" ViewCount="327" Body="&lt;p&gt;I have this bit of vim script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F9&amp;gt; :w&amp;lt;cr&amp;gt;&#xA;  \:execute 'silent !tmux new -ds blah'&amp;lt;cr&amp;gt;&#xA;  \:execute &quot;silent !tmux send-keys -t blah '%:p' Enter&quot;&amp;lt;cr&amp;gt;&#xA;  \:execute 'silent !open_iterm'&amp;lt;cr&amp;gt;&#xA;  \:redraw!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It chokes when there is a space in the path with a &quot;no such directory&quot; error. the culprit is the &lt;code&gt;%:p&lt;/code&gt; bit. How do I fix this?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="21" LastEditDate="2019-01-18T07:58:20.130" LastActivityDate="2020-10-09T10:02:40.367" Title="Using %:p when path has space in it" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18619" PostTypeId="2" ParentId="18617" CreationDate="2019-01-18T06:32:09.887" Score="2" Body="&lt;p&gt;Got it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F9&amp;gt; :w&amp;lt;cr&amp;gt;&#xA;  \:execute 'silent !tmux new -ds blah'&amp;lt;cr&amp;gt;&#xA;  \:execute &quot;silent !tmux send-keys -t blah '&quot; . fnameescape(expand('%:p')) . &quot;' Enter&quot;&amp;lt;cr&amp;gt;&#xA;  \:execute 'silent !open_iterm'&amp;lt;cr&amp;gt;&#xA;  \:redraw!&amp;lt;cr&amp;gt;`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="21" LastEditDate="2019-01-18T08:00:02.633" LastActivityDate="2019-01-18T08:00:02.633" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18620" PostTypeId="1" CreationDate="2019-01-18T07:36:34.287" Score="0" ViewCount="471" Body="&lt;p&gt;using &lt;code&gt;:browse old&amp;lt;cr&amp;gt;&lt;/code&gt; it's possible to view a list of the 100 most recently visited files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when selecting a file to visit, it's only possible to provide a single number and not a sequence of numbers or a range. Indeed, the prompt visible after pressing &lt;code&gt;:browse&amp;lt;cr&amp;gt;G&lt;/code&gt; does not allow the input of symbols other than &lt;code&gt;0123456789&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a separate command that can be used to open a range of oldfiles?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2019-03-13T00:12:16.080" Title="open multiple oldfiles" Tags="|multiple-files|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18621" PostTypeId="1" CreationDate="2019-01-18T11:32:26.840" Score="2" ViewCount="1101" Body="&lt;p&gt;I want to achieve two effects about using the netrw plugin for vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EFFECT ONE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a test directory.Here is its directory structure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MINGW64 ~/test&#xA;$ ll&#xA;total 1&#xA;drwxr-xr-x 1 uooki2 197121  0 一月   18 18:37 dir1/&#xA;drwxr-xr-x 1 uooki2 197121  0 一月   18 18:37 dir2/&#xA;drwxr-xr-x 1 uooki2 197121  0 一月   18 18:37 dir3/&#xA;-rw-r--r-- 1 uooki2 197121 13 一月   18 18:38 file1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can open the test directory via vim ，And vim displays the directory tree structure of this directory in a window.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ============================================================================&#xA;&quot; Netrw Directory Listing                                        (netrw v156)&#xA;&quot;   /c/Users/uooki2/test&#xA;&quot;   Sorted by      name&#xA;&quot;   Sort sequence: [\/]$,\&amp;lt;core\%(\.\d\+\)\=\&amp;gt;,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp&#xA;&quot;   Quick Help: &amp;lt;F1&amp;gt;:help  -:go up dir  D:delete  R:rename  s:sort-by  x:special&#xA;&quot; ==============================================================================&#xA;../&#xA;./&#xA;dir1/&#xA;dir2/&#xA;dir3/&#xA;file1&#xA;~&#xA;~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But,i hope that vim can open two windows ,one on the left and one on the right ; and the window on the left shows the directory tree structure of the test directory, and the right side is a blank window. And the width of the left window is 30 percent of the width of the right window. Just like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ==================|  1&#xA;&quot; Netrw Directory Li|~&#xA;&quot;   /c/Users/uooki2/|~&#xA;&quot;   Sorted by      n|~&#xA;&quot;   Sort sequence: [|~&#xA;&quot;   Quick Help: &amp;lt;F1&amp;gt;|~&#xA;&quot; ==================|~&#xA;../                 |~&#xA;./                  |~&#xA;dir1/               |~&#xA;dir2/               |~&#xA;dir3/               |~&#xA;file1               |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;2          test 0x2&amp;gt; 3          [unnamed] 0x0       0,0-1         &amp;lt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what should i do to achieve this effect?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EFFECT TWO:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I opened the file1 file in bash by the command: vim file1.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim file1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim open the file1 file  in a window. As follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1 hello world!&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;1          file1                           0x68      1,1           all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But，this is not what i want. I want that vim can open two windows ,one on the left and one on the right ; and the window on the left shows the directory tree structure of the  directory where the file1 file is located, and the right side shows the content of the file1 file. And the width of the left window is 30 percent of the width of the right window. Just like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;   /c/Users/uooki2/|  1 hello world!&#xA;&quot;   Sorted by      n|~&#xA;&quot;   Sort sequence: [|~&#xA;&quot;   Quick Help: &amp;lt;F1&amp;gt;|~&#xA;&quot; ==================|~&#xA;../                 |~&#xA;./                  |~&#xA;dir1/               |~&#xA;dir2/               |~&#xA;dir3/               |~&#xA;.file1.swo          |~&#xA;file1               |~&#xA;.file1.swp          |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;~                   |~&#xA;2          test 0x2&amp;gt; 4          test/file1 0x68      1,1      &amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should I modify the vimrc file? Or write a vimScript to achieve? Or netrw can do these functions by itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should i do to achieve this effect?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim version: vim8.1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to depend too heavily on third-party plugins, and I want to be able to use these two features directly on all machines where vim is installed, so I don't want to use nerdtree or any other third party plugins.&lt;/p&gt;&#xA;" OwnerUserId="20589" LastEditorUserId="20589" LastEditDate="2019-01-21T08:26:20.647" LastActivityDate="2019-01-21T08:26:20.647" Title="How to make vim open two windows when opening a directory or file with netrw?" Tags="|vimscript|netrw|original-vim|vim-development|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18622" PostTypeId="2" ParentId="9236" CreationDate="2019-01-18T14:34:51.940" Score="1" Body="&lt;p&gt;&lt;code&gt;**&lt;/code&gt; matches only directories as you can read in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#file-searching&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/editing.html#file-searching&lt;/a&gt;, but obviously &lt;strong&gt;at least 1 subdirectory&lt;/strong&gt; if you are using backslashes in your path.&#xA;I.e. &lt;code&gt;**&lt;/code&gt; matches not &lt;em&gt;0..n&lt;/em&gt; but &lt;em&gt;1..n&lt;/em&gt; subdirectories. (Again) this is true only when you are using backslashes in your search path.&lt;/p&gt;&#xA;" OwnerUserId="20098" LastActivityDate="2019-01-18T14:34:51.940" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18623" PostTypeId="2" ParentId="18621" CreationDate="2019-01-18T22:25:26.130" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDTree&lt;/a&gt; (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1658&quot; rel=&quot;nofollow noreferrer&quot;&gt;#1658&lt;/a&gt;) is a plugin that does those things by default, and much more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using vim 8, just enter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ git clone https://github.com/scrooloose/nerdtree  ~/.vim/pack/my-plugins/start/nerdtree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also look through the included manual with &lt;a href=&quot;https://github.com/scrooloose/nerdtree/blob/master/doc/NERDTree.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h NerdTree&lt;/code&gt;&lt;/a&gt;. You might need to update the help tags with &lt;code&gt;:helptags ALL&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16949" LastEditorUserId="1292" LastEditDate="2019-01-20T08:34:06.660" LastActivityDate="2019-01-20T08:34:06.660" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18625" PostTypeId="2" ParentId="18614" CreationDate="2019-01-19T08:53:35.360" Score="3" Body="&lt;p&gt;Vim can be build with static python or dynamic python support. If it is build with dynamic python you are able to change the python version. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just look at the output of &lt;code&gt;:version&lt;/code&gt;. If it contains &lt;code&gt;+python/dyn&lt;/code&gt; and &lt;code&gt;+python3/dyn&lt;/code&gt;, it is compiled for dynamic python. Then you are able to change the python dll to use by changing the option &lt;code&gt;pythondll&lt;/code&gt; or &lt;code&gt;pythonthreedll&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set pythonthreedll=python37.dll&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If Vim is not compiled with dynamic python support, this will result in an error message, as the option doesn't exist then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: If python is not installed, but only unpacked from a zip, Vim is not able to find it that way. Then you need:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set pythonthreehome=C:\path\to\python&#xA;set pythonthreedll=C:\path\to\python\python37.dll&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also useful if you have multiple python installations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As already mentioned in a comment, a up-to-date version of Vim for Windows with dynamic python support, can be downloaded from &lt;a href=&quot;https://github.com/vim/vim-win32-installer/releases&quot; rel=&quot;nofollow noreferrer&quot;&gt;this github page&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help python-dynamic&lt;/code&gt; and help for the named options. &lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-19T08:53:35.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18627" PostTypeId="2" ParentId="18620" CreationDate="2019-01-19T10:10:02.890" Score="2" Body="&lt;h2&gt;Plugins&lt;/h2&gt;&#xA;&lt;p&gt;There are plenty of plugins which provide a custom prompt for mru lists and allow you to select several entries:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Mru list by ctrlp.vim&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open mru list with &lt;code&gt;&amp;lt;c-p&amp;gt;&amp;lt;c-b&amp;gt;&lt;/code&gt; or &lt;code&gt;:CtrlPMR[UFiles]&lt;/code&gt; or  set &lt;code&gt;let g:ctrlp_cmd = 'CtrlPMRU'&lt;/code&gt; in your vimrc and then &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt; (my choice).&lt;/li&gt;&#xA;&lt;li&gt;select entries either via fuzzy search expr or cycle with &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-k&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;&amp;lt;c-z&amp;gt;&lt;/code&gt; to mark/unmark multiple files&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; to open them.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;:History in fzf.vim&lt;/strong&gt;&lt;/a&gt; (requires go)&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;TAB&lt;/code&gt; and &lt;code&gt;Shift-TAB&lt;/code&gt; to mark multiple items&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/yegappan/mru&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;mru.vim&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;You can open multiple files from the MRU window by specifying a count&#xA;before pressing '' or 'v' or 'o' or 't'. You can also visually select&#xA;multiple filenames and invoke the commands to open the files. Each&#xA;selected file will be opened in a separate window or tab.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Furthermore, you might consider &lt;a href=&quot;https://github.com/pbogut/fzf-mru.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf-mru&lt;/a&gt;, &lt;a href=&quot;https://github.com/wincent/command-t&quot; rel=&quot;nofollow noreferrer&quot;&gt;Command-T&lt;/a&gt; (+ruby) and &lt;a href=&quot;https://github.com/Shougo/denite.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Denite&lt;/a&gt; (+python3) with &lt;a href=&quot;https://github.com/Shougo/neomru.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;neomru.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As far as I haved check &lt;a href=&quot;https://github.com/romainl/vim-tinyMRU&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-tinyMRU&lt;/a&gt; does not allow to do this.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-02-20T07:56:02.020" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18629" PostTypeId="2" ParentId="18621" CreationDate="2019-01-19T13:48:14.670" Score="1" Body="&lt;p&gt;As others have pointed out your intended way of using netrw as a project drawer is not very well supported, designed for or a good fit in general for editors which use splits. I hope you find the time to read the mentioned article &lt;a href=&quot;http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Oil and vinegar – split windows and the project drawer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Despite this, netrw tries to provide some functionality to behave like a project drawer&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pi_netrw.txt.html#netrw-%3ALexplore&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:Lexplore&lt;/code&gt;&lt;/a&gt; Left Explorer Toggle&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pi_netrw.txt.html#netrw-P&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;P&lt;/code&gt;&lt;/a&gt; Edit in the previously used window&lt;/li&gt;&#xA;&lt;li&gt;Setting an editing window with &lt;a href=&quot;http://vimhelp.appspot.com/pi_netrw.txt.html#netrw-editwindow&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:NetrwC&lt;/code&gt;&lt;/a&gt; (i.e. open file from netrw in a specified window)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Additionally, you could try following to open the left explorer on startup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; On VimEnter&#xA;&quot; 1. open empty window along netrw window when starting with a directory as&#xA;&quot;    argument, or&#xA;&quot; 2. open netrw-Lexplore when opening a file or without argument&#xA;let g:netrw_winsize = 30&#xA;let g:netrw_liststyle = 3&#xA;augroup OpenLexploreOnStartup&#xA;    autocmd!&#xA;    autocmd VimEnter * if isdirectory(@%)&#xA;            \|   rightb vnew | exec 'vertical resize '. string(&amp;amp;columns * 0.7)&#xA;            \|   let g:netrw_chgwin = winnr()&#xA;            \| else &#xA;            \|   Lexplore&#xA;            \| endif&#xA;            \| wincmd p&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, you will most likely make the experience that netrw is cumbersome to use this way, in particular when you use several windows which cannot really be avoided: help window, quickfix window, diff windows, two code files next to each other (header/implementation), terminal window, ....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can only reiterate it one more time: If you want to use a project drawer, consider NerdTree, otherwise the way suggested by the article is recommended. The plugin &lt;a href=&quot;https://github.com/tpope/vim-vinegar&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-vinegar&lt;/a&gt; helps here and adds the global normal mode mapping &lt;code&gt;-&lt;/code&gt; to open a netrw window in-place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can basically &lt;a href=&quot;https://www.reddit.com/r/vim/comments/a062eb/replicating_vimvinegar_in_a_single_mapping/&quot; rel=&quot;nofollow noreferrer&quot;&gt;replicate vim-vinegar with these two lines&lt;/a&gt; in your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_banner = 0&#xA;nnoremap - :E&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim-vinegar would provide additionally a different sorting, file hiding behavior (ie. hide &lt;code&gt;'wildignore'&lt;/code&gt;), &lt;a href=&quot;https://github.com/tpope/vim-vinegar/blob/master/doc/vinegar.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;a few shortcuts&lt;/a&gt; (e.g. &lt;code&gt;~&lt;/code&gt; go home, &lt;code&gt;y.&lt;/code&gt; yank current filename as absolute path) and some modifications to syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I also want to add a remark about vanilla vim vs. vim+vimrc vs vim+plugins&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vanilla vim obviously does not work the way you want it. You need to customize.&lt;/li&gt;&#xA;&lt;li&gt;Copying an answer/code snippet from the internet into your vimrc is not any different than using a plugin. All plugins are open source and the code can be read and modified. They are not necessarily black boxes.&lt;/li&gt;&#xA;&lt;li&gt;Small lightweight plugins provide a solution to a desired functionality. They are usually documented and more tested than a homebaked code snippet.&lt;/li&gt;&#xA;&lt;li&gt;After a year people often do not understand anymore what the thousands of lines in their vimrc do.&lt;/li&gt;&#xA;&lt;li&gt;vim-vinegar is a single file plugin with a line count of 130 which can be read, understood and changed to the own liking.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-01-20T08:26:46.093" LastActivityDate="2019-01-20T08:26:46.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18631" PostTypeId="1" AcceptedAnswerId="18691" CreationDate="2019-01-19T17:50:44.717" Score="2" ViewCount="1020" Body="&lt;h1&gt;tl;dr:&lt;/h1&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How do I override the colorscheme's cursor color in a highlight block&lt;/li&gt;&#xA;&lt;li&gt;How do I find a comprehensive list of colorscheme variables and how do I set them in general (to override a colorscheme's defaults)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have been using Evan Schoonover's &lt;a href=&quot;https://github.com/altercation/solarized/tree/master/vim-colors-solarized&quot; rel=&quot;nofollow noreferrer&quot;&gt;Solarized&lt;/a&gt; colorscheme (the dark mode) and absolutely love it. Except for one &lt;em&gt;very&lt;/em&gt; annoying problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When incremental highlighting is on for &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;?&lt;/code&gt; searching, the cursor inside a highlighted block disappears:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DLFf5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DLFf5.png&quot; alt=&quot;cursorhighlighting problems&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the picture, the search was &lt;code&gt;/te&lt;/code&gt;, so the highlight covers &lt;code&gt;te&lt;/code&gt; but the cursor is setting on the &lt;code&gt;t&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is absolutely horrific for large scale search/replace &lt;code&gt;n.&lt;/code&gt; repeat operations. I can never quite tell where my current position is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am unsure if this problem is related to my terminal colors (I am using &lt;code&gt;urxvt&lt;/code&gt; with the Schoonover's &lt;a href=&quot;https://github.com/altercation/solarized/blob/master/xresources/solarized&quot; rel=&quot;nofollow noreferrer&quot;&gt;solarized xresources theme&lt;/a&gt; and some minor adjustments (set the font, the scrollbar, etc), especially considering the fact that I have yet to see anyone complain of the same problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For further context: I am using &lt;code&gt;i3wm&lt;/code&gt; in &lt;code&gt;Arch Linux&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even further context: I've been using &lt;code&gt;neovim&lt;/code&gt; for a while, but have never used a plugin manager, and the only 'plugin' I've ever used is this colorscheme (it just resides in my &lt;code&gt;~/.config/nvim/colors&lt;/code&gt; directory).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose hi&#xA; verbose hi&#xA;SpecialKey     xxx cterm=bold ctermfg=11 ctermbg=0 guifg=Cyan&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;EndOfBuffer    xxx links to NonText&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;TermCursor     xxx cterm=reverse gui=reverse&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;TermCursorNC   xxx cleared&#xA;NonText        xxx cterm=bold ctermfg=11 gui=bold guifg=Blue&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;Directory      xxx ctermfg=4 guifg=Cyan&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;ErrorMsg       xxx cterm=reverse ctermfg=1 guifg=White guibg=Red&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;IncSearch      xxx cterm=standout ctermfg=9 gui=reverse&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;Search         xxx cterm=reverse ctermfg=3 guifg=Black guibg=Yellow&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;MoreMsg        xxx ctermfg=4 gui=bold guifg=SeaGreen&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;ModeMsg        xxx ctermfg=4 gui=bold&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;LineNr         xxx ctermfg=10 ctermbg=0 guifg=Yellow&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;CursorLineNr   xxx ctermfg=11 gui=bold guifg=Yellow&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;Question       xxx cterm=bold ctermfg=6 gui=bold guifg=Green&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;StatusLine     xxx cterm=reverse ctermfg=14 ctermbg=0 gui=bold,reverse&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;StatusLineNC   xxx cterm=reverse ctermfg=11 ctermbg=0 gui=reverse&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;VertSplit      xxx ctermfg=11 ctermbg=11 gui=reverse&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;Title          xxx cterm=bold ctermfg=9 gui=bold guifg=Magenta&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;Visual         xxx cterm=reverse ctermfg=10 ctermbg=8 guibg=DarkGrey&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;VisualNC       xxx cleared&#xA;WarningMsg     xxx cterm=bold ctermfg=1 guifg=Red&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm convinced it would be related to these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TermCursor     xxx cterm=reverse gui=reverse&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;TermCursorNC   xxx cleared&#xA;IncSearch      xxx cterm=standout ctermfg=9 gui=reverse&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;Search         xxx cterm=reverse ctermfg=3 guifg=Black guibg=Yellow&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;CursorLineNr   xxx ctermfg=11 gui=bold guifg=Yellow&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Specifically the bits reading &lt;code&gt;gui=reverse&lt;/code&gt; seem highly indicative to me, but I am unsure, and also have no idea how to set them. I tried searching through the source file, &lt;em&gt;and&lt;/em&gt; hacking at it, but couldn't get it to load properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Advice?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Update 2:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have discovered the syntax and the (semiright) variable:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Search&lt;/code&gt; is the variable that corresponds to the mode presenting my problem (&lt;code&gt;IncSearch&lt;/code&gt; regards as-you-type searching colors (different, apparently)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;hi Search ctermfg=&amp;lt;color&amp;gt;&lt;/code&gt; changes the general color of the highlight. &lt;code&gt;ctermbg&lt;/code&gt; does nothing. The cursor seems out of the picture.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cterm=underline&lt;/code&gt; changes the highlighting mode to underline the selection, which properly changes the cursor color, but I would prefer to simply change the color of the cursor, not the mode of highlighting.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Will keep experimenting&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Solved:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It seems that the nature of the problem is simply the setting of Search &lt;code&gt;cterm=reverse&lt;/code&gt; and because of the nature of that specific setting, this is an impossible problem. ((Does no one else experience this?))&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Scratch all that: solved the problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Search         xxx cterm=reverse ctermfg=3 guifg=Black guibg=Yellow&#xA;        Last set from ~/.config/nvim/colors/solarized.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;essentially says to reverse the color scheme. I found that setting ctermbg did nothing for the cursor color. This was frustrating. I still don't &lt;em&gt;fully&lt;/em&gt; understand why, if the colors are simply reversed setting ctermbg wouldn't solve the problem. Solved it anyway with a (seemingly hacky?) workaround&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Turn off &lt;code&gt;cterm=reverse&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Set &lt;code&gt;ctermbg&lt;/code&gt; to the former value of &lt;code&gt;ctermfg&lt;/code&gt; (3)&lt;/li&gt;&#xA;&lt;li&gt;Set &lt;code&gt;ctermfg&lt;/code&gt; to something sufficiently high contrast to read the highlighted text (it needs to be dark; I went with 8).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Command: &lt;code&gt;hi Search cterm=none ctermbg=3 ctermfg=8&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The cursor becomes the color of normal unhighlighted text. This makes it visible. Setting the no reverse causes the highlighted text to be difficult to read, so the &lt;code&gt;ctermfg&lt;/code&gt;corrects that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm going to leave the answer open to someone with more understanding, who might expand on this subject for future readers. If no one answers in the next week, I'll just post this section as an answer and accept it.&lt;/p&gt;&#xA;" OwnerUserId="17830" LastEditorUserId="17830" LastEditDate="2019-01-19T20:21:07.020" LastActivityDate="2019-01-24T14:45:40.493" Title="Incremental Highlighting Colorscheme Override" Tags="|colorscheme|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="18633" PostTypeId="1" AcceptedAnswerId="18637" CreationDate="2019-01-19T20:06:54.890" Score="0" ViewCount="59" Body="&lt;p&gt;I find the command-line window incredibly useful for experimenting with my vim environment. But it's annoying to have to type &lt;code&gt;q:&lt;/code&gt; every time I execute a line with &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;. Is there a way to execute the line under my cursor &lt;em&gt;but not exit the command line window&lt;/em&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The help menu doesn't seem to suggest that. Only how to get out of the command line window.&lt;/p&gt;&#xA;" OwnerUserId="17830" LastActivityDate="2019-01-20T17:35:00.307" Title="Is there a way to stay in the command line window after executing a line?" Tags="|command-line|command-line-window|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18634" PostTypeId="1" CreationDate="2019-01-19T20:10:22.753" Score="1" ViewCount="352" Body="&lt;p&gt;I have found myself falling into a workflow where I'm often starting vim by running &lt;code&gt;$ vim&lt;/code&gt; and then opening up the most recent file once inside.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering how to detect:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;when vim is launched&lt;/li&gt;&#xA;&lt;li&gt;which files it was launched with&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;so that in the case when no files are specified, I can run a custom command (such as opening the most recent file).&lt;/p&gt;&#xA;" OwnerUserId="20625" LastActivityDate="2019-01-21T05:07:45.010" Title="Opening up most recent file automatically when vim is started without command line arguments" Tags="|command-line|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18635" PostTypeId="2" ParentId="18634" CreationDate="2019-01-20T10:25:34.080" Score="3" Body="&lt;p&gt;You could start with something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyVimEnter()&#xA;    if argc() != 0&#xA;        return&#xA;    endif&#xA;&#xA;    if exists(&quot;v:oldfiles[0]&quot;) &amp;amp;&amp;amp; filereadable(expand(v:oldfiles[0]))&#xA;        execute &quot;e &quot; . v:oldfiles[0]&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot; The 'nested' before call allows nested autocmds, important for&#xA;&quot; syntax detection etc.&#xA;autocmd VimEnter * nested call MyVimEnter()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whenever Vim is started and finished setup, the function &lt;code&gt;MyVimEnter&lt;/code&gt; is called. This checks if files where given on the command line. If yes, it returns immediately. If no, it loads the last file you edited.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-21T05:07:45.010" LastActivityDate="2019-01-21T05:07:45.010" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18636" PostTypeId="1" AcceptedAnswerId="18646" CreationDate="2019-01-20T15:06:00.407" Score="0" ViewCount="1073" Body="&lt;p&gt;I have this texts&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;drwxr-xr-x  enan    enan    Jan 15  16:10   Desktop/&#xA;drwxr-xr-x  enan    enan    Jan 16  20:09   Documents/&#xA;drwxr-xr-x  enan    enan    Jan 20  19:52   Downloads/&#xA;drwxr-xr-x  enan    enan    Nov 3   20:44   Music/&#xA;drwxr-xr-x  enan    enan    Jan 17  20:21   Pictures/&#xA;drwxr-xr-x  enan    enan    Jan 20  20:10   Videos/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The spaces separating the columns are tabs. How could I replace these tabs with appropriate number of spaces so that the columns are arranged just like above, thus not altered at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently do this with &lt;code&gt;:set et | '&amp;lt;,'&amp;gt; retab! | set noet&lt;/code&gt; after selecting the block visually, so that &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; marks are set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I came across these commands which are supposed to replace tabs at the beginning of a line to spaces, but I can't understand what it's doing. I think I could change this to do the above task with one substitution, although a complicated one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% -nargs=0 Tab2Space&#xA;            \ execute '&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;s#^\t\+#\=repeat(&quot; &quot;, len(submatch(0))*' . &amp;amp;ts . ')'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-01-21T10:31:44.517" Title="Replace tabs with appropriate number of spaces" Tags="|substitute|whitespace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18637" PostTypeId="2" ParentId="18633" CreationDate="2019-01-20T17:35:00.307" Score="2" Body="&lt;p&gt;Try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;q:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping needs to be active only in the command-line window, so,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CmdwinEnter * nnoremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;q:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Place in your vimrc, preferably surrounded by an &lt;code&gt;augroup/au!&lt;/code&gt; definition.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-01-20T17:35:00.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18638" PostTypeId="1" AcceptedAnswerId="18663" CreationDate="2019-01-20T17:43:09.030" Score="0" ViewCount="159" Body="&lt;p&gt;I recently made myself custom insert mode keybindings to type faster in LaTeX. However, When I use them, Vim adds tabs that weren't part of the original keybinding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my &lt;code&gt;inoremap&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd FileType tex inoremap ;t \begin{table}&amp;lt;Enter&amp;gt;\caption{}&amp;lt;Enter&amp;gt;\label{&amp;lt;++&amp;gt;}&amp;lt;Enter&amp;gt;\begin{center}&amp;lt;Enter&amp;gt;\begin{tabular}{&amp;lt;++&amp;gt;}&amp;lt;Enter&amp;gt;\toprule&amp;lt;Enter&amp;gt;&amp;lt;++&amp;gt;&amp;lt;Space&amp;gt;\\&amp;lt;Enter&amp;gt;\toprule&amp;lt;Enter&amp;gt;&amp;lt;++&amp;gt;&amp;lt;Space&amp;gt;\\&amp;lt;Enter&amp;gt;&amp;lt;++&amp;gt;&amp;lt;Space&amp;gt;\\&amp;lt;Enter&amp;gt;\bottomrule&amp;lt;Enter&amp;gt;\end{tabular}&amp;lt;Enter&amp;gt;\end{center}&amp;lt;Enter&amp;gt;\end{table}&amp;lt;Enter&amp;gt;&amp;lt;Enter&amp;gt;&amp;lt;++&amp;gt;&amp;lt;Esc&amp;gt;?caption{&amp;lt;Enter&amp;gt;8li&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the output (&lt;code&gt;&amp;lt;X&amp;gt;&lt;/code&gt; is the final location of my cursor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;             \begin{table}&#xA;             \caption{&amp;lt;X&amp;gt;}&#xA;             \label{&amp;lt;++&amp;gt;}&#xA;             \begin{center}&#xA;             \begin{tabular}{&amp;lt;++&amp;gt;}&#xA;             \toprule&#xA; &amp;lt;++&amp;gt; \\&#xA;             \toprule&#xA; &amp;lt;++&amp;gt; \\&#xA; &amp;lt;++&amp;gt; \\&#xA;             \bottomrule&#xA;             \end{tabular}&#xA;             \end{center}&#xA;             \end{table}&#xA;&#xA; &amp;lt;++&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why isn't everything lining up at the beginning of the line? (the previous lines are not indented)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;P.S.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that it would be more appropriate to use functions instead of mapping but I haven't learned them yet...&lt;/p&gt;&#xA;" OwnerUserId="20416" LastEditorUserId="1292" LastEditDate="2019-01-23T07:04:48.257" LastActivityDate="2019-01-24T11:06:14.817" Title="inoremap inserts unwanted tabs" Tags="|key-bindings|indentation|filetype-tex|snippets|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18640" PostTypeId="1" CreationDate="2019-01-20T21:06:47.207" Score="0" ViewCount="908" Body="&lt;p&gt;I have a &lt;code&gt;*.txt&lt;/code&gt; file with 10,000 lines. The lines are E-Mail and password divided by a &quot;:&quot;, so like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E-Mail:Password&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to delete the E-Mail addresses on every single line at once, so I end up with  the passwords only. How can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="20635" LastEditorUserId="2920" LastEditDate="2019-01-20T21:28:03.643" LastActivityDate="2019-01-21T05:12:07.587" Title="How can I edit multiple lines with a specific pattern?" Tags="|regular-expression|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18641" PostTypeId="2" ParentId="18640" CreationDate="2019-01-20T21:11:53.170" Score="2" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^[^:]*://&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Matches from the start of the line all not-&lt;code&gt;:&lt;/code&gt; until the first &lt;code&gt;:&lt;/code&gt; and replaces them with nothing.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-21T05:12:07.587" LastActivityDate="2019-01-21T05:12:07.587" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18642" PostTypeId="2" ParentId="18640" CreationDate="2019-01-20T21:29:21.460" Score="1" Body="&lt;p&gt;Ralf's answer is great. Here's another way you could do it as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm df:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%norm&lt;/code&gt; means type the following keys on every line. &lt;code&gt;df:&lt;/code&gt; means &lt;strong&gt;d&lt;/strong&gt;elete until your &lt;strong&gt;f&lt;/strong&gt;ind the next &lt;strong&gt;':'&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2019-01-20T21:51:02.657" LastActivityDate="2019-01-20T21:51:02.657" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18643" PostTypeId="1" AcceptedAnswerId="18644" CreationDate="2019-01-21T02:16:37.887" Score="0" ViewCount="38" Body="&lt;p&gt;Say I have the following text open in vi:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lorem Ipsum is simply dummy text [CURSOR]&#xA;of the  printing and ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The cursor position is denoted by [CURSOR]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I delete the end-of-line that follows the cursor so that the next line wraps around?&lt;/p&gt;&#xA;" OwnerUserId="20636" LastActivityDate="2019-01-21T03:32:08.623" Title="How do I delete the end-of-line to the right of my cursor?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18644" PostTypeId="2" ParentId="18643" CreationDate="2019-01-21T03:32:08.623" Score="2" Body="&lt;p&gt;In normal mode, use the &lt;code&gt;J&lt;/code&gt; command. From the Ex command line, prefer &lt;code&gt;join&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also variants, such as &lt;code&gt;gJ&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-01-21T03:32:08.623" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18645" PostTypeId="1" CreationDate="2019-01-21T09:07:56.220" Score="0" ViewCount="185" Body="&lt;p&gt;In my .vimrc file I have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre *.c :g/./ normal gqq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with text width 119 in order to hardwrap the lines before saving the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre *.c :g/./ normal gqq``zz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to move the cursor back to where it was and bring it in the centre but it seems like taking me to some arbitary location. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me with this?&lt;/p&gt;&#xA;" OwnerUserId="18443" LastActivityDate="2019-02-20T11:03:10.640" Title="Autocmd for hard wrap and going back to the previous position!" Tags="|vimrc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18646" PostTypeId="2" ParentId="18636" CreationDate="2019-01-21T10:28:07.637" Score="1" Body="&lt;p&gt;Okay, so you want that &lt;code&gt;command&lt;/code&gt; broken down? Here you go....&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; command! -range=% -nargs=0 Tab2Space&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Creates a custom command named &quot;Tab2Space&quot; that takes no arguments and operates on a range of lines which by default will be from first line to last line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        \ execute '&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;s#^\t\+#\=repeat(&quot; &quot;, len(submatch(0))*' . &amp;amp;ts . ')'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command just encompasses a regular substitution command that operates on the aforementioned range of lines (i.e. either the start and end lines specified by the caller or the entire file)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pattern to match is &lt;code&gt;^\t\+&lt;/code&gt; which is &quot;one or more tabs at the start of the line&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The substitution starts with &lt;code&gt;\=&lt;/code&gt; which means everything beyond that will be evaluated as a Vim expression and the result is what gets substituted.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;len(submatch(0))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gives us the character length of whatever was matched on the current line by the pattern. In this case it means we get a count of the number of tabs at the start of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;*&lt;/code&gt; that follows is multiplication operator and after that we look at the value of the &lt;code&gt;'ts'&lt;/code&gt; (&lt;code&gt;'tabstop'&lt;/code&gt;) setting with &lt;code&gt;&amp;amp;ts&lt;/code&gt;. So we multiply number of tabs at the beginning of the line by the number of configured spaces per tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of that is surrounded by &lt;code&gt;repeat(&quot; &quot;, ....)&lt;/code&gt; which means the substitution string is N spaces where N = (number of tabs x tabstop length)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tl;dr&lt;/strong&gt; For each line in the range of lines passed to it, the command replaces each tab at the beginning of the line with a number of spaces equal to the value stored in &lt;code&gt;'tabstop'&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It sound like you want to use this with the &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; marks...which should work just fine.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-01-21T10:28:07.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18647" PostTypeId="2" ParentId="18636" CreationDate="2019-01-21T10:31:44.517" Score="0" Body="&lt;p&gt;Have you tried &lt;code&gt;:h retab&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you have to have &lt;code&gt;set expandtab&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt; (or set manually) and just issue &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:retab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And all you tabs should be replaced with appropriate number of spaces.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-01-21T10:31:44.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18648" PostTypeId="2" ParentId="18645" CreationDate="2019-01-21T10:57:38.363" Score="1" Body="&lt;p&gt;What your command does &lt;code&gt;:g/./ normal gqq``zz&lt;/code&gt; is &quot;for each line do normal command which is format line and goto last position and recenter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you have to do is to separate &lt;code&gt;:g/../normal gqq&lt;/code&gt; command and the rest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Smth like (tested) &lt;code&gt;exe ':g/./normal gqq' | normal ``zz&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;exe&lt;/code&gt; is to execute a string as a command (&lt;code&gt;:h execute&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;|&lt;/code&gt; is to add another command to the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal&lt;/code&gt; to execute normal mode commands from command mode :)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So the end result should be (not tested)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre *.c :exe ':g/./normal gqq' | normal ``zz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-01-21T10:57:38.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18649" PostTypeId="1" AcceptedAnswerId="18652" CreationDate="2019-01-21T16:45:35.047" Score="1" ViewCount="325" Body="&lt;p&gt;When reading from stdin with something like &lt;code&gt;fancy-command | vim -R -&lt;/code&gt;, vim does not detect the &lt;code&gt;filetype&lt;/code&gt; (i.e. &lt;code&gt;set filetype&lt;/code&gt; prints &lt;code&gt;filetype=&lt;/code&gt;). When I know the right vim filetype, I can provide it from the command line (or from within vim) with &lt;code&gt;fancy-command | vim -R +'set ft=cpp' -&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, that pipe might be in a shell script e.g. in conjunction with &lt;code&gt;git show &amp;lt;commit hash&amp;gt;:&amp;lt;path&amp;gt;&lt;/code&gt;, such that I don't want to hardcode &lt;code&gt;cpp&lt;/code&gt; as filetype. I have thought about just taking the end of &lt;code&gt;&amp;lt;path&amp;gt;&lt;/code&gt; and provide it to &lt;code&gt;ft=&lt;/code&gt;, but I expect this to fail (&lt;code&gt;CMakeLists.txt&lt;/code&gt; are not identified by their suffix).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I'd like to do is run vim's &lt;code&gt;filetype detect&lt;/code&gt; but with a pretended filename when vim is actually reading from stdin.&lt;/p&gt;&#xA;" OwnerUserId="6044" LastActivityDate="2019-01-22T06:53:00.427" Title="fake a filename for filetype detection when reading from stdin" Tags="|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18650" PostTypeId="1" AcceptedAnswerId="18678" CreationDate="2019-01-21T22:09:23.993" Score="10" ViewCount="4125" Body="&lt;p&gt;netrw has a &lt;code&gt;gh&lt;/code&gt; command that toggles dotfile hiding. It is off by default. I would like it to be on by default. How do I do that?&lt;/p&gt;&#xA;" OwnerUserId="20175" LastActivityDate="2019-01-23T20:26:39.767" Title="How to make netrw start with dotfiles hidden?" Tags="|netrw|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18651" PostTypeId="2" ParentId="18650" CreationDate="2019-01-21T23:22:58.370" Score="3" Body="&lt;p&gt;You can try this on your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_list_hide = '^\..*'        &quot; or anything you like&#xA;let g:netrw_hide = 1                   &quot; hide by default&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;help netrw-a&lt;/code&gt; can give you more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-01-21T23:22:58.370" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18652" PostTypeId="2" ParentId="18649" CreationDate="2019-01-22T06:20:38.447" Score="4" Body="&lt;p&gt;You could try something like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;#!/bin/bash&#xA;&#xA;file=$1&#xA;&#xA;cat $file | vim -c &quot;doautocmd BufRead $file&quot; -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will run the autocommands that would normally run, when you would open a file with the given name. This includes filetype detection. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To my surprise, this also works when the file name contains a space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The name is only used to run the autocommands, the name of the loaded buffer is not changed (it still is &lt;code&gt;[No Name]&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-22T06:53:00.427" LastActivityDate="2019-01-22T06:53:00.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18653" PostTypeId="2" ParentId="18222" CreationDate="2019-01-22T08:11:39.863" Score="2" Body="&lt;p&gt;Find your dynamic python lib, for example &lt;code&gt;libpython3.6m.so.1.0&lt;/code&gt;. Then put it in your &lt;code&gt;.vimrc&lt;/code&gt; like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set pythonthreedll=/location/of/your/python/lib/libpython3.6m.so.1.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Of course, change the version of the library name accordingly.&lt;/p&gt;&#xA;" OwnerUserId="20653" LastEditorUserId="6350" LastEditDate="2020-09-22T13:15:33.017" LastActivityDate="2020-09-22T13:15:33.017" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18654" PostTypeId="1" CreationDate="2019-01-22T09:00:27.027" Score="0" ViewCount="78" Body="&lt;p&gt;Suppose you are trying to create a set of mappings such that pressing &lt;code&gt;&amp;lt;C-t&amp;gt;&lt;/code&gt; followed by a number &lt;code&gt;#&lt;/code&gt; would alternate to the respective tab at index &lt;code&gt;#&lt;/code&gt;. I know that using a loop, I can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Map alt-x keys to jump to a tab&#xA;for i in range(1, 9)&#xA;  execute &quot;nmap \&amp;lt;C-t&amp;gt;&quot; . i . &quot;&amp;gt; &quot; . i . &quot;gt&quot;&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Such a solution, however, hast the disadvantage of allowing only a mapping that recognizes up to 9. Is there a more general way to have a mapping depend on a count pressed &lt;strong&gt;at the end&lt;/strong&gt; of the mapping, for instance such that hitting &lt;code&gt;&amp;lt;C-t&amp;gt;14&lt;/code&gt; would focus tab number 14?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: the above is just an example, I am interested in this regardless of tabs per se.&lt;/p&gt;&#xA;" OwnerUserId="20408" LastActivityDate="2019-01-22T15:20:33.650" Title="Mappings with counts at the end without using loops?" Tags="|vimrc|key-bindings|count|map-operator|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18655" PostTypeId="1" CreationDate="2019-01-22T13:35:15.683" Score="0" ViewCount="694" Body="&lt;p&gt;I'm using &lt;code&gt;:bp&lt;/code&gt; to re-open the previous file I worked on, and &lt;code&gt;:bn&lt;/code&gt; to go back, but I'm stuck on a loop with 3 files, and I only want to loop over 2 of them. Is there a way to edit the buffer and pop the unwanted file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;sure I can use &lt;code&gt;bp&lt;/code&gt; and then &lt;code&gt;bn&lt;/code&gt; to use the same 2 files, but that wouldn't work in the general case&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Not sure which tags are relevant, and how this feature (using Ctrl+P to find files and &lt;code&gt;:bp&lt;/code&gt; and &lt;code&gt;:bn&lt;/code&gt; to go back and forth) of vim is called&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="20287" LastActivityDate="2019-01-22T15:11:43.763" Title="how to control the :bp / :bn files I loop?" Tags="|buffers|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18656" PostTypeId="2" ParentId="18655" CreationDate="2019-01-22T15:11:43.763" Score="2" Body="&lt;h3&gt;Cycling between 2 buffer&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:b #&lt;/code&gt;, &lt;code&gt;&amp;lt;c-6&amp;gt;&lt;/code&gt; , or &lt;code&gt;&amp;lt;c-^&amp;gt;&lt;/code&gt; to go between the current buffer and the alternative buffer (often the previous buffer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h alternative-file&#xA;:h :c_#&#xA;:h CTRL-6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;We can do better! or The problem with cycling buffers&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Cycling buffers is kind slow. I believe &lt;code&gt;:bprevious&lt;/code&gt; and &lt;code&gt;:bnext&lt;/code&gt; are only useful in a narrow set of conditions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;These commands become useful after you use more than 2 buffers (probably due to &lt;code&gt;&amp;lt;c-6&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;c-^&amp;gt;&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Once you hit a certain buffer number threshold, there is sort of an upper limit on the usefulness of cycling with these commands. Is it faster to cycle forward? Backwards? Does it matter because it simply takes too long either way?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Instead of cycling with &lt;code&gt;:bp&lt;/code&gt; and &lt;code&gt;:bn&lt;/code&gt; you can jump directly to a buffer via &lt;code&gt;:b&lt;/code&gt; command. Simply use &lt;code&gt;:b {partial_name}&amp;lt;tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Behold the power of &lt;code&gt;:b&lt;/code&gt;:&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Uses &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; completion&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; to list out completion&lt;/li&gt;&#xA;&lt;li&gt;Use partial file name. e.g. &lt;code&gt;:b foo&lt;/code&gt;. Works great with &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Globbing. e.g. &lt;code&gt;:b foo*bar&lt;/code&gt; or &lt;code&gt;:b foo/**/bar&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Split variant of &lt;code&gt;:b&lt;/code&gt; is &lt;code&gt;:sb&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Also accepts a buffer number&lt;/li&gt;&#xA;&lt;li&gt;A common mapping: &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :ls&amp;lt;cr&amp;gt;:b&amp;lt;space&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more help see: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :b&#xA;:h :ls&#xA;:h cmdline-completion&#xA;:h file-searching&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Can we do better than &lt;code&gt;:b&lt;/code&gt;?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Skip the buffer management completely and use tags, cscope, and/or &lt;a href=&quot;https://www.gnu.org/software/global/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GNU Global&lt;/a&gt;. These will help you go directly to where you want to go not just the right buffer with where ever you last left the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For beginners to tags I suggest &lt;a href=&quot;https://github.com/ludovicchabant/vim-gutentags&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gutentags&lt;/a&gt; and &lt;code&gt;:h tags&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;:find&lt;/code&gt; with tab completion and set your &lt;code&gt;'path'&lt;/code&gt; to &lt;code&gt;.,,**&lt;/code&gt; for a basic less fuzzy finder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h CTRL-]&#xA;:h tags&#xA;:h cscope&#xA;:h :find&#xA;:h 'path'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Plugins?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A fuzzy finder like &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;CtrlP&lt;/a&gt; or &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf&lt;/a&gt; allows for general file navigation. For more specific project navigation you can use something like &lt;a href=&quot;https://github.com/tpope/vim-projectionist&quot; rel=&quot;nofollow noreferrer&quot;&gt;Projectionist.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Conclusion&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I would suggest slowly learning more buffer and general navigation commands. These commands will serve you well and help you navigation quicker without resorting to buffer cycling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I use a combination of &lt;code&gt;:b&lt;/code&gt;, tags, cscope/GNU Global, and projectionist.vim for most of my navigation needs. I often have over 50+ buffers open and get to my desired file without ever resorting to buffer cycling.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-01-22T15:11:43.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18657" PostTypeId="2" ParentId="18654" CreationDate="2019-01-22T15:20:33.650" Score="1" Body="&lt;p&gt;The problem with having a count at the end is Vim will have to wait to see if more keys are going to be pressed. E.g. &lt;code&gt;&amp;lt;c-t&amp;gt;1&lt;/code&gt; might mean you are supplying a count of &lt;code&gt;1&lt;/code&gt; or maybe it will end up being &lt;code&gt;14&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other problem is you have to make all these mappings. So if you want to support a count up to 15, then you need 15 mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Provide a terminating sequence. e.g. &lt;code&gt;&amp;lt;c-t&amp;gt;{count}&amp;lt;c-t&amp;gt;&lt;/code&gt;. Still have to create lot of mappings, but it will allow for a &quot;count&quot;&lt;/li&gt;&#xA;&lt;li&gt;Simply use Vim's native &lt;code&gt;&amp;lt;count&amp;gt;&lt;/code&gt; which is a proceeds the map sequence. e.g. &lt;code&gt;4gt&lt;/code&gt;. This means one mapping and the count will work correctly.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Aside about tabs and buffers&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Your mappings suggest a heavy tab centric workflow. I know it might sound weird but maybe try and use less tab panes together with a more buffers centric workflow. Here are some nice posts about it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/q/26708822/438329&quot;&gt;Why do Vim experts prefer buffers over tabs?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/21338192/438329&quot;&gt;Use buffers effectively!&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-01-22T15:20:33.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18658" PostTypeId="1" AcceptedAnswerId="18659" CreationDate="2019-01-22T16:14:03.770" Score="0" ViewCount="42" Body="&lt;p&gt;I have a file with the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a=117&#xA;a=100&#xA;a=101&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try searching using &lt;code&gt;/a=10*&lt;/code&gt;, it correctly matches all of those lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I try searching using &lt;code&gt;/a=10+&lt;/code&gt;, it does not match any of those lines, even though it should match the last 2 lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why doesn't the + regular expression quantifier work when searching?&lt;/p&gt;&#xA;" OwnerUserId="334" LastActivityDate="2019-01-22T16:19:22.880" Title="Why doesn't the + regular expression quantifier (one or more) work when searching?" Tags="|regular-expression|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18659" PostTypeId="2" ParentId="18658" CreationDate="2019-01-22T16:19:22.880" Score="3" Body="&lt;p&gt;In Vim you need a backslash before the &lt;code&gt;+&lt;/code&gt;. So the following works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/a=10\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-22T16:19:22.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18660" PostTypeId="1" CreationDate="2019-01-22T16:35:44.307" Score="8" ViewCount="481" Body="&lt;p&gt;I want to set gVim font size for &lt;code&gt;Comment&lt;/code&gt; highlight group. When I set it, it does not do anything (the font is still the same but color changes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.gvimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;se guifont=Fira\ Mono\ Regular\ 10&#xA;hi Comment guibg=#ff0000 font='Liberation Mono Regular 10'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20657" LastEditorUserId="20657" LastEditDate="2019-01-22T16:59:50.737" LastActivityDate="2019-01-22T16:59:50.737" Title="gVim - Use different fonts using :highlight" Tags="|syntax-highlighting|gvim|font|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18661" PostTypeId="2" ParentId="10828" CreationDate="2019-01-22T16:56:15.960" Score="1" Body="&lt;p&gt;Simply pressing &lt;kbd&gt;Shift&lt;/kbd&gt; &lt;kbd&gt;+&lt;/kbd&gt; &lt;kbd&gt;}&lt;/kbd&gt; will take to next empty line without any text selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;kbd&gt;Sift&lt;/kbd&gt; &lt;kbd&gt;+&lt;/kbd&gt; &lt;kbd&gt;v&lt;/kbd&gt; &lt;kbd&gt;+&lt;/kbd&gt; &lt;kbd&gt;}&lt;/kbd&gt;, vim selects the text from current cursor position to next empty line and you have to Press &lt;kbd&gt;ESC&lt;/kbd&gt; to exit from selection mode&lt;/p&gt;&#xA;" OwnerUserId="20658" LastEditorUserId="20658" LastEditDate="2019-01-22T20:26:02.727" LastActivityDate="2019-01-22T20:26:02.727" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18663" PostTypeId="2" ParentId="18638" CreationDate="2019-01-22T19:31:39.060" Score="0" Body="&lt;h3&gt;Snippet plugin instead of a simple &lt;code&gt;inoremap&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you are interested in features like jumping from one placeholder to another one, you might be interested in using a plugin.&#xA;There are many options you can choose from. There are a few dedicated to LaTeX:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/vim-latex/vim-latex&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;vim-latex&lt;/strong&gt;&lt;/a&gt; (details in section &lt;a href=&quot;http://vim-latex.sourceforge.net/documentation/latex-suite/ls-new-macros.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;3.12&lt;/a&gt; and &lt;a href=&quot;https://github.com/vim-latex/vim-latex/blob/master/plugin/imaps.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;plugin/imaps.vim&lt;/code&gt;&lt;/a&gt;)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also install only &lt;code&gt;plugin/imaps.vim&lt;/code&gt; with&lt;br&gt;&#xA;&lt;code&gt;$ wget https://raw.githubusercontent.com/vim-latex/vim-latex/master/plugin/imaps.vim -O ~/.vim/plugin/imaps.vim&lt;/code&gt;&lt;br&gt;&#xA;and then define in &lt;code&gt;~/.vim/after/ftplugin/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call IMAP('ETE', &quot;\\begin{table}\&amp;lt;CR&amp;gt;\\caption{&amp;lt;++&amp;gt;}\&amp;lt;CR&amp;gt;\\label{&amp;lt;++&amp;gt;}\&amp;lt;CR&amp;gt;\\begin{center}\&amp;lt;CR&amp;gt;\\begin{tabular}{&amp;lt;++&amp;gt;}\&amp;lt;CR&amp;gt;\\toprule\&amp;lt;CR&amp;gt;&amp;lt;++&amp;gt;&amp;lt;Space&amp;gt;\\\\\&amp;lt;CR&amp;gt;\\toprule\&amp;lt;CR&amp;gt;&amp;lt;++&amp;gt;&amp;lt;Space&amp;gt;\\\\\&amp;lt;CR&amp;gt;&amp;lt;++&amp;gt;&amp;lt;Space&amp;gt;\\\\\&amp;lt;CR&amp;gt;\\bottomrule\&amp;lt;CR&amp;gt;\\end{tabular}\&amp;lt;CR&amp;gt;\\end{center}\&amp;lt;CR&amp;gt;\\end{table}\&amp;lt;CR&amp;gt;\&amp;lt;CR&amp;gt;&amp;lt;++&amp;gt;&quot;, 'tex')&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://wolfgangmehner.github.io/vim-plugins/latexsupport.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;latex-support&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/brennier/quicktex&quot; rel=&quot;nofollow noreferrer&quot;&gt;quicktex&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There are also a few plugins which provide a fixed set of snippets for LaTeX (however, you can always modify the source code):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=162&quot; rel=&quot;nofollow noreferrer&quot;&gt;auctex.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1269&quot; rel=&quot;nofollow noreferrer&quot;&gt;drcstubs&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#TEXMAPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;texmaps&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I personally prefer a general plugin such as&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Ultisnips&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/garbas/vim-snipmate&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;snipmate&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Shougo/neosnippet.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;neosnippet&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Your insert mode mapping as a ultisnips snippet (e.g. placed in &lt;code&gt;~/.vim/UltiSnips/tex.snippets&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet table &quot;Table &amp;amp; Tabular&quot;&#xA;\begin{table}&#xA;  \caption{${1:&amp;lt;+Caption text+&amp;gt;}}&#xA;  \label{tab:${2:&amp;lt;+label+&amp;gt;}}&#xA;  \centering&#xA;  \begin{tabular}{${3:&amp;lt;+dimensions+&amp;gt;}}&#xA;    \toprule&#xA;    $4 \\&#xA;    \toprule&#xA;    ${5:${VISUAL}} \\&#xA;    \bottomrule&#xA;  \end{tabular}&#xA;\end{table}$0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A more advanced snippet request is the question &lt;a href=&quot;https://vi.stackexchange.com/questions/17439/easiest-way-to-insert-latex-matrix&quot;&gt;Easiest way to insert LaTeX matrix?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You find also similar ones predefined in snippet collections such as&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/honza/vim-snippets/blob/87dd0531825ad90539a49d3e73e44f90fcb5a0f7/UltiSnips/tex.snippets#L73-L82&quot; rel=&quot;nofollow noreferrer&quot;&gt;honza/vim-snippets/UltiSnips/tex.snippets&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Shougo/neosnippet-snippets/blob/3169f157e76f1140790721604658f031f9283741/neosnippets/tex.snip#L108-L117&quot; rel=&quot;nofollow noreferrer&quot;&gt;Shougo/neosnippet-snippets/neosnippets/tex.snip&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The question &lt;a href=&quot;https://vi.stackexchange.com/questions/7466/what-is-the-difference-between-the-vim-snippets-plugins&quot;&gt;What is the difference between the vim snippets plugins?&lt;/a&gt; could also be interesting to compare the different options.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-01-24T11:06:14.817" LastActivityDate="2019-01-24T11:06:14.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18664" PostTypeId="1" AcceptedAnswerId="18665" CreationDate="2019-01-22T21:41:17.703" Score="0" ViewCount="76" Body="&lt;p&gt;I have a huge text file with Roman numbers for the paragraphs and I want to substitute them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text text ... text&#xA;&#xA;I&#xA;&#xA;text ...&#xA;&#xA;II&#xA;&#xA;and so on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is: what regular expression describes one Roman number per line? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other hand this one &lt;code&gt;/^\vM{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$&lt;/code&gt; seems to be ok, except that it includes all blank lines.&#xA;How refactor it in a way to exclude the empty lines?&lt;/p&gt;&#xA;" OwnerUserId="9633" LastActivityDate="2019-01-22T22:39:08.683" Title="Looking to substitute roman numbers" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18665" PostTypeId="2" ParentId="18664" CreationDate="2019-01-22T22:22:36.323" Score="1" Body="&lt;p&gt;You can use a look-behind assertion to check the length of the matched string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$.@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.&lt;/code&gt; means match any one character (i.e., zero characters will not work).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;@&amp;lt;=&lt;/code&gt; means look behind and accept only if the preceding atom (i.e., &lt;code&gt;.&lt;/code&gt;) matches text immediately before this position in text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This assertion will fail if the line is empty.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2019-01-22T22:39:08.683" LastActivityDate="2019-01-22T22:39:08.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18666" PostTypeId="1" AcceptedAnswerId="18675" CreationDate="2019-01-23T04:26:04.067" Score="0" ViewCount="479" Body="&lt;p&gt;When launching an internal Vim 8.1 terminal for an exclusive program like in &lt;code&gt;terminal ++close ipython&lt;/code&gt;, is there a way to identify from vimscript which is the PID of the launched process (i.e. of the IPython launched) so I can use that information?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Retrieving that upon launching and after that are both of interest to me, in case they happen to differ.&lt;/p&gt;&#xA;" OwnerUserId="20492" LastEditorUserId="20492" LastEditDate="2019-01-23T07:28:49.393" LastActivityDate="2019-01-23T15:21:37.927" Title="Identifying the PID of Vim 8.1 internal terminal launched with :terminal ++close" Tags="|vimrc|terminal-buffer|linux-ubuntu|shell|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18667" PostTypeId="1" AcceptedAnswerId="18709" CreationDate="2019-01-23T06:27:38.273" Score="2" ViewCount="369" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bypr2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bypr2.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;I'm not sure if it is duplicated or not, I tried to find Google also in here but cannot find the correct answer.&lt;/p&gt;&#xA;&lt;p&gt;I do not know why it shows &lt;code&gt;{language}&lt;/code&gt; next to the file &lt;code&gt;languages.js&lt;/code&gt;, as I use almost the same vimrc on my Ubuntu, and it does not show over there.&lt;/p&gt;&#xA;&lt;p&gt;List of my plugins, in Vundle:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'epmatsw/ag.vim'&#xA;Plugin 'mileszs/ack.vim'&#xA;Plugin 'ascenator/L9', {'name': 'newL9'}&#xA;Plugin 'drewtempelmeyer/palenight.vim'&#xA;Plugin 'rakr/vim-one'&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;Plugin 'sangdth/vue-element-snippets'&#xA;Plugin 'sangdth/tapilu-snippets'&#xA;Plugin 'fatih/vim-go'&#xA;Plugin 'posva/vim-vue'&#xA;Plugin 'pangloss/vim-javascript'&#xA;Plugin 'leafgarland/typescript-vim'&#xA;Plugin 'flazz/vim-colorschemes'&#xA;Plugin 'editorconfig/editorconfig-vim'&#xA;Plugin 'w0rp/ale'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'tiagofumo/vim-nerdtree-syntax-highlight'&#xA;Plugin 'SirVer/ultisnips'&#xA;Plugin 'honza/vim-snippets'&#xA;Plugin 'Valloric/YouCompleteMe'&#xA;Plugin 'ryanoasis/vim-devicons'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="19109" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-01-26T19:21:40.263" Title="Weird extra text after my file name in nerdtree {language}" Tags="|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18668" PostTypeId="1" AcceptedAnswerId="18672" CreationDate="2019-01-23T09:28:49.943" Score="10" ViewCount="1723" Body="&lt;p&gt;I've upgraded vim and now it's unhappy about some UTF-8 values in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This lead me to the question -- when vim reads &lt;code&gt;.vimrc&lt;/code&gt;, what encoding does it assume the file has? I.e. what's &lt;code&gt;fileencoding&lt;/code&gt; then?&lt;/p&gt;&#xA;" OwnerDisplayName="user20236" LastActivityDate="2024-02-27T21:29:31.500" Title="What is fileencoding of .vimrc?" Tags="|vimrc|encoding|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18670" PostTypeId="1" CreationDate="2019-01-23T11:51:39.963" Score="0" ViewCount="66" Body="&lt;p&gt;I built vim from source on Arch Linux and the help system is not present. I do not see any help-related options when I do vim --version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume it is either broken somehow or not installed. How can I fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Please don't tell me to reinstall it. Building it is a huge pain in the ass, and I do not want to repeat that process.)&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2019-01-23T11:51:39.963" Title="install / repair help system" Tags="|help-system|installing|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="18671" PostTypeId="1" CreationDate="2019-01-23T12:23:33.190" Score="0" ViewCount="428" Body="&lt;p&gt;I found that using the &lt;code&gt;:pwd&lt;/code&gt; command is the same as using the &lt;code&gt;:echo getcwd()&lt;/code&gt; command in the commandline mode of vim. Is pwd the same as cwd? Is there a difference between the two? As follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently in the directtory： &lt;code&gt;/tmp/xyz&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ pwd&#xA;/tmp/xyz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;/tmp/xyz&lt;/code&gt; directory structure :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ find /tmp/xyz&#xA;/tmp/xyz&#xA;/tmp/xyz/dir1&#xA;/tmp/xyz/dir1/file1&#xA;/tmp/xyz/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I open &lt;code&gt;/tmp/xyz/file&lt;/code&gt; file via vim in &lt;code&gt;/tmp/xyz&lt;/code&gt; directory：&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim /tmp/xyz/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I execute  &lt;code&gt;:pwd&lt;/code&gt; command in the vim window that i just opened:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:pwd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result is : &lt;code&gt;/tmp/xyz&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then to execute   &lt;code&gt;:echo getcwd()&lt;/code&gt; command ：&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo getcwd()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result is： &lt;code&gt;/tmp/xyz&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this time, it seems that pwd and cwd are the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then i use the same vim window  to open &lt;code&gt;/tmp/xyz/dir1/file1&lt;/code&gt; ,and to execoute &lt;code&gt;:pwd&lt;/code&gt; and &lt;code&gt;:echo getcwd()&lt;/code&gt; commands :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To open &lt;code&gt;/tmp/xyz/dir1/file1&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e /tmp/xyz/dir1/file1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To execute :pwd ：&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   :pwd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result is： &lt;code&gt;/tmp/xyz&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To execute :echo getcwd() :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  :echo getcwd()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result is still ： &lt;code&gt;/tmp/xyz&lt;/code&gt; ; why is the result here not &lt;code&gt;/tmp/xyz/dir1/&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is the value of pwd and cwd the same regardless of which file is opened?&lt;/p&gt;&#xA;" OwnerUserId="20589" LastActivityDate="2019-01-23T15:04:20.040" Title="why are the results of the pwd command and the getcwd() function the same in vim？" Tags="|original-vim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18672" PostTypeId="2" ParentId="18668" CreationDate="2019-01-23T14:00:45.707" Score="7" Body="&lt;p&gt;It is whatever you define with &lt;code&gt;:scriptencoding&lt;/code&gt;. It should be the first line in you &lt;code&gt;.vimrc&lt;/code&gt; file, e.g.:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;scriptencoding utf-8&#xA;&#xA;set number&#xA;set ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, as per the Help for &lt;code&gt;:scriptencoding&lt;/code&gt;, if you set the 'encoding' option in your vimrc, &lt;code&gt;:scriptencoding&lt;/code&gt; must be placed after that.&lt;/p&gt;&#xA;&lt;p&gt;Be aware that some options (&lt;code&gt;listchars&lt;/code&gt; for example) only accept single width values.&lt;/p&gt;&#xA;&lt;p&gt;Edit: Yeah, Vim is weird. &lt;code&gt;encoding&lt;/code&gt; is for the editor itself, &lt;code&gt;fileencoding&lt;/code&gt; is for the buffer and &lt;code&gt;scriptencoding&lt;/code&gt; is for Vim scripts.&lt;/p&gt;&#xA;" OwnerUserId="786" LastEditorUserId="21188" LastEditDate="2024-02-27T21:29:31.500" LastActivityDate="2024-02-27T21:29:31.500" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18673" PostTypeId="2" ParentId="18671" CreationDate="2019-01-23T14:20:51.727" Score="1" Body="&lt;p&gt;Yup, they are the same (but &lt;code&gt;getcwd()&lt;/code&gt; can accepts some arguments so it is useful for Vim scripting), both return the current &lt;strong&gt;working directory&lt;/strong&gt;. By default it is the directory where you executed Vim. To change it you need to execute &lt;code&gt;:cd&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="786" LastEditorUserId="19763" LastEditDate="2019-01-23T15:04:20.040" LastActivityDate="2019-01-23T15:04:20.040" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18674" PostTypeId="1" CreationDate="2019-01-23T14:36:26.640" Score="1" ViewCount="72" Body="&lt;p&gt;I've started to write my first vim plugin, a simple timer. I want to be able to set a timer for an arbitrary amount of time, and have it notify me once that time has passed. I've got it all working, but right now, I'm using &lt;code&gt;echom&lt;/code&gt; (or &lt;code&gt;echoerr&lt;/code&gt;) to display a message like &lt;em&gt;&quot;timer expired&quot;&lt;/em&gt;. What I want to do is draw some more attention to the fact that the timer has expired, either by using quickfix or the preview window. I've looked around, and short of arbitrarily setting an error string and using &lt;code&gt;setqflist&lt;/code&gt;, I can't really think of anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something I'd also be happy with is the statusline flashing up or something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would the more experienced vimscript ninja go about this? Ideally, I'd have something flash, so it draws attention. I'll do some more digging on how I can do that, but in case someone can point me in the right direction, that'd be greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to give you an idea of where I stand in terms of ability: I've been using vim as my main/only editor for about 3 years now. Using vim is not an issue at all. Configuring isn't a problem, either. When it comes to writing plugins, this is my first real attempt. This is what I've written thusfar:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:timer_callback = get(g:, 'etimer_callback', 'NotifyTimer')&#xA;&#xA;let s:factors = {&#xA;            \&quot;ms&quot;: 1,&#xA;            \&quot;s&quot;: 1000,&#xA;            \&quot;m&quot;: 60 * 1000,&#xA;            \&quot;h&quot;: 60 * 60 * 1000,&#xA;            \}&#xA;let s:active_timers = {}&#xA;&#xA;function NotifyTimer(timer_id)&#xA;    let l:timer_interval = remove(s:active_timers, a:timer_id)&#xA;    call timer_stop(a:timer_id)&#xA;    echom printf(&quot;Timer %d (%s) expired!&quot;, a:timer_id, l:timer_interval)&#xA;endfunction&#xA;&#xA;function! s:start_timer(i)&#xA;    let l:interval = s:parse_interval(a:i)&#xA;    if l:interval == -1&#xA;        return -1&#xA;    endif&#xA;    let l:timer = timer_start(l:interval, s:timer_callback)&#xA;    let s:active_timers[l:timer] = a:i&#xA;    echo printf(&quot;Timer %d set&quot;, l:timer)&#xA;endfunction&#xA;&#xA;function s:parse_interval(i)&#xA;    if a:i!~#&quot;[smh]$&quot;&#xA;        echoerr printf(&quot;Invalid interval %s, expected format \d+(ms|s|m|h)$&quot;, a:i)&#xA;        return -1&#xA;    endif&#xA;    let l:len = strlen(trim(a:i))&#xA;    let l:unit_idx = 1&#xA;    if a:i=~#&quot;ms$&quot;&#xA;        let l:unit_idx = 2&#xA;    endif&#xA;    let l:split_idx = l:len - l:unit_idx&#xA;    let l:unit = strpart(a:i, l:split_idx, l:unit_idx)&#xA;    let l:interval = str2nr(strpart(a:i, 0, l:split_idx))&#xA;    let l:interval = l:interval * get(s:factors, l:unit, 1)&#xA;    return l:interval&#xA;endfunction&#xA;&#xA;function s:list_timers()&#xA;    for key in keys(s:active_timers)&#xA;        echo printf(&quot;%d -&amp;gt; %s&quot;, key, s:active_timers[key])&#xA;    endfor&#xA;endfunction&#xA;&#xA;function s:cancel_timers()&#xA;    let s:active_timers = {}&#xA;    call timer_stopall()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Begin a golang dev, I'm really annoyed by the use of a global dictionary. Can't imagine that being safe. I know vim is mostly single threaded when it comes to its scripts, but can't hurt mentioning that concern, and see if it's something I should work on.&lt;/p&gt;&#xA;" OwnerUserId="10747" LastEditorUserId="10747" LastEditDate="2019-01-23T15:40:48.563" LastActivityDate="2019-01-23T15:40:48.563" Title="How to write to a temproary buffer in a plugin" Tags="|vimscript|plugin-system|statusline|quickfix|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18675" PostTypeId="2" ParentId="18666" CreationDate="2019-01-23T15:21:37.927" Score="1" Body="&lt;p&gt;You can use the term_getjob() function to get the Job associated&#xA;with a terminal. You can then use the job_info() function to query the&#xA;&quot;process&quot; attribute of the job.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let job = term_getjob(5)&#xA;echo job_info(job).process&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20673" LastActivityDate="2019-01-23T15:21:37.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18677" PostTypeId="2" ParentId="18668" CreationDate="2019-01-23T18:52:57.397" Score="1" Body="&lt;p&gt;As hinted at in the help files (&lt;code&gt;:help scriptencoding&lt;/code&gt;), if you do not use &lt;code&gt;scriptencoding&lt;/code&gt;, vim does no conversion, effectively assuming the script is in the encoding of the &lt;code&gt;'encoding'&lt;/code&gt; option.  This is very often &lt;code&gt;utf-8&lt;/code&gt;, occasionally &lt;code&gt;latin1&lt;/code&gt;.  Other encodings are possible.  Generally you want to use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;scriptencoding utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when your script file contains non-ascii characters and is encoding in utf-8.  If you use only 7-bit ascii characters, it is unnecessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'fileencoding'&lt;/code&gt; applies to the current buffer, not scripts.  When opening a file, vim tries to guess the encoding from the option &lt;code&gt;'fileencodings'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-01-23T18:52:57.397" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18678" PostTypeId="2" ParentId="18650" CreationDate="2019-01-23T19:59:14.597" Score="13" Body="&lt;p&gt;&lt;code&gt;gh&lt;/code&gt; works by modifying &lt;code&gt;netrw_list_hide&lt;/code&gt;, rather than by toggling a separate flag. It appends or removes the regex &lt;code&gt;\(^\|\s\s\)\zs\.\S\+&lt;/code&gt;. As far as I can tell, said regex matches &quot;a dot followed by any number of non-whitespace characters, starting either at the beginning of the string or after two spaces.&quot; I'm not sure why the two spaces, but would be interested to know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding it yourself is straightforward enough:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; If you don't have a hide list and just want to use gh's:&#xA;let ghregex='\(^\|\s\s\)\zs\.\S\+'&#xA;let g:netrw_list_hide=ghregex&#xA;&#xA;&quot; Or, if you already have a usual hide list, append it&#xA;let g:netrw_list_hide='yourhidelist'&#xA;let g:netrw_list_hide.=',' . ghregex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In both cases vim will then recognize that &lt;code&gt;gh&lt;/code&gt; is toggled on, and typing &lt;code&gt;gh&lt;/code&gt; will turn it off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regex &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/autoload/netrw.vim#L5477&quot; rel=&quot;noreferrer&quot;&gt;is hardcoded&lt;/a&gt; and not available as a variable (unless your make one yourself, as above), so in principle this will break if it changes. That line hasn't been touched in eleven years, though. It's probably pretty safe to rely on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(credit to &lt;a href=&quot;https://vi.stackexchange.com/a/18651/20175&quot;&gt;this answer&lt;/a&gt; for pointing me in the right direction)&lt;/p&gt;&#xA;" OwnerUserId="20175" LastEditorUserId="20175" LastEditDate="2019-01-23T20:26:39.767" LastActivityDate="2019-01-23T20:26:39.767" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18679" PostTypeId="1" AcceptedAnswerId="18690" CreationDate="2019-01-23T22:43:33.870" Score="14" ViewCount="2208" Body="&lt;p&gt;If someone is editing the following javascript file:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code&gt;let foo = true&#xA;if (foo) {&#xA;  let bar = 42&#xA;  // moooooore code...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;vi{&lt;/code&gt; anywhere on the line with &lt;code&gt;let bar&lt;/code&gt; to select &lt;code&gt;let bar = 42&lt;/code&gt; and all other lines inside &lt;code&gt;{...}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, how can I select based on indentation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's take Ruby as an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def some_method&#xA;  if @foo&#xA;    @bar = 42&#xA;    # moooooore code...&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What command would I use to select &lt;code&gt;@bar = 42&lt;/code&gt; and all other code ?&lt;/p&gt;&#xA;" OwnerUserId="10518" LastEditorUserId="1292" LastEditDate="2019-01-24T12:45:56.677" LastActivityDate="2019-01-24T14:30:49.367" Title="How to visually select based on indentation?" Tags="|indentation|visual-mode|custom-text-object|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18680" PostTypeId="1" CreationDate="2019-01-23T23:18:53.147" Score="0" ViewCount="58" Body="&lt;p&gt;Suppose that using &lt;code&gt;bufwinnr()&lt;/code&gt; I find the windows number where a given buffer is being displayed to be &lt;code&gt;2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that information, is there a way to display a specific string only in the &lt;code&gt;airline&lt;/code&gt; status bar of that window, this is, of window &lt;code&gt;2&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be more specific, of course I did find examples of how to define airline parts for custom functions (see &lt;a href=&quot;https://vi.stackexchange.com/questions/15698/add-custom-section-to-airline&quot;&gt;Add custom section to airline&lt;/a&gt;). However, what I could not do yet is to find how:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) define an airline part for a constant string (for example stored in a dictionary). While the possibility of creating a part with a constant string is mentioned in &lt;code&gt;:h airline-advanced-customization&lt;/code&gt;, there's no example of that and I can't seem find it easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) I can't seem to find what would be the proper way to display specific strings in each window airline, according to the window number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help or resource will be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="20408" LastActivityDate="2019-01-23T23:18:53.147" Title="Displaying specific text only in the airline of a given window" Tags="|vimrc|vim-windows|plugin-airline|linux-ubuntu|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18681" PostTypeId="1" CreationDate="2019-01-24T00:30:51.243" Score="2" ViewCount="52" Body="&lt;p&gt;I am considering using Vim's &lt;code&gt;auto-format&lt;/code&gt; feature (i.e., adding &lt;code&gt;a&lt;/code&gt; to &lt;code&gt;formatoptions&lt;/code&gt;).  However, I can't seem to figure out a combination of options that will give me the configuration that I want.  For reference, I am using Vim 8.1 (from May 18, 2018).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mainly use Vim for coding, and obviously I only want to automatically format comments.  When writing comments alone, then &lt;code&gt;formatoptions=acoqr&lt;/code&gt; seems to give me exactly what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For code, I also want Vim to force me to break a line after &lt;code&gt;textwidth&lt;/code&gt; has been reached, but I do not want it to reformat whole paragraphs when lines are edited.  Using &lt;code&gt;formatoptions=t&lt;/code&gt; seems to give me the behavior that I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I try to combine the two, with &lt;code&gt;formatoptions=acoqrt&lt;/code&gt;, then Vim starts to reformat whole blocks of code as well as comments.  This seems to contradict the information in &lt;code&gt;:help fo-table&lt;/code&gt;, which states:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a       Automatic formatting of paragraphs.  Every time text is inserted or&#xA;        deleted the paragraph will be reformatted.  See |auto-format|.&#xA;        When the 'c' flag is present this only happens for recognized&#xA;        comments.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, I would expect that since I am including &lt;code&gt;c&lt;/code&gt; in &lt;code&gt;formatoptions&lt;/code&gt;, then the auto-formatting behavior should apply to comments, and the ordinary &lt;code&gt;t&lt;/code&gt; behavior (inserting newlines but not reformatting whole paragraphs) should apply to code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something?  Is this a bug?  If so, is there a workaround?&lt;/p&gt;&#xA;" OwnerUserId="20679" LastActivityDate="2019-01-24T00:30:51.243" Title="Applying full auto-format to comments but not code" Tags="|formatting|comments|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18682" PostTypeId="1" AcceptedAnswerId="18683" CreationDate="2019-01-24T03:32:13.643" Score="1" ViewCount="33" Body="&lt;p&gt;Directly on the Ubuntu terminal, I can extract the results from &lt;code&gt;top&lt;/code&gt; regarding a specific PID with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;top -p &amp;lt;pid&amp;gt; -n1 | awk '/&amp;lt;pid&amp;gt;/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;&amp;lt;pid&amp;gt;&lt;/code&gt; should be substituted with a PID number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I am inside gVim 8.1, I try doing the same with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call system(&quot;top -p &amp;lt;pid&amp;gt; -n1 | awk '\/&amp;lt;pid&amp;gt;\/'&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use the backslashes to make the forward-slashes be interpreted correctly as the &lt;code&gt;/&lt;/code&gt; character. However, to my surprise, I get the error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;TERM environment variable not set&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I found that to be odd, since things like &lt;code&gt;:call system(&quot;ps&quot;)&lt;/code&gt; work perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I try the same in terminal Vim 8.1, I get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;top: failed tty get^@&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But again all sorts of variations of &lt;code&gt;:call system(&quot;ps&quot;)&lt;/code&gt; work well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why would that be the case and how could I make it work such that I retrieve the results of &lt;code&gt;system(&quot;top -p &amp;lt;pid&amp;gt; -n1 | awk '\/&amp;lt;pid&amp;gt;\/'&quot;)&lt;/code&gt; inside a variable like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let myvariable = system(&quot;top -p &amp;lt;pid&amp;gt; -n1 | awk '\/&amp;lt;pid&amp;gt;\/'&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20681" LastActivityDate="2019-01-24T06:03:45.860" Title="Retrieving results from variations of system('top') returns errors" Tags="|gvim|terminal|external-command|shell|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18683" PostTypeId="2" ParentId="18682" CreationDate="2019-01-24T05:23:37.790" Score="0" Body="&lt;p&gt;&lt;code&gt;top&lt;/code&gt; is a interactive program, so I'm not surprised it has problems when called in a non interactive shell without a terminal. Loosely speaking this is like&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;$ top -p 7783 -n1 &amp;lt;/dev/null | awk &quot;/7783/&quot;&#xA;top: failed tty get&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use &lt;code&gt;top&lt;/code&gt; like you want, add the option &lt;code&gt;-b&lt;/code&gt; for &quot;batch mode&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the man page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;-b&lt;/strong&gt; Batch-mode operation &lt;br&gt; &#xA;  Starts top in Batch mode, which could be useful  for  sending&#xA;  output  from  top  to  other  programs or to a file.  In this&#xA;  mode, top will not accept input and runs until the iterations&#xA;  limit  you've  set with the `-n' command-line option or until&#xA;  killed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-24T06:03:45.860" LastActivityDate="2019-01-24T06:03:45.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18684" PostTypeId="1" CreationDate="2019-01-24T05:59:18.767" Score="0" ViewCount="226" Body="&lt;p&gt;When I use a command like &lt;code&gt;vim -s script *.cfg&lt;/code&gt; it stops at the end of first file stating that there are x files left to edit and not executing the script in the remaining matching files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;script&lt;/code&gt; contains commands to format files and works when passing single file as argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the correct format to include all files with similar name and edit with same script file?&lt;/p&gt;&#xA;" OwnerUserId="20683" LastEditorUserId="51" LastEditDate="2019-01-28T05:46:40.440" LastActivityDate="2019-01-28T05:46:40.440" Title="How to edit multiple files with same scriptin/scriptout using vim" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18685" PostTypeId="1" AcceptedAnswerId="18692" CreationDate="2019-01-24T07:40:18.980" Score="1" ViewCount="5080" Body="&lt;p&gt;Input&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(statement)&#xA;{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to Ouput&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( statement ) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can find the input using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/if(\S\(.*\))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if( is the keyword to be searched , \S to negate whitespace , (.*) for anything in between and ) end bracket.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Need :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trying to automate coding guideline over code written w/o coding guideline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/if(\S\(.*\)\S)/if ( \1 )/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Came very close but it removes the first character after the 'if(' and last char before ')'&lt;/p&gt;&#xA;" OwnerUserId="18443" LastEditorUserId="18443" LastEditDate="2019-01-24T08:56:42.060" LastActivityDate="2019-01-24T15:32:50.517" Title="How to search and replace this using vim and regex?" Tags="|search|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18686" PostTypeId="2" ParentId="7758" CreationDate="2019-01-24T09:20:18.000" Score="4" Body="&lt;h2&gt;Plugin &lt;a href=&quot;https://github.com/jeetsukumaran/vim-indentwise&quot; rel=&quot;nofollow noreferrer&quot;&gt;indentwise&lt;/a&gt; by jeetsukumaran&lt;/h2&gt;&#xA;&#xA;&lt;h3&gt;Movements by Relative Indent-Depth&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[-&lt;/code&gt;  : Move to &lt;em&gt;previous&lt;/em&gt; line of &lt;em&gt;lesser&lt;/em&gt; indent than the current line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[+&lt;/code&gt;  : Move to &lt;em&gt;previous&lt;/em&gt; line of &lt;em&gt;greater&lt;/em&gt; indent than the current line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[=&lt;/code&gt;  : Move to &lt;em&gt;previous&lt;/em&gt; line of &lt;em&gt;same&lt;/em&gt; indent as the current line that&#xA;      is separated from the current line by lines of different indents.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;]-&lt;/code&gt;  : Move to &lt;em&gt;next&lt;/em&gt; line of &lt;em&gt;lesser&lt;/em&gt; indent than the current line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;]+&lt;/code&gt;  : Move to &lt;em&gt;next&lt;/em&gt; line of &lt;em&gt;greater&lt;/em&gt; indent than the current line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;]=&lt;/code&gt;  : Move to &lt;em&gt;next&lt;/em&gt; line of &lt;em&gt;same&lt;/em&gt; indent as the current line that&#xA;      is separated from the current line by lines of different indents.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Movements by Absolute Indent-Levels&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;{count}[_&lt;/code&gt;  : Move to &lt;em&gt;previous&lt;/em&gt; line with indent-level of &lt;code&gt;{count}&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;{count}]_&lt;/code&gt;  : Move to &lt;em&gt;next&lt;/em&gt; line with indent-level of &lt;code&gt;{count}&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Movements by Indent-Block Scope&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[%&lt;/code&gt;  : Move to beginning of indent-block scope (i.e., move to the&#xA;      line just after the previous line of lesser indent); repeat&#xA;      for &lt;code&gt;{count}&lt;/code&gt; outer scopes.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;]%&lt;/code&gt;  : Move to end of indent-block scope (i.e., move to the line&#xA;      just before the next line of lesser indent); repeat&#xA;      for &lt;code&gt;{count}&lt;/code&gt; outer scopes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;a href=&quot;https://github.com/vim/vim/tree/master/runtime/pack/dist/opt/matchit&quot; rel=&quot;nofollow noreferrer&quot;&gt;matchit's&lt;/a&gt; (&lt;a href=&quot;https://github.com/andymass/vim-matchup&quot; rel=&quot;nofollow noreferrer&quot;&gt;matchup&lt;/a&gt;) &lt;code&gt;[%&lt;/code&gt; and &lt;code&gt;]%&lt;/code&gt;, you have to pick different ones (&lt;a href=&quot;https://github.com/jeetsukumaran/vim-indentwise/issues/6&quot; rel=&quot;nofollow noreferrer&quot;&gt;#issue 6&lt;/a&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Remarks&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;This question is possibly a duplicate of &lt;a href=&quot;https://vi.stackexchange.com/questions/120/how-do-i-move-vertically-until-reaching-a-non-whitespace-character&quot;&gt;How do I move vertically until reaching a non-whitespace character?&lt;/a&gt;&#xA;similar as the question &lt;a href=&quot;https://vi.stackexchange.com/questions/8719/structural-navigation-by-indentation-level&quot;&gt;Structural navigation by indentation level&lt;/a&gt;.&lt;br&gt;&#xA;However, I would like to emphasize that the idea is about navigating based on different indentation levels which is not the focus of the title &lt;a href=&quot;https://vi.stackexchange.com/questions/120/how-do-i-move-vertically-until-reaching-a-non-whitespace-character&quot;&gt;How do I move vertically until reaching a non-whitespace character?&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;see also wiki page &lt;a href=&quot;http://vim.wikia.com/wiki/Move_to_next/previous_line_with_same_indentation&quot; rel=&quot;nofollow noreferrer&quot;&gt;'Move to next/previous line with same indentation'&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Futher related plugins are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tmhedberg/indent-motion&quot; rel=&quot;nofollow noreferrer&quot;&gt;tmhedberg/indent-motion&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/inkarkat/vim-JumpToVerticalOccurrence&quot; rel=&quot;nofollow noreferrer&quot;&gt;inkarkat/vim-JumpToVerticalOccurrence&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/michaeljsmith/vim-indent-object&quot; rel=&quot;nofollow noreferrer&quot;&gt;michaeljsmith/vim-indent-object&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/qstrahl/vim-dentures&quot; rel=&quot;nofollow noreferrer&quot;&gt;qstrahl/vim-dentures&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-01-24T10:52:47.073" LastActivityDate="2019-01-24T10:52:47.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18687" PostTypeId="2" ParentId="18684" CreationDate="2019-01-24T10:41:38.157" Score="2" Body="&lt;p&gt;Your vim script has to handle the looping through the buffer list. Or maybe you can handle it with &lt;code&gt;:bufdo&lt;/code&gt;, see &lt;code&gt;:help :bufdo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simpler:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;for file in *.cfg; do&#xA;    vim -s scriptin &quot;$file&quot;&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-24T12:04:27.547" LastActivityDate="2019-01-24T12:04:27.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18688" PostTypeId="1" CreationDate="2019-01-24T10:48:39.693" Score="3" ViewCount="930" Body="&lt;p&gt;I believe the default behaviour in vi(m) for pasting (&lt;code&gt;p&lt;/code&gt;) or (&lt;code&gt;P&lt;/code&gt;) was to leave the cursor at the current position as before pasting, and in order to paste a register and have the cursor be at the end of the pasted text one would need to use the commands &lt;code&gt;gp&lt;/code&gt; and &lt;code&gt;gP&lt;/code&gt; respectively. I get only the latter behaviour, but I would like to have the former, what configuration options do I have to change for that?&lt;/p&gt;&#xA;" OwnerUserId="2774" LastActivityDate="2019-01-24T10:48:39.693" Title="Cursor position after pasting" Tags="|cut-copy-paste|cursor|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18689" PostTypeId="1" CreationDate="2019-01-24T11:24:38.797" Score="1" ViewCount="308" Body="&lt;p&gt;If I open gdb in vim with &lt;strong&gt;Termdebug filename&lt;/strong&gt; command it doesn't show source code in bottom window. &lt;strong&gt;cgdb&lt;/strong&gt; works proper way with same &lt;strong&gt;filename&lt;/strong&gt;.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/28Luo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/28Luo.png&quot; alt=&quot;Termdebug&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/JVpMg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JVpMg.png&quot; alt=&quot;cgdb&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20634" LastActivityDate="2019-01-26T05:35:59.530" Title="vim command Termdebug doesn't show source code" Tags="|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18690" PostTypeId="2" ParentId="18679" CreationDate="2019-01-24T14:30:49.367" Score="15" Body="&lt;p&gt;I've used &lt;a href=&quot;https://github.com/michaeljsmith/vim-indent-object&quot; rel=&quot;noreferrer&quot;&gt;vim-indent-object&lt;/a&gt; for a while with some success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It provides text objects like &lt;code&gt;ii&lt;/code&gt;, &lt;code&gt;ai&lt;/code&gt;, &lt;code&gt;iI&lt;/code&gt;, and &lt;code&gt;aI&lt;/code&gt;, each with slightly different semantics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your sample code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def some_method&#xA;  if @foo&#xA;    @bar = 42&#xA;    # moooooore code...&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the cursor is anywhere inside the &lt;code&gt;if&lt;/code&gt; block, you could use &lt;code&gt;vii&lt;/code&gt; to select the the &lt;code&gt;bar&lt;/code&gt; and &lt;code&gt;more&lt;/code&gt; lines. Or, use &lt;code&gt;=ii&lt;/code&gt;, &lt;code&gt;cii&lt;/code&gt;, &lt;code&gt;dii&lt;/code&gt;, &lt;code&gt;!ii&lt;/code&gt;, &lt;code&gt;yii&lt;/code&gt; &amp;amp;c., depending on what you want to do.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-01-24T14:30:49.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18691" PostTypeId="2" ParentId="18631" CreationDate="2019-01-24T14:45:40.493" Score="2" Body="&lt;h3&gt;Debugging&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Make sure your version of the colorscheme is up-to-date (sometimes &quot;bugs&quot; are fixed).&lt;/li&gt;&#xA;&lt;li&gt;Run &lt;code&gt;verbose hi {group}&lt;/code&gt; on groups involved in the highlighting problem, and try to pin down the source of the highlighting.&lt;/li&gt;&#xA;&lt;li&gt;Come up with your fix! This requires some experimenting; cf. &lt;code&gt;:help :hi&lt;/code&gt; (apparently &lt;a href=&quot;https://alvinalexander.com/linux/vi-vim-editor-color-scheme-syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt; is also good).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Solution from OP&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The OP decided turning off &lt;code&gt;reverse&lt;/code&gt; solved the problem and then chose some appropriately contrasting color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The resulting command was &lt;code&gt;hi Search cterm=none ctermbg=3 ctermfg=8&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend putting this in an autocommand like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc_colorschemes&#xA;  au!&#xA;  au ColorScheme solarized hi Search cterm=none ctermbg=3 ctermfg=8&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Finally, I'll note that &lt;a href=&quot;https://github.com/dracula/vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dracula&lt;/a&gt; (a colorscheme I use and maintain) uses the value&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Search         xxx term=reverse ctermfg=0 ctermbg=11 guifg=Black guibg=Yellow&#xA;                   links to DraculaSearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and does &lt;em&gt;not&lt;/em&gt; hide the cursor.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-01-24T14:45:40.493" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18692" PostTypeId="2" ParentId="18685" CreationDate="2019-01-24T15:32:50.517" Score="7" Body="&lt;p&gt;Your regex was really close. As you mentioned, it cuts off the first and last character of your statement, since &lt;code&gt;\S&lt;/code&gt; matches any non-whitespace character. There's no need for &lt;code&gt;\S&lt;/code&gt; here. If you remove it, you get really close:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/if(\(.*\))/if ( \1 )/c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This changes your example to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( statement )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to also grab the brace on the next line, you'll need this regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/if(\(.*\))\n{/if ( \1 ) {/c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, note that I didn't include &lt;code&gt;/g&lt;/code&gt;, only &lt;code&gt;/c&lt;/code&gt;. This is because &lt;code&gt;/g&lt;/code&gt; tells vim to replace every match per line. Without it, vim will search ever line, and replace the first match per line. For this regex, it could only possibly match one per line, so there's no need to tell it to replace every match per line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also some edge cases to consider. For example, what if there were some lines like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( statement)&#xA;{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(statement ) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (   statement   )  {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A more robust regex could be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/if\s*(\s*\(.\{-}\)\s*)\_s*{/if ( \1 ) {/c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although without seeing your file, I can't guarantee this would catch every case.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-01-24T15:32:50.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18693" PostTypeId="1" CreationDate="2019-01-24T15:54:46.290" Score="0" ViewCount="669" Body="&lt;p&gt;I have two different lists of words and I want to make sure that they have no mutual duplicates. In other words, none of the words in list A can be in list B and vice versa. They must be mutually exclusive word lists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both lists are guaranteed to be sorted alphabetically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2019-01-25T21:32:52.130" Title="Find duplicate entries in two different lists" Tags="|search|vimdiff|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18694" PostTypeId="2" ParentId="18693" CreationDate="2019-01-24T16:09:01.637" Score="2" Body="&lt;p&gt;The easiest solution in my mind is to use &lt;code&gt;comm&lt;/code&gt; utility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;List A:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;comm -2 -3 a.txt b.txt &amp;gt; a.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;List B:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;comm -1 -3 a.txt b.txt &amp;gt; b.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can do this inside of Vim with the filter command, &lt;code&gt;:!&lt;/code&gt;. e.g. &lt;code&gt;:%!comm -2 -3 % b.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see &lt;code&gt;man comm&lt;/code&gt; and &lt;code&gt;:h :range!&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-01-24T16:09:01.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18695" PostTypeId="1" CreationDate="2019-01-24T16:57:41.250" Score="0" ViewCount="196" Body="&lt;p&gt;I have been a Vim user for several years now and I haven't been able to find a solution to this issue. There have been a lot of questions on the internet that try to address it, but none of the solutions I found work properly. When I'm doing WordPress development I need to mix in HTML into my template files. What I &lt;em&gt;ideally&lt;/em&gt; want is for &lt;a href=&quot;https://github.com/alvan/vim-closetag&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Closetag&lt;/a&gt; to function in PHP files the same way it does in HTML files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I get is this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Type: &lt;code&gt;&amp;lt;table&amp;gt;&amp;gt;&lt;/code&gt;&#xA;Returns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;table&amp;gt;&#xA;|&#xA;&amp;lt;/table&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gets even more annoying when dealing with inserting these tags in an already indented line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;table&amp;gt;&#xA;   |&#xA;&amp;lt;/table&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried these settings with no luck.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.php'&#xA;let g:closetag_filetypes = 'html,xhtml,phtml,php'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A &quot;solution&quot; I found is setting &lt;code&gt;ft&lt;/code&gt; to either &lt;code&gt;phtml&lt;/code&gt; or &lt;code&gt;html&lt;/code&gt;, but that then stops ALE's linting and fixing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have a viable solution for this? It's been driving me absolutely nuts and I can't figure out a good solution.&lt;/p&gt;&#xA;" OwnerUserId="20692" LastActivityDate="2019-01-24T16:57:41.250" Title="In PHP files, how can I auto close HTML tag pairs and indent the new line?" Tags="|indentation|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18696" PostTypeId="1" AcceptedAnswerId="18697" CreationDate="2019-01-24T20:16:20.453" Score="0" ViewCount="504" Body="&lt;p&gt;In my installation of vim 8.1 (compiled from source) syntax highlighting is not working. The runtime path ($VIMRUNTIME) is set to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; /XYZ/VIM8/installnew/share/vim/vim81&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which contains (autoload, colors, ftpligin, doc,  keymap, spells, tutor etc..)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Futhermore, vimrc also contains&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;syntax on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in addition, the default folder .vim also contains a large selection of colors. Furthermore, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &amp;amp;rtp prints:     &#xA;/XYZ/.vim,/XYZ/.vim/pack/bundle/start/l9,/XYZ/.vim/pack/bundle/start/ack,/XYZ/.vim/pack/bundle/start/FuzzyFinder&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet, I am getting the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E185: Cannot find color scheme 'darkblue'&#xA;Press ENTER or type command to continue &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The colors are not highlighted. In addition &lt;code&gt;colorscheme &amp;lt;tab&amp;gt;&lt;/code&gt; yields no result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried various colors in the above mentioned folders but none worked. What is the cause of this problem?&lt;/p&gt;&#xA;" OwnerUserId="20023" LastEditorUserId="20023" LastEditDate="2019-01-24T20:28:12.163" LastActivityDate="2019-01-24T20:53:36.243" Title="Enable syntax highlighting in vim using colorschemes?" Tags="|vimrc|syntax-highlighting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18697" PostTypeId="2" ParentId="18696" CreationDate="2019-01-24T20:40:37.160" Score="1" Body="&lt;p&gt;Your &lt;code&gt;runtimepath&lt;/code&gt; seems incomplete. I would expect that it contains the following directories:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/XYZ/VIM8/installnew/share/vim/vimfiles&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/XYZ/VIM8/installnew/share/vim/vim81&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/XYZ/VIM8/installnew/share/vim/vimfiles/after&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These directories are part of the default value of &lt;code&gt;runtimepath&lt;/code&gt;. Note that the &#xA;first (&lt;code&gt;vimfiles&lt;/code&gt;) and the last (&lt;code&gt;vimfiles/after&lt;/code&gt;) might not exists when installing from source. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check your &lt;code&gt;vimrc&lt;/code&gt; for manipulation of the runtimepath (something like &lt;code&gt;set runtimepath&lt;/code&gt; or &lt;code&gt;set rtp&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you manipulate the runtime path you should always use &lt;code&gt;set runtimepath+=&lt;/code&gt; (to append) or &lt;code&gt;set runtimepath^=&lt;/code&gt; (to prepend). See &lt;code&gt;:help :set+=&lt;/code&gt; and &lt;code&gt;:help :set^=&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-24T20:53:36.243" LastActivityDate="2019-01-24T20:53:36.243" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18698" PostTypeId="2" ParentId="18689" CreationDate="2019-01-24T22:02:41.070" Score="-1" Body="&lt;p&gt;I should open source file manually. Termdebug doesn't open source file when I do &lt;code&gt;Termdebug filename&lt;/code&gt;. So I need to go to Source window and open source file with &lt;code&gt;:Explore&lt;/code&gt; e.g.&lt;/p&gt;&#xA;" OwnerUserId="20634" LastEditorUserId="20634" LastEditDate="2019-01-26T05:35:59.530" LastActivityDate="2019-01-26T05:35:59.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18699" PostTypeId="1" CreationDate="2019-01-25T10:22:42.333" Score="0" ViewCount="164" Body="&lt;p&gt;I wrote a vimscript function that prevents the cursor from changing its location on the screen when I press &lt;code&gt;n&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! s:my_n()&#xA;    let l:start=line(&amp;quot;w0&amp;quot;)&#xA;    let end = line(&amp;quot;w$&amp;quot;)&#xA;    let cursor = line(&amp;quot;.&amp;quot;)&#xA;    let from_top = cursor-l:start&#xA;    normal! n&#xA;    let new_start = line(&amp;quot;w0&amp;quot;)&#xA;    let new_end = line(&amp;quot;w$&amp;quot;)&#xA;    let new_cursor = line(&amp;quot;.&amp;quot;)&#xA;    let new_from_top = new_cursor-new_start&#xA;    if new_from_top&amp;gt;from_top&#xA;        for i in range(new_from_top-from_top)&#xA;            execute &amp;quot;normal! \&amp;lt;C-e&amp;gt;&amp;quot;&#xA;        endfor&#xA;    else&#xA;        for i in range(from_top-new_from_top)&#xA;            execute &amp;quot;normal! \&amp;lt;C-y&amp;gt;&amp;quot;&#xA;        endfor&#xA;    endif&#xA;endfunction&#xA;nnoremap n :call &amp;lt;SID&amp;gt;my_n()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Everything works fine, except for the messages:&lt;/p&gt;&#xA;&lt;p&gt;I'd want the same as a normal &lt;code&gt;n&lt;/code&gt;, namely:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When there is a match, get &lt;code&gt;.. match x out of y&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;When there is no match, get &lt;code&gt;E486 Pattern not found: ...&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Instead, what I get is:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If I press &lt;code&gt;n&lt;/code&gt; directly after the &lt;code&gt;/&lt;/code&gt; command and when there is a match, I get &lt;code&gt;:call &amp;lt;SNR&amp;gt;1_my_n()&lt;/code&gt; in the command line, but once I move away from matches and then press &lt;code&gt;n&lt;/code&gt; again, I don't get anything at all anymore.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When there is no match, the command line grows in size and displays&lt;/p&gt;&#xA;&lt;p&gt;Error detected while processing function 1_contextn:&#xA;line    6:&#xA;E486: Pattern not found: asdfsdf&#xA;Press ENTER or type command to continue&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I tried a few things:&lt;/p&gt;&#xA;&lt;p&gt;(A) Use &lt;code&gt;silent normal! n&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Nothing changes&lt;/p&gt;&#xA;&lt;p&gt;(B) Use &lt;code&gt;silent! normal! n&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;When there is no match, I don't get an error message anymore and instead get &lt;code&gt;:call &amp;lt;SNR&amp;gt;1_my_n()&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;(C) Use &lt;code&gt;map &amp;lt;silent&amp;gt; n&lt;/code&gt; and go back to &lt;code&gt;normal! n&lt;/code&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When there is a match, I get the proper message &lt;code&gt;.. match x out of y&lt;/code&gt;, but once I leave the matches and then press &lt;code&gt;n&lt;/code&gt; I don't get anything at all&lt;/li&gt;&#xA;&lt;li&gt;Same behavior as in the original when there are no matches&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;(D) Use &lt;code&gt;map &amp;lt;silent&amp;gt; n&lt;/code&gt; and &lt;code&gt;silent normal! n&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Exactly as (C)&lt;/p&gt;&#xA;&lt;p&gt;(E) Use &lt;code&gt;map &amp;lt;silent&amp;gt; n&lt;/code&gt; and &lt;code&gt;silent! normal! n&lt;/code&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When there is a match, same as in (C)&lt;/li&gt;&#xA;&lt;li&gt;When there is no match, no message or error at all&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Note: This question is basically the same as  &lt;a href=&quot;https://vi.stackexchange.com/questions/18583/how-to-show-foobar-match-1-of-or-e486-pattern-not-found-foobar-in-comman?noredirect=1#comment32125_18583&quot;&gt;How to show &amp;quot;/foobar match 1 of &amp;quot; or &amp;quot;E486: Pattern not found: foobar&amp;quot; in commandline when calling `normal! n` in function&lt;/a&gt; but cleaned up, with the complete code, and with all my attempts. In comparison to that question, I am omitting here another complexity, namely that my full mapping is&#xA;&lt;code&gt;nnoremap n :call &amp;lt;SID&amp;gt;my_n()&amp;lt;CR&amp;gt;&amp;lt;SID&amp;gt;my_other_function()&amp;lt;CR&amp;gt;&lt;/code&gt; and if the solution to my problem involves changing this mapping, it'd be also good to know how to control the output of the two function calls separately&lt;/p&gt;&#xA;" OwnerUserId="18613" LastEditorUserId="23502" LastEditDate="2023-08-31T19:38:12.737" LastActivityDate="2024-01-28T21:04:05.463" Title="How to get the same message and error behavior as normal `n` when calling `normal n` in function?" Tags="|vimscript|search|normal-mode|debugging|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18700" PostTypeId="1" CreationDate="2019-01-25T10:56:10.967" Score="1" ViewCount="213" Body="&lt;p&gt;I'm trying to to have a visible mark depicting the &quot;state&quot; the buffer is at. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &quot;state&quot; is nothing more but a function that sets or unsets some keymapings that should be easily arbitrarily turned on or of on a per buffer basis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking for a way to show some visual mark for every buffer that has that state set. Something like this (with ASCII graphics):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gOPOr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gOPOr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, pressing &lt;code&gt;F4&lt;/code&gt; draw that little rectangle in the top, and repressing it clears it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't have to be that exact visual mark, am open to suggestions that are simpler to implement but clearly show a visual difference in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on how to do this?&lt;/p&gt;&#xA;" OwnerUserId="7129" LastActivityDate="2019-01-28T14:50:26.273" Title="Have a buffer show a &quot;state mark&quot;" Tags="|neovim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18701" PostTypeId="1" AcceptedAnswerId="18749" CreationDate="2019-01-25T13:36:07.440" Score="3" ViewCount="5766" Body="&lt;p&gt;I suddenly receive &lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;30_Highlight_Matching_Pair&lt;/code&gt; when I want to write parantheses or when moving over parantheses. I can turn off these error message with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:NoMatchParen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunatly, I am unable to reconstruct what I have changed in my environment, possibly in the &lt;code&gt;vimrc&lt;/code&gt; file. Does someone have an idea where I have to look to turn this behavior off?&lt;/p&gt;&#xA;" OwnerUserId="985" LastActivityDate="2019-01-31T09:06:05.207" Title="Why do I suddenly receive &quot;Error detected while processing function &lt;SNR&gt;30_Highlight_Matching_Pair&quot;?" Tags="|original-vim|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18702" PostTypeId="1" AcceptedAnswerId="18751" CreationDate="2019-01-25T15:46:20.587" Score="3" ViewCount="582" Body="&lt;p&gt;I'd like to experiment one of the tip by Drew Neil in his Vimcast, that is to &quot;escape&quot; regularly, so that it gives more granularity to the &quot;undo&quot; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I write one short sentence. Then I press &lt;kbd&gt;Escape&lt;/kbd&gt;. Then I press &lt;kbd&gt;a&lt;/kbd&gt; to continue my editting and write another sentence. So when I press my final &lt;kbd&gt;escape&lt;/kbd&gt;, I can press &lt;kbd&gt;u&lt;/kbd&gt; several times and only one sentence at a time will disappear, not the whole text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if I could remap this simple sequence, (for example with &lt;code&gt;kj&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap kj &amp;lt;esc&amp;gt;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key remapping works (it feels like I didn't exit insert mode), but the problem is, when I use &lt;code&gt;kj&lt;/code&gt; to mark a pause after a sentence, then if I write another sentence and press &lt;kbd&gt;escape&lt;/kbd&gt;, then pressing &lt;kbd&gt;u&lt;/kbd&gt; will erease my two sentences at once, and therefore I don't benefit the granularity I was looking for in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is it pressing &lt;code&gt;kj&lt;/code&gt; doesn't have the same effect on the undo command compared to pressing manually &lt;kbd&gt;escape&lt;/kbd&gt; + &lt;kbd&gt;a&lt;/kbd&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, is there a way to do the remaping with the desired effect?&lt;/p&gt;&#xA;" OwnerUserId="20704" LastEditorUserId="20704" LastEditDate="2019-01-25T16:12:12.697" LastActivityDate="2019-01-31T11:36:06.190" Title="Exiting and entering insert mode again with key-binding" Tags="|key-bindings|insert-mode|undo-redo|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18703" PostTypeId="2" ParentId="18693" CreationDate="2019-01-25T17:32:34.077" Score="1" Body="&lt;p&gt;A “visual” solution would be to arrange two windows, each with one of the two buffers you want to view (e.g. &lt;code&gt;vim a b&lt;/code&gt; then &lt;code&gt;:vs | next&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then do &lt;code&gt;:windo diffthis&lt;/code&gt; to turn on the diff mode. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Untested, but you might be able to &lt;code&gt;vimdiff a b&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-01-25T17:32:34.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18704" PostTypeId="2" ParentId="18693" CreationDate="2019-01-25T21:32:52.130" Score="1" Body="&lt;p&gt;I answer in the case you wish to test the intersection between two &lt;code&gt;|List|&lt;/code&gt; expressions, and not comparing text. In that later case others have already provide good answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Linear O(N) algorithms won't be efficient once implemented in vimscript as they would require using &lt;code&gt;:for&lt;/code&gt; which has terrible performances. Functional O(N²) implementations are likely to be the fastest with current versions of Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, in that case I'd use the following function from my &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim script library&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! lh#list#intersect(list1, list2) abort&#xA;  let result = copy(a:list1)&#xA;  call filter(result, 'index(a:list2, v:val) &amp;gt;= 0')&#xA;  return result&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2019-01-25T21:32:52.130" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18705" PostTypeId="1" AcceptedAnswerId="18731" CreationDate="2019-01-25T22:29:15.523" Score="3" ViewCount="3162" Body="&lt;p&gt;I am trying to work more with the built-in terminal for vim 8.1 and reading through the docs noticed it has two keybindings for entering the normal &lt;code&gt;Terminal-mode&lt;/code&gt;. &lt;code&gt;CTRL+\ CTRL+N&lt;/code&gt; as well as &lt;code&gt;CTRL+W CTRL+N&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While The &lt;code&gt;CTRL+\ CTRL+N&lt;/code&gt; works the other does not, it seems that &lt;code&gt;CTRL+W CTRL+N&lt;/code&gt; is associated with the &lt;code&gt;:new&lt;/code&gt; command as well.  Is this expected behavior or is there possibly a setting that I have on that might effect this that I can't find?  &lt;/p&gt;&#xA;" OwnerUserId="8008" LastActivityDate="2019-01-28T20:57:48.760" Title="Terminal-mode not working with Ctrl-W" Tags="|key-bindings|terminal|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18706" PostTypeId="1" AcceptedAnswerId="24514" CreationDate="2019-01-25T23:12:45.320" Score="1" ViewCount="226" Body="&lt;p&gt;Below is my configuration for &lt;code&gt;denite&lt;/code&gt;. When I exit from a denite buffer without selecting a file or buffer via the &lt;code&gt;escape&lt;/code&gt; key or &lt;code&gt;ctrl-o q&lt;/code&gt;, denite displays the contents of the file or buffer that the prompt was on last.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure denite to not to open &lt;em&gt;any&lt;/em&gt; file or buffer upon existing without selection?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Denite:&#xA;nnoremap &amp;lt;leader&amp;gt;f :Denite -direction=dynamicbottom -auto-preview file_rec&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;b :Denite -direction=dynamicbottom -auto-preview buffer&amp;lt;CR&amp;gt;&#xA;&#xA;call denite#custom#var('file/rec', 'command', ['ag', '--follow', '-g', '--nogroup', '--nocolor', '-u', ''])&#xA;call denite#custom#var('grep', 'command', ['ag'])&#xA;call denite#custom#var('grep', 'default_opts', ['-i', '--vimgrep'])&#xA;call denite#custom#var('grep', 'recursive_opts', [])&#xA;call denite#custom#var('grep', 'pattern_opt', [])&#xA;call denite#custom#var('grep', 'separator', ['--'])&#xA;call denite#custom#var('grep', 'final_opts', [])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11232" LastActivityDate="2020-04-09T20:43:01.947" Title="How to Close Preview When Exiting Denite?" Tags="|vimrc|plugin-denite|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18707" PostTypeId="1" CreationDate="2019-01-26T00:36:53.823" Score="2" ViewCount="315" Body="&lt;p&gt;Seems to me that &lt;code&gt;fillchars&lt;/code&gt; option doesn't include these characters.&lt;/p&gt;&#xA;" OwnerUserId="20505" LastActivityDate="2019-01-27T10:46:46.490" Title="Is there a way to customize the characters used in fold column?" Tags="|folding|options|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18709" PostTypeId="2" ParentId="18667" CreationDate="2019-01-26T19:21:13.397" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u4JDA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u4JDA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found out. It sounds stupid but I created by myself.&#xA;I do not know when did I make it, but it is a bookmark in nerdtree. Press &lt;kbd&gt;B&lt;/kbd&gt; to see the list and &lt;kbd&gt;D&lt;/kbd&gt; to delete it.&lt;/p&gt;&#xA;" OwnerUserId="19109" LastActivityDate="2019-01-26T19:21:13.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18710" PostTypeId="1" AcceptedAnswerId="25869" CreationDate="2019-01-27T04:31:46.920" Score="5" ViewCount="619" Body="&lt;p&gt;Occasionally, I paste large amounts of data into vim, using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; in my terminal emulator (in Linux). This takes several seconds before vim is responsive again. I have tried two &lt;a href=&quot;https://stackoverflow.com/q/18258561/1944384&quot;&gt;other methods&lt;/a&gt;, which work well: either &lt;code&gt;&quot;+P&lt;/code&gt;, or temporarily &lt;code&gt;:set noswapfile&lt;/code&gt; before pasting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tested launching vanilla vim, using &lt;code&gt;vim -u NONE&lt;/code&gt;, and the problem still persists. As a reference, this &lt;a href=&quot;https://pastebin.com/raw/gZCFiv0r&quot; rel=&quot;nofollow noreferrer&quot;&gt;5600-character lorem ipsum&lt;/a&gt; takes ~3 seconds to paste with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;. It's almost instantaneous with &lt;code&gt;&quot;+P&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only need the paste alternatives with large data and vim. In all other situations I use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;. In vim, this also has the added advantage of working in insert mode. It's only &lt;em&gt;after&lt;/em&gt; I paste long data, when I regret my life choices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to automatically apply some workaround, so that is it consistently quick to paste with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="1278" LastEditDate="2020-06-12T04:08:23.493" LastActivityDate="2020-06-12T04:24:08.810" Title="Can I define something in .vimrc to speed up pasting of large amounts of data?" Tags="|vimrc|cut-copy-paste|options|" AnswerCount="5" CommentCount="21" ContentLicense="CC BY-SA 4.0" />
  <row Id="18712" PostTypeId="1" AcceptedAnswerId="18719" CreationDate="2019-01-27T10:48:14.847" Score="0" ViewCount="231" Body="&lt;p&gt;I want to have fast pasting while having &lt;code&gt;:reg&lt;/code&gt; view. I have remapping:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:noremap &amp;lt;C-r&amp;gt;&amp;lt;C-r&amp;gt; &amp;lt;ESC&amp;gt;:reg&amp;lt;CR&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While i am in this mode I want to to have single keystroke(buffer name) option like: &quot;, 1, 2, 3, *, #, /, etc.. to paste register. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to do that?&lt;/p&gt;&#xA;" OwnerUserId="16328" LastActivityDate="2019-01-28T10:13:28.320" Title="Vim registers fast pasting with :reg view" Tags="|register|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18713" PostTypeId="1" CreationDate="2019-01-27T13:08:14.390" Score="2" ViewCount="237" Body="&lt;p&gt;how can I scroll or move around in the code while writing a search or command ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to write a substitution &lt;code&gt;:s/xxx/yyy&lt;/code&gt; but I forgot what yyy should be and I need to scroll a little bit to find it, but don't want to leave command line either because it took me a while to type xxx &lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2019-01-27T19:53:27.227" Title="scroll while writing a substitution" Tags="|search|command-line|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18714" PostTypeId="2" ParentId="18712" CreationDate="2019-01-27T15:06:52.670" Score="1" Body="&lt;p&gt;I’ve not used it myself, but &lt;a href=&quot;https://github.com/junegunn/vim-peekaboo&quot; rel=&quot;nofollow noreferrer&quot;&gt;peekaboo&lt;/a&gt; provides a sort of HUD for pasting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It’s not a “quick-paste” as you describe but may solve the same problem. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-01-27T15:06:52.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18715" PostTypeId="2" ParentId="18713" CreationDate="2019-01-27T15:17:03.777" Score="4" Body="&lt;p&gt;&lt;code&gt;&amp;lt;C-g&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-t&amp;gt;&lt;/code&gt; jump to the next and previous match, respectively. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if the mouse is enabled, you can probably use it (opening the command line window first might be necessary: &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; if already on &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;q:&lt;/code&gt; otherwise). Opening the command-line window has some additional benefits, so is worth looking into.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if the replacement is difficult to remember, I’d consider this workflow:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;(Optional: find &lt;code&gt;yyy&lt;/code&gt; and yank it into a register)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/xxx&lt;/code&gt; until you’re happy with the search pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:s//yyy&lt;/code&gt; &lt;em&gt;or&lt;/em&gt; &lt;code&gt;:s//&amp;lt;C-r&amp;gt;{reg}&lt;/code&gt; (type &lt;kbd&gt;CTRL-r&lt;/kbd&gt; literally, using the register you yanked &lt;code&gt;yyy&lt;/code&gt; into)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-01-27T19:53:27.227" LastActivityDate="2019-01-27T19:53:27.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18716" PostTypeId="2" ParentId="18710" CreationDate="2019-01-27T21:18:44.237" Score="1" Body="&lt;p&gt;You can try setting &lt;code&gt;lazyredraw&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="20725" LastActivityDate="2019-01-27T21:18:44.237" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18717" PostTypeId="1" CreationDate="2019-01-28T00:01:37.443" Score="0" ViewCount="409" Body="&lt;p&gt;Would like to have all content of the folded block, instead of only the first line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current foldsettings are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=marker&#xA;set foldmarker={,}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example how my data is structured:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  cows&#xA;  pigs&#xA;  chickens&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Current folds look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+--  5 lines: ---------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideally folds look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{  cows  pigs  chickens  } --------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Have searched on the net for a while, unfortunately didn't succeed.&lt;/p&gt;&#xA;" OwnerUserId="20726" LastActivityDate="2019-01-28T07:32:11.717" Title="Vim: Foldtext contain all content, instead of only the first line" Tags="|regular-expression|folding|functions|join|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18719" PostTypeId="2" ParentId="18712" CreationDate="2019-01-28T04:19:53.397" Score="1" Body="&lt;p&gt;Try this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-r&amp;gt;&amp;lt;C-r&amp;gt; :reg&amp;lt;CR&amp;gt;:let regname = input(&quot;Register? &quot;) \| exe 'norm &quot;' . regname . 'p'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll see the &lt;code&gt;:reg&lt;/code&gt; output and then a prompt. At the prompt enter the register (&lt;code&gt;#&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;@&lt;/code&gt;, etc.) and hit &lt;kbd&gt;Enter&lt;/kbd&gt;. The contents of the selected register will be &lt;code&gt;p&lt;/code&gt;asted right after the current position of the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is adapted from &lt;a href=&quot;https://vi.stackexchange.com/a/18166/11054&quot;&gt;an answer I gave to a similar question&lt;/a&gt; about acting on the output of the &lt;code&gt;[I&lt;/code&gt; command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately, &lt;code&gt;:reg&lt;/code&gt; enters the same general &quot;what now?&quot; prompt as &lt;code&gt;[I&lt;/code&gt; does. That prompt allows &lt;code&gt;:&lt;/code&gt; as a response and that puts us on the regular command line without dismissing the previous command's output. From there it's just a matter of displaying a prompt and then building a &lt;code&gt;:normal&lt;/code&gt; command that pastes whatever register the user entered.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Sounds like OP is interested in a variation that doesn't require hitting &lt;kbd&gt;Enter&lt;/kbd&gt;. This should do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;C-r&amp;gt;&amp;lt;C-r&amp;gt; :reg&amp;lt;CR&amp;gt;:echom &quot;Register? &quot;\|let n=nr2char(getchar())\|exe 'norm &quot;'.n.'p'\|redraw&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Besides using &lt;code&gt;nr2char(getchar())&lt;/code&gt; to get the register name I tacked a &lt;code&gt;:redraw&lt;/code&gt; onto the end to eliminate the &lt;em&gt;Press Enter or type command to continue&lt;/em&gt; prompt that blocks immediate return to Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(FYI it's also shortened/compressed a bit compared to the first one.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-01-28T10:13:28.320" LastActivityDate="2019-01-28T10:13:28.320" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18720" PostTypeId="2" ParentId="18717" CreationDate="2019-01-28T05:31:58.150" Score="1" Body="&lt;p&gt;The option &lt;code&gt;foldtext&lt;/code&gt; defines a expression, that is evaluated to create the text displayed for a closed fold. By default this is set to the build in function &lt;code&gt;foldtext()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create a custom function, to create the text displayed on a closed fold. The documentation &lt;code&gt;:help fold-foldtext&lt;/code&gt; contains an example. Note that the resulting text is truncated to fit window width.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-28T05:31:58.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18721" PostTypeId="2" ParentId="18717" CreationDate="2019-01-28T07:32:11.717" Score="0" Body="&lt;p&gt;An example of probably what you want:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LarMz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LarMz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=marker&#xA;set foldmarker={,}&#xA;&#xA;set foldtext=MyFoldText()&#xA;fu! MyFoldText()&#xA;    let lineNr = v:foldstart&#xA;    let text = &quot;&quot;&#xA;    while (strlen(text) &amp;lt; winwidth(0) - v:foldlevel - 2) &amp;amp;&amp;amp; lineNr &amp;lt;= v:foldend&#xA;        let text .= getline(lineNr).' '&#xA;        let lineNr += 1&#xA;    endwhile&#xA;&#xA;    let text = v:folddashes . text&#xA;    if strlen(text) &amp;gt; winwidth(0) - 5 &#xA;        let text = strpart(text, 0, winwidth(0) - 5).' … }'&#xA;    endif&#xA;    return text&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is not 100% bulletproof, probably will make your vim slow. I could make it more generic (you see there are some figures I manually hardcoded) but I will leave it for you to tinker.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-01-28T07:32:11.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18722" PostTypeId="1" AcceptedAnswerId="18772" CreationDate="2019-01-28T07:43:41.683" Score="1" ViewCount="893" Body="&lt;p&gt;I have some plugins I would prefer load by default in the terminal, and cause performance issues or UX glitches in Jetbrains' IDEs running IdeaVim. How can I detect IntelliJ IDEs in Vim?&lt;/p&gt;&#xA;&lt;p&gt;I have used this in the past to detect the name of the terminal &lt;code&gt;tmux&lt;/code&gt; is running in:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;echo $(basename &amp;quot;/&amp;quot;$(ps -f -p $(cat /proc/$(echo $$)/stat | cut -d \  -f 4) | \&#xA;    tail -1 |\ sed 's/^.* //'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'm looking for a Vim equivalent of the above pipeline using Vim built-ins for querying the state of the environment. Is there an api for that?&lt;/p&gt;&#xA;" OwnerUserId="20729" LastEditorUserId="10604" LastEditDate="2023-09-16T15:21:54.063" LastActivityDate="2024-03-09T22:26:04.630" Title="How to detect IntelliJ/IdeaVim in vimrc?" Tags="|vimrc|vimscript|ide|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18723" PostTypeId="2" ParentId="18722" CreationDate="2019-01-28T10:23:41.393" Score="0" Body="&lt;p&gt;Not really sure why you want to check that, since IdeaVim uses &lt;code&gt;.ideavimrc&lt;/code&gt; and not &lt;code&gt;.vimrc&lt;/code&gt; or &lt;code&gt;init.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And so you can not have single common rc file for both IntelliJ and Vim. Contents of &lt;code&gt;.vimrc&lt;/code&gt; and &lt;code&gt;.ideavimrc&lt;/code&gt; can be same but the files have to be different.&lt;/p&gt;&#xA;" OwnerUserId="18373" LastActivityDate="2019-01-28T10:23:41.393" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18724" PostTypeId="1" CreationDate="2019-01-28T10:23:53.123" Score="1" ViewCount="53" Body="&lt;p&gt;I use &lt;strong&gt;vimtex&lt;/strong&gt; plugin for writing tex documents in &lt;strong&gt;vim8&lt;/strong&gt;. I added custom hilight for sections in my .vimrc like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType tex :syntax match texSectioning &quot;\\section.*&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;texSectioning&lt;/code&gt; is defined in my color scheme file in &lt;code&gt;.vim/colors&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works on any file with &lt;code&gt;.tex&lt;/code&gt; extension except for one! Copying/movig the file to different dir or/and changing name, changing file extention to &lt;code&gt;.txt&lt;/code&gt; and then manually switching on tex filetype does not help. Even typing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match texSectioning &quot;\\section.*&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;command has no effect.  There is no &lt;code&gt;.swp&lt;/code&gt; file, I didn't use &lt;code&gt;mkview&lt;/code&gt; (there is no &lt;code&gt;view&lt;/code&gt; folder in .vim), I didn't use sessions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm really confused by this... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the output of &lt;code&gt;set filetype&lt;/code&gt; is &lt;code&gt;filetype=tex&lt;/code&gt;. The standard syntax highlighting works, I'm only missing he custom one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently, removing &lt;code&gt;.latexmkrc&lt;/code&gt; &lt;strong&gt;solved&lt;/strong&gt; the problem.&#xA; There must have been some interference between &lt;code&gt;vimtex&lt;/code&gt; and &lt;code&gt;latexmk&lt;/code&gt;, but it is wierd if that was the case...&lt;/p&gt;&#xA;" OwnerUserId="20733" LastEditorUserId="20734" LastEditDate="2019-02-01T22:55:16.120" LastActivityDate="2019-02-01T22:55:16.120" Title="custom syntax hilighting lost on single LaTeX file" Tags="|syntax-highlighting|filetype-tex|plugin-vimtex|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18725" PostTypeId="1" AcceptedAnswerId="18726" CreationDate="2019-01-28T12:54:57.340" Score="3" ViewCount="200" Body="&lt;p&gt;I'm learning Vimscript in &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/16.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard way&lt;/a&gt; and trying an exercise. Here is this:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The lines &amp;quot;underlined&amp;quot; with = characters are treated as headings by Markdown.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;:onoremap ih :&amp;lt;c-u&amp;gt;execute &amp;quot;normal! ?^==\\+$\r:nohlsearch\rkvg_&amp;quot;&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;By this, Vim will delete the heading of whatever section you're in and put you in insert mode (&amp;quot;change inside heading&amp;quot;).&lt;/p&gt;&#xA;&lt;p&gt;Markdown can also have headings delimited with lines of - characters. Adjust the regex in these mappings to work for either type of heading.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So I changed the regex(&lt;code&gt;?^==\\+$&lt;/code&gt;) to this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;?^\(==\|--\)\\+$&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then replaced it. However, this regex can't find neither '-' headings nor '=' them.&lt;/p&gt;&#xA;&lt;p&gt;What is the correct regex I want in this case?&lt;/p&gt;&#xA;" OwnerUserId="20737" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-01-28T13:26:01.770" Title="Vim RegEx question: how to detect headings of markdown(.md) i.e. lines composed of '-' or '='" Tags="|regular-expression|filetype-markdown|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18726" PostTypeId="2" ParentId="18725" CreationDate="2019-01-28T13:26:01.770" Score="6" Body="&lt;p&gt;The original regex is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?^==\\+$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which means, searching backwards (&lt;code&gt;?&lt;/code&gt;) for start-of-line (&lt;code&gt;^&lt;/code&gt;), followed by &lt;code&gt;=&lt;/code&gt;, followed by another &lt;code&gt;=&lt;/code&gt; which can be repeated several times (&lt;code&gt;\+&lt;/code&gt; qualifier, followed by end-of-line (&lt;code&gt;$&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The backslash needs to be doubled, because the regex is embedded into a double-quoted string, read &lt;a href=&quot;https://vimhelp.org/eval.txt.html#expr-quote&quot; rel=&quot;noreferrer&quot;&gt;:h expr-quote&lt;/a&gt; why this is needed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to allow either &lt;code&gt;-&lt;/code&gt; or &lt;code&gt;=&lt;/code&gt; to find the headers, you would change the regex to be somthing like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ^[=-]\+$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which comes down to, search start of line (&lt;code&gt;^&lt;/code&gt;), any of the chars &lt;code&gt;-&lt;/code&gt; or &lt;code&gt;=&lt;/code&gt; at least once (&lt;code&gt;\+&lt;/code&gt;) and end of line (&lt;code&gt;$&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, that this would also find e.g. lines consisting of: &lt;code&gt;=-=-=-&lt;/code&gt; If you would like to prevent this, you would need to capture the first character and make sure it comes several times:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^\([=-]\)\1\+$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: remember to double the backslashes, if you put this into a double quoted string.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-01-28T13:26:01.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18727" PostTypeId="1" AcceptedAnswerId="18728" CreationDate="2019-01-28T14:14:56.963" Score="1" ViewCount="698" Body="&lt;p&gt;I have an .xml file which contains many times the following web beacon&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;span lang=&quot;EN&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO&amp;lt;/span&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to make a &quot;Find&amp;amp;Replace&quot;: each web beacon of this type (&lt;strong&gt;the text inside may differ&lt;/strong&gt;)  should be replace by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;span lang=&quot;FR&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO&amp;lt;/span&amp;gt;&#xA;&amp;lt;span lang=&quot;EN&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO&amp;lt;/span&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In short I copy each &quot;EN&quot; web beacon into the same web beacon except I would replace &quot;EN&quot; by &quot;FR&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first, my file looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;text&amp;gt;&amp;lt;![CDATA[&amp;lt;p&amp;gt;&amp;lt;span lang=&quot;EN&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO1&amp;lt;/span&amp;gt;&amp;lt;span lang=&quot;FI&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO1&amp;lt;/span&amp;gt;&amp;lt;span lang=&quot;RU&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO1&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;]]&amp;gt;&amp;lt;/text&amp;gt;&#xA;&amp;lt;text&amp;gt;&amp;lt;![CDATA[&amp;lt;p&amp;gt;&amp;lt;span lang=&quot;EN&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO2&amp;lt;/span&amp;gt;&amp;lt;span lang=&quot;FI&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO2&amp;lt;/span&amp;gt;&amp;lt;span lang=&quot;RU&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO2&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;]]&amp;gt;&amp;lt;/text&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and should be edited as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text&amp;gt;&amp;lt;![CDATA[&amp;lt;p&amp;gt;&amp;lt;span lang=&quot;FR&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO1&amp;lt;/span&amp;gt;&amp;lt;span lang=&quot;EN&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO1&amp;lt;/span&amp;gt;&amp;lt;span lang=&quot;FI&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO1&amp;lt;/span&amp;gt;&amp;lt;span lang=&quot;RU&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO1&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;]]&amp;gt;&amp;lt;/text&amp;gt;&#xA;text&amp;gt;&amp;lt;![CDATA[&amp;lt;p&amp;gt;&amp;lt;span lang=&quot;FR&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO2&amp;lt;/span&amp;gt;&amp;lt;span lang=&quot;EN&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO2&amp;lt;/span&amp;gt;&amp;lt;span lang=&quot;FI&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO2&amp;lt;/span&amp;gt;&amp;lt;span lang=&quot;RU&quot; class=&quot;multilang&quot;&amp;gt;ANY TEXT TOTO2&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;]]&amp;gt;&amp;lt;/text&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20739" LastEditorUserId="20739" LastEditDate="2019-01-28T14:39:24.570" LastActivityDate="2019-01-28T14:47:22.513" Title="Find and replace in XML file in vi" Tags="|command-line|replace|find|filetype-xml|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18728" PostTypeId="2" ParentId="18727" CreationDate="2019-01-28T14:31:19.283" Score="1" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/lang=&quot;EN&quot;/s%^\(.\{-}\)\(&amp;lt;span .\{-}&amp;lt;/span&amp;gt;\)%\1\2\2%|s%lang=&quot;EN&quot;%lang=&quot;FR&quot;%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Breakdown:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;g/lang=&quot;EN&quot;/&lt;/code&gt; for all lines that contain &lt;code&gt;lang=&quot;EN&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s%^\(.\{-}\)\(&amp;lt;span .\{-}&amp;lt;/span&amp;gt;\)%\1\2\2%&lt;/code&gt; &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^\(.\{-}\)&lt;/code&gt; match the shortest possible prefix&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(&amp;lt;span .\{-}&amp;lt;/span&amp;gt;\)&lt;/code&gt; match from first &lt;code&gt;&amp;lt;span&lt;/code&gt; to first &lt;code&gt;&amp;lt;/span&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\1\2\2&lt;/code&gt; replace with the prefix (first &lt;code&gt;\(...\)&lt;/code&gt;) and two times the matched span (second &lt;code&gt;\(...\)&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s%lang=&quot;EN&quot;%lang=&quot;FR&quot;%&lt;/code&gt; finally replace first &lt;code&gt;lang=&quot;EN&quot;&lt;/code&gt; with &lt;code&gt;lang=&quot;FR&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-28T14:47:22.513" LastActivityDate="2019-01-28T14:47:22.513" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18729" PostTypeId="2" ParentId="18700" CreationDate="2019-01-28T14:50:26.273" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;draw that little rectangle in the top&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This will be possible when Neovim's &lt;a href=&quot;https://github.com/neovim/neovim/pull/6619&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;floating windows&quot; PR&lt;/a&gt; is merged.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meanwhile you might be interested in &lt;code&gt;:help nvim_buf_set_virtual_text()&lt;/code&gt;, it could be used to simulate a one-line floating status, but will require some logic to re-position the text when you scroll. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call nvim_buf_set_virtual_text(bufnr('%'), 0, line('w0')-1, [[repeat(' ',max([4,80-strdisplaywidth(getline(line('w0')))])).'Fancy Status', 'Error']],{})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Re-execute the command (&lt;code&gt;@:&lt;/code&gt;) whenever you move the viewport.&lt;/li&gt;&#xA;&lt;li&gt;Of course, a full solution will need to respond to cursor motion and remove the previous virtual text. Read &lt;code&gt;:help nvim_buf_set_virtual_text()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="578" LastActivityDate="2019-01-28T14:50:26.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18730" PostTypeId="1" CreationDate="2019-01-28T20:23:28.430" Score="1" ViewCount="487" Body="&lt;p&gt;Below is my configuration for &lt;code&gt;denite&lt;/code&gt;. When I select a file from the denite buffer, the file is opened in the preview split window rather than a new window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure denite to open the selected file in a new window?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Denite:&#xA;nnoremap &amp;lt;leader&amp;gt;f :Denite -direction=dynamicbottom -auto-preview file_rec&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;b :Denite -direction=dynamicbottom -auto-preview buffer&amp;lt;CR&amp;gt;&#xA;&#xA;call denite#custom#var('file/rec', 'command', ['ag', '--follow', '-g', '--nogroup', '--nocolor', '-u', ''])&#xA;call denite#custom#var('grep', 'command', ['ag'])&#xA;call denite#custom#var('grep', 'default_opts', ['-i', '--vimgrep'])&#xA;call denite#custom#var('grep', 'recursive_opts', [])&#xA;call denite#custom#var('grep', 'pattern_opt', [])&#xA;call denite#custom#var('grep', 'separator', ['--'])&#xA;call denite#custom#var('grep', 'final_opts', [])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11232" LastActivityDate="2019-01-28T20:23:28.430" Title="Configure Denite to Open File in New Window" Tags="|vimrc|neovim|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18731" PostTypeId="2" ParentId="18705" CreationDate="2019-01-28T20:57:48.760" Score="2" Body="&lt;p&gt;So, after the obvious blunder of not using a &lt;strong&gt;capital N&lt;/strong&gt; ‍♂️ ... I was able to get the remap working with the lowercase n (just for terminal) which is what I was hoping to get.  This was done by adding the following to my vim startup.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tnoremap &amp;lt;C-W&amp;gt;n &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8008" LastActivityDate="2019-01-28T20:57:48.760" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18732" PostTypeId="1" AcceptedAnswerId="18976" CreationDate="2019-01-29T01:43:58.183" Score="2" ViewCount="1343" Body="&lt;p&gt;I have two syntax region defined as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region xBCD start=&quot;b&quot; end=&quot;d&quot;&#xA;hi def link xBCD Todo&#xA;&#xA;syntax region xBlock start=&quot;\z(abcde\)\zs::&quot; end=&quot;;&quot;&#xA;hi def link xBlock Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and a text file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abcde::test;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I.e, I have is a syntax region that I'd like to define within the start match of another region.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use these regions, then only the &lt;code&gt;xBCD&lt;/code&gt; region is highlighted.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If I try to defined &lt;code&gt;xBCD&lt;/code&gt; as contained in &lt;code&gt;xBlock&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region xBCD start=&quot;b&quot; end=&quot;d&quot; contained&#xA;hi def link xBCD Todo&#xA;&#xA;syntax region xBlock start=&quot;\z(abcde\)\zs::&quot; end=&quot;;&quot; contains=xBCD&#xA;hi def link xBlock Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then I get the opposite effect; everything after &lt;code&gt;start&lt;/code&gt; is highlighted as &lt;code&gt;xBlock&lt;/code&gt;, but &lt;code&gt;bcd&lt;/code&gt; is not highlighted as &lt;code&gt;xBCD&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to define and highlight other regions within the un-highlighted parts of a broader region's &lt;code&gt;start&lt;/code&gt; match?&lt;/p&gt;&#xA;" OwnerUserId="20748" LastActivityDate="2019-02-26T11:11:51.550" Title="Syntax Highlighting a region inside the start match of another region" Tags="|syntax-highlighting|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18733" PostTypeId="1" CreationDate="2019-01-29T02:13:10.030" Score="1" ViewCount="419" Body="&lt;p&gt;This function outputs data between braces as joined lines in a quickfix window. The output is sorted based on line numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm searching for a method to sort the data alphabetically. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to exclude &lt;code&gt;bufnr&lt;/code&gt; and &lt;code&gt;lnum&lt;/code&gt;, but that breaks the relocation to the actual buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Overview() abort&#xA;    0&#xA;    let bufnr = bufnr('%')&#xA;    let items = []&#xA;    while 1&#xA;        let start = search('^{', 'cW')&#xA;        if !start&#xA;            break&#xA;        endif&#xA;        let end = search('^}', 'W')&#xA;        let lines = getline(start, end)&#xA;        let lines = map(lines, 'trim(v:val)')&#xA;        call add(items, {&#xA;            \ 'bufnr': bufnr,&#xA;            \ 'lnum': start,&#xA;            \ 'text': join(lines, ' '),&#xA;        \ })&#xA;    endwhile&#xA;    call setloclist(winnr(), items)&#xA;    lopen&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20749" LastEditorUserId="16789" LastEditDate="2019-02-01T00:30:02.320" LastActivityDate="2019-10-30T13:03:30.607" Title="function: sort output alphabetically" Tags="|vimscript|functions|quickfix|sort|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18734" PostTypeId="1" AcceptedAnswerId="18747" CreationDate="2019-01-29T02:25:56.663" Score="5" ViewCount="8487" Body="&lt;p&gt;As an extension (follow-up question) of the answer &lt;a href=&quot;https://vi.stackexchange.com/a/11008/20750&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If you type &lt;code&gt;:version&lt;/code&gt;, you should see &lt;code&gt;+python/dyn&lt;/code&gt; and &lt;code&gt;+python3/dyn&lt;/code&gt;. On Windows, this means that Vim is compiled to dynamically load the Python DLL. You can read about this in &lt;code&gt;:h python-dyanmic&lt;/code&gt;. Depending on the versions you install, you may want to look at &lt;code&gt;:h pythondll&lt;/code&gt; and &lt;code&gt;:h pythonthreedll&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you install Python 3, keep in mind that you will need to verify it with &lt;code&gt;:echo has('python3')&lt;/code&gt;. Additionally, if you want to install both Python 2 and 3, you will want to read &lt;code&gt;:h has-python&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I've checked the version settings and ensured the existence of both &lt;code&gt;+python/dyn&lt;/code&gt; and &lt;code&gt;+python3/dyn&lt;/code&gt;. I have the latest distribution of Python 3 (which, at this time, is 3.7.2), and have installed a 32-bit version of it so that it's compatible to my 32-bit gVim 8.1, as per the comment in the quoted answer:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Also be sure to use a 32-bit python with a 32-bit vim, or use a 64-bit version of both. If you mix them, vim will not be able to load the &lt;code&gt;dll&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;However, even after several reboots and re-installations, the command &lt;code&gt;:echo has('python3')&lt;/code&gt; still returns &lt;code&gt;0&lt;/code&gt;. How can I make sure that Python 3 is supported on Vim?&lt;/p&gt;&#xA;&lt;p&gt;I just wanted to use that YCM plugin...&lt;/p&gt;&#xA;" OwnerUserId="20750" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2021-08-25T13:49:55.363" Title="Getting Python support for gVim 8.1 (Windows 10)" Tags="|microsoft-windows|plugin-you-complete-me|plugin-python-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18735" PostTypeId="1" CreationDate="2019-01-29T05:15:31.140" Score="0" ViewCount="76" Body="&lt;p&gt;Is there some way to display an identifier as something else?&#xA;Imagine the following setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have a readme file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* &amp;lt;&amp;lt;123456&amp;gt;&amp;gt;&#xA;* &amp;lt;&amp;lt;789078&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This readme file is inside of a directory&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;├── README.txt&#xA;├── 123456.txt&#xA;└── 789078.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But now instead of displaying &lt;code&gt;123456&lt;/code&gt;, it would instead the first line of the file &lt;code&gt;123456.txt&lt;/code&gt;. I now a decent amount of Vimscript, but I don't know of any way to accomplish this, and I'm led to believe it's impossible. I know of &lt;code&gt;conceallevel&lt;/code&gt;, but that doesn't really help with it...&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2019-01-31T04:02:23.043" Title="Display the first line of some file instead of an identifier" Tags="|vimscript|multiple-files|conceal|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18736" PostTypeId="2" ParentId="18735" CreationDate="2019-01-29T11:50:59.430" Score="1" Body="&lt;p&gt;&lt;em&gt;I don't think you said whether a &quot;destructive&quot; approach was acceptable or not. That is, the change is not superficial in this solution (although you could &quot;undo&quot; out of it). In case a non-destructive option is not forthcoming I offer this...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're in a Unix-like environment&lt;sup&gt;1&lt;/sup&gt; (Linux, Mac, Windows+Cygwin) then you can send output from an appropriate shell command through a Vim filter like so...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\* &amp;lt;&amp;lt;[^&amp;gt;]\+&amp;gt;&amp;gt;/ exe '.!head -1 &quot;' . substitute(getline(&quot;.&quot;), &quot;^\* &amp;lt;&amp;lt;\\([^&amp;gt;]\\+\\)&amp;gt;&amp;gt;&quot;, &quot;\\1.txt&quot;, &quot;&quot;) . '&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Every line with the pattern you indicated will get processed so the proper filename is generated and then that is sent through a command (&lt;code&gt;head -1&lt;/code&gt; in this case) to get the first line. Thanks to the filter &lt;code&gt;:.!&lt;/code&gt; the result will replace the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can either run this manually (probably want to map it to a shortcut, though) or you can put it in an autocommand if there's a particular file type(s) that you always want to apply it to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll break it down in a bit more detail later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;sub&gt;If you're on straight Windows and know some Windows console command that extracts the first line of a file this can be made to work there, too.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Got to thinking how the above could be made non-destructive. Christian Brabandt mentioned use of &lt;code&gt;conceal&lt;/code&gt; in a comment and that's where my thinking is, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The change to the above is to append the first line of text rather than have it replace the original line. The original part is hidden with conceal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set conceallevel=3&#xA;syn match Conceal /^\* &amp;lt;&amp;lt;[^&amp;gt;]*&amp;gt;&amp;gt;&amp;lt;&amp;lt;/hs=s+2,he=e-2 conceal&#xA;&quot; would prefer to do this with a single global but for now...&#xA;g/\* &amp;lt;&amp;lt;[^&amp;gt;]\+&amp;gt;&amp;gt;/ s/$/\='&amp;lt;&amp;lt;' . system('head -1 &quot;' . substitute(getline(&quot;.&quot;), &quot;^\* &amp;lt;&amp;lt;\\([^&amp;gt;]\\+\\)&amp;gt;&amp;gt;&quot;, &quot;\\1.txt&quot;, &quot;&quot;) . '&quot;')&#xA;g/\* &amp;lt;&amp;lt;[^&amp;gt;]\+&amp;gt;&amp;gt;/ norm! gJA&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(BTW, upon rereading the question I think the idea is to have the first line of text just replace the text between &lt;code&gt;&amp;lt;&amp;lt; &amp;gt;&amp;gt;&lt;/code&gt; rather than replace the entire line. This part assumes that's correct.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To reverse the effect just use a global command to delete everything from the second &quot;&amp;lt;&amp;lt;&quot; to the end of the line. I can show those commands but I'm waiting to hear from OP if this is even what they have in mind.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-01-31T04:02:23.043" LastActivityDate="2019-01-31T04:02:23.043" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18737" PostTypeId="1" AcceptedAnswerId="18738" CreationDate="2019-01-29T11:51:55.070" Score="0" ViewCount="385" Body="&lt;p&gt;I just recently found a very nice command to search for a pattern in a document, and display all hits:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/pattern/z#.1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the command is a bit cumbersome to type, I would like to make a shortcut, so instead of typing the command above, I could simply type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sl pattern&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;sl&lt;/code&gt; stands for search &amp;amp; list, for lack of a better name.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder what is the best way to do this. I think one first needs to define a function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SearchList(pattern)&#xA;    f/a:pattern/z#.1&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the only thing the function does, is to show its own content (since this is the only occurrence of &lt;code&gt;a:pattern&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here I'm stuck. To create a mapping, is the function actually needed? Or what is the best way to define the mapping? And if indeed a function is the way to go, how would I write this function?&lt;/p&gt;&#xA;" OwnerUserId="6154" LastActivityDate="2019-01-29T12:59:58.707" Title="function to search for a pattern" Tags="|search|functions|global-command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18738" PostTypeId="2" ParentId="18737" CreationDate="2019-01-29T12:47:50.940" Score="6" Body="&lt;p&gt;To create a custom command line command &lt;a href=&quot;https://vimhelp.org/map.txt.html#:command&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:command&lt;/code&gt;&lt;/a&gt; is a good choice:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -nargs=1 SL g/&amp;lt;args&amp;gt;/z#.1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll need to use a name that starts with a capital letter, though, so I'm using &quot;SL&quot; instead of &quot;sl&quot;. Run with &lt;code&gt;:SL pattern&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rest is pretty self-explanatory. Use a bang (&lt;code&gt;!&lt;/code&gt;) after &lt;code&gt;:command&lt;/code&gt; to allow subsequent overrides (good for including it in your vimrc file). Specify number of args as 1. Insert that in the command to be run with &lt;code&gt;&amp;lt;args&amp;gt;&lt;/code&gt;. BTW, with &lt;code&gt;-nargs=1&lt;/code&gt; spaces are allowed in whatever comes after the command name (in our case the pattern) and it will still be considered one argument.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-01-29T12:59:58.707" LastActivityDate="2019-01-29T12:59:58.707" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18739" PostTypeId="1" AcceptedAnswerId="18740" CreationDate="2019-01-29T16:15:21.567" Score="2" ViewCount="715" Body="&lt;p&gt;I would like to use the arguments passed to a function, as an argument to replace a search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Myfunction(...)&#xA;    %s/hello/   goodBye a:1, a:2/g&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how it can be done?&lt;/p&gt;&#xA;" OwnerUserId="20762" LastEditorUserId="626" LastEditDate="2019-01-29T17:14:07.037" LastActivityDate="2019-01-30T12:08:01.847" Title="vim argument substitution inside a function" Tags="|substitute|replace|functions|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18740" PostTypeId="2" ParentId="18739" CreationDate="2019-01-29T18:09:36.503" Score="2" Body="&lt;p&gt;If you can have any number of parameters, you'd have the choice between the following (untested) solutions&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe '%s/hello/  goodbye '.join(a:000, ', ').'/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(expecting the parameters contain no backslashes) or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/hello/\='  goodbye '.join(a:000, ', ')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This second solution works only when the dynamic part is used in the replacement text, not in the searched pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3as%5c%3d&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :s\=&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#join%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h join()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3aexe&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :exe&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2019-01-30T12:08:01.847" LastActivityDate="2019-01-30T12:08:01.847" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18741" PostTypeId="1" CreationDate="2019-01-30T04:23:56.470" Score="1" ViewCount="131" Body="&lt;p&gt;I have this substitution, which does not work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe 's/&amp;lt;&amp;lt;\(.*\)\%(,.*\)\?&amp;gt;&amp;gt;/&amp;lt;&amp;lt;\1,'.system('ark headings \1 | head -1').'&amp;gt;&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I want to do is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;capture some expression within double angle brackets: &lt;code&gt;&amp;lt;&amp;lt;\(.*\)&amp;gt;&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;paste opening double angle brackets back, followed by expression and comma: &lt;code&gt;&amp;lt;&amp;lt;\1,&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and then paste it after filtering it through some external command: &lt;code&gt;system('foo \1 | head -1 | cut -f1')&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;follow it with the closing double angle brackets: &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But I can't get the expression to work...&lt;/p&gt;&#xA;" OwnerUserId="6300" LastActivityDate="2019-01-30T07:23:16.737" Title="Using submatches inside and outside of system() call" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18742" PostTypeId="2" ParentId="9982" CreationDate="2019-01-30T06:32:38.530" Score="1" Body="&lt;p&gt;When calling &lt;code&gt;sudoedit&lt;/code&gt; or &lt;code&gt;sudo -e&lt;/code&gt;, sudo will start the editor defined by the environment variables &lt;code&gt;SUDO_EDITOR&lt;/code&gt;, &lt;code&gt;VISUAL&lt;/code&gt; and &lt;code&gt;EDITOR&lt;/code&gt; (in that order) or will typically fall back to &lt;code&gt;vi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your screenshots, you can see that two different versions of Vim are called.&#xA;&lt;code&gt;vim&lt;/code&gt; calls a &quot;Huge version without gui&quot;, while &lt;code&gt;sudoedit&lt;/code&gt; calls a &quot;Small version without gui&quot;. Most likely the &quot;Small version...&quot; is called when you invoke &lt;code&gt;vi&lt;/code&gt;. The small version does not include syntax highlighting. See &lt;code&gt;:help +feature-list&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By setting &lt;code&gt;EDITOR=vim&lt;/code&gt; you tell &lt;code&gt;sudo&lt;/code&gt;, that it should start &lt;code&gt;vim&lt;/code&gt;. Hence you get the full feature set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whether &lt;code&gt;vi&lt;/code&gt; and &lt;code&gt;vim&lt;/code&gt; starts different executables is installation dependent. On my machine they both start the same version of Vim.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-30T06:32:38.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18743" PostTypeId="2" ParentId="18741" CreationDate="2019-01-30T06:44:41.553" Score="2" Body="&lt;p&gt;The &lt;code&gt;system&lt;/code&gt; function is called before the search-replace is executed. It is called to generate the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/&amp;lt;&amp;lt;\(.*\)\%(,.*\)\?&amp;gt;&amp;gt;/\='&amp;lt;&amp;lt;'.submatch(1).','.system('ark headings '.submatch(1).' | head -1').'&amp;gt;&amp;gt;'/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\=&lt;/code&gt; tells Vim that the substitute string is a expression, that should be evaluated on every replace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help sub-replace-expression&lt;/code&gt; and &lt;code&gt;:help submatch()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: I'm not sure what &lt;code&gt;&amp;lt;&amp;lt;\(.*\)\%(,.*\)\?&amp;gt;&amp;gt;&lt;/code&gt; should match. The &lt;code&gt;\(.*\)&lt;/code&gt; will match everything until the &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;. I guess you want &lt;code&gt;&amp;lt;&amp;lt;\([^,]*\).*&amp;gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;&amp;lt;\([^,]*\).\{-}&amp;gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-30T07:23:16.737" LastActivityDate="2019-01-30T07:23:16.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18744" PostTypeId="1" AcceptedAnswerId="18745" CreationDate="2019-01-30T15:57:34.673" Score="25" ViewCount="10242" Body="&lt;p&gt;&lt;em&gt;Note: this question has two sort of answers on StackOverflow but I thought perhaps a better answer would come from here, and, if not, at least it will be documented where it should be:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/45086981/what-are-the-vim-commands-that-start-with-g&quot;&gt;What are the vim commands that start with g?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/7632472/use-of-g-key-in-vim-normal-mode&quot;&gt;Use of g key in vim normal mode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;What is the semantic meaning of the letter &lt;code&gt;g&lt;/code&gt; in normal mode commands? I have used the heck out of &lt;code&gt;gg&lt;/code&gt;, &lt;code&gt;G&lt;/code&gt;, and &lt;code&gt;&amp;lt;n&amp;gt;G&lt;/code&gt;, but until today, I had never thought to find out what the semantics of &lt;code&gt;g&lt;/code&gt; are in the larger &lt;a href=&quot;https://stackoverflow.com/a/1220118/9691276&quot;&gt;Zen of Vi&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Today I had to lowercase a bunch of constants in my code, and I figured there had to be a better way than character by character (since &lt;code&gt;&amp;lt;n&amp;gt;~&lt;/code&gt; doesn't work, for whatever odd reason that I am unaware of). I found it in &lt;code&gt;g~&lt;/code&gt;, specifically &lt;code&gt;g~iw&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This led me to find the linked answers, but they have less than satisfying explanations, and are on StackOverflow, and not vi.SE, to boot.&lt;/p&gt;&#xA;&lt;p&gt;So,&lt;/p&gt;&#xA;&lt;h3&gt;What is the vi-semantic meaning of &lt;code&gt;g&lt;/code&gt;?&lt;/h3&gt;&#xA;&lt;p&gt;By vi-semantic meaning, I expect people to understand, as &lt;code&gt;ciw&lt;/code&gt; means change in word, so &lt;code&gt;c&lt;/code&gt; means change, &lt;code&gt;i&lt;/code&gt;, means inner text item, and &lt;code&gt;w&lt;/code&gt; means word delineated by space or punctuation excluding &lt;code&gt;_&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;P.S., how do I tag this?&lt;/p&gt;&#xA;" OwnerUserId="17830" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-01-31T22:07:33.583" Title="What is the meaning of 'g'?" Tags="|key-bindings|normal-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18745" PostTypeId="2" ParentId="18744" CreationDate="2019-01-30T16:46:59.607" Score="24" Body="&lt;p&gt;&lt;kbd&gt;g&lt;/kbd&gt; is a little bit of a weird key in vim. A lot of other keys have a specific word to describe their category:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;h&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, &lt;code&gt;l&lt;/code&gt;, &lt;code&gt;}&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt;, &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;e&lt;/code&gt;, etc. are all &lt;em&gt;motions&lt;/em&gt;. They tell your cursor to move.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;d&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, etc. are all &lt;em&gt;operators&lt;/em&gt;. They change the text they operate on in a specific way, and you tell them what text to operate on by giving a &lt;em&gt;motion&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g&lt;/code&gt; does not have a name like this. If I had to come up with a name, I would call it a &lt;em&gt;namespace&lt;/em&gt;. Bram Moolenaar and Bill Joy I'm sure had many useful operations (such as go the beginning/end of the file, or go to &lt;code&gt;[line]&lt;/code&gt;) that make sense to create a shortcut for in default vim, but they're not going to be used often enough to justify giving them a one-key shortcut, since these are reserved for the more useful/frequently used things like &lt;code&gt;hjkl&lt;/code&gt;, or &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt;, and there's only 95 keys to pick from. &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/vimindex.html#g&quot; rel=&quot;noreferrer&quot;&gt;There are &lt;em&gt;tons&lt;/em&gt; of keyboard shortcuts that all start with &lt;code&gt;g&lt;/code&gt;.&lt;/a&gt; What do they have in common? Absolutely nothing. They just happen to be useful things to have that aren't worth giving a one-key shortcut for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So really, &lt;code&gt;gg&lt;/code&gt; is a motion just like all the other motions I listed, it just happens to use a two-key sequence. &lt;code&gt;g~&lt;/code&gt; is an operator just like all the other operators I listed, it just happens to use a two-key sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several other &lt;em&gt;&quot;namespace&quot;&lt;/em&gt; like keys in vim. For example, look up in help&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h z&lt;/code&gt; (Commands that start with 'z')&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h [&lt;/code&gt; (Commands that start with '[')&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2019-01-31T22:07:33.583" LastActivityDate="2019-01-31T22:07:33.583" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="18746" PostTypeId="1" CreationDate="2019-01-30T19:50:37.797" Score="2" ViewCount="387" Body="&lt;p&gt;&lt;strong&gt;Issue&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Vim within an activated Python virtual environment i.e. I have run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python3 -m pip venv env&#xA;. env/bin/activate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However when I am editing a Python file, then Ale is complaining about import errors for third party packages. These are definitely installed inside the virtual environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Investigation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Upon further investigation I noticed the following issue. Running inside Vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py3 import sys, site; print('Version:', sys.version); print('Executable:', sys.executable); print('Site Packages:', site.getsitepackages())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives the output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Version: 3.5.2 (default, Nov 12 2018, 13:43:14)                                                                                                                                                             &#xA;[GCC 5.4.0 20160609]                                                                                                                                                                                        &#xA;Executable: /home/rob/Documents/misc/benchmarks/env/bin/python3                                                                                                                                             &#xA;Site Packages: ['/home/rob/Documents/misc/benchmarks/env/lib/python3.5/site-packages', '/home/rob/Documents/misc/benchmarks/env/local/lib/python3.5/dist-packages', '/home/rob/Documents/misc/benchmarks/env/lib/python3/dist-packages', '/home/rob/Documents/misc/benchmarks/env/lib/python3.5/dist-packages']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue here is that I am using Python3.6. Hence the above site packages don't even exist. This is indicated, as while it says the Python version is 3.5.2, if I run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/rob/Documents/misc/benchmarks/env/bin/python3 --version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Python 3.6.8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence the version and executable are not matching up within Vim. Is there a way to fix this and will it fix my false import errors with Ale?&lt;/p&gt;&#xA;" OwnerUserId="3155" LastActivityDate="2019-01-30T19:50:37.797" Title="Vim using wrong executable and site packages in Python venv" Tags="|vimscript-python|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18747" PostTypeId="2" ParentId="18734" CreationDate="2019-01-31T05:48:45.757" Score="9" Body="&lt;p&gt;With dynamic python, the name of the python DLL (or shared object on Unix) is defined at compile time. In your case it is &lt;code&gt;python36.dll&lt;/code&gt;. As you now want to use a different python version, this name needs to be changed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this Vim has the option &lt;code&gt;pythonthreedll&lt;/code&gt; (and &lt;code&gt;pythondll&lt;/code&gt; for python2). Set it to the name of DLL you want to load. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set pythonthreedll=python37.dll&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this doesn't work you can also set the full path to that library. In that case you might also need to set &lt;code&gt;pythonthreehome&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set pythonthreedll=c:\path\to\python\python37.dll&#xA;set pythonthreehome=c:\path\to\python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;AFAIK this second way is needed, when python was not installed but just unpacked. In that case, the DLL is not registered to Windows and hence can't be found by name.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-01-31T05:48:45.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18748" PostTypeId="2" ParentId="18732" CreationDate="2019-01-31T07:27:14.827" Score="0" Body="&lt;p&gt;I don't think vim can do what you want (highlight region in a start match of another region -- in terms of vim regions)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you can do simpler thing (in case you didn't find it in a documentation) -- highlight start and end of a region with a different highlight group:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fbgmp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fbgmp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region xBlock matchgroup=String start=&quot;abcde::&quot; end=&quot;;&quot;&#xA;hi link xBlock Todo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-01-31T07:27:14.827" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18749" PostTypeId="2" ParentId="18701" CreationDate="2019-01-31T08:57:21.217" Score="4" Body="&lt;p&gt;The error you see, comes from the plugin &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/plugin/matchparen.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;matchparen&lt;/a&gt;, that is distributed with vim and which does highlight the matching parenthesis as you edit them. Internally is uses the &lt;code&gt;searchpairpos()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting with Vim patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.0112&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.0112&lt;/a&gt;, Vim will throw an error, if the &lt;code&gt;skip&lt;/code&gt; argument for the functions &lt;code&gt;searchpair()&lt;/code&gt; and &lt;code&gt;searchpairpos()&lt;/code&gt; is not a string argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That caused the error message &lt;code&gt;invalid argument: 0&lt;/code&gt;, because the two plugins &lt;code&gt;matchparen&lt;/code&gt; and &lt;code&gt;matchpair&lt;/code&gt; that come with Vim, used a skip expression of &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a bit later, those two plugins have been changed to make use of a skip expression of &lt;code&gt;'0'&lt;/code&gt;. So patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.0115&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.115&lt;/a&gt; fixed the matchparen plugin and patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.0143&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.143&lt;/a&gt; fixed a related problem with the matchit and matchparen plugin, that should keep Vim responsive, even when the pattern is not found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still see the error, even after you have installed a Vim version later than 8.1.143, that means you most likely have an older matchparen plugin laying around and are not using the latest version that comes with Vim. So make so to update the runtime files properly and delete older plugins in case you have them in your local &lt;code&gt;.vim&lt;/code&gt; path as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The related issue in the Vim bug tracker is &lt;a href=&quot;https://github.com/vim/vim/issues/3225&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/issues/3225&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-01-31T09:06:05.207" LastActivityDate="2019-01-31T09:06:05.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18751" PostTypeId="2" ParentId="18702" CreationDate="2019-01-31T11:03:48.107" Score="1" Body="&lt;p&gt;How about &lt;code&gt;inoremap jk &amp;lt;c-O&amp;gt;&amp;lt;esc&amp;gt;&lt;/code&gt;?&#xA;&lt;code&gt;&amp;lt;c-O&amp;gt;&lt;/code&gt; in insert mode is executing one command and return to insert mode. So it executes &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; and return to insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though it is unable for me to explain precisely because it is depended on Vim's specification, I guess that it is because when you map &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; to some keys, it will be executed as one general command, not as &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, and Vim records one set of strokes for insert mode from enter to it to press &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;. The command we define seems not to be regarded as &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; even if it includes &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; inside.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vim.wikia.com/wiki/Helps_undo_1_line_when_entered_many&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt; and &lt;code&gt;:help i_CTRL-G_u&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="20737" LastEditorUserId="20737" LastEditDate="2019-01-31T11:36:06.190" LastActivityDate="2019-01-31T11:36:06.190" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18754" PostTypeId="1" AcceptedAnswerId="18756" CreationDate="2019-01-31T14:21:02.943" Score="3" ViewCount="4069" Body="&lt;p&gt;Sometime there is &lt;strong&gt;0xa0&lt;/strong&gt; in my code, which causes compile error and hard to find out where it is because it's invisible.. I searched on google and found &lt;code&gt;set listchars=nbsp:.&lt;/code&gt; can make the &lt;strong&gt;0xa0&lt;/strong&gt; visible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to enable &lt;code&gt;listchars&lt;/code&gt; permanently, but it requires &lt;code&gt;set list&lt;/code&gt;, which causes tabs are displayed as '^I'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I enable &lt;code&gt;set list&lt;/code&gt; and make tabs remain unchanged?&lt;/p&gt;&#xA;" OwnerUserId="6971" LastActivityDate="2019-01-31T20:26:12.837" Title="How to show tabs normally when 'set list'?" Tags="|gvim|listchars|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18755" PostTypeId="2" ParentId="18754" CreationDate="2019-01-31T15:18:50.223" Score="2" Body="&lt;p&gt;One slightly hacky workaround that I’m not entirely satisfied with is to use the space character for listchars tab:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'set listchars+=tab:  '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that there are &lt;strong&gt;2&lt;/strong&gt; spaces; the first character traditionally represents the start of a tab, and the second character is used for the &quot;filler&quot; space.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use myself a value more like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'set listchars+=tab:» '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that I can see where the tabs are.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-01-31T15:18:50.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18756" PostTypeId="2" ParentId="18754" CreationDate="2019-01-31T15:19:16.470" Score="4" Body="&lt;p&gt;Displaying &lt;code&gt;^I&lt;/code&gt; for tab is the default Vi behavior. You could set the list character for tab to a spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set listchars=nbsp:×,tab:\ \ ,trail:\ ,&#xA;set list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I have added a definition for trailing spaces (to be displayed as spaces). Without it, the nbsp is not displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Alternative:&lt;/strong&gt; Use Syntax highlighting&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Syntax * syntax match NBSP &quot;[\xa0]&quot; containedin=ALL | highlight link NBSP Error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-01-31T20:26:12.837" LastActivityDate="2019-01-31T20:26:12.837" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="18757" PostTypeId="2" ParentId="8693" CreationDate="2019-01-31T20:51:32.333" Score="2" Body="&lt;p&gt;EDIT: Simpler way is to do &lt;code&gt;:tab terminal&lt;/code&gt;, thanks to comment on this post&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ORIGINAL ANSWER:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this is an old post, but if anyone arrived here from google, as I did, you can open a new tab with &lt;code&gt;:tabe&lt;/code&gt;, type &lt;code&gt;:terminal&lt;/code&gt;, which will open a shell in that tab, and then close the empty editor with &lt;code&gt;:q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure if there's a more elegant solution, but this achieves what is asked without any plugins. &lt;code&gt;:terminal&lt;/code&gt; Was introduced to vim in vim 8&lt;/p&gt;&#xA;" OwnerUserId="20798" LastEditorUserId="20798" LastEditDate="2019-01-31T21:28:08.317" LastActivityDate="2019-01-31T21:28:08.317" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18758" PostTypeId="1" AcceptedAnswerId="18759" CreationDate="2019-02-01T01:30:43.440" Score="0" ViewCount="47" Body="&lt;p&gt;How could I encode space in .vimrc? This is required here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list&#xA;set listchars=tab:→\ ,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you see, I use comma to workaround this issue, but I want something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list&#xA;set listchars=tab:→{U+0020}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7169" LastActivityDate="2019-02-01T15:54:51.680" Title="To encode trailing space with something like {U+0020}" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18759" PostTypeId="2" ParentId="18758" CreationDate="2019-02-01T04:42:04.697" Score="1" Body="&lt;p&gt;The solution is to just use a literal space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply use &lt;code&gt;execute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'set listchars=tab:&amp;gt; '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, as &lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;Christian Brabandt&lt;/a&gt; points out in the &lt;a href=&quot;https://vi.stackexchange.com/questions/18758/to-encode-trailing-space-with-something-like-u0020/18759?noredirect=1#comment32367_18759&quot;&gt;comments&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Alternatively, you can use &lt;code&gt;let &amp;amp;listchars=&quot;tab:&amp;gt;\u0020&quot;&lt;/code&gt;, see &lt;code&gt;:h expr-quote&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that unicode sequences may be entered via &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; if it is followed by a 0, x, or other specifiers (they determine the « format » of the following code). &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-02-01T15:54:51.680" LastActivityDate="2019-02-01T15:54:51.680" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18760" PostTypeId="2" ParentId="11685" CreationDate="2019-02-01T08:14:55.873" Score="4" Body="&lt;p&gt;I have similar issue. The culprit is the &lt;strong&gt;space between patterns&lt;/strong&gt;, like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;*.html,&lt;/code&gt; and &lt;code&gt;*.css&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Removing &lt;strong&gt;the space&lt;/strong&gt; should fix it. Good luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference &gt; &lt;a href=&quot;https://stackoverflow.com/questions/45416839/error-detected-while-processing-bufread-auto-commands-for-py&quot;&gt;https://stackoverflow.com/questions/45416839/error-detected-while-processing-bufread-auto-commands-for-py&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20806" LastActivityDate="2019-02-01T08:14:55.873" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18761" PostTypeId="1" AcceptedAnswerId="18762" CreationDate="2019-02-01T10:40:59.873" Score="8" ViewCount="1892" Body="&lt;p&gt;I have made a mapping &lt;code&gt;xnoremap j; &amp;lt;Esc&amp;gt;&lt;/code&gt; where &lt;code&gt;j;&lt;/code&gt; puts you into normal mode if you're in visual mode. Having this mapping in my vimrc slows down visual selection.  I can't figure out why this is the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: If you select a line in visual selection mode and move a line down you have to wait a few seconds before the selection updates.&lt;/p&gt;&#xA;" OwnerUserId="20735" LastActivityDate="2019-02-18T11:19:54.970" Title="Why does xnoremap mapping make visual selection slow?" Tags="|vimrc|key-bindings|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18762" PostTypeId="2" ParentId="18761" CreationDate="2019-02-01T10:45:19.587" Score="13" Body="&lt;p&gt;Well, whenever you hit &lt;code&gt;j&lt;/code&gt; vim has to wait. Is it a &quot;real&quot; &lt;code&gt;j&lt;/code&gt; and the user wants to move down, or is he/she entering an additional &lt;code&gt;;&lt;/code&gt; to trigger the mapping &lt;code&gt;j;&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess you should chose another mapping. &lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-01T10:45:19.587" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18765" PostTypeId="1" AcceptedAnswerId="18795" CreationDate="2019-02-01T21:05:12.807" Score="2" ViewCount="250" Body="&lt;p&gt;I PGP sign my commit messages, and every once in a while GPG will fail for whatever reason (invalid cache, incorrect pin, etc), and my fugitive buffer will close, loosing all my changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't happen often, but when it does it's really frustrating because I like to write thorough commit messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, does anyone have a suggestion of how to retrieve the message I wrote after the commit fails?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="14" LastActivityDate="2019-02-09T19:54:35.393" Title="Retrieving failed fugitive commit message" Tags="|git|plugin-fugitive|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18766" PostTypeId="1" AcceptedAnswerId="18769" CreationDate="2019-02-01T21:30:32.673" Score="1" ViewCount="588" Body="&lt;p&gt;How could I replace text in status line flags?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set laststatus=2&#xA;set statusline=&#xA;set statusline+=%r%m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to replace &lt;code&gt;[RO]&lt;/code&gt; to &lt;code&gt;Read only&lt;/code&gt;, and &lt;code&gt;[+]&lt;/code&gt; to &lt;code&gt;Modified&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="7200" LastActivityDate="2019-02-01T22:56:07.010" Title="Replace text in status line flags" Tags="|vimrc|statusline|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18767" PostTypeId="1" AcceptedAnswerId="18770" CreationDate="2019-02-01T21:42:41.633" Score="0" ViewCount="27" Body="&lt;p&gt;When I search for a word in my files, many of them come up, and it's tough to tell which one my cursor is currently over. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See image: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jxAk4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jxAk4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to edit the background color for the search I'm currently on? It would be great to turn the whole word a different color, instead of just the first character. You can't see it when the screenshot tool is open, but the actual effect is that the letter &lt;code&gt;e&lt;/code&gt; that's currently outlined in fact inverts the foreground and background colors. That effect is great, but any way I can apply it to the whole word?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other ideas on how to know which one I'm on are welcome : )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the current lines in my color file that might be relevant:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi IncSearch    ctermfg=0   guifg=#000000 ctermbg=223 guibg=#ffdfaf cterm=none gui=none&#xA;hi Search       ctermfg=0   guifg=#000000 ctermbg=149 guibg=#afdf5f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1596" LastActivityDate="2019-02-01T22:20:36.933" Title="Edit colorscheme to tell me which search result my cursor is currently on" Tags="|search|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18768" PostTypeId="1" AcceptedAnswerId="18785" CreationDate="2019-02-01T21:51:27.430" Score="2" ViewCount="2608" Body="&lt;p&gt;Currently I highlight these with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set listchars=tab:▶—,trail:␣,nbsp:⍽&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the drawback is I cannot usefully copy-paste from the terminal where vim resides to another one: e.g. suppose I'm editing a shell script and want to test some of the lines in a shell, it will choke on the &lt;code&gt;▶&lt;/code&gt;'s and &lt;code&gt;—&lt;/code&gt;'s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm looking into highlighting these &quot;listchars&quot; by colors. I found the following trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set listchars=tab:\ \ ,trail:\ ,nbsp: &#xA;:highlight SpecialKey ctermbg=7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is quite good, however they all have the same color. Is there a way to display them in different colors? &lt;a href=&quot;https://vi.stackexchange.com/a/10542/7824&quot;&gt;This&lt;/a&gt; may be relevant but I'm not vim-savvy enough to adapt it to my case :)&lt;/p&gt;&#xA;" OwnerUserId="7824" LastActivityDate="2019-02-03T04:21:50.397" Title="Highlighting tabs, trailing space and non-breaking space by colors, not chars" Tags="|highlight|listchars|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18769" PostTypeId="2" ParentId="18766" CreationDate="2019-02-01T21:57:02.030" Score="1" Body="&lt;p&gt;You can use conditional expressions when defining the statusline. Like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{&amp;amp;modified?\&quot;Modified\&quot;:\&quot;\&quot;}&#xA;set statusline+=%{&amp;amp;readonly?\&quot;Read\ Only\&quot;:\&quot;\&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'statusline'&lt;/code&gt; (it's a long text).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;amp;modified&lt;/code&gt; is the notation to access a option from Vim script. As &lt;code&gt;modified&lt;/code&gt; and &lt;code&gt;readonly&lt;/code&gt; are are boolean options, you can test them as shown above. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check for a help file you would need:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{&amp;amp;ft==\&quot;help\&quot;?\&quot;HELP\ ME\&quot;:\&quot;\&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;ft&lt;/code&gt; is short for the option &lt;code&gt;filetype&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At some point you might be better off by moving all this stuff into a function to return the statusline. Like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%!MyStatuslineFunction()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The plugin &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-airline&lt;/a&gt; does it this way.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-01T22:56:07.010" LastActivityDate="2019-02-01T22:56:07.010" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18770" PostTypeId="2" ParentId="18767" CreationDate="2019-02-01T22:20:36.933" Score="2" Body="&lt;p&gt;It looks like &lt;a href=&quot;https://github.com/timakro/vim-searchant&quot; rel=&quot;nofollow noreferrer&quot;&gt;timakro/vim-searchant&lt;/a&gt; should do what you want:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WPRnT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WPRnT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will set the current word red, although you can override it to some other color if you want. &lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-02-01T22:20:36.933" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18771" PostTypeId="1" AcceptedAnswerId="18774" CreationDate="2019-02-01T23:50:05.027" Score="3" ViewCount="5355" Body="&lt;p&gt;I'm trying to use indent size as variable, but it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let indent=4&#xA;set tabstop=&amp;amp;indent&#xA;set softtabstop=&amp;amp;indent&#xA;set shiftwidth=&amp;amp;indent&#xA;set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried both &lt;code&gt;&amp;amp;indent&lt;/code&gt; and &lt;code&gt;%(&amp;amp;indent)&lt;/code&gt; - just guessing, but it still broken.&lt;/p&gt;&#xA;" OwnerUserId="20821" LastActivityDate="2019-02-02T09:39:09.877" Title="How to use variables?" Tags="|vimrc|variables|" AnswerCount="2" CommentCount="8" ClosedDate="2019-02-03T22:34:44.707" ContentLicense="CC BY-SA 4.0" />
  <row Id="18772" PostTypeId="2" ParentId="18722" CreationDate="2019-02-02T03:33:56.797" Score="3" Body="&lt;p&gt;&lt;em&gt;Things have evolved quite a bit since this was posted and there is apparently now support for vimscript parsing. I'll update this once I learn the details. In the meantime, see other answers.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Generally speaking ideavim can handle consuming of native vimrc. That's because it doesn't actually parse it as vimscript. It just does pattern matching so anything non-compatible is skipped over. Most people get away with this just fine...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;source ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And that command is recommended on &lt;a href=&quot;https://github.com/JetBrains/ideavim&quot; rel=&quot;nofollow noreferrer&quot;&gt;ideamvim's github homepage&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, if you want to pick and choose parts of vimrc to include there's no proper way. But there is a workaround based on the aforementioned fact that ideavim isn't a vimscript parser....you can source things in vimrc that you don't want sourced by ideamvim using this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;exe &amp;quot;source ~/someconfig.vim&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Ideavim will skip over such lines so you could have common stuff in vimrc and source vim-only stuff by way of the above command. Then you can safely source vimrc in ideavim.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; To reiterate, ideavim does not have a vimscript/VimL interpreter. It does a simple pattern-based scan of any sourced vimrc file, recognizing a few directives/commands...&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Currently IdeaVim parses several .vimrc commands (:set, :map, :source,&#xA;etc.) via pattern matching, i. e. it doesn't fully understand syntax&#xA;of Vim configuration files.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The above quote is from &lt;a href=&quot;https://youtrack.jetbrains.com/issue/VIM-669&quot; rel=&quot;nofollow noreferrer&quot;&gt;an issue in the ideavim bug tracker&lt;/a&gt; that is requesting more expansive capabilities in this area.&lt;/p&gt;&#xA;&lt;p&gt;Until/unless there are any such enhancements made, the things OP would like to do (e.g. conditional sourcing based on environment via something like &lt;code&gt;if has('win32') ... endif&lt;/code&gt;) are not possible except to the limited extent that I mention above and which is also discussed on Stack Overflow &lt;a href=&quot;https://stackoverflow.com/questions/34528322/how-to-include-only-some-of-vimrc-in-ideavimrc&quot;&gt;How To Include Only Some of Vimrc in IdeaVimrc&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2024-03-09T22:26:04.630" LastActivityDate="2024-03-09T22:26:04.630" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18773" PostTypeId="1" AcceptedAnswerId="18776" CreationDate="2019-02-02T08:44:02.560" Score="3" ViewCount="1537" Body="&lt;p&gt;Cluttering Swaps and Backups that I never use are so annoying and takes up unnecessary space. Is there a way to delete them as one quits vim with &lt;code&gt;:q&lt;/code&gt; and similar quitting commands?&lt;/p&gt;&#xA;" OwnerUserId="20750" LastEditorUserId="1292" LastEditDate="2019-02-06T15:02:09.163" LastActivityDate="2019-02-06T15:02:09.163" Title="Auto-Deleting Swaps, Backups and Undos while Quitting vim?" Tags="|gvim|microsoft-windows|swap-file|backup|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18774" PostTypeId="2" ParentId="18771" CreationDate="2019-02-02T09:28:23.500" Score="5" Body="&lt;p&gt;Most is already in the comments, but to summarize:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let indent=4&#xA;let &amp;amp;tabstop=indent&#xA;let &amp;amp;softtabstop=indent&#xA;let &amp;amp;shiftwidth=indent&#xA;set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to set a setting (like &lt;code&gt;tabstop&lt;/code&gt;) to the value of a variable, you have to Vim script expressions instead of set-expressions. In that case, settings are given with a leading &lt;code&gt;&amp;amp;&lt;/code&gt;. &lt;code&gt;indent&lt;/code&gt; is a Vim script variable so NO &lt;code&gt;&amp;amp;&lt;/code&gt; is needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See it as namespaces. The leading &lt;code&gt;&amp;amp;&lt;/code&gt; tells that the following name is from the namespace &quot;Vim settings&quot;. Like a leading &lt;code&gt;$&lt;/code&gt; tells, that the following name is from the namespace &quot;environment variables&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the following two lines leads to identical results.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4&#xA;let &amp;amp;tabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4&#xA;let &amp;amp;softtabstop=&amp;amp;tabstop&#xA;let &amp;amp;shiftwidth=&amp;amp;tabstop&#xA;set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another way to achieve the same (also NOT recommended in this scenario) is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let indent=4&#xA;execute &quot;set tabstop=&quot; . indent&#xA;execute &quot;set softtabstop=&quot; . indent&#xA;execute &quot;set shiftwidth=&quot; . indent&#xA;set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-02T09:28:23.500" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18775" PostTypeId="2" ParentId="18771" CreationDate="2019-02-02T09:39:09.877" Score="3" Body="&lt;p&gt;If you want to have all tabstop related settings follow each other, it is best to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4      &quot; set to specific value here, that you want to use&#xA;set shiftwidth=0   &quot; follow tabstop setting&#xA;set softtabstop=-1 &quot; follow shiftwidth setting&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will also work for the vartabfeature (since patch 8.1.542).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-02-02T09:39:09.877" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18776" PostTypeId="2" ParentId="18773" CreationDate="2019-02-02T12:13:26.737" Score="2" Body="&lt;p&gt;As Christian pointed out in his comment, there are some risks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Swap-Files: They are deleted automatically on Vim exit. If you have swap files lying around, they are most likely from abnormal terminations (terminal close or reboot while Vim still running or crash).  In that cases it might be worth to check the files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To disable backup files, I would propose the following for your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set writebackup&#xA;set nobackup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This settings writes a backup file while saving. After saving was successful, the backup file is deleted. This is a safety net in case Vim crashes while writing the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;BTW: I had (rare) cases, where I was really happy that I had a backup file.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, and undo files is easy. Add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noundofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then undo is only held in memory and does not survive multiple edit sessions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Doing &lt;code&gt;set noundofile&lt;/code&gt; at runtime, does not delete an existing undo file.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Another idea for backup files&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a directory to hold &lt;em&gt;all&lt;/em&gt; backup files. Let's say &lt;code&gt;$HOME/vimbackup&lt;/code&gt;. Then add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set backupdir=$HOME/vimbackup//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The two trailing slashes are important! Even on Windows use &lt;code&gt;//&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then Vim will create all backup files in that directory. Because of the trailing &lt;code&gt;//&lt;/code&gt; It will create filenames that contain the entire path. Like &lt;code&gt;%home%user%bin%script.sh~&lt;/code&gt;. Without the trailing slashes, it will just use plain file names, like &lt;code&gt;script.sh~&lt;/code&gt;, which is bad if you have the same file name in different directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this the backups are there, when you need them, but will not pollute your working directories. Well, you have to clean up from time to time.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(Unix only, I guess you are on Windows) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding backup files: I let Vim write backup files. So some of my code directories are scattered with backup files. If I decide to get rid of them all (e.g. after I committed the stuff), I have a bash shell function &lt;code&gt;rmbak&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;rmbak()&#xA;{&#xA;    typeset opt OPTIND OPTARG depth=&quot;-maxdepth 1&quot; action=&quot;-delete&quot;&#xA;    while getopts &quot;:rn&quot; opt; do&#xA;        case &quot;$opt&quot; in&#xA;            r) depth='' ;;&#xA;            n) action='' ;;&#xA;            &quot;?&quot;)&#xA;                echo &amp;gt;&amp;amp;2 &quot;Invalid option: -$OPTARG&quot;&#xA;                echo &amp;gt;&amp;amp;2 &quot;USAGE: rmbak [-rn]&quot;&#xA;                echo &amp;gt;&amp;amp;2 &quot;  -r recursive&quot;&#xA;                echo &amp;gt;&amp;amp;2 &quot;  -n print files but don't delete&quot;&#xA;                return 1&#xA;                ;;&#xA;        esac&#xA;    done&#xA;    find . $depth -name \*~ -type f -print $action&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-02T14:31:05.020" LastActivityDate="2019-02-02T14:31:05.020" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18777" PostTypeId="1" AcceptedAnswerId="18830" CreationDate="2019-02-02T12:43:28.677" Score="1" ViewCount="1240" Body="&lt;p&gt;Since Vim considers paragraphs as lines/sentences separated by blank lines the paragraph movement with &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; feels little weird to me as it takes you to the next blank line and you always have to press either &lt;code&gt;w&lt;/code&gt; or &lt;code&gt;j&lt;/code&gt; to go to the actual text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So i thought of remapping this behaviour, the forward movement is pretty simple as you can create a mapping like below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap } }w&#xA;nmap } }j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I am not able to create a mapping to create a mapping to move backward because it kind of creates a loop&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap { {j&#xA;nmap { {w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above mappings do not seem to work because once you move down with &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;w&lt;/code&gt; the next &lt;code&gt;{&lt;/code&gt; will again takes you back to empty line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there any work around to this ?&lt;/p&gt;&#xA;" OwnerUserId="18373" LastActivityDate="2019-02-08T11:06:13.997" Title="Move to first word of paragraph in vim with { and }" Tags="|navigation|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18778" PostTypeId="2" ParentId="18733" CreationDate="2019-02-02T12:43:58.490" Score="1" Body="&lt;p&gt;Include a call to &lt;code&gt;sort()&lt;/code&gt; with a custom sorting function. This works for me based on your description:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; custom function that sorts the items by the 'text' key&#xA;function! Sorter(i1, i2) abort&#xA; return a:i1['text'] == a:i2['text'] ? 0 : a:i1['text'] &amp;gt; a:i2['text'] ? 1 : -1&#xA;endfunction&#xA;&#xA;function! Overview() abort&#xA;    0&#xA;    let bufnr = bufnr('%')&#xA;    let items = []&#xA;    while 1&#xA;        let start = search('^{', 'cW')&#xA;        if !start&#xA;            break&#xA;        endif&#xA;        let end = search('^}', 'W')&#xA;        let lines = getline(start, end)&#xA;        let lines = map(lines, 'trim(v:val)')&#xA;        call add(items, {&#xA;            \ 'bufnr': bufnr,&#xA;            \ 'lnum': start,&#xA;            \ 'text': join(lines, ' '),&#xA;        \ })&#xA;    endwhile&#xA;    &quot; sort using the Sorter function to compare items&#xA;    call sort(items, 'Sorter')&#xA;    call setloclist(winnr(), items)&#xA;    lopen&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also &lt;code&gt;:help sort()&lt;/code&gt; for more information.&lt;/p&gt;&#xA;" OwnerDisplayName="user4879" LastActivityDate="2019-02-02T12:43:58.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18780" PostTypeId="1" CreationDate="2019-02-02T16:32:37.743" Score="1" ViewCount="125" Body="&lt;p&gt;I have this little augroup that contains a simple autocommand&#xA;that hides the &lt;code&gt;/home/devs/&lt;/code&gt; text on top of nerdtree:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup HideHOME&#xA;  autocmd! FileType nerdtree&#xA;  autocmd FileType nerdtree syntax match NERDTreeHideCWD &#xA;        \ #^[&amp;lt;/]home[/]devs[/]# conceal&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works well on my neovim setup.. but not on vim(8.1),&#xA;I even tried pasting this into a separate file then source&#xA;using &lt;code&gt;vim -u HideHome.vim&lt;/code&gt; but it still doesn't work..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The weird thing is when I typed it manually on the commandline it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:syntax match NERDTreeHideCWD #^[&amp;lt;/]home[/]devs[/]# conceal&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;they also have the same &lt;code&gt;concealcursor&lt;/code&gt; and &lt;code&gt;conceallevel&lt;/code&gt; values so what might be the problem in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Okay I still don't know what's the cause but I'm sourcing this from the system-wide vimrc in /usr/local/share/vim/vim81/vimrc and when I tried from ~/vimrc it works.. If anybody can enlighten me I'll gladly accept it as the answer.&lt;/p&gt;&#xA;" OwnerUserId="18514" LastEditorDisplayName="user4879" LastEditDate="2019-02-04T06:26:33.533" LastActivityDate="2019-02-04T06:26:33.533" Title="Why does this autocommand works on neovim but not on vim?" Tags="|vimscript|autocmd|conceal|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18782" PostTypeId="1" CreationDate="2019-02-02T19:00:16.887" Score="2" ViewCount="2867" Body="&lt;p&gt;I'm trying to understand what does exclamation mark after autocommands mean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes it is possible to see something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LangSpecificOptions()&#xA;  if (&amp;amp;filetype == 'markdown' || &amp;amp;filetype == 'html')&#xA;    set wrap&#xA;  else&#xA;    set nowrap        &#xA;  endif&#xA;endfunction&#xA;autocmd! BufReadPost,BufNewFile * call LangSpecificOptions()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I already found what &quot;!&quot; means when placed after the function:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Bao Niu:&lt;/strong&gt; I am learning Vimscript and I wonder if there is any difference between writing &quot;function!&quot; vs. &quot;function&quot;? What is that exclamation point for here? &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Tim Chase:&lt;/strong&gt; As detailed at &lt;code&gt;:help E123&lt;/code&gt;, if a function already exists with the same name as you want to &#xA;  create, the &quot;!&quot; will tell it to overwrite the previously-existing &#xA;  function.  Thus, you might have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Hello() &#xA;  echo 'Hello' &#xA;endfunction &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;and then want to change it, so you'd use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Hello() &#xA;  echoerr 'Hello' &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;to overwrite it.  Because of the behavior, I just use the &quot;!&quot; &lt;em&gt;every&lt;/em&gt; &#xA;  time that I define a function.  That way, I don't have to think about &#xA;  whether it already exists or not. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Source: &lt;a href=&quot;http://vim.1045645.n5.nabble.com/why-quot-function-quot-instead-of-just-quot-function-quot-td5723708.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.1045645.n5.nabble.com/why-quot-function-quot-instead-of-just-quot-function-quot-td5723708.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, I haven't found similar explanation for autocommands.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Edit:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;As it correctly stated in comments by @mass, &quot;!&quot; after autocommands mean that this autocommand should be removed. Well, then another question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the purpose of removing autocommands?&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="7200" LastEditDate="2019-02-02T22:12:33.480" LastActivityDate="2019-02-02T22:12:33.480" Title="Exclamation mark after autocommands" Tags="|vimrc|autocmd|functions|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18784" PostTypeId="1" CreationDate="2019-02-03T01:35:29.627" Score="2" ViewCount="84" Body="&lt;p&gt;Would like to maintain the concealed text in the locationlist (aka quickfix) from the targeted file, which has the extension .rex .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the target file is  has:&#xA;+-&#xA;concealed to&#xA;±&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quicklist still shows &#xA;+-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is an example which contain a small portion of concealed text. I also have a concealed text which has more characters, and would be nice to shorten to have more space for other information.&lt;/p&gt;&#xA;" OwnerUserId="20828" LastActivityDate="2019-02-03T09:20:25.977" Title="Maintain concealed text in quickfix buffer" Tags="|quickfix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18785" PostTypeId="2" ParentId="18768" CreationDate="2019-02-03T02:18:59.780" Score="2" Body="&lt;p&gt;This appears to be an example of the &lt;a href=&quot;https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem/66378&quot;&gt;XY problem&lt;/a&gt;. @b-layer has pointed out in the comments that there is likely to be limited success with individually highlighting listchars. I will address the issues with copy-pasting from vim in a terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 1: continue using terminal-level copying. To avoid listchars getting into the copy, temporarily to &lt;code&gt;:set nolist&lt;/code&gt; to stop vim from displaying listchars. Then you can copy without any issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 2: use vim's system clipboard integration to copy directly from vim. See &lt;code&gt;:help clipboard&lt;/code&gt; for more information. Basically, if vim is compiled with clipboard support, the &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;+&lt;/code&gt; registers can be used as the primary and clipboard x11 clipboards respectively. For example, &lt;code&gt;&quot;+yy&lt;/code&gt; will copy the current line to the clipboard, and &lt;code&gt;&quot;*p&lt;/code&gt; will paste the primary selection into vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use the system clipboard by default instead of needing to use the &lt;code&gt;*&lt;/code&gt; or &lt;code&gt;+&lt;/code&gt; registers explicitly, use &lt;code&gt;:set clipboard=unnamed&lt;/code&gt; or &lt;code&gt;:set clipboard=unnamedplus&lt;/code&gt;. See &lt;code&gt;:help 'clipboard'&lt;/code&gt; for more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: just thought of something (which i realize now is exactly what the answer you linked to was talking about). You can actually highlight these characters using a different method. Instead of relying on &lt;code&gt;list&lt;/code&gt;, you can add custom syntax matching and highlight groups. For example the following vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nolist&#xA;hi  TabChar             ctermbg=1&#xA;hi  TrailingSpaceChar   ctermbg=2    &#xA;hi  NBSP                ctermbg=3&#xA;syn match TabChar &quot; &quot;&#xA;syn match TrailingSpaceChar &quot; *$&quot;&#xA;syn match NBSP &quot; &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will result in (solarized colour scheme):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gAG6h.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gAG6h.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: if copy/pasting this script, you will probably have to manually write in the tab and nbsp characters in the match regex because browsers like to convert them to spaces...&lt;/p&gt;&#xA;" OwnerDisplayName="user4879" LastEditorDisplayName="user4879" LastEditDate="2019-02-03T04:21:50.397" LastActivityDate="2019-02-03T04:21:50.397" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18786" PostTypeId="2" ParentId="18777" CreationDate="2019-02-03T06:16:40.600" Score="0" Body="&lt;p&gt;This feels kludgy to me, but it's my first vim function, and I still haven't done a custom command yet...  It's not used by the &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;, and &lt;code&gt;y&lt;/code&gt; commands as a motion.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! PriorParagraph() range&#xA;  let s:Redraw = &amp;amp;lazyredraw&#xA;  let &amp;amp;lazyredraw = 1&#xA;  &quot; If our current line is not blank, and the prior line is blank&#xA;  if len(getline(line('.'))) &amp;gt; 0 &amp;amp;&amp;amp; len(getline(line('.') - 1)) == 0&#xA;    &quot; then figure out if we are to the right of the start of the line.&#xA;    let s:Curpos = col('.')&#xA;    normal ^&#xA;    &quot; If we're not to the right of the start of the line, go back another&#xA;    &quot; paragraph.&#xA;    if s:Curpos &amp;lt;= col('.')&#xA;      normal! {&#xA;    endif&#xA;  endif&#xA;  &quot; Was there a count? If so, handle it.&#xA;  let s:Count = a:lastline - a:firstline&#xA;  if s:Count&#xA;    for x in range(1, s:Count)&#xA;      normal! {&#xA;    endfor&#xA;  endif&#xA;  normal! {w&#xA;  let &amp;amp;lazyredraw = s:Redraw&#xA;  return&#xA;endfun!&#xA;nnoremap { :call PriorParagraph()&amp;lt;CR&amp;gt;&#xA;&#xA;fun! NextParagraph() range&#xA;  let s:View      = winsaveview()&#xA;  let s:Redraw = &amp;amp;lazyredraw&#xA;  let &amp;amp;lazyredraw = 1&#xA;  &quot; If we're not on a blank line, we need to go down at least two&#xA;  &quot; paragraphs before coming back up one.&#xA;  if len(getline(s:StartLine))&#xA;    normal! }&#xA;  endif&#xA;  &quot; Was there a count? If so, handle it.&#xA;  let s:Count = a:lastline - a:firstline&#xA;  if s:Count &amp;gt; 0&#xA;    for x in range(1, s:Count)&#xA;      normal! }&#xA;    endfor&#xA;  endif&#xA;  &quot; We're on a blank line or at EOF. If we're at EOF, }{ can take us back&#xA;  &quot; up. So check where we are before we }{w.&#xA;  let s:StartLine = line('.')&#xA;  normal! }{w&#xA;  &quot; If we were at EOF, go back there.&#xA;  if s:StartLine &amp;gt;= line('.')&#xA;    normal! }&#xA;  endif&#xA;  let s:View.col  = col('.') - 1&#xA;  let s:View.lnum = line('.')&#xA;  let s:View.curswant = s:View.col&#xA;  call winrestview(s:View)&#xA;  let &amp;amp;lazyredraw = s:Redraw&#xA;  return&#xA;endfun!&#xA;nnoremap } :call NextParagraph()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20713" LastEditorUserId="11054" LastEditDate="2019-02-04T13:39:25.960" LastActivityDate="2019-02-04T13:39:25.960" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18787" PostTypeId="2" ParentId="18784" CreationDate="2019-02-03T09:20:25.977" Score="1" Body="&lt;p&gt;Concealing is just changing the visual appearance of the content of your window. As such, it always happens local to the window in which it was defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the quickfix buffer is displayed in another window, concealing from the original window won't happen there and you need to define it there additionally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to make this work, you might just enter the following command in your quickfix (or locationlist) window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd('Conceal', '+-', 10, -1, {'conceal': '±'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to have this happen, you might need to run a command like this on a WinEnter (or BufWinEnter) autocommand. It might also be possible to run it on QuickFixCmdPre or Post autocommand, not exactly sure and it might depend on how the quickfix list is created.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-02-03T09:20:25.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18788" PostTypeId="2" ParentId="18042" CreationDate="2019-02-03T13:35:00.753" Score="1" Body="&lt;p&gt;In SpaceVim, the default layer contains checkers layer which is using neomake, you can read &lt;code&gt;:h neomake&lt;/code&gt; to config your pylint maker. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;in neomake the default pylint confg is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! neomake#makers#ft#python#pylint() abort&#xA;    let maker = {&#xA;        \ 'args': [&#xA;            \ '--output-format=text',&#xA;            \ '--msg-template=&quot;{path}:{line}:{column}:{C}: [{symbol}] {msg} [{msg_id}]&quot;',&#xA;            \ '--reports=no'&#xA;        \ ],&#xA;        \ 'errorformat':&#xA;            \ '%A%f:%l:%c:%t: %m,' .&#xA;            \ '%A%f:%l: %m,' .&#xA;            \ '%A%f:(%l): %m,' .&#xA;            \ '%-Z%p^%.%#,' .&#xA;            \ '%-G%.%#',&#xA;        \ 'output_stream': 'stdout',&#xA;        \ 'postprocess': [&#xA;        \   function('neomake#postprocess#generic_length'),&#xA;        \   function('neomake#makers#ft#python#PylintEntryProcess'),&#xA;        \ ]}&#xA;    function! maker.filter_output(lines, context) abort&#xA;        if a:context.source ==# 'stderr'&#xA;            call filter(a:lines, &quot;v:val !=# 'No config file found, using default configuration' &amp;amp;&amp;amp; v:val !~# '^Using config file '&quot;)&#xA;        endif&#xA;        call neomake#makers#ft#python#FilterPythonWarnings(a:lines, a:context)&#xA;    endfunction&#xA;    return maker&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;make sure you have &lt;code&gt;.pylintrc&lt;/code&gt; in your project root or home dir.&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2019-02-03T13:35:00.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18789" PostTypeId="1" CreationDate="2019-02-03T13:44:48.697" Score="4" ViewCount="202" Body="&lt;p&gt;I'm trying to figure out what is the proper way to prevent autocmds from being redundantly repeated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are articles which I have already read:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/5580&quot;&gt;Remove augroups around autocmds in .vimrc&lt;/a&gt; (related question)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/14.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Autocommand Groups&lt;/a&gt; (article from the book)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://gist.github.com/romainl/6e4c15dfc4885cb4bd64688a71aa7063&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dealing with autocommands&lt;/a&gt; (article at GitHub by &lt;a href=&quot;https://vi.stackexchange.com/users/54/romainl&quot;&gt;romainl&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Well, so we have our .vimrc and we need to use autocmds inside it. We could use it like this (1):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * :call Function()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...or like this (2):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufWritePre * :call Function()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...or like this (3):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup OurGroup&#xA;  autocmd!&#xA;  autocmd BufWritePre * :call Function()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...or like this (4):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup OurGroup&#xA;  autocmd!&#xA;augroup END&#xA;&#xA;autocmd OurGoup BufWritePre * :call Function()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it correct that we should never use the 1st version?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it correct that we should always use the 2nd or 3rd or 4th version?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Which version is better: 2nd or 4th? (I don't mention the 3rd version because it is quite similar to the 4th one).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="7200" LastEditDate="2019-02-03T22:22:00.773" LastActivityDate="2019-02-03T22:22:00.773" Title="Preventing autocmds from being redundantly repeated" Tags="|vimrc|autocmd|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18790" PostTypeId="1" CreationDate="2019-02-03T16:37:47.213" Score="1" ViewCount="282" Body="&lt;p&gt;Trying to maintain add conceals to the generated location list, but I can not figure it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current workaround is to add it manually everytime through the vim commandline, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;: set conceallevel=1&#xA;: set concealcursor=n&#xA;: call matchadd('Conceal', 'None', 10, -1, {'conceal': '∅'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would be less frustrating to automate the steps described above in the function below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; function: list multiline block code as one line in a quickfix buffer&#xA;function! Overview() abort&#xA;    0&#xA;    let bufnr = bufnr('%')&#xA;    let items = []&#xA;    while 1&#xA;        let start = search('^{', 'cW')&#xA;        if !start&#xA;            break&#xA;        endif&#xA;        let end = search('^}', 'W')&#xA;        let lines = getline(start, end)&#xA;        let lines = map(lines, 'trim(v:val)')&#xA;        call add(items, {&#xA;            \ 'bufnr': bufnr,&#xA;            \ 'lnum': start,&#xA;            \ 'text': join(lines, ' '),&#xA;        \ })&#xA;        call sort(items, {a, b -&amp;gt; a[&quot;text&quot;] == b[&quot;text&quot;] ? 0 : a[&quot;text&quot;] &amp;gt; b[&quot;text&quot;] ? 1 : -1})&#xA;    endwhile&#xA;    call setloclist(winnr(), items)&#xA;    lopen&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tried to add &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call matchadd('Conceal', 'None', 10, -1, {'conceal': '∅'}) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after the line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setloclist(winnr(), items)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this way of frankensteining the script didn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, but not nessecary, it would be nice if the generated quickfix/locationlist respected the conceals assigned to the original filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That would preventing me copying and maintaing conceals from the original filetype to the function. And it would make the function filetype agnostic.&lt;/p&gt;&#xA;" OwnerUserId="20831" LastActivityDate="2019-02-03T16:37:47.213" Title="Add conceal in function" Tags="|functions|quickfix|conceal|location-list|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18792" PostTypeId="1" CreationDate="2019-02-03T23:38:34.873" Score="1" ViewCount="65" Body="&lt;p&gt;I have a latex file I am editing in vim. Something annoying that I'm running into is that vim seems to auto display things that I am typesetting in math mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example. Say I write the code &lt;/p&gt;&#xA;&#xA;&lt;p&gt;$v^{2}$ and $V_{wind}&gt;&gt;V_{ocean}$&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like it to simply display this way as it would in visual mode, but instead, I get something that looks like the output of latex code, except not quite working. Here's a screenshot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Vh1hb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Vh1hb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20442" LastEditorUserId="1292" LastEditDate="2020-01-02T23:03:38.693" LastActivityDate="2020-01-02T23:03:38.693" Title="How to stop vim from automatically displaying latex formatting?" Tags="|visual-mode|filetype-tex|conceal|" AnswerCount="0" CommentCount="4" ClosedDate="2020-01-04T15:11:04.283" ContentLicense="CC BY-SA 4.0" />
  <row Id="18793" PostTypeId="2" ParentId="18346" CreationDate="2019-02-04T08:18:41.320" Score="1" Body="&lt;p&gt;Since a &lt;a href=&quot;https://github.com/neovim/neovim/pull/9564&quot; rel=&quot;nofollow noreferrer&quot;&gt;new &quot;Signal&quot; autocmd was added&lt;/a&gt;, we can automatically call a function when neovim receives SIGUSR1. Which is nice.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;$ readlink -qn ~/.config/termite/config&#xA;/home/bart/.config/termite/config_dark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I now have this in my init.vim&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;&quot; ~/.config/nvim/init.vim&#xA;&quot; ...&#xA;au Main Signal * call Darkorlight('~/.config/termite/config')&#xA;&#xA;function! Darkorlight(file) abort&#xA;  if getftype(expand(a:file)) != 'link'&#xA;    return&#xA;  endif&#xA;  if resolve(glob(expand(a:file))) =~ '_dark$'&#xA;    set background=dark&#xA;  else&#xA;    set background=light&#xA;  endif&#xA;  redraw&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then watch for the symlink to change with this unit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# ~/.config/systemd/user/termite.path&#xA;[Unit]&#xA;Description=Make termite reload its configuration file when it changes&#xA;&#xA;[Path]&#xA;PathChanged=%h/.config/termite&#xA;&#xA;[Install]&#xA;WantedBy=default.target&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# ~/.config/systemd/user/termite.service&#xA;[Unit]&#xA;Description=Send a signal to all termite and neovim processes&#xA;&#xA;[Service]&#xA;Type=oneshot&#xA;ExecStart=/usr/bin/killall -USR1 termite&#xA;ExecStart=/usr/bin/killall -USR1 nvim&#xA;&#xA;[Install]&#xA;WantedBy=default.target&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works great. It comes in handy as a toggle switch (i.e. for a toolbar):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;#!/bin/sh&#xA;conf=~/.config/termite/config&#xA;if [[ `readlink $conf 2&amp;gt;/dev/null` =~ light ]]; then&#xA;  ln -sf &quot;${conf}_dark&quot; &quot;$conf&quot;&#xA;else&#xA;  ln -sf &quot;${conf}_light&quot; &quot;$conf&quot;&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks to Justin M. Keyes for encouraging me to ask for a scriptable Signal feature on Github, and to Marco Hinz for implementing it so quickly!&lt;/p&gt;&#xA;" OwnerUserId="1027" LastActivityDate="2019-02-04T08:18:41.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18794" PostTypeId="1" CreationDate="2019-02-04T14:49:12.303" Score="3" ViewCount="428" Body="&lt;p&gt;I am long time Vim (Windows 10, gVim 8.1) user, happy as a clam with Vim 7. I have not used any of the plugin managers, just the one-off plugin from vim.org. I went looking for plugins to help with editing Javascript code (syntax highlighting, indenting, linting, etc.) and most folks seem to recommend &lt;a href=&quot;https://github.com/pangloss/vim-javascript&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am &lt;strong&gt;not&lt;/strong&gt; interested in Git integration, auto updating it, sub-modules or any of that stuff. I created a &lt;code&gt;pack/&amp;lt;key&amp;gt;/start&lt;/code&gt; folder and downloaded &lt;a href=&quot;https://github.com/pangloss/vim-javascript/archive/master.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; from Github. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the next step? Where should I unzip it in order to associate all the goodness in the package with &lt;code&gt;*.js&lt;/code&gt; buffers automatically or manually using &lt;code&gt;set ft=javascript&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="20837" LastEditorUserId="1292" LastEditDate="2019-02-06T14:59:55.047" LastActivityDate="2019-02-06T14:59:55.047" Title="How to load vim-javascript using Vim 8 native package manager?" Tags="|gvim|microsoft-windows|packages|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18795" PostTypeId="2" ParentId="18765" CreationDate="2019-02-04T18:42:36.017" Score="2" Body="&lt;p&gt;The contents of &lt;code&gt;.git/COMMIT_EDITMSG&lt;/code&gt; usually persist, but there are ways to create backups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution that comes to mind, leveraging the filetype &lt;code&gt;gitcommit&lt;/code&gt; (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; .vim/after/ftplugin/gitcommit.vim&#xA;&quot; autocmd! prevents duplication if resourced&#xA;&quot; |      BufWritePre triggered before write&#xA;&quot; |      |           &amp;lt;buffer&amp;gt; applies only to this buffer&#xA;&quot; |      |           |        write to '%.save' ('%' expands to current filename)&#xA;&quot; |      |           |        |&#xA;autocmd! BufWritePre &amp;lt;buffer&amp;gt; write %.save&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, if there was a failure, when you do &lt;code&gt;git commit&lt;/code&gt;, simply type &lt;code&gt;:0read %.save&lt;/code&gt;. You might even want to create a buffer-local mapping for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; .vim/after/ftplugin/gitcommit.vim&#xA;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;LocalLeader&amp;gt;b 0read %.save&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure to adjust &lt;code&gt;b:undo_ftplugin&lt;/code&gt; appropriately. You'll also need (at minimum) &lt;code&gt;filetype plugin on&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-02-09T19:54:35.393" LastActivityDate="2019-02-09T19:54:35.393" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18796" PostTypeId="1" AcceptedAnswerId="18797" CreationDate="2019-02-04T21:09:19.400" Score="0" ViewCount="302" Body="&lt;h2&gt;Clarification of the moving parts&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First, let me clarify what I mean by &quot;Window Title&quot;, and what I expect to achieve&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;On Windows OS, GUI programs will have three attributes: its Window Title texts, the process.exe name and its win-class name. An example of Gvim ran through Xming looks like the following: &#xA;&lt;a href=&quot;https://i.stack.imgur.com/BDfxg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BDfxg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Window Title&lt;/strong&gt;: &lt;code&gt;[No Name] - - GVIM1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;win-class name: &lt;code&gt;Xming X&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Process Name: &lt;code&gt;Xming.exe&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I am looking for a way to &lt;strong&gt;start&lt;/strong&gt; Vim, so that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Instead of reporting &lt;code&gt;FileName -- GVIM1&lt;/code&gt; as its &quot;Win-Title&quot;, it also reports, either:&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Filename -- GVIM1 - Insert-mode&lt;/code&gt; OR &lt;code&gt;Filename -- GVIM1 - Normal-mode&lt;/code&gt;, depending on the current state of Vim.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Please advise if there is a better way to have Vim dynamically update its &quot;Title&quot;. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Explanation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;At the end of the day, I would like to detect the precise Vim mode through its &quot;Window Title&quot;. This opens new doors for re-mapping indistinguishable pairs of keys, like &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, through AutoHotKey, which runs on Windows OS, I can happily assign &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; (in normal mode) to a particular command-line function, while keeping &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; behaving &quot;normally&quot; (go to the next position on the jump list). AutoHotKey detects WinTitle by default and will need a lot more effort to conduct real-time OCR on the dynamic Window of Gvim, to tell its current mode. Blindly remapping the &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; key will distort the &lt;em&gt;normal usage&lt;/em&gt; of &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; key in Insert-mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please advise if this is achievable, as it is funny to learn that &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; are identical keys in the year 2019 :)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Motivation and cross-reference (TL;DR)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Things start from &lt;a href=&quot;https://github.com/vimwiki/vimwiki/issues/607&quot; rel=&quot;nofollow noreferrer&quot;&gt;this post about Vimwiki&lt;/a&gt;, where I re-learned that &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; are indistinguishable by the Modern Vim. This brings conflict in my hard-to-change muscle memory. For the mappings in normal mode:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; should take me to the more recent position in the jump list (opposite of &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;), and&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; should handle its own business:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For Vimwiki, &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; jumps to the next hyperlink, and &lt;code&gt;&amp;lt;s-tab&amp;gt;&lt;/code&gt; jumps to the previous hyperlink&lt;/li&gt;&#xA;&lt;li&gt;For other filetypes, I do not press &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; key in normal mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I tend to spend a considerable amount of time in Markdown documents, and I rely on &lt;a href=&quot;https://github.com/vimwiki/vimwiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimwiki&lt;/a&gt; to nativage the stacks of Markdown files. (I maintain two websites + one personal wiki with more than 2,000 entires.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the end of the day, I would like to &quot;split&quot; the functionality of &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; ==&gt; In Normal-mode, pressing &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; shall issue &lt;code&gt;:VimwikiNextLink&amp;lt;CR&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; shall bring me to the next point in the Jump list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since it is well established that &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; are treated alike by Vim, I am planning to use AutoHotKey to &lt;em&gt;overwrite&lt;/em&gt; the &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; key &lt;strong&gt;only in Normal Mode&lt;/strong&gt;. This is where all dots should connect: through a title-matching trick in AutoHotKey, &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; is only mapped to &lt;code&gt;:VimwikiNextLink&amp;lt;CR&amp;gt;&lt;/code&gt; in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the tweak on the &lt;code&gt;titlestring&lt;/code&gt; option, I see the light of distinguishing modes.&lt;/p&gt;&#xA;" OwnerUserId="2398" LastEditorUserId="2398" LastEditDate="2019-02-05T13:11:52.777" LastActivityDate="2019-02-05T13:11:52.777" Title="May I have a Vim session report its &quot;Mode&quot; in its &quot;Window Title&quot;?" Tags="|command-line|visual-mode|insert-mode|normal-mode|startup|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18797" PostTypeId="2" ParentId="18796" CreationDate="2019-02-04T23:43:04.813" Score="2" Body="&lt;p&gt;You can try&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set titlestring=%F\ %{v:servername}\ %{mode()}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this will indicate the mode as &lt;code&gt;n&lt;/code&gt; rsp. &lt;code&gt;i&lt;/code&gt; and some other characters as described in &lt;code&gt;:help mode()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can improve the last expression (&lt;code&gt;%{mode()}&lt;/code&gt;) to something longer using a ?: construct.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2019-02-04T23:43:04.813" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18798" PostTypeId="1" AcceptedAnswerId="18799" CreationDate="2019-02-05T04:18:40.663" Score="4" ViewCount="10201" Body="&lt;p&gt;Instead of wrapping lines visually, I want vim to wrap with a linebreak regardless of my the window dimensions. How can I set this automatically &lt;/p&gt;&#xA;" OwnerUserId="16949" LastEditorUserId="14480" LastEditDate="2023-09-26T17:05:53.443" LastActivityDate="2023-09-26T17:05:53.443" Title="Automatic wrapping to new line?" Tags="|wrapping|line-breaks|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18799" PostTypeId="2" ParentId="18798" CreationDate="2019-02-05T06:25:30.160" Score="4" Body="&lt;p&gt;You could work with &lt;code&gt;wrapmargin&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=0&#xA;set wrapmargin=1&#xA;set formatoptions+=t&#xA;set formatoptions-=l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The option &lt;code&gt;wrapmargin&lt;/code&gt; defines the &lt;em&gt;number of characters from the right window border where wrapping starts&lt;/em&gt;. This option is only used, if &lt;code&gt;textwidth&lt;/code&gt; is set to zero.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;formatoptions&lt;/code&gt; flag &lt;code&gt;t&lt;/code&gt; enables auto-wrap of text. By removing &lt;code&gt;l&lt;/code&gt; from &lt;code&gt;formatoptions&lt;/code&gt;, also lines that are already longer are wrapped.&lt;/p&gt;&#xA;&lt;p&gt;See  &lt;code&gt;:help 'wrapmargin'&lt;/code&gt;, &lt;code&gt;:help 'formatoptions'&lt;/code&gt; and &lt;code&gt;:help fo-table&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="30858" LastEditDate="2020-08-05T16:02:29.887" LastActivityDate="2020-08-05T16:02:29.887" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18800" PostTypeId="2" ParentId="18798" CreationDate="2019-02-05T06:27:27.073" Score="4" Body="&lt;p&gt;Set&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The 'textwidth' option can be used to automatically break a line&#xA;  before it gets too long.  Set the 'textwidth' option to the desired&#xA;  maximum line length.  If you then type more characters (not spaces or&#xA;  tabs), the last word will be put on a new line (unless it is the only&#xA;  word on the line).  If you set 'textwidth' to 0, this feature is&#xA;  disabled.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The line is only broken automatically when using Insert mode, or when&#xA;  appending to a line.  When in replace mode and the line length is not&#xA;  changed, the line will not be broken.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the comments I see you use &quot;auto&quot; linebreaks for coding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you tried &lt;code&gt;breakindent&lt;/code&gt; and friends?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IZR2m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IZR2m.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-02-05T08:14:39.497" LastActivityDate="2019-02-05T08:14:39.497" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18801" PostTypeId="1" CreationDate="2019-02-05T09:21:23.730" Score="1" ViewCount="1232" Body="&lt;p&gt;I am used working on Vim on Linux, where I use tmux + vim to switch between terminal and vim edit quickly. Now I am trying to setup the same on windows 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I try to use gVim on Windows 10, but I like to work in Bash terminal. Windows 10 allows you to download and used it Microsoft Bash terminal. &#xA;Problem that I have now, is to change in gVim default cmd terminal to Bash terminal, by typing in gVim command &lt;code&gt;:terminal&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="20847" LastActivityDate="2019-02-05T09:34:34.343" Title="Change Vim command :terminal so instead of CMD there will open Bash terminal" Tags="|terminal|bash|" AnswerCount="1" CommentCount="0" ClosedDate="2019-02-06T08:27:07.537" ContentLicense="CC BY-SA 4.0" />
  <row Id="18802" PostTypeId="2" ParentId="18801" CreationDate="2019-02-05T09:34:34.343" Score="1" Body="&lt;p&gt;Well, you could change the option &lt;code&gt;shell&lt;/code&gt;, see &lt;code&gt;:help :terminal&lt;/code&gt; and &lt;code&gt;:help 'shell'&lt;/code&gt;. But this means, that you also use &lt;code&gt;shell&lt;/code&gt; for all &lt;code&gt;:!&lt;/code&gt; commands. I don't know if you want that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, you could just define a new command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command Bash  terminal ++close bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;++close&lt;/code&gt; is needed, so Vim closes the terminal window when you exit bash.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-05T09:34:34.343" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18803" PostTypeId="1" AcceptedAnswerId="18806" CreationDate="2019-02-05T13:12:45.203" Score="5" ViewCount="1712" Body="&lt;p&gt;Vim automatically strips trailing whitespace from my files on save, which is extremely annoying in various contexts. How do I disable this behaviour?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question is &lt;strong&gt;not&lt;/strong&gt; a duplicate of &lt;a href=&quot;https://vi.stackexchange.com/questions/8995/stop-vim-from-removing-whitespace-on-save-for-diff-files&quot;&gt;this one&lt;/a&gt;, because I'm not using editorconfig at all. This behaviour has been the default in every version of Vim I've ever used, including MacVim, NeoVim, and the build of Vim 8.1 I compiled myself.&lt;/p&gt;&#xA;" OwnerUserId="14849" LastActivityDate="2019-02-05T14:12:11.207" Title="Stop Vim from deleting trailing whitespace" Tags="|whitespace|" AnswerCount="2" CommentCount="1" ClosedDate="2019-02-05T16:29:26.013" ContentLicense="CC BY-SA 4.0" />
  <row Id="18804" PostTypeId="1" CreationDate="2019-02-05T13:46:43.773" Score="1" ViewCount="89" Body="&lt;p&gt;Following from &lt;a href=&quot;https://vi.stackexchange.com/questions/18796/may-i-have-a-vim-session-report-its-mode-in-its-window-title&quot;&gt;this post&lt;/a&gt;, I can happily &quot;project&quot; character &lt;code&gt;n&lt;/code&gt; to the &lt;code&gt;titlestring&lt;/code&gt; when Vim is in Normal-mode, and &quot;project&quot; character &lt;code&gt;i&lt;/code&gt; to the &lt;code&gt;titlestring&lt;/code&gt; when Vim is in Insert-mode. This almost finished my journey of having external programs to learn about Vim's precise mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: may I add an indicator (character) to the &lt;code&gt;titlestring&lt;/code&gt;, so that it reflects the status when Vim enters the &quot;command-line mode&quot;, via pressing the &lt;code&gt;:&lt;/code&gt; key? &lt;/p&gt;&#xA;" OwnerUserId="2398" LastActivityDate="2019-02-05T13:46:43.773" Title="May I let `titlestring` tell whether I am in command-line mode?" Tags="|vimscript|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18805" PostTypeId="2" ParentId="18803" CreationDate="2019-02-05T14:09:55.003" Score="4" Body="&lt;p&gt;In my .vimrc I have the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Trim trailing whitespace&#xA;&quot; ========================&#xA;function! TrimWhitespace()&#xA;  &quot; trailing whitespaces have meaning in markdown so don't try there&#xA;  if &amp;amp;filetype!='markdown'&#xA;    let l:save = winsaveview()&#xA;    %s/\s\+$//e&#xA;    call winrestview(l:save)&#xA;  endif&#xA;endfunction&#xA;&#xA;command! TrimWhitespace call TrimWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This checks if the current file is a markdown file, and disables the removal of trailing whitespace if it is. You can expand this for other filetypes.&lt;/p&gt;&#xA;" OwnerUserId="11066" LastActivityDate="2019-02-05T14:09:55.003" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18806" PostTypeId="2" ParentId="18803" CreationDate="2019-02-05T14:12:11.207" Score="2" Body="&lt;p&gt;@statox was right on the money: it was, of course, an old leftover in my .vimrc. Who would have guessed!&lt;/p&gt;&#xA;" OwnerUserId="14849" LastActivityDate="2019-02-05T14:12:11.207" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18807" PostTypeId="1" AcceptedAnswerId="18808" CreationDate="2019-02-05T18:02:50.700" Score="2" ViewCount="201" Body="&lt;p&gt;Here is an attempt to write a function which will remove trashy characters (^F, ^S, ^Z, zero-width space, etc) on save, and keep cursor position.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme desert&#xA;set guifont=Consolas:h10&#xA;set encoding=utf-8&#xA;setglobal fileencoding=utf-8&#xA;set noexpandtab&#xA;set list&#xA;set listchars=tab:→\ ,space:·&#xA;&#xA;set nobackup&#xA;set noswapfile&#xA;set noundofile&#xA;&#xA;function! RemoveTrash()&#xA;  let l:save = winsaveview()&#xA;  keeppatterns %s/[^[:print:]\t]//g&#xA;  call winrestview(l:save)&#xA;endfun&#xA;&#xA;augroup Test&#xA;  autocmd!&#xA;  autocmd BufWritePre * :call RemoveTrash()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The overall idea about function was taken from Martin Tournoij's answer about removing whitespace:  &lt;a href=&quot;https://vi.stackexchange.com/a/456&quot;&gt;https://vi.stackexchange.com/a/456&lt;/a&gt;, and regex was taken lincz's answer: &lt;a href=&quot;https://stackoverflow.com/a/16135425&quot;&gt;https://stackoverflow.com/a/16135425&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the test file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;---foo##bar##baz&#xA;&amp;gt;---foo##bar##baz&#xA;&amp;gt;---foo##bar##baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To post it here I replaced tab characters with &lt;code&gt;&amp;gt;---&lt;/code&gt; and control characters (&lt;code&gt;^F&lt;/code&gt;, &lt;code&gt;^S&lt;/code&gt;) with &lt;code&gt;##&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I save the file, the cursor position isn't really saved - it slightly moves to the right side accordingly number of control characters before it. Here are two examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you have cursor on letter &lt;code&gt;a&lt;/code&gt; in &lt;code&gt;bar&lt;/code&gt; - it will be moved to &lt;code&gt;r&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If you have cursor on letter &lt;code&gt;b&lt;/code&gt; in &lt;code&gt;baz&lt;/code&gt; - it will be moved to &lt;code&gt;z&lt;/code&gt; (because there are two control characters before it).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And here are screenshots for the first example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IuSUm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IuSUm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;DJMcMayhem posted an answer at February the 5th, but it seems it doesn't properly work for tab-indented lines. That's why I started a bounty. I tried to fix it by changing &lt;code&gt;getcurpos()[2]&lt;/code&gt; to &lt;code&gt;getcurpos()[4]&lt;/code&gt;, but my &quot;knowledge&quot; of Vimscript is too low.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="7200" LastEditDate="2019-02-07T22:24:24.230" LastActivityDate="2019-02-10T20:33:25.047" Title="Keep cursor position while removing control characters" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18808" PostTypeId="2" ParentId="18807" CreationDate="2019-02-05T18:51:58.283" Score="1" Body="&lt;p&gt;Like Ralf said, your function is correctly saving the cursor position. The issue is when characters to the left of your cursor get deleted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I came up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RemoveTrash()&#xA;  let l:initialCol = getcurpos()[2]&#xA;  let l:line = getline('.')[0:initialCol-1]&#xA;&#xA;  let l:numRemoved = len(l:line) - len(substitute(l:line, '[^[:print:]\t]', &quot;&quot;, &quot;g&quot;))&#xA;&#xA;  let l:save = winsaveview()&#xA;  keeppatterns %s/[^[:print:]\t]//ge&#xA;  call winrestview(l:save)&#xA;&#xA;  if l:numRemoved != 0&#xA;    call cursor(line('.'), (l:initialCol-l:numRemoved))&#xA;  endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It keeps track of the old cursor position, and then calculates how many characters before that column will be deleted, and compensates.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: &lt;em&gt;switched &lt;code&gt;exec normal |&lt;/code&gt; to &lt;code&gt;cursor()&lt;/code&gt;, since that function compensates for tabs whereas &lt;code&gt;|&lt;/code&gt; does not.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2&lt;/strong&gt;: &lt;em&gt;Added the &lt;code&gt;/e&lt;/code&gt; flag to the substitute command so that it will not throw an error if there are no unprintables to remove.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2019-02-10T20:33:25.047" LastActivityDate="2019-02-10T20:33:25.047" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="18810" PostTypeId="1" CreationDate="2019-02-05T19:18:05.810" Score="0" ViewCount="223" Body="&lt;p&gt;UPDATE: I run an X server (XQuartz 2.7.11) on MacOS, which I forward via ssh to any Linux machine I use. The problem seems to be that under XQuartz, the &lt;code&gt;&quot;+&lt;/code&gt; register does not support blockwise yanking/pasting. Indeed, &lt;code&gt;:call setreg('+',@+,&quot;b&quot;)&lt;/code&gt; does not work (&lt;code&gt;echo getregtype('+')&lt;/code&gt; still gives &lt;code&gt;V&lt;/code&gt;). Is there anything that can be done about this? How does vim registers work under the hood? Why does the system clipboard affect whether the &lt;code&gt;&quot;+&lt;/code&gt; register supports blockwise yanking/pasting?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am having trouble with blockwise pasting from the &quot;+ register. It works if I run MacOS's default version but on both MacOS or Linux I get the following results when I use the version I have installed via nixpkgs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I start up vim with &lt;code&gt;vim -u NONE&lt;/code&gt; and then use &lt;code&gt;ctrl+v&lt;/code&gt; to select the first three lines in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;2&#xA;3&#xA;a&#xA;b&#xA;c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then press &lt;code&gt;&quot;+y&lt;/code&gt; to put the block in the &quot;+ register. I then put the cursor on the line &lt;code&gt;a&lt;/code&gt; and press &lt;code&gt;&quot;+p&lt;/code&gt; to paste from the &quot;+ register. Result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;2&#xA;3&#xA;a&#xA;1&#xA;2&#xA;3&#xA;b&#xA;c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any advice?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Additional info:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It works with other registers including &lt;code&gt;*&lt;/code&gt; (like using &lt;code&gt;&quot;ay&lt;/code&gt; and &lt;code&gt;&quot;ap&lt;/code&gt; or &lt;code&gt;&quot;*y&lt;/code&gt; and &lt;code&gt;&quot;*p&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;If I start vim with &lt;code&gt;vim -u NONE -X&lt;/code&gt; (disable connection to X server):&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Linux: The register &lt;code&gt;+&lt;/code&gt; works as expected.&lt;/li&gt;&#xA;&lt;li&gt;MacOS: The register &lt;code&gt;+&lt;/code&gt; does not work at all.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;MacOS: If I stop the X server (XQuartz 2.7.11) things works as expected.&lt;/li&gt;&#xA;&lt;li&gt;After blockwise yank to &lt;code&gt;&quot;+&lt;/code&gt; respectively to &lt;code&gt;&quot;a&lt;/code&gt;:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;echo getregtype('+')&lt;/code&gt; gives &lt;code&gt;V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;echo getregtype('a')&lt;/code&gt; gives &lt;code&gt;^V1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;I do not use any clipboard manager.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;vim version on MacOS:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$vim --version&#xA;VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 10 2018 05:50:24)&#xA;macOS version w/o darwin feat.&#xA;Included patches: 1-146&#xA;Compiled by root&#xA;Huge version with GTK3 GUI.  Features included (+) or not (-):&#xA;+acl               +farsi             +mouse_sgr         -tag_any_white&#xA;+arabic            +file_in_path      -mouse_sysmouse    -tcl&#xA;+autocmd           +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       +terminal&#xA;+balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;+browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    +gettext           +netbeans_intg     +timers&#xA;+byte_offset       -hangul_input      +num64             +title&#xA;+channel           +iconv             +packages          +toolbar&#xA;+cindent           +insert_expand     +path_extra        +user_commands&#xA;+clientserver      +job               -perl              +vartabs&#xA;+clipboard         +jumplist          +persistent_undo   +vertsplit&#xA;+cmdline_compl     +keymap            +postscript        +virtualedit&#xA;+cmdline_hist      +lambda            +printer           +visual&#xA;+cmdline_info      +langmap           +profile           +visualextra&#xA;+comments          +libcall           +python            +viminfo&#xA;+conceal           +linebreak         -python3           +vreplace&#xA;+cryptv            +lispindent        +quickfix          +wildignore&#xA;+cscope            +listcmds          +reltime           +wildmenu&#xA;+cursorbind        +localmap          +rightleft         +windows&#xA;+cursorshape       +lua               +ruby              +writebackup&#xA;+dialog_con_gui    +menu              +scrollbind        +X11&#xA;+diff              +mksession         +signs             -xfontset&#xA;+digraphs          +modify_fname      +smartindent       +xim&#xA;+dnd               +mouse             +startuptime       +xpm&#xA;-ebcdic            +mouseshape        +statusline        -xsmp&#xA;+emacs_tags        +mouse_dec         -sun_workshop      +xterm_clipboard&#xA;+eval              -mouse_gpm         +syntax            -xterm_save&#xA;+ex_extra          -mouse_jsbterm     +tag_binary        &#xA;+extra_search      +mouse_netterm     +tag_old_static    &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;&#xA;/nix/store/mxb9yfzskiid83j9rv1icw39fnimaiv1-vim_configurable-8.1.0146/share/vim&#xA;&quot;&#xA;Compilation: see nix-store --read-log /nix/store/mxb9yfzskiid83j9rv1icw39fnimaiv1-vim_configurable-8.1.0146&#xA;Linking: see nix-store --read-log /nix/store/mxb9yfzskiid83j9rv1icw39fnimaiv1-vim_configurable-8.1.0146&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim version on Linux:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 8.1 (2018 May 18, compiled Jan  1 1970 00:00:01)&#xA;Included patches: 1-578&#xA;Compiled by nixbld&#xA;Huge version with GTK3 GUI.  Features included (+) or not (-):&#xA;+acl               +extra_search      +mouse_netterm     +tag_old_static&#xA;+arabic            +farsi             +mouse_sgr         -tag_any_white&#xA;+autocmd           +file_in_path      -mouse_sysmouse    -tcl&#xA;+autochdir         +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       +terminal&#xA;+balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;+browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    +gettext           +netbeans_intg     +timers&#xA;+byte_offset       -hangul_input      +num64             +title&#xA;+channel           +iconv             +packages          +toolbar&#xA;+cindent           +insert_expand     +path_extra        +user_commands&#xA;+clientserver      +job               -perl              +vartabs&#xA;+clipboard         +jumplist          +persistent_undo   +vertsplit&#xA;+cmdline_compl     +keymap            +postscript        +virtualedit&#xA;+cmdline_hist      +lambda            +printer           +visual&#xA;+cmdline_info      +langmap           +profile           +visualextra&#xA;+comments          +libcall           +python            +viminfo&#xA;+conceal           +linebreak         -python3           +vreplace&#xA;+cryptv            +lispindent        +quickfix          +wildignore&#xA;+cscope            +listcmds          +reltime           +wildmenu&#xA;+cursorbind        +localmap          +rightleft         +windows&#xA;+cursorshape       +lua               +ruby              +writebackup&#xA;+dialog_con_gui    +menu              +scrollbind        +X11&#xA;+diff              +mksession         +signs             -xfontset&#xA;+digraphs          +modify_fname      +smartindent       +xim&#xA;+dnd               +mouse             +startuptime       +xpm&#xA;-ebcdic            +mouseshape        +statusline        -xsmp&#xA;+emacs_tags        +mouse_dec         -sun_workshop      +xterm_clipboard&#xA;+eval              -mouse_gpm         +syntax            -xterm_save&#xA;+ex_extra          -mouse_jsbterm     +tag_binary        &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;&#xA;/nix/store/dgna8nl8d3nmzxbzjxvv7kqbwyv9f62c-vim_configurable-8.1.0578/share/vim&#xA;&quot;&#xA;Compilation: see nix-store --read-log /nix/store/dgna8nl8d3nmzxbzjxvv7kqbwyv9f62c-vim_configurable-8.1.0578&#xA;Linking: see nix-store --read-log /nix/store/dgna8nl8d3nmzxbzjxvv7kqbwyv9f62c-vim_configurable-8.1.0578&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20853" LastEditorUserId="20853" LastEditDate="2019-02-06T13:24:04.107" LastActivityDate="2019-02-06T13:24:04.107" Title="Blockwise pasting from &quot;+ register not working" Tags="|cut-copy-paste|register|visual-block|x11|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="18811" PostTypeId="2" ParentId="14315" CreationDate="2019-02-05T20:02:11.667" Score="1" Body="&lt;p&gt;For posterity: Turns out, additionally to the mentioned approaches (which would qualify as hacks in my book) you can simply use &lt;code&gt;getcmdwintype()&lt;/code&gt;. Credits to user micbou from the Youcompleteme maintainers. Docs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getcmdwintype()&#xA;        Return the current |command-line-window| type. Possible return&#xA;        values are the same as |getcmdtype()|. Returns an empty string&#xA;        when not in the command-line window.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17075" LastActivityDate="2019-02-05T20:02:11.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18812" PostTypeId="2" ParentId="9431" CreationDate="2019-02-06T12:33:36.280" Score="3" Body="&lt;p&gt;And to make it persistent, check out vim's help files under the keyword &lt;code&gt;au&lt;/code&gt; for autocmd&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:h au&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then create a group (i.e. &lt;em&gt;scope/namespace&lt;/em&gt; as the ubiquitous term) to protect yourself from duplicate definitions (just like an include guard in C)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup debianlatexfix &#xA;  &amp;quot; Remove all vimrc autocommands within scope&#xA;  autocmd! &#xA;  autocmd BufNewFile,BufRead *.tex   set syntax=tex&#xA;  autocmd BufNewFile,BufRead *.cls   set syntax=tex&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17834" LastEditorUserId="17834" LastEditDate="2021-04-01T05:50:38.227" LastActivityDate="2021-04-01T05:50:38.227" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18813" PostTypeId="1" AcceptedAnswerId="18815" CreationDate="2019-02-06T13:45:23.707" Score="2" ViewCount="584" Body="&lt;p&gt;I've somehow managed to have all tabs show up as the control character &lt;code&gt;^I&lt;/code&gt; in VIm, specifically gvim 8.1.1 on Windows 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/K53vS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/K53vS.png&quot; alt=&quot;Some JSON with tabs as control characters in gvim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I have related to tabs in vimrc is this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set tabstop=2&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do also have these lines that point to something else, so to speak, but wouldn't expect them to have an influence on tabs showing as control characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/mswin.vim&#xA;set nocompatible&#xA;behave mswin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did have the following, but after thinking there could be some interaction (&lt;a href=&quot;https://vi.stackexchange.com/questions/422/displaying-tabs-as-characters&quot;&gt;1&lt;/a&gt;, &lt;a href=&quot;https://stackoverflow.com/a/1675752/1028230&quot;&gt;2&lt;/a&gt;, &lt;a href=&quot;http://www.chrispian.com/quick-vi-tip-show-hidden-characters/&quot; rel=&quot;nofollow noreferrer&quot;&gt;3&lt;/a&gt;), commented it out and still see the control characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; highlight tabs and trailing spaces&#xA;&quot;set listchars=trail:-&#xA;&quot;set list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3342" LastActivityDate="2019-02-06T15:26:48.303" Title="How to view tabs as conventional whitespace, not as control character ^I (caret I) in VIm?" Tags="|tab-characters|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18814" PostTypeId="1" CreationDate="2019-02-06T15:16:16.400" Score="0" ViewCount="345" Body="&lt;p&gt;Can someone explain or link to valid explanation information on the syntax highlighting mechanism. In particular I am having having a hard time understanding how rules are applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine the following rule&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match paragraph &quot;^\s*[^\n]*\%(\n[^\n]\+\)\n\n\+&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the applied to a (UNIX) file with of 100 lines. I would expect the pattern to be applied at most 100 times. In reality it is applied much more times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a Markdown syntax file that correctly detects and supports all Pandoc features (and a couple more). But I am confronted with rules being executed tens of thousands times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas ?&lt;/p&gt;&#xA;" OwnerUserId="17308" LastActivityDate="2024-02-23T09:01:45.260" Title="Vim syntax line matching mechanism" Tags="|syntax-highlighting|performance|syntax|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18815" PostTypeId="2" ParentId="18813" CreationDate="2019-02-06T15:26:48.303" Score="2" Body="&lt;p&gt;This is caused by &lt;code&gt;set list&lt;/code&gt;. You can check that it is enabled with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set list?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can turn it off with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nolist&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(That should confirm that the problem goes away.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though you commented the one in your .vimrc, it is possible the setting is coming from another initialization file, so you should look for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vi.stackexchange.com/q/2003/18609&quot;&gt;this question&lt;/a&gt; for help on how to debug your .vimrc file.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-02-06T15:26:48.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18816" PostTypeId="1" AcceptedAnswerId="18817" CreationDate="2019-02-06T19:03:52.613" Score="2" ViewCount="118" Body="&lt;p&gt;I'd like it if, when filling out my Roxygen comment snippet,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#' Title     &#xA;#'           &#xA;#' @param    &#xA;#'           &#xA;#' @return   &#xA;#'           &#xA;#' @examples &#xA;#'           &#xA;#'           &#xA;#' @export   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim would extend the &lt;code&gt;#'&lt;/code&gt; when I press return on a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figure I need to do something with &lt;code&gt;:setlocal comments&lt;/code&gt;, but I haven't been able to figure out what.&lt;/p&gt;&#xA;" OwnerUserId="20868" LastActivityDate="2019-02-07T05:10:29.480" Title="Vim doesn't extend Roxygen R comments" Tags="|insert-mode|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18817" PostTypeId="2" ParentId="18816" CreationDate="2019-02-06T19:37:10.953" Score="4" Body="&lt;p&gt;Create the file &lt;code&gt;~/.vim/after/ftplugin/r.vim&lt;/code&gt; (Windows: &lt;code&gt;$HOME/vimfiles/after/ftplugin/r.vim&lt;/code&gt;) with the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal formatoptions+=r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This file is sourced, after Vims filetype specific file for R is sourced. So it can be used to change settings that are from the R file type plugin or to add other things that you want to do when loading a R file (like define specific mappings etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only want to change the &lt;code&gt;formatoptions&lt;/code&gt; you could also add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType r setlocal formatoptions+=r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The added formatoption &lt;code&gt;r&lt;/code&gt; means: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Automatically insert the current comment leader after hitting &amp;lt;Enter&amp;gt; in Insert mode.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-07T05:10:29.480" LastActivityDate="2019-02-07T05:10:29.480" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18818" PostTypeId="1" CreationDate="2019-02-06T21:13:31.440" Score="2" ViewCount="150" Body="&lt;p&gt;Line endings differ between platforms; LF on unix, CRLF on windows, CR on Mac OS Classic. Unicode introduced LS (Line separator, U+2028) and PS (Paragraph separator, U+2029), as unambiguous alternatives to platform-defined line endings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim can handle LF, CR, or CRLF line endings just fine. Can it be configured to do the Right Thing with the Unicode separators as well?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(context: natural-language text, not programming)&lt;/p&gt;&#xA;" OwnerUserId="20175" LastEditorUserId="20175" LastEditDate="2019-02-07T16:39:41.427" LastActivityDate="2019-02-07T16:39:41.427" Title="Can vim handle unicode line and paragraph separators?" Tags="|unicode|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18819" PostTypeId="1" CreationDate="2019-02-06T23:23:18.080" Score="1" ViewCount="821" Body="&lt;p&gt;Because the default &lt;code&gt;Ctrl-B/F&lt;/code&gt; or &lt;code&gt;PageUp/Down&lt;/code&gt; behaviour usually leaves the cursor somewhere other than where it started, I remapped &lt;code&gt;PageUp&lt;/code&gt; and &lt;code&gt;PageDown&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; to simply move up/down 25 lines. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;PageUp&amp;gt; 25&amp;lt;Up&amp;gt; &#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;PageDown&amp;gt; 25&amp;lt;Down&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I get to the top of the file the line number goes to 1 and so when I return down to near the original text it is now on the wrong line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to correct for this (perhaps some function for &lt;code&gt;PageUp&lt;/code&gt; and &lt;code&gt;PageDown&lt;/code&gt; that remembers when it could only go a lesser distance and so the first movement in the opposite direction also goes a lesser distance, or possibly some scheme where a marker is placed at the original spot... although I'd prefer not to have to remember to do that manually every time, just in case I may find myself needing it because I try to scroll too far).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Fedora 28 (but I'm pretty sure vi/vim under other systems had this problem of returning to a different line). &lt;code&gt;Ctrl-B/F&lt;/code&gt; have the side effect of moving the cursor to the last/first line on the screen, so I often find the process of looking at something off the top of the screen means returning afterwards does not actually return me to the correct line; I have to hit up/down arrows a lot. And &lt;code&gt;PageUp/Down&lt;/code&gt; keys are mapped to &lt;code&gt;Ctrl-B/F&lt;/code&gt; so have this annoying feature. Using &lt;code&gt;Ctrl-U/D&lt;/code&gt; or my simple workaround is usually better, except if I accidentally try to go too far... hence my question of a more general solution.&lt;/p&gt;&#xA;" OwnerUserId="20870" LastEditorUserId="20870" LastEditDate="2019-02-07T21:23:48.843" LastActivityDate="2024-02-02T10:35:30.317" Title="How to get PageUp and PageDown to return to the exact same character?" Tags="|cursor-movement|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18820" PostTypeId="2" ParentId="12794" CreationDate="2019-02-07T01:36:42.267" Score="26" Body="&lt;p&gt;You can use &lt;code&gt;if has('nvim')&lt;/code&gt;. Here are complete examples:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Configuration only for Neovim:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('nvim')&#xA;        tnoremap &amp;lt;Esc&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Configuration only for Vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !has('nvim')&#xA;    set ttymouse=xterm2&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6094" LastActivityDate="2019-02-07T01:36:42.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18821" PostTypeId="1" AcceptedAnswerId="18822" CreationDate="2019-02-07T11:27:06.660" Score="1" ViewCount="389" Body="&lt;p&gt;I have similar text on more lines:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;_AB_ _ABC_ _&lt;/code&gt; &lt;em&gt;OR&lt;/em&gt; &lt;code&gt;_ _A_ _ABC_&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to replace only the underscores that delimit some text. So I need: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;=AB= =ABC= _&lt;/code&gt; &lt;em&gt;OR&lt;/em&gt; &lt;code&gt;_ =A= =ABC=&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to match each pattern?&lt;/p&gt;&#xA;" OwnerUserId="20882" LastEditorUserId="20882" LastEditDate="2019-02-07T11:44:13.077" LastActivityDate="2019-02-07T11:44:13.077" Title="How to match each occurrence per line?" Tags="|regular-expression|delimiter-matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18822" PostTypeId="2" ParentId="18821" CreationDate="2019-02-07T11:33:44.283" Score="4" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/_\([A-Za-z]\+\)_/=\1=/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[A-Za-z]&lt;/code&gt; matches the chars A-Z and a-z. You could add other chars between &lt;code&gt;[]&lt;/code&gt;. Note: If you want to add a dash (&lt;code&gt;-&lt;/code&gt;), it has to be the first char after the opening &lt;code&gt;[&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\+&lt;/code&gt; means &quot;one or more&quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-07T11:39:55.517" LastActivityDate="2019-02-07T11:39:55.517" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18823" PostTypeId="1" CreationDate="2019-02-07T11:46:42.637" Score="0" ViewCount="258" Body="&lt;p&gt;Before switching to vim years ago I was using Sublime Text and it perfectly handled situations when I just close it and open again. Nothing is lost and at the place where I left it off. So I'm aiming to reproduce that behaviour in Vim. What I have already is &lt;a href=&quot;https://github.com/xolox/vim-session&quot; rel=&quot;nofollow noreferrer&quot;&gt;xolox/vim-session&lt;/a&gt; set up and running and swap files properly working as I expect them to. However, I encountered an issue that I create a new buffer without a name and it's not possible to restore it when I close vim and open it again. I would use a temporary file name as it mentioned &lt;a href=&quot;https://vi.stackexchange.com/questions/2644/writing-modified-buffer-to-a-temporary-file&quot;&gt;here&lt;/a&gt; but I'm no so sure that this is the best approach to take. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my question is how to properly organize session save and restore even for unsaved buffers without a name?&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2019-02-07T11:46:42.637" Title="How to properly organize persistence of the vim state of all opened buffers?" Tags="|buffers|sessions|hidden-buffers|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18824" PostTypeId="2" ParentId="7126" CreationDate="2019-02-07T15:28:23.247" Score="8" Body="&lt;p&gt;Adding this to my .vimrc works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.tex silent! execute &quot;!pdflatex % &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&quot; | redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On all &lt;code&gt;.tex&lt;/code&gt; files it will execute &lt;code&gt;pdflatex &amp;lt;filename&amp;gt;&lt;/code&gt; upon &lt;code&gt;:w&lt;/code&gt; without outputting anything in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is minimal and uses no plugins or extra programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: on compilation errors vim appears to hang, but pressing return solves this.&lt;/p&gt;&#xA;" OwnerDisplayName="user20887" LastEditorDisplayName="user20887" LastEditDate="2019-02-08T20:55:45.040" LastActivityDate="2019-02-08T20:55:45.040" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18825" PostTypeId="1" CreationDate="2019-02-07T20:00:17.817" Score="1" ViewCount="143" Body="&lt;p&gt;My LaTeX files contain lots of acronyms and they are often highlighted as spelling errors. I tried to ignore acronyms by adding &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match AcronymNoSpell '\&amp;lt;\(\u\|\d\)\{3,}s\?\&amp;gt;' contains=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(as suggested &lt;a href=&quot;http://www.panozzaj.com/blog/2016/03/21/ignore-urls-and-acroynms-while-spell-checking-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;) to my &lt;code&gt;~/.vim/after/syntax/tex.vim&lt;/code&gt; file but the acronyms are still highlighted. I'm wondering if I'm leaving out a setting or if the settings are being overwritten by something else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;filetype plugin indent on&#xA;&#xA;&quot; Enable backspace to work like normal text editors&#xA;set backspace=indent,eol,start&#xA;&#xA;&quot; vim-latex-live-preview settings&#xA;let g:livepreview_previewer = 'open -a Skim'&#xA;&#xA;&quot; Enable Spell Checking&#xA;set spelllang=en&#xA;set spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20890" LastActivityDate="2019-02-07T20:00:17.817" Title="Ignore acronyms as spelling errors in TeX files" Tags="|vimrc|syntax-highlighting|filetype-tex|spell-checking|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18826" PostTypeId="1" AcceptedAnswerId="18828" CreationDate="2019-02-08T00:20:33.940" Score="0" ViewCount="229" Body="&lt;p&gt;I'm trying to add whitespace on the left side of the flags section, and to hide this whitespace when flags aren't exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I mean:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Statusline with no flags:&#xA;:File.txt                              text:&#xA;:------------------------------------------:&#xA;&#xA;The same, with flags:&#xA;:File.ext                   text    [+][RO]:&#xA;:------------------------------------------:&#xA;&#xA;Incorrect:&#xA;:File.ext                          text    :&#xA;:------------------------------------------:&#xA;&#xA;Colons and hyphens are used to show window size.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is statusline code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set laststatus=2&#xA;set statusline=&#xA;set statusline+=%t&#xA;set statusline+=%=&#xA;set statusline+=%{strlen(&amp;amp;filetype)?&amp;amp;filetype:'text'}&#xA;&quot;set statusline+=%{&amp;amp;modified?'\ \ \ \ ':''}             &quot; Works&#xA;set statusline+=%{(&amp;amp;modified||&amp;amp;readonly)?'\ \ \ \ ':''} &quot; Doesn't work&#xA;set statusline+=%m%r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, there is an issue with 7th line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, there are two questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How to check condition against both flags?&lt;/li&gt;&#xA;&lt;li&gt;A better option: is there a way to check against &lt;em&gt;any&lt;/em&gt; flag? If we have some arbitrary flag in statusline, then add whitespace; if we don't have flags, then don't add whitespace.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7169" LastEditorUserId="7169" LastEditDate="2019-02-08T00:27:34.453" LastActivityDate="2019-02-08T10:55:40.440" Title="Add whitespace conditionally, based on flags" Tags="|vimrc|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18828" PostTypeId="2" ParentId="18826" CreationDate="2019-02-08T05:22:35.973" Score="1" Body="&lt;p&gt;You have to escape the pipe symbols, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{(&amp;amp;modified\|\|&amp;amp;readonly)?'\ \ \ \ ':''} &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it gets to complicated, you might consider to use a function to create the statusline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyStatusLine()&#xA;    let sl = '%t%='&#xA;    if &amp;amp;filetype != ''&#xA;        let sl .= &amp;amp;filetype&#xA;    else&#xA;        let sl .= 'text'&#xA;    endif&#xA;    if &amp;amp;modified || &amp;amp;readonly&#xA;        let sl .= '    '&#xA;    endif&#xA;    let sl .= '%m%r'&#xA;    return sl&#xA;endfunc&#xA;set statusline=%!MyStatusLine()&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;The flags named in &lt;code&gt;:help stl&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%m/%M&lt;/code&gt; is &lt;code&gt;&amp;amp;modified&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%r/%R&lt;/code&gt; is &lt;code&gt;&amp;amp;readonly&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%h/%H&lt;/code&gt; is &lt;code&gt;&amp;amp;filetype == 'help'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%w/%W&lt;/code&gt; is &lt;code&gt;&amp;amp;previewwindow&lt;/code&gt; &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-08T10:55:40.440" LastActivityDate="2019-02-08T10:55:40.440" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18830" PostTypeId="2" ParentId="18777" CreationDate="2019-02-08T07:12:11.227" Score="1" Body="&lt;p&gt;If I understand correctly what you want, the following mapping achieves it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt;&amp;lt;silent&amp;gt; { (col('.')==1 &amp;amp;&amp;amp; len(getline(line('.')-1))==0? '2{j' : '{j')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a map expression, that means one can use expression have evaluated at the time the mapping is performed and react to certain conditions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the specific case, it checks, whether the cursor is at the beginning of a line (&lt;code&gt;col('.')==1&lt;/code&gt;) &lt;strong&gt;and&lt;/strong&gt; the line before that is empty (&lt;code&gt;len(getline(line('.')-1))==0&lt;/code&gt;). If that is the case, it will perform the motion &lt;code&gt;2{j&lt;/code&gt; (to not end at the same place with the &lt;code&gt;{j&lt;/code&gt;, else it will perform only &lt;code&gt;{j&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-02-08T07:12:11.227" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18832" PostTypeId="1" CreationDate="2019-02-08T08:27:50.377" Score="-1" ViewCount="132" Body="&lt;p&gt;&lt;code&gt;:scriptnames&lt;/code&gt; outputs a (not convenient) list with more at the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to have all the output in a buffer so i can search, edit ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do i do that?&lt;/p&gt;&#xA;" OwnerUserId="19908" LastActivityDate="2019-02-08T08:59:46.023" Title="How to output the result of a command like :scriptnames in a buffer" Tags="|command-line|" AnswerCount="2" CommentCount="0" ClosedDate="2019-02-08T10:44:08.493" ContentLicense="CC BY-SA 4.0" />
  <row Id="18833" PostTypeId="2" ParentId="18832" CreationDate="2019-02-08T08:35:56.210" Score="0" Body="&lt;p&gt;You could redirect the output to a register like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @a | silent scriptnames | redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then past the content of the register wherever you want with &lt;code&gt;&quot;ap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;silent&lt;/code&gt; is used here, to prevent a &quot;-- More --&quot; prompt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also redirect to file or a script variable. See &lt;code&gt;:help :redir&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-08T08:35:56.210" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18834" PostTypeId="2" ParentId="18832" CreationDate="2019-02-08T08:59:46.023" Score="2" Body="&lt;p&gt;You can also directly paste it into the current buffer using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put =execute(':scriptnames')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-02-08T08:59:46.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18835" PostTypeId="2" ParentId="10245" CreationDate="2019-02-08T09:10:43.127" Score="6" Body="&lt;p&gt;For those curious, if NerdTree can xdg-open: Yes it can.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Put the cursor on the desired file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;em&gt;m&lt;/em&gt; for the context menu.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;em&gt;o&lt;/em&gt; to open in the system editor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Enjoy.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="20898" LastActivityDate="2019-02-08T09:10:43.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18836" PostTypeId="2" ParentId="18819" CreationDate="2019-02-08T09:44:23.283" Score="0" Body="&lt;p&gt;You could use Ctrl+O to go back to the previous positions instead of relying on the standard scrolling commands. &lt;/p&gt;&#xA;" OwnerUserId="10482" LastActivityDate="2019-02-08T09:44:23.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18837" PostTypeId="2" ParentId="18777" CreationDate="2019-02-08T11:00:40.280" Score="0" Body="&lt;p&gt;I have defined following mappings using the search function to avoid messing up search history:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; } :call search('\(^$\n\s*\zs\S\)\&amp;lt;bar&amp;gt;\(\S\ze\n*\%$\)', 'sW')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; { :call search('\(^$\n\s*\zs\S\)\&amp;lt;bar&amp;gt;\(^\%1l\s*\zs\S\)','sWb')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can jump to a possibly indented beginning of a paragraph with &lt;code&gt;}&lt;/code&gt; and &lt;code&gt;{&lt;/code&gt;. Additionally, at the last paragraph you jump to the end of the last line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;&#xA;    CURSOR Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod&#xA;tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At&#xA;vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,&#xA;no sea takimata sanctus est Lorem ipsum dolor sit amet.&#xA;&#xA;    CURSOR Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod&#xA;tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At&#xA;vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,&#xA;no sea takimata sanctus est Lorem ipsum dolor sit amet. CURSOR&#xA;&#xA;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Variant&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you prefer to jump to the start or end of the file as well, use following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; } :call search('\(^$\n\s*\zs\S\)\&amp;lt;bar&amp;gt;\%$', 'sW')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; { :call search('\(^$\n\s*\zs\S\)\&amp;lt;bar&amp;gt;\%1l','sWb')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CURSOR&#xA;&#xA;&#xA;    CURSOR Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod&#xA;tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At&#xA;vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,&#xA;no sea takimata sanctus est Lorem ipsum dolor sit amet.&#xA;&#xA;    CURSOR Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod&#xA;tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At&#xA;vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,&#xA;no sea takimata sanctus est Lorem ipsum dolor sit amet.&#xA;&#xA;&#xA;CURSOR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(remove &lt;code&gt;CURSOR&lt;/code&gt; to test also the behavior with whitespace)&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-02-08T11:06:13.997" LastActivityDate="2019-02-08T11:06:13.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18838" PostTypeId="1" AcceptedAnswerId="18840" CreationDate="2019-02-08T11:18:11.487" Score="3" ViewCount="110" Body="&lt;p&gt;I write ruby test files in vim, and regularly run tests from the file I'm editing by running &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:!rspec %:N&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or something similar (to execute the test at line N). The &lt;em&gt;problem&lt;/em&gt; is that when the first digit of N is an 8, like: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:!rspec %:89&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get an error: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;cannot load such file -- /.../foo_spec.rb9&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it looks like the sequence &lt;code&gt;%:8&lt;/code&gt; means something inside of a colon command. Additionally, if I &lt;em&gt;escape&lt;/em&gt; the colon: &lt;code&gt;rspec %\:89&lt;/code&gt; works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But why is this happening?&lt;/p&gt;&#xA;" OwnerUserId="17288" LastActivityDate="2019-02-08T12:34:44.670" Title="Why does colon in shell command read the wrong file?" Tags="|external-command|ex-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18839" PostTypeId="1" CreationDate="2019-02-08T11:24:47.010" Score="2" ViewCount="120" Body="&lt;p&gt;As system administrator I have to work under several user IDs, some of which are shared with others. We all have different tastes in what we like in terms of settings for our vi, so I am looking at ways to easily set up our own preferences. It would be ideal to use the &lt;em&gt;-u&lt;/em&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi -u ~myusername/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it looks like it simply gets ignored - I have tried to strace it, and there is no reference to the alternative vimrc at all. Is there some other option I need to use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;---EDIT---&#xA;To answer the questions in the comments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bash-4.2$ type -a vi&#xA;vi is /bin/vi&#xA;vi is /usr/bin/vi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bash-4.2$ vi --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug  2 2017 00:45:54)&#xA;Included patches: 1-160&#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Small version without GUI.  Features included (+) or not (-):&#xA;+acl             -farsi           -mouse_sgr       -tag_old_static&#xA;-arabic          -file_in_path    -mouse_sysmouse  -tag_any_white&#xA;-autocmd         -find_in_path    -mouse_urxvt     -tcl&#xA;-balloon_eval    -float           -mouse_xterm     +terminfo&#xA;-browse          -folding         +multi_byte      -termresponse&#xA;+builtin_terms   -footer          -multi_lang      -textobjects&#xA;-byte_offset     +fork()          -mzscheme        -title&#xA;-cindent         -gettext         -netbeans_intg   -toolbar&#xA;-clientserver    -hangul_input    -path_extra      -user_commands&#xA;-clipboard       +iconv           -perl            -vertsplit&#xA;-cmdline_compl   -insert_expand   -persistent_undo -virtualedit&#xA;+cmdline_hist    +jumplist        -printer         +visual&#xA;-cmdline_info    -keymap          -profile         -visualextra&#xA;-comments        -langmap         -python          -viminfo&#xA;-conceal         -libcall         -python3         -vreplace&#xA;-cryptv          -linebreak       -quickfix        +wildignore&#xA;-cscope          -lispindent      -reltime         -wildmenu&#xA;-cursorbind      -listcmds        -rightleft       +windows&#xA;-cursorshape     -localmap        -ruby            +writebackup&#xA;-dialog          -lua             -scrollbind      -X11&#xA;-diff            -menu            -signs           -xfontset&#xA;-digraphs        -mksession       -smartindent     -xim&#xA;-dnd             -modify_fname    -sniff           -xsmp&#xA;-ebcdic          -mouse           -startuptime     -xterm_clipboard&#xA;-emacs_tags      -mouse_dec       -statusline      -xterm_save&#xA;-eval            -mouse_gpm       -sun_workshop    -xpm&#xA;-ex_extra        -mouse_jsbterm   -syntax          &#xA;-extra_search    -mouse_netterm   -tag_binary      &#xA;   system vimrc file: &quot;/etc/virc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/etc&quot;&#xA; f-b for $VIMRUNTIME: &quot;/usr/share/vim/vim74&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -Wl,-z,relro  -L/usr/local/lib -Wl,--as-needed -o vim        -lm  -lselinux -lncurses -lacl -lattr -ldl          &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The odd - very odd IMO - thing is, when I expand the path of &lt;code&gt;~myusername/.vimrc&lt;/code&gt; using &lt;code&gt;echo ~myusername/.vimrc&lt;/code&gt; (IOW using the shell as normal) and then start &lt;code&gt;vi -u&lt;/code&gt; with the explicit path, then it works, which makes no sense to me.&lt;/p&gt;&#xA;" OwnerUserId="20900" LastEditorUserId="20900" LastEditDate="2019-02-08T13:25:30.303" LastActivityDate="2019-02-08T13:25:30.303" Title="vi -u doesn't seem to work?" Tags="|vimrc|options|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18840" PostTypeId="2" ParentId="18838" CreationDate="2019-02-08T11:26:28.950" Score="3" Body="&lt;p&gt;As you already know &lt;code&gt;%&lt;/code&gt; in the vim command line is resolved to the path name of&#xA;the file in the current buffer. But &lt;code&gt;%&lt;/code&gt; can  be modified by adding a modifier.&#xA;A modifier starts with a &lt;code&gt;:&lt;/code&gt; and &lt;code&gt;:8&lt;/code&gt; is a valid modifier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help filename-modifiers&lt;/code&gt; for the full list of modifiers. For &lt;code&gt;:8&lt;/code&gt; it&#xA;says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;  :8  Converts the path to 8.3 short format (currently only on&#xA;      MS-Windows).  Will act on as much of a path that is an&#xA;      existing path.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On Linux a &lt;code&gt;%:8&lt;/code&gt; is just like &lt;code&gt;%&lt;/code&gt;, so &lt;code&gt;%:89&lt;/code&gt; results in &lt;code&gt;%9&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-08T12:34:44.670" LastActivityDate="2019-02-08T12:34:44.670" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18841" PostTypeId="2" ParentId="11977" CreationDate="2019-02-08T11:59:23.023" Score="0" Body="&lt;p&gt;By using &lt;code&gt;matchup&lt;/code&gt; with &lt;code&gt;textobj-user&lt;/code&gt; which provides the &lt;code&gt;%&lt;/code&gt; text object for code blocks you can select the first block with &lt;code&gt;vi%&lt;/code&gt;. Incrementally selecting outer blocks are done by hitting &lt;code&gt;i%&lt;/code&gt;, &lt;code&gt;i%&lt;/code&gt;, ... (or &lt;code&gt;a%&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="5410" LastActivityDate="2019-02-08T11:59:23.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18842" PostTypeId="2" ParentId="11977" CreationDate="2019-02-08T12:37:05.480" Score="1" Body="&lt;h3&gt;Recommendation: do not do it&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I &lt;strong&gt;strongly&lt;/strong&gt; recommend not to remap &lt;code&gt;.&lt;/code&gt; to extend visual selections. &lt;code&gt;.&lt;/code&gt; is meant to repeat the last change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You break an essential workflow pattern of vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also plugins are designed around this pattern: for example, consider the plugin &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=3848&quot; rel=&quot;nofollow noreferrer&quot;&gt;visualrepeat&lt;/a&gt;: its purpose is to make it possible to press &lt;code&gt;.&lt;/code&gt; to apply the last change to the current visual selection. If &lt;code&gt;.&lt;/code&gt; extends the selection, this plugin does not work as intended. This is only a single example. There are plenty more of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really need a single key to extend the last applied text object in visual mode, extending &lt;code&gt;,&lt;/code&gt; might be a better choice. But I am also not entirely convinced of this choice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend to get used to pressing &lt;code&gt;va{a{&lt;/code&gt; or &lt;code&gt;v2a{&lt;/code&gt;. It is not that bad.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;{&lt;/code&gt; on a French keyboard&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If the motivation is the French keyboard layout, I would consider following options&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;simply use &lt;code&gt;aB&lt;/code&gt; instead of &lt;code&gt;a{&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a%&lt;/code&gt; from vim-matchup might also be helpful&lt;/li&gt;&#xA;&lt;li&gt;repeat the motions &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; with &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt; with the help of &lt;a href=&quot;https://github.com/Houl/repmo-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Houl/repmo-vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;learn the English layout (I've done this myself coming from a German layout; I switch to German layout when writing German text otherwise I use the English layout)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-02-08T12:37:05.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18843" PostTypeId="1" AcceptedAnswerId="19381" CreationDate="2019-02-08T13:36:49.847" Score="0" ViewCount="300" Body="&lt;p&gt;&lt;strong&gt;N.B&lt;/strong&gt; I use the word &lt;em&gt;blank&lt;/em&gt; here due to lack of a better word. By &lt;em&gt;blank&lt;/em&gt; I mean the remaining part of a tab that is visualized after the starting part. Please feel free to edit this question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there are questions already answered about vim's indent with tabs and align with spaces. But those questions have answers that says it's not possible or possible with supertab plugin. And moreover, my question is a little bit specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take this example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Format_tabs() abort&#xA;&amp;gt;...let s = ''&#xA;&amp;gt;...let s .= repeat(' ', &amp;amp;ts)&#xA;&amp;gt;...let t = '&amp;gt;..&amp;gt;...hello there&amp;gt;&amp;gt;...hey'&#xA;&amp;gt;...echo substitute(t, '\v[^\t]+\zs\t+\ze', s, 'g')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where all &lt;code&gt;&amp;gt;&lt;/code&gt; are start of a tab and following &lt;code&gt;.&lt;/code&gt; are the remaining &lt;em&gt;blank&lt;/em&gt; part throughout the tabstop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And my tabstop settings are all set to 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the above function I'm trying to convert the tabs in the string that are not at the beginning of a line with equivalent number of spaces. At the beginning I thought, I could replace each tabs, that are not at the beginning, with &amp;amp;tabstop number of spaces. But it turns out due to some settings, that I'm not trying to change, the tabs show different amount of &lt;em&gt;blanks&lt;/em&gt; to figure out the alignment. So I need to figure out how many spaces I need to substitute the tabs for. But I have no idea!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any solution?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-06T06:15:57.337" Title="Substitute tabs for equivalent number of spaces" Tags="|indentation|substitute|alignment|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="18844" PostTypeId="1" AcceptedAnswerId="18845" CreationDate="2019-02-08T14:03:12.647" Score="0" ViewCount="588" Body="&lt;p&gt;I've this in my vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:currentmode={&#xA;            \ 'n'      : 'NORMAL  ',&#xA;            \ 'v'      : 'VISUAL  ',&#xA;            \ 'V'      : 'V·Line  ',&#xA;            \ '^V' : 'V·Block ',&#xA;            \ 'i'      : 'INSERT  ',&#xA;            \ 'R'      : 'REPLACE ',&#xA;            \ 'c'      : 'COMMAND ',&#xA;            \ 't'      : 'TERM    '&#xA;            \}&#xA;&#xA;set statusline=&#xA;            \%{toupper(g:currentmode[mode()])}&#xA;            \\ %{&amp;amp;filetype!=#''?&amp;amp;filetype:'none'}&#xA;            \\ \ %{&amp;amp;fileformat==#'unix'?'U':&amp;amp;fileformat==#'dos'?'D':'N'}&#xA;            \:%{&amp;amp;readonly\|\|!&amp;amp;modifiable?&amp;amp;modified?'%*':'%%':&amp;amp;modified?'**':'--'}&#xA;            \\ \ %{expand('%:~:.')!=#''?expand('%:~:.'):'[No\ Name]'}&#xA;            \%=\ %3p%%\ \ %l:\ %3c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The character that you see as the key in the currentmode dictionary for the value &lt;code&gt;V.Block&lt;/code&gt; is something I inserted by pressing &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;C-v&lt;/code&gt;, but here it shows up as a box, so I changed it into &lt;code&gt;^V&lt;/code&gt; for the sake of visibility here in the forum. I don't want a keyword like that in my vimrc, is there any way I can change it into something like &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;? I've tried &lt;code&gt;\&amp;lt;C-v&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;, doesn't work either of these.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-08T14:13:33.823" LastActivityDate="2019-02-08T14:21:41.217" Title="\&lt;C-v&gt; character in vim" Tags="|keyword|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18845" PostTypeId="2" ParentId="18844" CreationDate="2019-02-08T14:21:41.217" Score="1" Body="&lt;p&gt;The problem are the single-quotes you are using. Single quotes enclose &quot;literal-strings&quot;, in these strings, the backslash is not a escape character, but just a backslash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use double-quotes like &lt;code&gt;&quot;\&amp;lt;C-v&amp;gt;&quot;&lt;/code&gt;. Just try the following two commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo '\&amp;lt;C-v&amp;gt;'&#xA;:echo &quot;\&amp;lt;C-v&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might want to read &lt;code&gt;:help string&lt;/code&gt; and &lt;code&gt;:help literal-string&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-08T14:21:41.217" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18846" PostTypeId="1" AcceptedAnswerId="18849" CreationDate="2019-02-08T15:31:39.490" Score="2" ViewCount="1289" Body="&lt;p&gt;I am writing a compiler plugin for eslint. It mostly works, but I want to ignore some lines in the output and am unsure how.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the eslint &quot;unix&quot; format, which outputs errors like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/chris/Sites/build/web/test.js:1:1: Use the function form of 'use strict'. [Error/strict]&#xA;/Users/chris/Sites/build/web/test.js:2:3: Unexpected console statement. [Warning/no-console]&#xA;&#xA;2 problems&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice the blank line and &quot;2 problems&quot; line at the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My errorformat is this: &lt;code&gt;%f:%l:%c:\ %m&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works, except I get the blank line and the &quot;2 problems&quot; line in my quickfix list, like so.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;test.js|1 col 1| Use the function form of 'use strict'. [Error/strict]&#xA;test.js|2 col 3| Unexpected console statement. [Warning/no-console]&#xA;|| &#xA;|| 2 problems&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reading the errorformat help docs, I see I can ignore some pieces with &lt;code&gt;%-&lt;/code&gt;, but I'm unsure how to apply that to just blank lines or lines matching this &quot;[number] problems&quot; format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated. Thanks in advance! &lt;/p&gt;&#xA;" OwnerUserId="14" LastActivityDate="2019-02-08T21:02:02.870" Title="Ignore lines in errorformat" Tags="|errorformat|eslint|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18847" PostTypeId="1" AcceptedAnswerId="18867" CreationDate="2019-02-08T16:40:01.330" Score="1" ViewCount="1186" Body="&lt;p&gt;My &lt;code&gt;$VIM\_vimrc&lt;/code&gt; is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/vimrc_example.vim&#xA;source $VIMRUNTIME/mswin.vim&#xA;behave mswin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;$HOME\_vimrc&lt;/code&gt; does &lt;strong&gt;not&lt;/strong&gt; have this option. I was led to believe that Vim first invokes the system &lt;code&gt;_vimrc&lt;/code&gt; in &lt;code&gt;$VIM&lt;/code&gt;, then moves on to the user &lt;code&gt;_vimrc&lt;/code&gt; in their respective &lt;code&gt;$HOME&lt;/code&gt;s, but it's obvious here that that's no longer the case here. This is important because I need to move all of my personal configs somewhere else, and &lt;code&gt;$VIM&lt;/code&gt; is not a good option. Any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Edit 1&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;After the use of &lt;code&gt;:scriptnames&lt;/code&gt; as per recommendations of the comment below, I found that indeed, a) &lt;code&gt;$VIM\_vimrc&lt;/code&gt; was &lt;strong&gt;not used&lt;/strong&gt;, and b) the first file used was &lt;code&gt;$HOME\_vimrc&lt;/code&gt;. I need Vim to use, first and foremost, &lt;code&gt;$VIM\_vimrc&lt;/code&gt;, so that Vim recognizes &lt;code&gt;$HOME&lt;/code&gt; to be elsewhere of the &lt;code&gt;C:\Users\foo&lt;/code&gt; that I currently use.&lt;/p&gt;&#xA;" OwnerUserId="20750" LastEditorUserId="20750" LastEditDate="2019-02-08T18:19:35.203" LastActivityDate="2019-08-13T15:57:05.500" Title="My gVim (8.1, Win10) does NOT invoke $VIM\_vimrc during initialization" Tags="|vimrc|gvim|microsoft-windows|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18848" PostTypeId="2" ParentId="18843" CreationDate="2019-02-08T20:28:55.753" Score="1" Body="&lt;p&gt;This seems to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReplaceMiddleTabs() abort&#xA;    let s:linenum = line('.')&#xA;    let s:current_line = getline(s:linenum)&#xA;    let s:temp = Format_tabs(s:current_line)&#xA;    call setline(s:linenum, s:temp)&#xA;endfunction&#xA;&#xA;function! Format_tabs(line) abort&#xA;    let s:tablen = &amp;amp;ts&#xA;    let s:start = match(a:line, '^\s\+\zs.\ze')&#xA;&#xA;    let s:temp = a:line&#xA;    let s:control = 1&#xA;    while s:control &amp;gt; 0&#xA;        let s:next = match(s:temp, '\t', s:start + 1)&#xA;        if s:next &amp;gt; 0&#xA;            let s:mod = (s:next % s:tablen)&#xA;            if s:mod == 0&#xA;                let s:mod = 4&#xA;            endif&#xA;            let s:substlen = s:tablen - s:mod + 1&#xA;&#xA;            let s:temp = s:temp[0:s:next - 1] . repeat(' ', s:substlen) . s:temp[s:next + 1:]&#xA;        else&#xA;            let s:control = 0&#xA;        endif&#xA;    endwhile&#xA;&#xA;    return s:temp&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The trick here is to calculate how many visual spaces each tab fills.&#xA;To test it, I've used this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|...|...|...|...|...|...|...|...|...|...|...|&#xA;&amp;gt;...|...&amp;gt;...|...|...|...|...|...|...|...|...|&#xA;&amp;gt;...|...|&amp;gt;..|...|...|...|...|...|...|...|...|&#xA;&amp;gt;...|...|.&amp;gt;.|...|...|...|...|...|...|...|...|&#xA;&amp;gt;...|...|..&amp;gt;|...|...|...|...|...|...|...|...|&#xA;&amp;gt;...|...|...&amp;gt;...|...|...|...|...|...|...|...|&#xA;&amp;gt;...|...&amp;gt;...|...|&amp;gt;..&amp;gt;...&amp;gt;...&amp;gt;...&amp;gt;...|...|...|&#xA;&amp;gt;...|...|&amp;gt;..|...|.&amp;gt;.|.&amp;gt;.|.&amp;gt;.|.&amp;gt;.|...|...|...|&#xA;&amp;gt;...|...|.&amp;gt;.|...|..&amp;gt;|..&amp;gt;|..&amp;gt;|..&amp;gt;|...|...|...|&#xA;&amp;gt;...|...|..&amp;gt;|...|...&amp;gt;...&amp;gt;...|...&amp;gt;...|...|...|&#xA;&amp;gt;...|...|...&amp;gt;...|...|...&amp;gt;...|..&amp;gt;|.&amp;gt;.|&amp;gt;..|...|&#xA;|...|...|...|...|...|...|...|...|...|...|...|&#xA;&#xA;:%s/&amp;gt;\.*/\t/g&#xA;:call ReplaceMiddleTabs()&#xA;:%s/\t/&amp;gt;###/g&#xA;&#xA;|...|...|...|...|...|...|...|...|...|...|...|&#xA;&amp;gt;###|...    |...|...|...|...|...|...|...|...|&#xA;&amp;gt;###|...|   |...|...|...|...|...|...|...|...|&#xA;&amp;gt;###|...|.  |...|...|...|...|...|...|...|...|&#xA;&amp;gt;###|...|.. |...|...|...|...|...|...|...|...|&#xA;&amp;gt;###|...|...    |...|...|...|...|...|...|...|&#xA;&amp;gt;###|...    |...|                   |...|...|&#xA;&amp;gt;###|...|   |...|.  |.  |.  |.  |...|...|...|&#xA;&amp;gt;###|...|.  |...|.. |.. |.. |.. |...|...|...|&#xA;&amp;gt;###|...|.. |...|...        |...    |...|...|&#xA;&amp;gt;###|...|...    |...|...    |.. |.  |   |...|&#xA;|...|...|...|...|...|...|...|...|...|...|...|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this is my first &lt;code&gt;vimscript&lt;/code&gt; function, so look at it with a grain of salt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edited: use &lt;code&gt;%&lt;/code&gt; (thanks, @Enan Ajmain)&lt;/p&gt;&#xA;" OwnerUserId="11384" LastEditorUserId="11384" LastEditDate="2019-02-11T11:06:55.833" LastActivityDate="2019-02-11T11:06:55.833" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18849" PostTypeId="2" ParentId="18846" CreationDate="2019-02-08T21:02:02.870" Score="6" Body="&lt;p&gt;Try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set errorformat=%A%f:%l:%c:%m,%-G%.%#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The final &lt;code&gt;%-G%.%#&lt;/code&gt; acts as a &quot;catch all&quot; clause, that ignores all lines, that are not matched by previous expressions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following should also work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set errorformat=%A%f:%l:%c:%m,%-G\\s%#,%-G%*\\d\ problem%.%#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%-G\\s%#&lt;/code&gt; ignores all lines that contains zero or more whitespaces. This inclues empty lines.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%-G%*\\d\ problem%.%#&lt;/code&gt; ignores lines, that start with digits, a space and followed by &quot;problem&quot;. I removed the final &lt;code&gt;s&lt;/code&gt; and replaced it by &lt;code&gt;%.%#&lt;/code&gt; (regex: &lt;code&gt;.*&lt;/code&gt;), as I don't know if the s is omitted, when only one problem is detected.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The expression to match zero-or-more whitespaces (&lt;code&gt;\\s%#&lt;/code&gt;) is different from zero-or-more digits (&lt;code&gt;%*\\d&lt;/code&gt;). I'm don't understand why this is different. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both formats tested with your example input.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-08T21:02:02.870" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18851" PostTypeId="1" CreationDate="2019-02-09T00:07:01.767" Score="0" ViewCount="100" Body="&lt;p&gt;In this function I would like to substitute everything within &lt;code&gt;(&quot;&lt;/code&gt; and &lt;code&gt;&quot;)&lt;/code&gt; with emptiness&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ListJoinFolds() abort&#xA;    0&#xA;    let bufnr = bufnr('%')&#xA;    let items = []&#xA;    while 1&#xA;        let start = search('^{{{', 'cW')&#xA;        if !start&#xA;            break&#xA;        endif&#xA;        let end = search('^}}}', 'W')&#xA;        let lines = getline(start, end)&#xA;        let lines = map(lines, 'trim(v:val)')&#xA;        call add(items, {&#xA;            \ 'bufnr': bufnr,&#xA;            \ 'lnum': start,&#xA;            \ 'text': join(lines, ' '),&#xA;        \ })&#xA;        &quot; credits to: https://www.reddit.com/r/vim/comments/akv0wl/function_sort_output_alphabetically/ef8nlrr&#xA;        call sort(items, {a, b -&amp;gt; a[&quot;text&quot;] == b[&quot;text&quot;] ? 0 : a[&quot;text&quot;] &amp;gt; b[&quot;text&quot;] ? 1 : -1})&#xA;    endwhile&#xA;    call setloclist(winnr(), items)&#xA;    lopen&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've added the following nearly every thinkable order I could think of, but my intelligence couldn't find the right place to succeed for the attempted success.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let lines = substitute(items, '(&quot;.\{-}&quot;)', '', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hopefully someone could assist me with this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also posted this question to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;reddit.com/r/vim (&lt;a href=&quot;https://www.reddit.com/r/vim/comments/aomufd/substitute_lines_in_a_function/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If question solved, I will post it here, and vice versa.&lt;/p&gt;&#xA;" OwnerUserId="20911" LastEditorDisplayName="user4879" LastEditDate="2019-02-09T11:02:24.617" LastActivityDate="2020-03-05T14:01:07.300" Title="substitute lines in a function" Tags="|substitute|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18852" PostTypeId="1" AcceptedAnswerId="18862" CreationDate="2019-02-09T02:59:10.693" Score="0" ViewCount="307" Body="&lt;p&gt;Following code switches off Vim syntax highlighting for buffers opened after its execution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufAdd * exe 'buffer ' . expand('&amp;lt;abuf&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why? Is it bug?&lt;/p&gt;&#xA;" OwnerUserId="20634" LastActivityDate="2019-02-10T08:27:05.477" Title="Vim disables syntax highlighting after execution `autocmd BufAdd * exe 'buffer ' . expand('&lt;abuf&gt;')`" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18853" PostTypeId="2" ParentId="18851" CreationDate="2019-02-09T06:17:42.110" Score="1" Body="&lt;p&gt;&lt;code&gt;substitute()&lt;/code&gt; only works on a &lt;em&gt;string&lt;/em&gt;. You appear to have been trying it with the &lt;code&gt;items&lt;/code&gt; list. Does something like this work for you (as a modification of the part where you add the text to the items list)?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    call add(items, {&#xA;        \ 'bufnr': bufnr,&#xA;        \ 'lnum': start,&#xA;        \ 'text': substitute(join(lines, ' '), '(&quot;.\{-}&quot;)', '', 'g'),&#xA;    \ })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user4879" LastActivityDate="2019-02-09T06:17:42.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18855" PostTypeId="1" CreationDate="2019-02-09T10:05:50.643" Score="1" ViewCount="382" Body="&lt;p&gt;Long time reader, first time poster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm having an issue with ALE (asynchronous lint engine) -- be aware that I'm a second year student and relatively new to programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really like this plugin. It is by far my most used vim plugin and it makes developing with a command line editor SO much more palatable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes (relatively often in fact) it stops recognizing errors in a (seemingly random) file. This often coincides with a loss of syntax highlighting. The highlighting can be fixed with an easy :set syntax=cpp but no matter what I try I can't get the linter back. Literally the only thing that works is changing my directory name (and if I change it back it disappears again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried all the ale commands that look promising (ALEReset, ALEEnable, ALEResetBuffer, ALEFix, etc) but they don't do anything. I've also tried completely uninstalling and reinstalling the plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers?&lt;/p&gt;&#xA;" OwnerUserId="20913" LastActivityDate="2019-02-09T10:05:50.643" Title="vim w0rp/ale plugin stops working out of the blue" Tags="|plugin-ale|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18856" PostTypeId="2" ParentId="18843" CreationDate="2019-02-09T18:01:21.277" Score="0" Body="&lt;p&gt;Based on the docs for &lt;code&gt;submatch()&lt;/code&gt;, I would use something like (untested)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Format_tabs() abort&#xA;  let t = '&amp;gt;..&amp;gt;...hello there&amp;gt;&amp;gt;...hey'&#xA;  echo substitute(t, '\v[^\t]+\zs\t+\ze', '\=repeat(&quot; &quot;, len(submatch(1)) * &amp;amp;tabstop)', 'g')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For reference, the example in the docs is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo substitute(text, '\d\+', '\=submatch(0) + 1', '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-02-10T04:10:50.343" LastActivityDate="2019-02-10T04:10:50.343" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18859" PostTypeId="1" AcceptedAnswerId="18863" CreationDate="2019-02-09T21:54:20.010" Score="4" ViewCount="1527" Body="&lt;p&gt;I'm trying to show / hide horizontal scrollbar conditionally, depending on &lt;code&gt;wrap&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;with &lt;code&gt;wrap&lt;/code&gt; - show horizontal scrollbar&lt;/li&gt;&#xA;&lt;li&gt;with &lt;code&gt;nowrap&lt;/code&gt; - hide&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is what I tried, but for some reason it doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guioptions+=%{&amp;amp;wrap?'b':''}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20821" LastActivityDate="2019-02-10T16:33:09.603" Title="Show / hide horizontal scrollbar depending on &quot;wrap&quot; option" Tags="|vimrc|scrolling|wrapping|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18860" PostTypeId="1" CreationDate="2019-02-09T23:13:36.357" Score="1" ViewCount="156" Body="&lt;p&gt;I have installed Vim-latex on my Mac. When I compiled my file, there seemed to be no error. Yet, when I pressed \lv, I got the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function Tex_ViewLaTeX:&#xA;line   34:&#xA;E121: Undefined variable: s:viewer&#xA;E116: Invalid arguments for function strlen(s:viewer)&#xA;line   39:&#xA;E121: Undefined variable: appOpt&#xA;line   79:&#xA;E121: Undefined variable: execString&#xA;E116: Invalid arguments for function substitute(execString, '\V$*', mainfname, 'g')&#xA;line   80:&#xA;E121: Undefined variable: execString&#xA;E116: Invalid arguments for function Tex_Debug&#xA;line   82:&#xA;E121: Undefined variable: execString&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Besides, for the sake of testing, I added an extra $ sign in my source file, but I got the same result as before when I pressed \ll. Thus, I guess the compilation was actually problematic. Does anyone know how to resolve this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help will be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="14411" LastEditorUserId="14411" LastEditDate="2019-02-09T23:21:25.020" LastActivityDate="2019-02-09T23:21:25.020" Title="vim-latex compilation and viewing" Tags="|plugin-vim-latex|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18861" PostTypeId="1" AcceptedAnswerId="18866" CreationDate="2019-02-10T03:12:57.593" Score="2" ViewCount="746" Body="&lt;p&gt;I have a job I want to run in the background of vim, and update my status line with the periodic results of that job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm able to setup the timer, call the external job and get my response back. I'm able to &lt;code&gt;echom&lt;/code&gt; the response and see it in &lt;code&gt;:messages&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am unable to get my global variable to take hold of the new value though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:please_vim_why = 'an echo example'&#xA;let g:why_vim_why = -1&#xA;function! TimerRun(timer)&#xA;  call jobstart('date', {'on_stdout': 'TimerCallback'})&#xA;endfunction&#xA;function! TimerCallback(j, d, e)&#xA;  echom a:d[0]&#xA;  let g:why_vim_why = a:d[0]&#xA;endfunction&#xA;let timer = timer_start(2000, 'TimerRun', {'repeat': -1})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Run via &lt;code&gt;nvim -u godwhyvimwhydoyouhateme.vim&lt;/code&gt; to load it as your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you go &lt;code&gt;:echo g:please_vim_why&lt;/code&gt;, you'll see the response, 'an echo example'. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you run &lt;code&gt;:messages&lt;/code&gt;, you'll see a repeated output of the date.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If you run &lt;code&gt;:echo g:why_vim_why&lt;/code&gt; you will see no output.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought maybe it might be &lt;code&gt;a:d&lt;/code&gt; is scoped and gets garbage collected after the function, but &lt;code&gt;let g:why_vim_why = 'not a good joke' . a:d[0]&lt;/code&gt;, sets the variable to 'not a good joke' but doesn't concatenate anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why VIM? Why?&lt;/p&gt;&#xA;" OwnerUserId="20041" LastEditorUserId="20041" LastEditDate="2019-02-10T15:30:39.503" LastActivityDate="2019-02-10T16:14:07.127" Title="jobstart callback wont assign variable outside of function" Tags="|vimscript|neovim|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18862" PostTypeId="2" ParentId="18852" CreationDate="2019-02-10T08:27:05.477" Score="1" Body="&lt;p&gt;In the comment you describe, that you want to do &lt;code&gt;nmap &amp;lt;buffer&amp;gt;&lt;/code&gt; on &lt;code&gt;BufAdd&lt;/code&gt;&#xA;event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The event &lt;code&gt;BufAdd&lt;/code&gt; is very early in the processing, the use-cases for this&#xA;event are limited.&#xA;If you want to do buffer local mappings, you should do that with &lt;code&gt;autocmd BufEnter&lt;/code&gt; or with &lt;code&gt;autocmd FileType&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter *.c   nnoremap &amp;lt;buffer&amp;gt; ...&#xA;autocmd FileType c     nnoremap &amp;lt;buffer&amp;gt; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW: You should prefer &lt;code&gt;noremap&lt;/code&gt; to &lt;code&gt;map&lt;/code&gt;. See the answer to &lt;a href=&quot;https://vi.stackexchange.com/questions/2089/what-are-the-differences-between-the-map-noremap-abbrev-and-noreabbrev-command&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Back to your initial question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Autocmds are blocked while another autocmd is running. In your case, you use an&#xA;autocmd on &lt;code&gt;BufAdd&lt;/code&gt; to immediately switch to the new buffer. Switching to a new&#xA;buffer needs to read the file and would normally trigger the &lt;code&gt;BufRead&lt;/code&gt; and&#xA;&lt;code&gt;BufEnter&lt;/code&gt; autocmds, that are used to determine the file type and hence the&#xA;syntax highlighting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As this switch to the buffer is done in the context of an autocmd, the&#xA;&lt;code&gt;BufRead&lt;/code&gt; and &lt;code&gt;BufRead&lt;/code&gt; events are not triggered. So no file type detection and hence&#xA;no syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Don't use the following in your case, use another autocmd event  as described above.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible, to allow nested autocmds by adding the keyword &lt;code&gt;nested&lt;/code&gt;, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufAdd * nested ....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then autocmds are triggered while the this autocmd is running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to read &lt;code&gt;:help autocmd-nested&lt;/code&gt; for the details.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-10T08:27:05.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18863" PostTypeId="2" ParentId="18859" CreationDate="2019-02-10T09:20:17.900" Score="2" Body="&lt;p&gt;I guess you want the horizontal scrollbar on &lt;code&gt;nowrap&lt;/code&gt;.&#xA;You can handle this with a autocmd, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd OptionSet wrap if &amp;amp;wrap|set guioptions-=b|else|set guioptions+=b|endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you change the option &lt;code&gt;wrap&lt;/code&gt; &lt;em&gt;during runtime&lt;/em&gt;, this will automatically switch on/off the horizontal scrollbar. The autocommand is not triggered on startup (sourcing &lt;code&gt;vimrc&lt;/code&gt;), see &lt;code&gt;:help OptionSet&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your vimrc, you should define your initial settings like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nowrap&#xA;...&#xA;if &amp;amp;wrap&#xA;    set guioptions-=b&#xA;else&#xA;    set guioptions+=b&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, you just need to change &lt;code&gt;wrap&lt;/code&gt; and &lt;code&gt;guioptions&lt;/code&gt; will be changed as needed. Order is important here.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-10T16:33:09.603" LastActivityDate="2019-02-10T16:33:09.603" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18864" PostTypeId="1" AcceptedAnswerId="18865" CreationDate="2019-02-10T10:21:34.650" Score="0" ViewCount="127" Body="&lt;p&gt;I need to load a particular keymap file that enables me to write underscore, special characters by typing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set keymap=iast &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;iast.vim&lt;/code&gt; is my keymap file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This no longer works. Where should this file reside. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the mac and my vim package is updated by homebrew&lt;/p&gt;&#xA;" OwnerUserId="4709" LastEditorUserId="19763" LastEditDate="2019-02-10T11:33:04.110" LastActivityDate="2019-02-10T11:33:34.387" Title="Loading UTF keymap file" Tags="|key-bindings|macos|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18865" PostTypeId="2" ParentId="18864" CreationDate="2019-02-10T11:33:34.387" Score="0" Body="&lt;p&gt;According to the docs (&lt;code&gt;:help mbyte-keymap&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The value of the 'keymap' option specifies a keymap file to use.  The name of&#xA;  this file is one of these two:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;keymap/{keymap}_{encoding}.vim&#xA;keymap/{keymap}.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would expect &lt;code&gt;$HOME/.vim/keymap/iast.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-10T11:33:34.387" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18866" PostTypeId="2" ParentId="18861" CreationDate="2019-02-10T15:19:27.000" Score="6" Body="&lt;p&gt;The &lt;code&gt;on_stdout&lt;/code&gt; callback will be called twice for each execution of &lt;code&gt;date&lt;/code&gt; in this example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First it will be called with the result from &lt;code&gt;date&lt;/code&gt; as an array with two elements &lt;code&gt;['the-date', '']&lt;/code&gt; where &lt;code&gt;''&lt;/code&gt; is an artifact of the newline output by date. (If you run a job such as &lt;code&gt;echo -n &quot;no new line&quot;&lt;/code&gt;, you'd only receive &lt;code&gt;['no new line']&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second it will be called with &lt;code&gt;['']&lt;/code&gt; to signal &lt;code&gt;EOF&lt;/code&gt; on &lt;code&gt;stdout&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second call is clobbering the first, which makes it appear as if the result is going missing somehow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can either check the length of the argument (i.e. &lt;code&gt;if len(a:d[0])...&lt;/code&gt;) or pass the option &lt;code&gt;'stdout_buffered': 1&lt;/code&gt; to &lt;code&gt;jobstart&lt;/code&gt; to only receive output when all output from the command is collected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All this is explained in &lt;code&gt;:h on_stdout&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="20041" LastEditorUserId="10604" LastEditDate="2019-02-10T16:14:07.127" LastActivityDate="2019-02-10T16:14:07.127" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18867" PostTypeId="2" ParentId="18847" CreationDate="2019-02-10T18:24:14.343" Score="1" Body="&lt;p&gt;See &lt;code&gt;:help vimrc&lt;/code&gt; for a detailed understanding of how &lt;code&gt;_vimrc&lt;/code&gt;s work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When Vim loads, it invokes &lt;code&gt;_vimrc&lt;/code&gt;s in the following steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;$VIM/vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The first existing file of&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;$HOME/_vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$HOME/vimfiles/_vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$VIM/_vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$VIM/vimrc&lt;/code&gt; is the system-wide config file. &lt;code&gt;$VIM/_vimrc&lt;/code&gt; is a user-defined config file used if the two &lt;code&gt;$HOME&lt;/code&gt; files above are not defined.&lt;/p&gt;&#xA;" OwnerUserId="20750" LastEditorUserId="2636" LastEditDate="2019-08-13T15:57:05.500" LastActivityDate="2019-08-13T15:57:05.500" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18870" PostTypeId="1" CreationDate="2019-02-11T08:06:34.880" Score="1" ViewCount="837" Body="&lt;p&gt;Whenever I create html file with &lt;code&gt;jinja&lt;/code&gt; code from terminal either using shell commands or directly using &lt;code&gt;vim&lt;/code&gt;, the file type is always set to &lt;code&gt;html&lt;/code&gt; and not &lt;code&gt;jinja.html&lt;/code&gt;, which causes number of issues like &lt;code&gt;jinja&lt;/code&gt; files not being syntax highlighted, snippets do not show up in completion popups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;code&gt;Glench/Vim-Jinja2-Syntax&lt;/code&gt; for jinja syntax highlighting. I do understand this plugin might be looking for certain keywords in the file to associate the file as &lt;code&gt;jinja.html&lt;/code&gt; file. Even if I create a file like below in &lt;code&gt;Vim&lt;/code&gt;, save it , close it with &lt;code&gt;:wq&lt;/code&gt; and then open it again, still the file type is &lt;code&gt;html&lt;/code&gt; only.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{%  extends &quot;base.html&quot; %}&#xA;&#xA;{% block body %}&#xA;&#xA;{% endblock %}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is what &lt;code&gt;set filetype?&lt;/code&gt; reports &lt;code&gt;filetype=html&lt;/code&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if I create the same file with some IDE like &lt;code&gt;PyCharm&lt;/code&gt; or &lt;code&gt;VsCode&lt;/code&gt; this does not happen, and after that if I open the file in &lt;code&gt;Vim&lt;/code&gt;, then it sets the correct file type as &lt;code&gt;jinja.html&lt;/code&gt;. My guess is &lt;code&gt;PyCharm&lt;/code&gt; and &lt;code&gt;VsCode&lt;/code&gt; might be adding some metadata to the file while creating the file which Vim is not doing when the file is created by Vim but I am not sure about this..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another weird thing that I noticed, say I create a file named &lt;code&gt;dummy.html&lt;/code&gt; with above &lt;code&gt;jinja&lt;/code&gt; code with &lt;code&gt;Vim&lt;/code&gt; and then save+close it, obviously &lt;code&gt;Vim&lt;/code&gt; isn't setting the correct file type for it. Now the weird, even if I delete this file and then recreate it in &lt;code&gt;PyCharm&lt;/code&gt; with same name i.e. &lt;code&gt;dummy.html&lt;/code&gt; and load in &lt;code&gt;Vim&lt;/code&gt; , &lt;code&gt;Vim&lt;/code&gt; fails to set the correct file type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested this multiple file names, means I created the file in &lt;code&gt;Vim&lt;/code&gt; and then delete it and then create the file with same name in &lt;code&gt;PyCharm&lt;/code&gt; and &lt;code&gt;Vim&lt;/code&gt; does not set the file type. However if I use a new name while creating the file in &lt;code&gt;PyCharm&lt;/code&gt;, a name which I haven't used while creating file with &lt;code&gt;Vim&lt;/code&gt; , then &lt;code&gt;Vim&lt;/code&gt; file sets the file type correctly to &lt;code&gt;jinja.html&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So can anyone please help me how can I fix this. I apologize if the issue description is bit confusing but this issue is so weird that honestly I am not sure how to better the description.&lt;/p&gt;&#xA;" OwnerUserId="18373" LastEditorUserId="18373" LastEditDate="2019-02-11T13:51:48.420" LastActivityDate="2020-07-05T20:08:30.823" Title="Vim not setting correct file type for jinja files" Tags="|filetype|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18871" PostTypeId="2" ParentId="18870" CreationDate="2019-02-11T13:03:58.990" Score="1" Body="&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What file type plugin are you using for Jinja? Vim doesn't ship with one so you must have installed it. Looking into it will probably give you some pointers. Also, there are several plugins, so you could try another one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;=====&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a difference depending on how the file is created, the file type recognition may be dependent on whether or not a byte order mark (BOM) is present (there is probably no BOM in files created on the terminal). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a first workaround might be to add a BOM (or remove it if present) for offending files:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set invbomb&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may have to save and re-read the file to refresh syntax highlighting:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:w | e&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm afraid I have no immediate idea &lt;em&gt;why&lt;/em&gt; the file type recognition might be BOM-dependent and how to remedy that.&lt;/p&gt;&#xA;" OwnerUserId="9430" LastEditorUserId="9430" LastEditDate="2019-02-11T18:31:03.387" LastActivityDate="2019-02-11T18:31:03.387" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18872" PostTypeId="1" AcceptedAnswerId="18873" CreationDate="2019-02-11T15:39:02.437" Score="0" ViewCount="60" Body="&lt;p&gt;I have this following function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; copy yanked text to tmux pane&#xA;function! Send_to_tmux(count) range&#xA;    if (a:firstline == a:lastline)&#xA;        execute &quot;normal! \&quot;zyip&quot;&#xA;    else&#xA;        execute &quot;normal! \&quot;zy&quot;&#xA;    endif&#xA;    let text = @z&#xA;    let text = substitute(text, ';', '\\;', 'g')&#xA;    let text = substitute(text, '&quot;', '\\&quot;', 'g')&#xA;    let text = substitute(text, '\n', '&quot; Enter &quot;', 'g')&#xA;    let text = substitute(text, '!', '\\!', 'g')&#xA;    let text = substitute(text, '%', '\\&quot;', 'g')&#xA;    let text = substitute(text, '#', '\\#', 'g')&#xA;    silent execute &quot;!tmux send-keys -t &quot; . a:count . &quot; \&quot;&quot; . text . &quot;\&quot;&quot;&#xA;    silent execute &quot;!tmux send-keys -t &quot; . a:count . &quot;Enter&quot;&#xA;endfunction&#xA;nnoremap &amp;lt;leader&amp;gt;cc :&amp;lt;C-u&amp;gt;call Send_to_tmux(v:count1)&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;leader&amp;gt;cc :&amp;lt;C-u&amp;gt;call Send_to_tmux(v:count1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Originally, I didn't use the range attribute in the function and mapped it like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;cc &quot;zyip:&amp;lt;C-u&amp;gt;call Send_to_tmux(v:count1)&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;leader&amp;gt;cc &quot;zy:&amp;lt;C-u&amp;gt;call Send_to_tmux(v:count1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this didn't work with the &lt;code&gt;count&lt;/code&gt;, that's why I put the if else check for checking if the function was called for visual selection mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does the work, but seems counter intuitive. Is it alright? Is there any other way to call functions with &lt;code&gt;count&lt;/code&gt; but do some yanking etc. before calling the function?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-27T03:53:09.570" LastActivityDate="2019-02-27T03:53:09.570" Title="Call function with count after performing some normal! level tasks" Tags="|vimscript|count|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18873" PostTypeId="2" ParentId="18872" CreationDate="2019-02-11T16:35:52.053" Score="1" Body="&lt;p&gt;I've ran into this exact issue many times. The same problem comes up with &lt;code&gt;v:reg&lt;/code&gt; as well. In general, there's two main solutions.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Do what you did. Like you said, this isn't always the most convenient solution. Thankfully, there's...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping. In general, this means that your mapping is an expression that evaluates to a string, rather than some static string. This can be really useful when your mapping isn't identical every time you use it (for example, if the &lt;code&gt;v:count1&lt;/code&gt; varies). In your case, this would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;cc '&quot;zyip:\&amp;lt;C-u&amp;gt;call Send_to_tmux('.v:count1.')\&amp;lt;cr&amp;gt;'&#xA;xnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;cc '&quot;zy:\&amp;lt;C-u&amp;gt;call Send_to_tmux('.v:count1.')\&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Some general notes on this approach... Even though this is more convenient, building the string can be a bit of a pain. Especially if the mapping you want has weird characters, quotes or backslashes. Note that in vimscript, &lt;code&gt;&quot;\&amp;lt;C-u&amp;gt;&quot;&lt;/code&gt;&#xA;evaluates to the unprintable &lt;code&gt;^u&lt;/code&gt; (0x15, ctrl-u). But &lt;code&gt;'\&amp;lt;C-u&amp;gt;'&lt;/code&gt;&#xA;evaluates to the literal text &lt;code&gt;\&amp;lt;C-u&amp;gt;&lt;/code&gt;. So you'll have to be careful about which quotes you use.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="1841" LastEditDate="2019-02-18T08:56:48.023" LastActivityDate="2019-02-18T08:56:48.023" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18874" PostTypeId="1" CreationDate="2019-02-11T17:03:48.537" Score="0" ViewCount="75" Body="&lt;p&gt;I remapped the &lt;code&gt;Esc&lt;/code&gt; key to &lt;code&gt;jj&lt;/code&gt; as follows: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap jj &amp;lt;esc&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I only put &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; the cursor is always one letter to the right, however once I add the &lt;code&gt;l&lt;/code&gt; the notification message &lt;strong&gt;--INSERT --&lt;/strong&gt; won't go away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I solve this issue without removing the &lt;code&gt;l&lt;/code&gt;? &lt;/p&gt;&#xA;" OwnerUserId="15958" LastEditorUserId="2920" LastEditDate="2019-02-11T17:36:08.977" LastActivityDate="2019-02-11T17:36:08.977" Title="&quot;--INSERT--&quot; doesn't go away with a remapped escape key" Tags="|insert-mode|key-bindings|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18875" PostTypeId="2" ParentId="137" CreationDate="2019-02-11T20:19:44.747" Score="1" Body="&lt;p&gt;Not the same error but also happening quite often:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /root/.vimrc:&#xA;line    2:&#xA;E319: Sorry, the command is not available in this version: syntax enable&#xA;line    7:&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This error will show up, if you use &lt;code&gt;vi&lt;/code&gt; instead of &lt;code&gt;vim&lt;/code&gt; for crontab.&#xA;You need to set the editor of crontab by adding the following code in your &lt;code&gt;~/.bashrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export EDITOR=vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20940" LastActivityDate="2019-02-11T20:19:44.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18877" PostTypeId="1" CreationDate="2019-02-12T01:17:08.857" Score="2" ViewCount="94" Body="&lt;p&gt;I recently switched to using &lt;code&gt;neovim&lt;/code&gt; + &lt;code&gt;deoplete&lt;/code&gt; + &lt;code&gt;neosnippets&lt;/code&gt; and I'm trying to get a snippet to do a thing that I'm &lt;em&gt;pretty&lt;/em&gt; sure that I've been able to do in &lt;code&gt;UltiSnips&lt;/code&gt;. In a template I'd like to be able to enter a value for &lt;code&gt;${0:THING}&lt;/code&gt; and have it be reused throughout the snippet output without retyping it. I'm not sure if there's a point in providing the snippet because it doesn't do what I want, but just in case my description isn't clear enough, this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet thing&#xA;abbr    thing&#xA;    #ifndef THING_${0:TYPE}_H&#xA;    #define THING_${0}_H&#xA;&#xA;    #include &amp;lt;something.h&amp;gt;&#xA;&#xA;    BEGIN_DECLS&#xA;&#xA;    // ...&#xA;&#xA;    END_DECLS&#xA;&#xA;    #endif /* THING_${0}_H */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would produce:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef THING_TEST_H&#xA;#define THING_TEST_H&#xA;&#xA;#include &amp;lt;something.h&amp;gt;&#xA;&#xA;BEGIN_DECLS&#xA;&#xA;// ...&#xA;&#xA;END_DECLS&#xA;&#xA;#endif /* THING_TEST_H */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if I hit &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; and enter 'TEST' when prompted.&lt;/p&gt;&#xA;" OwnerUserId="20943" LastEditorUserId="1292" LastEditDate="2019-02-12T12:02:42.477" LastActivityDate="2019-11-09T21:49:27.633" Title="Reuse value in snippet" Tags="|snippets|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18878" PostTypeId="1" CreationDate="2019-02-12T02:40:45.110" Score="2" ViewCount="194" Body="&lt;p&gt;I want a jumplist like tree (undotree), or like taglist stack (trim some needless items), but I can not find any way to delete jumplist items.&#xA;I think about hook jump action for my own jumplist, but I can not find some efficient way (CursorMove?).&#xA;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="20944" LastActivityDate="2019-02-13T03:41:18.977" Title="Is there a way to delete (trim) some jumplist items?" Tags="|jumplist|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18879" PostTypeId="2" ParentId="16611" CreationDate="2019-02-12T05:44:07.373" Score="0" Body="&lt;p&gt;If you had installed vim using the make command then, follow the steps below to uninstall it.&#xA;Type the following commands in the terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd vim-master&#xA;cd src&#xA;sudo make uninstall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This must uninstall the vim!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pls note: If your installing directory is not vim-master, please navigate to your installing directory before proceeding.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="20946" LastActivityDate="2019-02-12T05:44:07.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18880" PostTypeId="2" ParentId="14897" CreationDate="2019-02-12T07:41:41.380" Score="0" Body="&lt;p&gt;Before you execute your command, run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:term&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will open a shell in a buffer window.  You can then run commands there, and then while those commands are running ^W back to a normal window.  This does, admittedly, make it a little annoying to send CTRL-W to that window; you need to press a period after your CTRL-W.  You can get more help on various keys available there using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help ctrl-w_.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can run different things in the terminal window instead of your default shell, including the command you were wanting to run.&lt;/p&gt;&#xA;" OwnerUserId="20713" LastActivityDate="2019-02-12T07:41:41.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18881" PostTypeId="1" AcceptedAnswerId="18885" CreationDate="2019-02-12T12:44:48.457" Score="1" ViewCount="2101" Body="&lt;p&gt;I installed the following plugins in NeoVim after installing the Nerd Fonts.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'tiagofumo/vim-nerdtree-syntax-highlight'&#xA;Plug 'ryanoasis/vim-devicons'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is how NerdTree in Vim looks,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3Sbzy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3Sbzy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see the glyph icons for CSS3 and HTML5 are not the one's we see with modern editors, however the icons for python and javascript are rendered just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is the expected behavior or I am missing something. I tested this both with &lt;code&gt;SourceCodePro&lt;/code&gt; and &lt;code&gt;FiraCode&lt;/code&gt; and I got the same output.&lt;/p&gt;&#xA;" OwnerUserId="18373" LastEditorUserId="18373" LastEditDate="2019-02-12T13:59:16.303" LastActivityDate="2019-02-12T20:11:46.593" Title="Some of the icons from Devicons not rendering properly" Tags="|plugin-devicons|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18882" PostTypeId="1" CreationDate="2019-02-12T13:02:12.657" Score="0" ViewCount="2059" Body="&lt;p&gt;When I want to call an external program, I have the option of spawning a shell or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;system('my command')&lt;/code&gt; will spawn a shell (executing your .bashrc/etc and all it seems).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;system(['my command'])&lt;/code&gt; will execute the command without a shell, which seems like it's the faster and probably preferred method since you avoid any start up cost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine I have &lt;code&gt;do_it&lt;/code&gt; installed to &lt;code&gt;~/totally/not/standard/bin/do_it&lt;/code&gt;, and I've added that a dir to my &lt;code&gt;$PATH&lt;/code&gt; in my shell, so it normally works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run &lt;code&gt;system(['do_it'])&lt;/code&gt; it executes fine in nvim, where as I'd actually expect it to fail because without the shell, it shouldn't know where to find &lt;code&gt;do_it&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Unless&lt;/em&gt; nvim is injecting/resolving the &lt;code&gt;$PATH&lt;/code&gt; as it was when nvim loaded up. I can't run &lt;code&gt;system(['echo $PATH'])&lt;/code&gt; to check because &lt;code&gt;echo&lt;/code&gt; is a builtin.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Is this whats happening?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it safe to assume that if it works in &lt;code&gt;system(string)&lt;/code&gt; it will work with &lt;code&gt;system(list)&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Should I be doing &lt;code&gt;exepath('do_it')&lt;/code&gt; first to get the full path without spawning a shell, then passing the full path to &lt;code&gt;system(list)&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Why would I ever really want &lt;code&gt;system(string)&lt;/code&gt; when it's so potentially magnitudes slower (if you have a heavy rc) and &lt;code&gt;system(list)&lt;/code&gt; seems to inherit your environment anyway?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="20041" LastActivityDate="2019-02-12T13:02:12.657" Title="How does (neo)vim set $PATH for system(['command'])" Tags="|neovim|external-command|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18883" PostTypeId="1" AcceptedAnswerId="18888" CreationDate="2019-02-12T13:13:02.777" Score="3" ViewCount="422" Body="&lt;p&gt;Sometimes when I paste (via cmd+v) some text into neovim, it inserts &lt;code&gt;&amp;lt;Paste&amp;gt;&lt;/code&gt; at the bottom, i.e:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This&#xA;was pasted and&#xA;I got some bonus letters&#xA;&amp;lt;Paste&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't figure where this text comes from and googling it is impossible because I can't search for the actual tag, it just shows results for anything including &quot;paste&quot; and &quot;inserts text&quot; which is pretty common when talking about copy-paste...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often it leaves me in &lt;code&gt;PASTE&lt;/code&gt; mode afterwards too, which might be a clue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm on OS X, iTerm2 with I guess the default &lt;code&gt;pbcopy/pbpaste&lt;/code&gt; providers, perhaps its a bug with them?&lt;/p&gt;&#xA;" OwnerUserId="20041" LastEditorUserId="20041" LastEditDate="2019-02-12T17:29:51.230" LastActivityDate="2019-02-12T23:36:34.763" Title="Paste mode sometimes inserting &quot;&lt;Paste&gt;&quot;" Tags="|neovim|cut-copy-paste|macos|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18884" PostTypeId="1" CreationDate="2019-02-12T14:21:59.663" Score="0" ViewCount="455" Body="&lt;p&gt;So it seems that vim is great for so many things. And I love it. And yet, it is the configuration that sometimes is a limitation for those of us who don't get a tight grasp on how to tinker into it. I know there's a number of programs that are useful for transcribing audio, and it is great to have many options. However it seems they need some amount of steps to get them installed and configured, in order to get them compatible with controlling from inside of vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for the following main features to be controled inside vim, ability mainly to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;pause/play system wide, so that doing so from the vim editor is possible. Perhaps it would be nice that after each pause there is slight backwards, so that one can hear a little before, which is needed when hearing repeatidly.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;How can I control an average audio program from inside vim?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;These other features two are additional but highly valuable:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;make audio slower and with proper pitch to stop as little as possible.&lt;/li&gt;&#xA;&lt;li&gt;fast forward and back system wide, to move along through broad sections.&lt;/li&gt;&#xA;&lt;li&gt;make a clean catch of timing to insert into the transcription.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Can I run a transcription program from vim in a old operative system?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I am running debian 6, stable (actually it is a bunsen labs distro on top of debian), and am having a hard time searching for a program that will work directly. Up to now my best solution is doing this online but the fix I found is not vim like, which is not the best possible solution: &lt;a href=&quot;https://otranscribe.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;online transcribe&lt;/a&gt;. It pauses/plays with ctrl+esc, controls time pace slower/quicker with F2/F3 (auto regulates pitch), inserts time stamp with ctrl+j. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Any vim-like solution, be it online or instalable?&lt;/h3&gt;&#xA;" OwnerUserId="12815" LastEditorUserId="12815" LastEditDate="2019-02-13T17:50:04.257" LastActivityDate="2019-02-22T20:23:45.957" Title="How do I control an external program from vim? The final end is to listen to audio and make a transcript in sync" Tags="|external-command|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18885" PostTypeId="2" ParentId="18881" CreationDate="2019-02-12T17:41:04.187" Score="0" Body="&lt;p&gt;You can customize any icon by adding the following line to your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['css']  = ''&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply change the 'css' and '' to what you would like (the CSS symbol is U+F13C).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good website to look for icons is &lt;a href=&quot;https://nerdfonts.com/#cheat-sheet&quot; rel=&quot;nofollow noreferrer&quot;&gt;nerdfonts.com&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While in Vim, the plugin &lt;a href=&quot;https://github.com/tpope/vim-characterize&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-characterize&lt;/a&gt; by the great &lt;em&gt;tpope&lt;/em&gt; is ideal to identify up any character you come across.&lt;/p&gt;&#xA;" OwnerUserId="8493" LastEditorUserId="8493" LastEditDate="2019-02-12T20:11:46.593" LastActivityDate="2019-02-12T20:11:46.593" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18886" PostTypeId="2" ParentId="18877" CreationDate="2019-02-12T18:13:05.357" Score="2" Body="&lt;p&gt;The answer is synchronized placeholders; I just couldn't find anything online/in the manual because I didn't know the terminology. The correct snippet would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet thing&#xA;abbr    thing&#xA;    #ifndef THING_${1:something}_H&#xA;    #define THING_$1_H&#xA;&#xA;    #include &amp;lt;something.h&amp;gt;&#xA;&#xA;    BEGIN_DECLS&#xA;&#xA;    // ...&#xA;&#xA;    END_DECLS&#xA;&#xA;    #endif /* THING_$1_H */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason, starting from &lt;code&gt;0&lt;/code&gt; creates an error.&lt;/p&gt;&#xA;" OwnerUserId="20943" LastEditorUserId="10604" LastEditDate="2019-11-09T21:49:27.633" LastActivityDate="2019-11-09T21:49:27.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18888" PostTypeId="2" ParentId="18883" CreationDate="2019-02-12T23:36:34.763" Score="1" Body="&lt;p&gt;This is a &lt;a href=&quot;https://github.com/neovim/neovim/issues/7994&quot; rel=&quot;nofollow noreferrer&quot;&gt;known issue&lt;/a&gt; with Neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/neovim/neovim/issues/7994#issuecomment-388296360&quot; rel=&quot;nofollow noreferrer&quot;&gt;suggested workaround&lt;/a&gt; until the problem is fixed is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au InsertLeave * set nopaste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15" LastActivityDate="2019-02-12T23:36:34.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18889" PostTypeId="1" AcceptedAnswerId="18893" CreationDate="2019-02-13T02:00:32.790" Score="2" ViewCount="3301" Body="&lt;p&gt;Suppose I want to use this colorscheme: &lt;a href=&quot;https://github.com/NLKNguyen/papercolor-theme&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/NLKNguyen/papercolor-theme&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I copied the &lt;code&gt;PaperColor.vim&lt;/code&gt; file into &lt;code&gt;.vim/colors&lt;/code&gt; and made my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;colorscheme PaperColor&#xA;background=light&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I want to use this syntax highlighting for haskell files: &lt;a href=&quot;https://github.com/raichoo/haskell-vim/tree/master/syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/raichoo/haskell-vim/tree/master/syntax&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two syntax highlighting files. Which one am I supposed to use, and where do it put them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I put it in &lt;code&gt;./vim/syntax&lt;/code&gt; and vim auto-loads all files in &lt;code&gt;./vim/syntax&lt;/code&gt; folder?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like to load &lt;code&gt;haskell.vim&lt;/code&gt; automatically. But doesn't load &lt;code&gt;cabal.vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wondering if it only loads &lt;code&gt;haskell.vim&lt;/code&gt; when I open &lt;code&gt;*.hs&lt;/code&gt; files? I'm trying to make it like that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can vim load multiple syntax files at once?&lt;/p&gt;&#xA;" OwnerUserId="20958" LastEditorUserId="19763" LastEditDate="2019-02-13T05:23:16.420" LastActivityDate="2019-02-13T06:46:28.763" Title="How to use different colorscheme and syntax highlighting in vim?" Tags="|syntax-highlighting|colorscheme|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18890" PostTypeId="1" CreationDate="2019-02-13T02:52:03.857" Score="0" ViewCount="197" Body="&lt;p&gt;I have a Macbook. I want to save files by pressing command + s (this should happen if it is in insert mode or not, and I want it to go to non-insert mode after it is saved). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance! :)&lt;/p&gt;&#xA;" OwnerUserId="20958" LastEditorUserId="1292" LastEditDate="2019-02-13T07:47:55.283" LastActivityDate="2019-02-13T07:47:55.283" Title="How to bind command+s to save file on macOS?" Tags="|vimrc|key-bindings|macos|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18891" PostTypeId="2" ParentId="18878" CreationDate="2019-02-13T03:41:18.977" Score="1" Body="&lt;p&gt;Finally, I write a experiment plugin for this&#xA;&lt;a href=&quot;https://github.com/epheien/myjl&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/epheien/myjl&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20944" LastActivityDate="2019-02-13T03:41:18.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18892" PostTypeId="2" ParentId="18889" CreationDate="2019-02-13T06:43:47.153" Score="1" Body="&lt;p&gt;To use colorscheme:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;put it into &lt;code&gt;.vim/colors/PaperColor.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;run `:color PaperColor&lt;/li&gt;&#xA;&lt;li&gt;run &lt;code&gt;:set background=light&lt;/code&gt; to make it use light background&lt;/li&gt;&#xA;&lt;li&gt;if it works, persist settings in your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;color PaperColor&#xA;set background=light&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use haskell syntax from mentioned package without following installation instructions given on repo readme :) :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;put it into &lt;code&gt;/vim/syntax/haskell.vim&lt;/code&gt; (from the repo folder &lt;code&gt;/syntax/&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;now there is also file type detection located in repo's &lt;code&gt;/ftdetect/&lt;/code&gt; folder (&lt;a href=&quot;https://github.com/raichoo/haskell-vim/tree/master/ftdetect&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/raichoo/haskell-vim/tree/master/ftdetect&lt;/a&gt;), get &lt;code&gt;haskell.vim&lt;/code&gt; from there and put it into your local &lt;code&gt;.vim/ftdetect/haskell.vim&lt;/code&gt;. File type detection makes vim load haskell syntax automatically (simplified explanation)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But I really suggest to use installation method described in a README file. Either using pathogen or manually. (or using any package manager)&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-02-13T06:43:47.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18893" PostTypeId="2" ParentId="18889" CreationDate="2019-02-13T06:46:28.763" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How to use different colorscheme and syntax highlighting in vim?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Colorscheme and syntax highlighting are complementary in Vim, so you typically use one of each.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The colorscheme will define what color is applied to each type of element (such as Keyword, Identifier, String, Number, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the syntax highlighting (for a specific filetype, typically a programming language) will define how to identify those elements for that language (for example, with a list of reserved words or regular expressions to delimit the specific items.)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Suppose I want to use [papercolor] colorscheme. &#xA;  I copied the &lt;code&gt;PaperColor.vim&lt;/code&gt; file into &lt;code&gt;.vim/colors&lt;/code&gt; and made my &lt;code&gt;.vimrc&lt;/code&gt;: [...]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's one possible way to install it, but I really recommend using a plugin manager instead! Read on.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Now, I want to use this syntax highlighting for haskell files: &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So here you'll see more the value of a plugin  manager! Since technically you're supposed to copy &lt;em&gt;all&lt;/em&gt; the &lt;code&gt;*.vim&lt;/code&gt; files from every subdirectory into the corresponding subdirectory of &lt;code&gt;~/.vim&lt;/code&gt;, but that quickly becomes pretty messy if you want to install many plugins. (Manually unpacking them means all the files would mix together!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really recommend using &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt;, since it works great on Vim 7, Vim 8, Neovim, etc. Vim 8 and Neovim support &quot;native&quot; plugins but you need to manually handle the docs, so you benefit from using vim-plug on them too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the README file for installation instructions (you just need to download one file), then update your &lt;code&gt;~/.vimrc&lt;/code&gt; to list the two plugins you're interested on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;Plug 'NLKNguyen/papercolor-theme'&#xA;Plug 'raichoo/haskell-vim'&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then start Vim and run the &lt;code&gt;:PlugInstall&lt;/code&gt; command. Done!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you use a plugin manager, you don't need to &lt;em&gt;care&lt;/em&gt; about the other details... But in case you want to understand how it works, here it goes:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There are two syntax highlighting files. Which one am I supposed to use, and where do it put them?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;They are for different &lt;code&gt;filetype&lt;/code&gt;s and they're loaded when a specific &lt;code&gt;filetype&lt;/code&gt; is set.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Do I put it in &lt;code&gt;./vim/syntax&lt;/code&gt; and vim auto-loads all files in &lt;code&gt;./vim/syntax&lt;/code&gt; folder?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, Vim will load a file named &lt;code&gt;&lt;em&gt;xyz&lt;/em&gt;.vim&lt;/code&gt; whenever &lt;code&gt;filetype&lt;/code&gt; is set to &lt;em&gt;xyz&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you open a buffer, type some text and then use a command such as &lt;code&gt;:setf haskell&lt;/code&gt; it will load &lt;code&gt;haskell.vim&lt;/code&gt; from &lt;code&gt;~/.vim/syntax&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(See &lt;code&gt;:help 'filetype'&lt;/code&gt; and &lt;code&gt;:help :setf&lt;/code&gt; for more details.)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It seems like to load &lt;code&gt;haskell.vim&lt;/code&gt; automatically. But doesn't load &lt;code&gt;cabal.vim&lt;/code&gt;. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That will be used for files of type &lt;code&gt;cabal&lt;/code&gt;, so using &lt;code&gt;:setf cabal&lt;/code&gt; will use that syntax highlighting configuration. (i don't know much about Haskell and Cabal but I imagine they're related files, with somewhat different syntax and distinct file extensions.)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Wondering if it only loads &lt;code&gt;haskell.vim&lt;/code&gt; when I open &lt;code&gt;*.hs&lt;/code&gt; files? I'm trying to make it like that. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The default Vim configuration already ships commands that will set up the correct filetype (haskell, cabal) for common extensions such as &lt;code&gt;*.hs&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The haskell-vim plugin also ships a &lt;code&gt;ftdetect/haskell.vim&lt;/code&gt; script that configures it for additional extensions, with the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.hsc set filetype=haskell&#xA;au BufRead,BufNewFile *.bpk set filetype=haskell&#xA;au BufRead,BufNewFile *.hsig set filetype=haskell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, that's how plugins attach syntax (and indent, key mappings, etc.) for specific file types.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can vim load multiple syntax files at once?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, but that's quite unusual...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example from &lt;code&gt;:help 'filetype'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    When a dot appears in the value then this separates two filetype&#xA;    names.  Example:&#xA;        /* vim: set filetype=c.doxygen : */ &#xA;    This will use the &quot;c&quot; filetype first, then the &quot;doxygen&quot; filetype.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-02-13T06:46:28.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18894" PostTypeId="1" AcceptedAnswerId="18895" CreationDate="2019-02-13T08:36:18.503" Score="10" ViewCount="8237" Body="&lt;p&gt;I really like and often use the &lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt; command for replacing something I was currently searching for, but it sort of lacks a (imho) rather intuitive feature: replace the word (or whatever) under the cursor. My current approach is to search for the word in question, but that feels like a hack, plus the cursor immediately moves onwards to the &lt;em&gt;next&lt;/em&gt; hit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to use &lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt; on the &lt;em&gt;current&lt;/em&gt; word?&lt;/p&gt;&#xA;" OwnerUserId="6350" LastActivityDate="2020-10-29T08:04:26.017" Title="How do I use 'cgn' for word under cursor?" Tags="|search|replace|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18895" PostTypeId="2" ParentId="18894" CreationDate="2019-02-13T09:11:30.503" Score="7" Body="&lt;p&gt;There is no built-in way to do it (as an option), as far as I know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; change current word (like ciw) but repeatable with dot . for the same next&#xA;&quot; word&#xA;nnoremap &amp;lt;silent&amp;gt; c&amp;lt;Tab&amp;gt; :let @/=expand('&amp;lt;cword&amp;gt;')&amp;lt;cr&amp;gt;cgn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically what it does is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;make current search term == word under cursor (without actual search and jump)&lt;/li&gt;&#xA;&lt;li&gt;call &lt;code&gt;cgn&lt;/code&gt; -- and it will use current search from 1.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For reference:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h @/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h &amp;lt;cword&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-02-13T09:17:06.063" LastActivityDate="2019-02-13T09:17:06.063" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18896" PostTypeId="2" ParentId="18894" CreationDate="2019-02-13T10:34:16.087" Score="8" Body="&lt;h2&gt;Make &lt;code&gt;*&lt;/code&gt; stay at the cursor position&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap * m`:keepjumps normal! *``&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/4256697/vim-search-and-highlight-but-do-not-jump&quot;&gt;https://stackoverflow.com/questions/4256697/vim-search-and-highlight-but-do-not-jump&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2&gt;Plugins for &lt;code&gt;*&lt;/code&gt;: &lt;a href=&quot;https://github.com/haya14busa/vim-asterisk&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-asterisk&lt;/a&gt;, &lt;a href=&quot;https://github.com/junegunn/vim-slash&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-slash&lt;/a&gt;, ...&lt;/h2&gt;&#xA;&lt;p&gt;There are quite a few (lightweight) plugins which try to enhance searching in vim with the star command.&lt;/p&gt;&#xA;&lt;p&gt;Typically, people miss that the star command does not consider a visual selection and secondly, what you want, to not move the cursor when pressing &lt;code&gt;*&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;After installation of one of these, you would press &lt;code&gt;*cgn&lt;/code&gt; to achieve what you want.&lt;/p&gt;&#xA;&lt;p&gt;In case of &lt;code&gt;vim-asterisk&lt;/code&gt;, you have to override the builtin &lt;code&gt;*&lt;/code&gt; yourself in your vimrc. &lt;code&gt;vim-asterisk&lt;/code&gt; suggests:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;map *   &amp;lt;Plug&amp;gt;(asterisk-*)&#xA;map #   &amp;lt;Plug&amp;gt;(asterisk-#)&#xA;map g*  &amp;lt;Plug&amp;gt;(asterisk-g*)&#xA;map g#  &amp;lt;Plug&amp;gt;(asterisk-g#)&#xA;map z*  &amp;lt;Plug&amp;gt;(asterisk-z*)&#xA;map gz* &amp;lt;Plug&amp;gt;(asterisk-gz*)&#xA;map z#  &amp;lt;Plug&amp;gt;(asterisk-z#)&#xA;map gz# &amp;lt;Plug&amp;gt;(asterisk-gz#)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where &lt;code&gt;z*&lt;/code&gt; means stay. However, you can make &lt;code&gt;*&lt;/code&gt; to stay with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;map *  &amp;lt;Plug&amp;gt;(asterisk-z*)&#xA;map #  &amp;lt;Plug&amp;gt;(asterisk-z#)&#xA;map g* &amp;lt;Plug&amp;gt;(asterisk-gz*)&#xA;map g# &amp;lt;Plug&amp;gt;(asterisk-gz#)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;vim-slash does this for you. This might be a reason to prefer vim-asterisk because you have control of what gets remapped.&lt;/p&gt;&#xA;&lt;p&gt;There are more of them. Just to give you an idea I mention a few:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/pgdouyon/vim-evanesco&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-evanesco&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4320&quot; rel=&quot;nofollow noreferrer&quot;&gt;SearchHighlighting&lt;/a&gt; (&lt;a href=&quot;https://github.com/inkarkat/vim-SearchHighlighting&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/thinca/vim-visualstar/blob/master/doc/visualstar.txt#L105-L107&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-visualstar&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Plugin with new operator: &lt;a href=&quot;https://github.com/hauleth/sad.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;sad.vim&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;If you like an explicit mapping for this operation, consider &lt;a href=&quot;https://github.com/hauleth/sad.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/hauleth/sad.vim&lt;/a&gt;. This remaps &lt;code&gt;s&lt;/code&gt; (changes builtin and clashes with a few other plugins, e.g. vim-sneak and vim-sandwich). &lt;code&gt;siw&lt;/code&gt; and then press &lt;code&gt;.&lt;/code&gt; as often you want to repeat the change for the next search matches.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2020-10-29T08:04:26.017" LastActivityDate="2020-10-29T08:04:26.017" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18897" PostTypeId="1" AcceptedAnswerId="18898" CreationDate="2019-02-13T15:11:13.907" Score="0" ViewCount="2334" Body="&lt;p&gt;Is there a way that a open up a window or buffer, where i can run my bash commands? I thought on something like you know it from VS Code(&lt;a href=&quot;https://i.stack.imgur.com/SNyAc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;). The code windows on the top and a small command prompt on the bottom of the view, where i can run for example my rails or node server?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SNyAc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SNyAc.png&quot; alt=&quot;VS Code&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For more clearity I want an editor on the top and a command prompt on the bottom of the window, where I can switch using  commands. On the terminal should run a long running part.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="20971" LastActivityDate="2019-02-14T13:28:39.167" Title="Shell running inside vim windows" Tags="|buffers|tabbed-user-interface|bash|window-management|shell|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18898" PostTypeId="2" ParentId="18897" CreationDate="2019-02-13T15:38:51.730" Score="3" Body="&lt;p&gt;You need Vim 8.1, then you can use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:below terminal ++rows=10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Normally a terminal is opened above the current window, but with &lt;code&gt;below&lt;/code&gt; it is opened at the bottom. And in this case, the terminal should have a height of 10 rows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :terminal&lt;/code&gt; for additional &lt;code&gt;++&lt;/code&gt;-options.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-13T15:38:51.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18899" PostTypeId="1" AcceptedAnswerId="18901" CreationDate="2019-02-13T16:02:00.653" Score="5" ViewCount="2490" Body="&lt;p&gt;I'm working in a react project and opened vim from the root folder. When I'm using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /pattern/ **&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just can search everywhere, but I want to search everywhere except the 'node_modules' folder. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I create a mapping to exclude specific folder names permanently from searching?&lt;/p&gt;&#xA;" OwnerUserId="20971" LastEditorUserId="19763" LastEditDate="2019-02-13T19:57:18.467" LastActivityDate="2019-02-15T14:25:44.220" Title="Exclude folder when searching files in working directory" Tags="|search|replace|working-directory|vimgrep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18900" PostTypeId="1" CreationDate="2019-02-13T16:08:30.040" Score="2" ViewCount="983" Body="&lt;p&gt;I have two code files open and I'm trying to write a macro for moving code from one file to the other. I start recording the macro in file A. After I enter all of the commands I need in file A, I switch into file B using &lt;code&gt;gt&lt;/code&gt;. After I've switched, the commands that I run in file B are not included in the macro. If I try to end my recording with &lt;code&gt;q&lt;/code&gt; while in file B, I instead initiate a new recording. When I go back to file A, my original macro is still recording. If I stop that recording and run the macro it only does the commands I entered in file A, but that does include the command to switch files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it helps, I'm using the vscodevim extension for vim emulation in Visual Studio Code&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible for me to record commands across multiple files into a macro? If so, how?&lt;/p&gt;&#xA;" OwnerUserId="20975" LastEditorUserId="13654" LastEditDate="2020-11-19T14:30:31.237" LastActivityDate="2020-11-19T14:30:31.237" Title="How can I record a macro across multiple files" Tags="|macro|vscode|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18901" PostTypeId="2" ParentId="18899" CreationDate="2019-02-13T19:47:59.560" Score="7" Body="&lt;p&gt;Try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildignore=*/node_modules/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just played a little with &lt;code&gt;wildignore&lt;/code&gt;, so I don't know if it works in all cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. if you do a &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /pattern/ node_modules/**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will find nothing, as all files below &lt;code&gt;node_modules&lt;/code&gt; are ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help wildignore&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The option &lt;code&gt;wildignore&lt;/code&gt; is a comma-separated list of pattern. To ignore multiple directories use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildignore=*/node_modules/*,*/target/*,*/tmp/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-15T14:25:44.220" LastActivityDate="2019-02-15T14:25:44.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18903" PostTypeId="1" AcceptedAnswerId="18905" CreationDate="2019-02-14T01:00:43.100" Score="0" ViewCount="134" Body="&lt;h1&gt;How can a keypress dynamically change its behavior, depending upon which split pane has focus?&lt;/h1&gt;&#xA;&lt;p&gt;(Specifically, whether the pane containing the cursor has another split pane to the right, or not.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;map &amp;lt;expr&amp;gt;&lt;/code&gt; Can be used to map the keypress to the result of an expression, such as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;expr&amp;gt; &amp;lt;F2&amp;gt; RightPane() ? ':echom RightPane()' : 'Never happens'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But the rightmost result is &lt;strong&gt;never&lt;/strong&gt; returned! When &lt;kbd&gt;F2&lt;/kbd&gt; is pressed with the cursor/focus in the left split pane:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the expression &lt;code&gt;:echom RightPane()&lt;/code&gt; is displayed in the status bar.&lt;/li&gt;&#xA;&lt;li&gt;Pressing &lt;kbd&gt;CR&lt;/kbd&gt; then always evaluates properly, as either 0 or 1.&lt;/li&gt;&#xA;&lt;li&gt;'Never happens' is never shown, however&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Can the function respond differently, based on the pane with the cursor, each time &lt;kbd&gt;F2&lt;/kbd&gt; is pressed?&lt;/h3&gt;&#xA;&lt;p&gt;The function is defined as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func! RightPane()    &#xA;  let saveW = winnr() &#xA;  silent! exe &amp;quot;normal! \&amp;lt;c-w&amp;gt;l&amp;quot;&#xA;  let rightW = winnr()&#xA;  silent! exe saveW.'wincmd w'&#xA;  return saveW == rightW&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Example Use-Case&lt;/h2&gt;&#xA;&lt;h3&gt;Resize Panes Using Ctrl-Arrow Keys:&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;func! RightPane()    &#xA;  let saveW = winnr() &#xA;  exe &amp;quot;normal! \&amp;lt;c-w&amp;gt;l&amp;quot;&#xA;  let rightW = winnr()&#xA;  exe saveW.'wincmd w'&#xA;  return saveW == rightW&#xA;endfunction&#xA;&#xA;&amp;quot; Resize split panes using Ctrl-Arrow&#xA;noremap &amp;lt;expr&amp;gt; &amp;lt;C-Left&amp;gt;  RightPane() ? '&amp;lt;C-W&amp;gt;&amp;gt;' : '&amp;lt;C-W&amp;gt;&amp;lt;'&#xA;noremap &amp;lt;expr&amp;gt; &amp;lt;C-Right&amp;gt; RightPane() ? '&amp;lt;C-W&amp;gt;&amp;lt;' : '&amp;lt;C-W&amp;gt;&amp;gt;'&#xA;noremap &amp;lt;expr&amp;gt; &amp;lt;C-Up&amp;gt;    BottomPane() ? '&amp;lt;C-W&amp;gt;+' : '&amp;lt;C-W&amp;gt;-'&#xA;noremap &amp;lt;expr&amp;gt; &amp;lt;C-Down&amp;gt;  BottomPane() ? '&amp;lt;C-W&amp;gt;-' : '&amp;lt;C-W&amp;gt;+'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4743" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-02-15T05:43:37.607" Title="map &lt;expr&gt; &lt;F2&gt; Cannot Check Focus Pane" Tags="|vimrc|key-bindings|functions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18904" PostTypeId="1" CreationDate="2019-02-14T04:59:02.393" Score="0" ViewCount="60" Body="&lt;p&gt;accidentally just wrote&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void foo(bar, baz, que) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and forgot to specify type, I want to convert the above to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void foo(String bar, String baz, String que) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do that quickly?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="9024" LastEditDate="2019-02-14T10:53:21.147" LastActivityDate="2019-02-15T09:52:21.137" Title="prepend word before every function argument" Tags="|repeated-commands|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18905" PostTypeId="2" ParentId="18903" CreationDate="2019-02-14T06:32:51.263" Score="2" Body="&lt;p&gt;In a &lt;code&gt;map-&amp;lt;expr&amp;gt;&lt;/code&gt; the allowed actions are limited. You explicitly suppressed error messages with &lt;code&gt;silent!&lt;/code&gt;. If you remove this, you get the error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function RightPane:&#xA;line    2:&#xA;E523: Not allowed here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:normal&lt;/code&gt; is not allowed in a &lt;code&gt;map-&amp;lt;expr&amp;gt;&lt;/code&gt;. See &lt;code&gt;:help map-&amp;lt;expr&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: You could replace that with &lt;code&gt;wincmd l&lt;/code&gt;, but that isn't allowed either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the second call to &lt;code&gt;RightPane()&lt;/code&gt; is not within the context of &lt;code&gt;map-&amp;lt;expr&amp;gt;&lt;/code&gt;, so it returns the expected value. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update: You could work with a &quot;normal&quot; map, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DoVertResize(left, right)&#xA;    if RightPane()&#xA;        execute &quot;normal \&amp;lt;C-W&amp;gt;&quot; . a:right&#xA;    else&#xA;        execute &quot;normal \&amp;lt;C-W&amp;gt;&quot; . a:left&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;C-Right&amp;gt; :call DoVertResize('&amp;gt;','&amp;lt;')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-Left&amp;gt; :call DoVertResize('&amp;lt;','&amp;gt;')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-15T05:43:37.607" LastActivityDate="2019-02-15T05:43:37.607" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18906" PostTypeId="2" ParentId="18904" CreationDate="2019-02-14T06:35:00.763" Score="1" Body="&lt;p&gt;Define &quot;quickly&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Easiest way for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/bar&amp;lt;cr&amp;gt;iString &amp;lt;esc&amp;gt;WW.WW.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another one would be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;V:s/b/String b/g&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-02-14T06:35:00.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18907" PostTypeId="1" AcceptedAnswerId="18908" CreationDate="2019-02-14T06:57:27.297" Score="0" ViewCount="33" Body="&lt;p&gt;I'm trying to programmatically record a macro (using &lt;code&gt;:let @m=&lt;/code&gt; rather than &lt;code&gt;qm&lt;/code&gt;). In vim, I executed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @m = ':retab^M'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;^M&lt;/code&gt; is typed as ctrl+V, Enter. I expect the buffer to contain exactly what is written above, but it also contains a newline at the end, and when the macro is executed, my cursor moves down by one line. If I populate &lt;code&gt;@m&lt;/code&gt; with the &lt;code&gt;q&lt;/code&gt; record function, this problem does not occur.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I programmatically set a register to contain a &lt;code&gt;^M&lt;/code&gt; but not an extra newline? Note that &lt;code&gt;:let @m=&quot;:retab\&amp;lt;cr&amp;gt;&quot;&lt;/code&gt; gives the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To elaborate: I expect the &lt;code&gt;@m&lt;/code&gt; to contain ':retab^M' or ':retab\n' but it actually contains: ':retab\n\n' with an extra newline. Or to say it another way, &lt;code&gt;:let @m = ':retab^M'&lt;/code&gt; and &lt;code&gt;qm:retab ENTER q&lt;/code&gt; should give the same result (the identical macro in register &lt;code&gt;m&lt;/code&gt;), but they differ by a newline character. (The result is the same on Windows and Linux.)&lt;/p&gt;&#xA;" OwnerUserId="13936" LastEditorUserId="13936" LastEditDate="2019-02-14T07:07:31.323" LastActivityDate="2019-02-14T07:22:57.767" Title="How to let a register contain exactly one ^M without an extra newline?" Tags="|macro|register|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18908" PostTypeId="2" ParentId="18907" CreationDate="2019-02-14T07:07:29.957" Score="1" Body="&lt;p&gt;Could you try to replace c-m to c-j? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @m = ':retab^@'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not 100% sure why it happens but...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you do (with &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;C-m&amp;gt;&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @m = ':retab^M'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;m&lt;/code&gt; register gets additional 'newline' and looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:retab^M^@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if instead of ^M you will insert ^@, no additional 'newline' is inserted and you end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:retab^@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;to see contents of the register use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echomsg @m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;echo @m&lt;/code&gt; will not show those special symbols.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-02-14T07:21:32.390" LastActivityDate="2019-02-14T07:21:32.390" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18909" PostTypeId="2" ParentId="18907" CreationDate="2019-02-14T07:22:57.767" Score="1" Body="&lt;p&gt;You could use the following, if you don't want to &lt;code&gt;&amp;lt;C-V&amp;gt;...&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @m=&quot;:retab\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: You need double-quotes. Doesn't work with single quotes.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-14T07:22:57.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18911" PostTypeId="1" AcceptedAnswerId="19311" CreationDate="2019-02-14T08:20:16.917" Score="0" ViewCount="2264" Body="&lt;p&gt;I am using Vim 8.1 on Windows 10 and with a default package manager Vim doesn't see plugins in &lt;code&gt;C:\Program Files (x86)\Vim\vimfiles\pack&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did I put in into incorrect place?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is the same configuration as I use on Ubuntu and it works there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;packpath=~/vimfiles,C:\Program Files (x86)\Vim/vimfiles,C:\Program Files (x86)&#xA;\Vim\vim81,C:\Program Files (x86)\Vim/vimfiles/after,~/vimfiles/after &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1860" LastEditorUserId="1860" LastEditDate="2019-02-14T15:38:42.087" LastActivityDate="2019-03-25T08:34:51.593" Title="Vim 8 on Windows doesn't see plugins directory" Tags="|microsoft-windows|plugin-system|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18912" PostTypeId="2" ParentId="18911" CreationDate="2019-02-14T09:22:12.703" Score="0" Body="&lt;p&gt;Not sure if packages are being searched in &lt;code&gt;$VIM/vimfiles&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;if your &lt;code&gt;HOME&lt;/code&gt; environment variable is not set, set it. (right click on Start button, select &lt;code&gt;System&lt;/code&gt;, then &lt;code&gt;Advanced system settings&lt;/code&gt;, then &lt;code&gt;Environment Variables&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;put your &lt;code&gt;vimfiles&lt;/code&gt; directory to &lt;code&gt;HOME&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It works for me, settings and packages are loaded etc...&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-02-14T09:22:12.703" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18914" PostTypeId="2" ParentId="18897" CreationDate="2019-02-14T13:28:39.167" Score="1" Body="&lt;p&gt;For older Vim versions, there is &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2771&quot; rel=&quot;nofollow noreferrer&quot;&gt;Conque Shell&lt;/a&gt;, a no-longer-supported plugin which nevertheless has served me well in the past, and for now, continues to do so. It's still provided by e.g. &lt;code&gt;vim-addons&lt;/code&gt;, which makes it really easy to add to your setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can start a &lt;code&gt;bash&lt;/code&gt; (or any other command, really...) using the current window as terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ConqueTerm bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Personally I have the following two corresponding lines in my &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ConqueTerm_CWInsert = 1      &quot; Allow &amp;lt;C-w&amp;gt; to switch buffer without leaving insert mode&#xA;let g:ConqueTerm_InsertOnEnter = 1 &quot; Automatically enter insert mode when switching to Conque buffer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1726" LastActivityDate="2019-02-14T13:28:39.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18915" PostTypeId="1" CreationDate="2019-02-14T15:36:45.143" Score="1" ViewCount="314" Body="&lt;p&gt;I am trying to make it so, in the normal mode :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;some modifier + scroll upward&lt;/code&gt; triggers revert &lt;code&gt;u&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;some modifier + scroll downward&lt;/code&gt; triggers redo &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Edit : I do mean mouse scroll&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;some modifier&lt;/em&gt; being left-alt, but that's not the important part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do that ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit 2 : this question is a duplicate of &lt;a href=&quot;https://vi.stackexchange.com/questions/11763/console-vimx-can-i-map-the-scroll-wheel-to-undo-redo&quot;&gt;Console vim(x): Can I map the scroll wheel to undo--redo?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6868" LastEditorUserId="6868" LastEditDate="2019-02-14T16:47:21.643" LastActivityDate="2019-02-14T16:47:21.643" Title="bind mouse scroll up and down" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ClosedDate="2019-02-14T16:55:39.873" ContentLicense="CC BY-SA 4.0" />
  <row Id="18916" PostTypeId="2" ParentId="18915" CreationDate="2019-02-14T16:02:53.690" Score="0" Body="&lt;p&gt;Here is my guess: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;&amp;lt;Up&amp;gt; :execute &quot;normal u&quot;&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;&amp;lt;Down&amp;gt; :execute &quot;normal ^R&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To see all mappings, look at key-codes: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h keycodes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7226" LastEditorUserId="7226" LastEditDate="2019-02-14T16:11:00.110" LastActivityDate="2019-02-14T16:11:00.110" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18917" PostTypeId="1" AcceptedAnswerId="18928" CreationDate="2019-02-14T16:59:22.430" Score="0" ViewCount="92" Body="&lt;p&gt;I would like to be able to open up&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim foo.md foo.css foo.html foo.ts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And either be able to run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Tab md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or the like and jump to the &lt;code&gt;foo.md&lt;/code&gt; tag. Is it possible to get this kind of functionality with Fzf. If I run &lt;code&gt;:Buffers&lt;/code&gt; it does what I want, but it doesn't operate on tabs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  [2]     src/app/foo.component.html                   &#xA;  [3]     src/app/foo.component.spec.ts                &#xA;&amp;gt; [4]     src/app/foo.component.ts                     &#xA;  [1] %   src/app/foo.component.css&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5078" LastActivityDate="2019-02-15T14:41:13.077" Title="Is there an fzf for finding an open tab?" Tags="|tabbed-user-interface|fzf|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18918" PostTypeId="2" ParentId="9426" CreationDate="2019-02-14T18:46:41.527" Score="0" Body="&lt;p&gt;This doesn't exactly answer your question, but I found that neomake works better with &lt;a href=&quot;https://github.com/mantoni/eslint_d.js&quot; rel=&quot;nofollow noreferrer&quot;&gt;eslint_d&lt;/a&gt;. It has the nice side effect that it should do the linting faster too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You first have to install eslint_d globally (but it still seems to pick up any local &lt;code&gt;.eslintrc&lt;/code&gt; file):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;npm install -g eslint_d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then add the following configuration for neomake to your &lt;code&gt;init.vim&lt;/code&gt; / &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;let g:neomake_javascript_enabled_makers = ['eslint_d']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For me that was all I required, after restarting neovim and opening a javascript file running &lt;code&gt;:Neomake&lt;/code&gt; gave me eslint warnings.&lt;/p&gt;&#xA;" OwnerUserId="11986" LastActivityDate="2019-02-14T18:46:41.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18919" PostTypeId="1" AcceptedAnswerId="18921" CreationDate="2019-02-14T23:09:20.937" Score="0" ViewCount="298" Body="&lt;p&gt;I'm using NVIM 0.2.2. When I launch it from the terminal, the color scheme of the terminal affects it's look. And when I launch it from the search menu, it works just fine&lt;a href=&quot;https://i.stack.imgur.com/h9Wbk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h9Wbk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What makes it behaves that way? and how to solve it?&#xA;Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="17888" LastActivityDate="2019-02-15T01:36:51.457" Title="vim looks different when i launch it via the terminal" Tags="|neovim|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18921" PostTypeId="2" ParentId="18919" CreationDate="2019-02-15T01:36:51.457" Score="1" Body="&lt;p&gt;The terminal colours affect any colours in the 16 or 256 colour palette. Most terminal emulators have a pretty standard 256 colour palette, but customize the bottom 16 colors to set the terminal colour scheme. Many vim colourschemes use these 16 colours, so will look very different depending on the terminal colour scheme. There are multiple methods to debug and fix this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good first step might be to work out how the 'launch from the search menu' and 'open in the terminal' methods of running neovim differ. Are they different terminals? etc.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if using a custom vim colorscheme, follow the instructions on that. eg. a solarized colorscheme might ask you to set the terminal 16 colors to the solarized colours.&lt;/li&gt;&#xA;&lt;li&gt;if you can't or don't want to change the terminal colour scheme, look for a true colour (if your terminal supports it) or a 256 colour colorscheme for vim. this will give a standard look regardless of the terminal colour scheme.&lt;/li&gt;&#xA;&lt;li&gt;be careful reading older posts that talk about playing with vim options like &lt;code&gt;t_Co&lt;/code&gt; and friends; in newer vim versions and neovim these are &lt;em&gt;rarely&lt;/em&gt; needed and mostly works out of the box. This can be a common gotcha. ;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerDisplayName="user4879" LastActivityDate="2019-02-15T01:36:51.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18922" PostTypeId="1" AcceptedAnswerId="18925" CreationDate="2019-02-15T09:16:01.333" Score="2" ViewCount="62" Body="&lt;p&gt;I use &lt;code&gt;CTRL-W c&lt;/code&gt; to close current window.&#xA;I expected that &lt;code&gt;5 CTRL-W c&lt;/code&gt; close 5 windows in row, but it's not. Now I just type &lt;code&gt;CTRL-W c&lt;/code&gt; 5 times. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is correct way to do it and why it don't work as I expected?&lt;/p&gt;&#xA;" OwnerUserId="7245" LastEditorUserId="1841" LastEditDate="2019-02-15T11:23:19.203" LastActivityDate="2019-02-18T08:47:02.777" Title="How to close several windows with one mapping?" Tags="|vim-windows|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18923" PostTypeId="1" AcceptedAnswerId="18926" CreationDate="2019-02-15T09:34:58.257" Score="2" ViewCount="29" Body="&lt;p&gt;On line &lt;code&gt;ay&lt;/code&gt;, &lt;code&gt;0dtxdty&lt;/code&gt; deletes the &lt;code&gt;a&lt;/code&gt; (as I would expect), but &lt;code&gt;:norm dtxdty&lt;/code&gt; does nothing, &lt;code&gt;norm!&lt;/code&gt; and &lt;code&gt;exec&lt;/code&gt; don't change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to use it as part of a command to align as explained &lt;a href=&quot;http://vim.wikia.com/wiki/Simple_text_alignment&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, but to two different characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong and what command will work just like normal mode &lt;code&gt;0dtxdty&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="20626" LastEditorUserId="20626" LastEditDate="2019-02-15T10:56:07.083" LastActivityDate="2019-02-15T11:27:12.593" Title="':norm dtxdty' works different than '0dtxdty', what's happening?" Tags="|command-line|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18924" PostTypeId="2" ParentId="18904" CreationDate="2019-02-15T09:52:21.137" Score="1" Body="&lt;p&gt;I handle such situations using macros&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) move cursor to right place:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void foo(bar, baz, que) {&#xA;         ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2) Start writing macros to some buffer. For example - buffer &quot;e&quot; &lt;code&gt;qe&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) correct one argument and move cursor to another &lt;code&gt;iString &amp;lt;esc&amp;gt;WW&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void foo(String bar, baz, que) {&#xA;                     ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;4) Stop macros execution &lt;code&gt;q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5) Execute macros two more times &lt;code&gt;2@e&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void foo(String bar, String baz, String que) {&#xA;                                             ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Total input from right position &lt;code&gt;qeiString &amp;lt;esc&amp;gt;WW2@e&lt;/code&gt;. Where &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; is escape key.&lt;/p&gt;&#xA;" OwnerUserId="7245" LastActivityDate="2019-02-15T09:52:21.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18925" PostTypeId="2" ParentId="18922" CreationDate="2019-02-15T10:58:11.127" Score="2" Body="&lt;p&gt;First, giving a count to the command doesn't work as you expected because the doc (&lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#CTRL-W_c&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h CTRL-W_c&lt;/code&gt;&lt;/a&gt;) says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Without {count}: Close the current window.  If {count} is&#xA;given close the {count} window.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if you want to create a mapping calling &lt;code&gt;&amp;lt;C-w&amp;gt;c&lt;/code&gt; N times you could add this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F1&amp;gt; :&amp;lt;C-u&amp;gt;for i in range(v:count1) \| close \| endfor&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace &lt;code&gt;&amp;lt;F1&amp;gt;&lt;/code&gt; by the key you want to use in your mapping. What is line does is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:                           Go to command line mode&#xA;&amp;lt;C-u&amp;gt;                       Remove the range automatically added to the command line&#xA;for i in range(v:count1)    Create a loop from 0 to the count you gave to the mapping (or 1 if you didn't gave a count)&#xA;close                       Close the current window&#xA;endfor                      End of the loop&#xA;&amp;lt;CR&amp;gt;                        Validate the command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can press &lt;code&gt;&amp;lt;F1&amp;gt;&lt;/code&gt; to close the current window and &lt;code&gt;4&amp;lt;F1&amp;gt;&lt;/code&gt; to close the current window and the 3 next current windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read the following related help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#c_CTRL-U&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h c_CTRL-U&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#range%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h range()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#v%3acount1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h v:count1&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3aclose&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :close&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-02-18T08:47:02.777" LastActivityDate="2019-02-18T08:47:02.777" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18926" PostTypeId="2" ParentId="18923" CreationDate="2019-02-15T11:12:59.837" Score="2" Body="&lt;p&gt;The command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:normal 0dtxdty&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;stops processing after an error. In your case &lt;code&gt;dtx&lt;/code&gt; results in an error, as there is no &lt;code&gt;x&lt;/code&gt; on that line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To ignore this error, use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! normal 0dtxdty&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But be careful with &lt;code&gt;silent!&lt;/code&gt;, you might hide errors, that you want to see.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-15T11:27:12.593" LastActivityDate="2019-02-15T11:27:12.593" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18927" PostTypeId="1" CreationDate="2019-02-15T12:03:05.117" Score="1" ViewCount="742" Body="&lt;p&gt;In vimscript &lt;code&gt;expand('&amp;lt;cword&amp;gt;')&lt;/code&gt; gives me the word under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get the word under the cursor starting at he current cursor location (skipping the word start).&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2023-10-13T18:01:00.170" Title="How to get the current word starting from the cursor?" Tags="|vimscript|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18928" PostTypeId="2" ParentId="18917" CreationDate="2019-02-15T14:41:13.077" Score="1" Body="&lt;p&gt;You need &lt;strong&gt;:Windows&lt;/strong&gt; instead of &lt;strong&gt;:Buffers&lt;/strong&gt; because output of that command has a tab column.&lt;/p&gt;&#xA;" OwnerUserId="19475" LastActivityDate="2019-02-15T14:41:13.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18930" PostTypeId="1" AcceptedAnswerId="18934" CreationDate="2019-02-15T16:23:49.120" Score="1" ViewCount="7656" Body="&lt;p&gt;My current &lt;code&gt;nvim&lt;/code&gt; is in &lt;code&gt;~/AppData/Local/&lt;/code&gt; and I want to drag it out just one directory below &lt;code&gt;$HOME&lt;/code&gt;. How can I set &lt;code&gt;$XDG_CONFIG_HOME&lt;/code&gt;, and can it be done via Neovim?&lt;/p&gt;&#xA;" OwnerUserId="20750" LastActivityDate="2019-02-17T03:24:06.850" Title="Setting $XDG_CONFIG_HOME" Tags="|vimrc|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18932" PostTypeId="1" AcceptedAnswerId="18933" CreationDate="2019-02-15T18:10:07.837" Score="4" ViewCount="2094" Body="&lt;p&gt;How can I detect whether a color scheme installed via a vim-plug plug-in is available?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For context, I'm trying to automate my Vim setup on a new machine, pulling the vimrc from a git repository. The vimrc has &lt;code&gt;:Plug&lt;/code&gt; directives to load all the plugins, but on the first run they're not installed yet. Later on I have a &lt;code&gt;:colorscheme&lt;/code&gt; setting, but that fails if the plug-ins are not installed yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can automate installing plug-ins on first run with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c PlugInstall -c qa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that trips on the &lt;code&gt;:colorscheme&lt;/code&gt; setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing ~/.vimrc:&#xA;line  123:&#xA;E185: Cannot find color scheme 'blablabla'&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After pressing &lt;kbd&gt;Enter&lt;/kbd&gt;, plug-ins are installed correctly and next time everything works as expected... But it's still inconvenient to have this on installation (which is supposed to be as automatic as possible.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found some solutions for the problem, but none of them seems ideal... Using &lt;code&gt;:silent! colorscheme&lt;/code&gt; makes it fail silently, but that's not great since other than during setup I would actually want to know when this fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked at vim-plug documentation to see if there's a function telling whether plug-in X is installed but couldn't find it...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also a possibility of loading the colorscheme using &lt;code&gt;:runtime colors/blablabla.vim&lt;/code&gt; but that's not really great since later on typing &lt;code&gt;:colo&lt;/code&gt; will not report which one is in use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim knows about the color schemes, since when typing &lt;code&gt;:colorscheme &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;D&lt;/kbd&gt;&lt;/code&gt; it will autocomplete all those which are available. But I couldn't really find a good way to get that list from VimL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a good way to programatically tell which color schemes are installed or available?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would you suggest I take a different approach in this case? (I'm open to alternatives that involve radically different ways to fixing the core problem, which is reliable first-time plug-in installation...)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-02-16T10:36:33.223" Title="Detecting whether colorscheme is available" Tags="|vimrc|colorscheme|plugin-system|plugin-vim-plug|" AnswerCount="1" CommentCount="1" ClosedDate="2019-02-18T08:53:53.173" ContentLicense="CC BY-SA 4.0" />
  <row Id="18933" PostTypeId="2" ParentId="18932" CreationDate="2019-02-15T19:02:10.997" Score="5" Body="&lt;p&gt;You could search the colorscheme file via the runtime path:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let colorscheme=&quot;desert&quot;&#xA;if findfile(&quot;colors/&quot; .colorscheme .&quot;.vim&quot;, &amp;amp;rtp) != &quot;&quot;&#xA;    execute &quot;colorscheme &quot; . colorscheme&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another way is to work with try-catch. Thanks to D. Ben Knoble for the hint. Here is a example from his &lt;a href=&quot;https://github.com/benknoble/Dotfiles/blob/master/links/vim/vimrc#L615&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vimrc&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;try&#xA;  colorscheme dracula&#xA;catch /^Vim\%((\a\+)\)\=:E185/&#xA;  colorscheme default&#xA;  set background=dark&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the colorschema &quot;dracula&quot; is not available, Vim would throw the exception &lt;code&gt;Vim(colorscheme):E185: Cannot find color scheme 'dracula'&lt;/code&gt;. This is then catched and a default processing is possible.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-16T10:36:33.223" LastActivityDate="2019-02-16T10:36:33.223" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18934" PostTypeId="2" ParentId="18930" CreationDate="2019-02-15T21:34:53.077" Score="3" Body="&lt;p&gt;Setting environment variables is done via the OS or the shell. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Windows, you can &lt;a href=&quot;https://stackoverflow.com/a/17312376/152142&quot;&gt;use the GUI&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Right click on Computer, Advanced system settings, select Advanced tab and click Environment variables.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;or &lt;a href=&quot;https://stackoverflow.com/a/5898197/152142&quot;&gt;use the shell&lt;/a&gt; (cmd.exe):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setx XDG_CONFIG_HOME C:\Users\foo\bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;code&gt;$XDG_CONFIG_HOME&lt;/code&gt; is generic to all XDG-compliant applications, so don't set it to an Nvim-specific path. If you set &lt;code&gt;XDG_CONFIG_HOME=C:\Users\foo&lt;/code&gt;, then Nvim will put its config in &lt;code&gt;C:\Users\foo\nvim&lt;/code&gt;, and other apps will put their configs in &lt;code&gt;C:\Users\foo\&amp;lt;app&amp;gt;&lt;/code&gt;.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help xdg&lt;/code&gt; attempts to explain this clearly.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="578" LastEditorUserId="578" LastEditDate="2019-02-17T03:24:06.850" LastActivityDate="2019-02-17T03:24:06.850" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18935" PostTypeId="2" ParentId="18188" CreationDate="2019-02-15T23:13:12.407" Score="0" Body="&lt;p&gt;I have been using the official Windows installer from the  site. It worked pretty well on 10+ Windows machines, across multiple years (5+). They are the &quot;best&quot; in terms of the integration with Windows ==&gt; when you right click on two files, there should be a &lt;code&gt;Diff with Vim&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Download link: &lt;a href=&quot;https://www.vim.org/download.php#pc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.vim.org/download.php#pc&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/eaKfw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eaKfw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To note, there are other popular Vim builds, like the one salchint has suggested. Here goes one more:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://sourceforge.net/projects/cream/files/Vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cream's Windows installer for Vim without Cream&lt;/a&gt;. You can find the link at the bottom of &lt;a href=&quot;http://cream.sourceforge.net/download.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;the Cream download page&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Lastly, I would &lt;strong&gt;recommend&lt;/strong&gt; using &lt;a href=&quot;https://github.com/lukesampson/scoop&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;scoop&lt;/code&gt;&lt;/a&gt; to install Vim on Windows. I have just updated all my Vim-on-Windows installation on 4 of my Windows 10 machines this afternoon using the &lt;code&gt;scoop&lt;/code&gt; method. Bring up a Powershell with Admin right, and issue the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    set-executionpolicy remotesigned -scope currentuser&#xA;    iex (new-object net.webclient).downloadstring('https://get.scoop.sh')&#xA;    scoop install vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the end, you need to populate your home directory (&lt;code&gt;C:\users\&amp;lt;username&amp;gt;&lt;/code&gt;) with one more file and one more folder:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;~/_vimrc&lt;/code&gt; file (or &lt;code&gt;.vimrc&lt;/code&gt; file), which configures all aspects of Vim;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;~/vimfiles&lt;/code&gt; ==&gt; on Windows, the &lt;code&gt;autoload&lt;/code&gt; and &lt;code&gt;ftplugin&lt;/code&gt; folders should go into this folder. (This should be the Unix equivalent of &lt;code&gt;~/.vim&lt;/code&gt; folder.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2398" LastActivityDate="2019-02-15T23:13:12.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18937" PostTypeId="1" AcceptedAnswerId="18938" CreationDate="2019-02-16T15:04:10.043" Score="2" ViewCount="493" Body="&lt;p&gt;I'm trying to write a function + map that works on a visual selection. My function just prints out the marks right now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:count = 0&#xA;function! s:plink(...) abort&#xA;    let g:count = g:count + 1&#xA;    echomsg printf(&quot;%d %s %d %s %d&quot;, g:count, a:1, line(a:1), a:2, line(a:2))&#xA;endfunction&#xA;vnoremap &amp;lt;Leader&amp;gt;r :call &amp;lt;SID&amp;gt;plink(&quot;'&amp;lt;&quot;, &quot;'&amp;gt;&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was surprised to find out that my function is being called once per line when I invoke it as &lt;code&gt;shift-V&lt;/code&gt;, select lines, &lt;code&gt;\r&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 '&amp;lt; 80 '&amp;gt; 84&#xA;2 '&amp;lt; 80 '&amp;gt; 84&#xA;3 '&amp;lt; 80 '&amp;gt; 84&#xA;4 '&amp;lt; 80 '&amp;gt; 84&#xA;5 '&amp;lt; 80 '&amp;gt; 84&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I make this snippet call my code only once when I invoke it?&lt;/p&gt;&#xA;" OwnerUserId="21009" LastActivityDate="2019-02-16T15:19:22.527" Title="How to have vnoremap call function once?" Tags="|key-bindings|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18938" PostTypeId="2" ParentId="18937" CreationDate="2019-02-16T15:13:06.473" Score="2" Body="&lt;p&gt;When you start an ex-command (&lt;code&gt;:&lt;/code&gt;) from visual mode, Vim automatically prepends &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; to the command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Function calls can accept ranges, of which the above is an example: when given them, they are called once for each line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One fix is to get rid of the range when the function is called:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;Leader&amp;gt;r :&amp;lt;C-u&amp;gt;call ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that I’ve switched to &lt;code&gt;xnoremap&lt;/code&gt; to only map in visual mode—&lt;code&gt;vnoremap&lt;/code&gt; includes select mode, which generally is undesirable.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The alternative is to declare the function with the range attribute (see &lt;code&gt;:help func-range&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the mapping is unchanged, but the declaration must take two arguments (&lt;code&gt;a:firstline&lt;/code&gt; and &lt;code&gt;a:lastline&lt;/code&gt;). &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-02-16T15:19:22.527" LastActivityDate="2019-02-16T15:19:22.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18940" PostTypeId="1" AcceptedAnswerId="18943" CreationDate="2019-02-16T17:39:28.743" Score="1" ViewCount="1035" Body="&lt;p&gt;When in (Vim) terminal mode, I can use  and then :e! fileName to open a file. Note that without the !, the following error message is displayed &quot;E948: Job still running (add ! to end the job)&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I use the (awesome) fzf commands :Buffers, :Files etc., from the terminal buffer (as if they were run with an !)? &lt;/p&gt;&#xA;" OwnerUserId="21014" LastActivityDate="2019-02-17T08:29:48.573" Title="How to use fzf :Buffers/:Files commands from vim terminal buffer" Tags="|terminal|plugin-fzf|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18942" PostTypeId="1" AcceptedAnswerId="18947" CreationDate="2019-02-16T19:56:07.947" Score="1" ViewCount="219" Body="&lt;p&gt;I installed the latest Neovim 0.4 from scratch, install 'vim-plug', then add only 4 lines to my init.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('d:/neovim/nvim/plugged')&#xA;Plug 'ap/vim-buftabline'&#xA;set hidden&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then create two buffers with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:badd aaa&#xA;:badd bbb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it looks like this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ob7jv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ob7jv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I trid different plugins like &lt;a href=&quot;https://github.com/ap/vim-buftabline&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-buftabline&lt;/a&gt;, &lt;a href=&quot;https://github.com/zefei/vim-wintabs&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-wintabs&lt;/a&gt;, &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-airline&lt;/a&gt;, same issue, it must be problem with the configuration, what do I miss?&lt;/p&gt;&#xA;" OwnerUserId="6971" LastActivityDate="2019-02-17T14:49:14.263" Title="Why buffer tab plugin not work with Neovim 0.4" Tags="|neovim|buffers|tabbed-user-interface|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18943" PostTypeId="2" ParentId="18940" CreationDate="2019-02-16T23:35:46.823" Score="2" Body="&lt;p&gt;The error E948 only occurs if &lt;code&gt;hidden&lt;/code&gt; is not set. In this case vim does not allow to move a modified buffer out of view (lingua Vim: &quot;abandon&quot;). A terminal buffer with a running process (e.g. the shell) is handled like a modified file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set hidden&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your &lt;code&gt;vimrc&lt;/code&gt;. This allows to abandon a modified buffer and a terminal with a running process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help hidden&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-17T08:29:48.573" LastActivityDate="2019-02-17T08:29:48.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18944" PostTypeId="1" AcceptedAnswerId="18948" CreationDate="2019-02-17T01:02:16.953" Score="2" ViewCount="761" Body="&lt;p&gt;I've found it's common to set &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;opfunc&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;opfunc&lt;/code&gt;&lt;/a&gt; in this manner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;r :set opfunc=&amp;lt;SID&amp;gt;my_function&amp;lt;CR&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With Vim8 supporting lambda functions, is it possible to now set &lt;code&gt;opfunc&lt;/code&gt; to a lambda function? The following cursory try did not work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set opfunc={-&amp;gt; &quot;test&quot; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21009" LastEditorUserId="21009" LastEditDate="2019-02-17T16:47:27.413" LastActivityDate="2019-02-18T08:40:14.720" Title="How to set opfunc to a lambda function?" Tags="|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18945" PostTypeId="1" AcceptedAnswerId="18946" CreationDate="2019-02-17T13:07:12.937" Score="1" ViewCount="1857" Body="&lt;p&gt;I know that I can do a conditional key mapping by &lt;code&gt;map-expression&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map [key] [condition] ? [foo] : [bar]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But now my situation is somehow awkward. I want to map &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;C-w&amp;gt;h&lt;/code&gt; if I have more than one windows in my VIM, and map it to &lt;code&gt;:bprev&lt;/code&gt; if there is only one window in my VIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    nnoremap &amp;lt;C-h&amp;gt; winnr('$')&amp;gt;1 ? '&amp;lt;C-w&amp;gt;h' : ':bprev&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work as &lt;code&gt;.vimrc&lt;/code&gt; is only read once when I start VIM. So I also tried with &lt;code&gt;autocmd&lt;/code&gt; and failed. Could anyone help me?&lt;/p&gt;&#xA;" OwnerUserId="17515" LastActivityDate="2019-02-17T14:38:58.220" Title="How to do a conditional key mapping dynamically?" Tags="|vimrc|vimscript|autocmd|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18946" PostTypeId="2" ParentId="18945" CreationDate="2019-02-17T14:38:58.220" Score="4" Body="&lt;p&gt;You need the &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; modifier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;C-h&amp;gt; winnr('$')&amp;gt;1 ? '&amp;lt;C-w&amp;gt;h' : ':bprev&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This conditional is evaluated &lt;em&gt;every&lt;/em&gt; time the mapped key is sent, instead of once at mapping time. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-02-17T14:38:58.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18947" PostTypeId="2" ParentId="18942" CreationDate="2019-02-17T14:49:14.263" Score="0" Body="&lt;p&gt;Finally I found why. There's a command to disable the tab.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Guitabline 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the &lt;a href=&quot;https://raw.githubusercontent.com/equalsraf/neovim-gui-shim/master/doc/nvim_gui_shim.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;document&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6971" LastActivityDate="2019-02-17T14:49:14.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18948" PostTypeId="2" ParentId="18944" CreationDate="2019-02-17T18:25:05.867" Score="5" Body="&lt;p&gt;The &lt;code&gt;operatorfunc&lt;/code&gt; is a option. A option can only have the types boolean (on/off), number or string (see &lt;code&gt;:help options&lt;/code&gt;). So you can't assign a lambda to an option. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the documentation &lt;code&gt;help 'operatorfunc'&lt;/code&gt; says &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This option specifies a function to be called by the g@ operator.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My interpretation of &quot;specifies&quot; is &quot;names&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a look at the code (function &lt;code&gt;op_function&lt;/code&gt; in &lt;code&gt;normal.c&lt;/code&gt;). It calls a vim script function by name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the answer is: No&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-18T08:40:14.720" LastActivityDate="2019-02-18T08:40:14.720" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18949" PostTypeId="1" AcceptedAnswerId="18950" CreationDate="2019-02-17T19:01:27.070" Score="0" ViewCount="49" Body="&lt;p&gt;I have a few functions to help with adding PHP docblock tags. Suppose a block like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt;/**&#xA; * Does a thing&#xA; *&#xA; * |&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;|&lt;/code&gt; is my cursor position. I have a mapping to &lt;code&gt;&amp;lt;localleader&amp;gt;@p&lt;/code&gt;, for instance, to insert an &lt;code&gt;@package&lt;/code&gt; tag:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt; * @package foo-bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Function&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Here's my basic function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MaybeSetPackage()&#xA;    if ! exists( &quot;g:php_package&quot; )&#xA;        let l:package = ''&#xA;    else&#xA;        let l:package = g:php_package&#xA;    endif&#xA;&#xA;    execute ':normal! a@package ' . l:package&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Expectation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;When I move to a line in the docblock and type &lt;code&gt;\@p&lt;/code&gt;, this should be the result:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt;/**&#xA; * Does a thing&#xA; *&#xA; * @package foo-bar&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;What sometimes happens&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If I'm on a line in NORMAL mode, like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt;/**&#xA; * Does a thing&#xA; * |&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And hit &lt;code&gt;o&lt;/code&gt;, I'm here:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt;/**&#xA; * Does a thing&#xA; *&#xA; * |&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then, while still in INSERT mode, I type &lt;code&gt;\@p&lt;/code&gt;, I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt;/**&#xA; * Does a thing&#xA; *&#xA; *@package foo-bar&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I type &lt;code&gt;o&lt;/code&gt;, delete the space after &lt;code&gt;*&lt;/code&gt;, type a new space, and &lt;em&gt;then&lt;/em&gt; do &lt;code&gt;\@p&lt;/code&gt;, I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt;/**&#xA; * Does a thing&#xA; *&#xA; * @package foo-bar&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Why?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Why, after hitting &lt;code&gt;o&lt;/code&gt; and getting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; * |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does my function seem to remove the automatically inserted space and leave me with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; *@package foo-bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when I delete the automatically inserted space and add my own, followed by my mapping, I get the expected result of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; * @package foo-bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Update&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Adding my mapping: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;    autocmd FileType php inoremap &amp;lt;buffer&amp;gt; &amp;lt;localleader&amp;gt;@p &amp;lt;esc&amp;gt;:call MaybeSetPackage()&amp;lt;CR&amp;gt;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="286" LastEditorUserId="286" LastEditDate="2019-02-19T04:32:13.307" LastActivityDate="2019-02-19T04:32:13.307" Title="Why does my function sometimes respect whitespace?" Tags="|key-bindings|functions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18950" PostTypeId="2" ParentId="18949" CreationDate="2019-02-17T20:43:07.837" Score="3" Body="&lt;p&gt;The important part of the question is missing: The mapping. I assume the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;localleader&amp;gt;@p &amp;lt;C-O&amp;gt;:call MaybeSetPackage()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The point here is, that you are leaving insert mode (here with &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;) and Vim automatically removes spaces that were added by automatic indent. If you add the spaces yourself, they are not removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to insert text &lt;em&gt;without&lt;/em&gt; leaving insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Inserting the expression register&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;expression register&quot; can be inserted with &lt;code&gt;&amp;lt;C-R&amp;gt;=...&lt;/code&gt;. This is not really a register, you have to provide the expression. &#xA;Your mapping might than be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;localleader&amp;gt;@p @package &amp;lt;C-R&amp;gt;=exists(&quot;g:php_package&quot;)?g:php_package:''&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or, if you want to keep your function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MaybeSetPackage()&#xA;    if ! exists( &quot;g:php_package&quot; )&#xA;        let l:package = ''&#xA;    else&#xA;        let l:package = g:php_package&#xA;    endif&#xA;    &quot; Now returns the text to insert&#xA;    return '@package ' . l:package&#xA;endfunction&#xA;&#xA;&#xA;inoremap &amp;lt;localleader&amp;gt;@p &amp;lt;C-R&amp;gt;=MaybeSetPackage()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help i_Ctrl-R_=&lt;/code&gt; for the details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Map-Expressions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way would be to use a &lt;code&gt;map-&amp;lt;expr&amp;gt;&lt;/code&gt;. This type of maps, maps to a Vim script expression, that returns the characters (or keystrokes) that Vim should interpret. In the following case the &lt;code&gt;@package ...&lt;/code&gt; characters are returned and as it is a input-mapping, they are inserted in the buffer. Again, you can put the Vim script code directly into the mapping or call a function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; \@p '@package ' . (exists('g:php_package')?g:php_package:'')&#xA;inoremap &amp;lt;expr&amp;gt; \@P MaybeSetPackage()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help map-&amp;lt;expr&amp;gt;&lt;/code&gt; for details.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;BTW: Using &lt;code&gt;get()&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@D.BenKnoble mentioned &lt;code&gt;get()&lt;/code&gt; in the comments. This is a function to search for an entry in a dictionary. It can be used in the following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;get(g:, 'php_package', '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case &lt;code&gt;g:&lt;/code&gt; is the dictionary of all global variables. Now &lt;code&gt;get()&lt;/code&gt; searches for the entry &lt;code&gt;php_package&lt;/code&gt; in this dictionary. If found the variable value is returned, else the default value (&lt;code&gt;''&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the above mapping could be written as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; \@p '@package ' . get(g:,'php_package','')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works, is very compact and (if you know what it is doing) easy to understand.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-18T22:13:15.240" LastActivityDate="2019-02-18T22:13:15.240" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18951" PostTypeId="1" CreationDate="2019-02-17T22:16:25.680" Score="0" ViewCount="95" Body="&lt;p&gt;I'm trying to understand the difference in character counting between Normal and Visual modes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Roses are red,&#xA;Violets are blue,&#xA;Sugar is sweet,&#xA;And so are you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The task is to copy everything from &lt;code&gt;are&lt;/code&gt; on the 1st line to &lt;code&gt;so&lt;/code&gt; on the last:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;are red,&#xA;Violets are blue,&#xA;Sugar is sweet,&#xA;And so&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Normal mode it could be achieved with &lt;code&gt;wy13w&lt;/code&gt;. However, when I use the same command in Visual mode (&lt;code&gt;wv13w&lt;/code&gt;), the selection looks wrong:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mP6Iv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mP6Iv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's wrong with it?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;temporary image (see comments):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZmO2q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZmO2q.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="7200" LastEditDate="2019-02-17T23:08:48.370" LastActivityDate="2019-02-17T23:08:48.370" Title="Select characters in Visual mode (works differently than Normal mode)" Tags="|visual-mode|cursor-motions|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18952" PostTypeId="1" CreationDate="2019-02-17T23:36:43.957" Score="1" ViewCount="761" Body="&lt;p&gt;I have a question: How to search a string using a basic regular expression in Vi editor? How about using extended regular expression in Vi editor?. Is it a real difference between basic regular expression and extended regular expression? They have different syntaxes but the algorithm is the same. What is the logically correct answer for this question?&lt;/p&gt;&#xA;" OwnerUserId="21029" LastActivityDate="2019-02-17T23:36:43.957" Title="Basic and extended regular expression" Tags="|regular-expression|" AnswerCount="0" CommentCount="4" ClosedDate="2019-09-18T12:05:33.813" ContentLicense="CC BY-SA 4.0" />
  <row Id="18953" PostTypeId="1" AcceptedAnswerId="18954" CreationDate="2019-02-18T03:31:46.340" Score="0" ViewCount="87" Body="&lt;p&gt;I have the following command for &lt;code&gt;\&lt;/code&gt; that jumps to the last character unless the cursor is under the last character, in which case it jumps to the start of the line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; \ ((col(&quot;.&quot;) &amp;gt;= col(&quot;$&quot;)-1) ? &quot;^&quot; : &quot;$&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works great most of the time unless the final character is a multibyte char, e.g. the 1-line file &lt;code&gt;multibyte.txt&lt;/code&gt; (given below)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aaaaaaaaaa的的的的的的的&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\&lt;/code&gt; moves to the end of the line, but repeatedly pressing it keeps it there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to detect whether the cursor is at the last byte in a line, regardless of the number of bytes that make up the character?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2019-02-18T06:10:09.470" Title="Detect when at last character when character is multibyte" Tags="|unicode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18954" PostTypeId="2" ParentId="18953" CreationDate="2019-02-18T06:10:09.470" Score="2" Body="&lt;p&gt;The function &lt;code&gt;col()&lt;/code&gt; returns the byte offset of the cursor in the current line. The returned value is the offset of the first byte of a multi-byte character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use &lt;code&gt;virtcol()&lt;/code&gt; instead. It returns the screen column of the character.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; \ ((virtcol(&quot;.&quot;) &amp;gt;= virtcol(&quot;$&quot;)-1) ? &quot;^&quot; : &quot;$&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a short test it also works, when the last char is double-width.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-18T06:10:09.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18955" PostTypeId="2" ParentId="18761" CreationDate="2019-02-18T10:12:51.673" Score="3" Body="&lt;p&gt;Even though the accepted answer is correct and OP has moved away from using a mapping that is subject to the root cause I feel like an important detail has been omitted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The time that Vim waits to see if the next keystroke is part of a mapped key sequence or not is configurable via the &lt;code&gt;'timeoutlen'&lt;/code&gt; (abbreviation &lt;code&gt;'tm'&lt;/code&gt;) setting. It contains the delay in milliseconds and the default is 1000 which is a quite conspicuous wait for an interactive application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you were particularly set on using a mapping that is subject to the kind of issues described by OP then you can set it to something like 100. I find 100 to be plenty enough time to enter in a pair of characters while at the same time not being too disruptive to my flow in those cases where it's applicable. If you're really quick you can even set it to 0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I don't know what the actual delay is in the case of 0. It's not literally 0 or it wouldn't work. I should look at the code but I suppose it could mean a &quot;natural&quot; delay, i.e. there's always some fudge factor to timings in non-real-time systems. Maybe thanks the buffering characteristics vim pulls more than one input char in a loop iteration so the timer doesn't get incremented. Or a millisecond granularity clock is being used and the char fetch loop is executed multiple times before it is incremented. Or....ah never mind. It's quick!)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-02-18T11:19:54.970" LastActivityDate="2019-02-18T11:19:54.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18956" PostTypeId="2" ParentId="18814" CreationDate="2019-02-18T13:00:56.660" Score="0" Body="&lt;p&gt;Found a way round my problem... though I still don't fully understand the underlying logic. So all comments welcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By adding a rule that simply matches the start of line and making my previously top-level rules (block level as opposed to inlined in block) contained, I dramatically reduced the number of occurrences, and hence the &lt;code&gt;syntime&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match mdStartOfLine /^/ contains=@mdBlock&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;mdStartOfLine&lt;/code&gt; rule is effectively only matched once per line, as opposed to the &lt;code&gt;paragraph&lt;/code&gt; rule in my original post which was tried thousands of times (the number of trials not apparently linked to the number of lines in the file to hilight).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A (supposedly) side effect of this approach being that I can now use &lt;code&gt;region&lt;/code&gt; rather than &lt;code&gt;match&lt;/code&gt;, and consequently don't need to check for the block separator (&lt;code&gt;\n\n\+&lt;/code&gt;). This significantly simplifies my syntax file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A lesson learnt for me in this exercise is that a syntax highlighting grammar is not a parser; it doesn't need to &lt;em&gt;understand&lt;/em&gt;, simply to &lt;em&gt;detect&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17308" LastActivityDate="2019-02-18T13:00:56.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18957" PostTypeId="1" CreationDate="2019-02-18T15:24:14.400" Score="1" ViewCount="88" Body="&lt;p&gt;I have a fresh install of Ubuntu 18.10 and VI is exhibiting behavior I am unaccustomed to. For example, when I insert something using &quot;i&quot;, 4 spaces are automatically placed in front of what I've inserted. Or, when I use &quot;o&quot;, instead of creating a new line and putting me at the front of the line, it puts me 8 spaces ahead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm guessing this is some kind of auto-indenting mechanism, but I don't have a .vimrc file in my home directory so not really sure where to unset this.&lt;/p&gt;&#xA;" OwnerUserId="21036" LastActivityDate="2019-02-18T15:24:14.400" Title="How do I configure my VI environment on Ubuntu 18.10?" Tags="|vimrc|linux-ubuntu|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="18958" PostTypeId="1" CreationDate="2019-02-18T20:47:12.407" Score="0" ViewCount="189" Body="&lt;p&gt;I have vim version 7.4.1689. It was running quite smoothly. But recently I noticed a problem that I didn't have before. Whenever I run &lt;code&gt;:help &amp;lt;something&amp;gt;&lt;/code&gt; in command mode the following error shows up (say I ran the command &lt;code&gt;help normal&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;various.txt&quot; [readonly] 674L, 26915C&#xA;Error detected while processing BufRead Auto commnads for &quot;*.*&quot;:&#xA;E45: 'readonly option is set (add ! to override)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See attached picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am mentioning all my &lt;code&gt;BufRead&lt;/code&gt; autocmds here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup SomeAutocmds&#xA;    autocmd!&#xA;    autocmd BufNewFile,BufRead *.* write&#xA;    autocmd BufNewFile,BufRead *.* source $MYVIMRC&#xA;    autocmd BufNewFile,BufRead *.* setlocal foldmethod=marker&#xA;    autocmd BufNewFile,BufRead *.* silent loadview&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have recently updated my plugins, and I started noticing this problem right after updating my plugins. My plugins are listed below (I am sorry, I have lot of plugins):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'LaTeX-Box-Team/LaTeX-Box'&#xA;Plugin 'MahbubAlam231/dragvisuals'&#xA;Plugin 'MahbubAlam231/hybrid-line-numbers'&#xA;Plugin 'MahbubAlam231/searching-with-blinking'&#xA;Plugin 'MahbubAlam231/vim-system-copy'&#xA;Plugin 'SirVer/ultisnips'&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'bronson/vim-trailing-whitespace'&#xA;Plugin 'christoomey/vim-quicklink'&#xA;Plugin 'christoomey/vim-sort-motion'&#xA;Plugin 'christoomey/vim-titlecase'&#xA;Plugin 'danro/rename.vim'&#xA;Plugin 'easymotion/vim-easymotion'&#xA;Plugin 'ervandew/supertab'&#xA;Plugin 'flazz/vim-colorschemes'&#xA;Plugin 'junegunn/fzf.vim'&#xA;Plugin 'justinmk/vim-sneak'&#xA;Plugin 'kana/vim-textobj-datetime'&#xA;Plugin 'kana/vim-textobj-entire'&#xA;Plugin 'kana/vim-textobj-indent'&#xA;Plugin 'kana/vim-textobj-line'&#xA;Plugin 'kana/vim-textobj-user'&#xA;Plugin 'mattn/webapi-vim'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'tibabit/vim-templates'&#xA;Plugin 'tpope/vim-abolish'&#xA;Plugin 'tpope/vim-commentary'&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'tpope/vim-repeat'&#xA;Plugin 'tpope/vim-surround'&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;Plugin 'vim-scripts/ReplaceWithRegister'&#xA;Plugin 'vim-scripts/ZoomWin'&#xA;Plugin 'vim-scripts/indentpython.vim'&#xA;Plugin 'vim-scripts/matchit.zip'&#xA;Plugin 'vim-syntastic/syntastic'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bMjPL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bMjPL.png&quot; alt=&quot;BufRead autocmd problem and E45&quot;&gt;&lt;/a&gt;&#xA;I had changed &lt;code&gt;*.*&lt;/code&gt; to &lt;code&gt;*&lt;/code&gt; in &lt;code&gt;BufRead&lt;/code&gt; autocmds, but the problem didn't go away. I have tried to find solution to this online, but couldn't find any that helped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would be glad if someone points out what's going on and gives a solution.&lt;/p&gt;&#xA;" OwnerUserId="16884" LastEditorUserId="1841" LastEditDate="2019-02-19T08:37:10.527" LastActivityDate="2019-02-19T08:37:10.527" Title="BufRead autocmd error for &quot;*.*&quot; and E45" Tags="|autocmd|help-system|error|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="18959" PostTypeId="1" AcceptedAnswerId="18961" CreationDate="2019-02-19T04:17:17.773" Score="2" ViewCount="1606" Body="&lt;p&gt;I am new to Vim. I managed to use &lt;code&gt;:terminal&lt;/code&gt; and &lt;code&gt;:vertical terminal&lt;/code&gt; to have a terminal side by side with my code.  This works great, I can move between my code and the terminals.  However, how do I go back to the last command in terminal? For example, I can't just press &quot;Up&quot; on the keyboard while in terminal.  For the standalone terminal application, this would bring up the previous command.  This doesn't work on while in Vim's terminal. The error is &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;cannot make changes, modifieable is off&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed that there are two modes when you use Terminal in Vim.  There's the usual command line in Linux, and the Vim mode where you can use hjkl to move and etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this why I cant press up to use previous command? Please let me know and thank you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P/S: This is solved.  I mapped the Esc key to exit Terminal Normal Mode to Terminal Vim Mode.  There were replies below but for some reasons those got deleted.  Anyway, yes we can press up to get to the last command.  Just remember, that we have to be in Normal terminal mode and not Vim mode.  &lt;/p&gt;&#xA;" OwnerUserId="21038" LastEditorUserId="1841" LastEditDate="2019-02-19T08:24:46.947" LastActivityDate="2019-02-20T10:41:54.310" Title="How to go up to previous command when in terminal mode in Vim 8?" Tags="|terminal-buffer|command-history|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18961" PostTypeId="2" ParentId="18959" CreationDate="2019-02-19T05:37:54.390" Score="0" Body="&lt;p&gt;OP mentioned using &lt;code&gt;tnoremap &amp;lt;Esc&amp;gt; &amp;lt;C-w&amp;gt;N&lt;/code&gt; in the comments: as noted in &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/doc/terminal.txt#L113&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h terminal-typing&lt;/code&gt;&lt;/a&gt;, this tends to break cursor keys, which send escape-sequences that vim interprets. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this mapping, those sequences stop making sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution is to fiddle with &lt;code&gt;'timeoutlen'&lt;/code&gt; and &lt;code&gt;'ttimeoutlen'&lt;/code&gt; (if memory serves, it’s generally ok to make &lt;code&gt;'ttimeout'&lt;/code&gt; quite small). They control how vim interprets rapid key-presses and mappings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other solution is to disable/stop using said mapping. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-02-19T05:37:54.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18963" PostTypeId="2" ParentId="6627" CreationDate="2019-02-19T15:03:58.767" Score="1" Body="&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: As noted by @Christian Brabandt below, &lt;strong&gt;this is no longer the case&lt;/strong&gt;. Can't imagine why I had to do this. :=(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to &lt;code&gt;:set filetype=markdown&lt;/code&gt; or do it in an autocmd group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turns out that vim by default sets &lt;code&gt;.md&lt;/code&gt; files to Modula-2 (except for README.md), so that overrides the syntax setting.&lt;/p&gt;&#xA;" OwnerUserId="4449" LastEditorUserId="4449" LastEditDate="2019-04-16T11:06:17.837" LastActivityDate="2019-04-16T11:06:17.837" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18964" PostTypeId="1" AcceptedAnswerId="18966" CreationDate="2019-02-19T15:14:56.450" Score="1" ViewCount="877" Body="&lt;p&gt;I want to set my markdown files to have &lt;code&gt;textwidth=100&lt;/code&gt; but cannot get it working. The strange thing is that it works sometimes and sometimes not. My autocmd is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup auFileTypes&#xA;  autocmd! auFileTypes&#xA;  audocmd BufNewFile,BufRead *.md set filetype=markdown | setlocal textwidth=100&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some files (such as &lt;code&gt;create_template.md&lt;/code&gt; or &lt;code&gt;index.md&lt;/code&gt;) just work; some files (such as &lt;code&gt;completed_jobs.md&lt;/code&gt; or &lt;code&gt;issues.md&lt;/code&gt;) don't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought at first it might be a &quot;sequencing&quot; problem such as every other one works, but that turned out not to be the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm on version 8.1-650, via Homebrew.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&#xA;When I load the file &lt;code&gt;completed_jobs.md&lt;/code&gt;, :setlocal says this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Local option values ---&#xA;  autoindent          cryptmethod=        errorformat=        grepprg=            linebreak           number              scroll=33           sidescrolloff=-1    syntax=markdown&#xA;--autoread            cursorline          expandtab           include=            lispwords=          path=               scrolloff=-1        softtabstop=2       tabstop=2&#xA;  backupcopy=         define=             filetype=markdown   keywordprg=         makeprg=            relativenumber      shiftwidth=2      noswapfile            tagcase=&#xA;  cinkeys=0{,0},0),:,0#,!^F,o,O,e&#xA;  comments=fb:*,fb:-,fb:+,n:&amp;gt;&#xA;  commentstring=&amp;lt;!--%s--&amp;gt;&#xA;  fileencoding=utf-8&#xA;  formatlistpat=^\s*\d\+\.\s\+\|^[-*+]\s\+\|^\[^\ze[^\]]\+\]:&#xA;  indentkeys=0{,0},:,0#,!^F,o,O,e&#xA;  iskeyword=@,48-57,_,192-255,$&#xA;  tags=./tags,tags,~/workspace/automation-ui-core-etap/tags&#xA;  undolevels=-123456&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and `onboarding.md :setlocal says this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Local option values ---&#xA;  autoindent          cryptmethod=      noendofline           filetype=markdown   keywordprg=         makeprg=            relativenumber      shiftwidth=2      noswapfile            tagcase=&#xA;--autoread            cursorline          errorformat=        grepprg=            linebreak           number              scroll=33           sidescrolloff=-1    syntax=markdown     textwidth=100&#xA;  backupcopy=         define=             expandtab           include=            lispwords=          path=               scrolloff=-1        softtabstop=2       tabstop=2&#xA;  cinkeys=0{,0},0),:,0#,!^F,o,O,e&#xA;  comments=fb:*,fb:-,fb:+,n:&amp;gt;&#xA;  commentstring=&amp;lt;!--%s--&amp;gt;&#xA;  fileencoding=utf-8&#xA;  formatoptions=tcqln&#xA;  formatlistpat=^\s*\d\+\.\s\+\|^[-*+]\s\+\|^\[^\ze[^\]]\+\]:&#xA;  indentkeys=0{,0},:,0#,!^F,o,O,e&#xA;  iskeyword=@,48-57,_,192-255,58,-,$&#xA;  tags=./tags,tags,~/workspace/automation-ui-core-etap/tags&#xA;  undolevels=-123456&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Only difference I can see (besides the missing &lt;code&gt;textwidth=100&lt;/code&gt;) is the &lt;code&gt;noendofline&lt;/code&gt; setting. However, even that is not consistent across the various successes and failures.&lt;/p&gt;&#xA;" OwnerUserId="4449" LastEditorUserId="4449" LastEditDate="2019-02-19T19:31:35.173" LastActivityDate="2019-02-19T19:31:35.173" Title="autocmd for markdown textwidth=100 failing" Tags="|vimrc|autocmd|filetype|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18966" PostTypeId="2" ParentId="18964" CreationDate="2019-02-19T18:26:18.390" Score="0" Body="&lt;p&gt;Files matching &lt;code&gt;*.md&lt;/code&gt; are detected as markdown. The extension &lt;code&gt;md&lt;/code&gt; was removed from Modula and &quot;given&quot; to Markdown. So you don't need to act on file extensions, but you can use the &lt;code&gt;FileType&lt;/code&gt; event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change your &lt;code&gt;vimrc&lt;/code&gt; to contain:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup auFileTypes&#xA;  autocmd!&#xA;  autocmd FileType markdown setlocal textwidth=100&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This autocommand is executed when the file type &quot;markdown&quot; is detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this doesn't work as expected, reduce your Vim setup to only contain the four lines above and test. Then slowly build up your Vim setup again, until you find the part that interferes with above autocommands.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As statox mentioned in the comments, there is a defined way to activate filetype specific settings, by creating a file in the directory &lt;code&gt;~/.vim/after/ftplugin&lt;/code&gt; with the file name like the file type (&lt;code&gt;~/.vim/after/ftplugin/markdown.vim&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to admit, that if you only want to change one option, this is oversized.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-19T19:29:40.803" LastActivityDate="2019-02-19T19:29:40.803" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="18967" PostTypeId="1" AcceptedAnswerId="18971" CreationDate="2019-02-19T19:28:20.767" Score="3" ViewCount="805" Body="&lt;p&gt;I am able to use &lt;code&gt;strftime()&lt;/code&gt; to convert the &lt;strong&gt;current&lt;/strong&gt; time to a string, but now I need to work the other way around:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Convert a string to &lt;code&gt;{time}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Modify the time value&lt;/li&gt;&#xA;&lt;li&gt;Convert back to string&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is there a way of doing this within Vim? That is, without the help of external commands, like &lt;code&gt;date&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="599" LastActivityDate="2019-02-20T08:10:01.047" Title="How use a custom time value in `strftime()`" Tags="|vimscript|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18969" PostTypeId="1" AcceptedAnswerId="18970" CreationDate="2019-02-20T04:13:38.470" Score="2" ViewCount="674" Body="&lt;p&gt;I am a Vim beginner. I know you can do &lt;code&gt;:tabnew file1 file2&lt;/code&gt; to have Vim open up a bunch of files name file1, file2 spread across as tabs.  I know you can move forward and backward between tabs.  My problem is: when I try to open a Vim terminal using &lt;code&gt;:terminal&lt;/code&gt;, I can only switch back to 1 of the tab.  For example, if I am in file1, I use &lt;code&gt;:terminal&lt;/code&gt; , I can only switch back between the terminal and file1, I cannot access file2 unless I close the terminal, which brings us back to the beginning, where we have tabs across the editor. Is it possible to cycle between Vim terminal, file1 and file2? Or I better off just use &lt;code&gt;:!  some commands&lt;/code&gt; then use that as my way to access the terminal? That is a good idea but due to my work, I would need to see the terminal outputs.  Using &lt;code&gt;:! some commands&lt;/code&gt; will perform terminal commands, but once you press Enter, you are back to the editor and can no longer see what happens at the terminal.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please let me know and thank you very much for your help. &lt;/p&gt;&#xA;" OwnerUserId="21038" LastActivityDate="2019-07-22T10:39:07.897" Title="How to set group of tabs and 1 single terminal in Vim 8?" Tags="|vimscript|buffers|terminal|linux|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="18970" PostTypeId="2" ParentId="18969" CreationDate="2019-02-20T05:12:52.417" Score="2" Body="&lt;p&gt;You can move between tabs by type &lt;code&gt;gt&lt;/code&gt; to move forward and &lt;code&gt;gT&lt;/code&gt; to move backward in the Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can show the buffers (like the opening files) by type the command &lt;code&gt;:buffers&lt;/code&gt; then choose the index number to open any buffer you want by typing another command &lt;code&gt;b4&lt;/code&gt; for example to open the first buffer like in the picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WyMpf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WyMpf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at fzf.vim plugin &lt;a href=&quot;https://github.com/junegunn/fzf.vim#commands&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/junegunn/fzf.vim#commands&lt;/a&gt;. They provides an easy way to access buffers by just type &lt;code&gt;:Buffer&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="20074" LastActivityDate="2019-02-20T05:12:52.417" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18971" PostTypeId="2" ParentId="18967" CreationDate="2019-02-20T08:10:01.047" Score="4" Body="&lt;p&gt;There's no native function to parse a string into a time. The other direction is possible, though, because the &lt;code&gt;strftime()&lt;/code&gt; function you mentioned takes an optional second parameter, &lt;code&gt;{time}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo strftime(&quot;%Y %b %d %X&quot;, localtime())&#xA;2019 Feb 20 12:12:12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The form of the time is seconds since epoch (1/1/1970). &lt;code&gt;localtime()&lt;/code&gt; returns current time in that form which is why I used it in the example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, &lt;code&gt;strftime()&lt;/code&gt; isn't portable. It's system dependent both in it's presence or lack there of as well as determining what are valid format strings if it is present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since portability is out the window might as well use external commands (e.g. &lt;code&gt;:!date ...&lt;/code&gt; if you're on *nix).  :)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-02-20T08:10:01.047" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18972" PostTypeId="2" ParentId="18959" CreationDate="2019-02-20T10:41:54.310" Score="4" Body="&lt;p&gt;One other thing that you can do is use &lt;code&gt;&amp;lt;Ctrl-P&amp;gt;&lt;/code&gt; to go to the 'Previous' command. This is also works in bash terminals. You can also do &lt;code&gt;&amp;lt;Ctrl-N&amp;gt;&lt;/code&gt; to go to the 'Next' command.&lt;/p&gt;&#xA;" OwnerUserId="21060" LastActivityDate="2019-02-20T10:41:54.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18973" PostTypeId="1" AcceptedAnswerId="18974" CreationDate="2019-02-20T15:59:02.003" Score="3" ViewCount="226" Body="&lt;p&gt;I'm writing a plugin where I have several buffers open in split panes ( let's call them small panes ). The user can navigate between the small pane using the usual ctrl+w , wincmd etc ways. While I have another larger pane ( let's call it the large pane ), into which the buffer moved to should get automatically loaded. I have the following script to do this : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:current_buff=1&#xA;let g:loading_buffer=0&#xA;&#xA;function! ActionOnWindowSwitch(...)&#xA;    if g:loading_buffer == 0&#xA;        let g:current_buff = bufnr(&quot;%&quot;)&#xA;        echo g:current_buff&#xA;        if g:current_buff != 1&#xA;            let g:loading_buffer=1&#xA;            :wincmd k&#xA;            :buffer g:current_buff&#xA;            :wincmd p&#xA;            let g:loading_buffer=0&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&#xA;au BufEnter * call ActionOnWindowSwitch()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I run this, I get the error : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;E94: No matching buffer for g:current_buff&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have verified by hardcoding the &lt;code&gt;g:current_buff&lt;/code&gt; value that the script works in terms of loading the buffer etc. The problem seems mostly in variable substitution. Or that's what is my best guess. Any ideas how this can be fixed ?&lt;/p&gt;&#xA;" OwnerUserId="17398" LastActivityDate="2019-02-20T16:40:00.953" Title="Load current buffer in another pane" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18974" PostTypeId="2" ParentId="18973" CreationDate="2019-02-20T16:06:48.203" Score="7" Body="&lt;p&gt;You're correct in your diagnosis of the problem: no variable substitution is being performed. Try replacing the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:buffer g:current_buf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;buffer&quot; g:current_buf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(As an aside, note also that the colon characters at the start of your &lt;code&gt;:wincmd&lt;/code&gt; lines can also be removed.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally, if you want the &lt;em&gt;value&lt;/em&gt; of a variable to be used in a command-line command, you need to build the command as a string and then run it using &lt;code&gt;:execute&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-02-20T16:40:00.953" LastActivityDate="2019-02-20T16:40:00.953" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18975" PostTypeId="2" ParentId="16575" CreationDate="2019-02-20T16:30:21.380" Score="1" Body="&lt;p&gt;I am using the following in gVim on Windows 10:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Record a macro that does the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:TOhtml&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ggVG&lt;/code&gt; (select all)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;*y&lt;/code&gt; (yank to system clipboard)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:q!&lt;/code&gt; (close the TOhtml file)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:!start /min powershell -noprofile &quot;gcb | scb -as&quot;&lt;/code&gt; Start a minimized instance of Powershell that runs a shorthand equivallent of &lt;code&gt;Get-Clipboard | Set-Clipboard -AsHtml)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;After running this macro and allowing Powershell to complete, I can then paste directly into Outlook 2016.&lt;/p&gt;&#xA;" OwnerUserId="21070" LastEditorUserId="21070" LastEditDate="2019-02-21T14:37:35.330" LastActivityDate="2019-02-21T14:37:35.330" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18976" PostTypeId="2" ParentId="18732" CreationDate="2019-02-20T17:33:36.413" Score="2" Body="&lt;h2&gt;The fix&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region xBCD start=&quot;b&quot; end=&quot;d&quot;&#xA;syntax region xBlock start=&quot;abcde::&quot;hs=s+5 end=&quot;;&quot; contains=xBCD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Explanation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The problem is not that Vim cannot highlight a subset of &lt;code&gt;start&lt;/code&gt;. Instead it is your use of &lt;code&gt;\zs&lt;/code&gt; that is causing issues. We can show this is true by removing the &lt;code&gt;\zs&lt;/code&gt; and allowing the &lt;code&gt;xBCD&lt;/code&gt; to be inside the &lt;code&gt;xBlock&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region xBlock start=&quot;abcde::&quot; end=&quot;;&quot; contains=xBCD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will see that your &lt;code&gt;bcd&lt;/code&gt; is now highlighted, but obviously now your &lt;em&gt;entire&lt;/em&gt; &lt;code&gt;xBlock&lt;/code&gt; is highlighted, which is not your goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a highlight offset (see &lt;code&gt;:help syn-pattern-offset&lt;/code&gt;) fixes this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a &quot;positive lookbehind&quot; instead (see &lt;code&gt;:help /\@&amp;lt;=&lt;/code&gt;) is an alternative method of achieving your desired highlighting which might work better for your requirements:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region xBlock start=&quot;\(abcde\)\@&amp;lt;=::&quot; end=&quot;;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Your use of &lt;code&gt;\z()&lt;/code&gt; to mark the subexpression as &quot;external&quot; doesn't seem to be used anywhere in your example, so I removed it. The solution still works fine with it reinserted, though.)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Why your code failed&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here is my explanation of I think was going wrong with your code. It's conjecture, but &lt;a href=&quot;https://vi.stackexchange.com/questions/14047/how-does-zs-interact-with-syntax-matches&quot;&gt;based on a reasonable amount of experimentation&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use &lt;code&gt;\zs&lt;/code&gt; it moves the start of your match to &lt;em&gt;after&lt;/em&gt; the &lt;code&gt;abcde&lt;/code&gt;. This means that your &lt;code&gt;xBlock&lt;/code&gt; is no longer the first piece of matching syntax in your sample file: the &lt;code&gt;xBCD&lt;/code&gt; is now found a few characters earlier, and thus is highlighted. Vim then starts looking after the end of the matching &lt;code&gt;xBCD&lt;/code&gt;, which is too far forwards for &lt;code&gt;xBlock&lt;/code&gt; to match, so no more matches are found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your attempt to fix it by adding &lt;code&gt;contains=xBCD&lt;/code&gt; to your &lt;code&gt;xBlock&lt;/code&gt; definition therefore failed because the &lt;code&gt;xBCD&lt;/code&gt; region is &lt;em&gt;not&lt;/em&gt; inside &lt;code&gt;xBlock&lt;/code&gt;, it's a few characters before the start of where the &lt;code&gt;xBlock&lt;/code&gt; would be, if its own presence didn't prevent the &lt;code&gt;xBlock&lt;/code&gt; from being matched at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason your second attempt gave different results is that you also added &lt;code&gt;contained&lt;/code&gt; to your definition of &lt;code&gt;xBCD&lt;/code&gt;, which does &lt;em&gt;not&lt;/em&gt; mean that &lt;code&gt;xBCD&lt;/code&gt; can be found inside other syntax groups, but instead that it &lt;em&gt;cannot&lt;/em&gt; be found outside of them, at the top level. Therefore, the &lt;code&gt;xBCD&lt;/code&gt; region is no longer found, and now your highlighting for &lt;code&gt;xBlock&lt;/code&gt; starts working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried allowing the &lt;code&gt;xBlock&lt;/code&gt; to start within the &lt;code&gt;xBCD&lt;/code&gt; block (the opposite of what you tried) with appropriate use of &lt;code&gt;contains&lt;/code&gt;, because this is closer to how Vim would see it, but that failed too: I guess because regardless of whether Vim considers the &lt;code&gt;a&lt;/code&gt; or the &lt;code&gt;:&lt;/code&gt; to be the &quot;start&quot; of the match, neither is actually within the &lt;code&gt;xBCD&lt;/code&gt; region.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I therefore don't think it's possible to get this working using &lt;code&gt;\zs&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-02-26T11:11:51.550" LastActivityDate="2019-02-26T11:11:51.550" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18977" PostTypeId="2" ParentId="16108" CreationDate="2019-02-20T18:26:10.883" Score="3" Body="&lt;p&gt;This happened to me, and it was because I configured my colorscheme colors &lt;em&gt;after&lt;/em&gt; I actually set the colorscheme. Moving my &lt;code&gt;colorscheme&lt;/code&gt; command to a line after the actual color configuration solved my problem.&lt;/p&gt;&#xA;" OwnerUserId="21072" LastActivityDate="2019-02-20T18:26:10.883" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18978" PostTypeId="1" CreationDate="2019-02-20T19:58:59.770" Score="4" ViewCount="999" Body="&lt;p&gt;When running through a log file, I will catch a log that's bad, and I want to search around that line for other lines that will match search parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Frequently the log files are very long, and the words I'm searching for are bound to knock me out of my current context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to give the search a range, say 200 lines in any direction (directional would be nice too, only above/only below), so that my search is restricted to relevant context?&lt;/p&gt;&#xA;" OwnerUserId="21073" LastEditorUserId="11054" LastEditDate="2022-10-07T00:03:50.740" LastActivityDate="2022-10-07T09:36:44.973" Title="Search only within a relevant context (line range)?" Tags="|search|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18979" PostTypeId="2" ParentId="16575" CreationDate="2019-02-20T20:07:31.230" Score="3" Body="&lt;p&gt;I'm not on windows, but @root described in his answer, that you can copy formatted HTML to clipboard with the command &lt;code&gt;scb -as&lt;/code&gt; (that's what I understood).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following just collects @roots steps in a function. Put the following in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CopyFormatted(line1, line2)&#xA;    execute a:line1 . &quot;,&quot; . a:line2 . &quot;TOhtml&quot;&#xA;    %yank *&#xA;    !start /min powershell -noprofile &quot;gcb | scb -as&quot;&#xA;    bwipeout!&#xA;endfunction&#xA;&#xA;command! -range=% HtmlClip silent call CopyFormatted(&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then restart Vim and execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:HtmlClip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-21T18:38:52.847" LastActivityDate="2019-02-21T18:38:52.847" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="18980" PostTypeId="2" ParentId="18978" CreationDate="2019-02-21T09:15:56.733" Score="8" Body="&lt;p&gt;Just visually select the lines within which you want to search for the pattern, i.e. visually select those lines what you're referring to as &amp;quot;context&amp;quot;. Then get out of visual mode with &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;. Then search using &lt;code&gt;/%V&lt;em&gt;pattern&lt;/em&gt;&lt;/code&gt;, which will restrict the search to the most recent visual selection. For more info, see &lt;code&gt;:h /\%V&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; For even more info, read the whole &lt;code&gt;:h pattern.txt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2022-10-06T09:54:37.023" LastActivityDate="2022-10-06T09:54:37.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18981" PostTypeId="1" AcceptedAnswerId="18982" CreationDate="2019-02-21T10:02:42.090" Score="1" ViewCount="133" Body="&lt;p&gt;I am trying to write a wrapper shell script that is supposed to launch vim with a vimwiki in current directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;&#xA;gvim -c &quot;let g:vimwiki_list = [{'path': '$PWD/'}] | normal ,ww&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;normal&lt;/code&gt; command works (the comma is my custom remapped &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;), but it doesn't honor the custom &lt;code&gt;path&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To reproduce the problem, just run the above script somewhere not in home directory. At startup, vim will ask to create &lt;code&gt;~/vimwiki&lt;/code&gt; instead of using current working directory. Yet after I skip that question and do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo g:vimwiki_list&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in vim's command line, it displays the correct current directory. So it's not a problem of the correct value of &lt;strong&gt;$PWD&lt;/strong&gt; getting passed to vim, I use the bash variable inside double quotes so this part is fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to debug and eventually fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a customized g:vimwiki_list in my vimrc, but I also tried with defaults by commenting that part, the problem still persists (Is it true that settings passed via command line the way I did aren't overwritten by the ones hardcoded in vimrc anyway?).&lt;/p&gt;&#xA;" OwnerUserId="19475" LastActivityDate="2019-02-21T12:41:01.123" Title="Can't make vimwiki honor setting passed via command line" Tags="|linux|plugin-vimwiki|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18982" PostTypeId="2" ParentId="18981" CreationDate="2019-02-21T12:41:01.123" Score="3" Body="&lt;p&gt;The commands given with &lt;code&gt;-c&lt;/code&gt; are executed after the first file is loaded. I guess that at that time, vimwiki is already initialized and asked for creation of the directory &lt;code&gt;~/vimwiki&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;--cmd ...&lt;/code&gt;. This commands are executed &lt;em&gt;before&lt;/em&gt; &lt;code&gt;vimrc&lt;/code&gt; is loaded. So the variable should be set at the time vimwiki is initializing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Untested:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --cmd &quot;let g:vimwiki_list = [{'path': '$PWD/'}]&quot; -c &quot;normal ,ww&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;g:vimwiki_list&lt;/code&gt; is assigned before &lt;code&gt;vimrc&lt;/code&gt; is sourced and &lt;code&gt;,ww&lt;/code&gt; is executed after the first file was loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help --cmd&lt;/code&gt; and &lt;code&gt;:help -c&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-21T12:41:01.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18983" PostTypeId="1" CreationDate="2019-02-21T14:27:42.673" Score="2" ViewCount="100" Body="&lt;p&gt;My normal terminal color scheme is set via a color preset in iTerm. When I open a terminal window in Vim (&lt;code&gt;:terminal&lt;/code&gt;) that color scheme doesn't get applied, presumably because Vim has no knowledge of it and instead falls back to the settings in my &lt;code&gt;.bashrc&lt;/code&gt; file. Is there a way I can fix this and make the Vim terminal window use the same scheme as my normal terminal?&lt;/p&gt;&#xA;" OwnerUserId="21081" LastActivityDate="2019-02-21T14:27:42.673" Title="Using an iTerm color scheme inside a Vim :terminal window" Tags="|terminal|colorscheme|iterm2|color|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18984" PostTypeId="1" CreationDate="2019-02-21T15:29:13.110" Score="0" ViewCount="248" Body="&lt;p&gt;I'm trying to edit a file on a remote host using &lt;code&gt;vim scp://user@host//path/to/file&lt;/code&gt;&#xA;However, vim just displays &quot;Stopped&quot; and crashes.&#xA;Here is the log thats produces when I run &lt;code&gt;vim -V9 scp://user@host//path/to/file&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://pastebin.com/0Hk1Zx0Y&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pastebin.com/0Hk1Zx0Y&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21082" LastActivityDate="2019-02-21T15:29:13.110" Title="Editing file on remote host using scp not working" Tags="|netrw|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18985" PostTypeId="2" ParentId="778" CreationDate="2019-02-21T17:20:54.117" Score="7" Body="&lt;p&gt;If you just want to just use vimdiff without installing anything extra, &#xA;the following command will open all the differing files in succession &#xA;letting you look at the changes with vimdiff:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    for files in $(diff -rq dir1 dir2|grep 'differ$'|sed &quot;s/^Files //g;s/ differ$//g;s/ and /:/g&quot;); do &#xA;        vimdiff ${files%:*} ${files#*:}; &#xA;    done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21084" LastActivityDate="2019-02-21T17:20:54.117" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18986" PostTypeId="1" AcceptedAnswerId="18996" CreationDate="2019-02-21T17:56:23.157" Score="4" ViewCount="350" Body="&lt;p&gt;When I run this command in &lt;code&gt;ex&lt;/code&gt; mode it works without a problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call deoplete#custom#source('ultisnips', 'rank', 1000)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I put it in my vimrc I get an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /Users/me/config/nvim/plugins/deoplete.vim:&#xA;line   14:&#xA;E117: Unknown function: deoplete#custom#source&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have the deoplete plugin installed via a git submodule and deoplete works in vim.  I just can't use &lt;code&gt;call&lt;/code&gt; with any of its commands.  Am using Neovim 0.3.3.  I feel perhaps my init is being sourced before the plugin has finished loading but I am not sure how to go about sorting this out.&lt;/p&gt;&#xA;" OwnerUserId="21086" LastActivityDate="2019-02-22T19:58:55.097" Title="Command works in ex mode but not during init (call)" Tags="|vimrc|neovim|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18987" PostTypeId="2" ParentId="18986" CreationDate="2019-02-21T19:29:06.587" Score="2" Body="&lt;p&gt;You could try using the &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#VimEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;VimEnter&lt;/code&gt;&lt;/a&gt; autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup DeopleteOptions&#xA;   au!&#xA;   autocmd VimEnter * &#xA;   \ if exists('*deoplete#custom#source') | &#xA;   \     call deoplete#custom#source('ultisnips', 'rank', 1000) |&#xA;   \ endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;if&lt;/code&gt; avoids errors if you are running somewhere you don't have all your plugins installed.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2019-02-21T19:29:06.587" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18988" PostTypeId="1" CreationDate="2019-02-21T20:28:13.560" Score="0" ViewCount="46" Body="&lt;p&gt;How can I configure Vim and MacVim to respond to control-arrow and meta-{h,l} key-presses? The configuration below is ignored by both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using iTerm2 (version 3.2.7), Tmux (version 2.8), and Vim (version 8.1, patch 1-950).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Vimrc:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;Esc&amp;gt;[1;5D &amp;lt;C-Left&amp;gt;&#xA;map &amp;lt;Esc&amp;gt;[1;5C &amp;lt;C-Right&amp;gt;&#xA;nnoremap &amp;lt;C-S-Tab&amp;gt; :bprevious&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-Tab&amp;gt; :bnext&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-Left&amp;gt; :bprevious&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-Right&amp;gt; :bnext&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;M-h&amp;gt; :bprevious&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;M-l&amp;gt; :bnext&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11232" LastActivityDate="2019-02-21T20:28:13.560" Title="Mapping Buffer Movement" Tags="|vimrc|macvim|" AnswerCount="0" CommentCount="4" ClosedDate="2019-02-23T10:45:10.640" ContentLicense="CC BY-SA 4.0" />
  <row Id="18989" PostTypeId="2" ParentId="18058" CreationDate="2019-02-22T10:17:06.633" Score="0" Body="&lt;p&gt;According to @Luc Hermitte's answer, the correct version are&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap gb :NERDTree&amp;lt;CR&amp;gt;:exe 'OpenBookmark '.bookmark&amp;lt;Cr&amp;gt;&lt;/code&gt;&#xA;or&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap gb :NERDTree&amp;lt;CR&amp;gt;:exe &quot;OpenBookmark&quot; bookmark&amp;lt;Cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="15958" LastActivityDate="2019-02-22T10:17:06.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18990" PostTypeId="2" ParentId="17755" CreationDate="2019-02-22T10:28:38.413" Score="1" Body="&lt;p&gt;All the credits &lt;a href=&quot;https://redd.it/979lv2&quot; rel=&quot;nofollow noreferrer&quot;&gt;go&lt;/a&gt; to &lt;a href=&quot;https://www.reddit.com/user/tLaw101&quot; rel=&quot;nofollow noreferrer&quot;&gt;reddit user tLaw101&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! WinZoomToggle() abort&#xA;    if ! exists('w:WinZoomIsZoomed') &#xA;        let w:WinZoomIsZoomed = 0&#xA;    endif&#xA;    if w:WinZoomIsZoomed == 0&#xA;        let w:WinZoomOldWidth = winwidth(0)&#xA;        let w:WinZoomOldHeight = winheight(0)&#xA;        wincmd _&#xA;        wincmd |&#xA;        let w:WinZoomIsZoomed = 1&#xA;    elseif w:WinZoomIsZoomed == 1&#xA;        execute &quot;resize &quot; . w:WinZoomOldHeight&#xA;        execute &quot;vertical resize &quot; . w:WinZoomOldWidth&#xA;        let w:WinZoomIsZoomed = 0&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;wz :call WinZoomToggle()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5232" LastActivityDate="2019-02-22T10:28:38.413" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18991" PostTypeId="1" AcceptedAnswerId="18992" CreationDate="2019-02-22T15:12:29.807" Score="0" ViewCount="588" Body="&lt;p&gt;I want to make a Python &lt;code&gt;ftplugin&lt;/code&gt; (but other filetypes will also have this option) where, if the previous line has a comment that starts with &lt;code&gt;#&lt;/code&gt;, the next line can be commented via &lt;code&gt;&amp;lt;Shift&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, an insert-mode mapping (&lt;code&gt;inoremap&lt;/code&gt;). How can I code Vimscript so that it checks whether the current line is commented, and subsequently allows the &lt;code&gt;inoremap&lt;/code&gt; to make a new line commented?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And please don't recommend a third-party plugin like &lt;code&gt;NERD Commenter&lt;/code&gt; (which, btw, I respect very much), I want something as close to vanilla-Vim as possible for this.&lt;/p&gt;&#xA;" OwnerUserId="20750" LastActivityDate="2019-02-22T15:27:24.763" Title="How can I make Vimscript check if the current line has a comment?" Tags="|vimscript|neovim|comments|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18992" PostTypeId="2" ParentId="18991" CreationDate="2019-02-22T15:27:24.763" Score="4" Body="&lt;p&gt;To check if the current line is commented, you can use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo synIDattr(synIDtrans(synID(line(&quot;.&quot;), col(&quot;$&quot;)-1, 1)), &quot;name&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This checks, if the current line ends with a comment syntax item.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt;&amp;lt;silent&amp;gt; &amp;lt;f6&amp;gt; synIDattr(synID(line('.')-1, strlen(getline(line('.')-1)), 1),'name')=~?'comment'?'#':' '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this maps the &lt;kbd&gt;F6&lt;/kbd&gt; key to check if the syntax group from the end of the previous line matches &lt;code&gt;comment&lt;/code&gt; and if so returns the comment character &lt;code&gt;#&lt;/code&gt;, else it will simply return a &lt;kbd&gt;Space&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-02-22T15:27:24.763" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18993" PostTypeId="2" ParentId="17755" CreationDate="2019-02-22T15:47:46.167" Score="4" Body="&lt;p&gt;I use &lt;code&gt;ctrl-w |&lt;/code&gt; if my screen is split vertically or &lt;code&gt;ctrl-w _&lt;/code&gt; if split horizontally to zoom in. To get back, I use &lt;code&gt;ctrl-w =&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="20775" LastActivityDate="2019-02-22T15:47:46.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18994" PostTypeId="1" AcceptedAnswerId="18995" CreationDate="2019-02-22T17:55:16.737" Score="4" ViewCount="1479" Body="&lt;p&gt;I would like to remapping some of the default keys, where I can find all the command name list used by vim?&lt;/p&gt;&#xA;" OwnerUserId="15958" LastActivityDate="2019-02-22T19:26:17.470" Title="Where is the command list for the default keys?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18995" PostTypeId="2" ParentId="18994" CreationDate="2019-02-22T19:26:17.470" Score="8" Body="&lt;p&gt;you find a complete list under &lt;code&gt;:help normal-index&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a &lt;code&gt;insert-index&lt;/code&gt;, &lt;code&gt;visual-index&lt;/code&gt; and &lt;code&gt;ex-edit-index&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2019-02-22T19:26:17.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18996" PostTypeId="2" ParentId="18986" CreationDate="2019-02-22T19:58:55.097" Score="1" Body="&lt;p&gt;According to the OP, the plugin directory is located inside the &lt;code&gt;'packpath'&lt;/code&gt;, which means the plugin is not available until &lt;em&gt;after&lt;/em&gt; the vimrc is processed:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;When Vim starts up, after processing your .vimrc, it scans all directories in&#xA;'packpath' for plugins under the &quot;pack/*/start&quot; directory.  First all those&#xA;directories are added to 'runtimepath'.  Then all the plugins are loaded.&#xA;See |packload-two-steps| for how these two steps can be useful.&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;Note that the files under &quot;pack/foo/opt&quot; are not loaded automatically, only the&#xA;ones under &quot;pack/foo/start&quot;.  See |pack-add| below for how the &quot;opt&quot; directory&#xA;is used.&#xA;Loading packages automatically will not happen if loading plugins is disabled,&#xA;see |load-plugins|.&#xA;To load packages earlier, so that 'runtimepath' gets updated: &gt;&#xA;    :packloadall&#xA;This also works when loading plugins is disabled.  The automatic loading will&#xA;only happen once.&#xA;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;(&lt;code&gt;:help packages&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;While the help system mentions using &lt;code&gt;:packloadall&lt;/code&gt; to load packages earlier, I offer an alternative suggestion: the &lt;code&gt;after&lt;/code&gt; directory. By the time after files load, packages have been loaded. In &lt;a href=&quot;https://github.com/benknoble/Dotfiles/tree/master/links/vim/after/plugin/config&quot; rel=&quot;nofollow noreferrer&quot;&gt;my own Dotfiles&lt;/a&gt;, I keep a directory &lt;code&gt;~/.vim/after/plugin/config/&lt;/code&gt;&lt;sup&gt;1&lt;/sup&gt; with short files to customize my plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, my config for ale is in &lt;code&gt;~/.vim/after/plugin/config/ale.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ! exists(':ALEInfo')&#xA;  finish&#xA;endif&#xA;&#xA;let g:ale_set_signs = 0&#xA;&#xA;let g:ale_linters = {&#xA;      \ 'python': 'all',&#xA;      \ 'java': [],&#xA;      \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The trick is generally to find a reliable way of testing for the presence of the plugin: when they define commands or &quot;skip&quot; variables (e.g. &lt;code&gt;g:loaded_{name}&lt;/code&gt;), we can test those. Autoload'ed functions (&lt;code&gt;file#name&lt;/code&gt;) are harder because they don't exist until they are used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, I'd use &lt;a href=&quot;https://github.com/Shougo/deoplete.nvim/blob/master/plugin/deoplete.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g:loaded_deoplete&lt;/code&gt;&lt;/a&gt; in a file like &lt;code&gt;~/.vim/after/plugin/config/deoplete.vim&lt;/code&gt; (use the equivalent for neovim):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ! exists('g:loaded_deoplete')&#xA;  finish&#xA;endif&#xA;&#xA;&quot; your custom code here&#xA;call deoplete#custom#source('ultisnips', 'rank', 1000)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The name &lt;code&gt;plugin&lt;/code&gt; does not mean &lt;em&gt;plugin&lt;/em&gt; as a set of code from GitHub or elsewhere, but rather a plugin script (cf. &lt;code&gt;:help plugin&lt;/code&gt;). The name &lt;code&gt;config&lt;/code&gt; is not significant except that it helps me organize my &lt;code&gt;after/plugin&lt;/code&gt; directory: all the configuration lies there. Note that all subdirectories of a plugin directory are searched for scripts.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-02-22T19:58:55.097" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="18997" PostTypeId="2" ParentId="18884" CreationDate="2019-02-22T20:23:45.957" Score="1" Body="&lt;p&gt;Controlling an external program from vim is just like controlling an external program from many other unix utilities: we lean on the mechanisms provided to us in the shell, who specializes in external programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each of the following methods requires that we could, should we want, manipulate our program from the command line (shell). Most well-behaved unix utilities exhibit this feature, and many are scriptable (I used to have an &lt;code&gt;itunes&lt;/code&gt; control script lying around, before I realized I didn't use it in favor of my Mac's keyboard).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first step is, therefore, to ensure there is some external command (be it a script you write or the executable utility from the program) that can control your audio program. Make sure it is in your &lt;code&gt;$PATH&lt;/code&gt;, and that you can run it from a shell. You'll probably want to consult its documentation and get quite familiar with it.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Method 1: Bang&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:!&lt;/code&gt; command is a handy &quot;shell-out&quot; to run an external program. It uses the shell (typically in non-interactive mode, though one can adjust &lt;code&gt;'shell'&lt;/code&gt; and &lt;code&gt;'shellcmdflag'&lt;/code&gt;) to execute the following command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command has its peculiarities; a glance at the docs comes highly recommended. For simple usage, it tends to work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your command has no output, you can even &lt;code&gt;:silent !cmd&lt;/code&gt; to avoid the hit-enter prompt.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Method 2: Background&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Vim plays well with job-control in the shell, meaning standard signals like &lt;kbd&gt;Ctrl-Z&lt;/kbd&gt; and &lt;code&gt;fg&lt;/code&gt; work. Vim also provides the &lt;code&gt;:suspend&lt;/code&gt; command, though I prefer my mapping &lt;code&gt;&amp;lt;Leader&amp;gt;z&lt;/code&gt; for the same effect. The idea here is to get back to a terminal, run some commands, and come back to vim when ready.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Method 3: New Shell&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Vim has a command called &lt;code&gt;:shell&lt;/code&gt; which spawns a shell as a subprocess of vim; one can easily run commands here as well.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;3a: Terminal&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim, as of version 8.1, ships with the &lt;code&gt;:terminal&lt;/code&gt; command, opening a terminal inside your vim instance for minimal distraction. Combined with &lt;code&gt;tmux&lt;/code&gt; or similar, this can be a powerful multi-tasking tool.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Results&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Because vim provides so many different ways to execute external commands, I recommend you experiment with the ones that work best for you in a given situation. I like &lt;code&gt;:terminal&lt;/code&gt; for running interpreters/quick processes, &lt;code&gt;tmux&lt;/code&gt; for shells, and &lt;code&gt;!&lt;/code&gt; for when I &lt;em&gt;know&lt;/em&gt; I'm not going to need to run more than one command. My &lt;code&gt;&amp;lt;Leader&amp;gt;z&lt;/code&gt; map also sees heavy usage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best part, though, is that you can create mappings for these! If your command (possibly a script) is called &lt;code&gt;audio-control&lt;/code&gt;, you could:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;a :!audio-control&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, if it has subcommands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;aa :!audio-control&#xA;nnoremap &amp;lt;Leader&amp;gt;ap :!audio-control play-toggle&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&amp;amp;c. The list goes on and on...&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-02-22T20:23:45.957" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18999" PostTypeId="1" CreationDate="2019-02-24T06:46:36.637" Score="2" ViewCount="41" Body="&lt;p&gt;In vim, when I operate on a textobject from a plugin, say the 'inner indent' typed &lt;code&gt;ii&lt;/code&gt; from kana/vim-textobj-indent, my last visual selection (&lt;code&gt;'&amp;gt;&lt;/code&gt;, &lt;code&gt;'&amp;lt;&lt;/code&gt;) is reset to where the operator worked on. That is usually quite useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this is not the case with built-in textobjects like &lt;code&gt;is&lt;/code&gt; (inner sentence), &lt;code&gt;ap&lt;/code&gt; (a paragraph), etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the 'last visual selection' is a useful thing to keep i.m.o., and there already are markers for 'last operator-pending opfunc range' (&lt;code&gt;'[&lt;/code&gt;, &lt;code&gt;']&lt;/code&gt;), is there a way to achieve consistency in this behavior, to keep the visual range markers untouched by ranges or movements that were used by operators?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes on the intended scope of the question:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I am aware of the 'usual way' of implementing a textobject: &lt;code&gt;omap :&amp;lt;C-u&amp;gt;exec &quot;normal! &amp;lt;do-something-with-visual-selection-here&amp;gt;&quot;&lt;/code&gt;. Every textobject in existence seems to base on &lt;code&gt;kana/vim-textobj-user&lt;/code&gt;. Could a possibility lie in changing how that library implements textobjects? One could maintain a forked version of that plugin.&lt;/li&gt;&#xA;&lt;li&gt;Not-quite-that-big workarounds would be preferred, however :)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thank you for your insights!&lt;/p&gt;&#xA;" OwnerUserId="17075" LastEditorUserId="17075" LastEditDate="2019-02-24T07:43:18.303" LastActivityDate="2019-02-24T07:43:18.303" Title="Do operator ranges/movements/textobjects always overwrite the last visual selection? workaround?" Tags="|visual-mode|custom-text-object|map-operator|plugin-textobj-user|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19000" PostTypeId="1" CreationDate="2019-02-24T09:31:52.480" Score="1" ViewCount="795" Body="&lt;p&gt;I need to set cursor position when &lt;em&gt;opening&lt;/em&gt; quickfix window. I have tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter * call cursor(2, 2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't set cursor for quickfix buffer immediately after I have opened it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPD: I am trying to save current cursor position of quickfix window when close it and restore when open again.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:saved_cursor = [0, 1, 1]&#xA;autocmd BufDelete * call s:SaveCursor()&#xA;autocmd BufWinEnter quickfix call s:RestoreCursor()&#xA;&#xA;func s:SaveCursor()&#xA;    if expand(&quot;&amp;lt;abuf&amp;gt;&quot;) == s:get_qf_bufnr()&#xA;        let s:saved_cursor = getpos('.')&#xA;    endif&#xA;endfunc&#xA;&#xA;func s:RestoreCursor()&#xA;    call cursor(s:saved_cursor[1], s:saved_cursor[2])&#xA;endfunc&#xA;&#xA;func s:get_qf_bufnr()&#xA;    for buf_i in getbufinfo()&#xA;        if getbufvar(buf_i.bufnr, '&amp;amp;buftype') == 'quickfix'&#xA;            return buf_i.bufnr&#xA;        endif&#xA;    endfor&#xA;    return -1&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't work.&#xA;Scenario is below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Open and fill quickfix buffer by &lt;code&gt;cs find&lt;/code&gt; command&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Move cursor in quickfix window&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Close quickfix window by &lt;code&gt;:cclose&lt;/code&gt; (and save cursor position by &lt;code&gt;s:SaveCursor()&lt;/code&gt; function)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Open quickfix again by &lt;code&gt;:copen&lt;/code&gt; (and restore cursor position by &lt;code&gt;s:RestoreCursor()&lt;/code&gt; function)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably &lt;code&gt;BufWinEnter autocmd&lt;/code&gt; event is not suitable for my purpose and I am trying to set cursor before quickfix window opened.&#xA;On &lt;code&gt;BufEnter&lt;/code&gt; event I can set cursor position if quickfix window is already opened. But if I close quickfix window and open it again cursor will be at first line first column. &lt;/p&gt;&#xA;" OwnerUserId="20634" LastEditorUserId="20634" LastEditDate="2019-02-24T18:32:06.467" LastActivityDate="2022-07-09T16:08:15.800" Title="Set cursor in quickfix on autocmd event" Tags="|vimscript|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19001" PostTypeId="2" ParentId="19000" CreationDate="2019-02-24T13:45:55.053" Score="0" Body="&lt;p&gt;Put this in your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup quickfix&#xA;    autocmd!&#xA;    autocmd QuickFixCmdPost [^l]* nested cwindow&#xA;    autocmd QuickFixCmdPost    l* nested lwindow&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h QuickFixCmdPost&lt;/code&gt;, this autocommand event is triggered after a quickfix command is run. And &lt;code&gt;[^l]*&lt;/code&gt; makes sure that the quickfix command is not actually a location list command. From &lt;code&gt;:h location-list&lt;/code&gt;, a location list is a window-local quickfix list, and to create a location list window, you'll just have to put an &lt;code&gt;l&lt;/code&gt; at the beginning of the equivalent quickfix command. So, depending on whether the command has &lt;code&gt;l&lt;/code&gt; at the beginning, the quickfix or location-list window is opened.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-02-24T17:05:43.777" LastActivityDate="2019-02-24T17:05:43.777" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19002" PostTypeId="1" CreationDate="2019-02-24T16:27:56.797" Score="0" ViewCount="47" Body="&lt;p&gt;I installed gruvbox color-scheme. Then I did :ls and saw this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/JF4k2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JF4k2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After &quot;.vimrc&quot; there's some black stuff. It is kind of ugly and makes it harder to read. Is there any way to fix this?&lt;/p&gt;&#xA;" OwnerUserId="21104" LastActivityDate="2019-02-24T16:27:56.797" Title="Ugly black thing when using :ls with colorscheme" Tags="|colorscheme|" AnswerCount="0" CommentCount="8" ClosedDate="2019-02-24T18:43:14.320" ContentLicense="CC BY-SA 4.0" />
  <row Id="19003" PostTypeId="1" AcceptedAnswerId="19004" CreationDate="2019-02-24T17:01:11.560" Score="2" ViewCount="2335" Body="&lt;p&gt;I want to be able to hit a single key to see the netrw buffer for the directory of the file I'm in. Rex will handily move your cursor to where it was previously, but only works if you opened the file from netrw, and breaks when you reopen a session.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! OpenExplorer()&#xA;    try&#xA;        silent! :Rex&#xA;    catch&#xA;        :Ex&#xA;    endtry&#xA;endfu&#xA;&#xA;nno - :call OpenExplorer()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought I could do this with a try catch, but this code still opens a minibuffer saying &lt;code&gt;**warning** (netrw) win#1 not a former netrw window&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could write some more elaborate solution or roll my own Rex, but why doesn't this work?&lt;/p&gt;&#xA;" OwnerUserId="8483" LastActivityDate="2021-04-03T23:32:26.637" Title="try catch with :Rexplore" Tags="|vimscript|netrw|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19004" PostTypeId="2" ParentId="19003" CreationDate="2019-02-24T18:35:19.593" Score="2" Body="&lt;p&gt;Well, &lt;code&gt;:silent!&lt;/code&gt; suppresses errors and neutralizes exceptions. If the &lt;code&gt;netrw&lt;/code&gt; code is indeed throwing exceptions (see below) then removing it, or at least dropping the &lt;code&gt;!&lt;/code&gt;, should clear things up. (Note: I'm interpreting what you said about that error message you saw as if that occurred in a later/different context than this code with &lt;code&gt;:silent!&lt;/code&gt;. Accurate?) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need &lt;code&gt;:silent!&lt;/code&gt; for some other reason you could check for failure by checking whether the variable &lt;code&gt;v:errmsg&lt;/code&gt; is non-empty/non-null. With the code below we will see &lt;code&gt;v:errmsg is bzzzt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! DoError()&#xA;    echoerr(&quot;bzzzt&quot;)&#xA;endfunc&#xA;&#xA;func! HandleError()&#xA;    echom(&quot;got it&quot;)&#xA;endfunc&#xA;&#xA;func! ErrmsgTest()&#xA;    try&#xA;        let v:errmsg = &quot;&quot;&#xA;        silent! :call DoError()&#xA;        echom(&quot;v:errmsg is &quot; . v:errmsg)&#xA;    catch&#xA;        call HandleError()&#xA;    endtry&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; saw some netrw documentation that says &quot;messages from netrw will use echoerr&quot; so the evidence indicates you can solve your issue by removing &lt;code&gt;:silent!&lt;/code&gt; or using &lt;code&gt;v:errmsg&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; Well, silly me, believing the documentation is accurate. My findings after a deeper dive...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a flag &lt;code&gt;g:netrw_use_errorwindow&lt;/code&gt; that when set to 0 (as OP has tried) is supposed to result in, per the docs: &lt;em&gt;messages from netrw will use &lt;strong&gt;echoerr&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But at the point in the code where the flag comes into play a comment says &lt;em&gt;netrw will show messages using &lt;strong&gt;echomsg&lt;/strong&gt;&lt;/em&gt;, completely contradicting the docs. And indeed &lt;code&gt;echomsg&lt;/code&gt; is used there not &lt;code&gt;echoerr&lt;/code&gt;. On top of that I initially overlooked that the message is a &lt;em&gt;warning&lt;/em&gt; and rarely will you find exceptions thrown as a result of a warning condition (at least not in quality code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically there's nothing you can do to &lt;em&gt;directly&lt;/em&gt; detect this state. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about a hack? One that comes to mind is to see if the message in question shows up in the message history. You could do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mess clear&#xA;Rex&#xA;if match(execute(&quot;1mess&quot;), &quot;not a former netrw window&quot;) &amp;gt;= 0&#xA;    Ex  &quot; or whatever you want to do to handle the warn state&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Like I said, &lt;em&gt;hack&lt;/em&gt;, but it should work if there's nothing else going on in parallel that can add to message history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, the key &lt;code&gt;echomsg&lt;/code&gt; in the netrw code is preceded by &lt;code&gt;unsilent&lt;/code&gt; which explains why you're seeing the warning despite &lt;code&gt;silent&lt;/code&gt;. (&lt;code&gt;unsilent&lt;/code&gt; nullifes the message suppression caused by any &lt;code&gt;silent&lt;/code&gt; command set in the surrounding code.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-02-25T00:10:51.533" LastActivityDate="2019-02-25T00:10:51.533" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19005" PostTypeId="2" ParentId="19000" CreationDate="2019-02-24T19:24:28.027" Score="1" Body="&lt;p&gt;From the source code it looks like the position in the quickfix window is determined by the current position in the quickfix list. This is set after the window was opened, hence after your autocmd ran.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you need the autocmd event &lt;code&gt;BufLeave&lt;/code&gt;, to save the cursor position (the quickfix buffer is not deleted). Then change your function &lt;code&gt;s:RestoreCursor&lt;/code&gt; to contain:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call cursor(g:saved_cursor[0], g:saved_cursor[1])&#xA;echom &quot;My Pos: &quot; . string(getpos('.'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should print the cursor position you want to restore. But in the end the cursor ends up on the line corresponding to the current position in the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea how to prevent this.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-24T19:24:28.027" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19006" PostTypeId="1" AcceptedAnswerId="19009" CreationDate="2019-02-24T22:50:34.307" Score="3" ViewCount="2593" Body="&lt;p&gt;I want to add a config line to my &lt;code&gt;.vimrc&lt;/code&gt; so that when I select a grouping of lines in visual mode I can easily call &lt;code&gt;:norm i#&lt;/code&gt; and &lt;code&gt;norm x&lt;/code&gt; on them (to comment/ uncomment in python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The desired workflow would be visually highlight multiple lines and then press a key to comment/ uncomment them all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking of adding something like &lt;code&gt;map # :norm i#&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt; but clearly this isn't the correct syntax. I'm new to vim so not super familiar with &lt;code&gt;map&lt;/code&gt; vs &lt;code&gt;noremap&lt;/code&gt; etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: I'm aware of this question, but this is not the implementation I'm looking for &lt;a href=&quot;https://vi.stackexchange.com/questions/5286/making-a-custom-function-to-comment-out-a-range-of-lines?rq=1&quot;&gt;Making a custom function to comment out a range of lines&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21123" LastActivityDate="2019-02-25T20:47:36.137" Title="How to map key to command-line mode command" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19007" PostTypeId="1" AcceptedAnswerId="19008" CreationDate="2019-02-24T22:53:14.060" Score="3" ViewCount="3744" Body="&lt;p&gt;I need to write a function that returns current visually selected text or &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; on mapping. Result of this function I give further to &lt;code&gt;cscope find s&lt;/code&gt; command. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C-\&amp;gt;s :call &amp;lt;SID&amp;gt;Run_cscope(&amp;lt;SID&amp;gt;get_vselect_or_cword())&amp;lt;CR&amp;gt;&#xA;&#xA;func s:Run_cscope(pattern)&#xA;  exe 'cs find s ' . a:pattern&#xA;endfunc&#xA;&#xA;func s:get_vselect_or_cword()&#xA;  let vselect = s:get_visual_selection()&#xA;  if vselect != ''&#xA;    let pattern = vselect&#xA;  else&#xA;    let pattern = expand(&quot;&amp;lt;cword&amp;gt;&quot;)&#xA;  endif&#xA;  return pattern&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The question is how to write &lt;code&gt;get_visual_selection()&lt;/code&gt; function? Another words how to get &lt;strong&gt;current&lt;/strong&gt; visually selected text? I have found some solutions in &lt;a href=&quot;https://stackoverflow.com/questions/1533565/how-to-get-visually-selected-text-in-vimscript&quot;&gt;this question&lt;/a&gt; but all of them are not appropriate because &lt;code&gt;get_visual_selection()&lt;/code&gt; returns previous visually selected text if nothing selected. I need that it returns &lt;code&gt;''&lt;/code&gt; in this case. It seems that solution should be very easy, but I don't really experienced in vimscript and just not see it.&lt;/p&gt;&#xA;" OwnerUserId="20634" LastActivityDate="2019-02-24T23:33:06.480" Title="Get current visually selected text" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19008" PostTypeId="2" ParentId="19007" CreationDate="2019-02-24T23:33:06.480" Score="3" Body="&lt;p&gt;The main problem is that, once you're in a mapping that is &lt;code&gt;:call&lt;/code&gt;ing a function, you're &lt;em&gt;no longer in visual mode&lt;/em&gt;, so there's no such thing as the &lt;em&gt;current&lt;/em&gt; visual selection in that case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good approach here is to install separate mappings for normal (&lt;code&gt;:nnoremap&lt;/code&gt;) and visual (&lt;code&gt;:vnoremap&lt;/code&gt;) modes. You can still call the same function from both, just pass an argument so you know whether you're coming from normal mode (in which case you'll want to look at &lt;code&gt;expand(&quot;&amp;lt;cword&amp;gt;&quot;)&lt;/code&gt;) or from visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When coming from visual mode, it's possible you were in characterwise, linewise or blockwise mode and the selection might need to be handled differently for each case. You can use the &lt;code&gt;visualmode()&lt;/code&gt; function to determine which mode you were on (and possibly pass that as the argument in your &lt;code&gt;:vnoremap&lt;/code&gt; mapping.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're in characterwise visual mode, you can capture it with a command such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal! `&amp;lt;v`&amp;gt;y&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then access the contents in Vimscript from register &lt;code&gt;@@&lt;/code&gt;. (You might want to save and restore this register at the start/end of your function.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an excellent tutorial explaining all these concepts, see &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/33.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Case Study: Grep Operator&lt;/a&gt; from the amazing &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; by Steve Losh. (Seriously, if you haven't read it yet, do so, it's really awesome!)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-02-24T23:33:06.480" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19009" PostTypeId="2" ParentId="19006" CreationDate="2019-02-25T02:59:20.300" Score="3" Body="&lt;p&gt;This base action can be a single command like &lt;code&gt;'&amp;lt;,'&amp;gt;s/^\s*\zs\(\S\)/#\1&lt;/code&gt;. Or, in a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Insert Python comment char # before first non-whitespace char&#xA;&quot; for all Visually selected lines&#xA;func! PyComment()&#xA;    '&amp;lt;,'&amp;gt;s/^\s*\zs\(\S\)/#\1&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can see how you might run into a few gotchas, though, getting this to run by way of a mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Tricky part #1: Which mapping command?&lt;/em&gt; So you want this to be available when lines are visually selected. That means &lt;code&gt;:vmap&lt;/code&gt;. Or more accurately it means &lt;code&gt;:vnoremap&lt;/code&gt;. Always use the &quot;noremap&quot; variants until you know enough about mappings to recognize a reason to do otherwise. (There are very few circumstances where it comes into play.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Tricky part #2: What are those weird characters on the command line?&lt;/em&gt; When you enter the command line to, say, call a function while you're in Visual mode, vim will prepopulate it with &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt;. That is the range of lines covered by the Visual selection. This will also happen behind the scenes when we do the same thing as part of a mapping. Well we don't want that, we're handling the range in our function, so the first thing to do is hit &lt;code&gt;Ctrl-U&lt;/code&gt; (delete from cursor to beginning of line) or, in mapping speak, add &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Tricky part #3: How do I call a function?&lt;/em&gt; Well, this isn't really &quot;tricky&quot; but not everyone knows that user functions must be called with &lt;code&gt;:call&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Tricky part #4: It doesn't do anything?&lt;/em&gt; As DBK suggested in his comment it's common for people to forget that the mapping must include the carriage return that submits everything for execution. So make the last thing you add to the mapping &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That gives us&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap X :&amp;lt;C-U&amp;gt;call PyComment()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Where &lt;code&gt;X&lt;/code&gt; is whatever key(s) you want to use for the mapping.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-02-25T20:47:36.137" LastActivityDate="2019-02-25T20:47:36.137" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19010" PostTypeId="2" ParentId="9366" CreationDate="2019-02-25T06:32:27.337" Score="10" Body="&lt;p&gt;When &lt;code&gt;vim&lt;/code&gt; starts, it runs &lt;code&gt;$VIMRUNTIME/ftdetect.vim&lt;/code&gt; to find out what type of file you're editing; then, if you have &lt;code&gt;'ftplugin'&lt;/code&gt; set, it sources &lt;code&gt;$VIMRUNTIME/ftplugin.vim&lt;/code&gt; which sources &lt;code&gt;$VIMRUNTIME/ftplugin/&amp;amp;filetype.vim&lt;/code&gt; (see &lt;code&gt;:help startup&lt;/code&gt; for more detail).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can alter or override &lt;code&gt;$VIMRUNTIME/ftplugin.vim&lt;/code&gt; or &lt;code&gt;$VIMRUNTIME/ftplugin/&amp;amp;filetype.vim&lt;/code&gt;. Create a folder and subfolder in your home directory called &lt;code&gt;.vim/after&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to override formatoptions for all filetype plugins, edit &lt;code&gt;$HOME/.vim/after/ftplugin.vim&lt;/code&gt;, otherwise edit &lt;code&gt;$HOME/.vim/after/ftplugin/lua.vim&lt;/code&gt; (or replace &lt;code&gt;lua&lt;/code&gt; with whichever language - in your case it's &lt;code&gt;vim&lt;/code&gt;). For a proper explanation of how this works, see &lt;code&gt;:help 'runtimepath'&lt;/code&gt; (and &lt;code&gt;:help :runtime&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the following content in the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set formatoptions-=o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see whether it's worked by running &lt;code&gt;:scriptnames&lt;/code&gt;. You should get a list like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: H:\script\vim\vimrc&#xA;  2: H:\script\vim\syntax\syntax.vim&#xA;  3: H:\script\vim\syntax\synload.vim&#xA;  4: H:\script\vim\syntax\syncolor.vim&#xA;  5: H:\script\vim\filetype.vim&#xA;  6: ~\vimfiles\ftdetect\log.vim&#xA;  7: ~\vimfiles\ftdetect\rdp.vim&#xA;  8: ~\vimfiles\ftdetect\scratch.vim&#xA;  9: ~\vimfiles\ftdetect\sqlite.vim&#xA; 10: ~\vimfiles\ftdetect\todo.vim&#xA; 11: H:\script\vim\ftplugin.vim&#xA; 12: ~\vimfiles\after\ftplugin.vim&#xA; 13: ~\vimfiles\colors\desert.vim&#xA; 14: H:\script\vim\defaults.vim&#xA; 15: H:\script\vim\plugin\getscriptPlugin.vim&#xA; 16: H:\script\vim\plugin\gzip.vim&#xA; 17: H:\script\vim\plugin\logiPat.vim&#xA; 18: H:\script\vim\plugin\manpager.vim&#xA; 19: H:\script\vim\plugin\matchparen.vim&#xA; 20: H:\script\vim\plugin\netrwPlugin.vim&#xA; 21: H:\script\vim\plugin\rrhelper.vim&#xA; 22: H:\script\vim\plugin\spellfile.vim&#xA; 23: H:\script\vim\plugin\tarPlugin.vim&#xA; 24: H:\script\vim\plugin\tohtml.vim&#xA; 25: H:\script\vim\plugin\vimballPlugin.vim&#xA; 26: H:\script\vim\plugin\zipPlugin.vim&#xA; 27: H:\script\vim\syntax\lua.vim&#xA; 28: H:\script\vim\ftplugin\lua.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note lines 11 and 12. Your file paths will look a bit different.&lt;/p&gt;&#xA;" OwnerUserId="21127" LastEditorUserId="-1" LastEditDate="2019-06-06T10:21:01.000" LastActivityDate="2019-06-06T10:21:01.000" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19011" PostTypeId="1" CreationDate="2019-02-25T09:36:06.863" Score="1" ViewCount="866" Body="&lt;p&gt;Using following .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Just to see tab/spaces/endline clearly:&#xA;set encoding=utf-8&#xA;set list&#xA;set listchars=tab:▸\ ,eol:¬&#xA;nnoremap &amp;lt;F5&amp;gt; :set list!&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; Tab to spaces settings&#xA;set tabstop=4&#xA;set softtabstop=4&#xA;set shiftwidth=4&#xA;set shiftround&#xA;set expandtab&#xA;&#xA;&quot; paste and pastetoggle settings&#xA;set nopaste&#xA;set pastetoggle=&amp;lt;F2&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now open a test-file and type following:  &lt;code&gt;i&amp;lt;TAB&amp;gt;&amp;lt;F2&amp;gt;&amp;lt;TAB&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;go to insert mode&lt;/li&gt;&#xA;&lt;li&gt;TAB   =&gt; gives space&lt;/li&gt;&#xA;&lt;li&gt; to insert-paste mode&lt;/li&gt;&#xA;&lt;li&gt;TAB   =&gt; gives TAB but i would like spaces&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is it possible to have spaces in the insert-paste mode or do I really have to leave PASTE mode each time again? I just like to stay in paste mode as i copy-paste a lot of snippets constantly from other terminals.&lt;/p&gt;&#xA;" OwnerUserId="2715" LastEditorUserId="2715" LastEditDate="2019-02-27T03:03:24.547" LastActivityDate="2024-01-23T13:54:21.857" Title="tabs after pastetoggle instead of spaces" Tags="|vimrc|tab-characters|paste|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19012" PostTypeId="2" ParentId="19011" CreationDate="2019-02-25T09:58:31.367" Score="2" Body="&lt;p&gt;Yes, you have to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it easier, you could add the following snippet to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set pastetoggle=&amp;lt;F9&amp;gt;&#xA;noremap  &amp;lt;F9&amp;gt;   :set invpaste paste?&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;F9&amp;gt;   &amp;lt;C-O&amp;gt;:set invpaste&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This toggles paste mode by simply hitting &lt;kbd&gt;F9&lt;/kbd&gt;. This works in normal mode and  insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you like to use another key, just change &lt;code&gt;&amp;lt;F9&amp;gt;&lt;/code&gt; to something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: The setting &lt;code&gt;pastetoggle&lt;/code&gt; defines a key that should NOT be inserted in the text, but handled normally by Vim. Without this setting, Vim would just insert &lt;code&gt;&amp;lt;F9&amp;gt;&lt;/code&gt; in the text if you hit &lt;kbd&gt;F9&lt;/kbd&gt; while in insert mode.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-25T09:58:31.367" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19013" PostTypeId="2" ParentId="12849" CreationDate="2019-02-25T12:52:39.213" Score="8" Body="&lt;p&gt;There is also a function to go to a specific line and column:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call cursor(row, col)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21133" LastEditorUserId="51" LastEditDate="2019-02-26T01:33:00.100" LastActivityDate="2019-02-26T01:33:00.100" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19014" PostTypeId="1" CreationDate="2019-02-25T17:32:47.677" Score="0" ViewCount="17" Body="&lt;p&gt;I'm trying to get in to plugin writing, and currently I'm doing some builds (like Latex and LanguageTools checker), and I have in place hotkeys that call for the compilation, and It throws the output message (text streams) in a split term buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to do is to have special rules for the navigation of the output, similar to when linters, reference a line, and by entering that line you jump in to the file/line in question. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do that should I introduce a new filetype? or is this something? or how should I approach this? &lt;/p&gt;&#xA;" OwnerUserId="19307" LastActivityDate="2019-02-25T17:32:47.677" Title="How can I reproduce a Linting Plugin Behavior" Tags="|filetype|terminal-buffer|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19015" PostTypeId="1" AcceptedAnswerId="19019" CreationDate="2019-02-25T17:44:49.803" Score="0" ViewCount="123" Body="&lt;p&gt;There are many build targets in the project, I would like to create a command, for example &lt;strong&gt;BuildFor&lt;/strong&gt;. The idear is, the alternative parameter will present one by one while keep pressing the Tab key after entering the  command in Vim's command line window. Each predefined parameter represents one building target which will eventually be constructed as a ninja/GNU Build within the function that is called by the &lt;strong&gt;BuildFor&lt;/strong&gt; command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I create a sort of enum to save all those options for the &lt;strong&gt;BuildFor&lt;/strong&gt; command and make them presented by tapping Tab key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any better build integration suggestions for Vim you know that is better than this, I would be very appreciate you can share.&lt;/p&gt;&#xA;" OwnerUserId="15958" LastEditorUserId="15958" LastEditDate="2019-02-25T17:49:53.020" LastActivityDate="2019-02-26T09:42:54.073" Title="How to create a enum for command parameters for build integration" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19016" PostTypeId="2" ParentId="19003" CreationDate="2019-02-25T19:36:21.193" Score="0" Body="&lt;p&gt;Since try catch doesn't work, I just used this workaround instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! OpenExplorer()&#xA;    let g:netrw_use_errorwindow = 0&#xA;    Rex&#xA;    if &amp;amp;ft != 'netrw'&#xA;        Ex&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's a little ugly that it changes the error window variable, but I kinda find that way of showing the user an error message lame anyway, so I don't mind ensuring it is set. If you didn't want that, you could run quit after the netrw ft check to close the error window instead.&lt;/p&gt;&#xA;" OwnerUserId="8483" LastActivityDate="2019-02-25T19:36:21.193" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19017" PostTypeId="1" CreationDate="2019-02-25T20:08:16.447" Score="1" ViewCount="242" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TnSPf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TnSPf.png&quot; alt=&quot;Symbols and line numbering problem&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an issue as the image shows where the linting symbols on the left are corrupted. I can't find why this happens. But it appears only in python scripts. I suppose this has something to do with the linter and the symbols. I am using the gruvbox scheme along with jedi-vim and the powerline symbols. Has anyone dealt with a similar issue before? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on   &quot; load filetype-specific indent files&#xA;&#xA;&#xA;&quot; minimalist&#xA;&quot; set t_Co=256&#xA;let g:gruvbox_italic=0&#xA;colorscheme gruvbox &#xA;set background=dark&#xA;let g:airline_theme='angr'&#xA;let g:gruvbox_contrast_dark='medium'&#xA;&#xA;&quot; UltiSnips&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsEditSplit=&quot;vertical&quot;&#xA;&#xA;&quot; JS syntastic fix&#xA;let g:jsx_ext_required = 0 &quot; Allow JSX in normal JS files&#xA;let g:syntastic_javascript_checkers = ['eslint']&#xA;&#xA;&quot; Force jedi to work with py3&#xA;let g:jedi#force_py_version = 3&#xA;&#xA;&quot; vim-commentary&#xA;autocmd FileType c   setlocal commentstring=//\ %s&#xA;autocmd FileType cpp setlocal commentstring=//\ %s&#xA;&#xA;&quot;&quot;&quot; automatically change working directory to the directory of the current file&#xA;autocmd BufEnter * if expand('%:p') !~ '://' | :lcd %:p:h | endif&#xA;&#xA;&quot; Ignore pyc files&#xA;let NERDTreeIgnore=['\.pyc$', '\~$'] &quot;ignore files in NERDTree&#xA;&#xA;&quot; Python syntax highlight&#xA;let python_highlight_all = 1&#xA;let python_no_operator_highlight = 1&#xA;let g:python_highlight_class_vars = 1&#xA;&#xA;&quot; DoxyGen-Syntax&#xA;let g:load_doxygen_syntax = 1&#xA;&#xA;&quot;&quot;&quot; NERD Tree&#xA;&quot; show hidden files&#xA;let NERDTreeShowHidden=1&#xA;&#xA;&#xA;&quot; Ack&#xA;if executable('ag')&#xA;    let g:ackprg = 'ag --vimgrep'&#xA;endif&#xA;&#xA;&quot; Ale&#xA;&quot; Signs&#xA;let g:ale_sign_error = '❌'&#xA;let g:ale_sign_warning = '❗'&#xA;&#xA;&quot;Echoed message&#xA;let g:ale_echo_msg_error_str = 'E'&#xA;let g:ale_echo_msg_warning_str = 'W'&#xA;let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'&#xA;&#xA;&quot;Linters&#xA;&quot; let g:ale_linters = {&#xA;&quot; \   'c': ['clangd', 'uncrustify'],&#xA;&quot; \   'python': ['flake8'],&#xA;&quot; \}&#xA;&#xA;&quot; Syntastic settings for linting&#xA;&quot; set statusline+=%#warningmsg#&#xA;&quot; set statusline+=%{SyntasticStatuslineFlag()}&#xA;&quot; set statusline+=%*&#xA;&#xA;&quot; let g:syntastic_always_populate_loc_list = 1&#xA;&quot; let g:syntastic_auto_loc_list = 1&#xA;&quot; let g:syntastic_check_on_open = 1&#xA;&quot; let g:syntastic_check_on_wq = 0&#xA;&#xA;&quot; let g:syntastic_python_checkers = ['flake8']&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot; Filetype settings&#xA;&quot; C&#xA;autocmd BufNewFile,BufRead *.h set filetype=c&#xA;&#xA;&quot; CSS&#xA;autocmd FileType css setlocal tabstop=2 softtabstop=2 shiftwidth=2&#xA;&#xA;&quot; HTML&#xA;autocmd FileType html setlocal tabstop=2 softtabstop=2 shiftwidth=2&#xA;&#xA;&quot; ino Arduino sketches&#xA;autocmd FileType ino setlocal tabstop=2 softtabstop=2 shiftwidth=2&#xA;&#xA;&quot; JavaScript&#xA;autocmd FileType javascript setlocal tabstop=2 softtabstop=2 shiftwidth=2&#xA;&#xA;&quot; JSON&#xA;autocmd BufNewFile,BufRead *.json set filetype=json&#xA;&#xA;&quot; make&#xA;&quot; makefiles require tabs for indentation&#xA;autocmd FileType make setlocal noexpandtab&#xA;&#xA;&quot; Markdown&#xA;autocmd BufNewFile,BufRead *.md set filetype=markdown&#xA;&#xA;&quot; Python&#xA;autocmd FileType py setlocal textwidth=79 tabstop=4 softtabstop=4 shiftwidth=4 expandtab autoindent&#xA;&#xA;&quot; SQL&#xA;autocmd FileType sql setlocal tabstop=2 softtabstop=2 shiftwidth=2&#xA;&#xA;&quot; yaml&#xA;&quot; yaml files require spaces for indentation&#xA;autocmd FileType yaml setlocal tabstop=2 softtabstop=2 shiftwidth=2&#xA;&#xA;&quot;&quot;&quot; strip trailing whitespace&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot; http://vim.wikia.com/wiki/Remove_unwanted_spaces&#xA;&quot; http://vimcasts.org/episodes/tidying-whitespace/&#xA;function! &amp;lt;SID&amp;gt;StripTrailingWhitespaces()&#xA;    &quot; Preparation :save last search, and cursor position.&#xA;    let _s=@/&#xA;    let l = line(&quot;.&quot;)&#xA;    let c = col(&quot;.&quot;)&#xA;    &quot; Do the business:&#xA;    %s/\s\+$//e&#xA;    &quot; Clean up: restore previous search history, and cursor position&#xA;    let @/=_s&#xA;    call cursor(l, c)&#xA;endfunction&#xA;&#xA;&quot; strip trailing whitespace on save&#xA;&quot; NOTE&#xA;&quot; order file extensions alphabetically&#xA;autocmd BufWritePre *.c,*.css,*.cu,*.h,*.html,*.ino,*.md,*.markdown,*.js,*.py,*.sh,*.sql,*.tex,*.txt :call &amp;lt;SID&amp;gt;StripTrailingWhitespaces()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my &lt;code&gt;line.vimrc&lt;/code&gt; script which is loaded in the &lt;code&gt;.vimrc&lt;/code&gt; file. I think the problem lies in the following lines from &lt;code&gt;line.vimrc&lt;/code&gt; script and the mixture of syntastic and the configurations.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_sign_error = '❌'&#xA;let g:ale_sign_warning = '❗'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19630" LastEditorUserId="19630" LastEditDate="2019-02-26T15:45:29.057" LastActivityDate="2019-02-26T15:45:29.057" Title="Pylint symbols and line numbering issue" Tags="|vimrc|plugin-powerline|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19018" PostTypeId="1" AcceptedAnswerId="19020" CreationDate="2019-02-25T21:09:40.060" Score="1" ViewCount="30" Body="&lt;p&gt;my text look like this in several places of the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FDE&#xA; PW91k&#xA; XCNADD PBE&#xA; ::FULLGRID&#xA;END&#xA;&#xA;&#xA;END &#xA;eor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to introduce a word two lines above &quot;eor&quot; word throughout. I have tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :,.-2/eor/foo/g &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and similar expressions, non worked so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you please help me with a trick that does this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="21135" LastActivityDate="2019-02-25T21:25:51.813" Title="how to add a word two lines above certain word in multiples places" Tags="|search|normal-mode|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19019" PostTypeId="2" ParentId="19015" CreationDate="2019-02-25T21:20:10.130" Score="1" Body="&lt;p&gt;You need to write your own complete function. Like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:env = [ &quot;test&quot;, &quot;perf&quot;, &quot;preprod&quot;, &quot;prod&quot; ]&#xA;&#xA;command! -complete=customlist,ListFor -nargs=1 BuildFor make &amp;lt;args&amp;gt;&#xA;function! ListFor(argLead, line, pos)&#xA;    return filter(s:env, { i, v -&amp;gt; match(v, '^' . a:argLead) == 0})&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you the enter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:BuildFor pr&amp;lt;TAB&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will propose the completions &quot;preprod&quot; and &quot;prod&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the completion depends on other arguments already on the command line, you have to work with the function parameters &lt;code&gt;line&lt;/code&gt; and &lt;code&gt;pos&lt;/code&gt; to determine them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read about the details with &lt;code&gt;:help :command-completion-custom&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-26T09:42:54.073" LastActivityDate="2019-02-26T09:42:54.073" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19020" PostTypeId="2" ParentId="19018" CreationDate="2019-02-25T21:25:51.813" Score="1" Body="&lt;p&gt;You could use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^eor/-2normal Ofoo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:g/^eor/&lt;/code&gt;:  For every line that starts with &quot;eor&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-2&lt;/code&gt;:  go two lines up&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Ofoo&lt;/code&gt;: open a line above and enter &quot;foo&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:g&lt;/code&gt; stands for &quot;global&quot;. See &lt;code&gt;:help :g&lt;/code&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-25T21:25:51.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19021" PostTypeId="1" CreationDate="2019-02-25T21:59:01.187" Score="0" ViewCount="9223" Body="&lt;p&gt;I start up vim from mac terminal like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But my colorschemes do not load properly (I tried loading &lt;code&gt;desert.vim&lt;/code&gt;, &lt;code&gt;desert256.vim&lt;/code&gt; and &lt;code&gt;solarized.vim&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;desert256.vim&lt;/code&gt; has a black background and white text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;desert.vim&lt;/code&gt; doesn't make a difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;solarized.vim&lt;/code&gt; has blue font and grey background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried a lot of solutions online, but cannot get it to work. (like adding lines to &lt;code&gt;.vimrc&lt;/code&gt;). My current &lt;code&gt;.vimrc&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax enable&#xA;set background=dark&#xA;colorscheme desert256&#xA;set t_Co=256&#xA;let colors_name = &quot;desert&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20958" LastActivityDate="2019-02-26T23:35:25.673" Title="Colorscheme not display correctly for vim on mac terminal" Tags="|colorscheme|color|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19022" PostTypeId="1" CreationDate="2019-02-26T02:02:55.880" Score="3" ViewCount="1280" Body="&lt;p&gt;I want to keep the terminal background somewhat transparent, but when I open vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim filename.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it opens it in terminal (as I want) but the background of the vim is somewhat transparent too. Can I make this background not transparent?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding this line: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Normal guibg=#ffffff guifg=#000000 ctermbg=white ctermfg=black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;results in this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Zrz2r.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Zrz2r.png&quot; alt=&quot;terminal&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20958" LastEditorUserId="20958" LastEditDate="2019-02-26T23:42:36.913" LastActivityDate="2019-03-29T00:15:43.250" Title="Remove transparency in VIM when terminal is transparent?" Tags="|terminal|colorscheme|" AnswerCount="0" CommentCount="2" ClosedDate="2019-06-03T14:30:38.143" ContentLicense="CC BY-SA 4.0" />
  <row Id="19023" PostTypeId="1" AcceptedAnswerId="19025" CreationDate="2019-02-26T02:56:16.217" Score="1" ViewCount="273" Body="&lt;p&gt;so my terminal window size on MAC OS is 100 columns and 30 rows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open &lt;code&gt;vim&lt;/code&gt; like this &lt;code&gt;vim filename.txt&lt;/code&gt; I want the size to open to whatever size is specified in &lt;code&gt;.vimrc&lt;/code&gt; (this works).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The size in my &lt;code&gt;.vimrc&lt;/code&gt; is 200 columns and 40 rows. When I quit vim with &lt;code&gt;:q&lt;/code&gt; I want the size of the window to go back to the terminal size (100 columns and 30 rows) but it remains 200 columns and 40 rows. Is there a way to go back to 100 coulmns and 30 rows automatically when &lt;code&gt;vim&lt;/code&gt; closes?&lt;/p&gt;&#xA;" OwnerUserId="20958" LastActivityDate="2019-02-26T11:30:09.460" Title="Vim open a certain size but return to terminal window size when closed" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19025" PostTypeId="2" ParentId="19023" CreationDate="2019-02-26T06:18:19.630" Score="2" Body="&lt;p&gt;You can use an autocmd with the event &lt;code&gt;VimLeave&lt;/code&gt; to reset &lt;code&gt;lines&lt;/code&gt; and &lt;code&gt;columns&lt;/code&gt; before Vim closes. Add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup term_size&#xA;    autocmd!&#xA;    autocmd VimLeave * set columns=100 lines=30&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The autocmd is executed once when Vim is about to exit and resets &lt;code&gt;colums&lt;/code&gt; and &lt;code&gt;lines&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use a autocmd-group to prevent multiple definition of the autocmd when the &lt;code&gt;vimrc&lt;/code&gt; is sourced multiple times (e.g. during testing Vim setup). The &lt;code&gt;autocmd!&lt;/code&gt; clears the group before the autocmd for &lt;code&gt;VimLeave&lt;/code&gt; is defined. See &lt;code&gt;:help autocmd-groups&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-02-26T11:30:09.460" LastActivityDate="2019-02-26T11:30:09.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19027" PostTypeId="1" AcceptedAnswerId="19028" CreationDate="2019-02-26T11:03:15.840" Score="7" ViewCount="5891" Body="&lt;p&gt;I'm trying to re-do the C-w selection shortcut in Jetbrains's IDE.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to select visually the whole containing block ?&lt;/p&gt;&#xA;&lt;p&gt;for now, i use&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-w&amp;gt; &amp;lt;Esc&amp;gt;viw&#xA;vnoremap &amp;lt;C-w&amp;gt; &amp;lt;Esc&amp;gt;{v}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Which allow me to select current word, then current block. (That's already really nice though)&lt;/p&gt;&#xA;&lt;p&gt;I know i could select multiple blocks with like &lt;code&gt;{{v}}&lt;/code&gt;, but that would just catch adjacent blocks, and would not backtrack to parent block, and that plays poorly with new lines.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to achieve that ?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;It seems what I was looking for is called &amp;quot;smart selection&amp;quot;, and there seem to be at least one vim extension that does that :&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/gcmt/wildfire.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/gcmt/wildfire.vim&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/gcmt/wildfire.vim/raw/master/_assets/preview.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://github.com/gcmt/wildfire.vim/raw/master/_assets/preview.gif&quot; alt=&quot;wildfire in use&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6868" LastEditorUserId="6868" LastEditDate="2022-08-09T14:06:29.537" LastActivityDate="2022-08-09T14:06:29.537" Title="How to expand selection to containing block? (It is in fact called Smart Selection)" Tags="|key-bindings|visual-mode|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19028" PostTypeId="2" ParentId="19027" CreationDate="2019-02-26T11:17:04.730" Score="6" Body="&lt;p&gt;A slight change of workflow would be to type &lt;kbd&gt;[&lt;/kbd&gt;&lt;kbd&gt;{&lt;/kbd&gt; as many times as necessary to jump to the start of the enclosing block, then &lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;%&lt;/kbd&gt; to visually select that entire block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%5B%7B&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help [{&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%25&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help %&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use these to implement your mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-W&amp;gt; [{V%&#xA;xnoremap &amp;lt;C-W&amp;gt; &quot;_y[{V%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The visual mode mapping works by first yanking into the black hole register (see &lt;code&gt;:help quote_&lt;/code&gt;), in order to exit visual mode leaving the cursor at the start of the previously selected block, and then selecting the next surrounding block with the same commands. I'm using &lt;code&gt;xnoremap&lt;/code&gt; instead of &lt;code&gt;vnoremap&lt;/code&gt; because the latter also applies in select mode, which you probably don't want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/19027/how-to-expand-selection-to-containing-block/19028?noredirect=1#comment32964_19027&quot;&gt;Like statox&lt;/a&gt;, I'd recommend against using &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; for the lhs. You'd be better off finding another trigger for your mappings.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-02-26T11:39:00.780" LastActivityDate="2019-02-26T11:39:00.780" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19029" PostTypeId="1" AcceptedAnswerId="19030" CreationDate="2019-02-26T15:37:03.277" Score="7" ViewCount="6728" Body="&lt;p&gt;I need to create a variable with a fool folder direct which need to concatenate from a environment variable and the end notes &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFoo(arg)&#xA;    let repo=$Project + &quot;/cfora&quot;                #Q1      &#xA;    let build=$project + &quot;/build/cfora/debug&quot;   &#xA;    exec &quot;!cd build&quot;                            &#xA;    exec &quot;!cmake repo&quot;                          #02&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q1: How can I concatenate the value of the environment variable &lt;code&gt;$Project&lt;/code&gt; with the end node string &lt;code&gt;/cfora&lt;/code&gt; into one string and assign it to a new variable &lt;code&gt;repo&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q2: How can I refer the variable in the string not print the variable name? For example here, I want to ultimately run &lt;code&gt;cmake /root/to/the/project/repo&lt;/code&gt;, not &lt;code&gt;cmake repo&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="15958" LastEditorUserId="9430" LastEditDate="2019-02-27T08:26:18.313" LastActivityDate="2022-08-06T19:16:34.747" Title="How to generate a string by concatenating another string with an environment variable" Tags="|variables|string-manipulation|environment-variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19030" PostTypeId="2" ParentId="19029" CreationDate="2019-02-26T15:42:58.517" Score="12" Body="&lt;p&gt;In vim dot is a concatenation operator:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let repo = $Project . '/cfora'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To &quot;refer&quot; variable in the string, well, in your case it is just a concatenation again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe '!cmake ' . repo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest to use built in make facilities for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And vim &lt;code&gt;lcd&lt;/code&gt; instead of &lt;code&gt;exe '!cd ...&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-02-26T15:42:58.517" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19031" PostTypeId="2" ParentId="19021" CreationDate="2019-02-26T16:27:22.160" Score="1" Body="&lt;p&gt;It is very common for a fancy colorscheme (such as solarized, base16-*, you name it) to require palette changes in a terminal. Without it you will face ugly colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I generally avoid such colorschemes in terminals and use them only in GUI vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve it -- goto the place you have obtained colorscheme, find description on how to properly use it. Usually it is smth about changing first 16 terminal colors. Solarized example: &lt;a href=&quot;https://github.com/altercation/solarized&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/altercation/solarized&lt;/a&gt; . There you can find how to redefine your colors for different stuff including osx terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also colorshemes that are not made with terminals in mind -- they define only gui colors.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-02-26T16:36:23.003" LastActivityDate="2019-02-26T16:36:23.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19032" PostTypeId="2" ParentId="18911" CreationDate="2019-02-26T18:34:22.113" Score="0" Body="&lt;p&gt;Here is an example of how your directory structure below &lt;code&gt;pack&lt;/code&gt; should look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pack&#xA;└── bundle&#xA;    ├── opt&#xA;    │   └── vim-fugitive&#xA;    │       ├── autoload&#xA;    │       ├── doc&#xA;    │       ├── ftdetect&#xA;    │       ├── plugin&#xA;    │       └── syntax&#xA;    └── start&#xA;        ├── ctrlp.vim&#xA;        │   ├── autoload&#xA;        │   │   └── ctrlp&#xA;        │   ├── doc&#xA;        │   └── plugin&#xA;        └── vim-commentary&#xA;            ├── doc&#xA;            └── plugin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-02-26T18:34:22.113" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19034" PostTypeId="1" CreationDate="2019-02-26T21:27:32.713" Score="0" ViewCount="18" Body="&lt;p&gt;I've somehow introduced a problem in my Vim configuration and I don't know how to track down where the problem is. Sometimes (most times) when I do &lt;code&gt;:w&lt;/code&gt; then the buffer is not actually written; something else happens instead. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What can I do to find out what is happening so I know what to fix?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="7213" LastEditorUserId="7213" LastEditDate="2019-02-26T22:04:56.587" LastActivityDate="2019-02-26T22:04:56.587" Title="How to diagnose configuration---:w doesn't always work" Tags="|vimrc|save|" AnswerCount="0" CommentCount="2" ClosedDate="2019-02-27T08:39:49.417" ContentLicense="CC BY-SA 4.0" />
  <row Id="19035" PostTypeId="2" ParentId="12638" CreationDate="2019-02-26T21:57:59.060" Score="0" Body="&lt;p&gt;&lt;code&gt;:columns&lt;/code&gt; is an internal VIM property that is intended to be a mirror for the number of columns for the &lt;em&gt;interactive shell environment&lt;/em&gt; that VIM is running under.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:columns&lt;/code&gt; should always match the result of &lt;code&gt;tput cols&lt;/code&gt; (for bash). This means that VIM is able to automatically reflow the text on the screen when the terminal dimensions change. One such reflow event is triggered when VIM recovered from a &quot;STOPPED&quot; (ctrl+Z) state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:columns&lt;/code&gt; is not the best way to set the width of text in the VIM editor. In most GUI environments, simply resizing the VIM window is the best way &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Recommendation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Windowed GUI environments: Simply click and drag the terminal to the desired size.&lt;/li&gt;&#xA;&lt;li&gt;Plain console: (BASH) Run &lt;code&gt;stty cols ${COLUMN_WIDTH}&lt;/code&gt; in the shell to set the number of columns for your terminal. This will change the dimensions of your shell, and VIM will automatically pick up the new dimensions.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5850" LastActivityDate="2019-02-26T21:57:59.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19036" PostTypeId="2" ParentId="19021" CreationDate="2019-02-26T23:35:25.673" Score="0" Body="&lt;p&gt;Look for colorschemes that are compatible with the terminal and the mac OS terminal colors. Here is a list of them (search for the word &quot;solarized&quot;): &lt;a href=&quot;https://github.com/rafi/awesome-vim-colorschemes&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/rafi/awesome-vim-colorschemes&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20958" LastActivityDate="2019-02-26T23:35:25.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19037" PostTypeId="1" CreationDate="2019-02-27T03:14:14.537" Score="1" ViewCount="555" Body="&lt;p&gt;I'm trying to workout whether this is an issue with my ALE configuration, or it's some kind of bug with the linter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I'm using &lt;code&gt;tsserver&lt;/code&gt; and &lt;code&gt;prettier&lt;/code&gt; for Typescript with ALE. Both error and warning signs are appearing as expected in the gutter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I put the cursor over an error, I see the error in the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I put the cursor over a warning, nothing is showing in the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this normal behaviour, and if so is it possible to configure that?  Or am I experiencing some kind of issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can actually see the warning messages if I use the &lt;code&gt;:lopen&lt;/code&gt; command, but I'd like to see them when moving the cursor over them too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additional info:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NVIM v0.3.2&#xA;Build type: Release&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21148" LastEditorUserId="21148" LastEditDate="2019-02-28T05:03:46.790" LastActivityDate="2019-02-28T05:03:46.790" Title="ALE - how to configure warnings to appear in the command line?" Tags="|plugin-ale|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19038" PostTypeId="1" CreationDate="2019-02-27T09:10:43.233" Score="4" ViewCount="427" Body="&lt;p&gt;When I start vim and I want to return to the last location in the jump list, I would like to do so with a single &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;. However, right now I have to press twice &lt;code&gt;&amp;lt;C-O&amp;gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; to achieve this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to better understand this, I narrowed down the behavior by deleting viminfo, moving my vimrc away (i.e. vim starts only with &lt;code&gt;defaults.vim&lt;/code&gt;), opening a single file and then restarting vim without any argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I then enter &lt;code&gt;:jumps&lt;/code&gt;, I get following output &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/S9O4f.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S9O4f.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see the first entry in the jump list points to no file and I &quot;move&quot; the current position to this entry when I press the first time &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;. This can be confirmed by running &lt;code&gt;:jumps&lt;/code&gt; after the first &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim help says&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If the &lt;em&gt;pointer&lt;/em&gt; is below the last entry, this indicates that&#xA;  you did not use a &lt;code&gt;CTRL-I&lt;/code&gt; or &lt;code&gt;CTRL-O&lt;/code&gt; before.  In this case the &lt;code&gt;CTRL-O&lt;/code&gt; command&#xA;  will cause the cursor position to be added to the jump list, so you can get&#xA;  back to the position before the &lt;code&gt;CTRL-O&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Can someone confirm/explain this to me and maybe point out how this could be resolved?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMHO if &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; is invoked the first time and the newly added entry for return as described in the helpfile is identical to the first entry, it should be skipped and does not need to be added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chapter 29 of the user manual suggests to use &lt;code&gt;'0&lt;/code&gt; to return to the last position when you exited vim. I will consider to use this instead. However, &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; has the advantage to jump to older entries in the jumplist. Therefore, I still like to know why vim has this behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim version: 8.1.950&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-03-30T15:52:35.740" LastActivityDate="2019-03-30T15:52:35.740" Title="Pressing CTRL-O twice is required to return to previous entry in jumplist" Tags="|startup|jumplist|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19039" PostTypeId="2" ParentId="14518" CreationDate="2019-02-27T18:17:14.860" Score="1" Body="&lt;p&gt;You can get the size of the file that is loaded in the current buffer with: &lt;code&gt;getfsize(expand(@%))&lt;/code&gt;. To add it to the statusline you would use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;statusline .= &quot;%{getfsize(expand(@%))}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Be aware that it will show -1 for the size of a new unnamed buffer and will update on modified files only after they are saved.&lt;/p&gt;&#xA;" OwnerUserId="17560" LastActivityDate="2019-02-27T18:17:14.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19040" PostTypeId="1" AcceptedAnswerId="19044" CreationDate="2019-02-27T18:38:24.093" Score="9" ViewCount="5986" Body="&lt;p&gt;&lt;code&gt;Todo&lt;/code&gt; highlight group currently highlights &lt;code&gt;TODO&lt;/code&gt; and &lt;code&gt;FIXME&lt;/code&gt; keywords. What do I do to add &lt;code&gt;NOTE&lt;/code&gt;, and possibley more keywords, to this existing highlight group, for all file types?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-03-01T09:08:05.220" Title="Add keywords to a highlight group" Tags="|syntax-highlighting|syntax|keyword|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19041" PostTypeId="1" CreationDate="2019-02-27T21:19:46.170" Score="0" ViewCount="159" Body="&lt;p&gt;(I have TComment installed, and I'm on NeoVim 0.4.0.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given this code, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mem key st =&#xA;   let is_matching_key = function&#xA;   | Positional _ -&amp;gt; false&#xA;   | Flag f -&amp;gt; f.name == key&#xA;   in&#xA;   (* FIXME: This is slow, but Array.exists isn't available until OCaml 4.03, and I am lazy. *)&#xA;   List.exists is_matching_key (Array.to_list st.args)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I select the above code, and hit &lt;kbd&gt;gc&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(* let mem key st = *)&#xA;(*    let is_matching_key = function *)&#xA;(*    | Positional _ -&amp;gt; false *)&#xA;(*    | Flag f -&amp;gt; f.name == key *)&#xA;(*    in *)&#xA;(*    (* FIXME: This is slow, but Array.exists isn't available until OCaml 4.03, and I am lazy. *) *)&#xA;(*    List.exists is_matching_key (Array.to_list st.args) *)&#xA;(*  *)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead, I'd like to get something like,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(* let mem key st =&#xA;   let is_matching_key = function&#xA;   | Positional _ -&amp;gt; false&#xA;   | Flag f -&amp;gt; f.name == key&#xA;   in&#xA;   (* FIXME: This is slow, but Array.exists isn't available until OCaml 4.03, and I am lazy. *)&#xA;   List.exists is_matching_key (Array.to_list st.args) *)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… where there are only comment-delimiters at the beginning and end of the entire text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I achieve this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Additionally — I'd like to get Vim to continue to maintain this indent-style when hitting &lt;kbd&gt;Return&lt;/kbd&gt; inside docblocks. If &lt;code&gt;⁁&lt;/code&gt; is the insertion-point in the following text …&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(** This is a documentation-block for this function.⁁&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;… I currently get this after hitting &lt;kbd&gt;Return&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(** This is a documentation-block for this function.&#xA; * ⁁&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note the additional asterisk it's adding on each line; also note that the indentation is ‘one off’, not aligning with the &lt;code&gt;T&lt;/code&gt; in the above line.) I'd like to get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(** This is a documentation-block for this function.&#xA;    ⁁&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried to pore thru the TComment documentation, but I'm having no luck improving this behaviour.&lt;/p&gt;&#xA;" OwnerUserId="6108" OwnerDisplayName="ELLIOTTCABLE" LastActivityDate="2019-02-27T21:21:51.743" Title="How do I get Vim (with TComment) to do proper block comments in OCaml?" Tags="|comments|indentation|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19042" PostTypeId="2" ParentId="16216" CreationDate="2019-02-27T22:31:45.620" Score="0" Body="&lt;p&gt;I ran into this same thing, specifically with Anaconda Python. It appears to be a recent change to some of their DLLs and it has nothing to do with Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/ContinuumIO/anaconda-issues/issues/10660&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ContinuumIO/anaconda-issues/issues/10660&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21037" LastActivityDate="2019-02-27T22:31:45.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19043" PostTypeId="2" ParentId="19040" CreationDate="2019-02-28T06:19:00.783" Score="15" Body="&lt;p&gt;The highlight group &lt;code&gt;Todo&lt;/code&gt; just defines how a &quot;todo&quot; should be highlighted. What is actually highlighted by &lt;code&gt;Todo&lt;/code&gt; is defined by the syntax. For the C language, the expression is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn keyword     cTodo           contained TODO FIXME XXX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This defines the syntax group &lt;code&gt;cTodo&lt;/code&gt;, that contains the named keywords. This syntax group is later linked to highlight group &lt;code&gt;Todo&lt;/code&gt; with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi def link cTodo       Todo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to add an additional keyword to the &lt;code&gt;cTodo&lt;/code&gt; syntax group, you should create the file &lt;code&gt;~/.vim/after/syntax/c.vim&lt;/code&gt; (&lt;code&gt;~/vimfiles/after/syntax/c.vim&lt;/code&gt; on Windows) with the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Add NOTE as todo keyword&#xA;syntax keyword cTodo contained NOTE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this definition is syntax-specific. For python it would be &lt;code&gt;pythonTodo&lt;/code&gt; and the file would be &lt;code&gt;~.vim/after/syntax/python.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :syn-keyword&lt;/code&gt; and &lt;code&gt;:help :syn-contained&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Add-on:&lt;/strong&gt; How do I delete a keyword from am syntax keyword group?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK, there is no way to do that directly. You have to clear the entire group and rebuild it. Like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax clear cTodo&#xA;syntax keyword cTodo contained TODO FIXME NOTE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Add-on:&lt;/strong&gt; How do I know how the &quot;todo&quot; syntax group is named for a given language?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most likely it is &lt;code&gt;&amp;lt;file-type&amp;gt;Todo&lt;/code&gt;. To be sure, create a file of this language and add a &quot;todo&quot; comment. Move the cursor to the highlighted word and execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 1), &quot;name&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need to do that more than once, you might want to define a new command in Vim by adding the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Show name of syntax element below cursor&#xA;command! SynName  echo synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 1), &quot;name&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; How to add &quot;todo&quot; keywords for all file types?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is more complicated. Now you need a autocmd and a function to find the&#xA;correct syntax groups and extend them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is it important to add the new keywords to the existing definitions? Well, Vim syntax knows &lt;code&gt;contained&lt;/code&gt; and &lt;code&gt;contains=...&lt;/code&gt;. The &quot;todo&quot; syntax group is defined as &lt;code&gt;contained&lt;/code&gt;, that means, that it is only highlighted, when is is contained in another syntax group. On the other hand the syntax group(s) for comments is defined with &lt;code&gt;contains=xxxTodo&lt;/code&gt;, so &quot;todos&quot; are highlighted within comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you go:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! UpdateTodoKeywords(...)&#xA;    let newKeywords = join(a:000, &quot; &quot;)&#xA;    let synTodo = map(filter(split(execute(&quot;syntax list&quot;), '\n') , { i,v -&amp;gt; match(v, '^\w*Todo\&amp;gt;') == 0}), {i,v -&amp;gt; substitute(v, ' .*$', '', '')})&#xA;    for synGrp in synTodo&#xA;        execute &quot;syntax keyword &quot; . synGrp . &quot; contained &quot; . newKeywords&#xA;    endfor&#xA;endfunction&#xA;&#xA;augroup now&#xA;    autocmd!&#xA;    autocmd Syntax * call UpdateTodoKeywords(&quot;NOTE&quot;, &quot;NOTES&quot;)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;UpdateTodoKeywords&lt;/code&gt; is called whenever a syntax is loaded and adds the given keywords to all&#xA;&quot;todo&quot; syntax groups. You can add multiple names to the call to &lt;code&gt;UpdateTodoKeywords&lt;/code&gt;, as mutch as you want (but at least one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that there are syntax definitions, that contain multiple definitions for &quot;todo&quot;. E.g. &#xA;for Vim script files also python syntax is loaded, so it has &lt;code&gt;vimTodo&lt;/code&gt; and &lt;code&gt;pythonTodo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function is strait forward, except for the line &lt;code&gt;let synTodo = map(...&lt;/code&gt;. Here is what that line does:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It lists all syntax items (&lt;code&gt;execute(&quot;syntax list&quot;)&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Splits it into a list of lines (&lt;code&gt;split(..., '\n')&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Filters it to only contain lines with syntax group name that ends with &lt;code&gt;Todo&lt;/code&gt; (&lt;code&gt;filter(..., { i,v -&amp;gt; match(v, '^\w*Todo\&amp;gt;') == 0})&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Removes everything after syntax group name (&lt;code&gt;map(..., {i,v -&amp;gt; substitute(v, ' .*$', '', '')})&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So the result of this is a list of syntax group names that end with &lt;code&gt;Todo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then for every syntax group name it adds the given keywords.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: This even works, if the &quot;todo&quot; syntax group is initially defined as &lt;code&gt;syn-match&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Finally:&lt;/strong&gt; The &quot;brute force attempt&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Syntax * syntax keyword myTodo NOTE NOTES containedin=ALL | highlight def link myTodo TODO&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This defines a new syntax group &lt;code&gt;myTodo&lt;/code&gt; that will be contained in every existing syntax group. So it will highlight &quot;NOTE&quot; and &quot;NOTES&quot; everywhere. In comments, in strings or if you use it as a variable name.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-01T09:08:05.220" LastActivityDate="2019-03-01T09:08:05.220" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19044" PostTypeId="2" ParentId="19040" CreationDate="2019-02-28T13:43:23.950" Score="4" Body="&lt;p&gt;Add the following to your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! SetMyTodos()&#xA;    syn match myTodos /\%(HABA:\)\|\%(NOTE:\)/&#xA;    hi link myTodos Todo&#xA;endfu&#xA;autocmd bufenter * :call SetMyTodos()&#xA;autocmd filetype * :call SetMyTodos()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Restart. Then everytime you will set filetype (usually when you edit a file) or when you enter a buffer (:e newfile) it will add a &lt;code&gt;myTodos&lt;/code&gt; syntax that is highlighted as a &lt;code&gt;Todo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is just an example, though :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SIzeQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SIzeQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-02-28T13:43:23.950" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19045" PostTypeId="1" CreationDate="2019-02-28T14:48:00.347" Score="0" ViewCount="2798" Body="&lt;p&gt;I have some code that looks similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&#xA;    (Text),&#xA;    (Text),&#xA;    (Text), &#xA;],&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to edit the lines that say &quot;Text&quot; by using Visual Block mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can type &lt;code&gt;ctrl-v&lt;/code&gt; on the first &quot;T&quot; and then &lt;code&gt;}&lt;/code&gt;, but that brings me down to the first blank line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to jump to the &quot;T&quot; on the bottom line that says &quot;Text&quot;? Essentially I want to jump down until there is whitespace below.&lt;/p&gt;&#xA;" OwnerUserId="11931" LastActivityDate="2019-04-02T17:01:10.217" Title="Jump to bottom of block in Visual Block mode" Tags="|visual-block|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19046" PostTypeId="1" CreationDate="2019-02-28T16:02:01.270" Score="1" ViewCount="218" Body="&lt;p&gt;How can I keep the search results location list window open after opening a file in a new buffer?&lt;/p&gt;&#xA;" OwnerDisplayName="elpdpt" LastEditorUserId="11357" LastEditDate="2019-03-15T15:30:49.603" LastActivityDate="2024-03-02T20:29:09.427" Title="How do I keep the spacevim search results window open after opening a file?" Tags="|search|spacevim|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19047" PostTypeId="1" AcceptedAnswerId="19061" CreationDate="2019-02-28T20:23:04.183" Score="2" ViewCount="814" Body="&lt;p&gt;I am a new Vim user. I can do : &lt;code&gt;:! &amp;lt;some command&amp;gt;&lt;/code&gt; in Vim to run a bash command in Linux.  After that bash command is executed, I can press &lt;code&gt;Enter&lt;/code&gt; to go back to Vim.  What happens if the bash command takes a long time to run (I am running some simulations), so I need to go back to code and read while waiting for the command to finish executing.  I can do &lt;code&gt;Ctrl + Z&lt;/code&gt;, then open Vim again, then go back to terminal and type &lt;code&gt;fg&lt;/code&gt;.  But is there a better way of doing this? I would like my bash running, and I can switch back between Vim and the running bash. &lt;/p&gt;&#xA;" OwnerUserId="21038" LastEditorUserId="16280" LastEditDate="2019-03-02T12:25:45.993" LastActivityDate="2019-03-02T12:25:45.993" Title="Run processes in shell while editing in Vim" Tags="|vimrc|bash|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19048" PostTypeId="2" ParentId="14065" CreationDate="2019-02-28T21:44:58.513" Score="9" Body="&lt;p&gt;Just a remark to Martin Tournoij answer.&lt;/p&gt;&#xA;&lt;p&gt;When you just opened a quickfix buffer/window (and not switched to it yet), the &lt;code&gt;&amp;amp;buftype&lt;/code&gt; option is not set yet. You may find another autocommand event useful:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWinEnter quickfix echo 'bufwinenter'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20634" LastEditorUserId="48316" LastEditDate="2023-07-19T12:50:09.197" LastActivityDate="2023-07-19T12:50:09.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19049" PostTypeId="1" AcceptedAnswerId="19050" CreationDate="2019-03-01T04:07:06.660" Score="1" ViewCount="306" Body="&lt;p&gt;My vimrc is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set langmap='q,\\,w,.e,pr,yt,fy,gu,ci,ro,lp,/[,=],aa,os,ed,uf,ig,dh,hj,tk,nl,s\\;,-',\\;z,qx,jc,kv,xb,bn,mm,w\\,,v.,z/,[-,]=,\&quot;Q,&amp;lt;W,&amp;gt;E,PR,YT,FY,GU,CI,RO,LP,?{,+},AA,OS,ED,UF,IG,DH,HJ,TK,NL,S:,_\&quot;,:Z,QX,JC,KV,XB,BN,MM,W&amp;lt;,V&amp;gt;,Z?&#xA;syntax on&#xA;set number&#xA;set autoindent&#xA;set tabstop = 4&#xA;color dracula&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet for some reason, the changes to the keymaps aren't being made in Vim. This exact vimrc works perfectly in both Vim on my Linux system and GVim on my Windows system. I even tried installing the git version of Vim. What could be causing this?&lt;/p&gt;&#xA;" OwnerUserId="21173" LastEditorUserId="23502" LastEditDate="2022-09-16T16:12:47.590" LastActivityDate="2022-09-16T16:12:47.590" Title="Why will my set langmap in my vimrc not actually make the changes in Vim on macOS?" Tags="|key-bindings|command-line|macos|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19050" PostTypeId="2" ParentId="19049" CreationDate="2019-03-01T07:33:01.957" Score="1" Body="&lt;p&gt;Check if you have your vim compiled with langmap support:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ggoQf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ggoQf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-03-01T07:33:01.957" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19051" PostTypeId="1" AcceptedAnswerId="19054" CreationDate="2019-03-01T07:51:45.620" Score="1" ViewCount="116" Body="&lt;p&gt;My problem on this gif:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GQh4M.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GQh4M.gif&quot; alt=&quot;vim incremental search, theme Gotham, macOS, term&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am in one place, searching for &lt;code&gt;meta&lt;/code&gt;, I do not want to loose my current search highlighting (yes I know that I can restore it later in &lt;code&gt;/&lt;/code&gt; menu). I found what I need - without pressing &lt;kbd&gt;Enter&lt;/kbd&gt;. I want to stay here, without autoscrolling back to my original position.&lt;/p&gt;&#xA;" OwnerUserId="6038" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-03-01T19:36:46.543" Title="Incremental search: is it possible to push 'Esc` without scrolling back?" Tags="|search|navigation|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19053" PostTypeId="1" AcceptedAnswerId="19057" CreationDate="2019-03-01T09:13:11.123" Score="1" ViewCount="155" Body="&lt;p&gt;I am traversing through a &lt;strong&gt;C code in Vim using cscope&lt;/strong&gt;. Sometimes while traversing, some key gets pressed or mouse gets right-clicked and the Vim enters in insert mode, and it creates a mess to undo the changes and all. I just want to read the code, and hence want to open &lt;strong&gt;Vim in read-only mode.&lt;/strong&gt; Is it possible? How can it be done so?&lt;/p&gt;&#xA;" OwnerUserId="21150" LastEditorUserId="21150" LastEditDate="2019-03-01T10:04:31.483" LastActivityDate="2019-03-01T17:31:12.640" Title="Read-only mode in Vim while using cscope?" Tags="|search|navigation|cscope|original-vim|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19054" PostTypeId="2" ParentId="19051" CreationDate="2019-03-01T09:46:14.990" Score="1" Body="&lt;p&gt;I don't think that this is possible in Vim, but I'm ready to be surprised. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only idea I have is to create a mapping to set the last search to the next to last search. So you hit &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; and then use the mapping to reset your search highlighting.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap _ps :let @/=histget('/',-2)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to drop the last search entirely, you could define the mapping as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap _ps :call histdel('/',-1)\|let @/=histget('/',-1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-01T09:46:14.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19055" PostTypeId="2" ParentId="19053" CreationDate="2019-03-01T10:23:16.307" Score="0" Body="&lt;p&gt;You can try to reuse &lt;code&gt;modifiable&lt;/code&gt; setting (&lt;code&gt;:h mo&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;code&gt;set noma&lt;/code&gt; (nomodifiable) for a current buffer -- it will prevent any modifications you will try to do for that buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure how to connect it with cscope -- I have never used it and I don't know what is your workflow...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just an idea -- to use autocommand&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufEnter * :set noma&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this will turn on no modifiable setting for all your buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To revert do the same with &lt;code&gt;:set ma&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufEnter * :set ma&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can limit it to &lt;code&gt;c&lt;/code&gt; buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufEnter *.c,*.h :set noma&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PPS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create mappings (add to your .vimrc):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;f5&amp;gt; :set noma&amp;lt;CR&amp;gt;:autocmd! BufEnter *.cpp,*.c,*.h :set noma&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;f6&amp;gt; :set ma&amp;lt;CR&amp;gt;:autocmd! BufEnter *.cpp,*.c,*.h :set ma&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Press &lt;code&gt;&amp;lt;f5&amp;gt;&lt;/code&gt; when you want to do your cscope.&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;&amp;lt;f6&amp;gt;&lt;/code&gt; when done.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;PPPS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then again, to be more safe you have to check if it was you who set nomodifiable flag before removing it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably it would be better to use &lt;code&gt;:bufdo&lt;/code&gt; to remove nomodifiable flag instead of autocommand. (Plus don't forget to turnoff autocommand from &lt;code&gt;&amp;lt;f5&amp;gt;&lt;/code&gt; ...)&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-03-01T10:59:18.227" LastActivityDate="2019-03-01T10:59:18.227" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19056" PostTypeId="1" AcceptedAnswerId="19059" CreationDate="2019-03-01T10:23:53.060" Score="2" ViewCount="1100" Body="&lt;p&gt;I'm using a LSP plugin to call a command from the server, and currently it is logging the data using &lt;code&gt;echom&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/i3cyg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/i3cyg.png&quot; alt=&quot;Response&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current code is like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PtypeCallback(result)&#xA;    echom json_encode(a:result)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It was working, but for functions with larger types, The JSON string is truncated. Also I want to keep it for some time, preferably launching it in a preview window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I open the preview-window using a custom created buffer which contains the &lt;code&gt;typ&lt;/code&gt; parameter from the JSON I'm receiving in &lt;code&gt;a:result&lt;/code&gt; parameter?&lt;/p&gt;&#xA;" OwnerUserId="18597" LastActivityDate="2019-03-02T04:48:55.383" Title="How to create Preview window to display a string?" Tags="|echo|scratch-buffer|previewwindow|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19057" PostTypeId="2" ParentId="19053" CreationDate="2019-03-01T17:31:12.640" Score="1" Body="&lt;p&gt;Invoke vim as &lt;code&gt;view&lt;/code&gt; on the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;view myfile.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will automatically set the appropriate “readonly” flags. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-01T17:31:12.640" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19058" PostTypeId="2" ParentId="19047" CreationDate="2019-03-01T17:32:51.157" Score="1" Body="&lt;p&gt;If you're sitting at a console, one option is the &lt;code&gt;screen&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using XWindows, there are a couple of options,  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use gvim to do your editing, and switch between it and your terminal &lt;/li&gt;&#xA;&lt;li&gt;Use a tabbed terminal, and switch between the tabs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2019-03-01T17:32:51.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19059" PostTypeId="2" ParentId="19056" CreationDate="2019-03-01T17:45:55.137" Score="2" Body="&lt;p&gt;After seven hours of fiddling with the documentation and searching, I was able to write a function that takes a filetype, an array of strings and show a dummy buffer based on that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! showInPreview(name, fileType, lines)&#xA;    let l:command = &quot;silent! pedit! +setlocal\\ &quot; .&#xA;                  \ &quot;buftype=nofile\\ nobuflisted\\ &quot; .&#xA;                  \ &quot;noswapfile\\ nonumber\\ &quot; .&#xA;                  \ &quot;filetype=&quot; . a:fileType . &quot; &quot; . a:name&#xA;&#xA;    exe l:command&#xA;&#xA;    if has('nvim')&#xA;        let l:bufNr = bufnr(a:name)&#xA;        call nvim_buf_set_lines(l:bufNr, 0, -1, 0, a:lines)&#xA;    else&#xA;        call setbufline(a:name, 1, a:lines)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wrote this function based on the rust plugin code I found in the LanguageClient_neovim plugin. Thanks @D._Ben_Knoble for suggesting the vim/nvim check in the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps anyone looking for this answer. I can now call this function from my callback function with the correct lines and I'm ensured that it works for me.&lt;/p&gt;&#xA;" OwnerUserId="18597" LastEditorUserId="18597" LastEditDate="2019-03-02T04:48:55.383" LastActivityDate="2019-03-02T04:48:55.383" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19060" PostTypeId="2" ParentId="19051" CreationDate="2019-03-01T17:49:59.660" Score="2" Body="&lt;p&gt;You can use this mapping &amp;amp; function to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! KeepCursorEsc() abort&#xA;  let g:search_pos = getcurpos()&#xA;  return &quot;\&amp;lt;C-C&amp;gt;:call setpos('.', g:search_pos)\&amp;lt;CR&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;Esc&amp;gt; KeepCursorEsc()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;How it works&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;We can't use an regular &lt;code&gt;cmap&lt;/code&gt; because we need to run code while the search is still active. Instead we use an expression mapping, which allows us to run a function by evaluating it as an expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function first reads the cursor position with &lt;code&gt;getcurpos()&lt;/code&gt; and then returns a string which is used as the &lt;code&gt;rhs&lt;/code&gt; of the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;code&gt;rhs&lt;/code&gt; cancels the search with &lt;code&gt;&amp;lt;C-C&amp;gt;&lt;/code&gt; (&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; used in a &lt;code&gt;cmap&lt;/code&gt; &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_Esc&quot; rel=&quot;nofollow noreferrer&quot;&gt;runs the search command instead of cancelling it&lt;/a&gt;) and then restores the cursor position to what it was when the mapping was invoked by calling &lt;code&gt;setpos()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.B. Note that the function will also be called when you press &lt;kbd&gt;Esc&lt;/kbd&gt; while typing a &lt;code&gt;:&lt;/code&gt; command. We should really avoid this by checking the type of the command-line with &lt;code&gt;getcmdtype()&lt;/code&gt;, but for simplicity, this answer does not do so: when you're typing a &lt;code&gt;:&lt;/code&gt; command the cursor will be in the same position anyway, so the function won't move it unexpectedly!&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-03-01T19:36:46.543" LastActivityDate="2019-03-01T19:36:46.543" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19061" PostTypeId="2" ParentId="19047" CreationDate="2019-03-01T17:57:26.570" Score="5" Body="&lt;p&gt;For general purpose multi-window terminal experience, look into &lt;a href=&quot;https://github.com/tmux/tmux&quot; rel=&quot;noreferrer&quot;&gt;tmux&lt;/a&gt;. Tmux, a terminal multiplexer, provides functionalities to split a terminal window into several vertical and horizontal splits, managing windows from one terminal emulator instance and managing different sessions. Here is a basic bird's eye view:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+---------------------------------------------------+&#xA;|   +-------------------------------------------+   |&#xA;|   |                                           |   |&#xA;|   |   +-----------+-----------+-----------+   |   |&#xA;|   |   |           |           |           |   |   |&#xA;|   |   |  SPLITS   |  SPLITS   |  SPLITS   |   |   |&#xA;|   |   |           |           |           |   |   |&#xA;|   |   +-----------+----+------+-----------+   |   |&#xA;|   |   |                |                  |   |   |&#xA;|   |   |     SPLITS     |      SPLITS      |   |   |&#xA;|   |   |                |                  |   |   |&#xA;|   |   +----------------+------------------+   |   |&#xA;|   |                                           |   |&#xA;|   |                 WINDOWS                   |   |&#xA;|   +-------------------------------------------+   |&#xA;|                     SESSIONS                      |&#xA;+---------------------------------------------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are many more advantages of tmux. For example, you can kill your terminal emulator instance and don't have to fear for losing your work, you can just attach to the tmux session. You can share your tmux screen with your co-worker etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Enough of tmux advertising. Let's get to native vim solutions. From &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/doc/version8.txt#L14532&quot; rel=&quot;noreferrer&quot;&gt;vim version 8.1&lt;/a&gt;, you can use &lt;code&gt;:terminal&lt;/code&gt; to get a buffer which will act as a shell from within vim. Since, it &lt;em&gt;is&lt;/em&gt; a vim buffer you can manage it like any other buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your mentioned use cases, I'd something like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;open vim&lt;/li&gt;&#xA;&lt;li&gt;open file&lt;/li&gt;&#xA;&lt;li&gt;split vertically (vim term, tmux splitting has totally different term!)&lt;/li&gt;&#xA;&lt;li&gt;run &lt;code&gt;:term make&lt;/code&gt; (although if you're using just make, you should look into &lt;code&gt;:h quickfix&lt;/code&gt; and &lt;code&gt;:h :make&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;switch back and forth, etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;N.B&lt;/strong&gt; The above workflow is completely compatible with tmux.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-03-01T17:57:26.570" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19062" PostTypeId="2" ParentId="3897" CreationDate="2019-03-01T19:17:13.220" Score="3" Body="&lt;p&gt;This is what I put in my vimrc thanks to the answer by @raphael&lt;/p&gt;&#xA;&lt;p&gt;I also install the &lt;a href=&quot;https://github.com/tmux-plugins/vim-tmux-focus-events&quot; rel=&quot;nofollow noreferrer&quot;&gt;tmux-plugins/vim-tmux-focus-events&lt;/a&gt; plugin for the FocusGained and FocusLost events.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup tmux&#xA;  autocmd!&#xA;  if exists('$TMUX')&#xA;    autocmd BufReadPost,FileReadPost,BufNewFile,FocusGained * call system(&amp;quot;tmux rename-window &amp;quot; . expand(&amp;quot;%:t&amp;quot;))&#xA;    autocmd VimLeave,FocusLost * call system(&amp;quot;tmux set-window-option automatic-rename&amp;quot;)&#xA;  endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17290" LastEditorUserId="26878" LastEditDate="2023-04-18T14:57:57.117" LastActivityDate="2023-04-18T14:57:57.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19064" PostTypeId="1" CreationDate="2019-03-02T08:22:50.960" Score="0" ViewCount="478" Body="&lt;p&gt;I'm not sure if it has always happened or its just recent, but vim auto-compiles on each save (&lt;code&gt;:w&lt;/code&gt;). I would like to only manually compile (I use a hot-keyed pdflatex command instead).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've had a quick google and read through the manual and nothing has jumped out at me. Anyone know how to do this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: Relevant lines in vimrc  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'vim-latex/vim-latex'&#xA;let g:tex_flavor='latex'&#xA;&quot; OPTIONAL: This enables automatic indentation as you type.&#xA;filetype indent on&#xA;&quot; `Ctrl` + `P` compiles latest save of current .tex file to pdf&#xA;autocmd FileType tex nnoremap &amp;lt;c-p&amp;gt; &amp;lt;ESC&amp;gt;:!pdflatex %&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NB: Plug-in manager is &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;junegunn/vim-plug&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update 2: Turns out I did it back when I first got latex.. Really should be keeping a record of changes I make&lt;/p&gt;&#xA;" OwnerUserId="14380" LastEditorUserId="14380" LastEditDate="2019-03-05T23:58:33.180" LastActivityDate="2019-03-06T15:05:56.780" Title="Stop vim-latex from autocompiling on save" Tags="|filetype-tex|plugin-vim-latex|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19066" PostTypeId="1" AcceptedAnswerId="19068" CreationDate="2019-03-02T20:14:36.027" Score="2" ViewCount="1060" Body="&lt;p&gt;I know that pressing &lt;code&gt;ZZ&lt;/code&gt; is the same as &lt;code&gt;:x&lt;/code&gt; and &lt;code&gt;ZQ&lt;/code&gt; is the same as &lt;code&gt;:q!&lt;/code&gt;; are there any others? There doesn't seem to be any around &lt;code&gt;:help ZZ&lt;/code&gt; or &lt;code&gt;:help ZQ&lt;/code&gt;, and  &lt;code&gt;:help Z&lt;/code&gt; brings up the &lt;code&gt;-Z&lt;/code&gt; flag.&lt;/p&gt;&#xA;" OwnerUserId="21195" LastActivityDate="2019-03-02T21:14:35.543" Title="Are there any commands aside from ZZ and ZQ that start with Z?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19067" PostTypeId="1" AcceptedAnswerId="19071" CreationDate="2019-03-02T20:32:41.050" Score="5" ViewCount="768" Body="&lt;p&gt;I find myself often aligning certain code blocks by inserting one or more spaces, like in the following situation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case something of&#xA;    Just a▉-&amp;gt; ...&#xA;    Nothing -&amp;gt; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;▉&lt;/code&gt; is the position of my cursor. In order to align the arrows, I enter insert mode with &lt;code&gt;i&lt;/code&gt;, hit &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. In my vim configuration the &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; key doesn't do anything meaningful, so I tried creating the following mapping, hoping that it would do the same job with just one keystroke:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Space&amp;gt; i&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In case of one space character this works without any problems, and even repeating with &lt;code&gt;.&lt;/code&gt; works. However, &lt;code&gt;3&amp;lt;Space&amp;gt;&lt;/code&gt; won't insert 3 spaces without moving the cursor. With the help of this &lt;a href=&quot;https://vim.fandom.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_2)#Supplying_a_count_to_a_map&quot; rel=&quot;noreferrer&quot;&gt;Vim Tips wiki&lt;/a&gt; article, I made the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Space&amp;gt; @=&quot;i\&amp;lt;lt&amp;gt;Space&amp;gt;\&amp;lt;lt&amp;gt;Esc&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This successfully inserts &lt;code&gt;n&lt;/code&gt; number of spaces with &lt;code&gt;n&amp;lt;Space&amp;gt;&lt;/code&gt;, but the problem is that I cannot repeat &lt;code&gt;n&amp;lt;Space&amp;gt;&lt;/code&gt; with &lt;code&gt;.&lt;/code&gt;. I would like to make this repeatable in a way, that when I first insert 2 spaces with &lt;code&gt;2&amp;lt;Space&amp;gt;&lt;/code&gt; and hit the repeat operation &lt;code&gt;.&lt;/code&gt;, it would insert 2 spaces again instead of one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My knowledge of Vimscript is very limited, but I suppose one could write such mapping with help of a function, and use a plugin like &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;noreferrer&quot;&gt;repeat&lt;/a&gt; to do the repetition part? Or is this possible to do without any plugins?&lt;/p&gt;&#xA;" OwnerUserId="21196" LastActivityDate="2019-03-03T15:20:42.507" Title="Creating a repeatable mapping in Vim" Tags="|vimscript|key-bindings|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19068" PostTypeId="2" ParentId="19066" CreationDate="2019-03-02T21:14:35.543" Score="1" Body="&lt;p&gt;According to &lt;code&gt;:help index&lt;/code&gt;, no: &lt;code&gt;ZZ&lt;/code&gt; and &lt;code&gt;ZQ&lt;/code&gt; are the only two. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-02T21:14:35.543" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19069" PostTypeId="1" AcceptedAnswerId="19073" CreationDate="2019-03-02T23:09:28.693" Score="2" ViewCount="790" Body="&lt;p&gt;I mostly use MacVim, but sometimes I'm in the terminal and use the CLI vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently decided to clean up my vimrc file, retaining only what I knew I wanted. It works fine with MacVim, but when I launch &lt;code&gt;vim&lt;/code&gt; from the terminal, it works, but does two things MacVim doesn't:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Beeps&lt;/li&gt;&#xA;&lt;li&gt;Places me in Replace mode&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/users/10604/d-ben-knoble&quot;&gt;D. Ben Knoble&lt;/a&gt; helped me track down that it has to do with the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;ESC&amp;gt; :nohlsearch&amp;lt;RETURN&amp;gt;&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I remove that line, the problem does disappear. But I do like the behavior it gives me (removing highlighted searches when I hit &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, why does that line cause the problem, and is there a way to get what I want with it that doesn't cause a problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my &lt;a href=&quot;https://github.com/chivalry/vimrc/blob/master/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimrc file on GitHub&lt;/a&gt;: &lt;/p&gt;&#xA;" OwnerUserId="942" LastEditorUserId="942" LastEditDate="2019-03-03T00:25:30.490" LastActivityDate="2024-03-28T23:06:53.277" Title="Why does terminal vim enter replace mode with my vimrc file?" Tags="|vimrc|terminal|macos|" AnswerCount="1" CommentCount="9" ClosedDate="2020-12-05T18:49:07.017" ContentLicense="CC BY-SA 4.0" />
  <row Id="19070" PostTypeId="2" ParentId="19067" CreationDate="2019-03-03T08:10:35.430" Score="1" Body="&lt;p&gt;You could use &lt;code&gt;`[&lt;/code&gt; to return &quot;to the first character of the previously changed or yanked text&quot; (from &lt;code&gt;:help `[&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Space&amp;gt; i&amp;lt;Space&amp;gt;&amp;lt;esc&amp;gt;`[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works with &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; and &lt;code&gt;3&amp;lt;Space&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Flaw: If you do &lt;code&gt;3&amp;lt;Space&amp;gt;&lt;/code&gt; and you want to add another three spaces with &lt;code&gt;.&lt;/code&gt;, the cursor will move. From my understanding, this is because with &lt;code&gt;.&lt;/code&gt; Vim repeats the change (inserting 3 spaces), but not the mapping. A following &lt;code&gt;`[&lt;/code&gt; will bring the cursor back to the initial position.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-03T08:39:22.903" LastActivityDate="2019-03-03T08:39:22.903" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19071" PostTypeId="2" ParentId="19067" CreationDate="2019-03-03T15:20:42.507" Score="6" Body="&lt;p&gt;You can create repeatable mappings by passing them through &lt;code&gt;g@&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:insspace(...)&#xA;  if a:0&#xA;    &quot; perform operation&#xA;    execute 'normal' v:count1.'i '.&quot;\&amp;lt;esc&amp;gt;&quot;.'`['&#xA;  else&#xA;    &quot; set up&#xA;    let &amp;amp;operatorfunc = matchstr(expand('&amp;lt;sfile&amp;gt;'), '[^. ]*$')&#xA;    return &quot;g@\&amp;lt;space&amp;gt;&quot;&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;space&amp;gt; &amp;lt;sid&amp;gt;insspace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Normally &lt;code&gt;g@&lt;/code&gt; is used for operators, but by using &lt;code&gt;g@&amp;lt;space&amp;gt;&lt;/code&gt;, this makes it an actual operation.  The function here &lt;code&gt;s:insspace&lt;/code&gt; actually called twice, once with no arguments meaning &quot;set up,&quot; which sets the &lt;code&gt;operatorfunc&lt;/code&gt; option to itself (the complicated-looking &lt;code&gt;matchstr&lt;/code&gt;), and again by vim with one argument (see &lt;code&gt;:help g@&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This approach is general.  To use a different operation you only need to change the line after the comment &quot;perform operation.&quot;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-03-03T15:20:42.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19072" PostTypeId="2" ParentId="19045" CreationDate="2019-03-03T16:26:36.860" Score="2" Body="&lt;h2&gt;With &lt;code&gt;relativenumber&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Turn on &lt;code&gt;relativenumber&lt;/code&gt; with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set relativenumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, your test case is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1  [&#xA;0      (Text),&#xA;1      (Text),&#xA;2      (Text), &#xA;3  ],&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, the numbers on the left side are not part of the text, it's simple line numbers. See &lt;code&gt;:h rnu&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, perform the following actions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Move the cursor to first &lt;code&gt;T&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Enable &lt;code&gt;visual-block&lt;/code&gt; mode with &lt;code&gt;Ctrl-V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;2j&lt;/code&gt; to go 2 line down vertically to the desired &lt;code&gt;T&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;With searching&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Your text case looks like the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&#xA;    (Text),&#xA;    (Text),&#xA;    (Text), &#xA;],&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, perform the following actions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Take the cursor to the first &lt;code&gt;T&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Enter &lt;code&gt;visual-block&lt;/code&gt; mode with &lt;code&gt;Ctrl-V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Search forward for &lt;code&gt;T&lt;/code&gt; with &lt;code&gt;/T&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Go to the next &lt;code&gt;T&lt;/code&gt; with &lt;code&gt;&amp;lt;Ctrl-G&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But I'm guessing what you really want is select the whole column within the indentation. So a more general approach would be the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Take the cursor to the first &lt;code&gt;T&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Enter &lt;code&gt;visual-block&lt;/code&gt; mode with &lt;code&gt;Ctrl-V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Jump to the last line with &lt;code&gt;}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Search backward for &lt;code&gt;T&lt;/code&gt; with &lt;code&gt;?T&amp;lt;Enter&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Explanation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In case of using &lt;code&gt;relativenumber&lt;/code&gt;, the important part is what vim considers &lt;code&gt;jumps&lt;/code&gt;, see &lt;code&gt;:h jump-motions&lt;/code&gt;. When you pressed &lt;code&gt;}&lt;/code&gt; as you stated in your question, the cursor moved to the first (virtual) column. It may seem like it happened because there is simple no other characters in that line so the cursor had no way to maintain it's column number. But this is the case with all other jump-motions. Vim doesn't consider &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt; as jump-motions. So, if you use &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt; to move around in visual-block mode, your (virtual) column position will be maintained.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case of searching, you're necessarily directed the cursor where to go manually. So, it's a more rigorous process and only to come into play if you're hardfast not to use &lt;code&gt;relativenumber&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-03T16:44:30.840" LastActivityDate="2019-03-03T16:44:30.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19073" PostTypeId="2" ParentId="19069" CreationDate="2019-03-04T00:16:11.833" Score="5" Body="&lt;p&gt;&lt;em&gt;If you are seeing a similar issue and using Windows Terminal jump down to the &amp;quot;Update&amp;quot; below.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Seeing &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; used as the LHS of a key mapping causes me some discomfort. You've demonstrated one reason why...it doesn't seem to work right in a vimrc file. It doesn't matter what you have on the RHS, the LHS &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; causes some characters (maybe related to the underlying key code for &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;) to be emitted as if they were Normal mode commands and those include &lt;code&gt;2R&lt;/code&gt;. (If you type something right after entering Vim and hit escape you'll see the typed string replace current text twice.)&lt;/p&gt;&#xA;&lt;p&gt;My first bit of advice would be to save the headaches and use a different key for mapping. If you really want to use &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; then continue...&lt;/p&gt;&#xA;&lt;p&gt;My first instinct while trying to fix things was to use an &lt;code&gt;autocommand&lt;/code&gt; to delay the setup of the mapping but that doesn't help. It's still in the context that doesn't play nice with LHS &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;My second notion was to also use an &lt;code&gt;autocommand&lt;/code&gt; but with an asynchronous call since these calls occur in a different context (i.e. when Vim's thread has entered an idle state). Turns out, it works...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func! EscMapSetup(timerid)&#xA;    nnoremap &amp;lt;ESC&amp;gt; :nohlsearch&amp;lt;CR&amp;gt;&amp;lt;ESC&amp;gt;&#xA;endfunc&#xA;&#xA;autocmd VimEnter * call timer_start(100, 'EscMapSetup')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Has that hack smell to it but if someone can't come up with the root cause of this issue and a clean way around it this isn't too bad...at least it doesn't require any particular timing; the 100ms above is an arbitrarily chosen number of short duration.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;BTW&lt;/strong&gt;...&#xA;What is the purpose of the &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; on the RHS of the mapping? You're already in Normal mode so it doesn't do anything there. Only thing I can think of is you want to clear the command line of the &lt;code&gt;nohlsearch&lt;/code&gt; text that lingers there. If so, consider using &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; in it's place. That will redraw the screen after cleaning it...that leaves a pristine c/l...and no more flirting with problems that the special status of &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; sometimes bears.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;2020-12-05 Update:&lt;/strong&gt; Per the numerous comments below &lt;a href=&quot;https://vi.stackexchange.com/questions/28269/command-already-typed-in-when-i-open-vim&quot;&gt;Command already typed in when I open vim&lt;/a&gt; there is a bug, since fixed and released in September, in the Windows Terminal terminal emulator.&lt;/p&gt;&#xA;&lt;p&gt;You can either get the latest version of WT or you can try an alternate terminal emulator. I personally use and like mintty.&lt;/p&gt;&#xA;&lt;p&gt;There is also a workaround that appears to be benign: &lt;code&gt;:set t_u7=&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;In short the problem is how WT handles the control sequence contained in &lt;code&gt;'t_u7'&lt;/code&gt;. This control sequence, valid only for xterm-compatible terminal emulators, is used to get the cursor's position. Vim sends the sequence to the terminal on startup under certain conditions (i.e. if using utf-8 &lt;code&gt;'encoding'&lt;/code&gt; or similar) to find out how wide characters are represented. When WT responds it mixes the answer with the response to a separate control sequence such that individual characters are intermingled rendering the whole thing invalid and causing Vim to think it's normal user input. It so happens that the last two characters are &lt;em&gt;usually&lt;/em&gt; &lt;code&gt;2R&lt;/code&gt; which explains why things behave as if you entered that Normal mode command.&lt;/p&gt;&#xA;&lt;p&gt;See also&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/microsoft/terminal/issues/1637&quot; rel=&quot;nofollow noreferrer&quot;&gt;Windows Terminal bug details&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim/issues/6365&quot; rel=&quot;nofollow noreferrer&quot;&gt;Original defect filed against Vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2024-03-28T23:06:53.277" LastActivityDate="2024-03-28T23:06:53.277" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19074" PostTypeId="1" AcceptedAnswerId="19076" CreationDate="2019-03-04T02:10:52.630" Score="0" ViewCount="84" Body="&lt;p&gt;Yes, I know that &lt;code&gt;d2e&lt;/code&gt; and &lt;code&gt;2de&lt;/code&gt; are two different commands and therefore works slightly different, though it's not visible to the eyes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's call them &quot;number-in-the-middle&quot; (nim) and &quot;number-in-the-beginning&quot; (nib). As I know, some commands doesn't work with nim syntax, but successfully works with nib one. So, is it a good idea (for newbies) to get rid of nim syntax and stick to nib, to have consistent behavior across all commands? And are there any commands that doesn't support nib syntax?&lt;/p&gt;&#xA;" OwnerUserId="7200" LastActivityDate="2019-03-04T03:26:00.667" Title="Number in the beginning vs. number in the end" Tags="|cursor-motions|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19075" PostTypeId="1" CreationDate="2019-03-04T03:15:47.117" Score="2" ViewCount="975" Body="&lt;p&gt;I am working on a machine where I do not have root access, and I do not like some of the global vim settings (in &lt;code&gt;/etc/vimrc.local&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I disable these in my personal &lt;code&gt;.vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, the global file has many&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType XXX setlocal ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which differ from my preferences. Besides redefining every filetype in my local file, is there any other way to fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; more information:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant portion of &lt;code&gt;/etc/vimrc.local&lt;/code&gt; is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot; indentation schema&#xA;set autoindent              &quot; enable automatic indentation&#xA;&quot; set default indentation scheme&#xA;filetype plugin indent on   &quot; indent based on filetype&#xA;set tabstop=2&#xA;set shiftwidth=2&#xA;set expandtab               &quot; insert spaces instead of tab&#xA;&quot; set language-specific indentation schema&#xA;if has(&quot;autocmd&quot;)&#xA;  &quot; use real tabs in Makefiles&#xA;  autocmd FileType make setlocal tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab&#xA;  &quot; indentation is tab/width=8,4 in C's KNF style&#xA;  autocmd FileType c setlocal tabstop=8 shiftwidth=8 softtabstop=4 noexpandtab&#xA;  autocmd FileType cpp setlocal tabstop=8 shiftwidth=8 softtabstop=4 noexpandtab&#xA;  &quot; indentation is two spaces in Ruby&#xA;  autocmd FileType ruby setlocal tabstop=2 shiftwidth=2 expandtab&#xA;  &quot; indentation for shell scripts&#xA;  autocmd FileType sh setlocal tabstop=2 shiftwidth=2 expandtab&#xA;  &quot; indentation is four spaces in python - also set by python.vim&#xA;  autocmd FileType python setlocal tabstop=4 shiftwidth=4 expandtab&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my case, I don't like the &lt;code&gt;c&lt;/code&gt;/&lt;code&gt;cpp&lt;/code&gt; rules defined here; I'm wondering what I can put in my &lt;code&gt;.vimrc&lt;/code&gt; to override. Currently, my &lt;code&gt;.vimrc&lt;/code&gt; has&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=2&#xA;set shiftwidth=2&#xA;set autoindent&#xA;set expandtab &quot; spaces instead of tabs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the &lt;code&gt;autocmd&lt;/code&gt; options are taking precedence.&lt;/p&gt;&#xA;" OwnerUserId="19829" LastEditorUserId="19829" LastEditDate="2019-03-04T04:47:29.817" LastActivityDate="2019-08-02T11:00:55.427" Title="override /etc/vimrc.local" Tags="|vimrc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19076" PostTypeId="2" ParentId="19074" CreationDate="2019-03-04T03:26:00.667" Score="0" Body="&lt;p&gt;As far as built-in operators and motions go, they are completely identical.  There is some semantic value; &quot;delete to 2 ends of words&quot; vs &quot;twice, delete to end of word,&quot; but from vim's perspective there is only a single count for the operator+motion.  You can provide both if you wish:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;2d2e&lt;/code&gt; means delete 4 to end.  The rule is that vim multiplies each given number to produce the count (which is 4).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In fact, you can use even more with registers:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;2&quot;ade&lt;/code&gt; &lt;code&gt;2de&lt;/code&gt;, but place in register &lt;code&gt;a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;a2de&lt;/code&gt; identical to above&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;ad2e&lt;/code&gt; identical to above&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2&quot;a2d2e&lt;/code&gt;, delete to 8 ends of words, placing in register &lt;code&gt;a&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Similarly, with puts from a register, you can specify multiple counts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;2&quot;a2p&lt;/code&gt; paste four times from reigster &lt;code&gt;p&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2&quot;a2&quot;a2&quot;a2&quot;ap&lt;/code&gt; paste 16 times from register &lt;code&gt;p&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some commands, despite not being operators or motions do support &quot;middle&quot; count.  The primary example is the &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; family of window commands.  &lt;code&gt;2&amp;lt;c-w&amp;gt;2w&lt;/code&gt; means go to window 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some caveats though:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;some operators are multiple characters, like &lt;code&gt;gu&lt;/code&gt;.  You can write &lt;code&gt;2gue&lt;/code&gt; or &lt;code&gt;gu2e&lt;/code&gt;, but not &lt;code&gt;g2ue&lt;/code&gt;, since the operator is &lt;code&gt;gu&lt;/code&gt; as a unit.&lt;/li&gt;&#xA;&lt;li&gt;some motions and text objects are multiple characters.  &lt;code&gt;d2iw&lt;/code&gt; is fine, but &lt;code&gt;di2w&lt;/code&gt; is meaningless.  &lt;code&gt;d2gj&lt;/code&gt; is good, but &lt;code&gt;dg2j&lt;/code&gt; is not.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;custom maps can break.  Let's say you make the map&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;space&amp;gt; 2w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;2d&amp;lt;space&amp;gt;&lt;/code&gt; works exactly as you expect: it deletes four words.  However, &lt;code&gt;d2&amp;lt;space&amp;gt;&lt;/code&gt; means &lt;code&gt;d22w&lt;/code&gt;!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-03-04T03:26:00.667" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19077" PostTypeId="1" CreationDate="2019-03-04T07:46:25.000" Score="0" ViewCount="781" Body="&lt;p&gt;I have problems using YCM plugged for C-family languages.&#xA;Here are what I have done:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;project layout&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- build&#xA;-- src&#xA;   -- source file dir0&#xA;      -- include&#xA;      main.cpp&#xA;   -- source file dir1&#xA;      -- include&#xA;         -- dir1.h&#xA;      -- dir1.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;generate compile database running command on windows in directory build as below.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..\src\ -G &quot;MinGW Makefiles&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;copy compile_commands.json to directory src.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I also generate configure file to src/.ycm_extra_conf.py with contents as below.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;flags = [&#xA;    '-x',&#xA;    'c++',&#xA;    '-I',&#xA;    'dir1/include',&#xA;]&#xA;&#xA;&#xA;def Settings(**kwargs):&#xA;    return {'flags': flags}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I compiled both &lt;em&gt;clangd&lt;/em&gt; and &lt;em&gt;libclang&lt;/em&gt; during installation.&#xA;Since &lt;em&gt;clangd&lt;/em&gt; is default selected by YCM, I switch &lt;em&gt;clangd&lt;/em&gt; and &lt;em&gt;libclang&lt;/em&gt; by manipulating vimrc setting  &lt;em&gt;ycm_use_clangd&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After doing all these above,&#xA;The completion and syntax checking seem not working at all.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;dir1.h&quot;  ==&amp;gt; diagnosed as header file not FOUND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And those functions and variables defined in dir1.h are diagnosed as undefined.&lt;/p&gt;&#xA;" OwnerUserId="16803" LastEditorUserId="16803" LastEditDate="2019-03-04T10:28:47.687" LastActivityDate="2019-03-04T10:28:47.687" Title="YCM is not working with .ycm_extra_conf nor compile_comands.json on Windows" Tags="|vimrc|vim-windows|plugin-you-complete-me|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19078" PostTypeId="1" AcceptedAnswerId="19079" CreationDate="2019-03-04T09:43:38.370" Score="6" ViewCount="2351" Body="&lt;p&gt;I have completely clean &lt;code&gt;vimrc&lt;/code&gt;, no plugins, and the following test file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar baz baz baz baz baz baz&#xA;baz baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I press &lt;kbd&gt;/&lt;/kbd&gt; to start search, then type &lt;code&gt;baz&lt;/code&gt;, press &lt;kbd&gt;Enter&lt;/kbd&gt;, press &lt;kbd&gt;n&lt;/kbd&gt; twice. It will move me to the beginning of 3rd &lt;code&gt;baz&lt;/code&gt;. Then I press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;O&lt;/kbd&gt; and it will move me to the beginning of 2nd &lt;code&gt;baz&lt;/code&gt;. But then, if I try to press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;I&lt;/kbd&gt;, nothing happens!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is jumplist not being updated properly with each search?&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="16280" LastEditDate="2019-03-04T13:56:17.173" LastActivityDate="2019-03-04T13:56:17.173" Title="How does Ctrl-I works?" Tags="|cursor-motions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19079" PostTypeId="2" ParentId="19078" CreationDate="2019-03-04T10:11:53.360" Score="6" Body="&lt;p&gt;From &lt;code&gt;:h jump-motions&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;8. Jumps                    *jump-motions*&#xA;&#xA;A &quot;jump&quot; is a command that normally moves the cursor several lines away.  If&#xA;you make the cursor &quot;jump&quot; the position of the cursor before the jump is&#xA;remembered.  You can return to that position with the &quot;''&quot; and &quot;``&quot; command,&#xA;unless the line containing that position was changed or deleted.  The&#xA;following commands are &quot;jump&quot; commands: &quot;'&quot;, &quot;`&quot;, &quot;G&quot;, &quot;/&quot;, &quot;?&quot;, &quot;n&quot;, &quot;N&quot;,&#xA;&quot;%&quot;, &quot;(&quot;, &quot;)&quot;, &quot;[[&quot;, &quot;]]&quot;, &quot;{&quot;, &quot;}&quot;, &quot;:s&quot;, &quot;:tag&quot;, &quot;L&quot;, &quot;M&quot;, &quot;H&quot; and the&#xA;commands that start editing a new file. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, the important part is, &lt;strong&gt;A &quot;jump&quot; is a command that normally moves the cursor several lines away&lt;/strong&gt;. Even though &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; are jump-motions, i.e. invoking these keys will edit &lt;code&gt;jumplist&lt;/code&gt;, if the next/previous search result is on the same line as the cursor was on prior to invoking the key, the jump-cursor is simply moved down to a new line effectively stating that you're currently on a line not listed in the &lt;code&gt;jumplist&lt;/code&gt;. This is the case no matter where the jump-cursor was previously on. For example, if the &lt;code&gt;jumplist&lt;/code&gt; is in following state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is the text of test case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo bar baz baz baz baz baz baz&#xA;baz baz&#xA;foo bar baz baz baz baz baz baz&#xA;foo bar baz baz baz baz baz baz&#xA;foo bar baz baz baz baz baz baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Following is output of &lt;code&gt;:jumps&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; jump line  col file/text&#xA;   1     2    0 baz baz&#xA;&amp;gt;  0     1    8 foo bar baz baz baz baz baz baz&#xA;   1     3   12 foo bar baz baz baz baz baz baz&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, if you use &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;N&lt;/code&gt;, so that the cursor goes to next or previous search result but stays in same line, the &lt;code&gt;jumplist&lt;/code&gt; will be edited to be in the following state:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; jump line  col file/text&#xA;   3     2    0 baz baz&#xA;   2     3   12 foo bar baz baz baz baz baz baz&#xA;   1     1    0 foo bar baz baz baz baz baz baz&#xA;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, if you do &lt;code&gt;Ctrl-I&lt;/code&gt;, nothing will happen; if you do &lt;code&gt;Ctrl-O&lt;/code&gt;, you'll move back in &lt;code&gt;jumplist&lt;/code&gt;. I don't know if there is a reasoning behind this, but it is what seems to be happening.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-03-04T10:11:53.360" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19081" PostTypeId="1" AcceptedAnswerId="19083" CreationDate="2019-03-05T02:53:59.487" Score="1" ViewCount="44" Body="&lt;p&gt;I've installed the vim by homebrew, current version and installation information is as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 19 2019 11:57:49)&#xA;macOS version&#xA;Included patches: 1-950&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               +extra_search      +mouse_netterm     +tag_old_static&#xA;+arabic            -farsi             +mouse_sgr         -tag_any_white&#xA;+autocmd           +file_in_path      -mouse_sysmouse    -tcl&#xA;+autochdir         +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       +terminal&#xA;-balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;-browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    +gettext           +netbeans_intg     +textprop&#xA;+byte_offset       -hangul_input      +num64             +timers&#xA;+channel           +iconv             +packages          +title&#xA;+cindent           +insert_expand     +path_extra        -toolbar&#xA;-clientserver      +job               +perl              +user_commands&#xA;+clipboard         +jumplist          +persistent_undo   +vartabs&#xA;+cmdline_compl     +keymap            +postscript        +vertsplit&#xA;+cmdline_hist      +lambda            +printer           +virtualedit&#xA;+cmdline_info      +langmap           +profile           +visual&#xA;+comments          +libcall           -python            +visualextra&#xA;+conceal           +linebreak         +python3           +viminfo&#xA;+cryptv            +lispindent        +quickfix          +vreplace&#xA;+cscope            +listcmds          +reltime           +wildignore&#xA;+cursorbind        +localmap          +rightleft         +wildmenu&#xA;+cursorshape       +lua               +ruby              +windows&#xA;+dialog_con        +menu              +scrollbind        +writebackup&#xA;+diff              +mksession         +signs             -X11&#xA;+digraphs          +modify_fname      +smartindent       -xfontset&#xA;-dnd               +mouse             +startuptime       -xim&#xA;-ebcdic            -mouseshape        +statusline        -xpm&#xA;+emacs_tags        +mouse_dec         -sun_workshop      -xsmp&#xA;+eval              -mouse_gpm         +syntax            -xterm_clipboard&#xA;+ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -lintl -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.13 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.28.1/lib/perl5/5.28.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation  -lruby.2.6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After I mapped some key to Escape key like &lt;code&gt;:inoremap qq &amp;lt;Esc&amp;gt;&lt;/code&gt;, when I pressed &lt;code&gt;qq&lt;/code&gt;, text &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; input, instead of quiting insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, when I followed the guide of &lt;code&gt;:help keycodes&lt;/code&gt;, pressing &lt;code&gt;Ctrl&lt;/code&gt;+&lt;code&gt;K&lt;/code&gt; to complete keycode while setting the key map, nothing happened if I pressed Escape key (however worked for backspace, turned into &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="21218" LastActivityDate="2019-03-05T06:35:26.830" Title="Cannot map some key to Escape key in insert mode" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19082" PostTypeId="1" CreationDate="2019-03-05T06:09:44.663" Score="0" ViewCount="2862" Body="&lt;p&gt;I have Fugitive vim and Airline vim installed via Vundle. I installed them as follow: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'https://github.com/tpope/vim-fugitive.git'&#xA;Plugin 'vim-airline/vim-airline'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Airline status works fine.  All of the functions in Fugitive works fine, such as Gcommit, Gpush... Now, I just want to have the name of the branch shows up on Airline. I've been searching around a lot, and most of the time, the problem is that doing &lt;code&gt;:echo fugitive#head()&lt;/code&gt; does not show the correct branch.  Mine works.  It shows the correct branch. So, how to get it shows up in Vim Airline status bar? I tried: 152 let &lt;code&gt;g:airline#extensions#branch#enabled = 1&lt;/code&gt;, this does not work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I even tried to clean up entire .vim and .vimrc (start fresh from zero) and reinstalled Vundle, Fugitive, Airline... Still, the same problem occurs. What else do I need to add to my vimrc to make this works?  Please let me know and thank you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The .vimrc is as follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'https://github.com/Valloric/YouCompleteMe.git'  &#xA;Plugin 'https://github.com/ajh17/VimCompletesMe.git'&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'https://github.com/tomasiser/vim-code-dark.git'&#xA;Plugin 'https://github.com/tpope/vim-fugitive.git' &#xA;Plugin 'https://github.com/scrooloose/nerdcommenter.git' &#xA;&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&quot; To ignore plugin indent changes, instead use:&#xA;&quot;filetype plugin on&#xA;&quot;&#xA;&quot; Brief help&#xA;&quot; :PluginList       - lists configured plugins&#xA;&quot; :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate&#xA;&quot; :PluginSearch foo - searches for foo; append `!` to refresh local cache&#xA;&quot; :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal&#xA;&quot;&#xA;&quot; see :h vundle for more details or wiki for FAQ&#xA;&quot; Put your non-Plugin stuff after this line    &#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;  KEY MAPPINGS &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;  &#xA;&#xA;&quot;To resize split&#xA;nnoremap &amp;lt;C-Right&amp;gt; &amp;lt;C-W&amp;gt;&amp;gt;&#xA;nnoremap &amp;lt;C-Left&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;&#xA;&#xA;nnoremap &amp;lt;C-Down&amp;gt;  :exe &quot;resize &quot; . (winheight(0) * 3/2)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-Up&amp;gt;  :exe &quot;resize &quot; . (winheight(0) * 2/3)&amp;lt;CR&amp;gt;&#xA;&#xA;&#xA;&quot;Move between splits   &#xA;&#xA;nnoremap &amp;lt;C-J&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-J&amp;gt;&#xA;nnoremap &amp;lt;C-K&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-K&amp;gt;&#xA;nnoremap &amp;lt;C-L&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-L&amp;gt;&#xA;nnoremap &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-H&amp;gt;&#xA;&#xA;&quot;Move between tabs &#xA;&#xA;map &amp;lt;C-t&amp;gt;&amp;lt;up&amp;gt; :tabr&amp;lt;cr&amp;gt;&#xA;&#xA;map &amp;lt;C-t&amp;gt;&amp;lt;down&amp;gt; :tabl&amp;lt;cr&amp;gt;&#xA;&#xA;map &amp;lt;C-t&amp;gt;&amp;lt;left&amp;gt; :tabp&amp;lt;cr&amp;gt;&#xA;&#xA;map &amp;lt;C-t&amp;gt;&amp;lt;right&amp;gt; :tabn&amp;lt;cr&amp;gt;&#xA;&#xA;&quot;Buffer maps&#xA;:nnoremap &amp;lt;C-n&amp;gt; :bnext&amp;lt;CR&amp;gt;&#xA;:nnoremap &amp;lt;C-p&amp;gt; :bprevious&amp;lt;CR&amp;gt;&#xA;&#xA;&#xA;map &amp;lt;F12&amp;gt; :!sh -xc 'clear &amp;amp;&amp;amp; gfortran shocktest.f95 &amp;amp;&amp;amp; ./a.out' &amp;lt;enter&amp;gt;&#xA;&#xA;map &amp;lt;F8&amp;gt; :!sh -xc 'gnuplot shockplot &amp;amp;&amp;amp;  eog --fullscreen RHO.png ' &amp;lt;enter&amp;gt;   &#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;  THEMES  &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;  &#xA;&#xA;colo codedark &#xA;set cursorline &#xA;hi MatchParen cterm=bold ctermbg=yellow ctermfg=red&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot; AIRLINE STUFF &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&#xA;let g:airline_theme='codedark'&#xA;let g:airline_section_b = '%{strftime(&quot;%I:%M %p&quot;)}'&#xA;let g:airline#extensions#branch#enabled = 1&#xA;&#xA;&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot; FORTRAN STUFF &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&#xA;&quot; Ensure correct highlighting for&#xA;&quot; Fortran free-form source code&#xA;&quot; and turn syntax highlighting on&#xA;let fortran_free_source=1&#xA;let fortran_do_enddo=1&#xA;filetype plugin indent on&#xA;syntax on&#xA;&#xA;&quot; Turn on line numbers and&#xA;&quot; row/column numbers&#xA;set nu&#xA;set ruler&#xA;&#xA;&quot; Make vim echo commands as they&#xA;&quot; are being entered.&#xA;set showcmd&#xA;&#xA;&quot; Set tabstops to two spaces&#xA;&quot; and ensure tab characters are&#xA;&quot; expanded into spaces.&#xA;set smarttab&#xA;set expandtab&#xA;set tabstop=2&#xA;set shiftwidth=2&#xA;&#xA;&quot; Fix backspace key&#xA;set bs=2&#xA;&#xA;&quot; Set up searching so&#xA;&quot; that it jumps to matches&#xA;&quot; as the word is being&#xA;&quot; entered and is case-insensitive&#xA;set incsearch&#xA;set ignorecase&#xA;set smartcase&#xA;&#xA;&quot; Uncomment the following lines to make&#xA;&quot; vim automatically create a backup copy&#xA;&quot; each time a file is edited.&#xA;&quot;&#xA;&quot; If you enable this feature, be sure to&#xA;&quot;&#xA;&quot;   mkdir ~/codeBackups&#xA;&quot;&#xA;&quot; or it won't work.&#xA;&quot;set backupdir=~/codeBackups&#xA;&quot;set backup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21038" LastEditorUserId="21038" LastEditDate="2019-03-05T07:18:18.510" LastActivityDate="2023-06-05T20:08:06.027" Title="Vim Airline no GitBranch name [doing echo fugitive#head() shows correct branch]" Tags="|vimrc|git|plugin-airline|plugin-fugitive|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="19083" PostTypeId="2" ParentId="19081" CreationDate="2019-03-05T06:35:26.830" Score="0" Body="&lt;p&gt;OK, it turns out to be the default option &lt;code&gt;compatible&lt;/code&gt; of my homebrew installed vim is &lt;code&gt;compatible&lt;/code&gt;, and somehow this option has impact with this &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's working well when &lt;code&gt;nocompatible&lt;/code&gt; is set&lt;/p&gt;&#xA;" OwnerUserId="21218" LastActivityDate="2019-03-05T06:35:26.830" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19084" PostTypeId="2" ParentId="19075" CreationDate="2019-03-05T06:44:32.247" Score="1" Body="&lt;p&gt;The only &quot;clean&quot; way I see, is to replicate the autocmds in your own setup and correct the option values with them (you already mentioned that in the comments). Autocmds for the same event (here &lt;code&gt;FileType&lt;/code&gt;) are executed in the order they are defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you have to add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType c setlocal ....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you have contact to the person(s) responsible for &lt;code&gt;/etc/vimrc.local&lt;/code&gt;? If yes, you could ask them to wrap the autocmds in a &lt;code&gt;augroup&lt;/code&gt; like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;autocmd&quot;)&#xA;  augroup vimrc_local&#xA;    &quot; use real tabs in Makefiles&#xA;    autocmd FileType make setlocal tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab&#xA;    ...&#xA;  augroup END&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now all the autocmds from &lt;code&gt;vimrc.local&lt;/code&gt; are grouped under &lt;code&gt;vimrc_local&lt;/code&gt;. With that you could add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! vimrc_local&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will delete all autocmds from the group &lt;code&gt;vimrc_local&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Could I use &lt;code&gt;autocmd!&lt;/code&gt; without a &lt;code&gt;augroup&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, but this will delete all autocommands in the &quot;default&quot; group. The docs (&lt;code&gt;:help autocmd-remove&lt;/code&gt;) contains warnings like:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; You should normally not do this without a group, it breaks plugins, syntax highlighting, etc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;might&lt;/em&gt; get away with it, if you use it as the first command in your &lt;code&gt;vimrc&lt;/code&gt; and no plugins or syntax settings are in the global &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could test yourself with the following.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open Vim and execute &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put =execute('autocmd')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will put all defined autocmds into the current buffer. Save it as &lt;code&gt;a1&lt;/code&gt; and exit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add &lt;code&gt;autocmd!&lt;/code&gt; as the first line in your &lt;code&gt;vimrc&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again open Vim and execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put =execute('autocmd')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Save the buffer as &lt;code&gt;a2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can diff &lt;code&gt;a1&lt;/code&gt; and &lt;code&gt;a2&lt;/code&gt; and see which autocmds were removed. Then you decide for yourself, whether this might work for you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you see some strange behavior later on, disable the &lt;code&gt;autocmd!&lt;/code&gt; to check if that might be the reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway I would recommend to talk to the vimrc.local guys first.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-05T09:19:04.873" LastActivityDate="2019-03-05T09:19:04.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19085" PostTypeId="1" CreationDate="2019-03-05T11:03:08.270" Score="1" ViewCount="1629" Body="&lt;p&gt;When I run the &lt;code&gt;:sh&lt;/code&gt; command I see the following characters&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/D70i1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/D70i1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is relevant, my default shell is zsh and it runs oh-my-zsh also&lt;br&gt;&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="19397" LastEditorUserId="19763" LastEditDate="2019-03-05T21:26:40.643" LastActivityDate="2022-04-07T09:18:20.480" Title="Weird characters when running :shell" Tags="|gvim|shell|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19086" PostTypeId="2" ParentId="19085" CreationDate="2019-03-05T12:35:37.473" Score="3" Body="&lt;p&gt;You are doing this in GVim and this only provides a terminal with limited capabilities. The command &lt;code&gt;echo $TERM&lt;/code&gt; returns &quot;dumb&quot;. Might be your zsh /oh-my-zsh setup can't handle this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works for me (with bash) as my bash setups checks for terminal capabilities before configuring a colored PS1 or configuring colored output for &lt;code&gt;ls&lt;/code&gt; or &lt;code&gt;grep&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim 8.0.1609 added the &lt;code&gt;guioption&lt;/code&gt; &lt;code&gt;!&lt;/code&gt;, see &lt;code&gt;:help 'go-!'&lt;/code&gt;. This provides a better terminal: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set guioptions+=!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the &quot;terminal&quot; started by &lt;code&gt;:sh&lt;/code&gt; supports colors.(tested with Vim 8.1.996 on Ubuntu: &lt;code&gt;echo $TERM&lt;/code&gt; returns &quot;xterm&quot;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have Vim 8.0.747+, or better 8.1.x, you should use &lt;code&gt;:terminal&lt;/code&gt; to start a terminal window inside GVim. See &lt;code&gt;:help terminal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are on an older version of Vim, you need to change your zsh setup to work properly on a dumb terminal. Google something like &quot;zsh dumb terminal&quot; or &quot;oh-my-zsh dumb terminal&quot;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-06T06:35:45.220" LastActivityDate="2019-03-06T06:35:45.220" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19087" PostTypeId="1" AcceptedAnswerId="19114" CreationDate="2019-03-05T13:38:41.990" Score="0" ViewCount="59" Body="&lt;p&gt;Much like what was asked in &lt;a href=&quot;https://stackoverflow.com/questions/6391022/how-to-change-vim-insert-mode-mappings-behavior&quot;&gt;this question&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want Neovim to show what I type, and keep recognising it as a mapping in progress even if I use &lt;kbd&gt;Backspace&lt;/kbd&gt; or &lt;kbd&gt;Delete&lt;/kbd&gt;. This is actually a very useful function that's in &lt;code&gt;vim-latex&lt;/code&gt;, a famous plugin for LaTeX in Vim, called by the function &lt;code&gt;call IMAP()&lt;/code&gt;. Is this implementable in other filetypes and buffers of Neovim/Vim, and if so, is there an example of this being implemented publically?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT : Giving a clear example would be better for everyone, I was assured, so here goes an example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I have an insert mode mapping of the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;buffer&amp;gt; hello helloworld&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I type &lt;code&gt;hello&lt;/code&gt;, I want Vim to do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;h|&#xA;he|&#xA;hel|&#xA;hell|&#xA;hello|&#xA;helloworld|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, Vim does the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|h&#xA;|e&#xA;|l&#xA;|l&#xA;|o&#xA;helloworld|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is quite annoying since I can't know if I make a typo, and also requires me to type in very quick succession, which I am not really fond of. This, I hear, has something to do with the &lt;code&gt;ttimeout&lt;/code&gt; option, which I have next to no knowledge of. Would this be enough of an example to better understand my question? I'm sorry for the inconvenience, but I really don't have a clue of how to phrase this...&lt;/p&gt;&#xA;" OwnerUserId="20750" LastEditorUserId="20750" LastEditDate="2019-03-06T05:26:02.930" LastActivityDate="2019-03-07T00:08:40.610" Title="How to show the left-hand side of insert mode mappings while invoking them in Neovim" Tags="|key-bindings|neovim|insert-mode|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19088" PostTypeId="1" AcceptedAnswerId="19411" CreationDate="2019-03-05T15:06:36.313" Score="6" ViewCount="1461" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/d3WoM.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/d3WoM.png&quot; alt=&quot;why isn&amp;#39;t the fourth SELECT highlighted like the second one?&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I edited my original question and title to broaden its scope to any syntax - with SQL used as just an example. You can adapt the examples and the answer to other languages.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By adding suitable highlighting rules, one can make vim highlight multiple languages within the same file. This comes particularly handy for shell scripts, in which each new language block is embedded inside a &lt;a href=&quot;https://en.wikipedia.org/wiki/Here_document&quot; rel=&quot;noreferrer&quot;&gt;heredoc&lt;/a&gt;.  For instance, the above picture shows SQL within four shell heredocs.  SQL is displayed mono-color inside &lt;code&gt;EOF&lt;/code&gt; delimited heredocs, in which default highlighting rules apply, By contrast, SQL is displayed multi-color inside &lt;code&gt;SQLDOC&lt;/code&gt; delimited heredocs, in which new highlighting rules were added specific to SQL syntax elements.  We can see an issue, however: the last &lt;code&gt;SQLDOC&lt;/code&gt; heredoc is incorrectly highlighted mono-color. How can I fix this and make that block display multi-color SQL highlights?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To reproduce this issue:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Close vim and copy the highlighting file to ~/.vim/after/syntax/sh/heredoc-embed.vim (file contents below).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Start &lt;code&gt;vim ./vim-heredoc-syntax-issue.sh&lt;/code&gt; (file contents below).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;We are often instructed to start vim with &lt;code&gt;-u NONE&lt;/code&gt; to make sure that plugins don't get in the way of reproducing an issue. In this case I can't tell you so. If I use &lt;code&gt;-u NONE&lt;/code&gt; syntax highlighting will not load at all.  And I'm unable to find a sequence of vim commands that enables syntax highlighting from &lt;code&gt;-u NONE&lt;/code&gt; to my issue. I tried! but failed. So please start your vim as I explained above and hopefully you'll reproduce this issue. To make sure that it occurs in a reasonably pristine vim configuration, I took the above screenshot in a virtual machine, in which I booted a fresh copy of my Linux distribution, installed vim from the package manager, copied the &quot;heredoc-embed.vim&quot; file, and ran vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;heredoc-embed.vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This VIML code sets SQL syntax highlighting for heredoc content blocks&#xA;&quot; marked by word &amp;lt;LANGUAGE&amp;gt;DOWN, i.e. SQLDOC.&#xA;&#xA;&quot; source https://subvisual.co/blog/posts/87-smarter-heredoc-syntax-in-vim/ {{{1&#xA;&#xA;let s:bcs = b:current_syntax&#xA;&quot; this unlet instruction is needed before we load each new syntax&#xA;unlet b:current_syntax&#xA;syntax include @SQL syntax/sql.vim&#xA;&#xA;let b:current_syntax = s:bcs&#xA;&#xA;syntax region hereDocDashSQL matchgroup=Statement start=+&amp;lt;&amp;lt;\s*[-'\\]\?\z(SQLDOC\)+  end=+^\s*\z1+ contains=@SQL&#xA;&#xA;if exists(&quot;b:current_syntax&quot;)&#xA;  unlet b:current_syntax&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;vim-heredoc-syntax-issue.sh&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# colorscheme evening&#xA;&#xA;: &amp;lt;&amp;lt; EOF&#xA;    SELECT * FROM table;&#xA;EOF&#xA;: &amp;lt;&amp;lt; SQLDOC&#xA;    SELECT * FROM table;&#xA;SQLDOC&#xA;&#xA;foo() {&#xA;: &amp;lt;&amp;lt; EOF&#xA;    SELECT * FROM table;&#xA;EOF&#xA;: &amp;lt;&amp;lt; SQLDOC&#xA;    SELECT * FROM table;&#xA;SQLDOC&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Similar questions I found on SE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/9387/how-do-i-enable-language-specific-syntax-inside-a-heredoc&quot;&gt;How do I enable language-specific syntax inside a heredoc?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'd rather fix mine because the regular expressions are simpler.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/8025/how-can-i-fix-the-default-bash-syntax-highlighter&quot;&gt;How can I fix the default bash syntax highlighter?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Maybe Dr Chip can tell me?&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/6867/highlight-heredoc-as-perl-code&quot;&gt;Highlight heredoc as perl code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My formula but for Perl heredoc.&lt;/p&gt;&#xA;" OwnerUserId="1634" LastEditorUserId="1634" LastEditDate="2019-03-31T12:17:24.583" LastActivityDate="2019-04-03T05:11:16.137" Title="Highlighting another syntax in a shell heredoc" Tags="|syntax-highlighting|filetype-sh|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19089" PostTypeId="1" AcceptedAnswerId="19091" CreationDate="2019-03-05T15:16:03.413" Score="2" ViewCount="111" Body="&lt;p&gt;Some vim plugins provides functions especially designed to be used for statusline rendering. For example, in my &lt;code&gt;.vimrc&lt;/code&gt; I create the status line format string like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;set statusline+=%{SyntasticStatuslineFlag()}&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and status line of my windows contain some summary of problems detected by Syntastic plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the problem is that on some of my machines the Syntastic plugin is not installed. The statusline on the machines w/o the plugin should not contain the &lt;code&gt;SyntasticStatuslineFlag()&lt;/code&gt; call, but I still want to use my standard &lt;code&gt;.vimrc&lt;/code&gt; on all my machines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't check availability of the function in &lt;code&gt;.vimrc&lt;/code&gt; because at the time &lt;code&gt;.vimrc&lt;/code&gt; is processed plugins are not loaded yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to construct statusline in &lt;code&gt;.vimrc&lt;/code&gt; and avoid this problem?&lt;/p&gt;&#xA;" OwnerUserId="6194" LastActivityDate="2019-03-05T17:17:10.263" Title="How to use plugin provided value in statusline?" Tags="|plugin-system|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19090" PostTypeId="1" AcceptedAnswerId="19094" CreationDate="2019-03-05T16:56:22.257" Score="3" ViewCount="2864" Body="&lt;p&gt;I have an XML document with many (dozens) of the following tags:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;item prop1=&quot;val1&quot; prop2=&quot;val2&quot; /&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to change this to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;item prop1=&quot;val1&quot; prop2=&quot;val2&quot;&amp;gt;&#xA;   &amp;lt;sometihng&amp;gt;text&amp;lt;/something&amp;gt;&#xA;&amp;lt;/item&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I cannot even figure out how to change the self-cosing &quot;item&quot; tag into an open + close tag.  Further complicating this is the fact that each &quot;item&quot; tag may have a different number of properties.&lt;/p&gt;&#xA;" OwnerUserId="21221" LastActivityDate="2019-03-06T12:12:20.150" Title="Replace all self-closing xml tags with open and close tags" Tags="|substitute|filetype-xml|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19091" PostTypeId="2" ParentId="19089" CreationDate="2019-03-05T17:17:10.263" Score="3" Body="&lt;p&gt;Simply use ternaries in the statusline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{exists('*SyntasticStatuslineFlag')?SyntasticStatuslineFlag():''}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-05T17:17:10.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19092" PostTypeId="2" ParentId="19090" CreationDate="2019-03-05T17:20:48.807" Score="0" Body="&lt;p&gt;I would do something like (untested)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq0f&amp;lt;lyiwf&amp;gt;F/i&amp;gt;&amp;lt;Enter&amp;gt;&amp;lt;&amp;lt;Esc&amp;gt;pq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; should be the keys Enter and Esc on your keyboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should record a macro that does the transformation. It assumes the whole tag is on one line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Theoretically, you could then follow with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/&amp;lt;.*\\&amp;gt;/normal! @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To transform the whole file. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-03-06T04:35:39.990" LastActivityDate="2019-03-06T04:35:39.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19093" PostTypeId="2" ParentId="19090" CreationDate="2019-03-05T17:33:17.580" Score="1" Body="&lt;p&gt;So after doing some more research I came up with something that is able to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;lt;item \(.*\)\/&amp;gt;/&amp;lt;item \1 &amp;gt;\r\t&amp;lt;something&amp;gt;text&amp;lt;\/something&amp;gt;\r&amp;lt;\/item&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21221" LastActivityDate="2019-03-05T17:33:17.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19094" PostTypeId="2" ParentId="19090" CreationDate="2019-03-05T17:44:55.167" Score="2" Body="&lt;p&gt;You could use the following substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s%&amp;lt;item[^&amp;gt;]\{-}\zs */&amp;gt;\ze%&amp;gt;&amp;lt;/item&amp;gt;%g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case I use &lt;code&gt;%&lt;/code&gt; as separator instead of &lt;code&gt;/&lt;/code&gt;. That way I need less escaping. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To explain the regex:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;item[^&amp;gt;]\{-}&lt;/code&gt; matches &lt;code&gt;&amp;lt;item&lt;/code&gt; followed by any number of characters, that are not &lt;code&gt;&amp;gt;&lt;/code&gt;. The &lt;code&gt;\{-}&lt;/code&gt; matches 0 or more, but as few as possible.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs */&amp;gt;\ze&lt;/code&gt;: This matches the end of the tag with possible whitespaces. The interesting part it &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt;. This defines the part of the match that should be replaced. Everything matched before &lt;code&gt;\zs&lt;/code&gt; is left unchanged.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In words: Replace the &lt;code&gt;/&amp;gt;&lt;/code&gt; of an &quot;item&quot; tag with &lt;code&gt;&amp;gt;&amp;lt;/item&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a line break between opening and closing tag, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s%\(\s*\)&amp;lt;item[^&amp;gt;]\{-}\zs */&amp;gt;\ze%&amp;gt;\r\1&amp;lt;/item&amp;gt;%g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This time the leading &lt;code&gt;\(\s*\)&lt;/code&gt; matches the leading whitespaces and &lt;code&gt;\r\1&lt;/code&gt; inserts the leading whitespaces after the line break. So indent is kept.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: This only works, when self-closing tag is on one line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To replace &lt;em&gt;any&lt;/em&gt; self closing tag, you could use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s%\(\s*\)&amp;lt;\([-A-Za-z0-9_\.]*\)[^&amp;gt;]\{-}\zs */&amp;gt;\ze%&amp;gt;\r\1&amp;lt;/\2&amp;gt;%g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-05T18:16:21.853" LastActivityDate="2019-03-05T18:16:21.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19095" PostTypeId="1" AcceptedAnswerId="19096" CreationDate="2019-03-05T18:22:09.863" Score="0" ViewCount="2988" Body="&lt;p&gt;I have multiple numbers in lines of 16, for example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  $02 c, $3f c, $fe c, $01 c, $ff c, $06 c, $00 c, $f8 c, $06 c, $1f c, $fe c, $00 c, $7f c, $8c c, $00 c, $fc c,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with pattern &lt;code&gt;[$][0-9][0-9]\s@,&lt;/code&gt; and I need to substitute those lines by grouping the numbers in set of four and adding &lt;code&gt;group&lt;/code&gt; after each group, like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; $02 $3f $fe $01 group $ff $06 ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a short way to do this, or I have to copy and paste same pattern four times in the &lt;code&gt;:s&lt;/code&gt; command ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: the pattern should be: &lt;code&gt;\$\x\x c,&lt;/code&gt;, thanks DJMcMayhem&lt;/p&gt;&#xA;" OwnerUserId="9633" LastEditorUserId="9633" LastEditDate="2019-03-05T18:51:56.240" LastActivityDate="2019-03-05T18:51:56.240" Title="Is there a way to describe a repeating pattern in substitution?" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19096" PostTypeId="2" ParentId="19095" CreationDate="2019-03-05T18:37:10.173" Score="1" Body="&lt;p&gt;Your regex doesn't seem right. &lt;code&gt;[$][0-9][0-9]\s@,&lt;/code&gt; won't match the hex digits (such as &lt;code&gt;3f&lt;/code&gt;), and it seems like there's a &lt;code&gt;c&lt;/code&gt; after each number, not an &lt;code&gt;@&lt;/code&gt;. Don't you mean they match this pattern? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[$][0-9a-f][0-9a-f]\sc, &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or even simpler&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\$\x\x c, &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But anyway, on to your main question. Yes, you can repeat a pattern without having to type it out multiple times. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(foo\)\{3}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will match &quot;foo&quot; repeated 3 times. I'd recommend reading through &lt;a href=&quot;http://vimregex.com/#Non-Greedy&quot; rel=&quot;nofollow noreferrer&quot;&gt;quantifiers on vimregex.com&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your specific example, I'd recommend two regexes. One to remove the &quot;c&quot;s:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/ c,//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Followed by a regex to add the &quot;group&quot; text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v(\$\x\x ){4}/&amp;amp;group /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-03-05T18:37:10.173" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19098" PostTypeId="1" AcceptedAnswerId="19116" CreationDate="2019-03-05T18:57:07.760" Score="1" ViewCount="367" Body="&lt;p&gt;Last week I reinstalled Ubuntu 18.04 LTS on my laptop. During my last installation of ubuntu (also 18.04) I learned vim and used it in combination with the latex-suite. However on this new installation the &lt;code&gt;&amp;lt;alt-I&amp;gt;&lt;/code&gt; function does not work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;alt&amp;gt;&lt;/code&gt; key works fine, for example with &lt;code&gt;&amp;lt;alt-L&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;alt-C&amp;gt;&lt;/code&gt;, but when I use &lt;code&gt;&amp;lt;alt-I&amp;gt;&lt;/code&gt; I get &lt;strong&gt;é&lt;/strong&gt; in both gVim and vi in the gnome terminal.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I reused a part of my .vimrc of my previous installation. From what I understood, this is the part that handles the alt-key mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   let c='a'&#xA;   while c &amp;lt;= 'z'&#xA;     exec &quot;set &amp;lt;A-&quot;.c.&quot;&amp;gt;=\e&quot;.c&#xA;     exec &quot;imap \e&quot;.c.&quot; &amp;lt;A-&quot;.c.&quot;&amp;gt;&quot;&#xA;     let c = nr2char(1+char2nr(c))&#xA;   endw&#xA;&#xA;   set timeout ttimeoutlen=50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I think that I found this here: &lt;a href=&quot;https://tex.stackexchange.com/questions/130389/vim-latex-suite-alt-macro-not-working&quot;&gt;https://tex.stackexchange.com/questions/130389/vim-latex-suite-alt-macro-not-working&lt;/a&gt; but I am not sure since this is from my old .vimrc file, from my old installation.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the alt-key works (for the other key combinations), I expect that it is some other setting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim-latex is installed using Vundle. I tried to put this line:&lt;code&gt;let g:Tex_AdvancedMath = 1&lt;/code&gt; in &lt;code&gt;~/.vim/bundle/LaTeX-Suite-aka-Vim-LaTeX/ftplugin/tex_latexSuite.vim&lt;/code&gt;. I tried both methods:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; LaTeX filetype&#xA;&quot;     Language: LaTeX (ft=tex)&#xA;&quot;   Maintainer: Srinath Avadhanula&#xA;&quot;        Email: srinath@fastmail.fm&#xA;&#xA;if !exists('s:initLatexSuite')&#xA;    let s:initLatexSuite = 1&#xA;    exec 'so '.expand('&amp;lt;sfile&amp;gt;:p:h').'/latex-suite/main.vim'&#xA;    let g:Tex_AdvancedMath = 1&#xA;    silent! do LatexSuite User LatexSuiteInitPost&#xA;endif&#xA;&#xA;silent! do LatexSuite User LatexSuiteFileType&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;and:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; LaTeX filetype&#xA;&quot;     Language: LaTeX (ft=tex)&#xA;&quot;   Maintainer: Srinath Avadhanula&#xA;&quot;        Email: srinath@fastmail.fm&#xA;&#xA;if !exists('s:initLatexSuite')&#xA;    let s:initLatexSuite = 1&#xA;    exec 'so '.expand('&amp;lt;sfile&amp;gt;:p:h').'/latex-suite/main.vim'&#xA;&#xA;    silent! do LatexSuite User LatexSuiteInitPost&#xA;endif&#xA;&#xA;silent! do LatexSuite User LatexSuiteFileType&#xA;let g:Tex_AdvancedMath = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The difference between both methods is that either the &lt;code&gt;let g:Tex_AdvancedMath = 1&lt;/code&gt; is inside or outside the if statement). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nothing worked so far. I did not had any trouble with the &lt;code&gt;&amp;lt;alt&amp;gt;&lt;/code&gt;-key, like that it is linked to the menu in GVim for example. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be complete, this is my .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;Plugin 'LaTeX-Suite-aka-Vim-LaTeX'&#xA;Plugin 'junegunn/goyo.vim' &#xA;Plugin 'junegunn/limelight.vim'&#xA;Plugin 'Valloric/YouCompleteMe'&#xA;Plugin 'scrooloose/nerdtree'&#xA;&#xA;Plugin 'tmhedberg/SimpylFold' &quot;fold&#xA;Plugin 'vim-syntastic/syntastic'&#xA;&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&#xA;set relativenumber&#xA;syntax on&#xA;set showmatch&#xA;set ruler&#xA;set smarttab&#xA;set shiftwidth=4&#xA;set tabstop=4&#xA;&#xA;set expandtab&#xA;&#xA;set grepprg=grep\ -nH\ $*&#xA;filetype indent on&#xA;let g:tex_flavor='latex'&#xA;let g:Tex_DefaultTargetFormat='pdf'&#xA;map &amp;lt;f2&amp;gt; :w&amp;lt;cr&amp;gt;&amp;lt;leader&amp;gt;ll&#xA;&quot;set spell spelllang=en_us&#xA;set spell spelllang=en&#xA;&#xA;let c='a'&#xA;while c &amp;lt;= 'z'&#xA;  exec &quot;set &amp;lt;A-&quot;.c.&quot;&amp;gt;=\e&quot;.c&#xA;  exec &quot;imap \e&quot;.c.&quot; &amp;lt;A-&quot;.c.&quot;&amp;gt;&quot;&#xA;  let c = nr2char(1+char2nr(c))&#xA;endw&#xA;&#xA;set timeout ttimeoutlen=50&#xA;&#xA;&quot; Use a blinking upright bar cursor in Insert mode, a blinking block in normal&#xA;if &amp;amp;term == 'xterm-256color' || &amp;amp;term == 'screen-256color'&#xA;    let &amp;amp;t_SI = &quot;\&amp;lt;Esc&amp;gt;[5 q&quot;&#xA;    let &amp;amp;t_EI = &quot;\&amp;lt;Esc&amp;gt;[1 q&quot;&#xA;endif&#xA;&#xA;if exists('$TMUX')&#xA;    let &amp;amp;t_EI = &quot;\&amp;lt;Esc&amp;gt;Ptmux;\&amp;lt;Esc&amp;gt;\&amp;lt;Esc&amp;gt;]50;CursorShape=0\x7\&amp;lt;Esc&amp;gt;\\&quot;&#xA;    let &amp;amp;t_SI = &quot;\&amp;lt;Esc&amp;gt;Ptmux;\&amp;lt;Esc&amp;gt;\&amp;lt;Esc&amp;gt;]50;CursorShape=1\x7\&amp;lt;Esc&amp;gt;\\&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I disabled my .vimrc, by renaming &lt;em&gt;.vimrc&lt;/em&gt; &amp;rarr; &lt;em&gt;.vimrc_backup&lt;/em&gt;. Now the plugins are disabled, but I é is still the result from clicking &lt;code&gt;&amp;lt;alt-i&amp;gt;&lt;/code&gt; in GVim, but not in the terminal. &lt;/p&gt;&#xA;" OwnerUserId="21223" LastEditorUserId="1292" LastEditDate="2019-03-06T14:38:33.180" LastActivityDate="2019-03-07T08:43:20.850" Title="Latex-suite &lt;alt-I&gt; mapping" Tags="|filetype-tex|linux|plugin-vim-latex|linux-ubuntu|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19099" PostTypeId="1" CreationDate="2019-03-05T20:41:58.143" Score="0" ViewCount="134" Body="&lt;p&gt;What I need to do is yank a word (yw) and then move my cursor to a diffent location and &quot;paste&quot; the word &lt;em&gt;over&lt;/em&gt; whatever follows the cursor without disturbing the other characters in the line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;yw&quot;&#xA;...move cursor&#xA;&quot;p&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;inserts the word. I need the put (p) to act as if it was coming from &quot;R&quot; mode&lt;/p&gt;&#xA;" OwnerUserId="21225" LastActivityDate="2019-03-06T11:58:42.633" Title="How to put a word into like as if in R (type over) mode?" Tags="|insert-mode|" AnswerCount="2" CommentCount="1" ClosedDate="2019-03-06T20:33:02.023" ContentLicense="CC BY-SA 4.0" />
  <row Id="19100" PostTypeId="2" ParentId="19099" CreationDate="2019-03-05T20:52:19.730" Score="0" Body="&lt;p&gt;I am also very new to vim, but I have a work-around for you (I think). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What worked on my machine is the following. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We start with the line:&lt;br&gt;&#xA;&lt;em&gt;first second third&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then in normal mode go to 's' of second and &lt;code&gt;yw&lt;/code&gt; (to copy this word). Then go to 't' of third and delete the word with &lt;code&gt;dw&lt;/code&gt;. Then use the last yanked text with &lt;code&gt;&quot;0P&lt;/code&gt;. Note the capital 'P', so that the yanked word is placed before the next. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(found this last part here: &lt;a href=&quot;https://stackoverflow.com/questions/54255/in-vim-is-there-a-way-to-delete-without-putting-text-in-the-register&quot;&gt;https://stackoverflow.com/questions/54255/in-vim-is-there-a-way-to-delete-without-putting-text-in-the-register&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first google hit showed me this:&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/14233498/replace-word-under-cursor-vim&quot;&gt;https://stackoverflow.com/questions/14233498/replace-word-under-cursor-vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution that is used there (and better than my own solution in my opinion) is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 &quot;This first word should overwrite the second&quot;&#xA;&#xA;yiw     yank inner word (copy word under cursor, say &quot;first&quot;).&#xA;...     Move the cursor to another word (say &quot;second&quot;).&#xA;viwp    select &quot;second&quot;, then replace it with &quot;first&quot;. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this what you wanted to do?&lt;/p&gt;&#xA;" OwnerUserId="21223" LastEditorUserId="21223" LastEditDate="2019-03-05T21:06:11.017" LastActivityDate="2019-03-05T21:06:11.017" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19102" PostTypeId="2" ParentId="19090" CreationDate="2019-03-06T09:06:22.787" Score="0" Body="&lt;h3&gt;Plugin &lt;a href=&quot;https://github.com/mattn/emmet-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Emmet&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The plugin emmet provides the mapping &lt;code&gt;&amp;lt;C-y&amp;gt;j&lt;/code&gt; to split or join tags. The help section explains what emmet does when using this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12. Split/join tag                             *emmet-split-join-tag* *&amp;lt;C-y&amp;gt;j*&#xA;&#xA;  To join block, type '&amp;lt;C-y&amp;gt;j'.&#xA;&amp;gt;&#xA;  &amp;lt;div class=&quot;foo&quot;&amp;gt;&#xA;      cursor is here&#xA;  &amp;lt;/div&amp;gt;&#xA;&amp;lt;&#xA;  Type '&amp;lt;C-y&amp;gt;j' in insert mode. Then,&#xA;&amp;gt;&#xA;  &amp;lt;div class=&quot;foo&quot; /&amp;gt;&#xA;&amp;lt;&#xA;  And type '&amp;lt;C-y&amp;gt;j' in there again.&#xA;&amp;gt;&#xA;  &amp;lt;div class=&quot;foo&quot;&amp;gt;&#xA;  &amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sometimes you have to modify many tags individually because you have to insert different content between the tags which makes a global substitution not perfect. However, a global substitution could still be the first step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following steps achieve the change described in the question:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Modify single tag&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/&amp;lt;item&lt;/code&gt; to move to tag &lt;code&gt;&amp;lt;item ... /&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-y&amp;gt;j&lt;/code&gt; (&lt;code&gt;:h emmet-split-join&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cit&lt;/code&gt; (&lt;code&gt;:h it&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;something&amp;lt;C-y&amp;gt;;&lt;/code&gt;  (&lt;code&gt;:h emmet-expand-word&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;text specific for this line&amp;lt;Esc&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt; jump to next &lt;code&gt;&amp;lt;item&lt;/code&gt; which should be changed&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Modify all lines and insert the same text everywhere&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case I would use the &lt;code&gt;:substitute&lt;/code&gt; command similar to &lt;a href=&quot;https://vi.stackexchange.com/a/19093/1292&quot;&gt;you&lt;/a&gt;. However, I want to show that it is also be possible to use the plugin in combination with &lt;code&gt;:global&lt;/code&gt; and &lt;code&gt;:normal&lt;/code&gt; (or with a macro not shown here). I assume that all &lt;code&gt;&amp;lt;item .../&amp;gt;&lt;/code&gt; are placed on separate lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/item/exec &quot;norm f&amp;lt;\&amp;lt;C-y&amp;gt;jcitsomething\&amp;lt;C-y&amp;gt;;text&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Formatting&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To format your xml source code, you can consider using &lt;code&gt;tidy&lt;/code&gt; for &lt;code&gt;formatprg&lt;/code&gt; by placing following into &lt;code&gt;~/.vim/after/ftplugin/xml.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal formatprg=tidy\ -xml\ -quiet\ --indent\ auto\ --tidy-mark\ no\ --indent-spaces\ 2\ --vertical-space\ yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can format the whole xml file afterwards with &lt;code&gt;gggqG&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, if you like to combine &lt;code&gt;formatprg=tidy ...&lt;/code&gt; with &lt;code&gt;indentexpr=XmlIndentGet(v:lnum,1)&lt;/code&gt; from &lt;code&gt;$VIMRUNTIME/indent/xml.vim&lt;/code&gt;, have a look at following question &lt;a href=&quot;https://vi.stackexchange.com/questions/17996/automatically-reindent-lines-filtered-through-formatprg&quot;&gt;Automatically reindent lines filtered through formatprg&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-03-06T11:13:14.943" LastActivityDate="2019-03-06T11:13:14.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19103" PostTypeId="2" ParentId="19090" CreationDate="2019-03-06T11:02:05.847" Score="0" Body="&lt;h3&gt;Plugins &lt;a href=&quot;https://github.com/AndrewRadev/switch.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Switch&lt;/em&gt;&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://github.com/AndrewRadev/splitjoin.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;SplitJoin&lt;/em&gt;&lt;/a&gt; by Andrew Radev&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Install the two plugins and add following to &lt;code&gt;~/.vim/after/ftplugin/xml.vim&lt;/code&gt; for &lt;em&gt;switch.vim&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:switch_custom_definitions =&#xA;      \ [&#xA;      \   {&#xA;      \     '&amp;lt;\(\S*\) \(.*\)\s*/&amp;gt;': '&amp;lt;\1 \2&amp;gt;&amp;lt;/\1&amp;gt;',&#xA;      \     '&amp;lt;\(\S*\) \(.*\S\)\s*&amp;gt;.*&amp;lt;/\1&amp;gt;': '&amp;lt;\1 \2 /&amp;gt;',&#xA;      \   },&#xA;      \ ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additionally, you could install &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-surround&lt;/a&gt; or &lt;a href=&quot;https://github.com/machakann/vim-sandwich&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sandwich&lt;/a&gt; to add more easily the tag &lt;code&gt;something&lt;/code&gt; with &lt;code&gt;ysiwt&lt;/code&gt;+&lt;code&gt;something&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, this answer targets the situation where it is more suitable to change individual tags:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/&amp;lt;item&lt;/code&gt; to move to first &lt;code&gt;&amp;lt;item&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gs&lt;/code&gt; from &lt;code&gt;switch.vim&lt;/code&gt; to toggle tag between &lt;code&gt;&amp;lt;item .../&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;item ...&amp;gt;&amp;lt;/item&amp;gt;&lt;/code&gt;&lt;br&gt;&#xA;(check toggle by pressing &lt;code&gt;gsgsgs&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gS&lt;/code&gt; from &lt;code&gt;splitjoin.vim&lt;/code&gt; to change from a single line to multi-line format&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&lt;/code&gt; to insert a new line below with the correct indentation&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;your text&amp;lt;Esc&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ysiwt&lt;/code&gt;+&lt;code&gt;something&amp;lt;CR&amp;gt;&lt;/code&gt; surround your text with a tag with the help of &lt;code&gt;vim-surround&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt; jump to next &lt;code&gt;&amp;lt;item&lt;/code&gt; which should be changed&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-03-06T12:12:20.150" LastActivityDate="2019-03-06T12:12:20.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19104" PostTypeId="2" ParentId="14405" CreationDate="2019-03-06T11:05:27.760" Score="2" Body="&lt;p&gt;You can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot; &quot;&#xA;let maplocalleader = &quot; &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16633" LastActivityDate="2019-03-06T11:05:27.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19105" PostTypeId="2" ParentId="19099" CreationDate="2019-03-06T11:58:42.633" Score="1" Body="&lt;h3&gt;Replacing Several Occurrences with the Same Text in Visual Mode&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I want to point out following: when you yanked and replaced the first occurrence with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yiw&#xA;viwp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and now want to repeat the replacement for another occurrence with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;viwp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the inserted text is the one from the first replacement and not the originally yanked text which is something you might not want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default recommendation is to use the register &lt;code&gt;&quot;0&lt;/code&gt; as following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yiw&#xA;viwp&#xA;viw&quot;0p&#xA;viw&quot;0p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I often have this situation and actually want to replace even more occurences.&#xA;In this situation typing &lt;code&gt;viw&quot;0p&lt;/code&gt; felt too cumbersome and it is not dot repeateable which IMHO is a real pity.&#xA;Therefore, I was looking for a more comfortable solution which matches my expectations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have settled with the plugin &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2703&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;ReplaceWithRegister&lt;/em&gt;&lt;/a&gt; by Ingo Karkat which provides the new operator &lt;code&gt;gr&lt;/code&gt; (overrides builtin &lt;code&gt;gr&lt;/code&gt;). This changes the keys to press to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;griw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is dot-repeatable. This means &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yiw&#xA;griw&#xA;griw or .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Registers: the Good, the Bad, and the Ugly Parts&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Drew Neil has discussed this matter at length:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/episodes/pasting-from-visual-mode/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimcasts.org/episodes/pasting-from-visual-mode/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/blog/2013/11/registers-the-good-the-bad-and-the-ugly-parts/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimcasts.org/blog/2013/11/registers-the-good-the-bad-and-the-ugly-parts/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimcasts.org/blog/2013/11/the-copypaste-series-a-retrospective/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimcasts.org/blog/2013/11/the-copypaste-series-a-retrospective/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Additionally to ReplaceWithRegister he points following plugins out&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/kana/vim-operator-replace&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kana/vim-operator-replace&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/svermeulen/vim-easyclip&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/svermeulen/vim-easyclip&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The latter one is now split into smaller ones&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/svermeulen/vim-cutlass&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/svermeulen/vim-cutlass&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/svermeulen/vim-yoink&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/svermeulen/vim-yoink&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/svermeulen/vim-subversive&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/svermeulen/vim-subversive&lt;/a&gt; (similar to&#xA;ReplaceWithRegister or vim-operator-replace)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-03-06T11:58:42.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19106" PostTypeId="1" AcceptedAnswerId="19570" CreationDate="2019-03-06T12:17:44.223" Score="2" ViewCount="115" Body="&lt;p&gt;I am trying to return this &lt;code&gt;:GrepperAck ''&amp;lt;Left&amp;gt;&lt;/code&gt; from a Python function and use it in the following mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def invoke_search_command():&#xA;  return &quot;:GrepperAck ''&amp;lt;Left&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;f py3eval('invoke_search_command()')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the &lt;code&gt;&amp;lt;Left&amp;gt;&lt;/code&gt; is printed literally like &lt;code&gt;:GrepperGit ''&amp;lt;Left&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I use &lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;f py3eval('invoke_search_command()') . '&amp;lt;Left&amp;gt;'&lt;/code&gt;, it works. I tried escaping the returned string like &lt;code&gt;&quot;:GrepperAck ''\&amp;lt;Left&amp;gt;&quot;&lt;/code&gt;, but it is still getting printed literally. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="11793" LastActivityDate="2019-07-19T22:03:26.273" Title="Return &lt;motion&gt; character from Python function in &lt;expr&gt; mapping" Tags="|key-bindings|vimscript-python|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19107" PostTypeId="2" ParentId="19064" CreationDate="2019-03-06T14:57:13.893" Score="1" Body="&lt;h2&gt;Debugging Autocmds&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If something happens automatically for a certain command (here &lt;code&gt;:write&lt;/code&gt;) in vim, an autocmd might be the reason for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you already know the event of the autocmd, you can see the autocmds with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd &amp;lt;Event Name&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as described under &lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-list&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h autocmd-list&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case likely candidates are&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd BufWritePost&#xA;:autocmd BufWrite&#xA;:autocmd FileWritePost&#xA;:autocmd FileWrite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To see also the filenames where these autocmds are defined, run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose autocmd &amp;lt;Event Name&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A list of events used by the autocmds can be found under&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#autocmd-events&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h autocmd-events&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this list is quite long and you might have no clue where to start, a second method is to invoke your command prefixed with &lt;code&gt;:9verbose&lt;/code&gt;. In your case&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:9verbose write&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The count &lt;code&gt;9&lt;/code&gt; is important so that also autocmds are listed. This is described under &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27verbose%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'verbose'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-03-06T15:05:56.780" LastActivityDate="2019-03-06T15:05:56.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19108" PostTypeId="1" AcceptedAnswerId="19109" CreationDate="2019-03-06T15:43:16.137" Score="0" ViewCount="139" Body="&lt;p&gt;I'm using &lt;code&gt;U&lt;/code&gt; in normal mode to undo steps in vim, I wonder how to set a sort of a bookmark and create a undo command to undo steps/reverse to the bookmark moment in Vim. This would be nicer than just keep pressing &lt;code&gt;U&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="15958" LastEditorUserId="1841" LastEditDate="2019-03-06T16:09:33.173" LastActivityDate="2019-03-06T17:28:42.743" Title="Undo to a specific user defined point" Tags="|undo-redo|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19109" PostTypeId="2" ParentId="19108" CreationDate="2019-03-06T17:28:42.743" Score="2" Body="&lt;h3&gt;Via Plugins&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/mbbill/undotree&quot; rel=&quot;nofollow noreferrer&quot;&gt;mbbill/undotree&lt;/a&gt; (this is what I use)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/simnalamburt/vim-mundo&quot; rel=&quot;nofollow noreferrer&quot;&gt;simnalamburt/vim-mundo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/chrisbra/histwin.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;chrisbra/histwin&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Via External Tooling&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Consider using VCS systems like git or mercurial (the two leading distributed systems). &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Aside: your question mentions capital &lt;code&gt;U&lt;/code&gt;, which has very different effects from &lt;code&gt;u&lt;/code&gt;. They both have their uses, but my goto is usually &lt;code&gt;u&lt;/code&gt; because it truly &quot;undoes.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plus, &lt;code&gt;&amp;lt;Leader&amp;gt;u&lt;/code&gt; makes a good mapping for, e.g., undotree’s command. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-06T17:28:42.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19111" PostTypeId="1" AcceptedAnswerId="19113" CreationDate="2019-03-06T22:06:45.390" Score="3" ViewCount="213" Body="&lt;p&gt;I used to have some simple &lt;code&gt;map&lt;/code&gt; macros that implemented a &quot;pager mode&quot; for vi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I was reading through a very long file, I would activate pager mode.  This would make two key maps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; would be mapped to: &lt;code&gt;^F^G&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Backspace&amp;gt;&lt;/code&gt; would be mapped to: &lt;code&gt;^B^G&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Not that weird.  Space would go to the next whole screenful, and then display the filename status line (that also includes line number and percent progress through the file).  Backspace went to previous screen and displayed the status line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I didn't want these active all the time; I wanted to be able to activate and deactivate them.  So I bound a pair of key sequences:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;]p&lt;/code&gt; would &quot;activate pager mode&quot; (i.e. would make the bindings above)&#xA;&lt;code&gt;]P&lt;/code&gt; would &quot;deactivate pager mode&quot; (i.e. would unmap those two keys)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is tricky because mapping the space bar can be tricky, and because I was trying to write a macro that would run two &lt;code&gt;map&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Way back in the day, I'm pretty sure this used to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;this was in .exrc&#xA;&quot;note: all &quot;^&quot; sequences were actual control characters&#xA;map ]p :map ^V^V^V  ^F^G^M:map ^V^V^? ^B^G^M&#xA;map ]P :unmap ^V^V^V ^M:unmap ^V^V^?^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All &lt;code&gt;^&lt;/code&gt; sequences were actual control characters.  &lt;code&gt;^V&lt;/code&gt; was &lt;code&gt;&amp;lt;Ctrl+V&amp;gt;&lt;/code&gt; and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^V&lt;/code&gt; quotes something, and I think I had to double it to get a single &lt;code&gt;^V&lt;/code&gt; in the macro that would run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the &lt;code&gt;]p&lt;/code&gt; macro, when run, would map the two keys, and &lt;code&gt;]P&lt;/code&gt; would unmap them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't use these every day and I'm not sure when they broke.  But at some point I tried them, and they were broken.  Recently I decided to invest the time to get these working.  I have a kludge working but it's not elegant, and it only flips pages; the part where it should display the status line simply doesn't work.  I tried both including &lt;code&gt;^G&lt;/code&gt; and explicitly saying &lt;code&gt;:file^M&lt;/code&gt; and while I don't have any errors, it also doesn't display anything.  It does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I ever run these days is Vim so I'm specifically looking for a solution that will work in Vim and I don't care if it's Vim-specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because this is a &lt;code&gt;map&lt;/code&gt; that is supposed to do a &lt;code&gt;map&lt;/code&gt; the quoting issues are tedious, and because we are binding space bar quoting is even trickier.  It seems like there ought to be an elegant way to do this by making Vimscript functions that would map or unmap the keys, and then binding &lt;code&gt;]p&lt;/code&gt; and &lt;code&gt;]P&lt;/code&gt; to call the functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone really wants I'll post my kludge here, but I'm hoping someone with more Vim knowledge can make something better so I'm not posting it now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In summary:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;]p&lt;/code&gt; should map the keys&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;]P&lt;/code&gt; should unmap the keys&lt;/li&gt;&#xA;&lt;li&gt;When mapped, &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; should do the same thing as: &lt;code&gt;^F^G&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;When mapped, &lt;code&gt;&amp;lt;Backspace&amp;gt;&lt;/code&gt; should do the same thing as: &lt;code&gt;^B^G&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21250" LastActivityDate="2019-03-06T23:03:53.000" Title="Mapping space and backspace for &quot;pager mode&quot;" Tags="|vimscript|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19112" PostTypeId="2" ParentId="19111" CreationDate="2019-03-06T22:44:30.263" Score="1" Body="&lt;p&gt;There lots of variations, including &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mappings, but I'm just going to outline a pair of functions which you can drop in &lt;code&gt;~/.vim/autoload/pager.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! pager#map() abort&#xA;  if get(b:, 'pager_maps', v:false)&#xA;    return&#xA;  endif&#xA;&#xA;  let b:pager_maps = v:true&#xA;  nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;Space&amp;gt; &amp;lt;C-f&amp;gt;&amp;lt;C-g&amp;gt;&#xA;  nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;BS&amp;gt; &amp;lt;C-b&amp;gt;&amp;lt;C-g&amp;gt;&#xA;endfunction&#xA;&#xA;function! pager#unmap() abort&#xA;  if ! get(b:, 'pager_maps', v:false)&#xA;    return&#xA;  endif&#xA;&#xA;  let b:pager_maps = v:false&#xA;  silent! nunmap &amp;lt;buffer&amp;gt; &amp;lt;Space&amp;gt;&#xA;  silent! nunmap &amp;lt;buffer&amp;gt; &amp;lt;BS&amp;gt;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, in your &lt;code&gt;~/.vim/vimrc&lt;/code&gt;, you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ]p :call pager#map()&amp;lt;CR&amp;gt;&#xA;nnoremap ]P :call pager#unmap()&amp;lt;CR&amp;gt;&#xA;&quot; I'm including [p because I think it's easier to remember, just as an example&#xA;nnoremap [p :call pager#unmap()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've included the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; modifiers to ensure the mappings only happen in the the desired buffer; they can be removed to make the mappings global.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also silence the unmapping commands, as they can error if the mappings aren't present (e.g., because you unmapped them manually). Because of the &lt;code&gt;abort&lt;/code&gt; attribute, these errors would cause the function to terminate.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-03-06T22:58:49.967" LastActivityDate="2019-03-06T22:58:49.967" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19113" PostTypeId="2" ParentId="19111" CreationDate="2019-03-06T23:03:53.000" Score="1" Body="&lt;p&gt;This is how you would do it with expression mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;space&amp;gt; get(g:, 'pager_mode', 0) ? &quot;\&amp;lt;c-f&amp;gt;:redraw\&amp;lt;cr&amp;gt;\&amp;lt;c-g&amp;gt;&quot; : &quot;\&amp;lt;space&amp;gt;&quot;&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;bs&amp;gt; get(g:, 'pager_mode', 0) ? &quot;\&amp;lt;c-b&amp;gt;:redraw\&amp;lt;cr&amp;gt;\&amp;lt;c-g&amp;gt;&quot; : &quot;\&amp;lt;bs&amp;gt;&quot; &#xA;nnoremap ]p :&amp;lt;c-u&amp;gt;let g:pager_mode = 1&amp;lt;cr&amp;gt;:echo &quot;Pager mode&quot;&amp;lt;cr&amp;gt;&#xA;nnoremap ]P :&amp;lt;c-u&amp;gt;let g:pager_mode = 0&amp;lt;cr&amp;gt;:echo &quot;Nopager mode&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;]p&lt;/code&gt; &amp;amp; &lt;code&gt;]P&lt;/code&gt; can be useful. I would personally suggest a different key and maybe make it toggle instead. Maybe something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;p :&amp;lt;c-u&amp;gt;let g:pager_mode = !get(g:, 'pager_mode', 0)&amp;lt;cr&amp;gt;echo get(['Nopager', 'Pager'], g:pager_mode) . ' mode'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-03-06T23:03:53.000" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19114" PostTypeId="2" ParentId="19087" CreationDate="2019-03-07T00:08:40.610" Score="0" Body="&lt;p&gt;Note to self: Use &lt;strong&gt;abbreviations&lt;/strong&gt; (like &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/08.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="20750" LastActivityDate="2019-03-07T00:08:40.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19116" PostTypeId="2" ParentId="19098" CreationDate="2019-03-07T08:43:20.850" Score="0" Body="&lt;p&gt;What worked for me was to remove the plugin from Vundle and manually add all the files in my .vim folder (&lt;a href=&quot;http://vim-latex.sourceforge.net/index.php?subject=download&quot; rel=&quot;nofollow noreferrer&quot;&gt;as described here&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I added the line &lt;code&gt;imap &amp;lt;buffer&amp;gt; &amp;lt;m-i&amp;gt; &amp;lt;Plug&amp;gt;Tex_InsertItemOnThisLine&lt;/code&gt; in &lt;code&gt;~/.vim/ftplugin/tex_latexSuite.vim&lt;/code&gt;. Now &lt;code&gt;&amp;lt;alt-i&amp;gt;&lt;/code&gt; inserted an item, instead of the text &lt;em&gt;Tex_InsertItemOnThisLine&lt;/em&gt;. So I think there was a problem with the combination of Vundle and the latex-suite. &lt;/p&gt;&#xA;" OwnerUserId="21223" LastActivityDate="2019-03-07T08:43:20.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19117" PostTypeId="1" CreationDate="2019-03-07T15:21:11.087" Score="0" ViewCount="88" Body="&lt;p&gt;If I already have vim running with numerous documents open and I want to use tmux, it seems that I have to quit vim, start the tmux session and then reopen everything again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway to start the new tmux session with the vim open inside of it?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2019-03-07T15:21:11.087" Title="Any way to add an existing Vim environment to a tmux session?" Tags="|tmux|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19118" PostTypeId="1" CreationDate="2019-03-07T15:51:06.433" Score="0" ViewCount="129" Body="&lt;p&gt;I built Vim from source and unfortunately when doing this the help system is not created (in other words you get an error if you execute :h). What is the procedure for creating the help system?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo $VIMRUNTIME&#xA;    /usr/share/vim&#xA;sudo mkdir /usr/share/vim/doc&#xA;sudo chmod 666 /usr/share/vim/doc&#xA;:helptags $VIMRUNTIME/doc&#xA;    E151: No match: /usr/share/vim/doc/**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last shown error above is where I am stuck.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2019-03-07T15:51:06.433" Title="How do I create the help system for Vim?" Tags="|help-system|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19119" PostTypeId="1" CreationDate="2019-03-07T15:55:58.073" Score="2" ViewCount="944" Body="&lt;p&gt;In the fzf plugin you can define mappings for the fzf window to open the selected file in a vertical split, etc. How can I make fzf mapping to insert the path of the selected file as a string into the current buffer? I want to use this mapping inside the fzf-window opend by &lt;code&gt;:FZF&lt;/code&gt; and similar commands.&lt;/p&gt;&#xA;" OwnerUserId="3316" LastEditorUserId="3316" LastEditDate="2019-03-20T10:31:48.963" LastActivityDate="2020-09-11T18:56:50.920" Title="Insert filepath from FZF window in buffer" Tags="|plugin-fzf|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19120" PostTypeId="1" CreationDate="2019-03-07T17:56:11.987" Score="0" ViewCount="878" Body="&lt;p&gt;Can you target a spesific line number in the gutter? Let's say I want line 20 in the gutter te be red for some reason. Possible? Like &lt;code&gt;CursorLineNr&lt;/code&gt;, but defining the line number yourself. In short I'm looking to write a simple plugin showing some simple warnings through colours, not relying on the sign column feature. I use Neovim.&lt;/p&gt;&#xA;" OwnerUserId="18541" LastActivityDate="2020-05-01T22:01:40.550" Title="Highlight specific line numbers in the gutter" Tags="|highlight|line-numbers|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19122" PostTypeId="1" CreationDate="2019-03-07T20:12:30.883" Score="2" ViewCount="377" Body="&lt;p&gt;I need to process text line by line in one buffer and append the processed text to another buffer in Vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can do this by using buffer switching ex commands, but I suspect it will cause epilepsy-inducing screen flashing when the script runs and it is probably really inefficient to be rendering and re-rendering the buffer on the screen thousands and thousands of times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to append text to another buffer (other than the active buffer) without actually making the destination buffer active?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastActivityDate="2019-03-07T20:47:38.087" Title="Copy text from one buffer to another using Vimscript" Tags="|vimscript|buffers|text-generation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19123" PostTypeId="2" ParentId="19122" CreationDate="2019-03-07T20:47:38.087" Score="6" Body="&lt;p&gt;You can use &lt;code&gt;appendbufline()&lt;/code&gt; like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call appendbufline(&quot;other.txt&quot;, &quot;$&quot;, &quot;Appended Line&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or if you want to work with buffer numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call appendbufline(3, &quot;$&quot;, &quot;Appended Line&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help appendbufline()&lt;/code&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-07T20:47:38.087" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19124" PostTypeId="1" AcceptedAnswerId="19125" CreationDate="2019-03-07T20:54:23.670" Score="0" ViewCount="74" Body="&lt;p&gt;I have a keybinding that works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;Tab&amp;gt; &amp;lt;C-r&amp;gt;=&#xA;  \ pumvisible() ? &quot;\&amp;lt;lt&amp;gt;C-N&amp;gt;&quot; :&#xA;  \ CursorAfterOnlyWhitespace() ? &quot;\&amp;lt;lt&amp;gt;Tab&amp;gt;&quot; :&#xA;  \ &quot;\&amp;lt;lt&amp;gt;C-\&amp;gt;\&amp;lt;lt&amp;gt;C-O&amp;gt;:ALEComplete\&amp;lt;lt&amp;gt;CR&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to put it in a function that takes arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TabComplete(complete, indent)&#xA;  if pumvisible()&#xA;    &quot; Tab through completions.&#xA;    return a:complete&#xA;  endif&#xA;  if CursorAfterOnlyWhitespace()&#xA;    &quot; Indent.&#xA;    return a:indent&#xA;  endif&#xA;  &quot; Find completions.&#xA;  return '\&amp;lt;C-\&amp;gt;\&amp;lt;C-O&amp;gt;:ALEComplete\&amp;lt;CR&amp;gt;'&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;Tab&amp;gt; &amp;lt;C-R&amp;gt;=TabComplete('\&amp;lt;lt&amp;gt;C-N&amp;gt;', '\&amp;lt;lt&amp;gt;Tab&amp;gt;')&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;S-Tab&amp;gt; &amp;lt;C-R&amp;gt;=TabComplete('\&amp;lt;lt&amp;gt;C-P&amp;gt;', '\&amp;lt;lt&amp;gt;S-Tab&amp;gt;')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this &lt;em&gt;does not work&lt;/em&gt;. It just inserts the literal string returned by the function. How do I get Vim to decode the control characters in the string returned by my function?&lt;/p&gt;&#xA;" OwnerUserId="1176" LastActivityDate="2019-03-07T21:14:44.057" Title="How to return control characters from a function?" Tags="|key-bindings|vimscript|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19125" PostTypeId="2" ParentId="19124" CreationDate="2019-03-07T21:03:08.550" Score="3" Body="&lt;p&gt;Replace the single quotes with double quotes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return &quot;\&amp;lt;C-\&amp;gt;\&amp;lt;C-O&amp;gt;:ALEComplete\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Single quoted Strings are &quot;literal strings&quot;. Every character is used as entered. They are useful to express regular expressions etc as you don't have to double the backslashes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In double quoted strings backslash-escapes like &lt;code&gt;\&amp;lt;C-O&amp;gt;&lt;/code&gt; are interpreted as one character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help literal-string&lt;/code&gt; and &lt;code&gt;:help String&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-07T21:14:44.057" LastActivityDate="2019-03-07T21:14:44.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19126" PostTypeId="1" AcceptedAnswerId="19127" CreationDate="2019-03-07T23:06:03.233" Score="1" ViewCount="37" Body="&lt;p&gt;I modifying a gcode file with custom toolswap codee, and I need to replace every instance of &quot;T0&quot; (&lt;code&gt;^T0$&lt;/code&gt;) with a large amount of text (19 lines), which is stored in a separate file. How can I do so quickly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are about 100 instances that need replacement, and I can see the need to do more in the future, so I need something that does it all at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried defining a macro with &lt;code&gt;q&lt;/code&gt; to replace one instance, hoping to run it a certain number of times, but I could only run the macro once. The macro deleted the line, and then read (&lt;code&gt;:r&lt;/code&gt;) from the other file.&lt;/p&gt;&#xA;" OwnerUserId="21268" LastActivityDate="2019-03-08T00:09:17.230" Title="How do I replace all occurances of a string with a large amount of text?" Tags="|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19127" PostTypeId="2" ParentId="19126" CreationDate="2019-03-08T00:09:17.230" Score="2" Body="&lt;p&gt;Does that work for you?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^T0$/\=readfile('filename')/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will replace every occurence of &lt;code&gt;T0&lt;/code&gt; with the content of &lt;code&gt;filename&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-03-08T00:09:17.230" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19128" PostTypeId="1" AcceptedAnswerId="19130" CreationDate="2019-03-08T05:37:10.727" Score="3" ViewCount="1547" Body="&lt;p&gt;I have a quick question about the regex (neo)vim uses. After long hours of toiling, staring at documentation and trying everything else I could think of, I seem to be stuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm trying to accomplish is this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm working on updating the d.vim file, as there hasn't been an update to it since 2016 (AFAIK, anyways), and I don't know about you, but proper syntax highlighting is one of the great pleasures in my life.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been able to brute force vim regex in to my brain to figure out how to match everything I've wanted to up to this point, that point being trying to match the namespace of a function. For example, say I have the following chunk code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void main() {&#xA;    int i = 10;&#xA;    i += 2;&#xA;    std.writeln(i);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The thing I want to return is specifically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;std&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To accomplish this, and after (admittedly many hours of) trial and error, I've come up with the following chunk of regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v((^\W{-})@&amp;lt;=\w+)\@=(\.)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which returns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;std.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While I want it to &lt;em&gt;only&lt;/em&gt; return:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;std&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've searched high and low, far and wide, and yet come up empty handed. Is it possible to do this? Is there some way to trim the last character off of the end of a regex match? Please teach me, a mere novice, the ways of the RegEx!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Side question that doesn't take priority: I did manage to figure out a string in &lt;em&gt;regular&lt;/em&gt; regex that would return what I'm looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(?&amp;lt;=\s)\w+?(?=\.)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My totally-2nd-priority-question here would be: Is there some &quot;easy&quot; way to convert between &quot;regular&quot; regex and vim regex?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[ EDIT: Grammar 'n stuff ]&lt;/p&gt;&#xA;" OwnerUserId="21273" LastEditorUserId="21273" LastEditDate="2019-03-10T05:47:42.897" LastActivityDate="2019-03-10T05:47:42.897" Title="Using (neo)vim's regex to match up to but *excluding* a certain character?" Tags="|regular-expression|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19129" PostTypeId="2" ParentId="19119" CreationDate="2019-03-08T06:36:35.867" Score="0" Body="&lt;p&gt;You could always yank it and put it. I dont know how to create fzf mappings but the right hand side would basically be something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! yaW&amp;lt;C-w&amp;gt;pp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or in “pure” Ex commands, which work linewise:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yank | wincmd p | put&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on how much you want to yank. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-03-20T12:35:32.690" LastActivityDate="2019-03-20T12:35:32.690" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19130" PostTypeId="2" ParentId="19128" CreationDate="2019-03-08T06:43:21.433" Score="1" Body="&lt;p&gt;For a stab at your first question, I’d use the match start and end modifiers (&lt;code&gt;\zs&lt;/code&gt;, &lt;code&gt;\ze&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v\zs((^\W{-})@&amp;lt;=\w+)\ze\.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the second, it’s worth learning vim regex proper. Most of it makes sense, and the more complex features I don’t often need in day-to-day scenarios. Those are also well documented, and accessible when needed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, no, I am not aware of any tools to convert between vim regex and any other form (for lack of a standard, take, e.g., perl). That said, it gives me ideas for &#xA;another tool to build...&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-03-08T14:18:24.923" LastActivityDate="2019-03-08T14:18:24.923" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19131" PostTypeId="1" AcceptedAnswerId="19133" CreationDate="2019-03-08T09:41:43.577" Score="2" ViewCount="474" Body="&lt;p&gt;I have neovim 0.3.4 installed which means I can run the &lt;code&gt;:terminal&lt;/code&gt; command, however, doing &lt;code&gt;:echo has('terminal')&lt;/code&gt; shows &lt;code&gt;0&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I wonder if there is any other way I can test for its support because all my terminal mappings wrapped within an &lt;code&gt;if has('terminal)...endif&lt;/code&gt; do not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the vim manual that is the way to test it&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The terminal feature is optional, use this to check if your Vim has it: &#xA;          echo has('terminal')&#xA;  If the result is &quot;1&quot; you have it.&#xA;  -- &lt;a href=&quot;https://vimhelp.org/terminal.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vimhelp.org/terminal.txt.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="14568" LastActivityDate="2019-03-08T12:04:03.433" Title="How to test for :terminal support?" Tags="|neovim|terminal|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19132" PostTypeId="1" CreationDate="2019-03-08T10:01:38.740" Score="1" ViewCount="166" Body="&lt;p&gt;The image below shows two terminals. Both are running vim instances on remote machines (ssh and a serial connection through an UART cable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's on those machines don't have a way to access the system clipboard since they are running on physically different machines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way I know to copy content between them is by using the mouse (as shown in the video).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking for suggestions on how to do this without needing to leave the keyboard. I know the window switching can be solved with introducing &lt;code&gt;tmux&lt;/code&gt;, but how to solve the problem of a shared copy register?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some kind of integration with &lt;code&gt;xterm&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/h7KZi.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h7KZi.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7129" LastActivityDate="2019-03-08T10:01:38.740" Title="Sharing a copy register between vim on different machines?" Tags="|neovim|os-clipboard|tmux|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19133" PostTypeId="2" ParentId="19131" CreationDate="2019-03-08T10:32:14.193" Score="3" Body="&lt;p&gt;As said by Christian Brabandt in the question's comment:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;neovim always has the terminal included, so you can simply use has('nvim') the other test is for Vim specifically.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="14568" LastActivityDate="2019-03-08T10:32:14.193" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19134" PostTypeId="2" ParentId="19131" CreationDate="2019-03-08T12:04:03.433" Score="9" Body="&lt;p&gt;You can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(':terminal')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to check for existence of the &lt;code&gt;terminal&lt;/code&gt; command.  This works in both vim and neovim.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-03-08T12:04:03.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19135" PostTypeId="1" CreationDate="2019-03-08T13:33:20.570" Score="1" ViewCount="134" Body="&lt;p&gt;I've got a lot of HTML files, some of them with garbage indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I select a block, and then prettify/reindent the HTML within, adding in newlines where appropriate? I can install any plugin necessary.&lt;/p&gt;&#xA;" OwnerUserId="13555" LastActivityDate="2019-03-08T14:22:07.167" Title="How can I reindent/prettyify blocks of HTML code?" Tags="|indentation|filetype-html|plugin-vim-jsbeautify|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19137" PostTypeId="2" ParentId="19135" CreationDate="2019-03-08T14:22:07.167" Score="1" Body="&lt;p&gt;Read &lt;code&gt;:h 'equalprg'&lt;/code&gt;—you can set this to, e.g., &lt;code&gt;prettify&lt;/code&gt; for html filetypes by placing a &lt;code&gt;setlocal&lt;/code&gt; in &lt;code&gt;~/.vim/after/ftplugin/html.vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, use the &lt;code&gt;=&lt;/code&gt; operator over a motion, text object, or Visual selection to prettyify that code. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-08T14:22:07.167" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19138" PostTypeId="1" AcceptedAnswerId="19139" CreationDate="2019-03-08T18:03:27.873" Score="1" ViewCount="127" Body="&lt;p&gt;I'm trying to make a search and replace to format the following type of strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;INPUT&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;someName0 : in std_logic;&#xA;someName1 : in integer;&#xA;someName2 : out unsigned;&#xA;someName3 : out std_logic_vector(3 downto 0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OUTPUT&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;someName0 : in    std_logic;&#xA;someName1 : in    integer;&#xA;someName2 :   out unsigned;&#xA;someName3 :   out std_logic_vector(3 downto 0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I'm going to have two search and replaces. First one works on the in signals. However &quot;in&quot; also matches &quot;integer&quot;, so I need a way to specify to ignore those matches. I've tried using the following but it is saying the pattern wasn't found.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\&amp;lt;: in \&amp;gt;/: in    /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The basic problem then seems to be how to do a search and replace on some specific string based on what the following character is. Or maybe I'm just taking a horrible approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="21279" LastEditorUserId="2920" LastEditDate="2019-03-08T18:19:42.800" LastActivityDate="2019-03-10T11:50:18.553" Title="Search and replace only if following character is &quot;x&quot;" Tags="|regular-expression|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19139" PostTypeId="2" ParentId="19138" CreationDate="2019-03-08T18:16:23.140" Score="1" Body="&lt;p&gt;It's actually simpler than doing a search and replace based on the following character. Use word boundaries&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h \&amp;lt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            */\&amp;lt;*&#xA;\&amp;lt;  Matches the beginning of a word: The next char is the first char of a&#xA;    word.  The 'iskeyword' option specifies what is a word character.&#xA;    |/zero-width|&#xA;&#xA;                            */\&amp;gt;*&#xA;\&amp;gt;  Matches the end of a word: The previous char is the last char of a&#xA;    word.  The 'iskeyword' option specifies what is a word character.&#xA;    |/zero-width|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;:%s/\&amp;lt;in\&amp;gt;/&amp;amp;    /g&lt;/code&gt; will do what you're looking for. (The ampersand means &quot;the full text you matched&quot;, which is just &quot;in&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason why your search wasn't found is because you can never match &lt;code&gt;/ \&amp;gt;/&lt;/code&gt; because that means &lt;em&gt;a space, followed by the &lt;strong&gt;end of a word&lt;/em&gt;&lt;/strong&gt;. And &quot;end of word&quot; means &lt;em&gt;The previous char is the last char of a word&lt;/em&gt;, i.e. not a space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to do something like &lt;em&gt;match &lt;code&gt;in&lt;/code&gt; not followed by &lt;code&gt;t&lt;/code&gt;&lt;/em&gt;, you'd want something like &lt;code&gt;int\@!&lt;/code&gt;, but lookaheads and lookbehinds are fairly complicated. I try to avoid them where possible. Although in this particular case, you know that &lt;code&gt;in&lt;/code&gt; will be followed by a space, so something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/in /&amp;amp;   /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would work.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\&amp;lt;in\&amp;gt;\s*/in    /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will insure that running this substitution multiple times will not continually add spaces.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2019-03-08T18:43:33.547" LastActivityDate="2019-03-08T18:43:33.547" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19140" PostTypeId="2" ParentId="18316" CreationDate="2019-03-09T00:24:17.900" Score="1" Body="&lt;p&gt;I installed the &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-user&lt;/a&gt; and &lt;a href=&quot;https://github.com/glts/vim-textobj-comment&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-comment&lt;/a&gt; plugins, which provide just the text object I was looking for. If the cursor is on the second or third line in the code sample in the question, I can type &lt;code&gt;gqac&lt;/code&gt; to format both lines of the comment without touching either of the surrounding lines of code.&lt;/p&gt;&#xA;" OwnerUserId="671" LastActivityDate="2019-03-09T00:24:17.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19142" PostTypeId="1" AcceptedAnswerId="19186" CreationDate="2019-03-08T23:40:12.007" Score="10" ViewCount="3069" Body="&lt;p&gt;In Vimscript, if you use a function as an R-value (right hand side value) of an assignment statement, then the function simply evaluates. For example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let count_pattern += str2nr( strpart( execute( command ), 1 ) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, if a function is used not as an R-value of an assignment statement, then a &amp;quot;call&amp;quot; keyword must be used:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;call substitute( current_line, '\d\+', '\=add( listValues, submatch(0) )', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What is the necessity for the use of the &amp;quot;call&amp;quot; keyword? In most languages one can simply use a function by itself as a statement, but apparently in Vimscript you cannot.&lt;/p&gt;&#xA;" OwnerUserId="6952" OwnerDisplayName="Tyler Durden" LastEditorUserId="38936" LastEditDate="2023-02-24T04:58:20.593" LastActivityDate="2023-02-24T04:58:20.593" Title="Why do functions in Vimscript require a &quot;call&quot; statement?" Tags="|vimscript|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19143" PostTypeId="2" ParentId="19142" CreationDate="2019-03-09T06:07:11.083" Score="6" Body="&lt;p&gt;&lt;strong&gt;Hypothesis&lt;/strong&gt;:&#xA;When you're using a function as an R-value, or right hand side value, of an assignment statement, you're trying to assign the output of the R-value to the L-value variable.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Why &lt;code&gt;call&lt;/code&gt; is needed when calling a function&lt;/strong&gt;:&#xA;From the documentation (see &lt;code&gt;:h call&lt;/code&gt;) it is evident that &lt;code&gt;call&lt;/code&gt; will discard the return value of a function.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;                                        *:cal* *:call* *E107* *E117*&#xA;:[range]cal[l] {name}([arguments])&#xA;        Call a function.  The name of the function and its arguments&#xA;        are as specified with |:function|.  Up to 20 arguments can be&#xA;        used.  The returned value is discarded.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So, since when you're using functions as R-value you don't want to discard the output of the function, rather want to assign it to the L-value, you don't use call.&lt;/p&gt;&#xA;&lt;p&gt;Moreover, you don't always need &lt;code&gt;call&lt;/code&gt; to call a function. You can pass the function to another function for example,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:function GetMeow()&#xA;:  return &amp;quot;Meow String!&amp;quot;&#xA;:endfunction&#xA;&#xA;:GetMeow()       &amp;quot; ERROR!&#xA;&#xA;:call GetMeow()  &amp;quot; no output&#xA;&#xA;:echom GetMeow() &amp;quot; shows &amp;quot;Meow String!&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Many languages have the notion of &amp;quot;statements&amp;quot; and &amp;quot;expressions&amp;quot; and programs are generally sequences of statements. In C, &lt;code&gt;GetMeow()&lt;/code&gt; may be an expression but &lt;code&gt;GetMeow();&lt;/code&gt; (with a semicolon) is a statement. In vim, &lt;code&gt;GetMeow()&lt;/code&gt; is an expression but &lt;code&gt;call GetMeow()&lt;/code&gt; is a statement, which are referred to as &lt;code&gt;ex commands&lt;/code&gt;. It's really not as strange as the question implies.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="38936" LastEditDate="2023-02-24T04:57:17.847" LastActivityDate="2023-02-24T04:57:17.847" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19144" PostTypeId="1" AcceptedAnswerId="19145" CreationDate="2019-03-09T12:56:52.563" Score="3" ViewCount="185" Body="&lt;p&gt;I basically have the same problem as described &lt;a href=&quot;https://vi.stackexchange.com/q/8075/21292&quot;&gt;here&lt;/a&gt;. In my vimrc I have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; k gk&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; j gj&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; 0 g0&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; $ g$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This setting however gets somehow overwritten and I have to use &lt;code&gt;:source $MYVIMRC&lt;/code&gt; to get it to work again. The answers of the question above suggest that a plugin might overwrite my setting and to check that using &lt;code&gt;:verbose :map&lt;/code&gt;, which brings me to my question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find the mapping for any of my navigation keys. I see mappings for more complex key combinations like &lt;code&gt;[[&lt;/code&gt; by plugins, my own mappings for navigating windows or things that seem like variables to me like &lt;code&gt;&amp;lt;Plug&amp;gt;Tex_LeftRight&lt;/code&gt; (my guess that this are variables comes from &lt;a href=&quot;https://www.reddit.com/r/vim/comments/78izt4/please_help_understand_how_to_use_plug_mapping/doufox8&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;). However I cannot find any mappings for the &lt;em&gt;hjkl&lt;/em&gt; keys or other keys I am mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are those mapped by those &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mappings? If so, how can I resolve these? If not, how can I find out their mappings?&lt;/p&gt;&#xA;" OwnerUserId="21292" LastActivityDate="2019-03-09T16:06:04.410" Title="How to see the active mapping of hjkl" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19145" PostTypeId="2" ParentId="19144" CreationDate="2019-03-09T13:13:09.610" Score="5" Body="&lt;p&gt;You defined the mappings as buffer-local. So the mappings are only available in the buffer active at the time of executing the mapping commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;vimrc&lt;/code&gt; use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap k gk&#xA;nnoremap j gj&#xA;nnoremap 0 g0&#xA;nnoremap $ g$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also removed &lt;code&gt;&amp;lt;silence&amp;gt;&lt;/code&gt;. The &lt;code&gt;&amp;lt;silence&amp;gt;&lt;/code&gt; is only needed if you want to suppress some output, but I don't see the need here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check that a mapping is active, just execute &lt;code&gt;:map&lt;/code&gt; to see all mappings, but that produces lots of output (as you already know).&#xA;So executing &lt;code&gt;:map k&lt;/code&gt; will just show the mapping for &lt;code&gt;k&lt;/code&gt;. The output would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n  k           * gk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt; means, it is a normal mode mapping.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;k&lt;/code&gt; is the char mapped&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;*&lt;/code&gt; means that it is defined &lt;code&gt;noremap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gk&lt;/code&gt; is the value &lt;code&gt;k&lt;/code&gt; is mapped to&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help map-listing&lt;/code&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-09T16:06:04.410" LastActivityDate="2019-03-09T16:06:04.410" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19146" PostTypeId="2" ParentId="17177" CreationDate="2019-03-09T18:41:57.767" Score="0" Body="&lt;p&gt;B Layer already answered how to open a file in a new tab. That just leaves: Is it possible with &lt;code&gt;&amp;lt;Ctrl-Enter&amp;gt;&lt;/code&gt;. The short answer is: No.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check if a key or key-combination is mappable, do the following. Start Vim and change into insert mode. Then hit &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; followed by the key/key-kombination you plan to map. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you try that with &lt;kbd&gt;Ctrl-Enter&lt;/kbd&gt; the resulting input in Vim will be &lt;code&gt;^M&lt;/code&gt; (one character) usually displayed in light blue (depends on colorscheme). Now do the same with just &lt;kbd&gt;Enter&lt;/kbd&gt;. The result is the same &lt;code&gt;^M&lt;/code&gt; as above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conclusion: Vim can't distinguish between &lt;kbd&gt;Ctrl-Enter&lt;/kbd&gt; and &lt;kbd&gt;Enter&lt;/kbd&gt;, so &lt;kbd&gt;Ctrl-Enter&lt;/kbd&gt; can't be mapped. &lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-09T18:41:57.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19147" PostTypeId="1" AcceptedAnswerId="19150" CreationDate="2019-03-09T19:28:45.823" Score="1" ViewCount="532" Body="&lt;p&gt;I'm new to vim, and I find using &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to enter normal mode to be slow. I'm on &lt;strong&gt;Windows&lt;/strong&gt;. I seldom use the &lt;code&gt;&amp;lt;Alt&amp;gt;&lt;/code&gt; keys (left and right) when I'm editing text. It should be convenient to use &lt;code&gt;&amp;lt;Alt&amp;gt;&lt;/code&gt; to enter normal mode instead. What should I enter into my &lt;code&gt;vimrc&lt;/code&gt; use &lt;code&gt;&amp;lt;Alt&amp;gt;&lt;/code&gt; instead of &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to enter normal mode ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found articles online that explain this for MAC, but I could not find one for Windows.&lt;/p&gt;&#xA;" OwnerUserId="21298" LastEditorUserId="21298" LastEditDate="2019-03-09T19:40:45.273" LastActivityDate="2019-03-10T09:14:12.280" Title="&lt;Alt&gt; to enter normal mode on Windows" Tags="|vimrc|key-bindings|microsoft-windows|vim-windows|normal-mode|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19148" PostTypeId="1" AcceptedAnswerId="19149" CreationDate="2019-03-09T23:36:22.730" Score="1" ViewCount="168" Body="&lt;p&gt;When I start just vi which is alias to vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ which vi&#xA;alias vi='vim'&#xA;/usr/bin/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;my ~/.vimrc is used which is great, every configuration and all plugins are being properly loaded and etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if I try to run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi -u ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Eror detected while processing /home/dstoev/.vimrc:&#xA;line   10:&#xA;E117: Unknown function: pathogen#infect&#xA;line   19:&#xA;E15: Invalid expression: {&#xA;line   20:&#xA;E10: \ should be followed by /, ? or &amp;amp;&#xA;line   21:&#xA;E10: \ should be followed by /, ? or &amp;amp;&#xA;line   22:&#xA;E10: \ should be followed by /, ? or &amp;amp;&#xA;line   23:&#xA;E10: \ should be followed by /, ? or &amp;amp;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My ~/.vimrc :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;filetype plugin indent on&#xA;&quot; show existing tab with 4 spaces width&#xA;set tabstop=4&#xA;&quot; when indenting with '&amp;gt;', use 4 spaces width&#xA;set shiftwidth=4&#xA;&quot; On pressing tab, insert 4 spaces&#xA;set expandtab&#xA;set laststatus=2&#xA;syntax on&#xA;execute pathogen#infect()&#xA;&quot; let g:indent_guides_start_level = 1&#xA;let g:indent_guides_enable_on_vim_startup = 1&#xA;&quot; automatically start indent_guides plugin&#xA;let g:indent_guides_auto_colors = 0&#xA;&quot;hi IndentGuidesOdd  guibg=red   ctermbg=4&#xA;&quot;hi IndentGuidesEven guibg=green ctermbg=4&#xA;hi IndentGuidesOdd  ctermbg=black&#xA;hi IndentGuidesEven ctermbg=darkgrey&#xA;let g:lightline = {&#xA;      \ 'active': {&#xA;      \   'left': [ [ 'mode', 'paste' ], [ 'readonly', 'absolutepath', 'modified' ] ],&#xA;      \ }&#xA;      \ }&#xA;&quot; show full path in the status bar,plugin lightline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar  4 2019 16:22:18) on  4.20.13-200.fc29.x86_64 as a normal user (with sudo capabilities/wheel group).&lt;/p&gt;&#xA;" OwnerUserId="21300" LastActivityDate="2019-03-10T03:40:25.537" Title="vim -u ~/.vimrc gives error" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19149" PostTypeId="2" ParentId="19148" CreationDate="2019-03-10T03:40:25.537" Score="2" Body="&lt;p&gt;Your vimrc forgets to set &lt;code&gt;'nocompatible'&lt;/code&gt; if compatible is already set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically, when vim is started and finds a vimrc, it disables compatibility. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, such a check may not be done with the &lt;code&gt;-u&lt;/code&gt; option. So I’d do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;compatible&#xA;  set nocompatible&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the top of your vimrc. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Diagnosis&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The error traces in your snippet showed evidence of failing to interpret key features of vimscript, like autoload functions and line continuations. These are not present in vi, hence the guess about compatible. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-10T03:40:25.537" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19150" PostTypeId="2" ParentId="19147" CreationDate="2019-03-10T09:14:12.280" Score="1" Body="&lt;p&gt;The &lt;kbd&gt;Alt&lt;/kbd&gt; can't be mapped, as it is a &quot;modifier&quot;. It is only&#xA;detectable if it used together with some other key, like &lt;kbd&gt;Alt-F&lt;/kbd&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prove that, do the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open Vim, change into insert mode and hit &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;. Then hold down the &lt;kbd&gt;Alt&lt;/kbd&gt; key. Nothing happens. Only after you hit another key, some input appears. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to map the &lt;code&gt;Alt&lt;/code&gt; key alone, you have to reassign the &lt;code&gt;Alt&lt;/code&gt; key on the OS level.  For Windows that might be done with &lt;a href=&quot;https://www.autohotkey.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Autohotkey&lt;/a&gt; (not tested). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: Reassigning &lt;kbd&gt;Alt&lt;/kbd&gt; globally will affect all programs, but&#xA;Autohotkey seems to have &lt;a href=&quot;https://www.autohotkey.com/docs/commands/_IfWinActive.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;context-sensitive hotkeys&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to map &lt;code&gt;Alt-something&lt;/code&gt;, search Vi and Vim Stackexchange, there are &lt;a href=&quot;https://vi.stackexchange.com/search?q=Alt&quot;&gt;several questions&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-10T09:14:12.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19151" PostTypeId="1" CreationDate="2019-03-09T23:38:52.897" Score="1" ViewCount="71" Body="&lt;p&gt;I wanted to test if I can handle working on C++ projects in vim (well actually neovim). These were the core features, that I wanted to have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;syntax highlighting&lt;/li&gt;&#xA;&lt;li&gt;window splitting&lt;/li&gt;&#xA;&lt;li&gt;go to definition&lt;/li&gt;&#xA;&lt;li&gt;autocompletion&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The first two ones are obvious, so I got to setting up the third. I already knew about ctags, but I wanted to check if it works for me. I created two files:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;test.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;test.hpp&quot;&#xA;&#xA;void foo(int* a)&#xA;{&#xA;    (*a)++;&#xA;}&#xA;&#xA;&#xA;int main()&#xA;{&#xA;    int a = 5;&#xA;    foo(&amp;amp;a);&#xA;    bar(a);&#xA;    bar(5.0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;test.hpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void bar(int i)&#xA;{&#xA;&#xA;}&#xA;&#xA;void bar(double d)&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By running &lt;code&gt;ctags ./*&lt;/code&gt;, I created the corresponding &lt;code&gt;tags&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!_TAG_FILE_FORMAT   2   /extended format; --format=1 will not append ;&quot; to lines/&#xA;!_TAG_FILE_SORTED   1   /0=unsorted, 1=sorted, 2=foldcase/&#xA;!_TAG_OUTPUT_MODE   u-ctags /u-ctags or e-ctags/&#xA;!_TAG_PROGRAM_AUTHOR    Universal Ctags Team    //&#xA;!_TAG_PROGRAM_NAME  Universal Ctags /Derived from Exuberant Ctags/&#xA;!_TAG_PROGRAM_URL   https://ctags.io/   /official site/&#xA;!_TAG_PROGRAM_VERSION   0.0.0   /45968eff/&#xA;bar ./test.hpp  /^void bar(double d)$/;&quot;    f   typeref:typename:void&#xA;bar ./test.hpp  /^void bar(int i)$/;&quot;   f   typeref:typename:void&#xA;foo ./test.cpp  /^void foo(int* a)$/;&quot;  f   typeref:typename:void&#xA;main    ./test.cpp  /^int main()$/;&quot;    f   typeref:typename:int&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So being in &lt;code&gt;main&lt;/code&gt; and pressing &lt;code&gt;Ctrl-]&lt;/code&gt; on &lt;code&gt;foo(&amp;amp;a)&lt;/code&gt; jumps straight to the right function. The problem is, that when I am on &lt;code&gt;bar(a)&lt;/code&gt; and I do that, the windows switches to &lt;code&gt;test.hpp&lt;/code&gt;, but the &lt;code&gt;double d&lt;/code&gt; overload of the function is selected (I know it could through implicit conversion, but I have a better overload), not the one taking an int as an argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question here is: can I somehow configure vim or ctags to make it so I jump to a proper definition when using vim?&lt;/p&gt;&#xA;" OwnerDisplayName="dabljues" LastActivityDate="2019-03-10T09:33:35.013" Title="Ctags function overload" Tags="|ctags|" AnswerCount="0" CommentCount="2" ClosedDate="2019-03-11T07:34:11.470" ContentLicense="CC BY-SA 4.0" />
  <row Id="19152" PostTypeId="2" ParentId="19138" CreationDate="2019-03-10T11:50:18.553" Score="0" Body="&lt;p&gt;You don't need the word boundary start. Just replace the word boundary end for the match end flag:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:s/: in \ze[^ ]/&amp;amp;   /g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use&lt;code&gt;\zs&lt;/code&gt; for the match start flag as well.&lt;/p&gt;&#xA;" OwnerUserId="10482" LastActivityDate="2019-03-10T11:50:18.553" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19153" PostTypeId="2" ParentId="7561" CreationDate="2019-03-10T16:35:36.003" Score="1" Body="&lt;h2&gt;&lt;a href=&quot;https://clang.llvm.org/extra/clangd/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;clangd&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://github.com/prabirshrestha/vim-lsp&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-lsp&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have tested &lt;code&gt;clangd&lt;/code&gt; to see whether overloaded functions are actually distinguished when looking for the correct definition from a code line where one of the overloaded functions is used. In my minimal testing configuration using the vim plugin &lt;code&gt;vim-lsp&lt;/code&gt; it worked.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Minimal Configuration&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$MYVIMRC&lt;/code&gt; is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/defaults.vim&#xA;if executable('/usr/local/Cellar/llvm/7.0.0/bin/clangd')&#xA;    augroup Clangd&#xA;        autocmd User lsp_setup call lsp#register_server({&#xA;            \ 'name': 'clangd',&#xA;            \ 'cmd': {server_info-&amp;gt;['/usr/local/Cellar/llvm/7.0.0/bin/clangd']},&#xA;            \ 'whitelist': ['c', 'cpp', 'objc', 'objcpp'],&#xA;            \ })&#xA;        autocmd FileType c,cpp,objc,objcpp nmap &amp;lt;buffer&amp;gt; gd &amp;lt;plug&amp;gt;(lsp-definition)&#xA;        autocmd FileType c,cpp,objc,objcpp setlocal omnifunc=lsp#complete&#xA;    augroup END&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Installation of &lt;code&gt;vim-lsp&lt;/code&gt; which requires &lt;code&gt;async.vim&lt;/code&gt; into vim8 packpath&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd ~/.vim&#xA;$ git clone https://github.com/prabirshrestha/async.vim pack/prabirshrestha/start/async.vim/&#xA;$ git clone https://github.com/prabirshrestha/vim-lsp   pack/prabirshrestha/start/vim-lsp/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now your vim configuration should look like (omitting more deeply nested files and folders)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim&#xA;❯ tree -L 4 -F&#xA;.&#xA;├── pack/&#xA;│   └── prabirshrestha/&#xA;│       └── start/&#xA;│           ├── async.vim/&#xA;│           └── vim-lsp/&#xA;└── vimrc&#xA;&#xA;5 directories, 1 file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Test&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Now consider the cpp file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void abc(int a, int b) {&#xA;&#xA;}&#xA;&#xA;void abc(int a, int b, int c) {&#xA;&#xA;}&#xA;&#xA;int main(int argc, char const *argv[])&#xA;{&#xA;    abc(1,2);&#xA;    abc(1,2,3);&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;code&gt;gd&lt;/code&gt; on &lt;code&gt;abc&lt;/code&gt; of&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;abc(1,2)&lt;/code&gt; jumps to first line, and of&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;abc(1,2,3)&lt;/code&gt; jumps to fifth line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Environment and versions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vim&lt;/code&gt;: MacVim 8.1.950 (155); installed from DMG from &lt;a href=&quot;https://github.com/macvim-dev/macvim/releases&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt; on macOS 10.14.3&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;clangd&lt;/code&gt;: 7.0.0; installed with &lt;code&gt;$ brew install llvm&lt;/code&gt; (not in &lt;code&gt;$PATH&lt;/code&gt; by default, use absolute path)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vim-lsp&lt;/code&gt;: &lt;a href=&quot;https://github.com/prabirshrestha/vim-lsp/tree/e3f69339efbf9582be1859766e2b2ed353bedfbc&quot; rel=&quot;nofollow noreferrer&quot;&gt;e3f6933&lt;/a&gt; (Mar 7, 2019)&#xA;and &lt;code&gt;async.vim&lt;/code&gt;: &lt;a href=&quot;https://github.com/prabirshrestha/async.vim/tree/f3014550d7a799097e56b094104dd2cd66cf2612&quot; rel=&quot;nofollow noreferrer&quot;&gt;f301455&lt;/a&gt; (Feb 13, 2019)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-03-12T09:49:13.890" LastActivityDate="2019-03-12T09:49:13.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19154" PostTypeId="1" CreationDate="2019-03-10T20:07:30.147" Score="1" ViewCount="419" Body="&lt;p&gt;I have the following minimal .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; syntax enable&#xA;syntax case match&#xA;syntax keyword MyTodo TODO PENDING &#xA;syntax keyword MyTodoIP IN PROGRESS &#xA;syntax keyword MyTodoClosed CLOSED COMPLETE DONE&#xA;hi MyTodo        ctermfg=yellow&#xA;hi MyTodoIP      ctermfg=darkgreen&#xA;hi MyTodoClosed  ctermfg=darkgray&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As is, this works fine (&lt;code&gt;TODO&lt;/code&gt;, etc are correctly highlighted).&#xA;However, &lt;strong&gt;When I uncomment &lt;code&gt;syntax enable&lt;/code&gt;, my syntax keywords are not highlighted as I have specified.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked at &lt;code&gt;:help syn-enable&lt;/code&gt; and it says the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The &lt;code&gt;:syntax enable&lt;/code&gt; command will keep your current color settings.&#xA;  This allows using &lt;code&gt;:highlight&lt;/code&gt; commands to set your preferred colors&#xA;  before or after using this command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I also tried using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match MyTodoMatch &quot;TODO&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;code&gt;hi MyTodoWatch&lt;/code&gt; with the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is &lt;a href=&quot;https://stackoverflow.com/q/8423228/2778474&quot;&gt;a similar question on stackoverflow from 2011&lt;/a&gt; that seems to be having the same problem, but no solution so I'm posting here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing here? &lt;strong&gt;How can I use &lt;code&gt;syntax enable&lt;/code&gt; with custom &lt;code&gt;keywords&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, with &lt;code&gt;syntax enable&lt;/code&gt; 'enabled', I can &lt;code&gt;source ~/.vimrc&lt;/code&gt; after opening vim and the desired syntax &lt;em&gt;is&lt;/em&gt; applied correctly.&lt;/p&gt;&#xA;" OwnerUserId="15023" LastEditorUserId="15023" LastEditDate="2019-03-10T20:41:57.850" LastActivityDate="2019-03-11T14:24:16.003" Title="Is there a conflict between `syntax enable` and custom keywords?" Tags="|syntax-highlighting|syntax|keyword|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19156" PostTypeId="1" AcceptedAnswerId="19184" CreationDate="2019-03-11T06:47:59.490" Score="2" ViewCount="2482" Body="&lt;p&gt;On my Ubuntu OS, I see this in &lt;code&gt;/etc/vim/vimrc.tiny&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat /etc/vim/vimrc.tiny&#xA;&quot; Vim configuration file, in effect when invoked as &quot;vi&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the partial output from &lt;code&gt;:version&lt;/code&gt;:&lt;br&gt;&#xA;&lt;code&gt;system vimrc file: &quot;$VIM/vimrc&quot;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like the VIM environment variable is not defined - &lt;code&gt;echo $VIM&lt;/code&gt; doesn't show anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how does &lt;code&gt;vi&lt;/code&gt; know to read &lt;code&gt;/etc/vim/vimrc.tiny&lt;/code&gt;? &lt;/p&gt;&#xA;" OwnerUserId="21314" LastEditorUserId="19763" LastEditDate="2019-03-15T08:04:50.970" LastActivityDate="2019-03-15T08:14:24.017" Title="Understanding how &quot;vi&quot; finds its global configuration file" Tags="|vimrc|linux-ubuntu|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19157" PostTypeId="1" AcceptedAnswerId="19160" CreationDate="2019-03-11T07:19:19.067" Score="0" ViewCount="231" Body="&lt;p&gt;I deleted every files and dir in &lt;code&gt;~/.vim/&lt;/code&gt;. I know some dir and files is needed. Fortunately I have my &lt;code&gt;vimrc&lt;/code&gt; file. But I don't know which files and dir are needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I create theme automatically?&lt;/p&gt;&#xA;" OwnerUserId="4680" LastActivityDate="2019-03-11T10:11:00.740" Title="initialization .vim directory base contents" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19158" PostTypeId="2" ParentId="19154" CreationDate="2019-03-11T09:08:14.820" Score="2" Body="&lt;p&gt;The only explanation I have, is that there is another &lt;code&gt;syntax enable&lt;/code&gt; (or &lt;code&gt;syntax on&lt;/code&gt;) somewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Background: If &lt;code&gt;syntax enable&lt;/code&gt; is executed and syntax was enabled before, all&#xA;syntax items are cleared. See &lt;code&gt;$VIMRUNTIME/syntax/syntax.vim&lt;/code&gt; line 12.  The&#xA;documentation only talks about &lt;code&gt;:highlight&lt;/code&gt;, not &lt;code&gt;:syntax&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have the directory &lt;code&gt;$HOME/.vim&lt;/code&gt; with other setup files, rename it to&#xA;&lt;code&gt;$HOME/.vim.off&lt;/code&gt; and test again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't help, you could run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -V15verbose.out ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace &lt;code&gt;...&lt;/code&gt; with whatever you use to reproduce the problem. After Vim is started, check that the problem can be reproduced and exit Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command will write a trace of all commands to the file &lt;code&gt;verbose.out&lt;/code&gt;. You&#xA;can then grep that file for &lt;code&gt;syntax enable&lt;/code&gt; or &lt;code&gt;syntax on&lt;/code&gt; to check if there is another invocation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that Vim appends to that file, so you might want to delete it between tries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: You should also check &lt;code&gt;verbose.log&lt;/code&gt; for &lt;code&gt;sy clear&lt;/code&gt;, &lt;code&gt;syn clear&lt;/code&gt; or &lt;code&gt;syntax clear&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-11T14:24:16.003" LastActivityDate="2019-03-11T14:24:16.003" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19159" PostTypeId="2" ParentId="19156" CreationDate="2019-03-11T09:26:48.157" Score="2" Body="&lt;p&gt;Have a look at &lt;code&gt;:h VIMINIT&lt;/code&gt; there is a list of places vim looks for a config, and it will use the first one found:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most used are the user vimrc files:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The user vimrc file(s):&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&quot;$HOME/.vimrc&quot;         (for Unix and OS/2) (*)&lt;/li&gt;&#xA;  &lt;li&gt;&quot;$HOME/.vim/vimrc&quot;     (for Unix and OS/2) (*)&lt;/li&gt;&#xA;  &lt;li&gt;&quot;s:.vimrc&quot;             (for Amiga) (*)&lt;/li&gt;&#xA;  &lt;li&gt;&quot;home:.vimrc&quot;          (for Amiga) (*)&lt;/li&gt;&#xA;  &lt;li&gt;&quot;home:vimfiles:vimrc&quot;  (for Amiga) (*)&lt;/li&gt;&#xA;  &lt;li&gt;&quot;$VIM/.vimrc&quot;          (for OS/2 and Amiga) (*)&lt;/li&gt;&#xA;  &lt;li&gt;&quot;$HOME/_vimrc&quot;         (for MS-DOS and Win32) (*)&lt;/li&gt;&#xA;  &lt;li&gt;&quot;$HOME/vimfiles/vimrc&quot; (for MS-DOS and Win32) (*)&lt;/li&gt;&#xA;  &lt;li&gt;&quot;$VIM/_vimrc&quot;          (for MS-DOS and Win32) (*)&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But there is also a backup and systemwide files. Have a look at the help since it is somewhat different depending on version,&lt;/p&gt;&#xA;" OwnerUserId="11316" LastActivityDate="2019-03-11T09:26:48.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19160" PostTypeId="2" ParentId="19157" CreationDate="2019-03-11T10:11:00.740" Score="1" Body="&lt;p&gt;I think &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27runtimepath%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'runtimepath'&lt;/code&gt;&lt;/a&gt; might help your answer your question. The directory &lt;code&gt;~/.vim&lt;/code&gt; is a part of &lt;code&gt;'runtimepath'&lt;/code&gt; by default on Unix systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The help states the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a list of directories which will be searched for runtime files:&#xA;&#xA;  filetype.vim  filetypes by file name |new-filetype|&#xA;  scripts.vim   filetypes by file contents |new-filetype-scripts|&#xA;  autoload/     automatically loaded scripts |autoload-functions|&#xA;  colors/       color scheme files |:colorscheme|&#xA;  compiler/     compiler files |:compiler|&#xA;  doc/          documentation |write-local-help|&#xA;  ftplugin/     filetype plugins |write-filetype-plugin|&#xA;  indent/       indent scripts |indent-expression|&#xA;  keymap/       key mapping files |mbyte-keymap|&#xA;  lang/         menu translations |:menutrans|&#xA;  menu.vim      GUI menus |menu.vim|&#xA;  pack/         packages |:packadd|&#xA;  plugin/       plugin scripts |write-plugin|&#xA;  print/        files for printing |postscript-print-encoding|&#xA;  spell/        spell checking files |spell|&#xA;  syntax/       yntax files |mysyntaxfile|&#xA;  tutor/        files for vimtutor |tutor|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;None of these directories &lt;em&gt;have&lt;/em&gt; to exist, they are just a way to configure vim and these directories in &lt;code&gt;~/.vim&lt;/code&gt; are just user defined configurations. The built-in configurations live in other &lt;code&gt;runtimepath&lt;/code&gt; directories like &lt;code&gt;$VIMRUNTIME&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you added some configurations by yourself and didn't versioned them (in git for example) then you'll have lost these settings but that will not prevent Vim from working properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About your last sentence &quot;Can I create a theme automatically?&quot; I think that would deserve a question on its own with more clarifications about what you mean exactly but the files used to define a colorscheme can live in &lt;code&gt;~/.vim/colors&lt;/code&gt;. Now I don't know what you mean by creating a colorscheme &lt;em&gt;automatically&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-03-11T10:11:00.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19161" PostTypeId="2" ParentId="18819" CreationDate="2019-03-11T12:09:37.547" Score="1" Body="&lt;p&gt;You can mark the current position of the cursor typing &lt;code&gt;m&lt;/code&gt; followed by an alphabet in normal mode which is the register to store it. If you use &lt;code&gt;ma&lt;/code&gt; to mark it, you can jump back to this position by &lt;code&gt;`a&lt;/code&gt; or &lt;code&gt;'a&lt;/code&gt;. For more details, run &lt;code&gt;:help mark&lt;/code&gt; in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you had used certain commands to navigate the documents, you can also have a look at &lt;code&gt;:help jump-motions&lt;/code&gt; in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As quoted there&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A &quot;jump&quot; is one of the following commands: &quot;'&quot;, &quot;`&quot;, &quot;G&quot;, &quot;/&quot;, &quot;?&quot;, &quot;n&quot;,&#xA;  &quot;N&quot;, &quot;%&quot;, &quot;(&quot;, &quot;)&quot;, &quot;[[&quot;, &quot;]]&quot;, &quot;{&quot;, &quot;}&quot;, &quot;:s&quot;, &quot;:tag&quot;, &quot;L&quot;, &quot;M&quot;, &quot;H&quot; and&#xA;  the commands that start editing a new file.  If you make the cursor &quot;jump&quot;&#xA;  with one of these commands, the position of the cursor before the jump is&#xA;  remembered.  You can return to that position with the &quot;''&quot; and &quot;``&quot; command,&#xA;  unless the line containing that position was changed or deleted.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="16789" LastActivityDate="2019-03-11T12:09:37.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19162" PostTypeId="1" AcceptedAnswerId="19163" CreationDate="2019-03-11T12:19:45.863" Score="2" ViewCount="72" Body="&lt;p&gt;I'm currently writing a plugin to quickly appends commented &lt;code&gt;TODO:&lt;/code&gt; codetags to the end of a line in any file type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make vim make use of it's &lt;code&gt;commenstring&lt;/code&gt; feature to append a comment that corresponds to the filetype?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently entering those manually but I feel like there may be a more platform agnostic way to do this...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what some of my maps look like right now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Markdown todo's&#xA;autocmd FileType markdown nnoremap &amp;lt;buffer&amp;gt; td o&amp;lt;Esc&amp;gt;o&amp;lt;Esc&amp;gt;O[comment]:&amp;lt;Space&amp;gt;#&amp;lt;Space&amp;gt;TODO:&amp;lt;Space&amp;gt;&#xA;autocmd FileType markdown nnoremap &amp;lt;buffer&amp;gt; TD 0/TODO:&amp;lt;Enter&amp;gt;kd2j&#xA;&quot; Vim todo's&#xA;autocmd FileType vim nnoremap &amp;lt;buffer&amp;gt; td A&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&quot;TODO:&amp;lt;Space&amp;gt;&#xA;autocmd FileType vim nnoremap &amp;lt;buffer&amp;gt; TD 0/&quot;TODO:&amp;lt;Enter&amp;gt;d$&#xA;&quot; PHP todo's&#xA;autocmd FileType php nnoremap &amp;lt;buffer&amp;gt; td A&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;//TODO:&amp;lt;Space&amp;gt;&#xA;autocmd FileType php nnoremap &amp;lt;buffer&amp;gt; TD j0?//TODO:&amp;lt;Enter&amp;gt;d$&#xA;&quot; Javascript todo's&#xA;autocmd FileType javascript nnoremap &amp;lt;buffer&amp;gt; td A&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;//TODO:&amp;lt;Space&amp;gt;&#xA;autocmd FileType javascript nnoremap &amp;lt;buffer&amp;gt; TD j0?//TODO:&amp;lt;Enter&amp;gt;d$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20416" LastActivityDate="2019-03-11T12:55:55.057" Title="Mapping to insert comment at the end of a line" Tags="|vimscript|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19163" PostTypeId="2" ParentId="19162" CreationDate="2019-03-11T12:48:39.743" Score="2" Body="&lt;p&gt;You could use a combination of &lt;code&gt;:execute&lt;/code&gt; and &lt;code&gt;substitute&lt;/code&gt;. The idea would be to use &lt;code&gt;substitute&lt;/code&gt; to replace the &lt;code&gt;%s&lt;/code&gt;  in the &lt;code&gt;commentstring&lt;/code&gt;  by your &lt;code&gt;TODO&lt;/code&gt; and then use &lt;code&gt;execute&lt;/code&gt; to forge the content of the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your js mapping could be something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap td :execute &quot;norm! A  &quot; . substitute(&amp;amp;commentstring, '%s', 'TODO ', '')&amp;lt;CR&amp;gt;A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;execute&lt;/code&gt; lets you execute a command forged from a concatenation of strings.&lt;/li&gt;&#xA;&lt;li&gt;The concatenated strings are &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;norm! A&lt;/code&gt; to execute  &lt;code&gt;A&lt;/code&gt; as in normal mode (The &lt;code&gt;!&lt;/code&gt; is important if your users remaps &lt;code&gt;A&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;substitute(&amp;amp;commentstring, '%s', 'TODO ', '')&lt;/code&gt; is the &lt;code&gt;commentstring&lt;/code&gt; with &lt;code&gt;%s&lt;/code&gt;  replaced by &lt;code&gt;TODO&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; validates the &lt;code&gt;execute&lt;/code&gt; command&lt;/li&gt;&#xA;&lt;li&gt;The final &lt;code&gt;A&lt;/code&gt; allows the user continue to type their comment.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Relevant help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27commentstring%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'commentstring'&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :execute&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#substitute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h substitute()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could also have a look at the source code of &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDCommenter&lt;/a&gt; to see how they use &lt;code&gt;'commentstring'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-03-11T12:55:55.057" LastActivityDate="2019-03-11T12:55:55.057" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19164" PostTypeId="2" ParentId="15343" CreationDate="2019-03-11T15:25:12.047" Score="1" Body="&lt;p&gt;I was facing the same problem in MobaXTerm for a long time up to version 11.1. The reason (and solution) I finally found is twofold:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;E810&lt;/code&gt; is about Vim being unable to write and read temporary files. If you run fugitive you get &lt;code&gt;E484&lt;/code&gt; about the same.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;E97&lt;/code&gt; is about wrong output of the &lt;code&gt;diff&lt;/code&gt; executable called by Vim.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;Resolving &lt;code&gt;E810&lt;/code&gt; and &lt;code&gt;E484&lt;/code&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;In my case it was about wrong &lt;code&gt;set shellxquote=\&quot;&lt;/code&gt;, which I got during my searching for a solution. That setting is responsible for how Vim quotes filenames. Removing it, resulting in unsetting, resolved the error with writing and reading temporary files.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Resolving &lt;code&gt;E97&lt;/code&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This is where the &lt;code&gt;diffexpr&lt;/code&gt; comes to help. But it might not be sufficient itself. In my case I had to install &lt;code&gt;diffutils&lt;/code&gt; package too as the &lt;code&gt;/bin/diff&lt;/code&gt; was pointing to &lt;code&gt;busybox&lt;/code&gt;, which supports &lt;em&gt;only&lt;/em&gt; the unified diff format, while Vim requires ed-style (i.e. normal) diff format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now my diff executables are:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bsh prettyprint-override&quot;&gt;&lt;code&gt;lrwxrwxrwx     16 Jan 29 13:26 /bin/diff -&amp;gt; /bin/busybox.exe*&#xA;-rwxr-xr-x 201.5K Dec  6  2016 /bin/diff.exe*&#xA;-rwxr-xr-x  56.0K Dec  6  2016 /bin/diff3.exe*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The difference in output is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bsh prettyprint-override&quot;&gt;&lt;code&gt;$ /bin/diff one two&#xA;--- one&#xA;+++ two&#xA;@@ -1,3 +1,3 @@&#xA; no change&#xA;-file one&#xA;+file two&#xA; no change&#xA;&#xA;$ /bin/diff.exe one two&#xA;2c2&#xA;&amp;lt; file one&#xA;---&#xA;&amp;gt; file two&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All that needs to be done is to point to the proper one in the &lt;code&gt;diffexpr&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bsh prettyprint-override&quot;&gt;&lt;code&gt;silent execute &quot;!/bin/diff.exe  &quot; . opt . v:fname_in . &quot; &quot; . v:fname_new . &quot; &amp;gt; &quot; . v:fname_out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even the &lt;code&gt;-a --binary&lt;/code&gt; options are not required.&lt;/p&gt;&#xA;" OwnerUserId="16164" LastEditorUserId="16164" LastEditDate="2019-03-11T15:33:29.873" LastActivityDate="2019-03-11T15:33:29.873" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19165" PostTypeId="1" CreationDate="2019-03-11T22:31:24.220" Score="1" ViewCount="199" Body="&lt;p&gt;I can have multiple splits in a new tab. To change background and foreground of active and inactive &lt;code&gt;tabpages&lt;/code&gt;, I can do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi TabLineSel term=bold ctermfg=White ctermbg=DarkBlue&#xA;hi TabLine ctermfg=White ctermbg=Black  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, if I have multiple splits in a tab, Vim shows this by a number in the &lt;code&gt;tabline&lt;/code&gt;.  How do I change that number's color?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of attached picture, how do I change the color of number 3, meaning I have 3 splits? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ixVrV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ixVrV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please let me know and thank you. &lt;/p&gt;&#xA;" OwnerUserId="21038" LastEditorUserId="19763" LastEditDate="2019-03-12T06:23:23.373" LastActivityDate="2019-03-12T15:03:55.767" Title="How to change color of the splits counter in a 'tabline'" Tags="|vimrc|colorscheme|tabbed-user-interface|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19167" PostTypeId="2" ParentId="19165" CreationDate="2019-03-12T04:27:32.230" Score="1" Body="&lt;p&gt;As far as I remember it uses &lt;code&gt;Title&lt;/code&gt; highlight group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS, indeed for default tabline &lt;code&gt;Title&lt;/code&gt; is used:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qSLXR.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qSLXR.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-03-12T07:02:06.137" LastActivityDate="2019-03-12T07:02:06.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19168" PostTypeId="1" AcceptedAnswerId="19170" CreationDate="2019-03-12T07:00:04.453" Score="3" ViewCount="8225" Body="&lt;p&gt;I was reading &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/starting.html#initialization&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/starting.html#initialization&lt;/a&gt;, but couldn't immediately find the answer. Is the &lt;code&gt;$VIM&lt;/code&gt; environment variable hardcoded in its binary (not read from a config file)? The binary is built differently depending on the OS, so I'm guessing that's how the &lt;code&gt;$VIM&lt;/code&gt; differs per OS.&lt;/p&gt;&#xA;" OwnerUserId="21314" LastActivityDate="2021-07-13T07:11:45.263" Title="How does VIM sets the $VIM environment variable?" Tags="|environment-variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19169" PostTypeId="2" ParentId="19168" CreationDate="2019-03-12T07:33:05.867" Score="3" Body="&lt;p&gt;Linux view, for more details see Doktor OSwaldo answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The installation directory is defined during build (to be exact: It is defined when configuring the build.). The default value of &lt;code&gt;$VIM&lt;/code&gt; is a subdirectory below the installation directory and is compiled in (&lt;code&gt;&amp;lt;inst-dir&amp;gt;/share/vim&lt;/code&gt; on Linux).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can override this by setting the environment variable &lt;code&gt;VIM&lt;/code&gt; before starting Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The compiled-in value of &lt;code&gt;$VIM&lt;/code&gt; is part of the output from &lt;code&gt;:version&lt;/code&gt; or &lt;code&gt;vim --version&lt;/code&gt;. Just search for &lt;code&gt;fall-back for $VIM&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Within Vim you can display the actual value by executing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo $VIM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-12T07:54:14.703" LastActivityDate="2019-03-12T07:54:14.703" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19170" PostTypeId="2" ParentId="19168" CreationDate="2019-03-12T07:37:03.690" Score="2" Body="&lt;p&gt;The whole process can be read under &lt;code&gt;:h $VIM&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;To avoid the need for every user to set the $VIM environment variable,&#xA;Vim will try to get the value for $VIM in this order:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The value defined by the $VIM environment variable.  You can use this to    make Vim look in a specific directory for its support&#xA;files.  Example:&#xA;setenv VIM /home/paul/vim&lt;/li&gt;&#xA;&lt;li&gt;The path from 'helpfile' is used, unless it contains some environment    variable too (the default is&#xA;&amp;quot;$VIMRUNTIME/doc/help.txt&amp;quot;: chicken-egg    problem).  The file name&#xA;(&amp;quot;help.txt&amp;quot; or any other) is removed.  Then    trailing directory&#xA;names are removed, in this order: &amp;quot;doc&amp;quot;, &amp;quot;runtime&amp;quot; and&lt;br /&gt;&#xA;&amp;quot;vim{version}&amp;quot; (e.g., &amp;quot;vim54&amp;quot;).&lt;/li&gt;&#xA;&lt;li&gt;For MSDOS, Win32 and OS/2 Vim tries to use the directory name of the    executable.  If it ends in &amp;quot;/src&amp;quot;, this is removed.  This is&#xA;useful if you    unpacked the .zip file in some directory, and&#xA;adjusted the search path to    find the vim executable.  Trailing&#xA;directory names are removed, in this    order: &amp;quot;runtime&amp;quot; and&#xA;&amp;quot;vim{version}&amp;quot; (e.g., &amp;quot;vim54&amp;quot;).&lt;/li&gt;&#xA;&lt;li&gt;For Unix the compile-time defined installation directory is used (see the    output of &amp;quot;:version&amp;quot;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Once Vim has done this once, it will set the $VIM environment&#xA;variable.  To change it later, use a &amp;quot;:let&amp;quot; command like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    :let $VIM = &amp;quot;/home/paul/vim/&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It is sometimes hard to find stuff in the vim help &amp;quot;immediately&amp;quot; but it is a great source. The vim helpfile is a mighty tool which will guide you a long way before you need this site, once you got the hang of it!&lt;/p&gt;&#xA;" OwnerUserId="11316" LastEditorUserId="11316" LastEditDate="2021-07-13T07:11:45.263" LastActivityDate="2021-07-13T07:11:45.263" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19171" PostTypeId="1" CreationDate="2019-03-12T11:00:00.670" Score="0" ViewCount="573" Body="&lt;p&gt;I'm trying to make autocommands that will run only when the buffer is a man page (&lt;code&gt;:Man&lt;/code&gt;), but I can't get the right pattern as I'm not too familiar with regex and globs. Here's what I've tried so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufEnter *man://* call Myfunc()&#xA;autocmd! BufEnter [^man://]* call Myfunc()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but nothing seems to work. Any alternative ideas are okay too.&lt;/p&gt;&#xA;" OwnerUserId="18514" LastEditorUserId="10604" LastEditDate="2019-12-28T18:41:25.693" LastActivityDate="2019-12-28T18:41:25.693" Title="How to match autocmd pattern for unique file" Tags="|vimscript|autocmd|manpages|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19172" PostTypeId="2" ParentId="19171" CreationDate="2019-03-12T11:07:05.393" Score="1" Body="&lt;p&gt;From what I have tested this works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test()&#xA;    echom &quot;entering man buffer &quot; . expand('%')&#xA;endfunction&#xA;&#xA;autocmd! BufEnter man://* call Test()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-03-12T11:07:05.393" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19173" PostTypeId="1" CreationDate="2019-03-12T11:08:57.687" Score="1" ViewCount="56" Body="&lt;p&gt;If I open Macvim, everything works fine, unless I zoom in (using Cmd+&quot;+&quot;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do that, then I get a strange black boarder around the added bit of the window and the whole thing freezes.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I see: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PkUq6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PkUq6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;(except, bizarrely, it isn't, because I &lt;em&gt;see&lt;/em&gt; a black boarder, the mac screenshot shows a light gray one, and the image uploaded to SE mysteriously makes it white, which suggests there's something wrong with me)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...and there is a 40 second video of the problem here: &lt;a href=&quot;https://youtu.be/cjKWRGLSWTk&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://youtu.be/cjKWRGLSWTk&lt;/a&gt;, which, thankfully, shows the same black border I see. Thank you YouTube.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This appears to be part of a few linked bugs on MacVim, I have quite a lot of trouble with the display not refreshing if I've changed the zoom level while the app is already full-screen and that's quite frustrating. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some useful information.  I'm on High Sierra 10.13.6. and I get the same error with /Applications/MacVim.app/Contents/bin/mvim -u NONE -U NONE.  My custom vimrc is here: &lt;a href=&quot;https://github.com/joereddington/dotvimdirectory&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/joereddington/dotvimdirectory&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Josephs-Mini:.vim josephreddington$ defaults read org.vim.MacVim | grep 'MM\|SU'.&#xA;    MMAutosaveColumns = 155;&#xA;    MMAutosaveRows = 61;&#xA;    MMCurrentPreferencePane = General;&#xA;    MMLastWindowClosedBehavior = 2;&#xA;    MMOpenInCurrentWindow = 1;&#xA;    MMTopLeftPoint = &quot;{375, 980}&quot;;&#xA;    MMUseCGLayerAlways = 1;&#xA;    SUEnableAutomaticChecks = 0;&#xA;    SUHasLaunchedBefore = 1;&#xA;    SUSendProfileInfo = 0;&#xA;Josephs-Mini:.vim josephreddington$ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8792" LastEditorUserId="8792" LastEditDate="2019-03-18T11:33:31.047" LastActivityDate="2019-03-18T11:33:31.047" Title="Why does MacVim crash on Zoom" Tags="|macvim|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19174" PostTypeId="1" CreationDate="2019-03-12T12:38:24.273" Score="1" ViewCount="100" Body="&lt;p&gt;I am using VIM on Ubuntu 18.04 with the EurKEY keyboard layout.&#xA;I find the layout useful since it allows me to type German letters like &quot;öüä&quot; easily while still using a more or less standard US layout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the layout 'AltGr'+'r' is mapped to the symbol 'ý'.&#xA;The problem is when I am in INSERT mode and I type 'AltGr'+'r' the symbol 'ý' is not inserted, instead the symbol under the courser is moved to some totally different location.&#xA;The location is deterministic in the sense that the symbol is always moved to the same location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea why that is the case?&#xA;Actually I do not need the symbol 'ý' at all (I just happen to press the combination very often ...) so disabling it all together would be an option for me. Nevertheless I would also like to understand what is causing the error?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need any more information about setup please let me know.&lt;/p&gt;&#xA;" OwnerUserId="21336" LastActivityDate="2020-04-05T16:01:25.167" Title="EurKEY input moves characters in INSERT mode" Tags="|keyboard-layout|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19175" PostTypeId="2" ParentId="19174" CreationDate="2019-03-12T14:58:49.163" Score="1" Body="&lt;p&gt;This is probably due to the way Alt combinations are send: usually it’s &lt;code&gt;&amp;lt;Esc&amp;gt;{some other characters}&lt;/code&gt; (you can find out which via &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; I believe). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see why in Insert mode this can cause edits—vim sees and Escape and then some (usually deterministic) normal mode commands. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for a solution, I’d suggest looking at other questions on vi.stackexchange regarding Alt mappings (IIRC correctly, there are some good ones—anyone who finds them should please edit them in). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the meantime, take a look at the &lt;code&gt;:h digraphs&lt;/code&gt; feature. It’s a useful way to type special characters. I’ve even &lt;a href=&quot;https://github.com/benknoble/Dotfiles/blob/master/links/vim/autoload/digraphs.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;created a function to make using them easier&lt;/a&gt; which I’ve mapped to &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; in insert mode. Then certain digraphs are enabled without pressing &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt;; they are disabled once you leave insert mode. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-12T14:58:49.163" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19176" PostTypeId="1" CreationDate="2019-03-12T19:24:31.937" Score="6" ViewCount="6867" Body="&lt;p&gt;In order to have my vim text always bold, I found this config in stackoverflow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :hi MyGroup cterm=bold&#xA; :match MyGroup /./&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But somehow, it has messed up search highlighting. It is no longer highlighted, but it shouldn't have any effect on that, since it is only changing the cterm property, and not ctermfg/ctermbg.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought if I added the following I would fix it, but it didn't:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :hi Search ctermbg=yellow ctermfg=black term=bold cterm=bold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any solutions?&lt;/p&gt;&#xA;" OwnerUserId="21343" LastEditorUserId="28" LastEditDate="2019-03-13T11:02:35.133" LastActivityDate="2019-10-03T01:12:52.100" Title="How to make vim text bold?" Tags="|vimrc|highlight|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19177" PostTypeId="1" AcceptedAnswerId="19182" CreationDate="2019-03-12T23:20:11.120" Score="2" ViewCount="267" Body="&lt;p&gt;I want to make a mapping that jumps to the file of a mark but on the last visited line. Ideally I would write something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap z&amp;lt;mark&amp;gt; '&amp;lt;mark&amp;gt;`&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;z&lt;/code&gt; is some command prefix and &lt;code&gt;&amp;lt;mark&amp;gt;&lt;/code&gt; is the mark I want to use. However I don't see any way to implement this for all marks. I could manually expand this but that is nasty.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap zA 'A`&quot;&#xA;nnoremap zB 'B`&quot;&#xA;nnoremap zC 'C`&quot;&#xA;&quot; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was wondering if there is anything nicer then iterating over all marks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus points if the command can be &lt;code&gt;za&lt;/code&gt; and the mark is automatically upper-cased.&lt;/p&gt;&#xA;" OwnerUserId="6999" LastActivityDate="2019-03-13T06:50:36.287" Title="How to make mapping for any mark" Tags="|key-bindings|mark|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19178" PostTypeId="2" ParentId="18620" CreationDate="2019-03-13T00:12:16.080" Score="1" Body="&lt;p&gt;Here's one way of doing this with no plugins:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It follows the structure of romainl's &lt;a href=&quot;https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7&quot; rel=&quot;nofollow noreferrer&quot;&gt;Redir.vim&lt;/a&gt; script and writes the output of &lt;code&gt;oldfiles&lt;/code&gt; (which is not the same thing as &lt;code&gt;browse oldfiles&lt;/code&gt;) to a temporary buffer opened with a vertical split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also defines a function &lt;code&gt;VisitFilesFromLineRange&lt;/code&gt; that allows a user to visit multiple files at once if a line range in visual line mode is currently active.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also defined a wrapper function around &lt;code&gt;VisitFilesFromLineRange&lt;/code&gt; that takes an explicit range argument and rebound &lt;code&gt;gf&lt;/code&gt; in visual mode so that it ultimately calls &lt;code&gt;VisitFilesFromLineRange&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;Oldfiles&lt;/code&gt; function, by itself, is far more useful than the new &lt;code&gt;gf&lt;/code&gt; binding in my opinion since it makes it easy to search through the list of old files using ordinary vim bindings.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Oldfiles()&#xA;  &quot; kill all the windows called oldfiles_scratch&#xA;  &quot; we don't need them around anymore&#xA;  for win in range(1, winnr('$'))&#xA;    if getwinvar(win, 'oldfiles_scratch')&#xA;      execute win . 'windo close'&#xA;    endif&#xA;  endfor&#xA;  &quot; redirect the stuff that normally prints to the console&#xA;  &quot; to the variable &quot;output&quot;. Note that in &quot;redir =&amp;gt; output&quot;&#xA;  &quot; output refers to the variable itself not its contents.&#xA;  &quot; If VimL were more like C, this would be written&#xA;  &quot;&#xA;  &quot;     redir =&amp;gt; &amp;amp;output&#xA;  &quot;&#xA;  redir =&amp;gt; output&#xA;  execute &quot;oldfiles&quot;&#xA;  redir END&#xA;  &quot; create a new pane thingy but vertically. seems to create it&#xA;  &quot; on the left by default which is cool.&#xA;  vnew&#xA;  &quot; tag this particular window with out variable outfiles_scratch&#xA;  &quot; so we know to kill it later.&#xA;  let w:oldfiles_scratch = 1&#xA;  &quot; our new window is ephemeral, give it ephemeralish properties.&#xA;  &quot; NOTE: explicitly make the buffer modifiable NOW.&#xA;  &quot; we set it to nomodifiable after trimming the line numbers.&#xA;  setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile modifiable&#xA;  &quot; dump the contents of output as lines&#xA;  call setline(1, split(output, &quot;\n&quot;))&#xA;  &quot; remove the leading numbers. Leading numbers make it harder to ``gf&quot; the lines we want.&#xA;  execute &quot;%s/^\\d\\+: //&quot;&#xA;  &quot; go to the top line&#xA;  execute &quot;1&quot;&#xA;  &quot; make it nomodifiable&#xA;  setlocal nomodifiable&#xA;endfunction&#xA;command! -nargs=0 Oldfiles silent call Oldfiles()&#xA;&#xA;&#xA;&#xA;function! VisitFilesFromLineRange(low, hi)&#xA;  &quot; save the current buffer index&#xA;  &quot; so we can read from it later&#xA;  let current_buf = bufnr(&quot;%&quot;)&#xA;  &quot; keep track of whether we spawned a new tab already or not&#xA;  &quot; there isn't really a convenient way to spawn a truly-empty&#xA;  &quot; container tab that we then fill up so it's easier to spawn&#xA;  &quot; the container &quot;on demand&quot; as we process our first line&#xA;  let did_tabnew = 0&#xA;  &quot; walk the array of lines from the buffer&#xA;  for line in getbufline(current_buf, a:low, a:hi)&#xA;    &quot; escape the line name before doing stuff to it&#xA;    let eline = fnameescape(line)&#xA;    &quot; perform a horizontal split or tabedit depending on whether&#xA;    &quot; the new tab has been created or not&#xA;    if did_tabnew&#xA;      execute(&quot;split &quot; . eline)&#xA;    else&#xA;      let did_tabnew = 1&#xA;      execute(&quot;tabedit &quot; . eline)&#xA;    endif&#xA;  endfor&#xA;endfunction&#xA;command! -nargs=+ VisitFilesFromLineRange silent call VisitFilesFromLineRange(&amp;lt;f-args&amp;gt;)&#xA;&#xA;&#xA;&quot; define a function that accepts a range&#xA;&quot; and forwards it into VisitFilesFromLineRange with the appropriate arguments&#xA;function! RangeFuncVisitFilesFromRange() range&#xA;  call VisitFilesFromLineRange(a:firstline, a:lastline)&#xA;endfunction&#xA;&quot; VisitLines command accepting a range argument for convenience&#xA;command! -range VisitLines silent &amp;lt;line1,line2&amp;gt;call RangeFuncVisitFilesFromRange()&#xA;&#xA;&quot; detect visual line mode and call RangeFuncVisitFilesFromRange&#xA;&quot; otherwise delegate to the default implementation of &quot;gf&quot; for visual mode&#xA;xnoremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; gf (mode() ==# &quot;V&quot;) ? &quot;:call RangeFuncVisitFilesFromRange()\&amp;lt;cr&amp;gt;&quot; : &quot;gf&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2019-03-13T00:12:16.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19179" PostTypeId="1" AcceptedAnswerId="19180" CreationDate="2019-03-13T00:46:21.727" Score="2" ViewCount="857" Body="&lt;p&gt;I modified a colorscheme file which generates E419/E420 errors when loading, but I would like to ignore them silently. &lt;code&gt;silent!&lt;/code&gt; and &lt;code&gt;try&lt;/code&gt;/&lt;code&gt;catch&lt;/code&gt; aren't working for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .vimrc is shown below. All the loading of the &quot;theme&quot; is done at &lt;code&gt;source ~/.vim/theme.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;.vimrc&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set backspace=2&#xA;&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;set softtabstop=4&#xA;set expandtab&#xA;set smarttab&#xA;&#xA;:au FileType cpp setlocal tabstop=2 shiftwidth=2 softtabstop=2 cindent&#xA;:au FileType tcl setlocal tabstop=2 shiftwidth=2 softtabstop=2&#xA;:au FileType make setlocal noexpandtab&#xA;&#xA;source ~/.vim/theme.vim                                                                                                                                                                                             &#xA;&#xA;set cursorline&#xA;set hlsearch&#xA;set showmatch&#xA;set matchtime=0&#xA;syntax enable&#xA;&#xA;set number&#xA;set relativenumber&#xA;nmap &amp;lt;F3&amp;gt; :set nu! rnu!&amp;lt;CR&amp;gt;&#xA;&#xA;nnoremap Q &amp;lt;nop&amp;gt;&#xA;&#xA;&quot; *last-position-jump*&#xA;:au BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) | exe &quot;normal! g`\&quot;&quot; | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Attempt 1: ~/.vim/theme.vim&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co=256&#xA;let g:gruvbox_termcolors=16&#xA;set background=dark&#xA;silent! colorscheme gruvbox&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;silent!&lt;/code&gt; I still get these errors whenever I start vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;3_HL:&#xA;line   43:&#xA;E419: FG color unknown&#xA;E420: BG color unknown&#xA;E420: BG color unknown&#xA;E420: BG color unknown&#xA;E419: FG color unknown&#xA;E419: FG color unknown&#xA;E419: FG color unknown&#xA;E419: FG color unknown&#xA;E419: FG color unknown&#xA;E419: FG color unknown&#xA;E419: FG color unknown&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Attempt 2: ~/.vim/theme.vim&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co=256&#xA;let g:gruvbox_termcolors=16&#xA;set background=dark&#xA;try&#xA;    colorscheme gruvbox&#xA;catch&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;try&lt;/code&gt;/&lt;code&gt;catch&lt;/code&gt;, I still get the same errors as above.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Attempt 3: ~/.vimrc&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I also tried the same techniques directly in my ~/.vimrc, wrapping them around the source command, but I still get the same errors.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! source ~/.vim/theme.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;try&#xA;    source ~/.vim/theme.vim&#xA;catch&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I silence these errors every time I launch vim?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;vim --version output&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct  7 2016 22:47:41)&#xA;Included patches: 1-2&#xA;Compiled by ...&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    +mouse_sgr       +tag_old_static&#xA;+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           +mouse_urxvt     -tcl&#xA;+balloon_eval    +folding         +mouse_xterm     +termguicolors&#xA;+browse          -footer          +multi_byte      +terminfo&#xA;++builtin_terms  +fork()          +multi_lang      +termresponse&#xA;+byte_offset     +gettext         -mzscheme        +textobjects&#xA;+channel         -hangul_input    +netbeans_intg   +timers&#xA;+cindent         +iconv           +num64           +title&#xA;+clientserver    +insert_expand   +packages        +toolbar&#xA;+clipboard       +job             +path_extra      +user_commands&#xA;+cmdline_compl   +jumplist        -perl            +vertsplit&#xA;+cmdline_hist    +keymap          +persistent_undo +virtualedit&#xA;+cmdline_info    +lambda          +postscript      +visual&#xA;+comments        +langmap         +printer         +visualextra&#xA;+conceal         +libcall         +profile         +viminfo&#xA;+cryptv          +linebreak       -python          +vreplace&#xA;+cscope          +lispindent      -python3         +wildignore&#xA;+cursorbind      +listcmds        +quickfix        +wildmenu&#xA;+cursorshape     +localmap        +reltime         +windows&#xA;+dialog_con_gui  -lua             +rightleft       +writebackup&#xA;+diff            +menu            -ruby            +X11&#xA;+digraphs        +mksession       +scrollbind      -xfontset&#xA;+dnd             +modify_fname    +signs           +xim&#xA;-ebcdic          +mouse           +smartindent     +xpm&#xA;+emacs_tags      +mouseshape      +startuptime     +xsmp_interact&#xA;+eval            +mouse_dec       +statusline      +xterm_clipboard&#xA;+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save&#xA;+extra_search    -mouse_jsbterm   +syntax          &#xA;+farsi           +mouse_netterm   +tag_binary   &#xA;...&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lelf -lnsl  -lselinux -lacl -lattr   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21346" LastActivityDate="2019-03-13T01:02:15.590" Title="Silence errors from colorscheme, silent! and try/catch not working" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19180" PostTypeId="2" ParentId="19179" CreationDate="2019-03-13T01:02:15.590" Score="2" Body="&lt;p&gt;The command &lt;code&gt;syntax enable&lt;/code&gt; reloads your current color scheme.  This is documented at &lt;code&gt;:help syntax-loading&lt;/code&gt;.  If there is an error in the colors file, you'll see it then.  Options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Move &lt;code&gt;syntax enable&lt;/code&gt; to before the &lt;code&gt;colorscheme&lt;/code&gt; statement.  This makes the most sense- you should be enabling syntax highlighting before loading color schemes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;silent! syntax enable&lt;/code&gt; (or try/catch).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-03-13T01:02:15.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19181" PostTypeId="1" AcceptedAnswerId="19183" CreationDate="2019-03-13T06:28:34.393" Score="2" ViewCount="771" Body="&lt;p&gt;Vim probably did this by default, whenever I invoke files from a project that has its own &lt;code&gt;.vimrc&lt;/code&gt;s it's auto-sourced. Neovim, however, doesn't import &lt;code&gt;vimrc&lt;/code&gt;s. How can I make Neovim scan and use project-specific configuration files?&lt;/p&gt;&#xA;" OwnerUserId="20750" LastActivityDate="2019-03-13T09:27:40.433" Title="Importing project-specific rc files in Neovim" Tags="|vimrc|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19182" PostTypeId="2" ParentId="19177" CreationDate="2019-03-13T06:50:36.287" Score="2" Body="&lt;p&gt;Try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyJumps()&#xA;    let chr=nr2char(getchar())&#xA;    if chr &amp;lt; 'A' || chr &amp;gt; 'Z'&#xA;        return &quot;&quot;&#xA;    endif&#xA;    return &quot;'&quot; . chr . '`&quot;'&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt; z MyJumps()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This maps &lt;code&gt;z&lt;/code&gt; to call the function &lt;code&gt;MyJump()&lt;/code&gt;. This functions first gets&#xA;one char of input. If the input is not in the range &lt;code&gt;A-Z&lt;/code&gt; it returns an empty string.&#xA;Else it returns &lt;code&gt;'&amp;lt;char&amp;gt;`&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the &lt;code&gt;nnoremap&lt;/code&gt; is a map-expression, Vim takes the returned characters and executes them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help map-expr&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-13T06:50:36.287" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19183" PostTypeId="2" ParentId="19181" CreationDate="2019-03-13T09:27:40.433" Score="4" Body="&lt;p&gt;Vim doesn't do that by default, you probably had &lt;code&gt;set exrc&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt;, see &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27exrc%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'exrc'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the doc says if you add &lt;code&gt;set exrc&lt;/code&gt; to your vimrc you also probably want to add &lt;code&gt;set secure&lt;/code&gt; (&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27secure%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'secure'&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both of these options are also available in neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also want to have a look at &lt;a href=&quot;https://github.com/LucHermitte/local_vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;this Luc Hermitte's plugin&lt;/a&gt; which also allows to enable local configurations files with more options.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-03-13T09:27:40.433" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19184" PostTypeId="2" ParentId="19156" CreationDate="2019-03-13T15:49:00.983" Score="2" Body="&lt;p&gt;This is not a answer to your question, but a follow up on you comment:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;From the above methods, I found &lt;code&gt;$VIM&lt;/code&gt; to be &lt;code&gt;/usr/share/vim&lt;/code&gt;. So following&#xA;   the &lt;code&gt;:version&lt;/code&gt; output, I would think that the system &lt;code&gt;vimrc&lt;/code&gt; file is&#xA;   &lt;code&gt;/usr/share/vim/vimrc&lt;/code&gt;. However, &lt;code&gt;$ ll /usr/share/vim/vimrc&lt;/code&gt; shows it's&#xA;   point to &lt;code&gt;/usr/share/vim/vimrc -&amp;gt; /etc/vim/vimrc&lt;/code&gt;, not&#xA;   &lt;code&gt;/etc/vim/vimrc.tiny&lt;/code&gt;, and there is no mention of &lt;code&gt;.tiny&lt;/code&gt; in&#xA;   &lt;code&gt;/etc/vim/vimrc&lt;/code&gt;. So it's not still unclear how the &lt;code&gt;.tiny&lt;/code&gt; file is used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You have &lt;code&gt;/etc/vim/vimrc&lt;/code&gt; and &lt;code&gt;/etc/vim/vimrc.tiny&lt;/code&gt;, because you installed multiple vim-related packages on Ubuntu.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/etc/vim/vimrc.tiny&lt;/code&gt; is from the package &quot;vim-tiny&quot;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/etc/vim/vimrc&lt;/code&gt; is from the package &quot;vim-common&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In a default setup of Ubuntu only &quot;vim-tiny&quot; is installed. This is a small Vim build with limited features (e.g. no syntax highlighting). This package also created the file &lt;code&gt;/usr/share/vim/vimrc&lt;/code&gt; as a symbolic link to &lt;code&gt;/etc/vim/vimrc.tiny&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later on a &quot;bigger&quot; Vim package was installed, like &quot;gvim&quot;. This has a dependency on &quot;vim-common&quot;. The package &quot;vim-common&quot; contains all the runtime files (syntax highlighting etc). This package also creates the file &lt;code&gt;/usr/share/vim/vimrc&lt;/code&gt;, but this time as a symbolic link to &lt;code&gt;/etc/vim/vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So: The file &lt;code&gt;/etc/vim/vimrc.tiny&lt;/code&gt; is from the package &quot;vim-tiny&quot; and is not used anymore. The package is still installed and you can call the executable with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim.tiny&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To see all installed vim-related packages execute&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ dpkg -l \*vim\*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-15T08:14:24.017" LastActivityDate="2019-03-15T08:14:24.017" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19185" PostTypeId="2" ParentId="19176" CreationDate="2019-03-13T16:45:55.487" Score="1" Body="&lt;p&gt;Despite this seeming like a fairly simple task, I can't think of straight forward way to do this. The best way I know how is to create your own color file and change all the &lt;code&gt;cterm&lt;/code&gt;s to bold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using one of the default color schemes you can find it at &lt;code&gt;.../Vim/vim##/colors&lt;/code&gt; where &lt;code&gt;##&lt;/code&gt; is the version you're running.&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2019-03-13T16:45:55.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19186" PostTypeId="2" ParentId="19142" CreationDate="2019-03-13T16:48:30.770" Score="8" Body="&lt;p&gt;IMO, we have to consider that &lt;code&gt;vi&lt;/code&gt; and &lt;code&gt;ed&lt;/code&gt; had ex-commands, and that &lt;code&gt;vim&lt;/code&gt; introduces functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;vim&lt;/code&gt; interprets a line, it needs a way to distinguish &lt;code&gt;:substitute&lt;/code&gt; from &lt;code&gt;substitute()&lt;/code&gt;, or &lt;code&gt;:MyUserThing&lt;/code&gt; (which is a command) from &lt;code&gt;MyUserThing()&lt;/code&gt; (which is a function).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why &lt;code&gt;:call&lt;/code&gt; is required. As &lt;code&gt;:let&lt;/code&gt;, this is an ex-command. The difference between these two is that the result will be ignored as we don't need it, but this is anecdotal. What's important is to be able to distinguish ex-commands from function calls.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2019-03-13T18:43:31.203" LastActivityDate="2019-03-13T18:43:31.203" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19187" PostTypeId="2" ParentId="10937" CreationDate="2019-03-13T18:32:44.267" Score="0" Body="&lt;p&gt;Since Python is an Indented language, The easier solution is to set &lt;code&gt;foldmethod=indent&lt;/code&gt;. The crux of this solution is when you initialize list(or any code) in multiple lines, then they also get folded in a separate fold which is unwanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But vim does have syntax fold support for python out of the box, As suggested below in comment, running &lt;code&gt;:help ft-python-indent&lt;/code&gt; gives:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Indent after an open paren:                                                                                                                                              &lt;/p&gt;&#xA;  &#xA;  &lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;   let g:pyindent_open_paren = '&amp;amp;sw * 2'      &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &lt;/blockquote&gt;&#xA;  &#xA;  &lt;p&gt;Indent after a nested paren:                                                                                                                                             &lt;/p&gt;&#xA;  &#xA;  &lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;  let g:pyindent_nested_paren = '&amp;amp;sw'   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &lt;/blockquote&gt;&#xA;  &#xA;  &lt;p&gt;Indent for a continuation line:                                                                                                                                          &lt;/p&gt;&#xA;  &#xA;  &lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;   let g:pyindent_continue = '&amp;amp;sw * 2' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For more details, check this &lt;a href=&quot;https://stackoverflow.com/a/4789615/6299181&quot;&gt;answer&lt;/a&gt; or run &lt;code&gt;:help fold-commands&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16789" LastEditorUserId="16789" LastEditDate="2019-03-13T19:05:53.217" LastActivityDate="2019-03-13T19:05:53.217" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19188" PostTypeId="1" AcceptedAnswerId="19189" CreationDate="2019-03-13T20:18:13.223" Score="0" ViewCount="44" Body="&lt;p&gt;Recently I had to compile a latex file a few times, &lt;code&gt;:!pdflatex filename.tex&lt;/code&gt; did the trick. But is there a way in normal mode to repeat commands like these which are in the recent history,but used repeatedly for a short time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting keybinding to for &lt;code&gt;:command&lt;/code&gt; is not what I am looking for, since the command is used only for a short time. &lt;/p&gt;&#xA;" OwnerUserId="16789" LastActivityDate="2019-03-13T21:55:28.517" Title="Running previous run command that was run in normal mode using colon" Tags="|command-line|normal-mode|repeated-commands|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19189" PostTypeId="2" ParentId="19188" CreationDate="2019-03-13T21:55:28.517" Score="2" Body="&lt;p&gt;As Ralf mentions in the comments, the &lt;code&gt;:&lt;/code&gt; register always contains the last colon command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;@:&lt;/code&gt; will replay the last command, and &lt;code&gt;@@&lt;/code&gt; should work after that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, you can &lt;code&gt;:&amp;lt;Up&amp;gt;&lt;/code&gt; for command line history, or use &lt;code&gt;q:&lt;/code&gt; for the command line window. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-13T21:55:28.517" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19190" PostTypeId="1" AcceptedAnswerId="19192" CreationDate="2019-03-14T07:53:09.427" Score="1" ViewCount="61" Body="&lt;p&gt;I happen to come across the = register. I checked &lt;code&gt;:h @=&lt;/code&gt; and &lt;code&gt;:h recording&lt;/code&gt; where it is mentioned. I am not able to understand how to use it. It could be helpful to know a valid usecase for the same.&lt;/p&gt;&#xA;" OwnerUserId="16789" LastActivityDate="2019-03-14T08:29:54.220" Title="Valid usecases for `=` macro register" Tags="|macro|repeated-commands|expression-register|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19191" PostTypeId="2" ParentId="19190" CreationDate="2019-03-14T08:29:44.667" Score="2" Body="&lt;p&gt;Assume you often need to insert a timestamp in your documents. Then you could define a mapping for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;C-G&amp;gt;t &amp;lt;C-R&amp;gt;=strftime(&quot;%Y-%m-%dT%H:%M:%S%z&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-14T08:29:44.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19192" PostTypeId="2" ParentId="19190" CreationDate="2019-03-14T08:29:54.220" Score="4" Body="&lt;p&gt;So let's begin by quoting the doc &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%40%3d&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h @=&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When typing the '=' after &quot; or CTRL-R the cursor moves to the command-line,&#xA;where you can enter any expression (see |expression|).  All normal&#xA;command-line editing commands are available, including a special history for&#xA;expressions.  When you end the command-line by typing &amp;lt;CR&amp;gt;, Vim computes the&#xA;result of the expression.  If you end it with &amp;lt;Esc&amp;gt;, Vim abandons the&#xA;expression.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it is also worth reading &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#usr_41.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h usr_41.txt&lt;/code&gt;&lt;/a&gt; about the expressions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now how can you use the expression register?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is important to understand the the expression register is not meant to be used in a macro, it more common usage is to insert the result of an expression while you are in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example you can do simple math. Let's get this in our buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 + 2 + 3 + 4 = &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to put the result you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0               To go the the beginning of the line&#xA;yf4             To yank the text from 1 to 4&#xA;A               To start inserting at the end of the line&#xA;&amp;lt;C-r&amp;gt;           Here the magic begins, this allow to insert the content of a register&#xA;=               To start editing the content of the expression register&#xA;&amp;lt;C-r&amp;gt;&quot;          To insert your yanked text in the expression register&#xA;&amp;lt;CR&amp;gt;            To validate the operation&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;em&gt;voila&lt;/em&gt; vim computes the content of the expression register (i.e. &lt;code&gt;1 + 2 + 3 + 4&lt;/code&gt;) and inserts the result (i.e. &lt;code&gt;10&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 + 2 + 3 + 4 = 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the actual use cases depends on your usage but evaluating some vimscript while you are in insert mode can sometimes be useful. &lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-03-14T08:29:54.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19193" PostTypeId="2" ParentId="10368" CreationDate="2019-03-14T12:15:16.273" Score="13" Body="&lt;h3&gt;Stage Complete or Partial Hunks with &lt;a href=&quot;https://github.com/airblade/vim-gitgutter&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;vim-gitgutter&lt;/code&gt;&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Stage Complete Hunk&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Leader&amp;gt;hs&lt;/code&gt; or&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:GitGutterStageHunk&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Stage Part of an &lt;em&gt;Additions-only&lt;/em&gt; Hunk (since 8/2019)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Visual mode&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;{Visual}&amp;lt;Leader&amp;gt;hs&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;GitGutterStageHunk&lt;/code&gt;&lt;br&gt;&#xA;(&lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; are as always inserted for you)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Range&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:42,45GitGutterStageHunk&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Stage Part of any Hunk via &lt;em&gt;Preview Window&lt;/em&gt; (since 8/2019)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Preview the hunk, e.g. &lt;code&gt;&amp;lt;Leader&amp;gt;hp&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move to the preview window, e.g. &lt;code&gt;:wincmd P&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Delete the lines you do not want to stage&lt;/li&gt;&#xA;&lt;li&gt;Stage the remaining lines, e.g. &lt;code&gt;&amp;lt;Leader&amp;gt;hs&lt;/code&gt; or &lt;code&gt;:GitGutterStageHunk&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Updated: 17.8.2019&lt;/strong&gt; due to recent commits &lt;a href=&quot;https://github.com/airblade/vim-gitgutter/commit/bc1d28db46f7d8f174df4b0c98da092e10369281&quot; rel=&quot;noreferrer&quot;&gt;bc1d28d&lt;/a&gt; and &lt;a href=&quot;https://github.com/airblade/vim-gitgutter/commit/b036fcf5274315fbefde53f20bb9b30f19ce80b0&quot; rel=&quot;noreferrer&quot;&gt;b036fcf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-08-17T06:58:11.597" LastActivityDate="2019-08-17T06:58:11.597" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19194" PostTypeId="1" CreationDate="2019-03-14T13:31:00.073" Score="1" ViewCount="129" Body="&lt;p&gt;I'm seeing strange behavior in my windows gvim -- it will continue to indent after a function ends, even once characters in column 0 have been entered:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo(k):&#xA;  return 42&#xA;  &quot;&quot;&quot;Still indenting&quot;&quot;&quot;&#xA;# Comment here&#xA;  &quot;&quot;&quot;Still indenting&quot;&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme slate&#xA;&#xA;filetype plugin indent on&#xA;set tabstop=2&#xA;set shiftwidth=2&#xA;set expandtab&#xA;set ai&#xA;&#xA;set backspace=2&#xA;set backspace=indent,eol,start&#xA;&#xA;set cindent&#xA;autocmd FileType python setlocal foldmethod=indent smartindent shiftwidth=2 ts=2 et cinwords=if,elif,else,for,while,try,except,finally,def,class&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I also have appended the python vim file found here: &lt;a href=&quot;https://www.vim.org/scripts/download_script.php?src_id=21056&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.vim.org/scripts/download_script.php?src_id=21056&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Removing autoindent/ai so that only smartindent is being used does not seem to solve the problem... any thoughts?&lt;/p&gt;&#xA;" OwnerUserId="21364" LastActivityDate="2023-08-03T20:36:18.723" Title="gVim python continues to indent after function ends" Tags="|vimrc|gvim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19195" PostTypeId="2" ParentId="19194" CreationDate="2019-03-14T14:24:18.910" Score="3" Body="&lt;p&gt;I'm afraid there's no solution for that: &lt;code&gt;vim&lt;/code&gt; (or even &lt;code&gt;Python&lt;/code&gt;) can't detect the end of the function if you don't change the indentation (besides the &lt;code&gt;return 42&lt;/code&gt;). The comment on first column may seem strange but is not enough to tell &lt;code&gt;Python&lt;/code&gt; that your function has ended:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;def test():&#xA;    &amp;quot;&amp;quot;&amp;quot;comment&amp;quot;&amp;quot;&amp;quot;&#xA;    print(&amp;quot;on test&amp;quot;)&#xA;# comment&#xA;    print(&amp;quot;still on test&amp;quot;)&#xA;    return 42&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you run &lt;code&gt;print(test())&lt;/code&gt; you will get:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;on test&#xA;still on test&#xA;42&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11384" LastEditorUserId="10604" LastEditDate="2023-08-03T20:36:18.723" LastActivityDate="2023-08-03T20:36:18.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19196" PostTypeId="1" CreationDate="2019-03-14T17:23:18.067" Score="3" ViewCount="890" Body="&lt;p&gt;I've been using Vim regularly for a decade, but still feel rather inexperienced because there is so much of Vim that I am not aware of and do not use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I sometimes want to see two different parts of a single file and edit both simultaneously, without having to either&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Make an edit at the top, scroll down, make an edit at the bottom, scroll up (etc.) &lt;strong&gt;or&lt;/strong&gt; &lt;/li&gt;&#xA;&lt;li&gt;have two views open, make an edit in one session, save the file in that session, switch to the second session, reload the file in the second session, make an edit, save, switch to first session (etc.). &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is there a good way to do this in Vim? &lt;/p&gt;&#xA;" OwnerUserId="21369" LastEditorUserId="1841" LastEditDate="2019-03-15T08:04:17.613" LastActivityDate="2019-03-15T08:04:17.613" Title="Is it possible to simultaneously edit one file in two views?" Tags="|buffers|split|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19197" PostTypeId="2" ParentId="19196" CreationDate="2019-03-14T17:35:11.147" Score="9" Body="&lt;p&gt;I think you need to read &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#windows-intro&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h windows-intro&lt;/code&gt;&lt;/a&gt; which explains the concepts of buffer, window and tab, summarized like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Summary:&#xA;   A buffer is the in-memory text of a file.&#xA;   A window is a viewport on a buffer.&#xA;   A tab page is a collection of windows.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you should read the end of the help file &lt;code&gt;windows.txt&lt;/code&gt; because it is really useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what you want is to create new windows which can be done in different ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Via the command line &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Asplit&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :split&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Avsplit&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :vsplit&lt;/code&gt;&lt;/a&gt; should be helpful&lt;/li&gt;&#xA;&lt;li&gt;In normal mode &lt;kbd&gt;ctrl+w&lt;/kbd&gt;+&lt;kbd&gt;ctrl+s&lt;/kbd&gt; and &lt;kbd&gt;ctrl+w&lt;/kbd&gt;+&lt;kbd&gt;ctrl+v&lt;/kbd&gt; are helpful&lt;/li&gt;&#xA;&lt;li&gt;In a script &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Awincmd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :wincmd&lt;/code&gt;&lt;/a&gt; can be useful.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then to move between the splits and to move the splits themselves you probably want to read &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#window-move-cursor&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h window-move-cursor&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#window-moving&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h window-moving&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In your precise use case I would:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open my buffer with &lt;code&gt;:e&lt;/code&gt;, &lt;code&gt;:find&lt;/code&gt;, netrw or however you usually do&lt;/li&gt;&#xA;&lt;li&gt;Switch create a new split with &lt;code&gt;:vs&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move to the new split with &lt;kbd&gt;ctrl+w&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;Go to the bottom of the buffer in the new split with &lt;kbd&gt;G&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;And then move between my splits with &lt;kbd&gt;ctrl+w&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt; and &lt;kbd&gt;ctrl+w&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-03-14T17:35:11.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19198" PostTypeId="1" AcceptedAnswerId="19199" CreationDate="2019-03-15T10:10:06.127" Score="1" ViewCount="64" Body="&lt;p&gt;I have a mapping set by a plugin that I want to unmap, which is the sequence &quot;cop&quot;. The mapping is defined in unimpaired plugin: &lt;code&gt;nnoremap cop &amp;lt;Nop&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map cop&#xA;n  cop         * &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the mapping is there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I fail to detect it in my script (I don't want &lt;code&gt;nunmap&lt;/code&gt; , because maparg(&quot;cop&quot;, &quot;n&quot;) returns an empty string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo empty(maparg(&quot;cop&quot;, &quot;n&quot;))&#xA;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;maparg(&quot;cop&quot;, &quot;n&quot;, 0, 1)&lt;/code&gt; returns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{'silent': 0, 'noremap': 1, 'lhs': 'cop', 'mode': 'n', 'nowait': 0, 'expr': 0, 'sid': 34, 'rhs': '&amp;lt;Nop&amp;gt;', 'buffer': 0}     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does the first maparg returns an empty string, and how to detect if the mapping is present?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Vim 8.0.1453)&lt;/p&gt;&#xA;" OwnerUserId="20552" LastActivityDate="2019-03-15T10:59:39.537" Title="maparg returns empty string, but the mapping is effective" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19199" PostTypeId="2" ParentId="19198" CreationDate="2019-03-15T10:59:39.537" Score="0" Body="&lt;p&gt;Thanks to @Ralf comment, upgrading to Vim 8.1 solved the issue&lt;/p&gt;&#xA;" OwnerUserId="20552" LastActivityDate="2019-03-15T10:59:39.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19200" PostTypeId="1" AcceptedAnswerId="19201" CreationDate="2019-03-15T13:25:25.557" Score="3" ViewCount="75" Body="&lt;p&gt;I have a file written in bash (with the she-bang) and called &quot;catalog&quot;, and the syntax highlighting is incorrect. If I rename the file, the colors become correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not configured anything in any file for syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I type &lt;code&gt;:set syntax=sh&lt;/code&gt; the colors got correct. However, I do not want to do this, but instead, I want to see, each time I open the file, the correct syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="21377" LastActivityDate="2019-03-15T13:55:38.347" Title="Invalid syntax for a bash file called catalog" Tags="|syntax-highlighting|bash|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19201" PostTypeId="2" ParentId="19200" CreationDate="2019-03-15T13:55:38.347" Score="3" Body="&lt;p&gt;Unfortunately Vim has a hard filetype detection on the name &lt;code&gt;catalog&lt;/code&gt;. It detects it as SGML catalog file. I'm not sure if that is a wise idea. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway here is a workaround. Add the following line as last line in your script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: ft=sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Save and then reload the file with &lt;code&gt;:e!&lt;/code&gt;. And the file should be detected as shell script. (If not, see below.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The line you inserted, is called &quot;modeline&quot;. Vim checks the first few and last few lines for such a modeline (5 by default). If it is found, the settings are applied. In this case it sets the filetype to &lt;code&gt;sh&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A modeline could contain multiple settings, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim: ft=sh et sw=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets the filetype to &lt;code&gt;sh&lt;/code&gt; it sets &lt;code&gt;expandtab&lt;/code&gt; and a shiftwidth of 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this doesn't work, check the modeline option with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set modeline?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it prints &lt;code&gt;nomodeline&lt;/code&gt; you have to adjust your &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details about modeline can be found with &lt;code&gt;:help 'modeline'&lt;/code&gt; and &lt;code&gt;:help modeline&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The number of checked lines at start/end of the file is configured with &lt;code&gt;modelines&lt;/code&gt; (plural). See &lt;code&gt;:help 'modelines'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-15T13:55:38.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19203" PostTypeId="1" CreationDate="2019-03-15T14:37:00.783" Score="1" ViewCount="74" Body="&lt;p&gt;When I work with ruby .erb files, vim correctly detect javascript blocks and highlights them accordingly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;... colored html ...&#xA;&amp;lt;script&amp;gt;&#xA;  ... colored javascript ...&#xA;&amp;lt;/script&amp;gt;&#xA;... more colored html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have defined blocks in my erb template that puts it's content in &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags, but vim doesn't know about it and i end up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;... colored html ...&#xA;&amp;lt;% content_for :tail_script do %&amp;gt;&#xA;  ... javascript is not detected and is colored as html ...&#xA;&amp;lt;% end %&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I add custom tag detection to enable javascript syntax highlighting? &lt;/p&gt;&#xA;" OwnerUserId="12428" LastActivityDate="2019-03-15T14:37:00.783" Title="Enable syntax highlight between custom tags" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="3" ClosedDate="2019-03-15T17:56:09.863" ContentLicense="CC BY-SA 4.0" />
  <row Id="19204" PostTypeId="1" AcceptedAnswerId="19207" CreationDate="2019-03-15T21:43:48.453" Score="1" ViewCount="317" Body="&lt;p&gt;I would like to parse the latex log to extract warnings from the refcheck package. These warnings look like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Package refcheck Warning: Unused label `eq:my_equation_label' on input line 2&#xA;28.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The linebreak always appears after a given number of characters, and here it happens to break the line number. I have been trying to set up a working &lt;code&gt;errorformat&lt;/code&gt; for a couple of hours but this was to no avail. Any idea how I could extract the correct error message and line number?&lt;/p&gt;&#xA;" OwnerUserId="11125" LastEditorUserId="11125" LastEditDate="2019-03-16T12:12:00.940" LastActivityDate="2019-03-19T17:39:34.093" Title="Multiline errorformat" Tags="|filetype-tex|errorformat|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19206" PostTypeId="2" ParentId="12031" CreationDate="2019-03-16T01:12:13.763" Score="5" Body="&lt;p&gt;&lt;code&gt;vim 8&lt;/code&gt; now also supports &lt;code&gt;terminal&lt;/code&gt; feature. It also supports to edit terminal buffer as text using &lt;code&gt;&amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;c-w&amp;gt; + N&lt;/code&gt;, which is called &lt;code&gt;Terminal-Normal&lt;/code&gt; mode in &lt;code&gt;vim 8&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim 8&lt;/code&gt; also supports &lt;code&gt;termdebug&lt;/code&gt;, a plugin that can launch &lt;code&gt;gdb&lt;/code&gt; with or without builtin &lt;code&gt;terminal&lt;/code&gt; support. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just type &lt;code&gt;packadd termdebug&lt;/code&gt; and &lt;code&gt;termdebug program_name&lt;/code&gt;, then the current buffer (if not modified) will become source of the program, another 2 split windows for &lt;code&gt;gdb&lt;/code&gt; and program (in another &lt;code&gt;tty&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This provides all functionalities &lt;code&gt;conque_gdb&lt;/code&gt; provides. For more info about this plugin, type &lt;code&gt;:h termdebug&lt;/code&gt; after &lt;code&gt;packadd termdebug&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21391" LastActivityDate="2019-03-16T01:12:13.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19207" PostTypeId="2" ParentId="19204" CreationDate="2019-03-16T09:56:38.390" Score="3" Body="&lt;p&gt;Afaik &lt;code&gt;'efm'&lt;/code&gt; of vim cannot handle this situation, i.e. &lt;code&gt;%l&lt;/code&gt; matches only a sequence of digits with no spaces or linebreaks between the digits. Vim help discusses in more detail a possible value of&lt;code&gt;'efm'&lt;/code&gt; for LaTeX but does not answer this question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#errorformat-LaTeX&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help errorformat-LaTeX&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe you can ask this on the &lt;a href=&quot;https://github.com/vim/vim/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue tracker of vim&lt;/a&gt; or the &lt;a href=&quot;https://groups.google.com/forum/#!forum/vim_dev&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim_dev mailing list&lt;/a&gt; to get an official confirmation of this and possibly add a note to the vim help section.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there are two ways to handle it anyway:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Change the line length of the log output&lt;/strong&gt; of &lt;code&gt;pdflatex&lt;/code&gt; to a high value. For example, set &lt;code&gt;makeprg&lt;/code&gt; in vim as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set makeprg=max_print_line=10000\ pdflatex\ %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also the plugin &lt;a href=&quot;https://github.com/lervag/vimtex/blob/b3700fedac319b8ada377317a6ba0904b7c526fc/autoload/vimtex/compiler/latexmk.vim#L152-L161&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt; does this for the default compilation method with &lt;code&gt;latexmk&lt;/code&gt; and would show you also the message by default.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Post-process the log file&lt;/strong&gt; with an external tool, e.g. &lt;code&gt;rubber-info&lt;/code&gt; correctly parses the splitted line number. &lt;a href=&quot;https://vi.stackexchange.com/a/5057/1292&quot;&gt;The principle idea is&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set mp=pdflatex\ %\ \\\|&amp;amp;\ error_filter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For LaTeX log files quite a few tools exist. Following two are pre-installed under TeXLive 2018&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://ctan.org/pkg/texloganalyser&quot; rel=&quot;nofollow noreferrer&quot;&gt;texloganalyser&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://ctan.org/pkg/texfot&quot; rel=&quot;nofollow noreferrer&quot;&gt;texfot&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, both struggle with the linebreak in the line number and report the wrong line number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried following further tools&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/stefanhepp/pplatex&quot; rel=&quot;nofollow noreferrer&quot;&gt;pplatex&lt;/a&gt; gets the line number correct but does not capture the full message. The warning&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Package refcheck Warning: Unused label `eq:your_equation_label' on input line 1&#xA;7.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is converted by &lt;code&gt;pplatex&lt;/code&gt; to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;** Warning in ./demo-multine-efm.tex:&#xA;   (Package refcheck) your_equation_label' on input line 17.&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/skapfer/rubber&quot; rel=&quot;nofollow noreferrer&quot;&gt;rubber-info&lt;/a&gt; was &lt;strong&gt;successful&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WARNING:rubber.cmdline:demo-multine-efm.tex:17: [refcheck] Unused label `eq:your_equation_label'. (page 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Other tools are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/dmwit/pulp&quot; rel=&quot;nofollow noreferrer&quot;&gt;pulp&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://ctan.org/pkg/texlog-extract&quot; rel=&quot;nofollow noreferrer&quot;&gt;texlog-extract&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Demo file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\documentclass{article}&#xA;\usepackage{refcheck}&#xA;&#xA;\begin{document}&#xA;&#xA;Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod&#xA;tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At&#xA;vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,&#xA;no sea takimata sanctus est Lorem ipsum dolor sit amet.&#xA;&#xA;\begin{equation}&#xA;   a=b\label{eq:your_equation_label}&#xA;\end{equation}&#xA;&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;latex&lt;/code&gt; returns a &lt;code&gt;refcheck&lt;/code&gt; warning with a line number containing a linebreak (&lt;code&gt;1\n2&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;❯ latex log-msg-line-no-with-linebreak.tex&#xA;This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=latex)&#xA; restricted \write18 enabled.&#xA;entering extended mode&#xA;(./log-msg-line-no-with-linebreak.tex&#xA;LaTeX2e &amp;lt;2018-12-01&amp;gt;&#xA;(/usr/local/texlive/2018/texmf-dist/tex/latex/base/article.cls&#xA;Document Class: article 2018/09/03 v1.4i Standard LaTeX document class&#xA;(/usr/local/texlive/2018/texmf-dist/tex/latex/base/size10.clo))&#xA;(/usr/local/texlive/2018/texmf-dist/tex/latex/refcheck/refcheck.sty)&#xA;No file log-msg-line-no-with-linebreak.aux.&#xA;Package: `refcheck' v1.9.1 &amp;lt;2013/02/14&amp;gt;&#xA;options: showrefs, showcites, msgs, chckunlbld&#xA;&#xA;Package refcheck Warning: Unused label `eq:your_equation_label' on input line 1&#xA;2.&#xA;&#xA;[1] (./log-msg-line-no-with-linebreak.aux)&#xA;&#xA;LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.&#xA;&#xA; )&#xA;Output written on log-msg-line-no-with-linebreak.dvi (1 page, 816 bytes).&#xA;Transcript written on log-msg-line-no-with-linebreak.log.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set efm=%+WPackage\ %s\ Warning:\ %m\ on\ input\ line\ %l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;reading the log file manually &lt;code&gt;:cfile log-msg-line-no-with-linebreak.log&lt;/code&gt; generates following warning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|1 warning| Package refcheck Warning: Unused label `eq:your_equation_label' on input line 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see the warning is issued for line number 1 which is incorrect.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For the purpose of reference I want to add links to &lt;code&gt;'efm'&lt;/code&gt; settings for latex or  external tools&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#errorformat-LaTeX&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help errorformat-LaTeX&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/compiler/tex.vim#L37-L64&quot; rel=&quot;nofollow noreferrer&quot;&gt;$VIMRUNTIME/compiler/tex.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim-latex/vim-latex/blob/master/compiler/tex.vim#L211&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-latex compiler/tex.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;vimtex provides settings for&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/autoload/vimtex/qf/latexlog.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;original latex output&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/autoload/vimtex/qf/pplatex.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;pplatex output&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/autoload/vimtex/qf/pulp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;pulp output&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-03-19T17:39:34.093" LastActivityDate="2019-03-19T17:39:34.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19209" PostTypeId="1" AcceptedAnswerId="19234" CreationDate="2019-03-16T15:21:26.590" Score="8" ViewCount="13712" Body="&lt;p&gt;Other editors and IDEs, such as &lt;a href=&quot;https://code.visualstudio.com/&quot; rel=&quot;noreferrer&quot;&gt;VSCode&lt;/a&gt; and &lt;a href=&quot;https://www.rstudio.com/&quot; rel=&quot;noreferrer&quot;&gt;RStudio&lt;/a&gt;, have an integrated console/terminal/REPL with the following characteristics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;They open in a split window. The file we’re working on is visible at the same time as the console.&lt;/li&gt;&#xA;&lt;li&gt;If we press a certain shortcut (typically ⌘↵), it sends and executes code to the console. Bonus if it auto-opens the console if it was closed.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If no code was selected, the current caret line is sent. Bonus if the caret moves down to the next line with code.&lt;/li&gt;&#xA;&lt;li&gt;If code was selected, only that portion is sent.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Bonus if it auto-detects the current language and opens the appropriate REPL.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I’ve been searching on and off for months, and never found that same functionality for Neovim. I found a few plugins that looked promising (e.g. &lt;code&gt;neoterm&lt;/code&gt;, &lt;code&gt;vim-slime&lt;/code&gt;) but I can’t get them to work, or the documentation is awful, or they don’t do exactly that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like Neovim should be capable of this. Is there no solution? I’m looking for something that in addition to the above functionality will have a fairly simple setup. A plugin would be ideal; having to create and maintain multiple files myself would be a recipe for breakage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The lack of this functionality is the &lt;em&gt;only&lt;/em&gt; reason why I don’t use Neovim full-time.&lt;/p&gt;&#xA;" OwnerUserId="21397" LastEditorUserId="21397" LastEditDate="2019-03-16T18:04:49.550" LastActivityDate="2022-07-19T18:56:35.667" Title="Neovim with split integrated terminal / REPL" Tags="|neovim|terminal|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19210" PostTypeId="2" ParentId="19209" CreationDate="2019-03-16T17:31:07.753" Score="6" Body="&lt;p&gt;&lt;em&gt;Disclaimer&lt;/em&gt;: this answer is more vim-centric than it is neovim-centric because I use the one and not the other. However, techniques shown are broadly applicable to both editors, as they share the same features.&lt;/p&gt;&#xA;&lt;h1&gt;TL;DR&lt;/h1&gt;&#xA;&lt;p&gt;Simply making use of built-in features and some scripting/maps, we can accomplish a lot.&lt;/p&gt;&#xA;&lt;p&gt;But I also turned my approach into a plugin called &lt;a href=&quot;https://github.com/benknoble/vim-simpl&quot; rel=&quot;nofollow noreferrer&quot;&gt;simpl&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Feature Number 1: Terminals in the Editor&lt;/h2&gt;&#xA;&lt;p&gt;(Neo)Vim provides a builtin terminal emulator via &lt;code&gt;:terminal&lt;/code&gt;. There are other techniques to access the shell (including job control, &lt;code&gt;!&lt;/code&gt;, and tmux), but this is the closest to a REPL in the editor.&lt;/p&gt;&#xA;&lt;p&gt;Learn to use it (both in Normal and Terminal modes!).&lt;/p&gt;&#xA;&lt;h2&gt;Feature Number 2: Terminal by Filetype&lt;/h2&gt;&#xA;&lt;p&gt;I recently realized I was using &lt;code&gt;:term python&lt;/code&gt; frequently when working on python code, and &lt;code&gt;:term scala&lt;/code&gt; for scala code, etc. Noticing a repeatable pattern, I generalized and abstracted.&lt;/p&gt;&#xA;&lt;p&gt;I &lt;a href=&quot;https://github.com/benknoble/Dotfiles/blob/ebc74e7d37b6a352198f3ced8a186a69207d9bb8/links/vim/autoload/terminal.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;created a function&lt;/a&gt; to control terminal behavior based on a buffer setting:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; ~/.vim/autoload/terminal.vim&#xA;&amp;quot; Functions for dealing with the terminal&#xA;&#xA;&amp;quot; Global function for calling terminal with the appropriate interpreter&#xA;&amp;quot; b:interpreter controls the program run&#xA;function! terminal#run(...) abort&#xA;  let l:interpreter = get(b:, 'interpreter', &amp;amp;shell)&#xA;  let l:command = 'term'&#xA;  if a:0&#xA;    for l:opt in a:000&#xA;      let l:command .= printf(' %s', opt)&#xA;    endfor&#xA;  endif&#xA;  let l:command .= printf(' %s', l:interpreter)&#xA;  execute l:command&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then, in my (many) &lt;code&gt;after/ftplugin&lt;/code&gt; files (available in the same repo), I set &lt;code&gt;b:interpreter&lt;/code&gt; as needed—the default is to launch a shell, but I get python, irb, scala, even jdb as necessary.&lt;/p&gt;&#xA;&lt;h2&gt;Feature Number 3: Mappings&lt;/h2&gt;&#xA;&lt;p&gt;Finally, I set up mappings to launch said terminal in my vimrc.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Terms and interpreters&#xA;&amp;quot; set b:interpreter for filetypes to affect the term&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;t :call terminal#run('++close')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;T :call terminal#run()&amp;lt;CR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Feature Number 4: Scriptability and Custom Operators&lt;/h3&gt;&#xA;&lt;p&gt;Vim’s scriptability is what makes it king, so we script some more. Custom operators mean we can operate over any motion of text to do whatever we want (in this case, send it to a terminal).&lt;/p&gt;&#xA;&lt;p&gt;The plugin &lt;a href=&quot;https://github.com/habamax/vim-sendtoterm&quot; rel=&quot;nofollow noreferrer&quot;&gt;habamax/vim-sendtoterm&lt;/a&gt; accomplishes the last piece of the puzzle in a single, short script. It even supports neovim, and the Readme has instructions to use control-enter and go to next line.&lt;/p&gt;&#xA;&lt;p&gt;Once you have this infrastructure in place, it should be fairly easy to map a key sequence of your choosing to&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start REPL if not running (may have to set a &lt;code&gt;b:repl_running&lt;/code&gt; to the window number or buffer number when opening the specified terminal)&lt;/li&gt;&#xA;&lt;li&gt;Get the text of the current line and send it to said REPL&lt;/li&gt;&#xA;&lt;li&gt;Move the cursor down one line.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Copy/paste work well enough that I’ve never needed the send-line functionality.&lt;/p&gt;&#xA;&lt;p&gt;I ended up creating &lt;a href=&quot;https://github.com/benknoble/vim-simpl&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-simpl&lt;/a&gt; to meet both the original &lt;code&gt;terminal#run&lt;/code&gt; needs and the &amp;quot;load this file in the REPL&amp;quot; needs. It still requires the old &lt;code&gt;b:interpreter&lt;/code&gt; setup, and you get to make your own mappings/commands. It also only supports a few languages out-of-box (mostly because I haven't implemented any others), but it's easy to register new ones.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2022-07-19T18:56:35.667" LastActivityDate="2022-07-19T18:56:35.667" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19211" PostTypeId="1" AcceptedAnswerId="19242" CreationDate="2019-03-16T19:41:11.793" Score="1" ViewCount="338" Body="&lt;p&gt;I have the following bash array after automatic indentation, both on pressing carriage return when was editing in &lt;code&gt;:h Insert mode&lt;/code&gt; and doing &lt;code&gt;=ip&lt;/code&gt; on the block in &lt;code&gt;:h Normal-mode&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DOTFILES=(&#xA;&quot;.bashrc&quot;&#xA;&quot;.bash_profile&quot;&#xA;&quot;.gitconfig&quot;&#xA;&quot;.profile&quot;&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Trying with &lt;code&gt;nvim -u NORC&lt;/code&gt; yielded the same result, so I'm guessing it's the default &lt;code&gt;/usr/share/nvim/runtime/indent/sh.vim&lt;/code&gt; indent file in action. Output of &lt;code&gt;:set ft?&lt;/code&gt; is &lt;code&gt;filetype=sh&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to have the aforementioned array with the following indentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DOTFILES=(&#xA;    &quot;.bashrc&quot;&#xA;    &quot;.bash_profile&quot;&#xA;    &quot;.gitconfig&quot;&#xA;    &quot;.profile&quot;&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I do that?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-17T05:08:14.420" LastActivityDate="2019-03-20T14:41:22.093" Title="Multi-line array variable in bash with filetype sh does not indent correctly" Tags="|indentation|filetype|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19213" PostTypeId="1" AcceptedAnswerId="19214" CreationDate="2019-03-16T20:33:16.517" Score="3" ViewCount="245" Body="&lt;p&gt;I'm going through the &lt;code&gt;vimtutor&lt;/code&gt;, and in Lesson 2.1 I read  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;NOTE: The letter  d  will appear on the last line of the screen&#xA;  as you type&#xA;          it.  Vim is waiting for you to type  w .&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On my MacOS-default &lt;code&gt;vim&lt;/code&gt;, I don't see it appearing on the last line of screen. What setting might control this?&lt;/p&gt;&#xA;" OwnerUserId="21320" LastActivityDate="2019-03-16T22:55:25.680" Title="Last line on screen not showing state" Tags="|default-settings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19214" PostTypeId="2" ParentId="19213" CreationDate="2019-03-16T22:55:25.680" Score="1" Body="&lt;p&gt;You must &lt;code&gt;set showcmd&lt;/code&gt; to see this&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-16T22:55:25.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19216" PostTypeId="1" AcceptedAnswerId="19217" CreationDate="2019-03-17T09:16:38.310" Score="2" ViewCount="1595" Body="&lt;p&gt;Must mapleader be a key with a char?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I use Ctrl/Shift/Alt or some other keys which won't type a char in insert mode?&lt;/p&gt;&#xA;" OwnerUserId="21218" LastActivityDate="2019-03-17T09:35:56.490" Title="Can mapleader be Ctrl or Shift?" Tags="|leader|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19217" PostTypeId="2" ParentId="19216" CreationDate="2019-03-17T09:35:56.490" Score="3" Body="&lt;p&gt;No.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The keys &lt;kbd&gt;Ctrl&lt;/kbd&gt;, &lt;kbd&gt;Shift&lt;/kbd&gt; and &lt;kbd&gt;Alt&lt;/kbd&gt; are &lt;a href=&quot;https://en.wikipedia.org/wiki/Modifier_key&quot; rel=&quot;nofollow noreferrer&quot;&gt;modifier keys&lt;/a&gt;. They modify another key, when pressed together with it. Vim can't detect them by itself. &lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-17T09:35:56.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19218" PostTypeId="1" CreationDate="2019-03-17T11:55:15.913" Score="1" ViewCount="761" Body="&lt;p&gt;I would like an object method call to be syntax highlighted in Vim. For instance, in an expression that contains &lt;code&gt;person.getName()&lt;/code&gt;, I would like to match &lt;code&gt;getName&lt;/code&gt; and give it some syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried quite a number of patterns and at the moment, this is what I have in my experimental syntax file;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; :set iskeyword+=.&#xA;syntax match myMatch &quot;\v\.\zs\w+\ze\(&quot; &#xA;highlight link myMatch Function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is not highlighting unless I comment in the first line above or issue &lt;code&gt;:set iskeyword+=.&lt;/code&gt; manually and then try editing the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make the highlighting successful without having to set &lt;code&gt;.&lt;/code&gt; as part of &lt;code&gt;iskeyword&lt;/code&gt;??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: I have Pathogen and I have the file with the contents above in &lt;code&gt;~/.vim/bundle/vim-javascript-syn/syntax/javascript.vim&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="21080" LastEditorUserId="21080" LastEditDate="2019-03-17T15:20:33.523" LastActivityDate="2019-03-17T15:40:40.830" Title="Vim Syntax Highlighting for an Object's Method Call" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19219" PostTypeId="2" ParentId="2132" CreationDate="2019-03-17T11:55:48.163" Score="2" Body="&lt;p&gt;I use below commands for folding in perl&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set foldmarker={,}&#xA;:set foldmethod=marker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I believe this should work for your case as well.&lt;/p&gt;&#xA;" OwnerUserId="21403" LastActivityDate="2019-03-17T11:55:48.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19220" PostTypeId="2" ParentId="19218" CreationDate="2019-03-17T14:06:21.793" Score="1" Body="&lt;p&gt;Have you tried to do it on an empty noname buffer with &lt;code&gt;vim -u NONE&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have copied (only changed function to title hl group) your lines and executed them, as you can see on a screenshot, it works without &lt;code&gt;.&lt;/code&gt; in &lt;code&gt;iskeyword&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LJ3aD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LJ3aD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To execute those commands type/copy them to &lt;code&gt;:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use my own plugin to eval vimscript :)&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-03-17T14:06:21.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19221" PostTypeId="2" ParentId="19218" CreationDate="2019-03-17T15:40:40.830" Score="1" Body="&lt;p&gt;I can't reproduce your problem. But here is what I would do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create the file &lt;code&gt;~/.vim/after/syntax/javascript.vim&lt;/code&gt; and add you configuration to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match myMatch &quot;\v\.\zs\w+\ze\(&quot;&#xA;highlight link myMatch Function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This syntax file it then an extension to the default javascript syntax file of Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim first loads the default syntax file &lt;code&gt;syntax/javascript.vim&lt;/code&gt; from the runtimepath. After that it looks for &lt;code&gt;after/syntax/javascript.vim&lt;/code&gt; (also via runtimepath). If found, this is loaded also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help mysyntaxfile-add&lt;/code&gt;, &lt;code&gt;:help after-directory&lt;/code&gt; and &lt;code&gt;:help runtimepath&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To display you current runtimepath execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: If you really want to do that via Pathogen, you also could create the file as &lt;code&gt;~/.vim/bundle/vim-javascript-syn/after/syntax/javascript.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-17T15:40:40.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19222" PostTypeId="1" AcceptedAnswerId="19224" CreationDate="2019-03-17T16:01:05.427" Score="4" ViewCount="575" Body="&lt;p&gt;It is possible to open a new file with  :edit or :tabnew but without jumping to that new buffer ?&lt;/p&gt;&#xA;" OwnerUserId="21405" LastActivityDate="2019-03-17T20:02:23.260" Title="Open new file while keeping the focus on the the current buffer" Tags="|buffers|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19223" PostTypeId="2" ParentId="19222" CreationDate="2019-03-17T16:58:29.740" Score="0" Body="&lt;p&gt;I'm not aware of a command to do this. Not to worry though - you can define your own commands to do it!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For edit, you might want to use something like this to open the file then immediately switch to the previous buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;command -nargs=1 Bgedit edit &amp;lt;args&amp;gt; | bprevious&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which you can call with &lt;code&gt;:Bgedit filename&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;command&lt;/code&gt; - Create a new user-defined command&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;-nargs=1&lt;/code&gt; - With one argument (the filename)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Bgedit&lt;/code&gt; - Name of the command (user-defined commands have to start with capital letters). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What comes next is what you will run when :Bgedit gets called: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;edit &amp;lt;args&amp;gt;&lt;/code&gt; - open the file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;|&lt;/code&gt; - Used in vim to chain two commands together, like a semicolon in bash&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;bprevious&lt;/code&gt; - switch to the previous buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For tabnew, you can do the same thing, but using &lt;code&gt;tabprevious&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;command -nargs=1 Tabbgedit tabnew &amp;lt;args&amp;gt; | tabprevious&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would put these two lines in your .vimrc.&lt;/p&gt;&#xA;" OwnerUserId="2757" LastActivityDate="2019-03-17T16:58:29.740" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19224" PostTypeId="2" ParentId="19222" CreationDate="2019-03-17T17:20:56.967" Score="2" Body="&lt;p&gt;Perhaps &lt;code&gt;:badd {fname}&lt;/code&gt; is what you are looking for. It just adds a new buffer to the buffer list without switching to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help badd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think there is something similar for tabs.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-17T20:02:23.260" LastActivityDate="2019-03-17T20:02:23.260" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19226" PostTypeId="1" AcceptedAnswerId="19227" CreationDate="2019-03-18T00:42:43.250" Score="0" ViewCount="230" Body="&lt;p&gt;What is the meaning of &lt;code&gt;&amp;lt;S-x&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt; in the documentation? Example: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#%3CS-Right%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/motion.html#%3CS-Right%3E&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often see people using &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt; to refer to Ctrl-x, but I don't believe that's what the documentation means.&lt;/p&gt;&#xA;" OwnerUserId="21314" LastActivityDate="2019-03-18T00:59:13.083" Title="Syntax of keys on keyboard in documentation" Tags="|key-bindings|keyword|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19227" PostTypeId="2" ParentId="19226" CreationDate="2019-03-18T00:46:29.270" Score="2" Body="&lt;p&gt;From &lt;code&gt;:help &amp;lt;s-&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;S-...&amp;gt;     shift-key           *shift* *&amp;lt;S-*&#xA;&amp;lt;C-...&amp;gt;     control-key         *control* *ctrl* *&amp;lt;C-*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus, &lt;code&gt;S-&lt;/code&gt; refers to the holding the shift key while pressing the following key.  This is usually not necessary since &lt;code&gt;&amp;lt;s-a&amp;gt;&lt;/code&gt; literally means &lt;code&gt;A&lt;/code&gt;, but it is with &lt;code&gt;&amp;lt;s-left&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;s-right&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-03-18T00:46:29.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19228" PostTypeId="2" ParentId="19226" CreationDate="2019-03-18T00:59:13.083" Score="2" Body="&lt;p&gt;&lt;code&gt;:help key-notation&lt;/code&gt; shows a complete list of all special keys.&lt;/p&gt;&#xA;" OwnerUserId="11477" LastActivityDate="2019-03-18T00:59:13.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19229" PostTypeId="2" ParentId="12520" CreationDate="2019-03-18T03:58:31.187" Score="10" Body="&lt;p&gt;Like @caneta, the &lt;code&gt;indentLine&lt;/code&gt; plugin was the culprit for me too. I solved it by disabling it for &lt;code&gt;markdown&lt;/code&gt; files like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:indentLine_fileTypeExclude = ['markdown']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="969" LastActivityDate="2019-03-18T03:58:31.187" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19230" PostTypeId="1" AcceptedAnswerId="19232" CreationDate="2019-03-18T05:52:44.153" Score="4" ViewCount="330" Body="&lt;p&gt;I am aware of lists and dictionaries in Vim. But are sets supported in Vim to store only unique values? Or do I just have to use a dictionary with some dummy value?&lt;/p&gt;&#xA;" OwnerUserId="21408" LastEditorUserId="23502" LastEditDate="2024-01-26T19:19:30.147" LastActivityDate="2024-01-26T20:01:39.837" Title="Is there a Set datatype in VimScript?" Tags="|vimscript|dictionary|list|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19231" PostTypeId="1" AcceptedAnswerId="19233" CreationDate="2019-03-18T06:18:00.443" Score="0" ViewCount="302" Body="&lt;p&gt;I don't understand what &lt;code&gt;:h infercase&lt;/code&gt; is supposed to do. I tried out some scenarios, but still can't figure out the differences between when it is turned off and on. Can someone explain it to me, please?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-03-18T12:07:13.980" Title="Explain `infercase` option" Tags="|ins-completion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19232" PostTypeId="2" ParentId="19230" CreationDate="2019-03-18T07:10:54.343" Score="4" Body="&lt;p&gt;No, there is no datatype Set. So you have to implement it yourself or maybe find some implementation on the net.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you implement it yourself, you might consider &quot;Dictionary functions&quot; (see &lt;code&gt;:help Dictionary-function&lt;/code&gt;) or &quot;numbered functions&quot; (see &lt;code&gt;:help numbered-function&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a quick hack. Maybe you can start from this. Note: This &quot;Set&quot; can only handle strings or numbers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NewSet()&#xA;    let newSet = {'dict': {} }&#xA;&#xA;    &quot; number of elements in set&#xA;    function! newSet.len()&#xA;        return len(self.dict)&#xA;    endfunction&#xA;&#xA;    &quot; adds element to set&#xA;    &quot; returns 1 if element was added, 0 if it was already present&#xA;    function! newSet.add(element)&#xA;        if ! has_key(self.dict, a:element)&#xA;            let self.dict[a:element] = 1&#xA;            return 1&#xA;        else&#xA;            return 0&#xA;        endif&#xA;    endfunction&#xA;&#xA;    &quot; returns 1 if element is contained in set&#xA;    function! newSet.contains(element)&#xA;        return has_key(self.dict, a:element)&#xA;    endfunction&#xA;&#xA;    &quot; removes element from set&#xA;    &quot; returns 1 if element was removed, 0 if it was not present&#xA;    function! newSet.remove(element)&#xA;        if(self.contains(a:element))&#xA;            call remove(self.dict, a:element)&#xA;            return 1&#xA;        else&#xA;            return 0&#xA;        endif&#xA;    endfunction&#xA;&#xA;    &quot; returns content as list&#xA;    function! newSet.as_list()&#xA;        return keys(self.dict)&#xA;    endfunction&#xA;&#xA;    return newSet&#xA;endfunction&#xA;&#xA;&quot; TEST&#xA;&#xA;let mySet = NewSet()&#xA;&#xA;echo &quot;Add Vim: &quot; . mySet.add(&quot;Vim&quot;)&#xA;echo &quot;Add Vim 2: &quot; . mySet.add(&quot;Vim&quot;)&#xA;&#xA;echo &quot;Add NeoVim: &quot; . mySet.add(&quot;NeoVim&quot;)&#xA;&#xA;echo &quot;Contains Vim: &quot; . mySet.contains(&quot;Vim&quot;)&#xA;echo &quot;Contains NeoVim: &quot; . mySet.contains(&quot;NeoVim&quot;)&#xA;echo &quot;Content: &quot; . string(mySet.as_list())&#xA;echo &quot;Len: &quot; . string(mySet.len())&#xA;echo &quot;Remove Vim: &quot; . mySet.remove(&quot;Vim&quot;)&#xA;echo &quot;Remove Vim 2: &quot; . mySet.remove(&quot;Vim&quot;)&#xA;echo &quot;Contains Vim: &quot; . mySet.contains(&quot;Vim&quot;)&#xA;echo &quot;Content: &quot; . string(mySet.as_list())&#xA;echo &quot;Len: &quot; . string(mySet.len())&#xA;echo &quot;Remove UNKNOWN: &quot; . mySet.remove(&quot;UNKNOWN&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I reconsidered my answer and came to the conclusion, that my previous example&#xA;implementation has a drawback. Whenever you create a new Set, the functions&#xA;are added as anonymous (aka numbered) functions. So if&#xA;you create two sets, all functions are parsed two times and defined two&#xA;times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The better solution is to define the functions once and just add the&#xA;function-references to the Set implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I would recommend this updated implementation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; number of elements in set&#xA;function! s:len() dict&#xA;    return len(self.dict)&#xA;endfunction&#xA;&#xA;&quot; adds element to set&#xA;&quot; returns 1 if element was added, 0 if it was already present&#xA;function! s:add(element) dict&#xA;    if ! has_key(self.dict, a:element)&#xA;        let self.dict[a:element] = 1&#xA;        return 1&#xA;    else&#xA;        return 0&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot; returns 1 if element is contained in set&#xA;function! s:contains(element) dict&#xA;    return has_key(self.dict, a:element)&#xA;endfunction&#xA;&#xA;&quot; removes element from set&#xA;&quot; returns 1 if element was removed, 0 if it was not present&#xA;function! s:remove(element) dict&#xA;    if(self.contains(a:element))&#xA;        call remove(self.dict, a:element)&#xA;        return 1&#xA;    else&#xA;        return 0&#xA;    endif&#xA;endfunction&#xA;&#xA;&quot; returns content as list&#xA;function! s:as_list() dict&#xA;    return keys(self.dict)&#xA;endfunction&#xA;&#xA;function! NewSet()&#xA;    let newSet = {'dict': {},&#xA;                \ 'len': function(&quot;s:len&quot;),&#xA;                \ 'add': function(&quot;s:add&quot;),&#xA;                \ 'contains': function(&quot;s:contains&quot;),&#xA;                \ 'remove': function(&quot;s:remove&quot;),&#xA;                \ 'as_list': function(&quot;s:as_list&quot;),&#xA;                \ }&#xA;    return newSet&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-23T06:01:11.013" LastActivityDate="2019-03-23T06:01:11.013" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19233" PostTypeId="2" ParentId="19231" CreationDate="2019-03-18T12:07:13.980" Score="1" Body="&lt;p&gt;Assuming you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ignorecase&#xA;set noinfercase&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you have a file that somewhere contains the word &quot;WORLD&quot; and you type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wor&amp;lt;C-P&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The part &lt;code&gt;wor&lt;/code&gt; will be completed to &lt;code&gt;WORLD&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you enable &lt;code&gt;infercase&lt;/code&gt; and try the same, &lt;code&gt;wor&lt;/code&gt; will be completed to &lt;code&gt;world&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So Vim does a case-insensitive completion, but infers the case from the characters you already typed. As mentioned in the docs, this only works with &lt;code&gt;ignorecase&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: &lt;code&gt;Wo&lt;/code&gt; is completed to &lt;code&gt;World&lt;/code&gt;, but &lt;code&gt;wO&lt;/code&gt; is completed to &lt;code&gt;wOrld&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-18T12:07:13.980" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19234" PostTypeId="2" ParentId="19209" CreationDate="2019-03-18T13:26:20.627" Score="2" Body="&lt;p&gt;After further searching and testing, it looks like &lt;a href=&quot;https://github.com/kassio/neoterm&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;kassio/neoterm&lt;/code&gt;&lt;/a&gt; can tick all the boxes, with the following configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:neoterm_default_mod='belowright' &quot; open terminal in bottom split&#xA;let g:neoterm_size=16 &quot; terminal split size&#xA;let g:neoterm_autoscroll=1 &quot; scroll to the bottom when running a command&#xA;nnoremap &amp;lt;leader&amp;gt;&amp;lt;cr&amp;gt; :TREPLSendLine&amp;lt;cr&amp;gt;j &quot; send current line and move down&#xA;vnoremap &amp;lt;leader&amp;gt;&amp;lt;cr&amp;gt; :TREPLSendSelection&amp;lt;cr&amp;gt; &quot; send current selection&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21397" LastActivityDate="2019-03-18T13:26:20.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19235" PostTypeId="1" CreationDate="2019-03-18T16:31:39.440" Score="3" ViewCount="2569" Body="&lt;p&gt;I know that with this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:yyp!!bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can execute current line and print the output in the next line (actually it copies the current line to the next line, executes it, and replaces it with the output), to get from this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;Hello&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to this (after the command above):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;Hello&quot;&#xA;Hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also know that I can use this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To execute the selected lines (&lt;em&gt;plural&lt;/em&gt;) and show the output in the window below the editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I want is to be able to select multiple lines, execute it in bash, and print the output in vim. How can I do that?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So desired behavior is to get from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo \&#xA;    -e &quot;Hello\nWorld&quot;&#xA;echo &quot;Hi&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo \&#xA;    -e &quot;Hello\nWorld&quot;&#xA;echo &quot;Hi&quot;&#xA;Hello&#xA;World&#xA;Hi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21415" LastEditorUserId="21415" LastEditDate="2019-03-20T08:44:15.230" LastActivityDate="2019-03-20T09:41:10.270" Title="How to execute selected lines in bash and print the output in the next line?" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="11" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19236" PostTypeId="1" AcceptedAnswerId="19241" CreationDate="2019-03-18T18:31:49.560" Score="0" ViewCount="445" Body="&lt;p&gt;see the following session in dash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ printf &quot;foo\nbar\n&quot; &amp;gt; testfile&#xA;$ cat testfile&#xA;foo&#xA;bar&#xA;$ vim -E testfile &amp;lt;&amp;lt;-EOS&#xA;&amp;gt; 1&#xA;&amp;gt; s/foo/baz/&#xA;&amp;gt; x&#xA;&amp;gt; EOS&#xA;$ echo $?&#xA;1&#xA;$ cat testfile&#xA;baz&#xA;bar&#xA;$ vim -E testfile +'1' +'s/baz/foo/' +'x'&#xA;$ echo $?&#xA;0&#xA;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use ex-mode of vi for exchaning the string &lt;code&gt;foo&lt;/code&gt; with the string &lt;code&gt;baz&lt;/code&gt; by using a here-document. Apparently that works. But nevertheless vim is still existing with an exit code of &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then exchange the &lt;code&gt;baz&lt;/code&gt; with &lt;code&gt;foo&lt;/code&gt; again by giving the commands directly on the commandline to vim. That works too and returns with exit code of &lt;code&gt;0&lt;/code&gt; (as expected).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the reason the here-document is always returning with an exit code of 1?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That even happens if I do not edit the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -E testfile &amp;lt;&amp;lt;-EOS&#xA;&amp;gt; 1&#xA;&amp;gt; p&#xA;&amp;gt; q&#xA;&amp;gt; EOS&#xA;foo&#xA;$ echo $?&#xA;1&#xA;$ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's going on there?&lt;/p&gt;&#xA;" OwnerUserId="21417" LastActivityDate="2019-03-19T06:56:30.850" Title="Why is `vim -E` always exiting with non-zero exit code when using here-doc?" Tags="|ex-mode|shell|posix|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19237" PostTypeId="2" ParentId="19236" CreationDate="2019-03-18T18:46:27.533" Score="0" Body="&lt;p&gt;Let's consider this test file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat file&#xA;baz is here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, let's run two variations on your command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -E file +'1' +'s/None/foo/' +'x'; echo code=$?&#xA;code=1&#xA;$ vim -E file +'1' +'s/baz/foo/' +'x'; echo code=$?&#xA;code=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Apparently, the exit code is &lt;code&gt;0&lt;/code&gt; if the substitute command succeeds in making a substitution and &lt;code&gt;1&lt;/code&gt; otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's try this again but looking at the difference between &lt;code&gt;q&lt;/code&gt; and &lt;code&gt;x&lt;/code&gt; as a means of exiting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat file&#xA;foo is here&#xA;$ vim -E file &amp;lt;&amp;lt;-EOS&#xA;1&#xA;s/foo/bar/&#xA;q&#xA;EOS&#xA;$ echo $?&#xA;1&#xA;$ vim -E file &amp;lt;&amp;lt;-EOS&#xA;1&#xA;s/foo/bar/&#xA;x&#xA;EOS&#xA;$ echo $?&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If a change was made to the file but vim was exited with &lt;code&gt;q&lt;/code&gt; leaving the changes unsaved, the exit code is &lt;code&gt;1&lt;/code&gt;.  If the changes were saved with &lt;code&gt;x&lt;/code&gt;, then the exit code is &lt;code&gt;0&lt;/code&gt; (success).  Using &lt;code&gt;q!&lt;/code&gt; to exit while purposefully discarding changes, however, produces success (exit code &lt;code&gt;0&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat file&#xA;foo is here&#xA;$ vim -E file &amp;lt;&amp;lt;-EOS&#xA;1&#xA;s/foo/bar/&#xA;q!&#xA;EOS&#xA;$ echo $?&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16880" LastEditorUserId="16880" LastEditDate="2019-03-18T20:48:21.873" LastActivityDate="2019-03-18T20:48:21.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19238" PostTypeId="1" AcceptedAnswerId="19239" CreationDate="2019-03-18T22:08:01.787" Score="0" ViewCount="993" Body="&lt;p&gt;So, I can create custom key mapping for specific directories like this: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufNewFile,BufRead &amp;lt;name of directory&amp;gt;*  map &amp;lt;key&amp;gt; :! &amp;lt;command here&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This only executes the command in that specific directory.  Say I have F5 as key, then outside of that directory, F5 does not do anything special.  To add F5 to another directory, I simply repeat the above code and change name of directory and commands.  This would get make my vimrc to be very messy if I have many directories that I need F5 to do stuff (just for example). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do something like this? &#xA;`&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (directory = &amp;lt;dirA&amp;gt;) then &#xA;   execute this command &#xA;else if (directory = &amp;lt;dirB&amp;gt;) then &#xA;   execute this command instead &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21038" LastActivityDate="2019-03-18T22:27:29.553" Title="If else statement vimrc for custom key mapping" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ClosedDate="2019-03-19T13:53:17.283" ContentLicense="CC BY-SA 4.0" />
  <row Id="19239" PostTypeId="2" ParentId="19238" CreationDate="2019-03-18T22:27:29.553" Score="3" Body="&lt;p&gt;Sure: use an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;F5&amp;gt; My_mapping()&#xA;&#xA;function! My_mapping&#xA;  if getcwd() ==# 'special'&#xA;    return 'special mapping'&#xA;  else&#xA;    return ''&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This differs slightly from the example given, in that it is re-evaluated each time the key is hit. I do this so that changes to the pwd during editing are propagated to the mapping. If you &lt;em&gt;only&lt;/em&gt; care about directory at startup, you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if getcwd() ==# 'special'&#xA;  nnoremap &amp;lt;F5&amp;gt; &amp;lt;blah&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-18T22:27:29.553" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19241" PostTypeId="2" ParentId="19236" CreationDate="2019-03-19T06:56:30.850" Score="3" Body="&lt;p&gt;This is a interesting question and I'm not sure I fully understand what is&#xA;going on. So here are &lt;em&gt;my&lt;/em&gt; findings based on &lt;em&gt;my&lt;/em&gt; Vim setup. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My setup contains some plugins (mainly self written) installed in &lt;code&gt;~/.vim/pack/.../start&lt;/code&gt;. These plugins all require Vim to run in &lt;code&gt;nocompatible&lt;/code&gt; mode (see &lt;code&gt;:help 'compatible'&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked at two different scenarios:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;run &lt;code&gt;vim -E testfile&lt;/code&gt; and enter the commands manually&lt;/li&gt;&#xA;&lt;li&gt;run &lt;code&gt;vim -E testfile &amp;lt;&amp;lt;-EOS...&lt;/code&gt; with a here document as in your question&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In the first case Vim exists with 0 in the second with 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By running scenario 2 with &lt;code&gt;-V9&lt;/code&gt; I found that one of my plugins has an autocmd&#xA;for the BufWritePre event and that the code of the called function is not parsed&#xA;correctly. This error happens, as Vim is running in &lt;code&gt;compatible&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the verbose output of Vim I can see, that my &lt;code&gt;~/.vim/vimrc&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt;&#xA;loaded, but all my plugins are loaded. This explains why vim is in&#xA;&lt;code&gt;compatible&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Investigating scenario 1 shows, that my &lt;code&gt;~/.vim/vimrc&lt;/code&gt; &lt;em&gt;is&lt;/em&gt; loaded and hence&#xA;Vim runs in &lt;code&gt;nocompatible&lt;/code&gt; mode. In that case everything works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why is my &lt;code&gt;vimrc&lt;/code&gt; only loaded in scenario 1?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;My interpretation&lt;/em&gt; is, that Vim detects that input is from a terminal. In that&#xA;case I could enter &lt;code&gt;visual&lt;/code&gt; at the ex-prompt to switch to &quot;normal&quot; Vim. So Vim&#xA;is preparing for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In scenario 2 Vim detects, that input is &lt;em&gt;not&lt;/em&gt; a terminal (it's the here-document)&#xA;and it is not possible to switch to visual. Even if you add &lt;code&gt;visual&lt;/code&gt; to your&#xA;here-document, Vim will not switch to visual (it can't as it has no access to terminal input). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why are all the plugins loaded?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be honest: I don't know. I think that it is fair to assume, that most&#xA;plugins need Vim to run in &lt;code&gt;nocompatible&lt;/code&gt; mode. So it doesn't make sense to&#xA;load them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Workaround&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;em&gt;my&lt;/em&gt; case everything works smooth if I force Vim to run in &lt;code&gt;nocompatible&lt;/code&gt;&#xA;mode by adding the option &lt;code&gt;-N&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -N -E testfile &amp;lt;&amp;lt;-EOS&#xA;&amp;gt; 1&#xA;&amp;gt; s/foo/baz/&#xA;&amp;gt; x&#xA;&amp;gt; EOS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-19T06:56:30.850" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19242" PostTypeId="2" ParentId="19211" CreationDate="2019-03-19T12:57:24.683" Score="1" Body="&lt;p&gt;&lt;sup&gt;From &lt;a href=&quot;https://github.com/chrisbra/vim-sh-indent&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/chrisbra/vim-sh-indent&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have vim with &lt;code&gt;:h packages&lt;/code&gt;, you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ mkdir -p ~/.vim/pack/dist/start # if using neovim: $ mkdir -p ~/.local/share/nvim/site/pack/dist/start&#xA;$ cd ~/.vim/pack/dist/start       # if using neovim: $ cd ~/.local/share/nvim/site/pack/dist/start&#xA;$ git clone https://github.com/chrisbra/vim-sh-indent&#xA;$ cd -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't have ':h packages` feature in your version of neo/vim, or you just don't want to use it, you can either use a plugin manager, or just put the following indent file in your user-specific indent directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the following in &lt;code&gt;~/.config/nvim/indent/sh.vim&lt;/code&gt; or &lt;code&gt;~/.vim/indent/sh.vim&lt;/code&gt; if you're using &lt;code&gt;nvim&lt;/code&gt; or &lt;code&gt;vim&lt;/code&gt; respectively:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Vim indent file&#xA;&quot; Language:            Shell Script&#xA;&quot; Maintainer:          Christian Brabandt &amp;lt;cb@256bit.org&amp;gt;&#xA;&quot; Original Author:     Nikolai Weibull &amp;lt;now@bitwi.se&amp;gt;&#xA;&quot; Previous Maintainer: Peter Aronoff &amp;lt;telemachus@arpinum.org&amp;gt;&#xA;&quot; Latest Revision:     2019-03-19&#xA;&quot; License:             Vim (see :h license)&#xA;&quot; Repository:          https://github.com/chrisbra/vim-sh-indent&#xA;&quot; Changelog:&#xA;&quot;          20190319  - Indent arrays (only zsh and bash)&#xA;&quot;                      https://github.com/chrisbra/vim-sh-indent/issues/13&#xA;&quot;          20190316  - Make use of searchpairpos for nested if sections&#xA;&quot;                      fixes https://github.com/chrisbra/vim-sh-indent/issues/11&#xA;&quot;          20190201  - Better check for closing if sections&#xA;&quot;          20180724  - make check for zsh syntax more rigid (needs word-boundaries)&#xA;&quot;          20180326  - better support for line continuation&#xA;&quot;          20180325  - better detection of function definitions&#xA;&quot;          20180127  - better support for zsh complex commands&#xA;&quot;          20170808: - better indent of line continuation&#xA;&quot;          20170502: - get rid of buffer-shiftwidth function&#xA;&quot;          20160912: - preserve indentation of here-doc blocks&#xA;&quot;          20160627: - detect heredocs correctly&#xA;&quot;          20160213: - detect function definition correctly&#xA;&quot;          20160202: - use shiftwidth() function&#xA;&quot;          20151215: - set b:undo_indent variable&#xA;&quot;          20150728: - add foreach detection for zsh&#xA;&#xA;if exists(&quot;b:did_indent&quot;)&#xA;  finish&#xA;endif&#xA;let b:did_indent = 1&#xA;&#xA;setlocal indentexpr=GetShIndent()&#xA;setlocal indentkeys+=0=then,0=do,0=else,0=elif,0=fi,0=esac,0=done,0=end,),0=;;,0=;&amp;amp;&#xA;setlocal indentkeys+=0=fin,0=fil,0=fip,0=fir,0=fix&#xA;setlocal indentkeys-=:,0#&#xA;setlocal nosmartindent&#xA;&#xA;let b:undo_indent = 'setlocal indentexpr&amp;lt; indentkeys&amp;lt; smartindent&amp;lt;'&#xA;&#xA;if exists(&quot;*GetShIndent&quot;)&#xA;  finish&#xA;endif&#xA;&#xA;let s:cpo_save = &amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;&#xA;let s:sh_indent_defaults = {&#xA;      \ 'default': function('shiftwidth'),&#xA;      \ 'continuation-line': function('shiftwidth'),&#xA;      \ 'case-labels': function('shiftwidth'),&#xA;      \ 'case-statements': function('shiftwidth'),&#xA;      \ 'case-breaks': 0 }&#xA;&#xA;function! s:indent_value(option)&#xA;  let Value = exists('b:sh_indent_options')&#xA;            \ &amp;amp;&amp;amp; has_key(b:sh_indent_options, a:option) ?&#xA;            \ b:sh_indent_options[a:option] :&#xA;            \ s:sh_indent_defaults[a:option]&#xA;  if type(Value) == type(function('type'))&#xA;    return Value()&#xA;  endif&#xA;  return Value&#xA;endfunction&#xA;&#xA;function! GetShIndent()&#xA;  let curline = getline(v:lnum)&#xA;  let lnum = prevnonblank(v:lnum - 1)&#xA;  if lnum == 0&#xA;    return 0&#xA;  endif&#xA;  let line = getline(lnum)&#xA;&#xA;  let pnum = prevnonblank(lnum - 1)&#xA;  let pline = getline(pnum)&#xA;  let ind = indent(lnum)&#xA;&#xA;  &quot; Check contents of previous lines&#xA;  if line =~ '^\s*\%(if\|then\|do\|else\|elif\|case\|while\|until\|for\|select\|foreach\)\&amp;gt;' ||&#xA;        \  (&amp;amp;ft is# 'zsh' &amp;amp;&amp;amp; line =~ '\&amp;lt;\%(if\|then\|do\|else\|elif\|case\|while\|until\|for\|select\|foreach\)\&amp;gt;')&#xA;    if !s:is_end_expression(line)&#xA;      let ind += s:indent_value('default')&#xA;    endif&#xA;  elseif s:is_case_label(line, pnum)&#xA;    if !s:is_case_ended(line)&#xA;      let ind += s:indent_value('case-statements')&#xA;    endif&#xA;  &quot; function definition&#xA;  elseif s:is_function_definition(line)&#xA;    if line !~ '}\s*\%(#.*\)\=$'&#xA;      let ind += s:indent_value('default')&#xA;    endif&#xA;  &quot; array (only works for zsh or bash)&#xA;  elseif s:is_array(line) &amp;amp;&amp;amp; line !~ ')\s*$' &amp;amp;&amp;amp; (&amp;amp;ft is# 'zsh' || s:is_bash())&#xA;      let ind += s:indent_value('continuation-line')&#xA;  &quot; end of array&#xA;  elseif curline =~ '^\s*)$'&#xA;      let ind -= s:indent_value('continuation-line')&#xA;  elseif s:is_continuation_line(line)&#xA;    if pnum == 0 || !s:is_continuation_line(pline)&#xA;      let ind += s:indent_value('continuation-line')&#xA;    endif&#xA;  elseif s:end_block(line) &amp;amp;&amp;amp; !s:start_block(line)&#xA;    let ind -= s:indent_value('default')&#xA;  elseif pnum != 0 &amp;amp;&amp;amp;&#xA;        \ s:is_continuation_line(pline) &amp;amp;&amp;amp;&#xA;        \ !s:end_block(curline) &amp;amp;&amp;amp;&#xA;        \ !s:is_end_expression(curline)&#xA;    &quot; only add indent, if line and pline is in the same block&#xA;    let i = v:lnum&#xA;    let ind2 = indent(s:find_continued_lnum(pnum))&#xA;    while !s:is_empty(getline(i)) &amp;amp;&amp;amp; i &amp;gt; pnum&#xA;      let i -= 1&#xA;    endw&#xA;    if i == pnum&#xA;      let ind += ind2&#xA;    else&#xA;      let ind = ind2&#xA;    endif&#xA;  endif&#xA;&#xA;  let pine = line&#xA;  &quot; Check content of current line&#xA;  let line = curline&#xA;  &quot; Current line is a endif line, so get indent from start of &quot;if condition&quot; line&#xA;  &quot; TODO: should we do the same for other &quot;end&quot; lines?&#xA;  if curline =~ '^\s*\%(fi\)\s*\%(#.*\)\=$'&#xA;    let previous_line = searchpair('\&amp;lt;if\&amp;gt;', '', '\&amp;lt;fi\&amp;gt;', 'bnW')&#xA;    if previous_line &amp;gt; 0&#xA;      let ind = indent(previous_line)&#xA;    endif&#xA;  elseif line =~ '^\s*\%(then\|do\|else\|elif\|done\|end\)\&amp;gt;' || s:end_block(line)&#xA;    let ind -= s:indent_value('default')&#xA;  elseif line =~ '^\s*esac\&amp;gt;' &amp;amp;&amp;amp; s:is_case_empty(getline(v:lnum - 1))&#xA;    let ind -= s:indent_value('default')&#xA;  elseif line =~ '^\s*esac\&amp;gt;'&#xA;    let ind -= (s:is_case_label(pine, lnum) &amp;amp;&amp;amp; s:is_case_ended(pine) ?&#xA;             \ 0 : s:indent_value('case-statements')) +&#xA;             \ s:indent_value('case-labels')&#xA;    if s:is_case_break(pine)&#xA;      let ind += s:indent_value('case-breaks')&#xA;    endif&#xA;  elseif s:is_case_label(line, lnum)&#xA;    if s:is_case(pine)&#xA;      let ind = indent(lnum) + s:indent_value('case-labels')&#xA;    else&#xA;      let ind -= (s:is_case_label(pine, lnum) &amp;amp;&amp;amp; s:is_case_ended(pine) ?&#xA;                  \ 0 : s:indent_value('case-statements')) -&#xA;                  \ s:indent_value('case-breaks')&#xA;    endif&#xA;  elseif s:is_case_break(line)&#xA;    let ind -= s:indent_value('case-breaks')&#xA;  elseif s:is_here_doc(line)&#xA;    let ind = 0&#xA;  &quot; statements, executed within a here document. Keep the current indent&#xA;  elseif match(map(synstack(v:lnum, 1), 'synIDattr(v:val, &quot;name&quot;)'), '\c\mheredoc') &amp;gt; -1&#xA;    return indent(v:lnum)&#xA;  elseif s:is_comment(line) &amp;amp;&amp;amp; s:is_empty(getline(v:lnum-1))&#xA;    return indent(v:lnum)&#xA;  endif&#xA;&#xA;  return ind &amp;gt; 0 ? ind : 0&#xA;endfunction&#xA;&#xA;function! s:is_continuation_line(line)&#xA;  &quot; Comment, cannot be a line continuation&#xA;  if a:line =~ '^\s*#'&#xA;    return 0&#xA;  else&#xA;    &quot; start-of-line&#xA;    &quot; \\ or &amp;amp;&amp;amp; or || or |&#xA;    &quot; followed optionally by { or #&#xA;    return a:line =~ '\%(\%(^\|[^\\]\)\\\|&amp;amp;&amp;amp;\|||\||\)' .&#xA;                 \ '\s*\({\s*\)\=\(#.*\)\=$'&#xA;  endif&#xA;endfunction&#xA;&#xA;function! s:find_continued_lnum(lnum)&#xA;  let i = a:lnum&#xA;  while i &amp;gt; 1 &amp;amp;&amp;amp; s:is_continuation_line(getline(i - 1))&#xA;    let i -= 1&#xA;  endwhile&#xA;  return i&#xA;endfunction&#xA;&#xA;function! s:is_function_definition(line)&#xA;  return a:line =~ '^\s*\&amp;lt;\k\+\&amp;gt;\s*()\s*{' ||&#xA;       \ a:line =~ '^\s*{' ||&#xA;       \ a:line =~ '^\s*function\s*\w\S\+\s*\%(()\)\?\s*{'&#xA;endfunction&#xA;&#xA;function! s:is_array(line)&#xA;  return a:line =~ '^\s*\&amp;lt;\k\+\&amp;gt;=('&#xA;endfunction&#xA;&#xA;function! s:is_case_label(line, pnum)&#xA;  if a:line !~ '^\s*(\=.*)'&#xA;    return 0&#xA;  endif&#xA;&#xA;  if a:pnum &amp;gt; 0&#xA;    let pine = getline(a:pnum)&#xA;    if !(s:is_case(pine) || s:is_case_ended(pine))&#xA;      return 0&#xA;    endif&#xA;  endif&#xA;&#xA;  let suffix = substitute(a:line, '^\s*(\=', &quot;&quot;, &quot;&quot;)&#xA;  let nesting = 0&#xA;  let i = 0&#xA;  let n = strlen(suffix)&#xA;  while i &amp;lt; n&#xA;    let c = suffix[i]&#xA;    let i += 1&#xA;    if c == '\\'&#xA;      let i += 1&#xA;    elseif c == '('&#xA;      let nesting += 1&#xA;    elseif c == ')'&#xA;      if nesting == 0&#xA;        return 1&#xA;      endif&#xA;      let nesting -= 1&#xA;    endif&#xA;  endwhile&#xA;  return 0&#xA;endfunction&#xA;&#xA;function! s:is_case(line)&#xA;  return a:line =~ '^\s*case\&amp;gt;'&#xA;endfunction&#xA;&#xA;function! s:is_case_break(line)&#xA;  return a:line =~ '^\s*;[;&amp;amp;]'&#xA;endfunction&#xA;&#xA;function! s:is_here_doc(line)&#xA;    if a:line =~ '^\w\+$'&#xA;      let here_pat = '&amp;lt;&amp;lt;-\?'. s:escape(a:line). '\$'&#xA;      return search(here_pat, 'bnW') &amp;gt; 0&#xA;    endif&#xA;    return 0&#xA;endfunction&#xA;&#xA;function! s:is_case_ended(line)&#xA;  return s:is_case_break(a:line) || a:line =~ ';[;&amp;amp;]\s*\%(#.*\)\=$'&#xA;endfunction&#xA;&#xA;function! s:is_case_empty(line)&#xA;  if a:line =~ '^\s*$' || a:line =~ '^\s*#'&#xA;    return s:is_case_empty(getline(v:lnum - 1))&#xA;  else&#xA;    return a:line =~ '^\s*case\&amp;gt;'&#xA;  endif&#xA;endfunction&#xA;&#xA;function! s:escape(pattern)&#xA;    return '\V'. escape(a:pattern, '\\')&#xA;endfunction&#xA;&#xA;function! s:is_empty(line)&#xA;  return a:line =~ '^\s*$'&#xA;endfunction&#xA;&#xA;function! s:end_block(line)&#xA;  return a:line =~ '^\s*}'&#xA;endfunction&#xA;&#xA;function! s:start_block(line)&#xA;  return a:line =~ '{\s*\(#.*\)\?$'&#xA;endfunction&#xA;&#xA;function! s:find_start_block(lnum)&#xA;  let i = a:lnum&#xA;  while i &amp;gt; 1 &amp;amp;&amp;amp; !s:start_block(getline(i))&#xA;    let i -= 1&#xA;  endwhile&#xA;  return i&#xA;endfunction&#xA;&#xA;function! s:is_comment(line)&#xA;  return a:line =~ '^\s*#'&#xA;endfunction&#xA;&#xA;function! s:is_end_expression(line)&#xA;  return a:line =~ '\&amp;lt;\%(fi\|esac\|done\|end\)\&amp;gt;\s*\%(#.*\)\=$'&#xA;endfunction&#xA;&#xA;function! s:is_bash()&#xA;  return get(g:, 'is_bash', 0) || get(b:, 'is_bash', 0)&#xA;endfunction&#xA;&#xA;let &amp;amp;cpo = s:cpo_save&#xA;unlet s:cpo_save&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-20T14:41:22.093" LastActivityDate="2019-03-20T14:41:22.093" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19243" PostTypeId="1" CreationDate="2019-03-19T16:46:18.250" Score="2" ViewCount="2128" Body="&lt;p&gt;(EDIT: In the original question, I had accidentally used &lt;code&gt;\w&lt;/code&gt; instead of &lt;code&gt;\&amp;lt;&lt;/code&gt;.  Comments and answers with &lt;code&gt;\w&lt;/code&gt; should be interpreted as using &lt;code&gt;\&amp;lt;&lt;/code&gt; as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my LaTeX source files, section headings have an initial uppercase on each first word, but all lowercase on subsequent words.  I want to convert all words in each section heading to initial uppercase.  Section headings have the form &quot;*section{Here is my section name}&quot;.  That is, I want to replace this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Some text.&#xA;\section{New information}&#xA;Some other text.&#xA;\subsection{More cool stuff}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Some text.&#xA;\section{New Information}&#xA;Some other text.&#xA;\subsection{More Cool Stuff}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am currently using this to perform the task:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/section{/s/\&amp;lt;\(.\)/\u&amp;amp;/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &lt;strong&gt;g&lt;/strong&gt;lobally searches for lines containing &quot;section{&quot; and then &lt;strong&gt;s&lt;/strong&gt;earches within the line for characters that begin &lt;strong&gt;w&lt;/strong&gt;ords, replacing the found character with its &lt;strong&gt;u&lt;/strong&gt;ppercase variant, with &lt;strong&gt;c&lt;/strong&gt; allowing me to reject the change if I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this means that I always first find the &quot;s&quot; at the beginning of the sectioning command--&lt;code&gt;\section&lt;/code&gt;, or &lt;code&gt;\subsection&lt;/code&gt;, etc., and I have to hit &quot;n&quot; to reject the substitution and move on to the next match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In some contexts it's possible to search and move to the end of the match, using &lt;code&gt;e&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/section{/e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;places the cursor on the &quot;{&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I don't see a way to mix the &lt;code&gt;e&lt;/code&gt; suffix functionality with the combination of a global line search and a within-line search and replace.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/section{/es/\&amp;lt;\(.\)/\u&amp;amp;/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;generates the error &quot;Not an editor command&quot; on &quot;es&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/section{/e s/\&amp;lt;\(.\)/\u&amp;amp;/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;results in a new buffer with the message '&quot;s/\w(.)/\u&amp;amp;/gc&quot; [NEW DIRECTORY]'.  I don't know what Vim thinks I'm trying to do, but it's not what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to find a line and then search/replace only within part of the line?&lt;/p&gt;&#xA;" OwnerUserId="4643" LastEditorUserId="4643" LastEditDate="2019-03-20T02:56:35.777" LastActivityDate="2019-03-27T20:51:54.487" Title="Search for line, move to end of search string, then search+replace" Tags="|regular-expression|search|replace|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19244" PostTypeId="2" ParentId="19243" CreationDate="2019-03-19T21:49:41.347" Score="2" Body="&lt;p&gt;Limit the match using &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; as Klaus suggested and adjusting per Mars:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/section{/s/[^{\\]\zs\&amp;lt;\(.\)/\u&amp;amp;/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;g/section/&lt;/code&gt; is needed because we want to do this only on the &lt;code&gt;section{&lt;/code&gt; lines, but &lt;code&gt;section{&lt;/code&gt; should not be involved in the replacement match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;[^{\\]\zs&lt;/code&gt; means that we don't try to replace after the initial &lt;code&gt;\&lt;/code&gt; on the line, nor after the &lt;code&gt;{&lt;/code&gt; (since we already have an uppercase character after the brace), but then start searching for word-beginnings after that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\zs&lt;/code&gt; is needed because otherwise the &lt;code&gt;[^{\\]&lt;/code&gt; causes the interword space to be what's matched and then &quot;uppercased&quot;, which would cause no change.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-03-20T03:19:04.500" LastActivityDate="2019-03-20T03:19:04.500" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19245" PostTypeId="2" ParentId="19243" CreationDate="2019-03-20T03:00:45.550" Score="3" Body="&lt;p&gt;If I understand the question correctly, you want to convert lines of the form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\section{Here is my section name}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\section{Here Is My Section Name}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One way to do this is using a look-behind:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\%(\\section{[^}]*\)\@&amp;lt;=\&amp;lt;\w/\u&amp;amp;/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Breaking this down,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(                             start grouping&#xA;      \\section{[^}]*           match \section{ followed by anything except }&#xA;\)\@&amp;lt;=                          ensure matching at this position (not part of the match) &#xA;\&amp;lt;\w                            match start of words (first character)&#xA;&#xA;\u&amp;amp;                             upper case the match&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The way this works is vim stores the group preceding the &lt;code&gt;\@&amp;lt;=&lt;/code&gt;, then for each match of &lt;code&gt;\&amp;lt;\w&lt;/code&gt;, looks back character by character to see if it can match what is in the look behind.  This means it is often slow, as the help mentions.  It is also distinct from using &lt;code&gt;\zs&lt;/code&gt;, which would first match &lt;code&gt;\section{Here Is My Section&lt;/code&gt;, restart the match, then match &lt;code&gt;\&amp;lt;\w&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2019-03-20T19:35:00.467" LastActivityDate="2019-03-20T19:35:00.467" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19246" PostTypeId="2" ParentId="19235" CreationDate="2019-03-20T06:37:09.133" Score="2" Body="&lt;p&gt;When you have the lines selected you could just use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yPgv:!bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to have that as a mapping you can do like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:xnoremap x yPgv:!bash&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To be clear, do NOT use &lt;code&gt;x&lt;/code&gt; here but insert your desired mapping. &lt;code&gt;x&lt;/code&gt; would be a horrible idea, the cut function is pretty useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Breakdown:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;y&lt;/code&gt; will copy the selected text&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;P&lt;/code&gt; paste before&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gv&lt;/code&gt; reselect last visual selection&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:!bash&lt;/code&gt; send it to bash&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you see, you had all the hard parts already there, which made it easy for me. Just a little lesson in vim trickery needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;!&lt;/code&gt; commands means filter all selected lines through an external program. In this case &lt;code&gt;bash&lt;/code&gt;. see &lt;code&gt;:h !&lt;/code&gt; for information about that.&#xA;So &lt;code&gt;:! bash&lt;/code&gt; means send the lines to bash, and replace them with the output from bash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You used &lt;code&gt;:w !bash&lt;/code&gt; which is a &lt;code&gt;write&lt;/code&gt; command (see &lt;code&gt;:h :w&lt;/code&gt;). It does execute bash with the selected lines as the standard input. So vim just writes and does not directly read it back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is simple way I know of to get the results line by line. You could however call this command for every line. This would require some vimscript (see &lt;a href=&quot;https://vi.stackexchange.com/questions/16610/operate-on-a-visual-selection-by-looping-through-the-lines&quot;&gt;here&lt;/a&gt; for a starting point).&lt;/p&gt;&#xA;" OwnerUserId="11316" LastEditorUserId="11316" LastEditDate="2019-03-20T09:15:13.870" LastActivityDate="2019-03-20T09:15:13.870" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19247" PostTypeId="1" AcceptedAnswerId="19248" CreationDate="2019-03-20T08:37:55.643" Score="6" ViewCount="5211" Body="&lt;p&gt;I'm writting scripts for vim, and I want to let the script do different things in different mode. I know that the statusline will show the current mode, but I don't know how to get the exact current mode and store it in variables. For example, when I enter the &lt;code&gt;visual-line&lt;/code&gt; mode, can I get the current mode from some system variables of vim and distinct the mode from other &lt;code&gt;visual&lt;/code&gt; mode?&lt;/p&gt;&#xA;" OwnerUserId="21438" LastActivityDate="2021-03-30T13:12:01.423" Title="How to get the current mode in vim?" Tags="|vimscript|statusline|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19248" PostTypeId="2" ParentId="19247" CreationDate="2019-03-20T08:55:58.327" Score="6" Body="&lt;p&gt;You are looking for the function &lt;code&gt;mode()&lt;/code&gt;, see &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#mode%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h mode()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mode([expr])    Return a string that indicates the current mode.&#xA;        If [expr] is supplied and it evaluates to a non-zero Number or&#xA;        a non-empty String (|non-zero-arg|), then the full mode is&#xA;        returned, otherwise only the first letter is returned.&#xA;&#xA;            n   Normal&#xA;            no  Operator-pending&#xA;            v   Visual by character&#xA;            V   Visual by line&#xA;            CTRL-V  Visual blockwise&#xA;            s   Select by character&#xA;            S   Select by line&#xA;            CTRL-S  Select blockwise&#xA;            i   Insert&#xA;            ic  Insert mode completion |compl-generic|&#xA;            ix  Insert mode |i_CTRL-X| completion&#xA;            R   Replace |R|&#xA;            Rc  Replace mode completion |compl-generic|&#xA;            Rv  Virtual Replace |gR|&#xA;            Rx  Replace mode |i_CTRL-X| completion&#xA;            c   Command-line editing&#xA;            cv  Vim Ex mode |gQ|&#xA;            ce  Normal Ex mode |Q|&#xA;            r   Hit-enter prompt&#xA;            rm  The -- more -- prompt&#xA;            r?  A |:confirm| query of some sort&#xA;            !   Shell or external command is executing&#xA;            t   Terminal mode: keys go to the job&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So all you need to do is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let currentMode = mode()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-03-20T08:55:58.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19249" PostTypeId="1" CreationDate="2019-03-20T08:58:31.763" Score="1" ViewCount="367" Body="&lt;p&gt;The vim version on my Mac is 8.1.1000, installed by homebrew:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar 11 2019 08:36:53)&#xA;macOS version&#xA;Included patches: 1-1000&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               +extra_search      +mouse_netterm     +tag_old_static&#xA;+arabic            -farsi             +mouse_sgr         -tag_any_white&#xA;+autocmd           +file_in_path      -mouse_sysmouse    -tcl&#xA;+autochdir         +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       +terminal&#xA;-balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;-browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    +gettext           +netbeans_intg     +textprop&#xA;+byte_offset       -hangul_input      +num64             +timers&#xA;+channel           +iconv             +packages          +title&#xA;+cindent           +insert_expand     +path_extra        -toolbar&#xA;-clientserver      +job               +perl              +user_commands&#xA;+clipboard         +jumplist          +persistent_undo   +vartabs&#xA;+cmdline_compl     +keymap            +postscript        +vertsplit&#xA;+cmdline_hist      +lambda            +printer           +virtualedit&#xA;+cmdline_info      +langmap           +profile           +visual&#xA;+comments          +libcall           -python            +visualextra&#xA;+conceal           +linebreak         +python3           +viminfo&#xA;+cryptv            +lispindent        +quickfix          +vreplace&#xA;+cscope            +listcmds          +reltime           +wildignore&#xA;+cursorbind        +localmap          +rightleft         +wildmenu&#xA;+cursorshape       +lua               +ruby              +windows&#xA;+dialog_con        +menu              +scrollbind        +writebackup&#xA;+diff              +mksession         +signs             -X11&#xA;+digraphs          +modify_fname      +smartindent       -xfontset&#xA;-dnd               +mouse             +startuptime       -xim&#xA;-ebcdic            -mouseshape        +statusline        -xpm&#xA;+emacs_tags        +mouse_dec         -sun_workshop      -xsmp&#xA;+eval              -mouse_gpm         +syntax            -xterm_clipboard&#xA;+ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -lintl -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.13 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.28.1/lib/perl5/5.28.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation  -lruby.2.6     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's strange that I cannot map &lt;code&gt;&amp;lt;C-S&amp;gt;&lt;/code&gt; to any thing, for example, &lt;code&gt;nnoremap &amp;lt;C-S&amp;gt; dd&lt;/code&gt;, or &lt;code&gt;map &amp;lt;C-S&amp;gt; echom&amp;lt;Space&amp;gt;'hi'&amp;lt;CR&amp;gt;&lt;/code&gt;, nothing happens, the information from &lt;code&gt;:map&lt;/code&gt; is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n  &amp;lt;C-S&amp;gt;       * dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I change &lt;code&gt;&amp;lt;C-S&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;C-P&amp;gt;&lt;/code&gt;, it's working well, (however the result of &lt;code&gt;:map&lt;/code&gt; is still &lt;code&gt;n  &amp;lt;C-P&amp;gt;       * dd&lt;/code&gt;, still un-remappable? but it's working)&lt;/p&gt;&#xA;" OwnerUserId="21218" LastEditorUserId="21218" LastEditDate="2019-03-20T09:14:03.017" LastActivityDate="2019-03-20T09:14:03.017" Title="Why is &lt;C-S&gt; not remappable?" Tags="|key-bindings|" AnswerCount="0" CommentCount="11" ClosedDate="2019-03-20T15:26:17.983" ContentLicense="CC BY-SA 4.0" />
  <row Id="19250" PostTypeId="1" CreationDate="2019-03-20T09:22:13.640" Score="1" ViewCount="4963" Body="&lt;p&gt;So, to begin, this is similar to &lt;a href=&quot;https://vi.stackexchange.com/questions/2824/pipe-shell-command-into-buffer-in-real-time&quot;&gt;Pipe shell command into buffer in real-time&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference is that the top answer there pipes the output to a new buffer. How do I pipe the output &lt;strong&gt;to the editor itself in real time&lt;/strong&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I have this open in my vim (with line numbers on for illustration):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 for num in &quot;a&quot; &quot;b&quot; &quot;c&quot;; do echo &quot;${num}&quot;; sleep 1; done&#xA;2&#xA;3&#xA;4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I want is to be able to run a command that execute that line (something like &lt;code&gt;yyp!!bash&lt;/code&gt;), and get these in the editor in the interval of 1 second:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 for num in &quot;a&quot; &quot;b&quot; &quot;c&quot;; do echo &quot;${num}&quot;; sleep 1; done&#xA;2 a&#xA;3&#xA;4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 for num in &quot;a&quot; &quot;b&quot; &quot;c&quot;; do echo &quot;${num}&quot;; sleep 1; done&#xA;2 a&#xA;3 b&#xA;4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 for num in &quot;a&quot; &quot;b&quot; &quot;c&quot;; do echo &quot;${num}&quot;; sleep 1; done&#xA;2 a&#xA;3 b&#xA;4 c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this possible to do in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently &lt;code&gt;yyp!!bash&lt;/code&gt; will print the output only after the whole command is finished (i.e., only gets the output after three seconds).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If that's not possible (as hinted in the comments), alternatively I would be interested in an editable terminal, essentially being able to edit the output (and the input) of &lt;code&gt;:term&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21415" LastEditorUserId="21415" LastEditDate="2019-03-21T14:27:17.367" LastActivityDate="2021-07-04T21:30:10.917" Title="How to execute commands in vim, piping the output back into the editor in real time?" Tags="|vimscript|external-command|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19251" PostTypeId="2" ParentId="19235" CreationDate="2019-03-20T09:41:10.270" Score="3" Body="&lt;p&gt;I would propose the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap _X  :put =system(getline('.'))&amp;lt;cr&amp;gt;&#xA;vnoremap _X  :&amp;lt;C-U&amp;gt;'&amp;gt;put =system(join(getline('''&amp;lt;','''&amp;gt;'),\&quot;\n\&quot;).\&quot;\n\&quot;)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first mapping is to execute a single line. Just put the cursor in the line and hit &lt;code&gt;_X&lt;/code&gt;. This takes the current line (&lt;code&gt;getline(&quot;.&quot;)&lt;/code&gt;), executes it (&lt;code&gt;system(...)&lt;/code&gt;) and puts the returned result below the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The visual mode mapping works similar, but &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;`getline('''&amp;lt;', '''&gt;') fetches the list of selected lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;join(..., &quot;\n&quot;).&quot;\n&quot;&lt;/code&gt; joins the list into one string&lt;/li&gt;&#xA;&lt;li&gt;finally &lt;code&gt;put&lt;/code&gt; puts the result below the last selected line, due to the leading `'&gt;' &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-20T09:41:10.270" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19253" PostTypeId="2" ParentId="19243" CreationDate="2019-03-20T15:00:00.480" Score="1" Body="&lt;p&gt;You can use a sub-replace-expression to do the title casing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.*{\zs.*\ze}/\=substitute(submatch(0), '\&amp;lt;\w', '\u&amp;amp;', 'g')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Overview:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;\zs&lt;/code&gt; &amp;amp; &lt;code&gt;\ze&lt;/code&gt; to set the match to be inside the curly brackets (&lt;code&gt;{\zs.*\ze}&lt;/code&gt;). Then do a substitute on the match (&lt;code&gt;submatch(0)&lt;/code&gt;) where every start of a word (&lt;code&gt;\&amp;lt;\w&lt;/code&gt;)) is capitalized (&lt;code&gt;\u&amp;amp;&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h /\zs&#xA;:h sub-replace-expression&#xA;:h /\&amp;lt;&#xA;:h submatch()&#xA;:h substitute &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2019-03-20T18:58:00.620" LastActivityDate="2019-03-20T18:58:00.620" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19254" PostTypeId="1" AcceptedAnswerId="19255" CreationDate="2019-03-20T15:19:01.243" Score="0" ViewCount="390" Body="&lt;p&gt;I'v remapped &lt;code&gt;esc&lt;/code&gt; key by double &lt;code&gt;jj&lt;/code&gt; for insert mode and command line mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I using it in command line mode it removes the word where the cursor is highlighted &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap jj &amp;lt;esc&amp;gt;&#xA;nnoremap rr :s/\&amp;lt;&amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;\&amp;gt;/ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The example above shows that rr key for normal mode is highlight the current words and after user input the word and press the enter key, the highlighted words will be replaced. However, after I entered &lt;code&gt;rr&lt;/code&gt; in normal mode and want to cancel the replace action by press &lt;code&gt;jj&lt;/code&gt;, it removes the word under the cursor, why is that? and how can I solve this&lt;/p&gt;&#xA;" OwnerUserId="15958" LastActivityDate="2019-03-20T15:31:51.017" Title="remap esc key introduced remove behave" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19255" PostTypeId="2" ParentId="19254" CreationDate="2019-03-20T15:31:51.017" Score="2" Body="&lt;p&gt;That is expected behaviour. See &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_Esc&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h c_ESC&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In macros or when 'x' present in 'cpoptions', start entered command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In the vim documentation, when mentioning macros, this also applies to mappings and abbreviations (basically whenever the input has not literally been typed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you want to abort a command in command line mode, use &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;C&lt;/kbd&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-03-20T15:31:51.017" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19256" PostTypeId="1" AcceptedAnswerId="19262" CreationDate="2019-03-20T17:10:05.983" Score="0" ViewCount="158" Body="&lt;p&gt;So, I had this keymapping for helping me to edit files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;e :e **/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this doesn't work with hidden directories. So, I naively added:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;d :e .**/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this only worked if the root directory was hidden. All the other hidden directory in the directory tree would be ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I learnt from &lt;code&gt;:h starstar&lt;/code&gt; that &lt;code&gt;**&lt;/code&gt; is not used as &lt;code&gt;*&lt;/code&gt;. So, I can't do something like &lt;code&gt;[.]?**&lt;/code&gt;. And then I found out &lt;code&gt;:h backtick-expansion&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm doing following which gives me all the files with &lt;code&gt;.vim&lt;/code&gt; extension according to the output of the &lt;code&gt;find&lt;/code&gt; unix command, and I can tab through them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e `find . -name '*.vim' -print`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How wonderful! But from &lt;code&gt;:h backtick-expansion&lt;/code&gt;, I see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        :e `find . -name ver\\*.c -print`&#xA;&#xA;The backslashes before the star are required to prevent &quot;ver*.c&quot; to be&#xA;expanded by the shell before executing the find program.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, my questions are&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why using single quotes after &lt;code&gt;-name&lt;/code&gt; doesn't require &lt;code&gt;*&lt;/code&gt; to be escaped with backslashes?&lt;/li&gt;&#xA;&lt;li&gt;When would using single-quotes require escaping with backslashes?&lt;/li&gt;&#xA;&lt;li&gt;Is there any obscure part in &lt;code&gt;backtick-expansion&lt;/code&gt; that I have totally missed?&lt;/li&gt;&#xA;&lt;li&gt;How would I beautify this stupid mapping?&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;o :e `find . -name '' -print`&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="11357" LastEditDate="2019-10-21T12:06:26.190" LastActivityDate="2019-10-21T12:06:26.190" Title="Could backtick-expansion be consistently used for autocompleting filenames within directory tree?" Tags="|key-bindings|shell|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19257" PostTypeId="1" AcceptedAnswerId="19258" CreationDate="2019-03-20T18:33:57.657" Score="1" ViewCount="721" Body="&lt;p&gt;I need to find ONLY the lines that start with the string &lt;code&gt;G1 Z&lt;/code&gt;, and then replace any occurrence on that same line of &lt;code&gt;F1800&lt;/code&gt; with a new value of &lt;code&gt;F500&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;G1 Z9.800 F1800.000 ; move to next layer (48)&#xA;G1 X103.711 Y99.145 F1800.000 ; move to first perimeter point&#xA;G1 X96.289 Y96.289 E320.13685 ; perimeter&#xA;G1 Z0.000 F1800.000 ; move to next layer (49)&#xA;G1 X103.711 Y96.289 E320.44978 ; perimeter&#xA;G1 X103.711 Y99.070 E320.56702 ; perimeter&#xA;G1 X95.782 Y104.218 E321.13977 F1800.000 ; perimeter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;G1 Z9.800 F500.000 ; move to next layer (48)&#xA;G1 X103.711 Y99.145 F1800.000 ; move to first perimeter point&#xA;G1 X96.289 Y96.289 E320.13685 ; perimeter&#xA;G1 Z10.000 F500.000 ; move to next layer (49)&#xA;G1 X103.711 Y96.289 E320.44978 ; perimeter&#xA;G1 X103.711 Y99.070 E320.56702 ; perimeter&#xA;G1 X95.782 Y104.218 E321.13977 F1800.000 ; perimeter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know &lt;code&gt;/^G1 Z&lt;/code&gt; will find these lines, and &lt;code&gt;%s/F1800/F500/g&lt;/code&gt; will replace ALL F1800s, but I can't see how to restrict the replace to the lines starting with that string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm on GVIM 8.0.586.&lt;/p&gt;&#xA;" OwnerUserId="11454" LastActivityDate="2019-03-20T19:01:54.473" Title="How to replace a string only if the line starts with another string" Tags="|search|gvim|replace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19258" PostTypeId="2" ParentId="19257" CreationDate="2019-03-20T18:39:46.433" Score="7" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^G1 Z/s/F1800/F500/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:g&lt;/code&gt; is the &quot;global&quot; command. It selects lines with a regular expression and then executes a command on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here it selects lines that start with &lt;code&gt;G1 Z&lt;/code&gt; and then substitutes all &quot;F1800&quot; with &quot;F500&quot; in this line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The default command for &lt;code&gt;:g&lt;/code&gt; is &lt;code&gt;print&lt;/code&gt;. So by just executing &lt;code&gt;:g/^G1 Z/&lt;/code&gt; Vim will print all lines that start with &lt;code&gt;G1 Z&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;There is also the &lt;code&gt;:v/.../&lt;/code&gt; command. It selects all lines that does not match the given regular expression.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help multi-repeat&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-20T18:39:46.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19259" PostTypeId="2" ParentId="19257" CreationDate="2019-03-20T18:56:02.670" Score="2" Body="&lt;p&gt;The following command uses look behind regex pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(^G1 Z.*)@&amp;lt;=F1800/F500/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%s&lt;/code&gt; starts the substitution in the whole file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt; starts the find part of the find and replace.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; enables &lt;code&gt;very-magic&lt;/code&gt; (see &lt;code&gt;:h /magic&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(^G1 Z.*)@&amp;lt;=&lt;/code&gt; looks behind for lines starting with &lt;code&gt;G1 Z&lt;/code&gt;. But it doesn't start the matching. (see &lt;code&gt;:h /\@&amp;lt;=&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;F1800&lt;/code&gt; starts matching for, well, &lt;code&gt;F1800&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt; starts the replace part of find and replace.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;F500&lt;/code&gt; replaces the matched pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt; finishes the replace pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g&lt;/code&gt; is for global substitution, so that all the instances of &lt;code&gt;F1800&lt;/code&gt; will be replaced by &lt;code&gt;F500&lt;/code&gt;. (see &lt;code&gt;:h :s_flags&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-20T19:01:54.473" LastActivityDate="2019-03-20T19:01:54.473" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19260" PostTypeId="1" CreationDate="2019-03-20T21:59:16.253" Score="0" ViewCount="152" Body="&lt;p&gt;I am attempting custom fold logic as my first VimScript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What works for me: USING VERY MAGIC (\v) and explicit CASE SENSITIVE (\C), find python comments in foo.py that begin with hash, then Roman Numeral, a period, and finally .*$&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;/\v\C^#(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})\.\s.*$.@&amp;lt;=&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to apply this pattern to tell Vim when to start a fold in my Python scripts. The same pattern that works in foo.py now stops working once I pass it to a function. I assign the pattern to a variable in match() in python.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PythonFolds()&#xA;  let thisline = getline(v:lnum)&#xA;&#xA;  let rom_num = &quot;\v\C^#(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})\.\s.*$.@&amp;lt;=&quot;&#xA;  if match(thisline, rom_num) &amp;gt;= 0&#xA;    return &quot;&amp;gt;1&quot;&#xA;  else&#xA;    return &quot;=&quot; &#xA;  endif&#xA;endfunction&#xA;&#xA;setlocal foldmethod=expr&#xA;setlocal foldexpr=PythonFolds()&#xA;setlocal foldcolumn=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically when the above code is applied to a python.vim preference file, the folds are not applied. I have successfully tested simpler regex, which makes me believe the problem can be isolated as something I don't understand with regex/VimScript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if match(thisline, &quot;^#&quot;) &amp;gt;= 0      &quot; folds work as intended&#xA;   return &quot;&amp;gt;1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additionally, the tutorials below suggest that \v and \C are both passable in VimScript.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;\v&#xA;&lt;a href=&quot;http://andrewradev.com/2011/05/08/vim-regexes/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://andrewradev.com/2011/05/08/vim-regexes/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;\C&#xA;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/46.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://learnvimscriptthehardway.stevelosh.com/chapters/46.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am running Vim8 on Ubuntu 18.04.&lt;/p&gt;&#xA;" OwnerUserId="21448" LastActivityDate="2019-03-20T21:59:16.253" Title="How to pass '\v\C[pattern]' into the built-in match() VimScript function" Tags="|vimscript|regular-expression|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19261" PostTypeId="1" CreationDate="2019-03-20T22:52:31.413" Score="2" ViewCount="289" Body="&lt;p&gt;I'm trying to figure out a good workflow for printing source code and studying it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, the &lt;code&gt;TOhtml&lt;/code&gt; function seems really useful for this purpose. I can create an &lt;code&gt;html&lt;/code&gt; file with ease, open it in a browser and get a source code listing with extremely legible line numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My only complaint is that the resulting HTML file tries to mimic my white text on a dark background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, &lt;code&gt;foo.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line 1&#xA;Line 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which looks like this in my terminal&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   1 Line 1&#xA;   2 Line 2&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;~&#xA;foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;produces the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&amp;gt;&#xA;&amp;lt;html&amp;gt;&#xA;&amp;lt;head&amp;gt;&#xA;&amp;lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot;&amp;gt;&#xA;&amp;lt;title&amp;gt;~/tmp/foo.txt.html&amp;lt;/title&amp;gt;&#xA;&amp;lt;meta name=&quot;Generator&quot; content=&quot;Vim/8.1&quot;&amp;gt;&#xA;&amp;lt;meta name=&quot;plugin-version&quot; content=&quot;vim8.1_v1&quot;&amp;gt;&#xA;&amp;lt;meta name=&quot;syntax&quot; content=&quot;none&quot;&amp;gt;&#xA;&amp;lt;meta name=&quot;settings&quot; content=&quot;number_lines,use_css,no_foldcolumn,expand_tabs,line_ids,prevent_copy=&quot;&amp;gt;&#xA;&amp;lt;meta name=&quot;colorscheme&quot; content=&quot;least&quot;&amp;gt;&#xA;&amp;lt;style type=&quot;text/css&quot;&amp;gt;&#xA;&amp;lt;!--&#xA;pre { font-family: monospace; color: #ffffff; background-color: #000000; }&#xA;body { font-family: monospace; color: #ffffff; background-color: #000000; }&#xA;* { font-size: 1em; }&#xA;.LineNr { color: #008080; font-weight: bold; }&#xA;--&amp;gt;&#xA;&amp;lt;/style&amp;gt;&#xA;&#xA;&amp;lt;script type='text/javascript'&amp;gt;&#xA;&amp;lt;!--&#xA;&#xA;/* function to open any folds containing a jumped-to line before jumping to it */&#xA;function JumpToLine()&#xA;{&#xA;  var lineNum;&#xA;  lineNum = window.location.hash;&#xA;  lineNum = lineNum.substr(1); /* strip off '#' */&#xA;&#xA;  if (lineNum.indexOf('L') == -1) {&#xA;    lineNum = 'L'+lineNum;&#xA;  }&#xA;  var lineElem = document.getElementById(lineNum);&#xA;  /* Always jump to new location even if the line was hidden inside a fold, or&#xA;   * we corrected the raw number to a line ID.&#xA;   */&#xA;  if (lineElem) {&#xA;    lineElem.scrollIntoView(true);&#xA;  }&#xA;  return true;&#xA;}&#xA;if ('onhashchange' in window) {&#xA;  window.onhashchange = JumpToLine;&#xA;}&#xA;&#xA;--&amp;gt;&#xA;&amp;lt;/script&amp;gt;&#xA;&amp;lt;/head&amp;gt;&#xA;&amp;lt;body onload='JumpToLine();'&amp;gt;&#xA;&amp;lt;pre id='vimCodeElement'&amp;gt;&#xA;&amp;lt;span id=&quot;L1&quot; class=&quot;LineNr&quot;&amp;gt;1 &amp;lt;/span&amp;gt;Line 1&#xA;&amp;lt;span id=&quot;L2&quot; class=&quot;LineNr&quot;&amp;gt;2 &amp;lt;/span&amp;gt;Line 2&#xA;&amp;lt;/pre&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&amp;lt;!-- vim: set foldmethod=manual : --&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried disabling CSS via&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:html_use_css = 0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but the resulting html file still mimics the colorscheme of my current vim configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like there should be a dedicated way to say &quot;export this code as HTML in a way that will look nice when printed or viewed in a browser instead of mimicking what I see in my terminal&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found a 30% solution. Just call &lt;code&gt;sed&lt;/code&gt; on the html that vim generates with css generation disabled. It will do in a pinch but seems less than ideal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to manually adjust the colors with &lt;code&gt;sed&lt;/code&gt;. This intentionally ugly command line avoids differences between BSD and GNU sed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt; foo.txt.html sed \&#xA;'s/bgcolor=&quot;#......&quot;/bgcolor=&quot;#ffffff&quot;/;s/text=&quot;#......&quot;/text=&quot;#000000&quot;/' \&#xA;&amp;gt; /tmp/a.html ; \&#xA;cp /tmp/a.html foo.txt.html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2019-03-20T23:10:19.817" LastActivityDate="2019-03-22T06:02:05.170" Title="vim html version of text document black on white" Tags="|colorscheme|filetype-html|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19262" PostTypeId="2" ParentId="19256" CreationDate="2019-03-21T07:15:04.017" Score="3" Body="&lt;p&gt;Let me try to answer your questions here. We are going to touch shell command language here. It basically comes down to quote the arguments correctly, so that the shell does not expand them unintentionally. So to your questions:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;1) Why using single quotes after -name doesn't require * to be escaped with backslashes?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e `find . -name '*.vim' -print`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This passes the command &lt;code&gt;find . -name '*.vim' -print&lt;/code&gt; to your shell. The single quotes prevent the shell from expanding the &lt;code&gt;*&lt;/code&gt; to all vim files that are laying around in the current directory. (Sidenote: If your current directory does not contain any &lt;code&gt;.vim&lt;/code&gt; files, the &lt;code&gt;*&lt;/code&gt; is usually passed through to the command [well, depending on your shell and certain shell options]).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The alternative is of course to backslash escape the &lt;code&gt;*&lt;/code&gt; to prevent the shell from expanding.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2) When would using single-quotes require escaping with backslashes?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Off the top of my head, I don't currently think there is any necessity to need escaping within single quotes, except for preventing backslash escapes from being interpreted. There are two exceptions, however: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The command to be executed requires escaping for certain parts of the pattern. One example is if you want to print &lt;code&gt;foobar\n1&lt;/code&gt; in the shell, you can use &lt;code&gt;printf 'foobar\n1'&lt;/code&gt; will actually print:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; foobar&#xA; 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So instead, you need to use &lt;code&gt;printf 'foobar\\n1&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When run from within Vim, you need to escape the &lt;code&gt;#&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt; (and possibly others which I currently do not remember). So you need to escape those so that Vim won't try to replace those parts with the name of a file before passing the command to your shell.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;3) Is there any obscure part in backtick-expansion that I have totally missed?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yeah, I think this is only supported to work correctly on Unix like operating systems. I don't think this is all portable (and I believe Bram has mentioned in the past that he does not intend to enhance this further (when I mentioned I'd like to have a certain bug fixed)).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;4) How would I beautify this stupid mapping?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;o :e `find . -name '' -print`&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am leaving this for others to answer. I don't really care how beautiful a mapping looks like. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should also be possible to use &lt;code&gt;repeat()&lt;/code&gt; to return several times the same argument, but my basic attempt failed. Perhaps it is still to early for me to make this work :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(a bit later)&lt;/em&gt; &#xA;Ah, this seems to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;o &quot;:e `find . -name '' -print`&quot;.repeat('&amp;lt;left&amp;gt;', 9)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-03-21T09:55:46.213" LastActivityDate="2019-03-21T09:55:46.213" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19263" PostTypeId="2" ParentId="19261" CreationDate="2019-03-21T08:28:29.840" Score="1" Body="&lt;p&gt;In terminal Vim, the background for the HTML is derived from the option &lt;code&gt;background&lt;/code&gt;. If it is set to &lt;code&gt;dark&lt;/code&gt;, the HTML background is black. If &lt;code&gt;light&lt;/code&gt; the HTML background is white. The colors are fixed. Changing the Vim colorscheme does &lt;em&gt;not&lt;/em&gt; change the colors used in HTML.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In GVim the colors in the HTML match the colorscheme. If you use the colorscheme &quot;default&quot;, you get a white background.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another way would be to post-process the generated HTML and remove the internal CSS and replace it with a link to a external CSS file. You could then prepare a external CSS that fits your needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if this fits with your planed workflow. Anyway here is a quick-hack example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let DEFAULT_CSS=&quot;My-default-css-file.css&quot;&#xA;&#xA;function! MyToHtml(bang, css)&#xA;    let myCss=g:DEFAULT_CSS&#xA;    if !empty(a:css)&#xA;        let myCss = a:css&#xA;    endif&#xA;&#xA;    &quot; Create HTML&#xA;    TOhtml&#xA;&#xA;    &quot; if bang is given, write a css file. Name derived from html file&#xA;    &quot; but with extension 'css'&#xA;    if !empty(a:bang)&#xA;        let cssFilename = substitute(expand(&quot;%&quot;), '\.html$', '.css', '')&#xA;        execute '/^&amp;lt;style type=&quot;text\/css&quot;&amp;gt;/+2;/^&amp;lt;\/style&amp;gt;/-2 write! ' . cssFilename&#xA;        call cursor(1, 1)&#xA;    endif&#xA;&#xA;    &quot; delete the inline css code and replace it with a stylesheet link&#xA;    execute '/^&amp;lt;style type=&quot;text\/css&quot;&amp;gt;/;/^&amp;lt;\/style&amp;gt;/d'&#xA;    put! ='&amp;lt;link rel=\&quot;stylesheet\&quot; href=\&quot;' . myCss . '\&quot;&amp;gt;'&#xA;&#xA;endfunc&#xA;&#xA;&#xA;&quot; Usage:&#xA;&quot; MyToHtml[!] [css-file]&#xA;&quot; If bang (!) is given, write css-file from css found in html&#xA;&quot; If css-file is given use this as css-file&#xA;&quot; If css-file is NOT given use css-file set in g:DEFAULT_CSS&#xA;command! -bang -nargs=? MyToHtml call MyToHtml(&amp;lt;q-bang&amp;gt;, &amp;lt;q-args&amp;gt;)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-22T06:02:05.170" LastActivityDate="2019-03-22T06:02:05.170" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19264" PostTypeId="1" AcceptedAnswerId="19266" CreationDate="2019-03-21T10:53:06.063" Score="1" ViewCount="241" Body="&lt;p&gt;I am working on a group server and using Vim 6.4 there. And because admin there doesn't let us install new software or having any plugin-manager, I have to manually add those plugin files to runtimepath. However, I don't know why every time I add these files, there are always error when Vim trying to process them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what the error looks like when I try to add pathogen:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/tiennv/.vim/bundle/vim-pathogen/autoload/pathogen.vim:&#xA;line   24:&#xA;E128: Function name must start with a capital: pathogen#infect(...) abort&#xA;line   25:&#xA;E121: Undefined variable: a:0&#xA;E15: Invalid expression: a:0&#xA;line   34:&#xA;E492: Not an editor command:   for path in filter(copy(paths), 'v:val =~# static')&#xA;line   35:&#xA;E107: Missing braces: pathogen#surround(path)&#xA;line   36:&#xA;E492: Not an editor command:   endfor&#xA;line   37:&#xA;E492: Not an editor command:   for path in filter(copy(paths), 'v:val !~# static')&#xA;line   38:&#xA;E121: Undefined variable: path&#xA;E15: Invalid expression: path =~# '^\%([$~\\/]\|\w:[\\/]\)'&#xA;line   39:&#xA;E107: Missing braces: pathogen#surround(path)&#xA;line   41:&#xA;E107: Missing braces: pathogen#interpose(path)&#xA;line   43:&#xA;E492: Not an editor command:   endfor&#xA;line   44:&#xA;E107: Missing braces: pathogen#cycle_filetype()&#xA;line   45:&#xA;E121: Undefined variable: pathogen&#xA;E15: Invalid expression: pathogen#is_disabled($MYVIMRC)&#xA;line   46:&#xA;E133: :return not inside a function&#xA;line   48:&#xA;E133: :return not inside a function&#xA;line   49:&#xA;E193: :endfunction not inside a function&#xA;line   52:&#xA;E128: Function name must start with a capital: pathogen#split(path) abort&#xA;line   53:&#xA;-- More --&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here's what the error looks like when I try to add airline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/tiennv/.vim/bundle/vim-airline/autoload/airline.vim:&#xA;line    6:&#xA;E121: Undefined variable: g:&#xA;E116: Invalid arguments for function get(g:, 'airline_statusline_funcrefs', [])&#xA;E15: Invalid expression:  get(g:, 'airline_statusline_funcrefs', [])&#xA;line    8:&#xA;E15: Invalid expression: ['a','b','c','gutter','x','y','z', 'error', 'warning']&#xA;E15: Invalid expression:  ['a','b','c','gutter','x','y','z', 'error', 'warning']&#xA;line    9:&#xA;E15: Invalid expression: []&#xA;E15: Invalid expression:  []&#xA;line   10:&#xA;E15: Invalid expression:&#xA;E15: Invalid expression:&#xA;E15: Invalid expression:  {}&#xA;line   13:&#xA;E15: Invalid expression: [ function('airline#extensions#apply'), function('airline#extensions#default#apply') ]&#xA;E15: Invalid expression:  [ function('airline#extensions#apply'), function('airline#extensions#default#apply') ]&#xA;line   16:&#xA;E128: Function name must start with a capital: airline#add_statusline_func(name)&#xA;line   17:&#xA;E107: Missing braces: airline#add_statusline_funcref(function(a:name))&#xA;line   18:&#xA;E193: :endfunction not inside a function&#xA;line   20:&#xA;E128: Function name must start with a capital: airline#add_statusline_funcref(function)&#xA;line   21:&#xA;E121: Undefined variable: g:airline_statusline_funcrefs&#xA;E116: Invalid arguments for function index(g:airline_statusline_funcrefs, a:function) &amp;gt;= 0&#xA;E15: Invalid expression: index(g:airline_statusline_funcrefs, a:function) &amp;gt;= 0&#xA;line   22:&#xA;E107: Missing braces: airline#util#warning(printf('The airline statusline funcref &quot;%s&quot; has already been added.', string(a:function)))&#xA;line   23:&#xA;E133: :return not inside a function&#xA;line   25:&#xA;E121: Undefined variable: g:airline_statusline_funcrefs&#xA;E116: Invalid arguments for function add(g:airline_statusline_funcrefs, a:function)&#xA;-- More --&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, something is wrong with my version of Vim or my configuration is somewhat missing. But because I'm not very experienced with Vim, I don't know what's wrong? Can anyone help me with this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my configuration in .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime bundle/vim-pathogen/autoload/pathogen.vim&#xA;&quot; runtime bundle/vim-airline/autoload/airline.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21454" LastEditorUserId="1841" LastEditDate="2019-03-21T11:11:54.120" LastActivityDate="2019-03-21T13:25:03.993" Title="Vim 6.4 broke after adding plugin file to runtimepath" Tags="|plugin-system|version|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19265" PostTypeId="2" ParentId="19250" CreationDate="2019-03-21T11:17:21.400" Score="1" Body="&lt;p&gt;You've clarified in the comments that your need would be satisfied if you could edit the output buffer and current command prompt when in a &lt;code&gt;:terminal&lt;/code&gt; buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can achieve the latter by using your shell's &quot;edit in an editor&quot; function. In bash, this is called &lt;code&gt;edit-and-execute-command&lt;/code&gt; and is usually bound to &lt;kbd&gt;Ctrl-X&lt;/kbd&gt;&lt;kbd&gt;Ctrl-E&lt;/kbd&gt; (make sure your &lt;code&gt;EDITOR&lt;/code&gt; variable is set). &lt;a href=&quot;https://nuclearsquid.com/writings/edit-long-commands/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Other shells&lt;/a&gt; have &lt;a href=&quot;https://fishshell.com/docs/current/#shared-binds&quot; rel=&quot;nofollow noreferrer&quot;&gt;similar features&lt;/a&gt;, although I haven't tested these.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Amazingly, this even works inside a &lt;code&gt;:terminal&lt;/code&gt; buffer, spawning a new instance of Vim inside Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, unless I'm misreading &lt;code&gt;:help terminal.txt&lt;/code&gt;, it's not possible to edit the contents of a Vim terminal window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before looking into rolling your own solution, you might like to look into the &lt;a href=&quot;https://code.google.com/archive/p/conque/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Conque plugin&lt;/a&gt;. Whilst development on it has ceased, it's always worked well for me. To use it to run a bash shell you run the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ConqueTerm bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The new shell starts in insert mode. You can escape to normal mode by pressing &lt;kbd&gt;Esc&lt;/kbd&gt; as usual, after which you can edit any output using regular Vim commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Entering insert mode while on the command line will return you to typing into the prompt, but you can still use &lt;code&gt;edit-and-execute-command&lt;/code&gt; to edit the current command as I described above. The one proviso is that when you are in the Vim-inside-a-Vim in Conque, pressing &lt;kbd&gt;Esc&lt;/kbd&gt; will exit insert mode of the &lt;em&gt;outer&lt;/em&gt; instance of Vim. The easiest way to exit insert mode in the &lt;em&gt;inner&lt;/em&gt; Vim is to press &lt;kbd&gt;Ctrl-C&lt;/kbd&gt; instead, but setting up a mapping would also work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the above applies to Vim. I don't know what the situation is like in Neovim, which has it's own similar-but-different implementation of a terminal window.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-03-21T11:38:01.667" LastActivityDate="2019-03-21T11:38:01.667" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19266" PostTypeId="2" ParentId="19264" CreationDate="2019-03-21T13:25:03.993" Score="6" Body="&lt;p&gt;I am sorry, but you won't get happy with your ancient Vim 6.4 and plugins. Most of the scripting functionality have been added with the Vim 7 version and beyond. The old 6 version did only have very limited set of available functions (e.g. &lt;code&gt;glob()&lt;/code&gt; was certainly one of them, but did only support String and int as data types.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So have a look at the errors:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E128: Function name must start with a capital: pathogen#infect(...) abort&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That clearly means, that your Vim cannot handle auto-loadable functions.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E492: Not an editor command:   for path in filter(copy(paths), 'v:val =~# static')&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your Vim does not understand basic for loops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I skip the rest of your errors. Have a look at &lt;a href=&quot;https://vimhelp.org/version8.txt.html&quot; rel=&quot;noreferrer&quot;&gt;:h version8&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/version7.txt.html&quot; rel=&quot;noreferrer&quot;&gt;:h version7&lt;/a&gt; to find out about all the new features that the later version provides.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As said in the comments, Vim 6.4 has been &lt;a href=&quot;https://github.com/vim/vim-history/&quot; rel=&quot;noreferrer&quot;&gt;released almost 14 years ago&lt;/a&gt;. There will be almost no plugin (besides the very basic filetype plugins that came with Vim back then) that will run with that version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you cannot update, consider using a self compiled Vim or try the &lt;a href=&quot;https://github.com/vim/vim-appimage/&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/vim/vim-appimage/&lt;/a&gt; (although I really doubt that they will run with the underlying old libc and all other required libraries)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can say one more word as the maintainer of airline. vim-airline is tested against vim 7.2 and I am trying to keep this compatibility as long as possible. However even Vim 7.2 is already more than 10 years old and is becoming a hassle to support such ancient versions. I am pretty sure it will be almost impossible to support such an ancient Vim as 6.4.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-03-21T13:25:03.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19267" PostTypeId="2" ParentId="19250" CreationDate="2019-03-21T14:18:15.737" Score="1" Body="&lt;p&gt;Well looking at your comments... Try to reuse built in &lt;code&gt;:terminal&lt;/code&gt; either by manually copy-pasting to it or using plugin &lt;a href=&quot;https://github.com/habamax/vim-sendtoterm&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/habamax/vim-sendtoterm&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might look like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/T2GGP.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T2GGP.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-03-21T14:18:15.737" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19268" PostTypeId="2" ParentId="19243" CreationDate="2019-03-21T14:45:22.353" Score="2" Body="&lt;h1&gt;Use a Macro!&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You already have three excellent answers explaining how to achieve this using regular expressions. However, I thought I'd offer a solution that uses a completely different Vim feature. viz. a recording, or &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#complex-repeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;macro&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In many circumstances, a macro is a terrific alternative to a complex regular expression, and, to my mind, if you don't already have a good grasp of intermediate/advanced regular expression constructs, then macros are easier to pick up, because they just use all the editing commands you already know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Getting your head around how to ensure that the macro you record will work in all the places you intend to play it back does take a little bit of practice, but, personally, I found this easier than learning how all Vim's various regexp atoms work, and remembering the arcane syntax required to invoke them.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The Solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here's how to uppercase all your headings with a recursive macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, place your cursor on the beginning of the word &lt;code&gt;New&lt;/code&gt;, and then type the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqqqqgUlhellbw@qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will record a recursive macro that updates all the words in the current section header to begin with an uppercase character. To play this back, just run the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/section/norm!f{l@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Amazing! So how does this work?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Explanation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Let's break down the macro into its constituent parts:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;qqqqq {some stuff} @qq&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The beginning and end of our recording is just boilerplate for recording a recursive macro. You don't need to know how it works to use it, but how it does work is straightforward:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qqq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first three &lt;code&gt;q&lt;/code&gt; characters starts recording a macro into register &lt;code&gt;q&lt;/code&gt; and then immediately ends the recording, so the macro ends up empty. This will become important when we get to the end of our recording&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now we start recording our real macro into register &lt;code&gt;q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{some stuff}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then we type our macro steps. We'll come back to this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, we type &lt;code&gt;@q&lt;/code&gt; to make our macro recursive, and then type &lt;code&gt;q&lt;/code&gt; to end the recording.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When running the final macro, the &lt;code&gt;@q&lt;/code&gt; will cause our macro to run again and again until it hits an &quot;error&quot;, but when &lt;em&gt;recording&lt;/em&gt; the macro, the &lt;code&gt;q&lt;/code&gt; register is empty (because we specifically emptied it as the first thing we did), so typing it does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now lets take a look at the commands in the middle that actually do the work. We need to write a series of commands that will a). perform one change, and b). move the cursor to the next location where we want the change to be made, throwing some kind of error if we've reached the last location. So:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;gUhellbw&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;First we need to uppercase the first character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gU&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Done!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, we need to check if we're finished and jump to the next location. The easiest way to check if we're finished is to jump to the end of the current word and then attempt to move the cursor right twice. If we're on the final word, we'll &lt;a href=&quot;https://vi.stackexchange.com/a/6428/343&quot;&gt;hit the end of the line and the macro will stop&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;he&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is an example of the sort of thing you need to watch out for when recording a macro. We want to jump to the end of the word. Normally, &lt;code&gt;e&lt;/code&gt; will do this. But if we're on a single letter word like &lt;code&gt;A&lt;/code&gt;, it will instead jump to the end of the &lt;em&gt;next&lt;/em&gt; word. So first we move left once with &lt;code&gt;h&lt;/code&gt; and &lt;em&gt;then&lt;/em&gt; we jump to the end of the word with &lt;code&gt;e&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;llb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If we at the end of the final word on the line, attempting to move right twice will first move onto the &lt;code&gt;}&lt;/code&gt; character and then hit the end of the line, causing an &quot;error&quot; which means the macro will stop*. If there was no error, we are good to continue so we jump back to the start of the word with &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now we just need to move to the next word that needs to be uppercased.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So our macro is complete!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we just need to play it back once per section heading:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;:g/section/norm!f{l@q&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;We use the same &lt;code&gt;:global&lt;/code&gt; search that you already supplied: &lt;code&gt;:g/section/&lt;/code&gt;. Then, for our command, we just use some more normal mode commands, run via the &lt;a href=&quot;http://vimhelp.org/various.txt.html#:normal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:normal!&lt;/code&gt;&lt;/a&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f{l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This jumps to the first &lt;code&gt;{&lt;/code&gt; on the line and then moves right onto the first character of the section heading.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This plays back the macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;* N.B. I'm presuming you're using the default setting for &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27whichwrap%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'whichwrap'&lt;/code&gt;&lt;/a&gt;. If you have edited this setting to include &lt;code&gt;l&lt;/code&gt;, then replace the &lt;code&gt;l&lt;/code&gt; commands in the macro with either &lt;kbd&gt;Right Arrow&lt;/kbd&gt;, or &lt;kbd&gt;Space&lt;/kbd&gt;, depending on which of these is&lt;/em&gt; not &lt;em&gt;present in your &lt;code&gt;'whichwrap'&lt;/code&gt; setting. (There's not really any good reason to have all three in the setting, so if they are all present, consider removing one!)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-03-27T20:51:54.487" LastActivityDate="2019-03-27T20:51:54.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19269" PostTypeId="1" AcceptedAnswerId="19270" CreationDate="2019-03-21T17:15:47.633" Score="1" ViewCount="252" Body="&lt;p&gt;I'm trying to make it easier to refactor stuff by running a single command that &quot;performs the last rename interactively&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a binding for doing this that sort of works, but I'm curious whether there's a way to prevent it from ever getting &quot;out of sync&quot; by replacing an old substitution with a recent edit.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;so far the best I've been able to find is this, which clobbers a register and a marker and the user to manually &quot;wrap&quot; commands so that they populate the contents of the &lt;code&gt;p&lt;/code&gt; register. It's also very easy for &lt;code&gt;&amp;lt;leader&amp;gt;,&lt;/code&gt; to pick up a new edit and there's absolutely no indication that this has happened. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ciw mP&quot;pyiw`Pciw&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;, :%s/&amp;lt;c-r&amp;gt;p/&amp;lt;c-r&amp;gt;./gc&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to start with a file that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AAAA       (instant 1)&#xA;AAAA&#xA;AAAA&#xA;AAAA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;run the following commands &lt;code&gt;gg0ciwBBBBBBB&amp;lt;esc&amp;gt;&lt;/code&gt;, get the following buffer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BBBBBBB    (instant 2)&#xA;AAAA&#xA;AAAA&#xA;AAAA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;since &lt;code&gt;ciw&lt;/code&gt; has been remapped, running &lt;code&gt;&amp;lt;leader&amp;gt;,&lt;/code&gt; causes the buffer to look like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BBBBBBB    (instant 3)&#xA;BBBBBBB&#xA;BBBBBBB&#xA;BBBBBBB&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is correct behavior. If, however, I performed I inserted and then deleted some text after &lt;code&gt;(instant 2)&lt;/code&gt;. By performing &lt;code&gt;0ia&amp;lt;esc&amp;gt;&lt;/code&gt; and then &lt;code&gt;x&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aBBBBBBB    (instant 2.1 -- alternate)&#xA;AAAA&#xA;AAAA&#xA;AAAA&#xA;&#xA;BBBBBBB     (instant 2.2 -- alternate)&#xA;AAAA&#xA;AAAA&#xA;AAAA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then performing &lt;code&gt;&amp;lt;leader&amp;gt;,&lt;/code&gt; will result in the following buffer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BBBBBBB     (instant 3 -- alternate)&#xA;a&#xA;a&#xA;a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the correct identifier &lt;code&gt;AAAA&lt;/code&gt; was targeted, but the contents of the &lt;code&gt;.&lt;/code&gt; register has changed. I'd like a solution where performing a mismatched substitution is simply impossible.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2019-03-21T17:52:55.307" LastActivityDate="2019-03-22T01:31:58.483" Title="vim change instances of same identifier after `ciw`" Tags="|register|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19270" PostTypeId="2" ParentId="19269" CreationDate="2019-03-21T17:56:00.937" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;InsertLeave&lt;/code&gt; to capture &lt;code&gt;@@&lt;/code&gt; and &lt;code&gt;@.&lt;/code&gt; then use those values in your substitution mapping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; ciw &amp;lt;SID&amp;gt;replacer()&#xA;nnoremap gs :&amp;lt;c-u&amp;gt;%s/&amp;lt;c-r&amp;gt;=get(g:, 'replacer_pat')&amp;lt;cr&amp;gt;/&amp;lt;c-r&amp;gt;=get(g:, 'replacer_str')&amp;lt;cr&amp;gt;/gc&#xA;&#xA;function s:replacer()&#xA;  augroup replacer&#xA;    autocmd!&#xA;    autocmd InsertLeave * execute &quot;autocmd! replacer&quot; |&#xA;          \ let [g:replacer_pat, g:replacer_str] = [getreg(v:register), @.]&#xA;  augroup END&#xA;  return 'ciw'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;InsertLeave&lt;/code&gt; will not fire if you use &lt;code&gt;&amp;lt;c-c&amp;gt;&lt;/code&gt;. It might also act incorrectly when using &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2019-03-21T18:02:31.207" LastActivityDate="2019-03-21T18:02:31.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19271" PostTypeId="2" ParentId="19269" CreationDate="2019-03-22T01:31:58.483" Score="1" Body="&lt;p&gt;I recently added this little snippet to my vimrc, which accomplishes a similar but different effect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;cw :let @/=expand('&amp;lt;cword&amp;gt;')&amp;lt;CR&amp;gt;cgn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this, I can do &lt;code&gt;&amp;lt;Leader&amp;gt;cw&lt;/code&gt;, insert some text, and use &lt;code&gt;n&lt;/code&gt; to go to instances of the old name and &lt;code&gt;.&lt;/code&gt; to instantly change the next one wherever it is (see &lt;code&gt;:help gn&lt;/code&gt;). This provides me with a selective renaming tool. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-22T01:31:58.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19272" PostTypeId="2" ParentId="18978" CreationDate="2019-03-22T07:06:49.513" Score="5" Body="&lt;p&gt;The existing answer which suggests using Visual mode and &lt;code&gt;\%V&lt;/code&gt; is good. But since you mentioned line ranges and directional searches I figured it worth mentioning a couple other options, one of which allows relative line ranges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Absolute line ranges in search can be specified with the &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#E951&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\%l&lt;/code&gt; pattern atoms&lt;/a&gt; &lt;code&gt;\%&amp;gt;###l&lt;/code&gt; and &lt;code&gt;\%&amp;lt;###l&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\%&amp;gt;100lfoo\%&amp;lt;200l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will search for &quot;foo&quot; between lines 100 and 200.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Searching the next 200 lines starting with, let's say, a current line number of 50:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/foo\%&amp;lt;250l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you wanted to do something like that programmatically, in a mapping for example, this would do the same thing but for any current line number:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe '/foo\%&amp;lt;' . (line(&quot;.&quot;) + 200) . 'l'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that these operations are &lt;em&gt;exclusive&lt;/em&gt;. Referring to the first example, &lt;code&gt;\%&amp;lt;200l&lt;/code&gt; means &quot;less than 200&quot; just like the &lt;code&gt;&amp;lt;&lt;/code&gt; suggests so use &lt;code&gt;/\%&amp;gt;99lfoo\%&amp;lt;201l&lt;/code&gt; if you want to search lines 100 and 200 as well.* &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What if you want to use relative line ranges without resorting to anything programmatic? By relative I mean a range like &lt;code&gt;-10,+20&lt;/code&gt; (start 10 lines before the current line and end 20 lines beyond it).  For that you'll need to use a bit of a trick: the substitute command with the &lt;code&gt;c&lt;/code&gt; flag (normally used to manually confirm each potential substitution). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:-10,+20s/foo//gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Upon a match you will be asked to enter a one-character command that determines what happens next. Under typical circumstances you'd be deciding whether to do the substitution or not but in this case only two commands are of interest to us: &lt;code&gt;n&lt;/code&gt; to continue searching (without substitution!) and &lt;code&gt;q&lt;/code&gt; to quit searching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can, of course, use this method for absolute line ranges, too, if you prefer it to the &lt;code&gt;\%l&lt;/code&gt; searches described above.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-03-24T16:15:49.203" LastActivityDate="2019-03-24T16:15:49.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19273" PostTypeId="1" AcceptedAnswerId="19274" CreationDate="2019-03-22T10:56:24.350" Score="2" ViewCount="213" Body="&lt;p&gt;In VIM, using search and replace like &lt;code&gt;:%s/pat/repl/g&lt;/code&gt;, is it possible to have a quantifier in the replace part?&#xA;As an example, replace every line matching &lt;code&gt;pat&lt;/code&gt; by exactly 100 &lt;code&gt;#&lt;/code&gt; without actually typing exactly 100 &lt;code&gt;#&lt;/code&gt;'s into the command?&#xA;Something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/pat/#\{100}/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which, however, doesn't work for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More generally, is it possible to replace matches by a captured amount of characters?&#xA;For example replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This 3 is a text 5 &#xA;with some 2 numbers.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This XXX is a text XXXXX &#xA;with some XX numbers.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;using something like &lt;code&gt;:%s/\(\d\)/X\{\1}/g&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="21468" LastActivityDate="2019-03-22T12:02:31.643" Title="(Dynamical) quantifier in search and replace" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19274" PostTypeId="2" ParentId="19273" CreationDate="2019-03-22T12:02:31.643" Score="2" Body="&lt;p&gt;You are searching for &quot;sub-replace-expression&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(\d\)/\=repeat('X', submatch(1))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;\=&lt;/code&gt; the replace string is a Vim script expression. Here the function &lt;code&gt;repeat()&lt;/code&gt; is called. This functions returns a String that repeats the given String count times. The String is &lt;code&gt;X&lt;/code&gt; and the count is the first match group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help sub-replace-expression&lt;/code&gt; and &lt;code&gt;:help repeat()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-22T12:02:31.643" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19275" PostTypeId="1" CreationDate="2019-03-22T14:49:50.867" Score="0" ViewCount="36" Body="&lt;p&gt;Search pattern examples &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;0:4.10.5-5.el7&quot;&#xA;&quot;0:0.7.7-13.20120626.ov7&quot;&#xA;&quot;6:4.14.8-6.po7_3&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to search and print all occurrences like above patterns where the first number can be any number ranging from 0-9 separated by &quot;:&quot; trailing with any number or alphabet ranging from a-z separated by . or. in vi editor ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I could search the occurrences of all the patterns starting with any number [0-9] separated by &quot;:&quot; using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/[0-9]\+\:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;how to remove all the occurrences till end of line of each occurrence&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="21472" LastEditorUserId="2920" LastEditDate="2019-03-22T16:24:01.910" LastActivityDate="2019-03-22T16:24:01.910" Title="Search and replace any number separated by : trailing with number or alphabet separated by . and / or - or _" Tags="|regular-expression|substitute|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19276" PostTypeId="1" AcceptedAnswerId="19287" CreationDate="2019-03-22T17:44:21.330" Score="5" ViewCount="2116" Body="&lt;p&gt;My problem is similar to, if not same as, &lt;a href=&quot;https://github.com/neovim/neovim/issues/3340&quot; rel=&quot;noreferrer&quot;&gt;this issues&lt;/a&gt;. But I can't follow what they're talking about.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following steps are necessary to reproduce my problems:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sp&#xA;:term&#xA;:wincmd w&#xA;:wincmd o&#xA;:ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you'll see that the terminal buffer has disappeared. Any idea why it happens and how to keep the terminal buffer present/alive in the buffer list even after it has been hidden?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; I know about &lt;code&gt;:set hidden&lt;/code&gt;. But I don't like how it hides buffers yet to be written to disks. I want to use &lt;code&gt;autocmd&lt;/code&gt; to modify the neovim terminal buffer so that it &lt;em&gt;can't&lt;/em&gt; be hidden &lt;em&gt;at all&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-23T09:13:44.350" LastActivityDate="2019-03-23T09:22:07.347" Title="How to keep the neovim terminal buffer in the buffer list even after it being hidden" Tags="|neovim|terminal-buffer|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19277" PostTypeId="1" AcceptedAnswerId="19278" CreationDate="2019-03-22T18:18:49.050" Score="2" ViewCount="130" Body="&lt;p&gt;I'd like to make a command that works like this: &lt;code&gt;:KeepCursor {cmd}&lt;/code&gt; will the given execute ex command string, then restore the cursor's position.  A primary example is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:KeepCursor normal! *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which would perform a keyword search without jumping to the next match.  This can of course be accomplished in other ways, but it's a good demonstration of the functionality I'm looking for, which I want to work in every possible case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my attempt so far.  I'm using &lt;code&gt;feedkeys&lt;/code&gt;+&lt;code&gt;imtx&lt;/code&gt; because I'd like the command to behave exactly as though I typed it.  I put the cursor restoration in a &lt;code&gt;finally&lt;/code&gt; so it works even if the command encounters an error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:keepcursor(qargs)&#xA;  let l:view = winsaveview()&#xA;  let l:winid = win_getid()&#xA;  try&#xA;    call feedkeys(':'.a:qargs.&quot;\&amp;lt;cr&amp;gt;&quot;, 'imtx')&#xA;  finally&#xA;    if win_getid() != l:winid&#xA;      if !win_id2win(l:winid)&#xA;        return&#xA;      endif&#xA;      call win_gotoid(l:winid)&#xA;    endif&#xA;    call winrestview(l:view)&#xA;  endtry&#xA;endfunction&#xA;&#xA;command! -nargs=* KeepCursor call s:keepcursor(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it does not seem to work.  Using &lt;code&gt;:KeepCursor normal! *&lt;/code&gt; prints the search string but does not highlight anything.  Running &lt;code&gt;:hlsearch&lt;/code&gt; afterwards highlights the wrong thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are a) can it be explained why this doesn't work and b) can such a &lt;code&gt;:KeepCursor&lt;/code&gt; command be written?&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-03-25T07:58:41.277" Title="creating a &quot;:KeepCursor&quot; command" Tags="|search|command-line|cursor|command|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19278" PostTypeId="2" ParentId="19277" CreationDate="2019-03-22T19:02:46.480" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can it be written?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yup.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* -complete=command KeepCursor&#xA;      \ let [s:view, s:win] = [winsaveview(), win_getid()] |&#xA;      \ try |&#xA;      \   execute &amp;lt;q-args&amp;gt; |&#xA;      \ finally |&#xA;      \   if win_id2win(s:win) |&#xA;      \     call win_gotoid(s:win) |&#xA;      \   endif |&#xA;      \   keepjumps call winrestview(s:view) |&#xA;      \ endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can it be explained why this doesn't work&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is a lot going on here. I haven't debugged anything, but my guess is &lt;code&gt;feedkeys()&lt;/code&gt; is part of your problem. I typically avoid &lt;code&gt;feedkeys()&lt;/code&gt; as it is often easier to debug other methods.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2019-03-22T21:05:53.037" LastActivityDate="2019-03-22T21:05:53.037" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19279" PostTypeId="1" AcceptedAnswerId="19280" CreationDate="2019-03-22T19:03:55.667" Score="2" ViewCount="111" Body="&lt;p&gt;&lt;strong&gt;TLDR: Can I make Vim automatically switch to the buffer that I just opened?&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please tell me if I'm using Vim wrong in this case or something.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm currently working with &lt;code&gt;foo.txt&lt;/code&gt;.  I want to look at &lt;code&gt;bar.txt&lt;/code&gt;.  I type &lt;code&gt;:badd bar.txt&lt;/code&gt;.  I now have a new buffer for &lt;code&gt;bar.txt&lt;/code&gt;, but I'm still looking at &lt;code&gt;foo.txt&lt;/code&gt;, and I'm annoyed that Vim didn't switch to &lt;code&gt;bar.txt&lt;/code&gt;.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing I just opened should be the focus, not put in the background.  It seems like every other piece of software acts differently.  I use &lt;code&gt;set hidden&lt;/code&gt;, so it shouldn't matter if I have unsaved changes in &lt;code&gt;foo.txt&lt;/code&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="21476" LastActivityDate="2019-03-22T19:06:44.470" Title="How can I set Vim to switch to a buffer after I add it?" Tags="|buffers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19280" PostTypeId="2" ParentId="19279" CreationDate="2019-03-22T19:06:44.470" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;:edit&lt;/code&gt; or &lt;code&gt;:e&lt;/code&gt; to edit a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e bar.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:badd&lt;/code&gt; will simply add the buffer/document to the buffer list and not focus the buffer like you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :e&#xA;:h :badd&#xA;:h buffers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-03-22T19:06:44.470" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19281" PostTypeId="1" CreationDate="2019-03-22T19:34:22.817" Score="8" ViewCount="31437" Body="&lt;p&gt;Let's say a buffer has a certain characters I know will be repeated seven (7) times. How can I search for &lt;em&gt;any&lt;/em&gt; character repeated seven times? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can search for &lt;code&gt;..&lt;/code&gt;, but those to characters won't necessarily be the same. There's also a special character (not sure if it's &lt;code&gt;&amp;amp;&lt;/code&gt;) that can be used in substitutions to paste the found string in the replacement field, but I'm also not sure if that's useable again here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;I'm specifically searching for merge conflict markers from git (&lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/code&gt;, &lt;code&gt;=======&lt;/code&gt;, or &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; - possibly &lt;code&gt;|||||||&lt;/code&gt;), but I'd like to know how to perform this search for &lt;em&gt;any&lt;/em&gt; character X, repeating N times, so that I may reapply the knowledge in the future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to @DJMcMayhem for the suggestion of vimregex.com; it lead me to search for &lt;code&gt;/\v&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;|=====|&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; which caused an error, as each of those are special characters. Escaping those, however (&lt;code&gt;/\v\&amp;lt;\&amp;lt;\&amp;lt;\&amp;lt;\&amp;lt;|\=\=\=\=\=|\&amp;gt;\&amp;gt;\&amp;gt;\&amp;gt;\&amp;gt;&lt;/code&gt;) did succeed in finding what I was looking for, &lt;em&gt;in the short term&lt;/em&gt;. I'm still looking for a way to search for character X, repeating N times.&lt;/p&gt;&#xA;" OwnerUserId="16795" LastEditorUserId="16795" LastEditDate="2019-03-23T03:04:07.053" LastActivityDate="2019-03-23T03:04:07.053" Title="How to search for any repeating character, X number of times" Tags="|regular-expression|search|find|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19282" PostTypeId="1" CreationDate="2019-03-22T19:45:07.790" Score="1" ViewCount="34" Body="&lt;p&gt;(tag suggestions welcome)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've just started learning Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My other text editor, which I use for writing Hive queries is a browser based editor which has this very useful feature of auto suggesting schema and table names as a drop down as I start typing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Cbh8A.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cbh8A.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is handy since other schema names and table names are long and or have nuances around underscrores or dashes which I often forget.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess it's probably a long shot but I wanted to ask anyway. Is there some way for me to pass vim the schemas and store them somewhere so that vim could auto suggest as I type like in the screen shot?&lt;/p&gt;&#xA;" OwnerUserId="21478" LastEditorUserId="16280" LastEditDate="2019-03-24T20:59:26.033" LastActivityDate="2019-03-24T20:59:26.033" Title="Is it possible to have auto suggestion of schema names?" Tags="|autocompletion|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19284" PostTypeId="2" ParentId="19281" CreationDate="2019-03-22T20:15:15.343" Score="16" Body="&lt;p&gt;There's two different regex features that would be helpful. First off, you can use capturing groups. If you put something in parentheses, you can refer to whatever matched inside. So&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\(.\)\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will match &lt;em&gt;any character&lt;/em&gt; (&lt;code&gt;\(.\)&lt;/code&gt;) followed by that same character (Group 1, &lt;code&gt;\1&lt;/code&gt;). You can also refer to groups in the replacement part of a substitute command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other feature is quantifiers.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;\{n,m}&lt;/code&gt;&#xA;matches from n to m of the preceding characters...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;\{n}&lt;/code&gt;&#xA;matches exactly n times of the preceding characters...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;\{,m}&lt;/code&gt;&#xA;matches at most m (from 0 to m) of the preceding characters...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;\{n,}&lt;/code&gt;&#xA;matches at least n of of the preceding characters...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;putting it all together, you want to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\(.\)\1\{6}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or as the way I'd prefer it, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v(.)\1{6}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'd recommend reading through &lt;a href=&quot;http://vimregex.com/&quot; rel=&quot;noreferrer&quot;&gt;vimregex.com&lt;/a&gt;. It's a good tutorial on vim regex features.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2019-03-22T22:14:56.940" LastActivityDate="2019-03-22T22:14:56.940" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19285" PostTypeId="1" AcceptedAnswerId="19286" CreationDate="2019-03-23T04:57:18.537" Score="2" ViewCount="150" Body="&lt;p&gt;Preface: Newish to vim so please excuse any rookie mistakes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I normally use vim-latex/latex-suite to edit .tex files, and it works great. I've also started to use vim to edit scripts, and I use the autoclose plugin to help with that. Unfortunately, autoclose interferes with some of the imaps in latex-suite, so I'd like to disable it when editing tex files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I've tried the following autocmd in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.tex AutoCloseoff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it seems to work ok for the most part (it seems to correctly disable autoclose when I'm editing tex files). However, I'm not able to use the original imaps with latex-suite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example (the pipe represents the cursor)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without autoclose installed (what I want):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(( turns into (|)&amp;lt;++&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With autoclose installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(( turns into ((|))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With autoclose installed but disabled:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(( turns into ((&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="21479" LastEditorUserId="1292" LastEditDate="2019-03-23T08:35:32.810" LastActivityDate="2019-03-23T14:30:01.033" Title="Problem disabling autoclose when editing .tex files with vim-latex" Tags="|plugin-vim-latex|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19286" PostTypeId="2" ParentId="19285" CreationDate="2019-03-23T08:14:51.403" Score="0" Body="&lt;h3&gt;Preface: Disambiguation of plugins called “AutoClose”&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Plugins on vim.org: Two plugins with the name AutoClose are hosted on vim.org.&#xA;The AutoClose plugin &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2009&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;#2009&lt;/code&gt;&lt;/a&gt; by Thiago Alves which provides the command &lt;code&gt;:AutoCloseoff&lt;/code&gt; and the AutoClose plugin &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1849&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;#1849&lt;/code&gt;&lt;/a&gt; by Karl Guertin which does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Github repositories:&#xA;Thiago Alves has created a github repo for his AutoClose plugin: &lt;a href=&quot;https://github.com/Townk/vim-autoclose&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Townk/vim-autoclose&lt;/a&gt;.&#xA;Furthermore, the version on vim.org is mirrored by &lt;a href=&quot;http://vim-scripts.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim-scripts.org/&lt;/a&gt; to &lt;a href=&quot;https://github.com/vim-scripts/AutoClose--Alves&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim-scripts/AutoClose--Alves&lt;/a&gt; and not to &lt;a href=&quot;https://github.com/vim-scripts/AutoClose&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim-scripts/AutoClose&lt;/a&gt; which again is the plugin by Karl Guertin.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Naive answer: Install into &lt;code&gt;opt&lt;/code&gt; of a vim8 packpath and load on-demand&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The plugin AutoClose--Alves installs an autocmd which ensures the availability of its insert mode mappings all the time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead,BufEnter * if !&amp;lt;SID&amp;gt;IsLoadedOnBuffer() | call &amp;lt;SID&amp;gt;CreateMaps() | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Furthermore, calling &lt;code&gt;:AutoCloseOff&lt;/code&gt; does not unmap them.&#xA;You can verify this by running &lt;code&gt;:AutoCloseOff&lt;/code&gt; and then call&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose imap (&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i  (           * &amp;lt;C-R&amp;gt;=&amp;lt;SNR&amp;gt;32_SetVEAll()&amp;lt;CR&amp;gt;&amp;lt;C-R&amp;gt;=&amp;lt;SNR&amp;gt;32_InsertPair(&quot;(&quot;)&amp;lt;CR&amp;gt;&amp;lt;C-R&amp;gt;=&amp;lt;SNR&amp;gt;32_RestoreVE()&amp;lt;CR&amp;gt;&#xA;Last set from ~/.vim/plugin/autoclose.vim line 181&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:AutoCloseOff&lt;/code&gt; just &lt;a href=&quot;https://github.com/vim-scripts/AutoClose--Alves/blob/master/plugin/autoclose.vim#L167-L189&quot; rel=&quot;nofollow noreferrer&quot;&gt;sets a variable&lt;/a&gt; which is taken into account when the mappings are evaluated.&#xA;This means it still overrides vim-latex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A naive attempt to solve the problem would be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source Autoclose--Alves only for those filetypes you want to use it.&#xA;If you have vim8, you would install it into the &lt;code&gt;opt&lt;/code&gt; folder in a packpath, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/pack/manual/opt/vim-autoclose/plugin/autoclose.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and add following to the vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let blacklist = ['tex']&#xA;autocmd Filetype * if index(blacklist, &amp;amp;ft) &amp;lt; 0 | packadd vim-autoclose&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this naive attempt does not actually solve the problem because as soon&#xA;as the autocmd is installed, it is also triggered for new or existing tex buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The autocmd installation happens for example also for help buffers. This means even though&#xA;you edit only tex files but  look into a vim help page with &lt;code&gt;:h &amp;lt;topic&amp;gt;&lt;/code&gt;, the autocmd gets still installed.&#xA;If we return from the help page to our tex file, the autocmd will be triggered and the vim-latex mappings are again overwritten.&#xA;This really ensures that the AutoClose--Alves mappings are always available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are back at square 1.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Final answer: use a different auto-close plugin or patch AutoClose--Alves&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A &quot;good plugin&quot; should actually inform the user about situations where mappings are overwritten by using the vim feature &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap-%3Cunique%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;map-&amp;lt;unique&amp;gt;&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way the plugin AutoClose--Alves is written it is not meant to be disabled for certain filetypes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possibility is to modify AutoClose--Alves itself to allow for an option which does not enable it for certain filetypes (see my second answer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there are other plugins which have a similar feature set but IMHO are better vim plugin citizens which is why I recommend to use a different plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the plugins&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Raimondi/delimitMate&quot; rel=&quot;nofollow noreferrer&quot;&gt;delimitMate&lt;/a&gt;&#xA;and&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tmsvg/pear-tree&quot; rel=&quot;nofollow noreferrer&quot;&gt;pear-tree&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;have as well toggle functions but which actually unmap their own mappings. The remaining problem of the&#xA;first answer can here be resolved as the OP has done in the question:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup Myftevents&#xA;  autocmd!&#xA;  autocmd Filetype tex DelimitMateOff&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Btw, incompatibility between AutoClose--Alves and vim-latex has already been reported:&#xA;&lt;a href=&quot;https://github.com/Townk/vim-autoclose/issues/82&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Townk/vim-autoclose/issues/82&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-03-23T14:30:01.033" LastActivityDate="2019-03-23T14:30:01.033" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19287" PostTypeId="2" ParentId="19276" CreationDate="2019-03-23T09:22:07.347" Score="8" Body="&lt;p&gt;Put the following in &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup custom_term&#xA;    autocmd!&#xA;    autocmd TermOpen * setlocal bufhidden=hide&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know if it's enough, but it is working for now. Check the part with &lt;code&gt;bufhidden=hide&lt;/code&gt;, this makes only the terminal buffer &lt;code&gt;hidden&lt;/code&gt; when not loaded on any split/window. I don't know if I have to change any other options like &lt;code&gt;:h buflisted&lt;/code&gt; or &lt;code&gt;:h buftype&lt;/code&gt; and thus leaving this post open for anyone to comment.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-03-23T09:22:07.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19288" PostTypeId="1" CreationDate="2019-03-23T10:14:20.747" Score="2" ViewCount="4854" Body="&lt;p&gt;I want to make toggleable window with terminal buffer similar to every IDE terminal feature.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Currently i have mapped:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F4&amp;gt; :botright 8split term://bash&amp;lt;CR&amp;gt;&#xA;tnoremap &amp;lt;F4&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;:q&amp;lt;CR&amp;gt;&#xA;autocmd BufEnter term://* startinsert | set wfh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but buffer is lost whenever is not active on any window (ex. on :q)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;EDIT&#xA;And how to reopen the same buffer whenever it already eixsts instead of creating new one every time?&lt;/p&gt;&#xA;" OwnerUserId="8444" LastEditorUserId="8444" LastEditDate="2019-03-23T10:34:36.203" LastActivityDate="2022-11-09T21:47:09.500" Title="How to hide terminal buffer without closing it?" Tags="|neovim|terminal|terminal-buffer|" AnswerCount="2" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19289" PostTypeId="2" ParentId="19285" CreationDate="2019-03-23T11:13:32.170" Score="0" Body="&lt;h3&gt;Patch AutoClose--alves to skip setup for selected filetypes&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;❯ git diff&#xA;diff --git a/plugin/AutoClose.vim b/plugin/AutoClose.vim&#xA;index d91ba8b..218206b 100644&#xA;--- a/plugin/AutoClose.vim&#xA;+++ b/plugin/AutoClose.vim&#xA;@@ -482,6 +482,9 @@ endfunction&#xA;&#xA; function! s:CreateMaps()&#xA;     silent doautocmd FileType&#xA;+    if index(exists(&quot;g:autoclose_blacklist&quot;)? g:autoclose_blacklist : [], &amp;amp;ft) &amp;gt;= 0&#xA;+        return&#xA;+    endif&#xA;     call s:DefineVariables()&#xA;     call s:CreatePairsMaps()&#xA;     call s:CreateExtraMaps()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add to your vimrc to skip 'tex' files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:autoclose_blacklist = ['tex']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now Autoclose--alves should NOT create its mappings in tex files but in all other file types.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-03-23T11:13:32.170" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19290" PostTypeId="1" CreationDate="2019-03-23T11:17:27.610" Score="1" ViewCount="434" Body="&lt;p&gt;I am trying to handle events of nvim using nvim_subscribe() API via RPC. For instance, calling nvim_subscribe('CmdLineEnter').&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure the specification of this API exactly, but I imagine that the notification will be call back to the client when the 'CmdLineEnter' event occurs in nvim.&#xA;Is my understanding correct?&lt;/p&gt;&#xA;" OwnerUserId="19984" LastActivityDate="2021-08-10T08:07:20.677" Title="How to subscribe event by using nvim_subscribe" Tags="|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19291" PostTypeId="1" AcceptedAnswerId="19294" CreationDate="2019-03-23T16:13:25.263" Score="-2" ViewCount="593" Body="&lt;p&gt;I know its a simple one, but I've had no luck finding it so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I known A, brings you to the end of a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would like to jump to and, insert after the second last character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&#xA;My name is Joh|n&lt;/p&gt;&#xA;" OwnerUserId="21481" LastEditorUserId="21481" LastEditDate="2019-03-24T18:50:32.303" LastActivityDate="2019-03-24T18:50:32.303" Title="How to go to before last character in a line?" Tags="|navigation|" AnswerCount="1" CommentCount="2" ClosedDate="2019-03-26T14:31:56.657" ContentLicense="CC BY-SA 4.0" />
  <row Id="19292" PostTypeId="1" AcceptedAnswerId="19678" CreationDate="2019-03-23T16:44:34.920" Score="8" ViewCount="546" Body="&lt;p&gt;Vim has the commands &lt;code&gt;zg&lt;/code&gt; and &lt;code&gt;zw&lt;/code&gt; to mark a word as good (correctly spelled) or bad (incorrectly spelled), respectively. Is there a similar command to mark a word as rarely-used?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(It’s possible to manually append the word plus &lt;code&gt;/?&lt;/code&gt; to the spell file, but this is a lot less convenient than just putting the cursor on the word and typing a couple of keys.)&lt;/p&gt;&#xA;" OwnerUserId="671" LastActivityDate="2019-08-11T21:15:50.977" Title="How do I mark a word as rare?" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19294" PostTypeId="2" ParentId="19291" CreationDate="2019-03-23T18:11:19.303" Score="1" Body="&lt;p&gt;If you mean insert before last character: &lt;code&gt;$i&lt;/code&gt; (not repeatable like &lt;code&gt;A&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you mean just to go to the second to last character: &lt;code&gt;$h&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-23T18:11:19.303" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19297" PostTypeId="1" AcceptedAnswerId="19302" CreationDate="2019-03-23T21:31:17.360" Score="0" ViewCount="102" Body="&lt;p&gt;If I want to map a key to a certain command and I don't want the command to echo in the command line, I can do the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;N &amp;lt;... command ...&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But can the same be done with abbreviations? I didn't see anything relating to this in the manual, so I was wondering if it's even possible to prevent the abbreviation command from appearing in the command line.&lt;/p&gt;&#xA;" OwnerUserId="21269" LastActivityDate="2019-03-24T05:01:16.137" Title="Prevent abbreviations from echoing on the command line" Tags="|key-bindings|abbreviations|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19298" PostTypeId="1" AcceptedAnswerId="19303" CreationDate="2019-03-23T23:06:18.537" Score="1" ViewCount="1260" Body="&lt;p&gt;I have the ale linter installed. it works fine for my php files but for some reason when I started doing typescript, it keeps on giving me these error&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XC56S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XC56S.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with the error message&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;indent: space indentation expected&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried all the options listed in the ale &lt;a href=&quot;https://github.com/w0rp/ale#faq-disable-linters&quot; rel=&quot;nofollow noreferrer&quot;&gt;docs&lt;/a&gt;, but the only thing that seems to work is when i just shut it off entirely by putting this in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_linters_explicit = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do one of the following two:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) turn it on just for php &#xA;(I tried doing this but it didn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_linters = {&#xA;\   'php': ['eslint'],&#xA;\}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2) make it actually work for typescript without all these errors (it seems all the files are full of errors)&lt;/p&gt;&#xA;" OwnerUserId="14510" LastActivityDate="2019-03-24T08:16:45.120" Title="How to turn on ale linter for specific files" Tags="|plugin-ale|eslint|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19299" PostTypeId="1" AcceptedAnswerId="19301" CreationDate="2019-03-23T23:09:36.777" Score="2" ViewCount="201" Body="&lt;p&gt;Is there any way to have a digit group separator for line numbers in &lt;code&gt;vim&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e., if I am on line &lt;code&gt;1234567&lt;/code&gt; it would become &lt;code&gt;1,234,567&lt;/code&gt;, where &lt;code&gt;,&lt;/code&gt; is a delimiter.&lt;/p&gt;&#xA;" OwnerUserId="21487" LastActivityDate="2019-03-24T04:10:00.297" Title="vim line number digit group separator" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19300" PostTypeId="2" ParentId="19290" CreationDate="2019-03-24T01:57:49.530" Score="1" Body="&lt;p&gt;I found a solution to subscribe to events.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First monitor the event you want to subscribe with autocmd, and emit the event I defined myself by using rpcnotify().&#xA;For instance, define an autocmd in init.vim as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CmdLineEnter * call rpcnotify(0, 'mymethod')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or define it by nvim_command(&lt;code&gt;above autocmd&lt;/code&gt;) via RPC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, after execute &lt;code&gt;nvim_subscribe('mymethod')&lt;/code&gt;, nvim notifies &lt;code&gt;mymethod&lt;/code&gt; event to the client via RPC whenever CmdLineEnter event happens.&lt;/p&gt;&#xA;" OwnerUserId="19984" LastActivityDate="2019-03-24T01:57:49.530" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19301" PostTypeId="2" ParentId="19299" CreationDate="2019-03-24T04:10:00.297" Score="4" Body="&lt;p&gt;No, this is all hard-coded; see &lt;code&gt;screen.c&lt;/code&gt;, line 3893:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *fmt = &quot;%*ld &quot;;&#xA;&#xA;[..]&#xA;&#xA;sprintf((char *)extra, fmt, number_width(wp), num);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the only way to get what you want is to modify this code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry :-(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/3516/51&quot;&gt;Related&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-03-24T04:10:00.297" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19302" PostTypeId="2" ParentId="19297" CreationDate="2019-03-24T05:01:16.137" Score="0" Body="&lt;p&gt;I managed to get an &lt;code&gt;abbrev&lt;/code&gt; command to work without displaying it in the command line by wrapping it into a &lt;code&gt;silent execute &quot;normal! &amp;lt; iabbrev command here &amp;gt;&quot;&lt;/code&gt;. Without &lt;code&gt;silent&lt;/code&gt;, the command passed to &lt;code&gt;normal!&lt;/code&gt; will display in the command line, but by putting it into &lt;code&gt;silent&lt;/code&gt; prevents  any messages from appearing in message history.&lt;/p&gt;&#xA;" OwnerUserId="21269" LastActivityDate="2019-03-24T05:01:16.137" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19303" PostTypeId="2" ParentId="19298" CreationDate="2019-03-24T08:16:45.120" Score="1" Body="&lt;p&gt;1) didn't work because eslint is a typescript linter, you should pick a php linter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2)indent is not a an error, take a look at ale option of your linter, it can be turned off most of the time.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-03-24T08:16:45.120" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19304" PostTypeId="1" CreationDate="2019-03-24T12:14:11.077" Score="0" ViewCount="573" Body="&lt;p&gt;I see three sets of options for terminal colors on the vim documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first set of options:   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t_AB    set background color (ANSI)         *t_AB* *'t_AB'*&#xA;t_AF    set foreground color (ANSI)         *t_AF* *'t_AF'*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second set of options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t_Sb    set background color                *t_Sb* *'t_Sb'*&#xA;t_Sf    set foreground color                *t_Sf* *'t_Sf'*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The third set of options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t_RF    request terminal foreground color       *t_RF* *'t_RF'*&#xA;t_RB    request terminal background color       *t_RB* *'t_RB'*&#xA;t_8f    set foreground color (R, G, B)          *t_8f* *'t_8f'*&#xA;t_8b    set background color (R, G, B)          *t_8b* *'t_8b'*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am somewhat puzzled. Why are there three sets of options, what is the difference between them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use vim in a terminal that  its type is &lt;code&gt;linux&lt;/code&gt;. If I want to set the background color of vim in the terminal, which set of options should I use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw the value of the &lt;code&gt;t_AB&lt;/code&gt; option by using the &quot;&lt;code&gt;set termcap&lt;/code&gt;&quot; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; t_AB=^[[4%p1%dm &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does &quot;&lt;code&gt;^[[4%p1%dm&lt;/code&gt;&quot; mean?  What color does it represent?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the xshell emulation terminal, and its current color scheme is set to &quot;New black&quot;, the background color of this color scheme uses a &lt;code&gt;dark gray&lt;/code&gt; instead of &lt;code&gt;black&lt;/code&gt;. My vim color theme file is my_black.vim , the background color of the vimc window is set to &lt;code&gt;black&lt;/code&gt; in my_black.vim ; the code is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=dark&#xA;hi Normal    ctermfg=119 ctermbg=Black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open the vim window in the xshell terminal, the background color of the vim window is &lt;code&gt;dark gray&lt;/code&gt; rather than  &lt;code&gt;black&lt;/code&gt; that i configured in my_black.vim . The &lt;code&gt;dark gray&lt;/code&gt; is  the background color of the xshell color theme configuration. The xshell also supports other color schemes: &quot;ANISI colors onBlack&quot;,&quot;Pastel on black&quot;; The background color of the screens background configured in these color schemes is &lt;code&gt;black&lt;/code&gt;, and my color theme file: my_black.vim works fine in these color schemes, but only &quot;New black&quot; does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope that my vim color theme file is valid in any color configuration scheme of any terminal program, and is not interfered by the color configuration of the terminal program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore,I have an idea: first I go to get the background color of the current terminal screen  by using the value of &lt;code&gt;t_AB&lt;/code&gt; or &lt;code&gt;t_Sb&lt;/code&gt; or &lt;code&gt;t_8b&lt;/code&gt; option in vimrc, and then customize my vim color theme configuration based on the value of &lt;code&gt;t_AB&lt;/code&gt; or &lt;code&gt;t_Sb&lt;/code&gt; or &lt;code&gt;t_8b&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;how does set a value to &lt;code&gt;t_AB&lt;/code&gt; or &lt;code&gt;t_Sb&lt;/code&gt; or &lt;code&gt;t_8b&lt;/code&gt; option? What should I do ? &lt;/p&gt;&#xA;" OwnerUserId="20589" LastEditorUserId="20589" LastEditDate="2019-03-25T04:15:44.250" LastActivityDate="2019-03-25T04:15:44.250" Title="how does t_AB and t_Sb option difference in vim?" Tags="|vimscript|terminal|options|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19307" PostTypeId="1" AcceptedAnswerId="19309" CreationDate="2019-03-25T03:37:36.280" Score="0" ViewCount="43" Body="&lt;p&gt;I added two normal mode mappings so that the cursor doesn't move when changing case&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gUiw m0gUiw`0&#xA;nnoremap guiw m0guiw`0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Recently I had to uppercase a word and I tried like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;maintenance&amp;lt;C-o&amp;gt;gUiw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which turned into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;maintenanceguiw`0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, there is something conflicting between normal mode mapping and &lt;code&gt;:h i_CTRL-O&lt;/code&gt; workflow. What is it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt; I'm running NVIM v0.4.0-dev&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-25T03:58:32.703" LastActivityDate="2019-03-25T07:15:41.337" Title="nnoremap conflicts with i_CTRL-O" Tags="|key-bindings|neovim|insert-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19308" PostTypeId="1" CreationDate="2019-03-25T04:56:54.390" Score="0" ViewCount="91" Body="&lt;p&gt;Sometimes I need to use a literal tab that isn't in a leading position (for instance in a Makefile or occasionally in a shell script). It would be nice if tabs in those contexts were displayed in a fixed-width way instead of having a width that depends on the locations of tab stops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;code&gt;set list&lt;/code&gt; and &lt;code&gt;set listchars=&lt;/code&gt;, then all tabs show up as &lt;code&gt;^I&lt;/code&gt;, a literal representation of the tab byte. I'm not sure whether &lt;code&gt;vim&lt;/code&gt; itself or the terminal emulator is responsible for displaying tabs this way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to show all non-leading tabs and only non-leading tabs as &lt;code&gt;^I&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to make the behavior of the tab character dependent on where the tab character is within the line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for instance &lt;code&gt;set listchars=tab:12&lt;/code&gt;, will make tabs display the same way regardless of whether they appear as part of the leading indentation of the line or somewhere in the &quot;middle&quot; of the line, namely the first character corresponding to the tab will be &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;2&lt;/code&gt;s will be used to pad to the tab stop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, &lt;code&gt;&quot;\t\ta\tb\tc&quot;&lt;/code&gt; is displayed as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1222222212222222a1222222b1222222c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if there's a way to direct vim to display the first two tabs differently from the last two. I'd &quot;\t\ta\tb\tc&quot; to be displayed as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1222222212222222a^Ib^Ic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2019-03-25T05:15:31.097" LastActivityDate="2019-03-25T05:15:31.097" Title="show non-leading tabs as ^I" Tags="|listchars|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19309" PostTypeId="2" ParentId="19307" CreationDate="2019-03-25T07:15:41.337" Score="3" Body="&lt;p&gt;&lt;code&gt;i_CTRL-O&lt;/code&gt; allows one command to be executed before returning to insert mode. With your mapping the first command is setting the mark 0 (&lt;code&gt;m0&lt;/code&gt;). After that was executed, Vim returns to insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution would be a insert mode mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;C-G&amp;gt;Uiw &amp;lt;C-C&amp;gt;m0gUiw`0a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-25T07:15:41.337" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19310" PostTypeId="2" ParentId="19277" CreationDate="2019-03-25T07:58:41.277" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can it be written?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Possibly, but it might be a lot harder than expected. Because, what do you do with commands that close the current window? Or commands, that add lines above the current cursor position?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One problem you are running into is described unter &lt;a href=&quot;https://vimhelp.org/eval.txt.html#function-search-undo&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h function-search-undo&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The last used search pattern and the redo command &quot;.&quot;&#xA;will not be changed by the function.  This also&#xA;implies that the effect of :nohlsearch is undone&#xA;when the function returns.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only way I know to circumvent this is to make use of using &lt;code&gt;feedkeys()&lt;/code&gt;, but apparently, this does not work with the &lt;code&gt;x&lt;/code&gt; flag, you have given to the feedkeys command (and I am not actually sure this is needed here). So using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call feedkeys(':'.a:qargs.&quot;\&amp;lt;cr&amp;gt;&quot;, 'imt')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and your example starts to work (well, almost). However, if you start using this, you'll notice the cursor position will be off, despite the fact, that &lt;code&gt;winrestview()&lt;/code&gt; should have restored the cursor position. I think this happens, because the &lt;code&gt;feedkeys()&lt;/code&gt; call will insert the command after the current command is executed, e.g. &lt;strong&gt;after&lt;/strong&gt; the function &lt;code&gt;s:keepcursor()&lt;/code&gt; returns. I dont' know a way around this (well, perhaps a workaround would be to try to make use of timers, but I consider this ugly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, there is also &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=3800&quot; rel=&quot;nofollow noreferrer&quot;&gt;this script&lt;/a&gt; that implements a &lt;code&gt;:KeepView&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-03-25T07:58:41.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19311" PostTypeId="2" ParentId="18911" CreationDate="2019-03-25T08:34:51.593" Score="1" Body="&lt;p&gt;Well the problem initially was in the fact that due to some issues git repo files cloned in Ubuntu subsystem wasn't visible to Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second thing: paths should be &lt;code&gt;HOME/vimfiles&lt;/code&gt; and &lt;code&gt;HOME/.vimrc&lt;/code&gt;. At least this worked for me.&lt;/p&gt;&#xA;" OwnerUserId="1860" LastActivityDate="2019-03-25T08:34:51.593" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19313" PostTypeId="1" CreationDate="2019-03-25T10:49:28.033" Score="1" ViewCount="81" Body="&lt;p&gt;(Windows7-64bits-Vim8.1)&#xA;I have a problem with getting the python in Vim to work. This problem is probably caused because I do not have admin access to the machine; I can't help that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to narrow down the problem, I got it down to a one line cmd script that does work when double clicked, but not when started from DOS.&#xA;The script is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;path to my home&amp;gt;\bin\Vim\vim81\gvim.exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I start this by double clicking, I get a perfectly fine gvim window, and it allows me to say&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py3 print(&quot;Hello&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I start the very same file from DOS, it doesn't work: the same command :py print(&quot;Hello&quot;) gives E370 and E263.&#xA;The same works for every other way I could think of to start vim from DOS: starting from different directories, using start, using cmd, even using it with %edit in IPython.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked all environment variables, I checked the startup sequence of Vim, but I cannot see any difference. Except for the fact that Python3 works in only one of the cases.&#xA;By the way: my _vimrc (which is run in both cases) does modify pythonthreedll to the proper value, because I cannot get python in the registry.&#xA;What is going on? I am getting mad...&lt;/p&gt;&#xA;" OwnerUserId="21498" LastEditorUserId="1292" LastEditDate="2019-03-25T18:47:01.103" LastActivityDate="2019-03-25T18:47:01.103" Title="Why does vim work if command file is double clicked, but not from DOS?" Tags="|microsoft-windows|vimscript-python|cmdline|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19314" PostTypeId="1" AcceptedAnswerId="19315" CreationDate="2019-03-25T10:55:39.287" Score="2" ViewCount="308" Body="&lt;p&gt;I just accidentally deleted an important file in &lt;code&gt;:Ex&lt;/code&gt; (I thought I was still typing a search string and hit &lt;code&gt;Shift+D&lt;/code&gt; and then &lt;code&gt;Enter&lt;/code&gt; immediately).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I unmap this entirely to avoid this (stupid and not very likely, but still annoying) risk in the future?&lt;/p&gt;&#xA;" OwnerUserId="21500" LastActivityDate="2019-03-25T11:09:24.213" Title="Unmap &quot;delete file&quot; in Explore mode" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19315" PostTypeId="2" ParentId="19314" CreationDate="2019-03-25T11:09:24.213" Score="3" Body="&lt;p&gt;You will need to unmap &lt;code&gt;D&lt;/code&gt; only for the filetype &lt;code&gt;netrw&lt;/code&gt; to do that you can create the file &lt;code&gt;~/.vim/after/ftplugin/netrw.vim&lt;/code&gt; and inside put the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Avoid unwanted file deletions with D&#xA;unmap &amp;lt;buffer&amp;gt; D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you should be good to go, &lt;code&gt;D&lt;/code&gt; will not do the suppression anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does it work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#ftplugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ftplugin&lt;/code&gt;&lt;/a&gt;, the idea is to create a file which will be sourced when the filetype of a buffer is set to &lt;code&gt;netrw&lt;/code&gt; but &lt;em&gt;after&lt;/em&gt; the Netrw plugin did it's own configurations so that you can override them. Note that instead you can probably use an autocommand, but I think it would be pretty redundant since that would be not using the built-in Vim mechanisms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; parameter to the &lt;code&gt;unmap&lt;/code&gt; command is necessary because Netrw remaps &lt;code&gt;D&lt;/code&gt; only in its own buffers.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-03-25T11:09:24.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19316" PostTypeId="1" AcceptedAnswerId="19317" CreationDate="2019-03-25T12:17:59.647" Score="2" ViewCount="2354" Body="&lt;p&gt;Hello I am a pretty new user to vim, and am using nvim with ayu theme. The tabs dont look that great so I decided to edit the &lt;code&gt;ayu.vim&lt;/code&gt;, and so far I changed the TabLineFill property to fit my preferences, however the color of the unselected tab is something I don't know how to change, so which property should I change for unselected tabs?&lt;/p&gt;&#xA;" OwnerUserId="21501" LastActivityDate="2019-03-25T12:53:49.410" Title="How to change color of unselected tab?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19317" PostTypeId="2" ParentId="19316" CreationDate="2019-03-25T12:53:49.410" Score="8" Body="&lt;p&gt;The available highlight groups for tabpage line (see &lt;code&gt;:h tabpage&lt;/code&gt;) are the following :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TabLine     tab pages line, not active tab page label&#xA;TabLineFill tab pages line, where there are no labels&#xA;TabLineSel  tab pages line, active tab page label&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h hl-Tabline&lt;/code&gt;, &lt;code&gt;:h TabLineFill&lt;/code&gt; and &lt;code&gt;:h TabLineSel&lt;/code&gt; for documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the &lt;strong&gt;highlight group of the unselected tabpage line tab&lt;/strong&gt; would be &lt;code&gt;TabLine&lt;/code&gt; whose colors can be configured as in the following (see &lt;code&gt;:h :highlight&lt;/code&gt; for more info) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi TabLine    gui=NONE guibg=#3e4452 guifg=#abb2bf    cterm=NONE term=NONE ctermfg=black ctermbg=white&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here all parts with keyword &lt;code&gt;gui&lt;/code&gt; will work for terminal emulators with true color support and if &lt;code&gt;:h termguicolors&lt;/code&gt; has been enabled. See, &lt;code&gt;:h cterm-colors&lt;/code&gt; and &lt;code&gt;:h gui-colors&lt;/code&gt; for more details on them.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-03-25T12:53:49.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19318" PostTypeId="1" AcceptedAnswerId="19336" CreationDate="2019-03-25T13:22:13.293" Score="2" ViewCount="1862" Body="&lt;p&gt;I've been trying to set up spell checking in neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;init.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal spell spelllang=ru_ru&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First time it downloaded &lt;code&gt;ru.utf-8.spl&lt;/code&gt; and &lt;code&gt;ru.utf-8.sug&lt;/code&gt;, just as it probably should. Unfortunately, as soon as I try &lt;code&gt;:set spell/invspell&lt;/code&gt;, all the Russian words get highlighted. What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPD:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;English spell checking won't work, too (everything misspelled). The files are here &lt;code&gt;/usr/share/nvim/runtime/spell/en.utf-8.spl&lt;/code&gt; which looks OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPD:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;English spell checking started to work, I am not sure why (I tried &lt;code&gt;spelllang=ru_ru,en_us&lt;/code&gt;; Russian won't work even as a single option.&lt;/p&gt;&#xA;" OwnerUserId="21503" LastEditorUserId="21503" LastEditDate="2019-03-25T14:34:02.520" LastActivityDate="2019-03-27T08:35:30.710" Title="Neovim spellcheck: all the words highlighted as misspelled" Tags="|neovim|spell-checking|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19319" PostTypeId="1" AcceptedAnswerId="19320" CreationDate="2019-03-25T16:21:17.773" Score="1" ViewCount="672" Body="&lt;p&gt;can anyone give me an example of how &lt;code&gt;!!&lt;/code&gt; works? The documentation says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!!{filter}      Filter [count] lines through the external program {filter}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21157" LastActivityDate="2020-06-12T20:13:17.443" Title="What is &quot;!!&quot; filter used for?" Tags="|filter|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19320" PostTypeId="2" ParentId="19319" CreationDate="2019-03-25T16:34:05.143" Score="7" Body="&lt;p&gt;&lt;code&gt;!!&lt;/code&gt; (and more generally the &lt;code&gt;!&lt;/code&gt; operator) provides vim builtin support for all the unix filters that have evolved over the ages: this includes &lt;code&gt;cut&lt;/code&gt;, &lt;code&gt;paste&lt;/code&gt;, &lt;code&gt;sort&lt;/code&gt;, &lt;code&gt;uniq&lt;/code&gt;, &lt;code&gt;awk&lt;/code&gt;, &lt;code&gt;sed&lt;/code&gt;, even &lt;code&gt;bash&lt;/code&gt;. Basically a filter is anything that can transform stdin to stdout (possibly doing something meaningful—the identity filter is just &lt;code&gt;cat&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By providing access to these tools, vim avoids re-inventing them and allows you to combine them however you see fit. Table editing, cleaning a csv file, even interpreting lines of a shell script on the fly... the possibilities are about as limitless as the construction of *nix pipelines.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For a concrete example, type &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo Hello World&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a new file, then &lt;code&gt;!!sh -&lt;/code&gt; and hit enter (I think I have that syntax right).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://vi.stackexchange.com/a/18997/10604&quot;&gt;this answer of mine&lt;/a&gt; for more complex techniques.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-06-12T20:13:17.443" LastActivityDate="2020-06-12T20:13:17.443" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19321" PostTypeId="2" ParentId="19319" CreationDate="2019-03-25T16:36:36.327" Score="3" Body="&lt;p&gt;A classic example for this filter is to sort the input using the Shell command &lt;code&gt;sort&lt;/code&gt;. So vi does not have to implement its own sorting algorithm but could plugin external commands to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nowadays, Vim comes with its own sort implementation as &lt;code&gt;:sort&lt;/code&gt; command, mainly because some systems did not provide a sort binary.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-03-25T16:36:36.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19322" PostTypeId="1" CreationDate="2019-03-25T21:01:02.470" Score="1" ViewCount="174" Body="&lt;p&gt;I'd like to be able to get the contents of a register in &lt;code&gt;nvi&lt;/code&gt;, such as using&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;b&quot;wye&lt;/code&gt; to yank a word into the &lt;code&gt;w&lt;/code&gt; register and then invoke a shell command with the current word in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I have this command for running ripgrep (&lt;code&gt;rg&lt;/code&gt;), but it's less than ideal in a number of ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It basically creates a new line below the current one with an &lt;code&gt;ex&lt;/code&gt; command that runs the shell, deletes the new line into the &lt;code&gt;w&lt;/code&gt; register and then runs the register via &lt;code&gt;@&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; run ripgrep&#xA;map ^R mpb&quot;wyeo^[&quot;wpI:!rg --color=always ^[A ^V| less -R^[&quot;wdd`p@w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideally, is there a way to refer to the contents of a register while typing out an ex command (similar to how &lt;code&gt;&amp;lt;c-r&amp;gt;w&lt;/code&gt; would work in &lt;code&gt;vim&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, is there a way to write arbitrary content to a register without touching the file you are currently visiting?&lt;/p&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2019-04-07T04:30:16.760" LastActivityDate="2019-04-07T04:30:16.760" Title="`nvi` use contents of register in ex command" Tags="|nvi|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19323" PostTypeId="1" AcceptedAnswerId="19325" CreationDate="2019-03-26T02:48:11.093" Score="1" ViewCount="589" Body="&lt;p&gt;I'm writting a complete script, and when the function is triggered in i mode, I need to delete the word under the cursor and call the function &lt;code&gt;complete&lt;/code&gt; to put new words. I only know to delete the origin word by &lt;code&gt;&amp;lt;backspace&amp;gt;&lt;/code&gt;. Is there a good way to delete the word in i mode?&lt;/p&gt;&#xA;" OwnerUserId="21438" LastActivityDate="2019-03-26T13:17:46.593" Title="How to write a vimscript to replace the word under cursor in i mode?" Tags="|vimscript|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19324" PostTypeId="2" ParentId="19323" CreationDate="2019-03-26T05:58:36.450" Score="2" Body="&lt;p&gt;Although you can use c-w in i mode to delete until start of current word, it's much more convenient to switch to normal mode to change the entire word.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;leader&amp;gt;c &amp;lt;c-o&amp;gt;diw&amp;lt;c-r&amp;gt;=complete()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-03-26T07:06:51.033" LastActivityDate="2019-03-26T07:06:51.033" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19325" PostTypeId="2" ParentId="19323" CreationDate="2019-03-26T06:56:36.447" Score="4" Body="&lt;p&gt;&lt;code&gt;complete({startcol}, {matches})&lt;/code&gt; provides the function to replace the old word. You can use &lt;code&gt;complete(col(&quot;.&quot;) - ${length}, {matches})&lt;/code&gt; to replace the old word, &lt;code&gt;${length}&lt;/code&gt; is the length of your old word.&lt;/p&gt;&#xA;" OwnerUserId="21515" LastActivityDate="2019-03-26T06:56:36.447" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19326" PostTypeId="1" AcceptedAnswerId="19327" CreationDate="2019-03-26T10:59:30.230" Score="1" ViewCount="1730" Body="&lt;p&gt;VIM doesn't conceal text, for example tex. Here's my vimrc: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;commands for vim-plug &#xA;&quot;PlugInstall - installs plugs  &#xA;&quot;PlugUpdate - updates plugs &#xA;&quot;PlugClean - remove unused directories &#xA;&quot;PlugUpgrade - upgrades vim-plug itself &#xA;&quot;PlugStatus - status of plugs&#xA;&quot;vim-plug installer&#xA;&#xA;if empty(glob('~/.vim/autoload/plug.vim'))&#xA;    silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs&#xA;        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;        autocmd VimEnter * PlugInstall --sync | source $MYVIMRC&#xA;    endif&#xA;&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'itchyny/lightline.vim' &quot;lightline&#xA;Plug 'altercation/vim-colors-solarized' &quot;solarized theme&#xA;Plug 'scrooloose/nerdtree' &quot;NERDTree&#xA;Plug 'scrooloose/nerdcommenter' &quot;NerdCommenter&#xA;Plug 'majutsushi/tagbar' &quot;tagbar&#xA;Plug 'lervag/vimtex' &quot;for latex &#xA;&#xA;call plug#end()&#xA;&#xA;set encoding=utf-8&#xA;&#xA;&quot;settings for lightline &#xA;set laststatus=2 &quot;displays lightline&#xA;set noshowmode &quot;vim's mode is not show belove lightline &#xA;&#xA;&quot;changes colorscheme&#xA;let g:lightline = { &#xA;    \ 'colorscheme': 'solarized', &#xA;    \}&#xA;&#xA;&quot;settings for colorscheme &#xA;&quot;after installing&#xA;&quot;$ cd vim-colors-solarized/colors&#xA;&quot;$ mv solarized.vim ~/.vim/colors/&#xA;colorscheme solarized&#xA;set background=dark &#xA;&#xA;&quot;settings for NERDTree&#xA;&quot;autocmd vimenter * NERDTree &quot;opening NERDTree with every vim start&#xA;nmap &amp;lt;F8&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;autocmd bufenter * if (winnr(&quot;$&quot;) == 1 &amp;amp;&amp;amp; exists(&quot;b:NERDTree&quot;) &amp;amp;&amp;amp; b:NERDTree.isTabTree()) | q | endif &quot;closing NerdTree i&#xA;&#xA;nmap &amp;lt;F9&amp;gt; :TagbarToggle&amp;lt;CR&amp;gt;&#xA;&#xA;let g:tex_flavor='latex'&#xA;let g:vimtex_view_method='zathura'&#xA;set conceallevel=2&#xA;let g:tex_conceal='abdmg'&#xA;&quot;-------------------------------------------------------------------------------------------------------------&#xA;&quot;                                             no-plug setup &#xA;&quot;-------------------------------------------------------------------------------------------------------------&#xA;&#xA;&quot;split navigation CTRL + H/J/K/L&#xA;nnoremap &amp;lt;C-J&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-J&amp;gt; &#xA;nnoremap &amp;lt;C-K&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-K&amp;gt;&#xA;nnoremap &amp;lt;C-L&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-L&amp;gt;&#xA;nnoremap &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-H&amp;gt;&#xA;&#xA;syntax enable &#xA;set tabstop=4 &quot;number of visual spaces per TAB &#xA;set shiftwidth=4&#xA;set softtabstop=4 &quot;number of spaces in TAB when editing &#xA;set expandtab &quot; TABs are spaces &#xA;filetype indent on &#xA;filetype plugin on&#xA;autocmd FileType cpp setlocal commentstring=//%s&#xA;set showmatch &#xA;set splitbelow&#xA;set splitright&#xA;set lazyredraw&#xA;set wildmenu&#xA;&#xA;set hlsearch&#xA;set incsearch&#xA;nmap &amp;lt;silent&amp;gt; ,/ :nohlsearch&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; space open/closes folds&#xA;nnoremap &amp;lt;space&amp;gt; za&#xA;&#xA;set foldmethod=manual&#xA;augroup remember_folds&#xA;    autocmd!&#xA;    autocmd BufWinLeave * mkview&#xA;    autocmd BufWinEnter * silent! loadview&#xA;augroup END&#xA;&#xA;&quot;line numbers&#xA;set number relativenumber&#xA;&#xA;augroup numbertoggle&#xA;autocmd!&#xA;autocmd BufEnter,FocusGained,InsertLeave * set relativenumber&#xA;autocmd BufLeave,FocusLost,InsertEnter   * set norelativenumber&#xA;augroup END&#xA;&#xA;&quot;it's finnaly time to learn hjkl&#xA;map &amp;lt;up&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;down&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;left&amp;gt; &amp;lt;nop&amp;gt;&#xA;map &amp;lt;right&amp;gt; &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;khzaw/vim-conceal&lt;/code&gt; conceal works in python. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;any ideas?&lt;/p&gt;&#xA;" OwnerUserId="21516" LastActivityDate="2019-03-26T18:58:31.153" Title="VIM conceal doesn't work" Tags="|filetype-tex|conceal|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19327" PostTypeId="2" ParentId="19326" CreationDate="2019-03-26T12:29:15.973" Score="0" Body="&lt;p&gt;You should remove augroup remember_folds commands&lt;/p&gt;&#xA;" OwnerUserId="21518" LastActivityDate="2019-03-26T12:29:15.973" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19328" PostTypeId="2" ParentId="19323" CreationDate="2019-03-26T13:17:46.593" Score="1" Body="&lt;p&gt;If &lt;code&gt;complete&lt;/code&gt; conforms to the spec of &lt;code&gt;'completefunc'&lt;/code&gt; (or can be made to, either by editing or wrapping it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set completefunc=complete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then just use &lt;code&gt;&amp;lt;C-x&amp;gt;u&lt;/code&gt; in insert mode (see &lt;code&gt;:help ins-completion&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-26T13:17:46.593" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19329" PostTypeId="1" AcceptedAnswerId="19330" CreationDate="2019-03-26T16:11:32.017" Score="1" ViewCount="1283" Body="&lt;p&gt;I'm just trying to get conceal working, so I've created a simple test case. I have a clean .vimrc file with only the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set conceallevel=2&#xA;syn match Conceal /syn/ conceal cchar=+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I initially open this file in vim, the &quot;syn&quot; is not replaced with a &quot;+&quot; (it doesn't matter which line the cursor is on). But when I do &lt;code&gt;:source %&lt;/code&gt; to reload this .vimrc, it starts working, replacing the occurrence &quot;syn&quot; with &quot;+&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have verified that this .vimrc &lt;em&gt;does&lt;/em&gt; work when vim is initially opened for other things. For example, given the following .vimrc, the word &quot;hi&quot; is highlighted in red, while the word &quot;syn&quot; remains unconcealed until I type &lt;code&gt;:source %&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set conceallevel=2&#xA;syn match Conceal /syn/ conceal cchar=+&#xA;hi Test ctermfg=red&#xA;match Test /hi/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What gives?&lt;/p&gt;&#xA;" OwnerUserId="21521" LastActivityDate="2019-03-26T16:49:19.717" Title="Conceal initially ignored" Tags="|vimrc|conceal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19330" PostTypeId="2" ParentId="19329" CreationDate="2019-03-26T16:49:19.717" Score="5" Body="&lt;p&gt;First regarding your second example: The &lt;code&gt;match Test /hi/&lt;/code&gt; is &lt;strong&gt;not&lt;/strong&gt; syntax highlighting, but &quot;match highlighting&quot;. This are two different things. The &lt;code&gt;hi&lt;/code&gt; is still highlighted after you executed &lt;code&gt;:syntax off&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the initial problem: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your initial syntax-conceal definition is deleted in the process of loading the syntax definition needed for your &lt;code&gt;.vimrc&lt;/code&gt;. While loading the syntax, Vim first removes all syntax definition active in the current buffer and replaces them with the filetype-specific definitions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you source the &lt;code&gt;.vimrc&lt;/code&gt; again, the syntax-conceal is defined again and works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to conceal the word &lt;code&gt;syn&lt;/code&gt; in vim files, create the file &lt;code&gt;$HOME/.vim/after/syntax/vim.vim&lt;/code&gt; (&lt;code&gt;$HOME/vimfiles/after/syntax/vim.vim&lt;/code&gt; on Windows) and put your definition in it. The files from the &lt;code&gt;after&lt;/code&gt; directory are loaded after Vim loaded its default configuration. So Vim first loads the default Vim syntax and after that loads your &lt;code&gt;$HOME/.vim/after/syntax/vim.vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help mysyntaxfile-add&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-26T16:49:19.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19331" PostTypeId="1" CreationDate="2019-03-26T17:54:31.787" Score="0" ViewCount="195" Body="&lt;p&gt;Like you would in virtually any application editing text.&#xA;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this is a big sentence so I can explain&#xA;^                         ^&#xA;start of selection        my cursor is here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to copy only up to the cursor but not including I.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way to do this?&lt;/p&gt;&#xA;" OwnerUserId="21527" LastEditorUserId="21527" LastEditDate="2019-03-26T18:08:40.210" LastActivityDate="2019-03-28T13:55:21.573" Title="How to copy up to the cursor without including the charater under the cursor" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19332" PostTypeId="2" ParentId="19331" CreationDate="2019-03-26T18:06:14.457" Score="1" Body="&lt;p&gt;&lt;strong&gt;Answer&lt;/strong&gt;: &lt;code&gt;y^&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim is a modal editor. That means it has specific modes for doing specific things. Most common three modes are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Normal Mode : Enter all normal editor commands (see &lt;code&gt;:h Normal-mode&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Insert Mode : Insert characters (see &lt;code&gt;:h Insert-mode&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Visual Mode : Highlight a text area to perform a normal editor comman on (see &lt;code&gt;:h Visual-mode&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But there are many other modes also. For more info, see &lt;code&gt;:h intro.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal mode, you can perform editing tasks, for example, yanking (a.k.a copying) text. You can do that by two methods:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Normal mode&lt;/strong&gt; : You need to perform &lt;code&gt;:h Operator-pending-mode&lt;/code&gt; to yank the portion of the text you want to. Vim has many text objects (see &lt;code&gt;:h motion.txt&lt;/code&gt;). You can go in operator-pending mode by issuing a command, in this case, yank (&lt;kbd&gt;y&lt;/kbd&gt;) and then specify the text object to perform the command (yank) on with suitable text objects.&lt;br&gt;&#xA;If you want to yank from the start of the line til the character under the cursor, I'd do &lt;code&gt;y^&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Visual mode&lt;/strong&gt; : You go into visual mode with &lt;kbd&gt;v&lt;/kbd&gt; and highlight the portion of the text you want to perform the yank command on, and then issue the command. I'd do &lt;code&gt;hv^y&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-28T13:55:21.573" LastActivityDate="2019-03-28T13:55:21.573" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19333" PostTypeId="2" ParentId="19326" CreationDate="2019-03-26T18:58:31.153" Score="4" Body="&lt;p&gt;The reason removing augroup remember_folds helped was given here: &lt;a href=&quot;https://github.com/vim/vim/issues/4175&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/issues/4175&lt;/a&gt;. Basically neither mkview nor loadview remember filetype nor syntax. Quick fix to that problem is modyfing those commands. The augroup remember_folds should look like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup remember_folds&#xA;    autocmd!&#xA;    autocmd BufWinLeave ?* mkview | filetype detect&#xA;    autocmd BufWinEnter ?* silent loadview | filetype detect&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21516" LastActivityDate="2019-03-26T18:58:31.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19334" PostTypeId="1" CreationDate="2019-03-26T20:08:44.153" Score="1" ViewCount="514" Body="&lt;p&gt;I have configured UltiSnips for vim as described in the documentation of UltiSnips&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Track the engine.&#xA; Plugin 'SirVer/ultisnips'&#xA;&#xA;&quot; Snippets are separated from the engine. Add this if you want them:&#xA;Plugin 'honza/vim-snippets'&#xA;&#xA;&quot; Trigger configuration. Do not use &amp;lt;tab&amp;gt; if you use &#xA; https://github.com/Valloric/YouCompleteMe.&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;c-b&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-z&amp;gt;&quot;&#xA;&#xA;&quot; If you want :UltiSnipsEdit to split your window.&#xA;let g:UltiSnipsEditSplit=&quot;vertical&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Except that I am using &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt; and the directory for the plugins is &lt;code&gt;~/.vim/bundle&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that it seems as if my snippets won't get triggered every time. I have a test snippet in my &lt;code&gt;all.snippets&lt;/code&gt; which I can't execute. But I have added another trigger in my &lt;code&gt;html.snippets&lt;/code&gt; which I can execute in html files.&#xA;I then tried to save a snippet in the &lt;code&gt;vim.snippets&lt;/code&gt; which again cannot get executed or triggered. Is there another thing I have to configure?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I have added &lt;code&gt;let g:UltiSnipsEditSplit=&quot;vertical&quot;&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt;, it just does not want to start my &lt;code&gt;/ultisnips/&amp;lt;filetype&amp;gt;.snippets&lt;/code&gt; in a vertical window it always starts in a seperate vim buffer.^&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: &lt;br&gt;&#xA;Here is my real .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/bundle')&#xA;&#xA;Plug 'honza/vim-snippets'&#xA;&#xA;Plug 'lervag/vimtex'&#xA;let g:tex_flavor='latex'&#xA;let g:vimtex_view_method='zathura'&#xA;let g:vimtex_quickfix_mode=0&#xA;set conceallevel=1&#xA;let g:tex_conceal='abdmg'&#xA;&#xA;Plug 'SirVer/ultisnips'&#xA;let g:UltiSnipsExpandTrigger='&amp;lt;tab&amp;gt;'&#xA;let g:UltiSnipsJumpForwardTrigger='&amp;lt;tab&amp;gt;'&#xA;let g:UltiSnipsJumpBackwardTrigger='&amp;lt;s-tab&amp;gt;'&#xA;let g:UltiSnipsEditSplit='vertical'&#xA;&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have created an html file and added some snippets for html files. These snippets work. Then when I try to add some snippets to my &lt;code&gt;all.snippets&lt;/code&gt; file which should be executed no matter in what kind of file I am, if I get that correctly. But this is not the case. Only one snippet file seems to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found out something about this problem:&#xA;My test html file is in &lt;code&gt;~/Projects/learn_vim/testing.html&lt;/code&gt;. When I use the &lt;code&gt;:UltiSnipsEdit&lt;/code&gt; command, it does not place the &lt;code&gt;html.snippets&lt;/code&gt; file where it is usually placing my snippet files: it placed it at this location: &lt;code&gt;~/Projects/learn_vim/UltiSnips/&lt;/code&gt;. And this file seems to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I checked it further and it actually seems like it always creates an folder in the directory I am in with the snippet files.&#xA;Could I just define one place for all my snippets? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I have found out what my &quot;vertical&quot; problem was, see my &lt;code&gt;.vimrc&lt;/code&gt; :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for the patience&lt;/p&gt;&#xA;" OwnerUserId="21493" LastEditorUserId="1292" LastEditDate="2019-03-28T07:06:17.567" LastActivityDate="2019-03-28T07:06:17.567" Title="UltiSnips not work all the time" Tags="|plugin-ultisnips|" AnswerCount="0" CommentCount="4" ClosedDate="2019-04-25T21:20:31.853" ContentLicense="CC BY-SA 4.0" />
  <row Id="19335" PostTypeId="2" ParentId="17465" CreationDate="2019-03-27T02:50:20.120" Score="2" Body="&lt;p&gt;If you want to search multi-line literal text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call search('\V' . substitute(escape(text, '\'), '\n', '\\n', 'g'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here is an operator that set up multiline literal search pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ,l  :set opfunc=&amp;lt;sid&amp;gt;search_literal&amp;lt;CR&amp;gt;g@&#xA;vnoremap ,l  :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;search_literal(visualmode(), 1)&amp;lt;cr&amp;gt;&#xA;&#xA;function! s:search_literal(type, ...) abort&#xA;&#xA;  if a:0&#xA;    silent exe &quot;normal! gvy&quot;&#xA;  elseif a:type ==# 'line'&#xA;    silent exe &quot;normal! '[V']y&quot;&#xA;  else&#xA;    silent exe &quot;normal! `[v`]y&quot;&#xA;  endif&#xA;&#xA;  let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-07-18T09:39:07.040" LastActivityDate="2019-07-18T09:39:07.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19336" PostTypeId="2" ParentId="19318" CreationDate="2019-03-27T08:35:30.710" Score="0" Body="&lt;pre&gt;&lt;code&gt;set spelllang=ru_ru,en_us&#xA;nnoremap 99 :set invspell&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This solution is reasonably convenient. A better one is welcome :)&lt;/p&gt;&#xA;" OwnerUserId="21503" LastActivityDate="2019-03-27T08:35:30.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19337" PostTypeId="1" AcceptedAnswerId="19338" CreationDate="2019-03-27T15:09:15.723" Score="4" ViewCount="1853" Body="&lt;p&gt;If the autocmd has an obvious side effect, this is not too hard to tell; but sometimes the result is more subtle and it would be nice to just see &quot;Hey, here's all the autocmds that ran on startup.&quot; I checked &lt;code&gt;:history&lt;/code&gt; but autocmds don't seem to show up there.&lt;/p&gt;&#xA;" OwnerUserId="21543" LastActivityDate="2019-03-27T15:20:37.207" Title="Is there a way to tell what autocmds have run?" Tags="|autocmd|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19338" PostTypeId="2" ParentId="19337" CreationDate="2019-03-27T15:20:37.207" Score="9" Body="&lt;p&gt;Vim's &lt;code&gt;'verbose'&lt;/code&gt; option will give you this information. Set &lt;code&gt;'verbose'&lt;/code&gt; to a large enough number to get the debug information you need.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'verbose' 'vbs'     number  (default 0)&#xA;            global&#xA;            {not in Vi, although some versions have a boolean&#xA;            verbose option}&#xA;    When bigger than zero, Vim will give messages about what it is doing.&#xA;    Currently, these messages are given:&#xA;    &amp;gt;= 1    When the viminfo file is read or written.&#xA;    &amp;gt;= 2    When a file is &quot;:source&quot;'ed.&#xA;    &amp;gt;= 5    Every searched tags file and include file.&#xA;    &amp;gt;= 8    Files for which a group of autocommands is executed.&#xA;    &amp;gt;= 9    Every executed autocommand.&#xA;    &amp;gt;= 12   Every executed function.&#xA;    &amp;gt;= 13   When an exception is thrown, caught, finished, or discarded.&#xA;    &amp;gt;= 14   Anything pending in a &quot;:finally&quot; clause.&#xA;    &amp;gt;= 15   Every executed Ex command (truncated at 200 characters).&#xA;&#xA;    This option can also be set with the &quot;-V&quot; argument.  See |-V|.&#xA;    This option is also set by the |:verbose| command.&#xA;&#xA;    When the 'verbosefile' option is set then the verbose messages are not&#xA;    displayed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since you looking into autocommand's at startup, I would suggest you launch vim with the &lt;code&gt;-V&lt;/code&gt; (&lt;code&gt;'verbose'&lt;/code&gt;) option and supply a &lt;code&gt;'verbosefile'&lt;/code&gt; to write this debug data to a file (&lt;code&gt;debug.log&lt;/code&gt;). Then promptly close vim via &lt;code&gt;+q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -V10debug.log +q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;debug.log&lt;/code&gt; will have lot's of Vim's startup information including autocommand events.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h -V&#xA;:h 'verbose'&#xA;:h 'verbosefile'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-03-27T15:20:37.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19339" PostTypeId="1" CreationDate="2019-03-27T17:42:56.783" Score="0" ViewCount="1043" Body="&lt;p&gt;This is a noob question. I just installed UltiSnip to make use of the TeX snippets. Here is the relevant part of my &lt;code&gt;init.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Specify a directory for plugins (powered by vim-plug)&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;&quot; Make sure you use single quotes&#xA; Plug 'lambdalisue/suda.vim'&#xA; Plug 'powerman/vim-plugin-ruscmd'&#xA; Plug 'tpope/vim-fugitive'&#xA; Plug 'lervag/vimtex'&#xA; Plug 'SirVer/ultisnips'&#xA; Plug 'honza/vim-snippets'&#xA; Plug 'dart-lang/dart-vim-plugin'&#xA; Plug 'natebosch/vim-lsc'&#xA;&#xA;&quot; Initialize plugin system&#xA;call plug#end()&#xA;&#xA;&quot; UltiSnips group&#xA;&quot; Trigger configuration. Do not use &amp;lt;tab&amp;gt; if you use https://github.com/Valloric/YouCompleteMe.&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;c-b&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-z&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The edited file extension is &lt;code&gt;tex&lt;/code&gt;. I presume that it's enough to write &lt;code&gt;table&lt;/code&gt; in edit mode and push . It's just a tab entered. My research shows that 'not working' is a quite common problem, but no reasonable way of troubleshooting is suggested, just obscure bits and loose ends. I tried &lt;code&gt;let g:UltiSnipsSnippetDirectories=[&quot;UltiSnips&quot;]&lt;/code&gt; and &lt;code&gt;let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/plugged/vim-snippets/UltiSnips']&lt;/code&gt;, to no avail. &lt;code&gt;:UltiSnipsAddFiletypes&lt;/code&gt; manually, the same. The docs are big on features, but way too concise on getting started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.vim&lt;/code&gt; directory is shared via symlink, no trouble so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ln -s /home/user/.vim /home/user/.local/share/nvim/site&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPD:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, sorry. It turned out that with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/plugged/vim-snippets/UltiSnips']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;em&gt;after&lt;/em&gt; manual intervention&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:UltiSnipsAddFiletypes tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it starts breathing. What am I still missing?&lt;/p&gt;&#xA;" OwnerUserId="21503" LastEditorUserId="21503" LastEditDate="2019-03-28T04:30:47.993" LastActivityDate="2019-03-28T04:30:47.993" Title="UltiSnips: snippets not expanding" Tags="|neovim|filetype-tex|plugin-ultisnips|plugin-vimtex|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19340" PostTypeId="2" ParentId="11526" CreationDate="2019-03-27T19:57:44.027" Score="2" Body="&lt;p&gt;For those using anaconda python, some additional modifications are requited. They might want to compile vim as well, especially if you want code-completion. Here is the configure command:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Modified configure command for anaconda:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ./configure --enable-terminal --enable-gui=auto \&#xA;      --with-features=huge \&#xA;      --enable-multibyte \&#xA;       --enable-cscope --enable-terminal --enable-gui=auto  \&#xA;      --prefix=/XXX/SOFTWARE/VIM8/install3 \&#xA;   --enable-python3interp \&#xA;   --with-python3-config-dir=/XXX/anaconda2/envs/py36/bin/python3.6-config \&#xA;   --includedir=/XXX/anaconda2/envs/py36/include  \&#xA;   --includedir=/XXX/anaconda2/envs/py36/include/python3.6m \&#xA;   LDFLAGS=&quot; -L/XXX/anaconda2/envs/py36/lib -L/XXX/anaconda2/envs/py36/lib/python3.6/config-3.6m-x86_64-linux-gnu&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, vim is being installed to &lt;code&gt;/XXX/SOFTWARE/VIM8/install3&lt;/code&gt; using anaconda environment for python 3.6 installed in &lt;code&gt;/XXX/anaconda2/envs/py36&lt;/code&gt;           &lt;/p&gt;&#xA;" OwnerUserId="20023" LastActivityDate="2019-03-27T19:57:44.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19341" PostTypeId="1" CreationDate="2019-03-27T20:10:02.913" Score="2" ViewCount="102" Body="&lt;p&gt;If I press &lt;code&gt;v&lt;/code&gt; while using either the &lt;code&gt;vi-mode&lt;/code&gt; zsh plugin or &lt;code&gt;set -o vi&lt;/code&gt; in bash, it opens the line I'm working on in a full vim session.  However, this puts my cursor at the beginning at the beginning of the line.  Is it possible to keep my cursor where I invoked the &lt;code&gt;v&lt;/code&gt; command?  I would like this for doing quick text manipulation that isn't possible with the basic command-line mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm referring specifically to the &lt;code&gt;vi-mode&lt;/code&gt; zsh implementation, but a bash solution would be welcome too.&lt;/p&gt;&#xA;" OwnerUserId="19428" LastActivityDate="2019-03-27T20:10:02.913" Title="Go to current cursor position when invoking command-line edit mode" Tags="|bash|command-line-window|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19342" PostTypeId="1" CreationDate="2019-03-28T00:15:19.447" Score="2" ViewCount="95" Body="&lt;p&gt;I am new to vim and was wondering if there is a way for files that have already been manually saved to be automatically saved (every few seconds). I currently make a lot of new files (for testing plugins, etc.) that I don't want to keep, and so I want this function to only apply to files I have already manually saved at least once. Thank you!&lt;/p&gt;&#xA;" OwnerUserId="21547" LastActivityDate="2019-03-28T01:29:05.757" Title="Automatically save a file that has been previously saved" Tags="|autocmd|save|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19343" PostTypeId="1" AcceptedAnswerId="19347" CreationDate="2019-03-28T00:55:20.237" Score="1" ViewCount="315" Body="&lt;p&gt;I have created a &lt;strong&gt;guard&lt;/strong&gt; snippet (ultisnips) in order to add on my existing&#xA;functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet guard &quot;add guard to functions&quot; b&#xA;if !exists('*${1:func_name}')&#xA;   ${VISUAL}&#xA;endif&#xA;${0:jump here &amp;lt;C-j&amp;gt;}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the moment I have to type the &quot;func_name&quot; at the top and &#xA;it has to be equal at the name captured in the visual section, &#xA;anyone have a better suggestion or any improvement to this? &lt;/p&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="51" LastEditDate="2019-03-28T07:53:42.763" LastActivityDate="2019-03-28T07:53:42.763" Title="How to capture the name of a function on ultisnips plugin?" Tags="|plugin-ultisnips|snippets|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19344" PostTypeId="1" AcceptedAnswerId="19346" CreationDate="2019-03-28T01:00:04.903" Score="0" ViewCount="284" Body="&lt;p&gt;I currently have this autocommand in my vimrc: &#xA;&lt;code&gt;autocmd BufWritePost *.tex silent! execute &quot;!pdflatex %&quot; | redraw!&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It compiles my current LaTeX file whenever I save with &lt;code&gt;:w&lt;/code&gt;. However, a terminal window pops up every time I do so. &lt;code&gt;silent!&lt;/code&gt; seems to ensure the window automatically closes after a few seconds, but it does not prevent it from opening in the first place.&lt;/p&gt;&#xA;" OwnerUserId="21547" LastActivityDate="2019-03-28T12:01:47.657" Title="Run pdflatex in vim without a pop-up window" Tags="|autocmd|filetype-tex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19345" PostTypeId="2" ParentId="19342" CreationDate="2019-03-28T01:02:37.300" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;Every time you save, you add buffer number to a global set, it can be done with autocmd with BufWritePost event or custom save command.&lt;/li&gt;&#xA;&lt;li&gt;Write a function to go through all the buffers that have been saved, save it again if &amp;amp;modified is true.&lt;/li&gt;&#xA;&lt;li&gt;Add an autocmd with CursorHold event and your function. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-03-28T01:29:05.757" LastActivityDate="2019-03-28T01:29:05.757" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19346" PostTypeId="2" ParentId="19344" CreationDate="2019-03-28T01:16:17.917" Score="1" Body="&lt;p&gt;With vim 8, you could do something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.tex term ++close ++hidden pdflatex %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should create a terminal buffer in vim running pdflatex, but keep it hidden and close it when the process exits. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But even better is to place your autocommand in a filetype plugin, so you can rely on that detection mechanism: &lt;code&gt;~/.vim/after/ftplugin/tex.vim&lt;/code&gt; can contain&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost &amp;lt;buffer&amp;gt; term ++close ++hidden pdflatex %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-03-28T12:01:47.657" LastActivityDate="2019-03-28T12:01:47.657" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19347" PostTypeId="2" ParentId="19343" CreationDate="2019-03-28T01:23:36.237" Score="1" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet guard &quot;add guard to functions&quot; b&#xA;if !exists('*`!p snip.rv = re.search('\S+\s+(\S+)\(', snip.v.text.splitlines()[0]).group(1)`')&#xA;    ${VISUAL}&#xA;endif&#xA;${0:jump here &amp;lt;C-j&amp;gt;}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;`!p snip.rv = ...`&lt;/code&gt; part is a python interpolation. The evaluation of the expression to the right of the assignment operator after &lt;code&gt;snip.rv&lt;/code&gt; replaces everything between the backticks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the expression is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;re.search('\S+\s+(\S+)\(', snip.v.text.splitlines()[0]).group(1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;snip.v.text&lt;/code&gt; allows you to refer to the last visually-selected text in a python interpolation.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/172454/9780968&quot;&gt;&lt;code&gt;.splitlines()&lt;/code&gt;&lt;/a&gt; allows you to split the lines of the visual selection in a list.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;snip.v.text.splitlines()[0]&lt;/code&gt; grabs the first line in the selection.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;re.search('\S+\s+(\S+)\(', ...).group(1)&lt;/code&gt; extracts the function name from this line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you make a mistake when selecting the function, the first line may not match the regex, in which case an error will be raised.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside the python interpolation, you can use a &lt;code&gt;try&lt;/code&gt;, &lt;code&gt;except&lt;/code&gt; construct to &lt;a href=&quot;https://stackoverflow.com/a/4667014/9780968&quot;&gt;catch the error&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet guard &quot;add guard to functions&quot; b&#xA;if !exists('*`!p&#xA;try:&#xA;    func_name = re.search('\S+\s+(\S+)\(', snip.v.text.splitlines()[0]).group(1)&#xA;except AttributeError:&#xA;    func_name = ''&#xA;snip.rv = func_name&#xA;`')&#xA;    ${VISUAL}&#xA;endif&#xA;${0:jump here &amp;lt;C-j&amp;gt;}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-03-28T02:36:43.590" LastActivityDate="2019-03-28T02:36:43.590" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19349" PostTypeId="2" ParentId="8378" CreationDate="2019-03-28T14:50:57.513" Score="5" Body="&lt;p&gt;There's also the &lt;a href=&quot;https://github.com/AndrewRadev/bufferize.vim&quot; rel=&quot;noreferrer&quot;&gt;bufferize.vim&lt;/a&gt; plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Bufferize scriptnames&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is basically a packaged version of the accepted answer (using &lt;code&gt;:redir&lt;/code&gt;) and may be more convenient for some.&lt;/p&gt;&#xA;" OwnerUserId="21553" LastActivityDate="2019-03-28T14:50:57.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19350" PostTypeId="1" AcceptedAnswerId="19351" CreationDate="2019-03-28T15:40:32.587" Score="2" ViewCount="152" Body="&lt;p&gt;One of the files I have has &quot;wrapped&quot; text :&#xA;&lt;a href=&quot;https://i.stack.imgur.com/vd47T.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vd47T.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;Any idea how to unravel it?&#xA;I am not sure if this is feature of any of my plugins.&#xA;List of my plugins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'git://git.wincent.com/command-t.git'&#xA;Plugin 'file:///home/gmarik/path/to/plugin'&#xA;Plugin 'rstacruz/sparkup'&#xA;Plug 'pandoc-preview.vim'&#xA;Plug 'vimtex'&#xA;Plug 'vim-auto-save'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My vim version : &lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 22 2019 18:22:38)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="21555" LastEditorUserId="1841" LastEditDate="2019-03-28T16:20:37.017" LastActivityDate="2019-03-29T03:11:48.693" Title="How to unravel wrapped text" Tags="|folding|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19351" PostTypeId="2" ParentId="19350" CreationDate="2019-03-28T16:03:26.043" Score="5" Body="&lt;p&gt;First of all the &quot;wrapped&quot; text is actually a folded text (see &lt;code&gt;:h folds&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To open the closed folds, you can&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Place your cursor on the folded texts and do &lt;code&gt;zo&lt;/code&gt; to open it (see &lt;code&gt;:h zo&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Place your cursor on the folded text and do &lt;code&gt;za&lt;/code&gt; to toggle fold under cursor, i.e. open the fold if the fold is closed and vice versa (see &lt;code&gt;:h za&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Do &lt;code&gt;zR&lt;/code&gt; to open all the folds (see &lt;code&gt;:h zR&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Do &lt;code&gt;zi&lt;/code&gt; to toggle the the display of folds, i.e. toggle 'foldenable' (see &lt;code&gt;:h zi&lt;/code&gt; and &lt;code&gt;:h foldenable&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more info and keybinding to create/delete/open/close/interact with folds, see &lt;code&gt;:h folds&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-29T03:11:48.693" LastActivityDate="2019-03-29T03:11:48.693" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19353" PostTypeId="2" ParentId="454" CreationDate="2019-03-28T16:40:33.987" Score="0" Body="&lt;p&gt;Another version of the StripTrailingSpaces function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('*StripTrailingWhitespace')&#xA;    function! StripTrailingWhitespace() range&#xA;        if !&amp;amp;binary &amp;amp;&amp;amp; &amp;amp;filetype != 'diff'&#xA;            call Preserve(&quot;:&quot; . a:firstline . &quot;,&quot; . a:lastline . &quot;s/\\s\\+$//e&quot;)&#xA;        endif&#xA;    endfunction&#xA;endif&#xA;&#xA;&quot; http://technotales.wordpress.com/2010/03/31/preserve-a-vim-function-that-keeps-your-state/&#xA;if !exists('*Preserve')&#xA;    function! Preserve(command)&#xA;        try&#xA;            let l:win_view = winsaveview()&#xA;             &quot;silent! keepjumps keeppatterns execute a:command&#xA;            silent! execute 'keeppatterns keepjumps ' . a:command&#xA;        finally&#xA;            call winrestview(l:win_view)&#xA;        endtry&#xA;    endfunction&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Actually there is a bug in this function&lt;/em&gt; (this one):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The position is not being kept because of the &quot;range&quot; option.&#xA;It it is removed, and it works very well. However, I am sharing the code to receive some help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, it also uses the &lt;strong&gt;Preserve&lt;/strong&gt; function seen above, but in a slightly different fashion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference here is that I can select a range of lines or a paragraph with &lt;code&gt;vip&lt;/code&gt; and then the range &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt; will automatically appear&#xA;at the command prompt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea came from &lt;a href=&quot;https://bezhermoso.github.io/til/vim-function-ranges/&quot; rel=&quot;nofollow noreferrer&quot;&gt;a Bez Hermoso post&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2019-11-10T11:09:30.693" LastActivityDate="2019-11-10T11:09:30.693" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19354" PostTypeId="1" AcceptedAnswerId="19355" CreationDate="2019-03-28T17:36:18.730" Score="1" ViewCount="39" Body="&lt;p&gt;I'm trying to convert &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const std::string &amp;amp;s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;std::string const &amp;amp; s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and can't seem to get it quite right. This is the regex I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/const \(.\{-}\) &amp;amp;/\1 const &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the result I'm getting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;std::string const const std::string &amp;amp;s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9991" LastActivityDate="2019-03-28T17:47:25.507" Title="Rearrange c++ const and reference specifiers" Tags="|regular-expression|filetype-c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19355" PostTypeId="2" ParentId="19354" CreationDate="2019-03-28T17:47:25.507" Score="3" Body="&lt;p&gt;Just escape the &lt;code&gt;&amp;amp;&lt;/code&gt; with a backslash.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/const \(.\{-}\) &amp;amp;/\1 const \&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;amp;&lt;/code&gt; in the replace part inserts the entire matched pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help s/\&amp;amp;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-03-28T17:47:25.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19356" PostTypeId="2" ParentId="12565" CreationDate="2019-03-29T01:35:58.687" Score="2" Body="&lt;p&gt;According to &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/recover.html#swap-file&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help swap-file&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;If this file already exists (e.g., when you are recovering from a crash) a   warning is given and another extension is used, &quot;.swo&quot;,&#xA;  &quot;.swn&quot;, etc.&lt;/li&gt;&#xA;  &lt;li&gt;An existing file will never be overwritten.&lt;/li&gt;&#xA;  &lt;li&gt;The swap file is deleted as soon as Vim stops editing the file.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So if you realise that you need to recover from a swap file, even without the warning, then you can still manually &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/recover.html#recovery&quot; rel=&quot;nofollow noreferrer&quot;&gt;recover it&lt;/a&gt; at any time unless you explicitly deleted it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've decided to use the &lt;code&gt;shortmess=A&lt;/code&gt; option because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Nearly all of the swap file warnings are false positives (e.g. my PC crashed, but the file was already saved because I have set Vim to &lt;a href=&quot;https://vim.fandom.com/wiki/Auto_save_files_when_focus_is_lost&quot; rel=&quot;nofollow noreferrer&quot;&gt;auto save when the window focus changes&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;li&gt;If there is ever a genuine loss of data, then I will probably notice the problem without the warning, and be able to manually recover the data from the swap file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21559" LastActivityDate="2019-03-29T01:35:58.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19357" PostTypeId="1" AcceptedAnswerId="19360" CreationDate="2019-03-29T04:42:51.647" Score="9" ViewCount="4916" Body="&lt;p&gt;Is there a (built-in) way to search all vimwiki files for a certain pattern? I don't mean searching tags, but something akin to using grep on all the wiki files in the vimwiki directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is not a native vimwiki way, is there a way to do it without exiting the vimwiki (i.e a vim command of some sort)?&lt;/p&gt;&#xA;" OwnerUserId="20443" LastEditorUserId="343" LastEditDate="2019-03-29T11:08:18.520" LastActivityDate="2019-03-29T11:08:18.520" Title="Search through entire vimwiki" Tags="|plugin-vimwiki|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19358" PostTypeId="1" CreationDate="2019-03-29T08:00:51.207" Score="6" ViewCount="3737" Body="&lt;p&gt;I am using macvim 8.1, the map command is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;C-$&amp;gt; &amp;lt;End&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also tried &lt;code&gt;&amp;lt;C-4&amp;gt;&lt;/code&gt;, no working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tried other number, can't work too (however CTRL-6 could work).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also tried &lt;code&gt;nnoremap&lt;/code&gt;, same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;:map &amp;lt;C-$&amp;gt;&lt;/code&gt; command shows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i &amp;lt;C-$&amp;gt;      * &amp;lt;End&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21218" LastActivityDate="2020-02-26T19:01:13.963" Title="Cannot map Ctrl+ number (except 6 or ^)" Tags="|key-bindings|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19359" PostTypeId="2" ParentId="19358" CreationDate="2019-03-29T08:37:37.147" Score="9" Body="&lt;p&gt;Normally Ctrl-Number produce a different key code. You can check like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open Vim and change to insert mode. Then hit &lt;kbd&gt;Ctrl-V&lt;/kbd&gt; followed by &lt;kbd&gt;Ctrl-4&lt;/kbd&gt; (or whatever you plan to map). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Linux this produces the output &lt;code&gt;^\&lt;/code&gt;. Note that this is one character, usually displayed in light-blue. So &lt;kbd&gt;Ctrl-4&lt;/kbd&gt; is identical to &lt;kbd&gt;Ctrl-\&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tested with Vim 8.1 on Ubuntu in Gnome-Terminal (but &lt;em&gt;should&lt;/em&gt; be true for all systems):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-1&lt;/kbd&gt;  is not detected&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-2&lt;/kbd&gt;  is &lt;kbd&gt;Ctrl-@&lt;/kbd&gt; (hex &lt;code&gt;0x00&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-3&lt;/kbd&gt;  is &lt;kbd&gt;Ctrl-[&lt;/kbd&gt; aka &lt;kbd&gt;ESC&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-4&lt;/kbd&gt;  is &lt;kbd&gt;Ctrl-\&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-5&lt;/kbd&gt;  is &lt;kbd&gt;Ctrl-]&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-6&lt;/kbd&gt;  is &lt;kbd&gt;Ctrl-^&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-7&lt;/kbd&gt;  is &lt;kbd&gt;Ctrl-_&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-8&lt;/kbd&gt;  is &lt;kbd&gt;Ctrl-?&lt;/kbd&gt; aka &lt;kbd&gt;Delete&lt;/kbd&gt; used as &lt;kbd&gt;Backspace&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-9&lt;/kbd&gt;  is not detected&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-0&lt;/kbd&gt;  is not detected&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-29T08:45:37.717" LastActivityDate="2019-03-29T08:45:37.717" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19360" PostTypeId="2" ParentId="19357" CreationDate="2019-03-29T10:14:46.437" Score="14" Body="&lt;p&gt;Vimwiki has a simple search included. You can run &lt;code&gt;:VimwikiSearch /pattern/&lt;/code&gt; (the trailing slash is important). To go to the next hit run &lt;code&gt;:lnext&lt;/code&gt; and &lt;code&gt;:lprevious&lt;/code&gt; for the previous.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details you can look into the help pages &lt;code&gt;:h :VimwikiSearch&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5331" LastActivityDate="2019-03-29T10:14:46.437" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19361" PostTypeId="2" ParentId="19357" CreationDate="2019-03-29T10:32:19.463" Score="4" Body="&lt;h2&gt;vimgrep&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There is a command called &lt;code&gt;vimgrep&lt;/code&gt; (see &lt;code&gt;:h :vimgrep&lt;/code&gt;) that is a native grepping utility built into vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To search for a pattern in every wiki files in a directory, assuming the wiki files have &lt;code&gt;.wiki&lt;/code&gt; extension, you would do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /{pattern}/[g][j] path/to/directory/*.wiki&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Check &lt;code&gt;:h :vimgrep&lt;/code&gt; for info on the flags&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the above command vim will search the specified files with &lt;code&gt;.wiki&lt;/code&gt; extension in the specified directory for the specified &lt;code&gt;{pattern}&lt;/code&gt; and set the error list to the matches, i.e. load the quickfix window (see &lt;code&gt;:h quickfix&lt;/code&gt;). You can move through the matches in the following ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:copen&lt;/code&gt;  : To open the quickfix window&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:cclose&lt;/code&gt; : To close the quickfix window&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:cnext&lt;/code&gt;  : To jump to the next match&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:cprev&lt;/code&gt;  : To jump to the previous match&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:cfirst&lt;/code&gt;  : To jump to the first match&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:clast&lt;/code&gt;  : To jump to the last match&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can find info about the above keybindings and many more functionalities of quickfix in &lt;code&gt;:h quickfix&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a variant of quickfix window called &lt;code&gt;:h location-list&lt;/code&gt;. It's a window local quickfix list, where a quickfix list is independent of a window/split. That is you can have multiple location-list but not more than one quickfix windows. So, you can create your workflow based on your needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to open quickfix and location-list windows right after a quickfix/location-list command has been issued, you can put the following in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup quickfix&#xA;    autocmd!&#xA;    autocmd QuickFixCmdPost [^l]* nested cwindow&#xA;    autocmd QuickFixCmdPost    l* nested lwindow&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;grep&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can also use the grepping utility provided by your system to fill up the quickfix list. The command is called, well, &lt;code&gt;:grep&lt;/code&gt; (see &lt;code&gt;:h grep&lt;/code&gt;). By default, the grep program to be used is set to use GNU grep and in a weird way that I couldn't figure out how to use it. But if you have some other grepping utility, which you should, like &lt;code&gt;silversearcher-ag&lt;/code&gt; or &lt;code&gt;ripgrep-rg&lt;/code&gt;, then you can set up the grep command in vim in the following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if executable('ag')&#xA;    set grepprg=ag\ --nogroup\ --nocolor\ --hidden\ --ignore\ .git&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can set up vim &lt;code&gt;:h grepprg&lt;/code&gt; for &lt;code&gt;ripgrep-rg&lt;/code&gt; in similar way. And it will also fill up your quickfix list the same way &lt;code&gt;vimgrep&lt;/code&gt; does, and then you can jump among the matches with the same keybindings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The equivalent of the &lt;code&gt;vimgrep&lt;/code&gt; command mentioned above for &lt;code&gt;:h grep&lt;/code&gt; would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:grep '{pattern}' path/to/directory/*.wiki&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-03-29T10:32:19.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19362" PostTypeId="1" AcceptedAnswerId="19363" CreationDate="2019-03-29T12:45:58.743" Score="0" ViewCount="768" Body="&lt;p&gt;I am trying to find (in Vim script) if the 2 files open using vimdiff are same or different? Is there a way to do that? (a variable like &amp;amp;diff perhaps?)&lt;/p&gt;&#xA;" OwnerUserId="16636" LastActivityDate="2019-03-29T13:56:23.623" Title="Vimdiff: Is there a way of knowing if there are differences in the diff files or not?" Tags="|vimscript|vimdiff|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19363" PostTypeId="2" ParentId="19362" CreationDate="2019-03-29T13:01:45.837" Score="1" Body="&lt;p&gt;The easiest option is not to make vim do any work at all: &lt;code&gt;diff -q&lt;/code&gt; reports if files are different, and &lt;code&gt;diff -s&lt;/code&gt; if they are the same. According to &lt;a href=&quot;https://stackoverflow.com/a/5439382&quot;&gt;this answer&lt;/a&gt; if you don’t need output, &lt;code&gt;cmp -s&lt;/code&gt; works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in vimscript you might do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:files = [ get_file_names() ] &quot; left as an exercise&#xA;call system('cmp -s ' . join(l:files, ' '))&#xA;&quot; do something with v:shell_error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-03-29T13:01:45.837" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19364" PostTypeId="2" ParentId="19362" CreationDate="2019-03-29T13:56:23.623" Score="2" Body="&lt;p&gt;Okay, this is a very hacky approach. You really should check the result of &lt;code&gt;diff&lt;/code&gt; using e.g. a custom &lt;code&gt;diffexpr&lt;/code&gt;. But you asked for it, so here we go:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a=win_getid()|exe &quot;windo let g:diff=(get(g:, 'diff', 1) &amp;amp;&amp;amp; foldclosed(1) &amp;amp;&amp;amp; foldclosedend(1)==line('$'))&quot;|if g:diff |echomsg 'no differences found' |else |echomsg 'there are some differences!' |endif|call win_gotoid(a)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(one line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This assumes, that all windows are in diff mode and basically checks, whether each window contains only a single folded line. &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-03-29T13:56:23.623" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19365" PostTypeId="1" AcceptedAnswerId="19366" CreationDate="2019-03-29T14:31:51.497" Score="3" ViewCount="265" Body="&lt;p&gt;I've the following function and accompanying key-bindings to send texts from vim in one tmux pane to other:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; copy yanked text to tmux pane&#xA;function! Send_to_tmux(count) abort&#xA;    let _count = (a:count == 0) ? 2 : a:count&#xA;    let text = @z&#xA;    let text = substitute(text, ';', '\\;', 'g')&#xA;    let text = substitute(text, '&quot;', '\\&quot;', 'g')&#xA;    let text = substitute(text, '\n', '&quot; Enter &quot;', 'g')&#xA;    let text = substitute(text, '!', '\\!', 'g')&#xA;    let text = substitute(text, '%', '\\%', 'g')&#xA;    let text = substitute(text, '#', '\\#', 'g')&#xA;    silent execute &quot;!tmux send-keys -t &quot; . _count . &quot; \&quot;&quot; . text . &quot;\&quot;&quot;&#xA;    silent execute &quot;!tmux send-keys -t &quot; . _count . &quot;Enter&quot;&#xA;    unlet _count&#xA;    unlet text&#xA;endfunction&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;p '&quot;zyip:call Send_to_tmux('.v:count.')&amp;lt;CR&amp;gt;'&#xA;xnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;p '&quot;zy:call Send_to_tmux('.v:count.')&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I basically use this function when I use SQL. Now, SQL has commenting structure of two types:&#xA;&lt;sup&gt;(written in the structure of &lt;code&gt;:h 'commentstring'&lt;/code&gt;)&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;/* %s */&lt;/li&gt;&#xA;&lt;li&gt;-- %s&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I always used the first type of comment, and didn't set up the substitute command for second type of comment. And now I see that I can't send texts into other tmux panes of structure &lt;code&gt;-- texts&lt;/code&gt;. I have tried it in bare bash, and MySQL command line, same result. So, I guess bash is not taking string of that structure, or tmux is eating it itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've removed all tmux configurations and tried to do it, same result. So, I don't think it's a problem with my tmux config.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I send &lt;code&gt;--&lt;/code&gt; to tmux panes from vim?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-29T15:14:38.170" LastActivityDate="2019-03-29T17:04:29.050" Title="Cannot send `--` into tmux panes from vim" Tags="|tmux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19366" PostTypeId="2" ParentId="19365" CreationDate="2019-03-29T15:27:49.973" Score="4" Body="&lt;p&gt;Looks more like a shell related question than a Vim related question. I would try the following  (not tested, so might be wrong):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent execute &quot;!tmux send-keys -t &quot; . _count . &quot; -- \&quot;&quot; . text . &quot;\&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add a &lt;code&gt;--&lt;/code&gt; before the text. Most Unix commands stop option processing as soon as they see a &lt;code&gt;--&lt;/code&gt; and everything after it is handled as parameter.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="16280" LastEditDate="2019-03-29T17:04:29.050" LastActivityDate="2019-03-29T17:04:29.050" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19368" PostTypeId="1" CreationDate="2019-03-29T20:15:56.220" Score="3" ViewCount="1503" Body="&lt;p&gt;How can I adjust my .vimrc so that &lt;code&gt;set conceallevel=0&lt;/code&gt; is specific to just LaTeX documents?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin &lt;code&gt;vim-devicons&lt;/code&gt; requires the following conceal level with NERDTree:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set conceallevel=3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, with this level set to 3, when editing a LaTeX document the LaTeX code is hidden and its WYSIWYG form is shown instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, instead of this showing in Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\textbf{Leading Word:} This is a sentence.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...this is shown in Vim instead:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Leading Word&lt;/strong&gt;: This is a sentence.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's quite annoying to say the least because I would rather see the code, (or at least have the code revealed with the cursor placed over the text if there's no solution to see just the code with a conceallevel=3). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;set conceallevel=0&lt;/code&gt; in my .vimrc has no effect on the LaTeX document and it continues the WYSIWYG behavior.&#xA;Setting in vim &lt;code&gt;set conceallevel=0&lt;/code&gt; is cumbersome to do by hand in my workflow, and all the icons have special characters and brackets surrounding them.&lt;/p&gt;&#xA;" OwnerUserId="21571" LastEditorUserId="5298" LastEditDate="2019-03-29T21:49:47.813" LastActivityDate="2023-03-08T02:06:50.217" Title="How to show all LaTeX code but still have set conceallevel=3 for vim-devicons and NERDTree?" Tags="|vimrc|filetype-tex|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19369" PostTypeId="2" ParentId="19368" CreationDate="2019-03-29T23:43:25.903" Score="4" Body="&lt;p&gt;I found the answer to my own question after hours of hunting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This post sheds light on the issue: &#xA;&lt;a href=&quot;https://stackoverflow.com/questions/18160953/disable-latex-symbol-conversion-in-vim&quot;&gt;https://stackoverflow.com/questions/18160953/disable-latex-symbol-conversion-in-vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's resolved by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tex_conceal=&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To quote &lt;code&gt;h: tex_conceal&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;              *g:tex_conceal*  Tex: Selective Conceal Mode~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;You may selectively use conceal mode by setting g:tex_conceal in your&#xA;  &amp;lt;.vimrc&gt;.  By default, g:tex_conceal is set to &quot;admgs&quot; to enable&#xA;  concealment for the following sets of characters: &gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;a = accents/ligatures   b = bold and italic     d = delimiters  m = math&#xA;  symbols   g = Greek   s = superscripts/subscripts &amp;lt; By leaving one or&#xA;  more of these out, the associated conceal-character substitution will&#xA;  not be made.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Setting this to blank will reveal all the characters hidden specifically for TeX documents.&lt;/p&gt;&#xA;" OwnerUserId="21571" LastActivityDate="2019-03-29T23:43:25.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19370" PostTypeId="1" AcceptedAnswerId="19375" CreationDate="2019-03-30T03:11:23.237" Score="1" ViewCount="83" Body="&lt;p&gt;Given an integer &lt;code&gt;n&lt;/code&gt; and a block of text, rotate every character or element in the &lt;em&gt;n&lt;/em&gt;-th column up or down to the next position that exists.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A line with more th&lt;strong&gt;a&lt;/strong&gt;n k characters.&#xA;A longer line with &lt;strong&gt;m&lt;/strong&gt;ore than k character.&#xA;A short line.&#xA;Rotate here: ------&lt;strong&gt;v&lt;/strong&gt;--&#xA;This is long enough&lt;strong&gt;.&lt;/strong&gt;&#xA;&#xA;This is not enough.&#xA;Wrapping around to &lt;strong&gt;t&lt;/strong&gt;he first line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A line with more th&lt;strong&gt;t&lt;/strong&gt;n k characters.&#xA;A longer line with &lt;strong&gt;a&lt;/strong&gt;ore than k character.&#xA;A short line.&#xA;Rotate here: ------&lt;strong&gt;m&lt;/strong&gt;--&#xA;This is long enough&lt;strong&gt;v&lt;/strong&gt;&#xA;&#xA;This is not enough.&#xA;Wrapping around to &lt;strong&gt;.&lt;/strong&gt;he first line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Rotating the &lt;em&gt;k&lt;/em&gt;-th column of the same input where 35 &amp;lt; &lt;em&gt;k&lt;/em&gt; &amp;lt; 42 would yield the input text unchanged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related: &lt;a href=&quot;https://codegolf.stackexchange.com/questions/182363/rotate-a-column&quot;&gt;https://codegolf.stackexchange.com/questions/182363/rotate-a-column&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="398" LastActivityDate="2019-05-05T08:56:49.657" Title="Vimscript or macro to &quot;rotate&quot; column 20 (or n) vertically?" Tags="|vimscript|macro|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19372" PostTypeId="1" AcceptedAnswerId="19374" CreationDate="2019-03-30T04:52:37.367" Score="0" ViewCount="45" Body="&lt;p&gt;Is there a way to turn the &quot;region bounded by two specific marks&quot; into a text object similar to &lt;code&gt;aw&lt;/code&gt; or &lt;code&gt;ap&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been messing around with &lt;code&gt;vi&lt;/code&gt; and found it convenient to use &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;. and define a region and to define commands that act on the region bounded by &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be nice to be able to expose a text object for this purpose in vim.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have the following bindings in &lt;code&gt;vi&lt;/code&gt; for emulating something kind of like visual mode. I have some macros that set &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; to the boundaries of an interesting region. And another set of macros for manipulating the region bounded by &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's nice to be able to pick whether I want a linewise selection or not after setting the marks.                                                                                                                                                                                                                                                               &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^A&lt;/code&gt; and &lt;code&gt;^P&lt;/code&gt; are literal control characters, in this case they set the mark &lt;code&gt;a&lt;/code&gt; to the beginning of the buffer or paragraph and &lt;code&gt;b&lt;/code&gt; to the end.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map ^A 1GmaGmb&#xA;map ^P }mb{jmak}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And other macros that do stuff to the region like indent it and dedent it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map \. mp'a&amp;gt;'b`p&#xA;map \, mp'a&amp;lt;'b`p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2019-03-30T08:08:08.623" Title="define a text object as the boundary of two marks" Tags="|custom-text-object|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19373" PostTypeId="2" ParentId="19372" CreationDate="2019-03-30T05:11:27.100" Score="1" Body="&lt;p&gt;I would use something like the following. &lt;strong&gt;There might be a lot of corner cases&lt;/strong&gt;, but it's a start:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for s:nr1 in range(97, 122)&#xA;    for s:nr2 in range(97, 122)&#xA;        let s:char1 = nr2char(s:nr1)&#xA;        let s:char2 = nr2char(s:nr2)&#xA;        execute 'xnoremap i'.s:char1.s:char2.' :&amp;lt;C-u&amp;gt;normal! `'.s:char1.'v`'.s:char2.'&amp;lt;CR&amp;gt;'&#xA;        execute 'onoremap i'.s:char1.s:char2.' :normal vi'.s:char1.s:char2.'&amp;lt;CR&amp;gt;'&#xA;    endfor&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used &lt;code&gt;range(97, 122)&lt;/code&gt; to get a list of numbers from 97 to 122 (see &lt;code&gt;:h range()&lt;/code&gt; and these represent the ASCII values of characters &lt;code&gt;a&lt;/code&gt; to &lt;code&gt;z&lt;/code&gt; which could be converted to characters with &lt;code&gt;:h nr2char()&lt;/code&gt;. So, if you want uppercase letter marks, you can edit the list range yourself.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-30T05:27:26.997" LastActivityDate="2019-03-30T05:27:26.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19374" PostTypeId="2" ParentId="19372" CreationDate="2019-03-30T07:07:50.937" Score="2" Body="&lt;p&gt;Here is an example for a custom text object working with the marks &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; char-wise &#xA;onoremap am :&amp;lt;c-u&amp;gt;execute 'normal `av`b'&amp;lt;cr&amp;gt;&#xA;xnoremap am :&amp;lt;c-u&amp;gt;execute 'normal `av`b'&amp;lt;cr&amp;gt;&#xA;&quot; line-wise&#xA;onoremap aM :&amp;lt;c-u&amp;gt;execute 'normal `aV`b'&amp;lt;cr&amp;gt;&#xA;xnoremap aM :&amp;lt;c-u&amp;gt;execute 'normal `aV`b'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To copy the characters between the marks &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; hit &lt;code&gt;yam&lt;/code&gt;. To copy the lines between &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; hit &lt;code&gt;yaM&lt;/code&gt;. You can use it with other commands., like &lt;code&gt;=am&lt;/code&gt; to format the lines between marks &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :map-modes&lt;/code&gt; and &lt;code&gt;:help omap-info&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This moves the cursor. After it hit &lt;kbd&gt;Ctrl-O&lt;/kbd&gt; twice to get back to your initial cursor position.&lt;/li&gt;&#xA;&lt;li&gt;This changes the visual selection. If you used &lt;code&gt;yam&lt;/code&gt; and hit &lt;code&gt;gv&lt;/code&gt; afterwards, the visual selection is mark &lt;code&gt;a&lt;/code&gt; to &lt;code&gt;b&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to work with any mark, you could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;silent&amp;gt; am :&amp;lt;c-u&amp;gt;execute 'normal `'. nr2char(getchar()) . 'v`' . nr2char(getchar())&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; am :&amp;lt;c-u&amp;gt;execute 'normal `'. nr2char(getchar()) . 'v`' . nr2char(getchar())&amp;lt;cr&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; aM :&amp;lt;c-u&amp;gt;execute 'normal `'. nr2char(getchar()) . 'V`' . nr2char(getchar())&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; aM :&amp;lt;c-u&amp;gt;execute 'normal `'. nr2char(getchar()) . 'V`' . nr2char(getchar())&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you need to give the marks. Like &lt;code&gt;yamab&lt;/code&gt; copies the range of the marks &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;, while &lt;code&gt;yamxy&lt;/code&gt; uses the marks &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;. If you only want the line of the mark &lt;code&gt;a&lt;/code&gt; copied, you could use &lt;code&gt;yaMaa&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be careful with upper case marks here. Upper case marks might change the buffer.&#xA;Assuming mark &lt;code&gt;A&lt;/code&gt; is in another buffer, the command &lt;code&gt;yamAb&lt;/code&gt; will switch to the buffer of the mark &lt;code&gt;A&lt;/code&gt; and will copy to mark &lt;code&gt;b&lt;/code&gt; in that buffer. &lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-03-30T08:08:08.623" LastActivityDate="2019-03-30T08:08:08.623" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19375" PostTypeId="2" ParentId="19370" CreationDate="2019-03-30T08:33:14.593" Score="1" Body="&lt;pre&gt;&lt;code&gt;&quot; s : start line, e : end line, c : col&#xA;function! RotateColumn(s, e, c)&#xA;  &quot; place cursor at line a:s&#xA;  call cursor(a:s, 1)&#xA;  &quot; search backward to find last line that's longer enough&#xA;  if search(printf('\v%%&amp;gt;%dl%%&amp;lt;%dl%%%dc', a:s-1, a:e+1, a:c), 'b')&#xA;    &quot; copy current character into @&quot;&#xA;    norm! yl&#xA;    &quot; for each line, if character exists in screen column a:c, swap it with @&quot;&#xA;    exec printf('%d,%dg/\v%%%dc/ norm! %d|vp', a:s, a:e, a:c, a:c)&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No longer need to find last line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; s : start line, e : end line, c : col&#xA;function! RotateColumn2(s, e, c)&#xA;  &quot; set @&quot; to any letter&#xA;  let @&quot;='x'&#xA;  &quot; copy all lines to below a:e&#xA;  exec a:s.','.a:e.'t'.a:e&#xA;  &quot; for each line, if character exists in screen column a:c, swap it with @&quot;&#xA;  exec printf('%d,%dg/\v%%%dc/ norm! %d|vp', a:s, a:e*2-a:s+1, a:c, a:c)&#xA;  &quot; remove original lines&#xA;  exec a:s.','.a:e.'d'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-05T08:56:49.657" LastActivityDate="2019-05-05T08:56:49.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19376" PostTypeId="1" CreationDate="2019-03-30T12:25:50.777" Score="2" ViewCount="8272" Body="&lt;p&gt;I'm new to vim. The problem happens when I type &lt;code&gt;:PlugInstall&lt;/code&gt; I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[vim-plug] Invalid plug directory: /Users/joqsan/.vim/plugged. Try to call plug#begin with a valid directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is how I installed &lt;code&gt;vim-plug&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ mkdir -p ~/.vim/autoload/ $ cd ~/.vim/autoload/&#xA;$ curl -O https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;.vimrc&lt;/code&gt; I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number&#xA;&#xA;if filereadable(expand(&quot;~/.vimrc.plug&quot;))&#xA;source ~/.vimrc.plug&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;~/.vimrc.plug&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;Plug 'tpope/vim-fugitive'&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I reload &lt;code&gt;vim&lt;/code&gt; and type &lt;code&gt;:PlugInstall&lt;/code&gt;, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[vim-plug] Invalid plug directory: /Users/joqsan/.vim/plugged. Try to call plug#begin with a valid directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I type &lt;code&gt;:scriptnames&lt;/code&gt; I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: /usr/share/vim/vimrc&#xA;2: ~/.vimrc&#xA;3: ~/.vimrc.plug&#xA;4: ~/.vim/autoload/plug.vim&#xA;5: /usr/share/vim/vim80/filetype.vim&#xA;6: /usr/share/vim/vim80/ftplugin.vim&#xA;7: /usr/share/vim/vim80/indent.vim&#xA;8: /usr/share/vim/vim80/syntax/syntax.vim&#xA;9: /usr/share/vim/vim80/syntax/synload.vim&#xA;10: /usr/share/vim/vim80/syntax/syncolor.vim&#xA;11: /usr/share/vim/vim80/plugin/getscriptPlugin.vim&#xA;12: /usr/share/vim/vim80/plugin/gzip.vim&#xA;13: /usr/share/vim/vim80/plugin/logiPat.vim&#xA;14: /usr/share/vim/vim80/plugin/manpager.vim&#xA;15: /usr/share/vim/vim80/plugin/matchparen.vim&#xA;16: /usr/share/vim/vim80/plugin/netrwPlugin.vim&#xA;17: /usr/share/vim/vim80/plugin/rrhelper.vim&#xA;18: /usr/share/vim/vim80/plugin/spellfile.vim&#xA;19: /usr/share/vim/vim80/plugin/tarPlugin.vim&#xA;20: /usr/share/vim/vim80/plugin/tohtml.vim&#xA;21: /usr/share/vim/vim80/plugin/vimballPlugin.vim&#xA;22: /usr/share/vim/vim80/plugin/zipPlugin.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since I don't see &lt;code&gt;~/.vim/plugged&lt;/code&gt;, I try to create the directory:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;$ mkdir ~/.vim/plugged&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;net120:~ joqsan$ mkdir ~/.vim/plugged&#xA;mkdir: /Users/joqsan/.vim/plugged: File exists&#xA;net120:~ joqsan$ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know what I'm doing wrong. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 1&lt;/strong&gt;: Directory structure of &lt;code&gt;~/.vim&lt;/code&gt; and &lt;code&gt;~/.vim/autoload&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;net120:~ joqsan$ ls -la ~/.vim/autoload&#xA;total 256&#xA;drwxr-x---  3 root  staff     96 Mar 30 12:33 .&#xA;drwxr-x---  4 root  staff    128 Mar 30 13:14 ..&#xA;-rw-r--r--  1 root  staff  74434 Mar 30 13:45 plug.vim&#xA;&#xA;Joqsans-MacBook-Air:~ joqsan$ ls -al ~/.vim&#xA;total 0&#xA;drwxr-x---   4 root    staff   128 Mar 30 13:14 .&#xA;drwxr-xr-x+ 66 joqsan  staff  2112 Mar 30 17:38 ..&#xA;drwxr-x---   3 root    staff    96 Mar 30 12:33 autoload&#xA;-rw-r--r--   1 root    staff     0 Mar 30 13:14 plugged`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GLx5t.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GLx5t.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 3:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On OS X, the primary group is always &lt;code&gt;staff&lt;/code&gt;, so I think this is ok. I didn't create the directory &lt;code&gt;~/.vim&lt;/code&gt;. I installed vim with homebrew (I mean, I did nothing manually).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After doing what you recommended I got this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Joqsans-MacBook-Air:~ joqsan$ sudo chown joqsan:staff ~/.vim&#xA;Joqsans-MacBook-Air:~ joqsan$ ls -al ~/.vim&#xA;total 0&#xA;drwxr-x---   4 joqsan  staff   128 Mar 30 23:08 .&#xA;drwxr-xr-x+ 67 joqsan  staff  2144 Mar 31 04:28 ..&#xA;drwxr-x---   3 root    staff    96 Mar 30 12:33 autoload&#xA;drwxr-xr-x   2 root    staff    64 Mar 30 23:08 plugged&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With respect to the previous prompt (in &lt;strong&gt;Edit 1&lt;/strong&gt; above) now the first two directories are owned by &lt;code&gt;joqsan&lt;/code&gt;, but I still get the error when typing &lt;code&gt;:PlugInstall&lt;/code&gt;. Maybe that is because &lt;code&gt;autoload&lt;/code&gt; and &lt;code&gt;plugged&lt;/code&gt; are still owned by &lt;code&gt;root&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 4:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Joqsans-MacBook-Air:~ joqsan$ sudo chown -R joqsan: ~/.vim&#xA;Joqsans-MacBook-Air:~ joqsan$ ls -al ~/.vim&#xA;total 0&#xA;drwxr-x---   4 joqsan  staff   128 Mar 30 23:08 .&#xA;drwxr-xr-x+ 67 joqsan  staff  2144 Mar 31 13:11 ..&#xA;drwxr-x---   3 joqsan  staff    96 Mar 30 12:33 autoload&#xA;drwxr-xr-x   2 joqsan  staff    64 Mar 30 23:08 plugged&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/k239b.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/k239b.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="21574" LastEditorUserId="21574" LastEditDate="2019-03-31T10:53:33.427" LastActivityDate="2019-04-22T22:30:50.317" Title="Vim-Plug: Can't install plugins. Invalid plug directory" Tags="|vimrc|plugin-vim-plug|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="19377" PostTypeId="2" ParentId="14429" CreationDate="2019-03-30T12:58:39.490" Score="13" Body="&lt;p&gt;Here is what you should do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt; (or create it if not present)&lt;/li&gt;&#xA;&lt;li&gt;Add a line &lt;code&gt;language en_US&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Save it and reload Neovim&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I would like to give all the credits to @anothernode. I've just convert his comment into the regular answer.&lt;/p&gt;&#xA;" OwnerUserId="21575" LastActivityDate="2019-03-30T12:58:39.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19378" PostTypeId="1" AcceptedAnswerId="19379" CreationDate="2019-03-30T17:53:13.653" Score="0" ViewCount="124" Body="&lt;p&gt;Suppose I have a wrapped line like this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HJ5E4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HJ5E4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with the cursor positioned just before the AND (&lt;code&gt;&amp;amp;&lt;/code&gt;). &lt;br&gt;&#xA;Is there an option to move the cursor just before the OR (&lt;code&gt;|&lt;/code&gt;) pressing the &lt;code&gt;&amp;lt;Down&amp;gt;&lt;/code&gt; key ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should be possible with a function, but an option would be better, of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; The editor hid the &lt;code&gt;&amp;lt;Down&amp;gt;&lt;/code&gt; text word (now I edited). My intention is not to jump to a specific character but to a specific position. In other words, treating a single line as it were two line&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="15254" LastEditDate="2019-03-31T10:20:58.427" LastActivityDate="2019-03-31T13:12:46.587" Title="Fast moving with long lines when using set wrap" Tags="|cursor|wrap|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19379" PostTypeId="2" ParentId="19378" CreationDate="2019-03-30T18:41:32.657" Score="2" Body="&lt;p&gt;See &lt;code&gt;:h t&lt;/code&gt;, &lt;code&gt;:h T&lt;/code&gt;, &lt;code&gt;:h f&lt;/code&gt;, &lt;code&gt;:h F&lt;/code&gt; and &lt;code&gt;:h ;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a brief overview:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can jump to the next &lt;code&gt;{char}&lt;/code&gt; with &lt;code&gt;f{char}&lt;/code&gt; or jump to previous &lt;code&gt;{char}&lt;/code&gt; with &lt;code&gt;F{char}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;You can jump just before the next &lt;code&gt;{char}&lt;/code&gt; with &lt;code&gt;t{char}&lt;/code&gt; and jump just after the previous &lt;code&gt;{char}&lt;/code&gt; with &lt;code&gt;T{char}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;You can repeat last &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt; or  &lt;code&gt;T&lt;/code&gt; with &lt;code&gt;;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All of the above commands take &lt;code&gt;[counts]&lt;/code&gt; as an argument. So, you can perform &lt;code&gt;[count]f{char}&lt;/code&gt; to go to the &lt;code&gt;[count]-th&lt;/code&gt; next &lt;code&gt;{char}&lt;/code&gt; and similar for all &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt;, &lt;code&gt;T&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The OP edited his question and his actual requirement was to move up and down virtual display lines. You can do that with &lt;code&gt;:h gj&lt;/code&gt; and &lt;code&gt;:h gk&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-31T13:12:46.587" LastActivityDate="2019-03-31T13:12:46.587" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19380" PostTypeId="2" ParentId="19376" CreationDate="2019-03-30T18:44:53.040" Score="1" Body="&lt;p&gt;As posted in the &lt;a href=&quot;https://vi.stackexchange.com/questions/19376/vim-plug-cant-install-plugins-invalid-plug-directory#comment33660_19376&quot;&gt;comments&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You have a file where vim-plug wants to create a directory&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Create a back up and get it out of the way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mv ~/.vim/plugged ~/.vim/plugged.bak&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then try again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also make sure you own the directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo chown $USER: ~/.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The vim directory can become owned by root if you use &lt;code&gt;sudo vim&lt;/code&gt;—the correct technique is to set the &lt;code&gt;EDITOR&lt;/code&gt;or &lt;code&gt;VISUAL&lt;/code&gt; variable and invoke &lt;code&gt;sudoedit&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-04-22T22:30:50.317" LastActivityDate="2019-04-22T22:30:50.317" CommentCount="12" CommunityOwnedDate="2019-04-22T22:30:50.317" ContentLicense="CC BY-SA 4.0" />
  <row Id="19381" PostTypeId="2" ParentId="18843" CreationDate="2019-03-30T19:13:59.620" Score="0" Body="&lt;h2&gt;1st Method&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Use this command to convert tabs to spaces except the tabs used for indentation over a &lt;code&gt;range&lt;/code&gt; of lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! -bar -range=% RemoveTabs call s:remove_tabs(&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;)&#xA;function! s:remove_tabs(line1, line2) abort&#xA;    let view = winsaveview()&#xA;    let mods = 'sil keepj keepp'&#xA;    let range = a:line1 . ',' . a:line2&#xA;    let pat = '\%(^\s*\)\@!\&amp;amp;\(.\)\t'&#xA;    let l:Rep = {-&amp;gt; submatch(1) . repeat(' ', strdisplaywidth(&quot;\t&quot;, col('.') == 1 ? 0 : virtcol('.') ))}&#xA;    let g = 0&#xA;    while search(&quot;\t&quot;, 'n') &amp;amp;&amp;amp; g &amp;lt; 999&#xA;        exe mods . ' ' . range .'s/' . pat . '/\=l:Rep()/ge'&#xA;        let g += 1&#xA;    endwhile&#xA;    call winrestview(view)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;2nd Method&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Use this function to bind your &lt;kbd&gt;Tab&lt;/kbd&gt; to a function that inserts tabs for indentation and spaces for alignment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SpecialTab() abort&#xA;    if (col('.') == 1) || (matchstr(getline('.'), '\%'.(col('.') - 1).'c.') =~ '\t')&#xA;        return &quot;\&amp;lt;Tab&amp;gt;&quot;&#xA;    else&#xA;        return repeat(&quot;\&amp;lt;Space&amp;gt;&quot;, (&amp;amp;tabstop - (virtcol('.') % &amp;amp;tabstop)) + 1)&#xA;    endif&#xA;endfunction&#xA;inoremap &amp;lt;Tab&amp;gt; &amp;lt;C-R&amp;gt;=SpecialTab()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-04-06T06:15:57.337" LastActivityDate="2019-04-06T06:15:57.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19382" PostTypeId="1" AcceptedAnswerId="19383" CreationDate="2019-03-30T20:31:19.560" Score="1" ViewCount="111" Body="&lt;p&gt;Sometimes I'll have some text with an arbitrary indentation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                Sample text.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I want to bring this text back to the beginning of the line, I'll visually select the line and then indent a large number of times. So I type &lt;code&gt;V5&amp;lt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sample text.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to bring the indentation back to the beginning?&lt;/p&gt;&#xA;" OwnerUserId="11931" LastActivityDate="2019-03-30T20:52:25.493" Title="Indent text to beginning of line" Tags="|key-bindings|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19383" PostTypeId="2" ParentId="19382" CreationDate="2019-03-30T20:36:24.743" Score="3" Body="&lt;p&gt;Use &lt;code&gt;:left&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h left&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]le[ft] [indent]&#xA;            Left-align lines in [range].  Sets the indent in the&#xA;            lines to [indent] (default 0).&#xA;            Not available when |+ex_extra| feature was disabled at&#xA;            compile time.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;:h center&lt;/code&gt; and &lt;code&gt;:h right&lt;/code&gt; to align the current line to center and right.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-30T20:52:25.493" LastActivityDate="2019-03-30T20:52:25.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19384" PostTypeId="1" AcceptedAnswerId="19385" CreationDate="2019-03-30T22:57:49.137" Score="2" ViewCount="491" Body="&lt;p&gt;I'm trying to use autocmd BufNewFile to like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile  \(.*_spec\)\@!.rb  0r ~/vim/skeleton.rb  &#xA;autocmd BufNewFile  *_spec.rb          0r ~/vim/skeleton_spec.rb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, I want the first line to match all .rb files NOT ending with _spec.rb, and the second line to only match *_spec.rb files. I've tried various incarnations of the first line to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="21579" LastEditorUserId="13728" LastEditDate="2019-03-30T23:21:02.740" LastActivityDate="2019-03-30T23:26:22.000" Title="How to match file pattern, with extension, not containing a specific word?" Tags="|vimrc|regular-expression|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19385" PostTypeId="2" ParentId="19384" CreationDate="2019-03-30T23:26:22.000" Score="4" Body="&lt;p&gt;You should use a look-behind assertion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile  *\(_spec\)\@&amp;lt;!.rb  0r ~/vim/skeleton.rb&#xA;autocmd BufNewFile  *_spec.rb          0r ~/vim/skeleton_spec.rb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The glob pattern &lt;code&gt;*\(_spec\)\@&amp;lt;!.rb&lt;/code&gt; is converted to regular expression &lt;code&gt;\(_spec\)\@&amp;lt;!\.rb$&lt;/code&gt; which breaks down as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;             \.rb       match literal &quot;.rb&quot;&#xA;                 $      this must be the end of the filename&#xA;\(_spec\)\@&amp;lt;!           provided &quot;_spec&quot; does not appear right before the dot&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-03-30T23:26:22.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19386" PostTypeId="1" CreationDate="2019-03-31T01:46:14.113" Score="3" ViewCount="241" Body="&lt;p&gt;I installed Vim 8.1 with all the default options on Windows 10.  I didn't modify vimrc.  It takes more than 5 seconds to launch Vim (or gvim) each time I edit a file, and has just as long of a delay when I quit the application also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I launch it using the --clean option, then it takes less than a second to launch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make Vim always behave like it was launched with --clean?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;--startuptime log:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;000.000  000.000: --- VIM STARTING ---&#xA;000.000  000.000: Allocated generic buffers&#xA;004.000  004.000: locale set&#xA;004.000  000.000: clipboard setup&#xA;004.000  000.000: window checked&#xA;005.000  001.000: inits 1&#xA;069.000  064.000: parsing arguments&#xA;069.000  000.000: expanding arguments&#xA;583.000  514.000: shell init&#xA;584.000  001.000: Termcap init&#xA;585.000  001.000: inits 2&#xA;585.000  000.000: init highlight&#xA;1311.000  010.000  010.000: sourcing c:\Program Files (x86)\Vim\vim81\syntax\syncolor.vim&#xA;1694.000  676.000  666.000: sourcing c:\Program Files (x86)\Vim\vim81\syntax\synload.vim&#xA;2281.000  377.000  377.000: sourcing c:\Program Files (x86)\Vim\vim81\filetype.vim&#xA;2514.000  1675.000  622.000: sourcing c:\Program Files (x86)\Vim\vim81\syntax\syntax.vim&#xA;2521.000  001.000  001.000: sourcing c:\Program Files (x86)\Vim\vim81\filetype.vim&#xA;2699.000  001.000  001.000: sourcing c:\Program Files (x86)\Vim\vim81\ftplugin.vim&#xA;3133.000  001.000  001.000: sourcing c:\Program Files (x86)\Vim\vim81\indent.vim&#xA;3341.000  2504.000  826.000: sourcing c:\Program Files (x86)\Vim\vim81/defaults.vim&#xA;3750.000  2915.000  411.000: sourcing c:\Program Files (x86)\Vim\vim81/vimrc_example.vim&#xA;3750.000  2916.000  001.000: sourcing $VIM\_vimrc&#xA;3750.000  249.000: sourcing vimrc file(s)&#xA;3987.000  001.000  001.000: sourcing c:\Program Files (x86)\Vim\vim81\plugin\getscriptPlugin.vim&#xA;3992.000  001.000  001.000: sourcing c:\Program Files (x86)\Vim\vim81\plugin\gzip.vim&#xA;3999.000  002.000  002.000: sourcing c:\Program Files (x86)\Vim\vim81\plugin\logiPat.vim&#xA;4003.000  000.000  000.000: sourcing c:\Program Files (x86)\Vim\vim81\plugin\manpager.vim&#xA;4010.000  001.000  001.000: sourcing c:\Program Files (x86)\Vim\vim81\plugin\matchparen.vim&#xA;4019.000  002.000  002.000: sourcing c:\Program Files (x86)\Vim\vim81\plugin\netrwPlugin.vim&#xA;4024.000  000.000  000.000: sourcing c:\Program Files (x86)\Vim\vim81\plugin\rrhelper.vim&#xA;4029.000  000.000  000.000: sourcing c:\Program Files (x86)\Vim\vim81\plugin\spellfile.vim&#xA;4035.000  001.000  001.000: sourcing c:\Program Files (x86)\Vim\vim81\plugin\tarPlugin.vim&#xA;4039.000  001.000  001.000: sourcing c:\Program Files (x86)\Vim\vim81\plugin\tohtml.vim&#xA;4042.000  000.000  000.000: sourcing c:\Program Files (x86)\Vim\vim81\plugin\vimballPlugin.vim&#xA;4046.000  001.000  001.000: sourcing c:\Program Files (x86)\Vim\vim81\plugin\zipPlugin.vim&#xA;4052.000  002.000  002.000: sourcing c:\Program Files (x86)\Vim\vim81\pack\dist\opt\matchit\plugin\matchit.vim&#xA;4052.000  290.000: loading plugins&#xA;4053.000  001.000: loading packages&#xA;4253.000  200.000: loading after plugins&#xA;4253.000  000.000: inits 3&#xA;5080.000  827.000: reading viminfo&#xA;5081.000  001.000: setting raw mode&#xA;5398.000  317.000: start termcap&#xA;5398.000  000.000: clearing screen&#xA;5399.000  001.000: opening buffers&#xA;5399.000  000.000: BufEnter autocommands&#xA;5399.000  000.000: editing files in windows&#xA;5400.000  001.000: VimEnter autocommands&#xA;5400.000  000.000: before starting main loop&#xA;5446.000  046.000: first screen update&#xA;5446.000  000.000: --- VIM STARTED ---&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21582" LastActivityDate="2019-03-31T01:46:14.113" Title="How to get vim on Windows to start quickly" Tags="|microsoft-windows|startup|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19387" PostTypeId="1" AcceptedAnswerId="19393" CreationDate="2019-03-31T04:23:29.157" Score="3" ViewCount="223" Body="&lt;p&gt;I would like to have the keys M, J, K, L, U, I, O to be mapped to 0, 1, 2, 3, 4, 5, 6 (combine with the keys 7, 8, 9 already being on top of those keys) to be a total numpad when I hold a modifier key, say Alt/Meta.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that way commands with numbers like 25j, d3w, etc. would be easier and faster to be typed. But I haven't figured out how to make this happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it is said in this answer &lt;a href=&quot;https://vi.stackexchange.com/a/2363/21584&quot;&gt;https://vi.stackexchange.com/a/2363/21584&lt;/a&gt;, I've tried this solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;set &amp;lt;M-j&amp;gt;=\ej&quot;&#xA;nnoremap &amp;lt;M-j&amp;gt; 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it only works with commands which begin with a single number (7j), however complex commands which have number inside or multiple number (d3w, 25j) don't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Ubuntu 18.04, on terminal Kitty.&lt;/p&gt;&#xA;" OwnerUserId="21584" LastEditorUserId="21584" LastEditDate="2019-03-31T05:02:54.887" LastActivityDate="2019-03-31T15:04:17.790" Title="How to map Alt key with M J K L U I O to make a numpad?" Tags="|key-bindings|terminal|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19388" PostTypeId="1" CreationDate="2019-03-31T05:25:06.797" Score="1" ViewCount="310" Body="&lt;p&gt;I am developing a neovim client using RPC, and trying to get all status line texts shown in below figure. Are there any ways to get them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already tried using &lt;code&gt;execute&lt;/code&gt; function and the redirection function, but they can only get them partially. I would like to get all strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Y2bZa.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Y2bZa.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19984" LastActivityDate="2019-03-31T05:40:04.810" Title="Is it possible to obtain status line strings?" Tags="|neovim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19389" PostTypeId="2" ParentId="19388" CreationDate="2019-03-31T05:34:45.107" Score="1" Body="&lt;p&gt;You need to use &lt;code&gt;:h :redir&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @a&#xA;:ls&#xA;:redir END&#xA;:reg a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above commands will redirect the output of the commands used in between &lt;code&gt;redir@a&lt;/code&gt; and &lt;code&gt;redir END&lt;/code&gt; to &lt;code&gt;register a&lt;/code&gt; (see &lt;code&gt;:h :reg&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also redirect output to&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A file with &lt;code&gt;:redir &amp;gt;&amp;gt; file&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;A register with &lt;code&gt;:redir @{a-z}&lt;/code&gt; or &lt;code&gt;:redir @{a-z}&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Selection clipboard with &lt;code&gt;:redir @*&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;A variable with &lt;code&gt;:redir =&amp;gt; {var}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And you can append (not overwrite) to the already contents stored in the registers, files, variables by using &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; instead of &lt;code&gt;&amp;gt;&lt;/code&gt; in all the above &lt;code&gt;:h :redir&lt;/code&gt; commands. That is you can append the output of a command to&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A file with &lt;code&gt;:redir &amp;gt;&amp;gt; file&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;A register with &lt;code&gt;:redir @{a-z}&amp;gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;:redir @{A-Z}&amp;gt;&lt;/code&gt; or &lt;code&gt;:redir @{A-Z}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Selection clipboard with &lt;code&gt;:redir @*&amp;gt;&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;A variable with &lt;code&gt;:redir =&amp;gt;&amp;gt; {var}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-03-31T05:40:04.810" LastActivityDate="2019-03-31T05:40:04.810" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19390" PostTypeId="1" AcceptedAnswerId="19391" CreationDate="2019-03-31T06:03:26.740" Score="3" ViewCount="56" Body="&lt;p&gt;I am using Vim version 8.0 and I would like to use &lt;code&gt;&amp;lt;M-Up&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;M-Down&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;M-Left&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;M-Right&amp;gt;&lt;/code&gt; for navigating from window to window during insert mode. I am unable to get this work. These are the key-bindings in my &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;M-Left&amp;gt; &amp;lt;C-w&amp;gt;&amp;lt;Left&amp;gt;&#xA;inoremap &amp;lt;M-Right&amp;gt; &amp;lt;C-w&amp;gt;&amp;lt;Right&amp;gt;&#xA;inoremap &amp;lt;M-Up&amp;gt; &amp;lt;C-w&amp;gt;&amp;lt;Up&amp;gt;&#xA;inoremap &amp;lt;M-Down&amp;gt; &amp;lt;C-w&amp;gt;&amp;lt;Down&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In normal mode, things work. That is, when the key maps are changed from &lt;code&gt;inoremap&lt;/code&gt; to &lt;code&gt;noremap&lt;/code&gt;. Would someone have an idea how i can troubleshoot the problem or what is wrong in my above configuration?&lt;/p&gt;&#xA;" OwnerUserId="21585" LastEditorUserId="19763" LastEditDate="2019-03-31T06:32:10.237" LastActivityDate="2019-03-31T06:32:10.237" Title="Unable to get &lt;M-Up&gt; to work in insert mode" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19391" PostTypeId="2" ParentId="19390" CreationDate="2019-03-31T06:08:16.760" Score="3" Body="&lt;p&gt;You need to use &lt;code&gt;:h i_CTRL-O&lt;/code&gt;. From the help docs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-O      execute one command, return to Insert mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;M-Left&amp;gt;  &amp;lt;C-O&amp;gt;&amp;lt;C-w&amp;gt;&amp;lt;Left&amp;gt;&#xA;inoremap &amp;lt;M-Right&amp;gt; &amp;lt;C-O&amp;gt;&amp;lt;C-w&amp;gt;&amp;lt;Right&amp;gt;&#xA;inoremap &amp;lt;M-Up&amp;gt;    &amp;lt;C-O&amp;gt;&amp;lt;C-w&amp;gt;&amp;lt;Up&amp;gt;&#xA;inoremap &amp;lt;M-Down&amp;gt;  &amp;lt;C-O&amp;gt;&amp;lt;C-w&amp;gt;&amp;lt;Down&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-03-31T06:08:16.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19392" PostTypeId="2" ParentId="19088" CreationDate="2019-03-31T12:24:02.203" Score="1" Body="&lt;p&gt;Answering my own question after some time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The clue to a solution came from noticing that the same issue happens when the &lt;code&gt;SQLDOC&lt;/code&gt; heredoc is contained within other shell constructs, such as &lt;code&gt;if&lt;/code&gt; or &lt;code&gt;for&lt;/code&gt;. On the other hand, &lt;code&gt;EOF&lt;/code&gt; heredocs are always highlighted as such even when they appear inside &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt; and functions. Why the difference then? Looking at the &lt;em&gt;shell&lt;/em&gt; syntax rules one notices that heredoc regions are defined as contained elements of other regions or clusters, specifically &lt;code&gt;shCaseList&lt;/code&gt;, &lt;code&gt;shCommandSubList&lt;/code&gt; and &lt;code&gt;shFunctionList&lt;/code&gt;. So if I add my &lt;code&gt;hereDocDashSQL&lt;/code&gt; region as a contained element of those three clusters, SQL should display multi-colors in all cases. Add a continuation line after the syntax region line in file heredoc-embed.sh:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region hereDocDashSQL matchgroup=Statement start=+&amp;lt;&amp;lt;\s*[-'\\]\?\z(SQLDOC\)+  end=+^\s*\z1+ contains=@SQL&#xA;      \ containedin=@shCaseList,shCommandSubList,shFunctionList&#xA;&quot; Introduce ^^^^ the new heredoc to $VIMRUNTIME/syntax/sh.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The arguments to &lt;code&gt;containedin&lt;/code&gt; are the &lt;code&gt;syn cluster&lt;/code&gt;s that contain &lt;code&gt;shHereDoc&lt;/code&gt; in file &lt;code&gt;$VIMRUNTIME/syntax/sh.vim&lt;/code&gt;. The continuation line could include argument &lt;code&gt;contained&lt;/code&gt; to allow matching the heredoc only when it's contained in the clusters. In this case &lt;code&gt;contained&lt;/code&gt; is omitted so the heredoc can be recognized also in the main body of the shell script. Cf. &lt;code&gt;:help syn-containedin&lt;/code&gt;, &lt;code&gt;:help syn-contained&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Side-by-side before/after comparison:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9lsc0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9lsc0.png&quot; alt=&quot;SOLVED: now the fourth SELECT is highlighted like the second one&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1634" LastEditorUserId="1634" LastEditDate="2019-04-02T12:27:03.050" LastActivityDate="2019-04-02T12:27:03.050" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19393" PostTypeId="2" ParentId="19387" CreationDate="2019-03-31T14:50:24.410" Score="3" Body="&lt;p&gt;As I find out in this guide: &lt;a href=&quot;https://howchoo.com/g/nzc1ztu4ztd/custom-key-mappings-vim#triggering-our-custom-key-mapping&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://howchoo.com/g/nzc1ztu4ztd/custom-key-mappings-vim#triggering-our-custom-key-mapping&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I was missing was the Operator-pending Mode, which is the case of the command like d3w.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how I modified the mappings (I didn't think it would turn out to be this simple):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap ^[j 1&#xA;noremap ^[k 2&#xA;noremap ^[l 3&#xA;&quot; etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;^[&lt;/code&gt; is the Escape character, and &lt;code&gt;map&lt;/code&gt; applies the mapping for Normal, Visual and Operator-pending Mode. Now I can use Alt + J K L... to simulate the numpad on the right hand. Typing commands containing numbers is feeling more and more comfy now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this could help you guys :)&lt;/p&gt;&#xA;" OwnerUserId="21584" LastEditorUserId="21584" LastEditDate="2019-03-31T15:04:17.790" LastActivityDate="2019-03-31T15:04:17.790" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19394" PostTypeId="1" CreationDate="2019-04-01T00:25:28.913" Score="2" ViewCount="3564" Body="&lt;p&gt;I have been using nvim terminal mode to learn python and I want to have Ctrl-C break the python script from the terminal window even when I am not in insert mode. However, I also want Ctrl-C in my python script to result in entering an escape command directly to the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(':tnoremap')&#xA;    nnoremap &amp;lt;C-c&amp;gt; &amp;lt;C-w&amp;gt;wi&amp;lt;C-c&amp;gt;&amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&amp;lt;C-w&amp;gt;w  &#xA;    &quot; Ctrl-c from py sends key interupt to python terminal&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my .vimrc file which gives me the functionality for sending Ctrl-C to the terminal when I am in the python script buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried&#xA;&lt;code&gt;:tnoremap &amp;lt;C-c&amp;gt; i&amp;lt;C-c&amp;gt;&lt;/code&gt;&#xA;which does not work, I think because I am trying to issue the command from normal mode. This is a documented 'feature' of tmap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found that &#xA;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-c&amp;gt; i&amp;lt;C-c&amp;gt;&lt;/code&gt;&#xA;works but because the buffer has a name like :term\##:python where ## is the process id, and therefore varies, I cannot figure out how to incorporate the above into my rc file such that the terminal buffer automatically inherits this (local) functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried (from this &lt;a href=&quot;https://vi.stackexchange.com/questions/14377/neovim-map-selectively-only-on-a-terminal-window&quot;&gt;answer&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyTermMappings&#xA;  autocmd!&#xA;  autocmd TermOpen * nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-c&amp;gt; i&amp;lt;C-c&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this makes my whole rc file crap out with the error &lt;code&gt;no such group or event TermOpen * nnoremap &amp;lt;buffer&amp;gt;...&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried changing my launch of the terminal command (which is currently   &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;r :split \| terminal python&amp;lt;CR&amp;gt; &amp;lt;C-w&amp;gt;w&lt;/code&gt;)&#xA;to send the local remap to the command line on launch but all I have been able to accomplish is crashing the python terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can just run the &lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-c&amp;gt; i&amp;lt;C-c&amp;gt;&lt;/code&gt; after launching terminal but I would like to have any buffer that is launched with :terminal have this command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, I tried having the default behavior be that in normal mode Ctrl-C mapped to enter insert mode and type Ctrl-c e.g. &lt;code&gt;nnoremap &amp;lt;C-c&amp;gt; i&amp;lt;C-c&amp;gt;&lt;/code&gt; and then further in the .vimrc file &lt;code&gt;autocmd FileType python nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-w&amp;gt;wi&amp;lt;C-c&amp;gt;&amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&amp;lt;C-w&amp;gt;w&lt;/code&gt; but that also did not work.         &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this can be solved using autocmd options in Vim or if the nmap  cmd can take a pattern but I am fairly unfamiliar with these and have not had any luck looking at other responses. &lt;/p&gt;&#xA;" OwnerUserId="21593" LastEditorUserId="21593" LastEditDate="2019-04-01T18:50:35.923" LastActivityDate="2019-12-27T20:02:20.300" Title="neovim key remap specific to terminal buffer" Tags="|key-bindings|neovim|terminal|terminal-buffer|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19395" PostTypeId="2" ParentId="19394" CreationDate="2019-04-01T00:41:30.263" Score="0" Body="&lt;p&gt;Adding this to my .vimrc seems to have fixed it for my purposes without slowing down vim load or python launch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup pythonTerminal      &quot; name localized commands so they don'g get&#xA;                            &quot; written on every rc read&#xA;  autocmd!                  &quot; delete all exisiting au commands in group&#xA;  autocmd BufWinEnter,WinEnter term://* nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-c&amp;gt; i&amp;lt;C-c&amp;gt;&#xA;                            &quot; &amp;lt;C-c&amp;gt; interrupts python in terminal normal&#xA;  autocmd BufWinEnter,WinEnter *.py :nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-c&amp;gt; &#xA;      \ &amp;lt;C-w&amp;gt;wi&amp;lt;C-c&amp;gt;&amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&amp;lt;C-w&amp;gt;w&#xA;      &quot; &amp;lt;C-c&amp;gt; kills python terminal running from script file&#xA;augroup END&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not sure if I should add all my other python interactive mode commands to this and/or when autocmd is better to use than just the remap command but, to date at least, I haven't run into any issues in either vim or nvim with this snippet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to everyone for their help!&lt;/p&gt;&#xA;" OwnerUserId="21593" LastEditorUserId="21593" LastEditDate="2019-04-01T15:10:23.747" LastActivityDate="2019-04-01T15:10:23.747" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19396" PostTypeId="1" CreationDate="2019-04-01T02:42:18.247" Score="0" ViewCount="230" Body="&lt;p&gt;The option &lt;code&gt;colorcolumn&lt;/code&gt; is really useful. I would like a similar result to what it yields but only for the two lines that are at the top and the bottom of the screen (&lt;em&gt;not&lt;/em&gt; the document, but the screen). Is there a way to achieve that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More generally, is it possible to highlight or colorize a set of positions with row-column coordinates &lt;code&gt;(row_i, col_i), i = 1,...,N&lt;/code&gt; (again, those coordinates correspond to positions in the visible screen at any time, not the document)?&lt;/p&gt;&#xA;" OwnerUserId="6023" LastEditorUserId="6023" LastEditDate="2019-04-06T12:30:40.197" LastActivityDate="2019-04-06T12:46:51.023" Title="Highlighting screen positions, or `:set colorcolumn` only for the 2 bottom and top lines visible on the screen" Tags="|highlight|color|colorcolumn|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19397" PostTypeId="2" ParentId="19396" CreationDate="2019-04-01T03:35:57.610" Score="1" Body="&lt;p&gt;Hightlight first and last 2 lines after column 80:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd VimEnter,WinEnter * :match Error /\v%&amp;gt;80v%&amp;lt;3l.*|%&amp;gt;80v.*%$|%&amp;gt;80v.*(\n.*%$)@=/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to open a new window or reopen vim for this to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%&amp;gt;80v%&amp;lt;3l.*&lt;/code&gt;  match everything after column 80 in first 2 lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%&amp;gt;80v.*%$&lt;/code&gt;    match everything after column 80 in last line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%&amp;gt;80v.*(\n.*%$)@=/&lt;/code&gt; match everything after column 80 in last second line&lt;/li&gt;&#xA;&lt;li&gt;:help :match&lt;/li&gt;&#xA;&lt;li&gt;:help /\%v&lt;/li&gt;&#xA;&lt;li&gt;:help /\%l&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution doesn't work on screen line.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-06T12:46:51.023" LastActivityDate="2019-04-06T12:46:51.023" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19398" PostTypeId="2" ParentId="14377" CreationDate="2019-04-01T04:19:52.390" Score="1" Body="&lt;p&gt;I can't comment, only post an answer, but I'd like to say that the &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyTermMappings&#xA;  autocmd!&#xA;  autocmd TermOpen * nnoremap &amp;lt;buffer&amp;gt; q a&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works but it must go in your &lt;code&gt;init.vim&lt;/code&gt; file and not your standard &lt;code&gt;.vimrc&lt;/code&gt; if you use vi/m at all. Putting it into the &lt;code&gt;.vimrc&lt;/code&gt; file causes a &lt;code&gt;No such group or event: TermOpen * nnoremap &amp;lt;buffer&amp;gt; ...&lt;/code&gt; error.&lt;/p&gt;&#xA;" OwnerUserId="21593" LastActivityDate="2019-04-01T04:19:52.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19399" PostTypeId="1" CreationDate="2019-04-01T04:24:18.390" Score="2" ViewCount="499" Body="&lt;p&gt;I'm trying to make Omni completion work with my Ruby files, but it only works with Ruby's core libraries; for instance, after typing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String.&amp;lt;C-X&amp;gt;&amp;lt;C-O&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i get all Ruby's &lt;code&gt;String&lt;/code&gt; methods, but trying to omni complete from any local class (for instance: &lt;code&gt;MyClass.&amp;lt;C-X&amp;gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;) doesn't display any methods and, instead, shows me the following message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Omni completion (^O^N^P) Pattern not found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Upon further inspection (i.e. using vim debug) i found that the rails environment is not loading properly; this is the error log (just relevant lines shown):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[[31mCould not find json-1.8.6 in any of the sources^[[0m&#xA;^[[33mRun `bundle install` to install missing gems.^[[0m&#xA;calling function rubycomplete#Complete[22]..&amp;lt;SNR&amp;gt;116_ErrMsg&#xA;Error loading rails environment&#xA;.&#xA;.&#xA;.&#xA;calling function rubycomplete#Complete[22]..&amp;lt;SNR&amp;gt;116_ErrMsg&#xA;Problem loading class &quot;MyClass&quot;, was it already completed?&#xA;function rubycomplete#Complete[22]..&amp;lt;SNR&amp;gt;116_ErrMsg returning #0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But running &lt;code&gt;gem list json&lt;/code&gt; shows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;json (2.2.0, 2.0.2, 1.8.6, 1.8.3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the gem is definitely there, but it seems that vim omni completion is not aware of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that (after reading about similar issues) the ruby version used in the rails app must be the same used to compile vim, is this correct? Does anyone know a way around this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is in my .vimrc (only relevant lines):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;autocmd FileType ruby,eruby let g:rubycomplete_rails = 1&#xA;autocmd FileType ruby,eruby let g:rubycomplete_include_object = 1&#xA;autocmd FileType ruby,eruby let g:rubycomplete_include_objectspace = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;strong&gt;macOS (Sierra)&lt;/strong&gt; and this is &lt;code&gt;vim --version&lt;/code&gt; output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar 26 2019 01:54:59)&#xA;macOS version&#xA;Included patches: 1-1050&#xA;Compiled by Homebrew&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               +extra_search      +mouse_netterm     +tag_old_static&#xA;+arabic            -farsi             +mouse_sgr         -tag_any_white&#xA;+autocmd           +file_in_path      -mouse_sysmouse    -tcl&#xA;+autochdir         +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       +terminal&#xA;-balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;-browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    +gettext           +netbeans_intg     +textprop&#xA;+byte_offset       -hangul_input      +num64             +timers&#xA;+channel           +iconv             +packages          +title&#xA;+cindent           +insert_expand     +path_extra        -toolbar&#xA;-clientserver      +job               +perl              +user_commands&#xA;+clipboard         +jumplist          +persistent_undo   +vartabs&#xA;+cmdline_compl     +keymap            +postscript        +vertsplit&#xA;+cmdline_hist      +lambda            +printer           +virtualedit&#xA;+cmdline_info      +langmap           +profile           +visual&#xA;+comments          +libcall           -python            +visualextra&#xA;+conceal           +linebreak         +python3           +viminfo&#xA;+cryptv            +lispindent        +quickfix          +vreplace&#xA;+cscope            +listcmds          +reltime           +wildignore&#xA;+cursorbind        +localmap          +rightleft         +wildmenu&#xA;+cursorshape       +lua               +ruby              +windows&#xA;+dialog_con        +menu              +scrollbind        +writebackup&#xA;+diff              +mksession         +signs             -X11&#xA;+digraphs          +modify_fname      +smartindent       -xfontset&#xA;-dnd               +mouse             +startuptime       -xim&#xA;-ebcdic            -mouseshape        +statusline        -xpm&#xA;+emacs_tags        +mouse_dec         -sun_workshop      -xsmp&#xA;+eval              -mouse_gpm         +syntax            -xterm_clipboard&#xA;+ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -lintl -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.12 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.28.1/lib/perl5/5.28.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation  -lruby.2.6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21598" LastEditorUserId="21598" LastEditDate="2019-04-02T04:11:31.197" LastActivityDate="2019-04-02T04:11:31.197" Title="Omni completion Pattern not found - Error loading rails environment" Tags="|autocompletion|filetype-ruby|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19400" PostTypeId="2" ParentId="18361" CreationDate="2019-04-01T04:28:01.477" Score="1" Body="&lt;p&gt;This is a documented 'feature' of &lt;code&gt;:tnoremap&lt;/code&gt; as &lt;code&gt;tnoremap&lt;/code&gt; effectively only work for insert mode style actions and thus any variant using &lt;code&gt;tmap&lt;/code&gt; will not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding the below to &lt;code&gt;init.vim&lt;/code&gt; will remap the action of Ctrl-w + s in normal mode only for the terminal buffer&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufWinEnter,WinEnter term://* nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-w&amp;gt;s &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&amp;lt;C-w&amp;gt;&amp;lt;C-v&amp;gt; :terminal &amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as mentioned in the comments, it is better to use &lt;code&gt;augroup NAME&lt;/code&gt; before this command (and &lt;code&gt;augroup END&lt;/code&gt;) so that you don't add this command multiple times when your rc file is being sourced. It's also suggested practice that you place all the relevant terminal-specific commands in this augroup. &lt;/p&gt;&#xA;" OwnerUserId="21593" LastEditorUserId="21593" LastEditDate="2019-04-01T15:16:53.113" LastActivityDate="2019-04-01T15:16:53.113" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19401" PostTypeId="2" ParentId="18361" CreationDate="2019-04-01T08:52:17.190" Score="1" Body="&lt;p&gt;The following function will &lt;code&gt;:h :split&lt;/code&gt; the current buffer and create a new terminal buffer if the current buffer is a terminal buffer. Otherwise it will just &lt;code&gt;:h :split&lt;/code&gt;. Bind this function to both &lt;code&gt;:h :nnoremap&lt;/code&gt; and &lt;code&gt;:h :tnoremap&lt;/code&gt; variants of mappings to get the required results.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TermSplit() abort&#xA;    if exists('b:term_title')&#xA;        split&#xA;        terminal&#xA;    else&#xA;        split&#xA;    endif&#xA;endfunction&#xA;&#xA;tnoremap &amp;lt;C-w&amp;gt;s &amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;:call TermSplit()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-w&amp;gt;s :call TermSplit()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt; You can create similar function and bind it to &lt;code&gt;&amp;lt;C-w&amp;gt;v&lt;/code&gt; for &lt;code&gt;:h :vsplit&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-04-01T10:45:30.430" LastActivityDate="2019-04-01T10:45:30.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19402" PostTypeId="2" ParentId="8538" CreationDate="2019-04-01T13:30:17.087" Score="2" Body="&lt;p&gt;This is actually answered in an &lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator/issues/193&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue on vim-tmux-navigator&lt;/a&gt; and the solution works for me:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;.tmux.conf&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bind-key -n C-w switch-client -T VIMWINDOWS&#xA;bind-key -T VIMWINDOWS h if-shell &quot;$is_vim&quot; &quot;send-keys C-a C-h&quot;  &quot;select-pane -L&quot;&#xA;bind-key -T VIMWINDOWS j if-shell &quot;$is_vim&quot; &quot;send-keys C-a C-j&quot;  &quot;select-pane -D&quot;&#xA;bind-key -T VIMWINDOWS k if-shell &quot;$is_vim&quot; &quot;send-keys C-a C-k&quot;  &quot;select-pane -U&quot;&#xA;bind-key -T VIMWINDOWS l if-shell &quot;$is_vim&quot; &quot;send-keys C-a C-l&quot;  &quot;select-pane -R&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;vimrc&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;c-a&amp;gt;&amp;lt;c-h&amp;gt; :TmuxNavigateLeft&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;c-a&amp;gt;&amp;lt;c-j&amp;gt; :TmuxNavigateDown&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;c-a&amp;gt;&amp;lt;c-k&amp;gt; :TmuxNavigateUp&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;c-a&amp;gt;&amp;lt;c-l&amp;gt; :TmuxNavigateRight&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21605" LastEditorUserId="21605" LastEditDate="2019-04-01T13:52:46.097" LastActivityDate="2019-04-01T13:52:46.097" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19403" PostTypeId="2" ParentId="19394" CreationDate="2019-04-01T15:04:49.477" Score="2" Body="&lt;h3&gt;Using autocmds&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Neovim provides &lt;code&gt;TermOpen&lt;/code&gt;, while vim provides &lt;code&gt;TerminalOpen&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyTermMappings&#xA;  autocmd!&#xA;  if has('nvim')&#xA;    autocmd TermOpen * nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-c&amp;gt; i&amp;lt;C-c&amp;gt;&#xA;  else if exists('##TerminalOpen')&#xA;    audocmd TerminalOpen * nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-c&amp;gt; i&amp;lt;C-c&amp;gt;&#xA;  endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've provided another solution, but this is probably simpler and more general.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Via function and ftplugin&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Write a function in &lt;code&gt;~/.vim/autoload/terminal.vim&lt;/code&gt; (may need to adjust &lt;code&gt;~/.vim&lt;/code&gt;&#xA;for neovim users):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/autoload/terminal.vim&#xA;&quot; The name &amp;lt;terminal.vim&amp;gt; is arbitrary, but affects function declarations&#xA;&quot; within&#xA;&quot; cf :help autload&#xA;function! terminal#python() abort&#xA;  terminal python&#xA;  &quot; this is the equivalent of &amp;lt;C-w&amp;gt;w&#xA;  wincmd w&#xA;  nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-c&amp;gt; i&amp;lt;C-c&amp;gt;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And bind it to your terminal mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/after/ftplugin/python.vim&#xA;&quot; cf&#xA;&quot; - :help ftplugin&#xA;&quot; - :help after-directory&#xA;&quot; (after notes that after is rarely necessary, but I like it to overrule the&#xA;&quot; settings)&#xA;&#xA;&quot; Use whatever keys you want&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;LocalLeader&amp;gt;r :call terminal#python()&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Don't forget to add to 'b:undo_ftplugin'&#xA;&quot; I've got a specialized framework for that over at&#xA;&quot; https://github.com/benknoble/Dotfiles/blob/master/links/vim/autoload/ftplugin.vim&#xA;&quot; but this is simpler and should work for your purpose&#xA;let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')&#xA;if ! empty(b:undo_ftplugin)&#xA;  let b:undo_ftplugin .= ' | '&#xA;endif&#xA;let b:undo_ftplugin .= &quot;execute 'silent! nunmap &amp;lt;buffer&amp;gt; &amp;lt;LocalLeader&amp;gt;r'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Side Note: your normal mapping for python files could also go in the ftplugin&#xA;file above, unless you want it for &lt;em&gt;all&lt;/em&gt; files.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-04-01T15:04:49.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19404" PostTypeId="1" CreationDate="2019-04-01T20:53:58.807" Score="0" ViewCount="78" Body="&lt;p&gt;For a wiki syntax plugin, i'd like to have two highlighting colors for links. Links already having a destination file should be green and links with no destination yet should be red.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[[This file exist]] (green)&#xA;  filereadable(&quot;/wiki/dir/this_file_exist.md&quot;) -&amp;gt; true&#xA;&#xA;[[File does not exist]] (red) &#xA;  (filereadable(&quot;/wiki/dir/file_does_not_exist.md&quot;)-&amp;gt; false&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible in vim to run file validation code based on a region match?&lt;/p&gt;&#xA;" OwnerUserId="2165" LastEditorUserId="2165" LastEditDate="2019-04-01T23:10:42.300" LastActivityDate="2019-04-01T23:10:42.300" Title="highlight link with condition file does not exist" Tags="|vimscript|syntax-highlighting|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19405" PostTypeId="1" AcceptedAnswerId="19420" CreationDate="2019-04-01T21:29:26.957" Score="5" ViewCount="433" Body="&lt;p&gt;Often when editing LaTeX files, you are constantly switching between your &lt;code&gt;.tex&lt;/code&gt;, &lt;code&gt;.sty&lt;/code&gt; and &lt;code&gt;.bib&lt;/code&gt; files which are often in their own buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To navigate between those, I use the &lt;code&gt;:bn&lt;/code&gt; and &lt;code&gt;:bp&lt;/code&gt; commands which I have remapped to &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;S-Tab&amp;gt;&lt;/code&gt; for convenience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet, vimtex by default enables the quickfix buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I skip the quickfix buffer when buffer switching (the buffers are not in split windows)?&lt;/p&gt;&#xA;" OwnerUserId="20416" LastActivityDate="2019-04-02T22:28:13.340" Title="Skip the quickfix list when buffer switching using :bn" Tags="|vimrc|buffers|quickfix|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19407" PostTypeId="1" AcceptedAnswerId="19409" CreationDate="2019-04-02T06:45:31.330" Score="0" ViewCount="106" Body="&lt;p&gt;If I have a text containing markdown matching markings e.g.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Strikethrough uses two tildes. ~~Scratch this.~~&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be a good way to delete all those occurrences such as - in this example - &#xA;&quot;~~Scratch this.~~&quot;?&lt;/p&gt;&#xA;" OwnerUserId="19878" LastActivityDate="2019-04-02T08:59:17.197" Title="How omit text between and including matching characters?" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19408" PostTypeId="2" ParentId="19407" CreationDate="2019-04-02T06:49:55.630" Score="2" Body="&lt;p&gt;Put these in your &lt;code&gt;vimrc&lt;/code&gt; and then source the &lt;code&gt;vimrc&lt;/code&gt; with &lt;code&gt;:source $MYIMRC&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; simple text-objects&#xA;for s:char in [ '~', '_', '.', ':', ',', ';', '&amp;lt;Bar&amp;gt;', '/', '&amp;lt;Bslash&amp;gt;', '*', '+', '%', '`' ]&#xA;    execute 'xnoremap i' . s:char . ' :&amp;lt;C-u&amp;gt;normal! T' . s:char . 'vt' . s:char . '&amp;lt;CR&amp;gt;'&#xA;    execute 'onoremap i' . s:char . ' :normal vi' . s:char . '&amp;lt;CR&amp;gt;'&#xA;    execute 'xnoremap a' . s:char . ' :&amp;lt;C-u&amp;gt;normal! F' . s:char . 'vf' . s:char . '&amp;lt;CR&amp;gt;'&#xA;    execute 'onoremap a' . s:char . ' :normal va' . s:char . '&amp;lt;CR&amp;gt;'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can do &lt;code&gt;di{char}&lt;/code&gt; to delete the texts in between the &lt;code&gt;{char}&lt;/code&gt; and &lt;code&gt;da{char}&lt;/code&gt; to delete the texts in between the &lt;code&gt;{char}&lt;/code&gt; along with the characters themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The for loop iterates over &lt;code&gt;:h list&lt;/code&gt; containing the &lt;code&gt;{char}&lt;/code&gt; and execute &lt;code&gt;:h mapping&lt;/code&gt; commands for &lt;code&gt;:h operator-pending-mode&lt;/code&gt; and &lt;code&gt;:h visual-mode&lt;/code&gt; so that the &lt;code&gt;{char}&lt;/code&gt; in the list can act as &lt;code&gt;:h text-objects&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-04-02T06:54:59.647" LastActivityDate="2019-04-02T06:54:59.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19409" PostTypeId="2" ParentId="19407" CreationDate="2019-04-02T07:46:23.410" Score="2" Body="&lt;p&gt;I guess you want to search all strike-through text and delete it. That can be done with the following substitute command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\~\~\_.\{-}\~\~//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The escaped tilde &lt;code&gt;\~&lt;/code&gt; is needed as &lt;code&gt;~&lt;/code&gt; &quot;matches the last given substitute string&quot; (&lt;code&gt;:help /~&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;\_.&lt;/code&gt; matches any character &lt;em&gt;including&lt;/em&gt; newline, so multi-line strike-through is handled. (&lt;code&gt;:help /\_.&lt;/code&gt; and &lt;code&gt;:help /\_&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;\{-}&lt;/code&gt; matches &quot;as few as possible&quot;. (&lt;code&gt;help /\{-&lt;/code&gt;) BTW: Using &lt;code&gt;*&lt;/code&gt; here would match from the first to the last &lt;code&gt;~~&lt;/code&gt; in the file, as &lt;code&gt;*&lt;/code&gt; matches &quot;as many as possible&quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This command also handles multiple strike-throughs per line.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-04-02T08:59:17.197" LastActivityDate="2019-04-02T08:59:17.197" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19410" PostTypeId="1" AcceptedAnswerId="19434" CreationDate="2019-04-02T10:30:12.920" Score="5" ViewCount="133" Body="&lt;p&gt;Consider the following text snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;value1,&#xA;    value2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, if the cursor is at &lt;code&gt;(1,1)&lt;/code&gt; (the &lt;code&gt;'v'&lt;/code&gt; of &lt;code&gt;value1&lt;/code&gt;), &lt;code&gt;W&lt;/code&gt; takes me to &lt;code&gt;(2,5)&lt;/code&gt; (the &lt;code&gt;'v'&lt;/code&gt; of &lt;code&gt;value2&lt;/code&gt;) which is as expected. But if I do &lt;code&gt;dW&lt;/code&gt; at the same position, what I expect is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;value2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what I get is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;empty_line&amp;gt;&#xA;    value2 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h exclusive&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Which motions are linewise, inclusive or exclusive is mentioned with the&#xA;command.  There are however, two general exceptions:&#xA;1. If the motion is exclusive and the end of the motion is in column 1, the&#xA;   end of the motion is moved to the end of the previous line and the motion&#xA;   becomes inclusive.  Example: &quot;}&quot; moves to the first line after a &#xA;   paragraph,&#xA;   but &quot;d}&quot; will not include that line.&#xA;                                            exclusive-linewise&#xA;2. If the motion is exclusive, the end of the motion is in column 1 and the&#xA;   start of the motion was at or before the first non-blank in the line, the&#xA;   motion becomes linewise.  Example: If a paragraph begins with some blanks&#xA;   and you do &quot;d}&quot; while standing on the first non-blank, all the lines of&#xA;   the paragraph are deleted, including the blanks.  If you do a put now, the&#xA;   deleted lines will be inserted below the cursor position.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not sure if either of the exceptions applies to my case. What's going on?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan  9 2018 04:14:45)&#xA;Included patches: 1-662&#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20568" LastActivityDate="2019-04-05T16:34:26.117" Title="WORD movement across lines" Tags="|cut-copy-paste|cursor-movement|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19411" PostTypeId="2" ParentId="19088" CreationDate="2019-04-02T13:29:53.273" Score="2" Body="&lt;p&gt;I would recommend the following approach:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create the file &lt;code&gt;$HOME/.vim/after/syntax/sh.vim&lt;/code&gt; (&lt;code&gt;$HOME/vimfiles/after/syntax/sh.vim&lt;/code&gt; on Windows) with the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; safe b:current_syntax to restore it afterwards&#xA;&quot; Value could be 'sh', 'posix', 'ksh' or 'bash'&#xA;let s:cs_safe = b:current_syntax&#xA;&#xA;&quot; unlet b:current_syntax, so sql.vim will load&#xA;unlet b:current_syntax&#xA;syntax include @SQL syntax/sql.vim&#xA;&#xA;&quot; restore saved syntax&#xA;let b:current_syntax = s:cs_safe&#xA;&#xA;syn region shHereDoc matchgroup=shHereDocSql start=&quot;&amp;lt;&amp;lt;\s*\\\=\z(SQLDOC\)&quot; matchgroup=shHereDocSql end=&quot;^\z1\s*$&quot;   contains=@SQL&#xA;hi def link shHereDocSql        shRedir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This file is sourced &lt;em&gt;after&lt;/em&gt; the default sh syntax is sourced. At this point in time the buffer local &lt;code&gt;b:current_syntax&lt;/code&gt; is already set, so it has to be cleared before sourcing the sql syntax and restored afterward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then another &lt;code&gt;shHereDoc&lt;/code&gt; region is defined which contains sql code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To read about the &quot;after&quot; directory see &lt;code&gt;:help after-directory&lt;/code&gt; and &lt;code&gt;:help mysyntaxfile-add&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-04-03T05:11:16.137" LastActivityDate="2019-04-03T05:11:16.137" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19413" PostTypeId="1" AcceptedAnswerId="19414" CreationDate="2019-04-02T15:35:15.137" Score="0" ViewCount="664" Body="&lt;p&gt;I have a &lt;code&gt;plugin/smartcom.vim&lt;/code&gt; that I don't want to load for a &lt;code&gt;filetype&lt;/code&gt; I have called &lt;code&gt;cheat&lt;/code&gt; (for cheatsheets). The smartcom plugin has tab completion that I don't need for my cheat files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried moving the plugin to the &lt;code&gt;/after/plugin&lt;/code&gt; directory and added:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:loaded_smartcom = 1&#xA;let loaded_smartcom = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to the &lt;code&gt;ftplugin/cheat.vim&lt;/code&gt; file because The &lt;code&gt;smartcom.vim&lt;/code&gt; file has this in it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; If already loaded, we're done...&#xA;if exists(&quot;loaded_smartcom&quot;)&#xA;  finish&#xA;endif&#xA;let loaded_smartcom = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also removed a &lt;code&gt;runtime plugin/smartcom.vim&lt;/code&gt; line that was in my &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Despite all this, the plugin still has the tab completion feature. If I remove the plugin totally, cheat files no longer have tab completion so it's definitely this plugin creating the feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything else I can do or try?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="2021" LastEditDate="2019-04-02T15:49:17.333" LastActivityDate="2019-04-02T15:57:17.683" Title="Turning off global plugin for a filetype" Tags="|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19414" PostTypeId="2" ParentId="19413" CreationDate="2019-04-02T15:57:17.683" Score="2" Body="&lt;p&gt;This is not the way things are meant to interact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Global plugins are by default independent of the current filetype, and always loaded before any ftplugins. Beside, we can alternatively edit files of filetypes &lt;code&gt;{ft1}&lt;/code&gt; and &lt;code&gt;{ft2}&lt;/code&gt;, there is no way to magically disable and re-enable a global plugin when the filetype changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want more control, you'd need to fix the global plugin to do nothing for a given filetype. It's not possible to push such modifications on all plugins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, what you can do, in your case, is may be to add a buffer-local mapping in a &lt;code&gt;cheat&lt;/code&gt; ftplugin on &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; for it to behave as you desire.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2019-04-02T15:57:17.683" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19415" PostTypeId="1" AcceptedAnswerId="19417" CreationDate="2019-04-02T16:04:35.727" Score="0" ViewCount="410" Body="&lt;p&gt;I use default colorscheme for Vim since I just love to have consistency throughout my terminal. One thing I don't love though is the colour of number lines, bright yellow doesn't suit it. Is there any way that I can change it and leave the rest of colours as they are? Or is there a way I can make my own colorscheme that uses 16 ANSII colours of my terminal? &lt;a href=&quot;https://i.stack.imgur.com/eQl2V.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eQl2V.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21555" LastActivityDate="2019-04-02T17:22:19.880" Title="How to change default's colorscheme colours" Tags="|colorscheme|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19416" PostTypeId="1" AcceptedAnswerId="19418" CreationDate="2019-04-02T17:18:31.817" Score="1" ViewCount="133" Body="&lt;p&gt;I am trying to use a colorized parenthesis plugin. However, the colors don't match my current color scheme. The help page mentions ways to change the colors, but I don't know which magical words I have to use for the colors of my current color scheme. Is there some way I can call a getter in my vimrc for the colors of the color scheme applied?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:rainbow_conf = {&#xA;\   'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],&#xA;\}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Something like?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:rainbow_conf = {&#xA;\   'guifgs': [colorscheme.getcolor(1), colorscheme.getcolor(2), colorscheme.getcolor(3), colorscheme.getcolor(4)],&#xA;\}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18386" LastActivityDate="2019-04-02T17:26:17.617" Title="Retrieve color scheme colors to use for other plugin setting" Tags="|vimrc|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19417" PostTypeId="2" ParentId="19415" CreationDate="2019-04-02T17:22:19.880" Score="4" Body="&lt;p&gt;As @klaus mentioned, you want to change the highlight for the group &lt;code&gt;LineNr&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;.vimrc&lt;/code&gt;, you can change the color of a group with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight LineNr ctermfg=33&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ctermfg&lt;/code&gt; is the variable for a foreground color when using Vim in terminal. There are other options (background, bold, italic...), all described in the highlight help (&lt;code&gt;:h highlight&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The number (33 in my example) is the color (from 0 to 255), you can find the list of available colors here for example: &lt;a href=&quot;https://github.com/guns/xterm-color-table.vim&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/guns/xterm-color-table.vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-04-02T17:22:19.880" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19418" PostTypeId="2" ParentId="19416" CreationDate="2019-04-02T17:26:17.617" Score="1" Body="&lt;p&gt;You may get the colors in effect for a particular highlight group using &lt;code&gt;synIDattr&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo synIDattr(hlID('Normal'), 'fg')&#xA;#ffff00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other values are &lt;code&gt;bg&lt;/code&gt; for background, &lt;code&gt;fg#&lt;/code&gt;, &lt;code&gt;bg#&lt;/code&gt;, for hex color in gui, and &lt;code&gt;sp&lt;/code&gt; (underline/undercurl).  See &lt;code&gt;:help synIDattr(&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-04-02T17:26:17.617" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19419" PostTypeId="1" AcceptedAnswerId="19421" CreationDate="2019-04-02T22:05:01.757" Score="4" ViewCount="389" Body="&lt;p&gt;Unlike many people who are looking for this, or a similar sort of feature, it's not actually the file &lt;em&gt;size&lt;/em&gt; I care about, I just find myself needing to deal with a very specific section of a file - maybe a couple hundred lines or less, so typically more than what fits on a screen at a reasonable font size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thought that I considered is creating a couple of marks, yanking that section, editing in a new split or tab, and then putting the edited text back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's kind of a hack, though, and doesn't make it so I can easily just save the text and run a command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Manual folding could work for me, if I could make it so searches skip over the folds and they never open without a &lt;code&gt;zO&lt;/code&gt; or something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any kind of way to edit a partial file in vim like that, or would I have to resort to some sweet hacks?&lt;/p&gt;&#xA;" OwnerUserId="5574" LastActivityDate="2019-04-02T22:33:43.997" Title="Is there a way to edit only part of a file?" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19420" PostTypeId="2" ParentId="19405" CreationDate="2019-04-02T22:21:32.770" Score="8" Body="&lt;p&gt;You can adapt &lt;a href=&quot;https://vi.stackexchange.com/questions/16708/switching-buffers-in-vi-while-skipping-any-terminal-in-vi-8-1&quot;&gt;either of the answers here&lt;/a&gt; to skip the quickfix:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BSkipQuickFix(command)&#xA;  let start_buffer = bufnr('%')&#xA;  execute a:command&#xA;  while &amp;amp;buftype ==# 'quickfix' &amp;amp;&amp;amp; bufnr('%') != start_buffer&#xA;    execute a:command&#xA;  endwhile&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;Tab&amp;gt; :call BSkipQuickFix(&quot;bn&quot;)&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;S-Tab&amp;gt; :call BSkipQuickFix(&quot;bp&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-04-02T22:28:13.340" LastActivityDate="2019-04-02T22:28:13.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19421" PostTypeId="2" ParentId="19419" CreationDate="2019-04-02T22:33:43.997" Score="10" Body="&lt;p&gt;You could try the terrific &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn&quot; rel=&quot;noreferrer&quot;&gt;NarrwRgn plugin&lt;/a&gt; by our very own &lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;Christian Brabandt&lt;/a&gt;, which has always worked very well for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just select the lines you're interested in in visual mode, and then type &lt;code&gt;:NR&lt;/code&gt; to open a new buffer containing just that area. Any changes you &lt;code&gt;:write&lt;/code&gt; in the new buffer will appear instantly in the original, and you can simply close it when you're done: &lt;code&gt;:q&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-04-02T22:33:43.997" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19422" PostTypeId="1" AcceptedAnswerId="19423" CreationDate="2019-04-03T06:38:53.587" Score="2" ViewCount="1039" Body="&lt;p&gt;I have a vimscript function that needs to call Python code, depending on what mode I'm in. Some posts here recommend to use &lt;code&gt;:mode()&lt;/code&gt; such as &lt;a href=&quot;https://vi.stackexchange.com/questions/10396/within-a-function-is-there-a-way-to-determine-if-vim-is-in-insert-mode/10398&quot;&gt;Within a function, Is there a way to determine if vim is in insert mode?&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/19247/how-to-get-the-current-mode-in-vim&quot;&gt;How to get the current mode in vim?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem that I'm having is that &lt;code&gt;mode()&lt;/code&gt; doesn't work as expected for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you do this ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Test()&#xA;echo mode()&#xA;endfunction&#xA;&#xA;vnoremap &amp;lt;leader&amp;gt;v :call Test()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then go into visual mode or visual block mode or visual line mode (&lt;code&gt;v&lt;/code&gt;, &lt;code&gt;&amp;lt;ctrl-v&amp;gt;&lt;/code&gt;, &lt;code&gt;V&lt;/code&gt;) and run &lt;code&gt;&amp;lt;leader&amp;gt;v&lt;/code&gt;, this function prints &quot;n&quot; for all three.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I wanted to do was to, in python, call &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim.command('let l:mode = mode()')&#xA;mode = vim.eval('l:mode')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then use the &lt;code&gt;mode&lt;/code&gt; variable for my script but because it always seems to return &quot;n&quot;, this hasn't worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any advice is appreciated&lt;/p&gt;&#xA;" OwnerUserId="16073" LastEditorUserId="16073" LastEditDate="2019-04-03T06:48:03.240" LastActivityDate="2020-02-02T08:54:33.617" Title="Get the current mode in vimscript/Python" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19423" PostTypeId="2" ParentId="19422" CreationDate="2019-04-03T07:13:33.213" Score="4" Body="&lt;p&gt;As the doc &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#mode%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h mode()&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    [mode()] is useful in the 'statusline' option or when used&#xA;    with |remote_expr()| In most other places it always returns&#xA;    &quot;c&quot; or &quot;n&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on what your code should do, you could use an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test()&#xA;    echo mode()&#xA;endfunction&#xA;&#xA;xnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;v Test() &quot; echos 'v'&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;v Test() &quot; echo 'n'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think the problem comes from the fact that when your mapping uses &lt;code&gt;:&lt;/code&gt; to switch to command line it exits visual mode and returns a different mode from what you are looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe you would be interested instead in &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#visualmode%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h visualmode()&lt;/code&gt;&lt;/a&gt; which allows you to get the last visual mode used in the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Otherwise I think your best bet is to create two mappings in normal mode and in visual mode and to give them the mode as parameter like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test(mode)&#xA;    echo a:mode&#xA;endfunction&#xA;&#xA;xnoremap &amp;lt;leader&amp;gt;v :call Test('v')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;v :call Test('n')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you don't need to rely on &lt;code&gt;mode()&lt;/code&gt; to know in which mode you are.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-04-03T07:13:33.213" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19424" PostTypeId="1" CreationDate="2019-04-03T09:35:31.353" Score="0" ViewCount="380" Body="&lt;p&gt;I have in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi SpellBad ctermfg=7 ctermbg=0* cterm=underline&#xA;hi Nonascii ctermbg=Black ctermfg=Red cterm=none&#xA;hi [...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some config files I need to look at contains so many unknown words that the highlighting defined in that highlighting group actually becomes a hindrance for visualization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not looking for &lt;code&gt;:syntax off&lt;/code&gt; followed by &lt;code&gt;:syntax on&lt;/code&gt;. Obviously for any highlight group I could just issue &lt;code&gt;:hi clear highlight-group&lt;/code&gt;. But then I'd be left with how to restore highlighting within the same session, without having to type in the exact line as it stands in the &lt;code&gt;.vimrc&lt;/code&gt;  file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thoughts on how to selectively (exclusively) turn off and back on specific highlight groups, within a &lt;code&gt;vim&lt;/code&gt; session, would be appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Edit:&lt;/em&gt;&lt;/strong&gt;&lt;BR&gt;&#xA;Just to be precise, I mean the question to be more general than just its specialization to the SpellBad highlight group. I have a few other highlight groups that I need to turn off and on from within a session.&lt;/p&gt;&#xA;" OwnerUserId="4547" LastEditorUserId="4547" LastEditDate="2019-04-03T17:35:01.137" LastActivityDate="2019-04-03T17:35:01.137" Title="How to selectively turn specific highlight group on and off from vim session?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19425" PostTypeId="2" ParentId="19424" CreationDate="2019-04-03T13:53:45.923" Score="1" Body="&lt;p&gt;Turn of spell checking, as suggested in the comments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nospell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;unimpaired&lt;/a&gt;: &lt;code&gt;yos&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-04-03T13:53:45.923" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19426" PostTypeId="1" CreationDate="2019-04-03T14:33:51.390" Score="1" ViewCount="840" Body="&lt;p&gt;What possible downsides are there to using &lt;code&gt;&amp;lt;C-g&amp;gt;u&lt;/code&gt; on a regular basis to break the undo chain in small chunks, e.g. after every line-break or after every sentence? Has someone experiences with this?&lt;/p&gt;&#xA;" OwnerUserId="19878" LastEditorUserId="51" LastEditDate="2019-04-16T07:37:28.877" LastActivityDate="2019-04-16T07:37:28.877" Title="Automatic &lt;C-g&gt;u to break undo block?" Tags="|undo-redo|" AnswerCount="1" CommentCount="4" ClosedDate="2019-04-16T07:42:48.127" ContentLicense="CC BY-SA 4.0" />
  <row Id="19427" PostTypeId="1" AcceptedAnswerId="19428" CreationDate="2019-04-03T14:43:06.963" Score="1" ViewCount="158" Body="&lt;p&gt;I have big portions of code where functions are formatted with the opening curly brace on the next line, like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function foo()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to figure out how to search / replace in order to change it to this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function foo(){&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19461" LastEditorUserId="1292" LastEditDate="2019-04-04T07:27:55.227" LastActivityDate="2019-04-04T07:34:16.980" Title="How can I format a function declaration to force curly brace at the end of the line?" Tags="|regular-expression|substitute|formatting|filetype-php|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19428" PostTypeId="2" ParentId="19427" CreationDate="2019-04-03T14:49:32.747" Score="4" Body="&lt;p&gt;You can use the new line character is your search (&lt;code&gt;\n&lt;/code&gt; for linux):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/)\s*\n{/){/c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replaces &lt;code&gt;)\s*\n{&lt;/code&gt; into &lt;code&gt;){&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;c&lt;/code&gt; flag at the end will ask you to confirm before each replacement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Another solution would be to use the join line feature (&lt;code&gt;J&lt;/code&gt;) with the &lt;code&gt;g&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/function [^{]\+$/join&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will execute the command &lt;code&gt;join&lt;/code&gt; on every line matching the pattern &lt;code&gt;function [^{]\+$&lt;/code&gt; (&quot;function&quot; followed by anything without a &lt;code&gt;{&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will however put a space by default between &lt;code&gt;)&lt;/code&gt; and &lt;code&gt;{&lt;/code&gt;, it can be changed by running the following &lt;em&gt;before&lt;/em&gt; the g command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nojoinspaces&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21621" LastEditorUserId="21621" LastEditDate="2019-04-04T07:34:16.980" LastActivityDate="2019-04-04T07:34:16.980" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19429" PostTypeId="1" CreationDate="2019-04-03T17:42:49.063" Score="2" ViewCount="372" Body="&lt;p&gt;I am looking to jump automatically to the last position in any file that I open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have in my ~/.vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost *                                                                                                                                                                                   &#xA;  \ if line(&quot;'\&quot;&quot;) &amp;gt; 0 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) |&#xA;    \ exe &quot;normal! g`\&quot;&quot; |&#xA;  \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine if I open a file using the &lt;code&gt;vim&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I write &lt;code&gt;vim .&lt;/code&gt; in a directory to load netrw and use &lt;code&gt;t&lt;/code&gt; to open a file in a new tab, the cursor appears at the top of the file and not at the last position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then have to use &lt;code&gt;`&quot;&lt;/code&gt; to jump to the last position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to jump to the last position when using netrw and &lt;code&gt;t&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="21642" LastActivityDate="2019-04-03T17:42:49.063" Title="Jump to last position when using vim netrw to open a file" Tags="|vimrc|vimscript|autocmd|netrw|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19430" PostTypeId="2" ParentId="14150" CreationDate="2019-04-04T05:47:32.343" Score="2" Body="&lt;p&gt;I've added the following to my .vimrc to add the proper PEP 8 indentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.py&#xA;    \ set tabstop=4 |&#xA;    \ set softtabstop=4 |&#xA;    \ set shiftwidth=4 |&#xA;    \ set textwidth=79 |&#xA;    \ set expandtab |&#xA;    \ set autoindent |&#xA;    \ set fileformat=unix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This setting give me the standard four spaces when I hit tab. It also ensure the line length doesn’t go beyond 80 characters and the file will be stored in a Unix format. To insert space characters whenever the tab key is pressed I've used the &lt;code&gt;set expandtab&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21646" LastEditorUserId="21646" LastEditDate="2019-04-04T07:46:46.640" LastActivityDate="2019-04-04T07:46:46.640" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19431" PostTypeId="2" ParentId="19410" CreationDate="2019-04-04T08:46:32.897" Score="1" Body="&lt;p&gt;I don't think those exceptions apply because the end of the motion is not in column 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h WORD&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Another special case: When using the &quot;w&quot; motion in combination with an&#xA;  operator and the last word moved over is at the end of a line, the end of&#xA;  that word becomes the end of the operated text, not the first word in the&#xA;  next line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;One solution is to do &lt;code&gt;Jwd0&lt;/code&gt; or &lt;code&gt;Jwd|&lt;/code&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="712" LastEditorUserId="712" LastEditDate="2019-04-05T16:34:26.117" LastActivityDate="2019-04-05T16:34:26.117" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19432" PostTypeId="1" AcceptedAnswerId="19538" CreationDate="2019-04-04T14:42:23.343" Score="1" ViewCount="1260" Body="&lt;p&gt;I use vim for prose and and code, and when it comes to prose I use spelling a lot to help me out. I have it set up and already, and I'm already working with &lt;code&gt;z=, zg, zw, [s&lt;/code&gt; , and &lt;code&gt;]s&lt;/code&gt; to work with spelling. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is, I write in both Portuguese and English, and I want some words to be valid for both languages and still be able to add specific new words to just one language, and have spelling work right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I go about setting this up?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="14568" LastEditorUserId="1841" LastEditDate="2019-04-04T15:26:09.097" LastActivityDate="2019-04-11T20:28:33.310" Title="How to setup spelling for same words in different languages?" Tags="|neovim|spell-checking|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19434" PostTypeId="2" ParentId="19410" CreationDate="2019-04-04T23:59:44.917" Score="3" Body="&lt;p&gt;some contents of :help WORD&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Another special case: When using the &quot;w&quot; motion in combination with an&#xA;operator and the last word moved over is at the end of a line, the end of&#xA;that word becomes the end of the operated text, not the first word in the&#xA;next line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is another special case if there exists trailing space after current word:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;word0           &#xA;^       ^^^^^^some trailing space&#xA;word1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assume cursor at &quot;w&quot; of &quot;word0&quot;, dw will delete all trailing space after &quot;word0&quot;. So to be precise, it should be &quot;the end of line of current word becomes the end of operation text&quot;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-04-04T23:59:44.917" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19435" PostTypeId="1" CreationDate="2019-04-05T03:12:02.910" Score="6" ViewCount="1438" Body="&lt;p&gt;For themes like One or PaperColor, there are dark and light versions. For dark or light theme, I usually add my own customizations like bracket color, comment color... etc.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to combine them so that everytime I set background=dark or light, with an if else statement. I tried the following but it doesn't work.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (set background=dark)&#xA;    &quot;&quot;&quot; my own code here&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please let me know how to go about this and thank you.   &lt;/p&gt;&#xA;" OwnerUserId="21038" LastActivityDate="2019-04-05T06:34:55.653" Title="How to set if else for vim's &quot;set background = &quot; for light and dark colorschemes?" Tags="|vimrc|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19436" PostTypeId="2" ParentId="19435" CreationDate="2019-04-05T03:15:23.647" Score="11" Body="&lt;pre&gt;&lt;code&gt;if &amp;amp;background ==# 'dark'&#xA;    &quot; balabala&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&amp;amp;background get value of 'background' option, check &lt;code&gt;:help let-&amp;amp;&lt;/code&gt;&lt;br&gt;&#xA;==# compare strings case sensitively, check &lt;code&gt;:help ==#&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-05T06:34:55.653" LastActivityDate="2019-04-05T06:34:55.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19437" PostTypeId="1" CreationDate="2019-04-05T05:23:17.313" Score="2" ViewCount="1235" Body="&lt;p&gt;I'm working with typescript now, and I got this in my &lt;code&gt;~/.ctags&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--langdef=typescript&#xA;--langmap=typescript:.ts&#xA;--regex-typescript=/^[ \t]*(export[ \t]+([a-z]+[ \t]+)?)?class[ \t]+([a-zA-Z0-9_$]+)/\3/c,classes/&#xA;--regex-typescript=/^[ \t]*(declare[ \t]+)?namespace[ \t]+([a-zA-Z0-9_$]+)/\2/c,modules/&#xA;--regex-typescript=/^[ \t]*(export[ \t]+)?module[ \t]+([a-zA-Z0-9_$]+)/\2/n,modules/&#xA;--regex-typescript=/^[ \t]*(export[ \t]+)?(default[ \t]+)?(async[ \t]+)?function(\*)?[ \t]+([a-zA-Z0-9_$]+)/\5/f,functions/&#xA;--regex-typescript=/^[ \t]*export[ \t]+(var|let|const)[ \t]+([a-zA-Z0-9_$]+)/\2/v,variables/&#xA;--regex-typescript=/^[ \t]*(var|let|const)[ \t]+([a-zA-Z0-9_$]+)[ \t]*=[ \t]*function[ \t]*[*]?[ \t]*\(\)/\2/v,varlambdas/&#xA;--regex-typescript=/^[ \t]*(export[ \t]+)?(public|protected|private)[ \t]+(static[ \t]+)?(abstract[ \t]+)?(((get|set)[ \t]+)|(async[ \t]+[*]*[ \t]*))?([a-zA-Z1-9_$]+)/\9/m,members/&#xA;--regex-typescript=/^[ \t]*(export[ \t]+)?interface[ \t]+([a-zA-Z0-9_$]+)/\2/i,interfaces/&#xA;--regex-typescript=/^[ \t]*(export[ \t]+)?type[ \t]+([a-zA-Z0-9_$]+)/\2/t,types/&#xA;--regex-typescript=/^[ \t]*(export[ \t]+)?enum[ \t]+([a-zA-Z0-9_$]+)/\2/e,enums/&#xA;--regex-typescript=/^[ \t]*import[ \t]+([a-zA-Z0-9_$]+)/\1/I,imports/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and jumping to definition etc works just fine, but when i show my tags bar, nothing is there!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for reference, here is my &lt;a href=&quot;https://gist.github.com/abbood/cad3d31bb1804a05796942e5916929b9&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimrc file&lt;/a&gt;, and my &lt;a href=&quot;https://gist.github.com/abbood/7b5ef4229b955ba73afe2b7047ab23d0&quot; rel=&quot;nofollow noreferrer&quot;&gt;ctags file&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xHWxQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xHWxQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;i added this to my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tagbar_type_typescript = {                                                  &#xA;  \ 'ctagsbin' : 'tstags',                                                        &#xA;  \ 'ctagsargs' : '-f-',                                                           &#xA;  \ 'kinds': [                                                                     &#xA;    \ 'e:enums:0:1',                                                               &#xA;    \ 'f:function:0:1',                                                            &#xA;    \ 't:typealias:0:1',                                                           &#xA;    \ 'M:Module:0:1',                                                              &#xA;    \ 'I:import:0:1',                                                              &#xA;    \ 'i:interface:0:1',                                                           &#xA;    \ 'C:class:0:1',                                                               &#xA;    \ 'm:method:0:1',                                                              &#xA;    \ 'p:property:0:1',                                                            &#xA;    \ 'v:variable:0:1',                                                            &#xA;    \ 'c:const:0:1',                                                              &#xA;  \ ],                                                                            &#xA;  \ 'sort' : 0                                                                    &#xA;\ }   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also found out that when i run tagbar, I get this error message:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Necyq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Necyq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Tagbar: could not execute ctags for /path/to/file.ts!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;note: my &lt;em&gt;same&lt;/em&gt; tagbar setup works perfectly fine for my php files:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zxfr4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zxfr4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="14510" LastEditDate="2019-04-05T07:38:32.487" LastActivityDate="2019-09-02T09:01:40.180" Title="ctags works but not for tagbar" Tags="|ctags|plugin-tagbar|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19438" PostTypeId="2" ParentId="19426" CreationDate="2019-04-05T05:47:25.300" Score="1" Body="&lt;p&gt;For markdown I have the following mappings in &lt;code&gt;~/.vim/after/ftplugin/markdown.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Break undo sequence at punctuation marks&#xA;inoremap &amp;lt;buffer&amp;gt; . .&amp;lt;c-g&amp;gt;u&#xA;inoremap &amp;lt;buffer&amp;gt; ! !&amp;lt;c-g&amp;gt;u &#xA;inoremap &amp;lt;buffer&amp;gt; ? ?&amp;lt;c-g&amp;gt;u&#xA;inoremap &amp;lt;buffer&amp;gt; , ,&amp;lt;c-g&amp;gt;u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't think that this makes a difference in my workflow, because I seldom use undo on text that I just typed. It is more likely that I undo a formatting, deletion or copy command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I don't see any negative impact from this.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-04-05T05:47:25.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19439" PostTypeId="1" CreationDate="2019-04-05T08:13:53.543" Score="3" ViewCount="425" Body="&lt;p&gt;I am starting to use &lt;code&gt;quickfix&lt;/code&gt; to handle my latex compilation process. I found the &lt;code&gt;vim-latex&lt;/code&gt; package (&lt;a href=&quot;https://github.com/vim-latex/vim-latex&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim-latex/vim-latex&lt;/a&gt;) but I am only interested in the quickfix part, and I want to use my own Makefile, so I merely copied &lt;a href=&quot;https://github.com/vim-latex/vim-latex/blob/master/compiler/tex.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim-latex/vim-latex/blob/master/compiler/tex.vim&lt;/a&gt; to my &lt;code&gt;~/.vim/compiler/&lt;/code&gt; and commented out the part that sets &lt;code&gt;makeprg&lt;/code&gt;. I also modified&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;errorfile ==# ''  ||  &amp;amp;errorfile ==# 'errors.err'&#xA;    execute 'set errorfile=' . fnameescape(Tex_GetMainFileName(':p:r') . '.log')&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;errorfile ==# ''  ||  &amp;amp;errorfile ==# 'errors.err'&#xA;    execute 'set errorfile=' . fnameescape(expand('%:p:r') . '.log')&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also put&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;compiler tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my &lt;code&gt;~/.vim/ftplugin/tex.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quickfix otherwise works fine, a sample quickfix list looks like,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;(a lot of messages from latex log file)  &lt;br /&gt;&#xA;|125 error| Undefined control sequence. \R  &lt;br /&gt;                           ./abstract.tex|| ...  &lt;br /&gt;&#xA;(more messages from latex log file) &lt;br /&gt;&#xA;|197 warning| ... &lt;br /&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;where the &lt;code&gt;error&lt;/code&gt; is marked with red font and the &lt;code&gt;./abstract.tex&lt;/code&gt; is marked with light green font. If I go to the buffer containing the source file and execute &lt;code&gt;:cn&lt;/code&gt;, it jumps to the correct line in the source file with the next error/warning, so I believe &lt;code&gt;errorformat&lt;/code&gt; is set correctly. &lt;code&gt;:cn&lt;/code&gt; also works correctly in the quickfix list window, However, pressing &lt;kbd&gt;Enter&lt;/kbd&gt; in the quickfix list window around &lt;code&gt;125 error&lt;/code&gt; or &lt;code&gt;197 warning&lt;/code&gt; does not seem to have any effect. Pressing &lt;kbd&gt;Enter&lt;/kbd&gt; around &lt;code&gt;./abstract.tex||&lt;/code&gt; does work though. This is a minor issue that I can live with, but I would still like to know any fix to it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, &lt;code&gt;:verbose nmap &amp;lt;CR&amp;gt;&lt;/code&gt; says &quot;No mapping found&quot; in the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My second and main question is as in the sample quickfix list above, there are errors as well as warnings. I am wondering whether there is a way to jump to the next error ignoring all the warnings, and vice versa. In the terminology of &lt;code&gt;quickfix&lt;/code&gt;, is there a way to jump to the next error of a certain type (&lt;code&gt;%t&lt;/code&gt; in &lt;code&gt;errorformat&lt;/code&gt;)? The simple command &lt;code&gt;:cn&lt;/code&gt; navigates through all the errors, regardless of the type.&lt;/p&gt;&#xA;" OwnerUserId="15451" LastActivityDate="2019-04-05T08:13:53.543" Title="Quickfix go to next error of specific type" Tags="|quickfix|plugin-vim-latex|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19440" PostTypeId="2" ParentId="19437" CreationDate="2019-04-05T08:13:56.567" Score="1" Body="&lt;p&gt;The bug was happening b/c I didn't have tstags executive installed..&#xA;so i got it from &lt;a href=&quot;https://github.com/Perlence/tstags&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and built it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/Perlence/tstags.git&#xA;&#xA;npm install -g&#xA;$home/.nvm/versions/node/v8.1.0/bin/tstags -&amp;gt; $home/.nvm/versions/node/v8.1.0/lib/node_modules/tstags/bin/tstags.js&#xA;+ tstags@0.1.0&#xA;added 14 packages in 3.518s&#xA;&#xA;$ which tstags&#xA;$home/.nvm/versions/node/v8.1.0/bin/tstags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it worked like a charm!&lt;/p&gt;&#xA;" OwnerUserId="14510" LastActivityDate="2019-04-05T08:13:56.567" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19442" PostTypeId="1" AcceptedAnswerId="19445" CreationDate="2019-04-05T09:47:33.533" Score="2" ViewCount="328" Body="&lt;p&gt;I'd like to write the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Normal(command)&#xA;    execute &quot;normal!&quot; a:command&#xA;endfunction&#xA;call Normal(&quot;\&amp;lt;C-O&amp;gt;&quot;)&#xA;call Normal(&quot;\&amp;lt;C-I&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first call to Normal succeeds, but the second throws an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E471: Argument required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Indeed, you get the same error if you enter the command &lt;code&gt;:norm! ^I&lt;/code&gt; with the keystrokes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;!&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Ctrl-I&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a vague idea that the problem might be something to do with the fact that a &lt;code&gt;Tab&lt;/code&gt; character is whitespace, but I'd like to know more precisely what's going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.B. I've already worked around the issue by adding a count &lt;code&gt;&quot;1\&amp;lt;C-I&amp;gt;&quot;&lt;/code&gt;, so this is purely out of curiosity.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-04-05T09:56:08.783" LastActivityDate="2019-04-05T12:10:02.137" Title="Why can't I use a literal Tab as the {commands} for :normal?" Tags="|vimscript|tab-characters|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19443" PostTypeId="1" CreationDate="2019-04-05T11:12:26.537" Score="0" ViewCount="914" Body="&lt;p&gt;when I use:&#xA;&lt;code&gt;vim &amp;lt;file_name&amp;gt;&lt;/code&gt;&#xA;vim opens an empty buffer with no name (&lt;code&gt;[No Name]&lt;/code&gt;).&#xA;But when I type: &lt;code&gt;:tabnew &amp;lt;file_name&amp;gt;&lt;/code&gt; it opens the file properly. I tried &lt;code&gt;:bdelete&lt;/code&gt; to delete the open buffer which didn't help. Here is what &lt;code&gt;:ls&lt;/code&gt; returns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2 %a   &quot;[No Name]&quot;                    line 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What causes this problem? This is my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap ;; &amp;lt;esc&amp;gt;&#xA;inoremap \\ /&#xA;inoremap { {&amp;lt;CR&amp;gt;}&amp;lt;Esc&amp;gt;ko&#xA;inoremap &amp;lt;C-e&amp;gt; &amp;lt;C-o&amp;gt;$&#xA;inoremap &amp;lt;C-a&amp;gt; &amp;lt;C-o&amp;gt;0&#xA;inoremap &amp;lt;C-M-f&amp;gt; &amp;lt;C-o&amp;gt;&amp;lt;C-f&amp;gt;i&#xA;inoremap &amp;lt;C-M-b&amp;gt; &amp;lt;C-o&amp;gt;&amp;lt;C-b&amp;gt;i&#xA;inoremap &amp;lt;C-x&amp;gt; &amp;lt;Delete&amp;gt;&#xA;inoremap &amp;lt;C-u&amp;gt; &amp;lt;C-o&amp;gt;u&#xA;inoremap &amp;lt;C-k&amp;gt; &amp;lt;C-o&amp;gt;gk&#xA;inoremap &amp;lt;C-h&amp;gt; &amp;lt;Left&amp;gt;&#xA;inoremap &amp;lt;C-l&amp;gt; &amp;lt;Right&amp;gt;&#xA;inoremap &amp;lt;C-j&amp;gt; &amp;lt;C-o&amp;gt;gj&#xA;inoremap &amp;lt;C-M-x&amp;gt; :call delete(expand('%')) | bdelete!&#xA;&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'joshdick/onedark.vim'&#xA;Plug 'tpope/vim-eunuch'&#xA;&#xA;call plug#end()&#xA;&#xA;colorscheme onedark&#xA;&#xA;if has(&quot;autocmd&quot;)&#xA;  au InsertEnter * silent execute &quot;!sed -i.bak -e 's/TERMINAL_CURSOR_SHAPE_BLOCK/TERMINAL_CURSOR_SHAPE_IBEAM/' ~/.config/xfce4/terminal/terminalrc&quot;&#xA;  au InsertLeave * silent execute &quot;!sed -i.bak -e 's/TERMINAL_CURSOR_SHAPE_IBEAM/TERMINAL_CURSOR_SHAPE_BLOCK/' ~/.config/xfce4/terminal/terminalrc&quot;&#xA;  au VimLeave * silent execute &quot;!sed -i.bak -e 's/TERMINAL_CURSOR_SHAPE_IBEAM/TERMINAL_CURSOR_SHAPE_BLOCK/' ~/.config/xfce4/terminal/terminalrc&quot;&#xA;endif&#xA;&#xA;set nocompatible&#xA;&#xA;set number&#xA;set cursorline&#xA;hi cursorline ctermbg=none&#xA;&#xA;set expandtab&#xA;set smarttab&#xA;set shiftwidth=4&#xA;set tabstop=4&#xA;&#xA;set lbr&#xA;set tw=500&#xA;&#xA;set ai&#xA;set si&#xA;&#xA;set autoread&#xA;&#xA;command W w !sudo tee % &amp;gt; /dev/null&#xA;&#xA;function! VisualSelection(direction, extra_filter) range&#xA;    let l:saved_reg = @&quot;&#xA;    execute &quot;normal! vgvy&quot;&#xA;&#xA;    let l:pattern = escape(@&quot;, &quot;\\/.*'$^~[]&quot;)&#xA;    let l:pattern = substitute(l:pattern, &quot;\n$&quot;, &quot;&quot;, &quot;&quot;)&#xA;&#xA;    if a:direction == 'gv'&#xA;        call CmdLine(&quot;Ack '&quot; . l:pattern . &quot;' &quot; )&#xA;    elseif a:direction == 'replace'&#xA;        call CmdLine(&quot;%s&quot; . '/'. l:pattern . '/')&#xA;    endif&#xA;&#xA;    let @/ = l:pattern&#xA;    let @&quot; = l:saved_reg&#xA;endfunction&#xA;&#xA;vnoremap &amp;lt;silent&amp;gt; * :&amp;lt;C-u&amp;gt;call VisualSelection('', '')&amp;lt;CR&amp;gt;/&amp;lt;C-R&amp;gt;=@/&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; # :&amp;lt;C-u&amp;gt;call VisualSelection('', '')&amp;lt;CR&amp;gt;?&amp;lt;C-R&amp;gt;=@/&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&#xA;map &amp;lt;leader&amp;gt;te :tabedit &amp;lt;c-r&amp;gt;=expand(&quot;%:p:h&quot;)&amp;lt;cr&amp;gt;/&#xA;&#xA;set so=7&#xA;&#xA;set smartcase&#xA;&#xA;set noerrorbells&#xA;set novisualbell&#xA;&#xA;set nobackup&#xA;set nowb&#xA;set noswapfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21098" LastEditorUserId="19763" LastEditDate="2019-04-05T12:01:27.660" LastActivityDate="2019-04-05T17:00:08.543" Title="Vim opens an empty buffer when I try to open an existing file" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19444" PostTypeId="2" ParentId="19432" CreationDate="2019-04-05T11:19:16.727" Score="0" Body="&lt;p&gt;Vim allows you to manipulate multiple spellfiles and languages in a single buffer, so it's very flexible. Your best bet is to read &lt;code&gt;:help spell.txt&lt;/code&gt; and then come up with a system that works best for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how &lt;em&gt;I&lt;/em&gt; would do it. Probably your ideal solution will be slightly different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You've said that you only use a single language per buffer, so I set a single value for &lt;code&gt;'spelllang'&lt;/code&gt;, but I set two values for &lt;code&gt;'spellfile'&lt;/code&gt; to facilitate adding words to both languages easily: the &lt;code&gt;zg&lt;/code&gt; command will then add to the current language's &lt;code&gt;spellfile&lt;/code&gt;, and the &lt;code&gt;2zg&lt;/code&gt; command will add to the alternate language's &lt;code&gt;spellfile&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I set up a &lt;code&gt;:LanguageToggle&lt;/code&gt; command for switching languages, and a &lt;code&gt;&amp;lt;leader&amp;gt;zg&lt;/code&gt; mapping for adding a word to both languages at once.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set default language&#xA;set spelllang=en_gb&#xA;set spellfile=$HOME/.vim/spell/en.utf-8.add,$HOME/.vim/spell/it.utf-8.add&#xA;&#xA;function! LanguageToggle() abort&#xA;  if &amp;amp;l:spelllang == &quot;en_gb&quot;&#xA;    &quot; Switch to Italian&#xA;    setlocal spelllang=it&#xA;    setlocal spellfile=$HOME/.vim/spell/it.utf-8.add,$HOME/.vim/spell/en.utf-8.add&#xA;    echom &quot;Switching to Italian&quot;&#xA;  else&#xA;    &quot; Switch to English&#xA;    setlocal spelllang=en_gb&#xA;    setlocal spellfile=$HOME/.vim/spell/en.utf-8.add,$HOME/.vim/spell/it.utf-8.add&#xA;    echom &quot;Switching to English&quot;&#xA;  endif&#xA;endfunction&#xA;&#xA;&quot; Switch Languages&#xA;command! LanguageToggle call LanguageToggle()&#xA;&#xA;&quot; Add word to both spellfiles&#xA;nnoremap &amp;lt;leader&amp;gt;zg zg2zg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. I'm using Italian, because I don't speak any Portuguese: you'll want to replace &lt;code&gt;it&lt;/code&gt; with &lt;code&gt;pt&lt;/code&gt; in the above.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-04-05T13:38:28.100" LastActivityDate="2019-04-05T13:38:28.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19445" PostTypeId="2" ParentId="19442" CreationDate="2019-04-05T12:10:02.137" Score="3" Body="&lt;p&gt;If I guess then what's happening is, that the &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; gets expanded to a literal tab before inserting into the typeahead buffer. So Vim basically sees the command &lt;code&gt;:norm! &amp;lt;tab&amp;gt;&lt;/code&gt;, which is not a valid command. I don't know a way around and even escaping did not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What works, is to use the &lt;code&gt;feedkeys()&lt;/code&gt; command, e.g. &lt;code&gt;:call feedkeys(&quot;\t&quot;, 'tn')&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-04-05T12:10:02.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19446" PostTypeId="1" AcceptedAnswerId="19447" CreationDate="2019-04-05T14:08:57.220" Score="10" ViewCount="889" Body="&lt;p&gt;I can source a file, e.g. my &lt;code&gt;vimrc&lt;/code&gt; with &lt;code&gt;:so %&lt;/code&gt; or &lt;code&gt;:so &amp;lt;filename&amp;gt;&lt;/code&gt;. But what do I do when I need to source only part of a file. I want some way to visually select a portion of the file with &lt;code&gt;:h v&lt;/code&gt; and then source it. Kinda like emacs's &lt;code&gt;M-x eval-region&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="24" LastEditDate="2019-05-10T05:30:11.480" LastActivityDate="2019-10-14T21:12:12.113" Title="How to source a part of a file" Tags="|vimscript|visual-mode|register|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19447" PostTypeId="2" ParentId="19446" CreationDate="2019-04-05T14:31:11.097" Score="11" Body="&lt;p&gt;After you've done your Visual selection run this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y:@&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;y&lt;/code&gt; copies the selection to the unnamed register (&lt;code&gt;&quot;&lt;/code&gt;) since we didn't explicitly name a register. Then &lt;code&gt;:@&quot;&lt;/code&gt; executes the contents of that register as Ex commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;help :@&lt;/code&gt; and &lt;a href=&quot;https://stackoverflow.com/questions/20262519/vim-how-to-source-a-part-of-the-buffer&quot;&gt;https://stackoverflow.com/questions/20262519/vim-how-to-source-a-part-of-the-buffer&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="11054" LastEditDate="2019-05-13T09:27:13.327" LastActivityDate="2019-05-13T09:27:13.327" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19448" PostTypeId="2" ParentId="19443" CreationDate="2019-04-05T17:00:08.543" Score="1" Body="&lt;p&gt;As Ralf mentions in the comments, the &lt;code&gt;|&lt;/code&gt; in the last &lt;code&gt;inoremap&lt;/code&gt; actually starts a new command, so when you start editing a file its buffer is deleted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Escape it with a backslash. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-04-05T17:00:08.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19449" PostTypeId="1" CreationDate="2019-04-05T18:10:19.700" Score="1" ViewCount="227" Body="&lt;p&gt;I am a complete vim noob, that tries to get some Snippets with UltiSnips running. My minimal .vimrc is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;&#xA;call plug#begin('~/.vim/plugged')&#xA;Plug 'lervag/vimtex'&#xA;let g:tex_flavor='latex'&#xA;let g:vimtex_view_method='zathura'&#xA;let g:vimtex_quickfix_mode=0&#xA;set conceallevel=1&#xA;let g:tex_conceal='abdmg'&#xA;Plug 'SirVer/ultisnips'&#xA;let g:UltiSnipsExpandTrigger='&amp;lt;tab&amp;gt;'&#xA;let g:UltiSnipsJumpForwardTrigger='&amp;lt;tab&amp;gt;'&#xA;let g:UltiSnipsJumpBackwardTrigger='&amp;lt;s-tab&amp;gt;'&#xA;let g:UltiSnipsEditSplit='vertical'&#xA;Plug 'honza/vim-snippets'&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The preinstalled Snippets worked in :UtilsSnipetEdits. My own Snipets didn't work in my texfile. An example out of my tex Snipets is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet beg &quot;begin{} / end{}&quot; bA&#xA;\begin{$1}&#xA;    $0&#xA;\end{$1}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just tried to delete everything i used before (e.g. YouCompleteMe). Do you have some advice for trouble shooting?&lt;/p&gt;&#xA;" OwnerUserId="21670" LastActivityDate="2019-04-05T18:10:19.700" Title="Trigger doesn't expand my keywords" Tags="|plugin-ultisnips|" AnswerCount="0" CommentCount="7" ClosedDate="2019-04-07T17:12:03.357" ContentLicense="CC BY-SA 4.0" />
  <row Id="19450" PostTypeId="1" CreationDate="2019-04-05T20:45:28.537" Score="1" ViewCount="679" Body="&lt;p&gt;In case it's relevant, this is on MacOS and iTerm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I use key mappings that involve the Meta key, e.g. &lt;code&gt;&amp;lt;M-e&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;auto-pairs plugin&lt;/a&gt; has a keybinding that allows you to convert &lt;code&gt;(|)foo&lt;/code&gt; to &lt;code&gt;(foo)&lt;/code&gt; by pressing &lt;code&gt;&amp;lt;M-e&amp;gt;&lt;/code&gt;, where &lt;code&gt;|&lt;/code&gt; represents cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;iTerm &amp;gt; Preferences &amp;gt; Profiles &amp;gt; Keys&lt;/code&gt;, I have the following options selected:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kePf6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kePf6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So whenever I pressed &lt;code&gt;&amp;lt;M-e&amp;gt;&lt;/code&gt;, the behavior becomes &lt;code&gt;&amp;lt;Esc&amp;gt;e&lt;/code&gt;.  Note that changing the options to &lt;code&gt;Normal&lt;/code&gt; or &lt;code&gt;Meta&lt;/code&gt; in iTerm did not fix this issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end, I was only able to get this plugin command to work by adding the following to my &lt;code&gt;.vimrc&lt;/code&gt;: &lt;code&gt;set &amp;lt;M-e&amp;gt;=^[e&lt;/code&gt;, where &lt;code&gt;^[&lt;/code&gt; is the escape literal achieved by pressing &lt;code&gt;Ctrl-v&lt;/code&gt; followed by &lt;code&gt;Esc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, this is far from an ideal solution, since I'd having to manually set every single mapping involving Meta.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is: &lt;strong&gt;how can I get all keybindings involving the Meta key to perform as expected&lt;/strong&gt;, without needing to manually remap each individual instance?&lt;/p&gt;&#xA;" OwnerUserId="21416" LastEditorUserId="21416" LastEditDate="2019-04-05T21:03:05.470" LastActivityDate="2019-04-05T21:03:05.470" Title="In Vim, how to enable Meta in all keybindings?" Tags="|vimrc|key-bindings|iterm2|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19451" PostTypeId="1" AcceptedAnswerId="19452" CreationDate="2019-04-05T22:17:48.970" Score="2" ViewCount="243" Body="&lt;p&gt;I want to VISUAL select a piece of text character-wise and pass it to an external command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I want to select only the URL from the the text below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abcde www.google.com abcde&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and open it in the default browser.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But after I VISUAL selected it and ran the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call system('xdg-open', @*)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;nothing happened&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the register &lt;code&gt;*&lt;/code&gt; was filled with the selected contents. I tested it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo @*&#xA;www.google.com&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the right command to achieve it?&lt;/p&gt;&#xA;" OwnerUserId="18651" LastActivityDate="2022-06-12T00:30:17.897" Title="Pass character-wise visual selection to an external command" Tags="|visual-mode|external-command|register|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19452" PostTypeId="2" ParentId="19451" CreationDate="2019-04-06T00:01:40.013" Score="5" Body="&lt;p&gt;prototype of system is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;system({cmd} [, {input}])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;according to :help system()&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If {input} is a string it is written to a pipe and passed as&#xA;stdin to the command.  The string is written as-is, line&#xA;separators are not changed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so your final command becomes something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo www.google.com | xdg-open&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which doesn't make sense, as xdg-open doesn't read from stdin. you can call&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo system('xdg-open', @*)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to check error message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At last you can call system like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call system('xdg-open ' . @*)&#xA;                     ^ don't miss space&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-04-06T00:01:40.013" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19453" PostTypeId="1" AcceptedAnswerId="19455" CreationDate="2019-04-06T04:08:42.237" Score="0" ViewCount="61" Body="&lt;p&gt;Take for example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This is a line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How do I check if my cursor is after the first &lt;code&gt;&quot;&lt;/code&gt; character or before it, if I'm in insert mode?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The reason I need this is because I have a &lt;code&gt;insert-mode&lt;/code&gt; keymapping that depends on the &lt;code&gt;:h virtcol()&lt;/code&gt; position of the cursor. If I use &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;, the cursor goes to normal mode and in position &lt;em&gt;after&lt;/em&gt; the character &lt;code&gt;&quot;&lt;/code&gt;, when if I use &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, the cursor goes to normal mode and in position &lt;em&gt;before&lt;/em&gt; the character &lt;code&gt;&quot;&lt;/code&gt;. I could use &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; to distinguish if the insert mode cursor was before or after the character &lt;code&gt;&quot;&lt;/code&gt;. But the problem remains if the line has only one character, i.e. &lt;code&gt;&quot;&lt;/code&gt;. And I have some other reasons I want to use &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My if-else blocks has mainly two cases:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the insert-mode cursor is before any other character, insert a &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Otherwise, insert spaces.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-06T06:14:38.220" Title="Distinguish between the column number of cursor after and before the first character in a line" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19455" PostTypeId="2" ParentId="19453" CreationDate="2019-04-06T06:14:38.220" Score="0" Body="&lt;p&gt;In order to get the column number in &lt;code&gt;:h Insert-mode&lt;/code&gt;, &lt;code&gt;:h i_CTRL-R_=&lt;/code&gt; needs to be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the following function returns a &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; if the cursor has no text before it and required number of spaces otherwise.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SpecialTab() abort&#xA;    if (col('.') == 1) || (matchstr(getline('.'), '\%'.(col('.') - 1).'c.') =~ '\t')&#xA;        return &quot;\&amp;lt;Tab&amp;gt;&quot;&#xA;    else&#xA;        return repeat(&quot;\&amp;lt;Space&amp;gt;&quot;, (&amp;amp;tabstop - (virtcol('.') % &amp;amp;tabstop)) + 1)&#xA;    endif&#xA;endfunction&#xA;inoremap &amp;lt;Tab&amp;gt; &amp;lt;C-R&amp;gt;=SpecialTab()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-06T06:14:38.220" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19456" PostTypeId="1" AcceptedAnswerId="19457" CreationDate="2019-04-06T10:12:10.527" Score="0" ViewCount="623" Body="&lt;p&gt;I am learning Vim, and I find it useful the auto-pairs plugin generates closed paranthesis automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has some issues where I want to type a closed paranthesis but it jumps to the next closed paranthesis. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I wanna ask if it's better to use plugin like that or learn to type the closed paranthesis myself through muscle memory?&lt;/p&gt;&#xA;" OwnerUserId="21678" LastActivityDate="2019-04-06T11:50:05.167" Title="Is it good to use Auto-pairs plugin in Vim?" Tags="|plugin-auto-pairs|" AnswerCount="1" CommentCount="1" ClosedDate="2019-04-07T10:15:13.193" ContentLicense="CC BY-SA 4.0" />
  <row Id="19457" PostTypeId="2" ParentId="19456" CreationDate="2019-04-06T11:16:14.083" Score="0" Body="&lt;p&gt;Assume you are a programmer and a vim beginner:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As a beginner, you need really really a lot of time to familiar with vim built in stuff.&lt;/li&gt;&#xA;&lt;li&gt;There are also some plugins you can't live without them, you need time to choose and familar with them:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;plugin manage plugin&lt;/li&gt;&#xA;&lt;li&gt;resouce navigate plugin&lt;/li&gt;&#xA;&lt;li&gt;code navigate plugin.&lt;/li&gt;&#xA;&lt;li&gt;auto complete plugin&lt;/li&gt;&#xA;&lt;li&gt;snippet plugin&lt;/li&gt;&#xA;&lt;li&gt;syntax check plugin&lt;/li&gt;&#xA;&lt;li&gt;status line plugin&lt;/li&gt;&#xA;&lt;li&gt;color scheme plugin&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The list might goes on and on, it depends on your coding language, but &#xA; most of time auto-pair is not one of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's pretty easy to get overwhelmed. You also need extra plugin to make auto-pairs work with . repeat, so IMHO don't use it for the 1st and 2nd month, a few more key strokes wouldn't kill you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Feel free to try it later.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-06T11:50:05.167" LastActivityDate="2019-04-06T11:50:05.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19458" PostTypeId="2" ParentId="19451" CreationDate="2019-04-06T14:31:38.537" Score="0" Body="&lt;p&gt;One can also do &lt;code&gt;:!xdg-open &amp;lt;C-r&amp;gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; to shell out and grab the word under the cursor.&lt;/p&gt;&#xA;&lt;p&gt;I’m not sure how this handles a WORD like &lt;code&gt;www.google.com&lt;/code&gt;; it may be that &lt;code&gt;&amp;lt;C-r&amp;gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; is necessary&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2022-06-12T00:30:17.897" LastActivityDate="2022-06-12T00:30:17.897" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19459" PostTypeId="1" CreationDate="2019-04-06T18:22:51.870" Score="2" ViewCount="1263" Body="&lt;p&gt;I use (Neo)Vim with &lt;code&gt;mouse=a&lt;/code&gt; and &lt;code&gt;scrolloff=5&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Clicking on one of the top or bottom five lines with the mouse causes the screen to jump (so that the new cursor position is more centered), which distracts me.&lt;/p&gt;&#xA;&lt;p&gt;Is there any way to disable &amp;quot;&lt;code&gt;so=5&lt;/code&gt;&amp;quot; for mouse-clicking only?&lt;/p&gt;&#xA;" OwnerUserId="21684" LastEditorUserId="23502" LastEditDate="2023-08-28T10:26:34.823" LastActivityDate="2023-08-28T10:26:34.823" Title="Don't use scrolloff=5 for mouse clicks" Tags="|vimrc|scrolling|mouse|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19460" PostTypeId="2" ParentId="12520" CreationDate="2019-04-06T18:59:13.447" Score="1" Body="&lt;p&gt;Or create a Toggle mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;c :let &amp;amp;cole=(&amp;amp;cole == 2) ? 0 : 2 &amp;lt;bar&amp;gt; echo 'conceallevel ' . &amp;amp;cole &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using the abbreviated form of conceallevel &lt;em&gt;cole&lt;/em&gt; to make my line shorter&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can also test if the plugin indentline is loaded and then...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if match(&amp;amp;runtimepath, 'indentline') != -1&#xA;    let g:indentLine_fileTypeExclude = ['markdown']&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2019-12-06T15:22:06.980" LastActivityDate="2019-12-06T15:22:06.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19461" PostTypeId="1" CreationDate="2019-04-06T20:25:36.760" Score="3" ViewCount="2715" Body="&lt;p&gt;I'm trying to set up an autocompletion/snippet workflow that's a bit complicated. This is stemming from needing a better workflow for latex. Right now I'm using &lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;coc.nvim&lt;/a&gt; and &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnippets&lt;/a&gt; but I am willing from changing from coc to &lt;a href=&quot;https://github.com/autozimu/LanguageClient-neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;LanguageClient-neovim&lt;/a&gt; if need be.What I want to happen is as follows. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, I want tab to switch between things or scroll like it usually does with autocomplete, and I want enter to select things. I also want snippets to be prioritized.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Tab&lt;/h2&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If there is an autocomplete window open, I always want it to scroll through that. If a snippet is being expanded I want tab to jump to the next insert spot. Pseudo code - followed by what I think it roughly translates to - below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (there is an autocompletion context)&#xA;    scroll down to the next autocompletion option&#xA;elseif (this is in the middle of snippeting in select mode)&#xA;    jump to the next snippet insert place&#xA;else&#xA;    normal tab&#xA;endif&#xA;&quot; --- roughly equivalent to ---&#xA;if pumvisible()&#xA;    &amp;lt;c-n&amp;gt;&#xA;elseif (this is in the middle of snippeting in select mode)&#xA;    idk&#xA;else&#xA;    idk&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Enter&lt;/h2&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If there is a snippet that can be expanded, expand the snippet. Otherwise if the autocompletion window is up, select whatever is there. If nothing special is going on, just a normal enter.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (snippet can be expanded)&#xA;    (expand snippet) &#xA;elseif (there is an autocompletion context)&#xA;    (select autocomplete option)&#xA;else&#xA;    (normal enter)&#xA;endif&#xA;&quot; --- roughly equivalent to ---&#xA;if !empty(UltiSnips#SnippetsInCurrentScope())&#xA;    UltiSnips#ExpandSnippet()&#xA;elseif pumvisible()&#xA;    &amp;lt;c-y&amp;gt;&#xA;else&#xA;    &amp;lt;cr&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried a lot of stuff with coc and ultisnips. I tried it with and without supertab. Supertab made it a lot better but it isn't quite what I want and some things, such as normal tabbing (sometimes) and jumping to the next snippet insert spot were broken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Partial answers are welcome. @mods if this question is too specific or whatever, tell me how to break it up or make it better. The reason I ask is cause I figure it should be easy but I'm just missing something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is some easy standard thing that I'm missing and its just like what I want but a little different, I'm open to it. If you think this is a dumb setup I'd love to learn why and explain my point of view.&lt;/p&gt;&#xA;" OwnerUserId="21686" LastActivityDate="2022-01-15T07:01:20.147" Title="Integrating autocomplete and snippets" Tags="|vimrc|key-bindings|vimscript|autocompletion|plugin-ultisnips|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19462" PostTypeId="1" AcceptedAnswerId="19463" CreationDate="2019-04-07T00:38:56.240" Score="0" ViewCount="2030" Body="&lt;p&gt;Is there a way to set multiple default tag files, to be searched sequentially in my vimrc? My hope was that I would be able to have a local tags file that would be searched first and then, if nothing was found, it would move onto the next given tags file (and so on ideally, but at this point I'm mainly interested in the case of 2).&lt;/p&gt;&#xA;" OwnerUserId="13025" LastActivityDate="2019-04-07T01:51:10.813" Title="Setting a list of tag files" Tags="|vimrc|tags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19463" PostTypeId="2" ParentId="19462" CreationDate="2019-04-07T01:51:10.813" Score="2" Body="&lt;p&gt;Sure. See &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27tags%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;help 'tags'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tags+=./my_local_tags_name&#xA;set tags+=other_tags_file_name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default is &lt;code&gt;&quot;./tags,tags&quot;&lt;/code&gt;, which would do what you want if you can name your tags files in this way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tags option takes a comma-separated list of files to search for when using tags. But the usage of &lt;code&gt;+=&lt;/code&gt; is preferred to manual comma addition. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-04-07T01:51:10.813" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19464" PostTypeId="1" CreationDate="2019-04-07T02:51:25.820" Score="1" ViewCount="1771" Body="&lt;p&gt;A few days ago I found a command that allowed me to view all the syntax colors in a theme. I could then determine what highlight I needed to change in order to customize the theme. Can you help me remember what this command is?&lt;/p&gt;&#xA;" OwnerUserId="21691" LastEditorUserId="1841" LastEditDate="2019-04-07T17:08:03.743" LastActivityDate="2019-04-07T17:08:03.743" Title="Command to list all customizable color highlights" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19465" PostTypeId="1" AcceptedAnswerId="22312" CreationDate="2019-04-07T08:25:25.640" Score="1" ViewCount="317" Body="&lt;p&gt;I used to store macros in insert mode as &lt;code&gt;&amp;lt;c-r&amp;gt;&amp;lt;c-r&amp;gt;q&lt;/code&gt;, but that fails if the macro contains a special character such as &lt;code&gt;&amp;lt;C-Right&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I record a macro as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq&amp;lt;C-Right&amp;gt;q.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the result of &lt;code&gt;&amp;lt;c-r&amp;gt;&amp;lt;c-r&amp;gt;q&lt;/code&gt; in insert mode is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;80&amp;gt;ýV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the result of &lt;code&gt;&quot;qp&lt;/code&gt; in normal mode is : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I copy the result back to a new register &lt;code&gt;&quot;ay$&lt;/code&gt; , only the &lt;code&gt;&quot;qp&lt;/code&gt; approach works. The first character in the newly copied register of the &lt;code&gt;&amp;lt;c-r&amp;gt;&amp;lt;c-r&amp;gt;q&lt;/code&gt; approach is &lt;code&gt;&amp;lt;c2&amp;gt;&lt;/code&gt;, I have no idea what &lt;code&gt;&amp;lt;c2&amp;gt;&lt;/code&gt; is, it's echo result is 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is what's the difference between these two methods?&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="1238" LastEditDate="2019-12-16T22:59:54.193" LastActivityDate="2019-12-21T23:44:19.783" Title="What's the difference between &quot;qp and &lt;c-r&gt;&lt;c-r&gt;q when you store a macro?" Tags="|macro|register|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19466" PostTypeId="1" CreationDate="2019-04-07T09:29:42.200" Score="3" ViewCount="456" Body="&lt;p&gt;I can figure out which script changed a vim setting the last time with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set errorformat?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, sometimes a setting is modified/appended several times and I want to see all scripts who touched this setting not only the last one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, I am aware of following means:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;start vim in verbose mode with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -V15vim.log demo.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then grep &lt;code&gt;vim.log&lt;/code&gt; for the setting (in full and abbreviated form) I am interested in.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Grep in vim or on the commandline the directories &lt;code&gt;~/.vim&lt;/code&gt; and &lt;code&gt;$VIMRUNTIME&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Apparently, the event &lt;code&gt;OptionSet&lt;/code&gt; is deactivated on startup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a more polished way similar to &lt;code&gt;:verbose set efm?&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related wiki page:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vim.fandom.com/wiki/Debug_unexpected_option_settings&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vim.fandom.com/wiki/Debug_unexpected_option_settings&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="24" LastEditDate="2019-05-10T05:21:19.670" LastActivityDate="2019-05-10T05:21:19.670" Title="How to find all scripts which modified a certain vim setting?" Tags="|options|startup|debugging|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19467" PostTypeId="2" ParentId="19465" CreationDate="2019-04-07T10:31:24.180" Score="2" Body="&lt;p&gt;There are several ways to insert the content of a registers. I'm going to briefly discuss some that are inserted when in &lt;code&gt;:h Insert-mode&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h i_CTRL-R&lt;/code&gt; : Insert the content of a register. Unlike, &lt;code&gt;:h p&lt;/code&gt; or &lt;code&gt;:h P&lt;/code&gt; i.e. &lt;code&gt;&quot;qp&lt;/code&gt;, how the texts are inserted will be affected by options like &lt;code&gt;:h textwidth&lt;/code&gt;, &lt;code&gt;:h formatoptions&lt;/code&gt; or &lt;code&gt;:h autoindent&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h i_CTRL-R_CTRL-R&lt;/code&gt; : Works like using a single CTRL-R, but the text is inserted literally, not as if typed. So, if you record hitting a backspace, e.g. &lt;code&gt;type^Hing&lt;/code&gt;, would insert &lt;code&gt;typing&lt;/code&gt; when inserted with single CTRL-R but will insert &lt;code&gt;type^Hing&lt;/code&gt; when inserted with double CTRL-R. (&lt;code&gt;^H&lt;/code&gt; is CTRL-H, used for &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; in terminal emulators, i.e. they emit same code &lt;code&gt;&amp;lt;U+0008&lt;/code&gt;). Still is affected by auto-indent options.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h i_CTRL-R_CTRL-O&lt;/code&gt; : Insert text literally and isn't affected by auto-indent.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h i_CTRL-R_CTRL-P&lt;/code&gt; : Insert the contents of a register literally and fix the indent.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now, when you pressed &lt;code&gt;&amp;lt;Ctrl-Right&amp;gt;&lt;/code&gt; after starting the recording, your terminal emulator emits some keycodes. I don't exactly know what they might be and most probably they even differ from computer to computer. So, it's a wildcard why the characters &lt;code&gt;&amp;lt;80&amp;gt;&lt;/code&gt; &lt;code&gt;&amp;lt;fd&amp;gt;&lt;/code&gt; (both hexadecimal values) and most confusingly why &lt;code&gt;V&lt;/code&gt; is there! I have no answer to these. The only thing I have advanced on your observations is that both &lt;code&gt;ý&lt;/code&gt; and &lt;code&gt;&amp;lt;fd&amp;gt;&lt;/code&gt; are basically same character, i.e. they both have same HEX values which is &lt;code&gt;00FD&lt;/code&gt;. Double &lt;code&gt;CTRL-R&lt;/code&gt;, i.e. &lt;code&gt;i_CTRL-R_CTRL-R&lt;/code&gt;, inserts literal characters. That's why it inserted the literal value of &lt;code&gt;&amp;lt;fd&amp;gt;&lt;/code&gt; and not the HEX value which is saved in its &lt;code&gt;:h digraph&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to wrap it up:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Check out the documentations to know about various ways to insert content of a register and differences among them.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;fd&amp;gt;&lt;/code&gt; and &lt;code&gt;ý&lt;/code&gt; are same character, former is HEX value and latter is ASCII value.&lt;/li&gt;&#xA;&lt;li&gt;No idea why there is a literal &lt;code&gt;V&lt;/code&gt; in the &lt;code&gt;&amp;lt;C-Right&amp;gt;&lt;/code&gt; &lt;code&gt;:h key-codes&lt;/code&gt; recording&lt;/li&gt;&#xA;&lt;li&gt;No idea how to make sense of these nonsensical key-codes. And I suppose, in order to not have to think about these key-codes, vim provides us sensible &lt;code&gt;:h key-codes&lt;/code&gt; for mappings and such.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't use the literal string that you got when you inserted it with &lt;code&gt;:h i_CTRL-R_CTRL-R&lt;/code&gt; to use as a recording. Because the literal string that the extended ASCII key-code spews out is not within one of &lt;code&gt;:h key-codes&lt;/code&gt;. For example, if you want to insert &lt;code&gt;&amp;lt;C-Right&amp;gt;&lt;/code&gt; into a register and use it, you need to do it in the following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @q = &quot;\&amp;lt;C-Right&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The backslash and double-quote is necessary to evaluate to special characters, see &lt;code&gt;:h string&lt;/code&gt; and &lt;code&gt;:h literal-string&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, the weird character that the HEX value of &lt;code&gt;&amp;lt;fd&amp;gt;&lt;/code&gt; evaluates to in extended ASCII chart is not going to be converted to special characters or key-codes in &lt;code&gt;:h key-codes&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-04-07T11:20:47.013" LastActivityDate="2019-04-07T11:20:47.013" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19468" PostTypeId="2" ParentId="19466" CreationDate="2019-04-07T10:49:49.053" Score="1" Body="&lt;h3&gt;Put vimgrep matches in files from &lt;code&gt;:scriptnames&lt;/code&gt; into the quickfix list&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:scriptnames&lt;/code&gt; allows to consider&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;only files which have &lt;em&gt;actually&lt;/em&gt; been sourced&lt;/li&gt;&#xA;&lt;li&gt;and then you can grep for the full and abbreviated option name (regex pattern)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Steps&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;vim demo.tex&lt;/code&gt; or&lt;br&gt;&#xA;do whatever you need to do to get to the point where you want to find out how you ended up with the current setting.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run &lt;code&gt;:Scriptnames&lt;/code&gt; from &lt;a href=&quot;https://github.com/tpope/vim-scriptease&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-scriptease&lt;/a&gt;. This populates the quickfix list with results from &lt;code&gt;:scriptnames&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fill arglist from quickfixlist (Is there a better solution?)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:argdelete * &quot; if necessary&#xA;:for f in map(getqflist(), {i, v -&amp;gt; bufname(v.bufnr)}) | exe('argadd '.f) | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Search with vimgrep all entries in arglist&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vim /\&amp;lt;errorformat\&amp;gt;\|\&amp;lt;efm\&amp;gt;/ ##&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now one can cycle through likely candidates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 3 and 4 can be combined and avoids to use the arglist:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe('vimgrep /\&amp;lt;errorformat\&amp;gt;\|\&amp;lt;efm\&amp;gt;/ '.join(map(getqflist(), {i, v -&amp;gt; bufname(v.bufnr)})))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if you want to try different regex pattern, you might find it better to keep them separated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wish to see a list of files to get a first overview which script is involved, you could run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:for f in uniq(sort(map(getqflist(), {i, v -&amp;gt; bufname(v.bufnr)})))| echo f | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my case I get for &lt;code&gt;/\&amp;lt;errorformat\&amp;gt;\|\&amp;lt;efm\&amp;gt;/&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/hotschke/.vim/pack/lervag/start/vimtex/autoload/vimtex/qf/latexlog.vim&#xA;/Users/hotschke/.vim/pack/tpope/start/dispatch/autoload/dispatch.vim&#xA;/Users/hotschke/.vim/pack/tpope/start/fugitive/autoload/fugitive.vim&#xA;/Users/hotschke/.vim/pack/tpope/start/projectionist/autoload/projectionist.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this is not perfect and it would be better to have something similar for &lt;code&gt;$ vim -V15vim.log&lt;/code&gt;. But extracting the match and the corresponding file from the log file is more complicated (mostly due to autoloaded functions).&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-04-09T06:57:59.593" LastActivityDate="2019-04-09T06:57:59.593" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19469" PostTypeId="2" ParentId="19464" CreationDate="2019-04-07T12:27:16.517" Score="5" Body="&lt;p&gt;Thank you to @klaus for providing me with the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:hi&lt;/code&gt; allows me to view all the syntax highlighting assignments.&lt;/p&gt;&#xA;" OwnerUserId="21694" LastActivityDate="2019-04-07T12:27:16.517" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19470" PostTypeId="1" AcceptedAnswerId="19472" CreationDate="2019-04-07T14:54:15.317" Score="0" ViewCount="192" Body="&lt;p&gt;I have a problem with my softtabstop option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason when I put this line in my .vimrc &lt;code&gt;set softtabstop=4&lt;/code&gt; it does nothing. However if I do it as a command &lt;code&gt;:set softtabstop=4&lt;/code&gt; it does work properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea why it's not working as it should?&lt;/p&gt;&#xA;" OwnerUserId="5081" LastActivityDate="2019-04-07T18:02:57.370" Title="softtabstop not working" Tags="|softtabstop|" AnswerCount="1" CommentCount="4" ClosedDate="2019-04-07T18:49:54.753" ContentLicense="CC BY-SA 4.0" />
  <row Id="19471" PostTypeId="2" ParentId="3199" CreationDate="2019-04-07T16:31:35.937" Score="1" Body="&lt;p&gt;The simply approach&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @&quot; | silent map | redir END | new | put!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21697" LastActivityDate="2019-04-07T16:31:35.937" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19472" PostTypeId="2" ParentId="19470" CreationDate="2019-04-07T18:02:57.370" Score="0" Body="&lt;p&gt;As @klaus pointed out in the comments, it was some other setting that was causing the problem (&lt;code&gt;set paste&lt;/code&gt; in my case)&lt;/p&gt;&#xA;" OwnerUserId="5081" LastActivityDate="2019-04-07T18:02:57.370" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19473" PostTypeId="1" AcceptedAnswerId="19479" CreationDate="2019-04-07T18:06:36.097" Score="3" ViewCount="546" Body="&lt;p&gt;I compiled vim 8.1 for Ubuntu 16.04 x64, from source, by following Valloric's excellent &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source&quot; rel=&quot;nofollow noreferrer&quot;&gt;guide&lt;/a&gt; on the subject. Although that guide is for an older version, it was really simple to check out the correct version I wanted using git.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ran &lt;code&gt;./configure&lt;/code&gt; with the same options as that guide, except for the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I omitted Python 2 support since Python 2 + Python 3 support is a bit messy.&lt;/li&gt;&#xA;&lt;li&gt;I set &lt;code&gt;--prefix=/mnt/my_data_drive/software/vim/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After this, I ran the following commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir /mnt/my_data_drive/software/vim/vim81&#xA;make VIMRUNTIMEDIR=/mnt/my_data_drive/software/vim/vim81&#xA;make install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After this, the bin, and share folders were created correctly, but the vim81 folder was empty. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I tried setting VIMRUNTIMEDIR for make install, it made no difference. If I fail to create vim81, the directory is not created for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a result of this, I'm unable to turn syntax highlighting on in my .vimrc. The line simply results in:&#xA;&lt;code&gt;syntax.vim: No such file or directory.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you please help me solve this issue?&lt;/p&gt;&#xA;" OwnerUserId="11789" LastEditorUserId="19763" LastEditDate="2019-04-08T04:57:38.467" LastActivityDate="2019-04-08T17:47:48.713" Title="How to ensure files are copied to VIMRUNTIMEDIR when building Vim 8.1 from source and specifying a prefix?" Tags="|linux|installing|linux-ubuntu|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19474" PostTypeId="1" CreationDate="2019-04-07T18:33:52.590" Score="-1" ViewCount="86" Body="&lt;p&gt;I've been following how to do search replace in vim, but somehow it doesnt work for my case.  For example, I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x(i,1,1) = y(i,1,1) + z(i,1,1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I want to change the last index, i.e change &quot;x(i,1,1) to x(i,1,2)&quot; and similar for y and z.  I can just go change this manually but if I want to try our vim, just in case I have a larger expressions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I did: select the line visual mode &lt;code&gt;(Shift + V)&lt;/code&gt;.  Then press &lt;code&gt;:&lt;/code&gt;, then vim has this in the status bar &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt;, now I type: &lt;code&gt;s/,1)/,2)&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That only changes the first variable. In other words, I have this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x(i,1,2) = y(i,1,1) + z(i,1,1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Y and Z are not changed, even if they are on the same line and are selected together with X in visual mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help&lt;/p&gt;&#xA;" OwnerUserId="21038" LastEditorUserId="1841" LastEditDate="2019-04-07T18:48:53.633" LastActivityDate="2019-04-07T18:48:53.633" Title="search replace for 1 line" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19475" PostTypeId="2" ParentId="19474" CreationDate="2019-04-07T18:45:25.453" Score="3" Body="&lt;p&gt;So you want to make the substitution occur on every match of the pattern on the line and not only the first match. What you can do is read &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3As&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :s&lt;/code&gt;&lt;/a&gt;, where you'll find:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]&#xA;    [...]&#xA;    See |:s_flags| for [flags].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can go to &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3As_flags&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :s_flags&lt;/code&gt;&lt;/a&gt; where you'll find:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[g] Replace all occurrences in the line.  Without this argument,&#xA;    replacement occurs only for the first occurrence in each line. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you'll add &lt;code&gt;/g&lt;/code&gt; to your command like this: &lt;code&gt;:s/,1)/,2)/g&lt;/code&gt; and you'll have the behavior you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the tag &lt;code&gt;c&lt;/code&gt; is often useful when you use &lt;code&gt;g&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[c] Confirm each substitution. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also when you use &lt;code&gt;:s&lt;/code&gt; by default it operates on the current line so you don't need to visually select the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last note: the UI component where you type &lt;code&gt;:'&amp;lt;,'&amp;gt;s...&lt;/code&gt; is not the status line, it's the command line. The status line is the line at the bottom of a window is you set &lt;code&gt;laststatus&lt;/code&gt; (see &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#status-line&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h status-line&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#Command-line&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h Command-line&lt;/code&gt;&lt;/a&gt; to get the difference)&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-04-07T18:45:25.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19476" PostTypeId="1" CreationDate="2019-04-08T01:57:42.720" Score="0" ViewCount="62" Body="&lt;p&gt;I never use source with !, I'm just curious.&lt;/p&gt;&#xA;&lt;p&gt;I know source! is used to read normal commands. But its behavior is a bit strange.&lt;/p&gt;&#xA;&lt;p&gt;My experimental file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;line1&#xA;line2&#xA;line3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My normal command file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Assume cursor at &amp;quot;l&amp;quot; of &amp;quot;line1&amp;quot;, after &lt;code&gt;source! cmdfile&lt;/code&gt;, cursor moved to &amp;quot;i&amp;quot; of &amp;quot;line2&amp;quot; instead of &amp;quot;line1&amp;quot;. If I add a blank line after &amp;quot;l&amp;quot; in cmdfile, and try everything again, cursor will move from &amp;quot;l&amp;quot; of &amp;quot;line1&amp;quot; to &amp;quot;i&amp;quot; of &amp;quot;line3&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;It looks like linefeed was read as a normal command &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Is that normal? Am I doing something wrong? What would &lt;code&gt;source!&lt;/code&gt; be good for if it always read linefeeds as a normal command &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="11357" LastEditDate="2023-04-10T13:34:18.380" LastActivityDate="2023-04-10T13:34:18.380" Title="Why does :source! read linefeeds as &lt;c-j&gt;?" Tags="|normal-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19477" PostTypeId="1" AcceptedAnswerId="19478" CreationDate="2019-04-08T04:01:57.257" Score="2" ViewCount="168" Body="&lt;p&gt;Is there any way to display the reading time estimate in Vim? For example &quot;this will take about 4 minutes to read&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest that I know of is &lt;code&gt;g&amp;lt;C-g&amp;gt;&lt;/code&gt;, which gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Col 29 of 75; Line 68 of 132; Word 285 of 520; Byte 2187 of 3977&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But no reading time.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-04-09T04:32:38.397" Title="How can I get a reading time estimate?" Tags="|word-processing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19478" PostTypeId="2" ParentId="19477" CreationDate="2019-04-08T04:01:57.257" Score="3" Body="&lt;p&gt;As far as I know there is no built-in method for this, but I extended &lt;code&gt;g&amp;lt;C-g&amp;gt;&lt;/code&gt; using the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:readtime()&#xA;    let l:status = v:statusmsg&#xA;    try&#xA;        exe &quot;silent normal! g\&amp;lt;C-g&amp;gt;&quot;&#xA;        echo printf('%s; About %.0f minutes',&#xA;                    \ v:statusmsg, ceil(wordcount()['words'] / 200.0))&#xA;    finally&#xA;        let v:statusmsg = l:status&#xA;    endtry&#xA;endfun&#xA;nnoremap g&amp;lt;C-g&amp;gt; :call &amp;lt;SID&amp;gt;readtime()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I opted to extend the &lt;code&gt;&amp;lt;C-g&amp;gt;g&lt;/code&gt; output with an estimate of the reading time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Col 1 of 17; Line 62 of 131; Word 261 of 510; Byte 1967 of 3920; About 3 minutes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes a reading speed of 200 words per minute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trick is that you can read &lt;em&gt;and write&lt;/em&gt; &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#v%3Astatusmsg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;v:statusmsg&lt;/code&gt;&lt;/a&gt; to display a message in the commandline, so this first runs the default &lt;code&gt;g&amp;lt;C-g&amp;gt;&lt;/code&gt;, captures the output, get the word count, adds the reading time, and sets the statusmsg again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do the same but not set &lt;code&gt;v:statusmsg&lt;/code&gt; at the end if you want it mapped to a separate key, or run it as a command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this will only give you a naïve estimate which us unaware of syntax. It should be accurate enough for simple markup languages like Markdown, but it won't work well for more verbose markup such as HTML.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-04-09T04:32:38.397" LastActivityDate="2019-04-09T04:32:38.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19479" PostTypeId="2" ParentId="19473" CreationDate="2019-04-08T04:54:44.330" Score="2" Body="&lt;p&gt;I build Vim 8.1 on Ubuntu 16.04 and install it to the custom directory &lt;code&gt;/opt/vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My steps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;INST_DIR=&quot;/opt/vim&quot;&#xA;./configure --prefix=${INST_DIR} --mandir=${INST_DIR}/share/man ...&#xA;make &#xA;make test&#xA;make install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can run &lt;code&gt;make -n install&lt;/code&gt;. Then make just prints what it would install, without actually doing it. Check the output, it should contain lines like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;cp  ../runtime/doc/*.pl /opt/vim/share/vim/vim81/doc&#xA;chmod 755 /opt/vim/share/vim/vim81/doc/*.pl&#xA;cd ../runtime/doc; if test -f tags.dist; then mv -f tags.dist tags; fi&#xA;cp ../runtime/menu.vim /opt/vim/share/vim/vim81/menu.vim&#xA;chmod 644 /opt/vim/share/vim/vim81/menu.vim&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-04-08T04:54:44.330" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19480" PostTypeId="2" ParentId="19476" CreationDate="2019-04-08T05:56:36.750" Score="1" Body="&lt;p&gt;&lt;code&gt;source!&lt;/code&gt; reads literal character (including linefeed) as it's command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although newline is statement separator in ex command file, &#xA;newline is still newline in normal command file, it make things so much easier and clearer if you want source! to generate multi-line text. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess &lt;code&gt;source!&lt;/code&gt; mainly has 2 usages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Insert multi-line text, it would be a mess if lines are separated by&lt;code&gt;^M&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iclass ClassName&#xA; {&#xA;     ClassName()&#xA;     {&#xA;&#xA;     }&#xA; }&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;As a normal command storage file, it can be used together with :global, :*do family. The trailing newline must be removed if you want to use it this way, as @user938271 pointed out, you can use writefile with b flag to save without trailing newline, &lt;a href=&quot;https://stackoverflow.com/questions/1654021/how-can-i-delete-a-newline-if-it-is-the-last-character-in-a-file&quot;&gt;here&lt;/a&gt; are some other ways to do it. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="205" LastEditDate="2019-04-08T07:16:19.347" LastActivityDate="2019-04-08T07:16:19.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19481" PostTypeId="1" AcceptedAnswerId="19595" CreationDate="2019-04-08T07:56:35.930" Score="3" ViewCount="64" Body="&lt;p&gt;According to &lt;code&gt;:h hit-enter&lt;/code&gt;, a message is shown when there is something on the screen to read and the screen is about to be redrawn. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- After executing an external command (e.g., &quot;:!ls&quot; and &quot;=&quot;).&#xA;- Something is displayed on the status line that is longer than the width of&#xA;  the window, or runs into the 'showcmd' or 'ruler' output.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the &lt;code&gt;:h hit-enter&lt;/code&gt; prompt is shown, the user can press &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; to redraw the screen. The user can also press &lt;code&gt;:&lt;/code&gt; or any other Normal mode command character to start that command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now,I have grown accustomed to a keybinding that lets me use &lt;code&gt;&amp;lt;Space&amp;gt;;&lt;/code&gt; as &lt;code&gt;:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;; :&#xA;xnoremap &amp;lt;Leader&amp;gt;; :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was hoping I could use &lt;code&gt;&amp;lt;Space&amp;gt;;&lt;/code&gt; as &lt;code&gt;:&lt;/code&gt; when the &lt;code&gt;:h hit-enter&lt;/code&gt; message is shown.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-16T00:26:54.077" Title="How not to use &lt;Space&gt; as a hit-enter key in command output pager" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19482" PostTypeId="1" AcceptedAnswerId="19483" CreationDate="2019-04-08T09:14:36.563" Score="0" ViewCount="374" Body="&lt;p&gt;Currently my buffer bar (I don't know if this is the right word) looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PFRxy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PFRxy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though my terminal is super wide, it displays the names of only 4 buffers I have open and then an ellipsis (...) indicating I have more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would like it to fill up almost the entire width of the page with buffers, until it actually can't fit anymore and then use the ellipsis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use vim-airline.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2019-04-08T10:01:01.077" Title="how to make buffer bar longer, show the names of more buffers" Tags="|buffers|plugin-powerline|plugin-airline|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19483" PostTypeId="2" ParentId="19482" CreationDate="2019-04-08T10:01:01.077" Score="1" Body="&lt;p&gt;Since you only posted a part of the whole picture, this all is just my guess.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that &quot;buffer bar&quot; is &lt;code&gt;:h tabline&lt;/code&gt;. They display the current buffer in the corresponding tabs. I guess there are only 4 &lt;code&gt;:h tabpages&lt;/code&gt; in that current session and thus only 4 filenames showing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give you a solution, I would say not to use tabline as tabs in other general text editors. The tabpage in vim is supposed to work like separating sessions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's examine some terminologies:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A buffer is the in-memory text of a file.&lt;/li&gt;&#xA;&lt;li&gt;A window is a viewport on a buffer.&lt;/li&gt;&#xA;&lt;li&gt;A tab page is a collection of windows.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, the usage of tabpage is twofolds:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Managing splits&lt;/strong&gt;&lt;br&gt;&#xA;Assume, you have set up a beautiful set of splits which you don't want to lose. Now what do you do if you want to look at a buffer with full window height and width? You could do &lt;code&gt;:h CTRL-W_bar&lt;/code&gt; and &lt;code&gt;:h CTRL-W__&lt;/code&gt; but that would mess up your current splits. So, instead you should open a new tabpage and view that buffer with full height and width, and when you're done you can get back to your previous tabpage where your previously setup splits are left untouched.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Managing projects&lt;/strong&gt;&lt;br&gt;&#xA;Assume, you have a project in &lt;code&gt;~/projects/project_1&lt;/code&gt; and you open vim in there. Your current working directory in the current session is &lt;code&gt;~/projects/project_1&lt;/code&gt;. Now, if you have to check on a separate project, you could open up another terminal and use a separate vim instance to work in that project. But if project_1 is dependent on project_2 or vice versa, and you need to work on both projects in the same vim instance, because of &lt;code&gt;:h ins-completion&lt;/code&gt; etc. you can open a separate tabpages dedicated to each projects and change the current working directory corresponding to that tabpage with &lt;code&gt;:h lcd&lt;/code&gt;. Now, you have two separate working projects with separate working directories but in the same vim instance.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Bottom line, &lt;code&gt;:h tabpage&lt;/code&gt; is not supposed to be used for showing available buffers. You have &lt;code&gt;:h :ls&lt;/code&gt; for that.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-08T10:01:01.077" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19484" PostTypeId="1" AcceptedAnswerId="19487" CreationDate="2019-04-08T11:59:50.450" Score="5" ViewCount="1577" Body="&lt;p&gt;I want to highlight unused Python imports as Python syntax errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I sometimes forget to remove some packages used for debugging such as &lt;code&gt;time&lt;/code&gt;, &lt;code&gt;ipdb&lt;/code&gt;. It would be great to see warnings or even errors for the unused imports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;Syntastic&lt;/code&gt; plugin, but it does not highligh the unused imports or I don't know how to configure it. I have this &lt;code&gt;Syntastic&lt;/code&gt; setting set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_python_checkers = ['python', 'flake8']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="147" LastActivityDate="2019-04-08T13:43:43.020" Title="How to highlight unused Python imports in VIM" Tags="|syntax-highlighting|filetype-python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19485" PostTypeId="1" AcceptedAnswerId="19486" CreationDate="2019-04-08T13:26:06.443" Score="0" ViewCount="239" Body="&lt;p&gt;Using a terminal emulator (with &lt;code&gt;:term&lt;/code&gt;), I would like to insert the value of a variable at the terminal cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a normal text buffer, I could use &lt;code&gt;put =g:my_variable&lt;/code&gt; or &lt;code&gt;exec (&quot;normal! i&quot; . g:my_variable)&lt;/code&gt;. Neither of these seems to work with the terminal emulator, however. How can I send the contents of the variable &lt;code&gt;g:my_variable&lt;/code&gt; to the job that is running in the terminal emulator?&lt;/p&gt;&#xA;" OwnerUserId="5803" LastActivityDate="2019-04-08T13:43:58.493" Title="Ex command to put value of variable into terminal emulator?" Tags="|terminal|variables|terminal-buffer|input-methods|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19486" PostTypeId="2" ParentId="19485" CreationDate="2019-04-08T13:34:16.073" Score="1" Body="&lt;p&gt;In the &lt;code&gt;:terminal&lt;/code&gt;, you can put any register using (&lt;code&gt;&amp;lt;c-w&amp;gt; = ctrl w&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;&quot;{register}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In particular, to insert the contents of a variable you can use the expression register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;&quot;= g:variable &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are writing a script, in vim's terminal you may use the function &lt;code&gt;term_sendkeys&lt;/code&gt; to send the contents of a variable to the terminal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call term_sendkeys(bufnr('%'), g:contents)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If contents contains a &quot;\n&quot; newline character, the command will additionally be executed in the shell.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2019-04-08T13:43:58.493" LastActivityDate="2019-04-08T13:43:58.493" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19487" PostTypeId="2" ParentId="19484" CreationDate="2019-04-08T13:43:43.020" Score="4" Body="&lt;p&gt;Flake8 already supports &lt;a href=&quot;https://flake8.pycqa.org/en/latest/user/error-codes.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;checking for unused imports&lt;/a&gt; and is integrated with Syntastic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Python developers should make sure to install flake8 into their user or virtual environment.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-04-08T13:43:43.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19488" PostTypeId="1" CreationDate="2019-04-08T15:05:58.823" Score="2" ViewCount="315" Body="&lt;p&gt;Vim's &lt;code&gt;C-w o&lt;/code&gt; is equivalent to Emacs's &lt;code&gt;ESC ESC ESC&lt;/code&gt;, which closes all the Vim's windows (Emacs's buffers), except the current open one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Emacs, with the command &lt;code&gt;winner-undo&lt;/code&gt; and &lt;code&gt;winner-redo&lt;/code&gt; one can easily undo and redo the &lt;code&gt;ESC ESC ESC&lt;/code&gt; command and obtain exactly the split configuration that he had before using the command, with the cursor in the correct place. How can I do this in Vim?&lt;/p&gt;&#xA;" OwnerUserId="21705" LastEditorUserId="1841" LastEditDate="2019-04-08T15:14:39.347" LastActivityDate="2019-04-08T15:49:26.277" Title="Equivalent of emacs `winner-undo` and `winner-redo`" Tags="|vim-windows|split|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19489" PostTypeId="2" ParentId="19488" CreationDate="2019-04-08T15:43:34.403" Score="3" Body="&lt;p&gt;&lt;sup&gt;Emacs's &lt;code&gt;winner-undo&lt;/code&gt; and &lt;code&gt;winner-redo&lt;/code&gt; depends on &lt;code&gt;winner-mode&lt;/code&gt;. You can probably find some plugins similar to that in vim. But who wants that, right?&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm going to introduce some terminology, from &lt;code&gt;:h buffers&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A buffer is the in-memory text of a file. &lt;/li&gt;&#xA;&lt;li&gt;A window is a viewport on a buffer.       &lt;/li&gt;&#xA;&lt;li&gt;A tab page is a collection of windows.    &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h tabpage&lt;/code&gt; are supposed to hold onto your carefully managed splits. For example, suppose you have constructed a split configuration suited to your current project. For some reason, you need to check on some file in a full-screen view, i.e. with full width and height. You could do that with &lt;code&gt;:h |&lt;/code&gt; and &lt;code&gt;:h _&lt;/code&gt; but you can't get back to your previous split configurations like &lt;code&gt;winner-mode&lt;/code&gt; in emacs. So, instead, you open a new tab page (check ways to do that in &lt;code&gt;:h tabpage&lt;/code&gt;) and view the buffer in the new tab page. Now, you can switch back and forth between those tab pages without disrupting your split configurations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you can use several separate split configurations in separate tabs and switch between them, i.e. not just using tabs for zooming purposes. This was just an example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To wrap up, you can't have undo style performance for split management in vim like Emacs's &lt;code&gt;winner-mode&lt;/code&gt;. What you have is a workspace management setup with &lt;code&gt;:h tabpage&lt;/code&gt; similar to Emacs's &lt;a href=&quot;https://github.com/wasamasa/eyebrowse&quot; rel=&quot;nofollow noreferrer&quot;&gt;eyebrowse package&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;https://stackoverflow.com/a/26710166/11135136&quot;&gt;Here is a detailed answer&lt;/a&gt; describing the uses and differences of buffers, windows/splits and tab pages&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-04-08T15:49:26.277" LastActivityDate="2019-04-08T15:49:26.277" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19490" PostTypeId="2" ParentId="19473" CreationDate="2019-04-08T16:53:58.160" Score="0" Body="&lt;p&gt;Setting &lt;code&gt;VIMRUNTIMEDIR&lt;/code&gt; when running make only specifies the runtimedir for the vim installation. It does not set the runtime directory. The actual location of the directory is controlled by &lt;code&gt;--prefix&lt;/code&gt;. The runtime directory location will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Depending on the version of vim being built, this might be vim74. &#xA;# In general, the format vimXY, where X is the major version number,&#xA;# and Y is the minor version number is followed.&#xA;$YOUR_PREFIX_PATH/share/vim/vim81&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When running make, one should:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make VIMRUNTIMEDIR=$YOUR_PREFIX_PATH/share/vim/vim81&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will cause the resulting vim install to look in the correct location, and hence, it will find syntax.vim etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;TL;DR: VIMRUNTIMEDIR is actually populated correctly. The location is determined by the &lt;code&gt;--prefix&lt;/code&gt; option during the configuration phase, and the proper path must be given to make. In the case of vim8, not specifying the &lt;code&gt;VIMRUNTIMEPATH&lt;/code&gt; is fine.&lt;/p&gt;&#xA;" OwnerUserId="11789" LastEditorUserId="11789" LastEditDate="2019-04-08T17:47:48.713" LastActivityDate="2019-04-08T17:47:48.713" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19491" PostTypeId="1" CreationDate="2019-04-08T22:50:05.020" Score="0" ViewCount="477" Body="&lt;p&gt;I'm receiving the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Color name or number not recognized: ctermbg=g:extra_whitespace_color guibg=g:extra_whitespace_color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pointing to these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:extra_whitespace_color = 'black'&#xA;highlight ExtraWhitespace ctermbg=g:extra_whitespace_color guibg=g:extra_whitespace_color&#xA;autocmd ColorScheme * highlight ExtraWhitespace ctermbg=g:extra_whitespace_color guibg=g:extra_whitespace_color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I don't use a variable, everything works but I'm unclear what I'm doing wrong.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd ColorScheme * highlight ExtraWhitespace ctermbg=black guibg=black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="552" LastActivityDate="2019-04-08T23:39:44.753" Title="Color name or number not recognized: ctermbg" Tags="|colorscheme|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19492" PostTypeId="2" ParentId="19491" CreationDate="2019-04-08T23:39:44.753" Score="2" Body="&lt;p&gt;Variable interpolation is not automatic in certain contexts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute printf('highlight ExtraWhitespace ctermbg=%s guibg=%s', g:extra_whitespace_color, g:extra_whitespace_color)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-04-08T23:39:44.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19493" PostTypeId="1" AcceptedAnswerId="19495" CreationDate="2019-04-09T01:26:44.167" Score="0" ViewCount="122" Body="&lt;p&gt;Are there any built-in functions to search sorted list? Such as binary_search, lower_bound, upper_bound, etc.&lt;br&gt;&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="24" LastEditDate="2019-05-10T05:25:06.597" LastActivityDate="2019-05-10T05:25:06.597" Title="Are there any built-in functions to search sorted list?" Tags="|vimscript|search|performance|list|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19494" PostTypeId="1" AcceptedAnswerId="19496" CreationDate="2019-04-09T03:46:29.350" Score="0" ViewCount="2241" Body="&lt;p&gt;I have the following function that inserts tabs if cursor is at the start of a line and required amount of spaces otherwise.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SpecialTab() abort&#xA;    if (col('.') == 1) || (matchstr(getline('.'), '\%'.(col('.') - 1).'c.') =~ '\t')&#xA;        return &quot;\&amp;lt;Tab&amp;gt;&quot;&#xA;    else&#xA;        return repeat(&quot;\&amp;lt;Space&amp;gt;&quot;, (&amp;amp;tabstop - (virtcol('.') % &amp;amp;tabstop) + 1))&#xA;    endif&#xA;endfunction&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; SpecialTab()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;:set backspace=indent,eol,start&lt;/code&gt; with &lt;code&gt;:set expandtab&lt;/code&gt;, one backspace can delete a tabs worth of spaces if you originally inserted a tabs worth of spaces by tapping the  key in the first place. But if you manually typed required amount of spaces, one backspace just deletes one space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to get that with my function. I don't have enough experience to understand C source code and I don't understand how backspace characteristics is maintained. Any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have just checked that vim actually doesn't check whether the spaces were inserted with pressing &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;. It just behaves that way until you escape from the insert mode. After you have escaped from insert mode and returned back to insert mode, if you try to use &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; you'll see that it is deleting &lt;code&gt;&amp;amp;tabstop&lt;/code&gt; amount (i.e. assuming the spaces are integer multiple of &lt;code&gt;&amp;amp;tabstop&lt;/code&gt;) of spaces no matter how you inserted it.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-04-09T09:31:40.577" LastActivityDate="2019-04-09T09:44:38.890" Title="Change the backspace behavior in neovim" Tags="|vimscript|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19495" PostTypeId="2" ParentId="19493" CreationDate="2019-04-09T04:27:37.470" Score="2" Body="&lt;p&gt;There is nothing built in. But you might check &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-vim-lib&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has the following functions working on sorted lists:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;lh#list#equal_range()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;lh#list#lower_bound()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;lh#list#upper_bound()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="51" LastEditDate="2019-04-09T04:33:55.273" LastActivityDate="2019-04-09T04:33:55.273" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19496" PostTypeId="2" ParentId="19494" CreationDate="2019-04-09T08:44:31.297" Score="0" Body="&lt;p&gt;We discuss only non indention space here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;During inserting, if you backspace after a series of tab and space (mixed), vim only check the last key stroke, if it's tab, it delete softtabstop number of spaces, other wise only 1 space deleted. If you backspace immediately after enter insert mode, vim delete softtabstop number of spaces. I don't believe vim knows if existing space are created by tab or space, it's a bit crazy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your backspace behaves different with default because you send 4 space to vim instead of a real tab. To fix that, you must fake a tab by adding an extra tab and backspace after 4 spaces, so vim will believe it's a tab, not space.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim: tabstop=4 shiftwidth=4 softtabstop=4 smarttab shiftround noexpandtab noet list listchars=tab\:+.,space\:-&#xA;&#xA;function! SpecialTab() abort&#xA;    if (col('.') == 1) || (matchstr(getline('.'), '\%'.(col('.') - 1).'c.') =~ '\t')&#xA;        return &quot;\&amp;lt;Tab&amp;gt;&quot;&#xA;    else&#xA;        return repeat(&quot;\&amp;lt;Space&amp;gt;&quot;, (&amp;amp;tabstop - (virtcol('.') % &amp;amp;tabstop) + 1)) . &quot;\&amp;lt;Tab&amp;gt;\&amp;lt;Backspace&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; SpecialTab()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I missed something, it's not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for unknow resason send &lt;code&gt;\&amp;lt;space&amp;gt;\&amp;lt;space&amp;gt;\&amp;lt;space&amp;gt;\&amp;lt;space&amp;gt;\&amp;lt;tab&amp;gt;\&amp;lt;backspace&amp;gt;&lt;/code&gt; will insert a real tab. I have no idea why it behaves like this. But if i send &lt;code&gt;\&amp;lt;space&amp;gt;\&amp;lt;space&amp;gt;\&amp;lt;space&amp;gt;\&amp;lt;space&amp;gt;a\&amp;lt;tab&amp;gt;\&amp;lt;backspace&amp;gt;\&amp;lt;backspace&amp;gt;&lt;/code&gt;, it works.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim: tabstop=4 shiftwidth=4 softtabstop=4 smarttab shiftround noexpandtab noet list listchars=tab\:+.,space\:-&#xA;&#xA;function! SpecialTab() abort&#xA;    if (col('.') == 1) || (matchstr(getline('.'), '\%'.(col('.') - 1).'c.') =~ '\t')&#xA;        return &quot;\&amp;lt;Tab&amp;gt;&quot;&#xA;    else&#xA;        return repeat(&quot;\&amp;lt;Space&amp;gt;&quot;, (&amp;amp;tabstop - (virtcol('.') % &amp;amp;tabstop) + 1)) . &quot;a\&amp;lt;tab&amp;gt;\&amp;lt;backspace&amp;gt;\&amp;lt;backspace&amp;gt;&quot;&#xA;    endif&#xA;endfunction&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; SpecialTab()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;check comment for the reason why &lt;code&gt;\&amp;lt;space&amp;gt;\&amp;lt;space&amp;gt;\&amp;lt;space&amp;gt;\&amp;lt;space&amp;gt;\&amp;lt;tab&amp;gt;\&amp;lt;backspace&amp;gt;&lt;/code&gt; result in a tab. &lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-09T09:44:38.890" LastActivityDate="2019-04-09T09:44:38.890" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="19497" PostTypeId="1" AcceptedAnswerId="19498" CreationDate="2019-04-09T10:33:11.987" Score="1" ViewCount="357" Body="&lt;pre&gt;&lt;code&gt;\p{Cyrillic}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works in my normal regular expressions. When trying to match in Vim or gvim however, I can not seem to get it to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried something like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\p\{Cyrillic}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it not supported, or am I missing something?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2019-04-09T11:30:52.207" Title="Can you match unicode blocks by name in vim?" Tags="|regular-expression|search|unicode|escape|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19498" PostTypeId="2" ParentId="19497" CreationDate="2019-04-09T11:30:52.207" Score="5" Body="&lt;p&gt;Vim has its own regex engine and it doesn't support &lt;code&gt;{Cyrillic}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably want to read &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#pattern-atoms&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h pattern-atoms&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2fcharacter-classes&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h /character-classes&lt;/code&gt;&lt;/a&gt; to find out what you can use in your regexes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the best alternative you can find comes from &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5b%5d&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h /[]&lt;/code&gt;&lt;/a&gt; (especially the last example):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\_[]&#xA;    A collection.  This is a sequence of characters enclosed in brackets.&#xA;    It matches any single character in the collection.&#xA;&#xA;    Example     matches ~&#xA;    [xyz]       any 'x', 'y' or 'z'&#xA;    [a-zA-Z]$   any alphabetic character at the end of a line&#xA;    [А-яЁё]     Russian alphabet (with utf-8 and cp1251)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-04-09T11:30:52.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19499" PostTypeId="1" CreationDate="2019-04-09T12:00:38.717" Score="2" ViewCount="7604" Body="&lt;p&gt;How do I display the list of all buffers in the tabline? I am using the &lt;a href=&quot;https://github.com/itchyny/lightline.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;lightline plugin&lt;/a&gt;, with the following settings in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set showtabline=2&#xA;let g:lightline = { 'colorscheme': 'PaperColor' }&#xA;let g:lightline.tabline = {&#xA;            \ 'left': [ [ 'tabs' ] ],&#xA;            \ 'right': [ [ 'bufnum'] ] }&#xA;let g:lightline.separator = { 'left': '', 'right': '' }&#xA;let g:lightline.subseparator = {'left': '', 'right': '' }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am only able to view one buffer name in the tabline at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wF1aq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wF1aq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Swapping through the various buffers simply updates the name in the single available tab slot, like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/j8Gjl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/j8Gjl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, I would like to display the buffer names simultaneously in the tabline, like the &lt;a href=&quot;https://github.com/ap/vim-buftabline&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-buftabline&lt;/a&gt; plugin does here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8UgwD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8UgwD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway I can achieve this without installing additional plugins? Is this a lightline issue or a vim issue, i.e. what do I need to add to my &lt;code&gt;.vimrc&lt;/code&gt; to solve this? I've scoured the docs for lightline and vim (&lt;code&gt;:h setting-tabline&lt;/code&gt;, etc.) and couldn't figure out how to display all the buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for reading&lt;/p&gt;&#xA;" OwnerUserId="21416" LastEditorUserId="21416" LastEditDate="2019-04-09T12:09:14.903" LastActivityDate="2020-11-21T00:09:36.107" Title="How to display all buffer names in tabline?" Tags="|buffers|statusline|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="19500" PostTypeId="2" ParentId="12536" CreationDate="2019-04-09T13:06:00.470" Score="2" Body="&lt;p&gt;&lt;code&gt;gll&lt;/code&gt; indents item right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;glh&lt;/code&gt; indents item left.&lt;/p&gt;&#xA;" OwnerUserId="21724" LastActivityDate="2019-04-09T13:06:00.470" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19501" PostTypeId="1" AcceptedAnswerId="19503" CreationDate="2019-04-09T14:28:35.867" Score="4" ViewCount="350" Body="&lt;p&gt;Is there a nondestructive way to search a pattern in all registers, like redirecting &lt;code&gt;:reg&lt;/code&gt; to some register and then paste it to a new buffer and perform the search there? &lt;/p&gt;&#xA;" OwnerUserId="21649" LastEditorUserId="1841" LastEditDate="2019-04-09T15:31:40.723" LastActivityDate="2019-04-09T21:51:56.110" Title="How to search in all registers" Tags="|register|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19502" PostTypeId="2" ParentId="19501" CreationDate="2019-04-09T14:49:32.510" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here is a gist from romainl&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my tweaked version of the gist.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Redirect the output of a Vim or external command into a scratch buffer&#xA;command! -nargs=1 Redir&#xA;            \ tabnew |&#xA;            \ setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile |&#xA;            \ call setline(1, split(execute(&amp;lt;q-args&amp;gt;), &quot;\n&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, you can do &lt;code&gt;:Redir reg&lt;/code&gt; to open a new tabpage with output of &lt;code&gt;:reg&lt;/code&gt;. Then do what you gotta do.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-04-09T16:07:27.537" LastActivityDate="2019-04-09T16:07:27.537" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19503" PostTypeId="2" ParentId="19501" CreationDate="2019-04-09T14:49:35.550" Score="4" Body="&lt;p&gt;You can have the list of registers that match a pattern with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let regs=split('abcdefghijklmnopqrstuvwxyz0123456789/-&quot;.', '\zs')&#xA;&#xA;:echo filter(regs, 'getreg(v:val) =~ &quot;the_pattern&quot;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you really prefer to paste all registers into a buffer in order to search interactively (and not programmatically) -- I leave the creation of scratch buffer out&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let regs=split('abcdefghijklmnopqrstuvwxyz0123456789/-&quot;.', '\zs')&#xA;:call map(regs, '&quot;\&quot;&quot;.v:val. &quot;  &quot;.getreg(v:val)')&#xA;:put=regs&#xA;&#xA;&quot; or, if neither the noise nor the joined lines bother you&#xA;put=execute('registers')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2019-04-09T14:58:44.070" LastActivityDate="2019-04-09T14:58:44.070" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19504" PostTypeId="2" ParentId="19501" CreationDate="2019-04-09T14:55:51.690" Score="3" Body="&lt;p&gt;Just create a new unnamed buffer and then  put the output of &lt;code&gt;:reg&lt;/code&gt; into it with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:enew&#xA;:put =execute('reg')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note that the output of &lt;code&gt;:reg&lt;/code&gt; is truncated to terminal width.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;=&lt;/code&gt; is the &quot;expression register&quot; and &lt;code&gt;execute('reg')&lt;/code&gt; is the expression. See &lt;code&gt;:help @=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;execute()&lt;/code&gt; executes a command and returns the output as string. See &lt;code&gt;:help execute()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Or, to show the power of Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=1 RegSearch echo join(filter(split(execute('reg'), &quot;\n&quot;), {i, v -&amp;gt; v =~ &amp;lt;q-args&amp;gt;}), &quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inner-to-outer:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;execute('reg')&lt;/code&gt; is already known&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;split(..., &quot;\n&quot;)&lt;/code&gt; split into a list of lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;filter(..., {i, v -&amp;gt; v =~ &amp;lt;q-args&amp;gt;})&lt;/code&gt; only keep those line that match the commands argument (see &lt;code&gt;:help &amp;lt;q-args&amp;gt;&lt;/code&gt; and  &lt;code&gt;:help lambda&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;join(..., &quot;\n&quot;)&lt;/code&gt; join the kept list elements into a string separated by newlines.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then use it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:RegSearch &amp;lt;searchterm&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Searchterm is a regular expression. If it contains whitespaces, they have to be escaped with a backslash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;I love it when it is doable on one line :-). And then Christian writes a comment ... :-/ He is right.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-04-09T21:51:56.110" LastActivityDate="2019-04-09T21:51:56.110" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19505" PostTypeId="2" ParentId="439" CreationDate="2019-04-09T14:56:03.887" Score="4" Body="&lt;p&gt;To always join with a single space :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap J gJi &amp;lt;ESC&amp;gt;ciW &amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To join with no space at all (removes trailing+leading space) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-J&amp;gt; gJi &amp;lt;ESC&amp;gt;diW&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21726" LastEditorUserId="1841" LastEditDate="2019-04-09T15:29:52.383" LastActivityDate="2019-04-09T15:29:52.383" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19506" PostTypeId="1" AcceptedAnswerId="19507" CreationDate="2019-04-09T21:18:23.480" Score="1" ViewCount="337" Body="&lt;p&gt;I have some text with two dashes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is some text -- with two dashes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to delete the space before and after the dashes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is some text--with two dashes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way this can be done without simply pressing &lt;code&gt;x&lt;/code&gt; on each space?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought maybe vim-surround works with spaces, so I tried &lt;code&gt;ds&amp;lt;Space&amp;gt;&lt;/code&gt;, but it didn't work.&lt;/p&gt;&#xA;" OwnerUserId="11931" LastActivityDate="2019-04-10T11:22:17.503" Title="Delete whitespace before and after word" Tags="|whitespace|plugin-vim-surround|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19507" PostTypeId="2" ParentId="19506" CreationDate="2019-04-09T21:28:02.620" Score="1" Body="&lt;p&gt;I'd go for a substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/ \+-- \+/--/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;g&lt;/code&gt; flag to be executed globally on the lines (not only first occurrence per line) and &lt;code&gt;c&lt;/code&gt; to confirm (to make sure it does not change things you did not want)&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-04-09T21:28:02.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19508" PostTypeId="1" AcceptedAnswerId="19510" CreationDate="2019-04-09T21:53:02.237" Score="0" ViewCount="199" Body="&lt;p&gt;I have been learning about quickfix recently, trying to make it work well with &lt;code&gt;pytest&lt;/code&gt; to that end I provided my own &lt;code&gt;makeprg&lt;/code&gt; and &lt;code&gt;efm&lt;/code&gt;.&#xA;So far everything is great except that pytest frequently traces error back to a library that I use within my project and when I run &lt;code&gt;:make&lt;/code&gt; vim open a new buffer of file in that 3rd party library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like to do is make vim ignore error paths that are not in my project, which in case of &lt;code&gt;pytest&lt;/code&gt; happen to be error that start with absolute path rather than relative one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure if this is of any relevance to this but this is my efm &lt;code&gt;%f:%l:\ %m&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5827" LastActivityDate="2019-04-10T04:29:22.510" Title="Modify Quickfix to ignore paths outside project" Tags="|quickfix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19510" PostTypeId="2" ParentId="19508" CreationDate="2019-04-10T04:29:22.510" Score="3" Body="&lt;p&gt;There is a marker to ignore a matched file: &lt;code&gt;%-G&lt;/code&gt; (see &lt;code&gt;:help efm-ignore&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you want to ignore a line that contains an absolute path, just ignore anything matching &lt;code&gt;/.*&lt;/code&gt;. For errorformat this is written as &lt;code&gt;/.%#&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Combined together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set errorformat=%-G/.%#,%f:%l:\ %m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are on Windows, maybe the following (can't test):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set errorformat=%-G.:\\.%#,%f:%l:\ %m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-04-10T04:29:22.510" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19512" PostTypeId="2" ParentId="19506" CreationDate="2019-04-10T11:22:17.503" Score="3" Body="&lt;h2&gt;vim-surround by tpope on &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have tried following undocumented feature of vim-surround&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ds&amp;lt;space&amp;gt;&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it worked for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has been added in commit &lt;a href=&quot;https://github.com/tpope/vim-surround/commit/e38dea39723c49caa7700f1b8904314e07a82a65&quot; rel=&quot;nofollow noreferrer&quot;&gt;Support &lt;code&gt;ds&amp;lt;space&amp;gt;&amp;lt;space&amp;gt;&lt;/code&gt;&lt;/a&gt; (7 Aug 2015&#xA;).&#xA;This commit was added after the release of version &lt;code&gt;2.1&lt;/code&gt; (2015-02-08) which is currently the newest version on &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1697&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim.org&lt;/a&gt;. Therefore, this feature is only available if you have pulled in a newer version from &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;. Most plugin manager, e.g. vim-plug or minpac, do this anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, there is an alternative plugin &lt;a href=&quot;https://github.com/machakann/vim-sandwich&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sandwich&lt;/a&gt; which supports this as well (here by default &lt;code&gt;sd&amp;lt;space&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-04-10T11:22:17.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19513" PostTypeId="1" AcceptedAnswerId="19596" CreationDate="2019-04-10T12:13:02.657" Score="1" ViewCount="69" Body="&lt;p&gt;I used to believe that &lt;code&gt;:buffer file&lt;/code&gt; is faster than &lt;code&gt;:edit file&lt;/code&gt; if file is   an existing unchanged buffer. I even created a tiny function for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! myvim#open(file) abort&#xA;  let nr = bufnr(a:file)&#xA;  if nr != -1&#xA;    exec printf('buffer %d', nr)&#xA;  else&#xA;    exec printf('edit %s', a:file)&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I totally forgot why and when i did this.&#xA;So, are there any performance difference between :edit and :buffer on existing buffer?&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-10T13:48:03.870" LastActivityDate="2019-04-16T00:58:22.417" Title="Are there any performance difference between :edit and :buffer on existing unchanged buffer?" Tags="|buffers|performance|command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19514" PostTypeId="1" CreationDate="2019-04-10T13:39:21.000" Score="4" ViewCount="284" Body="&lt;p&gt;When you switch to command-line-mode, with &lt;kbd&gt;:&lt;/kbd&gt;, you see a &quot;:&quot; symbol identifying that you're indeed in command line mode. Is there any way, other than modifying source code, I can change this symbol?&lt;/p&gt;&#xA;" OwnerUserId="21742" LastActivityDate="2019-04-11T08:56:05.227" Title="How do I change the &quot;:&quot; symbol in the minibuffer?" Tags="|command-line|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19515" PostTypeId="1" CreationDate="2019-04-10T13:54:25.503" Score="1" ViewCount="37" Body="&lt;p&gt;Using VIM (v6.3) from a command-prompt (i.e. not gVIM) I'm getting different behaviour for the &lt;code&gt;:shell&lt;/code&gt; command depending on whether I specify a drive-letter when editing a file or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Without Driver Letter&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;X:\&amp;gt;vi Directory\File.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(file opens; use &lt;code&gt;:sh&lt;/code&gt; to open a command-prompt)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Microsoft Windows [Version 10.0.17763.379]&#xA;(c) 2018 Microsoft Corporation. All rights reserved.&#xA;&#xA;X:\&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;With Driver Letter&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;X:\&amp;gt;vi X:\Directory\File.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(file opens; use &lt;code&gt;:sh&lt;/code&gt; to open a command-prompt)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Microsoft Windows [Version 10.0.17763.379]&#xA;(c) 2018 Microsoft Corporation. All rights reserved.&#xA;&#xA;X:\Directory&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In both cases, I'm editing the same file (&lt;code&gt;X:\Directory\File.txt&lt;/code&gt;), from the same location (&lt;code&gt;X:&lt;/code&gt;) but if I don't specify the drive-letter I'm left in the original directory (what I want) whereas if I &lt;em&gt;do&lt;/em&gt; specify the driver letter I'm left in the directory containing the file being edited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know &lt;strong&gt;(a)&lt;/strong&gt; why this is happening, and &lt;strong&gt;(b)&lt;/strong&gt; how to stop it? Ideally I'd like to be left in &lt;code&gt;X:\&lt;/code&gt; in both the above cases. Tested on both Windows 7 and Windows 10.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This also seems to affect the expansion of &lt;code&gt;%&lt;/code&gt; (&quot;the current filename&quot;) when executing a shell command. When the drive-letter is given, and the shell opens in the directory containing the file being edited, &lt;code&gt;%&lt;/code&gt; expands to just the name of the file (&lt;code&gt;File.txt&lt;/code&gt;). Without the driver-letter, &lt;code&gt;%&lt;/code&gt; expands to the path as entered when starting VI (&lt;code&gt;Directory\File.txt&lt;/code&gt;). However, I can handle this by using &lt;code&gt;%:p&lt;/code&gt; which in both cases expands to the full drive/path/name (&lt;code&gt;Directory\File.txt&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="2740" LastEditorUserId="2740" LastEditDate="2019-04-10T14:50:09.687" LastActivityDate="2019-04-10T15:54:19.403" Title="Why does current/shell directory change depending whether drive-letter is used in filename?" Tags="|microsoft-windows|shell|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19516" PostTypeId="2" ParentId="19514" CreationDate="2019-04-10T15:38:56.273" Score="7" Body="&lt;p&gt;The answer is short and might be unpleasing for you but: no.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't change that character without modifying the sources.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-04-10T15:38:56.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19517" PostTypeId="1" AcceptedAnswerId="19524" CreationDate="2019-04-10T15:41:36.353" Score="0" ViewCount="445" Body="&lt;p&gt;I want to map an operator-pending key combination to erase contents of any embedded combination of &lt;code&gt;(text)&lt;/code&gt;, &lt;code&gt;[more text]&lt;/code&gt;, &lt;code&gt;&amp;lt;other text&amp;gt;&lt;/code&gt; or &lt;code&gt;{misc text}&lt;/code&gt; by placing my cursor inside and issuing the &lt;code&gt;c+&amp;lt;mapped_key&amp;gt;&lt;/code&gt; o &lt;code&gt;d+&amp;lt;mapped_key&amp;gt;&lt;/code&gt; operator-pending mode cmds in buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Until now I have always used (in &lt;code&gt;~/.vimrc&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap p i(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that only concerns &lt;code&gt;()&lt;/code&gt; and their embeddings, such that if I place my cursor on &quot;more&quot; inside &lt;code&gt;(text [more te &amp;lt;001  &amp;gt;xt] misc text)&lt;/code&gt;, issuing &lt;code&gt;dp&lt;/code&gt; will not only delete &quot;more te &amp;lt;001  &gt;xt&quot;, which is what I would like, but (as expected) everything between ( and ).  Having:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap p( i(&#xA;onoremap p[ i[&#xA;onoremap p{ i{&#xA;onoremap p&amp;lt; i&amp;lt;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is not practical. I would like one mapping, NOT four different ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to &lt;code&gt;onoremap p &amp;lt;RHS&amp;gt;&lt;/code&gt; to ANY occurence of (), [], &amp;lt;&gt; or {} and their embeddings ?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;EDIT:&lt;/em&gt;&lt;/strong&gt;&#xA;Please test with something such as the following line of plain text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dd xsd  sdl(sddi{dss[ asd]aa }e9&amp;lt;888&amp;gt;n 0:)&quot;wdwww&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4547" LastEditorUserId="4547" LastEditDate="2019-04-10T18:01:34.413" LastActivityDate="2019-04-11T07:55:03.190" Title="Mapping (omap) to erase inside any of (), {}, [], &lt;&gt; or their embeddings" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19518" PostTypeId="2" ParentId="19515" CreationDate="2019-04-10T15:54:19.403" Score="1" Body="&lt;p&gt;I can't say why it happens - I've reproduced the behaviour and it is strange indeed - but here is a work-around I found:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi -c &quot;cd %CD%&quot; X:\Directory\File.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;-c&lt;/code&gt;, vi will execute the &lt;code&gt;cd&lt;/code&gt; command as soon as it opens, taking you back to the working directory you launched vi from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Caveat: when I'm at C:\ (rather than c:\some-other-dir), I get an error message as vi starts, but the working directory is set correctly despite that error message.&lt;/p&gt;&#xA;" OwnerUserId="21446" LastActivityDate="2019-04-10T15:54:19.403" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19519" PostTypeId="2" ParentId="17686" CreationDate="2019-04-10T15:56:06.173" Score="2" Body="&lt;p&gt;I think would be useful a &quot;Toggle&quot; mapping that allows us to swich concealling level:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;c :let &amp;amp;cole=(&amp;amp;cole == 2) ? 0 : 2 &amp;lt;bar&amp;gt; echo 'conceallevel ' . &amp;amp;cole &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2019-04-10T15:56:06.173" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19521" PostTypeId="1" CreationDate="2019-04-10T23:38:46.807" Score="10" ViewCount="4268" Body="&lt;p&gt;I'm trying to find a way to show relative line numbers as well as absolute line numbers, but not the way &lt;a href=&quot;https://jeffkreeftmeijer.com/vim-number/&quot; rel=&quot;noreferrer&quot;&gt;hybrid line numbers&lt;/a&gt; does it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to see both at all times, probably each displayed on a column.  Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="21750" LastActivityDate="2023-03-17T03:01:00.773" Title="Show absolute and relative line numbers (not hybrid)" Tags="|line-numbers|" AnswerCount="3" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19522" PostTypeId="1" AcceptedAnswerId="19523" CreationDate="2019-04-11T00:27:05.213" Score="6" ViewCount="11132" Body="&lt;p&gt;I'd like to change the default terminal of Vim from &lt;code&gt;cmd&lt;/code&gt; to &lt;code&gt;cmder&lt;/code&gt;. By using &lt;code&gt;:help :terminal&lt;/code&gt; I have read the &lt;code&gt;terminal.txt&lt;/code&gt; but it seems that there is no setting instruction in that help file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is it likely to change the default terminal of vim by using &lt;code&gt;:terminal&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="21738" LastEditorUserId="1238" LastEditDate="2019-04-12T07:07:37.543" LastActivityDate="2019-04-12T07:07:37.543" Title="Is it possible to change the default terminal of Vim?" Tags="|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19523" PostTypeId="2" ParentId="19522" CreationDate="2019-04-11T02:25:53.467" Score="5" Body="&lt;p&gt;The &lt;a href=&quot;http://vimhelp.appspot.com/terminal.txt.html#%3Aterminal&quot; rel=&quot;nofollow noreferrer&quot;&gt;help for &lt;code&gt;:terminal&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If [command] is not given the 'shell' option is used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On that help page, if you move the cursor inside the word &quot;shell&quot; and press &lt;code&gt;C-]&lt;/code&gt; (the control key and the right bracket), it'll take you to the help for the shell setting.  Alternatively, you can get there with &lt;code&gt;:help 'shell'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like you should be able to add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shell=cmder&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may need to specify the full path to cmder depending on whether it's in your system path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that the &lt;code&gt;shell&lt;/code&gt; setting is used for executing external commands from vim.  I'd recommend reading the help for that setting to make sure it will work as you expect.&lt;/p&gt;&#xA;" OwnerUserId="1115" LastEditorUserId="205" LastEditDate="2019-04-11T02:38:29.197" LastActivityDate="2019-04-11T02:38:29.197" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19524" PostTypeId="2" ParentId="19517" CreationDate="2019-04-11T03:49:07.507" Score="1" Body="&lt;p&gt;&lt;strong&gt;warning&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;!!!! Dangerous cmd when used with cursor outside visible set of bracketing characters (), &amp;lt;&gt;, [] or {}, because it will happily wrap around end-of-lines and greedily execute on the nearest set of unrelated opening and closing orphan bracketing symbols.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;implemention&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a bit complicated, read comment as explanation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; objs  : any valid text object without i or a, eg: '{[(&amp;lt;'&#xA;&quot; ai    : 'a' or 'i'&#xA;&quot; force : start visual mode even if no valid text object found&#xA;&quot;&#xA;&quot; visually select minimal textobject&#xA;function! SelectMinTextObject(objs, ai, force)&#xA;  &quot; init data&#xA;  let [minObj, minObjStart, minObjEnd] = ['', [], []]&#xA;&#xA;  &quot; split objs into list, loop it&#xA;  for obj in split(a:objs, '\zs')&#xA;&#xA;    &quot; get textobject range, continue if it's blank&#xA;    let [startPos, endPos] = GetTextObjectPos(a:ai . obj)&#xA;    if startPos == [] | continue | endif&#xA;&#xA;    &quot; updat data if it's empty or current text object is smaller&#xA;    if minObj ==# '' || minObjStart[1] &amp;lt; startPos[1] ||&#xA;          \ minObjStart[1] == startPos[1] &amp;amp;&amp;amp; minObjStart[2] &amp;lt; startPos[2]&#xA;      let [minObj, minObjStart, minObjEnd] = [obj, startPos, endPos]&#xA;    endif&#xA;&#xA;  endfor&#xA;&#xA;  &quot; return if no valid obj found&#xA;  if minObj ==# ''&#xA;    if a:force&#xA;      normal! v&#xA;    endif&#xA;    return 0&#xA;  endif&#xA;&#xA;  &quot; visually select textobject.&#xA;  execute 'normal! v'. a:ai . minObj&#xA;&#xA;  return 1&#xA;endfunction&#xA;&#xA;&quot; get text object range as [startPos, endPos], pos format is the same as&#xA;&quot; getpos(), except it returns [[],[]] if text object is blank&#xA;function! GetTextObjectPos(obj)&#xA;  try&#xA;    &quot; record cursor, @a, '[, ']&#xA;    let [ cursorPos, regText, regType, yankPos0, yankPos1 ] =&#xA;          \ [ getcurpos(), getreg('&quot;'), getregtype('&quot;'),&#xA;          \   getpos(&quot;'[&quot;), getpos(&quot;']&quot;)]&#xA;    &quot; clear register. it's necessary because &quot;ay.. won't fill a if .. is blank&#xA;    let @a = ''&#xA;    &quot; copy text object into @a if it's not blank&#xA;    exec 'normal! &quot;ay' . a:obj&#xA;    &quot; return blank if nothing copied, otherwise return start and end of copied&#xA;    &quot; area&#xA;    return @a ==# '' ? [[],[]] : [getpos(&quot;'[&quot;), getpos(&quot;']&quot;)]&#xA;  finally&#xA;    &quot; restore cursor, @a, '[, ']&#xA;    call setpos('.', cursorPos) | call setreg('a', regText, regType)&#xA;    call setpos(&quot;'[&quot;, yankPos0) | call setpos(&quot;']&quot;, yankPos1)&#xA;  endtry&#xA;endfunction&#xA;&#xA;&quot; you can't implement omap with vmap, because miminal v area is 1 character,&#xA;&quot; miminal o area is 0 character&#xA;vnoremap ip &amp;lt;esc&amp;gt;:call SelectMinTextObject('({[&amp;lt;', 'i', 1)&amp;lt;cr&amp;gt;&#xA;vnoremap ap &amp;lt;esc&amp;gt;:call SelectMinTextObject('({[&amp;lt;', 'a', 1)&amp;lt;cr&amp;gt;&#xA;onoremap ip :call SelectMinTextObject('({[&amp;lt;', 'i', 0)&amp;lt;cr&amp;gt;&#xA;onoremap ap :call SelectMinTextObject('({[&amp;lt;', 'a', 0)&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; dd xsd  sdl(sddi{dss[ asd]aa }e9&amp;lt;888&amp;gt;n 0:)&quot;wdwww&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;known issue&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vip&lt;/code&gt; will discard whatever you visually selected before. It's inconsistent with &lt;code&gt;viw&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-11T07:55:03.190" LastActivityDate="2019-04-11T07:55:03.190" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19525" PostTypeId="1" AcceptedAnswerId="19526" CreationDate="2019-04-11T04:17:23.933" Score="3" ViewCount="1832" Body="&lt;p&gt;I know that with commands like &lt;code&gt;sbuffer&lt;/code&gt; you can create a new buffer and display it in a split window, and commands like &lt;code&gt;enew&lt;/code&gt; can create a new buffer in the current window. But is it possible to not display the buffer in any way but just create a hidden buffer right away?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My use case is that I have a python class that should return a &lt;code&gt;vim.buffer&lt;/code&gt; object to be processed. The display happens differently depending on conditions in the calling object. So I need a buffer that I can load, and write stuff into (it's a buffer not associated with any file, so it's a &lt;code&gt;nofile&lt;/code&gt; buftype), but that is not displayed until I command to load into the current or some other window.&lt;/p&gt;&#xA;" OwnerUserId="21269" LastActivityDate="2019-04-11T06:05:56.460" Title="Creating a hidden buffer" Tags="|buffers|vimscript-python|hidden-buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19526" PostTypeId="2" ParentId="19525" CreationDate="2019-04-11T05:37:32.560" Score="8" Body="&lt;p&gt;I'm not aware that you can create a hidden unnamed buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you can create a hidden (even unlisted) buffer with some fancy name and use that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In VimScript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:myscratch = bufnr(&quot;my-fancy-name&quot;, 1)&#xA;call setbufvar(g:myscratch, &quot;&amp;amp;buftype&quot;, &quot;nofile&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first line returns the buffer number for the buffer named &quot;my-fancy-name&quot;. If the buffer does not exist, it is created as hidden, &lt;em&gt;unlisted&lt;/em&gt; buffer. So you don't see it with &lt;code&gt;:ls&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second line sets the buffer as &lt;code&gt;nofile&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The buffer is created, but (for whatever reasons) you cannot write to it. You first have to activate it for a moment: &lt;sup&gt;[I didn't find another way to make it &quot;writable&quot;.]&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let curbuf = bufnr(&quot;&quot;)&#xA;execute g:myscratch . &quot;buffer&quot;&#xA;execute curbuf . &quot;buffer&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you do this short switch of buffers in a function, you won't see it (screen is not updated).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that you can write to it with &lt;code&gt;setbufline(g:myscratch, ...)&lt;/code&gt; and &lt;code&gt;appendbufline(g:myscratch, ...)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To bring it to view:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute g:myscratch . &quot;buffer&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To finally delete it use &lt;code&gt;bwipeout&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute g:myscratch . &quot;bwipeout&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-04-11T06:05:56.460" LastActivityDate="2019-04-11T06:05:56.460" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19527" PostTypeId="2" ParentId="19514" CreationDate="2019-04-11T08:56:05.227" Score="0" Body="&lt;p&gt;I am really not too sure, but by digging through the plugin &lt;code&gt;vim-easymotion&lt;/code&gt; which displays a prompt &quot;Search for characters: &quot;, I found that it uses:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/osyo-manga/vital-over&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/osyo-manga/vital-over&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which, based on the example, seems to be able to customise the command or search prompt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did not have time to experiment deeply with it, but it might be a lead.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-04-11T08:56:05.227" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19528" PostTypeId="2" ParentId="15926" CreationDate="2019-04-11T11:23:12.087" Score="0" Body="&lt;p&gt;I faced the same issue couple of weeks ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look inside of &lt;code&gt;solarized.vim&lt;/code&gt;, you will find a section &lt;strong&gt;GUI &amp;amp; CSApprox hexadecimal palettes&lt;/strong&gt; (in my case line 235).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a bunch of ifs, the 2 first being &lt;code&gt;if (has(&quot;gui_running&quot;) &amp;amp;&amp;amp; ...)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the terminal, it does not, so depending on if you are using 16 or 256 colors, you will be in the 3rd or 4th &lt;code&gt;elseif&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-If you really want the blue of Solarized, you can set your gnome-terminal profile to use solarized colors and change in &lt;code&gt;solarized.vim&lt;/code&gt; the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:base03 = &quot;234&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:base03 = &quot;NONE&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use the terminal's default color (base03 is used for the background color).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I am not persuaded than modifying the theme like that is the best to do (I tried to set the variable at the end of my &lt;code&gt;.vimrc&lt;/code&gt; but it did not work).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And as I don't want to use solarized in my terminal, just in Vim, I stayed with the grey and 256 colors of solarized by default.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastEditorUserId="21621" LastEditDate="2019-04-11T11:37:08.370" LastActivityDate="2019-04-11T11:37:08.370" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19529" PostTypeId="2" ParentId="15926" CreationDate="2019-04-11T12:00:51.760" Score="0" Body="&lt;p&gt;Most people barely know about gnome terminal color setting, they just use existing tool to do the job.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use&#xA;&lt;a href=&quot;https://github.com/Anthony25/gnome-terminal-colors-solarized&quot; rel=&quot;nofollow noreferrer&quot;&gt;gnome-terminal-colors-solarized&lt;/a&gt; to setup your terminal.&lt;/li&gt;&#xA;&lt;li&gt;use &lt;a href=&quot;https://github.com/seebi/dircolors-solarized&quot; rel=&quot;nofollow noreferrer&quot;&gt;dircolors-solarized&lt;/a&gt; to fix directory color.&lt;/li&gt;&#xA;&lt;li&gt;if your terminal looks solarized, put &lt;code&gt;colorscheme solarized&lt;/code&gt; in your .vimrc . That's all i need to get solarized colorsheme for neovim.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Don't waste your time on vim setting before you setup your terminal.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-04-11T12:00:51.760" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19530" PostTypeId="2" ParentId="16675" CreationDate="2019-04-11T12:34:53.070" Score="5" Body="&lt;p&gt;this is the default mapping of up and down in fzf:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;down : ctrl-j  ctrl-n  down&lt;/li&gt;&#xA;&lt;li&gt;up : ctrl-k  ctrl-p  up&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Most people don't have problem with this. If you really really want to add your own setting, you need to change enviroment variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export FZF_DEFAULT_OPTS='--bind=ctrl-w:up,ctrl-m:down'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;above setting will bind &lt;code&gt;ctrl-w&lt;/code&gt; to &lt;code&gt;up&lt;/code&gt;, &lt;code&gt;ctrl-m&lt;/code&gt; to &lt;code&gt;down&lt;/code&gt;. check &lt;code&gt;man fzf&lt;/code&gt; for detail.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-04-11T12:34:53.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19531" PostTypeId="1" CreationDate="2019-04-11T13:59:24.487" Score="1" ViewCount="81" Body="&lt;p&gt;As I see the substitution command e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:% s/a/b/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;puts a into the register &quot;/ but the text that is being replaced is not saved in a register.&#xA;Now, I would like to replace a with b but keep the result of a in a specific register where I can any moment retrieve it and paste it back at the same position where it was.&#xA;I mean something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace the text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:% s/^\(.*\)\t\(.*\)/\2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Retrieve it from register &quot;z and paste it back where it was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:% s/^/\=@z/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think it should be pretty simple but I couldn't find anything related.&lt;/p&gt;&#xA;" OwnerUserId="21739" LastActivityDate="2019-04-12T14:15:06.603" Title="Cut text with substitute into specific register &amp; paste it back" Tags="|substitute|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19532" PostTypeId="2" ParentId="19531" CreationDate="2019-04-11T14:04:59.477" Score="0" Body="&lt;p&gt;You might want &lt;code&gt;&amp;amp;&lt;/code&gt;, which is the original matched pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:% s/^\(.*\)\t\(.*\)/&amp;amp;\2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, when you do a search (or a substitution), your search regex is stored in the register &lt;code&gt;/&lt;/code&gt;, you can paste it for example with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;/p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21621" LastEditorUserId="21621" LastEditDate="2019-04-11T14:39:39.043" LastActivityDate="2019-04-11T14:39:39.043" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19533" PostTypeId="2" ParentId="19531" CreationDate="2019-04-11T15:07:58.713" Score="0" Body="&lt;p&gt;Yank all the matching text first, then do your substitute:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Clear a register: &lt;code&gt;qaq&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Set a mark at the original point: &lt;code&gt;gg/pattern&lt;/code&gt; then &lt;code&gt;mo&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Yank text: &lt;code&gt;:g//yank A&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Substitute: &lt;code&gt;:%s//replacement/flags&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now paste: &lt;code&gt;'o&quot;ap&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The paste will paste all of the matching text at the location of the first match pre-substitution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to save each match and the line it came from, I’d write a function to create a buffer-local dictionary (&lt;code&gt;line -&amp;gt; text&lt;/code&gt; assuming one match per line, or &lt;code&gt;line -&amp;gt; { column -&amp;gt; text }&lt;/code&gt;—dict of dict—for multiple matches anticipated), loop over the matches, grab the text and line number for the dicts, then do the substitution. Then you could write a separate function to &quot;restore&quot; from this dictionary based on line (and column) &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-04-11T17:30:26.737" LastActivityDate="2019-04-11T17:30:26.737" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19534" PostTypeId="1" CreationDate="2019-04-11T15:13:19.190" Score="1" ViewCount="84" Body="&lt;p&gt;I have a bug and I can't figure out the solution. Perhaps you esteemed folk can be of aid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to extend a syntax file (julia syntax in polyglot package). I want to include the following patterns&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;\::\zs\w*\ze&quot;&#xA;&quot;\^\s*function \zs\w*\ze\(&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first is intended to match words following ::. The second is intended to match the function name foo in an expression like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function foo(bar)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my .vim/after/syntax/julia.vim, I write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match juliaCustomType &quot;\v::\zs\w*\ze&quot; display&#xA;syntax match juliaFunctionName &quot;\v^\s*function \zs.*\ze\(&quot; display&#xA;&#xA;highlight def link juliaCustomType Constant&#xA;highlight def link juliaFunctionName Function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this works if I disable vim-polyglot and the julia-vim packages, the ones providing julia syntax support. If I add either of them back, it no longer works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I add both the custom groups to the relevant syntax cluster &lt;code&gt;juliaExpressions&lt;/code&gt;, which is the one that is allowed to be contained in other regions everywhere. I check this by making a mock syn match like this &lt;code&gt;syntax match juliaCustomType &quot;foobar&quot;&lt;/code&gt; and see that it highlights inside syntax regions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if I remove &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; from the &lt;code&gt;::&lt;/code&gt;matching, it works but highlights the :: which I don't want. The second expression, I believe has some problems because of how &lt;code&gt;function&lt;/code&gt; is handled in this line from the package syntax file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:nodot = '\%(\.\)\@'.s:d(1).'1&amp;lt;!'&#xA;exec 'syntax region juliaFunctionBlock matchgroup=juliaBlKeyword start=&quot;'.s:nodot.'\&amp;lt;function\&amp;gt;&quot; end=&quot;'.s:nodot.'\&amp;lt;end\&amp;gt;&quot; contains=@juliaExpressions fold'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I can't for the life of me figure out what the problem is. Any help or suggestions are welcome!&lt;/p&gt;&#xA;" OwnerUserId="21761" LastActivityDate="2019-04-11T15:13:19.190" Title="Syntax highlighting - help me find the bug" Tags="|vimrc|vimscript|syntax|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19536" PostTypeId="2" ParentId="7466" CreationDate="2019-04-11T18:25:52.107" Score="14" Body="&lt;p&gt;SnipMate and UltiSnips are the two most popular snippet engine for Vim. Both are inspired from TextMate's snippet syntax.  UltiSnips can run all SnipMate snippets but also have additional syntax to make it more powerful.&lt;/p&gt;&#xA;&lt;p&gt;A good rule of thumb is that if your Vim has python support, then use UltiSnips.  If not, then use SnipMate.&lt;/p&gt;&#xA;&lt;p&gt;UltiSnips dropped support for &lt;code&gt;python2&lt;/code&gt; on Nov 5, 2019, see &lt;a href=&quot;https://github.com/SirVer/ultisnips/pull/1129&quot; rel=&quot;noreferrer&quot;&gt;Remove support for Python2 #1129&lt;/a&gt;.&#xA;In your &lt;code&gt;.vimrc&lt;/code&gt;, load (using Plug) one of the plugins depending on python availability.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if has('python3')&#xA;    Plug 'SirVer/ultisnips'&#xA;elseif has('python')&#xA;    Plug 'SirVer/ultisnips', {&#xA;        \   'tag': '3.2',&#xA;        \   'dir': get(g:, 'plug_home', '~/.vim/plugged') . '/ultisnips_py2',&#xA;        \ }&#xA;else&#xA;    Plug 'garbas/vim-snipmate'&#xA;    Plug 'MarcWeber/vim-addon-mw-utils' &amp;quot;required for snipmate&#xA;    Plug 'tomtom/tlib_vim' &amp;quot;required for snipmate&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;UltiSnips can also run python codes in its snippet, allowing it to do some cool tricks.  This is one of my favorite snippet that draws a box around a text (from &lt;a href=&quot;https://castel.dev/post/lecture-notes-1/&quot; rel=&quot;noreferrer&quot;&gt;How I'm able to take notes in mathematics lectures using LaTeX and Vim | Gilles Castel&lt;/a&gt; )&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;snippet box2 &amp;quot;Box&amp;quot;&#xA;`!p snip.rv = '┌' + '─' * (len(t[1]) + 2) + '┐'`&#xA;│ $1 │&#xA;`!p snip.rv = '└' + '─' * (len(t[1]) + 2) + '┘'`&#xA;$0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With this snippet, I can output something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;┌─────────────────────┐&#xA;│ this is a cool box! │&#xA;└─────────────────────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21762" LastEditorUserId="17257" LastEditDate="2020-10-09T14:11:00.360" LastActivityDate="2020-10-09T14:11:00.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19537" PostTypeId="2" ParentId="19432" CreationDate="2019-04-11T19:20:59.703" Score="0" Body="&lt;p&gt;One easy way to do this is to have different file name extension for different language, which makes it easy to set spellchecker's language based on its extension. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you write mostly in English, you can designate &lt;code&gt;.txt&lt;/code&gt; to use English spelling, and &lt;code&gt;.ptxt&lt;/code&gt; as Portuguese spelling.  So, an English text file might be &lt;code&gt;file1.txt&lt;/code&gt; and Portuguese text might be &lt;code&gt;file2.ptxt&lt;/code&gt;. (I just made up the file extension &lt;code&gt;.ptxt&lt;/code&gt;. It could be anything, like &lt;code&gt;.pt&lt;/code&gt; or &lt;code&gt;.pt_txt&lt;/code&gt;, etc)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then in &lt;code&gt;.vimrc&lt;/code&gt;, inside the &lt;code&gt;autocmd&lt;/code&gt;, add the following to load different spell checker based on filename extension (checking for either &lt;code&gt;.txt&lt;/code&gt; or &lt;code&gt;.ptxt&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;autocmd&quot;)&#xA;  augroup vimrcEx&#xA;    au! &#xA;    &quot;... all the autocmd goes here&#xA;    autocmd BufNewFile,BufReadPost  *.txt setlocal spell spelllang=en_gb spellfile=~/.vim/spell/en.utf-8.add&#xA;    autocmd BufNewFile,BufReadPost  *.ptxt setlocal filetype=text spell spelllang=pt spellfile=~/.vim/spell/pt.utf-8.add&#xA;  augroup END&#xA;endif &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you want to be able to switch to different spelling by manually pressing keys:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F10&amp;gt; :setlocal spelllang=en_gb spellfile=~/.vim/spell/en.utf-8.add&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;F11&amp;gt; :setlocal spelllang=pt spellfile=~/.vim/spell/pt.utf-8.add&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the other hand, if you're mixing both English and Portuguese in one text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal spelllang=pt,en_gb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21762" LastEditorUserId="21762" LastEditDate="2019-04-11T19:43:04.680" LastActivityDate="2019-04-11T19:43:04.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19538" PostTypeId="2" ParentId="19432" CreationDate="2019-04-11T20:28:33.310" Score="0" Body="&lt;p&gt;Based on the comments above I went with this solution&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Spelling {{{&#xA;if has('spell')&#xA;  set nospell&#xA;  set dictionary=/user/share/dict/words&#xA;  set complete+=kspell&#xA;  &quot; Manually Added Words Are Sent To `Names` Dictionary&#xA;  nnoremap zG 2zg&#xA;endif&#xA;&#xA;function! s:ToggleSpellLanguage(lang)&#xA;  if a:lang == 'none'&#xA;    set spellfile=&#xA;    set spelllang=&#xA;    set nospell&#xA;    return&#xA;  else&#xA;    let &amp;amp;spellfile=expand('~/.dotfiles/vim/spell/' . a:lang . '.utf-8.add') . ',' . expand('~/.dotfiles/vim/spell/names.utf-8.add')&#xA;    if a:lang == 'en'&#xA;      set spelllang=en_us&#xA;    elseif a:lang == 'pt'&#xA;      set spelllang=pt_pt&#xA;    endif&#xA;    set spell&#xA;  endif&#xA;endfunction&#xA;command! -nargs=1 ToggleSpellLanguage call &amp;lt;sid&amp;gt;ToggleSpellLanguage(&amp;lt;q-args&amp;gt;)&#xA;&quot; }}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;zg&lt;/code&gt; to add new words to the &quot;language&quot; dictionary. and &lt;code&gt;zG&lt;/code&gt; to add words to the private/names dictionary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks  &lt;/p&gt;&#xA;" OwnerUserId="14568" LastActivityDate="2019-04-11T20:28:33.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19539" PostTypeId="1" CreationDate="2019-04-11T22:18:44.230" Score="0" ViewCount="68" Body="&lt;p&gt;POD is a markup file that is used by Perl. It's a pretty unreasonable documentation format that has nothing to do with perl (accept for being the only known use-case), and it's sometimes found &lt;a href=&quot;https://metacpan.org/pod/distribution/perl/pod/perlpod.pod#Embedding-Pods-in-Perl-Modules&quot; rel=&quot;nofollow noreferrer&quot;&gt;intermingled with code&lt;/a&gt;. Think MarkDown-nroff hybrid, but optimized to distract the user from anything they may be doing. You can find more information on it from the official docs on &lt;a href=&quot;https://metacpan.org/pod/perlpod&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;perlpod&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;https://metacpan.org/pod/perlpodspec&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;perlpodspec&lt;/code&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to fold POD, but in such a way that the&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the fold isn't affected by generic operations (&lt;code&gt;zF&lt;/code&gt; to unfold all) unless I'm explicitly targeting that fold, and for it to otherwise not-expand unless requested.&lt;/li&gt;&#xA;&lt;li&gt;for it to &lt;strong&gt;not&lt;/strong&gt; be searched when I do &lt;code&gt;/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I just don't want to be bothered with POD inside the document.&lt;/p&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="51" LastEditDate="2021-07-28T10:29:05.870" LastActivityDate="2021-07-28T10:29:05.870" Title="Define a fold that can not be searched, and that isn't affected by other fold commands?" Tags="|folding|file-formats|filetype-perl|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19541" PostTypeId="1" CreationDate="2019-04-11T22:47:33.960" Score="2" ViewCount="93" Body="&lt;p&gt;How can I make continuation lines indent 1 tab instead of align with the some text? With the default cindent options, I get the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static int A = 0,&#xA;           B = 0,&#xA;           C = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, what I want is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static int A = 0,&#xA;    B = 0,&#xA;    C = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have gone through all the cino settings, and none of them seem to affect this. What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="19614" LastEditorUserId="19614" LastEditDate="2019-04-14T23:37:16.140" LastActivityDate="2019-04-14T23:37:16.140" Title="Unwanted extra indentation of multi-line statements" Tags="|vimrc|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19542" PostTypeId="1" AcceptedAnswerId="19549" CreationDate="2019-04-11T23:01:52.310" Score="1" ViewCount="403" Body="&lt;p&gt;I am trying to set &lt;code&gt;foldmarker={{{,\n\n\n&lt;/code&gt;, so that &lt;code&gt;{{{&lt;/code&gt; starts a fold and two consecutive empty lines end a fold. However, vim treats this as equivalent to &lt;code&gt;foldmarker={{{,nnn&lt;/code&gt;. Is it possible to use newlines in a fold marker in this way?&lt;/p&gt;&#xA;" OwnerDisplayName="user20228" LastActivityDate="2019-04-12T12:50:02.160" Title="Is it possible to use newlines in a fold marker?" Tags="|folding|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19543" PostTypeId="2" ParentId="19539" CreationDate="2019-04-12T02:55:03.757" Score="1" Body="&lt;p&gt;You can probably use &lt;code&gt;foldexpr&lt;/code&gt; to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://gist.github.com/bpj/0727f00b5c566bdd8fb0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here is a gist written by a person on the Internet&lt;/a&gt;. It defines a &lt;code&gt;foldexpr&lt;/code&gt; function for folding the &lt;code&gt;POD&lt;/code&gt; format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried it on a random Perl script I found on &lt;a href=&quot;http://sphaerula.com/legacy/Perl/Intermediate/podusage.html#completeExample&quot; rel=&quot;nofollow noreferrer&quot;&gt;this site (warning no https)&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;foldexpr&lt;/code&gt; seems to work okay. It might work well enough for your use case that you can tweak it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the example script I found it managed to hide most but not all of the &lt;code&gt;POD&lt;/code&gt; documentation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+   +-- 11 lines: !/usr/local/bin/perl---------------------------------------------------------------------------------------------------&#xA;                                   [--clearDb] [--writeToDb]&#xA;                                   --path path --division name&#xA;                                   --out name&#xA;&#xA;+   +--  2 lines: Examples:--------------------------------------------------------------------------------------------------------------&#xA;        perl parseRefSeqGenomes.pl --help&#xA;&#xA;        perl parseRefSeqGenomes.pl --man&#xA;&#xA;        #   Load all RefSeq data:&#xA;&#xA;        perl parseRefSeqGenomes.pl --clearDb --writeToDb&#xA;                                   --path /data/genomes --division bct&#xA;                                   --out bct.genomes.pep.fasta&#xA;&#xA;+   +-- 82 lines: =head1 DESCRIPTION-----------------------------------------------------------------------------------------------------&#xA;+   +-- 16 lines: package main;----------------------------------------------------------------------------------------------------------&#xA;        #   Check arguments.&#xA;&#xA;        my( $help, $man, $clearDb, $writeToDb, $division, $path, $outFileName );&#xA;&#xA;        Getopt::Long::GetOptions(&#xA;            'help'          =&amp;gt;  \$help,&#xA;            'man'           =&amp;gt;  \$man,&#xA;            'clearDb'       =&amp;gt;  \$clearDb,&#xA;            'writeToDb'     =&amp;gt;  \$writeToDb,&#xA;            'division=s'    =&amp;gt;  \$division,&#xA;            'path=s'        =&amp;gt;  \$path,&#xA;            'out=s'         =&amp;gt;  \$outFileName );&#xA;&#xA;        #   Check for requests for help or for man (full documentation):&#xA;&#xA;        Pod::Usage::pod2usage( -verbose =&amp;gt; 1 ) if ( $help );&#xA;example.pl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2019-04-12T02:55:03.757" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19544" PostTypeId="1" AcceptedAnswerId="19545" CreationDate="2019-04-12T05:41:14.993" Score="2" ViewCount="78" Body="&lt;p&gt;I wanted to map &lt;kbd&gt;'&lt;/kbd&gt; to &lt;kbd&gt;&quot;&lt;/kbd&gt; because I think both &lt;kbd&gt;`&lt;/kbd&gt; and &lt;kbd&gt;'&lt;/kbd&gt; does the same thing. But I don't want to shadow anything without knowing properly. So, any differences between &lt;kbd&gt;`&lt;/kbd&gt; and &lt;kbd&gt;'&lt;/kbd&gt;?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-12T05:53:45.200" Title="Differences between tick and quote as jump to mark" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19545" PostTypeId="2" ParentId="19544" CreationDate="2019-04-12T05:53:45.200" Score="5" Body="&lt;p&gt;&lt;kbd&gt;'&lt;/kbd&gt; jumps to the start of a line where the mark is set, whereas &lt;kbd&gt;`&lt;/kbd&gt; jumps directly to the specific character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I find that I use &lt;kbd&gt;'&lt;/kbd&gt; far more frequently than &lt;kbd&gt;`&lt;/kbd&gt;, in part because it's easier to reach, but mostly because it means I don't have to care (or try to remember) precisely where within the line I set marks.&lt;/p&gt;&#xA;" OwnerUserId="21770" LastActivityDate="2019-04-12T05:53:45.200" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19546" PostTypeId="2" ParentId="19531" CreationDate="2019-04-12T06:10:41.203" Score="1" Body="&lt;p&gt;By default, the matched text in a substitution, won't be captured into a register, however it will always be available as atom &lt;code&gt;&amp;amp;&lt;/code&gt; in the replace part of your &lt;code&gt;:s&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, you can of course store the matched text inside a specific register using the special atom &lt;a href=&quot;https://vimhelp.org/change.txt.html#sub-replace-special&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\=&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for example this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    function StoreAndReplace(submatch)&#xA;        call setreg('z', a:submatch)&#xA;        return a:submatch . '_'. getreg('z')&#xA;    endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then running &lt;code&gt;:%s/\w\+/\=StoreAndReplace(submatch(0))/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;will store the matched text in register &lt;code&gt;z&lt;/code&gt; and replace the matched text by itsself + the register contents. However this is just a funny way to say:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/\w\+/&amp;amp;_&amp;amp;/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So one usually just uses the later and not the former way of doing it (especially since the content of the register will be overwritten the next time a replacement is performed).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-04-12T06:10:41.203" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19548" PostTypeId="2" ParentId="19531" CreationDate="2019-04-12T12:28:01.990" Score="0" Body="&lt;p&gt;@Christian Brabandt:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks! I meant something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;text11&amp;gt;\t&amp;lt;text12&amp;gt;&#xA;&amp;lt;text21&amp;gt;\t&amp;lt;text22&amp;gt;&#xA;...&#xA;&amp;lt;textM1&amp;gt;\t&amp;lt;textM2&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;remove  all text together with the tab &amp;amp; save it into a register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;text12&amp;gt;\t&#xA;&amp;lt;text22&amp;gt;\t&#xA;...&#xA;&amp;lt;textM2&amp;gt;\t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then be able to retrieve it from the register any time and place it back exactly where it was.&#xA;But the example is simple because the removed text starts on the left. What if I wanted to remove text from x to y characters for every line?&lt;/p&gt;&#xA;" OwnerUserId="21739" LastEditorUserId="21739" LastEditDate="2019-04-12T14:15:06.603" LastActivityDate="2019-04-12T14:15:06.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19549" PostTypeId="2" ParentId="19542" CreationDate="2019-04-12T12:50:02.160" Score="3" Body="&lt;h1&gt;fold-marker&lt;/h1&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#%27foldmarker%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;entry for &lt;code&gt;foldmarker&lt;/code&gt;&lt;/a&gt; notes that:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The marker is a literal string (a regular expression would be too slow).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;...so you don't have full use of all the usual escapes sequences.&lt;/p&gt;&#xA;&lt;p&gt;The section &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#option-backslash&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;option-backslash&lt;/code&gt;&lt;/a&gt; shows that the arguments to &amp;quot;set&amp;quot; can include a backslash to escape whitespace, quotemarks, or backslashes themselves.  But it doesn't appear to be possible to escape a newline this way (because that still ends the &amp;quot;set&amp;quot; command).&lt;/p&gt;&#xA;&lt;h1&gt;fold-syntax&lt;/h1&gt;&#xA;&lt;p&gt;You can instead set multiline fold markers using &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-fold&quot; rel=&quot;nofollow noreferrer&quot;&gt;syntax folding&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;syn region myFold start=&amp;quot;{{{&amp;quot; end=&amp;quot;\n\n\n&amp;quot; transparent fold&#xA;syn sync fromstart&#xA;set foldmethod=syntax&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7600" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-04-12T12:50:02.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19550" PostTypeId="1" CreationDate="2019-04-12T13:18:30.913" Score="0" ViewCount="129" Body="&lt;p&gt;assume you you have some text like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;           &amp;lt;-------unknown area&#xA;           &amp;lt;-------blank lines&#xA;.....0.....&amp;lt;-------dot represent unknown character&#xA;.....1.....&#xA;.....*.....&amp;lt;-------unknown number of lines, the 6th column is not blank&#xA;.....3.....&#xA;.....4.....&#xA;.....5.....&amp;lt;-------your cursor at 5&#xA;.....6.....&#xA;.....7.....&#xA;.....*.....&amp;lt;-------unknown number of lines, the 6th column is not blank&#xA;.....9.....&#xA;.....0.....&#xA;           &amp;lt;--------blank lines&#xA;           &amp;lt;-------unknown area&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what's the simplest way to select from 5 to the first or last 0 in visual block wise mode? Please don't use character value(such as /0 or ?0), don't assume there are 11 lines(such as 5j or 5k), don't assume there are 11 columns.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="24" LastEditDate="2019-05-10T05:28:46.727" LastActivityDate="2019-05-10T05:28:46.727" Title="What's the simplest way to select the longest non blank vertical column in visual block wise mode?" Tags="|visual-block|" AnswerCount="3" CommentCount="3" ClosedDate="2019-05-10T14:16:47.563" ContentLicense="CC BY-SA 4.0" />
  <row Id="19551" PostTypeId="2" ParentId="19550" CreationDate="2019-04-12T13:22:24.713" Score="0" Body="&lt;p&gt;If I understood correctly (If you want to visual select from 5 to the end or beginning of the block), you can do it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to go to the beginning&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to go to the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CF: &lt;code&gt;:help {&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And it can be done is visual or normal modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Again, I am not sure to have properly understood the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are trying to do a visual selection as follow:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Iq80Y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Iq80Y.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did with the cursor on &lt;code&gt;5&lt;/code&gt; (which is on the &lt;em&gt;6th&lt;/em&gt; column):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;c-v&amp;gt;}k5l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which puts me on visual mode (&lt;code&gt;&amp;lt;c-v&lt;/code&gt;, ctrl + v), goes at the end of the paragraph (&lt;code&gt;}&lt;/code&gt;, paragraphs are delimited with empty lines), go one line up (&lt;code&gt;k&lt;/code&gt;, bringing at the beginning of the line), move of (n-1) chars to reach the column back (&lt;code&gt;5l&lt;/code&gt;, to go to the 6th column).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is not what you are trying to achieve, can you please rephrase the question?&lt;/p&gt;&#xA;" OwnerUserId="21621" LastEditorUserId="21621" LastEditDate="2019-04-12T14:56:10.677" LastActivityDate="2019-04-12T14:56:10.677" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19552" PostTypeId="2" ParentId="2883" CreationDate="2019-04-12T13:36:41.877" Score="0" Body="&lt;p&gt;If you have a way to edit the file, you might want to wrap the colors setup with &lt;code&gt;\[&lt;/code&gt; and &lt;code&gt;\]&lt;/code&gt;, as per explained &lt;a href=&quot;http://tldp.org/HOWTO/Bash-Prompt-HOWTO/nonprintingchars.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[...] What's been done is to enclose the '\033[1;33m' that starts the yellow colour in '[' and ']' which tells the shell &quot;everything between these escaped square brackets, including the brackets themselves, is a non-printing character [...]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Otherwise, the whole color codes are considered as characters, and therefore might be taken in account for the horizontal scroll.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure this is the issue, but seeing the source of the calendar (with &lt;code&gt;syntax off&lt;/code&gt;) and the current behaviour, it made me think of that.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-04-12T13:36:41.877" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19553" PostTypeId="1" AcceptedAnswerId="19560" CreationDate="2019-04-12T13:43:25.127" Score="0" ViewCount="112" Body="&lt;p&gt;POD is a markup format that is used by Perl. It's sometimes found &lt;a href=&quot;https://metacpan.org/pod/distribution/perl/pod/perlpod.pod#Embedding-Pods-in-Perl-Modules&quot; rel=&quot;nofollow noreferrer&quot;&gt;embedded within the code&lt;/a&gt;. You can find more information on it from the official docs on &lt;a href=&quot;https://metacpan.org/pod/perlpod&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;perlpod&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;https://metacpan.org/pod/perlpodspec&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;perlpodspec&lt;/code&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if there is a simple method to delete it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think something like that removes all lines that start with &lt;code&gt;/^=(?:head\d|pod|item)/&lt;/code&gt; ... &#xA; and end with &lt;code&gt;/^=cut/&lt;/code&gt; would work reasonably well, as most of it looks like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;=item snazzle($)&#xA;&#xA;The snazzle() function will behave in the most spectacular&#xA;form that you can possibly imagine, not even excepting&#xA;cybernetic pyrotechnics.&#xA;&#xA;=cut back to the compiler, nuff of this pod stuff!&#xA;&#xA;sub snazzle($) {&#xA;    my $thingie = shift;&#xA;    .........&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="51" LastEditDate="2021-07-28T10:28:52.230" LastActivityDate="2021-07-28T10:28:52.230" Title="VIM Macro to delete all Perl POD?" Tags="|regular-expression|filetype-perl|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19554" PostTypeId="2" ParentId="19553" CreationDate="2019-04-12T14:16:01.227" Score="2" Body="&lt;p&gt;You can do the following mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; *D*elete *P*od&#xA;nnoremap &amp;lt;leader&amp;gt;dp gg/^=[^\s]&amp;lt;cr&amp;gt;V/^=cut&amp;lt;cr&amp;gt;d&#xA;&quot; *F*old *P*od&#xA;nnoremap &amp;lt;leader&amp;gt;fp /^=[^\s]&amp;lt;cr&amp;gt;V/^=cut&amp;lt;cr&amp;gt;jzf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To either delete the first POD of the file, or fold the next POD accessible from your cursor (if you are in a POD, only part of it will be folded)&lt;/p&gt;&#xA;" OwnerUserId="21621" LastEditorUserId="21621" LastEditDate="2019-04-12T14:27:08.383" LastActivityDate="2019-04-12T14:27:08.383" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19555" PostTypeId="1" AcceptedAnswerId="19556" CreationDate="2019-04-12T15:01:16.887" Score="1" ViewCount="158" Body="&lt;p&gt;Vim can read / write a gzipped file &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html#gzip-example&quot; rel=&quot;nofollow noreferrer&quot;&gt;like this&lt;/a&gt; which is great but it only works with gunzip, because it can read from stdin. Apparently zip files have a directory listing at the end of the archive which makes this difficult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm working with zipped Python .egg files (for those who don't know, .egg is a zipped Python format). When I get Python tracebacks which refer to a .egg location, for example this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;  File &quot;/foo/bar.egg/dir/file.py&quot;, line 15, in main&#xA;ValueError: asdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can literally replace &quot;/foo/bar.egg/dir/file.py&quot; with &quot;zipfile:/foo/bar.egg::dir/file.py&quot; and then run &lt;code&gt;:e zipfile:/foo/bar.egg::dir/file.py&lt;/code&gt; and Vim will open the zipped file correctly. It opens with read/write access through, for whatever reason, I get an exception &quot;Undefined variable: s:zipfile_1&quot; in &lt;code&gt;zip#Write&lt;/code&gt; any time I &lt;code&gt;:w&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a script that automates doing this substitution on each line and then runs that code through &lt;code&gt;:set makeprg=converted_text&lt;/code&gt; &lt;code&gt;:make&lt;/code&gt; but I'd like to ask:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Can I somehow get Vim to detect a .egg and convert &quot;/foo/bar.egg/dir/file.py&quot; to &quot;zipfile:/foo/bar.egg::dir/file.py&quot; automatically on file read without me having to do manual effort?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can this suggested idea for #1 modify the file in-place with read/write access?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In regards to #1, I tried using BufReadPre/BufReadPost but Vim gave me warnings about being allowed to modify the current buffer.&lt;/p&gt;&#xA;" OwnerUserId="16073" LastActivityDate="2019-04-12T15:04:11.890" Title="Auto-read .egg zip archive" Tags="|plugin-zip|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19556" PostTypeId="2" ParentId="19555" CreationDate="2019-04-12T15:04:11.890" Score="4" Body="&lt;p&gt;As documented at &lt;code&gt;:help zip-extension&lt;/code&gt;, you may use the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup zip_add&#xA;   au!&#xA;   au BufReadCmd *.egg call zip#Browse(expand(&quot;&amp;lt;amatch&amp;gt;&quot;))&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-04-12T15:04:11.890" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19557" PostTypeId="1" AcceptedAnswerId="19558" CreationDate="2019-04-12T15:25:07.470" Score="1" ViewCount="95" Body="&lt;p&gt;I want to copy something to a register or more ideally the system clipboard and then run a search / replace regex on it the way that I do in the buffer...is that possible?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2019-04-12T15:42:14.523" Title="Can you run a regex on a register or the clipboard contents?" Tags="|regular-expression|register|os-clipboard|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19558" PostTypeId="2" ParentId="19557" CreationDate="2019-04-12T15:35:14.673" Score="4" Body="&lt;p&gt;Assume you copied the following line to the register &lt;code&gt;+&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Copied to clipboard.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you want to replace &quot;clipboard&quot; with &quot;register&quot; inside the register &lt;code&gt;+&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @+=substitute(@+, 'clipboard', 'register', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;@+&lt;/code&gt; represents the register &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;@@&lt;/code&gt; is the unnamed register, &lt;code&gt;@a&lt;/code&gt; is register &lt;code&gt;a&lt;/code&gt;,... . See &lt;code&gt;:help :let-@&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;substitute(...)&lt;/code&gt; is processing a string (here from reg &lt;code&gt;+&lt;/code&gt;) like  &lt;code&gt;:s/clipboard/register/g&lt;/code&gt; would process the line in the file.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-04-12T15:42:14.523" LastActivityDate="2019-04-12T15:42:14.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19560" PostTypeId="2" ParentId="19553" CreationDate="2019-04-12T17:44:19.460" Score="3" Body="&lt;p&gt;Just use an ex command with searches for ranges:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/^=[^\s]/,/^=cut/ delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Repeat with &lt;code&gt;@:&lt;/code&gt;. Or, for the whole file,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^=[^\s]/,/^=cut/ delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can make it a hotkey with &lt;code&gt;dp&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;dp :g/^=[^\s]/,/^=cut/ delete&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="5078" LastEditDate="2019-04-25T13:59:00.140" LastActivityDate="2019-04-25T13:59:00.140" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19561" PostTypeId="2" ParentId="19553" CreationDate="2019-04-12T19:45:20.097" Score="0" Body="&lt;p&gt;So, I wrote a Python script &lt;code&gt;foldpod&lt;/code&gt; (at bottom) that can be used to &quot;fold&quot; POD into a magical perl comment that's a really long base64-encoded line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have made no attempt to parse the full POD format, it recognizes &lt;code&gt;=pod&lt;/code&gt;, &lt;code&gt;=begin&lt;/code&gt;, &lt;code&gt;=item&lt;/code&gt;, and &lt;code&gt;=head1&lt;/code&gt; as beginning a POD block and recognizes &lt;code&gt;=cut&lt;/code&gt; as ending a block. Starting a block multiple times within the same block is not an error from the perspective of &lt;code&gt;foldpod&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does not bother to check whether the lines surrounding a &lt;code&gt;POD&lt;/code&gt; directive are blank or not, so it should work acceptably well even if the POD documentation of the perl source file is malformed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unterminated blocks are not an error and get passed through as is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When invoked as &lt;code&gt;foldpod -u&lt;/code&gt; it will unfold the magical base-64 encoded comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As long as you have &lt;code&gt;set nowrap&lt;/code&gt; enabled, this should make the POD comments substantially less annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't use &lt;code&gt;set nowrap&lt;/code&gt; it should still be possible to target lines containing &lt;code&gt;MAGIC_POD_COMMENT&lt;/code&gt; with a fold expression or conceal them in some way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result looks like this with no wrapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/local/bin/perl&#xA;&#xA;# MAGIC_POD_COMMENT : PWhlYWQxIE5BTUUKCnBhcnNlUmVmU2VxR2Vub21lcy5wbCAtIHBhcnNlIFJlZlNlcSBnZW5vbWVzIGZyb20gTkNCSQoKPWhlYWQxIFNZTk9QU0lTCgp&#xA;Vc2U6CgogICAgcGVybCBwYXJzZVJlZlNlcUdlbm9tZXMucGwgWy0taGVscF0gWy0tbWFuXQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgWy0tY2xlYXJEYl0gWy0td3Jp&#xA;dGVUb0RiXQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLS1wYXRoIHBhdGggLS1kaXZpc2lvbiBuYW1lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtLW91d&#xA;CBuYW1lCgpFeGFtcGxlczoKCiAgICBwZXJsIHBhcnNlUmVmU2VxR2Vub21lcy5wbCAtLWhlbHAKCiAgICBwZXJsIHBhcnNlUmVmU2VxR2Vub21lcy5wbCAtLW1hbgoKICAgICMgIC&#xA;BMb2FkIGFsbCBSZWZTZXEgZGF0YToKCiAgICBwZXJsIHBhcnNlUmVmU2VxR2Vub21lcy5wbCAtLWNsZWFyRGIgLS13cml0ZVRvRGIKICAgICAgICAgICAgICAgICAgICAgICAgICA&#xA;gICAgIC0tcGF0aCAvZGF0YS9nZW5vbWVzIC0tZGl2aXNpb24gYmN0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtLW91dCBiY3QuZ2Vub21lcy5wZXAuZmFzdGEKCj1o&#xA;ZWFkMSBERVNDUklQVElPTgoKVGhpcyBzY3JpcHQgaXMgcGFydCBvZiB0aGUgZ2Vub21lIGFubm90YXRpb24gcGlwZWxpbmUuIFRoZSBzY3JpcHQgc2NhbnMKdGhlIEdlbkJhbmstZ&#xA;m9ybWF0IFJlZlNlcSBnZW5vbWVzIGZyb20gTkNCSSBhbmQgaW5zZXJ0cyB0aGUgZGF0YSBpbnRvIHRoZQpNeVNRTCBkYXRhYmFzZTsgb3B0aW9uYWxseSwgdGhlIHNjcmlwdCBjcm&#xA;VhdGVzIGEgRmFzdGEtZm9ybWF0IG91dHB1dCBmaWxlCmNvbnRhaW5pbmcgdGhlIHByb3RlaW4gc2VxdWVuY2VzLgoKPWhlYWQxIEFSR1VNRU5UUwoKcGFyc2VSZWZTZXFHZW5vbWV&#xA;zLnBsIHRha2VzIHRoZSBmb2xsb3dpbmcgYXJndW1lbnRzOgoKPW92ZXIgNAoKPWl0ZW0gaGVscAoKICAtLWhlbHAKCihPcHRpb25hbC4pIERpc3BsYXlzIHRoZSB1c2FnZSBtZXNz&#xA;YWdlLgoKPWl0ZW0gbWFuCgogIC0tbWFuCgooT3B0aW9uYWwuKSBEaXNwbGF5cyBhbGwgZG9jdW1lbnRhdGlvbi4KCj1pdGVtIHBhdGgKCiAgLS1wYXRoIG5hbWUKCihSZXF1aXJlZ&#xA;C4pIFNldHMgdGhlIHBhdGggdG8gdGhlIGRpcmVjdG9yeSBpbiB3aGljaCB0aGUgZGl2aXNpb24gaXMgZm91bmQuCgo9aXRlbSBkaXZpc2lvbgoKICAtLWRpdmlzaW9uIG5hbWUKCi&#xA;hSZXF1aXJlZC4pIFNldHMgdGhlIG5hbWUgb2YgdGhlIEdlbkJhbmsgZGl2aXNpb24sIGEgc3ViZGlyZWN0b3J5IG9mIHRoZSBwYXRoCmNvbnRhaW5pbmcgb25lIG9yIG1vcmUgR2V&#xA;uQmFuayBmbGF0IGZpbGVzLgoKPW92ZXIgOAoKPWl0ZW0gYmN0CgpUaGUgUmVmU2VxIG1pY3JvYmlhbCBnZW5vbWVzIGZyb20gTkNCSS4KCj1iYWNrCgo9aXRlbSB3cml0ZVRvRGIK&#xA;CiAgLS13cml0ZVRvRGIKCihPcHRpb25hbC4pIEluY2x1ZGUgdGhpcyBhcmd1bWVudCBpZiB5b3Ugd2FudCB0byB3cml0ZSBkYXRhIHRvIHRoZSBkYXRhYmFzZS4KCj1pdGVtIGNsZ&#xA;WFyRGIKCiAgLS1jbGVhckRiCgooT3B0aW9uYWwuKSBJbmNsdWRlIHRoaXMgYXJndW1lbnQgaWYgeW91IHdhbnQgdG8gZGVsZXRlIGFsbCBkYXRhIGZyb20gYWxsCmRhdGFiYXNlIH&#xA;RhYmxlcyBiZWZvcmUgcGFyc2luZyBhbmQgaW5zZXJ0aW5nIGJlZ2lucy4KCj1pdGVtIG91dEZpbGVOYW1lCgogIC0tb3V0RmlsZU5hbWUgbmFtZQoKKE9wdGlvbmFsLikgVGhlIG5&#xA;hbWUgb2YgdGhlIGZhc3RhLWZvcm1hdCBvdXRwdXQgZmlsZSBjb250YWluaW5nIHRoZSBwcm90ZWluCnNlcXVlbmNlcyBleHRyYWN0ZWQgZnJvbSB0aGUgQ0RTIGZlYXR1cmVzIG9m&#xA;IGVhY2ggYWNjZXNzaW9uLiBJZiBub3Qgc3BlY2lmaWVkLApubyBmYXN0YSBkYXRhIHdpbGwgYmUgY3JlYXRlZC4KCj1iYWNrCgo9aGVhZDEgQVVUSE9SCgpDb25yYWQgSGFsbGluZ&#xA;ywgRTxsdD5jb25yYWQuaGFsbGluZ0BzcGhhZXJ1bGEuY29tRTxndD4uCgo9aGVhZDEgQ09QWVJJR0hUCgpUaGlzIHByb2dyYW0gaXMgZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIEFydG&#xA;lzdGljIExpY2Vuc2UuCgo9aGVhZDEgREFURQoKMzEtTWFyLTIwMDYKCj1jdXQK&#xA;&#xA;&#xA;package main;&#xA;use 5.8.7;&#xA;use strict;&#xA;use warnings;&#xA;use IO::File;&#xA;use Getopt::Long ();    #   Resist name-space pollution!&#xA;use Pod::Usage ();      #   Ditto!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here's the script.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#! /usr/bin/env python3&#xA;&#xA;&#xA;import argparse&#xA;import sys&#xA;from io import StringIO&#xA;from base64 import b64encode, b64decode&#xA;import unittest&#xA;import re&#xA;&#xA;from shutil import copyfile&#xA;&#xA;&#xA;isa = isinstance&#xA;&#xA;parser = argparse.ArgumentParser(prog=&quot;foldpod&quot;)&#xA;parser.add_argument(&#xA;    &quot;-S&quot;, &quot;--selftest&quot;, action=&quot;store_true&quot;, dest=&quot;selftest&quot;, help=&quot;run test suite&quot;,&#xA;)&#xA;parser.add_argument(&#xA;    &quot;-u&quot;,&#xA;    &quot;--unfold&quot;,&#xA;    action=&quot;store_true&quot;,&#xA;    dest=&quot;unfold&quot;,&#xA;    help=&quot;unfold flattened POD comments&quot;,&#xA;)&#xA;args, files = parser.parse_known_args()&#xA;args_ = vars(args)&#xA;del args&#xA;args = args_&#xA;&#xA;&#xA;POD_START = re.compile(r&quot;^=pod\b|^=begin\b|^=head1\b|^=item\b&quot;)&#xA;&#xA;&#xA;def pod_start(line):&#xA;    return bool(POD_START.match(line))&#xA;&#xA;&#xA;def pod_end(line):&#xA;    return line.rstrip() == &quot;=cut&quot;&#xA;&#xA;&#xA;def magic_comment(line):&#xA;    words = line.split()&#xA;    if len(words) &amp;lt; 2:&#xA;        return False&#xA;    if words[0] == &quot;#&quot; and words[1] == &quot;MAGIC_POD_COMMENT&quot;:&#xA;        return True&#xA;    return False&#xA;&#xA;&#xA;def pod_classify(line):&#xA;    r&quot;&quot;&quot;&#xA;    &amp;gt;&amp;gt;&amp;gt; pod_classify('')&#xA;    &amp;gt;&amp;gt;&amp;gt; pod_classify('=pod')&#xA;    'START'&#xA;    &amp;gt;&amp;gt;&amp;gt; pod_classify('=cut')&#xA;    'END'&#xA;    &quot;&quot;&quot;&#xA;    is_start = pod_start(line)&#xA;    is_end = pod_end(line)&#xA;    is_magic_comment = magic_comment(line)&#xA;    hits = sum([is_start, is_end, is_magic_comment])&#xA;    if hits == 0:&#xA;        return None&#xA;    elif hits == 1:&#xA;        if is_start:&#xA;            return &quot;START&quot;&#xA;        elif is_end:&#xA;            return &quot;END&quot;&#xA;        elif is_magic_comment:&#xA;            return &quot;MAGIC_POD_COMMENT&quot;&#xA;        else:&#xA;            raise RuntimeError(&quot;couldn't handle line type&quot;)&#xA;    else:&#xA;        raise ValueError(&quot;line matched more than one pattern: %s&quot; % line)&#xA;&#xA;&#xA;def fold_pod(itr):&#xA;    r&quot;&quot;&quot;&#xA;    returns: iterator of lines of file with pod sections&#xA;    organized into base64-encoded magical comments.&#xA;    Note that the lines emitted by this function always have&#xA;    a newline terminator.&#xA;&#xA;    &amp;gt;&amp;gt;&amp;gt; list(fold_pod(['a', 'b']))&#xA;    ['a\n', 'b\n']&#xA;    &quot;&quot;&quot;&#xA;    if isinstance(itr, (str, bytes)):&#xA;        raise ValueError(&quot;expecting iterator of lines, not single line&quot;)&#xA;    cur_pod = None&#xA;    for line in itr:&#xA;        line = line if line.endswith(&quot;\n&quot;) else line + &quot;\n&quot;&#xA;        if None is cur_pod:&#xA;            klass = pod_classify(line)&#xA;            # if we're a start line, start filling pod buffer&#xA;            if klass == &quot;START&quot;:&#xA;                cur_pod = StringIO()&#xA;                cur_pod.write(line)&#xA;            # otherwise just emit the line&#xA;            else:&#xA;                yield line&#xA;        else:&#xA;            klass = pod_classify(line)&#xA;            if klass == &quot;END&quot;:&#xA;                cur_pod.write(line)&#xA;                b64 = b64encode(cur_pod.getvalue().encode(&quot;utf-8&quot;))&#xA;                b64 = b64.decode(&quot;utf-8&quot;)&#xA;                assert isa(b64, str)&#xA;                content = &quot;# MAGIC_POD_COMMENT : %s\n&quot; % b64&#xA;                cur_pod.close()&#xA;                cur_pod = None&#xA;                yield content&#xA;            else:&#xA;                cur_pod.write(line)&#xA;    # once we're out of the iterator,&#xA;    # read from an incomplete cur_pod buffer a line at a time&#xA;    if cur_pod:&#xA;        for line in cur_pod.getvalue().splitlines(True):&#xA;            yield line&#xA;        cur_pod.close()&#xA;&#xA;&#xA;def fold_pod_(*args, **kwargs):&#xA;    return list(fold_pod(*args, **kwargs))&#xA;&#xA;&#xA;def unfold_pod(itr):&#xA;    if isinstance(itr, (str, bytes)):&#xA;        raise ValueError(&quot;expecting iterator of lines, not single line&quot;)&#xA;    for line in itr:&#xA;        if pod_classify(line) == &quot;MAGIC_POD_COMMENT&quot;:&#xA;            words = line.split()&#xA;            assert len(words) == 4&#xA;            assert words[0] == &quot;#&quot;&#xA;            assert words[1] == &quot;MAGIC_POD_COMMENT&quot;&#xA;            assert words[2] == &quot;:&quot;&#xA;            b64 = words[3]&#xA;            b64 = b64.encode(&quot;utf-8&quot;)&#xA;            out = b64decode(b64)&#xA;            out = out.decode(&quot;utf-8&quot;)&#xA;            for l in out.splitlines(True):&#xA;                yield l&#xA;        else:&#xA;            yield line&#xA;&#xA;&#xA;def unfold_pod_(*args, **kwargs):&#xA;    return list(unfold_pod(*args, **kwargs))&#xA;&#xA;&#xA;class TestFoldPod(unittest.TestCase):&#xA;    def test_fold_pod_empty(self):&#xA;        self.assertEqual(fold_pod_([]), [])&#xA;&#xA;    def test_fold_single(self):&#xA;        self.assertEqual(fold_pod_([&quot;a&quot;]), [&quot;a\n&quot;])&#xA;&#xA;    def test_fold_just_begin(self):&#xA;        self.assertEqual(fold_pod_([&quot;=begin&quot;]), [&quot;=begin\n&quot;])&#xA;&#xA;    def test_fold_empty_pod(self):&#xA;        xs = fold_pod_([&quot;=begin&quot;, &quot;=cut&quot;])&#xA;        self.assertEqual(len(xs), 1)&#xA;        first = xs[0]&#xA;        words = first.split()&#xA;        self.assertEqual(words[0], &quot;#&quot;)&#xA;        self.assertEqual(words[1], &quot;MAGIC_POD_COMMENT&quot;)&#xA;&#xA;    def test_fold_unfold_round_trip(self):&#xA;        xs = [&quot;=begin\n&quot;, &quot;aaaaa\n&quot;, &quot;=cut\n&quot;]&#xA;        rt = unfold_pod_(fold_pod_(xs))&#xA;        self.assertEqual(rt, xs)&#xA;&#xA;&#xA;def main(files, unfold=False, selftest=False):&#xA;    if selftest:&#xA;        return do_selftest(files=files)&#xA;    if files:&#xA;        for path in files:&#xA;            bak = path + &quot;.bak&quot;&#xA;            copyfile(src=path, dst=bak)&#xA;            filt = unfold_pod if unfold else fold_pod&#xA;            with open(bak) as source:&#xA;                with open(path, &quot;w&quot;) as sink:&#xA;                    for line in filt(source):&#xA;                        sink.write(line)&#xA;    else:&#xA;        filt = unfold_pod if unfold else fold_pod&#xA;        source = sys.stdin&#xA;        for line in filt(source):&#xA;            sys.stdout.write(line)&#xA;&#xA;&#xA;def do_selftest(files):&#xA;    import doctest&#xA;&#xA;    doctest.testmod()&#xA;    argv = [&quot;foldpod&quot;] + files&#xA;    unittest.main(argv=argv)&#xA;&#xA;&#xA;if __name__ == &quot;__main__&quot;:&#xA;    selftest = args[&quot;selftest&quot;]&#xA;    unfold = args[&quot;unfold&quot;]&#xA;    main(files=files, selftest=selftest, unfold=unfold)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2019-04-13T15:42:54.223" LastActivityDate="2019-04-13T15:42:54.223" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19562" PostTypeId="2" ParentId="19550" CreationDate="2019-04-12T20:09:22.373" Score="0" Body="&lt;p&gt;You can read the column number of the cursor by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g&amp;lt;C-G&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your case the &lt;code&gt;5&lt;/code&gt; is in column 6. Subtract 1 and use &lt;code&gt;5l&lt;/code&gt; to get from line&#xA;start to the same column as the &lt;code&gt;5&lt;/code&gt;. To get the longest &#xA;column that includes the &lt;code&gt;5&lt;/code&gt; between the blank lines you &#xA;can use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vip5l&amp;lt;C-V&amp;gt;o5l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the following commands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;v&lt;/code&gt; get in visual mode &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ip&lt;/code&gt; select inner paragraph, this is separated by the blank lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;5l&lt;/code&gt; move the end cursor of the visual to 6th column &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-V&amp;gt;&lt;/code&gt; change to visual block mode (see also &lt;code&gt;&amp;lt;C-Q&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&lt;/code&gt; change to the next cursor of the block mode &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;5l&lt;/code&gt; move the start cursor of the visual block mode to 6th column.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2843" LastActivityDate="2019-04-12T20:09:22.373" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19563" PostTypeId="2" ParentId="19550" CreationDate="2019-04-13T06:36:36.993" Score="0" Body="&lt;p&gt;Built in normal commands such as &lt;code&gt;&amp;lt;c-v&amp;gt;}k6|&lt;/code&gt; always require you to manually find current virtual column to finish the selection, that's unpleasant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some plugins can be used to select vertical column:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim-utils/vim-vertical-move&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-vertical-move&lt;/a&gt; column selection done as &lt;code&gt;&amp;lt;c-v&amp;gt;ic&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/coderifous/textobj-word-column.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;textobj-word-column.vim&lt;/a&gt; column selection done as &lt;code&gt;&amp;lt;c-v&amp;gt;]v&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I borrowed some idea from &lt;a href=&quot;https://github.com/vim-utils/vim-vertical-move&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-vertical-move&lt;/a&gt;, &lt;code&gt;&amp;lt;c-v&amp;gt;ic&lt;/code&gt; is pretty easy to memorize. I created following script to do the job:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ov : o for omap, v for v map&#xA;&quot; jk : j or k or jk. j for down, k for up.&#xA;&quot; visuall block wisely select current column until blank line.&#xA;function! SelectScreenColumn(ov, jk) abort&#xA;  let [curVnum, curLnum, colLnum0, colLnum1, lnum] =&#xA;              \ [virtcol('.')] + repeat([line('.')], 4)&#xA;  &quot; do nothing if cursor in blank&#xA;  if GetV(curLnum, curVnum) =~# '\v\s'&#xA;    if a:ov ==# 'v' | exec 'normal! ' | endif | return&#xA;  endif&#xA;&#xA;  &quot; get column end&#xA;  if stridx(a:jk, 'j') != -1&#xA;    while 1&#xA;      let lnum = lnum + 1&#xA;      if lnum &amp;gt; line('$') || GetV(lnum, curVnum) =~# '\v^$|\s'&#xA;        let colLnum0 = lnum - 1 | break&#xA;      endif&#xA;    endwhile&#xA;  endif&#xA;&#xA;  &quot; get column start&#xA;  if stridx(a:jk, 'k') != -1&#xA;    let lnum = curLnum&#xA;    while 1&#xA;      let lnum = lnum - 1&#xA;      if lnum &amp;lt;= 0 || GetV(lnum, curVnum) =~# '\v^$|\s'&#xA;        let colLnum1 = lnum + 1 | break&#xA;      endif&#xA;    endwhile&#xA;  endif&#xA;&#xA;  &quot; visual select&#xA;  call cursor(colLnum0, col('.'))&#xA;  exec &quot;normal! \&amp;lt;c-v&amp;gt;&quot;&#xA;  call cursor(colLnum1, col('.'))&#xA;endfunction&#xA;&#xA;vnoremap ic :&amp;lt;c-u&amp;gt;call SelectScreenColumn('v', 'j')&amp;lt;cr&amp;gt;&#xA;onoremap ic :call SelectScreenColumn('o', 'j')&amp;lt;cr&amp;gt;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-15T08:18:05.460" LastActivityDate="2019-04-15T08:18:05.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19564" PostTypeId="1" CreationDate="2019-04-13T09:55:17.177" Score="2" ViewCount="214" Body="&lt;p&gt;searchpair or searchpairpos works only on current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there similar functions work on string instead of buffer?&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="24" LastEditDate="2019-05-10T05:26:48.970" LastActivityDate="2019-05-10T05:26:48.970" Title="Is it possible to call searchpair or searchpairpos on string instead of current buffer?" Tags="|vimscript|search|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19565" PostTypeId="1" CreationDate="2019-04-13T10:33:13.293" Score="1" ViewCount="529" Body="&lt;p&gt;I am running VIM 8.1 with MacVim on MacOS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I set &lt;code&gt;clipboard+=unnamed&lt;/code&gt;, then when I click &lt;code&gt;p&lt;/code&gt; in visual mode,&#xA;it simply copies the currently selected text into &quot;* and &quot;+. &#xA;If I remove this and restart vim, it works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any solution? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(There are no relevant mappings by the way) &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="23502" LastEditDate="2022-09-16T16:14:40.483" LastActivityDate="2022-09-16T16:14:40.483" Title="paste doesn't work in visual mode with `clipboard+=unnamed`" Tags="|cut-copy-paste|macos|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19566" PostTypeId="2" ParentId="8405" CreationDate="2019-04-13T17:16:53.557" Score="1" Body="&lt;h2&gt;Native vim solution &lt;strong&gt;Update&lt;/strong&gt;:&lt;/h2&gt;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://vi.stackexchange.com/a/38180/7339&quot;&gt;https://vi.stackexchange.com/a/38180/7339&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup yank_restore_cursor&#xA;    autocmd!&#xA;    autocmd VimEnter,CursorMoved *&#xA;        \ let s:cursor = getpos('.')&#xA;    autocmd TextYankPost *&#xA;        \ if v:event.operator ==? 'y' |&#xA;            \ call setpos('.', s:cursor) |&#xA;        \ endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Using the &lt;strong&gt;Preserve&lt;/strong&gt; function&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('*Preserve')&#xA;    function! Preserve(command)&#xA;        try&#xA;            let l:win_view = winsaveview()&#xA;             &amp;quot;silent! keepjumps keeppatterns execute a:command&#xA;            silent! execute 'keeppatterns keepjumps ' . a:command&#xA;        finally&#xA;            call winrestview(l:win_view)&#xA;        endtry&#xA;    endfunction&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Copy a paragraph whithout moving the cursor&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;:call Preserve('normal yap')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If we could wrap this idea in a more generic solution would be gret&lt;/p&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2022-08-05T22:32:39.600" LastActivityDate="2022-08-05T22:32:39.600" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19567" PostTypeId="1" AcceptedAnswerId="19574" CreationDate="2019-04-13T19:13:34.080" Score="2" ViewCount="543" Body="&lt;p&gt;When I create a new line or hit &lt;code&gt;o&lt;/code&gt; I have Vim configured to match the previous indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, since I use hard tabs in most places, vim will replace &lt;strong&gt;any&lt;/strong&gt; spaces that are greater than or equal to the current shift width with hard tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I mix tabs and spaces depending on logical indent (tabs) and alignment (spaces), this gets really annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, take the following comment (&lt;code&gt;›&lt;/code&gt; = tab, &lt;code&gt;○&lt;/code&gt; = space):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;›   /*&#xA;›   ›   Returns:&#xA;›   ›   ○○○○0 for success&#xA;›   ›   ○○○○non-zero for failure&#xA;›   */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I go to the end of the &lt;code&gt;0 for success&lt;/code&gt; line and hit enter (or just go to the line and, in normal mode, hit &lt;code&gt;o&lt;/code&gt;), seeing as how my tab width is 4, vim will copy the indentation but replace all sequences of 4 spaces with a hard tab instead of keeping them as 4 spaces.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;›   /*&#xA;›   ›   Returns:&#xA;›   ›   ○○○○0 for success&#xA;›   ›   ›   &amp;lt;-- super annoying&#xA;›   ›   ○○○○non-zero for failure&#xA;›   */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my current indentation configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoindent&#xA;set nosmartindent&#xA;set nocindent&#xA;set indentexpr=-1&#xA;set indentkeys=&#xA;filetype plugin indent off&#xA;autocmd FileType * setlocal indentkeys=&#xA;autocmd BufNewFile,BufRead * setlocal indentkeys=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;How do I get Vim to match the indentation &lt;strong&gt;exactly&lt;/strong&gt; when it creates a new line with automatic indentation?&lt;/p&gt;&#xA;" OwnerUserId="3164" LastActivityDate="2019-04-14T18:21:16.357" Title="Match indentation upon newline without replacing spaces with tabs or vice versa" Tags="|indentation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19569" PostTypeId="1" AcceptedAnswerId="19584" CreationDate="2019-04-14T03:32:13.823" Score="0" ViewCount="243" Body="&lt;p&gt;I constantly need to copy existing variable names or expressions as arguments for my current typing function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// int TyrionLannister;&#xA;&#xA;int JonSnow;&#xA;&#xA;...&#xA;&#xA;int AryaStark;&#xA;&#xA;...&#xA;&#xA;// int DaenerysTargaryen;&#xA;&#xA;foo();&#xA;   ^ current currsor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to change foo() to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo(JonSnow, AryaStark, TyrionLannister, DaenerysTargaryen)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have used two methods to do the job so far:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;use autocomplete plugin such as ycm, i can type &quot;js&quot;, and select &quot;JonSnow&quot; from popup list.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;sometimes plugin can't help me, because target variable is commented or it's some compound expression or whatever reason, i have to copy and paste by myself. &#xA;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to move my cursor to the variable if i want to copy it, sometimes i use &lt;kbd&gt;G&lt;/kbd&gt;, sometimes i use &lt;kbd&gt;H&lt;/kbd&gt;&lt;kbd&gt;M&lt;/kbd&gt;&lt;kbd&gt;L&lt;/kbd&gt; and a lot of &lt;kbd&gt;{&lt;/kbd&gt;,&lt;kbd&gt;}&lt;/kbd&gt; and &lt;kbd&gt;j&lt;/kbd&gt; &lt;kbd&gt;k&lt;/kbd&gt;, some times even&lt;kbd&gt;/&lt;/kbd&gt; seemes to be a good choice. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes i copy all variables into different registers &lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;b&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;..., then &lt;kbd&gt;`&lt;/kbd&gt; &lt;kbd&gt;.&lt;/kbd&gt; or &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt; to go back to foo(), paste from &lt;kbd&gt;a&lt;/kbd&gt;, add comma,  paste from &lt;kbd&gt;b&lt;/kbd&gt;, add comma, etc. Sometimes i copy only one variable, go back to foo(), add comma, paste it, then repeat the process for other variables.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Method 2 is quite awkward, i hate it so much that sometimes i type the arguments manually(i know i shouldn't do it manually).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should i change my workflow? What's your workflow for this problem?&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-14T07:12:53.497" LastActivityDate="2019-04-15T08:19:34.640" Title="How to copy and paste arguments into function parenthesis?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19570" PostTypeId="2" ParentId="19106" CreationDate="2019-04-14T05:59:08.880" Score="1" Body="&lt;p&gt;You definitely need the backslash version &lt;code&gt;\&amp;lt;Left&amp;gt;&lt;/code&gt;. Is use of &lt;code&gt;py3eval&lt;/code&gt; necessary? Unless you need to translate data structures from Python to Vim or something it would be better to return a straight string. You need to make sure the string &lt;code&gt;:GrepperAck ''\&amp;lt;Left&amp;gt;&lt;/code&gt; is passed literally to the command line. Then it will be processed as an expression due to &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have a Python installation but I can demonstrate the fundamental workings without it. Given...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! Foo()&#xA;    return &quot;:GrepperAck ''\&amp;lt;Left&amp;gt;&quot;&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this mapping...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;f Foo()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then when I enter leader key and &lt;kbd&gt;f&lt;/kbd&gt; this is what I'll see on the command line..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:GrepperAck ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and the cursor will be inside the quotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you must use &lt;code&gt;py3eval&lt;/code&gt; then one thing you might try is to wrap that in a &lt;code&gt;string()&lt;/code&gt; function call.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;f string(py3eval(..))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; In retrospect the reason &lt;code&gt;\&amp;lt;Left&amp;gt;&lt;/code&gt; doesn't work is almost certainly because the parsing of the mapping occurs in a certain order, i.e. the phase that substitutes actual keys for &lt;code&gt;&amp;lt;xxx&amp;gt;&lt;/code&gt; tokens occurs before any external programs are executed. I haven't confirmed this by looking at the Vim source code or anything but as a veteran software developer I can tell you that it's a solid theory. It wouldn't make much sense for the parser to have multiple passes with &lt;code&gt;&amp;lt;xxx&amp;gt;&lt;/code&gt; resolution nor, generally speaking, to make such a pass over external (non-Vim originated) runtime data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anything be done? Well, I thought that substituting the actual key code would do the trick....&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def invoke_search_command():&#xA;    return &quot;:GrepperAck ''&amp;lt;C-V&amp;gt;&amp;lt;Left&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That means rather than type &lt;code&gt;\&amp;lt;Left&amp;gt;&lt;/code&gt; you actually enter &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; followed by &lt;kbd&gt;←&lt;/kbd&gt; (left arrow key).  (For me the combo comes out looking like &lt;code&gt;^[OD&lt;/code&gt;.) Unfortunately, I'm getting an error: &lt;code&gt;Not an editor command: GrepperAck ''&lt;/code&gt;. &lt;em&gt;But&lt;/em&gt; I know I'm on the right track because if I replace &lt;kbd&gt;←&lt;/kbd&gt; with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;H&lt;/kbd&gt; (commonly the same function as the backspace key) then the cursor is actually moved on the resulting GrepperAck command line (erasing the last &lt;code&gt;'&lt;/code&gt; as expected).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So why isn't the left arrow key code working?  Dunno. It might be that we can substitute something else in the terminal codes but that's a stretch and getting into possibly non-portable behavior. I'll play around with that for a bit but unfortunately, unless your system behaves differently than mine (try it out) I believe the ultimate answer to your question is &quot;this is not possible&quot;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-07-19T22:03:26.273" LastActivityDate="2019-07-19T22:03:26.273" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19572" PostTypeId="2" ParentId="19521" CreationDate="2019-04-14T12:46:11.720" Score="2" Body="&lt;p&gt;Take a look at &lt;a href=&quot;https://stackoverflow.com/a/16624418/8909756&quot;&gt;this&lt;/a&gt; answer. You can use &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2351&quot; rel=&quot;nofollow noreferrer&quot;&gt;RltvNmbr&lt;/a&gt; to display the relative line numbers while Vim displays the absolute ones.&lt;/p&gt;&#xA;" OwnerUserId="20400" LastActivityDate="2019-04-14T12:46:11.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19573" PostTypeId="1" CreationDate="2019-04-14T13:59:19.757" Score="1" ViewCount="138" Body="&lt;p&gt;Why can I not get Vim 8.1 on Cygwin? The latest version I can find is 8.0.1567-1. I found out that patch 8.1.0372 fixes the slow scrolling when 'cursorline' is set.&lt;/p&gt;&#xA;" OwnerUserId="19614" LastActivityDate="2019-06-05T00:51:17.050" Title="Latest Vim on Cygwin" Tags="|cygwin|" AnswerCount="0" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19574" PostTypeId="2" ParentId="19567" CreationDate="2019-04-14T18:21:16.357" Score="2" Body="&lt;p&gt;According to the comments,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set copyindent&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;should do it&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-04-14T18:21:16.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19575" PostTypeId="1" CreationDate="2019-04-14T19:27:38.190" Score="3" ViewCount="171" Body="&lt;p&gt;I have some long text on Yank var&#xA;e.g. &amp;quot;Hello all how are you ?&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;I have a rectangular selection between abc and ABC &lt;code&gt;/a llC-vjj&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;a A&#xA;b B&#xA;C C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And I want to past my long text without having to type it&lt;/p&gt;&#xA;&lt;p&gt;To get this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;a Hello all how are you ? A&#xA;b Hello all how are you ? B&#xA;c Hello all how are you ? C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;From  @christian-Brabandt I select (&lt;code&gt;|&lt;/code&gt; is where my cursor is) not the line but characters like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;|Hello how are you ?&#xA;vllllllllllllllllllly&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then I put the cursor on 'a'&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;a A&#xA;b B&#xA;C C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and press 'p'&lt;/p&gt;&#xA;&lt;p&gt;I got&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;aHello how are you ? A&#xA;b B&#xA;C C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So with this method I have to add a space with &lt;code&gt;i &amp;lt;ESC&amp;gt;&lt;/code&gt;, go on &lt;code&gt;b&lt;/code&gt; type &lt;code&gt;pi &amp;lt;ESC&amp;gt; go on &lt;/code&gt;c` ...&lt;/p&gt;&#xA;&lt;p&gt;Not optimal because not using the block selection ;(&lt;/p&gt;&#xA;" OwnerUserId="16022" LastEditorUserId="16022" LastEditDate="2022-04-16T15:50:27.147" LastActivityDate="2022-04-16T15:50:27.147" Title="past yanked content in rectangular selection with vim8" Tags="|visual-mode|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19576" PostTypeId="1" CreationDate="2019-04-14T19:52:40.263" Score="2" ViewCount="2305" Body="&lt;p&gt;I want my vim statusline to have some color and I can't figure out why it does not with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set laststatus=2&#xA;set statusline+=%1*\ %f\ %*&#xA;set statusline+=%2*\ %&amp;lt;%F%*&#xA;set statusline+=%2*%m%*&#xA;set statusline+=%=&#xA;set statusline+=%1*%=%5l%*&#xA;set statusline+=%2*/%L%*&#xA;hi User1 guifg=#eea040 guibg=%222222&#xA;hi User2 guifg=%dd3333 guibg=%222222&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is what it looks like currently:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/8qev3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8qev3.png&quot; alt=&quot;Vim Image&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get color onto the filename etc. and&lt;/li&gt;&#xA;&lt;li&gt;Remove the whitespace between the left and right side?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thank You in advance.&lt;/p&gt;&#xA;" OwnerUserId="21794" LastEditorUserId="21794" LastEditDate="2019-04-14T20:09:58.783" LastActivityDate="2019-04-15T06:54:40.763" Title="Vim Statusline colors not appearing" Tags="|gvim|microsoft-windows|statusline|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19577" PostTypeId="2" ParentId="19576" CreationDate="2019-04-15T02:02:02.213" Score="1" Body="&lt;p&gt;according to &lt;code&gt;:h gui-colors&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    You can also specify a color by its Red, Green and Blue values.&#xA;    The format is &quot;#rrggbb&quot;, where&#xA;        &quot;rr&quot;    is the Red value&#xA;        &quot;gg&quot;    is the Green value&#xA;        &quot;bb&quot;    is the Blue value&#xA;    All values are hexadecimal, range from &quot;00&quot; to &quot;ff&quot;.  Examples: &amp;gt;&#xA;  :highlight Comment guifg=#11f0c3 guibg=#ff00ff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to change &lt;code&gt;guibg=%222222&lt;/code&gt; to &lt;code&gt;guibg=#222222&lt;/code&gt;. It surprises me you didn't get any error, i thought you are running a terminal vim until i saw gvim tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can remove &lt;code&gt;%=&lt;/code&gt; area by changing guifg of StatusLine to guibg of your &lt;code&gt;User#&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix problem 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi User1 guifg=#eea040 guibg=#222222&#xA;hi User2 guifg=#dd3333 guibg=#222222&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To fix problem 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    hi StatusLine guifg=#222222&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-15T02:19:20.813" LastActivityDate="2019-04-15T02:19:20.813" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19578" PostTypeId="1" CreationDate="2019-04-15T06:07:45.473" Score="1" ViewCount="153" Body="&lt;p&gt;I have 50 lines of code&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt;private const CODE = 0;&#xA;private const DESC = 1;&#xA;// ... &#xA;private const TRIM = 19; // instead of 24&#xA;private const SMURF = 35; // instead of 25&#xA;private const DOG = 31; // instead of 26&#xA;// ... &#xA;private const CAT = 49;&#xA;private const AMOUNT = 50;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, numbers are not sorted right.&#xA;I'd like to rewrite them so that I get the following instead:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt;private const CODE = 0;&#xA;private const DESC = 1;&#xA;// ... &#xA;private const TRIM = 24;&#xA;private const SMURF = 25;&#xA;private const DOG = 26;&#xA;// ... &#xA;private const CAT = 49;&#xA;private const AMOUNT = 50;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13172" LastEditorUserId="13172" LastEditDate="2019-04-15T06:45:40.833" LastActivityDate="2019-04-15T07:37:04.257" Title="reset sequence of numbers" Tags="|sort|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19579" PostTypeId="2" ParentId="12882" CreationDate="2019-04-15T06:23:41.983" Score="4" Body="&lt;p&gt;You can select the currently highlighted &lt;code&gt;:h ins-completion&lt;/code&gt; by pressing &lt;code&gt;Ctrl-y&lt;/code&gt; and discard the completions and go back to original text by pressing &lt;code&gt;Ctrl-E&lt;/code&gt;. For more information, see &lt;code&gt;:h complete_CTRL-E&lt;/code&gt; and &lt;code&gt;:h complete_CTRL-Y&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ctrl-E&lt;/strong&gt;&lt;br&gt;&#xA;When completion is active you can use CTRL-E to stop it and go back to the originally typed text. The CTRL-E will not be inserted.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ctrl-Y&lt;/strong&gt;&lt;br&gt;&#xA;When the popup menu is displayed you can use CTRL-Y to stop completion and&#xA;accept the currently selected entry.  The CTRL-Y is not inserted.  Typing a&#xA;space, Enter, or some other unprintable character will leave completion mode&#xA;and insert that typed character.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For some more completion-menu keys, you can read &lt;code&gt;:h popupmenu-keys&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-15T06:23:41.983" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19580" PostTypeId="2" ParentId="19576" CreationDate="2019-04-15T06:54:40.763" Score="0" Body="&lt;p&gt;You need these lines. Put them in your &lt;code&gt;vimrc&lt;/code&gt; and restart vim (&lt;code&gt;:xa&lt;/code&gt; and &lt;code&gt;$ vim&lt;/code&gt;). Or you can put them in your &lt;code&gt;vimrc&lt;/code&gt; and source it (&lt;code&gt;:so %&lt;/code&gt;) twice, once to get the vimrc updated and once again to set up the colors according to the &lt;code&gt;:h autocmd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set termguicolors&#xA;set laststatus=2&#xA;set statusline=%1*\ %f\ %*&#xA;set statusline+=%2*\ %&amp;lt;%F%*&#xA;set statusline+=%2*%m%*&#xA;set statusline+=%=&#xA;set statusline+=%1*%=%5l%*&#xA;set statusline+=%2*/%L%*&#xA;&#xA;augroup statusline&#xA;    autocmd!&#xA;    autocmd VimEnter,ColorScheme * hi User1 guifg=#eea040 guibg=#222222&#xA;    autocmd VimEnter,ColorScheme * hi User2 guifg=#dd3333 guibg=#222222&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Explanation:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;:h termguicolors&lt;/code&gt; part is just there in case you're using a terminal vim.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I took the liberty to change the &lt;code&gt;+=&lt;/code&gt; from the first line to &lt;code&gt;=&lt;/code&gt; because otherwise everytime you sourced your &lt;code&gt;vimrc&lt;/code&gt; you would've added to (not overwritten) your statusline. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;You need to wrap the &lt;code&gt;:h hi&lt;/code&gt; commands in &lt;code&gt;:h :augroup&lt;/code&gt;. Otherwise, it won't work when you manually change the colorscheme with &lt;code&gt;:colorscheme default&lt;/code&gt; etc.&lt;/li&gt;&#xA;&lt;li&gt;You had some typos. You used &lt;code&gt;%&lt;/code&gt; instead of &lt;code&gt;#&lt;/code&gt; to represent hex colors.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-15T06:54:40.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19581" PostTypeId="2" ParentId="19578" CreationDate="2019-04-15T07:00:43.453" Score="2" Body="&lt;p&gt;What you can do is the following. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Prepare: Execute &lt;code&gt;:set virtualedit=block&lt;/code&gt;. This allows visual block selection (&lt;code&gt;&amp;lt;Ctrl-V&lt;/code&gt;&gt;) beyond the end of line.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Visually select the lines and execute &lt;code&gt;:'&amp;lt;,'&amp;gt;s/=.*$//&lt;/code&gt; (this also deletes all trailing comments!)&lt;/li&gt;&#xA;&lt;li&gt;Go to the end of the first line and hit &lt;code&gt;&amp;lt;C-V&amp;gt;&lt;/code&gt; and move down over all 50 lines and to the right, so the right side of the visual box is behind all variable names.&lt;/li&gt;&#xA;&lt;li&gt;Enter &lt;code&gt;A= 0;&amp;lt;esc&amp;gt;&lt;/code&gt;, to append the text &lt;code&gt;= 0;&lt;/code&gt; to all lines.&lt;/li&gt;&#xA;&lt;li&gt;Go to the &lt;strong&gt;second&lt;/strong&gt; line and move to the &lt;code&gt;0&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;code&gt;&amp;lt;C-V&amp;gt;&lt;/code&gt; again and move down to the last line. You have now one column visually selected.&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;code&gt;g&amp;lt;Ctrl-A&amp;gt;&lt;/code&gt;. This will replace the &lt;code&gt;0&lt;/code&gt;s with a increasing sequence of numbers.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-04-15T07:15:30.843" LastActivityDate="2019-04-15T07:15:30.843" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19582" PostTypeId="2" ParentId="19578" CreationDate="2019-04-15T07:04:44.450" Score="2" Body="&lt;p&gt;Assume there has no negative numbers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @&quot;=-1 | global /\v\w+\s*\=\s*\d+\s*;/ exec(&quot;normal! f;bviwp\&amp;lt;c-a&amp;gt;yiw&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;let @&quot;=-1&lt;/code&gt; set register &quot; to -1&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;global /\v\w+\s*\=\s*\d+\s*;/&lt;/code&gt; find all line that need to be changed&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\w+\s*\=\s*&lt;/code&gt; match &lt;code&gt;&quot;CODE = &quot;&lt;/code&gt; in &lt;code&gt;&quot;CODE = 0;&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\d+\s*;&lt;/code&gt; match &lt;code&gt;&quot;0;&quot;&lt;/code&gt; in &lt;code&gt;&quot;CODE = 0;&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;exec(&quot;normal! f;bviwp\&amp;lt;c-a&amp;gt;yiw&quot;)&lt;/code&gt; execute a tiny script on each matched line:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;f;b&lt;/code&gt; locate cursor at number before ;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;viwp&lt;/code&gt; replace current number with register &quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\&amp;lt;c-a&amp;gt;&lt;/code&gt; increase current number&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yiw&lt;/code&gt; set register &quot; to current number&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-04-15T07:04:44.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19583" PostTypeId="2" ParentId="19578" CreationDate="2019-04-15T07:10:58.933" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;At first make every digit zero:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\vprivate const .* = \zs\d*\ze;/0/g&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then goto the first line with &lt;code&gt;gg&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Then start recording. Just press &lt;kbd&gt;q&lt;/kbd&gt; twice, i.e. &lt;code&gt;qq&lt;/code&gt;. The first &lt;code&gt;q&lt;/code&gt; will start the recording and the second &lt;code&gt;q&lt;/code&gt; will define in which register (&lt;code&gt;:reg q&lt;/code&gt;) the recording will be stored.&lt;/li&gt;&#xA;&lt;li&gt;Goto the digit before &lt;code&gt;;&lt;/code&gt; by pressing &lt;code&gt;t;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Yank the integer with &lt;code&gt;yiw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Go one line below, goto before &lt;code&gt;;&lt;/code&gt; and put the integer in place of the zero there and increment. The whole process should be done by &lt;code&gt;j0t;viw&quot;0p&amp;lt;Ctrl-A&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Stop recording by pressing &lt;code&gt;q&lt;/code&gt; once.&lt;/li&gt;&#xA;&lt;li&gt;Perform the task from 4 to 7 with &lt;code&gt;50@q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-04-15T07:37:04.257" LastActivityDate="2019-04-15T07:37:04.257" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19584" PostTypeId="2" ParentId="19569" CreationDate="2019-04-15T08:19:34.640" Score="2" Body="&lt;p&gt;As @D. Ben Knoble mentioned, I'd use &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; which will look mostly (but not only, cf &lt;code&gt;:help i_ctrl-n&lt;/code&gt; for more information) in the words in the opened files, making the completion quite &quot;local&quot;, and appropriate in your case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the completion of Vim, I'd encourage you to have a look at it, my favourite ones being the path completion (&lt;code&gt;:help i_CTRL-X_CTRL-F&lt;/code&gt;) and the whole line completion (&lt;code&gt;i_CTRL-X_CTRL-L&lt;/code&gt;). But the tag completion is definitely worth having a look. Take them and get comfortable with them one after the other, and it will be less daunting.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-04-15T08:19:34.640" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19585" PostTypeId="2" ParentId="19521" CreationDate="2019-04-15T08:32:39.393" Score="0" Body="&lt;p&gt;There is no way to have both absolute and relative numbers being displayed by Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do however, is to (ab)use the &lt;a href=&quot;https://vimhelp.org/sign.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;sign feature&lt;/a&gt; and display the relative numbers there. Note, since the sign column is limited to 2 characters, it won't work on very long windows with more than 100 lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a couple of plugins that enable it. The already mentioned &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=2351&quot; rel=&quot;nofollow noreferrer&quot;&gt;RltvNmbr.vim&lt;/a&gt; from Dr. Chip, which was used to enable relative line numbering before that feature was available in Vim natively (around Vim 7.3 I believe). An alternative is to use my plugin &lt;a href=&quot;https://github.com/chrisbra/DynamicSigns&quot; rel=&quot;nofollow noreferrer&quot;&gt;DynamicSigns&lt;/a&gt;. This allows to flexible define what kind of signs will be drawn and when. Have a look at the example from &lt;a href=&quot;https://vi.stackexchange.com/a/5691/71&quot;&gt;this answer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the sign column needs to be updated very often, which might impose a performance penalty. My DynamicSigns plugin tries to update the sign column as often as needed, but it might still be noticeable, if you scroll a lot. There is not much that can be done against it. &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-04-15T08:32:39.393" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19587" PostTypeId="1" CreationDate="2019-04-15T12:52:08.787" Score="1" ViewCount="114" Body="&lt;p&gt;When writing code, I often have code of the form&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;variableA operator variableB&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I would like to edit it to be&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;variableB operator variableA.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, I do this by deleting/pasting &lt;code&gt;variableB&lt;/code&gt; to be in front of &lt;code&gt;variableA&lt;/code&gt; and then deleting/pasting &lt;code&gt;operator&lt;/code&gt; to be in between them. Is there a slicker way to do this in Vim? &lt;/p&gt;&#xA;" OwnerUserId="18196" LastActivityDate="2019-04-15T13:16:58.367" Title="Switch order of three &quot;words&quot;" Tags="|key-bindings|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19588" PostTypeId="2" ParentId="19587" CreationDate="2019-04-15T13:15:08.427" Score="2" Body="&lt;pre&gt;&lt;code&gt;variableA operator variableB&#xA;   ^ cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diwmmwwvep`mP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;explanation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;diw&lt;/code&gt; delete variableA into register &quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;mm&lt;/code&gt; mark current position&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ww&lt;/code&gt; move cursor to variableB&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;vep&lt;/code&gt; replace variableB with variableA, also set register &quot; to variableB&lt;/li&gt;&#xA;&lt;li&gt;`m go back to marked position&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt; paste variableB&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It's awkward to swap this way. &#xA;I recommand &lt;a href=&quot;https://github.com/tommcdo/vim-exchange&quot; rel=&quot;nofollow noreferrer&quot;&gt;tommcdo/vim-exchange&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that plugin all you need is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cxiwww.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-04-15T13:15:08.427" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19589" PostTypeId="2" ParentId="19587" CreationDate="2019-04-15T13:16:58.367" Score="2" Body="&lt;p&gt;Yes, via search and replace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v(variableA) (operator) (variableB)/\3 \2 \1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; is for very magic to make the parens easier&lt;/li&gt;&#xA;&lt;li&gt;The parens make capture groups, referenced in the substitution to flip the order&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can add a range at the beginning of &lt;code&gt;:s&lt;/code&gt; (e.g., &lt;code&gt;:%s...&lt;/code&gt; to operate on the entire file) and flags at the end (e.g., &lt;code&gt;...\1/g&lt;/code&gt; to operate on all matches in each line). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pattern needs adjusting if situation is more complex. See &lt;code&gt;:h pattern&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-04-15T13:16:58.367" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19590" PostTypeId="2" ParentId="19575" CreationDate="2019-04-15T13:21:23.150" Score="2" Body="&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can accomplish this by using &lt;code&gt;q&lt;/code&gt; to record a sequence of operations and &lt;code&gt;@&lt;/code&gt; to replay it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Assumptions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you want this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a Hello all how are you ? A&#xA;b Hello all how are you ? B&#xA;c Hello all how are you ? C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A paste like you describe would be quite a useful feature, I agree, but I did some tests and I don't see how to do it in my vim 7.4 installation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Recording as a solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution I found uses &lt;code&gt;q&lt;/code&gt; to record pasting the line once, and then replaying the recorded commands twice:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set the cursor on A and record doing the insertion once:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;q1P6bjq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;q1&lt;/code&gt;: start recording into register 1&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;P&lt;/code&gt;: insert the text - you could type it out, as well&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;6bj&lt;/code&gt;: place the cursor on B to be ready to paste on the next line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: stop recording&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then replay register 1 twice, or however many times are needed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2@1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before replaying, make sure the cursor is still on B, and things should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I agree, this is not nearly as nice as a block-duplicated paste as you describe in the question, but it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;vim 8&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: with Vim 8 or more recent, a simple paste over a block selection is likely to work. See @ChristianBrabandt's answer for more details.&lt;/p&gt;&#xA;" OwnerUserId="21446" LastEditorUserId="21446" LastEditDate="2019-04-16T20:36:32.570" LastActivityDate="2019-04-16T20:36:32.570" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="19591" PostTypeId="1" CreationDate="2019-04-15T14:01:29.423" Score="2" ViewCount="246" Body="&lt;p&gt;I would like to create a custom fold expression for functions of the form&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x &amp;lt;- function(a,b,c) {&#xA;  ...&#xA;  ... body&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the lines starting from function(...) until the closing brace are to have the same fold level.&#xA;Yet, I do not want code in other braces to be folded (such as if blocks).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(For those who are wondering, this is r syntax)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the start of the function, I have tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FoldExpr(lnum) &#xA;  let thisline = getline(a:lnum)&#xA;  if thisline =~ '[^#].*function(.*)\s*{'&#xA;    return 'a1'&#xA;  elseif &quot;... condition to check end of function ...&#xA;    &quot; ...&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I am unsure how to check if a line is the last line of the function.&#xA;I am able to check if the line contains a closing &lt;code&gt;}&lt;/code&gt;. But how can I tell if it is the closing brace of the function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(BTW, I am using a fold expression instead of &lt;code&gt;foldmethod=syntax&lt;/code&gt; as I would like to fold other objects as well, not just functions)&lt;/p&gt;&#xA;" OwnerUserId="21495" LastEditorUserId="21495" LastEditDate="2019-04-16T08:00:49.807" LastActivityDate="2019-04-16T08:00:49.807" Title="custom fold expression to fold functions" Tags="|regular-expression|folding|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19592" PostTypeId="2" ParentId="19575" CreationDate="2019-04-15T18:00:56.783" Score="3" Body="&lt;p&gt;It is not very clear from the question, what the goal is (e.g. what the final result should look like). So let me describe what you can do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, store your text in register a:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a='Hello all how are you ?'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A register does not only store text, it also remembers whether it has been used in line wise, character wise or block wise mode. You can influence this using the 3rd argument of the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#setreg()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;setreg()&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now with a sample like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a A&#xA;b B&#xA;c C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/npLeH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/npLeH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pasting in character wise mode&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;After 1), the register content will be in character wise mode, as &lt;code&gt;:echo getregtype('a')&lt;/code&gt; confirms. So block selecting the empty space after the capital&#xA;letters (&lt;code&gt;1gg$&amp;lt;c-v&amp;gt;2j&lt;/code&gt;) and hitting &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; will result in:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/7Fp9q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7Fp9q.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Pasting in line wise mode&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Change the register &lt;code&gt;a&lt;/code&gt; to be linewise: &lt;code&gt;call setreg('a', getreg('a'), 'l')&lt;/code&gt;&#xA;Now, block select the empty space after the capital letters (&lt;code&gt;1gg$&amp;lt;c-v&amp;gt;2j&lt;/code&gt;) and hitting &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; will result in:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/TFZjR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TFZjR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Pasting in block wise mode&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Change the register &lt;code&gt;a&lt;/code&gt; to be linewise: &lt;code&gt;call setreg('a', getreg('a'), 'b')&lt;/code&gt;&#xA;Now, block select the empty space after the capital letters (&lt;code&gt;1gg$&amp;lt;c-v&amp;gt;2j&lt;/code&gt;) and hitting &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; will result in:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/kzEjS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kzEjS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to define, how register should be handled and you might need to change the register type if needed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, there also exist plugins to make handling this easier. Ingo Karkat maintains a plugin &lt;a href=&quot;https://github.com/inkarkat/vim-UnconditionalPaste&quot; rel=&quot;nofollow noreferrer&quot;&gt;UnconditionalPaste&lt;/a&gt;, that can be used to force pasting a register with a different type.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-04-15T18:00:56.783" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19593" PostTypeId="1" CreationDate="2019-04-15T23:45:11.377" Score="3" ViewCount="287" Body="&lt;p&gt;I have a keyboard with an undo key right next to the esc key. I often miss esc, hit undo, which causes the vim process to be stopped. How can I remap the undo key in vim such that it doesn't do anything? I know how to map keys in vim, but I can't make it work for this particular key.&lt;/p&gt;&#xA;" OwnerUserId="21814" LastEditorUserId="51" LastEditDate="2019-04-15T23:55:46.447" LastActivityDate="2019-04-15T23:55:46.447" Title="remap &quot;undo key&quot; to no op" Tags="|key-bindings|macvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19594" PostTypeId="2" ParentId="19593" CreationDate="2019-04-15T23:55:36.650" Score="3" Body="&lt;p&gt;You can get the character(s) that this key sends by using &lt;code&gt;&amp;lt;C-v&amp;gt;[key]&lt;/code&gt; in commandline or insert mode; for example &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;F1&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will probably be multiple characters starting with the escape character (&lt;code&gt;^[&lt;/code&gt;). You can then map this to &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Esc&amp;gt;OP OP &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This example is F1 on my system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace &lt;code&gt;^[&lt;/code&gt; with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;; you can also use the literal escape character, but that can be a bit awkward to edit.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-04-15T23:55:36.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19595" PostTypeId="2" ParentId="19481" CreationDate="2019-04-16T00:26:54.077" Score="3" Body="&lt;p&gt;No, the mappings for the pager are hard-coded. See &lt;code&gt;wait_return()&lt;/code&gt; in &lt;code&gt;message.c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * If the user hits ':', '?' or '/' we get a command line from the next&#xA; * line.&#xA; */&#xA;if (c == ':' || c == '?' || c == '/')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-04-16T00:26:54.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19596" PostTypeId="2" ParentId="19513" CreationDate="2019-04-16T00:52:18.100" Score="2" Body="&lt;p&gt;It's faster as &lt;code&gt;:buf&lt;/code&gt; won't reload the file from disk, whereas &lt;code&gt;:edit&lt;/code&gt; will, which is different &lt;em&gt;behaviour&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is why it's slightly slower in some cases. For most purposes, this is not a huge issue, although it can be over NFS connections, or with larger files. The performance should be identical when opening files that are not yet loaded by Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can test/benchmark this with e.g. &lt;a href=&quot;https://github.com/Carpetsmoker/testing.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;testing.vim&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:mkbuf()&#xA;    new&#xA;    call setline(1, repeat('a', 1048576))  &quot; 1M&#xA;    silent w! test&#xA;endfun&#xA;&#xA;fun! Benchmark_Buf() abort&#xA;    call s:mkbuf()&#xA;    let l:buf = bufnr('')&#xA;    close&#xA;&#xA;    for i in range(0, g:bench_n)&#xA;        exe printf('buffer %d', l:buf)&#xA;        close&#xA;    endfor&#xA;endfun&#xA;&#xA;fun! Benchmark_Edit() abort&#xA;    call s:mkbuf()&#xA;    let l:buf = bufname('')&#xA;    close&#xA;&#xA;    for i in range(0, g:bench_n)&#xA;        exe printf('edit %s', l:buf)&#xA;        close&#xA;    endfor&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ tvim test -b . .&#xA;Benchmark_Edit                   0.599s&#xA;Benchmark_Buf                    0.027s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's a difference for 100 000 runs of the above code, so the actual difference for one invocation is about 0.00000006s for a 1M file.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-04-16T00:58:22.417" LastActivityDate="2019-04-16T00:58:22.417" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19597" PostTypeId="1" AcceptedAnswerId="19600" CreationDate="2019-04-16T06:24:41.497" Score="3" ViewCount="540" Body="&lt;p&gt;A plugin I've recently started maintaining currently checks to see if any bindings exist to its functions before creating the default ones. This makes it easy to setup custom bindings and not have to do anything about the default ones.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !hasmapto('&amp;lt;Plug&amp;gt;MyFunction', 'n')&#xA;    nmap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;f &amp;lt;Plug&amp;gt;MyFunction&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this doesn't do is keep these default bindings from clobbering existing mappings. How can I detect if, say, there is an existing normal mode mapping for &lt;code&gt;&amp;lt;leader&amp;gt;f&lt;/code&gt; before clobbering it with the plugin's default mapping.&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="267" LastEditDate="2019-04-16T06:33:05.353" LastActivityDate="2019-04-16T12:35:23.787" Title="Detect existing key binding before creating one" Tags="|key-bindings|vimscript|leader|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19598" PostTypeId="1" CreationDate="2019-04-16T06:11:38.870" Score="2" ViewCount="56" Body="&lt;p&gt;To find errors in a latex document, I open vim on the .log file. Then I type manually&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^l\.\|[Ee]rr\|[Ww]ar followed by RETURN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This extended regular expression works well. It matches a line starting with ell followed by a fullstop (period) OR the word &quot;error&quot;, possibly capitalized OR the word &quot;warning&quot;, possibly capitalized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to put this command into my .vimrc with the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map % &quot;what should I put here?&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I made various attempts, including doubling some of the backslashes, but couldn't get it to work. I want vim to look for a match for my extended regular expression when I type &quot;%&quot;&lt;/p&gt;&#xA;" OwnerUserId="21842" OwnerDisplayName="David Epstein" LastActivityDate="2019-04-17T07:30:56.043" Title="vimrc and finding errors in latex document" Tags="|filetype-tex|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19599" PostTypeId="2" ParentId="19598" CreationDate="2019-04-16T06:48:37.990" Score="1" Body="&lt;p&gt;your mapping should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap % /^l\.\|[Ee]rr\|[Ww]ar&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is a carriage return, your &quot;enter key&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;nnoremap&lt;/code&gt; instead of &lt;code&gt;map&lt;/code&gt; so that it is done only in Normal mode and does not recursively calls mappings if anything in your mapping is itself a mapping.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-04-16T06:48:37.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19600" PostTypeId="2" ParentId="19597" CreationDate="2019-04-16T07:14:03.687" Score="3" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#mapcheck%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;mapcheck()&lt;/code&gt;&lt;/a&gt; function to check if the user mapped a key to something:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo json_encode(mapcheck('&amp;lt;F1&amp;gt;', 'n'))&#xA;&quot;&quot;&#xA;&#xA;:echo mapcheck('&amp;lt;F11&amp;gt;', 'n')&#xA;:set cursorcolumn!&amp;lt;CR&amp;gt;:set cursorcolumn?&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in your mapping, you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !hasmapto('&amp;lt;Plug&amp;gt;MyFunction', 'n') &amp;amp;&amp;amp; mapcheck('&amp;lt;Leader&amp;gt;f', 'n') is# ''&#xA;    nmap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;f &amp;lt;Plug&amp;gt;MyFunction&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Personally, I'm not completely convinced this is actually a good approach though. While it does prevent overriding user mappings, it's also very &quot;magic&quot; and may be surprising.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An approach that I often use is to make a single setting to disable all mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if get(g:, 'myplugin_map_keys', 1)&#xA;    nmap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;f &amp;lt;Plug&amp;gt;MyFunction&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way users have a reasonable set of mappings by default, but can disable mappings and do their own thing if they want something custom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to map from a variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe printf('nmap &amp;lt;buffer&amp;gt; %s &amp;lt;Plug&amp;gt;MyFunction',&#xA;         \ get(g:, 'myplugin_map_foo', '&amp;lt;Leader&amp;gt;f')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way users can set their own keys for a specific mapping, without having to remap everything.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I don't think there is &quot;one right way&quot;. Aside from personal preference, it also depends on the kind of plugin you're working on. For some plugins a key mapping is just an &quot;extra bonus&quot;, whereas it's critical for others. Some plugins map just one or two keys, others dozens or even hundreds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For smaller plugins with just one or two mappings, the first method will usually be better; for larger plugins with a lot of mappings, the second is often better. Of course, you can also do both.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-04-16T07:14:03.687" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19601" PostTypeId="2" ParentId="19171" CreationDate="2019-04-16T07:56:30.157" Score="2" Body="&lt;p&gt;It's probably better to use a &lt;code&gt;FileType&lt;/code&gt; buffer. The problem with &lt;code&gt;BufEnter&lt;/code&gt; is that the buffer may not yet be fully set up when it's run; I also don't think it's run for new buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also not entirely sure if I follow where you go the &lt;code&gt;man://&lt;/code&gt; pattern from? I don't see that in the source? And using &lt;code&gt;bufname('')&lt;/code&gt; gives me &lt;code&gt;/home/martin/ls.~&lt;/code&gt;, not &lt;code&gt;man://...&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At any rate, something like this should work as you expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! FileType man call Myfunc()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-04-16T07:56:30.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19602" PostTypeId="2" ParentId="19597" CreationDate="2019-04-16T12:35:23.787" Score="1" Body="&lt;pre&gt;&lt;code&gt;silent! {map} &amp;lt;unique&amp;gt; {lhs} {rhs}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works too. The &lt;code&gt;&amp;lt;unique&amp;gt;&lt;/code&gt; modifier issues an error if there is already a mapping for the left-hand side, which silent swallows. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-04-16T12:35:23.787" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19603" PostTypeId="1" AcceptedAnswerId="19606" CreationDate="2019-04-16T12:42:09.293" Score="1" ViewCount="418" Body="&lt;p&gt;I'm on MacOS, so basically all terminals are login terminals for me which source my &lt;code&gt;bash_profile&lt;/code&gt; and load everything I need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the &lt;code&gt;:term&lt;/code&gt; command does not source my &lt;code&gt;bash_profile&lt;/code&gt;, I believe because its not a login terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can use &lt;code&gt;set shell=bash\ -l&lt;/code&gt; to do this, but that also causes Vim to source my &lt;code&gt;bash_profile&lt;/code&gt; on load, which is slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to only do this when actually running the &lt;code&gt;term&lt;/code&gt; command in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update Solved!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/users/19763/ralf&quot;&gt;Ralf&lt;/a&gt;'s idea worked perfectly. I also integrated in &lt;a href=&quot;https://vi.stackexchange.com/users/10604/d-ben-knoble&quot;&gt;d-ben-knoble&lt;/a&gt;'s interactive check as well.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [[ -n &quot;$PS1&quot; &amp;amp;&amp;amp; -f &quot;$HOME/.bashrc&quot; ]]; then&#xA;    source &quot;$HOME/.bashrc&quot;&#xA;fi&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21823" LastEditorUserId="21823" LastEditDate="2019-04-16T14:24:05.113" LastActivityDate="2019-04-16T14:24:05.113" Title="Using a login shell only for the :term command" Tags="|bash|terminal-buffer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19604" PostTypeId="1" CreationDate="2019-04-16T13:01:30.250" Score="-1" ViewCount="508" Body="&lt;p&gt;I am trying to open a different file at some different location while i am working on a file in vim using split screen feature using &lt;/p&gt;&#xA;&#xA;&lt;p&gt;vsp:cd.. / folder/filename&lt;/p&gt;&#xA;&#xA;&lt;p&gt;after I hit enter it just shows me blank screen with split window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I need to know how to open a file in different location from current vim screen&lt;a href=&quot;https://i.stack.imgur.com/bVoU7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bVoU7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21825" LastEditorUserId="16789" LastEditDate="2019-04-18T05:27:59.983" LastActivityDate="2019-04-18T05:27:59.983" Title="Vim split screen opens blank split" Tags="|split|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19605" PostTypeId="2" ParentId="19604" CreationDate="2019-04-16T13:08:08.563" Score="3" Body="&lt;p&gt;So you should actually use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vsp ../folder/filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No need to use &lt;code&gt;cd&lt;/code&gt; because &lt;code&gt;:vsp&lt;/code&gt;  only expects a path not a shell command.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-04-16T13:08:08.563" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19606" PostTypeId="2" ParentId="19603" CreationDate="2019-04-16T13:10:10.747" Score="2" Body="&lt;p&gt;I would solve this in bash:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Move all setting that you need in login shells &lt;em&gt;and&lt;/em&gt; non-login shells to the file &lt;code&gt;.bashrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Add the following to the end of your &lt;code&gt;.bash_profile&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# include .bashrc if it exists&#xA;if [ -f &quot;$HOME/.bashrc&quot; ]; then&#xA;    . &quot;$HOME/.bashrc&quot;&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could drop the &lt;code&gt;if...&lt;/code&gt;, as the file always exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Background: The file &lt;code&gt;.bashrc&lt;/code&gt; is source by bash if it is started as an interactive shell that is not a login shell. See &lt;code&gt;man bash&lt;/code&gt; section &quot;INVOCATION&quot;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You &lt;code&gt;.bash_profile&lt;/code&gt; will be rather empty, but that is ok. On Linux I use the file &lt;code&gt;.profile&lt;/code&gt; (sourced by bash if &lt;code&gt;.bash_profile&lt;/code&gt; is not available) and it only contains a few &lt;code&gt;export&lt;/code&gt; statements and the source command for &lt;code&gt;.bashrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-04-16T13:31:47.710" LastActivityDate="2019-04-16T13:31:47.710" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19607" PostTypeId="1" AcceptedAnswerId="19608" CreationDate="2019-04-16T13:30:53.183" Score="4" ViewCount="2925" Body="&lt;p&gt;I'm familiar with vertical blocks, and I often &lt;code&gt;ctrl+v&lt;/code&gt; &lt;code&gt;down&lt;/code&gt; &lt;code&gt;down&lt;/code&gt; &lt;code&gt;down&lt;/code&gt; &lt;code&gt;shift+I&lt;/code&gt; &lt;code&gt;foobar&lt;/code&gt; &lt;code&gt;esc&lt;/code&gt; to write foobar in various locations at once. &#xA;This is useful if I want to replace &lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;th&amp;gt;&lt;/code&gt; in a chain, for instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since not all the text blocks are of equal size, I don't know how to do the same for &lt;code&gt;&amp;lt;/td&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;/th&amp;gt;&lt;/code&gt;. I can think of selecting multiple lines as I did earlier, move to the end of the line with &lt;code&gt;shift+a&lt;/code&gt;, maybe, move one to the left, delete a character with &lt;code&gt;x&lt;/code&gt;, and type my &lt;code&gt;h&lt;/code&gt;, but I don't know how to move my position(s) when I am in visual block mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to select a position as active, and move as I usually would with my marker, choosing where to write?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In SublimeText3 I would do something like &lt;code&gt;ctrl+d&lt;/code&gt; to select the cases I'm looking for (skipping with &lt;code&gt;ctrl+k+d&lt;/code&gt; if necessary), moving to the end-of-line with &lt;code&gt;end&lt;/code&gt; (&lt;code&gt;home&lt;/code&gt; for the beginning of the line), and then moving with the arrow keys (alternatively with &lt;code&gt;ctrl&lt;/code&gt;+arrow keys).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example scenario:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-html prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;tr&amp;gt;&#xA;    &amp;lt;th&amp;gt;Language&amp;lt;/th&amp;gt;&#xA;    &amp;lt;th&amp;gt;Oral&amp;lt;/th&amp;gt;&#xA;    &amp;lt;th&amp;gt;Written&amp;lt;/th&amp;gt;&#xA;    &amp;lt;th&amp;gt;Diplomas&amp;lt;/th&amp;gt;&#xA;    &amp;lt;th&amp;gt;Notes&amp;lt;/th&amp;gt;&#xA;&amp;lt;/tr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which I want to be&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-html prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;tr&amp;gt;&#xA;    &amp;lt;td&amp;gt;Language&amp;lt;/td&amp;gt;&#xA;    &amp;lt;td&amp;gt;Oral&amp;lt;/td&amp;gt;&#xA;    &amp;lt;td&amp;gt;Written&amp;lt;/td&amp;gt;&#xA;    &amp;lt;td&amp;gt;Diplomas&amp;lt;/td&amp;gt;&#xA;    &amp;lt;td&amp;gt;Notes&amp;lt;/td&amp;gt;&#xA;&amp;lt;/tr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21826" LastEditorUserId="15" LastEditDate="2019-04-16T13:50:39.990" LastActivityDate="2019-04-17T07:02:56.287" Title="How to write on multiple places at once" Tags="|visual-mode|visual-block|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19608" PostTypeId="2" ParentId="19607" CreationDate="2019-04-16T13:42:47.760" Score="3" Body="&lt;p&gt;Aside from the suggested plugin &lt;code&gt;vim-multiple-cursors&lt;/code&gt;, you have different options:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example you can go on the parent tag (&lt;code&gt;tr&lt;/code&gt; I guess?) and visual select in the tag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then do a substitution in the &lt;code&gt;tr&lt;/code&gt; tag only:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/td/th/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to do a more complex change than a substitution, you can search for a pattern matching all the places you want to apply a change, go to the first one, do your change, and for all the other, if the change is atomic, use &lt;code&gt;.&lt;/code&gt; to repeat it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/td&amp;gt;&#xA;ceth&amp;lt;esc&amp;gt;&#xA;n.n.n.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first command searches for a &lt;code&gt;td&amp;gt;&lt;/code&gt; tag, the second cut until the end (&lt;code&gt;ce&lt;/code&gt;) and types &lt;code&gt;th&lt;/code&gt;, then leaves the insert mode. The third line goes to the next &lt;code&gt;td&lt;/code&gt; (&lt;code&gt;n&lt;/code&gt;), execute the second command (&lt;code&gt;.&lt;/code&gt;) and this 3 times (do it as many times as you need of course, it is just an example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the change is more complex, you can also create a macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an interesting article about multiple cursor (or rather lack of) in Vim: &lt;a href=&quot;https://medium.com/@schtoeffel/you-don-t-need-more-than-one-cursor-in-vim-2c44117d51db&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://medium.com/@schtoeffel/you-don-t-need-more-than-one-cursor-in-vim-2c44117d51db&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21621" LastEditorUserId="21621" LastEditDate="2019-04-17T06:22:02.243" LastActivityDate="2019-04-17T06:22:02.243" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19609" PostTypeId="2" ParentId="19607" CreationDate="2019-04-16T13:42:59.277" Score="0" Body="&lt;p&gt;Note: Not an answer anymore after your last update to the question, but perhaps still useful to know.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Try it like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Goto end of first line.&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;code&gt;&amp;lt;Ctrl-V&amp;gt;$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move down&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;code&gt;Afoobar&amp;lt;esc&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;With the &lt;code&gt;$&lt;/code&gt; you hit in step 2, the visual block selection is always till end-of-line. Even if one of the following lines is shorter.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-04-16T13:48:20.757" LastActivityDate="2019-04-16T13:48:20.757" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19610" PostTypeId="2" ParentId="19607" CreationDate="2019-04-16T14:01:23.970" Score="1" Body="&lt;p&gt;Building on padawin’s answer, I would go to the &lt;code&gt;&amp;lt;tr&amp;gt;&lt;/code&gt; tag, &lt;code&gt;vit&lt;/code&gt;, and then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s-&amp;lt;\(/\)?th&amp;gt;-&amp;lt;\1td&amp;gt;-g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To do the replacement. If your text doesn’t contain &lt;code&gt;th&lt;/code&gt;, then &lt;code&gt;:s/th/td/g&lt;/code&gt; is simpler. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternately, with tpope’s &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;surround&lt;/a&gt; plugin, on each &lt;code&gt;th&lt;/code&gt;, do &lt;code&gt;cst&amp;lt;td&amp;gt;&lt;/code&gt;.  Combined with tpope’s &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;repeat&lt;/a&gt;, you can do this for one line and repeat on each with the &lt;code&gt;.&lt;/code&gt; command, or even &lt;code&gt;:g/&amp;lt;th&amp;gt;/normal f&amp;gt;lcst&amp;lt;td&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-04-16T14:01:23.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19611" PostTypeId="1" AcceptedAnswerId="19614" CreationDate="2019-04-16T14:12:13.357" Score="2" ViewCount="2607" Body="&lt;p&gt;I use Vim on windows (not gVim) because I think, that windows menu bar is ugly. So I use Vim, but I cannot fullscreen it. When I try it caps at cmd max size (1/4 size of screen) and won't be bigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;make Vim fullscreen&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;hide menu bar from gVim?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21827" LastEditorUserId="21827" LastEditDate="2019-04-16T14:22:12.273" LastActivityDate="2022-12-06T07:17:47.487" Title="Why cannot I make Vim (not gVim) fullscreen?" Tags="|gvim|microsoft-windows|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19612" PostTypeId="2" ParentId="19607" CreationDate="2019-04-16T14:37:20.010" Score="2" Body="&lt;p&gt;I know there has already answers. But i couldn't help to try something i just learned from @padawin's link.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/th&amp;gt;&lt;/code&gt; search th&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cgntd&amp;gt;&lt;/code&gt; change &lt;code&gt;th&amp;gt;&lt;/code&gt; to &lt;code&gt;td&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.........&lt;/code&gt; repeat 9 times with 9 dots. You can just press the button, don't lift it.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;check :h gn&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your text doesn't contain &lt;code&gt;th&lt;/code&gt;, place your cursor under &lt;code&gt;th&lt;/code&gt;, you can replace word under cursor like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;*#cgntd&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;*&lt;/code&gt;  set @/ to &lt;code&gt;\v&amp;lt;th&amp;gt;&lt;/code&gt;, search forward&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;#&lt;/code&gt;  search backward, restore cursor, you can also use &lt;code&gt;N&lt;/code&gt; if you want.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cgntd&lt;/code&gt; replace next match (or the one under cursor) to &lt;code&gt;td&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.........&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;repeat, You can hold &lt;code&gt;.&lt;/code&gt; , don't release&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-17T07:02:56.287" LastActivityDate="2019-04-17T07:02:56.287" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19613" PostTypeId="2" ParentId="19607" CreationDate="2019-04-16T14:44:04.597" Score="1" Body="&lt;p&gt;I use &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;surround.vim&lt;/a&gt; which makes changing tags easier, e.g. &lt;code&gt;cst&amp;lt;td&amp;gt;&lt;/code&gt;. Combine this with &lt;code&gt;:normal&lt;/code&gt; and a visual mode makes this pretty easy. Just visually select the lines with &lt;code&gt;V&lt;/code&gt; then run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm cst&amp;lt;td&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :range&#xA;:h :norm&#xA;:h V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-04-16T14:44:04.597" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19614" PostTypeId="2" ParentId="19611" CreationDate="2019-04-16T14:47:27.970" Score="6" Body="&lt;p&gt;I believe that it's not Vim that you can't fullscreen: Vim in terminal mode runs in a terminal emulator. On Windows I think you can't make the console go full screen so this is absolutely not related to Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you want to remove the menu bar from gVim you can read &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27guioptions%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'guioptions'&lt;/code&gt;&lt;/a&gt; and you'll find out that you can add this line to your &lt;code&gt;.vimrc&lt;/code&gt; (or event better your &lt;code&gt;.gvimrc&lt;/code&gt;) to do that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guioptions-=m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-04-16T14:47:27.970" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19615" PostTypeId="2" ParentId="19611" CreationDate="2019-04-16T14:49:41.347" Score="1" Body="&lt;p&gt;For the gVim part of the answer, there are a few things you can add to your &lt;code&gt;_vimrc&lt;/code&gt;. &lt;code&gt;set guioptions -=m&lt;/code&gt; will remove the menu bar, and &lt;code&gt;set guioptions -=T&lt;/code&gt; will remove the toolbar (below the menu bar). If you're not using these, you may wish to speed up load times by not building the menus: you can add &lt;code&gt;let did_install_default_menus = 1&lt;/code&gt; and &lt;code&gt;let did_install_syntax_menu = 1&lt;/code&gt; as well.&lt;/p&gt;&#xA;" OwnerUserId="14684" LastActivityDate="2019-04-16T14:49:41.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19616" PostTypeId="1" AcceptedAnswerId="19617" CreationDate="2019-04-16T18:37:52.330" Score="2" ViewCount="1934" Body="&lt;p&gt;I am working on &lt;a href=&quot;https://github.com/cxw42/editorconfig-core-vimscript/issues/2&quot; rel=&quot;nofollow noreferrer&quot;&gt;UTF-8 support for my editorconfig-core vimscript plugin&lt;/a&gt;.  I have hit a strange snag.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is in official GVim 7.4 Win32.  I would like to get this working on 7.4, rather than updating to 8.0, so the plugin can be more widely usable.  It has &lt;code&gt;+iconv/dyn&lt;/code&gt;, &lt;code&gt;+multi_byte_ime/dyn&lt;/code&gt;, and &lt;code&gt;+multi_lang&lt;/code&gt;.  (Strangely, it does not show &lt;code&gt;+multi_byte&lt;/code&gt;, but UTF-8 editing works fine.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; I can also reproduce on Cygwin Vim running in mintty 3.0.0.  That is Vim 8.0 with &lt;code&gt;+iconv&lt;/code&gt;, &lt;code&gt;+multi_byte&lt;/code&gt;, and &lt;code&gt;+multi_lang&lt;/code&gt;.  Vim encoding is utf-8; &lt;code&gt;$LANG&lt;/code&gt; is &lt;code&gt;en_US.UTF-8&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Steps to reproduce&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open a new buffer &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;set encoding=utf8&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Paste in &lt;code&gt;中文&lt;/code&gt; (U+4e2d, UTF8 e4 b8 ad; U+6587, UTF8 e6 96 87)&lt;/li&gt;&#xA;&lt;li&gt;Search: &lt;code&gt;/\%u4e2d&amp;lt;CR&amp;gt;&lt;/code&gt;.  The search should land on the first character.&lt;/li&gt;&#xA;&lt;li&gt;Search &lt;strong&gt;using very-magic regexes&lt;/strong&gt;: &lt;code&gt;/\v\%u4e2d&amp;lt;CR&amp;gt;&lt;/code&gt;.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When I do this, I get &lt;code&gt;E486: Pattern not found: \v\%u4e2d&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Per &lt;a href=&quot;https://vi.stackexchange.com/a/3558/1430&quot;&gt;this answer&lt;/a&gt;, I also tried searching by unicode character entry: &lt;code&gt;/\v&amp;lt;Ctrl+V&amp;gt;u4e2d&amp;lt;CR&amp;gt;&lt;/code&gt;.  This does return a match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does &lt;code&gt;\%u4e2d&lt;/code&gt; not match in very-magic mode, when it does match in magic mode?  I also tried nomagic and very-nomagic, and it matches in both of those as well.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Context (aka XY problem)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I am trying to build a regex that will match against a filename.  In my particular test case, I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;regex:    \v\/editorconfig\-core\-vimscript\/localtests\/glob\/\中\文\.txt\_$&#xA;test:     /editorconfig-core-vimscript/localtests/glob/中文.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo match('/editorconfig-core-vimscript/localtests/glob/中文.txt', '\v\/editorconfig\-core\-vimscript\/localtests\/glob\/\中\文\.txt\_$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;returns &lt;code&gt;-1&lt;/code&gt; (no match), even though the similar-seeming &lt;code&gt;match('a','\v\a')&lt;/code&gt; returns &lt;code&gt;0&lt;/code&gt; (match found).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thought was that I could convert any character &gt;127 into its corresponding &lt;code&gt;\%uNNNN&lt;/code&gt; using &lt;code&gt;char2nr()&lt;/code&gt; and &lt;code&gt;printf()&lt;/code&gt;.  However, I ran into the problem above.&lt;/p&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="1430" LastEditDate="2019-04-17T13:05:17.937" LastActivityDate="2019-04-18T17:26:20.047" Title="How can I search for Unicode characters by hex code in very magic regexes in vimscript?" Tags="|vimscript|regular-expression|unicode|encoding|multibyte|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19617" PostTypeId="2" ParentId="19616" CreationDate="2019-04-16T19:12:57.660" Score="3" Body="&lt;p&gt;Turns out the &quot;how&quot; answer is very simple:  In very-magic mode, &lt;code&gt;%&lt;/code&gt; is already magical.  Therefore, instead of &lt;code&gt;\%u4e2d&lt;/code&gt;, &lt;code&gt;%u4e2d&lt;/code&gt; (no backslash) works fine!  In full, that's &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v%u4e2d&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1430" LastEditorUserId="1430" LastEditDate="2019-04-18T17:26:20.047" LastActivityDate="2019-04-18T17:26:20.047" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19618" PostTypeId="1" CreationDate="2019-04-16T19:19:48.823" Score="1" ViewCount="229" Body="&lt;p&gt;I am trying to send the vim line that is under the cursor to another tmux pane and then move the cursor on vim down 1 line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For context, I have vim open on 1 pane, and python open on another. I want to bind this capability to a key so that I may execute my python code line by line through vim. &lt;/p&gt;&#xA;" OwnerUserId="21834" LastEditorUserId="1841" LastEditDate="2019-04-16T19:34:38.697" LastActivityDate="2019-04-17T02:55:55.873" Title="Send current vim line to seperate tmux pane and move cursor down" Tags="|key-bindings|tmux|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19619" PostTypeId="2" ParentId="3725" CreationDate="2019-04-16T20:39:31.513" Score="15" Body="&lt;p&gt;Another alternative to swapping windows or swapping the buffers, is to mark positions (using &lt;strong&gt;uppercase&lt;/strong&gt; marks) in your files and open up those marks in the windows of your choosing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example if I have two files, &lt;strong&gt;file_A&lt;/strong&gt; and &lt;strong&gt;file_B&lt;/strong&gt;:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I would go the window with &lt;strong&gt;file_A&lt;/strong&gt; and mark it: &lt;code&gt;mA&lt;/code&gt;  &lt;/li&gt;&#xA;&lt;li&gt;go to the window with &lt;strong&gt;file_B&lt;/strong&gt; and mark it: &lt;code&gt;mB&lt;/code&gt;  &lt;/li&gt;&#xA;&lt;li&gt;Then fetch the mark of &lt;strong&gt;file_A&lt;/strong&gt; into that window: &lt;code&gt;'A&lt;/code&gt;  &lt;/li&gt;&#xA;&lt;li&gt;then go back to the first window and fetch the mark of &lt;strong&gt;file_B&lt;/strong&gt; in there: &lt;code&gt;'B&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The advantage of this method is if for some reason you split your pane more than once and there is no clear logic to swapping them around, like if you want to swap the panes at 12 o'clock and 7 o'clock, you can't just rotate the windows around but you can easily swap the buffers.&lt;/p&gt;&#xA;" OwnerUserId="20473" LastEditorUserId="20473" LastEditDate="2019-04-16T20:50:07.720" LastActivityDate="2019-04-16T20:50:07.720" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19620" PostTypeId="2" ParentId="3725" CreationDate="2019-04-17T02:49:14.910" Score="2" Body="&lt;p&gt;You can swap the buffers between two windows with the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SwitchWindow(count) abort&#xA;    let l:current_buf = winbufnr(0)&#xA;    exe &quot;buffer&quot; . winbufnr(a:count)&#xA;    exe a:count . &quot;wincmd w&quot;&#xA;    exe &quot;buffer&quot; . l:current_buf&#xA;    wincmd p&#xA;endfunction&#xA;nnoremap &amp;lt;C-w&amp;gt;x :&amp;lt;C-u&amp;gt;call SwitchWindow(v:count1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, most often, swapping the buffers will technically act like swapping windows. Because you don't manually keep track of windows, you keep track of which window is holding which buffer. So, the function above will get you by for most situations.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-17T02:49:14.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19621" PostTypeId="2" ParentId="19618" CreationDate="2019-04-17T02:55:55.873" Score="1" Body="&lt;p&gt;The following function will send a paragraph of text or visually selected text to the tmux pane that corresponding to the count.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Send_to_tmux(visual, count) range abort&#xA;    if (a:visual)&#xA;        execute &quot;normal! gv\&quot;zy&quot;&#xA;    else&#xA;        execute &quot;normal! \&quot;zyip&quot;&#xA;    endif&#xA;    let text = @z&#xA;    let text = substitute(text, ';', '\\;', 'g')&#xA;    let text = substitute(text, '&quot;', '\\&quot;', 'g')&#xA;    let text = substitute(text, '\n', '&quot; Enter &quot;', 'g')&#xA;    let text = substitute(text, '!', '\\!', 'g')&#xA;    let text = substitute(text, '%', '\\%', 'g')&#xA;    let text = substitute(text, '#', '\\#', 'g')&#xA;    silent execute &quot;!tmux send-keys -t &quot; . a:count . &quot; -- \&quot;&quot; . text . &quot;\&quot;&quot;&#xA;    silent execute &quot;!tmux send-keys -t &quot; . a:count . &quot;Enter&quot;&#xA;endfunction&#xA;nnoremap &amp;lt;Leader&amp;gt;p :&amp;lt;C-u&amp;gt;call Send_to_tmux(0, v:count1)&amp;lt;CR&amp;gt;&#xA;xnoremap &amp;lt;Leader&amp;gt;p :&amp;lt;C-u&amp;gt;call Send_to_tmux(1, v:count1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For, example, you want to send a line to adjacent tmux pane and move down one line in vim, you can adjust the function somewhat like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Send_to_tmux(visual, count) range abort&#xA;    execute &quot;normal! vg_o^\&quot;zy&quot;&#xA;    let text = @z&#xA;    let text = substitute(text, ';', '\\;', 'g')&#xA;    let text = substitute(text, '&quot;', '\\&quot;', 'g')&#xA;    let text = substitute(text, '\n', '&quot; Enter &quot;', 'g')&#xA;    let text = substitute(text, '!', '\\!', 'g')&#xA;    let text = substitute(text, '%', '\\%', 'g')&#xA;    let text = substitute(text, '#', '\\#', 'g')&#xA;    silent execute &quot;!tmux send-keys -t &quot; . a:count . &quot; -- \&quot;&quot; . text . &quot;\&quot;&quot;&#xA;    silent execute &quot;!tmux send-keys -t &quot; . a:count . &quot;Enter&quot;&#xA;    normal! j&#xA;endfunction&#xA;nnoremap &amp;lt;Leader&amp;gt;p :&amp;lt;C-u&amp;gt;call Send_to_tmux(0, v:count1)&amp;lt;CR&amp;gt;&#xA;xnoremap &amp;lt;Leader&amp;gt;p :&amp;lt;C-u&amp;gt;call Send_to_tmux(1, v:count1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above function will send the current line to the tmux pane corresponding to the count, i.e. if you press &lt;code&gt;2&amp;lt;Leader&amp;gt;p&lt;/code&gt; then the text will go the tmux pane number 2 and so on. Also, the cursor will go one line down.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-17T02:55:55.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19622" PostTypeId="2" ParentId="19598" CreationDate="2019-04-17T07:30:56.043" Score="0" Body="&lt;p&gt;I found that I needed to double the backslashes before the pipe \|&#xA;However, vim decreed that I should NOT use a double backslash before the fullstop/period.&#xA;So, what worked was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap % /^l\.\\|[Ee]rr\\|[Ww]ar&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It also works fine with &quot;map&quot; instead of &quot;nnoremap&quot;, though it's obviously safer to do the right thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quite tricky! Note that, when entering the search sequence directly from the keyboard, one must not double any of the backslashes.&lt;/p&gt;&#xA;" OwnerUserId="21842" LastActivityDate="2019-04-17T07:30:56.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19623" PostTypeId="1" CreationDate="2019-04-17T10:49:42.197" Score="0" ViewCount="248" Body="&lt;p&gt;I sometimes run vim as another user than me, using my own vimrc. In this case the swp and undo directory aren't writeable, and vim warns me with E303. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't care about not having swap file in this case, is there a way to disable this specific warning?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or how can I check from vimrc that the directory isn't writeable?&lt;/p&gt;&#xA;" OwnerUserId="20552" LastActivityDate="2019-04-17T10:49:42.197" Title="Disable E303 warning when swap directory isn't writeable" Tags="|vimrc|swap-file|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19624" PostTypeId="1" CreationDate="2019-04-17T11:34:51.997" Score="0" ViewCount="77" Body="&lt;p&gt;I've recently installed &quot;huge&quot; VIM 8.1 with Lua support (on macOS via MacPorts). This installation is side-by-side with my &quot;normal&quot; VIM 8.0 which lacks Lua support, so I have access to both versions. The &lt;code&gt;&amp;lt;DELETE&amp;gt;&lt;/code&gt; key behaves differently in &quot;huge&quot; VIM 8.1 than it does in &quot;normal&quot; VIM 8.0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say I have the phrase &lt;code&gt;GIVE REASON HERE&lt;/code&gt; and I want to cut/move the word &lt;code&gt;REASON&lt;/code&gt;  I would &lt;code&gt;fR&lt;/code&gt; then &lt;code&gt;v&lt;/code&gt; then &lt;code&gt;fH&lt;/code&gt; then &lt;code&gt;&amp;lt;DELETE&amp;gt;&lt;/code&gt; (to backspace over the &quot;H&quot; and remove it from the selection) then &lt;code&gt;x&lt;/code&gt; to cut the word &lt;code&gt;REASON&lt;/code&gt; &lt;em&gt;(Yes; there are different ways to do this. This is a contrived example to illustrate the issue I need to resolve.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &quot;normal&quot; VIM 8.0, this works fine. In &quot;huge&quot; VIM 8.1, when I hit the &lt;code&gt;&amp;lt;DELETE&amp;gt;&lt;/code&gt; key to backspace over the &quot;H&quot;, it instead deletes the word &lt;code&gt;REASON&lt;/code&gt;. I read &lt;em&gt;many&lt;/em&gt; online posts about how to fix this, quite a few of them were contradictory. These ranged from using &lt;code&gt;stty&lt;/code&gt;, mapping/unmapping keybinds, using &lt;code&gt;set backspace&lt;/code&gt;, and so on. I tried them all - in both their &quot;do this&quot; and &quot;don't do this&quot; configurations - and not a single one helped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want &lt;code&gt;&amp;lt;DELETE&amp;gt;&lt;/code&gt; in VIM 8.1 to behave the same as it does in VIM 8.0; how do I do this?&lt;/p&gt;&#xA;" OwnerUserId="9987" LastEditorUserId="23502" LastEditDate="2022-09-16T16:07:27.977" LastActivityDate="2022-09-16T16:07:27.977" Title="How do I fix &lt;DEL&gt; behavior on macOS in VIM 8.1?" Tags="|key-bindings|macos|original-vim|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19625" PostTypeId="1" AcceptedAnswerId="19626" CreationDate="2019-04-17T13:04:40.513" Score="0" ViewCount="89" Body="&lt;p&gt;My understanding of &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/magic&quot; rel=&quot;nofollow noreferrer&quot;&gt;very-magic regexes&lt;/a&gt; is that you can escape any character outside &lt;code&gt;[A-Za-z0-9_]&lt;/code&gt; with a backslash to make it match literally.  However, I don't see that behaviour with CJK characters.  For example, compare:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo match('中','\v中')         &quot; succeeds (returns 0)&#xA;:echo match('中','\v\中')        &quot; fails (returns -1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Test environments&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;encoding=utf-8&lt;/code&gt; in:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;official GVim 7.4 Win32 with &lt;code&gt;+iconv/dyn&lt;/code&gt;, &lt;code&gt;+multi_byte_ime/dyn&lt;/code&gt;, and &lt;code&gt;+multi_lang&lt;/code&gt;.  (Strangely, it does not show &lt;code&gt;+multi_byte&lt;/code&gt;, but UTF-8 editing works fine.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Vim 8.0 with &lt;code&gt;+iconv&lt;/code&gt;, &lt;code&gt;+multi_byte&lt;/code&gt;, and &lt;code&gt;+multi_lang&lt;/code&gt; running in Cygwin through mintty 3.0.0.  &lt;code&gt;$LANG&lt;/code&gt; is &lt;code&gt;en_US.UTF-8&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1430" LastActivityDate="2019-04-18T23:15:06.153" Title="Why does backslash-escaping a CJK character cause a very-magic regex match to fail?" Tags="|vimscript|regular-expression|unicode|encoding|multibyte|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19626" PostTypeId="2" ParentId="19625" CreationDate="2019-04-17T13:30:47.613" Score="1" Body="&lt;p&gt;According to &lt;code&gt;:h /\v&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            */\v* */\V*&#xA;Use of &quot;\v&quot; means that after it, all ASCII characters except '0'-'9', 'a'-'z',&#xA;'A'-'Z' and '_' have special meaning: &quot;very magic&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's &lt;strong&gt;ASCII&lt;/strong&gt; characters, not &lt;strong&gt;any&lt;/strong&gt; characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;code&gt;:h /\&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            */\* */\\*&#xA;\x  A backslash followed by a single character, with no special meaning,&#xA;    is reserved for future expansions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Therefore, &lt;code&gt;\中&lt;/code&gt; has no meaning &amp;mdash; it's just a reserved sequence.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="1430" LastEditDate="2019-04-18T23:15:06.153" LastActivityDate="2019-04-18T23:15:06.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19627" PostTypeId="1" CreationDate="2019-04-17T14:34:29.490" Score="1" ViewCount="497" Body="&lt;p&gt;I'm trying to configure Vim to make it so that if my system crashes I can recover my work from swap files set in &lt;code&gt;set directory=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested this out on Vim in Windows using gVim. If I forcibly crash Vim to test this out, when I reopen vim I get an alert about my swap files like so: &#xA;&lt;code&gt;'Swap file &quot;~\.vim\scratch_files\swap//C%%Path%To%WorkingDirectory%Filename.txt.swp&quot; already exists!'&lt;/code&gt;&#xA;&lt;code&gt;[Open Read-Only] [Edit anyway] [Recover] [Delete it] [Quit] [Abort]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it only recovers files that I have previously saved. Anything that I had in an &lt;strong&gt;empty buffer&lt;/strong&gt; prior to when it was saved (any unsaved files) doesn't have a swap to recover.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get Vim to create swap files for &lt;strong&gt;new files&lt;/strong&gt; I hadn't yet saved? / Is there any way to recover new files after a crash?&lt;/p&gt;&#xA;" OwnerUserId="21571" LastActivityDate="2019-04-17T14:34:29.490" Title="How can I get swap files for new/unsaved files/code in empty buffers? Any way to recover unsaved files?" Tags="|vimrc|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19628" PostTypeId="1" CreationDate="2019-04-17T14:52:20.680" Score="0" ViewCount="218" Body="&lt;p&gt;I have following in my &lt;code&gt;~/.vimrc&lt;/code&gt; to make sure that nerdtree opens for every tab:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * NERDTree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also have this in the &lt;code&gt;~/.vimrc&lt;/code&gt; to make sure that every new buffer opens in its own tab:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufAdd,BufNewFile * nested tab sball&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the moment, I'm trying to learn Go programming on vim and have installed &lt;code&gt;vim-go&lt;/code&gt; plugin. What happens is that if I hit &lt;code&gt;Ctrl&lt;/code&gt;+&lt;code&gt;]&lt;/code&gt; to open the definition for identifier under the cursor, vim &lt;em&gt;does&lt;/em&gt; open it in a new tab but nerdtree disappears from all tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I hit &lt;code&gt;&amp;lt;F2&amp;gt;&lt;/code&gt; in the very first tab that was opened by vim, nerdtree opens just fine. But in the subsequent tabs, &lt;code&gt;&amp;lt;F2&amp;gt;&lt;/code&gt; causes nerdtree to open in its own tab (it opens a scratch tab with just nerdtree).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I make sure that nerdtree opens just fine always? I don't need to open nerdtree by default for every tab or every time I open vim. But I need to hit &lt;code&gt;&amp;lt;F2&amp;gt;&lt;/code&gt; to open it up so that I can open other files when needed.&lt;/p&gt;&#xA;" OwnerUserId="21846" LastActivityDate="2019-04-17T14:52:20.680" Title="Open all but one buffer in a separate tab" Tags="|buffers|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19629" PostTypeId="2" ParentId="625" CreationDate="2019-04-17T16:47:14.653" Score="1" Body="&lt;p&gt;here's what I do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;open a window with first file (or text contents if you're pasting data)&lt;/li&gt;&#xA;&lt;li&gt;open next file/window using &lt;code&gt;:vnew&lt;/code&gt; (to have both windows side by side) or &lt;code&gt;:new&lt;/code&gt; (to have the windows top and bottom). if you have a specific file to open in the second window, you can include the path like this: &lt;code&gt;:vnew /path/to/secondfile.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;use F8 to toggle a custom function which turns diff mode on and off&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;here's the custom function that's in my &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;F8&amp;gt; :call ToggleDiff()&amp;lt;CR&amp;gt;&#xA;imap &amp;lt;silent&amp;gt; &amp;lt;F8&amp;gt; &amp;lt;C-O&amp;gt;:call ToggleDiff()&amp;lt;CR&amp;gt;&#xA;function ToggleDiff ()&#xA;    if (&amp;amp;diff)&#xA;        set nodiff noscrollbind&#xA;    else&#xA;        &quot; enable diff options in both windows; balance the sizes, too&#xA;        wincmd =&#xA;        set diff scrollbind nowrap number&#xA;        wincmd w&#xA;        set diff scrollbind nowrap number&#xA;        wincmd w&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5526" LastActivityDate="2019-04-17T16:47:14.653" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19630" PostTypeId="2" ParentId="625" CreationDate="2019-04-17T17:04:51.947" Score="2" Body="&lt;p&gt;I can see only three situations to use vim as a difftool. They are briefly described below:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For git difftool, put the following in your &lt;code&gt;~/.gitconfig&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[core]&#xA;editor = vim&#xA;[diff]&#xA;tool = vimdiff&#xA;[merge]&#xA;tool = vimdiff&#xA;conflictstyle = diff3&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To open vim as a diff-tool for two file, you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff file1.ext file2.ext      # for vim&#xA;nvim -d file1.ext file2.ext      # for neovim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To get diff view for the buffers that are currently active, i.e. all the buffers that have a window assigned to them in the currently active tabpage, you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:windo diffthis                &quot; to get diff view&#xA;:windo diffoff                 &quot; to remove diff view&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For more information, see &lt;code&gt;:h diff&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-17T17:04:51.947" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19631" PostTypeId="2" ParentId="18710" CreationDate="2019-04-17T17:08:24.813" Score="1" Body="&lt;p&gt;you could try disabling backup/swap files. if pasting the contents into memory is all you want, disabling disk writes might be faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;from &lt;a href=&quot;https://stackoverflow.com/q/743150/11374957&quot;&gt;https://stackoverflow.com/q/743150/11374957&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nobackup       &quot;no backup files&#xA;set nowritebackup  &quot;only in case you don't want a backup file while editing&#xA;set noswapfile     &quot;no swap files&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you could do a comparison with/without those settings and see if it's any faster. another option: do the same test, but turn on a disk I/O monitoring app first and see if that shows any meaningful spike (with backup files enabled) vs. drop (with &lt;code&gt;nobackup&lt;/code&gt;, &lt;code&gt;nowritebackup&lt;/code&gt;, &lt;code&gt;noswapfile&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="5526" LastActivityDate="2019-04-17T17:08:24.813" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19632" PostTypeId="1" AcceptedAnswerId="19633" CreationDate="2019-04-17T17:53:23.180" Score="7" ViewCount="2837" Body="&lt;p&gt;Suppose I have the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a test of the emergency broadcast system&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I want to do is delete the word &quot;test&quot; and replace it with four spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a      of the emergency broadcast system&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently what I do is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cw&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a built in way to do this, or should I look into writing a macro?&lt;/p&gt;&#xA;" OwnerUserId="15033" LastActivityDate="2019-04-17T18:04:23.733" Title="How to replace a word with spaces" Tags="|cursor-movement|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19633" PostTypeId="2" ParentId="19632" CreationDate="2019-04-17T18:04:23.733" Score="13" Body="&lt;p&gt;Move cursor anywhere on the word &quot;test&quot; and then &lt;code&gt;viwr&lt;/code&gt; (the last one is a space). Saves at least two key strokes.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;v&lt;/code&gt;  start visual selection&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;iw&lt;/code&gt; text object &quot;inner word&quot;  (see &lt;code&gt;:help text-object&lt;/code&gt;, read the entire section, very useful!)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;r&lt;/code&gt;  replace&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&lt;/code&gt; (space) with spaces&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-04-17T18:04:23.733" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19634" PostTypeId="2" ParentId="18387" CreationDate="2019-04-17T18:06:01.217" Score="5" Body="&lt;p&gt;add this to your &lt;code&gt;~/.vimrc&lt;/code&gt; (use whatever function-key numbers you want)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;F3&amp;gt; &amp;lt;C-w&amp;gt;K&amp;lt;CR&amp;gt;&#xA;:map &amp;lt;F4&amp;gt; &amp;lt;C-w&amp;gt;H&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then with two windows open, you can use F3 and F4 to switch the layout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if there's a way to determine the current state (are windows arranged vertically or horizontally), it would be possible to make a function that checks that state and sets horizontal or vertical layout.&lt;/p&gt;&#xA;" OwnerUserId="5526" LastActivityDate="2019-04-17T18:06:01.217" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19635" PostTypeId="1" CreationDate="2019-04-17T20:15:10.680" Score="1" ViewCount="64" Body="&lt;p&gt;When using vim's help I can jump to multi-word tags, but when creating my own tags Ctrl-] tries to match individual words. Consider the following example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;file.txt&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;|a-tag|&lt;br&gt;&#xA;  *a-tag*    &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When pressing Ctrl-[ over &quot;a&quot; it tries to match &quot;a&quot; and not &quot;a-tag&quot;. &#xA;Similarly, if the cursor is on top of &quot;tag&quot; vim searches for &quot;tag&quot; only. &#xA;When visually selecting &quot;a-tag&quot; it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tags file is the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tags&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;a-tag    file.txt    /*a-tag*&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h3&gt;How do I change Ctrl-] behavior to search for the whole WORD inside |a-tag|?&lt;/h3&gt;&#xA;" OwnerUserId="21851" LastActivityDate="2019-04-17T20:15:10.680" Title="Ctrl-] matching single word in custom tags" Tags="|tags|help-system|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19636" PostTypeId="2" ParentId="19611" CreationDate="2019-04-17T20:17:40.550" Score="2" Body="&lt;p&gt;You can increase the size of any standard console window in Windows, including Vim.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open the system menu by clicking the icon in the upper-left corner&#xA;of the window (to the left of the window title) or pressing&#xA;Alt+Space.&lt;/li&gt;&#xA;&lt;li&gt;Select the Properties menu item.&lt;/li&gt;&#xA;&lt;li&gt;In the Properties dialog, select the Layout tab.&lt;/li&gt;&#xA;&lt;li&gt;Adjust the Screen Buffer Size and Window Size.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eoMB5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eoMB5.png&quot; alt=&quot;Vim console windows properties&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, to widen the window, I adjust the Window Size Width. To make it less wide, I adjust the Screen Buffer Size Width. Editing in this way will prevent you from getting a horizontal scroll bar or having to edit both the values. For normal console apps I let the Screen Buffer Size be larger than the Window Size height to support scrolling vertically to see history, but that doesn’t apply to Vim, so you could use the same method above when changing the height.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The keyboard shortcut Alt+Enter can also be used to go into full-screen mode. This is also a standard Windows console feature, not Vim-specific.&lt;/p&gt;&#xA;" OwnerUserId="2680" LastActivityDate="2019-04-17T20:17:40.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19637" PostTypeId="2" ParentId="18387" CreationDate="2019-04-17T20:39:47.617" Score="2" Body="&lt;p&gt;Use tabs. Tabs in Vim function more like OS-level virtual desktops than tabs in most other text editors. Combined with the Vim's ability to display the same buffer in multiple splits, and you've got a built-in solution to your needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set up your first layout as you normally would, then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tab split&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to open a new tab with a single split showing your current buffer. You can then set up your second layout like normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gt&lt;/code&gt; will cycle you through your tabs. It's similar to &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;Tab&lt;/kbd&gt; in most web browsers. &lt;code&gt;gT&lt;/code&gt; cycles tabs in reverse order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find more information about tabs with &lt;a href=&quot;https://vimhelp.org/tabpage.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help tabpage&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Demo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5C5aq.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5C5aq.gif&quot; alt=&quot;Demo gif of tabs maintaining split layouts&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2736" LastEditorUserId="2736" LastEditDate="2019-04-18T18:02:34.957" LastActivityDate="2019-04-18T18:02:34.957" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19638" PostTypeId="1" CreationDate="2019-04-17T22:31:10.653" Score="0" ViewCount="124" Body="&lt;p&gt;I have a log file in which some lines are just a few characters while other lines are about a thousand. Is there a way to view the &lt;em&gt;ends&lt;/em&gt; of each line &lt;em&gt;without modifying the file&lt;/em&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two sub-optimal solutions.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Right-align via awk&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!awk '{d[i++]=$0}x&amp;lt;t=length($0){x=t}END{while(j&amp;lt;i)printf &quot;\%*s\n&quot;,x,d[j++]}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... that's pretty golfed. Here's a cleaner version of what I'm doing:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt;{ data[i] = $0; i++ }&#xA;{ tmp = length($0); if (max &amp;lt; tmp) { max = tmp } }&#xA;END { while (j &amp;lt; i) { printf &quot;\%*s\n&quot;, max, data[j]; j++ } }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This saves each line in an array, notes the line length and saves it if it's bigger than the previous biggest, and then iterates through each saved line, printing it out right-aligned to that max length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This presents my data the way I want to, but it modifies the data and I need to &lt;code&gt;:set sidescroll=1&lt;/code&gt; and then scroll left so the end of each line is at the rightmost edge of vim's viewport.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Right-align via right-to-left&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This one's pretty alienating since it swaps &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt; and therefore &lt;code&gt;D&lt;/code&gt; and other commands don't operate as expected, but visually it's close (yet it also modifies the contents):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set rightleft|%!rev&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This the display orientation to right-to-left and then reverses the contents with a filter calling &lt;code&gt;rev&lt;/code&gt; (part of GNU coreutils, which you'll have to install if you're on a Mac or BSD). I no longer have to play with &lt;code&gt;sidescroll&lt;/code&gt; but it's still very awkward (and it modifies the file).&lt;/p&gt;&#xA;" OwnerUserId="6505" LastActivityDate="2020-01-13T05:01:15.157" Title="How to view document as right-aligned without modifying it" Tags="|alignment|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19639" PostTypeId="1" AcceptedAnswerId="19760" CreationDate="2019-04-17T23:12:23.373" Score="1" ViewCount="1144" Body="&lt;p&gt;If &lt;code&gt;git&lt;/code&gt; is performing a 3-way merge and has a conflict it can't resolve, it marks up that area of the file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;No unresolvable conflicts here&#xA;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&#xA;xyz&#xA;||||||| parent of ...&#xA;abc&#xA;=======&#xA;123&#xA;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way (and, if so, how) to change the background color of these 3 &quot;sections&quot;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;/code&gt; through the line before &lt;code&gt;||||||| parent of ...&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;||||||| parent of ...&lt;/code&gt; through the line before &lt;code&gt;=======&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The line after &lt;code&gt;=======&lt;/code&gt; through the line &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; ...&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(EDIT: The question revolves around if there's a way to highlight certain lines depending on other lines.  &lt;code&gt;xyz&lt;/code&gt; would ordinarily not be highlighted, but since it's between &lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/code&gt; and &lt;code&gt;|||||||&lt;/code&gt; it would be highlighted.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With also being able to handle other sets of conflict markers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the most recent version of vim available at the time of a comment.  So, as of now, 8.1.1183.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use a black background and 256 colors in my terminal.  I was thinking it would be nice to give these sections using the darkest R/G/B/C/M/Y colors, so they didn't cause much of a problem with syntax highlighting.  (Talking about ANSI colors 52, 22, 17, 23, 53, and 58 - not the 1-6 colors.)&lt;/p&gt;&#xA;" OwnerUserId="8071" LastEditorUserId="8071" LastEditDate="2019-04-22T23:19:49.040" LastActivityDate="2019-11-06T13:16:31.080" Title="Change background color of git conflict marker sections" Tags="|syntax-highlighting|highlight|color|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19640" PostTypeId="1" CreationDate="2019-04-18T03:01:52.370" Score="1" ViewCount="468" Body="&lt;p&gt;I guess that &lt;code&gt;:py&lt;/code&gt; command is executed by some kind of extended Python interpreter. This extended Python has &lt;code&gt;vim&lt;/code&gt; package available:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:py import vim; print(dir(vim)); print(vim.__package__, vim.__name__)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;outputs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['Buffer', 'Dictionary', 'Function', 'List', 'Options', 'Range', 'TabPage', &#xA;'VAR_DEF_SCOPE', 'VAR_FIXED', 'VAR_LOCKED', 'VAR_SCOPE', 'VIM_SPECIAL_PATH', 'Window',&#xA;'_Loader', '__doc__', '__name__', '__package__', '_chdir', '_fchdir', '_find_module',&#xA;'_get_paths', '_getcwd', '_load_module', 'bindeval', 'buffers', 'chdir', 'command',&#xA;'current', 'error', 'eval', 'fchdir', 'find_module', 'foreach_rtp', 'options', 'os',&#xA;'path_hook', 'strwidth', 'tabpages', 'vars', 'vvars', 'windows']&#xA;(None, 'vim')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where could I find the documentation of this &lt;code&gt;vim&lt;/code&gt; package?&lt;/p&gt;&#xA;" OwnerUserId="147" LastActivityDate="2019-04-18T03:01:52.370" Title="Where could I find documentation of python/dyn or python3/dyn?" Tags="|vimscript|vimscript-python|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19641" PostTypeId="2" ParentId="19638" CreationDate="2019-04-18T03:02:33.160" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;matchadd()&lt;/code&gt; to conceal start of long lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let [b:logCols, b:minCols] = [80, 10]&#xA;let b:match_id = -1&#xA;&#xA;function! UpdateConceal()&#xA;  if b:match_id != -1 | call matchdelete(b:match_id) | endif&#xA;  let b:logCols = max([b:logCols, b:minCols])&#xA;  echo 'log columns : ' . b:logCols&#xA;  let b:match_id =  matchadd('Conceal', printf('\v^.+\ze.{%d}$', b:logCols), 10, -1)&#xA;endfunction&#xA;&#xA;call UpdateConceal()&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;c-right&amp;gt; :let b:logCols += 1 \| call UpdateConceal()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;c-left&amp;gt; :let b:logCols -= 1 \| call UpdateConceal()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Copy above script and source it, play around with &lt;code&gt;&amp;lt;c-right&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-left&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Pattern highlighted with &lt;code&gt;Conceal&lt;/code&gt; highlight group will be concealed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;\v^.+\ze.{80}$&lt;/code&gt; find lines that's longer then 80 characters, match from beginning of line until (not include) the last 80th character.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;check &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h matchadd()&#xA;:h hl-Conceal&#xA;:h 'conceallevel'&#xA;:h 'concealcursor'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this solution works on characters, not screen columns.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-18T03:12:22.660" LastActivityDate="2019-04-18T03:12:22.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19642" PostTypeId="1" CreationDate="2019-04-18T03:36:27.683" Score="1" ViewCount="249" Body="&lt;p&gt;Vim documentation states how to run &lt;code&gt;command&lt;/code&gt; and &lt;code&gt;normal&lt;/code&gt; mode commands (&lt;a href=&quot;https://vimhelp.org/if_pyth.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim.command(str)                                        python-command&#xA;        Executes the vim (ex-mode) command str.  Returns None.&#xA;        Examples: &#xA;            :py vim.command(&quot;set tw=72&quot;)&#xA;            :py vim.command(&quot;%s/aaa/bbb/g&quot;)&#xA;&#xA;       The following definition executes Normal mode commands: &#xA;                def normal(str):&#xA;                        vim.command(&quot;normal &quot;+str)&#xA;                # Note the use of single quotes to delimit a string containing&#xA;                # double quotes&#xA;                normal('&quot;a2dd&quot;aP')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to use &lt;code&gt;visual&lt;/code&gt; modes using &lt;code&gt;python/dyn&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I select something and start writing a command, the command gets substituted with &lt;code&gt;:'&amp;lt;,'&amp;gt;&lt;/code&gt;. I guess its some kind of selection identificator. Is it possible to explicitely state the selected region before a command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I want to select several lines or particular block and lower case it. In VIM visual block mode I could simply press &lt;code&gt;u&lt;/code&gt;, but how could I run this command using python/dyn &lt;code&gt;vim.command()&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="147" LastEditorUserId="147" LastEditDate="2019-04-18T03:58:03.513" LastActivityDate="2019-04-18T03:58:03.513" Title="How to use visual mode in python/dyn?" Tags="|vimscript|visual-mode|vimscript-python|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19643" PostTypeId="1" CreationDate="2019-04-18T05:55:45.940" Score="6" ViewCount="474" Body="&lt;p&gt;I am using &lt;code&gt;ibeam&lt;/code&gt; a.k.a &lt;code&gt;vertical bar&lt;/code&gt; cursor right now. When I switch to &lt;code&gt;terminal&lt;/code&gt; mode in &lt;code&gt;vim&lt;/code&gt;, it changes the cursor shape to &lt;code&gt;block&lt;/code&gt; - but doesn't restore it after I quit the &lt;code&gt;terminal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried changing it in my shell as per the below comment; it works for &lt;code&gt;:terminal&lt;/code&gt; but not for &lt;code&gt;:terminal tig&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help terminal&lt;/code&gt; has a section called &lt;code&gt;terminal-cursor-style&lt;/code&gt;, but I am not able sure what to do with that information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to inherit the terminal emulator's cursor shape inside &lt;code&gt;vim&lt;/code&gt; -- if not, can I at-least configure it to us my cursor style?&lt;/p&gt;&#xA;" OwnerUserId="8178" LastEditorUserId="8178" LastEditDate="2019-04-22T18:40:36.820" LastActivityDate="2024-01-25T05:33:25.640" Title="How do I make vim's terminal use my emulator's cursor shape?" Tags="|terminal|cursor|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19645" PostTypeId="1" AcceptedAnswerId="19685" CreationDate="2019-04-18T07:49:17.810" Score="1" ViewCount="116" Body="&lt;p&gt;Is there a way echoing a message if grep has no result and &lt;code&gt;getqflist()&lt;/code&gt; is empty?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried this, but it doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au QuickFixCmdPost grep call g:GrepPostActions() &#xA;&#xA;function! g:GrepPostActions()&#xA;  let qflist = getqflist()&#xA;  if len(qflist) &amp;gt; 0&#xA;    &quot;Move window to the very bottom&#xA;    wincmd J&#xA;  else &#xA;    &quot;??? QuickFixCmdPost doesn't fire on empty qflist ???&#xA;     echo 'No match found in '.getcwd() &#xA;  endif&#xA;endfunction&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8559" LastActivityDate="2019-04-21T18:00:10.643" Title="Echoing a message when grep has no result" Tags="|quickfix|grep|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19647" PostTypeId="1" CreationDate="2019-04-18T17:23:08.193" Score="1" ViewCount="45" Body="&lt;p&gt;Many moons ago, I made the common newb mistake of tricking out vim with all kinds of plugins and plugin loaders without really knowing what I was doing. I'm trying to clean things up a little. I'm still a little baffled, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just discovered the &lt;code&gt;vim --startuptime&lt;/code&gt; switch. I was looking at its output and noticed syntastic files were getting sourced twice, causing a big drag on load time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;087.736  000.744  000.609: sourcing /Users/me/.vim/bundle/ale/plugin/ale.vim&#xA;088.335  000.019  000.019: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/autoloclist.vim&#xA;088.410  000.014  000.014: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/balloons.vim&#xA;088.478  000.018  000.018: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/checker.vim&#xA;088.542  000.014  000.014: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/cursor.vim&#xA;088.606  000.014  000.014: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/highlighting.vim&#xA;088.670  000.014  000.014: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/loclist.vim&#xA;088.741  000.014  000.014: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/modemap.vim&#xA;088.803  000.014  000.014: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/notifiers.vim&#xA;088.869  000.016  000.016: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/registry.vim&#xA;088.933  000.014  000.014: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/signs.vim&#xA;089.637  000.480  000.480: sourcing /Users/me/.vim/bundle/syntastic/autoload/syntastic/util.vim&#xA;617.294  000.056  000.056: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/autoloclist.vim&#xA;617.409  000.051  000.051: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/balloons.vim&#xA;617.700  000.200  000.200: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/checker.vim&#xA;617.855  000.100  000.100: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/cursor.vim&#xA;617.993  000.085  000.085: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/highlighting.vim&#xA;618.331  000.286  000.286: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/loclist.vim&#xA;618.478  000.092  000.092: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/modemap.vim&#xA;618.607  000.077  000.077: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/notifiers.vim&#xA;619.003  000.344  000.344: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/registry.vim&#xA;619.161  000.093  000.093: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic/signs.vim&#xA;620.128  531.146  529.281: sourcing /Users/me/.vim/bundle/syntastic/plugin/syntastic.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to track down what causing this behavior. I commented out everything in my &lt;code&gt;.vimrc&lt;/code&gt; file having to do with syntastic. I notice in the output above, a file called &lt;code&gt;util.vim&lt;/code&gt; in the &lt;code&gt;autoload&lt;/code&gt; directory gets called. I'm wondering if that might be the culprit. But I'm just not sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The syntastic plugin is located in &lt;code&gt;~/.vim/bundle&lt;/code&gt;. I have pathogen in the &lt;code&gt;.vimrc&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;====[ Pathogen support ]======================&#xA;call pathogen#infect()&#xA;call pathogen#helptags()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2019-04-18T17:23:08.193" Title="syntastic plugin files getting sourced twice" Tags="|plugin-syntastic|" AnswerCount="0" CommentCount="3" ClosedDate="2019-04-23T00:39:56.457" ContentLicense="CC BY-SA 4.0" />
  <row Id="19648" PostTypeId="2" ParentId="3947" CreationDate="2019-04-18T20:17:49.930" Score="0" Body="&lt;p&gt;Well, I did somewhat of very nice overkill.&#xA;I have written code such that when you get to a wanted folder, you simply press &lt;code&gt;alt-right&lt;/code&gt; and it expands the folder (on top) and opens a new search. So I keep searching the wanted folder name in wanted level. I can also press &lt;code&gt;O&lt;/code&gt; (expand all) and look for it under the folder. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To collapse, &lt;code&gt;alt-left&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope you find it useful! &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DoOpen()&#xA;    let node = g:NERDTreeFileNode.GetSelected()&#xA;    if node.path.isDirectory &amp;amp;&amp;amp; (node.isOpen==0) &#xA;        execute &quot;norm \&amp;lt;CR&amp;gt;ztj&quot;&#xA;    endif   &#xA;endfunction&#xA;&quot; other&#xA;&quot;To use for consecutive searches. Saves the need to enter search seperately&#xA;&quot;each time. TODO: only on file xzt  &#xA;:autocmd FileType nerdtree cmap &amp;lt;buffer&amp;gt; &amp;lt;M-Right&amp;gt; &amp;lt;CR&amp;gt;:call DoOpen()&amp;lt;CR&amp;gt;/&#xA;:autocmd FileType nerdtree cmap &amp;lt;buffer&amp;gt; &amp;lt;M-left&amp;gt; &amp;lt;CR&amp;gt;x&#xA;:autocmd FileType nerdtree nmap &amp;lt;buffer&amp;gt; &amp;lt;M-Right&amp;gt; :call DoOpen()&amp;lt;CR&amp;gt;/&#xA;:autocmd FileType nerdtree nmap &amp;lt;buffer&amp;gt; &amp;lt;M-left&amp;gt; x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-04-19T07:34:37.007" LastActivityDate="2019-04-19T07:34:37.007" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19649" PostTypeId="2" ParentId="2455" CreationDate="2019-04-18T20:40:44.503" Score="1" Body="&lt;p&gt;One crucial point for me that continues to make me use MacVim verses just the terminal+vi is speed.  I have all kinds of vim plugins and language hints and syntax checkers that surprisingly bog the terminal vi way down, whilst the compiled bin of MacVim handles all that syntatic sugar just fine.  &lt;/p&gt;&#xA;" OwnerUserId="21861" LastActivityDate="2019-04-18T20:40:44.503" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19650" PostTypeId="1" CreationDate="2019-04-19T03:31:08.920" Score="1" ViewCount="150" Body="&lt;p&gt;Imagine I have a Vim buffer open and the file is changed externally (example: I switched git branches or the file was just edited normally).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any time that happens, I want to have 2 commands run. The first command, &lt;code&gt;Foo&lt;/code&gt; runs right before Vim updates the buffer with the new text and then the second command, &lt;code&gt;Bar&lt;/code&gt; runs after the buffer is updated. How do I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use autocmd like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! FileChangedShell * Foo&#xA;autocmd! FileChangedShellPost * Bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that it doesn't work. When the buffer updates, only FileChangedShellPost gets called. I tested this using these commands.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! FileChangedShell * echoerr &quot;About to read&quot;&#xA;autocmd! FileChangedShellPost * echoerr &quot;read!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the file is updated, only &quot;read!&quot; is printed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I'm using &lt;code&gt;CursorHold,CursorHoldI&lt;/code&gt; to try to simular a &quot;before buffer is read&quot; event but it's hacky. How do I run a command before the Vim buffer gets changed from an external edit?&lt;/p&gt;&#xA;" OwnerUserId="16073" LastEditorUserId="16073" LastEditDate="2019-04-19T05:24:40.080" LastActivityDate="2019-04-19T05:24:40.080" Title="Run commands before and after a buffer is externally changed" Tags="|autocmd|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19651" PostTypeId="1" AcceptedAnswerId="19652" CreationDate="2019-04-19T04:44:41.470" Score="20" ViewCount="5970" Body="&lt;p&gt;I was wondering what is the proper way to test whether a substring is included in some other string. If I want to check if string &lt;code&gt;a&lt;/code&gt; is part of string &lt;code&gt;b&lt;/code&gt;, I'm currently using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matchstr(b, a) != &quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to check if a is a substring of b. Is there a more &quot;proper&quot; way of doing it, since this seems like a bit of a hack.&lt;/p&gt;&#xA;" OwnerUserId="21269" LastActivityDate="2021-05-23T16:59:13.753" Title="How to check if a string is a substring of another string" Tags="|string-manipulation|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19652" PostTypeId="2" ParentId="19651" CreationDate="2019-04-19T04:50:19.337" Score="22" Body="&lt;p&gt;For this there is the function &lt;code&gt;stridx()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a = &quot;Vi and Vim&quot;&#xA;let b = &quot;and&quot;&#xA;echo stridx(a, b)&#xA;&quot; echos 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the substring is not found &lt;code&gt;stridx()&lt;/code&gt; returns &lt;code&gt;-1&lt;/code&gt;. &#xA;The function also supports a third argument to specify the start index to search from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help stridx()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-04-19T04:50:19.337" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19653" PostTypeId="1" AcceptedAnswerId="19654" CreationDate="2019-04-19T05:36:55.040" Score="6" ViewCount="1131" Body="&lt;p&gt;I would like to extract a list of distinct words from a set of lines. Is there a way of doing this ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say for example I have lines that look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&#xA;[(isPhysicallySettledFxFwd, NO,&quot;Y&quot;),(isPhysicallySettledFxFwd,isPhysicallySettledFxSwap,&quot;N&quot;)],&#xA;[(isPhysicallySettledFxSwap,NO,&quot;Y&quot;),(isPhysicallySettledFxSwap, isPhysicallySettledCommodity,&quot;Y&quot;)],&#xA;[(isPhysicallySettledCommodity,NO,&quot;Y&quot;),(isPhysicallySettledCommodity,YES,&quot;Y&quot;)]&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then i would get a list of distinct words, looking this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;isPhysicallySettledFxFwd&#xA;isPhysicallySettledFxSwap&#xA;isPhysicallySettledCommodity&#xA;NO&#xA;YES&#xA;Y&#xA;N&#xA;(&#xA;)&#xA;&quot;&#xA;[&#xA;]&#xA;,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not sure how to even start, apart from copying the lines to Excel and doing lots of manipulations...&lt;/p&gt;&#xA;" OwnerUserId="21293" LastActivityDate="2019-11-06T12:46:15.843" Title="How to get all distinct words within a set of lines?" Tags="|regular-expression|functions|vi-words|list|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19654" PostTypeId="2" ParentId="19653" CreationDate="2019-04-19T06:07:46.470" Score="3" Body="&lt;p&gt;You can do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let a=[]&#xA;:%s/\w\+/\=add(a, submatch(0))/gn&#xA;:new&#xA;:put =uniq(sort(a))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will first declare a list &lt;code&gt;a&lt;/code&gt; to work with. Then we run a &lt;code&gt;:%s&lt;/code&gt; command, to capture all word-characters (&lt;code&gt;\w\+&lt;/code&gt;) and act on all matches (&lt;code&gt;g&lt;/code&gt; flag of the &lt;code&gt;:s&lt;/code&gt; command), but won't actually replace (&lt;code&gt;n&lt;/code&gt; flag). We use a &lt;a href=&quot;https://vimhelp.org/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;sub-replace-expression&lt;/a&gt;(&lt;code&gt;\=&lt;/code&gt;) in the replacement part, to store the captured submatch in list &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally, we create a new window, and put the unique and sorted (&lt;code&gt;uniq&lt;/code&gt;) content of list a into it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get a lot more sophisticated, like only capturing certain words, or counting the numbers, but this shows how flexible the &lt;code&gt;:s&lt;/code&gt; command is.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-04-19T06:07:46.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19655" PostTypeId="2" ParentId="19653" CreationDate="2019-04-19T06:28:35.437" Score="2" Body="&lt;p&gt;Maybe this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\W/\r\0\r/g&#xA;:sort u&#xA;:g/^\s*$/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first puts a line break before and after each non-word character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second command sorts the entire file with the option &quot;unique&quot;, so all duplicate lines are removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third command deletes all lines that are empty or only contain whitespaces.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-04-19T06:28:35.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19656" PostTypeId="1" AcceptedAnswerId="19729" CreationDate="2019-04-19T07:07:37.667" Score="1" ViewCount="868" Body="&lt;p&gt;I'm trying to modify this file, by extracting the very &lt;em&gt;first&lt;/em&gt; line in the file and prepend it to each of the consecutive lines until end of the file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;black&#xA;widow&#xA;card&#xA;Friday&#xA;berry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used &lt;code&gt;ex&lt;/code&gt; command (which doesn't work as expected) which prepends the string &lt;code&gt;black&lt;/code&gt; from 2&lt;sup&gt;nd&lt;/sup&gt; line onward without deleting the first line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ex -sc '2,$s/^/black: /|x' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I want to do?&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Dynamically get the string &lt;code&gt;black&lt;/code&gt; in the replacement part &lt;code&gt;s//&amp;lt;&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Remove the first line after getting the string &lt;code&gt;black&lt;/code&gt; in the buffer&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Expected output would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;black: widow&#xA;black: card&#xA;black: Friday&#xA;black: berry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21865" LastEditorUserId="343" LastEditDate="2019-04-24T14:31:17.527" LastActivityDate="2019-04-24T15:34:12.137" Title="In Vim ex mode how to re-use a string from the default buffer in the command" Tags="|regular-expression|ex-mode|range|text-generation|string-manipulation|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19657" PostTypeId="1" AcceptedAnswerId="21438" CreationDate="2019-04-19T07:36:34.063" Score="3" ViewCount="933" Body="&lt;p&gt;With the default file explorer (netrw) you can press &lt;code&gt;x&lt;/code&gt; to open a file or directory with the system default application. Is there an easy way I can do the same with nerdTree? I can't find the option. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="5081" LastActivityDate="2021-06-24T13:37:39.817" Title="Execute a file from nerdTree" Tags="|plugin-nerdtree|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19658" PostTypeId="2" ParentId="74" CreationDate="2019-04-19T11:41:32.880" Score="2" Body="&lt;p&gt;Try to saves the buffer whenever text is changed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd TextChanged,TextChangedI &amp;lt;buffer&amp;gt; silent write&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/27387138/4217744&quot;&gt;Source&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18592" LastActivityDate="2019-04-19T11:41:32.880" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19659" PostTypeId="2" ParentId="830" CreationDate="2019-04-19T11:44:13.067" Score="0" Body="&lt;p&gt;For me is fine to save the buffer whenever text is changed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd TextChanged,TextChangedI &amp;lt;buffer&amp;gt; silent write&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found it &lt;a href=&quot;https://stackoverflow.com/a/27387138/4217744&quot;&gt;here&lt;/a&gt;. It works for me.&lt;/p&gt;&#xA;" OwnerUserId="18592" LastActivityDate="2019-04-19T11:44:13.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19660" PostTypeId="2" ParentId="19656" CreationDate="2019-04-19T14:19:24.667" Score="2" Body="&lt;p&gt;You can use registers (see &lt;code&gt;:h reg&lt;/code&gt;) to store a word of a line. For you particular case, you would have to perform the following set of commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm! gg&quot;zyiw&#xA;:norm! gg&quot;_dd&#xA;:%s/^/&amp;lt;C-r&amp;gt;z: /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first command yanks the first word into the register &lt;code&gt;z&lt;/code&gt; from the first line&lt;/li&gt;&#xA;&lt;li&gt;The second command deletes the first line into blackhole register.&lt;/li&gt;&#xA;&lt;li&gt;The third command is a general substitute command where &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; lets you insert content of a register (see &lt;code&gt;:h i_CTRL-R&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Of course, you can do this some other more general and secure way, but I guess that was not your query. You wanted to know how to store contents.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-19T14:19:24.667" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19661" PostTypeId="1" AcceptedAnswerId="19757" CreationDate="2019-04-19T14:49:09.673" Score="2" ViewCount="2536" Body="&lt;p&gt;I'll preface by saying that I am using Airline, &lt;a href=&quot;https://github.com/plytophogy/vim-virtualenv&quot; rel=&quot;nofollow noreferrer&quot;&gt;plytophogy/vim-virtualenv&lt;/a&gt; plugin and gruvbox as the Airline theme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to change the color of some string in the status line to, say, orange.&#xA;In my case that is the &quot;@my_env&quot; string that states my current working environment: &lt;a href=&quot;https://i.stack.imgur.com/7PJCy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7PJCy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, the line in my .vimrc that is responsible for this text is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_section_c='%t @%{virtualenv#statusline()}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Based on this &lt;a href=&quot;https://stackoverflow.com/questions/5994525/include-color-string-in-statusline&quot;&gt;question&lt;/a&gt;, I tried to change my .vimrc line to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_section_c='%t %#orange#@%{virtualenv#statusline()}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which seems to have highlighted the statusline from &quot;@my_env&quot; onwards:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ZOp2B.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZOp2B.png&quot; alt=&quot;Before&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that using &lt;code&gt;%#any_color#&lt;/code&gt; or even &lt;code&gt;%##&lt;/code&gt;by itself produces the same effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is: Is there a way to set a color for a string in the statusline?&lt;/p&gt;&#xA;" OwnerUserId="21831" LastActivityDate="2019-04-26T11:39:51.587" Title="Change/Set color to a string in statusline" Tags="|vimrc|vimscript|statusline|plugin-airline|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19662" PostTypeId="2" ParentId="19653" CreationDate="2019-04-19T15:03:27.850" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;grep&lt;/code&gt; with the &lt;code&gt;--only-matching&lt;/code&gt;/&lt;code&gt;-o&lt;/code&gt; flag to accomplish this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!grep -o '\w\+\|\W' | sort -u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-04-19T15:03:27.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19663" PostTypeId="1" AcceptedAnswerId="19664" CreationDate="2019-04-19T21:07:55.400" Score="2" ViewCount="1015" Body="&lt;p&gt;So, I started using NeoVim a little while ago and discovered a rather annoying quirk when using C++-style single-line comments &lt;code&gt;//&lt;/code&gt; in source code of any language.&#xA;Specifically, when you create a new line after a line which starts with &lt;code&gt;//&lt;/code&gt;, either by pressing enter in Insert Mode or by pressing &lt;code&gt;o&lt;/code&gt; in Normal Mode, the newly created line will also be pre-formatted to begin with &lt;code&gt;//&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//A single line comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;creating a line after it will produce&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//A single line comment&#xA;//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the cursor beginning Insert Mode after the second &lt;code&gt;//&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far as I can tell, this applies to all languages that support single-line comments. It's rather annoying since the whole point of a single-line comment is that they're, well, a &lt;strong&gt;single line&lt;/strong&gt;. This is likely just some new default option in NeoVim or something to do with the syntax files NeoVim uses compared to OG Vim but, regardless, how do I disable this &quot;feature&quot; so that creating a new line after a single-line comment won't automatically be prefixed with an unwanted &lt;code&gt;//&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, when I press &lt;code&gt;o&lt;/code&gt; in Normal Mode or press enter in Insert Mode on the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//A single line comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;should&lt;/em&gt; end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//A single line comment&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21879" LastActivityDate="2019-04-20T02:37:22.897" Title="NeoVim: Single-Line Comments Also Format the Next Line" Tags="|neovim|formatting|comments|options|default-settings|" AnswerCount="1" CommentCount="1" ClosedDate="2019-04-20T02:28:10.190" ContentLicense="CC BY-SA 4.0" />
  <row Id="19664" PostTypeId="2" ParentId="19663" CreationDate="2019-04-20T00:03:02.573" Score="2" Body="&lt;pre&gt;&lt;code&gt;set fo-=r fo -=o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                    *'formatoptions'* *'fo'*&#xA;'formatoptions' 'fo'    string (default: &quot;tcqj&quot;, Vi default: &quot;vt&quot;)&#xA;            local to buffer&#xA;    This is a sequence of letters which describes how automatic&#xA;    formatting is to be done.  See |fo-table|.  When the 'paste' option is&#xA;    on, no formatting is done (like 'formatoptions' is empty).  Commas can&#xA;    be inserted for readability.&#xA;    To avoid problems with flags that are added in the future, use the&#xA;    &quot;+=&quot; and &quot;-=&quot; feature of &quot;:set&quot; |add-option-flags|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *fo-table*&#xA;...&#xA;r   Automatically insert the current comment leader after hitting&#xA;    &amp;lt;Enter&amp;gt; in Insert mode.&#xA;o   Automatically insert the current comment leader after hitting 'o' or&#xA;    'O' in Normal mode.&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this option is local to buffer, lots of ftplugin changes this option, you can use &lt;code&gt;verbose set formatoption&lt;/code&gt; to check where it was last changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of time you need to put &lt;code&gt;set fo-=r fo -=o&lt;/code&gt; in &lt;code&gt;after/ftplugin/your_file_type.vim&lt;/code&gt; to override it. check &lt;code&gt;:h after-directory&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to apply it to all kinds of files, you need to create an autocmd and make sure it's created after &lt;code&gt;filetype plugon on&lt;/code&gt;, check &lt;a href=&quot;https://vi.stackexchange.com/questions/8824/in-what-order-does-vim-read-ftplugin-files-syntax-files-and-the-vimrc-when-th&quot;&gt;here&lt;/a&gt; for detail.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-20T02:37:22.897" LastActivityDate="2019-04-20T02:37:22.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19665" PostTypeId="1" AcceptedAnswerId="19666" CreationDate="2019-04-20T11:11:23.503" Score="3" ViewCount="973" Body="&lt;p&gt;Suppose I have a long python file which is limited to 79 character or so in width. One very helpful feature would be if I could view the whole file separated into multiple vertical splits which &quot;extends&quot; each other. This way, a wide monitor or laptop screen could be utilized more efficiently. Does such a vim plugin exist? Opening the same file in multiple splits would not cut it since both moving, editing and saving should impact all the splits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. If first split shows line 1-50, next would show line 51-100 and so on. And if I would move down in my first split, now showing line 25-75, the split nr.2 would then in turn visualize line 76-125 or something.&lt;/p&gt;&#xA;" OwnerUserId="21886" LastActivityDate="2019-04-20T18:46:21.450" Title="Split same file into multiple windows &quot;extending&quot; each other" Tags="|split|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19666" PostTypeId="2" ParentId="19665" CreationDate="2019-04-20T18:46:21.450" Score="4" Body="&lt;p&gt;The &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27scrollbind%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'scrollbind'&lt;/code&gt;&lt;/a&gt; option allows you to do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how you can set up 2 windows to scroll together:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:vsplit&lt;/code&gt; to have two windows showing the same buffer.  They start with the same viewport.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set scrollbind&lt;/code&gt; in the current window&lt;/li&gt;&#xA;&lt;li&gt;Switch to the other window.  Adjust it to display the next &quot;page&quot; of text.&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;L&lt;/kbd&gt; to move the cursor to the bottom of the second window&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;zt&lt;/kbd&gt; to scroll the buffer so the cursor's line is at the top of the window.  Now the last line in the first window is the first line in the second window.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+e&lt;/kbd&gt; to scroll the buffer up one line, so each window is now displaying their own distinct, but continuous views of the buffer.&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set scrollbind&lt;/code&gt; so the second window scrolls along with the first window&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can repeat these steps for any other windows you want to be part of the same bound group of windows.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2019-04-20T18:46:21.450" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19667" PostTypeId="1" AcceptedAnswerId="19668" CreationDate="2019-04-20T19:32:50.307" Score="3" ViewCount="2327" Body="&lt;p&gt;I'm a Colemak keyboard layout user and I recently started to learn and use Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was able to map the arrow keys in the &lt;code&gt;normal&lt;/code&gt; mode by putting custom mappings such as &lt;code&gt;noremap u k&lt;/code&gt; in .vimrc (because the keys &lt;code&gt;h&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, and &lt;code&gt;i&lt;/code&gt; are in different places in the Colemak layout).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I tried to use NERDTree, navigating through the NERDTree menu became very hard for me for I have to reach &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; key to navigate up and down (those keys are &lt;code&gt;y&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; in QWERTY). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to map those two keys into other keys? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would really appreciate any help!&lt;/p&gt;&#xA;" OwnerUserId="21891" LastActivityDate="2019-04-20T20:08:31.910" Title="NERDTreeMenu Remapping" Tags="|key-bindings|plugin-nerdtree|keyboard-layout|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19668" PostTypeId="2" ParentId="19667" CreationDate="2019-04-20T19:59:59.643" Score="4" Body="&lt;p&gt;if you look at the documentation (&lt;code&gt;:help NERDTree-t&lt;/code&gt;), you'll see that each of the command have a name and a default key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To remap for example &lt;code&gt;NERDTreeMapUpdir&lt;/code&gt; to the 'a' key, you just have to add to you &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let NERDTreeMapUpdir='a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7579" LastEditorUserId="7579" LastEditDate="2019-04-20T20:08:31.910" LastActivityDate="2019-04-20T20:08:31.910" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19669" PostTypeId="1" AcceptedAnswerId="19763" CreationDate="2019-04-20T22:17:42.453" Score="2" ViewCount="215" Body="&lt;p&gt;I know that when vim beeps at me it is generally telling me I did something wrong.  Sometimes it displays a helpful error message and sometimes it does not.  Is there a way to make it always show a message giving a reason for a beep, or is there a way to ask it for one?&lt;/p&gt;&#xA;" OwnerUserId="13018" LastEditorUserId="13018" LastEditDate="2019-05-03T21:55:50.467" LastActivityDate="2019-05-03T21:55:50.467" Title="Is There a Way to Make Vim Provide an Error Message Whenever it Beeps?" Tags="|message|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19670" PostTypeId="1" AcceptedAnswerId="19676" CreationDate="2019-04-20T23:12:25.563" Score="1" ViewCount="53" Body="&lt;p&gt;I'm learning to use Vim with vim-latex and I'm wondering when does the plugin actually activates once I open a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My intuition tells me that any file with the .tex extension should do it, but if I open a new file in the terminal with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim test.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The empty file is open but the plugin is not activated. Furthermore, if I save, quit and reopen, it is still not activated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've noticed it kicks in when I write the \begin{document} ... \end{document} environments and then I save, quit and reopen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this normal behavior? My purpose is to be able to open a new file and then immediately load a .tex template using vim-latex. &lt;/p&gt;&#xA;" OwnerUserId="21894" LastEditorUserId="21894" LastEditDate="2019-04-20T23:24:23.650" LastActivityDate="2019-04-21T09:36:43.840" Title="When does the file depending plugin kicks in?" Tags="|filetype-tex|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19671" PostTypeId="1" AcceptedAnswerId="19679" CreationDate="2019-04-21T02:26:31.103" Score="1" ViewCount="33" Body="&lt;p&gt;I'm working with vim + some plugins to code c++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes, because of some bug or some executing sequence issue, the command zone will show me two or three lines as below:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/5q8YH.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5q8YH.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, I got two lines in the command zone:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;test.cpp&quot; 62L...&#xA;:redraw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How could I clear them so that I can make it into one line as normal? I've tried to execute &lt;code&gt;:redraw&lt;/code&gt; but it's not working.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2019-04-21T09:53:34.140" Title="How to clear multi lines in command zone" Tags="|plugin-system|filetype-c++|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19672" PostTypeId="1" CreationDate="2019-04-21T02:32:39.953" Score="1" ViewCount="306" Body="&lt;p&gt;When I do &lt;code&gt;Vi{y&lt;/code&gt; to select inside a &lt;code&gt;{&lt;/code&gt; block and yank it, it doesn't paste how I expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed that after &lt;code&gt;V&lt;/code&gt; (which puts me into VISUAL-LINE mode), the &lt;code&gt;i{&lt;/code&gt; object takes me into &lt;code&gt;VISUAL&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a gif:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oQ1Fn.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oQ1Fn.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted the paste &lt;code&gt;p&lt;/code&gt; to put the text &lt;em&gt;underneath&lt;/em&gt; where my cursor was, as if I had yanked some text while in VISUAL-LINE mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I start visual mode with shift-V, I want object motions like &lt;code&gt;i{&lt;/code&gt; to keep me inside of that mode.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2019-05-21T04:07:51.417" Title="visual line mode is ended by inner block motion" Tags="|visual-mode|cursor-motions|object-motions|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19673" PostTypeId="2" ParentId="19672" CreationDate="2019-04-21T03:27:35.003" Score="1" Body="&lt;pre&gt;&lt;code&gt;i}                          *v_i}* *i}* *i{*&#xA;i{                          *v_iB* *v_i{* *iB*&#xA;iB          &quot;inner Block&quot;, select [count] Blocks, from &quot;[count] [{&quot;&#xA;            to the matching '}', excluding the '{' and '}' (see&#xA;            |[{|).&#xA;            When used in Visual mode it is made characterwise.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;getregtype()&lt;/code&gt; to check register type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Vi{&lt;/code&gt; will change visual mode to &lt;code&gt;v&lt;/code&gt;,  you can hit &lt;code&gt;V&lt;/code&gt; again to return to &lt;code&gt;V&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As long as lines of &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; don't belong to lines of &lt;code&gt;i}&lt;/code&gt;, &lt;code&gt;yi}&lt;/code&gt; will result in &lt;code&gt;V&lt;/code&gt; type register, you should use &lt;code&gt;yi}&lt;/code&gt; in your case.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-21T03:36:12.840" LastActivityDate="2019-04-21T03:36:12.840" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19674" PostTypeId="2" ParentId="19672" CreationDate="2019-04-21T04:06:46.213" Score="1" Body="&lt;p&gt;&lt;sup&gt;See &lt;code&gt;:h intro&lt;/code&gt; for more details&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has seven BASIC modes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Normal mode&lt;/li&gt;&#xA;&lt;li&gt;Visual mode&lt;/li&gt;&#xA;&lt;li&gt;Select mode&lt;/li&gt;&#xA;&lt;li&gt;Insert mode&lt;/li&gt;&#xA;&lt;li&gt;Command-line mode&lt;/li&gt;&#xA;&lt;li&gt;Cmdline mode&lt;/li&gt;&#xA;&lt;li&gt;Ex mode&lt;/li&gt;&#xA;&lt;li&gt;Terminal mode&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are six ADDITIONAL modes.  These are variants of the BASIC modes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Operator-pending mode&lt;/li&gt;&#xA;&lt;li&gt;Replace mode&lt;/li&gt;&#xA;&lt;li&gt;Virtual Replace mode&lt;/li&gt;&#xA;&lt;li&gt;Insert Normal mode&lt;/li&gt;&#xA;&lt;li&gt;Insert Visual mode&lt;/li&gt;&#xA;&lt;li&gt;Insert Select mode&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As you can see, there is no mode called &lt;code&gt;visual-line-mode&lt;/code&gt; that you talked about in your question. There are just three kinds of &lt;code&gt;visual-mode&lt;/code&gt;, none of which are modes themselves:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Characterwise visual (see `:h characterwise-visual)&lt;/li&gt;&#xA;&lt;li&gt;Linewise visual (see `:h linewise-visual)&lt;/li&gt;&#xA;&lt;li&gt;Blockwise visual (see `:h blockwise-visual)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Read &lt;code&gt;:h visual&lt;/code&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look through &lt;code&gt;:h text-object&lt;/code&gt;, you will see that the text objects you're talking about, i.e. &lt;code&gt;i{&lt;/code&gt; are not acceptable for &lt;code&gt;linewise-visual&lt;/code&gt; style of visual mode. Because, text-objects are supposed to work with visual-mode and after an operator, see &lt;code&gt;:h text-objects&lt;/code&gt;. That's why Vim intelligently changes the type of visual mode you were in, because it makes sense. But of course, you're in complete control with just one more keystroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Suggestion:&lt;/strong&gt; Use &lt;code&gt;vi{&lt;/code&gt; to visually select the content inside the curly braces and press &lt;code&gt;V&lt;/code&gt; to start visual line mode over the already selected lines. This is the default way.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-21T04:06:46.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19675" PostTypeId="1" AcceptedAnswerId="19677" CreationDate="2019-04-21T09:17:33.540" Score="6" ViewCount="2464" Body="&lt;p&gt;I am activating my autocomplete menu in vim using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-@&amp;gt; &amp;lt;C-n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and after it opened and only when it opened I would like to use the &quot;tab&quot; key to cycle through the menu. But when it isn't open I would still like to use the &quot;tab&quot; key to write normal &quot;tabs&quot;. Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much in advance.&lt;/p&gt;&#xA;" OwnerUserId="21901" LastEditorUserId="51" LastEditDate="2019-04-21T09:49:13.993" LastActivityDate="2019-04-21T09:49:13.993" Title="Cycle through autocomplete menu using tab" Tags="|key-bindings|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19676" PostTypeId="2" ParentId="19670" CreationDate="2019-04-21T09:31:17.517" Score="2" Body="&lt;p&gt;Vim has two filetype plugins for tex files. One is plaintex and the other is tex. The latter is more desirable for Latex files but Vim won't know if the file is Latex or PlainTex if you have no content in the file. That's why the plugin, which depends on the filetype autocommand of Tex filetype, is triggered after the file is recognized as a Latex document. So, to answer your question, the behavior is completely normal, even though I have no idea why there is a plaintex filetype and who uses that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solutions below are suggested better to worse, i.e. the first solution is best, the second better and the third meh:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You can put the following in your &lt;code&gt;vimrc&lt;/code&gt; to always use &lt;code&gt;tex&lt;/code&gt; as the default filetype:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tex_flavor = 'latex'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can put the following in your &lt;code&gt;~/.vim/after/ftplugin/plaintex.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set filetype=tex&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can put the following autocmds in your &lt;code&gt;vimrc&lt;/code&gt; in order to set the filetype to tex from plaintex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetype_tex&#xA;    au!&#xA;    autocmd FileType plaintex set filetype=tex&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-04-21T09:36:43.840" LastActivityDate="2019-04-21T09:36:43.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19677" PostTypeId="2" ParentId="19675" CreationDate="2019-04-21T09:40:50.773" Score="10" Body="&lt;p&gt;Put the following insert-mode mapping (see &lt;code&gt;:h mapmode-i&lt;/code&gt;) in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;TAB&amp;gt; pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;TAB&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;S-TAB&amp;gt; pumvisible() ? &quot;\&amp;lt;C-p&amp;gt;&quot; : &quot;\&amp;lt;TAB&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h pumvisible()&lt;/code&gt; returns non-zero when popupmenu is visible and zero otherwise. &lt;code&gt;:h :map-&amp;lt;expr&amp;gt;&lt;/code&gt; maps the key to the expression returned by the right hand side. And the whole expression is based on a ternary operator which ultimately states, map &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; to expression &lt;code&gt;\&amp;lt;C-n&amp;gt;&lt;/code&gt; if popup-menu is visible and to expression &lt;code&gt;\&amp;lt;Tab&amp;gt;&lt;/code&gt; otherwise.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-04-21T09:48:22.627" LastActivityDate="2019-04-21T09:48:22.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19678" PostTypeId="2" ParentId="19292" CreationDate="2019-04-21T09:48:08.213" Score="4" Body="&lt;p&gt;Since &lt;a href=&quot;https://github.com/vim/vim/commit/08cc374dabd2a02785129fa1c0100f7745c244ad&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.1838&lt;/a&gt; (Aug 2019) you can use the &lt;code&gt;:spellrare&lt;/code&gt; command, before that there is no way, other than manually editing the &lt;code&gt;~/.vim/spell/en.utf-8.add&lt;/code&gt; file.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-08-11T21:15:50.977" LastActivityDate="2019-08-11T21:15:50.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19679" PostTypeId="2" ParentId="19671" CreationDate="2019-04-21T09:53:34.140" Score="1" Body="&lt;p&gt;Try &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;L&lt;/kbd&gt;. This clears the screen then redraws it. That's also what &lt;code&gt;:redraw!&lt;/code&gt;, mentioned in the comments, does but this is a lot more convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The one caveat is that there can be a difference in timing between the two. Per help (i.e. the first couple entries in &lt;code&gt;:h various-commands&lt;/code&gt;), &lt;code&gt;ctrl-l&lt;/code&gt; may delay the redraw so Vim can process typeahead input while &lt;code&gt;:redraw!&lt;/code&gt; redraws right away. I've not encountered this difference myself and your scenario doesn't seem applicable...but it should be noted. Perhaps you'll be the one that has to resort to &lt;code&gt;:redraw!&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-04-21T09:53:34.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19680" PostTypeId="1" AcceptedAnswerId="19681" CreationDate="2019-04-21T10:17:58.113" Score="6" ViewCount="874" Body="&lt;p&gt;If I type &lt;code&gt;z=&lt;/code&gt; on a spelling suggestion it uses the entire screen. Is there any way to disable that?&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2021-03-16T15:49:01.307" Title="How can I make Vim not use the entire screen for spelling suggestions?" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19681" PostTypeId="2" ParentId="19680" CreationDate="2019-04-21T10:17:58.113" Score="10" Body="&lt;p&gt;There is the &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27spellsuggest%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'spellsuggest'&lt;/code&gt;&lt;/a&gt; option for this, which controls various options for the spelling suggestion. You can add a limit by appending a number (note the &lt;code&gt;+=&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set spellsuggest+=10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which limits the height of the spell window to ten lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like this feature has always been present; I just never knew.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another option I've been using for the last week is the below script; it will display suggestions in the commandline window, and just pressing a number (1-9) will replace the word while pressing 0 will load original &lt;code&gt;z=&lt;/code&gt; screen. Any other keys will be sent to Vim as normal, making it pretty easy to abort the search by just entering Vim commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NqNcw.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NqNcw.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Don't hijack the entire screen for spell checking, just show the top 9 results&#xA;&quot; in the commandline.&#xA;&quot; Press 0 for the full list. Any key press that's not a valid option (1-9) will&#xA;&quot; behave as normal.&#xA;fun! QuickSpell()&#xA;    if &amp;amp;spell is 0&#xA;        echohl Error | echo &quot;Spell checking not enabled&quot; | echohl None&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; Separator between items.&#xA;    let l:sep = ' | '&#xA;&#xA;    &quot; Show as many columns as will fit in the window.&#xA;    let l:sug = spellsuggest(expand('&amp;lt;cword&amp;gt;'), 9)&#xA;    let l:c = 0&#xA;    for l:i in range(0, len(l:sug))&#xA;        let l:c += len(l:sug[l:i - 1]) + len(printf('%d ', l:i + 1))&#xA;        &quot; The -5 is needed to prevent some hit-enter prompts, even when there is&#xA;        &quot; enough space (bug?)&#xA;        if l:c + (len(l:sep) * l:i) &amp;gt;= &amp;amp;columns - 5&#xA;            break&#xA;        endif&#xA;    endfor&#xA;&#xA;    &quot; Show options; make it stand out a bit.&#xA;    echohl QuickFixLine&#xA;    echo join(map(l:sug[:l:i - 1], {i, v -&amp;gt; printf('%d %s', l:i+1, l:v)}), l:sep)&#xA;    echohl None&#xA;&#xA;    &quot; Get answer.&#xA;    let l:char = nr2char(getchar())&#xA;&#xA;    &quot; Display regular spell screen on 0.&#xA;    if l:char is# '0'&#xA;        normal! z=&#xA;        return&#xA;    endif&#xA;&#xA;    let l:n = str2nr(l:char)&#xA;&#xA;    &quot; Feed the character if it's not a number, so it's easier to do e.g. &quot;ciw&quot;.&#xA;    if l:n is 0 || l:n &amp;gt; len(l:sug)&#xA;        return feedkeys(l:char)&#xA;    endif&#xA;&#xA;    &quot; Replace!&#xA;    exe printf(&quot;normal! ciw%s\&amp;lt;Esc&amp;gt;&quot;, l:sug[l:n-1])&#xA;    echo&#xA;endfun&#xA;nnoremap z= :call QuickSpell()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-04-23T01:44:56.650" LastActivityDate="2019-04-23T01:44:56.650" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19682" PostTypeId="1" AcceptedAnswerId="19683" CreationDate="2019-04-21T13:11:32.010" Score="2" ViewCount="831" Body="&lt;p&gt;I'm really new to Vim, and trying to proceed as described here: &lt;a href=&quot;https://vim.fandom.com/wiki/Keep_your_vimrc_file_clean&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vim.fandom.com/wiki/Keep_your_vimrc_file_clean&lt;/a&gt; for language specific customization.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to implement automatic line breaks in LaTeX.  So far my &lt;code&gt;.vimrc&lt;/code&gt; file has only one line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also created a file located at &lt;code&gt;~/.vim/ftplugin/tex.vim&lt;/code&gt; that reads &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal textwidth=80&#xA;setlocal number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However when I try to load some &lt;code&gt;.tex&lt;/code&gt; file these changes do not take effect.  I tried &lt;code&gt;:scriptnames&lt;/code&gt; to see what vim is loading and the output is the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: /usr/share/vim/vimrc&#xA;  2: /usr/share/vim/vim74/debian.vim&#xA;  3: /usr/share/vim/vim74/syntax/syntax.vim&#xA;  4: /usr/share/vim/vim74/syntax/synload.vim&#xA;  5: /usr/share/vim/vim74/syntax/syncolor.vim&#xA;  6: /usr/share/vim/vim74/filetype.vim&#xA;  7: ~/.vimrc&#xA;  8: /usr/share/vim/vim74/ftplugin.vim&#xA;  9: /usr/share/vim/vim74/indent.vim&#xA; 10: /usr/share/vim/vim74/plugin/getscriptPlugin.vim&#xA; 11: /usr/share/vim/vim74/plugin/gzip.vim&#xA; 12: /usr/share/vim/vim74/plugin/logiPat.vim&#xA; 13: /usr/share/vim/vim74/plugin/matchparen.vim&#xA; 14: /usr/share/vim/vim74/plugin/netrwPlugin.vim&#xA; 15: /usr/share/vim/vim74/plugin/rrhelper.vim&#xA; 16: /usr/share/vim/vim74/plugin/spellfile.vim&#xA; 17: /usr/share/vim/vim74/plugin/tarPlugin.vim&#xA; 18: /usr/share/vim/vim74/plugin/tohtml.vim&#xA; 19: /usr/share/vim/vim74/plugin/vimballPlugin.vim&#xA; 20: /usr/share/vim/vim74/plugin/zipPlugin.vim&#xA; 21: /usr/share/vim/vim74/syntax/vim.vim&#xA; 22: /usr/share/vim/vim74/syntax/python.vim&#xA; 23: /usr/share/vim/vim74/ftplugin/vim.vim&#xA; 24: /usr/share/vim/vim74/indent/vim.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for your help&lt;/p&gt;&#xA;" OwnerUserId="21903" LastActivityDate="2019-04-21T13:33:04.850" Title="ftplugin script not loading" Tags="|plugin-vim-latex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19683" PostTypeId="2" ParentId="19682" CreationDate="2019-04-21T13:33:04.850" Score="1" Body="&lt;p&gt;Vim has two filetype plugins for tex files. One is plaintex and the other is tex. The latter is more desirable for Latex files but Vim won't know if the file is Latex or PlainTex if you have no content in the file. That's why the plugin, which depends on the filetype autocommand of Tex filetype, is triggered after the file is recognized as a Latex document. So, to answer your question, the behavior is completely normal, even though I have no idea why there is a plaintex filetype and who uses that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solutions below are suggested better to worse, i.e. the first solution is best, the second better and the third meh:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You can put the following in your &lt;code&gt;vimrc&lt;/code&gt; to always use &lt;code&gt;tex&lt;/code&gt; as the default filetype:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tex_flavor = 'latex'&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can put the following in your &lt;code&gt;~/.vim/after/ftplugin/plaintex.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set filetype=tex&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can put the following autocmds in your &lt;code&gt;vimrc&lt;/code&gt; in order to set the filetype to tex from plaintex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetype_tex&#xA;    au!&#xA;    autocmd FileType plaintex set filetype=tex&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-21T13:33:04.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19684" PostTypeId="1" CreationDate="2019-04-21T15:42:49.603" Score="2" ViewCount="49" Body="&lt;p&gt;When editing a file named oldFile, with the command &lt;code&gt;:saveas newFileName&lt;/code&gt; I expected vim to save the current buffer under the new named file (i.e. newFileName) and set the filename of the current buffer to the new named file. However the current buffer still refers to the old file name (i.e. oldFile). I had to close vim and reopen the new named file from the command line.&lt;/p&gt;&#xA;&lt;p&gt;Why does renaming a file with &lt;code&gt;:saveas newFileName&lt;/code&gt; continue saving changes to the old filename instead of the new filename?&lt;/p&gt;&#xA;&lt;p&gt;Is there a single command to save the current buffer under the name of a new file and set the filename of the current buffer to the new file?&lt;/p&gt;&#xA;&lt;h2&gt;update&lt;/h2&gt;&#xA;&lt;p&gt;I tested the command &lt;code&gt;:saveas&lt;/code&gt; again and it works as expected, that it is, &lt;code&gt;:saveas newFile&lt;/code&gt; saves the current buffer as newFile, then renames the current buffer as newFile. I also found that another way to save a file as a different name and open the different named file is to (1) rename the current buffer &lt;code&gt;:f newFile&lt;/code&gt; (2) save the renamed current buffer (3) optionally delete the old file by executing a shell command in vim &lt;code&gt;!rm oldFile&lt;/code&gt;. I assume human error was the cause of the initial problem with the command &lt;code&gt;:saveas&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="18294" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-04-21T18:26:49.393" Title="Why does renaming with :saveas not open the new named file in the current buffer?" Tags="|buffers|save|file-operations|" AnswerCount="0" CommentCount="0" ClosedDate="2019-04-23T00:37:12.233" ContentLicense="CC BY-SA 4.0" />
  <row Id="19685" PostTypeId="2" ParentId="19645" CreationDate="2019-04-21T17:41:30.893" Score="0" Body="&lt;p&gt;Finally, I came up with this solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EchoResultMsg()&#xA;  let qflist = getqflist()&#xA;  if len(qflist) &amp;gt; 0&#xA;    echo 'grep: '.len(qflist).' matches found.'&#xA;  else&#xA;    echo 'grep: No match found in '.getcwd() &#xA;  endif&#xA;endfunction&#xA;&#xA;command! -nargs=+ -complete=file Grep grep &amp;lt;f-args&amp;gt; | cwindow | call EchoResultMsg() &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The newly defined &lt;code&gt;:Grep&lt;/code&gt; command calls &lt;code&gt;cwindow&lt;/code&gt; and &lt;code&gt;EchoResultMsg&lt;/code&gt; after &lt;code&gt;grep&lt;/code&gt;. The &lt;code&gt;cwindow&lt;/code&gt; command doesn't open the quickfix window, if there is no resulted match, but &lt;code&gt;EchoResultMsg&lt;/code&gt; can check the length of &lt;code&gt;qflist&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the simplified part of the code. The whole plugin can be found here: &lt;a href=&quot;https://github.com/mattia72/vim-ripgrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/mattia72/vim-ripgrep&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8559" LastEditorUserId="8559" LastEditDate="2019-04-21T18:00:10.643" LastActivityDate="2019-04-21T18:00:10.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19686" PostTypeId="1" CreationDate="2019-04-22T01:04:57.810" Score="2" ViewCount="48" Body="&lt;pre&gt;&lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-K&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;complete words with long dictionary file name, such as /home/xxx/.vim/mydict.&#xA;I'd like to omit or shorten the descriptive info.&#xA;I have googled but got no hints.&#xA;Any advice?&lt;/p&gt;&#xA;" OwnerUserId="21908" LastActivityDate="2019-04-22T01:04:57.810" Title="How to omit dictionary source file in dictionary completion" Tags="|autocompletion|dictionary|ins-completion|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19687" PostTypeId="2" ParentId="19656" CreationDate="2019-04-22T02:24:29.403" Score="3" Body="&lt;pre&gt;&lt;code&gt;ex -s +'norm! gg&quot;adiwdd' +'exec printf(&quot;%%s/^/%s : /&quot;, @a)' +'x' ex_txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;norm! gg&quot;adiwdd&lt;/code&gt; delete &lt;code&gt;black&lt;/code&gt; in 1st line to register a, delete first line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;exec printf(&quot;%%s/^/%s : /&quot;, @a)&lt;/code&gt; add content of register a to start of every line. You can get content of register a via &lt;code&gt;@a&lt;/code&gt; or &lt;code&gt;getreg('a')&lt;/code&gt; in ex mode . check &lt;code&gt;:h printf()&lt;/code&gt; if you have problem with &lt;code&gt;%%&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;x&lt;/code&gt; save and exit&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm new to this area, there might be other ways to access register in ex mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim -u NONE -Es +'norm! gg&quot;adiwdd' +'exec printf(&quot;%%s/^/%s : /&quot;, @a)' +'x' ex_txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OP had to add &lt;code&gt;-u NONE&lt;/code&gt; to make it work, that's very weird, i have no idea what kind of setting or plugin would make &lt;code&gt;ex&lt;/code&gt; broken.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-22T12:22:44.430" LastActivityDate="2019-04-22T12:22:44.430" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19688" PostTypeId="1" AcceptedAnswerId="19689" CreationDate="2019-04-22T08:01:59.810" Score="2" ViewCount="889" Body="&lt;p&gt;I'm trying to remove the verilog block comment start: &lt;code&gt;/*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to do this inside a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setline(line('.'), substitute(getline('.'), '/*','','')) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of some reason, it doesn't to anything.&#xA;I tried to use \V, I tried escaping.&#xA;It seems that no matter what I do, it never removes the comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The comment end syntax is removed with no problems:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setline(line('.'), substitute(getline('.'), &quot;*/&quot;, '', ''))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any advice?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;:&#xA;The function I'm trying to build is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! s:comment_line(set,vmode)&#xA;    let lnum = line('.')&#xA;    let line = getline('.')&#xA;    call setline(line('.'), substitute(getline('.'), '/\*', '', ''))&#xA;    call setline(lnum, substitute(line, &quot;*/&quot;, '', ''))&#xA;    norm! j&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; +  : call &amp;lt;SID&amp;gt;comment_line(0,0)&amp;lt;Cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; +  : call &amp;lt;SID&amp;gt;comment_line(0,1)&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I pick a few lines with visual/visual line/visual block, I get a &lt;code&gt;*/&lt;/code&gt; deleted but never a &lt;code&gt;/*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I removed other parts of the function for clarity)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Clarification:&lt;/strong&gt;&#xA;The reason I avoided using &lt;code&gt;s:/\*::&lt;/code&gt; is the errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer below suggests adding the &lt;code&gt;e&lt;/code&gt; switch: &lt;code&gt;s:/\*::e&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the suggestion to use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe a:firstline.&quot;,&quot;.a:lastline.&quot;s:\*/::e&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(which executes the substitution on all the selected range), is redundant here because the function is called for each line separately (A function is called for every line in a selected visual/visual line). So in this case one must use either &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe &quot;s:\*/::e&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if line('.')==a:firstline&#xA;   exe a:firstline.&quot;,&quot;.a:lastline.&quot;s:\*/::e&quot;&#xA;endif &quot; do only once&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19833" LastEditorUserId="19833" LastEditDate="2019-04-24T12:01:35.300" LastActivityDate="2019-04-24T12:01:35.300" Title="substituting /* in vimscript" Tags="|vimscript|substitute|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19689" PostTypeId="2" ParentId="19688" CreationDate="2019-04-22T08:33:29.500" Score="3" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use normal &lt;code&gt;:h :substitute&lt;/code&gt; ex-command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s:/\*::&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use setline in the following manner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setline(line('.'), substitute(getline('.'), &quot;/\\*&quot;, '', ''))&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or you can use &lt;code&gt;:h substitute()&lt;/code&gt; in the following manner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setline(line('.'), substitute(getline('.'), '/\*', '', ''))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suggest you use the ex-command, it also works in a function.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I used &lt;code&gt;:&lt;/code&gt; as delimiter because the pattern had &lt;code&gt;/&lt;/code&gt; in it. If I used &lt;code&gt;/&lt;/code&gt; as delimiter, I would need to escape the &lt;code&gt;/&lt;/code&gt; in the pattern like I did the &lt;code&gt;*&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;I needed to escape the &lt;code&gt;*&lt;/code&gt; twice because I used double-quotes to represent pattern string. Read &lt;code&gt;:h literal-string&lt;/code&gt; for more details.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You just need this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! s:comment_line(vmode) range abort&#xA;    if (a:vmode == 0)&#xA;        s:/\*::e&#xA;        s:\*/::e&#xA;    else&#xA;        exe a:firstline.&quot;,&quot;.a:lastline.&quot;s:/\\*::e&quot;&#xA;        exe a:firstline.&quot;,&quot;.a:lastline.&quot;s:\*/::e&quot;&#xA;    endif&#xA;endfunc&#xA;nnoremap &amp;lt;leader&amp;gt;tt :call &amp;lt;SID&amp;gt;comment_line(0)&amp;lt;CR&amp;gt;&#xA;xnoremap &amp;lt;leader&amp;gt;tt :call &amp;lt;SID&amp;gt;comment_line(1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-04-22T12:18:59.527" LastActivityDate="2019-04-22T12:18:59.527" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19690" PostTypeId="1" AcceptedAnswerId="19714" CreationDate="2019-04-22T12:59:20.790" Score="2" ViewCount="1382" Body="&lt;p&gt;I'm looking for a good way to generate lists that are automatically bulleted. I tried the markdown plugin. It generates bullets automatically but not numbered lists. I also tried the vim-pandoc plugin which handles markdown but it doesn't do automated bullets or numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2019-04-25T04:36:28.267" Title="Generating automated bullets and numbered lists with markdown" Tags="|filetype-markdown|plugin-vim-pandoc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19691" PostTypeId="2" ParentId="19690" CreationDate="2019-04-22T13:08:18.217" Score="4" Body="&lt;p&gt;Just discovered the &quot;bullets&quot; plugin. Seems to do the job perfectly: &lt;a href=&quot;https://github.com/dkarter/bullets.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/dkarter/bullets.vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2019-04-22T13:08:18.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19692" PostTypeId="1" AcceptedAnswerId="19693" CreationDate="2019-04-22T13:58:53.497" Score="1" ViewCount="128" Body="&lt;p&gt;With Vsplit, I always wish the new file would open on the last half of the vim session instead of the first. I can manually do &lt;code&gt;c-w&lt;/code&gt; and &lt;code&gt;c-r&lt;/code&gt; to switch them but I would rather have this automatic when I run &lt;code&gt;vsplit foo.js&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas how to make this automatic where the file opens on the right side of the screen?&lt;/p&gt;&#xA;" OwnerUserId="15557" LastActivityDate="2019-04-22T14:04:52.787" Title="Vpslit - open on the right side of session instead of left?" Tags="|window-management|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19693" PostTypeId="2" ParentId="19692" CreationDate="2019-04-22T14:04:52.787" Score="3" Body="&lt;p&gt;Put the following in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set splitright&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read &lt;code&gt;:h splitright&lt;/code&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-22T14:04:52.787" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19694" PostTypeId="1" AcceptedAnswerId="29542" CreationDate="2019-04-22T15:47:36.740" Score="5" ViewCount="1116" Body="&lt;p&gt;I'm doing some string processing in vimscript. I obtained a &lt;strong&gt;byte&lt;/strong&gt; index for a character in the string and now want to obtain the character at that byte index.&#xA;For single-byte charsets (like latin1) this is not a problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let char = string[offset]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what if the string is (potentially)  multi-byte?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I implemented the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:GetCharAtByteIdx(str, index)&#xA;  &quot; AFAIK maximum length of utf8-char is 4 byte&#xA;  let sp = a:str[a:index:(a:index+3)]&#xA;  let chr = strcharpart(sp, 0, 1)&#xA;  return [ chr, (a:index + strlen(chr)) ]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function returns the character at the given byte-index and the byte-index of the following character.&#xA;It works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better solution? Maybe a internal function I missed?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A (now deleted) comment proposed to use &lt;code&gt;matchstr(str, '\%2c.')&lt;/code&gt; to get the character at byte offset 2. The resulting function would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:GetCharAtByteIndex(str, index)&#xA;  let chr = matchstr(a:str, '\%' . (a:index+1) . 'c.')&#xA;  return [ chr, (a:index + strlen(chr)) ]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The tests were successful, but the test execution time increased from ~10 to ~15 seconds (5 Vim startup, 200 test overall + same for nvim). &lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-04-22T20:38:27.030" LastActivityDate="2021-03-07T16:37:23.137" Title="Reliably get the character at a byte index in a string" Tags="|vimscript|string-manipulation|multibyte|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="19695" PostTypeId="2" ParentId="19688" CreationDate="2019-04-22T16:29:56.830" Score="1" Body="&lt;p&gt;As @klaus stated, you need to escape &lt;code&gt;*&lt;/code&gt; and make things easier by using string-literals (aka single quotes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am going to take a different tact and suggest an alternative. Commenting is a common task and a bit tricker then it seems. I suggest you stand on the shoulders of giants and use a &lt;a href=&quot;https://vimawesome.com/?q=comment&quot; rel=&quot;nofollow noreferrer&quot;&gt;commenting plugin&lt;/a&gt;. I personally use &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow noreferrer&quot;&gt;commentary.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case this is an exercise then I would suggest you take a look at &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow noreferrer&quot;&gt;commentary.vim&lt;/a&gt; as a small example plugin or maybe this &lt;a href=&quot;https://gist.github.com/PeterRincker/13bde011c01b7fc188c5&quot; rel=&quot;nofollow noreferrer&quot;&gt;gist&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some thoughts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Try to use &lt;code&gt;'commentstring'&lt;/code&gt; so it works across multiple filetypes&lt;/li&gt;&#xA;&lt;li&gt;Avoid side-effects like mutating registers&lt;/li&gt;&#xA;&lt;li&gt;Maybe create an operator so you can combine with other motions&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-04-22T16:29:56.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19696" PostTypeId="1" AcceptedAnswerId="19697" CreationDate="2019-04-22T16:45:58.200" Score="1" ViewCount="58" Body="&lt;p&gt;Alot of times I will have a vim session with three split windows with three different files. But something might come up where I need to switch projects, close the vim session, and come back to it later. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to have it where I can save the state of that vim session with 3 seperate files loaded, close it, and come back to it later? With out having to vsplit each file manually again. &lt;/p&gt;&#xA;" OwnerUserId="15557" LastActivityDate="2019-04-22T16:52:30.603" Title="Possible to save session state with 3 seperate files loaded in one session?" Tags="|multiple-files|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19697" PostTypeId="2" ParentId="19696" CreationDate="2019-04-22T16:52:30.603" Score="2" Body="&lt;p&gt;Check out `:h Session'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can save a session by &lt;code&gt;:mksession session_name.vim&lt;/code&gt; and you can load a session by &lt;code&gt;:source session_name.vim&lt;/code&gt; where &lt;code&gt;session_name.vim&lt;/code&gt; is the name of the file that vim stores the info of a session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;:mksession&lt;/code&gt; without a filename, it will by default be saved into a file called &lt;code&gt;Session.vim&lt;/code&gt; in the current working directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can configure what settings of the current session you want to be saved for later use by setting up &lt;code&gt;:h 'sessionoptions'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-04-22T16:52:30.603" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19698" PostTypeId="1" CreationDate="2019-04-22T19:48:33.230" Score="1" ViewCount="737" Body="&lt;p&gt;I have a .cpp file in which I would like to change all less-than symbols to double quotes but maintain any instances of double-greater-than symbols, i.e. change &amp;lt; to &quot; while leaving all occurrences of &amp;lt;&amp;lt; alone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am very new to vim and as such am still trying to figure out the best way to replace characters in situations like this. &lt;/p&gt;&#xA;" OwnerUserId="21914" LastEditorUserId="343" LastEditDate="2019-04-23T13:37:30.347" LastActivityDate="2019-04-23T14:04:49.683" Title="Changing &lt; to &quot; but leave &lt;&lt; alone in Vim" Tags="|substitute|filetype-c++|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19699" PostTypeId="1" AcceptedAnswerId="19701" CreationDate="2019-04-22T22:10:52.187" Score="-1" ViewCount="540" Body="&lt;p&gt;When I append &lt;code&gt;map &amp;lt;leader&amp;gt;tn  :tabnew&amp;lt;CR&amp;gt;&lt;/code&gt; to my .vimrc and while tried to run this with &lt;code&gt;:,tn&lt;/code&gt; command it says &lt;code&gt;E73: tag stack empty&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21916" LastEditorUserId="51" LastEditDate="2019-04-23T00:37:56.270" LastActivityDate="2019-04-23T07:16:38.683" Title="E73: tag stack empty while creating a map&lt;leader&gt;" Tags="|key-bindings|leader|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19700" PostTypeId="2" ParentId="19656" CreationDate="2019-04-22T23:07:09.730" Score="4" Body="&lt;h1&gt;Using &lt;code&gt;ex&lt;/code&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Ex is the command-line successor to the venerable &lt;code&gt;ed&lt;/code&gt;, a line-oriented editor.&#xA;You can access ex-mode from vim by typing &lt;code&gt;Q&lt;/code&gt; (unless you have it mapped). &lt;code&gt;gQ&lt;/code&gt;&#xA;gives an improved ex-mode. See &lt;code&gt;:help Ex-mode&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also start &lt;code&gt;ex&lt;/code&gt; from the command line, just like &lt;code&gt;vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex {file}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you type your commands, and &lt;code&gt;ex&lt;/code&gt; does them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the &lt;code&gt;:&lt;/code&gt;-style commands available in &lt;code&gt;vim&lt;/code&gt; are available to &lt;code&gt;ex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Scripting &lt;code&gt;ex&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are scriptable ways of giving commands to &lt;code&gt;ex&lt;/code&gt;. We focus on&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;sourcing&lt;/code&gt; a file&lt;/li&gt;&#xA;&lt;li&gt;standard input&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;Sourcing a file&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Write a (vim)script in a file, then do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -S {script.vim} {file}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your script is sourced (executed line for line) on the file. When it's finished,&#xA;you'll be left in &lt;code&gt;ex&lt;/code&gt; as normal. We'll discuss the niceties of ending scripts&#xA;at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the benefits of this approach is the ability to easily edit and comment&#xA;your code (e.g., from &lt;code&gt;vim&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another benefit is the ability to source these scripts from inside &lt;code&gt;vim&lt;/code&gt; (via&#xA;&lt;code&gt;:source script.vim&lt;/code&gt;), and undo them (&lt;code&gt;u&lt;/code&gt;) as desired.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Standard Input&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Since you give commands to &lt;code&gt;ex&lt;/code&gt; on standard input, you can use any shell technique&#xA;to pass commands to it. For example, with bash, any of the following should&#xA;work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex {file} &amp;lt;&amp;lt;EOF&#xA;{script text}&#xA;EOF&#xA;&#xA;# or&#xA;&#xA;ex {file} &amp;lt;{script.vim}&#xA;&#xA;# or&#xA;&#xA;ex {file} &amp;lt; &amp;lt;(cat &amp;lt;&amp;lt;DOG&#xA;{script text}&#xA;DOG&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has the benefit that the entire contents of the 'ex-script' can be placed&#xA;in (human-readable!) form in a shell script.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Script considerations&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;What is the purpose of the script?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is intended to perform some changes to a file on disk, it should end with&#xA;the line &lt;code&gt;wq&lt;/code&gt; or a variation thereof, in order to write and quit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the script is just a pre-cursor to normal editing (and for you only), you can&#xA;end with &lt;code&gt;visual&lt;/code&gt; to drop you into Normal-mode of full-on &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, just let it end and drop you into interactive mode.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Solution&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Finally, a script to suit your needs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Delete first line into register z&#xA;1 delete z&#xA;&quot; Eliminate newlines&#xA;let @z = substitute(@z, '\v\n', '', 'g')&#xA;&quot; Put the contents from the first line on all the others&#xA;&quot; cf. :help sub-replace-special&#xA;%substitute/^/\=printf('%s: ', @z)/&#xA;&quot; Optional&#xA;&quot; write&#xA;&quot; quit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If using a heredoc syntax in the shell, you may need to eliminate the comments&#xA;entirely (delete them), since shell-quoting and comments may get in the way of&#xA;vim seeing the comments. In interactive and source use, commented lines are&#xA;perfectly fine.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've run &lt;code&gt;ex -S script.vim test.txt&lt;/code&gt; with the bottom two lines uncommented,&#xA;where &lt;code&gt;test.txt&lt;/code&gt; was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;black is the color of my true love's hair&#xA;widow&#xA;card&#xA;Friday&#xA;berry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And received as the new version&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;black is the color of my true love's hair: widow&#xA;black is the color of my true love's hair: card&#xA;black is the color of my true love's hair: Friday&#xA;black is the color of my true love's hair: berry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-04-23T13:14:15.293" LastActivityDate="2019-04-23T13:14:15.293" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19701" PostTypeId="2" ParentId="19699" CreationDate="2019-04-22T23:48:17.113" Score="1" Body="&lt;p&gt;A couple of points:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;(Most) maps of this form that I have seen want to be run in normal mode. So you need to press your leader key followed by &lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt;, without any colons. &lt;/li&gt;&#xA;&lt;li&gt;Dont use regular &lt;code&gt;map&lt;/code&gt;. It does too much, and is too easy to break. Prefer in this case a &lt;code&gt;noremap&lt;/code&gt; variant &lt;code&gt;nnoremap&lt;/code&gt; (for normal mode mappings). &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Your command fails because vim runs the command &lt;code&gt;tagnext&lt;/code&gt; (abbreviation: &lt;code&gt;tn&lt;/code&gt;) with an empty range, and the tagstack is empty. You probably meant to have &lt;code&gt;,tn&lt;/code&gt; make a new tab, with &lt;code&gt;,&lt;/code&gt; as your leader:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; make leader whatever you want&#xA;nnoremap &amp;lt;Leader&amp;gt;tn :tabnew&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="1841" LastEditDate="2019-04-23T07:16:38.683" LastActivityDate="2019-04-23T07:16:38.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19702" PostTypeId="2" ParentId="19698" CreationDate="2019-04-23T01:41:15.597" Score="0" Body="&lt;p&gt;It's tricky to match single &lt;code&gt;&amp;lt;&lt;/code&gt;, you have to consider behind and after character, which might also be start of line or end of line. An alternative is to match both of them, use &lt;code&gt;\=&lt;/code&gt; to deal with &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\V&amp;lt;&amp;lt;\|&amp;lt;/\=submatch(0)=='&amp;lt;'?'&quot;':'&amp;lt;&amp;lt;'/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\V&amp;lt;&amp;lt;\|&amp;lt;&lt;/code&gt; match &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;lt;&lt;/code&gt; if no &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; exists&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\=submatch(0)=='&amp;lt;'?'&quot;':'&amp;lt;&amp;lt;'&lt;/code&gt; replace &lt;code&gt;&amp;lt;&lt;/code&gt; with &lt;code&gt;&quot;&lt;/code&gt;, &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; with &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\=&lt;/code&gt; substitute with an expression, check &lt;code&gt;:h sub-replace-expression&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;submatch(0)&lt;/code&gt; the whole matched text in current &lt;code&gt;:substitute&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;submatch(0)=='&amp;lt;'?'&quot;':'&amp;lt;&amp;lt;'&lt;/code&gt; return &lt;code&gt;&quot;&lt;/code&gt; for &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; for &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-23T03:50:31.510" LastActivityDate="2019-04-23T03:50:31.510" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19703" PostTypeId="2" ParentId="2331" CreationDate="2019-04-23T02:39:40.593" Score="2" Body="&lt;p&gt;For example, if your ninja output directory is '$SRC/out'&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set makeprg=ninja\ -C\ $SRC/out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: the space should escape by backslash&lt;/p&gt;&#xA;" OwnerUserId="11350" LastActivityDate="2019-04-23T02:39:40.593" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19705" PostTypeId="1" AcceptedAnswerId="26494" CreationDate="2019-04-23T06:42:59.467" Score="3" ViewCount="17619" Body="&lt;p&gt;There is no &lt;code&gt;:shell&lt;/code&gt; command in neovim. &#xA;&lt;code&gt;:terminal&lt;/code&gt; opens a shell without previous output, while &lt;code&gt;:shell&lt;/code&gt; contains all the output of the parent shell and all previous shells. Is there any way to emulate &lt;code&gt;:shell&lt;/code&gt; behavior with &lt;code&gt;:term&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="11971" LastEditorUserId="5298" LastEditDate="2019-04-24T07:48:07.827" LastActivityDate="2024-03-29T08:55:07.320" Title="How can I emulate :shell command in Neovim?" Tags="|neovim|terminal|shell|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19707" PostTypeId="2" ParentId="19694" CreationDate="2019-04-23T07:19:15.213" Score="2" Body="&lt;p&gt;To answer my own question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) There is no internal function to get a character at a &lt;strong&gt;byte&lt;/strong&gt; offset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) How is the performance of the script function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Surprisingly: Very good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hacked Vim and added a new function called &lt;code&gt;strcharatbyte(str, index)&lt;/code&gt; that&#xA;returns the same list as the script function &lt;code&gt;s:GetCharAtByteIdx&lt;/code&gt; in my&#xA;question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I ran the tests for my &lt;a href=&quot;https://github.com/rakus/vimscript-editorconfig&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt; with Vim 50 times in a loop (on Linux). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The average time for the tests with the script function was 4982 ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The average time for the tests with the C function was 4468 ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function to get the character at byte offset is called 49334 times during the test. With this calling the C function is approximately 0.01 ms faster than the script function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is negligible.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The previous version of this answer calculated the advantage of the C with 0.0055 msec. That seemed to good to be true, so I reran the tests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This time with 50 iterations and also stopped other programs, so the tests are not influenced by other things happening on the computer. The result is still impressive.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-04-24T07:49:07.173" LastActivityDate="2019-04-24T07:49:07.173" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19709" PostTypeId="2" ParentId="11476" CreationDate="2019-04-23T12:02:45.540" Score="4" Body="&lt;p&gt;The following works and is faster than the &lt;code&gt;matchstr()&lt;/code&gt; solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Getchar()&#xA;  return strcharpart(strpart(getline('.'), col('.') - 1), 0, 1)&#xA;endfun&#xA;nnoremap GG :echo Getchar()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See my question &lt;a href=&quot;https://vi.stackexchange.com/questions/19694/reliably-get-the-character-at-a-byte-index-in-a-string&quot;&gt;Reliably get the character at a byte index in a string&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="51" LastEditDate="2019-04-29T05:56:46.790" LastActivityDate="2019-04-29T05:56:46.790" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19710" PostTypeId="2" ParentId="19698" CreationDate="2019-04-23T12:33:20.050" Score="2" Body="&lt;p&gt;Just to make an answer out of my comment above: you could substitute all ocurences of &lt;code&gt;&amp;lt;&lt;/code&gt; without a successor &lt;code&gt;&amp;lt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\(^\|[^&amp;lt;]\)&amp;lt;\($\|[^&amp;lt;]\)/\1&quot;\2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, using the very-magic flag, as suggested by @d-ben-knoble:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v(^|[^&amp;lt;])\&amp;lt;($|[^&amp;lt;])/\1&quot;\2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That means:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%s&lt;/code&gt;  substitute in all lines&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/\v&lt;/code&gt; starts search pattern and use &lt;code&gt;very-magic&lt;/code&gt; flag, so we don't need to escape some characters&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(^|[^&amp;lt;])&lt;/code&gt; searches for a start of line (&lt;code&gt;^&lt;/code&gt;) or one characters that is different from &lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\&amp;lt;&lt;/code&gt; then searches for a &lt;code&gt;&amp;lt;&lt;/code&gt; (the escape character here is needed)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;($|[^&amp;lt;])&lt;/code&gt; and finally searches for an end-of-line or a character that is different from &lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/\1&quot;\2/g&lt;/code&gt; and replaces all the findings with the first character, then &lt;code&gt;&quot;&lt;/code&gt; and the second character.&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-04-23T12:33:20.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19711" PostTypeId="1" AcceptedAnswerId="19747" CreationDate="2019-04-23T13:35:16.483" Score="0" ViewCount="470" Body="&lt;p&gt;I use 'DejaVu Sans Mono' as gui font both on Windows (7 and 10) and Linux. However, on Windows some characters are not displayed correctly (while many other Unicode characters are displayed normally). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. Ux20d7 combining character (right arrow above - mathematical vector symbol) is displayed OK on Linux (as a right arrow above the previously typed character), but on Windows 7 the character is displayed inside of the empty box (without any arrow), on Windows 10 the empty box is displayed next to the character. The encoding in all three cases is set as utf-8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Version info (Windows 7):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 10 2013 14:38:33)&#xA;MS-Windows 32-bit GUI version with OLE support&#xA;Compiled by mool@tororo&#xA;Big version with GUI.  Features included (+) or not (-):&#xA;+arabic             +ex_extra           +mouseshape         +syntax&#xA;+autocmd            +extra_search       +multi_byte_ime/dyn +tag_binary&#xA;+balloon_eval       +farsi              +multi_lang         +tag_old_static&#xA;+browse             +file_in_path       -mzscheme           -tag_any_white&#xA;++builtin_terms     +find_in_path       +netbeans_intg      +tcl/dyn&#xA;+byte_offset        +float              +ole                -tgetent&#xA;+cindent            +folding            +path_extra         -termresponse&#xA;+clientserver       -footer             +perl/dyn           +textobjects&#xA;+clipboard          +gettext/dyn        +persistent_undo    +title&#xA;+cmdline_compl      -hangul_input       -postscript         +toolbar&#xA;+cmdline_hist       +iconv/dyn          +printer            +user_commands&#xA;+cmdline_info       +insert_expand      -profile            +vertsplit&#xA;+comments           +jumplist           +python/dyn         +virtualedit&#xA;+conceal            +keymap             +python3/dyn        +visual&#xA;+cryptv             +langmap            +quickfix           +visualextra&#xA;+cscope             +libcall            +reltime            +viminfo&#xA;+cursorbind         +linebreak          +rightleft          +vreplace&#xA;+cursorshape        +lispindent         +ruby/dyn           +wildignore&#xA;+dialog_con_gui     +listcmds           +scrollbind         +wildmenu&#xA;+diff               +localmap           +signs              +windows&#xA;+digraphs           -lua                +smartindent        +writebackup&#xA;-dnd                +menu               -sniff              -xfontset&#xA;-ebcdic             +mksession          +startuptime        -xim&#xA;+emacs_tags         +modify_fname       +statusline         -xterm_save&#xA;+eval               +mouse              -sun_workshop       +xpm_w32&#xA;   system vimrc file: &quot;$VIM\vimrc&quot;&#xA;     user vimrc file: &quot;$HOME\_vimrc&quot;&#xA; 2nd user vimrc file: &quot;$HOME\vimfiles\vimrc&quot;&#xA; 3rd user vimrc file: &quot;$VIM\_vimrc&quot;&#xA;      user exrc file: &quot;$HOME\_exrc&quot;&#xA;  2nd user exrc file: &quot;$VIM\_exrc&quot;&#xA;  system gvimrc file: &quot;$VIM\gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME\_gvimrc&quot;&#xA;2nd user gvimrc file: &quot;$HOME\vimfiles\gvimrc&quot;&#xA;3rd user gvimrc file: &quot;$VIM\_gvimrc&quot;&#xA;    system menu file: &quot;$VIMRUNTIME\menu.vim&quot;&#xA;Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32   -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG   -DFEAT_XPM_W32   -DWINVER=0x0400 -D_WIN32_WINNT=0x0400  /Fo.\ObjGOLYHTRi386/ /Ox /GL -DNDEBUG  /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_GUI_W32 -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\&quot;tcl85.dll\&quot; -DDYNAMIC_TCL_VER=\&quot;8.5\&quot; -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\&quot;python27.dll\&quot; -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\&quot;python32.dll\&quot; -DFEAT_PERL -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\&quot;perl514.dll\&quot; -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=19 -DDYNAMIC_RUBY_DLL=\&quot;msvcrt-ruby192.dll\&quot; -DFEAT_BIG /Fd.\ObjGOLYHTRi386/ /Zi&#xA;Linking: link /RELEASE /nologo /subsystem:windows /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib uuid.lib /machine:i386 /nodefaultlib gdi32.lib version.lib   winspool.lib comctl32.lib advapi32.lib shell32.lib  /machine:i386 /nodefaultlib libcmt.lib oleaut32.lib  user32.lib      /nodefaultlib:python27.lib /nodefaultlib:python32.lib   &quot;E:\tcl\lib\tclstub85.lib&quot; WSock32.lib xpm\x86\lib\libXpm.lib /PDB:gvim.pdb -debug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Version info (Windows 10):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled May 18 2018 18:36:07)&#xA;MS-Windows 32-bit GUI version with OLE support&#xA;Included patches: 1&#xA;Compiled by mool@tororo&#xA;Huge version with GUI.  Features included (+) or not (-):&#xA;+acl                +emacs_tags         +mouse              +tag_binary&#xA;+arabic             +eval               +mouseshape         +tag_old_static&#xA;+autocmd            +ex_extra           +multi_byte_ime/dyn -tag_any_white&#xA;+autoservername     +extra_search       +multi_lang         +tcl/dyn&#xA;+balloon_eval       +farsi              +mzscheme/dyn       -termguicolors&#xA;-balloon_eval_term  +file_in_path       +netbeans_intg      +terminal&#xA;+browse             +find_in_path       +num64              -tgetent&#xA;++builtin_terms     +float              +ole                -termresponse&#xA;+byte_offset        +folding            +packages           +textobjects&#xA;+channel            -footer             +path_extra         +timers&#xA;+cindent            +gettext/dyn        +perl/dyn           +title&#xA;+clientserver       -hangul_input       +persistent_undo    +toolbar&#xA;+clipboard          +iconv/dyn          -postscript         +user_commands&#xA;+cmdline_compl      +insert_expand      +printer            +vertsplit&#xA;+cmdline_hist       +job                +profile            +virtualedit&#xA;+cmdline_info       +jumplist           +python/dyn         +visual&#xA;+comments           +keymap             +python3/dyn        +visualextra&#xA;+conceal            +lambda             +quickfix           +viminfo&#xA;+cryptv             +langmap            +reltime            +vreplace&#xA;+cscope             +libcall            +rightleft          -vtp&#xA;+cursorbind         +linebreak          +ruby/dyn           +wildignore&#xA;+cursorshape        +lispindent         +scrollbind         +wildmenu&#xA;+dialog_con_gui     +listcmds           +signs              +windows&#xA;+diff               +localmap           +smartindent        +writebackup&#xA;+digraphs           +lua/dyn            +startuptime        -xfontset&#xA;+directx            +menu               +statusline         -xim&#xA;-dnd                +mksession          -sun_workshop       +xpm_w32&#xA;-ebcdic             +modify_fname       +syntax             -xterm_save&#xA;   system vimrc file: &quot;$VIM\vimrc&quot;&#xA;     user vimrc file: &quot;$HOME\_vimrc&quot;&#xA; 2nd user vimrc file: &quot;$HOME\vimfiles\vimrc&quot;&#xA; 3rd user vimrc file: &quot;$VIM\_vimrc&quot;&#xA;      user exrc file: &quot;$HOME\_exrc&quot;&#xA;  2nd user exrc file: &quot;$VIM\_exrc&quot;&#xA;  system gvimrc file: &quot;$VIM\gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME\_gvimrc&quot;&#xA;2nd user gvimrc file: &quot;$HOME\vimfiles\gvimrc&quot;&#xA;3rd user gvimrc file: &quot;$VIM\_gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME\defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME\menu.vim&quot;&#xA;Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL -DFEAT_NETBEANS_INTG -DFEAT_JOB_CHANNEL   -DFEAT_XPM_W32   -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG /arch:IA32 /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_GUI_W32 -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DFEAT_DIRECTX_COLOR_EMOJI -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\&quot;tcl86t.dll\&quot; -DDYNAMIC_TCL_VER=\&quot;8.6\&quot; -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\&quot;lua53.dll\&quot; -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\&quot;python27.dll\&quot; -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\&quot;python36.dll\&quot; -DFEAT_MZSCHEME -I &quot;E:\Racket\include&quot; -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\&quot;libracket3m_a36fs8.dll\&quot; -DDYNAMIC_MZGC_DLL=\&quot;libracket3m_a36fs8.dll\&quot; -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\&quot;perl524.dll\&quot; -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=24 -DDYNAMIC_RUBY_DLL=\&quot;msvcrt-ruby240.dll\&quot; -DFEAT_HUGE /Fd.\ObjGXOULYHTRZi386/ /Zi&#xA;Linking: link  /nologo /subsystem:windows,5.01 /opt:ref /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib uuid.lib /machine:i386 gdi32.lib version.lib   winspool.lib comctl32.lib advapi32.lib shell32.lib  /machine:i386  libcmt.lib oleaut32.lib user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python36.lib   &quot;E:\ActiveTcl\lib\tclstub86.lib&quot; WSock32.lib xpm\x86\lib-vc14\libXpm.lib /PDB:gvim.pdb -debug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to correct this situation so that the same font was displayed identically on Windows and Linux.&lt;/p&gt;&#xA;" OwnerUserId="1378" LastActivityDate="2019-04-25T22:14:56.580" Title="On Windows some symbols are not displayed" Tags="|microsoft-windows|unicode|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19712" PostTypeId="2" ParentId="19698" CreationDate="2019-04-23T13:38:37.043" Score="1" Body="&lt;h2&gt;Use lookarounds&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I think the simplest &lt;code&gt;:substitute&lt;/code&gt; command might be to use lookarounds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;lt;\@&amp;lt;!&amp;lt;&amp;lt;\@!/&quot;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This replaces every &lt;code&gt;&amp;lt;&lt;/code&gt; character that is neither preceded nor followed by another &lt;code&gt;&amp;lt;&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How it works&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It uses a &lt;code&gt;:substitute&lt;/code&gt; command (See &lt;code&gt;:help :substitute&lt;/code&gt;) to replace strings that match the regular expression &lt;code&gt;&amp;lt;\@&amp;lt;!&amp;lt;&amp;lt;\@!&lt;/code&gt; with &lt;code&gt;&quot;&lt;/code&gt; characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regular expression is reasonably simple when broken down. It consists of three parts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;lt;\@&amp;lt;!&amp;lt;&amp;lt;\@!/&quot;/g&#xA;         ^&#xA;         1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the middle is a single &lt;code&gt;&amp;lt;&lt;/code&gt; character. This is what we want to match.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;lt;\@&amp;lt;!&amp;lt;&amp;lt;\@!/&quot;/g&#xA;    ^^^^^&#xA;      2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before that is: &lt;code&gt;&amp;lt;\@&amp;lt;!&lt;/code&gt;. This is a second &lt;code&gt;&amp;lt;&lt;/code&gt; character followed by Vim's atom for negative lookbehind: &lt;code&gt;\@&amp;lt;!&lt;/code&gt;, which means that our central &lt;code&gt;&amp;lt;&lt;/code&gt; will only be matched if we &lt;em&gt;didn't&lt;/em&gt; match a &lt;code&gt;&amp;lt;&lt;/code&gt; here.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&amp;lt;\@&amp;lt;!&amp;lt;&amp;lt;\@!/&quot;/g&#xA;          ^^^^&#xA;            3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the end we have: &lt;code&gt;&amp;lt;\@!&lt;/code&gt;. This is a third &lt;code&gt;&amp;lt;&lt;/code&gt;, this time followed by Vim's atom for negative lookahead: &lt;code&gt;\@!&lt;/code&gt;:our &lt;code&gt;&amp;lt;&lt;/code&gt; will only be matched if it is &lt;em&gt;not&lt;/em&gt; followed by a &lt;code&gt;&amp;lt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help \@!&lt;/code&gt; and &lt;code&gt;:help \@&amp;lt;!&lt;/code&gt; for more details of Vim's negative lookaround atoms.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-04-23T14:04:49.683" LastActivityDate="2019-04-23T14:04:49.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19713" PostTypeId="2" ParentId="3814" CreationDate="2019-04-23T17:43:57.257" Score="2" Body="&lt;p&gt;Expanding the idea of @Peter Rincker and @go2null. If you do not want to set the folding options in Vim modeline. You can use the following autocmd to set the folding method and folding expression.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vim_folding&#xA;    autocmd!&#xA;    autocmd FileType vim set foldmethod=expr foldlevel=0&#xA;    &quot; note that double quote in foldexpr has to be escaped with backslash&#xA;    autocmd FileType vim set foldexpr=getline(v:lnum)=~'^\&quot;#'?'&amp;gt;'.(matchend(getline(v:lnum),'\&quot;#*')-1):'='&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I made small modifications to make the original answer to make it work as regular vim command (no need to escape colon, but double quote needs to be escaped).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do not like the long &lt;code&gt;foldexpr&lt;/code&gt; string, we can define a function for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! VimFolds(lnum)&#xA;    let s:cur_line = getline(a:lnum)&#xA;&#xA;    if s:cur_line =~ '^&quot;#'&#xA;        return '&amp;gt;' . (matchend(s:cur_line, '&quot;#*')-1)&#xA;    else&#xA;        return '='&#xA;    endif&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then replace the autocmd line about &lt;code&gt;foldexpr&lt;/code&gt; to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType vim set foldexpr=VimFolds(v:lnum)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15292" LastEditorUserId="15292" LastEditDate="2019-04-24T01:52:21.933" LastActivityDate="2019-04-24T01:52:21.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19714" PostTypeId="2" ParentId="19690" CreationDate="2019-04-23T19:32:17.847" Score="3" Body="&lt;p&gt;There is an inbuilt feature in vim, write this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;use &lt;code&gt;yy5p&lt;/code&gt; to paste 5 (or use any number) lines of number 1)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1)&#xA;1)&#xA;1)&#xA;1)&#xA;1)&#xA;1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now select from the second to the last line and press &lt;code&gt;g&lt;/code&gt; then &lt;code&gt;Ctrl+A&lt;/code&gt;. It will populate numbered lists automatically as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1)&#xA;2)&#xA;3)&#xA;4)&#xA;5)&#xA;6)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19211" LastEditorUserId="19211" LastEditDate="2019-04-25T04:36:28.267" LastActivityDate="2019-04-25T04:36:28.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19715" PostTypeId="1" CreationDate="2019-04-23T20:22:32.957" Score="1" ViewCount="109" Body="&lt;p&gt;I installed pymode plugin but it overrides my default setting (&lt;code&gt;set wrap&lt;/code&gt;). According to &lt;code&gt;:verbose set wrap?&lt;/code&gt;, the option is set by pymode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'm not sure if it is possible to override the setting. I could not find how it is done in &lt;a href=&quot;https://github.com/python-mode/python-mode&quot; rel=&quot;nofollow noreferrer&quot;&gt;the plugin Github repository&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1072" LastEditorUserId="1072" LastEditDate="2019-04-24T13:51:40.147" LastActivityDate="2020-01-19T20:03:20.457" Title="Is it possible to disable the &quot;nowrap&quot; option on pymode?" Tags="|wrapping|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19716" PostTypeId="1" AcceptedAnswerId="19717" CreationDate="2019-04-23T20:57:50.083" Score="0" ViewCount="291" Body="&lt;p&gt;If my cursor is between the words &quot;because&quot; and &quot;and&quot; in the following text, typing &lt;strong&gt;d2w&lt;/strong&gt; in command mode deletes everything in between &quot;because&quot; and &quot;su without&quot;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;because and su without&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After typing &lt;strong&gt;d2w&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;becausesu without&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Before typing &lt;strong&gt;d2w&lt;/strong&gt; there was only one word between &quot;because&quot; and &quot;su&quot; so why were the white space characters either side of &quot;and&quot; also deleted?&lt;/li&gt;&#xA;&lt;li&gt;Does &lt;strong&gt;d2w&lt;/strong&gt; delete starting from the cursor or after the cursor?&lt;/li&gt;&#xA;&lt;li&gt;Why is &lt;strong&gt;d2w&lt;/strong&gt; deleting only one word and white space characters surrounding that word instead of deleting 2 words?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18294" LastActivityDate="2019-04-24T22:09:34.120" Title="How does deleting words with `d[number]w` work?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19717" PostTypeId="2" ParentId="19716" CreationDate="2019-04-23T21:16:34.520" Score="1" Body="&lt;p&gt;You should think of &lt;code&gt;dw&lt;/code&gt; as delete until the next start of a word.  Likewise &lt;code&gt;d2w&lt;/code&gt; means delete until the second next start of a word.  It is not the same as &quot;delete a word.&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;because and su without&#xA;       ||   \__ 2w&#xA;       |\______ w&#xA;       \_______ cursor position&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Before typing d2w there was only one word between &quot;because&quot; and &quot;su&quot; so why were the white space characters either side of &quot;and&quot; also deleted?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Do the motion &lt;code&gt;2w&lt;/code&gt;.  Then imagine deleting up until that cursor position.  The only thing that matters is that there are two starts of words (&lt;strong&gt;a&lt;/strong&gt;&amp;#x332;nd and &lt;strong&gt;s&lt;/strong&gt;&amp;#x332;u).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Does d2w delete starting from the cursor or after the cursor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It deletes starting from the cursor, that is to say the cursor character is also deleted.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why is d2w deleting only one word and white space characters surrounding that word instead of deleting 2 words?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Because it counts two starts of words forward then deletes everything until that point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The operation &lt;code&gt;daw&lt;/code&gt; and &lt;code&gt;d2aw&lt;/code&gt; can be thought of as &quot;delete a word&quot; and &quot;delete two words.&quot;  This might be closer to what you were expecting.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2019-04-24T22:09:34.120" LastActivityDate="2019-04-24T22:09:34.120" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19718" PostTypeId="2" ParentId="19715" CreationDate="2019-04-23T22:27:35.100" Score="2" Body="&lt;p&gt;Typically, one can override settings for file types with &lt;code&gt;.vim/after/ftplugin/{filetype}.vim&lt;/code&gt;, so,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; .vim/after/ftplugin/python.vim&#xA;setlocal wrap&#xA;&quot; dont forget about b:undo_ftplugin (1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternately, the plugin may provide a configuration variable (check its help documentation) that controls application of such settings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, you may want &lt;code&gt;let g:pymode_options = 0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;For &lt;code&gt;b:undo_ftplugin&lt;/code&gt;, I recommend my approach &lt;a href=&quot;https://github.com/benknoble/Dotfiles/blob/master/links/vim/autoload/ftplugin.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, especially if (like me) you maintain a fair number of filetype-specific settings. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-04-24T17:23:08.530" LastActivityDate="2019-04-24T17:23:08.530" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19719" PostTypeId="2" ParentId="16265" CreationDate="2019-04-24T03:28:39.217" Score="2" Body="&lt;p&gt;After you toggle the value of &lt;code&gt;g:ycm_show_diagnostics_ui&lt;/code&gt;, run &lt;code&gt;:YcmRestartServer&lt;/code&gt; and then reload the file with &lt;code&gt;:e&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15493" LastEditorUserId="51" LastEditDate="2019-04-24T07:48:46.643" LastActivityDate="2019-04-24T07:48:46.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19720" PostTypeId="2" ParentId="11476" CreationDate="2019-04-24T04:05:57.367" Score="1" Body="&lt;p&gt;I have been using this in my plugin.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let char = matchstr(getline('.')[col('.') - 1 :], '^.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1641" LastEditorUserId="51" LastEditDate="2019-04-24T05:19:03.863" LastActivityDate="2019-04-24T05:19:03.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19721" PostTypeId="1" AcceptedAnswerId="19722" CreationDate="2019-04-24T04:28:42.257" Score="0" ViewCount="256" Body="&lt;p&gt;If I make a mark &lt;code&gt;ma&lt;/code&gt; in one split pane and then from another I try to jump to it &lt;code&gt;'a&lt;/code&gt; I can't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess marks are stored per-buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I store marks per-tab?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2019-04-24T04:50:12.440" Title="marks between windows" Tags="|vim-windows|tabbed-user-interface|mark|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19722" PostTypeId="2" ParentId="19721" CreationDate="2019-04-24T04:50:12.440" Score="0" Body="&lt;p&gt;use upper case or number mark: &lt;code&gt;mA&lt;/code&gt;, &lt;code&gt;'A&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;a-z&lt;/code&gt; marks are stored per buffer. &lt;code&gt;A-Z0-9&lt;/code&gt; are are global marks, AFAIK you can't store built-in marks per-tab.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *'* *'a* *`* *`a*&#xA;'{a-z}  `{a-z}      Jump to the mark {a-z} in the current buffer.&#xA;&#xA;                        *'A* *'0* *`A* *`0*&#xA;'{A-Z0-9}  `{A-Z0-9}    To the mark {A-Z0-9} in the file where it was set (not&#xA;            a motion command when in another file).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-04-24T04:50:12.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19723" PostTypeId="1" CreationDate="2019-04-24T09:04:02.920" Score="0" ViewCount="91" Body="&lt;p&gt;I want to close a window by mentioning window name in command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's assume I have opened &lt;code&gt;1.c&lt;/code&gt;, &lt;code&gt;2.c&lt;/code&gt; and &lt;code&gt;3.c&lt;/code&gt; in different windows in vim. Now i'm in &lt;code&gt;2.c&lt;/code&gt; and i want to close &lt;code&gt;3.c&lt;/code&gt;. Is there a way i can close it like e.g. &lt;code&gt;:close 3.c&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="21933" LastEditorUserId="1841" LastEditDate="2019-04-24T13:37:17.257" LastActivityDate="2019-05-24T14:03:20.663" Title="how to close a single window by mentioning filename opened in that window" Tags="|buffers|vim-windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19724" PostTypeId="2" ParentId="19723" CreationDate="2019-04-24T09:16:46.697" Score="1" Body="&lt;p&gt;You need to use &lt;code&gt;:bdelete 3.c&lt;/code&gt; or in short form &lt;code&gt;:bd 3.c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a couple of terms you need to understand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A buffer is the in-memory text of a file.&#xA;A window is a viewport on a buffer.&#xA;A tab page is a collection of windows.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, what you're trying to do is close a buffer, not a window. The available commands to manipulate buffers are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:buffers&lt;/code&gt; or &lt;code&gt;:ls&lt;/code&gt; or &lt;code&gt;:files&lt;/code&gt; : See the list of opened buffers&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:badd&lt;/code&gt;     : Add a file to the buffer list&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:bdelete&lt;/code&gt;  : Remove buffer from the buffer list&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:bwipeout&lt;/code&gt; : Like &lt;code&gt;:bdelete&lt;/code&gt;, but really delete the buffer.&#xA;And many more. You can find all about them from &lt;code&gt;:help windows.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="16280" LastEditDate="2019-04-24T09:23:10.443" LastActivityDate="2019-04-24T09:23:10.443" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19725" PostTypeId="1" AcceptedAnswerId="19726" CreationDate="2019-04-24T09:57:24.830" Score="3" ViewCount="370" Body="&lt;p&gt;If I yank some text in the clipboard selection from Vim (e.g. &lt;code&gt;&quot;+yiw&lt;/code&gt;), then quit Vim, I can't paste it in &lt;a href=&quot;https://st.suckless.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;st&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a MWE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ git clone https://git.suckless.org/st&#xA;$ cd st&#xA;$ make&#xA;$ ./st&#xA;$ echo foo | vim -Nu NONE -&#xA;&quot;+yiw&#xA;:q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;code&gt;C-S-v&lt;/code&gt; to paste &lt;code&gt;foo&lt;/code&gt;, nothing is pasted on the shell's command-line. I can't paste the text in firefox, nor in xterm, but for some reason I can in urxvt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OTOH, if I don't quit Vim, but just suspend it with &lt;code&gt;:shell&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ./st&#xA;$ echo foo | vim -Nu NONE -&#xA;&quot;+yiw&#xA;:shell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I can paste the yanked text anywhere, including in the current st terminal.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;E558&lt;/code&gt; is raised when you start Vim, this may fix the issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ curl -LO http://invisible-island.net/datafiles/current/terminfo.src.gz&#xA;$ gunzip terminfo.src.gz&#xA;$ tic -x terminfo.src&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's another MWE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ./st&#xA;$ vim -Nu NONE +'let @+ = &quot;bar&quot;' +q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, if I press &lt;code&gt;C-S-v&lt;/code&gt; to paste &lt;code&gt;bar&lt;/code&gt;, nothing is pasted on the shell's command-line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can reproduce with Vim (8.1.1200), but not with Nvim (NVIM v0.4.0-620-geada8f5aa).&lt;br&gt;&#xA;I'm on Ubuntu 16.04, and I can also reproduce on Ubuntu 18.04 in a virtual machine.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Is it due to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a bug in Vim?&lt;/li&gt;&#xA;&lt;li&gt;a bug in st?&lt;/li&gt;&#xA;&lt;li&gt;a missing configuration in one of them?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If it's a bug, what's the best workaround?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I'm experimenting this autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup fix_yank_in_clipboard_from_st&#xA;   au!&#xA;   au TextYankPost * if v:event.regname is# '+'&#xA;       \ | call system('echo ' . shellescape(@+) . ' | xclip -selection clipboard')&#xA;       \ | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It requires the &lt;code&gt;$ xclip&lt;/code&gt; shell utility.&#xA;The autocmd is called whenever some text is yanked to invoke &lt;code&gt;$ xclip&lt;/code&gt; and make it write the text in the clipboard selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One issue with the current code is that it adds a trailing newline at the end of the yanked text.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior of st seems normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was confused by the behavior of urxvt which allows you to paste the text yanked in the &lt;code&gt;+&lt;/code&gt; register, back into a urxvt terminal, even after quitting Vim.&#xA;But it requires some custom configuration; i.e. these lines in &lt;code&gt;~/.Xresources&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;URxvt.perl-ext-common: selection-to-clipboard,pasta&#xA;URxvt.keysym.Control-Shift-V: perl:pasta:paste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;a href=&quot;https://wiki.gentoo.org/wiki/Rxvt-unicode#Copy.2FPaste_and_URL_handling&quot; rel=&quot;nofollow noreferrer&quot;&gt;this &lt;code&gt;pasta&lt;/code&gt; perl script&lt;/a&gt; in &lt;code&gt;~/.urxvt/ext&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#! /usr/bin/env perl -w&#xA;# Usage: put the following lines in your .Xdefaults/.Xresources:&#xA;# URxvt.perl-ext-common           : selection-to-clipboard,pasta&#xA;# URxvt.keysym.Control-Shift-V    : perl:pasta:paste&#xA;&#xA;use strict;&#xA;&#xA;sub on_user_command {&#xA;  my ($self, $cmd) = @_;&#xA;  if ($cmd eq &quot;pasta:paste&quot;) {&#xA;    $self-&amp;gt;selection_request (urxvt::CurrentTime, 3);&#xA;  }&#xA;  ()&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-04-24T12:15:18.163" LastActivityDate="2019-04-26T09:38:29.200" Title="How to paste the clipboard selection when it was populated with a yank in Vim started from the st terminal?" Tags="|cut-copy-paste|st|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19726" PostTypeId="2" ParentId="19725" CreationDate="2019-04-24T10:24:51.270" Score="6" Body="&lt;p&gt;That is not how the clipboard works in Unix land. Basically when the clipboard content is requested, it means a client requests from the X-Server the selection of the clipboard from whoever owns it. The X Server will then relay this request to the other X client, that owns the clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, obviously, this does not work, if you quit the X client, that initially owns the selection (in this case Vim). So once the original client did quit, the selection is usually lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A work-around is, to use a so called clipboard manager that comes with the big desktop environments like klipper, or parcellite or gnomes clipboard manager. What they do is, whenever they notice that the owner of the clipboard changes, take ownership of the selection and pretend to be the actual new owner (at least, if i remember correctly).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-04-24T10:24:51.270" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19727" PostTypeId="1" AcceptedAnswerId="19728" CreationDate="2019-04-24T14:53:49.270" Score="1" ViewCount="288" Body="&lt;p&gt;If I have a file that contains&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this_is_the_first_underscore_phrase&#xA;this_is_the_first_underscore_phrase&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I search for &quot;first&quot; &lt;code&gt;/first&lt;/code&gt; and my cursor is placed onto the start of the word &quot;first&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can change this word by doing &lt;code&gt;ct_&lt;/code&gt; but I wonder if there's a different way, is there a way to &quot;change inside currently highlighted text&quot; ?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2019-04-25T00:41:06.517" Title="text object for highlighted text" Tags="|cursor-motions|object-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19728" PostTypeId="2" ParentId="19727" CreationDate="2019-04-24T14:56:52.220" Score="7" Body="&lt;p&gt;You can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gnc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gn&lt;/code&gt; will do a visual selection of the search result, then &lt;code&gt;c&lt;/code&gt; is, as you know, &lt;code&gt;change&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;code&gt;cgn&lt;/code&gt; works (change the next occurence of the search result). &lt;/p&gt;&#xA;" OwnerUserId="21621" LastEditorUserId="10604" LastEditDate="2019-04-25T00:41:06.517" LastActivityDate="2019-04-25T00:41:06.517" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19729" PostTypeId="2" ParentId="19656" CreationDate="2019-04-24T15:09:03.253" Score="3" Body="&lt;p&gt;@D.BenKnoble has already given you a terrific answer explaining all the ins and outs of batch mode, but in case you were looking for a one liner similar to the one you already tried, here's one that I think is a bit simpler than the existing ones in the current answers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc 'norm!ggy$dd' -c '%norm!i^R0: ' -c 'x' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first &lt;code&gt;:normal&lt;/code&gt; command moves to the start of the file &lt;code&gt;gg&lt;/code&gt;, yanks the contents of the line &lt;code&gt;y$&lt;/code&gt;, and then deletes the line itself &lt;code&gt;dd&lt;/code&gt;. We yank before deleting because we don't want the newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We run the second &lt;code&gt;:normal&lt;/code&gt; command on every line by means of a &lt;code&gt;%&lt;/code&gt; range, inserting the contents of the yank register &lt;code&gt;&quot;0&lt;/code&gt;&amp;mdash;i.e. the original first line&amp;mdash;followed by the required colon and space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. The slight technicality here is that the &lt;code&gt;^R&lt;/code&gt; you see in the middle of the command is actually a literal &lt;code&gt;CTRL-R&lt;/code&gt; character&amp;mdash;which you can probably enter in your shell by typing &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Ctrl-R&lt;/kbd&gt;: you cannot copy/paste the whole command from this answer. For a copy-pastable version, we need to add the character using a string literal and then execute it:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc 'norm!ggy$dd' -c 'exe &quot;%norm!i\&amp;lt;C-R&amp;gt;0: &quot;' -c 'x' file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The third simply saves the file and quits Vim, as in the command you already tried.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Extra credit&lt;/strong&gt;: Finally, here's a version that replaces a little complexity in the first ex command with a bunch in the second:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc '1d a' -c '%norm!i^Ra^[kJi:' -c 'x' file&#xA;                         ^^ ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This time we have two literal control characters: a &lt;code&gt;CTRL-R&lt;/code&gt; and an &lt;code&gt;ESC&lt;/code&gt; (denoted by &lt;code&gt;^[&lt;/code&gt;, entered via &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;), which we use to remove the newline included when we used the ex &lt;code&gt;:delete&lt;/code&gt; command to delete the entire line into register &lt;code&gt;&quot;a&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-04-24T15:34:12.137" LastActivityDate="2019-04-24T15:34:12.137" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19730" PostTypeId="1" CreationDate="2019-04-24T15:29:47.160" Score="5" ViewCount="921" Body="&lt;p&gt;After saving a file in Vim, I get the message at the bottom of the screen &lt;code&gt;&quot;fileName&quot; 92L, 3554C written&lt;/code&gt;. Is there a way to show the time in this message?&lt;/p&gt;&#xA;" OwnerUserId="21942" LastActivityDate="2019-04-24T16:40:12.803" Title="Show time after saving a file" Tags="|save|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19731" PostTypeId="2" ParentId="19730" CreationDate="2019-04-24T16:11:04.793" Score="4" Body="&lt;p&gt;I don't think you can change the string by itself but you can use an autocommand to echo the date:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup SAVING&#xA;    autocmd!&#xA;    autocmd BufWritePost * echo strftime('%c')&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On my machine it shows something like that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ATQ78.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ATQ78.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An autocommand allows you to execute a command when a given event happens. Here we use the event &lt;code&gt;BufWritePost&lt;/code&gt; which is triggered when a buffer is written to a file. The command we use is &lt;code&gt;echo strftime()&lt;/code&gt; which echos the result of &lt;code&gt;strftime()&lt;/code&gt; which returns a formatted date and time, you can check the doc to change the formatting if needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#%3Aaugroup&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :augroup&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/autocmd.txt.html#BufWritePost&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h BufWritePost&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#strftime%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h strftime()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-04-24T16:11:04.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19732" PostTypeId="1" CreationDate="2019-04-24T16:19:28.707" Score="1" ViewCount="196" Body="&lt;p&gt;I am currently using gvim. I want to know is it possible to install a vim plugin offline?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the project files already downloaded from github, and I want to put them in the right locations for vim to source them.&lt;/p&gt;&#xA;" OwnerUserId="21943" LastEditorUserId="21943" LastEditDate="2019-04-25T00:28:58.600" LastActivityDate="2019-04-25T00:28:58.600" Title="How can I Install vim plugin offline?" Tags="|gvim|plugin-system|" AnswerCount="0" CommentCount="2" ClosedDate="2019-04-24T19:37:10.727" ContentLicense="CC BY-SA 4.0" />
  <row Id="19733" PostTypeId="2" ParentId="19730" CreationDate="2019-04-24T16:40:12.803" Score="4" Body="&lt;p&gt;Different approach: I have the save time as part of my statusline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%f               &quot; filename relative to current $PWD&#xA;set statusline+=%h              &quot; help file flag&#xA;set statusline+=%m              &quot; modified flag&#xA;set statusline+=%r              &quot; readonly flag&#xA;set statusline+=\ [%{&amp;amp;ff}]      &quot; Fileformat [unix]/[dos] etc...&#xA;set statusline+=\ (%{strftime(\&quot;%Y-%m-%d\ %H:%M\&quot;,getftime(expand(\&quot;%:p\&quot;)))})  &quot; last modified timestamp&#xA;set statusline+=%=              &quot; Rest: right align&#xA;set statusline+=%l,%c%V         &quot; Position in buffer: linenumber, column, virtual column&#xA;set statusline+=\ %P            &quot; Position in buffer: Percentage&#xA;&#xA;set laststatus=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To be honest I once copied that from somewhere (maybe stackoverflow) and it stayed in my &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The option &lt;code&gt;laststatus=2&lt;/code&gt; always displays the statusline.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-04-24T16:40:12.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19735" PostTypeId="1" AcceptedAnswerId="19737" CreationDate="2019-04-25T08:38:09.373" Score="1" ViewCount="151" Body="&lt;p&gt;I move around using the arrows ←↓↑→, never really got used to the hjkl thing. I know I'm supposed to use the hjkl thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When hitting ↓, it reaches a point where the caret is on the lower side of the display, until I hit some ↑ hits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the time I need more context down. How do you move the doc down while not moving the caret?&lt;/p&gt;&#xA;" OwnerUserId="13260" LastActivityDate="2020-09-28T11:17:54.217" Title="moving through the doc, caret staying centered" Tags="|navigation|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19736" PostTypeId="1" AcceptedAnswerId="19739" CreationDate="2019-04-25T08:42:06.667" Score="0" ViewCount="327" Body="&lt;p&gt;This is my &lt;code&gt;statusline&lt;/code&gt; setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set laststatus=2&#xA;:set statusline=%{GetMode()}\ %n\ %#StatusLineY#%m%*\%#StatusLineR#%r%*\ %t\ [%o\ %l\,%c\ %p%%\]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this is the GetMode() functiom&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetMode()&#xA;    let ms=mode()&#xA;    if ms == 'n'&#xA;        return 'NORMAL '&#xA;    elseif ms == 'i'&#xA;        return 'INSERT '&#xA;    elseif ms == 'v' || ms == 'V' &#xA;        return 'VISUAL '&#xA;    elseif ms == 's' || ms == 'S'&#xA;        return 'SELECT '&#xA;    elseif ms == 'R' ||  ms == 'Rv'&#xA;        return 'REPLACE'&#xA;    elseif ms == '!' &#xA;        return 'SHELL  '&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This setting works well and now I would like to have different colors for the stringsreturned by &lt;code&gt;GetMode()&lt;/code&gt; function (and not the whole statusline).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT2&lt;/strong&gt;&#xA;So for example blue foreground color for 'NORMAL', yellow for 'INSERT' etc.&#xA;Is it possible to achieve this ? If so, how ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT1&lt;/strong&gt;&#xA;According to comments given below, I tried to add the &lt;code&gt;autogroup statusline&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup statusline&#xA;autocmd!&#xA;autocmd VimEnter,ColorScheme * hi User1 guibg=#0a0a0a guifg=#0000ff&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and applying this small change to &lt;code&gt;GetMode&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let ms=mode()&#xA;if ms == 'n'&#xA;   return %1*NORMAL\ %*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this generates an &lt;strong&gt;E15 INvalid expression&lt;/strong&gt; error.&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="15254" LastEditDate="2019-04-25T09:37:46.367" LastActivityDate="2019-04-25T10:44:47.460" Title="Custom string colors in statusline" Tags="|statusline|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19737" PostTypeId="2" ParentId="19735" CreationDate="2019-04-25T09:11:11.570" Score="6" Body="&lt;p&gt;You're looking for &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27scrolloff%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'scrolloff'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'scrolloff' 'so'    number  (default 0)&#xA;            global&#xA;    Minimal number of screen lines to keep above and below the cursor.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can add something like this in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set scrolloff=10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-04-25T15:06:51.003" LastActivityDate="2019-04-25T15:06:51.003" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19738" PostTypeId="1" AcceptedAnswerId="19743" CreationDate="2019-04-25T09:48:22.320" Score="6" ViewCount="9854" Body="&lt;p&gt;I use &lt;a href=&quot;https://github.com/ludovicchabant/vim-gutentags&quot; rel=&quot;nofollow noreferrer&quot;&gt;gutentags&lt;/a&gt; and &lt;a href=&quot;https://github.com/skywind3000/gutentags_plus&quot; rel=&quot;nofollow noreferrer&quot;&gt;gutentags-plus&lt;/a&gt; for generating and managing tag files. When I use the key combinations setup by them ( cX usually ), it opens the relevant lines in a quickfix window and I can use :cnext etc for navigation. But how do I close them quickfix window and go back to the file I was editing after I have gone through the lines found in cscope?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: Actually I am using &lt;a href=&quot;https://www.gnu.org/software/global/global.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;global&lt;/a&gt; instead of cscope but I guess on VIM side it should not matter.&lt;/p&gt;&#xA;" OwnerUserId="21955" LastEditorUserId="10604" LastEditDate="2020-06-22T14:37:07.330" LastActivityDate="2020-06-23T08:40:33.077" Title="How can I close the quickfix window and go back to the file I was editing" Tags="|quickfix|tags|cscope|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19739" PostTypeId="2" ParentId="19736" CreationDate="2019-04-25T10:44:47.460" Score="0" Body="&lt;p&gt;OK so I post here my own solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ColorUser1ToGreen()&#xA;        hi User1 guifg=#00ff00 guibg=#0a0a0a gui=bold&#xA;endfunction&#xA;&#xA;function! ColorUser1ToLightBlue()&#xA;        hi User1 guifg=#9494ff  guibg=#0a0a0a gui=bold&#xA;endfunction&#xA;&#xA;function! ColorUser1ToYellow()&#xA;        hi User1 guifg=#ffff00 guibg=#0a0a0a gui=bold&#xA;endfunction&#xA;&#xA;function! ColorUser1ToOrange()&#xA;        hi User1 guifg=#ffa239 guibg=#0a0a0a gui=bold&#xA;endfunction&#xA;&#xA;function! ColorUser1ToPurple()&#xA;        hi User1 guifg=#a683ff guibg=#0a0a0a gui=bold&#xA;endfunction&#xA;&#xA;function! GetStatusLineMode()&#xA;    let ms=mode()&#xA;    if ms == 'n'&#xA;        call ColorUser1ToLightBlue()&#xA;        return 'NORMAL  '&#xA;    elseif ms == 'i'&#xA;        call ColorUser1ToYellow()&#xA;        return 'INSERT  '&#xA;    elseif ms == 'v' || ms == 'V' &#xA;        call ColorUser1ToOrange()&#xA;        return 'VISUAL  '&#xA;    elseif ms == 's' || ms == 'S'&#xA;        call ColorUser1ToOrange()&#xA;        return 'SELECT  '&#xA;    elseif ms == 'R' ||  ms == 'Rv'&#xA;        call ColorUser1ToPurple()&#xA;        return 'REPLACE '&#xA;    elseif ms == '!'&#xA;        call ColorUser1ToPurple()&#xA;        return 'SHELL   '&#xA;    else&#xA;        call ColorUser1ToGreen()&#xA;    endif&#xA;&#xA;endfunction&#xA;&#xA;:set laststatus=2&#xA;:set statusline=%1*%{GetStatusLineMode()}%*\ %n\ %#StatusLineY#%m%*\%#StatusLineR#%r%*\ %t\ [%o\ %l/%L(%p%%)\ %c\ \]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Perhaps there are better solutions, but this fit my preferences.&lt;/p&gt;&#xA;" OwnerUserId="15254" LastActivityDate="2019-04-25T10:44:47.460" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19740" PostTypeId="1" CreationDate="2019-04-25T10:53:45.180" Score="0" ViewCount="263" Body="&lt;p&gt;I found this snippet online which is apparently a way to make vim a little faster if your terminal background is the same as what vim's is meant to be (right?)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; General colors&#xA;if has('gui_running') || has('nvim')&#xA;  hi Normal             guifg=#a89984 guibg=#282828&#xA;else&#xA;  &quot; Set the terminal default background and foreground colors, thereby&#xA;  &quot; improving performance by not needing to set these colors on empty cells.&#xA;  hi Normal guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE&#xA;  let &amp;amp;t_ti = &amp;amp;t_ti . &quot;\033]10;#a89984\007\033]11;#282828\007&quot;&#xA;  let &amp;amp;t_te = &amp;amp;t_te . &quot;\033]110\007\033]111\007&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What are &lt;code&gt;t_ti&lt;/code&gt; and &lt;code&gt;t_te&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked up &lt;code&gt;:help t_te&lt;/code&gt; and found out that these &lt;code&gt;t_ti&lt;/code&gt; and &lt;code&gt;t_te&lt;/code&gt; &quot;put terminal in termcap mode&quot;, looking up &lt;code&gt;:help termcap&lt;/code&gt; didn't help me (I don't really understand what it is/means). Also looking up &lt;code&gt;:help &amp;amp;&lt;/code&gt; didn't help me understand why &lt;code&gt;t_ti&lt;/code&gt; etc. have had &lt;code&gt;&amp;amp;&lt;/code&gt; prepended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought this kind of stuff &lt;code&gt;\033]...&lt;/code&gt; were escape codes so I also did &lt;code&gt;:helpgrep escape code&lt;/code&gt; but didn't find anything useful. Probably they're a part of the terminal/shell so not in vim's help, but then I don't know how to try to find out more about them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is someone able to explain what exactly the snippet is doing/how it does it?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2019-04-25T11:17:06.437" Title="what does &quot;\033]110\007\033]111\007&quot; mean" Tags="|terminal|colorscheme|shell|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19741" PostTypeId="2" ParentId="19740" CreationDate="2019-04-25T11:17:06.437" Score="3" Body="&lt;p&gt;&lt;code&gt;t_ti&lt;/code&gt; and &lt;code&gt;t_te&lt;/code&gt; are used by Vim (in the terminal) to switch between the different screens. The whole detail of this is described at &lt;a href=&quot;https://vimhelp.org/tips.txt.html#xterm-screens&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h xterm-screens&lt;/a&gt; and those are xterm terminal control sequences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The usual effect of this is, that after you quit vim in the terminal, you do not see your old vim screen anymore, but the last commands you issued before starting vim (because the screens have been switched).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure, what your snippet is doing, it looks like it is requesting to set some foreground and background colors, using &lt;code&gt;#rgb&lt;/code&gt; format. This is not supported by all terminals (and I think xterm does not yet completely support that according to this &lt;a href=&quot;https://gist.github.com/XVilka/8346728&quot; rel=&quot;nofollow noreferrer&quot;&gt;gist&lt;/a&gt;). So this might or not might work, depending on the terminal you are using. The full details of the terminal escape sequences can be read at Thomas Dickeys website: &lt;a href=&quot;https://invisible-island.net/xterm/ctlseqs/ctlseqs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://invisible-island.net/xterm/ctlseqs/ctlseqs.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neovim does not support setting terminal capabilities that way and in the gui it doesn't make any sense. Therefore it makes sense to distinguish them as you did in your snippet.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-04-25T11:17:06.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19742" PostTypeId="2" ParentId="16509" CreationDate="2019-04-25T13:12:58.423" Score="1" Body="&lt;p&gt;I've personally found &lt;a href=&quot;https://github.com/thinca/vim-ambicmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/thinca/vim-ambicmd&lt;/a&gt; to be fairly useful for long commands.&lt;/p&gt;&#xA;" OwnerUserId="2152" LastActivityDate="2019-04-25T13:12:58.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19743" PostTypeId="2" ParentId="19738" CreationDate="2019-04-25T13:28:59.907" Score="10" Body="&lt;p&gt;To close the quickfix window, you use &lt;code&gt;:cclose&lt;/code&gt;, as @statox mentioned in the comments.&lt;/p&gt;&#xA;&lt;p&gt;This won't affect which code buffer you're viewing, though. Vim doesn't distinguish between the buffer you were looking at originally and the buffers you navigated to via the quickfix, so to go back you are going to have to use Vim's regular buffer switching commands. If you know the name or number of the original buffer, &lt;code&gt;:b&lt;/code&gt; is probably quickest.&lt;/p&gt;&#xA;&lt;p&gt;If not, you could try mashing &lt;kbd&gt;Ctrl-O&lt;/kbd&gt; to jump backwards through the jumplist till you reach the right buffer, or you might want to set up &lt;a href=&quot;https://stackoverflow.com/a/16084326/328936&quot;&gt;some mappings&lt;/a&gt;* (or a plugin) for faster buffer navigation.&lt;/p&gt;&#xA;&lt;p&gt;If you want something automated, how about adding something like following to your .vimrc?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gs mA:GscopeFind s &amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;b :cclose&amp;lt;CR&amp;gt;`A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The first mapping adapts your &lt;a href=&quot;https://vi.stackexchange.com/a/19754/343&quot;&gt;current search mapping&lt;/a&gt; to first set an uppercase mark A and then continue with its original behaviour.&lt;/p&gt;&#xA;&lt;p&gt;The second creates a new mapping that closes the quickfix and then returns to the marked position.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt;* Make sure you read as far down as the EDIT, because it's after that that the juicy details are included.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-06-23T08:40:33.077" LastActivityDate="2020-06-23T08:40:33.077" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="19744" PostTypeId="1" CreationDate="2019-04-25T15:11:06.013" Score="2" ViewCount="1149" Body="&lt;p&gt;I was using &lt;code&gt;vim scp://&lt;/code&gt; and &lt;code&gt;e scp://&lt;/code&gt; to edit remotes files. Sometimes I failed to open and got message &lt;code&gt;--No lines in buffer--&lt;/code&gt;. What does mean and how I should solve?&lt;/p&gt;&#xA;" OwnerUserId="21961" LastActivityDate="2019-04-25T15:11:06.013" Title="What does &quot;No lines in buffer&quot; mean when editing via scp?" Tags="|netrw|ssh|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19745" PostTypeId="1" AcceptedAnswerId="19746" CreationDate="2019-04-25T17:29:15.013" Score="25" ViewCount="5092" Body="&lt;p&gt;I'm a bit puzzeled as to why the underscore command &lt;code&gt;_&lt;/code&gt;, which jumps to&#xA;the beginning of the (COUNT - 1)th line below the cursor, gets its own&#xA;key.  When would I use this rather than &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;^&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2019-04-25T17:54:33.597" LastActivityDate="2024-03-20T12:10:42.823" Title="Why is the underscore command _ useful?" Tags="|cursor-motions|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19746" PostTypeId="2" ParentId="19745" CreationDate="2019-04-25T17:55:41.410" Score="24" Body="&lt;p&gt;Good question!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a motion by itself, you're right, &lt;code&gt;_&lt;/code&gt; is not a particularly useful key. &lt;code&gt;:h _&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *_*&#xA;_  &amp;lt;underscore&amp;gt;     [count] - 1 lines downward, on the first non-blank&#xA;            character |linewise|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key word here is &quot;linewise&quot;. So if your goal is to just move the cursor, then &lt;code&gt;^&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, and &lt;code&gt;+&lt;/code&gt; all get the job done, and there's not much point to &lt;code&gt;_&lt;/code&gt;. But as an argument to an operator, &lt;code&gt;_&lt;/code&gt; is super powerful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A lot of double-key shortcuts are actually just shortcuts for &lt;code&gt;_&lt;/code&gt;. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dd -&amp;gt; d_&#xA;cc -&amp;gt; c_&#xA;yy -&amp;gt; y_&#xA;Y  -&amp;gt; y_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc. Because it's a linewise motion, it basically selects the entire line to be operated on regardless of where your cursor starts, whereas &lt;code&gt;^&lt;/code&gt; just goes from your character to the first non-blank. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It helps me when thinking about linewise vs blockwise motions to imagine that I'm pressing either &lt;code&gt;v&lt;/code&gt; or &lt;code&gt;V&lt;/code&gt; right before the motion. So I imagine &lt;code&gt;d^&lt;/code&gt; to be equivalent to &lt;code&gt;v^d&lt;/code&gt; and I imagine &lt;code&gt;d_&lt;/code&gt; to be equivalent to &lt;code&gt;V_d&lt;/code&gt; or &lt;code&gt;V^d&lt;/code&gt;. Of course, you can also override a motion to force it to be linewise or characterwise. So &lt;code&gt;dv_&lt;/code&gt; is actually exactly the same as &lt;code&gt;d^&lt;/code&gt; or &lt;code&gt;v^d&lt;/code&gt;, and &lt;code&gt;dVw&lt;/code&gt; is like &lt;code&gt;Vwd&lt;/code&gt; which is exactly like &lt;code&gt;d_&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason it is specifically the &quot;count-1th&quot; line is so that &lt;code&gt;1dd&lt;/code&gt; (which is really &lt;code&gt;d1_&lt;/code&gt;) deletes one entire line, &lt;code&gt;2dd&lt;/code&gt; (which is really &lt;code&gt;d2_&lt;/code&gt;) deletes 2 entire lines, &lt;code&gt;3dd&lt;/code&gt; deletes 3 entire lines, etc.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-04-25T17:55:41.410" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19747" PostTypeId="2" ParentId="19711" CreationDate="2019-04-25T22:14:56.580" Score="1" Body="&lt;p&gt;Prerequisites are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use Vim built with multi-byte support&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;set encoding=utf-8&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;set guifont=&amp;lt;font that includes the combining chars of interest&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can test by putting the cursor after a character while in Insert mode and typing &lt;kbd&gt;&amp;#9096; Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; then &lt;kbd&gt;U&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;D&lt;/kbd&gt;&lt;kbd&gt;7&lt;/kbd&gt; (for example). Vim will draw the combining character above the preceding character. (Note though that it doesn't always look pretty, in my experience.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also &lt;code&gt;:h mbyte-combining&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since it sounds like your first hurdle is finding a font with the correct character set I can at least name one that I have that does have them. It's from the set of fonts patched for use with the Powerline tool set: &lt;a href=&quot;https://github.com/powerline/fonts/tree/master/DejaVuSansMono&quot; rel=&quot;nofollow noreferrer&quot;&gt;DejaVu Sans Mono for Powerline&lt;/a&gt;. I'm sure some of the other Powerline fonts are similarly equipped. Go to the parent directory of that link to see them all.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-04-25T22:14:56.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19748" PostTypeId="1" AcceptedAnswerId="21673" CreationDate="2019-04-26T01:30:33.823" Score="1" ViewCount="546" Body="&lt;p&gt;Inspired by &lt;a href=&quot;https://stackoverflow.com/a/42118416&quot;&gt;this answer&lt;/a&gt;, I have the following in my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup cursor&#xA;    au!&#xA;    autocmd VimEnter * silent !echo -ne &quot;\e[1 q&quot;&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this sometimes prints the following on startup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[[2;2R^[[&amp;gt;65;5402;1c^[]10;rgb:b2b2/b2b2/b2b2^[\^[]11;rgb:0000/0000/0000^[\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is causing this? The work around I came up with was to add &lt;code&gt;autocmd VimEnter * redraw!&lt;/code&gt;, but I would like to know the root cause and if there is a better way to fix this.&lt;/p&gt;&#xA;" OwnerDisplayName="user20228" LastActivityDate="2019-10-26T12:14:24.267" Title="VimEnter autocmd to change cursor shape sometimes outputs escape sequences" Tags="|terminal|autocmd|cursor|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19750" PostTypeId="1" CreationDate="2019-04-26T06:36:51.223" Score="2" ViewCount="297" Body="&lt;p&gt;I want to change 3rd byte of a string to &lt;code&gt;x&lt;/code&gt;, i'm currently using this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s = s[:1] . 'x' . s[3:]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's a bit awkward, i wish i can do &lt;code&gt;let s[2] = 'x'&lt;/code&gt;, but that's not allowed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any other built-in ways to do it nicely?&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-26T07:37:15.950" LastActivityDate="2020-01-29T16:02:10.570" Title="How to change string at specific byte index nicely?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19751" PostTypeId="1" CreationDate="2019-04-26T08:14:10.773" Score="2" ViewCount="2633" Body="&lt;p&gt;I am given an account on a new server these days. The new server does not have x11 install, neither do I have sudo. So I cannot install system packages, and I cannot compile with the option &lt;code&gt;-with-x&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I still want to use vim when I am working on my server, and I need to use the clipboard feature to allow me to copy the contents from and to the vim and other places. How could I do this pleaes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;=====&#xA;Edit: &#xA;I got to find that the clipboard provided by the terminal can help. I could paste contents to vim with &lt;code&gt;ctrl&lt;/code&gt;+&lt;code&gt;shift&lt;/code&gt;+&lt;code&gt;v&lt;/code&gt;. But the hot key of &lt;code&gt;ctrl&lt;/code&gt;+&lt;code&gt;shift&lt;/code&gt;+'c' does not work in the vim. how could I copy from vim like I copy from terminal?&lt;/p&gt;&#xA;" OwnerUserId="18259" LastEditorUserId="54" LastEditDate="2022-11-12T11:40:26.760" LastActivityDate="2022-11-19T13:16:33.280" Title="How could I enable vim clipboard without sudo and x11 installed?" Tags="|vimrc|os-clipboard|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19753" PostTypeId="1" AcceptedAnswerId="19756" CreationDate="2019-04-26T10:17:37.623" Score="1" ViewCount="3858" Body="&lt;p&gt;I want to search lines beginning with certain string in Vim, and then add something at the end of file. I have tried the following but it removed everything instead of appending&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^12138/*something_at_end_of_file/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This search all lines which begin with &lt;code&gt;12138&lt;/code&gt; but it removes everything and add &lt;code&gt;something_at_end_of_file&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I want to preserve actually string and add at end of line.&lt;/p&gt;&#xA;" OwnerUserId="21179" LastEditorUserId="1841" LastEditDate="2019-04-26T11:50:13.420" LastActivityDate="2019-04-26T18:24:27.497" Title="How to search in beginning of line and add something at end of that line" Tags="|search|replace|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19754" PostTypeId="2" ParentId="19738" CreationDate="2019-04-26T10:22:38.807" Score="0" Body="&lt;p&gt;@klaus makes the correct suggestion to set a mark. However I needed to set it before the quick fix window appeared not while traversing the list. I am using &lt;a href=&quot;https://github.com/skywind3000/gutentags_plus&quot; rel=&quot;nofollow noreferrer&quot;&gt;gutentags_plus&lt;/a&gt; plugin to make cscope work with guten-tags plugin. So I just redefined Gscopefind command mappings from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gs :GscopeFind s &amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gs mA :GscopeFind s &amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21955" LastActivityDate="2019-04-26T10:22:38.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19755" PostTypeId="2" ParentId="19753" CreationDate="2019-04-26T10:32:31.923" Score="3" Body="&lt;p&gt;You may try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v^(12138.*)/\1something_at_end_of_line/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That means:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%s&lt;/code&gt; substitute on all lines&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/\v&lt;/code&gt;  starts search pattern and uses very-magic mode, saves you from the need to escape everything (see &lt;code&gt;:help \v&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^(12138.*)&lt;/code&gt; starting from the beginning of the line, find all text that starts with &lt;code&gt;12138&lt;/code&gt; and is followed by anything else (&lt;code&gt;.*&lt;/code&gt;) and put it into a &lt;em&gt;group&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/\1something_at_end_of_line/g&lt;/code&gt; replace the found patterns with the first &lt;em&gt;group&lt;/em&gt; content and then add your text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-04-26T10:32:31.923" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19756" PostTypeId="2" ParentId="19753" CreationDate="2019-04-26T10:58:55.157" Score="5" Body="&lt;p&gt;use the &lt;code&gt;:g&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^12138/s/something-at-the-end$/something-new-at-the-end/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More information on &lt;code&gt;:help :g&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-04-26T10:58:55.157" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19757" PostTypeId="2" ParentId="19661" CreationDate="2019-04-26T11:14:05.253" Score="1" Body="&lt;p&gt;It looks like there are actually several questions to be answered here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1.  Is there a way to set a color for a string in the statusline?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes there is. As the help for &lt;a href=&quot;https://vimhelp.org/options.txt.html#&amp;#39;statusline&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;the statusline&lt;/a&gt; states, you can inject highlighting groups into the statusline by either using &lt;code&gt;%#&amp;lt;NAME&amp;gt;#&lt;/code&gt; to start using the highlighting group &lt;code&gt;&amp;lt;NAME&amp;gt;&lt;/code&gt; or use &lt;code&gt;%1*&lt;/code&gt;, to start using highlighting group &lt;code&gt;User1&lt;/code&gt;. Use the numbers 1-9 to select the corresponding highlighting group &lt;code&gt;User1-User9&lt;/code&gt;. Restore the highlighting group by using &lt;code&gt;%*&lt;/code&gt;. Restoring in this case means, to use again the &lt;code&gt;StatusLine&lt;/code&gt; (or &lt;code&gt;StatusLineNC&lt;/code&gt; for non-active windows) highlighting group. (This part is important, I'll come back to this in a bit.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this only works, if the actual highlighting group does exists. So you have to define the group like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi MyRedHighlightingGroup ctermfg=red ctermbg=black guifg=red guibg=black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Simply throwing magical color names into the statusline like your &lt;code&gt;orange&lt;/code&gt; won't make it work. I guess you must have defined the &lt;code&gt;orange&lt;/code&gt; highlighting group somewhere. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. How to use airline and customize the different sections&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In contrast to what was assumed in the comments, there is no magic going on here. But let me explain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you have already noticed, it is pretty easy to customize the airline sections, by simply putting the definitions into the &lt;code&gt;global&lt;/code&gt; variable &lt;code&gt;g:airline_section_X&lt;/code&gt;. (Use a window local variable to have this applied only to a particular window):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_section_c='%t %#orange#@%{virtualenv#statusline()}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this will display the Filename, and start highlighting in orange (provided the highlighting group does actually exists) the output of the function &lt;code&gt;virtualenv#statusline()&lt;/code&gt; until the  next section.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now airline makes heavy use of customized highlighting groups, as you can tell, if you look at the output of &lt;code&gt;:hi&lt;/code&gt; because you'll notice many, many airline groups that all start with &lt;code&gt;airline_xxx&lt;/code&gt;. Basically each section has its own highlighting group, plus groups that will be injected before the next section starts (the &lt;code&gt;airline_x_to_airline_y&lt;/code&gt; groups), so that the powerline symbols look nice and show a fancy transition between each section.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you want to reset the highlighting group to the one that was previously used, you &lt;strong&gt;must not&lt;/strong&gt; used &lt;code&gt;%*&lt;/code&gt;, as this will switch the highlighting group to be used to &lt;code&gt;StatusLine&lt;/code&gt; (or &lt;code&gt;StatusLineNC&lt;/code&gt; for non-active windows), since this highlighting group is not used at all for an airline managed statusline. Instead, you probably want to reset to the actual used highlighting group (which for the mentioned &lt;code&gt;section c&lt;/code&gt; is &lt;code&gt;airline_c&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_section_c='%t %#orange#@%{virtualenv#statusline()}%#airline_c#'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As this will correctly switch back to the highlighting group used in section c. Note, that when the window becomes inactive, airline will automatically try to use the corresponding highlighting group &lt;code&gt;orange_inactive&lt;/code&gt;, so that needs to be defined as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note, that section c for airline is actually a bit different here for inactive windows. Because in order to distinguish inactive sections containing different buffers, airline will automatically append the buffer number to the &lt;code&gt;c&lt;/code&gt;, else it could not use different inactive highlighting groups. So this might be an additional complexity for section &lt;code&gt;c&lt;/code&gt;. Might be easier to use one of the other pre-defined sections. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3. Some tips on debugging airline&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, you can always examine the result of the defined statusline using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo airline#statusline(&amp;lt;winnr&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;&amp;lt;winnr&amp;gt;&lt;/code&gt; is the window number. A bit simpler even is to use &lt;code&gt;:echo eval(&amp;amp;statusline[2:])&lt;/code&gt;, to see the resulting statusline option for the current window. In a similar way, you can always see the result of the tabline using &lt;code&gt;:echo eval(&amp;amp;tabline[2:])&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(On a related note: this also means, that if the statusline wraps, or some characters are not correctly aligned, that this almost always means it is either a font incompatibility or a Vim bug or a problem between different used unicode libraries between Vim and the terminal. Airline cannot influence it, since in the end it is merely setting the statusline option).&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-04-26T11:39:51.587" LastActivityDate="2019-04-26T11:39:51.587" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19758" PostTypeId="2" ParentId="19735" CreationDate="2019-04-26T14:08:31.080" Score="4" Body="&lt;p&gt;You can also use &lt;code&gt;CTRL-e&lt;/code&gt; and &lt;code&gt;CTRL-y&lt;/code&gt; to move the view, while not moving the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the end of your file, you can use &lt;code&gt;CTRL-e&lt;/code&gt; until the last line of the document is at the first line of the page.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-04-26T14:08:31.080" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19759" PostTypeId="2" ParentId="19705" CreationDate="2019-04-26T14:13:07.680" Score="2" Body="&lt;p&gt;As @statox mentioned, you can use &lt;code&gt;CTRL-z&lt;/code&gt;. If you want to spawn a new shell from vim, as &lt;code&gt;:shell&lt;/code&gt; does, you can do: &lt;code&gt;:!sh&lt;/code&gt;, &lt;code&gt;:!bash&lt;/code&gt;, &lt;code&gt;:!zsh&lt;/code&gt; (pick your favourite), which has pretty much the same effect as &lt;code&gt;:shell&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastEditorUserId="21621" LastEditDate="2019-04-29T07:49:47.027" LastActivityDate="2019-04-29T07:49:47.027" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19760" PostTypeId="2" ParentId="19639" CreationDate="2019-04-26T15:00:59.773" Score="5" Body="&lt;p&gt;In your Vim config, you can do the following (change the colors and styling to your liking):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ConflictsHighlight() abort&#xA;    syn region conflictStart start=/^&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; .*$/ end=/^\ze\(=======$\||||||||\)/&#xA;    syn region conflictMiddle start=/^||||||| .*$/ end=/^\ze=======$/&#xA;    syn region conflictEnd start=/^\(=======$\||||||| |\)/ end=/^&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; .*$/&#xA;&#xA;    highlight conflictStart ctermbg=red ctermfg=black&#xA;    highlight conflictMiddle ctermbg=blue ctermfg=black&#xA;    highlight conflictEnd ctermbg=green cterm=bold ctermfg=black&#xA;endfunction&#xA;&#xA;augroup MyColors&#xA;    autocmd!&#xA;    autocmd BufEnter * call ConflictsHighlight()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which renders as follow:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZuxdK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZuxdK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it what you are after?&lt;/p&gt;&#xA;" OwnerUserId="21621" LastEditorUserId="21621" LastEditDate="2019-04-26T18:30:46.097" LastActivityDate="2019-04-26T18:30:46.097" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19761" PostTypeId="2" ParentId="19753" CreationDate="2019-04-26T18:24:27.497" Score="2" Body="&lt;p&gt;Another similar alternative: use &lt;code&gt;:normal&lt;/code&gt; and &lt;code&gt;A&lt;/code&gt;ppend in a &lt;code&gt;:global&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^12138/norm!Asomething_at_the_end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-04-26T18:24:27.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19763" PostTypeId="2" ParentId="19669" CreationDate="2019-04-26T21:20:15.957" Score="3" Body="&lt;p&gt;It is not completely true that vim uses the beeps (or bells, as it calls them) only in errors.&#xA;There are many events that can trigger the bells, only some of them are errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can custom the bell to ring only in errors (or whenever you want), by setting the value of 'belloff'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the error messages should be shown when they are happening, other things that make vim beeps are probably not errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read more about customing the beeps and when they happens here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;help belloff&#xA;help errorbells&#xA;help visualbell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21987" LastActivityDate="2019-04-26T21:20:15.957" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19764" PostTypeId="1" CreationDate="2019-04-27T08:23:42.293" Score="1" ViewCount="313" Body="&lt;p&gt;The word &quot;vim&quot; is flagged as a spelling error in my documents. If I capitalize it, the error goes away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to capitalize &quot;vim&quot;. Adding it to dictionary with &lt;code&gt;zG&lt;/code&gt; or &lt;code&gt;zg&lt;/code&gt;  does not help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, I've discovered this word was somehow flagged as a &quot;rare&quot; word. How do I remove that designation? I'm not using any rare word list as far as I know. There's none in .vim/spell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remove my spell dir, &quot;vim&quot; is still getting flagged as rare. Where could the designation as &quot;rare&quot; be coming from?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 3&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, this is officially driving me crazy. I moved the spell directory and did vim -u NONE and it **still* shows up as a rare word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 4&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, tracked this down to neovim. I don't know why, but the &lt;code&gt;en.utf-8.spl&lt;/code&gt; file is in the &lt;code&gt;/usr/local/share/nvim/runtime/spell&lt;/code&gt; directory is getting loaded. How do I make changes to this file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 5&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, so I ended up copying over the &lt;code&gt;en.utf-8.spl&lt;/code&gt; from the vim install into neovim. But if someone could explain exactly what was happening, I'd appreciate it. How did this word get marked as flagged in the neovim spell file in the first place?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="54" LastEditDate="2023-05-08T06:49:36.223" LastActivityDate="2024-02-02T08:09:06.087" Title="Cannot remove spelling error highlight from lowercase &quot;vim&quot;" Tags="|neovim|spell-checking|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19765" PostTypeId="2" ParentId="300" CreationDate="2019-04-27T08:58:46.207" Score="1" Body="&lt;p&gt;I have settled for &lt;code&gt;&amp;lt;A-e&amp;gt;&lt;/code&gt; for the escape:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap  &amp;lt;A-e&amp;gt; &amp;lt;Esc&amp;gt;&#xA;snoremap &amp;lt;A-e&amp;gt; &amp;lt;Esc&amp;gt;&#xA;inoremap &amp;lt;A-e&amp;gt; &amp;lt;Esc&amp;gt;&#xA;tnoremap &amp;lt;A-e&amp;gt; &amp;lt;Esc&amp;gt;&#xA;&#xA;&quot; For some reason in command line mode '\e' is interpreted as Enter.&#xA;cnoremap &amp;lt;A-e&amp;gt; &amp;lt;C-c&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: Just found about &lt;code&gt;&amp;lt;C-\&amp;gt;&amp;lt;C\n&amp;gt;&lt;/code&gt; which sends you to normal mode from any other mode. It also has better overall behavior. The mappings become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;A-e&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&#xA;noremap! &amp;lt;A-e&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21990" LastEditorUserId="21990" LastEditDate="2019-08-31T13:07:35.663" LastActivityDate="2019-08-31T13:07:35.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19766" PostTypeId="2" ParentId="19750" CreationDate="2019-04-27T13:39:31.123" Score="1" Body="&lt;p&gt;In vimscript, strings are invariant: it would be very hard to&#xA;poke odd bytes into a series of Unicode characters without&#xA;trashing the entire thing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Concatenation of parts as you have done is not so hard!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative approach uses the substitute() function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s = substitute(s, &quot;^\\(..\\).&quot;, &quot;\\1x&quot;, &quot;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that is not much more readable or flexible. It is possible to&#xA;wrap up both attacks in a more useable fashion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:replacechar(src, pos, chr)&#xA;  if len(a:src) &amp;lt; a:pos&#xA;    return a:src&#xA;  else&#xA;        return (a:pos ? a:src[0:(a:pos-1)] : &quot;&quot;) . a:chr . a:src[(a:pos+1):]&#xA;  endif&#xA;endfunction&#xA;&#xA;function! s:rereplacechar(src, pos, chr)&#xA;  let l:pat = &quot;^\\(&quot; . repeat(&quot;.&quot;, a:pos) . &quot;\\).\\(.*\\)&quot;&#xA;  let l:rep = &quot;\\1&quot; . a:chr . &quot;\\2&quot;&#xA;  return substitute(a:src, l:pat, l:rep, &quot;&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Edit to correct a:p == 0 bug spotted by Mass)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tim&lt;/p&gt;&#xA;" OwnerUserId="7836" LastEditorUserId="7836" LastEditDate="2019-05-04T15:20:19.900" LastActivityDate="2019-05-04T15:20:19.900" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19767" PostTypeId="1" AcceptedAnswerId="19768" CreationDate="2019-04-27T19:09:38.193" Score="0" ViewCount="195" Body="&lt;p&gt;I'm trying to determine how many &lt;code&gt;#&lt;/code&gt; characters are at the beginning of a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In perl, I can so something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$match =~ m/^(#+)[^#])/;&#xA;$length = length $1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Trying to do something similar in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getline(a:lnum) =~ '\v^(#+)[^#]'&#xA;let length = strlen \1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I believe the &lt;code&gt;\v&lt;/code&gt; allows me to write a regex like perl, correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm just not sure if I can do capturing like I'm doing here or not.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="2021" LastEditDate="2019-04-27T19:22:31.853" LastActivityDate="2019-04-27T20:16:17.713" Title="Can capture groups be used like perl?" Tags="|regular-expression|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19768" PostTypeId="2" ParentId="19767" CreationDate="2019-04-27T19:52:35.117" Score="2" Body="&lt;p&gt;No, VimScript is not like Perl. It's basically a separate programming language and while it look like to support perl like regexes (&lt;code&gt;\v&lt;/code&gt;), those are not really perl like, since Vim supports different features for matching (see also &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#perl-patterns&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h perl-patterns&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means, captured groups are basically only valid within a &lt;code&gt;substitute()&lt;/code&gt; function (or within a &lt;code&gt;:s&lt;/code&gt; command).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the number of &lt;code&gt;#&lt;/code&gt; at the start of the line, you can however use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo strlen(matchstr(getline('.'), '^#\+'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(using &lt;code&gt;'.'&lt;/code&gt; for the cursor line).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-04-27T19:52:35.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19769" PostTypeId="2" ParentId="19767" CreationDate="2019-04-27T20:09:30.477" Score="2" Body="&lt;p&gt;@ChristanBrabandt typed &lt;a href=&quot;https://vi.stackexchange.com/a/19768/343&quot;&gt;his answer&lt;/a&gt; faster than me, so I won't repeat the information he's already given, or the simpler solution he supplied to your example problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you suggested in a comment that solving this problem isn't your main goal, and that you actually want to know &lt;a href=&quot;https://vi.stackexchange.com/questions/19767/can-capture-groups-be-used-like-perl/19769#comment34500_19767&quot;&gt;specifically whether it's possible to use capture groups like in Perl&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll therefore add the addendum that Vim does have a close analogue to how you describe Perl's capture groups: the &lt;code&gt;matchlist()&lt;/code&gt; function. You can use this to write Vimscript that more closely mirrors your Perl code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let groups = matchlist(getline(a:lnum), '\v^(#+)[^#]')&#xA;let length = empty(groups) ? 0 : len(groups[1])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-04-27T20:16:17.713" LastActivityDate="2019-04-27T20:16:17.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19770" PostTypeId="1" CreationDate="2019-04-28T03:50:13.010" Score="1" ViewCount="189" Body="&lt;pre&gt;&lt;code&gt;function! OperatorFunc(type, ...)&#xA;&#xA;  &quot; how to call another operator with current motion?&#xA;&#xA;  &quot; do other stuff&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to get motion text?  such as get &lt;code&gt;iw&lt;/code&gt; from &lt;code&gt;yiw&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="24" LastEditDate="2019-05-10T05:27:26.983" LastActivityDate="2019-11-06T09:02:00.300" Title="How to create new operator by using existing operator with current motion?" Tags="|vimscript|cursor-motions|operator|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19773" PostTypeId="1" AcceptedAnswerId="19779" CreationDate="2019-04-28T16:25:15.430" Score="9" ViewCount="2473" Body="&lt;p&gt;Calling the function &lt;code&gt;system(&quot;&amp;lt;command&amp;gt;&quot;)&lt;/code&gt; or &lt;code&gt;systemlist(&quot;&amp;lt;command&amp;gt;&quot;)&lt;/code&gt; retrieves the stdout output from a shell call to &lt;code&gt;&amp;lt;command&amp;gt;&lt;/code&gt;. How can I retrieve the exit status of that command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I would like to do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let output =  system_call_with_exit_status(&quot;my_shell_command&quot;)&#xA;let stdout = output[0]&#xA;let exit_status = output[1]&#xA;if (exit_status != 0)&#xA;    echo output&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The intention is to print the output from &lt;code&gt;my_shell_command&lt;/code&gt; only if the command gives a non-zero exit status.&lt;/p&gt;&#xA;" OwnerUserId="5803" LastActivityDate="2023-05-04T08:28:50.770" Title="get exit status from system() call" Tags="|vimscript|external-command|shell|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19774" PostTypeId="1" AcceptedAnswerId="19776" CreationDate="2019-04-28T16:27:10.410" Score="2" ViewCount="131" Body="&lt;p&gt;I have a string in a JSON file which is repeated with different values for chance. I want to replace all of these blocks by moving the miss chance out of the attack array and into a separate property.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code&gt;&quot;attacks&quot;: [&#xA;  {&#xA;    &quot;name&quot;: &quot;miss&quot;,&#xA;    &quot;chance&quot;: &quot;0.25&quot;&#xA;  },&#xA;  ...&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code&gt;&quot;missChance&quot;: 0.25,&#xA;&quot;attacks&quot;: [&#xA;  ...&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I managed to write a (basic) search pattern that would find all of these bits of JSON, and had grouping so I would be able to pull out the chance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&quot;attacks&quot;:\s*[\_s*{\_s*&quot;name&quot;:\s*&quot;miss&quot;,\_s*&quot;chance&quot;:\s&quot;\(0\.\d*\)&quot;\_s*},&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, although this search pattern would find all of the occurrences I wanted to replace, when I use it in a substitute command it returns &quot;Pattern not found&quot;. The substitute I was using was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&quot;attacks&quot;:\s*[\_s*{\_s*&quot;name&quot;:\s*&quot;miss&quot;,\_s*&quot;chance&quot;:\s&quot;\(0\.\d*\)&quot;\_s*},/&quot;missChance&quot;: \1^M&quot;attacks&quot;: [/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have noticed that the error includes more of the search pattern than I expected; it looks like it's searching for everything after the second &quot;/&quot; separator for some reason. Why would the search be different in the substitute command to in a normal search?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the error:&#xA;&lt;code&gt;Pattern not found: &quot;attacks&quot;:\s*[\_s*{\_s*&quot;name&quot;:\s*&quot;miss&quot;,\_s*&quot;chance&quot;:\s&quot;\(0\.\d*\)&quot;\_s*},/&quot;missChance&quot;: \1,^M&quot;attacks&quot;: [/g&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="22003" LastActivityDate="2019-04-28T17:09:45.477" Title="Difference between searching and substituting pattern matching" Tags="|neovim|search|substitute|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19775" PostTypeId="2" ParentId="19764" CreationDate="2019-04-28T17:07:14.527" Score="0" Body="&lt;p&gt;Check if this is caused by 'vim' is being used at the beginning of a sentence.&lt;br&gt;&#xA;In my tests on vim 8.* only the first 'vim' of &quot;vim vim vim&quot; is flagged as a spelling error.  &lt;/p&gt;&#xA;" OwnerUserId="14302" LastActivityDate="2019-04-28T17:07:14.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19776" PostTypeId="2" ParentId="19774" CreationDate="2019-04-28T17:09:45.477" Score="1" Body="&lt;p&gt;Try to escape the opening square bracket, otherwise the whole command becomes the pattern.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&quot;attacks&quot;:\s*\[\_s*{\_s*&quot;name&quot;:\s*&quot;miss&quot;,\_s*&quot;chance&quot;:\s&quot;\(0\.\d*\)&quot;\_s*},/&quot;missChance&quot;: \1^M&quot;attacks&quot;: [/g&#xA;                 ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you don't escape it, the pattern in this substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&quot;attacks&quot;:\s*[\_s*{\_s*&quot;name&quot;:\s*&quot;miss&quot;,\_s*&quot;chance&quot;:\s&quot;\(0\.\d*\)&quot;\_s*},/&quot;missChance&quot;: \1^M&quot;attacks&quot;: [/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is not:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;attacks&quot;:\s*[\_s*{\_s*&quot;name&quot;:\s*&quot;miss&quot;,\_s*&quot;chance&quot;:\s&quot;\(0\.\d*\)&quot;\_s*},&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;attacks&quot;:\s*[\_s*{\_s*&quot;name&quot;:\s*&quot;miss&quot;,\_s*&quot;chance&quot;:\s&quot;\(0\.\d*\)&quot;\_s*},/&quot;missChance&quot;: \1^M&quot;attacks&quot;: [/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is explained at &lt;code&gt;:h E769&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the ']' is not there Vim will not give an error message but&#xA;  assume no collection is used.  Useful to search for '['.  However, you&#xA;  do get E769 for internal searching.  And be aware that in a&#xA;  &lt;code&gt;:substitute&lt;/code&gt; command the whole command becomes the pattern.  E.g.&#xA;  &quot;:s/[/x/&quot; searches for &quot;[/x&quot; and replaces it with nothing.  It does&#xA;  not search for &quot;[&quot; and replaces it with &quot;x&quot;!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2019-04-28T17:09:45.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19777" PostTypeId="1" CreationDate="2019-04-28T17:13:27.567" Score="2" ViewCount="247" Body="&lt;p&gt;I am coding a C project and as I am unexperienced, everytime I needed to access the element of a pointer to a struct I typed &lt;code&gt;(*x).y&lt;/code&gt; (where x is a struct and y an item), which I just realized could be rewritten as &lt;code&gt;-&amp;gt;&lt;/code&gt; which would look much nicer. So I first tried to make a regular expression to find all such occurences. I thought &lt;code&gt;/(/*.+/)/.&lt;/code&gt; would work, but it gave some strange unwanted occurences. For example &lt;code&gt;(queue_t *queue)&lt;/code&gt; would match which I don't understand why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also unsure what macro could be used if I got the correct regex. I thought making then a macro which deletes the first 2 characters, and then would go to the &quot;end&quot; to replace &lt;code&gt;).&lt;/code&gt; with &lt;code&gt;-&amp;gt;&lt;/code&gt;, but then if I have something of the type &lt;code&gt;(*(*a).b)).c&lt;/code&gt; I don't know how to find the correct &lt;code&gt;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also are there better alternatives to do what I want other than use regular expressions and macros? &lt;/p&gt;&#xA;" OwnerUserId="21104" LastEditorUserId="21104" LastEditDate="2019-04-28T17:19:26.310" LastActivityDate="2019-04-29T04:05:15.300" Title="Substituting (*x).y with x-&gt;y" Tags="|regular-expression|replace|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19779" PostTypeId="2" ParentId="19773" CreationDate="2019-04-28T17:33:44.397" Score="16" Body="&lt;p&gt;Mentioned in the comments above, the &lt;code&gt;v:shell_error&lt;/code&gt; variable gives the result of the last shell command. So the exit status can be tested as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let output = system(&amp;quot;my_shell_command&amp;quot;)&#xA;if v:shell_error != 0&#xA;    echo output&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5803" LastEditorUserId="5803" LastEditDate="2022-04-21T23:52:08.493" LastActivityDate="2022-04-21T23:52:08.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19780" PostTypeId="2" ParentId="19777" CreationDate="2019-04-28T18:23:40.410" Score="5" Body="&lt;p&gt;Iwould try it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/(\*\(\k*\))\./\1-&amp;gt;/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The search string is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;(&lt;/code&gt; opening   parenthesis&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\*&lt;/code&gt; a literal &lt;code&gt;*&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(...\)&lt;/code&gt; a match group. This can later be addressed with &lt;code&gt;\1&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\k*&lt;/code&gt; any number of keywor characters&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;)&lt;/code&gt; closing  parenthesis&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\.&lt;/code&gt; a literal &lt;code&gt;.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The replace is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\1&lt;/code&gt; This is replaced with what is matched by the test within &lt;code&gt;\(...\)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See: &lt;code&gt;:help /\k&lt;/code&gt;, &lt;code&gt;:help /\(&lt;/code&gt; and &lt;code&gt;:help /\1&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="51" LastEditDate="2019-04-29T04:05:15.300" LastActivityDate="2019-04-29T04:05:15.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19781" PostTypeId="1" CreationDate="2019-04-28T20:57:21.067" Score="0" ViewCount="76" Body="&lt;p&gt;Trying to figure out why folds aren't happening as soon as I open a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldenable&#xA;set foldmethod=expr&#xA;let g:lastnum = 0&#xA;function! FoldFile(lnum)&#xA;    echom 'hi';&#xA;    if getline(a:lnum) =~? '\v^\s*$'&#xA;    let g:lastnum = -1&#xA;        return '-1'&#xA;    endif&#xA;    let last = g:lastnum&#xA;    let num_of_pounds = strlen(matchstr(getline(a:lnum), '^#\+'))&#xA;    if (num_of_pounds &amp;gt; 0)&#xA;            let g:lastnum = num_of_pounds&#xA;        if last == -1&#xA;            return '&amp;gt;' . num_of_pounds&#xA;        endif&#xA;        return num_of_pounds&#xA;    endif&#xA;    return g:lastnum&#xA;endfunction&#xA;set foldlevel=0&#xA;set foldexpr=FoldFile(v:lnum)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get the folds to kick in, I have to source my ~/.vimrc file&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2019-04-28T20:57:21.067" Title="File is not folding when opened" Tags="|folding|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19782" PostTypeId="1" AcceptedAnswerId="19783" CreationDate="2019-04-28T23:20:57.497" Score="2" ViewCount="255" Body="&lt;p&gt;Got this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let Func = function(folding_function) &quot;folding_function is name of function&#xA;setlocal foldexpr=call(Func(v:lnum))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is so user can set a custom function for folding in their config file. I can't get it to work, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also tried:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;call(Func, v:lnum)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;call(Func, 'v:lnum')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code in context&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set settings which are local to a window. In a new tab they would be reset to&#xA;&quot; Vim defaults. So we enforce our settings here when the cursor enters a&#xA;&quot; Vimwiki buffer.&#xA;function! s:set_windowlocal_options()&#xA;  if !&amp;amp;diff   &quot; if Vim is currently in diff mode, don't interfere with its folding&#xA;    let foldmethod = vimwiki#vars#get_global('folding')&#xA;    if foldmethod =~? '^expr.*'&#xA;      setlocal foldmethod=expr&#xA;      let custom = vimwiki#vars#get_global('custom_fold_func')&#xA;      if custom&#xA;        let Func = function('VimwikiFoldLevelCustom')&#xA;        setlocal foldexpr=Func(v:lnum)&#xA;&quot;        setlocal foldexpr=VimwikiFoldLevelCustom(v:lnum)&#xA;      else&#xA;        setlocal foldexpr=VimwikiFoldLevel(v:lnum)&#xA;      endif&#xA;      setlocal foldtext=VimwikiFoldText()&#xA;    elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*'&#xA;      setlocal foldmethod=expr&#xA;      setlocal foldexpr=VimwikiFoldListLevel(v:lnum)&#xA;      setlocal foldtext=VimwikiFoldText()&#xA;    elseif foldmethod =~? '^syntax.*'&#xA;      setlocal foldmethod=syntax&#xA;      setlocal foldtext=VimwikiFoldText()&#xA;    elseif foldmethod =~? '^custom.*'&#xA;      &quot; do nothing&#xA;    else&#xA;      setlocal foldmethod=manual&#xA;      normal! zE&#xA;    endif&#xA;  endif&#xA;&#xA;  if vimwiki#vars#get_global('conceallevel') &amp;amp;&amp;amp; exists(&quot;+conceallevel&quot;)&#xA;    let &amp;amp;conceallevel = vimwiki#vars#get_global('conceallevel')&#xA;  endif&#xA;&#xA;  if vimwiki#vars#get_global('auto_chdir')&#xA;    exe 'lcd' vimwiki#vars#get_wikilocal('path')&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="2021" LastEditDate="2019-04-29T02:38:31.813" LastActivityDate="2019-04-29T02:51:26.433" Title="Possible to set `foldexpr` using a function reference?" Tags="|functions|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="19783" PostTypeId="2" ParentId="19782" CreationDate="2019-04-29T00:46:27.760" Score="3" Body="&lt;p&gt;The value of the &lt;code&gt;foldexpr&lt;/code&gt; option is evaluated to get the foldlevel of a line. You don't need to add extra &lt;code&gt;call&lt;/code&gt; to it. You can copy following code in a new file and source it to check how it works.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vim:set foldmethod=expr noexpandtab:&#xA;&#xA;function! FoldingFunction(lnum)&#xA;  return getline(v:lnum)[0]==#&quot;\t&quot;&#xA;endfunction&#xA;let Func = function('FoldingFunction') &quot;FoldingFunction is name of function&#xA;setlocal foldexpr=Func(v:lnum)&#xA;&#xA;finish&#xA;&#xA;    fold&#xA;    fold&#xA;    fold&#xA;    fold&#xA;    fold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code doesn't work because your &lt;code&gt;Func&lt;/code&gt; is a function local variable, change it to &lt;code&gt;g:Func&lt;/code&gt; fix the problem.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-04-29T02:51:26.433" LastActivityDate="2019-04-29T02:51:26.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19784" PostTypeId="1" CreationDate="2019-04-29T09:08:37.807" Score="1" ViewCount="472" Body="&lt;p&gt;I have this shorcut in my vimrc that I use all the time (admittedly, I just copied it over from the web):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; bind K to grep word under cursor&#xA;nnoremap K :grep! &quot;\b&amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;\b&quot;&amp;lt;CR&amp;gt;:cw&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works excellent, it displays the matched keywards in the window below in my vim session:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TlkqM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TlkqM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is great, but I would like to create another keyboard shortcut that only searches for the keyword under the cursor for the &lt;em&gt;current file only&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched how to do that online and found this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vim /pattern/ % | cw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine if I type it out manually on vim, but I'm trying to create a keyboard shortcut for it using &lt;a href=&quot;https://vim.fandom.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_1)&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; bind L to grep word under cursor for current file only&#xA;nnoremap L :vim &amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt;% |&amp;lt;CR&amp;gt;:cw&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This isn't working, it's giving me a syntax error. My question is: how can I add the &lt;code&gt;%&lt;/code&gt; option to the above vim command to the keyboard map?&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="51" LastEditDate="2019-05-02T06:36:37.430" LastActivityDate="2019-05-02T06:36:37.430" Title="How to use filename expansion in a mapping" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19785" PostTypeId="2" ParentId="19784" CreationDate="2019-04-29T09:14:39.250" Score="1" Body="&lt;p&gt;I got it! Just by playing around, I got this to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; bind L to grep word under cursor for current file only&#xA;nnoremap L :vim &amp;lt;C-R&amp;gt;&amp;lt;C-W&amp;gt; %&amp;lt;CR&amp;gt;:cw&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="21943" LastEditDate="2019-05-02T04:43:54.607" LastActivityDate="2019-05-02T04:43:54.607" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19786" PostTypeId="2" ParentId="4850" CreationDate="2019-04-29T10:07:40.963" Score="9" Body="&lt;p&gt;&lt;code&gt;:ls&lt;/code&gt; shows the current buffers (opened files)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;code&gt;+&lt;/code&gt; mark before file path shows that file is modified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check &lt;a href=&quot;http://vimhelp.appspot.com/windows.txt.html#%3Als&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :ls&lt;/code&gt;&lt;/a&gt; for more details&lt;/p&gt;&#xA;" OwnerUserId="22010" LastEditorUserId="1841" LastEditDate="2019-04-29T11:00:57.477" LastActivityDate="2019-04-29T11:00:57.477" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19787" PostTypeId="2" ParentId="19770" CreationDate="2019-04-29T14:45:29.797" Score="1" Body="&lt;p&gt;Visually select motion text, execute existing operator:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! OperatorFunc(type, ...)&#xA;&#xA;  &quot; change op to desired operator&#xA;  call ExecuteOperator(a:type, a:0 &amp;gt; 0, 'op')&#xA;&#xA;  &quot; do other stuff&#xA;&#xA;endfunction&#xA;&#xA;function! ExecuteOperator(type, visual, operator)&#xA;  if a:visual&#xA;    exe 'norm gv'.a:operator&#xA;  els&#xA;    exe printf('`[%s`]%s', a:type ==# 'line' ? 'V' : 'v', a:operator)&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-09T07:06:32.823" LastActivityDate="2019-06-09T07:06:32.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19788" PostTypeId="1" AcceptedAnswerId="19868" CreationDate="2019-04-29T16:35:12.660" Score="0" ViewCount="95" Body="&lt;p&gt;For the purpose of this question, imagine that I have set&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;iab phil philosopher&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vim, as far as I know, the default display pattern when typing out the characters &quot;phil&quot; at the start of the word is to sequentially display each character in the same column until either: 1) I type a character that is not part of the potential abbreviation, 2) I pause long enough the abbreviation will not trigger, or 3) I hit the &quot;end&quot; character and the abbreviation triggers. I find this behavior annoying, especially since I otherwise love abbreviations in vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to set abbreviations in vim to type, as normal, and then only change text if triggered, rather than holding the character in place until a character is typed that determines if you are using an abbreviation or not? I would be fine with it if the change also affected macros.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: It seems the behavior I am observing is a function of imap/inoremap not iab. I have changed the question to reflect this discrepancy, but leaving the original text in place for context so other &lt;code&gt;*ahem&lt;/code&gt;* challenged people will be able to find the appropriate questions.&lt;/p&gt;&#xA;" OwnerUserId="16156" LastEditorUserId="16156" LastEditDate="2019-05-01T14:18:26.320" LastActivityDate="2019-05-06T13:05:05.467" Title="How can I get vim to type continuously, rather than holding in place for keymappings?" Tags="|vimrc|vimscript|gvim|insert-mode|abbreviations|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19789" PostTypeId="1" CreationDate="2019-04-29T17:22:02.440" Score="1" ViewCount="72" Body="&lt;p&gt;I try writing some HTML5 with omitted closing tags in NVIM v0.3.4, and get this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-html prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;ol&amp;gt;&#xA;    &amp;lt;li&amp;gt;3&#xA;        &amp;lt;li&amp;gt;4&#xA;            &amp;lt;li&amp;gt;8&#xA;                &amp;lt;li&amp;gt;9&#xA;&amp;lt;/ol&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is legit HTML5, and even recommended by some. Is there a way to get this fixed? Specifically, to have the following without manual intervention on the indentation:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-html prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;ol&amp;gt;&#xA;    &amp;lt;li&amp;gt;3&#xA;    &amp;lt;li&amp;gt;4&#xA;    &amp;lt;li&amp;gt;8&#xA;    &amp;lt;li&amp;gt;9&#xA;&amp;lt;/ol&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22017" LastActivityDate="2019-04-29T17:22:02.440" Title="How to indent HTML5 with omitted closing tags properly?" Tags="|indentation|filetype-html|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19790" PostTypeId="1" AcceptedAnswerId="19792" CreationDate="2019-04-29T18:09:47.537" Score="3" ViewCount="209" Body="&lt;p&gt;This vim binding will make &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; correct the previous spelling mistake:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-l&amp;gt; &amp;lt;c-g&amp;gt;u&amp;lt;Esc&amp;gt;[s1z=`]a&amp;lt;c-g&amp;gt;u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I modify it to make it correct the previous mistake on the current line only?&lt;/p&gt;&#xA;" OwnerUserId="18953" LastActivityDate="2019-04-30T00:52:28.293" Title="How to make vim spell error search the current line only?" Tags="|search|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19791" PostTypeId="2" ParentId="4850" CreationDate="2019-04-29T20:15:56.257" Score="1" Body="&lt;p&gt;Adding to what muru posted, here's a 'not easy' way to control the processes hanging out there:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;create and chmod +x type.py:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/python&#xA;import argparse&#xA;import fcntl,termios&#xA;&#xA;p = argparse.ArgumentParses()&#xA;p.add_argument('fname')&#xA;p.add_argument('test')&#xA;args = p.parse_args()&#xA;fd = open(args.fname,'w')&#xA;for c in args.text:&#xA;    fcntl.ioctl(fd,termios.TIOCSTI,c)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then from bash run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo ./type.py /proc/[vim pid goes here]/fd/0 $'\x1b\x1b:wq\x0d'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;note the preceding two ESCs &lt;code&gt;(\x1b)&lt;/code&gt; to (hopefully) get back to normal mode, and the following return &lt;code&gt;(\x0d)&lt;/code&gt; to execute the wq&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or do them all at once:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in $(pgrep vim); do sudo ./type.py /proc/$i/fd/0 $'\x1b\x1b:wq\x0d'; done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22018" LastActivityDate="2019-04-29T20:15:56.257" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19792" PostTypeId="2" ParentId="19790" CreationDate="2019-04-30T00:52:28.293" Score="4" Body="&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-l&amp;gt; &amp;lt;c-g&amp;gt;u&amp;lt;Esc&amp;gt;:call &amp;lt;sid&amp;gt;fixLineSpellError()&amp;lt;cr&amp;gt;`]a&amp;lt;c-g&amp;gt;u&#xA;&#xA;function! s:fixLineSpellError()&#xA;  &quot; get current line number&#xA;  let lnum = line('.')&#xA;  &quot; find last misspelled word before cursor&#xA;  normal! [s&#xA;  &quot; do nothing if line changed&#xA;  if lnum != line('.') | return | endif&#xA;  &quot; fix spell error if line doesn't change&#xA;  normal! 1z=&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Map break down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-g&amp;gt;u&amp;lt;Esc&amp;gt;&lt;/code&gt; break undo sequence, switch to normal mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:call &amp;lt;sid&amp;gt;fixLineSpellError()&amp;lt;cr&amp;gt;&lt;/code&gt; call a script scope function to fix current line spell error.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`]a&lt;/code&gt; move cursor back to the end of last change, start to append.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-g&amp;gt;u&lt;/code&gt; break undo sequence.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-04-30T00:52:28.293" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19793" PostTypeId="1" CreationDate="2019-04-30T10:15:21.490" Score="2" ViewCount="371" Body="&lt;p&gt;I have a file that looks similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;module.exports = {&#xA;    blank: {&#xA;        area: 'frontend',&#xA;        name: 'Magento/blank',&#xA;        locale: 'en_US',&#xA;        files: [&#xA;            'css/styles-m',&#xA;            'css/styles-l',&#xA;            'css/email',&#xA;            'css/email-inline'&#xA;        ],&#xA;        dsl: 'less'&#xA;    },&#xA;    backend: {&#xA;        area: 'adminhtml',&#xA;        name: 'Magento/backend',&#xA;        locale: 'en_US',&#xA;        files: [&#xA;            'css/styles-old',&#xA;            'css/styles'&#xA;        ],&#xA;        dsl: 'less'&#xA;    }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need to add another entry inside &lt;code&gt;module.exports&lt;/code&gt;. I use vim inside a bash script in the following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;THEME_CONFIG=&quot;\r    $LOWERCASE_THEME_TITLE: {\r&#xA;        area: 'frontend',\r&#xA;        name: '$ESCAPED_THEME_PATH',\r&#xA;        locale: 'en_US',\r&#xA;        files: [\r&#xA;            'css\/styles-m',\r&#xA;            'css\/styles-l'\r&#xA;        ],\r&#xA;        dsl: 'less'\r&#xA;    }\r&#xA;&quot;&#xA;&#xA;vim -c &quot;%s/}\n/},$THEME_CONFIG\n/|wq&quot; dev/tools/grunt/configs/themes.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine apart from the fact that I do not want to use &lt;code&gt;\r&lt;/code&gt; as it seems to be breaking grunt. I would like to use &lt;code&gt;\n&lt;/code&gt; instead, but if I replace &lt;code&gt;\r&lt;/code&gt; in the code above with &lt;code&gt;\n&lt;/code&gt; it does not work (&lt;code&gt;THEME_CONFIG&lt;/code&gt; has no line breaks).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried &lt;code&gt;\\n&lt;/code&gt;, &lt;code&gt;$'\n'&lt;/code&gt; but all I get is one line.&lt;/p&gt;&#xA;" OwnerUserId="22027" LastActivityDate="2019-05-03T13:08:55.417" Title="Replace a string with a variable containing newline characters" Tags="|replace|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19794" PostTypeId="2" ParentId="19793" CreationDate="2019-04-30T11:29:23.760" Score="0" Body="&lt;p&gt;Thank you guys for the answers. &lt;code&gt;awk&lt;/code&gt; (&lt;code&gt;gawk&lt;/code&gt; in this particular case) is indeed the way to go. Though the solution has nothing to do with vim I paste it here just in case somebody stumbles upon this question.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;THEME_CONFIG=&quot;    $LOWERCASE_THEME_TITLE: {&#xA;        area: 'frontend',&#xA;        name: '$ESCAPED_THEME_PATH',&#xA;        locale: 'en_US',&#xA;        files: [&#xA;            'css\/styles-m',&#xA;            'css\/styles-l'&#xA;        ],&#xA;        dsl: 'less'&#xA;    }&#xA;&quot;&#xA;&#xA;gawk -i inplace -v replacement=&quot;},\n$THEME_CONFIG&quot; -v RS=&quot;&quot; '{sub(/}\n/,replacement)}1' dev/tools/grunt/configs/themes.js  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22027" LastActivityDate="2019-04-30T11:29:23.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19795" PostTypeId="1" CreationDate="2019-04-30T13:59:19.630" Score="1" ViewCount="154" Body="&lt;p&gt;When I have multiple files open in multiple splits, when I open a new file via quickfix ( or Ctrl-P ), it sometimes ends up placing the new file in a window that I don't want to be changed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way we can specify a lock/pin on the viewport so that new files don't replace them?&lt;/p&gt;&#xA;" OwnerUserId="2277" LastActivityDate="2019-04-30T13:59:19.630" Title="How to pin a file to a window(/viewport)" Tags="|buffers|vim-windows|split|multiple-files|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19796" PostTypeId="1" AcceptedAnswerId="19797" CreationDate="2019-04-30T17:26:33.357" Score="1" ViewCount="573" Body="&lt;p&gt;I've got a line like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* [ ] Find a way to efficiently move a task from one area to another   #8ab879&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to create a map that selects just &quot;Find a way to efficiently move a task from one area to another&quot; in a visual block. The brackets may or may not be there. The &lt;code&gt;#8ab879&lt;/code&gt; may or may not be there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I got:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap \bw ma^/[A-z]&amp;lt;cr&amp;gt;n:set nohls&amp;lt;cr&amp;gt;v$F#be&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which doesn't quite work (the last bracket is selected) and my method seems awfully convoluted.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2019-04-30T20:35:51.587" Title="Moving to first letter in a line" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ClosedDate="2019-05-03T10:34:31.490" ContentLicense="CC BY-SA 4.0" />
  <row Id="19797" PostTypeId="2" ParentId="19796" CreationDate="2019-04-30T18:28:34.820" Score="4" Body="&lt;p&gt;Use &lt;code&gt;^&lt;/code&gt; followed by &lt;code&gt;search()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;^ ^:call search('\w', '', line('.'))&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: this uses &lt;code&gt;\w&lt;/code&gt; which is &lt;code&gt;[A-Za-z0-9_]&lt;/code&gt;. You may want to make it just &lt;code&gt;[A-Za-z]&lt;/code&gt; for your use case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h ^&#xA;:h search()&#xA;:h line()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2019-04-30T20:35:51.587" LastActivityDate="2019-04-30T20:35:51.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19798" PostTypeId="1" AcceptedAnswerId="19800" CreationDate="2019-04-30T21:03:32.227" Score="5" ViewCount="3076" Body="&lt;p&gt;Is there a command to make a newline &lt;em&gt;without&lt;/em&gt; the autoindent? In other words, I want &lt;code&gt;o&lt;/code&gt; and &lt;code&gt;O&lt;/code&gt; to normally autoindent, but is there another command that will not autoindent for just the duration of that command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively (if there isn't a way to that exactly), what's a better workaround than just backspacing a ton after autoindenting many tabs too far.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if some_check():&#xA;    self.some_long_function_name(withlots, ofargs&#xA;                                 andmaybe=keywordargs)&#xA;                               # ^ Indents to the caret&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;code&gt;o&lt;/code&gt; on the &lt;code&gt;andmaybe=keywordargs&lt;/code&gt; line leaves me &lt;em&gt;way&lt;/em&gt; more indented than I want to be.&lt;/p&gt;&#xA;" OwnerUserId="17770" LastEditorUserId="17770" LastEditDate="2019-04-30T21:27:35.973" LastActivityDate="2019-04-30T23:18:34.187" Title="How to make a newline without autoindent" Tags="|indentation|" AnswerCount="1" CommentCount="10" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19799" PostTypeId="1" CreationDate="2019-04-30T22:41:04.453" Score="3" ViewCount="261" Body="&lt;p&gt;I've looked up and tried several of the following post up here regarding setting up persistent undo history in vim, but still I'm not able to do so. (macOSX Mojave)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here are some info:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:version&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vimrc file = ~/.vim/.vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;:highlight Normal ctermfg=grey ctermbg=darkblue                                          &#xA;:let $MYVIMRC=&quot;~/.vim/.vimrc&quot;&#xA;&#xA;set undofile                                                                              &#xA;set undodir=/Users/dave/.vim/undodir&#xA;&#xA;let mapleader = &quot;\&amp;lt;Space&amp;gt;&quot;&#xA;&#xA;:nnoremap &amp;lt;leader&amp;gt;sv :source $MYVIMRC&amp;lt;cr&amp;gt;                                                 &#xA;:nnoremap &amp;lt;leader&amp;gt;ev :vsplit $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;~/.bash_profile&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vim=&quot;vim -S ~/.vim/.vimrc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inside of /undodir:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;%Users%dave%.vim%.vimrc %Users%dave%test.js&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when I load &quot;test.js&quot; and press u, vim responds with &quot;already oldest change&quot;.&lt;/p&gt;&#xA;" OwnerUserId="22045" LastActivityDate="2019-08-09T06:27:15.990" Title="unable to setup persistent undo history in Vim" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19800" PostTypeId="2" ParentId="19798" CreationDate="2019-04-30T23:05:01.473" Score="5" Body="&lt;p&gt;I don't think there is an normal mode command to start a new line without indent. You can, however, &lt;em&gt;remove&lt;/em&gt; the indent while in insert mode with the keystrokes &lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;Ctrl-D&lt;/kbd&gt;, and so it's easy to set up new mappings to do so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;o o0&amp;lt;C-D&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;O O0&amp;lt;C-D&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Personally, though, I'd install an indent plugin to handle this for you*.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;a href=&quot;https://github.com/Vimjas/vim-python-pep8-indent.git&quot; rel=&quot;noreferrer&quot;&gt;vim-python-pep8-indent&lt;/a&gt; which handles your example nicely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;Or indeed, just use the Python indent script included in Vim (via the &lt;code&gt;:filetype&lt;/code&gt; command) instead of the &lt;code&gt;'autoindent'&lt;/code&gt; setting. This is the one @Ralf &lt;a href=&quot;https://vi.stackexchange.com/questions/19798/how-to-make-a-newline-without-autoindent/19800#comment34558_19798&quot;&gt;describes in the comments&lt;/a&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-04-30T23:18:34.187" LastActivityDate="2019-04-30T23:18:34.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19801" PostTypeId="2" ParentId="19793" CreationDate="2019-04-30T23:46:51.597" Score="1" Body="&lt;p&gt;The problem isn't the &lt;code&gt;\r&lt;/code&gt; characters in your string, but the fact that the string &lt;em&gt;also&lt;/em&gt; contains literal newline characters, and Vim is including these in the replacement &lt;a href=&quot;https://stackoverflow.com/a/12389839/328936&quot;&gt;as NUL characters&lt;/a&gt; after the linebreaks. If you remove the latter from your bash script, then the replacement works correctly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;THEME_CONFIG=&quot;\r    $LOWERCASE_THEME_TITLE: {\r        area: 'frontend',\r        name: '$ESCAPED_THEME_PATH',\r        locale: 'en_US',\r [...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you (understandably) don't want to write your bash string on a single very long, line, there are &lt;a href=&quot;https://stackoverflow.com/questions/7316107/bash-continuation-lines&quot;&gt;a number of ways&lt;/a&gt; you can split it up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you’re also including another NUL character in your substitution which needs to be changed to a &lt;code&gt;\r&lt;/code&gt; linebreak:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;%s/}\n/},$THEME_CONFIG\n/|wq&quot; ...&#xA;                              ^^&#xA;                              NUL character&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's a complete solution, using line continuations to break up the string over several lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;THEME_CONFIG=&quot;\r    $LOWERCASE_THEME_TITLE: {\r&quot;\&#xA;&quot;        area: 'frontend',\r&quot;\&#xA;&quot;        name: '$ESCAPED_THEME_PATH',\r&quot;\&#xA;&quot;        locale: 'en_US',\r&quot;\&#xA;&quot;        files: [\r&quot;\&#xA;&quot;            'css\/styles-m',\r&quot;\&#xA;&quot;            'css\/styles-l'\r&quot;\&#xA;&quot;        ],\r&quot;\&#xA;&quot;        dsl: 'less'\r&quot;\&#xA;&quot;    }\r&quot;&#xA;&#xA;vim -c &quot;%s/}\n/},$THEME_CONFIG\r/|wq&quot; themes.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-05-01T09:02:14.267" LastActivityDate="2019-05-01T09:02:14.267" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19802" PostTypeId="2" ParentId="19793" CreationDate="2019-05-01T01:11:15.703" Score="0" Body="&lt;p&gt;Two methods to append something in ex mode. You don't need to add &lt;code&gt;\r&lt;/code&gt; in these methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in this case, you should use &lt;code&gt;sed&lt;/code&gt; or &lt;code&gt;awk&lt;/code&gt;, feel free to ignore this answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Append&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -sc +'if !search(&quot;}\\n&quot;) | q | endif' +'norm! A,' +&quot;a|$THEME_CONFIG&quot; +x theme.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;+'if !search(&quot;}\n&quot;) | q | endif' exit if search failed. &lt;code&gt;:append&lt;/code&gt; doesn't work well with &lt;code&gt;global&lt;/code&gt; or &lt;code&gt;if&lt;/code&gt;, you need to exit immediately if search failed.&lt;/li&gt;&#xA;&lt;li&gt;+'norm! A,' add &lt;code&gt;,&lt;/code&gt; after &lt;code&gt;}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;+&quot;a|$THEME_CONFIG&quot; append a block of text below current line. I didn't add the ending &lt;code&gt;.&lt;/code&gt;, but it still works.&lt;/li&gt;&#xA;&lt;li&gt;+x save and exit&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Characterwise paste&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;              v comma added here&#xA;THEME_CONFIG=&quot;,&#xA;    $LOWERCASE_THEME_TITLE: {&#xA;        area: 'frontend',&#xA;        name: '$ESCAPED_THEME_PATH',&#xA;        locale: 'en_US',&#xA;        files: [&#xA;            'css\/styles-m',&#xA;            'css\/styles-l'&#xA;        ],&#xA;        dsl: 'less'&#xA;    }&quot;&#xA;     ^ no line break between } and &quot;&#xA;&#xA;ex -ns +&quot;let @\&quot;=\&quot;$THEME_CONFIG\&quot;&quot; +'g/}\n/ norm! $p' +x  term.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;-ns&lt;/code&gt; ignore recovery file, silent.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;+&quot;let@\&quot;=\&quot;$THEME_CONFIG\&quot;&quot;&lt;/code&gt; set default register to desired content. Because you want to add &lt;code&gt;,&lt;/code&gt; directly after &lt;code&gt;}&lt;/code&gt;, you must paste in characterwise mode, so you need to make sure &lt;code&gt;THEME_CONFIG&lt;/code&gt; doesn't end in newline, otherwise your default register ended up in &lt;code&gt;linewise&lt;/code&gt; mode. check &lt;code&gt;:h :let-@&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;+'g/}\n/ norm! $p'&lt;/code&gt; search, go to line end, paste. check &lt;code&gt;:h :g&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-03T13:08:55.417" LastActivityDate="2019-05-03T13:08:55.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19803" PostTypeId="2" ParentId="19461" CreationDate="2019-05-01T01:23:39.630" Score="1" Body="&lt;p&gt;I have my setup working the way you want with neovim and coc-vim. Here is what I have in my &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use tab for trigger completion with characters ahead and navigate.&#xA;&quot; Use command ':verbose imap &amp;lt;tab&amp;gt;' to make sure tab is not mapped by other plugin.&#xA;function! s:check_back_space() abort&#xA;  let col = col('.') - 1&#xA;  return !col || getline('.')[col - 1]  =~# '\s'&#xA;endfunction&#xA;inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;TAB&amp;gt;&#xA;      \ pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; :&#xA;      \ &amp;lt;SID&amp;gt;check_back_space() ? &quot;\&amp;lt;TAB&amp;gt;&quot; :&#xA;      \ coc#refresh()&#xA;inoremap &amp;lt;expr&amp;gt;&amp;lt;S-TAB&amp;gt; pumvisible() ? &quot;\&amp;lt;C-p&amp;gt;&quot; : &quot;\&amp;lt;C-h&amp;gt;&quot;&#xA;&#xA;&quot; Navigate snippet placeholders using tab&#xA;let g:coc_snippet_next = '&amp;lt;Tab&amp;gt;'&#xA;let g:coc_snippet_prev = '&amp;lt;S-Tab&amp;gt;'&#xA;&#xA;&quot; Use enter to accept snippet expansion&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; pumvisible() ? &quot;\&amp;lt;C-y&amp;gt;&quot; : &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18953" LastActivityDate="2019-05-01T01:23:39.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19804" PostTypeId="1" AcceptedAnswerId="19805" CreationDate="2019-05-01T05:27:51.417" Score="2" ViewCount="186" Body="&lt;p&gt;I can customize the &lt;kbd&gt;n&lt;/kbd&gt; and &lt;kbd&gt;N&lt;/kbd&gt; keys to always search backward and forward respectively irrespective of what the last search direction was with the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; n (v:searchforward ? 'n' : 'N')&#xA;nnoremap &amp;lt;expr&amp;gt; N (v:searchforward ? 'N' : 'n')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to achieve similar effects for the &lt;kbd&gt;,&lt;/kbd&gt; and &lt;kbd&gt;;&lt;/kbd&gt; keys, i.e. I want &lt;kbd&gt;,&lt;/kbd&gt; to always jump backward and &lt;kbd&gt;;&lt;/kbd&gt; to always jump forward. But I can't find any similar variable in &lt;code&gt;:h eval.txt&lt;/code&gt; for this purpose. Maybe I'm missing some thing.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How do I make &lt;kbd&gt;,&lt;/kbd&gt; and &lt;kbd&gt;;&lt;/kbd&gt; unaware of the direction of the latest &lt;code&gt;f&lt;/code&gt;,&lt;code&gt;F&lt;/code&gt; or &lt;code&gt;t&lt;/code&gt;,&lt;code&gt;T&lt;/code&gt; command?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-05-01T05:38:49.230" Title="How to make comma and semi-colon direction-insensitive of the latest f,F,t,T command" Tags="|cursor-movement|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19805" PostTypeId="2" ParentId="19804" CreationDate="2019-05-01T05:38:49.230" Score="1" Body="&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; ; getcharsearch().forward ? ';':','&#xA;nnoremap &amp;lt;expr&amp;gt; , getcharsearch().forward ? ',':';'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;check &lt;code&gt;:h getcharsearch()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-05-01T05:38:49.230" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19807" PostTypeId="2" ParentId="93" CreationDate="2019-05-01T09:20:24.980" Score="3" Body="&lt;p&gt;A mapping I added to my .vimrc based on the answers here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; count nr of occurrences of word under cursor&#xA;nnoremap &amp;lt;leader&amp;gt;c :%s/&amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;//gn&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; count nr of occurrences of visual selection&#xA;vnoremap &amp;lt;leader&amp;gt;c :&amp;lt;c-u&amp;gt;%s/&amp;lt;c-r&amp;gt;*//gn&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A bit of explanation, hopefully helpful for newer vimmers:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; inserts the word under the cursor in the command line,&#xA;handy in many occasions.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; is needed to remove the automatically inserted &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt;&#xA;when pressing &lt;code&gt;:&lt;/code&gt; in visual mode and going to the command line. The&#xA;&lt;code&gt;*&lt;/code&gt; register contains the (last) visual selection, &lt;code&gt;&amp;lt;c-r&amp;gt;*&lt;/code&gt;&#xA;inserts the contents of the &lt;code&gt;*&lt;/code&gt; register in the command line (can also be&#xA;used in insert mode).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11614" LastEditorUserId="11614" LastEditDate="2019-05-01T09:35:15.400" LastActivityDate="2019-05-01T09:35:15.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19808" PostTypeId="1" AcceptedAnswerId="19809" CreationDate="2019-05-01T10:27:37.377" Score="0" ViewCount="238" Body="&lt;p&gt;I want to view the initial copy of the file in a separate window while I make changes to the same file in another window. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="4513" LastActivityDate="2019-05-01T12:56:04.667" Title="How to open same file in multiple window but with changes present only in one window?" Tags="|buffers|split|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19809" PostTypeId="2" ParentId="19808" CreationDate="2019-05-01T12:56:04.667" Score="2" Body="&lt;p&gt;As a workaround what you could do is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnew | execute(&quot;0read &quot; . @#)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vnew&lt;/code&gt; creates a new buffer in a vertical split&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;execute&lt;/code&gt; runs a string as an ex command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@#&lt;/code&gt; contains the file name of the alternate-file&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;read more at &lt;code&gt;:help alternate-file&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0read&lt;/code&gt; reads from a file into the first line of a file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're not making a custom command from this you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnew | 0read &amp;lt;C-r&amp;gt;&amp;lt;C-#&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both of these require the file to be saved&lt;/p&gt;&#xA;" OwnerUserId="22050" LastActivityDate="2019-05-01T12:56:04.667" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19810" PostTypeId="1" AcceptedAnswerId="19811" CreationDate="2019-05-01T13:39:19.320" Score="3" ViewCount="2112" Body="&lt;p&gt;Say I've got three splits open with code in, and I suddenly want to make the one I'm in fullscreen, temporarily. How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="13555" LastActivityDate="2019-05-05T12:37:17.910" Title="How can I focus on one vimsplit fullscreen?" Tags="|neovim|split|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19811" PostTypeId="2" ParentId="19810" CreationDate="2019-05-01T13:52:22.980" Score="8" Body="&lt;p&gt;When focused on it, run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabe %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To open a new tab with the same file. You can navigate tabs with &lt;code&gt;gT&lt;/code&gt; and &lt;code&gt;gt&lt;/code&gt; among other, if you want to go back to your split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you are done with it, on the &quot;fullscreen&quot; one, run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to close the tab (technically closes the focused window, which is the only one of the tab, and closing the last window of the tab closes the tab).&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-05-01T13:52:22.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19812" PostTypeId="1" CreationDate="2019-05-01T14:18:11.670" Score="0" ViewCount="144" Body="&lt;p&gt;Using vim 8.*, I am using these plugins:&#xA;html5.vim&#xA;polymer-ide.vim&#xA;supertab&#xA;vim-javascript&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my vimrc.local file if I enable &lt;code&gt;filetype plugin indent on&lt;/code&gt; it breaks my javaScript indention but makes the highlighting correct. However, if I remove that line then my indention works as it should for javaScript but the highlighting breaks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I have both the highlighting and indention working? &lt;/p&gt;&#xA;" OwnerUserId="15557" LastActivityDate="2019-05-01T14:20:31.100" Title="'filetype plugin indent on' breaks indention" Tags="|indentation|filetype-javascript|" AnswerCount="1" CommentCount="3" ClosedDate="2019-05-03T03:25:59.303" ContentLicense="CC BY-SA 4.0" />
  <row Id="19813" PostTypeId="2" ParentId="19812" CreationDate="2019-05-01T14:20:31.100" Score="1" Body="&lt;p&gt;What if you just enable the filetype plugin?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-05-01T14:20:31.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19814" PostTypeId="1" AcceptedAnswerId="19815" CreationDate="2019-05-01T14:35:25.933" Score="1" ViewCount="440" Body="&lt;p&gt;Suppose you have 5 lines in current buffer among others. You yank them using &lt;code&gt;5Y&lt;/code&gt;, make a new buffer with e.g. &lt;code&gt;tabe&lt;/code&gt;, and try to paste these 5 lines so that they are the only thing the new buffer would consist of. Yet if you use &lt;code&gt;p&lt;/code&gt;, you get an empty line before the lines pasted. If you use &lt;code&gt;P&lt;/code&gt;, you get an empty line after them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to paste without introducing extra lines and without doing fix-ups like &lt;code&gt;k&quot;_dd&lt;/code&gt; after &lt;code&gt;p&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1081" LastActivityDate="2019-05-01T14:37:13.343" Title="How to paste several lines to a new buffer without extra empty line?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19815" PostTypeId="2" ParentId="19814" CreationDate="2019-05-01T14:37:13.343" Score="4" Body="&lt;p&gt;Yes there is! I do this all the time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you paste in visual mode, the visual selection is &lt;em&gt;replaced&lt;/em&gt; with the contents of the register, so you end up replacing an empty line with what you wanted, and get no extra line. The only downside to this approach is that it will empty out your register, so you'll have to re-yank if you want to paste it several times.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-05-01T14:37:13.343" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19816" PostTypeId="2" ParentId="19810" CreationDate="2019-05-01T14:58:42.783" Score="4" Body="&lt;p&gt;If your splits are vertical you can press &lt;code&gt;Ctrl-w|&lt;/code&gt; to maximize the focused window.&#xA;If splits are horizontal then press &lt;code&gt;Ctrl-w_&lt;/code&gt;. To resize the splits press &lt;code&gt;Ctrl-w=&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="19211" LastEditorUserId="19211" LastEditDate="2019-05-05T12:37:17.910" LastActivityDate="2019-05-05T12:37:17.910" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19817" PostTypeId="1" CreationDate="2019-05-01T17:55:08.987" Score="0" ViewCount="82" Body="&lt;p&gt;I have set up &#xA;    set tabstop=2&#xA;    set lcs=tab&gt;.,trail=.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in .vimrc &#xA;when i open .txt files, tabs are displayed as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however when i open a .py file, tabs are displayed as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;.........&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have typed :tabstop=2 which works. How to make tabstop=2 activated by default?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set tabstop?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;results in &#xA;    tabstop=8&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .vimrc is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list&#xA;set tabstop=2&#xA;set listchars=eol:⏎,tab:␉·,trail:␠,nbsp:⎵&#xA;&#xA;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'davidhalter/jedi-vim'&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have only 1 plugin which is jedi-vim. Could that be the problem?&lt;/p&gt;&#xA;" OwnerUserId="22055" LastEditorUserId="22055" LastEditDate="2019-05-03T03:46:49.530" LastActivityDate="2019-05-03T03:46:49.530" Title="tabstop doesnt work by default in python files" Tags="|vimrc|filetype-python|plugin-python-mode|" AnswerCount="0" CommentCount="2" ClosedDate="2019-05-03T03:19:51.357" ContentLicense="CC BY-SA 4.0" />
  <row Id="19818" PostTypeId="2" ParentId="9631" CreationDate="2019-05-01T19:01:24.200" Score="0" Body="&lt;p&gt;I use vim installed by brew on a mac os 10.12.6. I'm currently coding in ruby.&#xA;In my case, a recent update to vim 8.1-153 caused a change in softtabstop and expandtabs.  Using the method above by Martin Tournoij I determined that this file controlled the settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/local/Cellar/macvim/8.1-153/MacVim.app/Contents/Resources/vim/runtime/ftplugin/ruby.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My attempts to override the settings in my ~/.gvimrc did not work.  I ended up modifying the installation's ruby.vim file (as above) which &lt;strong&gt;I did not want to do&lt;/strong&gt;.  Here is the code with changes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if get(g:, 'ruby_recommended_style', 1)&#xA;  setlocal shiftwidth=4 softtabstop=4 noexpandtab&#xA;  let b:undo_ftplugin .= ' | setl sw&amp;lt; sts&amp;lt; et&amp;lt;'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22056" LastActivityDate="2019-05-01T19:01:24.200" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19819" PostTypeId="1" CreationDate="2019-05-01T20:38:58.563" Score="1" ViewCount="257" Body="&lt;p&gt;I am trying to reproduce this vimscript code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! NormalRemap()&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; I I&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; a a&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; o o&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; O O&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; c c&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; C C&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; s s&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; S S&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; v v&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; V V&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; r r&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; R R&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; q q&#xA;endfunction&#xA;&#xA;function! NormalUnmap()&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; I &amp;lt;nop&amp;gt;&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; a &amp;lt;nop&amp;gt;&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; o &amp;lt;nop&amp;gt;&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; O &amp;lt;nop&amp;gt;&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; c &amp;lt;nop&amp;gt;&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; C &amp;lt;nop&amp;gt;&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; s &amp;lt;nop&amp;gt;&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; S &amp;lt;nop&amp;gt;&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; v &amp;lt;nop&amp;gt;&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; V &amp;lt;nop&amp;gt;&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; r &amp;lt;nop&amp;gt;&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; R &amp;lt;nop&amp;gt;&#xA;    :nnoremap &amp;lt;silent&amp;gt; &amp;lt;nowait&amp;gt; q &amp;lt;nop&amp;gt;&#xA;endfunction&#xA;&#xA;function! DoxyGenComment()&#xA;    :call NormalRemap()&#xA;    :Dox&#xA;    :call NormalUnmap()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(which works fine) with the following one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mymap = 1&#xA;&#xA;function! DoxyGenComment()&#xA;    let g:mymap = 0&#xA;    :Dox&#xA;    let g:mymap = 1&#xA;endfunction&#xA;&#xA;:nnoremap &amp;lt;expr&amp;gt; I (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 'I'&#xA;:nnoremap &amp;lt;expr&amp;gt; a (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 'a'&#xA;:nnoremap &amp;lt;expr&amp;gt; o (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 'o'&#xA;:nnoremap &amp;lt;expr&amp;gt; O (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 'O'&#xA;:nnoremap &amp;lt;expr&amp;gt; c (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 'c'&#xA;:nnoremap &amp;lt;expr&amp;gt; C (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 'C'&#xA;:nnoremap &amp;lt;expr&amp;gt; s (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 's'&#xA;:nnoremap &amp;lt;expr&amp;gt; S (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 'S'&#xA;:nnoremap &amp;lt;expr&amp;gt; v (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 'v'&#xA;:nnoremap &amp;lt;expr&amp;gt; V (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 'V'&#xA;:nnoremap &amp;lt;expr&amp;gt; r (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 'r'&#xA;:nnoremap &amp;lt;expr&amp;gt; R (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 'R'&#xA;:nnoremap &amp;lt;expr&amp;gt; q (mymap == 1) ? '&amp;lt;nop&amp;gt;' : 'q'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This last one doesn't work (&lt;code&gt;DoxygenToolkit.vim&lt;/code&gt; doesn't generate the correct comment syntax since it doesn't see the correct mapping).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is wrong in my second approach with conditional mapping ?&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="15254" LastEditDate="2019-05-01T20:44:32.853" LastActivityDate="2019-05-02T02:33:59.347" Title="Problem with conditional mapping &lt;expr&gt;" Tags="|key-bindings|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19820" PostTypeId="2" ParentId="19819" CreationDate="2019-05-02T02:33:59.347" Score="2" Body="&lt;p&gt;AFAIK, &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; should be used without &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;. If you want to use &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;, just return an empty string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; I (mymap == 1) ? '' : 'I'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By the way, you may consider to do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let forbiddens = 'IaoO.....'&#xA;for oper in split(forbiddens, '\zs')&#xA;  exec 'nnoremap ' . oper . ' &amp;lt;nop&amp;gt;'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-05-02T02:33:59.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19821" PostTypeId="2" ParentId="7924" CreationDate="2019-05-02T09:55:34.230" Score="2" Body="&lt;p&gt;What worked for me was the following lines in my &lt;code&gt;.vimrc&lt;/code&gt; (based on &lt;a href=&quot;https://vi.stackexchange.com/a/13213/22062&quot;&gt;Igor Mikushkin's answer&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead * call matchadd('SpecialKey', '\s\+')&#xA;autocmd BufNewFile,BufRead * call matchadd('NonText', '\n\+')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;VimEnter&lt;/code&gt; only works for the first file you open, not for files/tabs you open afterwards. &lt;code&gt;BufNewFile,BufRead&lt;/code&gt; has worked so far for all the buffers I've opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first line covers whitespace characters. Vim highlights them in the &lt;code&gt;SpecialKey&lt;/code&gt; group, so we apply those styles to them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second line covers newlines. Vim highlights them in the &lt;code&gt;NonText&lt;/code&gt; group, so we apply those styles to them. You only really need the second line if your &lt;code&gt;NonText&lt;/code&gt; characters are highlighted differently than &lt;code&gt;SpecialKey&lt;/code&gt; characters.&lt;/p&gt;&#xA;" OwnerUserId="22062" LastActivityDate="2019-05-02T09:55:34.230" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19822" PostTypeId="1" CreationDate="2019-05-02T12:33:15.113" Score="0" ViewCount="111" Body="&lt;p&gt;I often need to keep several directories synchronized across two or three machines. I will periodically run &lt;code&gt;diff -qr local/path mounted/remote/path &amp;gt; diff-list.txt&lt;/code&gt; to get a list of what is different and what is only present on either machine. After this runs, my current workflow is to cleanup the &quot;diff output&quot; then set about doing manual comparisons between the local and remote files. I cannot fully automate the synchronization or &quot;merge&quot; operation; some files &lt;em&gt;need&lt;/em&gt; to be different and will always show up as part of the diff. (That's OK.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a sample line from my diff file ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Files /home/seokor/root/src/bin/pasteboard/test/sok-info/swap.c and /mnt/diakor/root/src/bin/pasteboard/test/sok-info/swap.c differ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pain point is this: My current workflow has &lt;code&gt;diff-list.txt&lt;/code&gt; opened in VIM in one tmux window and a &lt;code&gt;vimdiff&lt;/code&gt; of the two files in question opened in another tmux window. I review the differences, resolve conflicts (merge, copy/replace, ignore, ... whatever). Then I quit the &lt;code&gt;vimdiff&lt;/code&gt; session, go back to tmux window 0, get the next pair of files, go back to tmux window 1, run &lt;code&gt;vimdiff&lt;/code&gt; on this new pair of files ... rinse and repeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to have this: A single VIM session with three panes: left is &lt;code&gt;diff-list.txt&lt;/code&gt;, middle and right are &lt;code&gt;vimdiff&lt;/code&gt;-ish. As I cursor up/down in the left-most pane (the listing), when I hit &lt;code&gt;&amp;lt;RETURN&amp;gt;&lt;/code&gt; (or some other mapping), I'd like the current line to be parsed (to extract the two file paths) and have the middle and right panes updated to open the two files then refresh the diff. Think of this as a &quot;diff browser.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've played a little bit with the idea and I managed to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -O -c 'wincmd l | diffthis | wincmd l | diffthis | 2wincmd h' f1 f2 f3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, files &lt;code&gt;f[123]&lt;/code&gt; are just for experimenting, but &lt;code&gt;f1&lt;/code&gt; would be &lt;code&gt;diff-list.txt&lt;/code&gt; and &lt;code&gt;f2&lt;/code&gt; and &lt;code&gt;f3&lt;/code&gt; would be pulled from the list's current line. (This test was to see if I could open VIM with three buffers and have only two of them operate as a &lt;code&gt;vimdiff&lt;/code&gt;. And it works.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question: Can this be done? Can a vimscript be written that is attached only to a specific buffer (in this case, the &quot;diff listing&quot; buffer on the left)? Can a vimscript, after parsing the buffer's line to extract file names, &quot;push&quot; those file names to the other two buffers (ostensibly closing the previous files and opening the new ones), then force a diff update?&lt;/p&gt;&#xA;" OwnerUserId="9987" LastEditorUserId="9987" LastEditDate="2019-06-03T11:27:45.787" LastActivityDate="2019-06-03T11:27:45.787" Title="Can I script VIM to process a list of diffs?" Tags="|vimscript|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19823" PostTypeId="1" AcceptedAnswerId="19824" CreationDate="2019-05-02T14:20:53.587" Score="4" ViewCount="576" Body="&lt;p&gt;&lt;code&gt;:1&lt;/code&gt; jumps to the first line, &lt;code&gt;:$&lt;/code&gt; jumps to the last line, &lt;code&gt;:+&lt;/code&gt; jumps to the next line, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems to me that there is a default &lt;code&gt;ex&lt;/code&gt; command which accepts a range and jumps to it: what's the name of this ex command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where can I find it in vim help? I guessed it might be in &lt;code&gt;various.txt&lt;/code&gt;, but I can't find it.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="10604" LastEditDate="2019-05-02T15:21:59.740" LastActivityDate="2019-05-03T01:07:02.613" Title="Where is the documentation for this ex command?" Tags="|cmdline|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19824" PostTypeId="2" ParentId="19823" CreationDate="2019-05-02T15:19:19.017" Score="8" Body="&lt;p&gt;This command has no name, but is simply the default behavior of the ex (and, notably, ed). Given a range, which may be one of the special sequences you mentioned, or a search, or even just a plain line number (e.g., &lt;code&gt;:42&lt;/code&gt;), ex will jump to that spot in the file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does, however, have a place in the doc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help :[range]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As requested, an in-depth look at my help-searching process:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;man ex&lt;/code&gt;: Always a good start. This took me to the &lt;code&gt;vim&lt;/code&gt; man-page, which more or less points to the online help&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;man ed&lt;/code&gt;: Remembering that &lt;code&gt;ex&lt;/code&gt; descends from &lt;code&gt;ed&lt;/code&gt;, I thought I'd try here. I'm not sure if the behavior is documented there, but it was worth a shot&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help ex&lt;/code&gt; led to &lt;code&gt;:help Ex-mode&lt;/code&gt;, neither of which were helpful&lt;/li&gt;&#xA;&lt;li&gt;Remembering something about viusage and exusage, I tried &lt;code&gt;:help exusage&lt;/code&gt;: an interesting command to run&lt;/li&gt;&#xA;&lt;li&gt;I didn't see a range-based command in the index... hm. What about &lt;code&gt;:help range&lt;/code&gt;? Took me to a useful page, but not quite there&lt;/li&gt;&#xA;&lt;li&gt;Ok, commands taking ranges are documented like &lt;code&gt;:[range]command&lt;/code&gt;, so maybe &lt;code&gt;:help [range]&lt;/code&gt;: Not quite, that's just above where we were&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :[range]&lt;/code&gt;: at long last.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(This is slightly exaggerated: in reality, post-exusage I jumped straight to &lt;code&gt;:help :[range]&lt;/code&gt; because that's the syntax of the command. It was a lucky guess.)&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-05-03T01:07:02.613" LastActivityDate="2019-05-03T01:07:02.613" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="19825" PostTypeId="1" AcceptedAnswerId="19831" CreationDate="2019-05-02T21:27:59.573" Score="1" ViewCount="275" Body="&lt;p&gt;On windows I use gvim, and like to keep just one gvim instance running. Most of the time I open files like this:&#xA;&lt;code&gt;gvim -p --remote-tab-silent FILES&lt;/code&gt;.&#xA;However, sometimes I want to open a tag in that same remote gvim server in a new tab. If I do&#xA;&lt;code&gt;gvim -t MYFUNCTION --remote-tab-silent&lt;/code&gt; it tells me it wants a file name after the last argument.&#xA;If I do &lt;code&gt;gvim --remote-tab-silent -t MYFUNCTION&lt;/code&gt; it opens a new tab with a split window with two files, one named literally &lt;code&gt;-t&lt;/code&gt; and the other named &lt;code&gt;MYFUNCTION&lt;/code&gt;.&#xA;I've also tried using &lt;code&gt;--&lt;/code&gt; to end the arguments list, but then I end up editing a file named &lt;code&gt;--&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I open a tag in my existing gvim instance?&lt;/p&gt;&#xA;" OwnerUserId="22071" LastActivityDate="2019-06-02T20:00:33.000" Title="How do I open a tag in an existing gvim instance?" Tags="|gvim|tags|clientserver|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19826" PostTypeId="1" CreationDate="2019-05-03T00:05:47.670" Score="1" ViewCount="54" Body="&lt;p&gt;When viewing a merge candidate created by git you will have something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;. . .&#xA;Some stuff not in conflict&#xA;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD  &#xA;Some stuff  &#xA;======&#xA;Something different&#xA;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; devel&#xA;Some more stuff not in conflict&#xA;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&#xA;. . .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For me at least, Vim tries to fold out the conflict so it looks like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;. . .&#xA;Some stuff not in conflict&#xA;[fold here][&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD]&#xA;Some more stuff not in conflict&#xA;[another fold][&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD]&#xA;. . .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't really care about the stuff not in conflict. I'm looking at the file because I want to resolve the conflict which means I need to look at it. Instead &lt;code&gt;Some stuff not in conflict&lt;/code&gt; and &lt;code&gt;Some more stuff not in conflict&lt;/code&gt; should be folded out so I can focus on the conflicts. In other words, I want the exact opposite. Preferably, I'd like some context, but I'll take what I can get.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set foldmethod? foldexpr? syntax? filetype?&#xA;foldmethod=manual&#xA;        Last set from /usr/share/vim/vimfiles/plugin/SyntaxFolds.vim line 134&#xA;  foldexpr=0&#xA;  syntax=tex&#xA;        Last set from /usr/share/vim/vim81/syntax/syntax.vim line 32&#xA;  filetype=tex&#xA;        Last set from /usr/share/vim/vim81/autoload/dist/ft.vim line 695&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18462" LastEditorUserId="18462" LastEditDate="2019-05-03T02:00:12.643" LastActivityDate="2019-05-03T02:00:12.643" Title="Folding for git merge candidates is (at least to me) backwards" Tags="|git|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19827" PostTypeId="2" ParentId="6112" CreationDate="2019-05-03T08:58:11.663" Score="1" Body="&lt;p&gt;I can't answer much of that but one point that I don't see mentioned, and re answering an interpretation of what is in the title&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I get Vim to ignore all user configuration, as if it were&#xA;  freshly installed?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;some have suggested &lt;code&gt;vim -u NONE&lt;/code&gt;  or &lt;code&gt;vim -u NORC&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;that's in some ways a bit more barebones than just no vimrc file. When I type 'i', it doesn't say 'insert'.  You may want it to still say 'insert'.  If you started vim with your vimrc file blank then it would show insert&lt;/p&gt;&#xA;&#xA;&lt;p&gt;that's because vim loads a default config first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can point vim to that default file to get the effect of your vimrc file being blank. Check that you have &lt;code&gt;/etc/vim/vimrc&lt;/code&gt;,  and you can do &lt;code&gt;vim -u /etc/vim/vimrc&lt;/code&gt;   or on osx, the default file is &lt;code&gt;/usr/share/vim/vicmrc&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="22080" LastActivityDate="2019-05-03T08:58:11.663" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19828" PostTypeId="1" AcceptedAnswerId="19894" CreationDate="2019-05-03T09:43:09.330" Score="2" ViewCount="880" Body="&lt;p&gt;I have been trying to make UltiSnips work with VimWiki to no avail, as they share mappings for expand snippet/next link (on &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried setting VimWiki's bindings to something else by using the following, which sadly didn't work, as the snippets didn't expand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vimwiki plugin settings&#xA;filetype plugin on&#xA;let g:vimwiki_list = [{'path': '~/Wiki/', 'syntax': 'markdown', 'ext': '.md'}]&#xA;nmap &amp;lt;C-j&amp;gt; &amp;lt;Plug&amp;gt;VimwikiNextLink&#xA;nmap &amp;lt;C-k&amp;gt; &amp;lt;Plug&amp;gt;VimwikiPrevLink&#xA;&#xA;&quot; ultisnips plugin settings&#xA;let g:UltiSnipsSnippetsDir=$HOME.'/.vim/UltiSnips/'&#xA;let g:UltiSnipsSnippetDirectories=[&quot;UltiSnips&quot;]&#xA;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;s-tab&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The link to my entire vimrc can be found &lt;a href=&quot;https://pastebin.com/raw/nB795hDp&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I set UltiSnips' expand trigger to anything else (like &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt;), it works without a problem, but I am quite used to expanding on &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; from other apps that I use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything I can do to fix this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="22081" LastActivityDate="2020-04-29T20:18:53.523" Title="UltiSnips not working with VimWiki" Tags="|vimrc|plugin-ultisnips|plugin-vimwiki|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19829" PostTypeId="1" CreationDate="2019-05-03T14:52:47.313" Score="0" ViewCount="48" Body="&lt;p&gt;For some reason, my html elements stop being highlighted when they are preceded by 4 or more spaces.  I use spaces to do indentation for nested elements, so this is quite unfortunate.  This only happens for &lt;code&gt;.md&lt;/code&gt; files, and not &lt;code&gt;.html&lt;/code&gt; files, though.  How can I insist that vim highlight my html elements in markdown files regardless of leading spaces?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;system: Ubuntu 16.04&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim: version 7.4.1689 (from the repos)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PI3sp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PI3sp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22086" LastEditorUserId="1841" LastEditDate="2019-05-03T14:56:32.643" LastActivityDate="2019-05-03T14:57:01.583" Title="markdown html-element syntax highlighting fails when line has leading spaces" Tags="|syntax-highlighting|filetype-markdown|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19830" PostTypeId="2" ParentId="19829" CreationDate="2019-05-03T14:57:01.583" Score="2" Body="&lt;p&gt;4 spaces or more are considered as a CodeBlock, which probably why these are not highlighted.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-05-03T14:57:01.583" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19831" PostTypeId="2" ParentId="19825" CreationDate="2019-05-03T19:54:14.363" Score="1" Body="&lt;p&gt;I tweaked an example  which Ralf mentioned in the comments to get this:&#xA;&lt;code&gt;gvim --server=$SERVER --remote-send &quot;:execute('tab tag $tag')&amp;lt;CR&amp;gt;&quot;&lt;/code&gt;&#xA;Remote send sends the following commands to the gvim server. &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is the return character.&lt;/p&gt;&#xA;" OwnerUserId="22071" LastActivityDate="2019-05-03T19:54:14.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19832" PostTypeId="2" ParentId="14356" CreationDate="2019-05-03T20:21:59.180" Score="3" Body="&lt;p&gt;The patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.1256&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.1256&lt;/a&gt; has just added the commands &lt;code&gt;:cabove&lt;/code&gt;, &lt;code&gt;:cbelow&lt;/code&gt;, &lt;code&gt;:labove&lt;/code&gt; and &lt;code&gt;:lbelow&lt;/code&gt;, which, I think, do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As usual, the commands prefixed by &lt;code&gt;c&lt;/code&gt; operate on a quickfix list, and the ones prefixed by &lt;code&gt;l&lt;/code&gt; operate on a location list. And here, &lt;code&gt;above&lt;/code&gt; makes the cursor jump to the previous entry, while &lt;code&gt;below&lt;/code&gt; makes it jump to the next one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The commands accept a count, so you can skip some entries when you jump.&#xA;For example, &lt;code&gt;:3cbelow&lt;/code&gt; should make you jump to the third entry after your current position.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There are some caveats though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The entries in the quickfix list must be sorted by their buffer number and line number. I think Vim's default commands – which populate a quickfix list – do that by default, like &lt;code&gt;:vimgrep&lt;/code&gt; and &lt;code&gt;:helpgrep&lt;/code&gt;; but it may not be the case with a quickfix list populated by a custom command (provided by a third-party plugin for example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if several entries are on the same line, it seems that only the first one is considered.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Relevant help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        *:cabo* *:cabove*&#xA;:[count]cabo[ve]        Go to the [count] error above the current line in the&#xA;                        current buffer.  If [count] is omitted, then 1 is&#xA;                        used.  If there are no errors, then an error message&#xA;                        is displayed.  Assumes that the entries in a quickfix&#xA;                        list are sorted by their buffer number and line&#xA;                        number. If there are multiple errors on the same line,&#xA;                        then only the first entry is used.  If [count] exceeds&#xA;                        the number of entries above the current line, then the&#xA;                        first error in the file is selected.&#xA;&#xA;                                                        *:lab* *:labove*&#xA;:[count]lab[ove]        Same as &quot;:cabove&quot;, except the location list for the&#xA;                        current window is used instead of the quickfix list.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2019-05-03T20:21:59.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19833" PostTypeId="1" CreationDate="2019-05-03T22:58:32.000" Score="1" ViewCount="25" Body="&lt;p&gt;How can I run a specific vimrc file after running the default one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(i.e. run the default one, then one of my choosing)&lt;/p&gt;&#xA;" OwnerUserId="22080" LastActivityDate="2019-05-03T22:59:16.383" Title="How can I run a specific vimrc file after running the default one?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19834" PostTypeId="2" ParentId="19833" CreationDate="2019-05-03T22:59:16.383" Score="1" Body="&lt;p&gt;A vim expert suggested &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;-u&lt;/code&gt; and &lt;code&gt;-S&lt;/code&gt; arguments: &lt;code&gt;$ vim -u myvimrc.vim -S some_script.vim&lt;/code&gt;; or just &lt;code&gt;-S&lt;/code&gt;: &lt;code&gt;$ vim -S some_script.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and that works&lt;/p&gt;&#xA;" OwnerUserId="22080" LastActivityDate="2019-05-03T22:59:16.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19835" PostTypeId="1" CreationDate="2019-05-04T00:52:57.027" Score="2" ViewCount="268" Body="&lt;p&gt;Is there an autocommand that is triggered when an error occurs (a Vim error of the type E###)? A try/catch block isn't enough because I need it at a more global level.&lt;/p&gt;&#xA;" OwnerUserId="16351" LastActivityDate="2019-06-05T12:01:16.377" Title="Trigger autocommand on error?" Tags="|autocmd|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19836" PostTypeId="1" CreationDate="2019-05-04T06:14:28.797" Score="4" ViewCount="1721" Body="&lt;p&gt;I've opened an empty buffer with just &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a shell script in the same directory that I can pipe SQL to. That script will print the result of the execution to stdout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my empty buffer, I wrote the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;select * from foo;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to pass the entire contents of the file over to my script, &lt;code&gt;exec-sql.sh&lt;/code&gt;, then append the stdout of the shell script back into my buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this first.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% !exec-sql.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This replaced the contents of my buffer with the result of the SQL query. Not what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I tried this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;w !exec-sql.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This didn't replace the SQL query in by buffer, but it also didn't append the result of the query to my buffer. This also isn't what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want both the query and the result to end up in my buffer like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;select * from foo;&#xA;id&#xA;---&#xA;1&#xA;2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this in vanilla Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&#xA;I'd also like to just select a range to pass to &lt;code&gt;exec-sql.sh&lt;/code&gt;, maybe by selecting some SQL statements in visual mode and piping just those statements.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt; !exec-sql.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to keep the selected lines, while also appending the result of executing the SQL commands right below the selected lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;exec-sql.sh&lt;/code&gt; doesn't read files. You must pipe data to it. In the regular shell I have to do this: &lt;code&gt;cat my.sql | exec-sql.sh&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know how to do a regular read from an external command. But I want to do a write first, then a read. Write to the external command's stdin and then read from the external command's stdout.&lt;/p&gt;&#xA;" OwnerUserId="22095" LastEditorUserId="22095" LastEditDate="2019-05-04T17:59:16.557" LastActivityDate="2023-11-20T01:02:17.327" Title="Write buffer to command and append stdout back to same buffer" Tags="|external-command|shell|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19837" PostTypeId="2" ParentId="19836" CreationDate="2019-05-04T07:42:11.633" Score="2" Body="&lt;p&gt;Two methods you tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;% !exec-sql.sh&lt;/code&gt;&#xA;&lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Arange%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :range!&lt;/a&gt; filter {range} lines through the external program. also  check &lt;a href=&quot;https://vimhelp.org/change.txt.html#%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h !&lt;/a&gt; .&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w !exec-sql.sh&lt;/code&gt;&#xA;&lt;a href=&quot;https://vimhelp.org/editing.txt.html#%3Aw_c&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :w_c&lt;/a&gt; execute {cmd} with [range] lines as standard input.&lt;br&gt;&#xA;Beware that &lt;code&gt;w !&lt;/code&gt; and &lt;code&gt;w!&lt;/code&gt; have total different meaning.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want to read external command output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :read !exec-sql.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/insert.txt.html#%3Aread%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :read!&lt;/a&gt; execute {cmd} and insert its standard output below the cursor or the specified line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to pass file name to external command, add &lt;code&gt;%&lt;/code&gt; to the end, it will be replaced with current filename.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:read !exec-sql.sh %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that external command knows nothing about vim buffer, you need to save it before you execute above command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use buffer content as input for external command and add the output to the end of the buffe ( doesn't work well on vim8, see update ):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:$put =execute('%w !exec-sql.sh')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%&lt;/code&gt; is default range of &lt;code&gt;:w&lt;/code&gt;, Replace it with whatever rang you like. check &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Aput&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :put&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At last you can create a map to send selected lines to external command and add the output to the end of the buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;leader&amp;gt;ex :&amp;lt;c-u&amp;gt;$put =execute('''&amp;lt;,''&amp;gt;w !exec-sql.sh')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;also check &lt;a href=&quot;https://vim.fandom.com/wiki/Append_output_of_an_external_command&quot; rel=&quot;nofollow noreferrer&quot;&gt;wiki&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Aput&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :put&lt;/a&gt; Put the text [from register x] after [line], &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%27%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h '&gt;&lt;/a&gt; marks the end of your selection, to output after selected lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;leader&amp;gt;ex :&amp;lt;c-u&amp;gt;'&amp;gt;put =execute('''&amp;lt;,''&amp;gt;w !exec-sql.sh')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are always 2 leading blank lines in the output, if that bothers you, use&#xA;&lt;a href=&quot;https://vimhelp.org/motion.txt.html#%27%5B&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h '[&lt;/a&gt; to move to there, and change it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;leader&amp;gt;ex :&amp;lt;c-u&amp;gt;'&amp;gt;put =execute('''&amp;lt;,''&amp;gt;w !exec-sql.sh')&amp;lt;cr&amp;gt;'[cj--------&amp;lt;esc&amp;gt;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just tested this on vim8.1, include patches 1-1142,  &lt;code&gt;execute()&lt;/code&gt; doesn't read output form &lt;code&gt;:w !&lt;/code&gt; style command, &lt;code&gt;redir&lt;/code&gt; doesn't work neither. Not sure if it's a bug.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-05T05:17:11.213" LastActivityDate="2019-05-05T05:17:11.213" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19838" PostTypeId="2" ParentId="19836" CreationDate="2019-05-04T11:03:02.483" Score="0" Body="&lt;p&gt;Based on my answer to a &lt;a href=&quot;https://vi.stackexchange.com/questions/19235/how-to-execute-selected-lines-in-bash-and-print-the-output-in-the-next-line&quot;&gt;similar question&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap _X  :put =\&quot;---\n\&quot; . system('exec-sql.sh', getline('.'))&amp;lt;cr&amp;gt;&#xA;vnoremap _X  :&amp;lt;C-U&amp;gt;'&amp;gt;put =\&quot;---\n\&quot; . system('exec-sql.sh', getline('''&amp;lt;','''&amp;gt;'))&amp;lt;cr&amp;gt;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first mapping is to execute a single line. Just put the cursor in the line and hit &lt;code&gt;_X&lt;/code&gt;. This takes the current line (&lt;code&gt;getline(&quot;.&quot;)&lt;/code&gt;) and uses it as stdin for the execution of &lt;code&gt;exec-sql.sh&lt;/code&gt;. The resulting output is put below the current line with a divider &lt;code&gt;---&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The visual mode mapping works similar, but &lt;code&gt;getline('''&amp;lt;', '''&amp;gt;')&lt;/code&gt; fetches the list of selected lines and feeds it to &lt;code&gt;exec-sql.sh&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-05-04T11:03:02.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19839" PostTypeId="1" CreationDate="2019-05-04T11:04:57.033" Score="1" ViewCount="158" Body="&lt;p&gt;Vim manual says: &lt;em&gt;&quot;The $MYVIMRC environment variable is set to the file that was first found, unless $MYVIMRC was already set and when using VIMINIT.&quot;&lt;/em&gt; Does this also mean that setting of $MYVIMRC (e.g. in the system vimrc) causes automatically its execution as private vimrc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following in my system vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $VIMFILES=$HOME.&quot;/Programs/Vim&quot;&#xA;let $MYVIMRC=$VIMFILES.&quot;/vimrc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it didn't work. I had to add the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $VIMINIT=&quot;source &quot;.$MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, this worked. So my question is if I misunderstood the cited sentence from the manual or else what I have to do to make it work &lt;em&gt;without&lt;/em&gt; the extra line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Johannes&lt;/p&gt;&#xA;" OwnerUserId="22097" LastEditorUserId="22097" LastEditDate="2019-05-04T14:20:40.147" LastActivityDate="2019-05-04T14:20:40.147" Title="Does explicit setting of $MYVIMRC imply its execution as private vimrc?" Tags="|vimrc|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19840" PostTypeId="2" ParentId="19835" CreationDate="2019-05-04T16:15:21.040" Score="1" Body="&lt;p&gt;No, there is no such autocommand event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might simulate something with custom autocmd events. Like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd User MyErrorEvent  call MyErrorHandler()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and somewhere in the code you could trigger that autocmd with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;doautocmd User MyErrorEvent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-05-04T16:15:21.040" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19841" PostTypeId="1" AcceptedAnswerId="19842" CreationDate="2019-05-04T19:11:56.773" Score="2" ViewCount="637" Body="&lt;p&gt;By default, vim lets you type 5G (5 then shift + g) to go to line 5. Instead, I don't want to have to press the shift key. Pressing &lt;code&gt;&amp;lt;S-g&amp;gt;&lt;/code&gt; does something different than just &lt;code&gt;5&amp;lt;S-g&amp;gt;&lt;/code&gt;. How can I remap a command that takes a number for repeated executions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like: &lt;code&gt;nnoremap &amp;lt;number&amp;gt;g &amp;lt;number&amp;gt;G&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="22104" LastActivityDate="2019-05-05T22:49:53.667" Title="How to remap repeating commands i.e. &lt;number&gt;&lt;command&gt;?" Tags="|key-bindings|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19842" PostTypeId="2" ParentId="19841" CreationDate="2019-05-04T19:57:59.887" Score="5" Body="&lt;pre&gt;&lt;code&gt;nnoremap g G&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this will not work well, as there are a lot of key mapping beginning with &lt;code&gt;g&lt;/code&gt;. So Vim has to wait a timeout (default 1000 msec) to be sure that no other key is pressed after the &lt;code&gt;g&lt;/code&gt;. The &lt;code&gt;g&lt;/code&gt; could be the start of 'gg' or 'g$' or ... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So after you pressed &lt;code&gt;5g&lt;/code&gt; nothing will happen for one second. Than the cursor jumps to line 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to know about the other key mappings starting with 'g' just enter ':help g' and then hit &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;. Lots of stuff.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-05-04T19:57:59.887" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19843" PostTypeId="1" AcceptedAnswerId="19844" CreationDate="2019-05-04T21:11:10.000" Score="0" ViewCount="537" Body="&lt;p&gt;When viewing a directory (using &lt;code&gt;:Explore&lt;/code&gt;, for example), I would like to see line numbers. I can run &lt;code&gt;:set number&lt;/code&gt; after opening the directory, and that works, but I can't get &lt;code&gt;number&lt;/code&gt;ing to turn on by default (using e.g. configuration in my &lt;code&gt;.vimrc&lt;/code&gt; file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried adding variations of the following to my &lt;code&gt;.vimrc&lt;/code&gt; file, but none seem to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd FileType netrw set number&#xA;:autocmd FileType * setlocal number&#xA;:autocmd BufEnter * setlocal number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a reference to a &lt;a href=&quot;https://stackoverflow.com/a/37807995/4256346&quot;&gt;similar question&lt;/a&gt; regarding numbering for help files. The solution to that question does not work in this case.&lt;/p&gt;&#xA;" OwnerUserId="5803" LastActivityDate="2019-05-04T23:52:51.917" Title="Enable line numbering for directories" Tags="|vimrc|autocmd|netrw|line-numbers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19844" PostTypeId="2" ParentId="19843" CreationDate="2019-05-04T23:52:51.917" Score="2" Body="&lt;p&gt;According to &lt;code&gt;:help netrw&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; *g:netrw_bufsettings*  the settings that netrw buffers have&#xA;            (default) noma nomod nonu nowrap ro nobl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I would try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; $MYVIMRC&#xA;let g:netrw_bufsettings = 'noma nomod nu nowrap ro nobl'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can also be found at &lt;code&gt;:help netrw-P19&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-05-04T23:52:51.917" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19845" PostTypeId="1" AcceptedAnswerId="19846" CreationDate="2019-05-05T01:10:07.320" Score="0" ViewCount="26" Body="&lt;p&gt;I'm getting one or more of these message when I open up a file I fold with a custom &lt;code&gt;foldexpr&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Pattern not found: lastlevel = -1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what's generating except the &lt;code&gt;lastlevel&lt;/code&gt; variable is used in my fold function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:lastlevel=0&#xA;function! Fold(lnum)&#xA;  &quot; is line blank?&#xA;  if getline(a:lnum) =~? '\v^\s*$'&#xA;     if GetLevel(a:lnum + 1)&#xA;         g:lastlevel = -1&#xA;         return -1&#xA;     endif&#xA;     return g:lastlevel&#xA;  endif&#xA;  let last = g:lastlevel&#xA;  let num_of_pounds = GetLevel(a:lnum)&#xA;  if (num_of_pounds &amp;gt; 0)&#xA;     let g:lastlevel = num_of_pounds&#xA;     return '&amp;gt;' . num_of_pounds&#xA;  endif&#xA;  return g:lastlevel&#xA;endfunction&#xA;&#xA;function! GetLevel(lnum)&#xA;  let pounds = strlen(matchstr(getline(a:lnum), '^#\+'))&#xA;  return pounds&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also have this related autocommand:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup persist_markdown_folds&#xA;au!&#xA;autocmd BufWinLeave *.md mkview&#xA;autocmd BufWrite *.md mkview&#xA;autocmd BufEnter *.md set foldenable | set foldlevel=0 | set foldmethod=expr | set foldexpr=Fold(v:lnum) | loadview&#xA;autocmd BufNewFile *.md set foldenable | set foldlevel=0 | set foldmethod=expr | set foldexpr=Fold(v:lnum)&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2019-05-05T01:23:48.263" Title="Pattern not found: lastlevel = -1" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19846" PostTypeId="2" ParentId="19845" CreationDate="2019-05-05T01:23:48.263" Score="1" Body="&lt;pre&gt;&lt;code&gt;g:lastlevel = -1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let&lt;/code&gt; is missing. I suggest you use syntactic check plugin such as &lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ale&lt;/a&gt; or &lt;a href=&quot;https://github.com/vim-syntastic/syntastic&quot; rel=&quot;nofollow noreferrer&quot;&gt;syntastic&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-05-05T01:23:48.263" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19847" PostTypeId="2" ParentId="19836" CreationDate="2019-05-05T04:25:53.687" Score="0" Body="&lt;p&gt;One way to cheat is to duplicate the line I want to execute and replace the duplicate with the output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My file starts off like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// notes.txt&#xA;select * from foo;&#xA;select * from foo;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, I highlight the second &lt;code&gt;select&lt;/code&gt; statement in visual mode and do this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt; !exec-sql.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which leaves me with this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// notes.txt&#xA;select * from foo;&#xA;id&#xA;---&#xA;1&#xA;2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is exactly what I want.&lt;/p&gt;&#xA;" OwnerUserId="22095" LastActivityDate="2019-05-05T04:25:53.687" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19849" PostTypeId="1" AcceptedAnswerId="19850" CreationDate="2019-05-05T08:47:39.503" Score="10" ViewCount="4160" Body="&lt;p&gt;For example, what's the difference between calling this command this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * call StripTrailingWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vs. this way (with the bang after &lt;code&gt;autocmd&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufWritePre * call StripTrailingWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20048" LastActivityDate="2019-05-05T11:06:18.963" Title="What's the difference between autocmd {cmd} and autocmd! {cmd}" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19850" PostTypeId="2" ParentId="19849" CreationDate="2019-05-05T09:13:03.597" Score="10" Body="&lt;p&gt;The command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufWritePre * call StripTrailingWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Removes all autocmds for the event &lt;code&gt;BufWritePre&lt;/code&gt; and the file pattern &lt;code&gt;*&lt;/code&gt; from the &lt;em&gt;default&lt;/em&gt; autocmd-group and sets a new autocmd for this event and pattern to call &lt;code&gt;StripTrailingWhitespace()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * echomsg &quot;First&quot;&#xA;autocmd BufWritePre * echomsg &quot;Second&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you then enter &lt;code&gt;:autocmd BufWritePre&lt;/code&gt; you will get the following (plus maybe other autocmds defined for this event):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Autocommands ---&#xA;BufWrite&#xA;    *         echomsg &quot;First&quot;&#xA;              echomsg &quot;Second&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you execute &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufWritePre * echomsg &quot;Third&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;followed by &lt;code&gt;:autocmd BufWritePre&lt;/code&gt; and you get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Autocommands ---&#xA;BufWrite&#xA;    *         echomsg &quot;Third&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the autocmds echoing &quot;First&quot; and &quot;Second&quot; were removed and the new autocmd echoing &quot;Third&quot; was defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help autocmd-remove&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-05-05T11:06:18.963" LastActivityDate="2019-05-05T11:06:18.963" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19851" PostTypeId="2" ParentId="19841" CreationDate="2019-05-05T09:22:20.517" Score="3" Body="&lt;p&gt;Even though OP accepted the existing answer this feels incomplete to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, the answer has a well-considered warning about remapping &lt;code&gt;g&lt;/code&gt; but there&#xA;is no mention of &lt;code&gt;&amp;lt;count&amp;gt;gg&lt;/code&gt; as a &lt;em&gt;near-synonym&lt;/em&gt; for &lt;code&gt;&amp;lt;count&amp;gt;G&lt;/code&gt;. (They differ only when the count is omitted. By default &lt;code&gt;gg&lt;/code&gt; goes to the first line and &lt;code&gt;G&lt;/code&gt; to the last.). Perhaps entering &lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt; is less annoying to OP than &lt;kbd&gt;5&lt;/kbd&gt; &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;G&lt;/kbd&gt; and we have a nice, easy workaround...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other thing that feels unaddressed is the subject of the question which is notably more generic than what has actually been discussed. It happens to be a good question, about applying a repeat count to a mapped command, but folks who come here from google will have to keep looking if it's not answered. So...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From Normal mode, if one precedes a command with a count and that command enters a vimscript/ex context we can retrieve the count from that context with the built-in variable &lt;code&gt;v:count&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll use it in an example applicable to the more specific question we've been addressing...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap XX :&amp;lt;C-U&amp;gt;exe 'norm! ' . v:count . 'G'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In place of &lt;code&gt;XX&lt;/code&gt; choose any key or keys you like better than &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;G&lt;/kbd&gt; and this will&#xA;give you a replacement for &lt;code&gt;&amp;lt;count&amp;gt;G&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;FYI about the use of &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; (see &lt;code&gt;:h c_CTRL-U&lt;/code&gt;): this is required to clear the command line before the mapped command is applied. Normally when we enter a number followed by &lt;code&gt;:&lt;/code&gt; the command line is pre-populated with a line range. In this case we don't want that.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-05-05T22:49:53.667" LastActivityDate="2019-05-05T22:49:53.667" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19852" PostTypeId="1" CreationDate="2019-05-05T13:03:39.610" Score="1" ViewCount="206" Body="&lt;p&gt;I recently started a transition from &lt;code&gt;vim&lt;/code&gt; to &lt;code&gt;neovim&lt;/code&gt; and one of the things that I noticed that changed is that typing &lt;code&gt;:!&lt;/code&gt; doesn't do anything in &lt;code&gt;neovim&lt;/code&gt; but in &lt;code&gt;vim&lt;/code&gt; it displays the content of the terminal before vim was launched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turn out that I use this feature quiet often.&#xA;does anyone know how can I get the same result in &lt;code&gt;neovim&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="496" LastActivityDate="2019-05-05T13:03:39.610" Title="Using ! (filter command) just to see the terminal behind vim" Tags="|neovim|filter|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19853" PostTypeId="1" AcceptedAnswerId="19859" CreationDate="2019-05-05T14:21:28.573" Score="1" ViewCount="69" Body="&lt;p&gt;I wrote a function for selecting a text region and replacing in it certain predefined characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! Tstrepl() range&#xA;    s/\%Va/\=&quot;\u2227&quot;/ge  &quot; 'a' to '∧'&#xA;    s/\%Vb/\=&quot;\u2228&quot;/ge  &quot; 'b' to '∨'&#xA;endfun&#xA;&#xA;vnoremap QQ :call Tstrepl()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that the function doesn't behave as expected and I cannot figure out why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following text is handled OK:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BEFORE: bbbaaa&#xA;AFTER: ∨∨∨∧∧∧&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But another text isn't handled OK:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BEFORE: aaabbb&#xA;AFTER: ∧∧∧bbb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's wrong with the function?&lt;/p&gt;&#xA;" OwnerUserId="1378" LastActivityDate="2019-05-06T00:02:13.080" Title="Replacement in visual mode" Tags="|visual-mode|replace|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19854" PostTypeId="1" CreationDate="2019-05-05T15:09:35.093" Score="3" ViewCount="250" Body="&lt;p&gt;I would like to make my Vim completion menu a little more IDE-like, and I was able to achieve this using the bindings suggested &lt;a href=&quot;https://vim.fandom.com/wiki/Improve_completion_popup_menu&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.  However, the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; binding causes a bit of a problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;Esc&amp;gt; pumvisible() ? &quot;\&amp;lt;C-e&amp;gt;&quot; : &quot;\&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The page warns:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Word to the wise, mapping over  can cause an issue in terminal vim where arrow keys will print letters A through D along with a newline rather than moving. To avoid the issue, simply omit the mapping over .&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Indeed!  And scrolling in insert mode does some crazy $#!^ that I don't even know how to describe.  The culprit seems to be that the up arrow is secretly bound to &lt;code&gt;^[OA&lt;/code&gt;, and rebinding &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; rebinds the &lt;code&gt;^[&lt;/code&gt; part.  I thought the whole point of &lt;code&gt;inoremap&lt;/code&gt; is that it won't affect other bindings, but what do I know...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, apart from those side-effects, the setting does exactly what I want.  Is there some way I can have my cake and eat it too?&lt;/p&gt;&#xA;" OwnerUserId="22112" LastActivityDate="2019-05-05T15:09:35.093" Title="Make &lt;Esc&gt; close completion menu and cancel selection, without side effects" Tags="|autocompletion|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19855" PostTypeId="1" CreationDate="2019-05-05T16:03:22.920" Score="2" ViewCount="89" Body="&lt;p&gt;I would like to search the word under my cursor. For this, I tried to press &lt;code&gt;*&lt;/code&gt;.&#xA;But, if the word I want to search is &lt;code&gt;#foo&lt;/code&gt;, as an example, vim only searches&#xA;word &lt;code&gt;foo&lt;/code&gt; (without hash), so it fails.&lt;/p&gt;&#xA;&lt;p&gt;In fact, the &lt;code&gt;#&lt;/code&gt; is not considered in the word, which is confirmed when I try to&#xA;go to the next word with &lt;code&gt;w&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Do you know how I can search effectively &lt;code&gt;#titi&lt;/code&gt; by pressing &lt;code&gt;*&lt;/code&gt; on my keyboard?&lt;/p&gt;&#xA;" OwnerUserId="22113" LastEditorUserId="23502" LastEditDate="2023-06-28T04:25:57.253" LastActivityDate="2023-06-28T12:11:48.347" Title="Search one word containing # with *" Tags="|search|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19856" PostTypeId="2" ParentId="19855" CreationDate="2019-05-05T16:37:40.897" Score="1" Body="&lt;p&gt;What is considered to be part of a word is defined, I think, by &lt;code&gt;iskeyword&lt;/code&gt;. You can try to change this setting to include &lt;code&gt;#&lt;/code&gt; and see if it solves your case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info: &lt;code&gt;:help 'iskeyword'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-05-05T16:37:40.897" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19857" PostTypeId="1" AcceptedAnswerId="19858" CreationDate="2019-05-05T17:20:20.697" Score="1" ViewCount="1714" Body="&lt;p&gt;First line says output is not a terminal. The rest of the output looks like term codes aren't being processed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use st, with $TERM = st-256color. I just tried it on termite ($TERM = xterm-termite) with the same screen.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;parmort • 1d    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I went and set diff.external=vimdiff and it displays the text above (after running just git diff). I've also tried nvim (through diff.external=nvim -d). Any thoughts&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7xFDC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7xFDC.png&quot; alt=&quot;Error messages&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21943" LastActivityDate="2019-05-05T17:22:25.230" Title="`vimdiff` nor `nvim -d` are working as an external diff tool for git" Tags="|command-line|vimdiff|git|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19858" PostTypeId="2" ParentId="19857" CreationDate="2019-05-05T17:22:25.230" Score="5" Body="&lt;p&gt;I tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git config --global diff.tool vimdiff3&#xA;git config --global difftool.vimdiff3.path nvim&#xA;git config --global merge.tool vimdiff3&#xA;git config --global mergetool.vimdiff3.path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It worked like a charm.&lt;/p&gt;&#xA;" OwnerUserId="21943" LastActivityDate="2019-05-05T17:22:25.230" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19859" PostTypeId="2" ParentId="19853" CreationDate="2019-05-05T17:39:40.640" Score="2" Body="&lt;p&gt;I think this is because you use multi-byte characters in the replacement field of the substitution commands. And because Vim – probably – keeps track of the start/end of the visual selection via &lt;em&gt;byte&lt;/em&gt; indexes (not character indexes). When you replace a character whose weight is 1 byte, with a character whose weight is 2 bytes, Vim should update the end of the visual selection it had saved originally; it probably doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:Tstrepl() abort&#xA;    let vcol = [virtcol(&quot;'&amp;lt;&quot;), virtcol(&quot;'&amp;gt;&quot;)]&#xA;    let pat = '\%&amp;gt;' . (vcol[0]-1) . 'v\%&amp;lt;' . (vcol[1]+1) . 'v'&#xA;    exe '*s/' . pat . 'a/\=&quot;\u2227&quot;/ge'&#xA;    exe '*s/' . pat . 'b/\=&quot;\u2228&quot;/ge'&#xA;endfu&#xA;xno &amp;lt;silent&amp;gt; QQ :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;Tstrepl()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure &lt;code&gt;*&lt;/code&gt; is not in the value of &lt;code&gt;'cpoptions'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h /\%v&#xA;:h virtcol()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2019-05-05T17:39:40.640" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19860" PostTypeId="1" AcceptedAnswerId="19862" CreationDate="2019-05-05T21:55:32.377" Score="0" ViewCount="396" Body="&lt;p&gt;For setting breakpoints, I was wondering if there is any way to copy the location of a line in a file opened in vim, to gdb rather than typing the whole file path and linenumber in the gdb shell?&lt;/p&gt;&#xA;" OwnerUserId="4513" LastActivityDate="2019-05-15T05:11:13.150" Title="How to copy file and line info from vim to gdb?" Tags="|cut-copy-paste|terminal|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19861" PostTypeId="2" ParentId="19860" CreationDate="2019-05-05T23:37:27.877" Score="0" Body="&lt;p&gt;I have found one way which is to use the : terminal feature of vim to start a new shell, run gdb in it and paste the filename from the alternate register #.&lt;/p&gt;&#xA;" OwnerUserId="4513" LastActivityDate="2019-05-05T23:37:27.877" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19862" PostTypeId="2" ParentId="19860" CreationDate="2019-05-05T23:54:48.577" Score="1" Body="&lt;p&gt;Good, since you're using &lt;code&gt;tmux&lt;/code&gt; then you can use &lt;code&gt;send-keys&lt;/code&gt; (alias: &lt;code&gt;send&lt;/code&gt;), a tmux command for inputting text into a different pane than the current one. You can call it from Vim using whatever data you need from there. For current (full) path and line number that would be &lt;code&gt;expand('%:p')&lt;/code&gt; and &lt;code&gt;line('.')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following command will send those two strings (separated by &lt;code&gt;:&lt;/code&gt;) to the terminal in pane 3. The combined string will not be submitted (i.e. carriage return is not sent).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;!tmux send -t 3 '&quot; . expand(&quot;%:p&quot;) . &quot;:&quot; . line(&quot;.&quot;) . &quot;'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So with, for example, a file &lt;em&gt;/tmp/foo.txt&lt;/em&gt; and line number 33 the tmux command that will be executed from the shell is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tmux send -t 3 '/tmp/foo.txt:33'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to submit the sent string in the target pane (i.e. by sending a carriage return) you just need to replace the last &lt;code&gt;&quot;'&quot;&lt;/code&gt; with &lt;code&gt;&quot;' Enter&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the &lt;code&gt;-t&lt;/code&gt; param to &lt;code&gt;send-keys&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In its simplest form, takes the target pane index as argument.&lt;/li&gt;&#xA;&lt;li&gt;If you are sending your command to another pane in the same window that's the only form we need to know. (Otherwise read the man page and/or ask me.)&lt;/li&gt;&#xA;&lt;li&gt;You can display pane indexes in the current window with &lt;em&gt;tmux-prefix&lt;/em&gt; + &lt;code&gt;q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Obviously, if you're going to use this a lot you'll want to put it in a mapping and/or function. A mapping-only solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap XX :&amp;lt;C-U&amp;gt;exe &quot;!tmux send -t &quot; . v:count . &quot; '&quot; . expand(&quot;%:p&quot;) . &quot; &quot; . line(&quot;.&quot;) . &quot;'&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace &lt;code&gt;XX&lt;/code&gt; with whatever unused key or key combo you want. Determine the target pane index (used by &lt;code&gt;-t&lt;/code&gt;) and, from Normal mode, type that number and then your &lt;code&gt;XX&lt;/code&gt; replacement. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though a little hard to read, the RHS of this isn't much more than the original &lt;code&gt;exe&lt;/code&gt; command plus:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Insertion of the variable &lt;code&gt;v:count&lt;/code&gt; where the &lt;code&gt;-t&lt;/code&gt; value goes. &lt;code&gt;v:count&lt;/code&gt; is a built-in variable that contains any number entered right before entering command-line mode (here that means the number entered before the the mapped key(s) are pressed).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; triggers Ctrl-U in order to clear the command line before we populate it. (Because when a number is entered right before entering command-line mode (&lt;code&gt;:&lt;/code&gt;) the command-line is prepopulated with a line range and we don't want that here.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could prompt the user for a pane index with a function+mapping. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! BufferInfoToPane()&#xA;    let l:pidx = ...prompt code here...&#xA;    exe &quot;!tmux send -t &quot;.l:pidx.&quot; '&quot;.expand(&quot;%:p&quot;).&quot; &quot;.line(&quot;.&quot;).&quot;'&quot;&amp;lt;CR&amp;gt;&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap XX :call BufferInfoToPane()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-05-15T05:11:13.150" LastActivityDate="2019-05-15T05:11:13.150" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19863" PostTypeId="2" ParentId="19853" CreationDate="2019-05-06T00:02:13.080" Score="1" Body="&lt;p&gt;user938271 already gave an explanation why OP had this problem.&lt;br&gt;&#xA;Here is another solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap QQ :s/\v%V[ab]/\=submatch(0)=='a'?&quot;\u2227&quot;:&quot;\u2228&quot;/g&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v%V[ab]&lt;/code&gt; search &lt;code&gt;a&lt;/code&gt; or &lt;code&gt;b&lt;/code&gt; in visual area.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\=submatch(0)=='a'?&quot;\u2227&quot;:&quot;\u2228&quot;&lt;/code&gt; replace &lt;code&gt;a&lt;/code&gt; with &lt;code&gt;&quot;\u2227&quot;&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt; with &lt;code&gt;&quot;\u2228&quot;&lt;/code&gt;. &lt;code&gt;submatch(0)&lt;/code&gt; is the whole matched text.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-05-06T00:02:13.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19864" PostTypeId="1" CreationDate="2019-05-06T07:46:12.803" Score="0" ViewCount="911" Body="&lt;p&gt;I sometimes need to work on remote server which does not have x11 installed and thus I cannot use vim with its full features. I want to work on remote server with the gvim installed to my local machine. What is not convenient is that I need two hops to access my server through some middle machine. That means I can only access server like this:  local -&gt; middle -&gt; server. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I do it please ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;=====&#xA;Edit: &#xA;Here is the specific case: &#xA;I have to access my remote server via middle server, and I have no way to bypass the middle server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not have a home directory at the middle server, so I cannot configure and use the middle server. It only plays the role of some entrance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not mind whether I have to use gvim, I am considering gvim because it has built-in clipboard function which is better than the terminal vim. I can compile terminal vim from source, but I do not have x11 in both the remote server and the middle server. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The core problem is how could I copy contents from the remote vim?&lt;/p&gt;&#xA;" OwnerUserId="18259" LastEditorUserId="18259" LastEditDate="2019-05-06T11:38:48.777" LastActivityDate="2019-05-11T06:24:43.877" Title="how could I use gvim through ssh two hops" Tags="|vimrc|gvim|ssh|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="19866" PostTypeId="2" ParentId="19835" CreationDate="2019-05-06T11:32:21.670" Score="2" Body="&lt;p&gt;No, this is not really possible. It has been requested a couple of times (&lt;a href=&quot;https://groups.google.com/forum/#!msg/vim_dev/EbTWqBl2rdw/vT4fTaGFnMoJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;https://groups.google.com/forum/#!msg/vim_dev/XzhNNjbtfow/u6BWsne4CwAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://groups.google.com/forum/#!msg/vim_dev/3_Mn38Jk3N0/W3TQ0g1WDQAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and even a &lt;a href=&quot;https://github.com/chrisbra/vim-mq-patches/blob/master/error_aucmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;patch&lt;/a&gt; has been proposed). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But Bram disregarded this so it has never been merged. &lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-05-06T11:32:21.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19867" PostTypeId="1" AcceptedAnswerId="19873" CreationDate="2019-05-06T12:35:05.127" Score="4" ViewCount="610" Body="&lt;p&gt;&lt;code&gt;terminal cd .&lt;/code&gt; results in following weird error in the terminal buffer:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;executing job failed: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The same error appears for &lt;code&gt;term_start('cd .')&lt;/code&gt;. It doesn't matter which directory I &lt;code&gt;cd&lt;/code&gt; to, the error doesn't change.&lt;/p&gt;&#xA;&lt;p&gt;If I execute &lt;code&gt;terminal&lt;/code&gt; without command, then execute &lt;code&gt;cd .&lt;/code&gt; in the opened terminal, everything works fine.&lt;/p&gt;&#xA;&lt;p&gt;I'm using vim8.1 include patches 1-1282 on Ubuntu 16.04.6 .&lt;/p&gt;&#xA;&lt;p&gt;Based on help from comment and answer, I changed the command to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;terminal bash -c 'cd .'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but it results in following error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;.': -c: line 0: unexpected EOF while looking for matching `''&#xA;.': -c: line 1: syntax error: unexpected end of file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;buffer name of the terminal is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;!bash -c 'cd .'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If I replace the single quotes with double quotes the command works. But why?&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="1238" LastEditDate="2020-08-11T20:34:10.093" LastActivityDate="2020-08-11T20:34:10.093" Title="What's wrong with &quot;terminal cd .&quot; in vim 8.1?" Tags="|terminal|vim8|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19868" PostTypeId="2" ParentId="19788" CreationDate="2019-05-06T13:05:05.467" Score="0" Body="&lt;p&gt;The behavior described is actually a function of &lt;code&gt;imap&lt;/code&gt; (or &lt;code&gt;inoremap&lt;/code&gt;) and not &lt;code&gt;iabbrev&lt;/code&gt; (= &lt;code&gt;iab&lt;/code&gt;). Using abbreviations instead of command mappings will allow you to continuously type, without any pause in place. It bears noting that abbreviations are not necessarily the best option, depending on what you are attempting to do, so use wisely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to @Ralf and @Rich for actually providing the answer to this question.&lt;/p&gt;&#xA;" OwnerUserId="16156" LastActivityDate="2019-05-06T13:05:05.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19869" PostTypeId="2" ParentId="14300" CreationDate="2019-05-06T15:05:15.747" Score="10" Body="&lt;p&gt;&lt;strong&gt;Here is a solution using Vim's term_sendkeys()&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;open a vim terminal and start the REPL&lt;br /&gt;&#xA;check which buffer the terminal is in with &lt;code&gt;:ls&lt;/code&gt;&lt;br /&gt;&#xA;this example assumes the terminal is in buffer 2&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;cmd to copy the content to the &amp;quot; register (the unamed register) and paste/run in the terminal&lt;br /&gt;&#xA;&lt;code&gt;:%y | call term_sendkeys(2, @&amp;quot;)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The command can then be mapped like this example:&lt;br /&gt;&#xA;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;sk :%y \| :call term_sendkeys(2, @&amp;quot;)&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Plugin Options:&lt;/strong&gt;&lt;br /&gt;&#xA;&lt;strong&gt;There are also many plugins available.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;This one is the next step up from manual steps.&lt;br /&gt;&#xA;I've tried it and it works and was updated in September of 2020.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/KKPMW/vim-sendtowindow&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/KKPMW/vim-sendtowindow&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also, its README includes an extensive list of related plugins. A few of these have continued to be updated in 2021.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/KKPMW/vim-sendtowindow#see-also&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/KKPMW/vim-sendtowindow#see-also&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;For those interested, here is a more manual solution&lt;/strong&gt;&lt;br /&gt;&#xA;Copy content into a register from an editing window and paste into the :terminal window with &lt;code&gt;&amp;lt;CTRL-W&amp;gt; &amp;quot; {reg}&lt;/code&gt; to run it.&lt;/p&gt;&#xA;&lt;p&gt;Example with one editing buffer and one :terminal buffer running bash:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;text content in editing window&lt;br /&gt;&#xA;echo hello&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;cmd to copy the content to the 0 register&lt;br /&gt;&#xA;&lt;code&gt;:vipy&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;move to the terminal window&lt;br /&gt;&#xA;&lt;code&gt;&amp;lt;CTRL-W&amp;gt; W&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;paste 0 register into terminal window&lt;br /&gt;&#xA;&lt;code&gt;&amp;lt;CTRL-W&amp;gt; &amp;quot;0&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;:terminal output&lt;br /&gt;&#xA;&lt;code&gt;hello&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;move back to editing window&lt;br /&gt;&#xA;&lt;code&gt;&amp;lt;CTRL-W&amp;gt; W&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;... continue editing...&lt;/p&gt;&#xA;&lt;p&gt;This also works for python REPL and probably for other languages' REPLs.&lt;/p&gt;&#xA;" OwnerUserId="14302" LastEditorUserId="14302" LastEditDate="2021-07-29T18:07:36.897" LastActivityDate="2021-07-29T18:07:36.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19870" PostTypeId="1" AcceptedAnswerId="19871" CreationDate="2019-05-06T18:06:20.733" Score="4" ViewCount="2420" Body="&lt;p&gt;I am new to vim and I've been asking a bunch of questions on here, most of which has to do with plugins. What is the correct way to access the documentation for plugin? As an example, I am using the this: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/gu-fan/simpleterm.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/gu-fan/simpleterm.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation on Gihub mentions the usage of: &lt;code&gt;g:simpleterm.pos = 'below'&lt;/code&gt;  to control where the terminal will appear.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess is that I only need to change this argument 'below' to something that I prefer.  'Top' seems to work. But about the other directions? 'Left', 'Right', 'East', 'West' do not work.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are no ways for me to figure out the correct syntax.  In vim, I tried: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h simpleterm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That brings me to the same documentation on github, i.e only mentions of possible usage but no syntax.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also happens with plugins like vim-airline, some vim themes...etc. But those are popular and so I can find answers via stackexchange.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bottom line is: where should I dig for a complete documentation with all the possible syntax usage for a given plugin? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help. &lt;/p&gt;&#xA;" OwnerUserId="21038" LastEditorUserId="51" LastEditDate="2021-01-27T03:11:56.257" LastActivityDate="2021-01-27T03:11:56.257" Title="How to access any given vim plugin documentation?" Tags="|plugin-system|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19871" PostTypeId="2" ParentId="19870" CreationDate="2019-05-06T18:55:08.660" Score="3" Body="&lt;p&gt;In general a good plugin will provide good and complete documentation using Vim's own help system, &lt;code&gt;:help&lt;/code&gt;, but sometimes it is hard to figure out the right topic name.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;How to find documentation topics?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim's documentation uses tags to provide quick navigation, e.g. &lt;code&gt;:help :s&lt;/code&gt;. This makes for a little chicken and egg problem because you might not know the help author choose for tags. Here are some ways to discover help topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use tab completion (and wildcards!) e.g. &lt;code&gt;:h buff&amp;lt;tab&amp;gt;&lt;/code&gt; to list out buffer related topics&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; to list out completions instead of using &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:helpgrep {pat}&lt;/code&gt; to search for some patter in the help files. Similar to &lt;code&gt;:vimgrep&lt;/code&gt;/&lt;code&gt;:grep&lt;/code&gt; and will populate the quickfix list&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help&lt;/code&gt; has a table of contents as well as tags to plugin help files (may need to run &lt;code&gt;:helptags&lt;/code&gt; in so form)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;So what about simpleterm.vim's documentation?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Sadly simpleterm.vim doesn't document the options for this behavior. You literally have to crack open the plugin and see what it is doing to figure out what options are available. It is using &lt;code&gt;below&lt;/code&gt; which is short for &lt;code&gt;:belowright&lt;/code&gt; followed by &lt;code&gt;:split&lt;/code&gt;. This means you probably have options of &lt;code&gt;:vertical&lt;/code&gt;, &lt;code&gt;:leftabove&lt;/code&gt;, &lt;code&gt;:aboveleft&lt;/code&gt;, &lt;code&gt;:rightbelow&lt;/code&gt;, &lt;code&gt;:belowright&lt;/code&gt;, &lt;code&gt;:topleft&lt;/code&gt;, and/or &lt;code&gt;:botright&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; bottom, right, top, left with regard to all the windows&#xA;let g:simpleterm.pos = 'botright'&#xA;let g:simpleterm.pos = 'botright vertical'&#xA;let g:simpleterm.pos = 'topleft'&#xA;let g:simpleterm.pos = 'topleft vertical'&#xA;&#xA;&quot; below, right, above, left with regard to the current window&#xA;let g:simpleterm.pos = 'belowright'&#xA;let g:simpleterm.pos = 'belowright vertical'&#xA;let g:simpleterm.pos = 'aboveleft'&#xA;let g:simpleterm.pos = 'aboveleft vertical'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would probably be useful to read &lt;code&gt;:h :vertical&lt;/code&gt; and the next few command to get a feel for all the split window modifiers. Actually reading all of &lt;code&gt;:h windows&lt;/code&gt; would be a good idea.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2019-05-06T19:09:19.380" LastActivityDate="2019-05-06T19:09:19.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19873" PostTypeId="2" ParentId="19867" CreationDate="2019-05-06T22:15:06.317" Score="3" Body="&lt;p&gt;Based on Chris’s comments on the OP, I would make the shell do the work, using a level of indirection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;terminal bash -c &quot;cd wherever &amp;amp;&amp;amp; do_something&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue is that the bare &lt;code&gt;:terminal&lt;/code&gt; command doesn’t ever execute a shell—it executes the name of the external program you give it (which, by default, happens to be the shell). So, &lt;code&gt;terminal cd .&lt;/code&gt; tries to run a command on disk named &lt;code&gt;cd&lt;/code&gt;. For reasons, you don’t have one, and it wouldn’t work if you did. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-05-07T13:34:51.633" LastActivityDate="2019-05-07T13:34:51.633" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19874" PostTypeId="1" AcceptedAnswerId="19876" CreationDate="2019-05-07T00:33:23.163" Score="0" ViewCount="357" Body="&lt;p&gt;I'm transitioning to vim and I love the feature other IDEs provided in which when I wrote something with a syntax error it accuses me through a red underlining.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know what this type of feature is called.&#xA;Can someone hint me how to make that work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm coding in ruby.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm looking for I think is called linter&lt;/p&gt;&#xA;" OwnerUserId="22132" LastEditorUserId="22132" LastEditDate="2019-05-07T01:04:48.667" LastActivityDate="2019-05-07T01:06:31.460" Title="How to use vim as an error checker?" Tags="|syntax-highlighting|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19875" PostTypeId="2" ParentId="14300" CreationDate="2019-05-07T01:04:52.253" Score="5" Body="&lt;p&gt;As Luc Hermitte pointed out, you can use &lt;code&gt;:h term_sendkeys&lt;/code&gt; to send commands to terminal buffer, the hard part is to manage the terminal buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:exec_on_term(lnum1, lnum2)&#xA;  &quot; get terminal buffer&#xA;  let g:terminal_buffer = get(g:, 'terminal_buffer', -1)&#xA;  &quot; open new terminal if it doesn't exist&#xA;  if g:terminal_buffer == -1 || !bufexists(g:terminal_buffer)&#xA;    terminal&#xA;    let g:terminal_buffer = bufnr('')&#xA;    wincmd p&#xA;  &quot; split a new window if terminal buffer hidden&#xA;  elseif bufwinnr(g:terminal_buffer) == -1&#xA;    exec 'sbuffer ' . g:terminal_buffer&#xA;    wincmd p&#xA;  endif&#xA;  &quot; join lines with &quot;\&amp;lt;cr&amp;gt;&quot;, note the extra &quot;\&amp;lt;cr&amp;gt;&quot; for last line&#xA;  &quot; send joined lines to terminal.&#xA;  call term_sendkeys(g:terminal_buffer,&#xA;        \ join(getline(a:lnum1, a:lnum2), &quot;\&amp;lt;cr&amp;gt;&quot;) . &quot;\&amp;lt;cr&amp;gt;&quot;)&#xA;endfunction&#xA;&#xA;command! -range ExecOnTerm call s:exec_on_term(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;)&#xA;nnoremap &amp;lt;leader&amp;gt;ex :ExecOnTerm&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;leader&amp;gt;ex :ExecOnTerm&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;read comment as explanation&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;usage&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;execute single line in normal mode, multiple lines in visual mode.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-05-07T01:04:52.253" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19876" PostTypeId="2" ParentId="19874" CreationDate="2019-05-07T01:06:31.460" Score="0" Body="&lt;p&gt;This is what's needed for solving the problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/vim-syntastic/syntastic&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim-syntastic/syntastic&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22132" LastActivityDate="2019-05-07T01:06:31.460" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19877" PostTypeId="1" CreationDate="2019-05-07T07:46:39.300" Score="1" ViewCount="26" Body="&lt;p&gt;I have an absurd problem. Honestly, I have a hard time figuring out whether this belongs here or a Windows forum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using Vim on Win10, I've changed my &lt;code&gt;C:\Program Files (x86)\Vim\_vimrc&lt;/code&gt; from the awful default that came with the installation to my own. For simplicity's sake, let's say the file was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; _vimrc (default)&#xA;colorscheme blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I changed it to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; _vimrc (custom)&#xA;colorscheme desert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, when I run &lt;code&gt;vim&lt;/code&gt; in cmd or powershell, the colorscheme is &quot;desert&quot;, and &lt;code&gt;:e C:\Program\ Files\ (x86)\Vim\_vimrc&lt;/code&gt; opens the custom file as I would expect. But here's where it gets weird: If I try to use the file from any other program (&lt;code&gt;notepad&lt;/code&gt;, &lt;code&gt;dir&lt;/code&gt;, &lt;code&gt;cat&lt;/code&gt;, &lt;code&gt;gvim&lt;/code&gt;), it's still the default file, and it's marked as read-only. And when running &lt;code&gt;gvim&lt;/code&gt;, it uses the &quot;blue&quot; colorscheme. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first thought was that vim was working on some temporary file, but the changed file persists over program restarts and even a reboot. Is there two files by the same name? How does Vim load different files than gVim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;:scriptnames&lt;/code&gt; has the exact same first line in both Vim and gVim, &quot;&lt;code&gt;C:\Program Files (x86)\Vim\_vimrc&lt;/code&gt;&quot;.&lt;/p&gt;&#xA;" OwnerUserId="22122" LastActivityDate="2019-05-07T07:46:39.300" Title="Different versions of vimrc being read" Tags="|vimrc|microsoft-windows|filesystem|" AnswerCount="0" CommentCount="9" ClosedDate="2019-05-07T10:06:26.763" ContentLicense="CC BY-SA 4.0" />
  <row Id="19878" PostTypeId="1" AcceptedAnswerId="19879" CreationDate="2019-05-07T14:48:29.990" Score="1" ViewCount="71" Body="&lt;pre&gt;&lt;code&gt;:s/\&amp;lt;word\&amp;gt;//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works but&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:S/\&amp;lt;word\&amp;gt;//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get equivalent of &lt;code&gt;\&amp;lt;&lt;/code&gt; and co in abolish?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2019-05-07T18:52:29.890" Title="word boundaries in abolish" Tags="|substitute|plugin-vim-abolish|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19879" PostTypeId="2" ParentId="19878" CreationDate="2019-05-07T14:52:22.283" Score="2" Body="&lt;p&gt;Use the &lt;code&gt;w&lt;/code&gt; flag&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:S/word//gw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from help page&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Flags can be given with the -flags= option to :Abolish, or by appending them&#xA;  after the separator to :Subvert. The flags trigger the following behaviors:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;I: Disable case variations (box, Box, BOX)&lt;br&gt;&#xA;   v: Match inside variable names (match my_box, myBox, but not mybox)&lt;br&gt;&#xA;   w: Match whole words (like surrounding with \&amp;lt; and \&gt;)  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="9024" LastEditDate="2019-05-07T18:52:29.890" LastActivityDate="2019-05-07T18:52:29.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19881" PostTypeId="1" CreationDate="2019-05-07T23:17:12.943" Score="1" ViewCount="773" Body="&lt;p&gt;OS: Ubuntu 18.04&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I ran&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apt-get install python3-dev ruby-dev&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, I installed vim using the instructions in the &lt;a href=&quot;https://www.vim.org/git.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;website&lt;/a&gt;, using &lt;code&gt;make distclean&lt;/code&gt;, &lt;code&gt;make&lt;/code&gt; and &lt;code&gt;make install&lt;/code&gt; (This was like the tenth time in one week that I was compiling from source. By the way, I know now that I should use checkinstall, but I already used &lt;code&gt;make install&lt;/code&gt; once, so I figured I just might as well continue using it). I chose the &lt;code&gt;big&lt;/code&gt; version of vim, and uncommented the lines as indicated in the Makefile file, located at the src folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Makefile, I also uncommented the necessary lines as indicted in that same file. I think there were 3 lines related to python3, I uncommented those but not the ones for python2. I also uncommented the lines for perl and ruby, because previous trials of installing python3 support had not worked properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The result&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;vim --version&lt;/code&gt; shows &lt;code&gt;-python&lt;/code&gt; and &lt;code&gt;+python3/dyn&lt;/code&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I enter vim and run &lt;code&gt;: python3 import sys&lt;/code&gt; or &lt;code&gt;:python3 print ('Hello')&lt;/code&gt; I get the errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E370: Could not load library libpython3.7m.a&#xA;E263: Sorry, this command is disabled, the Python library could not be loaded.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Question: How do I fix this? How do I make python3 support work properly? I have heard of using apt-get for installing vim, but I would like to avoid that for learning purposes, and because I am installing Vim on my home directory. I have also read about neovim, but for learning purposes I want to work with vim now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/44264315/8045669&quot;&gt;This answer&lt;/a&gt; to the post &quot;Gvim cannot load my Python&quot; says that one should copy the file python37.dll into Vim's directory. I do not know whether that works or not; but, if it does, is there really no other solution?&lt;/p&gt;&#xA;" OwnerUserId="21996" LastEditorUserId="21996" LastEditDate="2019-05-08T02:36:32.317" LastActivityDate="2019-05-08T02:36:32.317" Title="Vim shows error when running python3" Tags="|linux|vimscript-python|installing|linux-ubuntu|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19882" PostTypeId="1" AcceptedAnswerId="19883" CreationDate="2019-05-08T00:26:29.020" Score="3" ViewCount="918" Body="&lt;p&gt;I am searching for a way to execute a line under the cursor as a command. I assign it to a combination of &lt;code&gt;&amp;lt;Leader&amp;gt;el&lt;/code&gt; and basically I found a way to do it with &lt;code&gt;:exe !@u&lt;/code&gt; but the issue I have here is that special chars like # and % get expanded by vi as well. And I want the entire string in the named register to be executed literally as is. &#xA;I tried with &lt;code&gt;:call system(@u)&lt;/code&gt; but to no avail. &#xA;Can you please help?&lt;/p&gt;&#xA;" OwnerUserId="22144" LastActivityDate="2019-05-08T02:03:11.940" Title="Vi shortcut to execute line under cursor as a command" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19883" PostTypeId="2" ParentId="19882" CreationDate="2019-05-08T02:03:11.940" Score="1" Body="&lt;p&gt;As per the comment of @dedowsdi, &lt;code&gt;echo system(@u)&lt;/code&gt; worked. This is the answer. Unfortunately I cannot even upvote your comment. But you get the credit! Thank you so much!!&lt;/p&gt;&#xA;" OwnerUserId="22144" LastActivityDate="2019-05-08T02:03:11.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19884" PostTypeId="1" AcceptedAnswerId="19892" CreationDate="2019-05-08T03:27:35.813" Score="3" ViewCount="377" Body="&lt;p&gt;Currently when working with vim's spellcheck a word is highlighted a certain color based on the type of error it is. Instead of highlighting the erroneous word I'd like it to be underlined with the highlighted color. I'm aware it's possible underline a certain highlight group with &lt;code&gt;cterm=underline&lt;/code&gt;, and I can change to foreground color with the &lt;code&gt;ctermfg&lt;/code&gt; option, but that changes the color of the word &lt;em&gt;and&lt;/em&gt; underline whereas I just want the underline to be a different color.&lt;/p&gt;&#xA;" OwnerUserId="22133" LastEditorUserId="22133" LastEditDate="2019-05-08T03:47:04.407" LastActivityDate="2021-02-04T13:01:57.890" Title="How would one change the spell-checking style while preserving highlight color?" Tags="|syntax-highlighting|spell-checking|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19885" PostTypeId="1" CreationDate="2019-05-08T05:53:17.163" Score="1" ViewCount="696" Body="&lt;p&gt;I can use &lt;code&gt;:Explore&lt;/code&gt; to go through the current directory and open new files when I use vim locally. But when I use netrw to edit remote files, I cannot do it. For example, I opened a remote file with &lt;code&gt;vim sftp://name@url//path/to/file.txt&lt;/code&gt;. I opened a file for me. But when I run &lt;code&gt;:Explore&lt;/code&gt;, I find no tree-like folder structures showed to me. How could I go through the remote files like I did when I edit my local files ?&lt;/p&gt;&#xA;" OwnerUserId="18259" LastActivityDate="2020-11-12T23:01:20.107" Title="How could I explore the files when using netrw to edit remote files" Tags="|netrw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19886" PostTypeId="1" AcceptedAnswerId="19887" CreationDate="2019-05-08T07:59:04.817" Score="2" ViewCount="2714" Body="&lt;p&gt;I'm trying to write a 2D matrix of characters. I can get a string of random characters with &lt;code&gt;pwgen 4 1&lt;/code&gt;, for example. That gives me something like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ia6e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to split this string up by characters in vanilla Vim? I need to quote each individual character and put some spaces in between. Eventually, I want to end up with something like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'i', 'a', '6', 'e'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22095" LastActivityDate="2019-05-13T13:30:35.937" Title="Is there a way to split a word by characters?" Tags="|formatting|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19887" PostTypeId="2" ParentId="19886" CreationDate="2019-05-08T08:07:55.370" Score="1" Body="&lt;p&gt;Would the following substitutions help you?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\(.\)/'\1', /g&#xA;:s/, $//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first wraps all the characters with quotes and with comma and space afterwards (in the current line only).&#xA;The second removes the last comma and space from the line (again, current line only).&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-05-08T08:07:55.370" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19888" PostTypeId="2" ParentId="19886" CreationDate="2019-05-08T08:19:37.440" Score="1" Body="&lt;p&gt;You can use the &lt;code&gt;:split&lt;/code&gt; function of vim to separate a given string to all its different character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic split function that would do it for you would be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;split(current_word, '\zs')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A full command that would actually do the split is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;normal ciw&quot; . string(split(expand(&quot;&amp;lt;cword&amp;gt;&quot;), '\zs')) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you would like, you can create a function that would change the current word to its different characters.&#xA;The function would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SplitCurrentWord()                                                                                                                                                                       &#xA;    let current_word = expand(&quot;&amp;lt;cword&amp;gt;&quot;)                                                                                                                                                       &#xA;    normal ciw                                                                                                                                                                                 &#xA;    for current_char in split(current_word, '\zs')                                                                                                                                             &#xA;        execute &quot;normal a\'&quot; . current_char . &quot;\', &quot;                                                                                                                                           &#xA;    endfor                                                                                                                                                                                     &#xA;    normal &quot;xxx&quot;                                                                                                                                                                               &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add it to your vimrc and load it when needed, or map it to a command or a set of keys.&#xA;(with &lt;code&gt;command! SplitWord call SplitCurrentWord&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="21987" LastEditorUserId="21987" LastEditDate="2019-05-11T15:00:01.800" LastActivityDate="2019-05-11T15:00:01.800" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19889" PostTypeId="2" ParentId="3670" CreationDate="2019-05-08T08:27:04.337" Score="1" Body="&lt;p&gt;Or even slightly better:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  function! TerminalOptions()&#xA;    &amp;quot; /* folded code */&#xA;    silent! au BufEnter &amp;lt;buffer&amp;gt; startinsert!&#xA;    silent! au BufLeave &amp;lt;buffer&amp;gt; stopinsert!&#xA;  endfunction&#xA;  au TerminalOpen * call TerminalOptions()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Which the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; will make the au command to be applied locally, so only for the termial buffer type. This is also usefull for changing so setting for the terminal only. Such as swtich from relative lines to absolute ;)&lt;/p&gt;&#xA;&lt;p&gt;Also..... I cant get &lt;code&gt;:startinsert&lt;/code&gt; to work, even if all docs point to that. I had to do the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    au BufEnter &amp;lt;buffer&amp;gt; exec &amp;quot;normal! i&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13797" LastEditorUserId="13797" LastEditDate="2021-06-10T08:07:40.493" LastActivityDate="2021-06-10T08:07:40.493" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19890" PostTypeId="2" ParentId="15967" CreationDate="2019-05-08T08:30:57.190" Score="1" Body="&lt;p&gt;I have to suggest &lt;a href=&quot;https://github.com/luochen1990/rainbow&quot; rel=&quot;nofollow noreferrer&quot;&gt;this plugin&lt;/a&gt; for you, it is Highly configurable, to just enable rainbow parentheses for lisp, you can configure it like following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:rainbow_conf = {&#xA;\   'separately': {&#xA;\       '*': 0,&#xA;\       'lisp': {&#xA;\           'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'darkorchid3'],&#xA;\       }&#xA;\   }&#xA;\}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12521" LastActivityDate="2019-05-08T08:30:57.190" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19891" PostTypeId="1" CreationDate="2019-05-08T08:49:10.400" Score="1" ViewCount="513" Body="&lt;p&gt;I mounted the remote server directory to my local machine mount point with sshfs. Thus I could use my local vim to edit my code, it is much faster than editing with the vim installed to the remote server. However, the saving process and switching between buffers becomes very slow. Each time I run &lt;code&gt;:w&lt;/code&gt;, it will cost me around 20s to accomplish the saving process, and it is also very slow when I run &lt;code&gt;ctrl + w + l&lt;/code&gt; or &lt;code&gt;&amp;lt;leader&amp;gt;+f&lt;/code&gt; to switch between the split buffers or other opened buffers. The network is sort of slow but I am sure it is not so slow when I use &lt;code&gt;rsync&lt;/code&gt; to transmit files. What is the cause of this and how could I fix it please?&lt;/p&gt;&#xA;" OwnerUserId="18259" LastEditorUserId="24" LastEditDate="2019-05-10T05:24:28.653" LastActivityDate="2019-05-10T05:24:28.653" Title="Why is network latency becomes too long when edit in the sshfs mounted files" Tags="|buffers|performance|ssh|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19892" PostTypeId="2" ParentId="19884" CreationDate="2019-05-08T09:04:09.657" Score="2" Body="&lt;p&gt;Since Vim 8.2.0863 (May 2020) this can be done with &lt;code&gt;ctermul&lt;/code&gt; if your terminal supports it:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:hi SpellBad cterm=underline ctermul=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://github.com/vim/vim/pull/6011&quot; rel=&quot;nofollow noreferrer&quot;&gt;the PR&lt;/a&gt;; this should be supported on VTE-based terminals, KiTTY, and perhaps some more. You can check if &lt;code&gt;underline_rgb&lt;/code&gt; is present in &lt;code&gt;terminalprops()&lt;/code&gt; (which was added a few patchlevels later, in 8.2.0970). Don't forget to set the correct &lt;code&gt;TERM&lt;/code&gt; value, otherwise it won't work (e.g. &lt;code&gt;xterm-kitty&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;If you're using an older version or a terminal that doesn't support this then you're out of luck. Vim doesn't directly &amp;quot;draw&amp;quot; anything, it just sends text interspersed with escape codes for colouring, positioning, etc. and it's up to the terminal to interpret that.&lt;/p&gt;&#xA;&lt;p&gt;Neovim doesn't support this at the time of writing; you can &lt;a href=&quot;https://github.com/neovim/neovim/search?q=ctermul&quot; rel=&quot;nofollow noreferrer&quot;&gt;search the Neovim repo&lt;/a&gt; to see if it's supported if you're reading this a few years after posted.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;In gvim you can do this with &lt;code&gt;guisp&lt;/code&gt;, which is used for both strikethrough and undercurl (but not underline):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:hi SpellBad gui=underline guisp=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This value is also used in the terminal if you enable &lt;code&gt;termguicolors&lt;/code&gt; and the terminal supports &lt;code&gt;ctermul&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2021-02-04T13:01:57.890" LastActivityDate="2021-02-04T13:01:57.890" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19893" PostTypeId="1" AcceptedAnswerId="19895" CreationDate="2019-05-08T10:03:50.500" Score="2" ViewCount="253" Body="&lt;p&gt;Related config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F5&amp;gt; :make&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;F6&amp;gt; :!./%&amp;lt;&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;F7&amp;gt; :!./%&amp;lt; 2&amp;gt;/dev/null&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is while running the program with &lt;kbd&gt;F6&lt;/kbd&gt; when I paste input from clipboard it messes up the output and before all the input is pasted there is already something printed which makes it a bit difficult to read quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A workaround is to read from a file, like &lt;code&gt;./&amp;lt;filename&amp;gt; &amp;lt; in&lt;/code&gt; but i was not able to map this command to key.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F8&amp;gt; :!./%&amp;lt;CR&amp;gt; &amp;lt; in&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am a beginner and don't know much about these configurations.&#xA;Any help will be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;br&gt;&#xA;For copy pasting from clipboard, i have the following lines in &lt;code&gt;.vimrc&lt;/code&gt; from  &lt;a href=&quot;https://stackoverflow.com/questions/44480829/how-to-copy-to-clipboard-in-vim-of-bash-on-windows&quot;&gt;https://stackoverflow.com/questions/44480829/how-to-copy-to-clipboard-in-vim-of-bash-on-windows&lt;/a&gt;.&#xA;I am using WSL on windows. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;C-c&amp;gt; y:new ~/.vimbuffer&amp;lt;CR&amp;gt;VGp:x&amp;lt;CR&amp;gt; \| :!cat ~/.vimbuffer \| clip.exe &amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;map &amp;lt;C-Shift-v&amp;gt; :r ~/.vimbuffer&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22152" LastEditorUserId="22152" LastEditDate="2019-05-08T12:51:58.367" LastActivityDate="2019-05-08T23:26:46.770" Title="How to read a from a file while executing code" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19894" PostTypeId="2" ParentId="19828" CreationDate="2019-05-08T10:48:56.437" Score="0" Body="&lt;p&gt;The solution to this issue can be found in &lt;a href=&quot;https://github.com/vimwiki/vimwiki/issues/357&quot; rel=&quot;nofollow noreferrer&quot;&gt;this thread&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing one has to do is to add this line to &lt;code&gt;~/.vimrc&lt;/code&gt;, which allows to both use Tab in normal mode to cycle through links, and to expand links in Insert mode:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:vimwiki_table_mappings = 0&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="22081" LastActivityDate="2019-05-08T10:48:56.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19895" PostTypeId="2" ParentId="19893" CreationDate="2019-05-08T12:30:58.857" Score="1" Body="&lt;p&gt;You can't do it with &lt;code&gt;map&lt;/code&gt;, you should do it with &lt;code&gt;command&lt;/code&gt;, &lt;code&gt;command&lt;/code&gt; allows you to input filename as &lt;code&gt;args&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=1 -complete=file Exe !./%&amp;lt; &amp;lt;&amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h &amp;lt;args&amp;gt;&lt;/code&gt; will be expanded to your input filename. You can execute it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Exe input_filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are using vim8, you may try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=1 -complete=file ExeTerminal exec 'terminal bash -c &quot;./%&amp;lt; &amp;lt;&amp;lt;args&amp;gt;&quot;' | wincmd p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's asynchronous, you output will be in a vim terminal buffer.&#xA;&lt;code&gt;:h terminal&lt;/code&gt; see &lt;code&gt;|&lt;/code&gt; as it's arguments, you need to use &lt;code&gt;exec&lt;/code&gt; to write multiple commands in 1 line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to create a map to just enter filename:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;f8&amp;gt; :Exe&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; is a space.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-08T23:26:46.770" LastActivityDate="2019-05-08T23:26:46.770" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="19896" PostTypeId="1" AcceptedAnswerId="19897" CreationDate="2019-05-08T14:32:52.283" Score="0" ViewCount="102" Body="&lt;p&gt;In the help for move:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]m[ove] {address}                        *:m* *:mo* *:move* *E134*&#xA;                        Move the lines given by [range] to below the line&#xA;                        given by {address}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and help for address:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line numbers may be specified with:             *:range* *E14* *{address}*&#xA;        {number}        an absolute line number &#xA;        .               the current line                          *:.*&#xA;        $               the last line in the file                 *:$*&#xA;        %               equal to 1,$ (the entire file)            *:%*&#xA;        't              position of mark t (lowercase)            *:'*&#xA;        'T              position of mark T (uppercase); when the mark is in&#xA;                        another file it cannot be used in a range&#xA;        /{pattern}[/]   the next line where {pattern} matches     *:/*&#xA;        ?{pattern}[?]   the previous line where {pattern} matches *:?* &#xA;        \/              the next line where the previously used search&#xA;                        pattern matches&#xA;        \?              the previous line where the previously used search&#xA;                        pattern matches&#xA;        \&amp;amp;              the next line where the previously used substitute&#xA;                        pattern matches&#xA;&#xA;Each may be followed (several times) by '+' or '-' and an optional number.&#xA;This number is added or subtracted from the preceding line number.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it seems like &lt;code&gt;:m+1&lt;/code&gt; should move the current line &quot;below the line&quot; that is &lt;code&gt;+1&lt;/code&gt; the current line, so if I'm on line 7, it should move the current line below line 8, i.e. current line should be moved to line 9. At least this is how I've understood manual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, if I'm on line 7, it seems like both &lt;code&gt;:m7&lt;/code&gt; and &lt;code&gt;:m6&lt;/code&gt; do nothing (or just moves the cursor to the start of line 7).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a reason for this behaviour or &quot;convention&quot;?&lt;/p&gt;&#xA;" OwnerUserId="22159" LastEditorUserId="22159" LastEditDate="2019-05-08T14:50:25.253" LastActivityDate="2022-04-06T03:20:03.713" Title="Why does `:m+1` not move two lines down when `:m-2` moves one line up?" Tags="|cursor-movement|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19897" PostTypeId="2" ParentId="19896" CreationDate="2019-05-08T15:10:29.013" Score="2" Body="&lt;p&gt;The behavior is correct. When you move a line down below the next line (which means two lines down) your original line is deleted afterwards, thus resulting in a new location which is only one line down from its original location.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastActivityDate="2019-05-08T15:10:29.013" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19898" PostTypeId="2" ParentId="19896" CreationDate="2019-05-08T15:11:05.447" Score="4" Body="&lt;p&gt;I think you are correct. &lt;code&gt;:m+1&lt;/code&gt; does actually move the current line below the &lt;code&gt;current line + 1&lt;/code&gt;, so if you are on line 7, :m+1 does actually move the line to below line 8. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However&lt;/strong&gt;, after the line has been copied, the original line will be deleted (since it is a move), so it appears to be only 1 line lower. So it behaves essential the same as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:co+1&#xA;:7d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-05-08T15:27:00.733" LastActivityDate="2019-05-08T15:27:00.733" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19899" PostTypeId="1" AcceptedAnswerId="20325" CreationDate="2019-05-08T20:26:48.670" Score="7" ViewCount="1194" Body="&lt;p&gt;I'm unable to use the system clipboard in Vim. I'm using ssh to connect to an EC2 instance running Ubuntu 18.04. I'm fairly sure that this has to do with neither the &lt;code&gt;*&lt;/code&gt; or the &lt;code&gt;+&lt;/code&gt; register showing up in the output of &lt;code&gt;:reg&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I mean:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/1rPmb.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1rPmb.png&quot; alt=&quot;reg output missing * and +&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried vim-gtk, vim-gtk3, and vim-gnome and the output of &lt;code&gt;:reg&lt;/code&gt; is always missing &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in Neovim, the &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; registers show up and I am able to use the system clipboard:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3GpVV.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3GpVV.png&quot; alt=&quot;reg with + and * registers&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I make the &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; registers appear (work) in regular vim?&lt;/p&gt;&#xA;" OwnerUserId="22165" LastActivityDate="2021-08-25T00:30:43.813" Title="Vi: * and + registers do not exist" Tags="|cut-copy-paste|register|os-clipboard|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19900" PostTypeId="1" CreationDate="2019-05-08T23:21:01.410" Score="0" ViewCount="51" Body="&lt;p&gt;Are combining characters allowed in a concealment character? The following does not seem to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match underdot &quot;a\.&quot; conceal cchar=ạ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The underdot is &lt;a href=&quot;https://unicode-table.com/en/0323/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;U+0323&lt;/code&gt;&lt;/a&gt;. This syntax conceals &lt;code&gt;a.&lt;/code&gt; simply as &lt;code&gt;a&lt;/code&gt; rather than &lt;code&gt;ạ&lt;/code&gt;. Is there something I can do to make this work, or is this a limitation of Vim?&lt;/p&gt;&#xA;" OwnerDisplayName="user20228" LastActivityDate="2019-05-08T23:21:01.410" Title="Use combining characters in concealment character" Tags="|syntax-highlighting|conceal|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19901" PostTypeId="2" ParentId="5390" CreationDate="2019-05-09T00:15:42.393" Score="5" Body="&lt;p&gt;Add &lt;code&gt;set backupcopy=yes&lt;/code&gt; to your vimrc file to preserve file creation time on macOS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info, see &lt;code&gt;:help 'backupcopy'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://superuser.com/a/811805/59284&quot;&gt;How can I get VIM to maintain the creation date for a file? (OS X)&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18935" LastActivityDate="2019-05-09T00:15:42.393" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19902" PostTypeId="1" AcceptedAnswerId="19904" CreationDate="2019-05-09T07:26:59.417" Score="0" ViewCount="3120" Body="&lt;p&gt;I have tried other solutions proposed of this question but still none of them worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'SirVer/ultisnips'&#xA;&quot; Optional:&#xA;Plugin 'honza/vim-snippets'&#xA;&#xA;let g:UltiSnipsSnippetDirectories = ['/home/ayush/.vim/bundle/ultisnips', '~/UltiSnips']&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;c-b&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-z&amp;gt;&quot;&#xA;let g:UltiSnipsEditSplit=&quot;vertical&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use vundle package manager and installed ultisnips by &lt;code&gt;:PluginInstall&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When creating new snips, &lt;code&gt;:UltiSnipsEdit&lt;/code&gt;, it opens a file at &lt;code&gt;~/UltiSnips/&amp;lt;language&amp;gt;.snippets&lt;/code&gt;&#xA;and i think vundle installed the package at &lt;code&gt;~/.vim/bundle/ultisnips&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also,&#xA;&lt;code&gt;:verbose imap &amp;lt;tab&amp;gt;&lt;/code&gt; &#xA;shows &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &amp;lt;Tab&amp;gt;       * &amp;lt;C-R&amp;gt;=UltiSnips#ExpandSnippet()&amp;lt;CR&amp;gt;    &#xA;Last set from ~/.vim/bundle/ultisnips/autoload/UltiSnips/map_keys.vim                                                                                 Press ENTER or type command to continue                                 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&#xA;&lt;code&gt;:help UltiSnips-snippet-search-path&lt;/code&gt; shows &#xA;&lt;code&gt;E149: Sorry, no help for UltiSnips-snippet-search-path&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If some more info is needed, please mention in comments.&lt;/p&gt;&#xA;" OwnerUserId="22152" LastActivityDate="2019-05-09T12:43:51.937" Title="tab trigger not working for ultisnips" Tags="|key-bindings|plugin-ultisnips|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19904" PostTypeId="2" ParentId="19902" CreationDate="2019-05-09T12:06:32.860" Score="2" Body="&lt;p&gt;&lt;code&gt;g:UltiSnipsSnippetDirectories&lt;/code&gt; are used to search snippets, it's default to &lt;code&gt;['UltiSnips']&lt;/code&gt;, there are 2 kinds of settings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;relative path&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; let g:UltiSnipsSnippetDirectories = ['UltiSnips','foo']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;UltiSips will loop each path in &lt;code&gt;runtimepath&lt;/code&gt; to search for child directory named &lt;code&gt;UltiSnips&lt;/code&gt; and &lt;code&gt;foo&lt;/code&gt;, and use them as snippets source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &quot;snippets&quot; is reserved for snipMate snippets and cannot be used in&#xA;this list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;absolute path, one entry only&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsSnippetDirectories = [$HOME.'/.vim/UltiSnips']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;UltiSnips will search snippets from and only from this directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also check &lt;code&gt;:h UltiSnips-how-snippets-are-loaded&lt;/code&gt; if you have doubts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your &lt;code&gt;g:UltiSnipsSnippetDirectories&lt;/code&gt; are two absolute paths, it's a mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that &lt;code&gt;ultisnips&lt;/code&gt; itself doesn't contain snippets, it doesn't have a &lt;code&gt;UltiSnips&lt;/code&gt; child directory.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:UltiSnipsSnippetsDir&lt;/code&gt; is your private snippets directory. But by default it's not defined.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g:UltiSnipsSnippetsDir&#xA;                            Defines the directory where private snippet&#xA;                            definition files are placed in in.&#xA;&#xA;                            As example, if the current 'filetype' is &quot;cpp&quot; the&#xA;                            :UltiSnipsEdit command looks for a file to edit in&#xA;                            this order:&#xA;                            1. An existing&#xA;                               g:UltiSnipsSnippetsDir.&quot;/cpp.snippets&quot; file&#xA;                            2. Find a matching &quot;cpp&quot; snippets file in&#xA;                               g:UltiSnipsSnippetDirectories&#xA;                            3. Create a new&#xA;                               g:UltiSnipsSnippetsDir.&quot;/cpp.snippets&quot; file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't mix up &lt;code&gt;g:UltiSnipsSnippetsDir&lt;/code&gt; and &lt;code&gt;g:UltiSnipsSnippetDirectories&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;common setting&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsSnippetsDir = $HOME.'/.vim/UltiSnips'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't change &lt;code&gt;g:UltiSnipsSnippetDirectories&lt;/code&gt;. UltiSnips will loop each path in your &lt;code&gt;runtimepath&lt;/code&gt; to find subdirectory named &lt;code&gt;UltiSnips&lt;/code&gt; as snippets source, when you call &lt;code&gt;UltiSnipsEdit&lt;/code&gt;, it will open your private snippets if you already have one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;g:UltiSnipsSnippetsDir&lt;/code&gt; must be a child directory of one of  &lt;code&gt;runtimepath&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-09T12:43:51.937" LastActivityDate="2019-05-09T12:43:51.937" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19906" PostTypeId="1" AcceptedAnswerId="19923" CreationDate="2019-05-09T16:25:44.810" Score="2" ViewCount="810" Body="&lt;p&gt;I've been trying different colour schemes while manually setting a transparent background using &lt;code&gt;hi Normal guibg=NONE ctermbg=NONE&lt;/code&gt; so my &lt;code&gt;.vimrc&lt;/code&gt; file looks something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co=256&#xA;colo mycolorscheme&#xA;hi Normal guibg=NONE ctermbg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this works fine for some colour schemes but not for others. For those that don't work, I get a different coloured background. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples of colour schemes that worked for me are &lt;a href=&quot;http://vimcolors.com/34/hybrid/dark&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hybrid&lt;/a&gt; and &lt;a href=&quot;https://github.com/sonph/onehalf&quot; rel=&quot;nofollow noreferrer&quot;&gt;onehalfdark&lt;/a&gt; and one example of theme that didn't work is the skin &lt;code&gt;base16-bright&lt;/code&gt; from the &lt;a href=&quot;https://github.com/chriskempson/base16-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Base16 suite&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I manually enter &lt;code&gt;hi Normal guibg=NONE ctermbg=NONE&lt;/code&gt; after vim has loaded, I can get a transparent terminal background. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is it that for some colour schemes, the transparency background is automatically done via &lt;code&gt;.vimrc&lt;/code&gt; but not for some others?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Editted to add examples of colour schemes that work and don't. &lt;/p&gt;&#xA;" OwnerUserId="22178" LastEditorUserId="28" LastEditDate="2019-05-10T20:58:03.513" LastActivityDate="2019-05-11T06:00:50.100" Title="Terminal transparency automatically achieved on certain color schemes, but not others" Tags="|colorscheme|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19907" PostTypeId="1" AcceptedAnswerId="19914" CreationDate="2019-05-09T19:16:34.827" Score="1" ViewCount="118" Body="&lt;p&gt;I'm trying to &lt;a href=&quot;https://stackoverflow.com/questions/56064538/how-to-separate-erroneously-combined-words-in-ocred-text&quot;&gt;bulk correct some OCR formatting issues&lt;/a&gt;. I tried recording a macro that would:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;]s&lt;/code&gt; (advance to the next spelling error)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;z=&lt;/code&gt; (view the suggested corrections)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1&lt;/code&gt; (choose the first suggested correction)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Unfortunately for my purposes, when I replay the macro, it pauses at the step #3 and waits for me to make the selection. Is there a way to still automate that step too (as part of the macro or otherwise)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="22180" LastEditorUserId="22180" LastEditDate="2019-05-09T19:29:05.427" LastActivityDate="2019-05-10T13:35:55.467" Title="Can I record a macro that accepts the first spelling suggestion?" Tags="|macro|spell-checking|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19908" PostTypeId="2" ParentId="19907" CreationDate="2019-05-09T19:39:36.667" Score="1" Body="&lt;p&gt;First assign the macro. Lets use register &lt;code&gt;s&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @s=&quot;]sz=1\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The special thing is &lt;code&gt;\&amp;lt;cr&amp;gt;&lt;/code&gt;. This is Carriage Return that you need to hit after selecting the first spell sugestion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Mass &amp;amp;  D. Ben Knoble pointed out, &lt;code&gt;z=&lt;/code&gt; can take a count. So even simpler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @s=&quot;]s1z=&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now use &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt; to execute the macro in register &lt;code&gt;s&lt;/code&gt;. For the following invocations just use &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;BTW: Be careful with this. I tested it on a text that contains the word &quot;octothorpe&quot;. This was detected as spelling error and the first suggestion was &quot;onto Thorpe&quot;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="1841" LastEditDate="2019-05-10T07:16:51.360" LastActivityDate="2019-05-10T07:16:51.360" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19909" PostTypeId="1" AcceptedAnswerId="19912" CreationDate="2019-05-09T21:13:26.010" Score="0" ViewCount="50" Body="&lt;p&gt;In a file I'd like to replace some occurrences of triplets of 0 with F, 1 with E, ..., F with 0.  Only some, so I can't just pipe the whole file through a bash &lt;code&gt;tr&lt;/code&gt; filter; I need a text editor to examine each occurrence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is to invert the grayscale colors in some 1990's HTML from light-on-dark to dark-on-light, #000 to/from #FFF, #222 to/from #DDD,... .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What almost works:  cursor to the first digit,&#xA;&lt;code&gt;! tr 0123456789ABCDEF FEDCBA9876543210&lt;/code&gt;.  After that I can just hit dot to repeat.  &lt;strong&gt;But&lt;/strong&gt; that also reverses any other digits on the line.  For example, it changes&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;border: 2px solid #555;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;border: Dpx solid #AAA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can I restrict the command to affect just the &lt;code&gt;555&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Or can I write a macro purely within vim that reverses this range of values, just like &lt;code&gt;tr&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Or can a command other than &lt;code&gt;tr&lt;/code&gt;, applied to the whole line, limit its effect to &lt;code&gt;/#[0-9]{3}/&lt;/code&gt;?  Maybe some &lt;code&gt;sed&lt;/code&gt; magic?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(If the last of these three turns out to be the solution, then this question may be off topic here.)&lt;/p&gt;&#xA;" OwnerUserId="12809" LastActivityDate="2019-05-10T01:24:03.670" Title="restrict shell command to only part of a line" Tags="|substitute|macro|shell|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19910" PostTypeId="2" ParentId="10035" CreationDate="2019-05-09T21:58:06.100" Score="4" Body="&lt;p&gt;For what it's worth, I had this problem with MacVim (8.1.950 (155)). Placing the highlight statement after &lt;code&gt;colorscheme&lt;/code&gt; in .vimrc fixed it for me. E.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight SpellCap guisp=Yellow&#xA;...&#xA;colorscheme evening&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;-&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme evening&#xA;...&#xA;highlight SpellCap guisp=Yellow&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6891" LastActivityDate="2019-05-09T21:58:06.100" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19911" PostTypeId="1" AcceptedAnswerId="19913" CreationDate="2019-05-10T01:03:52.727" Score="3" ViewCount="110" Body="&lt;p&gt;Tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\\\/\\/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but VIM will search for &lt;code&gt;\\/\&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there any way I can do this in Vim?&lt;/p&gt;&#xA;" OwnerUserId="21700" LastEditorUserId="24" LastEditDate="2019-05-10T05:19:11.037" LastActivityDate="2019-05-13T05:22:47.783" Title="How do I replace '\\' with '\'?" Tags="|substitute|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19912" PostTypeId="2" ParentId="19909" CreationDate="2019-05-10T01:24:03.670" Score="2" Body="&lt;p&gt;use &lt;code&gt;:h :s\=&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\v\#[0-9A-F]{3}[0-9A-F]@!/\=tr(submatch(0), '0123456789ABCDEF','FEDCBA9876543210')/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\#[0-9A-F]{3}&lt;/code&gt; match &lt;code&gt;#000&lt;/code&gt;, &lt;code&gt;#111&lt;/code&gt;, ... &lt;code&gt;#FFF&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[0-9A-F]@!&lt;/code&gt; look forward to make sure &lt;code&gt;#0000&lt;/code&gt; doesn't match. check &lt;code&gt;:h /\@!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\=&lt;/code&gt; replace with an expression&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;tr(submatch(0), '0123456789ABCDEF','FEDCBA9876543210')&lt;/code&gt; transform matching text&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since you want to do it manually, a command or map would help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command InvertGrayScale s/\v\#[0-9A-F]{3}[0-9A-F]@!/\=tr(submatch(0), '0123456789ABCDEF','FEDCBA9876543210')/g&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;ig :InvertGrayScale&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-05-10T01:24:03.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19913" PostTypeId="2" ParentId="19911" CreationDate="2019-05-10T04:58:05.210" Score="5" Body="&lt;p&gt;In &lt;code&gt;s/\\\/\\/&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the first &lt;code&gt;\&lt;/code&gt; escapes the second &lt;code&gt;\&lt;/code&gt;; &lt;/li&gt;&#xA;&lt;li&gt;the second &lt;code&gt;\&lt;/code&gt; is escaped, so it's no longer special; and&lt;/li&gt;&#xA;&lt;li&gt;the third &lt;code&gt;\&lt;/code&gt; isn't escaped, so it escapes the &lt;code&gt;/&lt;/code&gt; after it.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So you need to escape the third &lt;code&gt;\&lt;/code&gt; like the second was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\\\\/\\/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2019-05-10T04:58:05.210" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19914" PostTypeId="2" ParentId="19907" CreationDate="2019-05-10T13:29:24.607" Score="2" Body="&lt;p&gt;The simple answer is to use a count as @Mass and @D.BenKnoble suggest:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;]s&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1z=&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But let's take a closer look at why your original macro was failing, because it's not quite as simple as @Ralf implies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First try recording your steps into register &lt;code&gt;&quot;r&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then use @Ralf's &lt;code&gt;:let&lt;/code&gt; command to set up register &lt;code&gt;&quot;s&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @s=&quot;]sz=1\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then take a look at the difference in the output of &lt;code&gt;:registers&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;r   ]sz=1^M&#xA;&quot;s   ]sz=1^M^J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you were recording your macro, you pressed &lt;kbd&gt;Enter&lt;/kbd&gt;, and you can see that it's been included in the &lt;code&gt;&quot;r&lt;/code&gt; register as a &lt;code&gt;CTRL-M&lt;/code&gt; or &lt;code&gt;CR&lt;/code&gt; character. (As you may already know, pressing &lt;kbd&gt;CTRL-M&lt;/kbd&gt; and pressing &lt;kbd&gt;Enter&lt;/kbd&gt; within a terminal does the same thing, for &lt;a href=&quot;https://catern.com/posts/terminal_quirks.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;historical reasons&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when you set the &lt;code&gt;&quot;s&lt;/code&gt; register directly with the &lt;code&gt;:let&lt;/code&gt; command, the &lt;code&gt;\&amp;lt;CR&amp;gt;&lt;/code&gt; carriage return has been included as a &lt;code&gt;CTRL-M&lt;/code&gt; followed by a &lt;code&gt;CTRL-J&lt;/code&gt; (&lt;code&gt;CRLF&lt;/code&gt;). I have no idea why there is a difference or why the &lt;code&gt;LF&lt;/code&gt; is required for the macro to work, but let's try re-recording the macro and this time pressing &lt;kbd&gt;CTRL-J&lt;/kbd&gt; after pressing &lt;kbd&gt;Enter&lt;/kbd&gt; to see if we can include this character in our recording:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;kbd&gt;CTRL-J&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now let's take another look at the &lt;code&gt;:registers&lt;/code&gt; output again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;r   ]sz=1^M^@&#xA;&quot;s   ]sz=1^M^J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Okay. Not quite right: pressing &lt;kbd&gt;CTRL-J&lt;/kbd&gt; seems to have inserted a &lt;code&gt;NUL&lt;/code&gt; character into our macro instead of a &lt;code&gt;LF&lt;/code&gt;. (Again, &lt;a href=&quot;https://stackoverflow.com/a/12389839/1208424&quot;&gt;no real idea&lt;/a&gt; why &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#NL-used-for-Nul&quot; rel=&quot;nofollow noreferrer&quot;&gt;this is&lt;/a&gt;.) Still, try running the new macro, and you will discover that it works!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Extra Credit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now let's make the macro recursive so we can &lt;a href=&quot;https://vi.stackexchange.com/a/15872/343&quot;&gt;correct&lt;/a&gt; the entire file with a single &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;z&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;kbd&gt;CTRL-J&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-05-10T13:35:55.467" LastActivityDate="2019-05-10T13:35:55.467" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19915" PostTypeId="1" CreationDate="2019-05-10T16:49:58.937" Score="0" ViewCount="143" Body="&lt;p&gt;I have &lt;code&gt;debug=msg,throw&lt;/code&gt; in my .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When trying to debug a foldexpr function, the &lt;code&gt;echom&lt;/code&gt; statements I use to print are ignored and are not accessible by &lt;code&gt;:messages&lt;/code&gt;. Any way to make them work?&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2019-06-09T18:01:55.477" Title="Debugging foldexpr function" Tags="|vimrc|folding|debugging|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19916" PostTypeId="2" ParentId="19915" CreationDate="2019-05-10T17:32:54.830" Score="2" Body="&lt;p&gt;Sorry I don't have a clear answer to your problem, but a few tricks that you could use instead. Typically, you could add the messages into a &lt;code&gt;|List|&lt;/code&gt; and display them (the list) on demand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my (complex) &lt;a href=&quot;https://github.com/LucHermitte/VimFold4C&quot; rel=&quot;nofollow noreferrer&quot;&gt;folding plugin for C&amp;amp;C++&lt;/a&gt;, I've used various techniques:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;balloons to display various information when the mouse is over a line&lt;/li&gt;&#xA;&lt;li&gt;signs to display in front of each line what the related call to foldexpr has returned&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/Log.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;my logging framework&lt;/a&gt; that can report messages to the quickfix window (which is quite slow and best to not overuse each time &lt;code&gt;foldexpr&lt;/code&gt; is evaluated)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, when there is an error, the only thing that permits to see the error is something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo map(range(1, line('$')), 'the_fold_function(v:val)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This last trick should also permit to display the messages you have produced.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2019-05-10T17:32:54.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19917" PostTypeId="1" AcceptedAnswerId="19924" CreationDate="2019-05-10T18:01:14.583" Score="2" ViewCount="1962" Body="&lt;p&gt;I'd like to be able to &lt;code&gt;:Sex&lt;/code&gt; when editing a file, select a file, press CR, and have that new split populated with the file I just selected. Is there an option for this? I think I became used to this behavior when using NERDtree or another plugin.&lt;/p&gt;&#xA;" OwnerUserId="2418" LastActivityDate="2019-05-11T06:17:34.890" Title="Replace netrw window when opening a file" Tags="|split|netrw|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19918" PostTypeId="2" ParentId="11210" CreationDate="2019-05-10T23:09:36.390" Score="2" Body="&lt;p&gt;By default &lt;code&gt;space&lt;/code&gt; in vim is &quot;move right 1 character&quot; which is already covered by &lt;code&gt;l&lt;/code&gt;, so I've remapped space to re-run a macro from the q buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;Space&amp;gt; @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use, just record a macro with &lt;code&gt;qq&lt;/code&gt; first, stop recording with &lt;code&gt;q&lt;/code&gt; and then hit &lt;code&gt;space&lt;/code&gt; to replay.&lt;/p&gt;&#xA;" OwnerUserId="1712" LastActivityDate="2019-05-10T23:09:36.390" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19919" PostTypeId="1" CreationDate="2019-05-11T00:29:25.593" Score="2" ViewCount="1660" Body="&lt;p&gt;When debugging my vimrc, I often want to log informational messages, e.g. things like &quot;skipping function X because a necessary plugin isn't available&quot;. I can use &lt;code&gt;echom&lt;/code&gt; statements to do that, but they block. At least, they do under gvim; I get an error window on startup that must be dismissed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want a way to log messages for future perusal, without otherwise obstructing what vimrc is doing. Can it be done?&lt;/p&gt;&#xA;" OwnerUserId="20175" LastActivityDate="2019-05-11T05:49:49.077" Title="How can I log debug messages without blocking?" Tags="|echo|debugging|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19921" PostTypeId="2" ParentId="19919" CreationDate="2019-05-11T04:20:23.040" Score="1" Body="&lt;p&gt;As @dedowsdi said in a comment: Log into a list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is derived from stuff I have in one of my plugins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DebugMsg(msg) abort&#xA;    if !exists(&quot;g:DebugMessages&quot;)&#xA;        let g:DebugMessages = []&#xA;    endif&#xA;    call add(g:DebugMessages, a:msg)&#xA;endfunction&#xA;&#xA;function! PrintDebugMsgs() abort&#xA;  if empty(get(g:, &quot;DebugMessages&quot;, []))&#xA;    echo &quot;No debug messages.&quot;&#xA;    return&#xA;  endif&#xA;  for ln in g:DebugMessages&#xA;    echo &quot;- &quot; . ln&#xA;  endfor&#xA;endfunction&#xA;&#xA;command DebugStatus call PrintDebugMsgs()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call DebugMsg(&quot;Doing this&quot;)&#xA;...&#xA;call DebugMsg(&quot;Doing&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To display the messages execute the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:DebugStatus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-05-11T04:20:23.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19922" PostTypeId="2" ParentId="19919" CreationDate="2019-05-11T05:28:00.100" Score="1" Body="&lt;p&gt;I'm sure there are at least a few third party alternatives for this. One I'm familiar with is &lt;em&gt;Decho&lt;/em&gt; which is used by netrw. You can enable/disable logging, indicate function enter/leave and depth and other useful things with any one of the following as the message destination:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Appended to separate window&lt;/li&gt;&#xA;&lt;li&gt;Uses &lt;code&gt;:echomsg&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Appended to a variable (default &lt;code&gt;g:dechovar&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Appended to a remote server&lt;/li&gt;&#xA;&lt;li&gt;Appended to a tab&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The window or tab will be opened automatically by &lt;em&gt;Decho&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple other features:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Basic output config (e.g. toggle line numbers and/or function names)&lt;/li&gt;&#xA;&lt;li&gt;Basic config of debug message window (e.g. # lines)&lt;/li&gt;&#xA;&lt;li&gt;Option to keep debug window closed until explicitly opened (e.g. to avoid conflicts with plugins that take control of windows).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Get &lt;a href=&quot;http://www.drchip.org/astronaut/vim/vbafiles/Decho.vba.gz&quot; rel=&quot;nofollow noreferrer&quot;&gt;Decho here&lt;/a&gt;. And here's &lt;a href=&quot;http://www.drchip.org/astronaut/vim/doc/Decho.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;the manual&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-05-11T05:49:49.077" LastActivityDate="2019-05-11T05:49:49.077" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19923" PostTypeId="2" ParentId="19906" CreationDate="2019-05-11T06:00:50.100" Score="1" Body="&lt;p&gt;There's no one, generic answer to your question. You'll need read the documentation for each color scheme that's giving you problems. For instance with Base16-Vim (which you linked as &quot;Base16 suite&quot;) you'll find the following instructions for customizing the scheme&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you want to do some local customization, you can add something like this to your ~/.vimrc:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:base16_customize() abort&#xA;  call Base16hi(&quot;MatchParen&quot;, g:base16_gui05, g:base16_gui03, g:base16_cterm05, g:base16_cterm03, &quot;bold,italic&quot;, &quot;&quot;)&#xA;endfunction&#xA;&#xA;augroup on_change_colorschema&#xA;  autocmd!&#xA;  autocmd ColorScheme * call s:base16_customize()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Really you should read all of the documentation as the installation for some of these is not the usual &quot;drop it in the colors dir&quot;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-05-11T06:00:50.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19924" PostTypeId="2" ParentId="19917" CreationDate="2019-05-11T06:17:34.890" Score="2" Body="&lt;p&gt;Well, I have &lt;code&gt;let g:netrw_browse_split = 4&lt;/code&gt; in my vimrc under the comment &quot;These settings cause Netrw file explorer to behave more like NERDTree&quot; yet I see the same behavior as you're seeing now. So 1) you must be thinking about that other plugin and, more importantly, 2) I'd guess you (or something) is setting that global var somewhere. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you want is to unset it or set it explicitly to 0.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  *g:netrw_browse_split*    when browsing, &amp;lt;cr&amp;gt; will open the file by:&#xA;                =0: re-using the same window  (default)&#xA;                =1: horizontally splitting the window first&#xA;                =2: vertically   splitting the window first&#xA;                =3: open file in new tab&#xA;                =4: act like &quot;P&quot; (ie. open previous window)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tested with 0 and it works the way you want.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-05-11T06:17:34.890" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19925" PostTypeId="2" ParentId="19864" CreationDate="2019-05-11T06:24:43.877" Score="1" Body="&lt;p&gt;In theory, it's fairly easy. I practice, there are a few gotcha's. Let's walk through this step by step, and I'll tell you what to look for. Once you validate that everything is correct, you ought to be able to do this lickity-split.&lt;br&gt;&#xA;Note: I use Red Hat/CentOS. You may have to make slight variations in commands for your environment.&lt;br&gt;&#xA;&lt;br&gt;&#xA;On &quot;local&quot; make sure &lt;code&gt;xhost&lt;/code&gt; is set correctly. Easy way:&lt;br&gt;&#xA;&lt;code&gt;[me@local]$ xhost +&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For convenience, check your DISPLAY variable:&lt;br&gt;&#xA;&lt;code&gt;[me@local]$ echo $DISPLAY&lt;/code&gt;&#xA;You should see something like &lt;code&gt;:0&lt;/code&gt; or &lt;code&gt;:0.1&lt;/code&gt;&lt;br&gt;&#xA;   (More later)&#xA;&lt;br&gt;&#xA;Next, use ssh with X-Display forwarding:&lt;br&gt;&#xA;&lt;code&gt;[me@local]$ ssh -X middle -l me&lt;/code&gt;&lt;br&gt;&#xA;Alternately: &lt;code&gt;ssh -X me@middle&lt;/code&gt;&lt;br&gt;&#xA;&lt;br&gt;&#xA;Now, here it is important to ensure that your DISPLAY variable is set correctly. On some machines, the login files are configured to set your DISPLAY variable for you. &lt;strong&gt;This will break the X-Display forwarding!!&lt;/strong&gt;&lt;br&gt;&#xA;&lt;code&gt;[me@middle]$ echo $DISPLAY&lt;/code&gt;&#xA;The &lt;strong&gt;correct&lt;/strong&gt; setting will look like this:&lt;br&gt;&#xA;&lt;code&gt;localhost:10&lt;/code&gt;  or even&lt;br&gt;&#xA;&lt;code&gt;localhost:11.1&lt;/code&gt;&lt;br&gt;&#xA;The &lt;strong&gt;incorrect&lt;/strong&gt; setting will look something like this:&#xA;&lt;code&gt;*starting_hostname*:0.0&lt;/code&gt;&lt;br&gt;&#xA;If you have an incorrect setting, you cannot manually change the DISPLAY environment back. You &lt;em&gt;must&lt;/em&gt; find where your login scripts on the &quot;middle&quot; host are changing it and leave it the default.&lt;br&gt;&#xA;&lt;br&gt;&#xA;Third, ssh using X-Display forwarding into server:&lt;br&gt;&#xA;&lt;code&gt;[me@middle]$ ssh -X me@server&lt;/code&gt;&lt;br&gt;&#xA;Check your DISPLAY variable again. The same caveat as above applies here. It must be &lt;em&gt;localhost:[number]&lt;/em&gt;&lt;br&gt;&#xA;&lt;br&gt;&#xA;At this point, check that your remote display is working correctly by starting &lt;em&gt;any&lt;/em&gt; GUI program and validate that screen appears on the local box.&lt;br&gt;&#xA;&lt;br&gt;&#xA;Once you are sure everything is configured, you can run these commands:&lt;br&gt;&#xA;&lt;code&gt;[me@local]$ xhost +&#xA;[me@local]$ ssh -X me@middle&#xA;[me@middle]$ ssh -X me@server&#xA;[me@server]$ gvim my_filename&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additional info:&lt;br&gt;&#xA;Port 6000 needs to be open between all of the boxes. That is the X-Display forwarding port.&lt;br&gt;&#xA;&lt;br&gt;&#xA;The X-Display programs &amp;amp; libraries need to be installed on &quot;server.&quot; (OS Dependent, can't help you here). IF you program (gVIM) calls the &quot;draw a box api&quot; and the &quot;server&quot; OS doesn't know what that is, it will never work.&lt;br&gt;&#xA;(Really what happens is, &quot;server&quot; application says &quot;Draw a box with these coordinates.&quot; The &quot;server&quot; X-window system says &quot;OK. But, I don't have a monitor ... oh, wait, I'll just draw the box on the 'localhost' monitor.&quot;&lt;br&gt;&#xA;&lt;br&gt;&#xA;&quot;server&quot; and &quot;local&quot; have to have compatible X-windowing systems. I've seen issues where Solaris or AIX talking to a CentOS box doesn't always work.&lt;br&gt;&#xA;&lt;br&gt;&#xA;Unless you are using IP addresses in lieu of hostnames, each of your machines need to be able to resolve all 3 host names to an IP address. Usually, I just ensure that all 3 host/IP names in /etc/hosts. This sounds odd, but I have seen this be an issue. And, FWIW, add FQDN &amp;amp; Short Hostname to /etc/hosts.&lt;/p&gt;&#xA;" OwnerUserId="20986" LastActivityDate="2019-05-11T06:24:43.877" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19926" PostTypeId="1" CreationDate="2019-05-11T08:24:48.513" Score="0" ViewCount="35" Body="&lt;p&gt;When I try using &lt;code&gt;vim --startuptime myfile&lt;/code&gt;, it reports it is not compiled in.&#xA;There seems to be no instructions on how to compile in startuptime. I have tried adding &lt;code&gt;--enable-startuptime&lt;/code&gt; to the configure, but that only complains. Looking through the Makefile finds no startuptime. :help offers no help. Googling for several hours offers no help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does one get this feature &quot;compiled&quot;?&lt;/p&gt;&#xA;" OwnerUserId="22191" LastEditorUserId="19763" LastEditDate="2019-05-11T11:03:00.663" LastActivityDate="2019-05-11T11:03:00.663" Title="How to compile startuptime for ver 8?" Tags="|compile-vim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19927" PostTypeId="1" CreationDate="2019-05-11T08:41:44.060" Score="3" ViewCount="3908" Body="&lt;p&gt;I know that the autocommand &lt;code&gt;autocmd BufEnter&lt;/code&gt; will be triggered every time a buffer is entered. Is there a way to define an &lt;code&gt;autocmd&lt;/code&gt; that will be triggered only the first time a buffer is entered?&lt;/p&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2019-05-31T11:42:08.820" Title="autocmd for the event: &quot;the first time a buffer is entered&quot;" Tags="|buffers|autocmd|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19929" PostTypeId="2" ParentId="6040" CreationDate="2019-05-11T09:18:54.777" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a plugin or setting which provides this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;a href=&quot;https://github.com/ryvnf/readline.vim&quot; rel=&quot;noreferrer&quot;&gt;readline.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a newer plug-in which focuses purely on the command-line.  It also implements a larger subset of the Readline shortcuts and has the goal of implementing each shortcut exactly like in Readline.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What makes this plugin different from similar plugins is that it implements a&#xA;  larger subset of the Readline mappings, and that it does a better job of&#xA;  mimicking the Readline behavior for each command.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The word movement and deletion commands have different behavior between Vim&#xA;  and Readline. The biggest difference is that in Readline punctuation is&#xA;  always skipped when searching for a word boundary. Another difference is that&#xA;  _ (underscore) is treated as a word delimiter. This plugin implements the&#xA;  Readline behavior for word movement and deletion commands.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3032" LastActivityDate="2019-05-11T09:18:54.777" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19930" PostTypeId="2" ParentId="19926" CreationDate="2019-05-11T09:30:57.207" Score="1" Body="&lt;p&gt;It's all in &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Aversion&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :version&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/various.txt.html#%2Bfeature-list&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h +feature-list&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;The first column shows the smallest version in which&#xA;they are included:&#xA;   T    tiny (always)&#xA;   S    small&#xA;   N    normal&#xA;   B    big&#xA;   H    huge&#xA;   m    manually enabled or depends on other features&#xA; (none) system dependent&#xA;...&#xA;...&#xA;N  *+startuptime*   |--startuptime| argument&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It requires version no less than &lt;code&gt;normal&lt;/code&gt; to include &lt;code&gt;+startuptime&lt;/code&gt;, most people use &lt;code&gt;huge&lt;/code&gt; to include as many features as possible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --with-features=huge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-11T10:33:35.437" LastActivityDate="2019-05-11T10:33:35.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19931" PostTypeId="2" ParentId="19911" CreationDate="2019-05-11T14:12:40.293" Score="1" Body="&lt;pre&gt;&lt;code&gt;:1,$:s/\\\\/\\/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;1 means the first line and $ means till the last one.&#xA;each &lt;code&gt;\\&lt;/code&gt; means &lt;code&gt;\&lt;/code&gt;, and &lt;code&gt;\/&lt;/code&gt; removes the &lt;code&gt;/&lt;/code&gt; as divider, here you have your syntax error.&lt;/p&gt;&#xA;" OwnerUserId="22194" LastEditorUserId="205" LastEditDate="2019-05-13T05:22:47.783" LastActivityDate="2019-05-13T05:22:47.783" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19932" PostTypeId="1" CreationDate="2019-05-11T16:50:28.790" Score="2" ViewCount="234" Body="&lt;p&gt;the goal is to be able to write functions names that follow PEP8 as easily and naturally as writing this sentence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;there are many types of situations that need handling&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;insert &lt;code&gt;_&lt;/code&gt; (underscores) for lines that&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;start with &lt;code&gt;&amp;lt;optional indentation&amp;gt;def&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;end with &lt;code&gt;.&amp;lt;optional_start_of_method_name&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;only when the cursor is not&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;directly after a comma (&lt;code&gt;,&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;in an inline comment&lt;/li&gt;&#xA;&lt;li&gt;after the closing parenthesis &lt;code&gt;)&lt;/code&gt; of a function definition or call&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;is there a plugin that already does that? if not, how can I test for the aforementioned situations in vimscript?&lt;/p&gt;&#xA;" OwnerUserId="20087" LastEditorUserId="20087" LastEditDate="2019-05-13T15:22:34.733" LastActivityDate="2019-05-14T09:32:20.223" Title="imap &lt;space&gt; to _ (underscore) when writing function names in python files" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19933" PostTypeId="2" ParentId="19932" CreationDate="2019-05-11T19:45:37.147" Score="2" Body="&lt;p&gt;This remap &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; to &lt;code&gt;_&lt;/code&gt; if the line starts with &lt;code&gt;def&lt;/code&gt;, which is the key to declare a function in python.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;space&amp;gt; getline('.')[0:3] == 'def ' ? &quot;_&quot; : &quot;&amp;lt;space&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try also the autocmd way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType python inoremap &amp;lt;expr&amp;gt; &amp;lt;space&amp;gt; getline('.')[0:3] == 'def ' ? &quot;_&quot; : &quot;&amp;lt;space&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT1:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps it's better to avoid using '_' between function arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;space&amp;gt; getline('.')[0:3] == 'def ' &amp;amp;&amp;amp; getline('.') !~ '(' ? &quot;_&quot; : &quot;&amp;lt;space&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I modified the approach detecting if the line ends with a dot as you ask:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! IsPythonFunction()&#xA;    return getline('.')[0:3] == 'def ' || getline('.')[-1:] == '.'&#xA;endfunction&#xA;&#xA;:inoremap &amp;lt;expr&amp;gt; &amp;lt;space&amp;gt; (IsPythonFunction() &amp;amp;&amp;amp; getline('.') !~ '(' ) ? &quot;_&quot; : &quot;&amp;lt;space&amp;gt;&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, I suggest to use the autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType python inoremap &amp;lt;expr&amp;gt; &amp;lt;space&amp;gt; (IsPythonFunction() &amp;amp;&amp;amp; getline('.') !~ '(' ) ? &quot;_&quot; : &quot;&amp;lt;space&amp;gt;&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="343" LastEditDate="2019-05-14T09:32:20.223" LastActivityDate="2019-05-14T09:32:20.223" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19934" PostTypeId="1" AcceptedAnswerId="19961" CreationDate="2019-05-12T16:37:54.020" Score="1" ViewCount="1310" Body="&lt;p&gt;Vim only seems to highlight comments, numbers, and imported modules. So function calls, attributes, etc are all non-highlighted. I have 'syntax on' and 'filetype plugin indent on' in my vimrc. syntax highlighting works with every other language EXCEPT python. I cant figure out why it doesnt like python. Any suggestions would be greatly appreciated! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using vim on mac terminal (vim Version: 8.1) installed via homebrew. I have verified that this is the version I am using. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: &#xA;output of FT: Filetype=Python &lt;br&gt;&#xA;Upon further research, it seems like perhaps my syntax highlighting is working, just not quit as good as I would of hoped. I thought I would be able to get similar syntax highlighting to something like atom&lt;/p&gt;&#xA;" OwnerUserId="22221" OwnerDisplayName="be_elle95" LastEditorUserId="22221" LastEditDate="2019-05-14T02:33:23.667" LastActivityDate="2019-05-14T23:19:04.863" Title="vim python syntax not working (Partly)" Tags="|syntax-highlighting|filetype-python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19935" PostTypeId="2" ParentId="19932" CreationDate="2019-05-12T20:44:20.350" Score="1" Body="&lt;p&gt;I improved upon @simo-zz (currently deleted/hidden) answer to&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;insert a space directly after a comma and underscores after that&lt;/li&gt;&#xA;&lt;li&gt;insert underscores after a dot or after a dot + start of a method name&lt;/li&gt;&#xA;&lt;li&gt;insert underscores after &lt;code&gt;def&lt;/code&gt; no matter it's indentation level&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! IsPythonFunction()&#xA;    let line = getline('.')&#xA;    let coln = col('.')&#xA;    let lineUptoCursor = line[0:coln-2]&#xA;    return (lineUptoCursor[-1:] != ',') &amp;amp;&amp;amp; ((line =~? '\(.\+ \)\?def ') || (line =~? '.\+\.\(.\+\)\?'))&#xA;endfunction&#xA;autocmd FileType python inoremap &amp;lt;expr&amp;gt; &amp;lt;space&amp;gt; (IsPythonFunction()) ? &quot;_&quot; : &quot;&amp;lt;space&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what's left for improvement:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;insert spaces not underscores in inline comments &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;harder that it initially seems, needs to exclude cases where the &lt;code&gt;#&lt;/code&gt; is inside a string, which probably requires an ast parser&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;insert spaces not underscores after the colon &lt;code&gt;:&lt;/code&gt; which comes after the parenthesis &lt;code&gt;()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="20087" LastEditorUserId="20087" LastEditDate="2019-05-12T20:56:50.293" LastActivityDate="2019-05-12T20:56:50.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19936" PostTypeId="1" AcceptedAnswerId="19938" CreationDate="2019-05-13T00:07:01.880" Score="2" ViewCount="105" Body="&lt;p&gt;I am a user of neomutt and I use neovim as my default editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I delete a character via backspace, and then type the correct character, I sometimes get a strange character from a different language. To give an example, If have have the word &quot;coe&quot;, and I want to change &quot;e&quot; to &quot;d&quot;, then I naturally would press backspace and then &quot;d&quot;. However, that inserts &quot;coで&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running into this problem only when I run neovim though neomutt. When I run vim regularly, I don't encounter this issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea what could cause this issue? I am a mac user.&lt;/p&gt;&#xA;" OwnerUserId="22203" LastEditorUserId="343" LastEditDate="2019-05-13T13:26:45.157" LastActivityDate="2019-05-13T13:26:45.157" Title="Backspace + keypress adds a character of a different language in neovim with neomutt on my mac" Tags="|insert-mode|digraphs|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19937" PostTypeId="2" ParentId="19927" CreationDate="2019-05-13T04:45:21.047" Score="3" Body="&lt;p&gt;Based on your comment&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My workflow usually involves having several buffers open, and switching between them using :bn and :bp. So I'm looking for a way to execute a command when I enter a buffer that I haven't entered before. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you start Vim with several files, they are not read into memory immediately at startup. The file is only read when you enter the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can use the autocmd event &quot;BufReadPost&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufReadPost * echo strftime(&quot;%c&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then open Vim with multiple &lt;em&gt;existing&lt;/em&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will print a timestamp immediately on startup, as you entered the first buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then it will print a timestamp on every &lt;code&gt;:bn&lt;/code&gt;, as you are entering a yet unvisited buffer (and it's file is read). If you use &lt;code&gt;:bp&lt;/code&gt; to return to a file you already visited, no timestamp will be printed. &#xA;Also no timestamp when you reached the end of the list and &lt;code&gt;:bn&lt;/code&gt; brings you to the first file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;only works when &lt;code&gt;hidden&lt;/code&gt; is set&lt;/li&gt;&#xA;&lt;li&gt;the autocmd also fires when you reload a file (with &lt;code&gt;:e&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;is not executed for new files, as there is no file to read yet&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-05-31T11:42:08.820" LastActivityDate="2019-05-31T11:42:08.820" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19938" PostTypeId="2" ParentId="19936" CreationDate="2019-05-13T12:44:16.650" Score="1" Body="&lt;p&gt;As @D.BenKnoble and @statox have mentioned, this sounds like you have the &lt;code&gt;'digraph'&lt;/code&gt; option set in Neovim but not in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:set nodigraph&lt;/code&gt; in a running instance of Neovim should fix the problem, and you can run &lt;code&gt;:verbose set digraph?&lt;/code&gt; to find out what part of your configuration is setting this option so you can resolve the issue properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/digraph.txt.html#i_digraph&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_digraph&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27digraph%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'digraph'&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-05-13T12:44:16.650" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19939" PostTypeId="2" ParentId="19886" CreationDate="2019-05-13T13:07:56.647" Score="0" Body="&lt;p&gt;I can never resist solving &lt;a href=&quot;https://vi.stackexchange.com/questions/19243/search-for-line-move-to-end-of-search-string-then-searchreplace/19268#19268&quot;&gt;this sort of problem&lt;/a&gt; with a &lt;a href=&quot;https://vi.stackexchange.com/questions/6426/how-do-i-stop-a-recursive-macro-at-the-end-of-the-line/6428#6428&quot;&gt;recursive macro&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, the complete set of keystrokes required to record and playback the macro:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt;&lt;kbd&gt;Right&lt;/kbd&gt;&lt;kbd&gt;Right&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;Right&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How it works&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; &amp;mdash; Recursive macro boilerplate. This clears out the &lt;code&gt;&quot;q&lt;/code&gt; register and starts recording a new macro into it,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt; &amp;mdash; Surround the character under the cursor with quotes*,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Right&lt;/kbd&gt;&lt;kbd&gt;Right&lt;/kbd&gt; &amp;mdash; Move to the next character. If we're at the end of the line, this command will fail**, and the recursive macro will stop,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; &amp;mdash; Add the comma-space, &lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Right&lt;/kbd&gt; &amp;mdash; Move to the next character on the line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; &amp;mdash; More boilerplate: when you are recording the macro, the first &lt;code&gt;@q&lt;/code&gt; does nothing because we cleared out the &lt;code&gt;&quot;q&lt;/code&gt; register in Step 1. However, when &lt;em&gt;playing back&lt;/em&gt; the macro, this will cause the macro to run again. The second &lt;code&gt;q&lt;/code&gt; then stops and saves the recording, and the final &lt;code&gt;@q&lt;/code&gt; plays back the macro.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* An alternative, here: &lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;&lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ctrl-R&lt;/a&gt;&lt;/kbd&gt;&lt;kbd&gt;-&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt; This variation is useful if you're ever trying to surround something with something longer than single characters, such as an HTML tag.&lt;br&gt;** If you've added &lt;code&gt;&amp;gt;&lt;/code&gt; to your &lt;code&gt;'whichwrap'&lt;/code&gt; setting, then the second &lt;code&gt;Right&lt;/code&gt; will instead move to the next line and your recursive macro will carry on splitting characters all the way to the end of the file! Replace &lt;code&gt;Right&lt;/code&gt; with &lt;code&gt;Space&lt;/code&gt; or &lt;code&gt;l&lt;/code&gt; to fix, depending on which of these is missing from your &lt;code&gt;'whichwrap'&lt;/code&gt; setting. If you have all three keystrokes in your &lt;code&gt;'whichwrap'&lt;/code&gt;, consider whether you really need all three &quot;move right one character&quot; commands to work in the same way at the end of a line.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Playing back on multiple lines&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Once you've got the macro recorded, if you want to run it on multiple lines, you can use a command like the following, which will convert lines 5&amp;ndash;10:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5,10norm!@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :normal&lt;/code&gt; and &lt;code&gt;:help ranges&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-05-13T13:30:35.937" LastActivityDate="2019-05-13T13:30:35.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19940" PostTypeId="1" CreationDate="2019-05-13T13:53:34.390" Score="6" ViewCount="590" Body="&lt;p&gt;I have the habit of leaving comments in my C source files like &lt;code&gt;// @TODO&lt;/code&gt; or &lt;code&gt;// @CHECK&lt;/code&gt; to quickly be able to get back to where I may have things to do.&#xA;I can already match those in pretty much any language with vimgrep and get them in the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, they're all a bit different and/or anywhere in a particular line: some are TODOs, some are CHECKs, and others may anything else. The quickfix list unfortunately lists them in no useful order, and to get the &quot;type&quot; (the few capital letters after the &lt;code&gt;@&lt;/code&gt;) I sometimes have to look at all the line if the pattern is near the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like to do is &quot;add a column&quot; to the quickfix list that displays that &quot;type&quot; (so, for &lt;code&gt;@CHECK&lt;/code&gt; it would be &lt;code&gt;CHECK&lt;/code&gt;, and so on), and to be able to filter this to keep only one &quot;type&quot; (so maybe keep only &lt;code&gt;FIXME&lt;/code&gt; or only &lt;code&gt;TODO&lt;/code&gt;). If possible, I'd also like to sort this list alphabetically according to the type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have dug a bit, and it seems it may not be possible with the quickfix list, but I don't really know that many plugins. It also seems to be a use case for tags, but likewise, I don't really know how I could generate and update a list of those particular tags &lt;em&gt;and&lt;/em&gt; add a column to the quickfix to show the &quot;tag name&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would I need a plugin to do this ? Could you point me to a particular one, maybe with a few configuration tips ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance !&lt;/p&gt;&#xA;" OwnerDisplayName="user22210" LastActivityDate="2021-02-24T03:03:19.580" Title="Changing how the quickfix list displays matches" Tags="|quickfix|vimgrep|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19941" PostTypeId="1" AcceptedAnswerId="19958" CreationDate="2019-05-13T19:19:26.483" Score="0" ViewCount="930" Body="&lt;p&gt;Today when i opened spacevim the ColorScheme was just blue! &lt;a href=&quot;https://i.stack.imgur.com/8Qwu8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8Qwu8.png&quot; alt=&quot;blue theme&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My init.toml:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[options]&#xA;# set spacevim theme. by default colorscheme layer is not loaded,&#xA;# if you want to use more colorscheme, please load the colorscheme&#xA;# layer&#xA;colorscheme = &quot;onedark&quot;&#xA;colorscheme_bg = &quot;dark&quot;&#xA;# Disable guicolors in basic mode, many terminal do not support 24bit&#xA;# true colors&#xA;enable_guicolors = true&#xA;# Disable statusline separator, if you want to use other value, please&#xA;# install nerd fonts&#xA;statusline_separator = &quot;arrow&quot;&#xA;statusline_inactive_separator = &quot;arrow&quot;&#xA;buffer_index_type = 4&#xA;enable_tabline_filetype_icon = true&#xA;&#xA;enable_statusline_mode = false&#xA;[[layers]]&#xA;name = 'autocomplete'&#xA;auto-completion-return-key-behavior = &quot;complete&quot;&#xA;auto-completion-tab-key-behavior = &quot;smart&quot;&#xA;&#xA;[[layers]]&#xA;name=&quot;colorscheme&quot;&#xA;&#xA;[[layers]]&#xA;name = 'shell'&#xA;default_position = 'top'&#xA;default_height = 30&#xA;&#xA;[[layers]]&#xA;name=&quot;lang#python&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim Version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 23 2019 20:00:52)&#xA;    macOS version&#xA;    Included patches: 1-1200&#xA;    Compiled by Homebrew&#xA;    Huge version without GUI.  Features included (+) or not (-):&#xA;    +acl               +extra_search      +mouse_netterm     -tag_old_static&#xA;    +arabic            -farsi             +mouse_sgr         -tag_any_white&#xA;    +autocmd           +file_in_path      -mouse_sysmouse    -tcl&#xA;    +autochdir         +find_in_path      +mouse_urxvt       +termguicolors&#xA;    -autoservername    +float             +mouse_xterm       +terminal&#xA;    -balloon_eval      +folding           +multi_byte        +terminfo&#xA;    +balloon_eval_term -footer            +multi_lang        +termresponse&#xA;    -browse            +fork()            -mzscheme          +textobjects&#xA;    ++builtin_terms    +gettext           +netbeans_intg     +textprop&#xA;    +byte_offset       -hangul_input      +num64             +timers&#xA;    +channel           +iconv             +packages          +title&#xA;    +cindent           +insert_expand     +path_extra        -toolbar&#xA;    -clientserver      +job               +perl              +user_commands&#xA;    +clipboard         +jumplist          +persistent_undo   +vartabs&#xA;    +cmdline_compl     +keymap            +postscript        +vertsplit&#xA;    +cmdline_hist      +lambda            +printer           +virtualedit&#xA;    +cmdline_info      +langmap           +profile           +visual&#xA;    +comments          +libcall           -python            +visualextra&#xA;    +conceal           +linebreak         +python3           +viminfo&#xA;    +cryptv            +lispindent        +quickfix          +vreplace&#xA;    +cscope            +listcmds          +reltime           +wildignore&#xA;    +cursorbind        +localmap          +rightleft         +wildmenu&#xA;    +cursorshape       +lua               +ruby              +windows&#xA;    +dialog_con        +menu              +scrollbind        +writebackup&#xA;    +diff              +mksession         +signs             -X11&#xA;    +digraphs          +modify_fname      +smartindent       -xfontset&#xA;    -dnd               +mouse             +startuptime       -xim&#xA;    -ebcdic            -mouseshape        +statusline        -xpm&#xA;    +emacs_tags        +mouse_dec         -sun_workshop      -xsmp&#xA;    +eval              -mouse_gpm         +syntax            -xterm_clipboard&#xA;    +ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save&#xA;       system vimrc file: &quot;$VIM/vimrc&quot;&#xA;         user vimrc file: &quot;$HOME/.vimrc&quot;&#xA;     2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;          user exrc file: &quot;$HOME/.exrc&quot;&#xA;           defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;      fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;    Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;    Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -lintl -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.14 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.28.1/lib/perl5/5.28.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation  -lruby.2.6 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21916" LastEditorUserId="21916" LastEditDate="2019-05-13T19:42:25.903" LastActivityDate="2019-06-13T16:04:45.637" Title="ColorScheme Not Working-Just Blue Color (Spacevim)" Tags="|spacevim|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19942" PostTypeId="1" CreationDate="2019-05-14T01:18:01.887" Score="1" ViewCount="27" Body="&lt;p&gt;I use vim to write text, and that’s why I often use it in combination with the Pencil plugin. The plugin creates significant delay in the movement of the cursor when in insert mode. I have tried to remap the arrow keys to quit the insert mode before moving the cursor, but this does not seem to work for up and down arrows as long as Pencil is enabled. Is there any way to override Pencil’s key bindings in this case, or any way to speed up the cursor movement when in insert mode?&lt;/p&gt;&#xA;" OwnerUserId="22219" LastActivityDate="2019-05-14T01:18:01.887" Title="How can I remap the arrow buttons in insert mode when Pencil is enabled" Tags="|key-bindings|insert-mode|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19943" PostTypeId="2" ParentId="17" CreationDate="2019-05-14T04:04:26.703" Score="2" Body="&lt;pre&gt;&lt;code&gt;100GV325G&amp;lt;esc&amp;gt;&#xA;/\v%Vpattern&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;100GV325G&amp;lt;esc&amp;gt;&lt;/code&gt; visually select lines from 100 to 325, return to &lt;code&gt;normal&lt;/code&gt; mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/\v%Vpattern&lt;/code&gt; use &lt;code&gt;:h /\%V&lt;/code&gt; to limit search ranges to last visual area.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If your pattern contains newline, you must add another &lt;code&gt;\%V&lt;/code&gt; to restrict pattern end in visual area:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;100GV325G&amp;lt;esc&amp;gt;&#xA;/\v%Vpattern%V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h /\%V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-21T09:43:04.447" LastActivityDate="2019-05-21T09:43:04.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19944" PostTypeId="1" CreationDate="2019-05-14T04:38:29.893" Score="1" ViewCount="108" Body="&lt;p&gt;recently i stumpled over vim :terminal mode.&#xA;i am really exited about that.&#xA;now i wanted to ask, how i can create a mapping, which sends a command, including a pipe symbol to :terminal?&#xA;it should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;hcu :term echo &quot;hello&quot; | grep &quot;ll&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But gives me something like this: &lt;a href=&quot;https://i.stack.imgur.com/1U0EG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/1U0EG.png&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any hints, on how i can use commands like this with the :term command?&lt;/p&gt;&#xA;" OwnerUserId="20506" LastActivityDate="2019-05-14T05:41:06.357" Title="use pipe symbol in vim :term command" Tags="|terminal|terminal-buffer|" AnswerCount="0" CommentCount="2" ClosedDate="2019-05-14T05:40:03.260" ContentLicense="CC BY-SA 4.0" />
  <row Id="19945" PostTypeId="1" AcceptedAnswerId="19951" CreationDate="2019-05-14T07:26:48.460" Score="7" ViewCount="12363" Body="&lt;p&gt;Suppose we have the following very simple file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 x 3 x&#xA;x 3 x 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I'd like to have a pattern that matches all lines containing &lt;em&gt;both&lt;/em&gt; &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;3&lt;/code&gt;. The order and position should not matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note that I used a very simple file on purpose. The file could contain many more lines, and the ”words“ could be words like ”hello“ and ”world“.)&lt;/p&gt;&#xA;" OwnerUserId="19901" LastActivityDate="2019-05-17T15:00:16.460" Title="regular expression to find lines containing multiple specific words or patterns in any arbitrary order" Tags="|regular-expression|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19946" PostTypeId="2" ParentId="19945" CreationDate="2019-05-14T07:26:48.460" Score="3" Body="&lt;p&gt;One option is to use a pattern with multiple lookaheads:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;magic:        ^\(.*1\)\@=\(.*3\)\@=&#xA;                   ‾         ‾&#xA;&#xA;very magic:   \v^(.*1)@=(.*3)@=&#xA;                    ‾      ‾&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since lookaheads (and lookarounds in general) do not consume characters, the same line can be searched for multiple different patterns/words.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;additional hint:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This even allows one to add another condition to the regular expression: matching lines that contain &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;3&lt;/code&gt;, but do &lt;em&gt;not&lt;/em&gt; contain &lt;code&gt;x&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;magic:        ^\(.*1\)\@=\(.*3\)\@=\(.*x\)\@!&#xA;                   ‾         ‾         ‾&#xA;&#xA;very magic:   \v^(.*1)@=(.*3)@=(.*x)@!&#xA;                    ‾      ‾      ‾&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19901" LastEditorUserId="19901" LastEditDate="2019-05-17T15:00:16.460" LastActivityDate="2019-05-17T15:00:16.460" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19947" PostTypeId="1" AcceptedAnswerId="19948" CreationDate="2019-05-14T07:28:14.043" Score="3" ViewCount="739" Body="&lt;p&gt;Part of the job performed by virtually all plugin managers in Vim is to create helptags, which will index the help files shipped with the plugins and will allow searching for commands and mappings added by the plugins themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This action is implemented by calling the &lt;code&gt;:helptags&lt;/code&gt; command and passing it the path to the &lt;code&gt;doc/&lt;/code&gt; directory inside a plugin directory tree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:helptags&lt;/code&gt; command will scan that directory for files matching &lt;code&gt;*.txt&lt;/code&gt;, index the tags inside those files and then create a new file named &lt;code&gt;tags&lt;/code&gt; &lt;em&gt;inside that same directory.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the contents of the &lt;code&gt;tags&lt;/code&gt; file only depend on contents of files shipped by the plugin itself (the &lt;code&gt;doc/*.txt&lt;/code&gt; files) and the file lives within the plugin directory tree as well (also under the &lt;code&gt;doc/&lt;/code&gt; subdirectory.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So why is it that this file always needs to be generated when installing or updating plugins, rather than shipped with the plugins themselves?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ask because it's kind of a pain to keep that always up to date when manually managing plugins, for instance when using the package manager support from Vim 8 and when storing the plugins as git submodules of a main repository.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-05-26T19:39:10.833" Title="Why are helptags not shipped with plugins?" Tags="|plugin-system|tags|help-system|packages|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19948" PostTypeId="2" ParentId="19947" CreationDate="2019-05-14T07:39:13.910" Score="2" Body="&lt;p&gt;I think the helptags are not distributed with the plugins for the same reasons you don't put the tags generated by cscope or ctags in version control:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;That limits the size of your repo&lt;/li&gt;&#xA;&lt;li&gt;Since generating them is deterministic, there is no added value to have the file generated by the author&lt;/li&gt;&#xA;&lt;li&gt;And that limit the risk for the author to distribute the wrong tags or to forget to update them.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also if your problem is to manually keep track of your helptags, maybe you don't know about &lt;code&gt;:helptag ALL&lt;/code&gt; which generates the tags for all of the directories in your &lt;code&gt;runtimepath&lt;/code&gt; &lt;a href=&quot;http://vimhelp.appspot.com/helphelp.txt.html#%3Ahelptags&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :helptags&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; I didn't see @Hotschke comment before redacting this answer but basically I agree with all they said :) &lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-05-14T07:39:13.910" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="19949" PostTypeId="1" CreationDate="2019-05-14T07:53:11.063" Score="0" ViewCount="187" Body="&lt;p&gt;I have a function which calls another function that reads user input from &lt;code&gt;input()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! fun1()&#xA;  call fun2()&#xA;endfunction&#xA;&#xA;function! fun2()&#xA;  let temp = input(&quot;Please input:&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I want is when typing in the command area of vim with &lt;code&gt;Please input: xxx&lt;/code&gt;, if I press &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, &lt;code&gt;fun1&lt;/code&gt; will be stopped/ not executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How is it possible to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trying to catch the &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; key with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;try&#xA;  let temp = input(&quot;Input: &quot;) &quot; show what is already there&#xA;catch &quot;normal! &amp;lt;esc&amp;gt;&quot;&#xA;  echo &quot;esc catched&quot;&#xA;finally&#xA;  echo &quot;\n&quot;.temp&#xA;endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does not seems to work.&lt;/p&gt;&#xA;" OwnerUserId="21506" LastActivityDate="2019-05-14T07:53:11.063" Title="How to stop a function when &lt;esc&gt; is pressed? OR how to catch a &lt;esc&gt; signal in vimscript?" Tags="|vimscript|functions|escape|" AnswerCount="0" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19950" PostTypeId="2" ParentId="16906" CreationDate="2019-05-14T07:59:59.997" Score="239" Body="&lt;p&gt;Or you can install &lt;code&gt;jq&lt;/code&gt; which is faster (written in C) from your package manager (e.g. &lt;code&gt;sudo apt install jq&lt;/code&gt; in Ubuntu/Debian, &lt;code&gt;sudo dnf install jq&lt;/code&gt; on Fedora/RHEL/CentOS) or &lt;a href=&quot;https://github.com/stedolan/jq&quot; rel=&quot;noreferrer&quot;&gt;from source&lt;/a&gt; and then in vim, type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!jq .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14229" LastEditorUserId="18609" LastEditDate="2020-04-06T03:01:38.710" LastActivityDate="2020-04-06T03:01:38.710" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="19951" PostTypeId="2" ParentId="19945" CreationDate="2019-05-14T08:05:23.713" Score="7" Body="&lt;p&gt;Another way is to use &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%26&quot; rel=&quot;noreferrer&quot;&gt;:h /\&amp;amp;&lt;/a&gt; , it works a bit like &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; in most coding language:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pattern0\&amp;amp;pattern1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Above expression will match pattern1 if pattern0 also match at the same position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve your example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v^(.*1&amp;amp;.*3).*$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; very magic&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; start of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(.*1&amp;amp;.*3)&lt;/code&gt; match &lt;code&gt;.*3&lt;/code&gt; if &lt;code&gt;.*1&lt;/code&gt; matches.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*$&lt;/code&gt; match anything until line end&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you have multiple patterns, you can write it as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v^(.*pattern0&amp;amp;.*pattern1&amp;amp;.*pattern2...).*$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-14T08:14:41.770" LastActivityDate="2019-05-14T08:14:41.770" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19952" PostTypeId="2" ParentId="19945" CreationDate="2019-05-14T09:41:53.773" Score="4" Body="&lt;p&gt;Here's another alternative: use &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2Fbar&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /bar&lt;/code&gt;&lt;/a&gt; to match either &lt;em&gt;&amp;hellip;1&amp;hellip;3&amp;hellip;&lt;/em&gt; or &lt;em&gt;&amp;hellip;3&amp;hellip;1&amp;hellip;&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v.*(1.*3|3.*1).*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; very magic&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*&lt;/code&gt; anything (or nothing)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(...)&lt;/code&gt; a group, containing either:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;1.*3&lt;/code&gt; &lt;code&gt;1&lt;/code&gt; followed by anything followed by &lt;code&gt;3&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;|&lt;/code&gt; or&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;3.*1&lt;/code&gt; &lt;code&gt;3&lt;/code&gt; followed by anything followed by &lt;code&gt;1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*&lt;/code&gt; anything&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-05-14T09:47:14.483" LastActivityDate="2019-05-14T09:47:14.483" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19953" PostTypeId="1" CreationDate="2019-05-14T10:05:57.117" Score="2" ViewCount="1067" Body="&lt;p&gt;I am writing an autocmd which will warn me if the file opened is not in UTF-8 format. This is what I have got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup non_utf8_file&#xA;    autocmd!&#xA;    autocmd BufRead * if &amp;amp;fileencoding != 'utf-8' | echomsg 'file not in utf-8 format!' | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the above autocmd does not work in Neovim when I tried to open a file which is not utf-8 encoded. No message is shown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I open the same file in Vim using the above settings, the warning message is shown correctly.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Version info:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Neovim: 0.4.0&lt;/li&gt;&#xA;&lt;li&gt;Vim: 7.4&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-05-15T04:36:37.320" Title="why doesn't this autocmd take effect for neovim?" Tags="|neovim|autocmd|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="19955" PostTypeId="1" CreationDate="2019-05-14T13:23:16.433" Score="1" ViewCount="112" Body="&lt;p&gt;Is there a way to bind a single in visual mode, or a small word in ex mode that will invoke the code formatter for the active filetype? For example &quot;ESC : fmt&quot; or CTRL ALT F in visual mode, to invoke &quot;ESC : Prettier&quot; or &quot;ESC : RustFmt&quot; for javascript or rust code respectively.&lt;/p&gt;&#xA;" OwnerUserId="19510" LastActivityDate="2019-05-14T13:36:27.693" Title="Single key/keyword to invoke code formatter across all extensions?" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19956" PostTypeId="2" ParentId="19955" CreationDate="2019-05-14T13:36:27.693" Score="3" Body="&lt;p&gt;You are looking for &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27formatprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'formatprg'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'formatprg' 'fp'    string (default &quot;&quot;)&#xA;            global or local to buffer |global-local|&#xA;    The name of an external program that will be used to format the lines&#xA;    selected with the |gq| operator.  The program must take the input on&#xA;    stdin and produce the output on stdout.  The Unix program &quot;fmt&quot; is&#xA;    such a program.&#xA;    If the 'formatexpr' option is not empty it will be used instead.&#xA;    Otherwise, if 'formatprg' option is an empty string, the internal&#xA;    format function will be used |C-indenting|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can set it to use an external formatting tool or the built-in mechanism.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have set &lt;code&gt;formatprg&lt;/code&gt; properly you can use &lt;code&gt;gq&lt;/code&gt; as a command to format your code the same way you'd use &lt;code&gt;d&lt;/code&gt; to delete it or &lt;code&gt;y&lt;/code&gt; to yank it. For example &lt;code&gt;gqip&lt;/code&gt; will format the current paragraph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27equalprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'equalprg'&lt;/code&gt;&lt;/a&gt; and the command &lt;code&gt;=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And as you want to have a different setting for each filetype, the best practice is to set it in a &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#ftplugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;ftplugin&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example for javascript you could create a file &lt;code&gt;~/.vim/after/ftplugin/javascript.vim&lt;/code&gt; and put something like the following in it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal formatprg=prettier\ --stdin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-05-14T13:36:27.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19957" PostTypeId="2" ParentId="10396" CreationDate="2019-05-14T14:48:03.983" Score="0" Body="&lt;p&gt;&lt;strong&gt;Jist of hinging behavior on the mode that you are in:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason that determining what mode you're in is difficult is because you're trying to decide something in a place where that information is generally not kept.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So move upstream and put your hinge on mode in the &lt;code&gt;nnoremap&lt;/code&gt;, &lt;code&gt;inoremap&lt;/code&gt;, &lt;code&gt;vnoremap&lt;/code&gt;, etc, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap jj :call DecoupleDilithiumMatrix()&#xA;nnoremap jk :call EjectWarpCore()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can put your mode-specific code in the functions.&lt;/p&gt;&#xA;" OwnerUserId="6775" LastEditorUserId="6775" LastEditDate="2019-05-14T14:54:20.630" LastActivityDate="2019-05-14T14:54:20.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19958" PostTypeId="2" ParentId="19941" CreationDate="2019-05-14T15:34:00.837" Score="0" Body="&lt;p&gt;It just back to normal when I update iTerm2. It should be an 'true color' issue with iTerm2 according to &lt;a href=&quot;https://github.com/SpaceVim/SpaceVim/issues/2824#issuecomment-492023825&quot; rel=&quot;nofollow noreferrer&quot;&gt;github comminity&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21916" LastActivityDate="2019-05-14T15:34:00.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19960" PostTypeId="1" AcceptedAnswerId="19962" CreationDate="2019-05-14T22:46:35.587" Score="1" ViewCount="214" Body="&lt;p&gt;Imagine I have comments&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// line one&#xA;// line two&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I am on line one and want to join it with line two I will press &lt;code&gt;J&lt;/code&gt; but that results in this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// line one // line two&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of what I want&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// line one line two&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can I change the behaviour of &lt;code&gt;J&lt;/code&gt; so that it works like this for comments?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2019-05-14T23:22:27.073" Title="use J to join comments" Tags="|comments|join|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19961" PostTypeId="2" ParentId="19934" CreationDate="2019-05-14T23:09:35.983" Score="0" Body="&lt;p&gt;I have extended the standard Python syntax file to cover your mentioned use cases:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Function calls&lt;/li&gt;&#xA;&lt;li&gt;Attributes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As well as &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;variables (as distinct from object instances)&lt;/li&gt;&#xA;&lt;li&gt;doctests&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;self&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;string formatting&lt;/li&gt;&#xA;&lt;li&gt;et cetera&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can find it &lt;a href=&quot;https://github.com/jalanb/jab/blob/master/vim/syntax/python.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, and use it as a drop-in replacement for the installed &lt;code&gt;.../syntax/python.vim&lt;/code&gt;. You may also wish to extend the colour file you use to take advantage of the new syntax elements, as I have done &lt;a href=&quot;https://github.com/jalanb/jab/blob/master/vim/colors/jalanb.vim#L34&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; (but you may not like the actual colours there, many of my colleagues think them very garish).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However: do notice that it is based on the syntax file from Vim &lt;strong&gt;6.1&lt;/strong&gt;, so is missing some more modern aspects of the language (e.g. fstrings). (Contributions are very welcome.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also &lt;a href=&quot;https://github.com/jalanb/jab/blob/master/vim/syntax/python.vim#L405&quot; rel=&quot;nofollow noreferrer&quot;&gt;uses some features&lt;/a&gt; from Kien's &lt;a href=&quot;https://github.com/kien/rainbow_parentheses.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Rainbow Parentheses&lt;/a&gt;, but they can be easily removed if you don't wish to use that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also in that directory is a &lt;a href=&quot;https://github.com/jalanb/jab/blob/master/vim/syntax/doctest.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;syntax file&lt;/a&gt; to cover doctest files, i.e. doctests which are written to a separate test file, not merely added to docstrings within the main source file.&lt;/p&gt;&#xA;" OwnerUserId="182" LastEditorUserId="182" LastEditDate="2019-05-14T23:19:04.863" LastActivityDate="2019-05-14T23:19:04.863" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19962" PostTypeId="2" ParentId="19960" CreationDate="2019-05-14T23:22:27.073" Score="2" Body="&lt;pre&gt;&lt;code&gt;set fo+=j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h fo-table&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;j   Where it makes sense, remove a comment leader when joining lines.  For&#xA;    example, joining:&#xA;        int i;   // the index ~&#xA;                 // in the list ~&#xA;    Becomes:&#xA;        int i;   // the index in the list ~&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;default &lt;code&gt;formatoptions&lt;/code&gt; in vim8 : &lt;code&gt;tcq&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;default &lt;code&gt;formatoptions&lt;/code&gt; in neovim : &lt;code&gt;tcqj&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-05-14T23:22:27.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19963" PostTypeId="2" ParentId="19953" CreationDate="2019-05-15T03:28:11.313" Score="4" Body="&lt;p&gt;This issue is caused by the &lt;code&gt;F&lt;/code&gt; flag in the &lt;code&gt;shortmess&lt;/code&gt; option&lt;sup&gt;[1]&lt;/sup&gt;. If you remove the &lt;code&gt;F&lt;/code&gt; flag from &lt;code&gt;shortmess&lt;/code&gt;, you can see the displayed message&#xA;correctly. This issue has been filled as &lt;a href=&quot;https://github.com/neovim/neovim/issues/8675&quot; rel=&quot;nofollow noreferrer&quot;&gt;#8675&lt;/a&gt; and &lt;a href=&quot;https://github.com/neovim/neovim/issues/9870&quot; rel=&quot;nofollow noreferrer&quot;&gt;#9870&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an alternative, if you change the autocmd event from &lt;code&gt;BufRead&lt;/code&gt; to &lt;code&gt;BufEnter&lt;/code&gt;&#xA;or &lt;code&gt;BufWinEnter&lt;/code&gt;, the message can be shown without removing the &lt;code&gt;F&lt;/code&gt; flag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also filed &lt;a href=&quot;https://github.com/neovim/neovim/issues/10008&quot; rel=&quot;nofollow noreferrer&quot;&gt;an issue&lt;/a&gt; in&#xA;the Neovim GitHub repo. The developer says that it is an internal implementation&#xA;and didn't give the reason for this behavior.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;[1]&lt;/sup&gt; Thanks to &lt;a href=&quot;https://vi.stackexchange.com/users/17449/user938271&quot;&gt;user938271&lt;/a&gt;&#xA;for pointing out that the &lt;code&gt;F&lt;/code&gt; flag is added in &lt;a href=&quot;https://github.com/neovim/neovim/commit/b7514493a0c4a4389a5921f15b0b429dae5c75e7&quot; rel=&quot;nofollow noreferrer&quot;&gt;this neovim commit&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastEditorUserId="51" LastEditDate="2019-05-15T04:36:37.320" LastActivityDate="2019-05-15T04:36:37.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19964" PostTypeId="1" AcceptedAnswerId="19965" CreationDate="2019-05-15T07:38:08.723" Score="1" ViewCount="295" Body="&lt;p&gt;I have the following &lt;code&gt;autocmd&lt;/code&gt; in my vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup line_return&#xA;  au!&#xA;  au BufReadPost *&#xA;    \ if line(&quot;'\&quot;&quot;) &amp;gt; 0 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) |&#xA;    \     execute 'normal! g`&quot;zvzz' |&#xA;    \ endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It moves the cursor to the line it was on when the file was previously opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like this behaviour generally, but I don't want this behaviour when writing a Git commit. I tried adding the following &lt;code&gt;autocmd&lt;/code&gt;, but it doesn't seem to work. I don't think the syntax is wrong since I see no errors when starting Vim. I &lt;em&gt;think&lt;/em&gt; it's because it runs &lt;em&gt;before&lt;/em&gt; the first &lt;code&gt;autocmd&lt;/code&gt; runs, but I'm not sure.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup always_start_at_top_of_git_commit&#xA;  au!&#xA;  au FileType gitcommit execute 'normal! gg'&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I make this work? Should I actually just add a conditional to the first &lt;code&gt;autocmd&lt;/code&gt; instead?&lt;/p&gt;&#xA;" OwnerUserId="2191" LastActivityDate="2019-05-15T07:46:13.407" Title="Always move cursor to top of gitcommit buffer" Tags="|autocmd|git|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19965" PostTypeId="2" ParentId="19964" CreationDate="2019-05-15T07:46:13.407" Score="1" Body="&lt;p&gt;Have you checked &lt;code&gt;:h last-position-jump&lt;/code&gt; with a recent vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has almost the same autocommand as yours but with 'commit' in mind:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            *restore-cursor* *last-position-jump*  &amp;gt;&#xA;autocmd BufReadPost *&#xA;  \ if line(&quot;'\&quot;&quot;) &amp;gt;= 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) &amp;amp;&amp;amp; &amp;amp;ft !~# 'commit'&#xA;  \ |   exe &quot;normal! g`\&quot;&quot;&#xA;  \ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See the last condition &lt;code&gt;&amp;amp;ft !~# 'commit'&lt;/code&gt; -- it checks the filetype of the buffer and if it has no 'commit' in it then jump to the given position.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-05-15T07:46:13.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19966" PostTypeId="1" AcceptedAnswerId="19967" CreationDate="2019-05-15T09:53:21.460" Score="0" ViewCount="80" Body="&lt;p&gt;I know I can write a buffer to an external program with &lt;code&gt;:w !&amp;lt;command&amp;gt;&lt;/code&gt;, but is there a way to pipe the contents of the spelling correction list I get with &lt;code&gt;z=&lt;/code&gt; into  an external program (i.e. dmenu)? If the function(s) behind &lt;code&gt;z=&lt;/code&gt; are written in vimscript, can I modify them or is it hard coded ?&lt;/p&gt;&#xA;" OwnerUserId="22239" LastActivityDate="2019-05-16T12:02:52.643" Title="Can I pipe vim spelling suggestions to an external program?" Tags="|external-command|spell-checking|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19967" PostTypeId="2" ParentId="19966" CreationDate="2019-05-15T10:19:37.053" Score="1" Body="&lt;p&gt;I don't have &lt;code&gt;dmenu&lt;/code&gt; installed, but I tried with &lt;code&gt;zenity&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo system(&quot;zenity --list --column=Suggestions 2&amp;gt;/dev/null&quot;, spellsuggest(expand(&quot;&amp;lt;cword&amp;gt;&quot;)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;expand(&quot;&amp;lt;cword&amp;gt;&quot;)&lt;/code&gt; expands to the word under the cursor.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;spellsuggest(...)&lt;/code&gt; returns a list of spelling suggestions&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;system(&quot;zenity...&quot;, ...)&lt;/code&gt; calls &lt;code&gt;zenity&lt;/code&gt; and pipes the the list from &lt;code&gt;spellsuggest(...)&lt;/code&gt; as input.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I then select one of the suggestions, it is echoed by Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the help for spellsuggest (&lt;code&gt;:h spellsuggest()&lt;/code&gt;), as it can take additional parameters.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-05-15T10:19:37.053" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19968" PostTypeId="1" CreationDate="2019-05-15T10:55:55.807" Score="1" ViewCount="774" Body="&lt;p&gt;Here is my &lt;code&gt;${HOME}/.vimrc&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set textwidth=0&#xA;set history=100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(FWIW, inverting their order has no effect, as one would expect.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is read by &lt;code&gt;vim&lt;/code&gt; (&lt;code&gt;:echo $MYVIMRC&lt;/code&gt; returns the correct path), and indeed &lt;code&gt;set history&lt;/code&gt; (actually included to check if it was a &lt;code&gt;.vimrc&lt;/code&gt; inclusion issue) is taken into account, but not &lt;code&gt;set textwidth&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set textwidth&#xA;  textwidth=78&#xA;    Last set from /usr/share/vim/vimrc&#xA;&#xA;:verbose set history&#xA;  history=100&#xA;    Last set from ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet if I source my &lt;code&gt;.vimrc&lt;/code&gt; it &lt;em&gt;does&lt;/em&gt; set &lt;code&gt;textwidth&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:so ~/.vimrc&#xA;:verbose set textwidth&#xA;  textwidth=0&#xA;    Last set from ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's wrong, and what can I do to force &lt;code&gt;textwidth&lt;/code&gt; to be set by my user &lt;code&gt;.vimrc&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="20972" LastActivityDate="2022-05-29T19:07:25.783" Title="/usr/share/vim/vimrc taking precedence over ~/.vimrc for textwidth" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19969" PostTypeId="2" ParentId="19968" CreationDate="2019-05-15T12:14:08.670" Score="1" Body="&lt;p&gt;From &lt;code&gt;/usr/share/vim/vimrc&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Only do this part when compiled with support for autocommands.&#xA;if has(&quot;autocmd&quot;)&#xA;&#xA;  […]&#xA;&#xA;  &quot; For all text files set 'textwidth' to 78 characters.&#xA;  autocmd FileType text setlocal textwidth=78&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Apparently these settings override basic custom &lt;code&gt;.vimrc&lt;/code&gt; settings.  I replaced &lt;code&gt;set textwidth=0&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  autocmd VimEnter * set textwidth=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and now &lt;code&gt;vim&lt;/code&gt; behaves as I expected.&lt;/p&gt;&#xA;" OwnerUserId="20972" LastActivityDate="2019-05-15T12:14:08.670" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19970" PostTypeId="1" CreationDate="2019-05-15T13:28:08.120" Score="0" ViewCount="614" Body="&lt;p&gt;I've tried dozens of different themes but always get wrong coloring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/danilo-augusto/vim-afterglow#latex&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; is how &lt;code&gt;vim-afterglow&lt;/code&gt; should look with &lt;code&gt;LaTeX&lt;/code&gt; code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is mine screenshot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6wbhj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6wbhj.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/danilo-augusto/vim-afterglow#python&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; is example for Python. And this is mine:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kHNNI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kHNNI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Colors are wrong for all themes I've tried: &lt;code&gt;afterglow&lt;/code&gt;, &lt;code&gt;dracula&lt;/code&gt;, &lt;code&gt;darcula&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried different tweaks like setting &lt;code&gt;t_Co&lt;/code&gt; to different values, setting &lt;code&gt;$TERM&lt;/code&gt; to different values, combining previous tweaks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried different terminals: &lt;code&gt;gnome-terminal&lt;/code&gt;, &lt;code&gt;tilda&lt;/code&gt;, &lt;code&gt;xterm&lt;/code&gt;, &lt;code&gt;tilix&lt;/code&gt;, &lt;code&gt;st&lt;/code&gt; and &lt;code&gt;xfce4-terminal&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Ubuntu 16.04, nvim v0.3.4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/dracula/vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; is how &lt;code&gt;dracula&lt;/code&gt; should look like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My screenshot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AaAVK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AaAVK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problems: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) function name, &lt;code&gt;var&lt;/code&gt; and &lt;code&gt;this&lt;/code&gt; keywords are grey but should have different colors as on authors screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) &lt;code&gt;function&lt;/code&gt; keyword is green but should be cyan&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Current line number is not highlighted&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Line numbers color is blue but not grey&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5) Other colors are not exactly as on screenshot&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used &lt;a href=&quot;https://askubuntu.com/a/821163/167196&quot;&gt;this&lt;/a&gt; command to test 256 color support.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lDzt4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lDzt4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD 3:*&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screenshot with &lt;code&gt;pangloss/vim-javascript&lt;/code&gt; installed:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9E3SU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9E3SU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19986" LastEditorUserId="19986" LastEditDate="2019-05-15T16:59:28.690" LastActivityDate="2019-05-15T16:59:28.690" Title="How to make vim theme looks exactly as on screenshot" Tags="|neovim|colorscheme|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="19971" PostTypeId="1" AcceptedAnswerId="19972" CreationDate="2019-05-15T16:27:04.317" Score="0" ViewCount="390" Body="&lt;p&gt;When I am using the ctrl-n functionality (autocomplete word), it just inserts the text. I do not want to do that, instead, I would want to choose a word from the dropdown list, which I may then want to insert it later. Is there any way I can stop ctrl-n from inserting text while autocompleting? Are there any other autocomplete plugins that may have this workaround?&lt;/p&gt;&#xA;" OwnerUserId="18499" LastActivityDate="2020-04-01T12:31:51.210" Title="ctrl-n - should not insert text" Tags="|vimrc|autocompletion|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19972" PostTypeId="2" ParentId="19971" CreationDate="2019-05-15T16:49:08.920" Score="1" Body="&lt;p&gt;The word completition as you describe it's just how &lt;code&gt;Ctrl-n&lt;/code&gt; works.&#xA;I use the following mapping to make autocompletition:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; getline('.')[col('.') - 2] =~ '\w' ? &quot;&amp;lt;C-N&amp;gt;&quot; : &quot;&amp;lt;Tab&amp;gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which uses &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; to automatically complete the current word if there is only one match, otherwise it shows the dropdown list if the current word could match many others.&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="15254" LastEditDate="2019-05-15T16:54:16.257" LastActivityDate="2019-05-15T16:54:16.257" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19974" PostTypeId="2" ParentId="7258" CreationDate="2019-05-15T19:08:18.557" Score="15" Body="&lt;p&gt;If you are using the 'indentLine' plugin or other plugins that can change 'conceal' features in vim. It is because these plugin enables the Vim 'conceal' feature which automatically hides stretches of text based on syntax highlighting. This setting will apply to all syntax items.&#xA;Specifically, in 'indentLine' plugin, it will overwrite &amp;quot;concealcursor&amp;quot; and &amp;quot;conceallevel&amp;quot; to:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:indentLine_concealcursor = 'inc'&#xA;let g:indentLine_conceallevel = 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So, I change it to the following value in my .vimrc file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:indentLine_setConceal = 2&#xA;&amp;quot; default ''.&#xA;&amp;quot; n for Normal mode&#xA;&amp;quot; v for Visual mode&#xA;&amp;quot; i for Insert mode&#xA;&amp;quot; c for Command line editing, for 'incsearch'&#xA;let g:indentLine_concealcursor = &amp;quot;&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Another option is to &lt;code&gt;let g:indentLine_concealcursor = &amp;quot;nc&amp;quot;&lt;/code&gt; which makes the hidden texts surrounding around your cursor only show in 'insert' mode and 'visual' mode.&lt;/p&gt;&#xA;" OwnerUserId="22245" LastEditorUserId="10604" LastEditDate="2023-02-25T14:13:00.990" LastActivityDate="2023-02-25T14:13:00.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19976" PostTypeId="1" AcceptedAnswerId="19977" CreationDate="2019-05-15T19:27:21.767" Score="0" ViewCount="118" Body="&lt;p&gt;After trying to make this work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/563/map-a-sequence-of-letters-in-insert-mode/19975#19975&quot;&gt;Map a sequence of letters in insert mode&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can’t get the correct answer to work. Is it still working? Can anyone post a working .vimrc file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to get this:&#xA;When I type  &lt;code&gt;'a&lt;/code&gt; in insert mode I want vim to change it to &lt;code&gt;á&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16303" LastEditorUserId="205" LastEditDate="2019-05-16T02:30:13.663" LastActivityDate="2019-05-16T02:30:13.663" Title="How do I map a sequence of letters in insert mode?" Tags="|key-bindings|insert-mode|replace|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19977" PostTypeId="2" ParentId="19976" CreationDate="2019-05-15T19:54:57.493" Score="2" Body="&lt;p&gt;An easy way to get á by typing 'a in insert mode is to first &lt;code&gt;:set keymap=accents&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22246" LastActivityDate="2019-05-15T19:54:57.493" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19978" PostTypeId="1" AcceptedAnswerId="19979" CreationDate="2019-05-15T20:04:47.297" Score="5" ViewCount="4602" Body="&lt;p&gt;I would like to copy several lines with line numbers; the text from &lt;code&gt;set number&lt;/code&gt; isn't copied. Is there any way to do this?&lt;/p&gt;&#xA;" OwnerUserId="7706" LastEditorUserId="51" LastEditDate="2019-05-16T07:13:54.643" LastActivityDate="2021-02-01T14:09:05.933" Title="How to copy lines with line numbers?" Tags="|cut-copy-paste|line-numbers|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19979" PostTypeId="2" ParentId="19978" CreationDate="2019-05-15T20:04:47.297" Score="4" Body="&lt;p&gt;You have several alternatives. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use the &lt;code&gt;TOhtml&lt;/code&gt; command&lt;/strong&gt; to let Vim generate an HTML file, which includes the line numbers, and then copy and paste from that file. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Replace each line by its line number plus its content&lt;/strong&gt;, so you can copy it with the line number. This can be done by visually selecting the lines, and using the following substitute command: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/^/\=printf(&quot;%2d &quot;, line('.'))/ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You obviously want to undo this replace after copying using e.g. undo &#xA;or &lt;code&gt;:s/^\d\+ //&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Create your own command&lt;/strong&gt; to take care of copying the desired &#xA;text together with the line numbers. Something like this should work: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! s:yank_number(first, last) &#xA;    let start = a:first &#xA;    let l = [] &#xA;    while start &amp;lt;= a:last &#xA;        let l = add(l, printf(&quot;%&quot; . len(a:last) . &quot;d %s&quot;, start, &quot; &quot; . getline(start))) &#xA;        let start += 1&#xA;    endwhile &#xA;    return join(l, &quot;\n&quot;) . &quot;\n&quot; &#xA;endfu &#xA;&#xA;command! -nargs=0 -range Yank :let @+ = s:yank_number(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now select your text and enter &lt;code&gt;:Yank&lt;/code&gt;, which will copy the range to the &lt;code&gt;+&lt;/code&gt;-register (which should correspond to your system's clipboard, if your Vim was compiled with clipboard functionality (&lt;code&gt;:help&lt;/code&gt; should output &lt;code&gt;+clipboard&lt;/code&gt;, instead of &lt;code&gt;-clipboard&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use &lt;code&gt;:redir&lt;/code&gt;&lt;/strong&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @a &#xA;:silent! :'&amp;lt;,'&amp;gt;number&#xA;:redir END &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:redir @a | silent! :'&amp;lt;,'&amp;gt;number | redir END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to pull the numbered lines into register &quot;a&quot;.  This can be &#xA;wrapped into a mapping: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnoremap &amp;lt;f4&amp;gt; :&amp;lt;home&amp;gt;redir @a&amp;lt;bar&amp;gt;silent! &amp;lt;end&amp;gt;number&amp;lt;bar&amp;gt;redir END&amp;lt;cr&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;assuming you always want to trump the same register.  If you use &#xA;it frequently, you might designate a preferred register such as &#xA;&quot;n&quot; for &quot;(n)umbered&quot; and then only use it for that purpose. &#xA;Alternatively, &lt;code&gt;:redir&lt;/code&gt; allows you to redirect to other sinks if &#xA;you prefer. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;DISCLAIMER: The above options have been created from the &lt;a href=&quot;http://vim.1045645.n5.nabble.com/set-nu-gt-how-to-copy-lines-with-line-numbers-td1186325.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim mailing list thread&lt;/a&gt;, using:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.1045645.n5.nabble.com/set-nu-how-to-copy-lines-with-line-numbers-tp1186325.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Krzysztof Cierpisz's question&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.1045645.n5.nabble.com/set-nu-how-to-copy-lines-with-line-numbers-tp1186325p1186331.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Christian Brabandt's answer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.1045645.n5.nabble.com/set-nu-how-to-copy-lines-with-line-numbers-tp1186325p1186326.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tim Chase's answer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vim.1045645.n5.nabble.com/set-nu-how-to-copy-lines-with-line-numbers-tp1186325p5597007.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bee-16's answer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you are one of the above authors, and would like to take credit for it, please let me know, and I will delete the question and answer so that you can re-create it.&lt;/p&gt;&#xA;" OwnerUserId="7706" LastEditorUserId="51" LastEditDate="2019-05-16T07:38:32.573" LastActivityDate="2019-05-16T07:38:32.573" CommentCount="3" CommunityOwnedDate="2019-12-30T13:46:25.410" ContentLicense="CC BY-SA 4.0" />
  <row Id="19980" PostTypeId="2" ParentId="19976" CreationDate="2019-05-15T20:17:52.660" Score="0" Body="&lt;p&gt;You might use digraph to enter á.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just enter the sequence &lt;kbd&gt;Ctrl-k&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or: Set the option digraph with &lt;code&gt;:set digraph&lt;/code&gt;. Then you can enter á with &lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;Backspace&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read more about digraphs with &lt;code&gt;:help digraph&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need it regularly, the better solution seems &lt;code&gt;keymap&lt;/code&gt; as proposed by @troydj.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-05-15T20:37:07.860" LastActivityDate="2019-05-15T20:37:07.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19981" PostTypeId="1" CreationDate="2019-05-15T21:26:46.883" Score="0" ViewCount="288" Body="&lt;p&gt;When I have some text indented as follows (like &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; variables assignment):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(condition)&#xA;    a = 1;&#xA;    b = 2;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to paste &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; block somewhere outside of the &lt;code&gt;if&lt;/code&gt; block, i.e just after it, vim adds the indentation starting from the second line of visual selection, resulting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = 1;&#xA;    b = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does exist such an option that don't expand the indentation (better said that maintains relative column alignment for each line) when text is pasted, without using a custom function ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&#xA;I mainly use gvim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT2:&lt;/strong&gt;&#xA;I have already tried &lt;code&gt;set paste&lt;/code&gt; and &lt;code&gt;set nopaste&lt;/code&gt; without success.&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="15254" LastEditDate="2019-05-15T21:54:14.483" LastActivityDate="2019-05-16T16:32:13.173" Title="Multiline paste with relative columns alignment" Tags="|cut-copy-paste|gvim|paste|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="19982" PostTypeId="1" AcceptedAnswerId="19983" CreationDate="2019-05-16T04:06:45.080" Score="0" ViewCount="58" Body="&lt;p&gt;I was looking at &lt;a href=&quot;https://unix.stackexchange.com/q/519129/135943&quot;&gt;this question&lt;/a&gt; on Unix &amp;amp; Linux Stack Exchange, and I thought I could write an answer for it using Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ran the following for a quick test, and was surprised to find it didn't seem to do anything.  I was expecting it to replace the first number on the first line with one less than the number of lines in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute '1s/^[0-9]\+/' . line('$')-1 . '/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the text I had in the buffer at the time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5 10&#xA;sample_1 gaatatccga&#xA;sample_2 gaatatccga&#xA;sample_3 gaatatcgca&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why didn't the &lt;code&gt;:execute&lt;/code&gt; command shown above replace the &lt;code&gt;5&lt;/code&gt; with a &lt;code&gt;3&lt;/code&gt; as intended?&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2019-05-16T07:19:42.687" Title="Why doesn't this `:execute` command work?" Tags="|vimscript|regular-expression|line-numbers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19983" PostTypeId="2" ParentId="19982" CreationDate="2019-05-16T04:45:47.167" Score="2" Body="&lt;p&gt;&lt;code&gt;.&lt;/code&gt; has the same precedence as &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'1s/^[0-9]\+/' . line('$')-1 . '/'&lt;/code&gt; is the same as &lt;code&gt;('1s/^[0-9]\+/' . line('$')) - 1 . '/'&lt;/code&gt;—it's &lt;code&gt;string - number . string&lt;/code&gt;, which is not what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve your problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute '1s/^[0-9]\+/' . (line('$')-1) . '/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h expr-.&lt;/code&gt;.  &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h expression-syntax&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="10604" LastEditDate="2019-05-16T07:19:42.687" LastActivityDate="2019-05-16T07:19:42.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19986" PostTypeId="2" ParentId="19978" CreationDate="2019-05-16T07:21:09.453" Score="2" Body="&lt;p&gt;You can copy the text with the mouse if you do &lt;em&gt;not&lt;/em&gt; have the mouse enabled (e.g. &lt;code&gt;set mouse=&lt;/code&gt;), and enable &lt;code&gt;number&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will work in any terminal, and also seems to work in the GTK3 version of gvim (but may not work in all gvim versions).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the perspective of the terminal there is no difference between the number column on the left and the buffer contents; it's all just text. This can be either a good or bad thing, depending on what you want. If you want to copy the number column then it's a good thing :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-05-16T07:21:09.453" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19988" PostTypeId="1" CreationDate="2019-05-16T09:37:32.560" Score="8" ViewCount="1644" Body="&lt;p&gt;If I'm editing a text file with &lt;code&gt;:set spell&lt;/code&gt;, is there any way to &#xA;have vim not check words within the boundaries of certain characters against the word list? I want to be able to write things like proper nouns or technical vocabulary (or even 'sic' quotations) but not have to add them to the wordlist.&lt;/p&gt;&#xA;" OwnerUserId="22258" LastActivityDate="2019-05-16T17:19:47.137" Title="How can I tell vim to ignore spelling errors inside quotes?" Tags="|spell-checking|custom-text-object|dictionary|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19989" PostTypeId="2" ParentId="19981" CreationDate="2019-05-16T10:20:21.713" Score="1" Body="&lt;p&gt;AFAIK, there is no direct way to do that in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a workaround:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all I have the following mapping in my &lt;code&gt;vimrc&lt;/code&gt; (From &lt;a href=&quot;https://vim.fandom.com/wiki/Selecting_your_pasted_text&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Tips Wiki, Tip 759&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; gp '`[' . strpart(getregtype(), 0, 1) . '`]'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this you can visually select the text you have just pasted (or changed).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;gp&lt;/code&gt; is already used by Vim for&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Just like &quot;p&quot;, but leave the cursor just after the new text.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So the mapping shadows the default functionality of &lt;code&gt;gp&lt;/code&gt;. Maybe you want to change the mapping.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Then I do&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Copy the text&lt;/li&gt;&#xA;&lt;li&gt;Paste it with &lt;code&gt;p&lt;/code&gt; (or &lt;code&gt;P&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Reselect the pasted text with &lt;code&gt;gp&lt;/code&gt; (the mapping above)&lt;/li&gt;&#xA;&lt;li&gt;Reformat with &lt;code&gt;=&lt;/code&gt; (or un-indent it with &lt;code&gt;&amp;lt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Or short: &lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-05-16T10:20:21.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19990" PostTypeId="2" ParentId="19966" CreationDate="2019-05-16T11:21:57.773" Score="2" Body="&lt;p&gt;My solution (as per the answer @Ralf gave) is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Dmenu integration for searching spelling correction. Replaces `z=`.&#xA;function DmenuCorrect()&#xA;    let word=system(&quot;$HOME/.bin/dmenuw -i -l 8 2&amp;gt;/dev/null&quot;, spellsuggest(expand(&quot;&amp;lt;cword&amp;gt;&quot;)))&#xA;    if len(word) != 0 &#xA;        exe &quot;normal ciw&quot;. word[0:-2]&#xA;    endif&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt;z= :call DmenuCorrect()&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replacing the word under the cursor is done with &lt;code&gt;exe &quot;normal ciw&quot; . word [0:-2]&lt;/code&gt;. &lt;code&gt;ciw&lt;/code&gt; puts vim into replace mode within the current word boundaries. &lt;code&gt;word [0:-2]&lt;/code&gt; is just to account for the newline dmenu prints, and inserts the chosen solution into the buffer in place of the now deleted misspelt word.&lt;/p&gt;&#xA;" OwnerUserId="22258" LastEditorUserId="51" LastEditDate="2019-05-16T12:02:52.643" LastActivityDate="2019-05-16T12:02:52.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19991" PostTypeId="2" ParentId="19988" CreationDate="2019-05-16T12:04:35.283" Score="5" Body="&lt;p&gt;You can add your own syntax element (probably overriding existing one):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match quoteblock /&quot;[^&quot;]\+&quot;/ contains=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;syntax match&lt;/code&gt;: Tells vim this is a syntax command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;quoteblock&lt;/code&gt;: The name of our match (Could be anything)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&quot;...&quot;/&lt;/code&gt;: Match things between quotes&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^&quot;]\+&lt;/code&gt;: Match anything that's not a quote&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;contains=@NoSpell&lt;/code&gt;: Tells vim not to use spell check on this match&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It is just an example and not very smart :). In my case it stops checking spelling inside quotes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IFhvY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IFhvY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-spell&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :syn-spell&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/spell.txt.html#spell-syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help spell-syntax&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3Asyn-match&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :syn-match&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2Fcollection&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /collection&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add to your vimrc the mapping such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;s :syntax match quoteblock /&quot;[^&quot;]\+&quot;/ contains=@NoSpell&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then press &lt;code&gt;&amp;lt;leader&amp;gt;s&lt;/code&gt; (you know what &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; is right?) to add this syntax element to the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to add a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! TurnOffSpellcheckForQuotes :syntax match quoteblock /&quot;[^&quot;]\+&quot;/ contains=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then just run this command from vim &lt;code&gt;:TurnOffSpellcheckForQuotes&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-05-16T17:19:47.137" LastActivityDate="2019-05-16T17:19:47.137" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19992" PostTypeId="2" ParentId="19988" CreationDate="2019-05-16T14:37:29.153" Score="1" Body="&lt;p&gt;If your file already have a syntax highlight, such as &lt;code&gt;vim&lt;/code&gt;. You can do it like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Preparation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add following function and command to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:synstack()&#xA;  if !exists('*synstack') | return | endif&#xA;  return map(synstack(line('.'), col('.')), 'synIDattr(v:val, &quot;name&quot;)')&#xA;endfunc&#xA;command! Synstack echo s:synstack()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assume current file content like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Foo()&#xA;  return &quot;balabala&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Get Syntax name&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;place your cursor at &lt;code&gt;balabala&lt;/code&gt;, execute &lt;code&gt;:Synstack&lt;/code&gt;, output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['vimFuncBody', 'vimString']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's stack of current syntax, from outside function to current string. &lt;code&gt;vimString&lt;/code&gt; is syntax name of string in &lt;code&gt;vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Get Syntax definition&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax list vimString&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Syntax items ---&#xA;vimString      xxx start=/[^a-zA-Z&amp;gt;!\\@]&quot;/ms=s+1,lc=1 skip=/\\\\\|\\&quot;/ matchgroup=vimStringEnd end=/&quot;/  oneline keepend contains=@vimStringGroup &#xA;                   start=/[^a-zA-Z&amp;gt;!\\@]'/ms=s+1,lc=1 end=/'/  oneline keepend &#xA;                   start=/=!/ms=s+1,lc=1 skip=/\\\\\|\\!/ end=/!/  oneline contains=@vimStringGroup &#xA;                   start=/=+/ms=s+1,lc=1 skip=/\\\\\|\\+/ end=/+/  oneline contains=@vimStringGroup &#xA;                   start=+\s/\s*\A+ms=s+1,lc=1 skip=/\\\\\|\\+/ end=+/+  oneline contains=@vimStringGroup &#xA;                   match /&quot;[^&quot;]*\\$/  contained nextgroup=vimStringCont skipnl &#xA;                   match /[^(,]'[^']\{-}\zs'/  &#xA;                   start=/^\s*\\\z(['&quot;]\)/ skip=/\\\\\|\\\z1/ end=/\z1/  oneline keepend contains=@vimStringGroup,vimContinue &#xA;                   links to String&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't understand above output, the only thing matters is &lt;code&gt;contains=@vimStringGroup&lt;/code&gt;. So this syntax contains a cluster called &lt;code&gt;vimStringGroup&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Add NoSpell to cluster&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax cluster vimStringGroup add=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Done.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :syn-contain&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :syn-cluster&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :spell-syntax&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-05-16T14:37:29.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19993" PostTypeId="1" CreationDate="2019-05-16T15:09:00.883" Score="2" ViewCount="597" Body="&lt;p&gt;Trying to remove newlines with a regular expression (not shift-j).&#xA;I have one vim install where  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/conf/s/\n//  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works as intended, removing a newline from all lines containing 'conf'.&lt;br&gt;&#xA;I have a second install where the same command has no obvious effect at all, other than highlighting the last character in the line.&lt;br&gt;&#xA;Is there something that I can look for in the configurations to find out why one install is working as expected and one isn't?&lt;br&gt;&#xA;Both installs are Linux, vim 7.4, 2013-08-10 build.&lt;/p&gt;&#xA;" OwnerUserId="22267" LastEditorUserId="19763" LastEditDate="2019-05-16T15:19:20.213" LastActivityDate="2019-05-16T15:19:20.213" Title="Regex to remove newline; works in one vim instance, but not another" Tags="|regular-expression|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19994" PostTypeId="1" CreationDate="2019-05-16T15:34:23.930" Score="1" ViewCount="49" Body="&lt;p&gt;I use Colemak &lt;code&gt;hnei&lt;/code&gt; for nav in normal mode, but my keys default to &lt;code&gt;hjkl&lt;/code&gt; when when I'm viewing &lt;code&gt;:history&lt;/code&gt; and &lt;code&gt;:highlight&lt;/code&gt;. How do I remap these keys? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess is that the program may be switching to &lt;code&gt;more&lt;/code&gt;. If so, how can I make vim choose &lt;code&gt;less&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per D. Ben Knoble, &lt;a href=&quot;https://vi.stackexchange.com/questions/5729/how-can-i-perform-a-search-when-vim-displays-content-using-more-pager&quot;&gt;this quesion&lt;/a&gt; looks pertinent.&lt;/p&gt;&#xA;" OwnerUserId="22268" LastEditorUserId="22268" LastEditDate="2019-05-17T14:48:50.373" LastActivityDate="2019-05-17T14:48:50.373" Title="How do you remap keys in :history or :highlight?" Tags="|highlight|navigation|command-history|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19996" PostTypeId="1" CreationDate="2019-05-17T00:04:53.263" Score="6" ViewCount="2646" Body="&lt;p&gt;I am trying and failing to get matchit to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the plugin at:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ locate matchit.vim&#xA;/usr/share/vim/vim80/macros/matchit.vim&#xA;/usr/share/vim/vim80/pack/dist/opt/matchit/plugin/matchit.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried ~/.virc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;packadd! matchit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does it work with &quot;vi&quot; and not &quot;vim&quot;?&lt;/p&gt;&#xA;" OwnerUserId="22275" LastActivityDate="2019-05-17T06:17:47.660" Title="How to get matchit to work" Tags="|plugin-matchit|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19997" PostTypeId="2" ParentId="19996" CreationDate="2019-05-17T06:17:47.660" Score="6" Body="&lt;p&gt;As @Klaus already mentioned in his comment, the correct file name for the initialization file is &lt;code&gt;~/.vimrc&lt;/code&gt;. The file &lt;code&gt;~/.virc&lt;/code&gt; is not loaded at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check the loaded files by executing the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:scriptnames&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also the matchit plugin is an optional plugin. The path to it contains &lt;code&gt;/opt/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/vim/vim80/pack/dist/opt/matchit/plugin/matchit.vim&#xA;&quot; matchit is optional          ^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you need &lt;code&gt;packadd! matchit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: If the path to a plugin contains &lt;code&gt;start&lt;/code&gt; instead of &lt;code&gt;opt&lt;/code&gt; it would be enabled by default. AFAIK the default Vim contains no plugin that is enabled by default. This might be different for binary distributions/packages build by third parties.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-05-17T06:17:47.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19998" PostTypeId="1" CreationDate="2019-05-17T07:40:53.817" Score="1" ViewCount="785" Body="&lt;p&gt;I'd like to keep the cursor at the middle of the screen wherever I am in the file, without scrolling. This mean to have blank space above the file when I'm at the start of the file, and have blank space under the file when I'm at the end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I now there is &lt;a href=&quot;https://stackoverflow.com/a/12838570/3616601&quot;&gt;this answer&lt;/a&gt; who give a hack (only to have blank space after the file), but we have to remap all keys, which is not really convenient, and it does not work in insert or visual modes.&lt;/p&gt;&#xA;" OwnerUserId="18102" LastEditorUserId="18102" LastEditDate="2019-05-17T07:55:49.627" LastActivityDate="2022-10-25T13:01:49.317" Title="Cursor in middle of the screen at start and end of file" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ClosedDate="2022-10-26T20:50:18.023" ContentLicense="CC BY-SA 4.0" />
  <row Id="19999" PostTypeId="2" ParentId="19998" CreationDate="2019-05-17T07:54:01.237" Score="1" Body="&lt;p&gt;I have part of a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure for the top of the file, but for the bottom of the file, if you use &lt;code&gt;CTRL_e&lt;/code&gt; to scroll down, you can scroll as far as having the last line of the file at the top of your screen. You can also use &lt;code&gt;CTRL_y&lt;/code&gt; to scroll up, but at the top of the file it will not scroll higher.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These two commands allow to scroll the view without moving your cursor (unlike using &lt;code&gt;k&lt;/code&gt; and &lt;code&gt;j&lt;/code&gt; to scroll up or down when the cursor is at the top or bottom). It is similar to scrolling with the mouse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And it works in visual mode, however not in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone has suggestions for the uncovered cases (top of the file and insert mode, if it is possible), a completion of this answer would be welcome.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-05-17T07:54:01.237" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20002" PostTypeId="1" AcceptedAnswerId="20003" CreationDate="2019-05-17T08:19:33.610" Score="-1" ViewCount="795" Body="&lt;p&gt;I edit DocBook XML files. In my plugin, i want to implement a function that would increase or decrease the section numbers recursively, assuming that cursor is at the toplevel section. For example, when my cursor is at the top &lt;code&gt;&amp;lt;sect2&lt;/code&gt; element, it means to turn&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;sect2&amp;gt;&#xA; &amp;lt;sect3&amp;gt;&#xA;  &amp;lt;sect4&amp;gt;&#xA;  &amp;lt;para&amp;gt;some text&amp;lt;/para&amp;gt;&#xA;  &amp;lt;/sect4&amp;gt;&#xA; &amp;lt;/sect3&amp;gt;&#xA;&amp;lt;/sect2&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;sect1&amp;gt;&#xA; &amp;lt;sect2&amp;gt;&#xA;  &amp;lt;sect3&amp;gt;&#xA;  &amp;lt;para&amp;gt;some text&amp;lt;/para&amp;gt;&#xA;  &amp;lt;/sect3&amp;gt;&#xA; &amp;lt;/sect2&amp;gt;&#xA;&amp;lt;/sect1&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i have this code in my script, but it does not work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'normal vat' # select the text up to the closing tag&#xA;execute 'normal :s/sect\(\d\?\)&amp;gt;/\=&quot;sect&quot; . (submatch(1) - 1). &quot;&amp;gt;&quot;/g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it does not work. any idea?&lt;/p&gt;&#xA;" OwnerUserId="22283" LastActivityDate="2019-05-17T09:22:45.310" Title="Increase numbers by one in a visual block" Tags="|regular-expression|functions|filetype-xml|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20003" PostTypeId="2" ParentId="20002" CreationDate="2019-05-17T08:22:37.670" Score="0" Body="&lt;p&gt;Visually select your lines and press &lt;code&gt;CTRL-x&lt;/code&gt; to decrease them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help v_CTRL-x&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;v_CTRL-X                                             {Visual}CTRL-X&#xA;                    Subtract [count] from the number or alphabetic                                                                                        &#xA;                    character in the highlighted text.  {not in Vi} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also &lt;code&gt;:help CTRL-x&lt;/code&gt;. And you can use &lt;code&gt;CTRL-a&lt;/code&gt; to increment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your vimscript, it will that (tested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; select the text up to the closing tag&#xA;execute 'normal vat'&#xA;&quot; Here the double quotes are important for the &amp;lt;C-X&amp;gt; to be executed&#xA;execute &quot;normal \&amp;lt;C-X&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: To decrement only the &quot;sect&quot;, you can use this function, however you need to do the selection before calling it (I haven't found a way to make a selection and use &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; both from within the function, if anyone has a suggestion):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DecSect()&#xA;    silent! substitute/sect\(\d\)&amp;gt;/\=&quot;sect&quot;.(submatch(1) - 1).&quot;&amp;gt;&quot;/g&#xA;endfunc&#xA;command -range -nargs=0 DecSect &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call DecSect()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the other hand, externalizing the visual selection gives you more flexibility to use it (you can use it on a tag, paragraph, document, line...), cf below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use it, first visual select the section you want to apply it on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vat&#xA;vap&#xA;%&#xA;....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then call it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;DecSect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or just call it directly to execute it on the current line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:DecSect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21621" LastEditorUserId="21621" LastEditDate="2019-05-17T09:22:45.310" LastActivityDate="2019-05-17T09:22:45.310" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20004" PostTypeId="2" ParentId="20002" CreationDate="2019-05-17T08:52:08.813" Score="0" Body="&lt;p&gt;Simply try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! vat&#xA;substitute/sect\(\d\)&amp;gt;/\=&quot;sect&quot;.(submatch(1) - 1).&quot;&amp;gt;&quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I’ve removed the &lt;code&gt;execute&lt;/code&gt;s, because the commands provides are valid vimscript commands and don’t need it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used &lt;code&gt;normal!&lt;/code&gt; to avoid mappings interfering. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I removed the &lt;code&gt;\?&lt;/code&gt; option on the digits, since your example always has digits after the &lt;code&gt;sect&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other ways to accomplish the same idea. For example:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;qa&lt;/code&gt; start a macro&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-X&amp;gt;&lt;/code&gt; increment&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; stop macro&lt;/li&gt;&#xA;&lt;li&gt;(Optional) if step (2) caused changes in the buffer, undo them with &lt;code&gt;u&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g/sect\d/normal! @a&lt;/code&gt; Run the macro on section lines. &lt;code&gt;&amp;lt;C-X&amp;gt;&lt;/code&gt; by default will jump to the first number on a line for decrements.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;From a script, steps (1)-(4) can be replaced by&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;let @a=&quot;\&amp;lt;C-X&amp;gt;&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-05-17T09:13:33.160" LastActivityDate="2019-05-17T09:13:33.160" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20005" PostTypeId="1" AcceptedAnswerId="26272" CreationDate="2019-05-17T11:57:28.513" Score="12" ViewCount="1271" Body="&lt;p&gt;I want to create a function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Foo()&#xA;    copy something from buffer into a register&#xA;    do something&#xA;    restore register&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Foo&lt;/code&gt; must have no side effect, every register should remain the same after you call it, how should i do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Attempt&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;unnamed register&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Foo()&#xA;    let [regText, regType] = [getreg('&quot;'), getregtype('&quot;')]&#xA;    norm! y{motion}&#xA;    do something&#xA;    call setreg('&quot;', regText, regType)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;side effect:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;register 0 was changed&lt;/li&gt;&#xA;&lt;li&gt;if &lt;code&gt;'clipboard'&lt;/code&gt; includes &lt;code&gt;unnamed&lt;/code&gt; or &lt;code&gt;unnamedplus&lt;/code&gt;, regster &lt;code&gt;*&lt;/code&gt; or &lt;code&gt;+&lt;/code&gt; was also changed.&lt;/li&gt;&#xA;&lt;li&gt;if &lt;code&gt;&quot;&lt;/code&gt; point to other register before calling &lt;code&gt;Foo&lt;/code&gt;, it stopped pointing to it after the calling.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;named register&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Foo()&#xA;    let [regText, regType] = [getreg('a'), getregtype('a')]&#xA;    norm! &quot;ay{motion}&#xA;    do something&#xA;    call setreg('a', regText, regType)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;side effect:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;&lt;/code&gt; now point to &lt;code&gt;a&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;explicit unnamed register&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Foo()&#xA;    let [regText, regType] = [getreg('&quot;'), getregtype('&quot;')]&#xA;    norm! &quot;&quot;y{motion}&#xA;    do something&#xA;    call setreg('&quot;', regText, regType)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;side effect:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if &lt;code&gt;&quot;&lt;/code&gt; point to other register before calling &lt;code&gt;Foo&lt;/code&gt;, it stopped pointing to it after the calling.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;update&lt;/strong&gt; register 0 was changed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-11-07T23:22:59.857" LastActivityDate="2020-12-17T23:13:04.307" Title="How to use register in a script without side effect?" Tags="|vimscript|register|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20006" PostTypeId="1" AcceptedAnswerId="20007" CreationDate="2019-05-17T12:16:25.123" Score="0" ViewCount="60" Body="&lt;p&gt;I am making my life easier by mapping shortcuts to long DocBook XML structures in insert mode, for example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map! &amp;lt;unique&amp;gt; &amp;lt;localleader&amp;gt;ct &amp;lt;callout arearefs=&quot;&quot;&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is there a way to prepend &lt;em&gt;count&lt;/em&gt; to the mapping in insert mode?&#xA;Assuming &lt;code&gt;,&lt;/code&gt; is my &lt;code&gt;&amp;lt;localleader&amp;gt;&lt;/code&gt;, if I want to insert the whole &lt;code&gt;&amp;lt;table&amp;gt;&lt;/code&gt; structure with &lt;code&gt;,tb&lt;/code&gt;, i could easily insert let's say 20 rows (&lt;code&gt;,tr&lt;/code&gt;) by typing something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;20,tr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22283" LastEditorUserId="21621" LastEditDate="2019-05-17T14:07:15.637" LastActivityDate="2019-05-17T14:13:49.703" Title="Repeating mapped text in insert mode" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20007" PostTypeId="2" ParentId="20006" CreationDate="2019-05-17T14:13:49.703" Score="1" Body="&lt;p&gt;If I understood correctly (cf comments under the question), the following might help you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CreateTable(count)&#xA;    &quot; Note, the append creates the table from the end to beginning&#xA;    call append(line('.'), &quot;&amp;lt;/table&amp;gt;&quot;)&#xA;    call append(line('.'), repeat([&quot;&amp;lt;tr&amp;gt;&amp;lt;/tr&amp;gt;&quot;], a:count))&#xA;    call append(line('.'), &quot;&amp;lt;table&amp;gt;&quot;)&#xA;endfunc&#xA;command -range -nargs=0 CreateTable call CreateTable()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And with a mapping (in normal mode) for it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;localleader&amp;gt;tr :&amp;lt;C-U&amp;gt;call CreateTable(v:count1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; cancels the count, to call the function once only (I think this is the good help page: &lt;code&gt;:h c_CTRL-U&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;v:count1&lt;/code&gt; in the last count typed (&lt;code&gt;:help v:count1&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-05-17T14:13:49.703" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20008" PostTypeId="1" AcceptedAnswerId="20152" CreationDate="2019-05-17T15:59:21.560" Score="-1" ViewCount="278" Body="&lt;p&gt;I am having difficulty getting MacVim to behave and look the same as gVim on Windows or Linux. Here's an example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;gVim on Windows:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/CT3ZL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CT3ZL.png&quot; alt=&quot;GVIM on Windows&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MacVim on Mac OS:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/8QtVI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8QtVI.png&quot; alt=&quot;MacVim on Mac OS&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are viewing precisely the same file. The gVim on Windows look is what I want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: the MacVim version appears to be computing the beginning of the line incorrectly, as it should be directly under the 'I' as the very first character in the file. On a number of the later lines, you simply can't navigate to the very beginning of the line, either with the &lt;code&gt;0&lt;/code&gt; command, or with the usual &lt;code&gt;h&lt;/code&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the vimrc files:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;gVim on Windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Courier_New:h9:cANSI:qDRAFT&#xA;set guioptions-=T&#xA;set guioptions-=m&#xA;set showmode&#xA;set cursorline&#xA;set showcmd&#xA;set autoindent&#xA;colorscheme murphy&#xA;set noswapfile&#xA;syntax on&#xA;set number&#xA;set mouse=a&#xA;map &amp;lt;ScrollWheelUp&amp;gt; &amp;lt;C-Y&amp;gt;&#xA;map &amp;lt;ScrollWheelDown&amp;gt; &amp;lt;C-E&amp;gt;&#xA;set numberwidth=8&#xA;set ruler&#xA;set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab&#xA;autocmd FileType python set columns=80&#xA;:imap &amp;lt;c-s&amp;gt; &amp;lt;Esc&amp;gt;:w&amp;lt;CR&amp;gt;a&#xA;:nmap &amp;lt;c-s&amp;gt; :w&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;MacVim on Mac OS:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fileformat=mac&#xA;set guifont=CourierNewPSMT:h10&#xA;set showmode&#xA;set cursorline&#xA;set showcmd&#xA;set autoindent&#xA;colorscheme murphy&#xA;set noswapfile&#xA;syntax on&#xA;set number&#xA;set mouse=a&#xA;map &amp;lt;ScrollWheelUp&amp;gt; &amp;lt;C-Y&amp;gt;&#xA;map &amp;lt;ScrollWheelDown&amp;gt; &amp;lt;C-E&amp;gt;&#xA;set numberwidth=8&#xA;set ruler&#xA;set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab&#xA;autocmd FileType python set columns=80&#xA;:imap &amp;lt;c-s&amp;gt; &amp;lt;Esc&amp;gt;:w&amp;lt;CR&amp;gt;a&#xA;:nmap &amp;lt;c-s&amp;gt; :w&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, here's the text of the text file, as copied from MacVim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I.   33: Introductions&#xA;&#xA; A. 33: Meyer: Scientific and Philosophical Introduction: Defining Theistic Evolution&#xA;    1. 34: Evolution #1: &quot;Change over Time&quot;&#xA;       a.  34: Can be simply &quot;change over time&quot;. Has little or nothing to do with the modern &quot;neo-Darwinian&quot; theory of evolution.&#xA;       b.  34: In evolutionary biology, &quot;change over time&quot; can refer to the idea that the life forms we see today are different from the life forms that existed in the distant &#xA;               past.&#xA;       c.  35: &quot;Change over time&quot; can also refer to observed minor changes in features of individual species - small-scale changes that take place over a relatively short &#xA;               period of time: microevolution.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to fix this? Thanks in advance for your time!&lt;/p&gt;&#xA;" OwnerUserId="22215" LastActivityDate="2019-05-29T16:34:32.347" Title="Whitespace Tabs Show Differently in gVim on Windows/Linux versus MacVim on Mac OS" Tags="|gvim|microsoft-windows|macvim|macos|" AnswerCount="1" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20009" PostTypeId="1" CreationDate="2019-05-17T17:39:29.973" Score="0" ViewCount="911" Body="&lt;p&gt;I want to change the highlighting of the function names inside a c++ file, here is an example&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jeQPV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jeQPV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see in the previous picture functions names have their own color, &lt;code&gt;parser(), parse(), get_headers(), get_http_version()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17299" LastActivityDate="2019-05-18T00:25:03.243" Title="How to edit the highlighting of the function names in c++ syntax" Tags="|syntax-highlighting|colorscheme|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20010" PostTypeId="1" CreationDate="2019-05-17T18:33:54.063" Score="0" ViewCount="320" Body="&lt;p&gt;Currently I have &lt;code&gt;set foldcolumn=1&lt;/code&gt;, but in a buffer with no folds, it's just a waste of space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a convenient event to listen to in order to automatically toggle it between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt; (or whatever preference for 'on')?&lt;/p&gt;&#xA;" OwnerUserId="5778" LastActivityDate="2019-05-17T20:03:25.320" Title="Hide foldcolumn when no folds?" Tags="|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20011" PostTypeId="2" ParentId="20010" CreationDate="2019-05-17T20:03:25.320" Score="2" Body="&lt;p&gt;There is no such event. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I opened &lt;a href=&quot;https://github.com/vim/vim/issues/1866&quot; rel=&quot;nofollow noreferrer&quot;&gt;an issue on vim’s github&lt;/a&gt; about getting an &lt;code&gt;auto&lt;/code&gt; value acceptable for the &lt;code&gt;'foldcolumn'&lt;/code&gt; option, but I don’t recall it gaining any traction. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I developed &lt;a href=&quot;https://github.com/benknoble/vim-auto-origami&quot; rel=&quot;nofollow noreferrer&quot;&gt;Auto Origami&lt;/a&gt; for just this purpose.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-05-17T20:03:25.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20012" PostTypeId="2" ParentId="20009" CreationDate="2019-05-18T00:25:03.243" Score="1" Body="&lt;p&gt;The default vim cpp syntax lacks highlight group for function and class names, there is an &lt;a href=&quot;https://github.com/octol/vim-cpp-enhanced-highlight&quot; rel=&quot;nofollow noreferrer&quot;&gt;enhanced cpp syntax&lt;/a&gt; that defines much more language constructs than the default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change the function colors using this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi clear cppSTLfunction&#xA;hi cppSTLfunction ctermfg=74&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17299" LastActivityDate="2019-05-18T00:25:03.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20014" PostTypeId="1" CreationDate="2019-05-18T02:48:03.657" Score="0" ViewCount="121" Body="&lt;p&gt;How can I prevent vi from starting in insert mode when opening a &quot;test.sh&quot;-like file with the vi-plugin &quot;bash-support&quot; v4.3 ?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When I &lt;code&gt;vim test.sh&lt;/code&gt; it opens in insert mode&lt;/li&gt;&#xA;&lt;li&gt;When I &lt;code&gt;vim .vimrc&lt;/code&gt; it opens in normal mode&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would like to disable this behavior&lt;/p&gt;&#xA;&#xA;&lt;p&gt;plug-in&#xA;&lt;a href=&quot;https://github.com/WolfgangMehner/bash-support&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/WolfgangMehner/bash-support&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22299" LastEditorUserId="-1" LastEditDate="2019-05-18T09:54:50.347" LastActivityDate="2019-05-18T09:54:50.347" Title="Don’t start in insert mode when opening a shell script" Tags="|insert-mode|normal-mode|startup|filetype-sh|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20015" PostTypeId="1" AcceptedAnswerId="20030" CreationDate="2019-05-18T06:06:58.047" Score="0" ViewCount="3658" Body="&lt;p&gt;Say I have a line &lt;code&gt;1234text5678&lt;/code&gt;, where I have selected &lt;code&gt;text&lt;/code&gt; in visual mode. I would like to have a command &lt;code&gt;&amp;lt;Shift&amp;gt;+&lt;/code&gt;, that moves &lt;code&gt;text&lt;/code&gt; to the right one character and selects &lt;code&gt;text&lt;/code&gt; again. I.e. the result should be &lt;code&gt;12345text678&lt;/code&gt;, and &lt;code&gt;text&lt;/code&gt; being selected. From playing around, I got&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap * dpgv=gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this selects &lt;code&gt;5tex&lt;/code&gt; after the movement. How can it be adjusted? (I don't know if this is standard, but on German keyboards &lt;code&gt;&amp;lt;Shift&amp;gt;+&lt;/code&gt; is the same as &lt;code&gt;*&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I would also like to create a similar command to move to the left, but probably I can figure that one out myself once I got the other version.&lt;/p&gt;&#xA;" OwnerDisplayName="user17723" LastActivityDate="2019-05-21T06:51:16.307" Title="Move selected text to the right" Tags="|visual-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20016" PostTypeId="2" ParentId="20015" CreationDate="2019-05-18T06:21:46.670" Score="0" Body="&lt;pre&gt;&lt;code&gt;xnoremap * dp`[v`]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;dp&lt;/code&gt; shift right&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`[v`]&lt;/code&gt; select newly pasted content.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h `[&lt;/code&gt; mark start of last changed or yanked text.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h `]&lt;/code&gt; mark end of last changed or yanked text.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-05-18T06:21:46.670" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20017" PostTypeId="1" CreationDate="2019-05-18T09:34:30.487" Score="1" ViewCount="64" Body="&lt;p&gt;I am trying to use the Dispatch plugin to compile my latex code asynchronously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, I am using the last code in the following question:&#xA;&lt;a href=&quot;https://tex.stackexchange.com/questions/241430/vim-latex-suite-background-compilation&quot;&gt;https://tex.stackexchange.com/questions/241430/vim-latex-suite-background-compilation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;namely I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Start! latexmk % &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then essentially nothing happens, but in the command line I see written:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!latexmk &amp;lt;path to the file&amp;gt;/file.tex (windows/?)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the same file the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:! latexmk % &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;produces the required output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any clues? I was under the impression that the code worked for half a day!&lt;/p&gt;&#xA;" OwnerUserId="22303" LastActivityDate="2019-05-18T15:55:22.987" Title="Dispatch plugin gives no output" Tags="|plugin-dispatch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20018" PostTypeId="1" CreationDate="2019-05-18T13:41:03.053" Score="1" ViewCount="274" Body="&lt;p&gt;I'm trying to combine &lt;a href=&quot;https://github.com/msprev/fzf-bibtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf-bibtex&lt;/a&gt; with &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt; so that I can search my bibliography file and insert a BibTeX key automatically. I use the following function from &lt;code&gt;fzf-bibtex&lt;/code&gt; (which calls the binaries &lt;code&gt;bibtex-cite&lt;/code&gt; and &lt;code&gt;bibtex-ls&lt;/code&gt; on my system, they just format and output the BibTeX key):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:bibtex_cite_sink_insert(lines)&#xA;    let r=system(&quot;bibtex-cite &quot;, a:lines)&#xA;    execute ':normal! i' . r&#xA;    call feedkeys('a', 'n')&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;silent&amp;gt; @@ &amp;lt;c-g&amp;gt;u&amp;lt;c-o&amp;gt;:call fzf#run({&#xA;                        \ 'source': 'bibtex-ls',&#xA;                        \ 'sink*': function('&amp;lt;sid&amp;gt;bibtex_cite_sink_insert'),&#xA;                        \ 'up': '40%',&#xA;                        \ 'options': '--ansi --layout=reverse-list --multi --prompt &quot;Cite&amp;gt; &quot;'})&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in my &lt;code&gt;markdown.snippets&lt;/code&gt; file I have the following snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet q &quot;Quote&quot; i&#xA;[$1, $2] $0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If i now press &lt;code&gt;@@&lt;/code&gt; in insert mode when at position &lt;code&gt;$1&lt;/code&gt; after the snipped expanded, it works fine and the &lt;code&gt;fzf&lt;/code&gt; prompt with my BibTeX entries is opened. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I wanted to automatically call this prompt when the snippet expanded. I thought that could maybe be done with telling vim to just type in &lt;code&gt;@@&lt;/code&gt; when at snippet position &lt;code&gt;$1&lt;/code&gt;, so I said:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet q &quot;Quote&quot; i&#xA;[`!v feedkeys('@@')`, $2] $0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;fzf&lt;/code&gt; prompt gets indeed invoked, but it stays in an &lt;em&gt;infinite&lt;/em&gt; loop after it entered the selected key, opening the prompt again and again. I can't even quit it with &lt;code&gt;Esc&lt;/code&gt; or &lt;code&gt;Ctrl-c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What did I do wrong? Thanks for helping.&lt;/p&gt;&#xA;" OwnerUserId="22304" LastActivityDate="2019-05-18T13:41:03.053" Title="Vimscript infinite loop" Tags="|vimscript|plugin-ultisnips|plugin-fzf|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20019" PostTypeId="1" AcceptedAnswerId="20031" CreationDate="2019-05-18T14:49:19.123" Score="3" ViewCount="800" Body="&lt;p&gt;I've been looking around for a while now but I couldn't find a proper answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to access python documentation from Vim. I know that some plugins exist (like this one: &lt;a href=&quot;https://github.com/fs111/pydoc.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/fs111/pydoc.vim&lt;/a&gt;). But these plugins are far from perfect. WIth pydoc for example, if you press K on a word, you'll get the documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import matplotlib.pyplot&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you &lt;kbd&gt;K&lt;/kbd&gt; on &lt;code&gt;pyplot&lt;/code&gt;, you'll get the documentation.&#xA;But if you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import matplotlib.pyplot as plt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;kbd&gt;K&lt;/kbd&gt; on &lt;code&gt;plt&lt;/code&gt;, you won't get anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also the jedi plugin, which displays documentation on the fly. If you type &lt;code&gt;plt.&lt;/code&gt;, it will display the objects/methods of &lt;code&gt;plt&lt;/code&gt;. But you need to be typing for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I think none of these plugins work on the code present in the same folder but imported in the current file. For example, if &lt;code&gt;my_module&lt;/code&gt; is implemented in a folder, and if I import it in &lt;code&gt;my_script.py&lt;/code&gt;, I don't have access to the documentation from &lt;code&gt;my_module&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any idea how to improve my situation please?&lt;/p&gt;&#xA;" OwnerUserId="22006" LastEditorUserId="4472" LastEditDate="2019-05-24T07:17:51.267" LastActivityDate="2019-05-24T07:17:51.267" Title="Documentation for python" Tags="|filetype-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20020" PostTypeId="2" ParentId="20015" CreationDate="2019-05-18T15:12:23.797" Score="1" Body="&lt;p&gt;Here’s two alternative solutions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap * dp`[1v&#xA;&#xA;xnoremap * dpgvlol&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;`[&lt;/code&gt; &amp;mdash; Jump to start of pasted text&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1v&lt;/code&gt;  &amp;mdash; reselect the same amount of text as the last visual operation, but starting from the current cursor position&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gv&lt;/code&gt;  &amp;mdash; reselect the same visual area as last selection,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;lol&lt;/code&gt; &amp;mdash; move visual selection right by moving the end one character to the right, and then jumping to the start and moving that one character to the right also.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-05-19T06:28:21.270" LastActivityDate="2019-05-19T06:28:21.270" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20021" PostTypeId="2" ParentId="12882" CreationDate="2019-05-18T15:24:55.770" Score="1" Body="&lt;p&gt;&lt;code&gt;patch 8.1.1068&lt;/code&gt; introduced a new function &lt;a href=&quot;https://vimhelp.org/eval.txt.html#complete_info%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h complete_info&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    patch 8.1.1068: cannot get all the information about current completion&#xA;&#xA;    Problem:    Cannot get all the information about current completion.&#xA;    Solution:   Add complete_info(). (Shougo, Hirohito Higashi, closes #4106)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can create map like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; map 1-9 to nth item&#xA;&quot; map shift+{1-9} to last nth item&#xA;let s:shiftKeys = '!@#$%^&amp;amp;*('&#xA;for s:i in range(1, 9)&#xA;  exe printf('inoremap &amp;lt;expr&amp;gt; %d pumvisible() ? &amp;lt;sid&amp;gt;select_pum(%d - 1) : %d ', s:i, s:i, s:i)&#xA;  let skey = s:shiftKeys[s:i-1]&#xA;  exe printf('inoremap &amp;lt;expr&amp;gt; %s pumvisible() ? &amp;lt;sid&amp;gt;select_pum(-%d) : &quot;%s&quot; ', skey, s:i, skey)&#xA;endfor&#xA;&#xA;&quot; map 0 to original item&#xA;inoremap &amp;lt;expr&amp;gt; 0 pumvisible() ? '&amp;lt;c-e&amp;gt;' : 0&#xA;&#xA;function! s:select_pum(index)&#xA;  let compInfo = complete_info()&#xA;  let idx = a:index &amp;gt;= 0 ? a:index : a:index + len(compInfo.items)&#xA;  let d = idx - compInfo.selected&#xA;  return repeat( d &amp;gt; 0 ? &quot;\&amp;lt;c-n&amp;gt;&quot; : &quot;\&amp;lt;c-p&amp;gt;&quot;, abs(d))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-18T23:44:56.077" LastActivityDate="2019-05-18T23:44:56.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20022" PostTypeId="2" ParentId="20017" CreationDate="2019-05-18T15:55:22.987" Score="2" Body="&lt;p&gt;The point of dispatch is to not clutter the screen when possible. The job is running in the background, most likely. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;:Copen&lt;/code&gt; to open the quickfix window. It may not yet be populated. Check the dispatch docs. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-05-18T15:55:22.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20023" PostTypeId="1" AcceptedAnswerId="20024" CreationDate="2019-05-18T16:09:02.617" Score="2" ViewCount="2656" Body="&lt;p&gt;I went to open a browser window today with CTRL+n and I wasn't in the browser I was in vim, when a menu popped up with what looked to be about every word in my entire document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does CTRL+n do, and where can I find the documentation for it?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2019-05-18T16:18:04.867" Title="What does c^n in vim do?" Tags="|keyboard-layout|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20024" PostTypeId="2" ParentId="20023" CreationDate="2019-05-18T16:18:04.867" Score="5" Body="&lt;p&gt;In normal mode, it basically moves your cursor down, it is like pressing &lt;code&gt;RETURN&lt;/code&gt;. From &lt;code&gt;:help CTRL-n&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;NL&amp;gt; or CTRL-N                      [count] lines downward linewise.   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In insert mode, it triggers the autocompletion (&lt;code&gt;n&lt;/code&gt; for &quot;Next&quot; matching term). From &lt;code&gt;help i_CTRL-n&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-N                  Find next match for words that start with the                                                                                                                                              &#xA;                        keyword in front of the cursor, looking in places                                                                                                                                          &#xA;                        specified with the 'complete' option.  The found                                                                                                                                           &#xA;                        keyword is inserted in front of the cursor.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In insert mode, &lt;code&gt;CTRL-p&lt;/code&gt; finds the previous match.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-05-18T16:18:04.867" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20025" PostTypeId="1" AcceptedAnswerId="20026" CreationDate="2019-05-18T17:45:13.710" Score="0" ViewCount="472" Body="&lt;p&gt;I'm trying to create a simple function in vim which lets me map &lt;code&gt;&amp;lt;leader&amp;gt;b&lt;/code&gt;, &lt;code&gt;&amp;lt;leader&amp;gt;n&lt;/code&gt;, and &lt;code&gt;&amp;lt;leader&amp;gt;0&lt;/code&gt; to execute a function that checks if a nerd tree is open then cycle tabs and do &lt;code&gt;:NerdTreeFind&lt;/code&gt; if not then only cycle tabs. but I couldn't seem to make it work and it returns &lt;code&gt;E121: Undefined variable: CR&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is the script &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CheckNerdTree(tab)&#xA;    if exists(&quot;g:NERDTree&quot;) &amp;amp;&amp;amp; g:NERDTree.IsOpen()&#xA;        execute a:tab&amp;lt;CR&amp;gt;:NERDTreeFind&amp;lt;CR&amp;gt;&amp;lt;C-w&amp;gt;l&amp;lt;CR&amp;gt;&#xA;    else&#xA;        execute a:tab&amp;lt;CR&amp;gt;&#xA;    endif&#xA;endfunction&#xA;&#xA;&#xA;noremap &amp;lt;leader&amp;gt;0 :call CheckNerdTree(&quot;:tablast&quot;)&#xA;noremap &amp;lt;leader&amp;gt;n :call CheckNerdTree(&quot;:tabnext&quot;)&#xA;noremap &amp;lt;leader&amp;gt;b :call CheckNerdTree(&quot;:tabprev&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm pretty new to vim scripting and haven't really 100% understand how it works, any help would be appreciated. Thanks&lt;/p&gt;&#xA;" OwnerUserId="22309" LastEditorUserId="51" LastEditDate="2019-05-19T02:34:29.690" LastActivityDate="2019-05-19T02:34:29.690" Title="Check nerd tree is open function" Tags="|vimscript|functions|plugin-nerdtree|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20026" PostTypeId="2" ParentId="20025" CreationDate="2019-05-18T18:00:01.423" Score="0" Body="&lt;p&gt;The execute command takes a string as an argument. Further, it is used to execute Ex commands. Finally, Ex-commands may be « executed » (in the programmatic sense, not the vimscript sense!) by simply calling them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So we can simplify to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute a:tab&#xA;NERDTreeFind&#xA;wincmd l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute a:tab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Don’t forget the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;s at the end of the mapping&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-05-18T19:39:06.673" LastActivityDate="2019-05-18T19:39:06.673" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20027" PostTypeId="1" AcceptedAnswerId="20028" CreationDate="2019-05-18T20:08:01.877" Score="4" ViewCount="2781" Body="&lt;p&gt;I tried entering the key sequence &lt;code&gt;&amp;lt;esc&amp;gt;+&amp;lt;n&amp;gt;+i+&amp;lt;some-char&amp;gt;+&amp;lt;esc&amp;gt;&lt;/code&gt; and it'll type &lt;code&gt;&amp;lt;some-char&amp;gt;&lt;/code&gt; &lt;code&gt;&amp;lt;n&amp;gt;&lt;/code&gt; times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I'm using a macbook keyboard there is no escape key, so I tried this instead &lt;code&gt;&amp;lt;CTRL+C&amp;gt;+&amp;lt;n&amp;gt;+i+&amp;lt;some-char&amp;gt;+&amp;lt;CTRL+C&amp;gt;&lt;/code&gt;, and it didn't type &lt;code&gt;&amp;lt;some-char&amp;gt;&lt;/code&gt; &lt;code&gt;&amp;lt;n&amp;gt;&lt;/code&gt; times; is there an alternative way to do this on a Macbook, or when you don't have an esc key?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2019-05-18T22:28:58.650" Title="Are CTRL+C and &lt;esc&gt; the same?" Tags="|macvim|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20028" PostTypeId="2" ParentId="20027" CreationDate="2019-05-18T22:01:25.663" Score="7" Body="&lt;p&gt;&lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; are mostly similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They will differ in some cases such as the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Doing a vertical insert (&lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;, then going down, then &lt;code&gt;i&lt;/code&gt; to insert the same character, or text, on multiple lines): &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; will leave the insert mode and insert the typed text on the selected lines, whereas &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; will leave the insert mode and will only insert the text where the cursor was (cancelling the vertical insert).&lt;/li&gt;&#xA;&lt;li&gt;When using &lt;code&gt;input()&lt;/code&gt;, the behaviour changes, cf: &lt;a href=&quot;https://stackoverflow.com/a/56163617/3866623&quot;&gt;https://stackoverflow.com/a/56163617/3866623&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;n&amp;gt;i&lt;/code&gt;, as in your question, &lt;code&gt;esc&lt;/code&gt; will insert &lt;code&gt;n&lt;/code&gt; times what you typed, &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; will cancel the input and insert it once.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; is pretty much cancelling the action and going back in Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want an alternative to &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; (&lt;code&gt;CTRL-[&lt;/code&gt;) is doing exactly the same, in case you don't have an escape key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, &lt;code&gt;:help i_CTRL-[&lt;/code&gt; and &lt;code&gt;:help i_CTRL-C&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Esc&amp;gt; or CTRL-[    End insert or Replace mode, go back to Normal mode. Finish &#xA;                   abbreviation.                                                   &#xA;                   Note: If your &amp;lt;Esc&amp;gt; key is hard to hit on your keyboard, &#xA;                   train yourself to use CTRL-[. If Esc doesn't work and you &#xA;                   are using a Mac, try CTRL-Esc. Or disable Listening under&#xA;                   Accessibility preferences.&#xA;&#xA;CTRL-C             Quit insert mode, go back to Normal mode.  Do not check for     &#xA;                   abbreviations.  Does not trigger the InsertLeave autocommand    &#xA;                   event. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21621" LastEditorUserId="21621" LastEditDate="2019-05-18T22:28:58.650" LastActivityDate="2019-05-18T22:28:58.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20030" PostTypeId="2" ParentId="20015" CreationDate="2019-05-19T08:38:55.410" Score="1" Body="&lt;h1&gt;Choice of Mapping&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I personnally like to use &lt;code&gt;v_*&lt;/code&gt; for searching the visually selected text, similar to what &lt;code&gt;n_*&lt;/code&gt; does in normal mode for the word under the cursor. Using &lt;code&gt;v_*&lt;/code&gt; for shifting a visual selection sideways is in conflict with &lt;a href=&quot;https://github.com/thinca/vim-visualstar&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-visualstar&lt;/a&gt; which I think could actually be the default behavior of vanilla vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;viwdp&lt;/code&gt; or with an additional movement between &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt; here is good enough for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vim.fandom.com/wiki/Moving_lines_up_or_down&quot; rel=&quot;nofollow noreferrer&quot;&gt;A&lt;/a&gt; &lt;a href=&quot;https://github.com/tpope/vim-unimpaired#unimpairedvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;typical&lt;/a&gt; &lt;a href=&quot;https://github.com/inkarkat/vim-LineJuggler&quot; rel=&quot;nofollow noreferrer&quot;&gt;related&lt;/a&gt; &lt;a href=&quot;http://vimcasts.org/episodes/bubbling-text/&quot; rel=&quot;nofollow noreferrer&quot;&gt;feature&lt;/a&gt; request is shifting lines up and down. Greg Hurrell has produced a screencast how to do this (&lt;a href=&quot;https://www.youtube.com/watch?v=X5IAdaN6IwM&amp;amp;list=PLwJS-G75vM7kFO-yUkyNphxSIdbi_1NKX&amp;amp;t=0s&amp;amp;index=65&quot; rel=&quot;nofollow noreferrer&quot;&gt;youtube&lt;/a&gt;). However, he&#xA;does not recommend it because:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;it encourages bad habits ... do not mash keys ... not the vim way&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I agree and would say that repeat is an anti-pattern here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want such behaviour and a direct key to press, consider also following plugins and their suggestions for mappings:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Plugins and their Suggested Mappings&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/matze/vim-move&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-move&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default mappings use the Alt-key as prefix which does not work in all circumstances:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;A-k&amp;gt;   Move current line/selection up&#xA;&amp;lt;A-j&amp;gt;   Move current line/selection down&#xA;&amp;lt;A-h&amp;gt;   Move current character/selection left&#xA;&amp;lt;A-l&amp;gt;   Move current character/selection right&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/t9md/vim-textmanip&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textmanip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xmap &amp;lt;C-j&amp;gt; &amp;lt;Plug&amp;gt;(textmanip-move-down)&#xA;xmap &amp;lt;C-k&amp;gt; &amp;lt;Plug&amp;gt;(textmanip-move-up)&#xA;xmap &amp;lt;C-h&amp;gt; &amp;lt;Plug&amp;gt;(textmanip-move-left)&#xA;xmap &amp;lt;C-l&amp;gt; &amp;lt;Plug&amp;gt;(textmanip-move-right)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The plugin &lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-tmux-navigator&lt;/a&gt; uses the same set in normal mode to switch windows. This makes them a little bit inconsistent between modes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/zirrostig/vim-schlepp&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-schlepp&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;unique&amp;gt; &amp;lt;up&amp;gt;    &amp;lt;Plug&amp;gt;SchleppUp&#xA;vmap &amp;lt;unique&amp;gt; &amp;lt;down&amp;gt;  &amp;lt;Plug&amp;gt;SchleppDown&#xA;vmap &amp;lt;unique&amp;gt; &amp;lt;left&amp;gt;  &amp;lt;Plug&amp;gt;SchleppLeft&#xA;vmap &amp;lt;unique&amp;gt; &amp;lt;right&amp;gt; &amp;lt;Plug&amp;gt;SchleppRight&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some may argue arrow keys are too far away from the homerow.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Related Plugins&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If you want to shift list items, function arguments and similar, consider the plugins &lt;a href=&quot;https://github.com/andrewradev/sideways.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;sideways.vim&lt;/a&gt; and &lt;a href=&quot;https://github.com/machakann/vim-swap&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-swap&lt;/a&gt;. Suggested mappings by the plugin author Andrew Radev are again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-h&amp;gt; :SidewaysLeft&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;c-l&amp;gt; :SidewaysRight&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim-swap defines following two which I think are a quite good choice:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap g&amp;lt; &amp;lt;Plug&amp;gt;(swap-prev)&#xA;nmap g&amp;gt; &amp;lt;Plug&amp;gt;(swap-next)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/tommcdo/vim-exchange&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;vim-exchange&lt;/strong&gt;&lt;/a&gt; works differently by not shifting things around. I think this plugin fits better to the vim way. The mappings are&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call s:create_map('n', 'cx', '&amp;lt;Plug&amp;gt;(Exchange)')&#xA;call s:create_map('x', 'X', '&amp;lt;Plug&amp;gt;(Exchange)')&#xA;call s:create_map('n', 'cxx', '&amp;lt;Plug&amp;gt;(ExchangeLine)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and allows to use &lt;code&gt;.&lt;/code&gt; if the target is addressed by the same mapping. E.g. swapping distant lines &lt;code&gt;cxx&lt;/code&gt;, &lt;code&gt;&amp;lt;no&amp;gt;G&lt;/code&gt; and then press &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;cxiw&lt;/code&gt;, move and then &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I point the reader to the screencast by &lt;a href=&quot;http://vimcasts.org/episodes/swapping-two-regions-of-text-with-exchange-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Drew Neil&lt;/a&gt; to see it in action.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-05-21T06:51:16.307" LastActivityDate="2019-05-21T06:51:16.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20031" PostTypeId="2" ParentId="20019" CreationDate="2019-05-20T02:57:26.900" Score="3" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/davidhalter/jedi-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;jedi-vim&lt;/a&gt; which can show the documentation for modules and functions. By default, it uses &lt;code&gt;K&lt;/code&gt; to look up documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since it relies on &lt;a href=&quot;https://github.com/davidhalter/jedi&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jedi&lt;/a&gt;, you must install Jedi package first:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pip install jedi&#xA;# or conda install jedi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-05-20T02:57:26.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20032" PostTypeId="1" AcceptedAnswerId="20034" CreationDate="2019-05-20T09:32:49.270" Score="0" ViewCount="831" Body="&lt;p&gt;I want to create a function that I can call to replace a specific string pattern with &lt;code&gt;md5sum&lt;/code&gt; of current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no experience writing VimL before and can't figure out the way to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I roughly have in my mind:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Calculate text hash and replace the old one&#xA;function! HashBuffer()&#xA;  :redir @a&#xA;  &quot; Will this work? Is this a buffer contents or previously save file?&#xA;  :!md5sum %&#xA;  :redir END&#xA;&#xA;  &quot; replace with @a (How?)&#xA;  %s/%%%HASH.*%%%/%%%HASH-XXXXXXXXX%%%/&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Usage example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let say I have a file, I am working on&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# %%%HASH-XXXXXXXXX%%%&#xA;&#xA;the content of file ....&#xA;....&#xA;..&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want the hash to be calculate when I manually &lt;code&gt;:call HashBuffer()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# %%%HASH-1d4171a91c31af2c59acb89a042836e1%%%&#xA;&#xA;the content of file ....&#xA;....&#xA;..&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's obviously not working but I don't have any idea what to do next.&lt;/p&gt;&#xA;" OwnerUserId="7247" LastEditorUserId="7247" LastEditDate="2019-05-20T10:06:41.810" LastActivityDate="2019-05-20T10:25:12.017" Title="How to create a function to `hash` buffer content" Tags="|vimscript|external-command|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20033" PostTypeId="2" ParentId="20032" CreationDate="2019-05-20T09:41:15.307" Score="1" Body="&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; After our discussion in chat here is the final function you need:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HashBuffer()&#xA;    let hashedContent = system(&quot;md5sum &quot; . expand('%')) &#xA;    execute '%s/HASH.*/HASH-' . split(hashedContent, ' ')[0]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First we use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#system%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h system()&lt;/code&gt;&lt;/a&gt; to get the result of the external command &lt;code&gt;md5sum &amp;lt;filename&amp;gt;&lt;/code&gt; in a variable and we use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expand%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h expand()&lt;/code&gt;&lt;/a&gt; to get the actual filename.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my system &lt;code&gt;md5sum&lt;/code&gt; returns a result of the form &lt;code&gt;{hash} {filename}&lt;/code&gt;, as you don't want the filename we use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#split%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h split()&lt;/code&gt;&lt;/a&gt; to get only the hash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally we use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#execute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h execute()&lt;/code&gt;&lt;/a&gt; to build the susbtitution command you want to use with the content of the variable.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I think you only need one command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!md5sum&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which basically filters the content of the full buffer (&lt;code&gt;%&lt;/code&gt;) through the external command (&lt;code&gt;!&lt;/code&gt;) &lt;code&gt;md5sum&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my setup the file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bar&#xA;buzz&#xA;fizz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;e70ad0b62c1f427ae49ce73b9c09155c  -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if you want to make that a function, the following should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HashBuffer()&#xA;    %!md5sum&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You probably want to read &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#filter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h filter&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3Arange&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :range&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-05-20T10:14:26.577" LastActivityDate="2019-05-20T10:14:26.577" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20034" PostTypeId="2" ParentId="20032" CreationDate="2019-05-20T10:25:12.017" Score="1" Body="&lt;p&gt;You could try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot; calculate text hash and replace the old one&#xA;function! HashBuffer()&#xA;  let md5=trim(system('md5sum ' . expand('%') . ' | cut &quot;-d &quot; -f1'))&#xA;  %s/%%%\&amp;lt;HASH.*%%%/\='%%%' . 'HASH-' . md5 . '%%%'/&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A few notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;expand('%')&lt;/code&gt; returns the current file name.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;| cut &quot;-d &quot; -f1&lt;/code&gt; only returns the md5sum, but cuts of the file name&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;trim(...)&lt;/code&gt; is used to trim the trailing newline (&lt;code&gt;trim()&lt;/code&gt; was introduced in  Vim 8.0.1630 or so, if you have an older versions I could provide a replacement)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The interesting part is the regex. This is written more complicated than needed, so if you ever run the function on its source code, the source code will not be destroyed. Lets simplify it first:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/%%%\&amp;lt;HASH.*%%%/\='%%%' . 'HASH-' . md5 . '%%%'/&#xA;%s/%%%HASH.*%%%/\='%%%HASH-' . md5 . '%%%'/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\&amp;lt;&lt;/code&gt; was removed, it just matches the &quot;start of  a word&quot;. See &lt;code&gt;:h /\&amp;lt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The interesting part is the replacement String: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\='%%%HASH-' . md5 . '%%%'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The leading &lt;code&gt;\=&lt;/code&gt; is called &quot;sub-replace-special&quot;. When the replacement string starts with this, the rest is interpreted as a VimScript expression. Here we just concatenate the leading string with the MD5  and the trailer.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-05-20T10:25:12.017" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20035" PostTypeId="1" AcceptedAnswerId="20036" CreationDate="2019-05-20T12:21:36.723" Score="3" ViewCount="336" Body="&lt;p&gt;Saying that I have such a file as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;random_string&amp;gt;hello&amp;lt;random_string&amp;gt;&#xA;random_string&amp;lt;random_string&amp;gt;hello&amp;lt;random_string&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to remove the first square bracket and its content so that the file becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello&amp;lt;random_string&amp;gt;&#xA;random_stringhello&amp;lt;random_string&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How could I achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to execute &lt;code&gt;:%s/&amp;lt;.*&amp;gt;//&lt;/code&gt; but it will remove all things I think it's because it matches the last &lt;code&gt;&amp;gt;&lt;/code&gt; for each line.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2019-05-20T13:08:47.563" Title="How to replace the first matching for each line with regular expression" Tags="|regular-expression|search|replace|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20036" PostTypeId="2" ParentId="20035" CreationDate="2019-05-20T13:04:35.173" Score="4" Body="&lt;p&gt;I guess this would be the easiest solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/&amp;lt;[^&amp;gt;]*&amp;gt;//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It matches:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;&lt;/code&gt; an opening angle bracket&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^&amp;gt;]*&lt;/code&gt; anything not being a closing angle bracket&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;gt;&lt;/code&gt; a angle bracket.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Of course the other solution is to use a non greedy operator as in the question linked by @Mass like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/&amp;lt;.\{-}&amp;gt;//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="19763" LastEditDate="2019-05-20T13:08:47.563" LastActivityDate="2019-05-20T13:08:47.563" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20037" PostTypeId="1" CreationDate="2019-05-20T14:16:36.280" Score="0" ViewCount="56" Body="&lt;p&gt;I am using &lt;code&gt;matchadd()&lt;/code&gt; to match some text in a line.  Using Vim script, how can I jump to the matched text?  Or, instead, how can I get the column number of the start of the match?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Motivation: I have one or more pieces of known text at known locations on a line and I want to jump from one to the next so they can be amended.  However as soon as the user amends something, the locations become out of date.  So instead of using locations and &lt;code&gt;matchaddpos()&lt;/code&gt; I'm using patterns and &lt;code&gt;matchadd()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried setting marks at the start when the locations are known, but marks only auto-update when the line number changes, not the column number.&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2019-05-20T14:16:36.280" Title="Find location of matched pattern" Tags="|search|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20038" PostTypeId="1" AcceptedAnswerId="20040" CreationDate="2019-05-20T15:02:56.013" Score="12" ViewCount="2371" Body="&lt;p&gt;Suppose I'd like to create a list&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- &quot;1&quot;&#xA;- &quot;2&quot;&#xA;- &quot;3&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what Is the smartest way to create such?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My attempt would be to &lt;kbd&gt;i&lt;/kbd&gt;&lt;code&gt;- &quot;1&quot;&lt;/code&gt;&lt;kbd&gt;ESC&lt;/kbd&gt;&lt;kbd&gt;yy&lt;/kbd&gt;&lt;kbd&gt;pp&lt;/kbd&gt; to get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- &quot;1&quot;&#xA;- &quot;1&quot;&#xA;- &quot;1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then jump to the second line's 1 &lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;3&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT: doing this for a list of e.g. 100 (also thinking about the second digit) is not what I want to do with technique above...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using nvim v0.3.5 von archLinux, but i don't think, that that does matter.&lt;/p&gt;&#xA;" OwnerUserId="19041" LastActivityDate="2019-05-20T17:10:28.870" Title="Visual Block Mode edit with sequential number" Tags="|visual-mode|macro|visual-block|line-numbers|" AnswerCount="3" CommentCount="0" ClosedDate="2019-05-21T09:19:57.253" ContentLicense="CC BY-SA 4.0" />
  <row Id="20039" PostTypeId="2" ParentId="20038" CreationDate="2019-05-20T15:13:43.833" Score="1" Body="&lt;p&gt;I would do it as follow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Somewhere in your file (before where you want your list), add a line with the first number - 1 (most likely 0),&lt;/li&gt;&#xA;&lt;li&gt;Make a mark at this place (&lt;code&gt;ma&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Make an empty line where you want your list and make another mark there (&lt;code&gt;mb&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Your file would, at this point, look like this (The lines 1 and 2 don't matter, they are just here to say where the marks are):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/895wH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/895wH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Record the following macro:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    qq                          // Start the macro in register q&#xA;    `a                          // go to mark a&#xA;    CTRL-a                      // Increase the number&#xA;    yiw                         // Copy the number&#xA;    `b                          // Go to mark b&#xA;    i- &quot;                        // Go in insert mode, insert - &quot;&#xA;    &amp;lt;esc&amp;gt;p                      // leave the insert mode and paste the number&#xA;    A&quot;&amp;lt;CR&amp;gt;&amp;lt;esc&amp;gt;                 // Closes the quote, add a new line and leave the insert mode&#xA;    mb                          // Update the mark b to be here&#xA;    q                           // Stop recording the macro&#xA;&#xA;    100@q                       // Run the macro 100 times&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can delete the line where the mark a is, as it was just to store the counter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;em&gt;voila&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastEditorUserId="21621" LastEditDate="2019-05-20T15:18:28.700" LastActivityDate="2019-05-20T15:18:28.700" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20040" PostTypeId="2" ParentId="20038" CreationDate="2019-05-20T15:27:24.727" Score="16" Body="&lt;p&gt;Depending on your usecase the following might be useful:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create the entries all with the number &quot;1&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- &quot;1&quot;&#xA;- &quot;1&quot;&#xA;- &quot;1&quot;&#xA;- &quot;1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then go to the second &quot;1&quot; and press &lt;kbd&gt;V&lt;/kbd&gt; to start line-wise visual. Then move down to the last &quot;1&quot;. So now all but the first &quot;1&quot; is selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now hit &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;Ctrl-a&lt;/kbd&gt; and you get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- &quot;1&quot;&#xA;- &quot;2&quot;&#xA;- &quot;3&quot;&#xA;- &quot;4&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help v_g_CTRL-A&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; What if a I need a new number &quot;3&quot; and all following should be increased by one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First insert the new line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- &quot;1&quot;&#xA;- &quot;2&quot;&#xA;- &quot;3&quot;&#xA;- &quot;3&quot;&#xA;- &quot;4&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then go to the second &quot;3&quot;, hit &lt;kbd&gt;V&lt;/kbd&gt; and move down to the end of the list. Now hit &lt;kbd&gt;Ctrl-a&lt;/kbd&gt; (without leading &lt;code&gt;g&lt;/code&gt;) and the selected numbers are increased by one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- &quot;1&quot;&#xA;- &quot;2&quot;&#xA;- &quot;3&quot;&#xA;- &quot;4&quot;&#xA;- &quot;5&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-05-20T15:50:04.743" LastActivityDate="2019-05-20T15:50:04.743" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20041" PostTypeId="2" ParentId="20038" CreationDate="2019-05-20T16:10:44.283" Score="3" Body="&lt;p&gt;Here's a shorter macro version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First write a single line with the contents&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- &quot;1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then type the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;Ctrl-A&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;9&lt;/kbd&gt;&lt;kbd&gt;8&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&amp;mdash;start recording&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&amp;mdash;Duplicate the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-A&lt;/kbd&gt;&amp;mdash;Increment the number&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&amp;mdash;End the recording&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;9&lt;/kbd&gt;&lt;kbd&gt;8&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&amp;mdash;Replay 98 times&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-05-20T17:10:28.870" LastActivityDate="2019-05-20T17:10:28.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20042" PostTypeId="1" CreationDate="2019-05-20T19:04:11.920" Score="0" ViewCount="36" Body="&lt;p&gt;For example one could have many of these for different tasks (with different values for different registers based on the task):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function !RegisterTemplateTest() &#xA;&#xA;    # Set contents of said register&#xA;    let @p='andy'&#xA;    let @w='blah'&#xA;    let @b='someBunchahText'&#xA;    let @v='dfaskfasf'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And have them setup with some sort of init function that calls them.&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2019-05-20T19:04:11.920" Title="Is there a particular name for when you pre-set a bunch of registers used for a specific task at hand?" Tags="|vimscript|terminology|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20043" PostTypeId="1" AcceptedAnswerId="20044" CreationDate="2019-05-21T08:14:10.450" Score="0" ViewCount="172" Body="&lt;p&gt;I have initiated online spell checking in &lt;code&gt;.vimrc&lt;/code&gt; with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType docbk set spell spelllang=en&#xA;autocmd FileType docbk highlight SpellBad cterm=underline ctermfg=red ctermbg=none&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my plugin's &lt;code&gt;after/syntax/&lt;/code&gt; directory, i created &lt;code&gt;docbk.vim&lt;/code&gt; file with the following content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    syntax spell toplevel&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to prevent spellchecking XML markup (although i dont know what it's actually doing...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that while everything is working fine, text inside &lt;code&gt;&amp;lt;title&amp;gt;text&amp;lt;/title&amp;gt;&lt;/code&gt; is not spellchecked at all.&lt;/p&gt;&#xA;" OwnerUserId="22283" LastEditorUserId="19763" LastEditDate="2019-05-21T08:38:12.253" LastActivityDate="2019-06-20T09:03:35.427" Title="Vim does not spellcheck the content of &lt;title&gt; element in my DocBook files" Tags="|spell-checking|filetype-xml|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20044" PostTypeId="2" ParentId="20043" CreationDate="2019-05-21T08:54:14.767" Score="1" Body="&lt;p&gt;I assume that spell check also doesn't work in &lt;code&gt;&amp;lt;emphasis&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;remark&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;comment&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;citation&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The syntax file for DocBook is rather old (2012) and I don't know if it is still maintained. Anyway you should try to contact the maintainer. See top of file &lt;code&gt;$VIMRUNTIME/syntax/dockbk.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do now:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Copy the file &lt;code&gt;$VIMRUNTIME/syntax/docbk.vim&lt;/code&gt; to your &lt;code&gt;~/.vim/syntax&lt;/code&gt; (on Windows: &lt;code&gt;~/vimfile/syntax&lt;/code&gt;) directory. &#xA;Execute &lt;code&gt;:echo $VIMRUNTIME&lt;/code&gt; in Vim display the value of &lt;code&gt;$VIMRUNTIME&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open the file and locate the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Add special emphasis on some regions. Thanks to Rory Hunter &amp;lt;roryh@dcs.ed.ac.uk&amp;gt; for these ideas.&#xA;syn region docbkRegion start=&quot;&amp;lt;emphasis&amp;gt;&quot;lc=10 end=&quot;&amp;lt;/emphasis&amp;gt;&quot;me=e-11 contains=xmlRegion,xmlEntity,sgmlRegion,sgmlEntity keepend&#xA;syn region docbkTitle  start=&quot;&amp;lt;title&amp;gt;&quot;lc=7     end=&quot;&amp;lt;/title&amp;gt;&quot;me=e-8 contains=xmlRegion,xmlEntity,sgmlRegion,sgmlEntity keepend&#xA;syn region docbkRemark start=&quot;&amp;lt;remark&amp;gt;&quot;lc=8    end=&quot;&amp;lt;/remark&amp;gt;&quot;me=e-9    contains=xmlRegion,xmlEntity,sgmlRegion,sgmlEntity keepend&#xA;syn region docbkRemark start=&quot;&amp;lt;comment&amp;gt;&quot;lc=9  end=&quot;&amp;lt;/comment&amp;gt;&quot;me=e-10   contains=xmlRegion,xmlEntity,sgmlRegion,sgmlEntity keepend&#xA;syn region docbkCite   start=&quot;&amp;lt;citation&amp;gt;&quot;lc=10 end=&quot;&amp;lt;/citation&amp;gt;&quot;me=e-11 contains=xmlRegion,xmlEntity,sgmlRegion,sgmlEntity keepend&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Than add &lt;code&gt;,@spell&lt;/code&gt; behind &lt;code&gt;sgmlEntity&lt;/code&gt;. So this lines look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Add special emphasis on some regions. Thanks to Rory Hunter &amp;lt;roryh@dcs.ed.ac.uk&amp;gt; for these ideas.&#xA;syn region docbkRegion start=&quot;&amp;lt;emphasis&amp;gt;&quot;lc=10 end=&quot;&amp;lt;/emphasis&amp;gt;&quot;me=e-11 contains=xmlRegion,xmlEntity,sgmlRegion,sgmlEntity,@spell keepend&#xA;syn region docbkTitle  start=&quot;&amp;lt;title&amp;gt;&quot;lc=7     end=&quot;&amp;lt;/title&amp;gt;&quot;me=e-8 contains=xmlRegion,xmlEntity,sgmlRegion,sgmlEntity,@spell keepend&#xA;syn region docbkRemark start=&quot;&amp;lt;remark&amp;gt;&quot;lc=8    end=&quot;&amp;lt;/remark&amp;gt;&quot;me=e-9    contains=xmlRegion,xmlEntity,sgmlRegion,sgmlEntity,@spell keepend&#xA;syn region docbkRemark start=&quot;&amp;lt;comment&amp;gt;&quot;lc=9  end=&quot;&amp;lt;/comment&amp;gt;&quot;me=e-10   contains=xmlRegion,xmlEntity,sgmlRegion,sgmlEntity,@spell keepend&#xA;syn region docbkCite   start=&quot;&amp;lt;citation&amp;gt;&quot;lc=10 end=&quot;&amp;lt;/citation&amp;gt;&quot;me=e-11 contains=xmlRegion,xmlEntity,sgmlRegion,sgmlEntity,@spell keepend&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-05-21T08:54:14.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20045" PostTypeId="1" AcceptedAnswerId="20047" CreationDate="2019-05-21T09:16:06.073" Score="1" ViewCount="330" Body="&lt;p&gt;My problem is rather simple : I use a macro to wrap my current visual selection with some text (&lt;code&gt;\verb;&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt;, in fact).&#xA;The current macro I use is &lt;code&gt;:s#\%V.*\%V#\\verb;\0;&lt;/code&gt;. It works, but suffers from one problem : subsitutions always jump at the beginning of the line the cursor is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to keep my cursor where it is to continue editing right where I did the subsitution or, alternatively, jump at the beginning/end of the substituted text. Is such a thing possible ? I've had a quick look at the &lt;code&gt;substitute&lt;/code&gt; help, but there doesn't seem to be such a flag. I am not sure where to look for a global toggle of this behavior, either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If possible, I would like to be able to keep this behavior for this macro only, however it is not too important and having a global toggle for this behavior would work, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks for your help !&lt;/p&gt;&#xA;" OwnerDisplayName="user22210" LastActivityDate="2019-05-21T13:12:56.460" Title="Substituting without jumping" Tags="|substitute|jump|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20046" PostTypeId="2" ParentId="20045" CreationDate="2019-05-21T11:04:48.003" Score="2" Body="&lt;p&gt;Custom operator would be a much better choice than a map, as you can use it with &lt;code&gt;motion&lt;/code&gt;, it's very flexible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lots of people use surround operator provided by &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;tpope/vim-surround&lt;/a&gt;, it's bound to &lt;code&gt;ys&lt;/code&gt; in normal mode and &lt;code&gt;S&lt;/code&gt; in visual mode. If you want to surround something with asymmetric text, you can customize it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:surround_{char2nr('v')} = &quot;\\verb;\r;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\r&lt;/code&gt; is used to separate left and right text. change &lt;code&gt;'v'&lt;/code&gt; to whatever key you like. &lt;code&gt;ys{motion}v&lt;/code&gt; will surround target with &lt;code&gt;\vert;&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt;. Your cursor will be placed at 1st character of &lt;code&gt;left&lt;/code&gt; text.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h curly-braces-names&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-21T13:12:56.460" LastActivityDate="2019-05-21T13:12:56.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20047" PostTypeId="2" ParentId="20045" CreationDate="2019-05-21T12:16:01.433" Score="1" Body="&lt;p&gt;There's a much simpler solution to your specific problem of surrounding the current selection with &lt;code&gt;\view;&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt; delimiters. Type:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;;&lt;/kbd&gt;&lt;kbd&gt;;&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;c&lt;/kbd&gt; &amp;mdash; change the visual selection: this deletes the text and enters insert mode. Crucially, it also stores the deleted text in the unnamed register,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;;&lt;/kbd&gt;&lt;kbd&gt;;&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; &amp;mdash; enter your delimiters and exit insert mode,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;P&lt;/kbd&gt; &amp;mdash; paste the previously deleted text just before the ending &lt;code&gt;;&lt;/code&gt; delimiter.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-05-21T12:16:01.433" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20048" PostTypeId="1" AcceptedAnswerId="20049" CreationDate="2019-05-21T14:48:50.083" Score="0" ViewCount="315" Body="&lt;p&gt;For practicing in &lt;code&gt;vim&lt;/code&gt; I made:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ man bash &amp;gt; PracticeFile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but upon setting up line numbers, using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the formatting got messed up, so that letters at the end of line are closer to number than the numbers are to remaining of text.&#xA;Is there any way to make line number not interfere with the formatting of the text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: A screenshot&#xA;&lt;a href=&quot;https://i.stack.imgur.com/3eOkz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3eOkz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22347" LastEditorUserId="22347" LastEditDate="2019-05-21T15:14:53.090" LastActivityDate="2019-05-21T15:15:35.810" Title="lines numbering and formatting" Tags="|line-numbers|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20049" PostTypeId="2" ParentId="20048" CreationDate="2019-05-21T15:15:35.810" Score="1" Body="&lt;p&gt;Your lines are just wrapped. To stay in the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want them wrapped, run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nowrap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information, look at:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help wrap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-05-21T15:15:35.810" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20050" PostTypeId="1" CreationDate="2019-05-21T19:11:41.937" Score="4" ViewCount="1361" Body="&lt;p&gt;I always have at least two directories in my projects:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;One with information about the projects: info.txt, log.txt&lt;/li&gt;&#xA;&lt;li&gt;One with code&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And every project has a name. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How to group and jump efficiently between those directories?&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How to save those multiple folders in my session?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other editors do this task natively, like sublimetext:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PXoj5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PXoj5.png&quot; alt=&quot;Sublime Text&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't know how to quickly switch from log.txt in one directory to package.json in another one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having both directories together wouldn't make sense, since one directory goes into a git repository and the other one don't&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do you do it?&lt;/strong&gt; &lt;/p&gt;&#xA;" OwnerUserId="22353" LastEditorUserId="5298" LastEditDate="2019-05-22T22:20:50.603" LastActivityDate="2019-05-23T16:00:19.270" Title="How to handle multiple directories in vim?" Tags="|working-directory|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20051" PostTypeId="2" ParentId="20050" CreationDate="2019-05-21T20:16:11.270" Score="1" Body="&lt;p&gt;If you open vim with your two files (&lt;code&gt;vim path/to/log.txt path/to/package.json&lt;/code&gt;), each file is open in a &lt;code&gt;buffer&lt;/code&gt;. You can switch from buffers to buffers in different ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:bnext&lt;/code&gt; and &lt;code&gt;:bprevious&lt;/code&gt; (to go to the.... next and previous buffers)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:buffer n&lt;/code&gt; where &lt;code&gt;n&lt;/code&gt; is a number, each buffer has a number, you can see them with &lt;code&gt;:buffers&lt;/code&gt; (For these I have two mappings: &lt;code&gt;&amp;lt;space&amp;gt;a&lt;/code&gt; for previous and &lt;code&gt;&amp;lt;space&amp;gt;s&lt;/code&gt; for next, to easily go from buffer to buffer)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I invite you to read:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help buffers&lt;/code&gt; to be more familiar with the concept of buffers, windows and tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the directories, I'd suggest to start your vim instance from the root directory of your project and work from there.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-05-21T20:16:11.270" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20052" PostTypeId="1" AcceptedAnswerId="20054" CreationDate="2019-05-22T02:39:06.947" Score="1" ViewCount="232" Body="&lt;p&gt;I'm coding a lot in &lt;code&gt;go&lt;/code&gt; these days and one pattern I use often is iterating over slices and would like to use a snippet for this. There are generic for loop snippets that work well, but I'd like to take it a step forward. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The below is my expected behavior of the snippet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine there's a slice (could be an array/list in other languages) of name &lt;code&gt;apples&lt;/code&gt;. Now when i type &lt;code&gt;apples.iter&lt;/code&gt; followed by the expand trigger(Tab in my config) it should expand to the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for _, apple := range apples {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;stripping the &lt;code&gt;s&lt;/code&gt; from the list name is doable using python interpolation. But, I'm not sure on what should be set as the snippet expand word when defining my custom snippet. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My little research makes me believe, some kind of regular expression could be used, but didn't find any useful examples yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this be done, using &lt;code&gt;ultisnips&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know we could always use a regular snippet, expand and then type &lt;code&gt;apples&lt;/code&gt;. But the &lt;code&gt;.iter&lt;/code&gt; would feel more natural (at least to me) and can be extended to other use-cases like &lt;code&gt;.isnull&lt;/code&gt;, &lt;code&gt;.isempty&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S: I'm on the latest version of &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;ultisnips&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="19338" LastActivityDate="2019-05-22T09:27:28.533" Title="How do I use a previous word in my snippet?" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20053" PostTypeId="1" CreationDate="2019-05-22T03:09:36.920" Score="1" ViewCount="50" Body="&lt;p&gt;Is there a way I can remove the blue warnings that appear when editing a file from a zip folder in vim? Is there some setting I can apply in the vimrc file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/86N5C.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/86N5C.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry, they are not really warnings but info about the location of the particular file in the zip folder&lt;/p&gt;&#xA;" OwnerUserId="22359" LastEditorUserId="22359" LastEditDate="2019-05-22T04:21:29.317" LastActivityDate="2019-05-22T04:21:29.317" Title="blue warning suppression, zip folder" Tags="|vimrc|vimscript|" AnswerCount="0" CommentCount="7" ClosedDate="2019-05-23T12:27:53.310" ContentLicense="CC BY-SA 4.0" />
  <row Id="20054" PostTypeId="2" ParentId="20052" CreationDate="2019-05-22T09:27:28.533" Score="1" Body="&lt;pre&gt;&lt;code&gt;snippet '(\b\w+\b)\.iter' &quot;loop list&quot; r&#xA;for _, ${1:`!p snip.rv = match.group(1)[:-1]`} := range `!p snip.rv = match.group(1)` {&#xA;    ${0}&#xA;}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add trailing &lt;code&gt;r&lt;/code&gt; to use regular expression style trigger_word. &lt;code&gt;(\b\w+\b)\.iter&lt;/code&gt; matches &lt;code&gt;apples.iter&lt;/code&gt;. &lt;code&gt;match&lt;/code&gt; is returned value of the match of the regular expression. &lt;code&gt;match.group(1)&lt;/code&gt; is list name.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h UltiSnips-python&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-05-22T09:27:28.533" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20055" PostTypeId="1" CreationDate="2019-05-22T09:59:31.017" Score="0" ViewCount="127" Body="&lt;p&gt;When editing html, vim applies different rules when inside certain tags (like script/pre/style). I want to have the normal html rules when inside a script tag (using handlebars, and I don't write any javascript in my html.). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there in a vim any way to disable this for the script tag and make it behave like a normal tag, so that I can get normal/html indentation rules inside a script tag. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found something in ft-html-indent, but that only applies to indentation level of the first line. The indentation rules are not changed. &lt;/p&gt;&#xA;" OwnerUserId="18386" LastActivityDate="2019-05-22T09:59:31.017" Title="vim disable behavior special tags (eg script)" Tags="|indentation|filetype-html|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20056" PostTypeId="1" CreationDate="2019-05-22T12:59:52.530" Score="0" ViewCount="48" Body="&lt;p&gt;I am not happy with the behavior of the &lt;code&gt;indent/html.vim&lt;/code&gt; file, so I made a custom one in &lt;code&gt;~/.vim/indent/html.vim&lt;/code&gt;. However, &lt;code&gt;vim -V2&lt;/code&gt; still revealed to me that the &lt;code&gt;/usr/share/vim/vim80/indent/html.vim&lt;/code&gt; is still sourced. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I prevent the latter from being sourced? I don't really want to remove that file manually and I am afraid I will than have to do that every time I update my system. &lt;/p&gt;&#xA;" OwnerUserId="18386" LastActivityDate="2019-05-22T12:59:52.530" Title="How to prevent certain files from being sourced" Tags="|startup|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20057" PostTypeId="1" AcceptedAnswerId="20225" CreationDate="2019-05-22T15:57:34.307" Score="1" ViewCount="982" Body="&lt;p&gt;I'm currently using &lt;code&gt;ALE&lt;/code&gt; (recently upgraded to this from &lt;code&gt;syntastic&lt;/code&gt;) and &lt;code&gt;YCM&lt;/code&gt; for code completion, highlighting syntax errors on-the-fly (rather than just at save time, like with &lt;code&gt;syntastic&lt;/code&gt;), and it's working great. However, I'd like to integrate more advanced &lt;code&gt;lint&lt;/code&gt;ing beyond syntax errors and PEP8 compliance. For example, I'd like obvious coding mistakes like so to be hightlighted/announced:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Beginning of .py file.&#xA;a = b # Should error-out, warning that `b` has not yet been defined.&#xA;a = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are there any advanced linters for Python (and, optionally, C, C++, and go) that can be used to point out simple/obvious semantic errors either on-the-fly (i.e. via &lt;code&gt;ALE&lt;/code&gt;) or whenever the file is saved (like with &lt;code&gt;syntastic&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm currently using &lt;code&gt;vim&lt;/code&gt; from &lt;code&gt;git&lt;/code&gt; on &lt;code&gt;master&lt;/code&gt; on Ubuntu 18.04 LTS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="14282" LastEditorUserId="51" LastEditDate="2021-01-27T03:09:49.273" LastActivityDate="2021-01-27T03:09:49.273" Title="Python semantic linting" Tags="|plugin-you-complete-me|plugin-ale|" AnswerCount="1" CommentCount="2" ClosedDate="2019-06-06T06:47:17.120" ContentLicense="CC BY-SA 4.0" />
  <row Id="20058" PostTypeId="1" CreationDate="2019-05-22T16:05:19.523" Score="0" ViewCount="48" Body="&lt;p&gt;As I understand, the default cursor looks like this: ▉ block. Currently I have these related settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guicursor=c-n-i-v:ver25-blinkoff0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ver25&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;makes the cursor look and behave as if only right side of primary cursor form. So this commands mapping does not work (but the button 'Paste' in UI in GVIM works well though):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;C-v&amp;gt; &amp;lt;Esc&amp;gt;&quot;+gPa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need to leave only left side of it, I mean it is necessary that pasting occurs alltime only from left-to-right direction.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;warning: gvim-8.1.1186-1 is up to date&#xA;5.1.3-arch1-1-ARCH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22368" LastEditorUserId="1841" LastEditDate="2019-05-22T16:24:00.657" LastActivityDate="2019-05-22T16:24:00.657" Title="Quick paste via single keybind" Tags="|gvim|cut-copy-paste|linux|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20059" PostTypeId="1" CreationDate="2019-05-22T18:36:31.560" Score="0" ViewCount="181" Body="&lt;p&gt;I love the plugin &lt;a href=&quot;https://github.com/fadein/vim-FIGlet&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-FIGlet&lt;/a&gt; but I every time when I run &lt;code&gt;:FIGlet ...&lt;/code&gt;, it always produces a text shape of &lt;code&gt;-w76--&lt;/code&gt; right after. For example, this is the output of &lt;code&gt;:FIGlet demo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     _                                        _____ __                  &#xA;  __| | ___ _ __ ___   ___        __      __ |___  / /_                 &#xA; / _` |/ _ \ '_ ` _ \ / _ \   ____\ \ /\ / /    / / '_ \   _____ _____  &#xA;| (_| |  __/ | | | | | (_) | |_____\ V  V /    / /| (_) | |_____|_____| &#xA; \__,_|\___|_| |_| |_|\___/         \_/\_/    /_/  \___/                &#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a solution for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="21891" LastActivityDate="2019-06-22T02:00:31.350" Title="vim FIGlet question: &quot;-w76--&quot; after every output" Tags="|vimscript|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20060" PostTypeId="1" CreationDate="2019-05-22T19:34:29.273" Score="3" ViewCount="1124" Body="&lt;p&gt;Is there a vim adaptation (plugin) for the Spanish keyboard?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is one for the &lt;a href=&quot;https://github.com/powerman/vim-plugin-ruscmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;Russian language&lt;/a&gt;, for instance. Of course, Russian is much more troublesome, because you have to remap virtually every key; Spanish is almost QWERTY, but not really. Periphery is quite different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made some research; nada. Perhaps, I just missed something.&lt;/p&gt;&#xA;" OwnerUserId="21503" LastActivityDate="2020-06-16T12:06:55.630" Title="Vim and Spanish" Tags="|keyboard-layout|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20061" PostTypeId="2" ParentId="20059" CreationDate="2019-05-22T22:16:45.993" Score="1" Body="&lt;p&gt;I ended up using &lt;code&gt;:r !figlet demo&lt;/code&gt; instead of that plugin, which works just as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     _                      &#xA;  __| | ___ _ __ ___   ___  &#xA; / _` |/ _ \ '_ ` _ \ / _ \ &#xA;| (_| |  __/ | | | | | (_) |&#xA; \__,_|\___|_| |_| |_|\___/ &#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21891" LastEditorUserId="51" LastEditDate="2019-05-23T01:55:43.167" LastActivityDate="2019-05-23T01:55:43.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20062" PostTypeId="1" CreationDate="2019-05-23T00:53:22.520" Score="0" ViewCount="335" Body="&lt;p&gt;I have a document that contains lines like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;![My title](/path/to/image.jpg)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the format for images in Markdown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have constructed a regular expression which I believe should be able to find the image tags:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!\[(.*)\]\((.+)\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I try the command &lt;code&gt;/!\[(.*)\]\((.+)\)&lt;/code&gt;, I get &lt;code&gt;E486: Pattern not found: !\[(.*)\]\((.+)\)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Motivation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I am trying to do this to change how images are presented in my &lt;a href=&quot;https://gohugo.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hugo&lt;/a&gt; static site. I want to be able to search and replace everywhere in a file with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/!\[(.*)\]\((.+)\)/{{&amp;lt; figure alt=&quot;\1&quot; src=&quot;\2&quot; &amp;gt;}}/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it matters, I'm using Vim version 8.0.1283.&lt;/p&gt;&#xA;" OwnerUserId="22376" LastActivityDate="2019-06-28T14:52:00.273" Title="Finding Markdown image tags with regular expressions (E486)" Tags="|regular-expression|filetype-markdown|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20063" PostTypeId="1" CreationDate="2019-05-23T03:29:15.860" Score="1" ViewCount="30" Body="&lt;p&gt;In the vim-gtk version of evim, selecting text and then beginning typing produces the normal WYSIWYG result of the first character typed deleting the selection and replacing it with that character (which seems to be stored internally as two separate actions, judging by &quot;undo&quot; results). Or rather, it does so for most characters, including lower-case &quot;q&quot; and capital &quot;S&quot; (just the particular characters I tested trying to narrow this down).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, however, the character typed is a capital &quot;Q&quot;, then it instead leaves the selection intact, but splits the current line (if it is over 79 characters) between words in order to produce a series of lines no longer than 79 characters in length, all whitespace-indented to the same level as the current line. This happens regardless of whether the capital is induced by holding down shift, or by having pressed caps-lock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typing a Q without text being selected works normally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is going on?&lt;/p&gt;&#xA;" OwnerUserId="22377" LastEditorUserId="51" LastEditDate="2019-05-23T04:20:22.717" LastActivityDate="2019-05-23T04:20:22.717" Title="Evim: Typing to delete and replace selected text instead reformats the current line if the letter typed is Q (vim-gtk, debian)" Tags="|key-bindings|evim|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20066" PostTypeId="1" CreationDate="2019-05-23T05:09:19.767" Score="2" ViewCount="444" Body="&lt;p&gt;I've looked around in &lt;code&gt;:help V&lt;/code&gt; but haven't found anything of this sort, but was wondering if there's a function I can call from vimscript that would visually select a region based on (row, column) coordinate pairs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I could call it with &lt;code&gt;(1,1),(2,3)&lt;/code&gt; to visually select the rectangle with the top left corner at row 1, column 1, and bottom right corner at row 2, column 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does such a function exist?&lt;/p&gt;&#xA;" OwnerUserId="1750" LastActivityDate="2021-03-24T10:52:15.687" Title="Is it possible to perform a visual block selection programmatically using line and column numbers?" Tags="|vimscript|visual-block|" AnswerCount="3" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20067" PostTypeId="2" ParentId="11879" CreationDate="2019-05-23T06:12:14.927" Score="18" Body="&lt;h1&gt;What if you want to move everything?&lt;/h1&gt;&#xA;&lt;p&gt;Although the answers here are correct, they miss something. The OP's question didn't ask about how to change everything, just &lt;code&gt;.vimrc&lt;/code&gt; and &lt;code&gt;.viminfo&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then to achieve this we need special attention to the &lt;code&gt;autoload&lt;/code&gt; folder and to the various plugins folders.&lt;/p&gt;&#xA;&lt;p&gt;I wanted to move all &lt;code&gt;vim&lt;/code&gt; configurations to the more (now) standard directory &lt;code&gt;.config&lt;/code&gt; that is supposed to be used by all applications, even than some of them do not use it and pollute the HOME folder.&lt;/p&gt;&#xA;&lt;p&gt;To be able to move all stuff vim needs to &lt;code&gt;.config/vim&lt;/code&gt;, you need to make the following changes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;on your &lt;code&gt;~/.bashrc&lt;/code&gt;, add: &lt;code&gt;export VIMINIT=&amp;quot;source ~/.config/vim/vimrc&amp;quot;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is to instruct &lt;code&gt;vim&lt;/code&gt; where to find your new &lt;code&gt;vimrc&lt;/code&gt; configuration file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;on your &lt;code&gt;~/.config/vim/vimrc&lt;/code&gt; file, &lt;strong&gt;before&lt;/strong&gt; your plugin manager, set the &lt;code&gt;autoload&lt;/code&gt; directory adding: &lt;code&gt;set runtimepath+=~/.config/vim,~/.config/vim/after&lt;/code&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;This will instruct &lt;code&gt;vim&lt;/code&gt; to run files and scripts found in those paths. The current &lt;code&gt;runtimepath&lt;/code&gt; can be seen with the command &lt;code&gt;set runtimepath?&lt;/code&gt; and it will probably show something like &lt;code&gt;~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after&lt;/code&gt;. You need to add the new folders in that list, without compromising the old folders, as they may have lots of default scripts. You don't need &lt;code&gt;~/.vim&lt;/code&gt; and &lt;code&gt;~/.vim/after&lt;/code&gt;, as they don't exist, but no harm letting the path as is, and just add what you need.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Edited: In case your spell checker can't find the path, it is because the first directory in the list &lt;code&gt;runtimepath&lt;/code&gt; is important and yours is probably out of order (you can check with &lt;code&gt;:set runtimepath?&lt;/code&gt;). In this case you need to enforce the order by using the following 3 lines instead of the above:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let rtp=&amp;amp;runtimepath&#xA;set runtimepath=~/.config/vim&#xA;let &amp;amp;runtimepath.=','.rtp.',~/.config/vim/after'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;also on your &lt;code&gt;vimrc&lt;/code&gt; file, add: &lt;code&gt;set viminfo+=n~/.config/vim/viminfo&lt;/code&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This will tell &lt;code&gt;vim&lt;/code&gt; to write the old &lt;code&gt;~/.viminfo&lt;/code&gt; file in the new location, now without the prefixed dot.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Almost done. Lets talk about plugins now, with, of course, a great plugin manager. If you never tried it, it is time to free yourself from the plugin madness and let a manager do the job.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you don't have one installed, use the following lines in your &lt;code&gt;~/.config/vim/vimrc&lt;/code&gt; file to download and auto-install it:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;    if empty(glob('~/.config/vim/autoload/plug.vim'))&#xA;       silent !curl -fLo ~/.config/vim/autoload/plug.vim --create-dirs&#xA;         \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;       autocmd VimEnter * PlugInstall --sync | source $MYVIMRC&#xA;    endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will download and install your plugin manager. After that, the following lines will download and install a plugin of your choice (examplified with &lt;code&gt;drbeco/vimtemplates&lt;/code&gt; and &lt;code&gt;ajh16/VimCompleteMe&lt;/code&gt; plugins. You can add more as you wish.):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.config/vim/plugged')&#xA;Plug 'drbeco/vimtemplates'&#xA;Plug 'ajh17/VimCompletesMe'&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This call will create folders like &lt;code&gt;~/.config/vim/plugged/vimtemplates&lt;/code&gt; and &lt;code&gt;~/.config/vim/plugged/VimCompletesMe&lt;/code&gt;, and so on, for each plugin.&lt;/p&gt;&#xA;&lt;p&gt;So now, even the plugins are all organized inside &lt;code&gt;~/.config/vim&lt;/code&gt;, and that really cleans the &lt;code&gt;HOME&lt;/code&gt; directory.&lt;/p&gt;&#xA;&lt;h1&gt;Bonus: swap, backup and undo files&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Move also &lt;code&gt;swapfiles&lt;/code&gt; adding to your now &lt;code&gt;~/.config/vim/vimrc&lt;/code&gt; file: &lt;code&gt;set directory=~/.config/vim/swap//,.,~/tmp,/var/tmp,/tmp&lt;/code&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You need to create the directory with: &lt;code&gt;mkdir ~/.config/vim/swap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;You can also avoid them by using: &lt;code&gt;set noswapfile&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Move the backup files to a central location adding to your &lt;code&gt;vimrc&lt;/code&gt; file: &lt;code&gt;set backupdir=~/.config/vim/backup//,.,~/tmp,~/&lt;/code&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You need to create the directory with: &lt;code&gt;mkdir ~/.config/vim/backup&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Or just avoid them by using: &lt;code&gt;set nobackup&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Move the &lt;code&gt;undo&lt;/code&gt; files adding to your &lt;code&gt;vimrc&lt;/code&gt; the line: &lt;code&gt;set undodir=~/.config/vim/undo//,.&lt;/code&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You need to create the directory with: &lt;code&gt;mkdir ~/.config/vim/undo&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Or avoid them using: &lt;code&gt;set noundofile&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note: the &lt;code&gt;//&lt;/code&gt; at the end instructs &lt;code&gt;vim&lt;/code&gt; to save also the directory path in the filename. Something like &lt;code&gt;home%documents%letter2mama.tex.swp&lt;/code&gt; will be used.&lt;/p&gt;&#xA;&lt;p&gt;Note 2: edited explanation about &lt;code&gt;runtimepath&lt;/code&gt; as the spell checker may get confused otherwise.&lt;/p&gt;&#xA;&lt;h1&gt;Extra bonus: some plugins may need help&lt;/h1&gt;&#xA;&lt;p&gt;If you use some plugins that insist to add files to &lt;code&gt;~/.vim&lt;/code&gt;, you may need to read the doc for each one and come up with a solution. For example:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimawesome.com/plugin/coc-nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Coc&lt;/a&gt; - For &lt;code&gt;VimPlug&lt;/code&gt; manager, install with &lt;code&gt;Plug 'neoclide/coc.nvim', {'branch': 'release'}&lt;/code&gt;; the problem is that, without proper setup it attempts to read coc-settings.json from &lt;code&gt;~/.vim&lt;/code&gt;. There are two solutions:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Add &lt;code&gt;export VIMCONFIG=&amp;quot;$HOME/.config/vim&amp;quot;&lt;/code&gt; to your &lt;code&gt;/etc/profile&lt;/code&gt; (or &lt;code&gt;zprofile&lt;/code&gt; for zsh); or&lt;/li&gt;&#xA;&lt;li&gt;Add &lt;code&gt;g:coc_config_home=&amp;quot;~/.config/vim&amp;quot;&lt;/code&gt; to your &lt;code&gt;/etc/vim/vimrc.local&lt;/code&gt; config file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13368" LastEditorUserId="13368" LastEditDate="2024-02-13T20:59:53.090" LastActivityDate="2024-02-13T20:59:53.090" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20068" PostTypeId="2" ParentId="20060" CreationDate="2019-05-23T09:05:28.597" Score="1" Body="&lt;p&gt;The way to do make vim use a different keyboard layout is by setting the&#xA;option &lt;code&gt;keymap&lt;/code&gt; in your &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info checkout &lt;code&gt;:h keymap&lt;/code&gt; inside vim.&lt;/p&gt;&#xA;" OwnerUserId="2689" LastActivityDate="2019-05-23T09:05:28.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20070" PostTypeId="1" CreationDate="2019-05-23T11:37:07.057" Score="0" ViewCount="286" Body="&lt;p&gt;I am trying to construct a regex pattern to match characters inside two &lt;code&gt;#&lt;/code&gt; characters. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#abc#bc#cd#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to match &lt;code&gt;abc&lt;/code&gt;, &lt;code&gt;bc&lt;/code&gt; and &lt;code&gt;cd&lt;/code&gt;. The following regex without using magic mode works as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(#\)\@&amp;lt;=.\{-\}\(#\)\@=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I try to use the &lt;code&gt;very magic&lt;/code&gt; mode, I can not make the regex pattern right. Here is what I have come up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v(#)\@&amp;lt;=.{-}(#)\@=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it does not work (matches nothing). Can you point out what is wrong with my regex pattern?&lt;/p&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-05-23T11:37:07.057" Title="can not make this regex pattern work in &quot;very magic&quot; mode" Tags="|regular-expression|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20071" PostTypeId="5" CreationDate="2019-05-23T11:59:27.147" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-05-23T11:59:27.147" LastActivityDate="2019-05-23T11:59:27.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20072" PostTypeId="4" CreationDate="2019-05-23T11:59:27.147" Score="0" Body="Methods and tools for using vim to create and edit diagrams, texts and pictures made entirely by stringing together the printable ASCII characters. " OwnerUserId="14302" LastEditorUserId="14302" LastEditDate="2019-05-23T22:45:54.623" LastActivityDate="2019-05-23T22:45:54.623" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20073" PostTypeId="2" ParentId="20050" CreationDate="2019-05-23T16:00:19.270" Score="2" Body="&lt;p&gt;One handy keymapping I found years ago and have had in my vimrc ever since is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap %% &amp;lt;C-R&amp;gt;=fnameescape(expand(&quot;%:p:h&quot;).&quot;/&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's a command-line mode mapping that expands &lt;code&gt;%%&lt;/code&gt; to the directory of the current file, complete with any necessary escapes for spaces or other funny characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Combine this with &lt;a href=&quot;https://vi.stackexchange.com/a/20051/2736&quot;&gt;padawin's &lt;code&gt;buffer&lt;/code&gt; suggestions&lt;/a&gt; and you've got fairly quick access to any directory you have an open file in via &lt;code&gt;:cd %%&lt;/code&gt; or &lt;code&gt;:e %%new_file_to_open&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're persisting your open buffers in a session file, then this automatically comes for free.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2019-05-23T16:00:19.270" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20074" PostTypeId="1" CreationDate="2019-05-23T16:14:07.677" Score="1" ViewCount="338" Body="&lt;p&gt;I am attempting to map &lt;code&gt;,&amp;lt;tab&amp;gt;&lt;/code&gt; in insert mode to first attempt omnicompletion then fall back to &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-p&amp;gt;&lt;/code&gt; completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used &lt;a href=&quot;https://vim.fandom.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; reference to successfully send a string as fallback, but I cannot get completion to work on fallback.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attempted mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; ,&amp;lt;tab&amp;gt; pumvisible() ? &quot;&amp;lt;c-p&amp;gt;&quot; : &#xA;    \'&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&amp;lt;c-r&amp;gt;=pumvisible() ? &quot;\&amp;lt;lt&amp;gt;down&amp;gt;&quot; : &quot;Print&quot;&amp;lt;cr&amp;gt;' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This successfully prints 'Print' if omnicomplete detects no matches&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; ,&amp;lt;tab&amp;gt; pumvisible() ? &quot;&amp;lt;c-p&amp;gt;&quot; : &#xA;    \'&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&amp;lt;c-r&amp;gt;=pumvisible() ? &quot;\&amp;lt;lt&amp;gt;down&amp;gt;&quot; : &quot;&amp;lt;c-x&amp;gt;&quot;&amp;lt;cr&amp;gt;' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This enters completion mode (c-x mode) if omnicomplete detects no matches&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; ,&amp;lt;tab&amp;gt; pumvisible() ? &quot;&amp;lt;c-p&amp;gt;&quot; : &#xA;    \'&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&amp;lt;c-r&amp;gt;=pumvisible() ? &quot;\&amp;lt;lt&amp;gt;down&amp;gt;&quot; : &quot;&amp;lt;c-x&amp;gt;&amp;lt;c-p&amp;gt;&quot;&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This prints &lt;code&gt;\&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&amp;lt;c-r&amp;gt;=pumvisible() ? &quot;\&amp;lt;lt&amp;gt;down&amp;gt;&quot; : &quot;&amp;lt;c-x&amp;gt;&amp;lt;c-p&amp;gt;&quot;&amp;lt;cr&amp;gt;&lt;/code&gt; into the vim window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong that causes vim to interpret these mappings the way it is? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: These mappings function correctly in the case that a popup already exists or when omnicomplete detects a completion.&lt;br&gt;&#xA;Also, I have attempted escaping (prefixing with &lt;code&gt;\&lt;/code&gt;) all combinations of the &lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt; commands, but none of them were successful.&lt;/p&gt;&#xA;" OwnerUserId="22388" LastEditorUserId="10604" LastEditDate="2019-05-23T19:33:42.963" LastActivityDate="2019-05-23T19:33:42.963" Title="Mapping to have completion attempt one mode and fall back to another if no completions found" Tags="|key-bindings|ins-completion|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20075" PostTypeId="2" ParentId="20062" CreationDate="2019-05-23T18:46:23.333" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/1631687/8033766&quot;&gt;Vim doesn't require escaping of parentheses by default&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Christian says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[I]f you want to capture a group, you need to use &lt;code&gt;\(\)&lt;/code&gt; instead of &lt;code&gt;()&lt;/code&gt; and for capturing at least one of the previous items, you need to use &lt;code&gt;\+&lt;/code&gt; instead of &lt;code&gt;+&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Using this modification, my regular expression becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!\[\(.*\)\](\(.\+\))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The parentheses which were part of capture groups have been escaped, as has the &lt;code&gt;+&lt;/code&gt;, and the parentheses which were literals have been unescaped. This new expression works as intended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My full search and replace is now&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/!\[\(.*\)\](\(.\+\))/{{&amp;lt; figure alt=&quot;\1&quot; src=&quot;\2&quot; &amp;gt;}}/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22376" LastActivityDate="2019-05-23T18:46:23.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20076" PostTypeId="1" CreationDate="2019-05-23T19:03:16.387" Score="1" ViewCount="270" Body="&lt;p&gt;New install of Vim 8.1.1 on Windows 10 64bit. Also running cygwin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a Windows Explorer r-click context menu for a file, the &quot;Edit with Vim&quot; produces a cmd.exe window with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\WINDOWS\system32\cmd.exe /c &amp;lt;symlink&amp;gt;ÿþ/&#xA;The system cannot find the file specified.&#xA;shell returned 1&#xA;Hit any key to close this window...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hit any key and get a Vim alert dialog saying &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:!&amp;lt;symlink&amp;gt;ÿþ&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Clicking ok then continues on to successfully open the file in gVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I select an option to &quot;Edit with existing vim &lt;em&gt;&amp;lt;some already open file&gt;&lt;/em&gt;&quot;, it works fine, opening up the target file in the specified existing Vim window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did find &lt;a href=&quot;https://superuser.com/questions/753537/windows-vim-symlink-config-file-persistent-error&quot;&gt;https://superuser.com/questions/753537/windows-vim-symlink-config-file-persistent-error&lt;/a&gt;. This talks about symlinks to vimrc/gvimrc files, but I case insensitive check of_all_ the files on disk with a name containing &quot;vim&quot; and the only ones with symlinks are for cygwin versions of things like &quot;evim&quot;, &quot;rvim&quot;, etc. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;% for f in $(locate -i vim); do file &quot;$f&quot;; done | grep -i symbolic&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(Note: had to muck w/ $IFS to allow spaces in Windows filenames.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried uninstalling/reinstalling VIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After yet more digging I found (using process explorer on the blocking cmd window) that gvim is actually executing vimrun&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;C:\Program Files (x86)\Vim\vim81\vimrun&quot; C:\WINDOWS\system32\cmd.exe /c ÿþ/&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From this I found that executing gvim.exe from that vim81 folder does the same thing. It's having trouble finding the &lt;code&gt;_vimrc&lt;/code&gt; file. If I specify &lt;code&gt;-u &amp;lt;path to _vimrc&amp;gt;&lt;/code&gt; it works. The default location of _vimrc seems to be &lt;code&gt;...\Vim\&lt;/code&gt;. Just copying _vimrc to &lt;code&gt;...\Vim\vim81\&lt;/code&gt; has no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now the questions maybe become &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to I make _vimrc findable by gvim.exe?&lt;/li&gt;&#xA;&lt;li&gt;Do I need to hack the registry to add &lt;code&gt;-u&lt;/code&gt;? &lt;/li&gt;&#xA;&lt;li&gt;If so where exactly? &lt;code&gt;&quot;...\gvim.exe&quot; &quot;%1&quot;&lt;/code&gt; occurs multiply in the reg&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Been living with this for months now, but would really like to get it figured out. Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="22389" LastEditorUserId="22389" LastEditDate="2019-05-23T23:12:34.117" LastActivityDate="2019-05-24T19:36:38.223" Title="Windows context menu &quot;open with vim&quot; symlink error" Tags="|microsoft-windows|cygwin|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20077" PostTypeId="1" AcceptedAnswerId="20079" CreationDate="2019-05-23T19:28:55.653" Score="5" ViewCount="11003" Body="&lt;p&gt;In text editors like sublime text, atom and notepad++, when you select a word, all matches are highlighted automatically as shown in the following screenshot of my atom editor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sXOsl.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sXOsl.png&quot; alt=&quot;Automatically highlight the word permutation when selected&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;v&lt;/code&gt; and select text in vim but how can I obtain all highlight functionality?&lt;/p&gt;&#xA;" OwnerUserId="22196" LastActivityDate="2021-01-01T04:14:55.360" Title="Automatically highlight all occurrences of the selected text in visual mode" Tags="|highlight|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20078" PostTypeId="1" AcceptedAnswerId="20089" CreationDate="2019-05-23T19:41:02.320" Score="3" ViewCount="169" Body="&lt;p&gt;I'm looking for functionality which may or may not exist. Basically, I'd like to have a location list split at the &lt;em&gt;top&lt;/em&gt; of each writable buffer which shows the last line of each enclosing indentation level. So for the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def some_function(x, y, z):&#xA;    some code&#xA;    some more code&#xA;    even more code&#xA;    if var == 3:&#xA;        do something&#xA;        do another_thi|g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If my cursor were at &lt;code&gt;|&lt;/code&gt;, I would see in this window something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; def some_function(x, y, z):&#xA;&amp;gt;    ...&#xA;&amp;gt;    if var == 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this doesn't exist, could such a plugin even be made for Vim (bear with me; I'm not a real programmer)? It seems like it would be very useful for orienting oneself in one's code after e.g., coming back from the coffee pot.&lt;/p&gt;&#xA;" OwnerUserId="19915" LastEditorUserId="19915" LastEditDate="2019-05-23T22:47:18.637" LastActivityDate="2019-12-18T12:20:12.030" Title="Plugin to show enclosing indentation levels" Tags="|indentation|quickfix|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="20079" PostTypeId="2" ParentId="20077" CreationDate="2019-05-23T19:41:30.840" Score="9" Body="&lt;h1&gt;TL;DR: Combine &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; with &lt;code&gt;hlsearch&lt;/code&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;could&lt;/em&gt; highlight by using &lt;code&gt;match&lt;/code&gt; and &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; via an &lt;code&gt;autocommand&lt;/code&gt; on an event like &lt;code&gt;CursorHold&lt;/code&gt;. But I’m going to show an alternative method.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;*&lt;/code&gt; searches forward for the word under the cursor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;#&lt;/code&gt; searches backward for the word under the cursor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Both have variants (&lt;code&gt;g*&lt;/code&gt;, &lt;code&gt;g#&lt;/code&gt;) that don’t restrict the searches to word-boundaries. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; to navigate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By &lt;code&gt;set&lt;/code&gt;ting &lt;code&gt;hlsearch&lt;/code&gt;, these searches will also highlight matches.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Why do this?&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It uses a vim search instead of arbitrary highlights, so you can actually navigate between matches&lt;/li&gt;&#xA;&lt;li&gt;It uses existing vim machinery and needs little-to-no setup&lt;/li&gt;&#xA;&lt;li&gt;The commands are good to learn anyway (and then you start to like &lt;code&gt;gd&lt;/code&gt;, among others)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Disadvantage&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is does not work for “partial words”: if you visually-select part of a word and hit &lt;code&gt;*&lt;/code&gt;, you won’t get the result you want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One workaround is one of the many visual star plugins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another is to simply yank &lt;code&gt;y&lt;/code&gt; and then search &lt;code&gt;/&amp;lt;C-r&amp;gt;&quot;&amp;lt;CR&amp;gt;&lt;/code&gt; (vim notation: type slash &lt;code&gt;/&lt;/code&gt; to search, then Control-R quote to paste the selected text, then hit enter). &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-05-23T19:41:30.840" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20081" PostTypeId="1" AcceptedAnswerId="20083" CreationDate="2019-05-23T23:37:43.780" Score="0" ViewCount="1353" Body="&lt;p&gt;Consider the following text file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 1 3&#xA;1&#xA;1&#xA;5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One can rank row 1 with the command &lt;code&gt;y$&lt;/code&gt; with the cursor on row 1, column 1.&#xA;However, to yank the first column, the only way I know is to &lt;code&gt;&amp;lt;C-v&amp;gt;3jy&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mostly out of curiosity, is it possible to yank the column &lt;strong&gt;without ever entering visual block mode?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1750" LastActivityDate="2019-06-01T23:56:33.337" Title="Is it possible to yank a column of text in vim without visual block mode?" Tags="|cut-copy-paste|visual-block|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20082" PostTypeId="2" ParentId="20081" CreationDate="2019-05-23T23:52:34.097" Score="1" Body="&lt;p&gt;&lt;code&gt;y&amp;lt;c-v&amp;gt;G&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This yanks to the bottom of the file, forcing block mode.  This only works in some cases, when &lt;code&gt;set nostartofline&lt;/code&gt; and when the last line isn't blank.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, to yank a set number of lines, keeping horizontal position if possible,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;y&amp;lt;c-v&amp;gt;3j&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2019-05-24T01:14:22.887" LastActivityDate="2019-05-24T01:14:22.887" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20083" PostTypeId="2" ParentId="20081" CreationDate="2019-05-24T02:33:00.633" Score="2" Body="&lt;p&gt;You can create a blockwise text object to do this kind of job, if you bound it to &lt;code&gt;ic&lt;/code&gt; , you can copy with &lt;code&gt;yic&lt;/code&gt;, select it with &lt;code&gt;vic&lt;/code&gt;, no count needed. But it's not easy, feel free to skip it and use some existing plugins, forgot the plugin name, you can google it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Text object can be created directly or from a motion. I prefer motion in this case, there has no vertical word style motion in vim, you must create it by yourself. B Layer gives some good idea on how to do it &lt;a href=&quot;https://vi.stackexchange.com/questions/15151/move-to-the-first-last-non-whitespace-character-of-the-column-vertical-w-b-e&quot;&gt;here&lt;/a&gt;. My code is based on his:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vertical E,W,B. it's too much trouble to implement e,w,b.&#xA;function! misc#mo#vertical_motion(motion)&#xA;&#xA;  &quot; changed from https://vi.stackexchange.com/questions/15151/move-to-the-first-last-non-whitespace-character-of-the-column-vertical-w-b-e&#xA;  let curcol = virtcol('.')&#xA;  let nextcol = curcol + 1&#xA;&#xA;  if a:motion ==# 'E'&#xA;&#xA;    &quot; %dv : restrict virtual column&#xA;    &quot; \S.* : start from non-blank character&#xA;    &quot; (\n.*%%&amp;lt;%dv$|\n.*%%%dv\s|%%$)&#xA;    &quot;   \n.*%%&amp;lt;%dv$ : next line that's too short&#xA;    &quot;   \n.*%%%dv\s : next line that's empty in this column&#xA;    &quot;   %%$         : end of file&#xA;    let pattern = printf('\v%%%dv\S.*(\n.*%%&amp;lt;%dv$|\n.*%%%dv\s|%%$)', curcol, nextcol, curcol)&#xA;    let flag = 'W'&#xA;  elseif a:motion == 'B'&#xA;    let pattern = printf('\v^.*(%%&amp;lt;%dv$|%%%dv\s.*)\n.*\zs%%%dv\S', nextcol, curcol, curcol)&#xA;    let flag = 'bW'&#xA;  elseif a:motion == 'W'&#xA;    let pattern = printf('\v^.*(%%&amp;lt;%dv$|%%%dv\s.*)\n.*\zs%%%dv\S', nextcol, curcol, curcol)&#xA;    let flag = 'W'&#xA;  else&#xA;    echohl ErrorMsg | echo 'Not a valid motion: ' . a:motion | echohl None&#xA;  endif&#xA;  call search(pattern, flag)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I bind these motions to sequence starts with &lt;code&gt;,&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ,e :call misc#mo#vertical_motion('E')&amp;lt;cr&amp;gt;&#xA;nnoremap ,w :call misc#mo#vertical_motion('W')&amp;lt;cr&amp;gt;&#xA;nnoremap ,b :call misc#mo#vertical_motion('B')&amp;lt;cr&amp;gt;&#xA;vnoremap ,e :&amp;lt;c-u&amp;gt;exec 'norm! gv' &amp;lt;bar&amp;gt; call misc#mo#vertical_motion('E')&amp;lt;cr&amp;gt;&#xA;vnoremap ,w :&amp;lt;c-u&amp;gt;exec 'norm! gv' &amp;lt;bar&amp;gt; call misc#mo#vertical_motion('W')&amp;lt;cr&amp;gt;&#xA;vnoremap ,b :&amp;lt;c-u&amp;gt;exec 'norm! gv' &amp;lt;bar&amp;gt; call misc#mo#vertical_motion('B')&amp;lt;cr&amp;gt;&#xA;onoremap ,e :normal v,e&amp;lt;cr&amp;gt;&#xA;onoremap ,w :normal v,w&amp;lt;cr&amp;gt;&#xA;onoremap ,b :normal v,b&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After that, it's trivial to create text object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! misc#to#verticalE() abort&#xA;  exec &quot;norm! \&amp;lt;c-v&amp;gt;&quot;&#xA;  call misc#mo#vertical_motion('E')&#xA;endfunction&#xA;&#xA;vnoremap ic :&amp;lt;c-u&amp;gt;call misc#to#verticalE()&amp;lt;cr&amp;gt;&#xA;onoremap ic :normal vic&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-01T23:56:33.337" LastActivityDate="2019-06-01T23:56:33.337" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20084" PostTypeId="2" ParentId="20066" CreationDate="2019-05-24T06:06:23.333" Score="2" Body="&lt;p&gt;There is no direct function available to create a new block-wise selection. However you can work around it the following way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) First you need to set the visual selection type, so that when using &lt;code&gt;gv&lt;/code&gt; the selection will be set correctly. You can simply abort it right afterwards, so e.g. use &lt;code&gt;:exe &quot;:norm! \&amp;lt;c-v&amp;gt;\&amp;lt;esc&amp;gt;&lt;/code&gt;. This sets block-wise selection and aborts it right afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Since patch &lt;a href=&quot;https://github.com/vim/vim/commit/0306ac33a53114113825242d2&quot; rel=&quot;nofollow noreferrer&quot;&gt;7.3.590&lt;/a&gt; the visual marks &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; that define the start and end position of the visual selection are directly settable using &lt;code&gt;setpos()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) After the marks have been set, you can then use &lt;code&gt;gv&lt;/code&gt; to &quot;reselect&quot; the last visual selected area. I have been using this technique in my &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn&quot; rel=&quot;nofollow noreferrer&quot;&gt;NrrwRgn&lt;/a&gt; plugin ever since that patch has been included (&lt;a href=&quot;https://github.com/chrisbra/NrrwRgn/commit/4911ef6438e3ab26051b4635362&quot; rel=&quot;nofollow noreferrer&quot;&gt;commit&lt;/a&gt;) and is has been working well.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-05-24T06:06:23.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20085" PostTypeId="2" ParentId="20066" CreationDate="2019-05-24T07:07:00.867" Score="3" Body="&lt;p&gt;You can do this similarly to how you would do it manually, by using the &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Anormal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:normal&lt;/code&gt;&lt;/a&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:normal! 1G1|^V2G3|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;^V&lt;/code&gt; is a CTRL-V character. You can enter this literally by pressing &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Ctrl-V&lt;/kbd&gt;, but as you’re most likely going to need to build the command as a string anyway so you can use variables for the line/column numbers, using a &lt;a href=&quot;https://vimhelp.org/eval.txt.html#string&quot; rel=&quot;nofollow noreferrer&quot;&gt;string escape sequence&lt;/a&gt; is cleaner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;normal! 1G1|\&amp;lt;C-V&amp;gt;2G3|&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In an actual script, I'd probably break it up over a few lines to make it a bit clearer what you're doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let select_command = line1 . 'G' . column1 . '|'&#xA;let select_command .= &quot;\&amp;lt;C-V&amp;gt;&quot;&#xA;let select_command .= line2 . 'G' . column2 . '|'&#xA;execute 'normal!' select_command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-05-24T09:51:02.887" LastActivityDate="2019-05-24T09:51:02.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20086" PostTypeId="1" CreationDate="2019-05-24T11:14:33.477" Score="1" ViewCount="966" Body="&lt;p&gt;I was trying to append some text to multiple lines in vi on a RHEL 6 system, however I could not get it to work. I press Control + V to get into visual block mode, select the lines I need, but when I press capital A, instead of going into insert mode, it goes back into command mode. I then created two droplets on digital ocean to test this, one CentOS 7 and one Ubuntu, and to my surprise, this worked fine on Ubuntu, but did not on CentOS. So why is that? Is there some option I need to add to my vimrc file or are these functions remapped somehow on RHEL/CentOS? Searching the web did not help very much. &lt;/p&gt;&#xA;" OwnerDisplayName="Cristian Malita" LastEditorUserId="11357" LastEditDate="2019-06-01T01:59:38.947" LastActivityDate="2024-02-18T23:05:00.677" Title="Visual block mode insert/append not working in vim on RHEL/CentOS?" Tags="|visual-mode|insert-mode|normal-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20087" PostTypeId="2" ParentId="20081" CreationDate="2019-05-24T14:15:21.093" Score="0" Body="&lt;p&gt;Since you specifically mentioned that this is out of curiosity, here is a preposterous solution you would never use in real life:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg('&quot;', '') | g/^/call setreg('&quot;', nr2char(strgetchar(getline('.'), 0)), 'ab')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above assumes you want yank all the way down to the bottom of the file. If you just want the first four lines of a longer file, then one solution is to specify a range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setreg('&quot;', '') | 1,4g/^/call setreg('&quot;', nr2char(strgetchar(getline('.'), 0)), 'ab')&#xA;                        ^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you like this, I can think of several other ridiculous solutions to the problem.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-05-24T14:15:21.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20088" PostTypeId="1" AcceptedAnswerId="20124" CreationDate="2019-05-24T14:22:08.623" Score="2" ViewCount="661" Body="&lt;p&gt;I have a shell command which reads from stdin, processes the input, and writes to stdout.  To call it synchronously from vim I can do &lt;code&gt;system('mycommand', data)&lt;/code&gt; where &lt;code&gt;data&lt;/code&gt; is some string my vimscript has prepared.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the equivalent way to pass &lt;code&gt;data&lt;/code&gt; to stdin using &lt;code&gt;job_start()&lt;/code&gt; / &lt;code&gt;jobstart()&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: in this case I'm particularly interested in the answer for neovim.&lt;/p&gt;&#xA;" OwnerUserId="1643" LastEditorUserId="1643" LastEditDate="2019-05-25T08:34:21.870" LastActivityDate="2019-05-27T13:56:22.300" Title="How to pass a string as stdin to a job?" Tags="|external-command|async|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20089" PostTypeId="2" ParentId="20078" CreationDate="2019-05-24T14:45:38.940" Score="2" Body="&lt;p&gt;I was intending to write an answer explaining how you might go about doing this, but when I embarked on doing so I ended up with a prototype implementation instead. Writing code is often more fun than writing documentation, I'm afraid!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ShowContext() abort&#xA;  let items = []&#xA;  let l = line('.')&#xA;  let indent = 1000&#xA;  while l &amp;gt;= 0&#xA;    if indent(l) &amp;lt; indent&#xA;      call add(items, getline(l))&#xA;      let indent = indent(l)&#xA;      if indent == 0&#xA;        break&#xA;      endif&#xA;    endif&#xA;    let l -= 1&#xA;  endwhile&#xA;  lgetexpr reverse(items)&#xA;  above lopen&#xA;  wincmd p&#xA;endfunction&#xA;&#xA;augroup ContextList&#xA;  autocmd!&#xA;  autocmd CursorHold * call ShowContext()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are a lot of rough edges you'll need to file off, but hopefully this shows that your goal is certainly attainable. Let me know in the comments if there's anything in particular you don't understand or struggle with improving, and I'll be happy to explain more.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-05-31T15:11:48.410" LastActivityDate="2019-05-31T15:11:48.410" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20090" PostTypeId="1" CreationDate="2019-05-24T15:02:09.550" Score="2" ViewCount="245" Body="&lt;p&gt;I've added the following to my &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType gitcommit setlocal spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is great, as when I'm editing a got commit message, I now have &lt;code&gt;spell&lt;/code&gt; enabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, our commit style guidelines state that the commit message (the first line, a subject line) should always be lowercase, triggering spell's detection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to express that &lt;code&gt;spellcapcheck&lt;/code&gt; should disable for only the first line fo that scope?&lt;/p&gt;&#xA;" OwnerUserId="22400" LastActivityDate="2019-05-24T17:35:45.790" Title="How can I disable spellcapcheck for the first line of a FileType?" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20091" PostTypeId="1" AcceptedAnswerId="20102" CreationDate="2019-05-24T17:28:23.083" Score="0" ViewCount="44" Body="&lt;p&gt;One can create non-rectangular Visual-Block selections using &lt;code&gt;C-v$&lt;/code&gt; on files with lines of non-equal length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to programmatically determine whether the last Visual Block selection was non-rectangular?&lt;/p&gt;&#xA;" OwnerUserId="1750" LastActivityDate="2019-05-25T02:30:56.573" Title="Is there a way to determine whether the current / last visual block selection is non-rectangular?" Tags="|visual-mode|visual-block|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20092" PostTypeId="2" ParentId="20090" CreationDate="2019-05-24T17:35:45.790" Score="1" Body="&lt;p&gt;You can achieve this by changing the filetype syntax using &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#%3asyn%2dspell&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:syn-spell&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sy[ntax] spell [toplevel | notoplevel | default]&#xA;    This defines where spell checking is to be done for text that is not&#xA;    in a syntax item:&#xA;&#xA;    toplevel:   Text is spell checked.&#xA;    notoplevel: Text is not spell checked.&#xA;    default:    When there is a @Spell cluster no spell checking.&#xA;&#xA;    For text in syntax items use the @Spell and @NoSpell clusters&#xA;    |spell-syntax|.  When there is no @Spell and no @NoSpell cluster then&#xA;    spell checking is done for &quot;default&quot; and &quot;toplevel&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see &lt;code&gt;$VIMRUNTIME/syntax/tex.vim&lt;/code&gt; as an example, similar to what was done &lt;a href=&quot;https://vi.stackexchange.com/q/8091/1405&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it not possible to control only the capitalization. You'll need to disable the entire spell check on the first word of the file.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2019-05-24T17:35:45.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20093" PostTypeId="1" AcceptedAnswerId="20096" CreationDate="2019-05-24T17:52:52.713" Score="1" ViewCount="2342" Body="&lt;p&gt;I ran PlugUpdate recently and somehow all the Ale linter errors started popping up right in the buffer at the end of the line. It used to just put signs on the left side for the problematic line and put all the actual errors in the quickfix and display them in the status bar when cursor is on the line. How do I turn these inline errors off?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are relevant bits and pieces of my init.vim (using neovim)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh', }&#xA;Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }&#xA;Plug 'lighttiger2505/deoplete-vim-lsp'&#xA;Plug 'w0rp/ale'&#xA;&#xA;&quot; language client&#xA;let g:LanguageClient_serverCommands = {&#xA;    \ 'haskell': ['hie', '--lsp'],&#xA;    \ 'c': ['ccls', '--log-file=/tmp/ccls.log'],&#xA;    \ 'cpp': ['ccls', '--log-file=/tmp/ccls.log'],&#xA;    \ 'python': ['pyls', '--log-file=/tmp/pyls.log'],&#xA;    \ }&#xA;&#xA;&quot; deoplete&#xA;let g:deoplete#enable_at_startup = 1&#xA;let g:deoplete_disable_auto_complete=1&#xA;call deoplete#custom#buffer_option('auto_complete', v:false)&#xA;autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif&#xA;inoremap &amp;lt;expr&amp;gt;&amp;lt;tab&amp;gt; pumvisible() ? &quot;\&amp;lt;c-n&amp;gt;&quot; : &quot;\&amp;lt;tab&amp;gt;&quot;&#xA;&#xA;let g:deoplete#sources = {}&#xA;let g:deoplete#sources.cpp = ['LanguageClient']&#xA;let g:deoplete#sources.python = ['LanguageClient']&#xA;let g:deoplete#sources.python3 = ['LanguageClient']&#xA;let g:deoplete#sources.rust = ['LanguageClient']&#xA;let g:deoplete#sources.c = ['LanguageClient']&#xA;let g:deoplete#sources.vim = ['vim']&#xA;&#xA;&quot; ale&#xA;let g:ale_sign_column_always = 0&#xA;let g:ale_emit_conflict_warnings = 0&#xA;let g:ale_lint_on_text_changed = 'never'&#xA;let g:ale_set_loclist = 0&#xA;let g:ale_set_quickfix = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6761" LastEditorUserId="6761" LastEditDate="2019-05-24T19:02:59.447" LastActivityDate="2019-05-24T19:12:13.603" Title="How to get rid of inline linting errors?" Tags="|neovim|plugin-ale|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20094" PostTypeId="1" CreationDate="2019-05-24T18:01:39.973" Score="1" ViewCount="177" Body="&lt;p&gt;I have a git repository that contains my vimrc file and a couple of other utilities, called &lt;code&gt;myvimrcgit&lt;/code&gt;. I then hard link my vimrc to &lt;code&gt;~/.vimrc&lt;/code&gt;, so that they point to the same inodes. Now, when I go to vim and command &lt;code&gt;edit ~/myvimrcgit/vimrc&lt;/code&gt;, the buffer actually loads the &lt;code&gt;~/.vimrc&lt;/code&gt; file. Running &lt;code&gt;:echo expand(&quot;%&quot;)&lt;/code&gt; also yields the filename as &lt;code&gt;~/.vimrc&lt;/code&gt;. This is a problem when I want to use Fugitive to do some git operations while editing my vimrc since Fugitive relies on the filename rather than the current working directory. Calling edit on the original vimrc (&lt;code&gt;edit ~/.vimrc&lt;/code&gt;) yields the normal &lt;code&gt;~/.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any tips on how to disable this functionality and why does vim always resolve filenames this way?&lt;/p&gt;&#xA;" OwnerUserId="21269" LastActivityDate="2019-05-24T18:01:39.973" Title="Vim &quot;Follows&quot; Hard links" Tags="|vimrc|git|plugin-fugitive|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20096" PostTypeId="2" ParentId="20093" CreationDate="2019-05-24T19:12:13.603" Score="5" Body="&lt;p&gt;Found it. Turns out it was not Ale doing it, but rather LanguageClient-neovim. The setting to turn it off is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:LanguageClient_useVirtualText = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6761" LastActivityDate="2019-05-24T19:12:13.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20097" PostTypeId="1" CreationDate="2019-05-24T19:17:22.793" Score="0" ViewCount="229" Body="&lt;p&gt;I am trying to create and edit a file remotely from my iPad using iVim to my Linux box which is on the same network. I am trying to use the ftp protocol from the netrw utility that comes with vim. I keep getting this weird error which let me start editing the file but doesn’t let me save it. Can anyone help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps my network drops out? Or I am losing packets? I am not a networking expert by any means&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/egJ8P.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/egJ8P.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The private/var path is the directory that iVim creates when it wants to save files in the iVim app(almost like a pseudo-directory). iVim can't truly have access to the iPad's file system. Not using Docker or anything of the sort for this operation.&lt;/p&gt;&#xA;" OwnerUserId="22359" LastEditorUserId="343" LastEditDate="2019-05-26T22:57:38.613" LastActivityDate="2020-01-27T11:34:30.093" Title="Trouble with netrw ftp protocol, file won’t save" Tags="|netrw|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20098" PostTypeId="2" ParentId="20076" CreationDate="2019-05-24T19:36:38.223" Score="1" Body="&lt;p&gt;Found a solution/hack: If you set a Windows &lt;code&gt;%HOME%&lt;/code&gt; environment variable to a path for a folder that contains &lt;code&gt;_vimrc&lt;/code&gt; things will work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Experiments with MYVIMRC, MYGVIMRC, and VIM environment variables didn't work for me in spite of doc to the contrary in &lt;code&gt;:help _vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22389" LastActivityDate="2019-05-24T19:36:38.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20099" PostTypeId="1" AcceptedAnswerId="20100" CreationDate="2019-05-24T22:50:59.373" Score="2" ViewCount="147" Body="&lt;p&gt;&lt;code&gt;:h {subject}&lt;/code&gt; reads&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If there is no full match for the pattern, or there&#xA;are several matches, the &quot;best&quot; match will be used.&#xA;A sophisticated algorithm is used to decide which&#xA;match is better than another one.  These items are&#xA;considered in the computation:&#xA;    - A match with same case is much better than a match&#xA;      with different case.&#xA;    - A match that starts after a non-alphanumeric&#xA;      character is better than a match in the middle of a&#xA;      word.&#xA;    - A match at or near the beginning of the tag is&#xA;      better than a match further on.&#xA;    - The more alphanumeric characters match, the better.&#xA;    - The shorter the length of the match, the better.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get the system-wide help files to take precedence in the search? It has been bugging me for a while that plugin help seems to always come first. (for example, &lt;code&gt;:h cursor&lt;/code&gt; brings me to the file &lt;code&gt;~/.local/share/nvim/site/pack/github/start/hyperstyle/doc/hyperstyle.txt&lt;/code&gt;). I can't find information about the search order.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set helpfile?&#xA;helpfile=/usr/share/nvim/runtime/doc/help.txt&#xA;:echo $VIMRUNTIME&#xA;/usr/share/nvim/runtime&#xA;:echo $VIM&#xA;/usr/share/nvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use neovim &lt;code&gt;v0.4.0-391-gb90256e6c&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1027" LastActivityDate="2019-05-28T09:44:14.897" Title="help {subject} path precedence" Tags="|help-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20100" PostTypeId="2" ParentId="20099" CreationDate="2019-05-25T01:03:38.890" Score="3" Body="&lt;p&gt;If you just do &lt;code&gt;:help&lt;/code&gt; vim opens the file specified in &lt;code&gt;'helpfile'&lt;/code&gt;. If you supply a tag then vim will look for it in all &quot;doc/tags&quot; files it can find. It does this by going through the directories listed in &lt;code&gt;'runtimepath'&lt;/code&gt; (alias: &lt;code&gt;'rtp'&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Theoretically you could modify the order of directories in rtp to your liking and therby change help file priority. Since you want system help first I think what you want to do is put the directory named in &lt;code&gt;$VIMRUNTIME&lt;/code&gt; ahead of all plugin directories in the rtp list string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: at first I was wary of suggesting such a reorder&#xA;but &lt;code&gt;:h 'rtp'&lt;/code&gt; talks about reordering it for certain (unrelated) purposes so it should be safe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; My answer was hypothetical but now I've verified that it works as described. Specifically I...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Created a dummy plugin&lt;/li&gt;&#xA;&lt;li&gt;Added plugin's path to &lt;code&gt;'rtp'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Added a help file for the plugin&lt;/li&gt;&#xA;&lt;li&gt;In the helpfile added a tag that duplicates a Vim help tag&lt;/li&gt;&#xA;&lt;li&gt;Generated the tag file&lt;/li&gt;&#xA;&lt;li&gt;Ran &lt;code&gt;:h {duplicate-tag}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When the dummy plugin's path in &lt;code&gt;'rtp'&lt;/code&gt; is in front of all the paths that are subdirs of &lt;code&gt;$VIMRUNTIME&lt;/code&gt; then its help is loaded. When I move the plugin path &lt;em&gt;after&lt;/em&gt; those same paths then Vim's help is loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; As I noted in a comment if you have issues with duplicate tags &lt;code&gt;:tselect&lt;/code&gt; and other commands can help. See the &lt;code&gt;:h tag-matchlist&lt;/code&gt; section which opens with...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When there are several matching tags, these commands can be used to jump&#xA;  between them.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-05-28T09:44:14.897" LastActivityDate="2019-05-28T09:44:14.897" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="20102" PostTypeId="2" ParentId="20091" CreationDate="2019-05-25T02:30:56.573" Score="2" Body="&lt;p&gt;A little crude but this works...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! IsDollarBlock()&#xA;    let l:mode = char2nr(visualmode(&quot;&quot;))&#xA;    if l:mode != 22&#xA;        echom char2nr(l:mode) . &quot; is not block mode&quot;&#xA;        return 0&#xA;    endif&#xA;&#xA;    sil norm! gv&quot;aygv$&quot;by&#xA;    return @a == @b&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can test with...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo IsDollarBlock()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Assuming visual selection was not active)...first this checks whether the last visual selection was even block mode. If not it returns 0 (false). Otherwise it re-selects the visual selection and yanks into register &quot;a&quot;, re-selects it again, issues &lt;code&gt;$&lt;/code&gt; and yanks into register &quot;b&quot;. Then it compares the two registers and returns the comparison result (0/false or 1/true).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to preserve the visual selection you could issue &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; or equivalent at the beginning of the function then put &lt;code&gt;norm! gv&lt;/code&gt; as last command of the function.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-05-25T02:30:56.573" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20103" PostTypeId="1" CreationDate="2019-05-25T06:52:06.033" Score="2" ViewCount="609" Body="&lt;p&gt;Consider the following text file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1f line1n&#xA;line2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Suppose I visual select this, yank it into register a, and then pass it to the following vimscript function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function TestSplit(block)&#xA; for x in split(a:block, &quot;\0&quot;)&#xA;    echom x&#xA;    echom &quot;hi&quot;&#xA; endfor&#xA; return 0&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output will be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1f&#xA;hi&#xA;line1n&#xA;hi&#xA;line2&#xA;hi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What can I replace &lt;code&gt;\0&lt;/code&gt; with to get the following output?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1f line1n&#xA;hi&#xA;line2&#xA;hi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, I want to split on a logical newline for Vim. Note that I also tried &lt;code&gt;\r&lt;/code&gt; and got this output.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1f line1n^@line2&#xA;hi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1750" LastActivityDate="2019-05-25T06:52:06.033" Title="What is the correct character for splitting a string on line breaks in Vimscript?" Tags="|vimscript|string-manipulation|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20104" PostTypeId="1" CreationDate="2019-05-25T10:54:08.070" Score="2" ViewCount="91" Body="&lt;p&gt;I use &lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ALE&lt;/a&gt; for finding syntax errors in code in vim, which populates the loclist with any errors found. However, when I first open a file with errors, which populates that list (I have &lt;code&gt;g:ale_lint_on_enter&lt;/code&gt; set to &lt;code&gt;1&lt;/code&gt;), no error is highlighted. I like to move between errors using &lt;code&gt;:lnext&lt;/code&gt; and &lt;code&gt;:lprevious&lt;/code&gt; (in fact I have them bound to keys), but neither will move to the first error! I have to do this with &lt;code&gt;:lfirst&lt;/code&gt;. Only then will &lt;code&gt;:lnext&lt;/code&gt; and &lt;code&gt;:lprevious&lt;/code&gt; move between the errors in this file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make &lt;code&gt;:lnext&lt;/code&gt; and &lt;code&gt;:lprevious&lt;/code&gt; do this automatically so I don't have to use &lt;code&gt;:lfirst&lt;/code&gt; first to get going?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(To be clear, I don't think this is anything specific to ALE, I think it's anything that populates the loclist. The same behaviour may also occur for the quickfix list, I haven't checked.)&lt;/p&gt;&#xA;" OwnerUserId="91" LastActivityDate="2019-05-25T10:54:08.070" Title="How can I make 'lnext' run 'lfirst' if it needs to be?" Tags="|quickfix|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20105" PostTypeId="1" AcceptedAnswerId="24829" CreationDate="2019-05-25T11:15:13.023" Score="1" ViewCount="94" Body="&lt;p&gt;I often don't remember what was copied lately. So I don't know if I need to  do  &lt;code&gt;&amp;lt;C-r&amp;gt;0&lt;/code&gt; or &lt;code&gt;&amp;lt;C-R&amp;gt;1&lt;/code&gt; in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tend to rely only on the &lt;code&gt;*&lt;/code&gt; register, or type &lt;code&gt;:reg&lt;/code&gt;, look at everything and then decide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is cumbersome.  Is there a better way to do this?&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="51" LastEditDate="2019-05-26T01:24:27.630" LastActivityDate="2020-04-23T23:52:07.387" Title="How to efficiently use the paste registers?" Tags="|cut-copy-paste|statusline|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20106" PostTypeId="2" ParentId="20105" CreationDate="2019-05-25T11:15:13.023" Score="0" Body="&lt;p&gt;I arranged that when I press &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; it toggles yank mode, in which the usual status line turns into a line displaying the yank regs. &#xA;I use Airline.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetLine(timer)&#xA;    if !exists('g:reg_tog')&#xA;        return &#xA;    endif&#xA;    if g:reg_tog==0 &#xA;        return&#xA;    endif &#xA;    if (getreg('0')==getreg('*'))&#xA;        let regs=['+','1','2','3','x','z','4','5']&#xA;    else&#xA;        let regs=['*','0','1','2','x','z','4','5']&#xA;    endif &#xA;&#xA;    let tot=0&#xA;    let wid=winwidth(0)&#xA;    let s=&quot;&quot;&#xA;    let tl=0&#xA;    let avg=0&#xA;&#xA;    let countmore=0&#xA;    let lenlessthan=0&#xA;    let lenmore=0&#xA;&#xA;    for it in regs&#xA;        let t=printf('%s',getreg(it))&#xA;        let t=substitute(t,&quot;\&amp;lt;NL&amp;gt;&quot;,&quot;^M&quot;,&quot;g&quot;)&#xA;        let t=substitute(t,&quot;\t&quot;,&quot;    &quot;,&quot;g&quot;)&#xA;        let l= len(t) &#xA;&#xA;        if l&amp;lt;(wid-25)/(len(regs)+1)&#xA;            let lenlessthan+=l&#xA;        else&#xA;            let lenmore+=l &#xA;            let countmore+=1&#xA;        endif &#xA;    endfor &#xA;&#xA;    let neededavg = ((wid-25-(3*countmore)) - lenlessthan + 0.01) / (countmore+ 0.01)&#xA;&#xA;&#xA;&#xA;    for it in regs&#xA;        let t=printf('%s',getreg(it))&#xA;        let t=substitute(t,&quot;\&amp;lt;NL&amp;gt;&quot;,&quot;&quot;,&quot;g&quot;)&#xA;        let t=substitute(t,&quot;\t&quot;,&quot;    &quot;,&quot;g&quot;)&#xA;        let l= len(t) &#xA;        if  l&amp;gt;=(wid-25)/(len(regs)+1) &#xA;            let ll=min([len(t),float2nr(floor(neededavg))])&#xA;        else&#xA;            let ll=len(t)&#xA;        endif &#xA;        if ll&amp;gt;0&#xA;            if (len(s)+ll&amp;lt;wid-25)&#xA;                if ll&amp;lt;l&#xA;                    let s=s . printf('%s',it) . ': ' . t[0:ll] .'..| '&#xA;                else&#xA;                    let s=s . printf('%s',it) . ': ' . t[0:ll] .' | '&#xA;                endif &#xA;            endif&#xA;        endif&#xA;    endfor&#xA;    let g:line=s&#xA;endfunction&#xA;&#xA;function! RegsToggle()&#xA;    if !exists('g:reg_tog')&#xA;        let g:reg_tog=0&#xA;    endif&#xA;&#xA;&#xA;    let g:reg_tog=!(g:reg_tog)&#xA;    if g:reg_tog&#xA;        let g:airline_section_a_temp= g:airline_section_a&#xA;        let g:airline_section_a=&quot;&quot;&#xA;        let g:airline_section_x_temp= g:airline_section_x&#xA;        let g:airline_section_x=&quot;&quot;&#xA;        let g:airline_section_y_temp= g:airline_section_y&#xA;        let g:airline_section_y=&quot;&quot;&#xA;        let g:airline_section_z_temp= g:airline_section_z&#xA;        let g:airline_section_z=&quot;&quot;&#xA;        let g:airline_section_c= &quot;%{g:line}&quot;&#xA;        &quot;*=  %-0.40{printf('%s',getreg('*'))}  0=  %-0.40{printf('%s',getreg(0))}  1= %-0.40{printf('%s',getreg(1))}  2= %-0.40{printf('%s',getreg(2))} 3= %-0.40{printf('%s',getreg(3))} x= %-0.40{printf('%s',getreg('x'))}&quot;&#xA;        let g:airline_section_error_temp= g:airline_section_error&#xA;        let g:airline_section_error=&quot;&quot;&#xA;        let g:airline_section_warning_temp= g:airline_section_warning&#xA;        let g:airline_section_warning=&quot;&quot;&#xA;    else&#xA;        let g:airline_section_error= g:airline_section_error_temp&#xA;        let g:airline_section_warning = g:airline_section_warning_temp&#xA;        let g:airline_section_a= g:airline_section_a_temp&#xA;        let g:airline_section_x= g:airline_section_x_temp&#xA;        let g:airline_section_y= g:airline_section_y_temp&#xA;        let g:airline_section_z= g:airline_section_z_temp&#xA;        let g:airline_section_c= '%&amp;lt;%{tabpagenr()} %&amp;lt;%{getcwd()} | %f%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#'&#xA;    endif&#xA;    :AirlineRefresh&#xA;    &quot;call airline#extensions#tabline#buflist#invalidate()&#xA;    &quot;:redraw!&#xA;endfunction&#xA;&#xA;&#xA;let g:autoreg=timer_start(2000,'GetLine',{'repeat':-1})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and added&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-L&amp;gt; :call RegsToggle()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that added timer. &#xA;Notice that my c part is different in the usual display since it contains the current working directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so you can add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_section_c= '%&amp;lt;%{getcwd()} | %f%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2020-04-23T23:52:07.387" LastActivityDate="2020-04-23T23:52:07.387" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20107" PostTypeId="1" CreationDate="2019-05-25T11:24:31.353" Score="3" ViewCount="9697" Body="&lt;p&gt;I'm trying to install gvim on WSL (under windows 10) and use &lt;a href=&quot;https://mobaxterm.mobatek.net&quot; rel=&quot;nofollow noreferrer&quot;&gt;MobaXterm&lt;/a&gt; as my X server. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bash informed me that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Command 'gvim' not found, but can be installed with:&#xA;&#xA; sudo apt install vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which I did and vim was installed but not gvim. Anyone know what I'm doing wrong or how to install the latest version of gvim on WSL&lt;/p&gt;&#xA;" OwnerUserId="22412" LastEditorUserId="51" LastEditDate="2019-05-26T22:29:57.023" LastActivityDate="2019-10-24T01:02:35.387" Title="Installing gvim on Windows Subsystem for Linux" Tags="|gvim|microsoft-windows|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20108" PostTypeId="2" ParentId="10988" CreationDate="2019-05-25T11:55:33.697" Score="3" Body="&lt;p&gt;Updating the version of the netrw plugin indeed fixes the problem, as stated in &lt;a href=&quot;https://vi.stackexchange.com/a/11012/11968&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my Vim v8.0 (installed with Homebrew), I had netrw v156 (find out with &lt;code&gt;:echo g:loaded_netrwPlugin&lt;/code&gt;), and the mentioned problem existed. You can find the newest version of netrw on &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dr. Chip's website&lt;/a&gt; (currently v165b, updated on 13 March 2019). Installing this version fixed the problem for me (confirming what is stated in the &lt;a href=&quot;https://vi.stackexchange.com/a/11012/11968&quot;&gt;other answer&lt;/a&gt; that the problem should have been fixed in v162j).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how to install the newest version of the netrw plugin:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Go to &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#NETRW&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Click on the title, this should download a file named &lt;code&gt;netrw.vba.gz&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;netrw.vba&lt;/code&gt; file contained in the downloaded archive is a &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1502&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimball&lt;/a&gt; file. A vimball file is something like a self-installing plugin. Note that you don't have to unzip the &lt;code&gt;.gz&lt;/code&gt; file, as this is done automatically in the next step.&lt;/li&gt;&#xA;&lt;li&gt;Install the plugin (as explained &lt;a href=&quot;https://stackoverflow.com/questions/2033078/how-to-install-a-vimball-plugin-with-vba-extension&quot;&gt;here&lt;/a&gt; or &lt;a href=&quot;http://www.drchip.org/astronaut/vim/#VimFuncs&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; or by &lt;code&gt;:help vimball&lt;/code&gt;):&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open the vimball file with Vim: &lt;code&gt;vim netrw.vba.gz&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;In Vim, run: &lt;code&gt;:source %&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The above command installs the components of the plugin to their proper locations in one of your Vim directories (most probably &lt;code&gt;~/.vim&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the installation, you can restart Vim and test if the new version of the plugin has been correctly installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo g:loaded_netrwPlugin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should output &lt;code&gt;v165b&lt;/code&gt; now (or whatever version you have installed).&lt;/p&gt;&#xA;" OwnerUserId="11968" LastEditorUserId="11968" LastEditDate="2019-05-25T15:47:43.957" LastActivityDate="2019-05-25T15:47:43.957" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20109" PostTypeId="2" ParentId="20107" CreationDate="2019-05-25T21:31:19.803" Score="0" Body="&lt;p&gt;I don't have WSL in front of me at the moment, but going on the assumption that you're using the Ubuntu environment atop WSL, I tried to replicate your condition on an Ubuntu 18.04 LTS VM here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ gvim&#xA;Command 'gvim' not found, but can be installed with:&#xA;&#xA;sudo apt install vim       &#xA;sudo apt install vim-gtk3  &#xA;sudo apt install vim-tiny  &#xA;sudo apt install neovim-qt &#xA;sudo apt install vim-athena&#xA;sudo apt install vim-gtk   &#xA;sudo apt install vim-nox &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Did you trim the other outputs from that command, or does the command truly only tell you about the &lt;code&gt;vim&lt;/code&gt; package under WSL?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;APT is &lt;em&gt;guessing&lt;/em&gt; here, based on the command name you tried, not prescribing. Some of those options will get you something like what you're expecting, and some won't; you're expected to be able to make the distinction. Of the options, I'd recommend &lt;code&gt;vim-gtk3&lt;/code&gt;, but another might please you better.&lt;/p&gt;&#xA;" OwnerUserId="6852" LastActivityDate="2019-05-25T21:31:19.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20111" PostTypeId="2" ParentId="14622" CreationDate="2019-05-26T01:07:45.703" Score="13" Body="&lt;p&gt;The &lt;code&gt;autocmd FileType netrw setl bufhidden=wipe&lt;/code&gt; still leaves one buffer open. I found this solution, which closes it after opening the file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:netrw_fastbrowse = 0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;over at the discussion on &lt;a href=&quot;https://github.com/tpope/vim-vinegar/issues/13&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/tpope/vim-vinegar/issues/13&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1660" LastActivityDate="2019-05-26T01:07:45.703" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20112" PostTypeId="2" ParentId="19927" CreationDate="2019-05-26T01:42:29.140" Score="3" Body="&lt;p&gt;One solution is to create a buffer-local variable the first time a buffer is entered, and then check to see if that variable exists the following times that buffer is entered:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter * if !exists('b:has_been_entered') | &#xA;    \ let b:has_been_entered = 1 | call input('First time entered!') | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;*&lt;/sup&gt;note: this answer is based on &lt;a href=&quot;https://vi.stackexchange.com/questions/19927/autocmd-for-the-event-the-first-time-a-buffer-is-entered#comment34866_19927&quot;&gt;this comment&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2019-05-26T01:42:29.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20113" PostTypeId="1" CreationDate="2019-05-26T06:28:45.040" Score="1" ViewCount="140" Body="&lt;p&gt;I noticed that, if I use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call term_sendkeys(buf, &quot;make\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then I try to execute something else in the terminal windows (i.e. &lt;code&gt;ls&lt;/code&gt;), vim append the last string sent from command mode to the actual string just inserted in the terminal window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Resuming, if I execute (from command mode)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call term_sendkeys(buf, &quot;make\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then, from the terminal window I execute &lt;code&gt;ls&lt;/code&gt; , the inner shell automaticallt executes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lsmake&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this a bug or what am I missing here ? &lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="15254" LastEditDate="2019-05-26T07:12:56.710" LastActivityDate="2021-06-30T03:06:55.553" Title="vim 8.1 send_termkeys problem" Tags="|terminal-buffer|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20114" PostTypeId="1" AcceptedAnswerId="20117" CreationDate="2019-05-26T08:36:01.083" Score="0" ViewCount="58" Body="&lt;pre&gt;&lt;code&gt;      ,g$$$$$$$$$$$$$$$P.        OS: Debian 9.9 stretch&#xA;    ,g$$P&quot;&quot;       &quot;&quot;&quot;Y$$.&quot;.      Kernel: x86_64 Linux 4.19.0-0.bpo.4-amd64&#xA;   ,$$P'              `$$$.      Uptime: 3h 17m&#xA;  ',$$P       ,ggs.     `$$b:    Packages: 2012&#xA;  `d$$'     ,$P&quot;'   .    $$$     Shell: zsh 5.3.1&#xA;   $$P      d$'     ,    $$P     Resolution: 1920x1080&#xA;   $$:      $$.   -    ,d$$'     DE: XFCE&#xA;   $$\;      Y$b._   _,d$P'      WM: Xfwm4&#xA;   Y$$.    `.`&quot;Y$$$$P&quot;'          WM Theme: Moheli&#xA;   `$$b      &quot;-.__               GTK Theme: Adwaita-dark [GTK2]&#xA;    `Y$$                         Icon Theme: Zafiro-icons&#xA;     `Y$$.                       Font: TeX Gyre Bonum 10&#xA;       `$$b.                     CPU: Intel Core i5-6440HQ CPU @ 3.5GHz&#xA;         `Y$$b.                  GPU: Mesa DRI Intel(R) HD Graphics 530 (Skylake GT2) &#xA;            `&quot;Y$b._              RAM: 4804MiB / 7599MiB&#xA;                `&quot;&quot;&quot;&quot;           &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;em&gt;vim&lt;/em&gt; together with the pluging &lt;em&gt;python-jedi&lt;/em&gt;. I would like to edit my .sage program with vim to but the filetype .sage is not recognized by the plugin as python's file (where the content is in python). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I associate .sage files to the jedi plugin ?&lt;/p&gt;&#xA;" OwnerUserId="20739" LastActivityDate="2019-05-26T13:28:29.970" Title="Vim Jedi Plugin -- Add .sage filetype" Tags="|plugin-system|filetype|filetype-python|linux-debian|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20116" PostTypeId="1" CreationDate="2019-05-26T13:20:56.027" Score="1" ViewCount="52" Body="&lt;p&gt;Is there a way to update &lt;code&gt;scroll&lt;/code&gt; every time window height changes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know, that I can achieve the same behavior calling &lt;code&gt;winheight(0)&lt;/code&gt; on each &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; press as suggested &lt;a href=&quot;https://vi.stackexchange.com/questions/10031/scroll-a-quarter-25-of-the-screen-up-or-down&quot;&gt;here&lt;/a&gt;, but I'm curious if there is another way.&lt;/p&gt;&#xA;" OwnerUserId="22155" LastActivityDate="2019-05-26T13:20:56.027" Title="Keep `scroll` equal to current window height" Tags="|autocmd|scrolling|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20117" PostTypeId="2" ParentId="20114" CreationDate="2019-05-26T13:28:29.970" Score="2" Body="&lt;p&gt;Add to &lt;code&gt;~/.vim/ftdetect/sage.vim&lt;/code&gt; (create if not present):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.sage setfiletype python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;cf. &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/44.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt;, which directs to appropriate help pages. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-05-26T13:28:29.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20118" PostTypeId="2" ParentId="20107" CreationDate="2019-05-26T14:42:50.740" Score="1" Body="&lt;p&gt;Yes I had truncated the list of commands suggested by apt. I wasn't sure how apt determines the list of packages it suggests. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I ran:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt install vim-gtk3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gvim did install and did display the expected file contents using a window created by MobaXterm. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While gvim appeared to be working based on my limited testing so far it did display a series of messages in the terminal window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; (gvim:1869): dconf-WARNING **: 07:14:18.972: failed to &#xA;commit changes to dconf: Failed to execute child process &#xA;“dbus-launch” (No such file or directory)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After I installed dbus-x11:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; sudo apt install dbus-x11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue was resolved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks for your help.&lt;/p&gt;&#xA;" OwnerUserId="22412" LastActivityDate="2019-05-26T14:42:50.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20119" PostTypeId="2" ParentId="20097" CreationDate="2019-05-26T22:49:52.087" Score="1" Body="&lt;p&gt;Neither the netrw plugin nor Vim itself actually includes an FTP client: netrw just calls the system’s FTP executable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;iOS doesn’t really support this sort of thing, and doesn’t include an FTP client, thus, you cannot use FTP with the version of iVim that is currently available on the App Store.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might, however like to keep an eye on &lt;a href=&quot;https://github.com/terrychou/iVim/pull/23&quot; rel=&quot;nofollow noreferrer&quot;&gt;this pull request to the iVim source repository&lt;/a&gt;. It doesn’t mention FTP specifically, but it does add a significant number of external programs that can be called by Vim, and there’s no reason an FTP client couldn’t be added to these.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also might like to look into iVim’s support for &lt;a href=&quot;https://developer.apple.com/documentation/fileprovider&quot; rel=&quot;nofollow noreferrer&quot;&gt;document providers&lt;/a&gt; (see &lt;code&gt;:help idoc&lt;/code&gt;). You can use this in combination with a suitable third party FTP app&amp;mdash;such as the &lt;a href=&quot;https://panic.com/blog/the-future-of-transmit-ios/&quot; rel=&quot;nofollow noreferrer&quot;&gt;sadly defunct Transmit&lt;/a&gt;&amp;mdash;to edit remote documents in iVim via a slightly more iOS-native interface.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;UPDATE (January 2020)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The latest versions of iVim have incorporated the pull request mentioned above. There is still no FTP command available, but you &lt;em&gt;can&lt;/em&gt; now edit remote files by using &lt;code&gt;scp&lt;/code&gt; (which, when available, you should prefer over FTP, anyway).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help ios-external-cmds&lt;/code&gt; for more details on iVim's external commands, type &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;!&lt;/kbd&gt;&lt;kbd&gt;Ctrl-D&lt;/kbd&gt; for a list of the currently available commands, or see &lt;code&gt;:help netrw&lt;/code&gt; for more details on using &lt;code&gt;scp&lt;/code&gt; in netrw.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-27T11:34:30.093" LastActivityDate="2020-01-27T11:34:30.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20120" PostTypeId="1" CreationDate="2019-05-27T06:42:01.010" Score="1" ViewCount="93" Body="&lt;p&gt;When I use the command : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;startinsert&quot; sometextfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim starts with the characters &lt;code&gt;NSERT --&lt;/code&gt; at top. The cursor is placed on N and I can write over the whole thing. If I use space, the character remains. If I save and open the file, the characters are gone. If I run vim without my &lt;code&gt;.vimrc&lt;/code&gt; file, vim starts with &lt;code&gt;-- INSERT --&lt;/code&gt; at top (because of the line number gone perhaps).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---------------------------&#xA;  1 NSERT --&#xA;~&#xA;~&#xA;~&#xA;~&#xA;-------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OS : macOS High Sierra | version 10.13.3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim version : version 8.0.642&lt;/p&gt;&#xA;&#xA;&lt;p&gt;$TERM = xterm-256color&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:echo v:termresponse ( old ) = ^[[&gt;0;95;0c&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:echo v:termresponse ( new ) = ^[[&gt;0;95;0c&lt;/p&gt;&#xA;" OwnerUserId="17398" LastEditorUserId="17398" LastEditDate="2019-05-28T07:14:50.833" LastActivityDate="2019-05-28T07:14:50.833" Title="startinsert mode starts with NSERT -- at top" Tags="|original-vim|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="20121" PostTypeId="1" CreationDate="2019-05-27T10:48:21.653" Score="0" ViewCount="43" Body="&lt;p&gt;I am using vim in a terminal on my mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo has('mac')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should return &lt;code&gt;1&lt;/code&gt; (it does on macvim), because it's running on a mac. But it returns &lt;code&gt;0&lt;/code&gt;. Can anyone tell me why this is, and if there's a more reliable way of detecting if vim is running on osx?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: &lt;code&gt;:echo has('macunix')&lt;/code&gt; also returns &lt;code&gt;0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT2: &lt;code&gt;:echo has('osx')&lt;/code&gt; also returns &lt;code&gt;0&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="8792" LastEditorUserId="8792" LastEditDate="2019-05-27T12:51:05.857" LastActivityDate="2019-05-27T12:51:05.857" Title="has('mac') returns 0, but I'm on a mac?" Tags="|macvim|macos|" AnswerCount="0" CommentCount="4" ClosedDate="2019-05-27T20:33:14.833" ContentLicense="CC BY-SA 4.0" />
  <row Id="20122" PostTypeId="2" ParentId="18404" CreationDate="2019-05-27T13:17:29.703" Score="1" Body="&lt;p&gt;I tested that this works.  It assumes that the terminal is opened in buffer 2.&lt;br /&gt;&#xA;You can check which buffer the terminal is open in with &lt;code&gt;:ls&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:terminal&#xA;CTRL-W W &#xA;:let  $VIM_DIR=expand('%:p:h')&#xA;:call term_sendkeys(2, &amp;quot;cd $VIM_DIR\n&amp;quot;)&#xA;:call term_sendkeys(2, &amp;quot;pwd\n&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also your initial command worked for me.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F12&amp;gt; :let $VIM_DIR=expand('%:p:h')&amp;lt;CR&amp;gt;:terminal&amp;lt;CR&amp;gt;cd $VIM_DIR&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It maybe that you are testing this mapping using keys that are already mapped. You can review the nmap mappings with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:nmap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or a specific mapping with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:verb map &amp;lt;F12&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;verb&lt;/code&gt; (&lt;code&gt;verbose&lt;/code&gt;) tells you where the mapping was defined (file and line).&lt;/p&gt;&#xA;" OwnerUserId="14302" LastEditorUserId="22375" LastEditDate="2021-01-12T06:44:54.053" LastActivityDate="2021-01-12T06:44:54.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20124" PostTypeId="2" ParentId="20088" CreationDate="2019-05-27T13:56:22.300" Score="2" Body="&lt;p&gt;Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let job = job_start(...)&#xA;let channel = job_getchannel(job)&#xA;call ch_sendraw(channel, data)&#xA;call ch_close_in(channel)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NeoVim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let jobid = jobstart(...)&#xA;call chansend(jobid, data)&#xA;call chanclose(jobid, 'stdin')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2019-05-27T13:56:22.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20125" PostTypeId="1" AcceptedAnswerId="20128" CreationDate="2019-05-27T19:06:15.017" Score="1" ViewCount="354" Body="&lt;p&gt;I am having trouble crafting a command that would copy the text from the current window and paste this text into a &lt;code&gt;terminal&lt;/code&gt; buffer opened in the split below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are a few things I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal yaw&amp;lt;c-w&amp;gt;j&amp;lt;c-w&amp;gt;&quot;0&#xA;&#xA;:execute &quot;normal yaw\&amp;lt;c-w&amp;gt;j\&amp;lt;c-w&amp;gt;\&quot;0&quot;&#xA;&#xA;:execute 'normal yaw&amp;lt;c-w&amp;gt;j&amp;lt;c-w&amp;gt;&quot;0'&#xA;&#xA;let cmd = &quot;normal yaw\&amp;lt;c-w&amp;gt;j\&amp;lt;c-w&amp;gt;&quot; . '&quot;0'&#xA;:execute cmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But nothing seems to be working. I can get everything to work up until the very last part (&lt;code&gt;&quot;0&lt;/code&gt;) which specifies the register to paste from. No escape sequences seem to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing with this?&lt;/p&gt;&#xA;" OwnerUserId="307" LastEditorUserId="307" LastEditDate="2019-05-27T19:11:38.943" LastActivityDate="2021-02-24T17:16:22.203" Title="Command to copy from current window and paste the text into terminal buffer" Tags="|split|terminal-buffer|escape|string-manipulation|" AnswerCount="3" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20126" PostTypeId="1" AcceptedAnswerId="20186" CreationDate="2019-05-27T20:19:39.637" Score="0" ViewCount="52" Body="&lt;p&gt;I have tried to use FZF to filter my (last) commands.&#xA;The first function works well and retrieves the list of my last commands.&#xA;When I select a command, it triggers my HandleCommand function but goes to the wrong position sometimes. Strangely, it doesn't seem to be deterministic(at times the correct one, other times +1 or +3).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know why? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetCommands()&#xA;    let lines=[]&#xA;    let nu=histnr(&quot;cmd&quot;)&#xA;    for i in range(1,nu)&#xA;        let lines+=[histget(&quot;cmd&quot;,i)]   &#xA;    endfor&#xA;    return lines&#xA;endfunction&#xA;function! HandleCommand(item)&#xA;    let lines=Getcommands() &#xA;    let pos=index(lines, a:item)-1&#xA;    call feedkeys(&quot;q::&quot;.string(pos).&quot;\&amp;lt;CR&amp;gt;&quot;)&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-a&amp;gt;c :call fzf#run({'source': GetCommands(),'sink': function('HandleCommand'),'options': '-m'} )&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-05-27T20:30:39.880" LastActivityDate="2019-06-01T11:08:54.217" Title="Why doesn't it find the correct item?" Tags="|command-history|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20127" PostTypeId="1" CreationDate="2019-05-27T20:47:21.027" Score="2" ViewCount="35" Body="&lt;p&gt;How can I edit the &lt;code&gt;:&lt;/code&gt; history from a &lt;code&gt;VimLeavePre&lt;/code&gt; autocmd? I'd like certain abbreviated command forms to be recorded with their long form in the shada file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm in the habit of using both &lt;code&gt;:tabe {file}&lt;/code&gt; and &lt;code&gt;:tabedit {file}&lt;/code&gt;, and when typing &lt;code&gt;:tabe &amp;lt;tab&amp;gt;&lt;/code&gt; I don't get all entries. I'd like to get used to completing with &lt;code&gt;:tabe&amp;lt;tab&amp;gt;&lt;/code&gt;. In addition, I'd like to make the paths consistent  with &lt;code&gt;fnamemodify()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use neovim &lt;code&gt;v0.4.0-391-gb90256e6c&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="1027" LastEditorUserId="1027" LastEditDate="2019-05-27T20:55:15.380" LastActivityDate="2019-05-27T20:55:15.380" Title="substitute short by long command forms from history on VimLeavePre" Tags="|command-history|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20128" PostTypeId="2" ParentId="20125" CreationDate="2019-05-27T23:48:17.290" Score="2" Body="&lt;p&gt;The problem is that you can't really use &lt;code&gt;:normal&lt;/code&gt; in terminal mode, since that mode is special, it doesn't really behave like Normal/Insert mode in a normal vim buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you can use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#term_sendkeys()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;term_sendkeys()&lt;/code&gt;&lt;/a&gt; function to send the buffer to the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;normal yaw\&amp;lt;c-w&amp;gt;j&quot; | call term_sendkeys('', @0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;normal yaw&quot; | wincmd j | call term_sendkeys('', @0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note you can also pass a buffer name/number as a first argument to &lt;code&gt;term_sendkeys()&lt;/code&gt;, in which case you don't need to switch to that window first.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-05-27T23:48:17.290" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20129" PostTypeId="2" ParentId="20125" CreationDate="2019-05-28T01:01:16.887" Score="2" Body="&lt;p&gt;A little experiment:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Go to your fresh opened terminal, and do an echo:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Leave it in terminal job mode, go back to your original window, execute:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec &quot;norm! \&amp;lt;c-w&amp;gt;pggyy\&amp;lt;c-w&amp;gt;pp&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should see a new line in your current buffer, it's copied from first line of terminal buffer. As &lt;code&gt;ggyy&lt;/code&gt; are &lt;code&gt;normal mode commands&lt;/code&gt;, it tells us that when you switch to a terminal buffer in &lt;code&gt;:norm&lt;/code&gt;, it's always in terminal normal mode during the life time of &lt;code&gt;:normal&lt;/code&gt; , even though the terminal is actually in terminal job mode.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Execute another simple ex command:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec &quot;norm! \&amp;lt;c-w&amp;gt;p&quot; | echom 'balabala'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You must see &lt;code&gt;balabala&lt;/code&gt;. Note that &lt;code&gt;echom&lt;/code&gt; is an &lt;code&gt;ex&lt;/code&gt; command, which means your are still not in terminal job mode, you can execute as much &lt;code&gt;ex&lt;/code&gt; command as you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To communicate with the terminal with &lt;code&gt;ex&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h term_sendkeys()&lt;/code&gt; Send keystrokes to terminal without &lt;code&gt;tmap&lt;/code&gt; applied, without leaving current buffer.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h feedkeys()&lt;/code&gt; You can choose to apply map or not.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h ch_sendraw()&lt;/code&gt; You can get &lt;code&gt;handle&lt;/code&gt; from &lt;code&gt;:h term_getjob()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-28T01:49:32.090" LastActivityDate="2019-05-28T01:49:32.090" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20131" PostTypeId="1" AcceptedAnswerId="20132" CreationDate="2019-05-28T11:34:54.333" Score="2" ViewCount="710" Body="&lt;p&gt;I've been using dotfiles created by other people to setup Vim. Recently I decided to create my own config and investigate what's NeoVim about. I'm using default OSX Terminal.app with zsh shell (I've installed oh-my-zsh). I can't figure out which colors does Vim use and why they differ from NeoVim. &#xA;The only thing I've set so far is line number color (line 12 on screenshot).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I specify which colors for Vim to use? How to develop custom color scheme for Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NeoVim is on the left pane on the screenshot below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8BZ0l.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8BZ0l.png&quot; alt=&quot;Screenshot of NeoVim(left) and Vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22443" LastEditorUserId="22443" LastEditDate="2019-05-29T14:12:06.067" LastActivityDate="2019-05-29T14:12:06.067" Title="Where can I find color settings used by Vim and NeoVim?" Tags="|vimrc|neovim|colorscheme|color|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20132" PostTypeId="2" ParentId="20131" CreationDate="2019-05-28T12:53:04.097" Score="2" Body="&lt;p&gt;This specific difference is caused by the &lt;code&gt;background&lt;/code&gt; setting. It is because on a dark background, light font colors look better and vice versa. You can set it with the&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=dark&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The actual colorization rules use a relatively complex regexp-based ruleset, defined in &lt;code&gt;syntax/&lt;/code&gt; directory (on most Linuxes, it is in &lt;code&gt;/usr/share/vim/vim&amp;lt;version&amp;gt;/syntax&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="28" LastActivityDate="2019-05-28T12:53:04.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20133" PostTypeId="2" ParentId="20125" CreationDate="2019-05-28T12:53:46.603" Score="0" Body="&lt;p&gt;This will work if you are sending the whole current buffer.&lt;/p&gt;&#xA;&lt;p&gt;This example assumes the terminal is in buffer '2', so change the buffer number to your actual buffer number. To find the terminal buffer number(s) use either &lt;code&gt;:ls&lt;/code&gt; or `:echo term_list().&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%y | call term_sendkeys(2, @&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14302" LastEditorUserId="14302" LastEditDate="2021-02-24T17:16:22.203" LastActivityDate="2021-02-24T17:16:22.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20134" PostTypeId="1" AcceptedAnswerId="20135" CreationDate="2019-05-28T13:47:05.977" Score="0" ViewCount="111" Body="&lt;p&gt;Suppose i have several lines of text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1 line1&#xA;line2 line2&#xA;line3 line3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to create a vimscript function that has the following result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;itemizedlist&amp;gt;&#xA;&amp;lt;listitem&amp;gt;&amp;lt;para&amp;gt;line1 line1&amp;lt;/para&amp;gt;&amp;lt;/listitem&amp;gt;&#xA;&amp;lt;listitem&amp;gt;&amp;lt;para&amp;gt;line2 line2&amp;lt;/para&amp;gt;&amp;lt;/listitem&amp;gt;&#xA;&amp;lt;listitem&amp;gt;&amp;lt;para&amp;gt;line3 line3&amp;lt;/para&amp;gt;&amp;lt;/listitem&amp;gt;&#xA;&amp;lt;/itemizedlist&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do i use '&amp;lt; and '&gt; to move to the beginning and end of multiline visual selection inside a vimscript function? vim writes me &quot;Not an editor command: '&amp;lt;&quot;&lt;/p&gt;&#xA;" OwnerUserId="22283" LastActivityDate="2019-05-28T13:54:17.053" Title="How do I move to the beginning of a visual block from a vimscript function?" Tags="|vimscript|visual-mode|functions|filetype-xml|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20135" PostTypeId="2" ParentId="20134" CreationDate="2019-05-28T13:54:17.053" Score="1" Body="&lt;p&gt;Simply?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;normal! '&amp;lt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I would highly recommend seeing if there is a way to accomplish what you want via simpler (Ex) commands. If you need to do some work over a range, Ex commands are good at it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, visually select the lines (e.g., &lt;code&gt;Vap&lt;/code&gt;), then &lt;code&gt;:'&amp;lt;,'&amp;gt;normal! Isome text&lt;/code&gt; and &lt;code&gt;:'&amp;lt;,'&amp;gt;normal! Asome text&lt;/code&gt;. Then you should be able to get the lines above and below via the &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; registers and put the remaining text. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-05-28T13:54:17.053" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20136" PostTypeId="1" AcceptedAnswerId="20176" CreationDate="2019-05-28T14:39:14.487" Score="5" ViewCount="2736" Body="&lt;p&gt;I've recently started moving over to gvim from vim on Windows. I managed to get the terminal version set up properly, and the fonts render there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim, it works fine: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DFESW.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DFESW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in gvim, the powerline symbols are broken:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kBTqq.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kBTqq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm honestly not sure where the problem lies. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main difference between Vim in Cygwin and gvim is how the font is set up. Cygwin has a separate option for it on a window-level basis, while it appears that gvim follows &lt;code&gt;set guifont&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set both to use Source Code Pro for Powerline (also did a fresh install from &lt;a href=&quot;https://github.com/powerline/fonts&quot; rel=&quot;noreferrer&quot;&gt;powerline/fonts&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following another post, I also tried with &lt;code&gt;guifontwide&lt;/code&gt;, neither of which worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Manually adding the symbols (suggested &lt;a href=&quot;https://vi.stackexchange.com/a/11366/21251&quot;&gt;here&lt;/a&gt;) results in this within gvim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3dbLN.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3dbLN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in &lt;a href=&quot;https://i.stack.imgur.com/HjQEa.png&quot; rel=&quot;noreferrer&quot;&gt;Vim&lt;/a&gt;, and surprisingly Notepad++, the symbols render properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In theory a) minimal .vimrc (for reference, using Vim-Plug):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[...]&#xA;Plug 'vim-airline/vim-airline-themes'&#xA;Plug 'vim-airline/vim-airline'&#xA;[...]&#xA;&#xA;set guifont=Source\ Code\ Pro\ for\ Powerline:h11:cANSI &quot; Font&#xA;set guifontwide=Source\ Code\ Pro\ for\ Powerline:h11:cANSI &quot; gvim (?)&#xA;&#xA;let g:airline_theme='tomorrow'&#xA;&#xA;let g:airline_powerline_fonts = 1&#xA;let g:airline#extensions#ale#enabled = 1&#xA;&#xA;&quot; and the symbol definitions after this, but the issue is there with or without them.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Cygwin vimrc is slightly different from the gvim vimrc, but that code (aside &lt;code&gt;set guifont&lt;/code&gt; and &lt;code&gt;set guifontwide&lt;/code&gt;) is present in both. Same theme, same system, same font, and overall the same plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's nothing wrong with the fonts themselves, so it's probably a configuration issue somewhere. What am I missing? &lt;/p&gt;&#xA;" OwnerUserId="21251" LastActivityDate="2021-12-15T19:43:25.760" Title="How do I properly set up airline and powerline fonts with gvim?" Tags="|gvim|plugin-airline|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20137" PostTypeId="1" CreationDate="2019-05-28T18:47:33.947" Score="1" ViewCount="45" Body="&lt;p&gt;Consider the following function and mapping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetInvoker()&#xA;    echom &quot;I was invokeed by the key &quot;&#xA;    echom &amp;lt;This_should_echo_F_or_G&amp;gt;&#xA;endfunction&#xA;&#xA;map F :call GetInvoker()&amp;lt;CR&amp;gt;&#xA;map G :call GetInvoker()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I determine which key that the user actually typed from inside the function?&lt;/p&gt;&#xA;" OwnerUserId="1750" LastActivityDate="2020-04-05T15:00:31.210" Title="Is it possible to obtain the key that triggered a function to be called if there was one?" Tags="|key-bindings|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20138" PostTypeId="1" CreationDate="2019-05-28T18:53:26.877" Score="0" ViewCount="42" Body="&lt;p&gt;Consider the following function and mapping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DoMagic()&#xA;    if s:isActive&#xA;       echom &quot;Performing magic!&quot;&#xA;    else&#xA;       &quot; Perform default action of whatever key was mapped to this function&#xA;    endif&#xA;endfunction&#xA;&#xA;map F :call DoMagic()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a magic command that tells vim to pretend the mapping never happened  if some condition is not true?&lt;/p&gt;&#xA;" OwnerUserId="1750" LastActivityDate="2019-05-29T05:59:09.997" Title="Is it possible to perform the original action of a mapped key without knowing the key a priori?" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20139" PostTypeId="1" CreationDate="2019-05-28T20:43:24.547" Score="1" ViewCount="193" Body="&lt;p&gt;I'm wondering if this is possible, more for curiosity's sake, but also it might be useful to know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have several ascii data tables and I want to combine them all into a single file. So I combined all of the files into a single file with the file name to signify the start of the new data. What I'd like to do is search for that filename as a sort of delimiter, yank it, and put it as a column into all subsequent rows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;file-1.txt&#xA;1 1 1 1&#xA;2 2 2 2&#xA;3 3 3 3&#xA;4 4 4 4&#xA;file-2.txt&#xA;5 5 5 5&#xA;6 6 6 6&#xA;7 7 7 7&#xA;8 8 8 8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And turn it into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;file-1.txt 1 1 1 1&#xA;file-1.txt 2 2 2 2&#xA;file-1.txt 3 3 3 3&#xA;file-1.txt 4 4 4 4&#xA;file-2.txt 5 5 5 5&#xA;file-2.txt 6 6 6 6&#xA;file-2.txt 7 7 7 7&#xA;file-2.txt 8 8 8 8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It might be easier to do outside of vi, but I thought I might ask.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I suppose another question along the same vein I'm not sure about is if you can put a yanked word as a column over several rows)&lt;/p&gt;&#xA;" OwnerUserId="22456" LastActivityDate="2019-05-30T22:18:56.173" Title="Search for line and paste as column until next match" Tags="|regular-expression|search|replace|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20140" PostTypeId="2" ParentId="20138" CreationDate="2019-05-28T20:49:29.167" Score="2" Body="&lt;p&gt;Two patterns come to mind:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; F MyExprFunc('F')&#xA;nnoremap F :call MyFunc('F')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function has to know what key is mapped to it, so it can do the appropriate thing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyExprFunc(key)&#xA;  if blah blah&#xA;    return a:key&#xA;  else&#xA;    return magic_key_sequence&#xA;  endif&#xA;endfunction&#xA;&#xA;function MyFunc(key)&#xA;  if blah blah&#xA;    exec printf(&quot;normal! %s&quot;, a:key)&#xA;  else&#xA;    &quot; Do some magic&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-05-28T20:49:29.167" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20141" PostTypeId="2" ParentId="20139" CreationDate="2019-05-28T20:57:21.897" Score="0" Body="&lt;p&gt;The general pattern we'll be using is: insert text at the beginning of a range of lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have two options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:[range]normal! Itext&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:[range]substitute/^/text&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I tend to think of &lt;code&gt;normal!&lt;/code&gt; first, because of the insertion, but the substitute should work just as well. We're going to use substitute here, because it's easier to insert dynamic text at the end of.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Start by defining a function to do most of the work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Work() abort&#xA;  &quot; delete and capture the file.txt line&#xA;  delete a&#xA;  &quot; trim newlines and add a space&#xA;  let @a = trim(@a) . ' '&#xA;  &quot; insert the value on all lines up to the next '.txt' line&#xA;  .,/\.txt\|\%$/-1 substitute/^/\=@a&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I was able to eliminate the range error by using &lt;code&gt;\%$&lt;/code&gt; as I had been trying to do in my experiments. But the key was that we need a blank line at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We need a bit of prep, because the function uses the pattern &lt;code&gt;/.txt\|\%$/&lt;/code&gt; as part of a range, so we need a blank line at the end if none exists—&lt;code&gt;:s/\%$/\r&lt;/code&gt;,&#xA;or alternately, &lt;code&gt;:call setline('$', '')&lt;/code&gt;, &lt;code&gt;:call append('$', '')&lt;/code&gt;, or even &lt;code&gt;:$normal! o&lt;/code&gt;. We can inspect visually, of course, but for the scripter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if len(getline('$')) &amp;gt; 0&#xA;  call append('$', '') &quot; or whichever variant you prefer&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then do it with a global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/.txt/call Work()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Altogether, then, create a script-file called &lt;code&gt;whatever_you_want.vim&lt;/code&gt; with the following contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Work() abort&#xA;  &quot; delete and capture the file.txt line&#xA;  delete a&#xA;  &quot; trim newlines and add a space&#xA;  let @a = trim(@a) . ' '&#xA;  &quot; insert the value on all lines up to the next '.txt' line&#xA;  .,/\.txt\|\%$/-1 substitute/^/\=@a&#xA;endfunction&#xA;&#xA;if len(getline('$')) &amp;gt; 0&#xA;  call append('$', '') &quot; or whichever variant you prefer&#xA;endif&#xA;&#xA;global/.txt/call Work()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now start vim with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim /path/to/your/file.txt -S /path/to/vimscript.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Optionally, add to the end of your script&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;write&#xA;quit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you're quite sure of the results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The script has the benefit of being embarrassingly repeatable.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;N.B.&lt;/strong&gt; This function was crafted specifically to your example. It will definitely fail if any of your &quot;data&quot; contains &lt;code&gt;.txt&lt;/code&gt; somewhere.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-05-30T22:18:56.173" LastActivityDate="2019-05-30T22:18:56.173" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20143" PostTypeId="2" ParentId="20139" CreationDate="2019-05-29T00:26:23.367" Score="3" Body="&lt;p&gt;&lt;strong&gt;vim (it's ugly)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g /\S/ if getline('.') =~# '^file' | d | else | norm! PJ | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/\S/&lt;/code&gt; match none blank line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;if getline('.') =~# '^file' | d&lt;/code&gt; delete line starts with &quot;file&quot; to default register. Note that default register is line wise after deletion.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;norm! PJ&lt;/code&gt; paste above current line from default register, join them with a space. &lt;code&gt;J&lt;/code&gt; insert one space if 1st line doesn't end with &lt;code&gt;.&lt;/code&gt;, &lt;code&gt;!&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;, other wise it insert two spaces. also check &lt;code&gt;:h 'joinspaces'&lt;/code&gt;. As &lt;code&gt;D.Ben Knoble&lt;/code&gt; pointed out, you can replace it with &lt;code&gt;put! | join&lt;/code&gt; if you want to avoid &lt;code&gt;normal&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But vim is not a proper tool to do this kind of job, &lt;code&gt;awk&lt;/code&gt; is much better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;awk&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;awk '/^file/{p=$0; next} {print p, $0}' filename&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-30T12:51:46.143" LastActivityDate="2019-05-30T12:51:46.143" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20144" PostTypeId="2" ParentId="16295" CreationDate="2019-05-29T04:39:34.787" Score="1" Body="&lt;p&gt;A workaround might be to use the &lt;code&gt;\DeclarePairedDelimiter&lt;/code&gt; command from the mathtools package to then just write like &lt;code&gt;\leftopenint{a, b}&lt;/code&gt;. See the accepted answer to &lt;a href=&quot;https://tex.stackexchange.com/questions/118173/how-to-write-ceil-and-floor-in-latex/&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\documentclass{minimal}&#xA;\usepackage{mathtools}&#xA;\DeclarePairedDelimiter\leftopenint{(}{]}&#xA;\DeclarePairedDelimiter\rghtopenint{[}{)}&#xA;&#xA;\begin{document}&#xA;  \begin{equation*}&#xA;   \leftopenint{-\infty, \frac{1}{N} } \cup \rghtopenint*{\frac{1}{N}, \infty}&#xA;  \end{equation*}&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which gives me what is posted below. Note that the &lt;code&gt;*&lt;/code&gt; makes the delimiters scale.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GgMLu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GgMLu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Just noted&lt;/strong&gt; the asymmetric appearance of the brackets in the header also breaks syntax highlighting and the commands like &lt;em&gt;closing of matching environments&lt;/em&gt;. I could fix this with outsourcing these definitions to a separate file and then use &lt;code&gt;\include&lt;/code&gt;...&lt;/p&gt;&#xA;" OwnerUserId="8648" LastEditorUserId="8648" LastEditDate="2019-05-29T04:46:00.160" LastActivityDate="2019-05-29T04:46:00.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20145" PostTypeId="2" ParentId="20139" CreationDate="2019-05-29T05:01:03.853" Score="1" Body="&lt;p&gt;You had a secondary question about inserting a word as a column in a table. It's possible using Visual select in block mode and we can use this method, as you probably surmised, to solve your primary problem as shown by the following series of commands. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The first two answers use approaches that are generally better (easier to follow, less error prone) than what follows here. Consider this a bonus answer...for educational purposes.&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the cursor on a file line (e.g. &lt;code&gt;file-1.txt&lt;/code&gt;) to start. Note that where you see &lt;code&gt;^R&lt;/code&gt; that means to enter &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;R&lt;/kbd&gt;. Similarly for &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; enter &lt;kbd&gt;ESC&lt;/kbd&gt;...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;DJ&lt;/code&gt; - delete-yank the text and move everything up a row with the &lt;code&gt;J&lt;/code&gt;oin.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^V/^file/-1&lt;/code&gt; - start Visual select (block mode) and extend it to the line preceding the next delimeter line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;I^R&quot; &amp;lt;ESC&amp;gt;&lt;/code&gt; - Do a block insert of the filename (found in unnamed register &lt;code&gt;&quot;&lt;/code&gt;) followed by a space. Every selected row will get this text. That's our column insert magic.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;gt;j&lt;/code&gt; - Go to the line after the last line of previously selected text. We're ready for the next iteration.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;We can create a recursive macro out of a slight variation of these commands. Play the macro and the whole file will be converted into desired format. One caveat: you must have a blank line at the end of file. This is preventable but I was in a hurry. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the macro (almost) ready for insertion into register &lt;code&gt;q&lt;/code&gt;....&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DJ^V/^file\|^$/-1^MI^R&quot; &amp;lt;Esc&amp;gt;'&amp;gt;j@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I say &quot;almost ready&quot; because you can't just copy/paste this into Vim. Like before &lt;code&gt;^R&lt;/code&gt; means &lt;code&gt;Ctrl-R&lt;/code&gt; but to actually enter this text so you can yank it into register &lt;code&gt;q&lt;/code&gt; you'll need to precede each control-character (and &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;) with &lt;code&gt;Ctrl-V&lt;/code&gt;. So where it says &lt;code&gt;^M&lt;/code&gt; you'll actually enter &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; then &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;M&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-05-29T05:24:56.233" LastActivityDate="2019-05-29T05:24:56.233" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20146" PostTypeId="2" ParentId="20138" CreationDate="2019-05-29T05:59:09.997" Score="2" Body="&lt;p&gt;The generic way to do this is to use the &lt;code&gt;:norm! &amp;lt;key&amp;gt;[&amp;lt;key&amp;gt;]&lt;/code&gt; command. The bang (&lt;code&gt;!&lt;/code&gt;) is important, it will execute the given keys as normal commands as they are not mapped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another more low-level alternative is to make use of the &lt;code&gt;feedkeys()&lt;/code&gt; function, that allows to insert keys into the typeahead buffer and allows to define whether mappings should apply or not (among others). See the documentation: &lt;a href=&quot;https://vimhelp.org/various.txt.html#:norm&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :norm!&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/eval.txt.html#feedkeys()&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h feedkeys()&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-05-29T05:59:09.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20147" PostTypeId="2" ParentId="2280" CreationDate="2019-05-29T08:31:35.423" Score="1" Body="&lt;p&gt;Another way is to use &lt;code&gt;:h :ilist&lt;/code&gt;, i use it to get an overview of man page. it's result looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/find.~&#xA;  1:    3 NAME&#xA;  2:    6 SYNOPSIS&#xA;  3:    9 DESCRIPTION&#xA;  4:   18 OPTIONS&#xA;  5:   93 EXPRESSION&#xA;  6:  779 EXAMPLES&#xA;  7:  877 HISTORY&#xA;  8:  931 BUGS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a small function that let you choose to go to the result line by index:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:select_ilist(ilist_result)&#xA;  if empty(a:ilist_result) || a:ilist_result =~# '^\_s*Error'&#xA;    return&#xA;  endif&#xA;&#xA;  let select = input(a:ilist_result . &quot;\ngoto : &quot;)&#xA;  if empty(select) | return | endif&#xA;&#xA;  &quot; ilist result starts with '\nfilename\n', filename can be empty&#xA;  let lines = split(a:ilist_result[stridx(a:ilist_result, &quot;\n&quot;, 1) : ], &quot;\n&quot;)&#xA;  if select &amp;lt;= 0 || select &amp;gt; len(lines) | return | endif&#xA;&#xA;  exec matchstr(lines[select-1], '^\v\s*\d+\:\s+\zs\d+')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It can be used like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -buffer Section call s:select_ilist(execute('silent! ilist /\v\C^[A-Z][^a-z]+$/'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-29T10:09:27.697" LastActivityDate="2019-05-29T10:09:27.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20148" PostTypeId="2" ParentId="93" CreationDate="2019-05-29T09:59:41.150" Score="10" Body="&lt;p&gt;Thanks to this PR &lt;a href=&quot;https://github.com/vim/vim/pull/4317&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/vim/vim/pull/4317&lt;/a&gt; , each search command shows search statistics (like current match position, and number of matches) in vim 8.1.1270. Make sure to remove &lt;code&gt;S&lt;/code&gt; from the variable &lt;code&gt;shortmess&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22462" LastActivityDate="2019-05-29T09:59:41.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20149" PostTypeId="1" AcceptedAnswerId="20150" CreationDate="2019-05-29T10:32:33.077" Score="0" ViewCount="40" Body="&lt;p&gt;Is it possible to make &lt;code&gt;&amp;lt;C-W&amp;gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; command to make split on the right, if it's the rightmost pane opened? Otherwise, it would behave like regular move. It's something like &quot;conditional splitting&quot; I would say.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&#xA;I've got two panes opened, split vertically. Cursor is currently on the right pane. I press &lt;code&gt;&amp;lt;C-W&amp;gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; and I create third pane and my cursor is moved there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;code&gt;&amp;lt;C-W&amp;gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; from the leftmost pane, nothing unusual happens, I just move to the already existing pane to the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S.: which are common bindings for splitting panes among Vim users?&lt;/p&gt;&#xA;" OwnerUserId="22443" LastActivityDate="2019-05-29T12:02:33.803" Title="How can I specify &quot;split or move&quot; logic for &lt;C-W&gt;&lt;C-L&gt; and similar move commands?" Tags="|vimrc|split|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20150" PostTypeId="2" ParentId="20149" CreationDate="2019-05-29T11:05:44.673" Score="3" Body="&lt;p&gt;Split and move if window doesn't change after &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;c-*&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-w&amp;gt;&amp;lt;c-j&amp;gt; :call &amp;lt;sid&amp;gt;smart_split('j')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;c-w&amp;gt;&amp;lt;c-k&amp;gt; :call &amp;lt;sid&amp;gt;smart_split('k')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;c-w&amp;gt;&amp;lt;c-h&amp;gt; :call &amp;lt;sid&amp;gt;smart_split('h')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;c-w&amp;gt;&amp;lt;c-l&amp;gt; :call &amp;lt;sid&amp;gt;smart_split('l')&amp;lt;cr&amp;gt;&#xA;&#xA;function! s:smart_split(cmd)&#xA;  &quot; original window number&#xA;  let wn = winnr()&#xA;&#xA;  &quot; try to move to other window&#xA;  exec 'wincmd ' . a:cmd&#xA;&#xA;  &quot; do nothing if window changed&#xA;  if wn != winnr() | return | endif&#xA;&#xA;  &quot; otherwise split vertical or horizontal based on a:cmd&#xA;  exec 'wincmd ' . (a:cmd =~# '[lh]' ? 'v' : 's')&#xA;&#xA;  &quot; move to new window. You only need this 50% of time.&#xA;  exec 'wincmd ' . a:cmd&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't used this, i'm fine with default window splitting command binding.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-05-29T12:02:33.803" LastActivityDate="2019-05-29T12:02:33.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20151" PostTypeId="1" AcceptedAnswerId="20162" CreationDate="2019-05-29T13:21:10.270" Score="2" ViewCount="521" Body="&lt;p&gt;I am writing an RMarkdown file, which is a document that is a hybrid of text and R code. Here is an example of what that document could look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Here is an example of text within my Rmarkdown file. &#xA;This is used to describe the code block below:&#xA;&#xA;```{r}&#xA;dataframe &amp;lt;- outcome.df %&amp;gt;%&#xA;  na.omit() %&amp;gt;%&#xA;  group_by(Hospital, State) %&amp;gt;%&#xA;  arrange(desc(HeartAttackDeath)) %&amp;gt;%&#xA;```&#xA;&#xA;Here is an example of another text block&#xA;And the following is an example of another code chunk:&#xA;&#xA;```{r}&#xA;result &amp;lt;- lapply(names(dataframe), complete.cases)&#xA;```&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to move all of the code to another document. How would I go about selecting just the code, using vim? i.e. everything between &lt;code&gt;```{r}&lt;/code&gt; and &lt;code&gt;```&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="22464" LastEditorUserId="1841" LastEditDate="2019-06-05T16:00:41.570" LastActivityDate="2019-06-05T16:00:41.810" Title="Selecting code chunk in Rmarkdown" Tags="|visual-block|custom-text-object|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20152" PostTypeId="2" ParentId="20008" CreationDate="2019-05-29T16:34:32.347" Score="3" Body="&lt;p&gt;Got an answer on the vim_use Google group. It came down to priorities, and which vimrc is being used. For MacVim, there's a &lt;code&gt;.gvimrc&lt;/code&gt; as well as a &lt;code&gt;.vimrc&lt;/code&gt; file, and the &lt;code&gt;.gvimrc&lt;/code&gt; file was overriding the &lt;code&gt;.vimrc&lt;/code&gt; settings. Once I copied the &lt;code&gt;.vimrc&lt;/code&gt; file to &lt;code&gt;.gvimrc&lt;/code&gt; with the following changes in particular, I got the same view:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;.gvimrc&lt;/code&gt; file had &lt;code&gt;tabstop=8&lt;/code&gt;, which was the primary problem. There were also tabs in the actual file, which I replaced using the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,$s/\t/    /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22215" LastActivityDate="2019-05-29T16:34:32.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20153" PostTypeId="1" CreationDate="2019-05-29T15:40:56.047" Score="0" ViewCount="412" Body="&lt;p&gt;Every time I open a file (by which I mean what I would call a text file, typically one containing Python code) I get two lines of error messages that read&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;E576: viminfo: Missing '&gt;' in line: 555147747^I0 &lt;/li&gt;&#xA;&lt;li&gt;E576: viminfo: Missing '&gt;' in line: ^I&quot;^I72^I0&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have searched for an answer and found people discussing this problem and solving it but (a) they are Unix users and what they refer to doesn't apply - as far as I can tell - to me as a Windows user and (b) the posts are 7 years old so I'm guessing that the cause of my problem or its solution will be different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It dawned on me that the ^I in the error message is a \t i.e. a tab so the second message for example is saying that a '&gt;' was expected in a line that contains \t&quot;\t72\t0 but the file - which I assume is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Program Files (x86)\vim\vim81\syntax\viminfo.vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;does not contain such a line or indeed any occurrences of '72' at all.&lt;/p&gt;&#xA;" OwnerDisplayName="user1476044" LastEditorUserId="5298" LastEditDate="2019-05-30T02:33:29.410" LastActivityDate="2020-02-24T21:01:25.390" Title="Why am I getting vim error E576? (Vim 8.1, Windows 10)" Tags="|viminfo|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20154" PostTypeId="1" CreationDate="2019-05-29T17:00:57.313" Score="2" ViewCount="1068" Body="&lt;p&gt;I thought this was straightforward i.e. put the command that works in the buffer viz &quot;set ts=4&quot; in vimrc but this does not seem to work if I also want the functionality provided by vimrc_example, which I do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I started with a fresh install of Vim 8.1 and added &quot;set ts=4&quot; to the end. When I fired up Vim, tabstop was set to 8. I looked more carefully at what vimrc does and found that there are all sorts of complicated things going on, including instructions that prevent subsequent instructions having any effect - aha!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a new vimrc that contains the one instruction &quot;set ts=4&quot; and found that works in the sense that tabstop is 4 when I run Vim. But of course there is none of the functionality that I want and expect from Vim e.g. syntax highlighting, so I tried what I thought was a minimal way of getting from something that worked to what I want. I made a vimrc that reads, in its entirety:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/vimrc_example.vim&#xA;set ts=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This provides syntax highlighting etc but tabs are back at 8. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Digging a bit deeper, vimrc_example.vim calls defaults.vim and if I take that call out then tabs are set at 4 so the problem seems to be with defaults.vim. I had a look at defaults.vim and there are no occurrences of &quot;set tabstop&quot; or &quot;set ts&quot; or any mention of tabs so I am mystified. In desperation I stuck &quot;set ts=4&quot; on the end of defaults.vim and re-enabled the call to defaults.vim and that didn't work either.&lt;/p&gt;&#xA;" OwnerDisplayName="user1476044" LastActivityDate="2020-06-23T20:07:45.733" Title="How to set tabs in vimrc (Vim 8.1, Windows 10)" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20155" PostTypeId="1" AcceptedAnswerId="20185" CreationDate="2019-05-29T20:29:25.473" Score="1" ViewCount="217" Body="&lt;p&gt;I've got these mappings in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-Tab&amp;gt; :tabn&amp;lt;cr&amp;gt;  &quot; cycle tabs&#xA;nnoremap &amp;lt;C-S-Tab&amp;gt; :tabp&amp;lt;cr&amp;gt;    &quot; cycle tabs backward&#xA;&#xA;nnoremap &amp;lt;C-J&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-J&amp;gt;   &quot; no Ctrl-W needed to navigate up&#xA;nnoremap &amp;lt;C-K&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-K&amp;gt;   &quot; no Ctrl-W needed to navigate down&#xA;nnoremap &amp;lt;C-L&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-L&amp;gt;   &quot; no Ctrl-W needed to navigate right&#xA;nnoremap &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-H&amp;gt;   &quot; no Ctrl-W needed to navigate left&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I use them (e.g. I press &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;L&lt;/kbd&gt; or &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;H&lt;/kbd&gt;), they work, but I get a “bong” alert sound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get the sound in Windows (GVim 8.1 on Win 10), and in my terminal (Vim 8.1 on CentOS via SecureCRT).&lt;br&gt;&#xA;There's no sound when I enter the commands manually (e.g. &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;W&lt;/kbd&gt;,&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;L&lt;/kbd&gt;), with or without the &lt;code&gt;nnoremap&lt;/code&gt; in place.&lt;br&gt;&#xA;There's no sound when I use those key combos in other programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is that happening, and how can I stop it?&lt;/p&gt;&#xA;" OwnerUserId="9267" LastEditorUserId="9267" LastEditDate="2019-06-03T16:19:59.720" LastActivityDate="2019-06-03T16:19:59.720" Title="Alert sound when using &lt;C-L&gt; etc. mappings" Tags="|key-bindings|vimscript|comments|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20156" PostTypeId="2" ParentId="20154" CreationDate="2019-05-29T21:40:46.367" Score="1" Body="&lt;p&gt;There are a couple of things running amok here: when no vimrc exists for the user, vim sources the defaults.vim file, as you know. However, once that vimrc is created, it no longer does so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim also comes with an example. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The standard way to create your own vimrc is to do the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create your vimrc (&lt;code&gt;vim ~/.vim/vimrc&lt;/code&gt;, or &lt;code&gt;vim ~/.vimrc&lt;/code&gt; for older versions)&lt;/li&gt;&#xA;&lt;li&gt;Copy from the defaults and example scripts the lines you want, and embark on the long quest to continually customize your vim.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, in your case, the vimrc could look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;filetype plugin indent on&#xA;set tabstop=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Finally, a quick recommendation from someone who lives in Vim: leave tabs at width 8, unless you’re going to use exclusively tabs. I use spaces, and adjust the &lt;code&gt;shiftwidth&lt;/code&gt; and related settings per-filetype. So tabs always display as 8. See &lt;a href=&quot;https://github.com/benknoble/Dotfiles&quot; rel=&quot;nofollow noreferrer&quot;&gt;my Dotfiles&lt;/a&gt; for how I do it. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-05-30T12:02:43.767" LastActivityDate="2019-05-30T12:02:43.767" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20157" PostTypeId="2" ParentId="358" CreationDate="2019-05-30T01:20:01.757" Score="1" Body="&lt;p&gt;I often open a new vim instance in another workspace/screen just to pop open a help window so this article was enormously helpful to me.&#xA;Here Is a bit of VimScript that I just wrote that will open a &lt;code&gt;help&lt;/code&gt; page in a new tab, and automatically close a new/empty buffer if necessary. Hopefully it is useful to folks in the future. Thank y'all for your help!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Help: Open a `help` page in a new tab, or replace the current buffer if it&#xA;&quot; is unnamed and empty.&#xA;function! Help( query )&#xA;  &quot; Is the current buffer empty?&#xA;  let l:empty = line( '$' ) ==# 1 &amp;amp;&amp;amp; getline( 1 ) ==# ''&#xA;  &quot; Store the current tab number so we can close it later if need be.&#xA;  let l:tabnr = tabpagenr()&#xA;  let l:bufname = bufname( winbufnr( 0 ) )&#xA;  try&#xA;    &quot; Open the help page in a new tab. (or bail if it's not found)&#xA;    execute &quot;tab help &quot; . a:query&#xA;    &quot; The help page opened successfully. Close the original tab if it's empty.&#xA;    if l:bufname ==# '' &amp;amp;&amp;amp; l:empty&#xA;      execute &quot;tabclose &quot; . l:tabnr&#xA;    endif&#xA;  endtry&#xA;endfunction&#xA;&#xA;command! -nargs=1 Help call Help( &amp;lt;f-args&amp;gt; )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22472" LastActivityDate="2019-05-30T01:20:01.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20158" PostTypeId="1" AcceptedAnswerId="20159" CreationDate="2019-05-30T02:54:42.943" Score="1" ViewCount="137" Body="&lt;p&gt;I know &lt;code&gt;&amp;lt;C-w&amp;gt; =&lt;/code&gt; equalises window sizes but I often want to keep the heights as they are. I have &lt;code&gt;set noequalalways&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; as leaving it on ruins layouts when temporary windows open (like Tagbar). I thought there'd be a one-liner to do this.&lt;/p&gt;&#xA;" OwnerUserId="8520" LastActivityDate="2021-07-30T00:54:15.717" Title="How do I make the current tab's windows equal width but leave their heights?" Tags="|key-bindings|vimscript|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20159" PostTypeId="2" ParentId="20158" CreationDate="2019-05-30T02:54:42.943" Score="1" Body="&lt;p&gt;I ended up writing a plugin &lt;code&gt;~/.vim/plugin/equalise-window-widths.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-viml prettyprint-override&quot;&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;= :call EqualiseWindowWidths()&amp;lt;CR&amp;gt;&#xA;&#xA;function! EqualiseWindowWidths()&#xA;    let l:i = 1&#xA;    let l:n = winnr('$')&#xA;    let l:wfh = ['dummy']&#xA;    let l:wfw = ['dummy']&#xA;    while l:i &amp;lt;= l:n&#xA;        let l:wfh = add(l:wfh, getwinvar(l:i, '&amp;amp;winfixheight', 0))&#xA;        call setwinvar(l:i, '&amp;amp;winfixheight', 1)&#xA;        let l:wfw = add(l:wfw, getwinvar(l:i, '&amp;amp;winfixwidth', 0))&#xA;        call setwinvar(l:i, '&amp;amp;winfixwidth', 0)&#xA;        let l:i += 1&#xA;    endwhile&#xA;    execute 'wincmd ='&#xA;    let l:i = 1&#xA;    while l:i &amp;lt;= l:n&#xA;        call setwinvar(l:i, '&amp;amp;winfixheight', l:wfh[l:i])&#xA;        call setwinvar(l:i, '&amp;amp;winfixwidth', l:wfw[l:i])&#xA;        let l:i += 1&#xA;    endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=5819&quot; rel=&quot;nofollow noreferrer&quot;&gt;It's on Vim scripts&lt;/a&gt; so you can install it with your preferred plugin manager. It doesn't add any mappings so you may want to add the example, above, to your &lt;code&gt;vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8520" LastEditorUserId="8520" LastEditDate="2021-07-30T00:54:15.717" LastActivityDate="2021-07-30T00:54:15.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20160" PostTypeId="2" ParentId="20153" CreationDate="2019-05-30T12:00:45.900" Score="1" Body="&lt;p&gt;As Herb Wolfe wrote in his comment this is a problem with the viminfo file. On Windows this is &lt;code&gt;$HOME\_viminfo&lt;/code&gt; (&lt;code&gt;~/.viminfo&lt;/code&gt; on Unix).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The viminfo files is written when Vim exits and stores information to be available when Vim starts again. This contains command line history, search history, register and a lot more. See &lt;code&gt;:help viminfo&lt;/code&gt; for the details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason your viminfo file became invalid and Vim is complaining about this. When the file is invalid, Vim will not overwrite it. So it will complain about the invalid file on every restart. My terminal Vim also complains on exit (I &quot;destroyed&quot; my viminfo on purpose to write this answer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess that repairing this file is not trivial, so the easiest solution is to just delete or rename it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I have no idea &lt;em&gt;how&lt;/em&gt; a viminfo file might become invalid. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: If you get a error message with a &lt;code&gt;E...&lt;/code&gt; ID, always feed that ID to the help command. Like: &lt;code&gt;:help E576&lt;/code&gt;. This might not explain the actual error, but you get at least some context.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-05-30T12:00:45.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20161" PostTypeId="1" CreationDate="2019-05-30T15:57:25.827" Score="2" ViewCount="1396" Body="&lt;p&gt;In Vim I can switch between tab pages with &lt;code&gt;:tabnext-&lt;/code&gt; to go left and &lt;code&gt;tabnext+&lt;/code&gt; to go right, simulating the tabs on an IDE. In Tmux I can switch between windows using &lt;code&gt;&amp;lt;prefix&amp;gt;p&lt;/code&gt; and &lt;code&gt;&amp;lt;prefix&amp;gt;n&lt;/code&gt; respectively. I'd like to combine these functions: &#xA;I'm trying to remap the &lt;kbd&gt;Alt&lt;/kbd&gt;&lt;kbd&gt;left&lt;/kbd&gt; and &lt;kbd&gt;Alt&lt;/kbd&gt;&lt;kbd&gt;right&lt;/kbd&gt; keys to switch between tab pages in Vim and session windows (which are like tabs) in Tmux when Tmux is available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.codeography.com/2014/06/19/navigating-vim-and-tmux-splits&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.codeography.com/2014/06/19/navigating-vim-and-tmux-splits&lt;/a&gt;&#xA;The plugin 'Vim-Tmux-Navigator' provides a way to seamlessly navigate between Tmux and Vim panes via   for left and right and  and  for up and down. (It looks like when the window number in Vim is maxed it just sends the key commands to Tmux so that there's no need for me to think about which pane in which window I want to switch to.) I'm trying to do the same thing but for switching between Vim Tab pages (created via :tabnew) and Tmux Windows (created via c) (not buffers/windows in Vim or panes in Tmux but tab pages vs Windows).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I've tried&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In ~/.vimrc I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('$TMUX')&#xA;    function! TmuxOrTabSwitch(tabcmd, tmuxdir)                                                                      &#xA;        let previous_winnr = tabpagenr()&#xA;        silent! execute &quot;tabnext &quot; . a:tabcmd&#xA;        if previous_winnr == tabpagenr()                                                                         &#xA;            call system(&quot;tmux select-window -t &quot; . a:tmuxdir)&#xA;            redraw!&#xA;        endif&#xA;    endfunction&#xA;&#xA;    let previous_title = substitute(system(&quot;tmux display-message -p '#{pane_title}'&quot;), '\n', '', '')&#xA;    let &amp;amp;t_ti = &quot;\&amp;lt;Esc&amp;gt;]2;vim\&amp;lt;Esc&amp;gt;\\&quot; . &amp;amp;t_ti&#xA;    let &amp;amp;t_te = &quot;\&amp;lt;Esc&amp;gt;]2;&quot;. previous_title . &quot;\&amp;lt;Esc&amp;gt;\\&quot; . &amp;amp;t_te&#xA;&#xA;    nnoremap &amp;lt;silent&amp;gt; &amp;lt;A-Left&amp;gt; :call TmuxOrTabSwitch('-', '-')&amp;lt;cr&amp;gt;&#xA;    nnoremap &amp;lt;silent&amp;gt; &amp;lt;A-Right&amp;gt; :call TmuxOrTabSwitch('+', '+')&amp;lt;cr&amp;gt;                                                &#xA;else&#xA;    noremap &amp;lt;A-Left&amp;gt;  :tabprevious&amp;lt;Cr&amp;gt;&#xA;    noremap &amp;lt;A-Right&amp;gt; :tabnext&amp;lt;Cr&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In ~/.tmux.conf I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Move Window left and right&#xA;bind -n M-Left run &quot;(tmux display-message -p '#{pane_title}' | grep -iq vim &amp;amp;&amp;amp; tmux send-keys M-Left) || tmux select-window -t -&quot;&#xA;bind -n M-Right run &quot;(tmux display-message -p '#{pane_title}' | grep -iq vim &amp;amp;&amp;amp; tmux send-keys M-Right) || tmux select-window -t +&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this doesn't work! How can I get this to work the way I described above? Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="21571" LastEditorUserId="21571" LastEditDate="2019-06-06T20:28:41.790" LastActivityDate="2019-06-06T20:28:41.790" Title="Vim+Tmux: How to switch between Tmux Windows and Vim Tab Pages Seamlessly using the Alt Key?" Tags="|vimscript|tmux|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="20162" PostTypeId="2" ParentId="20151" CreationDate="2019-05-30T17:06:25.550" Score="2" Body="&lt;p&gt;This seems like a prime case for a &lt;a href=&quot;https://vimhelp.org/motion.txt.html#text-objects&quot; rel=&quot;nofollow noreferrer&quot;&gt;text object&lt;/a&gt;, but unfortunately, Vim doesn't recognize &lt;code&gt;```{R}&lt;/code&gt; or &lt;code&gt;```&lt;/code&gt; as text object delimiters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's at least three options that do work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Click and drag with the mouse. A bit blasphemous, perhaps, but it can get the job done if there's not too much needing to be selected and your Vim or equivalent was built with mouse support.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; Position your cursor on the first line of what you want selected, press &lt;kbd&gt;Shift + v&lt;/kbd&gt;, then use &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt; or &lt;kbd&gt;j&lt;/kbd&gt; to jump down to the last line you want selected. Having visible line numbers can be helpful here. Absolute line numbers for the count for &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt;, relative line numbers for the count for &lt;kbd&gt;j&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; This requires a little set up, but doesn't require you to think about how many lines you're selecting, and makes repeated use almost trivial.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @/ = &quot;```&quot;&#xA;:let @a = gnVnkoj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can then be used by positioning the cursor above the section you want to select (even above the delimiter, but after any preceding sections' delimiters), then just running &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first line, simply sets the &quot;last used&quot; search pattern without actually jumping to it by directly setting the search register. The second line sets up a macro in the &lt;code&gt;a&lt;/code&gt; register. &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt; jumps to the next item of the last used search pattern (should the the opening delimiter) and enters visual mode, selecting it. &lt;kbd&gt;Shift+v&lt;/kbd&gt; switches to line-wise visual mode. &lt;kbd&gt;n&lt;/kbd&gt; jumps to the next found instance of the search pattern (should be the closing delimiter). &lt;kbd&gt;k&lt;/kbd&gt; moves up a line to deselect the delimiter. &lt;kbd&gt;o&lt;/kbd&gt; moves the cursor to the other end of the selection and &quot;reverses&quot; the selection, so it starts at the bottom and ends at the top, where the cursor now is.  &lt;kbd&gt;j&lt;/kbd&gt; moves down a line to deselect the opening delimiter.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastActivityDate="2019-05-30T17:06:25.550" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20165" PostTypeId="2" ParentId="20151" CreationDate="2019-05-31T02:03:23.513" Score="1" Body="&lt;p&gt;You can try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ggqrq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute '/\%&amp;gt;' . line('.') . 'l^```{r}' | +1,/^```$/-1y R | normal @:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What it does:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gg&lt;/code&gt;  goes to first position in the buffer;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;qrq&lt;/code&gt; starts to record a macro on register &lt;code&gt;r&lt;/code&gt; and ends it immediately; it simply clears the register &lt;code&gt;r&lt;/code&gt;;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:execute '/\%&amp;gt;' . line('.') . 'l^```{r}'&lt;/code&gt; searches for a line after current one (see &lt;code&gt;:help /\%&amp;gt;l&lt;/code&gt;) with the pattern &lt;code&gt;^```{r}&lt;/code&gt;;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;|&lt;/code&gt; separates this command from the next;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;+1,/^```$/-1y R&lt;/code&gt; yanks to register &lt;code&gt;R&lt;/code&gt; from the next line till the next one that starts with &lt;code&gt;^```$&lt;/code&gt; less one; as we used capital &lt;code&gt;R&lt;/code&gt;, the new content is appended to what was already there; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;|&lt;/code&gt; separates this command from the next;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;normal @:&lt;/code&gt; re-executes last &lt;code&gt;:&lt;/code&gt; command (this whole line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the end you will have all the content you want in the &lt;code&gt;r&lt;/code&gt; register.&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-05-31T02:03:23.513" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20166" PostTypeId="1" AcceptedAnswerId="20167" CreationDate="2019-05-31T02:39:39.213" Score="1" ViewCount="96" Body="&lt;p&gt;My &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; key is &lt;code&gt;,&lt;/code&gt; and for convenience I'm using for a few years now the &lt;code&gt;;&lt;/code&gt; normal-mapped as a &lt;code&gt;:&lt;/code&gt;, to save me a key stroke to type &lt;code&gt;:commands&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I know that &lt;code&gt;,&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt; are shortcuts themselves, to repeat last &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;F&lt;/code&gt; commands and the inverse.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;; and ,         Repeat latest f, t, F or T [count] times. See :help cpo-;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to map them to be &lt;code&gt;&amp;lt;leader&amp;gt; ;&lt;/code&gt; and &lt;code&gt;&amp;lt;leader&amp;gt; ,&lt;/code&gt;, so I don't lose this functionality. So, if I type &lt;code&gt;,;&lt;/code&gt; it will act as &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,,&lt;/code&gt; will do as a single &lt;code&gt;,&lt;/code&gt;. I can't wrap my head around this mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions? Thanks.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;edited:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following configurations/maps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader=',' &#xA;nnoremap ; :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13368" LastEditorUserId="10604" LastEditDate="2019-05-31T03:47:50.883" LastActivityDate="2019-05-31T03:47:50.883" Title="mapping &lt;leader&gt;; and &lt;leader&gt;, to ; and , respectively" Tags="|key-bindings|leader|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20167" PostTypeId="2" ParentId="20166" CreationDate="2019-05-31T03:02:01.010" Score="3" Body="&lt;p&gt;If you simply need to create this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;, ,&#xA;nnoremap &amp;lt;leader&amp;gt;; ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OP mentions &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; is comma, via &lt;code&gt;let mapleader = ','&lt;/code&gt; or similar. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-05-31T03:02:01.010" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20168" PostTypeId="2" ParentId="20151" CreationDate="2019-05-31T07:28:52.897" Score="1" Body="&lt;h3&gt;&lt;code&gt;if&lt;/code&gt; of vim-textobj-markdown&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;When you use vim and do not mind to use a plugin, you can always check&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/kana/vim-textobj-user/wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kana/vim-textobj-user/wiki&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case you will find the plugin &lt;a href=&quot;https://github.com/coachshea/vim-textobj-markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/coachshea/vim-textobj-markdown&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin maps by default &lt;code&gt;if&lt;/code&gt; to address the inner of a code block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are more plugins which you could consider, e.g.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/machakann/vim-sandwich&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sandwich&lt;/a&gt; provides interactive text objects by querying the beginning and end specifier:&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/machakann/vim-sandwich/blob/master/doc/textobj-sandwich.txt#L148-L149&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;is &amp;lt;Plug&amp;gt;(textobj-sandwich-query-i)&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also creating your own textobject would be an option:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vim.fandom.com/wiki/Creating_new_text_objects&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vim.fandom.com/wiki/Creating_new_text_objects&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you get fancy, you could write a plugin based on &lt;a href=&quot;https://github.com/wellle/targets.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;targets.vim&lt;/a&gt; similar to &lt;a href=&quot;https://github.com/wellle/line-targets.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;line-targets.vim&lt;/a&gt; to get a very comprehensive experience of textobjects, something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if  af  If  Af&#xA;inf anf Inf Anf&#xA;ilf alf Ilf Alf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a pending &lt;a href=&quot;https://github.com/lervag/vimtex/pull/1384&quot; rel=&quot;nofollow noreferrer&quot;&gt;PR&lt;/a&gt; for &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt; (a LaTeX plugin) to define textobjects for LaTeX commands and environments based on targets.vim: see the &lt;a href=&quot;https://github.com/kiryph/vimtex/blob/text_obj_targets/cheatsheet.md#environments&quot; rel=&quot;nofollow noreferrer&quot;&gt;cheatsheet for a quick look&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I doubt that any of this will help you in RStudio.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-05-31T07:36:58.733" LastActivityDate="2019-05-31T07:36:58.733" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20169" PostTypeId="1" CreationDate="2019-05-31T08:35:42.480" Score="1" ViewCount="19" Body="&lt;p&gt;When I enter insert mode using &lt;code&gt;o&lt;/code&gt; or &lt;code&gt;O&lt;/code&gt; when programming, the cursor appears at the correct level of indentation. In this example below, X is the place where I press &lt;code&gt;o&lt;/code&gt; and &lt;code&gt;Y&lt;/code&gt; is where my cursor appears.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func doX() error{X&#xA;      Y&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I'd do this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func doX() error{&#xA;X&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now where I press X is also where my cursor appears. What I want is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func doX() error{&#xA;X    Y&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hopefully this makes sense!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;o/O&lt;/code&gt; enter newlines whilst &lt;code&gt;i&lt;/code&gt; just goes to insert mode, I expect that to be the 'problem' but I'm wondering if this can be fixed? I don't want &lt;code&gt;i&lt;/code&gt; to enter a new line, just to start editting at the right indentation point. (If the line is empty). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Preferably another key than &lt;code&gt;i&lt;/code&gt; :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="16963" LastActivityDate="2019-05-31T08:35:42.480" Title="Get correct indentation when entering insert mode" Tags="|insert-mode|" AnswerCount="0" CommentCount="3" ClosedDate="2019-06-01T01:19:48.520" ContentLicense="CC BY-SA 4.0" />
  <row Id="20170" PostTypeId="2" ParentId="9757" CreationDate="2019-05-31T10:30:43.537" Score="1" Body="&lt;p&gt;Below left is downloaded zip format of a plugin, right is created by 'get clone &lt;a href=&quot;https://plugin/path&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://plugin/path&lt;/a&gt;' command in Git Bash.&lt;br&gt;&#xA;Left is equivalent to the plugin you wrote locally. Although the plugin itself is the same, 'get clone' command will also create .git directory which contains git repo files.&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/RXk3Q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RXk3Q.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;If install the left side plugin, Vundle will complain &quot;does not appear to be a git repository&quot;. &#xA;So you need to create your own local git repo.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Install latest git from https://git-scm.com/download&#xA;cd to your plugin directory&#xA;Type git init.&#xA;Type git add to add the files (see the typical use page).&#xA;Type git commit.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More details can be found in &lt;a href=&quot;https://kbroman.org/github_tutorial/pages/init.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://kbroman.org/github_tutorial/pages/init.html&lt;/a&gt;&lt;br&gt;&#xA;Once local git repo is created, you can install it with &lt;code&gt;Plugin 'file:///home/gmarik/path/to/plugin'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2019-05-31T10:30:43.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20171" PostTypeId="1" AcceptedAnswerId="20175" CreationDate="2019-05-31T11:41:48.533" Score="2" ViewCount="893" Body="&lt;p&gt;I often want to open files using the wildcards like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e **/foo.bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However every now and then I get an&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E77: Too many file names&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I would like to have would be to add to that error message a list of the files found. That way, I can get the path to the one I want. I know that I can do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:arga **/foo.bar&#xA;:ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I would like to have it run automatically. For example populating the &lt;code&gt;quickfix&lt;/code&gt; list, or something like that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An idea would be to catch the &lt;code&gt;E77&lt;/code&gt; and run some command to list them.&lt;/p&gt;&#xA;" OwnerUserId="2170" LastActivityDate="2019-05-31T14:20:47.083" Title="List files if there are too many of them" Tags="|error|open|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20172" PostTypeId="2" ParentId="20171" CreationDate="2019-05-31T12:55:04.263" Score="1" Body="&lt;p&gt;I don't like &lt;code&gt;quickfix&lt;/code&gt; in this case, i think &lt;code&gt;input&lt;/code&gt; is better. I did both of them, choose the one you like.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:edit(pattern)&#xA;  let files = glob(a:pattern, 0, 1)&#xA;&#xA;  &quot; do nothing if no file matches&#xA;  if empty(files) | return | endif&#xA;&#xA;  &quot; open single result&#xA;  if len(files) == 1&#xA;    exec 'e ' . files[0]&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; otherwise warn and populate qflist&#xA;  &quot; echohl WarningMsg&#xA;  &quot; echo &quot;too many files : \n\n&quot; . join(files, &quot;\n&quot;)&#xA;  &quot; echohl None&#xA;&#xA;  &quot; call setqflist(map(files, '{&quot;filename&quot;: v:val}'))&#xA;  &quot; copen&#xA;&#xA;  &quot; otherwise let user select one&#xA;  let items = map(deepcopy(files), ' (v:key+1) . &quot; : &quot; . v:val ')&#xA;  let choice = input(&#xA;        \ &quot;too many files : \n\n&quot; . join(items, &quot;\n&quot;) . &quot;\n\nselect file : &quot;)&#xA;  if empty(choice) || choice &amp;lt;= 0 || choice &amp;gt; len(files)&#xA;    return&#xA;  endif&#xA;  exec 'e ' . files[choice - 1]&#xA;endfunction&#xA;&#xA;command! -nargs=+ -complete=file E call s:edit(&amp;lt;q-args&amp;gt;)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't use it. I prefer &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf.vim&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-05-31T12:55:04.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20173" PostTypeId="1" CreationDate="2019-05-31T13:39:22.923" Score="3" ViewCount="106" Body="&lt;p&gt;I'm searching through a big text file and want to copy certain lines to another file - there is no specific pattern,&#xA;I need to visually inspect and copy those lines to an external file.&#xA;The command &lt;code&gt;:2400p&lt;/code&gt; prints line 2400 to the Vim command line, but I can't get it to write (append) it to another file.&#xA;I could use more or less but not sure that would help any better.&lt;/p&gt;&#xA;" OwnerUserId="22489" LastEditorUserId="21251" LastEditDate="2019-06-01T01:59:27.013" LastActivityDate="2019-06-01T01:59:27.013" Title="How do I pick a line and write it to an external file?" Tags="|cygwin|original-vim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20174" PostTypeId="2" ParentId="20173" CreationDate="2019-05-31T13:47:58.687" Score="6" Body="&lt;p&gt;You can use &lt;code&gt;:[range]w &amp;gt;&amp;gt; file&lt;/code&gt; to append the given range to the given file. If the file does not yet exist, use the &lt;code&gt;!&lt;/code&gt; argument to the &lt;code&gt;:w&lt;/code&gt; command to force writing the new file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this means you can use &lt;code&gt;:2400w &amp;gt;&amp;gt; my_custom.txt&lt;/code&gt; to write line 2400 to my_custom.txt file, or if your cursor is on the current line already, you can simply use &lt;code&gt;:.w &amp;gt;&amp;gt; my_custom.txt&lt;/code&gt; (which could then e.g. be used by a &lt;code&gt;:g&lt;/code&gt; command, to write lines matching a certain pattern).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-05-31T13:47:58.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20175" PostTypeId="2" ParentId="20171" CreationDate="2019-05-31T14:20:47.083" Score="3" Body="&lt;h3&gt;Completion&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; to complete a filename. If you know there are going to be many candidates then you can use &lt;code&gt;&amp;lt;c-d&amp;gt;&lt;/code&gt; to list out the candidates. May want to look into &lt;code&gt;'wildmenu'&lt;/code&gt; &amp;amp; &lt;code&gt;'wildemode'&lt;/code&gt; settings as well.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Argument List&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:next&lt;/code&gt; with your argument to populate the argument list.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:next **/foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use &lt;code&gt;:next&lt;/code&gt;/&lt;code&gt;:prev&lt;/code&gt; to move along the argument list. Use &lt;code&gt;:args&lt;/code&gt; to show the list.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Catching the error with &lt;code&gt;try&lt;/code&gt;/&lt;code&gt;catch&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In order to catch &lt;code&gt;E77&lt;/code&gt; you will need to create a custom command and then use &lt;code&gt;:try&lt;/code&gt; &amp;amp; &lt;code&gt;:catch&lt;/code&gt; blocks.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -complete=file -nargs=1 -bar EList call s:elist(&amp;lt;f-args&amp;gt;)&#xA;function! s:elist(path)&#xA;    try&#xA;        silent execute 'edit ' . a:path&#xA;    catch /^Vim\%((\a\+)\)\=:E77:/&#xA;        cexpr getcompletion(a:path, 'file')&#xA;        cwindow&#xA;    endtry&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-05-31T14:20:47.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20176" PostTypeId="2" ParentId="20136" CreationDate="2019-05-31T14:46:09.890" Score="2" Body="&lt;p&gt;Thanks to &lt;a href=&quot;https://vi.stackexchange.com/questions/20136/how-do-i-properly-set-up-airline-and-powerline-fonts-with-gvim#comment35241_20136&quot;&gt;Christian Brabandt&lt;/a&gt;, I found the issue.&lt;/p&gt;&#xA;&lt;p&gt;The problem is the encoding. The reason it worked in Cygwin is because I could specify the global encoding used in the terminal without any Vim config, where as gVim appears to rely more on the content of the config file.&lt;/p&gt;&#xA;&lt;p&gt;I added this to the top of &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=utf-8&#xA;set fileencoding=utf-8&#xA;set termencoding=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that this requires a gVim restart to work. Using &lt;code&gt;:set encoding=utf-8&lt;/code&gt; produces more visual artifacts and HTML render failure on top of the other problems.&lt;/p&gt;&#xA;" OwnerUserId="21251" LastEditorUserId="21251" LastEditDate="2021-12-15T19:43:25.760" LastActivityDate="2021-12-15T19:43:25.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20177" PostTypeId="1" AcceptedAnswerId="20232" CreationDate="2019-05-31T14:57:09.453" Score="2" ViewCount="432" Body="&lt;p&gt;The &lt;code&gt;ctrl+A&lt;/code&gt; command to increment numbers is super handy, but it doesn't work in languages that don't use C-style &lt;code&gt;0x&lt;/code&gt; and &lt;code&gt;0&lt;/code&gt; prefixes for hexadecimal and octal numbers. In SystemVerilog, hexadecimal numbers are written as &lt;code&gt;&amp;lt;length_in_bits&amp;gt;'h&amp;lt;hex_number&amp;gt;&lt;/code&gt;. (A capital H will also work). Is there a way to add this number format to Vim so I can increment it with the command?&lt;/p&gt;&#xA;" OwnerUserId="22490" LastActivityDate="2019-06-07T00:59:40.967" Title="Custom Number Format for CTRL+A" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20178" PostTypeId="2" ParentId="20078" CreationDate="2019-05-31T16:57:30.187" Score="1" Body="&lt;p&gt;Expanding on &lt;a href=&quot;https://vi.stackexchange.com/users/343/rich&quot;&gt;Rich's&lt;/a&gt; answer, here is my ready-to-roll solution with keymap and ignoring blank lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ShowContext() abort&#xA;  let items = []&#xA;  let l = line('.')&#xA;  let indent = 1000&#xA;  while l &amp;gt;= 0&#xA;    &quot; added test to ignore blank lines&#xA;    if indent(l) &amp;lt; indent &amp;amp;&amp;amp; getline(l) != ''&#xA;      call add(items, getline(l))&#xA;      let indent = indent(l)&#xA;      if indent == 0&#xA;        break&#xA;      endif&#xA;    endif&#xA;    let l -= 1&#xA;  endwhile&#xA;  lgetexpr reverse(items)&#xA;endfunction&#xA;&#xA;let w:contextlist_open = 0&#xA;function! Toggle_contextlist()&#xA;    if w:contextlist_open == 1&#xA;        let w:contextlist_open = 0&#xA;        autocmd! ContextList&#xA;        above lclose&#xA;    else&#xA;        let w:contextlist_open = 1&#xA;        augroup ContextList&#xA;            autocmd!&#xA;            autocmd CursorHold * call ShowContext()&#xA;        augroup END&#xA;        above lopen&#xA;        wincmd p&#xA;    endif&#xA;endfunction&#xA;nnoremap &amp;lt;leader&amp;gt;lc :call Toggle_contextlist()&amp;lt;CR&amp;gt;&#xA;&#xA;autocmd BufWinEnter * let w:locallist_open = 0&#xA;autocmd BufWinEnter * let w:contextlist_open = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19915" LastEditorUserId="19915" LastEditDate="2019-05-31T17:49:37.783" LastActivityDate="2019-05-31T17:49:37.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20179" PostTypeId="1" AcceptedAnswerId="20180" CreationDate="2019-05-31T18:23:29.283" Score="3" ViewCount="94" Body="&lt;p&gt;First, I typed &lt;code&gt;2V&lt;/code&gt; to select two lines, and &lt;code&gt;y&lt;/code&gt; to yank them. Then I typed &lt;code&gt;3V&lt;/code&gt;, and instead of selecting 3 lines, Vim selects 6 lines. Next I typed &lt;code&gt;4V&lt;/code&gt; and Vim selected 8 lines. It seems that 3 or 4 in the later selections are multiplied by  the 2 in the first selection for yanking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is that?&lt;/p&gt;&#xA;" OwnerUserId="22494" LastEditorUserId="22494" LastEditDate="2019-06-01T01:59:59.870" LastActivityDate="2019-06-01T01:59:59.870" Title="Why is this appearing to select wrong number of lines?" Tags="|cut-copy-paste|visual-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20180" PostTypeId="2" ParentId="20179" CreationDate="2019-05-31T20:23:11.433" Score="2" Body="&lt;p&gt;Although it seem counter intuitive, this behaviour seems to be the expected one. From &lt;code&gt;:help V&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[count]V            Start Visual mode linewise.                                                                                                                                                                &#xA;                    With [count] select the same number of lines as used                                                                                                                                       &#xA;                    for the last Visual operation, but at the current                                                                                                                                          &#xA;                    cursor position, multiplied by [count].  When there                                                                                                                                        &#xA;                    was no previous Visual operation [count] lines are                                                                                                                                         &#xA;                    selected.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-05-31T20:23:11.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20181" PostTypeId="2" ParentId="20179" CreationDate="2019-05-31T23:42:15.427" Score="2" Body="&lt;p&gt;To be precise, &lt;code&gt;[count]V&lt;/code&gt; select &lt;code&gt;[count] * (lines of last visual operation)&lt;/code&gt; lines if and only if last visual operation is linewise (V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact if last visual operation exists, &lt;code&gt;[count]v&lt;/code&gt;, &lt;code&gt;[count]V&lt;/code&gt; and &lt;code&gt;[count]&amp;lt;c-v&amp;gt;&lt;/code&gt; are the same, they select &lt;code&gt;[count] * (visual area of last visual operation)&lt;/code&gt; in the same wise mode with last visual operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If last visual operation doesn't exist, &lt;code&gt;[count]v&lt;/code&gt; select &lt;code&gt;[count]&lt;/code&gt;characters to right, &lt;code&gt;[count]V&lt;/code&gt; select &lt;code&gt;[count]&lt;/code&gt; lines down, &lt;code&gt;[count]&amp;lt;c-v&amp;gt;&lt;/code&gt; select the same area with &lt;code&gt;[count]v&lt;/code&gt; but in block wise.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-05-31T23:42:15.427" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20182" PostTypeId="1" AcceptedAnswerId="20183" CreationDate="2019-06-01T01:24:27.157" Score="2" ViewCount="795" Body="&lt;p&gt;I'm able to find empty lines with &lt;code&gt;/^$&lt;/code&gt;, but when I go to remove them using &lt;code&gt;:%s/^$//&lt;/code&gt;, nothing seems to happen. Yet, some form of substitution is being made, because the status line reads &lt;code&gt;XX substitutions on XX lines&lt;/code&gt; where &lt;code&gt;XX&lt;/code&gt; is the number of empty lines in the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What substitutions are being made, as indicated by the status line?&lt;/li&gt;&#xA;&lt;li&gt;How do I accomplish what I want to do (eliminate empty lines from a file)?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="14480" LastActivityDate="2019-06-02T12:46:32.260" Title="Remove empty lines from a file" Tags="|substitute|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20183" PostTypeId="2" ParentId="20182" CreationDate="2019-06-01T03:23:42.353" Score="8" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; and &lt;code&gt;$&lt;/code&gt; are &lt;em&gt;zero-width&lt;/em&gt; items, so when you do &lt;code&gt;:%s/^$//&lt;/code&gt; you’re substituting zero characters for zero characters&lt;/li&gt;&#xA;&lt;li&gt;To actually perform the substitution, the idioms are&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&#xA;:g/^$/d&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^$/j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-06-02T12:46:32.260" LastActivityDate="2019-06-02T12:46:32.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20184" PostTypeId="1" AcceptedAnswerId="20187" CreationDate="2019-06-01T09:15:30.627" Score="0" ViewCount="71" Body="&lt;p&gt;Here's my use case. I have the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a [hyperlink](http://someurl.com).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to replace the &lt;code&gt;http://someurl.com&lt;/code&gt; text with a new URL in the default register (something I've copied from somewhere else).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, I would move to the line, then probably do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f(    # move to the opening bracket   &#xA;vi(   # select the contents of the brackets&#xA;p     # paste from the default register&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any out-of-the box way to make this faster? What I'm looking for is an operation which pastes over a motion, such as &quot;replace-in-whatever&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f(    # move to the opening bracket   &#xA;pi(   # paste *over* the contents of the brackets&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am guessing I'd need to manually create something for this, but before I look for plugins/commands, I wanted to check if there was a standard, idiomatic way (and also ideally one which supports pasting from any register if possible!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance! &lt;/p&gt;&#xA;" OwnerUserId="12921" LastEditorUserId="12921" LastEditDate="2019-06-05T00:31:35.300" LastActivityDate="2019-06-05T00:31:35.300" Title="Can I select and paste with a single operation?" Tags="|cursor-motions|replace|paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20185" PostTypeId="2" ParentId="20155" CreationDate="2019-06-01T10:45:26.820" Score="4" Body="&lt;p&gt;It is a bad habit to do spaces and remarks in the same line of the mapping. I believe it includes them in the mapping and it causes the beep(about the remark I am not sure). So try to remove them and see what happens.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have asked a similar question &lt;a href=&quot;https://vi.stackexchange.com/questions/17737/beep-upon-using-a-mapping&quot;&gt;Beep upon using a mapping&lt;/a&gt; . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a temporary solution: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set visualbell t_vb=&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disables all beeps &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-06-01T10:45:26.820" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20186" PostTypeId="2" ParentId="20126" CreationDate="2019-06-01T11:08:54.217" Score="0" Body="&lt;p&gt;I still don't know why, but this seems to solve it. It is a nice way to search for commands, so recommended. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HandleCommand(item)&#xA;    call feedkeys(&quot;q:&quot;)&#xA;    call feedkeys(&quot;G?\\V&quot;.escape(a:item,'\/?').&quot;\&amp;lt;CR&amp;gt;&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-06-01T11:08:54.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20187" PostTypeId="2" ParentId="20184" CreationDate="2019-06-01T12:27:30.983" Score="1" Body="&lt;p&gt;A custom operator that select and paste from any register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ,p :call &amp;lt;sid&amp;gt;opfunc_reg(&quot;&amp;lt;sid&amp;gt;select_and_paste&quot;)&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; Apply current register to g@ . It's not allowed to set opfunc to s:func, i&#xA;&quot; have to use a func argument.&#xA;&quot;&#xA;&quot; In function scope of normal map, v:register won't be changed by ex&#xA;&quot; command (except :normal) ?&#xA;function! s:opfunc_reg(func)&#xA;  let &amp;amp;opfunc = a:func&#xA;  call feedkeys('&quot;'. v:register .'g@')&#xA;endfunction&#xA;&#xA;function! s:select_and_paste(type) abort&#xA;&#xA;  &quot; back up current register before visual selection&#xA;  let reg = v:register&#xA;&#xA;  &quot; visually select operator target.&#xA;  let vcmd = a:type ==# 'line' ? 'V' : (a:type ==# 'char' ? 'v' : &quot;\&amp;lt;c-v&amp;gt;&quot;)&#xA;  silent exe printf('norm! `[%s`]', vcmd)&#xA;&#xA;  &quot; paste from current register&#xA;  exec 'norm! &quot;' . reg . 'p'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Don't use it&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This operator is useless, because &lt;code&gt;vi)p&lt;/code&gt; is 4 key strokes, &lt;code&gt;,pi)&lt;/code&gt; is also 4 key strokes (can be reduced to 3, which is still meaningless and crazy). One should get used to &lt;code&gt;v{motion}p&lt;/code&gt; style operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I create it only because i'm leaning to create operator that support register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use custom motion or text object, a lot of things could happen between &lt;code&gt;g@&lt;/code&gt; and &lt;code&gt;opfunc&lt;/code&gt;, a single ex command is enough to reset &lt;code&gt;v:register&lt;/code&gt;, to fix that, i have to use a global variable instead of &lt;code&gt;v:register&lt;/code&gt; (not sure if it's the right way):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ,p :let g:__opfunc_reg=v:register&amp;lt;cr&amp;gt;:set opfunc=&amp;lt;sid&amp;gt;select_and_paste&amp;lt;cr&amp;gt;g@&#xA;&#xA;function! s:select_and_paste(type) abort&#xA;&#xA;  &quot; visually select operator target.&#xA;  let vcmd = a:type ==# 'line' ? 'V' : (a:type ==# 'char' ? 'v' : &quot;\&amp;lt;c-v&amp;gt;&quot;)&#xA;  silent exe printf('norm! `[%s`]', vcmd)&#xA;&#xA;  &quot; paste from current register&#xA;  exec 'norm! &quot;' . g:__opfunc_reg . 'p'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-01T23:24:15.737" LastActivityDate="2019-06-01T23:24:15.737" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20188" PostTypeId="1" CreationDate="2019-06-01T09:56:54.767" Score="5" ViewCount="1133" Body="&lt;p&gt;How can I make Vim &lt;strong&gt;not&lt;/strong&gt; remove lines below with Ctrl and Left Arrow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I just found a dangerous setting with Vim on Linux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I press Ctrl and Left Arrow then whole rows below start vanishing. With autosave disabled this could accidentally destroy hours of work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I disable this dangerous behaviour in .vimrc for example?&lt;/p&gt;&#xA;" OwnerDisplayName="Vesa" LastEditorUserId="11357" LastEditDate="2019-06-12T07:35:51.620" LastActivityDate="2022-09-13T18:05:45.340" Title="How can I make Vim NOT remove lines below with Ctrl and Left Arrow?" Tags="|key-bindings|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20189" PostTypeId="1" CreationDate="2019-06-02T11:46:37.167" Score="1" ViewCount="884" Body="&lt;p&gt;I have the following options set (in &lt;code&gt;~/.config/vim/ftplugin/asciidoc.vim&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal wrap&#xA;setlocal textwidth=0&#xA;setlocal wrapmargin=0&#xA;setlocal formatoptions=l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I'm writing text, it's not hard-wrapped automatically at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I need to reformat an existing paragraph, and press &lt;code&gt;gqap&lt;/code&gt;, it's hard-wrapped to fit 79 columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;help gq&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Format the lines that {motion} moves over.&#xA;Formatting is done with one of three methods:&#xA;&#xA;In the third case the 'textwidth' option controls the&#xA;length of each formatted line (see below).&#xA;If the 'textwidth' option is 0, the formatted line&#xA;length is the screen width (with a maximum width of&#xA;79).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to work around this 79 columns limitation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VIM 8.1.&lt;/p&gt;&#xA;" OwnerUserId="8699" LastActivityDate="2019-07-02T14:01:05.113" Title="How to format with `gq` using the same settings as when editing the text" Tags="|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20190" PostTypeId="2" ParentId="20189" CreationDate="2019-06-02T12:15:50.707" Score="1" Body="&lt;p&gt;It turns out a negative value for &lt;code&gt;wrapmargin&lt;/code&gt; helps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal wrapmargin=-1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As per &lt;code&gt;:help wrapmargin&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Number of characters from the right window border where wrapping&#xA;starts.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it seems that the &lt;code&gt;:help gq&lt;/code&gt; docs are not entirely correct, and with &lt;code&gt;textwidth=0&lt;/code&gt;, &lt;code&gt;wrapmargin&lt;/code&gt; is also considered when picking a column to wrap at.&lt;/p&gt;&#xA;" OwnerUserId="8699" LastActivityDate="2019-06-02T12:15:50.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20192" PostTypeId="1" AcceptedAnswerId="20193" CreationDate="2019-06-03T07:13:34.343" Score="6" ViewCount="1765" Body="&lt;p&gt;How can I show the mappings for all function keys &lt;code&gt;&amp;lt;F1&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;F12&amp;gt;&lt;/code&gt; at once? I know that &lt;code&gt;:map &amp;lt;F1&amp;gt;&lt;/code&gt; shows the mapping for &lt;code&gt;&amp;lt;F1&amp;gt;&lt;/code&gt;, and I can repeat this 12 times for each key. But is there a faster way?  I have tried &lt;code&gt;:map &amp;lt;F&lt;/code&gt; but that doesn't work. &lt;/p&gt;&#xA;" OwnerUserId="21495" LastActivityDate="2019-06-04T08:19:40.113" Title="Show mappings for all function keys" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20193" PostTypeId="2" ParentId="20192" CreationDate="2019-06-03T09:34:28.040" Score="6" Body="&lt;p&gt;You could do this with a loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(1, 12) | execute 'map &amp;lt;F'.i.'&amp;gt;' | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't want any output for F-keys without mappings, you can use &lt;code&gt;mapcheck()&lt;/code&gt;, as &lt;a href=&quot;https://vi.stackexchange.com/questions/20192/show-mappings-for-all-function-keys/20193#comment35358_20193&quot;&gt;suggested by @BLayer&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(1, 12) | if !empty(mapcheck('&amp;lt;F'.i.'&amp;gt;')) | execute 'map &amp;lt;F'.i.'&amp;gt;' | endif | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more details, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :for&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :execute&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help range()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help mapcheck()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-06-04T08:19:40.113" LastActivityDate="2019-06-04T08:19:40.113" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20195" PostTypeId="2" ParentId="20192" CreationDate="2019-06-03T11:00:35.737" Score="6" Body="&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Afilter&quot; rel=&quot;nofollow noreferrer&quot;&gt;:filter&lt;/a&gt; allows to filter the output of certain vim commands. Currently, this is not yet supported by every Vim command, but according to &lt;a href=&quot;https://vimhelp.org/map.txt.html#map-listing&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h map-listing&lt;/a&gt;, it should be possible. As the help states:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The :filter command can be used to select what mappings to list.  The&#xA;pattern is matched against the {lhs} and {rhs} in the raw form.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means, you would need to put up a custom filter command with the &lt;strong&gt;raw&lt;/strong&gt; key codes as input to the filter command. I was able to come up with this somewhat convoluted example for all &lt;code&gt;&amp;lt;f&amp;gt;&lt;/code&gt; keys:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe &quot;:filter&quot; join(map(range(1,12), { i,v -&amp;gt; eval('&quot;\&amp;lt;f'.v.'&amp;gt;&quot;')}), '\|') &quot;:map&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This creates a list of each raw &lt;code&gt;&amp;lt;f&amp;gt;&lt;/code&gt; key by using the &lt;code&gt;&quot;\&amp;lt;f1&amp;gt;&quot;&lt;/code&gt; form (which will then be parsed into the correct raw key code by vim (therefore, the &lt;code&gt;eval()&lt;/code&gt; is needed). The resulting list, is then joined together into a regular expression, with each item joined by the &lt;code&gt;\|&lt;/code&gt; regex atom (OR). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the help states, the filter criteria will be applied to both, the left and right side of a mapping, so if the criteria matches the right side, it will be output as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, in order to really get all mapping output, you might as well need the &lt;code&gt;:map!&lt;/code&gt; command to get insert and commandline mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Overall this is a lot more complicated than to use the solution provided by &lt;a href=&quot;https://vi.stackexchange.com/a/20193/71&quot;&gt;Rich&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-06-03T13:44:47.237" LastActivityDate="2019-06-03T13:44:47.237" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20196" PostTypeId="1" CreationDate="2019-06-03T13:41:56.810" Score="1" ViewCount="118" Body="&lt;p&gt;I started learning serious programming since last year. Over the course, I have used various GUI based text editors and IDEs and, I decided to settle with &lt;strong&gt;Sublime Text&lt;/strong&gt; a few months ago. Now I want to switch to a text based editor either Vim or Emacs, most probably Vim. But I am not a particularly fast typer. I am not a total noob but I wouldn't say I am a super user either. According to everything I have learned so far about Vim, you really need to be a power user to start using it but I am thinking about spending a few weeks for learning Vim along with continuing learning as I go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this the right path or should I wait and master important coding and typing skills first, be comfortable and then think about it?&lt;/p&gt;&#xA;" OwnerDisplayName="user22513" LastActivityDate="2019-06-03T14:04:28.613" Title="Do I need to be a fast typer/power user to start using Vim?" Tags="|habit-breaking|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20197" PostTypeId="1" CreationDate="2019-06-03T13:51:20.213" Score="0" ViewCount="66" Body="&lt;p&gt;I have the following to change my cursor from a block into an underline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guicursor=a:hor20-Cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whenever I run &lt;code&gt;df&lt;/code&gt; to delete a range, my cursor is changed back to a block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to source my config to have it as an underscore again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This behaviour seems to happen only with Neovim and not Vim itself.&lt;/p&gt;&#xA;" OwnerUserId="16488" LastActivityDate="2019-06-03T13:51:20.213" Title="My cursor is changed after &quot;df&quot;" Tags="|neovim|cursor|" AnswerCount="0" CommentCount="2" ClosedDate="2019-06-03T14:50:31.293" ContentLicense="CC BY-SA 4.0" />
  <row Id="20198" PostTypeId="2" ParentId="20196" CreationDate="2019-06-03T14:03:44.733" Score="1" Body="&lt;p&gt;No you don't need to be a super fast power typer. You might become one though if you get hooked to it!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suggest you to run the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimtutor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your terminal, go through the tutorial, and after a few lessons, you will quickly see how you feel about it.&lt;/p&gt;&#xA;" OwnerUserId="21621" LastActivityDate="2019-06-03T14:03:44.733" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20199" PostTypeId="2" ParentId="20196" CreationDate="2019-06-03T14:04:28.613" Score="2" Body="&lt;p&gt;Many will tell you that you need good typing skills to use Vim, since (almost) all your interactions with it are on the keyboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I think that Vim is uniquely well suited to people who &lt;em&gt;don't&lt;/em&gt; type well, since once you are fluent in it, you can do so much with so few keystrokes: even hunt-and-peck-typists gain from Vim's modal interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not an entirely theoretical viewpoint: I've on occasion used Vim with my iPhone's software keyboard to write reasonable sized chunks of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whether it's a good idea to learn Vim while you are still learning programming is another issue. While I believe Vim's learning curve is less steep than generally purported, it does still exist, and any brain cycles you are spending on your editor are ones you're &lt;em&gt;not&lt;/em&gt; spending on your code, so it might arguably be better to wait until you're comfortable in your chosen programming language(s) before attempting to use Vim in that area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you intend to treat Vim as a side-hobby though, rather than something you're doing at the &lt;em&gt;same time&lt;/em&gt; as learning programming, then sure, why not! &lt;a href=&quot;https://stackoverflow.com/a/2781607/328936&quot;&gt;Vim is fun&lt;/a&gt;!&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-06-03T14:04:28.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20200" PostTypeId="1" CreationDate="2019-06-03T15:14:04.140" Score="3" ViewCount="1344" Body="&lt;p&gt;With other editors we can select vertical-blocks where each line has the same start column but not the same end-column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print(&quot;&quot;, s.field1);&#xA;print(&quot;&quot;, s.field_long);&#xA;print(&quot;&quot;, s.f);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way in Vim (with a plugin or not) to select the block from the snippet above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;field1&#xA;field_long&#xA;f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can we tell vim to select everything up to a certain character?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more powerful variant could be to tell Vim select everything between two characters going left and right from the currently selected column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT&lt;/em&gt;:&#xA;Doing tricks with &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;v&lt;/kbd&gt; does not work as it always selected a rectangle. Here I vertically selected the &lt;code&gt;f&lt;/code&gt;s and then did &lt;kbd&gt;w&lt;/kbd&gt; for word-skip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IFt7d.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IFt7d.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1542" LastEditorUserId="1542" LastEditDate="2019-07-05T09:56:06.897" LastActivityDate="2019-07-05T09:56:06.897" Title="How to vertically-block-select words of different length?" Tags="|selection|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20201" PostTypeId="2" ParentId="358" CreationDate="2019-06-03T15:25:46.100" Score="1" Body="&lt;p&gt;I wrote a tiny plugin to do this a few years ago: &lt;a href=&quot;https://github.com/airblade/vim-helptab&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-helptab&lt;/a&gt;.  It opens help docs in their own tab when you type &lt;code&gt;:h ...&lt;/code&gt;.  To bypass it you can do &lt;code&gt;:he ...&lt;/code&gt; or &lt;code&gt;:help ...&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2019-06-03T15:25:46.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20202" PostTypeId="2" ParentId="20200" CreationDate="2019-06-03T16:54:40.550" Score="0" Body="&lt;p&gt;If memory serves:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/field1&amp;lt;CR&amp;gt;&amp;lt;C-v&amp;gt;2jf)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-03T16:54:40.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20203" PostTypeId="2" ParentId="12794" CreationDate="2019-06-03T18:09:43.100" Score="5" Body="&lt;p&gt;The method here tries to symlink &lt;code&gt;~/.config/nvim&lt;/code&gt; to &lt;code&gt;~/.vim&lt;/code&gt;, and make the conf compatible with &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# nvim conf dir: ~/.config/nvim&#xA;# vim conf dir: ~/.vim&#xA;# link the 1st as the 2nd with relative links&#xA;&#xA;# Prepare a vimrc file in ~/.config/nvim folder&#xA;ln -sf ./init.vim ~/.config/nvim/vimrc&#xA;&#xA;# Link the whole ~/.config/nvim folder as ~/.vim foler&#xA;ln -sf ./.config/nvim ~/.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After this setup, &lt;code&gt;~/.config/nvim/init.vim&lt;/code&gt; is the real file used as conf. &lt;code&gt;~/.vim/vimrc&lt;/code&gt; is just a link to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we need to make &lt;code&gt;vim&lt;/code&gt; reuse &lt;code&gt;nvim&lt;/code&gt;'s plugin manager, plugins, by changing &lt;code&gt;runtimepath&lt;/code&gt; and &lt;code&gt;packpath&lt;/code&gt;. In fact, the plugin paths are reused automatically, the following fix is reusing the plugin manger. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:is_nvim = has('nvim')&#xA;let g:is_vim8 = v:version &amp;gt;= 800 ? 1 : 0&#xA;&#xA;&quot; Reuse nvim's runtimepath and packpath in vim&#xA;if !g:is_nvim &amp;amp;&amp;amp; g:is_vim8&#xA;  set runtimepath-=~/.vim&#xA;    \ runtimepath^=~/.local/share/nvim/site runtimepath^=~/.vim &#xA;    \ runtimepath-=~/.vim/after&#xA;    \ runtimepath+=~/.local/share/nvim/site/after runtimepath+=~/.vim/after&#xA;  let &amp;amp;packpath = &amp;amp;runtimepath&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://gist.github.com/9013f948345212563ede9c9ee56c6b42&quot; rel=&quot;nofollow noreferrer&quot;&gt;Share confs between vim and nvim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20090" LastEditorUserId="20090" LastEditDate="2019-07-19T11:25:58.150" LastActivityDate="2019-07-19T11:25:58.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20204" PostTypeId="1" CreationDate="2019-06-03T21:38:02.747" Score="0" ViewCount="113" Body="&lt;p&gt;I have noticed that with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set syntax=off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;option set, the gvim screen doesn't flicker when I scroll the page using &lt;code&gt;&amp;lt;PageUp&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;PageDown&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the possible solutions, if some exist, to maintain the colorscheme while having the syntax disabled ?  &lt;/p&gt;&#xA;" OwnerUserId="15254" LastActivityDate="2019-06-03T21:57:02.837" Title="Disabling syntax and maintaining colorscheme [flickering problem]" Tags="|gvim|colorscheme|syntax|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20205" PostTypeId="2" ParentId="20204" CreationDate="2019-06-03T21:57:02.837" Score="2" Body="&lt;p&gt;The syntax files define regions of code and links them to highlight groups, which in turn are colored by the colorscheme. So, if you want to keep your colorscheme for more than just ui elements (status/tabline, etc.), you’ll need to &lt;code&gt;syntax enable&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, there are a few ways to improve the speed of syntax highlighting. See&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/10495/10604&quot;&gt;this very detailed QA&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/2683/10604&quot;&gt;further mention of regexengine and syntime&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;a QA I won’t link to whose answer is effectively &quot;refactor your code to be smaller and you won’t have this problem&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-03T21:57:02.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20206" PostTypeId="1" AcceptedAnswerId="20207" CreationDate="2019-06-03T22:22:39.207" Score="1" ViewCount="1032" Body="&lt;p&gt;I am trying to remap &lt;code&gt;&amp;lt;PageUp&amp;gt;&lt;/code&gt; key to call this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PageUp()&#xA;    let l:line = line('.')&#xA;    if(l:line != 1)&#xA;        if(l:line != winline())&#xA;            :set syntax=off&#xA;            &amp;lt;PageUp&amp;gt;&#xA;            :set syntax=on&#xA;        else&#xA;            normal! 1G&#xA;        endif&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but gvim complains that I cannot do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what is the proper way to use the keys in a function ?&lt;/p&gt;&#xA;" OwnerUserId="15254" LastActivityDate="2019-06-04T03:49:40.660" Title="Using a special key in function" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20207" PostTypeId="2" ParentId="20206" CreationDate="2019-06-04T00:04:25.203" Score="4" Body="&lt;p&gt;First of all, you use the &lt;kbd&gt;PageUp&lt;/kbd&gt; key in Normal mode so the underlying functionality is a Normal mode command. You can't use such commands directly while in an Ex command-line or function/script. You need to use the Ex command &lt;a href=&quot;https://vimhelp.org/various.txt.html#:norm&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:norm&lt;/code&gt;&lt;/a&gt; for this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further, to use &quot;key codes&quot; (&lt;a href=&quot;https://vimhelp.org/intro.txt.html#keycodes&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h key-codes&lt;/code&gt;&lt;/a&gt;) of non-printing characters like &lt;code&gt;&amp;lt;PageUp&amp;gt;&lt;/code&gt; you need to construct the &lt;code&gt;:norm&lt;/code&gt; command as an &lt;a href=&quot;https://vimhelp.org/eval.txt.html#eval&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;expression&lt;/em&gt;&lt;/a&gt; and pass it to the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#:exe&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:exe&lt;/code&gt;&lt;/a&gt; command (see last paragraph of &lt;a href=&quot;https://vimhelp.org/various.txt.html#:norm&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :norm&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That gives us:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;norm \&amp;lt;PageUp&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The double quotes are required as is the &lt;code&gt;\&lt;/code&gt; to escape the keycode and indicate that you want the special meaning not the literal string &quot;&amp;lt;PageUp&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note: Usually we want to use &lt;code&gt;norm!&lt;/code&gt; instead of &lt;code&gt;norm&lt;/code&gt; in order to avoid conflicts with mappings but that's not a critical element of this answer so omitted.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-06-04T00:36:16.727" LastActivityDate="2019-06-04T00:36:16.727" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20208" PostTypeId="2" ParentId="20206" CreationDate="2019-06-04T00:17:09.533" Score="1" Body="&lt;p&gt;To send special key to &lt;code&gt;:normal&lt;/code&gt;, you need to get it's raw code by using &lt;code&gt;&quot;\&amp;lt;key&amp;gt;&quot;&lt;/code&gt; notation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec &quot;norm! \&amp;lt;PageUp&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use raw code directly if you want(not recommended, hard to read):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;norm! &amp;lt;80&amp;gt;kP&#xA;        ^----------&amp;lt;80&amp;gt; is 0x80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;80&amp;gt;kP&lt;/code&gt; is raw code of &lt;code&gt;&amp;lt;PageUp&amp;gt;&lt;/code&gt;, you can enter it like this in normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;=&quot;\&amp;lt;PageUp&amp;gt;&quot;&amp;lt;cr&amp;gt;p&#xA;              ^----------press carriage return&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If raw code of the key doesn't start with &lt;code&gt;0x80&lt;/code&gt;, it's the same as terminal code (not sure), you can use the &lt;code&gt;:h i_CTRL-V&lt;/code&gt; to insert terminal code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;norm! &amp;lt;c-v&amp;gt;&amp;lt;c-p&amp;gt;&#xA;       ^------------press ctrl-v ctrl-p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h :exec&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h quote=&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h string&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-04T03:49:40.660" LastActivityDate="2019-06-04T03:49:40.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20209" PostTypeId="2" ParentId="19565" CreationDate="2019-06-04T02:11:50.733" Score="2" Body="&lt;p&gt;It sounds like you have the &lt;a href=&quot;https://vimhelp.org/options.txt.html#guioptions-a&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;a&quot;&lt;/a&gt; flag set in &lt;a href=&quot;https://vimhelp.org/options.txt.html#&amp;#39;go&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'guioptions'&lt;/code&gt;&lt;/a&gt;. What this does is cause Vim to take control of the window manager's global selection mechanism with the effect that Visually selected text is available for pasting &lt;em&gt;to other applications&lt;/em&gt; as well as Vim. The other effect of this flag is to associate register &lt;code&gt;*&lt;/code&gt; with this global selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anytime you make or expand a Visual selection the global selection (and register &lt;code&gt;*&lt;/code&gt;) is updated. Combined with '&lt;code&gt;clipboard&lt;/code&gt;' having value &lt;a href=&quot;https://vimhelp.org/options.txt.html#clipboard-unnamed&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;unnamed&quot;&lt;/a&gt;, which ties the unnamed register (&lt;code&gt;&quot;&lt;/code&gt;) to &lt;code&gt;*&lt;/code&gt; (and &lt;code&gt;+&lt;/code&gt; in non-X systems), you'll see the behavior you describe: &lt;code&gt;put&lt;/code&gt; draws from &lt;code&gt;*&lt;/code&gt; (== the global selection == the Visual selection), with the result that the Visual selection is overwritten with itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See if &lt;code&gt;:set guioptions-=a&lt;/code&gt; changes the behavior.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-06-04T02:23:08.933" LastActivityDate="2019-06-04T02:23:08.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20210" PostTypeId="1" AcceptedAnswerId="20221" CreationDate="2019-06-04T07:38:27.540" Score="-1" ViewCount="112" Body="&lt;p&gt;My &lt;code&gt;vimrc&lt;/code&gt;: &lt;a href=&quot;https://paste.fedoraproject.org/paste/Wl5jvebADSDoAI4HbIX-hA&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://paste.fedoraproject.org/paste/Wl5jvebADSDoAI4HbIX-hA&lt;/a&gt;&#xA;and my corresponding python file is: &lt;a href=&quot;https://paste.fedoraproject.org/paste/g60mU7xBqGaEuKKWkZ6Rnw&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://paste.fedoraproject.org/paste/g60mU7xBqGaEuKKWkZ6Rnw&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, with ALE, as activated in my vimrc's line 168, should be able to fix problems like &quot;no space around operator&quot; etc. But It is not. &#xA;On the other hand it seems, no fixers is actually loaded. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ALEInfo is: &lt;a href=&quot;https://paste.fedoraproject.org/paste/-H6bujuam3WMuLt1gxer3Q&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://paste.fedoraproject.org/paste/-H6bujuam3WMuLt1gxer3Q&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone kindly show me where my vimrc went wrong?&lt;/p&gt;&#xA;" OwnerUserId="2738" LastEditorUserId="2738" LastEditDate="2019-06-04T07:50:56.063" LastActivityDate="2019-06-05T15:27:33.930" Title="vimrc for ale is creating confusion: is my augroup wrong?" Tags="|vimrc|gvim|plugin-ale|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20211" PostTypeId="2" ParentId="18315" CreationDate="2019-06-04T11:58:09.560" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/ipod825/vim-netranger&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ipod825/vim-netranger&lt;/a&gt;  works pretty well in my opinion. I open it with vsplit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The numbering can be removed. The fact it is a vim window is just an advantage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The real problem is highlighting that only works in the original neovim in the terminal. It can be solved. Let me know if you have done it.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-06-04T11:58:09.560" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20212" PostTypeId="1" AcceptedAnswerId="20213" CreationDate="2019-06-04T17:54:42.443" Score="24" ViewCount="9404" Body="&lt;p&gt;I need to determine whether a certain path exists and points to a directory, like the &lt;code&gt;-d&lt;/code&gt; test in the shell. I know about the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#filereadable()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;filereadable()&lt;/code&gt;&lt;/a&gt; function, which does basically this for files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filereadable({file})                    *filereadable()*&#xA;        The result is a Number, which is TRUE when a file with the&#xA;        name {file} exists, and can be read.  If {file} doesn't exist,&#xA;        or is a directory, the result is FALSE.  {file} is any&#xA;        expression, which is used as a String.&#xA;        If you don't care about the file being readable you can use&#xA;        |glob()|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there an equivalent for directories?&lt;/p&gt;&#xA;" OwnerUserId="671" LastActivityDate="2022-10-12T14:35:59.670" Title="How do I check whether a given directory exists?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20213" PostTypeId="2" ParentId="20212" CreationDate="2019-06-04T17:54:42.443" Score="33" Body="&lt;p&gt;You’re looking for the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#isdirectory()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;isdirectory()&lt;/code&gt;&lt;/a&gt; function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;isdirectory({directory})                *isdirectory()*&#xA;        The result is a Number, which is non-zero when a directory&#xA;        with the name {directory} exists.  If {directory} doesn't&#xA;        exist, or isn't a directory, the result is FALSE.  {directory}&#xA;        is any expression, which is used as a String.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Unlike &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#filereadable()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;filereadable()&lt;/code&gt;&lt;/a&gt;, this function doesn’t check whether the directory is readable; it only checks whether it exists. (Correspondingly, there isn’t a single built-in function to check whether a file exists without also checking that it’s readable. &lt;a href=&quot;https://vi.stackexchange.com/a/16659/671&quot;&gt;This answer&lt;/a&gt; demonstrates how to use the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#glob()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;glob()&lt;/code&gt;&lt;/a&gt; function to do this kind of check.)&lt;/p&gt;&#xA;&lt;p&gt;To summarize,&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;To check whether a file or directory named &lt;code&gt;name&lt;/code&gt; exists,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;!empty(glob(name))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To check whether a file (&lt;em&gt;not&lt;/em&gt; a directory) named &lt;code&gt;file_name&lt;/code&gt; exists,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;!empty(glob(file_name)) &amp;amp;&amp;amp; !isdirectory(file_name)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To check whether a directory (&lt;em&gt;not&lt;/em&gt; a file) named &lt;code&gt;dir_name&lt;/code&gt; exists,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;isdirectory(dir_name)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To check whether a file (&lt;em&gt;not&lt;/em&gt; a directory) named &lt;code&gt;file_name&lt;/code&gt; exists and is readable,&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;filereadable(file_name)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I’m not sure how to check whether a directory (&lt;em&gt;not&lt;/em&gt; a file) of a specified name exists and is readable.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For the forms that use &lt;code&gt;glob()&lt;/code&gt;, don’t forget that certain characters like &lt;code&gt;*&lt;/code&gt; are special and need to be escaped if they occur literally in the filename. See &lt;code&gt;:help wildcard&lt;/code&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="671" LastEditorUserId="671" LastEditDate="2022-10-12T14:35:59.670" LastActivityDate="2022-10-12T14:35:59.670" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20214" PostTypeId="1" AcceptedAnswerId="20215" CreationDate="2019-06-04T20:23:34.397" Score="1" ViewCount="101" Body="&lt;p&gt;The scenario is that the plugin I use (iron.nvim) has a mapping &lt;code&gt;crt&lt;/code&gt; which handle text objects. Ultimately, this mapping is based on a command &lt;code&gt;&amp;lt;Plug&amp;gt;(iron-send-motion)&lt;/code&gt;. I would like to create a new mapping based on it: &lt;code&gt;&amp;lt;localleader&amp;gt;sp&lt;/code&gt; which is to apply &lt;code&gt;&amp;lt;Plug&amp;gt;(iron-send-motion)&lt;/code&gt; on a paragraph -- since I use it often.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way that the existing command can be reused to tailor-make a new mapping?&lt;/p&gt;&#xA;" OwnerUserId="22540" LastActivityDate="2019-06-04T20:48:57.093" Title="How to wrap a command which can handle a text object?" Tags="|neovim|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20215" PostTypeId="2" ParentId="20214" CreationDate="2019-06-04T20:48:57.093" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;nmap&lt;/code&gt; with your &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;localleader&amp;gt;sp &amp;lt;Plug&amp;gt;(iron-send-motion)ap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;May need to add &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; option if this is &lt;code&gt;'filetype'&lt;/code&gt; specific.&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-06-04T20:48:57.093" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20217" PostTypeId="1" AcceptedAnswerId="20545" CreationDate="2019-06-05T08:37:34.250" Score="2" ViewCount="969" Body="&lt;p&gt;Literal terminal code of &lt;code&gt;&amp;lt;f4&amp;gt;&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[OS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;result of &lt;code&gt;set &amp;lt;f4&amp;gt;&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t_k4 &amp;lt;F4&amp;gt;        ^[[14;*~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They are totally different, unlike results of f5-f12 (which are the same except the modifier related sequence).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both of following command will trigger &lt;code&gt;&amp;lt;f4&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call feedkeys('^[OS')&#xA;call feedkeys('^[[14~')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also need to add extra setting to make &lt;code&gt;&amp;lt;c-f[1-4]&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;s-f[1-4]&amp;gt;&lt;/code&gt; work properly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;set &amp;lt;f16&amp;gt;=^[[1;2S&#xA;map &amp;lt;f16&amp;gt; &amp;lt;s-f4&amp;gt;&#xA;&#xA;set &amp;lt;f28&amp;gt;=^[[1;5S&#xA;map &amp;lt;f28&amp;gt; &amp;lt;c-f4&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why are f1-f4 special, what's the relationship between their terminal code and vim's t_xx key codes ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vim8.1-1432 on ubuntu16.04.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-08T00:20:53.460" LastActivityDate="2019-07-07T22:57:15.583" Title="How does vim receive f1-f4?" Tags="|vimrc|vimscript|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20218" PostTypeId="1" AcceptedAnswerId="20219" CreationDate="2019-06-05T07:11:21.067" Score="2" ViewCount="143" Body="&lt;p&gt;How can I build a tag file for Django templates, in order to jump to file definitions of &lt;code&gt;extends&lt;/code&gt; and &lt;code&gt;include&lt;/code&gt; template tags?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the script &lt;code&gt;PROJECT/.git/hooks/ctags-html&lt;/code&gt; I've tried so far&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;#!/bin/sh&#xA;set -e&#xA;PATH=&quot;/usr/local/bin:$PATH&quot;&#xA;dir=&quot;`git rev-parse --git-dir`&quot;&#xA;trap 'rm -f &quot;$dir/$$.tags-html&quot;' EXIT&#xA;git ls-files | \&#xA;  # DOC: ctags --list-kinds-full | grep -i html&#xA;  ctags -R --fields=+l --languages=html \&#xA;      --regex-html='/extends \&quot;([a-zA-Z0-9_-]+\.html)\&quot;/\1/t,templates/' \&#xA;      --html-kinds=+at \&#xA;      -f&quot;$dir/$$.tags-html&quot; $(python -c &quot;import os, sys; print(' '.join('{}'.format(d) for d in sys.path if os.path.isdir(d)))&quot;)&#xA;mv &quot;$dir/$$.tags-html&quot; &quot;$dir/tags-html&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In short, the script does:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Find my git repo files&lt;/li&gt;&#xA;&lt;li&gt;call ctags with html parser on all git repo files + other files from related python packages.&lt;/li&gt;&#xA;&lt;li&gt;generate tags for anchor &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; elements and template tag &lt;code&gt;{% extends &quot;&quot; %}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When I call &lt;code&gt;./git/hooks/ctags.html&lt;/code&gt;, a &lt;code&gt;.git/tags-html&lt;/code&gt; file is generated&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;…&#xA;base.html   /home/dori/.virtualenvs/env/lib/python3.7/site-packages/wagtail/project_template/home/templates/home/home_page.html /^{% templatetag openblock %} extends &quot;base.html&quot; {% templatetag closeblock %}$/;&quot;  t   language:HTML&#xA;base.html   /home/dori/.virtualenvs/env/lib/python3.7/site-packages/wagtail/project_template/project_name/templates/404.html    /^{% templatetag openblock %} extends &quot;base.html&quot; {% templatetag closeblock %}$/;&quot;  t   language:HTML&#xA;base.html   /home/dori/.virtualenvs/env/lib/python3.7/site-packages/wagtail/project_template/search/templates/search/search.html    /^{% templatetag openblock %} extends &quot;base.html&quot; {% templatetag closeblock %}$/;&quot;  t   language:HTML&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then, when opening a template file with vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{% extends &quot;base.html&quot; %}&#xA;&#xA;{% load i18n wagtailcore_tags wagtailimages_tags static %}&#xA;{% load debugger_tags %}&#xA;&#xA;{% block body_class %}template-blogpage{% endblock %}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I set the cursor on &lt;code&gt;base.html&lt;/code&gt; and press &lt;code&gt;CTRL-]&lt;/code&gt; to go to the definition, I only get &lt;code&gt;E426: tag not found: base&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22544" OwnerDisplayName="Fandekasp" LastActivityDate="2019-06-05T13:31:02.313" Title="ctags for django templates" Tags="|ctags|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20219" PostTypeId="2" ParentId="20218" CreationDate="2019-06-05T12:22:38.513" Score="2" Body="&lt;p&gt;The issue you're having is that your tags are filenames with extensions (which include a &quot;.&quot;) but searching for that tag using &lt;code&gt;Ctrl-]&lt;/code&gt; is actually only looking for the base name of the file without the extension.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see that through the error message you're getting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E426: tag not found: base&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can check whether your tags are otherwise working properly with a command such as &lt;code&gt;:tag base.html&lt;/code&gt;, which is looking for the full tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can fix the issue with &lt;code&gt;Ctrl-]&lt;/code&gt; by adding &lt;code&gt;.&lt;/code&gt; to the list of valid keyword characters, which you can do by modifying the &lt;a href=&quot;https://vimhelp.org/options.txt.html#set-option&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'iskeyword'&lt;/code&gt;&lt;/a&gt; option. You can add &lt;code&gt;.&lt;/code&gt; to that option using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword+=.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If what you really want is to jump to files in your work tree, perhaps using the &lt;a href=&quot;https://vimhelp.org/editing.txt.html#gf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;gf&lt;/code&gt;&lt;/a&gt; command is a more straightforward way to do so? You don't really have to generate a tags file to use that command. Though I can see that that would be a problem if you have many files named the same (many &quot;base.html&quot;s in distinct subdirectories of your tree.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can customize the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27path%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'path'&lt;/code&gt;&lt;/a&gt; option to control where commands like &lt;code&gt;gf&lt;/code&gt; will look for files. For example, to search recursively through the whole subtree starting at the current directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path+=**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That might be helpful if your filenames are for the most part unique (which, as mentioned before, might not be the case for you.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(A better alternative to setting &lt;code&gt;path+=**&lt;/code&gt; is to use a fuzzy finder plugin. Or you could be more specific about that setting for your project and file types. In any case, the general idea is that if you're looking for filenames, vim can do that for the most part without the need for an index, so using tags is not necessarily the most appropriate way to accomplish that.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-06-05T13:31:02.313" LastActivityDate="2019-06-05T13:31:02.313" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20220" PostTypeId="2" ParentId="16148" CreationDate="2019-06-05T12:27:09.417" Score="23" Body="&lt;p&gt;There are two kinds of delay when you press &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; in insert mode:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;mapping delay&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you create some improper mapping that starts with &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;esc&amp;gt;x &amp;lt;esc&amp;gt;:echom &quot;balabala&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you press &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, vim will wait &lt;code&gt;:h 'timeoutlen'&lt;/code&gt; milliseconds to see if next key is &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should avoid this kind of mapping in all modes, executes following commands to check if there exists this kind of mapping in all modes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose map &amp;lt;c-v&amp;gt;&amp;lt;esc&amp;gt;&#xA;:verbose map! &amp;lt;c-v&amp;gt;&amp;lt;esc&amp;gt;&#xA;               ^----------------press &amp;lt;c-v&amp;gt;&amp;lt;esc&amp;gt; on your keyboard      &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Mapping delay is controlled by &lt;code&gt;:h 'timeout'&lt;/code&gt; and &lt;code&gt;:h 'timeoutlen'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;keycode delay&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lots of terminal key code starts with &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, in my machine, &lt;code&gt;&amp;lt;f5&amp;gt;&lt;/code&gt; is &lt;code&gt;^[[15~&lt;/code&gt;, &lt;code&gt;^[&lt;/code&gt; is literal &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;. When &lt;code&gt;vim&lt;/code&gt; receives &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; from your terminal, it waits &lt;code&gt;:h 'ttimeoutlen'&lt;/code&gt; milliseconds to see if there are more characters in this key code, if there are none, then vim know it's truly a &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, otherwise it must be something else. This kind of delay is normal, you can change &lt;code&gt;ttimeoutlen&lt;/code&gt; to reduce it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keycode delay is controlled by &lt;code&gt;:h 'ttimeout'&lt;/code&gt; and &lt;code&gt;:h 'ttimeoutlen'&lt;/code&gt; (not quite true, see &lt;code&gt;:h 'ttimeout'&lt;/code&gt; for detail).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Common setting&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set timeoutlen=1000&#xA;set ttimeoutlen=50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To be honest, i set ttimeoutlen to 5, 50 is still too much delay.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-05T12:44:21.703" LastActivityDate="2019-06-05T12:44:21.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20221" PostTypeId="2" ParentId="20210" CreationDate="2019-06-05T12:43:26.297" Score="2" Body="&lt;p&gt;In your &lt;code&gt;ALEInfo&lt;/code&gt; output, it shows that ALE is using the variables from your latex autogroup. (Line 38: &lt;code&gt;let b:ale_fixers = ['latexindent', 'remove_trailing_lines', 'trim_whitespace']&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each of your autogroups are being loaded and &lt;code&gt;b:ale_fixers&lt;/code&gt; is being overridden each time. You could add something like the following to each of your augroups:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType *.py let b:ale_fixers = ['remove_trailing_lines', 'trim_whitespace', 'isort', 'yapf']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I think it would be a better solution would be to use a dictionary for ALE fixers instead of setting them in each augroup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_fixers = {&#xA;\   'fortran': ['remove_trailing_lines', 'trim_whitespace'],&#xA;\   'latex': ['latexindent', 'remove_trailing_lines', 'trim_whitespace'],&#xA;\   'python': ['remove_trailing_lines', 'trim_whitespace', 'isort', 'yapf']&#xA;\}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5952" LastEditorUserId="5952" LastEditDate="2019-06-05T15:27:33.930" LastActivityDate="2019-06-05T15:27:33.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20222" PostTypeId="1" AcceptedAnswerId="20224" CreationDate="2019-06-05T15:29:42.617" Score="7" ViewCount="543" Body="&lt;p&gt;What is the purpose of user &lt;code&gt;command&lt;/code&gt; in Vi/Vim?  I noticed that a lot of commands are usually used to call functions like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! TrimWhitespace call TrimWhitespace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From my observation, &lt;code&gt;command&lt;/code&gt; seems to provide quick way to call a function without having to type &lt;code&gt;call&lt;/code&gt; from the command mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I also see example like this, which executes Vim commands.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Vimrc :vsplit $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim's help page is quite terse and confusing on this subject and I would like more clarification. Are these ex commands or Vimscript?  In Vim's help page, I see more complex examples like this (not that I want to know what it does, but rather why we use them):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ -complete=file MyEdit&#xA;    \ for f in expand(&amp;lt;q-args&amp;gt;, 0, 1) |&#xA;    \ exe '&amp;lt;mods&amp;gt; split ' . f |&#xA;    \ endfor&#xA;&#xA;function! SpecialEdit(files, mods)&#xA;for f in expand(a:files, 0, 1)&#xA;    exe a:mods . ' split ' . f&#xA;endfor&#xA;endfunction&#xA;command! -nargs=+ -complete=file Sedit&#xA;    \ call SpecialEdit(&amp;lt;q-args&amp;gt;, &amp;lt;q-mods&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21762" LastEditorUserId="21762" LastEditDate="2019-06-05T15:41:38.633" LastActivityDate="2019-06-05T18:24:27.693" Title="What is the purpose of user `command` in Vi/Vim?" Tags="|functions|user-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20223" PostTypeId="1" AcceptedAnswerId="20761" CreationDate="2019-06-05T15:56:31.387" Score="3" ViewCount="1873" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Suppose I run &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:terminal someprg_wide_output&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the output is wrapped by current terminal window size wrapped hard way, so &lt;code&gt;:set nowrap&lt;/code&gt; there can't help&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When I run same program not from vim  like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;someprg_wide_output | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim accepts the whole width of the output without wrapping lines&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I tried adding &lt;code&gt;++cols&lt;/code&gt; option, it does not seem to work as expected&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:terminal ++cols=300 someprg_wide_output&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make vim terminal think it is wider as visible part?&#xA;I would like output looks in 1. like it does for 2.&lt;/p&gt;&#xA;" OwnerUserId="18356" LastEditorUserId="51" LastEditDate="2019-07-29T18:52:09.227" LastActivityDate="2019-07-30T05:09:53.007" Title="Vim 8 terminal change width" Tags="|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20224" PostTypeId="2" ParentId="20222" CreationDate="2019-06-05T16:38:07.667" Score="10" Body="&lt;p&gt;Let's get this confusion out of the way first:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are these ex commands or Vimscript?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Vim scripts are made of ex commands. From &lt;a href=&quot;https://vimhelp.org/usr_41.txt.html#script&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help script&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Your first experience with Vim scripts is the vimrc file.  Vim reads it when&#xA;it starts up and executes the commands.  You can set options to values you&#xA;prefer.  And you can use any colon command in it (commands that start with a&#xA;&quot;:&quot;; these are sometimes referred to as Ex commands or command-line commands).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:&lt;/code&gt; in &lt;code&gt;:vsplit&lt;/code&gt; in your second example is unnecessary, but Vim seems content to just ignore superfluous &lt;code&gt;:&lt;/code&gt;s at the front of ex commands (&lt;code&gt;:::::::::::vsplit&lt;/code&gt; seems to work just as well as &lt;code&gt;:vsplit&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, note that &lt;a href=&quot;https://vimhelp.org/eval.txt.html#:call&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:call&lt;/code&gt;&lt;/a&gt;, from your first example, is just another ex command.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On to your main question. &lt;code&gt;:command&lt;/code&gt; has three forms, depending on the number of arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With no arguments, &lt;code&gt;:command&lt;/code&gt; just lists all the user-defined commands. This will include commands defined in plugins, your vimrc, in command-line mode, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With one argument, it lists all user-defined commands that start with that argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With two or more arguments, &lt;code&gt;:command&lt;/code&gt; defines a new user command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as why anyone would use this, well, why would anyone use any tool? Because it makes it easier and/or faster to do things. Some specific advantages commands have over simply &lt;code&gt;:call&lt;/code&gt;ing functions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;No need to type &lt;code&gt;:call&lt;/code&gt; before the command name.&lt;/li&gt;&#xA;&lt;li&gt;The command can be abbreviated, as long as it's unambiguous. (From your first example, you might be able to get away with just &lt;code&gt;:TrimW&lt;/code&gt;. Compare that to &lt;code&gt;:call TrimWhitespace()&lt;/code&gt;. 1/3 as much typing.)&lt;/li&gt;&#xA;&lt;li&gt;Commands can support completion for their arguments. As far as I'm aware, functions do not.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2736" LastEditorUserId="2736" LastEditDate="2019-06-05T18:24:27.693" LastActivityDate="2019-06-05T18:24:27.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20225" PostTypeId="2" ParentId="20057" CreationDate="2019-06-05T17:13:06.577" Score="1" Body="&lt;p&gt;It turns out this was easier than expected. It just boils down to installing the &lt;code&gt;pip&lt;/code&gt; and &lt;code&gt;apt&lt;/code&gt; packages for &lt;code&gt;pylint&lt;/code&gt; and &lt;code&gt;flake8&lt;/code&gt;, i.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt install pylint&#xA;sudo apt install flake8&#xA;pip install pylint&#xA;pip install flake8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This of course needs to use &lt;code&gt;pip-python3&lt;/code&gt; instead of &lt;code&gt;pip&lt;/code&gt; if you've configured &lt;code&gt;YCM&lt;/code&gt; with Python3. From there, I just install the &lt;a href=&quot;https://github.com/Valloric/YouCompleteMe&quot; rel=&quot;nofollow noreferrer&quot;&gt;YCM&lt;/a&gt; and &lt;a href=&quot;https://github.com/w0rp/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;w0rp/ale&lt;/code&gt;&lt;/a&gt; packages via &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vundle&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only caveat is that PEP8 (via &lt;code&gt;flake8&lt;/code&gt;) errors will be rendered immediately, but other syntax errors detected by &lt;code&gt;pylint&lt;/code&gt; will only be updated/re-rendered when the buffer is saved. However, &lt;a href=&quot;https://github.com/w0rp/ale/issues/590&quot; rel=&quot;nofollow noreferrer&quot;&gt;there's an open issue on this topic,&lt;/a&gt; which is on the backlog to be resolved, &lt;a href=&quot;https://github.com/PyCQA/pylint/issues/1187&quot; rel=&quot;nofollow noreferrer&quot;&gt;as the underlying issue in &lt;code&gt;pylint&lt;/code&gt; is now fixed,&lt;/a&gt; and we're now just &lt;a href=&quot;https://github.com/w0rp/ale/issues/2522&quot; rel=&quot;nofollow noreferrer&quot;&gt;waiting on an update to &lt;code&gt;ale&lt;/code&gt;&lt;/a&gt; to support a plugin supplying buffers both via &lt;code&gt;stdin&lt;/code&gt; and via file buffers.&lt;/p&gt;&#xA;" OwnerUserId="14282" LastActivityDate="2019-06-05T17:13:06.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20226" PostTypeId="1" CreationDate="2019-06-05T17:24:10.777" Score="1" ViewCount="105" Body="&lt;p&gt;Faced a problem that I cannot force the buffer with results and the input field to work together, but not in turn (like in CtrlP)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! s:SearchByListFiles(all_files, query)&#xA;    let searched = []&#xA;    for filepath in a:all_files&#xA;        if a:query == '' || len(split(filepath, a:query)) &amp;gt; 1&#xA;            call add(searched, filepath)&#xA;        endif&#xA;    endfor&#xA;    return searched&#xA;endfunc&#xA;&#xA;function! s:GetListLocalFiles(local_path)&#xA;    let list_local_files_cmd = 'find ' . a:local_path . ' -type f'                                                          &#xA;    let all_local_files = split(system(list_local_files_cmd), '\n')&#xA;    return all_local_files &#xA;endfunc&#xA;&#xA;function! s:SearchFinderDialog(all_files, query)&#xA;    silent! execute &amp;quot;botright pedit ls&amp;quot;&#xA;    noautocmd wincmd P&#xA;    set buftype=nofile&#xA;&#xA;    let all_files = a:all_files&#xA;    if all_files == []&#xA;        let all_files = s:GetListLocalFiles(getcwd())&#xA;    endif&#xA;&#xA;    for filepath in s:SearchByListFiles(all_files, a:query)&#xA;        silent! execute &amp;quot;r! echo &amp;quot; . filepath&#xA;    endfor&#xA;    silent! execute &amp;quot;redraw!&amp;quot;&#xA;&#xA;    let search_query = input('&amp;gt;&amp;gt;&amp;gt; ')&#xA;    call s:SearchFinderDialog(all_files, search_query)&#xA;endfunc&#xA;&#xA;command! -nargs=? SearchFinderDialog :call s:SearchFinderDialog([], &amp;quot;&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I want the arrows (up, down) to control the selection of the file, and typing occurs in the input field&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VTzZ4.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VTzZ4.gif&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22551" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-06-10T11:46:30.007" Title="Live search in temporary buffer" Tags="|vimscript|plugin-development|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20227" PostTypeId="2" ParentId="9366" CreationDate="2019-06-06T05:59:30.490" Score="2" Body="&lt;p&gt;Since lot of us Vim users are suffering from this, I went and investigated this bit more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My solution is to create the &lt;code&gt;$HOME/.vim/after/ftplugin.vim&lt;/code&gt; as suggested by @abcq2 just to realize, it won't change anything. Given the list given by &lt;code&gt;:scriptnames&lt;/code&gt;, that file is source way too early. However, the second suggestion of creating a &lt;code&gt;$HOME/.vim/after/ftplugin/lua.vim&lt;/code&gt; for LUA-files does help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By &lt;code&gt;strace&lt;/code&gt;ing, I learned that file-type generic after-plugins are sourced before the file-type and file-type specific after-plugins are sourced after the file-type. Not very intuitive, but that's how it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is more information in &lt;a href=&quot;https://blog.hqcodeshop.fi/archives/442-Vims-comment-line-leaking-fix!-Part-3.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;my blog&lt;/a&gt; about this.&lt;/p&gt;&#xA;" OwnerUserId="20753" LastActivityDate="2019-06-06T05:59:30.490" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20228" PostTypeId="1" CreationDate="2019-06-06T06:35:16.573" Score="3" ViewCount="833" Body="&lt;p&gt;In my vim, I'm using gruvbox. Syntax colorization is great for everything except text written between `backticks`. You'll note once backticks are used, all subsequent lines of text are green.  I would like backtick text to behave just like standard quoted text and to not screw up highlighting for the rest of the file. I write a lot of JavaScript. Thanks for the help in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CxI6d.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CxI6d.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22562" LastEditorUserId="205" LastEditDate="2019-11-06T06:43:21.553" LastActivityDate="2019-11-06T06:43:21.553" Title="How to stylize text between backticks ( ` ) to match text style between single/double quotes ( ' | &quot; )?" Tags="|syntax-highlighting|colorscheme|" AnswerCount="1" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20229" PostTypeId="1" CreationDate="2019-06-06T07:20:56.557" Score="2" ViewCount="299" Body="&lt;p&gt;I would like the tabbar to start with the first tab not with &quot;tabs&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;tabs&amp;gt;1 main.tex&amp;gt;2 section_01.tex&amp;gt;     &amp;lt;tab 2/2&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6816" LastEditorUserId="11316" LastEditDate="2019-06-06T11:39:42.407" LastActivityDate="2019-06-06T12:42:02.610" Title="How can I remove the word &quot;tabs&quot; at the beginning of the tabbar in airline-vim?" Tags="|plugin-airline|original-vim|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20230" PostTypeId="2" ParentId="20229" CreationDate="2019-06-06T07:33:53.997" Score="3" Body="&lt;p&gt;The actual behavior occurs because of the vim-airline plugin and can be removed adding the following property to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline#extensions#tabline#tabs_label = ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So there will be no more leading &quot;tabs&gt;&quot; in the tabline.&lt;/p&gt;&#xA;" OwnerUserId="6816" LastEditorUserId="10604" LastEditDate="2019-06-06T12:42:02.610" LastActivityDate="2019-06-06T12:42:02.610" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20231" PostTypeId="2" ParentId="12376" CreationDate="2019-06-06T22:49:54.247" Score="6" Body="&lt;p&gt;What about this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if system('uname -r') =~ &quot;Microsoft&quot;&#xA;  augroup Yank&#xA;    autocmd!&#xA;    autocmd TextYankPost * :call system('clip.exe ',@&quot;)&#xA;  augroup END&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;uname&lt;/code&gt; is a Linux terminal command which returns OS info, such that it will return &lt;code&gt;Linux&lt;/code&gt; for WSL. Whereas with &lt;code&gt;-r&lt;/code&gt; flag, the command returns release info of OS, thus it should include &quot;Windows&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;TextYankPost&lt;/code&gt; is a vim event (see &lt;code&gt;:h TextYankPost&lt;/code&gt; in &lt;code&gt;vim&lt;/code&gt;), which detect your text yank activity. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;clip.exe&lt;/code&gt; is a Windows command prompt's command in WSL (see &lt;code&gt;CLIP /?&lt;/code&gt; in command prompt) which copy &lt;code&gt;text&lt;/code&gt; or return from a &lt;code&gt;command&lt;/code&gt; into clipbord via &lt;code&gt;text | clip.exe&lt;/code&gt; or &lt;code&gt;command | clip.exe&lt;/code&gt;. Here the &lt;code&gt;clip.exe&lt;/code&gt; is executed from vim by vim function &lt;code&gt;system&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="22573" LastEditorUserId="22573" LastEditDate="2019-06-09T21:51:01.590" LastActivityDate="2019-06-09T21:51:01.590" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20232" PostTypeId="2" ParentId="20177" CreationDate="2019-06-07T00:59:40.967" Score="2" Body="&lt;p&gt;Change &lt;code&gt;h&lt;/code&gt; to &lt;code&gt;0x&lt;/code&gt;, apply  &lt;code&gt;[count]&amp;lt;c-a&amp;gt;&lt;/code&gt;, then change &lt;code&gt;0x&lt;/code&gt; back to &lt;code&gt;h&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;c-a&amp;gt; expand('&amp;lt;cWORD&amp;gt;') =~# '\v\c\d+''h[0-9a-f]+' ?&#xA;      \ &quot;:&amp;lt;c-u&amp;gt;norm! \&quot;_yiWf'ls0x&amp;lt;c-v&amp;gt;&amp;lt;esc&amp;gt;&quot; . v:count1 . &quot;&amp;lt;c-v&amp;gt;&amp;lt;c-a&amp;gt;F'lvlpE&amp;lt;cr&amp;gt;&quot; : '&amp;lt;c-a&amp;gt;'&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;c-x&amp;gt; expand('&amp;lt;cWORD&amp;gt;') =~# '\v\c\d+''h[0-9a-f]+' ?&#xA;      \ &quot;:&amp;lt;c-u&amp;gt;norm! \&quot;_yiWf'ls0x&amp;lt;c-v&amp;gt;&amp;lt;esc&amp;gt;&quot; . v:count1 . &quot;&amp;lt;c-v&amp;gt;&amp;lt;c-x&amp;gt;F'lvlpE&amp;lt;cr&amp;gt;&quot; : '&amp;lt;c-x&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Break down the 1st return value of the ternary operator:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:&amp;lt;c-u&amp;gt;norm!&lt;/code&gt; Do a series of commands without screen update in the middle. You screen will flicker without this. &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; is used to remove &lt;code&gt;:h N:&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;_yiW&lt;/code&gt; Move cursor to start of current &lt;code&gt;&amp;lt;WORD&amp;gt;&lt;/code&gt; without copying anything.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f'ls0x&lt;/code&gt; find ', cursor right to &lt;code&gt;h&lt;/code&gt;, change it to 0x&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-v&amp;gt;&amp;lt;esc&amp;gt;&lt;/code&gt; escape insert mode. You need &lt;code&gt;&amp;lt;c-v&amp;gt;&lt;/code&gt; to insert literal &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; in command line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v:count1 . &quot;&amp;lt;c-v&amp;gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; let vim increase hex value &lt;code&gt;:h v:count1&lt;/code&gt; times for you&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;F'lvlp&lt;/code&gt; find &lt;code&gt;'&lt;/code&gt; backward, replace &lt;code&gt;0x&lt;/code&gt; with original h or H in default register.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;E&lt;/code&gt; back to end of hex value, to be consistent with vim.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-06-07T00:59:40.967" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20233" PostTypeId="1" AcceptedAnswerId="20234" CreationDate="2019-06-07T03:07:51.000" Score="1" ViewCount="1443" Body="&lt;p&gt;I'm on windows 10 with the Windows subsystem for linux. What I'd like to do with netrw is be able to jump from my home folder in Ubuntu to my home folder in windows. In Ranger I type &lt;code&gt;gh&lt;/code&gt; and it takes me to my Ubuntu home folder immediately. I mapped &lt;code&gt;ga&lt;/code&gt; to go to my Windows home folder so I can jump to that folder immediately too. Can this be done with vim's netrw without any plugins? I want a shortcut to jump between these two directories:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ubuntu home directory: &lt;code&gt;/home/me&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Windows home directory: &lt;code&gt;/mnt/c:/users/me&lt;/code&gt;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="22575" LastEditorUserId="205" LastEditDate="2019-06-07T04:11:36.513" LastActivityDate="2019-11-23T17:13:59.503" Title="Folder jumping in netrw" Tags="|netrw|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20234" PostTypeId="2" ParentId="20233" CreationDate="2019-06-07T04:25:32.223" Score="4" Body="&lt;p&gt;Netrw supports bookmarks, which could be used for this. See &lt;a href=&quot;https://vimhelp.org/pi_netrw.txt.html#netrw-bookmark&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h netwr-bookmark&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;BOOKMARKING A DIRECTORY         netrw-mb netrw-bookmark netrw-bookmarks&#xA;&#xA;One may easily &quot;bookmark&quot; the currently browsed directory by using     &#xA;        mb&#xA;[...]&#xA;                                                        netrw-:NetrwMB&#xA;Addtionally, one may use :NetrwMB to bookmark files or directories.     &#xA;        :NetrwMB[!] [files/directories]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;CHANGING TO A BOOKMARKED DIRECTORY                      netrw-gb&#xA;&#xA;To change directory back to a bookmarked directory, use    &#xA;        {cnt}gb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;LISTING BOOKMARKS AND HISTORY           netrw-qb netrw-listbookmark&#xA;&#xA;Pressing &quot;qb&quot; (query bookmarks) will list both the bookmarked directories and&#xA;directory traversal history.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, you can run &lt;code&gt;:NetrwMB /mnt/c:/users/me/&lt;/code&gt; to add it as a bookmark. Use &lt;code&gt;qb&lt;/code&gt; to see the list of bookmarks, and note the number (which should be &lt;code&gt;1&lt;/code&gt; if you haven't added a bookmark yet), and press &lt;code&gt;&amp;lt;number&amp;gt;gb&lt;/code&gt; (e.g., &lt;code&gt;1gb&lt;/code&gt;) to go that directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the list of bookmarks is kept in a sorted order (not by order of addition). So if you bookmark more directories, the numbers may change.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2019-06-07T04:25:32.223" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20235" PostTypeId="1" CreationDate="2019-06-07T07:09:36.027" Score="1" ViewCount="37" Body="&lt;p&gt;I'm a hobbyist &lt;em&gt;go&lt;/em&gt; programmer, and I'm using &lt;code&gt;vim-go&lt;/code&gt; to make vim efficient go editor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing I like about vim-go is, whenever in a directory, when you open a new &lt;code&gt;.go&lt;/code&gt; file. It adds this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;package main&#xA;&#xA;import &quot;fmt&quot;&#xA;&#xA;func main() {&#xA;    fmt.Println(&quot;vim-go&quot;)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that it has the main function. And now if you create other .go files now on, you'll get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;package main&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I really like this feature. And would like to implement this for other filetypes. E.g. for Python files, I would like to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python&#xA;# -*- coding: utf-8 -*-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And for bash files, I would like to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;#!/usr/bin/env bash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the minimal setup that I need to do for each filetype &lt;em&gt;(Say I already have a template file for each)&lt;/em&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5425" LastEditorUserId="5425" LastEditDate="2019-06-07T07:31:27.930" LastActivityDate="2019-06-07T07:31:27.930" Title="How to load a template file if new file is starting?" Tags="|filetype|" AnswerCount="0" CommentCount="0" ClosedDate="2019-06-07T09:54:44.590" ContentLicense="CC BY-SA 4.0" />
  <row Id="20236" PostTypeId="1" AcceptedAnswerId="20238" CreationDate="2019-06-07T08:23:07.407" Score="5" ViewCount="275" Body="&lt;p&gt;I have the following mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap # /___&amp;lt;CR&amp;gt;ciw&#xA;imap # &amp;lt;Esc&amp;gt;:w&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the following file that I am editing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo ___&#xA;goo ___&#xA;hoo ___&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is that I start at the beginning of the file, type &lt;code&gt;#&lt;/code&gt; and I am editing the first &lt;code&gt;___&lt;/code&gt;, then while still in insert mode, I type &lt;code&gt;#&lt;/code&gt; again, and I am editing the next &lt;code&gt;___&lt;/code&gt;, saving between each edit. This works fine, but the problem is that if I make a mistake, and type &lt;code&gt;u&lt;/code&gt;, it undoes &lt;strong&gt;ALL&lt;/strong&gt; the edits and reverts &lt;strong&gt;ALL&lt;/strong&gt; of them back to &lt;code&gt;___&lt;/code&gt; instead of just the most recent change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do these mappings in a way so that each time I save, it counts as a separate undo?&lt;/p&gt;&#xA;" OwnerUserId="18490" LastEditorUserId="1841" LastEditDate="2019-06-07T08:32:17.217" LastActivityDate="2019-06-07T08:54:33.520" Title="How to make insert mode mapping count as multiple undos?" Tags="|key-bindings|neovim|undo-redo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20237" PostTypeId="2" ParentId="20236" CreationDate="2019-06-07T08:29:01.730" Score="3" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/undo.txt.html#%3Aundojoin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h undojoin&lt;/code&gt;&lt;/a&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;One undo command normally undoes a typed command, no matter how many changes&#xA;that command makes.  This sequence of undo-able changes forms an undo block.&#xA;[...]&#xA;To do the opposite, break a change into two undo blocks, in Insert mode use&#xA;CTRL-G u.  This is useful if you want an insert command to be undoable in&#xA;parts.  E.g., for each sentence.  i_CTRL-G_u&#xA;Setting the value of 'undolevels' also breaks undo.  Even when the new value&#xA;is equal to the old value.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, you could modify your second mapping to break the undo block (before  the write):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap # &amp;lt;C-G&amp;gt;u&amp;lt;Esc&amp;gt;:w&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or the fist mapping to start a new block with input:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap # /___&amp;lt;CR&amp;gt;ciw&amp;lt;c-g&amp;gt;u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2019-06-07T08:54:33.520" LastActivityDate="2019-06-07T08:54:33.520" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20238" PostTypeId="2" ParentId="20236" CreationDate="2019-06-07T08:29:21.860" Score="8" Body="&lt;p&gt;You can use &lt;code&gt;&amp;lt;c-g&amp;gt;u&lt;/code&gt; in insert mode to break undo sequence and start new change. Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap # &amp;lt;c-g&amp;gt;u&amp;lt;Esc&amp;gt;:w&amp;lt;CR&amp;gt;#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(removed the second &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, as it is not needed.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help i_CTRL-G_u&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-06-07T08:47:13.947" LastActivityDate="2019-06-07T08:47:13.947" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20239" PostTypeId="2" ParentId="6358" CreationDate="2019-06-07T08:39:30.533" Score="1" Body="&lt;p&gt;To setup default skeleton for all filetypes and customize it for specific project:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:load_skeleton(type)&#xA;  &quot; do nothing if no filetype&#xA;  if empty(a:type) | return | endif&#xA;&#xA;  &quot; glob every directory of rtp to search for skeleton/filetype&#xA;  let skeletons = globpath(&amp;amp;rtp, 'skeleton/' . a:type, 0, 1)&#xA;  if empty(skeletons) | return | endif&#xA;&#xA;  &quot; read last skeleton into 1st line.&#xA;  exe '0read ' . skeletons[-1]&#xA;endfunction&#xA;&#xA;augroup aug_skeleton&#xA;  au!&#xA;&#xA;  &quot; BufNewFile event is trigged when you edit a new file.&#xA;  autocmd BufNewFile * call s:load_skeleton(&amp;amp;filetype)&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put default skeletons under &lt;code&gt;~/.vim/skeleton&lt;/code&gt;, eg: &lt;code&gt;~/.vim/skeleton/vim&lt;/code&gt;, &lt;code&gt;~/.vim/skeleton/sh&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put project specific skeleton under &lt;code&gt;balabala/project/.vim/skeleton&lt;/code&gt;. As long as &lt;code&gt;~/.vim&lt;/code&gt; appears  before  &lt;code&gt;balabala/project/.vim&lt;/code&gt; in &lt;code&gt;:h rtp&lt;/code&gt;, &lt;code&gt;balabala/project/skeleton/&lt;/code&gt; will be used as skeleton directory.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-06-07T08:39:30.533" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20240" PostTypeId="1" AcceptedAnswerId="20242" CreationDate="2019-06-07T08:43:38.977" Score="1" ViewCount="462" Body="&lt;p&gt;I'm setting up an environment to automatically recompile &lt;code&gt;.tex&lt;/code&gt; files on save. I've found solution for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.tex :! latexmk -pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But is there any better way to do this? It seems like &lt;code&gt;*.tex&lt;/code&gt; check will be executed every time I save a file, be it &lt;code&gt;.c&lt;/code&gt; or &lt;code&gt;.md&lt;/code&gt; file (maybe I'm wrong about this). Could I possibly place this option somewhere so it is executed only when I save &lt;code&gt;.tex&lt;/code&gt; files? Something like &lt;code&gt;ftplugin/tex.vim&lt;/code&gt; (I couldn't make it working there). &lt;/p&gt;&#xA;" OwnerUserId="22443" LastEditorUserId="22443" LastEditDate="2019-06-07T09:41:27.600" LastActivityDate="2019-06-07T11:45:09.953" Title="Execute command only for specified filetype" Tags="|autocmd|filetype-tex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20241" PostTypeId="1" AcceptedAnswerId="20271" CreationDate="2019-06-07T09:31:07.097" Score="0" ViewCount="614" Body="&lt;p&gt;This post is connected with the following one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/8205/jumping-from-function-definition-tag-to-prototype-tag/8206#8206?newreg=415baf15088d427ca9b0015280f1f80e&quot;&gt;Jumping from function definition tag to prototype tag&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Somehow, I did what it is mentioned there. Now, when I generate my tags file using the option &lt;code&gt;--c-kinds=+p&lt;/code&gt; and I do &lt;code&gt;CRTL+]&lt;/code&gt; it will jump directly to the prototype function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, sometimes I am in lines of code where a particular function is being used and I would like to be able to decide if I want to go to the function definition or the function prototype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, using &lt;code&gt;CTRL+]&lt;/code&gt; goes to the definition, and using &lt;code&gt;CTRL+[&lt;/code&gt; goes to the prototype. Is this easy to do?&lt;/p&gt;&#xA;" OwnerUserId="22579" LastActivityDate="2019-06-10T17:41:01.283" Title="Jumping to prototype or definition of a function using tags" Tags="|ctags|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20242" PostTypeId="2" ParentId="20240" CreationDate="2019-06-07T09:46:19.657" Score="3" Body="&lt;p&gt;Ftplugin is the right way to go you simply didn't use the right file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you open a &lt;code&gt;test.tex&lt;/code&gt; file and use &lt;code&gt;set ft?&lt;/code&gt; the result is &lt;code&gt;plaintex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to put your code in &lt;code&gt;ftplugin/plaintex.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I would advise to put it in &lt;code&gt;~/.vim/after/ftplugin/plaintex.vim&lt;/code&gt; this way you are sure that you don't override already existing ftplugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to read &lt;a href=&quot;http://vimhelp.appspot.com/usr_05.txt.html#ftplugin-name&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ftplugin-name&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/filetype.txt.html#ftplugin-overrule&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ftplugin-overrule&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-06-07T11:45:09.953" LastActivityDate="2019-06-07T11:45:09.953" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20243" PostTypeId="2" ParentId="20241" CreationDate="2019-06-07T11:37:04.993" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/options.txt.html#%27tagfunc%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'tagfunc'&lt;/code&gt;&lt;/a&gt; (Vim 8.1.1228 and up)&#xA; specifies a function to be used to perform tag searches. You can use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#taglist%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h taglist()&lt;/code&gt;&lt;/a&gt;&#xA; to get a list of tags and filter it inside your custom tagfunc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;c-f12&amp;gt; :call &amp;lt;sid&amp;gt;tag(&quot;&amp;lt;sid&amp;gt;get_dec_tag&quot;, expand('&amp;lt;cword&amp;gt;'))&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;s-f12&amp;gt; :call &amp;lt;sid&amp;gt;tag(&quot;&amp;lt;sid&amp;gt;get_def_tag&quot;, expand('&amp;lt;cword&amp;gt;'))&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; prototype tagfunc&#xA;function! s:get_dec_tag(pattern, flags, info)&#xA;  return filter(taglist(a:pattern), 'v:val.kind =~# &quot;^p&quot;')&#xA;endfunction&#xA;&#xA;&quot; function tagfunc&#xA;function! s:get_def_tag(pattern, flags, info)&#xA;  return filter(taglist(a:pattern), 'v:val.kind =~# &quot;^f&quot;')&#xA;endfunction&#xA;&#xA;&quot; setup tagfunc, exec :tjump with name, restore tagfunc&#xA;function! s:tag(tagfunc, name) abort&#xA;  try&#xA;    let oldfunc = &amp;amp;tagfunc&#xA;    let &amp;amp;tagfunc = a:tagfunc&#xA;    exec 'tjump' a:name&#xA;  catch /^Vim\%((\a\+)\)\=:E426:/&#xA;    echohl ErrorMsg&#xA;    echom v:exception&#xA;    echohl None&#xA;  finally&#xA;    let &amp;amp;tagfunc = oldfunc&#xA;  endtry&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that i use &lt;code&gt;&amp;lt;c-12&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;s-12&amp;gt;&lt;/code&gt; in above script, not sure it's a good idea to change behavior of &lt;code&gt;&amp;lt;c-]&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="6698" LastEditDate="2019-06-07T13:55:49.067" LastActivityDate="2019-06-07T13:55:49.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20244" PostTypeId="1" AcceptedAnswerId="20245" CreationDate="2019-06-07T12:06:12.723" Score="4" ViewCount="210" Body="&lt;p&gt;I'm trying to make a function to insert license header from external file on first line in the buffer. The script is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    fun InsertLicense()&#xA;        if filereadable('LICENSE')&#xA;            let license = 'LICENSE'&#xA;        elseif filereadable('LICENSE.txt')&#xA;            let license = 'LICENSE.txt'&#xA;        else&#xA;            let license = ''&#xA;        endif&#xA;      if line('$') &amp;lt; 3 &amp;amp;&amp;amp; len(license) &amp;gt; 0&#xA;          echo 'inserting license from ' . license&#xA;          call append(0, readfile(license))&#xA;      endif&#xA;    endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's working fine except one problem: &lt;code&gt;LICENSE&lt;/code&gt; file is a plaintext file, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Copyright 2019 OrgName&#xA;&#xA;Permission is hereby granted, free of charge, to any person&#xA;obtaining a copy of this software and associated&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I need to wrap it as Java multiline comment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * Copyright 2019 OrgName&#xA; *&#xA; * Permission is hereby granted, free of charge, to any person&#xA; * obtaining a copy of this software and associated&#xA;...&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to insert &lt;code&gt;*&lt;/code&gt; before each line of &lt;code&gt;license&lt;/code&gt; file using vim scripting language?&lt;/p&gt;&#xA;" OwnerUserId="9140" LastActivityDate="2019-06-07T16:43:27.967" Title="Insert external file and modify each line from script" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20245" PostTypeId="2" ParentId="20244" CreationDate="2019-06-07T12:15:47.900" Score="5" Body="&lt;p&gt;&lt;code&gt;readfile()&lt;/code&gt; returns a list, each line being in a separate list item.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can therefore make use of &lt;code&gt;map()&lt;/code&gt; to change the list inplace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a=map(readfile('LICENSE'), { i,v -&amp;gt; '/* ' . v. ' */'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes use of &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-lambda&quot; rel=&quot;noreferrer&quot;&gt;lambda&lt;/a&gt; expression and wraps a the comment characters &lt;code&gt;/*&lt;/code&gt; and &lt;code&gt;*/&lt;/code&gt; around it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :let a=['/* '] + map(readfile('LICENSE'), { i,v -&amp;gt; '* ' . v}) + ['*/']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which adds only &lt;code&gt;/*&lt;/code&gt; at the start of the file and &lt;code&gt;*/&lt;/code&gt; at the end of the file and for each line simply prepends the &lt;code&gt;*&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-06-07T12:15:47.900" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20246" PostTypeId="2" ParentId="20244" CreationDate="2019-06-07T12:46:45.390" Score="2" Body="&lt;p&gt;Christian’s answer is great—for java files. But it requires some care for different filetypes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One alternative would be to lean on the machinery of tpope’s &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow noreferrer&quot;&gt;commentary&lt;/a&gt; and do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Go comment a paragraph&#xA;normal gcap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After you insert the license text. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; that commentary comments each line individually, which can look less pretty for large chunks of text, but makes uncommenting lines (of code) easier in terms of the plugin code. You may or may not be able to live with this. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-06-07T16:43:27.967" LastActivityDate="2019-06-07T16:43:27.967" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20247" PostTypeId="1" AcceptedAnswerId="20249" CreationDate="2019-06-08T04:37:45.073" Score="3" ViewCount="606" Body="&lt;p&gt;I have my EXINIT set to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export EXINIT=&quot;set ts=4 sw=4 ai nosm nows expandtab&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also want &lt;code&gt;syn off&lt;/code&gt; to turn off syntax highlighting by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I add this to EXINIT? Tried using &lt;code&gt;;&lt;/code&gt; as a the separator but that doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can put these commands in &lt;code&gt;.exrc&lt;/code&gt; file but I want to know if I can simply use EXINIT.  &lt;code&gt;vi&lt;/code&gt; or &lt;code&gt;ex&lt;/code&gt; man pages don't talk about EXINIT when checked on my Mac.&lt;/p&gt;&#xA;" OwnerUserId="10998" LastActivityDate="2019-06-08T07:12:03.103" Title="Can EXINIT contain more than one command?" Tags="|vimrc|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20248" PostTypeId="2" ParentId="20247" CreationDate="2019-06-08T04:51:03.320" Score="2" Body="&lt;p&gt;Vim uses the &lt;code&gt;|&lt;/code&gt; (vertical bar) as a command separator. Like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export EXINIT=&quot;set ts=4 sw=4 ai nosm nows expandtab|syntax off&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :bar&lt;/code&gt;. The &lt;code&gt;|&lt;/code&gt; doesn't work with all commands. But there shouldn't be any problems with the commands you would typically use in a &lt;code&gt;EXINIT&lt;/code&gt; (or &lt;code&gt;VIMINIT&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-06-08T04:51:03.320" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20249" PostTypeId="2" ParentId="20247" CreationDate="2019-06-08T05:00:55.247" Score="2" Body="&lt;p&gt;&lt;strong&gt;by new line&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export EXINIT='&#xA;    set ...&#xA;    syntax off&#xA;    balabala&#xA;    balabala&#xA;    ...&#xA;    '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;by |&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export EXINIT='set ... | syntax off | balabala | ....'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;check &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#%3Abar&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :|&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-08T07:12:03.103" LastActivityDate="2019-06-08T07:12:03.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20250" PostTypeId="2" ParentId="6589" CreationDate="2019-06-08T05:08:47.280" Score="6" Body="&lt;p&gt;It looks like your &lt;em&gt;nasty&lt;/em&gt; regex was not nasty enough... :-)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Search Section&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The search would have to be changed to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^Hide\(\(\(Show\|Hide\)\@!\_.\)*\)SetFontSize 28&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This includes quite a few uncommon things and so many parenthesis... Let's see what we have in there:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The Caret (&lt;code&gt;^&lt;/code&gt;)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The caret is used to mean beginning of the line. I think we're already familiar with this one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An important point, the &lt;code&gt;^&lt;/code&gt; does not work except as the very first character in your pattern. After the it is taken verbatim. To include a &lt;em&gt;beginning of line&lt;/em&gt; within your expression you need to use &lt;code&gt;\_^&lt;/code&gt;. However, in our situation we did not need that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(There is a similar phenomena with &lt;code&gt;$&lt;/code&gt; and &lt;code&gt;\_$&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The first and last parenthesis (&lt;code&gt;\( ... \)&lt;/code&gt;)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The first and last parenthesis are used &lt;em&gt;on their own&lt;/em&gt; which means it will grab whatever appears inside and set it in parameter &lt;code&gt;\1&lt;/code&gt;. You already used that in your own regex, so I'll assume you also are familiar with this one.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The second set of parenthesis&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;As you may notice, there is a second set of parenthesis followed by an asterisk &lt;code&gt;\( ... \)*&lt;/code&gt;. This means we are looking for whatever matches any number of times. This is the usual way of using the asterisk so you should be familiar with it.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The third set of parenthesis, OR, and &lt;code&gt;\_.&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Yes, there are actually three parenthesis before the word &lt;code&gt;Show&lt;/code&gt;. This last set is necessary for two reasons: the &lt;code&gt;\|&lt;/code&gt; and the following &lt;code&gt;@!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In regard to the OR operation, you should already be familiar with it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Show\|Hide    or    Hide\|Show&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The order does not matter here. The &lt;code&gt;\&lt;/code&gt; is necessary in front of the &lt;code&gt;|&lt;/code&gt; to work in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The parenthesis around this expression allows us to follow the expression by &lt;em&gt;something&lt;/em&gt;. Here the &lt;code&gt;@!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(Show\|Hide\)@!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This one is much less familiar. It means &lt;em&gt;if not matched&lt;/em&gt;. The use of this is not very easy, though, but you need to follow that expression with what you want to extract which should not match said expression. This is why we have &lt;code&gt;\_.&lt;/code&gt; behind that pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\_.&lt;/code&gt; means match anything whatsoever. Contrary to the &lt;code&gt;.&lt;/code&gt; on its own, which doesn't match the &lt;code&gt;\n&lt;/code&gt; character. In other words, we match any character on any number of lines unless it matches &lt;code&gt;Show&lt;/code&gt; or &lt;code&gt;Hide&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the parenthesis around that expression are also important as is the asterisk, so this whole thing is really what makes it work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(\(Show\|Hide\)@!\_.\)*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;a.k.a. match whatever up to the next &lt;code&gt;Show&lt;/code&gt; or &lt;code&gt;Hide&lt;/code&gt; characters (note that it would also match &lt;code&gt;Showing&lt;/code&gt;, &lt;code&gt;Shower&lt;/code&gt;, &lt;code&gt;HideMe&lt;/code&gt;, etc. you should be able to use &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; if it is necessary to match the word exactly.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Side Note: to search on multiple lines, it is also possible to use the &lt;code&gt;\n&lt;/code&gt; character in the pattern. However, it's not as versatile than the &lt;code&gt;\_.&lt;/code&gt; pattern.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;SetFontSize 28&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Now the section has to include &lt;code&gt;SetFontSize 28&lt;/code&gt; as well. Just like you had in your regex. If no &lt;code&gt;SetFontSize 28&lt;/code&gt; appears in that section, try the search again on the next section.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of the negation above (the match except &lt;code&gt;Show&lt;/code&gt; or &lt;code&gt;Hide&lt;/code&gt;) the search doesn't leak to the next section, taking the risk of messing it up.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Replacement Section&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The replacement is just the same as you had it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.../Hide\1SetFontSize 18/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We use the parenthesis in the &lt;strong&gt;Search&lt;/strong&gt; so the &lt;code&gt;\1&lt;/code&gt; works as expected.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Complete Search and Replace&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The resulting patterns goes like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^Hide\(\(\(Show\|Hide\)@!\_.\)*\)SetFontSize 28/Hide\1SetFontSize 18/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\(Show\|Hide\)&lt;/code&gt; should include all the possible &lt;em&gt;headers&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Sources&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/13603/regex-to-match-any-character-including-newline&quot;&gt;Regex to match any character including newline&lt;/a&gt; (&lt;code&gt;\_.\{-}&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vim.fandom.com/wiki/Search_for_lines_not_containing_pattern_and_other_helpful_searches&quot; rel=&quot;noreferrer&quot;&gt;Search for lines not containing pattern and other helpful searches&lt;/a&gt; (&lt;code&gt;@!&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#pattern-overview&quot; rel=&quot;noreferrer&quot;&gt;Vim documentation: pattern&lt;/a&gt; (&lt;code&gt;\_^&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="9276" LastActivityDate="2019-06-08T05:08:47.280" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20251" PostTypeId="1" AcceptedAnswerId="20262" CreationDate="2019-06-08T14:42:18.100" Score="1" ViewCount="647" Body="&lt;p&gt;I open vim and have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 a = range(10)&#xA;2 for b in a:&#xA;3     print(b)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then open an ipython within vim by typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:term ipython&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I yank the code by doing &lt;code&gt;:1,2y&lt;/code&gt; and then go over to the ipython terminal and do &quot;&quot; to paste the yanked code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;problem&lt;/strong&gt; I have is that the spaces are not respected as shown below. Notice how &lt;code&gt;print(a)&lt;/code&gt; is a lot further to the right compared to before.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In [2]: for a in b:&#xA;   ...:         print(a)&#xA;   ...:         &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've seen this behaviour before when pasting things into a normal vim using -V however usually some version of set paste, set nopaste works. Though in this case it didn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how I can make this work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thank you&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running ubuntu 18.04.2 LTS.&#xA;Vim installation info in case helpful&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 10 2018 21:31:58)&#xA;Included patches: 1-1453&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               +comments          +file_in_path      +linebreak         +mouse_urxvt       +quickfix          +terminal          +windows&#xA;+arabic            +conceal           +find_in_path      +lispindent        +mouse_xterm       +reltime           +terminfo          +writebackup&#xA;+autocmd           +cryptv            +float             +listcmds          +multi_byte        +rightleft         +termresponse      -X11&#xA;-autoservername    +cscope            +folding           +localmap          +multi_lang        -ruby              +textobjects       -xfontset&#xA;-balloon_eval      +cursorbind        -footer            -lua               -mzscheme          +scrollbind        +timers            -xim&#xA;+balloon_eval_term +cursorshape       +fork()            +menu              +netbeans_intg     +signs             +title             -xpm&#xA;-browse            +dialog_con        +gettext           +mksession         +num64             +smartindent       -toolbar           -xsmp&#xA;++builtin_terms    +diff              -hangul_input      +modify_fname      +packages          +startuptime       +user_commands     -xterm_clipboard&#xA;+byte_offset       +digraphs          +iconv             +mouse             +path_extra        +statusline        +vertsplit         -xterm_save&#xA;+channel           -dnd               +insert_expand     -mouseshape        -perl              -sun_workshop      +virtualedit&#xA;+cindent           -ebcdic            +job               +mouse_dec         +persistent_undo   +syntax            +visual&#xA;-clientserver      +emacs_tags        +jumplist          +mouse_gpm         +postscript        +tag_binary        +visualextra&#xA;-clipboard         +eval              +keymap            -mouse_jsbterm     +printer           +tag_old_static    +viminfo&#xA;+cmdline_compl     +ex_extra          +lambda            +mouse_netterm     +profile           -tag_any_white     +vreplace&#xA;+cmdline_hist      +extra_search      +langmap           +mouse_sgr         -python            -tcl               +wildignore&#xA;+cmdline_info      +farsi             +libcall           -mouse_sysmouse    +python3           +termguicolors     +wildmenu&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-NQEcoP/vim-8.0.1453=. -fstack-protector-strong -Wformat -Werror=form&#xA;at-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl     -L/usr/lib/pytho&#xA;n3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19123" OwnerDisplayName="evan54" LastActivityDate="2019-06-09T13:30:36.523" Title="How to copy paste from a vim split text to terminal" Tags="|terminal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20252" PostTypeId="1" AcceptedAnswerId="20253" CreationDate="2019-06-08T16:09:16.027" Score="2" ViewCount="231" Body="&lt;p&gt;I have the following (simplified) statusline config in my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set laststatus=2&#xA;set statusline=&#xA;set statusline+=%{getcwd()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I'm somewhere in my home directory on macOS, my statusline looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/ruohola/dotfiles/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I would want it to just show it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/dotfiles/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I would be somewhere in the root directory the path should just be shown normally e.g:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Libarary/Application Support&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21062" LastEditorUserId="21062" LastEditDate="2019-08-06T12:28:38.587" LastActivityDate="2019-08-06T12:28:38.587" Title="How to have getcwd() give path with ~ in place of home folder?" Tags="|vimrc|statusline|working-directory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20253" PostTypeId="2" ParentId="20252" CreationDate="2019-06-08T16:17:50.503" Score="2" Body="&lt;pre&gt;&lt;code&gt;substitute(getcwd(),$HOME,'~','')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-06-08T16:31:00.203" LastActivityDate="2019-06-08T16:31:00.203" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20255" PostTypeId="2" ParentId="20228" CreationDate="2019-06-09T02:42:47.290" Score="2" Body="&lt;p&gt;Thanks to the keen &lt;a href=&quot;https://vi.stackexchange.com/users/10604/d-ben-knoble&quot;&gt;@D. Ben Knoble&lt;/a&gt;, I did some deeper digging into Javascript syntax... and found a vim plugin tailored specifically to Javascript called &lt;a href=&quot;https://github.com/pangloss/vim-javascript&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-javascript&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I installed it into the &lt;code&gt;my_plugins&lt;/code&gt; directory inside my &lt;code&gt;.vim_runtime&lt;/code&gt; folder that tunes &lt;a href=&quot;https://github.com/amix/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Ultimate Vim Configuration&lt;/a&gt;, which I also love more than any IDE so far. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That did the job swimmingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SzTfj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SzTfj.png&quot; alt=&quot;It works.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22562" LastActivityDate="2019-06-09T02:42:47.290" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20256" PostTypeId="1" AcceptedAnswerId="20257" CreationDate="2019-06-09T08:16:02.737" Score="2" ViewCount="94" Body="&lt;p&gt;I have a file that looks something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\usepackage{tex/Forkurs-1p-2p-laererutdanning-2018-V}&#xA;&#xA;\usepackage{../Sty/hyper}&#xA;&#xA;\begin{document}&#xA;&#xA;\input{tex/Forkurs-1p-2p-laererutdanning-2018-V-frontmatter.tex}&#xA;&#xA;\input{tex/Forkurs-1p-2p-laererutdanning-2018-V-del-1.tex}&#xA;&#xA;\input{tex/Forkurs-1p-2p-laererutdanning-2018-V-del-2.tex}&#xA;&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to create two commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;en&#xA;nmap &amp;lt;leader&amp;gt;ep&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To increase and decrease the year in the file  and swap H with V and V with H. Invoking &lt;code&gt;&amp;lt;leader&amp;gt;en&lt;/code&gt; should increase the year when the year is preceeded by an H. e.g &lt;code&gt;YEAR-H&lt;/code&gt;. While the command should swap H with V and V with H.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2018-V&#xA;2018-H&#xA;2019-V&#xA;2019-H&#xA;2020-V&#xA;2020-H&#xA;.&#xA;.&#xA;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly &lt;code&gt;&amp;lt;leader&amp;gt;ep&lt;/code&gt; should decrease the numbers when the number is preceeded by V. Always swap V with H and vice versa. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2018-V&#xA;2017-H&#xA;2017-V&#xA;2016-H&#xA;2016-V&#xA;2015-H&#xA;.&#xA;.&#xA;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I am not sure how to perform a conditional search replace from vim.  Any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: To clarify the increase function should work like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;IF H &#xA;   Increase year&#xA;Toggle VH (Change H to V and V to H)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;em&gt;only&lt;/em&gt; increase the year when the text contains &lt;code&gt;YEAR-H&lt;/code&gt;. &lt;em&gt;Always&lt;/em&gt; swap H and V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The decrease function should work similarly&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;IF V&#xA;   Decrease year&#xA;Toggle VH (Change H to V and V to H)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;em&gt;only&lt;/em&gt; decrease the year when the text contains &lt;code&gt;YEAR-V&lt;/code&gt;. &lt;em&gt;Always&lt;/em&gt; swap H with V and vice-versa.&lt;/p&gt;&#xA;" OwnerUserId="22594" LastEditorUserId="22594" LastEditDate="2019-06-09T09:06:17.910" LastActivityDate="2019-06-09T09:58:25.407" Title="Alternate vim mapping" Tags="|substitute|map-operator|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20257" PostTypeId="2" ParentId="20256" CreationDate="2019-06-09T08:43:06.860" Score="1" Body="&lt;p&gt;&lt;em&gt;The requirements, which were unclear originally, have been updated. Result: much of my original answer is out the window. Here's the new one...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can't reasonably wedge logic into global commands and/or Normal mode commands so in this case it makes more sense to use a function...to be called from a &lt;a href=&quot;https://vimhelp.org/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;sub-replace-expression&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! ProcessYHV(in, incr) &#xA;    let l:year = strcharpart(a:in, 0, 4)&#xA;    let l:code = strcharpart(a:in, 5, 1)&#xA;    if l:code == &quot;H&quot;&#xA;        if a:incr&#xA;            let l:year = l:year + 1&#xA;        endif&#xA;        let l:code = &quot;V&quot;&#xA;    else&#xA;        if ! a:incr&#xA;            let l:year = l:year - 1&#xA;        endif&#xA;        let l:code = &quot;H&quot;&#xA;    endif&#xA;    return l:year . &quot;-&quot; . l:code&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First parameter is a string that matches the key pattern, &lt;code&gt;\d\{4}-[HV]&lt;/code&gt;, second parameter is &quot;boolean&quot; (0 or 1) that determines if it's an increment or decrement operation, and the function returns the proper replacement string based on the specified logic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we just use this function in a substitution command by leveraging expression evaluation...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\d\{4}-[HV]/\=ProcessYHV(submatch(0), 1)/    &quot; decrement&#xA;:%s/\d\{4}-[HV]/\=ProcessYHV(submatch(0), 0)/    &quot; increment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &quot;sub-replace-expression&quot; (help link at beginning of this answer) works like this: everything to the right of the &lt;code&gt;\=&lt;/code&gt; is evaluated as an expression and the result becomes the replacement text. &lt;code&gt;submatch(0)&lt;/code&gt; returns the entire pattern match and we're passing that as the first param to our function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mappings...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Leader&amp;gt;en :%s/\d\{4}-[HV]/\=ProcessYHV(submatch(0), 1)/&amp;lt;cr&amp;gt;&#xA;:nnoremap &amp;lt;Leader&amp;gt;ep :%s/\d\{4}-[HV]/\=ProcessYHV(submatch(0), 0)/&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-06-09T09:58:25.407" LastActivityDate="2019-06-09T09:58:25.407" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20258" PostTypeId="1" CreationDate="2019-06-09T09:38:30.443" Score="1" ViewCount="103" Body="&lt;p&gt;I use switching between alternate-files in VIM a lot in my development workflow and it works great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, sometimes I feel that it will be very useful if I could create missing alternate files, so I wonder is there any way to easier perform Step 4 in the following example:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Given I have opened a file app/services/some_service.rb&lt;/li&gt;&#xA;&lt;li&gt;And I'm trying to switch to alternate-file by pressing a binding.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;VIM says:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E345: Can't find file &quot;/project_path/spec/services/some_service_spec.rb&quot; in&#xA;    path&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;I have to navigate to the path and create this file manually, which is time-taking. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="22595" LastActivityDate="2019-06-09T09:38:30.443" Title="Easier way to create alternate-file?" Tags="|navigation|" AnswerCount="0" CommentCount="1" ClosedDate="2023-05-27T22:24:33.217" ContentLicense="CC BY-SA 4.0" />
  <row Id="20259" PostTypeId="1" AcceptedAnswerId="20261" CreationDate="2019-06-09T11:30:27.557" Score="2" ViewCount="62" Body="&lt;p&gt;I have some files with names as below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long-ordinary-filename-del-1.tex&#xA;long-ordinary-filename-del-2.tex&#xA;long-ordinary-filename-del-3.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to define a command to cycle between these files? More concretely if I have &lt;code&gt;long-ordinary-filename-2.tex&lt;/code&gt; executing the command should take me to &lt;code&gt;long-ordinary-filename-3.tex&lt;/code&gt; and doing it again should give me &lt;code&gt;long-ordinary-filename-1.tex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would have posted what I have tried, but I have no idea how to search replace in commands. I know I can get the curent filename using &lt;code&gt;:pwd&lt;/code&gt; or &lt;code&gt;expand('%:r')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Using the &lt;a href=&quot;https://vi.stackexchange.com/a/20257/22594&quot;&gt;solution&lt;/a&gt; from my previous question I was able to create this solution&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Swaps between similarly named files&#xA;func! IncrementDel(in) &#xA;    let l:del = 1 + strcharpart(a:in, 4, 1)&#xA;    if l:del &amp;gt; &quot;3&quot;&#xA;        let l:del = 1&#xA;    endif&#xA;    return &quot;del-&quot; . l:del&#xA;endfunc&#xA;&#xA;:nnoremap &amp;lt;localleader&amp;gt;nd o&amp;lt;Esc&amp;gt;&quot;%p&amp;lt;S-V&amp;gt;:s/del-\d/\=IncrementDel(submatch(0))/&amp;lt;CR&amp;gt;:nohls&amp;lt;CR&amp;gt;dd:edit &amp;lt;C-r&amp;gt;&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pasting into the current file to switch files seems very barbaric, can this be avoided?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="22594" LastEditorUserId="22594" LastEditDate="2019-06-09T12:06:16.943" LastActivityDate="2019-06-09T14:11:47.117" Title="Cycle between filenames" Tags="|substitute|multiple-files|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20260" PostTypeId="1" AcceptedAnswerId="20266" CreationDate="2019-06-09T12:05:48.013" Score="2" ViewCount="438" Body="&lt;p&gt;I have the path of a folder in a variable, and for a custom debugging script I am making, i need to find an executable file inside that folder (the executable find is guaranteed to exist, but not to be unique). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The executable file is guaranteed to be inside the folder, not in a subfolder. How can I find the path of an executable file (preferably that when called it always returns the same path, although not necessary) in VimScript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="22596" LastActivityDate="2019-06-10T05:29:03.517" Title="How to find a executable file inside a folder?" Tags="|vimscript|filesystem|find|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20261" PostTypeId="2" ParentId="20259" CreationDate="2019-06-09T12:55:31.427" Score="2" Body="&lt;p&gt;You can create an argument list of files and cycle through them. Built in &lt;code&gt;:h :next&lt;/code&gt; won't wrap from last to first, so a custom map or command is necessary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;a :exe ( argidx() == argc() - 1 ? 'first' : 'next') &amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To populate argument list when you start vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim long-ordinary-filename-del-*.text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To change argument list after you start vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args long-ordinary-filename-del-*.text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You use &lt;code&gt;:h :args&lt;/code&gt; to check your current argument list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To create a dedicated solution to this problem only:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:next_of_3()&#xA;&#xA;  &quot; do nothing if current filename doesn't match&#xA;  if @% !~# '\v[123]\.tex$'&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; open next file&#xA;  let fname = substitute(@%, '\v[123]\ze\.tex$', '\=submatch(0)%3+1', '')&#xA;  if filereadable(fname)&#xA;    exec 'e ' . fname&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;3 :call &amp;lt;sid&amp;gt;next_of_3()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h quote%&lt;/code&gt; is name of current file. &lt;code&gt;:h :s\=&lt;/code&gt; is used to get the matching text.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-09T14:11:47.117" LastActivityDate="2019-06-09T14:11:47.117" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20262" PostTypeId="2" ParentId="20251" CreationDate="2019-06-09T13:30:36.523" Score="0" Body="&lt;p&gt;I found a few workarounds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think what @d-ben-knoble mentioned is the reason for the strange indentation.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%autoindent&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Benefit&lt;/strong&gt; almost does what I want, ie allows pasting code from vim&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Drawback&lt;/strong&gt; some code still executes before having pasted the entire block if there is a space being pasted as well&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Drawback&lt;/strong&gt; have to type &lt;code&gt;%autoindent&lt;/code&gt; before / after&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%cpaste&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Benefit&lt;/strong&gt; allows pasting exact code and executing&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Drawback&lt;/strong&gt; need to type &lt;code&gt;--&lt;/code&gt; after I've pasted&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Drawback&lt;/strong&gt; can't edit once pasted&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%edit&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Benefit&lt;/strong&gt; allows full pasting and editing of code&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Drawback&lt;/strong&gt; due to vimception in order to avoid vim's autoindent once entered in edit mode you need to do &lt;code&gt;:set paste&lt;/code&gt;. Also, there exists a pitfall that you edit the main vim process rather than the one started by IPython which itself lives in a vim subprocess.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Ultimately I think &lt;code&gt;%cpaste&lt;/code&gt; or &lt;code&gt;%edit&lt;/code&gt; are probably good enough workarounds for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll leave this answer sitting around in case anyone comes up with a better solution.&lt;/p&gt;&#xA;" OwnerUserId="19123" LastActivityDate="2019-06-09T13:30:36.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20263" PostTypeId="1" CreationDate="2019-06-09T18:48:33.680" Score="3" ViewCount="198" Body="&lt;p&gt;In Vim I make auto-completion of the filesystem paths just by the shortcut &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;x&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;f&lt;/kbd&gt;, in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a &lt;em&gt;Makefile&lt;/em&gt; I sometimes put a path's prefix in a variable. For instance &lt;code&gt;STYLEDIR=/home/user/style&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I have to refer to a file in that directory on another point in the &lt;em&gt;Makefile&lt;/em&gt;. For instance&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pandoc --style $(STYLEDIR)/main.css ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case I can't autocomplete with Vim, because Vim is not aware of the value of the &lt;code&gt;STYLEDIR&lt;/code&gt; variable. I start with &lt;code&gt;$(STYLEDIR)/&lt;/code&gt; and then &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;x&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;f&lt;/kbd&gt; and doesn't show the completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to have autocompletion of files in this case? Maybe a GNU Make plugin for Vim?&lt;/p&gt;&#xA;" OwnerUserId="22600" LastEditorUserId="22600" LastEditDate="2019-12-06T14:03:53.243" LastActivityDate="2019-12-06T14:03:53.243" Title="Autocompletion filenames with prefix in variable" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20264" PostTypeId="1" AcceptedAnswerId="20265" CreationDate="2019-06-09T21:22:18.373" Score="1" ViewCount="162" Body="&lt;p&gt;Suppose I map a key to enter a command in the command buffer, but without hitting enter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BuildSystemTask()&#xA;    if inProject() &quot;generic function that checks if I am in a buildable project&#xA;        :!make&amp;lt;Space&amp;gt;&#xA;    else&#xA;        echom(&quot;you are not in a valid project, whatever that means&quot;)&#xA;    endif&#xA;endfunction&#xA;nnoremap &amp;lt;Leader&amp;gt;b :BuildSystemTask()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea here is that I want to hit my mapping, and I would get &quot;make &quot; in the command buffer so that I can type whatever I want. However, this does not do it because it actually enters the whole command &lt;code&gt;:!make&amp;lt;Space&amp;gt;&lt;/code&gt; as is in the command buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried &lt;code&gt;:execute &quot;normal! :make&amp;lt;Space&amp;gt;&quot;&lt;/code&gt; and that didn't work either. It hits &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how to do this? Or if if there is a better way to invoke a build command (&lt;code&gt;make&lt;/code&gt; is here as an example. It could be &lt;code&gt;node&lt;/code&gt; or &lt;code&gt;go&lt;/code&gt; or &lt;code&gt;maven&lt;/code&gt;). Or if there is a better way to achieve being able to pass arbitrary build command that would be helpful too.&lt;/p&gt;&#xA;" OwnerUserId="22203" LastActivityDate="2019-06-09T23:57:28.143" Title="Print Command Without Hitting Enter" Tags="|vimscript|command-line|command|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20265" PostTypeId="2" ParentId="20264" CreationDate="2019-06-09T23:27:12.943" Score="3" Body="&lt;p&gt;I’d recommend an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping—make the following changes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;b BuildSystemTask()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then in your function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if inProject()&#xA;  return ':make! '&#xA;else&#xA;  return ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An alternative would be to use the &lt;code&gt;feedkeys()&lt;/code&gt; function&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-06-09T23:57:28.143" LastActivityDate="2019-06-09T23:57:28.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20266" PostTypeId="2" ParentId="20260" CreationDate="2019-06-10T02:19:58.830" Score="4" Body="&lt;p&gt;I don't fully understand your question, i know two ways to find all executable files inside a folder:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;readdir( require patch 8.1.1120)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;echo readdir('dir', {v-&amp;gt; executable('dir/' . v) &amp;amp;&amp;amp; !isdirectory('dir/' .  v)})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/eval.txt.html#readdir%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h readdir()&lt;/a&gt; return a list of files and subdirectories, you can provide a &lt;a href=&quot;https://vimhelp.org/eval.txt.html#lambda&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h lambda&lt;/a&gt; expression to filter it.&#xA;The return name is not preceded with &lt;code&gt;dir/&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;glob&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;echo filter(glob('dir/*', 0, 1), {i,v-&amp;gt; executable(v) &amp;amp;&amp;amp; !isdirectory(v)})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is how we do it before &lt;code&gt;readdir&lt;/code&gt; exists. Third arg of glob make it return a list instead of string. The return name is preceded with &lt;code&gt;dir/&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-06-10T05:29:03.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20267" PostTypeId="2" ParentId="20263" CreationDate="2019-06-10T11:18:21.173" Score="3" Body="&lt;p&gt;&lt;strong&gt;Get variable value&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;make -p -f/dev/null 2&amp;gt;/dev/null | grep -Po 'var\s*=\s*\K.+'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Complete in vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#complete%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h complete()&lt;/a&gt; in this case, you need to tell it where complete starts and give it a list of candidates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume your current line looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;........$(var)/mid0/mid1/mid2/base&#xA;                                  ^---cursor position in insert mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to get &lt;code&gt;var&lt;/code&gt;, &lt;code&gt;mid=/mid0/mid1/mid2/&lt;/code&gt; and &lt;code&gt;base&lt;/code&gt;, send &lt;code&gt;var&lt;/code&gt; to &lt;a href=&quot;https://vimhelp.org/eval.txt.html#system%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h system()&lt;/a&gt; to expand it, combine the expanded value with mid and base, send it to &lt;a href=&quot;https://vimhelp.org/eval.txt.html#glob%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h glob()&lt;/a&gt; , remove leading &lt;code&gt;expanded var + mid&lt;/code&gt; from every item in glob result, and that's our final complete candidates:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-b&amp;gt; &amp;lt;c-r&amp;gt;=&amp;lt;sid&amp;gt;complete_make_var_path()&amp;lt;cr&amp;gt;&#xA;&#xA;function! s:complete_make_var_path()&#xA;&#xA;  &quot; search $(..) backward, do nothing if not found&#xA;  let dolllar_pos = searchpos('\v\$\([^)]+\)', 'bn', line('.'))&#xA;  if dolllar_pos == [0, 0]&#xA;    return ''&#xA;  endif&#xA;&#xA;  &quot; get prefix from $ to current column -1&#xA;  let dir_base = getline('.')[ dolllar_pos[1] - 1 : col('.') - 2 ]&#xA;&#xA;  &quot; separate $(var)/mid0/mid1/mid2/base into var, mid, base&#xA;  let [var, mid, base] = matchlist(dir_base, '\v\$\(([^)]+)\)(.*/)?(.*)')[1:3]&#xA;&#xA;  &quot; expand var, erase trailing newline&#xA;  let evar = system('make -p -f/dev/null 2&amp;gt;/dev/null | grep -Po ''' . var . '\s*=\s*\K.+''' )&#xA;  if empty(evar)&#xA;    return ''&#xA;  endif&#xA;  let evar = evar[ 0 : len(evar) - 2 ]&#xA;&#xA;  &quot; glob candidates, remove leading evar+prefix&#xA;  let candidates = map(glob(evar . mid . base . '*', 0, 1), {i,v -&amp;gt; v[ len(evar . mid) : ]})&#xA;  call complete(col('.') - len(base), candidates)&#xA;  return ''&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-10T11:49:06.937" LastActivityDate="2019-06-10T11:49:06.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20268" PostTypeId="1" CreationDate="2019-06-10T12:47:15.790" Score="1" ViewCount="2321" Body="&lt;p&gt;I am trying to direct data from manpage to &lt;em&gt;gvim&lt;/em&gt; file but it's not properly formatted.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In manpage it is shown as &lt;strong&gt;&lt;code&gt;NAME&lt;/code&gt;&lt;/strong&gt; (bold)&lt;/li&gt;&#xA;&lt;li&gt;But in &lt;em&gt;gvim&lt;/em&gt; its printed as &lt;code&gt;N^HNA^HAM^HME^HE&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Similarly for &lt;strong&gt;&lt;code&gt;SYNTAX&lt;/code&gt;&lt;/strong&gt; it prints &lt;code&gt;S^HSY^HYN^HNT^HTA^HAX^HX&lt;/code&gt;.  &lt;/li&gt;&#xA;&lt;li&gt;You can notice additional letter after(or before) &lt;code&gt;^H&lt;/code&gt;.  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Please suggest how to correct this.&lt;br&gt;&#xA;Also suggest if there is any other way of re-directing, so that it keeps the formatting intact.  &lt;/p&gt;&#xA;" OwnerUserId="22609" LastEditorUserId="205" LastEditDate="2019-06-14T07:22:06.753" LastActivityDate="2021-02-06T08:11:03.400" Title="Remove ^H from gvim" Tags="|gvim|formatting|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20269" PostTypeId="1" AcceptedAnswerId="20270" CreationDate="2019-06-10T14:24:36.107" Score="1" ViewCount="938" Body="&lt;p&gt;I'm using both Neovim/Vim and VS Code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With both editors using the gruvbox theme, I noticed Neovim/Vim use fewer colors than VS Code when using the same theme. I have the same issue with the solarized theme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uY0MB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uY0MB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any option to activate in Vim that will enable more colors?&lt;/p&gt;&#xA;" OwnerUserId="18231" LastEditorUserId="205" LastEditDate="2019-06-12T01:13:11.280" LastActivityDate="2019-06-12T01:13:11.280" Title="Why do the color schemes in Vim use fewer colors?" Tags="|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20270" PostTypeId="2" ParentId="20269" CreationDate="2019-06-10T15:01:09.203" Score="3" Body="&lt;p&gt;Do you mean less colors than VS Code? This is an artifact of (n)vim’s regex/contains/follows-based syntax highlighter. VS Code uses &lt;a href=&quot;https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide&quot; rel=&quot;nofollow noreferrer&quot;&gt;TextMate Grammars&lt;/a&gt; which are inherently better for parsing language-elements. I think nvim was talking about switching to a &lt;a href=&quot;http://tree-sitter.github.io/tree-sitter/&quot; rel=&quot;nofollow noreferrer&quot;&gt;tree-sitter parser&lt;/a&gt; (the work in progress is &lt;a href=&quot;https://github.com/neovim/neovim/pull/9219&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As Mass mentions, there are a number of js plugins which greatly extend the syntax highlighting for javascript. I’ve been happy with pangloss/vim-javascript from github. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;VS Code also appears to be using rainbow parens, plugins for which exist in the vim ecosystem as well. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="205" LastEditDate="2019-06-12T01:12:49.743" LastActivityDate="2019-06-12T01:12:49.743" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20271" PostTypeId="2" ParentId="20241" CreationDate="2019-06-10T17:41:01.283" Score="1" Body="&lt;p&gt;An alternative is &lt;code&gt;g&amp;lt;C-]&amp;gt;&lt;/code&gt;, which lets one choose from multiple tag matches if they exists. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-10T17:41:01.283" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20272" PostTypeId="2" ParentId="20268" CreationDate="2019-06-10T17:42:28.663" Score="1" Body="&lt;p&gt;I suppose you are trying to capture the output from a program and open it on &lt;code&gt;gVim&lt;/code&gt;... If that's the case, I'm afraid you will need to open the file with the output and then &lt;em&gt;remove&lt;/em&gt; those &lt;code&gt;^H&lt;/code&gt; and the repeated character that follows it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v(.)^H\1/\1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%s/&lt;/code&gt; substitute in all lines:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\v&lt;/code&gt; uses &lt;em&gt;very magic mode&lt;/em&gt; (see &lt;code&gt;:help /magic&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(.)^H\1&lt;/code&gt; searchs for one character followed by &lt;code&gt;^H&lt;/code&gt; and then by itself again (&lt;code&gt;a^Ha&lt;/code&gt;, for example); note that in order to enter &lt;code&gt;^H&lt;/code&gt; you need to press &lt;code&gt;^V&lt;/code&gt; (or &lt;code&gt;^Q&lt;/code&gt; if you were on a Windows machine) and then &lt;code&gt;^H&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/\1/g&lt;/code&gt; replace all the occurrences with the first character&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: A long time ago, in order to print bold characters you would need to print it, than send a backspace and print it again; well, &lt;code&gt;^H&lt;/code&gt; is that backspace character. &lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-06-10T17:42:28.663" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20273" PostTypeId="1" AcceptedAnswerId="20281" CreationDate="2019-06-10T18:17:38.993" Score="3" ViewCount="904" Body="&lt;p&gt;I am on neovim with Oni. vim-netranger plugin uses terminal colors in this format to highlight things. It does work in terminal with neovim , but not in a gui app. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for a way to replace this that will work. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def c256(msg, c, background):&#xA;    if background:&#xA;        return '[38;5;{};7m{}[0m'.format(c, msg)&#xA;    else:&#xA;        return '[38;5;{}m{}[0m'.format(c, msg)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This string is printed into a line(in a buffer) somehow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-06-10T22:01:20.623" LastActivityDate="2019-06-13T02:09:13.137" Title="Apply terminal colors in gui?" Tags="|terminal|color|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20274" PostTypeId="2" ParentId="20273" CreationDate="2019-06-10T19:35:08.290" Score="2" Body="&lt;p&gt;Assuming by text line OP means the command line window (e.g., via &lt;code&gt;echom&lt;/code&gt;), use &lt;code&gt;:echohl&lt;/code&gt; to set the colors and &lt;code&gt;:echom&lt;/code&gt; to print strings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;echohl&lt;/code&gt; uses the available highlight groups; you may want to use &lt;code&gt;execute&lt;/code&gt; and &lt;code&gt;highlight&lt;/code&gt;to create your own from function arguments if custom highlights are needed. Otherwise, just lean on the provided groups and trust the colorscheme. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a buffer you need to use custom syntax commands, or borrow an existing syntax. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the relevant docs.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-06-10T21:45:31.767" LastActivityDate="2019-06-10T21:45:31.767" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20275" PostTypeId="1" AcceptedAnswerId="20277" CreationDate="2019-06-10T19:54:58.567" Score="1" ViewCount="323" Body="&lt;p&gt;I'm trying to debug an error in a vim plugin. The only clue I'm getting regarding the location of the error is this message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function 190[2]..191[15]..218:&#xA;line   27:&#xA;&amp;lt;custom error message&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried Googling an answer to this question, but it hasn't turned up anything. I know that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[2]&lt;/code&gt;, &lt;code&gt;[15]&lt;/code&gt;, and &lt;code&gt;27&lt;/code&gt; are line number offsets from the function definition, and&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;190&lt;/code&gt;, &lt;code&gt;191&lt;/code&gt;, and &lt;code&gt;218&lt;/code&gt; point to functions.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I don't need help debugging the script, but I'd like to know how to find the names of these functions?  Is there a built-in Vim function to reveal the functions' number/name association?&lt;/p&gt;&#xA;" OwnerUserId="4808" LastActivityDate="2019-06-11T23:09:05.177" Title="Find the function name associated with a number" Tags="|vimscript|error|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20276" PostTypeId="2" ParentId="20275" CreationDate="2019-06-10T20:20:40.453" Score="0" Body="&lt;p&gt;If you are profiling when the function is called, vim will print the lines of the function to a log file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:profile foo.log&#xA;:profile func *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;{do whatever causes the error}&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:profile pause&#xA;:noautocmd qall!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, inspect &lt;code&gt;foo.log&lt;/code&gt; for lines like &lt;code&gt;/FUNCTION\s\+190(/&lt;/code&gt;.  The location (script/linenumber) where the function is defined will be printed.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-06-10T20:20:40.453" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20277" PostTypeId="2" ParentId="20275" CreationDate="2019-06-10T22:24:22.137" Score="1" Body="&lt;p&gt;I use &lt;code&gt;fnum&lt;/code&gt; to represent function number in this answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Get numbered function definition&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:function {fnum}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's documented at &lt;a href=&quot;https://vimhelp.org/eval.txt.html#numbered-function&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h numbered-function&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Add breakpoint to numbered-function&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:breakadd func lnum fnum&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that everytime you sourced a numbered function, a new numbered function is created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Add breakpoint to numbered-function without knowing the number&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's the same job as get number of numbered-function from definition, it's dirty and crude, you properbally don't want to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can loop function number from 1 to a max number and compare result of &lt;code&gt;function {fnum}&lt;/code&gt; and your current numbered function. There will be multiple results if numbered function is sourced multiple times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Set breakpoint to all numberd-funcitons&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:breakadd func lnum [0-9]\\\{1,\}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Adebug-name&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :debug-name&lt;/a&gt; use the same pattern with autocommand, it's documented at &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#file-pattern&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h file-pattern&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:verbose function {fnum}&lt;/code&gt; will also tell you where the function is defined (Thanks to Phi R).&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-11T23:09:05.177" LastActivityDate="2019-06-11T23:09:05.177" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20280" PostTypeId="2" ParentId="20268" CreationDate="2019-06-11T07:22:22.203" Score="0" Body="&lt;p&gt;I got the solution.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;man &amp;lt;command&amp;gt; | col -b &amp;gt; &amp;lt;file&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command dumps the file without &lt;code&gt;^H&lt;/code&gt; and one extra character.&lt;br&gt;&#xA;&lt;em&gt;Drawback&lt;/em&gt;: bold letters are not bold, but at-least gvim file is now readable.  &lt;/p&gt;&#xA;" OwnerUserId="22609" LastEditorUserId="205" LastEditDate="2019-06-14T07:22:28.777" LastActivityDate="2019-06-14T07:22:28.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20281" PostTypeId="2" ParentId="20273" CreationDate="2019-06-11T08:02:31.203" Score="4" Body="&lt;p&gt;Those are ANSI escape sequences which are commonly used to print colored text in terminal windows. If valid sequences are being inserted into Vim buffers then you'll be happy to know that there's a plugin that will translate to Vim highlighting/colors: &lt;a href=&quot;https://github.com/powerman/vim-plugin-AnsiEsc&quot; rel=&quot;nofollow noreferrer&quot;&gt;AnsiEsc&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's are basic examples of the concepts...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Using something close to one of your samples this shows what happens on shell command line...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1Asl7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1Asl7.png&quot; alt=&quot;ASCII escape sequence in Bash&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Now if we redirect the printf output to a file and open with generic Vim we see...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SJ3YR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SJ3YR.png&quot; alt=&quot;ASCII escape sequence in Vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;With plugin installed just run command &lt;code&gt;:AnsiEsc&lt;/code&gt; and you get...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UJJe0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UJJe0.png&quot; alt=&quot;demo of AnsiEsc plugin&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-06-13T02:09:13.137" LastActivityDate="2019-06-13T02:09:13.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20282" PostTypeId="1" CreationDate="2019-06-11T08:46:17.230" Score="1" ViewCount="642" Body="&lt;p&gt;I'm using &lt;code&gt;vim-airline&lt;/code&gt; and would like to add a count of all characters on the current line to it. It should be displayed like &lt;code&gt;1:75&lt;/code&gt; where &lt;code&gt;1&lt;/code&gt; is the column the cursor is currently on and &lt;code&gt;75&lt;/code&gt; the total character count.&lt;/p&gt;&#xA;" OwnerUserId="22304" LastActivityDate="2019-12-09T06:02:50.287" Title="How can I add a count of all columns on every line to the statusline in Vim?" Tags="|statusline|plugin-airline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20283" PostTypeId="2" ParentId="20268" CreationDate="2019-06-11T12:08:33.363" Score="1" Body="&lt;p&gt;Since the OP is dealing directly with manpages, I suggest&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:runtime plugin/man.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Which can be put in startup files), followed by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Man command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;code&gt;help MANPAGER&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-11T12:08:33.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20284" PostTypeId="2" ParentId="10708" CreationDate="2019-06-11T12:15:13.310" Score="9" Body="&lt;p&gt;From the vim manual: &lt;code&gt;:h termguicolors&lt;/code&gt; recommends reading &lt;code&gt;:h xterm-true-color&lt;/code&gt;, also see &lt;code&gt;:h $TERM&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Sometimes setting 'termguicolors' is not enough and one has to set the |t_8f|&#xA;and |t_8b| options explicitly.  [ ... these are]  only set [to some default] when `$TERM` is `xterm`.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I use a condition similar to the below: (nvim recommends &lt;em&gt;not&lt;/em&gt; using &lt;code&gt;&amp;amp;term&lt;/code&gt; but rather &lt;code&gt;$TERM&lt;/code&gt; )&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if $TERM =~# '256color' &amp;amp;&amp;amp; ( $TERM =~# '^screen'  || $TERM =~# '^tmux' )&#xA;    let &amp;amp;t_8f = &amp;quot;\&amp;lt;Esc&amp;gt;[38;2;%lu;%lu;%lum&amp;quot;&#xA;    let &amp;amp;t_8b = &amp;quot;\&amp;lt;Esc&amp;gt;[48;2;%lu;%lu;%lum&amp;quot;&#xA;    set termguicolors&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20591" LastEditorUserId="20591" LastEditDate="2021-05-29T16:40:47.413" LastActivityDate="2021-05-29T16:40:47.413" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20285" PostTypeId="1" CreationDate="2019-06-11T15:19:38.737" Score="2" ViewCount="26" Body="&lt;p&gt;When I have a line of code such as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;result = function(myVar);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then I can delete the text &quot;myVar&quot; with the command &lt;strong&gt;di(&lt;/strong&gt; only if my cursor is already positioned inside the parentheses. However, when I'm working with this text:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;result = &quot;myString&quot;;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then I can delete the text &quot;myString&quot; with the command &lt;strong&gt;di&quot;&lt;/strong&gt; whether or not my cursor is already placed in the parentheses. Is there some reason for this? Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: The linked duplicate answers the question, that parentheses can be nested, unlike quotations, and this means that there is no simple default behavior choice like there is with quotes. Thanks everyone!&lt;/p&gt;&#xA;" OwnerUserId="22568" LastEditorUserId="22568" LastEditDate="2019-06-12T15:23:41.847" LastActivityDate="2019-06-12T15:23:41.847" Title="Different behavior when selecting quote blocks vs. selecting parentheses blocks" Tags="|cut-copy-paste|cursor-motions|normal-mode|" AnswerCount="0" CommentCount="2" ClosedDate="2019-06-12T04:03:59.733" ContentLicense="CC BY-SA 4.0" />
  <row Id="20286" PostTypeId="1" AcceptedAnswerId="20331" CreationDate="2019-06-11T15:39:25.343" Score="4" ViewCount="1336" Body="&lt;p&gt;Running &lt;code&gt;:checkhealth&lt;/code&gt; in NeoVim-Qt (v0.3.5) I get the following report on terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ERROR: command failed: infocmp -L&#xA;infocmp: environment variable TERM not set&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I set the environment variable TERM in NeoVim-Qt?&lt;/p&gt;&#xA;" OwnerUserId="17024" LastEditorUserId="1841" LastEditDate="2019-06-11T16:02:34.250" LastActivityDate="2022-09-29T20:44:33.803" Title="Neovim-Qt: environment variable TERM not set" Tags="|neovim|terminal|environment-variables|neovim-qt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20287" PostTypeId="2" ParentId="2782" CreationDate="2019-06-11T16:02:21.127" Score="0" Body="&lt;p&gt;There are some tools to make this automatic:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://bytefluent.com/vivify/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vivify&lt;/a&gt;: quite complex, you have to manually select each color for each single highlight group.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimcolors.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimcolors.org&lt;/a&gt;: very simple and easy. Just choose some colors and it will automatically generate the scheme for you.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="22619" LastActivityDate="2019-06-11T16:02:21.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20288" PostTypeId="2" ParentId="2782" CreationDate="2019-06-11T16:38:34.783" Score="1" Body="&lt;p&gt;Another great tool is &lt;a href=&quot;https://gist.github.com/romainl/5cd2f4ec222805f49eca&quot; rel=&quot;nofollow noreferrer&quot;&gt;RNB&lt;/a&gt; by romainl which uses &lt;a href=&quot;https://www.stuartellis.name/articles/erb/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ERB&lt;/a&gt;. ERB (Embedded RuBy) is a feature of Ruby that enables you to generate some text from templates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the usage of this tool is pretty straight forward: First you need to define different variables corresponding to the nomenclature of your colorscheme and of course to its actual content (How the colors should look, which groups you want to use, etc) it is pretty straight forward because the author wrote a lot of comments to help you. Then all you need to do is to give your customized template to erb and the tool will generate the right files.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-06-11T16:38:34.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20289" PostTypeId="1" AcceptedAnswerId="20293" CreationDate="2019-06-11T16:46:43.907" Score="2" ViewCount="265" Body="&lt;p&gt;I'm attempting to use powershell from gvim, and when I do...I set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set shellcmdflag=-NoProfile\ -NoLogo\ -ExecutionPolicy\ RemoteSigned\ -windowStyle\ Normal\ -Command&#xA;:set shell='C:\\windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe'&#xA;:set shellxquote=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I do it runs it like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I'll run a command like &lt;code&gt;!ls&lt;/code&gt; and get this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'C:\windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe' -NoProfile -NoLogo -ExecutionPolicy RemoteSigned -windowStyle Normal -Command &quot;ls&quot;&#xA;The filename, directory name, or volume label syntax is incorrect.&#xA;shell returned 1&#xA;Hit any key to close this window...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(note the quotes around the powershell path)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What variable causes those quotes to be there?  It is keeping me from running my command.&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="1292" LastEditDate="2019-07-10T06:43:42.087" LastActivityDate="2019-07-10T08:57:04.700" Title="Why does vim call powershell surrounded by two single quotes?" Tags="|microsoft-windows|external-command|shell|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20290" PostTypeId="1" AcceptedAnswerId="20291" CreationDate="2019-06-11T17:08:59.450" Score="0" ViewCount="205" Body="&lt;p&gt;I have this user defined command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! PS silent! w | PlugSnapshot! ~/.vim/plugins/plugins.lock&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How could I change it to take the filepath from a variable, something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let PathToPluginsFolder =  ~/.vim/plugins&#xA;command! PS silent! w | PlugSnapshot! %%%PathToPluginsFolder%%%/plugins.lock&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21062" LastEditorUserId="21062" LastEditDate="2019-06-11T17:24:40.473" LastActivityDate="2019-06-11T17:24:40.473" Title="How to use variables in a user defined command?" Tags="|variables|path|user-commands|command|" AnswerCount="1" CommentCount="2" ClosedDate="2019-06-11T17:47:32.050" ContentLicense="CC BY-SA 4.0" />
  <row Id="20291" PostTypeId="2" ParentId="20290" CreationDate="2019-06-11T17:18:38.467" Score="2" Body="&lt;p&gt;Can simply use &lt;code&gt;exec&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt; to build the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let PathToPluginsFolder =  ~/.vim/plugins&#xA;command! PS silent! exec ':w | PlugSnapshot! ' . PathToPluginsFolder . '/plugins.lock'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21062" LastActivityDate="2019-06-11T17:18:38.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20292" PostTypeId="2" ParentId="20273" CreationDate="2019-06-11T17:21:59.783" Score="0" Body="&lt;p&gt;I ask it also here&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/ipod825/vim-netranger/issues/22&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ipod825/vim-netranger/issues/22&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and what he wrote is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I now see that this is because I didn't set the highlit color for gui&#xA;  in the syntax file. The line should be modified to something like:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 'hi NETRhi'.c.' ctermfg='.c.' ctermbg=None guifg=#rrggbb guibg =None'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is working now. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-06-11T17:21:59.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20293" PostTypeId="2" ParentId="20289" CreationDate="2019-06-11T17:43:13.677" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Why does vim call powershell surrounded by two single quotes?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For it's own protection, maybe, but more than likely someone was thinking about protection of users too; single quotes &lt;em&gt;should&lt;/em&gt; mean &lt;em&gt;&quot;don't expand this string&quot;&lt;/em&gt; where as double quotes kinda mean &lt;em&gt;&quot;treat the output of this string as an argument&quot;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What variable causes those quotes to be there?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;shell&lt;/code&gt; variable that has been &lt;code&gt;:set&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set shell='C:\\windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... without quotes might look like...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set shell=C:\\windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It is keeping me from running my command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'd suggest double-checking that file path, including double-checking capitalization, because it might not be the quote's fault that errors be popping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example &lt;code&gt;windows&lt;/code&gt; may be &lt;code&gt;Windows&lt;/code&gt;, though if I've read the &lt;a href=&quot;https://docs.microsoft.com/en-us/powershell/scripting/getting-started/starting-windows-powershell?view=powershell-6&quot; rel=&quot;nofollow noreferrer&quot;&gt;docs&lt;/a&gt; correctly one might be able to mitigate some of this by using the built in variable &lt;code&gt;%SystemRoot%&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set shell='%SystemRoot%\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22621" LastEditorUserId="205" LastEditDate="2019-07-10T08:57:04.700" LastActivityDate="2019-07-10T08:57:04.700" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20294" PostTypeId="1" CreationDate="2019-06-11T20:27:43.797" Score="1" ViewCount="642" Body="&lt;p&gt;I understand that Vim does not support regex capture groups. The problem I am trying to solve is being able to easily capture parts of lines.  For example, given the following line of python source code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def is_string(s, *args):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to do something equivalent to using the following PCRE regex, which captures the function's name:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'^def (\w+) ?\(.*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(the capture group here would match &lt;code&gt;is_string&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the idiomatic way in VimScript to specify a regex pattern for what part of a line I am trying to match?&lt;/p&gt;&#xA;" OwnerUserId="17718" LastActivityDate="2019-06-12T01:32:57.630" Title="What alternative to capture groups should I use in VimScript?" Tags="|vimscript|regular-expression|search|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20295" PostTypeId="2" ParentId="20294" CreationDate="2019-06-11T21:11:44.953" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I understand that Vim does not support regex capture groups&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not sure where you got that idea from. Vim-regex most definitely supports capture groups. It wouldn't be very useful without them...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your regex is already pretty much right. Just a couple differences with which characters need to be escaped or not:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^def \(\w\+\) \?(.*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you want to use &lt;a href=&quot;https://stackoverflow.com/questions/1623160/can-i-turn-on-extended-regular-expressions-support-in-vim&quot;&gt;very magic&lt;/a&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v^def (\w+) ?\(.*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="10604" LastEditDate="2019-06-12T01:32:57.630" LastActivityDate="2019-06-12T01:32:57.630" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20296" PostTypeId="1" AcceptedAnswerId="20297" CreationDate="2019-06-11T23:45:34.833" Score="3" ViewCount="1677" Body="&lt;p&gt;Let's say I'm at line 20 and I want to copy (and paste below line 20) just the line 50. I can do that with &lt;code&gt;:50,50y&lt;/code&gt; , then paste with &lt;code&gt;p&lt;/code&gt; in normal mode. I found this &lt;a href=&quot;https://vi.stackexchange.com/a/9817/22625&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know if there are ways to do it without that command nor using &lt;code&gt;50ggyy20ggp&lt;/code&gt; (in general taking so many steps).&lt;/p&gt;&#xA;" OwnerUserId="22625" LastEditorUserId="19017" LastEditDate="2019-06-14T12:03:25.297" LastActivityDate="2019-06-14T12:03:25.297" Title="Copy entire line and paste it after another line" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20297" PostTypeId="2" ParentId="20296" CreationDate="2019-06-12T00:35:44.307" Score="8" Body="&lt;p&gt;&lt;strong&gt;Copy line 50 after line 20&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:50t20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change &lt;code&gt;20&lt;/code&gt; to &lt;code&gt;.&lt;/code&gt; if you want to copy line 50 after current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Move around and copy line after line 20&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go to line 20, and mark it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Move cursor to any line you want and execute an ex command :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:t'm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3At&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :t&lt;/code&gt;&lt;/a&gt; is synonym for &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#%3Acopy&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :copy&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]co[py] {address}                                *:co* *:copy*&#xA;                        Copy the lines given by [range] to below the line&#xA;                        given by {address}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3Arange&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :[range]&lt;/code&gt;&lt;/a&gt; is current line if omitted, &lt;code&gt;:h {address}&lt;/code&gt; is mark &lt;code&gt;m&lt;/code&gt; in this case.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="205" LastEditDate="2019-06-12T01:11:56.643" LastActivityDate="2019-06-12T01:11:56.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20298" PostTypeId="2" ParentId="20296" CreationDate="2019-06-12T01:34:11.447" Score="1" Body="&lt;p&gt;While the answer with &lt;code&gt;:t&lt;/code&gt; is definitely the most convenient way to do it, if you’ve already used &lt;code&gt;:yank&lt;/code&gt; then a good next step is probably&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-12T01:34:11.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20299" PostTypeId="1" CreationDate="2019-06-12T06:13:17.757" Score="1" ViewCount="309" Body="&lt;p&gt;If I'm using replace mode, but I want to keep one or a few characters in a row of the text I am replacing, is there an easy way to skip forward rather than retyping the characters or exiting replace mode and moving and re-entering replace mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's say I'm editing the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Tue Jun 11 20:08:07&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to change it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Wed Jun 12 20:08:07&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can do this by typing &lt;code&gt;RWed Jun 12&amp;lt;Esc&amp;gt;&lt;/code&gt; but that seems unwieldy.  I can do it as two separate edits, but I run into this use case often and it seems to me there may be a Vim feature just for this task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I recently learned about &lt;code&gt;:help i_ctrl-y&lt;/code&gt;, a feature which blew my mind, I thought it worth asking.  Ideally the feature I'm hoping for would allow for repeating the entire replace action with the &lt;code&gt;.&lt;/code&gt; key, including preserving the characters in the middle (whatever they might be).&lt;/p&gt;&#xA;" OwnerUserId="4676" LastActivityDate="2019-07-12T13:20:41.413" Title="Keep next letter in replace mode?" Tags="|replace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20300" PostTypeId="2" ParentId="20299" CreationDate="2019-06-12T07:56:22.580" Score="1" Body="&lt;p&gt;You want to skip &lt;code&gt;Jun&lt;/code&gt; , so you must find a way to move cursor to &lt;code&gt;11&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want to use dot repeat, so &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt; is not an option, as it always splits undo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That leave you only the arrow keys. To stop it from breaking undo, custom map is necessary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Left&amp;gt;  &amp;lt;C-G&amp;gt;U&amp;lt;Left&amp;gt;&#xA;inoremap &amp;lt;Right&amp;gt; &amp;lt;C-G&amp;gt;U&amp;lt;Right&amp;gt;&#xA;inoremap &amp;lt;C-Left&amp;gt;  &amp;lt;C-G&amp;gt;U&amp;lt;C-Left&amp;gt;&#xA;inoremap &amp;lt;C-Right&amp;gt; &amp;lt;C-G&amp;gt;U&amp;lt;C-Right&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The replace keystrokes are:&#xA; &lt;kbd&gt;R&lt;/kbd&gt;&lt;kbd&gt;W&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;c-right&lt;/kbd&gt;&lt;kbd&gt;c-right&lt;/kbd&gt;&lt;kbd&gt;right&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;, it's dot repeatable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-G_U&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h i_CTRL-G_U&lt;/a&gt; stopped next cursor movement from breaking undo. Read after the linked doc if you want to know how to achieve the same behavior for &lt;code&gt;&amp;lt;home&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;end&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;s&gt;Personally i prefer multiple edits and macro repeat.&lt;/s&gt;&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-12T08:21:42.130" LastActivityDate="2019-06-12T08:21:42.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20301" PostTypeId="1" CreationDate="2019-06-12T11:49:55.480" Score="0" ViewCount="128" Body="&lt;p&gt;I'm developing a vim plugin. There will be some global-level functionality that's not specific to a particular filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some kind of registry of commands being used by vim packages?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I ensure that some other module isn't already using the command name that I want to use?  Making it start with the full module name seems cumbersome at best.&lt;/p&gt;&#xA;" OwnerUserId="9412" LastEditorUserId="9412" LastEditDate="2019-06-13T01:22:17.673" LastActivityDate="2019-11-07T14:06:55.927" Title="Best way to avoid clobbering other vim plugins with global commands" Tags="|plugin-system|plugin-development|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20302" PostTypeId="1" CreationDate="2019-06-12T17:47:12.710" Score="2" ViewCount="74" Body="&lt;p&gt;Background: I'm working on a large project that has some disparate coding styles. I'm working on &lt;a href=&quot;https://github.com/python/black&quot; rel=&quot;nofollow noreferrer&quot;&gt;unifying that&lt;/a&gt; but only the parts that I've most recently touched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tool that I'm using produces a diff file, so I can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; black --diff &amp;lt;filename&amp;gt; &amp;gt;/tmp/patch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :diffp /tmp/patch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which works great! I can &lt;code&gt;]c&lt;/code&gt; and &lt;code&gt;[c&lt;/code&gt; to navigate my changes and &lt;code&gt;do&lt;/code&gt; to get the ones that I want. The only problem is that I end up with this garbage &lt;code&gt;myfile.new&lt;/code&gt; living in my pwd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't find anything in &lt;code&gt;:help :diffp&lt;/code&gt; that suggested there was any good way to say, &quot;Okay, I'm done now, go away other file!&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest thing I found was &lt;a href=&quot;https://stackoverflow.com/a/16679182/344286&quot;&gt;this answer&lt;/a&gt; - &lt;code&gt;:call delete(expand('%')) | bdelete!&lt;/code&gt;. This does exactly what I want. I could bind this of course, but I'm wondering...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way? Should I just add &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;rm :call delete(expand('%')) | bdelete!&amp;lt;cr&amp;gt;&lt;/code&gt; or something to &lt;code&gt;$MYVIMRC&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5574" LastEditorUserId="1818" LastEditDate="2019-06-14T12:03:16.007" LastActivityDate="2019-06-14T12:03:16.007" Title="Is there a better way to diff from a patch?" Tags="|vimdiff|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20304" PostTypeId="1" AcceptedAnswerId="20309" CreationDate="2019-06-13T05:25:39.060" Score="2" ViewCount="1271" Body="&lt;p&gt;Help! I am looking for a vim script function: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function takes &quot;currentDirectoryPath&quot; and &quot;fileName&quot;; starting from &quot;currentDirectoryPath&quot; it will search recursively for the existence of &quot;fileName&quot; in the parent directory . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Return true if &quot;fileName&quot; is found and stop searching. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Return false if fileName is not found when reaching root '/'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks if you can help! &lt;/p&gt;&#xA;" OwnerUserId="15493" LastActivityDate="2019-06-28T13:30:01.403" Title="vimscript to search recursively in parents directory for the existence of a file?" Tags="|vimscript|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20305" PostTypeId="2" ParentId="8903" CreationDate="2019-06-13T08:20:18.417" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://spacevim.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SpaceVim&lt;/a&gt; provides such functionality, but bundled with other things. Maybe it would be possible to cherrypick that plugin, or just use the entire bundle.&lt;/p&gt;&#xA;" OwnerUserId="2562" LastActivityDate="2019-06-13T08:20:18.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20306" PostTypeId="2" ParentId="5110" CreationDate="2019-06-13T09:43:12.140" Score="4" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/tonyxty/quickfix.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;quickfix.py&lt;/a&gt; parses the traceback into a vim-friendly errorformat. Here is an example of running it on a file with a single line &lt;code&gt;1 / 0&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;❯❯❯ quickfix.py tests/errors/div_by_zero.py&#xA;&quot;tests/errors/div_by_zero.py&quot;:1: ZeroDivisionError: division by zero&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By default, it shows user files, but it can show system files too (running it on a file containing &lt;code&gt;import os; os.environ['123']&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;❯❯❯ quickfix.py -a /tmp/test.py                                                                                                        &#xA;&quot;/usr/lib/lib/python3.7/os.py&quot;:678: KeyError: '123'&#xA;&quot;/tmp/test.py&quot;:1: in function &amp;lt;module&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Configuration:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;quickfix.py&lt;/code&gt; is available in the current path, add the following lines in the vimrc to use it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;autocmd&quot;)&#xA;  autocmd FileType python setlocal makeprg=quickfix.py\ %&#xA;  autocmd FileType python setlocal errorformat=%E\&quot;%f\&quot;:%l:%m,&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5514" LastActivityDate="2019-06-13T09:43:12.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20307" PostTypeId="1" CreationDate="2019-06-13T10:44:01.033" Score="7" ViewCount="2079" Body="&lt;p&gt;I want to use netrw as a project drawer. Not for opening/closing files or general file management, but only as a way to get a visual overview over the project structure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I open netrw automatically when I open gVim, and keep it open to the left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I have several splits open, I'd like the netrw &quot;project drawer&quot; to keep in sync with the active buffer. Is this possible? Additionally, if the current file is in a directory with a lot of files, I want netrw to scroll so that the current file is visible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I accomplish this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've previously gotten this working with NERDTree using &lt;code&gt;NERDTreeFind&lt;/code&gt;. But I found NERDTree to slow down vim too much.  I've also gotten it kind of working in defx, but with too much flickering. So now I'm putting my hope to netrw...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often when NERDTree and/or netrw are discussed the &lt;a href=&quot;http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/&quot; rel=&quot;noreferrer&quot;&gt;&quot;oil and vinegar&quot; article&lt;/a&gt; is mentioned. So ofcourse I have read it :)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It mentions that fuzzyfinding files with something like CtrlP is faster. And I agree, and that's what I use. But I still want my project drawer for a visual overview of where the current file is in the file tree, and the overall layout of the project.&lt;/p&gt;&#xA;" OwnerUserId="22642" LastEditorUserId="22642" LastEditDate="2019-06-13T13:26:22.880" LastActivityDate="2020-08-02T01:57:29.520" Title="Find and highlight current file in netrw" Tags="|netrw|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20308" PostTypeId="1" AcceptedAnswerId="20315" CreationDate="2019-06-13T11:46:39.957" Score="2" ViewCount="154" Body="&lt;p&gt;I have an insert mode mapping which calls a function to select some text and leave vim in select mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;C-J&amp;gt; &amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt;:call MyFunction()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works in regular insert mode; and it works when the insert-mode completion popup window is visible and I haven't pressed ctrl-p or ctrl-n.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't work when the insert-mode completion popup window is visible and I have pressed ctrl-p or ctrl-n.  In this case:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the cursor moves to the expected location;&lt;/li&gt;&#xA;&lt;li&gt;the literal text &lt;code&gt;:call MyFunction()&lt;/code&gt; with a newline is inserted in place of the text I wanted to be selected;&lt;/li&gt;&#xA;&lt;li&gt;vim remains in insert mode instead of switching to select mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I believe this is because the &lt;code&gt;C-\&lt;/code&gt; at the start of the RHS is not part of the current completion option, so it has the effect of accepting the completion, which triggers &lt;code&gt;CompleteDone&lt;/code&gt;, which executes &lt;code&gt;MyFunction()&lt;/code&gt; (I listen for the &lt;code&gt;CompleteDone&lt;/code&gt; event and in my listener call &lt;code&gt;MyFunction()&lt;/code&gt;), and then the rest of the RHS is taken literally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;completeopt&lt;/code&gt; is &lt;code&gt;menuone,noinsert&lt;/code&gt;.  &lt;code&gt;MyFunction()&lt;/code&gt;looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction()&#xA;  ...&#xA;  stopinsert&#xA;  call setpos(&quot;'&amp;lt;&quot;, ...)&#xA;  call setpos(&quot;'&amp;gt;&quot;, ...)&#xA;  execute &quot;normal! gv\&amp;lt;C-G&amp;gt;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried this variation instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;C-J&amp;gt; &amp;lt;C-R&amp;gt;=pumvisible() ? '&amp;lt;C-Y&amp;gt;' : MyFunction()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works when the completion window is open, both when I have and haven't pressed ctrl-p / ctrl-n; but it doesn't work in regular insert mode (it moves the cursor to the start of the line and switches to normal mode – I suspect because &lt;code&gt;MyFunction()&lt;/code&gt; doesn't have an explicit &lt;code&gt;return&lt;/code&gt;, and so implicitly returns &lt;code&gt;0&lt;/code&gt;, which takes the cursor to the start of the line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get the mapping to work all the time?&lt;/p&gt;&#xA;" OwnerUserId="1643" LastEditorUserId="1643" LastEditDate="2019-06-13T12:33:52.620" LastActivityDate="2019-06-14T11:14:11.893" Title="How to get insert mode map to work regardless of completion popup?" Tags="|key-bindings|ins-completion|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20309" PostTypeId="2" ParentId="20304" CreationDate="2019-06-13T11:57:04.333" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;findfile()&lt;/code&gt; for this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo !empty(findfile(fileName, currentDirectoryPath.';'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1643" LastEditorUserId="51" LastEditDate="2019-06-28T13:30:01.403" LastActivityDate="2019-06-28T13:30:01.403" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20310" PostTypeId="1" CreationDate="2019-06-13T16:22:01.783" Score="0" ViewCount="77" Body="&lt;p&gt;I am currently using a vertical monitor for my vim setup. I absolutely love being able to view 100+ lines of code at once. My eyes can scan longer and more complicated blocks of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have noticed that there are times when being able to see 100+ lines of code is actually quite distracting. There are cases when i'm really only concerned with 5-10 lines. This is especially problematic if I look away to my second monitor to read something in my browser; when my eyes go back to vim, I have to rescan the whole monitor to remember where I was.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ideal situation, personal preference-wise, would be to dynamically fade all rows a certain number of lines away from the center row with a convenient key binding. This would give me the flexibility to zone into narrower blocks of code and be able to quickly get back to looking at the bigger picture if I want to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know a solution like this? If not, I would also appreciate alternative solutions to the same problem or similar problem, which I would generally describe as &quot;the frequent changing of the scope of focus in my editor throughout the day&quot;.&lt;/p&gt;&#xA;" OwnerUserId="22644" LastActivityDate="2019-06-14T01:27:55.143" Title="Fade Rows Far From Center" Tags="|syntax-highlighting|highlight|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20312" PostTypeId="1" CreationDate="2019-06-13T22:44:12.243" Score="3" ViewCount="131" Body="&lt;p&gt;When I search for occurrences of some frequent pattern (lets say finding a c symbol), I'll get a list of suggestions at the bottom of vim. Is there a way that the pattern is highlighted for easier lookup?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how it actually looks like:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/CuxYB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CuxYB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a mockup of what I'd like it look like:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/uHpBB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uHpBB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would help the user see the slightly faster in the context.&lt;/p&gt;&#xA;" OwnerUserId="9059" LastEditorUserId="10604" LastEditDate="2019-06-14T01:29:49.453" LastActivityDate="2019-10-08T21:55:04.317" Title="Highlight tag matches for better visibility" Tags="|tags|cscope|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20313" PostTypeId="2" ParentId="20310" CreationDate="2019-06-14T00:24:53.763" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/junegunn/limelight.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;limelight.vim&lt;/a&gt; works great for fading paragraphs of text. I don't know if it works for code blocks also. It can still be a good starting point to look up the fading functionality, since getting current cursor line in vimscript is trivial, with functions line() / winline().&lt;/p&gt;&#xA;" OwnerUserId="19475" LastActivityDate="2019-06-14T00:24:53.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20314" PostTypeId="2" ParentId="20310" CreationDate="2019-06-14T01:27:55.143" Score="1" Body="&lt;p&gt;Another plugin option is &lt;a href=&quot;https://github.com/chrisbra/NrrwRgn&quot; rel=&quot;nofollow noreferrer&quot;&gt;NrrwRgn&lt;/a&gt;, which has editing benefits as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I’ve seen people use a trick to flash cursorline and cursor column as well, as a sort of &quot;where am I.&quot; This is not hard to do, but I’ll see if I can find the exact code later. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-14T01:27:55.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20315" PostTypeId="2" ParentId="20308" CreationDate="2019-06-14T03:37:51.883" Score="1" Body="&lt;p&gt;There are several mistakes in your map:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;mistake 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/change.txt.html#quote%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h quote=&lt;/a&gt; is expression register, it requires an expression. &lt;code&gt;MyFunction()&lt;/code&gt; is a function, when it's used in an expression, it's result is returned, not itself. &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Areturn&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :return&lt;/a&gt; says that if your function doesn't have an explicit &lt;code&gt;:return&lt;/code&gt;, it returns 0. 0 is a normal mode command that move your cursor to column 1.  To fix that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;..... &amp;lt;c-r&amp;gt;= ...... : &quot;\&amp;lt;lt&amp;gt;c-\&amp;gt;\&amp;lt;lt&amp;gt;c-o&amp;gt;:call MyFunction\&amp;lt;lt&amp;gt;cr&amp;gt;&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I will explain &lt;code&gt;&quot;\&amp;lt;lt&amp;gt;cr&amp;gt;&quot;&lt;/code&gt; shortly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;mistake 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Definition of map without &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        Map the key sequence {lhs} to {rhs} for the modes&#xA;                        where the map command applies.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's &lt;strong&gt;key sequence&lt;/strong&gt;, it works like you are typing it. The &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; in the end is right because you want to press carriage return in the end of the &lt;code&gt;&amp;lt;c-r&amp;gt;=&lt;/code&gt;. &lt;code&gt;&amp;lt;c-y&amp;gt;&lt;/code&gt; here works by accident, because when you press &lt;code&gt;&amp;lt;c-y&amp;gt;&lt;/code&gt; in command line, it inserts a literal &lt;code&gt;&amp;lt;c-y&amp;gt;&lt;/code&gt;, but you can't rely on that, try &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, they won't insert literal code for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now let's come back to the ugly &lt;code&gt;&quot;\&amp;lt;lt&amp;gt;cr&amp;gt;&quot;&lt;/code&gt;. Our goal is to return a literal &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; after &lt;code&gt;MyFunction&lt;/code&gt;, literal &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; is &lt;code&gt;&quot;\&amp;lt;cr&amp;gt;&quot;&lt;/code&gt; (check &lt;a href=&quot;https://vimhelp.org/eval.txt.html#string&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h string&lt;/a&gt; ), in order to stop &lt;code&gt;map&lt;/code&gt; command from interpreting &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; as special keycode, we replace &lt;code&gt;&amp;lt;&lt;/code&gt; with it's special keycode &lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt;. The same rules applys to &lt;code&gt;&amp;lt;c-\&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;common way&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should use &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; instead of &lt;code&gt;&amp;lt;c-r&amp;gt;&lt;/code&gt; unless there are special reasons ( eg: &lt;a href=&quot;https://vimhelp.org/eval.txt.html#complete%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h complete()&lt;/a&gt; ), because &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; think that &lt;code&gt;{rhs}&lt;/code&gt; is result of an &lt;code&gt;expression&lt;/code&gt;, what ever you provided in your &lt;code&gt;&amp;lt;map&amp;gt;&lt;/code&gt; is an expression, you don't need to worry about your second mistake inside an expression. I hope i have made my self clear. (my English is poor ~~)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-j&amp;gt; pumvisible() ? '&amp;lt;c-y&amp;gt;' : '&amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt;:call MyFunction()&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-14T11:14:11.893" LastActivityDate="2019-06-14T11:14:11.893" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20316" PostTypeId="2" ParentId="15113" CreationDate="2019-06-14T07:34:36.233" Score="6" Body="&lt;p&gt;Ok, after years of trying many things, I finally found a viable solution!&#xA;And the winner is:&#xA;&lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;COC&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&amp;quot;It's a completion framework and language server client which supports extension features of VSCode.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;The only thing is that to get the &amp;quot;floating windows&amp;quot; (which is the really cool stuff) you need to a &lt;a href=&quot;https://github.com/neoclide/coc.nvim/wiki/F.A.Q#how-to-make-preview-window-shown-aside-with-pum&quot; rel=&quot;nofollow noreferrer&quot;&gt;&amp;quot;Build neovim from master code or use nightly build&amp;quot;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But to get a nightly build version of neovim on osX works perfectly fine, so it's easy to do.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;After trying (many) different plugins, the best one is definitely &lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;CoC&lt;/a&gt;!&lt;/p&gt;&#xA;&lt;p&gt;It works well with js &amp;amp; &lt;a href=&quot;https://github.com/neoclide/coc.nvim/wiki/F.A.Q#how-to-make-preview-window-shown-aside-with-pum&quot; rel=&quot;nofollow noreferrer&quot;&gt;python&lt;/a&gt;, also typescript.&lt;/p&gt;&#xA;&lt;p&gt;The big plus is that it integrates many plugins from visual studio code.&#xA;The minus is the documentation...&lt;/p&gt;&#xA;" OwnerUserId="7579" LastEditorUserId="10604" LastEditDate="2020-12-10T03:17:48.087" LastActivityDate="2020-12-10T03:17:48.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20317" PostTypeId="1" CreationDate="2019-06-14T08:25:07.420" Score="2" ViewCount="845" Body="&lt;p&gt;In (g)vim on Windows I can use &lt;code&gt;:source \Program\ Files\ (x86)\Vim\vim81\msvim.vim&lt;/code&gt; to source the script for the Windows settings. Vim suggested the syntax with leading backslash when I found it in some menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I add to my &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source \Program\ Files\ (x86)\Vim\vim81\msvim.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does not work. I am not sure, when and where I need backslashes as path separator and to escape spaces, parentheses or other backslashes.&lt;/p&gt;&#xA;" OwnerUserId="16938" LastActivityDate="2019-06-14T12:44:20.350" Title="How to source vim-scripts on Windows?" Tags="|vimrc|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20318" PostTypeId="2" ParentId="20317" CreationDate="2019-06-14T08:56:09.273" Score="3" Body="&lt;p&gt;Use &lt;code&gt;:runtime&lt;/code&gt;, it'll look into the directories specified by &lt;code&gt;'runtimepath'&lt;/code&gt; which should contain &lt;code&gt;$VIMRUNTIME&lt;/code&gt; by default -- which should be &lt;code&gt;C:/Program files (x86)/Vim/vim81&lt;/code&gt; in your case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding slashes and backslashes, I never use backslashes, even on Windows with vim, nor in programs I develop (without the win32 API and the likes). They have too many side effects, starting with the need to double them (when they are required as characters and not as escaping signs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, &lt;a href=&quot;https://stackoverflow.com/questions/289681/why-does-c-a-ctrla-not-work-under-gvim-on-windows#comment138689_289689&quot;&gt;are you really sure you want to source &lt;code&gt;mswin.vim&lt;/code&gt;&lt;/a&gt;?&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2019-06-14T12:44:20.350" LastActivityDate="2019-06-14T12:44:20.350" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20319" PostTypeId="1" CreationDate="2019-06-14T20:34:06.997" Score="1" ViewCount="618" Body="&lt;p&gt;I often want to edit text in say line 200 of a file, but while doing this I need to look at say line 100, so I scroll to line 100. Is there a way to quickly jump back to line 200 after scrolling? Is there a possibility to configure a jump mark that is update with every movement except scrolling?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;''&lt;/code&gt; doesn't seem to work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; An answer should preferably describe a way to do what I'm asking. That is move to the position the cursor had before scrolling, without having to do anything beforehand.&lt;br&gt;&#xA;If you have advice on other ways to solve the general problem, e.g. using splits or setting a mark before scrolling feel free to write a comment.&lt;/p&gt;&#xA;" OwnerUserId="21684" LastEditorUserId="21684" LastEditDate="2019-06-14T23:38:23.070" LastActivityDate="2019-06-15T00:09:20.220" Title="Move cursor to old position after scrolling" Tags="|vimrc|navigation|jumplist|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20320" PostTypeId="2" ParentId="20319" CreationDate="2019-06-14T23:20:29.537" Score="0" Body="&lt;p&gt;First, instead of scrolling, try &lt;code&gt;:100&lt;/code&gt; or &lt;code&gt;100G&lt;/code&gt;; then the &lt;code&gt;`&lt;/code&gt; mark will work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, if viewing multiple parts of the same file, why not &lt;code&gt;:[v]split&lt;/code&gt; it? Splits are perfect for multiple views of the same file. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-14T23:20:29.537" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20321" PostTypeId="2" ParentId="20319" CreationDate="2019-06-14T23:29:08.037" Score="3" Body="&lt;p&gt;&lt;strong&gt;Go back in the same file&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mark your current position with &lt;code&gt;mm&lt;/code&gt; , move around, go back with &lt;code&gt;'m&lt;/code&gt; or &lt;code&gt;`m&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Go back to last insert position in the same file&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Go back to last insert position and continue in insert mode&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Go back accross files&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mark your current position with mM , move around, go back with 'M or `M.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-15T00:09:20.220" LastActivityDate="2019-06-15T00:09:20.220" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20322" PostTypeId="1" AcceptedAnswerId="20327" CreationDate="2019-06-15T08:50:24.380" Score="6" ViewCount="312" Body="&lt;p&gt;I have a simple custom operator, it echoes &lt;code&gt;v:register&lt;/code&gt;, it's mapped to &lt;code&gt;,f&lt;/code&gt;. After reading &lt;a href=&quot;https://vi.stackexchange.com/questions/12555/how-to-allow-count-before-my-custom-operator&quot;&gt;this&lt;/a&gt;, i creat it like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:foo(type,...)&#xA;  echo v:register&#xA;endfunction&#xA;&#xA;function! s:setupOpfunc(func)&#xA;  let &amp;amp;opfunc = a:func&#xA;  return 'g@'&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt; ,f &amp;lt;sid&amp;gt;setupOpfunc('&amp;lt;sid&amp;gt;foo')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It wors fine on built in textobjects, e.g. &lt;code&gt;&quot;x,faw&lt;/code&gt; output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work on custom textobject. Assume i have this simple custom  text object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap ix iw&#xA;&#xA;&quot; I know you can map to `iw` directly, but that's not the point of this problem.&#xA;onoremap ix :normal vix&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;x,fix&lt;/code&gt; output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think it doesn't work because &lt;code&gt;:normal ...&lt;/code&gt; erased &lt;code&gt;v:resiter&lt;/code&gt;. I tried to use &lt;code&gt;onoremap &amp;lt;expr&amp;gt; ...&lt;/code&gt; to create &lt;code&gt;omap&lt;/code&gt; for textobject, but &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h map-expression&lt;/a&gt; says &lt;code&gt;:normal&lt;/code&gt;( needed to visually select text object ) is blocked during it's expression evaluation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Built in operator has no this kind of problem &lt;code&gt;&quot;xyix&lt;/code&gt; happily copy word into register &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One crude way i know to make this work is to use some global variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:setupOpfunc(func)&#xA;  let g:__opfunc_rgister = v:register&#xA;  ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't feel right, are there any other ways to make this work?&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-15T23:57:48.953" LastActivityDate="2019-06-16T02:25:13.893" Title="How to pass v:register to custom operator when working on custom text object?" Tags="|custom-text-object|map-operator|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20323" PostTypeId="1" AcceptedAnswerId="20324" CreationDate="2019-06-15T11:14:47.933" Score="0" ViewCount="66" Body="&lt;p&gt;It seems like I need to use a lot of shortcut &lt;em&gt;tokens&lt;/em&gt; to do what I need in &lt;code&gt;vimscript&lt;/code&gt; - which is making my code unreadable, so are there regular &lt;code&gt;function&lt;/code&gt; calls for that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I need to write the following commands for their corresponding action:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Delete all the lines in the current buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read all the files in the current directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.!ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Omitting the &lt;code&gt;.&lt;/code&gt; would lead to an extra line)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To write forcefully:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:write!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All these tokens like &lt;code&gt;%&lt;/code&gt;, &lt;code&gt;.&lt;/code&gt;, &lt;code&gt;!&lt;/code&gt; are slightly difficult to ready sometimes, so are there some functional equivalent to those?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! InitDir(...)&#xA;    let g:previous_directory = g:current_directory&#xA;    let g:current_directory = a:0 &amp;gt;= 1 ? a:1 : getcwd()&#xA;    :%delete&#xA;    :execute &quot;.!ls &quot; . g:current_directory&#xA;    :write! &#xA;endfunction&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8178" LastEditorUserId="8178" LastEditDate="2019-06-15T11:21:06.173" LastActivityDate="2019-06-15T13:16:10.837" Title="Are there function equivalent to vim shortcuts?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20324" PostTypeId="2" ParentId="20323" CreationDate="2019-06-15T13:16:10.837" Score="1" Body="&lt;p&gt;Firstly, the tokens have names:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt; are ranges (&lt;code&gt;:h [range]&lt;/code&gt;)—they are a core part of vim’s ex-command language&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;!&lt;/code&gt; is usually a command suffix to indicate &lt;em&gt;really do it&lt;/em&gt; or &lt;em&gt;do something different&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Second, in functions, the leading &lt;code&gt;:&lt;/code&gt; can be omitted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third, space is allowed between range and command—&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% delete&#xA;. !ls&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I have found that vim’s syntax highlighting doesn’t like it, but the languag accepts it.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally: I strongly recommend you become comfortable with the notation. I find &lt;code&gt;%delete&lt;/code&gt; more readable than a mess of &lt;code&gt;setline&lt;/code&gt; calls. There are functions that can be put together to do what you want (someone is free to edit them in—I don’t have their names handy). But using Ex as intended is typical for vimmers. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-15T13:16:10.837" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20325" PostTypeId="2" ParentId="19899" CreationDate="2019-06-16T01:11:49.933" Score="6" Body="&lt;p&gt;I found the answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://askubuntu.com/a/729372/861689&quot;&gt;Clipboards in linux are handled by the X server&lt;/a&gt;. Because I am using an AWS EC2 instance without the X server installed, there is no such thing as a &quot;system clipboard&quot; in Vim and therefore the &lt;code&gt;*&lt;/code&gt; or &lt;code&gt;+&lt;/code&gt; registers are missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I installed &lt;a href=&quot;https://www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml&quot; rel=&quot;noreferrer&quot;&gt;Xvfb, which is a sort of dummy X server that is able to maintain a system clipboard,&lt;/a&gt; and ran it using &lt;code&gt;xvfb :0.0&lt;/code&gt;. Then I set my display variable: &lt;code&gt;export DISPLAY=:0.0&lt;/code&gt;. Now the &lt;code&gt;*&lt;/code&gt; register shows up in vim &lt;code&gt;:reg&lt;/code&gt; and I am able to copy things from one Vim instance to another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/FilipOsowski/configs/blob/master/install_vim_system_clipboard.sh&quot; rel=&quot;noreferrer&quot;&gt;I made a script to automate this process of getting the system clipboard to work in Vim.&lt;/a&gt; The script installs Xvfb, creates a xvfb.service file and uses it to enable xvfb starting on boot, and adds &lt;code&gt;export DISPLAY=:0.0&lt;/code&gt; to your &lt;code&gt;bashrc&lt;/code&gt; so you don't have to set it each time you want this to work. To run the script, do: &lt;code&gt;sudo bash install_vim_system_clipboard.sh&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22165" LastActivityDate="2019-06-16T01:11:49.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20326" PostTypeId="2" ParentId="8835" CreationDate="2019-06-16T02:23:58.160" Score="0" Body="&lt;p&gt;For situations where you need for vim to have fully loaded up as if you started it manually, this works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;autocmd! CursorHold * &amp;lt;commands to run&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, I wanted to redirect the output of &lt;code&gt;:map&lt;/code&gt; to a file from the shell, but I wanted to capture the mapping that &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-airline&lt;/a&gt; creates only after it's displayed its tabline (line at top showing all buffernames open.)  Because it seems to do this asynchronously, simply running a &lt;code&gt;-c&lt;/code&gt; redirect to a file wasn't giving it time to make the mappings.  There could be a better way, but this works for me, especially since I already have &lt;code&gt;updatetime&lt;/code&gt; set to &lt;code&gt;100&lt;/code&gt; (0.1 seconds), which affects how long until the &lt;code&gt;CursorHold&lt;/code&gt; event fires.  By default, vim sets it to 4 seconds.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c &quot;autocmd! CursorHold * set nomore | redir! &amp;gt; mapNew | map | redir END | q&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8071" LastActivityDate="2019-06-16T02:23:58.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20327" PostTypeId="2" ParentId="20322" CreationDate="2019-06-16T02:25:13.893" Score="5" Body="&lt;p&gt;Consider if you were doing some operation in visual mode for deleting in a word, you would use the following to put the deletion in register a.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;viw&quot;ad      -&amp;gt;   v        [iw]      [&quot;a]       d&#xA;                 visual   object    register   operator&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly, placing &lt;code&gt;&quot;a&lt;/code&gt; in the omap after the operator &lt;code&gt;ix&lt;/code&gt; passes it to the opfunc.  Either of these alternatives seems to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap ix :normal vix&quot;&amp;lt;c-r&amp;gt;=v:register&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&#xA;onoremap &amp;lt;expr&amp;gt; ix ':normal vix&quot;'.v:register.'&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the point of creation of the normal string, &lt;code&gt;v:register&lt;/code&gt; is set correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this is a general principle.  If you make an omap that uses visual mode, you should save and append the register invocation for the sake of any following opfuncs&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! MyOmap()&#xA;    let l:reg = v:register&#xA;    normal! vaw&#xA;    execute 'normal! &quot;' . l:reg &#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All that being said, custom text objects do work built-in operators without this extra work, so maybe vim should be fixed do the right thing here, with custom op + custom object.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-06-16T02:25:13.893" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20328" PostTypeId="1" AcceptedAnswerId="20329" CreationDate="2019-06-16T11:57:49.670" Score="0" ViewCount="184" Body="&lt;p&gt;Suppose I have a snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet prg &#xA;    !This is file : `!v expand('%:t:r')`&#xA;    ! Author= `!v expand($USER)`&#xA;    ! Started at: `date +%d.%m.%y`&#xA;    ! Last Modified : Sun 16 Jun 2019 12:30:58 IST&#xA;    !&#xA;    Program  ${1:&amp;lt;++`!v expand('%:t:r')`}&#xA;    Implicit None&#xA;    ${2}&#xA;    End Program  ${1/([^\n$]+).*/$1/}&#xA;endsnippet&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in vimrc, i have: &lt;code&gt;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;c-a&amp;gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which is working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, besides this, I am trying to have a keymap, like say, &lt;code&gt;&quot;prg&lt;/code&gt; in &lt;code&gt;insertmode&lt;/code&gt;, which will expand this snippet for me. eg:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &quot;prg :some_magic_(expand_snippet_prg)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;any idea how to do this?&lt;/p&gt;&#xA;" OwnerUserId="2738" LastActivityDate="2019-06-17T00:51:11.940" Title="custom snippet extender Ultisnips" Tags="|vimrc|gvim|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20329" PostTypeId="2" ParentId="20328" CreationDate="2019-06-16T12:53:34.527" Score="4" Body="&lt;p&gt;&lt;strong&gt;Use remap to trigger expansion&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &quot;prg prg&amp;lt;c-a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe printf('imap &quot;prg prg%s',  g:UltiSnipsExpandTrigger)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But not this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;expr&amp;gt; &quot;prg 'prg' . g:UltiSnipsExpandTrigger&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:UltiSnipsExpandTrigger&lt;/code&gt; is a variable, &lt;code&gt;map&lt;/code&gt; won't figure out special key code of it's value for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Manual expansion&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &quot;prg prg&amp;lt;c-r&amp;gt;=UltiSnips#ExpandSnippet()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can't use &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; here, as &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; can't change buffer text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You dont need to call &lt;code&gt;expand&lt;/code&gt; on &lt;code&gt;enviroment variable&lt;/code&gt;, &lt;code&gt;$USER&lt;/code&gt; is enough.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-17T00:51:11.940" LastActivityDate="2019-06-17T00:51:11.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20330" PostTypeId="2" ParentId="19751" CreationDate="2019-06-16T14:56:30.160" Score="1" Body="&lt;p&gt;If you want to use the clipboard directly from Vim, you'll need a version compiled with either the &lt;code&gt;+clipboard&lt;/code&gt; or &lt;code&gt;+xterm_clipboard&lt;/code&gt; features. On non-macOS Unix systems, those generally require at least X11 libraries. Without those features, Vim itself has no way of talking to the clipboard. You'll also need X forwarding enabled on your SSH connection (&lt;code&gt;ssh -X&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without those features, you can copy and paste from your terminal, but the copy will be only from the data you highlight with your mouse (then copy with Ctrl-Shift-C), just like at the shell. You can also use a terminal multiplexor like screen or tmux (running your remote Vim inside them) and configure it to copy and paste regions from the screen.&lt;/p&gt;&#xA;" OwnerUserId="22677" LastActivityDate="2019-06-16T14:56:30.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20331" PostTypeId="2" ParentId="20286" CreationDate="2019-06-16T15:11:01.817" Score="8" Body="&lt;p&gt;The &lt;code&gt;TERM&lt;/code&gt; environment variable is generally set by the terminal emulator you're running in, and it tells programs using curses (like Vim and Neovim) what sequences to send to the screen to do things like moving the cursor and setting colors. When you're using a graphical environment, Vim and Neovim don't need this environment variable to be set, since they're not drawing on a terminal, but instead in a graphical window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're invoking Neovim-Qt from a terminal, then this environment variable will be set, but otherwise it generally will not be, and that's not a problem. Neovim warns you about this in &lt;code&gt;:checkhealth&lt;/code&gt; because for terminals, not setting it usually leads to problems; they appear not to have considered the GUI case. You can just ignore this error, since it's harmless for GUIs.&lt;/p&gt;&#xA;" OwnerUserId="22677" LastActivityDate="2019-06-16T15:11:01.817" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20333" PostTypeId="1" AcceptedAnswerId="20334" CreationDate="2019-06-17T05:26:40.277" Score="5" ViewCount="5852" Body="&lt;p&gt;I use two spaces in my indentation of codes. What are the possible ways to indent or unindent a block of code?&lt;/p&gt;&#xA;" OwnerUserId="22680" LastActivityDate="2019-06-22T12:21:05.780" Title="How to indent or unindent lines in a block of text?" Tags="|indentation|visual-block|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20334" PostTypeId="2" ParentId="20333" CreationDate="2019-06-17T06:01:44.277" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I use two spaces in my indentation of codes. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;First off, you should set the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27shiftwidth%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'shiftwidth'&lt;/code&gt;&lt;/a&gt; option to 2, to match the number of spaces you want to use as indentation. You will probably also want to set &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27expandtab%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'expandtab'&lt;/code&gt;&lt;/a&gt; so that Vim will keep using spaces for indentation once you get to 8 spaces (or whatever the tab size is set to.) So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set shiftwidth=2 expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What are the possible ways to indent or unindent a block of code?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you have the block visually selected, then you can use the &lt;a href=&quot;https://vimhelp.org/change.txt.html#v_%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/a&gt; command to indent it and the &lt;a href=&quot;https://vimhelp.org/change.txt.html#v_%3C&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/a&gt; command to unindent it. You can pass these commands a &quot;count&quot; to indent/unindent the visual block by multiple &lt;code&gt;shiftwidth&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal mode, you can use the &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3C&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/a&gt; command followed by a motion to indent/unindent the lines covered by that motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also have the &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3E%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3C%3C&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt;&lt;/a&gt; commands to indent/unindent &quot;count&quot; lines (or a single line, without a count.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are a few of the ways in which you can indent/unindent an existing block. There are others available while you're in insert mode, either automatically (e.g. &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27autoindent%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'autoindent'&lt;/code&gt;&lt;/a&gt; or using indent expressions) or manually (&lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-T&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Ctrl-T&lt;/code&gt;&lt;/a&gt; to indent, &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Ctrl-D&lt;/code&gt;&lt;/a&gt; to unindent, the TAB key can be set to indent by setting an option such as &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27softtabstop%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'softtabstop'&lt;/code&gt;&lt;/a&gt; to match &lt;code&gt;'shiftwidth'&lt;/code&gt;, etc.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-06-17T06:07:32.463" LastActivityDate="2019-06-17T06:07:32.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20335" PostTypeId="1" CreationDate="2019-06-17T10:05:09.127" Score="1" ViewCount="1562" Body="&lt;p&gt;When I create a curly braces and press enter inside it I get this behavious&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{|} -&amp;gt; enter key&#xA;&#xA;{&#xA;|}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now how do I get vim to do this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{|} -&amp;gt; enter key&#xA;&#xA;{&#xA;    |&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;my vimrc brief&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;set lazyredraw&#xA;set smartcase&#xA;set smartindent&#xA;set ignorecase&#xA;set nocompatible&#xA;set number&#xA;set numberwidth=1&#xA;set autoindent&#xA;set backspace=2&#xA;set backspace=indent,eol,start&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;set shellslash&#xA;set clipboard=unnamed&#xA;set smarttab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6706" LastActivityDate="2019-06-17T11:21:38.457" Title="enter inside curly braces does not indent" Tags="|vimrc|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20336" PostTypeId="2" ParentId="10476" CreationDate="2019-06-17T10:43:06.670" Score="1" Body="&lt;p&gt;&lt;code&gt;local to window&lt;/code&gt; doesn't mean every buffer you loaded in the same window has the same &lt;code&gt;local to window&lt;/code&gt; options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;create new window&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://vimhelp.org/options.txt.html#local-options&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h local-options&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When splitting a window, the local options are copied to the new window.  Thus&#xA;  right after the split the contents of the two windows look the same.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;load new buffer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you load new buffer into window, &lt;code&gt;global window options&lt;/code&gt; are used, the current &lt;code&gt;local to window&lt;/code&gt; options are totally ignored, i believe this part works exactly the same as &lt;code&gt;local to buffer&lt;/code&gt;. When you call &lt;code&gt;set cc=..&lt;/code&gt;, both local and global values are changed, after you load new buffer, &lt;code&gt;colorcolumn&lt;/code&gt; is set from the &lt;code&gt;global&lt;/code&gt; one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;load existing buffer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://vimhelp.org/options.txt.html#local-options&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h local-options&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When editing a buffer that has been edited before, the options from the window&#xA;  that was last closed are used again.  If this buffer has been edited in this&#xA;  window, the values from back then are used.  Otherwise the values from the&#xA;  last closed window where the buffer was edited last are used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;IMHO, the doc is not precise, it should be &lt;code&gt;the options from the window that the buffer was last unloaded (from window, not from memory) are used again&lt;/code&gt;, it doesn't matter if the window is closed or not, so both &lt;code&gt;:q&lt;/code&gt; and &lt;code&gt;:e another_buffer&lt;/code&gt; counts.&#xA;It works like the buffer is never unloaded, everything is remembered, that's what most people desired. This explains why the last &lt;code&gt;colorcolumn&lt;/code&gt; is 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the &lt;code&gt;last unload window&lt;/code&gt; doesn't exists, the buffer is currently loaded in other window or windows (might be multiple), i believe local options are copied from the last window that load the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Experiment&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To help you understand the behavior of loading existing buffer, do this step by step :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim /tmp/abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Copy following commands and execute them with &lt;code&gt;:@+&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setlocal colorcolumn=10&#xA;:wincmd v&#xA;:wincmd l&#xA;:setlocal colorcolumn=20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Left window has &lt;code&gt;colorcolumn&lt;/code&gt; set to &lt;code&gt;10&lt;/code&gt;, right window has &lt;code&gt;colorcolumn&lt;/code&gt; set to &lt;code&gt;20&lt;/code&gt;, check it with &lt;code&gt;setlocal colorcolumn?&lt;/code&gt; (If you can see the column, check with your eye). Continue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h&#xA;:b abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h&lt;/code&gt; is used to avoid split with the same buffer. check &lt;code&gt;setlocal colorcolumn?&lt;/code&gt;, it should be &lt;code&gt;20&lt;/code&gt;, which is the same as bottom right window, as bottom right window is the last window that load the buffer when no &lt;code&gt;last unload window&lt;/code&gt; exists. Continue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1wincmd w&#xA;edit /tmp/balabala&#xA;setlocal colorcolumn=30&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These commands goto left window, edit a new buffer (cause unload of original buffer), and set local &lt;code&gt;colorcolumn&lt;/code&gt; to &lt;code&gt;30&lt;/code&gt;, check it with &lt;code&gt;setlocal colorcolumn?&lt;/code&gt;. Continue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:b abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check &lt;code&gt;setlocal colorcolumn?&lt;/code&gt;, it should be 10, the same as before it's unloaded, it's set from the &lt;code&gt;last unload window&lt;/code&gt;. Continue&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:2wincmd q&#xA;:h&#xA;:b abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check &lt;code&gt;setlocal colorcolumn?&lt;/code&gt;, it should be 20, it's set from the &lt;code&gt;last unload window&lt;/code&gt; (caused by &lt;code&gt;q&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-17T13:34:03.417" LastActivityDate="2019-06-17T13:34:03.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20337" PostTypeId="2" ParentId="20335" CreationDate="2019-06-17T11:21:38.457" Score="2" Body="&lt;p&gt;While mappings and abbreviations in insert mode should work, Vim has a large number of plugins -- some of them may have proven and largely tested solutions since what you are asking is probably a common feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the keywords you could try searching plugins for are &lt;a href=&quot;https://vimawesome.com/?q=complete&quot; rel=&quot;nofollow noreferrer&quot;&gt;complete&lt;/a&gt; and &lt;a href=&quot;https://vimawesome.com/?q=braces&quot; rel=&quot;nofollow noreferrer&quot;&gt;braces&lt;/a&gt;.&#xA;This last search, for example, brings &lt;a href=&quot;https://vimawesome.com/plugin/vim-c-cr&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-c-cr&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Finish braces, brackets and parentheses with ctrl+enter in vim&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A very simple and small (33 lines of vimscript) plugin that maps&#xA;  ctrl+enter () and ctrl+c ( for terminal-vim users) in&#xA;  insert mode to finish braces ({}), brackets ([]) and parentheses (())&#xA;  for you and puts your cursor tabbed over on a blank line between them.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But you certainly can find more plugins with similar behavior.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2019-06-17T11:21:38.457" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20339" PostTypeId="1" AcceptedAnswerId="20342" CreationDate="2019-06-17T19:23:06.817" Score="1" ViewCount="2143" Body="&lt;p&gt;I have a neovim session saved using &lt;code&gt;:mks&lt;/code&gt; which by default saves to a subdirectory in my project &lt;code&gt;~/project/subdir/Session.vim&lt;/code&gt;. I want it to save to &lt;code&gt;~/project/Session.vim&lt;/code&gt;, which I can do by running &lt;code&gt;:cd&lt;/code&gt; to change directories and then running &lt;code&gt;:mks&lt;/code&gt;, but every time I load up the session, it changes the working directory back to &lt;code&gt;~/project/subdir&lt;/code&gt;. How can I get it to save the changed working directory?&lt;/p&gt;&#xA;" OwnerUserId="687" LastActivityDate="2019-06-21T05:55:35.613" Title="Change saved session's working directory" Tags="|neovim|sessions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20340" PostTypeId="1" CreationDate="2019-06-17T21:40:03.593" Score="2" ViewCount="2032" Body="&lt;p&gt;I normally write my functions this way&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void test() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to continue, I need to insert a new line from within the brackets, so the final output is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void test(){&#xA;    // cursor is here now&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To do so in vim, I follow these steps: (the pipe is where the cursor at)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void test() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I press &lt;kbd&gt;Esc&lt;/kbd&gt; to go to normal mode, then &lt;kbd&gt;j&lt;/kbd&gt; so now my cursor is here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void test() {|}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I press &lt;kbd&gt;i&lt;/kbd&gt; to go to insert mode and then &lt;kbd&gt;enter&lt;/kbd&gt; twice so now I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void test() {&#xA;&#xA;|}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then I press &lt;kbd&gt;Esc&lt;/kbd&gt; to go to normal mode and then &lt;kbd&gt;k&lt;/kbd&gt; to go up a line, and then &lt;kbd&gt;i&lt;/kbd&gt; to go to insert mode and then &lt;kbd&gt;tab&lt;/kbd&gt; to get to the desired outcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I really don't wanna use plugins, I hope native vim helps me.&lt;/p&gt;&#xA;" OwnerUserId="22692" LastEditorUserId="1841" LastEditDate="2019-06-18T08:27:23.617" LastActivityDate="2021-10-19T00:21:53.857" Title="how to have a new line from within brackets" Tags="|cursor-motions|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20341" PostTypeId="2" ParentId="20340" CreationDate="2019-06-17T23:21:27.197" Score="2" Body="&lt;p&gt;Turn on &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27autoindent%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'autoindent'&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27smartindent%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'smartindent'&lt;/a&gt; , assume current typing is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void test(){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;input &lt;kbd&gt;enter&lt;/kbd&gt;&lt;kbd&gt;}&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void test(){&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;input &lt;kbd&gt;esc&lt;/kbd&gt;&lt;kbd&gt;O&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void test(){&#xA;    |&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you prefer &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-O&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h i_CTRL-O&lt;/a&gt; , replace &lt;kbd&gt;esc&lt;/kbd&gt; with &lt;kbd&gt;ctrl-o&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI, another way to reindent current line in &lt;code&gt;insert mode&lt;/code&gt; is &lt;a href=&quot;https://vimhelp.org/indent.txt.html#i_CTRL-F&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h i_CTRL-F&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-18T00:24:10.247" LastActivityDate="2019-06-18T00:24:10.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20342" PostTypeId="2" ParentId="20339" CreationDate="2019-06-18T04:53:16.193" Score="4" Body="&lt;p&gt;The behavior of &lt;a href=&quot;https://vimhelp.org/starting.txt.html#%3Amksession&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:mksession&lt;/code&gt;&lt;/a&gt; is driven by the flags you have set in &lt;a href=&quot;https://vimhelp.org/options.txt.html#&amp;#39;ssop&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'sessionoptions'&lt;/code&gt;&lt;/a&gt; (alias &lt;code&gt;'ssop'&lt;/code&gt;). The two flags that are likeliest to be factors here are &lt;code&gt;curdir&lt;/code&gt; and &lt;code&gt;sesdir&lt;/code&gt;. The former is simple, the current directory will be saved in the session data. The entry for &lt;code&gt;sesdir&lt;/code&gt; in Help says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt; sesdir     the directory in which the session file is located&#xA;            will become the current directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The two are not compatible (you shouldn't have them both set). &lt;code&gt;curdir&lt;/code&gt; is set by default but your explanation suggests that you have &lt;code&gt;sesdir&lt;/code&gt; enabled. Check your current configuration (&lt;code&gt;set ssop?&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to remove a default flag use &lt;code&gt;set ssop-=curdir&lt;/code&gt; (for example) in your vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; &lt;em&gt;Though OP has things working as needed and has accepted my answer, they still are describing behavior that doesn't jibe with how I believe Vim actually works. So I want to add some additional details with a more specific solution suggestion in case OP needs to revisit this.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My recommendation is to use &lt;code&gt;sesdir&lt;/code&gt; and then you'll see the behavior described below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you do &lt;code&gt;:mks /path/to/sess.vim&lt;/code&gt; the working dir doesn't matter as you've specified a path. When you later do &lt;code&gt;vim -S /path/to/sess.vim&lt;/code&gt; then &lt;code&gt;/path/to&lt;/code&gt; will be the working dir. That's it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if you don't specify a path? Then &lt;code&gt;sess.vim&lt;/code&gt; will be saved to the working dir of the window from which you issue the &lt;code&gt;:mks&lt;/code&gt; command. &lt;em&gt;It doesn't matter how or when the working dir was configured.&lt;/em&gt; It can be the &quot;default&quot; (whatever was set when you started Vim). Or it can be a dir you specified with &lt;em&gt;either&lt;/em&gt; &lt;code&gt;:cd&lt;/code&gt; or &lt;code&gt;:lcd&lt;/code&gt;. Regardless, when you later start Vim with &lt;code&gt;-S /some/path/sess.vim&lt;/code&gt; then, thanks to &lt;code&gt;sesdir&lt;/code&gt;, the working dir will be &lt;code&gt;/some/path&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have verified that all of the above is accurate.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-06-21T05:55:35.613" LastActivityDate="2019-06-21T05:55:35.613" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20344" PostTypeId="1" AcceptedAnswerId="20345" CreationDate="2019-06-18T07:51:54.237" Score="10" ViewCount="843" Body="&lt;p&gt;I stumbled recently upon a mapping in the &lt;a href=&quot;https://vim.fandom.com/wiki/Folding&quot; rel=&quot;noreferrer&quot;&gt;Vim Tips Wiki&lt;/a&gt; that uses an &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#expr-quote&quot; rel=&quot;noreferrer&quot;&gt;expr-quote&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Space&amp;gt; @=(foldlevel('.')?'za':&quot;\&amp;lt;Space&amp;gt;&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and realized it still worked after using a &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#literal-string&quot; rel=&quot;noreferrer&quot;&gt;literal-string&lt;/a&gt; instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Space&amp;gt; @=(foldlevel('.')?'za':'&amp;lt;Space&amp;gt;')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I find examples that use expr-quote over literal-string more often than not. Even the documentation for &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#feedkeys()&quot; rel=&quot;noreferrer&quot;&gt;feedkeys()&lt;/a&gt; mentions&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To include special keys into {string}, use double-quotes and &quot;\...&quot;&#xA;  notation |expr-quote|.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is there any particular reason to prefer the &lt;code&gt;&quot;\&amp;lt;xxx&amp;gt;&quot;&lt;/code&gt; notation over &lt;code&gt;'&amp;lt;xxx&amp;gt;'&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/9706/10164&quot;&gt;What is the difference between single and double quoted strings?&lt;/a&gt; answers this partially for special characters like &lt;code&gt;\n&lt;/code&gt;, but my question is specifically about the usage of special &lt;em&gt;named&lt;/em&gt; keys like &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt;, etc.&lt;/p&gt;&#xA;" OwnerUserId="10164" LastEditorUserId="10164" LastEditDate="2019-06-19T11:18:25.680" LastActivityDate="2022-04-18T04:55:30.057" Title="What's the functional difference between the key notations &quot;\&lt;xxx&gt;&quot; and '&lt;xxx&gt;'?" Tags="|vimscript|key-bindings|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20345" PostTypeId="2" ParentId="20344" CreationDate="2019-06-18T08:46:23.283" Score="12" Body="&lt;p&gt;Good question.  The keycode format with wider general usability is &lt;code&gt;&quot;\&amp;lt;xxx&amp;gt;&quot;&lt;/code&gt;. In any expression this will be replaced with the underlying numerical representation of the associated key (i.e.  the &quot;key code&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Per &lt;a href=&quot;https://vimhelp.org/intro.txt.html#keycodes&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h keycodes&lt;/code&gt;&lt;/a&gt; the other form, &lt;code&gt;&amp;lt;xxx&amp;gt;&lt;/code&gt;, is used in the documentation to represent &lt;em&gt;non-printing&lt;/em&gt; keys and, more relevant here, can be used to substitute the associated key &lt;em&gt;in mappings&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mappings-only restriction of &lt;code&gt;&amp;lt;xxx&amp;gt;&lt;/code&gt; is arguably the most critical difference between the two forms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To demonstrate take a look at these two expression commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe &quot;echom 'hi\&amp;lt;space&amp;gt;there'&quot;&#xA;exe &quot;echom 'hi&amp;lt;space&amp;gt;there'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first will print &lt;code&gt;hi there&lt;/code&gt; to the command line. The second will print &lt;code&gt;hi&amp;lt;space&amp;gt;there&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand if we put the same expressions in expression mappings...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; x &quot;:echom 'hi\&amp;lt;space&amp;gt;there'&amp;lt;cr&amp;gt;&quot;&#xA;nnoremap &amp;lt;expr&amp;gt; x &quot;:echom 'hi&amp;lt;space&amp;gt;there'&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...then when invoked both will print &lt;code&gt;hi there&lt;/code&gt;. (Note the oft-seen-in-mappings &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;, without which the preceding command will appear on the command line...followed by a waiting cursor...instead of being executed immediately. Now we recognize that as being another example of the no-backslash form &lt;code&gt;&amp;lt;xxx&amp;gt;&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, the &lt;code&gt;&quot;\&amp;lt;xxx&amp;gt;&quot;&lt;/code&gt; form is used quite a bit in certain Vim function parameters so it may be illuminating to go to &lt;a href=&quot;https://vimhelp.org/eval.txt.html#eval&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h eval&lt;/code&gt;&lt;/a&gt; and search for the string &lt;code&gt;\&amp;lt;&lt;/code&gt; to see a number of examples of this usage.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-06-30T01:51:53.190" LastActivityDate="2019-06-30T01:51:53.190" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20346" PostTypeId="1" CreationDate="2019-06-18T09:05:04.787" Score="0" ViewCount="886" Body="&lt;p&gt;For testing purposes I set the &lt;code&gt;setuid&lt;/code&gt; to my &lt;code&gt;vim&lt;/code&gt; binary. Now when I open for example &lt;code&gt;/etc/passwd&lt;/code&gt;, modify the file and execute &lt;code&gt;:w&lt;/code&gt;, then I get the &lt;code&gt;E45: 'readonly' option is set (add ! to override)&lt;/code&gt; error message. However, the &lt;code&gt;:w!&lt;/code&gt; saves the changes, i.e it is not a file-system restriction.&#xA;Based on what rules vim considers certain files as read-only?&lt;/p&gt;&#xA;" OwnerUserId="8626" LastActivityDate="2019-06-18T19:46:30.687" Title="How does vim decide if a file is &quot;readonly&quot;?" Tags="|security|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20347" PostTypeId="2" ParentId="20344" CreationDate="2019-06-18T09:43:32.940" Score="7" Body="&lt;p&gt;&lt;strong&gt;3 kinds of &amp;lt;xxxx&amp;gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;\&amp;lt;xxxx&amp;gt;&amp;quot;&#xA;'&amp;lt;xxxx&amp;gt;'&#xA;&amp;lt;xxxx&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Let's see &lt;code&gt;&amp;quot;\&amp;lt;xxxx&amp;gt;&amp;quot;&lt;/code&gt; first, &lt;a href=&quot;https://vimhelp.org/eval.txt.html#string&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h string&lt;/a&gt; says:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;`\&amp;lt;xxx&amp;gt; Special key named &amp;quot;xxx&amp;quot;.  e.g. &amp;quot;\&amp;lt;C-W&amp;gt;&amp;quot; for CTRL-W.`&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It's an expression, it's a string, a literal string for keycode, let's see it's relation ship with literal terminal keycode on my &lt;code&gt;xterm-256color&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;echo &amp;quot;\a&amp;quot;&lt;/code&gt; output &lt;code&gt;a&lt;/code&gt;, it's the same as terminal literal keycode&lt;br&gt;&#xA;&lt;code&gt;echo &amp;quot;\b&amp;quot;&lt;/code&gt; output &lt;code&gt;b&lt;/code&gt;, it's the same as terminal literal keycode&lt;br&gt;&#xA;...&lt;br&gt;&#xA;&lt;code&gt;echo &amp;quot;\&amp;lt;space&amp;gt;&amp;quot;&lt;/code&gt; output &lt;code&gt; &lt;/code&gt;, it's the same as terminal literal keycode&lt;br&gt;&#xA;&lt;code&gt;echo &amp;quot;\&amp;lt;c-a&amp;gt;&amp;quot;&lt;/code&gt; output &lt;code&gt;^a&lt;/code&gt;, it's the same as terminal literal keycode&lt;br&gt;&#xA;&lt;code&gt;echo &amp;quot;\&amp;lt;c-b&amp;gt;&amp;quot;&lt;/code&gt; output &lt;code&gt;^b&lt;/code&gt;, it's the same as terminal literal keycode&lt;br&gt;&#xA;...&lt;br&gt;&#xA;&lt;code&gt;echo &amp;quot;\&amp;lt;c-right&amp;gt;&amp;quot;&lt;/code&gt; output &lt;code&gt;&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;V&lt;/code&gt;, it's &lt;strong&gt;not the same&lt;/strong&gt; as terminal literal keycode&lt;br&gt;&#xA;&lt;code&gt;echo &amp;quot;\&amp;lt;c-left&amp;gt;&amp;quot;&lt;/code&gt;  output &lt;code&gt;&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;U&lt;/code&gt;, it's &lt;strong&gt;not the same&lt;/strong&gt; as terminal literal keycode&lt;br&gt;&#xA;&lt;code&gt;echo &amp;quot;\&amp;lt;f5&amp;gt;&amp;quot;&lt;/code&gt;  output &lt;code&gt;&amp;lt;80&amp;gt;k5&lt;/code&gt;, it's &lt;strong&gt;not the same&lt;/strong&gt; as terminal literal keycode&lt;br&gt;&#xA;&lt;code&gt;echo &amp;quot;\&amp;lt;f6&amp;gt;&amp;quot;&lt;/code&gt;  output &lt;code&gt;&amp;lt;80&amp;gt;k6&lt;/code&gt;, it's &lt;strong&gt;not the same&lt;/strong&gt; as terminal literal keycode&lt;br&gt;&#xA;...&lt;br&gt;&lt;/p&gt;&#xA;&lt;p&gt;So i believe &lt;code&gt;&amp;quot;\&amp;lt;xxxx&amp;gt;&amp;quot;&lt;/code&gt; is vim's internal keycode for keys, it's the same as terminal literal keycode if it doesn't starts with &lt;code&gt;0x80&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now let's see &lt;code&gt;'&amp;lt;xxxx&amp;gt;'&lt;/code&gt;, it's the same as &lt;code&gt;&amp;quot;&amp;lt;xxxx&amp;gt;&amp;quot;&lt;/code&gt;, it's an expression, it's a string, and that's it, there is nothing special about this string.&lt;/p&gt;&#xA;&lt;p&gt;Now let's see &lt;code&gt;&amp;lt;xxxx&amp;gt;&lt;/code&gt;, it's not an expression, it's also not a string, it's nothing by itself, it has to be used with  command like &lt;code&gt;map&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Map and all kinds of &amp;lt;xxxx&amp;gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Definition of &lt;code&gt;map&lt;/code&gt; without &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Map the key sequence {lhs} to {rhs} for the modes where the map command applies.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It's &lt;strong&gt;key sequence&lt;/strong&gt;, it works like you are typing it, remember that, it's very important.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/intro.txt.html#keycodes&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h keycodes&lt;/a&gt; says &lt;code&gt;&amp;lt;xxxx&amp;gt;&lt;/code&gt; can be used with &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :map&lt;/a&gt; command, e.g.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;down&amp;gt; &amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Above command map &lt;code&gt;&amp;lt;down&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; in insert mode, &lt;code&gt;map&lt;/code&gt; family command is smart, they interpret &lt;code&gt;&amp;lt;xxxx&amp;gt;&lt;/code&gt; style keycode as vim's internal keycode for special keys. Now turn on &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27showcmd%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'showcmd'&lt;/a&gt; , let's see another example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap '&amp;lt;down&amp;gt;' '&amp;lt;esc&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Type &lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;down arrow&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt; quickly in insert mode, you should see a single &lt;code&gt;'&lt;/code&gt;, and you are back to &lt;code&gt;normal mode&lt;/code&gt;, there should be a &lt;code&gt;'&lt;/code&gt; in right bottom of of your screen. Let's break it down: after you hit &lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;down arrow&lt;/kbd&gt;&lt;kbd&gt;'&lt;/kbd&gt; in insert mode, the map triggered, it's result is &lt;code&gt;'&amp;lt;esc&amp;gt;'&lt;/code&gt;, remember that map without &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; works like you are typing it, so you type &lt;kbd&gt;'&lt;/kbd&gt; &lt;kbd&gt;esc&lt;/kbd&gt;, vim return to normal mode, the last &lt;kbd&gt;'&lt;/kbd&gt; won't be discarded, it waits for you to enter a mark lonely in the right bottom.&lt;/p&gt;&#xA;&lt;p&gt;Another purpose of this example is to show you that &lt;code&gt;map&lt;/code&gt; without &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; knows nothing about &lt;code&gt;expression&lt;/code&gt;, when it saw &lt;code&gt;&amp;lt;xxxx&amp;gt;&lt;/code&gt;,  it knows it should be interpreted as special key code, it doesn't care if it's surrounded by &lt;code&gt;'&lt;/code&gt; or &lt;code&gt;&amp;quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The &amp;lt;c-r&amp;gt;=&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Let's see some wrong examples first, assume you want to map &lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; in insert mode:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-x&amp;gt; &amp;lt;c-r&amp;gt;='&amp;lt;esc&amp;gt;'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It won't work, because &lt;code&gt;map&lt;/code&gt; without &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; works like you are typing it, nothing good will happen if you type &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; in the middle of a string. Continue:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-x&amp;gt; &amp;lt;c-r&amp;gt;=&amp;quot;\&amp;lt;esc&amp;gt;&amp;quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This won't work too, &amp;quot;&amp;lt;xxxx&amp;gt;&amp;quot; doesn't have chance to do their job, for the same reason as above. In this case you must prevent vim from interpreting &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; as key code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-x&amp;gt; &amp;lt;c-r&amp;gt;=&amp;quot;\&amp;lt;lt&amp;gt;esc&amp;gt;&amp;quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;lt&amp;gt;&lt;/code&gt; is special keycode for &lt;code&gt;&amp;lt;&lt;/code&gt;, so after &lt;code&gt;map&lt;/code&gt; special keycode interpretation, &lt;code&gt;&amp;quot;\&amp;lt;lt&amp;gt;esc&amp;gt;&amp;quot;&lt;/code&gt; becomes &lt;code&gt;&amp;quot;\&amp;lt;esc&amp;gt;&amp;quot;&lt;/code&gt;, which is literal keycode for esc.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The &amp;lt;expr&amp;gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;&amp;quot;\&amp;lt;lt&amp;gt;esc&amp;gt;&amp;quot;&lt;/code&gt; is super ugly, &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :map-expression&lt;/a&gt; is much easier to work with, you provide an expression to &lt;code&gt;map &amp;lt;expr&amp;gt;&lt;/code&gt;, it's evaluated result will be used as &lt;code&gt;{rhs}&lt;/code&gt; for &lt;code&gt;map&lt;/code&gt;, the result is key sequence, the expression is not:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt; '&amp;lt;esc&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It's simple and beautiful. Don't miss the quote, both &lt;code&gt;'&amp;lt;xxxx&amp;gt;'&lt;/code&gt; and &lt;code&gt;&amp;quot;&amp;lt;xxxx&amp;gt;&amp;quot;&lt;/code&gt; work here. Note that &lt;code&gt;map&lt;/code&gt; still interpret &lt;code&gt;&amp;lt;xxxx&amp;gt;&lt;/code&gt; as special keycode, this rule won't change, never change, but only for &lt;code&gt;&amp;lt;xxxx&amp;gt;&lt;/code&gt; on the command, not for the result of the expression.&#xA;Let's use another example to explain that. Sometimes you want to use function as an expression:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-x&amp;gt; GetEsc()&#xA;function! GetEsc()&#xA;  return &amp;quot;&amp;lt;esc&amp;gt;&amp;quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Result of &lt;code&gt;GetEsc()&lt;/code&gt; is &lt;code&gt;&amp;quot;&amp;lt;esc&amp;gt;&amp;quot;&lt;/code&gt;, you hope that &lt;code&gt;map&lt;/code&gt; knows it's a special keycode. it won't work, &lt;code&gt;map&lt;/code&gt; recognize &lt;code&gt;&amp;lt;xxxx&amp;gt;&lt;/code&gt; as special keycode only if it's typed in the command directly, not for the expression result. The right form is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-x&amp;gt; GetEsc()&#xA;function! GetEsc()&#xA;  return &amp;quot;\&amp;lt;esc&amp;gt;&amp;quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="11054" LastEditDate="2022-04-18T04:55:30.057" LastActivityDate="2022-04-18T04:55:30.057" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20348" PostTypeId="1" CreationDate="2019-06-18T12:17:51.190" Score="1" ViewCount="694" Body="&lt;p&gt;for my &lt;code&gt;fortran&lt;/code&gt; code, I have defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType fortran let maplocalleader = &quot;`&quot;   # i have tried \` as well.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;fortran&lt;/code&gt; filetype in vim, &lt;code&gt;:echo maplocalleader&lt;/code&gt; is showing &lt;strong&gt;`&lt;/strong&gt; &#xA;as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, then, with my keyboard mapping as(inside a &lt;code&gt;ftplugin&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;localleader&amp;gt;wr      pr&amp;lt;c-r&amp;gt;=UltiSnips#ExpandSnippet()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or anything like this, defined &lt;code&gt;localleader&lt;/code&gt; is not honoured. Rather the expansion is working with &lt;code&gt;\&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am unable to guess what the problem is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help please?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am in vim8&lt;/p&gt;&#xA;" OwnerUserId="2738" LastEditorUserId="2738" LastEditDate="2019-06-18T12:34:42.780" LastActivityDate="2019-06-18T12:51:30.593" Title="localleader is not obeyed" Tags="|vimrc|snippets|leader|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20349" PostTypeId="2" ParentId="20348" CreationDate="2019-06-18T12:43:06.340" Score="4" Body="&lt;p&gt;When you register it this way, your new autocommand will be triggered after all other autocommands registered on the same event, in particular after the one that sources your ftplugin -- I suppose you define the mapping in an ftplugin (*).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could change that, probably by changing the order between this line and the &lt;code&gt;:filetype xxxx&lt;/code&gt; in your .vimrc, but this is not the right solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unlike what its name implies, &lt;em&gt;localleader&lt;/em&gt; is global. Somehow, I guess it's indeed meant to be used from filetype plugins, and buffer local-mappings, but you shall define it in your &lt;code&gt;.vimrc&lt;/code&gt;, once and for all, and for all filetypes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) if the mapping is defined in your &lt;code&gt;.vimrc&lt;/code&gt;, it has even less chances to work as you were expecting as the corresponding line would be sourced before any event is happening. IOW, the mapping would be defined before the filetype(=fortran)  event happens.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2019-06-18T12:51:30.593" LastActivityDate="2019-06-18T12:51:30.593" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20350" PostTypeId="1" AcceptedAnswerId="20351" CreationDate="2019-06-18T16:56:26.053" Score="1" ViewCount="178" Body="&lt;p&gt;my question is simillar to this: &lt;a href=&quot;https://vi.stackexchange.com/questions/6131/how-do-i-surround-a-quoted-string-without-including-leading-whitespace/6153#6153&quot;&gt;How do I surround a quoted string without including leading whitespace?&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But not exactly. I am using vim-surround.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a string &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print he^llo_and_welcome &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where ^ signify my cursor position&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want it to become &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print &quot;he^llo_and_welcome&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but ysaW&quot; includes leading whitespace and trying ys2i&quot;&quot; doesn't seem to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do? &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2023-09-02T12:04:30.050" Title="Add surrounding quotes no leading whitespace" Tags="|plugin-vim-surround|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20351" PostTypeId="2" ParentId="20350" CreationDate="2019-06-18T17:06:14.803" Score="3" Body="&lt;p&gt;Change your command to use inner Word: &lt;code&gt;ysiW&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to read the following help topic to understand better the difference between &lt;code&gt;iW&lt;/code&gt; and &lt;code&gt;aW&lt;/code&gt;: &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#aW&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h aW&lt;/code&gt;&lt;/a&gt; &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#iW&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h iW&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22529" LastEditorUserId="1841" LastEditDate="2019-06-18T17:38:58.817" LastActivityDate="2019-06-18T17:38:58.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20352" PostTypeId="2" ParentId="9236" CreationDate="2019-06-18T17:07:48.210" Score="2" Body="&lt;p&gt;So to conclude, one has to do:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :vimgrep /text/ path_to_dir/* path_to_dir/**/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if he wants to include the dir. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-06-18T17:07:48.210" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20354" PostTypeId="1" CreationDate="2019-06-18T19:28:24.367" Score="1" ViewCount="175" Body="&lt;p&gt;I have some text selected in select mode.  I want to delete it and start insert-mode completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I type these keystrokes into Vim it works perfectly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvc&amp;lt;C-X&amp;gt;&amp;lt;C-U&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gv&lt;/code&gt; switches to visual mode; &lt;code&gt;c&lt;/code&gt; changes / cuts the selection and switches to insert mode; and the rest triggers insert-mode completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when I try to this from Vimscript it doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal! gvc\&amp;lt;C-X&amp;gt;\&amp;lt;C-U&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;gv&lt;/code&gt; part works but the &lt;code&gt;c&lt;/code&gt; cuts a character extra at the right hand end of the selection, and the cursor ends up one character before where I want it (in insert mode, which is correct), and the completion doesn't start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if &lt;code&gt;bar&lt;/code&gt; is selected in the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo(bar, baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;– then after my &lt;code&gt;execute &quot;normal! ...&quot;&lt;/code&gt; I am left with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo( baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;– with the cursor just before the bracket.  What I want is &lt;code&gt;foo(, baz&lt;/code&gt; with the cursor just after the bracket and the completion menu open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get this working via Vimscript?&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2019-06-18T19:28:24.367" Title="How to start insert-mode completion from select mode using Vimscript?" Tags="|visual-mode|ins-completion|selection|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20355" PostTypeId="2" ParentId="20346" CreationDate="2019-06-18T19:46:30.687" Score="2" Body="&lt;p&gt;Based on a quick experiment:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;# touch readonly&#xA;# chmod a-w readonly&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, &lt;code&gt;vim readonly&lt;/code&gt; will start in readonly mode, because the current user does not have write permission. But, as root or as a regular user (file owner only? untested with other regular users), &lt;code&gt;w!&lt;/code&gt; can bypass this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, from the help, &lt;code&gt;vim&lt;/code&gt; will start with &lt;code&gt;'readonly'&lt;/code&gt; set if&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vim starts with the &lt;code&gt;-R&lt;/code&gt; flag&lt;/li&gt;&#xA;&lt;li&gt;the executable is named &lt;code&gt;view&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When using &quot;:w!&quot; the 'readonly' option is reset for the current&#xA;      buffer, unless the 'Z' flag is in 'cpoptions'.&#xA;      When using the &quot;:view&quot; command the 'readonly' option is set for the&#xA;      newly edited buffer. (&lt;code&gt;:h 'readonly'&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-18T19:46:30.687" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20356" PostTypeId="1" CreationDate="2019-06-18T20:34:04.887" Score="0" ViewCount="459" Body="&lt;p&gt;Currently I installed vim addons for python. &#xA;&lt;a href=&quot;http://fisadev.github.io/fisa-vim-config/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://fisadev.github.io/fisa-vim-config/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I don't like the +/-/! on the margin. Does anyone know how to disable all of them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7NCg8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7NCg8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22706" LastActivityDate="2019-06-19T12:34:41.550" Title="How to disable margin (+/!)?" Tags="|vimrc|syntax-highlighting|highlight|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20357" PostTypeId="1" AcceptedAnswerId="20358" CreationDate="2019-06-18T20:44:27.810" Score="1" ViewCount="203" Body="&lt;p&gt;I'd like to go directly into command line mode from insert mode, enter a single command (say &lt;code&gt;:r !date&lt;/code&gt; which inserts the date) and then go immediately back into insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically something similar to the Ctrl-o command for entering normal mode for a single command then returning to insert mode. &lt;/p&gt;&#xA;" OwnerUserId="20443" LastEditorUserId="21062" LastEditDate="2019-08-06T22:20:14.220" LastActivityDate="2019-08-06T22:20:14.220" Title="Is there a way to enter command line mode for a single command directly from insert mode?" Tags="|command-line|insert-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20358" PostTypeId="2" ParentId="20357" CreationDate="2019-06-18T23:09:28.917" Score="3" Body="&lt;p&gt;I believe &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-o&amp;gt;:r !date&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will work&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-18T23:09:28.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20359" PostTypeId="2" ParentId="20356" CreationDate="2019-06-18T23:10:35.303" Score="3" Body="&lt;p&gt;Try turning off the signcolumn:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set signcolumn=no&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-06-19T12:34:41.550" LastActivityDate="2019-06-19T12:34:41.550" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20360" PostTypeId="1" CreationDate="2019-06-19T01:37:22.890" Score="1" ViewCount="253" Body="&lt;p&gt;Saving a file with &lt;code&gt;:w&lt;/code&gt; takes several seconds for me, and I can't figure out the culprit. This is my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Specify a directory for plugins&#xA;&quot; - For Neovim: ~/.local/share/nvim/plugged&#xA;&quot; - Avoid using standard Vim directory names like 'plugin'&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;  Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }&#xA;  Plug 'lifepillar/vim-solarized8'&#xA;&#xA;&quot; Initialize plugin system&#xA;call plug#end()&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot;      Settings      &quot;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;set nocompatible                &quot; Enables us Vim specific features&#xA;filetype off                    &quot; Reset filetype detection first ...&#xA;filetype plugin indent on       &quot; ... and enable filetype detection&#xA;set ttyfast                     &quot; Indicate fast terminal conn for faster redraw&#xA;set ttymouse=xterm2             &quot; Indicate terminal type for mouse codes&#xA;set ttyscroll=3                 &quot; Speedup scrolling&#xA;set laststatus=2                &quot; Show status line always&#xA;set encoding=utf-8              &quot; Set default encoding to UTF-8&#xA;set autoread                    &quot; Automatically read changed files&#xA;set autoindent                  &quot; Enabile Autoindent&#xA;set backspace=indent,eol,start  &quot; Makes backspace key more powerful.&#xA;set incsearch                   &quot; Shows the match while typing&#xA;set hlsearch                    &quot; Highlight found searches&#xA;&#xA;set noerrorbells                &quot; No beeps&#xA;set number                      &quot; Show line numbers&#xA;set showcmd                     &quot; Show me what I'm typing&#xA;set noswapfile                  &quot; Don't use swapfile&#xA;set nobackup                    &quot; Don't create annoying backup files&#xA;set splitright                  &quot; Vertical windows should be split to right&#xA;set splitbelow                  &quot; Horizontal windows should split to bottom&#xA;set autowrite                   &quot; Automatically save before :next, :make etc.&#xA;                &quot; Don't need to write before calling :GoBuild!&#xA;set hidden                      &quot; Buffer should still exist if window is closed&#xA;set fileformats=unix,dos,mac    &quot; Prefer Unix over Windows over OS 9 formats&#xA;set noshowmatch                 &quot; Do not show matching brackets by flickering&#xA;set noshowmode                  &quot; We show the mode with airline or lightline&#xA;set ignorecase                  &quot; Search case insensitive...&#xA;set smartcase                   &quot; ... but not it begins with upper case&#xA;set completeopt=menu,menuone    &quot; Show popup menu, even if there is one entry&#xA;set pumheight=10                &quot; Completion window max size&#xA;set nocursorcolumn              &quot; Do not highlight column (speeds up highlighting)&#xA;set nocursorline                &quot; Do not highlight cursor (speeds up highlighting)&#xA;set lazyredraw                  &quot; Wait to redraw&#xA;&#xA;set belloff=all&#xA;&#xA;&quot; Strips trailing whitespace&#xA;autocmd BufWritePre * %s/\s\+$//e&#xA;&#xA;&quot; Clears search buffer with ,/&#xA;nmap &amp;lt;silent&amp;gt; ,/ :nohlsearch&amp;lt;CR&amp;gt;&#xA;&quot; Turn off search highlight&#xA;nnoremap &amp;lt;leader&amp;gt;&amp;lt;space&amp;gt; :nohlsearch&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Enable to copy to clipboard for operations like yank, delete, change and put&#xA;&quot; http://stackoverflow.com/questions/20186975/vim-mac-how-to-copy-to-clipboard-without-pbcopy&#xA;if has('unnamedplus')&#xA;  set clipboard^=unnamed&#xA;  set clipboard^=unnamedplus&#xA;else&#xA;  set clipboard=unnamed&#xA;endif&#xA;&#xA;&quot; Colorscheme&#xA;let g:solarized_use16 = 1&#xA;set background=light&#xA;colorscheme solarized8&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot;      Mappings      &quot;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&#xA;&quot; Set leader shortcut to a comma ','. By default it's the backslash&#xA;let mapleader = &quot; &quot;&#xA;&#xA;&quot; Search mappings: These will make it so that going to the next one in a&#xA;&quot; search will center on the line it's found in.&#xA;nnoremap n nzzzv&#xA;nnoremap N Nzzzv&#xA;&#xA;&quot; Act like D and C&#xA;nnoremap Y y$&#xA;&#xA;&quot; Settings: Mouse &amp;amp; Scrolling&#xA;set mouse=a&#xA;nnoremap &amp;lt;2-LeftMouse&amp;gt; &amp;lt;nop&amp;gt;&#xA;inoremap &amp;lt;2-LeftMouse&amp;gt; &amp;lt;nop&amp;gt;&#xA;vnoremap &amp;lt;2-LeftMouse&amp;gt; &amp;lt;nop&amp;gt;&#xA;nnoremap &amp;lt;ScrollWheelUp&amp;gt; &amp;lt;C-y&amp;gt;&#xA;nnoremap &amp;lt;ScrollWheelDown&amp;gt; &amp;lt;C-e&amp;gt;&#xA;nnoremap &amp;lt;Up&amp;gt; &amp;lt;C-y&amp;gt;&#xA;nnoremap &amp;lt;Down&amp;gt; &amp;lt;C-e&amp;gt;&#xA;&#xA;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&quot;      Plugins      &quot;&#xA;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&#xA;&#xA;&quot; vim-go&#xA;let g:go_fmt_command = &quot;goimports&quot;&#xA;let g:go_def_mode='gopls'&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What can I do to speed this up?&lt;/p&gt;&#xA;" OwnerUserId="22708" LastActivityDate="2019-06-19T01:37:22.890" Title="Simple .vimrc takes a very long time to save" Tags="|vimrc|macvim|performance|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20361" PostTypeId="1" CreationDate="2019-06-19T12:04:56.893" Score="1" ViewCount="28" Body="&lt;p&gt;So I am curious about one thing:&#xA;when I am between two brackets (&lt;code&gt;{&lt;/code&gt;) in vim (or nvim), and I press &lt;kbd&gt;Enter&lt;/kbd&gt; I go from this (where the pipe sign is the cursor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getUsers(){|}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getUsers(){&#xA;|}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I customize the editor to get this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getUsers(){&#xA;··|&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22710" LastEditorUserId="22710" LastEditDate="2019-06-19T15:27:38.783" LastActivityDate="2019-06-19T15:27:38.783" Title="How to get the right indentation and new line when adding a new line between brackets?" Tags="|indentation|" AnswerCount="0" CommentCount="2" ClosedDate="2019-06-19T12:19:35.157" ContentLicense="CC BY-SA 4.0" />
  <row Id="20362" PostTypeId="1" AcceptedAnswerId="20675" CreationDate="2019-06-19T14:02:08.040" Score="1" ViewCount="1218" Body="&lt;p&gt;Is there a way to 'delete current, and cnext' so that when progressing through the quickfix list progress can more easily be seen, and, when all quick fixes have been made, the window automatically closes?&lt;/p&gt;&#xA;" OwnerUserId="5778" LastEditorUserId="5778" LastEditDate="2019-09-27T12:53:24.680" LastActivityDate="2019-09-27T12:53:24.680" Title="Go to next quickfix entry, removing current?" Tags="|quickfix|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20363" PostTypeId="1" CreationDate="2019-06-19T14:09:26.677" Score="1" ViewCount="1450" Body="&lt;p&gt;I'd like to be able to define my own functions that add certain kinds of line to the quickfix list, or set it to those in its entirety, without having to go via the filesystem with a made-up &lt;code&gt;errorfile&lt;/code&gt; format that I tell vim how to parse (&lt;code&gt;errorfmt&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen &lt;code&gt;setqflist&lt;/code&gt; and &lt;code&gt;getqflist&lt;/code&gt;, but the only other questions or discussion I've seen about this has been people wanting to remove entries, and so the answer ends up being &lt;code&gt;filter&lt;/code&gt; - which doesn't tell me how to format an entry if I want to &lt;em&gt;add&lt;/em&gt; one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if I'm to call &lt;code&gt;setqflist(my_errs)&lt;/code&gt;, how should I define &lt;code&gt;my_errs&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5778" LastActivityDate="2019-07-20T16:01:15.197" Title="How to use setqflist to add an entry to the quickfix list" Tags="|quickfix|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20364" PostTypeId="2" ParentId="20362" CreationDate="2019-06-19T15:37:17.763" Score="0" Body="&lt;p&gt;Just don't open the quickfix list in the first place. Both &lt;code&gt;:cnext&lt;/code&gt; &amp;amp; &lt;code&gt;:cprev&lt;/code&gt; give you information like &lt;code&gt;(1 of 10)&lt;/code&gt;. And &lt;code&gt;:cc&lt;/code&gt; will give you the current quickfix list information. You can use &lt;code&gt;:clist&lt;/code&gt; to print out the list without opening a window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may need to look for &lt;code&gt;:cwindow&lt;/code&gt; / &lt;code&gt;:copen&lt;/code&gt; if the quickfix list is opening automatically or you copied part of your &lt;code&gt;vimrc&lt;/code&gt; from someplace else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h quickfix&#xA;:h :cnext&#xA;:h :cc&#xA;:h :clist&#xA;:h :cwindow&#xA;:h :copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-06-19T15:37:17.763" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20365" PostTypeId="2" ParentId="20363" CreationDate="2019-06-19T15:43:38.990" Score="2" Body="&lt;p&gt;&lt;code&gt;getqflist()&lt;/code&gt; and &lt;code&gt;setqflist()&lt;/code&gt; are sort of opposites. Printing out the results of &lt;code&gt;getqflist()&lt;/code&gt; will give you and idea of the structure &lt;code&gt;setqflist()&lt;/code&gt; is looking for.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setqflist(getqflist())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Recent versions of Vim (8+) also allow you to use &lt;code&gt;lines&lt;/code&gt; &amp;amp; &lt;code&gt;efm&lt;/code&gt; to parse a list of lines with a different format than the current &lt;code&gt;'errorformat'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information see &lt;code&gt;:h setqflist()&lt;/code&gt; &amp;amp; &lt;code&gt;:h getqflist()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-06-19T15:43:38.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20366" PostTypeId="1" AcceptedAnswerId="20367" CreationDate="2019-06-19T20:08:07.100" Score="0" ViewCount="266" Body="&lt;h1&gt;My Problem&lt;/h1&gt;&#xA;&#xA;&lt;h2&gt;Going from:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fCOUI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fCOUI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;To:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JHKYP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JHKYP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm doing some editing (interactive rebase on a git repo, but the problem is generally relevant). &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The cursor is on a word (&lt;code&gt;pick&lt;/code&gt;), and I would like to delete it , regardless of the cursor position in it&lt;/li&gt;&#xA;&lt;li&gt;Then, take the cursor back to the position of its first characterand&lt;/li&gt;&#xA;&lt;li&gt;Immediately insert the new word (&lt;code&gt;r&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;My Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Is there a shortcut to the common sequence of: Delete word, go to its beginning, move to insert mode?&lt;/p&gt;&#xA;" OwnerUserId="13179" LastActivityDate="2019-06-19T20:16:11.950" Title="Delete word around cursor and move to insert mode" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20367" PostTypeId="2" ParentId="20366" CreationDate="2019-06-19T20:16:11.950" Score="5" Body="&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ciw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mnemonic is &lt;strong&gt;c&lt;/strong&gt;hange &lt;strong&gt;i&lt;/strong&gt;nside &lt;strong&gt;w&lt;/strong&gt;ord.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;c&lt;/code&gt; command is like the &lt;code&gt;d&lt;/code&gt; command, except that it immediately goes to insert mode afterwards. So this is really like using &lt;code&gt;diwi&lt;/code&gt;. Using &lt;code&gt;iw&lt;/code&gt; instead of &lt;code&gt;w&lt;/code&gt; is to make sure the whole word your cursor is on gets deleted, not just the rest of the word from where your cursor is.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-06-19T20:16:11.950" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20369" PostTypeId="1" CreationDate="2019-06-19T21:37:15.230" Score="3" ViewCount="859" Body="&lt;p&gt;I've been using Vim with vim-plug, yiang-miao/auto-pairs and youcompleteme for a time now, and I really love it; but a friend recently recommended me NeoVim, and it seems it's more polished since it's community driven.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;He also suggested I used it without any plugins, but is the autocomplete function on NeoVim better than normal Vim's? I found Vim's built-in lacking coming from VScode, but I don't want to noticeably slow down NeoVim unnecessarily.&lt;/p&gt;&#xA;" OwnerUserId="22707" LastEditorUserId="11054" LastEditDate="2019-06-20T02:48:39.633" LastActivityDate="2019-07-16T05:14:11.103" Title="Does NeoVim really need plugins in 2019?" Tags="|neovim|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20370" PostTypeId="2" ParentId="20369" CreationDate="2019-06-19T22:29:21.020" Score="6" Body="&lt;p&gt;Actually, one big (huge!) feature of NeoVim and Vim 8 is actually meant for plug-in writers, which is the ability to do &lt;a href=&quot;https://vimhelp.org/eval.txt.html#job_start%28%29&quot; rel=&quot;noreferrer&quot;&gt;asynchronous communication&lt;/a&gt; with external jobs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is especially useful for plug-ins that communicate with external commands, doing tasks such as completion (YouCompleteMe, Deoplete, plug-ins that communicate with a language server using the LSP protocol) or linting (ALE, etc.)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;He also suggested I used it without any plugins, but is the autocomplete function on NeoVim better than normal Vim's?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not really. Vim's autocompletion features have been around and haven't been significantly changed in NeoVim or Vim 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I imagine your friend's recommendation to use it without plug-ins is so that you can experience the full power of native Vim autocompletion and learn to use its advanced features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I don't really use a plug-in to do autocompletion, but I do generate &lt;code&gt;ctags&lt;/code&gt; for most projects I work on and I use &lt;a href=&quot;https://vimhelp.org/insert.txt.html#compl-tag&quot; rel=&quot;noreferrer&quot;&gt;completion from tags&lt;/a&gt;, which I find does quite a good job for my needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I actually &lt;em&gt;do&lt;/em&gt; use a &lt;a href=&quot;https://github.com/ludovicchabant/vim-gutentags&quot; rel=&quot;noreferrer&quot;&gt;plug-in&lt;/a&gt; to generate and keep the &lt;code&gt;ctags&lt;/code&gt; file up to date, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end, it's up to you to decide how Vim works best for you. If you're happy with your current plug-ins, by all means keep using them in NeoVim! If you would like to see more of what it can do out-of-the-box, then disable the plug-ins to &quot;force&quot; you to learn the native way. And don't forget the two are not mutually exclusive, you can still use native completion even if you're also using a plug-in!&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-06-19T22:29:21.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20371" PostTypeId="1" CreationDate="2019-06-20T01:37:20.137" Score="5" ViewCount="1078" Body="&lt;h2&gt;Background and problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I've just discovered &lt;a href=&quot;https://stackoverflow.com/a/42118416/1944384&quot;&gt;how to make the cursor a vertical line&lt;/a&gt; in insert mode. This works well with &lt;a href=&quot;https://stackoverflow.com/a/6489348/1944384&quot;&gt;cursorline&lt;/a&gt;; even with the thinner cursor, I can still easily find my position.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd InsertEnter * set cul&#xA;autocmd InsertLeave * set nocul&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the default underline makes it hard to see literal underscore characters &lt;code&gt;_&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Attempts&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I know I can change the highlighting of &lt;code&gt;CursorLine&lt;/code&gt;, which would make underscores visible again, but this breaks syntax highlighting.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.reddit.com/r/vim/comments/45t1on/how_to_make_underscores_more_visible_with/czzyzdq/&quot; rel=&quot;noreferrer&quot;&gt;Another option&lt;/a&gt; is to highlight the underscore character itself in Insert mode. However, this seems like overkill, because I don't want every single underscore highlighted. Also, it doesn't work for areas that are syntax highlighted.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match underscore &quot;_&quot;&#xA;autocmd InsertEnter * hi underscore ctermbg=grey cterm=none ctermfg=black&#xA;autocmd InsertLeave * hi clear underscore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;I also know that I can change the cursorline to bold, italics, etc., but this is also visual overkill.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;An ideal solution would be to make the cursorline underline be a light colour, with the literal underscore a darker black, but it seems that cursorline always inherits &lt;code&gt;ctermfg&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is there a simple way to still see underscores, while using cursorline?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using regular terminal vim (in Terminator generally), not gvim.&lt;/p&gt;&#xA;" OwnerUserId="1278" LastEditorUserId="1278" LastEditDate="2019-06-20T05:19:44.667" LastActivityDate="2022-01-30T05:57:08.803" Title="How can I still see underscores with cursorline?" Tags="|highlight|cursorline|" AnswerCount="2" CommentCount="18" ContentLicense="CC BY-SA 4.0" />
  <row Id="20373" PostTypeId="1" CreationDate="2019-06-20T12:49:51.157" Score="1" ViewCount="74" Body="&lt;p&gt;To perform a buffer-wide substitution on all occurrences of &lt;code&gt;foo&lt;/code&gt; (and not just the 1st one in a line), we can do&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;%s/foo/bar/g&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;g&lt;/code&gt; flag may be omitted by setting this in the &lt;code&gt;vimrc&lt;/code&gt; as&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;set gdefault&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If the pattern &lt;code&gt;foo&lt;/code&gt; is not found, &lt;code&gt;vim&lt;/code&gt; raises an error&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E486: Pattern not found: foo                                                                                                                                      &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This error can be avoided by specifying the &lt;code&gt;e&lt;/code&gt; flag to the substitution operator i.e. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;%s/foo/bar/ge&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My question is, can an equivalent option (say &lt;code&gt;edefault&lt;/code&gt;) that can be put together in a &lt;code&gt;vimrc&lt;/code&gt; to achieve this effect?&lt;/p&gt;&#xA;" OwnerUserId="8408" LastActivityDate="2019-06-20T12:49:51.157" Title="Is there an `edefault` in the spirit of `gdefault` for setting the appropriate flags in vim's substitution commands?" Tags="|vimrc|substitute|options|default-settings|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20374" PostTypeId="2" ParentId="15584" CreationDate="2019-06-20T13:58:53.663" Score="10" Body="&lt;h1&gt;View diff of a swap file without plugins&lt;/h1&gt;&#xA;&lt;p&gt;Without plugins, you can use vim &lt;a href=&quot;https://stackoverflow.com/a/5182973/5720818&quot;&gt;alternate-file&lt;/a&gt;.&#xA;Wikia source: &lt;a href=&quot;https://vim.fandom.com/wiki/Diff_current_buffer_and_the_original_file&quot; rel=&quot;noreferrer&quot;&gt;Diff current buffer and the original file&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In short, try this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:diffthis | :vnew | r # | exe &amp;quot;norm! ggdd&amp;quot; | :diffthis&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Explained:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; start diff in current window with restored swap file&#xA;:diffthis &#xA;&#xA;&amp;quot; read origin file in new vsplit&#xA;:vnew | r # &#xA;&#xA;&amp;quot; Note: origin file is read to buffer,&#xA;&amp;quot; but first line is epmty&#xA;&amp;quot; It's a feature, so let's delete first empty line &#xA;:exe &amp;quot;norm! ggdd&amp;quot; &#xA;&#xA;&amp;quot; start diff mode in vsplit&#xA;:diffthis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;View and merge diff of a swap file using &lt;a href=&quot;https://github.com/chrisbra/recover.vim&quot; rel=&quot;noreferrer&quot;&gt;Recover&lt;/a&gt; plugin&lt;/h1&gt;&#xA;&lt;p&gt;Also, there is a plugin &lt;a href=&quot;https://github.com/chrisbra/recover.vim&quot; rel=&quot;noreferrer&quot;&gt;Recover.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Found a swap file by the name &amp;quot;test/normal/.testfile.swp&amp;quot;&#xA;        owned by: chrisbra   dated: Wed Nov 28 16:26:42 2012&#xA;        file name: ~chrisbra/code/git/vim/Recover/test/normal/testfile&#xA;        modified: YES&#xA;        user name: chrisbra   host name: R500&#xA;        process ID: 4878 [not existing]&#xA;While opening file &amp;quot;test/normal/testfile&amp;quot;&#xA;            dated: Tue Nov  6 20:11:55 2012&#xA;Please choose:&#xA;[C]ompare, (O)pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort, (D)elete:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After merge, you can delete swap-file using command &lt;code&gt;:FinishRecovery&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="22724" LastEditorUserId="22724" LastEditDate="2020-12-27T08:27:17.003" LastActivityDate="2020-12-27T08:27:17.003" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20375" PostTypeId="1" CreationDate="2019-06-20T15:00:26.377" Score="1" ViewCount="175" Body="&lt;p&gt;I want to know if there is a way to setup vim (internal feature, plugin) in such a way that it would raise an alarm (bell, flashing screen, anything) if there were NO changes to the find within a specific number of seconds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The vim window will always be on screen, and the use case is to ensure that notes are taken &lt;em&gt;during&lt;/em&gt; an event, rather than waiting until the end of the event and writing some. &lt;/p&gt;&#xA;" OwnerUserId="8792" LastActivityDate="2019-06-25T02:35:48.590" Title="Alarm for inactivity" Tags="|vimscript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20376" PostTypeId="2" ParentId="20363" CreationDate="2019-06-20T15:54:04.250" Score="1" Body="&lt;p&gt;I have this function. &#xA;The format of setloclist is the same as of setqflist. &#xA;Hope you find it helpful. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to set in the argument action 'a' for add. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Matches(pat)&#xA;let buffer=bufnr(&quot;&quot;) &quot;current buffer number&#xA;let b:lines=[]&#xA;&quot;the right way to escape!!&#xA;execute &quot;:%g/\\V&quot; . escape(a:pat,'/\?') . &quot;/let b:lines+=[{'bufnr':&quot; . 'buffer' . &quot;, 'lnum':&quot; . &quot;line('.')&quot; . &quot;, 'text': escape(getline('.'),'\&quot;')}]&quot;&#xA;&quot;call setloclist(0, [], ' ', {'items': b:lines}) &#xA;call setloclist(0,b:lines)&#xA;lopen&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-06-20T15:59:36.763" LastActivityDate="2019-06-20T15:59:36.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20377" PostTypeId="1" CreationDate="2019-06-20T18:06:20.623" Score="0" ViewCount="39" Body="&lt;p&gt;I don't know what changed recently but my NerdTree keeps opening up super wide and pushing my existing window to the right. Here's a picture:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before opening NerdTree:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lvopT.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lvopT.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Qts5N.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qts5N.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried adding this line to my vimrc file: &lt;code&gt;let g:NERDTreeWinSize = 1&#xA;&lt;/code&gt; but when I exit out of VIM and open it again nothing changes.&lt;/p&gt;&#xA;" OwnerUserId="22728" LastActivityDate="2019-06-20T18:06:20.623" Title="How to resize default NerdTree width?" Tags="|plugin-nerdtree|" AnswerCount="0" CommentCount="3" ClosedDate="2019-06-20T18:50:42.070" ContentLicense="CC BY-SA 4.0" />
  <row Id="20378" PostTypeId="2" ParentId="20333" CreationDate="2019-06-20T19:07:38.590" Score="4" Body="&lt;p&gt;You can combine the &lt;code&gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;&lt;/code&gt; operators with &lt;code&gt;%&lt;/code&gt; to indent blocks of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;%&lt;/code&gt; key will jump to the matching parenthesis, bracket or brace if your cursor is sitting on one of these characters: &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;)&lt;/code&gt;, &lt;code&gt;[&lt;/code&gt;, &lt;code&gt;]&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt; or &lt;code&gt;}&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an example, say you have a block of code like this and you want to indent it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  stuff here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To indent the code block, put the cursor on one of the braces (either one will work), type &lt;code&gt;&amp;gt;&lt;/code&gt; followed by &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5526" LastActivityDate="2019-06-20T19:07:38.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20379" PostTypeId="1" AcceptedAnswerId="20380" CreationDate="2019-06-20T19:31:19.867" Score="1" ViewCount="547" Body="&lt;p&gt;Using gvim on a file with 30K lines, I want to use ex mode to delete from column 130 to end of line, making each record no longer than 130 characters.&#xA;I want to do this for the entire file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My macro to do this is &lt;code&gt;131|D&lt;/code&gt;. How can I do this from the colon prompt?&lt;/p&gt;&#xA;" OwnerUserId="1132" LastEditorUserId="1132" LastEditDate="2019-06-20T20:24:52.213" LastActivityDate="2019-06-20T20:24:52.213" Title="Line mode command to delete from column X to end of line?" Tags="|command-line|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20380" PostTypeId="2" ParentId="20379" CreationDate="2019-06-20T20:15:45.483" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;\%c&lt;/code&gt; to match a column in a substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\%131c.*//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h /\%c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-06-20T20:15:45.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20381" PostTypeId="1" CreationDate="2019-06-21T00:01:12.247" Score="0" ViewCount="51" Body="&lt;p&gt;Let me briefly explain what I am trying to do.  I work on an air gap network.  Anything not native to Red hat, or that I do not write is out of the question.  The most popular two IDE's are VIM/GVIM and Eclipse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For many of us, there is only one reason to go into eclipse, the indexer.  The code base we work on is quite large.  The configuration I work in alone is over a terabyte when compiled. Currently I am using a combination of grep and find to locate files and information in them.  It doesn't seem like it should be hard to to write an external indexing deamon, but in order to be useful it would nice to be able to easily interface with a string.  I guess I could just copy it to something but I figured I'd check and see if there was some hidden register somewhere that was already doing what I wanted.&lt;/p&gt;&#xA;" OwnerUserId="18199" LastActivityDate="2019-06-22T16:56:48.310" Title="Are the contents of highlighted content saved to a register" Tags="|vimscript|search|" AnswerCount="1" CommentCount="5" ClosedDate="2019-06-24T07:40:51.130" ContentLicense="CC BY-SA 4.0" />
  <row Id="20382" PostTypeId="1" AcceptedAnswerId="20383" CreationDate="2019-06-21T05:15:22.430" Score="4" ViewCount="280" Body="&lt;p&gt;Let's consider that I have the following bash script called &lt;code&gt;time.bash&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;date -d @$1 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This script converts the epoch timestamp to its corresponding date as the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ./time.bash 1267619929&#xA;qua mar  3 09:38:49 -03 2010&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now let's suppose I'm editing the following file using Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1267619929 word word &#xA;1267619935 word word &#xA;1267619931 word word &#xA;1267619946 word word&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Considering that I'm working just on a single line, I'd like to save the timestamp 1267619929 on the register &lt;code&gt;a&lt;/code&gt; with &lt;code&gt;&quot;aye&lt;/code&gt;, execute the script &lt;code&gt;time.bash&lt;/code&gt; with the register &lt;code&gt;a&lt;/code&gt; content as input, and save its output on another register (let's say register &lt;code&gt;b&lt;/code&gt;). Is it possible to do this kind of stuff on Vim?&lt;/p&gt;&#xA;" OwnerUserId="2805" LastEditorUserId="2805" LastEditDate="2019-06-28T04:26:05.117" LastActivityDate="2019-06-28T04:26:05.117" Title="Is it possible to run a script on a register content and send its output to another register on Vim?" Tags="|vimscript|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20383" PostTypeId="2" ParentId="20382" CreationDate="2019-06-21T05:50:18.680" Score="7" Body="&lt;p&gt;You could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @b=system(&quot;time.bash &quot; . @a)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;@a&lt;/code&gt; is register &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;@b&lt;/code&gt; is register &lt;code&gt;b&lt;/code&gt;. The &lt;code&gt;system(...)&lt;/code&gt; runs a command and returns the output. The result is a line, so when you paste it, you get a new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help system()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setreg(&quot;b&quot;, system(&quot;time.bash &quot; . @a), &quot;v&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here you can set the mode for the register. The lower case &lt;code&gt;v&lt;/code&gt; sets it to characterwise. With it you can paste the result within a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help setreg()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also do it without first copying the value to register &lt;code&gt;a&lt;/code&gt;. Put the cursor on the numeric value and execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setreg(&quot;b&quot;, system(&quot;time.bash &quot; . expand(&quot;&amp;lt;cword&amp;gt;&quot;)), &quot;v&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;expand(&quot;&amp;lt;cword&amp;gt;&quot;)&lt;/code&gt; is expanded to the word under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help &amp;lt;cword&amp;gt;&lt;/code&gt; and &lt;code&gt;:help expand()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-06-21T06:48:33.103" LastActivityDate="2019-06-21T06:48:33.103" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20384" PostTypeId="1" CreationDate="2019-06-21T07:21:46.590" Score="0" ViewCount="145" Body="&lt;p&gt;I'm using an intellij editor (Rider/Clion) with the vim plugin on mac osx and am attempting to intelligently select words in my editor, which I accomplish via an 'extend selection'/'shrink selection' keymap within Rider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm happy with the above, but would like to delete the selection within one keystroke in normal mode in vim. I understand that the selection is not known to vim, so I'd like to remap my delete key to perform an &lt;code&gt;i&lt;/code&gt; followed by backspace for eg.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Del&amp;gt; i&amp;lt;backspace&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And a few others with no joy&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've checked the mapping within vim via &lt;code&gt;:nmap&lt;/code&gt; and I can see the result but when testing, the delete key remains in normal mode hence simply moves the cursor back one character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help to my above conundrum (or otherwise better advice than what I'm trying to perform) would be highly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="22734" LastEditorUserId="1841" LastEditDate="2019-06-21T09:27:44.953" LastActivityDate="2019-06-21T09:27:44.953" Title="Remap delete key on mac osx to 'insert then backspace'" Tags="|key-bindings|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20385" PostTypeId="1" CreationDate="2019-06-21T09:09:33.970" Score="2" ViewCount="1788" Body="&lt;p&gt;Like many, I like to browse using &lt;code&gt;:Lexplore&lt;/code&gt;. However, as indicated by the manual, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;By default, :Lexplore will change an uninitialized |g:netrw_chgwin|                                                                                                                                                                          to 2; edits will thus preferentially be made in window#2.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Additionally, I have set&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:netrw_browse_split = 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to open the files from the explorer in the previous buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if I have only a single window opened, it works fine. But consider the following sequence&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit foo.txt&#xA;:split bar.txt&#xA;:2wincmd w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We have bar.txt open on the top, foo.txt on the bottom and currently active.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if I call &lt;code&gt;:Lexplore&lt;/code&gt; it will set the &lt;code&gt;g:netrw_chgwin&lt;/code&gt; to 2 as indicated in the help. So opening a file in the explorer will take place in the bar.txt's window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, the help for &lt;code&gt;g:netrw_browse_split&lt;/code&gt; states that&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This option does not affect |:Lexplore| windows.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I can try to set &lt;code&gt;g:netrw_chgwin&lt;/code&gt; as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:netrw_chgwin = winnr()&#xA;:Lexplore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But on foo.txt, it gets the number 2 (2/2). After opening the explorer, foo.txt's windows gets assigned the number 3 (explorer taking the 1). So opening will again use bar.txt's window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let l:cur_buf = bufnr('%');&#xA;:Lexplore&#xA;:let g:netrw_chgwin = bufwinnr(l:cur_buf)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I override &lt;code&gt;:Lexplore&lt;/code&gt;'s default behaviour? Or make it to open on the last visited window?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="2170" LastEditorUserId="2170" LastEditDate="2019-06-21T09:46:32.077" LastActivityDate="2019-06-21T14:09:58.877" Title="Lexplore and split windows" Tags="|vim-windows|netrw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20386" PostTypeId="2" ParentId="7966" CreationDate="2019-06-21T09:31:55.723" Score="2" Body="&lt;p&gt;My workflow is similar to what &lt;em&gt;goldilocks&lt;/em&gt; said in his answer. I use vim8's &lt;code&gt;:terminal&lt;/code&gt; feature in combination with &lt;code&gt;--remote&lt;/code&gt; option. I maintain 2 window layout in vim. Code in left window and terminal on the right. I use the right window(terminal) to run compilations, navigate file system and open files in current vim instance(from the terminal). This flow allows me to operate with very less mouse involvement. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use gvim and icewm(any window manager should do) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start a gvim instance&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim somefile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inside gvim, open terminal in vertical split&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:botright vertical terminal&#xA;(or) short form&#xA;:bo vert term &#xA;&quot;botright&quot; splits the window to right&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the terminal window split&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --remote-send '&amp;lt;C-w&amp;gt;&amp;lt;C-w&amp;gt;' --remote anotherfile&#xA;&#xA;&quot;--remote-send&quot; will send Ctrl-W Ctrl-W to remote gvim instance(in our case, current instance) &#xA;to put the cursor in the left window. Otherwise, the terminal split would be replaced by&#xA;'anotherfile' buffer.&#xA;&quot;--remote&quot; will open 'anotherfile' in left window.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can create aliases to these long commands in your .zshrc/.bashrc and shorten them to your liking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this workflow, I rarely move out of my gvim instance and rarely use the mouse. &lt;/p&gt;&#xA;" OwnerUserId="21403" LastActivityDate="2019-06-21T09:31:55.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20387" PostTypeId="2" ParentId="17390" CreationDate="2019-06-21T10:09:29.853" Score="0" Body="&lt;p&gt;this solution works for me&lt;/p&gt;&#xA;&#xA;&lt;p&gt;just press enter when this message appears, and reopen the file like &lt;code&gt;sudo vi file.sh&lt;/code&gt;&#xA;and it's done, you can modify and quit the file as you want&lt;/p&gt;&#xA;&#xA;&lt;p&gt;just matter of permission issue to &lt;code&gt;viminfo&lt;/code&gt; file&lt;/p&gt;&#xA;" OwnerUserId="22736" LastActivityDate="2019-06-21T10:09:29.853" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20388" PostTypeId="2" ParentId="20385" CreationDate="2019-06-21T14:09:58.877" Score="3" Body="&lt;p&gt;Interesting question. I’ll leave it to someone else to fix your splitting issue; in the meantime, I’ll suggest an alternative workflow (one that works well for me). It consists of two steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;Explore&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That’s it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to let netrw take over the window I’m editing in, and open my next file directly in that window (not split it). This way, I don’t have to guess where my new file will go on the screen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, &lt;code&gt;:Rexplore&lt;/code&gt; is handy to switch between netrw and a file. And mapping a sequence of keys (like &lt;code&gt;&amp;lt;Leader&amp;gt;ed&lt;/code&gt;) to &lt;code&gt;Explore&lt;/code&gt; makes this really quite quick. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;project drawers and file explorers&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-21T14:09:58.877" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20389" PostTypeId="1" CreationDate="2019-06-21T14:27:44.597" Score="2" ViewCount="84" Body="&lt;p&gt;I was seeing how the different default colorschemes look like in vim. To do that I typed &lt;code&gt;:colo&lt;/code&gt;, then space and tab. But then when I want to set the next one, I have to press tab a lot of times to get to the next one (and remember the name of the current one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a faster way to get to the &quot;next&quot; item in a tab completion?&lt;/p&gt;&#xA;" OwnerUserId="21104" LastEditorUserId="21104" LastEditDate="2019-06-21T14:35:09.700" LastActivityDate="2019-06-21T14:35:09.700" Title="Next tab completion item" Tags="|autocompletion|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20390" PostTypeId="1" CreationDate="2019-06-21T14:35:38.347" Score="1" ViewCount="142" Body="&lt;p&gt;Does anyone know if the Windows versions (pre 8.1.1365) of VIM (&lt;a href=&quot;https://www.vim.org/download.php#pc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.vim.org/download.php#pc&lt;/a&gt;) are vulnerable, per CVE-2019-12735?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything I have read always mentions LINUX, and many LINUX commands would be harmless on Windows, but I assume malicious people could just as easily include Windows commands, yes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What think ye?&lt;/p&gt;&#xA;" OwnerUserId="22742" LastEditorUserId="22742" LastEditDate="2019-06-21T15:11:26.870" LastActivityDate="2019-07-22T18:03:40.500" Title="CVE-2019-12735 question" Tags="|microsoft-windows|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20391" PostTypeId="1" CreationDate="2019-06-21T17:13:56.050" Score="3" ViewCount="184" Body="&lt;p&gt;I was trying see if I can integrate &lt;em&gt;fzf&lt;/em&gt; with &lt;em&gt;nvi&lt;/em&gt;, but couldn't find a way to do something like &lt;code&gt;:Edit &amp;lt;shell command's output&amp;gt;&lt;/code&gt; which would solve my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;:source nvi.ex&lt;/code&gt; -- it works for a normal file; but when I do  &lt;code&gt;mkfifo nvi.ex&lt;/code&gt; and then &lt;code&gt;:source nvi.ex&lt;/code&gt;, &lt;strong&gt;nothing&lt;/strong&gt; happens even though it waits till I write into the &lt;em&gt;fifo&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote into the &lt;em&gt;fifo&lt;/em&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;cat - &amp;gt;&amp;gt; nvi.ex&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Edit README&lt;/code&gt; followed by an &lt;kbd&gt;Enter&lt;/kbd&gt; and &lt;kbd&gt;Ctrl-D&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Are there cases where a programs treats a &lt;em&gt;fifo&lt;/em&gt; differently compared to a normal file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: This works in &lt;em&gt;vi&lt;/em&gt; and &lt;em&gt;vim&lt;/em&gt; though! &lt;em&gt;nvi&lt;/em&gt; version is 1.79.&lt;/p&gt;&#xA;" OwnerUserId="8178" LastEditorUserId="8178" LastEditDate="2019-06-21T19:43:38.393" LastActivityDate="2024-02-26T07:08:31.103" Title="Is it possible to read a shell command's output from nvi's command line?" Tags="|shell|nvi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20393" PostTypeId="2" ParentId="20391" CreationDate="2019-06-21T18:28:15.960" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;fzf&lt;/code&gt; has a vim plugin &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; that might work for you&lt;/li&gt;&#xA;&lt;li&gt;vim users might try &lt;a href=&quot;https://github.com/sjl/clam.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;clam from Steve Losh&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Vim (not sure about nvi) has a &lt;code&gt;:redir&lt;/code&gt; command that can be used to accomplish similar results. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-06-21T22:38:08.173" LastActivityDate="2019-06-21T22:38:08.173" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20394" PostTypeId="1" CreationDate="2019-06-21T21:15:43.347" Score="5" ViewCount="2515" Body="&lt;p&gt;Well, there is &lt;code&gt;;&lt;/code&gt; to repeat the last move in some cases. &#xA;There is the &lt;code&gt;.&lt;/code&gt; to repeat last change. &#xA;But if I just did &lt;code&gt;za&lt;/code&gt; or &lt;code&gt;@a&lt;/code&gt;, is there a way to repeat it? I guess such a mechanism should ignore plain movements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for example, I have a mapping such that H does &lt;code&gt;o&amp;lt;ESC&amp;gt;D&lt;/code&gt;, or new line.&#xA;If I do &lt;code&gt;.&lt;/code&gt; , it only repeats the &lt;code&gt;D&lt;/code&gt;. So, to do so just for defined mappings would be a start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am almost certain that there is no way out of the box.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-06-21T22:46:54.787" LastActivityDate="2023-01-19T14:21:39.267" Title="Repeat last normal command" Tags="|normal-mode|repeated-commands|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20395" PostTypeId="2" ParentId="19885" CreationDate="2019-06-21T21:19:24.840" Score="1" Body="&lt;p&gt;From &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1075&quot; rel=&quot;nofollow noreferrer&quot;&gt;netrw.vim : Network oriented reading, writing, and browsing&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;REMOTE DIRECTORY BROWSING&#xA;    :e [protocol]://[user]@hostname/path/&#xA;    :Nread [protocol]://[user]@hostname/path/ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that these commands use directory paths only. (In your example you include a file.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-06-21T21:19:24.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20396" PostTypeId="2" ParentId="20394" CreationDate="2019-06-21T22:38:48.273" Score="7" Body="&lt;p&gt;&lt;code&gt;.&lt;/code&gt; repeats the last change, and usually does what you want (combine with, &lt;em&gt;e.g.&lt;/em&gt;, &lt;code&gt;cgn&lt;/code&gt; for a great sequence). For registers, &lt;code&gt;@@&lt;/code&gt; repeats the last register. &lt;code&gt;@:&lt;/code&gt; repeats the last ex command. This is particularly handy with &lt;code&gt;:normal!&lt;/code&gt; or &lt;code&gt;:global&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For mappings, I use &lt;a href=&quot;https://github.com/tpope/vim-repeat&quot; rel=&quot;nofollow noreferrer&quot;&gt;repeat.vim&lt;/a&gt;. You (and plugin authors) can have mappings take advantage of it so that &lt;code&gt;.&lt;/code&gt; works as expected.&lt;/p&gt;&#xA;&lt;p&gt;As you've noticed, the &lt;code&gt;ft&lt;/code&gt; family of motions can be repeated with &lt;code&gt;,;&lt;/code&gt;. The only other 'repeatable' motion I'm aware of is &lt;code&gt;/?&lt;/code&gt; searches via &lt;code&gt;nN&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In general, certain commands don't &lt;em&gt;have&lt;/em&gt; a repeatable version. For example, it doesn't make sense to have a builtin to repeat &lt;code&gt;za&lt;/code&gt;, because (a) it's two characters ; (b) it doesn't edit text ; (c) it's easily mappable.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2023-01-19T14:21:39.267" LastActivityDate="2023-01-19T14:21:39.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20397" PostTypeId="2" ParentId="14315" CreationDate="2019-06-22T03:58:44.490" Score="2" Body="&lt;p&gt;I am having the same issue as you. There are some discussions &lt;a href=&quot;https://github.com/mhinz/vim-signify/issues/231&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://stackoverflow.com/questions/4710305/error-when-attempting-to-go-back-to-normal-mode-in-vim-command-line-window/4710486#4710486&quot;&gt;here&lt;/a&gt;. It seems that we can use &lt;code&gt;getcmdwintype()&lt;/code&gt; to check if we are in command line window. Here is my working setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup auto_read&#xA;    autocmd!&#xA;    autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *&#xA;                \ if mode() == 'n' &amp;amp;&amp;amp; getcmdwintype() == '' | checktime | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-06-22T03:58:44.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20398" PostTypeId="2" ParentId="20333" CreationDate="2019-06-22T12:21:05.780" Score="1" Body="&lt;p&gt;&lt;code&gt;:help left&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;ex mode&lt;/code&gt; you can use &lt;code&gt;:left&lt;/code&gt; or &lt;code&gt;:le&lt;/code&gt; to align lines a specified amount. &#xA;Specifically, &lt;code&gt;:left&lt;/code&gt; will &lt;em&gt;Left align lines in the [range]. It sets the indent in the lines to [indent] (default 0).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%le3&lt;/code&gt; or &lt;code&gt;:%le 3&lt;/code&gt;  or &lt;code&gt;:%left3&lt;/code&gt; or &lt;code&gt;:%left 3&lt;/code&gt; will align the entire file by padding with three spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:5 le 4&lt;/code&gt; will pad line 5 with 4 spaces&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:5,7 le 3&lt;/code&gt; will align lines 5 through 7 by padding them with 3 spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:le&lt;/code&gt; without any value or &lt;code&gt;:le 0&lt;/code&gt; will left align with a padding of 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works in &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;gvim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://stackoverflow.com/questions/235839/indent-multiple-lines-quickly-in-vi/32509423#32509423&quot;&gt;https://stackoverflow.com/questions/235839/indent-multiple-lines-quickly-in-vi/32509423#32509423&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1132" LastActivityDate="2019-06-22T12:21:05.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20399" PostTypeId="2" ParentId="19459" CreationDate="2019-06-22T14:21:53.947" Score="0" Body="&lt;p&gt;Try the following: hold down &lt;kbd&gt;shift&lt;/kbd&gt; key before you press mouse button. &lt;/p&gt;&#xA;" OwnerUserId="1782" LastActivityDate="2019-06-22T14:21:53.947" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20400" PostTypeId="2" ParentId="20381" CreationDate="2019-06-22T16:05:54.017" Score="1" Body="&lt;p&gt;The highlight &lt;kbd&gt;*&lt;/kbd&gt; is actually just a search for word nearest to current cursor. So they are available in ‘last search pattern register’ &lt;code&gt;/&lt;/code&gt; (that is slash register).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don’t want the word boundary &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt;, use &lt;kbd&gt;g*&lt;/kbd&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case you highlighting (selecting) using Vim visual-mode or mouse selection, you can press &lt;kbd&gt;y&lt;/kbd&gt; afterward. This will make it available in unnamed register &lt;code&gt;”&lt;/code&gt; (a double-quote). And if you want it in other register, just prepend double-quote and the register name before &lt;kbd&gt;y&lt;/kbd&gt;. For example &lt;kbd&gt;“sy&lt;/kbd&gt; will make it available in register &lt;code&gt;s&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1782" LastEditorUserId="1782" LastEditDate="2019-06-22T16:56:48.310" LastActivityDate="2019-06-22T16:56:48.310" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20401" PostTypeId="2" ParentId="20390" CreationDate="2019-06-22T17:01:53.323" Score="1" Body="&lt;p&gt;Yes, the Windows version of Vim is still vulnerable to CVE-2019-12735, so you should upgrade your Vim to version 8.1.1365 or later as soon as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While most exploits are probably targeting Linux and Macs with shell commands such as &lt;code&gt;rm -rf&lt;/code&gt; etc., nothing prevents using a &lt;code&gt;cmd.exe&lt;/code&gt; or Powershell command there that would work on Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim on Windows is definitely not as popular as on Linux and Mac (where it's always shipped by default), it is possible that exploits for Windows are not to be found in the wild as much or as often as those that target Linux or Mac... But as explained above, exploits are still possible and you should upgrade your Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Version 8.1.1365 is the first one with the fix, use the &lt;code&gt;:version&lt;/code&gt; command to check the version you're running and make sure it's at least as high as that.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-06-22T17:01:53.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20402" PostTypeId="1" CreationDate="2019-06-23T07:46:45.827" Score="1" ViewCount="370" Body="&lt;p&gt;Trying to do something with job output in &lt;code&gt;exit_cb&lt;/code&gt; or &lt;code&gt;close_cb&lt;/code&gt;, but it's all buffered, how to flush it. e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:exit_cb(job, status)&#xA;  echom getbufline(s:bufnr, '$')&#xA;endfunction&#xA;&#xA;function! s:close_cb(channel)&#xA;  echom getbufline(s:bufnr, '$')&#xA;endfunction&#xA;&#xA;let s:bufnr = term_start('seq 1000',&#xA;      \ {'exit_cb': function(&quot;s:exit_cb&quot;), 'close_cb':function(&quot;s:close_cb&quot;) })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;None of them echo &lt;code&gt;1000&lt;/code&gt;,  how to flush it ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One work around is to call &lt;code&gt;:h :sleep&lt;/code&gt;, but i don't think that's the right way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/users/11054/b-layer&quot;&gt;B Layer&lt;/a&gt; pointed out, result of &lt;code&gt;close_cb&lt;/code&gt; depends on terminal window height. e.g., if it's height is 30, it prints &lt;code&gt;971&lt;/code&gt;, as &lt;code&gt;971 = 1000 - 30 + 1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I reread &lt;code&gt;:h close_cb&lt;/code&gt; , it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim will invoke callbacks that handle data before invoking&#xA;          close_cb, thus when this function is called no more data will&#xA;          be passed to the callbacks.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I guess the callback vim invoked to handle data haven't finished by the time &lt;code&gt;close_cb&lt;/code&gt; is called. Tried to call &lt;code&gt;term_wait()&lt;/code&gt; in &lt;code&gt;close_cb&lt;/code&gt;, but it cause hang.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A similar &lt;a href=&quot;https://github.com/vim/vim/issues/1320&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue&lt;/a&gt; on github.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-11-18T09:14:11.553" LastActivityDate="2019-11-18T09:14:11.553" Title="How to flush job output in vim8?" Tags="|vimscript|job-control|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20403" PostTypeId="1" AcceptedAnswerId="20404" CreationDate="2019-06-23T19:37:07.293" Score="2" ViewCount="291" Body="&lt;p&gt;Here is a Python list that I'm trying to assign to some Vim variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lines = ['&quot;&quot;&quot;Something foo\'s thing.&quot;&quot;&quot;', '', 'foo = &quot;asdfasdf&quot; \\', 'bar']&#xA;command = 'let l:corrected_lines = {lines}'.format(lines=lines)&#xA;vim.eval(command)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then in a caller function, I use &lt;code&gt;l:corrected_lines&lt;/code&gt; to do some extra work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that there are 2 issues with the string above&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The single quote &lt;code&gt;foo's&lt;/code&gt; apparently needs to be escaped&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;\&lt;/code&gt; also needs to be escaped&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Apparently Vim escapes single-quotes by placing two of them side-by-side, like this &lt;code&gt;''&lt;/code&gt;. So I've experimented with running &lt;code&gt;replace(&quot;\\'&quot;, &quot;''&quot;)&lt;/code&gt; and other combinations of methods. Also Vim changes the &lt;code&gt;\&lt;/code&gt; in the source-code to &lt;code&gt;\\&lt;/code&gt; so I've tried adding &lt;code&gt;replace('\\\\', '\\')&lt;/code&gt; and that works. The problem is that these replacements work in isolation but don't work together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I feel like there's probably a simpler way to escape this line but I haven't had success with Python or using Vim's &lt;code&gt;:escape()&lt;/code&gt; command. Can someone please suggest a solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Just to make &lt;code&gt;lines&lt;/code&gt; make a bit more sense visually, this is how &lt;code&gt;lines&lt;/code&gt; looks like printed out&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot;Something foo's thing.&quot;&quot;&quot;&#xA;&#xA;foo = &quot;asdfasdf&quot; \&#xA;bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16073" LastActivityDate="2019-06-23T21:20:15.130" Title="How to assign a Python list to a vim variable and escape its strings correctly" Tags="|vimscript-python|escape|string-manipulation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20404" PostTypeId="2" ParentId="20403" CreationDate="2019-06-23T21:20:15.130" Score="4" Body="&lt;p&gt;Use &lt;code&gt;pyeval()&lt;/code&gt;, &lt;code&gt;py3eval()&lt;/code&gt;, or &lt;code&gt;pyxeval()&lt;/code&gt; to read python variables into vim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = [1,2,3]&#xA;vim.command('let X = pyeval(&quot;x&quot;)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;py x = [1,2,3]&#xA;let X = pyeval('x')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-06-23T21:20:15.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20405" PostTypeId="1" CreationDate="2019-06-24T06:29:40.940" Score="1" ViewCount="419" Body="&lt;p&gt;When starting &lt;code&gt;nvim&lt;/code&gt;, my &lt;code&gt;:messages&lt;/code&gt; contains:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function LoadRope[4]..provider#python#Call:&#xA;line   18:&#xA;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;ImportError: No module named ropevim&#xA;Traceback (most recent call last):&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;ImportError: No module named ropevim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ropevim&lt;/code&gt; is installed by: &lt;code&gt;NeoBundleLazy 'python-rope/ropevim', { 'on_ft': 'python' }&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:checkhealth&lt;/code&gt; is all green&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;pip install --user --upgrade ropevim&lt;/code&gt; is fully satisfied&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;py3 print(ropevim.__dict__)&lt;/code&gt; produces a bunch of &lt;code&gt;rope&lt;/code&gt;-y output&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What does &lt;code&gt;ropevim&lt;/code&gt; need to be happy?&lt;/p&gt;&#xA;" OwnerUserId="5324" LastActivityDate="2019-06-24T06:33:14.687" Title="On startup: ImportError: No module named ropevim" Tags="|filetype-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20406" PostTypeId="2" ParentId="20405" CreationDate="2019-06-24T06:33:14.687" Score="1" Body="&lt;p&gt;It seems that &lt;code&gt;ropevim&lt;/code&gt; is a Python 2 animal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pip2 install --user ropevim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5324" LastActivityDate="2019-06-24T06:33:14.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20407" PostTypeId="1" AcceptedAnswerId="20408" CreationDate="2019-06-24T06:49:27.017" Score="2" ViewCount="204" Body="&lt;p&gt;1) To underline misspelled words, I can execute the following in an open buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi clear SpellBad&#xA;:hi SpellBad cterm=underline&#xA;:set spell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2) However, if I write in my &lt;code&gt;.vimrc&lt;/code&gt; the first two lines, namely:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi clear SpellBad&#xA;:hi SpellBad cterm=underline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and when I open a file, I execute &lt;code&gt;:set spell&lt;/code&gt;, misspelled words are highlighted in color, but not underlined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why are the &lt;code&gt;.vimrc&lt;/code&gt; settings in 2) overridden? How can I get the same result as in 1)?&lt;/p&gt;&#xA;" OwnerUserId="6023" LastEditorUserId="6023" LastEditDate="2019-06-25T04:55:45.103" LastActivityDate="2019-09-11T12:48:23.540" Title="`.vimrc` unsuccessful in setting highlight style" Tags="|vimrc|syntax-highlighting|highlight|spell-checking|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20408" PostTypeId="2" ParentId="20407" CreationDate="2019-06-24T12:22:43.310" Score="4" Body="&lt;p&gt;They are likely overridden by your colorscheme of choice (even if it is default). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggested fix is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup colors&#xA;  au!&#xA;  au ColorScheme * hi whatever&#xA;augroup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-24T12:22:43.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20409" PostTypeId="1" AcceptedAnswerId="20412" CreationDate="2019-06-24T16:25:14.600" Score="1" ViewCount="172" Body="&lt;p&gt;When I pass the names of multiple files to vim on the command line (e.g. &lt;code&gt;vim foo.txt bar.txt&lt;/code&gt;), I almost always want to add the &lt;code&gt;-o&lt;/code&gt; option, because I would like them to be visible side-by-side in separate windows. However, I often forget to add &lt;code&gt;-o&lt;/code&gt;. I cannot find an appropriate setting, but is there a way to set this as the default? (for example, in my &lt;code&gt;.vimrc&lt;/code&gt;?). I know I could probably create a shell alias, but that only works if it is invoked interactively from a shell (not from another program).&lt;/p&gt;&#xA;" OwnerUserId="91" LastActivityDate="2022-05-12T14:14:39.737" Title="Can I specify '-o' as the default for vi in my vimrc?" Tags="|vim-windows|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20410" PostTypeId="1" CreationDate="2019-06-24T20:49:03.813" Score="1" ViewCount="81" Body="&lt;p&gt;While writing in latex I often want to copy a math equation's right hand side or left hand side. For example I have something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{gather*}&#xA;    5 \cdot \left( A A 3 \right) + 50 \cdot \left( A A 3 \right) = 6CAB \\&#xA;    500A + 50A + 15 + 5000A + 500A + 150 = 6000 + 100C + 10A + 5&#xA;\end{gather*}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'd like to copy the right and left hand side of the n-th last equation I've written and store them each in the l and r register respectively. For example if I were to use this on the 2nd last equation the l register would contain &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5 \cdot \left( A A 3 \right) + 50 \cdot \left( A A 3 \right)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the r register would contain&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 6CAB \\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far I have this regex which represents a line that has an = between text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[^=]*\s\+=\s\+[^;]*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I have no clue on how to somehow input what it's matching into registers and how to find the n-th last equation either... I was wondering if anyone could help me figure this out and was also wondering if this should be a macro?&lt;/p&gt;&#xA;" OwnerUserId="18632" LastActivityDate="2019-06-24T21:09:01.273" Title="Yank both sides of equation" Tags="|regular-expression|functions|macro|filetype-tex|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20411" PostTypeId="2" ParentId="20410" CreationDate="2019-06-24T21:03:11.217" Score="7" Body="&lt;p&gt;This can be done with either regex+substitute or macros&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Substitute.&lt;/strong&gt;  This is the same as your regex except the important parts are surrounded by &lt;code&gt;\( . \)&lt;/code&gt; to create capture groups.  These are referred to by &lt;code&gt;submatch(1)&lt;/code&gt; and &lt;code&gt;submatch(2)&lt;/code&gt; respectively.  We use the replace expression &lt;code&gt;\=&lt;/code&gt; and &lt;code&gt;execute('let')&lt;/code&gt; idiom.  Finally, use &lt;code&gt;/n&lt;/code&gt; to prevent substitution from actually happening.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\([^=]*\)\s\+=\s\+\([^;]*\)/\=execute('let [@l,@r]=[submatch(1),submatch(2)]')/n &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Macro.&lt;/strong&gt;  Create a macro as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @q = '_&quot;lyt=f=l&quot;ry$'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then type @q to execute the macro on the line.  The parts are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;_&lt;/code&gt; go to start of line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;lyt=&lt;/code&gt; yank until &lt;code&gt;=&lt;/code&gt; into register &lt;code&gt;l&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f=l&lt;/code&gt; go one past the &lt;code&gt;=&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;ry$&lt;/code&gt; yank until end.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Command.&lt;/strong&gt;  Alternatively, this is straightforward to do using basic vimscript&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let [@l,@r] = split(getline('.'), '=')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2019-06-24T21:09:01.273" LastActivityDate="2019-06-24T21:09:01.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20412" PostTypeId="2" ParentId="20409" CreationDate="2019-06-25T00:08:49.597" Score="7" Body="&lt;p&gt;As a solution to the generalized question &lt;em&gt;How can I apply a command-line option every time I open vim?&lt;/em&gt; (there are options that don't have configuration equivalents) one approach is as follows.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Put your personal bin dir (&lt;code&gt;~/bin&lt;/code&gt;) ahead of vim's path in your PATH environment variable. If the bin dir is not already in your path you can use this (in .profile, or .bashrc or whatever you use):&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PATH=$HOME/bin:$PATH&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create a wrapper shell script named &lt;code&gt;vim&lt;/code&gt; in that directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat &amp;gt; ~/bin/vim &amp;lt;&amp;lt;'EOF'&#xA;#!/bin/sh&#xA;&#xA;exec /path/to/vim -o &quot;$@&quot;&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Per OP's request I'm using &lt;code&gt;-o&lt;/code&gt; in this example. Obviously you'll need to change &lt;code&gt;/path/to&lt;/code&gt; to actual path.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Make it runnable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ chmod +x ~/bin/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if you run &lt;code&gt;vim foo bar&lt;/code&gt; then &quot;foo&quot; and &quot;bar&quot; each get their own windows.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-06-26T07:03:14.510" LastActivityDate="2019-06-26T07:03:14.510" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20413" PostTypeId="2" ParentId="20375" CreationDate="2019-06-25T01:45:00.450" Score="3" Body="&lt;p&gt;There are a couple ways that come to mind. Here's one...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:inactivity_limit = 20  &quot; max Insert mode inactivity before fail, in seconds&#xA;let g:check_frequency = 10   &quot; seconds between checks&#xA;&#xA;augroup monitor&#xA;    au!&#xA;    &quot; when vim starts kick off the infinitely repeating calls to the monitor function&#xA;    au VimEnter * call timer_start(g:check_frequency * 1000, 'MonitorActivity', {'repeat' : -1})&#xA;&#xA;    &quot; when cursor moves in Insert mode update the last activity time&#xA;    au CursorMovedI * let g:last_activity = reltime()&#xA;augroup END&#xA;&#xA;func! MonitorActivity(timer_id)&#xA;    &quot; when we start we'll initialize the last activity time then return&#xA;    &quot; ...gives a little grace period at beginning&#xA;    if ! exists('g:last_activity') || empty(g:last_activity)&#xA;        let g:last_activity = reltime()&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; very handy function for our purposes, reltime&#xA;    let l:diff = reltime(g:last_activity)[0]&#xA;&#xA;    if l:diff &amp;gt; g:inactivity_limit&#xA;        &quot; Not ringing a bell or anything. Up to OP to change this part.&#xA;        echom &quot;Failed! &quot; . l:diff&#xA;        let g:last_activity = []&#xA;    endif&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will check, every 10 seconds (configurable) whether the cursor has moved &lt;em&gt;in Insert mode&lt;/em&gt; (thanks to &lt;code&gt;CursorMovedI&lt;/code&gt; auto-command/event) in the last 20 seconds (also configurable). The comments in the code have some more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMPORTANT: I leave it to you to figure out what happens when the time limit is exceeded. You'll have to replace the line that just prints &quot;Failed!&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, keep in mind that anyone with a fair amount of vim savvy can disable or otherwise mess with this. And if someone went into Insert mode and just lazily moved the cursor back and forth the whole time nothing would happen. But you're asking for free software so them's the breaks. ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Okay, since I was curious here, at least, is a function that will ring the basic system bell, and perhaps flash the screen, once a second for # of times specified in the param. (if Vim has &lt;code&gt;'visualbell'&lt;/code&gt; set or the system bell is otherwise disabled....&amp;lt;shrug&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! Alarm(bells)&#xA;    let l:i = 0&#xA;    while l:i &amp;lt; a:bells&#xA;        let l:i += 1 | sleep 1 | norm &amp;lt;c-g&amp;gt;&#xA;    endwhile&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add &lt;code&gt;call Alarm(5)&lt;/code&gt;, for example, to the main function where the &quot;Failed&quot; message currently is.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-06-25T02:35:48.590" LastActivityDate="2019-06-25T02:35:48.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20415" PostTypeId="2" ParentId="16826" CreationDate="2019-06-25T08:10:55.480" Score="0" Body="&lt;p&gt;I realized this vim's strange behavior just today.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a solution by chance :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;]p&lt;/code&gt; : paste the line with the right indent&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2019-07-27T19:07:45.053" LastActivityDate="2019-07-27T19:07:45.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20416" PostTypeId="1" CreationDate="2019-06-25T08:34:03.130" Score="0" ViewCount="45" Body="&lt;p&gt;in my project I have different kinds of files. For every filetype I created a ~/.vim/syntax/[type].vim file for e.g. highlighting and key mappings. In every filetype I have a footer line with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; # vim:syn=[type]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I switch from VIM 7.3.547 to 8.0.707. When I now open a file vim shows me on startup all key mappings I defined in the syntax file. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; &amp;lt;C-F&amp;gt;    :!/home/www-data/.vim/syntax/layout-formater.pl&amp;lt;CR&amp;gt;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I have to press the Enter key before I can edit the file. It shows only the mappings, not the highlight definition or other thing I defined in the syntax file. And only the mappings from the syntax file, not the mappings in my ~/.vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know, how I can avoid this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help!&lt;/p&gt;&#xA;" OwnerUserId="22773" LastEditorUserId="22773" LastEditDate="2019-06-25T08:40:00.770" LastActivityDate="2019-06-25T12:43:56.510" Title="&quot;map&quot;pings in syntax files shows on startup" Tags="|key-bindings|syntax|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20417" PostTypeId="2" ParentId="20416" CreationDate="2019-06-25T12:38:19.040" Score="2" Body="&lt;p&gt;You could avoid this by using the right files: &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#ftplugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ftplugin&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*41.12* Writing a filetype plugin   *write-filetype-plugin* *ftplugin*&#xA;&#xA;A filetype plugin is like a global plugin, except that it sets options and&#xA;defines mappings for the current buffer only.  See |add-filetype-plugin| for&#xA;how this type of plugin is used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So keep your command related to syntax in your syntax file and your mappings to your ftplugin &lt;code&gt;~/.vim/after/ftplugin/[type].vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also if I understand your mapping properly you probably want to read &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27formatprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'formatprg'&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27equalprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 'equalprg'&lt;/code&gt;&lt;/a&gt;, it's always better to use the built-in mechanisms to do this kind of things. And you also should not use &lt;code&gt;map&lt;/code&gt;: Always use the non recursive version &lt;code&gt;noremap&lt;/code&gt; and specify the mode &lt;code&gt;nnoremap&lt;/code&gt; (unless you know what you are doing) it might save you a lot of debugging in the futur.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-06-25T12:43:56.510" LastActivityDate="2019-06-25T12:43:56.510" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20418" PostTypeId="1" AcceptedAnswerId="20419" CreationDate="2019-06-25T12:51:19.897" Score="4" ViewCount="4051" Body="&lt;p&gt;I want to map &lt;code&gt;Ctrl&lt;/code&gt; + mouse click to a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-???&amp;gt; :YcmCompleter GoTo&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do that using &lt;code&gt;nnoremap&lt;/code&gt;? What symbol should I use for that?&lt;/p&gt;&#xA;" OwnerUserId="9140" LastActivityDate="2019-08-22T21:10:51.800" Title="Mapping Ctrl + mouse click" Tags="|key-bindings|mouse|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20419" PostTypeId="2" ParentId="20418" CreationDate="2019-06-25T12:58:23.927" Score="5" Body="&lt;p&gt;You are looking for this which I found at the bottom of &lt;a href=&quot;http://vimhelp.appspot.com/intro.txt.html#keycodes&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h keycodes&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-LeftMouse&amp;gt; :echom 'Foo'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And according to &lt;a href=&quot;http://vimhelp.appspot.com/visual.txt.html#%3cLeftMouse%3e&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h &amp;lt;LeftMouse&amp;gt;&lt;/code&gt;&lt;/a&gt; you also need to check that &lt;code&gt;set mouse&lt;/code&gt; contains &lt;code&gt;a&lt;/code&gt; or &lt;code&gt;n&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-06-25T12:58:23.927" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20420" PostTypeId="1" CreationDate="2019-06-25T14:37:01.717" Score="1" ViewCount="207" Body="&lt;p&gt;I'm trying to map ctrl+click event to generic navigation for java types using &lt;a href=&quot;https://github.com/ycm-core/YouCompleteMe&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouCompleteMe&lt;/a&gt; plugin. There's plugin command to do that: &lt;code&gt;:YcmCompleter GoTo&lt;/code&gt; it navigates to &quot;most sensible&quot; place for type under cursor: &lt;a href=&quot;https://github.com/ycm-core/YouCompleteMe#the-goto-subcommand&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ycm-core/YouCompleteMe#the-goto-subcommand&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This command tries to perform the &quot;most sensible&quot; GoTo operation it can&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is my &lt;code&gt;.vim/ftplugin/java.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-LeftMouse&amp;gt; :YcmCompleter GoTo&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's working but with one exception: it doesn't change cursor position before performing &lt;code&gt;GoTo&lt;/code&gt; command, e.g. if the cursor is located on one type and I'm clicking another type, it will open first type. It seems that I'm doing something wrong here. I need first move cursor to clicking position and then execute the command, or maybe I'm doing something wrong here and vim has another way to implement such feature. How to implement it correctly? &lt;/p&gt;&#xA;" OwnerUserId="9140" LastActivityDate="2019-06-25T14:37:01.717" Title="Using mouse to navigate to type using YouCompleteMe plugin" Tags="|key-bindings|plugin-you-complete-me|mouse|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20422" PostTypeId="1" AcceptedAnswerId="20423" CreationDate="2019-06-25T15:51:59.643" Score="2" ViewCount="282" Body="&lt;p&gt;When I need to cut some lines from one file to another file, I always do the following steps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Select the lines in file-1&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:w &amp;gt;&amp;gt; file-2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Re-select the lines&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is super annoying if you need to do it for like 10 times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there anyway I can write the selection to another file and delete the selection in the same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: maybe using &lt;code&gt;gvd&lt;/code&gt; to reselect and delete is a faster option.&lt;/p&gt;&#xA;" OwnerUserId="21700" LastEditorUserId="21700" LastEditDate="2019-06-26T01:44:51.987" LastActivityDate="2019-06-26T07:48:52.163" Title="vim - how do I cut some lines of file-1 to file-2 in 1 step?" Tags="|paste|selection|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20423" PostTypeId="2" ParentId="20422" CreationDate="2019-06-25T16:20:24.930" Score="3" Body="&lt;p&gt;You could make it a one liner using a range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2,3w &amp;gt;&amp;gt; b | 2,3d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if you want to keep doing this with visual selection, you can select the lines and then use &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; for the range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;w &amp;gt;&amp;gt; b | '&amp;lt;,'&amp;gt; d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; To address the questions in comments:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the file you're trying to write doesn't exist you can use &lt;code&gt;w!&lt;/code&gt; to force the command&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;|&lt;/code&gt; character is used to chain commands (not unlike &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; in bash), you can read about it at &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3Abar&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :bar&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *:bar* *:\bar*&#xA;'|' can be used to separate commands, so you can give multiple commands in one&#xA;line.  If you want to use '|' in an argument, precede it with '\'.&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-06-26T07:48:52.163" LastActivityDate="2019-06-26T07:48:52.163" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20424" PostTypeId="1" CreationDate="2019-06-25T16:26:35.533" Score="2" ViewCount="2864" Body="&lt;p&gt;After upgrading to Windows 10 1903 (18362.175), in Window Subsystem for Linux (WSL) Ubuntu 18.04, the background color is always set to black when scrolling backward in &lt;code&gt;vi&lt;/code&gt;, &lt;code&gt;vim&lt;/code&gt;, &lt;code&gt;man&lt;/code&gt; and maybe some other tools. &#xA;&lt;a href=&quot;https://i.stack.imgur.com/Q3hWF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Q3hWF.png&quot; alt=&quot;man ls background color wrong&quot;&gt;&lt;/a&gt;&#xA;Is there a workaround involving vi configuration or shell commands? (I would rather not install a different terminal emulator.)&lt;/p&gt;&#xA;" OwnerUserId="22779" LastActivityDate="2019-07-25T17:02:05.247" Title="vi background color wrong on Windows 10 1903 WSL Terminal" Tags="|terminal|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20425" PostTypeId="2" ParentId="20424" CreationDate="2019-06-25T16:34:29.083" Score="1" Body="&lt;p&gt;This Windows 10 terminal issue is documented in &lt;a href=&quot;https://github.com/microsoft/terminal/issues/832&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim background color renders incorrectly&lt;/a&gt;.  A workaround is to set the vi background color to one of 16 working colors.&#xA;In ~/.vimrc put:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight Normal ctermfg=black ctermbg=lightgrey&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When in vim, this sets the text color to black and the background color to lightgrey.&#xA;Use &lt;code&gt;:help cterm-colors&lt;/code&gt; in vim to see other working color names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in Windows 10 1903, Linux files can now be accessed from Windows.  See &lt;a href=&quot;https://devblogs.microsoft.com/commandline/whats-new-for-wsl-in-windows-10-version-1903/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;&#xA;So a graphical editor like gvim (&lt;a href=&quot;https://www.vim.org/download.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.vim.org/download.php&lt;/a&gt;) can be used.&lt;/p&gt;&#xA;" OwnerUserId="22779" LastActivityDate="2019-06-25T16:34:29.083" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20426" PostTypeId="1" CreationDate="2019-06-26T13:27:27.253" Score="0" ViewCount="64" Body="&lt;p&gt;Given an input file of the form &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#1. This STUFF&#xA;Content related to 1&#xA;...and some tips &#xA;&#xA;#4. Fouth heading &#xA;4para&#xA;4para&#xA;&#xA;&#xA;#3. &#xA;3para&#xA;3para&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to sort it to get: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#1. This STUFF&#xA;Content related to 1&#xA;...and some tips &#xA;&#xA;#3. &#xA;3para&#xA;3para&#xA;&#xA;#4. Fouth heading &#xA;4para&#xA;4para&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;specifically I'd like to be able to do this with a command that looks like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :sort break=&quot;#&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i.e. change the linebreak character to &quot;#&quot; for the duration of the sort. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible in any way? A similar question might be &quot;Can I sort the fuctions in a python file alphabetically by name?&quot;&lt;/p&gt;&#xA;" OwnerUserId="8792" LastActivityDate="2019-06-28T02:18:08.297" Title="Using different character(s) as linebreak" Tags="|macvim|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20427" PostTypeId="1" CreationDate="2019-06-26T13:31:15.320" Score="3" ViewCount="36" Body="&lt;p&gt;I'm writing a lot of LaTeX recently, and am used to hitting the &lt;code&gt;$&lt;/code&gt; key for inline math, but have heard that &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; is better (apparently it confuses vim less, especially with &lt;code&gt;$$&lt;/code&gt;, which I'm also not using).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; are hard to type quickly—&lt;code&gt;$&lt;/code&gt; is effectively one keystroke. Can I make &lt;code&gt;$&lt;/code&gt; insert the appropriate opening and closing brackets at once?&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-26T13:31:15.320" Title="How can I make $ in LaTeX insert \( and \) automatically?" Tags="|key-bindings|filetype-tex|" AnswerCount="1" CommentCount="0" ClosedDate="2019-06-26T16:08:55.003" ContentLicense="CC BY-SA 4.0" />
  <row Id="20428" PostTypeId="2" ParentId="20427" CreationDate="2019-06-26T13:31:15.320" Score="3" Body="&lt;p&gt;Yes you can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The preliminaries: we will need to determine if the last opening &lt;code&gt;\(&lt;/code&gt; comes before or after the last closing &lt;code&gt;\)&lt;/code&gt; in order to determine which delimiter to insert. (This also means we don't have a literal mapping—we are going to use &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; instead.) So I created &lt;code&gt;~/.vim/autoload/pos.vim&lt;/code&gt; with the following contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; true iff p1 is before p2 in the buffer&#xA;&quot; a pos is [lnum, col]&#xA;function! pos#before(p1, p2) abort&#xA;  return a:p1[0] &amp;lt; a:p2[0] || (a:p1[0] == a:p2[0] &amp;amp;&amp;amp; a:p1[1] &amp;lt;= a:p2[1])&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, we need to write our function to return the correct delimiter. In &lt;code&gt;~/.vim/autoload/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! tex#inline() abort&#xA;  let l:open_pattern = '\m\\('&#xA;  let l:close_pattern = '\m\\)'&#xA;  let l:open_pos = searchpos(l:open_pattern, 'bn')&#xA;  let l:close_pos = searchpos(l:close_pattern, 'bn')&#xA;  if pos#before(l:open_pos, l:close_pos)&#xA;    return '\('&#xA;  else&#xA;    return '\)'&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, we want this to take effect. In &lt;code&gt;~/.vim/after/ftplugin/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; $ tex#inline()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Make sure to add the unmapping of &lt;code&gt;$&lt;/code&gt; to &lt;code&gt;b:undo_ftplugin&lt;/code&gt; by whatever mechanism you use.)&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-26T13:31:15.320" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20429" PostTypeId="1" AcceptedAnswerId="20483" CreationDate="2019-06-26T14:06:08.100" Score="1" ViewCount="718" Body="&lt;p&gt;I have a file template which is rendered with replacing some stubs when new file created:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup templates&#xA;  autocmd!&#xA;  autocmd BufNewFile *.java $r ~/.vim/templates/skeleton.java|call s:SetupJavaClass()&#xA;&#xA;  fun! s:SetupJavaClass()&#xA;    exe &quot;%s/__CLASS_NAME__/&quot; . expand('%:t:r')&#xA;  endfun&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it's working fine, but only if I create new file with new buffer, e.g. &lt;code&gt;vim Foo.java&lt;/code&gt; works, but when I create new file from NerdTree, new file is opening in current buffer and my templates and vim doesn't call my autocommands. How can I fix it? Is it possible to create autocommand to be executed on every new file, doesn't matter it was opened in new buffer or not, or maybe I should use ftplugin for that?&lt;/p&gt;&#xA;" OwnerUserId="9140" LastActivityDate="2019-07-02T12:06:46.073" Title="Apply templates when new file created" Tags="|buffers|autocmd|plugin-nerdtree|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20430" PostTypeId="2" ParentId="20426" CreationDate="2019-06-26T14:52:17.847" Score="1" Body="&lt;p&gt;I would use a special marker for end-of-line, join all lines in a section into one line, sort the lines, and replace the markers by linefeeds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Add an empty line at the end of file so the search pattern&#xA;&quot; in the :global command will work.&#xA;:$put =''&#xA;&quot; Mark every end-of-line.&#xA;:%s/$/&amp;lt;EOL&amp;gt;/&#xA;&quot; Join all lines in a section starting with a hash up until&#xA;&quot; the line before the next section or the end of the file.&#xA;:g/^#/;/\(^#\|\%$\)/-1join!&#xA;&quot; Get rid of the additional empty line.&#xA;:$d&#xA;&quot; Sort the file by the numbers after the hash signs.&#xA;:sort n /^#/&#xA;&quot; Re-insert the linefeeds.&#xA;:%s/&amp;lt;EOL&amp;gt;/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2636" LastActivityDate="2019-06-26T14:52:17.847" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20431" PostTypeId="1" CreationDate="2019-06-26T15:23:45.703" Score="2" ViewCount="5041" Body="&lt;p&gt;I've found a lot of information online about this for Linux-Vim but not for the Windows-Vim (not gvim). Whenever I try to copy and paste something in Vim (using &lt;code&gt;y&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt;), the copies I make do not expand to the system, only to the currently running instance of vim. Here are a few different scenarios that all do different things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Copying-and-pasting like normal in the command prompt (by highlighting to copy and right-clicking to paste) works as expected - it copies to and pastes from the system clipboard&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I copy &lt;code&gt;abc&lt;/code&gt; in notepad, I can paste &lt;code&gt;abc&lt;/code&gt; in any opened vim with &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;&quot;*p&lt;/code&gt; or &lt;code&gt;&quot;+p&lt;/code&gt;. But if I copy &lt;code&gt;123&lt;/code&gt; from one instance of vim with &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;&quot;+y&lt;/code&gt;, or &lt;code&gt;&quot;*y&lt;/code&gt;, I can paste &lt;code&gt;123&lt;/code&gt; in that instance, but if I switch to another, &lt;code&gt;abc&lt;/code&gt; will paste instead of &lt;code&gt;123&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Based on what I've read, this is because Vim places the data in a register, but the register doesn't get transferred to the windows clipboard. However, I haven't been able to find any information online about why, everything is limited to the Linux version. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried using &lt;code&gt;:set guioptions+=a&lt;/code&gt; as mentioned &lt;a href=&quot;https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim&quot;&gt;here&lt;/a&gt; but that doesn't seem to work. Also, &lt;code&gt;+clipboard&lt;/code&gt; returns 1, so I believe it should be enabled.&lt;/p&gt;&#xA;" OwnerUserId="1965" LastEditorUserId="1965" LastEditDate="2019-06-26T15:55:51.970" LastActivityDate="2019-06-27T07:23:03.920" Title="Make vim support the Windows clipboard" Tags="|cut-copy-paste|microsoft-windows|os-clipboard|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20432" PostTypeId="2" ParentId="20431" CreationDate="2019-06-26T17:44:10.690" Score="2" Body="&lt;p&gt;I don't have a Windows machine to test, but I think you are looking for&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set clipboard=unnamedplus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Than Vim always uses the &lt;code&gt;+&lt;/code&gt; register &quot;for all yank, delete, change and put operations which would normally go to the unnamed register&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help clipboard&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-06-26T17:44:10.690" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20433" PostTypeId="1" AcceptedAnswerId="20435" CreationDate="2019-06-26T22:34:49.133" Score="3" ViewCount="2868" Body="&lt;p&gt;I have the text pattern &lt;code&gt;[2]&lt;/code&gt; in a text file. I want to replace it with the text string &lt;code&gt;[1]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Using this command:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:%s/\&amp;lt;[2]\&amp;gt;/[1]/&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Vim only replaces the string '2' in the square brackets so the result is &lt;code&gt;[[1]]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I read that when searching:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;After an opening [, everything until the next closing ] specifies a /collection &lt;a href=&quot;https://vim.fandom.com/wiki/Search_and_replace&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So I tried escaping the square brackets:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:%s/\&amp;lt;\[2\]\&amp;gt;/[1]/&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;But I received this error:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;E486: Pattern not found: \&amp;lt;\[2\]\&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Enclosing the entire pattern in the brackets (&lt;code&gt;:%s/\&amp;lt;[[2]]\&amp;gt;/[1]/&lt;/code&gt;) also returns the &lt;code&gt;E486: Pattern not found: \&amp;lt;[[2]]\&amp;gt;&lt;/code&gt; error&lt;/p&gt;&#xA;&lt;p&gt;Then removing the special character (or more accurately escape sequence) for the beginning of a word ('&amp;lt;') and the end of a word ('&amp;gt;') i.e. &lt;code&gt;:%s/[[2]]/[1]/&lt;/code&gt; gives the result &lt;code&gt;[[1]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;When searching with the &lt;code&gt;:s&lt;/code&gt; (substitute) command, the collection &lt;code&gt;[[2]]&lt;/code&gt; should match any single character '[', '2' or ']', so why does &lt;code&gt;:%s/\&amp;lt;[[2]]\&amp;gt;/[1]/&lt;/code&gt; cause an &lt;code&gt;E486: Pattern not found: \&amp;lt;[[2]]\&amp;gt; &lt;/code&gt; error?&lt;/li&gt;&#xA;&lt;li&gt;How do you search for text patterns consisting of an opening bracket (&lt;code&gt;[&lt;/code&gt;) and closing bracket (&lt;code&gt;]&lt;/code&gt;) e.g. the text pattern &lt;code&gt;[2]&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Why is &lt;code&gt;[ ]&lt;/code&gt; interpreted as a collection in the search part of the substitute command, but &lt;code&gt;[ ]&lt;/code&gt; is not interpreted as a collection in the replace part of the substitute command?&lt;/li&gt;&#xA;&lt;li&gt;Why does &lt;code&gt;:%s/[[2]]/[1]/&lt;/code&gt; only replace the text pattern '2]' i.e. giving the result &lt;code&gt;[[1]&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Does enclosing the entire pattern in the brackets (&lt;code&gt;:%s/\&amp;lt;[[2]]\&amp;gt;/[1]/&lt;/code&gt;) return an &lt;code&gt;E486: Pattern not found: \&amp;lt;[[2]]\&amp;gt; error&lt;/code&gt; because Vim tries looking for the text pattern '[[2]]' but couldn't find it, or is something else causing this error?&lt;/li&gt;&#xA;&lt;li&gt;The command &lt;code&gt;:%s/\&amp;lt;[2]\&amp;gt;/[1]/&lt;/code&gt;&#xA;only replaces the string &lt;code&gt;2&lt;/code&gt; in the square brackets (the result is &lt;code&gt;[[1]]&lt;/code&gt;), which indicates that the collection &lt;code&gt;[2]&lt;/code&gt; matches only the single character &lt;code&gt;2&lt;/code&gt;, but what happened to the beginning-of-a-word escape sequence ('&amp;lt;') and the ending-of-a-word escape sequence ('&amp;gt;')? Why do the escape sequences have no effect or not cause an error?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="18294" LastEditorUserId="40397" LastEditDate="2022-01-07T18:10:58.490" LastActivityDate="2022-01-07T18:10:58.490" Title="Inserting a square bracket as part of search and replace" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20435" PostTypeId="2" ParentId="20433" CreationDate="2019-06-27T00:35:44.600" Score="4" Body="&lt;p&gt;Before we get to all the questions, the way I'd achieve what you're looking to do is with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\[2\]/[1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or the following if you just want to change the text inside the &lt;code&gt;[]&lt;/code&gt; without having to specify them again in the replacement part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\[\zs2\ze\]/1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I believe the reason you are getting the &quot;Pattern not found&quot; error when you escape the square brackets is because &lt;code&gt;\&amp;lt;&lt;/code&gt; is expecting the next character to be a &quot;word character&quot;, but square brackets aren't considered to be a word character by default, so it gets a bit confused.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you remove the &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; and search for &lt;code&gt;[[2]]&lt;/code&gt;, I think vim is trying to be clever about the way it interprets the brackets.  The first &lt;code&gt;[&lt;/code&gt; starts the collection and the first &lt;code&gt;]&lt;/code&gt; closes the collection and inside the collection it's trying to match either a literal &lt;code&gt;[&lt;/code&gt; or a &lt;code&gt;2&lt;/code&gt;.  Then the second &lt;code&gt;]&lt;/code&gt; is being being interpreted as a literal &lt;code&gt;]&lt;/code&gt; since it would otherwise be a syntax error since there is no opening &lt;code&gt;[&lt;/code&gt; to match it.  So, it's basically looking for either a &lt;code&gt;[&lt;/code&gt; or a &lt;code&gt;2&lt;/code&gt; that is immediately followed by a &lt;code&gt;]&lt;/code&gt;.  It matches the &lt;code&gt;2]&lt;/code&gt; and replaces that with &lt;code&gt;[1]&lt;/code&gt; so you end up with &lt;code&gt;[[1]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Answers to your other questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;As I tried to explain above (probably confusingly), it's only looking for either a &lt;code&gt;[&lt;/code&gt; or a &lt;code&gt;2&lt;/code&gt;.  The first &lt;code&gt;]&lt;/code&gt; is terminating the collection.  Then the second &lt;code&gt;]&lt;/code&gt; is being interpreted as a literal &lt;code&gt;]&lt;/code&gt;.  I think you may have a typo in the question: &lt;code&gt;:%s/[[2]]/[1]/&lt;/code&gt; should result in &lt;code&gt;[[1]&lt;/code&gt; and not the &quot;Pattern not found&quot; error.&lt;/li&gt;&#xA;&lt;li&gt;You had the right idea with escaping the brackets with &lt;code&gt;\&lt;/code&gt;.  The problem was with the &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt;.  The pattern should be &lt;code&gt;\[2\]&lt;/code&gt; to match &lt;code&gt;[2]&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;It wouldn't really make sense to interpret &lt;code&gt;[]&lt;/code&gt; as a collection in the replacement part since that construct is intended to match a single character within the collection.  As such, it just assumes it's the literal characters in the replacement part.&lt;/li&gt;&#xA;&lt;li&gt;See the explanation above.&lt;/li&gt;&#xA;&lt;li&gt;As stated above, the brackets aren't considered to be a &quot;word character&quot; by default, so I &lt;em&gt;think&lt;/em&gt; it's choking on the fact that it's looking for a literal &lt;code&gt;]&lt;/code&gt; followed by the end of word boundary which doesn't really make sense.  I'm not 100% sure about this part, though (my experimentation had some odd results).&lt;/li&gt;&#xA;&lt;li&gt;In this case the brackets around the &lt;code&gt;2&lt;/code&gt; are used to specify a collection of just one character, so it finds the &lt;code&gt;2&lt;/code&gt; (which is considered a &quot;word character&quot;) and then replaces it with the &lt;code&gt;[1]&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2019-06-27T00:35:44.600" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20436" PostTypeId="2" ParentId="20426" CreationDate="2019-06-27T02:25:17.917" Score="2" Body="&lt;pre&gt;&lt;code&gt;for id in reverse(range(1,100)) | sil exe printf('g/\v^#%d\./,/\v.*(\n#\d+\.|%%$)/ m0', id) | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Loop from 100 to 1, execute &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Aglobal&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :global&lt;/a&gt; for each number, use &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Am&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :m&lt;/a&gt; to move each block to file start.&#xA;This method is slow, see update for a better way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Break down of &lt;code&gt;g/\v^#3\./,/\v.*(\n#\d+\.|%$)/ m0&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/\v^#3+\./&lt;/code&gt; find line starts with &lt;code&gt;#3.&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;,/\v.*(\n#\d+\.|%$)/&lt;/code&gt; this a &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#%5Brange%5D&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h [range]&lt;/a&gt; , it starts from current line, ends at line followed by line starts with &lt;code&gt;#\d+\.&lt;/code&gt; or end of file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;m0&lt;/code&gt; move to file start.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more efficient method:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%d | put ='#'.join(sort(split(@@, '\v#\ze\d+\.'),'N'),'#') | 1d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%d&lt;/code&gt; delete whole file into default register&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;put =&lt;/code&gt; &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Aput&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :put&lt;/a&gt; text from register &lt;a href=&quot;https://vimhelp.org/change.txt.html#quote%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h quote=&lt;/a&gt; after current line (line 1).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'#'.join(sort(split(@@, '\v#\ze\d+\.'),'N'),'#')&lt;/code&gt; split by &lt;code&gt;#&lt;/code&gt;, sort numberical, join by &lt;code&gt;#&lt;/code&gt;, add leading &lt;code&gt;#&lt;/code&gt; for 1st item.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1d&lt;/code&gt; remove 1st line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-06-28T02:18:08.297" LastActivityDate="2019-06-28T02:18:08.297" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20437" PostTypeId="2" ParentId="20431" CreationDate="2019-06-27T07:23:03.920" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I've found a lot of information online about this for Linux-Vim but not for the Windows-Vim (not gvim).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There's no much difference really, except Windows has only one clipboard, so both &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;+&lt;/code&gt; could be used interchangeably.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I copy abc in notepad, I can paste abc in any opened vim with p or &quot;*p or &quot;+p&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Just &lt;code&gt;p&lt;/code&gt; uses so-called unnamed register, which is basically an alias for the last register used. That means it may &lt;em&gt;accidentally&lt;/em&gt; work for the system clipboard, but, in general, it does not. On the other hand, both &lt;code&gt;&quot;*p&lt;/code&gt; and &lt;code&gt;&quot;+p&lt;/code&gt; always put the contents of the system clipboard at the cursor position.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But if I copy 123 from one instance of vim with y, &quot;+y, or &quot;*y&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The same, of course, applies to yanking. The unnamed register, in general, is not visible outside of the current instance of Vim. But &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; are.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-06-27T07:23:03.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20440" PostTypeId="2" ParentId="20304" CreationDate="2019-06-27T21:16:16.750" Score="0" Body="&lt;p&gt;Use :Ag command of the plugin FZF.vim. It is fuzzy regex search, possibly with preview. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-06-27T21:16:16.750" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20442" PostTypeId="1" AcceptedAnswerId="20443" CreationDate="2019-06-28T03:06:43.987" Score="3" ViewCount="115" Body="&lt;p&gt;Programming in Javascript and similar syntax languages we use a lot of &lt;code&gt;{}&lt;/code&gt; and &lt;code&gt;()&lt;/code&gt;, more so than &lt;code&gt;[]&lt;/code&gt; and the &lt;code&gt;90&lt;/code&gt;.  Therefore we end up using SHIFT a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make it so that when I type &lt;code&gt;[&lt;/code&gt; it actually outputs &lt;code&gt;{&lt;/code&gt; - &lt;code&gt;SHIFT+[&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I want SHIFT to work opposite on (), [] and &amp;amp; and |, so when I type &lt;code&gt;SHIFT+[&lt;/code&gt; it outputs &lt;code&gt;[&lt;/code&gt; and if I type just &lt;code&gt;[&lt;/code&gt; it outputs &lt;code&gt;{&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to have one less key stroke to output these special chars as I use than more than the &quot;unshifted&quot; chars.&lt;/p&gt;&#xA;" OwnerUserId="22815" LastActivityDate="2019-06-28T04:44:59.983" Title="Auto replace special programming characters" Tags="|key-bindings|keyboard-layout|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20443" PostTypeId="2" ParentId="20442" CreationDate="2019-06-28T03:58:09.840" Score="3" Body="&lt;p&gt;If you're using vim, you want a :noremap variant.  To apply this for just the current editing session, and just in insert mode,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap [ {&#xA;:inoremap ] }&#xA;:inoremap 9 (&#xA;:inoremap 0 )&#xA;:inoremap 7 &amp;amp;&#xA;:inoremap \\ \|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the last one is different.  &lt;code&gt;\&lt;/code&gt; and &lt;code&gt;|&lt;/code&gt; are both special characters in vim's editor mode, they need to be escaped.  I'm pretty sure in other vi variants, you'll need to escape the &lt;code&gt;\&lt;/code&gt;, but I don't know if you'll need to escape the &lt;code&gt;|&lt;/code&gt; or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you still want to be able to insert the characters you just mapped away, map the others back to those.  Since we're using the :inoremap command rather than the :imap command, this works fine.  (If you tried that with :imap, the following would make an infinite loop.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap { [&#xA;:inoremap } ]&#xA;:inoremap ( 9&#xA;:inoremap ) 0&#xA;:inoremap &amp;amp; 7&#xA;:inoremap \| \\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because these commands are limiting the change to just insert mode, the first set shouldn't interfere with typing the second set.  That said, you can also do them all on one line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap [ {|inoremap ] }|inoremap { [|inoremap } ]|inoremap 9 (|inoremap 0 )|inoremap ( 9|inoremap ) 0|inoremap 7 &amp;amp;|inoremap \\ \||inoremap &amp;amp; 7|inoremap \| \\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These commands are suitable for use in a .vimrc file, either to set them globally or as part of an autocommand.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd BufEnter *.html :inoremap [ {|inoremap ] }|inoremap { [|inoremap } ]|inoremap 9 (|inoremap 0 )|inoremap ( 9|inoremap ) 0|inoremap 7 &amp;amp;|inoremap \\ \||inoremap &amp;amp; 7|inoremap \| \\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20713" LastEditorUserId="20713" LastEditDate="2019-06-28T04:44:59.983" LastActivityDate="2019-06-28T04:44:59.983" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20444" PostTypeId="1" CreationDate="2019-06-28T08:57:23.737" Score="0" ViewCount="286" Body="&lt;p&gt;I use Ctrl+P and Ctrl-N for autocompletition, and since I have library sources in another directory, like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/opt/ST/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/STM32F4xx_StdPeriph_Driver/inc&#xA;/opt/ST/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/STM32F4xx_StdPeriph_Driver/src&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to add these paths for autocompletition.&#xA;I tried to do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path+=/opt/ST/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/STM32F4xx_StdPeriph_Driver/inc&#xA;set path+=/opt/ST/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/STM32F4xx_StdPeriph_Driver/src&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Changes to &lt;code&gt;path&lt;/code&gt; variables are reflected correctly, but Ctrl-P and Ctrl-N don't search in these path too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is wrong in my setup ?&lt;/p&gt;&#xA;" OwnerUserId="15254" LastActivityDate="2020-12-01T17:05:37.077" Title="Adding directory (header and source) to autocompletition search" Tags="|autocompletion|path|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20445" PostTypeId="2" ParentId="20062" CreationDate="2019-06-28T14:52:00.273" Score="1" Body="&lt;p&gt;I use &quot;very magic&quot; setting (&lt;code&gt;\v&lt;/code&gt;) so that I can use normal regex patterns and not have to convert it into vim's awkward regex format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I would do search as the original regex search term, but prepend with &lt;code&gt;\v&lt;/code&gt; to enable &quot;very magic&quot; regex setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v!\[(.*)\]\((.+)\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After testing it to make sure it is working correctly, I'd finally do search/replace operation by:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:%s/&lt;/code&gt;&lt;strong&gt;&lt;code&gt;&amp;lt;ctrl-r&amp;gt;/&lt;/code&gt;&lt;/strong&gt;&lt;code&gt;/{{&amp;lt; figure alt=&quot;\1&quot; src=&quot;\2&quot; &amp;gt;}}/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;ctrl-r&amp;gt;/&lt;/code&gt; will paste the original search regex, so you don't have to retype it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Result will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v!\[(.*)\]\((.+)\)/{{&amp;lt; figure alt=&quot;\1&quot; src=&quot;\2&quot; &amp;gt;}}/ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21762" LastActivityDate="2019-06-28T14:52:00.273" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20446" PostTypeId="2" ParentId="14698" CreationDate="2019-06-28T15:17:25.823" Score="2" Body="&lt;p&gt;I saw this warning when editing a file on a cifs share. My local machine time was ahead of the remote system (by ~30min) due to incorrect date&amp;amp;time/timezone setting. Once sorted,the vim warning stopped !&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim 8.0&#xA;Local and remote systems: Linux&lt;/p&gt;&#xA;" OwnerUserId="22823" LastActivityDate="2019-06-28T15:17:25.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20447" PostTypeId="2" ParentId="10581" CreationDate="2019-06-28T17:24:12.557" Score="1" Body="&lt;p&gt;You can enable caching, if it is not enabled already:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_use_caching = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It significantly reduces lag and is ideal if there aren't a lot of changes inside the directory, ie not a lot of new or deleted files.  However, as files are added or removed or renamed, the file index will become stale, and it needs to be refreshed (ie re-indexed) by pressing &lt;code&gt;ctrl+p&lt;/code&gt; and then &lt;code&gt;F5&lt;/code&gt; (or alternatively, enter &lt;code&gt;:CtrlPClearCache&lt;/code&gt; in command mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer to use faster file search external app, and not have to deal with caching at all.  I recommend either &lt;a href=&quot;https://geoff.greer.fm/ag/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ag (The Silver Searcher)&lt;/a&gt; or &lt;a href=&quot;https://github.com/BurntSushi/ripgrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;ripgrep&lt;/a&gt;. They are significantly faster than the ctrl-p's built-in search engine, and switching the engine is very easy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ag or Ripgrep needs to be installed first.  And then in &lt;code&gt;.vimrc&lt;/code&gt;, I add the following.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If using ripgrep:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if executable('rg')&#xA;    let g:ctrlp_user_command = 'rg %s --files --color=never --glob &quot;&quot;'&#xA;    let g:ctrlp_use_caching = 0&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If using ag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if executable('ag')&#xA;  let g:ctrlp_user_command = 'ag -l --nocolor -g &quot;&quot; %s'&#xA;  let g:ctrlp_use_caching = 0&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;On Windows, Ag seems to be slower and I recommend Ripgrep instead of Ag.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21762" LastActivityDate="2019-06-28T17:24:12.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20448" PostTypeId="1" AcceptedAnswerId="20450" CreationDate="2019-06-28T18:19:44.397" Score="10" ViewCount="2275" Body="&lt;p&gt;I pasted some code into a new, unwritten buffer in Vim.  I'd like to do some quick edits on the code without saving it to a file, but it hurts my eyes to look at code without syntax highlighting.  Can I use syntax highlighting without writing it to a file?  I don't want to write it to a file so I don't have to delete the file when I'm done.&lt;/p&gt;&#xA;" OwnerUserId="21476" LastActivityDate="2019-06-28T20:15:41.893" Title="Can I use syntax highlighting on an unwritten buffer?" Tags="|syntax-highlighting|buffers|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20449" PostTypeId="2" ParentId="20448" CreationDate="2019-06-28T18:43:23.997" Score="4" Body="&lt;p&gt;You can set the syntax highlighting by doing: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set syntax=java&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will work in the unwritten buffer. Change &lt;code&gt;java&lt;/code&gt; for the appropriate value.&lt;/p&gt;&#xA;" OwnerUserId="22830" LastActivityDate="2019-06-28T18:43:23.997" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20450" PostTypeId="2" ParentId="20448" CreationDate="2019-06-28T20:15:41.893" Score="14" Body="&lt;p&gt;In addition to setting the syntax, setting the filetype brings indent options (if you have those on), mappings, and other filetype specific vimscript to bear on your code. So I recommend&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set filetype=java&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which we typically abbreviate in interactive use as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ft=java&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-06-28T20:15:41.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20451" PostTypeId="2" ParentId="9296" CreationDate="2019-06-28T20:55:00.403" Score="3" Body="&lt;p&gt;Add &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; to map command, which will prevent this delay. It will instantly leave insert mode as soon as the second &lt;code&gt;j&lt;/code&gt; is pressed, as well as remove initially typed &lt;code&gt;j&lt;/code&gt;. Also if you need to type literal &quot;jj&quot;, you'd need to wait a bit, but it's very rare.   Also you won't be able to map something like &lt;code&gt;jjj&lt;/code&gt; as it won't wait for any character after &lt;code&gt;jj&lt;/code&gt; (which is probably ok for most).  See &lt;code&gt;:help map-nowait&lt;/code&gt; for more information.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;nowait&amp;gt; jj &amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; was added in Vim version 7.3.1261&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21762" LastEditorUserId="21762" LastEditDate="2019-06-28T21:02:23.083" LastActivityDate="2019-06-28T21:02:23.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20452" PostTypeId="1" CreationDate="2019-06-29T01:59:20.487" Score="2" ViewCount="386" Body="&lt;p&gt;I've recently decided to improve my multiple-pane Vim workflow, so I'm adding some new mappings to avoid the awkward &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; command. &#xA;Here's what I have currently:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; split-pane navigation remaps                                                   &#xA;nnoremap &amp;lt;c-j&amp;gt; &amp;lt;c-w&amp;gt;j                                                            &#xA;nnoremap &amp;lt;c-k&amp;gt; &amp;lt;c-w&amp;gt;k                                                            &#xA;nnoremap &amp;lt;c-h&amp;gt; &amp;lt;c-w&amp;gt;h                                                            &#xA;nnoremap &amp;lt;c-l&amp;gt; &amp;lt;c-w&amp;gt;l                                                            &#xA;nnoremap &amp;lt;c-|&amp;gt; :vsplit&amp;lt;cr&amp;gt;                                                     &#xA;nnoremap &amp;lt;c-_&amp;gt; :split&amp;lt;cr&amp;gt;                                                        &#xA;set splitbelow                                                                   &#xA;set splitright  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Right now, everything works except the &lt;code&gt;&amp;lt;c-|&amp;gt;&lt;/code&gt; vertical split. It is my understanding that the syntax would normally be &lt;code&gt;&amp;lt;c-|&amp;gt;&lt;/code&gt;, but since &lt;code&gt;|&lt;/code&gt; is a special character, it must be escaped. Here's what I found through &lt;code&gt;:help map_bar&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Since the '|' character is used to separate a map command from the next          &#xA;command, you will have to do something special to include  a '|' in {rhs}.       &#xA;There are three methods:                                                         &#xA;   use       works when                    example      ~                        &#xA;   &amp;lt;Bar&amp;gt;     '&amp;lt;' is not in 'cpoptions'     :map _l :!ls &amp;lt;Bar&amp;gt; more^M             &#xA;   \|        'b' is not in 'cpoptions'     :map _l :!ls \| more^M                &#xA;   ^V|       always, in Vim and Vi         :map _l :!ls ^V| more^M               &#xA;&#xA;(here ^V stands for CTRL-V; to get one CTRL-V you have to type it twice; you     &#xA;cannot use the &amp;lt;&amp;gt; notation &quot;&amp;lt;C-V&amp;gt;&quot; here).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I've tried the following and none of them seem to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-|&amp;gt; :vsplit&amp;lt;cr&amp;gt;    &#xA;nnoremap &amp;lt;c-\|&amp;gt; :vsplit&amp;lt;cr&amp;gt;    &#xA;nnoremap &amp;lt;c-&amp;lt;bar&amp;gt;&amp;gt; :vsplit&amp;lt;cr&amp;gt;    &#xA;nnoremap &amp;lt;c-^V|&amp;gt; :vsplit&amp;lt;cr&amp;gt;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And yes, I got &lt;code&gt;^V&lt;/code&gt; by holding Control and double-tapping V, not by typing Caret V. Thanks, any ideas would be appreciated!&lt;/p&gt;&#xA;" OwnerUserId="13333" LastActivityDate="2019-06-29T03:31:53.637" Title="Trouble mapping &lt;control-pipe&gt; in new keybinds" Tags="|key-bindings|split|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20453" PostTypeId="2" ParentId="20452" CreationDate="2019-06-29T03:31:53.637" Score="2" Body="&lt;p&gt;Use &lt;code&gt;&amp;lt;c-\&amp;gt;&lt;/code&gt;, which despite the backslash doesn't need to be escaped in maps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, &lt;code&gt;&amp;lt;c-bslash&amp;gt;&lt;/code&gt; is the same, useful in cases such as strings where the backslash has meaning.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-06-29T03:31:53.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20454" PostTypeId="1" AcceptedAnswerId="20456" CreationDate="2019-06-29T11:17:15.147" Score="1" ViewCount="133" Body="&lt;p&gt;I am usually writing LaTeX documents. I like to use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:iab iso isomorphism&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so that if I write a sentence like &lt;code&gt;This map is an iso.&lt;/code&gt;, it will expand to &lt;code&gt;This map is an isomorphism.&lt;/code&gt;. However, I also quite frequently use the command &lt;code&gt;\iso&lt;/code&gt; in math mode. So for example, I will write &lt;code&gt;$f \colon V \iso W$&lt;/code&gt; and nothing should be expanded. In other words, the backslash should be counted like a regular character at the beginning of the word, just as &lt;code&gt;aiso&lt;/code&gt; would not be expanded.&lt;/p&gt;&#xA;" OwnerDisplayName="user17723" LastActivityDate="2019-06-29T14:06:28.493" Title="Abbreviations: Count backslash as part of the word" Tags="|abbreviations|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20455" PostTypeId="1" AcceptedAnswerId="20460" CreationDate="2019-06-29T13:35:27.657" Score="1" ViewCount="255" Body="&lt;p&gt;Say I have files File1.m, File2.m, and File3.m in the current directory.  I want vimgrep to search all but File3.m.  After reading the help on using backticks to specify files for vimgrep, I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep SearchExpression `echo !(File3).m`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This yields the error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Cannot open file &quot;File1.m File2.m&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the &lt;code&gt;!(File3).m&lt;/code&gt; is being properly expanded by bash, but the space-separated file names that come back are being interpretted in the vimgrep command as a single file name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to have them interpretted as separate files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using [g]vim on cygwin.&lt;/p&gt;&#xA;" OwnerUserId="7970" LastEditorUserId="7970" LastEditDate="2019-06-29T14:15:47.310" LastActivityDate="2019-06-30T02:56:34.753" Title="Exclude files from vimgrep by using bash file name expansion?" Tags="|vimgrep|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20456" PostTypeId="2" ParentId="20454" CreationDate="2019-06-29T14:06:28.493" Score="2" Body="&lt;p&gt;Abbreviations use the &lt;code&gt;iskeyword&lt;/code&gt; option.  Thus, you can add &lt;code&gt;\&lt;/code&gt; to the list of keyword characters.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set iskeyword+=\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this has many side effects which might be unwanted, such changing the meaning of motions like &lt;code&gt;w&lt;/code&gt;.  An alternative is to use an expression abbreviation which checks whether the iso is prefixed with a &lt;code&gt;\&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoreabbrev &amp;lt;expr&amp;gt; iso getline('.')[col('.')-5] == '\' ? 'iso' : 'isomorphism'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus, &lt;code&gt;\iso&lt;/code&gt; will stay as &lt;code&gt;\iso&lt;/code&gt; but &lt;code&gt;iso&lt;/code&gt; will be expanded to &lt;code&gt;isomorphism&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-06-29T14:06:28.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20457" PostTypeId="1" AcceptedAnswerId="20458" CreationDate="2019-06-29T17:33:49.443" Score="0" ViewCount="1803" Body="&lt;p&gt;Today I was writing code in VIM and wanted to change the PYTHONPATH and so I ran:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!echo $PYTHONPATH;export PYTHONPATH=&quot;/home/oli/git/published_libraries/computer_communication_framework&quot;;echo $PYTHONPATH&#xA;:/home/oli/git/whole_cell_modelling_suite:/home/oli/git/cluster_control:/home/oli/git/whole_cell_modelling_suite:/home/oli/git/cluster_control&#xA;/home/oli/git/published_libraries/computer_communication_framework&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as expected but checking the PYTHONPATH again shows that the change has not been remembered:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!echo $PYTHONPATH&#xA;:/home/oli/git/whole_cell_modelling_suite:/home/oli/git/cluster_control:/home/oli/git/whole_cell_modelling_suite:/home/oli/git/cluster_control&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me what is going on here and how I can set the PYTHONPATH from inside VIM. &lt;/p&gt;&#xA;" OwnerUserId="18379" LastActivityDate="2019-06-30T19:27:28.187" Title="Changing PYTHONPATH from inside VIM" Tags="|command-line|external-command|bash|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20458" PostTypeId="2" ParentId="20457" CreationDate="2019-06-29T19:29:04.010" Score="2" Body="&lt;p&gt;Your change happened inside a subprocess you spawned from vim. It is not visible to the parent process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;might&lt;/em&gt; be able to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let $PYTHONPATH='whatever_you_want'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it is probably a better idea to adjust the environment in the shell and launch vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# export PYTHONPATH=...&#xA;# vim ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As pointed out in comments, you can set environment variables only for a single process using &lt;code&gt;env&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# env PYTHONPATH=... vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or with bash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# PYTHONPATH=... vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-06-30T19:27:28.187" LastActivityDate="2019-06-30T19:27:28.187" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20460" PostTypeId="2" ParentId="20455" CreationDate="2019-06-30T02:25:56.740" Score="1" Body="&lt;p&gt;There's no &lt;em&gt;word splitting&lt;/em&gt; done on the string read by Vim. That is, there's nothing special about space characters...they are considered part of the filename. There are a couple ways that come to mind to separate the filenames. This one works...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimgrep SearchExpression `printf &quot;\%s\n&quot; !(File3).m`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The &lt;code&gt;%&lt;/code&gt; is escaped as Vim will otherwise treat it as special.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shell will put every filename on a separate line. Vim understands that each line is a different filename per last paragraph of &lt;a href=&quot;https://vimhelp.org/editing.txt.html#%60%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h `=&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tested on Cygwin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If any of your filenames have newlines in them, legal in bash, that's a different ball of wax. Vim doesn't deal well with them. I'm guessing that's not an issue for you.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-06-30T02:56:34.753" LastActivityDate="2019-06-30T02:56:34.753" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20461" PostTypeId="2" ParentId="20455" CreationDate="2019-06-30T02:30:43.267" Score="1" Body="&lt;p&gt;Set &lt;code&gt;'verbose'&lt;/code&gt; to 4, and execute your command again, you should see something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Calling shell to execute: &quot;(echo !(File3).m)&amp;gt;/tmp/vT1eqVi/2&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no way to tell whether a space belongs to filename in &lt;code&gt;/tmp/vT1eqVi/2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read after &lt;a href=&quot;https://vimhelp.org/editing.txt.html#backtick-expansion&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h backtick-expansion&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/editing.txt.html#%60%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h `=&lt;/a&gt; , you will find this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If the expression returns a string then names are to be separated with line&#xA;  breaks.  When the result is a |List| then each item is used as a name.  Line&#xA;  breaks also separate names.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To fix your problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimgrep SearchExpression `ls !(File3).m`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;ls&lt;/code&gt; is the same as &lt;code&gt;ls -1&lt;/code&gt; here, as it's output is redirected to a file.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-06-30T02:30:43.267" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20462" PostTypeId="1" CreationDate="2019-06-30T02:33:41.390" Score="1" ViewCount="257" Body="&lt;p&gt;Is it possible to break visual line without breaking line? For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Some text blah blah &quot;insert visual break&quot;&#xA;&quot;cursor now here&quot; keep writing. But both these sentences is one wrapped line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Visually it would be same behavior as regular &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; line break. But without new line characters inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can imagine a brute force solution, if tw=80, count the number of character spaces from cursor to textwidth limit 80, insert that many blank spaces.&lt;/p&gt;&#xA;" OwnerUserId="22840" LastEditorUserId="22857" LastEditDate="2019-07-03T01:28:32.850" LastActivityDate="2019-07-03T01:28:32.850" Title="Break visual line without hard breaking line" Tags="|line-breaks|wrap|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20464" PostTypeId="2" ParentId="20444" CreationDate="2019-06-30T15:55:26.680" Score="2" Body="&lt;pre&gt;&lt;code&gt;set complete=.,w,b,u,t,i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;the &lt;code&gt;i&lt;/code&gt; flag makes vim autocompletion search the including files.&lt;/p&gt;&#xA;&lt;p&gt;Also, you can use &lt;code&gt;gf&lt;/code&gt; command at the including file to verify vim can actually find the file.&lt;/p&gt;&#xA;&lt;p&gt;However, &lt;code&gt;i&lt;/code&gt; flag may slows down vim autocompletion significantly depending on the including file size and I avoid to use it.&lt;/p&gt;&#xA;" OwnerUserId="21815" LastEditorUserId="27564" LastEditDate="2020-12-01T17:05:37.077" LastActivityDate="2020-12-01T17:05:37.077" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20465" PostTypeId="1" AcceptedAnswerId="20466" CreationDate="2019-06-30T18:02:08.603" Score="2" ViewCount="163" Body="&lt;p&gt;I have successfully hidden undo files by using this auto hide plugin, but I could not hide any *.extension~ files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;suppose I created a.txt&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now there are two files shown in windows explorer&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a.txt&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;a.txt~&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;a.txt.un~ (Hidden)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I want to hide a.txt~ on save.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I need to use the&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;p pattern option for this&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Auto hide plugin&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;*g:autohide_types* (default &quot;suv&quot;)&#xA;  b = backup files (currently doesn't work with 'backupdir') &#xA; s = swap files&#xA;  u = undo files&#xA;  v = viminfo &#xA; p = files matching pattern&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;My vimrc file&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;source $VIMRUNTIME/vimrc_example.vim&#xA;&#xA;    set diffexpr=MyDiff()&#xA;    function MyDiff()&#xA;      let opt = '-a --binary '&#xA;      if &amp;amp;diffopt =~ 'icase' | let opt = opt . '-i ' | endif&#xA;      if &amp;amp;diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif&#xA;      let arg1 = v:fname_in&#xA;      if arg1 =~ ' ' | let arg1 = '&quot;' . arg1 . '&quot;' | endif&#xA;      let arg1 = substitute(arg1, '!', '\!', 'g')&#xA;      let arg2 = v:fname_new&#xA;      if arg2 =~ ' ' | let arg2 = '&quot;' . arg2 . '&quot;' | endif&#xA;      let arg2 = substitute(arg2, '!', '\!', 'g')&#xA;      let arg3 = v:fname_out&#xA;      if arg3 =~ ' ' | let arg3 = '&quot;' . arg3 . '&quot;' | endif&#xA;      let arg3 = substitute(arg3, '!', '\!', 'g')&#xA;      if $VIMRUNTIME =~ ' '&#xA;        if &amp;amp;sh =~ '\&amp;lt;cmd'&#xA;          if empty(&amp;amp;shellxquote)&#xA;            let l:shxq_sav = ''&#xA;            set shellxquote&amp;amp;&#xA;          endif&#xA;          let cmd = '&quot;' . $VIMRUNTIME . '\diff&quot;'&#xA;        else&#xA;          let cmd = substitute($VIMRUNTIME, ' ', '&quot; ', '') . '\diff&quot;'&#xA;        endif&#xA;      else&#xA;        let cmd = $VIMRUNTIME . '\diff'&#xA;      endif&#xA;      let cmd = substitute(cmd, '!', '\!', 'g')&#xA;      silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' &amp;gt; ' . arg3&#xA;      if exists('l:shxq_sav')&#xA;        let &amp;amp;shellxquote=l:shxq_sav&#xA;      endif&#xA;    endfunction&#xA;&#xA;&#xA;   let g:autohide_file_list='suvb'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What I have tried&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/9885725/hide-vim-backups-in-windows-explorer/43663493#comment100191400_43663493%20-&quot;&gt;Hide Vim backups (*~) in Windows Explorer&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4505&quot; rel=&quot;nofollow noreferrer&quot;&gt;autohide : Set 'hidden' attribute on swap files and the like in Windows &lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="22847" LastEditorUserId="22847" LastEditDate="2019-07-01T04:19:32.880" LastActivityDate="2019-07-01T05:50:52.700" Title="How can I hide *.extension~ files by using auto hide plugin?" Tags="|vimrc|plugin-system|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20466" PostTypeId="2" ParentId="20465" CreationDate="2019-06-30T19:35:53.327" Score="2" Body="&lt;p&gt;&lt;code&gt;autohide_types&lt;/code&gt; is a global variable, it should be declared like this &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:autohide_types='b'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you want to add type to existing list it should be like this &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:autohide_types.='b'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunetly this plugin works only with glob patterns and does not works with regexp. But it has public function &lt;code&gt;Autohide_DoHide({file})&lt;/code&gt;. So workaround&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4505&quot; rel=&quot;nofollow noreferrer&quot;&gt;You must have installed  auto hide plugin&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Then You should add this line to vimrc file &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufWritePost,FileWritePost * silent call Autohide_DoHide(expand('%:p').'~')&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1145" LastEditorUserId="22847" LastEditDate="2019-07-01T05:50:52.700" LastActivityDate="2019-07-01T05:50:52.700" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="20467" PostTypeId="1" CreationDate="2019-06-30T21:41:56.213" Score="1" ViewCount="114" Body="&lt;p&gt;In my &lt;code&gt;~/.vimrc&lt;/code&gt; I have at the moment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufLeave,FocusLost * nested silent! wall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which most of the time works as I would like, however sometimes it seems saving simply stops working (for a particular &lt;code&gt;gvim&lt;/code&gt; window, all tabs): when I alt-tab away from the window changes aren't saved. It does seem as though changing to a different tab saves the changes to the buffer, so perhaps &lt;code&gt;FocusLost&lt;/code&gt; in particular is not firing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way to get it working again is to close gvim and re-open my files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how to go about starting to debug this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: I've noticed that if I do a &lt;code&gt;:autocmd FocusLost * echo &quot;lost focus&quot;&lt;/code&gt; in a broken gvim session nothing is printed when I alt-tab away, while the message is printed as expected in windows where my autosaving is working as expected.&lt;/p&gt;&#xA;" OwnerUserId="22849" LastEditorUserId="22849" LastEditDate="2019-07-05T18:56:36.387" LastActivityDate="2019-07-05T18:56:36.387" Title="Automatically saving on FocusLost sometimes stops working for a gvim window" Tags="|gvim|autocmd|save|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20468" PostTypeId="1" AcceptedAnswerId="20482" CreationDate="2019-07-01T09:15:29.083" Score="0" ViewCount="210" Body="&lt;p&gt;I have a function that accepts a count of iterations, its &lt;code&gt;command&lt;/code&gt; is defined with &lt;code&gt;-range&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=1 -range DocbkPrintTag :call s:DocbkPrintTag(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and to output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;listitem&amp;gt;&#xA;&amp;lt;para&amp;gt;&#xA;&amp;lt;/para&amp;gt;&#xA;&amp;lt;/listitem&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I map it followingly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;unique&amp;gt; &amp;lt;localleader&amp;gt;li :&amp;lt;C-U&amp;gt;DocbkPrintTag li&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;&amp;lt;listitem&amp;gt;&lt;/code&gt; is defined in a custom dictionary as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:tags.li = { 'tag': 'listitem', 'type': 'outline', 'include': ['pa'] }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;while &lt;code&gt;&amp;lt;para&amp;gt;&lt;/code&gt; ['pa'] is defined as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:tags.pa = { 'tag': 'para', 'type': 'outline' }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;DocbkPrintTag&lt;/code&gt; function calls another function &lt;code&gt;DocbkRenderTag&lt;/code&gt; which assembles the XML output for a tag, possibly rendering it n-times if &lt;code&gt;count&lt;/code&gt; is specified on a keyboard before the mapping itself.&#xA;The problem is that for the case of ,&#xA;I call &lt;code&gt;DocbkRenderTag&lt;/code&gt; recursively from itself to first render &lt;code&gt;&amp;lt;para/&amp;gt;&lt;/code&gt; as an inside element of &lt;code&gt;&amp;lt;listitem/&amp;gt;&lt;/code&gt;.&#xA;Everyhing works fine for 1 repetition, but if i want to print 2 or more such structures, the &lt;code&gt;v:count1&lt;/code&gt; parameter is passed over to the inner function calling&#xA;but the inner tag should be repeated only once. How can i force to do the inner function call only once?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For completeness, here is the important part of the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists(&quot;:DocbkPrintTag&quot;)&#xA;  command -nargs=1 -range DocbkPrintTag :call s:DocbkPrintTag(&amp;lt;f-args&amp;gt;)&#xA;endif&#xA;&#xA;function s:DocbkPrintTag(tag)&#xA;  let result = s:DocbkRenderTag(a:tag)&#xA;  if !empty(result)&#xA;    call feedkeys('a' . result, 'n')&#xA;  endif&#xA;endfunction&#xA;&#xA;function s:DocbkRenderTag(tag)&#xA;  [...]&#xA;  let result = ''&#xA;  &quot; number of repetitions&#xA;  let i = 1&#xA;  while i &amp;lt;= v:count1 &#xA;    [...]&#xA;    if !empty(include)&#xA;      for incl_tag in include&#xA;        let incl_result .= s:DocbkRenderTag(incl_tag)&#xA;      endfor&#xA;    endif&#xA;    [...]&#xA;  endwhile&#xA;  return result&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output now is for example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;listitem&amp;gt;&amp;lt;para&amp;gt;&amp;lt;/para&amp;gt;&amp;lt;para&amp;gt;&amp;lt;/para&amp;gt;&amp;lt;/listitem&amp;gt;&#xA;&amp;lt;listitem&amp;gt;&amp;lt;para&amp;gt;&amp;lt;/para&amp;gt;&amp;lt;para&amp;gt;&amp;lt;/para&amp;gt;&amp;lt;/listitem&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of just &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;listitem&amp;gt;&amp;lt;para&amp;gt;&amp;lt;/para&amp;gt;&amp;lt;/listitem&amp;gt;&#xA;&amp;lt;listitem&amp;gt;&amp;lt;para&amp;gt;&amp;lt;/para&amp;gt;&amp;lt;/listitem&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22283" LastEditorUserId="22283" LastEditDate="2019-07-02T10:14:57.653" LastActivityDate="2019-07-02T11:03:30.170" Title="Run vimscript function only once although v:count1 &gt; 1" Tags="|vimscript|functions|filetype-xml|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20469" PostTypeId="1" AcceptedAnswerId="20470" CreationDate="2019-07-01T10:57:21.997" Score="2" ViewCount="167" Body="&lt;p&gt;I started to learn ViM one month ago, so I'm not a ViM expert. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: if I make some changes in insert mode (let's say I type some text, then I delete the last two words and finally type some other words) and then I press &lt;code&gt;&amp;lt;ESC&amp;gt; u&lt;/code&gt; the entire text I typed in Insert mode disappears. I know the existence of the &lt;code&gt;&amp;lt;CTRL-G&amp;gt; u&lt;/code&gt; command, which breaks the undo history, but I find it annoying typing &lt;code&gt;&amp;lt;CTRL-G&amp;gt; u&lt;/code&gt; every single time I delete something. Is there a way to automate the execution of that command every time I press a key (&lt;code&gt;&amp;lt;SPACE&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt;, ...) in insert mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot.&lt;/p&gt;&#xA;" OwnerUserId="22833" LastActivityDate="2020-12-14T14:09:49.463" Title="Automate breaking of history in insert mode" Tags="|insert-mode|undo-redo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20470" PostTypeId="2" ParentId="20469" CreationDate="2019-07-01T11:22:39.470" Score="3" Body="&lt;p&gt;You can define insert mode mappings for those keys by prepending &lt;code&gt;&amp;lt;c-g&amp;gt;u&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;space&amp;gt; &amp;lt;c-g&amp;gt;u&amp;lt;space&amp;gt;&#xA;:inoremap &amp;lt;bs&amp;gt;    &amp;lt;c-g&amp;gt;u&amp;lt;bs&amp;gt;&#xA;:inoremap &amp;lt;c-w&amp;gt;   &amp;lt;c-g&amp;gt;u&amp;lt;c-w&amp;gt;&#xA;&amp;quot; etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2636" LastEditorUserId="29128" LastEditDate="2020-12-14T14:09:49.463" LastActivityDate="2020-12-14T14:09:49.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20471" PostTypeId="2" ParentId="20469" CreationDate="2019-07-01T11:34:29.587" Score="2" Body="&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/insert.txt.html#ins-special-special&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ins-special-special&lt;/code&gt;&lt;/a&gt;, that section has some specific examples on using &lt;code&gt;inoremap&lt;/code&gt; to trigger &lt;code&gt;&amp;lt;C-G&amp;gt;u&lt;/code&gt; automatically for specific keystrokes such as backspace or newline.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An example for using &lt;code&gt;CTRL-G u&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    :inoremap &amp;lt;C-H&amp;gt; &amp;lt;C-G&amp;gt;u&amp;lt;C-H&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This redefines the backspace key to start a new undo sequence.  You can now undo the effect of the backspace key, without changing what you typed before that, with &lt;code&gt;CTRL-O u&lt;/code&gt;.  Another example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    :inoremap &amp;lt;CR&amp;gt; &amp;lt;C-]&amp;gt;&amp;lt;C-G&amp;gt;u&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This breaks undo at each line break.  It also expands abbreviations before this.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-01T11:34:29.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20473" PostTypeId="1" CreationDate="2019-07-01T13:25:00.537" Score="3" ViewCount="223" Body="&lt;p&gt;While in ViM I can set the &lt;code&gt;linebreak&lt;/code&gt; option to make a long line wrap at the end of the window avoiding a word to be split in two pieces, but I cannot find an equivalent option while printing a file with &lt;code&gt;:hardcopy&lt;/code&gt; or &lt;code&gt;:hardcopy &amp;gt; out.ps&lt;/code&gt; (there is the wrap option while setting &lt;code&gt;printoptions&lt;/code&gt;, but, if set, it can split a word in two parts). Is there an equivalent option of &lt;code&gt;linebreak&lt;/code&gt; while printing out the file with &lt;code&gt;:hardcopy&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot&lt;/p&gt;&#xA;" OwnerUserId="22833" LastActivityDate="2019-07-26T21:21:40.667" Title="Word wrap when printing a file with hardcopy" Tags="|printing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20474" PostTypeId="1" CreationDate="2019-07-01T10:37:00.687" Score="2" ViewCount="269" Body="&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; How do I permanently and persistently &lt;code&gt;:set syntax=context&lt;/code&gt; for &lt;code&gt;*.tex&lt;/code&gt; files?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've been using &lt;code&gt;vim&lt;/code&gt; for a LaTeX project, with &lt;a href=&quot;https://github.com/patstockwell/vim-monokai-tasty&quot; rel=&quot;nofollow noreferrer&quot;&gt;monokai-tasty&lt;/a&gt; as the colour scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default syntax highlighting seems to be TeX Highlighting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set syntax=tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I personally prefer ConTeXt Highlighting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set syntax=context&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but cannot figure out how to make it stick for all &lt;code&gt;*.tex&lt;/code&gt; buffers, or between sessions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried several ways of getting this to work, mostly through &lt;code&gt;vimrc&lt;/code&gt;, though none of them have. Most recently I created &lt;code&gt;~/.vim/ftdetect/tex.vim&lt;/code&gt; containing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.tex set syntax=context&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;vimrc&lt;/code&gt; can be &lt;a href=&quot;https://github.com/BrokenFlows/dotfiles/blob/master/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;seen here&lt;/a&gt;, in case there are any obvious collisions with what I'm trying to do there.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Not sure if I've given enough information. I am, of course, happy to add any more if it's not enough to be helpful.&lt;/p&gt;&#xA;" OwnerUserId="22858" OwnerDisplayName="BitFlow" LastActivityDate="2019-11-30T10:45:23.093" Title="How to set LaTeX syntax to &quot;ConTeXt&quot; in vimrc" Tags="|filetype-tex|syntax-highlighting|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20475" PostTypeId="1" CreationDate="2019-07-01T21:27:07.737" Score="0" ViewCount="89" Body="&lt;p&gt;When I run :maps that use ! to execute linux commands, the vim display is suspended to show the command output in the underlying container (xterm in my case). When the mapping terminates, any shell messages it may have produced are immediately obscured by the restored vim buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a handy Ctrl- or Ex command that will toggle the underlying xterm so that I can read such shell messages?&lt;/p&gt;&#xA;" OwnerUserId="5220" LastActivityDate="2019-07-02T19:05:55.827" Title="How show underlying container for vim, ie xterm etc" Tags="|shell|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20476" PostTypeId="1" AcceptedAnswerId="20488" CreationDate="2019-07-01T22:26:41.030" Score="0" ViewCount="246" Body="&lt;p&gt;I opened several files in vim and then switched git branches. I want to save the versions I have open to the new git branch, for all of them, without having to silence the &lt;code&gt;WARNING: The file has changed since reading it!!!&lt;/code&gt; for each of them individually. I am specifically interested in doing this for several files at once. Iterating over all buffers is unacceptable because that will write any file which was previously open in this vim session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Answers &lt;a href=&quot;https://vi.stackexchange.com/questions/15280/how-to-avoid-file-has-changed-warning-when-writing-buffer&quot;&gt;here&lt;/a&gt; only help for the single file case and provide no guidance on how to iterate it across many open files without collateral damage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do it?&lt;/p&gt;&#xA;" OwnerUserId="22859" LastEditorUserId="22859" LastEditDate="2020-01-27T21:09:47.033" LastActivityDate="2020-01-30T13:47:52.413" Title="Write several files all of which have been changed since read" Tags="|save|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="20477" PostTypeId="1" CreationDate="2019-07-01T22:53:26.833" Score="2" ViewCount="52" Body="&lt;p&gt;&lt;code&gt;head&lt;/code&gt; is a common Unix/Linux executable, but it's not listed in the shell syntax highlighting configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In contrast, many common executables are. Specifically, its counterpart, &lt;code&gt;tail&lt;/code&gt;, &lt;em&gt;is&lt;/em&gt; listed. As are some not uncommon, but not fundamental executables like &lt;code&gt;less&lt;/code&gt; and &lt;code&gt;rpm&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also interesting that the lists differ between the &lt;code&gt;syn keyword&lt;/code&gt; &lt;code&gt;bashStatement&lt;/code&gt;, &lt;code&gt;kshStatement&lt;/code&gt; and &lt;code&gt;shStatement&lt;/code&gt; sections in the &lt;code&gt;Misc&lt;/code&gt; &quot;fold&quot; for executables even when they are independent from the shell. For example, &lt;code&gt;cat&lt;/code&gt; is only listed in the ksh section.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the reason &lt;code&gt;head&lt;/code&gt; is omitted? Why are there these other discrepancies?&lt;/p&gt;&#xA;" OwnerUserId="1866" LastActivityDate="2019-07-01T22:53:26.833" Title="head isn't included in syntax/sh.vim" Tags="|syntax-highlighting|bash|shell|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20478" PostTypeId="1" CreationDate="2019-07-01T23:35:02.000" Score="1" ViewCount="46" Body="&lt;p&gt;I'm working on a code generator tool. I'm planing to use # LINE &quot;filename&quot; directives like the ones generated by the C preprocessor to show the relationship between the generated code and the original source. It would be nice to navigate the generated code and see side-to-side the original source file while moving through it. Is anyone aware if such a tool exists, or can VIM customized to do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;main.c&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;main.h&quot;&#xA;&#xA;main () {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;main.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;int a=1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;$ gcc main.c -E&lt;/p&gt;&#xA;&#xA;&lt;p&gt;would output the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# 1 &quot;main.c&quot;&#xA;# 1 &quot;&amp;lt;built-in&amp;gt;&quot;&#xA;# 1 &quot;&amp;lt;command-line&amp;gt;&quot;&#xA;# 31 &quot;&amp;lt;command-line&amp;gt;&quot;&#xA;# 1 &quot;/usr/include/stdc-predef.h&quot; 1 3 4&#xA;# 32 &quot;&amp;lt;command-line&amp;gt;&quot; 2&#xA;# 1 &quot;main.c&quot;&#xA;&#xA;# 1 &quot;main.h&quot; 1&#xA;&#xA;int a=1;&#xA;# 3 &quot;main.c&quot; 2&#xA;&#xA;main () {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Observe the # line &quot;file&quot; directives&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is about correlating the 2 views as we navigate in one of them. In a way the error window (:copen) does something like this. The idea is that as I move over the generated file view, I can see automatically the corresponding high level relevant source line on the first view. My generator is not a C-style preprocessor but I intend to use a similar directive to correlate source and generated code. The generated and source views are very distinct, so having a visual way to correlate can be very helpful. &lt;/p&gt;&#xA;" OwnerUserId="22860" LastEditorUserId="1841" LastEditDate="2019-07-02T07:19:08.410" LastActivityDate="2019-07-02T07:19:08.410" Title="Is there a simple way to navigate a generated file that includes # line preprocessor directives?" Tags="|multiple-files|navigation|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20479" PostTypeId="2" ParentId="20475" CreationDate="2019-07-02T04:28:48.923" Score="1" Body="&lt;p&gt;The command &lt;code&gt;:suspend&lt;/code&gt; (same as &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;Z&lt;/kbd&gt;, for obvious reasons) will suspend vim and return you to your shell. If used just after a &lt;code&gt;:!&lt;/code&gt; command, you can usually see the output. If your terminal has scrollback (via the emulator or tmux, for example), that may be useful. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, as far as I know, shell commands that produce output should result in a « Hit ENTER to continue » prompt, unless &lt;code&gt;'shortmess'&lt;/code&gt; contains certain flags or the command was prefixed with &lt;code&gt;:silent&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another somewhat common cause of missing output is a double &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; at the end of mappings that is meant to avoid the prompt. Removing it can get back the output.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-02T19:05:55.827" LastActivityDate="2019-07-02T19:05:55.827" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20480" PostTypeId="2" ParentId="20474" CreationDate="2019-07-02T06:34:48.240" Score="3" Body="&lt;p&gt;I think what you are looking for is the variable &lt;code&gt;g:tex_flavor&lt;/code&gt;. Put this in your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tex_flavor = 'context'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information, see &lt;code&gt;:help g:tex_flavor&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21" LastActivityDate="2019-07-02T06:34:48.240" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20481" PostTypeId="2" ParentId="7126" CreationDate="2019-07-02T08:37:21.033" Score="3" Body="&lt;p&gt;Since compiling a .tex file make take a few seconds, I prefer to do it in the background. There are two ways I've done this in the past: by running an asynchronous command using &lt;code&gt;job_start()&lt;/code&gt;, and by using &lt;a href=&quot;https://github.com/tmux/tmux/wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;tmux&lt;/a&gt; to send the compilation command to another terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. using &lt;code&gt;job_start()&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following to your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! RedrawScreen(channel)&#xA;    redraw!&#xA;endfunction&#xA;&#xA;function! RunLatexmk()&#xA;    let tex_file = expand('%:p')    &quot; current file&#xA;    let tex_cmd = 'latexmk -pdf -interaction=nonstopmode -cd ' . tex_file&#xA;    let s:job = job_start(['/bin/sh', '-c', tex_cmd],&#xA;        \ {'close_cb': 'RedrawScreen'})&#xA;endfunction&#xA;&#xA;autocmd BufWrite *.tex :call RunLatexmk()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have defined the &lt;code&gt;RedrawScreen()&lt;/code&gt; callback function because my screen often gets messed up when the &lt;code&gt;job_start()&lt;/code&gt; job completes. Note that this uses &lt;code&gt;latexmk -pdf&lt;/code&gt; which calls &lt;code&gt;pdflatex&lt;/code&gt;. If instead you want to use &lt;code&gt;pdflatex&lt;/code&gt; directly, you will have to first &lt;code&gt;cd&lt;/code&gt; into the directory of the .tex file before you can call &lt;code&gt;pdflatex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. using tmux to send the &lt;code&gt;latexmk&lt;/code&gt; command to another terminal&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the following to your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TmuxSend()&#xA;    let tex_file = expand('%:p')    &quot; current file&#xA;    let tex_cmd = 'latexmk -pdf -interaction=nonstopmode -cd ' . tex_file&#xA;    let tmux_cmd = 'tmux send-keys -t vim_output.0 &quot;' . tex_cmd . '&quot; ENTER'&#xA;    let output = system(tmux_cmd)   &#xA;endfunction&#xA;&#xA;autocmd BufWrite *.tex :call TmuxSend()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, open another terminal and create a tmux session named &quot;vim_output&quot;: &lt;code&gt;tmux new-session -s vim_output&lt;/code&gt;. Now, when you save your file in Vim, the &lt;code&gt;latexmk&lt;/code&gt; command will be run in the terminal you just created.&lt;/p&gt;&#xA;" OwnerUserId="16602" LastEditorUserId="16602" LastEditDate="2020-02-21T17:49:43.467" LastActivityDate="2020-02-21T17:49:43.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20482" PostTypeId="2" ParentId="20468" CreationDate="2019-07-02T10:55:53.417" Score="1" Body="&lt;p&gt;There are two &lt;code&gt;&amp;lt;para&amp;gt;&lt;/code&gt; because you apply &lt;code&gt;v:count1&lt;/code&gt; to every tag you render. Try this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function s:DocbkPrintTag(tag)&#xA;&#xA;  &amp;quot; apply v:count1 to the outside tag&#xA;  put =repeat(s:DocbkRenderTag(a:tag), v:count1)&#xA;endfunction&#xA;&#xA;function s:DocbkRenderTag(tag)&#xA;  ...&#xA;&#xA;  &amp;quot; render single tag here&#xA;  if !empty(include)&#xA;    for incl_tag in include&#xA;      let incl_result .= s:DocbkRenderTag(incl_tag)&#xA;    endfor&#xA;  endif&#xA;  ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;IMO, raw &lt;code&gt;command&lt;/code&gt; with &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Acommand-completion-customlist&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :command-completion-customlist&lt;/a&gt; is way better than &lt;code&gt;map&lt;/code&gt; here. &lt;code&gt;v:count1&lt;/code&gt; can be replaced with &lt;a href=&quot;https://vimhelp.org/eval.txt.html#optional-function-argument&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h optional-function-argument&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-07-02T11:03:30.170" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20483" PostTypeId="2" ParentId="20429" CreationDate="2019-07-02T12:06:46.073" Score="1" Body="&lt;p&gt;As suggested &lt;code&gt;@PhilRunninger&lt;/code&gt; in Github &lt;a href=&quot;https://github.com/scrooloose/nerdtree/issues/1010#issuecomment-507104724&quot; rel=&quot;nofollow noreferrer&quot;&gt;ticket&lt;/a&gt;, I can use &lt;code&gt;BufRead&lt;/code&gt; autocommand and apply templates if file size is zero:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead *.java if getfsize(expand('%'))==0|$r ~/.vim/templates/skeleton.java|call s:SetupJavaClass()|endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it's working fine.&lt;/p&gt;&#xA;" OwnerUserId="9140" LastActivityDate="2019-07-02T12:06:46.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20484" PostTypeId="1" AcceptedAnswerId="20485" CreationDate="2019-07-02T14:18:51.420" Score="0" ViewCount="151" Body="&lt;p&gt;in my plugin, i am joining XML tags together depending on a mapping a use. It also uses  so i can make XML snippets repetitive.&#xA;After inserting the text into a buffer, i would like the cursor to return to the initial position from which I started the 'pasting', but somehow i cannot leave the insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:DocbkPrintTag(tag)&#xA;  &quot;mark the initial position&#xA;  execute &quot;normal! mq&quot;&#xA;  let result = repeat(s:DocbkRenderTag(a:tag), v:count1)&#xA;  if !empty(result)&#xA;    call feedkeys('a' . result, 'n')&#xA;  endif&#xA;  &quot;stop insert mode and resore the cursor position&#xA;  execute &quot;normal! `q&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22283" LastActivityDate="2019-07-02T23:47:34.683" Title="Return cursor to an initial position after pasting text from a function" Tags="|vimscript|normal-mode|filetype-xml|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20485" PostTypeId="2" ParentId="20484" CreationDate="2019-07-02T15:37:47.957" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;Instead of marking in normal mode, you can use &lt;code&gt;:mark q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Instead of entering insert mode to paste your data, try using either &lt;code&gt;put =result&lt;/code&gt; (results on a new line), save the result into a register (&lt;code&gt;let @a=result&lt;/code&gt;) and paste inline (&lt;code&gt;normal! &quot;ap&lt;/code&gt;), or match a part of the line to insert (e.g., at the beginning: &lt;code&gt;substitute/^/\=result&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;You only need &lt;code&gt;:execute&lt;/code&gt; with &lt;code&gt;:normal&lt;/code&gt; if the command contains special characters or is computed. So the last line can be &lt;code&gt;normal! `q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;All of that said, it is easiest to use &lt;code&gt;getcurpos&lt;/code&gt; and &lt;code&gt;setpos&lt;/code&gt; (example at &lt;code&gt;:help getcurpos()&lt;/code&gt;) for cursor saving and restoration.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-02T15:37:47.957" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20486" PostTypeId="1" AcceptedAnswerId="20487" CreationDate="2019-07-02T16:11:33.223" Score="1" ViewCount="1153" Body="&lt;p&gt;I have a couple of things which suggest there's an issue with the way I use &lt;code&gt;colorscheme&lt;/code&gt; with my &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Errors when running &lt;code&gt;source ~/.vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The colorscheme used when opening a vim session&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Sourcing vimrc&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I update my &lt;code&gt;vimrc&lt;/code&gt; file and &lt;code&gt;source&lt;/code&gt; it to see the changes in my current session I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /usr/share/vim/vim80/syntax/synload.vim:&#xA;line   19:&#xA;E185: Cannot find color scheme 'vim-monokai-tasty'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Despite the complaint the colour scheme does seem to update to be &lt;code&gt;monokai-tasty&lt;/code&gt;.&#xA;The colour scheme is at &lt;code&gt;~/.vim/colors/monokai-tasty.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Vim Sessions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I start a vim session with &lt;code&gt;vim -S /path/to/session.vim&lt;/code&gt; some colour scheme, other than &lt;code&gt;monokai-tasty&lt;/code&gt; is used.&#xA;This would be a time where I may use &lt;code&gt;:source ~/.vimrc&lt;/code&gt; and get the above errors, but also the correct colour scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Saving the vim session after making changes to the colour scheme seems to have no effect upon starting a new session.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated.&#xA;Here is where you can find my &lt;a href=&quot;https://github.com/BrokenFlows/dotfiles/tree/96e197530eb2f078f7e4c89f1b563be4bdae1ca7/vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim&lt;/a&gt; and &lt;a href=&quot;https://github.com/BrokenFlows/dotfiles/tree/96e197530eb2f078f7e4c89f1b563be4bdae1ca7/vim/colors&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim/colors&lt;/a&gt; directories&lt;/p&gt;&#xA;" OwnerUserId="22858" LastActivityDate="2019-07-02T16:21:13.197" Title="Colorscheme Errors (E185) with vimrc and sessions" Tags="|vimrc|colorscheme|sessions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20487" PostTypeId="2" ParentId="20486" CreationDate="2019-07-02T16:21:13.197" Score="1" Body="&lt;p&gt;The colorscheme in question, &quot;monokai-tasty.vim&quot; does not properly set &lt;code&gt;g:colors_name&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:colors_name = &quot;vim-monokai-tasty&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:colors_name&lt;/code&gt; should be set to the file name of the colorscheme without the &lt;code&gt;.vim&lt;/code&gt;.  Correct:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:colors_name = &quot;monokai-tasty&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the two differ, setting colorscheme initially appears to work.  However there are instances where vim reloads the colorscheme, and it uses &lt;code&gt;g:colors_name&lt;/code&gt; to do that.  At that point the error will be generated.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-07-02T16:21:13.197" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20488" PostTypeId="2" ParentId="20476" CreationDate="2019-07-02T23:00:20.693" Score="4" Body="&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It is completely possible to build on the linked duplicate for a specific list of files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We first extract the old code into a function that will operate on a given filename:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ReallyWrite(f) abort&#xA;  execute 'buffer' f&#xA;  let lastline = line('$')&#xA;  let bufcontents = getline(1, lastline)&#xA;  edit!&#xA;  call setline(1, bufcontents)&#xA;  if line('$') &amp;gt; lastline&#xA;    execute lastline+1.',$:d _'&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then we write a command to do it for all the files we want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=+ -complete=file ReallyWrite for f in [&amp;lt;f-args&amp;gt;] | call ReallyWrite(f) | endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usage: &lt;code&gt;:ReallyWrite file1 file2&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With some simple modifications, &lt;code&gt;ReallyWrite&lt;/code&gt; could return to the old buffer after it is finished working. (I think you'd just have to do &lt;code&gt;buffer #&lt;/code&gt; at the end of the function.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This answer is a two-parter:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&quot;Tricking&quot; vim into not caring about the fact that files have changed&lt;/li&gt;&#xA;&lt;li&gt;Using git properly to avoid this in the first place&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;Vim&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Reading &lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Awall&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :wall&lt;/code&gt;&lt;/a&gt; tells us that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vim will warn you if you try to overwrite a file that has been changed&#xA;elsewhere.  See |timestamp|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help timestamp&lt;/code&gt; gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If you do not want to be asked or automatically reload the file, you can use&#xA;this: &#xA;        set buftype=nofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, the problem with &lt;code&gt;buftype=nofile&lt;/code&gt; is that the file &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;will not be written (&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27buftype%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'buftype'&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, the linked QA provides one answer (save and restore). My solution would be to set all buffers to &lt;code&gt;nofile&lt;/code&gt; and then use &lt;code&gt;:w filename&lt;/code&gt; (which should still work, according to the docs):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;argdo set buftype=nofile | execute 'write' bufname('%')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;except&lt;/em&gt; that, for some reason, the docs don't seem to be correct: the above command errors for each argument, even though &lt;code&gt;:write filename&lt;/code&gt; is supposed to work. &lt;code&gt;:write othername&lt;/code&gt; works, but you cannot write to the buffer name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I would use the linked answer.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Git&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how on-topic this part is, but it's an answer to the question, if a bit of a frame challenge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want to get (some of) the files in one branch (&lt;code&gt;to_update&lt;/code&gt;) to have identical contents to the corresponding files on another branch (&lt;code&gt;stable&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Checkout the &lt;code&gt;to_update&lt;/code&gt; branch&lt;/li&gt;&#xA;&lt;li&gt;Choose a strategy:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Merge the branches: &lt;code&gt;git merge stable&lt;/code&gt;. You don't have control over which files change, and they won't be identical post-merge, but you do get the contents from the &lt;code&gt;stable&lt;/code&gt; branch (integrated with &lt;code&gt;to_update&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Checkout the files on another branch: &lt;code&gt;git checkout stable [files...]&lt;/code&gt;. This makes &lt;code&gt;files&lt;/code&gt; exactly as they are in &lt;code&gt;stable&lt;/code&gt;, and lets you pick which files. No vim reloading necessary.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Caveat:&lt;/em&gt; if you have &lt;em&gt;already&lt;/em&gt; edited the files, then you switch branches, you have a different problem. You wouldn't be allowed to switch branches if there were conflicts, so the vim method should work fine. If there were conflicts, do &lt;code&gt;git stash&lt;/code&gt;, the use the second strategy for git, the &lt;code&gt;git stash apply&lt;/code&gt; (followed by &lt;code&gt;git stash drop&lt;/code&gt; if you're satisfied).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wish to edit the files that changed, you can do some parsing to get a list of changed files. I do this with my &lt;a href=&quot;https://github.com/benknoble/Dotfiles/blob/master/links/bin/git-ed&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;git-ed&lt;/code&gt; script&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-01-27T21:54:07.637" LastActivityDate="2020-01-27T21:54:07.637" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20489" PostTypeId="2" ParentId="20484" CreationDate="2019-07-02T23:47:34.683" Score="1" Body="&lt;p&gt;DBK already show you how to fix it, so i explain only why your approach doesn't work here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://vimhelp.org/eval.txt.html#feedkeys%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h feedkeys()&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The function does not wait for processing of keys contained in {string}.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To show you that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ,t :call &amp;lt;sid&amp;gt;foo()&amp;lt;cr&amp;gt;:echom 2&amp;lt;cr&amp;gt;&#xA;function! s:foo()&#xA;  echom 1&#xA;  call feedkeys(&quot;:echom 3\&amp;lt;cr&amp;gt;&quot;)&#xA;  echom 4&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Execute &lt;kbd&gt;,&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;, check message with &lt;code&gt;:mes&lt;/code&gt;, you should see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;4&#xA;2&#xA;3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;i&lt;/code&gt; mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call feedkeys(&quot;:echom 3\&amp;lt;cr&amp;gt;&quot;, 'i')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;4&#xA;3&#xA;2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-07-02T23:47:34.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20490" PostTypeId="2" ParentId="6979" CreationDate="2019-07-03T03:22:58.653" Score="0" Body="&lt;p&gt;You might need to add &lt;code&gt;&amp;lt;esc&amp;gt;a&lt;/code&gt;, especially if you are using YouCompleteMe plugin along with SnipMate. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;tab&amp;gt; &amp;lt;esc&amp;gt;a&amp;lt;Plug&amp;gt;snipMateNextOrTrigger&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also verify that tab key is working by pressing &lt;code&gt;ctrl&lt;/code&gt;+&lt;code&gt;i&lt;/code&gt;, as it is identical to &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; in Vim.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, check your &lt;code&gt;.vimrc&lt;/code&gt; if there is &lt;code&gt;set paste&lt;/code&gt;, and remove that line if it exists or replace it with &lt;code&gt;set nopaste&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21762" LastActivityDate="2019-07-03T03:22:58.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20491" PostTypeId="1" AcceptedAnswerId="20492" CreationDate="2019-07-03T06:48:48.180" Score="1" ViewCount="206" Body="&lt;p&gt;These are my scenarios and expected output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:Foo(text)&#xA;    echoerr &quot;'&quot; . a:text . &quot;'&quot;&#xA;endfunction&#xA;&#xA;command ... FooCommand ... (not sure what to write here)&#xA;&#xA;FooCommand text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'text'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FooCommand text asdfsfd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'text asdfsfd'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(it's hard to see in stackoverflow but the next one has trailing whitespace)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FooCommand line with 4 trailing spaces    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'line with 4 trailing spaces    '&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FooCommand line with&quot;quotes&quot; here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'line with&quot;quotes&quot; here'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Nothing that I've tried works. I've tried &lt;code&gt;&amp;lt;f-args&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;q-args&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;args&amp;gt;&lt;/code&gt; and I've tried manually adding &lt;code&gt;&quot;&quot;&lt;/code&gt;s around the non &lt;code&gt;q-&lt;/code&gt; versions. They all fail for some reason or another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either the function will say it didn't &lt;code&gt;get enough args&lt;/code&gt;, &lt;code&gt;Undefined variable&lt;/code&gt;, or including &lt;code&gt;&quot;&lt;/code&gt;s will cut off text at the first double-quote that's found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best combination I got was my first try - Use &lt;code&gt;&amp;lt;q-args&amp;gt;&lt;/code&gt; and then manually escape &lt;code&gt;&quot;&lt;/code&gt;s all the time. But even then, &lt;code&gt;&amp;lt;q-args&amp;gt;&lt;/code&gt; doesn't seem to allow trailing whitespace. So I can't use it for what I'm trying to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way for Vim to just let me pass everything as one big string to a function and it just escape everything properly? Including quotes. Including spaces. I just want Vim to take whatever I write and put it in a  string.&lt;/p&gt;&#xA;" OwnerUserId="16073" LastActivityDate="2019-07-03T08:11:40.953" Title="How to pass everything from a command into a function with escaped characters" Tags="|command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20492" PostTypeId="2" ParentId="20491" CreationDate="2019-07-03T08:11:40.953" Score="3" Body="&lt;p&gt;You must add &lt;code&gt;-nargs=1&lt;/code&gt; to your command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command -nargs=1 FooCommand :call Foo(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This tells Vim not to treat white space as separator. Only white space between the command name and the first non-white space character is removed from the argument passed to &lt;code&gt;Foo()&lt;/code&gt;. All other spaces and tabs, even trailing ones, are included in the argument.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastActivityDate="2019-07-03T08:11:40.953" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20493" PostTypeId="1" CreationDate="2019-07-03T08:12:17.973" Score="1" ViewCount="184" Body="&lt;p&gt;I use the following mapping for &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; getline('.')[col('.') - 2] =~ '\w' ? &quot;&amp;lt;C-N&amp;gt;&quot; : &quot;&amp;lt;Tab&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works well except that if I want to insert a tab and the previous word is not matched, &lt;code&gt;i_Ctrl-N&lt;/code&gt; returns the &lt;code&gt;Pattern not found&lt;/code&gt; error and I have to insert a space manually and then I can insert a tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is quite annoying.&#xA;I know I can use &lt;code&gt;pumvisible&lt;/code&gt; to detect if completion pop-up is visible, but how can I evaluate the return value of &lt;code&gt;i_Ctrl-N&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="1841" LastEditDate="2019-07-03T08:24:36.197" LastActivityDate="2019-07-03T08:24:36.197" Title="Prevent &quot;Pattern not found&quot; error in autocompletition (i_Ctrl-N)" Tags="|key-bindings|autocompletion|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20494" PostTypeId="1" CreationDate="2019-07-03T12:57:04.633" Score="4" ViewCount="3566" Body="&lt;p&gt;By default, the version of vim on centos7 is 7.4. I want to update it to vim 8. There are some questions with '&lt;a href=&quot;https://copr.fedorainfracloud.org/coprs/mcepl/vim8/repo/epel-7/mcepl-vim8-epel-7.repo&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://copr.fedorainfracloud.org/coprs/mcepl/vim8/repo/epel-7/mcepl-vim8-epel-7.repo&lt;/a&gt; -o /etc/yum.repos.d/mcepl-vim8-epel-7.repo'. So, how can I to update it?&lt;/p&gt;&#xA;" OwnerUserId="22872" LastEditorUserId="51" LastEditDate="2019-08-06T22:20:44.897" LastActivityDate="2019-10-28T17:22:57.710" Title="How to update vim on centos7?" Tags="|linux|installing|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20495" PostTypeId="1" CreationDate="2019-07-03T13:36:11.913" Score="1" ViewCount="421" Body="&lt;p&gt;I really like the &lt;code&gt;vimdiff&lt;/code&gt; / &lt;code&gt;vim -d&lt;/code&gt; , it's awesome.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I need to see the vimdiff result without enter in the interactive mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Show the result colored , scrolling all differences and exit. Behave like a &lt;code&gt;diff -y&lt;/code&gt;, side-by-side, but with the benefits of the colored and diff configuration from vim.&lt;/p&gt;&#xA;" OwnerUserId="18285" LastEditorUserId="18285" LastEditDate="2019-07-03T18:37:09.787" LastActivityDate="2020-03-30T03:23:43.143" Title="How to run Vim Diff without enter in interctive mode?" Tags="|vimdiff|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20496" PostTypeId="2" ParentId="485" CreationDate="2019-07-03T14:14:18.610" Score="13" Body="&lt;p&gt;If you have a sufficiently modern vim that has the +terminal feature, you can do &lt;code&gt;:term cat somefile&lt;/code&gt; and you'll get a buffer with all the terminal codes interpreted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This might work better on large files than e.g. Colorizer, which made my vim unusably slow when I let it loose on a 6000-line file.&lt;/p&gt;&#xA;" OwnerUserId="21553" LastActivityDate="2019-07-03T14:14:18.610" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20497" PostTypeId="1" CreationDate="2019-07-03T14:18:22.243" Score="1" ViewCount="1086" Body="&lt;p&gt;When prettier tells me to take one line with a whole object and put every property on a new line, I want a key to autofix that. I know prettier has things that can be auto-fixed, but I have no idea how to trigger it with ALE (or prettier).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(note: I'm programming in JS. An object would be something like &lt;code&gt;{ prop1: 1, prop2: 2 }&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="20308" LastActivityDate="2019-07-03T14:18:22.243" Title="Autofix a single line in ALE" Tags="|formatting|plugin-ale|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20498" PostTypeId="1" CreationDate="2019-07-03T15:40:20.243" Score="0" ViewCount="46" Body="&lt;p&gt;I'm attempted to duplicate &lt;a href=&quot;https://andrew.stwrt.ca/posts/project-specific-vimrc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this functionality&lt;/a&gt; in a windows environment running gvim 8.1 but it doesn't appear to pick up my changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've updated my &lt;code&gt;$VIMRC\_vimrc&lt;/code&gt; with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set exrc&#xA;set secure&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and my local _vimrc contains&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fileencoding=latin1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I try to load a file with the project-local _vimrc file it doesn't work because when I check &lt;code&gt;:set fileencoding&lt;/code&gt; it's set to &lt;code&gt;fileencoding=&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="1292" LastEditDate="2019-07-10T06:42:24.637" LastActivityDate="2019-07-10T06:42:24.637" Title="Run project specific _vimrc in windows?" Tags="|vimrc|gvim|microsoft-windows|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20499" PostTypeId="2" ParentId="3868" CreationDate="2019-07-03T16:03:58.647" Score="1" Body="&lt;p&gt;Since no one has really answered this question, here's my recommendation for installing the latest Vim on Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.vim.org/download.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;Official Vim website - download page&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;My recommendation for getting Windows Vim. &lt;/li&gt;&#xA;&lt;li&gt;You can download the latest stable Vim installer &lt;code&gt;gvim##.exe&lt;/code&gt; (ie &lt;code&gt;gvim81.exe&lt;/code&gt;).  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/vim/vim-win32-installer/releases&quot; rel=&quot;nofollow noreferrer&quot;&gt;Latest/ Nightly builds&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Download page for latest nightly build installer &lt;/li&gt;&#xA;&lt;li&gt;Not recommended because build may not be stable, unless you need the absolute latest build. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://tuxproject.de/projects/vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tuxproject.de Windows Vim build&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Another Windows Vim build.  &lt;/li&gt;&#xA;&lt;li&gt;However, some DLLs are not included, but they can be downloaded from the official Vim website download page (see above), called &lt;code&gt;vim##rt.zip&lt;/code&gt; (ie &lt;code&gt;vim81rt.zip&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you are using Chocolatey package manager, I recommend &lt;code&gt;vim-tux&lt;/code&gt; which is sourced from tuxproject.de:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;choco install vim-tux -y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The other chocolatey package, &lt;code&gt;vim&lt;/code&gt; has not been updated, and it seems that package maintenance has stalled.  Otherwise, you can install the older version using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;choco install vim -y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21762" LastEditorUserId="21762" LastEditDate="2019-07-03T16:13:12.357" LastActivityDate="2019-07-03T16:13:12.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20500" PostTypeId="1" CreationDate="2019-07-03T17:01:23.013" Score="0" ViewCount="215" Body="&lt;h3&gt;Background&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I'm using UltiSnips in conjunction with some autocomplete plugins. I have this line controlling the behavior of enter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt;&#xA;            \ !empty(UltiSnips#SnippetsInCurrentScope()) ? &#xA;            \ &quot;\&amp;lt;C-R&amp;gt;=UltiSnips#ExpandSnippet()\&amp;lt;cr&amp;gt;&quot; :&#xA;            \ pumvisible() ? &quot;\&amp;lt;c-y&amp;gt;&quot; : &quot;\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to check for snippets (and expand if necessary) then check for autocomplete suggestions (and select that if it is available) and if nothing is going on, use enter.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The Problem&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;When I press enter on a blank line I don't get a new line. I figured out that what's happening is &lt;code&gt;UltiSnips#SnippetsInCurrentScope()&lt;/code&gt; returns a bunch of my snippets when I'm at the beginning of a blank line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea of using &lt;code&gt;UltiSnips#SnippetsInCurrentScope()&lt;/code&gt; is from the UltiSnips docs (part 6, the FAQ) as a stand in for an &quot;IsExpandable&quot; function.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Question&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Is there another function that captures the spirit of what I want better? If not what is the best way to achieve what I want (just a case that checks if the lines empty?)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="21686" LastActivityDate="2019-12-01T03:04:15.557" Title="Ultisnips Sinppets in current scope on blank line" Tags="|vimrc|vimscript|plugin-ultisnips|snippets|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20501" PostTypeId="2" ParentId="20494" CreationDate="2019-07-03T17:04:13.623" Score="1" Body="&lt;p&gt;That repo is no longer available. Instead, use this (source: &lt;a href=&quot;https://gist.github.com/yevrah/21cdccc1dc65efd2a4712781815159fb&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gist.github.com/yevrah/21cdccc1dc65efd2a4712781815159fb&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm&#xA;rpm --import http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7&#xA;&#xA;yum -y remove vim-minimal vim-common vim-enhanced&#xA;yum -y --enablerepo=gf-plus install vim-enhanced sudo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21762" LastActivityDate="2019-07-03T17:04:13.623" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20502" PostTypeId="2" ParentId="8741" CreationDate="2019-07-03T17:55:10.080" Score="4" Body="&lt;p&gt;It might sound stupid or naive, but what I do when I want to stop the highlighting is I search for a random string that (virtually certainly) is not present in the document. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/skljdfhadhfs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Granted, it does take a few key strokes, but they are really random, so they can be typed in no time.&lt;/p&gt;&#xA;" OwnerUserId="22878" LastActivityDate="2019-07-03T17:55:10.080" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20503" PostTypeId="2" ParentId="20495" CreationDate="2019-07-03T18:05:46.887" Score="0" Body="&lt;p&gt;If you don't mind having the differences above each other as opposed to side-by-side, you can try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git diff --no-index FILE1 FILE2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22878" LastActivityDate="2019-07-03T18:05:46.887" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20504" PostTypeId="2" ParentId="20200" CreationDate="2019-07-03T18:29:48.320" Score="1" Body="&lt;p&gt;Go to the first letter of the word, and press&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that selects the word. You may use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;5w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to select e.g. 5 words. Then you do whatever you want, e.g. to copy to clipboard you do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; * y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22878" LastActivityDate="2019-07-03T18:29:48.320" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20505" PostTypeId="1" AcceptedAnswerId="20506" CreationDate="2019-07-03T18:57:31.867" Score="3" ViewCount="316" Body="&lt;p&gt;I use git to share my vimrc across multiple machines. &#xA;But now I have some commands which I only want on one machine. Namely, this&#xA;line:&#xA;&lt;code&gt;au! redhat BufReadPost&lt;/code&gt;&#xA;(derived from this very helpful answer!&#xA;&lt;a href=&quot;https://unix.stackexchange.com/questions/59486/disable-vi-from-going-to-the-last-visited-line-upon-file-opening&quot;&gt;https://unix.stackexchange.com/questions/59486/disable-vi-from-going-to-the-last-visited-line-upon-file-opening&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to load this line only for my linux machine? Or maybe put into a&#xA;second vimrc file which only exists/loads on linux? Or maybe another solution, so that I can keep using version control for the rest of my files but let this one command apply just for this one machine?&lt;/p&gt;&#xA;" OwnerUserId="18504" LastActivityDate="2020-05-17T17:52:10.997" Title="shared vimrc on two machines; only run command for one of them" Tags="|vimrc|git|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20506" PostTypeId="2" ParentId="20505" CreationDate="2019-07-03T19:21:48.617" Score="5" Body="&lt;p&gt;You can surround the config/code in question with a conditional based on an &lt;a href=&quot;https://vimhelp.org/eval.txt.html#expr-env&quot; rel=&quot;nofollow noreferrer&quot;&gt;environment variable&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using Bash environments a good candidate is envvar &lt;code&gt;HOSTNAME&lt;/code&gt; which will probably be unique (in a personal context, at least). In other environments there is usually a way to get this same information (e.g.  output of the *nix command &lt;code&gt;hostname&lt;/code&gt; or envvar &lt;code&gt;COMPUTERNAME&lt;/code&gt; on Windows). If you have a heterogeneous mix of machines then the best approach is probably to use the Vim function &lt;code&gt;hostname()&lt;/code&gt; which provides a platform agnostic means of getting the information.&lt;sup&gt;1&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For simplicity, we'll pretend we're all in on Bash. :) For the example you mentioned we'd just need to add something like...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if $HOSTNAME == &quot;foo&quot;&#xA;     au! redhat BufReadPost ...&#xA; endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, we can also extend this to multiple hosts and/or have default settings...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if $HOSTNAME == &quot;foo&quot;&#xA;     &quot; this config&#xA; elseif $HOSTNAME == &quot;bar&quot;&#xA;     &quot; that config&#xA; else&#xA;     &quot; default config&#xA; endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before you set it up check availability with &lt;code&gt;:echo $HOSTNAME&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to look for alternatives you could run &lt;code&gt;:!printenv&lt;/code&gt; or &lt;code&gt;:!env&lt;/code&gt; or whatever your system's equivalent command is. In the unlikely event that you can't find an existing envvar that will work then make something up! Choose a variable name not currently in use and on the machine(s) you want to isolate put (assuming Bash, again) &lt;code&gt;export MYSPECIALVAR=uniquevalue&lt;/code&gt; in your &lt;em&gt;.profile&lt;/em&gt;, &lt;em&gt;.bash_profile&lt;/em&gt;, &lt;em&gt;.bashrc&lt;/em&gt; or whatever makes the most sense for your environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;sub&gt;Thanks to @Achilleas for spurring me to expand/improve this section.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-05-17T17:52:10.997" LastActivityDate="2020-05-17T17:52:10.997" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20507" PostTypeId="1" AcceptedAnswerId="20509" CreationDate="2019-07-03T21:02:04.947" Score="1" ViewCount="328" Body="&lt;p&gt;I'm editing a small bash script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;d=$1&#xA;  year=$(date -d&quot;$d&quot; +%Y)&#xA;  month=$(date -d &quot;$d&quot; +%m)&#xA;  day=$(date -d &quot;$d&quot; +%d)&#xA;  hive -f /home/gavin_cameron/hive_queries/dc_player_daily_snapshot.hive -d jobYear=&quot;$year&quot; -d jobMonth=&quot;$month&quot; -d jobDay=&quot;$day&quot; &amp;gt; logs/debug_$d.log 2&amp;gt;&amp;amp;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to delete the 2 spaces for each line for year, month, day and hive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I place my cursor underneath the &lt;code&gt;d&lt;/code&gt; in &lt;code&gt;d=$1&lt;/code&gt; and then press &lt;kbd&gt;v&lt;/kbd&gt; and then press &lt;kbd&gt;right&lt;/kbd&gt; once to cover the white space on the first line and then &lt;kbd&gt;down&lt;/kbd&gt; to highlight all the white spaces, the entire lines are highlighted whereas I was expecting just the white space to be highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is that and how can I delete the indentation using visual mode plus delete in a oner rather than line by line deletion?&lt;/p&gt;&#xA;" OwnerUserId="21478" LastEditorUserId="1841" LastEditDate="2019-07-04T07:27:54.910" LastActivityDate="2019-07-04T07:27:54.910" Title="Entering visual mode is selecting whole lines unexpectedly" Tags="|visual-mode|visual-block|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20508" PostTypeId="1" AcceptedAnswerId="20510" CreationDate="2019-07-03T23:25:21.463" Score="2" ViewCount="470" Body="&lt;p&gt;pyflakes (with ALE) automatically defaults to python2 instead of python3 and gives me false errors and there are no variables in ALE documentation letting me change python versions. Thanks for any help in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S I just switched to MyPy linter, it defaults to python3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S (2) Got it! Add &lt;code&gt;let g:ale_python_pyflakes_executable = 'pyflakes3'&lt;/code&gt; to your .vimrc&lt;/p&gt;&#xA;" OwnerUserId="22880" LastEditorUserId="22880" LastEditDate="2019-07-04T00:37:57.903" LastActivityDate="2019-07-04T00:40:19.727" Title="Switch pyflakes linter from python2 to python3 in ALE" Tags="|plugin-ale|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20509" PostTypeId="2" ParentId="20507" CreationDate="2019-07-04T00:08:03.937" Score="2" Body="&lt;p&gt;While you can use visual block mode via Ctrl-V, I would suggest a re-indenting tool (since that’s your goal).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meet &lt;code&gt;=&lt;/code&gt;. It’s an operator. It takes motions and text objects. And it indents things. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would do &lt;code&gt;=ip&lt;/code&gt; from anywhere in your block of code. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-04T00:08:03.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20510" PostTypeId="2" ParentId="20508" CreationDate="2019-07-04T00:40:19.727" Score="1" Body="&lt;p&gt;Add let &lt;code&gt;g:ale_python_pyflakes_executable = 'pyflakes3'&lt;/code&gt; to your .vimrc and be at peace&lt;/p&gt;&#xA;" OwnerUserId="22880" LastActivityDate="2019-07-04T00:40:19.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20511" PostTypeId="2" ParentId="20500" CreationDate="2019-07-04T02:32:29.427" Score="1" Body="&lt;p&gt;&lt;code&gt;UltiSnips#SnippetsInCurrentScope&lt;/code&gt; return all snippets whose trigger &lt;code&gt;matches&lt;/code&gt; the current word, I think the &lt;code&gt;match&lt;/code&gt; here means &lt;code&gt;=~&lt;/code&gt;, not &lt;code&gt;==&lt;/code&gt;. You need to check word before cursor and the triggers by yourself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:is_ultisnips_expandable()&#xA;&#xA;  &quot; get word before cursor&#xA;  let word = matchstr(getline('.'), printf('\v\w*%%%dc\w', col('.') - 1))&#xA;  if(empty(word))&#xA;    return 0&#xA;  endif&#xA;&#xA;  &quot; test word against triggers&#xA;  return !empty(filter(UltiSnips#SnippetsInCurrentScope(), {k,v -&amp;gt; k ==# word}))&#xA;&#xA;endfunction&#xA;&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt;&#xA;            \ &amp;lt;sid&amp;gt;is_ultisnips_expandable() ?&#xA;            \ &quot;&amp;lt;C-R&amp;gt;=UltiSnips#ExpandSnippet()&amp;lt;cr&amp;gt;&quot; :&#xA;            \ pumvisible() ? &quot;&amp;lt;c-y&amp;gt;&quot; : &quot;&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I change your &lt;code&gt;\&amp;lt;xxxx&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;xxxx&amp;gt;&lt;/code&gt;, one should not use &lt;code&gt;\&amp;lt;xxxx&amp;gt;&lt;/code&gt; in &lt;code&gt;map&lt;/code&gt; command, check &lt;a href=&quot;https://vi.stackexchange.com/questions/20344/whats-the-functional-difference-between-the-key-notations-xxx-and-xxx&quot;&gt;here&lt;/a&gt; for detail.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-07-04T02:32:29.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20512" PostTypeId="1" CreationDate="2019-07-04T09:21:25.817" Score="3" ViewCount="474" Body="&lt;p&gt;The system is Centos7.2. I have installed vim-enhanced and vim-X11, used &lt;code&gt;vimx&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It shows that vimx supports &lt;code&gt;clipboard&lt;/code&gt; and &lt;code&gt;xterm_clipboard&lt;/code&gt;. But in vimx, there is no &lt;code&gt;reg +&lt;/code&gt; and &lt;code&gt;reg *&lt;/code&gt;. I can't copy text to system clipboard using command &lt;code&gt;&quot;+yy&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/g0CeX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/g0CeX.png&quot; alt=&quot;supporting clipboard and xterm_clipboard&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/qbiAk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qbiAk.png&quot; alt=&quot;there is no register + and *&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22884" LastEditorUserId="19763" LastEditDate="2019-07-06T09:51:33.483" LastActivityDate="2020-07-06T16:02:00.453" Title="unable to copy to system clipboard with +clipboard and +xterm_clipboard in vimx" Tags="|register|os-clipboard|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20513" PostTypeId="1" AcceptedAnswerId="20517" CreationDate="2019-07-04T09:57:22.263" Score="0" ViewCount="1049" Body="&lt;p&gt;I need to search for a string in a file, then I need to some text after one line following the first match. I need to perform this for a number of files in a script.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to use vim ex mode for this. I know &lt;code&gt;:/search_string&lt;/code&gt; can perform a search but I am not able to figure out how to move the cursor down and insert the line.&#xA;Will sed or awk be more suitable for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to do this in a script. &lt;/p&gt;&#xA;" OwnerUserId="4513" LastEditorUserId="4513" LastEditDate="2019-07-04T14:59:28.037" LastActivityDate="2022-08-25T07:57:26.213" Title="Add a line after 1 line after match in Ex mode" Tags="|search|ex-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20514" PostTypeId="1" AcceptedAnswerId="20518" CreationDate="2019-07-04T10:28:12.867" Score="1" ViewCount="53" Body="&lt;p&gt;If I do a grep search within vim, I'll get a list of results that I can browse using &lt;code&gt;:lopen&lt;/code&gt;. Is there a way to do a subsequent search on only these resulting files? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I want to do refined searches as might be done with a pipe on the terminal. &lt;/p&gt;&#xA;" OwnerUserId="20443" LastActivityDate="2019-07-04T13:40:48.933" Title="Is it possible to do consecutive vimgrep searches to refine and filter results?" Tags="|vimgrep|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20515" PostTypeId="1" AcceptedAnswerId="20521" CreationDate="2019-07-04T12:15:04.927" Score="3" ViewCount="187" Body="&lt;p&gt;How to add abbrevs made of more than one word?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been trying:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev a aquilo àquilo&#xA;iabbrev a aquele àquele&#xA;iabbrev a aquela àquela&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I want to do is have the two words &quot;a aquilo&quot; expand to &quot;àquilo&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it won't work. Also, I see in the docs for &lt;code&gt;abbrev&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Examples of strings that cannot be abbreviations: &quot;a.b&quot;, &quot;#def&quot;, &quot;a b&quot;, &quot;_$r&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I'm assuming that it can't be done officially, I wonder if is there a work around?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;" OwnerUserId="14568" LastEditorUserId="18609" LastEditDate="2019-07-05T08:13:42.763" LastActivityDate="2019-07-05T08:13:42.763" Title="abbrev for multiwords" Tags="|abbreviations|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20516" PostTypeId="1" AcceptedAnswerId="20520" CreationDate="2019-07-04T12:59:54.550" Score="3" ViewCount="985" Body="&lt;p&gt;I know about &lt;code&gt;:yN&lt;/code&gt; for example , &lt;code&gt;:y10&lt;/code&gt; , yank 10 lines from current line.&#xA;&lt;br /&gt;&#xA;I need to yank from line 73 until line 81, How can I do it?&lt;/p&gt;&#xA;" OwnerUserId="4680" LastActivityDate="2019-07-04T13:44:32.417" Title="copy or yank from line x until line y" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20517" PostTypeId="2" ParentId="20513" CreationDate="2019-07-04T13:34:37.283" Score="1" Body="&lt;p&gt;Load your files into vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim files&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, we will use a command on each of them via &lt;code&gt;:argdo&lt;/code&gt;. The command searches (&lt;code&gt;:/pattern/+1&lt;/code&gt;) and &lt;code&gt;o&lt;/code&gt;pens a new line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/pattern/+1 normal! oYour new text here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another option is to &lt;code&gt;put&lt;/code&gt; from the expression register&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/pattern/+1 put ='Your text here'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Altogether:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;argdo /pattern/+1 put ='text'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This may struggle if any of the files don’t contain &lt;code&gt;pattern&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://vi.stackexchange.com/a/19700/10604&quot;&gt;my answer on scripting ex&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex file &amp;lt;&amp;lt;EOF&#xA;/pattern/+1 put ='text'&#xA;wq&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-04T20:20:23.223" LastActivityDate="2019-07-04T20:20:23.223" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20518" PostTypeId="2" ParentId="20514" CreationDate="2019-07-04T13:40:48.933" Score="2" Body="&lt;p&gt;There are plugins that address this, such as &lt;a href=&quot;https://github.com/AndrewRadev/qftools.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;qftools&lt;/a&gt; or &lt;a href=&quot;https://github.com/romainl/vim-qf&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-qf&lt;/a&gt; by our own romainl. A quick &lt;a href=&quot;https://www.google.com/search?q=vim+quickfix+filter&amp;amp;ie=UTF-8&amp;amp;oe=UTF-8&amp;amp;hl=fr-us&amp;amp;client=safari&quot; rel=&quot;nofollow noreferrer&quot;&gt;google&lt;/a&gt; gets plenty of results.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-04T13:40:48.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20519" PostTypeId="2" ParentId="20515" CreationDate="2019-07-04T13:42:14.893" Score="1" Body="&lt;p&gt;Simply omit the first &lt;code&gt;a&lt;/code&gt; and change the abbreviation as a compromise:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoreabbrev aaquilo àquilo&#xA;inoreabbrev aaquele àquele&#xA;inoreabbrev aaquela àquela&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As should be clear from &lt;code&gt;:help abbrev&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason you can't have &lt;code&gt;a aquilo -&amp;gt; àquilo&lt;/code&gt; is that vim sees &lt;code&gt;a -&amp;gt; aquilo àquilo&lt;/code&gt;. The left-hand-side of the abbreviation must follow certain patterns (see &lt;code&gt;:help abbreviations&lt;/code&gt; and then &lt;code&gt;/full-id&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-04T15:28:59.327" LastActivityDate="2019-07-04T15:28:59.327" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="20520" PostTypeId="2" ParentId="20516" CreationDate="2019-07-04T13:44:32.417" Score="5" Body="&lt;pre&gt;&lt;code&gt;:73,81yank&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ex commands usually take ranges and &lt;code&gt;yank&lt;/code&gt; is no exception. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-04T13:44:32.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20521" PostTypeId="2" ParentId="20515" CreationDate="2019-07-04T15:50:29.703" Score="1" Body="&lt;p&gt;You can accomplish what you're trying to do by using an expression (introduced using &lt;code&gt;&amp;lt;C-r&amp;gt;=&lt;/code&gt;, or using &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; when defining the abbreviation) and then matching a single &quot;a&quot; word at the end of the text that precedes the word being abbreviated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you find that &quot;a&quot; word, then you can expand it to a &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt;, that will delete that word, followed by the abbreviation you desire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use this function to implement all the &quot;à&quot; (named &lt;em&gt;crase&lt;/em&gt;) abbreviations in Portuguese:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Crase()&#xA;    &quot; Get the list of words until this point,&#xA;    &quot; including the one being abbreviated.&#xA;    let words = split(getline('.')[0:col('.')-2])&#xA;    &quot; By default, return the word itself.&#xA;    let replacement = words[-1]&#xA;    &quot; Check if a word 'a' precedes it.&#xA;    if len(words) &amp;gt;=# 2 &amp;amp;&amp;amp; words[-2] ==? 'a'&#xA;        &quot; Handle capitalization.&#xA;        if words[-2] ==# 'A' || words[-1] =~# '^A'&#xA;            let replacement = substitute(replacement, '^\ca', 'À', '')&#xA;        else&#xA;            let replacement = substitute(replacement, '^\ca', 'à', '')&#xA;        endif&#xA;        &quot; Remove the 'a' word and&#xA;        &quot; contract the 'crase'.&#xA;        return &quot;\&amp;lt;C-w&amp;gt;&quot;.replacement&#xA;    endif&#xA;    &quot; Otherwise, no change.&#xA;    return replacement&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks at the sentence so far, then takes the two last words in it (when using &lt;code&gt;iab &amp;lt;expr&amp;gt;&lt;/code&gt;, you'll get the word being abbreviated as well.) Then it checks whether the second last word was an &quot;a&quot; or an &quot;A&quot;. If that's the case, it will then remove that word (using the &lt;code&gt;&quot;\&amp;lt;C-w&amp;gt;&quot;&lt;/code&gt; at the beginning of the expansion), then return the word being abbreviated, just replacing the first character (which must be an &quot;a&quot;, lower or uppercase!) with an &quot;à&quot; or an &quot;À&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function does proper capitalization, so &quot;A aquele&quot; will be expanded to &quot;Àquele&quot;, as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the function as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoreabbrev &amp;lt;expr&amp;gt; aquele Crase()&#xA;inoreabbrev &amp;lt;expr&amp;gt; Aquele Crase()&#xA;inoreabbrev &amp;lt;expr&amp;gt; AQUELE Crase()&#xA;inoreabbrev &amp;lt;expr&amp;gt; aquela Crase()&#xA;inoreabbrev &amp;lt;expr&amp;gt; Aquela Crase()&#xA;inoreabbrev &amp;lt;expr&amp;gt; AQUELA Crase()&#xA;inoreabbrev &amp;lt;expr&amp;gt; aquilo Crase()&#xA;inoreabbrev &amp;lt;expr&amp;gt; Aquilo Crase()&#xA;inoreabbrev &amp;lt;expr&amp;gt; AQUILO Crase()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can even use it for &quot;a a&quot;, turn it into &quot;à&quot;, with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoreabbrev &amp;lt;expr&amp;gt; a Crase()&#xA;inoreabbrev &amp;lt;expr&amp;gt; A Crase()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-07-04T17:03:59.530" LastActivityDate="2019-07-04T17:03:59.530" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20522" PostTypeId="2" ParentId="8884" CreationDate="2019-07-04T19:55:23.227" Score="4" Body="&lt;p&gt;In vim, it is now possible since &lt;a href=&quot;https://github.com/vim/vim/commit/98aefe7c3250bb5d4153b994f878594d1745424e#diff-90dd8c04113fca83dfa90e38f053465e&quot; rel=&quot;nofollow noreferrer&quot;&gt;patch 8.1.0579&lt;/a&gt; using text properties (&lt;code&gt;:help textprop&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the name suggests, a text property is a property that can be associated to text, and moves with it. Properties can be used for highlighting, but the concept is more general and could have other use cases (e.g. tagging for jumping).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do highlighting with properties, firstly it is necessary to define a property type for the desired highlight group, and secondly to apply it to regions of text. A property type can be defined using the function &lt;code&gt;prop_type_add()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call prop_type_add('error_property', {'highlight': 'Error'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;'error_property'&lt;/code&gt; is a name for the new property, and the second argument defines what the property is, in this case it is the &lt;code&gt;Error&lt;/code&gt; syntax highlight group (for more options, please refer to &lt;code&gt;|prop_type_add()|&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once a property type is defined, it can be assigned to a region of text using the function &lt;code&gt;prop_add()&lt;/code&gt;. An instance of property can be identified by an optional id. What I find handy is the fact that a property can span over multiple lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:options = {&#xA;\   'id': l:id,&#xA;\   'type': 'error_property',&#xA;\   'end_lnum': l:end_line,&#xA;\   'end_col': l:end_column,&#xA;\ }&#xA;call prop_add(l:start_line, l:start_column, l:options)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For additional options, please refer to |&lt;code&gt;prop_add()&lt;/code&gt;|.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Properties can be removed with &lt;code&gt;prop_remove()&lt;/code&gt;, either by id or by type, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Remove property with ID equal to 1&#xA;call prop_remove({'id': 1})&#xA;&#xA;&quot; Remove all properties of type 'error_property' within lines l:start and l:end (inclusive)&#xA;call prop_remove({'type': 'error_property', 'all': v:true}, l:start, l:end)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22887" LastActivityDate="2019-07-04T19:55:23.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20523" PostTypeId="1" AcceptedAnswerId="20524" CreationDate="2019-07-05T00:37:50.147" Score="3" ViewCount="382" Body="&lt;p&gt;I'm wanting to write a simple plugin that allows using a motion to choose some text and then processes that text. I'm trying to find out how to get the text that a motion results in. So far I haven't noticed anything under :help functions or :help motions that I might be able to use. I tried going through the source of vim-fireplace, but rapidly got lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So does anybody have a simple example or a link to a near trivial plugin that does something similar?&lt;/p&gt;&#xA;" OwnerUserId="22881" LastActivityDate="2019-07-05T01:14:16.360" Title="How do I get the text that is chosen by some motion?" Tags="|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20524" PostTypeId="2" ParentId="20523" CreationDate="2019-07-05T01:14:16.360" Score="4" Body="&lt;p&gt;In short, you set &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27operatorfunc%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'operatorfunc'&lt;/code&gt;&lt;/a&gt; to point to the name of a function, then write a mapping that uses the &lt;a href=&quot;https://vimhelp.org/map.txt.html#g%40&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g@&lt;/code&gt;&lt;/a&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;g@&lt;/code&gt; command will take a motion (in operator-pending mode) and then will call the function set in &lt;code&gt;'operatorfunc'&lt;/code&gt;, passing it an argument to indicate whether the motion was char-wise or line-wise. Additionally, it will set the &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt; markers pointing to the start and end of the motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See section &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-operator&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mapping an Operator&lt;/a&gt; in Vim help (also accessible through &lt;code&gt;:help :map-operator&lt;/code&gt;) which will have some more details on that and an example. It will also have pointers to the documentation on &lt;code&gt;g@&lt;/code&gt; and &lt;code&gt;'operatorfunc'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also want to read the &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/33.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Grep Operator, Part 2&lt;/a&gt; section of the excellent &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt;. Actually, you should probably read the whole thing, if Vimscript interests you, but that particular section handles this very specific case of creating a mapping that takes a motion in operator-pending mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also want to make your mapping work in Visual mode. Both the Vim help and &quot;Learning Vimscript the Hard Way&quot; show examples of writing a function that will work for both, and the appropriate mappings to go along with that.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-05T01:14:16.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20525" PostTypeId="1" AcceptedAnswerId="20527" CreationDate="2019-07-05T10:00:21.303" Score="3" ViewCount="171" Body="&lt;p&gt;Using plugin YouCompleteMe, I get useful previews of entries. However, if the cursor is near the end of the line, the list gets out of sight. Screenshots below; the latter with &lt;code&gt;pumwidth=75&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(First image.) &lt;a href=&quot;https://i.stack.imgur.com/LQh9U.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LQh9U.png&quot; alt=&quot;Truncated preview list&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Second image.) &lt;a href=&quot;https://i.stack.imgur.com/5mUf0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5mUf0.png&quot; alt=&quot;Pumwidth 75&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way I've found to get around this, is to resize the window temporarily so that it will be wide enough to show the preview, or move the cursor to the left in the line, as in the screenshot below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fIVOJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fIVOJ.png&quot; alt=&quot;Wider preview list&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to tell vim, that &lt;em&gt;n&lt;/em&gt; characters of preview should always be shown, and if the completion list &quot;disappears outside the window&quot;, it should shift it to accommodate &lt;em&gt;n&lt;/em&gt;? (&lt;em&gt;n&lt;/em&gt;=20 might be a suitable number for me.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Setting &lt;code&gt;pumwidth&lt;/code&gt; to really high did the trick; in the figures of 200 or so. Screenshot:&lt;a href=&quot;https://i.stack.imgur.com/BUd2R.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BUd2R.png&quot; alt=&quot;pumwidth = 200&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22895" LastEditorUserId="22895" LastEditDate="2019-07-06T20:13:42.880" LastActivityDate="2019-07-07T16:20:43.377" Title="Float YCM completion candidate list to make more of entry previews visible?" Tags="|macvim|plugin-you-complete-me|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20526" PostTypeId="1" CreationDate="2019-07-05T11:26:22.820" Score="0" ViewCount="22" Body="&lt;p&gt;On vim I enter for a mistake the&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I can exit only with ctrl+c&#xA;What the command :c do?&lt;/p&gt;&#xA;" OwnerUserId="5009" LastActivityDate="2019-07-05T11:26:22.820" Title="Vim what the :c command do?" Tags="|keyword|" AnswerCount="0" CommentCount="2" ClosedDate="2019-07-05T11:56:40.700" ContentLicense="CC BY-SA 4.0" />
  <row Id="20527" PostTypeId="2" ParentId="20525" CreationDate="2019-07-05T13:02:37.190" Score="1" Body="&lt;p&gt;You can set the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27pumwidth%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'pumwidth'&lt;/code&gt;&lt;/a&gt; option to set a minimum width for the pop-up menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The setting is for the total width, including the match and the preview, so you want to set it to something higher (like 35 or 40) to ensure you'll have at least 20 characters or so of the preview available.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; Setting &lt;code&gt;'pumwidth'&lt;/code&gt; to a really large value, like 200, solved the OP's problem, so that's worth a try!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set pumwidth=200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-07-07T16:20:43.377" LastActivityDate="2019-07-07T16:20:43.377" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20528" PostTypeId="2" ParentId="4167" CreationDate="2019-07-05T19:25:52.413" Score="4" Body="&lt;p&gt;The OP's question is whether there is a good omnifunc for Vimscript itself, such as offering semantically or syntactically are completion suggestions for vimscript functions, variables, etc. A number of answers just note general autocompletion plugins like YCM and snippet plugins like UltiSnips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to answer the original question: Yes, there's vim-verdin: &lt;a href=&quot;https://github.com/machakann/vim-Verdin&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/machakann/vim-Verdin&lt;/a&gt;. It's surprisingly good at vimscript suggestions, and seems to be getting better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But be warned though that at the time of writing it doesn't work perfectly with YCM (I would know as the YCM maintainer!). It works well enough that I use it regularly however. Disabling &lt;code&gt;g:verdin#autocomplete&lt;/code&gt; and enabling &lt;code&gt;g:verdin#cooperativemode&lt;/code&gt; allows you to hit ctrl-space for completion suggestions from verdin.&lt;/p&gt;&#xA;" OwnerUserId="17683" LastActivityDate="2019-07-05T19:25:52.413" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20530" PostTypeId="2" ParentId="18592" CreationDate="2019-07-05T20:50:44.477" Score="2" Body="&lt;p&gt;this one works for me &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-y&amp;gt; :CtrlPBuffer&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16105" LastActivityDate="2019-07-05T20:50:44.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20531" PostTypeId="1" CreationDate="2019-07-05T22:15:21.263" Score="4" ViewCount="164" Body="&lt;p&gt;I'm using fzf.vim instead of ctrlp.vim for quite some time now but there is one functionality that a miss quite a lot. In ctrlp.vim once you have the extension opened you can cycle between modes using the &lt;code&gt;&amp;lt;c-f&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-b&amp;gt;&lt;/code&gt;. This for me was very useful when switching from buffers to files search of vice versa while keeping everything that I have typed into the search by that point. Is there any way to do that in fzf.vim for &lt;code&gt;:Files&lt;/code&gt;, &lt;code&gt;:Buffers&lt;/code&gt; commands respectively?&lt;/p&gt;&#xA;" OwnerUserId="15048" LastEditorUserId="18609" LastEditDate="2019-07-06T09:29:40.570" LastActivityDate="2019-07-06T09:29:40.570" Title="Cycle between modes in fzf.vim" Tags="|plugin-ctrlp|plugin-fzf|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20532" PostTypeId="1" AcceptedAnswerId="20533" CreationDate="2019-07-06T03:01:46.967" Score="1" ViewCount="302" Body="&lt;p&gt;Assume &lt;code&gt;autoindent&lt;/code&gt; is set, and you have the buffer below. Note the cursor is represented as &lt;code&gt;I&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(1, 6):&#xA;    print(i)I&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you hit Enter key, you get this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(1, 6):&#xA;    print(i)&#xA;    I&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Question: is there any simple way to move the cursor back to the place before the press of Enter key? These are solutions but too complicated:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Five presses of backspace key&lt;/li&gt;&#xA;&lt;li&gt;Ctrl+d (decrease indent by one) and one press of backspace&lt;/li&gt;&#xA;&lt;li&gt;Esc (exit insert mode) and k (move cursor up) and Shift+a (append to current line).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If it is possible, I would like to realize that &lt;strong&gt;without&lt;/strong&gt; exiting insert mode. In the other words, I would like to avoid Esc, Ctrl+o (execute one normal command), and so on.&lt;/p&gt;&#xA;" OwnerUserId="16502" LastEditorUserId="16502" LastEditDate="2019-07-06T03:18:25.880" LastActivityDate="2019-07-07T02:03:06.810" Title="How to move a cursor to the last line with auto indent?" Tags="|indentation|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20533" PostTypeId="2" ParentId="20532" CreationDate="2019-07-06T03:31:17.367" Score="2" Body="&lt;p&gt;&lt;kbd&gt;ctrl&lt;/kbd&gt; &lt;kbd&gt;w&lt;/kbd&gt; &lt;kbd&gt;w&lt;/kbd&gt; (hold ctrl, don't release)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you need to set &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27backspace%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'backspace'&lt;/a&gt; to &lt;code&gt;indent,eol,start&lt;/code&gt; for this to work . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;&amp;lt;backspace&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; instead of &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; if you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior is described in &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_backspacing&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h i_backspacing&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-07-07T02:03:06.810" LastActivityDate="2019-07-07T02:03:06.810" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20534" PostTypeId="2" ParentId="20532" CreationDate="2019-07-06T04:03:45.350" Score="0" Body="&lt;p&gt;You can create a mapping to be able to use a single backspace to return to the previous line and undo the autoindent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27autoindent%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'autoindent'&lt;/code&gt; documentation&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you do not type anything on the new line except &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; or &lt;code&gt;CTRL-D&lt;/code&gt; and then type &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, &lt;code&gt;CTRL-O&lt;/code&gt; or &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, the indent is deleted again.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;CTRL-O&lt;/code&gt; and a normal mode command that does nothing is convenient, since it will not have unwanted side effects where there's no autoindent, but it will still do the job where there's an autoindent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a command that does nothing, we can use &lt;code&gt;:&amp;lt;CR&amp;gt;&lt;/code&gt;, briefly entering command mode but not entering any command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This mapping should do the job:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;bs&amp;gt; &amp;lt;c-o&amp;gt;:&amp;lt;cr&amp;gt;&amp;lt;bs&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this mapping in place, pressing a single &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; after a return that triggers an autoindent will get the cursor back to the end of the previous line. Elsewhere, &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; will work as it normally does.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-06T04:03:45.350" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20535" PostTypeId="1" CreationDate="2019-07-06T05:18:51.247" Score="0" ViewCount="51" Body="&lt;p&gt;I added this line to my .vimrc: &lt;code&gt;set formatoptions-=ro&lt;/code&gt;. When I open any file it works as intended, except if it is .vimrc. In that case it doesn't work. Why does this happen and how to fix it?&lt;/p&gt;&#xA;" OwnerUserId="21104" LastActivityDate="2019-07-06T05:36:09.683" Title="Option doesn't happen when opening vimrc?" Tags="|vimrc|set|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20536" PostTypeId="2" ParentId="20535" CreationDate="2019-07-06T05:36:09.683" Score="2" Body="&lt;p&gt;The FileType plugin for vim files sets the format options. It contains the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal fo-=t fo+=croql&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to overwrite this, create the file &lt;code&gt;.vim/after/ftplugin/vim.vim&lt;/code&gt; and add your personal &lt;code&gt;formatoptions&lt;/code&gt; to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When Vim loads the &lt;code&gt;.vimrc&lt;/code&gt; it will first load the global &lt;code&gt;vim.vim&lt;/code&gt; FileType plugin and then load &lt;code&gt;.vim/after/ftplugin/vim.vim&lt;/code&gt;. So you can overwrite any settings from there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help after-directory&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-07-06T05:36:09.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20537" PostTypeId="1" CreationDate="2019-07-06T15:36:35.587" Score="2" ViewCount="706" Body="&lt;p&gt;I've been trying to disable vim from highlighting random words and types for a few hours now. I've noticed vim will highlight specific types when I write python and golang programmes. Even my &lt;code&gt;.vimrc&lt;/code&gt; file has random highlighting. I've tried setting &lt;code&gt;set nospell&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt; and have experimented with a number of themes but can't seem to solve this problem, even after researching about it online for a few hours. Here's an example of what I'm talking about:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/O6NNi.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/O6NNi.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;Here's my &lt;code&gt;.vimrc&lt;/code&gt; file &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax enable&#xA;set number relativenumber&#xA;set ts=4&#xA;set autoindent&#xA;set expandtab&#xA;set shiftwidth=4&#xA;set showmatch&#xA;let python_hightlight_all=1&#xA;set nocompatible&#xA;filetype off&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&#xA;au BufNewFile,BufRead *.py&#xA;    \ set tabstop=4 |&#xA;    \ set softtabstop=4 |&#xA;    \ set shiftwidth=4 |&#xA;    \ set textwidth=79 |&#xA;    \ set expandtab |&#xA;    \ set autoindent |&#xA;    \ set fileformat=unix&#xA;&#xA;set encoding=utf-8&#xA;&#xA;au BufRead *.py set softtabstop=4 shiftwidth=4&#xA;&#xA;&#xA;set incsearch&#xA;&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'itchyny/lightline.vim'&#xA;Plugin 'mattn/emmet-vim'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'dracula/vim'&#xA;Plugin 'morhetz/gruvbox'&#xA;Plugin 'Yggdroot/indentLine'&#xA;Plugin 'joshdick/onedark.vim'&#xA;Plugin 'vim-scripts/indentpython.vim'&#xA;Plugin 'vim-syntastic/syntastic'&#xA;Plugin 'nvie/vim-flake8'&#xA;Plugin 'airblade/vim-gitgutter'&#xA;Plugin 'hashivim/vim-terraform'&#xA;Plugin 'Valloric/YouCompleteMe'&#xA;Plugin 'fatih/vim-go'&#xA;call vundle#end()&#xA;color dracula&#xA;set laststatus=2&#xA;filetype plugin indent on&#xA;autocmd StdinReadPre * let s:std_in=1&#xA;autocmd VimEnter * if argc() == 0 &amp;amp;&amp;amp; !exists(&quot;s:std_in&quot;) | NERDTree | endif&#xA;set cursorline&#xA;set nospell&#xA;autocmd! FileType python nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F9&amp;gt; :exec '!python' shellescape(@%, 1)&amp;lt;cr&amp;gt;&#xA;autocmd FileType go nmap &amp;lt;buffer&amp;gt; &amp;lt;F5&amp;gt;  &amp;lt;Plug&amp;gt;(go-build)&#xA;autocmd FileType go nmap &amp;lt;buffer&amp;gt; &amp;lt;F6&amp;gt;  &amp;lt;Plug&amp;gt;(go-run)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22908" LastActivityDate="2019-07-06T16:11:04.623" Title="How to prevent vim from highlighting random words and types" Tags="|vimrc|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20538" PostTypeId="2" ParentId="20537" CreationDate="2019-07-06T16:11:04.623" Score="1" Body="&lt;p&gt;As one of the maintainers of the dracula theme, I believe what you are seeing is dracula’s italics (which fallback to this highlighting in terminals not supporting italics). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As noted in &lt;code&gt;:help dracula&lt;/code&gt;, you can turn this off by doing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:dracula_italic = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;before you load dracula. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-06T16:11:04.623" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20539" PostTypeId="1" CreationDate="2019-07-06T18:01:30.993" Score="2" ViewCount="90" Body="&lt;p&gt;Yes, I know this is unconventional, but I just want to know. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I right click on a chunk of higlighted text, the  dropdown doesn't show any option for deleting - just &lt;code&gt;copy&lt;/code&gt;, &lt;code&gt;copy as html&lt;/code&gt;...&lt;code&gt;show menu bar&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want the option for &lt;strong&gt;deleting&lt;/strong&gt; a chunk of text as well: How do I accomplish this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(bracing myself for the &quot;that's not how you use vim&quot; shaming)&lt;/p&gt;&#xA;" OwnerUserId="22909" LastActivityDate="2019-07-06T18:01:30.993" Title="How do I delete a block a text using the mouse cursor?" Tags="|key-bindings|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20540" PostTypeId="2" ParentId="11338" CreationDate="2019-07-07T07:06:12.007" Score="1" Body="&lt;p&gt;In case of someone want to find a solution to avoid the completion history. It just take much time to find this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmode=longest,full&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmode=longest:list,full&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13428" LastActivityDate="2019-07-07T07:06:12.007" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20541" PostTypeId="2" ParentId="8480" CreationDate="2019-07-07T08:14:27.933" Score="-1" Body="&lt;p&gt;For python 3 use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim --api-info | python -c 'import msgpack, sys, yaml; print( yaml.dump(msgpack.unpackb(sys.stdin.buffer.read(), raw=False)))' | less&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22911" LastActivityDate="2019-07-07T08:14:27.933" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20542" PostTypeId="1" CreationDate="2019-07-07T16:04:26.303" Score="2" ViewCount="2814" Body="&lt;p&gt;Note: this is an educational exercise. For those wanting a ready-made solution, use &lt;a href=&quot;https://github.com/itchyny/vim-gitbranch&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-gitbranch&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am learning vimscript, and the code below is part of my &lt;code&gt;.vimrc&lt;/code&gt; used to display the current git branch in the statusline. I am aware that there are ready-made options out there, but this is more of an educational exercise. The purpose of this question is to solicit advice on improving the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only arbitrary requirement of this exercise is that the git branch has to be obtained using a &lt;code&gt;system&lt;/code&gt; call (instead of directly through the &lt;code&gt;.git&lt;/code&gt; directory).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! StatuslineGitBranch()&#xA;    if exists(&quot;g:git_branch&quot;)&#xA;        return g:git_branch&#xA;    else&#xA;        return ''&#xA;    endif&#xA;endfunction&#xA;&#xA;function! GetGitBranch()&#xA;    let l:is_git_dir = system('echo -n $(git rev-parse --is-inside-work-tree)')&#xA;    let g:git_branch = l:is_git_dir == 'true' ?&#xA;        \ system('bash -c &quot;echo -n $(git rev-parse --abbrev-ref HEAD)&quot;') : ''&#xA;endfunction&#xA;&#xA;autocmd BufEnter * call GetGitBranch()&#xA;&#xA;set laststatus=2&#xA;set statusline=&#xA;set statusline+=%{StatuslineGitBranch()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reason for the existence of &lt;code&gt;g:git_branch&lt;/code&gt;, and the slightly convoluted execution: so that statusline does not involve a &lt;code&gt;system&lt;/code&gt; call (&lt;a href=&quot;https://github.com/vim/vim/issues/3197&quot; rel=&quot;nofollow noreferrer&quot;&gt;reference&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can the above be improved? I'm new to this, so comments will be very helpful.&lt;/p&gt;&#xA;" OwnerUserId="19712" LastEditorUserId="19712" LastEditDate="2019-11-15T05:49:57.223" LastActivityDate="2019-11-15T05:49:57.223" Title="Review: git branch in statusline" Tags="|vimscript|statusline|git|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20543" PostTypeId="1" CreationDate="2019-07-07T18:29:09.653" Score="2" ViewCount="61" Body="&lt;p&gt;When I use &lt;code&gt;:w&lt;/code&gt; to save my JSON file, vim automatically adds some commas&#xA;at syntactically significant (?) places. &#xA;It does not happen when I use &lt;code&gt;:x&lt;/code&gt; or &lt;code&gt;ZZ&lt;/code&gt;.  This started today. &#xA;I did not change anything about vim (expect just tab space).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here’s an animated demonstration:&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/8Goks.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8Goks.gif&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any suggestions? I can't figure out why this is happening. &lt;/p&gt;&#xA;" OwnerUserId="22921" OwnerDisplayName="1t1e1" LastEditorUserId="11357" LastEditDate="2019-07-14T11:46:49.783" LastActivityDate="2019-07-14T11:46:49.783" Title="Vim has started adding commas unnecessary places" Tags="|debugging|" AnswerCount="0" CommentCount="4" ClosedDate="2019-07-08T08:52:08.917" ContentLicense="CC BY-SA 4.0" />
  <row Id="20544" PostTypeId="2" ParentId="20542" CreationDate="2019-07-07T22:06:31.850" Score="5" Body="&lt;p&gt;The most general improvements I can give are to avoid the long &lt;code&gt;?:&lt;/code&gt; and to make use of the &lt;code&gt;get&lt;/code&gt; function on dictionaries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I would write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return get(g:, 'git_branch', '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the if, use a plain if&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:is_git_dir = trim(system('git rev-parse --in-inside-work-tree'))&#xA;if l:is_git_dir is# 'true'&#xA;  let g:git_branch = trim(system('git rev-parse --abbrev-ref HEAD'))&#xA;else&#xA;  let g:git_branch = ''&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that I've upgraded your test to use &lt;code&gt;==#&lt;/code&gt; for casing and the system call to be more portable: &lt;code&gt;system()&lt;/code&gt; already uses &lt;code&gt;'shell'&lt;/code&gt;, so no need to wrap that. Invoke git more or less directly. Also, &lt;code&gt;echo -n&lt;/code&gt; is unreliable, and there is never a reason to &lt;code&gt;echo $(command)&lt;/code&gt; when you could just &lt;code&gt;command&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, encode your data as data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:is_git_dir = trim(system('git rev-parse --in-inside-work-tree'))&#xA;let g:git_branch = get(&#xA;        \ { 'true': trim(system('git rev-parse --abbrev-ref HEAD')) },&#xA;        \ l:is_git_dir,&#xA;        \ '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another note is that you're performing two system calls on every &lt;code&gt;BufEnter&lt;/code&gt;; this may or may not be acceptable in terms of performance (measure!!!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I'll add that your best bet is to dig into the ever-popular &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;noreferrer&quot;&gt;fugitive&lt;/a&gt; plugin and try to understand how its statusline function is constructed.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-07T22:17:19.610" LastActivityDate="2019-07-07T22:17:19.610" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20545" PostTypeId="2" ParentId="20217" CreationDate="2019-07-07T22:57:15.583" Score="1" Body="&lt;p&gt;&lt;code&gt;:h xterm-function-keys&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;An xterm can send function keys F1 to F4 in two modes: vt100 compatible or&#xA;not.  Because Vim may not know what the xterm is sending, both types of keys&#xA;are recognized.  The same happens for the &amp;lt;Home&amp;gt; and &amp;lt;End&amp;gt; keys.&#xA;            normal                      vt100 ~&#xA;    &amp;lt;F1&amp;gt;    t_k1    &amp;lt;Esc&amp;gt;[11~   &amp;lt;xF1&amp;gt;   &amp;lt;Esc&amp;gt;OP     *&amp;lt;xF1&amp;gt;-xterm*&#xA;    &amp;lt;F2&amp;gt;    t_k2    &amp;lt;Esc&amp;gt;[12~   &amp;lt;xF2&amp;gt;   &amp;lt;Esc&amp;gt;OQ     *&amp;lt;xF2&amp;gt;-xterm*&#xA;    &amp;lt;F3&amp;gt;    t_k3    &amp;lt;Esc&amp;gt;[13~   &amp;lt;xF3&amp;gt;   &amp;lt;Esc&amp;gt;OR     *&amp;lt;xF3&amp;gt;-xterm*&#xA;    &amp;lt;F4&amp;gt;    t_k4    &amp;lt;Esc&amp;gt;[14~   &amp;lt;xF4&amp;gt;   &amp;lt;Esc&amp;gt;OS     *&amp;lt;xF4&amp;gt;-xterm*&#xA;    &amp;lt;Home&amp;gt;  t_kh    &amp;lt;Esc&amp;gt;[7~    &amp;lt;xHome&amp;gt; &amp;lt;Esc&amp;gt;OH     *&amp;lt;xHome&amp;gt;-xterm*&#xA;    &amp;lt;End&amp;gt;   t_@7    &amp;lt;Esc&amp;gt;[4~    &amp;lt;xEnd&amp;gt;  &amp;lt;Esc&amp;gt;OF     *&amp;lt;xEnd&amp;gt;-xterm*&#xA;&#xA;When Vim starts, &amp;lt;xF1&amp;gt; is mapped to &amp;lt;F1&amp;gt;, &amp;lt;xF2&amp;gt; to &amp;lt;F2&amp;gt; etc.  This means that&#xA;by default both codes do the same thing.  If you make a mapping for &amp;lt;xF2&amp;gt;,&#xA;because your terminal does have two keys, the default mapping is overwritten,&#xA;thus you can use the &amp;lt;F2&amp;gt; and &amp;lt;xF2&amp;gt; keys for something different.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-07-07T22:57:15.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20546" PostTypeId="1" CreationDate="2019-07-08T12:32:50.437" Score="5" ViewCount="1508" Body="&lt;p&gt;Is there a way to search and replace from a specific position in the line to the end of this line?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I am here and you are there&#xA;         ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to show cursor position with ^. For instance, I don't need to replace &lt;code&gt;here&lt;/code&gt; which is before the cursor and want to replace the second one (which is a part of &lt;code&gt;there&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="20314" LastEditorUserId="51" LastEditDate="2019-08-06T18:44:42.527" LastActivityDate="2019-08-06T18:44:42.527" Title="Replace from the current position to the end of the line" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20547" PostTypeId="1" AcceptedAnswerId="20550" CreationDate="2019-07-08T12:48:37.247" Score="2" ViewCount="365" Body="&lt;p&gt;Vim 8 built-in terminal allows communication to and from a running job. The manual describes a terminal API &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#terminal-api&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h terminal-api&lt;/code&gt;&lt;/a&gt; that lets a running job to Vim. An example message is provided to open a file with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;]51;[&quot;drop&quot;, &quot;README.md&quot;]&amp;lt;07&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is how to actually send this to Vim from a running bash interactive session or a shell script? If this line has to be typed literally how can one enter the escape codes before and after the list?&lt;/p&gt;&#xA;" OwnerUserId="22923" LastActivityDate="2019-07-10T19:39:16.830" Title="How to send messages from terminal to Vim using the JSON API?" Tags="|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20548" PostTypeId="1" CreationDate="2019-07-08T12:56:29.287" Score="2" ViewCount="34" Body="&lt;p&gt;I use command-line vim in xterms (actually &lt;code&gt;TERM=rxvt-unicode&lt;/code&gt;) and have long been used to allowing X to manage all mouse interactions, with vim remaining blissfully unaware of the difference between manual keystrokes and pasted text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Today, I made my first test install of the Debian buster release, which comes with vim 8.1.  I went to create a new &lt;code&gt;vimrc.local&lt;/code&gt; to turn off &lt;code&gt;mouse=a&lt;/code&gt; by manually entering &lt;code&gt;:set mouse=&lt;/code&gt;, and then copying (mouse highlight) and pasting (middle-click) the text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set paste&#xA;O&#xA;let g:skip_defaults_vim = 1&#xA;set mouse=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the previous Debian release, with vim 8.0, this behaved exactly as if I had typed those characters by hand - it turned on &lt;code&gt;paste&lt;/code&gt;, then opened a new line in insert mode, and added the two commands to the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the new version, however, vim apparently sees &quot;Oh!  He's pasting with a mouse!&quot; and immediately goes into insert mode, resulting in the file including all four lines. This effectively makes it impossible to paste any kind of commands, only allowing the mouse to be used to insert text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on some web searches, I have tried using &lt;code&gt;:set ttymouse=&lt;/code&gt; in addition to &lt;code&gt;set mouse=&lt;/code&gt;, but this has not affected the &quot;force insert mode when pasting with the mouse&quot; behavior.  It is definitely not anything to do with my X environment, as I can have two xterms open side-by-side to different machines and see the old behavior in the window sshed to the machine with vim 8.0 and the new behavior in the window sshed to the machine with vim 8.1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I restore the previous behavior?&lt;/p&gt;&#xA;" OwnerUserId="14483" LastEditorUserId="21062" LastEditDate="2019-08-07T07:30:31.633" LastActivityDate="2019-08-07T07:30:31.633" Title="Allow pasting into all modes, not just insert" Tags="|mouse|paste|" AnswerCount="0" CommentCount="1" ClosedDate="2019-07-09T07:23:46.653" ContentLicense="CC BY-SA 4.0" />
  <row Id="20549" PostTypeId="2" ParentId="20546" CreationDate="2019-07-08T13:21:08.787" Score="7" Body="&lt;p&gt;You can do it by using visual mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal mode (with the cursor where you want it)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;v$&lt;/code&gt; (Start visual mode and move to end of line)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Esc&lt;/code&gt; (Move back to normal mode)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:s/\%Vhere/xxxx/g&lt;/code&gt; (The substitute command needed)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The important part is the &lt;code&gt;\%V&lt;/code&gt;, you can read more about it here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vim.fandom.com/wiki/Search_only_over_a_visual_range&quot; rel=&quot;noreferrer&quot;&gt;https://vim.fandom.com/wiki/Search_only_over_a_visual_range&lt;/a&gt;&#xA;&lt;a href=&quot;https://vim.fandom.com/wiki/Search_and_replace_in_a_visual_selection&quot; rel=&quot;noreferrer&quot;&gt;https://vim.fandom.com/wiki/Search_and_replace_in_a_visual_selection&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22925" LastActivityDate="2019-07-08T13:21:08.787" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20550" PostTypeId="2" ParentId="20547" CreationDate="2019-07-08T17:19:19.040" Score="1" Body="&lt;p&gt;My understanding of the word job in that doc is that it refers to whatever is running in the &lt;code&gt;:term&lt;/code&gt; (a shell, gdb, etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can encode the message in bash with &lt;code&gt;printf&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf '&amp;lt;Esc&amp;gt;]51;%s\a' message. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, the esc sequence is entered as &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;V&lt;/kbd&gt; followed by &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-10T19:39:16.830" LastActivityDate="2019-07-10T19:39:16.830" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20551" PostTypeId="1" CreationDate="2019-07-08T17:26:51.213" Score="2" ViewCount="175" Body="&lt;p&gt;I am trying to use EnhancedCommentify plugin for vim and mostly using C. However I can't figure out the issue but when I comment/uncomment it uses &lt;code&gt;(* ---- \*)&lt;/code&gt; instead of &lt;code&gt;/* ----- \*/&lt;/code&gt;. I tried to change the plugin itself, it didn't change anything. I also verified wit :set filetype? that vim recognizes the C code, and it does. I even looked for the languages that use &lt;code&gt;(* *)&lt;/code&gt; for comment and simply removed the lines from the plugin : issue is still there !&lt;/p&gt;&#xA;&lt;p&gt;It works fine for fortran, python and .vimrc however...&lt;/p&gt;&#xA;&lt;p&gt;I am kinda puzzled at this, anyone has any idea ?&lt;/p&gt;&#xA;&lt;p&gt;Also, the plugin did output an error when first using it :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Erreur détectée en traitant /home/jacques/.vim/plugin/EnhancedCommentify-2.3/ftplugin/php_enhcomm.vim :&#xA;ligne    6 :&#xA;E117: Fonction inconnue : EnhCommentifyFallback4Embedded&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I opened the file and commented the line as i seemed to me it's only relevant for php, but maybe I am wrong...&lt;/p&gt;&#xA;&lt;p&gt;On another note, I am also trying to remap the smart comment but it seems that I fail, here is the vimrc for now&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vmap &amp;lt;unique&amp;gt; &amp;lt;C-c&amp;gt; &amp;lt;Plug&amp;gt;VisualComment&#xA;nmap &amp;lt;unique&amp;gt; &amp;lt;C-c&amp;gt; &amp;lt;Plug&amp;gt;Comment&#xA;imap &amp;lt;unique&amp;gt; &amp;lt;C-c&amp;gt; &amp;lt;ESC&amp;gt;&amp;lt;Plug&amp;gt;Comment&#xA;vmap &amp;lt;unique&amp;gt; &amp;lt;F3&amp;gt; &amp;lt;Plug&amp;gt;VisualDeComment&#xA;nmap &amp;lt;unique&amp;gt; &amp;lt;F3&amp;gt; &amp;lt;Plug&amp;gt;DeComment&#xA;imap &amp;lt;unique&amp;gt; &amp;lt;F3&amp;gt; &amp;lt;ESC&amp;gt;&amp;lt;Plug&amp;gt;DeComment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and i tried with &amp;quot;Guess&amp;quot; instead of &amp;quot;Comment&amp;quot; but it didn't seem to work. I remember doing this a long time ago but can't find my .vimrc from back then...&lt;/p&gt;&#xA;&lt;p&gt;vmap   VisualComment&#xA;nmap   Comment&#xA;imap   Comment&#xA;vmap   VisualDeComment&#xA;nmap   DeComment&#xA;imap   DeComment&lt;/p&gt;&#xA;" OwnerUserId="22928" LastEditorUserId="23502" LastEditDate="2023-01-19T10:24:09.250" LastActivityDate="2023-06-18T13:09:46.210" Title="Vim and enhanced commentify weird behavior for C" Tags="|comments|filetype-c|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20552" PostTypeId="1" AcceptedAnswerId="20553" CreationDate="2019-07-08T18:30:33.657" Score="4" ViewCount="3059" Body="&lt;p&gt;I'm trying to allow using backspace in normal mode. My best attempt is adding the following to my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;BS&amp;gt; i&amp;lt;BS&amp;gt;&amp;lt;ESC&amp;gt;l&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works great except for two situations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I'm at the second character in the line&lt;/li&gt;&#xA;&lt;li&gt;I delete a tab which is the first tab in the line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In either case, after deleting, my cursor is on the second character of the line, not the first, as one would expect/desire. I get why this happens, but am not sure if there's a better way to get backspace functionality without having these problems. Any solutions?&lt;/p&gt;&#xA;" OwnerUserId="18504" LastActivityDate="2022-06-07T22:49:33.783" Title="Backspace functionality in normal mode" Tags="|normal-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20553" PostTypeId="2" ParentId="20552" CreationDate="2019-07-08T18:50:24.403" Score="10" Body="&lt;p&gt;I'm glad I can share a command I just learned after few years of vim ! The &lt;code&gt;X&lt;/code&gt; command in normal mode does what you want. You can remap &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; to it if you want :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;BS&amp;gt; X&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Edit&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Indeed, if you have spaces in place of tabs, it will delete the space. In the same vein you already achieved, you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;BS&amp;gt; i&amp;lt;BS&amp;gt;&amp;lt;Esc&amp;gt;`^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;^&lt;/code&gt; mark is &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the position where the cursor was the last time when Insert mode was stopped&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sidenote : I suggest you beware of mashing the &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; key and use normal mode motions to delete things backward, because one &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; is one &quot;chunk&quot; of editing (pressing &lt;code&gt;u&lt;/code&gt; will undo just 1 character deletion). Try &lt;code&gt;db&lt;/code&gt;, &lt;code&gt;dge&lt;/code&gt;, &lt;code&gt;d^&lt;/code&gt;, &lt;code&gt;d0&lt;/code&gt;, &lt;code&gt;dF{char}&lt;/code&gt;, &lt;code&gt;dT{char}&lt;/code&gt; &lt;code&gt;d?{pattern}&lt;/code&gt; and more generally &lt;code&gt;d{motion}&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="22929" LastEditorUserId="22929" LastEditDate="2019-07-08T20:03:32.440" LastActivityDate="2019-07-08T20:03:32.440" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20554" PostTypeId="2" ParentId="20551" CreationDate="2019-07-08T18:58:36.757" Score="1" Body="&lt;p&gt;I cannot answer directly your answer, cannot add a comment, but I'll still answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like &lt;a href=&quot;https://github.com/hrp/EnhancedCommentify&quot; rel=&quot;nofollow noreferrer&quot;&gt;EnhancedCommentify&lt;/a&gt; have not beed updated for 6 years now. I suggest you try another plugin. I personnally use &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;NerdCommenter&lt;/a&gt; and love it. You can find other such plugins on &lt;a href=&quot;https://vimawesome.com/?q=comment&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim Awesome&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Edit&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Actually NerdCommenter was my very first comment plugin but I rapidly switched to &lt;a href=&quot;https://github.com/tpope/vim-commentary&quot; rel=&quot;nofollow noreferrer&quot;&gt;Commentary&lt;/a&gt;, the &lt;code&gt;gc&lt;/code&gt; mappings sticks very fine in muscle memory. Can't tell why I messed-up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Jacques, Commentary has the &lt;code&gt;:Commentary&lt;/code&gt; command, so for insert-mode mapping, use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-c&amp;gt; &amp;lt;C-o&amp;gt;:Commentary&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, for &quot;unsupported&quot; file formats, from &lt;code&gt;:h commentary&lt;/code&gt; we can tell that it&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Relies on 'commentstring' to be&#xA;  correctly set, or uses b:commentary_format if it is set.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you can set the &lt;code&gt;commentstring&lt;/code&gt; option for any filetype and it will work. See &lt;code&gt;:h 'commentstring'&lt;/code&gt;. For example to add for python :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufNewFile,BufRead *.py setlocal commentstring=#\ %s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Note&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The python &lt;code&gt;'commentstring'&lt;/code&gt; is already set in default &lt;code&gt;ftplugin/python.vim&lt;/code&gt;. It is just an example.&lt;/li&gt;&#xA;&lt;li&gt;This &quot;answer&quot; is off-topic regarding your initial question.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="22929" LastEditorUserId="22929" LastEditDate="2019-08-08T00:33:43.947" LastActivityDate="2019-08-08T00:33:43.947" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20555" PostTypeId="1" CreationDate="2019-07-08T20:00:15.550" Score="5" ViewCount="506" Body="&lt;p&gt;I recently added the vimtex plugin which includes a conceal feature which I really like; however, I found it doesn't work in custom math environments such as &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-latex prettyprint-override&quot;&gt;&lt;code&gt;\newcommand{\beq}{\begin{equation}}&#xA;\newcommand{\eeq}{\end{equation}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I share my latex documents with other collaborators that frequently use these new commands, so I cannot unilaterally decide to drop the use of these new commands in favor of another feature (e.g) ultisnips. Is there any way I can make the conceal feature recognize these new commands as a math environment?&lt;/p&gt;&#xA;" OwnerUserId="22930" LastEditorUserId="21062" LastEditDate="2019-08-06T18:45:10.087" LastActivityDate="2019-08-06T18:45:10.087" Title="Vimtex conceal doesn't recognize new command math environment" Tags="|filetype-tex|conceal|plugin-vimtex|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20557" PostTypeId="1" AcceptedAnswerId="20571" CreationDate="2019-07-09T00:20:06.643" Score="1" ViewCount="120" Body="&lt;p&gt;I want to hide the number column &lt;code&gt;set nonumber norealtivenumber&lt;/code&gt; in &lt;code&gt;Tlist&lt;/code&gt; window! Every time I call &lt;code&gt;:Tlist&lt;/code&gt; the number column appears in the window.&#xA;How can I disable the number column for that window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vV7Zk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vV7Zk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17299" LastEditorUserId="17299" LastEditDate="2019-07-10T06:52:56.797" LastActivityDate="2019-07-10T11:48:00.537" Title="Number column in Tlist window" Tags="|vimrc|plugin-taglist|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20558" PostTypeId="2" ParentId="5687" CreationDate="2019-07-09T05:51:34.183" Score="4" Body="&lt;p&gt;I went through all colorschemes that go with vim by default, and found 'morning' and 'zellner' look kind of OK for vimdiff.&lt;/p&gt;&#xA;" OwnerUserId="6676" LastActivityDate="2019-07-09T05:51:34.183" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20559" PostTypeId="2" ParentId="20557" CreationDate="2019-07-09T13:14:27.910" Score="1" Body="&lt;p&gt;If &lt;code&gt;:Tlist&lt;/code&gt; comes from the &lt;a href=&quot;http://vim-taglist.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;taglist&lt;/a&gt; plugin, from the docs, I can see :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To not display the Vim fold column in the taglist window, set the&#xA;  'Tlist_Enable_Fold_Column' variable to zero.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So in your .vimrc, do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let Tlist_Enable_Fold_Column=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this column helps you see how the folds are applied. You can toggle folds with &lt;code&gt;za&lt;/code&gt;. For more infos about folds, see &lt;code&gt;:help folds&lt;/code&gt; or &lt;code&gt;:h zo&lt;/code&gt; to see fold mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend you try a fuzzy finder plugin such as &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;CtrlP&lt;/a&gt; or &lt;a href=&quot;https://github.com/wincent/command-t&quot; rel=&quot;nofollow noreferrer&quot;&gt;CommandT&lt;/a&gt;. With both, you can - in addition to search files, buffers, etc... - search in tags. With CtrlP, you can use &lt;code&gt;:CtrlPBufTagAll&lt;/code&gt; to toggle the search, fuzzy find whatever you want, and jump to it.&lt;/p&gt;&#xA;" OwnerUserId="22929" LastActivityDate="2019-07-09T13:14:27.910" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20560" PostTypeId="1" AcceptedAnswerId="20561" CreationDate="2019-07-09T16:05:24.450" Score="12" ViewCount="2272" Body="&lt;p&gt;I want to disable autoindent and smartindent for LaTeX so I did&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set noai noci nosi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open a brand new &lt;code&gt;mwe.tex&lt;/code&gt;, &lt;code&gt;filetype=plaintex&lt;/code&gt; and there is no auto indent magic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I then enter some code, such as &lt;code&gt;\begin{frame}\end{frame}&lt;/code&gt;, save and reopen the file, &lt;code&gt;filetype=tex&lt;/code&gt;, colours have changed, and... there is what to me looks like both auto indent and smart indent going on:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I start typing &lt;code&gt;\begin{frame}&lt;/code&gt; at the beginning of the line, so far so good&lt;/li&gt;&#xA;&lt;li&gt;I press enter, and the cursor is indented by four spaces, despite setting &lt;code&gt;noai&lt;/code&gt;, &lt;code&gt;noci&lt;/code&gt;, and &lt;code&gt;nosi&lt;/code&gt;.  At this point, &lt;code&gt;:set&lt;/code&gt; shows:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Options ---&#xA;  background=dark     helplang=en         shiftwidth=4        ttyfast&#xA;  commentstring=%%s nomodeline            showmatch           ttymouse=xterm&#xA;  expandtab           modified            suffixesadd=.tex&#xA;  filetype=tex        ruler               syntax=tex&#xA;  foldmethod=indent   scroll=34           tabstop=4&#xA;  backspace=indent,eol,start&#xA;  comments=sO:% -,mO:%  ,eO:%%,:%&#xA;  define=\\\([egx]\|char\|mathchar\|count\|dimen\|muskip\|skip\|toks\)\=def\|\\font\|\\\(future\)\&#xA;=let\|\\new\(count\|dimen\|skip\|muskip\|box\|toks\|read\|write\|fam\|insert\)\|\\\(re\)\=new\(boo&#xA;lean\|command\|counter\|environment\|font\|if\|length\|savebox\|theorem\(style\)\=\)\s*\*\=\s*{\=\&#xA;|DeclareMathOperator\s*{\=\s*&#xA;  fileencoding=utf-8&#xA;  fileencodings=ucs-bom,utf-8,default,latin1&#xA;  include=\\input\|\\include{&#xA;  includeexpr=substitute(v:fname, '^.\{-}{\|}.*', '', 'g')&#xA;  indentexpr=GetTeXIndent()&#xA;  indentkeys=0{,0},:,0#,!^F,o,O,e,[,(,{,),},],&amp;amp;,=\bibitem,=\item&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I type &lt;code&gt;\end{frame&lt;/code&gt; at the indented base.  After I add a &lt;code&gt;}&lt;/code&gt;, it gets automatically dedented (with a fraction of a second delay).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:scriptnames&lt;/code&gt;, I can tell there are scripts loaded at &lt;code&gt;/usr/share/vim/vim80/indent.vim&lt;/code&gt;,  &lt;code&gt;/usr/share/vim/vim80/syntax/tex.vim&lt;/code&gt;, &lt;code&gt;/usr/share/vim/vim80/ftplugin/tex.vim&lt;/code&gt;, and &lt;code&gt;/usr/share/vim/vim80/indent/tex.vim&lt;/code&gt;.  So it looks like there is a script overriding the standard vim settings.  How do I configure the behaviour of this script?&lt;/p&gt;&#xA;" OwnerUserId="13038" LastEditorUserId="1292" LastEditDate="2019-07-11T06:48:03.930" LastActivityDate="2021-10-20T06:20:13.760" Title="Why does vim still auto-indent LaTeX after I set noai noci nosi?" Tags="|indentation|filetype-tex|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20561" PostTypeId="2" ParentId="20560" CreationDate="2019-07-09T17:02:22.530" Score="13" Body="&lt;p&gt;&lt;code&gt;'indentexpr'&lt;/code&gt; has the highest priority of how vim can automatically indent lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h 'indentexpr'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When this option is not empty, it overrules the &lt;code&gt;'cindent'&lt;/code&gt; and&#xA;      &lt;code&gt;'smartindent'&lt;/code&gt; indenting.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your value is &lt;code&gt;indentexpr=GetTeXIndent()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Customize &lt;code&gt;GetTeXIndent()&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior of &lt;code&gt;GetTeXIndent()&lt;/code&gt; can be customized by a few variables (e.g. &lt;code&gt;g:tex_indent_brace&lt;/code&gt; or &lt;code&gt;g:tex_indent_items&lt;/code&gt;). They are documented in-source in &lt;a href=&quot;https://github.com/vim/vim/blob/eb3dc87f01391bb075d97aef3d00f91b4e08a25c/runtime/indent/tex.vim#L70-L122&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;$VIMRUNTIME/indent/tex.vim&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only want to disable the indentation after &lt;code&gt;\begin{frame}&lt;/code&gt; but keep indenting other code, you can put in your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tex_noindent_env = 'document\|verbatim\|lstlisting\|frame'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This variable is also respected by &lt;code&gt;Tex_CalcIdent()&lt;/code&gt; of &lt;a href=&quot;https://github.com/vim-latex/vim-latex&quot; rel=&quot;noreferrer&quot;&gt;vim-latex&lt;/a&gt; and &lt;code&gt;BuckyTeXIndent()&lt;/code&gt; of &lt;a href=&quot;https://github.com/dbmrq/vim-bucky&quot; rel=&quot;noreferrer&quot;&gt;vim-bucky&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Vimtex user: Customize &lt;code&gt;VimtexIndentExpr()&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;noreferrer&quot;&gt;vimtex&lt;/a&gt; provides its own indentation function &lt;code&gt;VimtexIndentExpr()&lt;/code&gt;. This function can be customized with a similar option &lt;code&gt;g:vimtex_indent_ignored_envs&lt;/code&gt; which, however, is a list of names&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vimtex_indent_ignored_envs = ['document', 'verbatim', 'lstlisting', 'frame']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Disable indentation completely&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set indentexpr=&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Permanent vim setting&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to &lt;code&gt;set indentexpr=&lt;/code&gt; permanently in your vim config, see the question&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/4/how-can-i-change-the-default-indentation-based-on-filetype&quot;&gt;How can I change the default indentation based on filetype?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and its answers.&#xA;Some recommend to not use autocmds but to place&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal indentexpr=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into a file such as &lt;code&gt;~/.vim/after/indent/tex.vim&lt;/code&gt; which is always sourced by vim and has the last word.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-07-11T11:40:34.600" LastActivityDate="2019-07-11T11:40:34.600" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20562" PostTypeId="2" ParentId="20542" CreationDate="2019-07-09T17:09:05.483" Score="4" Body="&lt;p&gt;0- +1 to D. Ben Knoble suggestions.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Regarding pure vim-scripting&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- Never define autocommands globally. Prefer to define them in their own group, and when filling the group, start by clearing it. This way, the related snippet of code can be re-executed, which you'll will want when you'll be working on your script&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aug MyGitBranch&#xA;  au!&#xA;  au BufEnter * call s:GetGitBranch()&#xA;aug END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2- Avoid globally defined functions. Global functions may be defined/changed/removed by any other piece of code. Either define them as script local functions (with the &lt;code&gt;s:&lt;/code&gt; prefix as I've done above), or as autoloaded functions if you need to export them (i.e. if you're defining a library plugin), or if they can be lazily loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the specific case of statusline, I don't remember if we can use script-local functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3- Also, it's better to annotate functions with the &lt;code&gt;abort&lt;/code&gt; keyword. In case an error is triggered (even if this is impossible on the current code, problems may be introduced on different flavours of Vim (the suggested &lt;code&gt;trim()&lt;/code&gt; is quite recent for instance), or in later versions of your plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;abort&lt;/code&gt; ensure the function doesn't continue (this should be the default, but this is not how Vim used to work, and backward compatibility has been chosen here), and it'll also help decoding possible error messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4- I'd use &lt;code&gt;finddir()&lt;/code&gt; to recursively find the upstream &lt;code&gt;.git/&lt;/code&gt; directory instead of using &lt;code&gt;system()&lt;/code&gt;. On user saturated machines, it can make the difference -- I've experienced such shared environments, and I've come to the conclusion it's always better to reduce the dependence of the system. Also, on Windows machines, calls to &lt;code&gt;system()&lt;/code&gt; are really annoying and inefficient.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Otherwise, I not sure we can really avoid checking the current branch every time we switch the current buffer. If a &lt;code&gt;git checkout&lt;/code&gt; is operated, we'll want to know the branch has changed. I don't know if there is a smart way to do it.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2019-09-19T12:56:48.177" LastActivityDate="2019-09-19T12:56:48.177" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20563" PostTypeId="1" AcceptedAnswerId="20574" CreationDate="2019-07-09T18:16:49.227" Score="3" ViewCount="352" Body="&lt;p&gt;Let's consider an example where the cursor is at the beginning of the text &lt;code&gt;one_two three&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Underscores are treated as part of the word, so &lt;kbd&gt;w&lt;/kbd&gt; moves right to the first letter of &lt;code&gt;three&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;With &lt;code&gt;set iskeyword-=_&lt;/code&gt; the underscore is a separate word, so &lt;kbd&gt;w&lt;/kbd&gt; moves to the underscore.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Instead, I'd like &lt;kbd&gt;w&lt;/kbd&gt; to treat the underscore as whitespace, moving to the first letter of &lt;code&gt;two&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How can I configure Vim to get the third of these behaviors?&lt;/p&gt;&#xA;" OwnerUserId="3255" LastEditorUserId="1292" LastEditDate="2019-07-10T14:28:19.557" LastActivityDate="2019-07-10T14:28:19.557" Title="How to treat underscores as whitespace when skipping to the next word?" Tags="|cursor-movement|navigation|keyword|" AnswerCount="1" CommentCount="0" ClosedDate="2019-07-10T11:58:30.370" ContentLicense="CC BY-SA 4.0" />
  <row Id="20564" PostTypeId="1" CreationDate="2019-07-09T18:33:42.537" Score="2" ViewCount="36" Body="&lt;p&gt;I have a key binding to reload my &lt;code&gt;~/.vimrc&lt;/code&gt;. However, some of my options set via &lt;code&gt;autocmd FileType&lt;/code&gt; are not active after reloading the config. Those are to set the text width, creating highlights, etc. I can trigger them manually by &lt;code&gt;set syntax=python&lt;/code&gt;. Is there a way to trigger them again to all open buffers with the correct filetypes?&lt;/p&gt;&#xA;" OwnerUserId="3255" LastActivityDate="2019-07-09T18:33:42.537" Title="How can I trigger the autocmd FileType commands for all buffers?" Tags="|autocmd|" AnswerCount="0" CommentCount="0" ClosedDate="2019-07-10T03:46:45.743" ContentLicense="CC BY-SA 4.0" />
  <row Id="20565" PostTypeId="1" AcceptedAnswerId="20567" CreationDate="2019-07-09T19:10:08.460" Score="2" ViewCount="458" Body="&lt;p&gt;I’ve created a new filetype, “usenet,” for Usenet messages. I would like files with this filetype to be highlighted exactly as if they had the “mail” filetype. Is it possible to tell Vim that I want to reuse the existing “mail” syntax definitions for this other filetype?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;What I’ve tried&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I tried writing &lt;code&gt;setlocal syntax=mail&lt;/code&gt; in the &lt;code&gt;ftplugin/usenet.vim&lt;/code&gt; file but this seemed to be ignored—running &lt;code&gt;:set syntax?&lt;/code&gt; in a file with the “usenet” filetype just produced &lt;code&gt;usenet&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I also tried copying the &lt;code&gt;mail.vim&lt;/code&gt; syntax file from &lt;code&gt;$VIMRUNTIME/syntax&lt;/code&gt; into &lt;code&gt;~/.vim/syntax&lt;/code&gt;, renaming it to &lt;code&gt;usenet.vim&lt;/code&gt;, and changing the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:current_syntax = &quot;mail&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:current_syntax = &quot;usenet&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This worked, but if a future version of Vim improves the &lt;code&gt;mail.vim&lt;/code&gt; file then I would have to go through this process again (and it’s unlikely that I would even notice such a change in the first place). What I want, semantically, is to highlight “usenet” files as if they were “mail” files, which seems like it should be possible.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="671" LastEditorUserId="671" LastEditDate="2019-07-09T19:57:51.010" LastActivityDate="2019-07-10T00:59:57.743" Title="Linking a filetype to a syntax file of a different name" Tags="|syntax-highlighting|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20566" PostTypeId="2" ParentId="5851" CreationDate="2019-07-09T21:06:31.433" Score="8" Body="&lt;p&gt;You could add this to your &lt;code&gt;.vimrc&lt;/code&gt; to disable the arrow keys in Command, Insert, Normal and Visual Mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Remove newbie crutches in Command Mode&#xA;cnoremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;cnoremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;cnoremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;cnoremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&#xA;&quot; Remove newbie crutches in Insert Mode&#xA;inoremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&#xA;&quot; Remove newbie crutches in Normal Mode&#xA;nnoremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;nnoremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;nnoremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;nnoremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&#xA;&quot; Remove newbie crutches in Visual Mode&#xA;vnoremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;vnoremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;vnoremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;vnoremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Checkout &lt;code&gt;:help map-overview&lt;/code&gt; for more details on the different types of mapping&lt;/p&gt;&#xA;" OwnerUserId="11897" LastActivityDate="2019-07-09T21:06:31.433" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20567" PostTypeId="2" ParentId="20565" CreationDate="2019-07-09T21:45:45.267" Score="5" Body="&lt;p&gt;Create a &lt;code&gt;syntax/usenet.vim&lt;/code&gt; with the contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Quit when a syntax file was already loaded&#xA;if exists(&quot;b:current_syntax&quot;)&#xA;  finish&#xA;endif&#xA;&#xA;runtime! syntax/mail.vim&#xA;let b:current_syntax = &quot;usenet&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In short, just source the file you want to inherit syntax from. If you want any customizations for &lt;code&gt;usenet&lt;/code&gt;, just make them after you've sourced &lt;code&gt;syntax/mail.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-09T21:45:45.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20568" PostTypeId="2" ParentId="20565" CreationDate="2019-07-10T00:59:57.743" Score="5" Body="&lt;p&gt;You can use multiple filetype names separated with &lt;code&gt;.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# in your personal filetype.vim&#xA;augroup filetypedetect&#xA;  au! BufRead,BufNewFile *.usenet setfiletype mail.usenet&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All &lt;code&gt;mail&lt;/code&gt; filetype plugins and syntax files will be applied before &lt;code&gt;usenet&lt;/code&gt; filetype plugins and syntax files. All &lt;code&gt;mail&lt;/code&gt; related stuff (&lt;code&gt;abbreviations&lt;/code&gt;, &lt;code&gt;snippets&lt;/code&gt;, balabalas) should work in &lt;code&gt;usenet&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-07-10T00:59:57.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20569" PostTypeId="1" CreationDate="2019-07-10T05:12:14.877" Score="1" ViewCount="223" Body="&lt;p&gt;I would like to write a plugin  which will be triggered at paste from system clipboard if it contains image data. Is it feasible to do this with scripting? My preference is to write in Python, using neovim is also possible. The image would be then saved to file and its name inserted into the edited text.&lt;/p&gt;&#xA;" OwnerUserId="19495" LastActivityDate="2019-07-10T05:12:14.877" Title="Pasting non-text data (image) from system clipboard" Tags="|os-clipboard|" AnswerCount="0" CommentCount="5" ClosedDate="2019-07-10T11:54:31.820" ContentLicense="CC BY-SA 4.0" />
  <row Id="20570" PostTypeId="1" AcceptedAnswerId="20572" CreationDate="2019-07-10T09:54:58.540" Score="4" ViewCount="479" Body="&lt;p&gt;I know that e.g. &lt;code&gt;50%&lt;/code&gt; is a normal mode command to go halfway down a file, but &lt;code&gt;[count]%&lt;/code&gt; is line-wise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get to the halfway point of the line that my cursor is on?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="51" LastEditDate="2019-07-26T22:28:19.470" LastActivityDate="2019-10-28T15:22:24.693" Title="How to go halfway into a line? Percentage navigation within a line" Tags="|cursor-movement|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20571" PostTypeId="2" ParentId="20557" CreationDate="2019-07-10T10:16:00.040" Score="2" Body="&lt;p&gt;You can specify specific commands for some file as the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter filename/pattern   set commands&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I my case I have to explicitly hide the number column for the Tag List window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter __Tag_List__   set nonumber norelativenumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17299" LastEditorUserId="1841" LastEditDate="2019-07-10T11:48:00.537" LastActivityDate="2019-07-10T11:48:00.537" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20572" PostTypeId="2" ParentId="20570" CreationDate="2019-07-10T10:19:16.203" Score="3" Body="&lt;p&gt;Well, there is no built in way to do it as far as I know, but out of curiosity I have come up with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gl :exe 'normal ' . len(getline('.'))/2 . '\|'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;gl&lt;/code&gt; you will be placed in the &quot;middle&quot; of the line (you know... those odd char counts :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What it does:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I want to bind a &lt;code&gt;77|&lt;/code&gt; normal command which is &quot;goto 77th char in current line&quot;. We have to count proper char count though.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:exe&lt;/code&gt; -- execute a command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'normal '&lt;/code&gt; -- we want to execute normal command and start to combine it from different strings&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;. len(getline('.'))/2 .&lt;/code&gt; -- calculate the half length of a current line and join it with other parts of a normal command with dots (.)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'\|'&lt;/code&gt; this normal command should move the cursor to the given char (we have to escape it though as this bar &lt;code&gt;|&lt;/code&gt; is also used in vimscript)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; -- emits enter to execute &lt;code&gt;:exe&lt;/code&gt; we have constructed&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I think there might be an easier way but this one works :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More bulletproof solution with percentage prefix provided by @Jürgen Krämer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gl :&amp;lt;c-u&amp;gt;exe 'normal! ' . (strchars(getline('.')) * v:count1 / 100) . '\|'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;30gl&lt;/code&gt; to go to 30% char of the current line.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; -- removes range symbols that might be added by vim (just in case)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal!&lt;/code&gt; -- executes normal mode command with default not remapped meanings (like if you have remapped &lt;code&gt;|&lt;/code&gt; command to do smth else and still want to execute default command)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;strchars&lt;/code&gt; instead of &lt;code&gt;len&lt;/code&gt; -- to properly count length of a unicode line. &lt;code&gt;len&lt;/code&gt; gives you byte count.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v:count1&lt;/code&gt; is the built-in variable, count number that you have entered just before pressing normal command itself -- in &lt;code&gt;50l&lt;/code&gt; it would be &lt;code&gt;50&lt;/code&gt; that is passed to &lt;code&gt;l&lt;/code&gt; as &lt;code&gt;v:count1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(strchars(getline('.')) * v:count1 / 100)&lt;/code&gt; -- percentage to real char count calculation. So you have a line with 150 length and you have provided &lt;code&gt;50gl&lt;/code&gt; to go to 50% of the line. &lt;code&gt;150*50/100&lt;/code&gt; will give you half of the line.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-07-11T06:16:49.907" LastActivityDate="2019-07-11T06:16:49.907" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20574" PostTypeId="2" ParentId="20563" CreationDate="2019-07-10T11:51:42.720" Score="2" Body="&lt;h3&gt;Plugins &lt;a href=&quot;https://github.com/chaoren/vim-wordmotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-wordmotion&lt;/a&gt; or &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1905&quot; rel=&quot;nofollow noreferrer&quot;&gt;camelcasemotion&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I do not know how vim can be configured to do this out of the box. There is a related wikipage: &lt;a href=&quot;https://vim.fandom.com/wiki/Moving_through_camel_case_words&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vim.fandom.com/wiki/Moving_through_camel_case_words&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This wikipage points you to following plugins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/chaoren/vim-wordmotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;vim-wordmotion&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Under Vim's definition of a word:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CamelCaseACRONYMWords_underscore1234&#xA;w---------------------------------&amp;gt;w&#xA;e---------------------------------&amp;gt;e&#xA;b&amp;lt;---------------------------------b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;With this plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CamelCaseACRONYMWords_underscore1234&#xA;w---&amp;gt;w--&amp;gt;w-----&amp;gt;w----&amp;gt;w--------&amp;gt;w-&amp;gt;w&#xA;e--&amp;gt;e--&amp;gt;e-----&amp;gt;e---&amp;gt;e---------&amp;gt;e--&amp;gt;e&#xA;b&amp;lt;---b&amp;lt;--b&amp;lt;-----b&amp;lt;----b&amp;lt;--------b&amp;lt;-b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1905&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;camelcasemotion&lt;/strong&gt; (#1905)&lt;/a&gt;, despite its name, also supports &lt;code&gt;snake_case&lt;/code&gt;.&lt;br&gt;&#xA;This plugin defines new mappings &lt;code&gt;,w&lt;/code&gt; &lt;code&gt;,b&lt;/code&gt; and &lt;code&gt;,e&lt;/code&gt;. I use &lt;code&gt;;&lt;/code&gt;/&lt;code&gt;,&lt;/code&gt; for repeating &lt;code&gt;fFtT&lt;/code&gt; and other motions with the help of &lt;a href=&quot;https://github.com/Houl/repmo-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;repmo-vim&lt;/a&gt;. As always you can define your own ones, e.g. redefine the builtin ones or choose those which you think are a good pick:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;map w &amp;lt;Plug&amp;gt;CamelCaseMotion_w &#xA;map b &amp;lt;Plug&amp;gt;CamelCaseMotion_b &#xA;map e &amp;lt;Plug&amp;gt;CamelCaseMotion_e &#xA;sunmap w &#xA;sunmap b &#xA;sunmap e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-07-10T11:51:42.720" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20575" PostTypeId="2" ParentId="20570" CreationDate="2019-07-10T13:27:49.423" Score="1" Body="&lt;p&gt;Assume halfway is center of line screen columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/motion.txt.html#gm&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h gm&lt;/a&gt; moves to window center or as far as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To move to center of a line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; gc virtcol('$')/2 . '&amp;lt;bar&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/eval.txt.html#virtcol%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h virtcol()&lt;/a&gt; with &lt;code&gt;'$'&lt;/code&gt; return &lt;code&gt;1 + screen columns of current line&lt;/code&gt;. &lt;a href=&quot;https://vimhelp.org/motion.txt.html#bar&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h bar&lt;/a&gt; move to &lt;code&gt;count&lt;/code&gt; screen column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMO, this kind of command is useless most of the time, &lt;a href=&quot;https://vimhelp.org/motion.txt.html#f&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h f&lt;/a&gt; is the practical way.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-07-10T13:27:49.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20576" PostTypeId="1" AcceptedAnswerId="20586" CreationDate="2019-07-10T14:54:25.600" Score="6" ViewCount="1715" Body="&lt;p&gt;When I mess up typing an uppercase letter, I usually hold &lt;kbd&gt;Shift&lt;/kbd&gt; while pressing the &lt;kbd&gt;Backspace&lt;/kbd&gt;. Instead of backspacing, it types &lt;code&gt;^?&lt;/code&gt; (to my frustration).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google tells me that &lt;code&gt;^?&lt;/code&gt; is the &quot;delete&quot; character, but it has no effect from what I can see (I may be wrong).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen stuff online for setting &lt;code&gt;'backspace'&lt;/code&gt; but none for &lt;code&gt;shift-'backspace'&lt;/code&gt;, so I'm lost unfortunately. I have also tried doing &lt;code&gt;:inoremap &amp;lt;S-BS&amp;gt; &amp;lt;BS&amp;gt;&lt;/code&gt;, but that doesn't seem to be working either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please let me know&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;how to solve this; or,&lt;/li&gt;&#xA;&lt;li&gt;why not to change this if it turns out to be something important; or,&lt;/li&gt;&#xA;&lt;li&gt;why it can't be done for some reason.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Edit: update to responses to u/D. Ben Knoble and u/Ralf&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OS: 18.04&lt;/li&gt;&#xA;&lt;li&gt;Terminal: &lt;a href=&quot;https://mobaxterm.mobatek.net/&quot; rel=&quot;noreferrer&quot;&gt;MobaXterm&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Settings: result of &lt;code&gt;$TERM&lt;/code&gt; is xterm&lt;/li&gt;&#xA;&lt;li&gt;Vim Version: VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 10 2018 21:31:58). Included patches: 1-1453&lt;/li&gt;&#xA;&lt;li&gt;Typing &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;S-BS&amp;gt;&lt;/code&gt; gives '^?'&lt;/li&gt;&#xA;&lt;li&gt;Typing &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;BS&amp;gt;&lt;/code&gt; gives '^H'&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="22957" LastEditorUserId="22957" LastEditDate="2019-07-10T19:21:37.330" LastActivityDate="2019-09-27T09:03:44.397" Title="Pressing Shift-Backspace in insert mode types '^?' instead of backspacing" Tags="|vimrc|key-bindings|terminal|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20577" PostTypeId="1" CreationDate="2019-07-10T15:04:36.120" Score="1" ViewCount="252" Body="&lt;p&gt;When I am developing some python script, I regularly find myself running part of the code to see if it does what I want it to do. Currently I do this by copying the code that I want to run to the clipboard, alt-tabbing to the console and then &lt;code&gt;%paste&lt;/code&gt;ing the code into ipython. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course this procedure is far from ideal, which is why I want to make use of the new &lt;code&gt;:term&lt;/code&gt; and &lt;code&gt;term_sendkeys()&lt;/code&gt;. I can send code to ipython using &lt;code&gt;term_sendkeys()&lt;/code&gt;, but somehow I cannot get ipython to actually run the code. Below is a summary of my steps thus far:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First I start vim 8.1 using &lt;code&gt;vim -u NONE&lt;/code&gt; in a normal command prompt on Windows 7. Then I run &lt;code&gt;:term&lt;/code&gt; to create the terminal buffer. In this buffer I type &lt;code&gt;&amp;lt;c-w&amp;gt;:echo bufnr('%')&amp;lt;cr&amp;gt;&lt;/code&gt; to find the number of the buffer and find that the number is &lt;code&gt;2&lt;/code&gt;. Then I move to the text buffer and run two commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call term_sendkeys(2, &quot;ipython\&amp;lt;cr&amp;gt;&quot;)&#xA;:call term_sendkeys(2, &quot;a=1\&amp;lt;cr&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first starts ipython as expected. The second enters &lt;code&gt;a=1&lt;/code&gt; and a newline. However, when I type the same sequence of keys in ipython hitting enter actual executes the statement instead of starting a new line. I therefore believe that either vim is sending another key than I think it's sending or that ipython treats keys received in this way differently than keys received from the user directly. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="8061" LastActivityDate="2019-07-10T15:04:36.120" Title="send &lt;cr&gt; to ipython in :term" Tags="|terminal-buffer|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20579" PostTypeId="1" CreationDate="2019-07-10T17:13:09.217" Score="1" ViewCount="44" Body="&lt;h1&gt;TL;DR: I want to persist &lt;code&gt;:Man&lt;/code&gt; windows in sessions&lt;/h1&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I am &lt;a href=&quot;https://github.com/tpope/vim-obsession&quot; rel=&quot;nofollow noreferrer&quot;&gt;obsessed&lt;/a&gt; with sessions, and use tpope's vim-obsession for managing them. Coupled with a scripted tmux, sessions make for a perfect &quot;quit, go home, come back&quot; workflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently, I decided to embark on learning perl. Perl wonderfully ships with a massive amount of documentation, all of which is accessible via &lt;code&gt;perldoc&lt;/code&gt;. But, these pages are &lt;em&gt;also&lt;/em&gt; available via manpages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perfect, says I: I can run vim, &lt;code&gt;:Man perl&lt;/code&gt; to view the documentation, then &lt;code&gt;:term&lt;/code&gt; to have a shell for experimenting with the scripts I'm writing as I write them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do this, then &lt;code&gt;:Obsession&lt;/code&gt; to save the session, and quit and restart (&lt;code&gt;vim -S&lt;/code&gt;) to see if it works the way I thought.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the session didn't save my open &lt;code&gt;:Man&lt;/code&gt; window: it's not even present in the &lt;code&gt;Session.vim&lt;/code&gt; code.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I suspect this is a result of &lt;code&gt;:Man&lt;/code&gt; setting &lt;code&gt;'buftype'=nofile&lt;/code&gt;. I also suspect that what I am asking may be fundamentally impossible: I &lt;em&gt;could&lt;/em&gt; edit the session code by hand, but there are so many cases and this is so error prone that even a one-time attempt to script this edit seems... unwieldy. By hand, I'm not even sure I'd know where to start, and it will just get overwritten by the next session save.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Obsession isn't really necessary to try this out yourself; all you need is &lt;code&gt;mksession&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-10T17:13:09.217" Title="Save :Man window in session" Tags="|buffers|sessions|manpages|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20580" PostTypeId="5" CreationDate="2019-07-10T17:18:55.330" Score="0" Body="&lt;h1&gt;Introduction&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Man pages (usually viewed with &lt;code&gt;man(1)&lt;/code&gt;) can be viewed in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to do &lt;code&gt;:runtime ftplugin/man.vim&lt;/code&gt; to make this work (see &lt;code&gt;:help :Man&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can use &lt;code&gt;:Man&lt;/code&gt; to view manpages. You can also set your &lt;code&gt;$MANPAGER&lt;/code&gt; environment variable to &lt;code&gt;vim -M +MANPAGER -&lt;/code&gt; (see &lt;code&gt;:help manpager.vim&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Use this tag if...&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you have questions about using the manpager functionalities of vim&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Do not use this tag if...&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you have questions about &lt;code&gt;man(1)&lt;/code&gt;, other manpagers (such as &lt;code&gt;less(1)&lt;/code&gt;), or the meaning of a specific manpage&lt;/li&gt;&#xA;&lt;li&gt;you have questions about the &lt;code&gt;vim(1)&lt;/code&gt; manpage&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-10T19:08:45.270" LastActivityDate="2019-07-10T19:08:45.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20581" PostTypeId="4" CreationDate="2019-07-10T17:18:55.330" Score="0" Body="For questions about viewing manpages in vim." OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-10T19:08:36.863" LastActivityDate="2019-07-10T19:08:36.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20582" PostTypeId="5" CreationDate="2019-07-10T17:24:04.227" Score="0" Body="&lt;h1&gt;Introduction&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;From vim's &lt;code&gt;:help session&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A Session keeps the Views for all windows, plus the global settings.  You can&#xA;save a Session and when you restore it later the window layout looks the same.&#xA;You can use a Session to quickly switch between different projects,&#xA;automatically loading the files you were last working on in that project.&#xA;&#xA;Views and Sessions are a nice addition to viminfo-files, which are used to&#xA;remember information for all Views and Sessions together |viminfo-file|.&#xA;&#xA;You can quickly start editing with a previously saved View or Session with the&#xA;|-S| argument: &amp;gt;&#xA;    vim -S Session.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can create sessions with &lt;code&gt;mksession&lt;/code&gt;, and they are controlled by &lt;code&gt;'sessionopts'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Use this tag if...&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you have questions about vim's sessions&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Do not use this tag if...&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you have questions relating to the English usage of the word &quot;session&quot;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;a meeting of a deliberative or judicial body to conduct its business&lt;/li&gt;&#xA;  &lt;li&gt;a period devoted to a particular activity: gym is followed by a training session.&lt;/li&gt;&#xA;  &lt;li&gt;the governing body of a Presbyterian Church. &lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;  &#xA;  &lt;p&gt;(source: Apple Dictionary.app)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;you have questions other kinds of sessions (such as &lt;code&gt;tmux(1)&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-10T19:08:42.747" LastActivityDate="2019-07-10T19:08:42.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20583" PostTypeId="4" CreationDate="2019-07-10T17:24:04.227" Score="0" Body="For questions about vim's sessions feature, which persist an editing session to disk for recovery later." OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-10T19:08:33.587" LastActivityDate="2019-07-10T19:08:33.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20584" PostTypeId="1" AcceptedAnswerId="20585" CreationDate="2019-07-10T23:45:59.473" Score="2" ViewCount="229" Body="&lt;p&gt;I'm using Neovim 0.3.7. I have a default session file that loads up a number of files I'm working on at the moment. To save and load the sessions I have the following custom commands defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let sessionlocation = maindir.'/basetest.vim'&#xA;exe 'command Sdfs mks' sessionlocation&#xA;exe 'command Ldfs source' sessionlocation&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This worked fine when I first saved the session. But now I have closed some tabs and opened some new ones and I want the &lt;em&gt;current&lt;/em&gt; file layout to be the default session. When I try to run &lt;code&gt;:Sdfs&lt;/code&gt; I get the error message: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E189 &quot;...&quot; exists (add ! to overwrite)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;...&lt;/code&gt; is the session file directory. That makes sense. But when I run &lt;code&gt;:Sdfs!&lt;/code&gt; I get another error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E447: No ! allowed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I allow &lt;code&gt;!&lt;/code&gt; in my custom command so that I can overwrite my default session file?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="22639" LastActivityDate="2019-07-11T00:01:02.223" Title="! is required but not allowed for custom command" Tags="|sessions|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20585" PostTypeId="2" ParentId="20584" CreationDate="2019-07-11T00:01:02.223" Score="4" Body="&lt;p&gt;&lt;code&gt;E189 &quot;...&quot; exists (add ! to overwrite)&lt;/code&gt; is reported by &lt;a href=&quot;https://vimhelp.org/starting.txt.html#%3Amksession&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :mksession&lt;/a&gt; if session file exists , add &lt;code&gt;!&lt;/code&gt; after &lt;code&gt;mks&lt;/code&gt; should fix that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe 'command Sdfs mks!' sessionlocation&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to pass &lt;code&gt;!&lt;/code&gt; from &lt;code&gt;Sdfs&lt;/code&gt; to &lt;code&gt;mks&lt;/code&gt;, use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe 'command -bang Sdfs mks&amp;lt;bang&amp;gt;' sessionlocation&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Acommand-bang&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :command-bang&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Cbang%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h &amp;lt;bang&amp;gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-07-11T00:01:02.223" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20586" PostTypeId="2" ParentId="20576" CreationDate="2019-07-11T03:09:29.050" Score="6" Body="&lt;p&gt;Typically what you want is for backspace to send &lt;code&gt;^?&lt;/code&gt; and not &lt;code&gt;^H&lt;/code&gt;. (I need a citation, but this is typically how modern terminals work.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like MobaXterm has an &lt;a href=&quot;https://mobaxterm.mobatek.net/documentation.html#3_2_7&quot; rel=&quot;nofollow noreferrer&quot;&gt;option to have backspace send &lt;code&gt;^H&lt;/code&gt;&lt;/a&gt;, I imagine that option is currently set on your MobaXterm, perhaps start by trying to uncheck that option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you should look into why Vim has an impression that &lt;code&gt;^?&lt;/code&gt; is not valid for backspace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps start by checking what Vim thinks the escape sequences for the backspace key is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set t_kb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Normally, this should be &lt;code&gt;^?&lt;/code&gt;, if you have &lt;code&gt;^H&lt;/code&gt;, then check why that might be. Do you have a setting for &lt;code&gt;t_kb&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt; or another sourced file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that still doesn't solve it, you might want to explore these &lt;a href=&quot;https://vim.fandom.com/wiki/Backspace_and_delete_problems&quot; rel=&quot;nofollow noreferrer&quot;&gt;tips on backspace problems&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; OP tracked it down to the version of xterm they were using. Setting &lt;code&gt;t_kb&lt;/code&gt; explicitly in &lt;code&gt;.vimrc&lt;/code&gt; produced a successful workaround for the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quoted by the OP, from the forums of the issue:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Good workaround if you can't/don't want to install a new version of&#xA;  xterm or whatever is to simply go into your .vimrc (in vim) and add&#xA;  the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_kb=^?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Note that you don't want to type '^' and then '?', but rather hit&#xA;  &amp;lt;backspace&gt;; this should create a ^? symbol (or, if you have some&#xA;  similar bug, whatever symbol it thinks is backspace).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="11054" LastEditDate="2019-09-27T09:03:44.397" LastActivityDate="2019-09-27T09:03:44.397" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20587" PostTypeId="2" ParentId="184" CreationDate="2019-07-11T21:33:50.330" Score="2" Body="&lt;p&gt;When I typed &lt;code&gt;:help incsearch&lt;/code&gt;, I found the following in the manual:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc-incsearch-highlight&#xA;  autocmd!&#xA;  autocmd CmdlineEnter /,\? :set hlsearch&#xA;  autocmd CmdlineLeave /,\? :set nohlsearch&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which I resigned to using since other solutions I tried were not perfect and this solution comes &amp;quot;straight from the horse's mouth&amp;quot;, so to speak. It highlights all search matches in the current window. While searching you can use the &lt;code&gt;CTRL-G&lt;/code&gt; and &lt;code&gt;CTRL-T&lt;/code&gt; keys to move to the next and previous match.&lt;/p&gt;&#xA;" OwnerUserId="22751" LastEditorUserId="30860" LastEditDate="2020-08-06T14:47:34.403" LastActivityDate="2020-08-06T14:47:34.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20588" PostTypeId="2" ParentId="20282" CreationDate="2019-07-12T05:43:18.387" Score="1" Body="&lt;p&gt;You can customize the section that includes line and column information in vim-airline by &lt;a href=&quot;https://github.com/vim-airline/vim-airline/blob/v0.10/doc/airline.txt#L336&quot; rel=&quot;nofollow noreferrer&quot;&gt;setting the &lt;code&gt;airline_section_z&lt;/code&gt; variable&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's not really a direct escape sequence for the total number of columns in the current line, but you can use an expression &lt;code&gt;%{...}&lt;/code&gt; which gets evaluated by &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27statusline%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'statusline'&lt;/code&gt;&lt;/a&gt; (see the documentation on the &lt;code&gt;{ NF&lt;/code&gt; item.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an expression, you can use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#col()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;col()&lt;/code&gt; function&lt;/a&gt;, in particular, you can use &lt;code&gt;col(&quot;$&quot;)-1&lt;/code&gt; which evaluates to the total number of bytes in the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, setting &lt;code&gt;airline_section_z&lt;/code&gt; isn't that convenient, since when you do that, you override the default set by vim-airline itself, so you need to fully set it to all that you want to include.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you want to preserve whatever was already there, you'll want to query it on Vim before any changes and then set it in your &lt;code&gt;~/.vimrc&lt;/code&gt; to include whatever it was set to in addition to the modifications you would like to introduce.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in my case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:airline_section_z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Returns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g:airline_section_z    %3p%% %#__accent_bold#%{g:airline_symbols.linenr}%4l%#__restore__#%#__accent_bold#/%L%{g:airline_symbols.maxlinenr}%#__restore__# :%3v&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I can customize it to add the column number in my &lt;code&gt;~/.vimrc&lt;/code&gt; using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline_section_z = '%3p%% %#__accent_bold#%{g:airline_symbols.linenr}%4l%#__restore__#%#__accent_bold#/%L%{g:airline_symbols.maxlinenr}%#__restore__# :%3v/%03{col(&quot;$&quot;)-1}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where I added a &lt;code&gt;/%03{col(&quot;$&quot;)-1}&lt;/code&gt; to the end of the string previously set by default by vim-airline itself. (The &lt;code&gt;%03{...}&lt;/code&gt; shows the total column count with width 3 and leading zeroes.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, you mentioned using &lt;code&gt;:&lt;/code&gt; as a separator, so you might be considering further customizations to &lt;code&gt;airline_section_z&lt;/code&gt;, in which case this might be more acceptable to you.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-12T05:43:18.387" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20589" PostTypeId="1" CreationDate="2019-07-12T08:28:55.523" Score="0" ViewCount="140" Body="&lt;p&gt;When I press &lt;kbd&gt;C-o&lt;/kbd&gt; in insert mode, the expected behaviour is that vim will wait for me to execute a single command and then returns to insert mode. Usually, after pressing &lt;kbd&gt;C-o&lt;/kbd&gt; I have all the time in the world to enter the command. However, with my current setup the temporary normal mode triggered by &lt;kbd&gt;C-o&lt;/kbd&gt; only lasts for a second and then falls back to regular insert mode. I have narrowed the problem down to the &lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;coc.vim&lt;/a&gt; plugin so it probably has to do with how autocompletion works. Could there be, for instance, an option to increase the time vim waits before returning back to insert mode?&lt;/p&gt;&#xA;" OwnerUserId="7784" LastActivityDate="2019-07-12T08:28:55.523" Title="Temporary normal mode doesn't wait for the command" Tags="|autocompletion|insert-mode|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20591" PostTypeId="1" CreationDate="2019-07-12T10:55:43.373" Score="0" ViewCount="115" Body="&lt;p&gt;only the vim app can't show the Chinese right. I have checked the encoding, fileencoding and fileencodings configs, all of them are utf-8 at the first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/X831Z.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/X831Z.jpg&quot; alt=&quot;first is vim app, second is notepad of mac, third is vim in my iterm&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22985" LastActivityDate="2019-07-12T10:55:43.373" Title="My vim can't print Chinese right on my mac?" Tags="|encoding|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20592" PostTypeId="2" ParentId="20299" CreationDate="2019-07-12T13:15:19.670" Score="0" Body="&lt;p&gt;You can bind some keys in insert mode to move to the next word like vim-rsi plugin does making vim readline binding aware or use built-in arrow keys. This would be dot repeatable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can &lt;code&gt;RWed&amp;lt;C-o&amp;gt;/11&amp;lt;CR&amp;gt;12&lt;/code&gt; to replace Tue to Wed, goto normal mode for a single command, search for 11 and continue replacing 11 to 12. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your example though I would just go for &lt;code&gt;cwWed&amp;lt;ESC&amp;gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; -- change word Tue to Wed and increase next number by 1. But that is not dot repeatable.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-07-12T13:20:41.413" LastActivityDate="2019-07-12T13:20:41.413" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20593" PostTypeId="1" AcceptedAnswerId="20594" CreationDate="2019-07-12T14:19:48.847" Score="1" ViewCount="49" Body="&lt;p&gt;Ubuntu is my OS, and I have the Latex-Suite plugin installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to get pdflatex to output a .pdf file instead of a .dvi file, but it continues to output only a .dvi file (along with .log and .aux files, which I realize are &lt;a href=&quot;https://tex.stackexchange.com/questions/11123/prevent-pdflatex-from-writing-a-bunch-of-files&quot;&gt;unavoidable&lt;/a&gt;). I am also trying to output to an existing ./test directory, which it is also failing to do. Here are my settings (I realize there are probably redundancies, I was pretty much just trying everything I could find):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &quot; Latex-Suite ----------------------------&#xA;&#xA;&quot; Starting with Vim 7, the filetype of empty .tex files defaults to&#xA;&quot; 'plaintex' instead of 'tex', which results in vim-latex not being loaded.&#xA;&quot; The following changes the default filetype back to 'tex':&#xA;let g:tex_flavor = 'latex'&#xA;&#xA;&quot; Setting viewing rules based on document type&#xA;let g:Tex_ViewRule_dvi = 'xdvi'&#xA;let g:Tex_ViewRule_ps = 'ghostview'&#xA;let g:Tex_ViewRule_pdf = 'xpdf'&#xA;&#xA;let g:Tex_FormatDependency_pdf = 'dvi,ps,pdf'&#xA;let g:Tex_defaultTargetFormat = 'pdf'&#xA;&#xA;let g:Tex_CompileRule_pdf = 'pdflatex --interaction=nonstopmode --output-directory=./test --output-format=pdf $*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd appreciate any help (or letting me know if this question is better suited for the Latex StackExchange)!&lt;/p&gt;&#xA;" OwnerUserId="22987" LastEditorUserId="1292" LastEditDate="2019-07-12T14:42:34.167" LastActivityDate="2019-07-16T15:50:34.947" Title="Adjusting pdflatex settings" Tags="|plugin-vim-latex|" AnswerCount="1" CommentCount="0" ClosedDate="2019-07-15T09:39:53.723" ContentLicense="CC BY-SA 4.0" />
  <row Id="20594" PostTypeId="2" ParentId="20593" CreationDate="2019-07-12T14:42:23.103" Score="1" Body="&lt;p&gt;Vimscript is case-sensitive. Typo in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Tex_defaultTargetFormat = 'pdf'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Tex_DefaultTargetFormat = 'pdf'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: Does someone know a place in vim help which states explicitly that vimscript is case-sensitive?&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2019-07-16T15:50:34.947" LastActivityDate="2019-07-16T15:50:34.947" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20595" PostTypeId="1" AcceptedAnswerId="20599" CreationDate="2019-07-12T21:26:31.267" Score="2" ViewCount="89" Body="&lt;p&gt;Currently I have my vim set up to update the statuslline based on what mode the editor is in.  Like if I'm in insert mode then the statusline turns red.  Magenta in replace mode.  Green in command mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; statusline setup&#xA;set laststatus=2&#xA;set statusline=\&#xA;    \ %F\ \|\ %h%w%m%r\ \|\ %=%(\|\ L\:\ %l\ \|\ C\:\ %c%V\ \|\ %=\ %P\ %)&#xA;hi statusline cterm=none ctermbg=green ctermfg=black&#xA;function! InsertStatuslineColor(mode)&#xA;    if a:mode=='i'&#xA;        hi statusline ctermbg=red&#xA;    elseif a:mode=='r'&#xA;        hi statusline ctermbg=magenta&#xA;    else&#xA;        hi statusline ctermbg=red&#xA;    endif&#xA;endfunction&#xA;au InsertEnter * call InsertStatuslineColor(v:insertmode)&#xA;au InsertChange * call InsertStatuslineColor(v:insertmode)&#xA;au InsertLeave * hi statusline ctermbg=green&#xA;hi statusline ctermbg=green&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to know if it's possible have vim update an external file based on what mode the editor is currently in.  For instance, is it possible to have it change the statusline color and then also perform a shell command in the background?  My ultimate goal here is to have my led backlit keyboard match the color of the statusline.  I can achieve these color switches via cli like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;FF00FF&quot; &amp;gt; /sys/class/leds/system76::kbd_backlight/color_left&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to work this into my .vimrc to achieve my goal or nah?&lt;/p&gt;&#xA;" OwnerUserId="22993" LastEditorUserId="22993" LastEditDate="2019-07-12T21:52:27.083" LastActivityDate="2019-07-13T13:05:37.853" Title="Update external file based on VIM mode" Tags="|vimrc|vimscript|external-command|linux-ubuntu|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20596" PostTypeId="1" CreationDate="2019-07-13T00:27:28.703" Score="1" ViewCount="154" Body="&lt;p&gt;I was wondering if it was possible to scroll (left or right) along the status line so that the content (which could not be displayed due to the size of the window) could be seen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps there is a key combination that allows this, something like &lt;code&gt;Control+E&lt;/code&gt; and &lt;code&gt;Control+Y&lt;/code&gt; (key combinations that allow you to move through the content of the file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Complete statusline&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZMtZ9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZMtZ9.png&quot; alt=&quot;Complete statusline&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incomplete statusline&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tGPGJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tGPGJ.png&quot; alt=&quot;Incomplete statusline&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22995" LastActivityDate="2019-07-13T00:27:28.703" Title="Is there a keybinding that allows to scroll through the status line?" Tags="|statusline|scrolling|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20597" PostTypeId="1" AcceptedAnswerId="20598" CreationDate="2019-07-13T00:39:47.640" Score="3" ViewCount="879" Body="&lt;p&gt;For a new filetype, I was trying to make block comments in the syntax highlighting but they kept disappearing while I was moving around.  I have managed to reduce it to the following.  First, in the syntax file, there is just this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region testComment start=/a/ end=/b/&#xA;hi def link testComment Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my file created to highlight (pun not intended) the problem, I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&#xA;()&#xA; (&#xA;&#xA;)&#xA;(&#xA;)&#xA;b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to the rule, the entire file should be colored like a comment, and it does normally.  However, when moving the cursor down through the whole file while staying on the first column, once I hit the final set of parentheses, the last three visible characters ('&lt;code&gt;(&lt;/code&gt;', '&lt;code&gt;)&lt;/code&gt;', and '&lt;code&gt;b&lt;/code&gt;') are un-colored.  This can be fixed in the moment by redrawing the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed that the &lt;code&gt;matchparen&lt;/code&gt; plugin is involved.  While moving the cursor down, the first set of parentheses is matched correctly, the second set is not matched, and then when the third set should be matched is when the color goes off.  Disabling the plugin through &lt;code&gt;:NoMatchParen&lt;/code&gt; makes the problem not appear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Several things cause the problem not to happen.  If I remove the empty line it works.  If I go to the second opening parenthesis on the way down it works.  If I remove the empty line but add an extra space before the second close parenthesis, the problem comes back.  It seems like the plugin has a hard time reading the second set of parentheses and then freaks out on the third one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am pretty sure this is a bug in the matchparen plugin.  However, block comments work just fine in other languages, like C.  So, my final question is this: &lt;strong&gt;How can I change my syntax file to make this problem not happen, maybe similarly to how C does it?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have Vim 8.1.&lt;/p&gt;&#xA;" OwnerUserId="22994" LastEditorUserId="4472" LastEditDate="2019-07-19T20:02:43.810" LastActivityDate="2019-07-19T20:22:35.287" Title="Syntax highlighting region messed up by matching parentheses" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20598" PostTypeId="2" ParentId="20597" CreationDate="2019-07-13T01:09:11.803" Score="3" Body="&lt;p&gt;When parentheses are highlighted and unhighlighted vim needs to re-synchronize the syntax highlighting.  What is happening is vim doesn't know the lines are inside a comment because it tries to avoid looking backwards if it doesn't need to.  See &lt;a href=&quot;https://vimhelp.org/syntax.txt.html#%3Asyn-sync&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :syn-sync&lt;/code&gt;&lt;/a&gt;.  There are four methods available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest method is using &lt;code&gt;syntax sync fromstart&lt;/code&gt;, but this makes syntax highlighting slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second method is literally hardwired for C comments (&lt;code&gt;/* */&lt;/code&gt;) and will only work for them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third method is similar to &lt;code&gt;fromstart&lt;/code&gt;, except looks back a certain number of lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax sync minlines=50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The fourth method works when you have start and end delimiters like a and b:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax sync match startComment groupthere testComment &quot;a&quot;&#xA;:syntax sync match endComment groupthere NONE &quot;b&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are more complex uses shown in the help.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2019-07-19T20:22:35.287" LastActivityDate="2019-07-19T20:22:35.287" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20599" PostTypeId="2" ParentId="20595" CreationDate="2019-07-13T05:34:15.453" Score="1" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#writefile%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;writefile()&lt;/a&gt; function to write to an external file from a Vimscript function or mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Using external shell commands through &lt;code&gt;!&lt;/code&gt; or the system() function would be another possibility, but sticking to a native feature of Vim is probably better.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider that you'll need to have permissions to write to the aforementioned file from Vim under the user you're running Vim as, I'm not sure whether that will be the case or whether that driver will only allow root to write to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that, if you have multiple instances of Vim running and all are using the same mappings, they're likely to fight each other on setting your keyboard lights...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like the below (based on your original code) might work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:keyboard_backlight_controller = '/sys/class/leds/system76::kbd_backlight/color_left'&#xA;function! InsertStatuslineColor(mode)&#xA;    if a:mode=='i'&#xA;        hi statusline ctermbg=red&#xA;        call writefile(['FF0000'], g:keyboard_backlight_controller)&#xA;    elseif a:mode=='r'&#xA;        hi statusline ctermbg=magenta&#xA;        call writefile(['FF00FF'], g:keyboard_backlight_controller)&#xA;    else&#xA;        hi statusline ctermbg=red&#xA;        call writefile(['FF0000'], g:keyboard_backlight_controller)&#xA;    endif&#xA;endfunction&#xA;function! NormalStatuslineColor()&#xA;    hi statusline ctermbg=green&#xA;    call writefile(['00FF00'], g:keyboard_backlight_controller)&#xA;endfunction&#xA;au InsertEnter * call InsertStatuslineColor(v:insertmode)&#xA;au InsertChange * call InsertStatuslineColor(v:insertmode)&#xA;au InsertLeave * call NormalStatuslineColor()&#xA;call NormalStatuslineColor()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-07-13T13:05:37.853" LastActivityDate="2019-07-13T13:05:37.853" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20602" PostTypeId="2" ParentId="2904" CreationDate="2019-07-13T09:47:16.440" Score="8" Body="&lt;h3&gt;Commands &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Abufdo&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:bufdo&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#%3Avimgrepadd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:vimgrepadd&lt;/code&gt;&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;This answer is based on &lt;a href=&quot;https://stackoverflow.com/a/11976158/1057593&quot;&gt;https://stackoverflow.com/a/11976158/1057593&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, I wanted add a few bits. Again the basic command is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:bufdo vimgrepadd pattern %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If your quickfix list is not empty, you probably want to clear it first. This can be done with &lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#E777&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:cexpr&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:cexpr []&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Mappings to cycle through matches&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-unimpaired&lt;/a&gt; provides the mappings &lt;code&gt;]q&lt;/code&gt; and &lt;code&gt;[q&lt;/code&gt; to cycle through the matches.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Workflow with the command line history&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is a convenient workflow to enter the search pattern separately with &lt;code&gt;/pattern&lt;/code&gt;. This allows you to use a generic command from your command line history using the current search pattern. This would look like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/pattern&#xA;:bufdo vimgrepadd // %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A typical new buffer wide search would be&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/pattern2&#xA;:bufdo&amp;lt;up&amp;gt;&amp;lt;up&amp;gt;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have added following mappings to my vimrc to use &lt;code&gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-P&amp;gt;&lt;/code&gt; instead of the arrow keys to stay with my hands on the home row&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cmap &amp;lt;C-P&amp;gt; &amp;lt;Up&amp;gt;&#xA;cmap &amp;lt;C-N&amp;gt; &amp;lt;Down&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note searching the command line history &lt;code&gt;q:&lt;/code&gt; with &lt;code&gt;/bufdo&amp;lt;CR&amp;gt;&lt;/code&gt; interferes with using the current search pattern. You could use &lt;code&gt;:keepp /bufdo&amp;lt;cr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For more details on the command line history see the help pages &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#history&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h history&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#cmdline-window&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h cmdline-window&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vim.fandom.com/wiki/Using_command-line_history&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vim.fandom.com/wiki/Using_command-line_history&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can add to the reusable command &lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#%3Acopen&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:copen&lt;/code&gt;&lt;/a&gt; to immediately see the quickfix list in the following way:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:execute &amp;quot;bufdo vimgrepadd // %&amp;quot; | copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The proposal from stackoverflow &lt;code&gt;:bufdo vimgrepadd // % | copen&lt;/code&gt; opened several unintended windows in my case.&lt;/p&gt;&#xA;&lt;p&gt;And with &lt;code&gt;:cexpr []&lt;/code&gt; the reusable command would become&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:execute &amp;quot;cexpr [] | bufdo vimgrepadd // %&amp;quot; | copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2021-03-23T07:31:59.497" LastActivityDate="2021-03-23T07:31:59.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20603" PostTypeId="1" CreationDate="2019-07-13T15:17:41.460" Score="0" ViewCount="110" Body="&lt;p&gt;Wondering why this happens, if it is a bug or supposed to happen?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps to reproduce:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;open vim, &lt;/li&gt;&#xA;&lt;li&gt;split two windows, one with netrw and another with few lines of text (line numbers enabled).&lt;/li&gt;&#xA;&lt;li&gt;As both of them are open, click any number on the line numbers column, the buffer will clear.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The interesting part is, this doesn't happen on NeoVim.&lt;/p&gt;&#xA;" OwnerUserId="22998" LastEditorUserId="205" LastEditDate="2019-07-16T08:18:24.997" LastActivityDate="2019-07-16T08:18:24.997" Title="When openning netrw in split view, the opened buffer I'm still editing clears when I click a line number" Tags="|netrw|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20605" PostTypeId="1" CreationDate="2019-07-14T02:17:40.713" Score="4" ViewCount="2943" Body="&lt;p&gt;I can use the &lt;code&gt;finddir&lt;/code&gt; function to find a parent folder that contains a &lt;code&gt;.git&lt;/code&gt; folder (project root), like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let dir = finddir('.git/..', ';')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this only finds project roots that are parent folders of Vim's current working directory, which is usually the directory Vim was started in. I would like to find project roots that are parent folders of the location of the currently active buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I tried     &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let dir = finddir('.git/..', expand('%').';')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this always returns the current directory for some reason.&lt;/p&gt;&#xA;" OwnerUserId="23001" LastEditorUserId="23001" LastEditDate="2019-07-14T17:23:51.280" LastActivityDate="2019-07-14T17:54:21.527" Title="Find project root relative to the active buffer" Tags="|vimscript|filesystem|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20606" PostTypeId="2" ParentId="20605" CreationDate="2019-07-14T04:29:17.203" Score="11" Body="&lt;p&gt;After following dedowsdi's instructions, it turns out you just need to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let dir = finddir('.git/..', expand('%:p:h').';')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;expand(%)&lt;/code&gt; expands into the path of the current file (excluding the filename).&lt;/p&gt;&#xA;" OwnerUserId="23001" LastEditorUserId="23001" LastEditDate="2019-07-14T17:54:21.527" LastActivityDate="2019-07-14T17:54:21.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20607" PostTypeId="1" CreationDate="2019-07-14T08:43:34.743" Score="0" ViewCount="408" Body="&lt;p&gt;I tried searching for this on the internet but I get bombarded with answers saying to &lt;code&gt;:so $MYVIMRC&lt;/code&gt;which does not work if I add lines of the type &lt;code&gt;autocmd FileType foo bar&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's a more efficient way to apply the effects instead of opening &lt;code&gt;.vimrc&lt;/code&gt;, closing vim and then opening the file I was editing again?&lt;/p&gt;&#xA;" OwnerUserId="21104" LastEditorUserId="51" LastEditDate="2022-09-23T11:09:04.137" LastActivityDate="2022-09-23T11:09:04.137" Title="Reload vim autocmd Filetype" Tags="|vimrc|autocmd|" AnswerCount="1" CommentCount="0" ClosedDate="2019-07-18T14:14:51.200" ContentLicense="CC BY-SA 4.0" />
  <row Id="20608" PostTypeId="2" ParentId="20607" CreationDate="2019-07-14T09:39:47.083" Score="0" Body="&lt;p&gt;&lt;code&gt;FileType&lt;/code&gt; autocommands are triggered when the &lt;code&gt;filetype&lt;/code&gt; option is &lt;strong&gt;set&lt;/strong&gt;. Hence to reload an &lt;code&gt;autocmd&lt;/code&gt; you added/edited, after &lt;code&gt;:so $MYVIMRC&lt;/code&gt;, you should do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ft=&amp;lt;your filetype&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;on the target file.&#xA;As a mapping to do that automatically :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;leader&amp;gt;rft :exe ':set filetype='.&amp;amp;filetype&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22929" LastActivityDate="2019-07-14T09:39:47.083" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20609" PostTypeId="1" AcceptedAnswerId="20615" CreationDate="2019-07-14T10:35:42.180" Score="3" ViewCount="663" Body="&lt;p&gt;I notice a different behavior in command line completion from the regular completion in a buffer. Usually even if I select and item from the completion menu, CTRL-E  cancels the completion and reverts whatever text was inserted due to it. However that's not the case for me in command line completion. There if I press CTRL-E the suggestion list closes but it also leaves whatever text was selected last. I want to be able to leave completion while keeping the original text I have entered before it.&lt;/p&gt;&#xA;" OwnerUserId="15048" LastActivityDate="2019-07-14T22:28:23.693" Title="Cancel command line completion insert" Tags="|autocompletion|ins-completion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20610" PostTypeId="1" AcceptedAnswerId="20614" CreationDate="2019-07-14T13:31:58.133" Score="2" ViewCount="529" Body="&lt;p&gt;Is there a way to add some buffer space between the vertical separator and the content of a file in vertical split mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to say this:&#xA;How do I force vim to not let a line touch a vertical separator. Yes, line wrapping is on. I do not want the line to touch the vertical separator, nor the edge of the screen if it is on the right split.&lt;/p&gt;&#xA;" OwnerUserId="23004" LastEditorUserId="23004" LastEditDate="2019-07-14T13:43:07.737" LastActivityDate="2019-07-14T17:52:45.240" Title="Add buffer space on line wraps" Tags="|vimrc|split|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20611" PostTypeId="2" ParentId="20610" CreationDate="2019-07-14T13:38:15.853" Score="0" Body="&lt;p&gt;Quick thoughts:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If the lines are too long, try &lt;code&gt;set wrap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;You could also resize the window with the resizing commands (e.g. &lt;code&gt;&amp;lt;C-w&amp;gt;&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-14T13:38:15.853" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20612" PostTypeId="1" AcceptedAnswerId="20613" CreationDate="2019-07-14T16:27:33.493" Score="2" ViewCount="855" Body="&lt;p&gt;I have a function in Vim script that returns a string.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Return first directory with &quot;.git&quot; folder, if none is found&#xA;&quot; return the current directory&#xA;function! s:project_root()&#xA;      for vcs in ['.git']&#xA;          let dir = finddir(vcs.'/..', expand('%:p:h').';')&#xA;          if !empty(dir)&#xA;              return dir&#xA;          endif&#xA;      endfor&#xA;      &quot; If there is no root dir use the current dir&#xA;      return expand('%:p:h')&#xA;  endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to use this function in a key mapping as the argument to a command called &lt;code&gt;Files&lt;/code&gt;. So something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;f :Files&amp;lt;Space&amp;gt;&amp;lt;insert result of function call here&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'nnoremap &amp;lt;leader&amp;gt;f :Files&amp;lt;Space&amp;gt;'.s:project_root()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I believe this only calls the function once (when the .vimrc is loaded), when I need the function to be called everytime the keybinding is pressed.&lt;/p&gt;&#xA;" OwnerUserId="23001" LastEditorUserId="23001" LastEditDate="2019-07-14T17:54:39.840" LastActivityDate="2019-07-14T17:54:39.840" Title="How to use the result of a function in a Vim keymap?" Tags="|vimrc|vimscript|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20613" PostTypeId="2" ParentId="20612" CreationDate="2019-07-14T17:14:21.570" Score="4" Body="&lt;p&gt;Do the &lt;code&gt;:execute&lt;/code&gt; inside your mapping instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't need to use &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; in mappings, you can just use an actual space instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably want to include a &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; at the end, to actually execute the &lt;code&gt;:Files&lt;/code&gt; command and not leave it pending on the command line waiting for you to press enter (but, again, maybe that's what you want?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;f :execute 'Files '.&amp;lt;SID&amp;gt;project_root()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-07-14T17:20:33.277" LastActivityDate="2019-07-14T17:20:33.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20614" PostTypeId="2" ParentId="20610" CreationDate="2019-07-14T17:52:45.240" Score="3" Body="&lt;p&gt;This is perhaps not &lt;em&gt;exactly&lt;/em&gt; what you're looking for, but setting &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27linebreak%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;the &lt;code&gt;'linebreak'&lt;/code&gt; option&lt;/a&gt; adds enough whitespace to the right margin to create enough of a visual buffer, when &lt;code&gt;'wrap'&lt;/code&gt; is enabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically, it will insert at least one space before the end of a wrapped line. If a word would end exactly at the margin, adding a space will move it to the next line. One of the few exceptions where a word &lt;em&gt;can&lt;/em&gt; touch the right margin is if it's the last word in a line (so no wrapping occurs there.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully this will be close enough to what you're looking for.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-14T17:52:45.240" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20615" PostTypeId="2" ParentId="20609" CreationDate="2019-07-14T22:28:23.693" Score="3" Body="&lt;p&gt;The insert mode completion menu and the command-line completion menu are two different beasts. They behave differently in many ways, in particular a keystroke to cancel completion and return to the original word is only available in the insert mode completion menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/insert.txt.html#ins-completion&quot; rel=&quot;nofollow noreferrer&quot;&gt;insert mode completion menu&lt;/a&gt; is typically invoked with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;P&lt;/kbd&gt; or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;N&lt;/kbd&gt; (or some of the more specialized keys looking at filenames, tags, etc.), it is displayed vertically close to where the cursor is inserting text, and &lt;a href=&quot;https://vimhelp.org/insert.txt.html#complete_CTRL-E&quot; rel=&quot;nofollow noreferrer&quot;&gt;the &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;E&lt;/kbd&gt; keystroke&lt;/a&gt; is available to cancel completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#cmdline-completion&quot; rel=&quot;nofollow noreferrer&quot;&gt;command-line completion menu&lt;/a&gt; (invoked by &lt;kbd&gt;Tab&lt;/kbd&gt;, or whatever &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27wildchar%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'wildchar'&lt;/code&gt;&lt;/a&gt; is set to), is typically displayed horizontally and uses different keystrokes or key bindings than the insert completion menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#cmdline-completion&quot; rel=&quot;nofollow noreferrer&quot;&gt;command-line completion menu&lt;/a&gt; doesn't really have any key binding to cancel completion and return to the original word. In fact, Vim help on command-line completion is quite specific on that point, as this snippet shows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When repeating &lt;code&gt;'wildchar'&lt;/code&gt; or &lt;code&gt;CTRL-N&lt;/code&gt; you cycle through the matches, eventually&#xA;  ending up back to what was typed.  &lt;strong&gt;If the first match is not what you wanted,&#xA;  you can use &lt;code&gt;&amp;lt;S-Tab&amp;gt;&lt;/code&gt; or &lt;code&gt;CTRL-P&lt;/code&gt; to go straight back to what you typed.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, short of cycling back to the start or cycling all the way to the end, there's no other way to cancel and go back to the text before completion started in command-line completion.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-14T22:28:23.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20616" PostTypeId="1" AcceptedAnswerId="20617" CreationDate="2019-07-15T08:11:11.640" Score="3" ViewCount="283" Body="&lt;p&gt;It seems that there is an issue with window-resize with Quickfix list window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case of regular window and quickfix list window, how to make them equal in high? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;kbd&gt;CTRL-W&lt;/kbd&gt;&lt;kbd&gt;-&lt;/kbd&gt; (and the &lt;kbd&gt;CTRL-W&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt;) works, but &lt;kbd&gt;CTRL-W&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt; - doesn't work! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Observed in GVIM 8.1 for Windows&lt;/p&gt;&#xA;" OwnerUserId="21649" LastActivityDate="2019-07-15T09:42:46.537" Title="How to make two windows equally high?" Tags="|quickfix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20617" PostTypeId="2" ParentId="20616" CreationDate="2019-07-15T09:28:15.727" Score="2" Body="&lt;p&gt;&lt;code&gt;:h winfixheight&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h copen&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quickfix window sets &lt;code&gt;winfixheight&lt;/code&gt; and 10 lines height by default. &lt;code&gt;winfixheight&lt;/code&gt; is local to window and makes it not respect your &lt;code&gt;&amp;lt;c-w&amp;gt;=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is to create an autocmd for quickfix window that will &lt;code&gt;set nowinfixheight&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;smth like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! BufWinEnter *Quickfix* setlocal nowinfixheight &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then after &lt;code&gt;:copen&lt;/code&gt; and &lt;code&gt;C-W =&lt;/code&gt; you will have 2 equal windows.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-07-15T09:42:46.537" LastActivityDate="2019-07-15T09:42:46.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20618" PostTypeId="2" ParentId="20603" CreationDate="2019-07-15T17:50:09.287" Score="2" Body="&lt;p&gt;I've been able to reproduce this, and here's what's happening.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Setup&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open vim&lt;/li&gt;&#xA;&lt;li&gt;Type a few lines of text&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:Sexplore&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;With the focus on netrw, click on the buffer with text (esp. on the line numbers).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That buffer switches to a new buffer (generally named after the line you clicked on).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Why?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;netrw&lt;/code&gt; maps &lt;code&gt;&amp;lt;LeftMouse&amp;gt;&lt;/code&gt; to call the scriptlocal function &lt;code&gt;NetrwLeftmouse(1)&lt;/code&gt;. This function is responsible for editing the files you click on. It tries to abort if you don't click in the window (&lt;code&gt;if ... || v:mouse_win != winnr()&lt;/code&gt;), but I believe by the time this executes the mouse window and &lt;code&gt;winnr()&lt;/code&gt; have been aligned (the mapping actually performs a regular &lt;code&gt;&amp;lt;LeftMouse&amp;gt;&lt;/code&gt; first, so focus has already changed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function happily carries on and edits a new buffer. &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; is sometimes enough to get you back, but because the function uses &lt;code&gt;NetrwKeepj&lt;/code&gt;, the jumplist doesn't change, so &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; may not suffice.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Solutions&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Don't use the mouse in netrw (easy to give up, but might accidentally still get you). Combine with unmapping the mouse keys in &lt;code&gt;netrw&lt;/code&gt; (in &lt;code&gt;~/.vim/after/ftplugin/netrw.vim&lt;/code&gt; for example) for maximum effect.&lt;/li&gt;&#xA;&lt;li&gt;??? This would require a serious patch for a strange edge case, and I'm not quite sure how to do it yet.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-15T17:50:09.287" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20619" PostTypeId="1" AcceptedAnswerId="20625" CreationDate="2019-07-15T17:51:15.733" Score="1" ViewCount="763" Body="&lt;p&gt;I'd like to maximize NERDTree when I enter the NERDTree buffer. The command I have so far is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufEnter NERD_tree_* &amp;lt;A&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...but the &lt;code&gt;&amp;lt;A&amp;gt;&lt;/code&gt; part is wrong. I get the error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;E21: Cannot make changes, 'modifiable' is off: &amp;lt;A&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The maximize command is &lt;code&gt;shift-A&lt;/code&gt;, and there's not any type of &lt;code&gt;:NERDTreeMaximize&lt;/code&gt; command - I can't figure out what to put as the final step of that &lt;code&gt;BufEnter&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated, thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I used a combination of the answers below to come up with this snippet, that maximizes on enter, and sets back to regular size when you leave the nerdtree buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function NERDTreeMaximize()    &#xA;  if !exists(&quot;b:NERDTreeZoomed&quot;) || !b:NERDTreeZoomed    &#xA;    call NERDTreeMaximizeToggle()                                        &#xA;  endif                                                                      &#xA;endfunction                                                                  &#xA;&#xA;function NERDTreeMinimize()                                                  &#xA;  if exists(&quot;b:NERDTreeZoomed&quot;) &amp;amp;&amp;amp; b:NERDTreeZoomed    &#xA;    call NERDTreeMaximizeToggle()    &#xA;  endif                                                                      &#xA;endfunction                                                                  &#xA;&#xA;function NERDTreeMaximizeToggle()                                            &#xA;  call b:NERDTree.ui.toggleZoom()                                            &#xA;endfunction                                                                  &#xA;&#xA;augroup vimrc_nerdtree                                                       &#xA;  autocmd BufEnter NERD_tree_* :call NERDTreeMaximize()    &#xA;  autocmd BufLeave NERD_tree_* :call NERDTreeMinimize()    &#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure of the etiquette here, but I'll upvote all answers, and choose one as the correct one - I want everyone to get as many internet points as possible. Thanks to all!&lt;/p&gt;&#xA;" OwnerUserId="6900" LastEditorUserId="21062" LastEditDate="2019-08-06T20:02:55.087" LastActivityDate="2019-08-06T20:02:55.087" Title="NERDTree maximize on enter" Tags="|autocmd|functions|plugin-nerdtree|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20620" PostTypeId="1" AcceptedAnswerId="26773" CreationDate="2019-07-15T21:30:11.450" Score="2" ViewCount="917" Body="&lt;p&gt;In visual studio, that code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int x=0;x&amp;lt;10;x++)&#xA;{}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes that code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int x = 0; x &amp;lt; 10; x++)&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as soon as you hit enter.&#xA;I was wondering, is it possible, and if so, how can I make so vim does the same ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance !&lt;/p&gt;&#xA;" OwnerUserId="23021" LastActivityDate="2020-08-09T15:23:50.437" Title="Format / Indent c++ as you type inside expressions" Tags="|indentation|formatting|filetype-c++|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20621" PostTypeId="2" ParentId="15584" CreationDate="2019-07-15T21:57:46.847" Score="2" Body="&lt;p&gt;Based off Trevor's answer, I made the following commands for dealing with swap files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;LEADER&amp;gt;s &amp;lt;C-w&amp;gt;o:sav! ~/.vim/.recovered&amp;lt;CR&amp;gt;:vs&amp;lt;CR&amp;gt;&amp;lt;C-w&amp;gt;w:bn&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;LEADER&amp;gt;t  :wa&amp;lt;CR&amp;gt;:bp\|bd #&amp;lt;CR&amp;gt;&amp;lt;C-o&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Upon reaching the &lt;code&gt;ATTENTION: Found a swap file...&lt;/code&gt; prompt, I &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;type &lt;code&gt;r&lt;/code&gt; to recover the swap&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;&amp;lt;LEADER&amp;gt;s&lt;/code&gt; to save the swapped version as &lt;code&gt;.recovered&lt;/code&gt; and open the original in a new split&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;e&lt;/code&gt; at the swap prompt to edit the original file&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;:windo diffthis&lt;/code&gt; to diff the two files&lt;/li&gt;&#xA;&lt;li&gt;make any necessary changes to the original&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;&amp;lt;LEADER&amp;gt;t&lt;/code&gt; to write the original file, close it, and reopen it&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;d&lt;/code&gt; at the swap prompt to delete the swap file&lt;/li&gt;&#xA;&lt;li&gt;close the &lt;code&gt;.recovered&lt;/code&gt; file (typing something like &lt;code&gt;:bp&amp;lt;CR&amp;gt;:bp\|bd #&amp;lt;CR&amp;gt;&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18504" LastEditorUserId="18504" LastEditDate="2019-07-15T22:25:07.507" LastActivityDate="2019-07-15T22:25:07.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20622" PostTypeId="1" AcceptedAnswerId="20624" CreationDate="2019-07-15T22:31:40.500" Score="2" ViewCount="285" Body="&lt;p&gt;I'm trying to edit my init.vim to allow quick, custom retabbing with one key. My current attempt is as follows (the replace text in the last command is a tab character inputted in insert mode):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-i&amp;gt; :%s/\s\+$//ge&amp;lt;CR&amp;gt;:%s/ \{2,}/ /ge&amp;lt;CR&amp;gt;&#xA;vmap &amp;lt;C-i&amp;gt; :'&amp;lt;,'&amp;gt;s/\s\+$//ge&amp;lt;CR&amp;gt;:'&amp;lt;,'&amp;gt;s/ \{2,}/ /ge&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The normal mode map works perfectly, but I can't figure out why the visual map doesn't. The only thing it does is report:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E488: Trailing characters&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why doesn't the visual map work the same way as the normal mode map, and is what I'm attempting impossible?&lt;/p&gt;&#xA;" OwnerUserId="23022" LastActivityDate="2019-07-15T23:27:10.677" Title="How do I map multiple replace commands in visual mode" Tags="|visual-mode|replace|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20623" PostTypeId="2" ParentId="20619" CreationDate="2019-07-15T23:24:09.897" Score="1" Body="&lt;p&gt;Try &lt;code&gt;normal A&lt;/code&gt; in your autocommand&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-16T00:00:36.160" LastActivityDate="2019-07-16T00:00:36.160" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20624" PostTypeId="2" ParentId="20622" CreationDate="2019-07-15T23:27:10.677" Score="3" Body="&lt;p&gt;The &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; in your first command get inserted automatically when entering &lt;code&gt;:&lt;/code&gt; from visual mode. Remove them. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-15T23:27:10.677" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20625" PostTypeId="2" ParentId="20619" CreationDate="2019-07-16T00:16:14.093" Score="2" Body="&lt;p&gt;TL;DR: You can use this auto-command to maximize the width of your NERDTree window when opened:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType nerdtree let b:NERDTreeZoomed = 1 | wincmd |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can consider increasing the width of the window by setting the &lt;code&gt;g:NERDTreeWinSize&lt;/code&gt; variable to a higher value (defaults to 30), you can set it to something very high to get the same effect as maximizing it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:NERDTreeWinSize = 99999&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;First let's look at what's wrong with your command. &lt;code&gt;autocmd&lt;/code&gt; takes an actual command (as in, one you start with &lt;code&gt;:&lt;/code&gt;), so if you want to run a normal command (such as &lt;code&gt;A&lt;/code&gt;, which has a special key-binding), you need to use the &lt;code&gt;:normal&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter NERD_tree_* normal A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't really work though, first because the buffer only gets a &lt;code&gt;NERD_tree_*&lt;/code&gt; name after it's created and entered (so the &lt;code&gt;BufEnter&lt;/code&gt; event will not happen right after you open the NERDTree window) and also because the &lt;code&gt;BufEnter&lt;/code&gt; event &lt;em&gt;will&lt;/em&gt; trigger every other time you enter the NERDTree window (so it will toggle zoom every time you enter it again!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better event is &lt;code&gt;FileType&lt;/code&gt;, which is set to &lt;code&gt;nerdtree&lt;/code&gt; on the NERDTree window and that is done only once, so you can use that event to trigger the zooming you want. So you'd think this would work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType nerdtree normal A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alas, it doesn't. Probably because the &lt;code&gt;A&lt;/code&gt; binding was still not set by NERDTree at the time this auto-command happens. So what it's probably doing here is an &quot;append&quot;, which is the default keybinding for &lt;code&gt;A&lt;/code&gt;, but without any text, so a no-op overall...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I found it's possible to get something to a similar effect by just using the equivalent of &lt;code&gt;&amp;lt;C-w&amp;gt;|&lt;/code&gt;, which maximizes the window horizontally. There is &lt;code&gt;:wincmd&lt;/code&gt; which allows accessing these &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; commands conveniently from normal mode, so this one works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType nerdtree wincmd |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This solution still has a small shortcoming in that it's expanding the window width but not using NERDTree's &quot;zoom&quot; command, so the first time you use the &lt;code&gt;A&lt;/code&gt; command from within NERDTree nothing will happen (it will &quot;zoom&quot; the window, but it will look the same.) The second time you do so, you will successfully &quot;unzoom&quot; it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can actually fix this by setting a buffer variable used by NERDTree to control whether the window is zoomed or not. The complete autocmd including setting the variable would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType nerdtree let b:NERDTreeZoomed = 1 | wincmd |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, &lt;code&gt;autocmd&lt;/code&gt;s should live in their &lt;code&gt;augroup&lt;/code&gt; (always, that is), so make sure you create an appropriate &lt;code&gt;augroup&lt;/code&gt; or reuse one you might have in your &lt;code&gt;.vimrc&lt;/code&gt; for this kind of customizations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc_nerdtree&#xA;  autocmd!&#xA;  autocmd FileType nerdtree let b:NERDTreeZoomed = 1 | wincmd |&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, NERDTree has a configuration variable to set the initial width of the window, so setting that one is also a possibility. If all you want is a &lt;em&gt;larger&lt;/em&gt; window (not necessarily maximized), just increase it from 30 to something more reasonable such as 50 or 60 or whatever you prefer. If you want it maximized, just set it to something much higher than the number of columns you might have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:NERDTreeWinSize = 99999&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This solution (with a very large window size) has the issue with &lt;code&gt;A&lt;/code&gt; no longer working as expected, just like the previous solution. In fact, in this case zooming and un-zooming with repeated &lt;code&gt;A&lt;/code&gt;s won't do a thing, since the &quot;unzoomed&quot; size of the window is already as large as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a smaller window size but larger than the default of 30 might be a good alternative, since you'll get more than you get by default but still be able to &quot;zoom&quot; and &quot;unzoom&quot; if you need to see more.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-07-16T15:40:06.970" LastActivityDate="2019-07-16T15:40:06.970" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="20626" PostTypeId="2" ParentId="20619" CreationDate="2019-07-16T02:26:06.297" Score="1" Body="&lt;p&gt;This is one of those tricky scenarios where you can't be sure whether something is fully initialized at the time an autocommand is invoked. A hack is to delay some arbitrary amount of time before doing whatever it is you want to do. Slightly less hacky is to delay a bit, try, if it fails delay/try again some limited number of times. If no joy then give up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Combining that with knowledge of the function actually used to do zooms we could try something like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! NerdMax(timerid)&#xA;  if !exists(&quot;b:NERDTree&quot;)&#xA;      &quot;echoerr &quot;The plugin isn't initialized yet&quot;&#xA;      return&#xA;  endif&#xA;&#xA;  if !exists(&quot;b:NERDTreeZoomed&quot;) || b:NERDTreeZoomed == 0&#xA;      call b:NERDTree.ui.toggleZoom()&#xA;  else&#xA;      &quot;echom &quot;NERDTree is already zoomed&quot;&#xA;  endif&#xA;&#xA;  &quot; Prevent any further calls&#xA;  call timer_stop(a:timerid)&#xA;endfunc&#xA;&#xA;augroup nerdmax&#xA;  autocmd!&#xA;  autocmd FileType nerdtree call timer_start(500, 'NerdMax', {'repeat': 3})&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to do the trick for me though one annoyance that I haven't explored yet is that &#xA;sometimes the zoomed state doesn't take up the entire width. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Based on my observations so far we might not actually need an artificial delay. It may be enough that we're executing the function in a different thread/context. Perhaps everything is allowed to finish initializing before Vim starts doing timer calls. If this is the actual reality (and I've seen similar behavior before) then everything could be reduced to...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! NerdMax(timerid)&#xA;  if !exists(&quot;b:NERDTreeZoomed&quot;) || b:NERDTreeZoomed == 0&#xA;      call b:NERDTree.ui.toggleZoom()&#xA;  endif&#xA;endfunc&#xA;&#xA;augroup nerdmax&#xA;  autocmd!&#xA;  autocmd FileType nerdtree call timer_start(50, 'NerdMax')&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Come to think of it, now we can just use &lt;code&gt;norm A&lt;/code&gt; instead of the &lt;code&gt;toggleZoom()&lt;/code&gt; call!)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-07-16T03:01:16.640" LastActivityDate="2019-07-16T03:01:16.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20628" PostTypeId="1" AcceptedAnswerId="20633" CreationDate="2019-07-16T04:41:00.960" Score="1" ViewCount="2959" Body="&lt;p&gt;Is there a plugin which autocompletes C/C++ code from specific headers given in a specific path (i.e. &lt;code&gt;/path/&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I include some headers from that path, I would get autocompletion from given header.&lt;/p&gt;&#xA;" OwnerUserId="23025" LastEditorUserId="1841" LastEditDate="2019-07-16T08:00:26.377" LastActivityDate="2019-07-16T12:03:39.210" Title="Autocompletion plugin for c/c++ with specific header path?" Tags="|autocompletion|filetype-c++|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20629" PostTypeId="2" ParentId="20369" CreationDate="2019-07-16T05:14:11.103" Score="1" Body="&lt;p&gt;I am a Neovim user and have been using Neoivm for about a year. Neovim is initially a fork of Vim and is actively maintained by a few maintainers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you can not notice an apparent difference as a normal user. After all, Neovim is trying to be compatible with Vim. Neovim does have differences with Vim: different default options, new features, removed features, new architecture, etc. For complete documentation on the differences between Neovim and Vim. Open Neovim and use &lt;code&gt;:h vim-differences&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for plugins, it is a subjective topic. Even if you are minimalist, you may want to install a few plugins to enhance your experience with Neovim. Personally, I use more than 60 plugins and I use vim-plug to control when the plugins should be activated.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-07-16T05:14:11.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20630" PostTypeId="1" CreationDate="2019-07-16T08:32:21.413" Score="1" ViewCount="596" Body="&lt;p&gt;I have tried without any luck, but can anyone kindly let me know if &lt;code&gt;di&lt;/code&gt; is possible for language like vim/fortran which has structure like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   do loop&#xA;      Something&#xA;   end do&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; command &lt;code&gt;di', di&quot;, di{, di[, di(&lt;/code&gt; delete content inside the given surround. So, consider the given code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Program  i&#xA;Implicit None&#xA;if (&amp;lt;some condition&amp;gt;) then&#xA;  text for if block&#xA;end if  &#xA;End Program  i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if my cursor is inside &lt;code&gt;(&amp;lt;some condition&amp;gt;)&lt;/code&gt;, and do &lt;code&gt;di(&lt;/code&gt;, in normal mode, then &lt;code&gt;&amp;lt;some condition&amp;gt;&lt;/code&gt; will be deleted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I am looking for some similar thing, when my cursor is inside if block, and I can delete &lt;code&gt;text for if block&lt;/code&gt;!&lt;/p&gt;&#xA;" OwnerUserId="2738" LastEditorUserId="2738" LastEditDate="2019-07-16T09:59:03.760" LastActivityDate="2019-07-16T11:07:09.180" Title="di in vim/fortran" Tags="|vimscript|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20631" PostTypeId="2" ParentId="20630" CreationDate="2019-07-16T11:07:09.180" Score="1" Body="&lt;p&gt;Consider using the &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=3037&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-indent-object&lt;/a&gt; plug-in, which allows you to select or delete blocks based on indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As long as your indentation is correct (and that should be easy, since Vim has good Fortran plug-ins to indent your code correctly and the built-in Fortran indentation plugin works well enough), the vim-indent-object motions can accomplish what you describe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using a plug-in manager such as vim-plug (or Vundle), you can have them install the plug-in directly with something like &lt;code&gt;Plug '&lt;a href=&quot;https://github.com/michaeljsmith/vim-indent-object&quot; rel=&quot;nofollow noreferrer&quot;&gt;michaeljsmith/vim-indent-object&lt;/a&gt;'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After you have it installed, you can use the &lt;strong&gt;&lt;code&gt;ii&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;aI&lt;/code&gt;&lt;/strong&gt; motions in your Fortran code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming this block in your code sample:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (&amp;lt;some condition&amp;gt;) then&#xA;  text for if block&#xA;end if  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And your cursor is in the first line of the block (the &lt;code&gt;if (...) then&lt;/code&gt; line), then you can use &lt;strong&gt;&lt;code&gt;dii&lt;/code&gt;&lt;/strong&gt; command (&quot;delete inside indent&quot;) to delete the block inside the &lt;code&gt;if&lt;/code&gt;, which in your example means &lt;code&gt;text for if block&lt;/code&gt;. (Of course, this becomes more useful as there are more lines of code and further indentation within that block, which this plug-in should handle nicely.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also useful is the &lt;strong&gt;&lt;code&gt;daI&lt;/code&gt;&lt;/strong&gt; command (&quot;delete around indent&quot;, note uppercase &lt;code&gt;I&lt;/code&gt;) to delete the indented block, but also the current line and one line below the block with indentation matching the current line. This is useful in Fortran, to include the matching &lt;code&gt;end if&lt;/code&gt; or &lt;code&gt;end do&lt;/code&gt; line. In your example, this would delete the three lines of code, the &lt;code&gt;if (...) then&lt;/code&gt; line, then the indented &lt;code&gt;text for if block&lt;/code&gt; and finally the &lt;code&gt;end if&lt;/code&gt; block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you can use these text objects with other operations than &quot;delete&quot;, for instance &lt;strong&gt;&lt;code&gt;Vii&lt;/code&gt;&lt;/strong&gt; to visually select the indented block.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-16T11:07:09.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20632" PostTypeId="2" ParentId="20620" CreationDate="2019-07-16T11:48:05.240" Score="1" Body="&lt;p&gt;I used the plugin &lt;a href=&quot;https://github.com/rhysd/vim-clang-format.git&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/rhysd/vim-clang-format.git&lt;/a&gt;&#xA;and added those lines to my vimrc :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Clang formater things :&#xA;let g:clang_format#style_options = {&#xA;            \ &quot;BreakBeforeBraces&quot; : &quot;Allman&quot;,&#xA;            \ &quot;AccessModifierOffset&quot; : -4,&#xA;            \ &quot;AllowShortIfStatementsOnASingleLine&quot; : &quot;true&quot;,&#xA;            \ &quot;AlwaysBreakTemplateDeclarations&quot; : &quot;true&quot;,&#xA;            \ &quot;Standard&quot; : &quot;C++11&quot;}&#xA;&#xA;&quot; map to &amp;lt;Leader&amp;gt;cf in C++ code&#xA;autocmd FileType c,cpp,objc nnoremap &amp;lt;buffer&amp;gt;&amp;lt;Leader&amp;gt;cf:&amp;lt;Cu&amp;gt;ClangFormat&amp;lt;CR&amp;gt;&#xA;autocmd FileType c,cpp,objc vnoremap &amp;lt;buffer&amp;gt;&amp;lt;Leader&amp;gt;cf :ClangFormat&amp;lt;CR&amp;gt;&#xA;&quot; if you install vim-operator-user&#xA;autocmd FileType c,cpp,objc map &amp;lt;buffer&amp;gt;&amp;lt;Leader&amp;gt;x &amp;lt;Plug&amp;gt;(operator-clang-format)&#xA;&quot; Toggle auto formatting:&#xA;nmap &amp;lt;Leader&amp;gt;C :ClangFormatAutoToggle&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23021" LastActivityDate="2019-07-16T11:48:05.240" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20633" PostTypeId="2" ParentId="20628" CreationDate="2019-07-16T12:03:39.210" Score="3" Body="&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;: Set &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27path%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'path'&lt;/code&gt;&lt;/a&gt; to include the path to your include files. In your example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path+=/path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Native completion from include files&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Vim native completion is quite useful for C and C++ files, Vim can search for your include files and find candidate completion targets in them and the defaults in Vim are already pretty useful for Vim completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;code&gt;CTRL-X CTRL-I&lt;/code&gt; sequence to initiate &lt;a href=&quot;https://vimhelp.org/insert.txt.html#compl-keyword&quot; rel=&quot;nofollow noreferrer&quot;&gt;keyword completion&lt;/a&gt;, completing keywords in the current and include files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;CTRL-X CTRL-D&lt;/code&gt; to initiate &lt;a href=&quot;https://vimhelp.org/insert.txt.html#compl-define&quot; rel=&quot;nofollow noreferrer&quot;&gt;define completion&lt;/a&gt;, completing macros and defines in the current and include files.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;set path&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The important option to customize for these is &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27path%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'path'&lt;/code&gt;&lt;/a&gt;, which tells Vim where to search for include files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, Vim will search the directory where the file lives (if you're editing &lt;code&gt;src/submodule/xyz.c&lt;/code&gt;, then it will search under &lt;code&gt;src/submodule&lt;/code&gt; first), the system include directory (&lt;code&gt;/usr/include&lt;/code&gt;) and the current directory (which might typically be the root of your project.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to add paths to this setting, basically any include path you're passing the compiler through a &lt;code&gt;-I&lt;/code&gt; flag should be of interest here.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Other relevant settings&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Also relevant are &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27include%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'include'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27define%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'define'&lt;/code&gt;&lt;/a&gt;, which hold patterns (regexps) used to detect &lt;code&gt;#include&lt;/code&gt; and &lt;code&gt;#define&lt;/code&gt; directives used for the aforementioned completion commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27includeexpr%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'includeexpr'&lt;/code&gt;&lt;/a&gt;, which can be used to translate an include to a file name (useful for languages in which submodule paths are separated by &lt;code&gt;.&lt;/code&gt; rather than &lt;code&gt;/&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are already correctly set for C/C++ by default, so you typically don't need to set these unless you're working with a different language.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Other useful commands for include files&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;There are other commands that can become very useful once &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27path%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'path'&lt;/code&gt;&lt;/a&gt; is set correctly to find your include files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, see &lt;a href=&quot;https://vimhelp.org/tagsrch.txt.html#include-search&quot; rel=&quot;nofollow noreferrer&quot;&gt;include file search&lt;/a&gt; for commands such as &lt;code&gt;[i&lt;/code&gt; and &lt;code&gt;[d&lt;/code&gt; which will show you the first occurrence of a keyword (or a define) and &lt;em&gt;will go inside include files&lt;/em&gt; whenever it sees an &lt;code&gt;#include&lt;/code&gt; directive. This can be quite powerful, as a quick way to check a function prototype wherever it's declared.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/editing.txt.html#gf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;gf&lt;/code&gt;&lt;/a&gt; command can be used from an &lt;code&gt;#include&lt;/code&gt; line to open that header file. The &lt;a href=&quot;https://vimhelp.org/editing.txt.html#%3Afind&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:find&lt;/code&gt;&lt;/a&gt; command can be used to open an include file (or really any file under &lt;code&gt;'path'&lt;/code&gt;) by name.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-16T12:03:39.210" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20634" PostTypeId="1" AcceptedAnswerId="20635" CreationDate="2019-07-16T13:52:28.873" Score="4" ViewCount="1663" Body="&lt;p&gt;I want to create a command that will place my gvim window to a different &quot;x&quot; location on my screen while maintaining the &quot;y&quot; position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do this in my _gvimrc by calling&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;winpos 319 16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to create a function &lt;code&gt;WinRight&lt;/code&gt; that will put my window on the right side of the screen, but this doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! WinRight()&#xA;    let ypos=getwinposy()&#xA;    winpos 1241 ypos&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I &lt;code&gt;:call WinRight()&lt;/code&gt;, I get &quot;E466 :winpos requires two number arguments&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function works if I substitute a number for &lt;code&gt;ypos&lt;/code&gt;.  Why doesn't my use of the variable &lt;code&gt;ypos&lt;/code&gt; work here though?&lt;/p&gt;&#xA;" OwnerUserId="23033" LastActivityDate="2019-07-18T19:46:43.177" Title="Gvim - Change window position horizontally" Tags="|gvim|functions|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20635" PostTypeId="2" ParentId="20634" CreationDate="2019-07-16T14:17:09.833" Score="3" Body="&lt;p&gt;Use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:execute&lt;/code&gt;&lt;/a&gt; to assemble a command from a string, which allows you to include the contents of a variable or return value from a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! WinRight()&#xA;    let ypos=getwinposy()&#xA;    execute &quot;winpos 1241 &quot;.ypos&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! WinRight()&#xA;    execute &quot;winpos 1241 &quot;.getwinposy()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-16T14:17:09.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20636" PostTypeId="1" CreationDate="2019-07-16T19:01:23.853" Score="0" ViewCount="1133" Body="&lt;p&gt;I’m trying to run &lt;a href=&quot;https://fennel-lang.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fennel&lt;/a&gt; scripts in Vim 8.1 using the &lt;a href=&quot;https://github.com/jaawerth/fennel-nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fennel-nvim&lt;/a&gt; plugin. (Fennel is a language that basically lets you write Lua with LISP syntax; you can use it from any Lua-supporting application by dropping in a single Lua file.) The fennel-nvim package is obviously written with Neovim in mind, but I thought maybe it would be simple enough to get it working with Vim anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I’m using the &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt; plugin manager. When I add the line &lt;code&gt;Plug 'jaawerth/fennel-nvim'&lt;/code&gt; to my vimrc, I get the following error when starting Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/bdesham/.vim/plugged/fennel-nvim/plugin/fnl.vim:&#xA;line    1:&#xA;[string &quot;vim chunk&quot;]:1: module 'patch_searcher' not found:&#xA;^Ino field package.preload['patch_searcher']&#xA;^Ino file '/usr/share/lua/5.2/patch_searcher.lua'&#xA;^Ino file '/usr/share/lua/5.2/patch_searcher/init.lua'&#xA;^Ino file '/usr/lib/lua/5.2/patch_searcher.lua'&#xA;^Ino file '/usr/lib/lua/5.2/patch_searcher/init.lua'&#xA;^Ino file './patch_searcher.lua'&#xA;^Ino file '/usr/lib/lua/5.2/patch_searcher.so'&#xA;^Ino file '/usr/lib/lua/5.2/loadall.so'&#xA;^Ino file './patch_searcher.so'&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The offending line is the first line of &lt;code&gt;fnl.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lua require(&quot;patch_searcher&quot;)()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The plugin does come with a file called patch_searcher.lua:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fennel-nvim&#xA;├── FENNEL-LICENSE&#xA;├── .gitignore&#xA;├── LICENSE&#xA;├── lua&#xA;│   ├── fennel.lua&#xA;│   ├── fennelview.lua&#xA;│   └── patch_searcher.lua&#xA;├── plugin&#xA;│   └── fnl.vim&#xA;└── README.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It &lt;em&gt;seems&lt;/em&gt; like I might be able to get this plugin to work with Vim if I can tell the embedded Lua interpreter to add this directory to its “search path,” or whatever this is called in Lua. How can I go about doing that?&lt;/p&gt;&#xA;" OwnerUserId="671" LastActivityDate="2019-07-16T19:01:23.853" Title="Adding directories to Lua’s search path" Tags="|vimscript-lua|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20637" PostTypeId="1" AcceptedAnswerId="20639" CreationDate="2019-07-16T20:55:20.880" Score="3" ViewCount="359" Body="&lt;p&gt;I have a job that produces output continually. I want to write this output to a Vim buffer. I start it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let job = job_start(cmd, { 'out_io': 'buffer', 'out_name': 'joboutput' })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I can't see the job's output as it's produced-- I only see the first line &quot;Reading from channel output...&quot;. Only when I call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call job_stop(job)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will I see the rest of the output, which is all written to the buffer. So it appears that the job's output is buffered by the OS before I can see it, and stopping the job causes it to be flushed. Is there a way to have Vim continually update the output buffer, the way it would appear if I ran the same job (i.e. process) in a terminal?&lt;/p&gt;&#xA;" OwnerUserId="13151" LastActivityDate="2019-07-17T00:22:07.657" Title="Job continuously outputting to Vim buffer" Tags="|job-control|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20638" PostTypeId="2" ParentId="18073" CreationDate="2019-07-16T21:59:24.713" Score="2" Body="&lt;p&gt;According to &lt;a href=&quot;https://github.com/neovim/neovim/wiki/FAQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;neovim Wiki FAQ&lt;/a&gt; and &lt;a href=&quot;https://github.com/neovim/neovim/issues/1750&quot; rel=&quot;nofollow noreferrer&quot;&gt;Issue #1750&lt;/a&gt;, client-server / remote feature was removed in Neovim.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, &lt;a href=&quot;https://github.com/mhinz/neovim-remote&quot; rel=&quot;nofollow noreferrer&quot;&gt;neovim-remote&lt;/a&gt; can be used.  After installing it (&lt;code&gt;pip3 install neovim-remote&lt;/code&gt;), launch &lt;code&gt;nvim&lt;/code&gt; like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ NVIM_LISTEN_ADDRESS=/tmp/nvimsocket nvim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And open files remotely&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ nvr --remote file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21762" LastActivityDate="2019-07-16T21:59:24.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20639" PostTypeId="2" ParentId="20637" CreationDate="2019-07-17T00:22:07.657" Score="6" Body="&lt;p&gt;This is almost surely happening because the output from &lt;code&gt;cmd&lt;/code&gt; is getting buffered when being sent to a pipe, so until you get enough of it (a few kilobytes), Vim won't really receive any.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A very simple fix for this, that will work in most cases, is to have Vim use a &lt;strong&gt;pty&lt;/strong&gt; instead of a pipe to communicate with the external job. The standard library in Linux/Unix will typically set up output to be unbuffered when writing to a terminal, so using a pty is a good fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do that by including &lt;code&gt;'pty': 1&lt;/code&gt; as part of the job options.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let job = job_start(cmd, { 'out_io': 'buffer', 'out_name': 'joboutput', 'pty': 1 })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See documentation for &lt;a href=&quot;https://vimhelp.org/channel.txt.html#job-options&quot; rel=&quot;noreferrer&quot;&gt;job options&lt;/a&gt;, which includes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;pty&quot;: 1                Use a pty (pseudo-tty) instead of a pipe when&#xA;                        possible.  This is most useful in combination with a&#xA;                        terminal window, see terminal.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can make sure your external &lt;code&gt;cmd&lt;/code&gt; will use unbuffered output, for which there are some options depending on what &lt;code&gt;cmd&lt;/code&gt; is. If it's a C program, then &lt;a href=&quot;https://linux.die.net/man/1/stdbuf&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;stdbuf&lt;/code&gt;&lt;/a&gt; is usually an option, if it's a Python program, then using &lt;code&gt;python -u&lt;/code&gt; or setting the &lt;code&gt;PYTHONUNBUFFERED=1&lt;/code&gt; environment variable works. Some of the solutions (such as &lt;a href=&quot;https://linux.die.net/man/1/unbuffer&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;unbuffer&lt;/code&gt;&lt;/a&gt;) &lt;em&gt;actually&lt;/em&gt; use a pty wrapper. (Search Unix&amp;amp;Linux StackExchange and you'll find tons of answers about buffered output!)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-17T00:22:07.657" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20640" PostTypeId="2" ParentId="5514" CreationDate="2019-07-17T00:57:54.747" Score="4" Body="&lt;p&gt;The Vim FAQ has a well formatted list:&#xA;&lt;a href=&quot;https://vimhelp.org/vim_faq.txt.html#faq-1.4&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vimhelp.org/vim_faq.txt.html#faq-1.4&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Excerpt from the FAQ:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Multi-level undo &lt;/li&gt;&#xA;&lt;li&gt;Tabs, Multiple windows and buffers &lt;/li&gt;&#xA;&lt;li&gt;Flexible insert mode (can use arrow keys in Insert Mode)&lt;/li&gt;&#xA;&lt;li&gt;Macros &lt;/li&gt;&#xA;&lt;li&gt;Visual mode (visually select sections of text)&lt;/li&gt;&#xA;&lt;li&gt;Block operators &lt;/li&gt;&#xA;&lt;li&gt;Online help system &lt;/li&gt;&#xA;&lt;li&gt;Command-line editing and history &lt;/li&gt;&#xA;&lt;li&gt;Command line completion (tab completion)&lt;/li&gt;&#xA;&lt;li&gt;Horizontal scrolling (long lines) &lt;/li&gt;&#xA;&lt;li&gt;Unicode and internationalization improvements. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6610" LastActivityDate="2019-07-17T00:57:54.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20641" PostTypeId="1" CreationDate="2019-07-17T05:11:37.200" Score="3" ViewCount="110" Body="&lt;h3&gt;Situation&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Entire &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap a &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Action: user types &lt;code&gt;ia&lt;/code&gt; to enter insert mode and type &lt;code&gt;a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Expected result: a carriage return is entered into the document&lt;/li&gt;&#xA;&lt;li&gt;Actual result: the characters &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; are typed&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've discovered that &lt;code&gt;a&lt;/code&gt; can be any sequence of characters, and &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; can be&#xA;any special character denoted with &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt;, and this behavior still persists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I swear it wasn't doing this a few days ago.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Origin&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Specifically, I'm trying to include in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap {&amp;lt;CR&amp;gt; {&amp;lt;CR&amp;gt;}&amp;lt;Esc&amp;gt;ko&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it did not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To debug, I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap { {&amp;lt;CR&amp;gt;}&amp;lt;Esc&amp;gt;ko&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so Vim did not have to listen for any enter keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When Vim typed out &lt;code&gt;{&amp;lt;CR&amp;gt;}&amp;lt;Esc&amp;gt;ko&lt;/code&gt; in my document, I became aware of the nature&#xA;of the issue.  I believe Vim never activated the initial map because it did not&#xA;receive the set of characters &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; after the &lt;code&gt;{&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Netrw also stopped receiving the enter key and Vim just goes to the next line&#xA;when I intend to select a directory.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;About my setup&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I'm operating a relatively fresh install of Arch Linux, running off of a&#xA;bootable USB flash drive.  The USB flash drive is plugged into a standard Dell&#xA;latitude E5510 laptop with Windows 7 on the hard drive, though it is not being&#xA;used.  However, when I use the Windows 7 on the hard drive and use Vim, this&#xA;problem does not occur.  The problem occurs both in the system's console, and in&#xA;XTerm in i3wm, whether the &quot;VT220 Keyboard&quot; setting is turned on or off, whether&#xA;&quot;Old Function Keys&quot; is on or off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3FGPK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3FGPK.jpg&quot; alt=&quot;NeoFetch output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19097" LastEditorUserId="10604" LastEditDate="2020-03-27T14:32:17.200" LastActivityDate="2020-08-24T15:03:00.257" Title="Maps literally read &lt; and &gt; instead of the actual character" Tags="|vimrc|linux|key-bindings|linux-arch|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20642" PostTypeId="1" CreationDate="2019-07-17T08:07:58.580" Score="1" ViewCount="336" Body="&lt;p&gt;I've got a pretty large log file with some info interleaved with some errors / warnings and I would like to go to the next error in my quickfix window but without jumping to that location in the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment I've got a dirty hack that basically consist in doing &lt;code&gt;:cnext &amp;lt;C-o&amp;gt;&lt;/code&gt; but that's not ideal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any cleaner alternative ? &#xA;I was thinking about something with &lt;code&gt;getqflist&lt;/code&gt; and &lt;code&gt;setqflist&lt;/code&gt; to get the current position and increment it, but I have only managed to go to the next line in the log (Which might just be plain text), whereas I want the next error. (So I probably need to iterate over the valid entries in the quickfix window but I haven't figured out how to do that yet)&lt;/p&gt;&#xA;" OwnerUserId="23048" LastActivityDate="2021-09-21T13:12:17.807" Title=":cnext / :cprevious without jumping to location" Tags="|quickfix|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20643" PostTypeId="1" AcceptedAnswerId="20645" CreationDate="2019-07-17T11:41:45.057" Score="5" ViewCount="5713" Body="&lt;p&gt;Recently I found out that vim has added the :terminal command which opens a terminal buffer within vim, however I see no way to enter normal mode so that I can move around and copy things. Neovim has it as \n. Is there an equivalent in vim which lets me switch to normal mode?&lt;/p&gt;&#xA;" OwnerUserId="12408" LastActivityDate="2019-07-23T16:22:15.810" Title="How to enter normal mode while in terminal buffer?" Tags="|terminal|normal-mode|" AnswerCount="1" CommentCount="1" ClosedDate="2020-07-01T15:54:11.777" ContentLicense="CC BY-SA 4.0" />
  <row Id="20644" PostTypeId="1" AcceptedAnswerId="20646" CreationDate="2019-07-17T11:53:05.257" Score="1" ViewCount="717" Body="&lt;p&gt;new VIM user. I'm trying to make creating python properties easier for my class definitions. What I would like for say I type&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:pyp x&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then VIM will autofill where my cursor is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@property&#xA;def x(self):&#xA;   return self.x&#xA;@property.setter&#xA;   def x(self,val):&#xA;      self._x = val&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or more abstractly I type&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:pyp &amp;lt;property_name&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and VIM fills&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@property&#xA;def &amp;lt;property_name&amp;gt;(self):&#xA;   return self.&amp;lt;property_name&amp;gt;&#xA;@property.setter&#xA;   def &amp;lt;property_name&amp;gt;(self,val):&#xA;      self._&amp;lt;property_name&amp;gt; = val&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've looked at a few posts and the wikis on functions, macros but I'm very unsure of how to go about it or what to even look up as I am brand new VIM user, less than a week old. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using &lt;a href=&quot;https://vi.stackexchange.com/questions/9644/how-to-use-a-variable-in-the-expression-of-a-normal-command&quot;&gt;this&lt;/a&gt; as an example, in my .vimrc but I couldn't even get that to work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the system I am working on, its very very difficult if not impossible to get pluggins so I have to do stuff through my vimrc or other method. Basically trying to get a plugin installed could take half a year. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the code I am currently trying is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PythonProperty(prop_name)&#xA; let cur_line = line('.')&#xA; let num_spaces = indent('.')&#xA; let spaces = repeat(' ',num_spaces)&#xA; let lines = [ spaces.&quot;@property&quot;,&#xA;             \ spaces.&quot;def &quot;.prop_name.&quot;(self):&quot;,&#xA;             \ spaces.&quot;   return self.&quot;.property,&#xA;             \ spaces.&quot;@property.setter&quot;,&#xA;             \ spaces.&quot;def&quot;.prop_name.&quot;(self,val)&quot;,&#xA;             \ spaces.&quot;   self._&quot;.prop_name.&quot; = val&quot; ]&#xA; call append(cur_line,lines)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I am getting the errors&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E121: Undefined variable: prop_name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am typing&#xA;&lt;code&gt;:call PythonProperty(&quot;x&quot;)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="23052" LastEditorUserId="23052" LastEditDate="2019-07-17T15:24:21.583" LastActivityDate="2019-07-17T16:28:11.220" Title="VIM command to insert multiline text with argument" Tags="|functions|text-generation|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20645" PostTypeId="2" ParentId="20643" CreationDate="2019-07-17T12:37:21.190" Score="5" Body="&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#t_CTRL-W_N&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Ctrl-W N&lt;/code&gt;&lt;/a&gt; to enter normal mode from the terminal. (That's &lt;code&gt;Ctrl-W Shift+N&lt;/code&gt;, for an uppercase &lt;code&gt;N&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also possible to use &lt;code&gt;Ctrl-\ Ctrl-N&lt;/code&gt;, which might be easier to type (thanks @D.BenKnoble for the comment.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks @ChristianBrabandt for the tip on &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#terminal-use&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help terminal-use&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12408" LastEditorUserId="18609" LastEditDate="2019-07-23T16:22:15.810" LastActivityDate="2019-07-23T16:22:15.810" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20646" PostTypeId="2" ParentId="20644" CreationDate="2019-07-17T12:38:48.617" Score="2" Body="&lt;p&gt;Define a list of all the lines you want to insert, and then insert them with either &lt;code&gt;append()&lt;/code&gt; or &lt;code&gt;setline()&lt;/code&gt;. You'll also need to extract the current indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#List&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h List&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#setline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h setline()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#append%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h append()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#indent%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h indent()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;PS: half a year is almost the time we spent on validating our snippet plugins...&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2019-07-17T12:38:48.617" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20647" PostTypeId="2" ParentId="20642" CreationDate="2019-07-17T13:05:33.097" Score="2" Body="&lt;pre&gt;&lt;code&gt;function! s:next_error()&#xA;  let wv = winsaveview()&#xA;  keepjumps cnext&#xA;  call winrestview(wv)&#xA;  copen&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the only problem of your approach is that it changed the &lt;a href=&quot;https://vimhelp.org/motion.txt.html#jumplist&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h jumplist&lt;/a&gt; , you can use &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%3Akeepjumps&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :keepjumps&lt;/a&gt; to avoid that. But your cursor position still get changed after &lt;code&gt;keepjump cnext&lt;/code&gt;, you window might also get scrolled, to restore that, use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#winsaveview%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h winsaveview()&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/eval.txt.html#winrestview%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h winrestview()&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It's unpleasent to do this with &lt;code&gt;getqflist()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:next_error2()&#xA;&#xA;  &quot; return if current qflist empty&#xA;  let qfl = getqflist()&#xA;  if empty(qfl)&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; find next valid error&#xA;  let idx = getqflist({'idx':0}).idx&#xA;  let next_idx = 0&#xA;  while idx &amp;lt; len(qfl)&#xA;    if qfl[idx].valid&#xA;      let next_idx = idx + 1&#xA;      break&#xA;    endif&#xA;    let idx += 1&#xA;  endwhile&#xA;&#xA;  &quot; return if there has no next valid error&#xA;  if !next_idx&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; open qf, jump to next error line&#xA;  copen&#xA;  exe next_idx&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this approach jump to next &lt;code&gt;valid&lt;/code&gt; error, i'm not sure if it's exactly the same as &lt;code&gt;cnext&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-07-17T13:23:35.640" LastActivityDate="2019-07-17T13:23:35.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20648" PostTypeId="2" ParentId="20644" CreationDate="2019-07-17T16:28:11.220" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;the system I am working on, its very very difficult if not impossible to get pluggins so I have to do stuff through my vimrc or other method. Basically trying to get a plugin installed could take half a year.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Please note that you don't need to install plug-ins system wide and they can live completely inside your home directory (under &lt;code&gt;~/.vim&lt;/code&gt; more exactly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A plug-in manager such as &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt; can be installed by downloading a single file to &lt;code&gt;~/.vim/autoload&lt;/code&gt; and then it will get plug-ins by cloning them from git inside a different subdirectory under &lt;code&gt;~/.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can see how this can look somewhat worrisome from a security point of view. The reason you might say it's difficult to get plug-ins in your environment is that this code should go through a security review, and having a plug-in manager download it &quot;on the fly&quot; from the Internet is a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then, is that so much different than pasting potentially large chunks of Vimscript from this website and others into your &lt;code&gt;.vimrc&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're interested in a small number of plug-ins and want to manage them on your own, then consider fetching it yourself (and vetting the source code) and using Vim 8's &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#packages&quot; rel=&quot;nofollow noreferrer&quot;&gt;package support&lt;/a&gt; to have it loaded automatically. (For Vim 7, the &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow noreferrer&quot;&gt;pathogen&lt;/a&gt; script does something similar, so you can use that as a fallback.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, some very popular Vim plug-ins have been packaged by Linux distributions such as Red Hat and Debian. In the process, they have been vetted by those Linux distributions. So, while this might involve requesting IT to have them installed on machines, etc., perhaps that helps with the trust and vetting issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do consider plug-ins, take a look at the &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt; plug-in. Or you'll also find other snippet managers which might suit your particular use case.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-17T16:28:11.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20649" PostTypeId="2" ParentId="20642" CreationDate="2019-07-17T18:45:03.320" Score="0" Body="&lt;p&gt;If you have a new enough version of Vim which supports &lt;code&gt;getqflist()&lt;/code&gt;/&lt;code&gt;setqflist()&lt;/code&gt; with the &lt;code&gt;idx&lt;/code&gt; option then you can directly change the current index without jumping.&lt;/p&gt;&#xA;&lt;p&gt;Example changing the index to &lt;code&gt;10&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:call setqflist([], 'a', {'idx': 10})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This can be wrapped into a commands to make it easier:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;command! Csilentnext call setqflist([], 'a', {'idx': get(getqflist({'idx':0}), 'idx', 0)+1})&#xA;command! Csilentprev call setqflist([], 'a', {'idx': get(getqflist({'idx':0}), 'idx', 0)-1})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2021-09-21T13:12:17.807" LastActivityDate="2021-09-21T13:12:17.807" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20650" PostTypeId="1" CreationDate="2019-07-17T19:04:25.337" Score="2" ViewCount="1087" Body="&lt;p&gt;I have a small question: let's suppose I'm at the beginning of line 10 and I search a term with the command &lt;code&gt;/term_to_search&lt;/code&gt; and then I press &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; to start navigating search results with &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;N&lt;/code&gt;. Then I want to go back to the location I were before starting the search (the beginning of line 10). How can I do? I know that the commands &lt;code&gt;CTRL+O&lt;/code&gt; and &lt;code&gt;CTRL+I&lt;/code&gt; jump back and forth the list of jumps, but how can I do it in just one keypress? Do I need to define a new special mark to do that (if so, how)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="22833" LastActivityDate="2019-07-19T18:46:17.107" Title="Jump back to the position I started a search" Tags="|search|mark|jump|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20651" PostTypeId="2" ParentId="20650" CreationDate="2019-07-17T20:08:59.047" Score="3" Body="&lt;p&gt;Two options I can think of off the top of my head:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:[v]split&lt;/code&gt;, then search in only one window&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:nnoremap / mz/&lt;/code&gt;; then &lt;code&gt;`z&lt;/code&gt; should take you back. Only works for one search at a time (i.e. new searches overwrite the mark)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-17T20:08:59.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20652" PostTypeId="2" ParentId="20650" CreationDate="2019-07-17T20:20:02.743" Score="6" Body="&lt;p&gt;I do this by first creating a mark - for example, create a mark named &quot;a&quot; with &lt;code&gt;ma&lt;/code&gt; in command mode – then search or move around the file however you want. Then go back to your mark with &lt;code&gt;'a&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5526" LastActivityDate="2019-07-17T20:20:02.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20653" PostTypeId="2" ParentId="328" CreationDate="2019-07-17T23:47:13.853" Score="1" Body="&lt;p&gt;With Vim 8+ on Linux or Mac, you can now simply use the terminal's native paste (e.g. middle mouse button, &lt;code&gt;ctrl+shift+V&lt;/code&gt; in Gnome, &lt;code&gt;cmd+V&lt;/code&gt; on Mac) if the terminal supports bracketed paste. Do not press &lt;code&gt;i&lt;/code&gt; for Insert Mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will paste the contents of your OS clipboard, preserving the spaces and tabs without adding autoindenting. It's equivalent to the old &lt;code&gt;:set paste&lt;/code&gt;, &lt;code&gt;i&lt;/code&gt;, &lt;code&gt;ctrl+shift+V&lt;/code&gt;, &lt;code&gt;esc&lt;/code&gt;, &lt;code&gt;:set nopaste&lt;/code&gt; method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't even need the &lt;code&gt;+clipboard&lt;/code&gt; or &lt;code&gt;+xterm_clipboard&lt;/code&gt; vim features installed anymore. This feature is called &quot;bracketed paste&quot;. For more details, see &lt;a href=&quot;https://stackoverflow.com/questions/2514445/turning-off-auto-indent-when-pasting-text-into-vim/56781763#56781763&quot;&gt;https://stackoverflow.com/questions/2514445/turning-off-auto-indent-when-pasting-text-into-vim/56781763#56781763&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6610" LastEditorUserId="8" LastEditDate="2019-07-18T07:07:14.810" LastActivityDate="2019-07-18T07:07:14.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20654" PostTypeId="2" ParentId="20650" CreationDate="2019-07-18T05:10:26.917" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;let's suppose I'm at the beginning of line 10&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then the easiest way back is &lt;code&gt;10G&lt;/code&gt; or &lt;code&gt;:10&lt;/code&gt;. It's not that useless if you have line numbers on and your memory is not bad either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, sometimes the command &lt;code&gt;g;&lt;/code&gt; (go back one position in &lt;em&gt;the change list&lt;/em&gt;) proves to be be useful.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-07-18T05:10:26.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20655" PostTypeId="1" AcceptedAnswerId="20656" CreationDate="2019-07-18T09:05:49.583" Score="1" ViewCount="508" Body="&lt;p&gt;I am trying a search and replace because I am using some macros in my code. &#xA;I want to replace  &lt;code&gt;tb.DUT.genblk4[0].U_rap_cisfd_wrapper&lt;/code&gt; this with &lt;code&gt;`RAP_CISFD_WRAP_I&lt;/code&gt;&#xA;in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/tb\.DUT\.genblk4[0\]\.U_rap_cisfd_wrapper/`RAP_CISFD_WRAP_I/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it is saying pattern not found. Help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;begin   &#xA;&#xA;    force tb.DUT.genblk4[0].U_rap_cisfd_wrapper.agent_ops_mem_inst_0.u_ops_mem.wbe_a = 8'hFF;&#xA;    force tb.DUT.genblk4[0].U_rap_cisfd_wrapper.agent_ops_mem_inst_0.u_ops_mem.wr_rd_en_a = 1'b1;&#xA;    force tb.DUT.genblk4[0].U_rap_cisfd_wrapper.agent_ops_mem_inst_0.u_ops_mem.addr_a = 15'h0000 + 15'h1*d0;&#xA;    force tb.DUT.genblk4[0].U_rap_cisfd_wrapper.agent_ops_mem_inst_0.u_ops_mem.data_inp_a = data_ops;&#xA;    d0=d0+1;&#xA;    @(posedge tb.DUT.genblk4[0].U_rap_cisfd_wrapper.agent_ops_mem_inst_0.u_ops_mem.clk);&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23064" LastEditorUserId="21062" LastEditDate="2019-08-06T18:45:06.410" LastActivityDate="2019-08-06T18:45:06.410" Title="Seach and replace with special characters" Tags="|substitute|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20656" PostTypeId="2" ParentId="20655" CreationDate="2019-07-18T09:16:37.567" Score="2" Body="&lt;p&gt;You need to also escape the &lt;code&gt;[&lt;/code&gt; character otherwise Vim consider it as the beginning of the &lt;code&gt;/[]&lt;/code&gt; pattern atom which create a group containing the characters between &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s;tb\.DUT\.genblk4\[0\]\.U_rap_cisfd_wrapper;`RAP_CISFD_WRAP;gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-07-18T09:16:37.567" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20657" PostTypeId="2" ParentId="20650" CreationDate="2019-07-18T10:34:14.040" Score="0" Body="&lt;p&gt;&lt;em&gt;If, contrary to my initial thinking, OP just wants a way to do what they describe manually (and the voting so far suggests that's most people are reading it that way) then this is overkill. But if one wants a transparent, automated method that allows return to search start any time w/o having to think about it ahead of time....this should help...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we want to get a little fancier (though still down and dirty) we can create an autocommand and a mapping like so...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup searchorigin&#xA;  autocmd!&#xA;  au CmdLineLeave * let b:cmdtype = expand('&amp;lt;afile&amp;gt;') | if (b:cmdtype == '/' || b:cmdtype == '?') | let b:searchorigin = getpos(&quot;.&quot;) | endif&#xA;augroup END&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;/ :exec 'call setpos(&quot;.&quot;, b:searchorigin)'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The autocommand will record the starting point of your current search in a buffer-local variable, allowing this to work simultaneously on different searches occurring in different buffers. The mapping will move the cursor back to that point using that variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So just start a search as you always do and then hit &lt;code&gt;\/&lt;/code&gt; and you'll be back to the start point. (Replace &lt;code&gt;&amp;lt;leader&amp;gt;/&lt;/code&gt; in the mapping with whatever free key(s) you desire.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-07-19T18:46:17.107" LastActivityDate="2019-07-19T18:46:17.107" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20658" PostTypeId="1" AcceptedAnswerId="20670" CreationDate="2019-07-18T11:03:43.837" Score="15" ViewCount="3743" Body="&lt;p&gt;The question's title might sound a little vague, so I'll explain the situation here more clearly.&#xA;I have these lines of code in a file which I want to align with respect to the character &lt;code&gt;=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const service = require('./service');&#xA;const baseService = require('./baseService');&#xA;const config = require('../config');&#xA;const Promise = require('bluebird');&#xA;const errors = require('../errors');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want the above lines to somehow look like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const service     = require('./service');&#xA;const baseService = require('./baseService');&#xA;const config      = require('../config');&#xA;const Promise     = require('bluebird');&#xA;const errors      = require('../errors');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope you understand what I'm trying to ask. I want all the &lt;code&gt;=&lt;/code&gt; characters to lie in the same column and shift the after-coming code accordingly. What can I do to achieve this task?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A plugin capable of doing this would be nice, but it'd be great if I could do this without the aid of any plugin. That way I'd also learn something. &lt;/p&gt;&#xA;" OwnerUserId="22982" LastEditorUserId="5017" LastEditDate="2019-07-18T11:33:31.990" LastActivityDate="2022-07-07T15:43:06.890" Title="Align a block of code on the basis of a single character" Tags="|alignment|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20659" PostTypeId="1" CreationDate="2019-07-18T11:25:57.473" Score="0" ViewCount="710" Body="&lt;p&gt;I have a git repository: &lt;code&gt;~/home/foo/repo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mounted core to another directory:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;mount --bind ~/home/foo/repo ~/home/bar&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to edit my code with vim and use vim-fugitive.&#xA;&lt;code&gt;vim ~/home/bar/myCode.txt; :Gblame&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="23065" LastActivityDate="2020-06-06T13:11:16.497" Title="Is it possible to use vim-fugitive outside of the repository (in local mounted directory)" Tags="|git|plugin-fugitive|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20660" PostTypeId="2" ParentId="20658" CreationDate="2019-07-18T11:32:19.420" Score="4" Body="&lt;p&gt;Install &lt;a href=&quot;https://github.com/junegunn/vim-easy-align&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-easy-align&lt;/a&gt;, assume you bind &lt;code&gt;&amp;lt;Plug&amp;gt;(EasyAlign)&lt;/code&gt; to &lt;code&gt;ga&lt;/code&gt;,  execute &lt;code&gt;gaip=&lt;/code&gt;, done.&lt;/p&gt;&#xA;&lt;p&gt;This plugin comes with a lot of predefined rule to handle common align scenarios.&lt;/p&gt;&#xA;&lt;p&gt;Another way to do this is to use &lt;a href=&quot;https://vimhelp.org/change.txt.html#%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h !&lt;/a&gt; : &lt;code&gt;!ipcolumn -t&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-07-18T11:32:19.420" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20661" PostTypeId="2" ParentId="6975" CreationDate="2019-07-18T12:08:43.700" Score="2" Body="&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt;: The accepted answer does not return a number or number-like object. This does.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Count( word )&#xA;  redir =&amp;gt; cnt&#xA;    silent exe '%s/' . a:word . '//n'&#xA;  redir END&#xA;  return matchstr( cnt, '\d\+' )&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the same instructions as the accepted answer, except you can actually perform further calculations with the result, &lt;em&gt;e.g.:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo Count(&quot;word&quot;) + 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or something superbly more complex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyMatch()&#xA;  let results = ingo#text#frompattern#Get(1, '$', 'j\w\{1,5\} \zs\(loc\|lab\)_\w\+\ze', '', '', '1')&#xA;  let counter=1&#xA;  for result in results&#xA;    if Count(result) != 2&#xA;      execute '%s/' . result . '/label' . counter . '/g'&#xA;      let counter+=1&#xA;    endif&#xA;  endfor&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10033" LastActivityDate="2019-07-18T12:08:43.700" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20662" PostTypeId="2" ParentId="6975" CreationDate="2019-07-18T13:15:25.803" Score="1" Body="&lt;p&gt;If you have a new enough version of vim which suport &lt;a href=&quot;https://vimhelp.org/eval.txt.html#execute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h execute()&lt;/a&gt; , you can get count like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetCount(pattern)&#xA;  let l:cnt = 0&#xA;  silent exe '%s/' . a:pattern . '/\=execute(''let l:cnt += 1'')/gn'&#xA;  return l:cnt&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In fact you can get all the matches and put them in a list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetMatches(pattern)&#xA;  let l:matches = []&#xA;  silent exe '%s/' . a:pattern .&#xA;        \ '/\=execute(''let l:matches += [submatch(0)]'')/gn'&#xA;  return l:matches&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;Christian Brabandt&lt;/a&gt; pointed out, you can use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#add%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h add()&lt;/a&gt; , it's simpler :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetMatches(pattern)&#xA;  let l:matches = []&#xA;  silent exe '%s/' . a:pattern . '/\=add(l:matches, submatch(0))/gn'&#xA;  return l:matches&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-07-19T00:05:51.877" LastActivityDate="2019-07-19T00:05:51.877" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20663" PostTypeId="1" CreationDate="2019-07-18T13:38:52.823" Score="0" ViewCount="78" Body="&lt;p&gt;When I'm working with &lt;code&gt;HTML&lt;/code&gt; in a &lt;code&gt;PHP&lt;/code&gt; file and I press &lt;kbd&gt;enter&lt;/kbd&gt; while in &lt;code&gt;INSERT&lt;/code&gt; mode, my cursor goes to the start of the next line instead of going at the right positive therefore I have to press &lt;kbd&gt;tab&lt;/kbd&gt; to position my cursor every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I have the following in my &lt;code&gt;index.php&lt;/code&gt; and my cursor is at the &lt;code&gt;_&lt;/code&gt; position:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&#xA;&amp;lt;html&amp;gt;&#xA;    &amp;lt;head&amp;gt;_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;kbd&gt;enter&lt;/kbd&gt; in &lt;code&gt;INSERT&lt;/code&gt; mode, it becomes like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&#xA;&amp;lt;html&amp;gt;&#xA;    &amp;lt;head&amp;gt;&#xA;_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&#xA;&amp;lt;html&amp;gt;&#xA;    &amp;lt;head&amp;gt;&#xA;        _&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I do get the expected position when I modify a &lt;code&gt;HTML&lt;/code&gt; file type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an option or plugin that change this behaviour?&lt;/p&gt;&#xA;" OwnerUserId="16488" LastEditorUserId="16488" LastEditDate="2019-07-18T14:18:13.587" LastActivityDate="2021-04-08T18:06:25.653" Title="How to have the cursor at the right indentation when editing PHP/HTML" Tags="|indentation|cursor|filetype-php|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20664" PostTypeId="1" CreationDate="2019-07-18T14:35:05.553" Score="1" ViewCount="532" Body="&lt;p&gt;I cannot get the leader key working in vim. I have been troubleshooting for quite some time.&lt;/p&gt;&#xA;&lt;p&gt;Stuff I did already:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Mapping leader key to another key&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:PlugInstall&lt;/code&gt; --&amp;gt; Already Installed x Plugin&lt;/li&gt;&#xA;&lt;li&gt;started vim without plugin / _vimrc file (&lt;code&gt;vim -u NONE -U NONE -N&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:messages&lt;/code&gt; --&amp;gt; does not say anything after beep&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This sadly doesn't solve the problem. (Beep)&lt;/p&gt;&#xA;&lt;h3&gt;_vimrc&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = ';'&#xA;source $VIMRUNTIME/vimrc_example.vim&#xA;source $VIMRUNTIME/mswin.vim&#xA;&#xA;set diffexpr=MyDiff()&#xA;function MyDiff()&#xA;  let opt = '-a --binary '&#xA;  if &amp;amp;diffopt =~ 'icase' | let opt = opt . '-i ' | endif&#xA;  if &amp;amp;diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif&#xA;  let arg1 = v:fname_in&#xA;  if arg1 =~ ' ' | let arg1 = '&amp;quot;' . arg1 . '&amp;quot;' | endif&#xA;  let arg1 = substitute(arg1, '!', '\!', 'g')&#xA;  let arg2 = v:fname_new&#xA;  if arg2 =~ ' ' | let arg2 = '&amp;quot;' . arg2 . '&amp;quot;' | endif&#xA;  let arg2 = substitute(arg2, '!', '\!', 'g')&#xA;  let arg3 = v:fname_out&#xA;  if arg3 =~ ' ' | let arg3 = '&amp;quot;' . arg3 . '&amp;quot;' | endif&#xA;  let arg3 = substitute(arg3, '!', '\!', 'g')&#xA;  if $VIMRUNTIME =~ ' '&#xA;    if &amp;amp;sh =~ '\&amp;lt;cmd'&#xA;      if empty(&amp;amp;shellxquote)&#xA;        let l:shxq_sav = ''&#xA;        set shellxquote&amp;amp;&#xA;      endif&#xA;      let cmd = '&amp;quot;' . $VIMRUNTIME . '\diff&amp;quot;'&#xA;    else&#xA;      let cmd = substitute($VIMRUNTIME, ' ', '&amp;quot; ', '') . '\diff&amp;quot;'&#xA;    endif&#xA;  else&#xA;    let cmd = $VIMRUNTIME . '\diff'&#xA;  endif&#xA;  let cmd = substitute(cmd, '!', '\!', 'g')&#xA;  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' &amp;gt; ' . arg3&#xA;  if exists('l:shxq_sav')&#xA;    let &amp;amp;shellxquote=l:shxq_sav&#xA;  endif&#xA;endfunction&#xA;&#xA;set nocompatible&#xA;syntax on&#xA;filetype plugin indent on&#xA;set hidden&#xA;&#xA;&amp;quot;let pythonthreedll = 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python36.dll'&#xA;&#xA;call plug#begin('~/.vim/plugged')&#xA;Plug 'lervag/vimtex'&#xA;Plug 'SirVer/ultisnips'&#xA;Plug 'honza/vim-snippets'&#xA;call plug#end()&#xA;&#xA;&amp;quot; Trigger configuration. Do not use &amp;lt;tab&amp;gt; if you use&#xA;let g:UltiSnipsExpandTrigger=&amp;quot;&amp;lt;tab&amp;gt;&amp;quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&amp;quot;&amp;lt;tab&amp;gt;&amp;quot;&#xA;&amp;quot;let g:UltiSnipsJumpBackwardTrigger=&amp;quot;&amp;lt;c-tab&amp;gt;&amp;quot;&#xA;&amp;quot;If you want :UltiSnipsEdit to split your window.&#xA;let g:UltiSnipsEditSplit=&amp;quot;vertical&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;:let mapleader&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;mapleader              ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;:map&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;x  &amp;lt;C-A&amp;gt;       * &amp;lt;C-C&amp;gt;ggVG&#xA;s  &amp;lt;C-A&amp;gt;       * &amp;lt;C-C&amp;gt;gggH&amp;lt;C-O&amp;gt;G&#xA;o  &amp;lt;C-A&amp;gt;       * &amp;lt;C-C&amp;gt;gggH&amp;lt;C-O&amp;gt;G&#xA;n  &amp;lt;C-A&amp;gt;       * gggH&amp;lt;C-O&amp;gt;G&#xA;v  &amp;lt;C-C&amp;gt;       * &amp;quot;+y&#xA;s  &amp;lt;C-H&amp;gt;       * &amp;lt;C-G&amp;gt;c&#xA;x  &amp;lt;Tab&amp;gt;       * :call UltiSnips#SaveLastVisualSelection()&amp;lt;CR&amp;gt;gvs&#xA;s  &amp;lt;Tab&amp;gt;       * &amp;lt;Esc&amp;gt;:call UltiSnips#ExpandSnippetOrJump()&amp;lt;CR&amp;gt;&#xA;   &amp;lt;C-Q&amp;gt;       * &amp;lt;C-V&amp;gt;&#xA;s  &amp;lt;C-R&amp;gt;       * &amp;lt;C-G&amp;gt;&amp;quot;_c&amp;lt;C-R&amp;gt;&#xA;v  &amp;lt;C-S&amp;gt;       * &amp;lt;C-C&amp;gt;:update&amp;lt;CR&amp;gt;&#xA;no &amp;lt;C-S&amp;gt;       * :update&amp;lt;CR&amp;gt;&#xA;v  &amp;lt;C-V&amp;gt;       &amp;amp; &amp;quot;-c&amp;lt;Esc&amp;gt;:call paste#Paste()&amp;lt;CR&amp;gt;&#xA;no &amp;lt;C-V&amp;gt;         &amp;quot;+gP&#xA;v  &amp;lt;C-X&amp;gt;       * &amp;quot;+x&#xA;   &amp;lt;C-Y&amp;gt;       * &amp;lt;C-R&amp;gt;&#xA;   &amp;lt;C-Z&amp;gt;       * u&#xA;o  %             &amp;lt;Plug&amp;gt;(MatchitOperationForward)&#xA;x  %             &amp;lt;Plug&amp;gt;(MatchitVisualForward)&#xA;n  %             &amp;lt;Plug&amp;gt;(MatchitNormalForward)&#xA;   Q             gq&#xA;o  [%            &amp;lt;Plug&amp;gt;(MatchitOperationMultiBackward)&#xA;x  [%            &amp;lt;Plug&amp;gt;(MatchitVisualMultiBackward)&#xA;n  [%            &amp;lt;Plug&amp;gt;(MatchitNormalMultiBackward)&#xA;o  ]%            &amp;lt;Plug&amp;gt;(MatchitOperationMultiForward)&#xA;x  ]%            &amp;lt;Plug&amp;gt;(MatchitVisualMultiForward)&#xA;n  ]%            &amp;lt;Plug&amp;gt;(MatchitNormalMultiForward)&#xA;x  a%            &amp;lt;Plug&amp;gt;(MatchitVisualTextObject)&#xA;o  g%            &amp;lt;Plug&amp;gt;(MatchitOperationBackward)&#xA;x  g%            &amp;lt;Plug&amp;gt;(MatchitVisualBackward)&#xA;n  g%            &amp;lt;Plug&amp;gt;(MatchitNormalBackward)&#xA;v  gx            &amp;lt;Plug&amp;gt;NetrwBrowseXVis&#xA;n  gx            &amp;lt;Plug&amp;gt;NetrwBrowseX&#xA;v  &amp;lt;Plug&amp;gt;(MatchitVisualTextObject)   &amp;lt;Plug&amp;gt;(MatchitVisualMultiBackward)o&amp;lt;Plug&amp;gt;(MatchitVisualMultiForward)&#xA;o  &amp;lt;Plug&amp;gt;(MatchitOperationMultiForward) * :&amp;lt;C-U&amp;gt;call matchit#MultiMatch(&amp;quot;W&amp;quot;,  &amp;quot;o&amp;quot;)&amp;lt;CR&amp;gt;&#xA;o  &amp;lt;Plug&amp;gt;(MatchitOperationMultiBackward) * :&amp;lt;C-U&amp;gt;call matchit#MultiMatch(&amp;quot;bW&amp;quot;, &amp;quot;o&amp;quot;)&amp;lt;CR&amp;gt;&#xA;v  &amp;lt;Plug&amp;gt;(MatchitVisualMultiForward) * :&amp;lt;C-U&amp;gt;call matchit#MultiMatch(&amp;quot;W&amp;quot;,  &amp;quot;n&amp;quot;)&amp;lt;CR&amp;gt;m'gv``&#xA;v  &amp;lt;Plug&amp;gt;(MatchitVisualMultiBackward) * :&amp;lt;C-U&amp;gt;call matchit#MultiMatch(&amp;quot;bW&amp;quot;, &amp;quot;n&amp;quot;)&amp;lt;CR&amp;gt;m'gv``&#xA;n  &amp;lt;Plug&amp;gt;(MatchitNormalMultiForward) * :&amp;lt;C-U&amp;gt;call matchit#MultiMatch(&amp;quot;W&amp;quot;,  &amp;quot;n&amp;quot;)&amp;lt;CR&amp;gt;&#xA;n  &amp;lt;Plug&amp;gt;(MatchitNormalMultiBackward) * :&amp;lt;C-U&amp;gt;call matchit#MultiMatch(&amp;quot;bW&amp;quot;, &amp;quot;n&amp;quot;)&amp;lt;CR&amp;gt;&#xA;o  &amp;lt;Plug&amp;gt;(MatchitOperationBackward) * :&amp;lt;C-U&amp;gt;call matchit#Match_wrapper('',0,'o')&amp;lt;CR&amp;gt;&#xA;o  &amp;lt;Plug&amp;gt;(MatchitOperationForward) * :&amp;lt;C-U&amp;gt;call matchit#Match_wrapper('',1,'o')&amp;lt;CR&amp;gt;&#xA;v  &amp;lt;Plug&amp;gt;(MatchitVisualBackward) * :&amp;lt;C-U&amp;gt;call matchit#Match_wrapper('',0,'v')&amp;lt;CR&amp;gt;m'gv``&#xA;v  &amp;lt;Plug&amp;gt;(MatchitVisualForward) * :&amp;lt;C-U&amp;gt;call matchit#Match_wrapper('',1,'v')&amp;lt;CR&amp;gt;m'gv``&#xA;n  &amp;lt;Plug&amp;gt;(MatchitNormalBackward) * :&amp;lt;C-U&amp;gt;call matchit#Match_wrapper('',0,'n')&amp;lt;CR&amp;gt;&#xA;n  &amp;lt;Plug&amp;gt;(MatchitNormalForward) * :&amp;lt;C-U&amp;gt;call matchit#Match_wrapper('',1,'n')&amp;lt;CR&amp;gt;&#xA;v  &amp;lt;Plug&amp;gt;NetrwBrowseXVis * :&amp;lt;C-U&amp;gt;call netrw#BrowseXVis()&amp;lt;CR&amp;gt;&#xA;n  &amp;lt;Plug&amp;gt;NetrwBrowseX * :call netrw#BrowseX(expand((exists(&amp;quot;g:netrw_gx&amp;quot;)? g:netrw_gx : '&amp;lt;cfile&amp;gt;')),netrw#CheckIfRemote())&amp;lt;CR&amp;gt;&#xA;s  &amp;lt;Del&amp;gt;       * &amp;lt;C-G&amp;gt;c&#xA;s  &amp;lt;BS&amp;gt;        * &amp;lt;C-G&amp;gt;c&#xA;s  &amp;lt;C-Tab&amp;gt;     * &amp;lt;Esc&amp;gt;:call UltiSnips#ListSnippets()&amp;lt;CR&amp;gt;&#xA;o  &amp;lt;C-F4&amp;gt;      * &amp;lt;C-C&amp;gt;&amp;lt;C-W&amp;gt;c&#xA;nv &amp;lt;C-F4&amp;gt;      * &amp;lt;C-W&amp;gt;c&#xA;o  &amp;lt;C-Tab&amp;gt;     * &amp;lt;C-C&amp;gt;&amp;lt;C-W&amp;gt;w&#xA;nx &amp;lt;C-Tab&amp;gt;     * &amp;lt;C-W&amp;gt;w&#xA;v  &amp;lt;S-Insert&amp;gt;    &amp;lt;C-V&amp;gt;&#xA;no &amp;lt;S-Insert&amp;gt;    &amp;quot;+gP&#xA;v  &amp;lt;C-Insert&amp;gt;  * &amp;quot;+y&#xA;v  &amp;lt;S-Del&amp;gt;     * &amp;quot;+x&#xA;x  &amp;lt;BS&amp;gt;        * d&#xA;v  ÎØ            &amp;quot;*d&#xA;v  Î×            &amp;quot;*d&#xA;v  ÎÕ            &amp;quot;*y&#xA;v  ÎÔ            &amp;quot;-d&amp;quot;*P&#xA;n  ÎÔ            &amp;quot;*P&#xA;nv Îu            &amp;lt;C-End&amp;gt;&#xA;nv Îw            &amp;lt;C-Home&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;:imap&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;i  &amp;lt;C-F4&amp;gt;      * &amp;lt;C-O&amp;gt;&amp;lt;C-W&amp;gt;c&#xA;i  &amp;lt;C-Tab&amp;gt;     * &amp;lt;C-R&amp;gt;=UltiSnips#ListSnippets()&amp;lt;CR&amp;gt;&#xA;i  &amp;lt;S-Insert&amp;gt;    &amp;lt;C-V&amp;gt;&#xA;i  ÎÔ            &amp;lt;C-R&amp;gt;&amp;lt;C-O&amp;gt;*&#xA;!  Îu            &amp;lt;C-End&amp;gt;&#xA;!  Îw            &amp;lt;C-Home&amp;gt;&#xA;i  &amp;lt;C-A&amp;gt;       * &amp;lt;C-O&amp;gt;gg&amp;lt;C-O&amp;gt;gH&amp;lt;C-O&amp;gt;G&#xA;i  &amp;lt;Tab&amp;gt;       * &amp;lt;C-R&amp;gt;=UltiSnips#ExpandSnippetOrJump()&amp;lt;CR&amp;gt;&#xA;i  &amp;lt;C-S&amp;gt;       * &amp;lt;Esc&amp;gt;:update&amp;lt;CR&amp;gt;gi&#xA;i  &amp;lt;C-U&amp;gt;       * &amp;lt;C-G&amp;gt;u&amp;lt;C-U&amp;gt;&#xA;i  &amp;lt;C-V&amp;gt;       &amp;amp; &amp;lt;C-G&amp;gt;u&amp;lt;C-\&amp;gt;&amp;lt;C-O&amp;gt;&amp;quot;+gP&#xA;i  &amp;lt;C-Y&amp;gt;       * &amp;lt;C-O&amp;gt;&amp;lt;C-R&amp;gt;&#xA;i  &amp;lt;C-Z&amp;gt;       * &amp;lt;C-O&amp;gt;u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Expected Behavior&lt;/h3&gt;&#xA;&lt;p&gt;On the bottom right vim screen there should be a &lt;code&gt;;&lt;/code&gt; (want to use &lt;code&gt;;ll&lt;/code&gt; for vimtex) but it just beeps. I can use &lt;code&gt;;&lt;/code&gt; in CMD-Window or vim insert mode but can't use it in the &amp;quot;normal&amp;quot;-vim-window (ESC, ESC)&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;### Another Problem with vimtex&#xA;I can't use the &lt;code&gt;:VimtexCompile&lt;/code&gt; command.&lt;/em&gt;&#xA;My Bad... You can only use those commands while editing a &lt;code&gt;.tex&lt;/code&gt; file&lt;/p&gt;&#xA;" OwnerUserId="23071" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-07-19T14:48:30.163" Title="How to fix Leader Key Beep in Vim?" Tags="|vimrc|key-bindings|plugin-vimtex|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20665" PostTypeId="2" ParentId="20663" CreationDate="2019-07-18T14:52:16.360" Score="1" Body="&lt;p&gt;Using this &lt;a href=&quot;https://github.com/captbaritone/better-indent-support-for-php-with-html&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt; solved the issue for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'captbaritone/better-indent-support-for-php-with-html', { 'for': 'php' }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is better than switching between &lt;code&gt;php&lt;/code&gt; and &lt;code&gt;html&lt;/code&gt; file type in my scenario because I have linters. So the html linter will throw me &lt;strong&gt;fake&lt;/strong&gt; errors for my php code.&lt;/p&gt;&#xA;" OwnerUserId="16488" LastActivityDate="2019-07-18T14:52:16.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20666" PostTypeId="2" ParentId="6975" CreationDate="2019-07-18T15:00:38.287" Score="2" Body="&lt;p&gt;There is another way that doesn't move the cursor nor requires &lt;code&gt;:exe&lt;/code&gt;, but uses other tricks. Here I count by using a function that modifies and returns something (if &lt;code&gt;+=&lt;/code&gt; was an expression like in C, it would have been simpler)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 -range Count call s:Count2(&amp;lt;f-args&amp;gt;, &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;)&#xA;&#xA;&quot; Not using the usual :function-range to avoid moving the cursor&#xA;function! s:Count2(param, firstl, lastl) abort&#xA;  let s:c = []&#xA;  call map(getline(a:firstl, a:lastl), { k,v -&amp;gt; substitute(v, 'line', '\=add(s:c, v)[-1]', 'g')})&#xA;  echo len(s:c)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2019-07-18T15:00:38.287" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20667" PostTypeId="2" ParentId="20634" CreationDate="2019-07-18T19:46:43.177" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;I want to create a command that will place my gvim window to a different &quot;x&quot; location on my screen while maintaining the &quot;y&quot; position.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As a more general solution to the problem of rearranging windows, you might look at Divvy – it's a window manager available on &lt;a href=&quot;https://mizage.com/divvy/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mac&lt;/a&gt; and &lt;a href=&quot;https://mizage.com/windivvy/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Windows&lt;/a&gt; (there are probably other options for both of those operating systems, or Linux).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using Divvy, you get to define global keyboard commands that allow you to move any window from any application to one of several specific screen regions. I have defined &lt;code&gt;cmd-ctrl-8&lt;/code&gt; (as a chord) to relocate the current window to the left half of the screen, &lt;code&gt;cmd-ctrl-9&lt;/code&gt; to the right half, and &lt;code&gt;cmd-ctrl-0&lt;/code&gt; to maximize to full screen. I use it to rearrange vim windows as well as everything else – terminals, browser, email, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how many it supports in total, I have 9 unique shortcut/locations defined and it still shows the &quot;New&quot; button to create another one.&lt;/p&gt;&#xA;" OwnerUserId="5526" LastActivityDate="2019-07-18T19:46:43.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20668" PostTypeId="2" ParentId="10618" CreationDate="2019-07-19T02:10:45.097" Score="1" Body="&lt;p&gt;I can't tell what machine your using, but on my iMac I had the exact same issue and I've finally fixed it. The solution was to go to preferences and uncheck &quot;Use Core Text renderer&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I no longer have the issue and as far as I can tell, there hasn't been any adverse affects from doing this. &lt;/p&gt;&#xA;" OwnerUserId="23078" LastActivityDate="2019-07-19T02:10:45.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20670" PostTypeId="2" ParentId="20658" CreationDate="2019-07-19T04:27:36.410" Score="14" Body="&lt;p&gt;If you're in a pinch and want to get the expressions aligned, without having to install and learn any plug-ins, here is a quick way to do it.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Select the lines on a visual selection. For example, if this is your whole buffer, you could use &lt;code&gt;ggVG&lt;/code&gt;, but if these lines are in the middle of a file, just select appropriately. Perhaps &lt;code&gt;V4j&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Insert enough whitespace before the &lt;code&gt;=&lt;/code&gt;, which you can do with &lt;code&gt;:normal f=9i &lt;/code&gt;. (Note the &quot;space&quot; at the end.) This will add 9 spaces before each &lt;code&gt;=&lt;/code&gt; in the lines of the visual selection. If 9 is not enough, add more (like 99 or 999, as much as you want.) Note that when you type &lt;code&gt;:&lt;/code&gt; with the visual selection, Vim will automatically insert the range, so the actual command is &lt;code&gt;:'&amp;lt;,'&gt;normal f=9i &lt;/code&gt;, but you don't need to type those characters.&lt;/li&gt;&#xA;&lt;li&gt;Move to the column where you want the &lt;code&gt;=&lt;/code&gt;s to be flushed to. In this case, line 2 has the longest variable name, so move to two spaces after the end of that name, which is where the &lt;code&gt;=&lt;/code&gt;s should be at the end. If this is the whole buffer, you could use &lt;code&gt;2G2e2l&lt;/code&gt; to get there.&lt;/li&gt;&#xA;&lt;li&gt;Staying on that same column, move to the first line of the block. In this case, you're moving from line 2 to line 1, so &lt;code&gt;k&lt;/code&gt; is enough.&lt;/li&gt;&#xA;&lt;li&gt;Start visual-block selection, pressing &lt;code&gt;Ctrl-V&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Move to the last line of the block. If this is the whole buffer, you could use &lt;code&gt;G&lt;/code&gt;, if this is the middle of a file, you could use &lt;code&gt;4j&lt;/code&gt; to go four lines down, etc.&lt;/li&gt;&#xA;&lt;li&gt;(Optional) Use &lt;code&gt;$&lt;/code&gt; to select until the end of the line, on &lt;em&gt;every&lt;/em&gt; line of the visual block selection. &lt;strong&gt;UPDATE:&lt;/strong&gt; This step is actually not necessary here, since &lt;code&gt;&amp;lt;&lt;/code&gt; will work correctly even if you don't select lines to the end. Using &lt;code&gt;$&lt;/code&gt; is important when using e.g. &lt;code&gt;A&lt;/code&gt; to append to the end of all lines though.&lt;/li&gt;&#xA;&lt;li&gt;Now you can use the &lt;code&gt;&amp;lt;&lt;/code&gt; command to shift the lines left, but until they hit the left of the visual block. Each &lt;code&gt;&amp;lt;&lt;/code&gt; will shift them by one &lt;code&gt;'shiftwidth'&lt;/code&gt; only, so you're likely to need more than one. So, to be sure, use &lt;code&gt;9&amp;lt;&lt;/code&gt; (or &lt;code&gt;99&amp;lt;&lt;/code&gt;, or &lt;code&gt;999&amp;lt;&lt;/code&gt;, if you added tons of spaces in step 2.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Voilà!&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a pretty cool technique and it can be helpful when you need more flexibility than plug-ins can afford you. It's a good one to learn and keep on your Vim toolbox.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-07-19T12:37:38.400" LastActivityDate="2019-07-19T12:37:38.400" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="20671" PostTypeId="2" ParentId="20659" CreationDate="2019-07-19T09:28:07.210" Score="3" Body="&lt;p&gt;According to &lt;a href=&quot;https://github.com/tpope/vim-fugitive/blob/master/autoload/fugitive.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-fugitive sources&lt;/a&gt;, you can use Fugitive commands for any file that belongs to git index.&#xA;E.g. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;cd ~&#xA;vim ~/home/foo/repo/README.md # works&#xA;vim ~/home/bar/README.md # works too&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22724" LastActivityDate="2019-07-19T09:28:07.210" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20672" PostTypeId="1" AcceptedAnswerId="20673" CreationDate="2019-07-19T13:08:14.367" Score="2" ViewCount="310" Body="&lt;p&gt;&lt;code&gt;`.&lt;/code&gt; seems to take me to where I last left insert mode, but I would like to jump to where my cursor was when I entered insert mode last.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2019-07-25T05:21:38.993" Title="Jump to where insert mode was entered?" Tags="|mark|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20673" PostTypeId="2" ParentId="20672" CreationDate="2019-07-19T13:47:40.657" Score="4" Body="&lt;p&gt;If you haven't yanked or changed text since your last insertion, then you can use the &lt;code&gt;`[&lt;/code&gt; mark (see &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%60%5B&quot; rel=&quot;nofollow noreferrer&quot;&gt;docs&lt;/a&gt;), which gets you back &quot;to the first character of the previously changed or yanked text.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%60.&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;`.&lt;/code&gt;&lt;/a&gt; will track your last &lt;em&gt;change&lt;/em&gt;, not necessarily an insertion, a deletion, indent or format operation would also reset this mark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%60%5E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;`^&lt;/code&gt;&lt;/a&gt; mark is the one tracking your last insertion. (But, as you mentioned, it will go back to where your cursor ended, not started.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/motion.txt.html#%3Achanges&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:changes&lt;/code&gt;&lt;/a&gt;, which shows you a list of recent changes, including insertions;&lt;/li&gt;&#xA;&lt;li&gt;the &lt;a href=&quot;https://vimhelp.org/motion.txt.html#g%3B&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g;&lt;/code&gt;&lt;/a&gt; command, which lets you jump back to previous positions in that list (and corresponding &lt;code&gt;g,&lt;/code&gt; to jump forward.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-07-25T05:21:38.993" LastActivityDate="2019-07-25T05:21:38.993" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20674" PostTypeId="2" ParentId="20664" CreationDate="2019-07-19T14:48:30.163" Score="3" Body="&lt;p&gt;If I understand your question correctly, you are trying to use the vimtex keybinding for the &lt;code&gt;&amp;lt;plug&amp;gt;(vimtex-compile)&lt;/code&gt; command and you're expecting it should be available under &lt;code&gt;;ll&lt;/code&gt;, since you have &lt;code&gt;let mapleader = ';'&lt;/code&gt; at the start of your &lt;code&gt;_vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's the case, the problem you're having is that vimtex actually uses the &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3CLocalLeader%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;&lt;code&gt;&amp;lt;localleader&amp;gt;&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt; (not &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt;) for its mappings, so it will actually map the &lt;code&gt;&amp;lt;plug&amp;gt;(vimtex-compile)&lt;/code&gt; to &lt;strong&gt;&lt;code&gt;\ll&lt;/code&gt;&lt;/strong&gt; and not &lt;code&gt;;ll&lt;/code&gt;, since your &lt;code&gt;maplocalleader&lt;/code&gt; is unset and the default for &lt;code&gt;&amp;lt;localleader&amp;gt;&lt;/code&gt; is a backslash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/lervag/vimtex/blob/363a8c5dc3be3decd1e8060040f268b238a39689/doc/vimtex.txt#L651&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help vimtex-default-mappings&lt;/code&gt;&lt;/a&gt;, which explicitly documents that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Many of the mappings utilize the &lt;code&gt;|maplocalleader|&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And lists the mapping for compiling:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;&amp;lt;localleader&amp;gt;ll  &amp;lt;plug&amp;gt;(vimtex-compile)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you want to use &lt;code&gt;;ll&lt;/code&gt; for compiling instead, add this to the start of your &lt;code&gt;_vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;&lt;b&gt;let maplocalleader = ';'&lt;/b&gt;&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might want to remove the &lt;code&gt;mapleader&lt;/code&gt; setting (let it default to &lt;code&gt;\&lt;/code&gt;) or set it to some other key, since most of the point of setting those variables is to have different keybindings for global and local commands, in order to avoid clashes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, please remember that these keybindings from vimtex, such as &lt;code&gt;;ll&lt;/code&gt; (and, more generally, keybindings that use &lt;code&gt;&amp;lt;localleader&amp;gt;&lt;/code&gt;) are only defined for buffers where vimtex enables them, which is usually for the appropriate filetype, in this case, &lt;code&gt;.tex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same as you noticed &lt;code&gt;:VimtexCompile&lt;/code&gt; will only work in such a buffer, same is true for the corresponding keybinding.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-19T14:48:30.163" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20675" PostTypeId="2" ParentId="20362" CreationDate="2019-07-19T16:46:06.930" Score="2" Body="&lt;p&gt;I'm afraid the only way to update the quickfix list consists in manually changing its content with &lt;code&gt;setqflist()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;getqflist({'idx': 'whatever'})&lt;/code&gt; you should be able to obtain the index of the current item -- If I'm not mistaken you'll then have to count entries with &lt;code&gt;'nr'&lt;/code&gt; field to use that index. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From here you should by now have an absolute index which you could use to clear the qflist before re-setting it. &lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2019-07-19T16:46:06.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20677" PostTypeId="1" AcceptedAnswerId="20678" CreationDate="2019-07-20T08:39:57.993" Score="3" ViewCount="1020" Body="&lt;p&gt;Based on the accepted answer of the following post &lt;a href=&quot;https://vi.stackexchange.com/questions/688/how-to-add-permanent-line-numbers-to-a-file/818#818&quot;&gt;How to add permanent line numbers to a file?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to have the capacity to select a certain number of lines and add numbers to those particular lines only. Also I require to delete the numbers as well in case I need to renumber those lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will be great to have some keybindings for the commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is highly appreciated. Thanks&lt;/p&gt;&#xA;" OwnerUserId="23093" LastEditorUserId="21062" LastEditDate="2019-08-06T13:18:24.293" LastActivityDate="2019-08-06T13:18:24.293" Title="Add line numbers and remove line numbers to selected lines" Tags="|vimrc|line-numbers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20678" PostTypeId="2" ParentId="20677" CreationDate="2019-07-20T10:14:48.153" Score="2" Body="&lt;p&gt;Easy-peasy. Or should I say &quot;it can be done in a simple and straightforward manner&quot; instead? By default Ex commands in the visual mode work over a selected range just the way we want.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; F12 to add line numbers to the selected lines&#xA;vnoremap &amp;lt;F12&amp;gt; :s/^/\=line(&quot;.&quot;).&quot;. &quot;&amp;lt;CR&amp;gt;&#xA;&quot; The same as above but numbers from 1 to n&#xA;&quot;vnoremap &amp;lt;F12&amp;gt; :s/^/\=line(&quot;.&quot;)+1-line(&quot;'&amp;lt;&quot;).&quot;. &quot;&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Shift-F12 to remove any numbers from the beginning of selected lines&#xA;vnoremap &amp;lt;S-F12&amp;gt; :s/^\d\+\. /&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-07-20T10:24:41.503" LastActivityDate="2019-07-20T10:24:41.503" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20679" PostTypeId="2" ParentId="20677" CreationDate="2019-07-20T10:39:04.253" Score="2" Body="&lt;p&gt;Command &lt;a href=&quot;https://vimhelp.org/change.txt.html#v_g_CTRL-A&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g CTRL-A&lt;/code&gt;&lt;/a&gt; in visual mode can accomplish that for you. It creates an incrementing sequence, incrementing a number on each line by a subsequent number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example of using this to build a numbered list, somewhere in the middle of your file:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start visual block selection mode with &lt;a href=&quot;https://vimhelp.org/visual.txt.html#CTRL-V&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;CTRL-V&lt;/code&gt;&lt;/a&gt;, at the first column of a line (or a different column if you want the numbers to be added later on, or including an indent.) Move to the last line of the block you want to number.&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;code&gt;I0. &amp;lt;esc&amp;gt;&lt;/code&gt;, where the last key is the ESC key. You're entering insert mode with &lt;a href=&quot;https://vimhelp.org/visual.txt.html#v_b_I&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;I&lt;/code&gt;&lt;/a&gt; (more specifically, visual block insert), then inserting &quot;zero&quot;, &quot;dot&quot;, &quot;space&quot; (which are inserted to each line), and leaving insert mode with an ESC. When you leave insertion mode, Vim will add the text to each line in the block.&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;a href=&quot;https://vimhelp.org/visual.txt.html#gv&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;gv&lt;/code&gt;&lt;/a&gt; to recall your selection. This will select all &quot;zeroes&quot; you inserted.&lt;/li&gt;&#xA;&lt;li&gt;(Optional) Grow your insertion to include the whole numbers. It turns out right now all &quot;zeroes&quot; are covered, but if you're doing a further operation and have lines with two, three or four digit numbers, you'll want to make sure they're fully in the visual block. It's ok if there are further characters in the block. You can use &lt;code&gt;V&lt;/code&gt; here to switch to a linewise visual select, or you can keep in a visual block and use &lt;code&gt;$&lt;/code&gt; to select all the way to the end of the line.&lt;/li&gt;&#xA;&lt;li&gt;Finally, use the &lt;a href=&quot;https://vimhelp.org/change.txt.html#v_g_CTRL-A&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g CTRL-A&lt;/code&gt;&lt;/a&gt; command to increment the zeroes. You type a &lt;code&gt;g&lt;/code&gt; (lowercase &quot;g&quot;, which will be pending), followed by a Control-A. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;After this sequence, you'll end up with a numbered list, with a number on each line, starting at 1. Pretty handy stuff!&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;Side note:&lt;/em&gt; Beware if you use &lt;code&gt;screen&lt;/code&gt;, since Control-A is the default hot-key for it and might go to &lt;code&gt;screen&lt;/code&gt; and not Vim. The typical way to pass a Control-A to the application is to type Control-A, then &quot;a&quot;. The default keybindings for &lt;code&gt;tmux&lt;/code&gt; are different, but using Control-A for &lt;code&gt;tmux&lt;/code&gt; is a popular choice, in which case Control-A then &quot;a&quot; is typically the way around that too.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You asked about deleting numbers from some lines, which should be easy to do using the usual deletion commands, such as &lt;code&gt;dW&lt;/code&gt;, also using visual block mode you can use &lt;code&gt;x&lt;/code&gt;, or &lt;code&gt;r&lt;/code&gt; + &quot;space&quot; to replace the numbers with spaces to keep the lines where they are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you further need to adjust the numbering, typically by decrementing the numbers on the lines that follow (so you're not skipping from, say, 8 to 12), you can then use the &lt;a href=&quot;https://vimhelp.org/change.txt.html#v_CTRL-X&quot; rel=&quot;nofollow noreferrer&quot;&gt;CTRL-X&lt;/a&gt; command, with a count, to subtract from the numbers in the lines that follow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply select the lines that follow (visual line mode with &lt;code&gt;V&lt;/code&gt; is fine), then type, for example, &lt;code&gt;3&lt;/code&gt; (if that is the number of lines you deleted numbers from), followed by &lt;code&gt;CTRL-X&lt;/code&gt;, which will then subtract 3 from the numbers in the lines of your visual selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;g CTRL-A&lt;/code&gt; in visual mode is also useful if you want to number paragraphs, since it will skip lines with no numbers in them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have text that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0.    This is a paragraph. It uses multiple&#xA;      lines to make a point. There are 123&#xA;      numbers 456 in the middle of the&#xA;      789 text.&#xA;&#xA;0.    This is another paragraph.&#xA;&#xA;0.    And a final one here.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use visual block mode to select the first 6 columns (or even fewer) with the zeroes and use &lt;code&gt;g CTRL-A&lt;/code&gt;, which will renumber your paragraphs to &lt;code&gt;1.&lt;/code&gt;, &lt;code&gt;2.&lt;/code&gt; and &lt;code&gt;3.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have more than 9 paragraphs, some will get misaligned (as you get to double digit numberings.) In that case, use visual block mode to select the text of the paragraphs themselves and use &lt;a href=&quot;https://vimhelp.org/visual.txt.html#v_b_%3C&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/a&gt; to re-align them.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-20T10:39:04.253" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20680" PostTypeId="1" AcceptedAnswerId="20685" CreationDate="2019-07-20T11:02:38.510" Score="3" ViewCount="3237" Body="&lt;p&gt;I want to set up a shortcut to make word under the cursor upper case in the command mode. I know that you can get the word under the cursor with &lt;code&gt;expand(&quot;&amp;lt;cword&amp;gt;&quot;)&lt;/code&gt;. But I  am not sure how do I translate it to upper case the then replace the original word in command mode, because &lt;code&gt;U&lt;/code&gt;, &lt;code&gt;~&lt;/code&gt; will not work in command mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I can only come up with the following mapping, which is missing the right-hand side expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;c-u&amp;gt; xxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-07-22T10:45:04.977" Title="How to change word under cursor to upper case in command mode with shortcut?" Tags="|key-bindings|command-line|letter-case|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20681" PostTypeId="1" AcceptedAnswerId="20683" CreationDate="2019-07-20T13:32:47.767" Score="3" ViewCount="399" Body="&lt;p&gt;How do I get my cursor to not move to the last thing it replaced after a search and replace. No &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; or extra key presses. Is there some &lt;code&gt;autocmd&lt;/code&gt; magic I can setup to listen on any &lt;code&gt;substitute&lt;/code&gt; execution and perform a &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; automatically after it completes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're curious about further details, it's really for this bread-and-butter mapping, search and replace word under cursor for the whole file, honoring case. I type the binding then start typing the replacement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;sr :%s/&amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;//gI&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the neovim feature to animate the search and replace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;nvim&quot;)&#xA;    set inccommand=nosplit &quot; No preview window&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23094" LastEditorUserId="23094" LastEditDate="2019-07-20T13:58:37.543" LastActivityDate="2019-07-27T20:43:20.193" Title="Don't jump on search and replace" Tags="|search|autocmd|replace|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20682" PostTypeId="2" ParentId="20680" CreationDate="2019-07-20T13:41:59.360" Score="7" Body="&lt;p&gt;Rather than make a mapping (particularly over top of the helpful &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; kill-line), I suggest the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open the command-line window. &lt;code&gt;q:&lt;/code&gt; from normal mode, or &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; if already typing a &lt;code&gt;:&lt;/code&gt; command. &lt;/li&gt;&#xA;&lt;li&gt;Use vim’s editing commands, such as &lt;code&gt;gUiw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-20T13:41:59.360" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20683" PostTypeId="2" ParentId="20681" CreationDate="2019-07-20T15:00:51.520" Score="0" Body="&lt;p&gt;I forgot that you can prepare a series of commands separated by |.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution I'm happy with is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;nvim&quot;)&#xA;  set inccommand=nosplit &quot; Remove horizontal split that shows a preview of whats changing&#xA;endif&#xA;&quot; E means edit with confirms, e is no confirm. &#xA;&quot; Second letter is source: w is word under cursor, y is yanked text.&#xA;&quot; Even with very no magic (\V) modifier, still need to escape / and \ with \&#xA;&quot; The \&amp;lt; and \&amp;gt; means don't do a raw string replace but a word replace&#xA;&quot; so if you want to replace someVar, it won't touch vars name someVarOther&#xA;&quot; edit word in whole file&#xA;nnoremap &amp;lt;leader&amp;gt;ew :%s/\V\&amp;lt;&amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;\&amp;gt;//gI \|normal &amp;lt;c-o&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&quot; Edit confirm word in whole file&#xA;nnoremap &amp;lt;leader&amp;gt;Ew :,$s/\V\&amp;lt;&amp;lt;c-r&amp;gt;&amp;lt;c-w&amp;gt;\&amp;gt;//gIc \|1,''-&amp;amp;&amp;amp;&amp;lt;c-left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&quot; edit word under cursor within the visual lines&#xA;&quot; gv selects the last vis selection (line, block or select)&#xA;vnoremap &amp;lt;leader&amp;gt;ew &amp;lt;Esc&amp;gt;yiwgv:s/\V\&amp;lt;&amp;lt;c-r&amp;gt;&quot;\&amp;gt;//gI \| normal &amp;lt;c-o&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&quot; Visually selected text in file&#xA;&quot; If mode is visual line mode, edit the prev yank acros the vis lines, else across the whole file&#xA;&quot; see :help escape()&#xA;vnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;ey mode() ==# &quot;V&quot; ? &#xA;      \ &quot;:s/\\V&amp;lt;c-r&amp;gt;&amp;lt;c-r&amp;gt;=escape(@\&quot;, '/\\')&amp;lt;cr&amp;gt;//gI \| normal &amp;lt;c-o&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&quot;&#xA;      \: &quot;y:%s/\\V&amp;lt;c-r&amp;gt;&amp;lt;c-r&amp;gt;=escape(@\&quot;, '/\\')&amp;lt;cr&amp;gt;//gI \| normal &amp;lt;c-o&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&quot;&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;ey :%s/\V&amp;lt;c-r&amp;gt;=escape(@&quot;, '/\\')&amp;lt;cr&amp;gt;//gI &amp;lt;bar&amp;gt; normal &amp;lt;c-o&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;Ey :%s/\V&amp;lt;c-r&amp;gt;=escape(@&quot;, '/\\')&amp;lt;cr&amp;gt;//gIc &amp;lt;bar&amp;gt; normal &amp;lt;c-o&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;c-left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23094" LastEditorUserId="23094" LastEditDate="2019-07-27T20:43:20.193" LastActivityDate="2019-07-27T20:43:20.193" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20685" PostTypeId="2" ParentId="20680" CreationDate="2019-07-21T02:01:54.210" Score="5" Body="&lt;p&gt;Assuome current command :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo   &quot;hello   world&quot;&#xA;       ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^&lt;/code&gt; marks current cursor, after &lt;code&gt;upcase current word&lt;/code&gt;, it becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo   &quot;HELLO   world&quot;&#xA;             ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key part is to split your command into 3 parts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo   &quot;hello   world&quot;&#xA;--1----^     ---3-----&#xA;       ---2--&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be done  with &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%25c&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h /\%c&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo matchlist('echo   &quot;hello   world&quot;', '\v^(.*)(%8c\s*\S+)(.*)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#getcmdline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h getcmdline()&lt;/a&gt; to get current command, &lt;a href=&quot;https://vimhelp.org/eval.txt.html#getcmdpos%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h getcmdpos()&lt;/a&gt; to get cursor position,&#xA;&lt;a href=&quot;https://vimhelp.org/eval.txt.html#setcmdpos%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h setcmdpos()&lt;/a&gt; to set cursor position, &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_CTRL-%5C_e&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h c_CTRL-\_e&lt;/a&gt; to replace the entire command :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:cmd_word_case(up)&#xA;&#xA;  &quot; split cmdline into 3 parts&#xA;  let matches = matchlist(getcmdline(),&#xA;        \ printf('\v^(.*)(%%%dc\s*\S+)(.*)', getcmdpos()))&#xA;  if len(matches) &amp;lt; 4&#xA;    return getcmdline()&#xA;  endif&#xA;&#xA;  let [pre, word, post] = matches[1:3]&#xA;  call setcmdpos(len(pre) + len(word) + 1)&#xA;&#xA;  return pre . (a:up ? toupper(word) : tolower(word)) . post&#xA;&#xA;endfunction&#xA;&#xA;cnoremap &amp;lt;a-u&amp;gt; &amp;lt;c-\&amp;gt;e&amp;lt;sid&amp;gt;cmd_word_case(1)&amp;lt;cr&amp;gt;&#xA;cnoremap &amp;lt;a-l&amp;gt; &amp;lt;c-\&amp;gt;e&amp;lt;sid&amp;gt;cmd_word_case(0)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-07-22T10:45:04.977" LastActivityDate="2019-07-22T10:45:04.977" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20686" PostTypeId="2" ParentId="20680" CreationDate="2019-07-21T08:15:42.283" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The question is how can I turn current words into upper case in the command line. I am aware of the command window.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Simply open the command window, process the command, and get back to the command line, all inside a single mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;C-U&amp;gt; &amp;lt;C-F&amp;gt;gUiww&amp;lt;C-C&amp;gt;&#xA;&#xA;&quot; prevents the command-line window from remaining open after &amp;lt;C-C&amp;gt;&#xA;&quot; works in Vim (but not in Neovim)&#xA;set lazyredraw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-07-22T07:48:07.013" LastActivityDate="2019-07-22T07:48:07.013" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20687" PostTypeId="1" AcceptedAnswerId="20688" CreationDate="2019-07-21T11:02:10.433" Score="1" ViewCount="488" Body="&lt;p&gt;I'm trying to write vim plugin for easier work with cmake. I want it to read some values from json file: build_dir, generator, cmake VARS and then give vim user few functions: configure, build, maybe run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I decided to use python, because it's easy to run cmake from it and easy to parse json. But i have problem with understanding where i need to save values from json.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I decided to just save them to vim variables, &lt;code&gt;g:cmake_configuration_name&lt;/code&gt; for example. But i didn't find way to do this. I read &lt;code&gt;help python&lt;/code&gt; few times already and tried to google it, no luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe that's just bad way to do this, so i need help with this too.&lt;/p&gt;&#xA;" OwnerUserId="23099" LastActivityDate="2019-07-21T12:59:46.980" Title="How to set internal vim variable from python code" Tags="|vimscript-python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20688" PostTypeId="2" ParentId="20687" CreationDate="2019-07-21T12:59:46.980" Score="2" Body="&lt;p&gt;For a vim plugin with python, you may first import the &lt;code&gt;vim&lt;/code&gt; module (see &lt;code&gt;:h python-vim&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then there is &lt;code&gt;vim.command(cmd)&lt;/code&gt; to execute an Ex command, so in your case&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim.command('let g:cmake_configuration_name=' + python_variable)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should do the job.&lt;/p&gt;&#xA;" OwnerUserId="22929" LastActivityDate="2019-07-21T12:59:46.980" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20689" PostTypeId="2" ParentId="13674" CreationDate="2019-07-21T13:09:41.807" Score="0" Body="&lt;p&gt;Reason may be not in ycm, but in other plugins:&lt;br&gt;&#xA;I noticed that jedi-vim takes control over go-to command and after specifying &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:jedi#use_tabs_not_buffers = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;all work as expected&lt;/p&gt;&#xA;" OwnerUserId="23100" LastEditorUserId="1841" LastEditDate="2019-07-22T07:58:07.410" LastActivityDate="2019-07-22T07:58:07.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20690" PostTypeId="2" ParentId="18392" CreationDate="2019-07-21T14:52:47.170" Score="1" Body="&lt;p&gt;To add sentences as thesaurus, you need the &lt;code&gt;'iskeyword'&lt;/code&gt; option to contain the space character (32 in ascii). Your thesaurus file should then contain spaces only to separate words in a thesaurus sentence and not to separate entries :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iterate,loop,loop over&#xA;branch,condition&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;https://www.reddit.com/r/vim/comments/55y53e/allow_spaces_in_thesaurus_entries/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this post&lt;/a&gt; that works well to add &lt;code&gt;32&lt;/code&gt; to &lt;code&gt;'iskeyword'&lt;/code&gt; just before launching the popup menu, then removes it after a short time period. The trick is to &lt;code&gt;set iskeyword+=32&lt;/code&gt; after setting a self-destructing &lt;code&gt;autocmd&lt;/code&gt; that restores it after 200ms, so you keep your &lt;code&gt;iskeyword&lt;/code&gt; clean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an updated version :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Keyword32()&#xA;    let s:saved_iskeyword = &amp;amp;iskeyword&#xA;    let s:saved_updatetime = &amp;amp;updatetime&#xA;    if &amp;amp;updatetime &amp;gt; 200 | let &amp;amp;updatetime = 200 | endif&#xA;    augroup Keyword32&#xA;        autocmd CursorHold,CursorHoldI &amp;lt;buffer&amp;gt;&#xA;                    \ let &amp;amp;updatetime = s:saved_updatetime |&#xA;                    \ let &amp;amp;iskeyword = s:saved_iskeyword |&#xA;                    \ autocmd! Keyword32&#xA;    augroup END&#xA;    set iskeyword+=32&#xA;endfunction&#xA;inoremap &amp;lt;c-x&amp;gt;&amp;lt;c-t&amp;gt; &amp;lt;C-O&amp;gt;:call Keyword32()&amp;lt;CR&amp;gt;&amp;lt;c-x&amp;gt;&amp;lt;c-t&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that with this mapping, when you would like to use the &lt;code&gt;^X&lt;/code&gt; submode, it will take &lt;code&gt;'timeoutlen'&lt;/code&gt;ms until it shows you the &lt;code&gt;-- ^X mode (^]^D...)&lt;/code&gt; line. You could map something else if you want. Also make sure you have a reasonable &lt;code&gt;timeoutlen&lt;/code&gt; in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update : since vim 8.0, you can use a timer instead of the &lt;code&gt;autocmd&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Thesaurus32()&#xA;    if has('timers') &amp;amp;&amp;amp; !empty(&amp;amp;thesaurus)&#xA;        call timer_start(200, {_-&amp;gt;execute('set iskeyword-=32')})&#xA;        set iskeyword+=32&#xA;    endif&#xA;    return &quot;\&amp;lt;c-x&amp;gt;\&amp;lt;c-t&amp;gt;&quot;&#xA;endfunction&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-t&amp;gt; Thesaurus32()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22929" LastEditorUserId="22929" LastEditDate="2019-08-21T10:54:59.360" LastActivityDate="2019-08-21T10:54:59.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20691" PostTypeId="1" CreationDate="2019-07-21T19:29:00.723" Score="3" ViewCount="615" Body="&lt;p&gt;I have this configuration in .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FindProjectRootDir()&#xA;      return &quot;some path&quot;&#xA;endfunction&#xA;&#xA;set makeprg=LC_ALL=C\ make\ MONOCHROME=1&#xA;nnoremap &amp;lt;F7&amp;gt; :make -C FindProjectRootDir()&amp;lt;CR&amp;gt;:copen&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when i hit F7, there is a problem, make cannot get parameter from the function FindProjectRootDir()&lt;/p&gt;&#xA;" OwnerUserId="23102" LastEditorUserId="23102" LastEditDate="2019-07-21T20:04:53.653" LastActivityDate="2019-07-22T00:04:05.577" Title="How to pass function return value to make command in VIM" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ClosedDate="2019-07-22T14:26:55.000" ContentLicense="CC BY-SA 4.0" />
  <row Id="20692" PostTypeId="2" ParentId="20691" CreationDate="2019-07-21T22:29:34.383" Score="5" Body="&lt;p&gt;You should use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Aexecute&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:execute&lt;/code&gt;&lt;/a&gt; to run a command built from a string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your particular case, this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F7&amp;gt; :execute 'make -C '.FindProjectRootDir()&amp;lt;CR&amp;gt;:copen&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it wasn't for &lt;code&gt;:execute&lt;/code&gt;, Vim would assume what you wanted was the literal &lt;code&gt;FindProjectRootDir()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/28.html&quot; rel=&quot;noreferrer&quot;&gt;&quot;Execute&quot;&lt;/a&gt; section in &quot;Learn Vimscript the Hard Way&quot; has a great explanation of when you need to use &lt;code&gt;:execute&lt;/code&gt;, why you need it and why it isn't as dangerous as it may seem (even though it looks a lot like &lt;code&gt;eval&lt;/code&gt; statements from other languages.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-07-22T00:04:05.577" LastActivityDate="2019-07-22T00:04:05.577" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20693" PostTypeId="2" ParentId="594" CreationDate="2019-07-21T22:41:42.700" Score="0" Body="&lt;p&gt;My attemp to solve the issue&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vip ............... select paragraph&#xA;:'&amp;lt;,'&amp;gt;!column -t    align&#xA;:%norm $X ......... remove one space&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2019-07-21T22:41:42.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20694" PostTypeId="2" ParentId="20680" CreationDate="2019-07-22T05:36:54.313" Score="6" Body="&lt;p&gt;This answer builds on &lt;a href=&quot;https://vi.stackexchange.com/a/20685/18609&quot;&gt;dedowsdi's answer&lt;/a&gt;, but implements something closer to your specification:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Turns the word &lt;em&gt;under the cursor&lt;/em&gt; into uppercase (cursor doesn't have to be at the start of the word.)&lt;/li&gt;&#xA;&lt;li&gt;Doesn't change the cursor position while doing that.&lt;/li&gt;&#xA;&lt;li&gt;Uses &lt;code&gt;CTRL-U&lt;/code&gt; for mapping.&lt;/li&gt;&#xA;&lt;li&gt;Acts on keyword characters (as you mentioned &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; and not &lt;code&gt;&amp;lt;cWORD&amp;gt;&lt;/code&gt;, and I assume you did so intentionally.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If the cursor is on whitespace, on a non-keyword character, or at the end of the line, it will act on the word before the cursor. This is useful to turn the last typed word to uppercase by simply typing it and pressing &lt;code&gt;CTRL-U&lt;/code&gt;, and you'll be able to resume the command-line from there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, I agree with dedowsdi's choice of Vim features to implement this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_CTRL-%5C_e&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;CTRL-\ e&lt;/code&gt;&lt;/a&gt; is the most flexible way to write mappings for the command-line mode. Using &lt;code&gt;q:&lt;/code&gt; or &lt;code&gt;CTRL-F&lt;/code&gt; make mappings easier to write, by acting on a buffer with normal mode commands, but it doesn't seem like it's possible to dismiss that window upon returning to the command-line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;matchlist()&lt;/code&gt; with a suitable regex, and in particular using the &lt;code&gt;\%Nc&lt;/code&gt; family for matching on a column is the way to go to find the word under the cursor. (I was thinking of writing a &lt;code&gt;split()&lt;/code&gt; and a &lt;code&gt;for&lt;/code&gt; loop and quickly got stuck there.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Vimscript code and mapping&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The code is below. I used a public function suitable for &lt;code&gt;.vimrc&lt;/code&gt;, but it should be easy to adapt it to use a &lt;code&gt;s:&lt;/code&gt; function and refer to it by &lt;code&gt;&amp;lt;sid&amp;gt;&lt;/code&gt; as well.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CmdUpcaseWord()&#xA;  &quot; Split cmdline into 3 parts, where the middle&#xA;  &quot; one is the word under the cursor (or before&#xA;  &quot; the cursor, if the cursor is at the end, on&#xA;  &quot; whitespace or on a non-keyword character.)&#xA;  let re = '\v(.*&amp;lt;)%&amp;lt;'.(getcmdpos()+1).'c(\w+)(.*)'&#xA;  let matches = matchlist(getcmdline(), re)&#xA;  if len(matches) &amp;lt; 4&#xA;    return getcmdline()&#xA;  endif&#xA;  let [pre, word, post] = matches[1:3]&#xA;  return pre.toupper(word).post&#xA;endfunction&#xA;&#xA;cnoremap &amp;lt;c-u&amp;gt; &amp;lt;c-\&amp;gt;eCmdUpcaseWord()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;The regex&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Let's break down the regex.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Cv&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\v&lt;/code&gt;&lt;/a&gt;: Use the &quot;very magic&quot; flavor of regexes, so that it works independent of &lt;code&gt;set nomagic&lt;/code&gt; and fewer backslashes are needed.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(.*&amp;lt;)&lt;/code&gt;: Find the longest sequence ending on a &quot;start of word&quot; boundary. Under &quot;very magic&quot;, &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%3C&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/a&gt; matches the beginning of a word (none of the symbols need to be backslashed.) And as &lt;code&gt;*&lt;/code&gt; is greedy, the longest match will be used. Capture it in the first group.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%25%3Cc&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;%&amp;lt;&lt;em&gt;NN&lt;/em&gt;c&lt;/code&gt;&lt;/a&gt;: Matches &lt;em&gt;before&lt;/em&gt; column &lt;code&gt;*NN&lt;/code&gt;, in this case, up to the column where the cursor is. Considering we want to accept a match ending at the column where the cursor is, we use &lt;code&gt;getcmdpos()+1&lt;/code&gt; to make it equivalent to a &lt;code&gt;&amp;lt;=&lt;/code&gt; match.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(\w+)&lt;/code&gt;: Followed by a &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Cw&quot; rel=&quot;noreferrer&quot;&gt;word&lt;/a&gt;, captured in the middle group.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(.*)&lt;/code&gt;: Finally, capture the rest of the line, captured in the last group.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The end result of using a greedy regex at the start, a match for word boundary, a constraint for the column of the cursor and following it right with word characters accomplishes what was specified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like to match a WORD (as in &lt;code&gt;&amp;lt;cWORD&amp;gt;&lt;/code&gt;) instead, match a sequence of non-blank characters, you can use this regex instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let re = '\v(.*\s)?%&amp;lt;'.(getcmdpos()+1).'c(\S+)(.*)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tested this with the usual corner cases, and it seems to work as expected.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Keybinding&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I agree with the point made by &lt;a href=&quot;https://vi.stackexchange.com/a/20682/18609&quot;&gt;D. Ben Knoble in his answer&lt;/a&gt;, &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_CTRL-U&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;CTRL-U&lt;/code&gt;&lt;/a&gt; is a useful keystroke (for &quot;kill line&quot;) in command-line mode, so I'd recommend using a different keystroke instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, as you want to start adding more bindings to the command-line mode, you'll end up running out of CTRL-key sequences quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My recommendation would be to use &lt;code&gt;CTRL-G&lt;/code&gt;, which is unused, and then use a second keystroke after &lt;code&gt;CTRL-G&lt;/code&gt;, so you have a whole new namespace of mappings to exploit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, since the &lt;code&gt;g&lt;/code&gt; mappings in normal mode work similarly as a namespace (in fact, there's &lt;code&gt;gU&lt;/code&gt; for uppercase and &lt;code&gt;gu&lt;/code&gt; for lowercase), you can use something similar for &lt;code&gt;CTRL-G&lt;/code&gt; in command-line mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;c-g&amp;gt;U &amp;lt;c-\&amp;gt;eCmdUpcaseWord()&amp;lt;cr&amp;gt;&#xA;cnoremap &amp;lt;c-g&amp;gt;u &amp;lt;c-\&amp;gt;eCmdLocaseWord()&amp;lt;cr&amp;gt;&#xA;&quot; etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Command-line window&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Finally, in another point made by &lt;a href=&quot;https://vi.stackexchange.com/a/20682/18609&quot;&gt;D. Ben Knoble&lt;/a&gt;, I'd also recommend skipping on this kind of mapping altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, just use the command-line window instead, which allows you to use any arbitrary normal mode commands to edit your command-line. You have the full power of Vim to edit your Vim command-lines, what's not to like?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can enter it with &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_CTRL-F&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;CTRL-F&lt;/code&gt;&lt;/a&gt; from the command-line itself. Or, if you're in normal mode, you can type &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#q%3A&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;q:&lt;/code&gt;&lt;/a&gt; instead of &lt;code&gt;:&lt;/code&gt; to go straight to the command-line window to write your command from scratch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then use &lt;a href=&quot;https://vimhelp.org/change.txt.html#gU&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;gU{motion}&lt;/code&gt;&lt;/a&gt; to make any parts of the command uppercase, in addition to the full power of normal mode commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you're happy with your edits, you can either press &quot;ENTER&quot; to execute the command directly, or if you wish to resume the command-line, you can press &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#E199&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;CTRL-C&lt;/code&gt;&lt;/a&gt; to go back to the usual command-line, accepting the edits performed in the command-line window.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-22T05:36:54.313" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20695" PostTypeId="2" ParentId="18969" CreationDate="2019-07-22T10:39:07.897" Score="1" Body="&lt;p&gt;I use the following to access &lt;code&gt;:terminal&lt;/code&gt;. It searches for terminal buffers, if there is none it opens a new one in a new tab. If there are any it uses the first one it found, if that terminal buffer is currently displayed in a window it changes to that window, else it opens a new tab and displays the terminal buffer therein.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I only used this in NeoVim so far, it should also work in Vim, though&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TerminalTab()&#xA;    &quot; find evey terminal buffer&#xA;    let b = filter(range(1, bufnr('$')),&#xA;                \'getbufvar(v:val, &quot;&amp;amp;buftype&quot;, &quot;ERROR&quot;) == &quot;terminal&quot;')&#xA;    &quot; if no terminal buffers are available&#xA;    if len(b) == 0&#xA;        tabnew&#xA;        terminal&#xA;    else&#xA;        &quot; we only care for the first terminal buffer&#xA;        let b = b[0]&#xA;        let bb = win_findbuf(b)&#xA;        &quot; if there is no window in any tab that contains a terminal&#xA;        if len(bb) == 0&#xA;            tabnew&#xA;            buffer b&#xA;        else&#xA;            &quot; again we only care for the first match&#xA;            let bb = win_id2tabwin(bb[0])&#xA;            exe 'tabnext'.bb[0]&#xA;            exe bb[1].'wincmd w'&#xA;        endif&#xA;    endif&#xA;    &quot; we open a terminal to do something&#xA;    startinsert&#xA;endfunc&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;s :call TerminalTab()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16779" LastActivityDate="2019-07-22T10:39:07.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20697" PostTypeId="1" CreationDate="2019-07-22T14:55:16.220" Score="1" ViewCount="85" Body="&lt;p&gt;Let's say I have this text with &lt;code&gt;|&lt;/code&gt; as my cursor: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&#xA;hi&#xA;=======&#xA;hello&#xA;======&#xA;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; XXXX GGg| &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I'd like to select from &gt;&gt;&gt;&gt; to say second=== or line containing &amp;lt;&amp;lt;&amp;lt;&amp;lt; word. How do I do that?&lt;/p&gt;&#xA;" OwnerUserId="10062" LastActivityDate="2019-07-22T23:56:55.147" Title="How to end selection at an occurrence of a word?" Tags="|cursor-motions|selection|" AnswerCount="4" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20698" PostTypeId="2" ParentId="20697" CreationDate="2019-07-22T15:15:00.973" Score="0" Body="&lt;p&gt;You better be more clear|specific...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Now, I'd like to select from &gt;&gt;&gt;&gt; to say second===&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Vk&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;or line containing &amp;lt;&amp;lt;&amp;lt;&amp;lt; word. How do I do that?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Vgg&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if you want the answer to &quot;How to end selection at an occurrence of a word?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;he|llo beautiful world&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where | is your cursor and you want to select till the end of the &quot;beautiful&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;v/ful/e&lt;/code&gt; which is &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;v&lt;/code&gt; visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/ful&lt;/code&gt; search for &quot;ful&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/e&lt;/code&gt; move cursor to the end of word found&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-07-22T15:15:00.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20699" PostTypeId="2" ParentId="20697" CreationDate="2019-07-22T15:19:41.107" Score="2" Body="&lt;p&gt;To answer your question in a more general way, you can combine the visual mode with any motion you use in normal mode. That means that you can use &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt;, &lt;code&gt;w&lt;/code&gt;, etc but you can also use the search:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case with your cursor after &lt;code&gt;GGg&lt;/code&gt; you can start reverse search mode with &lt;kbd&gt;?&lt;/kbd&gt; and type &lt;code&gt;&amp;lt;&lt;/code&gt; in your search prompt. When you type &lt;kbd&gt;Enter&lt;/kbd&gt; the end of your selection will end up on the last &lt;code&gt;&amp;lt;&lt;/code&gt; of the first line. (Maybe linewise visual selection can be useful for you here, it is triggered with &lt;kbd&gt;Shift+v&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if you already did the search you can use the motions &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; to move your visual selection too.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-07-22T15:19:41.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20700" PostTypeId="2" ParentId="20697" CreationDate="2019-07-22T15:23:00.777" Score="0" Body="&lt;p&gt;After you enter visual mode (linewise with &lt;a href=&quot;https://vimhelp.org/visual.txt.html#linewise-visual&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;V&lt;/code&gt;&lt;/a&gt; is probably what you want), you can use the &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%3F&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;?&lt;/code&gt;&lt;/a&gt; to search backwards for the specific string you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'd like to select from &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; to say second &lt;code&gt;===&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;V&lt;/code&gt;, then &lt;code&gt;?^======&lt;/code&gt; and press enter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;n&lt;/code&gt; if you want to continue the selection to the first &lt;code&gt;======&lt;/code&gt; line.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;or line containing &lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/code&gt; word.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;V&lt;/code&gt;, then &lt;code&gt;?^&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/code&gt; and press enter.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-22T15:23:00.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20701" PostTypeId="1" AcceptedAnswerId="20702" CreationDate="2019-07-22T20:53:32.497" Score="4" ViewCount="253" Body="&lt;p&gt;I have opened vim in a directory of code which contains &lt;code&gt;long_name_module.py&lt;/code&gt;.  My path variable is &lt;code&gt;path+=**&lt;/code&gt; so the python file is visible to &lt;code&gt;find&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:find lo&amp;lt;tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the filename is completed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:find long_name_module.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Given this state in the command panel is there a way to pipe this to a split or vsplit like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:find long_name_module.py | vs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To save returning to the start of the command, changing &lt;code&gt;find&lt;/code&gt; to &lt;code&gt;vs&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a &lt;code&gt;vfind&lt;/code&gt; like method that would be great to know but I'm also interested in a sequential way of achiving this.&lt;/p&gt;&#xA;" OwnerUserId="22557" LastActivityDate="2019-07-22T23:31:55.730" Title="Pipe native command to vsplit" Tags="|split|find|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20702" PostTypeId="2" ParentId="20701" CreationDate="2019-07-22T23:31:55.730" Score="2" Body="&lt;p&gt;For your particular case, you can use &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Avertical&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:vertical&lt;/code&gt;&lt;/a&gt; &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Asfind&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;sfind&lt;/code&gt;&lt;/a&gt;, in which case you can Tab-complete the filename, same as you can do with &lt;code&gt;:find&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Short version is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vert sf lo&amp;lt;TAB&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will complete to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vert sf long_name_module.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And will open your file in a vertical split as you requested.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;More generally, Vim doesn't really have a concept similar to &quot;pipes&quot; in the shell to compose arbitrary commands, so there isn't really a general way to accomplish what you described with general commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest concept to this in Vim is that of commands that execute other commands but modify their behavior as they run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some examples of such modifier commands are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Avertical&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:vertical&lt;/code&gt;&lt;/a&gt;, which we just used in order to modify the way &lt;code&gt;:sfind&lt;/code&gt; works and split vertically rather than horizontally.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Aleftabove&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:leftabove&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Arightbelow&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:rightbelow&lt;/code&gt;&lt;/a&gt;, which also change how splits will work, more specifically where the next splits will open.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#%3Anoautocmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:noautocmd&lt;/code&gt;&lt;/a&gt;, to disable execution of auto-commands for a particular command execution.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Asilent&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:silent&lt;/code&gt;&lt;/a&gt;, which can silent the output of commands it executes.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Asandbox&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:sandbox&lt;/code&gt;&lt;/a&gt;, to run a potentially untrusted command in a sandbox and contain its effects.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can use many of these together. For example, &lt;code&gt;:silent noautocmd vertical rightbelow call MyFunc()&lt;/code&gt; will execute the &lt;code&gt;MyFunc()&lt;/code&gt; function, in silence, and if it splits to open a new file, it will be done vertically with a new split on the right, and no auto-commands will be executed for it. So, in a way, that's similar to how you'd chain multiple commands using pipes in a shell, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that for some particular cases, you end up with dedicated commands. For instance, there's not really a command modifier to open the next file &lt;em&gt;in a new split&lt;/em&gt;, so you end up with &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Asfind&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:sfind&lt;/code&gt;&lt;/a&gt; (similar to &lt;code&gt;:find&lt;/code&gt;), &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Anew&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:new&lt;/code&gt;&lt;/a&gt; (similar to &lt;code&gt;:enew&lt;/code&gt;), etc.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-22T23:31:55.730" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20703" PostTypeId="2" ParentId="20697" CreationDate="2019-07-22T23:49:46.307" Score="0" Body="&lt;pre&gt;&lt;code&gt;^va&amp;gt;V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; go 1st &lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;va&amp;gt;&lt;/code&gt; select &lt;a href=&quot;https://vimhelp.org/motion.txt.html#a%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h a&gt;&lt;/a&gt; block&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt; &lt;code&gt;a&amp;gt;&lt;/code&gt; is characterwise, need to convert to  linewise.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another way is to add &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; to &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27matchpairs%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'matchpairs'&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mps+=&amp;lt;:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V^%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt; start visual linewise &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt; go to 1st &lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt; goto matching &lt;code&gt;&amp;lt;&lt;/code&gt; for current &lt;code&gt;&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If there are &lt;code&gt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;gt;&lt;/code&gt; in the body, add an &lt;code&gt;e&lt;/code&gt; after &lt;code&gt;^&lt;/code&gt; to search match for the most outside &lt;code&gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the &lt;code&gt;===&lt;/code&gt; part, use &lt;code&gt;?^===&lt;/code&gt; to search backward, use &lt;code&gt;n&lt;/code&gt; to repeat last search.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-07-22T23:56:55.147" LastActivityDate="2019-07-22T23:56:55.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20704" PostTypeId="1" AcceptedAnswerId="20706" CreationDate="2019-07-23T06:14:17.477" Score="17" ViewCount="3512" Body="&lt;p&gt;I have the following line in my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;INCORRECT_EMAIL_MOBILE_COMBINATION(&quot;incorrect_email_mobile_combination&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try to substitute the underscores with spaces in visual mode (using &lt;code&gt;:'&amp;lt;,'&amp;gt;s/_/ /g&lt;/code&gt;), vim substitutes all underscores in the line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I replace the underscores just within the quotes?&lt;/p&gt;&#xA;" OwnerUserId="11044" LastEditorUserId="10604" LastEditDate="2020-02-04T22:59:29.310" LastActivityDate="2021-02-16T23:26:27.210" Title="How to run a substitute command on only a certain part of the line" Tags="|substitute|visual-mode|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20705" PostTypeId="2" ParentId="20704" CreationDate="2019-07-23T06:39:58.220" Score="3" Body="&lt;p&gt;You could also just match on uppercase characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\L\zs_//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or match the column numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\%&amp;gt;3\%&amp;lt;8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;only matches between column 3 and 8&lt;/p&gt;&#xA;" OwnerUserId="11316" LastEditorUserId="11316" LastEditDate="2019-07-23T09:40:26.447" LastActivityDate="2019-07-23T09:40:26.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20706" PostTypeId="2" ParentId="20704" CreationDate="2019-07-23T06:48:44.573" Score="20" Body="&lt;p&gt;&lt;em&gt;Yes, this is a long answer. That's because I try to cover the sometimes intimidating sub-replace expression as clearly as I can. Don't be frightened...please dive in!&lt;/em&gt; :)&lt;/p&gt;&#xA;&lt;p&gt;This can be looked at as a search-replace where the search is multi-level or nested. That is, first you need to match part of the line (i.e. quoted text in this case). Then you need to match part of &lt;em&gt;that&lt;/em&gt; string (i.e. underscores) and do the replacement on that.&lt;/p&gt;&#xA;&lt;p&gt;Basic regexes weren't really meant to handle nested searches (depending on the regex variant a complex solution may be possible). Fortunately, Vim has something called the &lt;a href=&quot;https://vimhelp.org/change.txt.html#sub-replace-expression&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;sub-replace&lt;/em&gt; expression&lt;/a&gt; and it is commonly used to solve these problems. Here's how we'd apply that to question's example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:s/&amp;quot;\zs[^&amp;quot;]\+\ze&amp;quot;/\=substitute(submatch(0), '_', ' ', 'g')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In the pattern component we match quoted strings then segregate the text within from the quotes with the &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#/%5Czs&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\zs&lt;/code&gt;&lt;/a&gt;...&lt;a href=&quot;https://vimhelp.org/pattern.txt.html#/%5Cze&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\ze&lt;/code&gt;&lt;/a&gt; pair. So the pattern will match just the string inside the double quotes. Breaking it down...&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;quot;&lt;/code&gt; : match an opening double-quote&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs&lt;/code&gt; : exclude from the final match (to which substitution is applied) all preceding text&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^&amp;quot;]\+&lt;/code&gt; : match one or more characters excluding double quotes&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\ze&lt;/code&gt; : exclude from the final match all following text&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;quot;&lt;/code&gt; : match a (closing) double-quote&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In the replacement component we open with &lt;code&gt;\=&lt;/code&gt;. This special operator tells Vim to &lt;em&gt;treat everything that follows as an expression, evaluate it, and use the result as the replacement of the final matched text&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the expression we invoke &lt;a href=&quot;https://vimhelp.org/eval.txt.html#substitute()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;substitute()&lt;/code&gt;&lt;/a&gt;. This function's parameters are:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;substitute({expression}, {pattern}, {replacement}, {flags})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Parameters 2-4 mirror the components of a substitution &lt;em&gt;command&lt;/em&gt;, i.e. &lt;code&gt;:s/pattern/replacement/flags&lt;/code&gt;. The first parameter must resolve to the string to which the other parameters apply. We are using &lt;a href=&quot;https://vimhelp.org/eval.txt.html#submatch()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;submatch({matchnum})&lt;/code&gt;&lt;/a&gt; which, with parameter value 0, returns the complete matched string from the pattern described previously. (Values other than 0 will return, naturally, pattern sub-matches which are denoted by surrounding &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt;. We don't have any sub-matches here but below is an example that uses them.)&lt;/p&gt;&#xA;&lt;p&gt;In this case  the return value and thus the replacement text is just what we're looking for: the string between the quotes expect with spaces instead of underscores.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Bringing a rocket launcher to a knife fight?&lt;/h3&gt;&#xA;&lt;p&gt;A few people have opined that this approach is too complicated. While I wouldn't use it for one-off editing of a line or two, respectfully, non-Euclidean geometry is complicated. For this all you need is reasonable familiarity with regexes and &lt;code&gt;\zs&lt;/code&gt;..&lt;code&gt;\ze&lt;/code&gt; to match the part(s) of the line to which you want to apply substitution. Then...&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Type in the pattern&lt;/li&gt;&#xA;&lt;li&gt;Type or paste this: &lt;code&gt;/\=substitute(submatch(0), '', '', 'g')/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Fill in params 2 and 3 with replacee and replacer text&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Bonus Material&lt;/h2&gt;&#xA;&lt;p&gt;Since there seems to a bit of interest around this topic I figured I'd add a couple variations of the solution above in the hopes of shining additional light on things. We all like lots of examples, right?&lt;/p&gt;&#xA;&lt;h3&gt;Solving without \zs or \ze&lt;/h3&gt;&#xA;&lt;p&gt;In the original solution I use the Vim specific &lt;code&gt;\zs&lt;/code&gt;..&lt;code&gt;\ze&lt;/code&gt; token pair because knowing how to use those gives a lot of flexibility (with respect to sub-replace expressions and generally speaking when using regex in Vim). In reality though the OPs specific case doesn't need them...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; s/&amp;quot;[^&amp;quot;]\+&amp;quot;/\=substitute(submatch(0), '_', ' ', 'g')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;We just include the quotes in the matched string and it's fine because the substitution only affects underscores.&lt;/p&gt;&#xA;&lt;h3&gt;A slightly harder problem&lt;/h3&gt;&#xA;&lt;p&gt;Our input string is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;INCORRECT_EMAIL_MOBILE_COMBINATION(&amp;quot;_incorrect_email_mobile_combination_&amp;quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;...and we want to replace the underscores inside the double-quotes but only those that have word characters on both sides. So we want to end up with...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;INCORRECT_EMAIL_MOBILE_COMBINATION(&amp;quot;_incorrect email mobile combination_&amp;quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Yes, &lt;code&gt;\zs&lt;/code&gt;..&lt;code&gt;\ze&lt;/code&gt; would come in handy again here but let's pretend we need a portable regex...&lt;/p&gt;&#xA;&lt;p&gt;Solution:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s/&amp;quot;_\([^&amp;quot;]\+\)_&amp;quot;/\='&amp;quot;_' . substitute(submatch(1), '_', ' ', 'g') . '_&amp;quot;'/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;First we wrap the part of the string to be modified in a capture group &lt;code&gt;\(..\)&lt;/code&gt;. This allows us to isolate the string from the quotes and outer underscores when we do the substitution by using &lt;code&gt;submatch(1)&lt;/code&gt; (returns string contained in first capture group) instead of &lt;code&gt;submatch(0)&lt;/code&gt; (returns entire matched string).&lt;/p&gt;&#xA;&lt;p&gt;Of course we will lose the quote-underscore pairs if we stop at the &lt;code&gt;substitute()&lt;/code&gt; call.  But we can just insert them into the sub-replace expression literally by (single) quoting them and using the concatenation operator (&lt;code&gt;.&lt;/code&gt;)...problem solved. Okay but what if the surrounding characters were not fixed? Let's say the quotes could be either single or double, &lt;code&gt;['&amp;quot;]_&lt;/code&gt;..&lt;code&gt;_['&amp;quot;]&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Then we'll have to use more capture groups and change the literal string to &lt;code&gt;submatch()&lt;/code&gt; calls with appropriate indices.&lt;/p&gt;&#xA;&lt;p&gt;Switching to &lt;em&gt;very magic&lt;/em&gt; mode (&lt;code&gt;\v&lt;/code&gt;) so the pattern is a little easier to read our solution is...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s/\v(['&amp;quot;]_)([^&amp;quot;]+)(_['&amp;quot;])/\=submatch(1) . substitute(submatch(2), '_', ' ', 'g') . submatch(3)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2021-02-16T23:26:27.210" LastActivityDate="2021-02-16T23:26:27.210" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20707" PostTypeId="2" ParentId="20704" CreationDate="2019-07-23T07:08:08.610" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How do I replace the underscores just within the quotes?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I assume that it's okay to replace all underscores just after the first quote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;normal f&quot;f_r ,.,.,.,.,.,.,.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, go &lt;code&gt;f&lt;/code&gt;ind the quote, then go &lt;code&gt;f&lt;/code&gt;ind the underscore, then &lt;code&gt;r&lt;/code&gt;eplace it with space, then repeat find/replace until it's enough (or even more than enough).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;'&amp;lt;&lt;/code&gt; and &lt;code&gt;'&amp;gt;&lt;/code&gt; are added automatically (because of the Visual mode), so you don't have to type them yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you can modify it to make use of a register if you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably, this solution is a bit of a hack, but I think it's easier than studying and debugging regexps for such routine tasks.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-07-23T07:08:08.610" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20708" PostTypeId="1" AcceptedAnswerId="21003" CreationDate="2019-07-23T08:04:44.750" Score="3" ViewCount="277" Body="&lt;p&gt;I use both &lt;a href=&quot;https://github.com/w0rp/ale/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ale&lt;/a&gt; and VIM &lt;a href=&quot;https://github.com/rkitover/vimpager&quot; rel=&quot;nofollow noreferrer&quot;&gt;pager&lt;/a&gt; plugins. But for obvious reasons I want to disable some Vim features and plugins in the &quot;less&quot; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I put as recommended this piece of code in my &lt;code&gt;.vimrc&lt;/code&gt; it still starts Ale:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('g:vimpager.enabled')&#xA;   set nospell&#xA;   let g:ale_enabled = 0&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if I start vimpager with &lt;code&gt;vimpager some_file.py&lt;/code&gt; it will still show Ale error and warning messages&lt;/p&gt;&#xA;" OwnerUserId="1515" LastActivityDate="2019-08-27T04:30:47.517" Title="How to disable Ale if PAGER mode is enabled" Tags="|plugin-ale|pager|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20709" PostTypeId="2" ParentId="20704" CreationDate="2019-07-23T11:46:56.533" Score="13" Body="&lt;p&gt;Since you mentioned visual mode... You can also use the &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%25V&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\%V&lt;/code&gt;&lt;/a&gt; match to only match inside the current visual selection (or last one, if not in visual mode.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;\%V&lt;/code&gt; would allow you to use the same command, with minimal modification:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V_/ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's assuming you have a visual selection around the quoted string, where you want to replace underscores.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Technically, the above will also match an underscore at the end of the selection, because &lt;code&gt;\%V&lt;/code&gt; is a zero-width match and while itself will only match within the selection, the underscore right after it might be outside. For cases where this matters, you can add another &lt;code&gt;\%V&lt;/code&gt; at the end of the pattern, to ensure the whole pattern is inside the selection.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V_\%V/ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tend to find the &lt;code&gt;\%V&lt;/code&gt; match quite useful, since it makes it very easy to quickly modify a &lt;code&gt;:s&lt;/code&gt; command to only work inside a selection, without having to change approach to use a normal mode command or to use an expression with functions as the replacement.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-23T11:46:56.533" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20710" PostTypeId="2" ParentId="20708" CreationDate="2019-07-23T12:57:59.640" Score="0" Body="&lt;p&gt;To quote the docs:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To disable loading plugins, put &quot;set noloadplugins&quot; into a vimpagerrc file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Vimpagerrc can be &lt;code&gt;~/.vimpagerrc&lt;/code&gt; or (recommended for version control) &lt;code&gt;~/.vim/vimpagerrc&lt;/code&gt; or in the file named by the value of the environment variable &lt;code&gt;VIMPAGER_RC&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also try putting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_enabled = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the vimpagerrc as filbranden suggests. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-23T15:26:09.960" LastActivityDate="2019-07-23T15:26:09.960" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20711" PostTypeId="1" CreationDate="2019-07-23T15:31:59.140" Score="1" ViewCount="1279" Body="&lt;p&gt;I have the following line in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap kj &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It had been working fine, ie it returned me to normal mode. But now it inserts the string &quot;&amp;lt; Esc&gt;&quot; (I use the initial space here just so my post displays properly) into the file at the cursor and I remain in insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My full .vimrc is as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;set smartindent&#xA;set shiftwidth=4&#xA;set expandtab&#xA;set tabstop=4&#xA;inoremap kj &amp;lt;Esc&amp;gt;&#xA;nnoremap zz :update&amp;lt;cr&amp;gt;&#xA;nnoremap qq :wq&amp;lt;cr&amp;gt;&#xA;nnoremap mm :vsplit&amp;lt;cr&amp;gt;&amp;lt;C-w&amp;gt;&amp;lt;C-w&amp;gt;&#xA;&quot; Ctrl-j/k deletes blank line below/above, and Alt-j/k inserts.&quot;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;C-j&amp;gt; m`:silent +g/\m^\s*$/d&amp;lt;CR&amp;gt;``:noh&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;C-k&amp;gt; m`:silent -g/\m^\s*$/d&amp;lt;CR&amp;gt;``:noh&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;A-j&amp;gt; :set paste&amp;lt;CR&amp;gt;m`o&amp;lt;Esc&amp;gt;``:set nopaste&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;A-k&amp;gt; :set paste&amp;lt;CR&amp;gt;m`O&amp;lt;Esc&amp;gt;``:set nopaste&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Enter&amp;gt; i&amp;lt;Enter&amp;gt;&amp;lt;Esc&amp;gt;&#xA;nnoremap &amp;lt;S-Enter&amp;gt; o&amp;lt;Esc&amp;gt;&#xA;nnoremap &amp;lt;S-tab&amp;gt; i&amp;lt;tab&amp;gt;&amp;lt;Esc&amp;gt;l&#xA;nnoremap &amp;lt;C-x&amp;gt; ^i#&amp;lt;Esc&amp;gt;&#xA;nnoremap &amp;lt;C-d&amp;gt; yy^i#&amp;lt;Esc&amp;gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why has this started happening and how can I fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;output of the following commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set compatible?&#xA;nocompatible&#xA;&#xA;:set cpoptions?&#xA;cpoptions=aAbBcCdDeEfFgHiIjJkKlLmMnoOpPqrRsStuvwWxXyZ$!%*-+&amp;lt;&amp;gt;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT2:&#xA;I'm running Arch Linux, 4.19.56-1-lts, and the latest version of Vim.&#xA;Output of &quot;vim --version&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul  4 2019 23:02:48)&#xA;Included patches: 1-1635&#xA;Compiled by Arch Linux&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               -farsi             -mouse_sysmouse    -tag_any_white&#xA;+arabic            +file_in_path      +mouse_urxvt       +tcl/dyn&#xA;+autocmd           +find_in_path      +mouse_xterm       +termguicolors&#xA;+autochdir         +float             +multi_byte        +terminal&#xA;-autoservername    +folding           +multi_lang        +terminfo&#xA;-balloon_eval      -footer            -mzscheme          +termresponse&#xA;+balloon_eval_term +fork()            +netbeans_intg     +textobjects&#xA;-browse            +gettext           +num64             +textprop&#xA;++builtin_terms    -hangul_input      +packages          +timers&#xA;+byte_offset       +iconv             +path_extra        +title&#xA;+channel           +insert_expand     +perl/dyn          -toolbar&#xA;+cindent           +job               +persistent_undo   +user_commands&#xA;-clientserver      +jumplist          +postscript        +vartabs&#xA;-clipboard         +keymap            +printer           +vertsplit&#xA;+cmdline_compl     +lambda            +profile           +virtualedit&#xA;+cmdline_hist      +langmap           +python/dyn        +visual&#xA;+cmdline_info      +libcall           +python3/dyn       +visualextra&#xA;+comments          +linebreak         +quickfix          +viminfo&#xA;+conceal           +lispindent        +reltime           +vreplace&#xA;+cryptv            +listcmds          +rightleft         +wildignore&#xA;+cscope            +localmap          +ruby/dyn          +wildmenu&#xA;+cursorbind        +lua/dyn           +scrollbind        +windows&#xA;+cursorshape       +menu              +signs             +writebackup&#xA;+dialog_con        +mksession         +smartindent       -X11&#xA;+diff              +modify_fname      -sound             -xfontset&#xA;+digraphs          +mouse             +spell             -xim&#xA;-dnd               -mouseshape        +startuptime       -xpm&#xA;-ebcdic            +mouse_dec         +statusline        -xsmp&#xA;+emacs_tags        +mouse_gpm         -sun_workshop      -xterm_clipboard&#xA;+eval              -mouse_jsbterm     +syntax            -xterm_save&#xA;+ex_extra          +mouse_netterm     +tag_binary        &#xA;+extra_search      +mouse_sgr         -tag_old_static    &#xA;   system vimrc file: &quot;/etc/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim        -lm -ltinfo -lelf -lnsl    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/5.30/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23129" LastEditorUserId="23129" LastEditDate="2019-07-23T18:42:02.873" LastActivityDate="2019-07-23T18:42:02.873" Title="Mapping using &lt;Esc&gt; writes &quot;&lt;Esc&gt;&quot; in insert mode rather than switching to normal mode" Tags="|key-bindings|insert-mode|normal-mode|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20712" PostTypeId="2" ParentId="20711" CreationDate="2019-07-23T16:33:59.167" Score="3" Body="&lt;p&gt;TL;DR: You're in &lt;code&gt;compatible&lt;/code&gt; mode, add this to the top of your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Key specifiers using the &lt;code&gt;&amp;lt;...&amp;gt;&lt;/code&gt; syntax are incompatible with the traditional &lt;code&gt;vi&lt;/code&gt; and are specific to Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This particular feature can be enabled by removing &lt;code&gt;&amp;lt;&lt;/code&gt; from the [&lt;code&gt;'cpoptions'&lt;/code&gt;] setting, which controls compatibility options. The &lt;code&gt;&amp;lt;&lt;/code&gt; option is documented as:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Disable the recognition of special key codes in &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; form in mappings, abbreviations, and the &quot;to&quot; part of menu commands.  For example, the command &lt;code&gt;:map X &amp;lt;Tab&amp;gt;&lt;/code&gt; results in X being mapped to:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;code&gt;&amp;lt;&lt;/code&gt; included:   &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;  (5 characters)&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;&amp;lt;&lt;/code&gt; excluded:   &lt;code&gt;^I&lt;/code&gt;     (^I is a real )&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When in compatible mode, all options in &lt;code&gt;'cpoptions'&lt;/code&gt; are set, while only a handful (and not including &lt;code&gt;&amp;lt;&lt;/code&gt;) are set in &lt;code&gt;nocompatible&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So ensuring you're in &lt;code&gt;nocompatible&lt;/code&gt; mode is the first step in making sure these mappings are going to work for you.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-23T16:33:59.167" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="20713" PostTypeId="1" CreationDate="2019-07-23T19:14:44.770" Score="0" ViewCount="287" Body="&lt;p&gt;In my &lt;code&gt;C&lt;/code&gt; code I am dealing with many variables of type  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RxMsgType0&#xA;RxMsgType1&#xA;RxMsgType2&#xA;RxMsgType3&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My Question:  Is there a way in VIM by which I can create 4 more variables which follow the same format?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Expected output: [Type Some Command]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RxMsgType4&#xA;RxMsgType5&#xA;RxMsgType6&#xA;RxMsgType7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the future I would like to pass the &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name (RxMsgType assumed here ) &#xA;&#xA;number( we assumed 4 here) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as an argument to get the variable names formed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is my final aim.&lt;/p&gt;&#xA;" OwnerUserId="22212" LastEditorUserId="1841" LastEditDate="2019-07-24T07:57:57.337" LastActivityDate="2019-07-24T07:57:57.337" Title="Increment the number at the end of variable" Tags="|text-generation|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20714" PostTypeId="2" ParentId="20713" CreationDate="2019-07-23T21:17:57.710" Score="2" Body="&lt;p&gt;An alternative solution if you are using vim 8 using the &lt;code&gt;g&amp;lt;c-A&amp;gt;&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;paste the variable n times&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RxMsgType0&#xA;RxMsgType0&#xA;RxMsgType0&#xA;RxMsgType0&#xA;&#xA;... n times&#xA;&#xA;RxMsgType0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;select all line wise e.g if that's the whole file &lt;code&gt;gg &amp;lt;s-V&amp;gt; G&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;g &amp;lt;c-A&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="23132" LastActivityDate="2019-07-23T21:17:57.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20715" PostTypeId="1" AcceptedAnswerId="20823" CreationDate="2019-07-24T08:56:09.340" Score="1" ViewCount="2548" Body="&lt;p&gt;I recently decided to give a try at neovim and one thing is bothering me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use a terminal window to run my code watcher i.e. a never ending command which outputs new lines each time I write a buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I put my cursor on this window and use &lt;code&gt;G&lt;/code&gt; the window will keep track of the output and I will always see the last lines of the output &lt;em&gt;as long as I don't switch of window&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I change of tab or of window, the window containing the terminal buffer stops scrolling and I have to go back to this window and use &lt;code&gt;G&lt;/code&gt; again to see the end of my output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If feel like I'm missing something but I wasn't able to find a solution to this problem. I guess I could have an autocommand on &lt;code&gt;TabEnter&lt;/code&gt; and for example which would find a terminal buffer in the new tab and use &lt;code&gt;norm! G&lt;/code&gt; in it but that feel kind of overkill (plus that wouldn't solve the problem if I have two split buffer and I work on the one next to the terminal buffer). Is there a simple solution to this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Here are the steps to reproduce my issue:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a file and continuously write in it from the shell:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;touch foo&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;while; do; echo 'a' &amp;gt;&amp;gt; foo; sleep 1; done&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Start neovim without any config:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nvim -u NONE -U NONE&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In neovim:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:term tail -f foo&lt;/code&gt; To open a terminal with a continuous output&lt;/li&gt;&#xA;&lt;li&gt;Go to insert mode and add an empty line to follow the output then go to normal mode and &lt;code&gt;G&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:tabnew&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Wait a few seconds&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When going to the first tab, the empty line should have changed of place, for me it doesn't.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-07-30T11:41:29.043" LastActivityDate="2019-08-23T15:26:20.027" Title="How to follow the output of a command in a terminal window" Tags="|neovim|scrolling|terminal-buffer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20716" PostTypeId="2" ParentId="20715" CreationDate="2019-07-24T12:12:29.423" Score="0" Body="&lt;p&gt;You can use this oneliner (from this &lt;a href=&quot;https://unix.stackexchange.com/a/417939/145897&quot;&gt;answer&lt;/a&gt;, tnx &lt;a href=&quot;https://unix.stackexchange.com/users/161003/eli&quot;&gt;eli&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set autoread | au CursorHold * checktime | call feedkeys(&quot;G&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;autoread&lt;/code&gt;: reads the file when changed from the outside&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;CursorHold * checktime&lt;/code&gt;: when the cursor isn't moved by the user for the time specified in &lt;code&gt;updatetime&lt;/code&gt; (which is 4000 miliseconds by default) &lt;code&gt;checktime&lt;/code&gt; is executed, which checks for changes from outside the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;call feedkeys(&quot;G&quot;)&lt;/code&gt;: the cursor is moved to the end of file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To stop the scrolling when using &lt;code&gt;call feedkeys(&quot;G&quot;)&lt;/code&gt;, execute &lt;code&gt;:set noautoread&lt;/code&gt; - now vim will tell, that the file was change ans ask if one wants to read the changes or not)&lt;/p&gt;&#xA;" OwnerUserId="22724" LastActivityDate="2019-07-24T12:12:29.423" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20717" PostTypeId="1" CreationDate="2019-07-24T12:32:03.240" Score="1" ViewCount="228" Body="&lt;p&gt;I try to harmonize the colors of my Vim and Emacs. But I am not sure how to map some Emacs faces to Vim. Emacs distinguishes between &lt;code&gt;keyword&lt;/code&gt; and &lt;code&gt;builtin&lt;/code&gt;. In shell mode &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;case&lt;/code&gt; are of the type &lt;code&gt;keyword&lt;/code&gt;, but &lt;code&gt;alias&lt;/code&gt; is a &lt;code&gt;builtin&lt;/code&gt;. I try to find the equivalent types. In Emacs I can use the function describe-face to inspect the faces in a buffer. How to do the same in Vim? All I found so far is the following list:&#xA;&lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/syntax/syncolor.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/blob/master/runtime/syntax/syncolor.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the list. Some are easy, because they have the same name. But some are not obvious.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Emacs                       Vim&#xA;⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯&#xA;font-lock-builtin-face      ?&#xA;font-lock-comment-face      Comment&#xA;font-lock-constant-face     Constant&#xA;font-lock-function-face     Function&#xA;font-lock-keyword-face      Statement&#xA;font-lock-string-face       String&#xA;font-lock-type-face         Type&#xA;font-lock-variable-face     Identifier&#xA;sh-quoted-exec              ?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the match for &lt;code&gt;builtin&lt;/code&gt; and &lt;code&gt;sh-quoted-exec&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;What is the Vim name for the color of sub shells? &lt;code&gt;$()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;What is the Vim name for punctuation? &lt;code&gt;.;[]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;What is the difference in Vim between the option in &lt;code&gt;shopt -s&lt;/code&gt; and &lt;code&gt;[ -f&lt;/code&gt;? They do not have the same color.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="23144" LastActivityDate="2019-07-25T09:28:50.610" Title="Mapping between Vim syntax highlighting and Emacs font-lock" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="8" ClosedDate="2019-07-24T13:26:22.270" ContentLicense="CC BY-SA 4.0" />
  <row Id="20718" PostTypeId="2" ParentId="20717" CreationDate="2019-07-24T13:39:47.780" Score="0" Body="&lt;p&gt;I added the following function to my &lt;code&gt;emacs.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Inspect Emacs colors with:&#xA;&quot; M-x describe-face&#xA;&quot; Inspect Vim colors with:&#xA;function DescribeFace()&#xA;  let l:s = synID(line('.'), col('.'), 1)&#xA;  let l:r = synIDattr(l:s, 'name')&#xA;  while 1&#xA;    let l:st = synIDtrans(l:s)&#xA;    if l:s == l:st&#xA;      break&#xA;    endif&#xA;    let l:r .= ' ▷ ' . synIDattr(l:st, 'name')&#xA;    let l:s = l:st&#xA;  endwhile&#xA;  echo l:r&#xA;endfunction&#xA;command DescribeFace call DescribeFace()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function displays the name of the syntax at the current point and all ancestors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: this was very useful: &lt;a href=&quot;https://devhints.io/vimscript&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://devhints.io/vimscript&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23144" LastEditorUserId="23144" LastEditDate="2019-07-25T09:28:50.610" LastActivityDate="2019-07-25T09:28:50.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20719" PostTypeId="1" AcceptedAnswerId="20738" CreationDate="2019-07-24T16:51:26.040" Score="2" ViewCount="1006" Body="&lt;p&gt;I am using  VIM version 8.1.1401 on Debian Buster. I am pretty new to VIM (just few days ago I started using it) and trying to get some plugin which can detect the grammatical mistakes. After few google searches I found &lt;a href=&quot;https://github.com/dpelle/vim-LanguageTool&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-LanguageTool&lt;/a&gt; and &lt;a href=&quot;https://github.com/rhysd/vim-grammarous&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-grammarous&lt;/a&gt;. There was little information regarding vim-grammarous's installation steps for newbies. Nonetheless, I finally got both of them working. I can see errors from these two. However, I am unable to correct or navigate between them. I am stuck on 'Scratch' windows. I can see some text suggesting few corrections and mistakes in that window but I am unable to understand how to use them. Can anyone explain it to me in layman's term how to use these plugins? I tried to check how to switch between buffers and scratch windows but none of those have worked. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following is my &lt;code&gt;.vimrc&lt;/code&gt; file (Comments are removed for brevity)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime! debian.vim&#xA;&#xA;set nocompatible              &#xA;filetype off         &#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'ervandew/supertab'&#xA;Plugin 'Valloric/YouCompleteMe'&#xA;Plugin 'dpelle/vim-LanguageTool'&#xA;Plugin 'SirVer/ultisnips'&#xA;Plugin 'lervag/vimtex'&#xA;Plugin 'honza/vim-snippets'&#xA;Plugin 'mtth/scratch.vim'&#xA;&#xA;call vundle#end()            &#xA;filetype plugin indent on    &#xA;&#xA;&#xA;let g:ycm_key_list_select_completion = ['&amp;lt;C-n&amp;gt;', '&amp;lt;Down&amp;gt;']&#xA;let g:ycm_key_list_previous_completion = ['&amp;lt;C-p&amp;gt;', '&amp;lt;Up&amp;gt;']&#xA;let g:SuperTabDefaultCompletionType = '&amp;lt;C-n&amp;gt;'&#xA;&#xA;if !exists('g:ycm_semantic_triggers')&#xA;    let g:ycm_semantic_triggers = {}&#xA;endif&#xA;&#xA;let g:ycm_semantic_triggers.tex = g:vimtex#re#youcompleteme&#xA;let g:tex_flavor='latex'&#xA;&#xA;syntax on&#xA;filetype plugin indent on&#xA;set showcmd     &#xA;set showmatch       &#xA;&#xA;if filereadable(&quot;/etc/vim/vimrc.local&quot;)&#xA;  source /etc/vim/vimrc.local&#xA;endif&#xA;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F9&amp;gt; :exec '!python3' shellescape(@%, 1)&amp;lt;cr&amp;gt;&#xA;map &amp;lt;f2&amp;gt; :w&amp;lt;cr&amp;gt;&amp;lt;leader&amp;gt;ll&#xA;&#xA;autocmd VimLeave * call system(&quot;xsel -ib&quot;, getreg('+'))&#xA;&#xA;noremap j gj&#xA;noremap k gk&#xA;&#xA;:let g:languagetool_jar='/path/to/LanguageTool-4.7/languagetool-commandline.jar'&#xA;:let g:languagetool_lang='en-GB'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try to use any of the commands given in the documentation, I am getting some or another error. Like one I am showing below,&#xA;&lt;a href=&quot;https://i.stack.imgur.com/PeTyi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PeTyi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23150" LastEditorUserId="23150" LastEditDate="2019-07-26T09:35:22.990" LastActivityDate="2019-07-26T09:35:22.990" Title="vim-LanguageTool and vim-grammarous not working" Tags="|grammar-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20720" PostTypeId="1" AcceptedAnswerId="20721" CreationDate="2019-07-24T17:31:10.090" Score="3" ViewCount="3178" Body="&lt;p&gt;All I want to do is to change &lt;code&gt;:vertical resize&lt;/code&gt; + arguments into &lt;code&gt;:vr&lt;/code&gt; + arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for example change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vertical resize +60 &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vr +60 &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From other answers &lt;a href=&quot;https://stackoverflow.com/a/3878710/5402169&quot;&gt;Aliasing a command in vim&lt;/a&gt;, I can see that i can use &lt;code&gt;:command&lt;/code&gt;, but there doesn't seem to be a simple way to pass arguments in the process of aliasing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&lt;br&gt;&#xA;also as a sidenote, I have tried the following and it doesn't seem to pass in the argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Vres &quot;vertical resize&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20473" LastActivityDate="2019-07-24T18:03:31.000" Title="How can I alias a command with arguments?" Tags="|command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20721" PostTypeId="2" ParentId="20720" CreationDate="2019-07-24T17:56:01.807" Score="8" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;it doesn't seem to pass in the argument&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Because you haven't passed it. The right syntax is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Vres vertical resize &amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Simply read &lt;code&gt;:help :command&lt;/code&gt; until the very end to know all the options.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-07-24T18:03:31.000" LastActivityDate="2019-07-24T18:03:31.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20722" PostTypeId="1" AcceptedAnswerId="20735" CreationDate="2019-07-24T20:43:40.157" Score="1" ViewCount="919" Body="&lt;p&gt;I am using ALE plugin with clangtidy linter to lint my C code and whenever I save my file and this linter gets activated it takes around 3-4 seconds for it to check for errors. File in question is around 1000 lines long and I am using a compilation database (compile_commands.json file). Is this the default behaviour of clangtidy? Is it just slow? Or what could be the problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is highly appreciated. Thanks&lt;/p&gt;&#xA;" OwnerUserId="22880" LastActivityDate="2019-07-28T00:17:19.303" Title="ALE + clangtidy + large file = big delay when linting" Tags="|plugin-ale|filetype-c|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20723" PostTypeId="2" ParentId="3512" CreationDate="2019-07-24T22:20:38.633" Score="0" Body="&lt;p&gt;You can visually select commented block with &lt;code&gt;vac&lt;/code&gt; and then create a manual fold &lt;code&gt;zf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Comment text object may be language extension to set of standard vim text objects. Tested it with Go syntax.&lt;/p&gt;&#xA;" OwnerUserId="179" LastActivityDate="2019-07-24T22:20:38.633" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20725" PostTypeId="2" ParentId="14743" CreationDate="2019-07-25T01:34:59.457" Score="1" Body="&lt;p&gt;I dont know if this would help. So far it helped me.&#xA;First I went to .vim/bundle/Vundle.vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I just do &quot;git pull origin master&quot; to pull latest code from the repo. If there is a merge conflict, settle the conflict and pull again. I dont know why, but while you are pulling from the repo, you have to quit any active editting mode on .vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, I went back to my .vimrc, do :PluginClean and suddenly all the plugin I cannot delete is deleted properly. Then I do :PluginUpdate to update again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully this helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess is that, vundle did not update its own code correctly.&lt;/p&gt;&#xA;" OwnerUserId="16492" LastActivityDate="2019-07-25T01:34:59.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20726" PostTypeId="2" ParentId="594" CreationDate="2019-07-25T07:29:50.640" Score="10" Body="&lt;p&gt;See accepted answer to &lt;a href=&quot;https://vi.stackexchange.com/questions/20658/align-a-block-of-code-on-the-basis-of-a-single-character&quot;&gt;Align a block of code on the basis of a single character&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To recap&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;ggVG&lt;/code&gt; to select all&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;normal f:5a&lt;/code&gt; you don't have to enter &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; and also note space at the end. For each line in a selection it will execute normal command to find &lt;code&gt;:&lt;/code&gt; and add 5 spaces after it&lt;/li&gt;&#xA;&lt;li&gt;goto second space after &lt;code&gt;epsilon:  &amp;lt;here&amp;gt;&lt;/code&gt; and press &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; to activate block visual mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;5k&lt;/code&gt; to select one char column up to the first row&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;&lt;/code&gt; to dedent everything 1 time&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt; repeat it until everything is aligned&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;PS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FvLhf.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FvLhf.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-07-25T07:37:32.220" LastActivityDate="2019-07-25T07:37:32.220" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20727" PostTypeId="1" AcceptedAnswerId="20729" CreationDate="2019-07-25T12:24:01.723" Score="2" ViewCount="2275" Body="&lt;p&gt;Say I've done the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^.\{1,50\}$/m$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To move all lines with 50 or less characters to the bottom of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I realise I actually didn't want to do that for the whole file, but for example a paragraph (or for any visually selected lines). I then do &lt;code&gt;u&lt;/code&gt; and &lt;code&gt;vip&lt;/code&gt; to select the paragraph I want the &lt;code&gt;g&lt;/code&gt; command to affect, I press &lt;code&gt;:&lt;/code&gt;, and try to press &lt;code&gt;&amp;lt;UP&amp;gt;&lt;/code&gt; to get the previous command, problem is that there are only commands I've done when I've been in visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I do this, so that I don't have to type the whole &lt;code&gt;g&lt;/code&gt; command again for the visual selection?&lt;/p&gt;&#xA;" OwnerUserId="21062" LastEditorUserId="21062" LastEditDate="2019-08-06T12:27:55.313" LastActivityDate="2019-08-06T12:27:55.313" Title="How to repeat the last : command for a visual selection instead of whole buffer?" Tags="|command-line|visual-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20728" PostTypeId="2" ParentId="20727" CreationDate="2019-07-25T12:40:02.247" Score="1" Body="&lt;p&gt;first of all, you can't do it in general for &lt;em&gt;any&lt;/em&gt; visual selection, since the ex commands operate on lines, so only for &lt;em&gt;the whole lines&lt;/em&gt; which are fully &lt;em&gt;or partially&lt;/em&gt; visually selected you can run such a command. E.g. you have a line 'Hello w&lt;strong&gt;or&lt;/strong&gt;ld' with the 'or' selected, but you can't operate on the selection, which is 'or', only on the whole line 'Hello w&lt;strong&gt;or&lt;/strong&gt;ld'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the automatically placed marks &lt;code&gt;'&amp;lt;&lt;/code&gt; for the first line of the visual selection, and &lt;code&gt;'&amp;gt;&lt;/code&gt; for the last one. The marks can be set with no visible selection (for example, if you escaped the select mode), and the command below will still work, but you can always press &lt;code&gt;gv&lt;/code&gt; in the normal mode, to restore the last selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the command would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt; g/^.\{1,50\}$/m$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the requirement to use the last command without retyping, one can use the &lt;code&gt;normal&lt;/code&gt; ex command and the &lt;code&gt;@:&lt;/code&gt; command from the normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt; normal @:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I personally don't find this convenient, it seems to be quicker to invoke the command history window, find you command (if it was so long to type) edit it quickly with the '&amp;lt;,'&gt; marks and run it&lt;/p&gt;&#xA;" OwnerUserId="2798" LastEditorUserId="2798" LastEditDate="2019-07-25T12:50:07.327" LastActivityDate="2019-07-25T12:50:07.327" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20729" PostTypeId="2" ParentId="20727" CreationDate="2019-07-25T12:54:42.570" Score="3" Body="&lt;p&gt;My preferred solution is&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Select your paragraph &lt;code&gt;vip&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Hit &lt;code&gt;:&lt;/code&gt; and then &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; OR press &lt;code&gt;q:&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move up to your &lt;code&gt;:g&lt;/code&gt; command and do &lt;code&gt;I'&amp;lt;,'&amp;gt;&lt;/code&gt;, then &lt;code&gt;Esc&lt;/code&gt;, then &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As mentioned in the comments, it might be handy to map this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;Leader&amp;gt;. q:&amp;lt;UP&amp;gt;I'&amp;lt;,'&amp;gt;&amp;lt;Esc&amp;gt;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-25T14:52:36.867" LastActivityDate="2019-07-25T14:52:36.867" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20730" PostTypeId="1" AcceptedAnswerId="20732" CreationDate="2019-07-25T13:37:09.583" Score="1" ViewCount="142" Body="&lt;p&gt;strlen(var) can return length without leading zeros.&lt;br&gt;&#xA;How to include leading zeros?&lt;br&gt;&#xA;Example &lt;code&gt;let var=0x00001234&lt;/code&gt;, width shall be 8 instead of 4.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="13402" LastEditDate="2019-07-25T13:56:12.473" LastActivityDate="2019-07-25T13:59:04.670" Title="How to get dynamic hex format variable width with leading zeros?" Tags="|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20731" PostTypeId="2" ParentId="20730" CreationDate="2019-07-25T13:50:28.307" Score="0" Body="&lt;p&gt;This isn't possible with hexadecimal (or decimal) numbers, since &lt;code&gt;0x0001234&lt;/code&gt; is actually just &lt;code&gt;0x1234&lt;/code&gt;, there's no way to &quot;save&quot; the leading zeros anywhere. And the variable simply cannot know that it was declared with leading zeros.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to just pass the variable as a string to have it know it's length with the zeros, then you can convert it to a hex number, when you're ready to use it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let var = '00001234'&#xA;echo strlen(var)  &quot; 8&#xA;&#xA;let var = str2nr(var, 16)&#xA;&quot; use var here&#xA;echo strlen(var)  &quot; 4 (since var == 4660 in decimal)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21062" LastEditorUserId="21062" LastEditDate="2019-07-25T13:59:04.670" LastActivityDate="2019-07-25T13:59:04.670" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20732" PostTypeId="2" ParentId="20730" CreationDate="2019-07-25T13:54:22.973" Score="1" Body="&lt;p&gt;In VimScript variables have (dynamic) types. After &lt;code&gt;let var=0x00001234&lt;/code&gt; the variable's value is a number &lt;code&gt;4660&lt;/code&gt;. &lt;code&gt;strlen()&lt;/code&gt; silently converts number &lt;code&gt;4660&lt;/code&gt; into a string &lt;code&gt;&quot;4660&quot;&lt;/code&gt;, therefore the &quot;string length&quot; is 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use explicit typecasts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let varstring = &quot;00001234&quot;&#xA;let varnumber = str2nr(var, 16)&#xA;echo varnumber strlen(varstring) &quot;4660 8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also you can simply &lt;code&gt;let var=&quot;0x00001234&quot;&lt;/code&gt; and rely on automatic conversion, however &lt;code&gt;strlen('0x00001234')&lt;/code&gt; is equal to 10.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-07-25T13:54:22.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20733" PostTypeId="5" CreationDate="2019-07-25T15:05:24.907" Score="0" Body="&lt;h1&gt;Brief intro&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Vimscript has variables (&lt;code&gt;:h variables&lt;/code&gt;) and scopes (&lt;code&gt;:h internal-variables&lt;/code&gt;) for use when programming vim. Most of their usage is via statements like &lt;code&gt;let&lt;/code&gt; or &lt;code&gt;execute&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help eval&lt;/code&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Use this tag if...&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you have questions about using variables&lt;/li&gt;&#xA;&lt;li&gt;you have questions about scope rules&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Do not use this tag if...&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you have questions about programming languages other than vimscript (if you have questions about using a programming interface, like python, use e.g. &lt;a href=&quot;/questions/tagged/vimscript-python&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;vimscript-python&amp;#39;&quot; rel=&quot;tag&quot;&gt;vimscript-python&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;you have questions about other definitions of the world &lt;em&gt;variable&lt;/em&gt; (such as &lt;em&gt;susceptible to variation&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-25T15:05:24.907" LastActivityDate="2019-07-25T15:05:24.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20734" PostTypeId="4" CreationDate="2019-07-25T15:05:24.907" Score="0" Body="For questions about vimscript variables, their scopes, and usages." OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-07-25T15:05:24.907" LastActivityDate="2019-07-25T15:05:24.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20735" PostTypeId="2" ParentId="20722" CreationDate="2019-07-25T18:43:28.997" Score="1" Body="&lt;p&gt;Since I ran this linter as an external command and it gave me the same delay to go through the file, I assume it is just really slow. So that's a shame...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S If you got any solutions on how to fight this delay in large files please feel free to comment below. Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I now use ccls linter, it is fast (at the cost of big cache for every project, but it is worth it imo)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit2: To make clang-tidy faster disable clang-analyzer-* checks, to do this in ALE put this line into your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_c_clangtidy_checks = ['-*', 'cppcoreguidelines-*']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can change cppcoreguidelines with any other checks available in clang-tidy&lt;/p&gt;&#xA;" OwnerUserId="22880" LastEditorUserId="51" LastEditDate="2019-07-28T00:17:19.303" LastActivityDate="2019-07-28T00:17:19.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20736" PostTypeId="2" ParentId="12422" CreationDate="2019-07-25T19:48:20.310" Score="1" Body="&lt;p&gt;Had the same issue. Was incorrectly putting the custom delimiter option in my ~/.gvimrc. Worked when I put the custom delimiter setting in ~/.vimrc instead.&lt;/p&gt;&#xA;" OwnerUserId="23165" LastActivityDate="2019-07-25T19:48:20.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20737" PostTypeId="1" CreationDate="2019-07-25T21:28:23.240" Score="1" ViewCount="190" Body="&lt;p&gt;Since Vim 8, I've noticed that the bell can sound at most once per half a second. This annoys me. I have this solved by recompiling, but am still looking for a way to do it without.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've searched the documentation and found, in a semi-related option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *'visualbell'* *'vb'* *'novisualbell'* *'novb'* *beep*&#xA;'visualbell' 'vb'        boolean        (default off)&#xA;                        global&#xA;                        {not in Vi}&#xA;        Use a visual bell instead of beeping.  The terminal code to display the&#xA;        visual bell is given with 't_vb'.  When no beep or flash is wanted,&#xA;        use: &amp;gt;&#xA;                :set vb t_vb=&#xA;&amp;lt;        If you want a short flash, you can use this on many terminals: &amp;gt;&#xA;                :set vb t_vb=[?5h$&amp;lt;100&amp;gt;[?5l&#xA;&amp;lt;        Here $&amp;lt;100&amp;gt; specifies the time, you can use a smaller or bigger value&#xA;        to get a shorter or longer flash.&#xA;&#xA;        Note: Vim will limit the bell to once per half a second.  This avoids&#xA;        having to wait for the flashing to finish when there are lots of&#xA;        bells, e.g. on key repeat.  This also happens without 'visualbell'&#xA;        set.&#xA;&#xA;        In the GUI, 't_vb' defaults to &quot;&amp;lt;Esc&amp;gt;|f&quot;, which inverts the display&#xA;        for 20 msec.  If you want to use a different time, use &quot;&amp;lt;Esc&amp;gt;|40f&quot;,&#xA;        where 40 is the time in msec.&#xA;&#xA;        Note: When the GUI starts, 't_vb' is reset to its default value.  You&#xA;        might want to set it again in your |gvimrc|.&#xA;&#xA;        Does not work on the Amiga, you always get a screen flash.&#xA;        Also see 'errorbells'.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The paragraph in the middle is the problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        Note: Vim will limit the bell to once per half a second.  This avoids&#xA;        having to wait for the flashing to finish when there are lots of&#xA;        bells, e.g. on key repeat.  This also happens without 'visualbell'&#xA;        set.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand that in the case of visual bell, this would be inconvenient, but I use audible bell and sending one &lt;code&gt;\a&lt;/code&gt; over SSH, even on EDGE (2G mobile internet) is really not an issue. So, I want to disable this &quot;feature&quot;. It doesn't give any option of disabling it though. Reading the release notes of Vim 8, I found:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Patch 8.0.0683&#xA;Problem:    When using a visual bell there is no delay, causing the flash to&#xA;            be very short, possibly unnoticeable.  Also, the flash and the&#xA;            beep can lockup the UI when repeated often.&#xA;Solution:   Do the delay in Vim or flush the output before the delay. Limit the&#xA;            bell to once per half a second. (Ozaki Kiichi, closes #1789)&#xA;Files:      src/misc1.c, src/proto/term.pro, src/term.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to change (in vimrc, probably) this without recompiling? I have this solved by recompiling, but am still looking for a way to do it without.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the people who are willing to recompile:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;get the Vim source&lt;/li&gt;&#xA;&lt;li&gt;search misc1.c for &quot;500&quot;&lt;/li&gt;&#xA;&lt;li&gt;go back in the file until you see &lt;code&gt;#ifdef ELAPSED_FUNC&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;change the &lt;code&gt;ELAPSED_FUNC&lt;/code&gt; to something else so it doesn't exist and the code is skipped&lt;/li&gt;&#xA;&lt;li&gt;search for the next &lt;code&gt;ELAPSED_FUNC&lt;/code&gt; and repeat&lt;/li&gt;&#xA;&lt;li&gt;./configure &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make install&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Again—I am searching for a way without recompiling.&lt;/p&gt;&#xA;" OwnerUserId="23166" LastEditorUserId="23166" LastEditDate="2019-07-29T07:10:18.787" LastActivityDate="2019-07-29T07:10:18.787" Title="Vim bell limited to once per half a second" Tags="|user-input|default-settings|vim8|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20738" PostTypeId="2" ParentId="20719" CreationDate="2019-07-26T05:12:24.907" Score="2" Body="&lt;p&gt;Normally, &lt;code&gt;:help&lt;/code&gt; is your friend!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, in the case of grammarous, &lt;a href=&quot;https://github.com/rhysd/vim-grammarous/blob/master/doc/grammarous.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help grammarous&lt;/code&gt;&lt;/a&gt; is rather short and incomplete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it still gives you pointers to where you can find more about the command it exposes:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Please do &lt;code&gt;:GrammarousCheck --help&lt;/code&gt; to show more detail about the command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And about the mappings available in an information window:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In information window, some local mappings are available.  Please enter &lt;code&gt;?&lt;/code&gt; in the window to show the help.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you can probably start with these two... In the information window, you simply press the &lt;code&gt;?&lt;/code&gt; key to get help (no &lt;code&gt;:&lt;/code&gt; or &quot;enter&quot;, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/rhysd/vim-grammarous/blob/master/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;README&lt;/a&gt; file in the Git repo also has some useful information, including a &lt;a href=&quot;https://github.com/rhysd/vim-grammarous/blob/master/README.md#local-mappings-in-the-information-window&quot; rel=&quot;nofollow noreferrer&quot;&gt;table of keybindings for the information window&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;q&lt;/code&gt; - Quit the info window&lt;br&gt;&#xA;  &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; - Move to the location of the error&lt;br&gt;&#xA;  &lt;code&gt;f&lt;/code&gt; - Fix the error &lt;strong&gt;automatically&lt;/strong&gt;&lt;br&gt;&#xA;  &lt;code&gt;r&lt;/code&gt; - Remove the error without fix&lt;br&gt;&#xA;  &lt;code&gt;R&lt;/code&gt; - Disable the grammar rule in the checked buffer&lt;br&gt;&#xA;  &lt;code&gt;n&lt;/code&gt; - Move to the next error's location&lt;br&gt;&#xA;  &lt;code&gt;p&lt;/code&gt; - Move to the previous error's location&lt;br&gt;&#xA;  &lt;code&gt;?&lt;/code&gt; - Show help of the mapping in info window&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So hopefully those should get you started?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; means pressing the &quot;enter&quot; or &quot;return&quot; key on your keyboard (&quot;CR&quot; stands for &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Carriage_return&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;carriage return&quot;&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, though. Start exploring plug-ins through the Vim help system. The help system is very good and makes it easy for plug-ins to ship their documentation that way. So most well written plug-ins do. Unfortunately, there isn't that much consistency within the Vim plug-in ecosystem, and many plug-ins will use their own means for documentation.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You mentioned you're new to Vim, so perhaps it would be helpful to familiarize yourself with the Vim base concepts, in particular the underlying features used by the plug-ins you're interested in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You mentioned scratch windows (which these plug-ins make heavy use of), so maybe start with &lt;a href=&quot;https://vimhelp.org/windows.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help windows&lt;/code&gt;&lt;/a&gt;? You can read that help page as a whole if you want. In particular, you might want to take a close look at all the &lt;code&gt;CTRL-W&lt;/code&gt; commands to switch to different windows and control them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also benefit from using windows in your workflows without the plug-ins, so that you get a good hang for what they do and how they work. From there, it might be easier to understand what the plug-ins are doing and how you can use your Vim windows knowledge to navigate and control the windows created and used by the plug-in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plug-ins which make use of Vim windows will typically leverage the Vim settings and bindings, so that you can navigate and manage them with the commands you already know. But, then, not all plug-ins do, and some try to make windows look and behave differently and use their own keystrokes. Unfortunately, there's not much consistency among Vim plug-ins, so YMMV.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and while I focused on windows here (since this is the concept you singled out as used by vim-grammarous), the advice is valid for other Vim features used by plug-ins as well. Try to figure out which Vim underlying feature is used by a plug-in implemetation and learn about that feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the Vim help system. Start at the &lt;a href=&quot;https://vimhelp.org/usr_toc.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;table of contents&lt;/a&gt; if you're not sure what you're looking for. Feel free to post further questions at the Vi and Vim Stack Exchange if you have specific questions.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-26T05:12:24.907" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20739" PostTypeId="1" AcceptedAnswerId="20743" CreationDate="2019-07-26T11:19:57.837" Score="2" ViewCount="1206" Body="&lt;p&gt;I have &lt;code&gt;au BufRead,BufNewFile *.vm  set ft=velocity&lt;/code&gt; in &lt;code&gt;vimrc&lt;/code&gt;.&lt;br&gt;&#xA;But if open .vm file and run &lt;code&gt;:set filetype?&lt;/code&gt;, still get &lt;code&gt;filetype=conf&lt;/code&gt;.&lt;br&gt;&#xA;How to fix this?&lt;/p&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="21062" LastEditDate="2019-08-06T13:17:25.433" LastActivityDate="2019-08-06T13:17:25.433" Title="Why set ft is not working?" Tags="|vimrc|filetype|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20741" PostTypeId="1" CreationDate="2019-07-26T13:50:09.417" Score="1" ViewCount="38" Body="&lt;p&gt;From &lt;code&gt;:h new-filetype&lt;/code&gt; : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A. If you want to overrule all default file type checks.&#xA;   This works by writing one file for each filetype.  The disadvantage is that&#xA;   means there can be many files.  The advantage is that you can simply drop&#xA;   this file in the right directory to make it work.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm having trouble understanding this paragraph for a long time, what does &lt;code&gt;one file for each filetype&lt;/code&gt; mean here ?  Do i need to create a file in ftdetect for every filetype that I want to overrule ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK, if i write &lt;code&gt;.vim/ftdetect/mine.vim&lt;/code&gt; like this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead,BufNewFile *.vim set filetype=vim_test&#xA;autocmd BufRead,BufNewFile *.h set filetype=h_test&#xA;autocmd BufRead,BufNewFile *.cpp set filetype=cpp_test&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It affects all &lt;code&gt;*.vim&lt;/code&gt;, &lt;code&gt;*.h&lt;/code&gt;, &lt;code&gt;*.cpp&lt;/code&gt;, it seems to me that one &lt;code&gt;mine.vim&lt;/code&gt; in ftdetect is sufficient for all filetypes that i want to overrule. What am i missing?&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-07-26T14:59:38.810" Title="What does &quot;one file for each filtype&quot; mean in :h new-filetype" Tags="|filetype|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20742" PostTypeId="2" ParentId="594" CreationDate="2019-07-26T14:02:29.553" Score="1" Body="&lt;p&gt;if you're on a unix environment you could just run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%!column -t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if you're on windows, and you have git installed, that means you could use one of the fancy unix tools installed :) Tools like grep, tee, which, and &lt;em&gt;column&lt;/em&gt; can be found here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%localappdata%\Programs\Git\usr\bin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running the column command from inside Vim then looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!C:\Users\USERNAME\AppData\Local\Programs\Git\usr\bin\column.exe -t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23175" LastEditorUserId="1841" LastEditDate="2019-07-26T14:06:46.930" LastActivityDate="2019-07-26T14:06:46.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20743" PostTypeId="2" ParentId="20739" CreationDate="2019-07-26T14:03:59.220" Score="3" Body="&lt;p&gt;First as a general advice, &lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3Averbose&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :verbose&lt;/code&gt;&lt;/a&gt; is a good way to debug stuff with Vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *:verb* *:verbose*&#xA;:[count]verb[ose] {command}&#xA;            Execute {command} with 'verbose' set to [count].  If&#xA;            [count] is omitted one is used. &quot;:0verbose&quot; can be&#xA;            used to set 'verbose' to zero.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So using &lt;code&gt;:verbose set ft?&lt;/code&gt; in the buffer with the wrong filetype allows you to see what was the last piece of configuration which set the filetype of your buffer. For example I get this result for a typescript source file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype=typescript&#xA;        Last set from ~/.dotfiles/vim/plugged/yats.vim/ftdetect/typescript.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Secondly the best practice to write your own filetype is to use the &lt;code&gt;ftdetect&lt;/code&gt; directory (&lt;a href=&quot;http://vimhelp.appspot.com/filetype.txt.html#ftdetect&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ftdetect&lt;/code&gt;&lt;/a&gt;). The idea is to create a directory &lt;code&gt;ftdetect&lt;/code&gt; in your &lt;code&gt;runtimepath&lt;/code&gt;. In it you should create a file name &lt;code&gt;mynewfiletype.vim&lt;/code&gt; (here it would be &lt;code&gt;velocity.vim&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this file you can create an autocommand like the one you put in your vimrc. Note that you should always put the autocommands in your vimrc in an augroup to avoid side effects &lt;em&gt;but&lt;/em&gt; the autocommands used in the &lt;code&gt;ftdetect&lt;/code&gt; files should not be in an augroup because Vim already does that for you.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-07-26T14:03:59.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20744" PostTypeId="2" ParentId="20741" CreationDate="2019-07-26T14:59:38.810" Score="2" Body="&lt;p&gt;What you are missing is the (highly subjective) organization. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally each of the lines would be in separate files, which makes debugging easier and helps you to group things together. In other words, do you immediately know what filetypes you overrule by looking at the name &lt;code&gt;ftdetect/mine.vim&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What about &lt;code&gt;ftdetect/vim_test.vim&lt;/code&gt; and &lt;code&gt;ftdetect/h_test.vim&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you have noted, however, it isn’t strictly necessary. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-26T14:59:38.810" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20745" PostTypeId="1" AcceptedAnswerId="20746" CreationDate="2019-07-26T17:41:48.173" Score="2" ViewCount="96" Body="&lt;p&gt;That character is used so much in Persian writing. And it makes the text difficult to read. I tried to make my terminal display it correctly but I couldn't I was wondering maybe I could use vim syntax concealing to get rid of it. Can I? How?&lt;/p&gt;&#xA;" OwnerUserId="14609" LastEditorUserId="14609" LastEditDate="2019-07-26T17:43:35.730" LastActivityDate="2019-07-26T17:59:36.320" Title="How to conceal zerowidth special characters like &lt;U200C&gt;" Tags="|unicode|conceal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20746" PostTypeId="2" ParentId="20745" CreationDate="2019-07-26T17:43:07.407" Score="3" Body="&lt;pre&gt;&lt;code&gt;:syntax match ZeroWidthNonJoiner &quot;[\u200c]&quot; conceal cchar=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to check &lt;code&gt;:h conceallevel&lt;/code&gt;, I set it to &lt;code&gt;2&lt;/code&gt; personally. Otherwise, you may not get conceal to work as you expect.&lt;/p&gt;&#xA;" OwnerUserId="6324" LastEditorUserId="6324" LastEditDate="2019-07-26T17:59:36.320" LastActivityDate="2019-07-26T17:59:36.320" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20747" PostTypeId="1" AcceptedAnswerId="20750" CreationDate="2019-07-26T18:14:19.130" Score="2" ViewCount="269" Body="&lt;p&gt;I've written a C code syntax rule to highlight function names in function definitions as such:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kYcU1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kYcU1.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is the syntax rule written in ~/.vim/syntax/c.vim:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;syntax match cCustomFunc /\w\+\s\+\zs\w\+(/he=e-1&#xA;highlight default link cCustomFunc Function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, when the type in the function definition is a C keyword, the syntax highlighting fails. For example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RZbfZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RZbfZ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Any keyword type such as char, int, void, etc. causes it to fail.&lt;/p&gt;&#xA;&lt;p&gt;I've tried putting &amp;quot;contains=Type&amp;quot; at the end of the syntax match rule, but it did not work.&lt;/p&gt;&#xA;&lt;p&gt;How can I make my syntax highlighting rule work when the type in the function definition is a keyword?&lt;/p&gt;&#xA;" OwnerUserId="23182" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-07-27T06:13:26.077" Title="Vim syntax match changes based on function type name keyword" Tags="|syntax-highlighting|filetype-c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20748" PostTypeId="2" ParentId="20473" CreationDate="2019-07-26T21:21:40.667" Score="1" Body="&lt;p&gt;My suggestion is convert to HTML and print from the browser with &lt;code&gt;:TOhtml&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="23185" LastActivityDate="2019-07-26T21:21:40.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20749" PostTypeId="2" ParentId="20737" CreationDate="2019-07-26T23:32:57.433" Score="1" Body="&lt;p&gt;I looked at the source and I don't see any user-facing way to disable the bell limit. You'd have to build your own version as you mentioned. Think twice about that, though...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than being a killjoy &quot;feature&quot; this apparently was implemented for the sake of Vim stability. I saw a couple comments indicating that rapid bell sequences can hang Vim. Here's one of them..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /* Only beep once per half a second, otherwise a sequence of beeps&#xA;     * would freeze Vim. */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Guess you have to live with it. :)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-07-26T23:32:57.433" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20750" PostTypeId="2" ParentId="20747" CreationDate="2019-07-27T06:13:26.077" Score="0" Body="&lt;p&gt;The problem is that the keyword is preventing your regex from matching, since the regex you're using needs to match the whole line, even though you're using &lt;code&gt;\zs&lt;/code&gt; to start the capture only at the function name, after the keyword...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can solve that by using a look-behind regex with &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%40%3C%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\@&amp;lt;=&lt;/code&gt;&lt;/a&gt;, rather than &lt;code&gt;\zs&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to work ok:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match cCustomFunc /\(\w\+\s\+\)\@&amp;lt;=\w\+(/he=e-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-27T06:13:26.077" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20751" PostTypeId="1" CreationDate="2019-07-27T19:22:00.607" Score="1" ViewCount="922" Body="&lt;p&gt;How do I keep the terminal buffer from showing up in my airline list of buffers?&#xA;I assume airline just pulls buffers from what normally shows up in :ls. But I actually don't want the terminal to show up in that list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see in this image there's an airline s &quot;tab&quot; to the right of the settings.json &quot;tab&quot; (airline has a setting to show buffers as tabs). This s tab is the terminal buffer that I had opened earlier with neoterm mapping for :botright Ttoggle. However, I really do not want this to show up in my list of buffers that I can tab through.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/U9dT0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/U9dT0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23094" LastEditorUserId="23094" LastEditDate="2019-07-27T20:44:44.237" LastActivityDate="2020-12-19T17:03:50.343" Title="Hide terminal buffer from buffer list" Tags="|terminal|hidden-buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20752" PostTypeId="2" ParentId="20751" CreationDate="2019-07-27T20:49:46.487" Score="1" Body="&lt;p&gt;This seems to get me what I want. I think neoterm relies on the terminal buffer being in the buffer list. I just made my buffer tab cycle key mapping check to see if the new buffer that was cycled to was the terminal buffer, if so do another bnext/bprev. Also needed an autocmd for getting into and out of insert mode depending on buftype. Airline has a var you can set for not displaying the terminal buffer to the buffer 'tabs'&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let g:airline#extensions#tabline#ignore_bufadd_pat = 'gundo|undotree|vimfiler|tagbar|nerd_tree|startify|!|term'&#xA;&#xA;    au BufEnter * if &amp;amp;buftype == 'terminal' | startinsert | else | stopinsert | endif&#xA;    function! PrevBufferTab()&#xA;      bprev&#xA;      if &amp;amp;buftype == 'terminal'&#xA;        bprev&#xA;      endif&#xA;    endfunction&#xA;    function! NextBufferTab()&#xA;      bnext&#xA;      if &amp;amp;buftype == 'terminal'&#xA;        bnext&#xA;      endif&#xA;    endfunction&#xA;    &quot; Cycle buffer tabs in airline's tab bar&#xA;    nnoremap &amp;lt;c-a&amp;gt; :call PrevBufferTab()&amp;lt;cr&amp;gt;&#xA;    nnoremap &amp;lt;c-x&amp;gt; :call NextBufferTab()&amp;lt;cr&amp;gt;&#xA;    &quot; kill buffer tab&#xA;    nnoremap &amp;lt;c-q&amp;gt; :bp &amp;lt;bar&amp;gt; bd #&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23094" LastEditorUserId="23094" LastEditDate="2019-07-28T15:01:17.967" LastActivityDate="2019-07-28T15:01:17.967" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20753" PostTypeId="1" AcceptedAnswerId="20757" CreationDate="2019-07-27T20:53:11.660" Score="3" ViewCount="2821" Body="&lt;p&gt;In putting together and addon for blender to integrate &lt;code&gt;neovim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/B0uM7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/B0uM7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;em&gt;Where I'm at with it, github colo imported to blender text editor from nvim_gtk&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One component is grabbing the current colorscheme of a running vim and importing it into blender's text editor theme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I have some &lt;code&gt;re&lt;/code&gt; code that looks at the return of &lt;code&gt;hi&lt;/code&gt; and follows links if need be  till I get a guifg or guibg &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# vim is a pynvim.api.nvim.Nvim object&#xA;vim_color = vim.command_output(f&quot;highlight {g}&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which for &lt;code&gt;g = &quot;pythonBuiltin&quot;&lt;/code&gt; returns &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pythonBuiltin xxx links to GruvboxOrange&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GruvboxOrange xxx ctermfg=208 guifg=#fe8019&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in which case I can get the RGB colour for blender from the hex.  Other colour codes not so easy.  And the code is getting unwieldly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you point me to a more direct way, possibly a plugin,  to get the RGB value of a highlight? &lt;/p&gt;&#xA;" OwnerUserId="4545" LastEditorUserId="4472" LastEditDate="2019-08-12T08:32:03.380" LastActivityDate="2019-08-12T08:32:03.380" Title="Getting an RGB color from highlight group" Tags="|neovim|colorscheme|color|neovim-python-client|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20754" PostTypeId="1" AcceptedAnswerId="20839" CreationDate="2019-07-27T23:30:27.410" Score="1" ViewCount="134" Body="&lt;p&gt;I'm writing a function to execute an external command using visual selection.&#xA;I've noticed that if by mistake the entire line is selected, including the new line char the extra &lt;code&gt;^@&lt;/code&gt; character makes the shell command to fail:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;20_BitwiseOperator:&#xA;line   18:&#xA;E485: Can't read file /tmp/v5rPHeq/9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know I can just trim the last character if it matches &lt;code&gt;^@&lt;/code&gt;, but I'm wondering if I am missing something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;BitwiseOperation&lt;/code&gt; function looks this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:BitwiseOperator(type)&#xA;  let saved_unnamed_register = @@&#xA;  if a:type ==# 'v'&#xA;        normal! `&amp;lt;v`&amp;gt;y&#xA;    elseif a:type ==# 'char'&#xA;        normal! `[v`]y&#xA;    else&#xA;        return&#xA;    endif&#xA;&#xA;  botright new&#xA;  setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap&#xA;  silent execute '$read !'. &quot;bitwise --no-color &quot;. shellescape(@@)&#xA;  setlocal nomodifiable&#xA;  let @@ = saved_unnamed_register&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="496" LastEditorUserId="1841" LastEditDate="2019-08-06T15:23:28.590" LastActivityDate="2019-08-07T14:43:50.870" Title="remove extra (^@) from visual selection" Tags="|vimscript|visual-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20755" PostTypeId="2" ParentId="20753" CreationDate="2019-07-28T01:45:22.967" Score="1" Body="&lt;p&gt;I don't know about any plugins for this but it should be easy to code up lookup tables for the other codes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The decimal numbers, like 208 in your example, are 256-color palette codes. It's easy to find translations to/from hex code. Like the top of the google search for &lt;a href=&quot;https://jonasjacek.github.io/colors&quot; rel=&quot;nofollow noreferrer&quot;&gt;256 color to hex&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The spelled-out colors (e.g. DarkSeaGreen4) are system dependent. You didn't mention what system you're using, I don't think. But for *nix that same translation page includes spelled colors, too.. For windows start with &lt;code&gt;:h win32-colors&lt;/code&gt; and go from there.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-07-28T01:50:38.450" LastActivityDate="2019-07-28T01:50:38.450" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20756" PostTypeId="1" CreationDate="2019-07-28T02:00:12.090" Score="1" ViewCount="239" Body="&lt;p&gt;I have a macro that's essentially equivalent to the following: in insert mode, I press the following keys: &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;O&lt;/kbd&gt;, &lt;kbd&gt;:&lt;/kbd&gt;, &lt;kbd&gt;!&lt;/kbd&gt;, &lt;kbd&gt;t&lt;/kbd&gt;, &lt;kbd&gt;r&lt;/kbd&gt;, &lt;kbd&gt;u&lt;/kbd&gt;, &lt;kbd&gt;e&lt;/kbd&gt;, &lt;kbd&gt;Enter&lt;/kbd&gt;. This runs the command &lt;code&gt;true&lt;/code&gt; in a shell and shows &quot;Press ENTER or type command to continue&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;kbd&gt;q&lt;/kbd&gt;, it continues past that point as well as inserting a spurious 'q' into the document I was editing. I don't want Vim to assume that it's OK to insert what I'm typing into a document when Vim isn't currently showing me the document. How do I stop this behavior?&lt;/p&gt;&#xA;" OwnerUserId="18802" LastActivityDate="2019-08-07T05:36:17.820" Title="How can I stop Vim from inserting keypresses into the document unless the document is visible?" Tags="|insert-mode|shell|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20757" PostTypeId="2" ParentId="20753" CreationDate="2019-07-28T02:35:44.080" Score="4" Body="&lt;p&gt;Consider using the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#synIDattr%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;synIDattr()&lt;/code&gt;&lt;/a&gt; function, which can take special attributes such as &lt;code&gt;fg#&lt;/code&gt; and &lt;code&gt;bg#&lt;/code&gt; to return RGB for attributes, when a GUI is running.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;fg#&quot;   like &quot;fg&quot;, but for the GUI and the GUI&#xA;        is running the name in &quot;#RRGGBB&quot; form&#xA;&quot;bg#&quot;   like &quot;fg#&quot; for &quot;bg&quot;&#xA;&quot;sp#&quot;   like &quot;fg#&quot; for &quot;sp&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first argument to this function is a numeric &lt;code&gt;{synID}&lt;/code&gt;, if you have a file styled with syntax elements you can look up the id from a specific position in the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to find all syntax groups, then perhaps you could iterate them starting from 1 and looking up the name with &lt;code&gt;synIDattr(..., 'name')&lt;/code&gt; to build a full map from name to RGB attributes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, to get the RGB for the foreground color of &lt;code&gt;pythonComment&lt;/code&gt;, you can use the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo synIDattr(synIDtrans(hlID(&quot;pythonComment&quot;)), &quot;fg#&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-07-28T11:33:37.620" LastActivityDate="2019-07-28T11:33:37.620" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20758" PostTypeId="2" ParentId="20754" CreationDate="2019-07-28T13:07:05.670" Score="2" Body="&lt;p&gt;The &lt;code&gt;^@&lt;/code&gt; you're referring to is actually a newline character, so the problem you describe will happen when your visual selection includes the newline (e.g. &lt;code&gt;v$&lt;/code&gt; to select until the end of the line) or when it spawns multiple lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming your external tool you're shelling out to is able to handle multiline strings appropriately, Vim's &lt;a href=&quot;https://vimhelp.org/eval.txt.html#shellescape%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;shellescape()&lt;/code&gt;&lt;/a&gt; will be able to handle it in a way that the shell will interpret it correctly, by turning it into a single quoted string that can embed newlines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;multiline\n&lt;/code&gt; becomes &lt;code&gt;'multiline\n'&lt;/code&gt; through &lt;code&gt;shellescape()&lt;/code&gt; (where the &lt;code&gt;\n&lt;/code&gt; here represents an actual newline character), and the shell is fine with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem you're having is that &lt;code&gt;:execute&lt;/code&gt; is now seeing two separate commands, in this case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$read !bitwise --no-color 'multiline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, more geneally, for &lt;code&gt;first line\nsecond line&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$read !bitwise --no-color 'first line&#xA;second line'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are two possible solutions to this problem. The first is to pass a non-zero second argument to &lt;a href=&quot;https://vimhelp.org/eval.txt.html#shellescape%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;shellescape()&lt;/code&gt;&lt;/a&gt;, which will make it do some extra magic to handle cases like this one with the newline. From &lt;a href=&quot;https://vimhelp.org/eval.txt.html#shellescape%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help shellescape()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;With a non-zero-arg &lt;code&gt;{special}&lt;/code&gt; the &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; character is also escaped. [...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Example of use with a &lt;code&gt;:!&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe '!dir ' . shellescape(expand('&amp;lt;cfile&amp;gt;'), 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The example itself is using &lt;code&gt;: execute&lt;/code&gt;, so it's actually a good illustration of your issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So one possible solution is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent execute '$read !'. &quot;bitwise --no-color &quot;. shellescape(@@, 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another, actually better solution, is to use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#system%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;system()&lt;/code&gt;&lt;/a&gt; function to shell out instead, in which case you don't need to worry about escaping the string from &lt;code&gt;:execute&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to put the contents of the &lt;code&gt;system()&lt;/code&gt; result into the new buffer, you can use the &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Aput&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:put&lt;/code&gt;&lt;/a&gt; command together with the &lt;a href=&quot;https://vimhelp.org/change.txt.html#%40%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;@=&lt;/code&gt; expression register&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent put =system('bitwise --no-color '.shellescape(@@))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#setline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;setline()&lt;/code&gt;&lt;/a&gt; instead of &lt;code&gt;:put&lt;/code&gt;, which makes it even easier to get rid of the empty line at the start of the buffer. With &lt;code&gt;setline()&lt;/code&gt;, use &lt;code&gt;systemlist()&lt;/code&gt;, to get the shell output as a list of lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setline(1, systemlist('bitwise --no-color '.shellescape(@@)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-28T13:07:05.670" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20759" PostTypeId="2" ParentId="18611" CreationDate="2019-07-28T19:44:24.563" Score="4" Body="&lt;p&gt;The following workflow commands can help me structure Vim windows like your desire. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.Split below window&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set splitbelow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2.Execute NERDTree             &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * NERDTree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;3.Change cursor to editor console&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * wincmd p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;4.Open terminal&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;5.Switch to terminal window&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * wincmd k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;6.Increase size of main editor console&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * 10 wincmd +&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8453" LastActivityDate="2019-07-28T19:44:24.563" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20760" PostTypeId="1" CreationDate="2019-07-28T22:19:51.767" Score="4" ViewCount="1881" Body="&lt;p&gt;How do you create a binding that behaves like yy but doesn't yank the leading white spaces?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;f ^v$y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yanks one line and the ^J. Which is what I want but how do I add a [count] to do mulitple lines? &lt;/p&gt;&#xA;" OwnerUserId="22837" LastActivityDate="2019-07-29T02:02:41.890" Title="How to add a [count] to a binding" Tags="|key-bindings|count|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20761" PostTypeId="2" ParentId="20223" CreationDate="2019-07-28T23:29:22.573" Score="4" Body="&lt;p&gt;No one has replied at all to this? Hmm. Well, I think I have an answer (&quot;works for me&quot;) Note: &lt;code&gt;++cols&lt;/code&gt; won't do anything if the terminal window already takes up the full width of the surrounding Vim window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Refer to the help section on &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#terminal-resizing&quot; rel=&quot;nofollow noreferrer&quot;&gt;terminal resizing&lt;/a&gt;. It discusses how to use the &lt;a href=&quot;https://vimhelp.org/options.txt.html#&amp;#39;termwinsize&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'termwinsize'&lt;/code&gt;&lt;/a&gt; option to control terminal window dimensions. For your needs try a value that uses the &lt;em&gt;rows*columns&lt;/em&gt; format. For example, if you do &lt;code&gt;:set termwinsize=20*200&lt;/code&gt; a subsequent &lt;code&gt;:terminal cmd&lt;/code&gt; for a command that outputs text will not force line breaks into any lines that fit into 200 columns or less.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you reset with &lt;code&gt;:set termwinsize&amp;amp;&lt;/code&gt; and try again then the width will go back to being constrained by Vim window width.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's it.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-07-30T05:09:53.007" LastActivityDate="2019-07-30T05:09:53.007" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20762" PostTypeId="2" ParentId="20760" CreationDate="2019-07-29T01:29:20.223" Score="4" Body="&lt;p&gt;Your mapping is tricky because you don't want to yank the leading whitespaces. You cannot simply &lt;a href=&quot;https://vim.fandom.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_2)#Supplying_a_count_to_a_map&quot; rel=&quot;nofollow noreferrer&quot;&gt;supply a count to your map&lt;/a&gt; as you would do &lt;a href=&quot;https://vi.stackexchange.com/questions/2543/how-can-i-map-dcountd&quot;&gt;for an operator&lt;/a&gt;. You need to define a new &lt;code&gt;command&lt;/code&gt; with the &lt;code&gt;-count&lt;/code&gt; attribute, or a new function and bind it using &lt;code&gt;v:count&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came up with this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -count=1 YY let @&quot;=join(map(getline(line('.'), line('.')+&amp;lt;count&amp;gt;-1), 'substitute(v:val, &quot;^\\s*&quot;, &quot;&quot;, &quot;&quot;)'),&quot;\&amp;lt;nl&amp;gt;&quot;).&quot;\&amp;lt;nl&amp;gt;&quot;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;f :&amp;lt;c-u&amp;gt;execute v:count1 . 'YY'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which get the list of the current line and the &lt;code&gt;&amp;lt;count&amp;gt;-1&lt;/code&gt; ones below (default is 1); removes their leading whitespaces; and join them in a single string with &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; (&lt;code&gt;^J&lt;/code&gt;) between and after; finally setting the result to the unnamed register &lt;code&gt;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a more &quot;intuitive&quot; solution without using Vimscript functions, you could do the following. It is more incremental, like if you were in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! YY(count)&#xA;    let l:s=@s                  &quot; save register 's'&#xA;    let @s=''                   &quot; empty register 's'&#xA;    let l:curpos = getcurpos()  &quot; save cursor position&#xA;    for l:i in range(a:count)   &quot; do your mapping but *append* to register 's'&#xA;        normal! ^v$&quot;Syj&#xA;    endfor                      &quot; and move down one line. repeat&#xA;    call setpos('.', l:curpos)  &quot; restore cursor position&#xA;    let @&quot;=@s                   &quot; set unnamed register to register 's'&#xA;    let @s=l:s                  &quot; restore register 's'&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;f :&amp;lt;c-u&amp;gt;call YY(v:count1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe someone has a better solution, this is all I got...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usefull helps.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h command-count&lt;/code&gt; and more generally &lt;code&gt;:h user-commands&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h v:count&lt;/code&gt; and &lt;code&gt;h v:count1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h function-list&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="22929" LastActivityDate="2019-07-29T01:29:20.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20763" PostTypeId="2" ParentId="20760" CreationDate="2019-07-29T02:02:41.890" Score="3" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#v%3Acount&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;v:count&lt;/code&gt;&lt;/a&gt; variable to access the count passed to a mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't pass any count, the &lt;code&gt;v:count&lt;/code&gt; variable will evaluate to zero. If you prefer something that evaluates to 1 instead, you can use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#v%3Acount1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;v:count1&lt;/code&gt;&lt;/a&gt; which does just that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your particular use case, yanking without leading whitespace, my suggestion is to just yank the contents normally, then process the yank contents using &lt;a href=&quot;https://vimhelp.org/eval.txt.html#substitute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;substitute()&lt;/code&gt;&lt;/a&gt; to strip leading whitespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When writing a mapping that does yanks, puts or deletes, you might also want to consider &lt;a href=&quot;https://vimhelp.org/eval.txt.html#v%3Aregister&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;v:register&lt;/code&gt;&lt;/a&gt;, in case the user specifies a non-default register when calling your mapping. You need to evaluate it early on in the mapping, since it may be overwritten by other commands you run, so best to pass it as an argument. You can then use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#setreg%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;setreg()&lt;/code&gt;&lt;/a&gt; to set the register's contents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you want to save the yank on the specified register only and not overwrite the default register (this is not how the &lt;code&gt;yy&lt;/code&gt; command works, but is a useful behavior), then this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! YankTrimLeadingSpace(register)&#xA;  let saved_unnamed_register = @@&#xA;  execute 'normal!' v:count1.'yy'&#xA;  let @@ = substitute(@@, '\v(^|\n)\zs\s+', '', 'g')&#xA;  if a:register != '&quot;'&#xA;    call setreg(a:register, @@)&#xA;    let @@ = saved_unnamed_register&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;f :&amp;lt;c-u&amp;gt;call YankTrimLeadingSpace(v:register)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It also works with uppercase register specifications, which will append to the existing registers. Works with and without a count.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-29T02:02:41.890" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20765" PostTypeId="1" CreationDate="2019-07-29T10:21:52.557" Score="4" ViewCount="142" Body="&lt;p&gt;Suppose I have a bunch of folds for more than one line each. How to make shuffle them as folds not lines?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case of lines it can be done by external &lt;code&gt;shuf&lt;/code&gt; or any other command (see &lt;a href=&quot;https://stackoverflow.com/a/17643450/359866&quot;&gt;https://stackoverflow.com/a/17643450/359866&lt;/a&gt; for example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the question is for more general case of multiline folds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. &lt;strong&gt;Example.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfolded:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fold1&#xA;  subfold text1&#xA;fold2&#xA;  subfold text2&#xA;fold3&#xA;  subfold text3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Folded:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fold1...&#xA;fold2...&#xA;fold3...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After shuffle for example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fold2&#xA;  subfold text2&#xA;fold1&#xA;  subfold text1&#xA;fold3&#xA;  subfold text3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5182" LastActivityDate="2019-07-29T13:57:04.223" Title="Shuffle multiline folds" Tags="|folding|multiple-lines|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20766" PostTypeId="2" ParentId="20765" CreationDate="2019-07-29T13:57:04.223" Score="6" Body="&lt;p&gt;There is a &lt;code&gt;:folddoclosed&lt;/code&gt; command which iterates over all closed folds (just like &lt;code&gt;:g&lt;/code&gt; command for the whole buffer) and executes one or more commands on them. So I would close all folds, convert each fold into one long line by replacing the end-of-line with a unique marker, shuffle the lines around, and replace the markers with line-breaks. Something along&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;zM&#xA;:folddoclosed s/\n/&amp;lt;EOL&amp;gt;/&#xA;:DoTheShuffle&#xA;:%s/&amp;lt;EOL&amp;gt;/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on the original text and the shuffling method some cleanup might be necessary afterwards, e.g., removal of superfluous empty lines.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastActivityDate="2019-07-29T13:57:04.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20767" PostTypeId="2" ParentId="104" CreationDate="2019-07-30T09:35:45.383" Score="1" Body="&lt;p&gt;I use &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim airline&lt;/a&gt; for that and some nice features:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UcTPZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UcTPZ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23224" LastActivityDate="2019-07-30T09:35:45.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20768" PostTypeId="2" ParentId="104" CreationDate="2019-07-30T09:57:50.530" Score="1" Body="&lt;p&gt;You can show the complete path of the file you are editing in the title bar, which is a convenient way to show the file path in my opinion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to do that, you need to set the &lt;a href=&quot;https://neovim.io/doc/user/options.html#&amp;#39;title&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;title&lt;/code&gt;&lt;/a&gt; option and &lt;a href=&quot;https://neovim.io/doc/user/options.html#&amp;#39;titlestring&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;titlestring&lt;/code&gt;&lt;/a&gt;. Current I am using the following settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set title&#xA;set titlestring=%{hostname()}\ \ %F\ \ %{strftime('%Y-%m-%d\ %H:%M',getftime(expand('%')))}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will show the hostname of Vim, then the complete path of the file and followed by last modified time of the file. See the figure below for a demo&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3JwaX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3JwaX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-07-30T09:57:50.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20769" PostTypeId="1" AcceptedAnswerId="20770" CreationDate="2019-07-30T10:28:19.137" Score="1" ViewCount="152" Body="&lt;p&gt;I often get really long lines, such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region SomeName start=/some_pattern/ end=/some other pattern/ contained contains=SomeOtherName,YetAnotherName,EvenMoreNames,More,MoreAgain,KeepsGoing,Etc,UntilLineWrapsAroundAndItLooksReallyUgly&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to add &lt;code&gt;\&lt;/code&gt; to break the long lines, as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region SomeName start=/some_pattern/ \&#xA;                       end=/some other pattern/ contained\&#xA;                       contains=SomeOtherName,YetAnotherName,\&#xA;                       EvenMoreNames,More,MoreAgain,\&#xA;                       KeepsGoing,Etc,\&#xA;                       UntilLineWrapsAroundAndItLooksReallyUgly&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thoughts?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(note:  I'm open to neovim-specific solutions)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="14744" LastActivityDate="2019-07-30T11:02:12.683" Title="How to make vim syntax files look nice?" Tags="|syntax-highlighting|formatting|" AnswerCount="1" CommentCount="2" ClosedDate="2019-07-30T13:17:21.417" ContentLicense="CC BY-SA 4.0" />
  <row Id="20770" PostTypeId="2" ParentId="20769" CreationDate="2019-07-30T11:02:12.683" Score="2" Body="&lt;p&gt;Line continuation in Ex commands is done by prepending a backslash to the beginning of the continuation lines themselves, not appending it to the end of the preceding lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#line-continuation&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help line-continuation&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Long lines in a &lt;code&gt;:source&lt;/code&gt;d Ex command script file can be split by inserting a line continuation symbol &lt;code&gt;\&lt;/code&gt; (backslash) at the start of the next line. There can be white space before the backslash, which is ignored.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And there's even an example for a &lt;code&gt;:syntax&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syn match Comment&#xA;    \ &quot;very long regexp&quot;&#xA;    \ keepend&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This may look very odd, so the help page even explains why it needs to be that way:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Rationale:&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Most programs work with a trailing backslash to indicate line continuation.  Using this in Vim would cause incompatibility with Vi.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;For example for this Vi mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  :map xx  asdf\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Therefore the unusual leading backslash is used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Applying that to your particular case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region SomeName&#xA;        \ start=/some_pattern/&#xA;        \ end=/some other pattern/&#xA;        \ contained&#xA;        \ contains=SomeOtherName,YetAnotherName,&#xA;        \EvenMoreNames,More,MoreAgain,&#xA;        \KeepsGoing,Etc,&#xA;        \UntilLineWrapsAroundAndItLooksNotThatBad&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The help page also has detailed explanations on how to handle whitespace, which is applicable to the last lines in your example:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;All leading whitespace characters in the line before a backslash are ignored. Note however that trailing whitespace in the line before it cannot be inserted freely; it depends on the position where a command is split up whether additional whitespace is allowed or not.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In short, you might need to be careful if using it where whitespace is to be prevented, but it's certainly doable even in those cases.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-30T11:02:12.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20771" PostTypeId="2" ParentId="20756" CreationDate="2019-07-30T11:29:27.730" Score="2" Body="&lt;p&gt;There doesn't seem to be a good way around what you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior is clearly documented, in quite some detail, in &lt;a href=&quot;https://vimhelp.org/message.txt.html#press-enter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help press-enter&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Press &lt;code&gt;:&lt;/code&gt; or any other Normal mode command character to start that command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your case, since you hit that from a &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-O&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;CTRL-O&lt;/code&gt;&lt;/a&gt; means the next keypress will actually be &lt;em&gt;inserted&lt;/em&gt; in your text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that not all keys will be recognized this way. For example:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Press &lt;code&gt;k&lt;/code&gt;, &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt;, &lt;code&gt;u&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt; or &lt;code&gt;g&lt;/code&gt; to scroll back in the messages. This works the same way as at the &lt;a href=&quot;https://vimhelp.org/message.txt.html#more-prompt&quot; rel=&quot;nofollow noreferrer&quot;&gt;more-prompt&lt;/a&gt;.  (Only works when &lt;code&gt;'compatible'&lt;/code&gt; is off and &lt;code&gt;'more'&lt;/code&gt; is on.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;These keys won't leave the &quot;Press ENTER&quot; prompt even if your command has no output (as is the case with &lt;code&gt;:!true&lt;/code&gt;.) If your command has long output, then once you scroll up, keys to scroll down will also be active and not leave the prompt to get inserted in your text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There doesn't seem to be a way around it. I can see why you'd want a behavior such as &quot;Press ANY key to continue&quot; but that doesn't seem to be available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could &lt;a href=&quot;https://github.com/vim/vim/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;file a new issue&lt;/a&gt; at the Vim tracker to request a way to tweak this behavior. (If you explain your use case invoking a command from &lt;code&gt;CTRL-O&lt;/code&gt; and having characters inserted into the text while the text is not visible, you might make such a feature request more compelling.) Though even if you successfully get that accepted, it will only be available in a future version of Vim, so not in generally available versions if you want to be compatible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most workarounds on this &quot;Press ENTER&quot; prompt are about &lt;em&gt;hiding&lt;/em&gt; or preventing it (which you can easily do by adding an extra &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to the end of your mapping.) But that doesn't seem to be what you want, since you do want the output of the command to be visible until the user presses Enter (or another key!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider alternative solutions, such as saving the external command's output into a scratch buffer or preview window and displaying it there, you can better control the user experience that way.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-30T11:29:27.730" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20772" PostTypeId="1" AcceptedAnswerId="20775" CreationDate="2019-07-30T13:46:30.323" Score="-1" ViewCount="50" Body="&lt;p&gt;I've tried the Emacs land and when using evil-org &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; are remapped to in/decrease the level of headings, how could I do the same with vim and &lt;a href=&quot;https://github.com/dhruvasagar/vim-dotoo&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-dotoo&lt;/a&gt;?&lt;/p&gt;&#xA;" OwnerUserId="14568" LastEditorUserId="51" LastEditDate="2019-07-30T14:57:33.067" LastActivityDate="2019-07-30T21:54:23.723" Title="How would one remap &gt;&gt; and &lt;&lt; to in/decrease the level of headings in org/dotoo files?" Tags="|key-bindings|plugin-dotoo|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20773" PostTypeId="5" CreationDate="2019-07-30T14:57:50.227" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/dhruvasagar/vim-dotoo&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/dhruvasagar/vim-dotoo&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-07-30T14:57:50.227" LastActivityDate="2019-07-30T14:57:50.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20774" PostTypeId="4" CreationDate="2019-07-30T14:57:50.227" Score="0" Body="Org-mode like task logging &amp; time tracking in Vim" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-07-30T14:57:50.227" LastActivityDate="2019-07-30T14:57:50.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20775" PostTypeId="2" ParentId="20772" CreationDate="2019-07-30T21:54:23.723" Score="1" Body="&lt;p&gt;A comment mentions that headings look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* heading&#xA;** subheading&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I think an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping could do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;gt;&amp;gt; getline('.') =~# '^\s*\*' ? &quot;I*\&amp;lt;Esc&amp;gt;&quot; : '&amp;gt;&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adjust regex/command as necessary. The unindent is left as an exercise. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-07-30T21:54:23.723" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20776" PostTypeId="1" AcceptedAnswerId="20778" CreationDate="2019-07-31T11:02:39.390" Score="1" ViewCount="1377" Body="&lt;p&gt;Yanked text with &lt;kbd&gt;y&lt;/kbd&gt;, then &lt;kbd&gt;v&lt;/kbd&gt; select some text, paste with &lt;kbd&gt;p&lt;/kbd&gt;, but nothing happens.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="21062" LastEditDate="2019-08-06T13:18:28.563" LastActivityDate="2019-08-06T13:18:28.563" Title="How to paste yanked text over visual selection?" Tags="|visual-mode|paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20778" PostTypeId="2" ParentId="20776" CreationDate="2019-07-31T11:42:44.287" Score="1" Body="&lt;p&gt;Pasting over a visual selection should work exactly once. When pasting a second time the visual selection from the first time will be pasted instead of the yanked text. (At least that's what happens in version 8.1.1779, but ISTR that in earlier versions pasting did not work; just like you describe. This might have been changed with 8.0.140, but I can't check this right now.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you yank a text without giving a target register the text will be stored in register &lt;code&gt;&quot;0&lt;/code&gt;. The default register &lt;code&gt;&quot;&quot;&lt;/code&gt; then points to register &lt;code&gt;&quot;0&lt;/code&gt;. Now you select some text. When you paste over the selection it is first deleted and stored in register &lt;code&gt;&quot;1&lt;/code&gt; (or &lt;code&gt;&quot;-&lt;/code&gt; for small deletions). Then the contents of the default register is inserted. At some time during the paste action the default register will be updated to point to register &lt;code&gt;&quot;1&lt;/code&gt; (or &lt;code&gt;&quot;-&lt;/code&gt;) because of the deletion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on when the update of register &lt;code&gt;&quot;&quot;&lt;/code&gt; happens you will either put the contents of register &lt;code&gt;&quot;0&lt;/code&gt; (the yank register) or &lt;code&gt;&quot;1&lt;/code&gt;/&lt;code&gt;&quot;-&lt;/code&gt; (the (small) delete register). You can state explicitly which register to paste by using &lt;code&gt;&quot;0p&lt;/code&gt; or &lt;code&gt;&quot;0P&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastEditorUserId="13728" LastEditDate="2019-08-01T12:35:50.280" LastActivityDate="2019-08-01T12:35:50.280" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20779" PostTypeId="1" CreationDate="2019-07-31T14:30:32.957" Score="1" ViewCount="310" Body="&lt;p&gt;I have a file, &lt;code&gt;/tmp/file.txt&lt;/code&gt; that is being edited by &lt;code&gt;vim&lt;/code&gt; (or &lt;code&gt;neovim&lt;/code&gt;), as well as some other external process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wish the external app to notify &lt;code&gt;vim&lt;/code&gt;, in such a way that &lt;code&gt;vim&lt;/code&gt; takes that notification to reload the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any kind of external hooks?  To let other external apps tell &lt;code&gt;vim&lt;/code&gt; &lt;em&gt;&quot;hey, you may want to do something now&quot;&lt;/em&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I ask this, is because &lt;a href=&quot;https://stackoverflow.com/questions/2490227/how-does-vims-autoread-work/2490635#2490635&quot;&gt;&lt;code&gt;autoread&lt;/code&gt; doesn't always work&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14744" LastActivityDate="2019-07-31T14:30:32.957" Title="How to externally trigger [neo]vim to reload an edited file?" Tags="|vimrc|neovim|autocmd|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20780" PostTypeId="1" CreationDate="2019-07-31T14:34:42.597" Score="1" ViewCount="749" Body="&lt;p&gt;I followed a tutorial toon vim setup and used wget to load someone's .vimrc . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On opening a file with vim, i get the following errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function pymode#breakpoint#init&#xA;line 29:&#xA;Traceback (most recent call last):&#xA;   File &quot;&amp;lt;string&amp;gt;&quot;, line 2, in &amp;lt;module&amp;gt;&#xA;ImportError: No module named six&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is then followed by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/bridge/c/sheth7/.vim/bundle/python-mode/autoload/pymode/lint.vim    &#xA;line    1:&#xA;Traceback (most recent call last):&#xA;Press ENTER or type command to continue&#xA;Error detected while processing /home/bridge/c/sheth7/.vim/bundle/python-mode/autoload/py&#xA;mode/lint.vim:&#xA;line    1:&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;Press ENTER or type command to continue&#xA;Error detected while processing /home/bridge/c/sheth7/.vim/bundle/python-mode/autoload/py&#xA;mode/lint.vim:&#xA;line    1:&#xA;  File &quot;/home/bridge/c/sheth7/.vim/bundle/python-mode/pymode/lint.py&quot;, line 9, in &amp;lt;module&#xA;&amp;gt;&#xA;Press ENTER or type command to continue&#xA;Error detected while processing /home/bridge/c/sheth7/.vim/bundle/python-mode/autoload/py&#xA;mode/lint.vim:&#xA;line    1:&#xA;    from pylama.lint.extensions import LINTERS&#xA;Press ENTER or type command to continue&#xA;Error detected while processing /home/bridge/c/sheth7/.vim/bundle/python-mode/autoload/py&#xA;mode/lint.vim:&#xA;line    1:&#xA;ImportError: No module named pylama.lint.extensions&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;my &lt;code&gt;vim --version:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jul  9 2019 02:33:15)&#xA;Included patches: 1-207, 209-629&#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;-clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   +perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python/dyn      +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            -ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            +mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;   system vimrc file: &quot;/etc/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/etc&quot;&#xA; f-b for $VIMRUNTIME: &quot;/usr/share/vim/vim74&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE   -L/usr/local/lib -Wl,--as-needed -o vim        -lm -lnsl  -lselinux  -ltinfo -lacl -lattr -lgpm   -Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE  -fstack-protector  -L/usr/lib64/perl5/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc      &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23235" LastEditorUserId="23235" LastEditDate="2019-07-31T17:02:32.423" LastActivityDate="2020-04-26T21:06:00.693" Title="Error detected while processing ~/.vim/bundle/python-mode/autoload/pymode/lint.vim" Tags="|error|plugin-python-mode|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20781" PostTypeId="2" ParentId="20780" CreationDate="2019-07-31T20:03:00.227" Score="1" Body="&lt;p&gt;Your problem is in Python code, importing a Python module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a Python stack trace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Traceback (most recent call last):&#xA;   File &quot;&amp;lt;string&amp;gt;&quot;, line 2, in &amp;lt;module&amp;gt;&#xA;ImportError: No module named six&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to install the Python &lt;a href=&quot;https://pypi.org/project/six/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;six&lt;/code&gt;&lt;/a&gt; module in your machine, in order to get past this error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are quite a few ways to install Python modules on a host (&lt;code&gt;pip&lt;/code&gt; or native package managers such as &lt;code&gt;apt-get&lt;/code&gt;, &lt;code&gt;yum&lt;/code&gt; or &lt;code&gt;dnf&lt;/code&gt;, you can install it for Python 2 or Python 3, for your user only or system-wide), so it's hard to tell which option is right for you without knowing more details on your environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now that you know what the issue is (missing Python module), you can try to search for answers related to that, you'll probably find one that's right for you.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-07-31T20:03:00.227" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20782" PostTypeId="1" AcceptedAnswerId="20784" CreationDate="2019-08-01T00:23:06.663" Score="6" ViewCount="2170" Body="&lt;p&gt;I often find I want to quickly select all the characters in an aligned column, something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;this.p           = obj.['propery'];&#xA;this.prop        = obj.['proper'];&#xA;this.proper      = obj.['prop'];&#xA;this.property    = obj.['p'];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Say I want to select the &lt;code&gt;.&lt;/code&gt;s with visual block selection (&lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;).&#xA;If it's not immediately obvious how many rows there are (perhaps there are more), I typically use &lt;kbd&gt;{&lt;/kbd&gt; or &lt;kbd&gt;}&lt;/kbd&gt; once in visual block select mode to jump the appropriate distance. However, they go one line too far; if the following line is blank the cursor move to the first column, selecting far more than I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an equivalent to &lt;kbd&gt;{&lt;/kbd&gt; or &lt;kbd&gt;}&lt;/kbd&gt; which jumps &lt;em&gt;to&lt;/em&gt; the last line in the paragraph, while maintaining the current column?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My question is similar to &lt;a href=&quot;https://vi.stackexchange.com/q/14847/6079&quot;&gt;How do I move by paragraphs, but end up *in* the paragraph?&lt;/a&gt; but the answer given there (mapping &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt; after a &lt;code&gt;{&lt;/code&gt; or &lt;code&gt;}&lt;/code&gt;) won't work for me; the column will be lost.&lt;/p&gt;&#xA;" OwnerUserId="6079" LastActivityDate="2023-07-13T21:49:38.300" Title="Jump *to* end of paragraph?" Tags="|cursor-movement|visual-block|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20783" PostTypeId="1" CreationDate="2019-08-01T03:49:03.700" Score="2" ViewCount="56" Body="&lt;p&gt;The DiffUpdated event has been added in patch-8.1.0397.&#xA;Sometimes the event occurs a few times in a session.&#xA;For example, when 2 files are opened in diff mode,&#xA;&quot;:e!&quot; generates the event 3 times.&#xA;As another example, &quot;dd&quot; will generate it 2 times.&#xA;Also 2 times for &quot;:.diffget&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is much better to catch and act only on the last event&#xA;rather than each time the event occurs.&#xA;Is there any idea to identify the last one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can see it by using something like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:evhist = []&#xA;autocmd DiffUpdated * let g:evhist += [mode()]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1641" LastActivityDate="2019-08-01T03:49:03.700" Title="How to identify the last DiffUpdated event?" Tags="|vimscript|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20784" PostTypeId="2" ParentId="20782" CreationDate="2019-08-01T05:37:24.747" Score="7" Body="&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;silent&amp;gt;x :&amp;lt;C-U&amp;gt;call cursor(line(&quot;'}&quot;)-1,col(&quot;'&amp;gt;&quot;))&amp;lt;CR&amp;gt;`&amp;lt;1v``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vnoremap &amp;lt;silent&amp;gt;x&lt;/code&gt; --- remap something useless in visual mode (&lt;code&gt;x&lt;/code&gt; is the same as &lt;code&gt;d&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:&amp;lt;C-U&amp;gt;&lt;/code&gt; --- drop visual line range (also switches to normal mode)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;call cursor(...)&amp;lt;CR&amp;gt;&lt;/code&gt; --- set cursor position&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;line(&quot;'}&quot;)-1&lt;/code&gt; --- the last line of the current paragraph (except if it's the last paragraph in the whole file, but it's not that important, I think; use &lt;code&gt;line(&quot;'}&quot;) - empty(getline(line(&quot;'}&quot;)))&lt;/code&gt; if it is)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;col(&quot;'&amp;gt;&quot;)&lt;/code&gt; --- the end column of the visual selection&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;`&amp;lt;1v --- restore visual mode&lt;/li&gt;&#xA;&lt;li&gt;`` --- jump back to the latest jump, i.e. extend selection till that &lt;code&gt;cursor()&lt;/code&gt; position&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-08-01T06:48:19.383" LastActivityDate="2019-08-01T06:48:19.383" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="20785" PostTypeId="1" CreationDate="2019-08-01T09:38:07.907" Score="1" ViewCount="122" Body="&lt;p&gt;I have an annoying problem that I have no idea how to fix it. Every time I open a specific log file for some weird reason the window starts with 2 spaces column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mL9UZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mL9UZ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This happen only with this specific log and I have no idea how to remove those columns. The only way that I've found is to rename the file (e.g. foo) and open it. When I do that, the layout is normal. Can anyone help please ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers,&#xA;Stefano.&lt;/p&gt;&#xA;" OwnerUserId="19221" LastActivityDate="2019-08-01T09:38:07.907" Title="Remove spacing column begin line" Tags="|vimrc|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20786" PostTypeId="1" AcceptedAnswerId="20796" CreationDate="2019-08-01T10:05:48.127" Score="0" ViewCount="48" Body="&lt;p&gt;I have below function to compare perforce versions.&lt;br&gt;&#xA;The function runs fine, only I must quit the version compare software to keep typing words or switch to anther window. Basically gvim stops responding after compare software starts.&lt;br&gt;&#xA;Tried adding '\&amp;amp;' to the command end, but it's not helping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! P4_Diff (...)&#xA;   if ! exists('a:1')&#xA;      let P4_Diff_Log = system('p4 diff '.expand(&quot;%&quot;).' \&amp;amp;')&#xA;      echo P4_Diff_Log&#xA;   else&#xA;      if a:1 =~# '\d\+$'&#xA;         let P4_Diff_Log = system('p4 diff '.expand(&quot;%&quot;).'\#'.a:1.' \&amp;amp;')&#xA;         echo P4_Diff_Log&#xA;      else&#xA;         echo &quot;Usage: P4_Diff (VersionNumber)&#xA;      endif&#xA;   endif&#xA;endfunction   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13402" LastActivityDate="2019-08-02T18:20:28.583" Title="How to keep vim running after kick off an application?" Tags="|functions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20787" PostTypeId="1" AcceptedAnswerId="20789" CreationDate="2019-08-01T10:17:00.720" Score="6" ViewCount="1313" Body="&lt;p&gt;When typing a report, we have a large list of acronyms defined in &lt;code&gt;Acronyms.tex&lt;/code&gt;. In order to use it, we have to encapsulate an acronym such as &lt;code&gt;KDF&lt;/code&gt; with the acronym command: &lt;code&gt;\ac{KDF}&lt;/code&gt;. I often forget and find it rather cumbersome to type it every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty sure I've seen auto-replacing in Vim, without using &lt;code&gt;:%s/x/y/&lt;/code&gt; manually. It may have been a plugin or it may have been supported natively, I don't know.&lt;/p&gt;&#xA;" OwnerUserId="14459" LastEditorUserId="21062" LastEditDate="2019-08-06T13:19:22.177" LastActivityDate="2019-08-06T13:19:22.177" Title="How to auto-replace words, such as acronyms, while typing?" Tags="|substitute|insert-mode|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20788" PostTypeId="2" ParentId="20787" CreationDate="2019-08-01T10:17:00.720" Score="4" Body="&lt;p&gt;After some searching, it turns out that &lt;a href=&quot;https://vi.stackexchange.com/a/20443/14459&quot;&gt;single character replacements&lt;/a&gt; work just as well for words. The answer is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap KDF \ac{KDF}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As the help text says: &quot;Map the key sequence {lhs} to {rhs}&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When typing the specified word (&quot;lhs&quot;) in insert mode, it will automatically be replaced (by the &quot;rhs&quot;). For example, when simply typing &lt;code&gt;When using a KDF for&lt;/code&gt;, it will automatically be replaced and result in: &lt;code&gt;When using a \ac{KDF} for&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beware that this also works in replace mode, e.g. when your cursor is on the beginning of a line of text starting with &lt;code&gt;KEF testtest&lt;/code&gt;, typing &lt;code&gt;RKDF&lt;/code&gt; will not turn the line into &lt;code&gt;KDF testtest&lt;/code&gt; or &lt;code&gt;\ac{KDF} testtest&lt;/code&gt;, but into &lt;code&gt;\ac{KDF}test&lt;/code&gt; instead (since you are in replace mode, it will overwrite the following characters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And beware that fixing a single character will not trigger the replacement. It maps the key sequence, not the word. Replacing the &quot;E&quot; in &quot;KEF&quot; using &lt;code&gt;lrD&lt;/code&gt; (turning it into &quot;KDF&quot;) does not trigger the replacement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I just noticed a disadvantage: any uppercase characters will now wait for the next character. If I defined inoremaps for &lt;code&gt;KDF&lt;/code&gt; and &lt;code&gt;ABC&lt;/code&gt;, then typing an &lt;code&gt;A&lt;/code&gt; or a &lt;code&gt;K&lt;/code&gt; in insert mode will wait for the next character (with a 1-second timeout) before moving the cursor ahead. If I type &lt;code&gt;KDF&lt;/code&gt; too slowly (1 second between each character), it is not replaced. Neither behaviour is impossible to work with, but neither is desirable, either. If anyone has a better solution, please post it as an answer to the question so I can accept that as answer instead!&lt;/p&gt;&#xA;" OwnerUserId="14459" LastEditorUserId="14459" LastEditDate="2019-08-01T10:31:05.530" LastActivityDate="2019-08-01T10:31:05.530" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20789" PostTypeId="2" ParentId="20787" CreationDate="2019-08-01T10:59:13.187" Score="7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I just noticed a disadvantage&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's because you're trying to remap &lt;em&gt;a command&lt;/em&gt;. While &quot;auto-replacements&quot; in Vim are supposed to be done with &lt;em&gt;abbreviations&lt;/em&gt; (see &lt;code&gt;:help abbreviations&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create an abbreviation like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoreabbrev KDF \ac{KDF}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unlike commands, the abbreviations are typed as usual. And the substitution takes place when Vim knows that &lt;code&gt;KDF&lt;/code&gt; makes a whole word, not a part of it (e.g. &lt;code&gt;KDF&amp;lt;space&amp;gt; ---&amp;gt; \ac{KDF}&amp;lt;space&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-08-01T11:04:29.590" LastActivityDate="2019-08-01T11:04:29.590" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20790" PostTypeId="1" CreationDate="2019-08-01T11:04:08.653" Score="0" ViewCount="770" Body="&lt;p&gt;I've configured my .vimrc file for GGrep:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bang -nargs=* GGrep&#xA;  \ call fzf#vim#grep(&#xA;  \   ('git grep -i --line-number '.(isdirectory(expand(&quot;.git&quot;))?'--untracked ':'--no-index ')).shellescape(&amp;lt;q-args&amp;gt;), 0,&#xA;  \   { 'dir': getcwd() }, &amp;lt;bang&amp;gt;0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note I've configured it to show the file path. However I don't want to search the file path. I just want to search the contents of the files. Does anyone know how to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See below it's also filtering on the path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ocEMJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ocEMJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20310" LastEditorUserId="20310" LastEditDate="2019-08-02T09:39:37.103" LastActivityDate="2020-05-18T00:03:25.437" Title="fzf vim - when configured to display filenames of matched items, how to filter on just content and not the file names" Tags="|fzf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20792" PostTypeId="1" AcceptedAnswerId="20795" CreationDate="2019-08-01T16:43:27.063" Score="2" ViewCount="1003" Body="&lt;p&gt;Note: this is a neovim question, not stock vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have both &lt;code&gt;rbprettier&lt;/code&gt; and &lt;code&gt;prettier&lt;/code&gt; with the ruby plugin installed on my system. If I pipe a Ruby file into &lt;code&gt;rbprettier&lt;/code&gt;, or if I pipe it into &lt;code&gt;prettier --parser ruby&lt;/code&gt;, I get back a properly formatted version of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have ALE configured to format on save, and when ALE pipes the file into &lt;code&gt;prettier&lt;/code&gt;, it always does so with &lt;code&gt;--parser babel&lt;/code&gt;, which triggers fatal errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my ALE fixer configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_fixers = {&#xA;\   '*': ['remove_trailing_lines', 'trim_whitespace'],&#xA;\   'javascript': ['prettier', 'eslint'],&#xA;\   'typescript': ['prettier', 'eslint'],&#xA;\   'ruby': ['prettier'],&#xA;\   'rust': ['rustfmt'],&#xA;\}&#xA;let g:ale_fix_on_save = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I reconfigure ALE to either call &lt;code&gt;rbprettier&lt;/code&gt; directly for Ruby files, or to add the &lt;code&gt;--parser ruby&lt;/code&gt; option instead of &lt;code&gt;--parser javascript&lt;/code&gt; when I'm working in a Ruby file?&lt;/p&gt;&#xA;" OwnerUserId="23251" LastActivityDate="2019-08-02T07:01:02.923" Title="How do I configure the parameters that ALE sends to prettier for ruby?" Tags="|neovim|plugin-ale|filetype-ruby|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20794" PostTypeId="1" CreationDate="2019-08-02T06:50:35.033" Score="4" ViewCount="2430" Body="&lt;p&gt;I wanted to copy a public key from one machine to the other. I opened up vim and had two terminal buffers - one for each machine. In the terminal in which I had the first machine I went into normal mode and that automatically made the public key appear as if it is on multiple lines which is not what I wanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I copy a long line from a terminal buffer as it is?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: the suggested duplicate refers to just resizing the window which even if it works is still a limited solution.&lt;/p&gt;&#xA;" OwnerUserId="12408" LastEditorUserId="12408" LastEditDate="2019-08-02T08:57:00.193" LastActivityDate="2019-08-03T13:01:52.220" Title="How to copy long line from terminal buffer as it is without adding new lines?" Tags="|cut-copy-paste|terminal-buffer|multiple-lines|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20795" PostTypeId="2" ParentId="20792" CreationDate="2019-08-02T07:01:02.923" Score="1" Body="&lt;p&gt;ALE doesn't seem to support &lt;code&gt;prettier&lt;/code&gt; for Ruby in its default configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though it offers enough hooks for you to use a different executable (such as &lt;code&gt;rbprettier&lt;/code&gt;) or to pass it additional arguments (such as &lt;code&gt;--parser ruby&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can override these with buffer-local variables &lt;code&gt;b:ale_javascript_prettier_executable&lt;/code&gt; and &lt;code&gt;b:ale_javascript_prettier_options&lt;/code&gt;. See &lt;a href=&quot;https://github.com/dense-analysis/ale/blob/master/autoload/ale/fixers/prettier.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;autoload/ale/fixers/prettier.vim&lt;/code&gt; in the ALE source tree&lt;/a&gt; for the code that defines and uses these variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try something like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup ale_ruby&#xA;  au!&#xA;  au FileType ruby let b:ale_javascript_prettier_executable = 'rbprettier'&#xA;  &quot; Or:&#xA;  au FileType ruby let b:ale_javascript_prettier_options = '--parser ruby'&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note you only need one or the other, not both!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another alternative is to consider one of the fixers for Ruby supported out-of-the-box. You can find the registry in &lt;a href=&quot;https://github.com/dense-analysis/ale/blob/master/autoload/ale/fix/registry.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;autoload/ale/fix/registry.vim&lt;/code&gt; in the source tree&lt;/a&gt;, if you search for &quot;ruby&quot; you will find it supports &lt;code&gt;rubocop&lt;/code&gt;, &lt;code&gt;rufo&lt;/code&gt;, &lt;code&gt;sorbet&lt;/code&gt; and &lt;code&gt;standardrb&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And one final approach is that you can write your own custom Vim function for a fixer, in which you could invoke &lt;code&gt;prettier&lt;/code&gt; however you like. See &lt;a href=&quot;https://github.com/dense-analysis/ale/blob/v2.5.0/doc/ale.txt#L212&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ale-fix&lt;/code&gt;&lt;/a&gt; for some more details on that.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-02T07:01:02.923" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20796" PostTypeId="2" ParentId="20786" CreationDate="2019-08-02T07:44:35.300" Score="0" Body="&lt;p&gt;If you're spawning an external command that will open a separate window and run on its own (for example, a graphical diff tool), and if you don't need to read what the tool is writing on its standard output (which is the usual case, if you're running an external GUI command), you can simplify this to use &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3A%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:!&lt;/code&gt;&lt;/a&gt; instead of &lt;code&gt;system()&lt;/code&gt;, which will make it easier to run the command in background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! P4_Diff (...)&#xA;  if ! exists('a:1')&#xA;    silent execute '!p4 diff '.shellescape(expand(&quot;%&quot;)).' &amp;amp;'&#xA;    redraw!&#xA;  elseif a:1 =~# '\v^\d+$'&#xA;    silent execute '!p4 diff '.shellescape(expand(&quot;%&quot;).'#'.a:1).' &amp;amp;')&#xA;    redraw!&#xA;  else&#xA;    echo &quot;Usage: P4_Diff (VersionNumber)&quot;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-02T07:44:35.300" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20797" PostTypeId="1" AcceptedAnswerId="20798" CreationDate="2019-08-02T09:54:47.197" Score="1" ViewCount="740" Body="&lt;p&gt;Inside a function, saved multiple lines of external command output to a variable.&lt;br&gt;&#xA;How to delete a line from the variable? Like first line.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can run &lt;code&gt;let tmp = split(variable, &quot;\n&quot;)&lt;/code&gt; to assign the variable to a tmp list, then delete an item. Not sure if there is any easy way.&lt;/p&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="21062" LastEditDate="2019-08-06T13:17:22.600" LastActivityDate="2021-03-01T09:28:04.480" Title="How to delete a line from a variable?" Tags="|vimscript|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20798" PostTypeId="2" ParentId="20797" CreationDate="2019-08-02T10:33:46.780" Score="0" Body="&lt;p&gt;You may try this &lt;code&gt;substitute&lt;/code&gt; command to delete, e.g the 3rd line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(var, '\v^((.{-}\n){2}).{-}\n(.*)', '\1\3', '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The regex works as follows&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;^((.{-}\n){2})&lt;/code&gt; matches the first &lt;code&gt;2&lt;/code&gt; lines and capture it in group &lt;code&gt;\1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.{-}\n&lt;/code&gt; matches the next line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(.*)&lt;/code&gt; matches the rest of the variable and capture it in group &lt;code&gt;\3&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;\{-}&lt;/code&gt;    matches 0 or more of the preceding atom, as few as possible&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="22929" LastActivityDate="2019-08-02T10:33:46.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20799" PostTypeId="2" ParentId="20797" CreationDate="2019-08-02T11:47:32.347" Score="4" Body="&lt;p&gt;It depends on how you get the result of your external command but you might be interested in &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#systemlist%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h systemlist()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It executes the command given as parameter and returns a list containing every lines of the output. You can then use &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#list-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h list-functions&lt;/code&gt;&lt;/a&gt; on the result or simply &lt;code&gt;listVar[1:]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I think that is more robust and portable than matching the lines and doing some substitutions.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Here is an example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Get the result of ls has a list&#xA;let output = systemlist('ls')&#xA;echo output    &amp;quot; ['autoload', 'CODE_OF_CONDUCT.md', 'CONTRIBUTING.md', 'doc', 'plugin', 'README.md']&#xA;&#xA;&amp;quot; Remove first line&#xA;let output = output[1:]&#xA;echo output    &amp;quot; ['CODE_OF_CONDUCT.md', 'CONTRIBUTING.md', 'doc', 'plugin', 'README.md']&#xA;&#xA;&amp;quot; Remove README.md&#xA;call filter(output, 'v:val != &amp;quot;README.md&amp;quot;')&#xA;echo output    &amp;quot; ['CODE_OF_CONDUCT.md', 'CONTRIBUTING.md', 'doc', 'plugin']&#xA;&#xA;&amp;quot; Remove all *.md files&#xA;call filter(output, 'v:val !~ &amp;quot;.md&amp;quot;')&#xA;echo output    &amp;quot; ['doc', 'plugin']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#filter%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h filter()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-%21%3d&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h expr-!=&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#expr-%21%7e&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h expr-!~&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2021-03-01T09:28:04.480" LastActivityDate="2021-03-01T09:28:04.480" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20800" PostTypeId="2" ParentId="20727" CreationDate="2019-08-02T11:50:13.797" Score="1" Body="&lt;p&gt;You can  edit the last command to include \%V in the beginning of the pattern &lt;code&gt;g/\%Vpattern/cmd&lt;/code&gt; and it will search the last visual selection. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-08-02T11:50:13.797" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20801" PostTypeId="2" ParentId="9767" CreationDate="2019-08-02T13:08:11.923" Score="2" Body="&lt;p&gt;Pathogen will not manage (update, install, etc.) your plugins for you. You have to do that yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And a good way to do that yourself is to install plugins simply by cloning their Git repos to the ~/.vim/bundle folder. Then you can update them with one-line loops. For example in Bash you could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in ~/.vim/bundle/*; do git -C $i pull; done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And on Windows you could do this (assuming Git is in PATH):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for /d %i in (%userprofile%\.vim\bundle\*) do ( git -C &quot;%i&quot; pull )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your plugins have submodules, you can also add &lt;code&gt;git -C &quot;$i&quot; submodule update --init --recursive&lt;/code&gt; after the pull (on Windows change &lt;code&gt;$&lt;/code&gt; to &lt;code&gt;%&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="16650" LastActivityDate="2019-08-02T13:08:11.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20802" PostTypeId="1" CreationDate="2019-08-02T19:45:26.990" Score="2" ViewCount="2418" Body="&lt;p&gt;I was editing a file and found accidentally that I somehow escaped all the forward slashes in a path I was replacing in text. And that is something very useful!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, to do this replacement correctly I should escape the second path:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/mvn//opt/maven/bin/mvn/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did that somehow with an accidental keystroke! But which one? :-(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="23262" LastEditorUserId="21062" LastEditDate="2019-08-06T13:17:19.133" LastActivityDate="2019-08-06T13:17:19.133" Title="How to escape forward slashes?" Tags="|substitute|escape|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20803" PostTypeId="2" ParentId="20802" CreationDate="2019-08-02T21:10:18.700" Score="9" Body="&lt;p&gt;You don't need to escape them: you could use a different separator for the search pattern and the replace part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s;mvn;/opt/maven/bin/mvn;g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, if you really want to escape them, you can use a backslash (&lt;code&gt;\&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/mvn/\/opt\/maven\/bin\/mvn/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(much harder to read, IMO)&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-08-02T21:10:18.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20804" PostTypeId="1" AcceptedAnswerId="20805" CreationDate="2019-08-03T02:27:41.790" Score="3" ViewCount="110" Body="&lt;p&gt;When open a file with &lt;code&gt;:e&lt;/code&gt;, it have to be tell the exact path of the file, and even the temporary file will be listed, is there anyway to do &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open a file with only name, and let it automatically search under &lt;code&gt;:pwd&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Ignore certain file types, e.g. file~&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="23264" LastActivityDate="2019-08-03T03:53:41.150" Title="file search with :e" Tags="|vimrc|path|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20805" PostTypeId="2" ParentId="20804" CreationDate="2019-08-03T03:53:41.150" Score="3" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://vimhelp.org/editing.txt.html#%3Afind&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:find&lt;/code&gt;&lt;/a&gt; command to locate a file by name and open it for editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:find&lt;/code&gt; will search for the file in the directories listed in &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27path%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'path'&lt;/code&gt;&lt;/a&gt;, which by default includes the current directory. You can add more directories to &lt;code&gt;'path'&lt;/code&gt; that you want to look up, and you can use wildcards, including &lt;code&gt;**&lt;/code&gt; to traverse multiple subdirectories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, to find files recursively under the current tree, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set path+=**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; This can be very slow in trees with many subdirectories, so be careful with this setting. Prefer to specify narrower subsets of the tree, where to locate files you're searching for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also take a look at &lt;a href=&quot;https://vimhelp.org/editing.txt.html#file-searching&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help file-searching&lt;/code&gt;&lt;/a&gt; for more details on the kinds of expressions available to use in &lt;code&gt;'path'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, you can specify extensions to add to the file names, using the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27suffixesadd%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'suffixesadd'&lt;/code&gt;&lt;/a&gt; setting. For example, if you're working on a project using Python, HTML and JavaScript, you can use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set suffixesadd=.py,.html,.css,.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Having both &lt;code&gt;'path'&lt;/code&gt; and &lt;code&gt;'suffixesadd'&lt;/code&gt; set, you can use a command such as &lt;code&gt;:find ui&lt;/code&gt; to open file &lt;code&gt;static/javascript/frontend/ui.js&lt;/code&gt;. Pretty neat, huh? Or &lt;code&gt;:find model&lt;/code&gt; to open &lt;code&gt;src/db/model.py&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note you always need to specify the full name of the file (except for the path and the extension.) If you wanted something that would handle incomplete filenames only, then consider plug-ins such as &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;ctrlp.vim&lt;/a&gt; or &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf.vim&lt;/a&gt; to extend Vim with support for fuzzy finders.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also asked about ignoring backup files. When you're completing filenames (for example, using &lt;kbd&gt;Tab&lt;/kbd&gt; after a &lt;code&gt;:e&lt;/code&gt;), you can ignore files matching certain patterns by adding them to the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27wildignore%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'wildignore'&lt;/code&gt;&lt;/a&gt; setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set wildignore=*~,*.bak&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will skip backup files when completing filenames on a &lt;code&gt;:e&lt;/code&gt; command line.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-03T03:53:41.150" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20806" PostTypeId="1" AcceptedAnswerId="20807" CreationDate="2019-08-03T05:17:00.710" Score="1" ViewCount="486" Body="&lt;p&gt;I'm trying to write a substitution command that would search for a line that doesn't end with a space character and others (see regex) and isn't followed by an empty line. The line length may vary between 3 and 60 characters. I've ended up with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v(^[^\_s]{3,60}[^\s\.:;\?!])(\n[^\n])/\1\r\2/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;User should be able to confirm a replacement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the text below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Preface&#xA;To the Reader&#xA;The book you have in your hands&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After all the confirmations it should be transformed to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Preface&#xA;&#xA;To the Reader&#xA;&#xA;The book you have in your hands&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But with the above command it transforms to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Preface&#xA;&#xA;To the Reader&#xA;The book you have in your hands&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it processes only the first match.&lt;/p&gt;&#xA;" OwnerUserId="18651" LastActivityDate="2019-08-03T10:47:20.837" Title="Search/replace multiple lines with confirmation" Tags="|substitute|multiple-lines|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20807" PostTypeId="2" ParentId="20806" CreationDate="2019-08-03T07:03:31.090" Score="1" Body="&lt;p&gt;The main issue you're having here is that your match includes the beginning of the next line. After the replacement, Vim will keep looking for the next match, but it will start right after the last match ended, so it will miss the second line, since it won't match a regex that is anchored at the start of a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the specific example you gave, the first match will take &lt;code&gt;Preface\nT&lt;/code&gt; and then, once that's dealt with, Vim will start looking for the next one at &lt;code&gt;o the Reader&lt;/code&gt;, but that's not the start of a line, so not a match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve this issue, you need some kind of zero-width match, such as &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%40%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\@=&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%40%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\@!&lt;/code&gt;&lt;/a&gt;. (Note that under &lt;code&gt;\v&lt;/code&gt; &quot;verymagic&quot; these are simply written &lt;code&gt;@=&lt;/code&gt; and &lt;code&gt;@!&lt;/code&gt;, since all non-alphanumeric symbols are by default special unless quoted!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But a simpler solution is to use the &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Cze&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\ze&lt;/code&gt;&lt;/a&gt; end-of-match marker, which can play a similar role and requires a lot less grouping. (In fact, you can do this whole regex with zero groups!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that's the main issue... But there are (quite a few) other issues with your regex:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[^\_s]&lt;/code&gt; actually matches any character other than &lt;code&gt;\&lt;/code&gt;, &lt;code&gt;_&lt;/code&gt; or the letter &lt;code&gt;s&lt;/code&gt;, which is definitely not what you want! I guess you wanted to refer to &lt;code&gt;\_s&lt;/code&gt; for a blank including end-of-line (note: under &quot;verymagic&quot; that's actually written &lt;code&gt;_s&lt;/code&gt;, since symbols are special by default.) But end-of-line normally needs to be matched explicitly, so you're fine with &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5CS&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\S&lt;/code&gt;&lt;/a&gt; for a non-blank here.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;{3,60}&lt;/code&gt; is repeating the group, but I doubt you want up to 60 non-blank characters. Instead, I believe you want a non-blank, followed by &lt;em&gt;any&lt;/em&gt; characters, ending with a specific character. So use a &lt;code&gt;.&lt;/code&gt; for the middle part. If the total length of the line is to be between 3 and 60 characters, and you have special matches for the first and last, then you want between 1 and 58 in the middle.&lt;/li&gt;&#xA;&lt;li&gt;Similarly the last part &lt;code&gt;[^\s\.:;\?!]&lt;/code&gt;, the &lt;code&gt;\s&lt;/code&gt; doesn't work there (it's matching a literal &lt;code&gt;s&lt;/code&gt; or literal &lt;code&gt;\&lt;/code&gt;) and you don't need backslashes before &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt; either. For the blanks, use an explicit space and you can use &lt;code&gt;\t&lt;/code&gt; for a tab. (Those are the only two you really care about.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Putting it all together, you get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\v^\S.{1,58}[^ \t.:;?!]\ze\n\S/\0\r/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After the newline, it's matching a non-blank &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5CS&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\S&lt;/code&gt;&lt;/a&gt; directly. Since the match will include the whole first line (and nothing of the second), and since we're not grouping anything anymore, you can now use &lt;a href=&quot;https://vimhelp.org/change.txt.html#s%2F%5C0&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\0&lt;/code&gt;&lt;/a&gt; on the replacement side, to include the whole match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Testing on your example, I got what you described, so I believe this is what you wanted, or at least pretty close to it.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-08-03T10:47:20.837" LastActivityDate="2019-08-03T10:47:20.837" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20808" PostTypeId="2" ParentId="20794" CreationDate="2019-08-03T09:16:41.827" Score="2" Body="&lt;p&gt;I'm assuming that by &quot;terminal buffers&quot; you mean the &lt;code&gt;:terminal&lt;/code&gt; command. In theory you can just use the &lt;code&gt;++cols=1000&lt;/code&gt; option or &lt;code&gt;:set termsize&lt;/code&gt; (8.0)/&lt;code&gt;set termwinsize&lt;/code&gt; (8.1) commands to set a wider terminal width, at the expense of having to scroll to read the whole line. In practice, this new feature &lt;a href=&quot;https://vi.stackexchange.com/q/20223/15666&quot;&gt;seems rather buggy&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other options, however.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Copying Using the Terminal Program's Cut and Paste&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TLDR: Avoid &quot;visual&quot; (curses-using) programs such as Vim or &lt;a href=&quot;https://en.wikipedia.org/wiki/Less_(Unix)&quot; rel=&quot;nofollow noreferrer&quot;&gt;less&lt;/a&gt; when copying from a terminal; instead just &lt;code&gt;cat&lt;/code&gt; or &lt;code&gt;type&lt;/code&gt; the file in a terminal and use the terminal program's copy function.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most common way of handling this is to use the terminal's ability to do cut and paste to the windowing system's clipboard. Select the text in one window using your mouse, choose &quot;Copy&quot; from the terminal application's menu or via hotkey, move the focus to the other window, put vim into insert mode, and choose &quot;Paste&quot; from that terminal application's menu or via a hotkey. Vim will see this text as being &quot;typed in&quot; from the keyboard; the terminal application is what's &quot;typing&quot; the characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you do that sort of copy above, it's best to use a non-visual mode program to display the text. If you &lt;code&gt;cat&lt;/code&gt; or &lt;code&gt;type&lt;/code&gt; a file with lines that wrap, the terminal will see this as a long string of characters with a newline, and the terminal, though it will wrap the text (if configured to do so), will know that there is no LF, CR or similar between the last character on one row and the first character on the subsequent row; this will be reflected on what gets copied. On the other hand, programs like vim may not send the text to the terminal that way since they're concerned primarily with a nice visual display and it's safer to send a CR or cursor movement command when printing on a new line than to rely on the terminal's automatic wrapping; the terminal may see this as a newline when copying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, &lt;code&gt;:terminal&lt;/code&gt; in Vim itself is doing exactly this kind of wrapping (turning a single output line into multiple lines as it wraps), which appears to be the problem you're experiencing.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Command-line Vim and the Windowing System's Clipboard&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Another option is to use vim's interface to the windowing system's clipboard. This has several requirements:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Your windowing system is X11 (Linux, *BSD, X11 server running under Windows, etc.).&lt;/li&gt;&#xA;&lt;li&gt;Any remote machine you're using has a connection to that X11 server (e.g., via &lt;code&gt;ssh -X&lt;/code&gt;. (Local terminals need access to, but this is typically automatic via the &lt;code&gt;DISPLAY&lt;/code&gt; environment variable.)&lt;/li&gt;&#xA;&lt;li&gt;You're using a version of &lt;code&gt;vim&lt;/code&gt; with support for X11 communications (&lt;code&gt;vim --version&lt;/code&gt; shows &lt;code&gt;+X11&lt;/code&gt;, not &lt;code&gt;-X11&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In these cases you can use vim on both sides, yanking into the &lt;code&gt;&quot;+&lt;/code&gt; or &lt;code&gt;&quot;*&lt;/code&gt; buffer in one vim and pasting from that buffer in the other vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, the command-line version of Vim for windows can have these capabilities too when run locally. The version I have, built for MSYS and run from &lt;code&gt;bash&lt;/code&gt; in a &lt;code&gt;mintty&lt;/code&gt; terminal, works well for this. I believe that this was installed along with various other Unix-y tools when I installed &lt;a href=&quot;https://gitforwindows.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Git for Windows&lt;/a&gt;, but I'm sure that there are various sources for various builds of Vim to run under both MSYS or at regular Windows command lines.&lt;/p&gt;&#xA;" OwnerUserId="15666" LastEditorUserId="15666" LastEditDate="2019-08-03T13:01:52.220" LastActivityDate="2019-08-03T13:01:52.220" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20809" PostTypeId="1" AcceptedAnswerId="20819" CreationDate="2019-08-03T15:21:41.910" Score="4" ViewCount="148" Body="&lt;p&gt;Typing source code is easier for me when the numbers row above the letters (the numrow) is permanently shifted, giving me access to the symbols at a single keypress, without pressing &lt;code&gt;Shift&lt;/code&gt;. The numbers themselves are available when pressing &lt;code&gt;Shift&lt;/code&gt; of course. To achieve this, I use the following in my configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap 1 !&#xA;nnoremap 2 @&#xA;nnoremap 3 #&#xA;nnoremap 4 $&#xA;&quot; etc...&#xA;&#xA;vnoremap 1 !&#xA;vnoremap 2 @&#xA;vnoremap 3 #&#xA;vnoremap 4 $&#xA;&quot; etc...&#xA;&#xA;onoremap 1 !&#xA;onoremap 2 @&#xA;onoremap 3 #&#xA;onoremap 4 $&#xA;&quot; etc...&#xA;&#xA;&quot; the inverse maps not included here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works great normally, but I have a problem. The command for 'select everything inside parantheses', namely &lt;code&gt;vi)&lt;/code&gt;, isn't working as expected, because I &lt;strong&gt;still&lt;/strong&gt; have to press &lt;code&gt;Shift&lt;/code&gt; for &lt;code&gt;)&lt;/code&gt;, otherwise Vim will receive the command &lt;code&gt;vi0&lt;/code&gt;, which isn't what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want is to press &lt;code&gt;vi0&lt;/code&gt; but have the &lt;code&gt;0&lt;/code&gt; mapped to &lt;code&gt;)&lt;/code&gt; without shifting. Unfortunately, &lt;code&gt;onoremap 0 )&lt;/code&gt; didn't have any effect. How can I achieve this?&lt;/p&gt;&#xA;" OwnerUserId="8754" LastActivityDate="2019-08-04T13:59:54.757" Title="How to map number keys within motions typed during the operator-pending mode?" Tags="|key-bindings|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="20810" PostTypeId="1" AcceptedAnswerId="20818" CreationDate="2019-08-04T01:38:47.993" Score="11" ViewCount="3460" Body="&lt;p&gt;I am trying to load my optional language packages based on filetype.&#xA;I am using vim8 native package feature.&lt;/p&gt;&#xA;&lt;p&gt;In vim I can load them with &lt;code&gt;:packadd vim-javascript&lt;/code&gt;. However, I read in &lt;code&gt;:help packadd&lt;/code&gt; - (emphasis mine)&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Apackadd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:pa[ckadd][!] {name}&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Search for an optional plugin directory in &lt;code&gt;'packpath'&lt;/code&gt; and source any plugin files found.  The directory must match: &lt;code&gt;pack/*/opt/{name}&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The directory is added to &lt;code&gt;'runtimepath'&lt;/code&gt; if it wasn't there yet. If the directory &lt;code&gt;pack/*/opt/{name}/after&lt;/code&gt; exists it is added at the end of &lt;code&gt;'runtimepath'&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If loading packages from &lt;code&gt;pack/*/start&lt;/code&gt; was skipped, then this directory is searched first: &lt;code&gt;pack/*/start/{name}&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that &lt;code&gt;{name}&lt;/code&gt; is the directory name, not the name of the &lt;code&gt;.vim&lt;/code&gt; file.  All the files matching the pattern &lt;code&gt;pack/*/opt/{name}/plugin/**/*.vim&lt;/code&gt; will be sourced.  This allows for using subdirectories below &lt;code&gt;plugin&lt;/code&gt;, just like with plugins in &lt;code&gt;'runtimepath'&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;If the filetype detection was not enabled yet (this is usually done with a &lt;code&gt;syntax enable&lt;/code&gt; or &lt;code&gt;filetype on&lt;/code&gt; command in your &lt;code&gt;.vimrc&lt;/code&gt; file), this will also look for &lt;code&gt;{name}/ftdetect/*.vim&lt;/code&gt; files.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;When the optional &lt;code&gt;!&lt;/code&gt; is added no plugin files or ftdetect scripts are loaded, only the matching directories are added to &lt;code&gt;'runtimepath'&lt;/code&gt;.  This is useful in your &lt;code&gt;.vimrc&lt;/code&gt;.  The plugins will then be loaded during initialization, see &lt;a href=&quot;https://vimhelp.org/starting.txt.html#load-plugins&quot; rel=&quot;noreferrer&quot;&gt;|load-plugins|&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#pack-add&quot; rel=&quot;noreferrer&quot;&gt;|pack-add|&lt;/a&gt;. {only available when compiled with &lt;code&gt;+eval&lt;/code&gt;}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So I try to write something in my vimrc but it doesn't work.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd! FileType javascript packadd vim-javascript&#xA;&amp;quot; Or&#xA;autocmd FileType javascript packadd! vim-javascript &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I found this &lt;a href=&quot;https://www.reddit.com/r/vim/comments/7doeit/using_vim_8_package_loader_tipguide/&quot; rel=&quot;noreferrer&quot;&gt;Reddit post&lt;/a&gt; but as I mentioned, it doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="23261" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-08-06T14:38:52.120" Title="how to load vim8 optional packages in vimrc?" Tags="|vimrc|plugin-system|packages|vim8|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20811" PostTypeId="1" AcceptedAnswerId="20812" CreationDate="2019-08-04T03:57:03.903" Score="1" ViewCount="137" Body="&lt;p&gt;Is it possible to map &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; to close the cmd window and go to normal mode? Currently pressing&#xA;&lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; closes the cmd window but takes you into Cmdline mode. So you have&#xA;to press either &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; again or &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; to go to normal mode.&lt;/p&gt;&#xA;" OwnerUserId="22837" LastActivityDate="2019-08-04T19:01:27.003" Title="Is there a quicker way to go from the cmd window to normal mode?" Tags="|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20812" PostTypeId="2" ParentId="20811" CreationDate="2019-08-04T04:40:19.887" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to map &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Remapping &lt;kbd&gt;Esc&lt;/kbd&gt; is strongly discouraged, as it may interfere with normal keycode processing in terminal version of Vim (see, for example, &lt;a href=&quot;https://stackoverflow.com/questions/11940801/mapping-esc-in-vimrc-causes-bizarre-arrow-behaviour&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, of course, you can remap something else &lt;strong&gt;for that particular &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; only&lt;/strong&gt;, so your mapping can't do bad things to other windows (BTW. this technique is also suggested under &lt;code&gt;:h cmdwin&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd CmdwinEnter * nnoremap &amp;lt;silent&amp;gt;&amp;lt;buffer&amp;gt;ZQ &amp;lt;C-C&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In fact, this is a very common pattern in Vim to fine-tune mappings for specific windows, and as such it's useful to add it to your toolbox. A pair of examples taken from my vimrc to illustrate this capability:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc | au!&#xA;    ...&#xA;    &quot; 'q' to close a non-modifiable window/buffer (e.g. 'help')&#xA;    autocmd BufWinEnter * if !&amp;amp;modifiable | nnoremap &amp;lt;buffer&amp;gt;q ZQ | endif&#xA;    &quot; &amp;lt;F5&amp;gt; to execute script&#xA;    autocmd FileType vim nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt;&amp;lt;F5&amp;gt; :update \| source %&amp;lt;CR&amp;gt;&#xA;    autocmd FileType sh nnoremap &amp;lt;buffer&amp;gt;&amp;lt;silent&amp;gt;&amp;lt;F5&amp;gt; :update \|&#xA;        \ execute 'terminal' &amp;amp;shell expand('%:S')&amp;lt;CR&amp;gt;&#xA;    ...&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-08-04T19:01:27.003" LastActivityDate="2019-08-04T19:01:27.003" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="20814" PostTypeId="1" AcceptedAnswerId="20981" CreationDate="2019-08-04T09:44:01.253" Score="3" ViewCount="213" Body="&lt;p&gt;In vim plugin 'tpope/vim-speeddating', it support wide variaty of date formats. e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; %Y-%m-%d%[ T_-]%H:%M             2019-08-04 07:42&#xA; %Y-%m-%d                         2019-08-04&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how to add my custom data formats, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; %Y/%m/%d                         2019/08/04&#xA; %Y/%m                            2019/08&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20720" LastEditorUserId="1292" LastEditDate="2019-08-04T13:28:24.637" LastActivityDate="2019-08-24T01:23:57.500" Title="How add new date formats to work in 'tpope/vim-speeddating' vim plugin?" Tags="|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20815" PostTypeId="2" ParentId="6731" CreationDate="2019-08-04T09:44:10.443" Score="3" Body="&lt;p&gt;I found that &lt;a href=&quot;https://vi.stackexchange.com/a/9917&quot;&gt;@Wolfie's answer&lt;/a&gt; captures unwrapping of a tuple as a keyword and it also had trouble capturing linebroken keyword arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inspired by his regex I came up with the following to put in my &lt;code&gt;python.vim&lt;/code&gt; syntax file. (Bear in mind that I'm originally using the &lt;code&gt;python.vim&lt;/code&gt; syntax file from &lt;a href=&quot;https://github.com/sheerun/vim-polyglot/blob/3ddca5da461ebfaa82104f82e3cbf19d1c326ade/syntax/python.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;sheerun/vim-polyglot&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match pythonFunctionKeyword &quot;\v\s{-}\zs\w+\ze\=(\=)@!(\_s)@!&quot; display&#xA;syn cluster pythonExpression add=pythonFunctionKeyword&#xA;syn region pythonFunctionKwargs start=+(+ end=+)+ contains=@pythonExpression&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the regex breakdown is very similar to &lt;a href=&quot;https://vi.stackexchange.com/a/9917&quot;&gt;@Wolfie's answer&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v      set to very magic mode&#xA;\s{-}   capture whitespace, nongreedy&#xA;\zs     start of the match (what to actually highlight)&#xA;\w+     one or more alphanumeric character, underscore included&#xA;\ze     stop matching; anything after this is delimiting only&#xA;\=      one single equal sign&#xA;(\=)@!  ...not followed by another equal sign&#xA;(\_s)@! ...not followed by any whitespace or newline character&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this will not color a keyword argument written as: &lt;code&gt;key = value&lt;/code&gt;. Which I consider a good thing, as that goes against the &lt;a href=&quot;https://www.python.org/dev/peps/pep-0008/#other-recommendations&quot; rel=&quot;nofollow noreferrer&quot;&gt;official PEP-8 whitespace recommendation for keyword arguments&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="23276" LastActivityDate="2019-08-04T09:44:10.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20816" PostTypeId="2" ParentId="20814" CreationDate="2019-08-04T09:45:07.983" Score="0" Body="&lt;p&gt;Write these lines in your ~/.vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufEnter * :SpeedDatingFormat %Y/%m/%d&#xA;au BufEnter * :SpeedDatingFormat %Y/%m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20720" LastActivityDate="2019-08-04T09:45:07.983" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20817" PostTypeId="1" CreationDate="2019-08-04T12:38:59.453" Score="4" ViewCount="980" Body="&lt;p&gt;I'm trying to use Mypy with Neomake, but without success.&#xA;I am currently using flake8 with Neomake, and it works seamlessly, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo(bar):&#xA;    return 1&#xA;&#xA;foo(1) &amp;gt; E305 expected 2 blank lines after class or function definition, found 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I am not getting warnings from Mypy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def foo(bar: str) -&amp;gt; int:&#xA;    return 1&#xA;&#xA;&#xA;foo(1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where I expect some sort of warnings at &lt;code&gt;foo(1)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run Mypy outside of vim, I get an exepcted result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;test.py:5: error: Argument 1 to &quot;foo&quot; has incompatible type &quot;int&quot;; expected &quot;str&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following is the part of my (Neo)vim setting relevant to Neomake / python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; make pyenv work with neovim&#xA;let g:python_host_prog = expand('~/.pyenv/versions/neovim-python2/bin/python')&#xA;let g:python3_host_prog = expand('~/.pyenv/versions/neovim-python3/bin/python')&#xA;&#xA;&quot; Neomake settings begin&#xA;call neomake#configure#automake('nrwi', 500)&#xA;&quot; let g:neomake_tex_enabled_makers = ['chktex', 'rubberinfo', 'proselint']&#xA;let g:neomake_python_enabled_makers = ['flake8', 'mypy']&#xA;let g:neomake_python_flake8_maker = {&#xA;  \ 'exe': expand('~/.pyenv/versions/3.7.3/envs/neovim-python3/bin/flake8'),&#xA;  \ 'args': ['--format=default'],&#xA;  \ 'errorformat':&#xA;      \ '%E%f:%l: could not compile,%-Z%p^,' .&#xA;      \ '%A%f:%l:%c: %t%n %m,' .&#xA;      \ '%A%f:%l: %t%n %m,' .&#xA;      \ '%-G%.%#',&#xA;  \ 'postprocess': function('neomake#makers#ft#python#Flake8EntryProcess')&#xA;  \ }&#xA;let g:neomake_python_mypy_maker = {&#xA;  \ 'exe': expand('~/.pyenv/versions/3.7.3/envs/neovim-python3/bin/mypy'),&#xA;  \ }&#xA;&quot; Neomake settings end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried with and without the latter three lines regarding &lt;code&gt;g:neomake_python_mypy_maker&lt;/code&gt;, but nothing seems to change.&#xA;Note that I use pyenv/virtualenv to encapsulate my vim settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make Mypy to work within vim?&#xA;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="19092" LastActivityDate="2019-08-04T12:38:59.453" Title="How do I setup Mypy with Neomake" Tags="|vimrc|neovim|filetype-python|plugin-neomake|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20818" PostTypeId="2" ParentId="20810" CreationDate="2019-08-04T13:34:13.657" Score="12" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;how to load vim8 optional packages in vimrc?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The way to load vim8 optional packages in your vimrc is to use the &lt;code&gt;:packadd!&lt;/code&gt; command, which will add them to your &lt;code&gt;'runtimepath'&lt;/code&gt;, which will make the &lt;code&gt;opt&lt;/code&gt; plugins load together with the ones in &lt;code&gt;start&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your particular case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;packadd! vim-javascript&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The examples you give hint that what you're actually trying to do is load a vim8 optional package &lt;em&gt;from an autocmd&lt;/em&gt;, which is a slightly different question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason they don't work is most likely because you're already processing a &lt;code&gt;FileType&lt;/code&gt; event at that point, and the plugin you're loading will register new &lt;code&gt;autocmd&lt;/code&gt;s for that same event, but those will most probably not be triggered for that same event you're already handling. Maybe you could hack something together using &lt;code&gt;doautocmd&lt;/code&gt; to process those commands again, but I really don't think that would be worth it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem here is that &lt;strong&gt;you're trying to optimize something which is not a performance problem&lt;/strong&gt;, or at least you haven't found it to be one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like most well written plug-ins, vim-javascript won't really load much of anything at the time it's loaded and the bulk of it will only get loaded once you start to actually use it (in this case, once you start editing JavaScript sources.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since vim-javascript (like most language plug-ins) doesn't carry any &lt;code&gt;plugin/*.vim&lt;/code&gt; files, the only code that will get loaded at startup is &lt;a href=&quot;https://github.com/pangloss/vim-javascript/blob/master/ftdetect/javascript.vim&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;ftdetect/javascript.vim&lt;/code&gt;&lt;/a&gt;, which has only 11 lines of Vimscript, should load really quickly and &lt;strong&gt;it's something you actually want loaded at startup&lt;/strong&gt;, since it contains interesting bits of FileType detection (such as looking for a &lt;code&gt;node&lt;/code&gt; shebang) that you'd be otherwise missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#pack-add&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help pack-add&lt;/code&gt;&lt;/a&gt; page has some interesting comments on the rationale for &lt;code&gt;opt&lt;/code&gt; and what should be stored there:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Where to put what&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Filetype plugins should go under &lt;code&gt;pack/*/start&lt;/code&gt;, so that they are always found.  Unless you have more than one plugin for a file type and want to select which one to load with &lt;code&gt;:packadd&lt;/code&gt;.  E.g. depending on the compiler&#xA;  version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if foo_compiler_version &amp;gt; 34&#xA;    packadd foo_new&#xA;else&#xA;    packadd foo_old&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In other words, the &lt;em&gt;intent&lt;/em&gt; of having filetype plug-ins under &lt;code&gt;opt&lt;/code&gt; is not to add the plug-in on demand. It is to add the plug-in conditionally, based on presence of some feature in your system which can be dynamically detected from your &lt;code&gt;.vimrc&lt;/code&gt;. For instance, you might want to detect whether a &lt;code&gt;node&lt;/code&gt; binary exists or if &lt;code&gt;eslint&lt;/code&gt; is present or similar, and only enable vim-javascript in those cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem of loading a plug-in's scripts on demand had been already solved, that's by using &lt;code&gt;autoload&lt;/code&gt; and &lt;code&gt;ftplugin&lt;/code&gt;. So the cost of adding it unconditionally is quite low, almost insignificant, at Vim startup. Definitely not a reason to try to add it from an &lt;code&gt;autocmd&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-04T13:34:13.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20819" PostTypeId="2" ParentId="20809" CreationDate="2019-08-04T13:59:54.757" Score="2" Body="&lt;p&gt;Vim maps will handle commands, not individual keystrokes, so if you want to remap your keys, you'll need to handle two character commands which use one of those keys explicitly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the example you brought up, &lt;code&gt;vi)&lt;/code&gt;, you'll want to create new Visual and operator-pending mappings for &lt;code&gt;i)&lt;/code&gt; (and &lt;code&gt;a)&lt;/code&gt; which is similar):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap i0 i)&#xA;vnoremap i0 i)&#xA;onoremap a0 a)&#xA;vnoremap a0 a)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then you'll see that there are more such two character commands that use the symbols on those keys, and will want to remap those as well. For example, &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#g%23&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g#&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#gstar&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g*&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap g3 g#&#xA;nnoremap g8 g*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then you'll start finding &lt;a href=&quot;https://vimhelp.org/change.txt.html#g%26&quot; rel=&quot;nofollow noreferrer&quot;&gt;more&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/motion.txt.html#g0&quot; rel=&quot;nofollow noreferrer&quot;&gt;more&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe it's not that bad, but it feels like it's not the best solution for this problem. I think I'd recommend looking into keyboard mappings at the O.S. level, or at least terminal emulator. Some advantages of that would be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;That would work in any program, not just Vim.&lt;/li&gt;&#xA;&lt;li&gt;That would work in Vim regardless of mode and whether the mapped character is part of a multi-character command.&lt;/li&gt;&#xA;&lt;li&gt;That would work even for new mappings introduced by plug-ins that include the remapped symbols.&lt;/li&gt;&#xA;&lt;li&gt;You could remap the numeric keys on the top row, but leave the keypad untouched so it would still produce numbers (with, or perhaps even without, NumLock.) With the Vim mappings, you're affecting all of them the same, since you can't tell them apart.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So I think there are better solutions to this problem than Vim mappings... But if you go that way, then consider the multi-character mappings as part of what you need to handle.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-04T13:59:54.757" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20821" PostTypeId="2" ParentId="4893" CreationDate="2019-08-05T13:59:28.187" Score="1" Body="&lt;p&gt;To avoid false positives with a pattern like &lt;code&gt;*markdown*&lt;/code&gt;, use &lt;code&gt;*&lt;/code&gt; and then filter in the code that you run from the autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType * call s:CheckMarkdown()&#xA;&#xA;function s:CheckMarkdown()&#xA;  if match(&amp;amp;filetype, '\v&amp;lt;markdown&amp;gt;') != -1&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; ... run your desired side-effects&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10084" LastActivityDate="2019-08-05T13:59:28.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20822" PostTypeId="1" CreationDate="2019-08-05T14:41:56.090" Score="1" ViewCount="284" Body="&lt;p&gt;I'm trying to sort following json that is inside of terraform file. I'd like to sort it alphabetically by &lt;code&gt;&quot;name&quot;&lt;/code&gt; value (ENV-&gt;PORT-&gt;USERNAME): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      {&#xA;        &quot;name&quot;: &quot;PORT&quot;,&#xA;        &quot;value&quot;: sometimes_there_is_no_quotation_mark&#xA;      },&#xA;      {&#xA;        &quot;name&quot;: &quot;ENV&quot;,&#xA;        &quot;value&quot;: &quot;${var.env}&quot;&#xA;      },&#xA;      {&#xA;        &quot;name&quot;: &quot;USERNAME&quot;,&#xA;        &quot;value&quot;: &quot;${var.username}&quot;&#xA;      }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've been trying &lt;code&gt;jq&lt;/code&gt; &lt;code&gt;json.tool&lt;/code&gt; and &lt;a href=&quot;https://www.reddit.com/r/vim/comments/76m6xa/sorting_multi_line_objects/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;SortGroup&lt;/code&gt;&lt;/a&gt; function but unfortunately none of them works for me.&lt;/p&gt;&#xA;" OwnerUserId="23292" LastEditorUserId="21062" LastEditDate="2019-08-06T13:17:08.113" LastActivityDate="2019-08-06T13:17:08.113" Title="sort json content in terraform file" Tags="|sort|filetype-json|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20823" PostTypeId="2" ParentId="20715" CreationDate="2019-08-05T20:20:55.420" Score="2" Body="&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; The problem was actually a bug in neovim fixed by the commit &lt;a href=&quot;https://github.com/neovim/neovim/commit/47b7b471fa0f33550f886dc93976ded97f602292&quot; rel=&quot;nofollow noreferrer&quot;&gt;47b7b471fa&lt;/a&gt; which is now merged in master.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So after &lt;a href=&quot;https://github.com/neovim/neovim/issues/10696&quot; rel=&quot;nofollow noreferrer&quot;&gt;asking the Neovim issue tracker&lt;/a&gt; it turns out this is the current &quot;expected&quot; behavior of the code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;https://github.com/neovim/neovim/blob/f5d1e0e7b1837e8b76f1561167543c90a9942a7a/src/nvim/terminal.c#L1309&quot; rel=&quot;nofollow noreferrer&quot;&gt;terminal.c&lt;/a&gt; the function &lt;code&gt;adjust_topline()&lt;/code&gt; iterates over &lt;code&gt;FOR_ALL_WINDOWS_IN_TAB&lt;/code&gt;, changing that to iterate over &lt;code&gt;FOR_ALL_TAB_WINDOWS&lt;/code&gt; fixes my issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure of the implications regarding the performances of this change, but if the neovim community agrees I'll create a PR.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-08-23T15:26:20.027" LastActivityDate="2019-08-23T15:26:20.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20824" PostTypeId="1" AcceptedAnswerId="20827" CreationDate="2019-08-05T22:27:55.003" Score="1" ViewCount="459" Body="&lt;p&gt;Currently, the numpad does the usual things(input numbers and so on). numlock does nothing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if you can differentiate numbers/char entered on the numpad from those typed on the main section of the keyboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am on MacOS if relevant(VimR). &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="1841" LastEditDate="2019-08-06T15:21:50.390" LastActivityDate="2019-08-06T22:21:09.530" Title="is it possible to map numpad differently?" Tags="|key-bindings|macos|keyboard-layout|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20826" PostTypeId="2" ParentId="12461" CreationDate="2019-08-06T05:13:25.563" Score="1" Body="&lt;p&gt;An alternative &lt;code&gt;~/.vimrc&lt;/code&gt; addition which only affects org-mode files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType org setlocal foldlevel=99&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23302" LastActivityDate="2019-08-06T05:13:25.563" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20827" PostTypeId="2" ParentId="20824" CreationDate="2019-08-06T05:50:51.413" Score="3" Body="&lt;p&gt;There are special keys &lt;code&gt;&amp;lt;k0&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;k9&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;kPlus&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;kMinus&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;kDivide&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;kMultiply&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;kEnter&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;kPoint&amp;gt;&lt;/code&gt;, which can be mapped separately, e.g.,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;k0&amp;gt; Zero&#xA;inoremap &amp;lt;k1&amp;gt; One&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I checked this with GVim running on Windows 7; the behavior on macOS might be different.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastEditorUserId="21062" LastEditDate="2019-08-06T22:21:09.530" LastActivityDate="2019-08-06T22:21:09.530" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20828" PostTypeId="1" CreationDate="2019-08-06T06:41:12.213" Score="3" ViewCount="227" Body="&lt;p&gt;I've mapped 'L' and 'H' to change buffers in vim. I often end up hitting these keys in NERDTree and Tagbar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm able to use &lt;code&gt;NERDTreeAddKeyMap&lt;/code&gt; to make NERDTree ignore keys. Tagbar only allows the use of &lt;code&gt;g:tagbar_map_.*&lt;/code&gt; to &lt;em&gt;replace&lt;/em&gt; key bindings that exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can make 'H' and 'L' do nothing in the Tagbar?&lt;/p&gt;&#xA;" OwnerUserId="23304" LastEditorUserId="21062" LastEditDate="2020-02-19T02:11:48.273" LastActivityDate="2020-02-19T02:11:48.273" Title="How do I disable a a key in Tagbar" Tags="|vimrc|key-bindings|plugin-tagbar|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20829" PostTypeId="2" ParentId="20828" CreationDate="2019-08-06T07:48:56.087" Score="0" Body="&lt;p&gt;You can easily do this with &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;-specific mappings. Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType tagbar nmap &amp;lt;buffer&amp;gt;H &amp;lt;Nop&amp;gt;&#xA;autocmd FileType tagbar nmap &amp;lt;buffer&amp;gt;L &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-08-06T07:48:56.087" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20830" PostTypeId="2" ParentId="12461" CreationDate="2019-08-06T13:02:31.450" Score="0" Body="&lt;p&gt;I turn folds off&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nofoldenable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And toggle them with &lt;code&gt;zi&lt;/code&gt;. My auto-origami plugin (on github—link later) toggles the foldcolumn for me. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-08-06T13:02:31.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20831" PostTypeId="2" ParentId="20828" CreationDate="2019-08-06T14:36:41.170" Score="3" Body="&lt;p&gt;You can use a &lt;code&gt;FileType&lt;/code&gt; &lt;code&gt;autocmd&lt;/code&gt; and map those keys to &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/map.html#%3CNop%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup TagBar&#xA;    autocmd!&#xA;    autocmd FileType tagbar nnoremap &amp;lt;buffer&amp;gt; H &amp;lt;Nop&amp;gt;&#xA;    autocmd FileType tagbar nnoremap &amp;lt;buffer&amp;gt; L &amp;lt;Nop&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also always remember to &lt;a href=&quot;https://vi.stackexchange.com/questions/9455/why-should-i-use-augroup&quot;&gt;enclose your &lt;code&gt;autocmd&lt;/code&gt;s with a &lt;code&gt;augroup&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21062" LastEditorUserId="21062" LastEditDate="2019-08-08T12:13:26.847" LastActivityDate="2019-08-08T12:13:26.847" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20832" PostTypeId="2" ParentId="10988" CreationDate="2019-08-06T20:59:17.697" Score="0" Body="&lt;p&gt;Based on alwc's answer without using global state. This way it doesn't get out of sync when Netrw was open manually first. It will still &quot;glitch&quot; when opening Netrw manully after it was opend with this function. But there is nothing one can do about manual commands I guess.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ToggleNetrw()&#xA;        let i = bufnr(&quot;$&quot;)&#xA;        let wasOpen = 0&#xA;        while (i &amp;gt;= 1)&#xA;            if (getbufvar(i, &quot;&amp;amp;filetype&quot;) == &quot;netrw&quot;)&#xA;                silent exe &quot;bwipeout &quot; . i&#xA;                let wasOpen = 1&#xA;            endif&#xA;            let i-=1&#xA;        endwhile&#xA;    if !wasOpen&#xA;        silent Lexplore&#xA;    endif&#xA;endfunction&#xA;map &amp;lt;F3&amp;gt; :call ToggleNetrw() &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additionally you can set some defaults&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup ProjectDrawer&#xA;    autocmd!&#xA;    autocmd VimEnter * :Vexplore&#xA;augroup END&#xA;let g:netrw_banner=0        &quot; disable annoying banner&#xA;let g:netrw_winsize = 18    &quot; width in percent&#xA;let g:netrw_browse_split=4  &quot; open in prior window&#xA;let g:netrw_altv=1          &quot; open splits to the right&#xA;let g:netrw_liststyle=3     &quot; tree view&#xA;&quot; ret g:netrw_list_hide=netrw_gitignore#Hide()&#xA;&quot; let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+'&#xA;&quot; check: |netrw-browse-maps| for more mappings&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23261" LastEditorUserId="23261" LastEditDate="2019-08-06T22:47:51.223" LastActivityDate="2019-08-06T22:47:51.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20833" PostTypeId="1" CreationDate="2019-08-06T23:02:22.933" Score="6" ViewCount="2650" Body="&lt;p&gt;How can I make it so that no command or extra keystroke is required for the autocompletion menu to pop up?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e. what I want is the menu to be always present while in insert mode and to be constantly updating its suggestions as I type.&lt;/p&gt;&#xA;" OwnerUserId="23314" LastEditorUserId="10604" LastEditDate="2019-08-07T12:32:57.920" LastActivityDate="2019-09-07T09:50:17.433" Title="How to enable “on-the-fly” autocompletion?" Tags="|autocompletion|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20834" PostTypeId="1" AcceptedAnswerId="20835" CreationDate="2019-08-06T23:13:24.443" Score="3" ViewCount="505" Body="&lt;p&gt;Take a plugin like &lt;a href=&quot;https://github.com/nvie/vim-flake8&quot; rel=&quot;nofollow noreferrer&quot;&gt;Flake8&lt;/a&gt;. It instructs users to install using Vim 8's package manager by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ~/.vim/pack/flake8/start/&#xA;cd ~/.vim/pack/flake8/start/&#xA;git clone https://github.com/nvie/vim-flake8.git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On Windows, this brings up some questions about the compatibility of these paths. What is &lt;code&gt;~&lt;/code&gt; here? Should the files actually go in &lt;code&gt;~/.vim&lt;/code&gt;, or should they go in the Windows equivalent - &lt;code&gt;~/vimfiles&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can answer these questions by:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Using &lt;code&gt;:echo expand('~')&lt;/code&gt; and &lt;code&gt;:echo $HOME&lt;/code&gt; to learn what &lt;code&gt;~&lt;/code&gt; and &lt;code&gt;$HOME&lt;/code&gt; mean.&lt;/li&gt;&#xA;&lt;li&gt;Using &lt;code&gt;:set packpath&lt;/code&gt; to show your packpath.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;These are the answers I get on my copy of Windows 10, with a fresh install of Vim 8.1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set packpath&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;packpath=~/vimfiles,C:\Program Files (x86)\Vim/vimfiles,C:\Program&#xA;  Files (x86) \Vim\vim81,C:\Program Files&#xA;  (x86)\Vim/vimfiles/after,~/vimfiles/after&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo expand('~')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;C:\Users\user.name&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo $HOME&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;C:\Users\user.name&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From those answers, it seems like the place to make the &lt;code&gt;pack/*/start&lt;/code&gt; directories is in &lt;code&gt;C:\Users\user.name\vimfiles&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, that doesn't work! If I put the Flake8 files in &lt;code&gt;C:\Users\user.name\vimfiles\pack\flake8\start&lt;/code&gt;, they don't get automatically loaded. And this problem doesn't seem to be with just with Flake8 - this doesn't work with any plugin I've tried.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at &lt;code&gt;:scriptnames&lt;/code&gt;, the only scripts that are picked up are in &lt;code&gt;C:\Program Files (x86)&lt;/code&gt;. Nothing in &lt;code&gt;~&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that there is no &lt;code&gt;_vimrc&lt;/code&gt; or &lt;code&gt;.vimrc&lt;/code&gt; file in &lt;code&gt;~&lt;/code&gt; or &lt;code&gt;~/vimfiles&lt;/code&gt; or &lt;code&gt;~/.vim&lt;/code&gt; at this time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can verify that Flake8 works just fine if it's sourced manually, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:source ~\vimfiles\pack\flake8\start\autoload\flake8.vim&#xA;:source ~\vimfiles\pack\flake8\start\ftplugin\python_flake8.vim &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use the Vim 8 package manager on a per-user basis when Vim is running on Windows? If it is, what am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="23313" LastActivityDate="2019-08-06T23:23:44.487" Title="Vim 8.1 on Windows 10 Won't Detect Packages in $HOME" Tags="|microsoft-windows|packages|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20835" PostTypeId="2" ParentId="20834" CreationDate="2019-08-06T23:23:44.487" Score="1" Body="&lt;p&gt;The bit you quoted about sourcing the files manually gave it away:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I can verify that Flake8 works just fine if it's sourced manually, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:source ~\vimfiles\pack\flake8\start\autoload\flake8.vim&#xA;:source ~\vimfiles\pack\flake8\start\ftplugin\python_flake8.vim &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need to have a &lt;strong&gt;plug-in directory&lt;/strong&gt; under &lt;code&gt;start/&lt;/code&gt; and the plug-in contents inside that directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, you should have a &lt;code&gt;vim-flake8/&lt;/code&gt; under &lt;code&gt;start/&lt;/code&gt; and &lt;code&gt;autoload/&lt;/code&gt; and &lt;code&gt;ftplugin/&lt;/code&gt; under that subdirectory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;~\vimfiles\pack\flake8\start\&lt;b&gt;vim-flake8&lt;/b&gt;\autoload\flake8.vim&#xA;~\vimfiles\pack\flake8\start\&lt;b&gt;vim-flake8&lt;/b&gt;\ftplugin\python_flake8.vim&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you follow the &lt;code&gt;git clone&lt;/code&gt; instructions you referred to (adapting to &lt;code&gt;~/vimfiles&lt;/code&gt;), you should end up with a tree such as this one here.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-06T23:23:44.487" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20836" PostTypeId="2" ParentId="16504" CreationDate="2019-08-07T00:05:56.017" Score="1" Body="&lt;p&gt;The problem is with the quotes around your &lt;code&gt;:execute&lt;/code&gt; command. You want to close the single quote and then concatenate the &lt;code&gt;a:file&lt;/code&gt; argument there. Then close the double quotes for the &lt;code&gt;cmd /k&lt;/code&gt; execution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh and like @D.BenKnoble mentioned in the comments, it's &lt;code&gt;a:file&lt;/code&gt; (to refer to the argument passed to the function) rather than &lt;code&gt;g:file&lt;/code&gt; (which refers to a global variable by that name.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's likely you might also need escaping, for this to still work if your filename contains special characters. I'm not too familiar with Windows to be able to tell you which one is right for you there, please experiment with &lt;a href=&quot;https://vimhelp.org/eval.txt.html#escape%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;escape()&lt;/a&gt; and friends.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ExecuteManagerCheck(file)&#xA;    execute ':!start cmd /k &quot;C:\Users\xyz\Documents\checker\manager check '.a:file.'&quot;'&#xA;endfunction&#xA;&#xA;nmap &amp;lt;leader&amp;gt;m :call ExecuteManagerCheck(expand('%:p'))&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(And for escaping, I &lt;em&gt;think&lt;/em&gt; &lt;code&gt;escape(a:file, ' &quot;\')&lt;/code&gt; might be the one you need...)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-07T00:05:56.017" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20837" PostTypeId="2" ParentId="20756" CreationDate="2019-08-07T05:36:17.820" Score="1" Body="&lt;p&gt;Thanks to @filbranden's hint to append an extra &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to skip past Vim's prompt, I now have two solutions using Bash's &lt;code&gt;read&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Wait for &lt;kbd&gt;Enter&lt;/kbd&gt;&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-o&amp;gt;:!true;read -sp$'\nPress ENTER to continue. '&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Wait for any key&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-o&amp;gt;:!true;read -n1 -sp$'\nPress any key to continue. '&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18802" LastActivityDate="2019-08-07T05:36:17.820" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20838" PostTypeId="1" AcceptedAnswerId="21832" CreationDate="2019-08-07T13:09:50.107" Score="4" ViewCount="769" Body="&lt;p&gt;Is there a way to use more than one syntax highlighting schemes in one file?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, I'm interested in having part of a LaTeX code highlighted according to my python syntax highlighting rules:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is an example of embedding python inside \LaTeX.&#xA;&#xA;\begin{pycode}&#xA;import random&#xA;n = random.randint(10)&#xA;\end{pycode}&#xA;&#xA;Here's a random integer: $N=\pyc{print(n)}$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above example, the code will be generally highlighted according to the syntax file latex.vim, but inside the &lt;code&gt;pycode&lt;/code&gt; environment and the &lt;code&gt;pyc&lt;/code&gt; command, it will be highlightex according to python.vim.&lt;/p&gt;&#xA;" OwnerUserId="23320" LastActivityDate="2019-11-08T12:52:05.083" Title="Different syntax highlighting in the same file for different languages" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20839" PostTypeId="2" ParentId="20754" CreationDate="2019-08-07T14:43:50.870" Score="0" Body="&lt;p&gt;In the end, I ended up trimming the newline charachter using search/replace.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(a:string, '\n\+$', '', '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="496" LastActivityDate="2019-08-07T14:43:50.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20840" PostTypeId="1" AcceptedAnswerId="20841" CreationDate="2019-08-07T15:48:03.340" Score="1" ViewCount="27" Body="&lt;p&gt;Consider the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alpha0_inc0 : beta0_inc0_term&#xA;alpha1_inc1 : beta1_inc1_term&#xA;alpha2_inc2 : beta2_inc1_term&#xA;alpha3_inc3 : beta3_inc0_term&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to replace text matching the regex &lt;code&gt;inc\d&lt;/code&gt; with the &lt;code&gt;match+new&lt;/code&gt;. The expected result should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alpha0_inc0_new : beta0_inc0_new_term&#xA;alpha1_inc1_new : beta1_inc1_new_term&#xA;alpha2_inc2_new : beta2_inc1_new_term&#xA;alpha3_inc3_new : beta3_inc0_new_term&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inc\d&lt;/code&gt; matches &lt;code&gt;inc0&lt;/code&gt;, &lt;code&gt;inc1&lt;/code&gt;, etc. The issue is I want to just add a new term to all the regex matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to do this would be to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/inc0/inc0_new/g&#xA;:%s/inc1/inc1_new/g&#xA;:%s/inc2/inc2_new/g&#xA;:%s/inc3/inc3_new/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this gets tedious quickly. Is there a better way to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="23322" LastEditorUserId="1841" LastEditDate="2019-08-08T12:12:16.893" LastActivityDate="2019-08-08T12:12:16.893" Title="Replace the regex search term with the new character along with the regex term" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20841" PostTypeId="2" ParentId="20840" CreationDate="2019-08-07T15:55:19.707" Score="0" Body="&lt;p&gt;Use &lt;code&gt;&amp;amp;&lt;/code&gt; in your replacement string, which replaces the whole match, so you can easily add to it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/inc\d/&amp;amp;_new/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3As%25&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :s&amp;amp;&lt;/code&gt;&lt;/a&gt; for more special sequences you can use in substitutions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, if you want to use parts of the match, you can group parts with pairs of &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; and refer back to them with &lt;code&gt;\1&lt;/code&gt;, &lt;code&gt;\2&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, for most flexibility, you can use &lt;a href=&quot;https://vimhelp.org/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\=&lt;/code&gt;&lt;/a&gt; which allows you to enter an expression and use VimL to generate your replacement string.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-08-07T16:21:34.927" LastActivityDate="2019-08-07T16:21:34.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20842" PostTypeId="1" AcceptedAnswerId="20843" CreationDate="2019-08-07T16:32:58.580" Score="16" ViewCount="2471" Body="&lt;p&gt;I have two dicts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let defaults = {'hello': 'world', 'bye': 'jupiter'}&#xA;&#xA;:let override = {'hello': 'mars'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I merge the keys from &lt;code&gt;override&lt;/code&gt; so that I end up with a new dict like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{'hello': 'mars', 'bye': 'jupiter'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-08-14T23:50:56.487" Title="How can I merge two dictionaries in Vim?" Tags="|vimscript|dictionary|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20843" PostTypeId="2" ParentId="20842" CreationDate="2019-08-07T16:32:58.580" Score="15" Body="&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#extend%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;extend()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let defaults = {'hello': 'world', 'bye': 'jupiter'}&#xA;:let override = {'hello': 'mars'}&#xA;&#xA;:echo extend(defaults, override)&#xA;{'hello': 'mars', 'bye': 'jupiter'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Keys from the second argument override any existing ones in the first. The &lt;code&gt;defaults&lt;/code&gt; dict will be &lt;em&gt;modified in place&lt;/em&gt;, which may not be wanted. Use &lt;code&gt;copy()&lt;/code&gt; to prevent that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call extend(copy(defaults), override)&#xA;:echo defaults&#xA;{'hello': 'world', 'bye': 'jupiter'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is especially something to be careful of when you're passing a dict to a function, since it's passed by reference (so it'll be modified outside of the function, too).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that it's won't merge nested dicts, which may or may not be a good thing, depending on what you're looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo extend({'nest': {'a': 'b'}}, {'nest': {'b': 'XXXX'}})&#xA;{'nest': {'b': 'XXXX'}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll need a small helper function to recursively merge nested dicts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Merge two dictionaries, also recursively merging nested keys.&#xA;&quot;&#xA;&quot; Use extend() if you don't need to merge nested keys.&#xA;fun! s:merge(defaults, override) abort&#xA;  let l:new = copy(a:defaults)&#xA;  for [l:k, l:v] in items(a:override)&#xA;    let l:new[l:k] = (type(l:v) is v:t_dict &amp;amp;&amp;amp; type(get(l:new, l:k)) is v:t_dict)&#xA;          \ ? s:merge(l:new[l:k], l:v)&#xA;          \ : l:v&#xA;  endfor&#xA;  return l:new&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can remove the &lt;code&gt;copy()&lt;/code&gt; if you want to modify it in-place (bit faster, but possibly unexpected).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2019-08-14T23:50:56.487" LastActivityDate="2019-08-14T23:50:56.487" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20844" PostTypeId="1" AcceptedAnswerId="20845" CreationDate="2019-08-07T16:45:24.663" Score="4" ViewCount="176" Body="&lt;p&gt;I just noticed this in a Vim help page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;popup_beval(s:balloonText, #{mousemoved: 'word'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the &lt;code&gt;#{mousemoved: 'word'}&lt;/code&gt;? It looks like a dict?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using &lt;code&gt;:help #{&lt;/code&gt;, but that doesn't show any results.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-08-07T16:45:24.663" Title="What is the #{} syntax in Vim?" Tags="|vimscript|dictionary|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20845" PostTypeId="2" ParentId="20844" CreationDate="2019-08-07T16:45:24.663" Score="6" Body="&lt;p&gt;This is known as a &quot;literal dict&quot;, and is just the same as a regular dictionary, except that you don't need to quote the keys with quotes: It's documented at &lt;a href=&quot;https://vimhelp.org/eval.txt.html#literal-Dict&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help literal-Dict&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;#{hello: 'x'}&lt;/code&gt; is just a slightly more convenient way of writing &lt;code&gt;{'hello': 'x'}&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo #{hello: 'x'} == {'hello': 'x'}&#xA;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This was added in Vim 8.1.1705 (July 2019) and as of the time of writing (August 2019) this is &lt;em&gt;not&lt;/em&gt; in Neovim yet.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-08-07T16:45:24.663" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20846" PostTypeId="1" AcceptedAnswerId="20847" CreationDate="2019-08-07T18:18:08.830" Score="2" ViewCount="131" Body="&lt;p&gt;I have this in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Export text under the cursor&#xA;noremap &amp;lt;leader&amp;gt;e :w! &amp;gt;&amp;gt;&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows me to select text using visual mode, press &lt;code&gt;leader e&lt;/code&gt;, type a file name, and append the text under the cursor to that file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to also have the text under the cursor be deleted from the current file as part of this command, but I don't know how to accomplish that. &lt;/p&gt;&#xA;" OwnerUserId="23324" LastEditorUserId="23324" LastEditDate="2019-08-08T01:07:13.857" LastActivityDate="2019-08-08T01:07:13.857" Title="Write text under the cursor to new file and delete it form current file" Tags="|vimrc|key-bindings|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20847" PostTypeId="2" ParentId="20846" CreationDate="2019-08-07T20:02:38.900" Score="2" Body="&lt;p&gt;It seems you are using this mapping line-wise by selecting lines with &lt;code&gt;V&lt;/code&gt; before executing &lt;code&gt;&amp;lt;leader&amp;gt;e&lt;/code&gt;. This is worth a &lt;code&gt;command&lt;/code&gt; in my opinion.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% -nargs=1 -complete=file MoveTo&#xA;        \ &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;write! &amp;gt;&amp;gt; &amp;lt;args&amp;gt; | &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;d_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;-range=%&lt;/code&gt; to allow a range, if none, consider the whole buffer&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-nargs=1 -complete=file&lt;/code&gt; accept one argument and allow file completion for it&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;MoveTo&lt;/code&gt; name of the command...&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;write! &amp;gt;&amp;gt; &amp;lt;args&amp;gt;&lt;/code&gt; append lines from the range to the given argument&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;| &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;d_&lt;/code&gt; then delete the lines in the black hole register so that they aren't copied in &lt;code&gt;&quot;&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;leader&amp;gt;e :MoveTo&amp;lt;Space&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;e :MoveTo&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/map.txt.html#user-commands&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h user-commands&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://vimhelp.org/change.txt.html#quote_&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h quote_&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22929" LastEditorUserId="22929" LastEditDate="2019-08-07T20:19:02.840" LastActivityDate="2019-08-07T20:19:02.840" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20848" PostTypeId="1" CreationDate="2019-08-08T01:26:11.103" Score="3" ViewCount="61" Body="&lt;p&gt;I want to use &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt; command for Unicode characters, so &lt;code&gt;lmap&lt;/code&gt; is the way to go. I can map a letter to a Japanese kanji:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:lmap k 中&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then after &lt;code&gt;i_CTRL-^&lt;/code&gt;, I can press &lt;code&gt;fk&lt;/code&gt; to locate &lt;code&gt;中&lt;/code&gt;。&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there is a problem. There are only 26 letters, so I have to map a single letter to multiple characters. Or it will be meaningless. Actually I hope to map the first letter of the English spelling to the underlying Kanji character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then how can I &lt;code&gt;lmap&lt;/code&gt; a letter to multiple alternative characters?&lt;/p&gt;&#xA;" OwnerUserId="23327" LastEditorUserId="1841" LastEditDate="2019-08-08T12:10:15.013" LastActivityDate="2020-09-01T14:03:25.297" Title="Is it possible to `lmap` a key to multiple characters?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20849" PostTypeId="2" ParentId="20848" CreationDate="2019-08-08T03:21:04.470" Score="1" Body="&lt;p&gt;This direction may not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just re-&lt;code&gt;nmap&lt;/code&gt; all these &lt;code&gt;fa&lt;/code&gt;, &lt;code&gt;fb&lt;/code&gt;, ..., &lt;code&gt;fz&lt;/code&gt; to function calls. And it works.&lt;/p&gt;&#xA;" OwnerUserId="23327" LastActivityDate="2019-08-08T03:21:04.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20850" PostTypeId="1" CreationDate="2019-08-08T04:10:26.827" Score="2" ViewCount="527" Body="&lt;p&gt;I would like to get these line numbers of a different window without moving to that window.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line('w0')&#xA;line('w$')&#xA;line('.')&#xA;line('$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for the first two, we can use &lt;code&gt;getwininfo([{winid}])&lt;/code&gt; which returns a list including 'topline' and 'botline'. Is there any function or some workaround as for the last two?&lt;/p&gt;&#xA;" OwnerUserId="1641" LastEditorUserId="1841" LastEditDate="2019-08-08T12:09:02.653" LastActivityDate="2019-08-08T13:50:08.793" Title="How to get line numbers of a different window" Tags="|vimscript|vim-windows|line-numbers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20851" PostTypeId="2" ParentId="20833" CreationDate="2019-08-08T07:28:00.313" Score="1" Body="&lt;p&gt;I'm personally using &lt;a href=&quot;https://github.com/maralla/completor.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/maralla/completor.vim&lt;/a&gt; for this, it's very lightweight and requires no configuration to work. It doesn't do any fancy stuff or alter what's shown in the completion pop-up in any way, it will simply auto show the completion pop-up whenever it can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also using these settings for it, to make it more ergonomical:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Select autocomplete item with Tab&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; pumvisible() ? &quot;\&amp;lt;C-Y&amp;gt;&quot; : &quot;\&amp;lt;Tab&amp;gt;&quot;&#xA;&#xA;&quot; Don't autoselect an item from the completion menu, and always show the menu&#xA;let g:completor_complete_options='menuone,noinsert'&#xA;&#xA;&quot; No delay on showing the completion pop-up&#xA;let g:completor_completion_delay=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21062" LastEditorUserId="21062" LastEditDate="2019-08-08T07:34:15.833" LastActivityDate="2019-08-08T07:34:15.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20852" PostTypeId="1" CreationDate="2019-08-08T09:20:24.257" Score="1" ViewCount="37" Body="&lt;p&gt;I have a build log file from compiling a project with Visual Studio on a Windows machine, and would like to use quickfix mode to jump to the errors and warnings in that logfile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The logfile is read correctly, and I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(240 of 365649): warning C4146: unary minus operator applied to unsigned type, result still uns...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the bottommost line, but obviously the file cannot be opened because the path is from another machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to transform the path names, and ignore warnings for files that cannot be found after transformation?&lt;/p&gt;&#xA;" OwnerUserId="1722" LastActivityDate="2019-08-08T09:20:24.257" Title="Quickfix mode with path transformation" Tags="|quickfix|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20853" PostTypeId="2" ParentId="20850" CreationDate="2019-08-08T11:08:40.590" Score="2" Body="&lt;p&gt;As a partial answer, for &lt;code&gt;line('.')&lt;/code&gt;, you can get the buffer number associated with a window with &lt;code&gt;winbufnr({nr})&lt;/code&gt; (carefull to pass the window &lt;em&gt;number&lt;/em&gt; and not the window &lt;em&gt;id&lt;/em&gt;) then pass it to &lt;code&gt;getbufinfo([{expr}])&lt;/code&gt; and get the &lt;code&gt;lnum&lt;/code&gt; entry :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getbufinfo(winbufnr({nr}))[0]['lnum']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks to @Luc Hermitte, we can get the last line number with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;len(getbufline(winbufnr({nr}), 1, '$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which gets all the lines of the buffer as a list of strings and returns its length.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Old original answer&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Can't tell how to get &lt;code&gt;line('$')&lt;/code&gt; without moving to the actual window. But we could achieve it with a function that restores the current and previous visited window, than get any &lt;code&gt;line({expr})&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! WindowLine(winnr, expr)&#xA;    let curr_window = winnr()&#xA;    let prev_window = winnr('#')&#xA;    exec a:winnr . 'wincmd w'&#xA;    let line = line(a:expr)&#xA;    exec prev_window . 'wincmd w'&#xA;    exec curr_window . 'wincmd w'&#xA;    return line&#xA;endfunction&#xA;echo WindowLine(2, '$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22929" LastEditorUserId="22929" LastEditDate="2019-08-08T12:02:43.667" LastActivityDate="2019-08-08T12:02:43.667" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20854" PostTypeId="2" ParentId="20850" CreationDate="2019-08-08T13:50:08.793" Score="2" Body="&lt;p&gt;patch 8.1.1418 introduced &lt;a href=&quot;https://vimhelp.org/eval.txt.html#win_execute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h win_execute()&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call win_execute(winid, 'let l:num_lines = line(&quot;$&quot;) | let l:current_line = line(&quot;.&quot;)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's fast, it has no window related side effect.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-08-08T13:50:08.793" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20855" PostTypeId="1" CreationDate="2019-08-08T16:40:37.483" Score="3" ViewCount="50" Body="&lt;p&gt;I have output from static analyzer, that I parsed with Bash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want Vim to run on specified by analyzer line and add comment containing  warning id and description.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this,&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;vim $file +$line+'normal A'+'/* KW: $kwid desc: $desc */'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;$file&lt;/code&gt; is the path to file, &lt;code&gt;$line&lt;/code&gt; line number, &lt;code&gt;$kwid&lt;/code&gt; and &lt;code&gt;$desc&lt;/code&gt; are strings that describe what problem I'm working on for this case.&lt;/p&gt;&#xA;" OwnerUserId="23336" LastEditorUserId="13982" LastEditDate="2019-08-09T21:10:15.947" LastActivityDate="2019-08-10T00:55:59.093" Title="Add comment to file while opening (C)" Tags="|shell|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20856" PostTypeId="1" CreationDate="2019-08-08T17:26:32.583" Score="3" ViewCount="449" Body="&lt;p&gt;I am using SpaceVim as Ruby on Rails IDE and installed the tpope/vim-rails plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Commands such as &lt;code&gt;:Econtroller&lt;/code&gt;, &lt;code&gt;:Emodel&lt;/code&gt; and &lt;code&gt;:find&lt;/code&gt; are working just fine, but the &lt;code&gt;gf&lt;/code&gt; command provided by this plugin is not working in SpaceVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to use it, it shows me an error message such as the ones below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# for partial&#xA;Can't find file &quot;users/edit_form&quot; in path&#xA;&#xA;# with association&#xA;User has_many :notes&#xA;Can't find file &quot;notes&quot; in path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23337" LastEditorUserId="18609" LastEditDate="2020-05-10T05:42:04.037" LastActivityDate="2020-05-21T17:14:43.017" Title="How to get tpope/vim-rails gf command to work with SpaceVim" Tags="|key-bindings|filetype-ruby|spacevim|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20857" PostTypeId="2" ParentId="20855" CreationDate="2019-08-08T17:37:05.967" Score="1" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim &quot;$file&quot; +$line +&quot;normal! A/* KW: $your text $here */&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Parameter expansion does not happen in single quotes in bash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each command given to vim get’s one &lt;code&gt;+&lt;/code&gt; (it is not like string concatenation at all). &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-08-10T00:55:59.093" LastActivityDate="2019-08-10T00:55:59.093" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20858" PostTypeId="1" CreationDate="2019-08-08T18:15:46.967" Score="2" ViewCount="785" Body="&lt;p&gt;Is it different to standard Vi/Vim, if so how and why? Is it Vi or Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does show a version string/identifier that would suggest it is Vim 8.1.320 though oddly it is opened with the 'vi' command rather than vim and also there does seem to be a separate package for Vim itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's confusing to say the least.&lt;/p&gt;&#xA;" OwnerUserId="5214" LastActivityDate="2019-08-09T13:14:01.367" Title="What's the deal with the Vi/Vim in Ubuntu 18.04/19.04?" Tags="|linux-ubuntu|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20859" PostTypeId="2" ParentId="20858" CreationDate="2019-08-08T19:09:50.897" Score="3" Body="&lt;h1&gt;TL;DR&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;vi&lt;/code&gt; on your computer is almost certainly a symlink to &lt;code&gt;vim&lt;/code&gt;, renamed executable, or something similar rather than an actual &lt;code&gt;vi&lt;/code&gt; executable. The Vim package(s) in the repositories are built with different switches (i.e. features).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Small note first: there is no program called Vi/Vim. Vi and Vim are two separate programs. Vi is an editor created in the 1970s. Vim is a clone (not a fork!) of Vi created in the 1990s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vi was, until the early 2000s, under some restrictive licensing, not to mention having limited development after the 1980s. Since Unix clones were generally expected to provide a vi executable, open source operating systems such as BSD and Linux turned to Vi clones. In Linux's case Vim is usually selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to ensure compatibility, a symlink, hardlink, renamed executable, or some other thing is created at /bin/vi (or /usr/bin/vi) that, rather than launching Vi, launches Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as the additional package(s) in the repositories, well, Vim has a &lt;em&gt;lot&lt;/em&gt; of build switches, controlling things such as whether Python can be used in plugins and which version of Python; whether there's a GUI and if so, which GUI (GTK+, Motif, Athena, Win32, etc.); whether there's clipboard support; whether there's mouse support; and many, many other things. Linux distributions will typically pick a somewhat limited build to include in the base image, and make additional variants available through the repos. And of course, if you're not satisfied by the options there, you can build your own and select exactly which features you want.&lt;/p&gt;&#xA;" OwnerUserId="2736" LastEditorUserId="2736" LastEditDate="2019-08-08T20:15:04.143" LastActivityDate="2019-08-08T20:15:04.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20860" PostTypeId="1" CreationDate="2019-08-08T20:50:42.573" Score="3" ViewCount="123" Body="&lt;p&gt;In a normal mode key mapping I'd like to match the &lt;kbd&gt;ESC&lt;/kbd&gt; and only this key, not key sequences like caused by the arrow keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Background: I thought I'd torture myself in the process of avoiding excess &lt;kbd&gt;ESC&lt;/kbd&gt; presses in normal mode by force-quitting vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My naive approach was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap &amp;lt;Esc&amp;gt; :q!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it's actually working quite well&lt;sup&gt;1&lt;/sup&gt;, except, when trying to navigate with the arrow keys in normal mode, vim quits too. I suppose it's because vim is converting the arrow keys into escape sequences internally, and then handling the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; key before the rest of the sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1: on another system with some 7.4 release, vim exits on startup because something issues an escape key (sequence), probably.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reproducible with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 21 2019 04:10:35)&#xA;Included patches: 1-197, 322, 377-378, 550, 649, 651, 703, 706-707&#xA;Extra patches: 8.1.1401, 8.1.1382, 8.1.1368, 8.1.1367, 8.1.1366, &#xA;8.1.1365, 8.1.1046, 8.1.0613, 8.1.0547, 8.1.0546, 8.1.0544, &#xA;8.1.0540, 8.1.0539, 8.1.0538, 8.1.0506, 8.1.0208, 8.1.0206,  &#xA;8.1.0205, 8.1.0189, 8.1.0177, 8.1.0067, 8.1.0066&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Ask for the list of included/missing features, if required.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No plugins loaded, ensured with &lt;code&gt;--noplugin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was learning via Fandom's &lt;a href=&quot;https://vim.fandom.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_1)&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim key mapping tutorial&lt;/a&gt; and by searching this and other Stacks, so I might not have understood things well enough, yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I ignore &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; in escape sequences or match a single &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; or even debounce key sequences?&lt;/p&gt;&#xA;" OwnerUserId="23339" LastEditorUserId="23339" LastEditDate="2019-08-08T21:05:51.860" LastActivityDate="2019-08-08T22:04:02.377" Title="Match &lt;Esc&gt; only for the ESC key, not escape sequences" Tags="|key-bindings|escape|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20861" PostTypeId="2" ParentId="20860" CreationDate="2019-08-08T22:04:02.377" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;vim is converting the arrow keys into escape sequences internally&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not quite. This is the issue with all escape mappings: your terminal is sending the escape sequences, which vim knows to interpret as arrow keys. Flip the logic a little. Best answer: dont map escape.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I’m not aware of any way for vim to distinguish the different kinds of Escape presses. It does this internally via a really good guess, some timeout settings, and the terminfo database (in other words, it depends heavily on the terminal emulator and the terminal being emulated). &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-08-08T22:04:02.377" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20862" PostTypeId="1" CreationDate="2019-08-09T00:13:09.667" Score="1" ViewCount="117" Body="&lt;p&gt;If there is a &lt;code&gt;echo/echom&lt;/code&gt; sentence in the &lt;code&gt;vimrc&lt;/code&gt; or &lt;code&gt;gvimrc&lt;/code&gt; file, a &lt;strong&gt;dialog box&lt;/strong&gt; is popped out when gvim starts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to avoid this?&lt;/p&gt;&#xA;" OwnerUserId="23341" LastEditorUserId="15" LastEditDate="2019-08-09T19:25:42.997" LastActivityDate="2019-08-09T19:25:42.997" Title="How to avoid dialog box when using echo in vimrc/gvimrc file?" Tags="|vimrc|startup|echo|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20863" PostTypeId="1" CreationDate="2019-08-09T00:24:17.540" Score="6" ViewCount="1832" Body="&lt;p&gt;Is there a way to use a register or visual selection for search and replace?&#xA;I have some longer sequence of words that are used repeatedly in my script. I want to replace them all but want to avoid typing a long sentence in a command line. &#xA;If I can select them in visual mode or yank them in a buffer, and utilize it in replacement, it  makes my life a lot easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e.&#xA;Instead of doing something like,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/Some really long word sequence that Id0n+wanna type /replacement sentence/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am imagining something like. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/selected/replacement in a register/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23342" LastEditorUserId="23342" LastEditDate="2019-08-09T15:03:14.260" LastActivityDate="2019-08-10T18:20:50.723" Title="Using visual selection or register for search and replace" Tags="|substitute|visual-mode|register|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20864" PostTypeId="2" ParentId="20863" CreationDate="2019-08-09T01:07:08.933" Score="5" Body="&lt;p&gt;One possible solution is to use what I call &lt;em&gt;register recall&lt;/em&gt;: on the &lt;code&gt;:&lt;/code&gt;-command line, &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;r&lt;/kbd&gt; followed by any of the registers (the named ones, like &lt;code&gt;a&lt;/code&gt; or &lt;code&gt;3&lt;/code&gt;, or the others, such as &lt;code&gt;-&lt;/code&gt; or &lt;code&gt;&quot;&lt;/code&gt;) will insert the contents of said register. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This works in insert mode as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you could&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Yank the text&lt;/li&gt;&#xA;&lt;li&gt;Substitute with &lt;code&gt;:%s/&amp;lt;C-r&amp;gt;&quot;/replacement/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It’s also interesting to note that this works on searches, too, so you could&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Yank the text&lt;/li&gt;&#xA;&lt;li&gt;Search: &lt;code&gt;/&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Verify that you get the matches you want, or further refine the search pattern&lt;/li&gt;&#xA;&lt;li&gt;Substitute using the last pattern: &lt;code&gt;:%s//replacement/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;A further refinement is to yank the replacement and do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s//&amp;lt;C-r&amp;gt;&quot;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-08-10T18:20:50.723" LastActivityDate="2019-08-10T18:20:50.723" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20865" PostTypeId="2" ParentId="19799" CreationDate="2019-08-09T06:27:15.990" Score="2" Body="&lt;p&gt;The problem is with your alias:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vim=&quot;vim -S ~/.vim/.vimrc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that sourcing a script with &lt;code&gt;-S&lt;/code&gt; is &lt;strong&gt;not&lt;/strong&gt; the same as using that file as your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://vimhelp.org/starting.txt.html#-S&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help -S&lt;/code&gt;&lt;/a&gt; (emphasis mine):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The &lt;code&gt;{file}&lt;/code&gt; will be sourced &lt;strong&gt;after&lt;/strong&gt; the first file has been read.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, in effect, you're only setting &lt;code&gt;'undofile'&lt;/code&gt; and &lt;code&gt;'undodir'&lt;/code&gt; after you've already opened your &lt;code&gt;test.js&lt;/code&gt;. If you simply opened &lt;code&gt;vim&lt;/code&gt; with no files and then opened the file with &lt;code&gt;:e test.js&lt;/code&gt;, restoring undo might have worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to load your vimrc from a non-standard location, then &lt;a href=&quot;https://vimhelp.org/starting.txt.html#-u&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;-u&lt;/code&gt;&lt;/a&gt; is what you want instead... But there's really no reason to do that, just store your vimrc at one of the standard locations and get rid of that alias instead.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-09T06:27:15.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20866" PostTypeId="2" ParentId="20858" CreationDate="2019-08-09T07:52:34.677" Score="4" Body="&lt;p&gt;In Debian and Debian-derived distributions (such as Ubuntu), &lt;code&gt;vi&lt;/code&gt; is handled through the &quot;alternatives&quot; system.  To see the available alternatives for &lt;code&gt;vi&lt;/code&gt;, you can use the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ update-alternatives --display vi&#xA;vi - auto mode&#xA;  link currently points to /usr/bin/vim.gnome&#xA;/usr/bin/vim.basic - priority 30&#xA;  slave vi.1.gz: /usr/share/man/man1/vim.1.gz&#xA;  slave vi.fr.1.gz: /usr/share/man/fr/man1/vim.1.gz&#xA;  slave vi.it.1.gz: /usr/share/man/it/man1/vim.1.gz&#xA;  slave vi.ja.1.gz: /usr/share/man/ja/man1/vim.1.gz&#xA;  slave vi.pl.1.gz: /usr/share/man/pl/man1/vim.1.gz&#xA;  slave vi.ru.1.gz: /usr/share/man/ru/man1/vim.1.gz&#xA;/usr/bin/vim.gnome - priority 60&#xA;  slave vi.1.gz: /usr/share/man/man1/vim.1.gz&#xA;  slave vi.fr.1.gz: /usr/share/man/fr/man1/vim.1.gz&#xA;  slave vi.it.1.gz: /usr/share/man/it/man1/vim.1.gz&#xA;  slave vi.ja.1.gz: /usr/share/man/ja/man1/vim.1.gz&#xA;  slave vi.pl.1.gz: /usr/share/man/pl/man1/vim.1.gz&#xA;  slave vi.ru.1.gz: /usr/share/man/ru/man1/vim.1.gz&#xA;/usr/bin/vim.tiny - priority 10&#xA;  slave vi.1.gz: /usr/share/man/man1/vim.1.gz&#xA;  slave vi.fr.1.gz: /usr/share/man/fr/man1/vim.1.gz&#xA;  slave vi.it.1.gz: /usr/share/man/it/man1/vim.1.gz&#xA;  slave vi.ja.1.gz: /usr/share/man/ja/man1/vim.1.gz&#xA;  slave vi.pl.1.gz: /usr/share/man/pl/man1/vim.1.gz&#xA;  slave vi.ru.1.gz: /usr/share/man/ru/man1/vim.1.gz&#xA;Current 'best' version is '/usr/bin/vim.gnome'.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see here that my laptop has &lt;code&gt;vi&lt;/code&gt; automatically selecting the &quot;best&quot; alternative (&lt;code&gt;vi - auto mode&lt;/code&gt;) and that the &lt;code&gt;vi&lt;/code&gt; link points to &lt;code&gt;/usr/bin/vim.gnome&lt;/code&gt;, and then a bunch of more detailed information about the files involved and their priority rankings (&quot;best&quot; = highest priority setting).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want &lt;code&gt;vi&lt;/code&gt; to start a different alternative, you can use &lt;code&gt;sudo update-alternatives --config vi&lt;/code&gt; to choose one manually.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As for whether it is the same as standard vim, aside from the build switches which may vary depending on which vim package is the active alternative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get some information about the details of your active &lt;code&gt;vim&lt;/code&gt; alternative by using &lt;code&gt;dpkg -S&lt;/code&gt; to identify which package it came from and &lt;code&gt;dpkg -s&lt;/code&gt; to view the package details:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ dpkg -S /usr/bin/vim.gnome&#xA;vim-gnome: /usr/bin/vim.gnome&#xA;$ dpkg -s vim-gnome&#xA;Package: vim-gnome&#xA;&amp;lt;snip&amp;gt;&#xA; This package contains a version of vim compiled with a GNOME2 GUI&#xA; and support for scripting with Lua, Perl, Python, Ruby, and Tcl.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14483" LastEditorUserId="15" LastEditDate="2019-08-09T13:05:12.593" LastActivityDate="2019-08-09T13:05:12.593" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20867" PostTypeId="1" AcceptedAnswerId="20868" CreationDate="2019-08-09T10:18:19.487" Score="2" ViewCount="546" Body="&lt;p&gt;I am trying to figure out how to open a specific vimwiki diary on opening vim.&#xA;With one wiki I use an alias like&#xA;&lt;code&gt;alias todo='vim -c VimwikiDiaryIndex'&lt;/code&gt;&#xA;which works perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now I want an additional diary wiki for another set of notes. I already added the path and can change the diary inside of vim with&#xA;&lt;code&gt;2&amp;lt;Leader&amp;gt;wi&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't know how to combine it with my alias commands. (Something like &lt;code&gt;-c 2VimwikiDiaryIndex&lt;/code&gt; does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does someone know how I could get it done?&lt;/p&gt;&#xA;" OwnerUserId="23345" LastEditorUserId="18609" LastEditDate="2019-08-09T13:46:35.767" LastActivityDate="2020-08-05T07:27:50.253" Title="Vimwiki open specific diary on vim startup with bash alias" Tags="|plugin-vimwiki|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20868" PostTypeId="2" ParentId="20867" CreationDate="2019-08-09T12:05:04.383" Score="1" Body="&lt;p&gt;I'm guessing here but it seems you are trying to run normal mode mappings in batch mode (IOW, &lt;code&gt;vim -c &amp;lt;cmd&amp;gt;&lt;/code&gt;). Your &lt;code&gt;2wi&lt;/code&gt; ... I'm assuming that refers to &lt;code&gt;[count]&amp;lt;Leader&amp;gt;wi&lt;/code&gt;, a VimWiki mapped command in the docs...?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To run such mappings you need to use the &lt;code&gt;norm&lt;/code&gt; command (&lt;code&gt;:h :norm&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;code&gt;vim -c 'norm 2\wi'&lt;/code&gt; if  your Leader key is the default &lt;code&gt;\&lt;/code&gt; (backslash).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, if you want to run multiple commands using this method just use a separate &lt;code&gt;-c&lt;/code&gt; for each. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c 'norm 2\wi' -c 'wq'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-08-09T14:00:51.007" LastActivityDate="2019-08-09T14:00:51.007" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20869" PostTypeId="2" ParentId="20863" CreationDate="2019-08-09T12:39:21.700" Score="0" Body="&lt;p&gt;I use the following plugin to search for visually selected text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! VisualSelection()&#xA;    &quot; Save register content and type.&#xA;    let old_reg     = getreg('&quot;')&#xA;    let old_regmode = getregtype('&quot;')&#xA;&#xA;    &quot; Calling this function has ended visual mode, so it must be started&#xA;    &quot; again before the selection can be yanked into the unnamed register.&#xA;    normal! gvy&#xA;    let selection = @&quot;&#xA;&#xA;    &quot; Restore register content and type.&#xA;    call setreg('&quot;', old_reg, old_regmode)&#xA;&#xA;    return selection&#xA;endfunction&#xA;&#xA;function! Escaped(text)&#xA;    call inputsave()&#xA;    let result = escape(a:text, '\\/.*$^~[]')&#xA;    let result = substitute(result, &quot;\n$&quot;, &quot;&quot;, &quot;&quot;)&#xA;    let result = substitute(result, &quot;\n&quot;, '\\n', &quot;g&quot;)&#xA;    call inputrestore()&#xA;    return result&#xA;endfunction&#xA;&#xA;xnoremap &amp;lt;silent&amp;gt; &amp;lt;unique&amp;gt; * :&amp;lt;C-U&amp;gt;&amp;lt;cr&amp;gt;/&amp;lt;C-R&amp;gt;&amp;lt;C-R&amp;gt;=Escaped(VisualSelection())&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;xnoremap &amp;lt;silent&amp;gt; &amp;lt;unique&amp;gt; # :&amp;lt;C-U&amp;gt;&amp;lt;cr&amp;gt;?&amp;lt;C-R&amp;gt;&amp;lt;C-R&amp;gt;=Escaped(VisualSelection())&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This overrides the default behavior of &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;+&lt;/code&gt; which would extend the visual selection to the next occurrence of the word under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For replacement you can define a third mapping which creates a substitute command for the whole buffer and prefills the search text with the visually selected text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;silent&amp;gt; &amp;lt;unique&amp;gt; g* :&amp;lt;C-U&amp;gt;%s/&amp;lt;C-R&amp;gt;&amp;lt;C-R&amp;gt;=Escaped(VisualSelection()) . '/'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2636" LastEditorUserId="2636" LastEditDate="2019-08-10T10:04:52.120" LastActivityDate="2019-08-10T10:04:52.120" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20870" PostTypeId="2" ParentId="20858" CreationDate="2019-08-09T13:14:01.367" Score="3" Body="&lt;p&gt;Debian (and Ubuntu) only have the &lt;a href=&quot;https://packages.debian.org/vim-tiny&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-tiny&lt;/a&gt; package installed by default.  The sole purpose of this package is to provide a &lt;code&gt;vi&lt;/code&gt; binary as part of the default install.  That it happens to be Vim is just an implementation detail.  This is why the package doesn't install anything under the name &lt;code&gt;vim&lt;/code&gt;, uses a separate system-wide configuration file (/etc/vim/vimrc.tiny), and tunes the default configuration towards behaving like vi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the benefits of it actually being Vim is that you can install the vim-runtime package and get much of the benefit of Vim, but without pulling in a lot of other dependencies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, for a more standard &quot;Vim&quot; experience, one of the other Vim packages should be installed.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vim - All of Vim's features are enabled, but there are no language bindings or GUI support&lt;/li&gt;&#xA;&lt;li&gt;vim-nox - Same as vim, except now language bindings are enabled&lt;/li&gt;&#xA;&lt;li&gt;vim-gtk/vim-gtk3/vim-athena - Same as vim-nox, except built against the specific GUI toolkit&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="15" LastActivityDate="2019-08-09T13:14:01.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20871" PostTypeId="1" AcceptedAnswerId="20873" CreationDate="2019-08-10T05:04:11.143" Score="0" ViewCount="835" Body="&lt;p&gt;&lt;strong&gt;Vim error detected&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everytime i quit the vim i got this error, it's just pop up in a second.&#xA;I already upgrade the vim to the latest version but still got the same error.. How to fix that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OGyEJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OGyEJ.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error message reads:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function unite#sources#mru#_save[7]..218[7]..219[24]..220:&#xA;line    1:&#xA;E892: Using a String as a Float&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23356" LastEditorUserId="18609" LastEditDate="2019-08-10T13:01:38.920" LastActivityDate="2019-08-10T13:16:27.793" Title="Vim error detected" Tags="|vimrc|error|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20873" PostTypeId="2" ParentId="20871" CreationDate="2019-08-10T13:16:27.793" Score="0" Body="&lt;p&gt;The error message you're seeing refers to a function in the &lt;code&gt;unite#sources#mru&lt;/code&gt; namespace, which means it's probably in a MRU plug-in for &lt;a href=&quot;https://github.com/Shougo/unite.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;unite.vim&lt;/a&gt;, most probably &lt;a href=&quot;https://github.com/Shougo/neomru.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;neomru.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's an issue reported there that is very similar to yours: &lt;a href=&quot;https://github.com/Shougo/neomru.vim/issues/48&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue #48: &quot;Vim error: using String as a Float&quot;&lt;/a&gt;, reporting code that works in NeoVim but breaks in Vim 8.1. That issue was fixed by &lt;a href=&quot;https://github.com/Shougo/neomru.vim/commit/8ad581e0925ecefb94a7d2251803e9b3ba78818e&quot; rel=&quot;nofollow noreferrer&quot;&gt;this commit&lt;/a&gt;, around 5 months ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, try updating your plug-ins and see if that fixes that issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it doesn't, see if these are indeed the plug-ins you have and try to disable them to confirm whether that solves your issue or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't really use those plug-ins (and just got them from copying and pasting from somewhere in the web into your vimrc), consider disabling/removing them, no point in keeping them around if you don't use them...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still can't figure it out, you need to post a more detailed question, including more information about your system, which plug-in manager you're using (if any), which plug-ins you have installed, perhaps relevant snippets from your vimrc, etc.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-10T13:16:27.793" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20874" PostTypeId="1" CreationDate="2019-08-10T14:18:39.023" Score="2" ViewCount="2902" Body="&lt;p&gt;I want to set PYTHONPATH and python interpreter according to projects I am working on. I am working both on projects involving python 2.0, and ones involving python 3.0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is the concept of workspaces in coc, but I don't really understand it.&#xA;What happens is that it asks me for interpreter every time I open the same file. (It asks in menu and after I pick a suitable choise it is OK)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how should I do it? i.e. is there a configuration file for a project(where is it located, what to write) ? can it identify the use of &lt;code&gt;print &quot;asdas&quot;&lt;/code&gt; vs &lt;code&gt;print(&quot;asdaa&quot;)&lt;/code&gt; and thus determine the python version? How do you handle this problem? &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-08-13T17:48:17.063" LastActivityDate="2022-09-01T20:04:10.460" Title="Correct way to setup python version for coc" Tags="|neovim|filetype-python|plugin-coc|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20875" PostTypeId="1" AcceptedAnswerId="20876" CreationDate="2019-08-11T18:32:35.850" Score="1" ViewCount="201" Body="&lt;p&gt;I'm trying to make a function in vimscript that converts markdown to html files using pandoc and putting that converted file in a specified directory.&#xA;Currently i am putting the file in a directory relative to the original markdown file's path using &lt;code&gt;expand('%:p:h')&lt;/code&gt; and appending a new directory&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if my markdown file is in &lt;code&gt;/home/user/notes/subjects/science&lt;/code&gt; the converted html file will be in &lt;code&gt;/home/user/notes/subjects/science/convertedfile_dir&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since having an extra directory for my converted files in each and every subdirectory of my markdown notes can be inconvenient, i want to have a 'convertedfile_dir' in my outermost 'notes' directory, like this &lt;code&gt;/home/user/notes/convertedfile_dir&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically how do i manipulate the output of &lt;code&gt;expand()&lt;/code&gt; function, so that i can add &lt;code&gt;convertedfile_dir&lt;/code&gt; in the middle of the outputted path, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;markdown file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/home/user/notes/subjects/science/ecosystem.md&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;converted file output&#xA;&lt;code&gt;/home/user/notes/convertedfile_dir/subjects/science/ecosystem.html&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the function that i currently use to convert markdown to html using pandoc to a directory (named _html) that resides in the same directory as the original markdown file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ConvertHTMLPandoc()&#xA;    let realfile = expand('%:p')&#xA;    let filedir = expand('%:p:h') . '/_html/'&#xA;    let file = expand('%:t:r')&#xA;    let convertedfile = filedir . file . '.html'&#xA;    redraw&#xA;    echo 'deleting old file '. convertedfile&#xA;    execute &quot;!rm -f &quot; . convertedfile&#xA;    echo 'converting to html'&#xA;    execute &quot;!pandoc &quot; . realfile . &quot; -o &quot; . convertedfile . &quot; --template=uikit.html --toc&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Making the 'convertedfile_dir' to have the exact same directory structure as  my main notes directory is really important since i'm going to be working with images that are going to be placed in a directory of it's own in the main 'notes' directory, so that the images can still be loaded in the converted file. Really trying to write only once, and never have to re-edit the files after it is converted. (especially messed up paths).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance for helping me.&lt;/p&gt;&#xA;" OwnerUserId="22309" LastActivityDate="2019-08-17T16:13:59.180" Title="Insert text in the middle of a string vimscript" Tags="|vimscript|neovim|functions|string-manipulation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20876" PostTypeId="2" ParentId="20875" CreationDate="2019-08-11T18:55:59.417" Score="2" Body="&lt;p&gt;&lt;em&gt;Rather than take a direct approach to &quot;inserting text in the middle of a string&quot; I'd suggest something a bit more robust (and a bit more complex). It allows you to, say, change the root directory path or the converted file directory name in a straightforward way if you need to in the future. With a straight string manipulation you'd have to redo the logic.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First let's talk about &lt;a href=&quot;https://vimhelp.org/eval.txt.html#matchlist()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;matchlist()&lt;/code&gt;&lt;/a&gt;. &lt;code&gt;matchlist()&lt;/code&gt; in its simplest form takes a string and regular expression and returns a list containing any sub-matches found in the string. Sub-matches or &quot;capture groups&quot; are designated in a regular expression by surrounding appropriate parts of the pattern with parentheses. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note that I'm using &quot;very magic&quot; mode in my pattern to reduce the number of escapes. Without it the pattern would be something like &lt;code&gt;/home/user/notes\(/.\+\)\(/[^/]\+\)\.md$&lt;/code&gt;. Note that capture groups look like &lt;code&gt;\(pattern\)&lt;/code&gt; normally, i.e. the parentheses are escaped.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to parse the path currently stored in &lt;code&gt;realfile&lt;/code&gt; with &lt;code&gt;matchlist()&lt;/code&gt;. We apply a pattern to the path and use a couple capture groups to extract the sub-paths we want. From those sub-paths the target directory and filename are built. First crack at it looks like...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let m = matchlist(realfile, '\v/home/user/notes(/.+)(/[^/]+)\.md$')&#xA;let convertedfile = &quot;/home/user/notes/convertedfile_dir&quot; . m[1] . m[2]  . &quot;.html&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if &lt;code&gt;realfile&lt;/code&gt; contains &lt;code&gt;/home/user/notes/foo/bar/baz.md&lt;/code&gt; then sub-match 1 would be the directory path under &lt;code&gt;/home/user/notes&lt;/code&gt; (&lt;code&gt;/foo/bar&lt;/code&gt;) [see note below] and sub-match 2 would be the base file name (&lt;code&gt;baz&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;production&quot; version would be more like...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let rootdir = &quot;/home/user/notes&quot;&#xA;let converteddir = rootdir . &quot;/convertedfile_dir&quot;&#xA;&#xA;let matched = matchlist(expand(&quot;%:p&quot;), '\v' . rootdir . '(/.+)(/[^/]+)\.md$')&#xA;&quot; length of list and string elements 1 and 2 should all be &amp;gt; 0&#xA;if len(matched) &amp;amp;&amp;amp; strlen(matched[1]) &amp;amp;&amp;amp; strlen(matched[2])&#xA;    let convertedfile = converteddir . matched[1] . matched[2]  . &quot;.html&quot;&#xA;else &#xA;    &quot; bad match...handle as you best see fit&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the original file was &lt;code&gt;/home/user/notes/foo/bar/baz.md&lt;/code&gt; then &lt;code&gt;convertedfile&lt;/code&gt; in this script would be &lt;code&gt;/home/user/notes/convertedfile_dir/foo/bar/baz.html&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Side note&lt;/strong&gt; Regarding the pattern in the first capture group (&lt;code&gt;/.+&lt;/code&gt;) I'm assuming *nix filesystem where all (single-byte) characters are valid in filenames except &lt;em&gt;slash&lt;/em&gt; (&lt;code&gt;/&lt;/code&gt;) and &lt;em&gt;Nul&lt;/em&gt; (&lt;code&gt;\0&lt;/code&gt;). Since the capture should match multiple dirs &lt;code&gt;/&lt;/code&gt; has to be allowed. As for &lt;em&gt;Nul&lt;/em&gt; if that appears in this context there are probably larger issues so I'm not even going to worry about it here.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-08-17T16:13:59.180" LastActivityDate="2019-08-17T16:13:59.180" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20877" PostTypeId="2" ParentId="20875" CreationDate="2019-08-12T06:35:14.123" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;in the middle of the outputted path&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That depends upon what you think as &quot;a middle&quot;. But, in general, you can simply repeat &quot;:h&quot; a few times. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let realfile = expand('%:p')&#xA;let depth = count(realfile, '/') / 2&#xA;let filedir = expand('%:p' . repeat(':h', depth)) . '/_html/'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-08-12T06:35:14.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20879" PostTypeId="1" AcceptedAnswerId="20880" CreationDate="2019-08-13T00:16:04.187" Score="3" ViewCount="166" Body="&lt;p&gt;I'm trying to sort my bash functions inside my &lt;code&gt;.bash_functions&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I type :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^function /,/^}$/ s/\n/@@@&#xA;:sort /^function /&#xA;:%s/@@@/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT0 : Here is some of the input :&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;function listVideosFromRSSPodCastPlayList {&#xA;    test $# = 1 &amp;amp;&amp;amp; {&#xA;        local rssURL=&quot;$1&quot;&#xA;        local wget=&quot;$(which wget2 2&amp;gt;/dev/null || which wget)&quot;&#xA;#       echo $(youtube-dl -g &quot;$rssURL&quot;)&#xA;        echo $(curl -s &quot;$rssURL&quot; | egrep -o &quot;https?:[^ &amp;lt;&amp;gt;]*(mp4|webm)&quot; | grep -v .google.com/ | uniq)&#xA;    }&#xA;}&#xA;function getVideosFromRSSPodCastPlayList {&#xA;    test $# = 1 &amp;amp;&amp;amp; {&#xA;        local rssURL=&quot;$1&quot;&#xA;        local wget=&quot;$(which wget2 2&amp;gt;/dev/null || which wget)&quot;&#xA;#       $wget $(youtube-dl -g &quot;$rssURL&quot;)&#xA;        $wget $(curl -s &quot;$rssURL&quot; | egrep -o &quot;https?:[^ &amp;lt;&amp;gt;]*(mp4|webm)&quot; | grep -v .google.com/ | uniq)&#xA;    }&#xA;}&#xA;function jpgRotate {&#xA;    test $# = 0 &amp;amp;&amp;amp; {&#xA;        echo &quot;=&amp;gt; Usage: $FUNCNAME angle file1 file2 file3 ...&quot; &amp;gt;&amp;amp;2&#xA;        return 1&#xA;    }&#xA;&#xA;    local angle=$1&#xA;    shift&#xA;    for pic&#xA;    do&#xA;        extension=&quot;${pic/*./}&quot;&#xA;        newFile=&quot;${pic/.$extension/_ROTATED.$extension}&quot;&#xA;        echo &quot;=&amp;gt; Losslessly rotating $pic by $angle degrees into $newFile ...&quot; &amp;gt;&amp;amp;2&#xA;        jpegtran -perfect -rotate $angle &quot;$pic&quot; &amp;gt; &quot;$newFile&quot;&#xA;        touch -r &quot;$pic&quot; &quot;$newFile&quot;&#xA;    done&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Something is wrong with my first command because the functions' code should be converted into one liners.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, here is a little piece of the output I get instead :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function listVideosFromRSSPodCastPlayList {@@@  test $# = 1 &amp;amp;&amp;amp; {@@@     local rssURL=&quot;$1&quot;@@@        local wget=&quot;$(which wget2 2&amp;gt;/dev/null || which wget)&quot;@@@#       echo $(youtube-dl -g &quot;$rssURL&quot;)@@@      echo $(curl -s &quot;$rssURL&quot; | egrep -o &quot;https?:[^ &amp;lt;&amp;gt;]*(mp4|webm)&quot; | grep -v .google.com/ | uniq)@@@    }@@@}@@@function getVideosFromRSSPodCastPlayList {&#xA;    test $# = 1 &amp;amp;&amp;amp; {&#xA;        local rssURL=&quot;$1&quot;&#xA;        local wget=&quot;$(which wget2 2&amp;gt;/dev/null || which wget)&quot;&#xA;#       $wget $(youtube-dl -g &quot;$rssURL&quot;)&#xA;        $wget $(curl -s &quot;$rssURL&quot; | egrep -o &quot;https?:[^ &amp;lt;&amp;gt;]*(mp4|webm)&quot; | grep -v .google.com/ | uniq)&#xA;    }&#xA;}&#xA;function jpgRotate {@@@ test $# = 0 &amp;amp;&amp;amp; {@@@     echo &quot;=&amp;gt; Usage: $FUNCNAME angle file1 file2 file3 ...&quot; &amp;gt;&amp;amp;2@@@       return 1@@@ }@@@@@@ local angle=$1@@@   shift@@@    for pic@@@  do@@@       extension=&quot;${pic/*./}&quot;@@@       newFile=&quot;${pic/.$extension/_ROTATED.$extension}&quot;@@@     echo &quot;=&amp;gt; Losslessly rotating $pic by $angle degrees into $newFile ...&quot; &amp;gt;&amp;amp;2@@@       jpegtran -perfect -rotate $angle &quot;$pic&quot; &amp;gt; &quot;$newFile&quot;@@@     touch -r &quot;$pic&quot; &quot;$newFile&quot;@@@   done@@@}@@@function locateBin {&#xA;    local regExp=&quot;$1&quot;&#xA;    shift&#xA;    locate &quot;bin/.*$regExp&quot; &quot;$@&quot;&#xA;}&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you help me ?&lt;/p&gt;&#xA;" OwnerUserId="14229" LastEditorUserId="14229" LastEditDate="2019-08-13T09:47:28.720" LastActivityDate="2019-08-19T05:12:54.253" Title="Cannot sort my bash functions correctly" Tags="|bash|sort|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20880" PostTypeId="2" ParentId="20879" CreationDate="2019-08-13T01:06:02.483" Score="4" Body="&lt;p&gt;Try to add the negative offset &lt;code&gt;-1&lt;/code&gt; to the second line specifier in the range passed to the first substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                   v&#xA;:g/^function /,/^}/- s/\n/@@@&#xA;:sort /^function /&#xA;:%s/@@@/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Otherwise, the newline at the end of your first function is replaced with &lt;code&gt;@@@&lt;/code&gt;, which wrongly merges the first line of the second function with the last line of the first one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the last substition does not work correctly for input lines already ending with @ (for example : echo $@)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your substitution commands, you need to use a text which doesn't appear in your file.&#xA;A good candidate for this kind of transformation is a non-printing character such as a control character like a literal &lt;code&gt;C-a&lt;/code&gt; whose caret notation is &lt;code&gt;^A&lt;/code&gt;.&#xA;Try this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;g/^function /,/^}/- s/\\n/\&amp;lt;c-a&amp;gt;&quot;&#xA;:sort /^function /&#xA;:exe &quot;%s/\&amp;lt;c-a&amp;gt;/\\r/g&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;why bother with the &quot;exe&quot; command, extra quotes and extra backslashes which makes this harder to read ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The original command that I posted worked on your input file. Now, you say that it doesn't work on another input file which contains &lt;code&gt;echo $@&lt;/code&gt;, so I use a non-printing character for the replacement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works without the &lt;code&gt;exe&lt;/code&gt; and the extra backslashes, but in this case your replacement is just the text &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt;. And there's no guarantee it will work on some other input file you encounter in the future. OTOH, &lt;code&gt;^A&lt;/code&gt; is unlikely to appear in your bash script files &lt;sup&gt;1&lt;/sup&gt;, so there should be no issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you agree, then you need &lt;code&gt;exe&lt;/code&gt;, the quotes, and the extra backslashes to make Vim translate &lt;code&gt;\&amp;lt;c-a&amp;gt;&lt;/code&gt; into &lt;code&gt;^A&lt;/code&gt; (see &lt;code&gt;:h expr-quote&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see the result of the translation by replacing &lt;code&gt;exe&lt;/code&gt; with &lt;code&gt;echo&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo &quot;g/^function /,/^}/- s/\\n/\&amp;lt;c-a&amp;gt;&quot;&#xA;g/^function /,/^}/- s/\n/^A&#xA;                         ^^&#xA;&#xA;:echo &quot;%s/\&amp;lt;c-a&amp;gt;/\\r/g&quot;&#xA;%s/^A/\r/g&#xA;   ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: If you don't like the &lt;code&gt;:exe&lt;/code&gt; and the extra backslashes, to express &lt;code&gt;^A&lt;/code&gt; you can write &lt;code&gt;\%x01&lt;/code&gt; in the pattern and &lt;code&gt;\=&quot;\&amp;lt;c-a&amp;gt;&quot;&lt;/code&gt; in the replacement of the substitutions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^function /,/^}/- s/\n/\=&quot;\&amp;lt;c-a&amp;gt;&quot;/&#xA;:sort /^function /&#xA;:%s/\%x01/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; If you need to write &lt;code&gt;^A&lt;/code&gt; in one of your bash script, try &lt;code&gt;$'\ca'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ printf '%s' $'\ca' | od -tc&#xA;0000000 001&#xA;0000001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The syntax is documented in the &lt;code&gt;QUOTING&lt;/code&gt; section from &lt;code&gt;$ man bash&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Words of the form $'string' are treated specially.  The word expands to&#xA;  string,  with backslash-escaped characters replaced as specified by the&#xA;  ANSI C standard.  Backslash escape sequences, if present,  are  decoded&#xA;  as follows:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;\cx    a control-x character&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-08-19T05:12:54.253" LastActivityDate="2019-08-19T05:12:54.253" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="20881" PostTypeId="1" AcceptedAnswerId="20892" CreationDate="2019-08-13T09:53:22.490" Score="1" ViewCount="1318" Body="&lt;p&gt;I'm trying to set up patched fonts from &lt;a href=&quot;https://github.com/powerline/fonts&quot; rel=&quot;nofollow noreferrer&quot;&gt;powerline/fonts&lt;/a&gt; with airline in gvim under Windows 10 64 bit. As you can see from the screenshot here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Wj9Ta.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wj9Ta.png&quot; alt=&quot;gvim with ProFont for Powerline&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the characters from the font do show up, but the airline itself doesn't seem to output the special characters. I'm using the &lt;code&gt;set guifont=ProFont\ for\ Powerline:h12&lt;/code&gt; directive in my &lt;code&gt;~/_vimrc&lt;/code&gt;. Also, it is strange that although I installed vim-airline through Vundle (with &lt;code&gt;Plugin 'vim-airline/vim-airline'&lt;/code&gt;, then &lt;code&gt;:PluginInstall&lt;/code&gt;), the airline commands are apparently not recognized, for example &lt;code&gt;:AirlineExtensions&lt;/code&gt; gives the error message shown in the screenshot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Airline also doesn't work in plain vim on my setup with ProFont for Powerline set through the terminal Font settings. How do I set airline correctly in both vim and gvim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Here's &lt;a href=&quot;https://pastebin.com/exDg599b&quot; rel=&quot;nofollow noreferrer&quot;&gt;my &lt;code&gt;_vimrc&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt; Apparently &lt;code&gt;:scriptnames&lt;/code&gt; shows that vim-airline isn't actually sourced, and vim-airline-themes is, even though both are installed under &lt;code&gt;~/vimfiles/bundle/&lt;/code&gt; (vim-airline is in &lt;code&gt;~/vimfiles/bundle/vim-airline/&lt;/code&gt; and vim-airline-themes is in &lt;code&gt;~/vimfiles/bundle/vim-airline-themes/&lt;/code&gt;)? Also, &lt;code&gt;:echo exists(&quot;loaded_airline_themes&quot;)&lt;/code&gt; gives 1, but &lt;code&gt;:echo exists(&quot;loaded_airline&quot;)&lt;/code&gt; gives 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 3:&lt;/strong&gt; I apparently also had a leftover lightline in global vim plugin directory, which was giving the output in the screenshot. I removed it, but now the airline still doesn't show, and this is the &lt;a href=&quot;https://pastebin.com/11ieViwg&quot; rel=&quot;nofollow noreferrer&quot;&gt;output of &lt;code&gt;:scriptnames&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3OQdf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3OQdf.png&quot; alt=&quot;Status line after removing lightline&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23377" LastEditorUserId="23377" LastEditDate="2019-08-15T09:24:23.937" LastActivityDate="2019-08-15T10:03:13.473" Title="Powerline font not working with airline in (g)vim on Windows 10" Tags="|gvim|microsoft-windows|plugin-airline|plugin-vundle|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20882" PostTypeId="1" AcceptedAnswerId="20890" CreationDate="2019-08-13T09:55:02.253" Score="2" ViewCount="119" Body="&lt;p&gt;Here is what I am doing now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim + $1 -c &quot;set titlestring=$title guioptions-=m guioptions-=r lines=66 columns=239&quot; -c &quot;:source .vim_map&quot; -c &quot;sp .help.txt&quot; -c &quot;:wincmd j&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to open the &lt;strong&gt;.help.txt&lt;/strong&gt; in split window but as &lt;em&gt;read-only&lt;/em&gt; where the other file (the $1 as it is in the script) to be writable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;Piotr&lt;/p&gt;&#xA;" OwnerUserId="23378" LastActivityDate="2019-08-13T14:55:36.703" Title="How to open one file as &quot;read only&quot; but the others as writable using command line?" Tags="|command-line|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20883" PostTypeId="1" AcceptedAnswerId="20910" CreationDate="2019-08-13T10:13:42.837" Score="0" ViewCount="258" Body="&lt;p&gt;I am trying to remap my &lt;code&gt;hjkl&lt;/code&gt; keys to &lt;code&gt;jklö&lt;/code&gt;. this is not a problem in most simple cases, but with commands like &lt;code&gt;&amp;lt;C-w&amp;gt;h&lt;/code&gt; where you can specify an amount in the form of &lt;code&gt;&amp;lt;C-w&amp;gt;{count}h&lt;/code&gt; or &lt;code&gt;{count}&amp;lt;C-w&amp;gt;h&lt;/code&gt; this doesn't seem to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is there some way of doing a mapping like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nn &amp;lt;C-w&amp;gt;{count}j &amp;lt;C-w&amp;gt;{count}h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23379" LastActivityDate="2019-08-16T08:40:54.107" Title="how can i remap &lt;C-w&gt;{number}h to &lt;C-w&gt;{number}j" Tags="|key-bindings|map-operator|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20884" PostTypeId="2" ParentId="20882" CreationDate="2019-08-13T10:20:03.780" Score="1" Body="&lt;p&gt;I found a way. First split the window, then view the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace this &lt;code&gt;-c &quot;sp .help.txt&quot;&lt;/code&gt; with this &lt;code&gt;-c &quot;sp&quot; -c &quot;view .help.txt&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="23378" LastActivityDate="2019-08-13T10:20:03.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20885" PostTypeId="1" CreationDate="2019-08-13T11:48:17.780" Score="2" ViewCount="248" Body="&lt;p&gt;I installed the latest versions of Python and GCC/G++ in alternative locations. I am using SpaceVim. I think SpaceVim is using neomake as the default. I want to know how you can configure neomake to use the newest versions I installed in the alternative locations instead of the default version that was installed on linux. Also, I am trying to test c++17. Since c++17 is not the default, how would you be able to switch to that version with neomake?&lt;/p&gt;&#xA;" OwnerUserId="14824" LastActivityDate="2020-12-03T16:05:55.603" Title="Get neomake to recognize python and gcc location" Tags="|spacevim|plugin-neomake|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20887" PostTypeId="1" CreationDate="2019-08-13T13:11:08.887" Score="3" ViewCount="1383" Body="&lt;p&gt;I recently found the awesome plugin named &lt;a href=&quot;https://github.com/bkad/CamelCaseMotion/&quot; rel=&quot;nofollow noreferrer&quot;&gt;CamelCaseMotion&lt;/a&gt; which is awesome. I used their suggested mappings in my .vimrc for the plugin like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; w &amp;lt;Plug&amp;gt;CamelCaseMotion_w&#xA;sunmap w&#xA;omap &amp;lt;silent&amp;gt; iw &amp;lt;Plug&amp;gt;CamelCaseMotion_iw&#xA;xmap &amp;lt;silent&amp;gt; iw &amp;lt;Plug&amp;gt;CamelCaseMotion_iw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to map w but also b, e, ge to their respective functions. The problem is now that I want to map W, B, E to work like w, b, e worked before and &amp;lt;leader&gt;w, &amp;lt;leader&gt;b, &amp;lt;leader&gt;e to work like W, B, E. Also I want to remap gE and g&amp;lt;leader&gt;e in normal mode using the same rules above. This is where my vimscript-fu and google-fu failed me. I can't use &lt;code&gt;map &amp;lt;silent&amp;gt; W w&lt;/code&gt; because I will override w, and I can't find the function to which w is mapped originally/natively by vim. Can someone help please? Also you please explain how can I find mappings for native vim keys in the future? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;:map does not help me. It does not show the native mappings for w or W motion.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose map W&#xA;No mapping found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23383" LastEditorUserId="23383" LastEditDate="2019-08-13T13:29:57.877" LastActivityDate="2019-08-13T21:26:23.417" Title="Remapping motion keys" Tags="|key-bindings|neovim|cursor-motions|" AnswerCount="1" CommentCount="9" ClosedDate="2019-08-14T00:56:53.733" ContentLicense="CC BY-SA 4.0" />
  <row Id="20888" PostTypeId="2" ParentId="20887" CreationDate="2019-08-13T14:35:16.393" Score="2" Body="&lt;p&gt;You should simply use &lt;strong&gt;non-recursive&lt;/strong&gt; mappings, which allow you to access the original command under the keys, regardless of them having been mapped to something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, for &lt;code&gt;w&lt;/code&gt;, &lt;code&gt;W&lt;/code&gt; and &lt;code&gt;&amp;lt;leader&amp;gt;w&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;silent&amp;gt; w &amp;lt;Plug&amp;gt;CamelCaseMotion_w&#xA;noremap W w&#xA;noremap &amp;lt;leader&amp;gt;w W&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(And possibly use the &lt;code&gt;sunmap&lt;/code&gt;s that you had as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first one can't use a non-recursive mapping, because &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; is a &quot;virtual&quot; keystroke and you're actually invoking a mapping, so you need it to be recursive. But that's fine. It's an exception and one of the few cases where you want a non-recursive mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For most other cases, you will almost always want a non-recursive mapping. Use non-recursive mappings by default, unless you really know you need a recursive one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details and a great discussion on them, see &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/05.html#nonrecursive-mapping&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Nonrecursive Mappings&quot;&lt;/a&gt; on &quot;Learn Vimscript the Hard Way&quot;, which demonstrates why they're important and why you always want to use them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see the excellent answer to &lt;a href=&quot;https://vi.stackexchange.com/questions/7722/how-to-debug-a-mapping&quot;&gt;&quot;How to debug a mapping?&quot;&lt;/a&gt;, which has many pointers on how you can learn to debug this by yourself. (In fact, the answer to your particular question, using non-recursive mappings, is listed there under best practices.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-08-13T21:26:23.417" LastActivityDate="2019-08-13T21:26:23.417" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20889" PostTypeId="2" ParentId="20883" CreationDate="2019-08-13T14:52:34.633" Score="0" Body="&lt;p&gt;Note that the correct way to type this command is &lt;code&gt;{count}&amp;lt;C-w&amp;gt;h&lt;/code&gt;, with the &lt;code&gt;{count}&lt;/code&gt; preceding the command. &lt;code&gt;&amp;lt;C-w&amp;gt;h&lt;/code&gt; (and its friends) is a whole command on its own, so the count should precede it and not stand in the middle of the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And note that the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-w&amp;gt;j &amp;lt;C-w&amp;gt;h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will work for both &lt;code&gt;&amp;lt;C-w&amp;gt;j&lt;/code&gt; and &lt;code&gt;{count}&amp;lt;C-w&amp;gt;j&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there are workarounds you can use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming it's unlikely you'll want to switch a double digit number of windows in any direction at any time, you could simply add mappings for single digit counts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-w&amp;gt;1j 1&amp;lt;C-w&amp;gt;h&#xA;nnoremap &amp;lt;C-w&amp;gt;2j 2&amp;lt;C-w&amp;gt;h&#xA;nnoremap &amp;lt;C-w&amp;gt;3j 3&amp;lt;C-w&amp;gt;h&#xA;nnoremap &amp;lt;C-w&amp;gt;4j 4&amp;lt;C-w&amp;gt;h&#xA;nnoremap &amp;lt;C-w&amp;gt;5j 5&amp;lt;C-w&amp;gt;h&#xA;nnoremap &amp;lt;C-w&amp;gt;6j 6&amp;lt;C-w&amp;gt;h&#xA;nnoremap &amp;lt;C-w&amp;gt;7j 7&amp;lt;C-w&amp;gt;h&#xA;nnoremap &amp;lt;C-w&amp;gt;8j 8&amp;lt;C-w&amp;gt;h&#xA;nnoremap &amp;lt;C-w&amp;gt;9j 9&amp;lt;C-w&amp;gt;h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;could&lt;/em&gt; keep going. And you could generate these programatically using a for loop as well...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a more general solution than that, consider creating an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping for &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; itself, which will read more characters (using &lt;a href=&quot;https://vimhelp.org/eval.txt.html#getchar%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getchar()&lt;/code&gt;&lt;/a&gt;), parse a &lt;code&gt;{count}&lt;/code&gt; and a remaining command, mapping the &quot;hjkl&quot; commands according to your specification and issuing the final remapped command including the &lt;code&gt;{count}&lt;/code&gt;. (Personally, I think that's overkill, but go for it if you feel like it!)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-13T14:52:34.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20890" PostTypeId="2" ParentId="20882" CreationDate="2019-08-13T14:55:36.703" Score="1" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Asview&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:sview&lt;/code&gt;&lt;/a&gt; command, which opens the file in a split and sets &lt;code&gt;'readonly'&lt;/code&gt; on it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim ... -c &quot;sview .help.txt&quot; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-13T14:55:36.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20891" PostTypeId="2" ParentId="2761" CreationDate="2019-08-13T17:33:28.967" Score="1" Body="&lt;p&gt;To keep things minimal, but still works perfectly for me, I have this, inspired from above : plain highlight until &lt;code&gt;CursorMoved&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HLNext()&#xA;  let l:higroup = matchend(getline('.'), '\c'.@/, col('.')-1) == col('.')&#xA;              \ ? 'SpellRare' : 'IncSearch'&#xA;  let b:cur_match = matchadd(l:higroup, '\c\%#'.@/, 101)&#xA;  redraw&#xA;  augroup HLNext&#xA;    autocmd CursorMoved &amp;lt;buffer&amp;gt;&#xA;                \   execute 'silent! call matchdelete('.b:cur_match.')'&#xA;                \ | redraw&#xA;                \ | autocmd! HLNext&#xA;  augroup END&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; * *:call HLNext()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; # #:call HLNext()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; n n:call HLNext()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; N N:call HLNext()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, &lt;code&gt;n&lt;/code&gt; even without &lt;code&gt;hlsearch&lt;/code&gt; shows me the where I landed until I move the cursor. The &lt;code&gt;SpellRare&lt;/code&gt; is used to make it more ovbious when only a single character matches, otherwise it's the smooth &lt;code&gt;IncSearch&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="22929" LastEditorUserId="22929" LastEditDate="2019-08-16T14:25:29.183" LastActivityDate="2019-08-16T14:25:29.183" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20892" PostTypeId="2" ParentId="20881" CreationDate="2019-08-13T21:23:59.597" Score="1" Body="&lt;p&gt;I found a workaround. Manually copying the entire &lt;code&gt;vim-airline&lt;/code&gt; tree under the &lt;code&gt;$HOME/vimfiles/pack/plugins/start/&lt;/code&gt; did the trick, as the vim-airline plugin was then able to be loaded at startup. For some reason, simply installing vim-airline via Vundle doesn't make it able to be loaded on startup on both of my setups, unlike other packages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I also found the exact culprit. Apparently, the call to the plugin &lt;a href=&quot;https://github.com/rstacruz/sparkup&quot; rel=&quot;nofollow noreferrer&quot;&gt;rstacruz/sparkup&lt;/a&gt; (contained in the suggested &lt;code&gt;.vimrc&lt;/code&gt; from the Vundle documentation) is causing both that plugin and the plugin referenced in the subsequent &lt;code&gt;Plugin&lt;/code&gt; directive to fail to be sourced. Commenting out the offending line fixed the problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; The sparkup vim script is in a subdirectory of this repo called vim.&#xA;&quot; Pass the path to set the runtimepath properly.&#xA;&quot; v----- Doesn't work AND messes up the next 'Plugin' call -----v&#xA;&quot;Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}&#xA;&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'vim-airline/vim-airline-themes'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; There is an &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim/issues/902&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue on Vundle's GitHub page&lt;/a&gt; referencing this.&lt;/p&gt;&#xA;" OwnerUserId="23377" LastEditorUserId="23377" LastEditDate="2019-08-15T10:03:13.473" LastActivityDate="2019-08-15T10:03:13.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20893" PostTypeId="2" ParentId="12602" CreationDate="2019-08-13T21:27:39.817" Score="5" Body="&lt;p&gt;As you have stated in your question, you don't want to use a new mapping for this. (I'm also more in favour of &quot;vanilla&quot; vim key-bindings if possible, so I can use my muscle-memory on other systems aswell)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following vim keys let you paste with an additional &lt;code&gt;space&lt;/code&gt;, without the need to leave insert mode for pasting:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) Paste after a word somewhere in the middle of the line  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;go to end of word with &lt;code&gt;e&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;press &lt;code&gt;a&lt;/code&gt; to go into insert mode directly after word&lt;/li&gt;&#xA;&lt;li&gt;press &lt;code&gt;space&lt;/code&gt; to insert space after last character&lt;/li&gt;&#xA;&lt;li&gt;press &lt;code&gt;CTRL-r&lt;/code&gt; (cursor turns into &lt;code&gt;&quot;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;press &lt;code&gt;&quot;&lt;/code&gt; for the last copy register (or &lt;code&gt;0&lt;/code&gt; for the second-to-last, or &lt;code&gt;+&lt;/code&gt; for system clipboard register,...) &lt;strong&gt;(*)&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;b) Paste at the end of current line&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;press &lt;code&gt;A&lt;/code&gt; to go directly into insert mode at the end of line&lt;/li&gt;&#xA;&lt;li&gt;press &lt;code&gt;space&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;press &lt;code&gt;CTRL-r&lt;/code&gt; (cursor turns into &lt;code&gt;&quot;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;select preferred register &lt;strong&gt;(*)&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;(*)&lt;/strong&gt; To see all the copy registers use the command &lt;code&gt;:registers&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;code&gt;:help i_CTRL-R&lt;/code&gt; might be worth a read.&lt;/p&gt;&#xA;" OwnerUserId="18646" LastActivityDate="2019-08-13T21:27:39.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20894" PostTypeId="1" AcceptedAnswerId="20895" CreationDate="2019-08-14T07:51:14.597" Score="1" ViewCount="170" Body="&lt;p&gt;When I write first command I get the &quot;press enter or type command&quot;, even if I try to type second one it returns me to the editor mode, even though I would like to stay on console.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am new vim user. &lt;/p&gt;&#xA;" OwnerUserId="23391" LastActivityDate="2019-08-14T15:46:55.980" Title="&quot;Press ENTER or type command to continue&quot; -writing second command returns to the editor mode" Tags="|original-vim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20895" PostTypeId="2" ParentId="20894" CreationDate="2019-08-14T08:21:49.920" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I would like to stay on console&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You have to press &lt;code&gt;:&lt;/code&gt; then. Make sure you also read the corresponding Vim's help topic &lt;code&gt;:h hit-enter&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you can switch into Ex mode (&quot;console&quot;) permanently with &lt;code&gt;gQ&lt;/code&gt; (enter &lt;code&gt;:vi&lt;/code&gt; to get back).&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-08-14T15:46:55.980" LastActivityDate="2019-08-14T15:46:55.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20896" PostTypeId="1" CreationDate="2019-08-14T08:58:04.330" Score="3" ViewCount="1501" Body="&lt;p&gt;For example, lets say I have a line like:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Hello, this should be bold.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then is there any way to change one or more words to be bold, so it will appear on the screen as:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Hello, this should be &lt;strong&gt;bold&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For example, in some text editors I can select a word and press a &quot;bold&quot; button, and the text remains bold for the lifetime of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using gVim 8.0 on Ubuntu 18.04.&lt;/p&gt;&#xA;" OwnerUserId="23393" LastEditorUserId="51" LastEditDate="2019-08-14T17:17:19.463" LastActivityDate="2019-08-19T14:03:23.477" Title="Can I mark some piece of text as bold?" Tags="|formatting|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20897" PostTypeId="2" ParentId="20896" CreationDate="2019-08-14T10:35:44.520" Score="3" Body="&lt;p&gt;Well, it is not that simple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can come up with -- use syntax definitions. But this bold text you will create would be temporary, it will not be saved with your file like word processing software does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to the code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! RegionMakeBold()&#xA;  hi MyBold gui=bold&#xA;  let l_start = getpos(&quot;'&amp;lt;&quot;)[1]&#xA;  let l_end = getpos(&quot;'&amp;gt;&quot;)[1]&#xA;  let c_start = getpos(&quot;'&amp;lt;&quot;)[2]&#xA;  let c_end = getpos(&quot;'&amp;gt;&quot;)[2]+1&#xA;  execute 'syntax region MyBold start=/\%'.l_start.'l\%'.c_start.'c/ end=/\%'.l_end.'l\%'.c_end.'c/'&#xA;endfunc&#xA;&#xA;vnoremap &amp;lt;leader&amp;gt;b :&amp;lt;C-U&amp;gt;call RegionMakeBold()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Having this in your &lt;code&gt;.vimrc&lt;/code&gt; will allow you to make bold text out of visually selected blocks. Just select text, press &lt;code&gt;&amp;lt;leader&amp;gt;b&lt;/code&gt; and text should be bolded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dHe9q.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dHe9q.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will probably not work for the files with defined filetypes/syntax.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-08-14T10:35:44.520" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20898" PostTypeId="1" AcceptedAnswerId="20899" CreationDate="2019-08-14T12:22:24.800" Score="21" ViewCount="3869" Body="&lt;p&gt;Many text files can be opened at once using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim *txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know I can use &lt;code&gt;:&amp;lt;int&amp;gt;n&lt;/code&gt; to move forward &lt;code&gt;&amp;lt;int&amp;gt;&lt;/code&gt; files, but I don't know how to get to the last opened file.  So far I've tried &lt;code&gt;:1000n&lt;/code&gt; to intentionally overshoot but that gives the error &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E165: Cannot go beyond last file&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From there I just resort to a binary search trying to get to the end, which takes a while, i.e., &lt;code&gt;:500n&lt;/code&gt;, &lt;code&gt;:250n&lt;/code&gt;, &lt;code&gt;125n&lt;/code&gt;, ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I get to the last opened file in vim?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="3209" LastActivityDate="2019-08-15T08:26:09.087" Title="Go to last file in vim" Tags="|multiple-files|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20899" PostTypeId="2" ParentId="20898" CreationDate="2019-08-14T12:36:51.280" Score="29" Body="&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/editing.txt.html#%3Alast&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:last&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :last&lt;/code&gt; for more details. You might be interested in the other commands around it for managing files in &lt;code&gt;:args&lt;/code&gt; as well.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-14T12:36:51.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20900" PostTypeId="1" CreationDate="2019-08-15T03:12:04.437" Score="2" ViewCount="254" Body="&lt;p&gt;I have an error report where often the known errors are in the top few thousand lines, formatting issue rather than quantity unfortunately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to run &lt;code&gt;:g/pattern/&lt;/code&gt; from the end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know &lt;code&gt;:g/pattern/m0&lt;/code&gt; reverses the file which is mainly the same thing but if I don't put it back to how it was the line references are wrong when I query the error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;$,1g/pattern/&lt;/code&gt; but got &lt;code&gt;Backwards range given, Ok to swap (y/n)?&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Selecting n aborts the command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this achievable?&lt;/p&gt;&#xA;" OwnerUserId="1313" LastActivityDate="2019-08-17T11:15:41.863" Title="Is it possible to use a reverse range in global search" Tags="|global-command|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20901" PostTypeId="1" AcceptedAnswerId="20902" CreationDate="2019-08-15T03:42:08.357" Score="1" ViewCount="823" Body="&lt;p&gt;I am coming from statically types languages, but I will have to be using python for the next few years and I want to get my setup as smooth as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I am using vim-jedi, and deoplete-jedi for python autocompletion. It's a dynamic language, so static analysis is not as good as it is for static languages and I find myself having to google library docs often which is really REALLY annoying. For example...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from matplotlib import pyplot as plt&#xA;&#xA;# jedi will complete the next lines subplot function&#xA;fig, ax = plt.subplots()&#xA;&#xA;# on the instantiated class I get no autocompletion whatsoever, if I want to see the methods, I have to google docs&#xA;ax.set_title('...')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to be able to see the instantiated class methods without having to go outside of vim. The best would be...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If I could get the method autocompletion to work&lt;/li&gt;&#xA;&lt;li&gt;If I could pull up the docs for that class (vim-jedi, will pull up docs on the subplot method, but then i'll have to chase down what it returns, etc which is probably harder than just googling so I need a faster way to get to it)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Does anyone know if there is a way to accomplish what I want, or do I just have to leave and google everything when I need to see methods?&lt;/p&gt;&#xA;" OwnerUserId="13719" LastActivityDate="2019-08-15T03:58:39.323" Title="getting vim to autocomplete python methods" Tags="|autocompletion|filetype-python|plugin-jedi-vim|plugin-deoplete|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20902" PostTypeId="2" ParentId="20901" CreationDate="2019-08-15T03:58:39.323" Score="2" Body="&lt;p&gt;I have had moderate success with &lt;a href=&quot;https://github.com/fs111/pydoc.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;pydoc.vim&lt;/a&gt; for documentation; it can be helpful to use a virtualenv/run &lt;code&gt;setup.py develop&lt;/code&gt;, but you may still have to point it at the right python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I’ve also had moderate success with tags (I use universal ctags and &lt;a href=&quot;https://github.com/benknoble/Dotfiles/tree/master/links/git_template/hooks&quot; rel=&quot;nofollow noreferrer&quot;&gt;these hooks&lt;/a&gt; to keep them up to date). With tags, I can quickly jump to the source and read a docstring. Occasionally it sends me to my tests instead of the source, so I need to use &lt;code&gt;g&amp;lt;C-]&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven’t used it, but &lt;a href=&quot;https://kite.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;kite&lt;/a&gt; may work for you. They have a vim plugin as well. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-08-15T03:58:39.323" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20903" PostTypeId="1" CreationDate="2019-08-15T07:24:13.607" Score="1" ViewCount="122" Body="&lt;p&gt;For some reason, gvim is adding one extra pixel of spacing after each character. It almost seems similar to &lt;a href=&quot;https://vi.stackexchange.com/questions/13432/gvim-looks-terrible-on-my-redhat-unable-to-change-font&quot;&gt;this question&lt;/a&gt;, but in my case gvim does use the correct font. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I compared the same font in my terminal and gvim (see below, top = terminal, bottom = gvim, just for testing with an empty &lt;code&gt;.vimrc&lt;/code&gt; file), the individual characters are identical (same font/width/height/..), but after each character there is an additional pixel of spacing. Any idea why this is happening and how I can fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Original size:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cLOVn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cLOVn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Enlarged:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dAspK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dAspK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17805" LastActivityDate="2019-08-15T07:24:13.607" Title="gvim adds one extra pixel spacing after each character?" Tags="|gvim|font|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20905" PostTypeId="1" CreationDate="2019-08-15T10:11:19.410" Score="2" ViewCount="58" Body="&lt;p&gt;Basically what I want is a PyCharm-like completion:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If there is only whitespace, insert &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If pum is visible and nothing is selected, complete with first, otherwise choose the selected word/function/snippet.&lt;/li&gt;&#xA;&lt;li&gt;I there's any other character, go right.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Additional points:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Filling text with selected option from pum should be made only if I accept it. &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; should discard completion.&lt;/li&gt;&#xA;&lt;li&gt;I'd like to have parentheses added if I selected class or function. If the function/class requires no arguments, place cursor after closing parentheses.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I tried getting it to work with deoplete on vim but neovim and any other plugins are also welcome. &lt;/p&gt;&#xA;" OwnerUserId="23451" LastActivityDate="2019-08-15T10:11:19.410" Title="How to get this tab/autocompletion setup?" Tags="|key-bindings|autocompletion|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20906" PostTypeId="1" CreationDate="2019-08-15T10:14:53.503" Score="7" ViewCount="656" Body="&lt;p&gt;I have a project consisting of files that Vim doesn't recognize by default, but has support for highlighting and indentation. I would like to have a &lt;code&gt;vimrc&lt;/code&gt; file or a &lt;code&gt;vimmodeline&lt;/code&gt; (or whatever similar) whose scope is similar to that of &lt;code&gt;.gitignore&lt;/code&gt; to Git, such that it'll apply to all files under the directory it's in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are too many files to handle so it's not practical to append a mode line to each one.&lt;/p&gt;&#xA;" OwnerUserId="16096" LastActivityDate="2019-08-16T00:02:00.157" Title="Is there a way to make some modeline that applies to all files in a directory, recursively?" Tags="|vimrc|modeline|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20907" PostTypeId="2" ParentId="5028" CreationDate="2019-08-15T23:27:01.977" Score="0" Body="&lt;p&gt;Just updating the answers to this question, as I encountered this annoyance and I found a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit &lt;code&gt;~/.vim/bundle/tcomment_vim/autoload/tcomment.vim&lt;/code&gt; (line ~152):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                &quot;\     '-': '&amp;amp;#45;',&#xA;                &quot;\     '&amp;amp;': '&amp;amp;#38;',&#xA;                \     '-': '-',&#xA;                \     '&amp;amp;': '&amp;amp;',&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I.e., simply replace &lt;code&gt;-&lt;/code&gt; with &lt;code&gt;-&lt;/code&gt; ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Restart Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Details here: &lt;a href=&quot;https://github.com/tomtom/tcomment_vim/issues/253&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tomtom/tcomment_vim/issues/253&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GbTT6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GbTT6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10749" LastActivityDate="2019-08-15T23:27:01.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20908" PostTypeId="2" ParentId="20906" CreationDate="2019-08-16T00:02:00.157" Score="6" Body="&lt;p&gt;There are a few options for you, depending on what exact settings you'd like to tweak, how you'd like to manage them and whether you're worried about untrusted settings.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Use &quot;editorconfig&quot;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If the kinds of settings you would like to set are related to indentation style, tab size, file format and charset, then you might want to look into &lt;a href=&quot;https://editorconfig.org/&quot; rel=&quot;noreferrer&quot;&gt;&quot;editorconfig&quot;&lt;/a&gt;, which is a cross-editor standard to specify this kind of settings in a specific project, and have all editors follow that configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;editorconfig&quot; specification allows projects to request different settings depending on file extensions or names within the project. (So you can have Makefiles using TABs, your Python scripts using 4 spaces and your shell scripts using 2 spaces for indentation.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a plug-in to use &quot;editorconfig&quot; in Vim. The official website provides one, but personally I'd recommend &lt;a href=&quot;https://github.com/sgur/vim-editorconfig&quot; rel=&quot;noreferrer&quot;&gt;sgur/vim-editorconfig&lt;/a&gt;, which is written in pure Vimscript, so you don't need to worry about external dependencies too much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &quot;editorconfig&quot; aims at cross-editor compatibility, it's quite limited in what it does, so if you want is consistent whitespace, file format (DOS vs. Unix) and encoding (Unicode utf-8, etc.), then &quot;editorconfig&quot; is for you. Otherwise, maybe not.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;An &lt;code&gt;autocmd&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Second choice is to manage project settings from your actual vimrc. If you have a single project, or at most a handful, that need this kind of setup, then that's possibly an option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to do that, use &lt;code&gt;:autocmd&lt;/code&gt;, looking for events &lt;code&gt;BufRead&lt;/code&gt; and &lt;code&gt;BufNewFile&lt;/code&gt; and use a pattern that matches files under your project tree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Always put your &lt;code&gt;:autocmd&lt;/code&gt;s inside an &lt;code&gt;:augroup&lt;/code&gt;, since then they won't be duplicated whenever you &lt;code&gt;:source&lt;/code&gt; your vimrc again.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup myproject&#xA;  autocmd!&#xA;  autocmd BufRead,BufNewFile ~/myproject/* set ft=myproject&#xA;  autocmd BufRead,BufNewFile ~/myproject/*.py set ft=mypython&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will set the filetype to &lt;code&gt;mypython&lt;/code&gt; for all the files with the &lt;code&gt;py&lt;/code&gt; extension in your project, and the &lt;code&gt;myproject&lt;/code&gt; filetype for all other files under that project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#file-pattern&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help file-pattern&lt;/code&gt;&lt;/a&gt; for more details in how you can specify the matching pattern for the &lt;code&gt;BufRead&lt;/code&gt; and &lt;code&gt;BufNewFile&lt;/code&gt; events. In particular, the &lt;code&gt;*&lt;/code&gt; will match path separators (&lt;code&gt;/&lt;/code&gt;), so this will work recursively in subdirectories of your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's likely that you might have multiple &lt;code&gt;autocmd&lt;/code&gt;s fighting for the filetype of a specific type (for example, Vim default runtime will try to make the &lt;code&gt;*.py&lt;/code&gt; files use the &lt;code&gt;python&lt;/code&gt; filetype.) Which one will win will depend on a few factors, including ordering. Typically the rules in your vimrc will be the earliest ones, but that's no longer the case if you source your vimrc and recreate those rules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have three options to set the filetype:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;set filetype=mypython&lt;/code&gt;: This will &lt;em&gt;always&lt;/em&gt; set the filetype, at that point. It will only be lost if it's overwritten by another &lt;code&gt;set filetype=...&lt;/code&gt; command. This is what you should typically use in your setup if you want to enforce your filetype.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;setfiletype mypython&lt;/code&gt;: This will set the filetype, but &lt;em&gt;only&lt;/em&gt; if it was unset at that point. This is typically what Vim's basic runtime and also plugins will use, so if you make your own setting, it will be stronger than these. (So, if all plugins are behaving correctly, you should be good!)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;setfiletype FALLBACK mypython&lt;/code&gt;: This will set the filetype, only if it's still unset. But if there's another &lt;code&gt;setfiletype&lt;/code&gt; the latter will override it. So this is a good way to set a fallback filetype, if the file doesn't get one in a different way.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You probably want either option 1 (if you want to control the final filetype), or option 3 (if you just want a fallback, for files that don't otherwise get a filetype.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, once you set filetypes, you can use the normal per-filetype configuration to set specific options and configure keybindings and commands for them. Just create the appropriate scripts under &lt;code&gt;ftplugin/&lt;/code&gt; in your &lt;code&gt;~/.vim/&lt;/code&gt; directory, named after your filetype, and add your &lt;code&gt;setlocal&lt;/code&gt;, &lt;code&gt;nnoremap &amp;lt;buffer&amp;gt;&lt;/code&gt;, etc. commands there.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Using &lt;code&gt;'exrc'&lt;/code&gt; and &lt;code&gt;'secure'&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You could enable the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27exrc%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'exrc'&lt;/code&gt;&lt;/a&gt; option in your vimrc. If you do so, make sure you also enable &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27secure%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'secure'&lt;/code&gt;&lt;/a&gt;, which typically needs to be set at the end of the vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set exrc&#xA;set secure&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will instruct Vim to read a vimrc file (&lt;code&gt;.vimrc&lt;/code&gt; or &lt;code&gt;_vimrc&lt;/code&gt;) from your &lt;em&gt;current&lt;/em&gt; directory. So you could use this to set a per-project vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you always cd to the top of the project, and refer to files in subdirectories by their full path, then a single &lt;code&gt;.vimrc&lt;/code&gt; at the top of the project might be enough. If you typically cd into subdirectories, you might want to keep symlinks to the &lt;code&gt;.vimrc&lt;/code&gt; at the top from subdirectories (which is not great, but possibly something you could automate.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many drawbacks with this solution, such as still having to solve subdirectories, having to be inside the project tree when you start Vim and also security concerns about sourcing &lt;code&gt;.vimrc&lt;/code&gt; files from the tree (you're setting &lt;code&gt;'exrc'&lt;/code&gt; globally, so Vim will try to open &lt;em&gt;any&lt;/em&gt; &lt;code&gt;.vimrc&lt;/code&gt; you happen to stumble upon.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a terrible idea. Don't go with this one!&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Roll your own&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Finally, you could roll your own solution. That might take some Vimscript to do, but you can probably come up with something that fits your exact requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can probably get some inspiration from &quot;editorconfig&quot; in searching for the config file up the tree, and maybe its basic file format. (Perhaps just extend it for whatever else you might want to configure? Perhaps so that you can set a &lt;code&gt;'filetype'&lt;/code&gt;?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would take a bit of work, but I think the idea has potential.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully one of these options will be close enough to what you'd like.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-16T00:02:00.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20909" PostTypeId="2" ParentId="20900" CreationDate="2019-08-16T00:56:02.663" Score="2" Body="&lt;p&gt;The simplest idea is to filter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:v/pattern/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then &lt;code&gt;u&lt;/code&gt;ndo when you want the whole file back. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-08-16T00:56:02.663" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20910" PostTypeId="2" ParentId="20883" CreationDate="2019-08-16T08:40:54.107" Score="1" Body="&lt;p&gt;what worked for me was to use langmap.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set langmap=jklöJKLé;hjlkHJKL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this remaps the keys for all commands&lt;/p&gt;&#xA;" OwnerUserId="23379" LastActivityDate="2019-08-16T08:40:54.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20911" PostTypeId="1" AcceptedAnswerId="20918" CreationDate="2019-08-16T14:16:47.073" Score="3" ViewCount="1906" Body="&lt;p&gt;I'd like to find a regex that matches Setex-style headings like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;My Heading&#xA;==========&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The headings text and the underline need to be of the same length. However, I don't know how to specify a regex that matches the above, but not&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;No Heading&#xA;====&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to require two groups of the match (first line and second line) to have the same number of characters?&lt;/p&gt;&#xA;" OwnerUserId="21417" LastActivityDate="2019-08-17T18:45:11.387" Title="regex that requires that two matches have the same length" Tags="|regular-expression|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20913" PostTypeId="1" AcceptedAnswerId="20920" CreationDate="2019-08-16T15:57:35.393" Score="1" ViewCount="449" Body="&lt;p&gt;I want to fold in markdown using &lt;a href=&quot;https://github.com/vim/vim/blob/89bcfda6834aba724d12554a34b9ed49f5789fd5/runtime/ftplugin/markdown.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;the built in markdown plugin&lt;/a&gt; that I believe should come with the version of vim I have (&lt;code&gt;Vi IMproved 8.1 (2018 May 18, compiled Apr 23 2019 20:02:08)&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am struggling to make the answers in &lt;a href=&quot;https://vi.stackexchange.com/questions/9543/how-to-fold-markdown-using-the-built-in-markdown-mode&quot;&gt;the other question on this topic&lt;/a&gt; work for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no plugins installed, and I made my &lt;code&gt;.vimrc&lt;/code&gt; the most minimal it can be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:markdown_folding = 1&#xA;let g:markdown_fenced_languages = ['vim', 'yaml', 'python', 'bash=sh', 'sql', 'git', 'make', 'html', 'css', 'javascript', 'js=javascript', 'json=javascript', 'xml']&#xA;syntax enable&#xA;set nocompatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this, if I open a markdown file, I see that it is highlighted correctly, and &lt;code&gt;:set ft?&lt;/code&gt; returns &lt;code&gt;markdown&lt;/code&gt;. However, &lt;code&gt;:set foldmethod?&lt;/code&gt; always returns &lt;code&gt;manual&lt;/code&gt;, and &lt;code&gt;zc&lt;/code&gt; returns &lt;code&gt;E490: fold not found&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea what I'm doing wrong, and I've run out of things to try. The only thing I can think of is that &lt;code&gt;if has(&quot;folding&quot;)&lt;/code&gt; from that built in plugin must be returning false, but I don't know what that syntax is or how to enable folding.&lt;/p&gt;&#xA;" OwnerUserId="17205" LastEditorUserId="17205" LastEditDate="2019-08-16T17:23:12.657" LastActivityDate="2019-08-17T03:02:03.273" Title="Enable Expr Folding in Markdown" Tags="|folding|filetype-markdown|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20914" PostTypeId="1" AcceptedAnswerId="20922" CreationDate="2019-08-16T20:54:38.403" Score="1" ViewCount="120" Body="&lt;p&gt;I use ',' as leader, so when I f/t and I want to go to previous hit, I cannto use ','&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using #:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap # ,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My mapping shows up (I think), :map # shows this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n #      * ,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it does nothing. Something obvious I am missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks&lt;/p&gt;&#xA;" OwnerUserId="590" LastEditorUserId="590" LastEditDate="2019-08-17T11:40:25.873" LastActivityDate="2019-08-17T11:40:25.873" Title="how to map # to , (when , is my leader) while using vim-sneak" Tags="|key-bindings|leader|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20917" PostTypeId="1" CreationDate="2019-08-17T00:16:53.870" Score="1" ViewCount="1046" Body="&lt;p&gt;There is VIM's default bar below my Airline's status bar, which causes file information to be viewed twice (as shown in the image). How can I move my airline's bar to the bottom? I have tried adding &lt;code&gt;set noshowmode&lt;/code&gt; but it didn't slove my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YW4Mw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YW4Mw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15848" LastActivityDate="2022-12-10T12:26:53.883" Title="How to move airline status bar to the bottom of the editor?" Tags="|statusline|plugin-airline|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20918" PostTypeId="2" ParentId="20911" CreationDate="2019-08-17T00:54:54.787" Score="4" Body="&lt;p&gt;While you could use a regular expression to identify such lines with a specific number of characters, e.g. &lt;code&gt;\v^%(.){6}\n%(\=){6}&lt;/code&gt;, there's no way to do so for an arbitrary number of characters with Vim regexes.&lt;sup&gt;1&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully you'll be able to use a Vimscript solution. For example this one liner will save the line numbers of all line pairs that match your criteria:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^[=]\+$/ if strlen(getline(line(&quot;.&quot;) - 1)) == strlen(getline(&quot;.&quot;)) | call add(b:matches, line(&quot;.&quot;) - 1) | endif &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It requires existence of a list &lt;code&gt;b:matches&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This one is a little easier to read and initializes the list and prints its contents...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:matchlines = []&#xA;g/^[=]\+$/ if strlen(getline(line(&quot;.&quot;) - 1)) == strlen(getline(&quot;.&quot;))&#xA;    call add(b:matches, line(&quot;.&quot;) - 1)&#xA;endif &#xA;echo b:matchlines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should be easy to tweak this as needed (e.g. if you wanted to save the actual matched text instead of line numbers). If you need some help with such a change let me know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; &lt;sub&gt;&lt;i&gt;For those hungry for some red meat here's @perelo's comment on why this is so...&lt;/i&gt; Actually this is a well-known limitation of theoretical regular expressions. Although pattern matching engines allow more expressivity than th. R.E. (e.g. backreferences with (...)), they cannot match strings as a^nb^n for any n. In your case, 'a' is like . and 'b' is =. Intuitivelly, R.E. are like DFA, so they cannot count dynamically. Patterns such as {n} are obtained by adding O(n) states to the corresponding DFA. This is why we cannot syntactically check a program with a single regex : matching parentheses are like (^n )^n.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-08-17T18:45:11.387" LastActivityDate="2019-08-17T18:45:11.387" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="20919" PostTypeId="2" ParentId="20917" CreationDate="2019-08-17T02:08:57.697" Score="1" Body="&lt;p&gt;That's not really possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last line is used not only to display messages and information, but also to enter Ex commands (the commands starting with a colon, such as &lt;code&gt;:w&lt;/code&gt;, &lt;code&gt;:q&lt;/code&gt;, &lt;code&gt;:e &lt;i&gt;filename&lt;/i&gt;&lt;/code&gt;, etc.), also where you can type a search pattern if you start a search using &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, that line is also used to display messages, such as error messages when you try to save a file but don't have permissions to write to it, or when you're searching for a term that's not present in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fact that the information in the message line is &lt;em&gt;occasionally&lt;/em&gt; duplicating some information that's in the airline bar doesn't mean it should be gotten rid of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;'showmode'&lt;/code&gt; option, when set, causes Vim to display &lt;code&gt;--INSERT--&lt;/code&gt; in the message line when in insert mode. That's indeed a duplicated information from the one set up by the vim-airline plug-in, so the plug-in will by default disable that option to avoid that particular case of duplication.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-17T02:08:57.697" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20920" PostTypeId="2" ParentId="20913" CreationDate="2019-08-17T03:02:03.273" Score="1" Body="&lt;p&gt;TL;DR: You should include the command &lt;code&gt;filetype plugin on&lt;/code&gt; in your vimrc. You most probably want &lt;code&gt;filetype plugin indent on&lt;/code&gt; to enable all filetype-related types of plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim has a handful of filetype-related features, and they can be enabled and disabled individually using the &lt;code&gt;:filetype&lt;/code&gt; command. (Technically, syntax highlighting is also dependent on filetypes, but you use the &lt;code&gt;:syntax&lt;/code&gt; command to enable or disable it.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:filetype&lt;/code&gt; command can be used to enable filetype detection, which is a pre-requisite for all the other features (since the other features depend on knowing &lt;em&gt;which&lt;/em&gt; filetype to load plugins for.) Detection is enabled with &lt;code&gt;filetype on&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then there are the &lt;code&gt;indent&lt;/code&gt; plugins (enabled with &lt;code&gt;filetype indent on&lt;/code&gt;), which typically set &lt;code&gt;'indentexpr'&lt;/code&gt; to set up rules for automatic indentation for that particular filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally there's the &lt;code&gt;plugin&lt;/code&gt; part, which enables loading Vim files from the &lt;code&gt;ftplugin/&lt;/code&gt; directory, such as the one &lt;code&gt;markdown.vim&lt;/code&gt; you identified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check whether filetype features are enabled with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you see &lt;code&gt;filetype detection:OFF  plugin:OFF  indent:OFF&lt;/code&gt;, that means it's disabled. (If you see &lt;code&gt;detection:ON&lt;/code&gt; but another feature is &lt;code&gt;OFF&lt;/code&gt;, it's not fully enabled either.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix that and enable all filetype features use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want that to be always the case, include that line in your vimrc.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-17T03:02:03.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20921" PostTypeId="1" CreationDate="2019-08-17T04:57:58.007" Score="1" ViewCount="243" Body="&lt;p&gt;When doing &lt;code&gt;&amp;lt;ESC&amp;gt;qq&lt;/code&gt; you can record a macro into the &lt;code&gt;q&lt;/code&gt; register (still in command mode though). How can I make &lt;code&gt;&amp;lt;ESC&amp;gt;qq&lt;/code&gt; go into insert mode right away (without having to type &lt;code&gt;i&lt;/code&gt;)? &lt;code&gt;map qq qqi&lt;/code&gt; will record and put me into insert mode, but I am unable to replay with &lt;code&gt;@@&lt;/code&gt; or &lt;code&gt;@q&lt;/code&gt;. The docs say you cannot use the &lt;code&gt;q&lt;/code&gt; command inside a macro, but it does not specify what happens in my case.&lt;/p&gt;&#xA;" OwnerUserId="23449" LastActivityDate="2019-08-17T04:57:58.007" Title="Vim go into insert mode when as a macro starts" Tags="|vimrc|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="20922" PostTypeId="2" ParentId="20914" CreationDate="2019-08-17T09:39:01.563" Score="0" Body="&lt;p&gt;You mentioned vim-sneak in your comments, and that's probably it here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim-sneak will try to map &lt;code&gt;,&lt;/code&gt;. It actually expects you might be using &lt;code&gt;,&lt;/code&gt; as a leader/localleader, it will check for whether you've mapped it and, if so, it will check for whether you've mapped &lt;code&gt;\&lt;/code&gt; to &lt;code&gt;,&lt;/code&gt; and use that instead. You can see the code doing that &lt;a href=&quot;https://github.com/justinmk/vim-sneak/blob/1.8.1/plugin/sneak.vim#L357&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you want to use &lt;code&gt;#&lt;/code&gt; instead, just map it directly to the &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mapping exposed by vim-plug:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap # &amp;lt;Plug&amp;gt;Sneak_,&#xA;omap # &amp;lt;Plug&amp;gt;Sneak_,&#xA;xmap # &amp;lt;Plug&amp;gt;Sneak_,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should be fine to add this to your vimrc (even though the plug-in actually gets loaded later on), but if you run into issues with that, consider creating a file named &lt;code&gt;~/.vim/after/plugin/*.vim&lt;/code&gt; and add those commands there instead, that will run after vim-sneak is loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use that file to remove any vim-sneak mappings from &lt;code&gt;,&lt;/code&gt; (if it happens to be adding any), if you intend to use it as a leader.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-17T09:39:01.563" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20923" PostTypeId="2" ParentId="20900" CreationDate="2019-08-17T11:15:41.863" Score="1" Body="&lt;p&gt;Use &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%3F&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;?&lt;/code&gt;&lt;/a&gt; to search backwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27wrapscan%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'wrapscan'&lt;/code&gt;&lt;/a&gt; is set (which is the default), you can use &lt;code&gt;?&lt;/code&gt; at the start of the file, and it will wrap to the end and continue the search from there, effectively finding the last occurrence of the pattern in the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there, you can use the &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#n&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;n&lt;/code&gt;&lt;/a&gt; command, repeatedly, to jump to the preceding occurrences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should allow you to easily find the lines containing a specific pattern at the end of a log file such as the one you describe.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-17T11:15:41.863" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20924" PostTypeId="1" AcceptedAnswerId="20926" CreationDate="2019-08-17T13:54:39.243" Score="4" ViewCount="2102" Body="&lt;p&gt;I have mapped my &lt;kbd&gt;F5&lt;/kbd&gt; key in vimrc file to run the code using the following command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map &amp;lt;F5&amp;gt; :!sh -xc 'cd &quot;/home/hashir/vscode/&quot; &amp;amp;&amp;amp; g++ test.cpp &amp;amp;&amp;amp; ./a.out&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is working well. But it only runs for &lt;code&gt;test.cpp&lt;/code&gt; file. I want to make it generic by inserting the name of my current file. Is there any way of doing this?&lt;/p&gt;&#xA;" OwnerUserId="15848" LastEditorUserId="1238" LastEditDate="2019-12-10T01:47:13.557" LastActivityDate="2019-12-10T01:47:13.557" Title="Get file name and directory in .vimrc file" Tags="|vimrc|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20925" PostTypeId="2" ParentId="20924" CreationDate="2019-08-17T14:05:44.177" Score="2" Body="&lt;p&gt;Use &quot;Ex special characters&quot; &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#cmdline-special&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h cmdline-special&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, &lt;code&gt;%&lt;/code&gt; is always replaced in normal Ex commands with the current buffer/file name as long as it's not escaped. So a simple drop-in replacement of &quot;test.cpp&quot; is all that's needed...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F5&amp;gt; :!sh -xc 'cd &quot;/home/hashir/vscode/&quot; &amp;amp;&amp;amp; g++ &quot;%&quot; &amp;amp;&amp;amp; ./a.out'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I corrected a couple omissions/typos in your mapping and use &quot;noremap&quot; as is recommended in almost all cases. Also, note quotes around &lt;code&gt;%&lt;/code&gt; which is best practice kind of thing with shell commands.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to plain &lt;code&gt;%&lt;/code&gt; there are a bunch of modifiers that can be appended that will do things like strip off the extension (&lt;code&gt;%:r&lt;/code&gt;) or force the name to be a full path (&lt;code&gt;%:p&lt;/code&gt;). See &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#filename-modifiers&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h filename-modifiers&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also a couple other special chars such as &lt;code&gt;#&lt;/code&gt; which will be replaced by the &quot;alternate&quot; file/buffer name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, if you wanted to use a plain &lt;code&gt;%&lt;/code&gt; in your shell command you'd have to escape it by preceding it with backslash &lt;kbd&gt;\&lt;/kbd&gt; as I alluded to before.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-08-17T14:14:39.313" LastActivityDate="2019-08-17T14:14:39.313" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20926" PostTypeId="2" ParentId="20924" CreationDate="2019-08-17T14:17:53.603" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;%&lt;/code&gt; to expand to the current filename.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3A%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :!&lt;/code&gt;&lt;/a&gt;, which goes into quite some level of detail about that!&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If &lt;code&gt;{cmd}&lt;/code&gt; contains &lt;code&gt;%&lt;/code&gt; it is expanded to the current file name.  Special characters are not escaped, use quotes to avoid their special meaning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!ls &quot;%&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note also that &lt;code&gt;:!&lt;/code&gt; will already run the command in a shell for you, so you don't really need a &lt;code&gt;sh -c '...'&lt;/code&gt; around it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reference to the file will be relative to the current directory, so using &lt;code&gt;cd&lt;/code&gt; here doesn't make much sense, since this will &lt;em&gt;only&lt;/em&gt; work in &lt;code&gt;~/vscode&lt;/code&gt;. I'll assume that's the case and I'll remove that as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;F5&amp;gt; :!set -x; g++ &quot;%&quot; &amp;amp;&amp;amp; ./a.out&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Vim also has powerful features for building software. Those can be most useful when compiling projects spanning hundreds of source code files, but you &lt;em&gt;could&lt;/em&gt; leverage them in your particular case too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They can be quite complex, so it might take a while to get the hang of them. You can start at &lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#%3Amake_makeprg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :make&lt;/code&gt;&lt;/a&gt;, though you might also try to find easier to digest tutorials about how to use &lt;code&gt;:make&lt;/code&gt; for your specific language, compiler, build system, etc.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-17T14:17:53.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20927" PostTypeId="1" AcceptedAnswerId="20932" CreationDate="2019-08-17T19:06:19.793" Score="2" ViewCount="144" Body="&lt;p&gt;I have two text files including steps, one is the main-file which has the entire steps and the other one is a sub-file has only part of steps. As follows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[main-file]&#xA;SeqMain.txt &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0001 K1G554   1  1 21-56 3  C- 2 1 0 0     0 D001&#xA;0002 K1H060   1  3 11-46 1 21-56 3 0 0 P   0&#xA;0003 K1G049   5  1 23-56 4  C- 4 1 0 0     0 D002&#xA;0004 K1H520   5  3 27-36 4 23-56 4 0 0 P   0&#xA;0005 K1G004  15  1 29-56 3  C- 6 1 0 0     0 D003&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[sub-file]&#xA;SeqSub.txt&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;001 000x K1G554  C- 2 1 AY-29 1&#xA;002 000y K1G049  C- 4 1 AY-19 1&#xA;003 000z K1G004  C- 6 1 AY-09 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I always have to modify the main-file to change the sequence of steps many times. Every time the main file was changed, the step numbers in the  sub-file needs to be updated too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how I edit them by using VIM:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.I sort the main-file by the column 46 &lt;code&gt;:sort/\%46&lt;/code&gt;, put the cursor at row3-column1 and blockwisely visual select &lt;code&gt;ctrl-v&lt;/code&gt; the row3-column1 to row6-column4 and yank &lt;code&gt;y&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0002 K1H060   1  3 11-46 1 21-56 3 0 0 P   0&#xA;0004 K1H520   5  3 27-36 4 23-56 4 0 0 P   0&#xA;0001 K1G554   1  1 21-56 3  C- 2 1 0 0     0 D001&#xA;0003 K1G049   5  1 23-56 4  C- 4 1 0 0     0 D002&#xA;0005 K1G004  15  1 29-56 3  C- 6 1 0 0     0 D003&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0001&#xA;0003&#xA;0005&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2.Then I open the sub-file &lt;code&gt;vsplit SeqSub.txt&lt;/code&gt;, put the cursor at row1-column4,  and paste what I just yanked on it &lt;code&gt;1vp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;001 0001 K1G554  C- 2 1 AY-29 1&#xA;002 0002 K1G049  C- 4 1 AY-19 1&#xA;003 0003 K1G004  C- 6 1 AY-09 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to write the steps above into a syntax file in vimscript or recording them &lt;code&gt;q&lt;/code&gt; that I can source the script to complete the steps. The function &lt;code&gt;execute normal! ...&lt;/code&gt; can do the same editting in normal mode. &#xA;But in visual mode it did't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does there any function for blockwise visual selection in vimscript? Or does anyone have a better solution to compare and update both files? &lt;/p&gt;&#xA;" OwnerUserId="23452" LastActivityDate="2019-08-19T07:19:53.433" Title="Is there a function for blockwise visual selection in Vimcript?" Tags="|visual-block|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20928" PostTypeId="1" AcceptedAnswerId="20931" CreationDate="2019-08-17T21:57:16.303" Score="1" ViewCount="54" Body="&lt;p&gt;I have the following lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd filetype tex nmap &amp;lt;d-p-1&amp;gt;       cha&#xA;autocmd filetype tex nmap &amp;lt;d-p-2&amp;gt;       sec&#xA;autocmd filetype tex nmap &amp;lt;d-p-3&amp;gt;       sub&#xA;autocmd filetype tex nmap &amp;lt;d-p-4&amp;gt;       ssub&#xA;autocmd filetype tex nmap &amp;lt;d-p-5&amp;gt;       par&#xA;autocmd filetype tex nmap &amp;lt;d-p-6&amp;gt;       subp&#xA;autocmd filetype tex nmap &amp;lt;d-s-p-0&amp;gt; part*&quot;&#xA;autocmd filetype tex nmap &amp;lt;d-s-p-1&amp;gt;     &#xA;autocmd filetype tex nmap &amp;lt;d-s-p-2&amp;gt; &#xA;autocmd filetype tex nmap &amp;lt;d-s-p-3&amp;gt; &#xA;autocmd filetype tex nmap &amp;lt;d-s-p-4&amp;gt; &#xA;autocmd filetype tex nmap &amp;lt;d-s-p-5&amp;gt; &#xA;autocmd filetype tex nmap &amp;lt;d-s-p-6&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I selected the last words in the first 6 lines using visual-block, tried to copy and paste as block(using &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;P&lt;/code&gt;, and it just creates lines like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    autocmd filetype tex nmap &amp;lt;d-p-1&amp;gt;       cha&#xA;    autocmd filetype tex nmap &amp;lt;d-p-2&amp;gt;       sec&#xA;    autocmd filetype tex nmap &amp;lt;d-p-3&amp;gt;       sub&#xA;    autocmd filetype tex nmap &amp;lt;d-p-4&amp;gt;       ssub&#xA;    autocmd filetype tex nmap &amp;lt;d-p-5&amp;gt;       par&#xA;    autocmd filetype tex nmap &amp;lt;d-p-6&amp;gt;       subp&#xA;    autocmd filetype tex nmap &amp;lt;d-s-p-0&amp;gt; part*&quot;&#xA;    autocmd filetype tex nmap &amp;lt;d-s-p-1&amp;gt;     &#xA;cha&#xA;sec&#xA;sub&#xA;ssub&#xA;par&#xA;subp&#xA;    autocmd filetype tex nmap &amp;lt;d-s-p-2&amp;gt; &#xA;    autocmd filetype tex nmap &amp;lt;d-s-p-3&amp;gt; &#xA;    autocmd filetype tex nmap &amp;lt;d-s-p-4&amp;gt; &#xA;    autocmd filetype tex nmap &amp;lt;d-s-p-5&amp;gt; &#xA;    autocmd filetype tex nmap &amp;lt;d-s-p-6&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the state of register after copying&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gemKC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gemKC.png&quot; alt=&quot;after copying&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using VimR and have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard+=unnamed&#xA;set go+=a&#xA;set cpoptions+=y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why hasn't it worked?!?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;update: It behaves the same in neovim binary(I am on macos). with &lt;code&gt;-u NONE&lt;/code&gt; it works as intended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-08-17T22:36:17.530" LastActivityDate="2019-08-18T06:44:16.967" Title="visual block copying didn't work" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20929" PostTypeId="1" AcceptedAnswerId="20933" CreationDate="2019-08-17T22:19:19.737" Score="2" ViewCount="175" Body="&lt;p&gt;I have a funny problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following symlink in /Users/eyalkarni/ AKA ~&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.vimrc -&amp;gt; /Users/eyalkarni/vimpy3/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;vimpy3 is a git repository.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I opened  ~/.vimrc in neovim and now I can't use git-fugitive because it doesn't know it is inside git repo. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, naturally, I tried &lt;code&gt;:bd&lt;/code&gt; and going into ~/vimpy3 and open it from there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It didn't work either. It keeps calling it ~/.vimrc , thinking it is in ~. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess &lt;code&gt;:bw&lt;/code&gt; will work, but I also have some marks in the file that I don't want to lose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to overcome this? &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-08-17T22:39:13.287" LastActivityDate="2019-08-18T15:32:31.610" Title="fun with symlink and buffers" Tags="|buffers|plugin-fugitive|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20931" PostTypeId="2" ParentId="20928" CreationDate="2019-08-18T06:44:16.967" Score="3" Body="&lt;p&gt;The problem is with your clipboard setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard+=unnamed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I urge you to not use system clipboard as the default clipboard in Vim, it has multiple problems, including the problem you're facing right now. It's not a unknown matter that system clipboard doesn't handle block-style-texts, it only knows lines of texts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another example of problems that arise with using system clipboard as the default clipboard in Vim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use clipboard in a recording, and you have &lt;code&gt;set clipboard+=unnamed&lt;/code&gt;, your macro wouldn't run, it will exit with an error. There are many more. When you're doing much back-and-forth between system and Vim, just do manually &lt;code&gt;:set clipboard=unnamed&lt;/code&gt;, and return to normal behavior afterwards. It would save you much hassle.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-08-18T06:44:16.967" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20932" PostTypeId="2" ParentId="20927" CreationDate="2019-08-18T08:12:57.510" Score="0" Body="&lt;p&gt;I get the gist of what you want to do now. First, sourcing a script is not a great way to manage reusable code. That's what functions are for. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for what you have so far you are unnecessarily putting &lt;code&gt;:execute&lt;/code&gt; in front of everything when you're already in an Ex execution context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a function that you can put in your vimrc and call with &lt;code&gt;:call JoinColumn()&lt;/code&gt;. This is adapted from the code in your comment but has some necessary or recommended changes. And you may need to do some tuning of your own once you start testing (esp. the last line...your original command doesn't do what you describe).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! JoinColumn()&#xA;    sort /\%46c/&#xA;    &quot; yank visual block selection into reg 'a'&#xA;    norm! 2j^V^V2j3l&quot;ay&#xA;    vsplit SeqSub.txt&#xA;    &quot; paste reg 'a' into desired location&#xA;    norm! 1G3l&quot;ap&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that where you see &lt;code&gt;^V^V&lt;/code&gt; is where you should type in the double &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; that we talked about. The first Ctrl-V is a special key that allows you to embed a control character in text. We're using another Ctrl-V here but the second key entered could be whatever control character you need. After you enter this you should see just a single &lt;code&gt;^V&lt;/code&gt;. See &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-V&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h i_CTRL-V&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/insert.txt.html#ins-special-keys&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h ins-special-keys&lt;/code&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As an aside, various shell commands could do the same operation. Following is an example of such a command sequence in a form that you'd run in Vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!join -1 13 -2 1 -o 2.1,1.1,2.3,2.4,2.5,2.6,2.7,2.8 &amp;lt;(sed -E 's/D([0-9]+)$/\1/' # | sort -k13) %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before you run you should have both files loaded with the file to modify in the current buffer and the other file as the &quot;alternate&quot; (i.e. hitting &lt;a href=&quot;https://vimhelp.org/editing.txt.html#CTRL-6&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;^&lt;/kbd&gt;&lt;/a&gt; should jump between the two files).&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-08-19T07:19:53.433" LastActivityDate="2019-08-19T07:19:53.433" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20933" PostTypeId="2" ParentId="20929" CreationDate="2019-08-18T15:32:31.610" Score="2" Body="&lt;p&gt;I don't know how vim-fugitive checks if the current file is under a git repository, but for this specific case you can follow the following steps to get the job done:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:file &amp;lt;path/to/file&amp;gt;&#xA;:edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;code&gt;:file &amp;lt;path/to/file&amp;gt;&lt;/code&gt; changes the associated file of the current buffer to the provided file and &lt;code&gt;:edit&lt;/code&gt; reloads the current buffer. A buffer is the in-memory text of a file. So, what you see on the window/split is actually a buffered memory (hence the name &lt;code&gt;buffer&lt;/code&gt;). When you do &lt;code&gt;:write&lt;/code&gt;, you save the current buffered memory to the associated file and when you do &lt;code&gt;:edit&lt;/code&gt;, you reload the current buffered memory with the content of the associated file. So, when you do &lt;code&gt;:file &amp;lt;path/to/file&amp;gt;&lt;/code&gt; you change the associated file of the current buffer and henceforward do any interaction with that file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, when you changed the associated file and reloaded it, the buffer checked that it's in a git repository and launched vim-fugitive instance; or so I conjecture since I already got the confirmation that this  solution worked from the OP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out &lt;code&gt;:h file_f&lt;/code&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-08-18T15:32:31.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20934" PostTypeId="2" ParentId="19119" CreationDate="2019-08-18T16:29:22.223" Score="1" Body="&lt;p&gt;You will need to run the underlying FZF functions to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you intend to adapt Files to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:Files probably calls fzf#run at some point. Find that call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sink argument of fzf#run (and grep and others) would be a function that says what to do with the selected string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call fzf#run({'source': uniq(reverse(b:inserts)),'sink':function('PInsert'),'options': '-m'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The source is the list of lines to select from. And PInsert would insert the selection to the buffer. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PInsert(item)&#xA;    let @z=a:item&#xA;    norm &quot;zp&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you just need to create a custom command and use PInsert as the sink argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-08-18T16:29:22.223" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20935" PostTypeId="1" CreationDate="2019-08-19T03:42:12.467" Score="1" ViewCount="51" Body="&lt;p&gt;I used the &lt;code&gt;MatchParen&lt;/code&gt; to match the parenthesis while coding C++ projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my config in &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi MatchParen cterm=underline ctermbg=NONE ctermfg=DarkCyan&#xA;set matchpairs+=&amp;lt;:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it doesn't work very well when &lt;code&gt;cout&lt;/code&gt; and &lt;code&gt;cin&lt;/code&gt; appear together. Here is an example:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Vu7ib.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Vu7ib.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you see, the two angle brackets are matched, which is not what we expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way or some vim-plugin to avoid this?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2019-08-19T03:47:48.270" LastActivityDate="2019-08-19T03:47:48.270" Title="matchparen made a wrong match on angle brackets" Tags="|plugin-system|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20936" PostTypeId="1" AcceptedAnswerId="20937" CreationDate="2019-08-19T06:13:39.600" Score="3" ViewCount="249" Body="&lt;p&gt;How to make vim respect the enumerated list indentation also on consecutive, not only on the second line? I.e. so that pressing &lt;code&gt;gq&lt;/code&gt; on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. A long line reaching near &amp;amp;tw.&#xA;following text on the second line.&#xA;the &quot;consecutive&quot; line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would yield:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. A long line reaching near &amp;amp;tw.&#xA;   following text on the second&#xA;   line. the &quot;consecutive&quot; line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and not like it is by default, currently in my vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. A long line reaching near &amp;amp;tw.&#xA;   following text on the second&#xA;line. the &quot;consecutive&quot; line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;?&lt;/p&gt;&#xA;" OwnerUserId="23463" LastEditorUserId="11054" LastEditDate="2019-08-19T06:58:06.273" LastActivityDate="2019-08-19T06:58:06.273" Title="Configure formatting to indent all lines of a numbered list (enum-list)?" Tags="|formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20937" PostTypeId="2" ParentId="20936" CreationDate="2019-08-19T06:19:49.733" Score="1" Body="&lt;p&gt;You just need to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set fo+=n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That'll add a flag to &quot;recognize numbered lists&quot; to &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27formatoptions%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'formatoptions'&lt;/code&gt;&lt;/a&gt; (&lt;code&gt;'fo'&lt;/code&gt; for short).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the details/limitations:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This actually uses the 'formatlistpat' option, thus any kind of list can be used.  The indent of the text after the number is used for the next line.  The default is to find a number, optionally followed by '.', ':', ')', ']' or '}'.  Note that 'autoindent' must be set too.  Doesn't work well together with &quot;2&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Excerpted from &lt;a href=&quot;https://vimhelp.org/change.txt.html#fo-table&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;fo-table&lt;/code&gt;&lt;/a&gt; which has the complete list of &lt;code&gt;'formatoptions'&lt;/code&gt; flags.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-08-19T06:41:48.797" LastActivityDate="2019-08-19T06:41:48.797" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20938" PostTypeId="1" AcceptedAnswerId="20939" CreationDate="2019-08-19T09:33:57.677" Score="1" ViewCount="53" Body="&lt;p&gt;I want to move some scripts that I have made to some sort of standalone plugin. The content would look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myplug/&#xA;  plugin/&#xA;  mydefaultdir/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the scripts, I require a set of files which could have any name. Those are located in &lt;code&gt;mydefaultdir/&lt;/code&gt;. I have a function that list the content of that directory and helps use it in the ensuing script. However, I want to leave to the user the option to select an entirely different directory than the one I am providing. For that I can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let g:scriptdir = get(g:, 'scriptdir', &quot;/path/to/plug/mydefaultdir&quot;)&#xA;:call myfunc(g:scriptdir)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I cannot be sure where my plugin is located, and hence cannot set the &lt;code&gt;/path/to/plug&lt;/code&gt; fixed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose I could look to &lt;code&gt;rtp&lt;/code&gt;, but even that would fail if the user decided to rename the plugin directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am assuming that there are better ways to do that (using runtimepath/runtime?). But essentially; it boils down to...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can a plugin find where it is itself located?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="2170" LastActivityDate="2019-08-19T10:35:40.823" Title="Find the location of a directory at runtime to provide a default directory" Tags="|vimscript|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20939" PostTypeId="2" ParentId="20938" CreationDate="2019-08-19T10:35:40.823" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How can a plugin find where it is itself located?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need to &lt;code&gt;expand()&lt;/code&gt; &lt;code&gt;&amp;lt;sfile&amp;gt;&lt;/code&gt;. Assuming your code resides in &lt;code&gt;myplug/plugin/&amp;lt;somefile.vim&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# the first :h is to skip the script name;&#xA;# the second is to skip &quot;plugin/&quot; part&#xA;let s:mydefaultdir = expand(&quot;&amp;lt;sfile&amp;gt;:h:h&quot;) . &quot;/mydefaultdir&quot;&#xA;...&#xA;let g:scriptdir = get(g:, 'scriptdir', s:mydefaultdir)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-08-19T10:35:40.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20940" PostTypeId="1" CreationDate="2019-08-19T12:19:00.350" Score="1" ViewCount="130" Body="&lt;p&gt;I search with &lt;code&gt;/&lt;/code&gt;, press enter, and go a few results down using &lt;code&gt;n&lt;/code&gt;.&#xA;I realize that I have gone a few more results down than I meant to and want to go back a few.&#xA;I press &lt;code&gt;m&lt;/code&gt; because that is next to &lt;code&gt;n&lt;/code&gt; just like &lt;code&gt;k&lt;/code&gt; is next to &lt;code&gt;j&lt;/code&gt;. Nothing happens because &lt;code&gt;m&lt;/code&gt; is not &lt;code&gt;N&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I remap &lt;code&gt;N&lt;/code&gt; to &lt;code&gt;m&lt;/code&gt; in the context of navigating search results?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I am using neovim in case that makes a difference ;)&lt;/p&gt;&#xA;" OwnerUserId="23468" LastActivityDate="2019-08-19T12:19:00.350" Title="How do I remap result navigation buttons after a search?" Tags="|key-bindings|search|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20941" PostTypeId="1" CreationDate="2019-08-19T13:52:36.777" Score="0" ViewCount="74" Body="&lt;p&gt;Editing large HTML file. Would like to do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/&amp;lt;blockquote&amp;gt;/,/&amp;lt;\/blockquote&amp;gt;/s/^\(\s\s\+\)\(&amp;lt;[^&amp;gt;].\{-}&amp;gt;\)/\1  \2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So basically just trying to indent all  between the  tag lines. I thought this was possible, but perhaps I mangled the syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&lt;/p&gt;&#xA;" OwnerUserId="23470" LastEditorUserId="343" LastEditDate="2019-10-16T09:19:50.463" LastActivityDate="2019-10-16T09:19:50.463" Title="Find and replace only between searched patterns" Tags="|indentation|substitute|find|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20942" PostTypeId="2" ParentId="20896" CreationDate="2019-08-19T14:03:23.477" Score="2" Body="&lt;p&gt;Plain text files do not have formatting options like a word processor does. If you want that WYSIWYG functionality like a traditional word processor, then I recommend a word processor like LibreOffice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there are document formats that support common formatting with additional syntax. Markdown is a lightweight syntax that is still readable as a textfile but vim syntax highlighting can somewhat show you what the final result will look like, e.g. with pandoc's markdown &lt;a href=&quot;https://github.com/vim-pandoc/vim-pandoc-syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim-pandoc/vim-pandoc-syntax&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SOqNT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SOqNT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;From pandoc's README.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is using LaTeX which has lots of precise control for formatting. For small documents, compiling is very fast so you can quickly get a preview of your document. &lt;/p&gt;&#xA;" OwnerUserId="9553" LastActivityDate="2019-08-19T14:03:23.477" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20943" PostTypeId="1" CreationDate="2019-08-19T16:06:00.120" Score="2" ViewCount="5994" Body="&lt;p&gt;I'm trying to configure my &lt;code&gt;guifont&lt;/code&gt; and I'd like to see the current setting so I can e.g. keep the same font but change the size. Is there a way to check the current font that works reliably, even if no font has been selected in the current vim session?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A similar question was previously asked on mailing lists at &lt;a href=&quot;http://vim.1045645.n5.nabble.com/How-to-determine-current-font-in-use-td1181670.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vim.1045645.n5.nabble.com/How-to-determine-current-font-in-use-td1181670.html&lt;/a&gt; but not sufficiently answered; &lt;code&gt;set guifont&lt;/code&gt; only seems to get the current font if it's been explicitly set in the current vim session.&lt;/p&gt;&#xA;" OwnerUserId="824" LastActivityDate="2019-08-20T04:48:42.190" Title="How can I look up the current/default guifont reliably?" Tags="|gvim|font|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20944" PostTypeId="2" ParentId="184" CreationDate="2019-08-19T18:22:47.547" Score="7" Body="&lt;pre&gt;&lt;code&gt;/asdfasdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has the advantage that you do not have to type it exaclty. The disadvantage is, that there is a about 1:68719476736 chance in a 4096 byte file that this does not work and your cursor will jump to a different place. This chance increases for larger files.&lt;/p&gt;&#xA;" OwnerUserId="10063" LastActivityDate="2019-08-19T18:22:47.547" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20945" PostTypeId="1" CreationDate="2019-08-19T20:39:01.807" Score="3" ViewCount="389" Body="&lt;p&gt;I would like to insert some Python-generated text at the current cursor position in insert mode using the Vim Python interface. The closest I have so far is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;c-x&amp;gt;&amp;lt;c-r&amp;gt; &amp;lt;c-o&amp;gt;:python vim.current.line += &quot;trivial example&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will append &quot;trivial example&quot; rather than put it at the current position. How can I insert the text at the cursor instead?&lt;/p&gt;&#xA;" OwnerUserId="23475" LastActivityDate="2019-08-20T11:48:29.340" Title="Inserting text with the Python interface" Tags="|vimscript-python|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20946" PostTypeId="2" ParentId="20945" CreationDate="2019-08-20T00:16:54.260" Score="4" Body="&lt;p&gt;It is generally easier to use pyeval (py3eval, pyxeval) and the expression register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;c-x&amp;gt;&amp;lt;c-r&amp;gt; &amp;lt;c-r&amp;gt;=pyxeval('python expression')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-08-20T00:16:54.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20947" PostTypeId="2" ParentId="20941" CreationDate="2019-08-20T01:29:11.947" Score="1" Body="&lt;p&gt;Is &lt;code&gt;sed&lt;/code&gt; an option?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sed -r '/&amp;lt;blockquote&amp;gt;/,/&amp;lt;\/blockquote&amp;gt;/{s/^(\s\s\+)(&amp;lt;[^&amp;gt;].\{-}&amp;gt;)/\1  \2/g}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23479" LastActivityDate="2019-08-20T01:29:11.947" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20948" PostTypeId="2" ParentId="20941" CreationDate="2019-08-20T03:23:03.403" Score="1" Body="&lt;p&gt;If you want to indent html, use the indent operator &lt;code&gt;=&lt;/code&gt; with the inner-tag text object &lt;code&gt;it&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Place your cursor on the tag whose contents need indenting&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;=it&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-08-20T03:23:03.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20949" PostTypeId="2" ParentId="20943" CreationDate="2019-08-20T04:48:42.190" Score="5" Body="&lt;p&gt;So it looks like if no &lt;code&gt;guifont&lt;/code&gt; is specified in your vimrc, gVim will use some built in default font and it would not be reflected in &lt;code&gt;guifont&lt;/code&gt; -- &lt;code&gt;set guifont&lt;/code&gt; is empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it turns out it is possible to change the size of your default font -- use &lt;code&gt;guifont&lt;/code&gt; without name, just size:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=:h10&#xA;set guifont=:h16&#xA;...&#xA;whatever your default bitmap font supports&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0SmOJ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0SmOJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7nCKO.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7nCKO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-08-20T04:48:42.190" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20950" PostTypeId="1" CreationDate="2019-08-20T05:40:16.653" Score="2" ViewCount="98" Body="&lt;p&gt;I am using vim to view Spyder's Python comman history.  I set to &lt;code&gt;:e +=ff=dos&lt;/code&gt; to get rid of &lt;code&gt;^M&lt;/code&gt; at the end of each line.  When I switch to another file, then switch back, the &lt;code&gt;fileformat&lt;/code&gt; is &lt;code&gt;unix&lt;/code&gt; again.  Is there anyway to have vim remember the &lt;code&gt;fileformat&lt;/code&gt; for the buffer?&lt;/p&gt;&#xA;" OwnerUserId="7041" LastActivityDate="2019-08-20T09:17:02.620" Title="Make vim remember the fileformat of a buffer" Tags="|buffers|file-formats|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20951" PostTypeId="2" ParentId="20950" CreationDate="2019-08-20T08:32:46.310" Score="4" Body="&lt;p&gt;Add &lt;code&gt;dos&lt;/code&gt; to your &lt;code&gt;fileformats&lt;/code&gt; option. If &lt;code&gt;fileformats&lt;/code&gt; contains &lt;code&gt;dos&lt;/code&gt; and all lines of a file end with &lt;code&gt;&amp;lt;CR&amp;gt;&amp;lt;NL&amp;gt;&lt;/code&gt; the &lt;code&gt;fileformat&lt;/code&gt; option of that file is automatically set to &lt;code&gt;dos&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Addendum:&lt;/strong&gt; @ChristianBrabandt's comment to try &lt;code&gt;:set hidden&lt;/code&gt; might be better if the file in question has mixed end-of-line styles. &lt;code&gt;set fileformats+=dos&lt;/code&gt; only works if all lines end with &lt;code&gt;&amp;lt;CR&amp;gt;&amp;lt;NL&amp;gt;&lt;/code&gt;, while &lt;code&gt;:e ++ff=dos&lt;/code&gt; prints a hint &lt;code&gt;[CR missing]&lt;/code&gt;, but loads the file without showing the &lt;code&gt;^M&lt;/code&gt;s anyway.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastEditorUserId="2636" LastEditDate="2019-08-20T09:17:02.620" LastActivityDate="2019-08-20T09:17:02.620" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20952" PostTypeId="2" ParentId="20945" CreationDate="2019-08-20T11:39:28.770" Score="1" Body="&lt;p&gt;if you want to use : py, you probably should use vim.command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function dosomething()&#xA;     :py import vim &#xA;     :py vim.command(&quot;let tt ='text' &quot;)&#xA;     return tt&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and call it by &lt;code&gt;&amp;lt;C-R&amp;gt;=dosomething()&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; function dosomething()&#xA;     :py import vim &#xA;     :py vim.command(&quot;norm i&quot;+ 'TEXT' )&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and call it by &lt;code&gt;&amp;lt;esc&amp;gt;:call dosomething()&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-08-20T11:48:29.340" LastActivityDate="2019-08-20T11:48:29.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20953" PostTypeId="2" ParentId="184" CreationDate="2019-08-20T13:42:59.727" Score="0" Body="&lt;p&gt;I find that highlighting is rarely needed and when it is, it's only for a brief moment. My solution is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;/ set hls!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Highlighting is enabled by pressing &lt;code&gt;\/&lt;/code&gt; and disabled by pressing again. This gives easy access to highlighting in the rare cases when you need it.&lt;/p&gt;&#xA;" OwnerUserId="20444" LastEditorUserId="20444" LastEditDate="2022-10-03T16:32:30.763" LastActivityDate="2022-10-03T16:32:30.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20954" PostTypeId="2" ParentId="514" CreationDate="2019-08-20T15:46:38.363" Score="3" Body="&lt;p&gt;For some reason (likely a plugin) the standard &lt;code&gt;C-w &amp;gt;&lt;/code&gt; (etc.) did not work in my &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These &lt;code&gt;.vimrc&lt;/code&gt; additions worked (&lt;code&gt;Ctrl-Shift-Left&lt;/code&gt; ... where &lt;code&gt;Left | Right&lt;/code&gt; = left and right arrow keys, respectively.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; noremap &amp;lt;silent&amp;gt; &amp;lt;C-S-Left&amp;gt; :vertical resize +5&amp;lt;CR&amp;gt;&#xA;&quot; noremap &amp;lt;silent&amp;gt; &amp;lt;C-S-Right&amp;gt; :vertical resize -5&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;C-S-Left&amp;gt; :vertical resize +1&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;C-S-Right&amp;gt; :vertical resize -1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10749" LastActivityDate="2019-08-20T15:46:38.363" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20955" PostTypeId="1" AcceptedAnswerId="20956" CreationDate="2019-08-21T02:17:19.783" Score="2" ViewCount="156" Body="&lt;p&gt;Using MacVim 8.1.1722, if I print a buffer, it opens a PDF in Preview.app. I want to open the PDF in Google Chrome instead. So I changed the file association so &lt;code&gt;open foo.pdf&lt;/code&gt; opens Google Chrome not Preview.app. And then I set my &lt;code&gt;printexpr&lt;/code&gt; in MacVIM as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;se printexpr=system('ps2pdf\ '.v:fname_in.'\ '.v:fname_in.'.pdf\ &amp;amp;&amp;amp;\ open\ '.v:fname_in.'.pdf')\ +\ v:shell_error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And using the above &lt;code&gt;printexpr&lt;/code&gt;, it does what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is when I try to persist the above setting in &lt;code&gt;$HOME/.vimrc&lt;/code&gt;. It doesn't take effect, upon restarting MacVim, &lt;code&gt;printexpr&lt;/code&gt; still has the default value of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;se printexpr=system('open\ '-a\ Preview\ '.v:fname_in)\ +\ v:shell_error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I set other related options, such as &lt;code&gt;se popt&lt;/code&gt;, in &lt;code&gt;$HOME/.vimrc&lt;/code&gt;, it does take effect. Also, the command line &lt;code&gt;vim&lt;/code&gt; (VIM 7.4 shipped by Apple as part of macOS 10.12.6) does pick up the printexpr from that file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how do I get my &lt;code&gt;printexpr&lt;/code&gt; setting to persist?&lt;/p&gt;&#xA;" OwnerUserId="7304" LastActivityDate="2019-08-21T02:38:14.500" Title="How to set printexpr on MacVim persistently?" Tags="|vimrc|macvim|printing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20956" PostTypeId="2" ParentId="20955" CreationDate="2019-08-21T02:38:14.500" Score="2" Body="&lt;p&gt;I worked it out myself. I need to add the setting to &lt;code&gt;$HOME/.gvimrc&lt;/code&gt; as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the setting is in &lt;code&gt;$HOME/.vimrc&lt;/code&gt;, then MacVim overrides it. If the setting is in &lt;code&gt;$HOME/.gvimrc&lt;/code&gt;, then MacVim doesn't override it.&lt;/p&gt;&#xA;" OwnerUserId="7304" LastActivityDate="2019-08-21T02:38:14.500" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20957" PostTypeId="1" CreationDate="2019-08-21T08:04:36.967" Score="1" ViewCount="26" Body="&lt;p&gt;In Vim the commands &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; move backwards and forwards through the jump list.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h CTRL-I &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I noticed that &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; is the alternative command you can use instead of &lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; and this leads me to my question...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following mapping defined in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Tab&amp;gt; gt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works fine, in that if I press &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; and there are tabs open, it will iterate through the list of tabs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I then noticed that &lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; stops working and instead is mapped to my new mapping behaviour...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose map &amp;lt;C-i&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...would show the line in my &lt;code&gt;.vimrc&lt;/code&gt; where I had defined the updated &lt;code&gt;Tab&lt;/code&gt; mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I prevent &lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; from being remapped to where I'm now mapping &lt;code&gt;Tab&lt;/code&gt; to? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already use &lt;code&gt;nnoremap&lt;/code&gt; so &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; doesn't get expanded back to the original &lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; jump list behaviour, and so I'm not sure how to prevent that with &lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; unless I try maybe doing something weird like &lt;code&gt;nnoremap &amp;lt;C-i&amp;gt; &amp;lt;C-i&amp;gt;&lt;/code&gt; (which doesn't work btw as I tried it).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: if I comment out my new map &lt;code&gt;nnoremap &amp;lt;Tab&amp;gt; gt&lt;/code&gt; and restart Vim the &lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; behaviour goes back to normal, and there's no longer a mapping against it (e.g. &lt;code&gt;:verbose map &amp;lt;C-i&amp;gt;&lt;/code&gt; returns nothing).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="22173" LastActivityDate="2019-08-21T08:04:36.967" Title="Mapping breaks built-in Vim command?" Tags="|key-bindings|" AnswerCount="0" CommentCount="3" ClosedDate="2019-08-21T09:14:34.920" ContentLicense="CC BY-SA 4.0" />
  <row Id="20958" PostTypeId="1" CreationDate="2019-08-21T09:07:57.133" Score="4" ViewCount="5819" Body="&lt;p&gt;I installed NeoVim and &lt;code&gt;dense-analysis/ale&lt;/code&gt; plugin with &lt;code&gt;vim-plug&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of those seems to be installed, as the commands starting with &lt;code&gt;:ALE&lt;/code&gt; autocomplete in NeoVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I tried to install PYLS via&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;python3 -m pip install --user python-language-server&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and enabled it in my &lt;code&gt;init.vim&lt;/code&gt; file that you can read here :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# File .config/nvim/init.vim&#xA;call plug#begin('~/.config/nvim/plugged')&#xA;Plug 'dense-analysis/ale'&#xA;let g:ale_linters = {'python': ['pyls']}&#xA;let g:ale_fixers = {'python': ['black']}&#xA;let g:ale_lint_on_text_changed = 'never'&#xA;let g:ale_lint_on_insert_leave = 0&#xA;let g:ale_lint_on_enter = 0&#xA;let g:ale_completion_enabled = 1&#xA;call plug#end()&#xA;&#xA;&quot; Display&#xA;set number &quot; show the line numbers&#xA;set cursorline &quot; underline the current line&#xA;colorscheme koehler &quot; use my preferred palette&#xA;&#xA;&quot; Syntax highlighting&#xA;syntax on&#xA;&#xA;&quot; Set tabs to have 4 spaces&#xA;set tabstop=4 &quot; nb of spaces in a tab&#xA;set softtabstop=4&#xA;set shiftwidth=4 &quot; nb of spaces when using &amp;lt;&amp;lt; or &amp;gt;&amp;gt;&#xA;set expandtab &quot; use spaces when pressing &amp;lt;tab&amp;gt;&#xA;&#xA;&quot; Input&#xA;set mouse=a&#xA;&#xA;&quot; Output&#xA;set fileformat=unix&#xA;set encoding=utf-8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is : &lt;strong&gt;commands like &quot;:ALEGoToDefinition&quot; or &quot;:ALEFindReferences&quot;&lt;/strong&gt; don't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw that PYLS need Jedi to provide those, so I installed Jedi too.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python3 -m pip install --user jedi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But there's no change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my &lt;code&gt;:ALEInfo&lt;/code&gt; content :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ALEInfo...&#xA; Current Filetype: python&#xA;Available Linters: ['bandit', 'flake8', 'mypy', 'prospector', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylama', 'pylint', 'pyls', 'pyre', 'vulture']&#xA; Current Filetype: python&#xA;Available Linters: ['bandit', 'flake8', 'mypy', 'prospector', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylama', 'pylint', 'pyls', 'pyre', 'vulture']&#xA;  Enabled Linters: ['pyls']&#xA; Suggested Fixers:&#xA;  'add_blank_lines_for_python_control_statements' - Add blank lines before control statements.&#xA;  'autopep8' - Fix PEP8 issues with autopep8.&#xA;  'black' - Fix PEP8 issues with black.&#xA;  'isort' - Sort Python imports with isort.&#xA;  'remove_trailing_lines' - Remove all blank lines at the end of a file.&#xA;  'reorder-python-imports' - Sort Python imports with reorder-python-imports.&#xA;  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.&#xA;  'yapf' - Fix Python files with yapf.&#xA; Linter Variables:&#xA;let g:ale_python_auto_pipenv = 0&#xA;let g:ale_python_pyls_auto_pipenv = 0&#xA;let g:ale_python_pyls_config = {}&#xA;let g:ale_python_pyls_executable = 'pyls'&#xA;let g:ale_python_pyls_use_global = 0&#xA; Global Variables:&#xA;let g:ale_cache_executable_check_failures = v:null&#xA;let g:ale_change_sign_column_color = v:null&#xA;let g:ale_command_wrapper = v:null&#xA;let g:ale_completion_delay = 100&#xA;let g:ale_completion_enabled = 1&#xA;let g:ale_completion_max_suggestions = 50&#xA;let g:ale_echo_cursor = 1&#xA;let g:ale_echo_msg_error_str = 'Error'&#xA;let g:ale_echo_msg_format = v:null&#xA;let g:ale_echo_msg_info_str = 'Info'&#xA;let g:ale_echo_msg_warning_str = 'Warning'&#xA;let g:ale_enabled = 1&#xA;let g:ale_fix_on_save = 0&#xA;let g:ale_fixers = {'python': ['black']}&#xA;let g:ale_history_enabled = 1&#xA;let g:ale_history_log_output = 1&#xA;let g:ale_keep_list_window_open = v:null&#xA;let g:ale_lint_delay = 200&#xA;let g:ale_lint_on_enter = 0&#xA;let g:ale_lint_on_filetype_changed = 1&#xA;let g:ale_lint_on_insert_leave = 0&#xA;let g:ale_lint_on_save = 1&#xA;let g:ale_lint_on_text_changed = 'never'&#xA;let g:ale_linter_aliases = {}&#xA;let g:ale_linters = {'python': ['pyls']}&#xA;let g:ale_linters_explicit = 0&#xA;let g:ale_list_vertical = v:null&#xA;let g:ale_list_window_size = v:null&#xA;let g:ale_loclist_msg_format = v:null&#xA;let g:ale_lsp_root = {}&#xA;let g:ale_max_buffer_history_size = v:null&#xA;let g:ale_max_signs = v:null&#xA;let g:ale_maximum_file_size = v:null&#xA;let g:ale_open_list = v:null&#xA;let g:ale_pattern_options = v:null&#xA;let g:ale_pattern_options_enabled = v:null&#xA;let g:ale_set_balloons = 0&#xA;let g:ale_set_highlights = 1&#xA;let g:ale_set_loclist = 1&#xA;let g:ale_set_quickfix = 0&#xA;let g:ale_set_signs = 1&#xA;let g:ale_sign_column_always = v:null&#xA;let g:ale_sign_error = v:null&#xA;let g:ale_sign_info = v:null&#xA;let g:ale_sign_offset = v:null&#xA;let g:ale_sign_style_error = v:null&#xA;let g:ale_sign_style_warning = v:null&#xA;let g:ale_sign_warning = v:null&#xA;let g:ale_statusline_format = v:null&#xA;let g:ale_type_map = v:null&#xA;let g:ale_use_global_executables = v:null&#xA;let g:ale_virtualtext_cursor = 0&#xA;let g:ale_warn_about_trailing_blank_lines = 1&#xA;let g:ale_warn_about_trailing_whitespace = 1&#xA;  Command History:&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Did I forget some steps ?&#xA;Thanks you&lt;/p&gt;&#xA;" OwnerUserId="23494" LastEditorUserId="23494" LastEditDate="2019-08-21T09:22:36.580" LastActivityDate="2022-09-26T04:42:38.670" Title="Use the PYLS python LSP with ALE on Neovim" Tags="|neovim|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20959" PostTypeId="1" AcceptedAnswerId="20967" CreationDate="2019-08-21T18:52:30.333" Score="1" ViewCount="402" Body="&lt;p&gt;I want to convert nonASCII characters to similar ASCII alternatives. I can do it at shell using &lt;code&gt;echo şİçğ | iconv -f utf-8 -t ascii//translit&lt;/code&gt; but how can I do it for selected vim text?&lt;/p&gt;&#xA;" OwnerUserId="21916" LastActivityDate="2019-08-23T11:30:21.850" Title="Non ascii characters to similar ascii characters at Vim" Tags="|vimrc|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20960" PostTypeId="2" ParentId="20959" CreationDate="2019-08-21T19:08:54.343" Score="3" Body="&lt;p&gt;For a line-wise operations, you can make a command and mappings :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range Translit &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;!iconv -f utf-8 -t ascii//translit&#xA;nnoremap &amp;lt;leader&amp;gt;t :Translit&amp;lt;CR&amp;gt;&#xA;xnoremap &amp;lt;leader&amp;gt;t :Translit&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The normal mapping &lt;code&gt;&amp;lt;leader&amp;gt;t&lt;/code&gt; will translate the current line.&lt;/li&gt;&#xA;&lt;li&gt;You can visually select lines with &lt;code&gt;V&lt;/code&gt; and enter &lt;code&gt;&amp;lt;leader&amp;gt;t&lt;/code&gt; to translit the selected lines.&lt;/li&gt;&#xA;&lt;li&gt;You can also call it manually with a range, e.g &lt;code&gt;:2,20Translit&lt;/code&gt; or &lt;code&gt;:%Translit&lt;/code&gt; etc...&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;line1&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;line2&amp;gt;&lt;/code&gt; are replaced by the actual line numbers from the range (e.g &lt;code&gt;2&lt;/code&gt; and &lt;code&gt;20&lt;/code&gt;) before executing the command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;:{range}![!]{filter} [!][arg]             *:range!*&#xA;          Filter {range} lines through the external program&#xA;          {filter}. ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;command&lt;/code&gt; I propose makes it easier to maintain. You can manage your mappings with the core command written in one place.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/change.txt.html#:range!&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :range!&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/map.txt.html#user-commands&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h user-commands&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="22929" LastEditorUserId="22929" LastEditDate="2019-08-22T13:31:14.533" LastActivityDate="2019-08-22T13:31:14.533" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20961" PostTypeId="2" ParentId="7975" CreationDate="2019-08-21T19:41:11.517" Score="1" Body="&lt;pre&gt;&lt;code&gt;touch ~/.vimrc&#xA;echo &quot;set ts=4 sw=4&quot; &amp;gt;&amp;gt; ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Shorthand for J.Chomel's answer.&lt;br&gt;&#xA;&lt;code&gt;touch&lt;/code&gt; will create the file .vimrc in your home directory if it doesn't exists yet&lt;br&gt;&#xA;Next, append tabstop and shiftwidth with your preferences to the &lt;em&gt;.vimrc file&lt;/em&gt;. &lt;/p&gt;&#xA;" OwnerUserId="23504" LastActivityDate="2019-08-21T19:41:11.517" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20962" PostTypeId="1" AcceptedAnswerId="20966" CreationDate="2019-08-21T21:37:21.313" Score="2" ViewCount="345" Body="&lt;p&gt;Currently, I have the following map for cpp files:  &lt;code&gt;inoremap ;;f for&amp;lt;Space&amp;gt;()&amp;lt;Space&amp;gt;{&amp;lt;Enter&amp;gt;}&amp;lt;Esc&amp;gt;kkf)i&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which essentially allows me to quickly setup a c-style for loop. However, I have been wondering for the longest time whether one could supply arguments to an inoremap command, so that typing: &lt;code&gt;var bound ;;f&lt;/code&gt; would automatically end up as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int var = 0; i &amp;lt; bound; var++) {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23507" LastEditorUserId="18375" LastEditDate="2019-08-23T16:18:50.353" LastActivityDate="2019-08-23T16:18:50.353" Title="Is it possible to supply arguments to inoremap?" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20963" PostTypeId="2" ParentId="20790" CreationDate="2019-08-21T22:38:54.067" Score="1" Body="&lt;p&gt;I assume the arguments of grep are similar to fzf#run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that is the case you need to set:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;{ 'dir': getcwd(), 'options': '-n 2'}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The -n tells the column that is relevant for the search. You can do &lt;code&gt;man fzf&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-08-21T22:38:54.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20964" PostTypeId="1" AcceptedAnswerId="20965" CreationDate="2019-08-21T22:53:09.813" Score="1" ViewCount="85" Body="&lt;p&gt;On one copy of Vim that I use sometimes, I get errors like this when I start up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/besham/.vimrc:&#xA;line  524:&#xA;E749: empty buffer&#xA;line  555:&#xA;E749: empty buffer&#xA;line  578:&#xA;E749: empty buffer&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Those three lines in my vimrc are all &lt;code&gt;write&lt;/code&gt; commands that occur within functions, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GnuplotCompileOpen()&#xA;    write    &quot; this is line 524&#xA;    exe &quot;:!gnuplot_pdf \&quot;%\&quot; &amp;amp;&amp;amp; open \&quot;&quot; . ChangeExt(expand(&quot;%&quot;), &quot;pdf&quot;) . &quot;\&quot;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It &lt;em&gt;seems&lt;/em&gt; like Vim is just executing commands it came across as it was reading my functions! Surely this isn’t the case… right? What is going on here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how this version of Vim is compiled. (I have never seen this kind of behavior in any other version.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 28 2019 13:59:32)&#xA;Included patches: 1-160, 399, 402-403, 1099&#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Small version without GUI.  Features included (+) or not (-):&#xA;+acl             -farsi           -mouse_sgr       -tag_old_static&#xA;-arabic          -file_in_path    -mouse_sysmouse  -tag_any_white&#xA;-autocmd         -find_in_path    -mouse_urxvt     -tcl&#xA;-balloon_eval    -float           -mouse_xterm     +terminfo&#xA;-browse          -folding         +multi_byte      -termresponse&#xA;+builtin_terms   -footer          -multi_lang      -textobjects&#xA;-byte_offset     +fork()          -mzscheme        -title&#xA;-cindent         -gettext         -netbeans_intg   -toolbar&#xA;-clientserver    -hangul_input    -path_extra      -user_commands&#xA;-clipboard       +iconv           -perl            -vertsplit&#xA;-cmdline_compl   -insert_expand   -persistent_undo -virtualedit&#xA;+cmdline_hist    +jumplist        -printer         +visual&#xA;-cmdline_info    -keymap          -profile         -visualextra&#xA;-comments        -langmap         -python          -viminfo&#xA;-conceal         -libcall         -python3         -vreplace&#xA;-cryptv          -linebreak       -quickfix        +wildignore&#xA;-cscope          -lispindent      -reltime         -wildmenu&#xA;-cursorbind      -listcmds        -rightleft       +windows&#xA;-cursorshape     -localmap        -ruby            +writebackup&#xA;-dialog          -lua             -scrollbind      -X11&#xA;-diff            -menu            -signs           -xfontset&#xA;-digraphs        -mksession       -smartindent     -xim&#xA;-dnd             -modify_fname    -sniff           -xsmp&#xA;-ebcdic          -mouse           -startuptime     -xterm_clipboard&#xA;-emacs_tags      -mouse_dec       -statusline      -xterm_save&#xA;-eval            -mouse_gpm       -sun_workshop    -xpm&#xA;-ex_extra        -mouse_jsbterm   -syntax&#xA;-extra_search    -mouse_netterm   -tag_binary&#xA;   system vimrc file: &quot;/etc/virc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/etc&quot;&#xA; f-b for $VIMRUNTIME: &quot;/usr/share/vim/vim74&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D__linux__ -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -Wl,-z,relro  -L/usr/local/lib -Wl,--as-needed -o vim        -lm  -lselinux -lncurses -lacl -lattr -ldl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="671" LastEditorUserId="671" LastEditDate="2019-08-27T17:30:46.713" LastActivityDate="2019-08-27T17:30:46.713" Title="Vim is executing commands that were part of a function definition" Tags="|functions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20965" PostTypeId="2" ParentId="20964" CreationDate="2019-08-21T23:10:33.560" Score="3" Body="&lt;p&gt;Your version of vim was compiled without &lt;code&gt;eval&lt;/code&gt; support, and I suspect that it therefore does not support functions. Vim would then ignore the function statement and likely tries to execute the bodies. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h eval&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Note: Expression evaluation can be disabled at compile time.  If this has been&#xA;done, the features in this document are not available.  See |+eval| and&#xA;|no-eval-feature|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;:h :function&lt;/code&gt; takes us to &lt;code&gt;eval.txt&lt;/code&gt;, from where I grabbed this heading.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As mentioned by Christian Brabandt in the comments,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;wrap the function definition in &lt;code&gt;if 1 ... endif&lt;/code&gt; statements to prevent non-eval builds of vim from executing this&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-08-23T20:05:58.787" LastActivityDate="2019-08-23T20:05:58.787" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20966" PostTypeId="2" ParentId="20962" CreationDate="2019-08-22T03:33:17.463" Score="5" Body="&lt;p&gt;TL;DR: Yes, you can find simple ways to pass arguments to mappings (in particular &lt;code&gt;inoremap&lt;/code&gt;), but they tend to be somewhat awkward or limited in some ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the particular case you mentioned, using a snippet manager, such as &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;noreferrer&quot;&gt;UltiSnips&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Having said that, there are a few ways to make your mappings take parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, you could prompt the user for the variable and bound, using the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#input%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;input()&lt;/code&gt;&lt;/a&gt; function. An example of that would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ForLoop()&#xA;  let var = input('Variable name? ')&#xA;  let bound = input('Bound? ')&#xA;  return &quot;for (int &quot;.var.&quot; = 0; &quot;.&#xA;      \ var.&quot; &amp;lt; &quot;.bound.&quot;; &quot;.&#xA;      \ var.&quot;++) {\n}\eO&quot;&#xA;endfunction&#xA;inoremap &amp;lt;expr&amp;gt; ;;f ForLoop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping uses &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; to call a function and have it return the keystrokes that will get expanded. As it's an &lt;code&gt;inoremap&lt;/code&gt;, the keystrokes will happen in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function composes a string with the expansion, starting with the &quot;for&quot; statement. At the end, the &lt;code&gt;\n&lt;/code&gt; inserts a line break, then the &lt;code&gt;\e&lt;/code&gt; exits insert mode and the &lt;a href=&quot;https://vimhelp.org/insert.txt.html#O&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;O&lt;/code&gt;&lt;/a&gt; normal mode command begins a new line above the current one, putting you back in insert mode in between the curly braces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One issue with this approach is that prompting might break the editing flow. You also don't get access to most of Vim's editing commands while answering the prompts. That makes this method somewhat awkward and limited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possibility is to have the mapping consume the text you typed on the current line before the mapping was invoked. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ForLoop()&#xA;  let [var, bound] = matchlist(getline('.'), '\v\s*(.*);(.*)')[1:2]&#xA;  return &quot;\&amp;lt;C-u&amp;gt;for (int &quot;.&#xA;      \ var.&quot; = 0; &quot;.&#xA;      \ var.&quot; &amp;lt; &quot;.bound.&quot;; &quot;.&#xA;      \ var.&quot;++) {\n}\eO&quot;&#xA;endfunction&#xA;inoremap &amp;lt;expr&amp;gt; ;;f ForLoop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\&amp;lt;C-u&amp;gt;&lt;/code&gt; at the start issues a &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-U&quot; rel=&quot;noreferrer&quot;&gt;Ctrl-U&lt;/a&gt; in order to delete the beginning of the line, that was used as arguments to the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can invoke this mapping with &lt;code&gt;i;100;;f&lt;/code&gt;, which will expand to a for loop going from 0 to 99 over the variable &lt;code&gt;i&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This approach has some advantages, in that you get access to Vim's editing commands when entering the parameters. But it's somewhat intuitive that you enter the arguments first, use a somewhat ad-hoc separator (&lt;code&gt;;&lt;/code&gt;, in this case) and the arguments disappear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in short, while some approaches are possible, they're far from what a snippet manager can do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A snippet manager exposes a much friendlier UI, typically showing you the expansion at first, then allowing you to fill in the fields in the order you specify, repeating them when they're needed in more than one place, and allowing you to skip to the next field by pressing &quot;Tab&quot; or a similar keystroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, snippet managers implement a generic engine, so you can define your own snippets using a simple templating language and they'll expand them correctly for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So while you can get something fairly simple done in a few lines of Vimscript, it's probably worth investing into setting up and learning to use a snippet manager, particularly if you expect to use many similar templates.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-22T03:33:17.463" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20967" PostTypeId="2" ParentId="20959" CreationDate="2019-08-22T12:38:18.507" Score="1" Body="&lt;p&gt;You can implement a mapping to translit a visual selection by using the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#system%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;system()&lt;/code&gt;&lt;/a&gt; function and passing the contents of the selection as the input to the system command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This mapping should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;leader&amp;gt;T ygv&quot;=system('iconv -f utf-8 -t ascii//translit', @@)&amp;lt;cr&amp;gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Breaking it down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt;: Yank the visual selection into the default register.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gv&lt;/code&gt;: Go back to visual mode, on the previous selection. (This will allow us to replace it with a &lt;code&gt;p&lt;/code&gt; next.)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;=&lt;/code&gt;: Use the &lt;a href=&quot;https://vimhelp.org/change.txt.html#quote%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;expression register&lt;/a&gt; for the next &lt;code&gt;p&lt;/code&gt; operation.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;system(...)&amp;lt;cr&amp;gt;&lt;/code&gt;: Enter the system expression. The final &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; finishes entering the expression and goes back to normal mode, where you can use it.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'iconv ...'&lt;/code&gt;: The external command to run on a shell.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@@&lt;/code&gt;: A reference to the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#expr-register&quot; rel=&quot;nofollow noreferrer&quot;&gt;default register&lt;/a&gt;, where we previously yanked the visual selection.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt;: Put. In this case, put the contents of the expression register, replacing the visual selection.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You access this mapping by entering visual mode, selecting some text and using &lt;code&gt;\T&lt;/code&gt; (or similar, if you have overridden &lt;code&gt;mapleader&lt;/code&gt;, in which case use that rather than a backslash as prefix.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works in both character-wise and linewise Visual mode. It doesn't work that well in block-wise mode, for some reason Vim loses track of the block once you modify the register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a bit more work, you could also make this work in normal mode with an operator (like &lt;code&gt;\Tw&lt;/code&gt; or &lt;code&gt;\Tiw&lt;/code&gt; to translit the current word under the cursor.) For that case, you set &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27operatorfunc%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'operatorfunc'&lt;/code&gt;&lt;/a&gt; to a function and then call &lt;a href=&quot;https://vimhelp.org/map.txt.html#g%40&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g@&lt;/code&gt;&lt;/a&gt; with a motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Translit(type)&#xA;  if a:type ==# 'visual'&#xA;    execute &quot;normal! gvy&quot;&#xA;  elseif a:type ==# 'char'&#xA;    execute &quot;normal! `[v`]y&quot;&#xA;  elseif a:type ==# 'line'&#xA;    execute &quot;normal! '[V']y&quot;&#xA;  else&#xA;    return&#xA;  endif&#xA;  call setreg('&quot;', &#xA;      \ system('iconv -f utf-8 -t ascii//translit', @@),&#xA;      \ getregtype('&quot;'))&#xA;  normal! gvp&#xA;endfunction&#xA;xnoremap &amp;lt;leader&amp;gt;T :&amp;lt;c-u&amp;gt;call Translit('visual')&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;T :set operatorfunc=Translit&amp;lt;cr&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more details on this solution, you might want to read &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/33.html#motion-types&quot; rel=&quot;nofollow noreferrer&quot;&gt;this &quot;Grep Operator&quot; section&lt;/a&gt; in &quot;Learn Vimscript the Hard Way&quot;. (Read the whole thing and make the exercises if you really want to learn Vimscript. It's an invaluable resource for that!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: This code also fixes the issue with block-wise Visual mode, by using &lt;a href=&quot;https://vimhelp.org/eval.txt.html#setreg%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;setreg()&lt;/code&gt;&lt;/a&gt; with a third argument after &lt;a href=&quot;https://vimhelp.org/eval.txt.html#getregtype%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getregtype()&lt;/code&gt;&lt;/a&gt; to preserve the block format. (Thanks @JürgenKrämer for figuring that out!)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-08-23T01:58:22.307" LastActivityDate="2019-08-23T01:58:22.307" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20968" PostTypeId="1" AcceptedAnswerId="20972" CreationDate="2019-08-22T13:04:26.497" Score="3" ViewCount="269" Body="&lt;p&gt;Consider this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;leader&amp;gt;U ygv&quot;=toupper(@@)&amp;lt;cr&amp;gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will yank the current visual selection, select it back, and then put a modified version of it. In this case, uppercase letters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works great on character-wise and linewise Visual modes, where the final &lt;code&gt;p&lt;/code&gt; command will replace the contents of the previous selection, leaving everything else in place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in block-wise Visual mode, it doesn't work as expected. Even though the resulting register has the same &quot;format&quot; as the one before the transformation, the put operation ends up shifting things around, putting the multi-line content in the first line of the block and breaking some lines as it does that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This same problem doesn't happen if I simply put the register, unmodified. Inspecting the register with &lt;code&gt;:reg &quot;&lt;/code&gt; doesn't show anything out of the ordinary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, applying the transformation manually with &lt;code&gt;:let @@ = toupper(@@)&lt;/code&gt; and inspecting the register afterwards doesn't show anything that's been lost, but putting it into a Visual block selection still fails at that point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I ask:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is there some magic in how contents coming from Visual block yanks/deletes are stored into registers?&lt;/li&gt;&#xA;&lt;li&gt;If so, is there anyway to inspect that, see it?&lt;/li&gt;&#xA;&lt;li&gt;Is there any way to reproduce that, so that after the &lt;code&gt;toupper()&lt;/code&gt; conversion I could still be able to preserve that it's meant to be a block?&lt;/li&gt;&#xA;&lt;li&gt;If that's not possible, are there any workarounds available for this situation?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I looked at help for Visual block mode and didn't find anything (in fact, didn't find specific help on &lt;code&gt;v_b_p&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;code&gt;toupper()&lt;/code&gt; is just a simple example. Of course I could simply use &lt;a href=&quot;https://vimhelp.org/change.txt.html#v_U&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;U&lt;/code&gt;&lt;/a&gt; for that case. The use of &lt;code&gt;toupper()&lt;/code&gt; is just as a proxy for a more general transformation. (This issue came up as I was writing an answer to &lt;a href=&quot;https://vi.stackexchange.com/q/20959/18609&quot;&gt;this question&lt;/a&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-17T10:23:16.130" Title="Pasting modified register contents into Visual Block selection" Tags="|register|visual-block|paste|expression-register|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20969" PostTypeId="1" CreationDate="2019-08-22T14:30:35.290" Score="0" ViewCount="259" Body="&lt;p&gt;Can you edit a vim session, so that it opens a file based on the value of an environment variable instead of an absolute path to a file?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2019-08-23T11:01:47.247" Title="Can a vim session use environment variables to specify the path to a file it opens?" Tags="|sessions|environment-variables|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="20970" PostTypeId="1" CreationDate="2019-08-22T16:15:56.020" Score="2" ViewCount="1371" Body="&lt;p&gt;I use sessions to separate projects in my workflow. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- info.txt file that I always mark &quot;I&quot;&#xA;- log.txt file that I always mark &quot;L&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I switch sessions, my markers are kept from the last project, causing lots of confusion!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to isolate markers per session?&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or let's say... save my markers to a local viminfo that runs on each session load? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is there a better way to do this? what's the vim way? &lt;/p&gt;&#xA;" OwnerUserId="22353" LastActivityDate="2019-08-22T19:31:12.390" Title="In Vim how to keep markers per session?" Tags="|vimrc|viminfo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20971" PostTypeId="1" CreationDate="2019-08-22T17:43:40.510" Score="4" ViewCount="1544" Body="&lt;p&gt;I have recently started using the vim-fugitive plugin, and currently I am facing problem with the Gpush command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;:Gpush %&lt;/code&gt; which gives me errors in the quick fix window saying &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;fatal: could not read from remote repository&lt;br&gt;&#xA;  make sure you have the correct access rights&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I can push from outside vim (the terminal) without any problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need extra configuration? or are there other arguments when executing &lt;code&gt;:Gpush&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already tried going through the help file via &lt;code&gt;:h fugitive&lt;/code&gt; and could find any clue. Please help.&lt;/p&gt;&#xA;" OwnerUserId="8537" LastActivityDate="2019-10-02T12:25:26.433" Title="I am running into problems while using Gpush command from vim-fugitive plugin" Tags="|gvim|plugin-fugitive|vim8|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="20972" PostTypeId="2" ParentId="20968" CreationDate="2019-08-22T19:10:18.160" Score="6" Body="&lt;p&gt;To modify the content of a register while keeping its type (characterwise, linewise or block) you need to use &lt;code&gt;setreg()&lt;/code&gt;. Otherwise Vim is only able to choose the register type as characterwise or linewise. There is note at &lt;code&gt;:help setreg()&lt;/code&gt; which hints at this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; you may not reliably restore register value&#xA;  without using the third argument to &lt;code&gt;getreg()&lt;/code&gt; as without it&#xA;  newlines are represented as newlines AND Nul bytes are&#xA;  represented as newlines as well, see &lt;code&gt;NL-used-for-Nul&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your example I would use the following command to uppercase the blockwise selection in the default register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setreg('&quot;', toupper(@&quot;), getregtype('&quot;'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I chose to use the default register instead of &lt;code&gt;@@&lt;/code&gt;, because in my tests &lt;code&gt;getregtype('@@')&lt;/code&gt; returned an empty string.)&lt;/p&gt;&#xA;&#xA;&#xA;" OwnerUserId="2636" LastEditorUserId="1238" LastEditDate="2019-12-17T10:23:16.130" LastActivityDate="2019-12-17T10:23:16.130" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20973" PostTypeId="2" ParentId="20970" CreationDate="2019-08-22T19:31:12.390" Score="2" Body="&lt;p&gt;Marks are stored in &lt;code&gt;viminfo&lt;/code&gt; not in a session and the &lt;code&gt;viminfo&lt;/code&gt; file is &lt;em&gt;only&lt;/em&gt; written when exiting vim. So if you are closing vim to switch projects then vim will only have marks for the previous project that you were working on. One would potentially have to come up with a plugin that separately reads and stores marks from &lt;code&gt;viminfo&lt;/code&gt; when calling &lt;code&gt;:mksession&lt;/code&gt; and then overwrites them in &lt;code&gt;viminfo&lt;/code&gt; when sourcing the session file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h session&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. Restores global mappings and options, if 'sessionoptions' contains&#xA;       &quot;options&quot;.  Script-local mappings will not be written.&#xA;    2. Restores global variables that start with an uppercase letter and contain&#xA;       at least one lowercase letter, if 'sessionoptions' contains &quot;globals&quot;.&#xA;    3. Unloads all currently loaded buffers.&#xA;    4. Restores the current directory if 'sessionoptions' contains &quot;curdir&quot;, or&#xA;       sets the current directory to where the Session file is if 'sessionoptions'&#xA;       contains &quot;sesdir&quot;.&#xA;    5. Restores GUI Vim window position, if 'sessionoptions' contains &quot;winpos&quot;.&#xA;    6. Restores screen size, if 'sessionoptions' contains &quot;resize&quot;.&#xA;    7. Reloads the buffer list, with the last cursor positions.  If&#xA;       'sessionoptions' contains &quot;buffers&quot; then all buffers are restored,&#xA;       including hidden and unloaded buffers.  Otherwise only buffers in windows&#xA;       are restored.&#xA;    8. Restores all windows with the same layout.  If 'sessionoptions' contains&#xA;       &quot;help&quot;, help windows are restored.  If 'sessionoptions' contains &quot;blank&quot;,&#xA;       windows editing a buffer without a name will be restored.&#xA;       If 'sessionoptions' contains &quot;winsize&quot; and no (help/blank) windows were&#xA;       left out, the window sizes are restored (relative to the screen size).&#xA;       Otherwise, the windows are just given sensible sizes.&#xA;    9. Restores the Views for all the windows, as with :mkview.  But&#xA;       'sessionoptions' is used instead of 'viewoptions'.&#xA;    10. If a file exists with the same name as the Session file, but ending in&#xA;       &quot;x.vim&quot; (for eXtra), executes that as well.  You can use *x.vim files to&#xA;       specify additional settings and actions associated with a given Session,&#xA;       such as creating menu items in the GUI version.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h viminfo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; The viminfo file is used to store:&#xA;    - The command line history.&#xA;    - The search string history.&#xA;    - The input-line history.&#xA;    - Contents of non-empty registers.&#xA;    - Marks for several files.&#xA;    - File marks, pointing to locations in files.&#xA;    - Last search/substitute pattern (for 'n' and '&amp;amp;').&#xA;    - The buffer list.&#xA;    - Global variables.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23520" LastActivityDate="2019-08-22T19:31:12.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20974" PostTypeId="2" ParentId="20418" CreationDate="2019-08-22T21:10:51.800" Score="1" Body="&lt;p&gt;This would work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-LeftMouse&amp;gt; &amp;lt;LeftMouse&amp;gt;:YcmCompleter GoTo&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add another &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; at the end to go to the first result&lt;/p&gt;&#xA;" OwnerUserId="23522" LastActivityDate="2019-08-22T21:10:51.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20975" PostTypeId="2" ParentId="20969" CreationDate="2019-08-23T11:01:47.247" Score="1" Body="&lt;p&gt;After saving a session to a file you can edit it and replace parts of the path with the environment variables:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Original:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ...&#xA;edit C:\Users\yourname\Some\Path\file.txt&#xA;set ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Modified:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ...&#xA;edit $HOME\Some\Path\file.txt&#xA;set ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-08-23T11:01:47.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20976" PostTypeId="2" ParentId="20959" CreationDate="2019-08-23T11:30:21.850" Score="1" Body="&lt;p&gt;It's possible to do this internally in Vimscript, without shelling out to an external executable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's regular expressions include support for &quot;equivalence classes&quot; i.e. characters that &quot;have almost the same meaning, e.g., when ignoring accents&quot;. (See &lt;code&gt;:help /[[=&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you can replace the first &lt;code&gt;ş&lt;/code&gt; in the current line with &lt;code&gt;s&lt;/code&gt; by running the &lt;code&gt;:substitute&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/[[=s=]]/s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use this to write a command that will perform such a substitution for all characters in the currently selected range of lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -range=% ToASCII call ToASCII(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;)&#xA;&#xA;function! ToASCII(start_line, end_line) abort&#xA;  &quot; Set up the range of lines to edit&#xA;  let range_string = a:start_line.','.a:end_line&#xA;&#xA;  &quot; Iterate over the alphabet&#xA;  for c in range(65, 90)&#xA;    &quot; Iterate over upper/lower case&#xA;    for capitilization in [0, 32]&#xA;      &quot; Get the string version of the number&#xA;      let ascii_char = nr2char(c + capitilization)&#xA;&#xA;      &quot; Build a substitute command&#xA;      let subst_string = 's/[[='.ascii_char.'=]]/'.ascii_char.'/ge'&#xA;&#xA;      &quot; Run the command over the range of lines&#xA;      execute range_string.subst_string&#xA;    endfor&#xA;  endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. Because this code uses &lt;code&gt;:substitute&lt;/code&gt;, it won't work well for characterwise visual selections. It's possible to write a solution that does, but the code would be a bit more complicated.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-08-23T11:30:21.850" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20977" PostTypeId="2" ParentId="2046" CreationDate="2019-08-23T14:03:00.940" Score="5" Body="&lt;p&gt;Although not technically vim. cgdb is a curses version of gdb with vim-like keybindings. It's been my goto debugger for years:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://cgdb.github.io/&quot; rel=&quot;noreferrer&quot;&gt;https://cgdb.github.io/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23495" LastActivityDate="2019-08-23T14:03:00.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20979" PostTypeId="1" AcceptedAnswerId="20980" CreationDate="2019-08-23T20:10:42.203" Score="3" ViewCount="153" Body="&lt;p&gt;If possible, I would prefer to not start using a package manager for now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to &lt;em&gt;manually&lt;/em&gt; install this plugin for editing JS files: &lt;a href=&quot;https://github.com/pangloss/vim-javascript&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/pangloss/vim-javascript&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have looked around, and tested several things, but for some reason I can't get it to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you go about &quot;manually&quot; installing the &lt;em&gt;pangloss&lt;/em&gt; plugin without using pathogen, or a package manager?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's my first question here. Hope this makes sense.&lt;/p&gt;&#xA;" OwnerUserId="23536" LastActivityDate="2019-08-23T20:38:34.173" Title="How to manually install pangloss JavaScript plugin?" Tags="|filetype-javascript|plugin-managers|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20980" PostTypeId="2" ParentId="20979" CreationDate="2019-08-23T20:38:34.173" Score="4" Body="&lt;h1&gt;TL;DR Use &lt;code&gt;:h packages&lt;/code&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You will need&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the plugin code (github is easiest, though if you just have a copy of the&#xA;source tree lying around, that works too)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;A brief history of &lt;strike&gt;time&lt;/strike&gt; managing plugins&lt;sup&gt;1&lt;/sup&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I won't go into extreme detail here unless it is requested. This is mostly a&#xA;background section, and can be skipped if needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the dark ages, you used to need to put all plugin code next to each other, so&#xA;(for example) your &lt;code&gt;~/.vim/plugin&lt;/code&gt; would have&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;plugin-a.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;unrelated-plugin-b.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Updating and removing plugins was a &lt;em&gt;nightmare&lt;/em&gt;: what did you do if an update&#xA;removed a file? How did you know which files belonged with which plugins and&#xA;needed deletion?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pathogen gave us &lt;code&gt;bundle&lt;/code&gt; to keep things separate, and that's what packages do&#xA;too&lt;sup&gt;2&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pathogen (typically) adds each directory under, e.g., &lt;code&gt;~/.vim/bundle&lt;/code&gt; to the&#xA;&lt;code&gt;'runtimepath'&lt;/code&gt;.  In other words, you could have&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/bundle/mypluginhere&lt;/code&gt;, and&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;~/.vim/bundle/pangloss-javascript-here&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But you still managed those directories yourself. (Other plugin managers can do&#xA;that for you, but you don't need—or always want—that).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage of this is described &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/42.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Plugin layout in the Dark&#xA;Ages&lt;/a&gt; and &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/43.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;A New&#xA;Hope: Plugin Layout with&#xA;Pathogen&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Packages bring to vim8 what pathogen had already done for previous vim versions,&#xA;and they do so natively. Packages provide a way of adding segmented components&#xA;to the &lt;code&gt;'runtimepath'&lt;/code&gt; (remember that this path controls where vim looks for&#xA;plugin code, autoload scripts, filetype plugins, &amp;amp;c.).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Enter packages&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Packages use &lt;code&gt;'packpath'&lt;/code&gt;, which is a bit like a combination of &lt;code&gt;bundle&lt;/code&gt; and&#xA;&lt;code&gt;'runtimepath'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What &lt;em&gt;you&lt;/em&gt; need to know is that you can put a complete copy of the plugin source&#xA;tree in &lt;code&gt;~/.vim/pack/&amp;lt;any-name-you-want&amp;gt;/start/&amp;lt;plugin-name&amp;gt;&lt;/code&gt;. (The adept user&#xA;may want to investigate &lt;code&gt;opt&lt;/code&gt; as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's it. It will be loaded for you by vim.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Some management strategies with &lt;code&gt;git&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;git-clone&lt;/code&gt;: this strategy is for users who just want to clone the plugin and&#xA;have it run. Typical interaction looks like&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# git clone &amp;lt;path/to/repo&amp;gt; ~/.vim/pack/&amp;lt;other-plugins&amp;gt;/start/&amp;lt;plugin-name&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;code&gt;git-submodule&lt;/code&gt;: this strategy is for folks like me who keep their&#xA;dotfiles/vim configs in version control. Typical interaction looks like&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# git -C &amp;lt;dotfile-dir&amp;gt; submodule add &amp;lt;path/to/repo&amp;gt; &amp;lt;dotfile-vim-dir&amp;gt;/pack/&amp;lt;other-plugins&amp;gt;/start/&amp;lt;plugin-name&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I omit all plugin managers except pathogen, which is actually a&#xA;&lt;code&gt;'runtimepath'&lt;/code&gt; manager. This little lie won't hurt anyone, though.&lt;/li&gt;&#xA;&lt;li&gt;They have a slightly broader use case. I'm aware, but I don't find it&#xA;necessary for the purposes of this question.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-08-23T20:38:34.173" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20981" PostTypeId="2" ParentId="20814" CreationDate="2019-08-24T01:23:57.500" Score="5" Body="&lt;p&gt;According to the documentation: (&lt;code&gt;help speeddating&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;One can use the &lt;code&gt;:SpeedDatingFormat&lt;/code&gt; command to list, add, and remove formats. A good place to place custom formats is in &lt;code&gt;.vim/after/plugin/speeddating.vim&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For the formats you listed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SpeedDatingFormat %Y/%m/%d&#xA;SpeedDatingFormat %Y/%m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23537" LastActivityDate="2019-08-24T01:23:57.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20982" PostTypeId="1" AcceptedAnswerId="20986" CreationDate="2019-08-24T06:43:33.520" Score="2" ViewCount="977" Body="&lt;p&gt;When I start &lt;code&gt;vim&lt;/code&gt;, I always use &lt;code&gt;-s SCRIPT_FILE_NAME&lt;/code&gt; option to execute additional commands. In &lt;code&gt;SCRIPT_FILE_NAME&lt;/code&gt;, some ex commands are written. Let &lt;code&gt;COMM&lt;/code&gt; denote the additional commands in the file. The problem is that &lt;code&gt;COMM&lt;/code&gt; is added to command history. For example, when I &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;start &lt;code&gt;vim&lt;/code&gt; and execute &lt;code&gt;:echo&lt;/code&gt; and exit with &lt;code&gt;:q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;and start &lt;code&gt;vim&lt;/code&gt; again&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;the expected contents of the command history (which can be seen via &lt;code&gt;q:&lt;/code&gt;) are&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;: 48 echo&#xA;: 49 q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the actual contents are&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;: 48 echo&#xA;: 49 q&#xA;: 50 COMM1&#xA;: 51 COMM2&#xA;      ︙&#xA;: 60 COMM11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this is truly annoying. (Assume &lt;code&gt;COMM&lt;/code&gt; consists of a hundread of commands.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to avoid this? &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;NOTE1: Because the execution order is different between commands in &lt;code&gt;.vimrc&lt;/code&gt; and those in &lt;code&gt;SCRIPT_FILE_NAME&lt;/code&gt;, I cannot move &lt;code&gt;COMM&lt;/code&gt; to &lt;code&gt;.vimrc&lt;/code&gt;. In other words, there &lt;strong&gt;is&lt;/strong&gt; a reason why I use &lt;code&gt;-s&lt;/code&gt; option in addition to &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE2: Of course, it is possible to execute &lt;code&gt;sed&lt;/code&gt; command between the first and second step above to remove the undesired lines. However, doing like this isn't elegant, I think. I wonder if there is a better solution supplied by &lt;code&gt;vim&lt;/code&gt; by default.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By putting all of &lt;code&gt;COMM&lt;/code&gt; into a function in &lt;code&gt;.vimrc&lt;/code&gt; and calling it from &lt;code&gt;SCRIPT_FILE_NAME&lt;/code&gt;, the number of items added to the history can be decreased to one. But I'd still like to decrease it to zero if I can.&lt;/p&gt;&#xA;" OwnerUserId="16502" LastEditorUserId="16502" LastEditDate="2019-08-24T09:56:01.003" LastActivityDate="2019-08-24T16:39:38.587" Title="Is there any way to execute ex command without adding it to the command history?" Tags="|startup|command-history|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20983" PostTypeId="1" CreationDate="2019-08-24T09:27:07.373" Score="1" ViewCount="355" Body="&lt;p&gt;I'm using the NerdCommenters &lt;code&gt;leader c&amp;lt;space&amp;gt;&lt;/code&gt; to toggle comments on blocks of C code, but when those blocks already contain C comments, they get replaced, by default with &lt;code&gt;[&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;]&lt;/code&gt;, and toggling the comment back off doesn't replace these placeholder with &lt;code&gt;/*&lt;/code&gt; and &lt;code&gt;*/&lt;/code&gt; again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've learned doing  two explicit uncomments, or an explicit uncomment (&lt;code&gt;leader-cu&lt;/code&gt;) after the uncommenting toggle, reverts the placeholders back to &lt;code&gt;/*&lt;/code&gt; and &lt;code&gt;*/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can things be set up so I don't need the extra uncomment?&#xA;I'd like to limit myself to using just &lt;code&gt;leader c&amp;lt;space&amp;gt;&lt;/code&gt; (toggle comment). &lt;/p&gt;&#xA;" OwnerUserId="4738" LastActivityDate="2024-03-16T16:02:35.360" Title="Using NerdCommenter to comment/uncomment blocks with old-style C comments" Tags="|filetype-c|plugin-nerdcommenter|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20984" PostTypeId="1" AcceptedAnswerId="20985" CreationDate="2019-08-24T10:46:49.673" Score="4" ViewCount="1540" Body="&lt;p&gt;I use &lt;code&gt;:vs&lt;/code&gt; to open a window. If I want this window to be the leftmost window, no matter what the currently active window is, how can I do it?&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="10604" LastEditDate="2019-08-24T18:29:45.240" LastActivityDate="2023-07-13T22:44:46.827" Title="Open split window at far left" Tags="|vim-windows|" AnswerCount="2" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20985" PostTypeId="2" ParentId="20984" CreationDate="2019-08-24T16:23:41.177" Score="6" Body="&lt;p&gt;You can use a couple of methods to achieve the same end result as  your request.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You can just open a vertical split and then move it to leftmost position using &lt;kbd&gt;Control&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; + &lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;H&lt;/kbd&gt; (note that the &quot;h&quot; is uppercase.) See &lt;a href=&quot;https://vimhelp.org/windows.txt.html#CTRL-W_H&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help CTRL-W_H&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Atopleft&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:topleft&lt;/code&gt;&lt;/a&gt; to modify your &lt;code&gt;:vs&lt;/code&gt; command to open the window in the leftmost position. You can use the following command for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:topleft vs&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="18609" LastEditDate="2019-08-24T16:51:34.510" LastActivityDate="2019-08-24T16:51:34.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20986" PostTypeId="2" ParentId="20982" CreationDate="2019-08-24T16:39:38.587" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I always use &lt;code&gt;-s SCRIPT_FILE_NAME&lt;/code&gt; option to execute additional commands. In &lt;code&gt;SCRIPT_FILE_NAME&lt;/code&gt;, some ex commands are written.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So &lt;a href=&quot;https://vimhelp.org/starting.txt.html#-s&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;-s {scriptin}&lt;/code&gt;&lt;/a&gt; or the equivalent &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Asource%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:source!&lt;/code&gt;&lt;/a&gt; command are meant to read the contents of a file and execute those as &lt;em&gt;Normal&lt;/em&gt; mode commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They fully reuse normal mode key processing. As such, Ex commands entered with &lt;code&gt;:&lt;/code&gt; will be added to history. There doesn't seem to be much you can really do about that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're primarily using this mechanism to run Ex commands, then turn this around. Turn it into an Ex script instead (which means you can drop the &lt;code&gt;:&lt;/code&gt;s), then you can use the &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Asource%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:source&lt;/code&gt;&lt;/a&gt; command to load it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have parts of the script that are using Normal mode commands, you can use the &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Anormal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:normal!&lt;/code&gt;&lt;/a&gt; command to enter them, turning that into an Ex command that you can use as part of the script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You mentioned &lt;em&gt;&quot;putting all of &lt;code&gt;COMM&lt;/code&gt; into a function in &lt;code&gt;.vimrc&lt;/code&gt; and calling it from &lt;code&gt;SCRIPT_FILE_NAME&lt;/code&gt;&quot;&lt;/em&gt;, so it sounds like you were able to accomplish that already, since &lt;code&gt;.vimrc&lt;/code&gt; and &lt;code&gt;function&lt;/code&gt; are both comprised of Ex mode commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have your Ex script, you can then use the &lt;a href=&quot;https://vimhelp.org/starting.txt.html#-c&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;-c&lt;/code&gt;&lt;/a&gt; command-line option to source it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -c 'source SCRIPT_FILE_NAME.vim' ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, if you have it as a function in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -c 'call MyInitFunc()' ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should work as expected, without polluting the Vim command history.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also, about this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Because the execution order is different between commands in &lt;code&gt;.vimrc&lt;/code&gt; and those in &lt;code&gt;SCRIPT_FILE_NAME&lt;/code&gt;, I cannot move &lt;code&gt;COMM&lt;/code&gt; to &lt;code&gt;.vimrc&lt;/code&gt;. In other words, there &lt;strong&gt;is&lt;/strong&gt; a reason why I use &lt;code&gt;-s&lt;/code&gt; option in addition to &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Take a look at the &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#VimEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;VimEnter&lt;/a&gt; event of &lt;code&gt;autocmd&lt;/code&gt;, it triggers once, around the same time as the &lt;code&gt;-c&lt;/code&gt; script works. (I believe &lt;code&gt;-s&lt;/code&gt; is a little later than both, but still close.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to &lt;em&gt;always&lt;/em&gt; use the sequence of commands and you have only been using the external script because of the timing, then using VimEnter should solve this problem in a better way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use something like the following in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyInitFunc()&#xA;  COMM1&#xA;  COMM2&#xA;  COMM3&#xA;endfunction&#xA;augroup vimrc_initfunc&#xA;  autocmd!&#xA;  autocmd VimEnter * call MyInitFunc()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(See also &lt;a href=&quot;https://vimhelp.org/eval.txt.html#v%3Avim_did_enter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;v:vim_did_enter&lt;/code&gt;&lt;/a&gt;, if you care about possibly re-running &lt;code&gt;MyInitFunc()&lt;/code&gt; if you're reloading your &lt;code&gt;.vimrc&lt;/code&gt; using &lt;code&gt;:source&lt;/code&gt; during runtime.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-24T16:39:38.587" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="20987" PostTypeId="1" AcceptedAnswerId="20988" CreationDate="2019-08-24T16:41:16.397" Score="1" ViewCount="61" Body="&lt;p&gt;I have this &lt;code&gt;go&lt;/code&gt; code snippet that I am working on in vim with &lt;code&gt;vim-go&lt;/code&gt; enabled. &lt;code&gt;|&lt;/code&gt; is where my cursor is at. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// PlayerServer is a HTTP interface for player information&#xA;type PlayerServer struct {&#xA;        store  PlayerStore |&#xA;        router *http.ServeMux&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I hit return, the cursor goes 8 spaces indented in the next line. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// PlayerServer is a HTTP interface for player information&#xA;type PlayerServer struct {&#xA;        store  PlayerStore &#xA;                |&#xA;        router *http.ServeMux&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What setting should I be looking at to see what causes this?&lt;/p&gt;&#xA;" OwnerUserId="2277" LastActivityDate="2019-08-24T17:13:29.593" Title="What setting causes my autoindent to add indent on a new line?" Tags="|indentation|filetype-go|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20988" PostTypeId="2" ParentId="20987" CreationDate="2019-08-24T17:13:29.593" Score="3" Body="&lt;p&gt;As diagnosed through comments, you were probably using some generic indentation (such as Vim's &lt;code&gt;cindent&lt;/code&gt;, which is likely to expect semi-colons to end statements.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to enable language-specific plugins for indentation, enable filetype detection and filetype indentation plugins, with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-24T17:13:29.593" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20989" PostTypeId="1" AcceptedAnswerId="20990" CreationDate="2019-08-25T21:26:41.173" Score="3" ViewCount="1281" Body="&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: this may be a Windows-only problem. The symptom has been reproduced on multiple Windows 10 machines.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I find my syntax-highlighting for Markdown files (ending in &lt;code&gt;.md&lt;/code&gt;) will fail to rander when there are &quot;code-blocks&quot; of hyper length (say, multiple lines of code that runs longer than the vertical length of the monitor). This usually happened when I jump directly to the bottom of the document using &lt;code&gt;G&lt;/code&gt; in normal mode. Here goes a comparison of the right and wrong syntax-highlighting obtained before and after the &quot;immediate fix&quot; (more details below).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FWThv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FWThv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To &lt;em&gt;restore&lt;/em&gt; the correct &quot;colorization&quot;, I originally was paging down to the bottom of the document using &lt;code&gt;&amp;lt;c-f&amp;gt;&lt;/code&gt;. Lately, I found the following immediate fix that worked within an active Vim session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following &lt;a href=&quot;https://github.com/vim/vim/issues/2790#issuecomment-379555340&quot; rel=&quot;nofollow noreferrer&quot;&gt;this suggestion from Issues for Vim on Github&lt;/a&gt;, setting &lt;code&gt;:syntax sync minlines=10000&lt;/code&gt; in a buffer does fix the coloring problem immediately. Yet, the fix only stay within the current Vim session and dropping any of the following lines to my &lt;code&gt;.vimrc&lt;/code&gt; did not help to reproduce the immediate solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax sync minlines=10000k&#xA;autocmd BufEnter,BufRead *.md :syntax sync minlines=10000&#xA;set redrawtime=10000 &quot;Suggested by someone else from the vim-Github-issue-page. Did not help in my case.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a &lt;strong&gt;compromise&lt;/strong&gt;, I am adding an abbreviation for the command line mode as the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cab mdd syntax sync minlines=10000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am looking for a once-and-for-all fix to the syntax-highlighting problem with markdown files.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Please advise if I am missing some handy settings for vim. This only happened on &lt;code&gt;gvim.exe&lt;/code&gt; installed on Windows 10 machines. I have been reusing almost 100% of the &lt;code&gt;.vimrc&lt;/code&gt; settings across Linux, Windows-WSL and Windows machines. Unix-based Vim has been consistently getting the syntax-highlighting correct.&lt;/p&gt;&#xA;" OwnerUserId="2398" LastEditorUserId="5298" LastEditDate="2019-08-26T07:37:21.540" LastActivityDate="2019-08-26T07:37:21.540" Title="Syntax-highlighting is getting screwed when loading long markdown files on Windows" Tags="|syntax-highlighting|microsoft-windows|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20990" PostTypeId="2" ParentId="20989" CreationDate="2019-08-26T00:44:51.613" Score="4" Body="&lt;p&gt;The issue here is ordering, you need this &lt;code&gt;syntax sync&lt;/code&gt; command to be issued only &lt;em&gt;after&lt;/em&gt; the syntax rules for Markdown have been loaded, otherwise the &lt;code&gt;sync&lt;/code&gt; will be cleared as those rules are loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good way to do so is to add this &lt;code&gt;syntax sync&lt;/code&gt; command to a syntax file in the &lt;code&gt;$HOME\vimfiles\after&lt;/code&gt; directory (that's for Windows, the corresponding directory on Linux/Unix would be &lt;code&gt;~/.vim/after&lt;/code&gt;.) Unfortunately, none of the other options you mentioned will issue that command late enough to work for your case, so that's actually the type of situation in which you want to resort to using the &quot;after&quot; directory. (See &lt;a href=&quot;https://vimhelp.org/options.txt.html#vimfiles&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help vimfiles&lt;/code&gt;&lt;/a&gt; for more details.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your specific case, create a file &lt;code&gt;$HOME\vimfiles\after\syntax\markdown.vim&lt;/code&gt; with the single line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax sync minlines=10000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, as @BLayer points out in the comments, you might as well just have the syntax engine evaluate the file from the start every time (10,000 lines is close enough to that in most cases):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax sync fromstart&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This file will get loaded &lt;em&gt;after&lt;/em&gt; the usual Markdown syntax is loaded, so it's the perfect place to add your customizations.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-08-26T03:48:01.453" LastActivityDate="2019-08-26T03:48:01.453" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20991" PostTypeId="1" AcceptedAnswerId="20992" CreationDate="2019-08-26T02:22:20.243" Score="1" ViewCount="98" Body="&lt;p&gt;I'm struggling to write a function that asks the user to input a string, but cuts it off after they've inputted a specific amount of characters (three, for example) and moves on with the rest of the function logic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example use-case would be a grep function, where it asks for a pattern, but then automatically begins the grep after three characters and the remaining characters typed act as a filter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See below for an example of the rough functionality I'm aiming for. After typing &quot;1&quot;, &quot;2&quot;, &quot;3&quot; the search is automatically executed:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4X4Q7.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4X4Q7.gif&quot; alt=&quot;example vim screencast of functionality&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am familiar with &lt;code&gt;getchar()&lt;/code&gt; as a way to &quot;fake&quot; it by monitoring raw keypresses and echoing them back, then after three keypresses executing the function. That solution seems imperfect for a number of reasons, the biggest one being that I would have to manually handle several non-ASCII keypresses (backspace, for example) that getchar() captures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance for the help!&lt;/p&gt;&#xA;" OwnerUserId="1019" LastActivityDate="2019-08-26T03:22:02.647" Title="How to cut off user input and continue with script after a certain number of characters are entered?" Tags="|user-input|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20992" PostTypeId="2" ParentId="20991" CreationDate="2019-08-26T03:02:27.003" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/vim/vim/commit/153b704e20f9c269450a7d3ea8cafcf942579ab7&quot; rel=&quot;nofollow noreferrer&quot;&gt;Patch 8.0.1445&lt;/a&gt; introduced &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#CmdlineChanged&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h CmdlineChanged&lt;/a&gt; , you can use it together with &lt;a href=&quot;https://vimhelp.org/eval.txt.html#input%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h input()&lt;/a&gt; to get what you want. Here is a simple example i wrote to update last line of current buffer to cmdline while typing in cmdline.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:on_input_change()&#xA;  call setline('$', getcmdline())&#xA;  redraw&#xA;endfunction&#xA;&#xA;function! s:dynamic_input()&#xA;  augroup input_test&#xA;    au!&#xA;    autocmd CmdlineChanged @ call s:on_input_change()&#xA;  augroup end&#xA;&#xA;  let str = input(&quot;blah : &quot;)&#xA;&#xA;  au! input_test&#xA;endfunction&#xA;&#xA;nnoremap \x :call &amp;lt;sid&amp;gt;dynamic_input()&amp;lt;cr&amp;gt;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-08-26T03:22:02.647" LastActivityDate="2019-08-26T03:22:02.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20993" PostTypeId="1" CreationDate="2019-08-26T07:16:26.900" Score="1" ViewCount="197" Body="&lt;p&gt;I am trying to correct some long latex files &gt; 10 000 lines. Something that bothers me and messes with the typopgraphy is the missuse of align and equation environments. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;The equation environment should be used instead of align whenever the equation does not contain &lt;code&gt;\\&lt;/code&gt; or &lt;code&gt;\newline&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I know there exists some fringe cases with &lt;code&gt;\begin{cases}&lt;/code&gt; and matrices, but the change above should do the bulk of the work, and I can do the rest manually. &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I write an regex expression that changes every &lt;code&gt;align&lt;/code&gt; and &lt;code&gt;align*&lt;/code&gt; environment into respectively &lt;code&gt;equation&lt;/code&gt; and &lt;code&gt;equation*&lt;/code&gt; environments, whenever the environment does not contain &lt;code&gt;\\&lt;/code&gt; or &lt;code&gt;\newline&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;I would also like to be able to remove &lt;code&gt;&amp;amp;&lt;/code&gt; from the equation environments if possible.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Test cases&lt;/h1&gt;&#xA;&#xA;&lt;h3&gt;Input:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{align}&#xA;  a &amp;amp;= b + c&#xA;\end{align}&#xA;&#xA;\begin{align}&#xA;    a &#xA;  &amp;amp;=b &#xA;   + c&#xA;\end{align}&#xA;&#xA;\begin{align*}&#xA;  a &amp;amp;= b + c&#xA;\end{align*}&#xA;&#xA;\begin{align}&#xA;    a = b \newline c = d&#xA;\end{align}&#xA;&#xA;\begin{align}&#xA;    a = b \\ c = d&#xA;\end{align}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Output&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{equation}&#xA;  a = b + c&#xA;\end{equation}&#xA;&#xA;\begin{equation}&#xA;    a &#xA;   =b &#xA;   + c&#xA;\end{equation}&#xA;&#xA;\begin{equation*}&#xA;  a = b + c&#xA;\end{equation*}&#xA;&#xA;\begin{align}&#xA;    a = b \newline c = d&#xA;\end{align}&#xA;&#xA;\begin{align}&#xA;    a = b \\ c = d&#xA;\end{align}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22594" LastActivityDate="2019-08-26T07:57:50.040" Title="Regex to change align into equation" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20994" PostTypeId="2" ParentId="20993" CreationDate="2019-08-26T07:51:44.483" Score="2" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\\begin{align\*\=}\_.\{-}\\end{align\*\=}/\=submatch(0) !~# '\s\\\\\s\|\\newline' ? substitute(substitute(submatch(0), '\\\%(begin\|end\){\zsalign\(\*\=\)\ze}', 'equation\1', 'g'), '&amp;amp;=', '=', 'g') : submatch(0)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pattern of the substitution command is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\\begin{align\*\=}\_.\{-}\\end{align\*\=}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the replacement is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\=submatch(0) !~# '\s\\\\\s\|\\newline' ? substitute(substitute(submatch(0), '\\\%(begin\|end\){\zsalign\(\*\=\)\ze}', 'equation\1', 'g'), '&amp;amp;=', '=', 'g') : submatch(0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's an evaluated expression, because it begins with &lt;code&gt;\=&lt;/code&gt;; and it relies on the conditional operator &lt;code&gt;?:&lt;/code&gt; which expects 3 operands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first operand – used as a test – is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;submatch(0) !~# '\s\\\\\s\|\\newline'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second operand – used as the value if the test succeeds – is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute(substitute(submatch(0), '\\\%(begin\|end\){\zsalign\(\*\=\)\ze}', 'equation\1', 'g'), '&amp;amp;=', '=', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The inner &lt;code&gt;substitute()&lt;/code&gt; replaces &lt;code&gt;align&lt;/code&gt; into &lt;code&gt;equation&lt;/code&gt;, while the outer one removes &lt;code&gt;&amp;amp;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third operand – used as the value if the test fails – is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;submatch(0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :s&#xA;:h /\_.&#xA;:h /\{-&#xA;:h /\=&#xA;:h :s\=&#xA;:h submatch()&#xA;:h !~#&#xA;:h /\s&#xA;:h /bar&#xA;:h expr1&#xA;:h substitute()&#xA;:h /\(&#xA;:h /\%(&#xA;:h /\zs&#xA;:h /\ze&#xA;:h /\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-08-26T07:57:50.040" LastActivityDate="2019-08-26T07:57:50.040" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20995" PostTypeId="1" AcceptedAnswerId="20996" CreationDate="2019-08-26T09:30:25.107" Score="6" ViewCount="1337" Body="&lt;p&gt;I recently had a need to type the letters æ, ø, and å. For context, these are available on my physical keyboard, and work fine in other programs. It's also a Norwegian keyboard (+ layout), if that's relevant.&lt;/p&gt;&#xA;&lt;p&gt;With Vim, and specifically gVim, only æ and ø work. Other combined letters (such as ö and â) work out of the box, though by using dead keys to actually do so. Attempting to write å results in various behavior I can't understand. With no remapping, pressing it shifts around lines or letters. Typing it in an empty buffer with no remapping pulls code from somewhere, though I don't understand how.&lt;/p&gt;&#xA;&lt;p&gt;I know I can type the letter with &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; (as suggested &lt;a href=&quot;https://unix.stackexchange.com/a/521357&quot;&gt;here&lt;/a&gt;), or with &lt;code&gt;&amp;lt;C-k&amp;gt; å å&lt;/code&gt;, but this is slow and, in my opinion, unnecessary. Also, &lt;code&gt;&amp;lt;C-v&amp;gt; å&lt;/code&gt; results in &lt;code&gt;å&lt;/code&gt;, so I'm assuming I'm supposed to use it when attempting to remap.&lt;/p&gt;&#xA;&lt;p&gt;I tried with &lt;code&gt;imap å &amp;lt;C-v&amp;gt; å&lt;/code&gt;, &lt;code&gt;imap å &amp;lt;C-k&amp;gt;å&lt;/code&gt;, &lt;code&gt;imap å &amp;lt;C-k&amp;gt; å&lt;/code&gt;, &lt;code&gt;imap å &amp;lt;C-k&amp;gt; å å&lt;/code&gt;, &lt;code&gt;imap å &amp;lt;C-k&amp;gt; åå&lt;/code&gt;, and the basic &lt;code&gt;imap å å&lt;/code&gt;, but none of them give me the letter. Remapping it to other output letters doesn't do anything at all (one of the other variants listed here resulted in an &lt;code&gt;e&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;How can I make Vim properly type non-ASCII letters?&lt;/p&gt;&#xA;&lt;p&gt;When I haven't explicitly remapped it myself for science, &lt;code&gt;:verbose map å&lt;/code&gt; says the key isn't used.&lt;/p&gt;&#xA;" OwnerUserId="21251" LastEditorUserId="21251" LastEditDate="2022-05-12T11:36:39.803" LastActivityDate="2024-02-27T21:35:38.077" Title="Why can't I type certain non-ASCII letters?" Tags="|key-bindings|gvim|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="20996" PostTypeId="2" ParentId="20995" CreationDate="2019-08-26T12:23:59.847" Score="7" Body="&lt;p&gt;&lt;code&gt;:verbose map&lt;/code&gt; does not work for detecting the keybind in insert mode. Since it's while editing, and the relevant mapping is &lt;code&gt;imap&lt;/code&gt; or &lt;code&gt;inoremap&lt;/code&gt;, &lt;code&gt;:verbose imap&lt;/code&gt;/&lt;code&gt;:verbose map!&lt;/code&gt; are the two correct options to use for tracking down the conflict.&lt;/p&gt;&#xA;&lt;p&gt;In this case, the reason I had such weird behavior is because of the function it's mapped to. It calls a function in a parentheses auto-completion/utility plugin, and specifically a fast wrap feature.&lt;/p&gt;&#xA;&lt;p&gt;However, independently of that plugin, a meta keybind conflicting with a letter does indeed cause unexpected behavior. What that behavior is depends on the mapping used. Whether it's from a plugin or something you set yourself, is something you'll have to figure out.&lt;/p&gt;&#xA;&lt;h2&gt;In general&lt;/h2&gt;&#xA;&lt;p&gt;Some meta keybinds map to non-ascii/European/other letters. In insert mode, this means the corresponding letters become an alternate way to use the meta keybind. This boils down to how input processing in Vim works, and that's a convoluted mess I don't understand myself, so I won't comment too much on it.&lt;/p&gt;&#xA;&lt;p&gt;Use &lt;code&gt;:verbose imap å&lt;/code&gt; (replace &lt;code&gt;å&lt;/code&gt; with your affected letter) to determine which keybind is affected.&lt;/p&gt;&#xA;&lt;p&gt;As an example, &lt;code&gt;å&lt;/code&gt; is equivalent to &lt;code&gt;&amp;lt;M-e&amp;gt;&lt;/code&gt; on my system. &lt;code&gt;&amp;lt;M-e&amp;gt;&lt;/code&gt; may correspond to something else on your system, however, because input processing is weird.&lt;/p&gt;&#xA;&lt;p&gt;When you determine which keybind is affected with &lt;code&gt;:verbose imap&lt;/code&gt;, you'll be able to track down the source. &lt;code&gt;verbose imap&lt;/code&gt; includes a path to the affected file, as well as the line it's declared on.&lt;/p&gt;&#xA;&lt;p&gt;Taking a look at the output I had:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:verbose imap å&#xA;i  å           *@&amp;lt;C-R&amp;gt;=AutoPairsFastWrap()&amp;lt;CR&amp;gt;&#xA;    Last set from ~\.vim\plugged\auto-pairs\plugin\auto-pairs.vim line 562&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The second line is the part that's guaranteed to give you enough information. Reading the relevant information is trivial, and explicitly a part of the output.&lt;/p&gt;&#xA;&lt;p&gt;If your keybinding is set from a:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a &lt;code&gt;.vimrc&lt;/code&gt; or other config file you've written, edit the keybind to something else.&lt;/li&gt;&#xA;&lt;li&gt;a plugin, read the documentation and/or plugin code. Some plugins have variables for re-mapping or fully unmapping keys. If no such option exists, find the bug tracker for the plugin and post there. As a hack, you can always edit the file in the meanwhile, but this may cause conflicts if you use a plugin manager with semi-automatic updates.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When you've fixed it, you of course need to reload Vim, and you should be good to go.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I highly recommend avoiding meta-based keybinds in insert mode entirely, particularly in plugins.&lt;/p&gt;&#xA;&lt;h2&gt;Auto-pairs&lt;/h2&gt;&#xA;&lt;p&gt;In my particular case, &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;jiangmiao/auto-pairs&lt;/a&gt; was the source of this problem.&lt;/p&gt;&#xA;&lt;p&gt;Running &lt;code&gt;:verbose imap å&lt;/code&gt; or &lt;code&gt;:verbose map! å&lt;/code&gt; gave me this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;i  å           *@&amp;lt;C-R&amp;gt;=AutoPairsFastWrap()&amp;lt;CR&amp;gt;&#xA;    Last set from ~\.vim\plugged\auto-pairs\plugin\auto-pairs.vim line 562&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The block that set the shortcut looks like this:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;if g:AutoPairsShortcutFastWrap != ''&#xA;  execute 'inoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; '.g:AutoPairsShortcutFastWrap.' &amp;lt;C-R&amp;gt;=AutoPairsFastWrap()&amp;lt;CR&amp;gt;'&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;By default, the shortcut is set to &lt;code&gt;&amp;lt;M-e&amp;gt;&lt;/code&gt;, but that in itself doesn't necessarily make sense, especially with the mapping. If, however, you type &lt;code&gt;&amp;lt;M-e&amp;gt;&lt;/code&gt; when it's not remapped, it outputs &lt;code&gt;å&lt;/code&gt;. &lt;code&gt;&amp;lt;C-v&amp;gt; &amp;lt;M-e&amp;gt;&lt;/code&gt; also gives &lt;code&gt;å&lt;/code&gt; &lt;sub&gt;this might be keyboard-dependent - I'm not sure and I can't test it&lt;/sub&gt;. So the plugin remapping &lt;code&gt;&amp;lt;M-e&amp;gt;&lt;/code&gt; resulted in &lt;code&gt;å&lt;/code&gt; being remapped to a function that when provided sensible input works fine, but when provided none or invalid input results in the weird behavior I saw.&lt;/p&gt;&#xA;&lt;p&gt;The reason I couldn't override it is because the original remapping was done with &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;, which seems to override the global ones. I think that's the reason &lt;code&gt;imap å å&lt;/code&gt; didn't work. With &lt;code&gt;imap &amp;lt;buffer&amp;gt; å å&lt;/code&gt;, it outputs å instead of calling the plugin function that originally defined it.&lt;/p&gt;&#xA;&lt;p&gt;That being said, there's a relatively easy fix to this that doesn't require any remapping of &lt;code&gt;å&lt;/code&gt;, but rather remapping the plugin. The code I showed earlier uses &lt;code&gt;g:AutoPairsShortcutFastWrap&lt;/code&gt;, which defines which key it'll map to. I just decided on &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt;, but any unused shortcut will do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:AutoPairsShortcutFastWrap = &amp;quot;&amp;lt;C-f&amp;gt;&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After reloading Vim, &lt;code&gt;å&lt;/code&gt; works as a normal letter again.&lt;/p&gt;&#xA;" OwnerUserId="21251" LastEditorUserId="21251" LastEditDate="2022-05-12T12:21:27.623" LastActivityDate="2022-05-12T12:21:27.623" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20997" PostTypeId="1" CreationDate="2019-08-26T19:12:16.903" Score="1" ViewCount="222" Body="&lt;p&gt;Characteristics:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MacOS 10.14.6&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using VIM as text editor for a few weeks, with both &lt;code&gt;Terminal&lt;/code&gt; and &lt;code&gt;iTerm2&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could write character dependent on hitting key &lt;kbd&gt;alt&lt;/kbd&gt; (left alt key in &lt;code&gt;iTerm&lt;/code&gt;) without problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ex:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;alt-3&lt;/kbd&gt; gave the the character &quot;#&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;alt-5&lt;/kbd&gt; gave the the character &quot;[&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;alt-6&lt;/kbd&gt; gave the the character &quot;]&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But suddenly, it changed and now when hit those shortcuts, it does not write the corresponding character with the left alt key and quits insert mode instead (although the command with the desired output work with the right alt key in &lt;code&gt;iTerm2&lt;/code&gt;. Moreover combinations with both right and left alt key are also working fine in &lt;code&gt;Terminal&lt;/code&gt;). I think that this change came after &lt;code&gt;Vim&lt;/code&gt; or &lt;code&gt;iTerm2&lt;/code&gt; asked me if I wanted to change some shortcuts and I (stupidly) responded yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So i conclude that pressing  suddenly seems to map to the command &lt;code&gt;Esc&lt;/code&gt; (and not the character &quot;#&quot;, How do I change that mapping&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following command  without success: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:unmap &amp;lt;Alt-3&amp;gt;&#xA;:unmap &amp;lt;Alt-3&amp;gt; Esc&#xA;:unmap &amp;lt;press Alt-3&amp;gt;&#xA;:unmap &amp;lt;press Alt-3&amp;gt; Esc&#xA;&#xA;:map  &amp;lt;A-3&amp;gt; #&#xA;:map! &amp;lt;A-3&amp;gt; #&#xA;:map  &amp;lt;A-&quot;&amp;gt; #&#xA;:map! &amp;lt;A-&quot;&amp;gt; #&#xA;:set timeout timeoutlen=5000 ttimeoutlen=250&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want be able to write the character &quot;#&quot; with the shortcut &lt;kbd&gt;Alt-3&lt;/kbd&gt; (left alt button) in &lt;code&gt;iTerm2&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did I change something by mistake? What should I do to fix the problem? Should I change the &lt;code&gt;~/vimrc&lt;/code&gt; file&lt;/p&gt;&#xA;" OwnerUserId="23561" LastEditorUserId="23561" LastEditDate="2019-08-26T19:45:36.763" LastActivityDate="2019-08-26T19:45:36.763" Title="Pressing &lt;Alt-3&gt; (left alt key) suddenly maps to Esc (and not the character &quot;#&quot;) using iTerm2" Tags="|key-bindings|terminal|macos|escape|" AnswerCount="0" CommentCount="5" ClosedDate="2019-09-02T14:28:01.210" ContentLicense="CC BY-SA 4.0" />
  <row Id="20998" PostTypeId="1" CreationDate="2019-08-26T19:50:33.433" Score="1" ViewCount="752" Body="&lt;p&gt;I really don't know what details to give except for some screenshots and my vimrc file, I think it is because of a plugin but I am really not sure. Random characters just appear. Note that they are not part of the file so if I press &quot;0&quot; I can't actually reach them nor do I see them when I close the buffer and reopen it again or &quot;cat filename&quot; in another terminal window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here on line 10, that &quot;D]&quot;.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/pNcA4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pNcA4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here you can see it on line 29 and 39. The &quot;portNam&quot; and &quot;ID]&quot;.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/9yWvu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9yWvu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;VUNDLE STARTS HERE&#xA;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;Plugin 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } &quot; Fuzzy finder&#xA;Plugin 'junegunn/fzf.vim'&#xA;&#xA;Plugin 'vim-airline/vim-airline' &quot; Vim airline statusline&#xA;Plugin 'vim-airline/vim-airline-themes' &quot; Plugin &amp;amp; themes&#xA;&#xA;Plugin 'terryma/vim-multiple-cursors' &quot; Multile cursors editing&#xA;&#xA;Plugin 'flazz/vim-colorschemes' &quot; Colorschemes pack to rule them all&#xA;&#xA;Plugin 'scrooloose/nerdtree' &quot; File explorer&#xA;Plugin 'Xuyuanp/nerdtree-git-plugin' &quot; and its git support&#xA;&#xA;Plugin 'ryanoasis/vim-devicons' &quot; Icons for nerdtree&#xA;&#xA;Plugin 'dense-analysis/ale' &quot; Linter&#xA;&#xA;Plugin 'leafgarland/typescript-vim' &quot; Plugin to detect Typescript syntax&#xA;&#xA;Plugin 'ycm-core/YouCompleteMe' &quot; Autocomplete engine&#xA;&#xA;Plugin 'pangloss/vim-javascript' &quot; Better Javascript support&#xA;&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&quot; To ignore plugin indent changes, instead use:&#xA;&quot; filetype plugin on&#xA;&quot;&#xA;&quot; Brief help&#xA;&quot; :PluginList       - lists configured plugins&#xA;&quot; :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate&#xA;&quot; :PluginSearch foo - searches for foo; append `!` to refresh local cache&#xA;&quot; :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal&#xA;&quot;&#xA;&quot; see :h vundle for more details or wiki for FAQ&#xA;&quot; Put your non-Plugin stuff after this line&#xA;&quot; VUNDLE ENDS HERE&#xA;&quot;&#xA;set number  &quot; Show line numbers&#xA;set linebreak   &quot; Break lines at word (requires Wrap lines)&#xA;set showbreak=+++   &quot; Wrap-broken line prefix&#xA;set textwidth=80    &quot; Line wrap (number of cols)&#xA;set showmatch   &quot; Highlight matching brace&#xA;set visualbell  &quot; Use neither visual bell&#xA;set t_vb=   &quot; nor beeping&#xA;&#xA;set hlsearch    &quot; Highlight all search results&#xA;set smartcase   &quot; Enable smart-case search&#xA;set ignorecase  &quot; Always case-insensitive&#xA;set incsearch   &quot; Searches for strings incrementally&#xA;&#xA;set autoindent  &quot; Auto-indent new lines&#xA;set cindent &quot; Use 'C' style program indenting&#xA;set shiftwidth=4    &quot; Number of auto-indent spaces&#xA;set smartindent &quot; Enable smart-indent&#xA;set smarttab    &quot; Enable smart-tabs&#xA;set softtabstop=4   &quot; Number of spaces per Tab&#xA;&#xA;set ruler   &quot; Show row and column ruler information&#xA;&#xA;set undolevels=1000 &quot; Number of undo levels&#xA;set backspace=indent,eol,start  &quot; Backspace behaviour&#xA;&#xA;&quot; Colorscheme&#xA;set background=dark&#xA;syntax enable&#xA;colorscheme dracula&#xA;&#xA;&quot; Airline settings&#xA;set laststatus=2&#xA;set noshowmode&#xA;let g:airline_powerline_fonts = 1&#xA;let g:airline#extensions#tabline#enabled = 1&#xA;let g:airline#extensions#tabline#left_sep = ' '&#xA;let g:airline#extensions#tabline#left_alt_sep = '|'&#xA;let g:airline#extensions#tabline#formatter = 'default'&#xA;let g:airline_theme='dracula'&#xA;&#xA;&quot; Nerd tree config&#xA;map &amp;lt;C-x&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Split and tab settings&#xA;&quot; Switch between windows with CTRL + direction key&#xA;map &amp;lt;C-J&amp;gt; &amp;lt;C-W&amp;gt;j&#xA;map &amp;lt;C-K&amp;gt; &amp;lt;C-W&amp;gt;k&#xA;map &amp;lt;C-l&amp;gt; &amp;lt;C-W&amp;gt;l&#xA;map &amp;lt;C-h&amp;gt; &amp;lt;C-W&amp;gt;h&#xA;&#xA;&quot; Map next and previous tab&#xA;map &amp;lt;F9&amp;gt; :tabp&amp;lt;CR&amp;gt;&#xA;map &amp;lt;F10&amp;gt; :tabn&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Split more naturally&#xA;set splitbelow&#xA;set splitright&#xA;&quot; Linters of ALE&#xA;let g:airline#extensions#ale#enabled = 1&#xA;let g:ale_linters = {&#xA;\   'javascript': ['eslint'],&#xA;\   'typescript': ['tslint'],&#xA;\   'python': ['autopep8', 'flake8'],&#xA;\   'C': ['gcc'],&#xA;\   'C++': ['gcc']&#xA;\}&#xA;let g:ale_linters_explicit = 1&#xA;&quot; Searching&#xA;nnoremap / /\v&#xA;vnoremap / /\v&#xA;set hlsearch&#xA;set incsearch&#xA;set ignorecase&#xA;set smartcase&#xA;set showmatch&#xA;map &amp;lt;leader&amp;gt;&amp;lt;space&amp;gt; :let @/=''&amp;lt;cr&amp;gt; &quot; clear search&#xA;&#xA;&quot; Javascript indent&#xA;autocmd FileType javascript setlocal shiftwidth=2 tabstop=2 softtabstop=0 expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23562" LastActivityDate="2019-08-26T19:50:33.433" Title="Random characters appear in my buffer but they are not part of the current file" Tags="|buffers|macos|terminal-buffer|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21000" PostTypeId="2" ParentId="17984" CreationDate="2019-08-26T22:54:51.640" Score="1" Body="&lt;p&gt;Use &lt;a href=&quot;https://github.com/kassio/neoterm&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kassio/neoterm&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It provides A better terminal support. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the command &lt;code&gt;:&amp;lt;terminal number&amp;gt;Tclear&lt;/code&gt; to clear the terminal.&#xA;&lt;code&gt;:Tclear&lt;/code&gt; for the last opened/active terminal (not sure which). &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-08-26T22:54:51.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21001" PostTypeId="1" AcceptedAnswerId="21002" CreationDate="2019-08-27T00:23:50.380" Score="2" ViewCount="42" Body="&lt;p&gt;I am trying to combine several commands into a single mapping - (i) open a split window with a height of 15 lines, (ii) open an existing file in that window, (iii) move to the last line and char of that file, (iv) create a new blank line thereafter, (v) and enter insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This achieves (i) and (ii):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;n :15sp +$ $HOME/_notes/n0w&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried to extend upon it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;n :15sp +$A $HOME/path/to/file&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;n :15sp +$ +A $HOME/path/to/file&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;n :15sp +A +$  $HOME/path/to/file&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;n :15sp +GA  $HOME/path/to/file&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which has given the respective results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E464: ambiguous use of user-defined command +$A&#xA;+A $/HOME/path/to/file [NEW DIRECTORY]&#xA;+S $/HOME/path/to/file [NEW DIRECTORY]&#xA;E492: not an editor command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also tried similar variations with &lt;code&gt;+startinsert&lt;/code&gt; and &lt;code&gt;+normal&lt;/code&gt; but not getting the desired result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would greatly appreciate help.&lt;/p&gt;&#xA;" OwnerUserId="23294" LastActivityDate="2019-08-27T13:28:29.373" Title="mapping to open existing file in a split window, creates a blank last line, then enters insert mode" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21002" PostTypeId="2" ParentId="21001" CreationDate="2019-08-27T00:35:04.903" Score="1" Body="&lt;p&gt;No need to embed commands in the split. You can use multiple commands in a single mapping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;n :15sp $HOME/_notes/n0w&amp;lt;cr&amp;gt;Go&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After the split command is submitted with &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;, this being &lt;code&gt;nmap&lt;/code&gt; we can just specify Normal mode commands. Specifically, &lt;code&gt;G&lt;/code&gt; for step (iii) (go to end of file) and &lt;code&gt;o&lt;/code&gt; for steps (iv) and (v) (add a new line and enter Insert mode). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(An assist to @JürgenKrämer for a shorter command and subsequent revelation that I have config/plugin issues.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-08-27T13:28:29.373" LastActivityDate="2019-08-27T13:28:29.373" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21003" PostTypeId="2" ParentId="20708" CreationDate="2019-08-27T04:30:47.517" Score="0" Body="&lt;p&gt;The answer was in the vimpager initialization. Before it was stated that initialization of the plugin should be done by adding these lines in the &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vimpager = {}&#xA;let g:less = {}&#xA;let g:vimpager.passthrough = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But and the check for the &lt;code&gt;g:vimpager.enabled&lt;/code&gt; occured later in the VIMRC file. Obviously the value of &lt;code&gt;g:vimpager&lt;/code&gt; was reset by this point, rendering the check useless.&#xA;So the right way would be to write :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('g:vimpager')&#xA;    let g:vimpager = {}&#xA;endif&#xA;if !exists('g:less')&#xA;    let g:less = {}&#xA;endif&#xA;let g:vimpager.passthrough = 0&#xA;...&#xA;if !exists('g:vimpager.enabled')&#xA;    Plug 'dense-analysis/ale'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the disabling the inclusion of the Ale plugin completely - it speeds up the loading considerably, compared to just setting &lt;code&gt;let g:ale_enabled = 0&lt;/code&gt;.&#xA;The documentation for vimpager plugin was fixed in &lt;a href=&quot;https://github.com/rkitover/vimpager/commit/e887ecc0ec75102c27f4d582cb7ed53742f49cfe&quot; rel=&quot;nofollow noreferrer&quot;&gt; e887ecc &lt;/a&gt; commit.&lt;/p&gt;&#xA;" OwnerUserId="1515" LastActivityDate="2019-08-27T04:30:47.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21004" PostTypeId="1" CreationDate="2019-08-27T05:05:52.757" Score="4" ViewCount="2459" Body="&lt;p&gt;I am using &lt;code&gt;:grep&lt;/code&gt; to search for occurences of a string within a set of files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:grep rainbow *.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This result is then shown in the terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;doc1.txt:2:saw a rainbow today&#xA;doc2.txt:17:it was not a black rainbow&#xA;doc3.txt:7:most of those rainbow unicorns&#xA;(1 of 3): saw a rainbow today&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get back to Vim, I need to press &lt;kbd&gt;Enter&lt;/kbd&gt;. I don't want to have to press &lt;kbd&gt;Enter&lt;/kbd&gt;. Is there a way to prevent the prompt?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can do this to prevent the prompt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:silent :grep rainbow *.txt&#xA;:redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that's a lot of extra letters to have to type.&lt;/p&gt;&#xA;" OwnerUserId="19712" LastEditorUserId="11054" LastEditDate="2019-08-27T06:10:19.157" LastActivityDate="2022-04-11T05:18:06.287" Title="Prevent &quot;Press ENTER or type command to continue&quot; prompt after external command executes" Tags="|external-command|grep|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21005" PostTypeId="2" ParentId="21004" CreationDate="2019-08-27T05:34:30.313" Score="1" Body="&lt;p&gt;Well, you need to do a redraw...per &lt;a href=&quot;https://vimhelp.org/various.txt.html#:!cmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :!cmd&lt;/code&gt;&lt;/a&gt;...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This requires a hit-enter prompt, so that you can read any messages. To avoid this use &lt;code&gt;:silent !{cmd}&lt;/code&gt;. The screen is not redrawn then....&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But if you're simply looking to reduce the number of keys to press perhaps I can interest you in an 89% reduction of the second command. A single key combo...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;L&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...thus you have to use &lt;code&gt;CTRL-L&lt;/code&gt; or &lt;code&gt;:redraw!&lt;/code&gt; if the command did display something.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-08-27T06:13:17.113" LastActivityDate="2019-08-27T06:13:17.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21006" PostTypeId="1" AcceptedAnswerId="21007" CreationDate="2019-08-27T09:42:57.460" Score="7" ViewCount="3050" Body="&lt;p&gt;I can use &lt;code&gt;%&lt;/code&gt; to get the name of the focused window for commands. How can I get a space-separated list of &lt;strong&gt;all&lt;/strong&gt; buffers for use in a command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I would like to call&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!cat [all]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;[all]&lt;/code&gt; is something that evaluates to what I want.&lt;/p&gt;&#xA;" OwnerUserId="23564" LastEditorUserId="23564" LastEditDate="2019-08-27T11:28:44.517" LastActivityDate="2019-08-27T15:51:46.163" Title="How to get the names of all open buffers?" Tags="|command-line|external-command|multiple-files|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21007" PostTypeId="2" ParentId="21006" CreationDate="2019-08-27T11:25:15.817" Score="8" Body="&lt;p&gt;I suppose by &quot;open files&quot; you mean active buffers (see &lt;code&gt;:h windows-intro&lt;/code&gt;). That could be achieved with the command &lt;code&gt;:ls a&lt;/code&gt; (use &lt;code&gt;h&lt;/code&gt;-flag to get hidden buffers if needed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To pack it into a function you could use a redirection or a dedicated &lt;code&gt;getbufinfo()&lt;/code&gt; interface. For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetActiveBuffers()&#xA;    let l:blist = getbufinfo({'bufloaded': 1, 'buflisted': 1})&#xA;    let l:result = []&#xA;    for l:item in l:blist&#xA;        &quot;skip unnamed buffers; also skip hidden buffers?&#xA;        if empty(l:item.name) || l:item.hidden&#xA;            continue&#xA;        endif&#xA;        call add(l:result, shellescape(l:item.name))&#xA;    endfor&#xA;    return l:result&#xA;endfunction&#xA;&#xA;&quot; the result is a list&#xA;&quot; use join() when a single string is needed&#xA;&quot;:exec '!cat' join(GetActiveBuffers())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-08-27T15:51:46.163" LastActivityDate="2019-08-27T15:51:46.163" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21008" PostTypeId="1" AcceptedAnswerId="21009" CreationDate="2019-08-27T15:00:27.867" Score="3" ViewCount="267" Body="&lt;p&gt;I'm trying to write a function that will highlight searches performed with the &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;F&lt;/code&gt; keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently have a solution &lt;a href=&quot;https://stackoverflow.com/questions/57650449/highlight-f-key-searches-in-vim&quot;&gt;here&lt;/a&gt; thanks to @filbranden, but would like to further improve it to only activate highlighting upon using either the &lt;code&gt;f&lt;/code&gt; or &lt;code&gt;F&lt;/code&gt; keys, and disable it upon moving to a new line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A solution using &lt;code&gt;CursorMoved&lt;/code&gt; was proposed, but I'm pretty confused on how to use it and didn't see too much documentation at &lt;code&gt;:h CursorMoved&lt;/code&gt; (though I'm probably just not looking at the right spot)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seems pretty difficult to me, but I figured I'd ask anyway. Thanks for the help!&lt;/p&gt;&#xA;" OwnerUserId="13078" LastActivityDate="2019-08-27T15:40:55.613" Title="Register CursorMoved on certain key press and disable when move to new line" Tags="|cursor-movement|cursor-motions|highlight|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21009" PostTypeId="2" ParentId="21008" CreationDate="2019-08-27T15:40:55.613" Score="3" Body="&lt;p&gt;It's actually not that hard!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use CursorMoved for this purpose, you write a function that will check if you're still in the same line. If you're not, you can clear highlighting using &lt;code&gt;:match none&lt;/code&gt;. At the same time, you can &lt;em&gt;remove&lt;/em&gt; the &lt;code&gt;autocmd&lt;/code&gt; hook that has been calling you, so you don't get called again (until registered again.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example of such a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ClearHighlightOnMove()&#xA;  &quot; First check if we moved to another line.&#xA;  if line('.') !=# b:fsearch_line&#xA;    &quot; If we did, clear highlighting.&#xA;    match none&#xA;    &quot; Remove the CursorMoved autocmd.&#xA;    &quot; We don't need it anymore.&#xA;    au! fsearch_moved&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This might look a bit magical, until you see how it's registered...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It depends on having a variable store the line you're highlighting, which we store in a buffer variable &lt;code&gt;b:fsearch_line&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also clears an &lt;code&gt;augroup&lt;/code&gt; called &lt;code&gt;fsearch_moved&lt;/code&gt;, which presumably is the one for the &lt;code&gt;autocmd&lt;/code&gt; that triggers this function on CursorMoved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to set the buffer variable and register the &lt;code&gt;autocmd&lt;/code&gt;, which you should do in &lt;code&gt;HighlightFSearches()&lt;/code&gt; itself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HighlightFSearches(cmd)&#xA;  &quot; ...&#xA;&#xA;  &quot; Save the current line in a buffer variable.&#xA;  let b:fsearch_line = line('.')&#xA;&#xA;  &quot; Install a CursorMoved autocmd to track it.&#xA;  &quot; Use an augroup so we can easily clear it.&#xA;  augroup fsearch_moved&#xA;    au!&#xA;    au CursorMoved * call ClearHighlightOnMove()&#xA;  augroup END&#xA;&#xA;  &quot; ...&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, the overhead of calling a function (&lt;code&gt;ClearHighlightOnMove()&lt;/code&gt;) on every motion only exists while you're highlighting the matches and will be cleared as soon as you move away from that line!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What's still missing from your implementation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should consider adding support for the &lt;code&gt;t&lt;/code&gt; and &lt;code&gt;T&lt;/code&gt; commands, which are pretty similar to &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;F&lt;/code&gt; (in fact, only the &lt;code&gt;:map&lt;/code&gt; commands are missing to handle those.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to support &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt; as well, which will repeat the last &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt; or &lt;code&gt;T&lt;/code&gt; command, but this might happen on a different line, so you need to highlight the previously searched character in that case, which you don't have at that time!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use another buffer variable to store that character, whenever your hook for the other functions run. Make sure you handle the corner case where &lt;code&gt;;&lt;/code&gt; or &lt;code&gt;,&lt;/code&gt; are called &lt;em&gt;before&lt;/em&gt; the other functions were ever called (you can maybe check that with &lt;code&gt;exists()&lt;/code&gt; on the buffer variable.) If you translate &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt; back to &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt; or &lt;code&gt;T&lt;/code&gt; commands, you might want to store those in yet another buffer variable, and switch capitalization in case of &lt;code&gt;,&lt;/code&gt; which goes in the inverse direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you might want to move this from your &lt;code&gt;.vimrc&lt;/code&gt; to a plug-in, which simply means storing it in a file under &lt;code&gt;~/.vim/plugin/*.vim&lt;/code&gt; (see &lt;a href=&quot;https://vimhelp.org/usr_05.txt.html#add-plugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help add-plugin&lt;/code&gt;&lt;/a&gt; for more details.) A file in that location will be automatically loaded when Vim starts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One advantage of moving this from &lt;code&gt;.vimrc&lt;/code&gt; to a plug-in file is that you can use &lt;code&gt;s:&lt;/code&gt; to make your functions local to that file (see &lt;a href=&quot;https://vimhelp.org/eval.txt.html#script-variable&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help script-variable&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/map.txt.html#script-local&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help script-local&lt;/code&gt;&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-27T15:40:55.613" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21010" PostTypeId="2" ParentId="21004" CreationDate="2019-08-27T17:09:37.227" Score="9" Body="&lt;p&gt;If what you're looking for is a way to automate the sequence of commands (&lt;code&gt;:silent grep&lt;/code&gt; and &lt;code&gt;redraw!&lt;/code&gt;), then consider creating a new &lt;a href=&quot;https://vimhelp.org/map.txt.html#user-commands&quot; rel=&quot;noreferrer&quot;&gt;user-defined command&lt;/a&gt; for that operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In fact, Vim documentation essentially &lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#grep&quot; rel=&quot;noreferrer&quot;&gt;recommends it for this particular use case&lt;/a&gt; with their &lt;code&gt;NewGrep&lt;/code&gt; example.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My recommendation would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ -complete=file Grep&#xA;    \ execute 'silent grep! &amp;lt;args&amp;gt;' | redraw! | cfirst&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Define &lt;code&gt;:Grep&lt;/code&gt; as the new command.&lt;/li&gt;&#xA;&lt;li&gt;Sets up command completion to search for files, which matches the type of completion available for &lt;code&gt;:grep&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:silent&lt;/code&gt; and &lt;code&gt;:redraw!&lt;/code&gt; as expected.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:grep!&lt;/code&gt; and jump to the first target explicitly with &lt;code&gt;cfirst&lt;/code&gt;. This is done so you'll see the line &lt;code&gt;(1 of 3): saw a rainbow today&lt;/code&gt; after jumping to the first result.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you like to work with the quickfix window most of the time, consider using &lt;code&gt;copen&lt;/code&gt; instead of &lt;code&gt;cfirst&lt;/code&gt; to open that window directly.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-27T17:09:37.227" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21012" PostTypeId="2" ParentId="12140" CreationDate="2019-08-27T17:56:50.750" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;:nnoremap &amp;lt;Down&amp;gt; &amp;lt;Nop&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;:nnoremap &amp;lt;Up&amp;gt; &amp;lt;Nop&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;does the trick (in conjunction with :set mouse=).  Of course, you can't use the arrow keys any more, but if you're using vim, you didn't care anyway.&#xA;Edit: Need to this in insert mode too, so add the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:inoremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;:inoremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="23573" LastEditorUserId="23573" LastEditDate="2019-08-27T18:42:38.107" LastActivityDate="2019-08-27T18:42:38.107" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21013" PostTypeId="2" ParentId="373" CreationDate="2019-08-27T19:51:16.593" Score="3" Body="&lt;p&gt;For the benefit of everyone, &lt;code&gt;incsearch&lt;/code&gt; was updated in vim8 to also show preview as you type the pattern&lt;/p&gt;&#xA;" OwnerUserId="74" LastActivityDate="2019-08-27T19:51:16.593" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21015" PostTypeId="1" CreationDate="2019-08-28T09:45:27.077" Score="2" ViewCount="87" Body="&lt;p&gt;Note: I am fairly new to NeoVim. So far I have installed plugins by simply unzipping the plug-in master folder into the directory &lt;code&gt;/usr/share/nvim/runtime/plugin&lt;/code&gt;. In case there is no master folder I just move the pluginname.vim file to this directory. It has worked well until now.&lt;/p&gt;&#xA;&lt;p&gt;I am trying to install the &lt;a href=&quot;https://github.com/raghur/vim-ghost&quot; rel=&quot;nofollow noreferrer&quot;&gt;GhostText plugin&lt;/a&gt; which goes with the &lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/ghosttext/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GhostText extension for Firefox&lt;/a&gt;. I did it as before, by simply unzipping the plug-in master folder into the directory &lt;code&gt;/usr/share/nvim/runtime/plugin&lt;/code&gt;, so that now I have a directory called &lt;code&gt;vim-ghost-master&lt;/code&gt; in that directory.&lt;/p&gt;&#xA;&lt;p&gt;When I run a nvim session and run the command &lt;code&gt;:GhostInstall&lt;/code&gt; (which does autocomplete), I get the following error:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YH8Dp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YH8Dp.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;What should I do?&lt;/p&gt;&#xA;" OwnerUserId="22616" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2021-01-19T13:04:15.443" Title=":GhostInstall does not work" Tags="|installing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21016" PostTypeId="2" ParentId="21015" CreationDate="2019-08-28T10:40:38.927" Score="1" Body="&lt;p&gt;Just use &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#packages&quot; rel=&quot;nofollow noreferrer&quot;&gt;packages&lt;/a&gt; to install Vim plug-ins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply create a directory &lt;code&gt;~/.vim/pack/&lt;i&gt;something&lt;/i&gt;/start&lt;/code&gt;, where &quot;something&quot; is literally anything, perhaps use your nickname &quot;Soap&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then unpack or git clone the plug-in tree there, so you get &lt;code&gt;~/.vim/pack/Soap/start/vim-ghost-master&lt;/code&gt; and then you get the plug-in directories (&lt;code&gt;autoload&lt;/code&gt;, &lt;code&gt;plugin&lt;/code&gt;, &lt;code&gt;python3&lt;/code&gt;) all there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would probably fix the plug-in, since it looks like it's failing to find the Python code, most likely because it's expecting to find it at the root of a plug-in directory, rather than somewhere inside a subdirectory of &lt;code&gt;plugin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're writing to the system location because you want the plug-in to be available to all users in your system, you can still use packages, just use the appropriate location, which it seems would be &lt;code&gt;/usr/share/nvim/site/pack&lt;/code&gt; in NeoVim (&lt;code&gt;/usr/share/vim/vimfiles/pack&lt;/code&gt; in Vim 8), and same scheme of creating a subdir (any name) and then &lt;code&gt;start/&lt;/code&gt; under it. (See &lt;code&gt;:help 'packpath'&lt;/code&gt; and &lt;code&gt;:help 'runtimepath'&lt;/code&gt; for more information on these paths.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-28T10:40:38.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21017" PostTypeId="1" AcceptedAnswerId="21018" CreationDate="2019-08-28T10:54:48.647" Score="2" ViewCount="970" Body="&lt;p&gt;I am relatively new to vim. I made my &lt;code&gt;.vimrc&lt;/code&gt; file watching different tutorial in order to use vim mainly as a python IDE. I am using &lt;code&gt;pathogen&lt;/code&gt; as plugin manager and I have recently installed &lt;code&gt;python-mode&lt;/code&gt;. However when typying &lt;code&gt;:Helptags pymode&lt;/code&gt; or &lt;code&gt;:Helptags NerdTree&lt;/code&gt; I get: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E488: Trailing characters&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suspect something is not right with my &lt;code&gt;.vimrc&lt;/code&gt;..Here is what I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1 &quot; Enable syntax highlight&#xA; 0 syntax on&#xA; 1 let python_highlight_all=1&#xA; 2 &quot; Highlight your search&#xA; 3 set hlsearch&#xA; 4 set number relativenumber&#xA; 5 &quot; Rebind &amp;lt;Leader&amp;gt; Key&#xA; 6 let mapleader = &quot;,&quot;&#xA; 7 &#xA; 8 noremap &amp;lt;Leader&amp;gt;l :nohl&amp;lt;CR&amp;gt;&#xA; 9 &#xA; 10 &quot; Quicksave command&#xA; 11 noremap &amp;lt;Leader&amp;gt;m :update&amp;lt;CR&amp;gt;&#xA; 12 &#xA; 13 &quot; Quickquit command&#xA; 14 noremap &amp;lt;Leader&amp;gt;e :quit&amp;lt;CR&amp;gt; &quot;Quit current wind&#xA; 15 noremap &amp;lt;Leader&amp;gt;E :qa!&amp;lt;CR&amp;gt; &quot;Quit all wind&#xA; 16 nnoremap &amp;lt;leader&amp;gt;b :ls&amp;lt;cr&amp;gt;:b&amp;lt;space&amp;gt;&#xA; 17 &#xA; 18 &#xA; 19 execute pathogen#infect()&#xA; 20 call pathogen#helptags()&#xA; 21 &#xA; 22 filetype plugin indent on&#xA; 23 set number&#xA; 24 &#xA; 25 &quot; Setting vim-colors-solarized&#xA; 26 &quot; cd ~/.vim/bundle&#xA; 27 &quot; git clone git://github.com/altercation/vim-colors-solarized.git&#xA; 28 &quot; It worked with this: cp .vim/bundle/solarized/vim-colors-solarized  /colors/solarized.vim ~/.vim/colors/&#xA; 29 let g:solarized_termcolors=256&#xA; 30 set t_Co=256&#xA; 31 set background=dark&#xA; 32 &quot; Highlight useless white spaces&#xA; 33 autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red&#xA; 34 au InsertLeave * match ExtraWhitespace /\s\+$/&#xA; 35 colorscheme solarized&#xA; 36 &#xA; 37 let g:pymode_python='python3'&#xA; 38 &#xA; 39 &quot; Setting for NERDTree&#xA; 40 &quot; cd ~/.vim/bundle&#xA; 41 &quot; git clone https://github.com/scrooloose/nerdtree.git&#xA; 42 &quot; toggle NERDtree&#xA; 43 map &amp;lt;Leader&amp;gt;n :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can somebody help me out? Thanks&lt;/p&gt;&#xA;" OwnerUserId="23580" LastActivityDate="2019-08-28T13:49:12.713" Title="Helptags gives: E488: Trailing characters" Tags="|vimrc|plugin-pathogen|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21018" PostTypeId="2" ParentId="21017" CreationDate="2019-08-28T11:20:10.213" Score="1" Body="&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; It looks like you were trying to get help on plug-ins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that, you can simply call &lt;code&gt;:help&lt;/code&gt;. Vim will look for help files in the plug-in directories, so something like &lt;code&gt;:help pymode&lt;/code&gt; will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you build the help tags for plug-ins (for instance, with the &lt;code&gt;:Helptags&lt;/code&gt; command of pathogen, or &lt;code&gt;:helptags ALL&lt;/code&gt; if you're simply using &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#packages&quot; rel=&quot;nofollow noreferrer&quot;&gt;packages&lt;/a&gt;), then the commands and bindings of plug-ins will be available through the help system as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, you'll be able to use &lt;code&gt;:help :NERDTreeToggle&lt;/code&gt; to get help on that specific command of the NERDTree plug-in.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You should call &lt;code&gt;:Helptags&lt;/code&gt; on its own, without any additional arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point of &lt;code&gt;:Helptags&lt;/code&gt; in vim-pathogen is that it will figure out which plugins have &lt;code&gt;doc/&lt;/code&gt; directories that need help tags generated, and generate them for all of those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;https://github.com/tpope/vim-pathogen/blob/master/README.markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;README&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Normally to generate documentation, Vim expects you to run &lt;code&gt;:helptags&lt;/code&gt; on each directory with documentation (e.g., &lt;code&gt;:helptags ~/.vim/doc&lt;/code&gt;). Provided with pathogen.vim is a &lt;code&gt;:Helptags&lt;/code&gt; command that does this on every directory in your &lt;code&gt;'runtimepath'&lt;/code&gt;. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also consider just using &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#packages&quot; rel=&quot;nofollow noreferrer&quot;&gt;packages&lt;/a&gt; instead of pathogen, if you're using Vim 8 or later, or NeoVim. Packages are built-in to Vim and work very similarly to how pathogen does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use native packages, then you can use &lt;a href=&quot;https://vimhelp.org/helphelp.txt.html#%3Ahelptags&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:helptags ALL&lt;/code&gt;&lt;/a&gt; to create tags for all your plug-ins (so you don't need pathogen's &lt;code&gt;:Helptags&lt;/code&gt; either.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pathogen itself recommends using packages instead. From the &lt;a href=&quot;https://github.com/tpope/vim-pathogen/blob/master/README.markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;README&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;For new users, I recommend using Vim's built-in package management instead.&lt;/strong&gt; &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#packages&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help packages&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-08-28T13:49:12.713" LastActivityDate="2019-08-28T13:49:12.713" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21019" PostTypeId="1" AcceptedAnswerId="21020" CreationDate="2019-08-28T11:59:25.343" Score="6" ViewCount="1786" Body="&lt;p&gt;When I use MS Windows version gvim, when typing EX-command, I can press TAB then there will show a completion candidates menu.&lt;br&gt;&#xA;For example, if I type &lt;code&gt;:colorscheme&lt;/code&gt; then a space then press TAB, gvim prompts menu like below:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/438mp.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/438mp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I use Linux version gvim, it just automatically type in one of candidates, no menu shows. &lt;br&gt;&#xA;How to set up my vim configuration to use this completion menu? &lt;/p&gt;&#xA;" OwnerUserId="23584" LastActivityDate="2019-08-28T13:30:37.070" Title="How to show completion menu when typing EX-command?" Tags="|command-line|autocompletion|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21020" PostTypeId="2" ParentId="21019" CreationDate="2019-08-28T13:23:51.837" Score="6" Body="&lt;p&gt;Thanks for the answer from @D. Ben Knoble&lt;br&gt;&#xA;&lt;br&gt;&#xA;This feature is called &lt;em&gt;wildmenu&lt;/em&gt;, putting this line &lt;code&gt;set wildmenu&lt;/code&gt; in the .vimrc or .gvimrc (_vimrc or _gvimrc on MS Windows version) can turn this feature on.&lt;br&gt;&#xA;&lt;br&gt;&#xA;Typing &lt;code&gt;:help wildmenu&lt;/code&gt; in vim to check further detail of wildmenu.&lt;/p&gt;&#xA;" OwnerUserId="23584" LastEditorUserId="23584" LastEditDate="2019-08-28T13:30:37.070" LastActivityDate="2019-08-28T13:30:37.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21022" PostTypeId="1" CreationDate="2019-08-28T20:08:21.817" Score="1" ViewCount="61" Body="&lt;p&gt;I'm in the habit of just hitting alt+[whatever] when I want to exit of insert mode (esc is just too far away - it's the one thing I can't for the life of me understand about vi/vim/etc.). This works, if I remember right, because the terminal translates this as an esc char, and then the following char.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm using a plugin for python. I have little code completion popup menus while I'm typing all the time. If I hit alt-j, or whatever, while a popup menu is open it closes the menu, types j and &lt;em&gt;doesn't&lt;/em&gt; exit insert mode. Hitting esc always works. This is really messing with my muscle memory. Any idea why the alt trick doesn't work in this case?&lt;/p&gt;&#xA;" OwnerUserId="20985" LastActivityDate="2021-05-19T23:05:20.670" Title="Using &lt;alt&gt; as alternative to &lt;esc&gt; doesn't work when popup menus are open" Tags="|neovim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21023" PostTypeId="2" ParentId="21022" CreationDate="2019-08-28T21:42:04.573" Score="1" Body="&lt;p&gt;Ok, I guess I should not rely on how alt is interpreted? Formalizing my alt-movement as escape habit as a mapping gave me back consistent behavior. I put the following in vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; exit by using alt-movement&#xA;imap &amp;lt;m-j&amp;gt; &amp;lt;esc&amp;gt;j&#xA;imap &amp;lt;m-k&amp;gt; &amp;lt;esc&amp;gt;k&#xA;imap &amp;lt;m-h&amp;gt; &amp;lt;esc&amp;gt;h&#xA;imap &amp;lt;m-l&amp;gt; &amp;lt;esc&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20985" LastActivityDate="2019-08-28T21:42:04.573" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21024" PostTypeId="2" ParentId="17074" CreationDate="2019-08-28T22:20:30.423" Score="0" Body="&lt;p&gt;This command GL meant to run python on a matched group. In this case, we run a search on the matched pattern.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('python3')&#xA;    command! -nargs=* -range PY &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;python3 &amp;lt;args&amp;gt;&#xA;elseif has('python')&#xA;    command! -nargs=* -range PY &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;python &amp;lt;args&amp;gt;&#xA;endif &#xA;&#xA;function! RunPython2(match,run)&#xA;PY &amp;lt;&amp;lt; EOF&#xA;import vim&#xA;try:&#xA;    match=vim.eval(&quot;a:match&quot;)&#xA;    retval=eval(vim.eval(&quot;a:run&quot;),globals())&#xA;except Exception as e:&#xA;    import traceback&#xA;    exp=traceback.format_exc()&#xA;    retval=None&#xA;    try:&#xA;        vim.command(&quot;echom \&quot;&quot; + str(exp).replace(&quot;\&quot;&quot;,&quot;\\\&quot;&quot;) + &quot;\&quot;&quot;)&#xA;    except:&#xA;        pass&#xA;&#xA;if retval==None: retval=match&#xA;vim.command(&quot;let retInVim=\&quot;&quot; + str(retval).replace(&quot;\&quot;&quot;,&quot;\\\&quot;&quot;) + &quot;\&quot;&quot;)&#xA;EOF&#xA;return retInVim&#xA;endfunction&#xA;&#xA;function! RunPython(match,run)&#xA;PY &amp;lt;&amp;lt; EOF&#xA;import vim&#xA;try:&#xA;    match=vim.eval(&quot;a:match&quot;)&#xA;    vim.command(' exec &quot;PY &quot; . a:run')&#xA;except Exception as e:&#xA;    import traceback&#xA;    exp=traceback.format_exc()&#xA;    try:&#xA;        vim.command(&quot;echom \&quot;&quot; + str(exp).replace(&quot;\&quot;&quot;,&quot;\\\&quot;&quot;) + &quot;\&quot;&quot;)&#xA;    except:&#xA;        pass&#xA;EOF&#xA;return &quot;&quot;&#xA;endfunction&#xA;&#xA;function! GL(arg) range&#xA;    let lst=matchlist(a:arg,'/\(.\{-\}\)/\(.\{-}\) \(.*\)$')&#xA;    if lst[2]==#&quot;rpy&quot;&#xA;        exec a:firstline. &quot;,&quot; . a:lastline . &quot;:s\/&quot; . lst[1] . &quot;/\\=RunPython2(submatch(1),\&quot;&quot;. escape(lst[3],&quot;\&quot;//&quot;) . &quot;\&quot;)&quot;&#xA;    elseif lst[2]==#&quot;py&quot;&#xA;        exec a:firstline. &quot;,&quot; . a:lastline . &quot;:s\/&quot; . lst[1] . &quot;/\\=submatch(0) . RunPython(submatch(1),\&quot;&quot;. escape(lst[3],&quot;\&quot;//&quot;) . &quot;\&quot;)&quot;&#xA;    endif&#xA;endfunction&#xA;&#xA;command! -nargs=1 -range GL &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call GL(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To execute: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%GL/pattern/py vim.command('call feedkeys(&quot;/'+match+'\\&amp;lt;CR&amp;gt;&quot;)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Be aware of some nasty escaping in the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It assume only one pattern found to be highlighted (or it will highlight the last one).&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-08-28T22:26:33.583" LastActivityDate="2019-08-28T22:26:33.583" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21026" PostTypeId="1" CreationDate="2019-08-29T03:06:07.973" Score="3" ViewCount="361" Body="&lt;p&gt;I have found myself so extraordinarily frustrated with Vim's &lt;code&gt;foldmethod=syntax&lt;/code&gt; behavior that I've contemplated dropping the editor entirely, despite being &lt;em&gt;mostly&lt;/em&gt; happy with it for a few years now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I &lt;em&gt;want&lt;/em&gt; is for the editor to not completely throw away the fold-state of individual lines, despite fold-levels changing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a related question here: &lt;a href=&quot;https://stackoverflow.com/questions/21280457/stop-vim-from-dynamically-updating-folds&quot;&gt;https://stackoverflow.com/questions/21280457/stop-vim-from-dynamically-updating-folds&lt;/a&gt;. The difference between this question and that one is that here I want to handle the following case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    stuff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;-&gt; fold in the braces -&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+- { .. }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;-&gt; enter insert mode and type &lt;code&gt;{ other stuff&lt;/code&gt; at the top -&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ other stuff&#xA;+- { .. }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;-&gt; leave insert mode -&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;what happens&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ other stuff&#xA;{&#xA;    stuff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;what I want&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ other stuff&#xA;+- { .. }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, ideally this would just be a simple configuration switch. I haven't found such a switch in the docs, but would &lt;em&gt;love&lt;/em&gt; for someone to point at something simple.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;my (very incomplete) attempt&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I otherwise &lt;em&gt;think&lt;/em&gt; that I could achieve what I want if I could keep my &lt;code&gt;foldmethod=manual&lt;/code&gt;, but do the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;on insert enter&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;for all lines, save whether or not the line is folded away (ignore their actual foldlevels)&lt;/li&gt;&#xA;&lt;li&gt;save a copy of the buffer's contents&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;on insert leave&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;set the foldlevels for all lines to whatever they should be for &lt;code&gt;foldmethod=syntax&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;diff the current buffer with the pre-insert buffer and use it to generate a partial map from line numbers in the post-insert buffer to the pre-insert buffer&lt;/li&gt;&#xA;&lt;li&gt;set whether or not a fold is folded based on whether or not any of the post-insert line numbers in that fold, when mapped to their pre-insert line numbers, were previously folded&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Depending on how the diff map is calculated this could inadvertently fold the current line, but I think I'd take that trade if I could keep the folds later in the file from flying open. If it ever became an annoyance I'm pretty sure some additional machinery could be added to force the highest foldlevels occupied by unmapped post-insert lines to stay open.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Having said all that...&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I don't know vimscript, and my experience with ad hoc languages leaves me dreading the possibility. I &lt;em&gt;think&lt;/em&gt; I'd be more willing to try it if quick individual ingredients were guaranteed to exist. My problems with this attempt are that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I don't know if there's a simple way to get the pre-insert/post-insert diff (or to just have vim provide me with a line-number map pre-insert vs. post-insert)&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I don't know if there's a way to backup whole buffers&lt;/li&gt;&#xA;&lt;li&gt;I don't know how to get a programmatic representation of the diff&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;I don't know how to retrieve whether or not lines are folded for each line&lt;/li&gt;&#xA;&lt;li&gt;I don't know how to set the foldlevels of all lines to what they would be for &lt;code&gt;foldmethod=syntax&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I don't know how to &lt;em&gt;retrieve&lt;/em&gt; those foldlevels without necessarily setting &lt;code&gt;foldmethod=syntax&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;I don't know how to, leaving foldlevel immutable, &lt;em&gt;set&lt;/em&gt; the fold state of particular lines&lt;/li&gt;&#xA;&lt;li&gt;I don't know if vim treats folds &lt;em&gt;implicitly&lt;/em&gt; (as in, the abstraction used in &lt;code&gt;foldmethod=expr&lt;/code&gt; is its internal representation) or &lt;em&gt;explicitly&lt;/em&gt; (as in there are explicit objects that represent folds that can be manipulated)&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If explicit I obviously don't know what those objects are&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And my biggest, biggest concern:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I can't figure out how the flip to RTFM for this; where are the vim functions for folding? All I can find are keyboard commands.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19896" LastActivityDate="2020-01-26T07:02:50.400" Title="Record all line-number fold-levels and restore fold-states (despite fold-level change)" Tags="|vimscript|folding|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21027" PostTypeId="2" ParentId="21026" CreationDate="2019-08-29T05:21:25.090" Score="1" Body="&lt;p&gt;What you might have not found that you're missing are the three functions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/eval.txt.html#foldclosed%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;foldclosed()&lt;/code&gt;&lt;/a&gt;: If the line is in a closed fold, the result is the number of the first line in that fold. If the line is not in a closed fold, -1 is returned.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/eval.txt.html#foldclosedend%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;foldclosedend()&lt;/code&gt;&lt;/a&gt;: Similar, but return the last line of a closed fold.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/eval.txt.html#foldlevel%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;foldlevel()&lt;/code&gt;&lt;/a&gt;: The fold level of a line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;foldclosed()&lt;/code&gt;, you can tell whether a line is in a closed fold or not. Using &lt;code&gt;foldclosedend()&lt;/code&gt; you can jump to the next line after this fold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you keep &lt;code&gt;'foldmethod'&lt;/code&gt; set to &lt;code&gt;manual&lt;/code&gt;, you &lt;em&gt;might&lt;/em&gt; get away with only having to check the status of folds after you leave insert mode. Then apply &lt;code&gt;setlocal foldmethod=syntax&lt;/code&gt;, back to &lt;code&gt;manual&lt;/code&gt; and compare to what you had before. (If you don't need to map it before entering insert mode, you won't have to adjust line offsets to compensate for the insertion.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this step, you can also check &lt;code&gt;foldlevel()&lt;/code&gt; before and after switching to &lt;code&gt;syntax&lt;/code&gt; and back, so you'll see which blocks were now shifted due to possibly unbalanced braces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to consider other fold methods, such as a &lt;code&gt;'foldexpr'&lt;/code&gt; mainly taking indentation into consideration, but with additional considerations for the closing &lt;code&gt;}&lt;/code&gt; and the starting function prototype. A method based in &lt;code&gt;'foldexpr'&lt;/code&gt; and using primarily indentation should be much more stable to insertions and edits than the &lt;code&gt;syntax&lt;/code&gt; fold method, which might save you some grief.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/49.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Advanced Folding&quot;&lt;/a&gt; from &quot;Learn Vimscript the Hard Way&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-29T05:21:25.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21028" PostTypeId="1" CreationDate="2019-08-29T10:51:43.857" Score="2" ViewCount="849" Body="&lt;h1&gt;Situation&lt;/h1&gt;&#xA;&lt;p&gt;I have a large, hierarchical json file with many single entries, like so:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-json prettyprint-override&quot;&gt;&lt;code&gt;       {&#xA;          &amp;quot;tokens&amp;quot;: [&#xA;            &amp;quot;payload, a string&amp;quot;&#xA;          ],&#xA;          &amp;quot;values&amp;quot;: [&#xA;            {&#xA;              &amp;quot;value&amp;quot;: &amp;quot;frong zshok blam flarb&amp;quot;&#xA;            }&#xA;          ]&#xA;        },&#xA;        {&#xA;          &amp;quot;tokens&amp;quot;: [&#xA;            &amp;quot;another token&amp;quot;&#xA;          ],&#xA;          &amp;quot;values&amp;quot;: [&#xA;            {&#xA;              &amp;quot;value&amp;quot;: &amp;quot;another important string&amp;quot;&#xA;            }&#xA;          ]&#xA;        },&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;so there are lots of empty lines with brackets and parentheses.&lt;/p&gt;&#xA;&lt;h1&gt;Question:&lt;/h1&gt;&#xA;&lt;p&gt;How can I have json formatted to only use line breaks after &lt;code&gt;:&lt;/code&gt; or &lt;code&gt;,&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;p&gt;What I'm hoping for is something like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-json prettyprint-override&quot;&gt;&lt;code&gt;{ &amp;quot;tokens&amp;quot;: &#xA;    [ &amp;quot;&amp;lt;foo.barbaz&amp;gt;&amp;quot; ],&#xA;  &amp;quot;values&amp;quot;: &#xA;    [ { &amp;quot;value&amp;quot;: &amp;quot;&amp;lt;frong gronk shoop blurb&amp;gt;&amp;quot; } ] },&#xA;{ &amp;quot;tokens&amp;quot;: &#xA;    [ &amp;quot;&amp;lt;a string&amp;gt;&amp;quot; ],&#xA;      &amp;quot;values&amp;quot;: &#xA;    [ { &amp;quot;value&amp;quot;: &amp;quot;&amp;lt;another string&amp;gt;&amp;quot; } ] },&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Pretty indentation to have contents of [] {} () aligned would be a bonus.&lt;/p&gt;&#xA;&lt;p&gt;Whether this is done via external tool or vim plugin, I wouldn't mind either.&lt;/p&gt;&#xA;" OwnerUserId="23604" LastEditorUserId="25" LastEditDate="2023-09-10T04:21:06.283" LastActivityDate="2024-02-07T06:02:05.247" Title="Format sparse json files for legibility" Tags="|formatting|filetype-json|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21029" PostTypeId="1" CreationDate="2019-08-29T12:10:38.053" Score="2" ViewCount="420" Body="&lt;p&gt;When editing Typescript neovim automatically sets &lt;code&gt;indentexpr=GetTypescriptIndent()&lt;/code&gt;. I don't like the way it aligns to&#xA;an open brace instead of inserting a (soft) tab or two, but it doesn't seem to be configurable. I tried adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType javascript,typescript setlocal cindent indentexpr&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to my init.vim but it hasn't made any difference; &lt;code&gt;indentexpr&lt;/code&gt; is still set to &lt;code&gt;GetTypescriptIndent()&lt;/code&gt; when I edit typescript files. How can I get my autocmd to override whatever typescript.vim does? &lt;/p&gt;&#xA;" OwnerUserId="12044" LastActivityDate="2019-08-30T13:24:14.200" Title="Override indentation settings with autocmd" Tags="|indentation|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21030" PostTypeId="2" ParentId="21029" CreationDate="2019-08-29T13:12:30.430" Score="4" Body="&lt;p&gt;To override settings, you need to use the &lt;code&gt;after&lt;/code&gt; directory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, we need to know whether to use &lt;code&gt;after/indent&lt;/code&gt; or &lt;code&gt;after/ftplugin&lt;/code&gt;—use &lt;code&gt;:verbose set &amp;lt;options we care about&amp;gt;?&lt;/code&gt; to find where they were last set, and pay attention to whether it was in the &lt;code&gt;ftplugin&lt;/code&gt; or &lt;code&gt;indent&lt;/code&gt; directory. We expect it to be &lt;code&gt;indent&lt;/code&gt; in this case, but sometimes people do strange things. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming we need to override an &lt;code&gt;indent&lt;/code&gt; file, we place&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal indentexpr=&#xA;setlocal cindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;~/.vim/after/indent/javascript.vim&lt;/code&gt; (ditto for &lt;code&gt;typescript&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don’t forget to read about &lt;code&gt;b:undo_ftplugin&lt;/code&gt; and &lt;code&gt;b:undo_indent&lt;/code&gt;—they will need to be set properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To quote from &lt;code&gt;:h undo_indent&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When the user does &quot;:setfiletype xyz&quot; the effect of the previous filetype&#xA;should be undone.  Set the b:undo_ftplugin variable to the commands that will&#xA;undo the settings in your filetype plugin.&#xA;...&#xA;For undoing the effect of an indent script, the b:undo_indent variable should&#xA;be set accordingly.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, we'll need to append&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'setlocal indentexpr&amp;lt; cindent&amp;lt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;code&gt;b:undo_indent&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:undo_indent = get(b:, 'undo_indent', '')&#xA;if !empty(b:undo_indent)&#xA;  let b:undo_indent .= '|'&#xA;endif&#xA;let b:undo_indent .= 'setlocal indentexpr&amp;lt; cindent&amp;lt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-08-30T13:24:14.200" LastActivityDate="2019-08-30T13:24:14.200" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21031" PostTypeId="2" ParentId="6258" CreationDate="2019-08-29T16:41:09.517" Score="0" Body="&lt;p&gt;Use &lt;code&gt;:Ve&lt;/code&gt; or &lt;code&gt;:Se&lt;/code&gt; to open the file explorer in a new vertical or horizontal split, respectively.&lt;/p&gt;&#xA;" OwnerUserId="23608" LastActivityDate="2019-08-29T16:41:09.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21032" PostTypeId="1" CreationDate="2019-08-29T16:47:41.550" Score="1" ViewCount="94" Body="&lt;p&gt;I found a whole bunch of green &lt;code&gt;^\&lt;/code&gt; characters in the file I have open in vim...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea what control character they are?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And how would I search for them in grep?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2019-08-29T18:17:08.657" Title="What control character is ^\ in the buffer in a file open in vim?" Tags="|gvim|control-character|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21033" PostTypeId="2" ParentId="21032" CreationDate="2019-08-29T18:08:37.853" Score="2" Body="&lt;p&gt;If it is indeed a single character, it’s likely to be &lt;code&gt;&amp;lt;C-\&amp;gt;&lt;/code&gt;. You can use &lt;code&gt;ga&lt;/code&gt; to get the ascii, octal, etc., versions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;grep(1)&lt;/code&gt;, most shells (my bash, at least) will let you input literals with &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; much like vim. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-08-29T18:08:37.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21034" PostTypeId="2" ParentId="21032" CreationDate="2019-08-29T18:17:08.657" Score="2" Body="&lt;p&gt;File Separator, code point 28, or 0x1C, originally used to delimit data structures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you cannot type it with &lt;code&gt;Ctrl+\&lt;/code&gt;, you can use alt codes if you have a number pad on your keyboard. Type &lt;code&gt;Alt+28&lt;/code&gt; and you should get something that looks like this: ∟ You must use your number pad, the keys above the letter keys will not work. If your keyboard doesn't have a number pad, you can copy-paste the character from here: &lt;code&gt;∟&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="23610" LastActivityDate="2019-08-29T18:17:08.657" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21035" PostTypeId="1" AcceptedAnswerId="21043" CreationDate="2019-08-30T10:30:48.963" Score="1" ViewCount="129" Body="&lt;p&gt;I have a shortcut in my vimrc to search for a string through my repository:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;gg :vimgrep // **/*.py \| clist&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want the cursor to be between the &lt;code&gt;//&lt;/code&gt; characters ready for a search term when I invoke the shortcut. I can do this with 18 &lt;code&gt;&amp;lt;Left&amp;gt;&lt;/code&gt;s but that is very long and ugly i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;... .py \| clist&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;.....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I see I can also use &lt;code&gt;&amp;lt;C-Left&amp;gt;&lt;/code&gt; which is shorter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;... .py \| clist&amp;lt;C-Left&amp;gt;&amp;lt;C-Left&amp;gt;&amp;lt;C-Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there another way to repeat 18  actions without such a long list of &lt;code&gt;&amp;lt;Left&amp;gt;&lt;/code&gt; in a mapping's definition?&lt;/p&gt;&#xA;" OwnerUserId="22557" LastActivityDate="2019-09-02T13:18:58.423" Title="Moving the cursor a large number of times in a nnoremap" Tags="|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21036" PostTypeId="2" ParentId="14714" CreationDate="2019-08-30T10:40:08.913" Score="0" Body="&lt;p&gt;I installed &lt;a href=&quot;https://gist.github.com/ds26gte/034b9ac9edeaf86d0ff5c73f97dd530b&quot; rel=&quot;nofollow noreferrer&quot;&gt;this script&lt;/a&gt;. It does the job, but the presented message is a general one. That may be confusing&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2019-08-30T10:40:08.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21037" PostTypeId="1" CreationDate="2019-08-30T12:17:56.770" Score="3" ViewCount="56" Body="&lt;p&gt;I have two Ubuntu Linux 18.04.3 LTS systems, both have &lt;code&gt;vim&lt;/code&gt; identify itself as &quot;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 06 2019 17:31:41)&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the systems supports the &lt;code&gt;vim -x&lt;/code&gt; option, the other one does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How is that possible?&lt;/p&gt;&#xA;" OwnerUserId="23617" LastEditorUserId="18609" LastEditDate="2019-08-30T14:34:07.440" LastActivityDate="2019-08-30T14:35:38.993" Title="Support of the -x option" Tags="|encryption|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21038" PostTypeId="2" ParentId="21037" CreationDate="2019-08-30T12:55:58.127" Score="3" Body="&lt;p&gt;On one system, &lt;code&gt;vim&lt;/code&gt; is a symbolic link to &lt;code&gt;vim.basic&lt;/code&gt;, on the other it is a symbolic link to &lt;code&gt;vim.tiny&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim.basic&lt;/code&gt; supports the &lt;code&gt;-x&lt;/code&gt; option.&#xA;&lt;code&gt;vim.tiny&lt;/code&gt; doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem solved.&lt;/p&gt;&#xA;" OwnerUserId="23617" LastEditorUserId="18609" LastEditDate="2019-08-30T14:35:38.993" LastActivityDate="2019-08-30T14:35:38.993" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21039" PostTypeId="2" ParentId="21035" CreationDate="2019-08-30T14:57:11.053" Score="3" Body="&lt;p&gt;This is not a direct answer to &lt;em&gt;&quot;moving the cursor a large number of times in a nnoremap&quot;&lt;/em&gt; or to &lt;em&gt;&quot;another way to repeat 18 actions without such a long list of keystrokes in a mapping's definition&quot;&lt;/em&gt;, but it's a different approach to the problem you presented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider creating a new &lt;a href=&quot;https://vimhelp.org/map.txt.html#user-commands&quot; rel=&quot;nofollow noreferrer&quot;&gt;user-defined command&lt;/a&gt; for that operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That way, you can have the command-line argument typed by the user be at the end of the line itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your particular example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Pygrep vimgrep /&amp;lt;args&amp;gt;/ **/*.py | clist&#xA;nnoremap &amp;lt;leader&amp;gt;gg :Pygrep&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll be left at the command-line, ready to type an argument to &lt;code&gt;:Pygrep&lt;/code&gt;, which will then be used as search expression for &lt;code&gt;vimgrep&lt;/code&gt; on your Python files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, if you'd like to preserve the &lt;code&gt;//&lt;/code&gt; look, to make it clear it's a regexp (and also that you need to escape &lt;code&gt;/&lt;/code&gt;s):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Pygrep vimgrep &amp;lt;args&amp;gt; **/*.py | clist&#xA;nnoremap &amp;lt;leader&amp;gt;gg :Pygrep //&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You still use a &lt;code&gt;&amp;lt;Left&amp;gt;&lt;/code&gt; in this case... But it's only a single one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/map.txt.html#user-commands&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help user-commands&lt;/code&gt;&lt;/a&gt; for more on how to define them.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-30T14:57:11.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21040" PostTypeId="2" ParentId="21028" CreationDate="2019-08-30T15:00:04.587" Score="0" Body="&lt;p&gt;This is pretty easy to do with a series of substitutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;First, add a newline after every &lt;code&gt;:&lt;/code&gt; or &lt;code&gt;,&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/[:,]/&amp;amp;\r&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then replace any newline that &lt;em&gt;doesn't&lt;/em&gt; follow a &lt;code&gt;:&lt;/code&gt; or &lt;code&gt;,&lt;/code&gt; with a single space.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/[^:,]\zs\n\s*/ /&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then, note that you don't actually want newlines between &lt;code&gt;:&lt;/code&gt; and &lt;code&gt;&quot;&lt;/code&gt; characters, so replace these with single spaces too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/:\_s*&quot;/: &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finally, fix the indents, and remove any completely blank lines that have been introduced:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;=gg&#xA;:g/^$/d&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You could probably do all this with only two substitutions or perhaps even just one, but the regular expressions would be a lot more complicated.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-08-30T15:19:18.840" LastActivityDate="2019-08-30T15:19:18.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21041" PostTypeId="2" ParentId="21028" CreationDate="2019-08-30T15:10:48.330" Score="0" Body="&lt;p&gt;Because the structure of your file is so regular, you can do this very quickly with a recursive macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting with your cursor at the top of the file (&lt;code&gt;gg&lt;/code&gt;), type in the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;br&gt;&#xA;&lt;kbd&gt;J&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;br&gt;&#xA;&lt;kbd&gt;J&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;br&gt;&#xA;&lt;kbd&gt;6&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt;&lt;br&gt;&#xA;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;How it works&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; This is recursive macro boilerplate. It clears out the &lt;code&gt;&quot;q&lt;/code&gt; register and then starts recording a macro into it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;J&lt;/kbd&gt; Join the next line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt; Move the cursor to the colon.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; Add a newline and some indent.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;J&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt; Join the next two lines.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;+&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt; Move the cursor to the next line and then to the colon.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; Add another newline and indent.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;6&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt; Join the next 6 lines.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;+&lt;/kbd&gt; Move to the next line. We're now done formatting.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; This is more recursive macro boilerplate. The first &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; plays back the macro in register &lt;code&gt;&quot;q&lt;/code&gt;, but that register is currently empty because we cleared it in step 1. Then the &lt;kbd&gt;q&lt;/kbd&gt; stops the recording and saves the macro. Finally, the &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; plays back the recursive macro. The macro will continue playing back until it hits the bottom of the file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-08-30T15:17:18.143" LastActivityDate="2019-08-30T15:17:18.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21042" PostTypeId="1" CreationDate="2019-08-30T15:15:22.273" Score="1" ViewCount="182" Body="&lt;p&gt;After resisting for a bit, I decided to try the plugin manager vim-plug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seemed to work well when installing the &lt;a href=&quot;https://github.com/raghur/vim-ghost&quot; rel=&quot;nofollow noreferrer&quot;&gt;GhostText plugin&lt;/a&gt;, except that I had to do  the installation in a &lt;code&gt;sudo nvim&lt;/code&gt; session, and the plugin only works when in such a session. If I start my session with the command &lt;code&gt;nvim&lt;/code&gt; and run the command &lt;code&gt;:GhostStart&lt;/code&gt;, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u97vw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u97vw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I already changed the owner of the directory ~/.local/share/nvim to myself, and it did not help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I solve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: If I run &lt;code&gt;:GhostInstall&lt;/code&gt; in a non-sudo session, I get this error:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/NK80V.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NK80V.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;env | grep ^XDG_&lt;/code&gt; outputs:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Qdwl0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qdwl0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22616" LastEditorUserId="22616" LastEditDate="2019-08-30T16:44:42.517" LastActivityDate="2019-08-30T16:44:42.517" Title="Vim-plugin error which goes away when using sudo" Tags="|plugin-vim-plug|plugin-managers|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="21043" PostTypeId="2" ParentId="21035" CreationDate="2019-08-30T16:00:15.770" Score="3" Body="&lt;p&gt;You can use counts in a mapping just as you can use them in normal mode. Of course, when you want to use the count you're not &lt;em&gt;in&lt;/em&gt; normal mode: you're in command-line mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick hack is to use the command-line window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;gg :vimgrep // **/*.py \| clist&amp;lt;C-F&amp;gt;17&amp;lt;Left&amp;gt;&amp;lt;C-C&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;repeat&lt;/code&gt; to create the series of &lt;code&gt;&amp;lt;left&amp;gt;&lt;/code&gt; keystrokes as a string and &lt;code&gt;feedkeys()&lt;/code&gt; to &quot;type&quot; this into the command-line. Unfortunately, this... uh... ends up quite a bit more ugly that what you had to start with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;gg :call feedkeys(':vimgrep // **/*.py \| clist' . repeat(&quot;\&amp;lt;lt&amp;gt;Left&amp;gt;&quot;, 17))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But an interesting technique nonetheless!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, probably the cleanest technique&amp;#8202;&amp;mdash;&amp;#8202;if you want to keep it all in a single mapping&amp;#8202;&amp;mdash;&amp;#8202;is to set the position of the cursor directly using the &lt;code&gt;setcmdpos()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;gg :vimgrep // **/*.py \| clist&amp;lt;C-R&amp;gt;=setcmdpos(10)&amp;lt;CR&amp;gt;&amp;lt;BS&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses the expression register (see &lt;code&gt;:help c_CTRL-R_=&lt;/code&gt;) to execute the function: the &lt;code&gt;&amp;lt;Backspace&amp;gt;&lt;/code&gt; at the end is required to remove the &lt;code&gt;0&lt;/code&gt; that is entered as the successful result of the &lt;code&gt;setcmdpos&lt;/code&gt; function.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-02T13:18:58.423" LastActivityDate="2019-09-02T13:18:58.423" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21044" PostTypeId="1" AcceptedAnswerId="21045" CreationDate="2019-08-30T18:23:01.177" Score="0" ViewCount="262" Body="&lt;p&gt;Ctrl-A is very useful for incrementing the first number in line,  but what if the number you want to increment is not the first one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for an example, if  want to make,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Section. 1-1&#xA;Section. 1-2&#xA;Section. 1-3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How would you do it?&lt;/p&gt;&#xA;" OwnerUserId="23342" LastActivityDate="2019-09-03T17:14:50.303" Title="Increment the Nth number in the line" Tags="|number-formatting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21045" PostTypeId="2" ParentId="21044" CreationDate="2019-08-30T20:35:21.260" Score="0" Body="&lt;p&gt;OK. I found a way to do this. I'm sure somebody has a better suggestion, but this is a start.&#xA;first of all, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ctrl-A jumps the cursor to the next number and increments, and&#xA;Ctrl-x jumps the cursor to the next number and decrements, &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;combine this with a search,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\d\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which simply gets your cursor to the next number, you can make a macro to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for the example question,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa&#xA;^&#xA;/\d\+&#xA;n&#xA;ctrl-x&#xA;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will make a macro that increments the second number of a given line. A trick is to have the n(ext) to get to the second number, and use ctrl-X instead of ctrl-A in this case, because vi thinks that hyphen as a negative sign. If you use ctrl-a, it actually decrements the subsection number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, we can use the n(ext) to increment any nth number. &#xA;I mean, first type,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;section 1-3.2.2.10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then, put the cursor to that line, then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa&#xA;yy&#xA;p&#xA;/\d\+&#xA;3n&#xA;ctrl-a&#xA;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to record a macro, then,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4@a &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will make,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Section 1-3.2.2.10&#xA;Section 1-3.2.3.10&#xA;Section 1-3.2.4.10&#xA;Section 1-3.2.5.10&#xA;Section 1-3.2.6.10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, (Thank you, Rich!)&#xA;If we are incrementing the last number, we can do it much simply, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa&#xA;yy&#xA;p&#xA;$&#xA;ctrl-a&#xA;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;section 1-3.2.2.10&#xA;section 1-3.2.2.11&#xA;section 1-3.2.2.12&#xA;section 1-3.2.2.13&#xA;section 1-3.2.2.14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23342" LastEditorUserId="23342" LastEditDate="2019-09-03T17:14:50.303" LastActivityDate="2019-09-03T17:14:50.303" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21047" PostTypeId="1" CreationDate="2019-08-30T21:28:10.020" Score="1" ViewCount="701" Body="&lt;p&gt;If I start with nvim -u NONE , I want to get &quot;-u NONE&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to get pid using bash and python, but it seems to return the pid of the process that is created (either python or bash). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how should I do it?  &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-08-31T01:25:51.317" Title="How to get the current cmd line of (neo)vim?" Tags="|external-command|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21048" PostTypeId="2" ParentId="21047" CreationDate="2019-08-30T23:03:40.187" Score="0" Body="&lt;p&gt;Sadly, this is what I came up with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Find the current process, the process parent, and use &lt;code&gt;ps ax&lt;/code&gt; to obtain the path. Meant to work in mac. in Linux, it is easier with `/proc/XXX/cmdline'. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PY import vim&#xA;PY import os&#xA;PY pid=os.getpid()&#xA;PY kk=os.popen('ps -o ppid= -p ' + str(pid)).read()&#xA;PY kk=kk.replace('\n','')&#xA;PY tt=(&quot;let cmdline=system('ps ax | grep \&quot;&quot;+kk + &quot;\&quot; | grep nvim | grep -v grep | /usr/bin/sed \&quot;s/^.*\///\&quot;')&quot;)&#xA;PY vim.command(tt)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-08-30T23:03:40.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21049" PostTypeId="2" ParentId="21047" CreationDate="2019-08-31T01:13:12.980" Score="2" Body="&lt;p&gt;If you're going the Python + &lt;code&gt;ps&lt;/code&gt; route, then this should be better and more efficient:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:pyx import os, subprocess&#xA;:let vim_cmdline = pyxeval(&quot;subprocess.check_output(['ps', '-p', str(os.getpid()), '-o', 'cmd='])&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you're checking for the current PID (&lt;code&gt;os.getpid()&lt;/code&gt;), since the Python interpreter is running &lt;em&gt;inside&lt;/em&gt; the current Vim process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One (definitely Linux-only!) method that doesn't involve Python &lt;em&gt;or&lt;/em&gt; &lt;code&gt;ps&lt;/code&gt; is to read from the &lt;code&gt;/proc&lt;/code&gt; filesystem directly. It turns out &lt;code&gt;/proc/self&lt;/code&gt; has information about the current process, and the &lt;code&gt;cmdline&lt;/code&gt; file has the command line (separated with NUL bytes.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get the current command-line in a Vim list with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let vim_cmdline = split(readfile('/proc/self/cmdline')[0], '\n', 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's not 100% perfect. If you have arguments with a newline in them, then this expression wil discard them (they'd be indices &lt;code&gt;[1]&lt;/code&gt;, &lt;code&gt;[2]&lt;/code&gt;, etc. in the list), but it's probably good enough for most purposes, since arguments with newlines are typically quite rare.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: This does a better job at it, taking into account newline characters, etc.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! VimCmdLine()&#xA;  let c = map(readfile('/proc/self/cmdline'), {_, v -&amp;gt; split(v, '\n', 1)})&#xA;  let r = c[0]&#xA;  for i in c[1:]&#xA;    let r[-1] = r[-1].&quot;\n&quot;.i[0]&#xA;    let r = r + i[1:]&#xA;  endfor&#xA;  return r[:-2]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also returns a list, with one element per command-line argument.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-08-31T01:25:51.317" LastActivityDate="2019-08-31T01:25:51.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21050" PostTypeId="1" AcceptedAnswerId="21052" CreationDate="2019-08-31T02:06:22.197" Score="7" ViewCount="8034" Body="&lt;p&gt;Opening the vim terminal using &lt;code&gt;:term&lt;/code&gt;, creates a horizontal split with the terminal placed at the top half of the window. Is there a way to open the terminal at the bottom half instead?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can use &lt;code&gt;set splitbelow&lt;/code&gt; to make all horizontal splits open below the current one. However, I only want the &lt;code&gt;set splitbelow&lt;/code&gt; behaviour to apply when opening &lt;code&gt;:term&lt;/code&gt;. I want all other horizontal splits to open above as usual.&lt;/p&gt;&#xA;" OwnerUserId="19712" LastActivityDate="2023-05-28T00:57:16.877" Title="Vim terminal: How to split below by default?" Tags="|terminal|terminal-buffer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21051" PostTypeId="1" AcceptedAnswerId="21053" CreationDate="2019-08-31T02:24:08.050" Score="2" ViewCount="887" Body="&lt;p&gt;I had a very large (14 digit) decimal number in my (Windows) clipboard. I had vim open in normal mode on the command line at the time. Accidentally, I pressed some key/mouse combination that caused vim to repeat a write command many times. vim was not responding for a while (I'm assuming it started a huge disk write). I killed vim. After opening the file, I saw that it was appending some text (in vim's clipboard) to my file over and over again (I should have executed something like &lt;code&gt;23280664932781p&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After deleting these lines and the swap file (I deleted the swap file because vim was complaining about it whenever I open the file), I found that the undo file had become very large (~700MB). Now, as soon as I launch vim, it does a lot disk reads and is slowing down everything else. I appears to hog my CPU and memory too (CPU usage was constantly above 25%, disk was upto 85% and memory was above 90%). I can't use anything else for some time as it reserves a large buffer in memory. Exiting vim has also become very slow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm still new to vim, and I don't know how to safely lower the size of the undo file (I don't want to forget the entire undo history because of this one thing). I opened the &lt;code&gt;.un~&lt;/code&gt; file to see what's wrong, it looked like this,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/62gZT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/62gZT.png&quot; alt=&quot;undo file contents&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It occurs to me that each line in this file maintains one command (or old content) in the past history (because scrolling past this line took a very long (CPU) time). I don't know if vim is logging the actual content or just the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please explain what has happened and how to fix this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vxBSZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vxBSZ.png&quot; alt=&quot;size of undo file&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21298" LastEditorUserId="1292" LastEditDate="2019-11-19T10:32:26.433" LastActivityDate="2019-11-19T10:32:26.433" Title="Reduce size of undo file" Tags="|key-bindings|microsoft-windows|repeated-commands|undo-redo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21052" PostTypeId="2" ParentId="21050" CreationDate="2019-08-31T02:27:19.310" Score="10" Body="&lt;p&gt;Use &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Abelowright&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:belowright&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:belowright terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, more succinctly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:bel term&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command is a modifier and affects the command run right after it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Another useful modifier here is &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Avertical&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:vertical&lt;/code&gt;&lt;/a&gt;, to split vertically instead.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-31T02:27:19.310" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21053" PostTypeId="2" ParentId="21051" CreationDate="2019-08-31T05:09:27.510" Score="2" Body="&lt;p&gt;You should simply remove that undo file, it's unlikely you'll manage to get something useful from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can actually trim the undo history by setting &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27undolevels%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'undolevels'&lt;/code&gt;&lt;/a&gt; (see also &lt;a href=&quot;https://vimhelp.org/undo.txt.html#clear-undo&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help clear-undo&lt;/code&gt;&lt;/a&gt;), but when you do so, the newer changes are preserved and the older ones are purged. If the newer changes are the problematic ones, trimming them means trimming the older entries you presumably would like to be able to access.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In the unlikelyhood that you're interested in the changes that come after the problematic one, trimming it by setting &lt;code&gt;'undolevels'&lt;/code&gt; might actually work.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order for you to get to the undo actions that precede the large one, you'll need to get past that one (two times actually, since I imagine there's one action and the undo of that action.) Going through them again is likely to make Vim allocate a lot of memory, start using swap, get your machine thrashing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim undo files are per file that you edit, so dropping this particular undo file will only lose your undo history for that particular file, not any other file for which you are saving persistent undo history.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-31T05:09:27.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21054" PostTypeId="1" AcceptedAnswerId="21058" CreationDate="2019-08-31T07:08:49.823" Score="5" ViewCount="1561" Body="&lt;p&gt;I have a command-line tool that can print search results in a format that works with vimgrep. The example output looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo/path/lib/usdviewq/appController.py:3795:22:        index = prim.GetPrimIndex()&#xA;foo/bar/lib/testenv/testUsdSpecializes.py:104:28:            refNode = prim.GetPrimIndex().rootNode.children[0]&#xA;foo/bar/lib/testenv/testUsdInherits.py:108:28:            refNode = prim.GetPrimIndex().rootNode.children[0]&#xA;foo/bar/lib/testenv/testUsdPrims.py:720:14:    def test_GetPrimIndex(self):&#xA;foo/bar/lib/testenv/testUsdPrims.py:722:43:            s = Usd.Stage.CreateInMemory('GetPrimIndex.'+fmt)&#xA;foo/bar/lib/testenv/testUsdPrims.py:739:34:            self.assertTrue(prim.GetPrimIndex().IsValid())&#xA;foo/bar/lib/testenv/testUsdPrims.py:740:34:            self.assertTrue(prim.GetPrimIndex().DumpToString())&#xA;foo/bar/lib/testenv/testUsdPrims.py:745:35:            self.assertFalse(prim.GetPrimIndex().IsValid())&#xA;foo/bar/lib/testenv/testUsdPrims.py:746:35:            self.assertFalse(prim.GetPrimIndex().DumpToString())&#xA;foo/bar/lib/testenv/testUsdInstancing.py:101:18:        s = prim.GetPrimIndex().DumpToString()&#xA;foo/bar/lib/testenv/testUsdEditTarget.py:40:26:        primIndex = prim.GetPrimIndex()&#xA;foo/bar/lib/testenv/testUsdReferences.py:275:28:            refNode = prim.GetPrimIndex().rootNode.children[0]&#xA;foo/bar/lib/testenv/testUsdTimeOffsets.py:288:27:            refNode = foo.GetPrimIndex().rootNode.children[0]&#xA;foo/bar/lib/testenv/testUsdTimeOffsets.py:306:31:            payloadNode = foo.GetPrimIndex().rootNode.children[1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way to feed that as input into Vim as a quickfix window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried doing &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;command_that_makes_these_lines | vim -&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that only adds that given text to a Vim buffer.&lt;/p&gt;&#xA;" OwnerUserId="16073" LastActivityDate="2019-08-31T15:10:18.703" Title="How to load files as a quickfix window at start-up" Tags="|startup|vimgrep|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21055" PostTypeId="2" ParentId="6177" CreationDate="2019-08-31T13:18:37.433" Score="2" Body="&lt;p&gt;According to Vim documentation (&lt;code&gt;:help -c&lt;/code&gt;) there can only be a maximum of 10 &lt;code&gt;+{command}&lt;/code&gt;, &lt;code&gt;-c {command}&lt;/code&gt; and &lt;code&gt;-S {file}&lt;/code&gt; option arguments combined when starting Vim, and they execute _after_ the first file is read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;--cmd {command}&lt;/code&gt; option allows an additional 10 commands to be executed before processing any vimrc file, but bear in mind that any settings can be overridden by vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore I prefer to set Vim options early, and avoid any need for environment variable or scripting logic. Also, plugins may be doing dodgy things so it is better to not load any.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most secure invocation method I can think of is using aliases in &lt;code&gt;~/.bashrc&lt;/code&gt; with a simple and to-the-point vimrcprivate file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Secure Vim&#xA;alias vimsec=&quot;vim -N -n -i NONE -u ~/.vimrcprivate&quot;&#xA;alias gvimsec=&quot;g$(alias vimsec | sed -e &quot;s/-u/-U/&quot; -e &quot;s/\(.*\)'\(.*\)'/\2/&quot;)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23632" LastEditorUserId="23632" LastEditDate="2019-09-03T00:35:16.223" LastActivityDate="2019-09-03T00:35:16.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21056" PostTypeId="2" ParentId="300" CreationDate="2019-08-31T14:16:35.297" Score="-1" Body="&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-I&amp;gt; &amp;lt;C-I&amp;gt;&#xA;vnoremap &amp;lt;Tab&amp;gt; &amp;lt;Esc&amp;gt;gV&#xA;onoremap &amp;lt;Tab&amp;gt; &amp;lt;Esc&amp;gt;&#xA;inoremap &amp;lt;Tab&amp;gt; &amp;lt;Esc&amp;gt;`^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I remap tab to exit. I think historically that's where the esc key used to be, so I used it and never looked back. I hardly ever need to put in a tab in a document, and when I do I just press shift + tab. I have never once missed the original tab binding.&lt;/p&gt;&#xA;" OwnerUserId="8483" LastEditorUserId="8483" LastEditDate="2019-09-02T18:17:25.530" LastActivityDate="2019-09-02T18:17:25.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21057" PostTypeId="1" AcceptedAnswerId="21062" CreationDate="2019-08-31T14:26:11.317" Score="3" ViewCount="1897" Body="&lt;p&gt;I read through Vim documentation, blogs and SO questions on &lt;code&gt;tabstop&lt;/code&gt;, &lt;code&gt;softtabstop&lt;/code&gt;, &lt;code&gt;shiftwidth&lt;/code&gt;, &lt;code&gt;expandtab&lt;/code&gt;. I understood their purpose (may be not), but for all of the following setting, hitting &lt;code&gt;tab&lt;/code&gt; key always moves cursor to right by &lt;code&gt;sw&lt;/code&gt; number of whitespace (3 chars)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:set ts=5 sts=7 sw=3 noexpandtab&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set ts=5 sts=7 sw=3 expandtab&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set ts=5 sts=11 sw=3 noexpandtab&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set ts=5 sts=11 sw=3 expandtab&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I used a text file to test. I have intentionally chosen prime values for each, to understand effect of each option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea why &lt;code&gt;tab&lt;/code&gt; is picking &lt;code&gt;sw&lt;/code&gt; instead of &lt;code&gt;tabstop&lt;/code&gt; or &lt;code&gt;softtabstop&lt;/code&gt;. I keep reading that &lt;code&gt;sts&lt;/code&gt; is kind of 'wrapper' of &lt;code&gt;ts&lt;/code&gt; where in between indentation that &lt;code&gt;tabstop&lt;/code&gt; cannot reach, &lt;code&gt;sts&lt;/code&gt; does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm just not clear, from my experiments, when is each option used. &lt;/p&gt;&#xA;" OwnerUserId="2796" LastActivityDate="2019-08-31T21:46:35.153" Title="tabstop, softtabstop, shiftwidth - confused" Tags="|softtabstop|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="21058" PostTypeId="2" ParentId="21054" CreationDate="2019-08-31T14:44:13.393" Score="12" Body="&lt;p&gt;Vim has a startup option &lt;code&gt;-q&lt;/code&gt; to read a quickfix file. So we have options (depending on your shell):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmd &amp;gt; results&#xA;vim -q results&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or my favorite&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -q &amp;lt;(cmd)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-08-31T14:44:13.393" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21059" PostTypeId="2" ParentId="21054" CreationDate="2019-08-31T15:10:18.703" Score="3" Body="&lt;p&gt;If you'd like to invoke the command from inside Vim and populate the quickfix window with its output, you can use &lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#%3Acexpr&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:cexpr&lt;/code&gt;&lt;/a&gt; together with &lt;a href=&quot;https://vimhelp.org/eval.txt.html#system%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;system()&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;https://vimhelp.org/eval.txt.html#systemlist%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;systemlist()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cexpr system('command_that_makes_these_lines')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#%3Acgetexpr&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:cgetexpr&lt;/code&gt;&lt;/a&gt; for a version that doesn't jump to the first result (you might want to combine that with &lt;code&gt;|&lt;/code&gt;&lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#%3Acopen&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;copen&lt;/code&gt;&lt;/a&gt; to show the quickfix window with the results.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#%3Alexpr&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:lexpr&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#%3Algetexpr&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:lgetexpr&lt;/code&gt;&lt;/a&gt; can be used, to use the location window instead.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-31T15:10:18.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21060" PostTypeId="1" CreationDate="2019-08-31T03:41:36.443" Score="3" ViewCount="2642" Body="&lt;p&gt;I make use of the builtins in spf13. Today when I open multiple files with vim and want to close one of them with q it closes all these files, how can I close only a few of them without closing them all?&lt;/p&gt;&#xA;" OwnerUserId="23637" OwnerDisplayName="Jingyu Gong" LastEditorUserId="23502" LastEditDate="2022-10-24T06:19:58.177" LastActivityDate="2022-10-24T06:19:58.177" Title="Close one file during manipulate multiple files with vim" Tags="|multiple-files|plugin-spf13|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21062" PostTypeId="2" ParentId="21057" CreationDate="2019-08-31T21:46:35.153" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Any idea why &quot;Tab&quot; is picking &lt;code&gt;shiftwidth&lt;/code&gt; instead of &lt;code&gt;tabstop&lt;/code&gt; or &lt;code&gt;softtabstop&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your case, I believe it's because you were enabling &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27smarttab%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'smarttab'&lt;/code&gt;&lt;/a&gt; in your vimrc. This option makes &quot;Tab&quot; insert blanks according to &lt;code&gt;shiftwidth&lt;/code&gt; when used in front of a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal situations, a Tab key jumps to the next &lt;code&gt;softtabstop&lt;/code&gt; position, if that is set. If you repeat this experiment using &lt;code&gt;vim -u NONE -U NONE -N&lt;/code&gt; to ensure you have no interference from other settings, you should see the expected behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than &lt;code&gt;'smarttab'&lt;/code&gt;, there are other possibilities of configurations that would change the behavior of the &quot;Tab&quot; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible that it's mapped by a plug-in (many completion plug-ins like to use &quot;Tab&quot; as a trigger for completion), in that case you can use &lt;code&gt;:imap &amp;lt;Tab&amp;gt;&lt;/code&gt; to inspect whether there are any mappings for &quot;Tab&quot; in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that, there is &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27indentkeys%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'indentkeys'&lt;/code&gt;&lt;/a&gt; (if &lt;code&gt;'indentexpr'&lt;/code&gt; is set) or &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27cinkeys%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'cinkeys'&lt;/code&gt;&lt;/a&gt; that may include &quot;Tab&quot; as a special key triggering indentation behavior. &quot;Tab&quot; would show up as &lt;code&gt;^I&lt;/code&gt; in those options (since Control-I is equivalent to Tab.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-08-31T21:46:35.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21063" PostTypeId="1" CreationDate="2019-09-01T01:18:47.793" Score="1" ViewCount="111" Body="&lt;p&gt;I know I can change the language of the Vim user interface using &lt;code&gt;:language en_US.UTF-8&lt;/code&gt;, but how can I do that using vimscript?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set language=en_US.UTF-8&lt;/code&gt; is invalid, and the Vim documentation says that the &lt;code&gt;v:lang&lt;/code&gt; variable cannot be set directly.&lt;/p&gt;&#xA;" OwnerUserId="19712" LastActivityDate="2019-09-04T00:25:16.323" Title="How to set the language for the user interface using vimscript?" Tags="|vimscript|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21065" PostTypeId="1" CreationDate="2019-09-01T04:37:01.310" Score="2" ViewCount="227" Body="&lt;p&gt;I am using &lt;code&gt;exuberent-ctags&lt;/code&gt; with &lt;code&gt;vim 8.0&lt;/code&gt;. While searching for a tag with a long name, I'd like to have a list of suggestions having the typed string as the sub-string when I use the &lt;code&gt;:ta&lt;/code&gt; command. What I want is to have a feature like Sublime's &lt;code&gt;Ctrl+P&lt;/code&gt;, that allows you to search for a symbol. Is it possible to achieve the same with &lt;code&gt;ctags&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="17461" LastActivityDate="2019-09-01T09:26:25.427" Title="Is it possible to have tag suggestion in ctags while searching for a tag?" Tags="|ctags|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21066" PostTypeId="1" AcceptedAnswerId="21072" CreationDate="2019-09-01T04:51:01.127" Score="2" ViewCount="1636" Body="&lt;p&gt;Situation: I've typed this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim foo.js&#xA;:terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I have one split, a file editing buffer and a terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The good: I can quit by closing the terminal first, then the file buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bad: But if I close the file buffer, and then the terminal, vim doesn't exit, but instead creates a new buffer editing the file, which I've just closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find this distracting and confusing. I don't want it to open up foo.js again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't seem like a bug/misfeature, consider this use-case:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I open up foo.js&lt;/li&gt;&#xA;&lt;li&gt;:terminal&lt;/li&gt;&#xA;&lt;li&gt;close foo.js&lt;/li&gt;&#xA;&lt;li&gt;open up foo.js in another instance of vim&lt;/li&gt;&#xA;&lt;li&gt;in the original vim instance, close the :terminal&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In this case when the original vim instance tries to open foo.js (instead of quitting) I get a large error screen about &quot;Another program may be editing the same file.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I make vim quit when I close the last buffer, even if it's a :terminal?&lt;/p&gt;&#xA;" OwnerUserId="23636" LastActivityDate="2019-09-01T21:08:33.070" Title="closing :terminal / term_start() should quit vim if it's the last buffer" Tags="|terminal-buffer|quit|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21067" PostTypeId="5" CreationDate="2019-09-01T04:52:57.310" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2019-09-01T04:52:57.310" LastActivityDate="2019-09-01T04:52:57.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21068" PostTypeId="4" CreationDate="2019-09-01T04:52:57.310" Score="0" Body="A terminal emulator within vim, eg created by :terminal or term_start()" OwnerUserId="23636" LastEditorUserId="23636" LastEditDate="2019-09-02T14:28:19.420" LastActivityDate="2019-09-02T14:28:19.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21069" PostTypeId="2" ParentId="21066" CreationDate="2019-09-01T07:11:45.143" Score="1" Body="&lt;p&gt;You can create a mapping which will close the terminal buffer directly. Then Vim will not open an additional empty buffer and will exit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For simplicity I assume that the terminal is running shell, so &lt;kbd&gt;Ctrl-D&lt;/kbd&gt; exits it normally.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tnoremap &amp;lt;silent&amp;gt;&amp;lt;C-D&amp;gt; &amp;lt;C-D&amp;gt;&amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;ZQ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-09-01T07:23:47.813" LastActivityDate="2019-09-01T07:23:47.813" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21070" PostTypeId="2" ParentId="21065" CreationDate="2019-09-01T09:26:25.427" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_CTRL-D&quot; rel=&quot;nofollow noreferrer&quot;&gt;You can use&lt;/a&gt; &lt;kbd&gt;Ctrl+D&lt;/kbd&gt; in command-line mode, it shows you all the suggestions you would get with the &lt;kbd&gt;Tab&lt;/kbd&gt; completion. e.g. &lt;code&gt;:ta func&amp;lt;C-D&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from that, fzf plugin have a &lt;code&gt;:Tags&lt;/code&gt; and CtrlP have &lt;code&gt;:CtrlPTag&lt;/code&gt; that allows fuzzy-searching for tags. But if you don't use their other features, it might be better to keep it simple with &lt;kbd&gt;CTRL+D&lt;/kbd&gt; if it works for you.&lt;/p&gt;&#xA;" OwnerUserId="22929" LastActivityDate="2019-09-01T09:26:25.427" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21071" PostTypeId="1" AcceptedAnswerId="21073" CreationDate="2019-09-01T18:40:50.217" Score="4" ViewCount="275" Body="&lt;p&gt;I love using Vim yet have a lot of very sensitive, encrypted files to edit, sometimes on an unencrypted drive, and can't have any residual information from these files forensically accessible to other users of that hardware or others. I realize I can just do &lt;code&gt;:set viminfo=&lt;/code&gt; but this disables lots of the best features. How can I get Vim to encrypt the &lt;code&gt;.viminfo&lt;/code&gt; file instead so that no information is stored on the drive?&lt;/p&gt;&#xA;" OwnerUserId="21571" LastActivityDate="2019-09-01T21:20:14.073" Title="How to encrypt the .viminfo file and still get Vim to read it?" Tags="|viminfo|encryption|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21072" PostTypeId="2" ParentId="21066" CreationDate="2019-09-01T21:08:33.070" Score="2" Body="&lt;p&gt;Thanks to @Matt I now know that if I close the terminal buffer myself instead of having the &lt;code&gt;'term_finish':'close'&lt;/code&gt; argument of &lt;code&gt;term_start()&lt;/code&gt; do it, then it doesn't do the weird behavior of sometimes opening a different file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I've &lt;code&gt;'term_finish':'close'&lt;/code&gt; that with an &lt;code&gt;exit_cb&lt;/code&gt; that closes the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I use in full:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! JW_on_term_exit(a, b)&#xA;    normal q!&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Bslash&amp;gt; :below call term_start('env TERM=st-256color zsh', { 'exit_cb': 'JW_on_term_exit', 'term_name': 'zsh', 'norestore': 1 })&amp;lt;Return&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23636" LastActivityDate="2019-09-01T21:08:33.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21073" PostTypeId="2" ParentId="21071" CreationDate="2019-09-01T21:20:14.073" Score="2" Body="&lt;p&gt;Do you mean swap files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;.viminfo is stored in your home directory, even when you're editing files on external disks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Swap files default to being stored in the same directory as the file you're editing though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use settings &lt;code&gt;viminfofile&lt;/code&gt; and &lt;code&gt;directory&lt;/code&gt; to set where the .viminfo and swap files (respectively) are stored, so that they are stored within an encrypted drive/partition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set directory=$HOME/tmp/vim/swap//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;because it speeds up working on slow remote-mounted disks such as sshfs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could do that plus something like (untested)...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viminfofile=$home/tmp/vim/info&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23636" LastActivityDate="2019-09-01T21:20:14.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21074" PostTypeId="2" ParentId="17074" CreationDate="2019-09-01T21:34:12.967" Score="5" Body="&lt;p&gt;I think the quick answer is &quot;no&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Partial solution: with a little extra typing, you can control what part of your search term gets hilighted: &lt;code&gt;\zs&lt;/code&gt; to mark the start of highlighting, and &lt;code&gt;\ze&lt;/code&gt; to mark the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works nicely for searches:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&quot;\zs\(foo\|bar\)\ze&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But breaks search-and-replace, eg with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&quot;\zs\(foo\|bar\)\ze&quot;/'\1'/gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;because it only replaces the highlighted part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tested on this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;foo&quot;, &quot;bar&quot;, &quot;ba'z&quot;, 'foo', 'bar'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23636" LastActivityDate="2019-09-01T21:34:12.967" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21075" PostTypeId="2" ParentId="2883" CreationDate="2019-09-01T21:41:38.483" Score="0" Body="&lt;p&gt;EDIT: This is a known bug, closed &quot;won't fix&quot;: &lt;a href=&quot;https://github.com/vim/vim/issues/260&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/issues/260&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Original answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim doesn't scroll horizontally until the cursor hits the edge of the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are you using &lt;code&gt;sidescrolloff&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know about disabling horizontal scrolling entirely, but this setting should make it wait until the cursor goes off the edge:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set sidescrolloff=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23636" LastEditorUserId="23636" LastEditDate="2019-10-04T03:14:29.410" LastActivityDate="2019-10-04T03:14:29.410" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21076" PostTypeId="1" AcceptedAnswerId="21079" CreationDate="2019-09-02T03:21:19.863" Score="1" ViewCount="274" Body="&lt;p&gt;In &lt;a href=&quot;https://www.youtube.com/watch?v=wiOalxCQ1Mw&amp;amp;t=6m12s&quot; rel=&quot;nofollow noreferrer&quot;&gt;this video&lt;/a&gt; from Bisqwit, the selected line is colored by a gradient according to column number. Image is below. He implemented the gradient in a custom terminal emulator. Is there any way to recreate it with a Vim plugin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UeXFT.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UeXFT.jpg&quot; alt=&quot;Image of source code in Joe editor with a gradient color behind the selected text.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23649" LastEditorUserId="23649" LastEditDate="2019-09-02T08:03:28.777" LastActivityDate="2019-09-02T08:14:07.620" Title="Gradient color background for visual selections" Tags="|visual-block|color|selection|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21077" PostTypeId="2" ParentId="12140" CreationDate="2019-09-02T03:51:22.143" Score="2" Body="&lt;p&gt;You can &lt;code&gt;set mouse=&lt;/code&gt; to disable mouse entirely, use &lt;code&gt;set mouse=a&lt;/code&gt; to restore mouse behaviour. You can automatically enable/disable mouse only in terminal vim but not in GUI vim by checking for &lt;code&gt;if has(&quot;gui&quot;)&lt;/code&gt;, or by putting your config in .gvimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can get into the habit of changing window using Alt-Tab instead of the mouse. As a side effect, this prepares your fingers to be in the keyboard to operate vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another alternative, depending on your window manager, you can get into the habit of doing Alt-Click to focus a windows without changing the focus inside that window.&lt;/p&gt;&#xA;" OwnerUserId="632" LastActivityDate="2019-09-02T03:51:22.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21078" PostTypeId="2" ParentId="6730" CreationDate="2019-09-02T05:49:37.177" Score="11" Body="&lt;p&gt;I finally found a way to get rid of the command, mode as well as file name in the command line bar!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;at the &lt;strong&gt;bottom&lt;/strong&gt; of your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noshowmode  &quot; to get rid of thing like --INSERT--&#xA;set noshowcmd  &quot; to get rid of display of last command&#xA;set shortmess+=F  &quot; to get rid of the file name displayed in the command line bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;notice that this piece of code should be at the &lt;strong&gt;bottom&lt;/strong&gt; of your &lt;code&gt;.vimrc&lt;/code&gt; or it may not works.&lt;/p&gt;&#xA;" OwnerUserId="23650" LastActivityDate="2019-09-02T05:49:37.177" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21079" PostTypeId="2" ParentId="21076" CreationDate="2019-09-02T08:14:07.620" Score="2" Body="&lt;p&gt;Vim (and neovim) use some highlighting groups (&lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#highlight-groups&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h highlight-groups&lt;/code&gt;&lt;/a&gt;) to define which color a UI component should have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the cursor line the group is &lt;code&gt;hl-CursorLine&lt;/code&gt; (&lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#hl-CursorLine&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h hl-CursorLine&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Such groups can only contain one color and the code is not made to support the kind of customization you are looking for. So the answer is: it is not possible to recreate that in a vim plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe this could be done by reworking heavily the source code but I don't see such a patch being merged into Vim (maybe into neovim but even there I'm really not sure).&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-09-02T08:14:07.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21080" PostTypeId="2" ParentId="20971" CreationDate="2019-09-02T08:15:25.467" Score="4" Body="&lt;p&gt;I rarely ever run &lt;code&gt;:Gpush&lt;/code&gt; on its own, so maybe try this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:Gstatus&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in the new split view, use &lt;code&gt;-&lt;/code&gt; to toggle which changes you want to stage for the commit, then use &lt;code&gt;cc&lt;/code&gt; to commit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After entering the commit message and save/quit, the split window shows unpushed commits; you can use &lt;code&gt;-&lt;/code&gt; to push individual commits. The exact push line and parameters are shown in the command line to be confirmed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;YMMV - I'd be curious what you make of this workflow.&lt;/p&gt;&#xA;" OwnerUserId="23604" LastActivityDate="2019-09-02T08:15:25.467" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21081" PostTypeId="2" ParentId="76" CreationDate="2019-09-02T10:24:52.193" Score="8" Body="&lt;p&gt;&lt;code&gt;:(v)split &amp;lt;name_of_buffer&amp;gt;&lt;/code&gt; or &lt;code&gt;:(v)split #&amp;lt;buffer_number&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This answer shows a shorter way to @user72's answer above and @zepp.lee's comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you can open buffer 2 in a vertical split with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vsp #2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vsp test.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23655" LastEditorUserId="10604" LastEditDate="2019-10-25T14:05:17.833" LastActivityDate="2019-10-25T14:05:17.833" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21082" PostTypeId="1" CreationDate="2019-09-02T10:59:50.927" Score="2" ViewCount="480" Body="&lt;p&gt;Since ever in my configuration of vim text and markdown-files are indented on following lines to align with open parenthesis.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Text Text Text (e.g. Hello&#xA;                World)&#xA;More Text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This happens when I create a new-line by line-breaking or when I run &lt;code&gt;gg=G&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I disable this for these Filetypes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried disabling &lt;code&gt;autoindent&lt;/code&gt;, &lt;code&gt;smartindent&lt;/code&gt;, ain't working.&lt;/p&gt;&#xA;" OwnerUserId="1542" LastActivityDate="2019-09-02T16:04:47.677" Title="How to disable intelligent indent for text/markdown files?" Tags="|filetype|filetype-markdown|indent|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21083" PostTypeId="1" AcceptedAnswerId="21084" CreationDate="2019-09-02T13:02:57.293" Score="1" ViewCount="380" Body="&lt;p&gt;Because the keys &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;x&lt;/code&gt;are used in normal mode to delete letters, I map &lt;code&gt;&amp;lt;ctrl-d&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;ctrl-x&amp;gt;&lt;/code&gt; in insert mode to &lt;code&gt;delete&lt;/code&gt; and &lt;code&gt;backspace&lt;/code&gt;.&lt;br&gt;&#xA;&lt;br&gt;&#xA;However, when I started to use completion plugin (I use &lt;em&gt;supertab&lt;/em&gt; now, though it doesn't update recently, it still works good), if I press &lt;code&gt;&amp;lt;ctrl-x&amp;gt;&lt;/code&gt; in insert mode, vim jump into &lt;em&gt;CTRL-X mode&lt;/em&gt;. &lt;br&gt;&#xA;&lt;br&gt;&#xA;After searching, I found that key &lt;code&gt;&amp;lt;ctrl-x&amp;gt;&lt;/code&gt; actually predefined in ins-completion feature. Because using &lt;em&gt;supertab&lt;/em&gt; I can use &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; to search completion, I still want to use &lt;code&gt;&amp;lt;ctrl-x&amp;gt;&lt;/code&gt; as &lt;code&gt;backspace&lt;/code&gt; in insert mode. Is there a way to do that?&lt;/p&gt;&#xA;" OwnerUserId="23584" LastActivityDate="2019-09-03T09:58:24.587" Title="Can I disable insert-mode completion (ins-completion) key mapping (CTRL-X)?" Tags="|key-bindings|autocompletion|ins-completion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21084" PostTypeId="2" ParentId="21083" CreationDate="2019-09-02T13:18:16.373" Score="1" Body="&lt;p&gt;It sounds as though the supertab plugin has either overwritten or removed your insert mode mapping. You can check if this is the case with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose imap &amp;lt;C-X&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can reinstate your mapping simply by re-running your map command again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;C-X&amp;gt; &amp;lt;BS&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The best way to do this automatically in your vim configuration is probably to use the &lt;code&gt;after&lt;/code&gt; directory &lt;a href=&quot;https://vi.stackexchange.com/questions/21083/can-i-disable-insert-mode-completion-ins-completion-key-mapping-ctrl-x#comment36967_21084&quot;&gt;as suggested by @filbranden in the comments&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a &lt;code&gt;.vim&lt;/code&gt; file with any name in the location:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/after/plugin/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-X&amp;gt; &amp;lt;BS&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will be run after supertab (and all other plugins) and so can override its settings. See &lt;code&gt;:help after-directory&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-03T09:58:24.587" LastActivityDate="2019-09-03T09:58:24.587" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21085" PostTypeId="2" ParentId="21082" CreationDate="2019-09-02T16:04:47.677" Score="3" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/21082/how-to-disable-intelligent-indent-for-text-markdown-files#comment36966_21082&quot;&gt;discussed in the comments&lt;/a&gt;, this behaviour is caused by &lt;code&gt;cindent&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check what's setting this with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set cindent?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-09-02T16:04:47.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21086" PostTypeId="1" AcceptedAnswerId="21087" CreationDate="2019-09-02T18:09:16.237" Score="2" ViewCount="823" Body="&lt;p&gt;How can I get the length of the current row in vim script?&lt;/p&gt;&#xA;" OwnerUserId="23659" LastActivityDate="2019-09-02T18:25:19.157" Title="Get the length/number of colums in the current line/row" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21087" PostTypeId="2" ParentId="21086" CreationDate="2019-09-02T18:25:19.157" Score="3" Body="&lt;p&gt;To get the current line you can use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#getline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h getline()&lt;/code&gt;&lt;/a&gt; giving it the parameter &lt;code&gt;'.'&lt;/code&gt;. This will return a string, all you have to do next is to get the length of this string, to do so you have several options: &lt;a href=&quot;http://vimhelp.appspot.com/usr_41.txt.html#string-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h string-functions&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strlen()        length of a string in bytes&#xA;strchars()      length of a string in characters&#xA;strwidth()      size of string when displayed&#xA;strdisplaywidth()   size of string when displayed, deals with tabs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So your code could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let size = strwidth(getline('.'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-09-02T18:25:19.157" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21089" PostTypeId="1" AcceptedAnswerId="21093" CreationDate="2019-09-03T06:48:50.903" Score="0" ViewCount="407" Body="&lt;p&gt;I'm using the &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;nerdcommenter&lt;/a&gt; to comment and uncomment my c++ code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I use &lt;code&gt;\cc&lt;/code&gt; to comment one line, &lt;code&gt;\cu&lt;/code&gt; to uncomment, &lt;code&gt;\ca&lt;/code&gt; to switch the delimiters (switch &lt;code&gt;//&lt;/code&gt; to &lt;code&gt;/**/&lt;/code&gt; or switch back).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to set a shortcut named &lt;code&gt;\cv&lt;/code&gt; for this case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\cv: \ca + \cc + \ca&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so that I can use the other delimiter quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to add &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;cv &amp;lt;leader&amp;gt;ca \| &amp;lt;leader&amp;gt;cc \| &amp;lt;leader&amp;gt;\ca&lt;/code&gt; into my &lt;code&gt;~/.vimrc&lt;/code&gt; but it doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2019-09-03T09:13:19.383" Title="How to set a shortcut for multiple leader commands" Tags="|key-bindings|comments|plugin-nerdcommenter|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21090" PostTypeId="1" CreationDate="2019-09-03T07:54:34.760" Score="0" ViewCount="1472" Body="&lt;p&gt;Every now and then I update my ViM configuration, and I would like to have a way to reload everything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I could use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:source ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I could run it similarly for all the modified files. But as vim loads e.g. the system-wide configuration and the content of the &lt;code&gt;~/.vim/&lt;/code&gt; directory, it can be some effort to source all those files again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to reload the whole set in one command?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, it should stop sourcing the previous configuration file and resource all anew.&lt;/p&gt;&#xA;" OwnerUserId="2170" LastActivityDate="2019-09-03T13:03:18.137" Title="Reload complete configuration from within vim" Tags="|vimrc|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21091" PostTypeId="2" ParentId="12475" CreationDate="2019-09-03T08:52:14.970" Score="0" Body="&lt;p&gt;I also encountered this issue and I ended up writing a plugin. It's called &lt;a href=&quot;https://github.com/theniceboy/vim-calc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-calc&lt;/a&gt;. I hope people who have similar needs of a calculator in Vim will check it out!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Side-note: You can also use python to calculate, but has some limitations.&lt;/p&gt;&#xA;" OwnerUserId="21891" LastActivityDate="2019-09-03T08:52:14.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21092" PostTypeId="2" ParentId="21090" CreationDate="2019-09-03T09:07:04.487" Score="0" Body="&lt;p&gt;Are your &quot;modified files&quot; not sourced by default of from within .vimrc? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you add the &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source /path/to/additional/config/file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;directive to your .vimrc, that would do the whole thing in one go. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then even &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;r :source ~/.vimrc&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to have &lt;code&gt;&amp;lt;leader&amp;gt;r&lt;/code&gt; (default  &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; is &lt;code&gt;/&lt;/code&gt;, I believe) reload your config with two keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two things additionally:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Thank you for asking the question! This prompted me to - &lt;em&gt;at last&lt;/em&gt; - also put this into my own config. Very convenient!&lt;/li&gt;&#xA;&lt;li&gt;I set &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; to be the Space key (&lt;code&gt;let mapleader = &quot; &quot;&lt;/code&gt;) and am &lt;em&gt;very&lt;/em&gt; happy with that.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="23604" LastActivityDate="2019-09-03T09:07:04.487" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21093" PostTypeId="2" ParentId="21089" CreationDate="2019-09-03T09:13:19.383" Score="1" Body="&lt;p&gt;Try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;cv &amp;lt;leader&amp;gt;ca&amp;lt;leader&amp;gt;cc&amp;lt;leader&amp;gt;ca&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you can't use &lt;code&gt;nore&lt;/code&gt;-stuff here.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-09-03T09:13:19.383" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21094" PostTypeId="2" ParentId="14467" CreationDate="2019-09-03T11:00:19.020" Score="1" Body="&lt;h2&gt;Plugin &lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-dispatch&lt;/a&gt; by Tim Pope&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This plugin provides as one of its main features running &lt;code&gt;makeprg&lt;/code&gt; non-blocking either in the foreground or the background. Quote from &lt;code&gt;:h dispatch&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Leverage the power of Vim's compiler system without being constrained by&#xA;  synchronicity.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The first command by vim-dispatch is &lt;code&gt;:Make&lt;/code&gt; (note the capital &lt;code&gt;M&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Make [arguments]       Using the current |:compiler| settings, dispatch a&#xA;                        build in the foreground.  Adapter strategies vary, but&#xA;                        the goal is visibility without stealing focus.  When&#xA;                        the build is complete, load the results into the&#xA;                        |quickfix| list and call |:cwindow|.  This command is&#xA;                        preferred for shorter tasks like &quot;build this file.&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let us consider this hello world perl file without errors which has as output two lines&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-perl prettyprint-override&quot;&gt;&lt;code&gt;#!/usr/bin/env perl&#xA;use strict;&#xA;use warnings;&#xA;&#xA;print &quot;Hello world\n&quot;;&#xA;print 42, &quot;\n&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set &lt;code&gt;makeprg&lt;/code&gt; as the OP suggested or manually with&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:se mp=perl\ %&lt;/code&gt; (abbreviated form of &lt;code&gt;makeprg&lt;/code&gt; is &lt;code&gt;mp&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now press either &lt;code&gt;m&amp;lt;CR&amp;gt;&lt;/code&gt; or type &lt;code&gt;:Make&amp;lt;CR&amp;gt;&lt;/code&gt; from vim-dispatch. Perl will be executed and the &#xA;output will be available in the quickfix window without any additional lines:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n7YRb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n7YRb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The OP might be interested in having the quickfix window automatically be opened or keeping it open during scripting &amp;amp; running. Unfortunately, I could not figure this out. But someone has already filed this as a feature request on &lt;a href=&quot;https://github.com/tpope/vim-dispatch/issues/226#issuecomment-394099194&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other plugins provide this but are heavier plugins such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/neomake/neomake#usage&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neomake&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim#quickfix-window&quot; rel=&quot;nofollow noreferrer&quot;&gt;AsyncRun&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;vim-dispatch as of 2019&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;supports vim8/neovim jobs (no tmux/screen/iterm needed anymore)&lt;/li&gt;&#xA;&lt;li&gt;nice (IMHO) default mappings &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;m&amp;lt;cr&amp;gt;&lt;/code&gt; for &lt;code&gt;:Make&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;m&amp;lt;Space&amp;gt;&lt;/code&gt; for &lt;code&gt;:Make&amp;lt;space&amp;gt;&lt;/code&gt; (e.g. allows the user to run &lt;code&gt;make debug&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;and more (see &lt;code&gt;:h dispatch-maps&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tpope/vim-dispatch/pull/250&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pending PR #250&lt;/a&gt; and &lt;a href=&quot;https://github.com/tpope/vim-dispatch/tree/reuse-terminal&quot; rel=&quot;nofollow noreferrer&quot;&gt;active branch&lt;/a&gt; to use vim8/neovim terminal for &lt;code&gt;:Start&lt;/code&gt; to &lt;a href=&quot;https://github.com/tpope/vim-dispatch#spawning-interactive-processes&quot; rel=&quot;nofollow noreferrer&quot;&gt;spawn interactive processes&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-09-03T11:00:19.020" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21095" PostTypeId="1" AcceptedAnswerId="21124" CreationDate="2019-09-03T11:38:36.273" Score="1" ViewCount="274" Body="&lt;p&gt;I am fairly new to Vim. I keep my notes in &lt;code&gt;.md&lt;/code&gt; files and would like to access them with CtrlP from several different directories. I would like to set a specific filter on them, because now loading all the files and changing the search patter quickly slows down vim a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that there are &lt;code&gt;wildignore&lt;/code&gt; and &lt;code&gt;ctrlp_custom_ignore&lt;/code&gt; for &lt;strong&gt;ignoring&lt;/strong&gt; specific files formats. However, based on &lt;a href=&quot;https://github.com/ctrlpvim/ctrlp.vim/issues/312&quot; rel=&quot;nofollow noreferrer&quot;&gt;this issue&lt;/a&gt;, for &lt;strong&gt;filtering&lt;/strong&gt; for particular patterns, I might need to use &lt;code&gt;ctrlp_user_command&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I have the default setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_user_command = 'rg %s --files --hidden --color=never --glob &quot;&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to adjust it based on the issue but the examples there use &lt;code&gt;find&lt;/code&gt; instead of &lt;code&gt;rg&lt;/code&gt; and I am confused with the vim regex (I am familiar with regex mainly in python and somehow in js).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="14718" LastEditorUserId="1841" LastEditDate="2019-09-03T12:00:19.910" LastActivityDate="2019-09-04T21:52:37.953" Title="How to show only a specific file format in ctrlp results?" Tags="|filesystem|plugin-ctrlp|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21096" PostTypeId="2" ParentId="21090" CreationDate="2019-09-03T13:03:18.137" Score="2" Body="&lt;p&gt;3 options&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Restart vim (using sessions, e.g., with tpope’s obsession plugin, this isn’t really too bad)&lt;/li&gt;&#xA;&lt;li&gt;Source only your vimrc (if it changed)—you have this&lt;/li&gt;&#xA;&lt;li&gt;Load files with &lt;code&gt;runtime&lt;/code&gt; (I use &lt;code&gt;Runtime&lt;/code&gt; from tpope’s scriptease plugin). &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-09-03T13:03:18.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21097" PostTypeId="1" CreationDate="2019-09-03T16:30:31.210" Score="1" ViewCount="313" Body="&lt;p&gt;I was trying to create a trigger that does the following:&#xA;When opening a new tab with a file, if there already exists a terminal buffer, it is opened below in this new tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen in logfiles that the events triggered when opening a new tab are &lt;code&gt;WinLeave&lt;/code&gt;, &lt;code&gt;TabLeave&lt;/code&gt;, &lt;code&gt;WinEnter&lt;/code&gt; and &lt;code&gt;TabEnter&lt;/code&gt; (in this order). In my &lt;code&gt;.vimrc&lt;/code&gt; file I created an augroup and tried to use autocmds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that it does not work as expected (it does nothing, actually), and I am pretty sure that the wrong part is related to sequential autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    autocmd!&#xA;    &quot; Take into account events in their order&#xA;    autocmd WinLeave ++nest autocmd TabLeave&#xA;        \ ++nest autocmd WinEnter ++nest autocmd TabEnter * |&#xA;        &quot; Create variable with existing terminal buffers&#xA;        \ let term_buf = filter(range(1, bufnr('$')),&#xA;            \ 'getbufvar(v:val, &quot;&amp;amp;buftype&quot;, &quot;ERROR&quot;) == &quot;terminal&quot;') |&#xA;        \ if len(term_buf) &amp;gt; 0 |&#xA;            &quot; First terminal buffer taken&#xA;            \ let x = term_buf[0] |&#xA;            &quot; Open new buffer below&#xA;            \ exe 'below sbuffer'.x |&#xA;            \ startinsert |&#xA;        \ endif&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23673" LastEditorUserId="10604" LastEditDate="2019-09-04T03:21:53.100" LastActivityDate="2019-09-04T03:21:53.100" Title="Autocmd commands for sharing terminal when open new tab" Tags="|autocmd|tabbed-user-interface|terminal-buffer|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21098" PostTypeId="1" CreationDate="2019-09-03T21:07:41.707" Score="2" ViewCount="47" Body="&lt;p&gt;Sometimes I make a change, then in my scramble to move to somewhere else that I want to repeat the change, I accidentally make some edit (e.g. &lt;code&gt;ill&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would normally undo the accidental edit with &lt;code&gt;u&lt;/code&gt;, but now I can't use &lt;code&gt;.&lt;/code&gt; anymore to repeat my last meaningful change, my intended change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can preserve the last &lt;em&gt;meaningful&lt;/em&gt; change I made? Either, have &lt;code&gt;u&lt;/code&gt; revert the last command stored in &lt;code&gt;.&lt;/code&gt;, or save myself from accidental edits differently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that 100% of the time I use &lt;code&gt;u&lt;/code&gt;, unless my last command was &lt;code&gt;.&lt;/code&gt;, then the command I undo with &lt;code&gt;u&lt;/code&gt; should also not be repeated by &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already know I can use macros to repeat changes, so I am looking for solutions that will work for commands I executed without recording them into macros.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2019-09-03T21:07:41.707" Title="make u (undo) also reset . (repeat last command)?" Tags="|repeated-commands|undo-redo|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21099" PostTypeId="2" ParentId="21060" CreationDate="2019-09-03T21:19:01.700" Score="3" Body="&lt;p&gt;This is not specific to spf13, but it applies to all Vim.  If you've loaded multiple files in the given manner, vim will issue such warning message  because &lt;code&gt;q&lt;/code&gt; will try to quit Vim, but there are other files that haven't been edited yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, after you're done editing with the current file, you can go to next file using &lt;code&gt;:next&lt;/code&gt;.  If you want to go back to previous file, you can do &lt;code&gt;:Next&lt;/code&gt;, with capital N.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use buffer commands, which is what I recommend. You can use &lt;code&gt;:ls&lt;/code&gt; to list all buffers, &lt;code&gt;:bnext&lt;/code&gt;, &lt;code&gt;:bprev&lt;/code&gt;,  to go go to next/previous buffers, and &lt;code&gt;:buffer 5&lt;/code&gt; to go to 5th buffer, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To close and unload the current buffer, you can also do &lt;code&gt;:bdelete&lt;/code&gt; (or &lt;code&gt;:bd&lt;/code&gt; for short), and keep other buffers.&lt;/p&gt;&#xA;" OwnerUserId="21762" LastEditorUserId="21762" LastEditDate="2019-09-03T21:25:44.510" LastActivityDate="2019-09-03T21:25:44.510" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21100" PostTypeId="1" CreationDate="2019-09-03T23:07:08.980" Score="3" ViewCount="118" Body="&lt;p&gt;Good afternoon,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just started using the Ubuntu shell from Windows 10, and I copied my Mac &lt;code&gt;.vimrc&lt;/code&gt; file. Everything seemed normal until these yellow bars started showing up at the end of some lines.&#xA;It doesn't seem to be search syntax highlighting. I used &lt;code&gt;:nohl&lt;/code&gt; command but that doesn't seem to work.&#xA;It goes away if I manually highlight the lines and yank them, I would not like to do that every time I want to edit files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what it looks like:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Ekg0n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ekg0n.png&quot; alt=&quot;Screenshot of vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shiftwidth=4&#xA;set tabstop=4&#xA;set softtabstop=4&#xA;set autoindent&#xA;&#xA;&quot;autocmd FileType html setlocal shiftwidth=2 tabstop=2&#xA;&quot;autocmd FileType php setlocal shiftwidth=4 tabstop=4&#xA;&quot;autocmd FileType javascript setlocal shiftwidth=4 tabstop=4&#xA;&#xA;set lbr&#xA;set tw=500&#xA;set ai&#xA;set si&#xA;set wrap&#xA;set t_Co=256&#xA;set number&#xA;set mouse=&#xA;&quot;ar mousemodel=extend&#xA;&quot;set clipboard=unnamedplus&#xA;set background=dark&#xA;syntax on&#xA;&quot;let g:onedark_termcolors=16&#xA;set noshowmatch&#xA;map &amp;lt;F6&amp;gt; :next&amp;lt;CR&amp;gt;&#xA;map &amp;lt;F5&amp;gt; :previous&amp;lt;CR&amp;gt;&#xA;set formatoptions=r&#xA;call plug#begin('~/.vim/plugged')&#xA;    Plug 'jwalton512/vim-blade'&#xA;    Plug 'maslaral/the-creator.vim'&#xA;    &quot;Plug 'liuchengxu/space-vim-theme'&#xA;    Plug 'sainnhe/edge'&#xA;call plug#end()&#xA;&quot;colorscheme space_vim_theme&#xA;&quot;colorscheme the-creator&#xA;colorscheme edge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23677" LastActivityDate="2019-09-03T23:07:08.980" Title="Syntax highlighting shows a yellow bar on Windows 10" Tags="|syntax-highlighting|microsoft-windows|colorscheme|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21102" PostTypeId="1" CreationDate="2019-09-04T05:52:42.583" Score="9" ViewCount="6952" Body="&lt;p&gt;Whats the best way to clang-format a C/C++/GLSL a buffer on save, that does nothing in the case there is no clang-format file found for a project?&lt;/p&gt;&#xA;" OwnerUserId="301" LastActivityDate="2020-02-28T14:22:29.770" Title="How to clang-format the current buffer on save?" Tags="|formatting|save|filetype-c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21103" PostTypeId="1" AcceptedAnswerId="21104" CreationDate="2019-09-04T06:27:55.993" Score="5" ViewCount="2997" Body="&lt;p&gt;&lt;strong&gt;A bit of context:&lt;/strong&gt; I'm trying to use NeoVim after Spacemacs. In Spacemacs, there is &lt;code&gt;gql&lt;/code&gt; key combination that hard wraps current long line of text into multiple short lines. It is useful if I want to write a long documentation comment. So I write a single line and let the IDE figure out linebreaks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I'm trying to configure NeoVim to wrap lines. And I want to achieve the following behaviour:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Don't wrap lines automatically when reaching a specific limit (like 80 columns).&lt;/li&gt;&#xA;&lt;li&gt;Wrap line (ideally preserving indentation) with some hotkey like &lt;code&gt;gql&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;:set tw=80&lt;/code&gt; and I can wrap lines by &lt;code&gt;gqq&lt;/code&gt;, but they are also wrapped automatically...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure my NeoVim environment to do this?&lt;/p&gt;&#xA;" OwnerUserId="23680" LastActivityDate="2019-09-04T08:13:36.537" Title="How to wrap lines on hotkey but not automatically?" Tags="|neovim|wrapping|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21104" PostTypeId="2" ParentId="21103" CreationDate="2019-09-04T08:13:36.537" Score="4" Body="&lt;pre&gt;&lt;code&gt;:set fo-=tc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can set &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27formatoptions%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'formatoptions'&lt;/code&gt;&lt;/a&gt; with your preferences controlling when and how to format text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/change.txt.html#fo-table&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help fo-table&lt;/code&gt;&lt;/a&gt; for the list of supported values in this option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, you'll want to remove these two:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;t&lt;/code&gt;: Auto-wrap text using &lt;code&gt;'textwidth'&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;c&lt;/code&gt;: Auto-wrap comments using &lt;code&gt;'textwidth'&lt;/code&gt;, inserting the current comment leader automatically.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, to remove them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set formatoptions-=tc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or the short abbreviated form at the beginning of the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll probably want to make sure you're preserving this one, applicable to comments specifically:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;q&lt;/code&gt;: Allow formatting of comments with &lt;code&gt;gq&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's typically included in the default (which is &lt;code&gt;tcq&lt;/code&gt;), so usually you don't need any action to keep it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27comments%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'comments'&lt;/code&gt;&lt;/a&gt; option.&lt;/li&gt;&#xA;&lt;li&gt;The full &lt;a href=&quot;https://vimhelp.org/change.txt.html#fo-table&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;fo-table&lt;/code&gt;&lt;/a&gt; for more useful options related to formatting and breaking lines.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-04T08:13:36.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21105" PostTypeId="1" AcceptedAnswerId="21106" CreationDate="2019-09-04T08:39:08.070" Score="4" ViewCount="552" Body="&lt;p&gt;Sometimes when there are a lot of buffers, it becomes hard to see which buffers have been modified using &lt;code&gt;:ls&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4513" LastActivityDate="2019-09-04T09:06:58.227" Title="How do I list only modified buffers in vim?" Tags="|buffers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21106" PostTypeId="2" ParentId="21105" CreationDate="2019-09-04T08:52:22.873" Score="7" Body="&lt;pre&gt;&lt;code&gt;:ls +&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Als&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :ls&lt;/code&gt;&lt;/a&gt;, you'll see it takes an optional &quot;flags&quot; argument, one of which is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;[flags]&lt;/code&gt; can be a combination of the following characters, which restrict the buffers to be listed:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;code&gt;+&lt;/code&gt;: modified buffers&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-04T08:52:22.873" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21107" PostTypeId="2" ParentId="21105" CreationDate="2019-09-04T09:06:58.227" Score="3" Body="&lt;p&gt;&lt;code&gt;:ls +&lt;/code&gt; shows all modified buffers&lt;/p&gt;&#xA;" OwnerUserId="23681" LastActivityDate="2019-09-04T09:06:58.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21108" PostTypeId="1" AcceptedAnswerId="21109" CreationDate="2019-09-04T09:34:39.213" Score="2" ViewCount="106" Body="&lt;p&gt;While selecting in visual mode I often accidentally hit &lt;kbd&gt;H&lt;/kbd&gt; or &lt;kbd&gt;L&lt;/kbd&gt; instead of &lt;kbd&gt;h&lt;/kbd&gt; or &lt;kbd&gt;l&lt;/kbd&gt; due to having used &lt;kbd&gt;Shift&lt;/kbd&gt; for some previous command (like e.g. &lt;kbd&gt;V&lt;/kbd&gt; to start selection by line) and not yet released it when trying to move (because hands are not in ideal synchronization).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal mode this is not a problem, because a remedy is quick: just hit &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;o&lt;/kbd&gt; and continue. But in visual mode this &quot;go back&quot; command doesn't appear to work. Currently I have to go to normal mode and start selecting all over again, which is an unproductive fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how can I go back in visual mode? Is there another mapping for this command?&lt;/p&gt;&#xA;" OwnerUserId="1081" LastActivityDate="2019-09-04T09:45:16.857" Title="How to go back after accidentally hitting H in visual mode?" Tags="|visual-mode|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21109" PostTypeId="2" ParentId="21108" CreationDate="2019-09-04T09:45:16.857" Score="3" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%60%60&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;``&lt;/code&gt;&lt;/a&gt; motion, which goes back to the position before the last jump.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only care about the line, not the column (for example, if you're using visual line mode), then &lt;code&gt;''&lt;/code&gt; also works.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-04T09:45:16.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21110" PostTypeId="1" AcceptedAnswerId="21112" CreationDate="2019-09-04T10:30:38.727" Score="5" ViewCount="2532" Body="&lt;p&gt;Considering the following regex pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\s*&amp;lt;&amp;lt;.\{-}&amp;gt;&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to match those patterns &lt;em&gt;only when the cursor is somewhere on this pattern&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if have the line (the character enclosed in [] is the cusor position):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is &amp;lt;&amp;lt;on[e]&amp;gt;&amp;gt; and this is &amp;lt;&amp;lt;another one&amp;gt;&amp;gt;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to only match &lt;code&gt;&amp;lt;&amp;lt;one&amp;gt;&amp;gt;&lt;/code&gt;, not &lt;code&gt;&amp;lt;&amp;lt;another one&amp;gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that &lt;code&gt;\%#&lt;/code&gt; specifies the cursor position, but I don't know how to apply it to state that &lt;em&gt;the cursor may be anywhere on that pattern&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible somehow?&lt;/p&gt;&#xA;" OwnerUserId="21417" LastActivityDate="2019-09-05T11:21:17.767" Title="Regex pattern matching cursor-position" Tags="|regular-expression|cursor|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21112" PostTypeId="2" ParentId="21110" CreationDate="2019-09-04T11:31:22.397" Score="4" Body="&lt;p&gt;One solution is to use a lookahead before the regex and a lookbehind after the regex. That ensures the cursor is &lt;em&gt;after&lt;/em&gt; the start of the match, and &lt;em&gt;before&lt;/em&gt; the end of the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One issue with the regex you're using is &lt;code&gt;.\{-}&lt;/code&gt; which is a non-greedy operator. If you add anchors for the cursor position, this will end up matching from the beginning of &lt;code&gt;&amp;lt;&amp;lt;one&lt;/code&gt; to the end of &lt;code&gt;another one&amp;gt;&amp;gt;&lt;/code&gt;. To solve that, I'm replacing it with &lt;code&gt;\([^&amp;gt;]\|&amp;gt;[^&amp;gt;]\)*&lt;/code&gt;, which will match any character other than &lt;code&gt;&amp;gt;&lt;/code&gt;, or a single &lt;code&gt;&amp;gt;&lt;/code&gt; followed by a different character. (Perhaps a negative match would have worked here instead.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\(.*\%#\)\@=\s*&amp;lt;&amp;lt;\([^&amp;gt;]\|&amp;gt;[^&amp;gt;]\)*&amp;gt;&amp;gt;\(\%#.*\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; Using &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%40%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\@&amp;gt;&lt;/code&gt;&lt;/a&gt; for the middle bit is able to preserve the &lt;code&gt;-\{-}&lt;/code&gt;, resulting in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; /\(.*\%#\)\@=\(\s*&amp;lt;&amp;lt;.\{-}&amp;gt;&amp;gt;\)\@&amp;gt;\(\%#.*\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-09-05T11:21:17.767" LastActivityDate="2019-09-05T11:21:17.767" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21113" PostTypeId="1" AcceptedAnswerId="21119" CreationDate="2019-09-04T12:41:33.463" Score="23" ViewCount="22691" Body="&lt;p&gt;I'm writing a Vim plugin which will need to surround the word directly under your cursor with a quotes. I have tried using simple solutions which use commands like &quot;b&quot; and &quot;e&quot; executed in normal mode, in combination with other cursor position commands, though those felt clunky and non-robust. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wondered if there was perhaps, a builtin way to surround text, or a more expedient method of doing so.&lt;/p&gt;&#xA;" OwnerUserId="23679" LastEditorUserId="23679" LastEditDate="2019-09-04T15:07:27.210" LastActivityDate="2023-09-02T12:04:51.523" Title="Vimscript - Surround word under cursor with quotes" Tags="|vimscript|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21114" PostTypeId="2" ParentId="21110" CreationDate="2019-09-04T13:00:42.507" Score="6" Body="&lt;p&gt;You can use the atom &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#/branch&quot; rel=&quot;noreferrer&quot;&gt;/\&amp;amp;&lt;/a&gt;. This is like forcing two different regular atoms to match at the same position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now it becomes a bit complicated, since the cursor position can be anywhere inside the &lt;code&gt;&amp;lt;&amp;lt;..&amp;gt;&amp;gt;&lt;/code&gt; and then you also want to allow whitespace inside those &lt;code&gt;&amp;lt;&amp;lt;..&amp;gt;&amp;gt;&lt;/code&gt;. This makes it a bit complex to match the correct item if there are several matches in a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So instead of using &lt;code&gt;.\{-\}&lt;/code&gt; to allow an arbitrarily long number of matches (even other &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt;), you need to restrict your match to only match until the &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make the pattern simpler, let's for now assume all characters are allowed except for &lt;code&gt;&amp;gt;&lt;/code&gt;. That would make the pattern like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&amp;lt;[^&amp;gt;]\+&amp;gt;&amp;gt;\&amp;amp;[^&amp;gt;]*\%#[^&amp;gt;]*&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which means &lt;code&gt;&amp;lt;&lt;/code&gt; followed by any character except &lt;code&gt;&amp;gt;&lt;/code&gt; (&lt;code&gt;[^&amp;gt;]&lt;/code&gt;) and at the same time (&lt;code&gt;\&amp;amp;&lt;/code&gt;) allow any character except &lt;code&gt;&amp;gt;&lt;/code&gt;, followed by the cursor position (&lt;code&gt;\%#&lt;/code&gt;), followed by any character except &lt;code&gt;&amp;gt;&lt;/code&gt; followed by &gt;&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can make this more complicated by enforcing the &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; delimiter. Possible search patterns are &lt;code&gt;\(&amp;gt;&amp;gt;\)\@!&lt;/code&gt; (not followed by &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;) or the already mentioned &lt;code&gt;\([^&amp;gt;]\|&amp;gt;[^&amp;gt;]\)&lt;/code&gt;. However this will make your search pattern a lot more complex, so this is left as an exercise to the reader ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also want to have a look at the distributed plugin &lt;a href=&quot;https://vimhelp.org/pi_logipat.txt.html&quot; rel=&quot;noreferrer&quot;&gt;LogiPat&lt;/a&gt;, which allows to construct patterns using logical operators (and, or, not, etc).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-09-04T13:00:42.507" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21115" PostTypeId="1" AcceptedAnswerId="21117" CreationDate="2019-09-04T15:04:29.580" Score="3" ViewCount="284" Body="&lt;h2&gt;Before you start reading.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Before having answers, I thought &lt;code&gt;vimdiff&lt;/code&gt; was a binary program because I'm used to Debian's &lt;code&gt;file&lt;/code&gt;, which seems not to honor POSIX (but I didn't knew); but then I used macOS 10.14 &lt;code&gt;file&lt;/code&gt;, which seems to honor POSIX (without me knowing such).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The original post.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Read in &lt;a href=&quot;https://vi.stackexchange.com/a/17552/13260&quot;&gt;this nice answer&lt;/a&gt;, you can see it for yourself, you can diff two documents without the need to use &lt;code&gt;vimdiff&lt;/code&gt;. Awesome!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That made me suppose &lt;code&gt;vimdiff&lt;/code&gt; should be some kind of scripted use of Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was surprised to read that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ uname -a&#xA;Darwin llc.local 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64&#xA;$ echo &quot;I don't know what's the Darwin equivalent to \`lsb_release -a\`.&quot;&#xA;I don't know what's the Darwin equivalent to `lsb_release -a`.&#xA;$ which vimdiff&#xA;/usr/bin/vimdiff&#xA;$ file /usr/bin/vimdiff &#xA;/usr/bin/vimdiff: Mach-O 64-bit executable x86_64&#xA;$ hexdump -C /usr/bin/vimdiff | head&#xA;00000000  cf fa ed fe 07 00 00 01  03 00 00 80 02 00 00 00  |................|&#xA;00000010  12 00 00 00 20 07 00 00  85 00 20 00 00 00 00 00  |.... ..... .....|&#xA;00000020  19 00 00 00 48 00 00 00  5f 5f 50 41 47 45 5a 45  |....H...__PAGEZE|&#xA;00000030  52 4f 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |RO..............|&#xA;00000040  00 00 00 00 01 00 00 00  00 00 00 00 00 00 00 00  |................|&#xA;00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|&#xA;00000060  00 00 00 00 00 00 00 00  19 00 00 00 28 02 00 00  |............(...|&#xA;00000070  5f 5f 54 45 58 54 00 00  00 00 00 00 00 00 00 00  |__TEXT..........|&#xA;00000080  00 00 00 00 01 00 00 00  00 c0 19 00 00 00 00 00  |................|&#xA;00000090  00 00 00 00 00 00 00 00  00 c0 19 00 00 00 00 00  |................|&#xA;$ vimdiff --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 19 2019 19:08:44)&#xA;Included patches: 1-503, 505-680, 682-1283, 1365&#xA;Compiled by root@apple.com&#xA;Normal version without GUI.  Features included (+) or not (-):&#xA;+acl             +file_in_path    -mouse_sgr       +tag_old_static&#xA;-arabic          +find_in_path    -mouse_sysmouse  -tag_any_white&#xA;+autocmd         +float           -mouse_urxvt     -tcl&#xA;-balloon_eval    +folding         +mouse_xterm     -termguicolors&#xA;-browse          -footer          +multi_byte      -terminal&#xA;+builtin_terms   +fork()          +multi_lang      +terminfo&#xA;+byte_offset     -gettext         -mzscheme        +termresponse&#xA;+channel         -hangul_input    +netbeans_intg   +textobjects&#xA;+cindent         +iconv           +num64           +timers&#xA;-clientserver    +insert_expand   +packages        +title&#xA;-clipboard       +job             +path_extra      -toolbar&#xA;+cmdline_compl   +jumplist        -perl            +user_commands&#xA;+cmdline_hist    -keymap          +persistent_undo +vertsplit&#xA;+cmdline_info    +lambda          +postscript      +virtualedit&#xA;+comments        -langmap         +printer         +visual&#xA;-conceal         +libcall         -profile         +visualextra&#xA;+cryptv          +linebreak       +python/dyn      +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             -rightleft       +windows&#xA;+diff            +menu            +ruby/dyn        +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;-emacs_tags      -mouseshape      +startuptime     -xpm&#xA;+eval            -mouse_dec       +statusline      -xsmp&#xA;+ex_extra        -mouse_gpm       -sun_workshop    -xterm_clipboard&#xA;+extra_search    -mouse_jsbterm   +syntax          -xterm_save&#xA;-farsi           -mouse_netterm   +tag_binary      &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      &#xA;Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa           &#xA;$ brew info vim&#xA;vim: stable 8.1.1850 (bottled), HEAD&#xA;Vi 'workalike' with many additional features&#xA;https://www.vim.org/&#xA;Conflicts with:&#xA;  ex-vi (because vim and ex-vi both install bin/ex and bin/view)&#xA;  macvim (because vim and macvim both install vi* binaries)&#xA;Not installed&#xA;From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/vim.rb&#xA;==&amp;gt; Dependencies&#xA;Required: gettext ✘, lua ✘, perl ✘, python ✔, ruby ✘&#xA;==&amp;gt; Options&#xA;--HEAD&#xA;    Install HEAD version&#xA;==&amp;gt; Analytics&#xA;install: 69,509 (30 days), 203,502 (90 days), 819,729 (365 days)&#xA;install_on_request: 64,612 (30 days), 188,872 (90 days), 745,495 (365 days)&#xA;build_error: 0 (30 days)&#xA;$ brew info macvim&#xA;macvim: stable 8.1-157 (bottled), HEAD&#xA;GUI for vim, made for macOS&#xA;https://github.com/macvim-dev/macvim&#xA;Conflicts with:&#xA;  vim (because vim and macvim both install vi* binaries)&#xA;Not installed&#xA;From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/macvim.rb&#xA;==&amp;gt; Dependencies&#xA;Required: cscope ✘, lua ✘, python ✔&#xA;==&amp;gt; Requirements&#xA;Build: xcode ✔&#xA;==&amp;gt; Options&#xA;--HEAD&#xA;    Install HEAD version&#xA;==&amp;gt; Analytics&#xA;install: 7,845 (30 days), 30,394 (90 days), 137,548 (365 days)&#xA;install_on_request: 7,268 (30 days), 27,783 (90 days), 124,890 (365 days)&#xA;build_error: 0 (30 days)&#xA;$ brew info ex-vi&#xA;ex-vi: stable 050325 (bottled)&#xA;UTF8-friendly version of tradition vi&#xA;https://ex-vi.sourceforge.io/&#xA;Conflicts with:&#xA;  vim (because ex-vi and vim both install bin/ex and bin/view)&#xA;Not installed&#xA;From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/ex-vi.rb&#xA;==&amp;gt; Analytics&#xA;install: 6 (30 days), 17 (90 days), 83 (365 days)&#xA;install_on_request: 6 (30 days), 17 (90 days), 83 (365 days)&#xA;build_error: 0 (30 days)&#xA;$ _&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;(EASY) &lt;strong&gt;Is &lt;code&gt;vimdiff&lt;/code&gt; really supposed to be a binary program always?&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;(HARD?) Is it really supposed to be a binary program in whatever provider I have been choosing (macOS default shipping, I guess)?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;(BONUS) Does this look like a compromised &lt;code&gt;vimdiff&lt;/code&gt;?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&lt;sub&gt;The X of my Y is, I want to write some Vim script, and I wanted to draw inspiration from the scripts I thought Vim would use to diff.&lt;/sub&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="13260" LastEditorUserId="13260" LastEditDate="2019-09-04T22:26:24.033" LastActivityDate="2020-09-23T17:37:11.800" Title="If one can diff from Vim without the need to boot `vimdiff` then why is it a binary program?" Tags="|vimdiff|macos|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21116" PostTypeId="2" ParentId="21113" CreationDate="2019-09-04T15:18:36.773" Score="20" Body="&lt;p&gt;Yes, a plug-in for surrounding with quotes exists! &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;noreferrer&quot;&gt;vim-surround&lt;/a&gt; is what you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To surround the current word in double quotes, you can use &lt;code&gt;ysiw&quot;&lt;/code&gt; once you have the plug-in installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ys&lt;/code&gt; is the command to surround and object (there's also &lt;code&gt;cs&lt;/code&gt; to replace one delmiter with another, &lt;code&gt;ds&lt;/code&gt; to remove surrounding), then &lt;a href=&quot;https://vimhelp.org/motion.txt.html#iw&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;iw&lt;/code&gt;&lt;/a&gt; is a &lt;a href=&quot;https://vimhelp.org/motion.txt.html#text-objects&quot; rel=&quot;noreferrer&quot;&gt;text-object&lt;/a&gt; defining what to surround  and finally &lt;code&gt;&quot;&lt;/code&gt; is what to surround it with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to read &lt;a href=&quot;https://github.com/tpope/vim-surround/blob/v2.1/doc/surround.txt&quot; rel=&quot;noreferrer&quot;&gt;the docs for vim-surround&lt;/a&gt; to see all that it can do. It's really a lot!&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-04T15:18:36.773" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21117" PostTypeId="2" ParentId="21115" CreationDate="2019-09-04T15:31:25.257" Score="6" Body="&lt;p&gt;vimdiff as well as the other binaries are just symbolic links to the actual vim binary. This is done because when vim starts up it checks under which name it has been started and does perform some extras (like running diff mode for &lt;code&gt;vimdiff&lt;/code&gt;, starting the gui for &lt;code&gt;gvim&lt;/code&gt;, or just starting in read-only mode for &lt;code&gt;view&lt;/code&gt; or starting in ex mode for &lt;code&gt;ex&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in short the answers to your questions are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) no (except for when your system or filesystem does not support links)&lt;br&gt;&#xA;2) no, a plain old symbold/hard link should just work&lt;br&gt;&#xA;3) no&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="1238" LastEditDate="2019-09-04T22:06:11.857" LastActivityDate="2019-09-04T22:06:11.857" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21118" PostTypeId="1" AcceptedAnswerId="21120" CreationDate="2019-09-04T15:39:27.140" Score="3" ViewCount="486" Body="&lt;p&gt;I rebound control + H/J/K/L to navigate between splits without needing &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-J&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-J&amp;gt;&#xA;nnoremap &amp;lt;C-K&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-K&amp;gt;&#xA;nnoremap &amp;lt;C-L&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-L&amp;gt;&#xA;nnoremap &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-H&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when inside a terminal opened with &lt;code&gt;:terminal&lt;/code&gt;, these keybinds are interpreted as terminal commands. &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; clears the terminal instead of moving to the right, for example. Is it possible to use my same navigation commands inside the vim terminal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running bash in Terminal.app on Mac OS X, if that's relevant.&lt;/p&gt;&#xA;" OwnerUserId="23689" LastEditorUserId="23689" LastEditDate="2019-09-04T15:46:49.620" LastActivityDate="2019-09-04T16:21:45.910" Title="Is it possible to use &lt;C-H&gt; (and J/K/L) for navigation inside a Vim 8 terminal?" Tags="|terminal-buffer|vim8|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21119" PostTypeId="2" ParentId="21113" CreationDate="2019-09-04T15:43:15.550" Score="40" Body="&lt;p&gt;You can surround the word currently under the cursor in quotes with the following normal mode commands:&lt;/p&gt;&#xA;&lt;p&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;&amp;quot;&lt;/kbd&gt;&lt;kbd&gt;&amp;quot;&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;p&gt;Replace &lt;code&gt;iw&lt;/code&gt; with any other Vim motion/text object to surround other things with quotes&lt;sup&gt;*&lt;/sup&gt;. Or &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt; with any other pair of characters to surround the object with different things.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sup&gt;* Or use &lt;code&gt;c&lt;/code&gt; from visual mode to surround text that is hard to describe with a single motion.&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you want to surround the object with a longer piece of text, such as an HTML &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag, you can use &lt;kbd&gt;Ctrl-R&lt;/kbd&gt; instead of the &lt;code&gt;P&lt;/code&gt; put command:&lt;/p&gt;&#xA;&lt;p&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;&amp;lt;&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;&amp;gt;&lt;/kbd&gt;&lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;&amp;quot;&lt;/kbd&gt;&lt;kbd&gt;&amp;lt;&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;&amp;gt;&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-R&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-R&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&lt;p&gt;Objects smaller than a line can also be surrounded using the &lt;a href=&quot;https://vimhelp.org/change.txt.html#quote-&quot; rel=&quot;noreferrer&quot;&gt;small delete register&lt;/a&gt;, and as of Vim 8.2.2189, this is repeatable via the dot command, making it easy to apply the edit quickly in several different places.&lt;/p&gt;&#xA;&lt;p&gt;So e.g. to go from this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;one two three four&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(one two) (three four)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;type:&lt;/p&gt;&#xA;&lt;p&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;(&lt;/kbd&gt;&lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;-&lt;/kbd&gt;&lt;kbd&gt;)&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;.&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Thanks to Christian Brabandt for &lt;a href=&quot;https://vi.stackexchange.com/a/28528/343&quot;&gt;letting us know about the fix&lt;/a&gt;, and for &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.2.2189&quot; rel=&quot;noreferrer&quot;&gt;implementing it&lt;/a&gt;!&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, as dicussed in the comments, if you attempt to use &lt;kbd&gt;Ctrl-R&lt;/kbd&gt; to surround an object larger than a single line (or prior to v8.2.2189), when you repeat this with the dot command, it will enter the text from the &lt;em&gt;original&lt;/em&gt; change command. As &lt;a href=&quot;https://vi.stackexchange.com/questions/21113/vimscript-surround-word-under-cursor-with-quotes/21119#comment37003_21119&quot;&gt;@user938271 explains&lt;/a&gt;, you can workaround this by using &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;Ctrl-O&lt;/kbd&gt; or &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;Ctrl-P&lt;/kbd&gt; instead of a plain &lt;kbd&gt;Ctrl-R&lt;/kbd&gt; when inserting the contents of the register.&lt;/p&gt;&#xA;&lt;p&gt;So to go from:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;li&amp;gt;one&#xA;&amp;lt;li&amp;gt;two&#xA;&#xA;&amp;lt;li&amp;gt;three&#xA;&amp;lt;li&amp;gt;four&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;ul&amp;gt;&#xA;&amp;lt;li&amp;gt;one&#xA;&amp;lt;li&amp;gt;two&#xA;&amp;lt;/ul&amp;gt;&#xA;&#xA;&amp;lt;ul&amp;gt;&#xA;&amp;lt;li&amp;gt;three&#xA;&amp;lt;li&amp;gt;four&#xA;&amp;lt;/ul&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can type:&lt;/p&gt;&#xA;&lt;p&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;&amp;lt;&lt;/kbd&gt;&lt;kbd&gt;u&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt;&lt;kbd&gt;&amp;gt;&lt;/kbd&gt;&lt;kbd&gt;Return&lt;/kbd&gt;&lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;Ctrl-O&lt;/kbd&gt;&lt;kbd&gt;&amp;quot;&lt;/kbd&gt;&lt;kbd&gt;&amp;lt;&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;u&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt;&lt;kbd&gt;&amp;gt;&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;.&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2021-03-25T09:58:33.927" LastActivityDate="2021-03-25T09:58:33.927" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="21120" PostTypeId="2" ParentId="21118" CreationDate="2019-09-04T16:21:45.910" Score="5" Body="&lt;p&gt;You need to use &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Atnoremap&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:tnoremap&lt;/code&gt;&lt;/a&gt; to map keys in the &lt;code&gt;:terminal&lt;/code&gt; window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you want that to work in both normal mode of a regular buffer and of terminal windows, you need to add another set of mappings for the terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tnoremap &amp;lt;C-J&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-J&amp;gt;&#xA;tnoremap &amp;lt;C-K&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-K&amp;gt;&#xA;tnoremap &amp;lt;C-L&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-L&amp;gt;&#xA;tnoremap &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;&amp;lt;C-H&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Beware that these keys usually have useful functions in programs running inside the terminal window (such as the shell.) For example, &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; to backspace last character, &lt;code&gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; to redraw the screen, &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; to delete from cursor to end of line. You should think twice about whether you're going to miss any of them. If you want to preserve them, you can also adding alternative mappings (possibly longer ones) mapping back to the keys you're remapping here.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-04T16:21:45.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21121" PostTypeId="1" CreationDate="2019-09-04T17:12:29.593" Score="1" ViewCount="156" Body="&lt;p&gt;Syntax highlighting just stopped working on my mac (v 10.14.6). I've been trying to get it back over the past 2 days with no success. I have neovim (v 0.3.8) and when I use &lt;code&gt;:syntax&lt;/code&gt;, the command line says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;No Syntax items defined for this buffer. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, I am using iterm2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is a snippet of my &lt;code&gt;init.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype plugin indent on  &#xA;:syntax on&#xA;set background=dark&#xA;colorscheme base16-snazzy&#xA;set termguicolors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23691" LastEditorUserId="18609" LastEditDate="2019-09-04T21:27:14.997" LastActivityDate="2019-09-04T21:27:14.997" Title="vim syntax highlight" Tags="|syntax-highlighting|syntax|" AnswerCount="0" CommentCount="5" ClosedDate="2019-09-28T11:14:07.040" ContentLicense="CC BY-SA 4.0" />
  <row Id="21122" PostTypeId="1" CreationDate="2019-09-04T20:40:50.297" Score="1" ViewCount="616" Body="&lt;p&gt;I'm trying to get to the point where I can build a CMake project in neovim and have it output a quickfix list that I can quickly step through.  In Visual Studio, I would typically hit CTRL+b for build, and use F8 to step through errors.  That's what I'm aiming for.  When I run a command line such as this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ASyncRun cmake --build .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I see the following in my quickfix window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|| [cmake --build .]&#xA;|| Microsoft (R) Build Engine version 16.2.0-preview.19264.2+c3389964c for .NET Framework&#xA;|| Copyright (C) Microsoft Corporation. All rights reserved.&#xA;|| &#xA;||   Checking Build System&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure why I get the || at the beginning of each line, but they are obviously messing up the quickfix, because :cn, etc. just steps through every line.&#xA;I was hoping for just a list of error lines that I could step through.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any tips for getting this to work on Windows?&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2020-05-31T22:07:35.723" Title="Quickfix and building a CMake project on windows" Tags="|neovim|microsoft-windows|quickfix|filetype-cmake|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21123" PostTypeId="2" ParentId="21122" CreationDate="2019-09-04T21:25:10.920" Score="1" Body="&lt;p&gt;I found I needed to change my errorformat for VC.  Here's what I did: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Thanks to https://forums.handmadehero.org/index.php/forum?view=topic&amp;amp;catid=4&amp;amp;id=704#3982&#xA;&quot; error message formats&#xA;&quot; Microsoft MSBuild&#xA;set errorformat+=\\\ %#%f(%l\\\,%c):\ %m&#xA;&quot; Microsoft compiler: cl.exe&#xA;set errorformat+=\\\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %m&#xA;&quot; Microsoft HLSL compiler: fxc.exe&#xA;set errorformat+=\\\ %#%f(%l\\\,%c-%*[0-9]):\ %#%t%[A-z]%#\ %m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2019-09-04T21:25:10.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21124" PostTypeId="2" ParentId="21095" CreationDate="2019-09-04T21:52:37.953" Score="0" Body="&lt;p&gt;If I'm understanding you correctly, and your goal is for CtrlP only to list files that have an &lt;code&gt;.md&lt;/code&gt; extension, you just need to alter the &lt;code&gt;--glob&lt;/code&gt; field in the rg command you included in your question:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ctrlp_user_command = 'rg %s --files --hidden --color=never --glob &quot;*.md&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-09-04T21:52:37.953" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21125" PostTypeId="1" CreationDate="2019-09-04T22:46:57.223" Score="2" ViewCount="112" Body="&lt;p&gt;When I use Vim on my home Ubuntu computer, I am able to use alt-[key] as a quick way to jump from insert mode to normal mode and immediately run the [key] command. One thing I frequently do is: alt-j or alt-k from insert mode, where it immediately jumps up or down in normal mode. Unfortunately on mac iterm2, using alt-j does nothing and option-j likewise simply adds the ' character. How can I edit this to use option/alt in the same way?&lt;/p&gt;&#xA;" OwnerUserId="14314" LastActivityDate="2019-09-04T22:46:57.223" Title="How to mimic Alt key functionality from ubuntu gnome to OSX iTerm2?" Tags="|macos|iterm2|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21126" PostTypeId="2" ParentId="5941" CreationDate="2019-09-05T00:18:27.070" Score="0" Body="&lt;p&gt;Instead of writing a regex as @romainl seem to be suggesting, You can have taglists installed and add the following to .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-l&amp;gt; :TlistToggle&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now by pressing &lt;code&gt;Ctrl + l&lt;/code&gt; you'll show/hide the list of functions, structures and more.&lt;/p&gt;&#xA;" OwnerUserId="9059" LastActivityDate="2019-09-05T00:18:27.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21127" PostTypeId="1" CreationDate="2019-09-06T02:37:33.497" Score="1" ViewCount="12650" Body="&lt;p&gt;Here's how I restart vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim&#xA;:q&#xA;$ vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to restart vim so that there is no need to type the second &lt;code&gt;vim&lt;/code&gt; in the shell?&lt;/p&gt;&#xA;" OwnerUserId="19712" LastActivityDate="2020-02-01T15:32:10.330" Title="How to restart vim from within vim?" Tags="|command-line|bash|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21128" PostTypeId="2" ParentId="21127" CreationDate="2019-09-06T11:16:56.393" Score="5" Body="&lt;p&gt;Add this in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno &amp;lt;space&amp;gt;R :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;vim_quit_and_restart()&amp;lt;cr&amp;gt;&#xA;fu! s:vim_quit_and_restart() abort&#xA;    if has('gui_running') | echo 'not available in GUI' | return | endif&#xA;    sil! update&#xA;    sil call system('kill -USR1 $(ps -p '.getpid().' -o ppid=)')&#xA;    qa!&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this in your bashrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;trap __catch_signal_usr1 USR1&#xA;__catch_signal_usr1() { trap __catch_signal_usr1 USR1; vim; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;code&gt;SPC R&lt;/code&gt; should make Vim restart.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Works on Vim 8.1.1967 and bash 4.3.48.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If your shell is zsh (version 5.7.1 sure; other versions probably), things get more complicated because of &lt;a href=&quot;https://unix.stackexchange.com/q/445051/289772&quot;&gt;a pitfall&lt;/a&gt;.&#xA;If you suspend Vim (&lt;code&gt;C-z&lt;/code&gt;, &lt;code&gt;:stop&lt;/code&gt;, &lt;code&gt;:suspend&lt;/code&gt;), after restarting it one or several times, you may not be able to send it back to the foreground, because for some reason the Vim job gets lost (absent from the shell's job table).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It could be a bug in zsh, or a race condition, I don't know.&#xA;There exists &lt;a href=&quot;https://unix.stackexchange.com/a/445192/289772&quot;&gt;a workaround&lt;/a&gt; (restarting from a hook):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;restarting_vim=&#xA;trap __catch_signal_usr1 USR1&#xA;__catch_signal_usr1() {&#xA;  trap __catch_signal_usr1 USR1&#xA;  restarting_vim=1&#xA;}&#xA;__restart_vim() {&#xA;  emulate -L zsh&#xA;  if [[ -n &quot;${restarting_vim}&quot; ]]; then&#xA;    restarting_vim=&#xA;    vim&#xA;  fi&#xA;}&#xA;precmd_functions=(__restart_vim)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it suffers from another issue; you can't restart several times consecutively, unless you suspend and &lt;code&gt;$ fg&lt;/code&gt; right back in between 2 restarts.&#xA;Maybe this could be fixed with an additional workaround, making zsh automatically suspend and &lt;code&gt;$ fg&lt;/code&gt; after every restart via another signal and trap, but it seems awkward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As long as you never suspend Vim (install &lt;code&gt;:nno &amp;lt;c-z&amp;gt; &amp;lt;nop&amp;gt;&lt;/code&gt; and &lt;code&gt;:vno &amp;lt;c-z&amp;gt; &amp;lt;nop&amp;gt;&lt;/code&gt; to avoid any accident), the Vim mapping + zsh trap works fine (at least in my experience).&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-09-16T12:11:38.070" LastActivityDate="2019-09-16T12:11:38.070" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21129" PostTypeId="1" CreationDate="2019-09-06T11:17:36.897" Score="1" ViewCount="280" Body="&lt;p&gt;My current workflow looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open a file in different splits, each split showing a different section&lt;/li&gt;&#xA;&lt;li&gt;Make appropriate edits in each split&lt;/li&gt;&#xA;&lt;li&gt;:wq from the split after editing&lt;/li&gt;&#xA;&lt;li&gt;Repeat as often as necessary &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This often ends up breaking the folds structure, as I find that on reopening the file after a series of edits, the folds are no longer where they are/were supposed to be. On one occasion it was so bad I had to delete all the folds and re-fold an entire 2000 line file. I would really like to avoid getting into that sort of annoyance again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What causes this and how do I preserve the folds? &lt;/p&gt;&#xA;" OwnerUserId="23720" LastActivityDate="2019-09-12T07:52:52.850" Title="Editing file in splits breaks the folding" Tags="|folding|split|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="21130" PostTypeId="1" CreationDate="2019-09-06T12:06:22.980" Score="5" ViewCount="2194" Body="&lt;p&gt;I have the given file&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;4 apples&#xA;2 bananas&#xA;6 peaches&#xA;3 grapes&#xA;1 pineapple&#xA;5 pears&#xA;3 tomatoes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What I want to do is to receive the following result instead:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;apple apple apple apple&#xA;banana banana&#xA;peach peach peach peach peach peach&#xA;grape grape grape&#xA;pineapple&#xA;pear pear pear pear pear&#xA;tomato tomato tomato&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I would imagine to do something along the lines of:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;&amp;quot;wyw$x&amp;quot;eyBddO&amp;lt;Esc&amp;gt;&amp;quot;e(&amp;quot;w)P&lt;/code&gt;&#xA;the part in brackets is supposed to result in something like &lt;code&gt;paste content of e for a w number of times&lt;/code&gt; which doesn't really seem to work out.&lt;/p&gt;&#xA;&lt;p&gt;[clarification for the given instructions would boil down to:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;yank the current word into w&lt;/li&gt;&#xA;&lt;li&gt;jump to the end of line, delete character (because of plurals, leaves me with a problem for words that are singular though)&lt;/li&gt;&#xA;&lt;li&gt;yank the current word from its beginning to cursor position into e&lt;/li&gt;&#xA;&lt;li&gt;delete the current line&lt;/li&gt;&#xA;&lt;li&gt;insert in one inserted line above this one, exit insert mode&lt;/li&gt;&#xA;&lt;li&gt;use the content of e to paste it w times&#xA;]&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I'm not exactly sure how i can use the number in &lt;code&gt;w&lt;/code&gt; as an argument for a command, which I execute &lt;code&gt;w&lt;/code&gt; times then.&lt;/p&gt;&#xA;&lt;p&gt;Can this be achieved at all? I'm looking for an answer using default vim, no additional external macros or anything like that.&lt;/p&gt;&#xA;&lt;p&gt;I would like to be able to just record this sequence and then to execute it for the number of lines on every line.&lt;/p&gt;&#xA;" OwnerUserId="23722" LastEditorUserId="43352" LastEditDate="2022-09-12T13:30:49.237" LastActivityDate="2022-09-12T13:30:49.237" Title="How to apply a register to a command?" Tags="|cut-copy-paste|macro|register|repeated-commands|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21131" PostTypeId="2" ParentId="21130" CreationDate="2019-09-06T12:44:55.653" Score="5" Body="&lt;p&gt;This is not exactly what you want, but you could visually select your lines, then run this global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^/exe 'norm! &quot;adiwD' | exe 'norm! '.@a.'p'&#xA;               ├───┘│                 ├────┘&#xA;               │    │                 └ paste unnamed register as many times as the number in register `a`&#xA;               │    └ delete word in unnamed register&#xA;               └ delete count in register `a`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There will we be an extra space in front of each line; to remove it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/^ /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;&lt;a href=&quot;https://vi.stackexchange.com/users/778/peter-rincker&quot;&gt;Peter Rincker&lt;/a&gt; has a &lt;a href=&quot;https://vi.stackexchange.com/questions/21130/how-to-apply-a-register-to-a-command/21131?noredirect=1#comment37049_21131&quot;&gt;shorter solution&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Broken down:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/exe 'norm x'|exe 'norm D'.@@.'p0x'&#xA;               │            │  ├───┘├┘&#xA;               │            │  │    └ delete extra space at the start of the line&#xA;               │            │  └ paste word count times&#xA;               │            └ delete word in unnamed register&#xA;               └ delete count in unnamed register&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make it more reliable, you could suffix &lt;code&gt;:norm&lt;/code&gt; with a bang (to ignore custom mappings), and delete the count with &lt;code&gt;diw&lt;/code&gt; (to handle multi-digit numbers):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/exe 'norm! diw'|exe 'norm! D'.@@.'p0x'&#xA;              ^ ^^^           ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, select your lines, then run this substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\(\d\+\)\s\+\(\k\+\)/\=repeat(submatch(2).' ', str2nr(submatch(1)))&#xA;  ├──────┘    ├──────┘ ├┘│      ├─────────────┘  ├─────────────────┘&#xA;  │           │        │ │      │                └ as many times as the count in the capturing group 1&#xA;  │           │        │ │      └ the capturing group 2 (word) followed by a space&#xA;  │           │        │ └ repeat the next string&#xA;  │           │        └ use evaluation of next expression for the replacement&#xA;  │           └ capture word&#xA;  └ capture count&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There will we be an extra space at the end of each line; to remove it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/ $/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm not sure the call to str2nr() is required.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If the number starts with a leading &lt;code&gt;0&lt;/code&gt;, Vim will take it as octal.&#xA;This is why, without &lt;code&gt;str2nr()&lt;/code&gt;, the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;010 foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would be turned into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo foo foo foo foo foo foo foo &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whereas, with &lt;code&gt;str2nr()&lt;/code&gt;, it will be turned into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo foo foo foo foo foo foo foo foo foo &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a more &lt;a href=&quot;https://vi.stackexchange.com/a/6674/17449&quot;&gt;detailed explanation&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if the OP is working with octal numbers, then you're right, and they should remove &lt;code&gt;str2nr()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On the :s/// case you can even handle plurals easily with an s\? at the end of the match, outside the group.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You're right, although, I think you would need to also add &lt;code&gt;s\@&amp;lt;!&lt;/code&gt; at the end of the second capturing group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\(\d\+\)\s\+\(\k\+s\@&amp;lt;!\)s\=/\=repeat(submatch(2).' ', str2nr(submatch(1)))&#xA;                     ^^^^  ^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As explained by &lt;a href=&quot;https://vi.stackexchange.com/questions/21130/how-to-apply-a-register-to-a-command/21131?noredirect=1#comment37055_21131&quot;&gt;Christian Brabandt&lt;/a&gt;, you could also use &lt;code&gt;\{-}&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\(\d\+\)\s\+\(\k\{-}\)s\=\&amp;gt;/\=repeat(submatch(2).' ', str2nr(submatch(1)))&#xA;                  ^^^^     ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But no solution will correctly deal with words whose plural form adds more than a single &lt;code&gt;s&lt;/code&gt;, like &lt;code&gt;peach&lt;/code&gt; whose plural form adds &lt;code&gt;e&lt;/code&gt; and &lt;code&gt;s&lt;/code&gt;. I guess that for such words, you will have to fix them manually afterward.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also, suggestion to use \v in your regex, do you don't need to backslash all parens and plusses.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For various reasons, I prefer &lt;code&gt;\m&lt;/code&gt;, but if it helps, the command substitution can be rewritten like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\v(\d+)\s+(\k+s@&amp;lt;!)s=/\=repeat(submatch(2).' ', str2nr(submatch(1)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-09-06T22:06:18.910" LastActivityDate="2019-09-06T22:06:18.910" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21132" PostTypeId="2" ParentId="21130" CreationDate="2019-09-06T13:22:09.820" Score="1" Body="&lt;p&gt;You can indeed do this by recording a macro in vanilla Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Type the following series of keystrokes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;A&lt;/kbd&gt;&lt;kbd&gt; Space&lt;/kbd&gt;&lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;+&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You now have in register &lt;code&gt;&quot;q&lt;/code&gt; a macro that will convert a single line. You can replay this on the remaining 6 lines by typing &lt;kbd&gt;6&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Converting the plural nouns into singular nouns is left as an exercise for the reader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How it works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; Start recording a macro.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;A&lt;/kbd&gt;&lt;kbd&gt; Space&lt;/kbd&gt;&lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; This series of normal mode commands edits the line so that it now contains the series of keystrokes required to write out the desired output, starting from normal mode. So for the &lt;code&gt;apples&lt;/code&gt; line, it starts with a &lt;code&gt;count&lt;/code&gt;, and then &lt;code&gt;a&lt;/code&gt;ppends the string &lt;code&gt;&quot;apples &quot;&lt;/code&gt; four times. The pair of keystrokes&lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt; inserts a literal &lt;code&gt;ESC&lt;/code&gt; character into the buffer.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt; Move to the start of the line and delete the contents of the line. The deleted text will be stored in register the unnamed register &lt;code&gt;&quot;&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt; Playback the contents of register &lt;code&gt;&quot;&quot;&lt;/code&gt; (the text we just deleted. This writes the output into the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;x&lt;/kbd&gt; There's an extra space at the end of the line. Remove it.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;+&lt;/kbd&gt; Move to the start of the next line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt; End the recording.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-06T13:52:49.660" LastActivityDate="2019-09-06T13:52:49.660" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21134" PostTypeId="2" ParentId="21127" CreationDate="2019-09-06T14:18:34.887" Score="4" Body="&lt;p&gt;To answer your title question is pretty simple, just add this to your shell aliases (note untested, there may be syntax issues, but I think it gets the point across):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim() {&#xA;    while command vim $@; do&#xA;    done;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, run vim in an infinite loop. If you quit with :q, The script will restart vim, and you can break out and really quit by using :cq.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But I think if I just leave you there, it'll be doing you a disservice. I believe what your real question is and what you really wanted to do is that you want to reload vim config from scratch without losing your editing session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two things you need to do to make that happen:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You'll want to save your editing session and reload them later; this will allow you to restore your open buffers and window/tab arrangements. Vim supports the basic mechanism for session saving here using &lt;code&gt;:mksession&lt;/code&gt;, but this builtin functionality is a bit low level for daily use. If you need to do this regularly, you'd want to have a session manager to make this feature actually usable and mostly automatic, try either &lt;a href=&quot;https://github.com/xolox/vim-session&quot; rel=&quot;nofollow noreferrer&quot;&gt;xolox/vim-session&lt;/a&gt; plugin or &lt;a href=&quot;https://github.com/tpope/vim-obsession&quot; rel=&quot;nofollow noreferrer&quot;&gt;tpope/vim-obsession&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You probably also want to set &lt;a href=&quot;https://vi.stackexchange.com/questions/6/how-can-i-use-the-undofile&quot;&gt;persistent undofile&lt;/a&gt;, this setting allows you to undo your edits throughout multiple editing session (i.e. over restarts)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="632" LastActivityDate="2019-09-06T14:18:34.887" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21135" PostTypeId="1" CreationDate="2019-09-06T14:47:08.233" Score="0" ViewCount="38" Body="&lt;p&gt;I want to replace all these at once:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Heading Name --&amp;gt; Another New Title&#xA;headingName  --&amp;gt; anotherNewTitle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:%S/heading{, }Name/another{, }New{, }Title/g&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It replaces correctly including the first &lt;code&gt;{, }&lt;/code&gt; brace pair on the replacement side, but the second one is substituted directly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Heading Name --&amp;gt; Another New{, }Title&#xA;headingName  --&amp;gt; anotherNew{, }Title&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can replace a space-separated string with a space separated string, while also replacing the camel cased version with its camel cased version?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just found out I can use 'coercion' on a camel-cased word to turn it into a title-cased word, &lt;code&gt;crt&lt;/code&gt; on &lt;code&gt;anotherNewTitle&lt;/code&gt; would become &lt;code&gt;Another New Title&lt;/code&gt;, but I would like a solution that uses only one substitution.&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="9024" LastEditDate="2019-09-06T15:28:05.503" LastActivityDate="2019-09-07T23:26:52.210" Title="Reuse brace pair in abolish.vim" Tags="|plugin-vim-abolish|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21136" PostTypeId="2" ParentId="21130" CreationDate="2019-09-06T14:55:25.277" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;&quot;e(&quot;w)P&lt;/code&gt;: the part in brackets is supposed to result in something like &quot;paste content of e for a w number of times&quot; which doesn't really seem to work out.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;How to apply a register (as a count) to a command?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The direct answer to this is that you need to use &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Anormal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:normal!&lt;/code&gt;&lt;/a&gt; to run a normal mode command and &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:execute&lt;/code&gt;&lt;/a&gt; to assemble it from a string. You can then refer to the register while assembling that string, so you can use the value of that register as a count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your particular case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute 'normal! &quot;e'.@w.'P'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;wyw$x&quot;eyBddO&amp;lt;Esc&amp;gt;:exe 'norm! &quot;e'.@w.'P'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can record this sequence to a macro and repeat it on every line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note there's a bug on the &lt;code&gt;pineapple&lt;/code&gt; line, it will consume the last &lt;code&gt;e&lt;/code&gt; instead of an &lt;code&gt;s&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other answers actually offer better ways to approach this task (personally I found using &lt;code&gt;:s///&lt;/code&gt; with an expression in the replacement was the cleanest), but I wanted to address your direct query of how to use a register as part of a normal mode command, in this particular case as a count.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-06T14:55:25.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21137" PostTypeId="2" ParentId="21130" CreationDate="2019-09-06T15:10:06.473" Score="1" Body="&lt;p&gt;Here's yet another method:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Type &lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; to start recording a macro,&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; to delete the number into the &lt;code&gt;&quot;w&lt;/code&gt; register,&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt; to delete the word into the &lt;code&gt;&quot;e&lt;/code&gt; register,&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt; to enter insert mode and start using the &lt;strong&gt;&lt;em&gt;expression register&lt;/em&gt;&lt;/strong&gt;. See &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-R_=&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-R_=&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;a href=&quot;https://vimhelp.org/eval.txt.html#repeat%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;repeat(@e, @w)&lt;/code&gt;&lt;/a&gt;, which is now an expression that evaluates to &lt;code&gt;apples&lt;/code&gt; repeated four times, and press &lt;kbd&gt;Enter&lt;/kbd&gt; to enter the evaluation of this expression into the buffer.&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt; to exit insert mode, and delete the first space on the line.&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;+&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; to move to the next line and end the recording.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Like in the other macro-based answer, you can then press &lt;kbd&gt;6&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; to replay the recording on the next 6 lines.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-06T15:17:08.450" LastActivityDate="2019-09-06T15:17:08.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21138" PostTypeId="2" ParentId="21135" CreationDate="2019-09-06T19:19:41.263" Score="3" Body="&lt;p&gt;I have not found a way to use another &lt;code&gt;{}&lt;/code&gt; in the replacement portion of &lt;code&gt;:Subvert&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can however accomplish this replacement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%S/heading{Name, Name}/another{TitleNew, Title New}/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It just isn't very satisfying and does not really save you much work.&lt;/p&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2019-09-07T23:26:52.210" LastActivityDate="2019-09-07T23:26:52.210" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21139" PostTypeId="1" CreationDate="2019-09-06T19:50:39.283" Score="2" ViewCount="192" Body="&lt;p&gt;I've searched around for how to configure vim/syntastic to process mixed Jinja/Html files but haven't found the configuration steps with the right linter for Jinja/Html files. Does anyone know if there is a way to configure Syntastic to handle filetype jinja.html?&lt;/p&gt;&#xA;&lt;p&gt;The issue that caused me to consider this issue is a Jinja/Html template file with this line&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;{{ url_for('about') }}&amp;quot;&amp;gt;About&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Vim and Syntastic both report the filetype as jinja.html so they are aware of the mixed file.&lt;/p&gt;&#xA;&lt;p&gt;The html/tidy checker report these error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;layout.html|23 col 11 warning| &amp;lt;a&amp;gt; escaping malformed URI reference&#xA;layout.html|23 col 11 warning| &amp;lt;a&amp;gt; illegal characters found in URI &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;After checking I think this is correct Jinja/Html syntax. If so, then tidy is probaby not the right checker. Is there a checker or checker configuration that checks the syntax of mixed Jinja/Html files?&lt;/p&gt;&#xA;" OwnerUserId="14302" LastEditorUserId="14302" LastEditDate="2021-02-05T17:54:43.720" LastActivityDate="2021-02-05T17:54:43.720" Title="How to configure Syntastic to process mixed Jinja/Html files correctly?" Tags="|plugin-syntastic|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21141" PostTypeId="2" ParentId="20833" CreationDate="2019-09-07T09:50:17.433" Score="2" Body="&lt;p&gt;If you're looking for a  super simple solution, you can add the code from this page to your .vimrc.&#xA;&lt;a href=&quot;https://gist.github.com/maxboisvert/a63e96a67d0a83d71e9f49af73e71d93&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gist.github.com/maxboisvert/a63e96a67d0a83d71e9f49af73e71d93&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a plugin version of it which can be found here.&#xA;&lt;a href=&quot;https://github.com/maxboisvert/vim-simple-complete&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/maxboisvert/vim-simple-complete&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23679" LastActivityDate="2019-09-07T09:50:17.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21142" PostTypeId="1" AcceptedAnswerId="21144" CreationDate="2019-09-07T10:18:18.223" Score="0" ViewCount="187" Body="&lt;p&gt;I am using YCM to work on a pretty large C project. I generate multiple executables/static libraries hence have multiple makefiles and so multiple compilation databases (generated using BEAR) for different parts of my project (Structure of the project in the image). My problem is that YCM seems to pick a single compilation database for all the files in my vim session based on the directory where I open vim. So for example if I were to edit my &lt;code&gt;server.c&lt;/code&gt; and &lt;code&gt;util.c&lt;/code&gt; from &lt;code&gt;mainserver/MainServer&lt;/code&gt; AND open vim in the same directory, YCM would load their corresponding compilation database and everything works great... BUT if I were to start editing my &lt;code&gt;arrayList.c&lt;/code&gt; from &lt;code&gt;misc/ArrayList&lt;/code&gt; in the same vim session then it would still use the compilation database from &lt;code&gt;mainserver/MainServer&lt;/code&gt; instead of from &lt;code&gt;misc/ArrayList&lt;/code&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how do I get YCM to load a separate compilation database for every file based on its location instead of having YCM load a compilation database depending on where I initially opened vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My not very practical solution was to have a single compilation database in the root of my project and generate it by having a shell script find every makefile in my project and then have BEAR generate the compilation databases and append them all at the root of my project...I am hoping there is a better option than that....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot for any help&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZrXtI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZrXtI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22880" LastActivityDate="2019-09-07T18:38:07.033" Title="YCM compilation database NOT on a per file basis" Tags="|plugin-you-complete-me|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21144" PostTypeId="2" ParentId="21142" CreationDate="2019-09-07T18:38:07.033" Score="0" Body="&lt;p&gt;Here is the github issue I started, we have found a solution to this nasty problem &lt;a href=&quot;https://github.com/ycm-core/YouCompleteMe/issues/3483&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ycm-core/YouCompleteMe/issues/3483&lt;/a&gt; In short, switch to clangd completer&lt;/p&gt;&#xA;" OwnerUserId="22880" LastActivityDate="2019-09-07T18:38:07.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21145" PostTypeId="2" ParentId="18433" CreationDate="2019-09-07T22:48:27.990" Score="2" Body="&lt;p&gt;I had the same error message &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;checking if compile and link flags for Python 3 are sane... no&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and was running essentially the same command. The issue was with the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--with-python3-config-dir=/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which was incorrect.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked the actual location of the config using the output of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python3.7-config&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and that fixed the issue. &lt;/p&gt;&#xA;" OwnerUserId="23741" LastActivityDate="2019-09-07T22:48:27.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21146" PostTypeId="1" CreationDate="2019-09-08T04:37:48.407" Score="2" ViewCount="1392" Body="&lt;p&gt;Let's say I have a folder located on &lt;code&gt;~/question&lt;/code&gt; with 4 files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls &#xA;_file1  _file2  _file3  _file4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've realized that it's possible to open folders with Vim and it'll list the file names of all the files that are inside this folder. For example, on Linux if I try to open Vim with &lt;code&gt;vim ~/question&lt;/code&gt; I'll have something like the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sprfq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sprfq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen the F1 help and I've realized that there is a &lt;code&gt;R&lt;/code&gt; command for renaming files... But it doesn't work very well since I can't create macros while renaming files like that. The commands there work a lot different from the traditional Vim commands. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I've realized that if I try to rename those files with &lt;code&gt;:%s/_/-/g&lt;/code&gt; (after running &lt;code&gt;:set modifiable&lt;/code&gt;) it actually works and it renames all files substituting &lt;code&gt;_&lt;/code&gt; to &lt;code&gt;-&lt;/code&gt; on all of them... The only problem is that I can't go out and save the changes after, I see the error &lt;code&gt;&quot;readonly&quot; option is set(add ! to override)&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there any way of solving that reading only problem while editing folders? Is it really possible to rename files of a folder on Vim directly using regular expressions?&lt;/p&gt;&#xA;" OwnerUserId="2805" LastActivityDate="2019-09-11T22:25:17.347" Title="Is it possible to edit the name of files by opening their root folder on Vim?" Tags="|multiple-files|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21147" PostTypeId="2" ParentId="21146" CreationDate="2019-09-08T10:00:55.907" Score="2" Body="&lt;p&gt;There are a &lt;a href=&quot;https://joeyh.name/code/moreutils/&quot; rel=&quot;nofollow noreferrer&quot;&gt;number&lt;/a&gt; &lt;a href=&quot;https://www.nongnu.org/renameutils/&quot; rel=&quot;nofollow noreferrer&quot;&gt;of&lt;/a&gt; &lt;a href=&quot;https://github.com/qpkorr/vim-renamer&quot; rel=&quot;nofollow noreferrer&quot;&gt;tools&lt;/a&gt; that allow you to rename files in a Vim buffer in this way. &lt;a href=&quot;https://www.perlmonks.org/?node_id=852545&quot; rel=&quot;nofollow noreferrer&quot;&gt;mvi is the one that I use&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It takes the paths of the files that you want to rename as arguments, so, for example, to edit the names of all the Python files in your current directory, you would invoke it from your shell with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mvi *.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will open with a buffer containing all the files that match the &lt;code&gt;*.py&lt;/code&gt; glob and you can make edits using any Vim commands. Then you just save the buffer and quit and the changes are applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://vim.fandom.com/wiki/Bulk_rename_files_with_Vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt; on the Vim tips wiki for a shell-based solution.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-08T18:53:53.363" LastActivityDate="2019-09-08T18:53:53.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21148" PostTypeId="1" AcceptedAnswerId="21150" CreationDate="2019-09-08T10:49:12.260" Score="1" ViewCount="288" Body="&lt;p&gt;I'm currently switching to Vim as my main text editing tool and I try to investigate if it is possible to make Vim behave like VScode when it comes to autocompletion. I got really used to the way VScode manages this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I work with JavaScript primarily, and when I use third party library, VScode is capable to analyse exports provided by external library. I've tried to capture this on attached screenshots: it knows that imported module has &lt;code&gt;scaleLinear&lt;/code&gt; function in it. And when I use this function, VScode knows that returned value has &lt;code&gt;domain&lt;/code&gt;, &lt;code&gt;range&lt;/code&gt;, etc. methods in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to use YouCompleteMe and coc.vim plugins, but could not achieve desired behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1Ii4A.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1Ii4A.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MN7ZP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MN7ZP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22443" LastActivityDate="2019-09-08T16:27:21.527" Title="Sophisticated autocompletion in Vim in a VScode manner" Tags="|autocompletion|plugin-you-complete-me|filetype-javascript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21149" PostTypeId="2" ParentId="21146" CreationDate="2019-09-08T15:08:34.773" Score="1" Body="&lt;p&gt;It is possible to use netrw (the default explorer when you open directories for editing) to execute bulk rename operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do that by first &lt;em&gt;marking&lt;/em&gt; the files, and then using a &lt;code&gt;s///&lt;/code&gt; substitution when prompted for a replacement in the rename operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Beware:&lt;/strong&gt; This gets really heavy in its use of regexps. It's also quite strict in how you get all the details correctly. You also don't have &quot;undo&quot; available, if you make any mistakes. And if you happen to get some details wrong and there are name clashes, you may end up overwriting existing files, with possibly no good way to recover them other than restoring from a backup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your particular case, replacing &lt;code&gt;_&lt;/code&gt; with &lt;code&gt;-&lt;/code&gt; at the start of the filenames, you can do that with this sequence of operations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use the &lt;code&gt;mr&lt;/code&gt; command to mark a series of files, selecting them based on a pattern.&lt;/li&gt;&#xA;&lt;li&gt;You'll be prompted with &lt;code&gt;Enter regexp:&lt;/code&gt; but note this command &lt;em&gt;actually wants a glob instead!&lt;/em&gt; So enter &lt;code&gt;_*&lt;/code&gt; to mark all files with a name starting with underscore. (You would use something like &lt;code&gt;*.txt&lt;/code&gt; to mark all files with a &quot;txt&quot; extension.)&lt;/li&gt;&#xA;&lt;li&gt;Use the &lt;code&gt;R&lt;/code&gt; command to rename files. netrw will prompt you about the first file, so it will ask you about renaming &lt;code&gt;_file1&lt;/code&gt; to what? But you can actually use a &lt;code&gt;s///&lt;/code&gt; expression here, which will then apply to all marked files.&lt;/li&gt;&#xA;&lt;li&gt;Press Control-U to delete the current replacement (or backspace as many times as needed), and enter &lt;code&gt;s/_\(.*\)/-\1/&lt;/code&gt; in its place. Once you press ENTER, all your files will be renamed as you expect.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You need to have the final slash in the &lt;code&gt;s///&lt;/code&gt; expression for this to work (that's usually not the case with the &lt;code&gt;:s&lt;/code&gt; command, but it's the case here.)&lt;/li&gt;&#xA;&lt;li&gt;You need the pattern to &lt;strong&gt;match the whole filename&lt;/strong&gt;. You can't just use &lt;code&gt;s/_/-/&lt;/code&gt; here unfortunately.&lt;/li&gt;&#xA;&lt;li&gt;Which means you typically need at least one capture group, such as &lt;code&gt;\(.*\)&lt;/code&gt;, which you then refer to using &lt;code&gt;\1&lt;/code&gt; on the replacement side.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The last couple of constraints mean it's really hard to use this feature to, for example, replace all underscores with hyphens...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it can be used to change a prefix in files, or to change file extension. Even in those cases, having to deal with capture groups makes this feature pretty clunky, so you're probably better off using a different tool for your bulk rename operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/pi_netrw.txt.html#netrw-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help netrw-R&lt;/code&gt;&lt;/a&gt;, particularly the part when &quot;there are marked files.&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/pi_netrw.txt.html#netrw-mr&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help netrw-mr&lt;/code&gt;&lt;/a&gt; for marking files by &quot;regular expression&quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-08T15:08:34.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21150" PostTypeId="2" ParentId="21148" CreationDate="2019-09-08T16:27:21.527" Score="1" Body="&lt;p&gt;What you want is to use a &lt;strong&gt;Language Server&lt;/strong&gt; through the Language Server Protocol (LSP).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read more about it &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Language_Server_Protocol&quot; rel=&quot;nofollow noreferrer&quot;&gt;on Wikipedia&lt;/a&gt; or &lt;a href=&quot;https://microsoft.github.io/language-server-protocol/&quot; rel=&quot;nofollow noreferrer&quot;&gt;on the official website&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the Wikipedia article points out:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Language Server Protocol was originally developed for Microsoft's Visual Studio Code and is now an open standard.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So what you get in VS Code is actually being backed by a language server. (In other words, at least in theory, all that information can be available to Vim as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things get a little more murky as you explore using LSP from Vim, since there are many competing plug-ins that can use an LSP (many with different levels of support, or different sets of features.) So you'll have to try them out and see which ones work best for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find a list of those plug-ins for Vim &lt;a href=&quot;https://microsoft.github.io/language-server-protocol/implementors/tools/&quot; rel=&quot;nofollow noreferrer&quot;&gt;at the official LSP website&lt;/a&gt;. Probably worth checking are &lt;a href=&quot;https://github.com/prabirshrestha/vim-lsp&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-lsp&lt;/a&gt; and &lt;a href=&quot;https://github.com/autozimu/LanguageClient-neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;LanguageClient-neovim&lt;/a&gt;, which were developed specifically for supporting the Language Server Protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you'll see other Vim plug-ins such as &lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;coc.nvim&lt;/a&gt; and &lt;a href=&quot;https://github.com/dense-analysis/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ALE&lt;/a&gt;, which predate LSP or started with a different approach have also added support for LSP, so looking into those (and particularly LSP integration from them) might be worth it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, if you're using LSP, you'll also need a language server for your particular language (JavaScript in your case.) See the &lt;a href=&quot;https://microsoft.github.io/language-server-protocol/implementors/servers/&quot; rel=&quot;nofollow noreferrer&quot;&gt;list of language server implementations&lt;/a&gt; for some you might want to try.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a fairly new area and there are quite a few moving parts, so expect it'll take quite a bit of experimentation, some research, you might find poor or lacking documentation and it's possible the end result is still far from what you expected. But this will be as close from VS Code as you can get, since in the essence that's what VS Code &lt;em&gt;actually&lt;/em&gt; uses.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-08T16:27:21.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21151" PostTypeId="1" AcceptedAnswerId="21153" CreationDate="2019-09-08T18:11:12.563" Score="0" ViewCount="267" Body="&lt;p&gt;When I'm opening a fold, I would say 100% of the time the behaviour I want is &lt;code&gt;zv&lt;/code&gt; - open all folds covering the current line, so that I can actually see it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;zv&lt;/code&gt; won't close a fold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I use the line's current state of being folded or not folded in a normal mode mapping so that I can have a &lt;code&gt;za&lt;/code&gt; (toggle fold) but with my desired &lt;code&gt;zv&lt;/code&gt; behaviour on opening?&lt;/p&gt;&#xA;" OwnerUserId="5778" LastActivityDate="2019-09-09T09:35:57.313" Title="Use line's 'folded state' in a mapping, so it's `zc` closing but `zv` opening?" Tags="|key-bindings|folding|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21152" PostTypeId="1" AcceptedAnswerId="21156" CreationDate="2019-09-08T18:12:07.937" Score="2" ViewCount="595" Body="&lt;p&gt;Is there a way to disable all mappings for &lt;a href=&quot;https://github.com/fatih/vim-go&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-go&lt;/a&gt;? So I can only have the mappings that I explicitly set myself?&lt;/p&gt;&#xA;" OwnerUserId="12658" LastEditorUserId="51" LastEditDate="2019-10-26T09:40:00.063" LastActivityDate="2019-10-26T09:40:00.063" Title="Disable All Default Mappings in vim-go" Tags="|filetype-go|plugin-vim-go|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21153" PostTypeId="2" ParentId="21151" CreationDate="2019-09-08T19:38:05.793" Score="3" Body="&lt;p&gt;Try overriding the default &lt;code&gt;za&lt;/code&gt; functionality with this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; za foldclosed(&quot;.&quot;) == -1 ? 'zc' : 'zv'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses the &lt;a href=&quot;https://www.vimhelp.org/eval.txt.html#foldclosed%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;foldclosed()&lt;/code&gt;&lt;/a&gt; function within an &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;expression mapping&lt;/a&gt; to check if the cursor is on a closed fold, mapping to &lt;code&gt;zc&lt;/code&gt; if it's not, and &lt;code&gt;zv&lt;/code&gt; if it is.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-09T09:35:57.313" LastActivityDate="2019-09-09T09:35:57.313" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21154" PostTypeId="1" AcceptedAnswerId="21155" CreationDate="2019-09-08T20:36:24.593" Score="2" ViewCount="122" Body="&lt;p&gt;If I navigate the first line of a folded function with &lt;code&gt;h&lt;/code&gt;,&lt;code&gt;l&lt;/code&gt;, etc it will open the fold. Navigating search matches with &lt;code&gt;n&lt;/code&gt; will also open a fold if there is a match inside the fold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you configure folds to only open when you explicitly open them with &lt;code&gt;z&lt;/code&gt; commands?&lt;/p&gt;&#xA;" OwnerUserId="12658" LastActivityDate="2019-09-08T22:32:47.927" Title="Only Open Folds With z Commands" Tags="|folding|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21155" PostTypeId="2" ParentId="21154" CreationDate="2019-09-08T22:32:47.927" Score="5" Body="&lt;p&gt;You can set the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27foldopen%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'foldopen'&lt;/code&gt;&lt;/a&gt; option to control which commands or movements will open folds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The specific cases you mentioned:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;h&lt;/code&gt; or &lt;code&gt;l&lt;/code&gt;: these are horizontal movements, controlled by the &lt;code&gt;hor&lt;/code&gt; setting.&lt;/li&gt;&#xA;&lt;li&gt;search or &lt;code&gt;n&lt;/code&gt;: these are controlled by the &lt;code&gt;search&lt;/code&gt; setting.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So you might want to remove these two specific cases, which you can do with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldopen-=hor foldopen-=search&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or maybe you want to disable all of them and just set &lt;code&gt;'foldopen'&lt;/code&gt; to be empty:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldopen=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-08T22:32:47.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21156" PostTypeId="2" ParentId="21152" CreationDate="2019-09-08T22:43:41.397" Score="2" Body="&lt;p&gt;Yes, there are settings for that, see &lt;a href=&quot;https://github.com/fatih/vim-go/blob/master/doc/vim-go.txt#L1215&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help go-settings&lt;/code&gt;&lt;/a&gt; for a list of all settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, the ones you're probably interested in are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:go_def_mapping_enabled = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe also:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:go_doc_keywordprg_enabled = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And perhaps also:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:go_textobj_enabled = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Not sure if these were the mappings you had in mind... Since they're essentially overriding default Vim keybindings in a way to make them more effective when editing Go source code.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also check &lt;a href=&quot;https://github.com/fatih/vim-go/blob/master/ftplugin/go.vim#L41&quot; rel=&quot;nofollow noreferrer&quot;&gt;the Vimscript source code&lt;/a&gt; to check which mappings exactly are being set (controlled by these options) in case you want to create separate mappings using different key combinations for them.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-08T22:43:41.397" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21157" PostTypeId="1" AcceptedAnswerId="21159" CreationDate="2019-09-09T07:43:40.717" Score="5" ViewCount="219" Body="&lt;p&gt;Some markdown as an example. I select the following paragraph in visual mode and press &lt;code&gt;gq&lt;/code&gt;. The result is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-   Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do&#xA;    eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim&#xA;ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut&#xA;aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit&#xA;in voluptate velit esse cillum dolore eu fugiat nulla pariatur.&#xA;Excepteur sint occaecat cupidatat non proident, sunt in culpa qui&#xA;officia deserunt mollit anim id est laborum.&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what I expect is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-   Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do&#xA;    eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim&#xA;    ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut&#xA;    aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit&#xA;    in voluptate velit esse cillum dolore eu fugiat nulla pariatur.&#xA;    Excepteur sint occaecat cupidatat non proident, sunt in culpa qui&#xA;    officia deserunt mollit anim id est laborum.&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this normal behavior? If yes, why and how could I change it? &#xA;Thanks a lot!&lt;/p&gt;&#xA;" OwnerUserId="23754" LastEditorUserId="23756" LastEditDate="2019-09-09T09:04:29.587" LastActivityDate="2019-09-09T10:37:28.270" Title="gq in visual mode indents just first two lines of enumeration" Tags="|indentation|visual-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21159" PostTypeId="2" ParentId="21157" CreationDate="2019-09-09T08:52:07.547" Score="3" Body="&lt;p&gt;You can fix this with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set autoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This causes the indent of the second line also to be used for the rest of the list item.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim's included filetype plugin for Markdown formats bulleted lists using the &lt;a href=&quot;https://www.vimhelp.org/options.txt.html#%27comments%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'comments'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://www.vimhelp.org/options.txt.html#%27formatoptions%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'formatoptions'&lt;/code&gt;&lt;/a&gt; settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;a href=&quot;https://www.vimhelp.org/change.txt.html#fo-table&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;q&lt;/code&gt; included in the &lt;code&gt;formatoptions&lt;/code&gt;&lt;/a&gt; setting, Vim will allow the formatting of &quot;comments&quot; using the &lt;code&gt;gq&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;'comments'&lt;/code&gt; setting is used to defined what is considered a comment. The markdown plugin sets this to include &lt;code&gt;fb:-&lt;/code&gt;, which means that a line that begins with a hyphen followed by whitespace is treated as a comment. The &lt;code&gt;f&lt;/code&gt; &lt;a href=&quot;https://www.vimhelp.org/change.txt.html#format-comments&quot; rel=&quot;nofollow noreferrer&quot;&gt;means that&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Only the first line has the comment string.  Do not repeat comment on the next line, but preserve indentation (e.g., a bullet-list).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But, as you have discovered, the &lt;code&gt;autoindent&lt;/code&gt; setting&amp;#8202;&amp;mdash;&amp;#8202;which is &lt;em&gt;not&lt;/em&gt; set by Vim's standard markdown plugin&amp;#8202;&amp;mdash;&amp;#8202;is required to carry this indentation over into subsequent lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that Vim also provides a more flexible mechanism for formatting lists: the &lt;a href=&quot;https://www.vimhelp.org/options.txt.html#%27formatlistpat%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'formatlistpat'&lt;/code&gt;&lt;/a&gt; option. There is a nice article on this, which goes into a bit more detail than the documentation, in &lt;a href=&quot;https://vimways.org/2018/formatting-lists-with-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;last year's edition of Vimways&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-09T10:37:28.270" LastActivityDate="2019-09-09T10:37:28.270" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21160" PostTypeId="2" ParentId="4944" CreationDate="2019-09-09T12:58:20.243" Score="7" Body="&lt;p&gt;If you are using a unix-like system, in vim, type ex-command&#xA;&lt;code&gt;:%! rev&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="23760" LastActivityDate="2019-09-09T12:58:20.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21161" PostTypeId="1" CreationDate="2019-09-09T14:30:18.613" Score="2" ViewCount="228" Body="&lt;p&gt;&lt;em&gt;Note: Possible fixed bug. See comments.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A somewhat minor nuisance, but as the pedantic for these things :P&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When saving and opening a Session file the Session.vim file does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;badd +1 file1&#xA;badd +1 file2&#xA;badd +1 file3&#xA;…&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This result in buffer numbering starting with 2 instead of 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/t8n1a.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/t8n1a.png&quot; alt=&quot;:ls after opening Session file&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I notice some Session files use &lt;code&gt;badd +0&lt;/code&gt; instead of &lt;code&gt;badd +1&lt;/code&gt;, but this does not make any difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to circumvent this is to comment out first file in the session file and open Vim by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim file1 -S Session.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this in the session-file instead?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to replace &lt;code&gt;badd&lt;/code&gt; with &lt;code&gt;edit&lt;/code&gt; for first file in Session.vim, but that does not work. (File does not get opened at all.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;VIM 8.0 patches: 1-1453&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://packages.ubuntu.com/bionic/vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://packages.ubuntu.com/bionic/vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also tested with &lt;code&gt;vim -u NONE -S&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16695" LastEditorUserId="16695" LastEditDate="2019-09-09T17:26:31.700" LastActivityDate="2024-01-17T22:09:06.163" Title="Session - start with buffer 1" Tags="|buffers|sessions|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21162" PostTypeId="1" CreationDate="2019-09-09T18:00:04.090" Score="3" ViewCount="361" Body="&lt;p&gt;&lt;strong&gt;TLDR&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this text in a buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a 'string' and 'another one' !&#xA;            ^&#xA;            cursor is here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I search for this regex in a &lt;code&gt;/&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(.*\%#\)\@=\%('[^']*'\)\@&amp;gt;\%(\%#.\+\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I remove &lt;code&gt;\@&amp;gt;&lt;/code&gt; from the regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(.*\%#\)\@='[^']*'\%(\%#.\+\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And search for it again. This time &lt;code&gt;' and '&lt;/code&gt; is matched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What did &lt;code&gt;\@&amp;gt;&lt;/code&gt; do exactly in the first regex, which explains why &lt;code&gt;' and '&lt;/code&gt; was not matched?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Additional information&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I'm looking for a regex to match the single-quoted string under the cursor.&lt;br&gt;&#xA;And I use this text to test the regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a 'string' and 'another one' !&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't want any match while the cursor is positioned on any of these characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a 'string' and 'another one' !&#xA;^^        ^^^^^             ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want &lt;code&gt;'string'&lt;/code&gt; to be the match when the cursor is on any of these characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a 'string' and 'another one' !&#xA;  ^^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want &lt;code&gt;'another one'&lt;/code&gt; to be the match when the cursor is on any of these characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a 'string' and 'another one' !&#xA;               ^^^^^^^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here's one possible regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(.*\%#\)\@=\%('[^']*'\)\@&amp;gt;\%(\%#.\+\)\@&amp;lt;=&#xA;├───────────┘   ├─────┘     ├─────────────┘&#xA;│               │           └ the cursor must be before the closing quote&#xA;│               └ a quoted string&#xA;└ the cursor must be after the opening quote&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand why it works when the cursor is inside a string, but I don't understand why it works when the cursor is outside. For example, assuming the cursor is on the &lt;code&gt;n&lt;/code&gt; of &lt;code&gt;and&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a 'string' and 'another one' !&#xA;            ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the regex fails to match anything, which is what I want.&#xA;This is due to the atom &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#/@%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\@&amp;gt;&lt;/code&gt;&lt;/a&gt; – which is inspired from the atomic group &lt;a href=&quot;https://perldoc.perl.org/perlre.html#Extended-Patterns&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;(?&amp;gt;pattern)&lt;/code&gt;&lt;/a&gt; in perl – because if I remove it, the regex becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(.*\%#\)\@='[^']*'\%(\%#.\+\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and when the cursor is on the &lt;code&gt;n&lt;/code&gt; of &lt;code&gt;and&lt;/code&gt;, this new regex matches &lt;code&gt;' and '&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a 'string' and 'another one' !&#xA;         ^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you think this last regex matches &lt;code&gt;'string'&lt;/code&gt; instead of &lt;code&gt;' and '&lt;/code&gt;, because that's the text which is highlighted by the &lt;code&gt;Search&lt;/code&gt; highlight group, run this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s///c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the substitution command is asking for your confirmation before replacing the pattern, you should see that the text highlighted by the &lt;code&gt;IncSearch&lt;/code&gt; highlight group is &lt;code&gt;' and '&lt;/code&gt;, not &lt;code&gt;'string'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Cmcge.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cmcge.gif&quot; alt=&quot;real text matched by previous regex&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I know what the help says about &lt;code&gt;\@&amp;gt;&lt;/code&gt;. It prevents the regex engine from backtracking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, let's assume you want to match all sequences of several uppercase characters &lt;em&gt;not&lt;/em&gt; followed by a comma, &lt;em&gt;nor by another uppercase character&lt;/em&gt;; and you test your regex against this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ABC,&#xA;DEF&#xA;GHI,&#xA;JKL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you try this regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\u\{2,},\@!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It correctly matches &lt;code&gt;DEF&lt;/code&gt; and &lt;code&gt;JKL&lt;/code&gt;, but it also wrongly matches &lt;code&gt;AB&lt;/code&gt; and &lt;code&gt;GH&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is because when the regex engine processed the token &lt;code&gt;\u\{2,}&lt;/code&gt;, it initially matched &lt;code&gt;ABC&lt;/code&gt; and &lt;code&gt;GHI&lt;/code&gt; (&lt;code&gt;\{2,}&lt;/code&gt; is greedy so it matches as many uppercase characters as it can); but then it realized that there was a comma, and that the negative lookahead assertion &lt;code&gt;,\@!&lt;/code&gt; could not be satisfied. So it backtracked into &lt;code&gt;\u\{2,}&lt;/code&gt; again, and this time was a little less greedy; it matched only &lt;code&gt;AB&lt;/code&gt; and &lt;code&gt;GH&lt;/code&gt;. Since there is no comma after &lt;code&gt;AB&lt;/code&gt; and &lt;code&gt;GH&lt;/code&gt;, the negative lookahead assertion can be satisfied and there is a match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you apply &lt;code&gt;\@&amp;gt;&lt;/code&gt; to &lt;code&gt;\u\{2,}&lt;/code&gt;, then you prevent the regex engine from backtracking into &lt;code&gt;\u\{2,}&lt;/code&gt;. That is, once the regex engine finds some text matching &lt;code&gt;\u\{2,}&lt;/code&gt;, it never comes back into it again; even if some later part of the regex fails. This is why the following regex correctly finds &lt;code&gt;DEF&lt;/code&gt;, &lt;code&gt;JKL&lt;/code&gt;, and nothing else:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(\u\{2,}\)\@&amp;gt;,\@!&#xA;^^^       ^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Going back to the original text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a 'string' and 'another one' !&#xA;            ^&#xA;            cursor is here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(.*\%#\)\@=\%('[^']*'\)\@&amp;gt;\%(\%#.\+\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;finds nothing, because of &lt;code&gt;\@&amp;gt;&lt;/code&gt;.&#xA;But how does preventing the regex engine from backtracking into &lt;code&gt;'[^']*'&lt;/code&gt; also prevents the &lt;code&gt;' and '&lt;/code&gt; match?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The core of the regex is &lt;code&gt;'[^']*'&lt;/code&gt; – two consecutive quotes with a minimum amount of text in-between – for which there are 3 possible matches:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'string'&#xA;' and '&#xA;'another one'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand why the first match fails; it's because of the negative lookbehind, which asserts that the cursor is positioned before the last quote, while it's after when it's on the &lt;code&gt;n&lt;/code&gt; of &lt;code&gt;and&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't understand why the second match fails. When the engine reaches the second quote on the line, it should find that &lt;code&gt;' and '&lt;/code&gt; matches, even if it can't backtrack into &lt;code&gt;'[^']*'&lt;/code&gt;.&#xA;It can't give up any character inside &lt;code&gt;and&lt;/code&gt; anyway (if it did, it couldn't match the second quote anymore), so there is no submatch which &lt;code&gt;\@&amp;gt;&lt;/code&gt; can prevent.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The only explanation I could find was the following one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;because of &lt;code&gt;\@&amp;gt;&lt;/code&gt;, the regex engine is not allowed to start a match from any character in any previous text which was successfully matched by &lt;code&gt;\@&amp;gt;&lt;/code&gt; (even if the global regex failed to match).&#xA;&lt;code&gt;\%('[^']*'\)\@&amp;gt;&lt;/code&gt; successfully matched &lt;code&gt;'string'&lt;/code&gt; – even though the overall regex failed – so now it can't start a match from any character inside &lt;code&gt;'string'&lt;/code&gt;.&#xA;And to find &lt;code&gt;' and '&lt;/code&gt;, the engine would need to start its match from the second quote in &lt;code&gt;'string'&lt;/code&gt;. It can't; thus it doesn't find &lt;code&gt;' and '&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this feature of &lt;code&gt;\@&amp;gt;&lt;/code&gt; doesn't seem to be documented at &lt;code&gt;:h /\@&amp;gt;&lt;/code&gt;. Unless this is implied by:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Matches the preceding atom &lt;strong&gt;like matching a whole pattern&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;'[^']*'&lt;/code&gt; matches a string like a whole pattern, it means that it doesn't matter whether the rest of the regex matches; it's processed as if it was alone (i.e. no backtracking).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But maybe it means something more; maybe it also implies that every character inside the text matched by &lt;code&gt;'[^']*'&lt;/code&gt; is ignored when searching for further matches.&#xA;Somewhat in the same way that &lt;code&gt;A.*C\|B.*D&lt;/code&gt; can't match &lt;code&gt;BCD&lt;/code&gt; in &lt;code&gt;ABCD&lt;/code&gt; because &lt;code&gt;ABC&lt;/code&gt; has already been matched, and the regex engine can't start a match inside a previous one (unless it's processing a multi-line regex).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I don't think that can be the explanation. Consider this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ABCD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(A.*C\)\@&amp;gt;E\@=\|B.*D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;A.*C&lt;/code&gt; matches &lt;code&gt;ABC&lt;/code&gt;, but the regex fails because of the positive lookahead &lt;code&gt;E\@=&lt;/code&gt; which asserts that an &lt;code&gt;E&lt;/code&gt; follows immediately afterward. Nevertheless, &lt;code&gt;ABC&lt;/code&gt; is matched like a whole pattern thanks to &lt;code&gt;\@&amp;gt;&lt;/code&gt;. If that means that no further match can start inside, then &lt;code&gt;BCD&lt;/code&gt; should not match. In practice, &lt;code&gt;BCD&lt;/code&gt; &lt;em&gt;does&lt;/em&gt; match; so the previous explanation is either wrong or incomplete.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-09-10T13:31:16.860" LastActivityDate="2019-09-10T13:31:37.990" Title="When searching for the string under the cursor, how does an atomic group prevent a match outside a string?" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21163" PostTypeId="1" CreationDate="2019-09-09T23:31:07.747" Score="3" ViewCount="31" Body="&lt;p&gt;One thing I find myself doing often is using visual mode to select a block containing a long function definition containing one or more keyword arguments, and then using &lt;kbd&gt;gq&lt;/kbd&gt; to reformat the code across multiple lines.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-r prettyprint-override&quot;&gt;&lt;code&gt;some_function &amp;lt;- function(keyword_argument1 = &quot;foo&quot;, keyword_argument2 = &quot;bar&quot;) {&#xA;   ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-r prettyprint-override&quot;&gt;&lt;code&gt;some_function &amp;lt;- function(keyword_argument1 = &quot;foo&quot;, &#xA;                          keyword_argument2 = &quot;bar&quot;) {&#xA;   ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I'm lucky, the function keyword arg pairs happen to line up with the maximum column width, and the reformatted function definition looks clean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just as often, however, the split happens to occur in between the &quot;key&quot; and &quot;value&quot; parts of the keyword argument pairs, and you end up with the function argument on one line and the value on the next, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-r prettyprint-override&quot;&gt;&lt;code&gt;some_function &amp;lt;- function(keyword_argument1 = &quot;foo&quot;, keyword_argument2 =&#xA;                          &quot;bar&quot;) {&#xA;   ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is particularly a problem for languages like R, where &lt;a href=&quot;http://adv-r.had.co.nz/Style.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;style conventions&lt;/a&gt; encourage you to keep a space before and after the &quot;=&quot; in the kwarg pairs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result is that I end up spending a lot of time first reformatting things with &lt;kbd&gt;gq&lt;/kbd&gt;, and then going back and manually adjusting the text so that the kwargs pairs are together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone happen to know of a way to avoid this behavior so that matched keyword-value pairs are kept together when reformatted across multiple lines?&lt;/p&gt;&#xA;" OwnerUserId="6840" LastActivityDate="2019-09-10T04:18:52.350" Title="Keep function &quot;keyword = arguments&quot; together when reformatting across multiple lines using &quot;gq&quot;?" Tags="|visual-mode|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21164" PostTypeId="2" ParentId="21162" CreationDate="2019-09-10T01:55:13.963" Score="2" Body="&lt;p&gt;&lt;strong&gt;TLDR&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the issue is due to the new NFA regex engine which doesn't support some particular combination of atoms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, even though the following regex can be used to match the string under the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(.*\%#\)\@=\%('[^']*'\)\@&amp;gt;\%(\%#.\+\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It only works because of an implementation detail; which probably means that there is no guarantee it will still work in the future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more reliable regex is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(^\%('[^']*'\|[^']\)*\)\@&amp;lt;=\%('[^']*\%#[^']*'\|\%#'[^']*'\)&#xA;       ├─────┘  ├──┘  │         ├─────────────┘  ├────────┘&#xA;       │        │     │         │                └ a string with the cursor on the opening quote&#xA;       │        │     │         └ a string with the cursor in the middle&#xA;       │        │     └ there can be several of them&#xA;       │        └ there can be a character outside a string before&#xA;       └ there can be a text surrounded by a string before&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This one works no matter the engine.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Additional information&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problematic regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(.*\%#\)\@=\%('[^']*'\)\@&amp;gt;\%(\%#.\+\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is similar to the following one, which is a little simpler (because it gets rid of &lt;code&gt;\%#&lt;/code&gt; and its results don't depend on the cursor position):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(.*B\)\@=\%(A[^A]*A\)\@&amp;gt;\%(B.*\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would expect the latter to match &lt;code&gt;A B A&lt;/code&gt; when compared to this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AxA B AxA&#xA;  ^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in practice it does not.&#xA;However, if Vim is forced to use the old engine by prefixing the regex with &lt;code&gt;\%#=1&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%#=1\%(.*B\)\@=\%(A[^A]*A\)\@&amp;gt;\%(B.*\)\@&amp;lt;=&#xA;^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it does match &lt;code&gt;A B A&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be confirmed with a shell command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -es -Nu NONE +&quot;put ='AxA B AxA'&quot; +&quot;put =search('\%#=2\m\%(.*B\)\@=\%(A[^A]*A\)\@&amp;gt;\%(B..\)\@&amp;lt;=')&quot; +'2p' +'qa!'&#xA;0&#xA;&#xA;$ vim -es -Nu NONE +&quot;put ='AxA B AxA'&quot; +&quot;put =search('\%#=1\m\%(.*B\)\@=\%(A[^A]*A\)\@&amp;gt;\%(B..\)\@&amp;lt;=')&quot; +'2p' +'qa!'&#xA;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first command outputs &lt;code&gt;0&lt;/code&gt; because Vim does not match anything when using the new engine, while the second command outputs &lt;code&gt;1&lt;/code&gt; because Vim does match something when using the old engine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out that the same is true for the original regex and text.&#xA;That is, if the original regex is prefixed with &lt;code&gt;\%#=1&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%#=1\%(.*\%#\)\@=\%('[^']*'\)\@&amp;gt;\%(\%#.\+\)\@&amp;lt;=&#xA;^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does match &lt;code&gt;' and '&lt;/code&gt; while the cursor is on the &lt;code&gt;n&lt;/code&gt; of &lt;code&gt;and&lt;/code&gt; in the text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a 'string' and 'another one' !&#xA;            ^&#xA;            cursor is here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It seems that the new engine does not support the combination of:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;an atomic group&lt;/li&gt;&#xA;&lt;li&gt;a variable-width lookahead&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, this regex does not match anything in the text &lt;code&gt;AxA B AxA&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;         the lookahead is variable-width&#xA;         |      atomic group&#xA;         v      vvv       vvvvv&#xA;\%#=2\%(.*B\)\@=\%(A[^A]*A\)\@&amp;gt;\%(B.*\)\@&amp;lt;=&#xA;├───┘├─────────┘               ├──────────┘&#xA;│    │                         └ positive lookbehind&#xA;│    └ positive lookahead&#xA;└ new NFA engine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if any of the 2 previous conditions is not satisfied, the regex matches &lt;code&gt;A B A&lt;/code&gt;.&lt;br&gt;&#xA;For example, if the atomic group is removed, the regex matches:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%#=2\%(.*B\)\@=A[^A]*A\%(B.*\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Same thing if the lookahead is fixed-width, instead of variable-width:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%#=2\%(..B\)\@=\%(A[^A]*A\)\@&amp;gt;\%(B.*\)\@&amp;lt;=&#xA;        ^^^&#xA;        fixed-width: three characters&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Remaining question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the old engine does not support the original regex, then why does it still match a string when the cursor is inside? Shouldn't it fail to match anything, just like when the cursor is outside a string?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe the engine parses the regex in a special way, which by accident matches the inside of strings but not the outside...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or maybe it's just a bug, because I have found out another regex with an atomic group, which gives another type of unexpected result when the new engine is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's assume you want &lt;code&gt;bar&lt;/code&gt; in &lt;code&gt;[foo](bar)&lt;/code&gt; when it's under the cursor.&#xA;Here's a one possible regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(.*\%#\)\@=\%(\[.\{-}\](\zs.\{-}\ze)\)\@&amp;gt;\%(\%#.*\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be tested against this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;one [two](three) (four) [five](six) seven&#xA;                                ^&#xA;                                cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the old engine, the match is &lt;code&gt;six&lt;/code&gt;, which is expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But with the new engine, the match is &lt;code&gt;[five](six)&lt;/code&gt;, while I would expect just &lt;code&gt;six&lt;/code&gt; (thanks to &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt;).&#xA;It's as if the new engine ignored &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; inside the atomic group.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Recommendations&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are a few recommendations for the next time you find a regex which does not give the expected match(es).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the regex in a substitution command with the &lt;code&gt;c&lt;/code&gt; flag: &lt;code&gt;:%s///gc&lt;/code&gt; (an empty pattern means that the contents of the search register – &lt;code&gt;@/&lt;/code&gt; – is used; i.e. the last search).&#xA;Answer no to each question, just to see which text is highlighted by &lt;code&gt;IncSearch&lt;/code&gt; for each match.&#xA;This command seems more reliable to test what a regex matches, rather than looking at the text highlighted by &lt;code&gt;Search&lt;/code&gt; after running a &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt; command, or by looking at the text highlighted by  &lt;code&gt;IncSearch&lt;/code&gt; while writing a search pattern in a &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, consider this regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a\_.*b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this text file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&#xA;a&#xA;b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you search for the regex in a &lt;code&gt;/&lt;/code&gt; command, all the text is highlighted by &lt;code&gt;Search&lt;/code&gt; (and by &lt;code&gt;IncSearch&lt;/code&gt; right before pressing Enter), which may make you think that there is only 1 match. But in reality, there are 2 matches: from the first &lt;code&gt;a&lt;/code&gt; up to &lt;code&gt;b&lt;/code&gt;, and from the second &lt;code&gt;a&lt;/code&gt; up to &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if you can get the exact number of matches by pressing &lt;code&gt;n&lt;/code&gt; and counting how many locations the cursor jumps to before wrapping around the end of the buffer, or by removing the &lt;code&gt;S&lt;/code&gt; flag from the &lt;code&gt;'shortmess'&lt;/code&gt; option which enables the display of &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.1270&quot; rel=&quot;nofollow noreferrer&quot;&gt;a search count message on the command-line&lt;/a&gt;, it can be difficult to see exactly which text is matched, especially with overlapping matches, or with some regexes using lookarounds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As another example, consider this regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^###\n.*\n###&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;###&#xA;foo&#xA;###&#xA;bar&#xA;###&#xA;baz&#xA;###&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you only look at the &lt;code&gt;Search&lt;/code&gt; highlighting, it seems there are only 2 matches; this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;###&#xA;foo&#xA;###&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;###&#xA;baz&#xA;###&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in reality, there is a third match in the middle, which is clearly shown by &lt;code&gt;%s///gc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;###&#xA;bar&#xA;###&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a final example, consider this regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(.*\%#\)\@=`[^`]*`\%(\%#.*\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this text, while your cursor is anywhere on &lt;code&gt;four&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;one `two` three `four` five&#xA;        ^^^^^^^^&#xA;        highlighted by the Search highlight group&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The real text matched by the regex is not the one highlighted by &lt;code&gt;Search&lt;/code&gt;, but this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;one `two` three `four` five&#xA;                ^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;Search&lt;/code&gt; highlighting is probably unreliable because right after the search command, the cursor is moved, and thus the position expressed by &lt;code&gt;\%#&lt;/code&gt; is altered.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If that doesn't help, then prefix your regex with &lt;code&gt;\%#=1&lt;/code&gt;.&#xA;This will force Vim to use its old regex engine, which &quot;supports everything&quot;.&#xA;From &lt;code&gt;:h two-engines&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;An old, backtracking engine that &lt;strong&gt;supports everything&lt;/strong&gt;.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If your regex now works as expected, it means that Vim was using the new NFA engine, and you were using some feature not supported by the latter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, try to prefix it with &lt;code&gt;\%#=2&lt;/code&gt; to force Vim to use the new NFA engine.&#xA;If it now works as expected, it means that Vim was using the old engine, and you were using some feature not supported by the latter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;\%#=1&lt;/code&gt; and &lt;code&gt;\%#=2&lt;/code&gt; must be written at &lt;em&gt;the very beginning&lt;/em&gt; of the regex.&#xA;Even before something like &lt;code&gt;\m&lt;/code&gt; or &lt;code&gt;\v&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If that still doesn't help, then simplify your regex, and the testing text, as much as possible.&#xA;Then try to translate this simplification into PCRE, and test the result on &lt;a href=&quot;https://regex101.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;regex101.com&lt;/a&gt;.&lt;sup&gt;1&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it produces the expected match(es), it probably means that there is a bug in Vim.&#xA;Have a look at &lt;code&gt;:h todo&lt;/code&gt; and search for &lt;code&gt;Regexp problems:&lt;/code&gt;, or just &lt;code&gt;regex&lt;/code&gt;.&#xA;If you don't find anything relevant, visit Vim's &lt;a href=&quot;https://github.com/vim/vim/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue tracker&lt;/a&gt;, and type a query in the &lt;code&gt;Filters&lt;/code&gt; field (remove &lt;code&gt;is:open&lt;/code&gt; from the pre-populated text; your issue could have been fixed/closed).&#xA;Maybe it is a known bug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, it probably means that you are missing some knowledge.&#xA;In that case, regex101.com can help you by providing an explanation of the PCRE regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; As an example, this Vim regex which exhibits the unexpected behavior described in the OP:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(.*B\)\@=\%(A[^A]*A\)\@&amp;gt;\%(B..\)\@&amp;lt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can be translated into PCRE like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(?=.*B)(?&amp;gt;A[^A]*A)(?&amp;lt;=B..)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which regex101.com describes like &lt;a href=&quot;https://regex101.com/r/65hepl/1&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-09-10T13:31:37.990" LastActivityDate="2019-09-10T13:31:37.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21166" PostTypeId="2" ParentId="15944" CreationDate="2019-09-10T13:07:33.877" Score="15" Body="&lt;h3&gt;&lt;a href=&quot;https://github.com/vim/vim/commit/9dfa3139198b38b28673e251a3756430065914e9&quot; rel=&quot;noreferrer&quot;&gt;vim 8.1.1270&lt;/a&gt;  (May 2019) &lt;code&gt;:set shortmess-=S&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Since May 2019 vim offers the possibility to show the count in the statusline (as long as it less than 99) which however is disabled by default. Add to your vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shortmess-=S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or activate it on demand with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:se shm-=S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Following additional information can be found under &lt;code&gt;:h search-commands&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When &lt;code&gt;'shortmess'&lt;/code&gt; does not include the &lt;code&gt;&quot;S&quot;&lt;/code&gt; flag, Vim will automatically&#xA;  show an index, on which the cursor is. This can look like this:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;[1/5]&lt;/code&gt;       Cursor is on first of 5 matches.&lt;br&gt;&#xA;    &lt;code&gt;[1/&amp;gt;99]&lt;/code&gt;    Cursor is on first of more than 99 matches.&lt;br&gt;&#xA;    &lt;code&gt;[&amp;gt;99/&amp;gt;99]&lt;/code&gt; Cursor is after 99 match of more than 99 matches.&lt;br&gt;&#xA;    &lt;code&gt;[?/??]&lt;/code&gt;      Unknown how many matches exists,&lt;br&gt;&#xA;                     generating the statistics was aborted because of search timeout.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Note: the count does not take offset into account.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2020-05-27T20:20:22.023" LastActivityDate="2020-05-27T20:20:22.023" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21167" PostTypeId="2" ParentId="21161" CreationDate="2019-09-10T14:02:15.727" Score="0" Body="&lt;p&gt;I could achieve that by moving the &lt;code&gt;edit&lt;/code&gt; line from the middle of the session file to the first line of the file. Ugly, I'd say...&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-09-10T14:02:15.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21168" PostTypeId="2" ParentId="18295" CreationDate="2019-09-10T15:59:28.200" Score="10" Body="&lt;p&gt;Here is a bit more complete answer to address this annoyance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Force to use underline for spell check results&#xA;augroup SpellUnderline&#xA;  autocmd!&#xA;  autocmd ColorScheme *&#xA;    \ highlight SpellBad&#xA;    \   cterm=Underline&#xA;    \   ctermfg=NONE&#xA;    \   ctermbg=NONE&#xA;    \   term=Reverse&#xA;    \   gui=Undercurl&#xA;    \   guisp=Red&#xA;  autocmd ColorScheme *&#xA;    \ highlight SpellCap&#xA;    \   cterm=Underline&#xA;    \   ctermfg=NONE&#xA;    \   ctermbg=NONE&#xA;    \   term=Reverse&#xA;    \   gui=Undercurl&#xA;    \   guisp=Red&#xA;  autocmd ColorScheme *&#xA;    \ highlight SpellLocal&#xA;    \   cterm=Underline&#xA;    \   ctermfg=NONE&#xA;    \   ctermbg=NONE&#xA;    \   term=Reverse&#xA;    \   gui=Undercurl&#xA;    \   guisp=Red&#xA;  autocmd ColorScheme *&#xA;    \ highlight SpellRare&#xA;    \   cterm=Underline&#xA;    \   ctermfg=NONE&#xA;    \   ctermbg=NONE&#xA;    \   term=Reverse&#xA;    \   gui=Undercurl&#xA;    \   guisp=Red&#xA;  augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Place this in your .vimrc&lt;/li&gt;&#xA;&lt;li&gt;Add line &lt;code&gt;colorscheme adrian&lt;/code&gt; after the above to start vim with &lt;code&gt;adrian&lt;/code&gt;. This will set you up to use adrian and use underline for misssp[elled words.  &lt;/li&gt;&#xA;&lt;li&gt;You can also execute any color scheme from the vim command line, it will use underline for spell errors.&lt;/li&gt;&#xA;&lt;li&gt;If you type at vim prompt as &lt;code&gt;:colorscheme&lt;/code&gt; and space and CTRL-D, you get list of available color scheme which can be activated while using underline for spell.  Trying many color scheme this way is the best way to get your favourite scheme.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Based on this, I made a simple plugin package: &lt;a href=&quot;https://github.com/osamuaoki/vim-spell-under&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/osamuaoki/vim-spell-under&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="23771" LastEditorUserId="23771" LastEditDate="2019-09-11T12:53:23.183" LastActivityDate="2019-09-11T12:53:23.183" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21169" PostTypeId="1" CreationDate="2019-09-10T19:19:12.277" Score="1" ViewCount="550" Body="&lt;p&gt;A vim newbie here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would like to know an efficient way of converting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;self.mat = material&#xA;self.epsilon=epsilon&#xA;self.x = x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;self.mat, self.epsilon, self.x = material, epsilon, x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23774" LastActivityDate="2019-09-11T15:53:48.400" Title="Converting multiple assignment statements to single comma separated assignment" Tags="|key-bindings|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21170" PostTypeId="2" ParentId="21169" CreationDate="2019-09-10T20:49:13.563" Score="3" Body="&lt;p&gt;I'm not sure this is what you want, but you could try these global commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^self\./,/^\(self\.\)\@!/-j&#xA;g/^self\./let l=[]|s/\s*=\s*\(\w*\)/\=add(l,submatch(1))[-1][-1]/g|s/\s/, /g|s/$/\=' = '.join(l,', ')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first command should turn this block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;self.mat = material&#xA;self.epsilon=epsilon&#xA;self.x = x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;self.mat = material self.epsilon=epsilon self.x = x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second command should turn the latter line into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;self.mat, self.epsilon, self.x = material, epsilon, x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that it doesn't work if the last line of the buffer starts with &lt;code&gt;self.&lt;/code&gt;.&#xA;In that case, maybe you could add an empty line at the end, before running the commands.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If this is a frequent task, and you don't want to remember these commands, you can wrap them inside a custom command.&#xA;As an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! -bar -range=% AssignmentMulti2Single call s:assignment_multi2single(&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;)&#xA;fu! s:assignment_multi2single(lnum1,lnum2) abort&#xA;    if getline('$') =~# '^self\.' | $put='' | endif&#xA;    exe a:lnum1 . 'ka'&#xA;    exe a:lnum2 . 'kb'&#xA;    sil 'a,'bg/^self\./,/^\(self\.\)\@!/-j&#xA;    sil 'a,'bg/^self\./let l=[]|s/\s*=\s*\(\w*\)/\=add(l,submatch(1))[-1][-1]/g|s/\s/, /g|s/$/\=' = '.join(l,', ')&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use this &lt;code&gt;:AssignmentMulti2Single&lt;/code&gt; custom command on an arbitrary range, like &lt;code&gt;:12,34&lt;/code&gt; to target the lines from the address &lt;code&gt;12&lt;/code&gt; to &lt;code&gt;34&lt;/code&gt;, or like &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; to target the last lines which were visually selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this time, the command works even if the last line starts with &lt;code&gt;self\.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I haven't tested the code a lot; only on this text file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;self.mat = material&#xA;self.epsilon=epsilon&#xA;self.x = x&#xA;&#xA;some text&#xA;&#xA;self.one = abc&#xA;self.two=def&#xA;self.three = ghi&#xA;&#xA;some other text&#xA;&#xA;self.four = jkl&#xA;self.five=mno&#xA;self.six = pqr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which &lt;code&gt;:AssignmentMulti2Single&lt;/code&gt; turns into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;self.mat, self.epsilon, self.x = material, epsilon, x&#xA;&#xA;some text&#xA;&#xA;self.one, self.two, self.three = abc, def, ghi&#xA;&#xA;some other text&#xA;&#xA;self.four, self.five, self.six = jkl, mno, pqr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/57qiy.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/57qiy.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there are probably special cases that it doesn't handle well.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :g&#xA;:h :j&#xA;:h :s&#xA;:h :s\=&#xA;:h :com&#xA;:h :command-bar&#xA;:h :command-range&#xA;:h &amp;lt;line1&amp;gt;&#xA;:h :put&#xA;:h :k&#xA;:h :silent&#xA;:h add()&#xA;:h submatch()&#xA;:h join()&#xA;:h getline()&#xA;:h =~#&#xA;:h /^&#xA;:h /$&#xA;:h /\(&#xA;:h /\@!&#xA;:h \s&#xA;:h \w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-09-11T08:14:06.397" LastActivityDate="2019-09-11T08:14:06.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21171" PostTypeId="2" ParentId="21169" CreationDate="2019-09-10T20:50:32.393" Score="3" Body="&lt;p&gt;There might be plug-ins that do this particular transformation, or you might be able to use two fairly long &lt;code&gt;:s///&lt;/code&gt; commands to isolate each side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But personally I find that using Vim's &lt;strong&gt;Visual Block&lt;/strong&gt; feature is the best way to handle &lt;em&gt;column&lt;/em&gt; data, which is the main kind of transformation you have here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can start by aligning the &lt;code&gt;=&lt;/code&gt;s so you really have three columns (the variables to be assigned, the &lt;code&gt;=&lt;/code&gt;s and the expressions.) I previously wrote &lt;a href=&quot;https://vi.stackexchange.com/a/20670/18609&quot;&gt;an answer&lt;/a&gt; on how to do that using visual block mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have that, you can again use visual block mode to cut the right column and paste it into its own lines. Go to the start of &lt;code&gt;material&lt;/code&gt;, then use &lt;code&gt;CTRL-V&lt;/code&gt; to start visual block mode, then &lt;code&gt;2j&lt;/code&gt; to select the three lines and finally &lt;code&gt;$&lt;/code&gt; to select to the end. Use &lt;code&gt;d&lt;/code&gt; or &lt;code&gt;x&lt;/code&gt; to cut that text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Navigate to a blank line (for example, use &lt;code&gt;o&lt;/code&gt; at the last line of the file to create a new bla m one and then &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to go back to normal mode.) Then paste with &lt;code&gt;:put&lt;/code&gt; (use &lt;code&gt;:put&lt;/code&gt; instead of &lt;code&gt;P&lt;/code&gt; or &lt;code&gt;p&lt;/code&gt; to force pasting in likewise mode.) You'll have your three expressions in different lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Visually select the first two again: &lt;code&gt;CTRL-V&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;$&lt;/code&gt; and add commas. You can use &lt;code&gt;A,&amp;lt;Esc&amp;gt;&lt;/code&gt; which will add commas to the end of &lt;em&gt;every&lt;/em&gt; line in the visual block selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally join them with &lt;code&gt;3J&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the variable names, first you'll need to clean up the whitespace at the end, together with the &lt;code&gt;=&lt;/code&gt;, which you can do with &lt;code&gt;3:s/ *= *$//&lt;/code&gt;. At that point, you can use the same procedure to add commas to the end of the first few lines (except the last one) and join them together. (Also possible is &lt;code&gt;3:norm! f D&lt;/code&gt; to jump to the first space and delete til the end of the line, or &lt;code&gt;3:norm! f C,&lt;/code&gt; to add a comma already.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here all you need to do is insert an &lt;code&gt;=&lt;/code&gt; back to the line with the list of variables, and paste back the list of expressions to the end of that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All done!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a bit of work, but it's a really flexible method that you can use in many similar situations, visual block mode is a tool in Vim I definitely recommend that everyone who uses Vim should really learn! It can be really useful for this kind of text transformation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; &lt;a href=&quot;https://vi.stackexchange.com/users/17449/user938271&quot;&gt;@user938271&lt;/a&gt; was kind enough to record this into a video for a nice visual reference!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.imgur.com/AwZSRcu.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.imgur.com/AwZSRcu.jpg&quot; alt=&quot;Video recording of demonstration&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-09-11T12:35:22.097" LastActivityDate="2019-09-11T12:35:22.097" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21172" PostTypeId="1" CreationDate="2019-09-10T22:49:48.247" Score="5" ViewCount="532" Body="&lt;p&gt;I want to have my tags file generated from gutentags/ctags to be in the .git folder, because I am working on a project with other people where I don't want to edit the .gitignore file. So, I have these 2 lines in my vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10 set tags^=.git/tags;&#xA;11 let g:gutentags_ctags_tagfile = '.git/tags'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the problem with this is that all the paths from this are still generated with respect to my root folder, so when vim tries to look for the tag it will throw the error &lt;code&gt;.git/root/folder/path/file.js does not exist&lt;/code&gt;. Somehow I need to be able to have gutentags generate this tag file with respect to my .git directory.&lt;/p&gt;&#xA;" OwnerUserId="14314" LastActivityDate="2019-09-10T22:49:48.247" Title="How to have gutentags build tags from the .git folder in a repository?" Tags="|tags|ctags|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21173" PostTypeId="1" CreationDate="2019-09-11T04:58:48.283" Score="0" ViewCount="615" Body="&lt;p&gt;I'm on the latest version of Arch Linux. The version of Vim from the Arch repos doesn't have python support, so I downloaded the source code and built it from that. I have checked, and Python support is enabled. I have Python installed on my system. However, when I try to start vim with a plugin which requires Python, I get a warning before vim opens, and the plugin doesn't function properly:&#xA;&lt;code&gt;vim-llp: python required&lt;/code&gt;. Do I have to tell vim that Python exists during the installation process or something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:version&lt;/code&gt; output is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Sep 11 2019 00:35:18)&#xA;Included patches: 1-2021&#xA;Compiled by noah@arch-xps&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl               +clientserver      +diff              +folding           +libcall           +mouse_gpm         +packages          -ruby              -tag_any_white     +vartabs           -xfontset&#xA;+arabic            +clipboard         +digraphs          -footer            +linebreak         -mouse_jsbterm     +path_extra        +scrollbind        -tcl               +vertsplit         +xim&#xA;+autocmd           +cmdline_compl     +dnd               +fork()            +lispindent        +mouse_netterm     -perl              +signs             +termguicolors     +virtualedit       +xpm&#xA;+autochdir         +cmdline_hist      -ebcdic            +gettext           +listcmds          +mouse_sgr         +persistent_undo   +smartindent       +terminal          +visual            +xsmp_interact&#xA;-autoservername    +cmdline_info      +emacs_tags        -hangul_input      +localmap          -mouse_sysmouse    +postscript        +sound             +terminfo          +visualextra       +xterm_clipboard&#xA;+balloon_eval      +comments          +eval              +iconv             -lua               +mouse_urxvt       +printer           +spell             +termresponse      +viminfo           -xterm_save&#xA;+balloon_eval_term +conceal           +ex_extra          +insert_expand     +menu              +mouse_xterm       +profile           +startuptime       +textobjects       +vreplace&#xA;+browse            +cryptv            +extra_search      +job               +mksession         +multi_byte        -python            +statusline        +textprop          +wildignore&#xA;++builtin_terms    +cscope            -farsi             +jumplist          +modify_fname      +multi_lang        -python3           -sun_workshop      +timers            +wildmenu&#xA;+byte_offset       +cursorbind        +file_in_path      +keymap            +mouse             -mzscheme          +quickfix          +syntax            +title             +windows&#xA;+channel           +cursorshape       +find_in_path      +lambda            +mouseshape        +netbeans_intg     +reltime           +tag_binary        +toolbar           +writebackup&#xA;+cindent           +dialog_con_gui    +float             +langmap           +mouse_dec         +num64             +rightleft         -tag_old_static    +user_commands     +X11&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi-&#xA;3.2.1/include -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/uuid -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/u&#xA;sr/include/libmount -I/usr/include/blkid -I/usr/include/atk-1.0 -pthread    -O2 -fno-strength-reduce -Wall -D_REENTRANT  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz&#xA; -lfontconfig -lfreetype  -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lelf -lnsl  -lcanberra  -lacl -lattr -lgpm -ldl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21173" LastEditorUserId="18609" LastEditDate="2019-09-11T19:54:47.637" LastActivityDate="2019-09-11T20:13:50.710" Title="Why doesn't Vim recognize that I have Python installed?" Tags="|installing|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21174" PostTypeId="2" ParentId="21169" CreationDate="2019-09-11T09:11:09.707" Score="3" Body="&lt;p&gt;In terms of &lt;em&gt;keystroke&lt;/em&gt; efficiency, it's hard to beat a &lt;a href=&quot;https://www.vimhelp.org/repeat.txt.html#recording&quot; rel=&quot;nofollow noreferrer&quot;&gt;recorded macro&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting with your cursor on the first &lt;code&gt;self.&lt;/code&gt;, typing the following will create a macro in your &lt;code&gt;&quot;q&lt;/code&gt; register which add the next line that begins with &lt;code&gt;self.&lt;/code&gt; to the current assignment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Emaqq/^self\.&amp;lt;CR&amp;gt;d3ei &amp;lt;Esc&amp;gt;`aa, &amp;lt;Esc&amp;gt;pma``d2wywdd`aA, &amp;lt;Esc&amp;gt;&quot;0pq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then replay this once with &lt;code&gt;@q&lt;/code&gt;, multiple times with &lt;code&gt;N@q&lt;/code&gt; (so, e.g. for &lt;a href=&quot;https://vi.stackexchange.com/a/21170/343&quot;&gt;@user938271's example file&lt;/a&gt;, you would type &lt;code&gt;7@q&lt;/code&gt;), or for &lt;em&gt;every&lt;/em&gt; matching line, you can just switch off &lt;code&gt;'wrapscan'&lt;/code&gt; and use a large number:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nows&#xA;99@q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The macro playback will then abort when there are no more matching lines in the file.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How it works&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Let's break it down into smaller pieces:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Ema&lt;/code&gt; First, move to the end of the first variable, and set a mark &lt;code&gt;'a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;qq&lt;/code&gt; Start recording a macro into register &lt;code&gt;&quot;q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/^self\.&amp;lt;CR&amp;gt;&lt;/code&gt; Search for the next line that begins with &lt;code&gt;self.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d3e&lt;/code&gt; Delete the variable name&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;i&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; In order to be sure that the macro will work on all lines, we add a space character here, so that there is always whitespace on the line before the equals sign&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`a&lt;/code&gt; Jump to the position we marked earlier&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a,&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt;p&lt;/code&gt; Append a comma, a space, and then paste the variable we deleted&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ma&lt;/code&gt; Reset the mark&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;``&lt;/code&gt; Jump back to our previous position (on the line we're merging from)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d2wywdd&lt;/code&gt; Delete the equals sign and surrounding whitespace (&lt;code&gt;d2w&lt;/code&gt;), yank the rhs of the assignment (&lt;code&gt;yw&lt;/code&gt;), and then delete the line (&lt;code&gt;dd&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`a&lt;/code&gt; Jump back to the position we just marked&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A,&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt;&quot;0p&lt;/code&gt; Append a comma and a space to the end of the line, and then paste in the value that we yanked&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; End the recording&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;We could shave off a few keystrokes here and there by using some more advanced Vim features (e.g. &lt;code&gt;:help registers&lt;/code&gt;, &lt;code&gt;:help i_CTRL-R&lt;/code&gt;), but this version offers a nice balance between simplicity and speed of recording.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We could also make some tweaks to make it more robust (e.g. to ignore lines like &lt;code&gt;self.do_something()&lt;/code&gt;), but this works for the examples supplied by you and @user938271).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the other answers on this page have videos, here's a screen recording of this answer in action (sadly without a keyboard overlay):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://asciinema.org/a/TgHLtalw9yUJN5xeLwXfvY5oz&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://asciinema.org/a/TgHLtalw9yUJN5xeLwXfvY5oz.svg&quot; alt=&quot;asciicast&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;For more information&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.vimhelp.org/repeat.txt.html#recording&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help recording&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.vimhelp.org/motion.txt.html#mark-motions&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help mark-motions&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.vimhelp.org/change.txt.html#quote&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help quote&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.vimhelp.org/change.txt.html#quote0&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help quote0&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-11T15:53:48.400" LastActivityDate="2019-09-11T15:53:48.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21175" PostTypeId="2" ParentId="21169" CreationDate="2019-09-11T09:28:30.480" Score="4" Body="&lt;p&gt;Andrew Radev's &lt;a href=&quot;https://github.com/AndrewRadev/splitjoin.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;splitjoin plugin&lt;/a&gt; is designed specifically for this (and many similar) use cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After installation, simply place your cursor on the first line and type &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;J&lt;/kbd&gt; to convert from a multiple assignments to a single one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to go in the other direction, you can type &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;S&lt;/kbd&gt; on a single-line multiple assignment.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-09-11T09:28:30.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21176" PostTypeId="2" ParentId="21129" CreationDate="2019-09-11T09:29:14.720" Score="2" Body="&lt;p&gt;As others have pointed out in the question comments, this is a somewhat complex issue that I really DON'T have the expertise to expound on. That being said, the crux of the trouble I was having was related to automatic saving/loading of views (which include info on folds) when a buffer is quit/loaded. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To automatically save/load folds in vim, one adds something like the below to one's &lt;code&gt;vimrc&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup auto_save_folds &#xA;autocmd! &#xA;au BufWinLeave ?* mkview&#xA;au BufWinEnter ?* silent loadview&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All the above code does is to automatically save folds when the buffer is unloaded, and automatically load the folds when the buffer is loaded. The way it does this, is via info stored in the views directory. With the above code included in the &lt;code&gt;vimrc&lt;/code&gt;, when one looks in the &lt;code&gt;~/.vim/view&lt;/code&gt; (can be different in different OS'es), one sees a number of files, with filenames similar to (but interspersed with special characters throughout the name) actual files one has ever opened in vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, the above works. But when using splits, it is a slightly different story. Each split is considered a different view, albeit of the same buffer. So when one has the same file in splits, and makes changes that affect the folds in one of the splits, then vim has no way of reconciling the changes in one split with the rest of the splits - so the information on the 'views' (folds et al) in each of the splits keeps overwriting each other. Because all of the splits use the same view to store their own info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What needs to be done is to give the program a way to better organize this information. That's done by giving names to each of the views. Assuming a use case of 2 views, the code above would look like - &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup auto_save_folds &#xA;autocmd! &#xA;au BufWinLeave ?* mkview 1&#xA;au BufWinEnter ?* silent loadview 1&#xA;au BufWinLeave ?* mkview 2&#xA;au BufWinEnter ?* silent loadview 2&#xA;.&#xA;.&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I often have up to 4-5 views, so the above numbering goes on till 5. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this setup, when one again looks in the &lt;code&gt;view&lt;/code&gt; directory (after opening and folding a fresh file), one can see that for each file opened in vim, there are now 2 files (), appropriately suffixed in the &lt;code&gt;view&lt;/code&gt; directory. This way the folds in the individual splits do not overwrite each other. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, this has worked nicely for me, using manual folds (which I continue to stick with because of personal preferences). But, given the complex interplay of various issues here, I cannot assure that this will work for all. &lt;/p&gt;&#xA;" OwnerUserId="23720" LastEditorUserId="23720" LastEditDate="2019-09-12T07:52:52.850" LastActivityDate="2019-09-12T07:52:52.850" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21177" PostTypeId="2" ParentId="21146" CreationDate="2019-09-11T11:38:12.647" Score="2" Body="&lt;p&gt;One alternative is to use  &lt;a href=&quot;https://github.com/ipod825/vim-netranger&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ipod825/vim-netranger&lt;/a&gt; . It replaces netrw, and uses vim key bindings to do actions on the files. In this case, you can go to insert mode with &lt;code&gt;i&lt;/code&gt; and change the file name. What will work is to do ctrl-o and from there &lt;code&gt;:%s&lt;/code&gt;. Alternatively, use &lt;code&gt;:g&lt;/code&gt; to enter i repeatedly and do the change. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-09-11T22:25:17.347" LastActivityDate="2019-09-11T22:25:17.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21178" PostTypeId="2" ParentId="20407" CreationDate="2019-09-11T12:48:23.540" Score="1" Body="&lt;p&gt;D. Ben&quot;s answer is correct one but a bit terse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also answered a similar question with detailed solution at &lt;a href=&quot;https://vi.stackexchange.com/questions/18295/how-to-set-a-colorscheme-that-still-shows-spelling-errors/&quot;&gt;How to set a colorscheme that still shows spelling errors?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;au&lt;/code&gt; is very useful!&lt;/p&gt;&#xA;" OwnerUserId="23771" LastActivityDate="2019-09-11T12:48:23.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21179" PostTypeId="1" AcceptedAnswerId="21181" CreationDate="2019-09-11T20:11:53.570" Score="5" ViewCount="3359" Body="&lt;p&gt;Does vim allow us to assign names to capture groups for search/replace that can be used in place of &lt;code&gt;\1&lt;/code&gt;, &lt;code&gt;\2&lt;/code&gt; etc... for back-references and substitution?&#xA;&lt;br&gt;&lt;br&gt;&#xA;Like in in Python: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; import re&#xA;&amp;gt;&amp;gt;&amp;gt; s=&quot;ABCD HELLO, WORLD! 1234&quot;&#xA;&amp;gt;&amp;gt;&amp;gt; print(re.sub(r&quot;^(?P&amp;lt;foo&amp;gt;\w+).*?(?P&amp;lt;bar&amp;gt;\d+)$&quot;, r&quot;\n\g&amp;lt;foo&amp;gt; \g&amp;lt;bar&amp;gt;\n&quot;, s))&#xA;&#xA;ABCD 1234&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;Or Perl:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dade_murphy@darkstar$ \&#xA;&amp;gt; printf &quot;ABCD HELLO, WORLD! 1234&quot; \&#xA;&amp;gt;   | perl -pe 's/^(?&amp;lt;foo&amp;gt;\w+).*?(?&amp;lt;bar&amp;gt;\d+)$/\n$+{foo} $+{bar}\n/'&#xA;&#xA;ABCD 1234&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;ie. something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/^\(?P&amp;lt;foo&amp;gt;\w\+\)\s*$/\g&amp;lt;foo&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;Neither syntax seems to work. I'm guessing this is not supported-- it doesn't strike me as a feature that would be particularly sought after in a text editor. But search / Google aren't confirming either way, so here I am.&lt;/p&gt;&#xA;" OwnerUserId="24791" LastEditorUserId="343" LastEditDate="2019-10-16T09:19:15.570" LastActivityDate="2024-03-01T14:56:55.620" Title="Named capture groups in vim regex?" Tags="|regular-expression|substitute|find|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="21180" PostTypeId="2" ParentId="21173" CreationDate="2019-09-11T20:13:50.710" Score="2" Body="&lt;p&gt;This vim is compiled without python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-python&#xA;-python3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also see &lt;code&gt;has()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this you’ll need to install a vim built with python support. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-09-11T20:13:50.710" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21181" PostTypeId="2" ParentId="21179" CreationDate="2019-09-12T03:47:02.900" Score="7" Body="&lt;p&gt;No, named capture groups are not available.&lt;/p&gt;&#xA;&lt;p&gt;In fact, some design decisions in Vim actually expose the limit of 9 (numbered) capture groups, such as the &lt;a href=&quot;https://vimhelp.org/builtin.txt.html#matchlist%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;matchlist()&lt;/code&gt; function&lt;/a&gt;, which returns a list of 10 strings for each of &lt;code&gt;\0&lt;/code&gt; through &lt;code&gt;\9&lt;/code&gt;. (That doesn't mean named groups would be impossible, it's just exposing some internals showing this is quite an ingrained design decision.)&lt;/p&gt;&#xA;&lt;p&gt;You can also go through the whole &lt;a href=&quot;https://vimhelp.org/pattern.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help pattern-searches&lt;/code&gt;&lt;/a&gt; and you'll see no reference to named capture groups.&lt;/p&gt;&#xA;&lt;p&gt;Vim also has some regexp features (namely &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; to mark the start and end of the match) that can replace the use of capture groups and are often more convenient to use in case you're only using capture groups to repeat them as part of the replacement.&lt;/p&gt;&#xA;&lt;p&gt;So, in short, no, named capture groups are not available as of Vim 8.1.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="22549" LastEditDate="2024-03-01T14:56:55.620" LastActivityDate="2024-03-01T14:56:55.620" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21182" PostTypeId="1" AcceptedAnswerId="21183" CreationDate="2019-09-12T07:58:12.780" Score="1" ViewCount="1078" Body="&lt;p&gt;Note this may be a duplicate, but I couldn't really find an answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a C++ perspective:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With universal ctags on, doing a &lt;code&gt;C-]&lt;/code&gt; on top of a method call presents you with a tag list matching the method name. Some of the methods in that list may be from different classes, some of them may be overloaded with either incompatible types or incorrect number of arguments compared to the original method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a plugin out there which removes some of the false positives or at the very least sorts this list in a smarter way? Something similar to what CLion cmake engine does?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not interested in autocompletion as that works for me.&lt;/p&gt;&#xA;" OwnerUserId="24802" LastActivityDate="2019-09-13T13:08:12.823" Title="Plugin to display a smarter method tag list" Tags="|ctags|filetype-c++|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21183" PostTypeId="2" ParentId="21182" CreationDate="2019-09-12T10:37:44.443" Score="6" Body="&lt;p&gt;I cannot provide an answer different to the one I gave in other similar questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While tag-based plugins may present a complete list of existing overloads in a way much more ergonomic than &lt;code&gt;:tselect&lt;/code&gt; (they may even provide a filter option like my &lt;a href=&quot;https://github.com/luchermitte/lh-tags&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-tags&lt;/a&gt; plugin), they cannot help restrict the list of overloads to the one matching the types of the objects involved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, they could. This would means they have parsed the current C++ code and built an associated &lt;a href=&quot;https://en.wikipedia.org/wiki/Abstract_syntax_tree&quot; rel=&quot;nofollow noreferrer&quot;&gt;AST&lt;/a&gt;. At this point, these plugins would have access to much better tools than tags, so they don't bother with tags. That's what &lt;a href=&quot;https://microsoft.github.io/language-server-protocol/&quot; rel=&quot;nofollow noreferrer&quot;&gt;language server protocol&lt;/a&gt; (LSP) &lt;a href=&quot;https://langserver.org/#implementations-client&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugins&lt;/a&gt; offer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lately, I've been using &lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;coc.nvim&lt;/a&gt; + &lt;a href=&quot;https://github.com/MaskRay/ccls/wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;ccls&lt;/a&gt;, the result is often much better that what I had with tag-based solutions to navigate C++ codes.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="1292" LastEditDate="2019-09-13T13:08:12.823" LastActivityDate="2019-09-13T13:08:12.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21184" PostTypeId="1" AcceptedAnswerId="26360" CreationDate="2019-09-12T10:58:01.407" Score="2" ViewCount="684" Body="&lt;p&gt;Sometimes (about once/twice a day), when I open a file in vim, I get a strange line containing meta control characters right at the top of the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/j8aKf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/j8aKf.png&quot; alt=&quot;strange line&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The line goes away when I refresh the buffer, so it's not really a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm just curious to know why it happens. I run vim in a terminal and I'm on ubuntu 18.04.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$&amp;gt; vim --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 06 2019 17:31:41)&#xA;Included patches: 1-1453&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've used vim on various machines for many years, but my current laptop is the only one where I've seen this happen.&lt;/p&gt;&#xA;" OwnerUserId="6296" LastActivityDate="2020-07-07T13:49:51.867" Title="Strange control line when opening a file" Tags="|terminal|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="21185" PostTypeId="2" ParentId="84" CreationDate="2019-09-12T13:04:56.320" Score="1" Body="&lt;p&gt;You can also use a global command to put some specific pattern on the clipboard. It can be useful in situations where you have information scattered in a file and manually coping is prone to errors and tiring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First clean the register that will receive the information&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then copy all the lines containing the pattern to it&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/pattern/yank A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally tranfereing (copying ) the information to the system clipboard&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @+=@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you try to copy every line containing a &quot;pattern&quot; directly to the clipboard it won't work because the clipboard does not have the capability of append new content, thus we are using here a normal vim register to store all the lines containing the pattern at once and then putting it on the clipboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;OBS: It is necessary clining the register before using it, and the use of the UPPERCASE version of the register allows us to append content, otherwise it won't work either.&lt;/p&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2019-09-12T13:10:27.340" LastActivityDate="2019-09-12T13:10:27.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21186" PostTypeId="1" AcceptedAnswerId="21217" CreationDate="2019-09-12T18:11:26.727" Score="2" ViewCount="143" Body="&lt;p&gt;When I open multiple files in &lt;code&gt;gvim&lt;/code&gt; with no options, they are assigned to buffers in the order I specify on the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim foo.cpp foo.h bar.cpp bar.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doing &lt;code&gt;:ls&lt;/code&gt; then yields:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 %a   &quot;foo.cpp&quot;                  line 1&#xA;2      &quot;foo.h&quot;                    line 0&#xA;3      &quot;bar.cpp&quot;                  line 0&#xA;4      &quot;bar.h&quot;                    line 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I am using &lt;code&gt;--servername&lt;/code&gt; and &lt;code&gt;--remote&lt;/code&gt; to have only one instance of &lt;code&gt;gvim&lt;/code&gt;, the files are loaded in a different order:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim --servername gvim &#xA;&#xA;// Later ...&#xA;&#xA;gvim --servername gvim --remote foo.cpp foo.h bar.cpp bar.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;code&gt;:ls&lt;/code&gt; yields:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2 %a   &quot;foo.cpp&quot;                  line 1&#xA;3      &quot;bar.cpp                   line 0&#xA;4      &quot;foo.h&quot;                    line 0&#xA;5      &quot;bar.h&quot;                    line 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that buffer 1 is not missing. It's a hidden empty buffer named &lt;code&gt;[No Name]&lt;/code&gt; that was created by the first call to &lt;code&gt;gvim&lt;/code&gt; with no file arguments)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like maybe the &lt;code&gt;--remote&lt;/code&gt; option causes the files to be grouped by extension. Is there a way to make &lt;code&gt;--remote&lt;/code&gt; load the files into buffers in the same order specified on the command line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, this is with stock gvim 7.4, on CentOS 6.9, with no &lt;code&gt;.vimrc&lt;/code&gt; or &lt;code&gt;.gvimrc&lt;/code&gt;, and no plugins installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like whatever &lt;code&gt;gvim&lt;/code&gt; is doing here has to do with the fact that it recognizes the extensions &lt;code&gt;.cpp&lt;/code&gt; and &lt;code&gt;.h&lt;/code&gt; as special in some way. If I replace &lt;code&gt;.cpp&lt;/code&gt; with &lt;code&gt;.cat&lt;/code&gt; and &lt;code&gt;.h&lt;/code&gt; with &lt;code&gt;.dog&lt;/code&gt;, the files are loaded in the same order specified on the command line, as expected.&lt;/p&gt;&#xA;" OwnerUserId="24811" LastEditorUserId="24811" LastEditDate="2019-09-13T16:52:43.837" LastActivityDate="2019-09-17T15:41:46.117" Title="Why does gvim --remote change order of files?" Tags="|gvim|" AnswerCount="1" CommentCount="8" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21187" PostTypeId="1" AcceptedAnswerId="21188" CreationDate="2019-09-12T18:27:55.183" Score="1" ViewCount="55" Body="&lt;p&gt;I have the following code in my &lt;code&gt;vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;:Goyo&quot;)&#xA;    augroup LatexGoyo&#xA;        autocmd!&#xA;        autocmd BufReadPost,BufNewFile *.tex Goyo&#xA;    augroup END&#xA;else&#xA;    augroup LatexColumnSet&#xA;        autocmd FileType tex setlocal columns=100&#xA;    augroup END&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to check for the presence of the &lt;code&gt;Goyo&lt;/code&gt; command provided by the &lt;a href=&quot;https://github.com/junegunn/goyo.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;goyo.vim&lt;/code&gt;&lt;/a&gt; plugin, and then invoke it upon opening any &lt;code&gt;tex&lt;/code&gt; file. If this plugin is not available/installed, then I'd like to set the columns to 100.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, with these settings in my &lt;code&gt;vimrc&lt;/code&gt;, when opening a &lt;code&gt;tex&lt;/code&gt; file, the &lt;code&gt;Goyo&lt;/code&gt; command is not executed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong, and how to fix this?&lt;/p&gt;&#xA;" OwnerUserId="8408" LastActivityDate="2019-11-19T08:18:51.127" Title="Unable to conditionally test for presence of a plugin command &amp; invoke it" Tags="|autocmd|plugin-system|filetype-tex|plugin-vim-plug|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21188" PostTypeId="2" ParentId="21187" CreationDate="2019-09-12T19:04:27.917" Score="5" Body="&lt;p&gt;The problem is, your vimrc file is executed before any plugins are loaded. You can check the order of what source files are loaded by issueing the &lt;code&gt;:scriptnames&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The usual way to fix this &lt;em&gt;problem&lt;/em&gt; is to execute the test inside a &lt;code&gt;VimEnter&lt;/code&gt; autocommand, something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:init()&#xA;   &quot; do your test here!&#xA;endfun&#xA;&#xA;augroup custom_vimrc&#xA;  autocmd!&#xA;  autocmd VimEnter * call s:init&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-09-12T19:04:27.917" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21189" PostTypeId="1" AcceptedAnswerId="21190" CreationDate="2019-09-12T19:32:48.480" Score="4" ViewCount="9891" Body="&lt;p&gt;When viewing a file &lt;code&gt;/tmp/vim_split_demo/test.txt&lt;/code&gt;, the parent directory can be opened in a horizontal split screen using the command &lt;code&gt;:Sex&lt;/code&gt;, as shown in these screenshots:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DzXEc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DzXEc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What command gives same functionality, except with the screen split vertically instead of horizontally?  Here is a screenshot of the desired results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lyz5s.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lyz5s.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That screenshot came from &lt;code&gt;vim /tmp/vim_split_demo&lt;/code&gt;, then doing &lt;code&gt;vsplit&lt;/code&gt; and opening the file in one side.  I've tried &lt;code&gt;:VSex&lt;/code&gt;, &lt;code&gt;:Vsex&lt;/code&gt; and a few others, but can't figure it out.  It doesn't matter which side shows the parent directory.&lt;/p&gt;&#xA;" OwnerUserId="3209" LastActivityDate="2019-09-13T16:49:55.697" Title="How to do :Sex but with a vertical split?" Tags="|split|filesystem|multiple-files|working-directory|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21190" PostTypeId="2" ParentId="21189" CreationDate="2019-09-12T19:36:17.857" Score="14" Body="&lt;p&gt;What you're looking for is &lt;code&gt;:Vexplore&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From your question, it sounds like you started off knowing only about &lt;code&gt;:Sexplore&lt;/code&gt; and understandably thought that that was the basic command for bringing up the &lt;code&gt;vim&lt;/code&gt; file explorer (which is called &lt;code&gt;netrw&lt;/code&gt;). However, the basic command is just &lt;code&gt;:Explore&lt;/code&gt;, and &lt;code&gt;:SExplore&lt;/code&gt; is actually just a variant of that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic &lt;code&gt;:Explore&lt;/code&gt; version doesn't open &lt;code&gt;netrw&lt;/code&gt; in a split window, it just replaces the current window with &lt;code&gt;netrw&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several variants. Here's the full list from the &lt;code&gt;vim&lt;/code&gt; help documentation, which you can see &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, or in &lt;code&gt;vim&lt;/code&gt; by typing &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help explore&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :[N]Explore[!]  [dir]... Explore directory of current file      *:Explore*&#xA; :[N]Hexplore[!] [dir]... Horizontal Split &amp;amp; Explore             *:Hexplore*&#xA; :[N]Lexplore[!] [dir]... Left Explorer Toggle                   *:Lexplore*&#xA; :[N]Sexplore[!] [dir]... Split&amp;amp;Explore current file's directory *:Sexplore*&#xA; :[N]Vexplore[!] [dir]... Vertical   Split &amp;amp; Explore             *:Vexplore*&#xA; :Texplore       [dir]... Tab &amp;amp; Explore                          *:Texplore*&#xA; :Rexplore            ... Return to/from Explorer                *:Rexplore*&#xA;&#xA; Used with :Explore **/pattern : (also see |netrw-starstar|)&#xA; :Nexplore............. go to next matching file                *:Nexplore*&#xA; :Pexplore............. go to previous matching file            *:Pexplore*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more detailed information about each variant, see the help docs.&lt;/p&gt;&#xA;" OwnerUserId="24811" LastEditorUserId="24811" LastEditDate="2019-09-13T16:49:55.697" LastActivityDate="2019-09-13T16:49:55.697" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21192" PostTypeId="1" CreationDate="2019-09-13T17:47:31.447" Score="1" ViewCount="100" Body="&lt;p&gt;Iam trying to put &lt;code&gt;nnoremap &amp;lt;C-Right&amp;gt; &amp;lt;C-w&amp;gt;3&amp;gt;&lt;/code&gt;  in the ~/.vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it's not working. Also, VIM has a PRETTY ANNOYING  line erasing binding to ctrl+Right in the Normal Mode.&#xA;I would like to deactivate  this erasing and do split resize with Ctrl + Arrows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How is the most secure way to config this  ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thank you&lt;/p&gt;&#xA;" OwnerUserId="24821" LastEditorUserId="24821" LastEditDate="2019-09-13T17:56:11.547" LastActivityDate="2019-09-13T17:56:11.547" Title="How do I securely remap the current split's width and height keys?" Tags="|key-bindings|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="21193" PostTypeId="1" AcceptedAnswerId="21194" CreationDate="2019-09-13T23:22:17.307" Score="1" ViewCount="176" Body="&lt;p&gt;I often nest one programming language within another (e.g. HTML inside python). This can be done per-language, and written items in &lt;code&gt;~/.vim/after/syntax/&lt;/code&gt; for that purpose, but I don't have the patience to implement it for every combination I use. This means I press &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;e&lt;/kbd&gt;&lt;kbd&gt;Up&lt;/kbd&gt;&lt;kbd&gt;Up&lt;/kbd&gt; a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to script this would simply be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F12&amp;gt; :set syn=&amp;lt;up&amp;gt;&amp;lt;up&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &lt;em&gt;almost&lt;/em&gt; works. The problem is that it's not literal enough; vim doesn't actually put this command in my history, so there's no &quot;toggling&quot; going on. (Actually, this is preferable; I don't want to pollute my history with all of this toggling.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty sure what I need is a custom function that searches my history for the most recent syntax specification (excluding the current syntax) and sets it. I know how to bind a function to a key, but I do not know how to implement the needed vimscript function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could somebody provide me some pointers here? Searching the web for this sort of thing merely turns up tricks for searching the command history manually (without vimscript).&lt;/p&gt;&#xA;" OwnerUserId="6505" LastActivityDate="2019-09-15T06:41:09.080" Title="Toggle between two most recent syntax highlighting settings" Tags="|vimscript|syntax-highlighting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21194" PostTypeId="2" ParentId="21193" CreationDate="2019-09-14T05:48:19.420" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Searching the web for this sort of thing merely turns up tricks for searching the command history manually (without vimscript).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I believe you're overthinking something. In Vim &quot;key macros&quot; are the &quot;first-class citizens&quot;. They are stable and repeatable (if written well). There's no need to turn them into the &quot;true&quot; VimScript statements other than some minor style and performance issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So searching over the command-window is quite doable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F12&amp;gt; q:2?^set syn=&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, open cmdwindow, backward find the 2nd occurence of the pattern, and then execute it. You may also want to &lt;code&gt;set lazyredraw&lt;/code&gt; to reduce flickering. Also, make sure to use &lt;code&gt;nnoremap&lt;/code&gt; instead of &lt;code&gt;nmap&lt;/code&gt;, so all the keystrokes on the right-hand side have the default meaning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPD. Now suppose we want the following: find the last &lt;code&gt;set syntax=xxx&lt;/code&gt; command &lt;em&gt;except the currently active syntax&lt;/em&gt;. Then this regexp could be used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;F12&amp;gt; q::call search('^set\s\+syn\(tax\)\?\s*=\(' .&#xA;    \ getwinvar(winnr(&quot;#&quot;), &quot;&amp;amp;syntax&quot;, &quot;nosyntax&quot;) . '\)\@!', &quot;b&quot;)&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;q:&lt;/code&gt; --- Open the command window&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:call search(..., &quot;b&quot;)&amp;lt;CR&amp;gt;&lt;/code&gt; --- backward find the pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; --- execute the line in the command window&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The regexp:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;^set&lt;/code&gt; --- the &quot;set&quot; command at the beginning of the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s\+&lt;/code&gt; --- followed by at least one space&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;syn\(tax\)\?&lt;/code&gt; --- &quot;syn&quot; or &quot;syntax&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\s*=&lt;/code&gt; --- optional spaces followed by the equal sign&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'\(' . getwinvar(...) . '\)'&lt;/code&gt; --- the current syntax value&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\@!&lt;/code&gt; --- negative match of the previous atom (i.e. any other syntax value)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also to note: &lt;code&gt;getwinvar(winnr(&quot;#&quot;), &quot;&amp;amp;syntax&quot;, &quot;nosyntax&quot;)&lt;/code&gt; returns &lt;code&gt;&amp;amp;syntax&lt;/code&gt; value of the &lt;em&gt;previous&lt;/em&gt; active window/buffer, because it's the command window an active one at this point; &lt;code&gt;&quot;nosyntax&quot;&lt;/code&gt; is simply a fake value used in case there is no syntax set at all.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-09-15T06:41:09.080" LastActivityDate="2019-09-15T06:41:09.080" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21195" PostTypeId="2" ParentId="21193" CreationDate="2019-09-14T07:57:22.290" Score="1" Body="&lt;p&gt;I believe this happens, because you are executing a normal mode command that resolves to a ex command but that is not put into the history as you noted. Now you could throw into an extra &lt;code&gt;histadd()&lt;/code&gt; call, but I believe this is more or less a hack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest a different, more robust approach, that does not depend on the order of &lt;code&gt;:set syn=&lt;/code&gt; commands you issued previously. Basically, check the current syntax value and toggle depending on its value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;f12&amp;gt; :set syntax=&amp;lt;c-r&amp;gt;=&amp;amp;syntax=='val1'?'val2':'val1'&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what this does is it exexutes the &lt;code&gt;:set syntax=&lt;/code&gt; command and returns the value from evaluating the expression (&lt;code&gt;&amp;lt;c-r&amp;gt;=&lt;/code&gt;, see &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_CTRL-R_=&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h c_CTRL-R-=&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &amp;amp;syntax=='val1'?'val2':'val1'. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This checks the value of the current syntax option, whether it is &lt;code&gt;val1&lt;/code&gt; and will return &lt;code&gt;val2&lt;/code&gt; in that case, otherwise it returns &lt;code&gt;val1&lt;/code&gt;. This return value will then be used for the &lt;code&gt;:set syntax&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, you need &lt;strong&gt;two&lt;/strong&gt; carriage returns (&lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;), because the first finishes the &lt;code&gt;c_CTRL-R-=&lt;/code&gt; command while the second executes the resulting &lt;code&gt;:set syntax&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-09-14T07:57:22.290" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21197" PostTypeId="1" AcceptedAnswerId="21198" CreationDate="2019-09-15T15:12:25.207" Score="2" ViewCount="232" Body="&lt;p&gt;In the context of developing a plug-in, what is the most portable (various versions of &lt;code&gt;vim&lt;/code&gt;, &lt;code&gt;nvim&lt;/code&gt;, ...) and readable way to implement a &quot;menu&quot; similar to what &lt;code&gt;:tselect&lt;/code&gt; gives &lt;em&gt;i.e.&lt;/em&gt; that&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;appears in the bottom and takes as much screen as necessary&lt;/li&gt;&#xA;&lt;li&gt;paginates the content if there are too many entries to fit on a single screen&lt;/li&gt;&#xA;&lt;li&gt;implements the commands to navigate the list&lt;/li&gt;&#xA;&lt;li&gt;enumerates and indexes the entries&lt;/li&gt;&#xA;&lt;li&gt;waits for an input for the selected entry (or defaults to cancelling)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This could be hacked together using a buffer, remapping, &lt;em&gt;etc.&lt;/em&gt; but there must be a simpler way to do such a common thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I would like to pass the structured data and receive back the selected index.&lt;/p&gt;&#xA;" OwnerUserId="23696" LastActivityDate="2019-09-15T16:05:19.807" Title="Standard way to implement a :tselect-like menu?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21198" PostTypeId="2" ParentId="21197" CreationDate="2019-09-15T15:58:29.723" Score="1" Body="&lt;p&gt;Perhaps, you want &lt;code&gt;inputlist()&lt;/code&gt;. It does not provide the item numbers, but it's quite easy to add them manually:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; MyChoice({list} [, {prompt}])&#xA;&quot; Lets user choose an item from {list}. Returns the selected item index or -1.&#xA;&quot; If {prompt} is omitted the default prompt is used.&#xA;function! MyChoice(list, ...)&#xA;    let l:prompt = a:0 ? a:1 : &quot;Input number:&quot;&#xA;    let l:idx = inputlist(insert(map(copy(a:list), '(1 + v:key) . &quot;. &quot; . v:val'), l:prompt))&#xA;    if l:idx &amp;gt;= 1 &amp;amp;&amp;amp; l:idx &amp;lt;= len(a:list)&#xA;        return l:idx - 1&#xA;    endif&#xA;    return -1&#xA;endfunction&#xA;&#xA;&quot; example usage&#xA;let choice = MyChoice(['foo', 'bar', 'baz'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-09-15T16:05:19.807" LastActivityDate="2019-09-15T16:05:19.807" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21201" PostTypeId="1" AcceptedAnswerId="21203" CreationDate="2019-09-15T18:16:25.020" Score="0" ViewCount="278" Body="&lt;p&gt;I opened up a terminal with &lt;code&gt;:terminal&lt;/code&gt;. Then I ran a server process that prints logs whenever someone hits the API. Next, I resized gnome-terminal, but I noticed vim didn't update the view of the server logs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to allow the vim &lt;code&gt;:terminal&lt;/code&gt; to redraw or reflow the text whenever the gnome-terminal window resizes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what &lt;code&gt;termwinsize&lt;/code&gt; is set to. Not sure if that's the right setting for this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set termwinsize?&#xA;termwinsize=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22095" LastActivityDate="2019-09-15T19:08:53.523" Title="Allow text to reflow in terminal mode after resizing" Tags="|vim-windows|terminal-buffer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21202" PostTypeId="2" ParentId="84" CreationDate="2019-09-15T18:46:09.743" Score="15" Body="&lt;p&gt;If you can't figure out how to get &lt;code&gt;+clipboard&lt;/code&gt; to work, which I couldn't for some reason, then you can do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you only want to copy a section of the file, I do &lt;code&gt;shift&lt;/code&gt;+&lt;code&gt;v&lt;/code&gt; to go into visual mode and only highlight the lines I want to copy. Then I do this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Linux Wayland&#xA;:'&amp;lt;,'&amp;gt;w !wl-copy&#xA;&#xA;# Linux Xorg&#xA;:'&amp;lt;,'&amp;gt;w !xclip -selection clipboard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; - means you used visual mode to select a range (you don't type this)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;w !{cmd}&lt;/code&gt; - write the range to the stdin of &lt;code&gt;cmd&lt;/code&gt;, see more at &lt;code&gt;:help w_c&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;wl-copy&lt;/code&gt; and &lt;code&gt;xclip&lt;/code&gt; are programs that you can pipe text to and they'll add it to your system clipboard&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also, once this is in your history, you don't have to type the whole thing again. Just select with visual mode, type &lt;code&gt;w&lt;/code&gt; then press up and the command should autocomplete. Also, also, you don't have to use visual mode. You can set whatever range you want.&lt;/p&gt;&#xA;" OwnerUserId="22095" LastActivityDate="2019-09-15T18:46:09.743" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21203" PostTypeId="2" ParentId="21201" CreationDate="2019-09-15T19:08:53.523" Score="0" Body="&lt;p&gt;When text is output by a program, that’s the output—fin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To reflow a program’s output would require&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Regenerating it; or&lt;/li&gt;&#xA;&lt;li&gt;Piping it to a formatting program; or&lt;/li&gt;&#xA;&lt;li&gt;Copying it into an editor that can reflow.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Once it’s on the screen, you won’t have much luck changing how it displays. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-09-15T19:08:53.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21204" PostTypeId="1" CreationDate="2019-09-15T19:24:55.153" Score="6" ViewCount="3034" Body="&lt;p&gt;I have a couple of tabs open. Is it possible to set custom tab page names for each individual tab page?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I want to name one tab &quot;database&quot;, another &quot;backend&quot;, and another &quot;frontend&quot;. I just want static labels. Does something like &lt;code&gt;rename-window&lt;/code&gt; from tmux exist in vim? (Without a plugin.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;I'm curious about vim in the terminal, not gvim.&lt;/p&gt;&#xA;" OwnerUserId="22095" LastEditorUserId="22095" LastEditDate="2019-09-15T22:06:44.657" LastActivityDate="2019-09-15T22:12:50.887" Title="How do you set the name of a tab page?" Tags="|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21205" PostTypeId="1" CreationDate="2019-09-15T21:41:25.693" Score="2" ViewCount="714" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vyBz1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vyBz1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to stay always in the same netrw buffer after selecting a file to edit?&lt;/p&gt;&#xA;" OwnerUserId="24841" LastActivityDate="2019-09-17T14:12:13.970" Title="Everytime I call :Explore netrw creates a new unlisted buffer" Tags="|buffers|netrw|hidden-buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21206" PostTypeId="2" ParentId="21204" CreationDate="2019-09-15T21:55:35.193" Score="1" Body="&lt;p&gt;There are two tablines in Vim: a &quot;regular&quot; tabline, and a GUI tabline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're running GVim and &lt;code&gt;guioptions&lt;/code&gt; contains &lt;code&gt;e&lt;/code&gt; (this is the default) then the GUI tabline is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tweaking the GUI tabline is pretty straightforward:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; use t:TabLabel if set; otherwise use the defaults&#xA;let &amp;amp;guitablabel='%{get(t:,&quot;TabLabel&quot;,&quot;&quot;)}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then set the labels with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call settabvar(1, &quot;TabLabel&quot;, &quot;Database&quot;)&#xA;call settabvar(2, &quot;TabLabel&quot;, &quot;Backend&quot;)&#xA;call settabvar(3, &quot;TabLabel&quot;, &quot;Frontend&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, for the regular tabline you have to compose the whole string at once, so it gets much more tricky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code is loosely based on the example code from &lt;code&gt;:h setting-tabline&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; get some label for a single tab&#xA;function! MyTabLabel(tabarg)&#xA;    &quot; try t:TabLabel&#xA;    let l:result = gettabvar(a:tabarg, &quot;TabLabel&quot;, &quot;&quot;)&#xA;    &quot; or active buffer name&#xA;    if empty(l:result)&#xA;        let l:result = bufname(winbufnr(win_getid(tabpagewinnr(a:tabarg), a:tabarg)))&#xA;    endif&#xA;    &quot; or some fixed string&#xA;    if empty(l:result)&#xA;        let l:result = '[Noname]'&#xA;    endif&#xA;    &quot; truncate the path, so (hopefully) it will not get too long&#xA;    return l:result[strridx(l:result, '/') + 1 : ]&#xA;endfunction&#xA;&#xA;&quot; build the whole tabline&#xA;function! MyTabLine()&#xA;    let l:result = ''&#xA;    &quot; all our tabs&#xA;    for l:num in range(1, tabpagenr(&quot;$&quot;))&#xA;        &quot; tab color&#xA;        let l:result .= (l:num != tabpagenr()) ? '%#TabLine#' : '%#TabLineSel#'&#xA;        &quot; tab text&#xA;        let l:result .= '%' . l:num . 'T %{MyTabLabel(' . l:num . ')} '&#xA;    endfor&#xA;    &quot; space filler&#xA;    let l:result .= '%#TabLineFill#%T%='&#xA;    &quot; [X] button on the right if there are several tabs&#xA;    let l:result .= repeat('%#TabLine#%999X[X]', l:num &amp;gt; 1)&#xA;    return l:result&#xA;endfunction&#xA;&#xA;&quot; setup our tabline&#xA;set tabline=%!MyTabLine()&#xA;&#xA;&quot; set sample labels&#xA;call settabvar(1, &quot;TabLabel&quot;, &quot;Database&quot;)&#xA;call settabvar(2, &quot;TabLabel&quot;, &quot;Backend&quot;)&#xA;call settabvar(3, &quot;TabLabel&quot;, &quot;Frontend&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the last but not least, make sure that &lt;code&gt;showtabline&lt;/code&gt; is not equal to zero, or your tabline will never be shown.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-09-15T22:12:50.887" LastActivityDate="2019-09-15T22:12:50.887" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21207" PostTypeId="1" AcceptedAnswerId="21212" CreationDate="2019-09-15T23:08:32.657" Score="1" ViewCount="728" Body="&lt;p&gt;I have a question regarding the following situation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use a default .vimrc and a vimrc (name it .vimrc2) for a special purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I start vim with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u ~/.vimrc2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have the following problem: Plugins (I use &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt;), which are specified in .vimrc (especially &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt;) will not be loaded if I run the command above.&#xA;I have tried to include the code from .vimrc: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin()&#xA;Plug 'sirver/ultisnips'&#xA;let g:UltiSnipsUsePythonVersion = 3&#xA;    let g:UltiSnipsExpandTrigger = '&amp;lt;tab&amp;gt;'&#xA;    let g:UltiSnipsJumpForwardTrigger = '&amp;lt;tab&amp;gt;'&#xA;    let g:UltiSnipsJumpBackwardTrigger = '&amp;lt;s-tab&amp;gt;'&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into my .vimrc2 file, but it doesn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure my system such that snippets (and other plugins) will be loaded, no matter which .vimrc file I use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plugins are at ~/.vim/plugged and snippets at ~/.vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running :scriptnames gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: ~/.vimrcforinkscape&#xA;  2: ~/.vim/autoload/plug.vim&#xA;  3: /usr/share/vim/vim81/filetype.vim&#xA;  4: ~/.vim/ftdetect/snippets.vim&#xA;  5: ~/.vim/plugged/ultisnips/ftdetect/snippets.vim&#xA;  6: /usr/share/vim/vim81/ftplugin.vim&#xA;  7: /usr/share/vim/vim81/indent.vim&#xA;  8: /usr/share/vim/vim81/syntax/syntax.vim&#xA;  9: /usr/share/vim/vim81/syntax/synload.vim&#xA; 10: /usr/share/vim/vim81/syntax/syncolor.vim&#xA; 11: ~/.vim/plugged/ultisnips/plugin/UltiSnips.vim&#xA; 12: /usr/share/vim/vim81/plugin/getscriptPlugin.vim&#xA; 13: /usr/share/vim/vim81/plugin/gzip.vim&#xA; 14: /usr/share/vim/vim81/plugin/logiPat.vim&#xA; 15: /usr/share/vim/vim81/plugin/manpager.vim&#xA; 16: /usr/share/vim/vim81/plugin/matchparen.vim&#xA; 17: /usr/share/vim/vim81/plugin/netrwPlugin.vim&#xA; 18: /usr/share/vim/vim81/plugin/rrhelper.vim&#xA; 19: /usr/share/vim/vim81/plugin/spellfile.vim&#xA; 20: /usr/share/vim/vim81/plugin/tarPlugin.vim&#xA; 21: /usr/share/vim/vim81/plugin/tohtml.vim&#xA; 22: /usr/share/vim/vim81/plugin/vimballPlugin.vim&#xA; 23: /usr/share/vim/vim81/plugin/zipPlugin.vim&#xA; 24: ~/.vim/plugged/ultisnips/after/plugin/UltiSnips_after.vim&#xA; 25: /usr/share/vim/vim81/autoload/dist/ft.vim&#xA; 26: /usr/share/vim/vim81/ftplugin/tex.vim&#xA; 27: /usr/share/vim/vim81/ftplugin/plaintex.vim&#xA; 28: /usr/share/vim/vim81/ftplugin/initex.vim&#xA; 29: /usr/share/vim/vim81/indent/tex.vim&#xA; 30: /usr/share/vim/vim81/syntax/tex.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24842" LastEditorUserId="24842" LastEditDate="2019-09-16T00:37:03.267" LastActivityDate="2019-09-18T12:21:18.643" Title="Same plugins for every .vimrc file (vim-plug)" Tags="|vimrc|plugin-ultisnips|plugin-vim-plug|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="21208" PostTypeId="1" AcceptedAnswerId="21214" CreationDate="2019-09-16T00:35:54.863" Score="0" ViewCount="206" Body="&lt;p&gt;In my .vimrc, I have the following exec command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-f&amp;gt; &amp;lt;Esc&amp;gt;: silent exec '.!inkscape-figures create &quot;'.getline('.').'&quot; &quot;'.b.vimtex.root.'/figures/&quot;'&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;:w&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where inkscape-figures create (figure) is a bash command. However, I want to include the following command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;inkscape-figures watch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to be executed when I press CTRL+F in insert mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I dont understand the syntax of exec and I haven't found anything similar online.&lt;/p&gt;&#xA;" OwnerUserId="24842" LastActivityDate="2019-09-16T20:39:18.360" Title="Syntax Question for exec (executing two commands)" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21209" PostTypeId="1" CreationDate="2019-09-16T12:33:21.900" Score="2" ViewCount="309" Body="&lt;p&gt;I mapped &lt;code&gt;&amp;lt;C-X&amp;gt;&lt;/code&gt; to &lt;code&gt;&quot;*d&lt;/code&gt; and now I can't revert it back. I want it to subtract number by 1 like default, but I can't unmap it permanently, it's set to &lt;code&gt;&amp;lt;C-X&amp;gt;&lt;/code&gt; in every new session. I'm sure .vimrc is not mapping it.&lt;/p&gt;&#xA;" OwnerUserId="24846" LastEditorUserId="10604" LastEditDate="2019-09-16T18:59:08.937" LastActivityDate="2019-09-16T19:00:38.333" Title="Can't unmap key mapping to its default permenantly" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21210" PostTypeId="2" ParentId="18238" CreationDate="2019-09-16T13:24:32.987" Score="2" Body="&lt;p&gt;You could check the value of &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27endofline%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;endofline&lt;/code&gt;&lt;/a&gt; and display your statusline accordingly. For example, this shows &lt;code&gt;[noeol]&lt;/code&gt; in your statusline when &lt;code&gt;endofline&lt;/code&gt; is false:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{&amp;amp;endofline?'':'[noeol]'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19712" LastEditorUserId="19712" LastEditDate="2020-11-14T10:14:52.533" LastActivityDate="2020-11-14T10:14:52.533" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21211" PostTypeId="2" ParentId="21209" CreationDate="2019-09-16T19:00:38.333" Score="2" Body="&lt;p&gt;In general, &lt;code&gt;:unmap &amp;lt;C-x&amp;gt;&lt;/code&gt; can get rid of he mapping (note the variants like &lt;code&gt;:nunmap&lt;/code&gt;, etc.). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it is strange that the mapping persists without being in your &lt;code&gt;.vimrc&lt;/code&gt;. You can use &lt;code&gt;:verbose map &amp;lt;C-x&amp;gt;&lt;/code&gt; to see where the mapping is coming from. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-09-16T19:00:38.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21212" PostTypeId="2" ParentId="21207" CreationDate="2019-09-16T19:24:33.820" Score="1" Body="&lt;h2&gt;Set &lt;code&gt;nocompatible&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;When you use a separate vimrc through the &lt;code&gt;-u&lt;/code&gt; command-line flag, the &lt;code&gt;nocompatible&lt;/code&gt; option will not be automatically set, as it is when using the normal user vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/starting.txt.html#compatible-default&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help compatible-default&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should either add &lt;code&gt;set nocompatible&lt;/code&gt; to the top of your alternative vimrc file, or pass Vim the &lt;a href=&quot;https://vimhelp.org/starting.txt.html#-N&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;-N&lt;/code&gt;&lt;/a&gt; command-line option in addition to &lt;code&gt;-u&lt;/code&gt; when using an alternative vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks &lt;a href=&quot;https://vi.stackexchange.com/users/343/rich&quot;&gt;@Rich&lt;/a&gt; for figuring out &lt;code&gt;nocompatible&lt;/code&gt; was likely the issue here, later confirmed by &lt;a href=&quot;https://vi.stackexchange.com/users/24842/aericura&quot;&gt;@Aericura&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Plug-ins &lt;em&gt;are&lt;/em&gt; loading, just not working&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Your listing of &lt;code&gt;:scriptnames&lt;/code&gt; shows that the UltiSnips plug-in &lt;em&gt;is&lt;/em&gt; being loaded. The fact that it isn't working for you seems to be unrelated to passing an alternative vimrc file through the &lt;code&gt;-u&lt;/code&gt; option, but probably due to some command from your original vimrc that's missing from your alternative vimrc and that you didn't realize was important to make UltiSnips work for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to do a few experiments, such as copying your original vimrc file (which is working) to a different name and passing that new file to the &lt;code&gt;-u&lt;/code&gt; flag. You should see that this configuration will be &lt;em&gt;working&lt;/em&gt;, same as your original vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another experiment is to make a back up copy of your original vimrc and deploy your alternative one in its place, as &lt;code&gt;~/.vimrc&lt;/code&gt; (assuming that's the path of your original vimrc file.) You should verify that this setup is also &lt;em&gt;not working&lt;/em&gt;, same as starting Vim with the alternate vimrc through the &lt;code&gt;-u&lt;/code&gt; flag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you check that this is indeed the case, then try to figure out what else is missing from your original vimrc to make UltiSnips work. You seem to be copying the global variables already, so that's probably not it... Do you perhaps have any key mappings to functions defined by UltiSnips that you're missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure you're in &lt;code&gt;nocompatible&lt;/code&gt; mode as well, maybe add &lt;code&gt;set nocompatible&lt;/code&gt; to the top of your alternative vimrc. Make sure you also enable filetype processing, with &lt;code&gt;filetype plugin indent on&lt;/code&gt;. (It's unlikely one of these is the cause of your issue, but it's worth mentioning since they're easy to try.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Sharing vim-plug configuration&lt;/h2&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Same plugins for every .vimrc file (vim-plug)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Answering your question from the title, having the same vim-plug stanza in every vimrc file should be enough to load the same plug-ins on Vim regardless of which .vimrc you're using, either the paths searched by default, or through the &lt;code&gt;-u&lt;/code&gt; command-line flag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to avoid repeating that information into multiple vimrc files, consider storing it on a separate file, such as &lt;code&gt;~/.vim/load-plugins.vim&lt;/code&gt; and loading it using &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Asource&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:source&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Asource&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:runtime&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you store it in the location above, then this command should be enough to load it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime load-plugins.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add the command above to all your vimrc alternatives, they will then share the same plug-ins and same plug-in configuration (assuming you also keep the configuration for the plug-ins in that same file.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Alternative: packages&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you're using Vim 8 or higher, or NeoVim, then consider using Vim &lt;em&gt;packages&lt;/em&gt; instead of a plug-in manager such as vim-plug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your plug-ins are loaded from a standard location under your &lt;code&gt;~/.vim&lt;/code&gt;, so you don't need any configuration in your &lt;code&gt;.vimrc&lt;/code&gt; to load the plug-ins, so that also solves that problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One difference between a plug-in manager such as vim-plug and native packages is that the former is able to install and update plug-ins for you (typically from Git repositories), while with packages it's on you to download them or &lt;code&gt;git clone&lt;/code&gt; them in the proper location and to update them there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vi.stackexchange.com/a/20980/18609&quot;&gt;this excellent answer&lt;/a&gt; with a description of packages and instructions on how to use them.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;There should be only one&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Finally, take a closer look at the reasons why you're using a separate vimrc. Are you using it to edit specific types of files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In many cases, you might be able to trigger the specific kind of behavior you're customizing by triggering it based on the type of file you're editing. (Or you can use other specific triggers to enable your custom behavior.) That should prevent the whole &quot;maintaining multiple vimrc files&quot; mess. It should also make it easier to reuse your customizations for a specific filetype in other situations, other machines (not really tied to your custom vimrc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're interested in this approach, I suggest you ask further questions here, detailing your particular use case and trigger, to get help into how you can refactor that into a set of filetype-specific customizations.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-09-18T12:21:18.643" LastActivityDate="2019-09-18T12:21:18.643" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="21213" PostTypeId="1" AcceptedAnswerId="21215" CreationDate="2019-09-16T19:27:27.133" Score="0" ViewCount="302" Body="&lt;p&gt;I put key mapping like this &lt;code&gt;nnoremap &amp;lt;space&amp;gt;d &quot;_d&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;, so I can delete text more comfortable. But when I in visual mode or visual block mode, the cursor will advance one more column, and delete more than I wanted.&lt;br&gt;&#xA; I know I can change &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; to other key, like &lt;code&gt;&amp;lt;alt&amp;gt;&lt;/code&gt;, and it works fine. But &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; is the most easily to pressed, I still want to use it. Is there any way to solve this problem? Thank you.&lt;/p&gt;&#xA;" OwnerUserId="23584" LastActivityDate="2019-09-17T06:02:44.110" Title="Using &lt;space&gt; as prefix key in normal mode, cursor will advance one character itself" Tags="|key-bindings|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21214" PostTypeId="2" ParentId="21208" CreationDate="2019-09-16T20:39:18.360" Score="1" Body="&lt;p&gt;You seem to be under the impression that &quot;exec&quot; is used to execute external shell commands, but that's not the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:execute&lt;/code&gt;&lt;/a&gt; command is simply used to run a Vimscript from a string, and this is used in this case to assemble a shell command-line from a string, to include arguments for the contents of the current line and also the path to the &lt;code&gt;figures/&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then this is being passed to a &lt;code&gt;:.!&lt;/code&gt; command, which runs the external command on a shell, passing the current line through the standard input, and then replacing the current line with the output produced by the external command. (See &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Arange%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :range!&lt;/code&gt;&lt;/a&gt;, where &lt;code&gt;.&lt;/code&gt; is being used as a range for the current line.)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;However, I want to include the &lt;code&gt;inkscape-figures watch&lt;/code&gt; command to be executed when I press CTRL+F in insert mode.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can similarly use that as a filter, or use the &lt;a href=&quot;https://vimhelp.org/insert.txt.html#%3Ar%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:r!&lt;/code&gt;&lt;/a&gt; command to simply read the output of the external command, without any input, and pasting it below the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r!inkscape-figures watch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If that's what you want, you can map that to the Ctrl-F combination in insert mode using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-f&amp;gt; &amp;lt;Esc&amp;gt;:r!inkscape-figures watch&amp;lt;CR&amp;gt;o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems you actually want to execute &lt;em&gt;both&lt;/em&gt; commands with the Ctrl-F keypress. You can surely do that, either use the two commands in sequence with &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in between them, or execute both commands in a single shell separating them with &lt;code&gt;;&lt;/code&gt; or perhaps &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; (i.e. anything you can do on a shell.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We'd need more details about what &lt;em&gt;exactly&lt;/em&gt; you want to be able to give you a more detailed and complete answer, but hopefully this addresses your point about &quot;exec&quot; and gives you enough pointers to be able to come up with a useful mapping on your own.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-16T20:39:18.360" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21215" PostTypeId="2" ParentId="21213" CreationDate="2019-09-16T20:41:11.683" Score="1" Body="&lt;p&gt;Just add the same mapping in Visual mode as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;space&amp;gt;d &quot;_d&#xA;xnoremap &amp;lt;space&amp;gt;d &quot;_d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use a simple &lt;code&gt;noremap&lt;/code&gt;, which maps in Normal, Visual and Selection mode, just in that case you might want to undo the mapping in Selection mode (which is probably inappropriate for that mode):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;space&amp;gt;d &quot;_d&#xA;sunmap &amp;lt;space&amp;gt;d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-09-17T06:02:44.110" LastActivityDate="2019-09-17T06:02:44.110" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21216" PostTypeId="2" ParentId="21205" CreationDate="2019-09-17T14:12:13.970" Score="1" Body="&lt;p&gt;Netrw already includes &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/autoload/netrw.vim#L4156&quot; rel=&quot;nofollow noreferrer&quot;&gt;code that attempts to reuse buffers&lt;/a&gt; but, as you have discovered, this code currently appears not to handle tree listings and ends up creating many buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the first thing to try is to make sure you are using the latest version of netrw. It looks like the code has changed as recently as July 2019, so it's possible this is something that has been fixed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that fails, however, and presuming you're not planning on altering the netrw plugin itself, your options include:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Stop using &lt;code&gt;g:netrw_liststyle = 3&lt;/code&gt;. In netrw's other list styles the buffers are named simply after the directory they display, and far fewer of them are created.&lt;/li&gt;&#xA;&lt;li&gt;Stop using &lt;em&gt;netrw&lt;/em&gt;. It's possible that &lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDTree&lt;/a&gt; or &lt;a href=&quot;https://github.com/justinmk/vim-dirvish/&quot; rel=&quot;nofollow noreferrer&quot;&gt;dirvish&lt;/a&gt; (which doesn't currently support tree views, but &lt;a href=&quot;https://github.com/justinmk/vim-dirvish/issues/70#issuecomment-273187435&quot; rel=&quot;nofollow noreferrer&quot;&gt;has them on the roadmap&lt;/a&gt;) don't exhibit this issue.&lt;/li&gt;&#xA;&lt;li&gt;Note that the buffers aren't listed in &lt;code&gt;ls&lt;/code&gt;, so if you can refrain from using the &lt;code&gt;:ls!&lt;/code&gt; version of the command maybe you can kid yourself that they don't exist at all.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If option 3. is unpalatable, perhaps you can live with the fact that the buffers are &lt;em&gt;created&lt;/em&gt;, but &lt;a href=&quot;https://github.com/tpope/vim-vinegar/issues/13&quot; rel=&quot;nofollow noreferrer&quot;&gt;get them to remove themselves when they are hidden&lt;/a&gt;. This should be as simple as setting &lt;code&gt;bufhidden=wipe&lt;/code&gt; for each netrw buffer with a simple &lt;code&gt;autocmd FileType&lt;/code&gt; (as suggested on the linked page), but at least on my machine, &lt;code&gt;netrw&lt;/code&gt; itself overwrites &lt;code&gt;bufhidden&lt;/code&gt;, so some shenanigans may be required. This code worked for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! WipeBuffer(name, id)&#xA;  let buffer_number = bufnr(a:name)&#xA;  execute 'bwipeout' buffer_number&#xA;endfunction&#xA;&#xA;augroup WipeNetrw&#xA;  autocmd!&#xA;  autocmd BufHidden * if &amp;amp;ft == 'netrw' | call timer_start(100, function('WipeBuffer', [expand('&amp;lt;afile&amp;gt;')])) | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-09-17T14:12:13.970" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21217" PostTypeId="2" ParentId="21186" CreationDate="2019-09-17T14:46:14.070" Score="2" Body="&lt;p&gt;I don't think &lt;code&gt;--remote&lt;/code&gt; is the issue here. I can reproduce what you observed with a normal vim instance and the &lt;code&gt;args&lt;/code&gt; command (e.g. &lt;code&gt;args a.c a.h b.h b.c&lt;/code&gt; then &lt;code&gt;args&lt;/code&gt; will show he two &lt;code&gt;.h&lt;/code&gt; files at the end).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I went through the code a bit last night (disclaimer: it's been years since I used C with any regularity) and it looks like &lt;code&gt;expand_wildcards()&lt;/code&gt; followed by &lt;code&gt;gen_expand_wildcards()&lt;/code&gt; are called from &lt;code&gt;do_arglist()&lt;/code&gt; for any &lt;code&gt;args &amp;lt;filelist&amp;gt;&lt;/code&gt; command. That is, when setting/overwriting the &lt;code&gt;args&lt;/code&gt; values (versus appending) and regardless of whether wildcards are present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So we get to &lt;code&gt;gen_expand_wildcards()&lt;/code&gt; which is summarized in the function comment which includes this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If there are no wildcards: Add the file name if it exists or when EW_NOTFOUND is given.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well, &lt;code&gt;EW_NOTFOUND&lt;/code&gt; is passed in from &lt;code&gt;do_arglist()&lt;/code&gt; so that accounts for this happening with files that have yet to be created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Okay so &lt;code&gt;gen_expand_wildcards()&lt;/code&gt; returns the original file list we specified to &lt;code&gt;expand_wildcards()&lt;/code&gt;. That's where we find the culprit: the code under this comment is executed unconditionally:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Move the names where 'suffixes' match to the end.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As Jürgen Krämer correctly surmised in his comment the root cause is related to an apparently undocumented application of the value in &lt;code&gt;'suffixes'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a bug? Probably only against the documentation as the code suggests the intent was always to do what is currently being done. The good news is you can work around the behavior if you'd like by modifying (temporarily) the value of &lt;code&gt;'suffixes'&lt;/code&gt;...&lt;code&gt;set suffixes-=.h&lt;/code&gt; for instance.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-09-17T15:41:46.117" LastActivityDate="2019-09-17T15:41:46.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21218" PostTypeId="1" AcceptedAnswerId="21221" CreationDate="2019-09-17T15:07:06.537" Score="2" ViewCount="286" Body="&lt;p&gt;When I write markdown and want to insert an image, i_CTRL-X_CTRL-F comes in handy. I know that I can filter by typing a few characters that precede the filename, but actually what I want is either type &lt;code&gt;*.jpg&lt;/code&gt; and see the completion list filter on jpegs or have an option to filter the completion list once it is open on &lt;code&gt;*.jpg&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I improve my local file selection workflow, preferably without a plugin?&lt;/p&gt;&#xA;" OwnerUserId="11633" LastActivityDate="2019-09-18T11:08:54.500" Title="Filter file completion list" Tags="|ins-completion|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21219" PostTypeId="1" CreationDate="2019-09-17T16:52:24.613" Score="5" ViewCount="320" Body="&lt;p&gt;I'm using Vim 8.1 from homebrew on MacOs 10.14.6. Whenever I exit vim back to the terminal, the first keypress in the terminal afterward results in a beachball and CPU spike to 100%, with terminal listed as &quot;not responding&quot; in Activity Monitor. The spike lasts for 5 to 25 seconds, then the terminal is fine until the next time I exit vim. vim is the only thing that seems to be causing this, so far. This behavior is recent -- this same configuration had been working fine before -- although I have updated vim from homebrew in an attempt to fix the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if there's a network issue somewhere (I'm behind a corporate firewall where the admins change the rules occasionally), or some other interaction betweeen vim and terminal that I'm not accounting for.&lt;/p&gt;&#xA;" OwnerUserId="24868" LastActivityDate="2019-12-13T00:46:25.180" Title="MacOS Terminal CPU spike after exiting Vim" Tags="|terminal|macos|performance|" AnswerCount="0" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="21220" PostTypeId="1" CreationDate="2019-09-17T18:21:47.593" Score="2" ViewCount="620" Body="&lt;p&gt;I am taking an OS class and we have an upcoming assignment involving Kernel modules.&#xA;I'm reading Wiley OS text to prepare and they have the below code.&#xA;I keep on getting an error that the header files are not found.&#xA;I'm using arch linux and I tried pacman -S linux-headers to install them so I know they are there.I also tried including direct path to init.h but the modules reference other modules from linux/.. directory.&#xA;How can solve this? I am thinking that maybe I have to edit the ycm_extra_conf.py file but I don't know what to do.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;linux/init.h&amp;gt;&#xA;#include &amp;lt;linux/kernel.h&amp;gt;&#xA;#include &amp;lt;linux/module.h&amp;gt;&#xA;&#xA;/* This function is called when the module is loaded. */&#xA;int simple init(void) {&#xA;    printk(KERN INFO &quot;Loading Kernel Module∖n&quot;);&#xA;    return 0;&#xA;}&#xA;&#xA;/* This function is called when the module is removed. */&#xA;void simple exit(void) {&#xA;    printk(KERN INFO &quot;Removing Kernel Module∖n&quot;);&#xA;}&#xA;&#xA;/* Macros for registering module entry and exit points. */&#xA;module init(simple init);&#xA;module exit(simple exit);&#xA;MODULE LICENSE(&quot;GPL&quot;);&#xA;MODULE DESCRIPTION(&quot;Simple Module&quot;);&#xA;MODULE AUTHOR(&quot;SGG&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24871" LastEditorUserId="10604" LastEditDate="2019-09-18T15:48:57.807" LastActivityDate="2019-09-18T15:48:57.807" Title="How to get YouCompleteme to work with kernel headers" Tags="|autocompletion|plugin-you-complete-me|linux-arch|" AnswerCount="0" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21221" PostTypeId="2" ParentId="21218" CreationDate="2019-09-17T19:09:39.207" Score="5" Body="&lt;p&gt;The relevant example with explanations can be found under &lt;code&gt;:h complete()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyCompleteFileName()&#xA;    &quot; match a (potential) wildcard preceding cursor position&#xA;    &quot; note: \f is a filename character, see :h 'isfname'&#xA;    let l:pattern = matchstr(strpart(getline('.'), 0, col('.') - 1), '\v(\f|\*|\?)*$')&#xA;    &quot; set the matches&#xA;    call complete(col('.') - len(l:pattern), getcompletion(l:pattern, &quot;file&quot;))&#xA;    &quot; must return an empty string to show the menu&#xA;    return ''&#xA;endfunction&#xA;&#xA;&quot; rebind &amp;lt;C-X&amp;gt;&amp;lt;C-F&amp;gt; to invoke our custom function&#xA;inoremap &amp;lt;C-X&amp;gt;&amp;lt;C-F&amp;gt; &amp;lt;C-R&amp;gt;=MyCompleteFileName()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-09-18T11:08:54.500" LastActivityDate="2019-09-18T11:08:54.500" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21222" PostTypeId="1" CreationDate="2019-09-18T00:55:15.027" Score="10" ViewCount="1719" Body="&lt;p&gt;There a number of types of plugins use the Vim gutter to display Git status, syntax correctness, linting and code formatting. But how can conflicts be managed when multiple plugins want to update the gutter on the same line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm attempting to use ALE to show eslint errors with NeoVim 0.4.0. I believe I had it working before but now it's not. However, I can see that my git gutter plugin is working fine and I suspect some kind of conflict between plugins updating the gutter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read once about some &quot;gutter manager&quot; plugin that could coordinate all the potential gutter updates, but now I can't a reference to it.  Is there a single plugin that can handle all the common uses of the gutter, including managing conflicts?&lt;/p&gt;&#xA;" OwnerUserId="6094" LastActivityDate="2020-06-15T19:30:10.287" Title="How to break-up gutter fights?" Tags="|neovim|git|plugin-fugitive|plugin-ale|eslint|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21223" PostTypeId="2" ParentId="17984" CreationDate="2019-09-18T04:08:35.597" Score="1" Body="&lt;p&gt;I don't know how to clear the previous texts but if you have problem with scrolling back to the last command after executing it you can go to text mood by pressing &lt;code&gt;ctrl + W&lt;/code&gt; &lt;code&gt;N&lt;/code&gt; and set mark by pressing &lt;code&gt;m&lt;/code&gt; &lt;code&gt;&amp;lt;any key on the keyboard&amp;gt;&lt;/code&gt; press &lt;code&gt;i&lt;/code&gt; to comeback to interactive mode and and execute your command and when you finished again go back to text mode by pressing &lt;code&gt;ctrl + W&lt;/code&gt; &lt;code&gt;N&lt;/code&gt; and go to the previously marked place by pressing &lt;code&gt;'&lt;/code&gt; &lt;code&gt;&amp;lt;that key you have pressed before&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="24873" LastActivityDate="2019-09-18T04:08:35.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21224" PostTypeId="2" ParentId="10817" CreationDate="2019-09-18T05:46:26.527" Score="5" Body="&lt;p&gt;Another option is to install &lt;a href=&quot;https://docs.brew.sh/Homebrew-on-Linux&quot; rel=&quot;nofollow noreferrer&quot;&gt;Homebrew on Linux&lt;/a&gt; as an alternate package manager and use it to install the latest vim with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;brew install vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Homebrew Features:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can install software to your home directory and so does not require sudo&lt;/li&gt;&#xA;&lt;li&gt;The repositories are generally newest version&lt;/li&gt;&#xA;&lt;li&gt;Install software not packaged by your host distribution&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Install up-to-date versions of software when your host distribution is old&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use the same package manager to manage your macOS, Linux, and Windows systems&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19983" LastEditorUserId="51" LastEditDate="2019-12-14T06:08:49.457" LastActivityDate="2019-12-14T06:08:49.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21225" PostTypeId="1" CreationDate="2019-09-19T06:50:22.417" Score="1" ViewCount="334" Body="&lt;p&gt;I am trying to replace the entire buffer with the output from an external command. Similar to &lt;code&gt;:% !myprog&lt;/code&gt;, but only if the command succeeds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let output = system('myprog')&#xA;if v:shell_error == 0&#xA;    &quot; What to do here?&#xA;    &quot; How to replace entire buffer with the contents of output?&#xA;    &quot; How to achieve exactly the same effect as ':% !myprog'?&#xA;else&#xA;    echoerr 'Command failed! Error message: ' . out&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To replace the entire buffer with the contents of the &lt;code&gt;output&lt;/code&gt; variable, I tried &lt;code&gt;:1,$d | put =output&lt;/code&gt;, but this is subtly different from the effect of &lt;code&gt;% !myprog&lt;/code&gt;. Among other things, &lt;code&gt;:1,$d | put =output&lt;/code&gt; inserts an unwanted newline, and the cursor position is different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for a way to replace the entire buffer with the contents of a variable in exactly the same way that &lt;code&gt;:% !myprog&lt;/code&gt; replaces the entire buffer with the output of an external command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I managed to achieve the desired effect using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1,$d          &quot; Delete contents of entire buffer.&#xA;0put =output  &quot; Insert contents of variable without extra newline at the beginning.&#xA;$d            &quot; Remove the extra newline at the end of the file.&#xA;call setpos('.', [0, 1, 1, 0])  &quot; Move cursor to first line, first column.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This looks like a hack. Is there a better way?&lt;/p&gt;&#xA;" OwnerUserId="19712" LastEditorUserId="19712" LastEditDate="2019-09-19T07:04:56.923" LastActivityDate="2019-09-19T10:37:51.000" Title="How to replace entire buffer with the contents of a variable?" Tags="|buffers|replace|external-command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21226" PostTypeId="2" ParentId="21225" CreationDate="2019-09-19T10:37:51.000" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a better way?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In Vim there are always &lt;em&gt;too&lt;/em&gt; many ways. I'd do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; get result as List&#xA;let output = systemlist('myprog')&#xA;if v:shell_error&#xA;    echoerr 'Command failed! Error message:' output[0]&#xA;else&#xA;    &quot; add output on top&#xA;    call append(0, output)&#xA;    &quot; delete the rest&#xA;    call deletebufline(&quot;%&quot;, len(output) + 1, &quot;$&quot;)&#xA;    &quot; go to first line, first column&#xA;    1&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-09-19T10:37:51.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21227" PostTypeId="1" AcceptedAnswerId="21239" CreationDate="2019-09-19T12:17:17.597" Score="1" ViewCount="1362" Body="&lt;p&gt;I'm trying to configure the &lt;code&gt;highlight&lt;/code&gt; to highlight keywords of my C++ project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the content of &lt;code&gt;~/.vim/syntax/cpp.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match    cCustomParen    &quot;?=(&quot; contains=cParen,cCppParen&#xA;syn match    cCustomFunc     &quot;\w\+\s*(\@=&quot; contains=cCustomParen&#xA;&#xA;hi CustomFunc guifg=NONE guibg=NONE guisp=NONE gui=bold ctermfg=lightyellow ctermbg=NONE cterm=bold    &#xA;hi def link cCustomFunc CustomFunc&#xA;&#xA;syn match cCustomClassName &quot;(?&amp;lt;=^class\s)\w\+&quot;&#xA;hi def link cCustomClassName CustomFunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a word, here I'm trying to highlight the function name and the class name. However, the function name is highlighted but the class name isn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zL5xE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zL5xE.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you see, the function names, such as &lt;code&gt;func&lt;/code&gt;, &lt;code&gt;size&lt;/code&gt;, have been highlighted by the color &lt;code&gt;lightyellow&lt;/code&gt;, but the class names, such as &lt;code&gt;Test&lt;/code&gt;, &lt;code&gt;Test2&lt;/code&gt; are still white.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I highlight the class name? My &lt;code&gt;cCustomCLassName&lt;/code&gt; is not correct?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2019-09-20T02:14:34.360" LastActivityDate="2019-09-20T09:50:01.103" Title="How to highlight class name of c++" Tags="|syntax-highlighting|highlight|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21228" PostTypeId="2" ParentId="21227" CreationDate="2019-09-19T12:55:46.763" Score="0" Body="&lt;p&gt;One &quot;simple&quot; (read &quot;low-tech&quot;) solution is to analyse your project with (universal-)ctags, extract only the class names and assign them a highlight group in all buffers. Unfortunately, this is not that simple to do that efficiently because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a new class has to be propagated to all buffers already opened, and all buffers yet to be opened (when they are opened)&lt;/li&gt;&#xA;&lt;li&gt;it'll be best to not add again the class names already highlighted&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In my lh-tags plugin I was planning to have such an option, but given the complexity to do it right, the low need I have of the feature I've just opened &lt;a href=&quot;https://github.com/LucHermitte/lh-tags/issues/4&quot; rel=&quot;nofollow noreferrer&quot;&gt;an issue&lt;/a&gt; for the day I have the time and the motivation.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2019-09-19T12:55:46.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21229" PostTypeId="2" ParentId="21222" CreationDate="2019-09-19T15:09:31.447" Score="2" Body="&lt;p&gt;Here's the answer I found for Neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, Neovim will display up to nine signs in the gutter by default, so plugins don't have to fight over sharing just one or two columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, &lt;a href=&quot;https://github.com/neovim/neovim/issues/990#issuecomment-533163057&quot; rel=&quot;nofollow noreferrer&quot;&gt;there is sign-id metadata associated with each sign so Neovim can tell which plugin the sign belongs to&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, a &lt;a href=&quot;https://github.com/neovim/neovim/pull/9295#issuecomment-445724214&quot; rel=&quot;nofollow noreferrer&quot;&gt;signpriority option has been proposed&lt;/a&gt;. This would contain something like an array of plugin names which specify which signs should get priority if there is not enough space to save this all-- in other words it lets you determine who wins the gutter fight!&lt;/p&gt;&#xA;" OwnerUserId="6094" LastActivityDate="2019-09-19T15:09:31.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21230" PostTypeId="1" CreationDate="2019-09-19T18:12:48.443" Score="3" ViewCount="344" Body="&lt;p&gt;This might rustle some feathers, but I do not like how vim's regular expression syntax differs from standard regex syntax (I've read &lt;a href=&quot;https://vi.stackexchange.com/questions/2268/are-vims-regex-magics-compatible-with-well-known-regex-classes&quot;&gt;this answer&lt;/a&gt;, but I don't think this is worth remember two syntaxes for).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an option or a plugin to use standard (i.e., Perl) regex syntax instead of the vim specific one?&lt;/p&gt;&#xA;" OwnerUserId="24897" LastEditorUserId="24897" LastEditDate="2019-09-20T18:04:03.053" LastActivityDate="2019-09-20T18:04:03.053" Title="Change to standard regex syntax?" Tags="|regular-expression|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21231" PostTypeId="2" ParentId="21230" CreationDate="2019-09-19T18:24:32.903" Score="3" Body="&lt;p&gt;I haven't used it, so I can't vouch for how good it is. But after a bit of searching I found &lt;a href=&quot;https://github.com/othree/eregex.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;othree/eregex.vim&lt;/a&gt; (&lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=3282&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim.org link&lt;/a&gt;), which is a plugin to enable Perl flavor regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will &lt;em&gt;not&lt;/em&gt; change the behavior of regex in vimscript, so if you want to use Perl flavor regex for things like highlighting groups, string comparisons, etc. you're out of luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it will remap the behavior of &lt;kbd&gt;/&lt;/kbd&gt; and &lt;kbd&gt;?&lt;/kbd&gt;, and allow you to do Perl flavor substitutions with &lt;code&gt;:%S&lt;/code&gt; instead of &lt;code&gt;:%s&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-09-19T18:24:32.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21232" PostTypeId="2" ParentId="21127" CreationDate="2019-09-19T21:26:55.187" Score="1" Body="&lt;p&gt;I am on macOS with neovim. &#xA;I will just provide my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('g:GuiLoaded')&#xA;    nmap &amp;lt;leader&amp;gt;rv :!osascript -e 'tell application &quot;Terminal&quot; to do script &quot;sh /users/eyalkarni/vimpy3/vimqt.sh&quot;'&amp;lt;CR&amp;gt;&#xA;else&#xA;    nmap &amp;lt;leader&amp;gt;rv :!osascript -e 'tell application &quot;Terminal&quot; to do script &quot;sh /users/eyalkarni/vimpy3/vimr.sh&quot;'&amp;lt;CR&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g:GuiLoaded&lt;/code&gt; signals neovim-qt. I assume it is VimR otherwise. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bash file is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;killall nvim-qt; open -a nvim-qt; exit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="26754" LastEditDate="2020-02-01T15:32:10.330" LastActivityDate="2020-02-01T15:32:10.330" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21233" PostTypeId="1" AcceptedAnswerId="21235" CreationDate="2019-09-19T22:25:03.417" Score="2" ViewCount="81" Body="&lt;p&gt;I've read &lt;a href=&quot;https://vi.stackexchange.com/questions/9656/how-does-p-command-work-in-vim&quot;&gt;this question and answer&lt;/a&gt; already, however it could not solve my doubts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as my understanding is correct, &lt;code&gt;p&lt;/code&gt; always has the same effect (&lt;code&gt;p&lt;/code&gt;utting the content of a register, by default the &lt;code&gt;&quot;&lt;/code&gt; register).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Different effects of the &lt;code&gt;p&lt;/code&gt; command are actually a consequence of different contents of the register(s) that we put. In this respect, given the sample text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-----------&#xA;---moree---&#xA;---lines---&#xA;---oftxt---&#xA;-----------&#xA;moree---&#xA;---l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I notice the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt;anking/&lt;code&gt;d&lt;/code&gt;eleting character-wise &lt;code&gt;more&lt;/code&gt; into a register fills the register with &lt;code&gt;more&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt;anking/&lt;code&gt;d&lt;/code&gt;eleting line-wise &lt;code&gt;---moree---&lt;/code&gt; into a register fills the register with &lt;code&gt;---more---^J&lt;/code&gt;, where &lt;code&gt;^J&lt;/code&gt; is a single caracter representing the linefeed &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt;anking/&lt;code&gt;d&lt;/code&gt;eleting block-wise the alphabetic rectangle fills the register with &lt;code&gt;moree^Jlines^Joftxt&lt;/code&gt;, where &lt;code&gt;^J&lt;/code&gt; has the same meaning as above.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;However:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Concerning 2 as compared to 1 and 3, how can something (&lt;code&gt;^J&lt;/code&gt;) &lt;strong&gt;later&lt;/strong&gt; in the register affect where the &lt;code&gt;p&lt;/code&gt;utting action &lt;strong&gt;starts&lt;/strong&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Concerning 1 and 2 as compared to 3,&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt;anking a &lt;code&gt;v&lt;/code&gt;isual selection going from the first &lt;code&gt;m&lt;/code&gt; to the first &lt;code&gt;l&lt;/code&gt; will fill the register with &lt;code&gt;moree---^J---l&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;y&lt;/code&gt;anking a block &lt;code&gt;CTRL-V&lt;/code&gt;isual selection of the last two lines (obtained by &lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;CTRL-V&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;) fills the register exactly with the same content &lt;code&gt;moree---^J---l&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;however putting the two registers will have a different effect.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Can someone please help me understand this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides, is it possible to get &lt;code&gt;^J&lt;/code&gt; in text just as can get &lt;code&gt;^M&lt;/code&gt; in text by &lt;kbd&gt;CTRL-V&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;, &lt;code&gt;^[&lt;/code&gt; by &lt;kbd&gt;CTRL-V&lt;/kbd&gt;&lt;kbd&gt;Escape&lt;/kbd&gt; and so on?&lt;/p&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="1238" LastEditDate="2019-12-16T19:20:26.410" LastActivityDate="2019-12-16T19:20:26.410" Title="How does p really works as related to content put in registers?" Tags="|cut-copy-paste|register|visual-block|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21234" PostTypeId="1" CreationDate="2019-09-20T04:11:29.250" Score="2" ViewCount="638" Body="&lt;p&gt;I am using a Windows 10, 64 bit machine, with gvim 8.1.1 installed (See screenshots below). I am using Vi version 8.1 which was installed as part of my git bash - version 4.4.23.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have never installed plugins for vi/gvim and am starting out by trying to install the typescript syntax highlighting plugin that is available here - &lt;a href=&quot;https://github.com/leafgarland/typescript-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/leafgarland/typescript-vim&lt;/a&gt; . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After following the instructions to install the plugin (running the git clone command on the front page), I can see that Vi has syntax highlighting for typescript. But gvim still doesn't. I can see the plugin files in my directory. What else do I need to do to make sure my Vi plugins are also functional in gvim? Or is this not possible? Do I need to install gvim plugins separately from Vi plugins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Psyhp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Psyhp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/6noND.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6noND.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4liP9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4liP9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Isp6W.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Isp6W.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/pIHpl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pIHpl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/IUUcC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IUUcC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12279" LastActivityDate="2019-09-20T06:07:07.260" Title="Plugins working in vi but not gvim" Tags="|gvim|plugin-system|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21235" PostTypeId="2" ParentId="21233" CreationDate="2019-09-20T04:58:53.723" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;As far as my understanding is correct, p always has the same effect (pasting the content of a buffer, by default the &quot; buffer).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In Vim they say &quot;putting&quot;, not &quot;pasting&quot;. And what is more important, that particular &quot;thing&quot; is called &quot;a register&quot;, so to find a relevant help topic you should type: &lt;code&gt;:h registers&lt;/code&gt;, not &lt;code&gt;:h buffers&lt;/code&gt; (which will lead you to a totally different place).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another (more subtle) point is that although the documentation says &quot;unnamed register&quot;, but, in fact, &lt;code&gt;&quot;&lt;/code&gt; is &lt;em&gt;a pointer to the last register used&lt;/em&gt;. So, for example, after the &lt;code&gt;yank&lt;/code&gt; command (without explicit register override) &lt;code&gt;&quot;&lt;/code&gt; points to a register named &lt;code&gt;0&lt;/code&gt;, and after &lt;code&gt;delete&lt;/code&gt; it points to the register &lt;code&gt;1&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;however pasting the two registers will have a different effect.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's easy. Besides &quot;contents&quot; all registers also have &quot;type&quot; which is normally deduced automatically. In your case &lt;code&gt;:echo getregtype('&quot;')&lt;/code&gt; will print different values, and so &lt;code&gt;p&lt;/code&gt; will behave differently too.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-09-20T04:58:53.723" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21236" PostTypeId="2" ParentId="21234" CreationDate="2019-09-20T05:59:10.403" Score="1" Body="&lt;p&gt;So it appears you're using native Windows gvim (as expected), but the plugin was installed by msys/cygwin/WSL Vim. Windows and Unix builds use different set of config directories (see &lt;code&gt;:h 'rtp'&lt;/code&gt;), so they end up seeing the different sets of plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I use a symlink to resolve a similar issue:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Make directory symlink from &lt;code&gt;C:\Users\[username]\vimfiles&lt;/code&gt; to &lt;code&gt;X:\msys64\home\[user]\.vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Move &lt;code&gt;.vimrc&lt;/code&gt; to &lt;code&gt;.vim/vimrc&lt;/code&gt; (that's not strictly necessary, but IMO it makes sense to write the config once with a help of a few &lt;code&gt;if&lt;/code&gt;s ).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now both your Vims should see the same configuration (except &lt;code&gt;viminfo&lt;/code&gt; and &lt;code&gt;mksession&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-09-20T06:07:07.260" LastActivityDate="2019-09-20T06:07:07.260" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21237" PostTypeId="2" ParentId="5567" CreationDate="2019-09-20T07:37:24.110" Score="0" Body="&lt;p&gt;I had the same issue but got it to work by putting the &quot;colorscheme yourtheme&quot; line after I've called the plugins.&lt;/p&gt;&#xA;" OwnerUserId="24903" LastActivityDate="2019-09-20T07:37:24.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21238" PostTypeId="2" ParentId="6101" CreationDate="2019-09-20T09:33:42.003" Score="6" Body="&lt;p&gt;I would suggest an additional solution, to use ^ instead of 0 (so the line starts at the beginning of the first character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap il g_o^&#xA;onoremap il :normal vil&amp;lt;CR&amp;gt;&#xA;xnoremap al $o^&#xA;onoremap al :normal val&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way if we do &quot;change in line&quot; it will respect the indentation level.&lt;/p&gt;&#xA;" OwnerUserId="15345" LastActivityDate="2019-09-20T09:33:42.003" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21239" PostTypeId="2" ParentId="21227" CreationDate="2019-09-20T09:37:30.840" Score="0" Body="&lt;p&gt;&lt;code&gt;(?&amp;lt;=pattern)&lt;/code&gt; is PCRE syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim, you need to use &lt;code&gt;:help /\@&amp;lt;=&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match cCustomClassName &quot;\(^class\s\)\@&amp;lt;=\w\+&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;N.B. Your &lt;code&gt;cCustomParen&lt;/code&gt; and &lt;code&gt;cCustomFunc&lt;/code&gt; don't look right, either, but I don't know Perl syntax very well, so I'm not sure what you're trying to do there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, the way you're including this file in your config also doesn't look quite right. If you want to add your highlighting in addition to the existing highlighting included in Vim, you should put it in the location &lt;code&gt;~/.vim/after/syntax/cpp.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to &lt;em&gt;replace&lt;/em&gt; Vim's standard highlighting, then you need to set &lt;code&gt;b:current_syntax&lt;/code&gt; in your file in order to prevent Vim from loading its own file (which could overwrite some of your highlighting):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:current_syntax = 'cpp'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help mysyntaxfile-add&lt;/code&gt; and &lt;code&gt;:help mysyntaxfile-replace&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-20T09:50:01.103" LastActivityDate="2019-09-20T09:50:01.103" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21240" PostTypeId="1" CreationDate="2019-09-20T12:27:16.023" Score="2" ViewCount="178" Body="&lt;p&gt;I'm trying to highlight the keywords for my c++ project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I've done is to create a file here: &lt;code&gt;~/.vim/after/syntax/cpp.vim&lt;/code&gt; and put some custom configuration into it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, putting the lines as below can highlight the class name:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi CustomClassName guifg=NONE guibg=NONE guisp=NONE gui=bold ctermfg=lightgreen ctermbg=NONE cterm=bold&#xA;syn match cCustomClassName &quot;\(^class\s*\)\@&amp;lt;=\w\+&quot;&#xA;hi def link cCustomClassName CustomClassName&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this can only highlight the class name while the class declaration.&#xA; &lt;a href=&quot;https://i.stack.imgur.com/16XGz.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/16XGz.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you see, the &lt;code&gt;Test&lt;/code&gt; at the line 8 is highlighted whereas the next &lt;code&gt;Test&lt;/code&gt; at the line 9 isn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a word, I can set the highlight for the declaration class because I can use the regex to match the keyword &lt;code&gt;class&lt;/code&gt;. But the codes like the line 9 can't be matched by the regex. It seems that I should use some method to find the codes like the line 9 dynamically and highlight them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking if I can set an array to store all custom class name and highlight them but I don't know how to do it.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2019-09-20T12:27:16.023" Title="How to set syntax keywords dynamically" Tags="|syntax-highlighting|highlight|syntax|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21241" PostTypeId="5" CreationDate="2019-09-20T14:46:46.077" Score="0" Body="&lt;p&gt;Questions related to text manipulations to align text in different ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A list of some popular alignment plugins:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Align:&lt;br&gt;&#xA;&lt;a href=&quot;https://www.drchip.org/astronaut/vim/align.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.drchip.org/astronaut/vim/align.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim Easy Align:&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/junegunn/vim-easy-align&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/junegunn/vim-easy-align&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;/questions/tagged/plugin-easy-align&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;plugin-easy-align&amp;#39;&quot; rel=&quot;tag&quot;&gt;plugin-easy-align&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tabular:&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/godlygeek/tabular&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/godlygeek/tabular&lt;/a&gt;     &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;/questions/tagged/plugin-tabular&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;plugin-tabular&amp;#39;&quot; rel=&quot;tag&quot;&gt;plugin-tabular&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14302" LastEditorUserId="1841" LastEditDate="2019-09-23T17:21:34.483" LastActivityDate="2019-09-23T17:21:34.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21242" PostTypeId="4" CreationDate="2019-09-20T14:46:46.077" Score="0" Body="Alignment is the organization of content elements by tokens/symbols and/or by column or line locations." OwnerUserId="14302" LastEditorUserId="14302" LastEditDate="2019-09-28T11:10:33.830" LastActivityDate="2019-09-28T11:10:33.830" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21244" PostTypeId="1" AcceptedAnswerId="21249" CreationDate="2019-09-21T00:10:36.280" Score="2" ViewCount="963" Body="&lt;p&gt;I have the following code in my ini.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup HiParens&#xA;    autocmd!&#xA;    autocmd Syntax c :syn match Parens /[(){}]/&#xA;    autocmd Syntax c :syn match Bracks /[\[\]]/&#xA;augroup End&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And highlighting is done in ~/.config/nvim/after/ftplugin/c.vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Parens ctermfg=XXX&#xA;hi Bracks ctermfg=XXX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first match &lt;code&gt;/[(){}]/&lt;/code&gt; works as expected.&#xA;The second seem to do nothing. &#xA;Yet this is the way I understand the help page I am supposed to do this.&#xA;I found somewhere else here on SE a suggestion about doing exactly this escaping but can't find the link anymore. &#xA;I'm a bit surprised, for I would think such escaping would be pretty logical and I also don't get any Errors when loading a C file.&#xA;Does anybody know what I did wrong? Must be a stupid detail failure on my end...&lt;/p&gt;&#xA;" OwnerUserId="22764" LastActivityDate="2019-09-21T17:50:52.637" Title="I can't escape square brackets for syntax matching" Tags="|syntax-highlighting|neovim|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21246" PostTypeId="1" CreationDate="2019-09-21T08:46:49.047" Score="2" ViewCount="606" Body="&lt;p&gt;As example, my current buffer contains below lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;di=01;34&#xA;ln=01;36&#xA;mh=00&#xA;pi=40;33&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to join all lines with &lt;code&gt;:&lt;/code&gt;, and set entire buffer to the joined string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to achieve that, using &lt;code&gt;:python&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;py3 vim.current.buffer[:] = ':'.join(vim.current.buffer)&#xA;py3 vim.current.buffer = ':'.join(vim.current.buffer)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But neither works.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="10604" LastEditDate="2019-10-04T13:26:26.723" LastActivityDate="2023-08-20T15:40:43.023" Title="vim : how to set current buffer to a string using `:python`" Tags="|buffers|vimscript-python|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21247" PostTypeId="2" ParentId="21246" CreationDate="2019-09-21T11:57:36.463" Score="0" Body="&lt;p&gt;&lt;code&gt;vim.current.buffer&lt;/code&gt; refers to a buffer object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim.current.buffer[:]&lt;/code&gt; on the other hand, is a list of strings containing the content of the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can manipulate the lines of the buffer by retrieving and assigning to this list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;py3 vim.current.buffer[:] = [ ':'.join(vim.current.buffer[:]) ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2019-09-22T12:02:06.017" LastActivityDate="2019-09-22T12:02:06.017" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21248" PostTypeId="2" ParentId="21246" CreationDate="2019-09-21T12:38:09.563" Score="1" Body="&lt;p&gt;In vimscript, just as an alternative:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,$-1substitute/$/:&#xA;:global/^/join&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In one line with abbreviated commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,$-1s/$/:/ | g/^/j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-09-22T03:08:30.667" LastActivityDate="2019-09-22T03:08:30.667" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21249" PostTypeId="2" ParentId="21244" CreationDate="2019-09-21T17:50:52.637" Score="2" Body="&lt;p&gt;It works for me in Vim (8.1.2044).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I would recommend to create the file &lt;code&gt;~/.config/nvim/after/syntax/c.vim&lt;/code&gt; to extend the C highlighting.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match Parens /[(){}]/&#xA;syn match Bracks /[[\]]/&#xA;&#xA;hi Parens term=underline ctermfg=11 guifg=Yellow&#xA;hi Bracks term=underline ctermfg=11 guifg=Yellow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adjust &lt;code&gt;hi ...&lt;/code&gt; to your liking.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For working with syntax and highlighting I have the following in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command SynID  echo synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 1), &quot;name&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Move the cursor to the place you want to inspect (e.g. a bracket) and execute &lt;code&gt;:SynID&lt;/code&gt;. It will print the name of the syntax item under the cursor.&#xA;If it prints nothing, your &lt;code&gt;syntax match...&lt;/code&gt; does not work. If it prints the correct name, but is not higlighted, there is a problem with the &lt;code&gt;hi ...&lt;/code&gt; statement. If it prints a different name, you might want to look at &lt;code&gt;:help :syn-contains&lt;/code&gt;, &lt;code&gt;:help :syn-contained&lt;/code&gt; and &lt;code&gt;:help :syn-containedin&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-09-21T17:50:52.637" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21250" PostTypeId="2" ParentId="21246" CreationDate="2019-09-22T01:21:27.973" Score="0" Body="&lt;p&gt;As @Mass's answer said, to set buffer content, you cannot assign to the &lt;code&gt;buffer&#xA;object&lt;/code&gt; itself, you need to assign to the the sliced version, eg &lt;code&gt;vim.current.buffer[:]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently what's missing from there is, you &lt;strong&gt;need to use a list of string instead&#xA;of a string&lt;/strong&gt; to assign to a sliced buffer object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To summary&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# set first line to a string&#xA;py3 vim.current.buffer[0] = &quot;Hello world&quot;&#xA;# replace whole buffer with a string&#xA;py3 vim.current.buffer[:] = [&quot;a long long string&quot;]&#xA;# replace whole buffer with two lines&#xA;py3 vim.current.buffer[:] = [&quot;first line&quot;, &quot;second line&quot;]&#xA;# replace first 10 line with two lines&#xA;py3 vim.current.buffer[:10] = [&quot;first line&quot;, &quot;second line&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2019-09-22T01:21:27.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21251" PostTypeId="1" AcceptedAnswerId="21252" CreationDate="2019-09-22T04:17:54.827" Score="2" ViewCount="811" Body="&lt;p&gt;please be gentle, I am trying to learn neovim, coming from vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the command &lt;code&gt;:!top&lt;/code&gt; executed inside neovim returns&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;top: failed tty get&#xA;&#xA;shell returned 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After googling, only search results from &lt;code&gt;fzf&lt;/code&gt; github regarding kernel regression&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/junegunn/fzf/issues/1486&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/junegunn/fzf/issues/1486&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/junegunn/fzf/issues/447&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/junegunn/fzf/issues/447&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have never used &lt;code&gt;fzf&lt;/code&gt; in vim/linux before, I am also trying to use it later on in neovim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But trying out the command on &lt;code&gt;fzf&lt;/code&gt; (after installing it), from &lt;a href=&quot;https://github.com/junegunn/fzf/issues/1486&quot; rel=&quot;nofollow noreferrer&quot;&gt;1486&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;hello&quot; | fzf --preview 'echo {}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the terminal, it does not return any error. So I think the kernel regression issue is solved?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The OS I am using is Debian Buster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not using &lt;code&gt;:terminal&lt;/code&gt; or &lt;code&gt;Ctrl-Z&lt;/code&gt; to use shell commands in my vim workflow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find that the only way to use these programs is to use these two options in neovim, please let me know.&lt;/p&gt;&#xA;" OwnerUserId="17884" LastActivityDate="2019-09-22T13:38:10.443" Title="Neovim 0.17.5: bash command top failed tty get" Tags="|neovim|external-command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21252" PostTypeId="2" ParentId="21251" CreationDate="2019-09-22T13:38:10.443" Score="1" Body="&lt;p&gt;Have a look at &lt;code&gt;:help :!&lt;/code&gt;. It says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The command runs in a non-interactive shell connected&#xA;  to a pipe (not a terminal). Use :terminal to run an&#xA;  interactive shell connected to a terminal.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As &lt;code&gt;top&lt;/code&gt; requires a terminal, it can't be run this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:!top&lt;/code&gt; in Vim works as expected, so &lt;code&gt;:!&lt;/code&gt; seems to be implemented differently in neovim.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-09-22T13:38:10.443" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21253" PostTypeId="1" CreationDate="2019-09-22T14:44:20.753" Score="5" ViewCount="220" Body="&lt;p&gt;I use YouCompleteMe on vim and it works great for me on the files in my local machine. However, when I open files in a remote server, for example, using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e scp://user@remote//path/to/file.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;None of my YouCompleteMe based completion works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see that the above &lt;code&gt;scp&lt;/code&gt; command, copies the remote file to local disk, and copies it back to the remote location whenever I do &lt;code&gt;:w&lt;/code&gt;. And it is very weird to me that &lt;code&gt;YouCompleteMe&lt;/code&gt; has no completion suggestions!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do for the YouCompleteMe suggestions to start working again?&lt;/p&gt;&#xA;" OwnerUserId="24919" LastActivityDate="2019-09-27T17:21:06.493" Title="YouCompleteMe on remote files" Tags="|plugin-you-complete-me|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21254" PostTypeId="1" AcceptedAnswerId="21255" CreationDate="2019-09-22T15:04:01.287" Score="1" ViewCount="1057" Body="&lt;p&gt;I am trying to delete items from the quickfix list, using the same delete interface I am used to, visual delete and dd. The .vimrc code I am trying to use to accomplish this is below. It does not work. It skips every other line and moves the cursor several lines down probably related to how many lines were visually selected. dd works but visual selected is where it breaks down.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Delete()&#xA;    if &amp;amp;buftype == 'quickfix'&#xA;        call setqflist(filter(getqflist(), {idx -&amp;gt; idx != line('.') - 1}), 'r')&#xA;    else&#xA;        deletel&#xA;    endif&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; dd :call Delete()&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; d :call Delete()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23094" LastActivityDate="2019-09-22T18:52:08.820" Title="Visual delete items from quickfix list" Tags="|quickfix|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21255" PostTypeId="2" ParentId="21254" CreationDate="2019-09-22T17:49:56.777" Score="2" Body="&lt;p&gt;1) Use a function with range keyword (&lt;code&gt;:h func-range&lt;/code&gt;) for processing your visual selection. Moreover, that also allows for &lt;code&gt;[count]&lt;/code&gt; in Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Prefer buffer-local mappings whenever it makes sense.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; using range-aware function&#xA;function! QFdelete(bufnr) range&#xA;    &quot; get current qflist&#xA;    let l:qfl = getqflist()&#xA;    &quot; no need for filter() and such; just drop the items in range&#xA;    call remove(l:qfl, a:firstline - 1, a:lastline - 1)&#xA;    &quot; replace items in the current list, do not make a new copy of it;&#xA;    &quot; this also preserves the list title&#xA;    call setqflist([], 'r', {'items': l:qfl})&#xA;    &quot; restore current line&#xA;    call setpos('.', [a:bufnr, a:firstline, 1, 0])&#xA;endfunction&#xA;&#xA;&quot; using buffer-local mappings&#xA;&quot; note: still have to check &amp;amp;bt value to filter out `:e quickfix` and such&#xA;augroup QFList | au!&#xA;    autocmd BufWinEnter quickfix if &amp;amp;bt ==# 'quickfix'&#xA;    autocmd BufWinEnter quickfix    nnoremap &amp;lt;silent&amp;gt;&amp;lt;buffer&amp;gt;dd :call QFdelete(bufnr())&amp;lt;CR&amp;gt;&#xA;    autocmd BufWinEnter quickfix    vnoremap &amp;lt;silent&amp;gt;&amp;lt;buffer&amp;gt;d  :call QFdelete(bufnr())&amp;lt;CR&amp;gt;&#xA;    autocmd BufWinEnter quickfix endif&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-09-22T18:52:08.820" LastActivityDate="2019-09-22T18:52:08.820" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21256" PostTypeId="1" CreationDate="2019-09-23T03:58:13.863" Score="11" ViewCount="2535" Body="&lt;p&gt;I want to create a basic Vim script that simply deletes n lines, skips 1 line and repeats until the end of the document. I don't care about specific matches, I just want to delete the line. For example;&#xA;So I want to repeat the command &lt;code&gt;3ddj&lt;/code&gt; for the entire document.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Text I want to keep.   &#xA;Text I want to delete.  &#xA;Text I want to delete.  &#xA;Text I want to delete.  &#xA;Text I want to keep.  &#xA;Text I want to delete.  &#xA;Text I want to delete.  &#xA;Text I want to delete.  &#xA;Text I want to keep.  &#xA;Text I want to delete.  &#xA;Text I want to delete.  &#xA;Text I want to delete.   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it looks like...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Text I want to keep.  &#xA;Text I want to keep.  &#xA;Text I want to keep.  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="24927" LastEditorUserId="1841" LastEditDate="2019-09-23T10:36:42.210" LastActivityDate="2023-05-18T07:30:19.083" Title="Delete n lines skip 1 line script" Tags="|regular-expression|normal-mode|repeated-commands|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21257" PostTypeId="2" ParentId="21256" CreationDate="2019-09-23T04:39:58.003" Score="20" Body="&lt;p&gt;Very simple approach:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Move to the first line you want to delete.&lt;/li&gt;&#xA;&lt;li&gt;Record a macro: &lt;code&gt;qa3ddjq&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Repeat it with a high number: 1000@a&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Step three will repeat the macro a thousand times or until an error is encountered. &#xA;Hitting end of file (hence no lines to delete) produces an error and repetition of the macro is canceled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help recording&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-09-23T04:39:58.003" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21258" PostTypeId="2" ParentId="21256" CreationDate="2019-09-23T05:39:31.423" Score="3" Body="&lt;p&gt;An alternative (I suppose we start on the line 1, and delete the lines 2-4, 6-8 and so on, as per an example text):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while line(&quot;.&quot;) &amp;lt; line(&quot;$&quot;)&#xA;    silent +1delete _ 3&#xA;endwhile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If prefer doing this interactively, you can make use of the &quot;command-line register&quot;. That is, press&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:+1del 3&amp;lt;CR&amp;gt;&lt;/code&gt; and then &lt;code&gt;1000@:&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-09-23T05:39:31.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21259" PostTypeId="2" ParentId="21256" CreationDate="2019-09-23T10:41:56.677" Score="6" Body="&lt;p&gt;You have some great solutions already available. Here is another one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^/if line('.')%4!=1|:s/^/DELETE ME/|endif&#xA;:g/^DELETE ME/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First, we perform an action on every line (&lt;code&gt;:g&lt;/code&gt; matching against the &lt;code&gt;^&lt;/code&gt; (start of line)) and for every line number perform the result of &lt;code&gt;linenumber % 4&lt;/code&gt;. If the result is unequal to &lt;code&gt;1&lt;/code&gt;, we add &lt;code&gt;DELETE ME&lt;/code&gt; at the beginning of the line, marking the lines to be deleted by the next command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next command is a regular (&lt;code&gt;:g&lt;/code&gt;) command, that matches all lines that start with &lt;code&gt;DELETE ME&lt;/code&gt; and does so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, You cannot immediately delete the line using the first &lt;code&gt;:g&lt;/code&gt; command, since this would change the resulting modulo calculation and as such such, we have to first mark the lines and in a second step delete it.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-09-23T10:41:56.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21260" PostTypeId="1" CreationDate="2019-09-23T11:35:13.277" Score="5" ViewCount="6539" Body="&lt;p&gt;I have a terminal buffer with 10000 lines of previously executed output. In order to search for the particular sequence of words I have to go through all 10000 lines before getting to my last executed command's output. Which makes me so annoyed. Is the a way of clearing a terminal buffer without quiting the terminal and running it again (because I use ssh to remote server and it's painfull to execute all the commands all over again to establish the connection to it). &#xA;(settings scroll back to 0 or whatever won't do a trick)&lt;/p&gt;&#xA;" OwnerUserId="22010" LastActivityDate="2022-11-16T11:00:56.793" Title="How to clear neovim terminal buffer" Tags="|neovim|terminal|" AnswerCount="4" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21261" PostTypeId="2" ParentId="21260" CreationDate="2019-09-23T12:48:06.297" Score="1" Body="&lt;p&gt;Both &lt;code&gt;clear&lt;/code&gt; and &lt;code&gt;Ctrl+l&lt;/code&gt; work for me using Neovim and bash.&#xA;Would have asked you to try it in a comment before posting as an answer but I don't have enough rep.&lt;/p&gt;&#xA;" OwnerUserId="22764" LastActivityDate="2019-09-23T12:48:06.297" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21262" PostTypeId="1" CreationDate="2019-09-23T13:10:51.767" Score="1" ViewCount="601" Body="&lt;p&gt;How to ignore a specific error (E303 in this case) globally? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(don't display it in the console)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wish not to use try...catch if possible. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-09-23T13:10:51.767" Title="Ignore a specific error" Tags="|error|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21264" PostTypeId="1" AcceptedAnswerId="21265" CreationDate="2019-09-23T15:31:28.710" Score="1" ViewCount="150" Body="&lt;p&gt;I need to write a function that when executed it opens &lt;code&gt;colon&lt;/code&gt; command and paste some stuff on to it and let user edit it before executing the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EditRelativePath()&#xA;&#xA;  :e expand(&quot;%&quot;)&#xA;&#xA;endfunction&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so i'm expecting the above code to start a prompt like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e src/user/index.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it does not simply work, please advice, thanks.&lt;/p&gt;&#xA;" OwnerUserId="24931" LastActivityDate="2019-09-23T16:09:22.070" Title="How to get a function to print something to colon command and let user edit it?" Tags="|vimscript|functions|user-input|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21265" PostTypeId="2" ParentId="21264" CreationDate="2019-09-23T16:03:42.213" Score="3" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call feedkeys(':e ' . expand('%'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/eval.txt.html#feedkeys%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help feedkeys()&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-23T16:09:22.070" LastActivityDate="2019-09-23T16:09:22.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21266" PostTypeId="1" AcceptedAnswerId="21267" CreationDate="2019-09-23T16:06:16.897" Score="11" ViewCount="1766" Body="&lt;p&gt;One example would be in the List docs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:unlet list[3] &quot;idem&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24933" LastActivityDate="2019-09-23T16:16:30.110" Title="What does `idem` mean in the VIM docs?" Tags="|vimscript|help-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21267" PostTypeId="2" ParentId="21266" CreationDate="2019-09-23T16:12:54.223" Score="14" Body="&lt;p&gt;It's &lt;a href=&quot;https://en.wikipedia.org/wiki/Idem&quot; rel=&quot;noreferrer&quot;&gt;a latin term meaning &quot;the same&quot;&lt;/a&gt;. In the quoted context, it just means the listed command does the same thing as the previously listed command, i.e. &lt;code&gt;remove item 3&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i = remove(list, 3)    &quot; remove item 3  &#xA;:unlet list[3]              &quot; idem&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-09-23T16:12:54.223" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21268" PostTypeId="2" ParentId="21266" CreationDate="2019-09-23T16:16:30.110" Score="6" Body="&lt;p&gt;&lt;code&gt;:help list&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;:let i = remove(list, 3)            &quot; remove item 3&#xA;:unlet list[3]                      &quot; idem&#xA;:let l = remove(list, 3, -1)        &quot; remove items 3 to last item&#xA;:unlet list[3 : ]                   &quot; idem&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;idem&lt;/code&gt; is to say that that line of code does the same as the line above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This could be useful: &lt;a href=&quot;https://en.wiktionary.org/wiki/idem&quot; rel=&quot;noreferrer&quot;&gt;https://en.wiktionary.org/wiki/idem&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-09-23T16:16:30.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21270" PostTypeId="2" ParentId="21256" CreationDate="2019-09-23T17:16:58.360" Score="18" Body="&lt;p&gt;The easiest solution to me would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%norm j3dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;That is:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt;: for every line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;norm&lt;/code&gt;: run the following keys as if in normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j3dd&lt;/code&gt;: go down one line then delete 3 lines&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;So from the first line, go down to the second one and delete the next 3 lines. The second &lt;code&gt;Text I want to keep.&lt;/code&gt; is now on the second line. Go down one line, delete 3. Rinse and repeat.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Note: if you don't want to process the entire file you can replace the &lt;code&gt;%norm&lt;/code&gt; with e.g &lt;code&gt;5,$norm&lt;/code&gt; to process from the 5th line to the end of the file.&lt;/p&gt;&#xA;" OwnerUserId="683" LastEditorUserId="683" LastEditDate="2023-05-18T07:30:19.083" LastActivityDate="2023-05-18T07:30:19.083" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21271" PostTypeId="1" AcceptedAnswerId="21273" CreationDate="2019-09-23T21:21:42.567" Score="3" ViewCount="259" Body="&lt;p&gt;I am using the plugin vimtex. It offers the functionality (from the introduction of its documentation)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Text objects&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;code&gt;ic&lt;/code&gt; &lt;code&gt;ac&lt;/code&gt; Commands&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;id&lt;/code&gt; &lt;code&gt;ad&lt;/code&gt; Delimiters&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;ie&lt;/code&gt; &lt;code&gt;ae&lt;/code&gt; LaTeX environments&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;i$&lt;/code&gt; &lt;code&gt;a$&lt;/code&gt; Inline math structures&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;iP&lt;/code&gt; &lt;code&gt;aP&lt;/code&gt; Sections&lt;/li&gt;&#xA;  &lt;/ul&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This means that with &lt;code&gt;ci$&lt;/code&gt; I can delete everyithing between two &lt;code&gt;$&lt;/code&gt;-signs. I would like to remap this to &lt;code&gt;cim&lt;/code&gt;, because it is easier to type. However &lt;code&gt;nnoremap cim ci$&lt;/code&gt; has no effect. What can I do instead?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I notice that this has probably nothing to do with vimtex, but I don't know any other example to illustrate my issue.&lt;/p&gt;&#xA;" OwnerDisplayName="user17723" LastActivityDate="2020-05-21T11:15:20.397" Title="How to remap ci$" Tags="|key-bindings|plugin-vimtex|custom-text-object|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21272" PostTypeId="1" AcceptedAnswerId="21305" CreationDate="2019-09-24T00:52:52.383" Score="0" ViewCount="327" Body="&lt;p&gt;I do a lot of plain text file editing, and many times I need to mark a section of text as 'DO NOT FORMAT' as it is pre-formatted, or even contains ascii art.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many years ago I did this by marking the block as a comment, and telling vim NOT to format such blocks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example text...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Looking across the road, I could see a large&#xA;rectangular building with various shops underneath.&#xA;Across the top half of the building was a sign.&#xA;&#xA;|&#xA;|                        The Doctor's Folly&#xA;|              Discreet and confidential medical clinic&#xA;|                     First time checkups, FREE&#xA;|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want the uncommented text to be re-formatted using 'gq' (EG: during a whole file re-format 'gggqG' ) but have it completely ignore the marked section of text as it is already pre-formatted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current settings&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setl textwidth=79&#xA;:setl comments=b:\|&#xA;:setl formatoptions=tcorjq1l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I had it working YEARS ago, but vim has changed, and started to format&#xA;the commented text sections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking I may need a special purpose 'formatexpr' to get it to ignore the specially marked text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OR use a special macro to itterate over paragraphs, but only reformat the ones that are not marked with '|' as the first characte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either of these solutions would let me still reformat 'comment' bullet lists.&lt;/p&gt;&#xA;" OwnerUserId="23299" LastEditorUserId="23299" LastEditDate="2019-09-25T04:47:20.097" LastActivityDate="2019-09-26T02:22:04.207" Title="Vi formatting to ignore a section of text" Tags="|formatting|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21273" PostTypeId="2" ParentId="21271" CreationDate="2019-09-24T03:30:20.410" Score="4" Body="&lt;p&gt;Since &lt;code&gt;i$&lt;/code&gt; is a mapping itself (defined by the vimtex plug-in), you need a &lt;em&gt;recursive&lt;/em&gt; mapping to be able to use &lt;code&gt;i$&lt;/code&gt; as part of the expansion of your mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap cim ci$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But you can also create an operator-pending mode mapping for &lt;code&gt;im&lt;/code&gt;, in which case that would work with other operations such as &lt;code&gt;dim&lt;/code&gt; or &lt;code&gt;yim&lt;/code&gt; and other built-in or custom operations that take a motion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;omap im i$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If vimtex also defines &lt;code&gt;i$&lt;/code&gt; in Visual mode (which is a common pattern), you might want to create the mapping for your alias in Visual mode as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xmap im i$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, you may want to define these mappings only for &lt;code&gt;tex&lt;/code&gt; files, so consider adding these commands to &lt;code&gt;~/.vim/after/ftplugin/tex.vim&lt;/code&gt; (so it's loaded only for files with FileType &lt;code&gt;tex&lt;/code&gt;, and only after the vimtex plug-in has been loaded.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you want to use &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; to make your mappings local to your buffer, so they're loaded for buffers of that filetype and do not leak into other filetypes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;omap &amp;lt;buffer&amp;gt; im i$&#xA;xmap &amp;lt;buffer&amp;gt; im i$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, you might want to modify the &lt;code&gt;b:undo_ftplugin&lt;/code&gt; variable to remove these mappings if the filetype-related plug-in actions need to be undone. See &lt;code&gt;:help undo_ftplugin&lt;/code&gt; for more details on that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you simply want &lt;code&gt;im&lt;/code&gt; as an alias to &lt;code&gt;i$&lt;/code&gt; in all cases (assuming other plug-ins might have their own definition for &lt;code&gt;i$&lt;/code&gt;), then global mappings for it might be acceptable, they certainly work.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-24T03:30:20.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21274" PostTypeId="1" CreationDate="2019-09-24T03:53:52.830" Score="1" ViewCount="70" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/srRAl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/srRAl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim on WSL has some unknown colored blocks. The weird thing is it happens randomly and some colored blocks would disappear when I pass them using cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is my .vimrc settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;&#xA;set nocompatible&#xA;set showmode&#xA;set showcmd&#xA;set mouse=a&#xA;set encoding=utf-8&#xA;set t_Co=256&#xA;set nu&#xA;&#xA;set autoindent&#xA;set expandtab&#xA;set tabstop=4&#xA;set softtabstop=4&#xA;set cursorline&#xA;&#xA;set hlsearch&#xA;set showmatch&#xA;set ignorecase&#xA;set smartcase&#xA;&#xA;set noerrorbells&#xA;set visualbell&#xA;set autoread&#xA;&#xA;filetype indent on&#xA;&#xA;colorscheme molokai &#xA;&#xA;&quot; Press F5 to run python program&#xA;map &amp;lt;F5&amp;gt; : call CompileRunGcc()&amp;lt;CR&amp;gt;&#xA;func! CompileRunGcc()&#xA;        exex &quot;w&quot;&#xA;        if &amp;amp;filetype == 'c'&#xA;                exec &quot;!g++ % -o %&amp;lt;&quot;&#xA;                exec &quot;!time ./%&amp;lt;&quot;&#xA;        elseif &amp;amp;filetype =='python'&#xA;                exec &quot;!clear&quot;&#xA;                exec &quot;!time python3 %&quot;&#xA;        endif&#xA;endfunc&#xA;&#xA;set nocompatible              &quot; required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'gmarik/Vundle.vim'&#xA;&#xA;&quot; Add all your plugins here (note older versions of Vundle used Bundle instead of Plugin)&#xA;Plugin 'https://github.com/scrooloose/nerdtree'&#xA;nnoremap &amp;lt;F3&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;autocmd bufenter * if (winnr(&quot;$&quot;) == 1 &amp;amp;&amp;amp; exists(&quot;b:NERDTree&quot;) &amp;amp;&amp;amp; b:NERDTree.isTabTree()) | q | endif&#xA;&#xA;Plugin 'https://github.com/bling/vim-airline'&#xA;&#xA;&quot; Plugin 'w0rp/ale'&#xA;&quot; let g:ale_fix_on_save = 1&#xA;&quot; let g:ale_completion_enabled = 1&#xA;&quot; let g:ale_sign_column_always = 1&#xA;&quot; let g:airline#extensions#ale#enabled = 1&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24938" LastActivityDate="2019-09-24T03:53:52.830" Title="Vim unknown colored block" Tags="|vimrc|vim-windows|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21275" PostTypeId="2" ParentId="21256" CreationDate="2019-09-24T06:09:21.823" Score="4" Body="&lt;p&gt;I know this is the &lt;code&gt;vi&lt;/code&gt; channel, but to me this is a &lt;code&gt;sed&lt;/code&gt; problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sed -ne 'p;n;n;n' &amp;lt;file &amp;gt;newfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can wrangle it into a &lt;code&gt;vi&lt;/code&gt; solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:0&#xA;!Gsed -ne 'p;n;n;n'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24941" LastActivityDate="2019-09-24T06:09:21.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21276" PostTypeId="2" ParentId="21272" CreationDate="2019-09-24T06:14:46.283" Score="0" Body="&lt;p&gt;Unfortunately, I can't find anything to force Vim to exclude some text region from the manual formatting. But at least the following script should do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; format a line range except the lines starting with a 'comment' string&#xA;function! MyFormat(comment) range&#xA;    &quot; go to the firstline; then mark the lastline&#xA;    execute a:firstline ';' a:lastline &quot;k'&quot;&#xA;    &quot; actually it's do / while&#xA;    let l:start = 1&#xA;    while l:start&#xA;        &quot; the last line number could change, so we use a bookmark&#xA;        let l:end = line(&quot;''&quot;)&#xA;        &quot; go to the first line which is NOT a comment&#xA;        let l:start = search('\V\^\(' . a:comment . '\)\@!', 'c', l:end)&#xA;        if l:start&#xA;            &quot; ...until the next comment&#xA;            let l:count = search('\V\^' . a:comment, 'n', l:end) - l:start&#xA;            &quot; no comment found -- format the rest and exit the loop&#xA;            if l:count &amp;lt; 1&#xA;                let l:count = l:end - l:start + 1&#xA;                let l:start = 0&#xA;            endif&#xA;            &quot; do formatting and go to the next line&#xA;            execute 'normal!' l:count . 'gqq+'&#xA;        endif&#xA;    endwhile&#xA;endfunction&#xA;&#xA;&quot; map Q to our function&#xA;noremap &amp;lt;silent&amp;gt;Q :%call MyFormat(&quot;\&amp;lt;bar&amp;gt;&quot;)&amp;lt;CR&amp;gt;&#xA;ounmap Q&#xA;&#xA;&quot; Now in Normal mode Q formats the whole buffer;&#xA;&quot; [count]Q formats [count] lines starting from the current one;&#xA;&quot; In Visual mode Q formats the selection.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-09-25T14:59:53.613" LastActivityDate="2019-09-25T14:59:53.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21277" PostTypeId="1" AcceptedAnswerId="21320" CreationDate="2019-09-24T06:48:14.310" Score="3" ViewCount="110" Body="&lt;p&gt;Just starting to get into Vim and facing the classic escape problem. I'm thinking binding &lt;kbd&gt;CapsLock&lt;/kbd&gt; to be &lt;kbd&gt;control&lt;/kbd&gt; when used with another key, and &lt;kbd&gt;escape&lt;/kbd&gt; when released without pressing anything else would be a great solution.  However, I don't want to do that if escape is used in some important key combinations.&lt;/p&gt;&#xA;" OwnerUserId="24943" LastEditorUserId="4472" LastEditDate="2019-09-28T11:10:40.900" LastActivityDate="2019-09-28T11:10:40.900" Title="Is ESC involved in any key combinations?" Tags="|key-bindings|escape|control-character|" AnswerCount="1" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21278" PostTypeId="2" ParentId="9757" CreationDate="2019-09-24T09:30:17.700" Score="3" Body="&lt;p&gt;If you are not using git to manage the plugin you are developing, you can use the &lt;code&gt;pinned&lt;/code&gt; option. I myself use this option for a plugin which I could only obtain as a zip archive &lt;code&gt;Plugin 'vim-specky', { 'pinned': 1 }&lt;/code&gt;. I downloaded the zip file and extracted it under &lt;code&gt;~/.vim/bundle&lt;/code&gt; and added this line in my &lt;code&gt;~/.vimrc&lt;/code&gt; and things are working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the docs of Vundle:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The 'pinned' option&#xA;-------------------&#xA;&#xA;A flag that, when set to a value of 1, tells Vundle not to perform any git&#xA;operations on the plugin, while still adding the existing plugin under the&#xA;`bundles` directories to the |runtimepath|.&#xA;&#xA;For example:&#xA;&amp;gt;&#xA;  Plugin 'mylocalplugin', {'pinned': 1}&#xA;&#xA;This allows the users to include, with Vundle, plugins tracked with version&#xA;control systems other than git, but the user is responsible for cloning and&#xA;keeping up to date. It also allows the users to stay in the current version of&#xA;a plugin that might have previously been updated by Vundle.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11793" LastActivityDate="2019-09-24T09:30:17.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21280" PostTypeId="2" ParentId="21256" CreationDate="2019-09-24T13:37:59.160" Score="1" Body="&lt;p&gt;an alternative: you want to keep any lines: 1, 4, etc.&#xA;You could use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;awk '!((FNR-1)%3)'  file &amp;gt; newfile&#xA;      # awk: when a condition is given without action:&#xA;      #        prints the lines for which the condition returns 0.&#xA;      # FNR designates the line number in the current file.&#xA;      # a%3 : takes the modulus of a and 3. ( 0%3=0, 1%3=1, 2%3=2, 3%3=0, 4%3=1, etc.) &#xA;      # This will be 0 for 3, 6, etc. &#xA;      # But we want it to be 0 (true) for 1, 4, etc : so we substract 1 to NR&#xA;&#xA;# to see that it keeps those lines:&#xA;seq 1 20 | awk '!((NR-1)%3)'&#xA;1&#xA;4&#xA;7&#xA;10&#xA;13&#xA;16&#xA;19&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;another alternative: if you know the lines you want match some unique pattern :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# for exemple each line you want contains &quot;some pattern&quot;:&#xA;fgrep &quot;some pattern&quot; file &amp;gt; newfile&#xA;# (or regular grep if you want &quot;some pattern&quot; to be interpreted as a regexp)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1289" LastEditorUserId="1289" LastEditDate="2019-09-24T13:43:24.187" LastActivityDate="2019-09-24T13:43:24.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21281" PostTypeId="1" CreationDate="2019-09-24T17:03:08.757" Score="0" ViewCount="92" Body="&lt;p&gt;I'm using Vim to typeset some Latex documents, and resizing it to take up half my screen so I can reference other materials on the other half. Therefore, &lt;code&gt;formatoptions+=t&lt;/code&gt; would be very helpful here. Unfortunately, Latex would need the newlines produced by &lt;code&gt;textwidth&lt;/code&gt; to be escaped with backslashes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick scan through the options page shows no simple way to change &lt;code&gt;textwidth&lt;/code&gt; wrapping to insert characters other than newlines, although the documentation for &lt;code&gt;wrapmargin&lt;/code&gt; does mention that the &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; character is inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to change the &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; character in this case? Or to use some other method to escape these inserted newlines?&lt;/p&gt;&#xA;" OwnerUserId="24951" LastActivityDate="2019-09-24T17:03:08.757" Title="Escape newlines when breaking text" Tags="|insert-mode|wrap|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21282" PostTypeId="1" CreationDate="2019-09-24T17:31:01.970" Score="1" ViewCount="107" Body="&lt;p&gt;I am trying to search for numeric values in files. I use  / command to start my search (/34587). However I need to add more then one search criteria (i.e. finding value 3487 and 09087 for instance). What is the search command in vim for such scenarios? thank you&lt;/p&gt;&#xA;" OwnerUserId="24952" LastActivityDate="2019-09-24T18:08:19.743" Title="Search for more then one numeric value in vim" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21283" PostTypeId="2" ParentId="21282" CreationDate="2019-09-24T18:08:19.743" Score="2" Body="&lt;p&gt;There's no &quot;special command&quot; for that. You use just the same &lt;code&gt;/&lt;/code&gt; (or &lt;code&gt;?&lt;/code&gt;) but along with a special pattern called &quot;a regular expression&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An introduction to this topic is written in the chapter 27 of Vim User Manual (&lt;code&gt;:h usr_27.txt&lt;/code&gt;). Specifically, a section 27.5 &quot;Alternatives&quot; (&lt;code&gt;:h 27.5&lt;/code&gt;). So in your case it is &lt;code&gt;/3487\|09087&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-09-24T18:08:19.743" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21284" PostTypeId="1" CreationDate="2019-09-24T21:11:50.443" Score="6" ViewCount="1287" Body="&lt;p&gt;I know I can use ranges/marks with the &lt;code&gt;!&lt;/code&gt; command like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%! column -t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc. Is there any way to pass a register to the external command instead of the current buffer? I imagine it would look something like this &lt;code&gt;@n! column -t&lt;/code&gt; but this just prints the contents of &lt;code&gt;n&lt;/code&gt; with the &quot;not an editor command&quot; error. Do I just have to resort to putting the contents of the register in a temporary buffer and then running the command?&lt;/p&gt;&#xA;" OwnerUserId="24955" LastActivityDate="2019-09-25T05:13:39.037" Title="running external command on contents of register" Tags="|external-command|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21285" PostTypeId="2" ParentId="21284" CreationDate="2019-09-24T21:44:18.990" Score="7" Body="&lt;p&gt;Not with the &lt;code&gt;!&lt;/code&gt; command. You'll have to use &lt;code&gt;system&lt;/code&gt; instead. From &lt;code&gt;:h system()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;system({expr} [, {input}])              *system()* *E677*&#xA;        Get the output of the shell command {expr} as a string.  See&#xA;        |systemlist()| to get the output as a List.&#xA;&#xA;        When {input} is given and is a string this string is written&#xA;        to a file and passed as stdin to the command.  The string is&#xA;        written as-is, you need to take care of using the correct line&#xA;        separators yourself.&#xA;        If {input} is given and is a |List| it is written to the file&#xA;        in a way |writefile()| does with {binary} set to &quot;b&quot; (i.e.&#xA;        with a newline between each list item with newlines inside&#xA;        list items converted to NULs).&#xA;        When {input} is given and is a number that is a valid id for&#xA;        an existing buffer then the content of the buffer is written&#xA;        to the file line by line, each line terminated by a NL and&#xA;        NULs characters where the text has a NL.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So putting this all together, you could do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call system(&quot;column -t&quot;, getreg(&quot;@n&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, unfortunately, this on it's own doesn't produce any output into the buffer. So if you want it to go into your buffer, you'll have to use &lt;code&gt;put&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:put =system(&quot;column -t&quot;, getreg(&quot;@n&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2019-09-25T05:13:39.037" LastActivityDate="2019-09-25T05:13:39.037" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21286" PostTypeId="1" CreationDate="2019-09-24T22:14:09.557" Score="1" ViewCount="198" Body="&lt;p&gt;I find myself wanting to use vim one-handed now and again. Practicality aside, I want to define a function along the lines of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetControlKey()&#xA;    echo &quot;Control? &quot;&#xA;    let key = nr2char(getchar())&#xA;    execute &quot;normal! &quot; . key &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that I can map to another key combination &lt;code&gt;&amp;lt;Leader&amp;gt;,&lt;/code&gt; maybe, that will allow me to get the keycode for a character, then mask it with whatever constant vim uses internally for key -&gt; Control-key conversion. Then use &lt;code&gt;normal!&lt;/code&gt; to emit the keypress, so I don't have to stretch my hand to reach the control key as often. Does vim use the same technique as other software (ControlMask,ShiftMask in Xlib) or does it use something specific to vim?&#xA;I am aware that &lt;a href=&quot;https://vi.stackexchange.com/questions/6206/sticky-shift-or-getting-shift-with-letter-combinations&quot;&gt;Sticky shift - or getting &amp;lt;shift&amp;gt; with letter combinations&lt;/a&gt; discusses a similar concept, but that uses subtraction to get lowercase-&gt;uppercase ascii conversion. I have tried bitwise &amp;amp;-ing the pairs for different keys &lt;code&gt;echo and(char2nr('&amp;lt;C-f&amp;gt;'),char2nr('f'))&lt;/code&gt; to try and get an idea of which bits are toggled between the two, but this doesn't produce a consistent result when doing the same thing for other characters (a, e, g etc.).&lt;/p&gt;&#xA;" OwnerUserId="24955" LastEditorUserId="24955" LastEditDate="2019-09-24T22:52:51.653" LastActivityDate="2019-09-26T02:14:56.390" Title="Control key bitmask" Tags="|key-bindings|vim-development|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21287" PostTypeId="1" AcceptedAnswerId="21293" CreationDate="2019-09-24T23:00:47.390" Score="1" ViewCount="151" Body="&lt;p&gt;I have the following function in an autoload file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! closet#FindSkeletonForFile()&#xA;    if exists('b:closet_skeleton')&#xA;        return 0&#xA;    endif&#xA;&#xA;    let b:closet_skeleton = s:closet.find_skeleton_for_file(expand('%:p'), &amp;amp;filetype)&#xA;&#xA;    if b:closet_skeleton !=# ''&#xA;        let cpopts = &amp;amp;cpoptions&#xA;        set cpoptions-=a&#xA;        echom &quot;Here goes the read:&quot;&#xA;        execute '0read '.fnameescape(b:closet_skeleton)&#xA;        let &amp;amp;cpoptions = cpopts&#xA;        return 1&#xA;    endif&#xA;&#xA;    return 0&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is triggered by a BufNewFile autocommand, and it appears to be working. The autocmd is in my &lt;code&gt;plugin/closet.vim&lt;/code&gt; file, and looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup closet&#xA;    autocmd!&#xA;    autocmd BufNewFile * call  closet#FindSkeletonForFile()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I invoke &lt;code&gt;vi foo.vim&lt;/code&gt; (a file that does not exist) I get an empty buffer, some of my earlier code identifies valid skeletons, I get a confirm dialog, the filename is returned, and the &lt;code&gt;s:closet.find_skeleton_for_file(...)&lt;/code&gt; function returns the correct value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;echom&lt;/code&gt; outputs to the message log, and when I run &lt;code&gt;:mess&lt;/code&gt; in the new vim window, I see this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Messages maintainer: Bram Moolenaar &amp;lt;Bram@vim.org&amp;gt;&#xA;Here goes the read:&#xA;&quot;~/Code/aghast/vim-closet/Closet/plugin.vim&quot; 28L, 448C&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This tells me that the dummy plugin is being read &lt;strong&gt;somewhere&lt;/strong&gt;, since those line/character numbers are what I see when I edit the dummy file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the &lt;code&gt;foo.vim&lt;/code&gt; buffer doesn't get changed! Since I can see the code being run correctly (many, many :echom statements) I'm pretty sure it's just down to getting that &lt;code&gt;0read&lt;/code&gt; statement to ... well, read!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone clue me in on the obvious thing I've missed?&lt;/p&gt;&#xA;" OwnerUserId="6216" LastActivityDate="2019-09-25T10:38:00.953" Title="vim8 - why does my 0read not read?" Tags="|vimscript|autocmd|functions|vim8|autoload|" AnswerCount="1" CommentCount="7" ClosedDate="2019-09-28T11:12:46.230" ContentLicense="CC BY-SA 4.0" />
  <row Id="21289" PostTypeId="2" ParentId="21286" CreationDate="2019-09-25T04:07:37.637" Score="0" Body="&lt;p&gt;The control keys are the ASCII values before ' ' (space). So &lt;code&gt;&amp;lt;C-A&amp;gt;&lt;/code&gt; is 1, &lt;code&gt;&amp;lt;C-B&amp;gt;&lt;/code&gt; is 2, ..., &lt;code&gt;&amp;lt;C-Z&amp;gt;&lt;/code&gt; is 26, &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; is 27 (aka ESC), &lt;code&gt;&amp;lt;C-\&amp;gt;&lt;/code&gt; is 28, &lt;code&gt;&amp;lt;C-]&amp;gt;&lt;/code&gt; is 29,  &lt;code&gt;&amp;lt;C-'&amp;gt;&lt;/code&gt; is 30 and &lt;code&gt;&amp;lt;C-_&amp;gt;&lt;/code&gt; is 31.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let key = getchar()&#xA;if key &amp;gt;= 97 &amp;amp;&amp;amp; key &amp;lt;= 122&#xA;    &quot; make it upper-case&#xA;    let key = key - 32&#xA;endif&#xA;let c_key = key - 64&#xA;if c_key &amp;lt; 0 || c_key &amp;gt; 31&#xA;    echoerr &quot;Invalid&quot;&#xA;else&#xA;    call feedkeys(nr2char(c_key))&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;feedkeys()&lt;/code&gt; to feed the determined control character to vim. That way it looks like it was typed by the user. See &lt;code&gt;:help feedkeys()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't know how to handle other control sequences (like &lt;code&gt;&amp;lt;C-F2&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-09-25T04:19:21.353" LastActivityDate="2019-09-25T04:19:21.353" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21290" PostTypeId="1" AcceptedAnswerId="21291" CreationDate="2019-09-25T08:20:28.663" Score="6" ViewCount="4502" Body="&lt;p&gt;Suppose I have a string as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RESULT=100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How would I replace everything following 'RESULT=' so that the string reads:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RESULT=200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The closest I've gotten so far is to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(RESULT=.*\)\@&amp;lt;=/200/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this simply places the desired string after the existing one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RESULT=100200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kindest regards!&lt;/p&gt;&#xA;" OwnerUserId="24963" LastEditorUserId="343" LastEditDate="2019-10-16T09:18:48.317" LastActivityDate="2019-10-16T09:18:48.317" Title="Replace after a specific pattern" Tags="|regular-expression|substitute|find|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21291" PostTypeId="2" ParentId="21290" CreationDate="2019-09-25T08:23:04.357" Score="5" Body="&lt;p&gt;One way to do this is by using &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Czs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\zs&lt;/code&gt;&lt;/a&gt; to set the &quot;start&quot; of the match, so that everything before &lt;code&gt;\zs&lt;/code&gt; is untouched by the replacement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/RESULT=\zs.*/200/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your original attempt using a lookbehind was also on the right track: you just put the &lt;code&gt;.*&lt;/code&gt; part in the wrong place:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(RESULT=\)\@&amp;lt;=.*/200/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This replaces &lt;em&gt;anything&lt;/em&gt; that comes after a &lt;code&gt;RESULT=&lt;/code&gt;, whereas your search replaced &lt;em&gt;nothing&lt;/em&gt; that comes after a &lt;code&gt;RESULT=.*&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; are recommended over lookarounds when it's possible to use them, because lookarounds can be slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/21290/replace-after-a-specific-pattern/21291#comment38330_21291&quot;&gt;@DJMcMayhem notes in the comments&lt;/a&gt;, yet another approach is to allow the substitution command to replace the &lt;code&gt;RESULT=&lt;/code&gt; part, but include that text in the replacement by using a capture group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(RESULT=\).*/\1200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-25T16:40:10.153" LastActivityDate="2019-09-25T16:40:10.153" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21292" PostTypeId="2" ParentId="21290" CreationDate="2019-09-25T09:43:47.383" Score="3" Body="&lt;p&gt;@Rich's solution is a perfect general solution, however maybe your question is a good example of an &lt;a href=&quot;https://meta.stackexchange.com/q/66377/288754&quot;&gt;XY problem&lt;/a&gt;. For your specific use case Vim has &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#CTRL-A&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h CTRL-A&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#CTRL-X&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h CTRL-X&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL-A          Add [count] to the number or alphabetic character at&#xA;            or after the cursor.&#xA;&#xA;CTRL-X          Subtract [count] from the number or alphabetic&#xA;            character at or after the cursor.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in your case you can simply put the cursor anywhere between the beginning of the line and the &lt;code&gt;1&lt;/code&gt; and in normal mode use &lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;CTRL+a&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-09-25T09:43:47.383" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21293" PostTypeId="2" ParentId="21287" CreationDate="2019-09-25T10:38:00.953" Score="2" Body="&lt;p&gt;Using &lt;code&gt;0read&lt;/code&gt; on BufNewFile actually works as expected, in fact the documentation for BufNewFile explicitly mentions using that event for loading a template or skeleton file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we also rule out the other things that might have gone wrong there, then the most likely explanation is that &lt;code&gt;0read&lt;/code&gt; &lt;em&gt;is&lt;/em&gt; working, but the contents of the buffer are later erased by another plug-in or hook.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As we ruled out anything else from that code path specifically (the &lt;code&gt;b:closet_skeleton&lt;/code&gt; was being set, and running the &lt;code&gt;0read&lt;/code&gt; from it after opening Vim was loading the file correctly), then the next course of action is to &lt;a href=&quot;https://vi.stackexchange.com/q/2003/18609&quot;&gt;debug your vimrc file&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following those steps, you were able to find you had a hook on VimEnter doing &quot;find-file-if-not-exist&quot; that was creating interference with your skeleton file hook. Updating that hook to consider previous contents of a file was enough to break that interference.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-25T10:38:00.953" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21294" PostTypeId="2" ParentId="21286" CreationDate="2019-09-25T16:02:32.653" Score="0" Body="&lt;p&gt;Historically, &lt;a href=&quot;http://catern.com/posts/terminal_quirks.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;terminals implemented &lt;kbd&gt;Ctrl&lt;/kbd&gt; by masking off the 6th and 7th bits&lt;/a&gt;. This is equivalent to doing bitwise &lt;code&gt;and&lt;/code&gt; with (octal) &lt;code&gt;037&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the following adaptation of your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetControlKey()&#xA;    echo &quot;Control? &quot;&#xA;    let key = nr2char(and(037, getchar()))&#xA;    execute &quot;normal &quot; . key &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I removed the &lt;code&gt;!&lt;/code&gt; from your &lt;code&gt;:normal&lt;/code&gt; command. Given your intended use, it seems likely that you do want this code to respect your mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also, that this will only work for keystrokes which are encoded in a single byte. For example, in my setup, the &lt;kbd&gt;End&lt;/kbd&gt; keystoke is encoded as the three bytes &lt;code&gt;0x80 0x40 0x37&lt;/code&gt; and &lt;kbd&gt;Ctrl-End&lt;/kbd&gt; is encoded as &lt;code&gt;0x80 0xFD 0x58&lt;/code&gt;. I'm not sure if there's a simple mapping between such multibyte combinations, but I suspect not.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-09-25T16:02:32.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21295" PostTypeId="1" CreationDate="2019-09-25T16:20:07.533" Score="9" ViewCount="1467" Body="&lt;p&gt;I'd like to know if there is an analogue to &lt;code&gt;verbose map &amp;lt;key&amp;gt;&lt;/code&gt; (which shows the location that the map was assigned) for functions. For example I have a few Git plugins and I'd like to know what plugin defines the &lt;code&gt;:GitFiles&lt;/code&gt; function, if Vim knows this info. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fallback (which'll certainly work) is to search my files for the string. &lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="1841" LastEditDate="2019-09-25T16:32:19.010" LastActivityDate="2019-09-25T23:40:21.927" Title="How to ask vim where function or command was defined?" Tags="|functions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21296" PostTypeId="2" ParentId="21295" CreationDate="2019-09-25T16:31:29.427" Score="8" Body="&lt;p&gt;From &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Afunction-verbose&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :function-verbose&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When 'verbose' is non-zero, listing a function will also display where it was&#xA;last defined. Example: &amp;gt;&#xA;&#xA;    :verbose function SetFileTypeSH&#xA;    function SetFileTypeSH(name)&#xA;        Last set from /usr/share/vim/vim-7.0/filetype.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;:verbose function GitFiles&lt;/code&gt; should do the work.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-09-25T16:31:29.427" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21297" PostTypeId="1" AcceptedAnswerId="21298" CreationDate="2019-09-25T16:42:55.997" Score="1" ViewCount="339" Body="&lt;p&gt;Suppose I have a file which contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TEMP=100&#xA;TEMP=100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I want to change all of the string beyond 'TEMP=' to 200, so it would read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TEMP=200&#xA;TEMP=200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could use the command &lt;code&gt;:%s/TEMP=\zs.*/200/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the command I need to ensure that only the first instance gets changed? The result should read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; TEMP=200&#xA; TEMP=100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried &lt;code&gt;:s/TEMP=\zs.*/200/&lt;/code&gt; but this fails unless I first perform &lt;code&gt;:%s/TEMP=\zs.*/200/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks!&lt;/p&gt;&#xA;" OwnerUserId="24963" LastEditorUserId="343" LastEditDate="2019-10-16T09:20:27.800" LastActivityDate="2019-10-16T09:20:27.800" Title="Replace Only First Occurence after Pattern" Tags="|substitute|find|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21298" PostTypeId="2" ParentId="21297" CreationDate="2019-09-25T16:52:19.840" Score="4" Body="&lt;p&gt;That &lt;code&gt;%&lt;/code&gt; in the &lt;code&gt;%s&lt;/code&gt; command at the beginning of your command specifies a range and tells the command to be run for all lines (short for &lt;code&gt;1,$&lt;/code&gt;, where &lt;code&gt;$&lt;/code&gt; stands for the last line). Besides line numbers, you can also specify marks or even specify search items.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the search you can specify the full range of regular expressions that vim knows about and you can even add offsets to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for your use case, you want to replace from the first line until the search term &lt;code&gt;TEMP&lt;/code&gt; is found, so you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1,/^TEMP=/s/TEMP=\zs.*/200/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will perform the &lt;code&gt;:s&lt;/code&gt; command only between the first line and the first line found that starts with &lt;code&gt;TEMP=&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the details see &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#:range&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :range&lt;/a&gt; and for a regular expression introduction have a look at &lt;a href=&quot;https://vimhelp.org/usr_27.txt.html#27.4&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 27.4&lt;/a&gt; in the user manual.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-09-25T16:52:19.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21299" PostTypeId="1" CreationDate="2019-09-25T22:18:55.007" Score="3" ViewCount="644" Body="&lt;p&gt;I'm trying to build a very simple plugin that allows for pressing a keymapping &lt;code&gt;&amp;lt;Leader&amp;gt;,&lt;/code&gt; to call a function that prompts for a single keypress:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ControlKey()&#xA;    echo &quot;Key → &amp;lt;C-Key&amp;gt; » &quot;&#xA;    let l:key = getchar()&#xA;    let l:key = ((l:key &amp;gt;= 97 &amp;amp;&amp;amp; l:key &amp;lt;= 122) ? l:key - 32 : l:key) - 64&#xA;    if l:key &amp;lt; 0 || l:key &amp;gt; 31&#xA;        echoerr &quot;Invalid Key Conbination! &quot;&#xA;    endif&#xA;    call feedkeys(nr2char(l:key), 't') | return ''&#xA;endfunction&#xA;&#xA;cnoremap &amp;lt;Leader&amp;gt;, &amp;lt;C-r&amp;gt;=ControlKey()&amp;lt;Cr&amp;gt;&#xA;inoremap &amp;lt;Leader&amp;gt;, &amp;lt;C-r&amp;gt;=ControlKey()&amp;lt;Cr&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;, :call ControlKey()&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function takes this keypress (for example, &lt;code&gt;a&lt;/code&gt;) and then uses feedkeys to send &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt; (essentially behaving as a sticky control key). This works fine in normal mode, as well as in insert and command (by (ab)using the expression register to make the requisite function call). I run into issues when wanting to use this function in operator pending mode, because I can't see a way to make make a call to the function that won't clobber the operator (&lt;code&gt;d&lt;/code&gt;,&lt;code&gt;y&lt;/code&gt;, etc) expecting a range or motion. Is there a way to achieve this or am I trying to stretch vim too far?&lt;/p&gt;&#xA;" OwnerUserId="24972" LastEditorUserId="8136" LastEditDate="2022-11-11T21:28:05.343" LastActivityDate="2022-11-11T21:28:05.343" Title="Vim feedkeys in operator pending mode" Tags="|key-bindings|plugin-development|operator-pending-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21300" PostTypeId="1" AcceptedAnswerId="21344" CreationDate="2019-09-25T22:25:30.920" Score="2" ViewCount="68" Body="&lt;p&gt;Question reposted &lt;a href=&quot;https://stackoverflow.com/questions/58145963/two-consecutive-identical-calls-to-echo-have-different-output-in-vim-function&quot;&gt;on StackOverflow&lt;/a&gt;, where it's receiving more attention.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the following function in the &lt;code&gt;.vimrc&lt;/code&gt; file,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! MyFun(count)&#xA;  echo a:count&#xA;  echo a:count&#xA;  if a:count &amp;gt; 0&#xA;    normal ,&#xA;    call MyFun(a:count - 1)&#xA;  endif&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;calling &lt;code&gt;:call MyFun(3)&lt;/code&gt; generates the following output.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3&#xA;3&#xA;2&#xA;2&#xA;1&#xA;1&#xA;0&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I define the mapping &lt;code&gt;nn , :&amp;lt;C-U&amp;gt;execute &quot;call MyFun(&quot; . v:count . &quot;)&quot;&amp;lt;CR&amp;gt;&lt;/code&gt;, then the call to &lt;code&gt;:call MyFun(3)&lt;/code&gt; generates&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3&#xA;0&#xA;2&#xA;0&#xA;1&#xA;0&#xA;0&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do understand that the mapping of &lt;code&gt;,&lt;/code&gt; makes the &lt;code&gt;MyFun&lt;/code&gt; function call itself twice (&lt;code&gt;if a:count &amp;gt; 0&lt;/code&gt;), however I cannot understand how this can cause a different result of the two successive calls to &lt;code&gt;echo a:count&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="6498" LastEditDate="2019-09-28T13:47:36.077" LastActivityDate="2019-09-28T14:07:59.937" Title="Two consecutive identical calls to echo have different output" Tags="|vimscript|functions|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21301" PostTypeId="2" ParentId="21295" CreationDate="2019-09-25T23:40:21.927" Score="0" Body="&lt;p&gt;While the other answer is correct, you can take another approach: install &lt;a href=&quot;https://github.com/iamcco/coc-vimlsp&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/iamcco/coc-vimlsp&lt;/a&gt; and use go to definition feature of coc. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-09-25T23:40:21.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21302" PostTypeId="2" ParentId="21299" CreationDate="2019-09-25T23:56:52.027" Score="1" Body="&lt;p&gt;I'm not sure if you're having the issue with a mapping for an operator that takes a motion or a mapping for the motion itself...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either way, you might want to try a different approach by using a &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:map &amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt; together with a recursive mapping, which should be better than using &lt;code&gt;feedkeys()&lt;/code&gt; as it's likely to produce less interferences with the following keypresses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ControlKey()&#xA;    let l:key = getchar()&#xA;    let l:key = ((l:key &amp;gt;= 97 &amp;amp;&amp;amp; l:key &amp;lt;= 122) ? l:key - 32 : l:key) - 64&#xA;    if l:key &amp;lt; 0 || l:key &amp;gt; 31&#xA;        echoerr &quot;Invalid Key Combination! &quot;&#xA;    endif&#xA;    return nr2char(l:key)&#xA;endfunction&#xA;&#xA;nmap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;, ControlKey()&#xA;omap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;, ControlKey()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I believe something like this should work better. Try it and see if it solves the problem you're trying to solve.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;am I trying to stretch vim too far?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In my opinion, yes. Vim mappings are great to act on Vim operations but not really that great to act on specific keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You seem to be trying to replace the Ctrl key. I think it's better if you find a solution for that on your OS's keyboard driver instead. Then that would work regardless of context (Vim mappings depend on the specific context) and it would work not only in Vim, but in other applications as well.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-09-25T23:56:52.027" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21303" PostTypeId="2" ParentId="21286" CreationDate="2019-09-26T01:29:03.010" Score="1" Body="&lt;p&gt;My recommendation would be to build a &lt;code&gt;&quot;\&amp;lt;C-...&amp;gt;&quot;&lt;/code&gt; string and then use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#eval%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;eval()&lt;/code&gt;&lt;/a&gt; to have Vim evaluate it as a key sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetControlKey()&#xA;    let key = getchar()&#xA;    let keyname = nr2char(key)&#xA;    return eval('&quot;\&amp;lt;C-'.escape(keyname,'\').'&amp;gt;&quot;')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can even find cases where the escape sequence fails, since then the &lt;code&gt;\&amp;lt;...&amp;gt;&lt;/code&gt; will not expand and the resulting string will keep the &lt;code&gt;&amp;lt;C-&lt;/code&gt; as a literal prefix, so checking for that flags failures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's still one set of keys to handle, which are the keys with a symbolic name, such as arrows, F-keys, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;can&lt;/em&gt; handle those, but I can't really see a way other than handling them one by one, essentially checking whether the key matches something like &lt;code&gt;&quot;\&amp;lt;left&amp;gt;&quot;&lt;/code&gt; and turning that into &lt;code&gt;left&lt;/code&gt; as keyname.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetControlKey()&#xA;    let key = getchar()&#xA;    if key ==# &quot;\&amp;lt;left&amp;gt;&quot;&#xA;        let keyname = 'left'&#xA;    elseif key ==# &quot;\&amp;lt;right&amp;gt;&quot;&#xA;        let keyname = 'right'&#xA;    ...&#xA;    elseif key ==# &quot;\&amp;lt;f2&amp;gt;&quot;&#xA;        let keyname = 'f2'&#xA;    ...&#xA;    elseif key ==# &quot;\&amp;lt;S-f2&amp;gt;&quot;&#xA;        let keyname = 'S-f2'&#xA;    ...&#xA;    endif&#xA;    return eval('&quot;\&amp;lt;C-'.escape(keyname,'\').'&amp;gt;&quot;')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, it's quite a bit of work to list all combinations, especially if you want to cover the &lt;code&gt;M-&lt;/code&gt; and &lt;code&gt;S-&lt;/code&gt; prefixes (and possibly the &lt;code&gt;C-&lt;/code&gt; ones as well, to preserve them.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a long &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;elseif&lt;/code&gt;/&lt;code&gt;endif&lt;/code&gt; chain is probably pretty inefficient too. If you can use a Dict, that's probably better. (See &lt;a href=&quot;https://vimhelp.org/eval.txt.html#Dict&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help Dict&lt;/code&gt;&lt;/a&gt; for more details.) If you use a Dict, you can probably use the &lt;code&gt;eval()&lt;/code&gt; expression to generate the keys (probably only once, as you load a plug-in.) So all you need is a list of valid key names, as you can also generate the combinations of the &lt;code&gt;M-&lt;/code&gt;, &lt;code&gt;S-&lt;/code&gt; and &lt;code&gt;C-&lt;/code&gt; modifiers programmatically as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in short, it's doable, but it's quite a bit of work. My recommendation is to use &lt;code&gt;eval()&lt;/code&gt; and build a Dict with the mapping of named keys.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="10604" LastEditDate="2019-09-26T02:14:56.390" LastActivityDate="2019-09-26T02:14:56.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21304" PostTypeId="2" ParentId="21300" CreationDate="2019-09-26T01:52:37.363" Score="2" Body="&lt;p&gt;I don't know why it happens, but if you add a &lt;code&gt;\n&lt;/code&gt; after the &lt;code&gt;echo&lt;/code&gt; it all works and the result is what you would expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! MyFun(count)&#xA;  echo a:count . &quot;\n&quot;&#xA;  echo a:count . &quot;\n&quot;&#xA;  if a:count &amp;gt; 0&#xA;    normal ,&#xA;    call MyFun(a:count - 1)&#xA;  endif&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But maybe you already knew that and was just curious to know &lt;em&gt;why&lt;/em&gt; (as I confess I am).&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2019-09-26T01:52:37.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21305" PostTypeId="2" ParentId="21272" CreationDate="2019-09-26T02:16:18.240" Score="0" Body="&lt;p&gt;Found it...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a moment of serendipity, I discovered that a comment block in a different file was not reformatted!  The only difference was this file used a different set of 'ftplugin' and 'syntax' configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a LONG bit of detective work I finally traced the solution to changing my comment settings from...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setl comments=b:\|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setl comments=fn:\|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I did this the 'gq' text re-formating (or text re-flow) did not change the lines.  that is because it will then see each and every line in the comment as a seperate paragraph (like a bullet list), so does nto re-indent, or merge short lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HOWEVER: &lt;strong&gt;This is only a partial solution, as 'gq' still looks at that text!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means 'gq' will still break up long lines, without adding comment leaders. And when editing it will not insert a comment leader on carriage returns or open new line, which was why I was using 'b:\|' in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But works for me as all the lines are less that the default 'textwidth' setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Matt   Thank you very much for you code. I will be trying it out as it would be even better if 'gq' did not even try to do anything, even for long lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone has a better solution, maybe using 'formatexpr' to modify actual 'gq' behavior, that would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="23299" LastEditorUserId="23299" LastEditDate="2019-09-26T02:22:04.207" LastActivityDate="2019-09-26T02:22:04.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21306" PostTypeId="1" CreationDate="2019-09-26T03:34:28.587" Score="0" ViewCount="236" Body="&lt;p&gt;Just started to look into VIM for my coding. I managed to set up some functionality with pathogen and want to make a slow start to learn VIM. the problem is that when I open a PHP document, I get swamped with the warning &quot;Missing doc comment&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course for good practice these comments should be in the file, but when just playing around this is annoying. Is there a way to turn (toggle) this off?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any other tips welcome, but I am just getting my feet wet in VIM&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit: My current plugins:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;auto-pairs , nerdtree , supertab , syntastic , vim-autoformat , vim-jsbeautify , vim-sensible&lt;/p&gt;&#xA;" OwnerUserId="24976" LastEditorUserId="24976" LastEditDate="2019-09-26T13:23:03.260" LastActivityDate="2019-09-26T16:22:40.647" Title="Missing doc comment errors" Tags="|error|filetype-php|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="21307" PostTypeId="1" AcceptedAnswerId="21308" CreationDate="2019-09-26T04:37:03.693" Score="1" ViewCount="855" Body="&lt;p&gt;I'm just getting into Vim, and, as one might expect, I'm constantly adding things to my &lt;code&gt;.vimrc&lt;/code&gt;. At the moment i'm using &lt;code&gt;:tabe ~/.vimrc&lt;/code&gt; and I was just curious if there was a quicker command for getting to the&lt;code&gt;.vimrc&lt;/code&gt; that was used when Vim launched.&lt;/p&gt;&#xA;" OwnerUserId="24943" LastActivityDate="2019-09-26T05:41:24.793" Title="What's the fastest way to open up .vimrc?" Tags="|vimrc|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21308" PostTypeId="2" ParentId="21307" CreationDate="2019-09-26T04:54:34.057" Score="3" Body="&lt;p&gt;You could use &lt;code&gt;$MYVIMRC&lt;/code&gt;. See &lt;code&gt;:help .vimrc&lt;/code&gt;. It says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The $MYVIMRC environment variable is set to the file that was first found, &#xA;  unless $MYVIMRC was already set and when using VIMINIT.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$MYVIMRC&lt;/code&gt; is also not set if you use the command line option &lt;code&gt;-u&lt;/code&gt; to specify a different ini file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two mappings in my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap _v :e $MYVIMRC&amp;lt;CR&amp;gt;&#xA;noremap _u :source $MYVIMRC&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By hitting &lt;code&gt;_v&lt;/code&gt; I can open my &lt;code&gt;vimrc&lt;/code&gt; and with &lt;code&gt;_u&lt;/code&gt; the &lt;code&gt;vimrc&lt;/code&gt; is reloaded.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-09-26T04:54:34.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21309" PostTypeId="2" ParentId="21307" CreationDate="2019-09-26T05:41:24.793" Score="4" Body="&lt;p&gt;Another way is to use a bookmark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, while &lt;code&gt;.vimrc&lt;/code&gt;is open, press &lt;kbd&gt;m&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt; to save current position in a global bookmark 'V'. To reopen &lt;code&gt;.vimrc&lt;/code&gt; in the current window simply go to the bookmark with &lt;kbd&gt;'&lt;/kbd&gt;&lt;kbd&gt;V&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;capital letters&quot; bookmarks are automatically saved in &lt;code&gt;viminfo&lt;/code&gt;, so they will persist between sessions. Also, there are 26 such bookmarks, so you can easily track a couple of other important files, not just &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-09-26T05:41:24.793" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21310" PostTypeId="1" AcceptedAnswerId="21311" CreationDate="2019-09-26T06:49:45.070" Score="0" ViewCount="33" Body="&lt;p&gt;Both the statusline and the tabline only show the file I'm currently working (on on my current tab). Is there any built-in setting that can show the names of the files that occupy the windows I'm not currently focused on?&lt;/p&gt;&#xA;" OwnerUserId="24943" LastActivityDate="2019-09-26T07:44:51.340" Title="Is it possible to have something that displays the filenames of all my unfocused windows?" Tags="|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21311" PostTypeId="2" ParentId="21310" CreationDate="2019-09-26T07:44:51.340" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there any built-in setting that can show the names of the files that occupy the windows I'm not currently focused on?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I suppose you mean &lt;code&gt;set laststatus=2&lt;/code&gt;. That makes every window to have a status line of its own (which by default also shows a file/buffer name).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beyond this, many customizations are possible, but they all require quite a bit of scripting (or plugin use).&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-09-26T07:44:51.340" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21312" PostTypeId="1" CreationDate="2019-09-26T08:24:10.987" Score="0" ViewCount="785" Body="&lt;p&gt;I have the following lines in my .vimrc. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme elflord&#xA;&#xA;set incsearch&#xA;&#xA;set guifont=Monospace\ 13 &#xA;&quot; &amp;lt;Ctrl-l&amp;gt; redraws the screen and removes any search highlighting.&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-l&amp;gt; :nohl&amp;lt;CR&amp;gt;&amp;lt;C-l&amp;gt;&#xA;&#xA;runtime macros/matchit.vim&#xA;runtime ftplugin/system_verilog.vim&#xA;syntax on&#xA;filetype on &#xA;filetype indent on &#xA;filetype plugin on&#xA;set nocompatible&#xA;set lines=40 columns=150&#xA;set nu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it is not able to match the pairs inside vim automatically. However if I do the following command inside the vim, it is able to detect the pairs with &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime ftplugin/system_verilog.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you please help me to fix it to be done automatically whenever I open gvim?&lt;/p&gt;&#xA;" OwnerUserId="24979" LastEditorUserId="343" LastEditDate="2019-09-26T09:01:36.277" LastActivityDate="2019-09-26T14:27:12.877" Title="Matchit plugin is not working when I put it in my .vimrc. However it works when I run the same command manually inside Vim" Tags="|plugin-matchit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21313" PostTypeId="2" ParentId="12794" CreationDate="2019-09-26T08:56:11.670" Score="2" Body="&lt;p&gt;Just to add to ipatch answer, which is the correct answer, if you have a slightly different setup from Vim you might need to adapt the path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, on Windows, rather than using the default configuration with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$HOME&#xA;   +--.vimrc&#xA;   +--.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$HOME&#xA;   +--vimfiles&#xA;          +--vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The reasons is that is it easier to put a single directory under revision control than a file and a directory, particularly when the file is at the root of your home directory)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following works for me then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath^=~/vimfiles runtimepath+=~/vimfiles/after&#xA;let &amp;amp;packpath=&amp;amp;runtimepath&#xA;source ~/vimfiles/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5604" LastEditorUserId="5604" LastEditDate="2019-09-30T11:11:33.907" LastActivityDate="2019-09-30T11:11:33.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21314" PostTypeId="2" ParentId="21312" CreationDate="2019-09-26T08:59:12.547" Score="1" Body="&lt;p&gt;As far as I can tell from your question, you're attempting to use the &lt;code&gt;matchit&lt;/code&gt; plugin in a Systemverilog file and it's not working how you'd expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you edit your question to be more specific about exactly what you're doing and what you're expecting to happen I can be more specific in my advice. Still, the following part of your &lt;code&gt;vimrc&lt;/code&gt; stands out:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;runtime&lt;/code&gt; lines in your &lt;code&gt;vimrc&lt;/code&gt; aren't the recommended way of enabling plugins (and don't do what I'm guessing you think they do).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How to enable matchit&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you're running Vim 8, then you enable matchit by adding the following line to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;packadd! matchit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're still on Vim 7, then instead of editing your &lt;code&gt;vimrc&lt;/code&gt;, you install matchit by running the following commands from an existing Vim instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!mkdir ~/.vim&#xA;:!mkdir ~/.vim/plugin&#xA;:!cp $VIMRUNTIME/macros/matchit.vim ~/.vim/plugin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.vimhelp.org/usr_05.txt.html#matchit-install&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help matchit&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Systemverilog filetype&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In order to use Vim's standard configuration for Systemverilog you just need to enable Vim's syntax and/or filetype plugins, and then ensure that the &lt;code&gt;'filetype'&lt;/code&gt; is set to &lt;code&gt;systemverilog&lt;/code&gt; when editing a Systemverilog file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do this manually by running the command &lt;code&gt;:set ft=systemverilog&lt;/code&gt; from a Systemverilog file, but since you've turned on filetype detection, Vim will automatically set the &lt;code&gt;'filetype'&lt;/code&gt; to &lt;code&gt;systemverilog&lt;/code&gt; and load its filetype/syntax/indent files when you open any file with an &lt;code&gt;.sv&lt;/code&gt; or &lt;code&gt;.svh&lt;/code&gt; extension.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.vimhelp.org/filetype.txt.html#filetype&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help filetype&lt;/code&gt;&lt;/a&gt; for more details, and &lt;a href=&quot;https://www.vimhelp.org/filetype.txt.html#new-filetype&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help new-filetype&lt;/code&gt;&lt;/a&gt; if you need Vim to detect Systemverilog files that &lt;em&gt;don't&lt;/em&gt; have an &lt;code&gt;.sv&lt;/code&gt; or &lt;code&gt;.svh&lt;/code&gt; extension.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-26T14:27:12.877" LastActivityDate="2019-09-26T14:27:12.877" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21315" PostTypeId="1" AcceptedAnswerId="21317" CreationDate="2019-09-26T09:24:41.190" Score="1" ViewCount="47" Body="&lt;p&gt;A plugin I use executes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent execute '%!cmd'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which fails because of a particular environment variable I have set that deliberately modifies the behaviour of &lt;code&gt;cmd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I&lt;/em&gt; can fix it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent execute '%!ENV_VAR= cmd'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I can't contribute that upstream because it won't work on Windows. I believe the Windows equivalent would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent execute '%!set ENV_VAR= &amp;amp;&amp;amp; cmd'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;though I can't readily test it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a platform agnostic way of doing this, say invoking &lt;code&gt;execute&lt;/code&gt; with a fresh environment?&lt;/p&gt;&#xA;" OwnerUserId="5778" LastActivityDate="2019-09-26T11:36:53.977" Title="Cross-platform way to execute command with clean environment?" Tags="|microsoft-windows|shell|unix|environment-variables|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21316" PostTypeId="2" ParentId="5123" CreationDate="2019-09-26T10:24:57.483" Score="1" Body="&lt;p&gt;Sometimes such behaviour can result from unusual key mappings setup in your &lt;code&gt;.vimrc&lt;/code&gt; - so for example if you have something that maps two &lt;kbd&gt;ESC&lt;/kbd&gt; key presses:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;Esc&amp;gt;&amp;lt;Esc&amp;gt; some_command_sequence&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it can lead to vim malfunctioning with the arrow keys.&lt;/p&gt;&#xA;" OwnerUserId="13589" LastActivityDate="2019-09-26T10:24:57.483" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21317" PostTypeId="2" ParentId="21315" CreationDate="2019-09-26T11:36:53.977" Score="2" Body="&lt;p&gt;As any child process inherits the environment from its parent, you can temporarily redefine Vim's own environment before executing your tool:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let [temp, $ENV_VAR] = [$ENV_VAR, '']&#xA;%!cmd&#xA;let $ENV_VAR = temp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-09-26T11:36:53.977" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21318" PostTypeId="1" AcceptedAnswerId="21319" CreationDate="2019-09-26T13:23:05.920" Score="3" ViewCount="899" Body="&lt;p&gt;I want to disable my VIM-arrows in VIM, to get used to move the cursor using hjkl. I have tried a lot of different approaches found on this forum, however, i can't seem to disable the up and down buttons in 'Insert Mode'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Heres my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'Valloric/YouCompleteMe'&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&quot; To ignore plugin indent changes, instead use:&#xA;&quot;filetype plugin on&#xA;&quot;&#xA;&quot; Brief help&#xA;&quot; :PluginList       - lists configured plugins&#xA;&quot; :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate&#xA;&quot; :PluginSearch foo - searches for foo; append `!` to refresh local cache&#xA;&quot; :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal&#xA;&quot;&#xA;&quot; see :h vundle for more details or wiki for FAQ&#xA;&quot; Put your non-Plugin stuff after this line&#xA;&#xA;&#xA;&quot; Removes preview window in YCM.&#xA;set completeopt-=preview&#xA;&#xA;&quot; Set clipboard to system clipboard&#xA;set clipboard=unnamedplus&#xA;&#xA;&quot; Enable pathogen&#xA;execute pathogen#infect()&#xA;&#xA;&quot; F# syntax on .fsi files. (.fsx and .fs are supported automaticly by plugin)&#xA;autocmd BufNewFile,BufRead *.fsi set syntax=fsharp&#xA;&#xA;&quot; Set numbers on side.&#xA;&quot; &#xA;set number&#xA;&#xA;&quot; Disables arrow keys.&#xA;&quot; Remove newbie crutches in Command Mode&#xA;cnoremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;cnoremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;cnoremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;cnoremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&#xA;&quot; Disable Arrow keys in Insert mode&#xA;inoremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;inoremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&quot; Remove newbie crutches in Normal Mode&#xA;nnoremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;nnoremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;nnoremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;nnoremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&#xA;&quot; Remove newbie crutches in Visual Mode&#xA;vnoremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;vnoremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;vnoremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;vnoremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arrow remapping is found in the bottom of .vimrc. Alongside inoremap, i have tried imap and this solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; noremap  &amp;lt;Up&amp;gt; &quot;&quot;&#xA; noremap! &amp;lt;Up&amp;gt; &amp;lt;Esc&amp;gt;&#xA; noremap  &amp;lt;Down&amp;gt; &quot;&quot;&#xA; noremap! &amp;lt;Down&amp;gt; &amp;lt;Esc&amp;gt;&#xA; noremap  &amp;lt;Left&amp;gt; &quot;&quot;&#xA; noremap! &amp;lt;Left&amp;gt; &amp;lt;Esc&amp;gt;&#xA; noremap  &amp;lt;Right&amp;gt; &quot;&quot;&#xA; noremap! &amp;lt;Right&amp;gt; &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Found on &lt;a href=&quot;https://stackoverflow.com/questions/23548932/how-do-i-disable-the-arrow-keys-in-insert-mode&quot;&gt;https://stackoverflow.com/questions/23548932/how-do-i-disable-the-arrow-keys-in-insert-mode&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rn everything but Up and Down in 'Insert mode' is disabled. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keyboard layout: Danish, Ubuntu 18.04&#xA;Vim: 8.0.1453&lt;/p&gt;&#xA;" OwnerUserId="24982" LastActivityDate="2023-08-11T13:14:46.570" Title="How to disable arrows in insert mode VIM" Tags="|vimrc|original-vim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21319" PostTypeId="2" ParentId="21318" CreationDate="2019-09-26T13:51:02.073" Score="3" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/21318/how-to-disable-arrows-in-insert-mode-vim/21319#comment38362_21318&quot;&gt;discussed in the comments&lt;/a&gt;, YouCompleteMe is overwriting your mapping with its own.&lt;/p&gt;&#xA;&lt;p&gt;Normally, you can overwrite a setting that a plugin has made by using the &lt;a href=&quot;https://www.vimhelp.org/starting.txt.html#load-plugins&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;.vim/after&lt;/code&gt;&lt;/a&gt; directory but in this instance, YouCompleteMe is actually creating the mapping even later on, via an &lt;a href=&quot;https://www.vimhelp.org/eval.txt.html#autoload&quot; rel=&quot;nofollow noreferrer&quot;&gt;autoload function&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You might like to &lt;a href=&quot;https://github.com/ycm-core/YouCompleteMe#options&quot; rel=&quot;nofollow noreferrer&quot;&gt;check the YouCompleteMe documentation&lt;/a&gt; to see if it's possible to stop it doing so. At a guess, it's the &lt;code&gt;g:ycm_key_list_select_completion&lt;/code&gt; and &lt;code&gt;g:ycm_key_list_previous_completion&lt;/code&gt; options you'll need to change.&lt;/p&gt;&#xA;&lt;p&gt;Otherwise, you could try recreating &lt;em&gt;your&lt;/em&gt; mappings &lt;a href=&quot;https://www.vimhelp.org/autocmd.txt.html#InsertEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;whenever you enter insert mode&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup SeriouslyNoInsertArrows&#xA;  autocmd!&#xA;  autocmd InsertEnter * inoremap &amp;lt;Up&amp;gt; &amp;lt;nop&amp;gt;&#xA;  autocmd InsertEnter * inoremap &amp;lt;Down&amp;gt; &amp;lt;nop&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or, if you want to continue using the arrows in YCM's autocomplete menus, you might prefer something like (untested):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup SeriouslyNoInsertArrows&#xA;  autocmd!&#xA;  autocmd InsertEnter * inoremap &amp;lt;expr&amp;gt; &amp;lt;Up&amp;gt; pumvisible() ? '&amp;lt;C-P&amp;gt;' : ''&#xA;  autocmd InsertEnter * inoremap &amp;lt;expr&amp;gt; &amp;lt;Down&amp;gt; pumvisible() ? '&amp;lt;C-N&amp;gt;' : ''&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2023-08-11T13:14:46.570" LastActivityDate="2023-08-11T13:14:46.570" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21320" PostTypeId="2" ParentId="21277" CreationDate="2019-09-26T15:05:26.707" Score="1" Body="&lt;p&gt;If, when you write &quot;combination&quot;, you are referring to when two keys are pressed simultaneously (sometimes also called &quot;chords&quot; by analogy with musical terminology), then &lt;kbd&gt;Escape&lt;/kbd&gt; &lt;em&gt;cannot be used&lt;/em&gt; in such combinations and thus you're safe to rebind your &lt;kbd&gt;Caps Lock&lt;/kbd&gt; key in this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that hundreds* of other Vim users (including me) already do this with no ill effect other than the fact that it becomes more difficult to use other people's computers once you get used to it. It's for this latter reason that I'm not sure if I'd &lt;em&gt;recommend&lt;/em&gt; you do this, but it's totally fine to do so, at least as far as Vim is concerned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* Thousands? Millions?!?&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-09-27T09:10:03.200" LastActivityDate="2019-09-27T09:10:03.200" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21321" PostTypeId="1" CreationDate="2019-09-26T15:28:17.280" Score="0" ViewCount="27" Body="&lt;p&gt;I found &lt;a href=&quot;https://vi.stackexchange.com/questions/1871/ins-completion-of-words&quot;&gt;this question&lt;/a&gt;, but mine is a bit different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I write code dealing with arrays or classes like &lt;code&gt;$myArray['myElement']&lt;/code&gt; or &lt;code&gt;document.getElementById(&quot;myElement&quot;)&lt;/code&gt;, I get annoyed because I have to use word completion a few times.  Vim's completion is helpful like &lt;code&gt;$myA&amp;lt;C-P&amp;gt;&lt;/code&gt; completes &lt;code&gt;$myArray&lt;/code&gt;, but then I still have to type &lt;code&gt;['$myE&amp;lt;C-P&amp;gt;']&lt;/code&gt; to finish the whole WORD. I tried changing &lt;code&gt;iskeyword&lt;/code&gt; to include &lt;code&gt;'[].&lt;/code&gt;, but that returned too many results to sort through when I only wanted to complete words.  &lt;code&gt;d&amp;lt;C-X&amp;gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; is helpful sometimes, but also not what I'm looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I configure Vim to keep the default word completion to complete &lt;code&gt;d&amp;lt;C-P&amp;gt;&lt;/code&gt; to &lt;code&gt;document&lt;/code&gt;, and also add something, maybe &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-W&amp;gt;&lt;/code&gt;, to complete &lt;code&gt;d&amp;lt;C-X&amp;gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; to &lt;code&gt;document.getElementById(&quot;myElement&quot;)&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="21476" LastActivityDate="2019-09-26T15:28:17.280" Title="How can I complete both words and WORDS?" Tags="|vimrc|autocompletion|functions|" AnswerCount="0" CommentCount="3" FavoriteCount="0" ClosedDate="2019-09-26T17:54:44.553" ContentLicense="CC BY-SA 4.0" />
  <row Id="21322" PostTypeId="2" ParentId="21306" CreationDate="2019-09-26T16:22:40.647" Score="1" Body="&lt;p&gt;Being a beginner of VIM it may be tempting to install plugin candy, but caution is in place. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With Pathogen, plugins get installed in ~/vim/bundle&#xA;First thing I tried is to zip all the plugins and delete their originals. This quick dirty step already fixed the main issue. My first assumption was the Syntastic plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking up this plugin and the toggle I was looking for, led me to this post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/20030603/vim-syntastic-how-to-disable-the-checker&quot;&gt;https://stackoverflow.com/questions/20030603/vim-syntastic-how-to-disable-the-checker&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;:SyntasticToggleMode&lt;/code&gt; will do the trick, but do check out the post, which has some tips as well.&lt;/p&gt;&#xA;" OwnerUserId="24976" LastActivityDate="2019-09-26T16:22:40.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21323" PostTypeId="1" CreationDate="2019-09-27T02:48:57.230" Score="2" ViewCount="48" Body="&lt;p&gt;There are a lot of times were I have something like &lt;code&gt;int x = someFunction(a, b, c);&lt;/code&gt; If my cursor is somewhere after the equals sign, is there a good way to put the cursor on the “s” in someFunction?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the options I’ve tried suck. F=ll has too many keypresses far away from each other, spamming B until I get there is dumb and doesn’t work with macros, and counting words and doing (number)B ruins the workflow because I have to stop and count words.&lt;/p&gt;&#xA;" OwnerUserId="24992" LastActivityDate="2019-09-27T02:48:57.230" Title="Best way to move cursor to start of variable declaration?" Tags="|cursor-movement|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21324" PostTypeId="1" CreationDate="2019-09-27T12:15:28.350" Score="2" ViewCount="494" Body="&lt;p&gt;Same question as &lt;a href=&quot;https://vi.stackexchange.com/questions/7644/use-vim-with-virtualenv&quot;&gt;Use Vim with virtualenv&lt;/a&gt;, except for these differences: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I'm using bash, not zsh&lt;/li&gt;&#xA;&lt;li&gt;using &lt;a href=&quot;https://docs.python.org/3/library/venv.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;venv&lt;/a&gt;, not &lt;code&gt;virtualenv&lt;/code&gt; or &lt;code&gt;virtualenvwrapper&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have a keybinding to run the current buffer as a python script, but even if I've started vim with my virtual environment activated, the shell that it uses isn't in my venv, therefore it can't import any of the modules that I've pip-installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried adding the following, one at a time, to &lt;code&gt;/etc/profile&lt;/code&gt;, &lt;code&gt;/etc/profile.d/vim.sh&lt;/code&gt;, &lt;code&gt;~/.bashrc&lt;/code&gt;, and &lt;code&gt;~/.bash_profile&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [[ -n $VIRTUAL_ENV &amp;amp;&amp;amp; -e &quot;${VIRTUAL_ENV}/bin/activate&quot; ]]; then&#xA;  source &quot;${VIRTUAL_ENV}/bin/activate&quot;&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But even after closing and reopening my terminal, vim still starts a shell thinking that &lt;code&gt;which python&lt;/code&gt; = &lt;code&gt;/bin/python&lt;/code&gt; instead of the one in my venv. However, running &lt;code&gt;:echo $VIRTUAL_ENV&lt;/code&gt; within vim does actually return the correct path to my venv, so at least I know can see the variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get vim's non-interactive shell to use the parent shell's environment? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;:&lt;br&gt;&#xA;to answer D. Ben Knoble, these are the keybindings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :w&amp;lt;CR&amp;gt;:!clear;python %&amp;lt;CR&amp;gt;&#xA;inoremap &amp;lt;F5&amp;gt; &amp;lt;Esc&amp;gt;:w&amp;lt;CR&amp;gt;:!clear;python %&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I follow you correctly, I should call python like so?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w&amp;lt;CR&amp;gt;:!clear;$VIRTUAL_ENV/bin/python %&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works as I try it now, but is it a reliable solution? &lt;/p&gt;&#xA;" OwnerUserId="22463" LastEditorUserId="22463" LastEditDate="2019-09-27T16:56:52.283" LastActivityDate="2019-09-27T16:56:52.283" Title="Use external commands within venv virtual environment" Tags="|external-command|bash|shell|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21325" PostTypeId="1" CreationDate="2019-09-27T16:01:16.223" Score="0" ViewCount="469" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aSYG0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aSYG0.png&quot; alt=&quot;Vim highlight some unused space in the file&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just recently used Vim as my code editor. It was working fine then suddenly when I opened a file to edit my code this happens. When I open the file nothing is highlighted. But when I start scrolling down the file then scroll back up the highlight shows up. Resizing the window also removes the highlight but goes back whenever I scroll the file up and down.&lt;/p&gt;&#xA;" OwnerUserId="24997" LastEditorUserId="24997" LastEditDate="2019-09-27T16:13:13.800" LastActivityDate="2019-10-02T11:55:53.830" Title="VIM suddenly highlighted the spaces in my file how do I turn this off?" Tags="|vimrc|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21326" PostTypeId="1" AcceptedAnswerId="21332" CreationDate="2019-09-27T16:12:58.153" Score="2" ViewCount="108" Body="&lt;p&gt;I recently installed Latex-Suite using Vundle, and I use Latex to take notes. My notes are separate files for each lecture, but I have a master.tex file set up to compile each document together, and I use the &lt;code&gt;subfile&lt;/code&gt; packaged to do this. Unfortunately, this package can lead to some unavoidable warnings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Package auxhook Warning: Cannot patch \document, using \AtBeginDocument instead.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe this is a result of having multiple nested &lt;code&gt;\begin{document}&lt;/code&gt; environments when the files are brought together. However, it does compile, and the document looks as it should. The problem is that Latex-Suite takes this warning and opens up the file &lt;code&gt;/usr/local/texlive/2017/texmf-dist/fex/latex/oberdiek/auxhook.sty&lt;/code&gt;, which I assume is where this warning presents. When it does this, it closes the current &lt;code&gt;.tex&lt;/code&gt; file which I'm trying to edit, which is extremely annoying. My question is, did I set something up incorrectly with the way Latex-Suite compiles my documents, or is there a way to get this to stop happening. As a side-note, I am trying to get my final result in &lt;code&gt;.pdf&lt;/code&gt; form for all of my compiled documents. Below are the relevant lines from my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;let g:Tex_DefaultTargetFormat='pdf'&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;let g:Tex_MultipleCompileFormats='pdf'&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This happens when I use the compile command &lt;code&gt;\lv&lt;/code&gt; in Latex-Suite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, this is my first post, please let me know if I've left anything important out.&lt;/p&gt;&#xA;" OwnerUserId="24998" LastActivityDate="2019-09-27T21:26:54.170" Title="Latex-Suite in Vim exits out of tex document if there's a warning in the aux file on compilation" Tags="|filetype-tex|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21327" PostTypeId="1" CreationDate="2019-09-27T16:45:56.903" Score="4" ViewCount="2920" Body="&lt;p&gt;I've traditionally used &lt;code&gt;vim&lt;/code&gt; as a text editor and &lt;code&gt;tmux&lt;/code&gt; as a terminal multiplexer, but I'm trying to see if I can drop tmux entirely and just use &lt;code&gt;vim&lt;/code&gt; for everything (except session attach/detach, which will be handled by an external tool). So far, I have almost zero knowledge about terminal emulators in &lt;code&gt;vim&lt;/code&gt; and how to customize them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My main question is: should I base this setup upon &lt;code&gt;neovim&lt;/code&gt; or &lt;code&gt;vim 8&lt;/code&gt;? From what I gathered, terminal support is largely different in those 2 programs. I know that &lt;code&gt;neovim&lt;/code&gt; implementation should be more mature, since it got terminal first, but I also noticed that terminal help in &lt;code&gt;neovim&lt;/code&gt; is very sparse, while help page in &lt;code&gt;vim 8&lt;/code&gt; is much more expansive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My second question is whether that's at all feasible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some of the functionality I'm hoping to achieve (don't yet know if all of this is possible):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open new splits with terminal similar to &lt;code&gt;tmux&lt;/code&gt; (each split is a separate terminal)&lt;/li&gt;&#xA;&lt;li&gt;Ability to go into &lt;code&gt;netrw&lt;/code&gt; from terminal with working directory being one opened in shell&lt;/li&gt;&#xA;&lt;li&gt;Start terminal in currently from directory currently open in &lt;code&gt;netrw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Have separate working directory for each tab/split&lt;/li&gt;&#xA;&lt;li&gt;Edit terminal command in normal mode without opening nested editor with &lt;code&gt;C-x C-e&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13992" LastActivityDate="2022-12-17T09:42:18.790" Title="Using vim as a terminal multiplexer: neovim or vim 8?" Tags="|neovim|terminal|vim8|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21328" PostTypeId="2" ParentId="21327" CreationDate="2019-09-27T18:49:29.697" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;should I base this setup upon neovim or vim 8?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you don't have any problems with Vim, there's no need to switch to Neovim. In particular, Vim's terminal support is very decent.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Open new splits with terminal similar to tmux (each split is a separate terminal)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, it's trivial. In fact, it's hard to avoid this.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Ability to go into netrw from terminal with working directory being one opened in shell&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;First, netrw sucks. Seriously consider migrating to NERDTree or vim-dirvish (or maybe vim-vinegar).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, that requires Vim to get CWD of another process. In general, that could be tricky, but as for shell you probably can live with &lt;code&gt;term_gettitle()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Start terminal in currently from directory currently open in netrw&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's not about terminal support, but rather about netrw/other plugin. Easily done with dirvish. Perhaps, the same for others.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Have separate working directory for each tab/split&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Again, that has nothing to do with terminal support (every process has CWD of its own anyway). But every window (and tab) in Vim can also have CWD of its own (see &lt;code&gt;:h lcd&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Edit terminal command in normal mode without opening nested editor with C-x C-e&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Vim (and also Neovim) has Normal mode for terminal window, but it's read-only. It should be possible to do some tricks with &lt;code&gt;tnoremap&lt;/code&gt; and &lt;code&gt;term_sendkeys()&lt;/code&gt;, but that will not be true editing mode either. Bash setting &lt;code&gt;set -o vi&lt;/code&gt; should be much more practical.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-09-27T18:49:29.697" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21329" PostTypeId="1" AcceptedAnswerId="21334" CreationDate="2019-09-27T19:41:24.467" Score="3" ViewCount="1033" Body="&lt;p&gt;I have string lets say&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;count number of elecment when tra(XYixe0/en_in/old)='mid/2' rise='corse/2'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to replace / from (XYixe0/en_in/old) to .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My output string should look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;count number of elecment when tra(XYixe0.en_in.old)='mid/2' rise='corse/2'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In summary, I want vim search / only on string which is inside () and replace / by .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated. &lt;/p&gt;&#xA;" OwnerUserId="25002" LastActivityDate="2019-09-27T21:51:42.933" Title="Vim search and replace &quot;/&quot; only from string between round bracket" Tags="|gvim|linux|" AnswerCount="4" CommentCount="1" ClosedDate="2019-10-01T06:46:16.373" ContentLicense="CC BY-SA 4.0" />
  <row Id="21330" PostTypeId="2" ParentId="21329" CreationDate="2019-09-27T20:28:34.860" Score="2" Body="&lt;p&gt;It's not perfect since you have to run it multiple times to get every slash, but that's not too big of a problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/(.*\zs\/\ze.*)/./g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will replace &lt;em&gt;one&lt;/em&gt; slash inside of parenthesis with a dot. To get it to replace all of them, you could then run something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5@:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to get all of them replaced. (Adjust 5 to be as big as needed).&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-09-27T20:28:34.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21331" PostTypeId="2" ParentId="21329" CreationDate="2019-09-27T21:20:58.377" Score="1" Body="&lt;p&gt;So this is a bit of a hack. If your inside the parenthesis&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;di(mmo^R&quot;^[:s/\//./g^Mv$hxdd`m&quot;-P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;di(&lt;/code&gt; delete inside the parenthesis&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;mm&lt;/code&gt; make a mark so you can get back to your original position&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^R&quot;&lt;/code&gt; paste the &quot; register into buffer from insert mode, that is ctrl+r&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^[&lt;/code&gt; is escape &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:s/\//./g^M&lt;/code&gt; this is the substitution with &lt;code&gt;^M&lt;/code&gt; = enter&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;v$hx&lt;/code&gt; mark and delete your change this will also put it in the &lt;code&gt;-&lt;/code&gt; register&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;dd&lt;/code&gt; will delete the line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;`m that is backtick m (couldn't format that properly) which will take you back to the mark&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;-P&lt;/code&gt; insert text from &lt;code&gt;-&lt;/code&gt; register in before current char&lt;/p&gt;&#xA;" OwnerUserId="17130" LastActivityDate="2019-09-27T21:20:58.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21332" PostTypeId="2" ParentId="21326" CreationDate="2019-09-27T21:26:54.170" Score="1" Body="&lt;p&gt;I had the same problem, as far as I could find that is the result of 2 things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You are allowing &lt;code&gt;vim-latex&lt;/code&gt; to jump to the first error atomatically. You can disable it with:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Tex_GotoError=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;You are probably on Windows, and the jumping to the package file is the result of a misunderstanding in the file paths. You can fix that by adding to your vimrc:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shellslash&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This, however, creates a problem within &lt;code&gt;vim-latex&lt;/code&gt; and the command &lt;code&gt;&amp;lt;Leader&amp;gt;ls&lt;/code&gt;, to jump to the current position in your pdf stops working. The &lt;code&gt;&amp;lt;Leader&amp;gt;lv&lt;/code&gt; command works properly. So is up to you to decide if this is adequate for your workflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="24995" LastActivityDate="2019-09-27T21:26:54.170" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21333" PostTypeId="2" ParentId="3992" CreationDate="2019-09-27T21:38:49.177" Score="1" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://github.com/vim-scripts/LanguageTool&quot; rel=&quot;nofollow noreferrer&quot;&gt;LanguageTool&lt;/a&gt; plugin to add a double functionality, it provides not only spell check but also grammar check using the external java tool. It checks the entire buffer and displays an error list buffer at the bottom. I find it quite useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="24995" LastActivityDate="2019-09-27T21:38:49.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21334" PostTypeId="2" ParentId="21329" CreationDate="2019-09-27T21:46:18.567" Score="2" Body="&lt;p&gt;Another way is to use a sub-replace-expression, &lt;code&gt;\=&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/([^)]*)/\=substitute(submatch(0),'\/','.','g')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:s/([^)]*)/{replacement}/&lt;/code&gt; will match a pair of parens, &lt;code&gt;([^)]*)&lt;/code&gt;. The &lt;code&gt;{replacement}&lt;/code&gt; is &lt;code&gt;\={expr}&lt;/code&gt;. Where &lt;code&gt;{expr}&lt;/code&gt; will be a vimscript expression to be evaluated. In this case a substitution over the entire match, &lt;code&gt;submatch(0)&lt;/code&gt;, matching on &lt;code&gt;\/&lt;/code&gt; and replacing with &lt;code&gt;.&lt;/code&gt; for the entire string, &lt;code&gt;g&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h sub-replace-expression&#xA;:h :s&#xA;:h substitute()&#xA;:h submatch()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-09-27T21:46:18.567" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21335" PostTypeId="2" ParentId="6425" CreationDate="2019-09-27T21:51:20.140" Score="1" Body="&lt;p&gt;Do you have &lt;code&gt;git&lt;/code&gt; installed? Vundle uses it to process the installations and it is not by default on Windows.&lt;/p&gt;&#xA;" OwnerUserId="24995" LastActivityDate="2019-09-27T21:51:20.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21336" PostTypeId="2" ParentId="21329" CreationDate="2019-09-27T21:51:42.933" Score="0" Body="&lt;p&gt;The shortest path, not requiring repeat runs, is probably the (in)famous sub-replace expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A recent q&amp;amp;a asked &lt;a href=&quot;https://vi.stackexchange.com/questions/20704/how-to-run-a-substitute-command-on-only-a-certain-part-of-the-line/20706#20706&quot;&gt;a similar question&lt;/a&gt; regarding doing a replacement on just a portion of a line. In fact, they also wanted to operate on text inside parentheses. (This could arguably be considered a duplicate question...but I won't argue that here.) I posted a pretty extensive answer on using sub-replace expressions which is a method for running an arbitrary Vim expression as the replacement part of a substitution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some people find this approach complicated but I don't think it's too bad once you break it down....which I tried my best to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Briefly, either of these will work for your question...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s#(\([^)]\+\))#\='(' . substitute(submatch(1), '/', '.', 'g') . ')'#&#xA;&#xA;:s#(\zs\([^)]\+\)\ze)#\=substitute(submatch(1), '/', '.', 'g')#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And there are other variations, too. These are a little stretched out for readability (maybe). It also depends on how conservative/error-proof you want the solution to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than repeat here what I said in that answer I suggest you read the original: &lt;a href=&quot;https://vi.stackexchange.com/questions/20704/how-to-run-a-substitute-command-on-only-a-certain-part-of-the-line/20706#20706&quot;&gt;How to run a substitute command on only a certain part of the line&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-09-27T21:51:42.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21337" PostTypeId="1" AcceptedAnswerId="21376" CreationDate="2019-09-27T22:49:58.830" Score="3" ViewCount="5986" Body="&lt;p&gt;Here's what I'd like to do, and I'm open to using any tool (not just fzf):&lt;/p&gt;&#xA;&lt;p&gt;I want to be able to open a new file quickly (with a horizontal split :sp) in a specific directory that I find using fzf. Say we're working with this structure&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;foo/&#xA;  bar/&#xA;    file.js&#xA;  baz/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;While I have file.js open in my buffer, I should be able to fuzzy find the foo/baz/ directory and open a new file foo/baz/newfile.js in a split window.&lt;/p&gt;&#xA;" OwnerUserId="14314" LastEditorUserId="13161" LastEditDate="2023-04-11T19:26:37.953" LastActivityDate="2023-04-11T19:26:37.953" Title="How to use FZF to search directories and open new file in directory" Tags="|working-directory|plugin-fzf|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21338" PostTypeId="1" CreationDate="2019-09-27T23:09:11.203" Score="1" ViewCount="556" Body="&lt;p&gt;I realise this might be impossible, but thought it might be worth asking anyway.&#xA;In vim, the typical way I map keys to functions is using &lt;code&gt;*noremap&lt;/code&gt; commands. However the downside of this is the fact that the mapping is not a call to the function. Instead, it automatically literally types out the characters needed to invoke said function; getting a command prompt with &lt;code&gt;:&lt;/code&gt;, typing &lt;code&gt;call&lt;/code&gt; and the function name, hitting return, etc. Is there a way I can bind a key to a function directly without this intermediary step, much like how &lt;code&gt;hjkl&lt;/code&gt; immediately invoke internal functions that actually do the work of changing the cursor position? Or is this kind of functionality not exposed to the user by vim?&lt;/p&gt;&#xA;" OwnerUserId="25003" LastActivityDate="2019-09-28T01:53:07.517" Title="calling function from normal mode without *noremap" Tags="|key-bindings|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21339" PostTypeId="2" ParentId="21338" CreationDate="2019-09-27T23:43:51.527" Score="3" Body="&lt;p&gt;Essentially, the answer is no, &lt;code&gt;:call&lt;/code&gt; &lt;em&gt;is&lt;/em&gt; the mechanism for invoking functions starting from normal mode, but there are at least two mechanisms I can think of that you could theoretically use if you needed to call a function from a normal-mode mapping but the colon key had been stolen from your keyboard:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Expression mappings&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Expression mappings work by evaluating an expression and then mapping to the result. A function call is a valid expression, thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;f2&amp;gt; Function()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, there are several limitations to what you can actually do &lt;em&gt;during&lt;/em&gt; that function: e.g. you can move the cursor but it will be moved back afterwards. See &lt;code&gt;:help map-expr&lt;/code&gt; for the full set of limitations and other details.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The expression register&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Vim has a register called the “expression register” which you can use to evaluate expressions in certain circumstances. This &lt;em&gt;could&lt;/em&gt; be used to run a function from a normal mode mapping by e.g. entering insert mode first:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;f2&amp;gt; i&amp;lt;C-R&amp;gt;=Function()&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In case it’s not already clear, this would be an asinine thing to do, but the expression register &lt;em&gt;is&lt;/em&gt; very useful in other contexts. See &lt;code&gt;:help &quot;=&lt;/code&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="18609" LastEditDate="2019-09-28T01:53:07.517" LastActivityDate="2019-09-28T01:53:07.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21340" PostTypeId="1" CreationDate="2019-09-28T00:05:22.553" Score="2" ViewCount="301" Body="&lt;p&gt;In bash you can easily search the current history entries by hitting &lt;code&gt;&amp;lt;C-r&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-s&amp;gt;&lt;/code&gt;. This search feature is incremental, and once you hit return, you get a bash prompt auto-filled with the closest match in your history. I know if I want to search for a vim command I can hit &lt;code&gt;q:&lt;/code&gt; and then search with &lt;code&gt;/&lt;/code&gt;. However, I find this slow. Tab completion somewhat alleviates the tedium of searching for command, but is not quite satisfactory. Does vim have a similar feature?&lt;/p&gt;&#xA;" OwnerUserId="25003" LastActivityDate="2019-10-02T19:05:37.247" Title="vim incremental command history search" Tags="|search|command-history|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21341" PostTypeId="2" ParentId="21337" CreationDate="2019-09-28T03:22:43.477" Score="0" Body="&lt;p&gt;Using fzf.vim, it has the wrapper for Files, (and GFiles, which respect the gitignore while searching)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under current directory, run &lt;code&gt;:Files&lt;/code&gt;, fzf will open a list of files to search. Remember, this only search &lt;strong&gt;file names&lt;/strong&gt;, not file's contents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hit &lt;code&gt;c-x&lt;/code&gt; for split, or &lt;code&gt;c-v&lt;/code&gt; for vsplit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to preview the content inside the file, set this in .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Likewise, Files command with preview window&#xA;command! -bang -nargs=? -complete=dir Files&#xA;  \ call fzf#vim#files(&amp;lt;q-args&amp;gt;, fzf#vim#with_preview(), &amp;lt;bang&amp;gt;0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will show the preview content next to the search list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set the shortcut to &lt;code&gt;sf&lt;/code&gt; (in my mind, it is &lt;code&gt;search files&lt;/code&gt;, so I can quickly open it)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; sf :FzfFiles&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to search the content inside the files, use :Ag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf.vim documentation&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="19109" LastEditorUserId="19109" LastEditDate="2019-09-28T03:32:09.680" LastActivityDate="2019-09-28T03:32:09.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21342" PostTypeId="2" ParentId="21340" CreationDate="2019-09-28T06:29:23.363" Score="2" Body="&lt;p&gt;I'm not aware that this is possible. The only thing I know is, that Vim uses the already typed characters to filter the history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you previously executed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/This/That/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you want to get this command again, you do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/T&amp;lt;up&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will get only commands that start with &lt;code&gt;%s/T&lt;/code&gt; from the history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_Up&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help c_Up&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="18609" LastEditDate="2019-09-28T14:37:28.073" LastActivityDate="2019-09-28T14:37:28.073" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21344" PostTypeId="2" ParentId="21300" CreationDate="2019-09-28T14:07:59.937" Score="2" Body="&lt;p&gt;The problem is all about screen redraw (see &lt;code&gt;:h echo-redraw&lt;/code&gt;) in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changing &lt;code&gt;echo&lt;/code&gt; to &lt;code&gt;echom&lt;/code&gt; still produces the same (broken) screen output (&lt;code&gt;3 0 2 0 1 0 0 0&lt;/code&gt;), but &lt;code&gt;:mess&lt;/code&gt; reveals what is hidden: &lt;code&gt;3 3 0 0 2 2 0 0 1 1 0 0 0 0&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-09-28T14:07:59.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21345" PostTypeId="1" AcceptedAnswerId="21359" CreationDate="2019-09-28T15:17:35.290" Score="6" ViewCount="1880" Body="&lt;p&gt;&lt;code&gt;:term&lt;/code&gt; usually looks ugly in most colorschemes I've tried. At least on Windows, with light themes, these colors do not work and end up in an unreadable shade of yellow against my light background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently re-enabled &lt;a href=&quot;https://github.com/NLKNguyen/papercolor-theme/&quot; rel=&quot;noreferrer&quot;&gt;papercolor-theme/PaperColor&lt;/a&gt;, and I noticed it changed the terminal colors. They terminal actually became readable. I dug into the code and found it (most likely) originates from &lt;a href=&quot;https://github.com/NLKNguyen/papercolor-theme/blob/master/colors/PaperColor.vim#L1106&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;g:terminal_ansi_colors&lt;/code&gt;&lt;/a&gt;, which is defined in the theme. Most themes only do this for Neovim, which requires a different variant, but I digress.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation (&lt;code&gt;:help g:terminal_ansi_colors&lt;/code&gt;) states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;pre&gt;&lt;code&gt;                                                        *g:terminal_ansi_colors*&#xA;In GUI mode or with 'termguicolors', the 16 ANSI colors used by default in new&#xA;terminal windows may be configured using the variable&#xA;`g:terminal_ansi_colors`, which should be a list of 16 color names or&#xA;hexadecimal color codes, similar to those accepted by |highlight-guifg|.  When&#xA;not using GUI colors, the terminal window always uses the 16 ANSI colors of&#xA;the underlying terminal.&#xA;The |term_setansicolors()| function can be used to change the colors, and&#xA;|term_getansicolors()| to get the currently used colors.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But say I wanted to make my own colorscheme (or just make a different colorscheme that doesn't add support for &lt;code&gt;g:terminal_ansi_colors&lt;/code&gt; readable) - how do I use it? Or to be more specific: how do each of the 16 values map to a color on the terminal, provided there is a system?&lt;/p&gt;&#xA;" OwnerUserId="21251" LastEditorUserId="21251" LastEditDate="2019-09-29T10:17:10.363" LastActivityDate="2019-09-30T11:59:55.757" Title="How does g:terminal_ansi_colors affect the :terminal colors?" Tags="|terminal-buffer|color|vim8|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21347" PostTypeId="1" CreationDate="2019-09-28T19:49:59.960" Score="0" ViewCount="146" Body="&lt;p&gt;The comment auto-insert feature is often very helpful and otherwise very annoying, depending on the kind of comment I am writing. Is it possible to bind the auto-insertion of &lt;code&gt;//&lt;/code&gt; exclusively to &lt;code&gt;&amp;lt;shift+enter&amp;gt;&lt;/code&gt;, and skip the auto-comment for ordinary &lt;code&gt;&amp;lt;enter&amp;gt;&lt;/code&gt;? I thought about binding a key to some kind of temporary &lt;code&gt;setlocal&lt;/code&gt;, but it seems too complicated since &lt;code&gt;setlocal&lt;/code&gt; is meant for local scope (obviously) and not for immediate modifiers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This earlier question is similar but really not the same: &lt;a href=&quot;https://vi.stackexchange.com/questions/15444/remove-automatic-comment-leader&quot;&gt;Remove automatic comment leader&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3353" LastActivityDate="2019-09-28T19:49:59.960" Title="Auto-insert C++ comment only on &lt;shift+enter&gt;" Tags="|vimrc|comments|filetype-c++|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21349" PostTypeId="1" AcceptedAnswerId="21350" CreationDate="2019-09-28T22:24:51.290" Score="3" ViewCount="356" Body="&lt;p&gt;basically I have a bunch of lines of code that all match the format &lt;code&gt;.\module.variable (),&#xA;.\module.variable2 (),&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to take everything between the backslash and the space, before the parentheses and put it in the parentheses for each line, with whatever is on that line, like this: &#xA;&lt;code&gt;.\module.variable (module.variable),&#xA;.\module.variable2 (module.variable2),&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="25014" LastEditorUserId="25014" LastEditDate="2019-09-28T22:30:03.323" LastActivityDate="2019-09-28T23:13:26.220" Title="search for pattern and insert text that precedes the pattern from pattern1 to pattern2 exclusive" Tags="|search|command-line|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21350" PostTypeId="2" ParentId="21349" CreationDate="2019-09-28T22:44:41.957" Score="2" Body="&lt;p&gt;Visit each line that has the key pattern using the &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#:g&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g&lt;/code&gt;lobal command&lt;/a&gt; and do a (global) &lt;a href=&quot;https://vimhelp.org/change.txt.html#:s&quot; rel=&quot;nofollow noreferrer&quot;&gt;substitution&lt;/a&gt; on that same pattern at each visited line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/\.\\\(\S\+\) ()/ s//.\\\1 (\1)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pattern, which is used in both the global and substitution operations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\.\\&lt;/code&gt; : period and backslash&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\(\S\+\)&lt;/code&gt; : non-empty, non-space string inside a capturing group (&lt;code&gt;\(...\)&lt;/code&gt;) which allows us to reference the match in the replacement section of the substitution operation&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;()&lt;/code&gt; : a space and empty pair of parens&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;We leave the pattern in the substitution operation empty which indicates that we want the last used pattern. The replacement part then just uses the &lt;a href=&quot;https://vimhelp.org/change.txt.html#s/%5c1&quot; rel=&quot;nofollow noreferrer&quot;&gt;capturing group back reference&lt;/a&gt; (&lt;code&gt;\1&lt;/code&gt;) twice to build the target string. (Note: I don't think Vim help refers to these constructs as &quot;capture/capturing groups&quot; but it's pretty much a universally used term for them.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-09-28T23:13:26.220" LastActivityDate="2019-09-28T23:13:26.220" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21351" PostTypeId="1" AcceptedAnswerId="21352" CreationDate="2019-09-29T01:05:30.383" Score="6" ViewCount="2042" Body="&lt;p&gt;I often find myself&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Opening a terminal&lt;/li&gt;&#xA;&lt;li&gt;Running &lt;code&gt;vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Starting a &lt;code&gt;:terminal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is there a way to say &lt;code&gt;vim --start-terminal&lt;/code&gt; and have Vim automatically run &lt;code&gt;:terminal ++curwin&lt;/code&gt; as soon as it starts?&lt;/p&gt;&#xA;" OwnerUserId="22095" LastActivityDate="2019-09-29T01:11:51.867" Title="Is there a way to start vim in terminal mode?" Tags="|terminal-buffer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21352" PostTypeId="2" ParentId="21351" CreationDate="2019-09-29T01:11:51.867" Score="9" Body="&lt;p&gt;I assume you aren't literally asking for a &lt;code&gt;--start-terminal&lt;/code&gt; flag :) ...but you can specify a command for Vim to run after it starts up using the &lt;code&gt;-c&lt;/code&gt; flag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this should be as easy as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -c ':term ++curwin'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run it I am indeed in a terminal window on the shell command line and it's the only window open. Hopefully that covers what you're asking for.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-09-29T01:11:51.867" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21353" PostTypeId="1" CreationDate="2019-09-29T01:21:48.647" Score="3" ViewCount="198" Body="&lt;p&gt;On my Linux system, if I try to type indic characters (specifically Kannada) in gvim (via ibus), the display is so garbled, I can barely see what has been typed. Is it the expected behaviour? Can Gvim display all the utf characters properly like pluma (another editor under Linux) does? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have avoided asking about vim/neovim supporting these as it would be a terminal issue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers would be helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Attaching a screenshot of the two editors.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/bMu6c.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bMu6c.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17897" LastEditorUserId="17897" LastEditDate="2019-09-29T12:32:10.003" LastActivityDate="2019-09-29T12:32:10.003" Title="Gvim and Unicode indic characters" Tags="|gvim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21354" PostTypeId="2" ParentId="21353" CreationDate="2019-09-29T05:53:12.033" Score="2" Body="&lt;p&gt;This is a known problem and has been discussed a couple of times in the past. Unfortunately, Vim is not really good suited to the specifics of indic fonts and therefore in the current implementation displays them a bit garbled. Having said that, a PR implementing proper support would certainly be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See those threads on the mailinglist: &lt;a href=&quot;https://groups.google.com/d/msg/vim_use/25IZ0sMfPbE/oVyhD7vXCwAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://groups.google.com/d/msg/vim_use/25IZ0sMfPbE/oVyhD7vXCwAJ&lt;/a&gt;, &lt;a href=&quot;https://groups.google.com/d/msg/vim_use/zgzENKfjybA/bB_k9qsh-ysJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://groups.google.com/d/msg/vim_use/zgzENKfjybA/bB_k9qsh-ysJ&lt;/a&gt; and &lt;a href=&quot;https://groups.google.com/d/msg/vim_use/tZV2rBXS_3U/quy6Ovau-BEJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://groups.google.com/d/msg/vim_use/tZV2rBXS_3U/quy6Ovau-BEJ&lt;/a&gt; (and most likely there were other threads about it as well).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-09-29T05:53:12.033" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21355" PostTypeId="1" AcceptedAnswerId="21356" CreationDate="2019-09-29T11:47:21.167" Score="7" ViewCount="4001" Body="&lt;p&gt;I'm a vim beginner. I want to handle multiple programming languages. I find great resources for how to perfect vim for one programming language by putting ton of stuff in one vimrc file. This is annoying. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found about filetype plugin, but it's confusing. All I need is to put a vimrc file that runs for this specific lanuage. However, filetype plugin is huge with tons of features and tons of strange file paths.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I set different settings/plugins for different file types?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; It would be nice if there's a guide on how do people go about this basic need.&lt;/p&gt;&#xA;" OwnerUserId="25022" LastActivityDate="2021-09-01T14:57:52.350" Title="Multiple vimrc files for different file types in vim?" Tags="|vimrc|filetype|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21356" PostTypeId="2" ParentId="21355" CreationDate="2019-09-29T14:46:30.483" Score="5" Body="&lt;p&gt;To enable filetype detection and plugins, add the following command to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then, for each filetype you want settings for, create a Vimscript file in the following location:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/after/ftplugin/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Name the file with the filetype you want it to apply to, so for e.g. a Python settings file, create:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/after/ftplugin/python.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For more details, see &lt;a href=&quot;https://vimhelp.org/filetype.txt.html#ftplugin-overrule&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ftplugin-overrule&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2021-09-01T14:57:52.350" LastActivityDate="2021-09-01T14:57:52.350" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21359" PostTypeId="2" ParentId="21345" CreationDate="2019-09-30T11:59:55.757" Score="3" Body="&lt;p&gt;The help for the function &lt;code&gt;term_setansicolors&lt;/code&gt; provides some more details.  The short story is these 16 colors form a conventional palette which terminal programs use when outputting text.  You can set them to anything you want, but it's best to stick to the vague color descriptions below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;term_setansicolors({buf}, {colors})         *term_setansicolors()*&#xA;        Set the ANSI color palette used by terminal {buf}.&#xA;        {colors} must be a List of 16 valid color names or hexadecimal&#xA;        color codes, like those accepted by |highlight-guifg|.&#xA;        Also see |term_getansicolors()| and |g:terminal_ansi_colors|.&#xA;&#xA;        The colors normally are:&#xA;            0    black&#xA;            1    dark red&#xA;            2    dark green&#xA;            3    brown&#xA;            4    dark blue&#xA;            5    dark magenta&#xA;            6    dark cyan&#xA;            7    light grey&#xA;            8    dark grey&#xA;            9    red&#xA;            10   green&#xA;            11   yellow&#xA;            12   blue&#xA;            13   magenta&#xA;            14   cyan&#xA;            15   white&#xA;&#xA;        These colors are used in the GUI and in the terminal when&#xA;        'termguicolors' is set.  When not using GUI colors (GUI mode&#xA;        or 'termguicolors'), the terminal window always uses the 16&#xA;        ANSI colors of the underlying terminal.&#xA;        {only available when compiled with the |+terminal| feature and&#xA;        with GUI enabled and/or the |+termguicolors| feature}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-09-30T11:59:55.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21360" PostTypeId="1" AcceptedAnswerId="21363" CreationDate="2019-09-30T14:08:37.420" Score="1" ViewCount="414" Body="&lt;p&gt;I sometimes need to do some remarks in parentheses in my commit message's detailed part. But when the parenthesized text comes to the rightmost column and is line-broken, the next line for some reason begins from the column after the opening parenthesis. See the screenshot below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uh0FC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uh0FC.png&quot; alt=&quot;screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what's going on here? Why does it happen, and how can I make wrapping continue from the first column?&lt;/p&gt;&#xA;" OwnerUserId="1081" LastActivityDate="2019-09-30T20:29:36.677" Title="Why is the commit message inside parentheses wrapped so strangely?" Tags="|indentation|git|line-breaks|" AnswerCount="1" CommentCount="10" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21361" PostTypeId="1" AcceptedAnswerId="21366" CreationDate="2019-09-30T15:52:25.067" Score="3" ViewCount="345" Body="&lt;p&gt;While using &lt;code&gt;:mksession&lt;/code&gt; feature, I found that it works well with files and &lt;code&gt;netrw&lt;/code&gt;, but not so much with neovim &lt;code&gt;terminal&lt;/code&gt; windows. The problem is that, for terminal, it never preserves working directory inside the shell, even if I &lt;code&gt;:lcd&lt;/code&gt; before saving the session. It does restore working directory inside &lt;code&gt;vim&lt;/code&gt; itself, but the shell directory is always the one that was specified when terminal was created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if there's a way to work around this. I'm thinking about something like calling extra function after session restore to run &lt;code&gt;cd getcwd()&lt;/code&gt; in every terminal window, but I'm not sure how to do it correctly.&lt;/p&gt;&#xA;" OwnerUserId="13992" LastActivityDate="2023-04-18T21:29:42.777" Title="Restore working directory in terminal windows when loading session" Tags="|neovim|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21362" PostTypeId="1" CreationDate="2019-09-30T18:13:17.597" Score="2" ViewCount="977" Body="&lt;p&gt;I'm using &lt;code&gt;PuTTY&lt;/code&gt; as SSH client and &lt;code&gt;zsh&lt;/code&gt; as a shell. When I just connect to a host and don't run &lt;code&gt;nvim&lt;/code&gt;, I can see that control-left/right keys work correctly and send a different key from simply pressing an arrow by using &lt;code&gt;ctrl-v&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# pressing ctrl-v left:&#xA;^[OD&#xA;# pressing ctrl-v ctrl-left:&#xA;^[[D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when i run neovim &lt;code&gt;:terminal&lt;/code&gt;, I get the same input no matter if I use control or not:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# pressing ctrl-v left:&#xA;^[OD&#xA;# pressing ctrl-v ctrl-left:&#xA;^[OD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Same thing when I just edit a file: In insert mode, &lt;code&gt;ctrl-v ctrl-left&lt;/code&gt; inserts &lt;code&gt;&amp;lt;Left&amp;gt;&lt;/code&gt; instead of &lt;code&gt;&amp;lt;C-Left&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This behavior is &lt;strong&gt;not&lt;/strong&gt; reproduced with &lt;code&gt;vim8&lt;/code&gt;, only with &lt;code&gt;neovim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way I managed to make it work correctly is by using &lt;code&gt;tmux&lt;/code&gt; with options &lt;code&gt;terminal-overrides &quot;xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@&quot;&lt;/code&gt; and &lt;code&gt;default-terminal &quot;screen-256color&quot;&lt;/code&gt;. However, I want to know how to make neovim correctly recognize ctrl-arrow keys without using &lt;code&gt;tmux&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My values for &lt;code&gt;$TERM&lt;/code&gt; are: &lt;code&gt;xterm&lt;/code&gt; before starting nvim, &lt;code&gt;xterm-256color&lt;/code&gt; inside nvim.&lt;/p&gt;&#xA;" OwnerUserId="13992" LastEditorUserId="13992" LastEditDate="2019-10-06T14:18:42.167" LastActivityDate="2019-10-06T14:18:42.167" Title="Make Ctrl + arrows work inside neovim" Tags="|neovim|terminal|putty|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="21363" PostTypeId="2" ParentId="21360" CreationDate="2019-09-30T20:29:36.677" Score="2" Body="&lt;p&gt;As stated in your comment you have &lt;code&gt;cindent&lt;/code&gt; and &lt;code&gt;cinoptions&lt;/code&gt; set like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cindent&#xA;set cinoptions=N-s,g0,:0,(0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The options &lt;code&gt;cindent&lt;/code&gt; should only be set for the file types you want to use it. It is set automatically for the C or CPP file types (assuming you have &lt;code&gt;filetype indent on&lt;/code&gt; in your vimrc [or better: &lt;code&gt;filetype plugin indent on&lt;/code&gt;]).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remove the line &lt;code&gt;set cindent&lt;/code&gt; from your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;BTW: If you want to change filetype specific settings I recommend to work with a file in &lt;code&gt;~/.vim/after/ftplugin&lt;/code&gt; (e.g. &lt;code&gt;~/.vim/after/ftplugin/c.vim&lt;/code&gt; to change settings for the C filetype). See &lt;code&gt;:help ftplugin-overrule&lt;/code&gt;, especially point 3.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-09-30T20:29:36.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21364" PostTypeId="2" ParentId="21260" CreationDate="2019-09-30T20:57:24.617" Score="2" Body="&lt;p&gt;AFAIK, there's no &quot;good&quot; way to do it, but there is a &quot;hacky&quot; way. Suppose you want &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;c-l&amp;gt;&lt;/code&gt; combination to clear vim internal buffer in both normal and terminal(insert) modes. The mappings in vimrc would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;c-w&amp;gt;&amp;lt;c-l&amp;gt; :set scrollback=1 \| sleep 100m \| set scrollback=10000&amp;lt;cr&amp;gt;&#xA;tmap &amp;lt;c-w&amp;gt;&amp;lt;c-l&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;&amp;lt;c-w&amp;gt;&amp;lt;c-l&amp;gt;i&amp;lt;c-l&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will &quot;clear&quot; the buffer, and return you to terminal &quot;insert&quot; mode if necessary. Extra &lt;code&gt;&amp;lt;c-l&amp;gt;&lt;/code&gt; at the end is to also clear the shell screen, feel free to remove if you wan't need that. Note the sleep, which is required for it to work. Maybe it's possible to use a lower value than 100m, I'm not sure.&lt;/p&gt;&#xA;" OwnerUserId="13992" LastActivityDate="2019-09-30T20:57:24.617" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21365" PostTypeId="1" CreationDate="2019-09-30T22:54:39.800" Score="2" ViewCount="222" Body="&lt;p&gt;I'm dealing with a cryptic issue in my environment which is annoying and I have no idea where to start debugging. Random characters on that aren't actually in the document appear on screen after YCM auto complete menu goes away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pictures are worth a thousand words so here's a demo:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Step 1 - Type a variable name&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jeEgn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jeEgn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Step 2 - Add a &lt;code&gt;.&lt;/code&gt; and YCM auto complete follows&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4x4t9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4x4t9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Step 3 - Delete the &lt;code&gt;.&lt;/code&gt; and get annoyed by floating characters&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5fev9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5fev9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone seen this before? I don't what the possible causes maybe which is why I also don't know what the relevant details are. If you think I should add something, just add and comment and I'll add it.&lt;/p&gt;&#xA;" OwnerUserId="25041" LastActivityDate="2022-01-07T22:02:28.487" Title="Characters from YCM completion menu not cleared in Vim" Tags="|plugin-you-complete-me|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21366" PostTypeId="2" ParentId="21361" CreationDate="2019-09-30T23:04:51.190" Score="3" Body="&lt;p&gt;I've managed to write something that achieves desired effect.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! Terminal_cd()&#xA;        if &amp;amp;buftype == 'terminal'&#xA;                call chansend(b:terminal_job_id, 'NVIM= cd &amp;quot;' . getcwd() . &amp;quot;\&amp;quot;\&amp;lt;cr&amp;gt;&amp;quot;)&#xA;        endif&#xA;endfunction&#xA;&#xA;function! Terminal_restore()&#xA;        let curtab = tabpagenr()&#xA;        let curwin = winnr()&#xA;        tabdo windo call Terminal_cd()&#xA;        exec curtab . 'tabn'&#xA;        exec curwin . 'wincmd w'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I call &lt;code&gt;Terminal_restore()&lt;/code&gt; after sourcing the session file. Since I already have vim automatically change working directory along with the shell &lt;code&gt;cd&lt;/code&gt;, this seems to be good enough. Unsetting &lt;code&gt;NVIM&lt;/code&gt; during restore is done because it is used to detect nvim session and calls &lt;code&gt;:lcd&lt;/code&gt; automatically from shell function.&lt;/p&gt;&#xA;" OwnerUserId="13992" LastEditorUserId="13992" LastEditDate="2023-04-18T21:29:42.777" LastActivityDate="2023-04-18T21:29:42.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21367" PostTypeId="1" AcceptedAnswerId="21421" CreationDate="2019-10-01T05:39:15.393" Score="3" ViewCount="287" Body="&lt;p&gt;I am using ultisnips with &lt;a href=&quot;https://castel.dev/post/lecture-notes-1/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gilles Castel's&lt;/a&gt; subscript snippet along with a snippet I found on SE to create matrices in latex rather quickly. Unfortunately, I can't use the matrices snippet because it keeps triggering the subscript snippet and I'm not sure how to make the two work together. &#xA;The snippet for matrices is defined as follows, (there is a separate python function it calls which can be found &lt;a href=&quot;https://vi.stackexchange.com/questions/17439/easiest-way-to-insert-latex-matrix?newreg=74a09d2f2e3e4abea8fba2a947ca6b31&quot;&gt;here&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;priority 1100&#xA;pre_expand &quot;create_matrix(snip)&quot;&#xA;snippet &quot;(small|[bBpvV])?mat(rix)?(\d+)x(\d+)&quot; &quot;Generate (small|[bBpvV])?matrix of *rows* by *columns*&quot; br&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The snippets for the subscripting are defined as follows,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;context &quot;math()&quot;&#xA;snippet '([A-Za-z])(\d)' &quot;auto subscript&quot; wrA&#xA;`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)`&#xA;endsnippet&#xA;&#xA;context &quot;math()&quot;&#xA;snippet '([A-Za-z])_(\d\d)' &quot;auto subscript2&quot; wrA&#xA;`!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, whenever I try to use the first snippet, e.g. by typing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bmat3x3&amp;lt;TAB&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The subscript snippet triggers and instead outputs&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bmat3x_3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can make it so that the subscript snippet does not trigger in this case? I was thinking perhaps there's a way to check if the current word contains &quot;bmat&quot;. I'm sorry I'm not familiar with regular expressions as I feel like if I was I could write some sort of if statement evaluating the word to only trigger when the word did not contain bmat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="25029" LastEditorUserId="25029" LastEditDate="2019-10-02T05:04:21.267" LastActivityDate="2019-10-05T08:26:01.737" Title="Stop Snippet from Triggering Inside Other Snippet" Tags="|filetype-tex|plugin-ultisnips|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21368" PostTypeId="1" AcceptedAnswerId="21375" CreationDate="2019-10-01T09:02:14.563" Score="0" ViewCount="97" Body="&lt;p&gt;I am pretty advanced in Vim. But one thing I am missing: how to put many Perl-Filters into Vim and run one of them over a selection. I was in former Times user of BBEdit, where I have set up many Perl-Filters, about 240 for Math, Text, Sorting, LaTeX, HTML ... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would it possible to put them into my &lt;code&gt;~/.vim&lt;/code&gt; and invoke them for a selection?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas? Thank you in advance&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here an example. Problem copying from PDF-Files is the encoding of Umlauts. See also the comment in this filter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl &#xA;&#xA;# this filter is looking a bit strange. &#xA;# but copying from a pdf file some text with &#xA;# German Umlauts gives you double letters&#xA;# and not unicode letters. Don't know &#xA;# how to explain it more precisely. &#xA;# So the letter in the search and replace&#xA;# here are not the same. &#xA;# And in Articles the hyphenation needs to &#xA;# be removed&#xA;&#xA;use warnings;&#xA;use strict;&#xA;&#xA;&#xA;while (&amp;lt;&amp;gt;) {&#xA;    s/- //g;&#xA;    s/’/'/g;&#xA;    s/„/&quot;/g;&#xA;    s/“/&quot;/g;&#xA;    s/­ //g;&#xA;    s/- (?!Euro)//ig;&#xA;    s/–/-/g;&#xA;    s/ü/ü/g;&#xA;    s/Ü/Ü/g;&#xA;    s/ö/ö/g;&#xA;    s/Ö/Ö/g;&#xA;    s/ß/ß/g;&#xA;    s/ä/ä/g;&#xA;    s/ç/ç/g;&#xA;    s/„/&amp;lt;em&amp;gt;„/g;&#xA;    s/“/“&amp;lt;\/em&amp;gt;/g;&#xA;    s/è/è/g;&#xA;    s/é/é/g;&#xA;    print;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25048" LastEditorUserId="51" LastEditDate="2021-07-28T10:28:23.400" LastActivityDate="2021-07-28T10:28:23.400" Title="Put many Perl-Filters into ~/.vim" Tags="|filetype-perl|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21370" PostTypeId="1" AcceptedAnswerId="21371" CreationDate="2019-10-01T11:38:19.800" Score="1" ViewCount="325" Body="&lt;p&gt;I have NVIM v0.4.2 and can run &lt;code&gt;:terminal&lt;/code&gt;. Despite that, &lt;code&gt;echo has('terminal')&lt;/code&gt; gives &lt;code&gt;0&lt;/code&gt;. In addition, if I try to run a command of &lt;a href=&quot;https://github.com/williamjameshandley/vimteractive&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimteractive&lt;/a&gt;, an error occurs with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Your version of vim is not compiled with +terminal. Cannot use vimteractive.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I missing here?&lt;/p&gt;&#xA;" OwnerUserId="6349" LastEditorUserId="1841" LastEditDate="2019-10-01T11:49:57.890" LastActivityDate="2019-10-01T11:57:17.403" Title="I can run :terminal in Neovim, but it thinks terminal is missing" Tags="|neovim|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21371" PostTypeId="2" ParentId="21370" CreationDate="2019-10-01T11:57:17.403" Score="4" Body="&lt;p&gt;&lt;code&gt;has('terminal')&lt;/code&gt; is for Vim only. In Neovim this feature is always present, and so checking it is &lt;em&gt;not&lt;/em&gt; supported.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:h feature-compile&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Nvim always includes ALL features, in contrast to Vim (which ships with&#xA;various combinations of 100+ optional features). Think of it as a leaner&#xA;version of Vim's &quot;HUGE&quot; build. This reduces surface area for bugs, and&#xA;removes a common source of confusion and friction for users.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-01T11:57:17.403" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21372" PostTypeId="2" ParentId="21260" CreationDate="2019-10-01T12:44:12.353" Score="0" Body="&lt;pre&gt;&lt;code&gt;&#xA;function! ClearTerminal()&#xA;  set scrollback=1&#xA;  let &amp;amp;g:scrollback=1&#xA;  echo &amp;amp;scrollback&#xA;  call feedkeys(&quot;\i&quot;)&#xA;  call feedkeys(&quot;clear\&amp;lt;CR&amp;gt;&quot;)&#xA;  call feedkeys(&quot;\&amp;lt;C-\&amp;gt;\&amp;lt;C-n&amp;gt;&quot;)&#xA;  call feedkeys(&quot;\i&quot;)&#xA;  sleep 100m&#xA;  let &amp;amp;scrollback=s:scroll_value&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22010" LastActivityDate="2019-10-01T12:44:12.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21373" PostTypeId="1" AcceptedAnswerId="21374" CreationDate="2019-10-01T16:08:28.180" Score="3" ViewCount="172" Body="&lt;p&gt;My experiments generate several log files, which I sometimes monitor manually. Some of the log files have an error message in the last line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to open all log files with the cursor located at the last line. One solution can be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim file1.log:128 file2.log:277&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with last line numbers &lt;code&gt;128&lt;/code&gt; and &lt;code&gt;277&lt;/code&gt; determined by some wrapper code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simpler solution?&lt;/p&gt;&#xA;" OwnerUserId="21088" LastEditorUserId="10604" LastEditDate="2019-10-04T13:22:03.267" LastActivityDate="2019-10-04T13:22:03.267" Title="How to open multiple files with cursor for all files being at the last line?" Tags="|multiple-files|line-numbers|open|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21374" PostTypeId="2" ParentId="21373" CreationDate="2019-10-01T17:41:30.620" Score="4" Body="&lt;p&gt;You can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim *.log +'argdo norm! G'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%5b%2bcmd%5d&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h [+cmd]&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/editing.txt.html#%3Aargdo&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :argdo&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://vimhelp.appspot.com/various.txt.html#%3Anorm&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :norm&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;+ [cmd]&lt;/code&gt; allows you to run an ex command when you start vim and the command &lt;code&gt;argdo norm! G&lt;/code&gt; will run &lt;code&gt;norm! G&lt;/code&gt; on all the files being opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course you can replace &lt;code&gt;*.log&lt;/code&gt; by the list of files you want to open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT&lt;/em&gt; to address the comments:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3A%24&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :$&lt;/code&gt;&lt;/a&gt; being a valid ex commands &lt;code&gt;norm! G&lt;/code&gt; can be replaced by &lt;code&gt;$&lt;/code&gt; to save some keystrokes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim *.log +'argdo $'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if you invoke Vim with the &lt;code&gt;-p&lt;/code&gt; parameter which opens every buffers in their own tab you can replace &lt;code&gt;argdo&lt;/code&gt; by &lt;code&gt;tabdo&lt;/code&gt; to have the command executed on every tab instead of every buffers.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-10-03T07:30:31.997" LastActivityDate="2019-10-03T07:30:31.997" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="21375" PostTypeId="2" ParentId="21368" CreationDate="2019-10-01T19:33:30.170" Score="3" Body="&lt;p&gt;You could use &lt;code&gt;!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mark the lines you want to filter. Then hit &lt;code&gt;!&lt;/code&gt;. The cursor will jump to the command line prefilled with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then just type the filter you want to use. E.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!~/filters/fix-umlauts.pl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To filter the entire file use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!~/filters/fix-umlauts.pl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To only filter the current line, just hit &lt;code&gt;!!&lt;/code&gt; and the command line is prefilled with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... just type your command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.!~/filters/fix-umlauts.pl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also work with text-objects (see &lt;code&gt;:help text-objects&lt;/code&gt;). To filter the current paragraph just hit &lt;code&gt;!ip&lt;/code&gt; and the command line is prefilled with something like (for a paragraph with 6 line):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,.+5!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Means: First line of paragraph plus 5 following lines). Again type your command. Note that in this context the text-objects always select the entire line. E.g. &lt;code&gt;!aw&lt;/code&gt; will filters the entire line of the selected word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help !&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: If the filters are in your shells &lt;code&gt;PATH&lt;/code&gt;, you can just type the command name.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-10-03T08:34:43.267" LastActivityDate="2019-10-03T08:34:43.267" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21376" PostTypeId="2" ParentId="21337" CreationDate="2019-10-01T22:04:57.063" Score="1" Body="&lt;p&gt;I ended up using this command in my vimrc with fzf.vim, specifically filtering directories in my current git repo.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:append_dir_with_fzf(line)&#xA;  call fzf#run(fzf#wrap({&#xA;    \ 'options': ['--prompt', a:line.'&amp;gt; '],&#xA;    \ 'source': 'git ls-files $(git rev-parse --show-toplevel) | xargs -n 1 dirname | uniq',&#xA;    \ 'sink': {line -&amp;gt; feedkeys(&quot;\&amp;lt;esc&amp;gt;:&quot;.a:line.line, 'n')}}))&#xA;  return ''&#xA;endfunction&#xA;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-d&amp;gt; &amp;lt;sid&amp;gt;append_dir_with_fzf(getcmdline())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14314" LastActivityDate="2019-10-01T22:04:57.063" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21377" PostTypeId="1" AcceptedAnswerId="21397" CreationDate="2019-10-01T23:12:13.953" Score="0" ViewCount="1844" Body="&lt;p&gt;I've got a file open in Neovim like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;neovim test.rb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And a split open like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:split ruby test.rb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I rerun the split command each time I write a save in the original window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've updated the question to make it clearer, sorry about that. I want to edit in one buffer then run the changes in the terminal split.&lt;/p&gt;&#xA;" OwnerUserId="19883" LastEditorUserId="19883" LastEditDate="2019-10-02T21:06:11.240" LastActivityDate="2019-10-03T11:12:01.313" Title="Neovim: run cmd on write" Tags="|neovim|terminal|vim-windows|" AnswerCount="1" CommentCount="7" FavoriteCount="0" ClosedDate="2019-10-23T05:32:06.113" ContentLicense="CC BY-SA 4.0" />
  <row Id="21378" PostTypeId="2" ParentId="16906" CreationDate="2019-10-01T23:22:17.213" Score="1" Body="&lt;p&gt;If PHP is available, add the tool &lt;code&gt;jf&lt;/code&gt; as a &lt;a href=&quot;https://whitephp.net/2018/07/31/jf-cli-json-formatter.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;JSON Formatter&lt;/a&gt; by Composer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ composer global require codegear/json-formatter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then Format current file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!jf %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or add a keymap in vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;jf :%!jf %&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25052" LastActivityDate="2019-10-01T23:22:17.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21379" PostTypeId="2" ParentId="19176" CreationDate="2019-10-02T02:12:54.857" Score="0" Body="&lt;p&gt;I do this in GUI Vim by setting the font to a bold font:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set guifont=Menlo-Bold:h13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To choose various fonts just use &lt;code&gt;:set guifont=*&lt;/code&gt; and you'll get a dialog chooser. After you've chosen your preferred font use &lt;code&gt;:set guifont?&lt;/code&gt; to see the font specification that you need to put in your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For console Vim fandom wiki says &quot;Console Vim uses whatever font the console/terminal is using. ... Consult the documentation or manpages for your terminal... Vim cannot use a different font than the rest of the terminal.&quot; &lt;a href=&quot;https://vim.fandom.com/wiki/Change_font&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vim.fandom.com/wiki/Change_font&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore to use a bold font in console Vim, change the font of your terminal to a bold font.&lt;/p&gt;&#xA;" OwnerUserId="19972" LastEditorUserId="19972" LastEditDate="2019-10-03T01:12:52.100" LastActivityDate="2019-10-03T01:12:52.100" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21381" PostTypeId="2" ParentId="20971" CreationDate="2019-10-02T12:25:26.433" Score="3" Body="&lt;p&gt;Quote from vim-fugitive &lt;code&gt;README&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;FAQ Why can't I enter my password when I :Gpush?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;It is highly recommended to use SSH keys or credentials caching to&#xA;  avoid entering your password on every upstream interaction. If this&#xA;  isn't an option, the official solution is to use the core.askPass Git&#xA;  option to request the password via a GUI. Fugitive will configure this&#xA;  for you automatically if you have ssh-askpass or git-gui installed;&#xA;  otherwise it's your responsibility to set this up.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;As an absolute last resort, you can invoke :Git --paginate push.&#xA;  Fugitive recognizes the pagination request and fires up a :terminal,&#xA;  which allows for interactive password entry.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, in your case, there are two possible solutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:Git --paginate push&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Switch to ssh and authenticate with a key&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13992" LastActivityDate="2019-10-02T12:25:26.433" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21383" PostTypeId="2" ParentId="2883" CreationDate="2019-10-02T13:29:10.630" Score="2" Body="&lt;h2&gt;How to disable horizontal scrolling&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I've written a solution that disables horizontal scrolling, (by riffing off of &lt;a href=&quot;https://vi.stackexchange.com/questions/2883/how-to-disable-horizontal-scrolling#comment23488_2883&quot;&gt;@ЯрославРахматуллин's suggestion&lt;/a&gt;), but I don't think you're going to like it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup NoScrollPlease&#xA;  autocmd!&#xA;  autocmd CursorMoved * norm!99zH&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This prevents scrolling to the right by the incredibly precise method of just scrolling back again.*&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* Because I don't know how far you've scrolled to the right or how long your lines are, I'm scrolling the arbitrarily &quot;far&quot; amount of 99 half screen widths. Note also that I'm not bothering to check whether or not you've actually scrolled to the right before scrolling &quot;back&quot; to the left. If you actually intend to use this solution you might want to knock something up by comparing the values of &lt;code&gt;getcurpos()&lt;/code&gt;, &lt;code&gt;'sidescroll'&lt;/code&gt; and &lt;code&gt;'columns'&lt;/code&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Why you're not going to want to do so&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The reason that you're not going to use this is that underlying the scrolling problem is another issue: Vim won't let you move the cursor &quot;off screen&quot;. Therefore, if you scroll to the left in a way such that the cursor would be off screen after the scroll, Vim helpfully brings the cursor along with it and moves it to the left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But because the calculation it's using for whether the cursor is on screen is the same as the one it's using for deciding whether to scroll in the original problem, the net effect is that with this &quot;solution&quot; in place, if you attempt to move the cursor to the right in a situation that would normally cause a sideways scroll, now the cursor refuses to move at all.**&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;**To be slightly more precise, depending on the current position and the movement, the cursor may move rightwards; it just won't move past the position where a scroll would normally occur.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Other options?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;So I'm afraid your planned workaround isn't going to pan out. If you want a &lt;em&gt;workable&lt;/em&gt; solution to the general problem, it's going to need to be implemented in the Vim source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/2883/how-to-disable-horizontal-scrolling#comment3054_2883&quot;&gt;you've already noted&lt;/a&gt;, this is unlikely to arrive any time soon, so I'm afraid your best bet for a workaround to the specific instance of the issue shown in your gif is to petition the plugin author to stop using &lt;code&gt;conceal&lt;/code&gt; entirely and instead remove the hidden text from the buffer entirely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the unconcealed output and the mention of &lt;code&gt;vim-plugin-AnsiEsc&lt;/code&gt; in &lt;a href=&quot;https://github.com/tbabej/taskwiki/blob/master/doc/taskwiki.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;the documentation&lt;/a&gt; this &lt;em&gt;might&lt;/em&gt; be something it's possible for them to implement, but it's hard to say for sure without knowledge of how the plugin functions.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-10-04T11:16:08.627" LastActivityDate="2019-10-04T11:16:08.627" CommentCount="0" CommunityOwnedDate="2019-10-18T10:35:44.960" ContentLicense="CC BY-SA 4.0" />
  <row Id="21384" PostTypeId="2" ParentId="8741" CreationDate="2019-10-02T17:59:10.663" Score="0" Body="&lt;p&gt;I use &lt;code&gt;&amp;lt;Leader&amp;gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; as a shortcut to &lt;code&gt;:hls&lt;/code&gt; and have my leader set as space.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = &quot;\&amp;lt;Space&amp;gt;&quot;&#xA;nmap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;&amp;lt;Esc&amp;gt; :set hls!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After searching an item will be highlighted, to turn it off, hit &lt;code&gt;&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;.  And if you decide you want to redisplay the search results, hit &lt;code&gt;&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;.  The &lt;code&gt;hls!&lt;/code&gt; means map this key binding to toggle the setting for &lt;code&gt;hls&lt;/code&gt; (shorthand for &lt;code&gt;hlsearch&lt;/code&gt;, i.e. search result highlighting) (so the &lt;code&gt;!&lt;/code&gt; toggles the setting right before it).&lt;/p&gt;&#xA;" OwnerUserId="18135" LastEditorUserId="343" LastEditDate="2019-10-02T19:01:50.173" LastActivityDate="2019-10-02T19:01:50.173" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21385" PostTypeId="2" ParentId="21340" CreationDate="2019-10-02T19:05:37.247" Score="1" Body="&lt;p&gt;You can use fuzzy searching using FZF(as I do). Check &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/junegunn/fzf.vim&lt;/a&gt;  .&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetCommands()&#xA;let lines=[]&#xA;let nu=histnr(&quot;cmd&quot;)&#xA;for i in range(1,nu)&#xA;    let lines+=[histget(&quot;cmd&quot;,i)]&#xA;endfor&#xA;return lines&#xA;endfunction&#xA;&#xA;function! HandleCommand(item)&#xA;    call feedkeys(&quot;q:&quot;)&#xA;    call feedkeys(&quot;G?\\V&quot;.escape(a:item,'\/?').&quot;\&amp;lt;CR&amp;gt;&quot;)&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-a&amp;gt;c :call fzf#run({'source': GetCommands(),'sink': function('HandleCommand'),'options': '-m'} )&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press &lt;code&gt;&amp;lt;c-a&amp;gt;c&lt;/code&gt; , it displays me a fuzzy search for command. Then, when I press enter, it goes to the command in the command window. If I press another enter it executes. I can also edit the command.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also want to do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set history=10000&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-a&amp;gt;&amp;lt;C-a&amp;gt; &amp;lt;C-a&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to save longer command history, and the functionality of &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-10-02T19:05:37.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21386" PostTypeId="1" AcceptedAnswerId="21935" CreationDate="2019-10-02T19:18:30.283" Score="2" ViewCount="836" Body="&lt;p&gt;Sometimes I want Ultisnip not to expand a snippet because I need this word as it was typed, even though is mapped to a snippet(of course in a perfect world of perfect snippets this wouldn't have happened). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to press &lt;code&gt;ESC&lt;/code&gt; and 2 times &lt;code&gt;u&lt;/code&gt; and even so it doesn't work sometimes. Any other way? &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-11-15T18:33:15.747" Title="Don't trigger an expansion in Ultisnips" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21387" PostTypeId="2" ParentId="21355" CreationDate="2019-10-02T19:24:28.827" Score="0" Body="&lt;p&gt;Sometimes is good to define an autocmd just for your file type. You can put it in your &lt;code&gt;.vimrc&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd filetype tex nmap &amp;lt;buffer&amp;gt; K &amp;lt;leader&amp;gt;lv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;K&lt;/code&gt; is mainly for documentation. But in tex files I want it to trigger to go line(vimtex). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, you can type any ex cmd instead of nmap. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-10-02T19:24:28.827" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21388" PostTypeId="1" AcceptedAnswerId="21395" CreationDate="2019-10-02T21:46:25.190" Score="1" ViewCount="1515" Body="&lt;h2&gt;Scenario&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I would like to perform the following,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Visually select some text that spans multiple lines and occurs multiple times in the file: &lt;code&gt;V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Yank to buffer: &lt;code&gt;y&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Perform substitute with text from buffer: (&lt;code&gt;:%s,&amp;lt;Ctrl-r&amp;gt; 0,new text,g&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Example&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Given the following example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;metadata:&#xA;  name: redis&#xA;spec:&#xA;  version: 5.0&#xA;...&#xA;metadata:&#xA;  name: redis&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to change all occurrences of metadata.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output: &lt;code&gt;:%s,metadata:^M  name: redis,some other text,g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Error: &lt;code&gt;E486: Pattern not found: metadata:^M  name: redis&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="25067" LastEditorUserId="343" LastEditDate="2019-10-03T12:11:34.793" LastActivityDate="2019-10-03T12:11:34.793" Title="Perform change to all occurrences of multi-line selection" Tags="|substitute|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21389" PostTypeId="1" CreationDate="2019-10-02T23:31:13.333" Score="1" ViewCount="119" Body="&lt;p&gt;I have python2 and python3 compiled into my vim &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --version&#xA;VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct  2 2019 14:25:42)&#xA;Included patches: 1-2109&#xA;Compiled by user@enterprise&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl               -farsi             -mouse_sysmouse    -tag_any_white&#xA;+arabic            +file_in_path      +mouse_urxvt       -tcl&#xA;+autocmd           +find_in_path      +mouse_xterm       +termguicolors&#xA;+autochdir         +float             +multi_byte        +terminal&#xA;-autoservername    +folding           +multi_lang        +terminfo&#xA;+balloon_eval      -footer            -mzscheme          +termresponse&#xA;+balloon_eval_term +fork()            +netbeans_intg     +textobjects&#xA;+browse            +gettext           +num64             +textprop&#xA;++builtin_terms    -hangul_input      +packages          +timers&#xA;+byte_offset       +iconv             +path_extra        +title&#xA;+channel           +insert_expand     +perl              +toolbar&#xA;+cindent           +job               +persistent_undo   +user_commands&#xA;+clientserver      +jumplist          +postscript        +vartabs&#xA;+clipboard         +keymap            +printer           +vertsplit&#xA;+cmdline_compl     +lambda            +profile           +virtualedit&#xA;+cmdline_hist      +langmap           +python/dyn        +visual&#xA;+cmdline_info      +libcall           +python3/dyn       +visualextra&#xA;+comments          +linebreak         +quickfix          +viminfo&#xA;+conceal           +lispindent        +reltime           +vreplace&#xA;+cryptv            +listcmds          +rightleft         +wildignore&#xA;+cscope            +localmap          +ruby              +wildmenu&#xA;+cursorbind        +lua               +scrollbind        +windows&#xA;+cursorshape       +menu              +signs             +writebackup&#xA;+dialog_con_gui    +mksession         +smartindent       +X11&#xA;+diff              +modify_fname      +sound             -xfontset&#xA;+digraphs          +mouse             +spell             +xim&#xA;+dnd               +mouseshape        +startuptime       +xpm&#xA;-ebcdic            +mouse_dec         +statusline        +xsmp_interact&#xA;+emacs_tags        -mouse_gpm         -sun_workshop      +xterm_clipboard&#xA;+eval              -mouse_jsbterm     +syntax            -xterm_save&#xA;+ex_extra          +mouse_netterm     +tag_binary&#xA;+extra_search      +mouse_sgr         -tag_old_static&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/home/user/.local/opt/vim/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16   -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux   -lcanberra -ldl  -L/usr/lib -llua5.3 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.28/CORE -lperl -ldl -lm -lpthread -lcrypt    -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that I can't use python2 and python3 at the same time since I'm running it on Ubuntu (see the relevant discussion &lt;a href=&quot;https://vi.stackexchange.com/questions/779/how-do-i-get-vim-to-be-able-to-run-both-python-and-python3-on-a-linux-system-in?answertab=active#tab-top&quot;&gt;here&lt;/a&gt;). It looks like whenever I run vim, it is choosing python3. However every time I invoke vim I  get a following message &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is python3 related. I'm sure the issue will be fixed later, but for now I just want to disable (not recompile) python3 support whenever I run vim. Is there a way to do it? Say something like &lt;code&gt;vim --no-python3 myfile.txt&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="2865" LastEditorUserId="10604" LastEditDate="2019-10-04T13:26:50.467" LastActivityDate="2020-03-02T18:03:50.580" Title="run vim without python3 suppport" Tags="|vimscript-python|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21390" PostTypeId="2" ParentId="11310" CreationDate="2019-10-03T00:31:20.407" Score="10" Body="&lt;p&gt;A 'scratch' buffer is just an informal term for a place to type arbitrary temporary content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following the accepted answer and another question, I created the following function in my vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function creates a blank buffer in the current window and names it 'scratch'. The scratch buffer is not protected if you try to quit. It will be discarded without prompting even with unsaved changes if you quit Vim or wipe it (&lt;code&gt;:bw&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put this function in your vimrc. To create a scratch buffer use &lt;code&gt;:call Scratch()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Scratch()&#xA;    split&#xA;    noswapfile hide enew&#xA;    setlocal buftype=nofile&#xA;    setlocal bufhidden=hide&#xA;    &quot;setlocal nobuflisted&#xA;    &quot;lcd ~&#xA;    file scratch&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can test this quickly by yanking the lines and then &lt;code&gt;:@&quot;&lt;/code&gt;. You can then try &lt;code&gt;:call Scratch()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A split is used so your current buffer is not affected when you create the scratch buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If you prefer to omit the &lt;code&gt;split&lt;/code&gt; from the function then your current buffer would be &quot;hidden&quot; (no longer in a window) when you create the scratch buffer. Vim will still stop and prompt you if you try to quit with unsaved changes in that buffer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The scratch buffer would normally have the same working directory of the buffer you are in when you call the Scratch function. I've included a commented out line to change the scratch buffer working directory to home. This is for those with funny status lines that may display the path of the current directory as the buffer path. Or just for those who prefer it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can set the scratch buffer to be &quot;listed&quot; or &quot;unlisted&quot; (listed by default). If you make it unlisted you won't see it in your &lt;code&gt;:buffers&lt;/code&gt; list, but it will be in &lt;code&gt;:buffers!&lt;/code&gt;. Uncomment the &lt;code&gt;nobuflisted&lt;/code&gt; line if you prefer it to be unlisted. Listed or unlisted, you can always change to your scratch buffer with &lt;code&gt;:b scratch&lt;/code&gt; anyway. Making the scratch buffer listed makes it slightly more accessible. For instance &lt;code&gt;:sball&lt;/code&gt; will include it in a split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;:bw&lt;/code&gt; (buffer wipe) on the scratch buffer Vim will delete the content and remove the buffer without warning. If you use &lt;code&gt;:bd&lt;/code&gt; (buffer delete) on the scratch buffer Vim will drop the content without warning and make the buffer unlisted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;can&lt;/em&gt; create multiple scratch buffers. Vim starts to complain but you still end up with additional ones.&lt;/p&gt;&#xA;" OwnerUserId="19972" LastEditorUserId="19972" LastEditDate="2019-10-11T01:02:15.317" LastActivityDate="2019-10-11T01:02:15.317" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21392" PostTypeId="1" AcceptedAnswerId="21393" CreationDate="2019-10-03T01:48:46.180" Score="12" ViewCount="2913" Body="&lt;p&gt;I have a variable &lt;code&gt;foo&lt;/code&gt; with &lt;code&gt;let foo='value'&lt;/code&gt;, and a function &lt;code&gt;F&lt;/code&gt; like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function F()&#xA;  return 'value'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and I want to use them&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;in an option: &lt;code&gt;:set option=foo&lt;/code&gt;, &lt;code&gt;:set option=F()&lt;/code&gt;; or&lt;/li&gt;&#xA;&lt;li&gt;in a command: &lt;code&gt;:edit foo&lt;/code&gt;, &lt;code&gt;:edit F()&lt;/code&gt;; or&lt;/li&gt;&#xA;&lt;li&gt;in a mapping: &lt;code&gt;:nnoremap f :foo&amp;lt;CR&amp;gt;&lt;/code&gt;, &lt;code&gt;:nnoremap f :F()&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;How can I do this? In other words, how can I reference variables as command arguments?&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2023-01-04T21:03:22.600" LastActivityDate="2023-01-04T21:03:22.600" Title="How do I use a variable or return value in option, command, or mapping?" Tags="|key-bindings|command-line|options|variables|string-manipulation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21393" PostTypeId="2" ParentId="21392" CreationDate="2019-10-03T01:48:46.180" Score="20" Body="&lt;p&gt;The reason your example attempts don't work is that in many locations text is simply seen as a literal string, rather than VimScript. So functions, variables, and the like don't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let var='value'&#xA;:set option=var&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then Vim will simply set the value of &lt;code&gt;option&lt;/code&gt; to the literal value &lt;code&gt;var&lt;/code&gt;, since it doesn't recognize VimScript in &lt;code&gt;:set&lt;/code&gt;. The same applies to &lt;code&gt;:map&lt;/code&gt; and many other locations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, most colon/Ex/&lt;code&gt;:&lt;/code&gt; commands do not evaluate VimScript.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;:execute&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Not all is lost, since you can still build a string with &lt;code&gt;:execute&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let var='value'&#xA;:execute ':set option=' . var&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:execute&lt;/code&gt; command executes the given VimScript expression. In this case, we build a string using the variable, and what &lt;code&gt;:execute&lt;/code&gt; sees is &lt;code&gt;:set option=value&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can use any Vim expression; some more examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Function return value&#xA;:execute 'set option=' . Fun()&#xA;&#xA;&quot; You don't need to use string concatenation; all arguments are &#xA;&quot; concatenated automatically. A space is added.&#xA;:execute 'edit' var&#xA;:execute 'edit' Fun()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map&lt;/code&gt; expands special key sequences like &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;. To get them in an execute, you need to prepend the &lt;code&gt;&amp;lt;&lt;/code&gt; with a &lt;code&gt;\&lt;/code&gt;: &lt;code&gt;&quot;\&amp;lt;CR&amp;gt;&quot;&lt;/code&gt;. You &lt;em&gt;need&lt;/em&gt; to use double quotes, single quotes won't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let key = 'h'&#xA;:execute 'nnoremap ' . key . &quot; :echo 'hello'\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because you're building VimScript code in a VimScript string things tend to look rather ugly. C'est la vie. Depending on your personal tastes, &lt;code&gt;printf()&lt;/code&gt; can make things a bit easier on the eyes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute printf(&quot;nnoremap %s :echo 'hello'\&amp;lt;CR&amp;gt;&quot;, key)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: it's very common to abbreviate &lt;code&gt;:execute&lt;/code&gt; to &lt;code&gt;:exe&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#%3Aexecute&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :execute&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Expression mappings&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Finally, you can use expression mappings to use a Vim expression for the entire right-hand side.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Execute the contents of the current line as a Vim command.&#xA;:nnoremap &amp;lt;expr&amp;gt; f getline('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The biggest difference with &lt;code&gt;:execute&lt;/code&gt; is that the expression is run when the key is pressed, and not when the command is defined. So every time you press &lt;code&gt;f&lt;/code&gt; in the above example &lt;code&gt;getline()&lt;/code&gt; gets the value of the current line. If we had used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute ':nnoremap f' getline('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it would get the value of the line &lt;em&gt;once&lt;/em&gt;. So if you had been on the line &lt;code&gt;gg&lt;/code&gt; it would be the same as typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap f gg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/map.txt.html#%3Amap-%3Cexpr%3E&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :map-&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interactively and in mappings, the expression register &lt;code&gt;&quot;=&lt;/code&gt; can be used to achieve similar effects. Its usage stands out as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap keys :put =Fun()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap keys &amp;lt;C-r&amp;gt;=Fun()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;:let-&amp;amp;&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;As a special case with options, you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let &amp;amp;option = 'value'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;syntax to have a similar effect as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute 'set option='.value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-10-03T18:57:57.700" LastActivityDate="2019-10-03T18:57:57.700" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="21394" PostTypeId="2" ParentId="21389" CreationDate="2019-10-03T05:11:41.290" Score="1" Body="&lt;p&gt;Vim (when configured for dynamic python) chooses the python version to use based on the first command that run. You should use :python as the first command that runs in .vimrc or even before (config/init.vim) .  It will make vim keep using python2 and disable py3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But do yourself a favor and just switch to neovim. Neovim supports real dynamic python, in which, at any point one can choose to use either python2 or python3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS &#xA;also the expression &lt;code&gt;has('python3')&lt;/code&gt; is like using python3. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-10-04T16:15:45.503" LastActivityDate="2019-10-04T16:15:45.503" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21395" PostTypeId="2" ParentId="21388" CreationDate="2019-10-03T05:29:52.880" Score="0" Body="&lt;p&gt;You can use &lt;code&gt;vim-visual-multi&lt;/code&gt;. Use multi line mode with &lt;code&gt;\\M&lt;/code&gt;. Select all occurrences with &lt;code&gt;\\A&lt;/code&gt; and do c to change. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other people will tell you the vim way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;%s/pattern\n nextline/something/&lt;/code&gt; (or &lt;code&gt;^v&amp;lt;enter&amp;gt;&lt;/code&gt; instead of \n  - would surely work ). &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-10-03T05:29:52.880" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21396" PostTypeId="1" CreationDate="2019-10-03T09:20:32.817" Score="2" ViewCount="249" Body="&lt;p&gt;I've got a warning on start:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;[coc.nvim] RLS configuration option use_crate_blacklist is deprecated: use crate_blacklist instead&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably I have to put into my &lt;code&gt;coc-settings.json&lt;/code&gt; &quot;rust.crate_blacklist&quot; option as suggested &lt;a href=&quot;https://github.com/neoclide/coc-rls&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. Unfortunately, I've no idea in what context I have to put it. Examples are precious few, and Google won't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my &lt;code&gt;coc-settings.json&lt;/code&gt; there is no mention of Rust since I use &lt;code&gt;coc-rls&lt;/code&gt; extension.&lt;/p&gt;&#xA;" OwnerUserId="21503" LastActivityDate="2019-10-03T09:20:32.817" Title="(coc.nvim) RLS warning: ...use crate_blacklist instead" Tags="|plugin-coc|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21397" PostTypeId="2" ParentId="21377" CreationDate="2019-10-03T11:04:32.963" Score="1" Body="&lt;p&gt;First off, you might like to look into any of the many plugins that incorporate a REPL into Vim (&lt;a href=&quot;https://github.com/jpalardy/vim-slime.git&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-slime&lt;/a&gt; is the one I use). They don't do &lt;em&gt;exactly&lt;/em&gt; what you're asking, but they do something very similar and are far more flexible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want your exact behaviour, though, then here's a proof of concept that shows how you can implement it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup RunCommandOnWrite&#xA;  autocmd!&#xA;  autocmd BufWritePost test.rb call RunCommand()&#xA;augroup END&#xA;&#xA;function! RunCommand() abort&#xA;  &quot; Find terminal&#xA;  windo if &amp;amp;buftype == &quot;terminal&quot; | let s:terminal = bufnr('%') | endif&#xA;&#xA;  &quot; Type in command&#xA;  call term_sendkeys(s:terminal, &quot;ruby test.rb\&amp;lt;CR&amp;gt;&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works by setting up an &lt;a href=&quot;https://www.vimhelp.org/autocmd.txt.html#autocommand&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;autocommand&lt;/code&gt;&lt;/a&gt; to run every time that you save a file named &lt;code&gt;test.rb&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The autocommand calls a function that finds a visible terminal buffer and then sends the keystrokes &lt;code&gt;ruby test.rb&amp;lt;Enter&amp;gt;&lt;/code&gt; to them to run your command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a lot you can/should do to make this more robust, if you're intending to use it. Feel free to ask if you need any tips on how to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to use it, you need to open your terminal by typing &lt;a href=&quot;https://www.vimhelp.org/terminal.txt.html#:terminal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:terminal&lt;/code&gt;&lt;/a&gt; (the &lt;a href=&quot;https://www.vimhelp.org/windows.txt.html#:split&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:split&lt;/code&gt;&lt;/a&gt; command you included in your question does &lt;em&gt;not&lt;/em&gt; run a command or open a terminal) and then return to your ruby file by typing &lt;kbd&gt;Ctrl-W&lt;/kbd&gt;&lt;kbd&gt;Ctrl-W&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's actually unclear from your question whether you need a terminal or a split window at all. If your goal is literally just to run a shell command whenever you save a file, all you need is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup RunCommandOnWrite&#xA;  autocmd!&#xA;  autocmd BufWritePost test.rb !ruby test.rb&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of running a function, this directly invokes the command &lt;code&gt;ruby test.rb&lt;/code&gt; by using &lt;code&gt;:!&lt;/code&gt;. See &lt;a href=&quot;https://www.vimhelp.org/various.txt.html#:!cmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :!cmd&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-10-03T11:12:01.313" LastActivityDate="2019-10-03T11:12:01.313" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21398" PostTypeId="2" ParentId="21388" CreationDate="2019-10-03T11:51:31.107" Score="3" Body="&lt;p&gt;The problem is that the characters used to represent newlines in a buffer are not the same as those needed to match a newline in a regular expression. As eyal kami suggests, you can fix this by manually replacing the Ctrl-M &lt;code&gt;^M&lt;/code&gt; characters in your substitution with &lt;code&gt;\n&lt;/code&gt;, or, perhaps cleaner, you could write a function to do both steps 2 and 3 for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MultiLineSubstitute() abort&#xA;  normal!gvy&#xA;  let expression = substitute(@0, &quot;\&amp;lt;C-J&amp;gt;&quot;, '\\n', 'g')&#xA;  execute '%s,'.expression.','.input(&quot;Replacement: &quot;)&#xA;endfunction&#xA;&#xA;vnoremap &amp;lt;F1&amp;gt; :&amp;lt;C-U&amp;gt;call MultiLineSubstitute()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note however that new lines are far from the only character that has a different meaning in a regular expression. You might want to look into the very nomagic atom (&lt;code&gt;:help /\V&lt;/code&gt;) and the &lt;code&gt;escape()&lt;/code&gt; function to work around this.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-10-03T11:51:31.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21399" PostTypeId="2" ParentId="17" CreationDate="2019-10-03T12:00:35.497" Score="1" Body="&lt;p&gt;Sometimes you need to search for a given symbol within a function/method&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  void f(bool b)&#xA;  {&#xA;    b;&#xA;    b;&#xA;  }&#xA;&#xA;  void g(bool b)&#xA;  {&#xA;    b;  &#xA;    b;  &#xA;    b;  &#xA;    b;  &#xA;  }&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to search for &lt;code&gt;b&lt;/code&gt; in &lt;code&gt;f()&lt;/code&gt; only:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;go to &lt;code&gt;{&lt;/code&gt; of &lt;code&gt;f()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;enter visual mode with &lt;code&gt;V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;go to end of &lt;code&gt;f()&lt;/code&gt; with '%' &lt;/li&gt;&#xA;&lt;li&gt;go to exec line with ':' command.&lt;/li&gt;&#xA;&lt;li&gt;once you are in command line input &lt;code&gt;il b&lt;/code&gt; to get&#xA;&lt;code&gt;:'&amp;lt;,'&amp;gt;il b&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;(enter) you get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b.cpp&#xA;  1:   15     b;&#xA;  2:   16     b;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25069" LastActivityDate="2019-10-03T12:00:35.497" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21400" PostTypeId="1" AcceptedAnswerId="21406" CreationDate="2019-10-03T15:49:09.947" Score="0" ViewCount="188" Body="&lt;p&gt;&lt;code&gt;:help airline&lt;/code&gt; states that variables related to sections can be window-local. The example from help shows how to do it for a plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  function! MyPlugin(...)&#xA;    if &amp;amp;filetype == 'MyPluginFileType'&#xA;      let w:airline_section_a = 'MyPlugin'&#xA;      let w:airline_section_b = '%f'&#xA;      let w:airline_section_c = '%{MyPlugin#function()}'&#xA;      let g:airline_variable_referenced_in_statusline = 'foo'&#xA;    endif&#xA;  endfunction&#xA;  call airline#add_statusline_func('MyPlugin')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to know how can I do it from the window itself, or understand a proper way to configure &lt;code&gt;autocmd&lt;/code&gt; for this purpose. After executing &lt;code&gt;:let w:airline_section_b = 'foo'&lt;/code&gt;, the bar isn't updated. Is there a way to redraw it with new changes? I found &lt;code&gt;:AirlineRefresh&lt;/code&gt;, but it just resets everything to defaults.&lt;/p&gt;&#xA;" OwnerUserId="13992" LastEditorUserId="13992" LastEditDate="2019-10-03T19:08:27.170" LastActivityDate="2019-10-06T14:32:55.857" Title="How do I redraw airline after setting window-local variable" Tags="|plugin-airline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21401" PostTypeId="1" CreationDate="2019-10-03T19:17:57.940" Score="2" ViewCount="187" Body="&lt;p&gt;I'm not interested in loading an item into a specific window. I'm interested in opening/loading quickfix list into a specific window/pane. Searched online everywhere, but couldn't find it. Does anyone know how to do it?&lt;/p&gt;&#xA;" OwnerUserId="2865" LastActivityDate="2019-10-03T20:49:03.360" Title="load quickfixlist into a specific window" Tags="|quickfix|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21402" PostTypeId="2" ParentId="21401" CreationDate="2019-10-03T20:49:03.360" Score="5" Body="&lt;p&gt;I don’t know of a built in way to do that, but here’s a function that will do it for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! OpenQuickfixHere() abort&#xA;  copen&#xA;  let bufn = bufnr('%')&#xA;  let winn = winnr()&#xA;  wincmd p&#xA;  execute 'b'.bufn&#xA;  execute winn.'close'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use it, move the cursor to the window into which you would like to place the quickfix, and run the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call OpenQuickfixHere()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can of course map this or create a custom command for easier access.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works by opening the quickfix (in a new window, as is standard), making a note of the buffer and window numbers, switching back to the original window, loading the quickfix buffer into that window, and then closing the original quickfix window.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-10-03T20:49:03.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21403" PostTypeId="2" ParentId="14403" CreationDate="2019-10-03T21:33:16.180" Score="18" Body="&lt;p&gt;You can also use &lt;code&gt;ctrl + o&lt;/code&gt; to go to the previous jump list, which might be buffer, going backwards. You can keep pressing the same command to go to the previous, previous buffer/jump list.&lt;/p&gt;&#xA;&lt;p&gt;You can also use &lt;code&gt;ctrl + i&lt;/code&gt; to go to the next buffer/jump list, going forward. I.e, if you had pressed &lt;code&gt;ctrl + o&lt;/code&gt; to go to the previous buffer, you can use &lt;code&gt;ctrl + i&lt;/code&gt; to go to the first/original buffer.&lt;/p&gt;&#xA;" OwnerUserId="22643" LastEditorUserId="22643" LastEditDate="2023-11-24T08:34:27.373" LastActivityDate="2023-11-24T08:34:27.373" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21404" PostTypeId="1" AcceptedAnswerId="21405" CreationDate="2019-10-03T23:09:54.657" Score="3" ViewCount="325" Body="&lt;p&gt;For a while, I'd been using &lt;code&gt;:nnoremap &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;h&lt;/code&gt; and &lt;code&gt;:tnoremap &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;h&lt;/code&gt;, et. al. to switch windows. This was working great, so when I started using tabs, I decided to expand this mapping to also switch tabs when I reached the edge of the screen. To do that, I wrote the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! WinTabSwitch(direction)&#xA;    let info = getwininfo(win_getid())[0]&#xA;    if a:direction == 'h' &amp;amp;&amp;amp; info.wincol &amp;lt;= 1&#xA;        execute 'tabprev|99wincmd l'&#xA;    elseif a:direction == 'l' &amp;amp;&amp;amp; info.wincol + info.width &amp;gt;= &amp;amp;columns&#xA;        execute 'tabnext|99wincmd h'&#xA;    else&#xA;        execute 'wincmd '.a:direction&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-H&amp;gt; :call WinTabSwitch('h')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-J&amp;gt; :call WinTabSwitch('j')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-K&amp;gt; :call WinTabSwitch('k')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-L&amp;gt; :call WinTabSwitch('l')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works great, except when I'm trying to leave a terminal window. To fix that, I use these mappings,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tnoremap &amp;lt;silent&amp;gt; &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;N:call WinTabSwitch('h')&amp;lt;CR&amp;gt;&#xA;tnoremap &amp;lt;silent&amp;gt; &amp;lt;C-J&amp;gt; &amp;lt;C-W&amp;gt;N:call WinTabSwitch('j')&amp;lt;CR&amp;gt;&#xA;tnoremap &amp;lt;silent&amp;gt; &amp;lt;C-K&amp;gt; &amp;lt;C-W&amp;gt;N:call WinTabSwitch('k')&amp;lt;CR&amp;gt;&#xA;tnoremap &amp;lt;silent&amp;gt; &amp;lt;C-L&amp;gt; &amp;lt;C-W&amp;gt;N:call WinTabSwitch('l')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the unfortunate side effect is that the terminal window is left in &lt;strong&gt;Terminal-Normal&lt;/strong&gt; mode. Is there a way to either &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;return to &lt;strong&gt;Terminal-Job&lt;/strong&gt; mode after leaving the terminal window (After reading &lt;code&gt;:h Terminal-Normal&lt;/code&gt;, I have my doubts.), or&lt;/li&gt;&#xA;&lt;li&gt;call the function without leaving &lt;strong&gt;Terminal-Job&lt;/strong&gt; mode?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4808" LastActivityDate="2019-10-04T03:23:18.470" Title="Execute Vim command in terminal window and return to Terminal-Job mode" Tags="|vim-windows|tabbed-user-interface|terminal-buffer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21405" PostTypeId="2" ParentId="21404" CreationDate="2019-10-04T03:23:18.470" Score="3" Body="&lt;p&gt;Sure—use &lt;code&gt;&amp;lt;C-w&amp;gt;:&lt;/code&gt; in your terminal mappings to get a colon command line instead of &quot;escaping&quot; to normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tnoremap &amp;lt;silent&amp;gt; &amp;lt;C-H&amp;gt; &amp;lt;C-W&amp;gt;:call WinTabSwitch('h')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-10-04T03:23:18.470" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21406" PostTypeId="2" ParentId="21400" CreationDate="2019-10-04T03:29:01.297" Score="1" Body="&lt;p&gt;A simple way to do this would be to just run the function definition and airline function add for each window—that is, to do it &lt;em&gt;from the window itself&lt;/em&gt; should require no modification other than removing the filetype check and changing plugin functions for your functions.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use an autocommand on the &lt;code&gt;WinEnter&lt;/code&gt; event (I may have that wrong—someone feel free to edit and correct me): it could declare some kind of function or variable referenced in a global function to be used.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It occurs to me that some of the confusion is in the way the example references plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;code&gt;.vimrc&lt;/code&gt; file contains Vimscript, the special scripting language builtin to vim. It is, for all intents and purposes, an extension of the Ex commands—&lt;code&gt;:global&lt;/code&gt;, &lt;code&gt;:join&lt;/code&gt;, etc., are all valid Vimscript commands. And so are &lt;code&gt;:function&lt;/code&gt; and &lt;code&gt;:autocmd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To summarize, you can just place things like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyFunc()&#xA;  echo 'do something here'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;directly in your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This ability to put Vimscript code in files is not unique to 3rd-party plugins or the &lt;code&gt;plugin&lt;/code&gt; directory of the &lt;code&gt;'runtimepath'&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-10-06T14:32:55.857" LastActivityDate="2019-10-06T14:32:55.857" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21407" PostTypeId="1" CreationDate="2019-10-04T04:29:05.990" Score="2" ViewCount="540" Body="&lt;p&gt;I've been using ycm for Python and Go, trying to configure ycm to work with Java. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've installed &lt;code&gt;java 8&lt;/code&gt;, &lt;code&gt;maven&lt;/code&gt;, recompiled ycm with &lt;code&gt;--java-completer&lt;/code&gt; and done &lt;code&gt;mvn install&lt;/code&gt; in a repo that contains a &lt;code&gt;pom.xml&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import org.springframework.beans.factory.annotation.Autowired;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;running &lt;code&gt;YcmCompleter GetDoc&lt;/code&gt; on &lt;code&gt;Autowired&lt;/code&gt; returns the full documentation of Autowired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However running &lt;code&gt;GoTo&lt;/code&gt;, &lt;code&gt;GoToDeclaration&lt;/code&gt;..etc commands return:&#xA;&lt;code&gt;RuntimeError: Cannot jump to location&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this behaviour expected or is there something that I'm missing, such as a configuration in &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt; to include such that the definitions of dependencies can be found by ycm? i understand java-semantic completion is still under experimental mode, any help would be great. &lt;/p&gt;&#xA;" OwnerUserId="25080" LastEditorUserId="25080" LastEditDate="2019-10-04T04:34:28.037" LastActivityDate="2019-10-04T04:34:28.037" Title="YouCompleteMe GoToDefinition for java gives 'RuntimeError: Cannot jump to location' when used on classes from Maven Dependencies" Tags="|plugin-you-complete-me|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21408" PostTypeId="2" ParentId="15011" CreationDate="2019-10-04T08:18:20.510" Score="0" Body="&lt;p&gt;Yang-Le Wu (yangle) works around the problem by using keybinds to switch buffer.  See the commit linked from the issue:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/yangle/dotfiles/commit/d2e3962a4f1c42f32ae1fa70fb690665011f1a43&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/yangle/dotfiles/commit/d2e3962a4f1c42f32ae1fa70fb690665011f1a43&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The keybinds call a function which will remove the first netrw buffer, if found, before attempting to do the actual movement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without the first buffer sitting in the way, the movement will go to the expected buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that's one solution, but it does require using certain keybinds.  You may want to add some of the other popular keystrokes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;silent&amp;gt; [b :call ChangeBuffer(&quot;prev&quot;)&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; ]b :call ChangeBuffer(&quot;next&quot;)&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; :bp&amp;lt;CR&amp;gt; :call ChangeBuffer(&quot;prev&quot;)&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; :bn&amp;lt;CR&amp;gt; :call ChangeBuffer(&quot;next&quot;)&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; :bprev&amp;lt;CR&amp;gt; :call ChangeBuffer(&quot;prev&quot;)&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;silent&amp;gt; :bnext&amp;lt;CR&amp;gt; :call ChangeBuffer(&quot;next&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I have had limited success with it.  It seems to always destroy the netrw buffer when it's unfocused.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;:set hidden&lt;/code&gt;.  I don't want to destroy it, I just don't want to get stuck on it!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My own experiments are a WIP.  I started off trying to remove the second buffer, as suggested by BitPusher16.  I used this method to detect it, which seems to work even if it was destroyed and then recreated:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;buflisted(bufnum) == 0 &amp;amp;&amp;amp; getbufvar(bufnum, &quot;netrw_curdir&quot;) != ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if we do remove netrw2, the next time we focus the netrw1 buffer, it will recreate the second buffer now at the end of the buffer list, and focus it.  This moves us out of our place in the buffer list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have time, I may pursue a new strategy:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Still use a function to change buffer (using keybinds as above).  Inside the function:&lt;/li&gt;&#xA;&lt;li&gt;If we start off focused on netrw2, then switch to netrw1 before moving.&lt;/li&gt;&#xA;&lt;li&gt;If after moving, we are now focused on netrw2, perform another move in the same direction (skip it).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In this case we won't actually need to destroy the second netrw window.  We will rather skip it, and act as if netrw1 and 2 are bound together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that does work, investigate edge cases:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;...Worry about counts like &lt;code&gt;:3bprev&lt;/code&gt; or &lt;code&gt;3[b&lt;/code&gt;...&lt;/li&gt;&#xA;&lt;li&gt;...Worry about &lt;em&gt;multiple&lt;/em&gt; open netrw buffers...&lt;/li&gt;&#xA;&lt;li&gt;...Check if the strategy still works with netrw visible in window panes...&lt;/li&gt;&#xA;&lt;li&gt;...Worry about cleaning up both netrw windows, if the user deletes one of them...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="630" LastActivityDate="2019-10-04T08:18:20.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21409" PostTypeId="1" AcceptedAnswerId="21415" CreationDate="2019-10-04T11:46:05.730" Score="1" ViewCount="449" Body="&lt;p&gt;I use &lt;a href=&quot;http://vrapper.sourceforge.net/home/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vrapper&lt;/a&gt;, which is a great plugin, providing some vim emulation to Eclipse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the features of Vrapper is that from anywhere you can type &lt;code&gt;:vim&lt;/code&gt; and it will reopen the file you are currently editing into gvim. (This is quite useful when you want to use the full power of Vim from Eclipse.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Users provide the path to a gvim executable to the plugin through a &lt;code&gt;_vrapperrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, if I set the path as follows, it works (with gvim)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set gvimpath=&quot;C:\Program Files (x86)\Vim\vim81\gvim.exe&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I also use nvim-qt, and the following setup doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set gvimpath=&quot;C:\Users\blah\Documents\tools\nvim\Neovim\bin\nvim-qt.exe&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am on the last vrapper stable version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be a vrapper bug, but I am posting hoping someone has a similar setup and solved the issue.&lt;/p&gt;&#xA;" OwnerUserId="5604" LastEditorUserId="23502" LastEditDate="2022-09-08T18:36:50.850" LastActivityDate="2022-09-08T18:36:50.850" Title="Integration between vrapper (Eclipse) and nvim-qt" Tags="|neovim|neovim-qt|vrapper|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21410" PostTypeId="2" ParentId="14851" CreationDate="2019-10-04T13:33:19.400" Score="13" Body="&lt;p&gt;Here's another way to do it, all within &lt;strong&gt;fugitive&lt;/strong&gt;. I believe some of this is new with the 3.0 release on Aug 20, 2019. Someone had created a &amp;quot;What's New?&amp;quot; video, which I sadly can't find now. The &lt;code&gt;:Git&lt;/code&gt; command received a &lt;strong&gt;lot&lt;/strong&gt; of attention.&lt;/p&gt;&#xA;&lt;p&gt;In the &lt;code&gt;:Git&lt;/code&gt; window, you can use these subcommands. There are many others, but these serve me well.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-N&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-P&amp;gt;&lt;/code&gt; to jump to the next/previous file (as mentioned above)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-&lt;/code&gt; on a file, stages (or unstages) the entire file.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;=&lt;/code&gt; shows the &lt;code&gt;git diff&lt;/code&gt; of the file your cursor is on.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-&lt;/code&gt; on a hunk, stages (or unstages) the hunk.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-&lt;/code&gt; in a visual selection, stages (or unstages) the selected lines in the hunk.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cvc&lt;/code&gt; - commits the staged changes in verbose mode. I like the last chance it gives me to verify the right changes have been staged, and it helps inform the commit message.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I really like the inline diffing in the &lt;code&gt;:Git&lt;/code&gt; window. For me, it's easier than dealing with the separate windows and the &lt;code&gt;do&lt;/code&gt; and &lt;code&gt;dp&lt;/code&gt; commands.&lt;/p&gt;&#xA;&lt;p&gt;Before I learned this, I would always go to the shell and do a &lt;code&gt;git commit -pv&lt;/code&gt;, but now I can stay entirely in Vim.&lt;/p&gt;&#xA;" OwnerUserId="4808" LastEditorUserId="4808" LastEditDate="2021-12-30T18:18:28.787" LastActivityDate="2021-12-30T18:18:28.787" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21411" PostTypeId="1" AcceptedAnswerId="21414" CreationDate="2019-10-04T14:32:02.637" Score="0" ViewCount="94" Body="&lt;p&gt;Short Question: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is netrw function for up one level, how can I call it in my own function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Context:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After installing a new ruby I had to reinstall vim to get it working again. But now netrw has some issue where if I press &lt;code&gt;-&lt;/code&gt; to go up one level, it goes up a level and then starts visual mode such that I can't just make it go up another level without &lt;code&gt;Esc&lt;/code&gt; every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an idea for a hacky solution, but I don't know what the function netrw uses to go up a level is, and I don't want to emulate it by searching for line .. and pressing enter, since then netrw won't remember my place I think. Incidentally I have a shortcut for opening Rex, but undoing it doesn't fix the problem. &lt;code&gt;vim -u NONE&lt;/code&gt; then &lt;code&gt;:se nocp&lt;/code&gt; &lt;code&gt;:so $VIMRUNTIME/plugin/netrwPlugin.vim&lt;/code&gt; then &lt;code&gt;:E&lt;/code&gt; will make it behave, but I don't have any clue where in my vimrc or plugins something could be going wrong. For now I think if I know the uponelevel function I could use it as a good band aid to the problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup netrw_mapping&#xA;    autocmd!&#xA;    autocmd filetype netrw call NetrwMapping()&#xA;augroup END&#xA;&#xA;function! NetrwMapping()&#xA;    noremap &amp;lt;buffer&amp;gt; - -&#xA;endfunction&#xA;&#xA;fu! OpenExplorer()&#xA;    &quot; if &amp;amp;ft ==# &quot;netrw&quot;&#xA;    &quot;   exe &quot;-&quot;&#xA;    &quot; endif&#xA;    try&#xA;        :Rex&#xA;    catch&#xA;        :Ex&#xA;    endtry&#xA;endfu&#xA;&#xA;&quot; Like :Ex, but put curson on file you opened from.&#xA;nno - :call OpenExplorer()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8483" LastEditorUserId="343" LastEditDate="2019-10-04T15:38:31.347" LastActivityDate="2019-10-06T22:13:39.830" Title="netrw's - map (up one level) broken after brew reinstall vim" Tags="|netrw|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21412" PostTypeId="1" CreationDate="2019-10-04T14:57:45.603" Score="1" ViewCount="827" Body="&lt;p&gt;I tried to change colors of Vim editor by going to the screen properties and change the color of background and text. It did not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like to know how to change the colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="25089" LastActivityDate="2019-10-04T15:02:31.467" Title="How to change colors of Vim editor?" Tags="|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21413" PostTypeId="2" ParentId="21412" CreationDate="2019-10-04T15:02:31.467" Score="3" Body="&lt;p&gt;You have mistaken your terminal color scheme with the Vim color theme. To change the Vim color theme, you need to use &lt;code&gt;:color&lt;/code&gt; command, followed by a valid color theme on your system, for example,  &lt;code&gt;color desert&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-10-04T15:02:31.467" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21414" PostTypeId="2" ParentId="21411" CreationDate="2019-10-04T15:13:41.157" Score="4" Body="&lt;p&gt;Ignoring the context, the answer to your &quot;short question&quot; is that you can't (easily) call it from your own function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find out what function &lt;code&gt;-&lt;/code&gt; invokes in netrw by entering the following command in a netrw buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose nmap -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For me, the output contains this function call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call &amp;lt;SNR&amp;gt;68_NetrwBrowseUpDir(1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what is &lt;code&gt;&amp;lt;SNR&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.vimhelp.org/map.txt.html#E81&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help &amp;lt;SNR&amp;gt;&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://www.vimhelp.org/eval.txt.html#script-variable&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help s:&lt;/code&gt;&lt;/a&gt; give the full details, but the gist is that when defining a function you can prepend its name with &lt;code&gt;s:&lt;/code&gt; which means that the function can only be called from within the script it's defined. This allows you to name your functions anything you like, safe in the knowledge that it can't be accidentally (or deliberately) called from elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The presence of &lt;code&gt;&amp;lt;SNR&amp;gt;&lt;/code&gt; at the beginning of the function name means that the netrw &quot;go up a directory&quot; function was defined using this technique, and thus you cannot map to it yourself. (At least, not without some shenanigans.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, I'd argue you might be better off attempting to &lt;a href=&quot;https://vi.stackexchange.com/questions/2003/how-do-i-debug-my-vimrc-file&quot;&gt;track down the root cause&lt;/a&gt; of the original issue with netrw's &lt;code&gt;-&lt;/code&gt; mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you're determined to forge ahead, the answer lies in the &lt;code&gt;sid&lt;/code&gt; item in the description of &lt;a href=&quot;http://www.vimhelp.org/eval.txt.html#maparg()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;maparg()&lt;/code&gt;'s &lt;code&gt;{dict}&lt;/code&gt; parameter&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup netrw_mapping&#xA;  autocmd!&#xA;  autocmd FileType netrw call NetrwMapping()&#xA;augroup END&#xA;&#xA;function! NetrwMapping() abort&#xA;  let netrw_sid = maparg('s', 'n', 0, 1)['sid']&#xA;&#xA;  execute 'nnoremap &amp;lt;buffer&amp;gt; - :&amp;lt;C-U&amp;gt;call &amp;lt;SNR&amp;gt;'.netrw_sid.'_NetrwBrowseUpDir(1)&amp;lt;CR&amp;gt;'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that, rather than checking the SID of the &lt;code&gt;-&lt;/code&gt; mapping, we inspect a different mapping that netrw makes. This is necessary to ensure that we don't overwrite the correct original SID with the SID of &lt;em&gt;our&lt;/em&gt; mapping if the function is run more than once in the same buffer. There are other ways to ensure that we always use the correct SID, but this is the simplest.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-10-04T22:43:45.973" LastActivityDate="2019-10-04T22:43:45.973" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21415" PostTypeId="2" ParentId="21409" CreationDate="2019-10-04T15:15:40.707" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/users/19763/ralf&quot;&gt;Ralf&lt;/a&gt; had the correct intuition regarding the other parameter &lt;code&gt;gvimargs&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This does not work with nvim-qt. If you to pass argument from &quot;nvim-qt&quot; to the neovim implementation you have to separate them by a double dash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is specific to nvim-qt, nvim in the terminal works both with and without double dash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ended up putting in my _vrapperrc &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set gvimargs=-- +{line} -c &quot;normal zv{col}|&quot; -c &quot;set nobackup&quot; -f -n {file} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it works correctly with NVIM 0.4.2 and Vrapper 0.74.0 on Win10. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, according to the &lt;a href=&quot;http://vrapper.sourceforge.net/documentation/?topic=configuration&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation of vrapper&lt;/a&gt;, the default value of gvimargs is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; gvimargs=+{line} -c normal zv{col}| -c set nobackup -f -n {file}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5604" LastEditorUserId="5604" LastEditDate="2019-10-07T08:10:53.073" LastActivityDate="2019-10-07T08:10:53.073" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21416" PostTypeId="2" ParentId="21411" CreationDate="2019-10-04T17:44:43.077" Score="0" Body="&lt;p&gt;Thanks Rich for giving me some direction. I couldn't get Rich's solution to work for me directly, but this little hacky bandaid will do for now until I get some time to look into this. If anyone else experienced this bug I would love to know, especially if you solved it more directly. I took the script number function from another stackexchange answer &lt;a href=&quot;https://stackoverflow.com/questions/24027506/get-a-vim-scripts-snr&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup netrw_mapping&#xA;    autocmd!&#xA;    autocmd filetype netrw call NetrwMapping()&#xA;augroup END&#xA;&#xA;&#xA;&quot; n  -            @&amp;lt;Plug&amp;gt;NetrwBrowseUpDir&amp;lt;Space&amp;gt;&#xA;&quot;         Last set from /usr/local/Cellar/vim/8.1.2100/share/vim/vim81/autoload/netrw.vim line 6331&#xA;    &quot; E117: Unknown function: &amp;lt;SNR&amp;gt;1_NetrwBrowseUpDir&#xA;&#xA;func! GetScriptNumber(script_name)&#xA;    &quot; Return the &amp;lt;SNR&amp;gt; of a script.&#xA;    &quot;&#xA;    &quot; Args:&#xA;    &quot;   script_name : (str) The name of a sourced script.&#xA;    &quot;&#xA;    &quot; Return:&#xA;    &quot;   (int) The &amp;lt;SNR&amp;gt; of the script; if the script isn't found, -1.&#xA;&#xA;    redir =&amp;gt; scriptnames&#xA;    silent! scriptnames&#xA;    redir END&#xA;&#xA;    for script in split(l:scriptnames, &quot;\n&quot;)&#xA;        if l:script =~ a:script_name&#xA;            return str2nr(split(l:script, &quot;:&quot;)[0])&#xA;        endif&#xA;    endfor&#xA;&#xA;    return -1&#xA;endfunc&#xA;&#xA;fu! GetScriptPathForNormalMapping(mapping)&#xA;    redir =&amp;gt; result&#xA;    exe 'silent verbose nmap '. a:mapping&#xA;    redir END&#xA;    return matchstr(result, '\v[\~\/][^ ]*')&#xA;endfu&#xA;&#xA;fu! UpALevel()&#xA;    call eval(&#xA;            \ printf(&quot;&amp;lt;SNR&amp;gt;%d_NetrwBrowseUpDir(1)&quot;,&#xA;            \ GetScriptNumber(g:netrw_path)))&#xA;endfu&#xA;&#xA;function! NetrwMapping()&#xA;    if !exists( &quot;g:netrw_path&quot; )&#xA;        let g:netrw_path = GetScriptPathForNormalMapping('-')&#xA;    end&#xA;    nno &amp;lt;buffer&amp;gt; - :call UpALevel()&amp;lt;CR&amp;gt;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8483" LastEditorUserId="8483" LastEditDate="2019-10-06T22:13:39.830" LastActivityDate="2019-10-06T22:13:39.830" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21417" PostTypeId="1" AcceptedAnswerId="21418" CreationDate="2019-10-04T22:47:58.517" Score="1" ViewCount="1829" Body="&lt;p&gt;Dear fellow Developers,&lt;br&gt;&#xA;I would like to quote variables having &lt;code&gt;@&lt;/code&gt; inside like &lt;code&gt;test@mail.org&lt;/code&gt;, but not starting with &lt;code&gt;@&lt;/code&gt; like &lt;code&gt;@var1&lt;/code&gt;, &lt;code&gt;@var2&lt;/code&gt;.&lt;br&gt;&#xA;Does Vi/Vim/Neovim have any option to inspect the matched pattern and create a pre- and postfix to &lt;code&gt;test@mail.org&lt;/code&gt;: &lt;code&gt;&quot;test@mail.org&quot;&lt;/code&gt; ?&lt;br&gt;&#xA;&lt;code&gt;:%s/ [a-zA-Z0-9]+@[a-zA-Z0-9]* / \&quot;*\&quot; /&lt;/code&gt;&lt;br&gt;&#xA;does not work due to &lt;code&gt;\&quot;*\&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If Vi/Vim/Neovim has no such feature, what tools would you recommend for portability?&#xA;I know C++ has a feature to inspect the matched regex as a string for manipulation, but I would like to have a more pluggable solution for vim.&lt;/p&gt;&#xA;" OwnerUserId="25094" LastActivityDate="2019-10-04T22:55:03.763" Title="Adding prefix and postfix to matching regular expression" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21418" PostTypeId="2" ParentId="21417" CreationDate="2019-10-04T22:55:03.763" Score="1" Body="&lt;p&gt;Try using &lt;code&gt;\0&lt;/code&gt; to insert the contents of the match in the substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\&amp;lt;[a-zA-Z0-9.]\+@[a-zA-Z0-9.]*\&amp;gt;/&quot;\0&quot;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that, given that you gave an example of an email address, I added &lt;code&gt;.&lt;/code&gt; to your character classes so that the expression will match these, but it won't &lt;em&gt;only&lt;/em&gt; match email addresses. e.g. It &lt;em&gt;would&lt;/em&gt; match &lt;code&gt;a@a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also changed the white spaces into start/end word atoms: &lt;code&gt;\&amp;lt;&lt;/code&gt;, &lt;code&gt;\&amp;gt;&lt;/code&gt; so that it will successfully match email addresses abutting punctuation, and added a &lt;code&gt;g&lt;/code&gt; flag so that more than one match can be found on each line.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-10-04T22:55:03.763" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21419" PostTypeId="1" CreationDate="2019-10-05T01:36:16.363" Score="1" ViewCount="405" Body="&lt;p&gt;I have 2 files opened in a vertically split window. I call term_start() and get results in a split window below. I use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let foo=term_start(&quot;some_script&quot;, {'hidden':1, 'term_finish':'open', 'term_opencmd':'botright split +b%d'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works great, but often times the script output cannot fit into one line, so it is getting wrapped in the terminal window. This is not something you can fix with &quot;:set nowrap&quot;. These terminal-inserted line breaks create problems with visualization of script output and with searches in the terminal window. I learned I can avoid this by setting 'termwinsize' option to a big number:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set termwinsize=0*999&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This helps, but it creates a different problem - now every time I call term_start() my active window/buffer is for some reasons getting resized to occupy the entire screen space and leaving just one-character wide window for the other buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using (linux) gvim version 8.1.1561 &lt;/p&gt;&#xA;" OwnerUserId="25095" LastActivityDate="2021-03-31T23:04:10.307" Title="how to prevent resize of my split windows on every call of term_start() if I do need to use 'termwinsize' option" Tags="|terminal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21421" PostTypeId="2" ParentId="21367" CreationDate="2019-10-05T08:26:01.737" Score="3" Body="&lt;p&gt;I add my comment as answer with the complete snippet file.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Negative Lookbehind Assertion in Python Regular Expressions&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Python documentation: &lt;a href=&quot;https://docs.python.org/3/library/re.html#index-23&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.python.org/3/library/re.html#index-23&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(?&amp;lt;!...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Important limitation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Similar to positive lookbehind assertions, the contained pattern must only match strings of some fixed length. Patterns which start with negative lookbehind assertions may match at the beginning of the string being searched.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To reduce the length of the regex I assume only the abbreviated form of the snippet is of interest&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet &quot;(small|[bBpvV])?mat(\d+)x(\d+)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i.e. without &lt;code&gt;(rix)?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global !p&#xA;texMathZones = ['texMathZone'+x for x in ['A', 'AS', 'B', 'BS', 'C',&#xA;'CS', 'D', 'DS', 'E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS',&#xA;'J', 'JS', 'K', 'KS', 'L', 'LS', 'DS', 'V', 'W', 'X', 'Y', 'Z']]&#xA;&#xA;texIgnoreMathZones = ['texMathText']&#xA;&#xA;texMathZoneIds = vim.eval('map('+str(texMathZones)+&quot;, 'hlID(v:val)')&quot;)&#xA;texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+&quot;, 'hlID(v:val)')&quot;)&#xA;&#xA;ignore = texIgnoreMathZoneIds[0]&#xA;&#xA;def math():&#xA;    synstackids = vim.eval(&quot;synstack(line('.'), col('.') - (col('.')&amp;gt;=2 ? 1 : 0))&quot;)&#xA;    try:&#xA;        first = next(&#xA;            i for i in reversed(synstackids)&#xA;            if i in texIgnoreMathZoneIds or i in texMathZoneIds&#xA;        )&#xA;        return first != ignore&#xA;    except StopIteration:&#xA;        return False&#xA;&#xA;def create_matrix(snip):&#xA;&#xA;        matrix_str = (snip.buffer[snip.line].split('mat')[0]+'matrix').strip()&#xA;&#xA;        rows = 'x'.join(snip.buffer[snip.line].split(&quot;x&quot;, 2)[:-1])&#xA;        cols = 'x'.join(snip.buffer[snip.line].split(&quot;x&quot;, 2)[-1:])&#xA;&#xA;        int_val = lambda string: int(''.join(s for s in string if s.isdigit()))&#xA;&#xA;        rows = int_val(rows)&#xA;        cols = int_val(cols)&#xA;&#xA;        offset = cols + 1&#xA;        old_spacing = snip.buffer[snip.line][:snip.buffer[snip.line].rfind('\t') + 1]&#xA;&#xA;        snip.buffer[snip.line] = ''&#xA;&#xA;        final_str = old_spacing + &quot;\\begin{&quot;+matrix_str+&quot;}\n&quot;&#xA;&#xA;        for i in range(rows):&#xA;                final_str += old_spacing + '\t'&#xA;                final_str += &quot; &amp;amp; &quot;.join(['$' + str(i * cols + j + offset) for j in range(cols)])&#xA;&#xA;                final_str += &quot; \\\\\\\n&quot;&#xA;&#xA;        final_str += old_spacing + &quot;\\end{&quot;+matrix_str+&quot;}\n$0&quot;&#xA;&#xA;        snip.expand_anon(final_str)&#xA;&#xA;&#xA;endglobal&#xA;&#xA;context &quot;math()&quot;&#xA;snippet '([A-Za-z]*)(?&amp;lt;!smallmat)(?&amp;lt;![bBpvV]mat)(?&amp;lt;![^A-Za-z]mat)(\d)' &quot;auto subscript&quot; wrA&#xA;`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)`&#xA;endsnippet&#xA;&#xA;pre_expand &quot;create_matrix(snip)&quot;&#xA;snippet &quot;(small|[bBpvV])?mat(\d+)x(\d+)&quot; &quot;Generate (small|[bBpvV])?matrix of *rows* by *columns*&quot; br&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as I see it the function &lt;code&gt;math()&lt;/code&gt; is based on &lt;a href=&quot;https://vi.stackexchange.com/a/18494/1292&quot;&gt;https://vi.stackexchange.com/a/18494/1292&lt;/a&gt; and the function &lt;code&gt;create_matrix(snip)&lt;/code&gt; is from &lt;a href=&quot;https://vi.stackexchange.com/a/17461/1292&quot;&gt;https://vi.stackexchange.com/a/17461/1292&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-10-05T08:26:01.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21423" PostTypeId="1" CreationDate="2019-10-06T19:03:54.720" Score="1" ViewCount="657" Body="&lt;p&gt;I'm writing a plugin which needs to replace the empty line tildes with with a '.' character in a single window split. Is this possible to do with Vimscript?&lt;/p&gt;&#xA;" OwnerUserId="23679" LastActivityDate="2019-10-06T19:03:54.720" Title="Is it possible to replace tildes representing empty lines with another character?" Tags="|vimscript|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21424" PostTypeId="1" CreationDate="2019-10-06T20:50:48.150" Score="1" ViewCount="596" Body="&lt;p&gt;I want to swap curly braces and brackets. The problem I encountered is that some plugin shortcuts dont trigger.&#xA;Here's example. If I put this in my config file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap { [&#xA;nnoremap [ {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then unimpaired shortcut for creating blank line doesn't work. Here's the entry from :map listing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n  [&amp;lt;space&amp;gt;    &amp;lt;Plug&amp;gt;unimpairedBlankUp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would expect when I press&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;shift { space&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that plugin function will trigger. Why is this not the case?&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="25118" LastActivityDate="2019-10-06T22:34:50.857" Title="Vim - swaping the curly braces and brackets, breaks the plugin shortcut" Tags="|vimrc|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21425" PostTypeId="2" ParentId="21424" CreationDate="2019-10-06T22:34:50.857" Score="2" Body="&lt;p&gt;The issue you're having is that your mappings are non-recursive, so they won't trigger other mappings (such as the ones from vim-unimpaired), only built-in key mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to fix that, use &lt;code&gt;nmap&lt;/code&gt; instead of &lt;code&gt;nnoremap&lt;/code&gt; for the &lt;code&gt;{&lt;/code&gt; mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap { [&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But note that you'll get into trouble if you keep the two mappings, since then it will go back to expanding the other one... Unfortunately it isn't really easy to solve that issue with Vim mappings. (You might want to consider doing a remapping at a different layer, such as your keyboard driver on the O.S.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/map.txt.html#recursive_mapping&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help recursive_mapping&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-10-06T22:34:50.857" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21426" PostTypeId="1" CreationDate="2019-10-07T01:00:45.803" Score="2" ViewCount="59" Body="&lt;p&gt;I have a lot of lines with with filetype-specific autocommands defining mappings and abbreviations, which looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc&#xA;au!&#xA;...&#xA;au FileType blah nnoremap &amp;lt;buffer&amp;gt; aa bb&#xA;au FileType blah nnoremap &amp;lt;buffer&amp;gt; cc dd&#xA;au FileType blah inoreabbrev &amp;lt;buffer&amp;gt; www xxx&#xA;au FileType blah inoreabbrev &amp;lt;buffer&amp;gt; zzz yyy&#xA;...&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Etc..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if it would be more efficient to assign one function for each file type, and declare all mappings/abbrevs there. I'm asking purely from performance standpoint, not code style.&lt;/p&gt;&#xA;" OwnerUserId="13992" LastEditorUserId="13992" LastEditDate="2019-10-07T08:37:26.953" LastActivityDate="2019-10-07T08:37:26.953" Title="Is it more efficient to use one function instead of multiple autocommands?" Tags="|vimrc|autocmd|performance|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="21427" PostTypeId="1" AcceptedAnswerId="21428" CreationDate="2019-10-07T02:59:39.883" Score="3" ViewCount="189" Body="&lt;p&gt;I want to have different behavior for the different visual modes. As an example if I wanted to &lt;code&gt;vnoremap S{&lt;/code&gt; so that it has the following behavior:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;surrounds the selection in &lt;code&gt;v mode&lt;/code&gt;, (puts &lt;code&gt;{&lt;/code&gt; at the start of selection and and &lt;code&gt;}&lt;/code&gt; at the end of selection)&lt;/li&gt;&#xA;&lt;li&gt;surrounds the lines in &lt;code&gt;V mode&lt;/code&gt;, (puts &lt;code&gt;{&lt;/code&gt; above and &lt;code&gt;}&lt;/code&gt; below the selected lines)&lt;/li&gt;&#xA;&lt;li&gt;surrounds the block in &lt;code&gt;ctrl-v mode&lt;/code&gt;, (puts&lt;code&gt;{&lt;/code&gt;s on the left edge and and &lt;code&gt;}&lt;/code&gt;s on the right edge) &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;what would that look like? I have this but its buggy (behavior isn't consistent, seems to toggle behavior on every attempt.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;expr&amp;gt; S{ visualmode() ==# &quot;v&quot; ?&#xA;\ &quot;&amp;lt;Esc&amp;gt;`&amp;gt;a}&amp;lt;Esc&amp;gt;`&amp;lt;i{&amp;lt;Esc&amp;gt;&quot; : visualmode() ==# &quot;V&quot; ?&#xA;\ &quot;&amp;lt;Esc&amp;gt;`&amp;gt;o}&amp;lt;Esc&amp;gt;`&amp;lt;O{&amp;lt;Esc&amp;gt;va{=&quot; :&#xA;\ &quot;A}&amp;lt;Esc&amp;gt;gvI{&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23094" LastActivityDate="2019-10-07T05:59:07.273" Title="Different mapping behavior for the different visual modes?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21428" PostTypeId="2" ParentId="21427" CreationDate="2019-10-07T04:44:30.160" Score="5" Body="&lt;p&gt;You use &lt;code&gt;visualmode()&lt;/code&gt; which returns the last used visual mode, not the current one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                   vvvvvvvvvvvv&#xA;vnoremap &amp;lt;expr&amp;gt; S{ visualmode() ==# &quot;v&quot; ?&#xA;\ &quot;&amp;lt;Esc&amp;gt;`&amp;gt;a}&amp;lt;Esc&amp;gt;`&amp;lt;i{&amp;lt;Esc&amp;gt;&quot; : visualmode() ==# &quot;V&quot; ?&#xA;                              ^^^^^^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need the current one, which is given by &lt;code&gt;mode()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                   vvvvvv&#xA;vnoremap &amp;lt;expr&amp;gt; S{ mode() ==# &quot;v&quot; ?&#xA;\ &quot;&amp;lt;Esc&amp;gt;`&amp;gt;a}&amp;lt;Esc&amp;gt;`&amp;lt;i{&amp;lt;Esc&amp;gt;&quot; : mode() ==# &quot;V&quot; ?&#xA;                              ^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Unrelated to the issue, but you don't need to call &lt;code&gt;[visual]mode()&lt;/code&gt; several times, and &lt;code&gt;xnoremap&lt;/code&gt; is better than &lt;code&gt;vnoremap&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xno &amp;lt;expr&amp;gt; S{ {&#xA;\  'v': &quot;\e`&amp;gt;a}\e`&amp;lt;i{\e&quot;,&#xA;\  'V': &quot;\e`&amp;gt;o}\e`&amp;lt;O{\eva{=&quot;,&#xA;\  '&amp;lt;c-v&amp;gt;': &quot;A}\egvI{\e&quot;,&#xA;\ }[mode()]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-10-07T05:59:07.273" LastActivityDate="2019-10-07T05:59:07.273" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21430" PostTypeId="1" AcceptedAnswerId="21432" CreationDate="2019-10-07T10:30:12.590" Score="2" ViewCount="688" Body="&lt;p&gt;I tried creating the following macro:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;search an empty line above my location&lt;/li&gt;&#xA;&lt;li&gt;go down one line&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;shift&lt;/kbd&gt;-&lt;kbd&gt;v&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;find an empty line down&lt;/li&gt;&#xA;&lt;li&gt;go up one line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:sort&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This should sort the entire section I'm pointing at...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my attempt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @q = '\/^$ N j &amp;lt;S-V&amp;gt; \/^$ n k :sort'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when trying to run the macro (using &lt;code&gt;@q&lt;/code&gt;) I get one line down, and the following error: &lt;code&gt;E35: No previous regular expression&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Removing the '\' from the macro gave me this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E486: Pattern not found: ^$ N j &amp;lt;S-V&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now I'm stuck...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;p.s.&lt;/strong&gt; If you have an idea how to make this macro robust so that if I don't have a line above or down (because I'm sorting till end / start of doc) I'll still be able to sort, that'd be cool, thx!&lt;/p&gt;&#xA;" OwnerUserId="20287" LastEditorUserId="4472" LastEditDate="2019-10-11T08:09:00.070" LastActivityDate="2019-10-11T08:09:00.070" Title="How to create a vimrc macro using :sort?" Tags="|macro|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21432" PostTypeId="2" ParentId="21430" CreationDate="2019-10-07T11:04:33.740" Score="8" Body="&lt;p&gt;As simple as that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;s Vip:sort&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ip&lt;/code&gt; is an &quot;inner paragraph&quot; object, i.e. a piece of text between two empty lines.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-07T11:04:33.740" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21433" PostTypeId="1" CreationDate="2019-10-07T11:28:39.433" Score="0" ViewCount="550" Body="&lt;p&gt;I would like to execute a command every single time I enter visual mode and another command every time I leave visual mode. Is there a way to achieve this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My objective is to automatically record what I do when I enter visual mode. I want to be able to automatically do &lt;code&gt;:normal! qv&lt;/code&gt; to store everything in the v register, and when when I'm back to normal mode &lt;code&gt;:normal! q&lt;/code&gt; to stop recording. &lt;/p&gt;&#xA;" OwnerUserId="15345" LastActivityDate="2019-10-10T07:30:37.837" Title="How to automatically execute a command every time visual mode is entered and every time normal mode is entered" Tags="|vimscript|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21434" PostTypeId="2" ParentId="21433" CreationDate="2019-10-07T12:34:20.720" Score="4" Body="&lt;p&gt;If your Vim version contains the patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.2044&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.2044&lt;/a&gt;, you could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:last_mode = 'n'&#xA;augroup visual_enter_normal_enter&#xA;    au!&#xA;    au SafeState * call s:fire_visualenter_or_normalenter()&#xA;augroup END&#xA;&#xA;fu! s:fire_visualenter_or_normalenter() abort&#xA;    if reg_executing() isnot# '' | return | endif&#xA;    let mode = mode()&#xA;    if s:last_mode is# 'n'&#xA;    \ &amp;amp;&amp;amp; index(['v', 'V', &quot;\&amp;lt;c-v&amp;gt;&quot;], mode) != -1&#xA;    \ &amp;amp;&amp;amp; exists('#User#VisualEnter')&#xA;        do &amp;lt;nomodeline&amp;gt; User VisualEnter&#xA;    elseif s:last_mode isnot# 'n'&#xA;    \ &amp;amp;&amp;amp; mode is# 'n'&#xA;    \ &amp;amp;&amp;amp; exists('#User#NormalEnter')&#xA;        do &amp;lt;nomodeline&amp;gt; User NormalEnter&#xA;    endif&#xA;    let s:last_mode = mode&#xA;endfu&#xA;&#xA;augroup record_keys_in_visual_mode&#xA;    au!&#xA;    au User VisualEnter call s:recording_start()&#xA;    au User NormalEnter call s:recording_stop()&#xA;augroup END&#xA;&#xA;fu! s:recording_start() abort&#xA;    if reg_recording() is# ''&#xA;        let @v = mode()&#xA;        call feedkeys('qV', 'int')&#xA;    endif&#xA;endfu&#xA;&#xA;fu! s:recording_stop() abort&#xA;    if reg_recording() is# 'V'&#xA;        call feedkeys('q', 'int')&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't tested the code a lot, but it seems to do what you want; i.e. record all the keys typed while in visual mode inside the register &lt;code&gt;v&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;SafeState&lt;/code&gt; is fired frequently, so &lt;code&gt;s:fire_visualenter_or_normalenter()&lt;/code&gt; will be run frequently too, and I don't know how much impact it will have on Vim's performance, nor whether it can cause unexpected issues.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you don't have &lt;code&gt;SafeState&lt;/code&gt;, you can use a timer which repeats invoking its callback forever:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:last_mode = 'n'&#xA;let s:waiting_time = 10&#xA;call timer_start(s:waiting_time, {-&amp;gt; s:fire_visualenter_or_normalenter()}, {'repeat': -1})&#xA;&#xA;fu! s:fire_visualenter_or_normalenter() abort&#xA;    if reg_executing() isnot# '' | return | endif&#xA;    let mode = mode()&#xA;    if s:last_mode is# 'n'&#xA;    \ &amp;amp;&amp;amp; index(['v', 'V', &quot;\&amp;lt;c-v&amp;gt;&quot;], mode) != -1&#xA;    \ &amp;amp;&amp;amp; exists('#User#VisualEnter')&#xA;        do &amp;lt;nomodeline&amp;gt; User VisualEnter&#xA;    elseif s:last_mode isnot# 'n'&#xA;    \ &amp;amp;&amp;amp; mode is# 'n'&#xA;    \ &amp;amp;&amp;amp; exists('#User#NormalEnter')&#xA;        do &amp;lt;nomodeline&amp;gt; User NormalEnter&#xA;    endif&#xA;    let s:last_mode = mode&#xA;endfu&#xA;&#xA;augroup record_keys_in_visual_mode&#xA;    au!&#xA;    au User VisualEnter call s:recording_start()&#xA;    au User NormalEnter call s:recording_stop()&#xA;augroup END&#xA;&#xA;fu! s:recording_start() abort&#xA;    if reg_recording() is# ''&#xA;        let @v = mode()&#xA;        call feedkeys('qV', 'int')&#xA;    endif&#xA;endfu&#xA;&#xA;fu! s:recording_stop() abort&#xA;    if reg_recording() is# 'V'&#xA;        call feedkeys('q', 'int')&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you notice a too big impact on Vim's performance, try to increase the value of &lt;code&gt;s:waiting_time&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you notice that some typed keys are missing from the register &lt;code&gt;v&lt;/code&gt;, try to decrease the value of &lt;code&gt;s:waiting_time&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h SafeState&#xA;:h User&#xA;:h reg_executing(&#xA;:h reg_recording(&#xA;:h mode(&#xA;:h index(&#xA;:h exists(&#xA;:h feedkeys(&#xA;:h timer_start(&#xA;:h :do&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-10-10T07:30:37.837" LastActivityDate="2019-10-10T07:30:37.837" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="21435" PostTypeId="2" ParentId="21430" CreationDate="2019-10-07T13:48:49.977" Score="9" Body="&lt;p&gt;You've already (rightly) accepted an answer that provides a much simpler method of achieving your goal, but I thought I'd address a few of the other issues raised by your question.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The problems with your &lt;code&gt;:let&lt;/code&gt; command&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To debug your macro, a first step might be to try recording a working macro, and then comparing this with the macro created by your &lt;code&gt;let&lt;/code&gt; command. I've run your command, and recorded a series of steps into the &lt;code&gt;&quot;r&lt;/code&gt; register, so lets take a look at the differences by running the &lt;a href=&quot;https://www.vimhelp.org/change.txt.html#:reg&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:registers&lt;/code&gt;&lt;/a&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;q   \/^$ N j &amp;lt;S-V&amp;gt; \/^$ n k :sort&#xA;&quot;r   /^$^MNjVnk:sort^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Okay, so first off, the &lt;code&gt;&quot;q&lt;/code&gt; register begins with a backslash, and has another one midway though. You were correct in your guess that these are not required, but as you discovered, there are further problems with your code.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;&quot;q&lt;/code&gt; register contains several spaces. Some of these should in fact be &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; characters (displayed in the output with the notation &lt;code&gt;^M&lt;/code&gt; meaning &lt;a href=&quot;https://vi.stackexchange.com/a/14381/343&quot;&gt;&lt;code&gt;&amp;lt;Ctrl-M&amp;gt;&lt;/code&gt;&lt;/a&gt;), and others are simply not required at all.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;&quot;q&lt;/code&gt; register contains the string &lt;code&gt;&amp;lt;S-V&amp;gt;&lt;/code&gt;, whereas it should simply contain an upper-case &lt;code&gt;V&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;&quot;q&lt;/code&gt; register contains both a second instance of the search command &lt;em&gt;and&lt;/em&gt; an instance of the jump to next match motion, &lt;code&gt;n&lt;/code&gt;. Only one of these is required.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;What went wrong&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I think these all stem from a few misunderstandings about a). how macros are stored and/or b). how control characters are included in strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A macro contains a series of keystrokes, &lt;em&gt;and nothing else&lt;/em&gt;. You don't separate operations with space characters: if a space character is included that equates to a press of the &lt;kbd&gt;Space&lt;/kbd&gt; on your keyboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, if you want to run a command-line command, you need to include a &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; character to emulate pressing &lt;kbd&gt;Return&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;S-V&amp;gt;&lt;/code&gt; notation is not required to insert upper-case characters into a string: &lt;code&gt;V&lt;/code&gt; is already an upper-case character. Furthermore, in Vimscript, single quotes &lt;code&gt;'&lt;/code&gt; denote a &lt;a href=&quot;https://www.vimhelp.org/eval.txt.html#literal-string&quot; rel=&quot;noreferrer&quot;&gt;&quot;literal&quot; string&lt;/a&gt;, which contains exactly the characters included (with the sole exception that two quotes stand for one quote). &lt;a href=&quot;https://www.vimhelp.org/eval.txt.html#string&quot; rel=&quot;noreferrer&quot;&gt;Double-quotes &lt;code&gt;&quot;&lt;/code&gt;&lt;/a&gt; on the other hand, allow you to include control characters by using the &lt;code&gt;&amp;lt;angle-bracket&amp;gt;&lt;/code&gt; notation &lt;em&gt;and&lt;/em&gt; prepending the opening bracket with a backslash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, this sets the variable &lt;code&gt;v&lt;/code&gt; to contain the the string &lt;code&gt;&quot;&amp;lt;S-V&amp;gt;&quot;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let v = '&amp;lt;S-V&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whereas this is a long-winded way of setting the variable &lt;code&gt;v&lt;/code&gt; to contain the string &lt;code&gt;&quot;V&quot;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let v = &quot;\&amp;lt;S-V&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;How to fix it&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;So to create the correct &lt;code&gt;:let&lt;/code&gt; command you have two options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Enter the following into your &lt;code&gt;vimrc&lt;/code&gt;: &lt;code&gt;let @q = ''&lt;/code&gt; and then, having recorded the working macro into a register &lt;code&gt;&quot;q&lt;/code&gt;, paste the (current) contents of that register in between the single quotes by pressing e.g. &lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;P&lt;/kbd&gt;. The downside of this is that, while it works, it's a bit icky to include literal control characters in your &lt;code&gt;vimrc&lt;/code&gt;, so perhaps a better solution is to:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Rewrite the &lt;code&gt;:let&lt;/code&gt; command to use a double quoted string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @q = &quot;/^$\&amp;lt;CR&amp;gt;NjVnk:sort\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;How to improve it&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Firstly, there is a better way of searching backwards than first searching forwards and then going back with &lt;code&gt;N&lt;/code&gt;, which is to use &lt;a href=&quot;https://www.vimhelp.org/pattern.txt.html#?&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;?&lt;/code&gt;&lt;/a&gt; instead of &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, there is a better way of moving to the line after or before a blank line than running the command &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt;, which is to use a &lt;a href=&quot;https://www.vimhelp.org/pattern.txt.html#search-offset&quot; rel=&quot;noreferrer&quot;&gt;&quot;search offset&quot;&lt;/a&gt;. At the end of your search command, add &lt;code&gt;+1&lt;/code&gt; to place the cursor on the line after the match, or &lt;code&gt;-1&lt;/code&gt; to place the cursor on the line before the match. Because we are searching backwards, we need to first end the regular expression with &lt;code&gt;?&lt;/code&gt;. (When searching forwards, you'd use &lt;code&gt;/&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can repeat a search by omitting the regular expression entirely, but you can still change the search offsets or other flags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @q = &quot;?^$?+1\&amp;lt;CR&amp;gt;V//-1\&amp;lt;CR&amp;gt;:sort\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, you specifically asked about how to handle the start and end of file. You can do so by updating your regular expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When searching upwards, instead of searching for a blank lines we'll search for either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The start of the file, or,&lt;/li&gt;&#xA;&lt;li&gt;The first character on the line following a blank line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;We can no longer use an line-offset, but instead we need to leave the cursor on the end of the match by ending our search with the &lt;code&gt;e&lt;/code&gt; offset to leave the cursor on the final character of the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And when searching downwards, we'll search for either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The end of the file, or,&lt;/li&gt;&#xA;&lt;li&gt;The last character on the line preceding a blank line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To search for the start of the file you can use &lt;a href=&quot;https://www.vimhelp.org/pattern.txt.html#start-of-file&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\%^&lt;/code&gt;&lt;/a&gt;, and to search for the end of the file you can use &lt;a href=&quot;https://www.vimhelp.org/pattern.txt.html#end-of-file&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\%$&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To search for &lt;code&gt;A&lt;/code&gt; or &lt;code&gt;B&lt;/code&gt; you can use the notation &lt;a href=&quot;https://www.vimhelp.org/pattern.txt.html#/bar&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;A\|B&lt;/code&gt;&#xA;&lt;/a&gt; in your regular expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @q = &quot;?\\%^\\|^$\\n.?e\&amp;lt;CR&amp;gt;V/\\%$\\|.\\n^$/\&amp;lt;CR&amp;gt;:sort\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-10-07T14:32:01.537" LastActivityDate="2019-10-07T14:32:01.537" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21436" PostTypeId="2" ParentId="21430" CreationDate="2019-10-07T14:00:59.910" Score="3" Body="&lt;p&gt;Just to show another way to do it, I've been using &lt;a href=&quot;https://github.com/benknoble/Dotfiles/commit/7b2d610b7272f2bc9bef70f9460d09fdbadf9042#diff-348f558bb82e829368a033e1748b8bd6&quot; rel=&quot;nofollow noreferrer&quot;&gt;this sort operator&lt;/a&gt; for about 2.5 weeks and loving it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you set up the code, you can use &lt;code&gt;gs&lt;/code&gt; (or another mapping of your choice) as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;in normal mode as an operator like &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;gu&lt;/code&gt;, or others to sort a range of lines&lt;/li&gt;&#xA;&lt;li&gt;in visual mode, to sort the highlighted lines&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that, because we are sorting, the operator always forces the motions to be linewise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you could then do &lt;code&gt;gsip&lt;/code&gt;, similarly to the accepted answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/autoload/sort.vim&#xA;function! sort#operator(type, ...) abort&#xA;&#xA;  let l:visual = a:0&#xA;&#xA;  if l:visual&#xA;    '&amp;lt;,'&amp;gt;sort&#xA;  else&#xA;    '[,']sort&#xA;  endif&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/plugin/sort_op.vim&#xA;&#xA;if exists('g:loaded_sort_op')&#xA;  finish&#xA;endif&#xA;let g:loaded_sort_op = 1&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; gs :set operatorfunc=sort#operator&amp;lt;CR&amp;gt;g@&#xA;vnoremap &amp;lt;silent&amp;gt; gs :&amp;lt;C-u&amp;gt;call sort#operator(visualmode(), 1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(It doesn't make sense to add the single line variant &lt;code&gt;gss&lt;/code&gt; since we are sorting.)&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-10-07T14:00:59.910" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21437" PostTypeId="1" AcceptedAnswerId="21580" CreationDate="2019-10-07T19:22:28.303" Score="1" ViewCount="1375" Body="&lt;p&gt;My vimrc: &lt;a href=&quot;http://ge0rges.com/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://ge0rges.com/vimrc&lt;/a&gt; &#xA;My environment is: Ubuntu 18.04 in WSL on Windows 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SDXrE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SDXrE.png&quot; alt=&quot;The issue&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 06 2019 17:31:41)&#xA;Included patches: 1-1453&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               +farsi             +mouse_sgr         -tag_any_white&#xA;+arabic            +file_in_path      -mouse_sysmouse    -tcl&#xA;+autocmd           +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       +terminal&#xA;-balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;-browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    +gettext           +netbeans_intg     +timers&#xA;+byte_offset       -hangul_input      +num64             +title&#xA;+channel           +iconv             +packages          -toolbar&#xA;+cindent           +insert_expand     +path_extra        +user_commands&#xA;-clientserver      +job               -perl              +vertsplit&#xA;-clipboard         +jumplist          +persistent_undo   +virtualedit&#xA;+cmdline_compl     +keymap            +postscript        +visual&#xA;+cmdline_hist      +lambda            +printer           +visualextra&#xA;+cmdline_info      +langmap           +profile           +viminfo&#xA;+comments          +libcall           -python            +vreplace&#xA;+conceal           +linebreak         +python3           +wildignore&#xA;+cryptv            +lispindent        +quickfix          +wildmenu&#xA;+cscope            +listcmds          +reltime           +windows&#xA;+cursorbind        +localmap          +rightleft         +writebackup&#xA;+cursorshape       -lua               -ruby              -X11&#xA;+dialog_con        +menu              +scrollbind        -xfontset&#xA;+diff              +mksession         +signs             -xim&#xA;+digraphs          +modify_fname      +smartindent       -xpm&#xA;-dnd               +mouse             +startuptime       -xsmp&#xA;-ebcdic            -mouseshape        +statusline        -xterm_clipboard&#xA;+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save&#xA;+eval              +mouse_gpm         +syntax&#xA;+ex_extra          -mouse_jsbterm     +tag_binary&#xA;+extra_search      +mouse_netterm     +tag_old_static&#xA;system vimrc file: &quot;$VIM/vimrc&quot;&#xA;user vimrc file: &quot;$HOME/.vimrc&quot;&#xA;2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;user exrc file: &quot;$HOME/.exrc&quot;&#xA;defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2&#xA;-fdebug-prefix-map=/build/vim-8l5tlu/vim-8.0.1453=. -fstack-protector-strong&#xA;-Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed&#xA;-o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl&#xA;-L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl&#xA;-lutil -lm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is that when I open a file (here a .c file), everything after the last character of a line is highlighted in yellow. This has a weird behavior though because it doesn't happen on the first page (ie landing after opening a file) and it goes away if the scroll bar is on the line. In addition, if I scroll up or down with the mouse wheel, the yellow highlight comes back.     &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: After investigation it seems to be the theme I am using that's causing the issue. Though this doesn't happen on other Ubuntu terminals, might be WSL's fault. After installing a different theme I notice that the same issue arises only with different colors.&lt;/p&gt;&#xA;" OwnerUserId="25132" LastEditorUserId="25132" LastEditDate="2019-10-09T21:38:04.100" LastActivityDate="2020-06-20T21:36:19.787" Title="Vim is highlights everything after EOL in yellow upon scrolling" Tags="|highlight|color|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="21438" PostTypeId="2" ParentId="19657" CreationDate="2019-10-07T21:29:23.363" Score="5" Body="&lt;p&gt;In NERDTree, press &lt;code&gt;m&lt;/code&gt; to bring up the &lt;strong&gt;NERDTree Menu&lt;/strong&gt;, and then you should see an option, labeled &lt;code&gt;o&lt;/code&gt;, to open the current node with the system editor associated with that file or directory. If that doesn't work for you, create an issue in the &lt;a href=&quot;https://github.com/preservim/nerdtree/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDTree repo&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4808" LastEditorUserId="4808" LastEditDate="2021-06-24T13:37:39.817" LastActivityDate="2021-06-24T13:37:39.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21439" PostTypeId="1" CreationDate="2019-10-07T22:05:02.913" Score="13" ViewCount="8512" Body="&lt;p&gt;As far as I know, Neovim enables running a command async, without blocking the user. I was told this is also enabled in Vim 8.&lt;/p&gt;&#xA;&lt;p&gt;But I couldn't find examples of how to run a command asynchronously. Suppose that I want to run the command &lt;code&gt;:make&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;How would I run this command in Neovim without blocking?&lt;/p&gt;&#xA;&lt;p&gt;Is there an example I can find, or easy to follow documentation?&lt;/p&gt;&#xA;" OwnerUserId="22203" LastEditorUserId="23502" LastEditDate="2023-04-11T07:44:23.863" LastActivityDate="2023-04-11T07:44:23.863" Title="Running a command Async in Neovim" Tags="|neovim|async|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21440" PostTypeId="2" ParentId="439" CreationDate="2019-10-07T23:05:40.310" Score="2" Body="&lt;p&gt;Select the lines you'd like to merge, enter an &lt;strong&gt;Ex&lt;/strong&gt; command by typing a colon &lt;code&gt;:&lt;/code&gt; in normal mode. Then type this command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s/$\n\s*//gc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The entire command should look likewise:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/$\n\s*//gc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is actually a tweaked version of the &lt;a href=&quot;https://vi.stackexchange.com/a/4420/25135&quot;&gt;@insidepower's command&lt;/a&gt; that replaces space-indentations as well as newline characters.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; means that we modify only the lines selected in visual mode.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;/$\n\s*&lt;/code&gt; is a &lt;em&gt;regex&lt;/em&gt; pattern. We're looking for a match that ends &lt;code&gt;$&lt;/code&gt; with a new line character &lt;code&gt;\n&lt;/code&gt; and has non-determined number of whitespaces &lt;code&gt;*&lt;/code&gt; thereafter.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;s/pattern//gc&lt;/code&gt; is a substitute command to find each &lt;em&gt;pattern&lt;/em&gt; and replace it with  an empty character on confirmation.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To figure out more about flags and metacharacters for regular expressions in Vim take a look at &lt;a href=&quot;https://learnbyexample.gitbooks.io/vim-reference/content/Regular_Expressions.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this chapter of Vim Reference.&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="25135" LastEditorUserId="25135" LastEditDate="2019-10-11T14:05:47.467" LastActivityDate="2019-10-11T14:05:47.467" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21441" PostTypeId="1" CreationDate="2019-10-08T00:15:34.187" Score="2" ViewCount="676" Body="&lt;p&gt;I'm trying to figure out how to get vim to correctly indent the next line in a JSX block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently when I press enter, the cursor goes slightly behind where it should be. In the example below, my cursor starts after &lt;code&gt;&amp;lt;Switch&amp;gt;&lt;/code&gt;. Then, when I press enter, the cursor is on the next line, but 4 spaces before where it should be.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// This is in a class, in a file foo.js.&#xA;render() {&#xA;  return (&#xA;    &amp;lt;Fragment&amp;gt;&#xA;      &amp;lt;Switch&amp;gt;|start&#xA;    |got&#xA;        |want&#xA;      &amp;lt;/Switch&amp;gt;&#xA;    &amp;lt;/Fragment&amp;gt;&#xA;  );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These are the settings in my vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Global settings.&#xA;set autoindent&#xA;set shiftwidth=4&#xA;set smartindent&#xA;set tabstop=4&#xA;filetype plugin indent on&#xA;syntax off&#xA;&#xA;&quot; Javascript specific settings.&#xA;autocmd FileType javascript setlocal tabstop=2 softtabstop=2 shiftwidth=2 expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I'm not in a JSX block, then the indentation seems to work fine.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;constructor(props) {&#xA;  super(props);|start&#xA;  |got&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;P.D.&#xA;I'd like to avoid installing a plugin, if possible.&lt;/p&gt;&#xA;" OwnerUserId="22095" LastEditorUserId="22095" LastEditDate="2019-10-08T02:14:39.857" LastActivityDate="2024-03-14T15:00:30.060" Title="Smart and auto indent not indenting as expected for JSX" Tags="|indentation|filetype-javascript|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21442" PostTypeId="2" ParentId="21419" CreationDate="2019-10-08T01:57:24.117" Score="1" Body="&lt;p&gt;I know you &lt;em&gt;said&lt;/em&gt; you &amp;quot;don't want to leave vim [terminal] window&amp;quot; and &amp;quot;Vim 8.1 is supposed to have [a] fully featured [sic] terminal&amp;quot;—but let's consider that&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You have to leave the terminal to do editing; and,&lt;/li&gt;&#xA;&lt;li&gt;No &amp;quot;fully featured [sic] terminal&amp;quot; that I am aware of prevents programs run in it from doing any line wrapping they want to.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;So, I propose the use of a file as intermediary: most programs disable line-wrapping when writing to a file (I'm unclear if this is a result of a lower level stdio routine, or a conscious decision on the part of the programmer). This has the benefit that we're ready to edit—which is why we use vim in the first place.&lt;/p&gt;&#xA;&lt;p&gt;There are many ways to do so:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:term&lt;/code&gt;, run your &lt;code&gt;cmd &amp;gt; file&lt;/code&gt;, then &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;w&lt;/kbd&gt;&lt;code&gt;:edit file&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:enew | execute &amp;quot;read !cmd&amp;quot; | 0d&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:Clam cmd&lt;/code&gt; (if you use &lt;a href=&quot;http://github.com/sjl/clam.vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Clam&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:term&lt;/code&gt;, run your &lt;code&gt;cmd&lt;/code&gt;, copy the output using term normal mode, paste into &lt;code&gt;:enew&lt;/code&gt;, then &lt;code&gt;J&lt;/code&gt; or &lt;code&gt;:join&lt;/code&gt; the appropriate lines&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;sub&gt;Consider this a frame-challenge answer—it may be what you wanted, but it might help you or others solve the problem&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-11-01T20:02:43.203" LastActivityDate="2020-11-01T20:02:43.203" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21443" PostTypeId="1" CreationDate="2019-10-08T07:18:56.730" Score="1" ViewCount="144" Body="&lt;p&gt;Background: neovim with &lt;a href=&quot;https://github.com/majutsushi/tagbar&quot; rel=&quot;nofollow noreferrer&quot;&gt;tagbar plugin&lt;/a&gt; installed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Goal: when starting nvim, if current window size is larger than 100, open tagbar and set auto-open for new buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I use the settings below to achieve auto-open for supported files in new buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * nested :call tagbar#autoopen(1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want the auto-open be controlled by window width because sometimes I use a narrow terminal split by iTerms or tmux, tagbar is not suitable to open in this situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following but it didn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; if I add `echo winwidth('%') here, it will show 80, not the current terminal width&#xA;if winwidth('%') &amp;gt; 100&#xA;    autocmd VimEnter * nested :call tagbar#autoopen(1)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that &lt;code&gt;winwidth('%')&lt;/code&gt; returns number of &lt;code&gt;columns&lt;/code&gt; when nvimrc is executed (I didn't overwrite columns, the default value is 80), so the &lt;code&gt;if&lt;/code&gt; is always false and the tagbar never auto-opens. But when I execute &lt;code&gt;:echo winwidth('%')&lt;/code&gt; after nvim is opened, the result is 154, represents the actual width of current terminal window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me find out the right &lt;code&gt;if&lt;/code&gt; statement, or gives another solution lead to the same goal.&lt;/p&gt;&#xA;" OwnerUserId="25139" LastEditorUserId="25139" LastEditDate="2019-10-08T13:50:38.677" LastActivityDate="2019-10-08T13:50:38.677" Title="How to use actual window size to control vim settings?" Tags="|vimrc|vimscript|neovim|plugin-tagbar|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21444" PostTypeId="1" AcceptedAnswerId="21445" CreationDate="2019-10-08T12:01:27.823" Score="1" ViewCount="194" Body="&lt;p&gt;In vim I often use &lt;code&gt;&amp;lt;S-x&amp;gt;&lt;/code&gt; to 'backspace' in normal mode (deleting the char behind the cursor). However if I position the cursor at the end of the line, the last character on the line is not removed (because of course in Vim the cursor cannot move past the last character on the line). I know I can just use &lt;code&gt;x&lt;/code&gt; normally to do this, but I want to know if I can change the behaviour of &lt;code&gt;&amp;lt;S-x&amp;gt;&lt;/code&gt; so it does the correct thing depending on the context.&lt;/p&gt;&#xA;" OwnerUserId="25144" LastEditorUserId="25144" LastEditDate="2019-10-08T13:03:11.393" LastActivityDate="2019-10-08T13:03:11.393" Title="How to backspace with X at the end of a line" Tags="|key-bindings|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21445" PostTypeId="2" ParentId="21444" CreationDate="2019-10-08T12:48:51.730" Score="1" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/21444/how-to-backspace-with-x-at-the-end-of-a-line?noredirect=1#comment38658_21444&quot;&gt;@Matt suggests&lt;/a&gt;, possibly the best solution for you is to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set virtualedit=onemore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows you to move the cursor one character further to the right so you can use &lt;kbd&gt;Shift-X&lt;/kbd&gt; to delete the last character on the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't like this setting, then you can change the behaviour of &lt;kbd&gt;Shift-X&lt;/kbd&gt; to act like an unshifted &lt;kbd&gt;x&lt;/kbd&gt; when it's at the end of a line with an expression mapping that checks the position of the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; X len(getline('.')) == getcurpos()[2] ? 'x' : 'X'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...but I don't really understand how this is better than the default behaviour: now you &lt;em&gt;can&lt;/em&gt; delete the last character on the line with &lt;kbd&gt;Shift-X&lt;/kbd&gt;, but you &lt;em&gt;can't&lt;/em&gt; delete the penultimate character any more.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-10-08T12:53:59.817" LastActivityDate="2019-10-08T12:53:59.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21446" PostTypeId="1" CreationDate="2019-10-08T14:01:00.473" Score="1" ViewCount="518" Body="&lt;p&gt;Often while editing (say, a post on this network), I find myself wanting to copy something, edit it, and paste it back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At other times, I have some text in my clipboard, but isn't perfect. I would like a quick way to edit it and place it back in the clipboard for pasting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do?&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-10-08T19:37:51.450" Title="How can I edit the contents of my clipboard in vim?" Tags="|os-clipboard|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21447" PostTypeId="2" ParentId="21446" CreationDate="2019-10-08T14:01:00.473" Score="2" Body="&lt;h2&gt;Command-line tools&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For the purposes of this sections, I'm going to assume you have a command line tool(s) which&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;output the clipboard on stdout (&lt;code&gt;clippaste&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;reads stdin and places it in the clipboard (&lt;code&gt;clipcopy&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With these, you can use&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;a href=&quot;https://joeyh.name/code/moreutils/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vipe&lt;/a&gt; (available with moreutils)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;vipe is the pipe editor (it uses your actual &lt;code&gt;EDITOR&lt;/code&gt;, so it doesn't have to be vim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run at a shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;clippaste | vipe | clipcopy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Manual vipe:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Run at a shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;clippaste &amp;gt; /tmp/clip&#xA;vim /tmp/clip # in bash, you can abbreviate as 'vim !$'&#xA;clipcopy &amp;lt; /tmp/clip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;clippaste and clipcopy&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;By OS:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;macOS: &lt;code&gt;pbpaste&lt;/code&gt; and &lt;code&gt;pbcopy&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;*nix: &lt;code&gt;xclip -selection c -o&lt;/code&gt; and &lt;code&gt;xclip -selection c&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;*nix: &lt;code&gt;xsel&lt;/code&gt; (?)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Registers&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In vim, use the clipboard register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:enew | put * | 0delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%yank * | bdelete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="343" LastEditDate="2019-10-08T19:37:51.450" LastActivityDate="2019-10-08T19:37:51.450" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21448" PostTypeId="2" ParentId="21446" CreationDate="2019-10-08T15:19:26.030" Score="2" Body="&lt;p&gt;So long as your Vim is built with &lt;code&gt;+clipboard&lt;/code&gt;, &lt;a href=&quot;https://www.reddit.com/r/vim/comments/98jq2p/vimclip_poor_mans_vimanywhere/e4meunj/?context=8&amp;amp;depth=9&quot; rel=&quot;nofollow noreferrer&quot;&gt;you can do this from the shell without external tools&lt;/a&gt;. Try the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +'pu+' +'$d' +'au BufWriteCmd vimclippy %y+ | set nomodified' vimclippy&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;N.B. I'm using the &lt;code&gt;&quot;+&lt;/code&gt; register for the clipboard. Use the &lt;code&gt;&quot;*&lt;/code&gt; register in the &lt;code&gt;:put&lt;/code&gt; and &lt;code&gt;:yank&lt;/code&gt; commands to edit the primary/selection instead.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of saving a file when you write the buffer, the changes will be saved back into the clipboard (and &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27modified%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'modified'&lt;/code&gt;&lt;/a&gt; will be unset so you can quit without Vim complaining the changes are unsaved. Using &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27buftype%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;buftype=nofile&lt;/code&gt;&lt;/a&gt; is an alternative implementation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can alias this so that you can run it simply by typing &lt;code&gt;vimclippy&lt;/code&gt;. e.g. in bash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vimclippy=&quot;vim +'pu+' +'\$d' +'au BufWriteCmd vimclippy %y+ | set nomodified' vimclippy&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-10-08T16:14:39.723" LastActivityDate="2019-10-08T16:14:39.723" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21449" PostTypeId="1" AcceptedAnswerId="21473" CreationDate="2019-10-08T15:32:42.217" Score="5" ViewCount="3408" Body="&lt;p&gt;I want to map a keyboard shortcut to execute the last command in a terminal buffer that I have open. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've made some progress: I am storing the buffer's channel id correctly but when I try to send keys to the terminal (up arrow and enter) they always appear as literal characters in the terminal rather than actually going to the previous command and executing it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; remember the chan id (buffer id) of the last terminal buffer&#xA;augroup Terminal&#xA;  au!&#xA;  au TermOpen * let g:last_terminal_chan_id = b:terminal_job_id&#xA;augroup END&#xA;&#xA;&#xA;&quot; WIP: doesn't work yet&#xA;function! REPLSend()&#xA;    &quot; the following commented out lines were taken from another plugin that sends keys to a terminal - it doesn't seem to work&#xA;    &quot; let isnormal = mode() ==# 'n'&#xA;    &quot; let curwin = winnr()&#xA;    &quot; exe &quot;sb &quot; . g:last_terminal_chan_id&#xA;    &quot; call cursor('$', 1)&#xA;    &quot; exe curwin . 'wincmd w'&#xA;    &quot; if isnormal&#xA;    &quot;     stopinsert&#xA;    &quot; endif&#xA;    &quot; call chansend(g:last_terminal_chan_id, '&amp;lt;Up&amp;gt;' . '\n')&#xA;    call term_sendkeys(g:last_terminal_chan_id, &quot;i\&amp;lt;Up&amp;gt;\&amp;lt;cr&amp;gt;&quot;)&#xA;endfunction&#xA;&#xA;command! REPLSendLine call REPLSend()&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;f5&amp;gt; :REPLSendLine&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25146" LastActivityDate="2024-02-04T23:12:59.813" Title="Send keys to a terminal buffer" Tags="|vimscript|neovim|" AnswerCount="4" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="21451" PostTypeId="1" AcceptedAnswerId="21453" CreationDate="2019-10-08T17:42:57.423" Score="1" ViewCount="349" Body="&lt;p&gt;I notice that when in insert, pressing &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; will take me to normal mode, but once I finish pressing a sequence of keys, I get taken back to insert mode. I find this very useful, but I want a way of programatically detecting this, so I can reflect the difference in my statusline. The help page for &lt;code&gt;mode()&lt;/code&gt; only mentions normal mode, whereas I can see with &lt;code&gt;set showmode&lt;/code&gt;, vim displays &lt;code&gt;-- (insert) --&lt;/code&gt; instead of &lt;code&gt;-- INSERT --&lt;/code&gt; so clearly it differentiates between the two to some extent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note; I have &lt;code&gt;set noshowmode&lt;/code&gt; set because I want to have &lt;strong&gt;just&lt;/strong&gt; my statusline display the mode. I am looking for a way to do this &lt;strong&gt;without&lt;/strong&gt; using &lt;code&gt;showmode&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="25150" LastActivityDate="2019-10-08T18:34:04.410" Title="detecting insert-normal mode" Tags="|insert-mode|normal-mode|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21452" PostTypeId="2" ParentId="14956" CreationDate="2019-10-08T17:54:37.437" Score="1" Body="&lt;p&gt;The other answer doesn’t give the full command (note the equals sign):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set selection=inclusive&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;even though the default is supposed to be inclusive. On my debian box I had to add it to .vimrc because it was exclusive.&lt;/p&gt;&#xA;" OwnerUserId="25120" LastEditorUserId="10604" LastEditDate="2019-10-10T03:36:37.647" LastActivityDate="2019-10-10T03:36:37.647" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21453" PostTypeId="2" ParentId="21451" CreationDate="2019-10-08T17:58:31.310" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The help page for mode() only mentions normal mode&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's not true. The help page (&lt;code&gt;:h mode()&lt;/code&gt;) is quite complete. You have to supply an optional argument for the &lt;code&gt;mode()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:mode = mode(1)&#xA;if s:mode[0] ==# 'n'&#xA;    if s:mode[1] ==# 'i'&#xA;        &quot; normal using i_CTRL-O&#xA;    elseif s:mode[1] ==# 'o'&#xA;        &quot; normal Operator-pending&#xA;    else&#xA;        &quot; just normal&#xA;    endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;:h mode()&lt;/code&gt; page does not mention &lt;code&gt;niI&lt;/code&gt;, &lt;code&gt;niR&lt;/code&gt; etc. then this version of Vim does not support this feature and should be updated first.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-10-08T18:34:04.410" LastActivityDate="2019-10-08T18:34:04.410" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="21455" PostTypeId="1" CreationDate="2019-10-09T00:17:45.027" Score="0" ViewCount="516" Body="&lt;p&gt;I am building a daemon, and &lt;code&gt;nodemon&lt;/code&gt; currently monitors a file called &lt;code&gt;server.js&lt;/code&gt;, which is compiled from the file I am working on, &lt;code&gt;server.ts&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to compile &lt;code&gt;server.ts&lt;/code&gt;, after saving with &lt;code&gt;:w&lt;/code&gt;, I need to run from the shell, &lt;code&gt;tsc server.ts&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the cleanest way for me to do this without having to exit vim, and taking into consideration that this action has to be performed about every 30 seconds while I code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.  &lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2019-10-09T02:49:14.783" Title="I want to save my typescript file, and immediately run tsc myfile.ts from inside vim. What is the best way to accomplish this?" Tags="|command-line|autocmd|external-command|save|filetype-javascript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21456" PostTypeId="2" ParentId="21455" CreationDate="2019-10-09T02:49:14.783" Score="2" Body="&lt;p&gt;The usual way to compile from Vim is to use &lt;code&gt;:make&lt;/code&gt;. From &lt;a href=&quot;http://vimhelp.appspot.com/quickfix.txt.html#%3Amake&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :make&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;:mak[e][!] [arguments]  1. All relevant |QuickFixCmdPre| autocommands are&#xA;               executed.&#xA;            2. If the 'autowrite' option is on, write any changed&#xA;               buffers&#xA;            3. An errorfile name is made from 'makeef'.  If&#xA;               'makeef' doesn't contain &quot;##&quot;, and a file with this&#xA;               name already exists, it is deleted.&#xA;            4. The program given with the 'makeprg' option is&#xA;               started (default &quot;make&quot;) with the optional&#xA;               [arguments] and the output is saved in the&#xA;               errorfile (for Unix it is also echoed on the&#xA;               screen).&#xA;            [...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, what I'd suggest is to &lt;code&gt;set&lt;/code&gt; &lt;code&gt;makeprg&lt;/code&gt; to &lt;code&gt;tsc %&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;The &quot;:make&quot; command executes the command given with the 'makeprg' option.&#xA;This is done by passing the command to the shell given with the 'shell'&#xA;option.  This works almost like typing&#xA;&#xA;    &quot;:!{makeprg} [arguments] {shellpipe} {errorfile}&quot;.&#xA;&#xA;{makeprg} is the string given with the 'makeprg' option.  Any command can be&#xA;used, not just &quot;make&quot;.  Characters '%' and '#' are expanded as usual on a&#xA;command-line.  You can use &quot;%&amp;lt;&quot; to insert the current file name without&#xA;extension, or &quot;#&amp;lt;&quot; to insert the alternate file name without extension, for&#xA;example: &amp;gt;&#xA;   :set makeprg=make\ #&amp;lt;.o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then use &lt;code&gt;:make&lt;/code&gt; to save your file and build it, instead of &lt;code&gt;:w&lt;/code&gt;. (Or make a convenient mapping.)&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2019-10-09T02:49:14.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21457" PostTypeId="1" AcceptedAnswerId="21469" CreationDate="2019-10-09T03:41:15.223" Score="2" ViewCount="2020" Body="&lt;p&gt;I am trying to remap this functionality:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/O9Y8t.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/O9Y8t.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;to Ctrl+Space, by using this line in &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-Space&amp;gt; &amp;lt;C-n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I can not seem to get it to work.&#xA;If I press Ctrl+Space after starting up, I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E29: No inserted text yet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which I suppose is already mapped to a clipboard which tracks your last input.&#xA;I would rather swap the functionality as auto-complete is more important to me.&#xA;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="7960" LastEditorUserId="51" LastEditDate="2021-01-27T03:10:53.730" LastActivityDate="2021-01-27T03:10:53.730" Title="How to remap Autocomplete on Control+N, to Control+Space?" Tags="|key-bindings|autocompletion|insert-mode|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21458" PostTypeId="1" AcceptedAnswerId="21459" CreationDate="2019-10-09T04:44:53.710" Score="2" ViewCount="327" Body="&lt;p&gt;I'm trying to start writing some Vim Script, and I've come across this issue.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu Test()&#xA;    call setline(1, getline(&quot;.&quot;))&#xA;endf&#xA;&#xA;autocmd InsertCharPre * call Test()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is in my &lt;code&gt;.vimrc&lt;/code&gt;. When I type something, I get an &lt;code&gt;E523&lt;/code&gt; error. Looking that up in help shows that it's liked with having &lt;code&gt;secure&lt;/code&gt; on. I checked and I have it off, so I'm stumped as to what the issue is.&lt;/p&gt;&#xA;" OwnerUserId="24943" LastActivityDate="2019-10-09T07:13:58.360" Title="Error With Simple Function Using setline()" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21459" PostTypeId="2" ParentId="21458" CreationDate="2019-10-09T06:11:23.403" Score="5" Body="&lt;p&gt;From &lt;code&gt;:h insertcharpre&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It is not allowed to change the text |textlock|.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You need to delay the change with a one-shot autocmd, for example until the next &lt;code&gt;TextChangedI&lt;/code&gt; is fired:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! Test() abort&#xA;    au TextChangedI * ++once call setline(1, getline('.'))&#xA;endfu&#xA;augroup test&#xA;    au!&#xA;    au InsertCharPre * call Test()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;++once&lt;/code&gt; flag is provided by the patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.1113&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.1113&lt;/a&gt;. If you don't have it, make the autocmd clear itself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! Test() abort&#xA;    augroup setline_on_textchangedi&#xA;        au!&#xA;        au TextChangedI * call setline(1, getline('.')) | au! setline_on_textchangedi&#xA;    augroup END&#xA;endfu&#xA;augroup test&#xA;    au!&#xA;    au InsertCharPre * call Test()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;TextChangedI&lt;/code&gt; is not fired after you insert a character while the popup menu is visible.&#xA;If that's an issue, you need to also listen to &lt;code&gt;TextChangedP&lt;/code&gt; provided by the patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.0.1494&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.0.1494&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au TextChangedI,TextChangedP * ++once call setline(1, getline('.'))&#xA;                ^^^^^^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Or just use a timer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu! Test() abort&#xA;    call timer_start(0, {-&amp;gt; setline(1, getline('.'))})&#xA;endfu&#xA;augroup test&#xA;    au!&#xA;    au InsertCharPre * call Test()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you don't need to listen to &lt;code&gt;InsertCharPre&lt;/code&gt;, then the textlock issue disappears, and the code can be simplified:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup test&#xA;    au!&#xA;    au TextChangedI,TextChangedP * call setline(1, getline('.'))&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h textlock&#xA;:h insertcharpre&#xA;:h textchangedi&#xA;:h textchangedp&#xA;:h autocmd-once&#xA;:h timer_start(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-10-09T07:13:58.360" LastActivityDate="2019-10-09T07:13:58.360" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21460" PostTypeId="1" CreationDate="2019-10-09T09:39:23.060" Score="1" ViewCount="179" Body="&lt;p&gt;I have a problem with gvim on Fedora 30: when opening a file, the content is displayed, but then the window is never refreshed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Already tried a lot of different solutions, with no success: CTRL-L does not refresh the window, neither does typing :redraw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However it's just the rendering: if I type any command blindly (including :q), it is executed and the file is changed.&lt;/p&gt;&#xA;" OwnerUserId="10355" LastActivityDate="2019-10-09T09:39:23.060" Title="gvim window completely frozen" Tags="|gvim|redraw|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21461" PostTypeId="1" CreationDate="2019-10-09T11:15:35.363" Score="13" ViewCount="3051" Body="&lt;p&gt;I'd been using Linux Mint MATE for years, and recently moved to Arch Linux with MATE Desktop Environment without any change of hardware or &lt;code&gt;.vimrc&lt;/code&gt;. (By the way, I use no plugin.) After that, when I open a file on vim and &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;scroll up/down&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;or, minimize the window and un-minimize it later&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;or, use &quot;show deskop&quot; functionality and then unuse it&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;, the screen is sometimes be corrupted in a way that the same lines are apparently duplicated. This has never occurred on Linux Mint on the same machine, and Linux Mint on MacbookPro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the first picture is a healthy state without any corruption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qzsSI.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qzsSI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The opened file consists only of ASCII characters (with UTF-8 encodings) and short enough not to cause memory problems. This screen can sometimes be (corruptions are underlined): &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zgZEW.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zgZEW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IYWog.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IYWog.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pressing Ctrl+L to redraw the display solves the problem, but it is really annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is bad is that I don't know when it occurs. So I cannot reproduce the problem to debug or find the cause.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I tried is&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;uninstall Arch's original &lt;code&gt;vim&lt;/code&gt; and compile &lt;code&gt;vim&lt;/code&gt; from the official source, because I did so also on Linux Mint &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;do some gpu settings&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;unset &lt;code&gt;TERM&lt;/code&gt;, &lt;code&gt;COLORTERM&lt;/code&gt; or try many values of them according to &lt;a href=&quot;https://github.com/neovim/neovim/issues/6802&quot; rel=&quot;noreferrer&quot;&gt;scrolling is messed up&lt;/a&gt; and &lt;a href=&quot;https://stackoverflow.com/questions/45245919/vim-nerdtree-corrupts-when-using-tmux&quot;&gt;Vim NerdTree corrupts when using Tmux&lt;/a&gt; (NOTE: I do not use &lt;code&gt;tmux&lt;/code&gt; or &lt;code&gt;screen&lt;/code&gt;.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;change HDMI-cable to a quality one&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;change startup command bound to &lt;code&gt;mate-terminal&lt;/code&gt; from the default &lt;code&gt;bash&lt;/code&gt; to &lt;code&gt;env TERM=xterm bash&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;unset &lt;code&gt;cursorline&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;change terminal emulator from &lt;code&gt;mate-terminal&lt;/code&gt; to &lt;code&gt;gnome-terminal&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:set term=&lt;/code&gt;&lt;em&gt;builtin_term&lt;/em&gt; (see &lt;code&gt;help builtin-terms&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:set nottybuiltin&lt;/code&gt; (this made the frequency of occurrence larger)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;reinstall everything including the OS (&lt;s&gt;It seems the problem has been solved. But I'm still checking whether it really has.&lt;/s&gt; Still occurs.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;unset &lt;code&gt;cursorline&lt;/code&gt; &lt;s&gt;(This worked like a charm. Now it seems the problem quite very rarely (but still) occurs. After a week or so, I'll append if the problem has really been solved or not.) (As &lt;a href=&quot;https://vi.stackexchange.com/questions/21461/how-to-avoid-screen-corruption#comment41460_21461&quot;&gt;@Rich&lt;/a&gt; pointed out, I had already tried this before. At that time, unsetting the options didn't work well. Perhaps this difference comes from the difference of versions...)&lt;/s&gt; No. Still occurs.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;refine compile options (see below) -&gt; It seems the problem is solved. I haven't observed it for more than two months.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What I don't want to do is&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;change font&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;change desktop environment&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Does anyone have an idea why that occurs? I really want to solve the problem. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Environment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll add any information if required.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;#This is the information at the time I posted this question.&#xA;#Please scroll down to see the lastest information.&#xA;&#xA;~ $ neofetch&#xA;OS: Arch Linux x86_64&#xA;Kernel: Linux 5.3.5-arch1-1-ARCH&#xA;Shell: bash 5.0.11&#xA;Resolution: 1920x1080 @ 60.00Hz&#xA;Terminal: mate-terminal&#xA;CPU: Intel i5-7500 (4) @ 3.8GHz [39.0°C]&#xA;GPU: NVIDIA GeForce GTX 1050 Ti&#xA;Memory: 1405MiB / 15978MiB [=--------------]&#xA;CPU Usage: 2% [---------------]&#xA;Locale: en_US.UTF-8 &#xA;&#xA;~ $ vi --version&#xA;VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct  4 2019 02:04:19)&#xA;Included patches: 1-2109&#xA;Compiled by me&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl               -farsi             -mouse_sysmouse    -tag_any_white&#xA;+arabic            +file_in_path      +mouse_urxvt       -tcl&#xA;+autocmd           +find_in_path      +mouse_xterm       +termguicolors&#xA;+autochdir         +float             +multi_byte        +terminal&#xA;-autoservername    +folding           +multi_lang        +terminfo&#xA;+balloon_eval      -footer            -mzscheme          +termresponse&#xA;+balloon_eval_term +fork()            +netbeans_intg     +textobjects&#xA;+browse            +gettext           +num64             +textprop&#xA;++builtin_terms    -hangul_input      +packages          +timers&#xA;+byte_offset       +iconv             +path_extra        +title&#xA;+channel           +insert_expand     -perl              +toolbar&#xA;+cindent           +job               +persistent_undo   +user_commands&#xA;+clientserver      +jumplist          +postscript        +vartabs&#xA;+clipboard         +keymap            +printer           +vertsplit&#xA;+cmdline_compl     +lambda            +profile           +virtualedit&#xA;+cmdline_hist      +langmap           +python/dyn        +visual&#xA;+cmdline_info      +libcall           +python3/dyn       +visualextra&#xA;+comments          +linebreak         +quickfix          +viminfo&#xA;+conceal           +lispindent        +reltime           +vreplace&#xA;+cryptv            +listcmds          +rightleft         +wildignore&#xA;+cscope            +localmap          -ruby              +wildmenu&#xA;+cursorbind        -lua               +scrollbind        +windows&#xA;+cursorshape       +menu              +signs             +writebackup&#xA;+dialog_con_gui    +mksession         +smartindent       +X11&#xA;+diff              +modify_fname      +sound             -xfontset&#xA;+digraphs          +mouse             +spell             +xim&#xA;+dnd               +mouseshape        +startuptime       +xpm&#xA;-ebcdic            +mouse_dec         +statusline        +xsmp_interact&#xA;+emacs_tags        +mouse_gpm         -sun_workshop      +xterm_clipboard&#xA;+eval              -mouse_jsbterm     +syntax            -xterm_save&#xA;+ex_extra          +mouse_netterm     +tag_binary        &#xA;+extra_search      +mouse_sgr         -tag_old_static    &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.&#xA;0/include -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi&#xA;-3.2.1/include -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/freetype2 -I/usr/include/li&#xA;bpng16 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmoun&#xA;t -I/usr/include/blkid -I/usr/include/atk-1.0 -pthread    -g -O2 -D_REENTRANT  -U_FORTIFY_SOURCE -D_FORT&#xA;IFY_SOURCE=1       &#xA;Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -l&#xA;atk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuz&#xA;z -lfontconfig -lfreetype  -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lelf -lnsl    -l&#xA;canberra  -lacl -lattr -lgpm -ldl           &#xA;&#xA;#Here is the lastest information.&#xA;&#xA;~ $ neofetch&#xA;OS: Arch Linux x86_64 &#xA;Kernel: Linux 5.5.2-arch1-1 &#xA;Shell: bash 5.0.11 &#xA;Resolution: 1920x1080 @ 60.00Hz &#xA;Terminal: gnome-terminal &#xA;CPU: Intel i5-7500 (4) @ 3.8GHz [25.0°C] &#xA;GPU: NVIDIA GeForce GTX 1050 Ti &#xA;Memory: 2175MiB / 15978MiB [==-------------] &#xA;CPU Usage: 9% [=--------------] &#xA;Locale: en_US.UTF-8 &#xA;&#xA;~ $ vi --version&#xA;VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Feb  9 2020 11:55:29)&#xA;Included patches: 1-235&#xA;Compiled by me&#xA;#(Contents below are exactly same as the above ones except `+popupwin` (this functionality was added in version 8.2).)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By the way, I'm not experiencing the problem other than on &lt;code&gt;vim&lt;/code&gt; (until today). &lt;code&gt;less&lt;/code&gt; and any GUI applications like &lt;code&gt;firefox&lt;/code&gt; work well.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Additional information:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the value of &lt;code&gt;TERM&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~ $ echo $TERM&#xA;xterm-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the output of &lt;code&gt;:pu =execute('set termcap')&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Terminal codes ---&#xA;  t_AL=^[[%p1%dL      t_DL=^[[%p1%dM      t_mr=^[[7m          t_se=^[[27m         t_u7=^[[6n&#xA;  t_al=^[[L           t_dl=^[[M           t_ms=y              t_Sf=               t_ue=^[[m&#xA;  t_bc=               t_EC=^G             t_nd=^[[C           t_SH=^[[%p1%d q     t_us=^[[4m&#xA;  t_BE=^[[?2004h      t_EI=               t_op=^[[39;49m      t_SI=               t_ut=y&#xA;  t_BD=^[[?2004l      t_fs=^G             t_RF=^[]10;?^G      t_Si=^[[22;1t       t_vb=&#xA;  t_cd=^[[J           t_GP=^[[13t         t_RB=^[]11;?^G      t_so=^[[7m          t_ve=^[[?25h&#xA;  t_ce=^[[K           t_IE=^G             t_RC=^[[?12$p       t_SR=               t_vi=^[[?25l&#xA;  t_cl=^[[H^[[2J      t_IS=^[]1;          t_RI=^[[%p1%dC      t_sr=^[M            t_VS=^[[?12l&#xA;  t_Ce=               t_ke=^[[?1l^[&amp;gt;      t_Ri=^[[23;1t       t_ST=^[[22;2t       t_vs=^[[?12h&#xA;  t_Co=256            t_ks=^[[?1h^[=      t_RS=^[P$q q^[\     t_Te=^[[29m         t_xn=y&#xA;  t_CS=               t_le=^H             t_RT=^[[23;2t       t_TE=^[[&amp;gt;4;m        t_xs=&#xA;  t_CV=               t_mb=^[[5m          t_RV=^[[&amp;gt;c          t_TI=^[[&amp;gt;4;2m       t_ZH=^[[3m&#xA;  t_da=               t_md=^[[1m          t_Sb=               t_Ts=^[[9m          t_ZR=^[[23m&#xA;  t_db=               t_me=^[[m           t_SC=^[]12;         t_ts=^[]2;&#xA;  t_AB=^[[%?%p1%{8}%&amp;lt;%t4%p1%d%e%p1%{16}%&amp;lt;%t10%p1%{8}%-%d%e48;5;%p1%d%;m&#xA;  t_AF=^[[%?%p1%{8}%&amp;lt;%t3%p1%d%e%p1%{16}%&amp;lt;%t9%p1%{8}%-%d%e38;5;%p1%d%;m&#xA;  t_cm=^[[%i%p1%d;%p2%dH&#xA;  t_Cs=^[]12;%p1%s^G&#xA;  t_cs=^[[%i%p1%d;%p2%dr&#xA;  t_te=^[[?1049l^[[23;0;0t&#xA;  t_ti=^[[?1049h^[[22;0;0t&#xA;  t_WP=^[[3;%p1%d;%p2%dt&#xA;  t_WS=^[[8;%p1%d;%p2%dt&#xA;  t_8f=^[[38;2;%lu;%lu;%lum&#xA;  t_8b=^[[48;2;%lu;%lu;%lum&#xA;--- Terminal keys ---&#xA;t_#2 &amp;lt;S-Home&amp;gt;    ^[[1;2H   t_KH &amp;lt;k5&amp;gt;        ^[O*u     t_kb &amp;lt;BS&amp;gt;        ^?&#xA;t_#4 &amp;lt;S-Left&amp;gt;    ^[[1;2D   t_KI &amp;lt;k6&amp;gt;        ^[O*v     t_kd &amp;lt;Down&amp;gt;      ^[O*B&#xA;t_%1 &amp;lt;Help&amp;gt;      ^[[28;*~  t_KJ &amp;lt;k7&amp;gt;        ^[O*w     t_kh &amp;lt;Home&amp;gt;      ^[[1;*H&#xA;t_%i &amp;lt;S-Right&amp;gt;   ^[[1;2C   t_KK &amp;lt;k8&amp;gt;        ^[O*x     t_kl &amp;lt;Left&amp;gt;      ^[O*D&#xA;t_&amp;amp;8 &amp;lt;Undo&amp;gt;      ^[[26;*~  t_KL &amp;lt;k9&amp;gt;        ^[O*y     t_kr &amp;lt;Right&amp;gt;     ^[O*C&#xA;t_*7 &amp;lt;S-End&amp;gt;     ^[[1;2F   t_PE &amp;lt;PasteEnd&amp;gt;  ^[[201~   t_ku &amp;lt;Up&amp;gt;        ^[O*A&#xA;t_@7 &amp;lt;End&amp;gt;       ^[[1;*F   t_PS &amp;lt;PasteStart&amp;gt; ^[[200~       &amp;lt;SgrMouse&amp;gt;  ^[[&amp;lt;*M&#xA;t_F1 &amp;lt;F11&amp;gt;       ^[[23;*~  t_k1 &amp;lt;F1&amp;gt;        ^[[11;*~       &amp;lt;Mouse&amp;gt;     ^[[M&#xA;t_F2 &amp;lt;F12&amp;gt;       ^[[24;*~  t_k2 &amp;lt;F2&amp;gt;        ^[[12;*~       &amp;lt;xF1&amp;gt;       ^[O*P&#xA;t_K1 &amp;lt;kHome&amp;gt;     ^[[1;*~   t_k3 &amp;lt;F3&amp;gt;        ^[[13;*~       &amp;lt;xF2&amp;gt;       ^[O*Q&#xA;t_K4 &amp;lt;kEnd&amp;gt;      ^[[4;*~   t_k4 &amp;lt;F4&amp;gt;        ^[[14;*~       &amp;lt;xF3&amp;gt;       ^[O*R&#xA;t_K6 &amp;lt;kPlus&amp;gt;     ^[O*k     t_k5 &amp;lt;F5&amp;gt;        ^[[15;*~       &amp;lt;xF4&amp;gt;       ^[O*S&#xA;t_K7 &amp;lt;kMinus&amp;gt;    ^[O*m     t_k6 &amp;lt;F6&amp;gt;        ^[[17;*~       &amp;lt;xEnd&amp;gt;      ^[O*F&#xA;t_K8 &amp;lt;kDivide&amp;gt;   ^[O*o     t_k7 &amp;lt;F7&amp;gt;        ^[[18;*~       &amp;lt;zEnd&amp;gt;      ^[[8;*~&#xA;t_K9 &amp;lt;kMultiply&amp;gt; ^[O*j     t_k8 &amp;lt;F8&amp;gt;        ^[[19;*~       &amp;lt;xHome&amp;gt;     ^[O*H&#xA;t_KA &amp;lt;kEnter&amp;gt;    ^[O*M     t_k9 &amp;lt;F9&amp;gt;        ^[[20;*~       &amp;lt;zHome&amp;gt;     ^[[7;*~&#xA;t_KB &amp;lt;kPoint&amp;gt;    ^[O*n     t_k; &amp;lt;F10&amp;gt;       ^[[21;*~       &amp;lt;xUp&amp;gt;       ^[[1;*A&#xA;t_KC &amp;lt;k0&amp;gt;        ^[O*p     t_kB &amp;lt;S-Tab&amp;gt;     ^[[Z           &amp;lt;xDown&amp;gt;     ^[[1;*B&#xA;t_KD &amp;lt;k1&amp;gt;        ^[O*q     t_kD &amp;lt;Del&amp;gt;       ^[[3~          &amp;lt;xLeft&amp;gt;     ^[[1;*D&#xA;t_KE &amp;lt;k2&amp;gt;        ^[O*r     t_kI &amp;lt;Insert&amp;gt;    ^[[2;*~        &amp;lt;xRight&amp;gt;    ^[[1;*C&#xA;t_KF &amp;lt;k3&amp;gt;        ^[O*s     t_kN &amp;lt;PageDown&amp;gt;  ^[[6;*~        &amp;lt;kDel&amp;gt;      ^[[3;*~&#xA;t_KG &amp;lt;k4&amp;gt;        ^[O*t     t_kP &amp;lt;PageUp&amp;gt;    ^[[5;*~&#xA;     &amp;lt;SgrMouseRelelase&amp;gt; ^[[&amp;lt;*m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the command I use to compile vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~ $ sudo ./configure --prefix=/usr/local --with-compiledby=me --with-features=huge --with-x --enable-pythoninterp=dynamic --enable-python3interp=dynamic &amp;amp;&amp;amp; sudo make install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;s&gt;&lt;code&gt;--with-x&lt;/code&gt; is needed since clipboard support is a must.&lt;/s&gt; (I just noticed &lt;code&gt;--with-features=huge&lt;/code&gt; implies &lt;code&gt;--with-x&lt;/code&gt;.) &lt;code&gt;--enable-pythoninterp=dynamic&lt;/code&gt; is not needed, so I'll omit this from now on. &lt;code&gt;--enable-python3interp=dynamic&lt;/code&gt; is needed since I have some (not async) functions written in Python3 in &lt;code&gt;.vimrc&lt;/code&gt; (they are all written by me and not external plugins).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my &lt;code&gt;.vimrc&lt;/code&gt; (with irrelevant or sensitive codes cut).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set t_Co=256&#xA;syntax on&#xA;set title&#xA;set mouse=&#xA;set backspace=indent,eol,start&#xA;set whichwrap=b,s,h,l,&amp;lt;,&amp;gt;,[,]&#xA;set virtualedit=onemore&#xA;set number&#xA;set display=lastline&#xA;set showcmd&#xA;set vb t_vb=&#xA;set hlsearch&#xA;set showmatch&#xA;set expandtab&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;set autoindent&#xA;&quot; set cursorline&#xA;set history=1000&#xA;set winheight=100&#xA;set cmdwinheight=10&#xA;set equalprg=sort&#xA;set conceallevel=2&#xA;set concealcursor=nvi&#xA;set tags=./tags&#xA;set diffopt+=vertical&#xA;set nrformats=&#xA;set timeoutlen=300&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16502" LastEditorUserId="16502" LastEditDate="2020-04-30T05:40:40.033" LastActivityDate="2023-12-27T20:03:05.393" Title="How to avoid screen corruption?" Tags="|redraw|" AnswerCount="1" CommentCount="28" ContentLicense="CC BY-SA 4.0" />
  <row Id="21462" PostTypeId="1" AcceptedAnswerId="21464" CreationDate="2019-10-09T12:09:36.163" Score="1" ViewCount="313" Body="&lt;p&gt;I want to call &lt;code&gt;g@&lt;/code&gt; from a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given an operation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Taken from :help g@&#xA;function! CountSpaces(type, ...)&#xA;  let sel_save = &amp;amp;selection&#xA;  let &amp;amp;selection = &quot;inclusive&quot;&#xA;  let reg_save = @@&#xA;&#xA;  if a:0  &quot; Invoked from Visual mode, use gv command.&#xA;    silent exe &quot;normal! gvy&quot;&#xA;  elseif a:type == 'line'&#xA;    silent exe &quot;normal! '[V']y&quot;&#xA;  else&#xA;    silent exe &quot;normal! `[v`]y&quot;&#xA;  endif&#xA;&#xA;  echomsg strlen(substitute(@@, '[^ ]', '', 'g'))&#xA;&#xA;  let &amp;amp;selection = sel_save&#xA;  let @@ = reg_save&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to call it from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! my_fun(...)&#xA;        set opfunc=CountSpaces&#xA;        normal! g@&#xA;endfunction&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't work, nothing happens. Am I doing something wrong?&lt;/p&gt;&#xA;" OwnerUserId="15345" LastActivityDate="2019-10-09T13:18:40.237" Title="Calling g@ from a a vimscript function" Tags="|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21463" PostTypeId="2" ParentId="21457" CreationDate="2019-10-09T12:48:20.763" Score="2" Body="&lt;p&gt;I believe you’ve got the map syntax backwards (see &lt;code&gt;:help :map&lt;/code&gt;): try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-Space&amp;gt; &amp;lt;C-n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;code&gt;:help ins-completion&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-10-09T12:48:20.763" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21464" PostTypeId="2" ParentId="21462" CreationDate="2019-10-09T13:18:40.237" Score="3" Body="&lt;p&gt;The &lt;code&gt;g@&lt;/code&gt; must be used with a motion, so it effectively switches to the operator-pending mode. However, that will not work in your example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h :normal&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{commands} should be a complete command.  If&#xA;{commands} does not finish a command, the last one&#xA;will be aborted as if &amp;lt;Esc&amp;gt; or &amp;lt;C-C&amp;gt; was typed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So eventually &lt;code&gt;normal! g@&lt;/code&gt; ends the operator-pending mode and falls back into the normal mode. Hence &lt;code&gt;g@&lt;/code&gt; does just nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply supplying any motion will work (e.g. &lt;code&gt;normal! g@$&lt;/code&gt;), but it's almost useless, as normally we want an operator, not a fixed operation. That's the reason &lt;code&gt;g@&lt;/code&gt; should be invoked by a mapping, like in &lt;code&gt;:h g@&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-09T13:18:40.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21465" PostTypeId="1" CreationDate="2019-10-09T13:36:17.287" Score="2" ViewCount="771" Body="&lt;p&gt;I often find myself operating in the vim terminal needing to edit a few files. In this case I might type &lt;code&gt;vim *.h&lt;/code&gt;. This opens a new vim instance nested inside my vim terminal. Is there a way to make a command that instead triggers the parent vim instance to load the files in buffers?&lt;/p&gt;&#xA;" OwnerUserId="25165" LastActivityDate="2020-07-13T05:34:50.090" Title="Is there a way to make a command running inside a vim terminal open files in buffers?" Tags="|terminal|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21466" PostTypeId="2" ParentId="21449" CreationDate="2019-10-09T22:42:17.283" Score="2" Body="&lt;p&gt;I don't have &lt;code&gt;term_sendkeys()&lt;/code&gt; in my &lt;code&gt;neovim&lt;/code&gt; instance, so I'll use &lt;code&gt;chandsend()&lt;/code&gt; in my example. Also, the &lt;code&gt;i&lt;/code&gt; is unnecessary, since this function can't put you into insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, regarding your problem. &lt;code&gt;&quot;\&amp;lt;Up&amp;gt;&quot;&lt;/code&gt; does indeed have some unexpected behavior inside double quotes. But, I managed to work around it like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open &lt;code&gt;vim&lt;/code&gt; preemptively to not get error on load.&lt;/li&gt;&#xA;&lt;li&gt;While in terminal, start by writing &lt;code&gt;echo -n '' &amp;gt;&amp;gt; ~/.vimrc&lt;/code&gt;, then put cursor between quotes and press &lt;code&gt;control-v&lt;/code&gt; followed by &lt;code&gt;Up&lt;/code&gt;, then &lt;code&gt;enter&lt;/code&gt; to execute your command.&lt;/li&gt;&#xA;&lt;li&gt;Reload &lt;code&gt;.vimrc&lt;/code&gt; with &lt;code&gt;:e!&lt;/code&gt;, delete the last line with literal &lt;code&gt;Up&lt;/code&gt; sequence, and &lt;code&gt;p&lt;/code&gt; it wherever you want (in this case, into &lt;code&gt;chansend&lt;/code&gt; function).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Upd:&lt;/strong&gt; Another way: enter keys by hex code directly in vim:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Find out your &lt;code&gt;Up&lt;/code&gt; key byte sequence in terminal by piping it to &lt;code&gt;hexdump -C&lt;/code&gt; (same method with echo as described above). This is important, because &lt;code&gt;Up&lt;/code&gt; key may produce different sequences based on your &lt;code&gt;$TERM&lt;/code&gt; value, shell, and system-global key remappings. Here's what mine looks like:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    echo -n '^[OA' | hexdump -C&#xA;    6 00000000  1b 4f 41                                          |.OA|&#xA;    5 00000003&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Enter every byte in vim by pressing &lt;code&gt;C-v&lt;/code&gt;, followed by &lt;code&gt;x&lt;/code&gt;, and then hex code. E.g. &lt;code&gt;C-v x 1 b&lt;/code&gt; for first byte, and so on...&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This seem to work correctly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call chansend(b:terminal_job_id, '^[OA' . &quot;\&amp;lt;cr&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do not try to copy code from here, though. You need to get actual literal &lt;code&gt;Up&lt;/code&gt; sequence from your shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Upd.2:&lt;/strong&gt; Actually, scratch &lt;em&gt;almost&lt;/em&gt; all of above, and just specify bytes as hex sequences, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call chansend(b:terminal_job_id, &quot;\x1b\x4f\x41\&amp;lt;cr&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13992" LastEditorUserId="13992" LastEditDate="2019-10-10T11:21:25.570" LastActivityDate="2019-10-10T11:21:25.570" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21467" PostTypeId="2" ParentId="7795" CreationDate="2019-10-10T00:36:24.123" Score="0" Body="&lt;p&gt;Use this function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Select two lines, then :TimeDifference &#xA;it'll generate the third.** &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;03:42:53&#xA;08:13:18&#xA;4 hrs 30 min 25 sec&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inspired from @Jair López code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot; line1 is the line number the first timestamp is on.&#xA;&quot; line2 is the line number the second timestamp is on.&#xA;function! GetTimeDifference(line1,line2)&#xA;    &quot; Get line content and split it where &quot;:&quot; matches.&#xA;    let l:t1List = split( getline(a:line1), &quot;:&quot; )&#xA;    let l:t2List = split( getline(a:line2), &quot;:&quot; )&#xA;&#xA;    &quot; Get the difference in seconds&#xA;    let l:diffSec = abs(  (l:t1List[0] * 3600 + l:t1List[1] * 60 + l:t1List[2]) - &#xA;                           \ (l:t2List[0] * 3600 + l:t2List[1] * 60 + l:t2List[2])   ) &#xA;    let l:sec=trunc(fmod(l:diffSec,60))&#xA;    let l:min=trunc(fmod(l:diffSec,3600) / 60) &quot; 60x60&#xA;    let l:hrs=trunc(l:diffSec / 3600)&#xA;&#xA;    &quot; Replace the line with the result.&#xA;   call append(a:line2, printf(&quot;%.0f hrs %.0f min %.0f sec&quot;, l:hrs,l:min,l:sec))&#xA;&#xA;    &quot; Delete the other one.&#xA;    &quot; execute a:line2 . &quot;delete&quot;&#xA;endfunction&#xA;&#xA;&quot; Create a user-defined command.&#xA;command! -range TimeDifference :call GetTimeDifference(&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TODO&lt;/strong&gt;: make it work with a.m. / p.m.&lt;/p&gt;&#xA;" OwnerUserId="22353" LastActivityDate="2019-10-10T00:36:24.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21468" PostTypeId="1" AcceptedAnswerId="21472" CreationDate="2019-10-10T07:16:52.920" Score="0" ViewCount="31" Body="&lt;p&gt;when using &lt;code&gt;setline()&lt;/code&gt; to insert brackets, &lt;code&gt;matchpairs&lt;/code&gt; does not do its job correctly. Using these commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fu Test()&#xA;    cal setline(&quot;.&quot;, &quot;()&quot;)&#xA;endf&#xA;&#xA;au TextChangedI * cal Test()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;set up the text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(&#xA;&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;upon typing &lt;code&gt;(&lt;/code&gt; into the middle line, (with &lt;code&gt;matchpairs&lt;/code&gt; including &lt;code&gt;(:)&lt;/code&gt;) you will get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(&#xA;|(|)&#xA;|)|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;||&lt;/code&gt; represents what's highlighted)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried disabling and reinstating &lt;code&gt;matchpairs&lt;/code&gt; but I couldn't get that to work. How can I make it behave as it should?&lt;/p&gt;&#xA;" OwnerUserId="24943" LastEditorUserId="24943" LastEditDate="2019-10-10T07:29:31.187" LastActivityDate="2019-10-10T10:43:11.937" Title="How to fix incorrect highlighting from 'matchpairs' caused by setline()" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21469" PostTypeId="2" ParentId="21457" CreationDate="2019-10-10T07:18:58.513" Score="4" Body="&lt;p&gt;Your terminal send &lt;code&gt;^@&lt;/code&gt; as &lt;code&gt;&amp;lt;c-space&amp;gt;&lt;/code&gt; to vim, &lt;code&gt;^@&lt;/code&gt; is &lt;code&gt;ctrl-@&lt;/code&gt;, it's equivalent&#xA;to &lt;code&gt;&amp;lt;Nul&amp;gt;&lt;/code&gt; in vim, check &lt;a href=&quot;https://vimhelp.org/intro.txt.html#keycodes&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h keycodes&lt;/a&gt; if you have doubts.&lt;/p&gt;&#xA;&lt;p&gt;You get &lt;code&gt;E29: No inserted text yet&lt;/code&gt; error message because &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-%40&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h i_CTRL-@&lt;/a&gt; is trying to insert previously inserted text (it doesn't exist).&lt;/p&gt;&#xA;&lt;p&gt;To fix it, use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Nul&amp;gt; &amp;lt;c-n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-@&amp;gt; &amp;lt;c-n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;Nul&amp;gt; &amp;lt;c-space&amp;gt;&#xA;map! &amp;lt;Nul&amp;gt; &amp;lt;c-space&amp;gt;&#xA;inoremap &amp;lt;c-space&amp;gt; &amp;lt;c-n&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Personally i think you should get used to &lt;code&gt;&amp;lt;c-n&amp;gt;&lt;/code&gt;, it's one of the most useful shortcut key in vim.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-10-10T07:25:47.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21470" PostTypeId="1" CreationDate="2019-10-10T09:14:09.627" Score="0" ViewCount="73" Body="&lt;p&gt;This might be quite challenging, but I would like to achieve the following behavior. Imagine that I have two mappings that overlap:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;dcb := delete comment block := delete comment block (all adjacent comment lines)&lt;/li&gt;&#xA;&lt;li&gt;dcl := delete comment line := delete comment line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;if I type in normal mode 'dc' and the timeout expires, I would like to provide help showing the different options. I have all the mappings documented so it would be easy to write a program that filters out what the verb is and what the text object is, but as I'm not very experienced with vimscript the challenging part for me is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Triggering the function when timeoutlen expires&lt;/li&gt;&#xA;&lt;li&gt;Retrieving the input command:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If I could get that the user input was 'dc' then I easy parse my documentation and provide the information. &lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Less challenging (still challenging for me but definitely possible as this is very common in many plugins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Presenting the different options to the user and letting them choose&lt;/li&gt;&#xA;&lt;li&gt;Executing the final command&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any ideas or guidance on how to achieve this would be very much appreciated. &lt;/p&gt;&#xA;" OwnerUserId="15345" LastActivityDate="2019-10-10T11:39:46.390" Title="Calling a function when timeoutlen expires and retrieving the input command" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21471" PostTypeId="1" AcceptedAnswerId="21477" CreationDate="2019-10-10T10:09:07.027" Score="7" ViewCount="1029" Body="&lt;p&gt;Run the following commands, where &lt;code&gt;&amp;lt;80&amp;gt;&lt;/code&gt; is a literal byte entered by typing &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;8&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let literal = &quot;&amp;lt;80&amp;gt;&quot;&#xA;let quoted  = &quot;\x80&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;echo(literal)&lt;/code&gt; and &lt;code&gt;echo(quoted)&lt;/code&gt; will now both output &lt;code&gt;&amp;lt;80&amp;gt;&lt;/code&gt;, but,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;len(literal)&lt;/code&gt; returns &lt;code&gt;2&lt;/code&gt; instead of the expected &lt;code&gt;1&lt;/code&gt;, and&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:echo literal[0]&lt;/code&gt; outputs &lt;code&gt;&amp;lt;c2&amp;gt;&lt;/code&gt;. The expected &lt;code&gt;&amp;lt;80&amp;gt;&lt;/code&gt; byte appears to be in &lt;code&gt;literal[1]&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Where does this extra byte prefix come from? Why doesn't entering bytes with &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt; result in the same sequences of bytes as adding them with a &lt;code&gt;\x&lt;/code&gt; special character?&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-10-10T13:27:47.130" Title="What is the difference between &lt;C-V&gt;x and \x?" Tags="|string-manipulation|control-character|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21472" PostTypeId="2" ParentId="21468" CreationDate="2019-10-10T10:36:31.580" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27matchpairs%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'matchpairs'&lt;/code&gt;&lt;/a&gt; option itself doesn't perform any highlighting. It's the &lt;a href=&quot;http://www.vimhelp.org/usr_05.txt.html#standard-plugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;standard plugin&lt;/a&gt; &lt;a href=&quot;https://www.vimhelp.org/pi_paren.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;matchparen&lt;/code&gt;&lt;/a&gt; that actually does the highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the autocommands &lt;code&gt;matchparen&lt;/code&gt; uses to implement the highlighting don't line up well with your code*. For a quick fix, try disabling the highlighting before making your change, and reinstating it afterwards:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test()&#xA;    NoMatchParen&#xA;    call setline(&quot;.&quot;, &quot;()&quot;)&#xA;    DoMatchParen&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* Specifically, what's happening is that you are entering the &lt;code&gt;(&lt;/code&gt;, the matchparen autocommand fires and highlights the last &lt;code&gt;)&lt;/code&gt;, &lt;em&gt;then&lt;/em&gt; your autocommand fires and changes the text (but not the highlighting). Then, (at least in my configuration) after a pause, another matchparen autocommand will fire and update the highlighting to be correct.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-10-10T10:43:11.937" LastActivityDate="2019-10-10T10:43:11.937" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21473" PostTypeId="2" ParentId="21449" CreationDate="2019-10-10T10:47:09.263" Score="0" Body="&lt;p&gt;I couldn't get the up arrow key working, it seems tricky and I don't think it's the best way. But thanks to @thunderbeef's answer I got the enter key working, and a solution I'm happy with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    call chansend(g:last_terminal_chan_id, &quot;!!\&amp;lt;cr&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25146" LastActivityDate="2019-10-10T10:47:09.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21475" PostTypeId="2" ParentId="21470" CreationDate="2019-10-10T11:39:46.390" Score="1" Body="&lt;p&gt;Create map for &lt;code&gt;dc&lt;/code&gt;, if you type in only &lt;code&gt;dc&lt;/code&gt;, it will be triggered after &lt;code&gt;timeoutlen&lt;/code&gt; ms.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap dcb :echo &quot;dcb&quot;&amp;lt;cr&amp;gt;&#xA;nnoremap dcl :echo &quot;dcl&quot;&amp;lt;cr&amp;gt;&#xA;nnoremap dc :call &amp;lt;sid&amp;gt;suggest('dc')&amp;lt;cr&amp;gt;&#xA;&#xA;function! s:suggest(cmd)&#xA;  &quot; get second column of `map dc`&#xA;  let l = map(split(execute('map ' . a:cmd), &quot;\n&quot;), {i,v-&amp;gt;split(v)[1]})&#xA;  echo 'possible commands : ' . join(l[1:], &quot; &quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-10-10T11:39:46.390" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21476" PostTypeId="1" CreationDate="2019-10-10T11:40:08.863" Score="0" ViewCount="419" Body="&lt;p&gt;with autoindent mode on, when writing a short bullet point on restructuredtext file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- item one&#xA;         ~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I press Enter, and I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- item one&#xA;  ~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I whould like to quickly by here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- item one&#xA;- &#xA;  ~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so ready to fill my &lt;code&gt;- item two&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;right now I have to do &lt;code&gt;ESC[enter]i[space][space]&lt;/code&gt; before &#xA;to be ready to write my item two.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;After adding the @Ralf vars:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setlocal comments+=b:-&#xA;:setlocal formatoptions+=ro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the check of vars values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set formatoptions?&#xA;     formatoptions=tcqlro&#xA;:set comments?&#xA;     comments=fb:..,b:-&#xA;:print&#xA;     - toto&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;In insert mode, enter add the &lt;code&gt;-&lt;/code&gt; but indented&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- lkdsj&#xA;      ~         &amp;lt;= press Enter&#xA;  - qsdfqsdf&#xA;           ~    &amp;lt;= press Enter&#xA;    - lqkfdjqd&#xA;             ~  &amp;lt;= press Enter&#xA;      - toto&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;In normal mode &lt;code&gt;o&lt;/code&gt; add the &lt;code&gt;-&lt;/code&gt; but indented:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- lkdsj&#xA;      ~         &amp;lt;= press o&#xA;  -&#xA;    ~           # in insert mode but indented&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;In normal mode &lt;code&gt;O&lt;/code&gt; add the &lt;code&gt;-&lt;/code&gt; not indented but line above:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- ~             &amp;lt;= 2. item added above&#xA;- lkdsj&#xA;      ~         &amp;lt;= 1. press O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16022" LastEditorUserId="16022" LastEditDate="2019-10-12T20:41:26.553" LastActivityDate="2019-10-12T20:41:26.553" Title="insert new bullet point in autoindent mode" Tags="|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21477" PostTypeId="2" ParentId="21471" CreationDate="2019-10-10T13:09:49.910" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Where does this extra byte prefix come from?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;literal&lt;/code&gt; holds an UTF-8 encoded string. &lt;code&gt;&amp;lt;80&amp;gt;&lt;/code&gt; is encoded in two bytes according to UTF-8 standard specification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here bold bits are used by UTF-8 decoder only. The remaining 11 bits are the value of &lt;code&gt;0x80&lt;/code&gt; prefixed with 3 zero bits.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;1 1 0&lt;/strong&gt; 0 0 0 1 0 | &lt;strong&gt;1 0&lt;/strong&gt; 0 0 0 0 0 0&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;1 1 0&lt;/strong&gt; --- the next char is encoded in two bytes (octets)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;1 0&lt;/strong&gt; --- the &quot;continuation&quot; octet&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On the other hand, &lt;code&gt;&quot;\x80&quot;&lt;/code&gt; is a &quot;byte&quot; as defined per &lt;code&gt;:h expr-quote&lt;/code&gt;, so it never gets encoded in UTF-8. A quote from the help page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that &quot;\xff&quot; is stored as the byte 255, which may be invalid in some&#xA;  encodings.  Use &quot;\u00ff&quot; to store character 255 according to the current value&#xA;  of 'encoding'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-10-10T13:27:47.130" LastActivityDate="2019-10-10T13:27:47.130" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21478" PostTypeId="2" ParentId="19046" CreationDate="2019-10-10T13:12:05.933" Score="2" Body="&lt;p&gt;SpaceVim provides new key binding for async searching. it is  SPC s  J, the  result will  be put into quickfix list.&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2019-10-10T13:12:05.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21479" PostTypeId="2" ParentId="20856" CreationDate="2019-10-10T13:14:12.053" Score="-1" Body="&lt;p&gt;You  can check &lt;code&gt;:map gf&lt;/code&gt;, it will tell you what this key is mapped to. &lt;/p&gt;&#xA;" OwnerUserId="7942" LastEditorUserId="1841" LastEditDate="2019-10-11T08:08:46.180" LastActivityDate="2019-10-11T08:08:46.180" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21480" PostTypeId="2" ParentId="20885" CreationDate="2019-10-10T13:17:36.017" Score="1" Body="&lt;p&gt;SpaceVim uses neomake by default: to  make neomake support this feature, you can  create a  &lt;code&gt;.clang&lt;/code&gt;  file in the root of your project. Please read the &lt;a href=&quot;https://spacevim.org/layers/lang/c/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;lang#c&lt;/code&gt;&lt;/a&gt; layer doc.&lt;/p&gt;&#xA;" OwnerUserId="7942" LastEditorUserId="10604" LastEditDate="2019-11-09T14:21:33.250" LastActivityDate="2019-11-09T14:21:33.250" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21481" PostTypeId="1" AcceptedAnswerId="21491" CreationDate="2019-10-10T14:47:48.863" Score="0" ViewCount="90" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;CtrlP&lt;/a&gt; plugin to switch to other files in Vim by pressing &lt;code&gt;Ctrl-p&lt;/code&gt;. But this only works in normal mode. I want to trigger it by pressing the same set of keys in insert mode as well. How can I do that? I couldn't find any mapping for insert mode in the help doc.&lt;/p&gt;&#xA;" OwnerUserId="22982" LastActivityDate="2019-10-11T09:23:37.117" Title="How do I open ctrlp plugin file suggestions in Insert mode?" Tags="|plugin-ctrlp|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21482" PostTypeId="1" CreationDate="2019-10-10T15:48:16.320" Score="0" ViewCount="110" Body="&lt;p&gt;This is the problem. I want to use  in my mapping but it causes a bell to ring every time I press on it, no matter what I mapped it to. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;c-/&amp;gt; y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am on nvim-qt. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS tried all of these and still happens:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set noerrorbells visualbell t_vb=&#xA;set noeb vb t_vb=&#xA;autocmd GUIEnter * set visualbell t_vb=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-10-10T15:57:34.447" LastActivityDate="2019-10-12T16:27:31.487" Title="Bell ring on mapping &lt;c-/&gt;" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21483" PostTypeId="1" CreationDate="2019-10-10T16:12:27.973" Score="0" ViewCount="228" Body="&lt;p&gt;I tried with &lt;code&gt;Flygrep *.kl&lt;/code&gt; but it didn't work, I searched how to use &lt;code&gt;--include \*.kl&lt;/code&gt; as in a grep search but I didn't find anything&lt;/p&gt;&#xA;" OwnerUserId="24926" LastEditorUserId="1841" LastEditDate="2019-10-11T07:58:22.423" LastActivityDate="2022-03-10T17:06:40.703" Title="How to find all .kl files in current directory with Flygrep (spacevim)" Tags="|spacevim|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21485" PostTypeId="1" AcceptedAnswerId="21486" CreationDate="2019-10-10T18:53:56.280" Score="1" ViewCount="161" Body="&lt;p&gt;I have a mapping that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt;b &quot;:call MyFunction(&quot; . v:count . &quot;)\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also tried to instead define function with &lt;code&gt;range&lt;/code&gt;, but the effect is the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point is to be able to press a number, followed by the mapping, e.g. &lt;code&gt;30&amp;lt;c-x&amp;gt;b&lt;/code&gt;. The problem is, it fails if the number of remaining lines in the file is less than count I input. The function actually don't do any line operations, so I don't care about actual number of lines. How can I make a mapping or a function that accepts count and isn't dependent on number of lines in open file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my final version, with working solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt;b &quot;:\&amp;lt;c-u&amp;gt;call MyFunction(&quot; . (v:count ? v:count . &quot;)\&amp;lt;cr&amp;gt;&quot; : &quot;)\&amp;lt;left&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this, if I press &lt;code&gt;&amp;lt;number&amp;gt;&amp;lt;c-b&amp;gt;x&lt;/code&gt;, the function is called immediately, or if I press just &lt;code&gt;&amp;lt;c-b&amp;gt;x&lt;/code&gt;, I go into command prompt and can enter number manually (using &lt;code&gt;v:count1&lt;/code&gt; by default isn't suitable for my case).&lt;/p&gt;&#xA;" OwnerUserId="13992" LastEditorUserId="13992" LastEditDate="2019-10-11T11:58:08.627" LastActivityDate="2019-10-11T11:58:08.627" Title="Make mapping that accepts count independent of line count" Tags="|key-bindings|functions|count|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21486" PostTypeId="2" ParentId="21485" CreationDate="2019-10-10T19:00:48.117" Score="6" Body="&lt;p&gt;The answer is actually not as complicated as you might think. A trick that I have found very useful in situations similar to this is to remove the &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; from the end of your mapping and see what comes up. If I do that and run &lt;code&gt;30&amp;lt;C-x&amp;gt;b&lt;/code&gt;, this pops up in the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,.+29call MyFunction(30)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because it's basically like you typed &lt;code&gt;30:call MyFunction(30)&lt;/code&gt;, and putting a count before &lt;code&gt;:&lt;/code&gt; will always insert a range. (Try it!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this, you just use &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; to clear the command line before typing in &quot;&lt;code&gt;call MyFunction(30)&lt;/code&gt;&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-x&amp;gt;b &quot;:\&amp;lt;C-u&amp;gt;call MyFunction(&quot; . v:count . &quot;)\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h c_&amp;lt;C-u&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *c_CTRL-U*&#xA;CTRL-U      Remove all characters between the cursor position and&#xA;        the beginning of the line.  Previous versions of vim&#xA;        deleted all characters on the line.  If that is the&#xA;        preferred behavior, add the following to your .vimrc: &amp;gt;&#xA;            :cnoremap &amp;lt;C-U&amp;gt; &amp;lt;C-E&amp;gt;&amp;lt;C-U&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2019-10-10T19:07:05.293" LastActivityDate="2019-10-10T19:07:05.293" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21488" PostTypeId="2" ParentId="21476" CreationDate="2019-10-10T21:24:38.537" Score="2" Body="&lt;p&gt;This works with the options &lt;code&gt;formatoptions&lt;/code&gt; and &lt;code&gt;comments&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create the file &lt;code&gt;.vim/after/ftplugin/rst.vim&lt;/code&gt; and add the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal comments+=b:-&#xA;setlocal formatoptions+=ro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;comments&lt;/code&gt;, the &lt;code&gt;b:-&lt;/code&gt; adds the the dash as a comment character that has to be followed by a blank. See &lt;code&gt;:help 'comments'&lt;/code&gt; and &lt;code&gt;:help format-comments&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;formatoptions&lt;/code&gt;, the &lt;code&gt;r&lt;/code&gt; inserts the comment leader when hitting &lt;kbd&gt;Enter&lt;/kbd&gt;. The &lt;code&gt;o&lt;/code&gt; inserts the comment leader on hitting &lt;kbd&gt;o&lt;/kbd&gt; or &lt;kbd&gt;O&lt;/kbd&gt; in normal mode. See &lt;code&gt;:help 'formatoptions'&lt;/code&gt; and &lt;code&gt;:help fo-table&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-10-10T21:24:38.537" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21490" PostTypeId="2" ParentId="410" CreationDate="2019-10-11T02:14:16.040" Score="0" Body="&lt;p&gt;I have found all of these answers lacking. After struggling through the xargs issue, the very simplest way--for me!--to do these search-and-opens on a generic box is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -O `grep -lir mySearchTerm *`&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have no issue using &lt;code&gt;find&lt;/code&gt; with &lt;code&gt;xargs&lt;/code&gt; and &lt;code&gt;grep&lt;/code&gt;, but I find the syntax annoying. And as a daily coder who uses &lt;code&gt;vim&lt;/code&gt; and the terminal as their IDE, and searches files for properties constantly, this is what I have been using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a time and place for &lt;code&gt;find . -path ./node_modules -prune -o -name '*.js' | xargs grep -i mySearchTerm&lt;/code&gt; coupled with opening files via vim, and other methods. For me, that is rarely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps someone.&lt;/p&gt;&#xA;" OwnerUserId="13372" LastActivityDate="2019-10-11T02:14:16.040" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21491" PostTypeId="2" ParentId="21481" CreationDate="2019-10-11T09:23:37.117" Score="2" Body="&lt;p&gt;You can do the mapping by yourself: Ctrlp provides an ex command to trigger the fuzzy finding: &lt;code&gt;:CtrlP&lt;/code&gt; so you can create an insert mode mapping which will switch to command mode and trigger the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-p&amp;gt; &amp;lt;Esc&amp;gt;:CtrlP&amp;lt;CR&amp;gt;`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that as &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; is used to navigate the pop up menu, this mapping could create a unwanted behavior (I'm not sure I didn't test it) but in this case you should be able to use &lt;code&gt;pumvisible()&lt;/code&gt; in an expression mapping to check if the menu is visible and trigger the built-in &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; or the &lt;code&gt;CtrlP&lt;/code&gt; ex command.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-10-11T09:23:37.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21492" PostTypeId="1" CreationDate="2019-10-11T12:25:55.337" Score="0" ViewCount="549" Body="&lt;p&gt;I've got the following obviously misspelled file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bla blar blar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open it as &quot;bla.txt&quot; and run &lt;code&gt;:setlocal spell&lt;/code&gt; vim rightly points out all three words as misspellings. However, if I &lt;code&gt;mv&lt;/code&gt; the file to &lt;code&gt;bla.js&lt;/code&gt; and open it again, turning on spelling does not highlight anything. It will select spelling mistakes inside of comments, however. Is there a way to enable spell checking of, say, string literals (or everything?)&lt;/p&gt;&#xA;" OwnerUserId="25184" LastEditorUserId="25184" LastEditDate="2019-10-11T12:55:43.723" LastActivityDate="2019-10-11T14:27:55.320" Title="Enable spelling in code files outside of comments" Tags="|spell-checking|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21493" PostTypeId="2" ParentId="21492" CreationDate="2019-10-11T12:57:52.510" Score="3" Body="&lt;p&gt;&lt;code&gt;$VIMRUNTIME/syntax/javascript.vim&lt;/code&gt; has some syntax items (specifically, the comments) which &lt;code&gt;contains=@Spell&lt;/code&gt;. Therefore, if user sets both &lt;code&gt;syntax on&lt;/code&gt; and &lt;code&gt;set spell&lt;/code&gt;, only such items will be spell-checked, as explained in &lt;code&gt;:h spell-syntax&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To override this you have to issue the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax spell toplevel&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h syn-spell&lt;/code&gt; for more info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that simply deleting &lt;code&gt;.vimrc&lt;/code&gt; leaves filetypes / syntax on, as Vim uses &lt;code&gt;$VIMRUNTIME/defaults.vim&lt;/code&gt; in this case. So always run &lt;code&gt;vim --clean&lt;/code&gt; when trying to check the true defaults.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-10-11T14:27:55.320" LastActivityDate="2019-10-11T14:27:55.320" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21494" PostTypeId="1" CreationDate="2019-10-11T14:12:08.670" Score="1" ViewCount="410" Body="&lt;p&gt;I am having trouble fixing a syntax plugin for Vim.  I've &lt;a href=&quot;https://github.com/cdata/vim-tagged-template/issues/4&quot; rel=&quot;nofollow noreferrer&quot;&gt;found a bug&lt;/a&gt; in a plugin that has not been touched in a fair amount of time. I want to address it myself but I believe I am lacking in a lot of knowledge surrounding the built in syntax rules in vim/neovim. The plugin's job is to syntax highlight a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals&quot; rel=&quot;nofollow noreferrer&quot;&gt;javascript tagged template literal&lt;/a&gt; with another filetype syntax. What I want to fix is the plugin's behavior inside a Typescript file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially there is a piece of syntax that works in Javascript but not in Typescript. Ive used the great plugin &lt;a href=&quot;https://github.com/vim-scripts/SyntaxAttr.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;SyntaxAttr.vim&lt;/a&gt; to see if any other syntaxes override the region in question, but the tagged template literal (the &lt;code&gt;sql&lt;/code&gt; word) has no syntax group attached to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The syntax in a Javascript file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/6627147/66614300-75790d00-eb96-11e9-9821-4b76eea792ed.png&quot; alt=&quot;screenshot(207)&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and the borked syntax in a identical Typescript file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/6627147/66614301-75790d00-eb96-11e9-9a95-a2ddfd8fcc73.png&quot; alt=&quot;screenshot(206)&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried messing with the syntax region command (which essentially boils down to):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region taggedTemplateStringSQL matchgroup=taggedTemplateTicks start=+sql`+ skip=&quot;\(\\`\|\${[^}]*`\|\(\&amp;lt;\K\k*\ze`[^`]*\)\)&quot; end=+`+ keepend contains=@taggedTemplateContentSQL containedin=@jsExpression extend&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I've had no luck. There's just something different about the Typescript file syntax that I don't see.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is the &lt;code&gt;init.vim&lt;/code&gt; file I am using to debug:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.config/nvim/plugged')&#xA;Plug 'cdata/vim-tagged-template'&#xA;Plug 'vim-scripts/SyntaxAttr.vim'&#xA;call plug#end()&#xA;&#xA;let g:taggedtemplate#tagSyntaxMap = {&#xA;  \ &quot;sql&quot;: &quot;sql&quot; }&#xA;&#xA;autocmd FileType javascript,typescript : call taggedtemplate#applySyntaxMap()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;running neovim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NVIM v0.4.2&#xA;Build type: Release&#xA;LuaJIT 2.0.5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25185" LastEditorUserId="25185" LastEditDate="2019-10-11T22:00:50.587" LastActivityDate="2019-10-11T22:00:50.587" Title="Neovim highlight syntax region inside typescript tagged template literal" Tags="|vimscript|syntax-highlighting|filetype-javascript|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21495" PostTypeId="1" CreationDate="2019-10-11T19:30:52.903" Score="1" ViewCount="1234" Body="&lt;p&gt;I just now upgraded to Catalina on Mac (10.15) and immediately ran into an odd font behavior: when I open a file with MacVim (8.1.1722 (157)), the letters with tails (g, y, p...) have their tails cut off at the base of the text (see screen shot).  I can temporarily fix the problem by enlarging and then reducing the font, but that's annoying to have to do every time I open a file.  The font is Menlo:Regular:11.  I don't mind going to either 10 or 12, but I don't know how to make that a default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have two questions: is this a Vim problem that is targeted for fixing?  If not, how do I change the default font?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VlfOf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VlfOf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15498" LastActivityDate="2019-12-12T22:02:45.370" Title="Font on Mac Catalina" Tags="|macvim|font|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21496" PostTypeId="1" CreationDate="2019-10-11T20:36:53.560" Score="4" ViewCount="802" Body="&lt;p&gt;When I try to do the following on Windows 10:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;go to a directory, set it as the target directory using &lt;code&gt;mt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;go to a different directory, mark a file in that directory using &lt;code&gt;mf&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;mc&lt;/code&gt; to copy the file to the target directory&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(netrw) tried using g:netrw_localcopycmd&amp;lt;C:\WINDOWS\system32\cmd.exe&amp;gt;; it doesn't work!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a fix to this? Or am I doing it wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;:echo g:netrw_localcopycmd&lt;/code&gt; is &lt;code&gt;C:\WINDOWS\system32\cmd.exe&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="25193" LastEditorUserId="25193" LastEditDate="2019-10-12T19:27:23.477" LastActivityDate="2019-10-12T19:27:23.477" Title="netrw bug? cannot copy marked file to target" Tags="|netrw|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21497" PostTypeId="1" CreationDate="2019-10-11T21:57:21.677" Score="4" ViewCount="1085" Body="&lt;p&gt;I tried using &lt;code&gt;MF *.h&lt;/code&gt; for example to select all the files in the current directory that end with &lt;code&gt;.h&lt;/code&gt; but this doesnt work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are good ways to mark multiple files using netrw?&lt;/p&gt;&#xA;" OwnerUserId="25193" LastActivityDate="2020-08-07T04:51:14.563" Title="How to mark multiple files in netrw?" Tags="|netrw|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21498" PostTypeId="1" AcceptedAnswerId="21500" CreationDate="2019-10-12T02:15:14.337" Score="3" ViewCount="1125" Body="&lt;p&gt;I was looking at the documentation for the 'complete' option, and I found it a bit confusing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.   scan the current buffer ('wrapscan' is ignored)&#xA;w   scan buffers from other windows&#xA;b   scan other loaded buffers that are in the buffer list&#xA;u   scan the unloaded buffers that are in the buffer list&#xA;U   scan the buffers that are not in the buffer list&#xA;k   scan the files given with the 'dictionary' option&#xA;kspell  use the currently active spell checking |spell|&#xA;k{dict} scan the file {dict}.  Several &quot;k&quot; flags can be given, patterns are valid too.  For example:  &#xA;        :set cpt=k/usr/dict/*,k~/spanish&#xA;s   scan the files given with the 'thesaurus' option&#xA;s{tsr}  scan the file {tsr}.  Several &quot;s&quot; flags can be given, patterns are valid too.&#xA;i   scan current and included files&#xA;d   scan current and included files for defined name or macro |i_CTRL-X_CTRL-D|&#xA;]   tag completion&#xA;t   same as &quot;]&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the difference between &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;u&lt;/code&gt; and &lt;code&gt;U&lt;/code&gt;? I thought as soon as you did either &lt;code&gt;:e file/path&lt;/code&gt; or &lt;code&gt;:badd file/path&lt;/code&gt;, everything gets &quot;loaded&quot; into memory for editing..&lt;/p&gt;&#xA;" OwnerUserId="25025" LastEditorUserId="10604" LastEditDate="2019-10-12T13:07:46.433" LastActivityDate="2019-10-12T13:07:46.433" Title="What is the difference between loaded and unloaded buffers?" Tags="|buffers|autocompletion|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21499" PostTypeId="2" ParentId="21498" CreationDate="2019-10-12T03:42:09.487" Score="6" Body="&lt;p&gt;A buffer is &lt;code&gt;listed&lt;/code&gt; if it's in the buffer list, you can see it in &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Abuffers&quot; rel=&quot;noreferrer&quot;&gt;:h :buffers&lt;/a&gt; , you can refer to it with &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Abuffer&quot; rel=&quot;noreferrer&quot;&gt;:h :buffer&lt;/a&gt; , &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Abnext&quot; rel=&quot;noreferrer&quot;&gt;:h :bnext&lt;/a&gt; , etc . It's controled by setting &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27buflisted%27&quot; rel=&quot;noreferrer&quot;&gt;:h 'buflisted'&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A buffer is &lt;code&gt;loaded&lt;/code&gt; if the corresponding file is loaded into memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not all buffers should be &lt;code&gt;listed&lt;/code&gt;, e.g. &lt;code&gt;help&lt;/code&gt; type buffer is not listed, as no one wants to refer to it with &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Abuffer&quot; rel=&quot;noreferrer&quot;&gt;:h :buffer&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not all buffers should be &lt;code&gt;loaded&lt;/code&gt;, as &lt;code&gt;load&lt;/code&gt; is not free, it cost time and memory, it doesn't make sense to load a buffer that you might not use at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:e file/path&lt;/code&gt; create a &lt;code&gt;listed&lt;/code&gt; and &lt;code&gt;loaded&lt;/code&gt; buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:badd file/path&lt;/code&gt; create a &lt;code&gt;listed&lt;/code&gt; but not &lt;code&gt;loaded&lt;/code&gt; buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:args a b c d&lt;/code&gt; creates 4 buffers, all of them &lt;code&gt;listed&lt;/code&gt;, but only &lt;code&gt;a&lt;/code&gt; is loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:bunload&lt;/code&gt; unload buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:bdelete&lt;/code&gt; unload buffer, remove it in the buffer list, clear options, variables, maps, abbreviations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:bwipe&lt;/code&gt; unload buffer, remove it in the buffer list, wipe everything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check buffer info with &lt;a href=&quot;https://vimhelp.org/eval.txt.html#getbufinfo%28%29&quot; rel=&quot;noreferrer&quot;&gt;:h getbufinfo()&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also check unlisted buffer with &lt;code&gt;:buffers!&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-10-12T04:06:41.577" LastActivityDate="2019-10-12T04:06:41.577" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21500" PostTypeId="2" ParentId="21498" CreationDate="2019-10-12T05:27:03.557" Score="6" Body="&lt;p&gt;The situation with buffers is quite complicated. Use &lt;code&gt;:ls&lt;/code&gt; (of &lt;code&gt;:buffers&lt;/code&gt;) to inspect them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There can be the following states:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Active buffer --- both loaded into RAM and shown in (at least one) window. This is what you normally got after &lt;code&gt;:e filename&lt;/code&gt;, &lt;code&gt;:buffer N&lt;/code&gt; and so on. (flagged &quot;a&quot; by &lt;code&gt;:ls&lt;/code&gt;; also when it's in active window, it's flagged by &quot;%&quot;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Hidden buffer --- fully loaded but nowhere shown, except the buffer list. This is when you call &lt;code&gt;bufload()&lt;/code&gt; to load a new buffer without showing it, or &lt;code&gt;:hide&lt;/code&gt; an existing window/buffer, or do &lt;code&gt;:quit&lt;/code&gt; while &lt;code&gt;set hidden&lt;/code&gt; or &lt;code&gt;setlocal bufhidden=hide&lt;/code&gt; etc. (flagged &quot;h&quot; by &lt;code&gt;:ls&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Unloaded buffer --- &quot;the data stream&quot; is unloaded from RAM, but all other stuff, such as local variables, options, bookmarks etc., is still preserved. This is what you get after &lt;code&gt;:bunload&lt;/code&gt;, or (if &lt;code&gt;set nohidden&lt;/code&gt;) when switching buffers by &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;^&lt;/kbd&gt;, or do &lt;code&gt;:quit!&lt;/code&gt; etc. (no special flag in &lt;code&gt;:ls&lt;/code&gt;, except maybe &lt;code&gt;#&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Unlisted buffer --- this is just a special flag which is honoured by &lt;code&gt;:ls&lt;/code&gt; command: unlisted buffers are not shown unless &lt;code&gt;:ls!&lt;/code&gt; is specifed. (flagged &quot;u&quot; by &lt;code&gt;:ls!&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In fact, any buffer has two independent flags: loaded and listed. &quot;Loaded and nolisted&quot; is a typical value for special buffers such as &quot;help&quot;, so they are visible but not normally shown by &lt;code&gt;:ls&lt;/code&gt;; &quot;unloaded and nolisted&quot; is set when a buffer is deleted.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;5&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Deleted buffer --- this is both unloaded and unlisted buffer. &quot;The data stream&quot; is unloaded from RAM, and all buffer-local variables and options are erased. However, all local bookmarks are still intact alongside with &quot;filename&quot; and &quot;buffer number&quot;. This is what you get after &lt;code&gt;:bdelete&lt;/code&gt;. Also the same fate awaits for all &quot;nofile&quot; and &quot;unnamed&quot; buffers - they are not just unloaded but also deleted (also flagged &quot;u&quot; by &lt;code&gt;:ls!&lt;/code&gt;, as they all are unlisted too).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Wiped buffer --- this is a full extermination, no mercy, no trace in history. Done by &lt;code&gt;:bwipeout&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-12T05:27:03.557" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="21501" PostTypeId="1" AcceptedAnswerId="21502" CreationDate="2019-10-12T09:33:16.570" Score="3" ViewCount="370" Body="&lt;p&gt;I am using VIM as a note taking application and have created syntax highlighting to assist with readability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See below or the &lt;a href=&quot;https://github.com/xvk3/vim_note&quot; rel=&quot;nofollow noreferrer&quot;&gt;repo&lt;/a&gt; for all the files.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Timestamp /^\d\d:\d\d \d\d[/]\d\d[/]\d\d\d\d -/&#xA;syntax match Complete /^\/.*$/&#xA;syntax match noteSingleDash /^\s*- .*$/ contains=KKS1,noteParenthesis2,noteCurlyBrace2,noteUpUpUp2,noteAt2&#xA;syntax match noteDoubleDash /\-- .*$/ contains=KKS1,noteParenthesis2,noteCurlyBrace2,noteUpUpUp2,noteAt2&#xA;syntax match noteTripleDash /\--- .*$/ contains=KKS2,noteParenthesis2,noteCurlyBrace2,noteUpUpUp2,noteAt2&#xA;syntax match noteQuadruDash /\---- .*$/ contains=KKS1,noteParenthesis2,noteCurlyBrace2noteUpUpUp2,noteAt3&#xA;&#xA;syntax match noteParenthesis  /[(].*[)]/&#xA;syntax match noteParenthesis2 /[(].*[)]/ contained&#xA;&#xA;syntax match noteCurlyBrace  /[{].*[}]/&#xA;syntax match noteCurlyBrace2 /[{].*[}]/ contained&#xA;&#xA;syntax match noteUpUpUp     /\^/&#xA;syntax match noteUpUpUp2    /\^/ contained&#xA;&#xA;syntax match KKS /\a\a\a\d\d\a\a\d\d\d\S*\|\s\n/&#xA;syntax match KKS1 /\a\a\a\d\d\a\a\d\d\d\S*\|\s\n/ contained&#xA;syntax match KKS2 /\a\a\a\d\d\a\a\d\d\d\S*\|\s\n/ contained&#xA;&#xA;syntax match noteAt /@\w*/&#xA;syntax match noteAt2 /@\w*/ contained&#xA;syntax match noteAt3 /@\w*/ contained&#xA;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to apply the highlighting of parentheses, braces, carets, the KKS and &quot;@&quot; regexes without creating multiple lines for each?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example can noteParenthesis be &quot;contained&quot; (and apply to dashed lines) while also effecting regular unhighlighted lines (text following a &quot;Timestamp&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .vimrc below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;set number&#xA;highlight LineNr ctermfg=red&#xA;:set wrap linebreak nolist&#xA;&#xA;map &amp;lt;F5&amp;gt; :.! date &quot;+\%H:\%M \%d/\%m/\%Y&quot;&amp;lt;cr&amp;gt;&#xA;cmap w!! w !sudo tee &amp;gt; /dev/null %&#xA;highlight noteSingleDash ctermfg=cyan guifg=#00ffff&#xA;highlight noteDoubleDash ctermfg=magenta guifg=#d700ff&#xA;highlight noteTripleDash ctermfg=yellow guifg=#878700&#xA;highlight noteQuadruDash ctermfg=red guifg=#af0000&#xA;highlight Timestamp ctermfg=green guifg=#005f00&#xA;highlight Complete ctermfg=green guifg=#005f00&#xA;&#xA;highlight noteParenthesis ctermfg=red guifg=#af0000&#xA;highlight noteParenthesis2 ctermfg=red guifg=#af0000&#xA;&#xA;highlight noteCurlyBrace ctermfg=red guifg=#af0000&#xA;highlight noteCurlyBrace2 ctermfg=red guifg=#af0000&#xA;&#xA;highlight noteUpUpUp ctermfg=cyan guifg=#00ffff&#xA;highlight noteUpUpUp2 ctermfg=cyan guifg=#00ffff&#xA;&#xA;highlight KKS ctermfg=yellow guifg=#878700&#xA;highlight KKS2 ctermfg=magenta guifg=#d700ff&#xA;highlight KKS1 ctermfg=yellow guifg=#878700&#xA;&#xA;highlight noteAt ctermfg=red guifg=#af0000&#xA;highlight noteAt2 ctermfg=red guifg=#af0000&#xA;highlight noteAt3 ctermfg=cyan guifg=#00ffff&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25196" LastActivityDate="2019-10-12T10:15:24.350" Title="Efficient Syntax Highlighting" Tags="|vimrc|syntax-highlighting|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21502" PostTypeId="2" ParentId="21501" CreationDate="2019-10-12T10:01:55.967" Score="5" Body="&lt;p&gt;You don't need the syntax definition lines with &lt;code&gt;contained&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every syntax item could be contained in another syntax item. You need &lt;code&gt;contained&lt;/code&gt; if a syntax item should &lt;em&gt;only&lt;/em&gt; be detected when it is contained in another item. (&lt;code&gt;:help :syn-contained&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match noteSingleDash /^\s*- .*$/ contains=KKS,noteParenthesis,noteCurlyBrace,noteUpUpUp,noteAt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might want to check &lt;code&gt;contains=ALL&lt;/code&gt;. With this a syntax item might contain any other item. Like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match noteSingleDash /^\s*- .*$/ contains=ALL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another way is to work with &lt;code&gt;cluster&lt;/code&gt;. A cluster is a group of syntax items that can be referenced by name. See &lt;code&gt;:help :syn-cluster&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match noteSingleDash /^\s*- .*$/ contains=@FlowText&#xA;&#xA;syntax match noteParenthesis  /[(].*[)]/&#xA;syntax match noteCurlyBrace  /[{].*[}]/&#xA;syntax match noteUpUpUp     /\^/&#xA;syntax match KKS /\a\a\a\d\d\a\a\d\d\d\S*\|\s\n/&#xA;syntax match noteAt /@\w*/&#xA;&#xA;syntax cluster FlowText contains=KKS,noteParenthesis,noteCurlyBrace,noteUpUpUp,noteAt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW: &lt;code&gt;noteSingleDash&lt;/code&gt; requires the dash to be the first non-whitespace character on the line. The other *Dash could be anywhere in the text.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-10-12T10:15:24.350" LastActivityDate="2019-10-12T10:15:24.350" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21503" PostTypeId="2" ParentId="21482" CreationDate="2019-10-12T13:42:28.587" Score="1" Body="&lt;p&gt;On my setup (Vim 8.1.2102, Ubuntu, Gnome-Terminal, german keyboard), &lt;code&gt;&amp;lt;C-/&amp;gt;&lt;/code&gt; is equivalent to &lt;code&gt;&amp;lt;C-7&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-_&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I opened a new buffer, changed to insert mode and hit &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; followed by &lt;code&gt;&amp;lt;C-/&amp;gt;&lt;/code&gt; and it inserted &lt;code&gt;^_&lt;/code&gt; (displayed in blue). The same input is created for &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;C-7&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;C-_&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I used the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-_&amp;gt; p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;&amp;lt;C-_&amp;gt;&lt;/code&gt; acts like &lt;code&gt;p&lt;/code&gt;. But also &lt;code&gt;&amp;lt;C-/&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-7&amp;gt;&lt;/code&gt; works like &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-10-12T16:27:31.487" LastActivityDate="2019-10-12T16:27:31.487" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21504" PostTypeId="1" CreationDate="2019-10-12T17:58:36.073" Score="0" ViewCount="350" Body="&lt;p&gt;I'm looking for a way to change the behaviour of the &lt;code&gt;%&lt;/code&gt; key. I know by default it will move the cursor to the corresponding parenthesis or brace, but I'm wondering if I can have it jump to the nearest similar character in the event I use it while on a non-bracket char.&#xA;i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Lam a -&amp;gt; k $ VClosure (\v k' -&amp;gt; eval (v:env) a k')&#xA;                                    ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(where &lt;code&gt;^&lt;/code&gt; is the cursor position) should move the cursor to the left parenthesis a couple chars to the right, after which the normal behaviour applies.&lt;/p&gt;&#xA;" OwnerUserId="25197" LastActivityDate="2019-10-12T18:15:46.230" Title="Jump to nearest pair of brackets with %" Tags="|key-bindings|cursor-movement|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21505" PostTypeId="2" ParentId="21504" CreationDate="2019-10-12T18:15:46.230" Score="1" Body="&lt;p&gt;Make use of a standard &quot;matchit&quot; plugin which provides &lt;code&gt;[%&lt;/code&gt; and &lt;code&gt;]%&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To enable &quot;matchit&quot; simply add &lt;code&gt;packadd! matchit&lt;/code&gt; to your vimrc (or execute &lt;code&gt;packadd matchit&lt;/code&gt; in your current Vim session).&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-12T18:15:46.230" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21506" PostTypeId="1" AcceptedAnswerId="21517" CreationDate="2019-10-12T20:25:41.063" Score="0" ViewCount="106" Body="&lt;p&gt;I've got a problem where in insert mode, if I type something like &lt;code&gt;{&lt;/code&gt; that will cause indentation, then press enter twice, then match that bracket (such that there is a line in between the opening and closing bracket), all indentation on the line inbetween will be gone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that didn't make any sense, &lt;a href=&quot;https://youtu.be/f3JGfZUPbAk&quot; rel=&quot;nofollow noreferrer&quot;&gt;here is a video&lt;/a&gt; demonstrating the behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent on&#xA;set smartindent&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I have the indentation stay, preferably &lt;strong&gt;without using an &quot;autoclose plugin&quot;&lt;/strong&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8151" LastEditorUserId="10604" LastEditDate="2019-10-14T12:45:30.770" LastActivityDate="2019-10-14T13:44:34.260" Title="Keep indentation after multiple newlines" Tags="|vimrc|indentation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21507" PostTypeId="1" AcceptedAnswerId="21508" CreationDate="2019-10-13T06:10:19.877" Score="1" ViewCount="2394" Body="&lt;p&gt;I am editting typescript now, and I'd like to be able to have it so, whenever &lt;code&gt;:w&lt;/code&gt; is invoked, the shell runs &lt;code&gt;tsc&lt;/code&gt; compiling my new save. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This beats having to &lt;code&gt;!tsc&lt;/code&gt; every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does something like this exist? A build or toolchain command is also an acceptable answer, as long as it can be done in one short command.&lt;/p&gt;&#xA;" OwnerUserId="7960" LastActivityDate="2019-12-12T12:18:13.717" Title="Is it possible to have vim run a command every time save `:w` is invoked?" Tags="|command-line|filetype|save|command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21508" PostTypeId="2" ParentId="21507" CreationDate="2019-10-13T06:40:12.593" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Does something like this exist?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In Vim this is called an autocommand. The relevant help topic can be found by typing &lt;code&gt;:h autocommand&lt;/code&gt; (sic!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example code to put into vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup typescript_save | au!&#xA;    autocmd BufWritePost *.ts !tsc &amp;lt;afile&amp;gt;:p:S&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-12-12T12:18:13.717" LastActivityDate="2019-12-12T12:18:13.717" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21510" PostTypeId="1" CreationDate="2019-10-14T01:04:30.667" Score="1" ViewCount="87" Body="&lt;p&gt;I have the following text file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: This is a book.&#xA;2: Here is the book for you.&#xA;3: There are book.&#xA;4: You can read the book.&#xA;5: Is book good to read?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to find all occurrences of &lt;code&gt;book&lt;/code&gt; not following &lt;code&gt;a&lt;/code&gt; or &lt;code&gt;the&lt;/code&gt;, that is, the &lt;code&gt;book&lt;/code&gt; in Line 3,5 but not those on lines 1,2,4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use the following search pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[^a|the] book&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however, this is only to check one character, but not the whole word.&lt;/p&gt;&#xA;" OwnerUserId="25211" LastEditorUserId="1841" LastEditDate="2019-10-14T07:55:45.430" LastActivityDate="2019-10-14T07:55:45.430" Title="How to match a word not following a defined pattern?" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21511" PostTypeId="1" AcceptedAnswerId="21516" CreationDate="2019-10-14T02:21:47.520" Score="2" ViewCount="396" Body="&lt;p&gt;I have the &lt;a href=&quot;https://github.com/dense-analysis/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ALE&lt;/a&gt; extension installed, and would like it to highlight errors and warnings, however when &lt;code&gt;:set termguicolors&lt;/code&gt; is enabled, the&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a screenshot of the problem:    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set termguicolors    &#xA;highlight ALEWarning ctermbg=DarkMagenta     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GUxcO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GUxcO.png&quot; alt=&quot;image&quot;&gt;&lt;/a&gt;    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set notermguicolors    &#xA;highlight ALEWarning ctermbg=DarkMagenta     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wbOtw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wbOtw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, when termguicolors is enabled, ALE is unable to errors or warnings.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this just a limitation of the plugin? If not, I would like some help as to how to solve it.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it helps, I am using &lt;code&gt;NVIM v0.4.2&lt;/code&gt;.              &lt;/p&gt;&#xA;" OwnerUserId="23679" LastActivityDate="2019-10-14T11:53:17.360" Title="ALE Error and warning highlighting gets disabled when termguicolors is enabled" Tags="|neovim|colorscheme|highlight|plugin-ale|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21512" PostTypeId="2" ParentId="7750" CreationDate="2019-10-14T04:50:10.103" Score="1" Body="&lt;p&gt;How about grouping the abbreviations by filetype?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of having all of them in your &lt;code&gt;~/.vimrc&lt;/code&gt; file, break them up and put them in the proper locations in your runtime directory, which is &lt;code&gt;~/.vim&lt;/code&gt; on Unix-like operating systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, your Markdown abbreviations would be located in the file &lt;code&gt;~/.vim/after/ftplugin/markdown.vim&lt;/code&gt;, which Vim checks &lt;em&gt;after&lt;/em&gt; the Markdown filetype plugin loads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turns out we shouldn't have huge &lt;code&gt;.vimrc&lt;/code&gt; files; you get more flexibility using &lt;code&gt;$VIMRUNTIME&lt;/code&gt;. The runtime path is documented in Vim’s help system: &lt;code&gt;:h 'runtimepath'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I first learned about this from the excellent article &lt;a href=&quot;https://vimways.org/2018/from-vimrc-to-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;From .vimrc to .vim&lt;/a&gt; on the Vim-themed advent calendar &lt;a href=&quot;https://vimways.org/2018/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimways&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14846" LastEditorUserId="14846" LastEditDate="2019-10-14T04:55:50.120" LastActivityDate="2019-10-14T04:55:50.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21513" PostTypeId="2" ParentId="21495" CreationDate="2019-10-14T05:08:42.967" Score="-1" Body="&lt;p&gt;I’m also running macOS Catalina and MavVim 8.1.1722.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I’m using a &lt;a href=&quot;https://github.com/powerline/fonts&quot; rel=&quot;nofollow noreferrer&quot;&gt;patched font for Powerline&lt;/a&gt;—Deja Vu Sans Mono for Powerline—and everything looks great, I launched MacVim in default mode—no vimrc or plugins: &lt;code&gt;mvim -u NONE&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Saw the issue with the font baselines getting cut off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably the best idea is to use a different font; here’s how to do that with any font you may have installed. Add a line to your &lt;code&gt;vimrc&lt;/code&gt; file that looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my testing, disabling &lt;strong&gt;Use CoreText Rendering&lt;/strong&gt; (&lt;strong&gt;MacVim&lt;/strong&gt; menu &gt; &lt;strong&gt;Preferences&lt;/strong&gt; &gt; &lt;strong&gt;Advanced&lt;/strong&gt;) also resolved the font issue but that seems like a last resort option, as it decreases rendering performance.&lt;/p&gt;&#xA;" OwnerUserId="14846" LastEditorUserId="14846" LastEditDate="2019-10-14T23:07:53.263" LastActivityDate="2019-10-14T23:07:53.263" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21514" PostTypeId="2" ParentId="21510" CreationDate="2019-10-14T05:08:53.130" Score="3" Body="&lt;p&gt;The brackets are for chars. Use subpattern (parentheses) instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\%(a\|the\)\@3&amp;lt;! book&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\%( ... \)&lt;/code&gt; --- a (unnumbered) submatch&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;a\|the&lt;/code&gt; --- &quot;a&quot; or &quot;the&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\@3&amp;lt;!&lt;/code&gt; --- NO match behind (3 bytes lookback)&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-14T05:08:53.130" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="21515" PostTypeId="1" CreationDate="2019-10-14T10:32:03.990" Score="0" ViewCount="84" Body="&lt;p&gt;I installed &lt;a href=&quot;https://github.com/vim-scripts/Txtfmt-The-Vim-Highlighter&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Vim Highlighter&lt;/a&gt; plugin by Brett Stahlman. The plugin requires setting &lt;code&gt;filetype=txtfmt&lt;/code&gt;. I set the option using &lt;code&gt;:set ft=txtfmt&lt;/code&gt; but got conflicts like &lt;code&gt;Level 1 map ambiguity:[bf already mapped to &amp;lt;Plug&amp;gt;unimpairedBPrevious&lt;/code&gt; and many more. I think it's because I've installed &lt;code&gt;unimpairedBPrevious&lt;/code&gt; as well. I commented out &lt;code&gt;unimpairedBPrevious&lt;/code&gt; entry from my .vimrc but still got few conflicts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone help me how can I resolve these conflicts without compromising any plugin's functionality?&lt;/p&gt;&#xA;" OwnerUserId="22982" LastActivityDate="2019-10-14T10:32:03.990" Title="Getting conflict when setting ft=txtfmt" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21516" PostTypeId="2" ParentId="21511" CreationDate="2019-10-14T11:53:17.360" Score="5" Body="&lt;p&gt;As you can read from &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27termguicolors%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'termguicolors'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'termguicolors' 'tgc'   boolean (default off)&#xA;            global&#xA;    Enables 24-bit RGB color in the TUI.  Uses &quot;gui&quot; :highlight&#xA;    attributes instead of &quot;cterm&quot; attributes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So your highlighting command can not work since it doesn't provide a &lt;code&gt;guifg&lt;/code&gt; attribute. I think the following should do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight ALEWarning guibg=DarkMagenta&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it doesn't you might check that you have an ISO-8613-3 compatible terminal as specified in the help.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-10-14T11:53:17.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21517" PostTypeId="2" ParentId="21506" CreationDate="2019-10-14T13:20:03.373" Score="2" Body="&lt;p&gt;The easiest way is to change the keystrokes you use to start editing an empty line from &lt;kbd&gt;a&lt;/kbd&gt; to &lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;. This allows the built-in &lt;code&gt;cindent&lt;/code&gt; indentation to correctly adjust the indent when you enter insert mode, which it doesn't do when you specify that you want to append to the existing (blank) line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this will only work if &lt;code&gt;cindent&lt;/code&gt; is actually switched on. This should be the case for you &lt;em&gt;if&lt;/em&gt; you are editing a &lt;code&gt;C&lt;/code&gt; file (and not just typing into an empty unsaved buffer with no name or filetype) because you have switched on file type detection and indent-handling with your &lt;code&gt;filetype indent on&lt;/code&gt; command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to have to change your habits at all, that's easy enough to fix with a mapping that changes the behaviour of &lt;kbd&gt;a&lt;/kbd&gt; when pressed on an empty line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; a empty(getline('.')) ? 'cc' : 'a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-10-14T13:44:34.260" LastActivityDate="2019-10-14T13:44:34.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21518" PostTypeId="2" ParentId="19446" CreationDate="2019-10-14T21:12:12.113" Score="2" Body="&lt;p&gt;An alternative implementation which does not stop at the first error in a script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% Exec call execute(getline(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;), '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now in visual mode type &lt;code&gt;:'&amp;lt;,'&amp;gt;Exec&lt;/code&gt; to process the selected lines (&lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; is added automatically as usual). Also, &lt;code&gt;:Exec&lt;/code&gt; in normal mode executes the whole buffer, just as &lt;code&gt;:source %&lt;/code&gt;, except the buffer does not need to be saved first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If needed the mappings, they can be added easily.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-14T21:12:12.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21519" PostTypeId="1" AcceptedAnswerId="21520" CreationDate="2019-10-15T02:45:53.427" Score="0" ViewCount="160" Body="&lt;p&gt;I wrote a plugin that executes a slow shell script and asynchronously shows the stdout in a popup (split) window. When I try to close my session while the popup is open, I get the message&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Save changes to &quot;popup.log&quot;?&#xA;[Y]es, (N)o, (C)ancel&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I automatically reject changes to this temporary buffer without rejecting changes to the files I am actually editing (as would happen with &lt;code&gt;:qa!&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some buffer-local option I can set that allows the buffer to changes but specifies &quot;this is a temporary buffer, but never ever ask me to save changes&quot;? Seems like lots of vim plugins do this (tagbar, NERDtree, etc.) but I don't know how.  &lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2019-10-15T04:12:05.373" LastActivityDate="2019-10-15T04:44:10.297" Title="Permit closing window with unsaved changes using vim setting" Tags="|buffers|save|quit|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21520" PostTypeId="2" ParentId="21519" CreationDate="2019-10-15T04:44:10.297" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there some buffer-local option I can set that allows the buffer to changes but specifies &quot;this is a temporary buffer, but never ever ask me to save changes&quot;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The most essential one is &lt;code&gt;buftype=nofile&lt;/code&gt;. Also, &lt;code&gt;:h special-buffers&lt;/code&gt; recommends using &lt;code&gt;noswapfile&lt;/code&gt; (nowadays often switched off globally) and &lt;code&gt;bufhidden=hide&lt;/code&gt; (so a buffer can be reused after &lt;code&gt;:quit&lt;/code&gt;-ting the window; but note that &lt;code&gt;ZQ&lt;/code&gt; and &lt;code&gt;:quit!&lt;/code&gt; still drop it completely). As following these recommendations does not seem to hurt, you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal buftype=nofile bufhidden=hide noswapfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-15T04:44:10.297" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21522" PostTypeId="1" AcceptedAnswerId="21528" CreationDate="2019-10-15T11:07:54.070" Score="5" ViewCount="438" Body="&lt;p&gt;What is the correct way get the column of the cursor after a visual selection was made?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a simple example, consider the following command. It takes a range and I am trying to obtain the column to eventually pass both to a filter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range CursorColumn echo col('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abc&#xA;def&#xA;ghi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the cursor is on &lt;code&gt;c&lt;/code&gt; and a visual line-wise selection is started and extended downwards to the third line, the cursor is on &lt;code&gt;i&lt;/code&gt;. Switching to command-line mode and executing the command above, it echos &lt;code&gt;1&lt;/code&gt;. If the selection is started at &lt;code&gt;i&lt;/code&gt; and extended upwards to &lt;code&gt;c&lt;/code&gt;, then the command echos &lt;code&gt;3&lt;/code&gt;, which I would expect in both cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get the column of the cursor independently of how the selection was made?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My use case is that I want to pass the selected lines to a filter. At the same time I would like to pass the column the cursor was on as an argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range MyFilter exe &amp;lt;line1&amp;gt;.&quot;,&quot;.&amp;lt;line2&amp;gt;.&quot;!myfilter &quot;.col('.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;Making the selection in &lt;strong&gt;visual mode&lt;/strong&gt;, instead of &lt;strong&gt;linewise-visual&lt;/strong&gt;, shows the behavior I want: I get the column the cursor was on when I execute the command no matter how I made the selection.&lt;/p&gt;&#xA;" OwnerUserId="25225" LastEditorUserId="25225" LastEditDate="2019-10-16T15:19:34.950" LastActivityDate="2019-10-16T15:19:34.950" Title="Cursor Column in Visual Selection" Tags="|visual-mode|cursor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21523" PostTypeId="1" CreationDate="2019-10-15T19:11:30.893" Score="2" ViewCount="46" Body="&lt;p&gt;The address is &lt;a href=&quot;ftp://ftp.yandex.ru/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ftp://ftp.yandex.ru/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried from bash:&#xA;&lt;code&gt;vim ftp://ftp.yandex.ru/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that I was asked for username and password (but this is public anonymous server), ok I entered &lt;code&gt;anonymous&lt;/code&gt; for username and password. I tried to &quot;enter&quot; empty username and password also. I see this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ============================================================================&#xA;&quot; Netrw Directory Listing                                        (netrw v156)&#xA;&quot;   ftp://ftp.yandex.ru/&#xA;&quot;   Sorted by      name&#xA;&quot;   Sort sequence: [\/]$,\&amp;lt;core\%(\.\d\+\)\=\&amp;gt;,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$&#xA;&quot;   Quick Help: &amp;lt;F1&amp;gt;:help  -:go up dir  D:delete  R:rename  s:sort-by  x:special&#xA;&quot; ==============================================================================&#xA;../&#xA;./&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim 8 from default repository on Xubuntu 18.04.3 LTS.&lt;/p&gt;&#xA;" OwnerUserId="6038" LastEditorUserId="6038" LastEditDate="2019-10-16T10:59:31.133" LastActivityDate="2019-10-16T10:59:31.133" Title="Cannot :Explore public ftp service (I see empty listing with ../ and ./)" Tags="|netrw|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21525" PostTypeId="1" AcceptedAnswerId="21529" CreationDate="2019-10-15T21:46:38.263" Score="0" ViewCount="56" Body="&lt;p&gt;I'm trying to do &lt;code&gt;i&amp;lt;Ctrl-R&amp;gt;=expandcmd('se shm')&lt;/code&gt; and more generally &lt;code&gt;i&amp;lt;Ctrl-R&amp;gt;=expandcmd({expr})&lt;/code&gt; but I'm just getting the literal {expr} inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I type &lt;code&gt;:se shm&amp;lt;CR&amp;gt;&lt;/code&gt; I get the value of the option printed on the command-line. I'd like that inserted into my buffer.&lt;/p&gt;&#xA;" OwnerUserId="22837" LastEditorUserId="22837" LastEditDate="2019-10-16T00:00:08.877" LastActivityDate="2019-10-16T08:12:24.623" Title="Why doesn't i&lt;Ctrl-R&gt;=expandcmd('se shm') work?" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21526" PostTypeId="1" AcceptedAnswerId="21527" CreationDate="2019-10-16T03:02:16.903" Score="1" ViewCount="302" Body="&lt;p&gt;I've used the information in &lt;a href=&quot;https://vi.stackexchange.com/questions/16963/remap-esc-key-in-vim&quot;&gt;this answer&lt;/a&gt; previously, but recently encountered a minimal installation with only vi. I edited the .vimrc in the user's home folder (&lt;code&gt;~/.vimrc&lt;/code&gt;), but when typing &lt;code&gt;jj&lt;/code&gt;, the literal text &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; was entered within insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does one do an inoremap for the escape key in vi?&lt;/p&gt;&#xA;" OwnerUserId="16795" LastEditorUserId="343" LastEditDate="2019-10-16T15:43:06.357" LastActivityDate="2019-10-16T15:43:06.357" Title="How to remap escape in *vi* (not vim)?" Tags="|escape|original-vi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21527" PostTypeId="2" ParentId="21526" CreationDate="2019-10-16T04:06:16.210" Score="3" Body="&lt;p&gt;The key syntax with brackets, such as &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, is specific to Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In plain vi, you need to enter an &lt;em&gt;actual&lt;/em&gt; ESC character in your mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do so by pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt;, followed by &lt;kbd&gt;ESC&lt;/kbd&gt;, which will insert an actual ESC and will be displayed as &lt;code&gt;^[&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command will look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap jj ^[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But note that the &lt;code&gt;^[&lt;/code&gt; is a single ESC character and is entered with the sequence described above.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-10-16T04:06:16.210" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21528" PostTypeId="2" ParentId="21522" CreationDate="2019-10-16T07:58:10.437" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How do I get the column of the cursor independently of how the selection was made?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Let's make it clear: at this point you're &lt;strong&gt;already in the normal mode&lt;/strong&gt;. All you can get is the selection range, not the cursor position at the time it was made. And so &lt;code&gt;col('.')&lt;/code&gt; correctly returns &lt;strong&gt;the current cursor position&lt;/strong&gt;, not the previous one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your confusion is based on an incorrect assumption that the cursor position is preserved on such transition from visual mode to normal. That's not true. The docs never say Vim should do this. And in fact, Vim normally moves the cursor into the topleft corner of the selection before executing a command. But not always, in particular, while in Visual-Line mode using only &lt;code&gt;k&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt; to extend the selection, the cursor stays in place (the true conditions may be more complicated, of course).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the point is that such things are not documented and should be viewed as a kind of &quot;undefined behaviour&quot;. You should not make any use of it, especially in linewise mode where the cursor column must be totally irrelevant.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-16T07:58:10.437" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21529" PostTypeId="2" ParentId="21525" CreationDate="2019-10-16T08:12:24.623" Score="0" Body="&lt;p&gt;&lt;code&gt;expandcmd()&lt;/code&gt; expands wildcards, environment variables and such. It is not intended for VimScript execution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, you can use &lt;code&gt;execute()&lt;/code&gt; function to run VimScript interpreter and get the ouput as a string. But in this case it's enough to use &amp;amp;-notation (see &lt;code&gt;:h expr-option&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i&amp;lt;C-R&amp;gt;=&amp;amp;shm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-16T08:12:24.623" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21530" PostTypeId="1" CreationDate="2019-10-16T09:35:43.217" Score="1" ViewCount="535" Body="&lt;p&gt;&lt;code&gt;view&lt;/code&gt; is the readonly mode of &lt;code&gt;vim&lt;/code&gt;. I would like &lt;code&gt;view&lt;/code&gt; to read the exact same &lt;code&gt;.vimrc&lt;/code&gt; file for its initialization as &lt;code&gt;vim&lt;/code&gt; already does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;view&lt;/code&gt; does not seem to read &lt;code&gt;~/.vimrc&lt;/code&gt; by default (I checked by adding &lt;code&gt;echo &quot;hello, world&quot;&lt;/code&gt; at the bottom). Using &lt;code&gt;view -u ~/.vimrc&lt;/code&gt; does not work for me either. Reading &lt;code&gt;:help initialization&lt;/code&gt; it seems that there are special files for &lt;strong&gt;e&lt;/strong&gt;vim and &lt;strong&gt;e&lt;/strong&gt;view, but not for &lt;code&gt;view&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unsurprisingly, &lt;code&gt;vim -R&lt;/code&gt; reads &lt;code&gt;.vimrc&lt;/code&gt; files. How do I make &lt;code&gt;view&lt;/code&gt; do the same?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Version info&lt;/h2&gt;&#xA;&#xA;&lt;h3&gt;vim&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 14 2019 11:41:55)&#xA;Included patches: 1-160, 399, 402-403, 1099&#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;-clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   +perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python/dyn      +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            +ruby/dyn        +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            +mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;   system vimrc file: &quot;/etc/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/etc&quot;&#xA; f-b for $VIMRUNTIME: &quot;/usr/share/vim/vim74&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D__linux__ -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -L. -Wl,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-rpath,/usr/lib64/perl5/CORE  -Wl,-z,relro  -L/usr/local/lib -Wl,--as-needed -o vim        -lm -lnsl  -lselinux  -lncurses -lacl -lattr -lgpm -ldl   -Wl,--enable-new-dtags -Wl,-rpath,/usr/lib64/perl5/CORE  -fstack-protector  -L/usr/lib64/perl5/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;view&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ view !$&#xA;view --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 14 2019 11:42:11)&#xA;Included patches: 1-160, 399, 402-403, 1099&#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Small version without GUI.  Features included (+) or not (-):&#xA;+acl             -farsi           -mouse_sgr       -tag_old_static&#xA;-arabic          -file_in_path    -mouse_sysmouse  -tag_any_white&#xA;-autocmd         -find_in_path    -mouse_urxvt     -tcl&#xA;-balloon_eval    -float           -mouse_xterm     +terminfo&#xA;-browse          -folding         +multi_byte      -termresponse&#xA;+builtin_terms   -footer          -multi_lang      -textobjects&#xA;-byte_offset     +fork()          -mzscheme        -title&#xA;-cindent         -gettext         -netbeans_intg   -toolbar&#xA;-clientserver    -hangul_input    -path_extra      -user_commands&#xA;-clipboard       +iconv           -perl            -vertsplit&#xA;-cmdline_compl   -insert_expand   -persistent_undo -virtualedit&#xA;+cmdline_hist    +jumplist        -printer         +visual&#xA;-cmdline_info    -keymap          -profile         -visualextra&#xA;-comments        -langmap         -python          -viminfo&#xA;-conceal         -libcall         -python3         -vreplace&#xA;-cryptv          -linebreak       -quickfix        +wildignore&#xA;-cscope          -lispindent      -reltime         -wildmenu&#xA;-cursorbind      -listcmds        -rightleft       +windows&#xA;-cursorshape     -localmap        -ruby            +writebackup&#xA;-dialog          -lua             -scrollbind      -X11&#xA;-diff            -menu            -signs           -xfontset&#xA;-digraphs        -mksession       -smartindent     -xim&#xA;-dnd             -modify_fname    -sniff           -xsmp&#xA;-ebcdic          -mouse           -startuptime     -xterm_clipboard&#xA;-emacs_tags      -mouse_dec       -statusline      -xterm_save&#xA;-eval            -mouse_gpm       -sun_workshop    -xpm&#xA;-ex_extra        -mouse_jsbterm   -syntax&#xA;-extra_search    -mouse_netterm   -tag_binary&#xA;   system vimrc file: &quot;/etc/virc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/etc&quot;&#xA; f-b for $VIMRUNTIME: &quot;/usr/share/vim/vim74&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D__linux__ -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -Wl,-z,relro  -L/usr/local/lib -Wl,--as-needed -o vim        -lm  -lselinux -lncurses -lacl -lattr -ldl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23667" LastEditorUserId="23667" LastEditDate="2019-10-16T10:27:40.637" LastActivityDate="2023-09-28T06:03:50.457" Title="How to make &quot;view&quot; read vimrc?" Tags="|vimrc|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="21531" PostTypeId="1" AcceptedAnswerId="21532" CreationDate="2019-10-16T12:46:45.673" Score="2" ViewCount="294" Body="&lt;p&gt;I'd like to have a colorscheme but keeping my terminal color as a background color. This code achieved that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colorscheme MyFavoriteOne&#xA;autocmd ColorScheme * highlight Normal ctermbg=NONE guibg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd also like to have a different colorscheme for different filetype. By itself, this also works :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype txt colorscheme NiceTheme&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that now for &lt;code&gt;.txt&lt;/code&gt; files my background is not my terminal background no more (even if permute the code lines above). Is there a solution?&lt;/p&gt;&#xA;" OwnerUserId="14401" LastActivityDate="2019-10-16T13:47:12.440" Title="Vim different colorchemes for different file, but same backgroung color" Tags="|colorscheme|filetype|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21532" PostTypeId="2" ParentId="21531" CreationDate="2019-10-16T13:47:12.440" Score="3" Body="&lt;p&gt;Change your &lt;code&gt;FileType&lt;/code&gt; autocommand to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype txt ++nested colorscheme NiceTheme&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to allow for nesting (by default, they do not nest).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h autocmd-nested&lt;/code&gt; (and thanks to Matt for the tip).&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-10-16T13:47:12.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21533" PostTypeId="1" AcceptedAnswerId="21548" CreationDate="2019-10-16T13:57:43.167" Score="0" ViewCount="40" Body="&lt;p&gt;I create a session using &lt;code&gt;:mks&lt;/code&gt;, which has tabs and split views inside tabs. When I open the session using &lt;code&gt;vi -S Session.vim&lt;/code&gt;, some of the files are swapped around. I have tried deleting and creating new session files, but to no good. It behaves reproducibly. If I create a session with an identical arrangement of files in tabs and splits, it swaps the same files in the same way. If I intentionally swap the files to get the desired outcome, I get the right outcomes for the two tabs among which the original swap occurred, but other files swap. It is mysterious and very annoying. Any ideas what may be wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using vim -S instead of vi -S does not make any difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This happens on a work computer, where I have only a pseudo-sudo access. (can install new software only from existing repositories) Therefore, I cannot install ViM 8, which has not been uploaded to the Ubuntu repository yet. I will try to reproduce this on my personal computer and see if updating ViM helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 07 2019 15:35:43)&#xA;&#xA;(2:7.4.1689-3ubuntu1.3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;I have managed to reproduce it on my personal computer and after updating to ViM 8 the problem disappeared. There is not much point in seeking solution for older versions, so let's consider this question solved.&lt;/p&gt;&#xA;" OwnerUserId="25243" LastEditorUserId="25243" LastEditDate="2019-10-17T19:59:31.113" LastActivityDate="2019-10-17T20:00:52.223" Title="Vim session swaps files around" Tags="|sessions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21534" PostTypeId="1" CreationDate="2019-10-16T14:07:11.093" Score="1" ViewCount="37" Body="&lt;p&gt;Is it possible to wrap the matches shown by YCM ? My current workaround is to decrease font size till I am able to see it and then increase font size. This is tedious and painful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any other way?&lt;/p&gt;&#xA;" OwnerUserId="23710" LastEditorUserId="205" LastEditDate="2019-11-06T06:48:22.963" LastActivityDate="2019-11-06T06:48:22.963" Title="Wrap matches shown by You Complete Me" Tags="|plugin-you-complete-me|wrapping|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21535" PostTypeId="1" CreationDate="2019-10-16T14:54:51.193" Score="0" ViewCount="47" Body="&lt;p&gt;In my vimrc I have the following mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set completeopt=longest,menuone,preview&#xA;inoremap &amp;lt;C-h&amp;gt;    &amp;lt;C-n&amp;gt; &#xA;inoremap &amp;lt;C-k&amp;gt;    &amp;lt;C-p&amp;gt;&#xA;inoremap &amp;lt;Leader&amp;gt;k &amp;lt;C-x&amp;gt;&amp;lt;C-k&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to be able to navigate up and down in the dictionary completion list I get with &lt;code&gt;&amp;lt;Leader&amp;gt;k&lt;/code&gt; by using &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt;. However, both move down in the list, contrary to the behaviour I'd expect as I have them mapped to &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt;. Any idea why this doesn't work? The keybindings behave the way they should when I access keyword completion, so I'm not sure what I might have done wrong.&lt;/p&gt;&#xA;" OwnerUserId="25247" LastActivityDate="2019-10-16T14:54:51.193" Title="navigating dictionary completion" Tags="|key-bindings|autocompletion|dictionary|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21536" PostTypeId="1" AcceptedAnswerId="21537" CreationDate="2019-10-17T06:06:49.180" Score="0" ViewCount="311" Body="&lt;p&gt;I sometimes make shortcuts for myself, which run some external command on the current buffer, such as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-f&amp;gt; :%!clang-format -style=file&amp;lt;C-m&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which formats the buffer with clang's formatter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this makes the cursor jump to the beginning of the file. Is there some way to avoid this?&#xA;I understand it would be difficult finding the correct line after reformatting, but just the same line number would be good. I assume one could set and use marks in the mapping somehow, but any smarter solution would also be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2019-10-17T06:42:08.300" Title="How can I keep the cursor position when piping the buffer through an external command?" Tags="|external-command|line-numbers|cursor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21537" PostTypeId="2" ParentId="21536" CreationDate="2019-10-17T06:36:57.057" Score="3" Body="&lt;p&gt;See &lt;code&gt;:h getcurpos()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically there is an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        This can be used to save and restore the cursor position: &amp;gt;&#xA;            let save_cursor = getcurpos()&#xA;            MoveTheCursorAround&#xA;            call setpos('.', save_cursor)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can try it with smth like (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-f&amp;gt; :let save_cursor=getcurpos() &amp;lt;bar&amp;gt; %!clang-format -style=file &amp;lt;bar&amp;gt; call setpos('.', save_cursor)&amp;lt;CR&amp;gt;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or make it a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-f&amp;gt; :call Clang_format()&amp;lt;CR&amp;gt;&#xA;&#xA;func! Clang_format()&#xA;    let save_cursor = getcurpos()&#xA;    exe '%!clang-format -style=file'&#xA;    call setpos('.', save_cursor)&#xA;endfunc&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-10-17T06:42:08.300" LastActivityDate="2019-10-17T06:42:08.300" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21538" PostTypeId="1" AcceptedAnswerId="21539" CreationDate="2019-10-17T08:34:32.497" Score="2" ViewCount="1514" Body="&lt;p&gt;I have a file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int var;&#xA;&#xA;int f() {&#xA;    // Use of var&#xA;}&#xA;&#xA;int g() {&#xA;    // Use of var&#xA;}&#xA;&#xA;int h() {&#xA;    // Use of var&#xA;}&#xA;&#xA;// ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to move my global &lt;code&gt;var&lt;/code&gt; into each function to get this file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int f() {&#xA;    int var;&#xA;    // Use of var&#xA;}&#xA;&#xA;int g() {&#xA;    int var;&#xA;    // Use of var&#xA;}&#xA;&#xA;int h() {&#xA;    int var;&#xA;    // Use of var&#xA;}&#xA;&#xA;// ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I started by yanking the declaration of &lt;code&gt;var&lt;/code&gt; and then created a macro to paste the contents of the register every 4 lines. This method has 2 problems. First, if my functions &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;g&lt;/code&gt;, &lt;code&gt;h&lt;/code&gt;,  ... have different numbers of lines, I can't use it. Also, I have to type &lt;code&gt;@@&lt;/code&gt; to repeat my macro again and again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to tell vim to paste the contents of my register after each line that matches a pattern: &lt;code&gt;/^int .*() {$/&lt;/code&gt; in my example?&lt;/p&gt;&#xA;" OwnerUserId="24895" LastEditorUserId="343" LastEditDate="2019-10-17T09:44:29.367" LastActivityDate="2019-10-17T14:19:31.783" Title="How to paste text after each line matching a pattern?" Tags="|regular-expression|cut-copy-paste|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21539" PostTypeId="2" ParentId="21538" CreationDate="2019-10-17T09:15:33.367" Score="4" Body="&lt;h2&gt;Using a :global command&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can use a &lt;a href=&quot;http://www.vimhelp.org/repeat.txt.html#%3Aglobal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:global&lt;/code&gt;&lt;/a&gt; command to run a command on every line that matches a pattern. Try the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^int .*() {$/put&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can equally easily run a macro once on each line that matches the pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^int .*() {$/normal! @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Using a macro&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;An alternative solution is to alter your macro so that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Instead of just moving down four lines, it uses more precise motions to move to the correct place,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It stops when it gets to the end of the file, so that instead of having to type &lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt; the exact number of times, you can instead just use a really large count, e.g. &lt;kbd&gt;9&lt;/kbd&gt;&lt;kbd&gt;9&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here's one way you could do this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting with the cursor at the top of the file (and having already yanked the variable definition with a linewise command such as &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;), type the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt;&lt;kbd&gt;%&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Breaking that down:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; Start recording a macro into the &lt;code&gt;&quot;q&lt;/code&gt; register,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt; &lt;a href=&quot;http://www.vimhelp.org/motion.txt.html#%5D%5B&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jump to the &lt;code&gt;}&lt;/code&gt; brace at the end of the function&lt;/a&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;%&lt;/kbd&gt; &lt;a href=&quot;http://www.vimhelp.org/motion.txt.html#%25&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jump back to the opening &lt;code&gt;{&lt;/code&gt; brace&lt;/a&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;p&lt;/kbd&gt; Put/paste your line,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;=&lt;/kbd&gt;&lt;kbd&gt;=&lt;/kbd&gt; &lt;a href=&quot;http://www.vimhelp.org/change.txt.html#%3D%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ensure indentation is correct&lt;/a&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;]&lt;/kbd&gt;&lt;kbd&gt;[&lt;/kbd&gt; Jump to the end of the function again, so that we're in the correct place the next time the macro is called, &lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt; End the recording.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;An alternative to the &lt;code&gt;][&lt;/code&gt; and &lt;code&gt;%&lt;/code&gt; motions is simply to include your search in the macro, but note that if you then want to playback the macro with a very large count (rather than using a precise count or manually typing &lt;code&gt;@@&lt;/code&gt; until you get to the last match in the buffer), you will need to turn off &lt;code&gt;'wrapscan'&lt;/code&gt; to stop the macro wrapping around to the start of the buffer when it reaches the end:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nowrapscan&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-10-17T14:19:31.783" LastActivityDate="2019-10-17T14:19:31.783" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21540" PostTypeId="1" CreationDate="2019-10-17T09:21:19.293" Score="3" ViewCount="868" Body="&lt;p&gt;I now have Vim version 8.1.2102 from Sep 30 2019 15:45:59 on Fedora 30. For some reason the word boundary in C++ code now also includes the underscore somehow, so I see this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mBxUA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mBxUA.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I have the cursor over that and press &lt;code&gt;*&lt;/code&gt;, it will only search for &lt;code&gt;quark&lt;/code&gt;. When I do &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; it will try to search for the tag &lt;code&gt;quark&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a bunch of plugins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls .vim/bundle&#xA;molokai/             vim-eunuch/         vim-regex-collection/&#xA;SingleCompile/       vim-fish/           vim-repeat/&#xA;syntastic/           vim-fswitch/        vim-snipmate/&#xA;tlib_vim/            vim-gutentags/      vim-surround/&#xA;vim-addon-mw-utils/  vim-headings/       vim-unimpaired/&#xA;vim-dirvish/         Vim-Jinja2-Syntax/  VOoM/&#xA;vim-dokuwiki/        vim-mathematica/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have not changed the plugins but Vim got updated and somehow this has changed. How can I further triage and fix this issue?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In the C++ code file I have this setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iskeyword=a-z,A-Z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my whole &lt;code&gt;.vim&lt;/code&gt; directory there is not a single spot where this is set to anything nonsensical:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ grep -R iskeyword .&#xA;./bundle/vim-fish/ftplugin/fish.vim:setlocal iskeyword=@,48-57,-,_,.,/&#xA;./bundle/vim-mathematica/syntax/mma.vim:setlocal iskeyword+=`,$&#xA;./bundle/vim-mathematica/syntax/mma.vim:setlocal iskeyword-=:,-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Fish is a shell and mma is for Wolfram Language code. Since the &lt;code&gt;filetype&lt;/code&gt; is set to &lt;code&gt;cpp&lt;/code&gt;, neither of them should be invoked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could just add &lt;code&gt;set iskeyword+=_&lt;/code&gt; to my &lt;code&gt;.vimrc&lt;/code&gt; but that does not seem right.&lt;/p&gt;&#xA;" OwnerUserId="5210" LastEditorUserId="5210" LastEditDate="2019-10-17T10:41:03.533" LastActivityDate="2019-10-17T10:57:58.890" Title="Underscore suddenly a word boundary" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21541" PostTypeId="2" ParentId="21540" CreationDate="2019-10-17T10:21:17.790" Score="3" Body="&lt;p&gt;This is configured by the &lt;code&gt;'iskeyword'&lt;/code&gt; setting. You can check the current value and what set that value by running the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set iskeyword?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.vimhelp.org/options.txt.html#%27iskeyword%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'iskeyword'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://www.vimhelp.org/options.txt.html#%27isfname%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'isfname'&lt;/code&gt;&lt;/a&gt; for details of this setting. It is a comma delimited string which usually contains a specific &lt;code&gt;_&lt;/code&gt; item.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the thing that is setting the option incorrectly cannot be configured not to do so, you can fix this by placing settings in a file in a subdirectory of your &lt;a href=&quot;http://www.vimhelp.org/options.txt.html#after-directory&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;.vim/after&lt;/code&gt; directory&lt;/a&gt;: the precise best location depends on exactly what is breaking the setting in the first place, but I'm guessing adding either of the following lines to &lt;code&gt;.vim/after/ftplugin/cpp.vim&lt;/code&gt; would work for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Just add an underscore&#xA;setlocal iskeyword+=_&#xA;&#xA;&quot; Reset to default&#xA;setlocal iskeyword&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-10-17T10:57:58.890" LastActivityDate="2019-10-17T10:57:58.890" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="21542" PostTypeId="1" AcceptedAnswerId="21544" CreationDate="2019-10-17T12:08:10.903" Score="3" ViewCount="284" Body="&lt;p&gt;So I have a plugin that I am writing which should allow the user to set whether they want to enable a feature. I want the feature to be disabled by default, and allow the user to change it by adding something like this to their .vimrc &lt;code&gt;let g:myplugin_enable_feature = 1&lt;/code&gt;, though when the user doesn't set the variable in their vimrc, it throws an error, as the variable is undefined. &#xA;I can fix the error by defining the variable inside of my plugin script, though when I do that, the user loses the ability to change the variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the proper way to allow the user to decide whether they want to change an option, without vim throwing an error when the user doesn't do anything?&lt;/p&gt;&#xA;" OwnerUserId="23679" LastActivityDate="2019-10-18T08:58:35.877" Title="What is the proper way to allow the user of a plugin to modify settings?" Tags="|vimscript|options|user-input|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21543" PostTypeId="2" ParentId="21542" CreationDate="2019-10-17T12:30:52.907" Score="4" Body="&lt;p&gt;Usually it suffices to use &lt;code&gt;get()&lt;/code&gt; function. Like that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if get(g:, 'myplugin_enable_feature')&#xA;    &quot; do something&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the feature should be enabled by default you can change it to &lt;code&gt;get(g:, 'myplugin_enable_feature', 1)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-17T12:30:52.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21544" PostTypeId="2" ParentId="21542" CreationDate="2019-10-17T12:32:24.443" Score="7" Body="&lt;p&gt;The simple way is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if get(g:, 'myplugin_enable_feature', defaultvalue)&#xA;   do whatever you want&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when I need to check a setting in more than one place, I usually prefer to have a dedicated getter in my plugin to be sure I have the same default value everywhere&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:enable_feature() abort&#xA;    return get(g:, 'myplugin_enable_feature', defaultvalue)&#xA;endfunction&#xA;.&#xA;.&#xA;.&#xA;if s:enable_feature()&#xA;   ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the setting can be buffer local, and could default on a global value that could default on some constant, I use &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/Options.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;dedicated functions&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2019-10-18T08:58:35.877" LastActivityDate="2019-10-18T08:58:35.877" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21545" PostTypeId="2" ParentId="7421" CreationDate="2019-10-17T14:31:57.420" Score="2" Body="&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;: You could record and apply the macro &lt;code&gt;03f,a ra: &amp;lt;Esc&amp;gt;j&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regular expression answers above are very good performance wise. However, for quick substitutions I would suggest using macro's. Above can be done by defining and applying the following macro:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Go to first line containing the to be edited text.&lt;/li&gt;&#xA;&lt;li&gt;Start recording macro to, lets say,&lt;code&gt;t&lt;/code&gt; ⇒ &lt;code&gt;qt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Jump to start of line ⇒ &lt;code&gt;0&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Jump to third occurrence of &lt;code&gt;,&lt;/code&gt; ⇒ &lt;code&gt;3f,&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;Append &lt;code&gt;ra:&lt;/code&gt; behind cursor ⇒ &lt;code&gt;a ra:&lt;/code&gt; (note the space behind &lt;code&gt;:&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Go to the next row ⇒ &lt;code&gt;&amp;lt;Esc&amp;gt;j&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Save the macro ⇒ &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Run the macro, lets say, 100 times ⇒ &lt;code&gt;100@t&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;(For people new to Vim: If you are using Vim for some time, then creating a similar macro and applying it takes less than a minute.)&lt;/p&gt;&#xA;" OwnerUserId="25264" LastEditorUserId="25264" LastEditDate="2019-10-18T07:25:11.857" LastActivityDate="2019-10-18T07:25:11.857" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21546" PostTypeId="1" AcceptedAnswerId="21553" CreationDate="2019-10-17T15:16:52.270" Score="2" ViewCount="1223" Body="&lt;p&gt;Is it possible to automatically create a highlight which is the reverse of an existing highlight? Example &lt;code&gt;highlight Search guifg=Black guibg=Yellow&lt;/code&gt;, becomes &lt;code&gt;highlight CustomHighlight guifg=Yellow guibg=Black&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would want to use this to highlight certain text so that it would look like the inverse of whatever the user has set as their search highlight color. Could vimscript be used to achieve this effect?&lt;/p&gt;&#xA;" OwnerUserId="23679" LastActivityDate="2023-07-07T05:28:31.243" Title="Is it possible to reverse an existing highlighting group?" Tags="|vimscript|highlight|color|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21547" PostTypeId="2" ParentId="21546" CreationDate="2019-10-17T16:05:11.790" Score="1" Body="&lt;p&gt;Not sure if it's a good idea at all, but it's certainly possible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HiliteSwap(group)&#xA;    let l:hi = execute('hi ' . a:group)&#xA;    let l:ctermfg = matchstr(l:hi, 'ctermfg=\zs\S*')&#xA;    let l:ctermbg = matchstr(l:hi, 'ctermbg=\zs\S*')&#xA;    let l:guifg = matchstr(l:hi, 'guifg=\zs\S*')&#xA;    let l:guibg = matchstr(l:hi, 'guibg=\zs\S*')&#xA;    call execute(printf(&quot;hi %s ctermfg=%s ctermbg=%s guifg=%s guibg=%s&quot;, a:group, l:ctermbg, l:ctermfg, l:guibg, l:guifg))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-17T16:05:11.790" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21548" PostTypeId="2" ParentId="21533" CreationDate="2019-10-17T20:00:52.223" Score="0" Body="&lt;p&gt;The solution is updating to ViM 8.&lt;/p&gt;&#xA;" OwnerUserId="25243" LastActivityDate="2019-10-17T20:00:52.223" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21549" PostTypeId="1" AcceptedAnswerId="21560" CreationDate="2019-10-17T20:40:08.220" Score="1" ViewCount="396" Body="&lt;p&gt;In the following screenshot, I demonstrate the following operations that shall yield a &quot;buffer&quot; that cannot be closed. My guess is that the list of files/directories is actually not a buffer. My question is: &lt;strong&gt;how to close such a thing?&lt;/strong&gt; When I use &lt;code&gt;:bnext&lt;/code&gt;, such a &quot;buffer&quot; always get in my way.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open a &quot;directory&quot; by &lt;code&gt;vim ~&lt;/code&gt; (this opened my home directory); ==&gt; I then get the first &quot;buffer&quot; opened, displaying the list of files + directories in my &lt;code&gt;~&lt;/code&gt; directory;&lt;/li&gt;&#xA;&lt;li&gt;In the newly opened Vim session, edit (open) &lt;code&gt;.Xauthority&lt;/code&gt; file by &lt;code&gt;:e .Xauthority&lt;/code&gt;; ==&gt; This brings up another buffer&lt;/li&gt;&#xA;&lt;li&gt;Then, I close the new buffer with &lt;code&gt;:bd&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Lastly, I tried twice to close the first buffer of all files+directories with &lt;code&gt;:bd&lt;/code&gt;. ==&gt; nothings gets closed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have been experiencing the problem all Vim installations that I have: on Windows machine as &lt;code&gt;gvim.exe&lt;/code&gt;, on Linux machine through the commandline (this recording) and on Linux with &lt;code&gt;gvim&lt;/code&gt; GUI sessions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mfTRB.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mfTRB.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2398" LastActivityDate="2019-10-18T13:17:48.150" Title="Closing the &quot;list of files in a directory&quot; when having Vim to open the directory" Tags="|gvim|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21550" PostTypeId="1" AcceptedAnswerId="21551" CreationDate="2019-10-17T21:21:58.433" Score="3" ViewCount="819" Body="&lt;p&gt;From a recent reddit post I saw:&#xA;&lt;a href=&quot;https://old.reddit.com/r/vim/comments/bm0ihb/evolution_of_a_vim_user/emt4p4a/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://old.reddit.com/r/vim/comments/bm0ihb/evolution_of_a_vim_user/emt4p4a/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I keep seeing jk, am I the only one who does kj? It feels more natural to roll from the outside in than from the inside out. Is there a reason jk is more popular?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I also saw it in this answer:&#xA;&lt;a href=&quot;https://vi.stackexchange.com/a/18081/25025&quot;&gt;https://vi.stackexchange.com/a/18081/25025&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For me it's more natural to roll from pinky to index finger. Therefore I chose to use kj. Also, I did a grep -rHin kj ~/src (recursive grep on the parent directory of all my source code) and found no matches.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and also this great book:&#xA;&lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/10.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://learnvimscriptthehardway.stevelosh.com/chapters/10.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It's typed with two separate keys, so you can &quot;roll&quot; your fingers instead of using the same one twice.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But I don't really know what this physically means. Could someone explain as it seems very ubiquitous in the Vim community.&lt;/p&gt;&#xA;" OwnerUserId="25025" LastEditorUserId="4472" LastEditDate="2019-10-25T01:25:35.003" LastActivityDate="2019-10-25T21:01:30.477" Title="Could someone explain &quot;rolling one's finger&quot; when used in a Vim context?" Tags="|key-bindings|terminology|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21551" PostTypeId="2" ParentId="21550" CreationDate="2019-10-17T21:25:32.610" Score="5" Body="&lt;p&gt;In the context given, it just means to press one key with one finger, and then immediately press an adjacent key with an adjacent finger. While doing so, your entire hand may rotate slightly. Hence: “roll”.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For what it’s worth, whilst I may have read other people use the word in this way before, I haven’t &lt;em&gt;noticed&lt;/em&gt; that they did so, and certainly wouldn’t have described it as a “roll” myself, so I’m not sure if the term as ubiquitous in the community as you think it is.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-10-17T21:31:29.047" LastActivityDate="2019-10-17T21:31:29.047" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21552" PostTypeId="1" CreationDate="2019-10-17T22:14:19.773" Score="2" ViewCount="333" Body="&lt;p&gt;In &lt;code&gt;neovim&lt;/code&gt;, open two different buffers as follows (using &lt;code&gt;:vnew&lt;/code&gt;, for example):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*--------------*--------------*&#xA;|              |              |&#xA;|      1       |       2      |&#xA;|              |              |&#xA;*--------------*--------------*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the first, run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au BufEnter &amp;lt;buffer&amp;gt; :call feedkeys('ahello', 'n') &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the second, run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:au BufEnter &amp;lt;buffer&amp;gt; :call feedkeys('ahola', 'n') &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, with the cursor in the second window, use e.g. &lt;code&gt;:History&lt;/code&gt; from fzf.vim&#xA;and cancel the search with &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing this on my machine, both autocommands are triggered on escaping the &lt;code&gt;fzf&lt;/code&gt; window and, even more strange, they are executed in the same pane. Is this a bug, or am I not using autocommands correctly?&#xA;End result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*--------------*--------------*&#xA;|              |helloahola    |&#xA;|              |              |&#xA;|              |              |&#xA;*--------------*--------------*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11125" LastEditorUserId="11125" LastEditDate="2019-10-18T10:00:58.770" LastActivityDate="2019-10-18T10:00:58.770" Title="Behaviour of BufEnter" Tags="|neovim|autocmd|plugin-fzf|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21553" PostTypeId="2" ParentId="21546" CreationDate="2019-10-18T06:52:30.033" Score="2" Body="&lt;p&gt;This is certainly possible, but it requires a bit of VimScript. The following function does the basic thing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func SwapHiGroup(group)&#xA;    let id = synIDtrans(hlID(a:group))&#xA;    for mode in ['cterm', 'gui']&#xA;        for g in ['fg', 'bg']&#xA;            exe 'let '. mode.g. &quot;=  synIDattr(id, '&quot;.&#xA;                        \ g.&quot;#', '&quot;. mode. &quot;')&quot;&#xA;            exe &quot;let &quot;. mode.g. &quot; = empty(&quot;. mode.g. &quot;) ? 'NONE' : &quot;. mode.g&#xA;        endfor&#xA;    endfor&#xA;    exe printf('hi %s ctermfg=%s ctermbg=%s guifg=%s guibg=%s', a:group, ctermbg, ctermfg, guibg, guifg)&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is, to query the syntax attributes using the function &lt;a href=&quot;https://vimhelp.org/eval.txt.html#synIDattr()&quot; rel=&quot;nofollow noreferrer&quot;&gt;synIDattr()&lt;/a&gt;. However you need to query each attribute (like 'fg', 'bg', etc) separately. In addition you need to do this separately for the different modes (like 'term', 'cterm', 'gui'), etc. So the whole function is a bit tedious to write. Therefore I made the function dynamically assign the different variables 'ctermfg', 'ctermbg', 'guifg' and 'guibg'. However this makes quoting a bit nasty :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also, the use of querying the attributes with a &lt;code&gt;#&lt;/code&gt; (e.g. &lt;code&gt;fg#&lt;/code&gt; instead of &lt;code&gt;fg&lt;/code&gt;) will translate color names into the &lt;code&gt;RGB&lt;/code&gt; color specification. But that shouldn't be a problem in practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In an ideal world, you also would need to query the basic terminal mode &lt;em&gt;term&lt;/em&gt; (which I left out here) and the additional attributes like 'strike', 'underline', 'undercurl', 'bold', 'italic', etc. This becomes additional fun if you find the attribute 'inverse' or 'reverse' :)&#xA;In addition, you'd need to add some error handling as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, I would not recommend the use of &lt;code&gt;execute()&lt;/code&gt;, since this depends on parsing the output of the command, which might &lt;em&gt;wrap&lt;/em&gt; (on small screen sizes) or add &lt;em&gt;newlines&lt;/em&gt; or might even be &lt;em&gt;translated&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally, one remark I learned from my work as the vim-airline maintainer. A function that queries all the syntax attributes of a highlighting group several times and executes a new &lt;code&gt;:hi&lt;/code&gt; statement, might slow down Vim considerably, if this happens often. vim-airline does this e.g. when evaluating the statusline and dynamically changes the colors of several highlighting groups and this has been the cause of many performance issues. So be careful with this.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-10-18T07:05:34.800" LastActivityDate="2019-10-18T07:05:34.800" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21554" PostTypeId="1" AcceptedAnswerId="21555" CreationDate="2019-10-18T07:10:51.683" Score="8" ViewCount="654" Body="&lt;p&gt;If I have a pair of quotes on a line by themselves:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and a short paragraph of text, say three lines of text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some text&#xA;that I'd like &#xA;to move&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I want to move the text into the quotes, I can place the caret at the line above the first line of text and press &lt;kbd&gt;3&lt;/kbd&gt;, &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; to select and delete them - but how can I paste them in between the quotes in the easiest way possible? The problem is that pasting them will add them on the line &lt;em&gt;below&lt;/em&gt; the quotes, producing this result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;''&#xA;some text&#xA;that I'd like &#xA;to move&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Until now I've typically done something like entering a newline between the quotes, then pasting the text between them, resulting in something like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&#xA;some text&#xA;that I'd like &#xA;to move&#xA;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...after which I'd remove the newlines at the top and bottom using &lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt;. This works, but it feels clumsy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to be clear, this is the result I'm trying to achieve:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'some text&#xA;that I'd like &#xA;to move'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16265" LastActivityDate="2019-10-18T10:46:11.407" Title="How to move a paragraph and paste it without an initial newline first" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21555" PostTypeId="2" ParentId="21554" CreationDate="2019-10-18T07:42:42.667" Score="9" Body="&lt;p&gt;When you paste the contents of a register in insert mode, you don't have the initial newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, we have this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;''&#xA;some text&#xA;that I'd like&#xA;to move&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Place your caret on the beginning of the second line in normal mode and type &lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;Ctrl+R&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;Backspace&lt;/kbd&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;3&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;: cut the three following lines;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;a&lt;/kbd&gt;: go to insert mode after the selected character;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl+R&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;: paste the content of the default register (directly after the caret, so without the newline);&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Backspace&lt;/kbd&gt;: remove the last newline.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'some text&#xA;that I'd like&#xA;to move'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24895" LastActivityDate="2019-10-18T07:42:42.667" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21556" PostTypeId="2" ParentId="21552" CreationDate="2019-10-18T07:46:22.700" Score="5" Body="&lt;p&gt;I don't use &lt;code&gt;fzf&lt;/code&gt; and use Vim instead of neovim. So I couldn't reproduce your scenario. &lt;s&gt;Also I was not able to reproduce what @dedowsdi described in his comment.&lt;/s&gt;(See end of answer.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But some general stuff around &lt;code&gt;autocmd&lt;/code&gt; and &lt;code&gt;feedkeys&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume we open Vim with three new files in split windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -O a.txt b.txt c.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim will open with three windows like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+--------------+--------------+--------------+&#xA;|      1       |      2       |      3       |&#xA;|    a.txt     |    b.txt     |    c.txt     |&#xA;|              |              |              |&#xA;+--------------+--------------+--------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Move to window 2 and execute &lt;code&gt;:au BufEnter &amp;lt;buffer&amp;gt; :call feedkeys('ab.txt', 'n')&lt;/code&gt;&#xA;and to window 3 and execute &lt;code&gt;:au BufEnter &amp;lt;buffer&amp;gt; :call feedkeys('ac.txt', 'n')&lt;/code&gt;&#xA;then back to window 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We now want to move to window 3 using two times &lt;code&gt;&amp;lt;C-W&amp;gt;l&lt;/code&gt;. To avoid delays with manual input we use: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:normal ^Wl^Wl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note: &lt;code&gt;^W&lt;/code&gt; is entered as &lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;C-W&amp;gt;&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the input queue is &lt;code&gt;&amp;lt;C-W&amp;gt;l&amp;lt;C-W&amp;gt;l&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first &lt;code&gt;&amp;lt;C-W&amp;gt;l&lt;/code&gt; is consumed and the second window is activated. The autocmd kicks in and calls &lt;code&gt;feedkeys&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the input queue is: &lt;code&gt;&amp;lt;C-W&amp;gt;lab.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the other &lt;code&gt;&amp;lt;C-W&amp;gt;l&lt;/code&gt; is consumed and the third window is activated. Again the autocmd kicks in and calls &lt;code&gt;feedkeys&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the input queue is &lt;code&gt;ab.txtac.txt&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is processed and appends the text &lt;code&gt;b.txtac.txt&lt;/code&gt; to the first line and leaves you in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conclusion:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;feedkeys&lt;/code&gt; is tricky. You should exactly know where you are and what is happening around you. Combined with an &lt;code&gt;autocmd&lt;/code&gt; this is even more tricky. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While your usage of &lt;code&gt;autocmd&lt;/code&gt; is correct from a technical point of view, the combination with &lt;code&gt;feedkeys&lt;/code&gt; might result in unexpected behavior.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now a test based on the comment from @dedowski (using Vim):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Add an autocmd to 1, move to 3, open a help window, in your case, it &#xA;  should take full width. exit help window by q, you should see &#xA;  autocmd of 1 and 3 applied to 3.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Open Vim with three new files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -O a.txt b.txt c.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;we get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+--------------+--------------+--------------+&#xA;|      1       |      2       |      3       |&#xA;|    a.txt     |    b.txt     |    c.txt     |&#xA;|              |              |              |&#xA;+--------------+--------------+--------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change to the window showing &lt;code&gt;c.txt&lt;/code&gt; and then open help with &lt;code&gt;:help&lt;/code&gt; and we get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+--------------+--------------+--------------+&#xA;|                   help                     |&#xA;|-----------------------------+--------------|&#xA;|      1       |      2       |      3       |&#xA;|    a.txt     |    b.txt     |    c.txt     |&#xA;+--------------+--------------+--------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd BufEnter * echomsg 'BufEnter ' . expand('%')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then close the help window using &lt;code&gt;:q&lt;/code&gt; and Vim will print&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BufEnter a.txt&#xA;BufEnter c.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(You might need &lt;code&gt;:messages&lt;/code&gt; to see both echos.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well -- that is unexpected. &#xA;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-10-18T09:54:15.057" LastActivityDate="2019-10-18T09:54:15.057" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21557" PostTypeId="2" ParentId="21554" CreationDate="2019-10-18T08:11:45.360" Score="6" Body="&lt;p&gt;Another way is to create &lt;a href=&quot;https://vimhelp.org/change.txt.html#characterwise-register&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h characterwise-register&lt;/a&gt; to paste into &lt;code&gt;''&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;place your cursor any place in the paragraph and do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vipv$hd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;move to first &lt;code&gt;'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;done.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vip&lt;/code&gt; select paragraph, &lt;a href=&quot;https://vimhelp.org/motion.txt.html#ip&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h ip&lt;/a&gt; is linewise, which means current visual mode is &lt;code&gt;V&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;v&lt;/code&gt;   change mode to &lt;code&gt;v&lt;/code&gt;, which is &lt;code&gt;character wise&lt;/code&gt;, check &lt;a href=&quot;https://vimhelp.org/visual.txt.html#v_v&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h v_v&lt;/a&gt; if you have doubt.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;$h&lt;/code&gt; select until last character of last line, &lt;code&gt;h&lt;/code&gt; is used to exclude trailing linebreak.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;d&lt;/code&gt;  delete into to register.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Rich mentioned &lt;code&gt;v}ged&lt;/code&gt; in the comment, it's 2 characters shorter, it doesn't involve count, although you must place cursor at start of the paragraph, it's still a very intuitive and handy method.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-10-18T10:46:11.407" LastActivityDate="2019-10-18T10:46:11.407" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21558" PostTypeId="2" ParentId="457" CreationDate="2019-10-18T11:58:09.917" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Does Ex mode have any practical use?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Probably not. However, while entering Ex mode isn't really useful, learning Ex commands still is useful, particularly because you use ex editing commands with &lt;a href=&quot;https://vim.fandom.com/wiki/Power_of_g&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:g/&lt;/code&gt; global commands&lt;/a&gt; to operate on matching lines. &lt;/p&gt;&#xA;" OwnerUserId="632" LastActivityDate="2019-10-18T11:58:09.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21559" PostTypeId="1" CreationDate="2019-10-18T13:03:55.597" Score="1" ViewCount="36" Body="&lt;p&gt;I use Vim as my main text editor and use Syntastic to assist with linting. I am editing large legacy python files (some upwards of 50,000 lines) and would like to run &lt;code&gt;SyntasticCheck&lt;/code&gt; over a range or a portion of the file instead of the entire file. Linting the entire file can be slow and displays many irrelevant syntax/styling errors/warnings that are not relevant to my work in that file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have read the Syntastic documentation and did not find anything. Anything built into Vim?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vim - 8.1(compiled Sep 30 2019) from homebrew&#xA;Syntastic - 3.10.0-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17861" LastActivityDate="2019-10-18T13:03:55.597" Title="Can you use Syntastic in Vim over a subset of code in a file?" Tags="|plugin-syntastic|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21560" PostTypeId="2" ParentId="21549" CreationDate="2019-10-18T13:17:48.150" Score="0" Body="&lt;p&gt;That “buffer” is netrw. It notoriously has this issue, although in practice it’s not a huge deal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tend to swap files by name or argument list (&lt;code&gt;:args&lt;/code&gt;) more often than cycling through buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, don’t worry about deleting it, and don’t let it bother your workflow. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-10-18T13:17:48.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21561" PostTypeId="1" AcceptedAnswerId="21565" CreationDate="2019-10-18T13:57:41.317" Score="1" ViewCount="69" Body="&lt;p&gt;Consider this situation, which I often follow in python and &lt;strong&gt;consider that my cursor is on the letter &lt;em&gt;a&lt;/em&gt; of &lt;em&gt;args&lt;/em&gt;:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;args = ap.add_argument(&quot;-i&quot;, &quot;--texture&quot;, type = str, required=True, help=&quot;path of the texture vector&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My objective is to change above line to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;args = ap.add_argument(&quot;-o&quot;, &quot;--output&quot;, type = str, required=True, help=&quot;path of the output&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I have to change all the text objects in this line {&quot;-i&quot;, &quot;--texture&quot;, &quot;path of the texture vector&quot;). I do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ci&quot; [ to change &quot;-i&quot; to &quot;-o&quot;]&#xA;Esc&#xA;2f&quot;&#xA;ci&quot; [ to change the second text object]&#xA;Esc&#xA;2f&quot;&#xA;ci&quot; [ then change the last text object]&#xA;Esc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is bit clumsy to do &lt;code&gt;2f&quot;&lt;/code&gt; between every &lt;code&gt;ci&quot;&lt;/code&gt;, what are the more faster and smoother ways of doing this?&lt;/p&gt;&#xA;" OwnerUserId="25275" LastEditorUserId="25275" LastEditDate="2019-10-18T14:39:57.953" LastActivityDate="2019-10-18T20:50:48.920" Title="Vim changing the text objects of &quot; in a single line with less number of keystrokes?" Tags="|cursor-motions|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21563" PostTypeId="1" AcceptedAnswerId="21564" CreationDate="2019-10-18T16:00:29.850" Score="6" ViewCount="815" Body="&lt;p&gt;I installed the ALE plugin, and I really like the highlighting, though the sign column shown in the far left of this image is distracting to me and seems unnecessary given that errors and warnings are highlighted anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dFSfS.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dFSfS.png&quot; alt=&quot;Sign column&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've checked out out the ALE readme, but all I found relating to the sign column was this line &lt;code&gt;let g:ale_sign_column_always = 0&lt;/code&gt;, which only seems to disable the column when there are no errors or warnings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to disable the sign column completely?&lt;/p&gt;&#xA;" OwnerUserId="23679" LastActivityDate="2019-10-18T19:34:39.843" Title="Is it possible to disable the column on the left that is created by ALE?" Tags="|plugin-ale|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21564" PostTypeId="2" ParentId="21563" CreationDate="2019-10-18T19:34:39.843" Score="7" Body="&lt;p&gt;Ralf mentions in the comments disabling ALE's sign column with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_set_signs = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but you can also disable signs entirely with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set signcolumn=no&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or have them in the number column with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set signcolumn=number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-10-18T19:34:39.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21565" PostTypeId="2" ParentId="21561" CreationDate="2019-10-18T20:50:48.920" Score="0" Body="&lt;p&gt;It'll be hard to get manually entered keys much shorter than you guys got it in comments. But if you use a mapping you can repeat the &quot;jump to quotes and enter insert&quot; action easily...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap XX 2f&quot;ci&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Replace XX with desired key combo.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you just do &lt;code&gt;XX&lt;/code&gt;, type in some text, &lt;code&gt;&amp;lt;esc&amp;gt;XX&lt;/code&gt;, type in some text, &lt;code&gt;&amp;lt;esc&amp;gt;XX&lt;/code&gt;, ... until you've changed all quoted strings in the line.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-10-18T20:50:48.920" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21566" PostTypeId="1" AcceptedAnswerId="21959" CreationDate="2019-10-19T03:47:09.523" Score="0" ViewCount="202" Body="&lt;p&gt;I'm trying to use &lt;code&gt;git grep&lt;/code&gt; as my &lt;code&gt;grepprg&lt;/code&gt;, but I keep getting spurious files such as &lt;code&gt;~/fatal: Not a git repository (or any of the parent directories): .git&lt;/code&gt;. Is there a way to configure vim to correctly ignore diagnostic messages? I'm okay with general solutions for configuring &lt;code&gt;grepprg&lt;/code&gt; and related options or solutions specific to &lt;code&gt;git grep&lt;/code&gt;. However, I'd prefer a vim-only solution that doesn't involve writing wrapper programs around &lt;code&gt;git grep&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a snippet from my &lt;code&gt;:browse oldfiles&lt;/code&gt; showing the spurious file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: ~/.vimrc.bak                                               &#xA;2: ~/.vimrc&#xA;3: ~/.bash_aliases&#xA;4: ~/.bashrc&#xA;5: /tmp/eee&#xA;6: /tmp/.vimrc&#xA;7: /tmp/.vimr&#xA;8: ~/fatal: Not a git repository (or any of the parent directories): .git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This problem is reproducible using the following vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set grepprg=git\ --no-pager\ grep\ --no-color\ -n\ $*&#xA;set grepformat=%f:%l:%m,%m\ %f\ match%ts,%f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above vimrc is based on &lt;a href=&quot;https://vi.stackexchange.com/a/8858&quot;&gt;this answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing I tried is &lt;code&gt;set shellredir=&amp;gt;&lt;/code&gt;, but the behavior of the grep &lt;code&gt;builtin&lt;/code&gt; command does not appear to change according to the value of &lt;code&gt;shellredir&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've confirmed experimentally that &lt;code&gt;shellredir&lt;/code&gt; has no effect on the &lt;code&gt;grep&lt;/code&gt; command. I can confirm that &lt;code&gt;set shellredir=&quot;00000000&quot;&lt;/code&gt; doesn't appear to affect the &lt;code&gt;grep&lt;/code&gt; ex command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/92ea26b925a0835badb0af2d5887238a4198cabb/src/quickfix.c#L4765&quot; rel=&quot;nofollow noreferrer&quot;&gt;The command &lt;code&gt;ex_make&lt;/code&gt;&lt;/a&gt;  is used for &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;make&lt;/code&gt;, and other commands that populate the &lt;code&gt;quickfix&lt;/code&gt; list. Briefly looking at the code, though, I can't tell why stderr is always captured on Linux and also can't say definitively that &lt;code&gt;shellredir&lt;/code&gt; isn't used at all.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;One semi-solution that does work is using a wrapper around git grep that immediately discards stderr before &lt;code&gt;vim&lt;/code&gt; can see it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl&#xA;&#xA;# ~/bin/gitgrep&#xA;&#xA;open(STDERR, &quot;&amp;gt;/dev/null&quot;);&#xA;exec(&quot;git&quot;, &quot;--no-pager&quot;, &quot;grep&quot;, &quot;--no-color&quot;, &quot;-n&quot;, @ARGV);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the corresponding vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set grepprg=$HOME/bin/gitgrep\ $*&#xA;set grepformat=%f:%l:%m,%m\ %f\ match%ts,%f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2019-10-19T03:52:40.027" LastActivityDate="2019-12-18T23:01:30.207" Title="don't capture stderr for git grep as grepprg" Tags="|external-command|git|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21567" PostTypeId="1" AcceptedAnswerId="21612" CreationDate="2019-10-19T06:03:16.577" Score="1" ViewCount="142" Body="&lt;p&gt;I upgraded MacVim to 8.1.2168 (159) tonight and now the vimwiki files in Markdown format do not highlight correctly when I enable spell check. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I run &lt;code&gt;set spell spelllang=en_ca&lt;/code&gt; as I have before. It looks almost like the spell check is finding all of the first word &lt;em&gt;except the first character&lt;/em&gt; in some (but not all!) of the sentences, and reporting those fractions of words as misspellings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rwQ9z.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rwQ9z.png&quot; alt=&quot;incorrect spell error hightlight&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe this is some sort of new conflict between the vimwiki files in Markdown format and the new upgraded version of vim and &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;spellcapcheck&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;spellcapcheck&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Abridged output from &lt;code&gt;set:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; syntax=vimwiki      &#xA; filetype=vimwiki    &#xA; spell  &#xA; spellcapcheck=[.?!]_[])'&#xA; spellfile=~/.vim/spell/en.utf-8.add&#xA; suffixesadd=.markd&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can see that the default string for &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;spellcapcheck&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;spellcapcheck&lt;/a&gt; is &lt;code&gt;default &quot;[.?!]\_[\])'&quot;' \t]\+&quot;&lt;/code&gt;  while mine is &lt;code&gt;[.?!]_[])'&lt;/code&gt;.  Yet I run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set spc=&quot;[.?!]\_[\])'&quot;' \t]\+&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the highlighting does not change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;set list&lt;/code&gt; I can see that there is an eol at the end of each line.  This is as I expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not lost on me that the first word of each sentence is &lt;em&gt;not&lt;/em&gt; highlighted if the remaining characters after the first character form a valid word:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;David&lt;/strong&gt; does &lt;em&gt;not&lt;/em&gt; appear as a highlighted spelling error because &lt;code&gt;avid&lt;/code&gt; is a valid word.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Daphne&lt;/strong&gt; appears as a highlighted spelling error because &lt;code&gt;aphne&lt;/code&gt; is a typo.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Where do I look next to fix this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;" OwnerUserId="6590" LastEditorUserId="6590" LastEditDate="2019-10-21T21:33:48.857" LastActivityDate="2019-10-22T14:48:00.560" Title="Where do I fix partial words incorrectly identified as errors with spell?" Tags="|spell-checking|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21568" PostTypeId="1" AcceptedAnswerId="21569" CreationDate="2019-10-19T06:46:51.770" Score="1" ViewCount="997" Body="&lt;p&gt;I would like to filter the output of vim commands with fzf. The idea is for example, if I use vim unimpaired plugin and I don't exactly remember which map was to navigate to the next git conflict but I do remember that it started with &quot;[&quot;, to be able to do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map [ | fzf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then I can search for &quot;conflict&quot; or &quot;git&quot; to explore the different mappings. &lt;/p&gt;&#xA;" OwnerUserId="15345" LastActivityDate="2019-10-29T09:32:29.473" Title="Redirect output of vim command to external program" Tags="|vimscript|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21569" PostTypeId="2" ParentId="21568" CreationDate="2019-10-19T07:52:21.800" Score="1" Body="&lt;pre&gt;&lt;code&gt;com -nargs=+ FF call fzf#run({'source' : split(execute(&amp;lt;q-args&amp;gt;), &quot;\n&quot;), 'sink':'&quot;'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FF map [&#xA;FF set termcap&#xA;FF buffers&#xA;FF oldfiles&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#%3Aquote&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :quote&lt;/a&gt; is used as sink, it's ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Filter blank lines, add &lt;code&gt;-bang&lt;/code&gt; to support reverse order, add &lt;code&gt;sink&lt;/code&gt; to copy into default register.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ -bang -complete=command FF call fzf#run({&#xA;            \ 'source' : filter(split(execute(&amp;lt;q-args&amp;gt;), &quot;\n&quot;), {i,v-&amp;gt;!empty(v)}),&#xA;            \ 'sink': function('s:ff_sink'),&#xA;            \ 'options' : &amp;lt;bang&amp;gt;0 ? '--tac' : ''})&#xA;&#xA;&quot; copy into @@, ignore leading index&#xA;function! s:ff_sink(item)&#xA;  let text = substitute(a:item, '\v^\&amp;gt;?\s*\d+\:?\s*', '', '')&#xA;  let @@ = empty(text) ? a:item : text&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-10-29T09:32:29.473" LastActivityDate="2019-10-29T09:32:29.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21570" PostTypeId="1" CreationDate="2019-10-19T09:42:51.757" Score="1" ViewCount="1607" Body="&lt;p&gt;I discovered vi/vim only yesterday&lt;br&gt;&#xA;on my ubuntu I didn't have vim installed, only vi&lt;br&gt;&#xA;I enjoyed its simplicity and minimalism&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then I decided to try vim too, ran &lt;code&gt;sudo apt install vim&lt;/code&gt;, played with it   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Today I tried turning on simpler vi again, but it opens only vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I return back to simpler version without uninstalling vim?&lt;/p&gt;&#xA;" OwnerUserId="25286" LastActivityDate="2020-07-16T01:07:35.790" Title="How do i open Vi after I installed Vim?" Tags="|linux-ubuntu|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21571" PostTypeId="2" ParentId="21570" CreationDate="2019-10-19T11:00:21.690" Score="2" Body="&lt;p&gt;In fact the &quot;simpler version&quot; on Ubuntu is also a Vim. Vim can be compiled with more or less features. The &quot;simple&quot; Vim is still available as &lt;code&gt;vi.tiny&lt;/code&gt; (at least on Ubuntu 16.04). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend to just use the full-featured Vim (called &quot;Huge version&quot;). It has things like syntax highlighting and a lot more. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: If you want to use Vim with graphical UI, you can install it with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install vim-gtk3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;How to start?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, Vim (and even the smaller Vim) is a very powerful editor. And like every powerful software there is a lot to learn. At the beginning it will be hard and you will be slow, but that will improve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the first steps start the program &lt;code&gt;vimtutor&lt;/code&gt;. It loads a text file as a tutorial and teaches you the basic move and editing commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the help of Vim is very good and extensive. You could start with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help user-manual&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you are always welcome to ask questions here. Be prepared that a lot of answers will contain a reference to some help topic. Don't worry, we all know that finding the correct help topics is sometimes difficult for a beginners.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last tip: Vim is highly configurable using a file called &lt;code&gt;vimrc&lt;/code&gt;. Don't just copy some fancy configuration from somewhere. You may use them as inspiration, but you should build up your own configuration as you learn. &lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-10-19T15:12:54.477" LastActivityDate="2019-10-19T15:12:54.477" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21572" PostTypeId="2" ParentId="21568" CreationDate="2019-10-19T11:14:37.217" Score="1" Body="&lt;p&gt;If you're only interested in working with fzf plugin you probably should do as @dedowsdi suggests. I'm going to talk about the general case, as stands in the question title.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;First of all, let's not forget that Vim has a builtin function for filtering command output which can come in handy on many occasions. Its usage (&lt;code&gt;:h :filter&lt;/code&gt;) is quite straightforward:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filter /conflict/ map [&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We can create a command of our own mixing &lt;code&gt;system()&lt;/code&gt; and &lt;code&gt;execute()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Pipe(...)&#xA;    let l:bar = index(a:000, &quot;\&amp;lt;bar&amp;gt;&quot;)&#xA;    if l:bar &amp;lt;= 0 || l:bar &amp;gt;= a:0 - 1&#xA;        return ''&#xA;    endif&#xA;    let l:result = execute(join(a:000[: l:bar - 1]))&#xA;    return system(join(a:000[l:bar + 1 :]), l:result)&#xA;endfunction&#xA;&#xA;command! -nargs=+ -complete=command Pipe echo Pipe(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now you can do &lt;code&gt;:Pipe map [ | grep &quot;conflict&quot;&lt;/code&gt;, or whatever else.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;The typical redirection pattern in Vim requires a (temporary) buffer usage. That is, dumping output into a buffer, filtering it, etc.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To redirect commands' output into a buffer you can use the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;x :-1put=trim(execute(input(\&quot;:\&quot;)))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now press &lt;code&gt;&amp;lt;leader&amp;gt;x&lt;/code&gt; and type any command you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the result gets into buffer you can either redirect it to an external terminal window (note that visual mode / Ex ranges are supported too):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !grep &quot;conflict&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or simply apply a filter in-place:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!grep &quot;conflict&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-19T11:14:37.217" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21573" PostTypeId="2" ParentId="21568" CreationDate="2019-10-19T11:23:34.133" Score="2" Body="&lt;p&gt;Redirect the output of the command to a new window, then use &lt;code&gt;:BLines&lt;/code&gt;. This is mainly useful for editing the output.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Exec(cmd)&#xA;redir @a&#xA;exec printf('silent %s',a:cmd)&#xA;redir END&#xA;tabnew&#xA;norm &quot;ap&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function executes the command and printes the output onto a new tab. I use it from time to time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example try :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call Exec('nmap')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-10-19T13:00:57.773" LastActivityDate="2019-10-19T13:00:57.773" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21574" PostTypeId="2" ParentId="21570" CreationDate="2019-10-19T11:40:06.620" Score="2" Body="&lt;pre&gt;&lt;code&gt;type -a vi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will give you the full path(s) to the vi(m) executable(s) .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most likely the simpler version is vim.tiny or vim.basic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can create an alias to whichever version of vi(m) you want.&lt;/p&gt;&#xA;" OwnerUserId="25289" LastActivityDate="2019-10-19T11:40:06.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21575" PostTypeId="1" CreationDate="2019-10-19T12:37:53.277" Score="5" ViewCount="2961" Body="&lt;p&gt;Macros can be repeated for every line matching a pattern with the global command as explained &lt;a href=&quot;https://stackoverflow.com/questions/390174/in-vim-how-do-i-apply-a-macro-to-a-set-of-lines&quot;&gt;in this answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This applies to every single line, but is it possible to do it for every single match? so if I save in a macro &lt;code&gt;ysiw&quot;&lt;/code&gt; (yank surround in word &quot;) I repeat it for every matching regex, for example: &lt;code&gt;match1\|match2&lt;/code&gt;&#xA;So that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;match1 nomatch match2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would become&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;match1&quot; nomatch &quot;match2&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15345" LastActivityDate="2019-10-21T01:38:27.980" Title="How to apply a macro for every single matching pattern" Tags="|macro|repeated-commands|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21576" PostTypeId="2" ParentId="21575" CreationDate="2019-10-19T13:05:11.827" Score="4" Body="&lt;p&gt;Search for your pattern using &lt;code&gt;/&lt;/code&gt;, then play your macro &lt;code&gt;@@&lt;/code&gt;—you can record a new macro for this by doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/pattern&amp;lt;CR&amp;gt;qqn@aq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming &lt;code&gt;@a&lt;/code&gt; holds your original macro. Then &lt;code&gt;@q&lt;/code&gt; will jump to the next occurrence and play your macro. (For this case, you may need &lt;code&gt;qqn@anq&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, you also do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%substitute/pattern/&quot;&amp;amp;&quot;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-10-19T13:24:08.547" LastActivityDate="2019-10-19T13:24:08.547" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21577" PostTypeId="1" CreationDate="2019-10-19T13:06:16.097" Score="2" ViewCount="235" Body="&lt;p&gt;I have a ruby file while is about 5K+ lines long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current setup uses the &lt;a href=&quot;https://github.com/igbanam/dotfiles/blob/0a369a17feba43c9b8d8f0663ccc028da0288a5d/vimrc#L112&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-ruby plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this, I &lt;a href=&quot;https://github.com/igbanam/dotfiles/blob/0a369a17feba43c9b8d8f0663ccc028da0288a5d/vimrc#L212&quot; rel=&quot;nofollow noreferrer&quot;&gt;enable code folding&lt;/a&gt; with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let ruby_fold = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This opens my ruby files pre-folded. I can open the folds I need to show the file I want to work on. However, while working on the file, when I open a block — like the &lt;code&gt;do&lt;/code&gt; of the multiline &lt;code&gt;do ... end&lt;/code&gt;, Vim gets stuck. I'm thinking Vim tries to recalculate the fold lines, and for a file this big, it takes a while.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there anyway to speed this up?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: If I turn off syntax highlighting, editing the file returns to being fast.&lt;/p&gt;&#xA;" OwnerUserId="20468" LastActivityDate="2019-10-19T13:06:16.097" Title="How to make code-folding more efficient" Tags="|syntax-highlighting|folding|performance|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21578" PostTypeId="2" ParentId="21575" CreationDate="2019-10-19T13:31:10.810" Score="1" Body="&lt;p&gt;Another possible answer is using vim-visual-multi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, select the pattern everywhere. To do so, use &lt;code&gt;\\/&lt;/code&gt; and then &lt;code&gt;\\A&lt;/code&gt; to select all. And then  &lt;code&gt;\\@&lt;/code&gt; with the macro register. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, you could have done &lt;code&gt;S&quot;&lt;/code&gt; instead of using the macro after &lt;code&gt;\\A&lt;/code&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-10-19T13:39:00.610" LastActivityDate="2019-10-19T13:39:00.610" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21579" PostTypeId="2" ParentId="21575" CreationDate="2019-10-19T13:47:17.953" Score="6" Body="&lt;p&gt;Another way that also works across files is to use &lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#%3Avimgrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :vimgrep&lt;/a&gt; with &lt;code&gt;g&lt;/code&gt; flag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            Without the 'g' flag each line is added only once.&#xA;            With 'g' every match is added.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The workflow is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Init your search pattern with &lt;code&gt;/your pattern&lt;/code&gt;, record your macro in &lt;code&gt;q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Find all matching in your interested files:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    vimgrep //g  **/*.cpp **/*.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Reverse quickfix result with this command:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    command! ReverseQuickFixList call setqflist(reverse(getqflist()))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This step is necessary, as there might be multiple matches in a line, the second matching position might be invalidated after you apply your macro on the 1st matching. You need to do this in reverse order, but there has no &lt;code&gt;creversedo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Apply your macro&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    cdo norm! @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#%3Acdo&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :cdo&lt;/a&gt; doesn't stop if an error occured in the middle. If that's a problem, jump to 1st matching with &lt;code&gt;:cfirst&lt;/code&gt;, record a another macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qp@q:cnext&amp;lt;cr&amp;gt;q&#xA;          ^-------carriage return&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Repeat it with sufficient large number, it will stop at 1st error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1000@p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-10-21T01:38:27.980" LastActivityDate="2019-10-21T01:38:27.980" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21580" PostTypeId="2" ParentId="21437" CreationDate="2019-10-19T14:36:35.513" Score="0" Body="&lt;p&gt;Add &lt;code&gt;autocmd VimEnter * set t_ut=&lt;/code&gt; to your vimrc file.&lt;/p&gt;&#xA;" OwnerUserId="25132" LastEditorUserId="-1" LastEditDate="2020-02-27T13:56:14.627" LastActivityDate="2020-02-27T13:56:14.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21581" PostTypeId="1" CreationDate="2019-10-19T16:50:41.373" Score="2" ViewCount="1123" Body="&lt;p&gt;It looks like quite a simple question, but I cannot find an answer. Is there a way to detect that the user pressed &lt;code&gt;ESC&lt;/code&gt; key while waiting for user input in vimscript? I would like an intuitive way to cancel my function. &#xA;I've seen that in this similar question, pressing &lt;code&gt;&amp;lt;C-C&amp;gt;&lt;/code&gt; is an option, but this doesn't solve the issue and it is not as intuitive from my point of view. Is there an standard approach? What options do we have?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/19949/how-to-stop-a-function-when-esc-is-pressed-or-how-to-catch-a-esc-signal-in&quot;&gt;How to stop a function when &amp;lt;esc&amp;gt; is pressed? OR how to catch a &amp;lt;esc&amp;gt; signal in vimscript?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15345" LastActivityDate="2019-10-20T11:13:46.547" Title="Detect that user pressed ESC in getchar()" Tags="|vimscript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21582" PostTypeId="1" AcceptedAnswerId="21586" CreationDate="2019-10-19T20:14:57.927" Score="3" ViewCount="76" Body="&lt;p&gt;I'd like to use vim's builtin indent fix feature on an entire file. I have looked up answers, but all I found were suggestions to type &lt;code&gt;gg=G&lt;/code&gt;, the only problem being that it brings your cursor to the top of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I easily indent a whole file without changing my cursor's position?&lt;/p&gt;&#xA;" OwnerUserId="23679" LastActivityDate="2019-10-20T08:17:46.040" Title="Fix indentation in a file while keeping cursor on the same line" Tags="|indentation|cursor|indent|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21583" PostTypeId="2" ParentId="21566" CreationDate="2019-10-19T21:00:03.540" Score="0" Body="&lt;p&gt;I solved this issue by removing the option consisting only of &lt;code&gt;%f&lt;/code&gt; by itself. I'm not sure what &lt;code&gt;%m %f match%ts&lt;/code&gt; means, since the original answer lacks explicit rationale for how the various &lt;code&gt;grepformat&lt;/code&gt; strings were determined. I suspect it's related to &lt;code&gt;git grep&lt;/code&gt;'s output for binary file matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The presence of &lt;code&gt;,%f&lt;/code&gt; in the format string above means that, by default, any string that doesn't fit one of the other patterns will be interpreted as a filename.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the following lines to configure your &lt;code&gt;.vimrc&lt;/code&gt; with &lt;code&gt;git grep&lt;/code&gt; as the &lt;code&gt;grepprg&lt;/code&gt; appears to solve the immediate problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;grepprg=&quot;git --no-pager grep --no-color -n $*&quot;                                                                                  &#xA;let &amp;amp;grepformat=&quot;%f:%l:%m,%m %f match%ts&quot;                                                                                            &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I'm using &lt;code&gt;let &amp;amp;grepprg=...&lt;/code&gt; instead of &lt;code&gt;set grepprg=...&lt;/code&gt; because I think it makes it more obvious &quot;where&quot; the magic is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;grepprg&lt;/code&gt; and &lt;code&gt;grepformat&lt;/code&gt; are just strings, but in the former &lt;code&gt;$*&lt;/code&gt; (among other things) is handled specially and in the latter &lt;code&gt;,&lt;/code&gt; (among other things) is handled specially.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2019-10-19T21:00:03.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21584" PostTypeId="2" ParentId="21582" CreationDate="2019-10-19T21:32:15.383" Score="0" Body="&lt;p&gt;If you are willing to dedicate a keybinding to it (let's say &lt;code&gt;\G&lt;/code&gt; for concreteness), then it's possible to set a mark and return to it in your keybinding.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap \G mpgg=G`p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;mp&lt;/code&gt; set mark. A lowercase letter means that mark is associated with the current buffer. The mark &lt;code&gt;P&lt;/code&gt; is universal, &lt;code&gt;p&lt;/code&gt; is not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gg=G&lt;/code&gt; move to the top of the buffer and indent down to the bottom, as you mentioned in the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;`p&lt;/code&gt; return to the mark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution is not ideal because your cursor might still jump around because of things like &lt;code&gt;scrolloff&lt;/code&gt;, but it does minimize how visually distracting it is to re-indent a file fairly well in practice.&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2019-10-19T21:32:15.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21585" PostTypeId="2" ParentId="21570" CreationDate="2019-10-19T21:59:52.993" Score="1" Body="&lt;p&gt;You mentioned that you are running on Ubuntu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that the executable called &lt;code&gt;vi&lt;/code&gt; is the same one as &lt;code&gt;vim&lt;/code&gt;, unless you've gone out of your way to install another &lt;code&gt;vi&lt;/code&gt;-compatible editor and changed it to be the default, which is unlikely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The name Vim is an abbrevation of &quot;VI iMproved&quot;. &lt;a href=&quot;https://en.wikipedia.org/wiki/Vi&quot; rel=&quot;nofollow noreferrer&quot;&gt;vi is an editor in its own right.&lt;/a&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Vim_(text_editor)&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim is based on a &lt;code&gt;vi&lt;/code&gt; clone called &lt;code&gt;stevie&lt;/code&gt;&lt;/a&gt;, but it has accumulated features over the years and now has many features that are not present in the original &lt;code&gt;vi&lt;/code&gt; or in &lt;code&gt;stevie&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under certain circumstances, &lt;code&gt;vim&lt;/code&gt; will run in vi-emulation mode, which disables many of the extensions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can &lt;em&gt;force&lt;/em&gt; vim to run in &lt;code&gt;vi&lt;/code&gt; emulation mode by putting &lt;code&gt;set compatible&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt; like so.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vimrc file&#xA;&#xA;&quot; turn on vi-compatibility&#xA;set compatible&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;vim&lt;/code&gt; is a complicated program with many obscure features. If it's important to you to have an editor that's very simple overall, there are some choices. Keep in mind, though, that getting help with unpopular editors is much harder than getting help with &lt;code&gt;vim&lt;/code&gt; or &lt;code&gt;emacs&lt;/code&gt; issues.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nvi&lt;/code&gt; available via &lt;code&gt;apt-get install nvi&lt;/code&gt; ... a re-implementation of the original &lt;code&gt;vi&lt;/code&gt; editor with few additional features.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;elvis&lt;/code&gt; available via &lt;code&gt;apt-get install elvis-tiny&lt;/code&gt; ... another small &lt;code&gt;vi&lt;/code&gt; clone.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And some that aren't &lt;code&gt;vi&lt;/code&gt;-compatible.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;mg&lt;/code&gt; -- editor that emulates the keybindings of gnu emacs. (&lt;code&gt;apt-get install mg&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nano&lt;/code&gt; -- another simple editor. (&lt;code&gt;apt-get install nano&lt;/code&gt; if it is not already installed). &lt;code&gt;nano&lt;/code&gt; is very popular, but it's somewhat hard to get help with because the editor has so few features.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2019-10-19T21:59:52.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21586" PostTypeId="2" ParentId="21582" CreationDate="2019-10-20T05:11:09.743" Score="4" Body="&lt;p&gt;All &quot;long&quot; jump commands, such as &lt;code&gt;gg&lt;/code&gt;, automatically save the bookmark for the previous poisition (note that &lt;code&gt;G&lt;/code&gt; here is a &quot;motion&quot;, so it does not overwrite the bookmark again), so all you have to do is to go back by that bookmark with two backticks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;= gg=G``&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can use &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;O&lt;/kbd&gt; and &lt;kbd&gt;CTRL&lt;/kbd&gt;&lt;kbd&gt;I&lt;/kbd&gt; to navigate through the jumplist (&lt;code&gt;:h jumplist&lt;/code&gt;) to and fro.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-10-20T08:17:46.040" LastActivityDate="2019-10-20T08:17:46.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21587" PostTypeId="2" ParentId="21581" CreationDate="2019-10-20T11:13:46.547" Score="2" Body="&lt;p&gt;Here is a (modified) piece from one of my scripts. This now also returns a empty string if &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; is hit. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:ESC = char2nr(&quot;\e&quot;)&#xA;&#xA;&quot; Gets a single char from user, returns empty string if Ctrl-C or ESC was hit.&#xA;&quot; Ignores special keys (F-Keys, mouse clicks etc).&#xA;function! GetChar(message)&#xA;    let msg = a:message . &quot; (Ctrl-C to cancel) &amp;gt; &quot;&#xA;    try&#xA;        echo msg&#xA;        let code = ''&#xA;        while type(code) != v:t_number&#xA;            let code = getchar()&#xA;        endwhile&#xA;        return code == s:ESC ? '' : nr2char(code)&#xA;    catch /Vim:Interrupt/&#xA;        return ''&#xA;    endtry&#xA;endfunction &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A quote from &lt;code&gt;:help getchar()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When [expr] is 0 and Esc is typed, there will be a short delay&#xA;  while Vim waits to see if this is the start of an escape&#xA;  sequence.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2019-10-20T11:13:46.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21588" PostTypeId="1" CreationDate="2019-10-20T15:16:24.870" Score="0" ViewCount="452" Body="&lt;p&gt;I have been using Vim/vi for a while but my computer ran out of space while writing a file and then this error appeared and continues to whenever I open or exit vi.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;E575: viminfo: Illegal starting char in line: s/School_work/.../t1_plotter.com&#xA;E575: viminfo: Ilegal starting char in line: ^I*^I1569136185^I0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;&lt;p&gt;Other responses have informed me I need to delete the viminfo file. However, I cannot find it. I have looked in &lt;code&gt;/usr/share&lt;/code&gt; where I find the vim directory which contains the vimrc, as well as &lt;code&gt;/mnt/c/Users/&amp;lt;Username&amp;gt;&lt;/code&gt;. But so far nothing.&lt;/p&gt;&#xA;" OwnerUserId="25298" LastEditorUserId="23502" LastEditDate="2023-04-04T05:35:21.037" LastActivityDate="2023-12-30T06:07:15.880" Title="Cannot find the viminfo file to fix the E575 error Windows 10 WSL" Tags="|viminfo|wsl|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21589" PostTypeId="2" ParentId="21588" CreationDate="2019-10-20T16:33:03.190" Score="0" Body="&lt;p&gt;Launch vim and run&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set viminfofile?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;That should tell you the location. (The default is listed at &lt;code&gt;:help viminfo-file-name&lt;/code&gt;.)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Based on some comments, it looks like the issue was trying to find &lt;code&gt;$HOME\_viminfo&lt;/code&gt;, since the OP is on Windows, but they are in the linux subsystem and thus should actually look for &lt;code&gt;$HOME/.viminfo&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2021-03-14T16:30:04.203" LastActivityDate="2021-03-14T16:30:04.203" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21590" PostTypeId="1" CreationDate="2019-10-21T03:35:47.537" Score="2" ViewCount="288" Body="&lt;p&gt;:h :cdo says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            When an error is detected execution stops.&#xA;            The last buffer (or where an error occurred) becomes&#xA;            the current buffer.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's see what really happens:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Prepare test file &lt;code&gt;a&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dog0 dog1&#xA;dog2 dog3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Prepare test file &lt;code&gt;b&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dog4 dog5&#xA;dog6 dog7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;set up quickfix for all dogs :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimgrep /dog\d/g a b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Create a test command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; call cdo to change dog to cat, throw an error in the first n entries&#xA;command! -nargs=1 TestCdo call Test(&amp;lt;q-args&amp;gt;)&#xA;&#xA;function! Test(error_count)&#xA;  let s:error_count = a:error_count&#xA;  let s:error_index = 0&#xA;&#xA;  &quot; restore a b&#xA;  cdo e!&#xA;&#xA;  cdo call s:test_impl()&#xA;endfunction&#xA;&#xA;function! s:test_impl()&#xA;  if s:error_index &amp;lt; s:error_count&#xA;    let s:error_index += 1&#xA;    throw 1&#xA;  endif&#xA;  norm! c3lcat&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Test result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Test        dogs     cats&#xA;---------------------------&#xA;TestCdo 1   dog0     cat1-7&#xA;TestCdo 2   dog0-1   cat2-7&#xA;TestCdo 3   dog0-2   cat3-7&#xA;TestCdo 4   dog0-7&#xA;TestCdo 5   dog0-7&#xA;TestCdo 6   dog0-7&#xA;TestCdo 7   dog0-7&#xA;TestCdo 8   dog0-7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks like &lt;code&gt;cdo&lt;/code&gt; stops only if &lt;code&gt;dog3&lt;/code&gt; throws an error, &lt;code&gt;dog3&lt;/code&gt; is the last &lt;code&gt;entry&lt;/code&gt; in &lt;code&gt;a&lt;/code&gt;, &lt;s&gt;&lt;strong&gt;does that mean &lt;code&gt;cdo&lt;/code&gt; only stops if last entry in a buffer cause an error&lt;/strong&gt;?&lt;/s&gt; That's very disturbing, especially if you have hundreds of files to deal with. Is this a bug?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know you can create &lt;code&gt;macro&lt;/code&gt; such as &lt;code&gt;qp@q:cnext&amp;lt;cr&amp;gt;q&lt;/code&gt; to make it stop at first error, this question is not about that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;vim8.1-2127&lt;/code&gt; on &lt;code&gt;ubuntu16.04&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update0&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Ralf's comment shows that &lt;code&gt;cdo&lt;/code&gt; may continue to next buffer if all entries in a buffer throws an error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@&lt;a href=&quot;https://vi.stackexchange.com/users/10604/d-ben-knoble&quot;&gt;D.Ben.Knoble&lt;/a&gt; filed a &lt;a href=&quot;https://github.com/vim/vim/issues/5102&quot; rel=&quot;nofollow noreferrer&quot;&gt;bug report&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-10-22T01:19:41.803" LastActivityDate="2019-10-22T01:19:41.803" Title="What happens when error occurs during cdo?" Tags="|vimscript|repeated-commands|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="21591" PostTypeId="1" AcceptedAnswerId="21592" CreationDate="2019-10-21T04:12:35.893" Score="0" ViewCount="2382" Body="&lt;p&gt;Recently I was reading &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://learnvimscriptthehardway.stevelosh.com&lt;/a&gt;, and he said a very fast way to improve your speed in vim is to do &lt;code&gt;inoremap jk &amp;lt;esc&amp;gt;&lt;/code&gt;. Sure, that made sense. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then when I next starting using Visual mode, I noticed jk did not work. Sure, yeah, that makes sense. So I added &lt;code&gt;vnoremap jk &amp;lt;esc&amp;gt;&lt;/code&gt; also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next I realized that I needed to use &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; in normal mode too. This is useful when you want to cancel a command, say you accidentally typed in a huge number, and were going to press &lt;code&gt;dd&lt;/code&gt; when you caught yourself. To get rid of the count, you need to do &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; in Normal mode as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I basically just removed everything else and put &lt;code&gt;noremap jk &amp;lt;esc&amp;gt;&lt;/code&gt;. But obviously I can no longer smoothly use &lt;code&gt;j&lt;/code&gt; to scroll down in vim since it is waiting to see (hanging) if I enter &lt;code&gt;k&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I can't use &lt;code&gt;jk&lt;/code&gt; in all my modes then there's no point in doing this mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So: Is there any way to universally and efficiently use something like &lt;code&gt;jk&lt;/code&gt; to escape?&lt;/p&gt;&#xA;" OwnerUserId="25025" LastActivityDate="2019-10-21T21:32:14.050" Title="How can one use jk to escape universally without causing hang?" Tags="|key-bindings|escape|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21592" PostTypeId="2" ParentId="21591" CreationDate="2019-10-21T05:19:09.397" Score="1" Body="&lt;p&gt;The combination &lt;code&gt;jk&lt;/code&gt; is not thought as a general replacement for &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; in all modes. It's just for insert mode to save you from moving your finger up to the &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; key. In all other modes you have to use &quot;normal&quot; &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, but then &lt;code&gt;jk&lt;/code&gt; just moves the cursor down and up -- so nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are users out there who redefine their keyboard layout and define the&lt;code&gt;&amp;lt;CapsLock&amp;gt;&lt;/code&gt; key as &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;. Then you can type &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; with the litte finger of your left hand. (My typing with that finger is so imprecisely, that I often hit &lt;code&gt;&amp;lt;CapsLock&amp;gt;&lt;/code&gt; when I want to hit &lt;code&gt;&amp;lt;Shift&amp;gt;&lt;/code&gt;, so I redefined &lt;code&gt;&amp;lt;CapsLock&amp;gt;&lt;/code&gt; as &lt;code&gt;&amp;lt;Shift&amp;gt;&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a lot of customization, but I did not do any special mapping for the essential movement/editing/... keys. That way I have less problems when I work on a Vi/Vim without my setup.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2019-10-21T17:54:12.287" LastActivityDate="2019-10-21T17:54:12.287" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21593" PostTypeId="1" CreationDate="2019-10-21T09:28:14.497" Score="0" ViewCount="235" Body="&lt;p&gt;Is there an insert and append operation that can be followed by a text-object? I've found this plugins: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/deris/vim-operator-insert&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/deris/vim-operator-insert&lt;/a&gt;&#xA;&lt;a href=&quot;https://github.com/mwgkgk/vim-operator-insert&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/mwgkgk/vim-operator-insert&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But they seem to be unmaintained. I think these operators are useful as they are easily repeatable, if you &lt;code&gt;gaiw&lt;/code&gt; (go append in word) you can add something and go to another word and also append it (just pressing &lt;code&gt;.&lt;/code&gt;), just like with change. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These plugins unfortunately not working with the &lt;code&gt;.&lt;/code&gt; operator and they also fail to work in visual mode. Is there any available solution? Is there a reason why this is not interesting? &lt;/p&gt;&#xA;" OwnerUserId="15345" LastEditorUserId="15345" LastEditDate="2019-10-22T05:54:58.133" LastActivityDate="2020-05-06T11:51:04.333" Title="Making operator insert and append repeatable" Tags="|vimrc|repeated-commands|operator|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21594" PostTypeId="1" CreationDate="2019-10-21T10:23:15.443" Score="1" ViewCount="182" Body="&lt;p&gt;I usually open a directory in vim with command &lt;code&gt;:e path-of-dir&lt;/code&gt;. Because the plugin Netrw is included by default, this will be taken over by it and a netrw window will open with the content of the dir.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But recently I have found that the buffer name of an opened directory would become &lt;code&gt;[No Name]&lt;/code&gt; sometimes. I can still run netrw operations in it, its name just gone. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The versions I am using are &lt;code&gt;vim 8.1&lt;/code&gt; and &lt;code&gt;netrw v165&lt;/code&gt;. I never had this problem in vim 7. Have you guys ever encounter this problem? Is it a bug or just designed to be so? Is there any workaround, since it is a pain for attempts to restore dirs between vim sessions?&lt;/p&gt;&#xA;" OwnerUserId="11308" LastActivityDate="2019-10-21T10:23:15.443" Title="buffer name of opened directory in netrw disappears sometimes" Tags="|buffers|netrw|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="21595" PostTypeId="1" CreationDate="2019-10-21T11:24:30.507" Score="0" ViewCount="290" Body="&lt;p&gt;In my .vimrc i have &#xA;&lt;code&gt;:imap .. .&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;&#xA;and it work as it should (double dot to open menu with fields).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I also want to be able type text like &lt;code&gt;[1..MAX]&lt;/code&gt; as you can see here vim will try use Omnicoplet to find fields in &lt;code&gt;1&lt;/code&gt; what is nonsense. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;is there way to write this map as&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:imap ..&amp;lt;wait&amp;gt; .&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;&amp;lt;wait&amp;gt;&lt;/code&gt; mean no keys is pressed for some time, after two dots.&#xA;Other solution I thought is like &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:imap .. .&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&#xA; :imap ..&amp;lt;any&amp;gt; ..&amp;lt;any&amp;gt;&#xA;&lt;/code&gt;&lt;br&gt;&#xA;Where &lt;code&gt;&amp;lt;any&amp;gt;&lt;/code&gt; mean any key after two dots will be replace to that key and two dots before.&lt;/p&gt;&#xA;" OwnerUserId="25309" LastActivityDate="2019-10-22T10:57:08.727" Title="&quot;Wait&quot; key in :map" Tags="|key-bindings|autocompletion|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21597" PostTypeId="1" CreationDate="2019-10-21T15:49:16.267" Score="0" ViewCount="147" Body="&lt;p&gt;I have the following function that I'm porting to neovim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ---------------&#xA;&quot; Auto record visual mode&#xA;&quot; ---------------&#xA;&quot; Allows executing operators with a different syntax.&#xA;&quot; First we go to visual mode and we can select with the target-objects the text&#xA;&quot; we wan to work on. Then we execute the operation. Finally we can repeat this&#xA;&quot; with gv (goto visual, repeat visual)&#xA;nmap gv v@v&#xA;&#xA;let s:last_mode = 'n'&#xA;augroup visual_enter_normal_enter&#xA;    au!&#xA;    au SafeState * call s:fire_visual_enter_normal_enter()&#xA;augroup END&#xA;&#xA;fu! s:fire_visual_enter_normal_enter() abort&#xA;    let mode = mode()&#xA;    if s:last_mode is# 'n'&#xA;    \ &amp;amp;&amp;amp; index(['v', 'V', &quot;\&amp;lt;c-v&amp;gt;&quot;], mode) != -1&#xA;    \ &amp;amp;&amp;amp; exists('#User#VisualEnter')&#xA;        do &amp;lt;nomodeline&amp;gt; User VisualEnter&#xA;    elseif s:last_mode isnot# 'n'&#xA;    \ &amp;amp;&amp;amp; mode() is# 'n'&#xA;    \ &amp;amp;&amp;amp; exists('#User#NormalEnter')&#xA;        do &amp;lt;nomodeline&amp;gt; User NormalEnter&#xA;    endif&#xA;    let s:last_mode = mode&#xA;endfu&#xA;&#xA;augroup record_keys_in_visual_mode&#xA;    au!&#xA;    au User VisualEnter call s:recording_start()&#xA;    au User NormalEnter call s:recording_stop()&#xA;augroup END&#xA;&#xA;fu! s:recording_start() abort&#xA;    if reg_recording() is# ''&#xA;        call feedkeys('qv', 'int')&#xA;    endif&#xA;endfu&#xA;&#xA;fu! s:recording_stop() abort&#xA;    if reg_recording() is# 'v' &amp;amp;&amp;amp; mode() is# 'n'&#xA;        call feedkeys('q', 'int')&#xA;    endif&#xA;endfu&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nevertheless I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E216: No such group or event: SafeState * call s:fire_visual_enter_normal_enter()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there an equivalent of &lt;code&gt;SafeState&lt;/code&gt; in neovim?&lt;/p&gt;&#xA;" OwnerUserId="15345" LastActivityDate="2019-10-21T15:49:16.267" Title="Is there a SafeState equivalent in neovim?" Tags="|vimscript|neovim|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21599" PostTypeId="2" ParentId="21593" CreationDate="2019-10-21T16:26:01.943" Score="3" Body="&lt;p&gt;You can come up with something relatively simple, following and tinkering what vim has described in &lt;code&gt;:h :map-operator&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example I came up with in about 15 minutes of experimenting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; gi :set opfunc=InsertToTextObject&amp;lt;CR&amp;gt;g@&#xA;vmap &amp;lt;silent&amp;gt; gi :&amp;lt;C-U&amp;gt;call InsertToTextObject(visualmode(), 1)&amp;lt;CR&amp;gt;&#xA;&#xA;nmap &amp;lt;silent&amp;gt; ga :set opfunc=AppendToTextObject&amp;lt;CR&amp;gt;g@&#xA;vmap &amp;lt;silent&amp;gt; ga :&amp;lt;C-U&amp;gt;call AppendToTextObject(visualmode(), 1)&amp;lt;CR&amp;gt;&#xA;&#xA;function! InsertToTextObject(type, ...)&#xA;    let sel_save = &amp;amp;selection&#xA;    let &amp;amp;selection = &quot;inclusive&quot;&#xA;    let reg_save = @@&#xA;&#xA;    if a:0  &quot; Invoked from Visual mode, use gv command.&#xA;        silent exe &quot;normal! gv&quot;&#xA;    else&#xA;        silent exe &quot;normal! `[&quot;&#xA;    endif&#xA;&#xA;    startinsert&#xA;&#xA;    let &amp;amp;selection = sel_save&#xA;    let @@ = reg_save&#xA;endfunction&#xA;&#xA;&#xA;function! AppendToTextObject(type, ...)&#xA;    let sel_save = &amp;amp;selection&#xA;    let &amp;amp;selection = &quot;inclusive&quot;&#xA;    let reg_save = @@&#xA;&#xA;    if a:0&#xA;        silent exe &quot;normal! `&amp;gt;&quot;&#xA;        call feedkeys('a', 'n')&#xA;    elseif a:type == 'line'&#xA;        silent exe &quot;normal! ']&quot;&#xA;        call feedkeys('A', 'n')&#xA;    else&#xA;        silent exe &quot;normal! `]&quot;&#xA;        call feedkeys('a', 'n')&#xA;    endif&#xA;&#xA;    let &amp;amp;selection = sel_save&#xA;    let @@ = reg_save&#xA;endfunction&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Insert to text object is really simple -- you just goto &lt;code&gt;[&lt;/code&gt; mark and &lt;code&gt;startinsert&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Append was a bit more difficult, you have to feedkey there, either &lt;code&gt;a&lt;/code&gt; or &lt;code&gt;A&lt;/code&gt; depending on linewise selection mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See it in action:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kR4jj.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kR4jj.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-10-21T16:26:01.943" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21602" PostTypeId="1" AcceptedAnswerId="21603" CreationDate="2019-10-22T00:55:46.070" Score="2" ViewCount="120" Body="&lt;p&gt;I like consulting my &lt;code&gt;oldfiles&lt;/code&gt; to see what I've been working on recently and to make it easy to find files that are buried deep in various directories. Before I started using the &lt;code&gt;grep&lt;/code&gt; and &lt;code&gt;make&lt;/code&gt; commands, the &lt;code&gt;oldfiles&lt;/code&gt; list only contained files I had intentionally visited, for the most part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've recently started using &lt;code&gt;grep&lt;/code&gt; and other commands that populate the quickfix list, but most of the matches I end up with are not interesting. However, these non-interesting matches end up polluting my &lt;code&gt;oldfiles&lt;/code&gt; list and limiting its usefulness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to exempt files visited by &lt;code&gt;cnext&lt;/code&gt; and &lt;code&gt;cprevious&lt;/code&gt; from being considered visited from the perspective of &lt;code&gt;oldfiles&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ideal solution would be something like an argument to &lt;code&gt;cnext&lt;/code&gt; or &lt;code&gt;cprevious&lt;/code&gt; that controls whether the file counts as visited or not for the purposes of &lt;code&gt;oldfiles&lt;/code&gt;, i.e. &lt;code&gt;cnext-silent&lt;/code&gt; or something like that if it existed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; begin .vimrc&#xA;nnoremap ( :cprevious&amp;lt;cr&amp;gt;                                                                                                            &#xA;nnoremap ) :cnext&amp;lt;cr&amp;gt;&#xA;&quot; end .vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For instance, suppose we have GHC (the Glasgow Haskell Compiler) checked out at &lt;code&gt;~/git/ghc&lt;/code&gt; and we search for &lt;code&gt;unwind&lt;/code&gt; on a whim by executing &lt;code&gt;:grep -r unwind .&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if we press &lt;code&gt;)&lt;/code&gt; (rebound in the vimrc), this ends up polluting the oldfiles list with things I didn't actually work on.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: ~/git/ghc/utils/genapply/Main.hs                                                                                &#xA;2: ~/git/ghc/rts/StgMiscClosures.cmm&#xA;3: ~/git/ghc/rts/StgStartup.cmm&#xA;4: ~/git/ghc/rts/win32/veh_excn.c&#xA;5: ~/git/ghc/testsuite/tests/typecheck/should_compile/T4524.hs&#xA;6: ~/git/ghc/rts/Exception.cmm&#xA;7: ~/git/ghc/rts/Libdw.h&#xA;8: ~/git/ghc/rts/PrimOps.cmm&#xA;9: ~/git/ghc/rts/RaiseAsync.c&#xA;10: ~/git/ghc/rts/StgCRun.c&#xA;11: ~/git/ghc/compiler/nativeGen/X86/Ppr.hs  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2019-10-22T01:51:27.623" Title="visit file from quickfix list without populating oldfiles" Tags="|quickfix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21603" PostTypeId="2" ParentId="21602" CreationDate="2019-10-22T01:42:27.900" Score="3" Body="&lt;p&gt;A few ideas, none of which do what you actually want, but all rely on increased specificity:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:copen&lt;/code&gt;, and be more selective of the matches you select&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:grep -r more_specific_pattern more_specific_file_list&lt;/code&gt;—this keeps the results relevant. (A favorite technique of mine is to populate the &lt;code&gt;:args&lt;/code&gt; list with files I care about—backtick expansion à la &lt;pre&gt;:args `ack -f --md`&lt;/pre&gt; is particularly handy there—and then to &lt;code&gt;:vimgrep /pattern/ ##&lt;/code&gt; to only search those files.)&lt;/li&gt;&#xA;&lt;li&gt;Try the (new-ish) cfilter plugin with&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:packadd cfilter&#xA;:Cfilter /pattern/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Actually answering the question: &lt;code&gt;:help oldfiles&lt;/code&gt; gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                        *v:oldfiles* *oldfiles-variable*&#xA;v:oldfiles      List of file names that is loaded from the |viminfo| file on&#xA;                startup.  These are the files that Vim remembers marks for.&#xA;                The length of the List is limited by the ' argument of the&#xA;                'viminfo' option (default is 100).&#xA;                When the |viminfo| file is not used the List is empty.&#xA;                Also see |:oldfiles| and |c_#&amp;lt;|.&#xA;                The List can be modified, but this has no effect on what is&#xA;                stored in the |viminfo| file later.  If you use values other&#xA;                than String this will cause trouble.&#xA;                {only when compiled with the |+viminfo| feature}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, theoretically, you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/autoload/qf.vim&#xA;function! qf#silent(direction) abort&#xA;  let command = 'c' . get({&#xA;        \ 'n': 'next',&#xA;        \ 'p': 'prev'},&#xA;        \ direction,&#xA;        \ 'next')&#xA;  exec command&#xA;  call remove(v:oldfiles, -1)&#xA;endfunction&#xA;&#xA;&quot; ~/.vim/vimrc or whatever&#xA;nnoremap ) :call qf#silent('n')&amp;lt;CR&amp;gt;&#xA;nnoremap ( :call qf#silent('p')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't have much experience defining commands, so there are probably easier ways to do that and get more features out of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I'm assuming that &lt;code&gt;v:oldfiles[-1]&lt;/code&gt; (the last element) is the current buffer, not the most recent. That might be wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I say &lt;em&gt;theoretically&lt;/em&gt; because, well, it seems like it might have little effect (see the quote).&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-10-22T01:51:27.623" LastActivityDate="2019-10-22T01:51:27.623" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21604" PostTypeId="1" CreationDate="2019-10-22T06:33:01.420" Score="0" ViewCount="111" Body="&lt;p&gt;I'm trying to figure out a way to make a repeatable operator insert. To do so I'm trying to make use of tpope/repeat. My idea is to set a repeatable call that repeats the last operation, repeating the last operation as it is doesn't work as insert is executed in place. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;let g:last_insert_operator_textobj = ''&#xA;function s:repeat_insert()&#xA;    &quot; TODO: detect that last action was the insert operator.&#xA;    &quot; gi := (go insert) operator (which is working)&#xA;    call feedkeys(&quot;gi&quot;.g:last_insert_operator_textobj)&#xA;endfunction&#xA;command! repeat_insert call s:repeat_insert()&#xA;nmap (operator-insert-i-repeat) &amp;lt;plug&amp;gt;repeat_insert&#xA;&#xA;function s:check_if_repeat_insert()&#xA;    &quot; TODO: detect that this insert is associated to the&#xA;    &quot; (operator-insert) and not a normal insert&#xA;&#xA;    let g:last_insert_operator_textobj = somehow_get_last_used_textobject_keys()&#xA;&#xA;    autocmd! InsertLeave * &quot;call repeat#set(&quot;\&amp;lt;Plug&amp;gt;(operator-insert-i-repeat)&quot;, -1)&#xA;endfunction&#xA;&#xA;command! check_if_repeat_insert call s:check_if_repeat_insert()&#xA;autocmd! InsertLeave * call check_if_repeat_insert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I could figure out how to retrieve the keys of the last used text object &lt;code&gt;let g:last_insert_operator_textobj = somehow_get_last_used_textobject_keys()&lt;/code&gt; then the rest of the script I think it would work. Figuring out the &lt;code&gt;&quot; TODO: detect that this insert is associated to the (operator-insert) and not a normal insert&lt;/code&gt; shouldn't be too complicated. &lt;/p&gt;&#xA;" OwnerUserId="15345" LastEditorUserId="15345" LastEditDate="2019-10-22T06:47:51.180" LastActivityDate="2019-10-22T06:47:51.180" Title="Find out last used text object" Tags="|vimscript|repeated-commands|operator|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="21606" PostTypeId="2" ParentId="21595" CreationDate="2019-10-22T10:57:08.727" Score="2" Body="&lt;p&gt;To implement your stated use case, the &lt;code&gt;:imap ..&amp;lt;any&amp;gt; ..&amp;lt;any&amp;gt;&lt;/code&gt; would leverage Vim's built-in &lt;code&gt;'timeoutlen'&lt;/code&gt;; it's implementation wouldn't be so outrageous, there's only a limited set of available keys and you can use metaprogramming with a &lt;code&gt;:for&lt;/code&gt; loop to build all these mappings. The biggest challenge here is enumerating all desired keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I doubt that this would be very useful. The completion popup would only open after that delay, so it will slow you down (unless you only intend to trigger that mapping if you're contemplating about the possible values, anyway) - completion is as much about saving typing than it is about showing alternatives.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an alternative approach, I'd home in on &lt;em&gt;try use Omnicoplet to find fields in 1 is nonsense&lt;/em&gt;. With a &lt;a href=&quot;https://vimhelp.appspot.com/map.txt.html#%3Amap-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :map-expression&lt;/code&gt;&lt;/a&gt;, you can check the text before the cursor, and then either trigger completion (without delay!) or (e.g. in case of a digit) just return a literal &lt;code&gt;.&lt;/code&gt; there. That condition can be as complex as you'd like (you could even query the syntax group and leverage syntax parsing of identifiers vs. other stuff), and should &quot;do what I mean&quot; in many cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For those special exceptions (that will always exist), I personally find it okay to actively avoid triggering the mapping, either by making a short pause when typing (&lt;code&gt;.&lt;/code&gt; &amp;lt;pause&amp;gt; &lt;code&gt;.&lt;/code&gt; in your case), or escaping one of the characters via &lt;a href=&quot;https://vimhelp.appspot.com/insert.txt.html#i_CTRL-V&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;i_CTRL-V&lt;/code&gt;&lt;/a&gt;: &lt;code&gt;.&amp;lt;C-v&amp;gt;.&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-10-22T10:57:08.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21607" PostTypeId="2" ParentId="21483" CreationDate="2019-10-22T11:01:59.140" Score="0" Body="&lt;p&gt;Flygrep is a plugin for searching text. it do not for searching file path. if you want to searching file path, I recommended to use denite.nvim &lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2019-10-22T11:01:59.140" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21608" PostTypeId="2" ParentId="3008" CreationDate="2019-10-22T12:50:17.927" Score="4" Body="&lt;p&gt;What happens here is, that the &lt;code&gt;bufdo&lt;/code&gt; and &lt;code&gt;argdo&lt;/code&gt; command iterate over all buffers themselves. However without writing your changes, vim will refuse to load the next buffer, &lt;strong&gt;unless&lt;/strong&gt; the &lt;a href=&quot;https://vimhelp.org/options.txt.html#&amp;#39;hidden&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;'hidden'&lt;/a&gt; option is set (which it is not by default) or the argument to the &lt;code&gt;buf/arg-doc&lt;/code&gt; comment does write the change itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this will work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex -s -c'bufdo! %s/\s\+$//e|w' -cx *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or alternatively using &lt;code&gt;:set hidden&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ex --cmd ':set hidden' -s -c'bufdo! %s/\s\+$//e' -cxa *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-10-22T12:50:17.927" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21609" PostTypeId="2" ParentId="21483" CreationDate="2019-10-22T12:53:21.107" Score="1" Body="&lt;p&gt;A &quot;standard vim&quot; answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:args `find . -iname '*.kl'`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Substitute the &lt;code&gt;find&lt;/code&gt; command for any command that can generate the list of files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can use &lt;code&gt;:next&lt;/code&gt; and &lt;code&gt;:prev&lt;/code&gt; for navigating (bound conveniently to &lt;code&gt;]a&lt;/code&gt; and &lt;code&gt;[a&lt;/code&gt; in tpope/unimpaired).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further refinement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vimgrep /pattern/ ##&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This searches the arglist (&lt;code&gt;##&lt;/code&gt;) for the given &lt;code&gt;pattern&lt;/code&gt;; you can use &lt;code&gt;:cnext&lt;/code&gt; and &lt;code&gt;:cprev&lt;/code&gt; to navigate (bound to &lt;code&gt;]q&lt;/code&gt; and &lt;code&gt;[q&lt;/code&gt; in tpope/unimpaired).&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-10-22T12:53:21.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21610" PostTypeId="2" ParentId="6295" CreationDate="2019-10-22T12:56:47.283" Score="1" Body="&lt;p&gt;You can do it with the following multi-line regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\*\{2,}.*\(\n\*\{2,}.*\)\+/&quot;&amp;amp;&quot;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-10-22T12:56:47.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21611" PostTypeId="2" ParentId="21567" CreationDate="2019-10-22T14:40:35.887" Score="1" Body="&lt;p&gt;I am having the same issue. Just upgraded to &lt;code&gt;8.1.2168&lt;/code&gt; a couple days ago. A couple things I noticed:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;My default &lt;code&gt;spellcapcheck&lt;/code&gt; was set to &lt;code&gt;[.?!]\_[\])'&quot;^I ]\+&lt;/code&gt;, changing it to yours (&lt;code&gt;[.?!]_[])'&lt;/code&gt;) or &lt;code&gt;[.?!]\_[\])'&quot;' \t]\+&lt;/code&gt; had no effect. &lt;/li&gt;&#xA;&lt;li&gt;Perhaps more interestingly, it doesn't appear that these are actually recognized as typos: when I use &lt;code&gt;]s&lt;/code&gt; and &lt;code&gt;[s&lt;/code&gt; to move to misspelled words, vim skips over the words at the start of lines (unless they are explicitly misspelled). &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In other words, looks like gvim doesn't actually &lt;em&gt;think&lt;/em&gt; these are misspelled words, but erroneously highlights them anyways. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested this by opening up an empty file (&lt;code&gt;vim -u NONE&lt;/code&gt;), running &lt;code&gt;set spell&lt;/code&gt;, typing some words (some purposefully misspelled), observing what was highlighted, and using &lt;code&gt;]s&lt;/code&gt; &amp;amp; &lt;code&gt;[s&lt;/code&gt; to see what was actually flagged as misspelled.&lt;/p&gt;&#xA;" OwnerUserId="25323" LastEditorUserId="25323" LastEditDate="2019-10-22T14:48:00.560" LastActivityDate="2019-10-22T14:48:00.560" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21612" PostTypeId="2" ParentId="21567" CreationDate="2019-10-22T14:44:34.243" Score="2" Body="&lt;p&gt;This is a &lt;a href=&quot;https://github.com/vim/vim/issues/5078&quot; rel=&quot;nofollow noreferrer&quot;&gt;known bug&lt;/a&gt;, introduced by patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.2153&quot; rel=&quot;nofollow noreferrer&quot;&gt;v8.1.2153&lt;/a&gt; that has since been fixed with patch &lt;a href=&quot;https://github.com/vim/vim/commit/7751d1d1a3d447d0d48f57f34e0da9f7c6ac433d&quot; rel=&quot;nofollow noreferrer&quot;&gt;v8.1.2172&lt;/a&gt;, so you'd need to update your MacVim to a new Version.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-10-22T14:44:34.243" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21613" PostTypeId="1" CreationDate="2019-10-22T19:18:10.027" Score="1" ViewCount="124" Body="&lt;p&gt;I would like to execute 'zz' to center the current line to the center of the screen when opening a new file.  I have tried the following, but it does not seem to be working for some reason:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter * :normal zz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="7226" LastActivityDate="2019-10-22T19:18:10.027" Title="Center current line to the center of screen when opening a file" Tags="|vimrc|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21614" PostTypeId="1" CreationDate="2019-10-23T02:49:55.943" Score="0" ViewCount="68" Body="&lt;p&gt;I have a news article which I need to edit up a bit. Basically, I need to search for all lines that do not contain characters t and h 2 or more times in a row and replace 4 letter words with character D in those lines. Have no idea where to start.&#xA;For example, I have this text &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Animals are multicellular eukaryotic organisms which form a biological kingdom Animalia. &#xA;Historically, Aristotle divided animals into those with blood and those without&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want it to look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Animals are multicellular eukaryotic organisms which D a biological kingdom Animalia.&#xA;Historically, Aristotle divided animals into those with blood and those without&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25334" LastActivityDate="2019-10-23T05:40:58.497" Title="Search for lines that do not have certain characters in a row" Tags="|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21615" PostTypeId="1" CreationDate="2019-10-23T03:51:11.987" Score="0" ViewCount="49" Body="&lt;p&gt;I need to search for a certain word, and if it occurs, move it to the end of the line where it occured. For instance, search for &quot;bugs&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Welcome! Meta Stack Exchange is intended for bugs, features, and discussions &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turns into:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Welcome! Meta Stack Exchange is intended for, features, and discussions bugs &lt;/p&gt;&#xA;" OwnerUserId="25335" LastActivityDate="2019-10-23T09:16:00.410" Title="Search for a word and if occurs, delete it and move to the end of line" Tags="|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21616" PostTypeId="2" ParentId="21615" CreationDate="2019-10-23T05:20:26.520" Score="2" Body="&lt;pre&gt;&lt;code&gt;:g/ \?\&amp;lt;bugs\&amp;gt;/normal! dgn$p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:g/.../&lt;/code&gt; for all lines matching a pattern&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\?\&amp;lt;bugs\&amp;gt;&lt;/code&gt; an optional space followed by &quot;bugs&quot; (a whole word)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;normal! dgn$p&lt;/code&gt; delete last match; go to end of line; put last match there&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-10-23T07:23:11.300" LastActivityDate="2019-10-23T07:23:11.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21617" PostTypeId="2" ParentId="21614" CreationDate="2019-10-23T05:40:58.497" Score="1" Body="&lt;p&gt;Not too hard, really, as such tasks can be translated into regexps in a very straightforward manner.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:v/tt\|hh/s/\&amp;lt;\a\{4}\&amp;gt;/D/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:v/.../&lt;/code&gt; for all lines NOT matching a pattern&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;tt\|hh&lt;/code&gt; &quot;tt&quot; OR &quot;hh&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s/.../D/g&lt;/code&gt; substitute ALL matches on a line with &quot;D&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\&amp;lt;...\&amp;gt;&lt;/code&gt; &quot;word&quot; borders&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\a\{4}&lt;/code&gt; exactly four Latin letters&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Have no idea where to start.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Read about regexps. In Vim's embedded help these are &lt;code&gt;:h usr_27.txt&lt;/code&gt; and &lt;code&gt;:h pattern.txt&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-23T05:40:58.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21618" PostTypeId="1" CreationDate="2019-10-23T07:00:27.550" Score="0" ViewCount="322" Body="&lt;p&gt;I started debugging a c program inside vim with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:packadd termdebug&#xA;:Termdebug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with vim 8 and and gdb &gt; 8.3 installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to set a breakpoint, I would like to send the following string while the cursor is in file main.c (by typing &lt;code&gt;&amp;lt;leader&amp;gt;b&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;break fileName:lineNumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so that the gdb terminal receives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;break main.c:100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if the file name is &lt;code&gt;main.c&lt;/code&gt; and the current line for this example is 100 and represented with &lt;code&gt;let lineNumber = line('.')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I've come up with until now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b : call SetBreakPoint()&amp;lt;CR&amp;gt;&#xA;function! SetBreakPoint() abort&#xA;    let lineNumber = line('.')&#xA;    let fileName = %f&#xA;    exe &quot;normal! ma&quot;&#xA;    exe &quot;normal! \&amp;lt;C-w&amp;gt;w\&amp;lt;C-w&amp;gt;w&quot; | call term_sendkeys('', &quot;break fileName\:lineNumber\&amp;lt;CR&amp;gt;&quot;)&#xA;    exe &quot;normal! \&amp;lt;C-w&amp;gt;w`a&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The line &lt;code&gt;exe &quot;normal! \&amp;lt;C-w&amp;gt;w\&amp;lt;C-w&amp;gt;w | call term_sendkeys()...&quot;&lt;/code&gt; takes into account that the cursor is in a file named main.c and has to traverse Nerdtree to arrive to the Terminal window opened by vim with gdb.&#xA;I have in total 3 vim windows (main.c, Nerdtree and Terminal (gdb)).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem here is that I cannot make &lt;code&gt;term_sendkeys()&lt;/code&gt; load the values of fileName and lineNumber.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, changing the longest line of code to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe &quot;normal! \&amp;lt;C-w&amp;gt;w\&amp;lt;C-w&amp;gt;w&quot; | call term_sendkeys('', &quot;break main.c:100\&amp;lt;CR&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works but defeats the whole purpose of defining break points inside the vim main.c window without having to manually change window and type in the break command for gdb.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="25338" LastActivityDate="2019-10-23T07:00:27.550" Title="Send keystrokes and string to gdb terminal" Tags="|vimrc|vimscript|terminal|vim8|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21619" PostTypeId="1" CreationDate="2019-10-23T07:03:31.167" Score="2" ViewCount="534" Body="&lt;p&gt;I'm testing neovim and for many thing it is working way faster than vim (I use many plugins ~80, and I can really tell the difference with neovim). All the same config files worked out of the box, but I've notice this different behavior. &lt;code&gt;hlsearch&lt;/code&gt; seems not to be working, it does work when I use &lt;code&gt;/&lt;/code&gt; but not when I use &lt;code&gt;:g&lt;/code&gt; or &lt;code&gt;:%s&lt;/code&gt;. Here an example, neovim on the left, vim on the right:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/puEDO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/puEDO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it can be observed, in vim the pattern is highlighted which is great. &#xA;Is there a way to activate this behavior in neovim or is this feature missing?&lt;/p&gt;&#xA;" OwnerUserId="15345" LastEditorUserId="343" LastEditDate="2019-10-23T09:20:56.623" LastActivityDate="2019-10-23T09:20:56.623" Title="neovim hlsearch not working" Tags="|neovim|substitute|highlight|global-command|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21620" PostTypeId="2" ParentId="21593" CreationDate="2019-10-23T08:23:54.453" Score="0" Body="&lt;p&gt;I think I'm almost there, maybe can use this as inspiration to make it work. I'm making use of kana/operator-user as in the suggested plugins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is entering insert mode during the repetition, so I've created a different operator to repeat using paste:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists('g:loaded_operator_insert')&#xA;  finish&#xA;endif&#xA;let g:loaded_operator_insert = 1&#xA;&#xA;let s:save_cpo = &amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;&#xA;&#xA;call operator#user#define('insert-i', 'operator#insert#insert_i')&#xA;call operator#user#define('insert-a', 'operator#insert#insert_a')&#xA;call operator#user#define('insert-i-repeat', 'operator#insert#insert_i_repeat')&#xA;call operator#user#define('insert-a-repeat', 'operator#insert#insert_a_repeat')&#xA;&#xA;&#xA;let &amp;amp;cpo = s:save_cpo&#xA;unlet s:save_cpo&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which works like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:save_cpo = &amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;&#xA;&quot; Public API {{{1&#xA;&#xA;function! operator#insert#insert_i(motion_wise)&#xA;    return s:operator_insert_i(a:motion_wise)&#xA;endfunction&#xA;&#xA;function! operator#insert#insert_a(motion_wise)&#xA;    return s:operator_insert_a(a:motion_wise)&#xA;endfunction&#xA;&#xA;function! operator#insert#insert_i_repeat(motion_wise)&#xA;    return s:operator_insert_i_repeat(a:motion_wise)&#xA;endfunction&#xA;&#xA;function! operator#insert#insert_a_repeat(motion_wise)&#xA;    return s:operator_insert_a_repeat(a:motion_wise)&#xA;endfunction&#xA;&#xA;&quot;}}}&#xA;&#xA;&quot; Private {{{1&#xA;&#xA;function! s:operator_insert_i_repeat(motion_wise)&#xA;    let s:original_pos = getpos(&quot;'[&quot;)[1:]&#xA;    call cursor(s:original_pos)&#xA;    normal! &quot;.P&#xA;endfunction&#xA;&#xA;function! s:operator_insert_a_repeat(motion_wise)&#xA;    call cursor(getpos(&quot;']&quot;)[1:])&#xA;    if col(&quot;']&quot;) &amp;gt;= col(&quot;$&quot;) - 1&#xA;        normal! &quot;.p&#xA;    else&#xA;        normal! l&#xA;        normal! &quot;.p&#xA;    endif&#xA;endfunction&#xA;&#xA;function! s:operator_insert_i(motion_wise)&#xA;    let s:original_pos = getpos(&quot;'[&quot;)[1:]&#xA;    call cursor(s:original_pos)&#xA;    startinsert&#xA;    silent! call repeat#set(&quot;\&amp;lt;Plug&amp;gt;(operator-insert-i-repeat)&quot;, -1)&#xA;endfunction&#xA;&#xA;function! s:operator_insert_a(motion_wise)&#xA;    call cursor(getpos(&quot;']&quot;)[1:])&#xA;    if col(&quot;']&quot;) &amp;gt;= col(&quot;$&quot;) - 1&#xA;        startinsert!&#xA;    else&#xA;        normal! l&#xA;        startinsert&#xA;    endif&#xA;    silent! call repeat#set(&quot;\&amp;lt;Plug&amp;gt;(operator-insert-a-repeat)&quot;, -1)&#xA;endfunction&#xA;&#xA;&quot;}}}&#xA;&#xA;let &amp;amp;cpo = s:save_cpo&#xA;unlet s:save_cpo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now it does work, but when we do the &lt;code&gt;.&lt;/code&gt; we need to reenter the first time the text object. It is not ideal, but something is something.&lt;/p&gt;&#xA;" OwnerUserId="15345" LastEditorUserId="15345" LastEditDate="2020-05-06T11:51:04.333" LastActivityDate="2020-05-06T11:51:04.333" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21621" PostTypeId="2" ParentId="21615" CreationDate="2019-10-23T09:16:00.410" Score="1" Body="&lt;p&gt;You can use a &lt;a href=&quot;https://www.vimhelp.org/change.txt.html#%3Asubstitute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:substitute&lt;/code&gt;&lt;/a&gt; command for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v ?(&amp;lt;bugs&amp;gt;)(.*)/\2 \1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s&lt;/code&gt; substitute&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt; start of regular expression&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt; use &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2Fmagic&quot; rel=&quot;nofollow noreferrer&quot;&gt;very magic&lt;/a&gt; mode. This makes this regular expression a bit easier to read/write, because you don't need to use so many backslashes&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[SPACE]?&lt;/code&gt; an &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%3F&quot; rel=&quot;nofollow noreferrer&quot;&gt;optional&lt;/a&gt; space&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(&amp;lt;bugs&amp;gt;)&lt;/code&gt; find the entire word bugs, and save it in capture group 1. The angle brackets &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; mark the &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%3C&quot; rel=&quot;nofollow noreferrer&quot;&gt;start and end of a word&lt;/a&gt;. The parentheses &lt;code&gt;()&lt;/code&gt; mark the start and end of a &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%28&quot; rel=&quot;nofollow noreferrer&quot;&gt;capture group&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(.*)&lt;/code&gt; find anything that follows, and save it in capture group 2&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/&lt;/code&gt; end of regular expression&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\2 \1&lt;/code&gt; replace the matched text with the contents of capture group 2, followed by a space, followed by the contents of capture group 1&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-10-23T09:16:00.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21622" PostTypeId="1" AcceptedAnswerId="21623" CreationDate="2019-10-23T12:29:09.760" Score="1" ViewCount="565" Body="&lt;p&gt;This question may have an obvious answer that I'm missing, but how can I easily tell how many of a character, in this case &quot; , &quot; are in a line, or a specified string using vimscript?&lt;/p&gt;&#xA;" OwnerUserId="23679" LastActivityDate="2019-10-23T12:56:40.180" Title="Get number of commas in a line using Vimscript" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21623" PostTypeId="2" ParentId="21622" CreationDate="2019-10-23T12:45:21.657" Score="3" Body="&lt;p&gt;VimScript does not have a special character type. In fact, you always &lt;code&gt;count()&lt;/code&gt; for substrings (or items in list):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo count(getline(&quot;.&quot;), &quot;,&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-23T12:45:21.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21624" PostTypeId="2" ParentId="21622" CreationDate="2019-10-23T12:45:43.350" Score="2" Body="&lt;p&gt;You can use this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:echo len(split(getline('.'), ','))&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That will get the content of the current line, split it on the &lt;code&gt;,&lt;/code&gt; (comma) to a list and count the number of items of the list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: that the &lt;code&gt;count()&lt;/code&gt; function just relatively recently learned about counting items in strings, while this solution is also compatible with Vim 7.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-10-23T12:56:40.180" LastActivityDate="2019-10-23T12:56:40.180" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21625" PostTypeId="1" CreationDate="2019-10-23T13:08:06.597" Score="0" ViewCount="43" Body="&lt;p&gt;I wondered if it is possible to add a character to &lt;code&gt;iskeyword&lt;/code&gt; or similar, but such that it is only allowed at the start of the keyword.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use case: TeX macros start with &lt;code&gt;\&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related question: &lt;a href=&quot;https://vi.stackexchange.com/questions/12365/possible-to-use-in-iskeyword-but-only-at-the-end-of-a-word&quot;&gt;Possible to use `!` in `iskeyword`, but only at the end of a word?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is, that if I just add &lt;code&gt;\&lt;/code&gt; to &lt;code&gt;iskeyword&lt;/code&gt; then &lt;code&gt;\macroA\macroB&lt;/code&gt; is a single keyword, instead of two keywords.&lt;/p&gt;&#xA;" OwnerUserId="16779" LastActivityDate="2019-10-23T13:08:06.597" Title="Add character to iskeyword string, but only at the beginning of a word" Tags="|keyword|" AnswerCount="0" CommentCount="6" ClosedDate="2019-11-05T09:48:22.070" ContentLicense="CC BY-SA 4.0" />
  <row Id="21626" PostTypeId="2" ParentId="795" CreationDate="2019-10-23T17:11:43.150" Score="5" Body="&lt;p&gt;A more complex example, to run a Python script on the current buffer, putting the output in a new tab:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabnew | r ! python -c &quot;import json, sys; json.load(sys.stdin)&quot; &amp;lt; #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;tabnew&lt;/code&gt; opens a new tab&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;r&lt;/code&gt; is short for &lt;code&gt;read&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;!&lt;/code&gt; executes a shell command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;python -c&lt;/code&gt; executes an inline python script&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;json.load(sys.stdin)&lt;/code&gt; tries to load (parse) json from stdin&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt; #&lt;/code&gt; redirects the &lt;em&gt;previous&lt;/em&gt; buffer (the current one pre &lt;code&gt;tabnew&lt;/code&gt;) into the command&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="25350" LastActivityDate="2019-10-23T17:11:43.150" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21627" PostTypeId="2" ParentId="795" CreationDate="2019-10-23T19:56:59.543" Score="1" Body="&lt;p&gt;A plugin I've been using to do this is &lt;a href=&quot;https://github.com/sjl/clam.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;clam.vim&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After installing it, you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Clam date&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to put the date in a new buffer. You can run pretty arbitrarily complex commands, so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Clam find . -iname '*.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Clam ./my-script&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is also possible.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-10-23T19:56:59.543" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21628" PostTypeId="1" AcceptedAnswerId="21632" CreationDate="2019-10-23T20:30:26.503" Score="1" ViewCount="205" Body="&lt;h2&gt;Huh?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://begriffs.com/posts/2019-07-19-history-use-vim.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this interesting&#xA;post&lt;/a&gt;, I took the&#xA;idea to incorporate &lt;code&gt;xxd&lt;/code&gt; into vim a little more nicely than the usual &lt;code&gt;%!xxd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I started structuring the code and testing. (It's a first draft.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/benknoble/Dotfiles/pull/124&quot; rel=&quot;nofollow noreferrer&quot;&gt;Link to code (also listed below)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The issue&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The problem I ran into is that, after doing &lt;code&gt;:Hex&lt;/code&gt;, the &lt;code&gt;'modified'&lt;/code&gt; option is&#xA;&lt;em&gt;always&lt;/em&gt; set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As best as I can tell, it's because the conversion to hex triggers the&#xA;&lt;code&gt;TextChanged&lt;/code&gt; autocmd-event, which then modifies the text. When the ftplugin&#xA;script actually finishes, &lt;code&gt;'modified'&lt;/code&gt; is still unset (as noticed using&#xA;&lt;code&gt;:debug&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a similar vein, anytime I save (&lt;code&gt;:w&lt;/code&gt;), the modified flag stays on. This one&#xA;I'm less sure about, but I'd bet it's a similar issue.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Attempted fix&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Removing the &lt;code&gt;TextChanged&lt;/code&gt; portion of the autocommand basically solves all my&#xA;problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, &lt;em&gt;I liked its other effects&lt;/em&gt;. When using &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-a&amp;gt;&lt;/code&gt;, or&#xA;even &lt;code&gt;r&lt;/code&gt;, the text corresponding the to the hex was instantly updated. I could&#xA;probably achieve this using &lt;code&gt;CursorHold&lt;/code&gt; or something else, but I do want it to&#xA;be rather instantaneous.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I've already checked, and &lt;code&gt;noautocmd&lt;/code&gt; won't help me here; &lt;code&gt;TextChanged&lt;/code&gt;&#xA;explicitly ignores it.)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Code&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/plugin/hex.vim&#xA;if exists('g:loaded_hex')&#xA;  finish&#xA;endif&#xA;let g:loaded_hex = 1&#xA;&#xA;command -bar -bang Hex&#xA;      \ if &amp;lt;bang&amp;gt;0 |&#xA;      \   set filetype= |&#xA;      \   edit! |&#xA;      \ else |&#xA;      \   set filetype=xxd |&#xA;      \ endif&#xA;command -bar Bless Hex!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/after/ftplugin/xxd.vim&#xA;&quot; Vim filetype plugin&#xA;&quot; Language:              xxd&#xA;&quot; Maintainer:            Ben Knoble &amp;lt;ben.knoble@gmail.com&amp;gt;&#xA;&#xA;&quot; cache it&#xA;let g:xxd = get(g:, 'xxd', executable('xxd'))&#xA;&#xA;if !g:xxd&#xA;  finish&#xA;endif&#xA;&#xA;call hex#setup()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/autoload/hex.vim&#xA;&quot; I realized this should be probably all just be scriptlocal in the ftplugin,&#xA;&quot; but oh well. It's not hurting anyone&#xA;function hex#setup() abort&#xA;  setlocal binary&#xA;  call hex#dump()&#xA;  setlocal nomodified&#xA;&#xA;  augroup ftplugin_xxd&#xA;    au! * &amp;lt;buffer&amp;gt;&#xA;&#xA;    au BufWritePre &amp;lt;buffer&amp;gt; call hex#write_pre()&#xA;    au BufWritePost &amp;lt;buffer&amp;gt; call hex#write_post()&#xA;    au TextChanged,InsertLeave &amp;lt;buffer&amp;gt; call hex#update()&#xA;  augroup END&#xA;&#xA;  &quot; this comes from another of my autoload files. You can check it in the github&#xA;  &quot; link above if you want&#xA;  let b:undo_ftplugin = ftplugin#undo({&#xA;        \ 'opts': [&#xA;        \   'binary',&#xA;        \ ],&#xA;        \ 'custom': [&#xA;        \   'execute &quot;au! ftplugin_xxd * &amp;lt;buffer&amp;gt;&quot;',&#xA;        \   'call hex#rev()',&#xA;        \ ],&#xA;        \ })&#xA;endfunction&#xA;&#xA;function hex#dump() abort&#xA;  silent %!xxd -g 1&#xA;  call hex#strip_trailing_CR()&#xA;endfunction&#xA;&#xA;function hex#rev() abort&#xA;  silent %!xxd -r&#xA;endfunction&#xA;&#xA;function hex#strip_trailing_CR() abort&#xA;  %substitute/\r$//e&#xA;endfunction&#xA;&#xA;&quot; before writing, translate back to original&#xA;function hex#write_pre() abort&#xA;  call hex#save_cursor()&#xA;  call hex#rev()&#xA;endfunction&#xA;&#xA;&quot; after writing, restore hex view and mark unmodified&#xA;function hex#write_post() abort&#xA;  call hex#dump()&#xA;  setlocal nomodified&#xA;  call hex#restore_cursor()&#xA;endfunction&#xA;&#xA;&quot; update text column after changing hex values&#xA;function hex#update() abort&#xA;  call hex#save_cursor()&#xA;  call hex#rev()&#xA;  call hex#dump()&#xA;  call hex#restore_cursor()&#xA;endfunction&#xA;&#xA;function hex#save_cursor() abort&#xA;  let b:xxd_cursor = getpos('.')&#xA;endfunction&#xA;&#xA;function hex#restore_cursor() abort&#xA;  call setpos('.', b:xxd_cursor)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-10-24T09:39:33.520" Title="Avoiding unwanted TextChanged events to avoid 'modified' (hex editing)" Tags="|autocmd|xxd|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21629" PostTypeId="1" CreationDate="2019-10-24T00:47:17.907" Score="0" ViewCount="167" Body="&lt;p&gt;I have a long text file (300 lines), and I would like to format it so each line is not longer than 50 characters. For example, we have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I have a really long text, I have a really long text, I have a really long text&#xA;I have a really long text, I have a really long text, I have a really long text&#xA;I have a really long text, I have a really long text, I have a really long text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the goal is for it to look like :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I have a really long text,I have a really long&#xA;text, I have a really long text I have a really&#xA;long text, I have a really long text, I have a &#xA;really long text, I have a really long text, I&#xA;have a really long text, I have a really long&#xA;text, I have a really long text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do it besides setting &lt;code&gt;'textwidth'&lt;/code&gt; and &lt;code&gt;gww&lt;/code&gt;? Using backrefernces?   &lt;/p&gt;&#xA;" OwnerUserId="25335" LastEditorUserId="25335" LastEditDate="2019-10-24T03:44:33.083" LastActivityDate="2019-10-24T06:36:20.663" Title="How to break lines into a certain amount of characters?" Tags="|search|formatting|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21630" PostTypeId="2" ParentId="21629" CreationDate="2019-10-24T06:36:20.663" Score="2" Body="&lt;p&gt;There are a couple of ways to approach this, however each one has its own drawbacks:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There is no really good way to re-format a list of strings programmatically according to a different textwidth value. Your current best chances are basically to set the 'textwidth' option and reformat using &lt;code&gt;gq&lt;/code&gt; (this can be done in another window to leave the current option value in the current window alone).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can also try to use some basic regexp magic, but be aware, you most certainly need to post process the result. Try this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\(.\{50\}\)/\1\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will add a newline after 50 characters, however it will add newlines within a word and the result may not look visually pleasing. Slightly better would be this approach, which tries to find a space after 40 characters and break the line on that one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/.\{40\}\zs\s/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finally, you can also try to implement your own textformatting algorithm according according to your needs. Be aware however, there is no VimScript function to reformat according to what Vim would do internally. So you have to re-implement it in pure VimScript and this can be become a can of worms once you start this way. I recently did this with the &lt;a href=&quot;https://github.com/chrisbra/vim-xml-runtime/&quot; rel=&quot;nofollow noreferrer&quot;&gt;official vim-xml-runtime plugin&lt;/a&gt; and I am not yet satisfied.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-10-24T06:36:20.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21631" PostTypeId="2" ParentId="12365" CreationDate="2019-10-24T07:31:47.760" Score="3" Body="&lt;p&gt;No, that is not possible. Vim treats all those &lt;code&gt;'is...'&lt;/code&gt; options as &lt;em&gt;collections of characters&lt;/em&gt; (like &lt;code&gt;[a-zA-z]&lt;/code&gt;), and cannot do more precise regular expression-like assertions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, the &lt;code&gt;'iskeyword'&lt;/code&gt; set has its own character class (&lt;a href=&quot;https://vimhelp.appspot.com/pattern.txt.html#%2F%5Ck&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\k&lt;/code&gt;&lt;/a&gt;), so it &lt;strong&gt;is limited to be a simple set of characters&lt;/strong&gt;. If this were changed, that correspondence of &quot;a keyword&quot; and a &lt;code&gt;\k\+&lt;/code&gt; match would be lost, and plugins would be broken.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Alternative approaches&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Fiddling with &lt;code&gt;'iskeyword'&lt;/code&gt; is convenient, as it affects many built-in motions and text objects. But as we've now seen, it has these inherent limitations that cannot be overcome. However, Vim can be extended with custom motions and text objects. For your example, you can define a text object pair &lt;code&gt;am&lt;/code&gt; / &lt;code&gt;im&lt;/code&gt; (a method / inner method, matching &lt;code&gt;\k\+!\?&lt;/code&gt;, the former also surrounding whitespace). (My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3130&quot; rel=&quot;nofollow noreferrer&quot;&gt;CountJump plugin&lt;/a&gt; can help with defining custom motions and text object, also the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2100&quot; rel=&quot;nofollow noreferrer&quot;&gt;textobj-user plugin&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many people have extended &lt;code&gt;*&lt;/code&gt; to also work on the visual selection (e.g. through my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4320&quot; rel=&quot;nofollow noreferrer&quot;&gt;SearchHighlighting plugin&lt;/a&gt;, or one of its many alternatives). You can then combine the text object with visual mode to search for the next method occurrence: &lt;code&gt;vim*&lt;/code&gt;. Or you define a custom search &lt;code&gt;&amp;lt;Leader&amp;gt;/{motion}&lt;/code&gt; and can then skip visual mode: &lt;code&gt;&amp;lt;Leader&amp;gt;/im&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, this is not as convenient as defining &lt;code&gt;'iskeyword'&lt;/code&gt; and hitting &lt;code&gt;*&lt;/code&gt;. But it is far more extensible: you can define additional text objects, e.g. for method name + its arguments, class names, ...&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-10-24T07:31:47.760" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21632" PostTypeId="2" ParentId="21628" CreationDate="2019-10-24T09:11:10.377" Score="1" Body="&lt;pre&gt;&lt;code&gt;                            *TextChanged*&#xA;TextChanged         After a change was made to the text in the&#xA;                current buffer in Normal mode.  That is after&#xA;                |b:changedtick| has changed (also when that&#xA;                happened before the TextChanged autocommand&#xA;                was defined).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's based on &lt;a href=&quot;https://vimhelp.org/eval.txt.html#b%3Achangedtick&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h b:changedtick&lt;/a&gt; , so change &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27modified%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'modified'&lt;/a&gt; won't stop it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although your &lt;code&gt;TextChanged&lt;/code&gt; is installed in the end of you &lt;code&gt;hex#setup()&lt;/code&gt;, the change of &lt;code&gt;b:changedtick&lt;/code&gt; happened before (&lt;code&gt;hex#dump()&lt;/code&gt;) still count. The help only says &lt;code&gt;before the TextChanged autocommand was defined&lt;/code&gt;, but it doesn't say it's starting point, i guess in this case it's the &lt;code&gt;Hex&lt;/code&gt; command, correct me if I'm wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your plugin have redefined the meaning of change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;It's a change if it's hex content is changed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use another changedtick to rule out other changes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:update_hex_changedtick() abort&#xA;  let b:hex_changedtick = b:changedtick&#xA;endfunction&#xA;&#xA;function hex#setup() abort&#xA;&#xA;  setlocal binary&#xA;  call hex#dump()&#xA;  call s:update_hex_changedtick()&#xA;  ...&#xA;endfunction&#xA;&#xA;function hex#write_post() abort&#xA;  ...&#xA;  call s:update_hex_changedtick()&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use it to decide whether hex changed happens:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! hex#changed() abort&#xA;  return b:changedtick &amp;gt; get(b:, 'hex_changedtick', 0)&#xA;endfunction&#xA;&#xA;function hex#update() abort&#xA;  &quot; get changed before b:changetick changed.&#xA;  let changed = hex#changed()&#xA;  ...&#xA;  if !changed&#xA;    set nomodified&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should fix all your problems. My test code doesn't include the &lt;code&gt;ftplugin#undo&lt;/code&gt; part.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-10-24T09:39:33.520" LastActivityDate="2019-10-24T09:39:33.520" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21633" PostTypeId="1" AcceptedAnswerId="21634" CreationDate="2019-10-24T14:08:51.563" Score="5" ViewCount="303" Body="&lt;p&gt;&lt;code&gt;:help change.txt&lt;/code&gt; mentions 2- or 3- letter :substitute commands, such as &lt;code&gt;:sg&lt;/code&gt;, &lt;code&gt;:sgn&lt;/code&gt; and so on. I am guessing that these &lt;code&gt;:s[xx]&lt;/code&gt; correspond to flags, but am not sure how to use them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I would think that &lt;code&gt;:%sg/foo/bar&lt;/code&gt; would substitute all matches of &lt;code&gt;foo&lt;/code&gt;, including multiple occurences on the same line. However, that commands gives me an error --- &quot;trailing characters&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the appropriate syntax for &lt;code&gt;:s[x[x]]&lt;/code&gt;? &lt;/p&gt;&#xA;" OwnerUserId="21495" LastActivityDate="2021-03-04T18:26:12.787" Title="How to use 2- or 3-letter :substitute commands?" Tags="|substitute|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21634" PostTypeId="2" ParentId="21633" CreationDate="2019-10-24T15:28:42.500" Score="8" Body="&lt;p&gt;Actually the behavior of the substitution command &lt;code&gt;:s&lt;/code&gt; if you don't provide any arguments is to repeat the last substitution you did. So if you have a line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo Foo foF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And use &lt;code&gt;:s/f/X/&lt;/code&gt; you will get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Xoo Foo foF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if you use &lt;code&gt;:s&lt;/code&gt; (without any argument) you will reapply the same command and get as a result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Xoo Foo XoF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The 2 and 3 letters substitution commands work the same but adding some flags at the end of the original substitution. So now if you have the previous line and use &lt;code&gt;:sgi&lt;/code&gt; you will get the equivalent of &lt;code&gt;:s/f/X/gi&lt;/code&gt; which will result in &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Xoo Xoo XoX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That explains why you get &lt;code&gt;E488 Trailing characters&lt;/code&gt; the short substitutes commands don't take an argument as they only apply the last &lt;code&gt;:s&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-10-24T15:28:42.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21635" PostTypeId="1" AcceptedAnswerId="21636" CreationDate="2019-10-24T15:31:42.453" Score="3" ViewCount="3944" Body="&lt;p&gt;There are commands to distinguish between the beginning of a line (&lt;code&gt;0&lt;/code&gt;) and the beginning of the first word of the line (&lt;code&gt;^&lt;/code&gt;), basically ignoring leading whitespace.  But I can only find one way to move to the end of a line (&lt;code&gt;$&lt;/code&gt;), including whitespace, much like &lt;code&gt;0&lt;/code&gt;, but no way to move to the end of the last word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an end-of-line equivalent to &lt;code&gt;^&lt;/code&gt;, which ignores trailing whitespace?&lt;/p&gt;&#xA;" OwnerUserId="20748" LastActivityDate="2022-02-05T13:14:49.120" Title="Moving to the end of the last word on a line" Tags="|cursor-movement|whitespace|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21636" PostTypeId="2" ParentId="21635" CreationDate="2019-10-24T15:37:14.933" Score="8" Body="&lt;p&gt;&lt;code&gt;g_&lt;/code&gt; will to go to the last non-blank character of the line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see &lt;code&gt;:h g_&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-10-24T15:37:14.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21637" PostTypeId="2" ParentId="21635" CreationDate="2019-10-24T15:37:33.697" Score="2" Body="&lt;p&gt;Yes, see &lt;code&gt;:h g_&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g_          To the last non-blank character of the line and&#xA;            [count - 1] lines downward |inclusive|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-10-24T15:37:33.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21638" PostTypeId="2" ParentId="21635" CreationDate="2019-10-24T15:48:57.767" Score="4" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;$&lt;/code&gt; or &lt;code&gt;&amp;lt;End&amp;gt;&lt;/code&gt; - goes to end of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g_&lt;/code&gt; - goes to last non blank of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g$&lt;/code&gt; or &lt;code&gt;g&amp;lt;End&amp;gt;&lt;/code&gt; (both take a count) - goes to end of last screen n-1'th line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Ctrl&amp;gt;&amp;lt;End&amp;gt;&lt;/code&gt; (takes a count) - goes to end of absolute n'th line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="17868" LastEditorUserId="71" LastEditDate="2019-10-24T21:22:41.460" LastActivityDate="2019-10-24T21:22:41.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21640" PostTypeId="1" AcceptedAnswerId="21647" CreationDate="2019-10-24T17:11:41.917" Score="0" ViewCount="129" Body="&lt;p&gt;These are the two lines of code responsible for inserting matching characters in my matching plugin&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:cur_split = [s:cur_split[0], s:match[press] . s:cur_split[1]]&#xA;cal setline(&quot;.&quot;, join(s:cur_split, &quot;&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is in a &lt;code&gt;TextChangedI&lt;/code&gt; event&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;press&lt;/code&gt; is the character that was inserted&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s:cur_split&lt;/code&gt; is a length 2 array holding the parts of the line that were before and after the cursor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;s:match&lt;/code&gt; is a dictionary that maps a character to its match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works great, accept when I try to use macros. A macro won't trigger the event and the matching character is not inserted. Is there any simple way around this or is this just not the right way to go about achieving this functionality?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: another related issues that I'll tack on here is that if I type &lt;code&gt;No{&amp;lt;Esc&amp;gt;&lt;/code&gt;, I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;{&#xA;...&#xA;{&#xA;{}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All the other lines don't copy the inserted character.&lt;/p&gt;&#xA;" OwnerUserId="24943" LastActivityDate="2019-10-25T06:29:00.083" Title="Make autocmd fire in a macro" Tags="|vimscript|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21641" PostTypeId="2" ParentId="3327" CreationDate="2019-10-25T00:31:16.247" Score="0" Body="&lt;p&gt;This is what has worked for me&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use the &lt;a href=&quot;https://github.com/igbanam/dotfiles/commit/c9f44018f9fa0ac73dba870e6bfa9018a09fefac&quot; rel=&quot;nofollow noreferrer&quot;&gt;old regex engine for large files&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Don't use relative number, cursor line, and cursor column for large files&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Basically, anything which is dependent on syntax, or is a &quot;nice to have&quot;, try to not do this for large files. &lt;/p&gt;&#xA;" OwnerUserId="20468" LastActivityDate="2019-10-25T00:31:16.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21642" PostTypeId="1" CreationDate="2019-10-25T02:38:56.630" Score="1" ViewCount="238" Body="&lt;p&gt;When I'm using Vim in the terminal, I sometimes get stuff like this:&lt;a href=&quot;https://i.stack.imgur.com/phLev.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/phLev.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The square bracket floating is what I'm talking about. When my autocompleter plugin stops completing, sometimes it &quot;forgets&quot; to delete some text and leaves it lying around (like that square bracket up there.) A Ctrl+L refresh fixes it, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using coc.nvim right now, but this also happened on YouCompleteMe and clang complete, so I'm not sure what to really think about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix this &quot;stuck text&quot;?&lt;/p&gt;&#xA;" OwnerUserId="25372" LastActivityDate="2020-07-29T00:10:20.390" Title="What is the &quot;stuck text&quot; that happens on my screen as a byproduct of a plugin? How can I remove it?" Tags="|autocompletion|plugin-coc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21643" PostTypeId="1" CreationDate="2019-10-25T02:39:23.660" Score="2" ViewCount="291" Body="&lt;p&gt;I have been using vim mode for atom for quite a while,&#xA;recently I've been trying to switch to nvim, but I can't seem to find a way to replicate the &lt;a href=&quot;https://github.com/t9md/atom-vim-mode-plus/wiki/OccurrenceModifier&quot; rel=&quot;nofollow noreferrer&quot;&gt;operator modifiers&lt;/a&gt; behaviour, which I've come to rely on quite frequently.&lt;/p&gt;&#xA;&lt;p&gt;So for example, in the following paragraph:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;hello this is me&#xA;writing to say hello&#xA;to everyone, so hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Let's say that I wanted to change every occurrence of the word &lt;strong&gt;hello&lt;/strong&gt; to the word &lt;strong&gt;hi&lt;/strong&gt;, I could do that by navigating my cursor over any of the occurrences of &lt;strong&gt;hello&lt;/strong&gt; and typing:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;coip&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I can't seem to find a convenient way to replace this behaviour, I'm open to any plugin suggestions as well, but a modifier like &amp;quot;o&amp;quot; seems pretty useful (or perhaps I'm missing a better way to do things).&lt;/p&gt;&#xA;" OwnerUserId="25373" LastEditorUserId="5298" LastEditDate="2021-09-13T16:50:07.983" LastActivityDate="2021-09-13T16:50:07.983" Title="Operator Modifier" Tags="|normal-mode|operator|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21644" PostTypeId="2" ParentId="21633" CreationDate="2019-10-25T03:17:36.243" Score="1" Body="&lt;p&gt;statox has given a complete answer. I tried to find this in the documentation, searching for &lt;code&gt;:h :sg&lt;/code&gt;, &lt;code&gt;:h :sgn&lt;/code&gt;, etc. But that only provided a table of 2-letter and 3-letter substitute commands.&lt;/p&gt;&#xA;&lt;p&gt;It turns out that the behavior in statox's answer is documented much higher up in the help file. To find it, refer to &lt;code&gt;:h :&amp;amp;&lt;/code&gt; or the paragraph after &lt;code&gt;:h :s&lt;/code&gt;. Quoting from the help (emphasis mine):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;:[range]s[ubstitute] [flags] [count]&lt;br /&gt;&#xA;:[range]&amp;amp;[&amp;amp;][flags] [count]&lt;/p&gt;&#xA;&lt;p&gt;Repeat last :substitute with same search pattern and&#xA;substitute string, but without the same flags.  You&#xA;may add [flags], see |:s_flags|.&lt;br /&gt;&#xA;Note that after &lt;code&gt;:substitute&lt;/code&gt; the '&amp;amp;' flag can't be&#xA;used, it's recognized as a pattern separator.&lt;br /&gt;&#xA;&lt;strong&gt;The space between &lt;code&gt;:substitute&lt;/code&gt; and the 'c', 'g',&#xA;'i', 'I' and 'r' flags isn't required, but in scripts&#xA;it's a good idea to keep it to avoid confusion.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="21495" LastEditorUserId="21495" LastEditDate="2021-03-04T18:26:12.787" LastActivityDate="2021-03-04T18:26:12.787" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21647" PostTypeId="2" ParentId="21640" CreationDate="2019-10-25T06:29:00.083" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://vimhelp.appspot.com/autocmd.txt.html#TextChanged&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help TextChanged&lt;/code&gt;&lt;/a&gt; has this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Not triggered when there is typeahead or when&#xA;    an operator is pending.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Typeahead&lt;/em&gt; means the input buffer has keys about to be executed. A mapping (e.g. &lt;code&gt;:nmap &amp;lt;F12&amp;gt; aTEXT&amp;lt;Esc&amp;gt;&lt;/code&gt;) fills it (and therefore, no &lt;code&gt;TextChangedI&lt;/code&gt; events are fired for the &lt;code&gt;TEXT&lt;/code&gt; here, neither), and macro playback is treated the same way as execution of a mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that there are good implementation reasons for this behavior. Unfortunately, this means that using &lt;code&gt;TextChangedI&lt;/code&gt; for your use case of inserting matching characters is fundamentally flawed. In order to support mappings and macros, you'd have to directly hook the matching characters (&lt;code&gt;:imap &amp;lt;expr&amp;gt; ) ...&lt;/code&gt;, &lt;code&gt;:imap &amp;lt;expr&amp;gt; ] ...&lt;/code&gt;, ...)&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-10-25T06:29:00.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21648" PostTypeId="2" ParentId="21643" CreationDate="2019-10-25T06:47:49.590" Score="3" Body="&lt;p&gt;That is indeed a novel and potentially time-saving feature!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way to do this in plain Vim would be using &lt;code&gt;:substitute&lt;/code&gt; for a range; the pattern can be easily set via &lt;code&gt;*&lt;/code&gt; when the cursor is on top of it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*vip:s//hi/g&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A mapping for the &lt;code&gt;:s///g&lt;/code&gt; part that puts the cursor right into the replacement part can save many keystrokes here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to support arbitrary text objects (&lt;code&gt;ip&lt;/code&gt; covers entire lines, which plays well with the &lt;code&gt;:{range}&lt;/code&gt;, but objects like &lt;code&gt;is&lt;/code&gt; don't), the &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1195&quot; rel=&quot;nofollow noreferrer&quot;&gt;vis.vim&lt;/a&gt; plugin can help.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Plugin alternatives&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I'm not aware of any plugin that implements this for Vim; however, my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4321&quot; rel=&quot;nofollow noreferrer&quot;&gt;ChangeGlobally plugin&lt;/a&gt; offers something similar: Instead of having a fixed text (the &lt;em&gt;cword&lt;/em&gt; with the operator modifier) applied over the specified &lt;code&gt;{motion}&lt;/code&gt;, it applies the change or delete of a specified &lt;code&gt;{motion}&lt;/code&gt; over a fixed range. I think the implementation could also support the other use case; I might add that to it ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I've added similar mappings to my plugin. Instead of the &lt;code&gt;o&lt;/code&gt; operator modifier, I went with the plugin's existing mapping scheme. (Also, the plugin only handles changes and deletions, and cannot be applied to other actions like &lt;code&gt;gU&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are the new mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[N][&quot;x]gc*{motion}      Delete the current whole \&amp;lt;word\&amp;gt; [into register x]&#xA;                        and start inserting. After exiting insert mode, that&#xA;                        text substitution is applied to all / the first [N]&#xA;                        occurrences inside {motion} text.&#xA;&#xA;[N][&quot;x]gx*{motion}      Delete the current whole \&amp;lt;word\&amp;gt; [into register x]&#xA;                        and apply the deletion to all / the first [N]&#xA;                        occurrences inside {motion} text.&#xA;&#xA;[N][&quot;x]gcg*{motion}     Delete the current word [into register x] and&#xA;                        start inserting. After exiting insert mode, that text&#xA;                        substitution is applied to all / the first [N]&#xA;                        occurrences inside {motion} text.&#xA;&#xA;[N][&quot;x]gxg*{motion}     Delete the current word [into register x] and&#xA;                        apply the deletion to all / the first [N] occurrences&#xA;                        inside {motion} text.&#xA;&#xA;[N][&quot;x]gc_ALT-8{motion} Delete the current whole \_sWORD\_s [into register x]&#xA;                        and ALT-8t inserting. After exiting insert mode, that&#xA;                        text substitution is applied to all / the first [N]&#xA;                        occurrences inside {motion} text.&#xA;&#xA;[N][&quot;x]gx_ALT-8{motion} Delete the current whole \_sWORD\_s [into register x]&#xA;                        and apply the deletion to all / the first [N]&#xA;                        occurrences inside {motion} text.&#xA;&#xA;[N][&quot;x]gcg_ALT-8{motion}Delete the current WORD [into register x] and&#xA;                        ALT-8t inserting. After exiting insert mode, that text&#xA;                        substitution is applied to all / the first [N]&#xA;                        occurrences inside {motion} text.&#xA;&#xA;[N][&quot;x]gxg_ALT-8{motion}Delete the current WORD [into register x] and&#xA;                        apply the deletion to all / the first [N] occurrences&#xA;                        inside {motion} text.&#xA;&#xA;[N][&quot;x]&amp;lt;Leader&amp;gt;gc{source-motion}{target-motion}&#xA;                        Delete {source-motion} text [into register x] and&#xA;                        start inserting. After exiting insert mode, that text&#xA;                        substitution is applied to all / the first [N]&#xA;                        occurrences inside {target-motion} text.&#xA;{Visual}[N][&quot;x]&amp;lt;Leader&amp;gt;gc{motion}&#xA;                        Delete the selected text [into register x] and start&#xA;                        inserting. After exiting insert mode, that text&#xA;                        substitution is applied to all / the first [N]&#xA;                        occurrences inside {motion} text.&#xA;&#xA;[N][&quot;x]&amp;lt;Leader&amp;gt;gx{source-motion}{target-motion}&#xA;                        Delete the {source-motion} text [into register x] and&#xA;                        apply the deletion to all / the first [N] occurrences&#xA;                        inside {target-motion} text.&#xA;{Visual}[N][&quot;x]&amp;lt;Leader&amp;gt;gx{motion}&#xA;                        Delete the selected text [into register x] and apply&#xA;                        the deletion to all / the first [N] occurrences inside&#xA;                        {motion} text.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2019-10-29T16:56:24.070" LastActivityDate="2019-10-29T16:56:24.070" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="21650" PostTypeId="1" AcceptedAnswerId="21651" CreationDate="2019-10-25T08:33:16.180" Score="1" ViewCount="187" Body="&lt;p&gt;Is there a way to trigger a certain short mapping i.e. &lt;code&gt;\c&lt;/code&gt; without waiting to see if there is a longer one that starts with the same characters (effectively disabling all other overlapping mappings)? &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="343" LastEditDate="2019-10-25T16:21:37.390" LastActivityDate="2019-10-25T16:21:37.390" Title="Override longer mappings" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21651" PostTypeId="2" ParentId="21650" CreationDate="2019-10-25T09:02:09.873" Score="5" Body="&lt;p&gt;Yes, you can use the &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; modifier. See here, copied from the documentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *:map-&amp;lt;nowait&amp;gt;* *:map-nowait*&#xA;When defining a buffer-local mapping for &quot;,&quot; there may be a global mapping&#xA;that starts with &quot;,&quot;.  Then you need to type another character for Vim to know&#xA;whether to use the &quot;,&quot; mapping or the longer one.  To avoid this add the&#xA;&amp;lt;nowait&amp;gt; argument.  Then the mapping will be used when it matches, Vim does&#xA;not wait for more characters to be typed.  However, if the characters were&#xA;already typed they are used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: this is not limited to buffer-local mappings, but it might effectively disable all the longer mappings, so use with care.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-10-25T09:02:09.873" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21653" PostTypeId="2" ParentId="18433" CreationDate="2019-10-25T13:07:12.407" Score="12" Body="&lt;p&gt;&lt;code&gt;make clean distclean&lt;/code&gt;&#xA;before running the &lt;code&gt;configure&lt;/code&gt; command for vim. This worked for me. There was lots of cached items hanging around from before that were interfering with vim &lt;code&gt;configure&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="25384" LastActivityDate="2019-10-25T13:07:12.407" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21654" PostTypeId="1" AcceptedAnswerId="21666" CreationDate="2019-10-25T16:35:39.253" Score="0" ViewCount="131" Body="&lt;p&gt;When open multiple tabs, it will show in the topmost line something &lt;code&gt;/c/e/n...&lt;/code&gt; alike.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I already has filename and &lt;code&gt;&amp;amp;modified&lt;/code&gt; in status line, which just waste space then.&#xA;Also I find that line quite distracting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there any way hide non active tabs completely?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2019-10-26T06:54:01.167" Title="vim: can non active tab being completely hidden, no headers show /c/e/n alike" Tags="|tabbed-user-interface|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21655" PostTypeId="1" CreationDate="2019-10-25T16:38:03.350" Score="1" ViewCount="676" Body="&lt;p&gt;From my &lt;code&gt;init.vim&lt;/code&gt; (I've checked that it doesn't work even with a minimal configuration):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin()&#xA;Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }&#xA;Plug 'dense-analysis/ale'&#xA;Plug 'lervag/vimtex'&#xA;call plug#end()&#xA;&#xA;let g:deoplete#enable_at_startup = 1&#xA;let g:ale_cpp_ccls_init_options = {&#xA;\   'cache': {&#xA;\       'directory': '/tmp/ccls/cache'&#xA;\   }&#xA;\ }&#xA;&#xA;call deoplete#custom#var('omni', 'input_patterns', {&#xA;      \ 'tex': g:vimtex#re#deoplete&#xA;\})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open a &lt;code&gt;.cpp&lt;/code&gt; file, sign column shows up and error/warning messages are displayed as expected. However, there are no language-specific autocompletion suggestions (i.e. the ones that should be provided by ALE/ccls; there are only snippets and basic suggestions like variable names).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything works fine with &lt;code&gt;.tex&lt;/code&gt; files. It also works if I use LanguageClient-neovim (also with &lt;code&gt;ccls&lt;/code&gt;) instead of ALE.&lt;/p&gt;&#xA;" OwnerUserId="25388" LastEditorUserId="25388" LastEditDate="2019-10-25T18:09:48.067" LastActivityDate="2019-10-25T18:09:48.067" Title="Autocompletion doesn't work when using ALE + deoplete" Tags="|neovim|autocompletion|filetype-c++|plugin-ale|plugin-deoplete|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21656" PostTypeId="1" AcceptedAnswerId="21659" CreationDate="2019-10-25T20:33:39.953" Score="2" ViewCount="93" Body="&lt;p&gt;I'm trying to create a zsh alias that will start vim and search backwards from the end of the file for a given string. I learnt about &lt;code&gt;+normal&lt;/code&gt; and can do something like this to start vim at the end of the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim &quot;+normal G&quot; log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'm not able to follow that by an incremental search. The following &lt;em&gt;does&lt;/em&gt; work (with a literal CR) from the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim &quot;+normal G?TEST^M&quot; log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I can't get this to work with an alias, probably because of the literal carriage return.&lt;/p&gt;&#xA;" OwnerUserId="25391" LastActivityDate="2019-10-26T06:29:44.910" Title="Incremental search for text from the command line" Tags="|startup|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21658" PostTypeId="2" ParentId="21550" CreationDate="2019-10-25T21:01:30.477" Score="1" Body="&lt;p&gt;Finger rolling describes typing keys such that successive keys are typed moving towards the center of the keyboard (inward rolling) or edges of the keyboard (outward rolling). Said another way, going from your pinky to your index finger, or the reverse. It's like drumming your fingers (see picture). On a Qwerty keyboard &quot;asdf&quot; and &quot;awe&quot; are examples of inward rolling, and &quot;jkl;&quot; and &quot;few&quot; of outward rolling. As it involves multiple fingers you wouldn't say &quot;rolling one's finger&quot; but &quot;rolling one's finger&lt;strong&gt;s&lt;/strong&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://www.cinemacats.com/wp-content/uploads/gifs/finncattyfingers.gif&quot; alt=&quot;Finger Rolling Cat&quot; title=&quot;finger roll&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The term &quot;finger rolling&quot; is very common in &lt;a href=&quot;https://en.wikipedia.org/wiki/Keyboard_layout&quot; rel=&quot;nofollow noreferrer&quot;&gt;keyboard layout&lt;/a&gt; communities. Particularly those focused on &lt;a href=&quot;https://en.wikipedia.org/wiki/Keyboard_layout#Functional_layouts&quot; rel=&quot;nofollow noreferrer&quot;&gt;functional layouts&lt;/a&gt;. That is, choosing where each letter or symbol is located on the keyboard. Qwerty, Dvorak, and Colemak are examples of different functional layouts. Finger rolling is considered to be a quick and comfortable motion for typing. Many layouts prioritize common letter sequences, like t-h-e, so that they can be typed with a finger roll.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think the term is ubiquitous in the Vim community. But there is a lot of overlap between the keyboard layout and Vim community as both are concerned with efficient keyboarding. It is really just a typing term, and appropriate to discussing whether &quot;jk&quot; or &quot;kj&quot; is a more natural, comfortable, or quick to type remap for escape.&lt;/p&gt;&#xA;" OwnerUserId="7222" LastActivityDate="2019-10-25T21:01:30.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21659" PostTypeId="2" ParentId="21656" CreationDate="2019-10-25T21:02:33.697" Score="2" Body="&lt;p&gt;I would recommend breaking this up into multiple commands. This works for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim log -c &quot;normal G&quot; -c &quot;?TEST&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't need a carriage return since &lt;code&gt;&quot;?test&quot;&lt;/code&gt; is treated as an ex command, not a normal mode command.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-10-25T21:02:33.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21660" PostTypeId="1" AcceptedAnswerId="21667" CreationDate="2019-10-25T23:14:42.280" Score="1" ViewCount="96" Body="&lt;p&gt;While playing with &lt;code&gt;map()&lt;/code&gt; I get an error, which I cannot understand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In essense,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pu=map(getcompletion('*','event'), '&quot;h&quot; . v:val')&#xA;pu=map(getcompletion('*','event'), &quot;'h' . v:val&quot;)&#xA;pu=map(getcompletion('*','event'), {i,v -&amp;gt; &quot;h&quot; . v})&#xA;pu=map(getcompletion('*','event'), {i,v -&amp;gt; 'h' . v})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;only last one works, all other raise error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it should all work, or it's just not correctly written?&lt;/p&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="10254" LastEditDate="2019-10-26T02:21:08.420" LastActivityDate="2019-10-26T13:28:14.843" Title="vim expression unusual behavior" Tags="|vimscript|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21661" PostTypeId="1" CreationDate="2019-10-25T23:48:58.873" Score="0" ViewCount="3068" Body="&lt;p&gt;Hi I am seeing the following on my .tex files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bvv9O.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bvv9O.png&quot; alt=&quot;Notice the light blue boxes.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .vimrc file looks like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader =&quot; &quot;&#xA;&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'lervag/vimtex'&#xA;let g:tex_flavor='latex'&#xA;let g:vimtex_view_method='zathura'&#xA;let g:vimtex_quickfix_mode=0&#xA;set conceallevel=1&#xA;let g:tex_conceal='abdmg'&#xA;&#xA;Plug 'SirVer/Ultisnips'&#xA;let g:UltiSnipsExpandTrigger = '&amp;lt;tab&amp;gt;'&#xA;let g:UltiSnipsJumpForwardTrigger = '&amp;lt;tab&amp;gt;'&#xA;let g:UltiSnipsJumpBackwardTrigger = '&amp;lt;s-tab&amp;gt;'&#xA;Plug 'junegunn/goyo.vim'&#xA;call plug#end()&#xA;&#xA;set nocompatible&#xA;filetype plugin on&#xA;set encoding=utf-8&#xA;set number relativenumber&#xA;&#xA;set wildmode=longest,list,full&#xA;&#xA;autocmd fileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o&#xA;&#xA;map &amp;lt;leader&amp;gt;f :Goyo \| set linebreak&amp;lt;CR&amp;gt;&#xA;&#xA;map &amp;lt;leader&amp;gt;o :setlocal spell! spelllang=en_uk&amp;lt;CR&amp;gt;&#xA;&#xA;set splitbelow splitright&#xA;&#xA;map &amp;lt;C-h&amp;gt; &amp;lt;C-w&amp;gt;h&#xA;map &amp;lt;C-j&amp;gt; &amp;lt;C-w&amp;gt;j&#xA;map &amp;lt;C-k&amp;gt; &amp;lt;C-w&amp;gt;k&#xA;map &amp;lt;C-l&amp;gt; &amp;lt;C-w&amp;gt;l&#xA;&#xA;autocmd VimLeave *.tex !texclear % &#xA;&#xA;map &amp;lt;C-v&amp;gt; &quot;+P`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am also using pywal so maybe there is an incompatibility with that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help&lt;/p&gt;&#xA;" OwnerUserId="25393" LastEditorUserId="71" LastEditDate="2019-10-26T07:17:36.203" LastActivityDate="2019-12-19T10:01:05.073" Title="Vimtex conceal not working properly" Tags="|conceal|syntax|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21663" PostTypeId="1" AcceptedAnswerId="21664" CreationDate="2019-10-26T00:53:37.993" Score="3" ViewCount="463" Body="&lt;p&gt;I have the following text in my &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;colorscheme koehler&#xA;highlight ErrorMsg ctermbg=Red ctermfg=Black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however the error messages show like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hm3qo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hm3qo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error message is gray on red, not black on red. How can I get it to display as black?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know it is reading the commands in my &lt;code&gt;.vimrc&lt;/code&gt; because I can change the text color to other colors, it's just that black doesn't show correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using iTerm2.&lt;/p&gt;&#xA;" OwnerUserId="25223" LastEditorUserId="25223" LastEditDate="2019-10-26T13:20:09.157" LastActivityDate="2019-10-26T13:20:09.157" Title="Vim color black isn't black" Tags="|colorscheme|color|iterm2|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21664" PostTypeId="2" ParentId="21663" CreationDate="2019-10-26T05:14:28.773" Score="2" Body="&lt;p&gt;You should also include:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight ErrorMsg cterm=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;cterm&lt;/code&gt; attributes often interact with the color settings and can end up having Vim picking a &quot;bright&quot; shade of the color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;koehler&quot; theme ships with &lt;code&gt;cterm=bold&lt;/code&gt;, which has this effect of using a bright color on many terminals, including iTerm2 (with default settings.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can inspect your settings by querying them, with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight ErrorMsg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I expect you'll see that &lt;code&gt;cterm=bold&lt;/code&gt; is included there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to remove that, simply set it to &lt;code&gt;NONE&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do all these settings from a single command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight ErrorMsg ctermbg=Red ctermfb=Black cterm=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-10-26T05:14:28.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21665" PostTypeId="2" ParentId="21656" CreationDate="2019-10-26T06:24:25.950" Score="1" Body="&lt;p&gt;You don't need &quot;normal&quot; at all, as Ex-&quot;?&quot; takes an address.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim log '+$?TEST'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;because of the literal carriage return&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When you really want a carriage return, you can use &quot;execute&quot;. The following is much longer but also works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim log '+exe &quot;normal! G?TEST\&amp;lt;CR&amp;gt;&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-10-26T06:29:44.910" LastActivityDate="2019-10-26T06:29:44.910" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21666" PostTypeId="2" ParentId="21654" CreationDate="2019-10-26T06:54:01.167" Score="1" Body="&lt;p&gt;Just like &lt;code&gt;:h 'laststatus'&lt;/code&gt;, you can customize when you want your &lt;code&gt;:h 'tabline'&lt;/code&gt; to show.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;code&gt;:h 'showtabline'&lt;/code&gt;, you can set the value of the variable &lt;em&gt;showtabline&lt;/em&gt; to any of the following numbers with associated significance following those numbers below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    The value of this option specifies when the line with tab page labels&#xA;    will be displayed:&#xA;        0: never&#xA;        1: only if there are at least two tab pages&#xA;        2: always&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, in your case, you will need to set the variable &lt;em&gt;showtabline&lt;/em&gt; to zero in order for it to be never shown. You can do that in either of the following manners.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set showtabline=0&#xA;:let &amp;amp;showtabline=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastActivityDate="2019-10-26T06:54:01.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21667" PostTypeId="2" ParentId="21660" CreationDate="2019-10-26T07:20:57.220" Score="3" Body="&lt;p&gt;What you are seeing here, is essentially the same problem, as why many people struggle with using variables on the command line with the ex commands. See e.g. &lt;a href=&quot;https://vi.stackexchange.com/questions/2139&quot;&gt;this question&lt;/a&gt;, there are a lot similar ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, Vims ex commandline commands expect their arguments to be literal, they cannot contain expressions (like variables or strings). Those commands do handle &lt;code&gt;%&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; (and a few others that I do not remember currently) special by replacing the former with the current filename and the latter by the alternate file name. At the same time, &lt;code&gt;&quot;&lt;/code&gt; is used to donate the start of a comment, everything after it will be ignored (not even seen by the command). The usage of &lt;code&gt;&quot;&lt;/code&gt; as a comment character goes back all the way to the original vi and therefore cannot be changed because this would introduce an incompatibility to the classic vi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few commands, that were not available in the original vi implementation, however are able to handle &lt;em&gt;expressions&lt;/em&gt;. The help usually mentions whenever a command expects an expression instead of a (literal) argument. The most notable ex commands that do that are &lt;code&gt;:exe&lt;/code&gt;, &lt;code&gt;:echo&lt;/code&gt;, &lt;code&gt;:echomsg&lt;/code&gt; and similar ex commands. That's why one has to use &lt;code&gt;:exe&lt;/code&gt; to dynamically build ex commands (see e.g. &lt;a href=&quot;https://vi.stackexchange.com/a/21393/71&quot;&gt;this answer&lt;/a&gt; for a great explanation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those expressions can contain variables and strings, either single quoted or double quoted and therefore the &lt;code&gt;&quot;&lt;/code&gt; is not detected as the start of a comment there. However, &lt;code&gt;:put&lt;/code&gt; is one of the old ex commands that was available already in old original vi. However adding the possibility to put an arbitrary expression using the expression register &lt;code&gt;=&lt;/code&gt; has been added for Vim only. So while you can use any expression when using &lt;code&gt;:put=&lt;/code&gt;, Vim will still parse the arguments for the &lt;code&gt;:put&lt;/code&gt; comments and see &lt;code&gt;&quot;&lt;/code&gt; as a start of a comment and not as start of a string. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is an implementation detail, that can still be seen today. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the error message would have given you a hint:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Jk5xm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Jk5xm.png&quot; alt=&quot;error message after executing above command&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That was me executing your 3rd example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pu=map(getcompletion('*','event'), {i,v -&amp;gt; &quot;h&quot; . v})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See how the echoed command stops after the &lt;code&gt;-&amp;gt;&lt;/code&gt; and does not contain anything after the comment? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why you have to escape the &lt;code&gt;&quot;&lt;/code&gt; using e.g. &lt;code&gt;\&quot;&lt;/code&gt; on the command line for the &lt;code&gt;:put&lt;/code&gt; command. So try to use this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:pu =map(getcompletion('*','event'), {i,v -&amp;gt; \&quot;h\&quot; . v})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-10-26T13:28:14.843" LastActivityDate="2019-10-26T13:28:14.843" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21668" PostTypeId="1" AcceptedAnswerId="21669" CreationDate="2019-10-26T07:57:40.393" Score="1" ViewCount="5257" Body="&lt;p&gt;I'm trying to install &lt;a href=&quot;https://github.com/rakr/vim-one&quot; rel=&quot;nofollow noreferrer&quot;&gt;this colorscheme&lt;/a&gt;. They instructed to use a package manager so I've used vim-plugged:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'rakr/vim-one'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While my colours on vim did change, it really does not look like the &lt;a href=&quot;https://github.com/rakr/vim-one/blob/master/screenshots/new-logo.png?raw=true&quot; rel=&quot;nofollow noreferrer&quot;&gt;colorscheme screenshot&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me just mention that I'm a noob to vim and I tweaked it a lot recently, in order to understand this environment. Among other things I did, I also installed the amix config, but removed it. I tried to undo all my configurations, I don't know if I've completely succeeded in doing so. I wanted to uninstall vim so I could fresh start, but did not find on Google how to properly uninstall vim, so I brew reinstalled it. I still don't think it reseted everything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm on iTerm 2 on a Mac OS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/69Ix5.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;My .vimrc&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="25181" LastEditorUserId="18609" LastEditDate="2019-10-26T08:49:46.417" LastActivityDate="2019-10-26T09:13:47.067" Title="Why can't I install this colorscheme properly?" Tags="|vimrc|terminal|colorscheme|iterm2|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21669" PostTypeId="2" ParentId="21668" CreationDate="2019-10-26T09:13:47.067" Score="1" Body="&lt;p&gt;In short, include this line in your Vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set termguicolors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The theme's README file indicates you need that to &lt;a href=&quot;https://github.com/rakr/vim-one/blob/master/README.md#true-color-support&quot; rel=&quot;nofollow noreferrer&quot;&gt;enable &quot;true color&quot; support&lt;/a&gt;. (The snippet over there is a bit more complicated, to also cope with early NeoVim releases and to check that the option is available in your Vim, you can probably skip that and just set it directly.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also mentions the theme is able to gracefully downgrade if True Color support is not enabled/available, in which case the final result will likely depend on quite a few other settings of your terminal, such as whether you're using a 256-color enabled &lt;code&gt;$TERM&lt;/code&gt; and, if not, what the 16-color pallete is in use on your terminal. (Unfortunately, this gets pretty complex very quickly.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;True Colors means using 24-bit values for RGB colors (one 8-bit byte per component), which needs to be supported by your terminal. You can read more starting at &lt;a href=&quot;https://vimhelp.org/term.txt.html#xterm-true-color&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help xterm-true-color&lt;/code&gt;&lt;/a&gt; but, again, it tends to go into the complex details of Terminal implementations, so maybe it won't help you too much there either.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-10-26T09:13:47.067" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21670" PostTypeId="1" CreationDate="2019-10-26T09:18:29.167" Score="2" ViewCount="786" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/rakr/vim-one&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; colorscheme, how can I change the color of the line numbers? I think that the colorscheme will overwrite anything I'll put in .vmrc.&lt;/p&gt;&#xA;" OwnerUserId="25181" LastActivityDate="2019-10-26T10:19:49.083" Title="I'm using a colorscheme installed with vim-plug, how can I change the color of the line numbers?" Tags="|vimrc|colorscheme|" AnswerCount="1" CommentCount="0" ClosedDate="2020-04-26T18:37:55.543" ContentLicense="CC BY-SA 4.0" />
  <row Id="21671" PostTypeId="1" CreationDate="2019-10-26T10:05:42.177" Score="3" ViewCount="137" Body="&lt;p&gt;That is, doing autocompletition with C-n, is there a way to obtain the list of possible matches, same as returned into the popup menu ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the example below&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1dW0H.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1dW0H.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is it possible to retrieve {aaa, aaab, ababa} from a vim inner list ?&#xA;In other words, where these matches are stored ?&lt;/p&gt;&#xA;" OwnerUserId="15254" LastEditorUserId="10604" LastEditDate="2019-11-02T14:39:44.930" LastActivityDate="2019-11-02T14:39:44.930" Title="How to print a list of possible matches from C-n?" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21672" PostTypeId="2" ParentId="21670" CreationDate="2019-10-26T10:19:49.083" Score="2" Body="&lt;p&gt;You have a few options to accomplish that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually changing the highlight rules after setting the colorscheme in your Vimrc is not a completely unreasonable approach, since the colorscheme is usually only reloaded if you set the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27background%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;background&lt;/a&gt;, so if you tend not to switch from &quot;light&quot; to &quot;dark&quot; or vice-versa, you might be fine...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are better approaches though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As recommended in &lt;a href=&quot;https://vimhelp.org/syntax.txt.html#%3Acolorscheme&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :colorscheme&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To customize a color scheme use another name, e.g.&#xA;    &lt;code&gt;~/.vim/colors/mine.vim&lt;/code&gt;, and use&#xA;  &lt;code&gt;:runtime&lt;/code&gt; to load the original color scheme:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime colors/evening.vim&#xA;hi Statement ctermfg=Blue guifg=Blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It fails to mention you should also set &lt;a href=&quot;https://vimhelp.org/options.txt.html#g%3Acolors_name&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g:colors_name&lt;/code&gt;&lt;/a&gt;, which is what is used to reload the theme after you change the background, so make sure you include this line there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:colors_name = 'mine'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Except instead of &quot;mine&quot; use the name you used for the colorscheme, the name you used for the &lt;code&gt;colors/*.vim&lt;/code&gt; file you created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to use an &lt;code&gt;:autocmd&lt;/code&gt;, using the &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#ColorScheme&quot; rel=&quot;nofollow noreferrer&quot;&gt;ColorScheme&lt;/a&gt; event to load additional highlights right after a colorscheme is loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simplistic example would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup colorscheme_override&#xA;  autocmd!&#xA;  autocmd ColorScheme one highlight LineNr ctermfg=Blue guifg=Blue&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will only override the &quot;one&quot; colorscheme (use a &lt;code&gt;*&lt;/code&gt; for the match to override any colorscheme.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One advantage of the &lt;code&gt;autocmd&lt;/code&gt; approach is that you don't need a new colorscheme name (but then one disadvantage is that it's harder to pick the unmodified colorscheme.) You don't need to touch &lt;code&gt;g:colors_name&lt;/code&gt; in the &lt;code&gt;autocmd&lt;/code&gt; approach, since the original theme will have taken care of that for you already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The approaches above are a bit naive in that they're setting colors regardless of whether the background is light or dark. Typically you would want to check for that to decide on it. Use a block similar to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;background ==# 'light'&#xA;  highlight LineNr ctermfg=DarkBlue guifg=DarkBlue&#xA;else&#xA;  highlight LineNr ctermfg=LightBlue guifg=LightBlue&#xA; endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If using a ColorScheme &lt;code&gt;autocmd&lt;/code&gt;, you probably want to call a function from the &lt;code&gt;autocmd&lt;/code&gt; and then add all your extra logic there for the overrides, including the blocks for light and dark backgrounds.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-10-26T10:19:49.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21673" PostTypeId="2" ParentId="19748" CreationDate="2019-10-26T12:14:24.267" Score="1" Body="&lt;p&gt;Not that it answers the question about the root cause but I found a better way (IMO) to reset the cursor on startup. The main problem is that vim only sends the &quot;t_EI&quot; escape sequence when is exiting either Insert mode or Replace mode (see :help termcap-cursor-shape) and since vim starts on Normal mode &quot;t_EI&quot; is not sent. An obvious solution to this is to enter and exit Insert mode on startup. This is one way to do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Reset cursor on startup&#xA;augroup ResetCursorShape&#xA;au!&#xA;autocmd VimEnter * :normal :startinsert :stopinsert &#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I prefer this way over the code you referenced because even when I add the &lt;code&gt;autocmd VimEnter * redraw!&lt;/code&gt; autocommand I still see the string in the command line for a split second and it is very annoying.&lt;/p&gt;&#xA;" OwnerUserId="25399" LastActivityDate="2019-10-26T12:14:24.267" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21674" PostTypeId="1" CreationDate="2019-10-26T13:18:49.717" Score="3" ViewCount="89" Body="&lt;p&gt;Is there a good reason why &lt;code&gt;gJip&lt;/code&gt; doesn't turn a paragraph into a line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, how could I make it work that way?&lt;/p&gt;&#xA;" OwnerUserId="4505" LastEditorUserId="4505" LastEditDate="2019-10-26T13:47:57.253" LastActivityDate="2019-10-27T10:12:12.333" Title="Why doesn't gJip turn a paragraph into a line?" Tags="|object-motions|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21675" PostTypeId="1" AcceptedAnswerId="21677" CreationDate="2019-10-26T14:22:55.560" Score="0" ViewCount="125" Body="&lt;p&gt;While there is &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;down&amp;gt;&lt;/code&gt; that tries to complete the line, sometimes one wants to recall all the commands that start with what was typed, on a (wild)menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible somehow? &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-10-26T18:30:55.793" Title="Wildmenu for command line history" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21676" PostTypeId="2" ParentId="21671" CreationDate="2019-10-26T14:33:35.813" Score="4" Body="&lt;p&gt;If your Vim binary includes the patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.1068&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.1068&lt;/a&gt;, you can use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#complete_info()&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;complete_info()&lt;/code&gt;&lt;/a&gt;. To get the list of all matches, while the pum is visible, you could use it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map(get(complete_info(['items']), 'items', {}), {_,v -&amp;gt; v.word})&#xA;        ^^^^^^^^^^^^^^^^^^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If your Vim binary also includes &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.1803&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.1803&lt;/a&gt;, you can rewrite the expression in a more readable way, using the method call operator:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;complete_info(['items'])-&amp;gt;get('items', {})-&amp;gt;map({_,v -&amp;gt; v.word})&#xA;                        ^^                ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As an example, this installs a &lt;code&gt;C-x C-x&lt;/code&gt; mapping which – when pressed while the pum is visible – will assign the list of completion matches to the variable &lt;code&gt;g:matches&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ino &amp;lt;silent&amp;gt; &amp;lt;c-x&amp;gt;&amp;lt;c-x&amp;gt; &amp;lt;c-r&amp;gt;=&amp;lt;sid&amp;gt;get_list_of_matches()&amp;lt;cr&amp;gt;&#xA;fu s:get_list_of_matches() abort&#xA;    if ! pumvisible() | return '' | endif&#xA;    let g:matches = complete_info(['items'])-&amp;gt;get('items', {})-&amp;gt;map({_,v -&amp;gt; v.word})&#xA;    return ''&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Instead of assigning the variable manually (via a mapping), you can also assign it automatically, by installing an autocmd listening to the &lt;code&gt;CompleteChanged&lt;/code&gt; event, provided your Vim binary includes &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.1138&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.1138&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup get_list_of_matches&#xA;    au!&#xA;    au CompleteChanged * let g:matches = complete_info(['items'])-&amp;gt;get('items', {})-&amp;gt;map({_,v -&amp;gt; v.word})&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more info, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h complete_info(&#xA;:h CompleteChanged&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-10-26T16:19:37.857" LastActivityDate="2019-10-26T16:19:37.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21677" PostTypeId="2" ParentId="21675" CreationDate="2019-10-26T18:23:45.857" Score="0" Body="&lt;p&gt;I was able to use FZF to complete the command by using the command history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I had to get out of the command line to do so, but it still fairly comfortable. I could edit the command afterwards if I want to. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetCommands()&#xA;    let lines=[]&#xA;    let nu=histnr(&quot;cmd&quot;)&#xA;    for i in range(1,nu)&#xA;        let lines+=[histget(&quot;cmd&quot;,i)]&#xA;    endfor&#xA;    return lines&#xA;endfunction&#xA;&#xA;function! HandleCommand(item)&#xA;    call feedkeys(&quot;q:&quot;)&#xA;    call feedkeys(&quot;G?\\V&quot;.escape(a:item,'\/?').&quot;\&amp;lt;CR&amp;gt;&quot;)&#xA;endfunction&#xA;&#xA;function! CompleteCommand(arg)&#xA;call fzf#run({'source': GetCommands(),'sink': function('HandleCommand'),'options': '-m --query &quot;'.a:arg.'&quot;'} ) &#xA;endfunction &#xA;&#xA;&#xA;:cmap &amp;lt;expr&amp;gt; &amp;lt;c-a&amp;gt; &amp;amp;cedit.'^&quot;xy$'.&quot;&amp;lt;esc&amp;gt;&amp;lt;esc&amp;gt;:call CompleteCommand(@x)&amp;lt;CR&amp;gt;&quot;&#xA;&#xA;:autocmd CmdwinEnter * map &amp;lt;buffer&amp;gt; &amp;lt;ESC&amp;gt; &amp;lt;C-c&amp;gt;&amp;lt;C-c&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-10-26T18:30:55.793" LastActivityDate="2019-10-26T18:30:55.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21678" PostTypeId="2" ParentId="21674" CreationDate="2019-10-27T10:05:03.993" Score="5" Body="&lt;p&gt;The answer is simple: &lt;code&gt;gJip&lt;/code&gt; doesn't work, because &lt;code&gt;gJ&lt;/code&gt; is not an operator. See &lt;a href=&quot;https://vimhelp.org/motion.txt.html#operator&quot; rel=&quot;noreferrer&quot;&gt;:h operator&lt;/a&gt; for which operators exist. The easy workaround is to use visual mode, and then join all the lines, e.g. use &lt;code&gt;vipgJ&lt;/code&gt;, because in visual mode &lt;code&gt;gJ&lt;/code&gt; will join all those selected lines (see &lt;a href=&quot;https://vimhelp.org/change.txt.html#v_gJ&quot; rel=&quot;noreferrer&quot;&gt;:h v_gJ&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to know the reason, why &lt;code&gt;gJ&lt;/code&gt; and also &lt;code&gt;J&lt;/code&gt; has not been implemented as an operator, you have to ask Bill Joy (for &lt;code&gt;J&lt;/code&gt; in original vi) and Bram Moolenaar (for &lt;code&gt;gJ&lt;/code&gt; only available in Vim). My guess is, that using e.g. a motion for the join operation does not always make sense, e.g. the command &lt;code&gt;Jw&lt;/code&gt; is non-sense.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2019-10-27T10:12:12.333" LastActivityDate="2019-10-27T10:12:12.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21681" PostTypeId="2" ParentId="245" CreationDate="2019-10-27T14:11:23.173" Score="0" Body="&lt;p&gt;I had the same need, because I run &lt;code&gt;make&lt;/code&gt; from a split terminal below the code - so I often put the cursor on an error in the compiler's output and want to jump there with the split above. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following functions and mappings will make &lt;code&gt;gf&lt;/code&gt; do a &lt;code&gt;find&lt;/code&gt; of the file, then go to the line and column (if present), in the split above. If you want it to use the same buffer, delete the &lt;code&gt;wincmd k&lt;/code&gt; line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does not change any registers, and only adds a single jump to the &lt;code&gt;:jumplist&lt;/code&gt;, even though there are two jumps in the implementation when a column is included.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Open file at position from compiler error on the terminal&#xA;&quot; e.g. foobar.adb:27:2: &quot;X&quot; not declared in &quot;Y&quot;&#xA;&quot; results in opening foobar.adb in the top buffer (not the terminal), and issuing '27G2|'&#xA;&quot; Default vim comes close with 'vt:&amp;lt;C-W&amp;gt;gf' - but:&#xA;&quot; 1) including the [colon][linenumber] suffix does not work as intended in NeoVim&#xA;&quot; 2) this does not include the column, &#xA;&quot; 3) you cannot reuse the top window.&#xA;&#xA;fu! OpenfileInTopBuffer(selection)&#xA;  let elements=split(a:selection, ':')&#xA;  let elementlen=len(elements)&#xA;  let filename=elements[0]&#xA;  if elementlen &amp;gt; 1&#xA;    let line=elements[1]&#xA;    if elementlen &amp;gt; 2&#xA;      let column=elements[2]&#xA;    endif&#xA;  endif&#xA;  &quot; switch to top buffer&#xA;  silent execute 'wincmd k'&#xA;  try&#xA;    &quot; find the file &#xA;    if elementlen &amp;gt; 1&#xA;      &quot; keepjumps ensures the top of the file is not added to the jumplist&#xA;      silent execute 'keepjumps find ' . filename&#xA;    else&#xA;      silent execute 'find ' . filename&#xA;      return&#xA;    endif&#xA;    if elementlen &amp;gt;= 3&#xA;      &quot; go to the indicated line and column&#xA;      silent execute 'normal! ' . line . 'G' . column . '|'&#xA;    else &quot; elementlen == 2&#xA;      &quot; go to the indicated line&#xA;      silent execute 'normal! ' . line . 'G'&#xA;    endif&#xA;  endtry&#xA;endfunction&#xA;&#xA;augroup Terminal_gf_mapping&#xA;  autocmd!&#xA;  autocmd TermOpen * nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; gf :call OpenfileInTopBuffer( expand('&amp;lt;cWORD&amp;gt;') )&amp;lt;CR&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18875" LastActivityDate="2019-10-27T14:11:23.173" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21682" PostTypeId="1" AcceptedAnswerId="21690" CreationDate="2019-10-27T17:09:06.580" Score="13" ViewCount="10655" Body="&lt;p&gt;I have a file, containing some lines like this: &lt;code&gt;aaa bbb (ccc) ddd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to replace the pair of brackets by a pair of square brackets to make this line become &lt;code&gt;aaa bbb [ccc] ddd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that &lt;code&gt;\ze&lt;/code&gt; and/or &lt;code&gt;\zs&lt;/code&gt; might be used but I don't know how.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2021-12-15T07:56:13.083" Title="How to replace a pair of brackets" Tags="|regular-expression|search|replace|" AnswerCount="8" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21683" PostTypeId="2" ParentId="21682" CreationDate="2019-10-27T17:20:18.197" Score="8" Body="&lt;p&gt;You can use this simple &lt;code&gt;:s&lt;/code&gt; command (or better two :))&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/(/[/g&#xA;:s/)/]/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can even do it in one run, you you define your replacements first like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let replace={'(':'[', ')':']'}&#xA;:s/[()]/\=replace[submatch(0)]/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here we first define a dictionary with the keys of what you want to have replaced. So we need a key &lt;code&gt;(&lt;/code&gt; with the value &lt;code&gt;[&lt;/code&gt; since that is the replacement char you want. Also we want the key &lt;code&gt;)&lt;/code&gt; wit the value &lt;code&gt;]&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we can use a &lt;a href=&quot;https://vimhelp.org/change.txt.html#sub-replace-special&quot; rel=&quot;noreferrer&quot;&gt;sub-replacement-special&lt;/a&gt; to have the replacement character dynamically evaluated using the provided replace dictionary.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="18609" LastEditDate="2019-10-28T04:38:52.857" LastActivityDate="2019-10-28T04:38:52.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21684" PostTypeId="2" ParentId="5132" CreationDate="2019-10-27T22:41:27.350" Score="3" Body="&lt;p&gt;You can find information about the format from &lt;a href=&quot;https://github.com/vim/vim/blob/cb86893114ce33dc9c7bd4ff992b05c12406b35d/src/memline.c&quot; rel=&quot;nofollow noreferrer&quot;&gt;the source&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;NB! Swapfiles are &lt;em&gt;“binary”&lt;/em&gt; 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 other words: one can look at, but not modify, unless one know what one are doing. I.e. one can change &lt;em&gt;User&lt;/em&gt; but have to be aware of padding bytes etc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It starts with a block named &lt;code&gt;block0&lt;/code&gt; which holds basic information, see below.&lt;/p&gt;&#xA;&lt;p&gt;The rest of the file is copies of memory blocks in a tree structure. See description in &lt;a href=&quot;https://github.com/vim/vim/blob/cb86893114ce33dc9c7bd4ff992b05c12406b35d/src/memline.c#L15&quot; rel=&quot;nofollow noreferrer&quot;&gt;top of source file&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The base information could easily be extracted. I.e:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ ./vimswap .foo.swp &#xA;b0_id       6230&#xA;Version     VIM 8.0&#xA;User        goldilocks&#xA;Host        HouseOfCorrection&#xA;File        ~goldilocks/devel/foo&#xA;inode       2230823&#xA;PID         12066&#xA;Pagesize    4096&#xA;mtime       1572209814&#xA;mtime_h     2019-10-27 21:56:54&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;by something like:&lt;/p&gt;&#xA;&lt;p&gt;(&lt;a href=&quot;https://github.com/vim/vim/blob/cb86893114ce33dc9c7bd4ff992b05c12406b35d/src/memline.c#L5238&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;char_to_long&lt;/code&gt;&lt;/a&gt; &lt;em&gt;(modified)&lt;/em&gt;, struct &lt;a href=&quot;https://github.com/vim/vim/blob/cb86893114ce33dc9c7bd4ff992b05c12406b35d/src/memline.c#L149&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;block0&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://github.com/vim/vim/blob/cb86893114ce33dc9c7bd4ff992b05c12406b35d/src/memline.c#L133&quot; rel=&quot;nofollow noreferrer&quot;&gt;constants&lt;/a&gt; copied form source-code.)&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;time.h&amp;gt;&#xA;&#xA;typedef unsigned char char_u;&#xA;&#xA;#define B0_FNAME_SIZE_ORG   900 /* what it was in older versions */&#xA;#define B0_UNAME_SIZE       40&#xA;#define B0_HNAME_SIZE       40&#xA;&#xA;struct block0 {&#xA;    char_u  b0_id[2];       /* id for block 0: BLOCK0_ID0 and BLOCK0_ID1,&#xA;                             * BLOCK0_ID1_C0, BLOCK0_ID1_C1 */&#xA;    char_u  b0_version[10]; /* Vim version string */&#xA;    char_u  b0_page_size[4];/* number of bytes per page */&#xA;    char_u  b0_mtime[4];    /* last modification time of file */&#xA;    char_u  b0_ino[4];      /* inode of b0_fname */&#xA;    char_u  b0_pid[4];      /* process id of creator (or 0) */&#xA;    char_u  b0_uname[B0_UNAME_SIZE]; /* name of user (uid if no name) */&#xA;    char_u  b0_hname[B0_HNAME_SIZE]; /* host name (if it has a name) */&#xA;    char_u  b0_fname[B0_FNAME_SIZE_ORG]; /* name of file being edited */&#xA;    long    b0_magic_long;  /* check for byte order of long */&#xA;    int     b0_magic_int;   /* check for byte order of int */&#xA;    short   b0_magic_short; /* check for byte order of short */&#xA;    char_u  b0_magic_char;  /* check for last char */&#xA;};&#xA;&#xA;static long char_to_long(char_u *s) {&#xA;    return s[3] &amp;lt;&amp;lt; 24 | s[2] &amp;lt;&amp;lt; 16 | s[1] &amp;lt;&amp;lt; 8 | s[0];&#xA;}&#xA;&#xA;char *t_str(long ts, char res[32]) {&#xA;    struct tm lt;&#xA;    lt = *localtime(&amp;amp;ts);&#xA;    strftime(res, 32, &amp;quot;%F %T&amp;quot;, &amp;amp;lt);&#xA;    return res;&#xA;}&#xA;&#xA;void dump_b0(struct block0 b0) {&#xA;    int wh = -8;&#xA;    char res[32];&#xA;    long mtime = char_to_long(b0.b0_mtime);&#xA;    /* TAB's added to make for easy shell-parsing */&#xA;    fprintf(stdout,&#xA;        &amp;quot;%*s\t%02x%02x\n&amp;quot;&#xA;        &amp;quot;%*s\t%s\n&amp;quot;&#xA;&#xA;        &amp;quot;%*s\t%s\n&amp;quot;&#xA;        &amp;quot;%*s\t%s\n&amp;quot;&#xA;        &amp;quot;%*s\t%s\n&amp;quot;&#xA;        &amp;quot;%*s\t%ld\n&amp;quot;&#xA;        &amp;quot;%*s\t%ld\n&amp;quot;&#xA;&#xA;        &amp;quot;%*s\t%ld\n&amp;quot;&#xA;        &amp;quot;%*s\t%ld\n&amp;quot;&#xA;        &amp;quot;%*s\t%s\n&amp;quot;&#xA;        ,&#xA;        wh, &amp;quot;b0_id&amp;quot;, b0.b0_id[0], b0.b0_id[1],&#xA;        wh, &amp;quot;Version&amp;quot;, b0.b0_version,&#xA;&#xA;        wh, &amp;quot;User&amp;quot;, b0.b0_uname,&#xA;        wh, &amp;quot;Host&amp;quot;, b0.b0_hname,&#xA;        wh, &amp;quot;File&amp;quot;, b0.b0_fname,&#xA;        wh, &amp;quot;inode&amp;quot;, char_to_long(b0.b0_ino),&#xA;        wh, &amp;quot;PID&amp;quot;, char_to_long(b0.b0_pid),&#xA;&#xA;        wh, &amp;quot;Pagesize&amp;quot;, char_to_long(b0.b0_page_size),&#xA;        wh, &amp;quot;mtime&amp;quot;, mtime,&#xA;        wh, &amp;quot;mtime_h&amp;quot;, t_str(mtime, res)&#xA;    );&#xA;}&#xA;&#xA;int read_block0(char *fn, struct block0 *b0) {&#xA;    size_t sz_str = sizeof *b0;&#xA;    size_t b_read;&#xA;    FILE *fh;&#xA;&#xA;    fh = fopen(fn, &amp;quot;rb&amp;quot;);&#xA;    if (fh == NULL) {&#xA;        fprintf(stderr, &amp;quot;Unable to open `%s'\n&amp;quot;, fn);&#xA;        return 1;&#xA;    }&#xA;    b_read = fread(b0, 1, sz_str, fh);&#xA;    fclose(fh);&#xA;    return b_read != sz_str;&#xA;}&#xA;&#xA;int dump_block0(char *fn) {&#xA;    struct block0 b0 = {0};&#xA;    if (read_block0(fn, &amp;amp;b0) != 0)&#xA;        return 1;&#xA;&#xA;    dump_b0(b0);&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;int main(int argc, char *argv[])&#xA;{&#xA;    int ec = 0;&#xA;&#xA;    if (argc != 2) {&#xA;        fprintf(stderr, &amp;quot;Usage: %s SWAP_FILE\n&amp;quot;, argv[0]);&#xA;        ec = 1;&#xA;    } else {&#xA;        ec = dump_block0(argv[1]);&#xA;    }&#xA;    return ec;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16695" LastEditorUserId="16695" LastEditDate="2021-10-02T09:06:14.307" LastActivityDate="2021-10-02T09:06:14.307" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21685" PostTypeId="2" ParentId="21682" CreationDate="2019-10-27T23:44:45.743" Score="19" Body="&lt;p&gt;With &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;tpope/vim-surround&lt;/a&gt;, this is a simple&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cs)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;away in Normal mode.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;cs&lt;/code&gt; is the &amp;quot;change-surrounding&amp;quot; operator&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;)&lt;/code&gt; is the &amp;quot;target&amp;quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;]&lt;/code&gt; is the replacement&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-12-01T16:08:18.740" LastActivityDate="2020-12-01T16:08:18.740" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21686" PostTypeId="2" ParentId="8257" CreationDate="2019-10-28T05:05:49.097" Score="1" Body="&lt;p&gt;I got my answer from here: &lt;a href=&quot;https://vim.fandom.com/wiki/Using_command-line_history&quot; rel=&quot;nofollow noreferrer&quot;&gt;Using command line history in vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a summary to execute your command of choice from command history:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt; (opens the command history window)&lt;/li&gt;&#xA;&lt;li&gt;use vim browsing keys to go to the command you want to execute.&#xA;Alternately &lt;code&gt;:n&lt;/code&gt; where n is line number of the command to execute, will&#xA;place you on the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;CR&lt;/kbd&gt; -&gt; (Carriage return) Press enter to execute the command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want to run the last n commands:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;:&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;yank the number of commands you want to run&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;kbd&gt;ctrl&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt; twice&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:@&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="25415" LastEditorUserId="25415" LastEditDate="2019-10-29T17:58:23.917" LastActivityDate="2019-10-29T17:58:23.917" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21687" PostTypeId="1" CreationDate="2019-10-28T06:53:03.567" Score="1" ViewCount="351" Body="&lt;p&gt;I have python examples in a markdown file in a code fence (e.g. when I convert a jupyter notebook into a markdown document). These snippets sometimes have code comments in them starting with #. The markdown folder, however, recognizes these as headings, so folds them as chapters. This, in turn, messes up the document outline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I prevent this?&lt;/p&gt;&#xA;" OwnerUserId="14718" LastActivityDate="2021-01-26T15:22:02.240" Title="How to prevent markdown folding of # comments in fenced code?" Tags="|folding|filetype-markdown|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21688" PostTypeId="2" ParentId="21682" CreationDate="2019-10-28T07:32:33.430" Score="5" Body="&lt;p&gt;If that your cursor is on the left brace that you want to change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%r]^Or[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your cursor is on the right brace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%r[^Or]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, ask vim to find the matching brace, change it, then jump back to the first brace and change it too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your cursor is near enough to one of the braces you want to change, then you can do much as the above but double the initial %:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%%r]^Or[&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%%r[^Or]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works across multiple lines, and with nested brackets. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may even find it works with xml or html, depending on various things. &lt;/p&gt;&#xA;" OwnerUserId="8897" LastActivityDate="2019-10-28T07:32:33.430" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21689" PostTypeId="2" ParentId="21687" CreationDate="2019-10-28T08:07:27.957" Score="2" Body="&lt;p&gt;It would be really hard to do reliably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, if you brave enough, check what current markdown plugin uses for folding and try to rewrite it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:set foldmethod?&lt;/code&gt; to find out if it is &lt;code&gt;expr&lt;/code&gt; or not&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set foldexpr?&lt;/code&gt; to find out what is the function name &lt;code&gt;expr&lt;/code&gt; uses&lt;/li&gt;&#xA;&lt;li&gt;create your own &lt;code&gt;MarkdownFold()&lt;/code&gt; function (or whatever name is 2. showed)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So you would end up copy pasting existing &lt;code&gt;MarkdownFold&lt;/code&gt; function to your vimrc and start hacking.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MarkdownFold()&#xA;  let line = getline(v:lnum)&#xA;&#xA;  ...&#xA;  ...&#xA;&#xA;  return &quot;=&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the end you will have to analyze if current line is python comment and skip it. Which would be the trickiest part. Is your line in a code block? How far backwards you should scan for code block beginning? Etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And depending on your implementation your vim would probably become slow for markdown files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS, I have tried to do similar thing for my implementation of folding for asciidoctor files, but couldn't do anything good, so I decided not to bother with it. Anyway &lt;code&gt;==&lt;/code&gt; is far less common than &lt;code&gt;##&lt;/code&gt; :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it just came to my mind that it is possible to get syntax group of a current line. And you should be able to check if it is a markdown header or not. I have implemented it for my asciidoctor plugin and did this also for a markdown (I already have it in my &lt;code&gt;after/ftplugin&lt;/code&gt; folder to tune it for markdown frontmatter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MarkdownFold()&#xA;  let line = getline(v:lnum)&#xA;&#xA;  &quot; Regular headers&#xA;  let depth = match(line, '\(^#\+\)\@&amp;lt;=\( .*$\)\@=')&#xA;  if depth &amp;gt; 0&#xA;    &quot; check syntax, it should be markdownH1-6&#xA;    let syncode = synstack(v:lnum, 1)&#xA;    if len(syncode) &amp;gt; 0 &amp;amp;&amp;amp; synIDattr(syncode[0], 'name') =~ 'markdownH[1-6]'&#xA;        return &quot;&amp;gt;&quot; . depth&#xA;    endif&#xA;  endif&#xA;&#xA;  &quot; Setext style headings&#xA;  let prevline = getline(v:lnum - 1)&#xA;  let nextline = getline(v:lnum + 1)&#xA;  if (line =~ '^.\+$') &amp;amp;&amp;amp; (nextline =~ '^=\+$') &amp;amp;&amp;amp; (prevline =~ '^\s*$')&#xA;    return &quot;&amp;gt;1&quot;&#xA;  endif&#xA;&#xA;  if (line =~ '^.\+$') &amp;amp;&amp;amp; (nextline =~ '^-\+$') &amp;amp;&amp;amp; (prevline =~ '^\s*$')&#xA;    return &quot;&amp;gt;2&quot;&#xA;  endif&#xA;&#xA;  &quot; frontmatter&#xA;  if (v:lnum == 1) &amp;amp;&amp;amp; (line =~ '^----*$')&#xA;      return &quot;&amp;gt;1&quot;&#xA;  endif&#xA;&#xA;  return &quot;=&quot;&#xA;endfunction&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XPxbF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XPxbF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-10-28T12:21:28.310" LastActivityDate="2019-10-28T12:21:28.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21690" PostTypeId="2" ParentId="21682" CreationDate="2019-10-28T08:36:12.833" Score="14" Body="&lt;p&gt;You can do it in a single substitute command like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/(\(.*\))/[\1]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt; mark the regex subexpression that matches everything &lt;em&gt;inside&lt;/em&gt; the ( and ) in the input line. In the replacement, the &lt;code&gt;\1&lt;/code&gt; stands for whatever the &lt;em&gt;first&lt;/em&gt; (in this case the &lt;em&gt;only&lt;/em&gt;) marked subexpression matched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In words you might describe the substitute command as: look for a &quot;(&quot; followed by anything followed by &quot;)&quot;. Replace that by &quot;[&quot; followed by the same &quot;anything&quot; followed by &quot;]&quot;.&lt;/p&gt;&#xA;" OwnerUserId="25419" LastEditorUserId="25419" LastEditDate="2019-10-28T08:43:23.167" LastActivityDate="2019-10-28T08:43:23.167" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21692" PostTypeId="1" CreationDate="2019-10-28T15:01:50.383" Score="6" ViewCount="7955" Body="&lt;p&gt;I have a &lt;code&gt;$HOME\_vimrc&lt;/code&gt; present, but it doesn't show up in the output of &lt;code&gt;:scriptnames&lt;/code&gt;. And when I run &lt;code&gt;gvim -V&lt;/code&gt;, it reports:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;could not source &quot;$HOME\_vimrc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only thing in my &lt;code&gt;$HOME\_vimrc&lt;/code&gt; is the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set packpath+=C:\Users\username\vimfiles&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In case there was something wrong with that path, I also changed the entire contents of the &lt;code&gt;$HOME\_vimrc&lt;/code&gt; file to this, with the same result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;:echo $HOME&lt;/code&gt; from gvim, it reports my Windows user profile directory &lt;code&gt;C:\Users\username&lt;/code&gt;. I have a &lt;code&gt;$HOME\_gvimrc&lt;/code&gt; which it reads fine. My vimfiles directory is at the default &lt;code&gt;$HOME\vimfiles&lt;/code&gt; which it seems to read fine, because it's sourcing a color scheme from there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:version&lt;/code&gt; shows the following entries:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   system vimrc file: &quot;$VIM\vimrc&quot;&#xA;     user vimrc file: &quot;$HOME\_vimrc&quot;&#xA; 2nd user vimrc file: &quot;$HOME\vimfiles\vimrc&quot;&#xA; 3rd user vimrc file: &quot;$VIM\_vimrc&quot;&#xA;    [...]&#xA;    user gvimrc file: &quot;$HOME\_gvimrc&quot;&#xA;    [...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:echo $MYVIMRC&lt;/code&gt; outputs &lt;code&gt;C:\Program Files (x86)\Vim\_vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried running as both administrator and my Windows username.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something I'm missing?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Edit:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;icacls _vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Users\username&amp;gt; icacls _vimrc&#xA;_vimrc NT AUTHORITY\SYSTEM:(I)(F)&#xA;       BUILTIN\Administrators:(I)(F)&#xA;       DOMAIN\username:(I)(F)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That last entry, DOMAIN\username, is the login I'm using to run gVim.&lt;/p&gt;&#xA;" OwnerUserId="25430" LastEditorUserId="1292" LastEditDate="2019-11-03T08:14:18.920" LastActivityDate="2021-04-23T16:48:29.987" Title="Gvim 8.1 on Windows 10 won't source $HOME\_vimrc" Tags="|vimrc|gvim|microsoft-windows|vim8|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21693" PostTypeId="2" ParentId="20570" CreationDate="2019-10-28T15:22:24.693" Score="4" Body="&lt;p&gt;As of version 8.1.2231 Vim has the &lt;code&gt;gM&lt;/code&gt; command which puts your cursor at the middle of a text line. If you supply a count the count is interpreted as the percentage of the line width, e.g., &lt;code&gt;33gm&lt;/code&gt; will put the cursor at roughly one third of the text width.&lt;/p&gt;&#xA;" OwnerUserId="2636" LastActivityDate="2019-10-28T15:22:24.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21694" PostTypeId="1" AcceptedAnswerId="21696" CreationDate="2019-10-28T16:16:18.823" Score="1" ViewCount="54" Body="&lt;p&gt;Suppose we have a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. un&#xA;2. deux&#xA;3. trois&#xA;4. quatre&#xA;5. cinq&#xA;6. six&#xA;7. sept&#xA;8. huit&#xA;9. neuf&#xA;10. dix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to create a window that shows only lines 5--10 and nothing else. Modifying them should modify the original lines (hence it refers to the same buffer). Ideally, adding and removing lines would add and remove lines into the original buffer. Is that possible, out of the box?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The reason is to focus on that part of the text... and procrastination.)&lt;/p&gt;&#xA;" OwnerUserId="12891" LastActivityDate="2019-10-28T17:21:06.503" Title="How to create a window for specific lines of a buffer?" Tags="|buffers|vim-windows|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21695" PostTypeId="2" ParentId="21694" CreationDate="2019-10-28T16:44:56.900" Score="1" Body="&lt;p&gt;Seems impossible, but there is a workaround. Create a new window and &lt;em&gt;fold&lt;/em&gt; (using &lt;code&gt;zf&lt;/code&gt;) unnecessary text. Note that by default the search command will search in the folded text too. To avoid this, run &lt;code&gt;:set fdo-=search&lt;/code&gt;, then vim only indicates that the item is found in the folded block, but won't unfold it. (This command changes the behaviour in other windows as well.)&lt;/p&gt;&#xA;" OwnerUserId="12891" LastActivityDate="2019-10-28T16:44:56.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21696" PostTypeId="2" ParentId="21694" CreationDate="2019-10-28T17:21:06.503" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=3075&quot; rel=&quot;nofollow noreferrer&quot;&gt;NrrwRgn plugin&lt;/a&gt; (the plugin page has links to alternative plugins) comes closest to your use case: As it mirrors part of the buffer into a separate scratch buffer (and can sync it back to the original), you can treat it like any regular Vim buffer, and edit away without worries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other workarounds, like&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;folding other lines (what you've discovered)&lt;/li&gt;&#xA;&lt;li&gt;using &lt;em&gt;syntax highlighting&lt;/em&gt; (to the &lt;code&gt;Normal&lt;/code&gt; group, or maybe &lt;code&gt;NonText&lt;/code&gt;) or the &lt;em&gt;conceal&lt;/em&gt; feature to make the contents invisible (whereas folding only works on whole lines, this works best on &lt;em&gt;columns&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, the hidden fragments are still there, so searches and other commands like &lt;code&gt;:substitute&lt;/code&gt; will still find them, so the illusion is far from perfect and you have to be vigilant during editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best &lt;em&gt;out of the box&lt;/em&gt; solution that I can imagine is a set of &lt;code&gt;:autocmd&lt;/code&gt;s that move the uninteresting lines into buffer-local List variable(s) on &lt;code&gt;BufReadPost,BufWritePost&lt;/code&gt; and undo that on &lt;code&gt;BufWritePre&lt;/code&gt;. That way, the lines would only be there during saving.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-10-28T17:21:06.503" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21697" PostTypeId="2" ParentId="20494" CreationDate="2019-10-28T17:22:57.710" Score="2" Body="&lt;p&gt;otter.pro's answer is helpful but be aware that it will remove sudo with &lt;code&gt;vim-minimal&lt;/code&gt; in the yum remove step because sudo depends upon vim-minimal. If running as root, no problem. But if you're running with sudo, you can find yourself stuck without root access anymore after sudo gets removed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed his steps, but used &lt;code&gt;rpm&lt;/code&gt; to do a targeted removal of just vim-minimal so that sudo would not be removed in the process (thanks to a tip from &lt;a href=&quot;https://superuser.com/a/1307216&quot;&gt;https://superuser.com/a/1307216&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm &#xA;sudo rpm --import http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7&#xA;&#xA;sudo yum -y remove vim-common vim-enhanced vim-filesystem&#xA;# Don't 'yum remove' vim-minimal because that will remove sudo:&#xA;sudo rpm -e --nodeps vim-minimal&#xA;sudo yum -y --enablerepo=gf-plus install vim-enhanced&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25433" LastActivityDate="2019-10-28T17:22:57.710" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21698" PostTypeId="1" AcceptedAnswerId="21699" CreationDate="2019-10-29T00:20:35.520" Score="1" ViewCount="2171" Body="&lt;h2&gt;Input&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Every line is separated into 8 parts by semicolons&lt;/li&gt;&#xA;&lt;li&gt;Every part can include words,numbers,space etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Output&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I am trying to replace the space in the 6th part with a semicolon, thus separating the line again, making the total number of parts 9.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Example&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1;30;68;Az LEMda;Ads Awdsâ;1 Bethesda, Galilea, Impe Mkals;29;63&#xA;264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20 May 1920 Maklo, Polasn;58;84&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would end up like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1;30;68;Az LEMda;Ads Awdsâ;1;Bethesda, Galilea, Impe Mkals;29;63&#xA;264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20;May 1920 Maklo, Polasn;58;84&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Attempts&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I tried to find the space using anything ranging from regex to &lt;code&gt;\zs&lt;/code&gt; but failed. The closest I came was finding the 5th semicolon.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\(.\{-};\zs\)\{5}/;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I need to find the space that comes after the number that comes after the 5th semicolon, so this kind of thinking got me nowhere and now I am trying to find the space in the parts that I defined earlier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could put &lt;code&gt;awk&lt;/code&gt; into vim but then again I am fairly new with it. I managed to find the 6th part and change the space into a semicolon, but then it changes all the spaces, not just the first one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%! awk 'BEGIN{FS=OFS=&quot;;&quot;} {gsub(/ /, &quot;;&quot;, $6)} 1'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I just change the first space in the 6th part?&lt;/p&gt;&#xA;" OwnerUserId="25440" LastEditorUserId="1841" LastEditDate="2019-10-29T09:03:28.290" LastActivityDate="2019-10-29T09:03:28.290" Title="How to replace a space with a colon - command line mode" Tags="|regular-expression|substitute|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21699" PostTypeId="2" ParentId="21698" CreationDate="2019-10-29T01:09:04.127" Score="4" Body="&lt;h2&gt;&lt;code&gt;substitute&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I was able to do this with just&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\(.\{-\};\)\{5\}[^ ]*\zs /;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Aside: &lt;code&gt;set hlsearch incsearch&lt;/code&gt; really helps here if you don't use them regularly. I basically did a &lt;code&gt;/&lt;/code&gt;-search and tooled with the regex until it looked right—based on the highlighted feedback—and then did &lt;code&gt;:%s//;/&lt;/code&gt; to re-use my search as the substitute pattern.)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Breakdown&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\(.\{-\};\)\{5\}[^ ]*\zs /;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt; on the whole file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s&lt;/code&gt; substitute&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\(&lt;/code&gt; the group&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.\{-\}&lt;/code&gt; of any character (non-greedy)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;&lt;/code&gt; followed by a semi&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\)&lt;/code&gt; (end group)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\{5\}&lt;/code&gt; 5 times&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^ ]*&lt;/code&gt; followed by non-spaces&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs&lt;/code&gt; start match here (this controls what will &lt;em&gt;actually&lt;/em&gt; be replaced&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt; &lt;/code&gt; a space&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;&lt;/code&gt; with a semi-colon&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;The power of macros&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A macro based solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qq0f5;f r;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, on each line you want to fix, &lt;code&gt;@q&lt;/code&gt;. You can even use &lt;code&gt;:%normal! @q&lt;/code&gt; to run it on the whole file, or &lt;code&gt;:g/my_pattern/normal! @q&lt;/code&gt; to only run it on lines which match &lt;code&gt;my_pattern&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Breakdown&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; record macro&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; into &lt;code&gt;q&lt;/code&gt; register&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; go to start of line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;5f;&lt;/code&gt; find the fifth semicolon&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f &lt;/code&gt; find a space&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;r;&lt;/code&gt; replace it by a semicolon&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; quit recording&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(I actually prefer this solution, because it's vastly easier on the brain than the regex, and and it's easier to modify according to your needs. Plus, it simulates how I would fix one line normally.)&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-10-29T01:41:06.443" LastActivityDate="2019-10-29T01:41:06.443" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21700" PostTypeId="2" ParentId="21682" CreationDate="2019-10-29T05:55:15.317" Score="-1" Body="&lt;p&gt;As @AndyB said, you can substitute with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/(\(.*\))/[\1]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would alter it slightly to this. I added a &lt;code&gt;?&lt;/code&gt; after the &lt;code&gt;.*&lt;/code&gt; to make it non-greedy, which means it will try to find the shortest match, rather than the longest one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/(\(.*?\))/[\1]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will also have issues if you have a right parenthesis inside a string. Which is a more complex problem to solve with regex.&lt;/p&gt;&#xA;" OwnerUserId="25442" LastActivityDate="2019-10-29T05:55:15.317" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21701" PostTypeId="2" ParentId="21698" CreationDate="2019-10-29T07:05:47.757" Score="2" Body="&lt;p&gt;If you are using csv data, you can try my &lt;a href=&quot;https://github.com/chrisbra/csv.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;csv pluging&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular it provides a command &lt;a href=&quot;https://github.com/chrisbra/csv.vim#searchincolumn&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;SearchInColumn&lt;/code&gt;&lt;/a&gt;, that allows to search for a pattern in a specific column. If you want to replace the value then, simply use a &lt;code&gt;:s&lt;/code&gt; command with an empty pattern (which will then re-use the last search pattern, which in this case then comes from the &lt;code&gt;:SearchInColumn&lt;/code&gt; command).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-10-29T07:05:47.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21702" PostTypeId="1" CreationDate="2019-10-29T07:56:53.297" Score="0" ViewCount="1176" Body="&lt;p&gt;I am trying to setup fzf and use it with vim, tried to follow the instructions in the git repo but could not get things to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was successfully able to install fzf and use the &lt;code&gt;:FZF&lt;/code&gt; command in vim. Then I tried to install the fzf wrapper plugin here &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/junegunn/fzf.vim&lt;/a&gt; and could not get it to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of the commands are found when I run them inside vim, for example &lt;code&gt;:Ag&lt;/code&gt; returns a &lt;code&gt;command not found error&lt;/code&gt; but &lt;code&gt;:FZF&lt;/code&gt; works fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my vimrc: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;Plugin 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }&#xA;&#xA;Plugin 'junegunn/fzf.vim'&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&quot; To ignore plugin indent changes, instead use:&#xA;&quot;filetype plugin on&#xA;&quot;&#xA;&quot; Brief help&#xA;&quot; :PluginList       - lists configured plugins&#xA;&quot; :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate&#xA;&quot; :PluginSearch foo - searches for foo; append `!` to refresh local cache&#xA;&quot; :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal&#xA;&quot;&#xA;&quot; see :h vundle for more details or wiki for FAQ&#xA;&quot; Put your non-Plugin stuff after this line&#xA;syntax on&#xA;set tabstop=2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the output of &lt;code&gt;:scriptnames&lt;/code&gt; in vim: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: /usr/share/vim/vimrc&#xA;  2: ~/.vimrc&#xA;  3: /usr/share/vim/vim80/ftoff.vim&#xA;  4: ~/.vim/bundle/Vundle.vim/autoload/vundle.vim&#xA;  5: ~/.vim/bundle/Vundle.vim/autoload/vundle/config.vim&#xA;  6: /usr/share/vim/vim80/filetype.vim&#xA;  7: /usr/share/vim/vim80/ftplugin.vim&#xA;  8: /usr/share/vim/vim80/indent.vim&#xA;  9: /usr/share/vim/vim80/syntax/syntax.vim&#xA; 10: /usr/share/vim/vim80/syntax/synload.vim&#xA; 11: /usr/share/vim/vim80/syntax/syncolor.vim&#xA; 12: ~/.vim/bundle/fzf.vim/plugin/fzf.vim&#xA; 13: /usr/share/vim/vim80/plugin/getscriptPlugin.vim&#xA; 14: /usr/share/vim/vim80/plugin/gzip.vim&#xA; 15: /usr/share/vim/vim80/plugin/logiPat.vim&#xA; 16: /usr/share/vim/vim80/plugin/manpager.vim&#xA; 17: /usr/share/vim/vim80/plugin/matchparen.vim&#xA; 18: /usr/share/vim/vim80/plugin/netrwPlugin.vim&#xA; 19: /usr/share/vim/vim80/plugin/rrhelper.vim&#xA; 20: /usr/share/vim/vim80/plugin/spellfile.vim&#xA; 21: /usr/share/vim/vim80/plugin/tarPlugin.vim&#xA; 22: /usr/share/vim/vim80/plugin/tohtml.vim&#xA; 23: /usr/share/vim/vim80/plugin/vimballPlugin.vim&#xA; 24: /usr/share/vim/vim80/plugin/zipPlugin.vim&#xA; 25: /usr/share/vim/vim80/scripts.vim&#xA; 26: /usr/share/vim/vim80/ftplugin/vim.vim&#xA; 27: /usr/share/vim/vim80/indent/vim.vim&#xA; 28: /usr/share/vim/vim80/syntax/vim.vim&#xA; 29: /usr/share/vim/vim80/syntax/ruby.vim&#xA; 30: /usr/share/vim/vim80/syntax/python.vim&#xA; 31: ~/.vim/bundle/Vundle.vim/autoload/vundle/installer.vim&#xA; 32: ~/.vim/bundle/Vundle.vim/autoload/vundle/scripts.vim&#xA; 33: ~/.vim/bundle/fzf/plugin/fzf.vim&#xA; 34: ~/.vim/bundle/fzf.vim/autoload/fzf/vim.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What seems weird is that there is &lt;code&gt;~/.vim/bundle/fzf/plugin/fzf.vim&lt;/code&gt; and &lt;code&gt;~/.vim/bundle/fzf.vim/plugin/fzf.vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be really appreciated!&lt;/p&gt;&#xA;" OwnerUserId="25445" LastEditorUserId="1841" LastEditDate="2019-10-29T09:05:55.907" LastActivityDate="2019-10-29T09:05:55.907" Title="Setting up fzf and integrating it with vim" Tags="|plugin-system|plugin-fzf|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21703" PostTypeId="2" ParentId="16764" CreationDate="2019-10-29T08:33:34.297" Score="5" Body="&lt;p&gt;Vim version &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.2233&quot; rel=&quot;noreferrer&quot;&gt;8.1.2233&lt;/a&gt; adds the read-only variable &lt;code&gt;v:argv&lt;/code&gt;, which can be used to parse the command line arguments given to Vim.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-10-29T08:33:34.297" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21704" PostTypeId="2" ParentId="3792" CreationDate="2019-10-29T10:04:42.447" Score="0" Body="&lt;p&gt;You can write a macro that operates on the pattern you want and run it like 500 times. For instance I had a bunch of lines like this one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Vrvirksomhed.virksomhedMetadata.nyesteNavn.navn&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That I wanted to CamelCase, so i wrote this small macro: &lt;code&gt;/\.xvU&lt;/code&gt;, and ran it until no more changes.&lt;/p&gt;&#xA;" OwnerUserId="25141" LastActivityDate="2019-10-29T10:04:42.447" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21705" PostTypeId="2" ParentId="21692" CreationDate="2019-10-29T13:28:28.247" Score="4" Body="&lt;p&gt;The solution was to define &lt;code&gt;$HOME&lt;/code&gt; as a Windows environment variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once I did that and restarted gVim, it read my &lt;code&gt;~\_vimrc&lt;/code&gt; and also sourced my native Vim 8.1 packages correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://stackoverflow.com/questions/58598312/vim-gvim-8-1-on-windows-10-wont-source-home-vimrc&quot;&gt;this answer&lt;/a&gt; at Stack Overflow.&lt;/p&gt;&#xA;" OwnerUserId="25430" LastEditorUserId="25430" LastEditDate="2019-10-31T16:41:34.850" LastActivityDate="2019-10-31T16:41:34.850" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21706" PostTypeId="1" CreationDate="2019-10-29T18:30:32.523" Score="0" ViewCount="240" Body="&lt;p&gt;I've been using Vim for about a year now (so still a newbie), but this morning UltiSnips stopped working for me. Any help would be really appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;:UltiSnipsEdit!&lt;/code&gt; the console returns &lt;code&gt;E492: Not an editor command&lt;/code&gt;. However what's weird is that I can still run &lt;code&gt;:h UltiSnips&lt;/code&gt; and I get the help menu. Moreover, UltiSnips shows up twice under &lt;code&gt;:scriptnames&lt;/code&gt; as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/bundle/ultisnips/plugin/UltiSnips.vim&#xA;~/.vim/bundle/ultisnips/after/plugin/UltiSnips_after.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other relevant info - I am running MacVim. Below is a minimum &lt;code&gt;.vimrc&lt;/code&gt; which shows this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;filetype off&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'SirVer/ultisnips'&#xA;Plugin 'honza/vim-snippets'&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-z&amp;gt;&quot;&#xA;let g:UltiSnipsEditSplit=&quot;vertical&quot;&#xA;call vundle#end()&#xA;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25452" LastEditorUserId="10604" LastEditDate="2019-10-29T23:11:55.573" LastActivityDate="2019-10-29T23:11:55.573" Title="Ultisnips stopped working this morning" Tags="|macvim|plugin-ultisnips|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21707" PostTypeId="1" AcceptedAnswerId="21710" CreationDate="2019-10-30T01:20:39.457" Score="1" ViewCount="435" Body="&lt;p&gt;Is there a simple way to setup a binding that will &lt;code&gt;:vimgrep&lt;/code&gt; up until a &lt;code&gt;tags&lt;/code&gt; file is found?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm curious because I can do &lt;code&gt;set tags=tags;/&lt;/code&gt; to do a similar search to define tags, but am not quite sure how to transfer this to a different use case.&lt;/p&gt;&#xA;" OwnerUserId="25455" LastEditorUserId="205" LastEditDate="2019-11-06T06:48:17.063" LastActivityDate="2019-11-06T06:48:17.063" Title="vimgrep: Search from 'tags' file location" Tags="|vimgrep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21708" PostTypeId="1" AcceptedAnswerId="21709" CreationDate="2019-10-30T04:19:03.747" Score="26" ViewCount="13713" Body="&lt;p&gt;How do I disable vim from producing backup files? Like file~ do not generate. Should I do that by modifying &lt;code&gt;/etc/vimrc&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added &lt;code&gt;set nobackup&lt;/code&gt; to &lt;code&gt;/etc/vimrc&lt;/code&gt;, but when I looked at the distributed file system log, the backup file was still generated but it was then deleted.&lt;/p&gt;&#xA;" OwnerUserId="25458" LastEditorUserId="1841" LastEditDate="2019-10-30T11:07:07.933" LastActivityDate="2019-10-31T08:11:21.440" Title="How do I disable vim from producing backup files?" Tags="|backup|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21709" PostTypeId="2" ParentId="21708" CreationDate="2019-10-30T04:36:36.973" Score="22" Body="&lt;p&gt;Try adding:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set nobackup nowritebackup&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE with regards to &lt;a href=&quot;https://vi.stackexchange.com/a/21714/9333&quot;&gt;Jason Lefler's answer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to prevent your backup/undo/swap files to be created next to your edited file consider setting directories for them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;directory = expand('~/.vimdata/swap//')&#xA;&#xA;set backup&#xA;let &amp;amp;backupdir = expand('~/.vimdata/backup//')&#xA;&#xA;set undofile&#xA;let &amp;amp;undodir = expand('~/.vimdata/undo//')&#xA;&#xA;if !isdirectory(&amp;amp;undodir) | call mkdir(&amp;amp;undodir, &quot;p&quot;) | endif&#xA;if !isdirectory(&amp;amp;backupdir) | call mkdir(&amp;amp;backupdir, &quot;p&quot;) | endif&#xA;if !isdirectory(&amp;amp;directory) | call mkdir(&amp;amp;directory, &quot;p&quot;) | endif&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You set &lt;code&gt;:h directory&lt;/code&gt;, &lt;code&gt;:h backupdir&lt;/code&gt;, &lt;code&gt;:h undodir&lt;/code&gt; to whatever you prefer. Note, there is double slash &lt;code&gt;//&lt;/code&gt; at the end (&lt;code&gt;~/.vimdata/swap//&lt;/code&gt;) needed to prevent collisions when you edit the same file names in different paths, e.g., there will be files like &lt;code&gt;C%%Users%%username%%docs%%test.adoc~&lt;/code&gt; and &lt;code&gt;C%%Users%%username%%docs%%awesome%%test.adoc~&lt;/code&gt; created in &lt;code&gt;backupdir&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you create those directories if they don't exist. &lt;code&gt;.vimdata&lt;/code&gt; dir is what I use to have all of them in one place, you can change it of course.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-10-31T08:11:21.440" LastActivityDate="2019-10-31T08:11:21.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21710" PostTypeId="2" ParentId="21707" CreationDate="2019-10-30T06:51:49.467" Score="0" Body="&lt;p&gt;I believe you're looking for a function that will return the directory where the &lt;code&gt;tags&lt;/code&gt; file is located, by performing the same kind of lookup up the tree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#findfile%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;findfile()&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;https://vimhelp.org/eval.txt.html#finddir%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;finddir()&lt;/code&gt;&lt;/a&gt; for this purpose, both will use a lookup method similar to the one used in the &lt;code&gt;'tags'&lt;/code&gt; option. See &lt;a href=&quot;https://vimhelp.org/editing.txt.html#file-searching&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help file-searching&lt;/code&gt;&lt;/a&gt; for more details on file searching syntax and a more complete list of functions and options that support that syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you can find the &lt;code&gt;tags&lt;/code&gt; file up the tree using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo findfile('tags', '.;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can get the path to the directory where the &lt;code&gt;tags&lt;/code&gt; file using &lt;a href=&quot;https://vimhelp.org/eval.txt.html#fnamemodify%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;fnamemodify()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo fnamemodify(findfile('tags', '.;'), ':p:h')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can use that expression to execute a &lt;code&gt;:vimgrep&lt;/code&gt; starting on that directory. You'll need &lt;code&gt;:execute&lt;/code&gt; to build the command from a string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute 'vimgrep /something/ '&#xA;    \ . fnamemodify(findfile('tags', '.;'), ':p:h')&#xA;    \ . '/**'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can easily adapt that to write a function or user-defined command starting the search at the expected directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; In order to bind a key combination to searching from the directory where your &lt;code&gt;tags&lt;/code&gt; file is, you can either use &lt;code&gt;:execute&lt;/code&gt; or create an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;s&#xA;    \ :execute &quot;vimgrep /&quot;&#xA;    \ . escape(input('/'), '/') . &quot;/ &quot;&#xA;    \ . fnamemodify(findfile('tags', '.;'), ':p:h') &#xA;    \ . &quot;/**&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The final &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; executes the Ex command right away. Input is being escaped so that &lt;code&gt;/&lt;/code&gt; characters are allowed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative, using &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt;, would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;s&#xA;    \ &quot;:vimgrep /&quot; . escape(input('/'), '/') . &quot;/ &quot;&#xA;    \ . fnamemodify(findfile('tags', '.;'), ':p:h') &#xA;    \ . &quot;/**\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This time we're using a string with &lt;code&gt;:&lt;/code&gt; so it enters Ex mode first. We're also including the final &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; inside the string with a &lt;code&gt;&quot;\&amp;lt;CR&amp;gt;&quot;&lt;/code&gt; (using &lt;code&gt;&quot;\r&quot;&lt;/code&gt; would also be possible, it's equivalent.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either approach would do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 2:&lt;/strong&gt; If you're interested in searching relative to where you found the &lt;code&gt;tags&lt;/code&gt; file in specific, then consider using the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#tagfiles%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;tagfiles()&lt;/code&gt;&lt;/a&gt; function to get the path of the one you're using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this would work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;s&#xA;    \ :execute &quot;vimgrep /&quot;&#xA;    \ . escape(input('/'), '/') . &quot;/ &quot;&#xA;    \ . fnamemodify(tagfiles()[0], ':p:h') &#xA;    \ . &quot;/**&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-10-30T17:22:00.330" LastActivityDate="2019-10-30T17:22:00.330" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21711" PostTypeId="1" AcceptedAnswerId="21713" CreationDate="2019-10-30T07:59:00.040" Score="1" ViewCount="248" Body="&lt;p&gt;I'd like to automatically call the omnicompletion (that is triggered manually by &lt;code&gt;&amp;lt;Ctrl-X&amp;gt;&amp;lt;Ctrl-O&amp;gt;&lt;/code&gt;) from within a vimscript function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I played around a bit with &lt;code&gt;execute 'normal! …'&lt;/code&gt; and &lt;code&gt;feedkeys()&lt;/code&gt;, but if I got it do actually do something, it always results in a literal &lt;code&gt;\&amp;lt;C-X&amp;gt;\&amp;lt;C-O&amp;gt;&lt;/code&gt; in my document.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I call the omnicompletion from within a vimscript function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have tried so far (to simplify the example, I just jump to line 27, enter a new line below it and start omni-completion):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'normal! 27Go\&amp;lt;c-x&amp;gt;\&amp;lt;c-o&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  execute 'normal! 27Go'&#xA;  startinsert&#xA;  execute 'normal! \&amp;lt;c-x&amp;gt;\&amp;lt;c-o&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  execute 'normal! 27Go'&#xA;  startinsert&#xA;  call feedkeys('\&amp;lt;c-x&amp;gt;\&amp;lt;c-o&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hah, thanks to @ChristianBrabant I played around a bit more and found that &lt;code&gt;feedkeys()&lt;/code&gt; should work, but I just used it wrongly! See my own answer below: &lt;a href=&quot;https://vi.stackexchange.com/a/21713/21417&quot;&gt;https://vi.stackexchange.com/a/21713/21417&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21417" LastEditorUserId="21417" LastEditDate="2019-10-30T10:32:58.870" LastActivityDate="2019-10-30T11:48:41.450" Title="call omnicompletion from vimscript" Tags="|vimscript|autocompletion|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21712" PostTypeId="1" CreationDate="2019-10-30T09:28:07.387" Score="2" ViewCount="763" Body="&lt;p&gt;Using the &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;snippets&lt;/a&gt; plugin I'm able to get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyClasnippets(object):&#xA;&#xA;    &quot;&quot;&quot;Docstring for MyClasnippets. &quot;&quot;&quot;&#xA;&#xA;    def __init__(self):&#xA;        &quot;&quot;&quot;TODO: to be defined. &quot;&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from just typing &lt;code&gt;class&lt;/code&gt;. If I add params I can get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyClass(object):&#xA;&#xA;    &quot;&quot;&quot;Docstring for MyClass. &quot;&quot;&quot;&#xA;&#xA;    def __init__(self, x, y):&#xA;        &quot;&quot;&quot;TODO: to be defined.&#xA;&#xA;        :x: TODO&#xA;        :y: TODO&#xA;&#xA;        &quot;&quot;&quot;&#xA;        self._x = x&#xA;        self._y = y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to edit the docstring + the triggers, so 2 things would change:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;When adding exception in a forward trigger, the docstring will add a &quot;Raises&quot; section (using Google's format)&lt;/li&gt;&#xA;&lt;li&gt;Change the entire format to Google's...&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I looked at the &lt;code&gt;vim ./bundle/vim-snippets/UltiSnips/python.snippets&lt;/code&gt;, specifically at the &lt;code&gt;class&lt;/code&gt; definition there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet class &quot;class with docstrings&quot; b&#xA;class ${1:MyClass}(${2:object}):&#xA;&#xA;    `!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)`&#xA;&#xA;    def __init__(self$4):&#xA;        `!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined.}`!p&#xA;snip.rv = &quot;&quot;&#xA;snip &amp;gt;&amp;gt; 2&#xA;&#xA;args = get_args(t[4])&#xA;&#xA;write_docstring_args(args, snip)&#xA;if args:&#xA;    snip.rv += '\n' + snip.mkline('', indent='')&#xA;    snip += '{0}'.format(triple_quotes(snip))&#xA;&#xA;write_init_body(args, t[2], snip)&#xA;`&#xA;        $0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but have no idea where the &lt;code&gt;Docstring&lt;/code&gt; is defined and what to do next. &lt;/p&gt;&#xA;" OwnerUserId="20287" LastEditorUserId="10604" LastEditDate="2019-10-30T12:41:48.633" LastActivityDate="2020-09-19T09:01:30.137" Title="How to change the docstring format of the snippets by Ultisnips?" Tags="|plugin-ultisnips|snippets|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21713" PostTypeId="2" ParentId="21711" CreationDate="2019-10-30T10:32:31.403" Score="2" Body="&lt;p&gt;&lt;code&gt;feedkeys()&lt;/code&gt; is the correct approach, but to respect the special keys, I must use double quotes (as mentioned in the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#feedkeys%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimhelp&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  execute 'normal! 27Go'&#xA;  startinsert&#xA;  call feedkeys(&quot;\&amp;lt;c-x&amp;gt;\&amp;lt;c-o&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21417" LastEditorUserId="21417" LastEditDate="2019-10-30T11:48:41.450" LastActivityDate="2019-10-30T11:48:41.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21714" PostTypeId="2" ParentId="21708" CreationDate="2019-10-30T14:37:53.483" Score="14" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/21709/25466&quot;&gt;Maxim's answer&lt;/a&gt; works for disabling backups entirely, but you can also relocate the backup directory, if you just want to stop cluttering your working directory but want the backup functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set backupdir=~/.vim/backup&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also do this for temporary files, as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set directory=~/.vim/tmp&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(These directories may need to already exist.)&lt;/p&gt;&#xA;" OwnerDisplayName="user25466" LastActivityDate="2019-10-30T14:37:53.483" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21715" PostTypeId="2" ParentId="19978" CreationDate="2019-10-30T16:13:10.583" Score="1" Body="&lt;p&gt;Why so complicated? The easy way to to this is with the &lt;code&gt;grep&lt;/code&gt; and &lt;code&gt;tee&lt;/code&gt; commands.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: before you start messing with files with the &lt;code&gt;tee&lt;/code&gt; command make an alias in your &lt;code&gt;.profile&lt;/code&gt; for the command:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;alias tee=&amp;quot;tee -a&amp;quot;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;-a&lt;/code&gt; flag tells &lt;code&gt;tee&lt;/code&gt; to append to rather than obliterate the&#xA;file. What &lt;code&gt;tee&lt;/code&gt; does specifically is take &lt;code&gt;stdout&lt;/code&gt; and redirects it&#xA;to files, similar to&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;echo some text &amp;gt; file.&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;But it works with what is produced on the terminal.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In order to use &lt;code&gt;tee&lt;/code&gt; properly we need to get some &lt;code&gt;stdout&lt;/code&gt; and that is where &lt;code&gt;grep&lt;/code&gt; comes in.&lt;/p&gt;&#xA;&lt;p&gt;What you want to do is &lt;code&gt;grep&lt;/code&gt; (find) the text you want to produce which by default will put the text as &lt;code&gt;stdout&lt;/code&gt;. You can also add lines before or after the line you want with &lt;code&gt;-A&lt;/code&gt;, &lt;code&gt;-B&lt;/code&gt;, and &lt;code&gt;-C&lt;/code&gt; flags. Also, to add line number you can add the &lt;code&gt;-n&lt;/code&gt; flag. So if you add &lt;code&gt;-A5&lt;/code&gt; for example, you will get the line you grep for plus 5 lines after that. Similarly with &lt;code&gt;-B5&lt;/code&gt; but in this case you get the line you grep for plus 5 lines before what you grep for. &lt;code&gt;-C5&lt;/code&gt; you get 5 lines before and after meaning 10 lines plus what you grep for. The &lt;code&gt;-n&lt;/code&gt; flag gets you your line numbers.&lt;/p&gt;&#xA;&lt;p&gt;The command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;grep -n[-ABC][num] &amp;quot;search line&amp;quot; | tee [-a, unless you alias it already] [file]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This command is a lot more simple. You see everything on the screen.&#xA;The only drawback (if it is a drawback) is that when &lt;code&gt;grep&lt;/code&gt; adds line numbers, it does so with a colon and each line after that gets a dash like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;33: text....&#xA;34- text....&#xA;35- text....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However seeing how you are injecting line numbers to begin with, this is a good visual clue, especially if you have line numbers enabled in your text editor.&lt;/p&gt;&#xA;&lt;p&gt;It could get real confusing otherwise.&lt;/p&gt;&#xA;&lt;p&gt;Enjoy.&lt;/p&gt;&#xA;" OwnerUserId="25469" LastEditorUserId="7706" LastEditDate="2021-02-01T14:09:05.933" LastActivityDate="2021-02-01T14:09:05.933" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21716" PostTypeId="2" ParentId="7707" CreationDate="2019-10-30T16:34:47.367" Score="0" Body="&lt;p&gt;The following answer on &lt;a href=&quot;https://stackoverflow.com/a/24974438&quot;&gt;stackoverflow&lt;/a&gt; explains why this is impossible:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Due to the way that the keyboard input is handled internally, this&#xA;  unfortunately isn't generally possible today, even in GVIM. Some key&#xA;  combinations, like &lt;strong&gt;Ctrl + non-alphabetic cannot be mapped&lt;/strong&gt;, and Ctrl +&#xA;  letter vs. Ctrl + Shift + letter cannot be distinguished.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="12891" LastActivityDate="2019-10-30T16:34:47.367" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21717" PostTypeId="1" AcceptedAnswerId="21771" CreationDate="2019-10-30T17:58:06.713" Score="1" ViewCount="1606" Body="&lt;p&gt;Can anyone help me get things like &quot;Go to definition&quot; working with Neovim and Python virtual environments?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My setup currently uses a specific virtual environment for Neovim (as recommended by &lt;code&gt;:checkhealth&lt;/code&gt;) which is working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've installed &lt;code&gt;python-language-server&lt;/code&gt; and &lt;code&gt;pyls-mypy&lt;/code&gt; into that virtual environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my &lt;code&gt;.vimrc&lt;/code&gt; I've got &lt;code&gt;w0rp/ale&lt;/code&gt; installed with the following configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_linters = {&#xA;      \ 'python': ['flake8', 'pyls']&#xA;      \}&#xA;let g:ale_virtualenv_dir_names = ['.venv']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm now in a directory with a virtual environment in &lt;code&gt;./.venv&lt;/code&gt; (which isn't activated) and can't get any LSP stuff like &lt;code&gt;:ALEGoToDefinition&lt;/code&gt; to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="2026" LastActivityDate="2019-12-04T13:33:53.737" Title="Python Language Server Protocol with virtual environment" Tags="|neovim|filetype-python|plugin-ale|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21718" PostTypeId="1" CreationDate="2019-10-30T18:40:59.363" Score="1" ViewCount="201" Body="&lt;p&gt;Similar to &lt;a href=&quot;https://vi.stackexchange.com/questions/3632/how-to-repeat-a-mapping-when-keeping-key-pressed&quot;&gt;this&lt;/a&gt; question, I want to be able to resize my splits in a repeatable manner, but without having to use a plugin. I currently use the mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;q &amp;lt;C-w&amp;gt;10&amp;lt;&#xA;nnoremap &amp;lt;Leader&amp;gt;w &amp;lt;C-w&amp;gt;10&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works just fine. But I have to press and release the whole combination multiple times to get it to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simple way to make this repeatable without adding a plugin like the mentioned solution? I also use the common mapping for tabbing visually selected code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt; &amp;lt;gv&#xA;vnoremap &amp;gt; &amp;gt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works by re-entering visual mode to avoid having to select again, but I'm not sure how this might be transferable to what I want to do as they aren't similar other than that I'm trying to achieve repeatability.&lt;/p&gt;&#xA;" OwnerUserId="25455" LastEditorUserId="205" LastEditDate="2019-11-06T06:48:07.537" LastActivityDate="2019-11-06T06:48:07.537" Title="Repeat &lt;Leader&gt; mapping without having to press/release full combination" Tags="|repeated-commands|leader|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21719" PostTypeId="1" AcceptedAnswerId="21720" CreationDate="2019-10-30T20:03:51.660" Score="3" ViewCount="957" Body="&lt;h1&gt;Background&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I am new to vi/vim world and finished running the vimtutor several times.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The setup&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;In the tutorial we learn several items to correct or edit lines of text.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;r&lt;/code&gt; to replace the letter the cursor is over&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;i&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;A&lt;/code&gt; to jump into insert mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ce&lt;/code&gt;, &lt;code&gt;c2w&lt;/code&gt;, &lt;code&gt;c&amp;lt;#&amp;gt;&amp;lt;cmd&amp;gt;&lt;/code&gt;, etc - will delete the &amp;lt;#&gt; and enter insert mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;The question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Is their a way to use &lt;code&gt;r&lt;/code&gt; to specific a number of characters to replace?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar to &lt;code&gt;c&lt;/code&gt; I am looking for something like &lt;code&gt;2r&lt;/code&gt; to replace the next 2 characters. Is this possible? Is their a way to do this with &lt;code&gt;c&lt;/code&gt; that I just haven't figured out yet?&lt;/p&gt;&#xA;" OwnerUserId="25476" LastActivityDate="2019-10-30T20:59:29.777" Title="Can `r` be used for multiple letters?" Tags="|replace|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21720" PostTypeId="2" ParentId="21719" CreationDate="2019-10-30T20:18:12.530" Score="8" Body="&lt;p&gt;There are 3 slightly different ways to do this.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;R&lt;/code&gt; will enter &quot;Replace mode&quot;. This is like insert mode except each character overwrites the character currently under the cursor. For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;testing&#xA;^ Cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and pressing &lt;code&gt;Rrunn&amp;lt;esc&amp;gt;&lt;/code&gt; will change the text to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;running&#xA;   ^ Cursor here&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Using &lt;code&gt;c&lt;/code&gt;. For example, if you want to change 2 characters, you could do &lt;code&gt;2cl&lt;/code&gt; or &lt;code&gt;c2l&lt;/code&gt; to delete two characters and enter insert mode. You could also use &lt;code&gt;2s&lt;/code&gt; as &lt;code&gt;s&lt;/code&gt; is a synonym for &lt;code&gt;cl&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;r&lt;/code&gt; command can take a count, but this will only work if you want to use the same character. For example, if I have 3 double quotes, and I want to change them to 3 single quotes, I could put the cursor on the first one and type &lt;code&gt;3r'&lt;/code&gt;. Note that &lt;code&gt;R&lt;/code&gt; also takes a count. If you typed &lt;code&gt;3Rabc&amp;lt;esc&amp;gt;&lt;/code&gt; it will replace the next 9 characters with &lt;code&gt;abcabcabc&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2019-10-30T20:59:29.777" LastActivityDate="2019-10-30T20:59:29.777" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21721" PostTypeId="2" ParentId="3632" CreationDate="2019-10-30T23:04:21.063" Score="4" Body="&lt;p&gt;With &lt;a href=&quot;https://github.com/simeji/winresizer&quot; rel=&quot;nofollow noreferrer&quot;&gt;winresizer&lt;/a&gt;, hit &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;e&lt;/kbd&gt; and resize away!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll use the regular hjkl keys (and maybe the arrow keys).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can &quot;accept&quot; the resize or &quot;abort&quot; it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also a move-mode where you swap windows around, and a focus-mode where you switch the window you're active in.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-10-30T23:04:21.063" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21722" PostTypeId="1" AcceptedAnswerId="21723" CreationDate="2019-10-31T06:46:01.263" Score="1" ViewCount="48" Body="&lt;p&gt;Due to working in an environment with no clipboard support I have the following line in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;F12&amp;gt; :set invnumber&amp;lt;CR&amp;gt; &amp;lt;bar&amp;gt; :set invpaste&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Oddly enough, this works for some files I open, but any other file (or new ones) only the first part (&lt;code&gt;invnumber&lt;/code&gt;) is run, and the &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; and anything that follows is ignored.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nmap&lt;/code&gt; shows the same output on working and non-working files&lt;/li&gt;&#xA;&lt;li&gt;I thought it might be somehow cached on a name, but new files with names matching working ones do not work either.&lt;/li&gt;&#xA;&lt;li&gt;I tried reversing the order of commands, but only the first is run on non-working files.&lt;/li&gt;&#xA;&lt;li&gt;Removed all plugins, but this behavior persists.&lt;/li&gt;&#xA;&lt;li&gt;Cleaned the vimrc except this line - persists.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What is the problem, or if it's not something simple, how do I debug this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VIM version is 7.4, (I do not control this) and the plugins I use are matchit, surround, Tabular, and flake8.&lt;/p&gt;&#xA;" OwnerUserId="25481" LastEditorUserId="1841" LastEditDate="2019-10-31T08:32:31.507" LastActivityDate="2019-10-31T08:32:31.507" Title="nmapping two commands works only sometimes" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21723" PostTypeId="2" ParentId="21722" CreationDate="2019-10-31T07:11:42.470" Score="4" Body="&lt;p&gt;Your mapping is written badly: you don't need both &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; at the same time. Use either &lt;code&gt;:cmd1&amp;lt;bar&amp;gt;cmd2&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;:cmd1&amp;lt;CR&amp;gt;:cmd2&amp;lt;CR&amp;gt;&lt;/code&gt;. Moreover, with &lt;code&gt;set&lt;/code&gt; you can/should merge both settings into one command: &lt;code&gt;:set invnumber invpaste&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing you should take into account is that &lt;code&gt;number&lt;/code&gt; is local to window, but &lt;code&gt;paste&lt;/code&gt; is global. Therefore, they could not always match each other.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-10-31T07:24:05.873" LastActivityDate="2019-10-31T07:24:05.873" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21724" PostTypeId="1" AcceptedAnswerId="22712" CreationDate="2019-10-31T09:33:31.623" Score="3" ViewCount="1142" Body="&lt;p&gt;When using CoC.nvim's suggestion list, I often find myself pressing &lt;kbd&gt;Esc&lt;/kbd&gt; twice to return to normal mode - once for cancelling CoC's list session and once to actually exit insert mode. I find that extraneous (and noisy, considering I'm using a clicky mechanical keyboard in an open office).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked CoC's documentation but could not find anything that would solve this with configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is a good, maintainable way of having &lt;kbd&gt;Esc&lt;/kbd&gt; close CoC's list session and exit insert mode with one press?&lt;/p&gt;&#xA;" OwnerUserId="25482" LastActivityDate="2020-01-30T10:56:49.360" Title="How to press ESC only once to close suggestions list and exit insert mode" Tags="|neovim|plugin-coc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21725" PostTypeId="1" AcceptedAnswerId="21728" CreationDate="2019-10-31T09:43:46.137" Score="3" ViewCount="799" Body="&lt;p&gt;I am trying to delete all the spaces that aren't sandwiched by a letter. So this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; I am trying; but ; I can't find a way    ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I am trying;but;I can't find a way;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried this but it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\([A-Za-z]\)\@&amp;lt;! *\([A-Za-z]\)\@!//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25440" LastActivityDate="2019-10-31T12:02:35.800" Title="How to use lookahead and lookbehind in vim in the same line" Tags="|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21726" PostTypeId="1" CreationDate="2019-10-31T10:22:04.243" Score="1" ViewCount="648" Body="&lt;p&gt;I was toying around with my &lt;code&gt;.vimrc&lt;/code&gt; editing it, and then checking in another file whether my changes worked or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now I ended up in a state where opening one file with &lt;code&gt;vim file1.tex&lt;/code&gt; (this was the one I used for testing) doesn't load syntax highlighting and using &lt;code&gt;vim file2.tex&lt;/code&gt; loads the syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thought was that maybe I accidentally set something specific for &lt;code&gt;file1.tex&lt;/code&gt; which persists, but the only info I found was &lt;code&gt;.viminfo&lt;/code&gt; and deleting that did not help.&lt;/p&gt;&#xA;" OwnerUserId="25312" LastEditorUserId="1841" LastEditDate="2019-10-31T10:28:12.767" LastActivityDate="2019-10-31T10:28:12.767" Title="vim doesn't load syntax for a single file" Tags="|vimrc|syntax-highlighting|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21727" PostTypeId="2" ParentId="21725" CreationDate="2019-10-31T11:47:33.890" Score="2" Body="&lt;p&gt;You can make use of &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v^\s+|\s+$|[^[:alpha:][:space:]]\zs\s+|\s+\ze[^[:alpha:][:space:]]//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:s/\v&amp;lt;pat1&amp;gt;|&amp;lt;pat2&amp;gt;|&amp;lt;pat3&amp;gt;|&amp;lt;pat4&amp;gt;//g&lt;/code&gt; --- delete all matches using &quot;very magic&quot; mode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^\s+&lt;/code&gt; --- leading spaces&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\s+$&lt;/code&gt; --- trailing spaces&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;[^[:alpha:][:space:]]\zs\s+&lt;/code&gt; --- matches anything except alpha or space followed by space(s), but selects space(s) only&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\s+\ze[^[:alpha:][:space:]]&lt;/code&gt; --- matches space(s) followed by anything except alpha or space, but selects space(s) only&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-10-31T11:47:33.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21728" PostTypeId="2" ParentId="21725" CreationDate="2019-10-31T11:55:57.417" Score="6" Body="&lt;p&gt;&quot;Aren't sandwiched by a letter&quot; means &lt;em&gt;does not have: a letter before it and a letter after it&lt;/em&gt;, when expressed through &lt;a href=&quot;https://en.wikipedia.org/wiki/De_Morgan%27s_laws&quot; rel=&quot;noreferrer&quot;&gt;De Morgan's laws&lt;/a&gt;: &lt;em&gt;does not have a letter before it &lt;strong&gt;OR&lt;/strong&gt; does not have a letter after it&lt;/em&gt;. What your regular expression is matching is &lt;em&gt;does not have a letter before it &lt;strong&gt;AND&lt;/strong&gt; does not have a letter after it&lt;/em&gt;; so it would only match between something like &lt;code&gt;# ; $&lt;/code&gt; (which your example does not have). Maybe it becomes clearer when we condense the collection to &lt;a href=&quot;https://vimhelp.appspot.com/pattern.txt.html#%2F%5Ca&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;/\a&lt;/code&gt;&lt;/a&gt; and remove the superfluous grouping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\a\@&amp;lt;! \+\a\@!/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also changed &lt;code&gt;*&lt;/code&gt; to &lt;code&gt;\+&lt;/code&gt;; though matching &lt;em&gt;no&lt;/em&gt; sandwiched spaces and replacing them with &lt;em&gt;nothing&lt;/em&gt; doesn't do harm, it's imprecise (and may be a bit more inefficient).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To arrive at the correct pattern, we need to turn the AND to OR, by introducing a branch with &lt;code&gt;\|&lt;/code&gt; (&lt;a href=&quot;https://vimhelp.appspot.com/pattern.txt.html#%2F%5Cbar&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help /\bar&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\a\@&amp;lt;! \+\| \+\a\@!/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2019-10-31T12:02:35.800" LastActivityDate="2019-10-31T12:02:35.800" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21729" PostTypeId="1" CreationDate="2019-10-31T16:12:08.010" Score="6" ViewCount="210" Body="&lt;p&gt;I'd like to switch the behaviour of the &lt;code&gt;&amp;lt;Down&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; keys when the popup menu (like from omnicompletion) is visible (and &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; respectively).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following two mappings work (actually only in neovim; in vim they insert arbitrary lines with single letters on each keystroke):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;Down&amp;gt;     pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;Down&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Up&amp;gt;       pumvisible() ? &quot;\&amp;lt;C-p&amp;gt;&quot; : &quot;\&amp;lt;Up&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following don't&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-n&amp;gt;      pumvisible() ? &quot;\&amp;lt;Down&amp;gt;&quot; : &quot;\&amp;lt;C-n&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-p&amp;gt;      pumvisible() ? &quot;\&amp;lt;Up&amp;gt;&quot; : &quot;\&amp;lt;C-p&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong? I tried it with &lt;code&gt;--no-plugin -u NONE&lt;/code&gt; to assure that they don't conflict with some other setting or plugin, but that is not the case.&lt;/p&gt;&#xA;" OwnerUserId="21417" LastActivityDate="2019-10-31T16:12:08.010" Title="switching `&lt;Down&gt;` and `&lt;C-n&gt;` in popup menu" Tags="|ins-completion|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21730" PostTypeId="1" CreationDate="2019-10-31T17:33:19.833" Score="1" ViewCount="1577" Body="&lt;p&gt;Let's assume we want to create a custom colorscheme. For example, content of a custom colorscheme file &lt;code&gt;~/.vim/colors/mytheme.vim&lt;/code&gt; are as follows,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; syntax highlighting groups&#xA;hi Comment  guifg=#007f7f&#xA;hi Constant guifg=#ffa0a0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see in above code snippet, I am just defining colors for default highlight groups.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How can add extend default highlight group? i.e. I want to add some words to be considered under &lt;code&gt;Comment&lt;/code&gt; group.&lt;/li&gt;&#xA;&lt;li&gt;How to create new highlight group e.g. &lt;code&gt;StylishComments&lt;/code&gt;? And similarly add few words under that group?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="20720" LastActivityDate="2019-11-01T07:22:45.667" Title="How to create a custom colorscheme in which define custom highlight group each of containing set of words?" Tags="|vimrc|linux|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21731" PostTypeId="2" ParentId="8741" CreationDate="2019-10-31T19:31:22.507" Score="-2" Body="&lt;p&gt;Add this macro to your .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map #h :set hls!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will allow you to toggle hilighting with #h&lt;/p&gt;&#xA;" OwnerUserId="25492" LastEditorUserId="25492" LastEditDate="2019-10-31T19:37:00.453" LastActivityDate="2019-10-31T19:37:00.453" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21733" PostTypeId="1" CreationDate="2019-10-31T19:54:31.080" Score="3" ViewCount="207" Body="&lt;p&gt;Let's suppose I have the following environment variable&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1| export  my__files=$HOME/Documents/MyFiles&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now let's suppose I am editing the file &lt;code&gt;main.txt&lt;/code&gt; (see content below)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1| foo&#xA;2| bar&#xA;3| $my__files/█&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; (complete filename) while in insert mode in the current cursor position, it will expand the environment variable and start listing the files and directories present within that specific directory&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1| foo&#xA;2| bar&#xA;3| /home/mario/Documents/MyFiles/DCBooks/█&#xA;   /home/mario/Documents/MyFiles/DCBooks/&#xA;   /home/mario/Documents/MyFiles/DCExperiments/&#xA;   /home/mario/Documents/MyFiles/DCPrograms/&#xA;   /home/mario/Documents/MyFiles/DCRemoteRepos/&#xA;   /home/mario/Documents/MyFiles/Music/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is: When using file completion in front an environment variable is it possible to make &lt;code&gt;vim&lt;/code&gt; not to expand it and just start listing files within the directory that is represented by the environment variable?&lt;/p&gt;&#xA;" OwnerUserId="22995" LastEditorUserId="22995" LastEditDate="2019-11-01T06:06:54.487" LastActivityDate="2019-11-01T06:06:54.487" Title="Disable expansion of environment variables when completing filenames" Tags="|environment-variables|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21734" PostTypeId="1" CreationDate="2019-10-31T20:43:44.920" Score="1" ViewCount="44" Body="&lt;p&gt;As far as I'm concerned &quot;printable characters&quot; are the set of characters that occupies a printing position on a display. You can print a subset of (not all) printable characters by executing &lt;code&gt;:echo &amp;amp;isprint&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo &amp;amp;isprint&#xA;@,161-255&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The speciications present in &lt;code&gt;vim&lt;/code&gt; documentation are concise. According to &lt;code&gt;:h 'isprint'&lt;/code&gt;, characters from space (decimal value: 32) to tilde (decimal value: 126) are considered as printable characters, even they are not included in &lt;code&gt;'isprint'&lt;/code&gt; or excluded. This raises the following question: why is the at sign (&lt;code&gt;@&lt;/code&gt;) explicitly specified within the set of characters that is displayed by executing &lt;code&gt;:h 'isprint'&lt;/code&gt; while the other characters are represented by a range of decimal values. Does this implies something significant? Is the at sign considered as something more than a simple character?&lt;/p&gt;&#xA;" OwnerUserId="22995" LastActivityDate="2019-10-31T20:43:44.920" Title="Meaning of `@` in `&amp;isprint`" Tags="|default-settings|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21735" PostTypeId="1" CreationDate="2019-11-01T06:27:14.043" Score="1" ViewCount="456" Body="&lt;p&gt;I have some configuration in my &lt;code&gt;.vimrc&lt;/code&gt; governing the initial folding strategy. Sometimes, I am looking to restore the initial state and would like a &lt;code&gt;:refold&lt;/code&gt; command or something, which restores the initial state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some built-in way to do this?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2019-11-01T11:06:58.463" Title="How can I reset all folds to the state when the editor started?" Tags="|folding|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21736" PostTypeId="2" ParentId="21730" CreationDate="2019-11-01T07:22:45.667" Score="1" Body="&lt;p&gt;In general, you can't/shouldn't &quot;create a custom colorscheme in which define custom highlight group each of containing set of words&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can/should do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;define your colorscheme file where for the color groups specific colors are defined (example snip):&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=dark&#xA;&#xA;hi clear&#xA;if exists('syntax_on')&#xA;    syntax reset&#xA;endif&#xA;&#xA;let g:colors_name = 'mycolorscheme'&#xA;&#xA;hi Comment  guifg=#007f7f&#xA;hi Constant guifg=#ffa0a0&#xA;&quot;... other color groups if needed. Otherwise default values would be used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;define syntax file that create syntax elements such as comments, keywords, constants, etc and maps them to colorgroups (existing or created by you), for example for asciidoctor syntax I have:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;b:current_syntax&quot;)&#xA;    finish&#xA;endif&#xA;&#xA;syn match asciidoctorComment &quot;^//.*$&quot;&#xA;&#xA;hi def link asciidoctorComment               Comment&#xA;&quot; ... other syntax elements&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where I define what is asciidoctor comment -- something that start with double slash in the beginning of the line till the end of the line -- and map it to default Comment highlight group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And to be closer to your questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;you can try to do explicit:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match Comment &quot;hello\|world&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That would make words &quot;hello&quot; and &quot;world&quot; a comment, kind of. Although it would be overwritten when you open a new file with defined syntax, so you should have find a way to properly execute this after current syntax file was loaded. (&lt;code&gt;:h autocommand&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Well it is the same, but you have to add highlight for that group:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match StylishComments &quot;My\|Stylish\|Comments&quot;&#xA;hi StylishComments guifg=&quot;#ffff00&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the same issue as with pt.1 but it also will probably overwritten after you change colorscheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try it in vim session &lt;code&gt;:syntax ...&lt;/code&gt; to see if it works for you (it worked for me:). Then decide what route to go, either using autocommands in vimrc to reapply those commands after filetype and/or colorscheme was changed or create a proper syntax and colorscheme files.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-11-01T07:22:45.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21737" PostTypeId="2" ParentId="21735" CreationDate="2019-11-01T08:29:13.107" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;would like a :refold command`&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range -addr=windows Refold call ResetWinOpts(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;, ['fdm', 'fdl', ...])&#xA;command! RefoldAll tabdo %Refold&#xA;&#xA;&quot; reset options through a window-range to global values&#xA;function! ResetWinOpts(winid1, winid2, opts)&#xA;    call execute(printf(&quot;%s,%swindo setl %s&amp;lt;&quot;, a:winid1, a:winid2, join(a:opts, &quot;&amp;lt; &quot;)))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're only interested in undoing all effects of manual folding, like &lt;code&gt;za/zo/zc&lt;/code&gt; etc. then, as @ChristianBrabandt suggested in the comments, the command &lt;code&gt;zX&lt;/code&gt; will do this for you.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-11-01T11:06:58.463" LastActivityDate="2019-11-01T11:06:58.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21738" PostTypeId="1" CreationDate="2019-11-01T11:42:59.663" Score="2" ViewCount="835" Body="&lt;p&gt;my usual setup is two vertically split windows. Lets say my cursor is in left window. When I vimgrep something, I would like for quickfix window to reuse &#xA;already opened right window and automatically open there as a new buffer. Similary, if cursor was in right window, quickfix should open in existing left window. Is that possible? This is what I currently have. But it will open third window that I will have to close later. Thanks.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup quickfix&#xA;    autocmd!&#xA;    autocmd QuickFixCmdPost [^l]* call OpenQuickFixList()&#xA;augroup END&#xA;&#xA;&quot;open in vertical split and realign windows&#xA;function OpenQuickFixList()&#xA;    vert cwindow&#xA;    execute &quot;normal \&amp;lt;C-w&amp;gt;=&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25118" LastActivityDate="2019-11-01T13:14:01.113" Title="Open quickfix/help in existing window" Tags="|vim-windows|quickfix|" AnswerCount="1" CommentCount="2" ClosedDate="2019-11-01T16:28:05.133" ContentLicense="CC BY-SA 4.0" />
  <row Id="21739" PostTypeId="2" ParentId="21738" CreationDate="2019-11-01T13:00:19.647" Score="2" Body="&lt;p&gt;if you want to always have it opened in vertical split with your current window, try next function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup quickfix&#xA;    autocmd!&#xA;    autocmd QuickFixCmdPost [^l]* call OpenQuickFixList()&#xA;augroup END&#xA;&#xA;function OpenQuickFixList()&#xA;    wincmd o&#xA;    vert cwindow&#xA;    wincmd p&#xA;    wincmd =&#xA;endfunction&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What it does is&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;make current window the only one (&lt;code&gt;:h wincmd&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;vertically split cwindow&lt;/li&gt;&#xA;&lt;li&gt;goes to previous window (remove this line if you want to stay in quickfix)&lt;/li&gt;&#xA;&lt;li&gt;make windows equal&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;PS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HSKGC.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HSKGC.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-11-01T13:14:01.113" LastActivityDate="2019-11-01T13:14:01.113" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21740" PostTypeId="1" CreationDate="2019-11-01T14:34:38.553" Score="1" ViewCount="269" Body="&lt;p&gt;I am trying to get YCM working on Windows 10.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vim version: &lt;code&gt;8.1 64-bit GUI&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Since I'm using the regular gvim installer for Windows I have python support&lt;/li&gt;&#xA;&lt;li&gt;Compiler flags as follows:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL -DFEAT_SOUND  -DFEAT_JOB_CHANNEL      -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG  /Zl /MT -DFEAT_MBYTE_IME -DDYNAMIC_IME -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\&quot;tcl86t.dll\&quot; -DDYNAMIC_TCL_VER=\&quot;8.6\&quot; -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\&quot;lua53.dll\&quot; -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\&quot;python27.dll\&quot; -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\&quot;python37.dll\&quot; -DFEAT_MZSCHEME -I &quot;C:\Program Files\Racket\include&quot; -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\&quot;libracket3m_a36fs8.dll\&quot; -DDYNAMIC_MZGC_DLL=\&quot;libracket3m_a36fs8.dll\&quot; -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\&quot;perl528.dll\&quot; -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=24 -DDYNAMIC_RUBY_DLL=\&quot;x64-msvcrt-ruby240.dll\&quot; -DFEAT_HUGE /Fd.\ObjCULYHTRZAMD64/ /Zi&#xA;Linking: link  /nologo /opt:ref /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib netapi32.lib uuid.lib /machine:AMD64   libcmt.lib  user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608&#xA;/nodefaultlib:python27.lib /nodefaultlib:python37.lib   &quot;C:\Tcl\lib\tclstub86.lib&quot; winmm.lib WSock32.lib /PDB:vim.pdb -debug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Python3.7 installed to &lt;code&gt;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Python37.dll is present in the same folder as python.exe&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:echo has('python3')&lt;/code&gt; returns 1&lt;/li&gt;&#xA;&lt;li&gt;YCM was installed as follows:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python install.py --clang-completer --ts-completer --cs-completer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;No error during YCM installation&lt;/li&gt;&#xA;&lt;li&gt;YCM Logs shows:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Traceback (most recent call last):&#xA; File &quot;C:\Users\&amp;lt;user&amp;gt;\.vim\bundle\YouCompleteMe\third_party\ycmd\ycmd\utils.py&quot;, line 639, in ImportAndCheckCore&#xA;   ycm_core = ImportCore()&#xA; File &quot;C:\Users\&amp;lt;user&amp;gt;\.vim\bundle\YouCompleteMe\third_party\ycmd\ycmd\utils.py&quot;, line 630, in ImportCore&#xA;   import ycm_core as ycm_core&#xA;ImportError: DLL load failed: The specified module could not be found.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25498" LastActivityDate="2020-08-28T10:59:54.623" Title="YouCompleteMe cannot find module" Tags="|microsoft-windows|plugin-you-complete-me|vimscript-python|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21741" PostTypeId="1" CreationDate="2019-11-01T17:42:36.397" Score="0" ViewCount="206" Body="&lt;p&gt;I'm using &lt;code&gt;coc.nvim&lt;/code&gt; for &lt;code&gt;react (typescript)&lt;/code&gt; development. I have installed following &lt;code&gt;coc&lt;/code&gt; plugins.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;coc-tslint-plugin &lt;/li&gt;&#xA;&lt;li&gt;coc-tsserver&lt;/li&gt;&#xA;&lt;li&gt;coc-prettier&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;tslint&lt;/code&gt; integration is enabled for prettier in &lt;code&gt;coc-settings.json&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;prettier.eslintIntegration&quot;: true,&#xA;&quot;prettier.tslintIntegration&quot;: true,&#xA;&quot;prettier.stylelintIntegration&quot;: true,&#xA;coc.preferences.formatOnSaveFiletypes&quot;: [&quot;typescriptreact&quot;],&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When a &lt;code&gt;tsx&lt;/code&gt; is saved, it formats the file but it is logging following warning messages.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[coc.nvim] error: Warning: The 'no-array-mutation' rule requires type information.&#xA;[coc.nvim] error: Warning: The 'no-object-mutation' rule requires type information.&#xA;[coc.nvim] error: Warning: The 'promise-function-async' rule requires type information.&#xA;[coc.nvim] error: Warning: The 'await-promise' rule requires type information.&#xA;[coc.nvim] error: Warning: The 'no-floating-promises' rule requires type information.&#xA;[coc.nvim] error: Warning: The 'no-for-in-array' rule requires type information.&#xA;[coc.nvim] error: Warning: The 'no-inferred-empty-object-type' rule requires type information.&#xA;[coc.nvim] error: Warning: The 'no-null-undefined-union' rule requires type information.&#xA;[coc.nvim] error: Warning: The 'no-restricted-globals' rule requires type information.&#xA;[coc.nvim] error: Warning: The 'no-unbound-method' rule requires type information.&#xA;[coc.nvim] error: Warning: The 'no-unsafe-any' rule requires type information.&#xA;[coc.nvim] error: Warning: The 'no-void-expression' rule requires type information.&#xA;[coc.nvim] error: Warning: The 'restrict-plus-operands' rule requires type information.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I enable type information for &lt;code&gt;coc.prettier&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="25016" LastEditorUserId="1155" LastEditDate="2019-11-04T08:33:23.103" LastActivityDate="2024-02-22T21:00:25.063" Title="(coc.nvim) error: Warning: The 'x' rule requires type information" Tags="|neovim|plugin-coc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21742" PostTypeId="2" ParentId="21741" CreationDate="2019-11-01T19:27:49.607" Score="0" Body="&lt;p&gt;After a quick &lt;a href=&quot;https://www.google.com/search?client=safari&amp;amp;rls=en&amp;amp;q=%5Bcoc.nvim%5D+error:+Warning:+The+%27no-array-mutation%27+rule+requires+type+information.&amp;amp;ie=UTF-8&amp;amp;oe=UTF-8&quot; rel=&quot;nofollow noreferrer&quot;&gt;google&lt;/a&gt;, I found &lt;a href=&quot;https://github.com/wbuchwalter/tslint-loader/issues/107&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;, which suggests this is not a coc.nvim issue, but a typescript configuration issue.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;my understanding is you'd need to provide the &lt;code&gt;typeCheck: true&lt;/code&gt; config option to ts-loader, at the cost of tslint running slower&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That said, the issue hasn't had much activity in a year.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-01T19:27:49.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21743" PostTypeId="2" ParentId="6858" CreationDate="2019-11-02T07:51:47.027" Score="0" Body="&lt;p&gt;I had this problem when the colorscheme name (as in &lt;code&gt;let g:colors_name = &quot;selenized&quot;&lt;/code&gt; inside colorscheme file) contained uppercase letters. Changing it to lowercase fixed the problem.&lt;/p&gt;&#xA;" OwnerUserId="836" LastActivityDate="2019-11-02T07:51:47.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21744" PostTypeId="1" CreationDate="2019-11-02T13:55:09.340" Score="1" ViewCount="146" Body="&lt;p&gt;I want a mapping that does it. &#xA;Apparently, it is not that simple.&#xA;Because first, it might decide to keep it commented when I press o.&#xA;And it behaves differently if it was copied by yy, insists adding additional &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;. &#xA;My best effort so far is this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MPf()&#xA;    let @+ =substitute(@+,&quot;\&amp;lt;NL&amp;gt;$&quot;,&quot;&quot;,'')&#xA;    exec &quot;norm x\&quot;+]P&quot;&#xA;endfunction&#xA;&#xA;&#xA;nnoremap mp o &amp;lt;esc&amp;gt;:s/[^ \t]//ge&amp;lt;CR&amp;gt;:call MPf()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I add a space so that  won't cancel indentation.&#xA;I delete every comment like char in a new line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But some combination of doing y/yy and when on indented line/unindent line originally still cause troubles. And somehow I don't get rid of the additional &lt;code&gt;\0&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-11-02T14:13:19.313" LastActivityDate="2019-11-02T14:26:30.960" Title="Paste into a new line and preserve indentation" Tags="|indentation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21745" PostTypeId="2" ParentId="21744" CreationDate="2019-11-02T14:21:13.087" Score="3" Body="&lt;p&gt;The command &lt;code&gt;]p&lt;/code&gt; does almost what you want, except it is not guaranteed to be linewise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;tpope/vim-unimpaired&lt;/code&gt; plugin it's already remapped to work linewise only, so if you use it (which I suggest anyway), you get it for free.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you can implement the same trick yourself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;]p :call &amp;lt;SID&amp;gt;putline(&quot;]p&quot;)&amp;lt;CR&amp;gt;&#xA;&#xA;function s:putline(how)&#xA;    let l:type = getregtype(v:register)&#xA;    call setreg(getreg(v:register), &quot;V&quot;)&#xA;    execute 'normal! &quot;' . v:register . a:how&#xA;    call setreg(getreg(v:register), l:type)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See plugin's source code for a more complete version.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-11-02T14:26:30.960" LastActivityDate="2019-11-02T14:26:30.960" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21747" PostTypeId="5" CreationDate="2019-11-02T15:29:13.007" Score="0" Body="&lt;p&gt;For questions about &lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;coc.nvim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What is it?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A plugin that&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Provides APIs that work on both vim8 and neovim&lt;/li&gt;&#xA;&lt;li&gt;Loads VSCode like extensions&lt;/li&gt;&#xA;&lt;li&gt;Is configured via jsonc configuration file&lt;/li&gt;&#xA;&lt;li&gt;Configures language servers that implements LSP&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Use this tag if you have a question about&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the plugin's usage&lt;/li&gt;&#xA;&lt;li&gt;customizing the plugin&lt;/li&gt;&#xA;&lt;li&gt;configuring the plugin&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Do not use this tag if&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the plugin is irrelevant to your question&lt;/li&gt;&#xA;&lt;li&gt;you want to file a bug about the plugin (use its &lt;a href=&quot;https://github.com/neoclide/coc.nvim/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue tracker&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="17515" LastEditorUserId="10604" LastEditDate="2019-11-02T16:44:19.750" LastActivityDate="2019-11-02T16:44:19.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21748" PostTypeId="4" CreationDate="2019-11-02T15:29:13.007" Score="0" Body="Intellisense engine for vim8 &amp; neovim, full language server protocol support as VSCode" OwnerUserId="17515" LastEditorUserId="17515" LastEditDate="2019-11-04T08:33:03.440" LastActivityDate="2019-11-04T08:33:03.440" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21749" PostTypeId="1" AcceptedAnswerId="21760" CreationDate="2019-11-02T17:12:22.677" Score="0" ViewCount="59" Body="&lt;p&gt;In visual mode, the &lt;code&gt;iw&lt;/code&gt; text object 'grows' with repeated presses of &lt;code&gt;iw&lt;/code&gt;, ie., &lt;code&gt;viwiwiw...&lt;/code&gt; will 'grow' to select multiple inner words.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this 'growing' behaviour is not seen when the cursor is placed on a single space. For example, pressing &lt;code&gt;viwiw&lt;/code&gt; on &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;word1 word2 word3&#xA;     ^ &amp;lt;-- cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;only selects the space (I expect 'word2' to be selected). This seems unexpected to me. Could this be a bug?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With multiple spaces, such as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;word1   word2 word3&#xA;      ^ &amp;lt;-- cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the selection grows as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(FYI, I am using gvim 8.1.2019, windows 64-bit)&lt;/p&gt;&#xA;" OwnerUserId="21495" LastActivityDate="2019-11-03T06:10:42.200" Title="'visual inner word' on single space does not grow selection" Tags="|visual-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21750" PostTypeId="1" CreationDate="2019-11-02T17:53:01.327" Score="2" ViewCount="280" Body="&lt;p&gt;The + register always worked weird for me but only now I noticed a regularity in the weirdness: after I quit vim I can't paste anymore, it's as if the clipboard was replaced with a blank. Why, and can I change it to keep the copied text?&lt;/p&gt;&#xA;" OwnerUserId="25509" LastEditorUserId="28" LastEditDate="2019-12-16T19:14:11.217" LastActivityDate="2019-12-16T19:14:11.217" Title="Why do I lose what I copied with &quot;+y after exiting vim, and how to change that?" Tags="|cut-copy-paste|register|" AnswerCount="1" CommentCount="1" ClosedDate="2019-11-05T09:48:01.257" ContentLicense="CC BY-SA 4.0" />
  <row Id="21751" PostTypeId="2" ParentId="4714" CreationDate="2019-11-02T18:15:39.397" Score="0" Body="&lt;p&gt;First you must compile your doc with synctex option:&#xA;To do reverse search add the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Adding reverse search between gvim and zathura&#xA;set synctex true&#xA;set synctex-editor-command &quot;gvim --remote-silent +%{line} %{input}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your zathurarc file (Usually it can be find in your $HOME/.config/zathura folder). &#xA;You can jump to line 150 column 2 by running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;zathura --synctex-forward 150:2:foo.tex foo.pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://magmath.com/vim-how-to-use-reverse-and-forward-search-with-vim-and-zathura.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to do reverse and forward search using vim and zathura&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="14422" LastEditorUserId="1841" LastEditDate="2019-11-04T08:32:22.997" LastActivityDate="2019-11-04T08:32:22.997" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21753" PostTypeId="1" AcceptedAnswerId="21756" CreationDate="2019-11-02T20:34:59.210" Score="0" ViewCount="73" Body="&lt;p&gt;I know that vim has a function &lt;code&gt;wordcount()&lt;/code&gt; that returns a dictionary containing the number of bytes, lines, words etc in the current buffer. The problem I have is that the &lt;code&gt;words&lt;/code&gt; field of the dict from &lt;code&gt;wordcount()&lt;/code&gt; seems to include the number of &lt;code&gt;WORD&lt;/code&gt;s (vim's term for any sequence of chars that are not a whitespace character). For example, given:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# a markdown title&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in a buffer, &lt;code&gt;wordcount()['words']&lt;/code&gt; returns 4, because the &quot;#&quot; counts as a word to vim. Is there some way I can count &lt;strong&gt;only&lt;/strong&gt; the alphanumerical words in a buffer? I know I can use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\w\+//eng&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but redirecting the output is cumbersome and slow if I want to have a constant word count (say, in the statusline). I need this for writing assignments.&lt;/p&gt;&#xA;" OwnerUserId="25512" LastActivityDate="2022-03-08T02:35:36.593" Title="Vim wordcount for alphanumeric characters only" Tags="|word-processing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21754" PostTypeId="1" CreationDate="2019-11-02T20:49:37.377" Score="1" ViewCount="353" Body="&lt;p&gt;I have just upgraded to Fedora 31 and see that my gVim with &lt;code&gt;Terminus 12&lt;/code&gt; font looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mmRxF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mmRxF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Resetting the &lt;code&gt;guifont&lt;/code&gt; option gives me a reasonable looking gVim back. How can I further diagnose this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just out of interest I have tried the other decent font option for me, &lt;code&gt;Noto Mono 12&lt;/code&gt;, and got this here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zC4Fr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zC4Fr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The spacing is really odd, and I do not know where it comes from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Konsole terminal application can still use the Terminus font just fine. This is simple Vim opened up in the Terminal:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KsuY2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KsuY2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5210" LastEditorUserId="10604" LastEditDate="2019-11-03T03:45:03.343" LastActivityDate="2019-11-03T03:45:03.343" Title="Terminus font broken in gVim on Fedora 31" Tags="|font|encoding|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21756" PostTypeId="2" ParentId="21753" CreationDate="2019-11-02T21:25:01.473" Score="1" Body="&lt;p&gt;You can &lt;code&gt;split()&lt;/code&gt; on non-word characters and count the number of resulting words.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let cnt=0 | g/./let cnt+=len(split(getline('.'), '\W\+'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-02T21:25:01.473" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21757" PostTypeId="1" AcceptedAnswerId="21767" CreationDate="2019-11-02T22:47:58.577" Score="1" ViewCount="128" Body="&lt;p&gt;I have both vimtex and surround plugins installed(and ultisnip if matters). &#xA;When doing surround in visual mode (using &lt;code&gt;S&lt;/code&gt;) on a tex file, and when I press &lt;code&gt;\&lt;/code&gt; next I get immediately &lt;code&gt;\begin&lt;/code&gt;. I am not sure how to change this.&#xA;I want to surround by &lt;code&gt;\{&lt;/code&gt; sometimes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;S&lt;/code&gt; in visual mode mapped to &lt;code&gt;&amp;lt;plug&amp;gt;VSurround&lt;/code&gt;)  &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="1292" LastEditDate="2019-11-03T08:12:23.660" LastActivityDate="2019-11-04T03:16:12.247" Title="Surround on tex files" Tags="|plugin-vimtex|plugin-vim-surround|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21758" PostTypeId="1" AcceptedAnswerId="21761" CreationDate="2019-11-03T01:04:06.083" Score="1" ViewCount="939" Body="&lt;p&gt;I am currently using the following mapping to search for knows tags:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;t &quot;&amp;lt;ESC&amp;gt;:tselect /&quot; . input(&quot;&quot;) . &quot;&amp;lt;ESC&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also use this mapping to grep all files below the closest &lt;code&gt;tags&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;g &quot;&amp;lt;ESC&amp;gt;:vimgrep /&quot; &#xA;\ . escape(input('/'), '/') &#xA;\ . &quot;/ &quot; &#xA;\ . fnamemodify(findfile('tags', ';'), ':p:h') &#xA;\ . &quot;/**&amp;lt;CR&amp;gt;:cope&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there an easy way to get &lt;code&gt;:tselect&lt;/code&gt; results to show up in the &lt;code&gt;quickfix&lt;/code&gt; menu, so that I can browse and preview the buffers that contain the matches?&lt;/li&gt;&#xA;&lt;li&gt;For &lt;code&gt;:vimgrep&lt;/code&gt;, how can I show just the menu, rather than automatically opening matches?&lt;/li&gt;&#xA;&lt;li&gt;Is there a way to open the selected result from the menu in a new split, or replace the current buffer based on user input?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; &lt;em&gt;I am trying to learn more about Vim, so I prefer to not just install plugins.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="25455" LastEditorUserId="205" LastEditDate="2019-11-06T06:47:53.497" LastActivityDate="2019-11-06T06:47:53.497" Title="quickfix Menu Usage With :tselect and :vimgrep" Tags="|quickfix|tags|ctags|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21759" PostTypeId="2" ParentId="21758" CreationDate="2019-11-03T03:56:48.433" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;Check out &lt;code&gt;:help taglist()&lt;/code&gt;—it returns a dictionary of tag-related items. Unfortunately, the quickfix list works with exact locations (file, line, and column). Tags provide  an Ex command to get to the tag, often a special search pattern. (Example from some vimscript: &lt;code&gt;&amp;lt;C-y&amp;gt;  ../links/vim/plugin/pbcopy_op.vim   /^vnoremap &amp;lt;silent&amp;gt; &amp;lt;C-y&amp;gt; :&amp;lt;C-u&amp;gt;call pbcopy#operator(visualmode(), 1)&amp;lt;CR&amp;gt;$/;&quot;&#xA;&lt;/code&gt;—we get a tag name, file, and search command, rather than line numbers and such.) So it may be difficult to get these matches into the quickfix list. &lt;strong&gt;But&lt;/strong&gt; the function does give you enough information to build your own &quot;tag list&quot; buffer from which you could navigate.&lt;/li&gt;&#xA;&lt;li&gt;Use the &lt;code&gt;/j&lt;/code&gt; flag: &lt;code&gt;vimgrep /pattern/j | copen&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;From &lt;code&gt;:help quickfix-window&lt;/code&gt;: &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                    *CTRL-W_&amp;lt;Enter&amp;gt;* *CTRL-W_&amp;lt;CR&amp;gt;*&#xA;You can use CTRL-W &amp;lt;Enter&amp;gt; to open a new window and jump to the error there.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-03T03:56:48.433" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21760" PostTypeId="2" ParentId="21749" CreationDate="2019-11-03T05:41:29.907" Score="2" Body="&lt;p&gt;Seems like it's working logically to me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The docs (&lt;code&gt;:h text-objects&lt;/code&gt;) give us three &quot;rules&quot;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;&quot;a&quot; commands: select &quot;a&quot;n object including white space&lt;/li&gt;&#xA;  &lt;li&gt;&quot;i&quot; commands: select an &quot;inner&quot; object without white space OR just the white space&lt;/li&gt;&#xA;  &lt;li&gt;the &quot;inner&quot; commands always select less text than the &quot;a&quot; commands.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There's also an unwritten rule that the selection should include already selected text (in our case the single character selected after hitting &lt;code&gt;v&lt;/code&gt;). I think the behavior most users expect is selection expansion not selection replacement where some selected text is deselected. Certainly we don't want to do expansion in some cases and replacement in others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, one has to accept that &lt;code&gt;iwiw&lt;/code&gt; is not the same as &lt;code&gt;2iw&lt;/code&gt;. The former is two atomic operations, the latter one. That is, as soon as we hit the first &lt;code&gt;w&lt;/code&gt; in &lt;code&gt;iwiw&lt;/code&gt; Vim acts before continuing to process our input. So we can't expect the two input sequences to always behave exactly the same way even if, in practice, they do for most circumstances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's look at examples. When in visual mode, on a line with &quot;The quick brown fox jumped...&quot; then, (replacing spaces with &quot;.&quot; just for readability&quot;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the cursor somewhere inside &lt;code&gt;quick&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;aw&lt;/code&gt; selects &lt;code&gt;quick.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;iw&lt;/code&gt; selects &lt;code&gt;quick&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2aw&lt;/code&gt; selects &lt;code&gt;quick.brown.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2iw&lt;/code&gt; selects &lt;code&gt;quick.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With the cursor on the space between &lt;code&gt;quick&lt;/code&gt; and &lt;code&gt;brown&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;aw&lt;/code&gt; selects &lt;code&gt;.brown&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;iw&lt;/code&gt; selects &lt;code&gt;.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2aw&lt;/code&gt; selects &lt;code&gt;.brown.fox&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;2iw&lt;/code&gt; selects &lt;code&gt;.brown&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To follow the rules above there's really no other behavior possible for &lt;code&gt;iw&lt;/code&gt; in the second scenario than remaining with a single space selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If instead selected text was:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.brown&lt;/code&gt; =&gt; violates &quot;object without white space OR just the white space&quot; rule as well as &quot;selects less than &lt;code&gt;aw&lt;/code&gt;&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;brown&lt;/code&gt; =&gt; violates unwritten rule of not deselecting currently selected text (selection replacement)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those are the only two alternatives that are remotely viable...and they don't follow the rules. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of this is a (long winded) way of saying this is just a matter of having some simple rules with less-than-ideal behavior for one edge case.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-11-03T06:10:42.200" LastActivityDate="2019-11-03T06:10:42.200" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21761" PostTypeId="2" ParentId="21758" CreationDate="2019-11-03T06:38:10.780" Score="5" Body="&lt;p&gt;You can use the &quot;:ltag&quot; command which adds the matching tags to the location&#xA;list for the current window. You can then use the location list commands to&#xA;browse the matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, the location list feature was originally developed in 2005 to add support&#xA;for this command.&lt;/p&gt;&#xA;" OwnerUserId="25517" LastEditorUserId="25517" LastEditDate="2019-11-03T06:53:59.613" LastActivityDate="2019-11-03T06:53:59.613" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21762" PostTypeId="1" AcceptedAnswerId="21764" CreationDate="2019-11-03T06:57:36.910" Score="1" ViewCount="53" Body="&lt;p&gt;When I split my window (&lt;code&gt;C-w v&lt;/code&gt;), is it possible to have the cursor automatically go to the new split right away?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I looked up &lt;code&gt;switchbuf&lt;/code&gt; but I think that's something else; having to do with buffers rather than windows?)&lt;/p&gt;&#xA;" OwnerUserId="158" LastEditorUserId="158" LastEditDate="2019-11-03T09:34:47.070" LastActivityDate="2019-11-03T09:59:38.387" Title="Is it possible to have the cursor follow a newly-created window?" Tags="|vim-windows|split|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21763" PostTypeId="2" ParentId="11609" CreationDate="2019-11-03T07:55:29.897" Score="3" Body="&lt;p&gt;For the sake of completeness, I'd like to mention the plugin-based option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use something like &lt;a href=&quot;https://github.com/dense-analysis/ale/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ALE&lt;/a&gt; which supports running your buffers through a beautifier on save, you could let &lt;a href=&quot;https://prettier.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Prettier&lt;/a&gt; handle rewrapping your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I accomplished that by putting this in &lt;code&gt;~/.vim/ftplugin/markdown.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:ale_fixers = ['prettier', 'remove_trailing_lines', 'trim_whitespace']&#xA;let b:ale_javascript_prettier_options = '--prose-wrap always'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and putting this in &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_fix_on_save = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20566" LastActivityDate="2019-11-03T07:55:29.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21764" PostTypeId="2" ParentId="21762" CreationDate="2019-11-03T09:59:38.387" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;When I split my window (C-w v), is it possible to have the cursor automatically go to the new split right away?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In fact, you &lt;em&gt;do move&lt;/em&gt; to the newly created window. The point is that it's opened on the left side by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to &lt;code&gt;set splitright&lt;/code&gt;. Be aware though, this option affects &lt;em&gt;all&lt;/em&gt; vertical split commands, not only &lt;code&gt;:vsplit&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-03T09:59:38.387" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21765" PostTypeId="2" ParentId="21750" CreationDate="2019-11-03T13:16:41.137" Score="0" Body="&lt;p&gt;I usually do below and works well for me on MacOS:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard=unnamedplus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This changes the default vim register to the &lt;code&gt;+&lt;/code&gt; register, which is linked to the system clipboard&lt;/p&gt;&#xA;" OwnerUserId="16898" LastEditorUserId="10604" LastEditDate="2019-11-03T18:31:07.630" LastActivityDate="2019-11-03T18:31:07.630" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21766" PostTypeId="2" ParentId="8757" CreationDate="2019-11-03T16:42:35.967" Score="6" Body="&lt;p&gt;The script that controls Vim's indentation of Python files is located at &lt;code&gt;$VIMRUNTIME/indent/python.vim&lt;/code&gt;. You can see the help file for it with &lt;code&gt;:help ft-python-indent&lt;/code&gt;. From that, we learn there are a few global variables that can be used to control the indentation's behaviour:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The amount of indent can be set for the following situations.  The examples&#xA;   given are the defaults.  Note that the variables are set to an expression, so&#xA;   that you can change the value of 'shiftwidth' later.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Indent after an open paren:&#xA;  let g:pyindent_open_paren = 'shiftwidth() * 2'&#xA;Indent after a nested paren:&#xA;  let g:pyindent_nested_paren = 'shiftwidth()'&#xA;Indent for a continuation line:&#xA;  let g:pyindent_continue = 'shiftwidth() * 2'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;With this in mind, to change the behaviour to the one you intend you can add the following to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:pyindent_open_paren = 'shiftwidth()'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="356" LastActivityDate="2019-11-03T16:42:35.967" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21767" PostTypeId="2" ParentId="21757" CreationDate="2019-11-04T03:10:52.317" Score="2" Body="&lt;p&gt;This behavior is from vim-surround. From its &lt;a href=&quot;https://github.com/tpope/vim-surround/blob/master/plugin/surround.vim#L212&quot; rel=&quot;nofollow noreferrer&quot;&gt;source code&lt;/a&gt;, pressing either &lt;code&gt;l&lt;/code&gt; or &lt;code&gt;\&lt;/code&gt; will result in &lt;code&gt;\begin&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To change the default behavior, refer to &lt;code&gt;:h surround-customizing&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First, find the number corresponding to &lt;code&gt;\&lt;/code&gt;. In this case, we would find it with &lt;code&gt;:echo char2nr(&quot;\\&quot;)&lt;/code&gt;, which gives &lt;code&gt;92&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then, declare the variable corresponding to this number. In this case, this would be&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:surround_92 = &quot;\\{ \r \\}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you prefer not to have a space betweeen the surroundings and the surrounded text, use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:surround_92 = &quot;\\{\r\\}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above, &lt;code&gt;\r&lt;/code&gt; is the placeholder for the surrounded text.&lt;br&gt;&#xA;Note that since our surroundings contain &lt;code&gt;\&lt;/code&gt;, we have to escape it by doubling the backslash.&lt;br&gt;&#xA;Also, since this is specific to .tex files, it is better to use &lt;code&gt;b:surround_92&lt;/code&gt; instead of &lt;code&gt;g:surround_92&lt;/code&gt;.   &lt;/p&gt;&#xA;" OwnerUserId="21495" LastEditorUserId="21495" LastEditDate="2019-11-04T03:16:12.247" LastActivityDate="2019-11-04T03:16:12.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21768" PostTypeId="1" CreationDate="2019-11-04T06:54:17.800" Score="2" ViewCount="1219" Body="&lt;p&gt;I am trying to set up syntax keyword based omnicompletion in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have defined a few &lt;code&gt;syntax keyword Constant&lt;/code&gt;s in &lt;code&gt;~/.config/nvim/syntax/spl.vim&lt;/code&gt;&lt;br&gt;&#xA;They are correctly detected and highlighted.&lt;br&gt;&#xA;They are also showing up in &lt;code&gt;:syntax list&lt;/code&gt; as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:syntax list                                                                                                 &#xA;--- Syntax items ---&#xA;Operator       xxx match #[=+\-*\/%]#&#xA;String         xxx match /&quot;.*&quot;/&#xA;Comment        xxx match +\/\/.*+&#xA;Constant       xxx SWAP_OUT FREE_PAGE_TABLE INT_CLOSE DISK_SIZE GET_CODE_PAGE IDLE_PROCESS INT_LOGOUT&#xA;                   CONTEXT_SWITCH MAX_FILE_SIZE INT_DELETE WAIT_TERMINAL INIT_PROCESS MAX_BUFFER&#xA;                   RESOURCE_TABLE_OFFSET PAGE_SIZE INODE_TABLE WAIT_DISK FILE &#xA;                   .. truncated ..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set omnifunc&lt;/code&gt; outputs &lt;code&gt;omnifunc=syntaxcomplete#Complete&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But still Ctrl+X Ctrl+O shows &lt;code&gt;Omni completion (^O^N^P) Pattern not found&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim version is: &lt;code&gt;NVIM v0.4.2&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ft?&#xA;  filetype=spl&#xA;scriptnames&#xA;  ...&#xA;  ftdetect/spl.vim&#xA;  syntax/spl.vim&#xA;  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25525" LastEditorUserId="10604" LastEditDate="2019-11-04T14:03:50.773" LastActivityDate="2021-03-30T23:23:58.547" Title="How to fix this `Omni completion (^O^N^P) Pattern not found` error?" Tags="|syntax-highlighting|autocompletion|filetype|syntax|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21769" PostTypeId="2" ParentId="5780" CreationDate="2019-11-04T09:59:59.097" Score="0" Body="&lt;p&gt;Try seeing in $VIMRUNTIME/syntax. Use :echo $VIMRUNTIME to know its value. In my computer, $VIMRUNTIME/syntax was /usr/share/vim/vim81/syntax. It has all the syntax files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a vim with gui, you can also use Syntax menu to get all the filetypes supported.&lt;/p&gt;&#xA;" OwnerUserId="17868" LastActivityDate="2019-11-04T09:59:59.097" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21770" PostTypeId="2" ParentId="6228" CreationDate="2019-11-04T11:12:40.780" Score="0" Body="&lt;p&gt;Install YouCompleteMe. When you place the cursor over an identifier, enter &lt;code&gt;YcmCompleter GetDoc&lt;/code&gt; command to get the doc in a little preview window at the bottom. It works across many languages like python and c/c++. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Youcompleteme also displays the preview window during its autocomplete feature. You can customize the behavior of the doc preview with &lt;code&gt;g:ycm_autoclose_preview_window_after_completion&lt;/code&gt; variable. &lt;/p&gt;&#xA;" OwnerUserId="25526" LastActivityDate="2019-11-04T11:12:40.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21771" PostTypeId="2" ParentId="21717" CreationDate="2019-11-04T12:10:10.627" Score="1" Body="&lt;p&gt;I finally resolved this by installed &lt;code&gt;python-language-server&lt;/code&gt; globally like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo -H pip install python-language-server&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know how popular a solution this will be, but it works for me, so I'm happy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the ale documentation for &lt;code&gt;ALEGoToDefinition&lt;/code&gt; says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Jump to the definition of a symbol under the cursor using the enabled LSP&#xA;linters for the buffer. ALE will jump to a definition if an LSP server&#xA;provides a location to jump to. Otherwise, ALE will do nothing.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the language server is probably necessary.&lt;/p&gt;&#xA;" OwnerUserId="2026" LastEditorUserId="10604" LastEditDate="2019-12-04T13:33:53.737" LastActivityDate="2019-12-04T13:33:53.737" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21772" PostTypeId="1" AcceptedAnswerId="21773" CreationDate="2019-11-04T15:55:48.123" Score="1" ViewCount="1431" Body="&lt;p&gt;Referring to answer from &lt;a href=&quot;https://vi.stackexchange.com/a/5614/20720&quot;&gt;this link.&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding two groups,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight MyGroup1 ctermbg=green guibg=green&#xA;:highlight MyGroup2 ctermbg=blue guibg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then adding two words &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;bar&lt;/code&gt; into specific groups.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd(&quot;MyGroup1&quot;, &quot;foo&quot;)&#xA;:call matchadd(&quot;MyGroup2&quot;, &quot;bar&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how to make sure that the exact words &lt;code&gt;foo&lt;/code&gt; is highlighted and not some conjunction word &lt;code&gt;bigwordwithfoo&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="20720" LastActivityDate="2019-11-04T16:23:10.380" Title="How to use matchadd to add exact word?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21773" PostTypeId="2" ParentId="21772" CreationDate="2019-11-04T16:23:10.380" Score="4" Body="&lt;p&gt;Use the &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; anchors around your pattern, to match word boundaries before and after your words.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call matchadd(&quot;MyGroup1&quot;, '\&amp;lt;foo\&amp;gt;')&#xA;:call matchadd(&quot;MyGroup2&quot;, '\&amp;lt;bar\&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need single quotes, to prevent Vim from using &lt;code&gt;\&lt;/code&gt; as an escape character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%3C&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\&amp;lt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help matchadd()&lt;/code&gt; for details on how pattern is used and matched.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help literal-string&lt;/code&gt; for how single quoted strings don't interpret backslashes as escape characters.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-11-04T16:23:10.380" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21774" PostTypeId="1" AcceptedAnswerId="21776" CreationDate="2019-11-04T18:05:10.757" Score="10" ViewCount="11623" Body="&lt;p&gt;I am using &lt;code&gt;coc.vim&lt;/code&gt; in neovim. &lt;code&gt;coc.vim&lt;/code&gt; suggests the following mapping for jumping to the definition of a class/method.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; gd &amp;lt;Plug&amp;gt;(coc-definition)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If there is only a single matching definition, pressing &lt;code&gt;gd&lt;/code&gt; will immediately open the definition in the current window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there are multiple matches, coc shows a preview window with the list of matching files. It is possible to scroll through the results with &lt;code&gt;j&lt;/code&gt;/&lt;code&gt;k&lt;/code&gt;. Pressing tab displays the following prompt, for opening the current selection.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Choose action:&#xA;[o]pen, (p)review, (q)uickfix, (t)abe, (d)rop, (v)split, (s)plit:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is the above prompt a standard part of &lt;code&gt;vim&lt;/code&gt; or is it part of &lt;code&gt;coc.vim&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Is it possible to force this prompt, even if there is only a single hit?&lt;/li&gt;&#xA;&lt;li&gt;If not, how can I force vim to open &lt;code&gt;coc-definition&lt;/code&gt; in a new vertical split?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="25529" LastActivityDate="2022-10-29T08:04:43.883" Title="open coc-definition in new split in coc" Tags="|neovim|plugin-coc|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21775" PostTypeId="1" AcceptedAnswerId="21777" CreationDate="2019-11-04T18:31:24.013" Score="0" ViewCount="433" Body="&lt;p&gt;Say I write an autocommand for a particular file to do something when I save it, such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost .Xresources silent! execute 'xrdb ~/.Xresources'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm doing it with &lt;code&gt;silent! execute&lt;/code&gt;, because if I only use&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufWritePost .Xresources !xrdb ~/.Xresources&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim would prompt for an enter. But I still want to see that the reload happened, which I thought could be handled with &lt;code&gt;echo&lt;/code&gt;, such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost .Xresources silent! execute 'xrdb ~/.Xresources' | echo 'Xresources reloaded'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But again this has the problem of prompting to &lt;code&gt;Press ENTER or type command to continue&lt;/code&gt;. Now there is &lt;code&gt;echon&lt;/code&gt; which does not do prompt for ENTER, but it also does not display the message, as saving the file with &lt;code&gt;:w&lt;/code&gt; causes &lt;code&gt;&quot;~/.Xresources&quot; 487L, 18435C written&lt;/code&gt; to be written to the status line instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the quation is, is there some way to run the autocommand such that it saves the file, runs the shell command, and echoes a confirmation message in the status line, without prompting the user to press ENTER, or interrupt in any other way?&lt;/p&gt;&#xA;" OwnerUserId="11916" LastActivityDate="2019-11-04T19:21:32.287" Title="How to echo a message in BufWritePost so that it writes over the &quot;~/.foo xxxL, xxC written&quot; status message?" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21776" PostTypeId="2" ParentId="21774" CreationDate="2019-11-04T18:40:50.357" Score="6" Body="&lt;p&gt;I inject my &lt;a href=&quot;https://github.com/LucHermitte/lh-misc/blob/master/vimrc_core.vim#L1130&quot; rel=&quot;nofollow noreferrer&quot;&gt;own way of opening files in CoC&lt;/a&gt; with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:coc_user_config = {}&#xA;let g:coc_user_config['coc.preferences.jumpCommand'] = ':SplitIfNotOpen4COC'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then the command is &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/plugin/lhvl.vim#L63&quot; rel=&quot;nofollow noreferrer&quot;&gt;defined in my lh-vim-lib plugin&lt;/a&gt; to search if the buffer is already opened or not. Having more control is possible.&lt;/p&gt;&#xA;&lt;p&gt;To use the prompt already provided by CoC, you may have to search in its source code.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2020-08-28T15:29:53.690" LastActivityDate="2020-08-28T15:29:53.690" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21777" PostTypeId="2" ParentId="21775" CreationDate="2019-11-04T19:10:14.307" Score="1" Body="&lt;p&gt;I'm not sure if the exact behavior you want is achievable. If it is it'll probably involve use of the &lt;code&gt;:redraw&lt;/code&gt; command (or &lt;code&gt;Ctrl-L&lt;/code&gt; in Normal mode). I haven't found the magic combo but can propose a couple &quot;workarounds&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't mind having the message displayed for a limited amount of time before it disappears you could try something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;snip&amp;gt; silent! execute 'xrdb ~/.Xresources' | echo 'Xresources reloaded' | sleep 2 | redraw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, if you don't always need to see the confirmation and just want a way to check it explicitly now and then you could use &lt;code&gt;echom&lt;/code&gt; and look for the message manually with &lt;code&gt;:mess&lt;/code&gt; (or &lt;code&gt;:1mess&lt;/code&gt; if looking for it immediately after the autocommand runs).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;yadda yadda&amp;gt; silent! execute 'xrdb ~/.Xresources' | echom 'Xresources reloaded' | redraw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Still, I'll see if I can find the ideal solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Actually...just swapping the &lt;code&gt;echo&lt;/code&gt; and &lt;code&gt;redraw&lt;/code&gt; positions might be the ticket! &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;yadda yadda&amp;gt; execute 'xrdb ~/.Xresources' | redraw | echo 'Xresources reloaded'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Bonus: you might not need &lt;code&gt;silent&lt;/code&gt; either. I've left it off but if your screen is getting jumpy or something then you can include it. Depends, at least in part, on how much output &lt;code&gt;xrdb&lt;/code&gt; has.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have &lt;code&gt;xrdb&lt;/code&gt; and what not so I was faking it with other shell commands so you'll need to verify.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(BTW, are you missing a bang &lt;code&gt;!&lt;/code&gt; before &lt;code&gt;xrdb&lt;/code&gt;? Thought it was an external command..)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-11-04T19:21:32.287" LastActivityDate="2019-11-04T19:21:32.287" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21778" PostTypeId="1" CreationDate="2019-11-04T20:09:33.340" Score="1" ViewCount="162" Body="&lt;p&gt;When using autocompletion with &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt;, if no matching string is found, vim shows the message &lt;code&gt;Pattern not found&lt;/code&gt; into the status bar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried something with this simple function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TestCN()&#xA;&#xA;    let l:retval = 0&#xA;&#xA;    try &quot;\i&amp;lt;C-n&amp;gt;&quot;&#xA;    catch /.*/&#xA;        &quot; should catch Pattern not Found here&quot;&#xA;        let l:retval = 1&#xA;    endtry&#xA;&#xA;    return l:retval&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to &lt;em&gt;test&lt;/em&gt; &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; with a &lt;code&gt;try-catch&lt;/code&gt; block to test if autocompletition should fail with &quot;Pattern not found&quot; (or any other way) ?&lt;/p&gt;&#xA;" OwnerUserId="15254" LastActivityDate="2019-11-05T09:04:33.027" Title="C-N using try-catch" Tags="|autocompletion|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21779" PostTypeId="2" ParentId="21778" CreationDate="2019-11-04T20:40:36.823" Score="1" Body="&lt;p&gt;To actually trigger the completion dropdown I think your best bet is to use &lt;code&gt;feedkeys()&lt;/code&gt; which more closely simulates a user entering text through a keyboard...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;try &#xA;    call feedkeys(&quot;i\&amp;lt;C-n&amp;gt;&quot;)&#xA;catch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This shows the completion dropdown for me. When the cursor follows text that won't result in any completion candidates I do see the &quot;Pattern not found&quot; message briefly at the bottom of the screen but control does not enter the &lt;code&gt;catch&lt;/code&gt; block that I can see. Could be as @D.BenKnoble mentioned in his comment that this isn't an &quot;official&quot;, catchable EXXX error...which kind of makes sense as this is not really a fault condition. Just a state to communicate.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-11-04T20:46:34.447" LastActivityDate="2019-11-04T20:46:34.447" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21780" PostTypeId="1" CreationDate="2019-11-04T20:49:12.420" Score="0" ViewCount="165" Body="&lt;p&gt;I have the following in my init.vim (neovim):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap i k&#xA;nnoremap j h&#xA;nnoremap k j&#xA;xnoremap i k&#xA;xnoremap j h&#xA;xnoremap k j&#xA;nnoremap h i&#xA;nnoremap H I&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I find this arrow key-like configuration much more comfortable, and aside from a few edge cases where plugins define special windows and don't expose movement remapping, it didn't seem to break anything...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...until I tried to use &lt;code&gt;viw&lt;/code&gt;, i.e. select inner word from normal mode. What happens now is that after pressing &lt;code&gt;vi&lt;/code&gt;, vim either waits &lt;code&gt;timeoutlen&lt;/code&gt; for a key sequence and then moves the cursor up a line, or cancels the sequence if &lt;code&gt;w&lt;/code&gt; is pressed and executes the normal &lt;code&gt;w&lt;/code&gt; action, i.e. move to the beginning of the next word. Pressing &lt;code&gt;i&lt;/code&gt; again while in visual mode starts another sequence countdown, so upward movement is also a bit jerky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty sure I understand why the sequence countdown happens, namely that &lt;code&gt;i&lt;/code&gt; is ambiguous between &quot;move up a line&quot; and &quot;start of a text object,&quot; but I don't understand why &lt;code&gt;w&lt;/code&gt; cancels the text object sequence instead of completing it. Note that this is true for all text objects, e.g. &lt;code&gt;s&lt;/code&gt; or &lt;code&gt;(&lt;/code&gt;. Is this expected behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I would like behavior like the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;After entering visual mode, wait &lt;code&gt;timeoutlen&lt;/code&gt; for a sequence to begin&lt;/li&gt;&#xA;&lt;li&gt;If a sequence is begun, wait indefinitely for it to be completed or canceled with an invalid key press&lt;/li&gt;&#xA;&lt;li&gt;If no sequence is begun or (2) completes, thereafter ignore sequences until visual mode is exited&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Intuitively, this might not be scriptable, but any help would be appreciated. As a fallback, I would at least like for &lt;code&gt;iw&lt;/code&gt; to work as expected in visual mode.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; @d-ben-knoble's answer doesn't quite get to the why of this, so I'm leaving the question unanswered in case anyone wants to take a whack at what exactly is going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, you'll all be proud I'm sure to know that there's officially an &lt;code&gt;hjkl&lt;/code&gt; branch in my dot files repo now. It's actually not as bad as I remember. I think it was overwhelming when I was first learning vim and everything was new, so I used arrows for a while, then realized having to move my hand to transition in and out of insert mode sucked and ended up in the situation described above. I guess &lt;code&gt;hjkl&lt;/code&gt; is the last step of the indoctrination process :)&lt;/p&gt;&#xA;" OwnerUserId="25078" LastEditorUserId="25078" LastEditDate="2019-11-09T17:41:20.340" LastActivityDate="2019-11-09T17:41:20.340" Title="viw breaks when i is remapped" Tags="|key-bindings|visual-mode|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21781" PostTypeId="2" ParentId="21780" CreationDate="2019-11-05T00:15:22.590" Score="4" Body="&lt;p&gt;First, terminology:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a &lt;strong&gt;chord&lt;/strong&gt; is a key-combination like &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;w&lt;/kbd&gt;—it is so-called because it is like the chords a pianist plays, with many keys pressed&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;iw&lt;/code&gt; is really more of a key sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;/end pendantry :)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your visual-mode mappings are screwing with the usual &lt;code&gt;iw&lt;/code&gt; sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once started with &lt;code&gt;v&lt;/code&gt;, Visual mode does what you tell it to. In this case, you've sent it &lt;code&gt;i&lt;/code&gt;—which could be the start of a text-object like &lt;code&gt;i(&lt;/code&gt;, or it could be your mapping. You can also give regular motions (like &lt;code&gt;w&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If it's your mapping, it does the &lt;code&gt;k&lt;/code&gt; motion (up).&lt;/li&gt;&#xA;&lt;li&gt;If it's a sequence, well, as best I can tell, it moves up (&lt;code&gt;i -&amp;gt; k&lt;/code&gt;), then moves, e.g., to the next &lt;code&gt;w&lt;/code&gt;ord.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how to achieve your desires, but a couple of things come to mind:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It will be easier for you in the long run if you just get used to &lt;code&gt;hjkl&lt;/code&gt;—&lt;code&gt;less(1)&lt;/code&gt; (and therefore &lt;code&gt;man(1)&lt;/code&gt;) and plenty of other programs use them. Even gmail. Trust me on this one. It's &lt;em&gt;more&lt;/em&gt; complicated to screw with this then it's worth.&lt;/li&gt;&#xA;&lt;li&gt;If you insist, you &lt;em&gt;could&lt;/em&gt; do something like override all the text objects (&lt;code&gt;xnoremap iw iw&lt;/code&gt; or something), or&lt;/li&gt;&#xA;&lt;li&gt;You could have a look at &lt;code&gt;langmap&lt;/code&gt; (for Normal mode translation) and &lt;code&gt;keymap&lt;/code&gt; (for Insert mode translation). These are commonly used by folks with non-qwerty keyboards but who have grown used to the placement of qwerty keys in vim.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-11-05T17:47:36.077" LastActivityDate="2019-11-05T17:47:36.077" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21782" PostTypeId="1" AcceptedAnswerId="21789" CreationDate="2019-11-05T03:43:14.540" Score="3" ViewCount="105" Body="&lt;p&gt;On Windows with an installation of gvim 8.1, Numpad behavior is different between the GUI and the console.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The GUI (&lt;code&gt;gvim.exe&lt;/code&gt;) has a &lt;code&gt;TERM&lt;/code&gt; of &lt;code&gt;builtin_gui&lt;/code&gt; and the keypad (with Numlock On) works properly.  By properly, I mean in insert mode, when you hit &lt;kbd&gt;Num 0&lt;/kbd&gt;, it inserts a &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the console version (&lt;code&gt;vim.exe&lt;/code&gt;) has a &lt;code&gt;TERM&lt;/code&gt; of &lt;code&gt;win32&lt;/code&gt; and the keypad (with Numlock On) inserts extended characters such as:&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;0&quot;&gt;&#xA;&lt;li&gt;╬┌&lt;/li&gt;&#xA;&lt;li&gt;╬▐&lt;/li&gt;&#xA;&lt;li&gt;╬&amp;Gamma;&lt;/li&gt;&#xA;&lt;li&gt;╬&amp;micro;&lt;/li&gt;&#xA;&lt;li&gt;╬&amp;Omega;&lt;/li&gt;&#xA;&lt;li&gt;╬&amp;epsilon;&lt;/li&gt;&#xA;&lt;li&gt;╬&amp;ge;&lt;/li&gt;&#xA;&lt;li&gt;╬&amp;divide;&lt;/li&gt;&#xA;&lt;li&gt;╬&amp;nbsp;&amp;middot;&lt;/li&gt;&#xA;&lt;li&gt;╬■&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How would I go about changing the behavior of the numpad in the console?  I have tried looking at the default vimscripts such as &lt;code&gt;mswin.vim&lt;/code&gt; to see if there is any obvious behavior that could affect the function of the numpad, but I didn't see anything.  I also searched Google and vi SE, but all answers I seemed to find had to do with the various terminal programs that people were using.  This issue is when using &lt;code&gt;vim.exe&lt;/code&gt; within the native Windows command prompt.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Providing Version information below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled May 18 2018 18:26:56)&#xA;MS-Windows 32-bit console version&#xA;Included patches: 1&#xA;Compiled by mool@tororo&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               +eval              -mouseshape        -tag_any_white&#xA;+arabic            +ex_extra          +multi_byte        -tcl&#xA;+autocmd           +extra_search      +multi_lang        +termguicolors&#xA;+autoservername    +farsi             -mzscheme          +terminal&#xA;-balloon_eval      +file_in_path      -netbeans_intg     -tgetent&#xA;+balloon_eval_term +find_in_path      +num64             -termresponse&#xA;-browse            +float             +packages          +textobjects&#xA;++builtin_terms    +folding           +path_extra        +timers&#xA;+byte_offset       -footer            -perl              +title&#xA;+channel           +gettext/dyn       +persistent_undo   -toolbar&#xA;+cindent           -hangul_input      -postscript        +user_commands&#xA;+clientserver      +iconv/dyn         +printer           +vertsplit&#xA;+clipboard         +insert_expand     +profile           +virtualedit&#xA;+cmdline_compl     +job               -python            +visual&#xA;+cmdline_hist      +jumplist          -python3           +visualextra&#xA;+cmdline_info      +keymap            +quickfix          +viminfo&#xA;+comments          +lambda            +reltime           +vreplace&#xA;+conceal           +langmap           +rightleft         +vtp&#xA;+cryptv            +libcall           -ruby              +wildignore&#xA;+cscope            +linebreak         +scrollbind        +wildmenu&#xA;+cursorbind        +lispindent        +signs             +windows&#xA;+cursorshape       +listcmds          +smartindent       +writebackup&#xA;+dialog_con        +localmap          +startuptime       -xfontset&#xA;+diff              -lua               +statusline        -xim&#xA;+digraphs          +menu              -sun_workshop      -xpm_w32&#xA;-dnd               +mksession         +syntax            -xterm_save&#xA;-ebcdic            +modify_fname      +tag_binary&#xA;+emacs_tags        +mouse             +tag_old_static&#xA;   system vimrc file: &quot;$VIM\vimrc&quot;&#xA;     user vimrc file: &quot;$HOME\_vimrc&quot;&#xA; 2nd user vimrc file: &quot;$HOME\vimfiles\vimrc&quot;&#xA; 3rd user vimrc file: &quot;$VIM\_vimrc&quot;&#xA;      user exrc file: &quot;$HOME\_exrc&quot;&#xA;  2nd user exrc file: &quot;$VIM\_exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME\defaults.vim&quot;&#xA;Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL  -DFEAT_JOB_CHANNEL      -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG /arch:IA32 /Zl /MT -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_HUGE /Fd.\ObjCi386/ /Zi&#xA;Linking: link  /nologo /subsystem:console,5.01 /opt:ref /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib uuid.lib /machine:i386   libcmt.lib  user32.lib          WSock32.lib  /PDB:vim.pdb -debug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18409" LastEditorUserId="18409" LastEditDate="2019-11-05T17:14:18.490" LastActivityDate="2019-11-05T19:06:19.527" Title="Numpad behavior incorrect with vim.exe - Windows" Tags="|terminal|microsoft-windows|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21783" PostTypeId="2" ParentId="21778" CreationDate="2019-11-05T09:04:33.027" Score="1" Body="&lt;p&gt;I agree with @D.BenKnoble's comment that &lt;em&gt;Pattern not found&lt;/em&gt; is not strictly an error, more of an exceptional condition, and therefore doesn't have an &lt;code&gt;E...&lt;/code&gt; number and no way to &lt;code&gt;:catch&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use the completion menu, you could use &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#pumvisible%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help pumvisible()&lt;/code&gt;&lt;/a&gt; to use the side effect of showing (or not) the menu in case of matches. Also, there's the &lt;a href=&quot;https://vimhelp.appspot.com/autocmd.txt.html#CompleteDone&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help CompleteDone&lt;/code&gt;&lt;/a&gt; event that you can hook into. Getting this right under all circumstances can be difficult, though. Rather than trying to implement this on your own, have a look at plugins like &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1643&quot; rel=&quot;nofollow noreferrer&quot;&gt;SuperTab&lt;/a&gt;; they may also suit your needs.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-05T09:04:33.027" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21784" PostTypeId="1" CreationDate="2019-11-05T10:34:54.607" Score="11" ViewCount="1240" Body="&lt;p&gt;I work with many terminals, and very often hit the case where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a vim instance holds &lt;code&gt;~/sm/file&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;I open another instance on the same file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My choice is always &lt;code&gt;:(E)dit&lt;/code&gt; without prompting ...&#xA;So I'd like vi to &quot;remember my choice&quot; for every file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many posts explain how to ignore swap files. &lt;strong&gt;* That is not what I want :) *&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The typical, well known message is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;E325: ATTENTION&#xA;Found a swap file by the name &quot;~/sm/.file.swp&quot;&#xA;          owned by: FRY02339   dated: Tue Oct 29 10:41:13 2019&#xA;         file name: ~FRY02339/sm/file&#xA;          modified: no&#xA;         user name: FRY02339    host name: shinwey&#xA;        process ID: 60165 (still running)&#xA;While opening file &quot;/home/FRY02339/sm/file&quot;&#xA;             dated: Tue Oct 29 10:41:09 2019&#xA;&#xA;(1) Another program may be editing the same file.  If this is the case,&#xA;    be careful not to end up with two different instances of the same&#xA;    file when making changes.  Quit, or continue with caution.&#xA;(2) An edit session for this file crashed.&#xA;    If this is the case, use &quot;:recover&quot; or &quot;vim -r /home/FRY02339/sm/file&quot;&#xA;    to recover the changes (see &quot;:help recovery&quot;).&#xA;    If you did this already, delete the swap file &quot;/home/FRY02339/sm/.file.swp&quot;&#xA;    to avoid this message.&#xA;&#xA;Swap file &quot;~/sm/.file.swp&quot; already exists!&#xA;[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you have any hint ?&lt;/p&gt;&#xA;" OwnerUserId="24877" LastEditorUserId="1841" LastEditDate="2019-11-05T12:40:18.020" LastActivityDate="2019-11-05T12:40:18.020" Title="vim: (E)dit anyway without prompting" Tags="|swap-file|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21785" PostTypeId="2" ParentId="21784" CreationDate="2019-11-05T10:39:55.890" Score="15" Body="&lt;p&gt;Through the &lt;a href=&quot;https://vimhelp.appspot.com/autocmd.txt.html#SwapExists&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;SwapExists&lt;/code&gt;&lt;/a&gt; event, you can influence the choice (and skip the dialog) by setting the special &lt;code&gt;v:swapchoice&lt;/code&gt; variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd SwapExists * let v:swapchoice = &quot;e&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I personally would at least add an &lt;code&gt;| echomsg &quot;Concurrent editing&quot;&lt;/code&gt; to notify that there's concurrent editing going on.)&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-05T10:39:55.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21786" PostTypeId="1" CreationDate="2019-11-05T12:22:15.097" Score="4" ViewCount="473" Body="&lt;p&gt;I use konsole terminal emulator and I am facing an issue with changing the font size in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I add the following snippet into my &lt;code&gt;.vimrc&lt;/code&gt;. In the vim application, the font size will snap back to the original value as seen in the gif. Note that in the video, &lt;code&gt;Ctrl =&lt;/code&gt; binding is used to increase the font size of my terminal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Change cursor in the various different mode&#xA;let &amp;amp;t_SI = &quot;\&amp;lt;Esc&amp;gt;]50;CursorShape=1\x7&quot;&#xA;let &amp;amp;t_SR = &quot;\&amp;lt;Esc&amp;gt;]50;CursorShape=2\x7&quot;&#xA;let &amp;amp;t_EI = &quot;\&amp;lt;Esc&amp;gt;]50;CursorShape=0\x7&quot;&#xA;if exists('$TMUX')&#xA;  let &amp;amp;t_SI = &quot;\ePtmux;\e&quot; . &amp;amp;t_SI . &quot;\e\\&quot;&#xA;  let &amp;amp;t_EI = &quot;\ePtmux;\e&quot; . &amp;amp;t_EI . &quot;\e\\&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YgSS4.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YgSS4.gif&quot; alt=&quot;Don&amp;#39;t work&quot;&gt;&lt;/a&gt;&#xA;However, once I remove the following snippet it works as intended.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/2yY0O.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2yY0O.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25538" LastEditorUserId="9333" LastEditDate="2019-11-22T05:50:32.083" LastActivityDate="2019-11-22T05:50:32.083" Title="Issues in changing font size in vim" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21787" PostTypeId="1" CreationDate="2019-11-05T13:54:08.197" Score="1" ViewCount="631" Body="&lt;p&gt;I am using a vimscript to &quot;highlight&quot; columns of interest in some text.&#xA;However, using &lt;code&gt;colorcolumn&lt;/code&gt; &quot;highlights&quot; the entire column on every row in the file.&#xA;Is there a good way to define start and end rows for the &lt;code&gt;colorcolumn&lt;/code&gt; to be applied on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information:&#xA;1. I know the row numbers I would like to highlight , so the solution should be based on row numbers.&#xA;2. I expect this to be a buffer and/or window setting , not a global setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="25541" LastEditorUserId="25541" LastEditDate="2019-11-05T14:16:31.527" LastActivityDate="2019-11-07T11:23:41.847" Title="Is it possible to use colorcolumn on specific lines only" Tags="|colorcolumn|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21788" PostTypeId="2" ParentId="21787" CreationDate="2019-11-05T15:06:58.800" Score="1" Body="&lt;p&gt;I can't help but feel that you are trying to limit the &lt;code&gt;colorcolumn&lt;/code&gt; to the 81st (or so) column &lt;strong&gt;only&lt;/strong&gt; when there actually is a line that goes beyond that column. I'm sorry, if I got your question wrong, because I'm a bit confused about rows vs columns...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway:&#xA;this is what I have in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Make 81st column stand out&#xA;highlight ColorColumn ctermbg=magenta&#xA;call matchadd('ColorColumn', '\%81v', 100)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not my idea, it's taken from Damian Conway's video &lt;a href=&quot;https://www.youtube.com/watch?v=aHm36-na4-4&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;more instantly better vim&quot;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again: Sorry, if I misunderstood your question.&lt;/p&gt;&#xA;" OwnerUserId="22956" LastActivityDate="2019-11-05T15:06:58.800" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21789" PostTypeId="2" ParentId="21782" CreationDate="2019-11-05T19:06:19.527" Score="2" Body="&lt;p&gt;This seems to be a bug in the original 8.1 version, that has since been fixed (possibly by patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.0457&quot; rel=&quot;nofollow noreferrer&quot;&gt;v8.1.0457&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can always test the latest nightly builds from the &lt;a href=&quot;https://github.com/vim/vim-win32-installer/releases&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim/vim-win32-installer&lt;/a&gt; repository. That one will provide nightly builds (and if I have the time, I'll also have the installer and the binaries signed using &lt;a href=&quot;https://app.signpath.io&quot; rel=&quot;nofollow noreferrer&quot;&gt;signpath.io&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-11-05T19:06:19.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21790" PostTypeId="1" CreationDate="2019-11-05T23:13:49.743" Score="3" ViewCount="1053" Body="&lt;p&gt;I feel &lt;a href=&quot;https://github.com/fatso83/dotfiles/blob/545b4abcb40840695588f261a070db30d2276bb0/common-setup/vim/dotvim/plugins-config#L14&quot; rel=&quot;nofollow noreferrer&quot;&gt;my current VIM setup&lt;/a&gt; is pretty sweet, but there is one thing that annoys me time and time again: how can I open a file or add a file to the same directory as the current file I am editing? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I should open NerdTree it will just list the contents of &lt;code&gt;$PWD&lt;/code&gt; and I need to manually browse down to where I want to go. I'd like to have a workflow a bit like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Find a file somehow (NerdTree, Ctrl-P or &lt;code&gt;:e the/file/path.txt&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;:SwitchCWDToSameAsCurrentFile (change working directory to same as the current file)&lt;/li&gt;&#xA;&lt;li&gt;Open NerdTree or &lt;code&gt;:e .&lt;/code&gt; and go to the current working directory&lt;/li&gt;&#xA;&lt;li&gt;Add/Open a file from the current working directory&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1087" LastActivityDate="2019-11-06T13:12:00.317" Title="Easily add/open a file in the same folder as the current file/buffer" Tags="|filesystem|plugin-nerdtree|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21791" PostTypeId="2" ParentId="21790" CreationDate="2019-11-06T00:41:07.793" Score="4" Body="&lt;p&gt;&lt;code&gt;:Ex&amp;lt;CR&amp;gt;&lt;/code&gt; followed by &lt;kbd&gt;%&lt;/kbd&gt; will prompt you for a new filename in that directory, which can be a pretty smooth process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that there's also &lt;a href=&quot;https://vim.fandom.com/wiki/Set_working_directory_to_the_current_file#Automatically_change_the_current_directory&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;set autochdir&lt;/code&gt;&lt;/a&gt; if that fits your patterns/plugins better (always change directory to match the current file).&lt;/p&gt;&#xA;" OwnerUserId="463" LastActivityDate="2019-11-06T00:41:07.793" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21792" PostTypeId="1" AcceptedAnswerId="21804" CreationDate="2019-11-06T02:03:17.840" Score="3" ViewCount="922" Body="&lt;p&gt;Is there a way to open just the quickfix list without jumping to the first result when using &lt;code&gt;:lt&lt;/code&gt;? I am using &lt;code&gt;:lt&lt;/code&gt; to populate the location list with tags that match with the following binding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;t &quot;:lt /&quot; . input(&quot;&quot;, &quot;&quot;, &quot;tags&quot;) . &quot;&amp;lt;CR&amp;gt;:lop&amp;lt;CR&amp;gt;&amp;lt;C-k&amp;gt;&amp;lt;C-o&amp;gt;&amp;lt;C-j&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works to some degree. Given that &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; are mappings for the associated window movement commands, this breaks down if the quickfix window is below some complex set of splits. &lt;code&gt;:h tag-matchlist&lt;/code&gt; and &lt;code&gt;:h quickfix&lt;/code&gt; don't seem to offer any helpful information. However, some options like &lt;code&gt;:cgete&lt;/code&gt; seem like the functionality is there, as they specify &quot;but don't jump to the first error&quot;, which isn't an option for &lt;code&gt;:lt&lt;/code&gt; as it specifies&quot;Jump to tag&quot; as part of its behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the new question is: &lt;em&gt;how can I populate the location list with tags matching a pattern without jumping to the first match?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently working on trying to get it to work with &lt;code&gt;:taglist()&lt;/code&gt; and &lt;code&gt;:lgete&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="25455" LastEditorUserId="25455" LastEditDate="2019-11-06T15:32:24.400" LastActivityDate="2019-11-06T15:47:52.187" Title="Open quickfix Window Only, Don't Jump To First Result" Tags="|quickfix|tags|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21793" PostTypeId="2" ParentId="21790" CreationDate="2019-11-06T05:51:24.800" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;SwitchCWDToSameAsCurrentFile (change working directory to same as the current file)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I use the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;= :lcd %:p:h \| pwd&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-06T05:51:24.800" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21794" PostTypeId="5" CreationDate="2019-11-06T06:54:45.893" Score="0" Body="" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2019-11-06T06:54:45.893" LastActivityDate="2019-11-06T06:54:45.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21795" PostTypeId="4" CreationDate="2019-11-06T06:54:45.893" Score="0" Body="the &quot;easy&quot; Vim, or Vim configured to run like a modeless editor" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2019-11-06T06:54:45.893" LastActivityDate="2019-11-06T06:54:45.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21796" PostTypeId="1" CreationDate="2019-11-06T11:06:09.250" Score="2" ViewCount="1836" Body="&lt;p&gt;I'm working on a plain text file. I'd like to highlight important words or lines so that they stand out. How can I change background color and/or text color for selected text or word under cursor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By permanent I meant that the highlighting lasts and saved when closing the document. I'd like to highlight different words and lines one after another.&lt;/p&gt;&#xA;" OwnerUserId="16800" LastEditorUserId="9333" LastEditDate="2019-11-07T07:19:37.520" LastActivityDate="2019-11-07T07:19:37.520" Title="Highlight important words/lines permanently" Tags="|highlight|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21798" PostTypeId="1" AcceptedAnswerId="21813" CreationDate="2019-11-06T12:35:14.973" Score="8" ViewCount="1628" Body="&lt;p&gt;After &lt;code&gt;:term ++curwin zsh&lt;/code&gt;, I use that buffer as an alternative of tmux window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there is one caveat, if I &lt;code&gt;cd&lt;/code&gt; in zsh, vim will not know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which cause problem in below case&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terminal normal mode, &lt;code&gt;gf&lt;/code&gt; will not work correctly, since vim don't know zsh has changed directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After googling, I found &lt;a href=&quot;https://unix.stackexchange.com/questions/171764/how-can-i-run-a-command-in-bash-after-any-change-in-pwd&quot;&gt;zsh support hook for directory change&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, my vim &amp;amp; shell expertise is insufficient to use that hook to tell vim change local directory of corresponding terminal buffer.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2020-05-15T07:15:13.870" Title="how to change local directory of terminal buffer whenever its shell change directory" Tags="|terminal|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21799" PostTypeId="2" ParentId="19653" CreationDate="2019-11-06T12:46:15.843" Score="0" Body="&lt;p&gt;If you're open for a plugin solution, my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4795&quot; rel=&quot;nofollow noreferrer&quot;&gt;ExtractMatches plugin&lt;/a&gt; has (among others) a &lt;code&gt;:YankUniqueMatches&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:YankUniqueMatches /\w\+/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Result (can be pasted (and &lt;code&gt;:sort&lt;/code&gt;ed) into a &lt;code&gt;:new&lt;/code&gt; buffer with &lt;code&gt;:put&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;isPhysicallySettledFxFwd&#xA;NO&#xA;Y&#xA;isPhysicallySettledFxSwap&#xA;N&#xA;isPhysicallySettledCommodity&#xA;YES&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-06T12:46:15.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21800" PostTypeId="2" ParentId="21790" CreationDate="2019-11-06T13:12:00.317" Score="0" Body="&lt;p&gt;Here are my edit in same directory mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Explore&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;ed :Explore&amp;lt;CR&amp;gt;&#xA;&quot; Quickly input the directory of the current file on the command line&#xA;cnoremap &amp;lt;expr&amp;gt; %% filename#command_dir('%%')&#xA;&quot; Need 'recursive' mapping here for %%&#xA;nmap &amp;lt;Leader&amp;gt;ew :e %%&#xA;nmap &amp;lt;Leader&amp;gt;ev :vs %%&#xA;nmap &amp;lt;Leader&amp;gt;es :sp %%&#xA;nmap &amp;lt;Leader&amp;gt;et :tabe %%&#xA;&#xA;&quot; Get the directory of a file&#xA;&quot; - On Ex command lines, returns the directory of the file ('./' for new files)&#xA;&quot; - On other command lines (/,?) returns the keymap used to trigger it&#xA;function! filename#command_dir(keymap) abort&#xA;  let l:command_type = getcmdtype()&#xA;  if l:command_type isnot# ':'&#xA;    return a:keymap&#xA;  endif&#xA;  let l:dir = expand('%:h')&#xA;  if empty(l:dir)&#xA;    let l:dir = '.'&#xA;  endif&#xA;  return l:dir . '/'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also then do &lt;code&gt;:cd %%&lt;/code&gt; if you really need to change directories (and &lt;code&gt;'autochdir'&lt;/code&gt; can make that easier, as pointed out).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Honestly, I prefer to stay at the root project level most of the time though. It makes more sense in many ways. I have tools like &lt;code&gt;ack&lt;/code&gt;, &lt;code&gt;grep&lt;/code&gt;, git subcommands, and others which, combined with some bash functions and the quickfix list, make it easy to jump into vim at various parts of my code base. I’ll add them here later as needed. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-06T13:12:00.317" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21801" PostTypeId="2" ParentId="19639" CreationDate="2019-11-06T13:16:31.080" Score="1" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/rhysd/conflict-marker.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;conflict-marker.vim&lt;/a&gt; can&#xA;highlight the markers themselves; it also offers jumps and ways to resolve&#xA;them.&lt;/li&gt;&#xA;&lt;li&gt;my own &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4129&quot; rel=&quot;nofollow noreferrer&quot;&gt;ConflictDetection plugin&lt;/a&gt; detects and highlights the entire sections (via syntax highlighting); a companion &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=3991&quot; rel=&quot;nofollow noreferrer&quot;&gt;ConflictMotions plugin&lt;/a&gt; offers motions and commands for resolution.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-06T13:16:31.080" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21802" PostTypeId="2" ParentId="21796" CreationDate="2019-11-06T13:29:52.687" Score="2" Body="&lt;p&gt;While it is possible to highlight arbitrary words temporary there is no builtin/easy way to make it permanent -- it is plain text. I mean, without injecting additional text/chars into your file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are OK there might be some stuff inserted then try txtfmt plugin &lt;a href=&quot;https://github.com/bpstahlman/txtfmt&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/bpstahlman/txtfmt&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-11-06T13:29:52.687" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21803" PostTypeId="2" ParentId="21796" CreationDate="2019-11-06T13:41:29.013" Score="0" Body="&lt;h3&gt;colorful, ephemeral or semi-permanent&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Adding arbitrary highlights for text fragments can be done via &lt;a href=&quot;https://vimhelp.appspot.com/pattern.txt.html#%3Amatch&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :match&lt;/code&gt;&lt;/a&gt; (and &lt;code&gt;:2match&lt;/code&gt;, &lt;code&gt;:3match&lt;/code&gt;, generically with &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#matchadd%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;matchadd()&lt;/code&gt;&lt;/a&gt;). These built-in commands provide the basic functionality, but for a great user experience, more stuff is needed (like helpful mappings that mirror the build-in &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; commands, &lt;code&gt;:autocmd&lt;/code&gt;s that apply the highlightings not just in the current window, maybe persistence across settings. For that, a plugin is needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2666&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mark plugin&lt;/a&gt; is one of those. (The plugin page has links to alternative plugins.) The highlighting (patterns and colors) won't be part of the buffer; best you could do is storing these as annotations in a &lt;em&gt;modeline&lt;/em&gt;-like comment.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;really permanent&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you instead really want complete permanency:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For a few keywords, a &lt;em&gt;syntax extension&lt;/em&gt; could work. Many syntaxes already have a common highlighting of &lt;code&gt;TODO&lt;/code&gt;, &lt;code&gt;FIXME&lt;/code&gt;, and similar keywords.&lt;/li&gt;&#xA;&lt;li&gt;There are many &quot;enriched text&quot; formats; &lt;em&gt;Markdown&lt;/em&gt; is very famous (and also used here on Stack Overflow); some languages already allow embedding inside comments or other blocks; for others this could be grafted on via my &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4168&quot; rel=&quot;nofollow noreferrer&quot;&gt;SyntaxRange plugin&lt;/a&gt;. You'd be limited to a few common formatting styles (like &lt;strong&gt;bold&lt;/strong&gt; and &lt;em&gt;italic&lt;/em&gt;), though, or have to insert big ugly markup (like &lt;code&gt;&amp;lt;font&amp;gt;&lt;/code&gt; tags).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2019-11-06T13:49:58.167" LastActivityDate="2019-11-06T13:49:58.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21804" PostTypeId="2" ParentId="21792" CreationDate="2019-11-06T15:47:52.187" Score="3" Body="&lt;p&gt;The jump is caused by the &lt;code&gt;:ltag&lt;/code&gt; command, not by &lt;code&gt;:lopen&lt;/code&gt;. Unfortunately, though that command takes an optional &lt;code&gt;[!]&lt;/code&gt;, it's meaning is different than that to &lt;code&gt;:make&lt;/code&gt; and friends, which can suppress the jump with &lt;code&gt;!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;code&gt;:ltag&lt;/code&gt; is just a variant of &lt;code&gt;:tag&lt;/code&gt;, the &lt;code&gt;!&lt;/code&gt; there is concerned with abandoning the current file, as &lt;a href=&quot;https://vimhelp.appspot.com/tagsrch.txt.html#tag-%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help tag-!&lt;/code&gt;&lt;/a&gt; explains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess the right way to solve this issue is through skipping &lt;code&gt;:ltag&lt;/code&gt; and using low-level functions like &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#taglist%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;taglist()&lt;/code&gt;&lt;/a&gt; to obtain the tags and &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#setloclist%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;setloclist()&lt;/code&gt;&lt;/a&gt; to populate the location list.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-06T15:47:52.187" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21805" PostTypeId="1" CreationDate="2019-11-06T18:42:36.210" Score="2" ViewCount="136" Body="&lt;p&gt;Anyone know how to get rid of the file path segment of the completion list.&#xA;I'm using youcompleteme with rust.&lt;a href=&quot;https://i.stack.imgur.com/jTA2P.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jTA2P.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25560" LastActivityDate="2019-11-06T18:42:36.210" Title="neovim and youcompleteme" Tags="|plugin-you-complete-me|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21806" PostTypeId="1" AcceptedAnswerId="21807" CreationDate="2019-11-06T20:39:20.237" Score="5" ViewCount="1166" Body="&lt;p&gt;I posted this question on stackoverflow already, but realized afterwards that it's probably better to ask here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have a function of the following form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:my_function(dict_arg)&#xA;    let darg = copy(a:dict_arg)&#xA;&#xA;    func! my_inner_func(cond)&#xA;        if a:cond ==# 'a'&#xA;            execute darg.a&#xA;        elseif a:cond ==# 'b'&#xA;            execute darg.b&#xA;        elseif a:cond ==# 'c'&#xA;            execute darg.c&#xA;        endif&#xA;    endfunc&#xA;&#xA;    return function('my_inner_func')&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where the argument passed to the &lt;code&gt;dict_arg&lt;/code&gt; parameter will be some dict keyed with &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt; and &lt;code&gt;c&lt;/code&gt;, with their respective values being strings representing Ex commands that will be executed depending on the specific &lt;code&gt;cond&lt;/code&gt; (condition).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The purpose of the outer function &lt;code&gt;s:my_function&lt;/code&gt; is to generate a Funcref that will execute the appropriate Ex command (&lt;code&gt;darg.a&lt;/code&gt;, &lt;code&gt;darg.b&lt;/code&gt; or &lt;code&gt;darg.c&lt;/code&gt;) based on the &lt;code&gt;cond&lt;/code&gt;, which is itself determined elsewhere by other variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So my problem is that I don't know how to reference the local variable &lt;code&gt;darg&lt;/code&gt; defined in the scope of &lt;code&gt;s:my_function&lt;/code&gt; from within &lt;code&gt;my_inner_func&lt;/code&gt;.&lt;/strong&gt; When the function is called, I get the error &lt;code&gt;E121: Undefined variable: darg&lt;/code&gt;. It also doesn't work (same error) if I don't define the local variable &lt;code&gt;darg&lt;/code&gt;, and instead just try to do &lt;code&gt;execute a:dict_arg.b&lt;/code&gt; for instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can get around it by defining &lt;code&gt;darg&lt;/code&gt; to be global, as in &lt;code&gt;let g:darg = copy(a:dict_arg)&lt;/code&gt;, then later doing &lt;code&gt;execute g:darg.a&lt;/code&gt;. But of course, I'd like to avoid that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In something like Python, this type of lexical scope resolution is automatic. But VimL is well.. VimL. Any help or pointers will be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="24816" LastActivityDate="2019-11-06T22:12:25.180" Title="VimL/Vimscript: how to access local variable of outer function from its inner function?" Tags="|vimscript|functions|variables|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21807" PostTypeId="2" ParentId="21806" CreationDate="2019-11-06T22:12:25.180" Score="9" Body="&lt;p&gt;I though it wasn't possible, but I was wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h :func-closure&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to patch two things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;add &lt;code&gt;closure&lt;/code&gt; at the end of the inner of the function declaration&lt;/li&gt;&#xA;&lt;li&gt;respect the usual naming conventions&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For instance&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:my_function(dict_arg)&#xA;    let darg = copy(a:dict_arg)&#xA;&#xA;    func! s:my_inner_func(cond) closure&#xA;      return darg[a:cond]&#xA;    endfunc&#xA;&#xA;    return function('s:my_inner_func')&#xA;endfunc&#xA;&#xA;let g:F = s:my_function({'a': 42, 'b': 5, 'c': 'str'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2019-11-06T22:12:25.180" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21808" PostTypeId="1" AcceptedAnswerId="21809" CreationDate="2019-11-06T22:45:31.367" Score="3" ViewCount="367" Body="&lt;p&gt;In my $VIMRC I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;A :set formatoptions+=a&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;a :set formatoptions-=a&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'm wondering is if there's something more like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;A :set formatoptions!=a&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that takes the value of a (the &lt;code&gt;formatoptions&lt;/code&gt; flag) and inverts it (if set, unset it, otherwise set it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;s :set spell!&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but for options where it takes flags rather than it being a true/false boolean. I'd like to accomplish this without getting into vimscript and if/else loops.&lt;/p&gt;&#xA;" OwnerUserId="158" LastEditorUserId="158" LastEditDate="2019-11-06T23:11:24.997" LastActivityDate="2019-11-07T18:12:21.023" Title="Is there a 'toggle' :set option?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21809" PostTypeId="2" ParentId="21808" CreationDate="2019-11-06T23:09:11.997" Score="6" Body="&lt;p&gt;There is no built-in way to do this in vimscript that I'm aware of. You could put it in a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function ToggleOption(option)&#xA;  if &amp;amp;formatoptions =~# a:option&#xA;    exec &quot;set formatoptions-=&quot;.a:option&#xA;  else&#xA;    exec &quot;set formatoptions+=&quot;.a:option&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;A :&amp;lt;C-u&amp;gt;call ToggleOption('a')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if you really want this as a one liner, you'd need something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;a &quot;:\&amp;lt;C-u&amp;gt;set fo&quot;.'+-'[&amp;amp;fo =~# 'a'].&quot;=a\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my opinion, this is kinda ugly and the function is much preferable.&lt;/p&gt;&#xA;" OwnerUserId="2920" LastEditorUserId="2920" LastEditDate="2019-11-07T18:12:21.023" LastActivityDate="2019-11-07T18:12:21.023" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21810" PostTypeId="1" AcceptedAnswerId="21811" CreationDate="2019-11-07T02:04:56.660" Score="2" ViewCount="82" Body="&lt;p&gt;I know that you can use &lt;code&gt;let @x = @w&lt;/code&gt; to copy the contents of a macro from one register to another, but how do you read the contents of your macro register into the buffer?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="10604" LastEditDate="2019-11-07T05:39:51.757" LastActivityDate="2019-11-07T05:39:51.757" Title="How do you read the contents of a macro into your buffer?" Tags="|buffers|macro|register|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21811" PostTypeId="2" ParentId="21810" CreationDate="2019-11-07T05:39:15.627" Score="4" Body="&lt;p&gt;Macros are stored in the same registers as you use for yanking, deleting, and putting, so any of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;ap&#xA;:put a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Etc &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-07T05:39:15.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21813" PostTypeId="2" ParentId="21798" CreationDate="2019-11-07T07:56:17.260" Score="11" Body="&lt;ol&gt;&#xA;&lt;li&gt;Create a special function in your vimrc that's callable from terminal, its name must start with &lt;code&gt;Tapi_&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; arglist : [ cwd ]&#xA;&quot; change window local working directory&#xA;function! Tapi_lcd(bufnum, arglist)&#xA;  let winid = bufwinid(a:bufnum)&#xA;  let cwd = get(a:arglist, 0, '')&#xA;  if winid == -1 || empty(cwd)&#xA;    return&#xA;  endif&#xA;  call win_execute(winid, 'lcd ' . cwd)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;create a function in your zshrc to call &lt;code&gt;Tapi_lcd&lt;/code&gt; in terminal:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cdv()&#xA;{&#xA;  printf '\033]51;[&quot;call&quot;, &quot;Tapi_lcd&quot;, [&quot;%s&quot;]]\007' &quot;$(pwd)&quot;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The leading &lt;code&gt;\033]51;&lt;/code&gt; and the trailing &lt;code&gt;\007&lt;/code&gt; are special escape sequence recognized by vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;check &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#terminal-api&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h terminal-api&lt;/a&gt; for more detail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can now use &lt;code&gt;cdv&lt;/code&gt; in terminal to change window local directory now (personally I would stop here, it's good enough for me). &lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;hook &lt;code&gt;cd&lt;/code&gt; and &lt;code&gt;cdv&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autoload -Uz add-zsh-hook&#xA;add-zsh-hook -Uz chpwd cdv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now they are &lt;code&gt;hooked&lt;/code&gt;, &lt;code&gt;cdv&lt;/code&gt; is called every time you &lt;code&gt;cd&lt;/code&gt; .&#xA;There are some side effect you should know, as some subshell environment (such as &lt;code&gt;$()&lt;/code&gt;) is a duplicate of the current shell environment, the hook works in such subshell too. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;( cd / )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Above command will trigger &lt;code&gt;cdv&lt;/code&gt;, it change your working directory to &lt;code&gt;/&lt;/code&gt;, if you want to avoid that, you need to filter out subshell &lt;code&gt;cd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cdv()&#xA;{&#xA;  if [[ $ZSH_SUBSHELL -eq 0 ]] ; then&#xA;    printf '\033]51;[&quot;call&quot;, &quot;Tapi_lcd&quot;, [&quot;%s&quot;]]\007' &quot;$(pwd)&quot;&#xA;  fi&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not a shell veteran, the hook make me nervous, &lt;s&gt;I wouldn't use it&lt;/s&gt;,.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update for nvim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; in init.vim/vimrc&#xA;fu Tapi_lcd(buf, cwd) abort&#xA;    if has('nvim')&#xA;        exe 'lcd '..a:cwd&#xA;        return ''&#xA;    endif&#xA;    let winid = bufwinid(a:buf)&#xA;    if winid == -1 || empty(a:cwd)&#xA;        return&#xA;    endif&#xA;    call win_execute(winid, 'lcd '..a:cwd)&#xA;endfu&#xA;&#xA;# in zshrc&#xA;autoload -Uz add-zsh-hook&#xA;if [[ -n &quot;$VIM_TERMINAL&quot; ]]; then&#xA;  add-zsh-hook -Uz chpwd cdv&#xA;  cdv() {&#xA;    printf -- '\033]51;[&quot;call&quot;, &quot;Tapi_lcd&quot;, &quot;%q&quot;]\007' &quot;$(pwd)&quot;&#xA;  }&#xA;elif [[ -n &quot;$NVIM_LISTEN_ADDRESS&quot; ]]; then&#xA;  add-zsh-hook -Uz chpwd cdv&#xA;  cdv() {&#xA;    nvr --servername &quot;$VIM_SERVERNAME&quot; --remote-expr &quot;$(printf -- 'Tapi_lcd(0, &quot;%q&quot;)' &quot;$(pwd)&quot;)&quot;&#xA;  }&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It requires the &lt;code&gt;nvr&lt;/code&gt; command; you can get it &lt;a href=&quot;https://github.com/mhinz/neovim-remote&quot; rel=&quot;nofollow noreferrer&quot;&gt;from here&lt;/a&gt;, or by running this shell command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python3 -m pip install --user --upgrade neovim-remote&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update for bash&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no &lt;code&gt;hook&lt;/code&gt; in bash, but we can use an alias and a function to hook cd and cdv. After step 2, put this in your &lt;code&gt;bashrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cdv()&#xA;{&#xA;  printf '\033]51;[&quot;call&quot;, &quot;Tapi_lcd&quot;, [&quot;%s&quot;]]\007' &quot;$(pwd)&quot;&#xA;}&#xA;&#xA;cd_and_cdv()&#xA;{&#xA;  'cd' &quot;$@&quot; &amp;amp;&amp;amp; cdv&#xA;}&#xA;&#xA;hookvim()&#xA;{&#xA;    alias cd=cd_and_cdv&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;execute &lt;code&gt;hookvim&lt;/code&gt; after entering &lt;code&gt;terminal&lt;/code&gt;, done. This solution works for &lt;code&gt;zsh&lt;/code&gt; too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update: set up hook automatically&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/terminal.txt.html#terminal-unix&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h terminal-unix&lt;/a&gt; add a bunch of environment variable to terminal inside vim, we can use it to setup hook.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put this to you zshrc/bashrc :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [[ ! -z &quot;$VIM_TERMINAL&quot; ]]; then&#xA;   hookvim&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="17449" LastEditDate="2020-05-15T07:15:13.870" LastActivityDate="2020-05-15T07:15:13.870" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21814" PostTypeId="2" ParentId="21787" CreationDate="2019-11-07T11:23:41.847" Score="0" Body="&lt;p&gt;Thanks to all the helpers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was able to achieve more or less what I was looking for using matchaddpos.&#xA;The only issue with this is that it is limited to 8 lines at a time , so I had to do the highlight in sections of 8 lines at a time.&#xA;If anyone has a nice idea how I can use matchaddpos on more than 8 lines at a time would be much appreciated.&#xA;Avi&lt;/p&gt;&#xA;" OwnerUserId="25541" LastActivityDate="2019-11-07T11:23:41.847" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21815" PostTypeId="2" ParentId="20137" CreationDate="2019-11-07T12:33:02.457" Score="2" Body="&lt;p&gt;You need to explicitly pass the key into the function; there's no built-in way to obtain that from Vim; this isn't a common use case. As plugins should only have a few keymappings, this approach should be fine. &lt;em&gt;Metaprogramming&lt;/em&gt; (e.g. a &lt;code&gt;:for&lt;/code&gt; loop) could be used to automatically define many mappings without duplicating all the information.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetInvoker( key )&#xA;    echom &quot;I was invokeed by the key &quot;&#xA;    echom a:key&#xA;endfunction&#xA;&#xA;map F :call GetInvoker('F')&amp;lt;CR&amp;gt;&#xA;map G :call GetInvoker('G')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-07T12:33:02.457" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21816" PostTypeId="2" ParentId="20077" CreationDate="2019-11-07T12:49:34.757" Score="1" Body="&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4320&quot; rel=&quot;nofollow noreferrer&quot;&gt;SearchHighlighting plugin&lt;/a&gt; is one of those &quot;visual star&quot; plugins that @D.BenKnoble mentions in his answer; it also has a command that does exactly what you're asking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SearchAutoHighlighting selection&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-07T12:49:34.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21817" PostTypeId="2" ParentId="20005" CreationDate="2019-11-07T12:57:33.590" Score="5" Body="&lt;p&gt;You've identified most of the issues - I think the best one can do is using the unnamed register, saving its contents and type, and temporarily resetting &lt;code&gt;'clipboard'&lt;/code&gt; and &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#cpo-y&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help cpo-y&lt;/code&gt;&lt;/a&gt; for yanks. I don't think it's possible to avoid the aliasing of register 0, but as these numbered registers are ephemeral and therefore rarely used, it's not so bad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the implementation of &lt;a href=&quot;https://github.com/inkarkat/vim-ingo-library/blob/e7cc1815df2c160b4cb4fd804c22ae7b1977c640/autoload/ingo/register.vim#L32-L64&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;ingo#register#KeepRegisterExecuteOrFunc()&lt;/code&gt;&lt;/a&gt; from my &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4433&quot; rel=&quot;noreferrer&quot;&gt;ingo-library plugin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ingo#register#KeepRegisterExecuteOrFunc( Action, ... )&#xA;&quot;******************************************************************************&#xA;&quot;* PURPOSE:&#xA;&quot;   Commands in the executed a:Action do not modify the default register.&#xA;&quot;* ASSUMPTIONS / PRECONDITIONS:&#xA;&quot;   None.&#xA;&quot;* EFFECTS / POSTCONDITIONS:&#xA;&quot;   None.&#xA;&quot;* INPUTS:&#xA;&quot;   a:Action    Either a Funcref or Ex commands to be :executed.&#xA;&quot;   a:arguments Value(s) to be passed to the a:Action Funcref (but not the&#xA;&quot;       Ex commands).&#xA;&quot;* RETURN VALUES:&#xA;&quot;   Result of evaluating a:Action, for Ex commands you need to use :return.&#xA;&quot;******************************************************************************&#xA;    let l:save_clipboard = &amp;amp;clipboard&#xA;    set clipboard= &quot; Avoid clobbering the selection and clipboard registers.&#xA;    if stridx(&amp;amp;cpoptions, 'y') != -1&#xA;        let l:save_cpoptions = &amp;amp;cpoptions&#xA;        set cpoptions-=y&#xA;    endif&#xA;    let l:save_reg = getreg('&quot;')&#xA;    let l:save_regmode = getregtype('&quot;')&#xA;    try&#xA;        return call('ingo#actions#ExecuteOrFunc', [a:Action] + a:000)&#xA;    finally&#xA;        call setreg('&quot;', l:save_reg, l:save_regmode)&#xA;        if exists('l:save_cpoptions')&#xA;            let &amp;amp;cpoptions = l:save_cpoptions&#xA;        endif&#xA;        let &amp;amp;clipboard = l:save_clipboard&#xA;    endtry&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-07T12:57:33.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21818" PostTypeId="2" ParentId="20301" CreationDate="2019-11-07T14:06:55.927" Score="1" Body="&lt;p&gt;&lt;sub&gt;From someone who has published 100+ Vim plugins:&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you spend some time to find a clear and precise name for your custom command, the chances of clashes actually are pretty small. &lt;strong&gt;Don't use abbreviations or prefixes&lt;/strong&gt; (prefer &lt;code&gt;:FrobnizeControlModule&lt;/code&gt; instead of &lt;code&gt;:FCM&lt;/code&gt; or &lt;code&gt;:FCtrlMod&lt;/code&gt;; people can define shorter aliases themselves) and in case of doubt, a &lt;strong&gt;longer, more exact variant&lt;/strong&gt; allows for future variations (and most Vim users do know about the disambiguation rules and command-completion).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#autoload-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help autoload-functions&lt;/code&gt;&lt;/a&gt; instead of script-local functions for the command implementation (and definitely not global functions!), people can duplicate your command definition, redefine a custom name themselves, and &lt;code&gt;:delcommand&lt;/code&gt; yours (if they really hate it / have a clash with their own customizations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's much more potential for clashes and plugin overlaps in &lt;em&gt;mappings&lt;/em&gt; - therefore, Vim has a lot of infrastructure and conventions for those (&lt;a href=&quot;https://vimhelp.appspot.com/usr_41.txt.html#using-%3CPlug%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help using-&amp;lt;Plug&amp;gt;&lt;/code&gt;&lt;/a&gt;). If there's really a command name clash with a very popular plugin, and you weren't aware of it, people &lt;em&gt;will&lt;/em&gt; tell you about it as long as you make it easy for them to contact you (which today mostly means publishing the plugin on GitHub and using its issue tracker).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-07T14:06:55.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21819" PostTypeId="1" AcceptedAnswerId="21822" CreationDate="2019-11-07T14:28:27.983" Score="2" ViewCount="790" Body="&lt;p&gt;In normal usage &lt;code&gt;:%s/A/B/g&lt;/code&gt; is a simple way to substitute a pattern across the entire buffer. However the command mode implementation of &lt;code&gt;:substitute&lt;/code&gt; is subject to many user configurable variables and as such linters rightfully complain about it's usage in scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to use &lt;code&gt;call substitute()&lt;/code&gt; instead since this is &lt;a href=&quot;https://google.github.io/styleguide/vimscriptguide.xml?showone=Fragile_commands#Fragile_commands&quot; rel=&quot;nofollow noreferrer&quot;&gt;a documented best practice in scripts&lt;/a&gt;. Using it against a string is easy, but &lt;a href=&quot;https://github.com/vim-pandoc/vim-pandoc/issues/336&quot; rel=&quot;nofollow noreferrer&quot;&gt;I can't figure out how to make it operate on a buffer&lt;/a&gt;. I seem to be able to to &lt;code&gt;call setline('1', substitute(getline('1'), 'A', 'B', ''))&lt;/code&gt; to change one line at a time, but it doesn't work across a whole buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the correct robust way to run a substitution across a whole buffer from a script or plugin?&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="267" LastEditDate="2019-11-07T14:47:23.693" LastActivityDate="2019-11-07T14:59:52.143" Title="How can substitute() operate on a whole buffer?" Tags="|vimscript|buffers|substitute|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21820" PostTypeId="2" ParentId="21819" CreationDate="2019-11-07T14:41:05.120" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;since this is documented best-practice in scripts&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Documented where?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vimscript (in which plugins are written), every &quot;statement&quot; is an Ex command, you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyFunc() abort&#xA;  %substitute/pattern/repl/g&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or whatever it is you're trying to do. &lt;em&gt;This is in fact the simplest mechanism.&lt;/em&gt; You can add modifiers (&lt;code&gt;keepjumps&lt;/code&gt;, etc.) to the command, or build it up programmatically, or any of the usual things. But don't make this painful by trying to use a &lt;code&gt;substitute()&lt;/code&gt; function—that works on a single string—on the entire buffer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you insist...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could do a Schwarzian transform from list of lines to line, substitute, and reverse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could loop&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for line in range(0, line('$'))&#xA;  call setline(line, substitute(getline(line), 'A', 'B', ''))&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, why?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://vi.stackexchange.com/questions/5949/substitute-with-pure-vimscript-without-s?rq=1&quot;&gt;this Q&amp;amp;A&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-07T14:41:05.120" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21821" PostTypeId="2" ParentId="21819" CreationDate="2019-11-07T14:47:35.040" Score="0" Body="&lt;p&gt;One way could be using regular &lt;code&gt;for&lt;/code&gt; loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let idx = 1&#xA;for line in getbufline(bufnr('%'), 1, &quot;$&quot;)&#xA;    call setline(idx, substitute(line, 'A', 'B', 'g'))&#xA;    let idx += 1&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for line in range(0, line('$'))&#xA;  call setline(line, substitute(getline(line), 'A', 'B', 'g'))&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is pretty obvious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another one could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let buflines = getbufline(bufnr('%'), 1, &quot;$&quot;)&#xA;%delete _&#xA;call append(0, map(buflines, {_, line -&amp;gt; substitute(line, 'A', 'B', 'g')}))&#xA;$delete _&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It takes all current buffer lines, then deletes whole buffer and appends transformed by map saved buffer lines.&#xA;With &lt;code&gt;append&lt;/code&gt; you going to have additional newline at the end, so the last line deletes it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There probably more ways to do it, not sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would still go with regular &lt;code&gt;%s//&lt;/code&gt; command. Remember you can set it up the way you like using &lt;code&gt;:execute&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let pattern = 'A'&#xA;let sub = 'B'&#xA;execute &quot;%s/&quot; . pattern . &quot;/&quot; . sub . &quot;/g&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, instead of dot concatenation ppl suggest using &lt;code&gt;printf&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-11-07T14:54:09.427" LastActivityDate="2019-11-07T14:54:09.427" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21822" PostTypeId="2" ParentId="21819" CreationDate="2019-11-07T14:53:53.180" Score="5" Body="&lt;p&gt;The only problems I see with &lt;code&gt;:substitute&lt;/code&gt; are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it messes a few registers&lt;/li&gt;&#xA;&lt;li&gt;we may have to be wary of the separator character used that'll need to be escaped&lt;/li&gt;&#xA;&lt;li&gt;its behaviour depends on &lt;code&gt;'magic&lt;/code&gt;' option &lt;del&gt;(as well as &lt;code&gt;substitute()&lt;/code&gt;'s one)&lt;/del&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you really want to operate on the whole buffer without &lt;code&gt;:s&lt;/code&gt;, you could also use the following oneliner (that'll be more efficient than any loop)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setline(1, map(getline(1,'$'), {k,v -&amp;gt; substitute(v, 'PATTERN', 'REPLACEMENT', FLAGS)}))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2019-11-07T14:59:52.143" LastActivityDate="2019-11-07T14:59:52.143" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="21823" PostTypeId="2" ParentId="17110" CreationDate="2019-11-07T19:31:19.490" Score="1" Body="&lt;p&gt;&lt;code&gt;.jar&lt;/code&gt; files are essentially zip files (you'll probably have noticed the &lt;code&gt;&quot; zip.vim version vxx&lt;/code&gt; banner at the top of the buffer). There are a few plugins which aim to help open nested zips, so you could try one (&lt;a href=&quot;https://github.com/lbrayner/vim-rzip&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-rzip&lt;/a&gt;, for example) as a possible fix.&lt;/p&gt;&#xA;" OwnerUserId="463" LastActivityDate="2019-11-07T19:31:19.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21824" PostTypeId="1" CreationDate="2019-11-08T01:55:21.057" Score="0" ViewCount="1344" Body="&lt;p&gt;Is there an option to control .cache folder location in Vim? Is there a setting or a variable for this?&lt;/p&gt;&#xA;" OwnerUserId="11022" LastEditorUserId="11022" LastEditDate="2019-11-08T08:19:11.880" LastActivityDate="2020-04-24T09:12:46.147" Title="How to control .cache folder location?" Tags="|vimrc|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21825" PostTypeId="1" CreationDate="2019-11-08T07:34:34.920" Score="5" ViewCount="6094" Body="&lt;p&gt;I am writing a vim script, and I need to insert the contents of a string variable at the current cursor position. What is an appropriate way to do this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let text = &quot;Lorem ipsum sit dolor amet ...&quot;&#xA;&quot; How to insert text at current cursor position?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know that &lt;code&gt;:read&lt;/code&gt; can do something like this, but it is only applicable for inserting text that come from files, not text stored in variables.&lt;/p&gt;&#xA;" OwnerUserId="19712" LastActivityDate="2023-06-30T13:58:19.217" Title="How to insert text from a variable at current cursor position?" Tags="|vimscript|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21826" PostTypeId="2" ParentId="21825" CreationDate="2019-11-08T07:54:28.650" Score="9" Body="&lt;p&gt;You can do a literal insert of register contents through &lt;a href=&quot;https://vimhelp.appspot.com/insert.txt.html#i_CTRL-R_CTRL-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-R_CTRL-R&lt;/code&gt;&lt;/a&gt;, combined with the &lt;em&gt;expression register&lt;/em&gt; (&lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#quote%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help quote=&lt;/code&gt;&lt;/a&gt;) to reference the variable:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;execute &amp;quot;normal! i\&amp;lt;C-r&amp;gt;\&amp;lt;C-r&amp;gt;=text\&amp;lt;CR&amp;gt;\&amp;lt;Esc&amp;gt;&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that newlines will appear as &lt;code&gt;^@&lt;/code&gt;; if the variable does not contain any other special characters, you could switch to &lt;a href=&quot;https://vimhelp.appspot.com/insert.txt.html#i_CTRL-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-R&lt;/code&gt;&lt;/a&gt;, which &lt;em&gt;does&lt;/em&gt; interpret the variable contents as types (and therefore inserts a newline, but would also interpret stuff like &lt;kbd&gt;Home&lt;/kbd&gt; etc.)&lt;/p&gt;&#xA;&lt;p&gt;If you know that the variable contents are just plain text (without any special control characters), you could also just append the variable contents as-is and conclude with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;execute &amp;quot;normal! i&amp;quot; . text . &amp;quot;\&amp;lt;Esc&amp;gt;&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or use the low-level &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#setline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;setline()&lt;/code&gt;&lt;/a&gt;, splicing in the text at the cursor column via string manipulation:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let line = getline('.')&#xA;call setline('.', strpart(line, 0, col('.') - 1) . text . strpart(line, col('.') - 1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2023-06-30T13:58:19.217" LastActivityDate="2023-06-30T13:58:19.217" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="21827" PostTypeId="2" ParentId="21825" CreationDate="2019-11-08T07:54:41.200" Score="5" Body="&lt;p&gt;You might go with &lt;code&gt;setline&lt;/code&gt; function or simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let text = &quot;Lorem ipsum sit dolor amet ...&quot;&#xA;exe &quot;normal! a&quot; . text . &quot;\&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;exe&lt;/code&gt; (&lt;code&gt;:execute&lt;/code&gt;) is to execute vimscript&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal! a&lt;/code&gt; executes &lt;code&gt;a&lt;/code&gt; command as you type in vim (append after cursor)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;. text&lt;/code&gt; then you concatenate your text with &lt;code&gt;normal a&lt;/code&gt;. As you would type this text in vim after &lt;code&gt;a&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;and &lt;code&gt;'\&amp;lt;Esc&amp;gt;&lt;/code&gt; to exit insert mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-11-08T08:15:33.527" LastActivityDate="2019-11-08T08:15:33.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21828" PostTypeId="1" AcceptedAnswerId="21831" CreationDate="2019-11-08T10:05:26.090" Score="1" ViewCount="86" Body="&lt;p&gt;I'm trying to use balloon text for my C macros, say, &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; as follows in the terminal version.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyBalloonExpr()&#xA;  let macros = {&#xA;\ 'true':&quot;true\n1&quot;,&#xA;\ 'false':&quot;false\n0&quot;,&#xA;\ }&#xA;  return get(macros, v:beval_text, '')&#xA;endfunction&#xA;set balloonexpr=MyBalloonExpr()&#xA;set ballooneval&#xA;set balloonevalterm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to display a two-line balloon, with the first line the macro name and the second line the macro value, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;true&#xA;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it gets displayed as &lt;code&gt;true^@1&lt;/code&gt; as if the newline were a NUL byte (^@). What am I missing? Are multi-line balloon texts possible in the terminal (they do work in the GUI version)? Is this a bug?&#xA;I'm using vim 8.1.2269 compiled today.&lt;/p&gt;&#xA;" OwnerUserId="2347" LastActivityDate="2022-12-05T16:06:22.603" Title="Can I have a newline in balloonevalterm expressions?" Tags="|terminal|balloon|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21829" PostTypeId="5" CreationDate="2019-11-08T10:12:40.110" Score="0" Body="&lt;p&gt;From the vim help on &quot;balloon-eval&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This feature allows a debugger, or other external tool, to display dynamic&#xA;information based on where the mouse is pointing.  The purpose of this feature&#xA;was to allow Sun's Visual WorkShop debugger to display expression evaluations.&#xA;However, the feature was implemented in as general a manner as possible and&#xA;could be used for displaying other information as well.&lt;/p&gt;&#xA;" OwnerUserId="2347" LastEditorUserId="2347" LastEditDate="2019-11-08T10:35:12.400" LastActivityDate="2019-11-08T10:35:12.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21830" PostTypeId="4" CreationDate="2019-11-08T10:12:40.110" Score="0" Body="A balloon is a small pop-up opening while hovering over certain words." OwnerUserId="2347" LastEditorUserId="2347" LastEditDate="2019-11-08T10:34:40.130" LastActivityDate="2019-11-08T10:34:40.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21831" PostTypeId="2" ParentId="21828" CreationDate="2019-11-08T10:30:37.557" Score="2" Body="&lt;p&gt;I'm not sure you've seen this, but &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27balloonexpr%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'balloonexpr'&lt;/code&gt;&lt;/a&gt; says this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To check whether line breaks in the balloon text work use this check:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if has(&quot;balloon_multiline&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;When they are supported &quot;\n&quot; characters will start a new line.  If the&#xA;    expression evaluates to a |List| this is equal to using each List item&#xA;    as a string and putting &quot;\n&quot; in between them.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So if &lt;code&gt;:echo has(&quot;balloon_multiline&quot;)&lt;/code&gt; returns &lt;code&gt;0&lt;/code&gt; in your terminal, you're outta luck. If it returns &lt;code&gt;1&lt;/code&gt;, works in normal windows, but not in terminal windows, that looks like a bug; please report this, see &lt;code&gt;:help bugs&lt;/code&gt;. Basically, open an issue at the &lt;a href=&quot;https://github.com/vim/vim/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;bug tracker&lt;/a&gt;, or directly discuss this on the &lt;a href=&quot;https://www.vim.org/community.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim_dev mailing list&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-08T10:30:37.557" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21832" PostTypeId="2" ParentId="20838" CreationDate="2019-11-08T12:52:05.083" Score="1" Body="&lt;p&gt;My &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4168&quot; rel=&quot;nofollow noreferrer&quot;&gt;SyntaxRange plugin&lt;/a&gt; can highlight certain ranges of lines with a different, embedded syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can either manually define those sections interactively:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1;/^\\begin{pycode}$/,/^\\end{pycode}$/SyntaxInclude python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or automate this in &lt;code&gt;~/.vim/after/ftplugin/tex/python_include.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call SyntaxRange#IncludeEx('start=&quot;^\\begin{pycode}$&quot; end=&quot;^\\end{pycode}$&quot;', 'python')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-08T12:52:05.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21834" PostTypeId="1" AcceptedAnswerId="21835" CreationDate="2019-11-08T22:48:45.407" Score="1" ViewCount="300" Body="&lt;p&gt;I'm trying to add more ex commands to my vim repertoire and I was wondering if there is setting or plugin that would allow to highlight the lines addressed by the command, if a range is give e.g., if I type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:-5,-3m.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like some highlight on the lines -5 and -3 (either the line number or the whole line or something like that), while I'm typing the command, until I actually execute it. If only the begin or end or the whole block is highlighted is not so important me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched the vim help and the web for some time but did not find anything useful so far.&lt;/p&gt;&#xA;" OwnerUserId="25586" LastEditorUserId="307" LastEditDate="2019-11-12T04:54:04.543" LastActivityDate="2019-11-12T04:54:04.543" Title="Highlight range for ex command" Tags="|highlight|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21835" PostTypeId="2" ParentId="21834" CreationDate="2019-11-09T06:04:14.953" Score="1" Body="&lt;p&gt;It's a bit complicated, I'll try to explain it in different abstraction levels.&lt;/p&gt;&#xA;&lt;h2&gt;Level 0&lt;/h2&gt;&#xA;&lt;p&gt;our goal is simple:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;update command range highlight after entering command line&lt;/li&gt;&#xA;&lt;li&gt;update command range highlight while typing in command line&lt;/li&gt;&#xA;&lt;li&gt;clear command range highlight when leaving command line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Level 1&lt;/h2&gt;&#xA;&lt;p&gt;We will use &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#CmdlineEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h CmdlineEnter&lt;/a&gt; , &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#CmdlineChanged&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h CmdlineChanged&lt;/a&gt; , and &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#CmdlineLeave&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h CmdlineLeave&lt;/a&gt; to implement our goals.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup cmdline_range_highlight&#xA;  au!&#xA;  autocmd CmdlineChanged : call s:update_cmdrange_highlight()&#xA;  autocmd CmdlineEnter : call s:update_cmdrange_highlight()&#xA;  autocmd CmdlineLeave : call s:clear_cmdrange_highlight()&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Level 2&lt;/h2&gt;&#xA;&lt;p&gt;Let's implement functions mentioned in &lt;code&gt;Level 1&lt;/code&gt;, their name should already tell you what they do.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; last command range and hightlight match id returned from matchadd()&#xA;let s:cmdrange = []&#xA;let s:cmdrange_hid = -1&#xA;&#xA;function s:update_cmdrange_highlight() abort&#xA;&#xA;  let cmdline = getcmdline()&#xA;&#xA;  &amp;quot; skip  v_:&#xA;  if cmdline =~# '\V\^''&amp;lt;,''&amp;gt;'&#xA;    return&#xA;  endif&#xA;&#xA;  &amp;quot; skip if range not changed&#xA;  let cmdrange = s:get_cmdrange(cmdline)&#xA;  if s:cmdrange == cmdrange&#xA;    return&#xA;  endif&#xA;&#xA;  &amp;quot; update highlight area&#xA;  call s:clear_cmdrange_highlight()&#xA;  let s:cmdrange_hid = matchadd('VISUAL',&#xA;        \ printf('\v%%&amp;gt;%dl.*%%&amp;lt;%dl', cmdrange[0]-1, cmdrange[1]+1))&#xA;  let s:cmdrange = cmdrange&#xA;  redraw&#xA;&#xA;endfunction&#xA;&#xA;function s:clear_cmdrange_highlight() abort&#xA;  if s:cmdrange_hid != -1&#xA;    call matchdelete(s:cmdrange_hid)&#xA;  endif&#xA;  let s:cmdrange = []&#xA;  let s:cmdrange_hid = -1&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Level 3&lt;/h2&gt;&#xA;&lt;p&gt;We need to implement &lt;code&gt;s:get_cmdrange&lt;/code&gt; to get current cmd range&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function s:get_cmdrange()&#xA;  ????????????&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There has no builtin function to get cmdrange without executing it(correct me if I'm wrong), the only way to get a cmdrange is executing a cmd. We can't execute current command, we must construct another labor command with current cmdrange text:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function s:get_cmdrange(cmdline) abort&#xA;&#xA;  let range_text = matchstr(a:cmdline, s:cmdrange_pat)&#xA;  if empty(range_text)&#xA;    return []&#xA;  endif&#xA;&#xA;  try&#xA;    let cpos = getcurpos()&#xA;&#xA;    &amp;quot; silent is used to reverse reversed command range&#xA;    exec printf('silent %s call Tech_get_cmdrange()', range_text)&#xA;    return [s:tech_cmdrange_line1, s:tech_cmdrange_line2]&#xA;  finally&#xA;    call setpos('.', cpos)&#xA;  endtry&#xA;endfunction&#xA;&#xA;function Tech_get_cmdrange() range&#xA;  let s:tech_cmdrange_line1 = a:firstline&#xA;  let s:tech_cmdrange_line2 = a:lastline&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Our labor command here is &lt;code&gt;silent original_command_range_text call Tech_get_cmdrange()&lt;/code&gt; .&lt;/p&gt;&#xA;&lt;p&gt;We use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Afunc-range&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :func-range&lt;/a&gt; to get cmdline range from &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Level 4&lt;/h2&gt;&#xA;&lt;p&gt;The last step is to init &lt;code&gt;s:cmdrange_pat&lt;/code&gt; , it's used in Level 3 to extract cmdline range from cmdline.&lt;/p&gt;&#xA;&lt;p&gt;A &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#cmdline-ranges&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h cmdline-ranges&lt;/a&gt; is one &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#%3Arange&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :range&lt;/a&gt; or two &lt;code&gt;:range&lt;/code&gt; joined by &lt;code&gt;,&lt;/code&gt; or &lt;code&gt;;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;A &lt;code&gt;:range&lt;/code&gt; is some basic pattern followed by multiple optional &lt;code&gt;[+-][number]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function s:build_cmdrange_pattern()&#xA;  &amp;quot; a range is various pattern followed by multiple optional [+-][number]&#xA;  let range_atoms = [&#xA;        \ '\d+',&#xA;        \ '[.$%]',&#xA;        \ &amp;quot;'[0-9A-Z]&amp;quot;,&#xA;        \ '\/.{-}\/',&#xA;        \ '\?.{-}\?',&#xA;        \ '\\\?',&#xA;        \ '\\\&amp;amp;',&#xA;        \ '\\\&amp;amp;',&#xA;        \ ''&#xA;        \ ]&#xA;  let range_basic = printf('%%(%s)', join(range_atoms, '|'))&#xA;  let range_optional = '%(\s*%([+-]\d*)*)'&#xA;  let range_pat = printf('\v%%(%s\s*%s*)', range_basic, range_optional)&#xA;&#xA;  &amp;quot; cmdrange is two ranges joined by, or ;&#xA;  let cmdrange_pat = printf('\v\C^%s([,;]%s)?', range_pat, range_pat)&#xA;  return cmdrange_pat&#xA;endfunction&#xA;let s:cmdrange_pat = s:build_cmdrange_pattern()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-11-09T11:00:47.633" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21836" PostTypeId="1" CreationDate="2019-11-09T10:40:10.670" Score="3" ViewCount="656" Body="&lt;p&gt;I use &lt;code&gt;:copy&lt;/code&gt; a fair bit. So like range &lt;code&gt;:12,15 copy 20&lt;/code&gt; will paste a block of text from 12 to 15 lines at 20th line. But when I want to paste a line at multiple places it doesn't work. For example &lt;code&gt;:24 copy 12,22,25&lt;/code&gt; it only pastes 24th line at 12th line. Is there a &lt;strong&gt;plugin&lt;/strong&gt; or &lt;strong&gt;.vimrc&lt;/strong&gt; setting that can help me achieve this behavior?&lt;/p&gt;&#xA;" OwnerUserId="25589" LastActivityDate="2019-12-11T07:54:45.750" Title="Is there a way to paste at multiple locations/lines in vim?" Tags="|vimrc|cut-copy-paste|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21837" PostTypeId="2" ParentId="21834" CreationDate="2019-11-09T11:13:45.393" Score="1" Body="&lt;p&gt;Finding an &quot;easy&quot; way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to drop to linewise Visual mode and then get back restoring the command-line contents.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; some regex magic to match a range pattern:&#xA;&quot; . or $ or % or number or mark or /pat/ or ?pat? or \/ or \? or \&amp;amp;&#xA;&quot; optionally followed by ++/--number&#xA;let s:pat = '([.$%]|\d+|''[[:alnum:]''\[\]]|/.*/|\?.*\?|\[/?&amp;amp;])?([+-]+\d*)?'&#xA;&quot; full pattern is: lineno followed by , or ; and another lineno&#xA;&quot; nearly every field is optional though&#xA;let s:fullpat = '\v^\s*' . s:pat . '([,;]' . s:pat . ')?'&#xA;function! s:getrange(line)&#xA;    return matchstr(a:line, s:fullpat)&#xA;endfunction&#xA;&#xA;&quot; use &amp;lt;l1&amp;gt;GV&amp;lt;l2&amp;gt;G to visually select range&#xA;&quot; then restore the command line with feedkeys()&#xA;command! -range -nargs=1 ToVisual exe 'norm!' &amp;lt;line1&amp;gt; . 'GV' . &amp;lt;line2&amp;gt; . 'G' |&#xA;    \ redraw | call feedkeys(&quot;:\&amp;lt;C-U&amp;gt;&quot; . &amp;lt;q-args&amp;gt;, 'n')&#xA;&#xA;&quot; Press &amp;lt;C-X&amp;gt; while in the command line to make a visual selection&#xA;&quot; The command line contents will be restored automatically&#xA;cnoremap &amp;lt;silent&amp;gt;&amp;lt;C-X&amp;gt; &amp;lt;C-\&amp;gt;e(getcmdtype() == ':' ?&#xA;    \ 'silent ' . &amp;lt;SID&amp;gt;getrange(getcmdline()) . 'ToVisual ' : '') .&#xA;    \ getcmdline()&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-11-09T14:00:32.673" LastActivityDate="2019-11-09T14:00:32.673" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21838" PostTypeId="1" CreationDate="2019-11-09T11:20:20.297" Score="5" ViewCount="2415" Body="&lt;p&gt;This is my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;filetype off                  &quot; required&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'altercation/vim-colors-solarized'&#xA;Plugin 'ycm-core/YouCompleteMe'&#xA;Plugin 'vim-latex/vim-latex'&#xA;Plugin 'vim-scripts/LanguageTool'&#xA;Plugin 'vim-airline/vim-airline'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'tpope/vim-fugitive'&#xA;Plugin 'vimoutliner/vimoutliner'&#xA;Plugin 'majutsushi/tagbar'&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&#xA;set encoding=utf-8&#xA;let g:languagetool_jar='$HOME/Downloads/LanguageTool-4.7/languagetool-commandline.jar'&#xA;&#xA;&quot; color scheme&#xA;set background=light&#xA;let g:solarized_termcolors=256&#xA;colorscheme solarized&#xA;syntax enable&#xA;&#xA;&quot; tab behaviour&#xA;set expandtab&#xA;set tabstop=4&#xA;&quot;set shiftwidth=4&#xA;&#xA;&quot; UI&#xA;set number&#xA;set showcmd&#xA;set cursorline&#xA;filetype plugin indent on&#xA;&#xA;set wildmenu&#xA;set lazyredraw&#xA;set showmatch&#xA;set guifont=Consolas:h12:cANSI:qDRAFT&#xA;&#xA;&quot; searching&#xA;set hlsearch&#xA;nnoremap &amp;lt;leader&amp;gt;&amp;lt;space&amp;gt; :nohlsearch&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; general behaviour&#xA;let mapleader=&quot;,&quot;&#xA;set backspace=2&#xA;set autoread&#xA;set foldmethod=syntax&#xA;&#xA;let g:tex_flavor='latex'&#xA;let g:Tex_DefaultTargetFormat='pdf'&#xA;let g:Tex_MultipleCompileFormats='pdf'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have the following files under &lt;code&gt;C:\Users\Jordi\.vim\after\ftplugin&lt;/code&gt; with different indent settings and other settings&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/Jordi/.vim/&#xA;~ after/ftplugin/&#xA;    matlab.vim&#xA;    tex.vim&#xA;    arduino.vim&#xA;+ bundle/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;:filetype&lt;/code&gt; yields everything ON&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I check &lt;code&gt;:scriptnames&lt;/code&gt; the ftplugin scripts are never being loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="19397" LastEditorUserId="10604" LastEditDate="2019-11-09T23:34:29.410" LastActivityDate="2019-11-09T23:34:29.410" Title="ftplugin not loading" Tags="|vimrc|microsoft-windows|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="21839" PostTypeId="2" ParentId="21836" CreationDate="2019-11-09T13:09:27.090" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;For example :24 copy 12,22,25 it only pastes 24th line at 12th line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is interpreted as a range, not as a list, of which &lt;code&gt;copy&lt;/code&gt; is able to take a first address only.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a plugin or .vimrc setting that can help me achieve this behavior?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's missing, probably, because it's rarely found useful. But you can always add such command yourself.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:multicopy(line1, line2, ...) abort&#xA;  &quot; save the text to be copied&#xA;  let l:text = getline(a:line1, a:line2)&#xA;  &quot; sort line numbers to prevent overlapping&#xA;  let l:lines = reverse(sort(filter(map(copy(a:000),&#xA;    \ {k, v -&amp;gt; trim(execute(v . '=', 'silent!'))}), '!empty(v:val)'), 'N'))&#xA;  &quot; now make all the copies&#xA;  for l:line in l:lines&#xA;    call append(l:line, l:text)&#xA;  endfor&#xA;endfunction&#xA;command! -range -nargs=+ Copy call s:multicopy(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;, &amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that normally Ex commands use a space as an argument separator, so you are expected to type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:24Copy 12 22 25&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;UPD.: Added support for an arbitrary &lt;code&gt;:h :range&lt;/code&gt; specification. Known bugs/features:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/pat/&lt;/code&gt; and &lt;code&gt;?pat?&lt;/code&gt; always must be closed. That is, &lt;code&gt;Copy /foo&lt;/code&gt; is not supported, use &lt;code&gt;Copy /foo/&lt;/code&gt; instead.&lt;/li&gt;&#xA;&lt;li&gt;With a range a last address is taken. That is, &lt;code&gt;Copy 10,20&lt;/code&gt; is the same as &lt;code&gt;Copy 20&lt;/code&gt;, although &lt;code&gt;copy 10,20&lt;/code&gt; is the same as &lt;code&gt;copy 10&lt;/code&gt; (a range rarely makes sense for a &lt;code&gt;copy&lt;/code&gt; destination anyway).&lt;/li&gt;&#xA;&lt;li&gt;No error messages (E16, E486 etc.) are given for bad arguments.&lt;/li&gt;&#xA;&lt;li&gt;Executing an arbitrary string may have some unexpected side-effects.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-11-10T08:55:45.157" LastActivityDate="2019-11-10T08:55:45.157" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21840" PostTypeId="1" AcceptedAnswerId="21904" CreationDate="2019-11-09T15:23:45.140" Score="2" ViewCount="960" Body="&lt;p&gt;Recently, I have tried to create my own colorscheme in only one color and &lt;strong&gt;no text decoration&lt;/strong&gt;. That means &lt;code&gt;Normal&lt;/code&gt;, &lt;code&gt;Comment&lt;/code&gt;, &lt;code&gt;ToolbarLine&lt;/code&gt;, &lt;code&gt;Tooltip&lt;/code&gt;... are the same; &lt;code&gt;Visual&lt;/code&gt;, &lt;code&gt;Cursor&lt;/code&gt;... are reversed, of course; no bold, no underline, no italic found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every built-in highlighting is successfully overwritten to one color, I pick &lt;strong&gt;green color&lt;/strong&gt; for testing:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/a4UJM.png&quot; alt=&quot;Normal mode&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QR4Z3.png&quot; alt=&quot;Expected highlighting&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because there are many unexpected name of highlighting, so there are &lt;strong&gt;still some colorful highlighting&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6LR8x.png&quot; alt=&quot;Unexpected highlighting&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to overwrite color for &lt;strong&gt;not built-in&lt;/strong&gt; highlighting?&lt;/p&gt;&#xA;" OwnerUserId="25588" LastEditorUserId="25588" LastEditDate="2019-11-14T05:13:36.000" LastActivityDate="2019-11-14T09:04:29.600" Title="How to force overwriting ALL syntax highlighting in Vim?" Tags="|syntax-highlighting|colorscheme|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21841" PostTypeId="1" CreationDate="2019-11-09T16:11:28.177" Score="1" ViewCount="386" Body="&lt;p&gt;I am implementing a smooth scrolling function for &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt;, which just sleeps for a few milliseconds and then moves the screen up (&lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt;) or down (&lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt;) one line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function SmoothScroll(up)&#xA;    if a:up&#xA;        let scrollaction= &quot;\&amp;lt;C-y&amp;gt;&quot;&#xA;    else&#xA;        let scrollaction=&quot;\&amp;lt;C-e&amp;gt;&quot;&#xA;    endif&#xA;    let s=&amp;amp;scroll &quot; total lines to scroll&#xA;    let x=0   &quot; counts from 0 to s&#xA;    let T=10 &quot; maximum sleep ms for smoothing&#xA;    let a=3 &quot; smoothing amount&#xA;    let p=2 &quot; must be at least 2&#xA;    let m=s/p &quot; number of lines for which is being smoothed&#xA;    while x &amp;lt; s&#xA;      let time=T*((x-m)*(x-s+m)*(x+m/a)*(x-s-m/a))/(m*(s-m)*(-m/a)*(s+m/a))&#xA;      if time &amp;gt; 0&#xA;        exec &quot;sleep &quot;.time.&quot;m&quot;&#xA;      end&#xA;      let x+=1&#xA;      redraw&#xA;      exec &quot;normal &quot; . scrollaction&#xA;    endwhile&#xA;endfunction&#xA;nnoremap &amp;lt;C-U&amp;gt; :call SmoothScroll(1)&amp;lt;Enter&amp;gt;&#xA;nnoremap &amp;lt;C-D&amp;gt; :call SmoothScroll(0)&amp;lt;Enter&amp;gt;&#xA;inoremap &amp;lt;C-U&amp;gt; &amp;lt;Esc&amp;gt;:call SmoothScroll(1)&amp;lt;Enter&amp;gt;i&#xA;inoremap &amp;lt;C-D&amp;gt; &amp;lt;Esc&amp;gt;:call SmoothScroll(0)&amp;lt;Enter&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function for &lt;code&gt;time&lt;/code&gt; is visualized here:&#xA;&lt;a href=&quot;https://www.desmos.com/calculator/of6hhoo1p3&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.desmos.com/calculator/of6hhoo1p3&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem now is that &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; move the cursor when the cursor comes closer to the screen edge than &lt;code&gt;scrolloff&lt;/code&gt; lines. So when you repeatedly &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt;, the cursor ends up at least &lt;code&gt;scrolloff&lt;/code&gt; lines above the bottom of the screen. And when you repeatedly &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; the cursor ends up at least &lt;code&gt;scrolloff&lt;/code&gt; lines below the top of the screen. However when I use &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; I would like the cursor to stay where it is on the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there maybe a way to move both cursor and screen at the same time? I do not want to call both &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; for example, because if my &lt;code&gt;scrolloff&lt;/code&gt; variable was greater than half the lines on my screen (to always keep the cursor centered, which I occasionally want to use), then &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; would scroll twice as far. &lt;/p&gt;&#xA;" OwnerUserId="17840" LastActivityDate="2019-12-09T18:00:56.110" Title="Move cursor and screen together" Tags="|vimscript|cursor-movement|scrolling|cursor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21842" PostTypeId="2" ParentId="21841" CreationDate="2019-11-09T16:46:35.853" Score="0" Body="&lt;p&gt;I have now just checked manually whether the cursor is at the border of scrolloff, i.e. if it would be scrolled by &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt; for example or not, and if not, then I move it manually at each iteration with &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function SmoothScroll(up)&#xA;  let cursormov=&quot;&quot;&#xA;  if a:up&#xA;    let scrollaction= &quot;normal \&amp;lt;C-y&amp;gt;&quot;&#xA;    &quot; now also check how far the cursor is away&#xA;    &quot; from the border, including scrolloff&#xA;    let offdist = abs((line(&quot;w$&quot;) - &amp;amp;scrolloff) - line(&quot;.&quot;))&#xA;    if offdist &amp;gt; 0 || line(&quot;w0&quot;) &amp;lt; &amp;amp;scroll&#xA;      let cursormov=&quot;normal k&quot;&#xA;    endif&#xA;  else&#xA;    let scrollaction=&quot;normal \&amp;lt;C-e&amp;gt;&quot;&#xA;    let offdist = abs(line(&quot;.&quot;) - (line(&quot;w0&quot;) + &amp;amp;scrolloff))&#xA;    if offdist &amp;gt; 0&#xA;      let cursormov=&quot;normal j&quot;&#xA;    endif&#xA;  endif&#xA;  let s=&amp;amp;scroll &quot; total lines to scroll&#xA;  let x=0   &quot; counts from 0 to s&#xA;  let T=2 &quot; maximum sleep ms for smoothing&#xA;  let a=2 &quot; smoothing amount&#xA;  let p=2 &quot; must be at least 2&#xA;  let m=s/p &quot; number of lines for which is being smoothed&#xA;  while x &amp;lt; s&#xA;    let time=T*((x-m)*(x-s+m)*(x+m/a)*(x-s-m/a))/(m*(s-m)*(-m/a)*(s+m/a))&#xA;    if time &amp;gt; 0&#xA;      exec &quot;sleep &quot;.time.&quot;m&quot;&#xA;      redraw&#xA;    end&#xA;    let x+=1&#xA;    exec scrollaction&#xA;    exec cursormov&#xA;  endwhile&#xA;endfunction&#xA;nnoremap &amp;lt;C-U&amp;gt; :call SmoothScroll(1)&amp;lt;Enter&amp;gt;&#xA;nnoremap &amp;lt;C-D&amp;gt; :call SmoothScroll(0)&amp;lt;Enter&amp;gt;&#xA;inoremap &amp;lt;C-U&amp;gt; &amp;lt;Esc&amp;gt;:call SmoothScroll(1)&amp;lt;Enter&amp;gt;i&#xA;inoremap &amp;lt;C-D&amp;gt; &amp;lt;Esc&amp;gt;:call SmoothScroll(0)&amp;lt;Enter&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There may be a more efficient solution though. But this way the cursor also stays in place while smoothly scrolling.&lt;/p&gt;&#xA;" OwnerUserId="17840" LastEditorUserId="17840" LastEditDate="2019-11-09T17:20:29.913" LastActivityDate="2019-11-09T17:20:29.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21843" PostTypeId="2" ParentId="21841" CreationDate="2019-11-09T17:32:21.587" Score="1" Body="&lt;p&gt;Not an answer to your question. But thought I'd mention that this exists: &lt;a href=&quot;https://github.com/terryma/vim-smooth-scroll&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/terryma/vim-smooth-scroll&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24816" LastActivityDate="2019-11-09T17:32:21.587" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21844" PostTypeId="2" ParentId="21836" CreationDate="2019-11-09T21:58:29.770" Score="2" Body="&lt;p&gt;Use &lt;a href=&quot;https://github.com/mg979/vim-visual-multi&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-visual-multi&lt;/code&gt;&lt;/a&gt;. Create cursors at different places using &lt;code&gt;\\c&lt;/code&gt; and press &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="6498" LastEditDate="2019-12-11T07:54:45.750" LastActivityDate="2019-12-11T07:54:45.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21846" PostTypeId="1" AcceptedAnswerId="21847" CreationDate="2019-11-10T08:42:09.963" Score="4" ViewCount="975" Body="&lt;p&gt;I got an error when opening my &lt;code&gt;.vimrc&lt;/code&gt; with &lt;code&gt;vim&lt;/code&gt; saying &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;.vimrc&quot; 138L, 3781C&#xA;Error detected while processing /home/fbence/.vim/view/~=+.vimrc=:&#xA;line  117:&#xA;E518: Unknown option: termkey=&#xA;line  118:&#xA;E518: Unknown option: termsize=&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I saw that it is opening some file I didn't create. What is the purpose of the files here? Can I delete them? What is this &quot;unknown option&quot; vim found here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am really unsure how to tag this question, but I need to sooo.&lt;/p&gt;&#xA;" OwnerUserId="25312" LastEditorUserId="51" LastEditDate="2021-01-27T03:11:40.783" LastActivityDate="2021-01-27T03:11:40.783" Title="what is the purpose of the view folder in the .vim folder?" Tags="|options|sessions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21847" PostTypeId="2" ParentId="21846" CreationDate="2019-11-10T09:20:48.753" Score="4" Body="&lt;p&gt;&lt;code&gt;~/.vim/view&lt;/code&gt; is a default value (under *nix) for &lt;code&gt;:h 'viewdir'&lt;/code&gt; option, which, in turn, is used by the &lt;code&gt;:h :mkview&lt;/code&gt; and &lt;code&gt;:h :loadview&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:mkview&lt;/code&gt; is a rarely used &lt;code&gt;:mksession&lt;/code&gt;-like command which saves some settings of a single window/view.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-10T09:20:48.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21848" PostTypeId="1" AcceptedAnswerId="21849" CreationDate="2019-11-10T13:54:31.453" Score="1" ViewCount="128" Body="&lt;p&gt;I wanted to have my vimrc automatically update when I write to a .vim file using this autocmd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.vim,$MYVIMRC source $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But for some reason when I have this enabled and then do &lt;code&gt;:w&lt;/code&gt; in my vimrc, my vimrc is pasted into my current buffer at the cursor position. How can I prevent this, and why does &lt;code&gt;source&lt;/code&gt; behave like this?&lt;/p&gt;&#xA;" OwnerUserId="17840" LastActivityDate="2019-11-10T16:41:16.430" Title="Autoreload vimrc when writing to vimscript files" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21849" PostTypeId="2" ParentId="21848" CreationDate="2019-11-10T14:21:43.857" Score="1" Body="&lt;p&gt;This code works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup reload_vimrc&#xA;    autocmd!&#xA;    autocmd BufWritePost *.vim,vimrc,$MYVIMRC ++once source $MYVIMRC | e&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;does the &lt;code&gt;augroup group&lt;/code&gt;/&lt;code&gt;autocmd!&lt;/code&gt; dance to set up a group and clear any commands already in it&lt;/li&gt;&#xA;&lt;li&gt;establishes a one-time (&lt;code&gt;++once&lt;/code&gt;) autocmd that&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;sources the vimrc&lt;/li&gt;&#xA;&lt;li&gt;uses &lt;code&gt;:edit&lt;/code&gt; to re-edit the current file (effectively sourcing its ftplugins and such again)&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;Ends the group&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="17840" LastEditorUserId="10604" LastEditDate="2019-11-10T16:41:16.430" LastActivityDate="2019-11-10T16:41:16.430" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21851" PostTypeId="1" CreationDate="2019-11-11T00:53:33.090" Score="5" ViewCount="2441" Body="&lt;p&gt;When I'm writing, I often have 2-3 buffers open. My main body of text in the middle, and then supporting materials on the left and right. I often read a paragraph from one of the supporting buffers then switch back to the primary to write for a while before switching back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to figure out how I can highlight a paragraph without selecting it. Is this the &lt;code&gt;highlight&lt;/code&gt; command or am I barking up the wrong tree? That seems like it's related specifically to syntax highlighting, rather than being able to highlight arbitrary blocks of text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I should clarify that part of why I want to highlight without selecting is that the side windows might be on the same buffer, and 'locked' together rather than independently operated; one can scroll independently but they lock together if you select then switch to another. I may want to look at two different parts of the document and select mode restricts freedom. I tested this, and can't seem to open a new independent buffer on the same file; editing the same file just makes that window join the same buffer.&lt;/p&gt;&#xA;" OwnerUserId="158" LastEditorUserId="158" LastEditDate="2019-11-11T17:23:22.433" LastActivityDate="2020-04-10T01:02:00.290" Title="Highlighting arbitrary text" Tags="|highlight|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="21852" PostTypeId="2" ParentId="21851" CreationDate="2019-11-11T01:36:08.900" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/syntax.txt.html#%3Ahighlight&quot; rel=&quot;noreferrer&quot;&gt;:h :highlight&lt;/a&gt; is used to define highlight group. What you want is the &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%3Amatch&quot; rel=&quot;noreferrer&quot;&gt;:h :match&lt;/a&gt; , &lt;a href=&quot;https://vimhelp.org/eval.txt.html#matchadd%28%29&quot; rel=&quot;noreferrer&quot;&gt;:h matchadd()&lt;/a&gt; families.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how I will do it.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Goal&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Highlight arbitary area without staying in visual mode, all wise type should be supported.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How to do it&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The job can be split into three main parts:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Select arbitary area:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two ways to select arbitary area in vim.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Operator ( bound to &lt;code&gt;,h&lt;/code&gt; )&lt;/li&gt;&#xA;&lt;li&gt;visual select&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Highlight it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We will use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#matchadd%28%29&quot; rel=&quot;noreferrer&quot;&gt;:h matchadd()&lt;/a&gt; to do it. We can use &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%25l&quot; rel=&quot;noreferrer&quot;&gt;:h /\%l&lt;/a&gt; , &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%25c&quot; rel=&quot;noreferrer&quot;&gt;:h /\%c&lt;/a&gt; to to control the highlight area precisely.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Remove highlight area where the cursor is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We will create a map &lt;code&gt;,hh&lt;/code&gt; for this. We must keep track of every highlighted area and compare current cursor position with them in order for this to work.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;The result&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;So after finishing it, you can use &lt;code&gt;,h{motion}&lt;/code&gt; to highlight some area and &lt;code&gt;,hh&lt;/code&gt; to remove highlight under cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also select arbitary area in any visual mode you like and use &lt;code&gt;,h&lt;/code&gt; to highlight it.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Build the skeleton&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I call a highlight area a &lt;code&gt;hblock&lt;/code&gt;. &lt;code&gt;wnd_hblocks&lt;/code&gt; is a list of hblocks per window.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ,h :set opfunc=AddHighlight&amp;lt;CR&amp;gt;g@&#xA;vnoremap ,h :&amp;lt;C-U&amp;gt;call AddHighlight(visualmode(), 1)&amp;lt;CR&amp;gt;&#xA;nnoremap ,hh :call &amp;lt;sid&amp;gt;remove_cursor_highlights()&amp;lt;cr&amp;gt;&#xA;&#xA;function AddHighlight(type, ...) abort&#xA;  let visual = get(a:000, 0, 0)&#xA;  let hblock = s:create_hblock(a:type, visual)&#xA;  call s:highlight(hblock)&#xA;endfunction&#xA;&#xA;function s:remove_cursor_highlights() abort&#xA;  let wnd_hblocks = s:get_wnd_hblocks( bufwinid('') )&#xA;&#xA;  &quot; clear highlight&#xA;  call map( copy(wnd_hblocks),&#xA;        \ { i,v -&amp;gt; s:contain( v, getcurpos() ) &amp;amp;&amp;amp; matchdelete(v.hid) } )&#xA;&#xA;  &quot; clear hblocks&#xA;  call filter( wnd_hblocks, { i,v -&amp;gt; !s:contain( v, getcurpos() ) } )&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;The data structure&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;We will keep track of every hblock, including it's start, end position and selection type.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; { winid: [ {hid: , start:  , end:  , wise :  }, ... ] , ...  }&#xA;&quot; hid : highlight id return from matchadd&#xA;&quot; start : start of cursor pos, same as getcurpos()&#xA;&quot; end : ditto&#xA;&quot; wise : v, V or &quot;\&amp;lt;c-v&amp;gt;&quot;&#xA;let s:hblocks = {}&#xA;&#xA;function s:create_hblock(type, visual) abort&#xA;  if a:visual&#xA;    let wise = visualmode()&#xA;    let start = getpos(&quot;'&amp;lt;&quot;)&#xA;    let end = getpos(&quot;'&amp;gt;&quot;)&#xA;  else&#xA;    let wise = a:type ==# 'char' ? 'v' : a:type ==# 'line' ? 'V' : &quot;\&amp;lt;c-v&amp;gt;&quot;&#xA;    let start = getpos(&quot;'[&quot;)&#xA;    let end = getpos(&quot;']&quot;)&#xA;  endif&#xA;&#xA;  return {'wise':wise, 'start':start, 'end': end}&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Rest of the book keeping and highlighting&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:highlight(hblock) abort&#xA;  let pattern = s:build_pattern(a:hblock)&#xA;&#xA;  &quot; lazy man's debug register&#xA;  let @/ = pattern&#xA;  let a:hblock.hid = matchadd('VISUAL', pattern)&#xA;  let wnd_hblocks = s:get_wnd_hblocks( bufwinid('') )&#xA;  call insert(wnd_hblocks, a:hblock)&#xA;endfunction&#xA;&#xA;function s:get_wnd_hblocks(winid)&#xA;  if !has_key(s:hblocks, a:winid)&#xA;    let s:hblocks[a:winid] = []&#xA;  endif&#xA;  return s:hblocks[a:winid]&#xA;endfunction&#xA;&#xA;function s:contain(hblock, pos)&#xA;  let [l0,c0] = a:hblock.start[1:2]&#xA;  let [l1,c1] = a:hblock.end[1:2]&#xA;  let [l2,c2] = a:pos[1:2]&#xA;&#xA;  if l2 &amp;lt; l0 || l2 &amp;gt; l1&#xA;    return 0&#xA;  endif&#xA;&#xA;  if a:hblock.wise ==# 'V'&#xA;    return 1&#xA;  elseif a:hblock.wise ==# &quot;\&amp;lt;c-v&amp;gt;&quot;&#xA;    return c2 &amp;gt;= c0 || c2 &amp;lt;= c1&#xA;  else&#xA;&#xA;    &quot; not ( cursor in the upper left corner or cursor in the lower right corner)&#xA;    return !( l2 == l0 &amp;amp;&amp;amp; c2 &amp;lt; c0 || l2 == l1 &amp;amp;&amp;amp; c2 &amp;gt; c1 )&#xA;  endif&#xA;endfunction&#xA;&#xA;function s:build_pattern(hblock)&#xA;  let [l0,c0] = a:hblock.start[1:2]&#xA;  let [l1,c1] = a:hblock.end[1:2]&#xA;&#xA;  if a:hblock.wise ==# 'V'&#xA;    return printf('\v%%&amp;gt;%dl^.*%%&amp;lt;%dl', l0 - 1, l1 + 1)&#xA;  elseif a:hblock.wise ==# &quot;\&amp;lt;c-v&amp;gt;&quot;&#xA;&#xA;    &quot; restrict cols on all lines&#xA;    return  printf('\v%%&amp;gt;%dl%%&amp;gt;%dc.*%%&amp;lt;%dl%%&amp;lt;%dc', l0 - 1, c0 - 1, l1 + 1, c1 + 1)&#xA;  else&#xA;    if l0 != l1&#xA;&#xA;      &quot; mid lines | tail of 1st line | head of last line&#xA;      return printf('\v%%&amp;gt;%dl^.*%%&amp;lt;%dl|%%%dl%%&amp;gt;%dc.*|%%%dl%%&amp;lt;%dc.*', l0, l1, l0, c0 - 1, l1, c1 + 1)&#xA;    else&#xA;&#xA;      &quot; mid of the only line&#xA;      return printf('\v%%%dl%%&amp;gt;%dc.*%%%dl%%&amp;lt;%dc', l0, c0 - 1, l1, c1 + 1)&#xA;    endif&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-11-11T23:09:54.700" LastActivityDate="2019-11-11T23:09:54.700" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21853" PostTypeId="1" AcceptedAnswerId="21854" CreationDate="2019-11-11T09:00:32.237" Score="2" ViewCount="126" Body="&lt;p&gt;I'm trying to understand logic of text-object-selection in the presence of double qoutes. In the following lines &lt;code&gt;*&lt;/code&gt; denotes cursor position, &lt;code&gt;//&lt;/code&gt; denotes my comments.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a&quot;b(c*d)e&quot;f //di) deletes everything inside parens, as expected&#xA;a&quot;b(c&quot;*d)e&quot;f //di) deletes everything inside parens, as expected&#xA;a&quot;b(c&quot;*d)e&quot;f&quot;g //di) does nothing&#xA;a&quot;b&quot;g(c&quot;*d)e&quot;f //di) does nothing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why in the last two lines doesn't &lt;code&gt;di)&lt;/code&gt; work? Why does it depend on the number of quotes outside parentheses? Is there any place where all details are described? (I didn’t find any &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#object-select&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="25606" LastEditorUserId="10604" LastEditDate="2019-11-11T13:20:54.213" LastActivityDate="2019-11-11T13:20:54.213" Title="Interaction of object-select with double quotes" Tags="|object-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21854" PostTypeId="2" ParentId="21853" CreationDate="2019-11-11T09:33:39.687" Score="1" Body="&lt;p&gt;It's in the docs, but you need to jump around a bit. &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#i%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h i)&lt;/code&gt;&lt;/a&gt; says it's like &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%5B%28&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;[(&lt;/code&gt;&lt;/a&gt;, which in turn is like &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#%25&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;%&lt;/code&gt;&lt;/a&gt;, which is affected by &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;cpoptions&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'cpoptions'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the '&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/motion.html#%25&quot; rel=&quot;nofollow noreferrer&quot;&gt;%&lt;/a&gt;' character is not present in &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;cpoptions&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;'cpoptions'&lt;/a&gt; |&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#cpo-%25&quot; rel=&quot;nofollow noreferrer&quot;&gt;cpo-%&lt;/a&gt;|, parens&#xA;  and braces inside double quotes are ignored, unless the number of&#xA;  parens/braces in a line is uneven and this line and the previous one&#xA;  does not end in a backslash.  '(', '{', '[', ']', '}' and ')' are also&#xA;  ignored (parens and braces inside single quotes).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's what you're seeing. If you do &lt;code&gt;:set cpoptions+=%&lt;/code&gt;, &lt;code&gt;di)&lt;/code&gt; will consistently delete everything inside the parentheses.&lt;/p&gt;&#xA;" OwnerUserId="205" LastEditorUserId="205" LastEditDate="2019-11-11T10:08:31.747" LastActivityDate="2019-11-11T10:08:31.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21856" PostTypeId="1" AcceptedAnswerId="21859" CreationDate="2019-11-11T10:48:52.863" Score="6" ViewCount="562" Body="&lt;p&gt;I can't remember start from when and why, i always add &lt;code&gt;!&lt;/code&gt; to &lt;code&gt;function&lt;/code&gt; and &lt;code&gt;command&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ..&#xA;...&#xA;endfunction&#xA;&#xA;command! ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;:h E122&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            When a function by this name already exists and [!] is&#xA;            not used an error message is given.  There is one&#xA;            exception: When sourcing a script again, a function&#xA;            that was previously defined in that script will be&#xA;            silently replaced.&#xA;            When [!] is used, an existing function is silently&#xA;            replaced.  Unless it is currently being executed, that&#xA;            is an error.&#xA;            NOTE: Use ! wisely.  If used without care it can cause&#xA;            an existing function to be replaced unexpectedly,&#xA;            which is hard to debug.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In short, one should use &lt;code&gt;!&lt;/code&gt; only when one need to replace an existing function defined in other scripts. But nothing good would happen if such replace happens, right? So it should be avoided?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I went through a few popular plugins on my machine, all of them use &lt;code&gt;!&lt;/code&gt;, even for a script scope function, does that make sense? am i missing something?&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-11-11T11:54:17.497" LastActivityDate="2022-01-21T12:50:32.443" Title="Is it necessary to always add ! to function and command" Tags="|vimscript|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21857" PostTypeId="2" ParentId="21856" CreationDate="2019-11-11T13:57:44.827" Score="2" Body="&lt;p&gt;Yes, I also wondered at seeing this topic first time. I suspect that the whole story is due to VimScript version changes, however, personally I still see these points:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;As it turns out, for a &lt;em&gt;script-local&lt;/em&gt; function there's absolutely no difference between &lt;code&gt;function&lt;/code&gt; and &lt;code&gt;function!&lt;/code&gt;. Therefore, it becomes rather a matter of taste: some people may prefer &quot;shorter&quot; notation, but writing &lt;code&gt;function! s:myfunc()&lt;/code&gt; clearly indicates that this thing is &quot;silently re-sourceable&quot; what I think isn't too bad.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For a global &lt;code&gt;function&lt;/code&gt;, there's a small chance of a name clash catching, however many plugins tend to prefer autoloaded functions anyway, and a clash inside your own config is very unlikely.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sometimes I also like &lt;code&gt;execute()&lt;/code&gt;-ing things from a &quot;scratch&quot; buffer. Such stuff must be global and have a &quot;bang&quot; to allow subsequent overwrite.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Just a stupid habit of blindly writing &lt;code&gt;function!&lt;/code&gt; and &lt;code&gt;command!&lt;/code&gt; (yes, &lt;code&gt;command!&lt;/code&gt; should be frowned upon too) ;-)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-11T13:57:44.827" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21858" PostTypeId="1" AcceptedAnswerId="21861" CreationDate="2019-11-11T14:58:05.687" Score="0" ViewCount="194" Body="&lt;p&gt;I'm using fzf's Rg command to populate QuickFix window with all search results. I also have my own mappings to &lt;code&gt;:cn&lt;/code&gt; and &lt;code&gt;:cp&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything is fine except one thing when I press mapped key for &lt;code&gt;:cn&lt;/code&gt; command new buffer is opened and the line with searched text is positioned very close to the bottom edge of window. So if I searched for function name I need to scroll down to see function's body.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to change this behavior? I would like to position line with found text somewhere near the middle of the window.&lt;/p&gt;&#xA;" OwnerUserId="25427" LastActivityDate="2019-11-11T16:35:18.110" Title="Line position after quickfix jump" Tags="|quickfix|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21859" PostTypeId="2" ParentId="21856" CreationDate="2019-11-11T15:50:46.790" Score="7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;When sourcing a script again, a function that was previously defined in that script will be silently replaced.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's a fairly recent (Vim 8.1) change. Previously, you had to use &lt;code&gt;:function!&lt;/code&gt; to redefine an existing function. As plugin writers very frequently reload their scripts during development (as its much faster than restarting Vim and restoring all context), you still see &lt;code&gt;:function!&lt;/code&gt; in most plugins, although going forward, this isn't needed any longer.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-11T15:50:46.790" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21860" PostTypeId="2" ParentId="21840" CreationDate="2019-11-11T16:05:03.597" Score="0" Body="&lt;p&gt;Most &lt;em&gt;filetypes&lt;/em&gt; (like &lt;code&gt;python&lt;/code&gt;) in Vim come with a syntax that defines highlight groups (see them via &lt;code&gt;:highlight python&amp;lt;C-d&amp;gt;&lt;/code&gt;). These particular groups (e.g. &lt;code&gt;pythonFunction&lt;/code&gt;) are then &lt;em&gt;linked&lt;/em&gt; to a set of default groups (&lt;code&gt;:help highlight-groups&lt;/code&gt;, e.g. &lt;code&gt;Identifier&lt;/code&gt;). A &lt;em&gt;colorscheme&lt;/em&gt; then provides combinations of foreground / background color and/or formatting like bold and italic (separately for terminals, color terminals, and/or GVIM) for the default groups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Plugins&lt;/em&gt; are also encouraged to link to existing default groups; after all, these adhere to the user's preferred style and will work under whatever conditions (low-color / high-color terminal / GUI, bright / dark) the user has. However, some plugins either provide functionality that has no existing related concept in Vim, or they need a highlighting that is relatively independent of user choices (like red / green for test results; those should always look red / green even if the user prefers bluish hues).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what you see is that &lt;em&gt;Lightline&lt;/em&gt; plugin not linking to the default groups. That plugin should use &lt;a href=&quot;https://vimhelp.appspot.com/syntax.txt.html#%3Ahighlight-default&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :highlight-default&lt;/code&gt;&lt;/a&gt;, so you can override its custom definitions (with greenish ones) with &lt;code&gt;:highlight LightlineLeft_replace_1 ...&lt;/code&gt; in your &lt;code&gt;~/.vimrc&lt;/code&gt; (you can always &lt;em&gt;overwrite&lt;/em&gt; them later, e.g. on &lt;code&gt;VimEnter&lt;/code&gt;). Yes, that's a lot of definitions there (but apparently mostly combinations of a few base colors and text attributes, and you want just green, anyway), but this needs to be done only once, for this plugin and maybe a few more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could employ &lt;em&gt;meta-programming&lt;/em&gt; and go over all &lt;code&gt;:hi&lt;/code&gt; definitions &lt;em&gt;after&lt;/em&gt; Vim startup (so plugins have added their definitions) and change them to green.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-11T16:05:03.597" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21861" PostTypeId="2" ParentId="21858" CreationDate="2019-11-11T16:35:18.110" Score="2" Body="&lt;p&gt;The &lt;code&gt;zz&lt;/code&gt; command and it’s siblings &lt;code&gt;zb&lt;/code&gt; and &lt;code&gt;zt&lt;/code&gt; are helpful positioning commands. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, I would probably update your mapping to do &lt;code&gt;zz&lt;/code&gt; (center cursor) after &lt;code&gt;:cnext&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-11T16:35:18.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21862" PostTypeId="1" AcceptedAnswerId="21863" CreationDate="2019-11-11T17:10:39.803" Score="5" ViewCount="347" Body="&lt;p&gt;When I set &lt;code&gt;foldtext&lt;/code&gt; to a simple value like &lt;code&gt;getline(v:foldstart)&lt;/code&gt;, vim should show the current line, as opposed to the usual &lt;code&gt;+&lt;/code&gt; and appropriate number of hyphens &lt;code&gt;-&lt;/code&gt; for the foldlevel. However, vim fills the remaining space till the far side of the window width with dashes, which I don't want. Is there any way to prevent this?&lt;/p&gt;&#xA;" OwnerUserId="25608" LastActivityDate="2019-11-11T17:52:24.057" Title="remove trailing dashes in foldtext" Tags="|folding|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21863" PostTypeId="2" ParentId="21862" CreationDate="2019-11-11T17:52:24.057" Score="2" Body="&lt;p&gt;This is due to &lt;code&gt;:h 'fillchars'&lt;/code&gt; option. You need&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fcs=fold:\ ,vert:\|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-11T17:52:24.057" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21864" PostTypeId="2" ParentId="9426" CreationDate="2019-11-11T22:13:44.960" Score="1" Body="&lt;p&gt;Some [lightly edited] info from the comments:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Actually this might be the reason for empty Quickfix window. On your screen cast when you run &lt;code&gt;:lopen&lt;/code&gt;, Neomake runs for that buffer due to the autocmd for BufEnter. It should be additionally limited to JavaScript files only:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup neomake&#xA;  au!&#xA;  autocmd BufWritePost *.js Neomake&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-11T22:13:44.960" CommentCount="0" CommunityOwnedDate="2019-11-11T22:13:44.960" ContentLicense="CC BY-SA 4.0" />
  <row Id="21865" PostTypeId="1" CreationDate="2019-11-12T01:37:48.767" Score="1" ViewCount="233" Body="&lt;p&gt;I implemented a fuzzy filter, which &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;accept a list argument, &lt;/li&gt;&#xA;&lt;li&gt;open a window with a scratch buffer whose content set to the list, then &lt;/li&gt;&#xA;&lt;li&gt;waiting for use input and do filtering.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is why I ask this question, in the key loop, I want &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;after &lt;code&gt;/&lt;/code&gt; was type, go into a pass through mode, just like &lt;code&gt;/&lt;/code&gt; was typed in normal mode, thus subsquent keys will do search, and move cursor of the scratch window, since &lt;code&gt;incsearch&lt;/code&gt; was set, &lt;/li&gt;&#xA;&lt;li&gt;after &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-m&amp;gt;&lt;/code&gt; was typed, return back to previous key loop mode.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is there any way to achieve above effect? I tried define a Handler for &lt;code&gt;/&lt;/code&gt;, which &lt;code&gt;getchar()&lt;/code&gt; then &lt;code&gt;feedkeys()&lt;/code&gt; after &lt;code&gt;feedkeys('/')&lt;/code&gt;, but seems caused infinite recursion/loop, which bumps cpu usage to 24%.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2020-08-09T23:07:20.773" Title="Can I use feedkeys() inside of a keyloop implemented by getchar()" Tags="|vimscript|search|cursor-movement|ex-mode|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="21866" PostTypeId="2" ParentId="3386" CreationDate="2019-11-12T04:49:47.833" Score="5" Body="&lt;p&gt;The two commands defined below move all buffers from the right hand tab to the current tab and then close the right hand tab. &lt;code&gt;Mtabsp&lt;/code&gt; moves them by splitting horizontally and &lt;code&gt;Mtabvsp&lt;/code&gt; splits vertically. You need to move the merged tab before using the commands. Use &lt;code&gt;+tabm&lt;/code&gt;, &lt;code&gt;-tabm&lt;/code&gt; or &lt;code&gt;&amp;lt;n&amp;gt;tabm&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Setup&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Add the below vim script to your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Mtab(vert)&#xA;    if tabpagenr() == tabpagenr(&quot;$&quot;)&#xA;        return 0&#xA;    endif&#xA;    +tabnext&#xA;    let s:killed_tab = tabpagenr()&#xA;    let s:buf_list = tabpagebuflist()&#xA;    -tabnext&#xA;    for item in s:buf_list&#xA;        if a:vert&#xA;            vsp&#xA;        else&#xA;            sp&#xA;        endif&#xA;        execute &quot;buf &quot; . item&#xA;    endfor&#xA;    execute &quot;tabclose &quot; . s:killed_tab&#xA;endfunction&#xA;&#xA;command! Mtabsp call Mtab(0)&#xA;command! Mtabvsp call Mtab(1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Technical details&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The function Mtab receives one parameter &lt;code&gt;vert&lt;/code&gt;. It determines if the current tab is split horizontally or vertically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The desired outcome is achieved with the following steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We move to the next tab temporarily&lt;/li&gt;&#xA;&lt;li&gt;Use two variables to reference its tab number and buffers&lt;/li&gt;&#xA;&lt;li&gt;Return to the current tab&lt;/li&gt;&#xA;&lt;li&gt;We split the tab and open each buffer&lt;/li&gt;&#xA;&lt;li&gt;Finally, we close the right hand tab&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If our current tab is last, the commands are ignored.&lt;/p&gt;&#xA;" OwnerUserId="25610" LastActivityDate="2019-11-12T04:49:47.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21867" PostTypeId="1" CreationDate="2019-11-12T04:57:14.750" Score="0" ViewCount="3052" Body="&lt;p&gt;I've installed coc following the instruction, using Vim-Plug (before that I did it without installing yarn and with kite still (partially) installed. I got a 'javascript file not found' error So I uninstalled and reinstalled, then I got this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KAmRv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KAmRv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This time no errors, but the thing just isn't working. I tried :call coc#util#install(), does not help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any other step I should take in order to make this work? If not, how can I debug this business to understand what's the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I further ran :CocInstall coc-python, it asked me to install a linter, I chose install. The installation went on, there were several errors that popped up, but it was to fast in order to read them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 2: when running :CocConfig I get this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NGpWa.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NGpWa.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 3: tried to install from branch, also, nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 4: seems that it does autocomplete perhaps only the commands I already used in the current document. See screenshot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/365F1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/365F1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 5: some details that might be relevant:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/66hma.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/66hma.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pxy09.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pxy09.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ESHNt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ESHNt.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7EO8U.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7EO8U.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ruler&#xA;set ai&#xA;set cursorline&#xA;set cursorcolumn&#xA;set hlsearch&#xA;set incsearch&#xA;set ignorecase&#xA;set smartcase&#xA;set showcmd&#xA;set clipboard+=unnamed&#xA;set backspace=indent,eol,start&#xA;set number&#xA;set belloff+=ctrlg  &quot; if vim beeps during completion&#xA;set completeopt+=preview&#xA;set statusline=%&amp;lt;%f\ %h%m%r%{kite#statusline()}%=%-14.(%l,%c%V%)\ %P&#xA;set laststatus=2&#xA;&#xA;nnoremap &amp;lt;plug&amp;gt;(slash-after) zz&#xA;&#xA;let g:lightline = {&#xA;      \ 'colorscheme': 'one',&#xA;      \ }&#xA;let g:vim_search_pulse_mode = 'cursor_line'&#xA;let g:python_highlight_all = 1&#xA;let g:codi#width = 60&#xA;let g:kite_auto_complete=1&#xA;let g:kite_tab_complete=1&#xA;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F5&amp;gt; :w &amp;lt;bar&amp;gt; :exec '!clear &amp;amp;&amp;amp; python3' shellescape(@%, 1)&amp;lt;cr&amp;gt;&#xA;&#xA;&quot;Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.&#xA;&quot;If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support&#xA;&quot;(see &amp;lt; http://sunaku.github.io/tmux-24bit-color.html#usage &amp;gt; for more information.)&#xA;if (empty($TMUX))&#xA;  if (has(&quot;nvim&quot;))&#xA;    let $NVIM_TUI_ENABLE_TRUE_COLOR=1&#xA;  endif&#xA;  if (has(&quot;termguicolors&quot;))&#xA;    set termguicolors&#xA;  endif&#xA;endif&#xA;&#xA;colorscheme onedark&#xA;&#xA;&#xA;if empty(glob('~/.vim/autoload/plug.vim'))&#xA;  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs&#xA;    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC&#xA;endif&#xA;&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;&quot; Make sure you use single quotes&#xA;&#xA;Plug 'joshdick/onedark.vim'&#xA;Plug 'sheerun/vim-polyglot'&#xA;Plug 'itchyny/lightline.vim'&#xA;Plug 'lfv89/vim-interestingwords'&#xA;Plug 'junegunn/vim-slash'&#xA;Plug 'inside/vim-search-pulse'&#xA;Plug 'easymotion/vim-easymotion'&#xA;Plug 'tmsvg/pear-tree'&#xA;Plug 'Yggdroot/indentLine'&#xA;Plug 'godlygeek/tabular'&#xA;Plug 'plasticboy/vim-markdown'&#xA;&#xA;&quot; Initialize plugin system&#xA;call plug#end()&#xA;&#xA;execute pathogen#infect()&#xA;filetype plugin indent on&#xA;syntax on&#xA;let g:pymode_python = 'python3'&#xA;&#xA;let g:indentLine_color_term = 239&#xA;let g:indentLine_char_list = ['|', '¦', '┆', '┊']&#xA;let g:indentLine_conceallevel=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My .zshrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bindkey &quot;^[^[[D&quot; backward-word&#xA;bindkey &quot;^[^[[C&quot; forward-word&#xA;&#xA;# Aliases&#xA;alias ls='colorls'&#xA;alias lc='colorls -lA --sd'&#xA;alias vim=&quot;/usr/local/bin/vim&quot;&#xA;alias _z='vim ~/.zshrc'&#xA;alias _v='vim ~/.vimrc'&#xA;&#xA;source $(dirname $(gem which colorls))/tab_complete.sh&#xA;&#xA;# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.&#xA;# Initialization code that may require console input (password prompts, [y/n]&#xA;# confirmations, etc.) must go above this block, everything else may go below.&#xA;if [[ -r &quot;${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh&quot; ]]; then&#xA;  source &quot;${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh&quot;&#xA;fi&#xA;&#xA;&#xA;# If you come from bash you might have to change your $PATH.&#xA;# export PATH=$HOME/bin:/usr/local/bin:$PATH&#xA;&#xA;# Path to your oh-my-zsh installation.&#xA;export ZSH=&quot;/Users/idankor/.oh-my-zsh&quot;&#xA;export LC_ALL=en_US.UTF-8&#xA;&#xA;# Set name of the theme to load --- if set to &quot;random&quot;, it will&#xA;# load a random theme each time oh-my-zsh is loaded, in which case,&#xA;# to know which specific one was loaded, run: echo $RANDOM_THEME&#xA;# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes&#xA;ZSH_THEME=&quot;robbyrussell&quot;&#xA;&#xA;# Set list of themes to pick from when loading at random&#xA;# Setting this variable when ZSH_THEME=random will cause zsh to load&#xA;# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/&#xA;# If set to an empty array, this variable will have no effect.&#xA;# ZSH_THEME_RANDOM_CANDIDATES=( &quot;robbyrussell&quot; &quot;agnoster&quot; )&#xA;&#xA;# Uncomment the following line to use case-sensitive completion.&#xA;# CASE_SENSITIVE=&quot;true&quot;&#xA;&#xA;# Uncomment the following line to use hyphen-insensitive completion.&#xA;# Case-sensitive completion must be off. _ and - will be interchangeable.&#xA;# HYPHEN_INSENSITIVE=&quot;true&quot;&#xA;&#xA;# Uncomment the following line to disable bi-weekly auto-update checks.&#xA;# DISABLE_AUTO_UPDATE=&quot;true&quot;&#xA;&#xA;# Uncomment the following line to automatically update without prompting.&#xA;# DISABLE_UPDATE_PROMPT=&quot;true&quot;&#xA;&#xA;# Uncomment the following line to change how often to auto-update (in days).&#xA;# export UPDATE_ZSH_DAYS=13&#xA;&#xA;# Uncomment the following line if pasting URLs and other text is messed up.&#xA;# DISABLE_MAGIC_FUNCTIONS=true&#xA;&#xA;# Uncomment the following line to disable colors in ls.&#xA;# DISABLE_LS_COLORS=&quot;true&quot;&#xA;&#xA;# Uncomment the following line to disable auto-setting terminal title.&#xA;# DISABLE_AUTO_TITLE=&quot;true&quot;&#xA;&#xA;# Uncomment the following line to enable command auto-correction.&#xA;# ENABLE_CORRECTION=&quot;true&quot;&#xA;&#xA;# Uncomment the following line to display red dots whilst waiting for completion.&#xA;# COMPLETION_WAITING_DOTS=&quot;true&quot;&#xA;&#xA;# Uncomment the following line if you want to disable marking untracked files&#xA;# under VCS as dirty. This makes repository status check for large repositories&#xA;# much, much faster.&#xA;# DISABLE_UNTRACKED_FILES_DIRTY=&quot;true&quot;&#xA;&#xA;# Uncomment the following line if you want to change the command execution time&#xA;# stamp shown in the history command output.&#xA;# You can set one of the optional three formats:&#xA;# &quot;mm/dd/yyyy&quot;|&quot;dd.mm.yyyy&quot;|&quot;yyyy-mm-dd&quot;&#xA;# or set a custom format using the strftime function format specifications,&#xA;# see 'man strftime' for details.&#xA;# HIST_STAMPS=&quot;mm/dd/yyyy&quot;&#xA;&#xA;# Would you like to use another custom folder than $ZSH/custom?&#xA;# ZSH_CUSTOM=/path/to/new-custom-folder&#xA;&#xA;# Which plugins would you like to load?&#xA;# Standard plugins can be found in ~/.oh-my-zsh/plugins/*&#xA;# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/&#xA;# Example format: plugins=(rails git textmate ruby lighthouse)&#xA;# Add wisely, as too many plugins slow down shell startup.&#xA;plugins=(git zsh-autosuggestions colored-man-pages)&#xA;&#xA;source $ZSH/oh-my-zsh.sh&#xA;&#xA;# User configuration&#xA;&#xA;# export MANPATH=&quot;/usr/local/man:$MANPATH&quot;&#xA;&#xA;# You may need to manually set your language environment&#xA;# export LANG=en_US.UTF-8&#xA;&#xA;# Preferred editor for local and remote sessions&#xA;# if [[ -n $SSH_CONNECTION ]]; then&#xA;#   export EDITOR='vim'&#xA;# else&#xA;#   export EDITOR='mvim'&#xA;# fi&#xA;&#xA;# Compilation flags&#xA;# export ARCHFLAGS=&quot;-arch x86_64&quot;&#xA;&#xA;# Set personal aliases, overriding those provided by oh-my-zsh libs,&#xA;# plugins, and themes. Aliases can be placed here, though oh-my-zsh&#xA;# users are encouraged to define aliases within the ZSH_CUSTOM folder.&#xA;# For a full list of active aliases, run `alias`.&#xA;#&#xA;# Example aliases&#xA;# alias zshconfig=&quot;mate ~/.zshrc&quot;&#xA;# alias ohmyzsh=&quot;mate ~/.oh-my-zsh&quot;&#xA;source ~/powerlevel10k/powerlevel10k.zsh-theme&#xA;&#xA;# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.&#xA;[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh&#xA;source /Users/idankor/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh&#xA;&#xA;# ----------------------------------&#xA;# Colors&#xA;# ----------------------------------&#xA;NOCOLOR='\033[0m'&#xA;RED='\033[0;31m'&#xA;GREEN='\033[0;32m'&#xA;ORANGE='\033[0;33m'&#xA;BLUE='\033[0;34m'&#xA;PURPLE='\033[0;35m'&#xA;CYAN='\033[0;36m'&#xA;LIGHTGRAY='\033[0;37m'&#xA;DARKGRAY='\033[1;30m'&#xA;LIGHTRED='\033[1;31m'&#xA;LIGHTGREEN='\033[1;32m'&#xA;YELLOW='\033[1;33m'&#xA;LIGHTBLUE='\033[1;34m'&#xA;LIGHTPURPLE='\033[1;35m'&#xA;LIGHTCYAN='\033[1;36m'&#xA;WHITE='\033[1;37m'&#xA;&#xA;function _help() {&#xA;echo &quot; &quot;&#xA;echo -e ${RED}tldr&#xA;echo &quot; &quot;&#xA;echo -e ${ORANGE}bro&#xA;echo &quot; &quot;&#xA;echo -e ${GREEN}eg&#xA;echo &quot; &quot;&#xA;echo -e ${BLUE}cheat&#xA;echo &quot; &quot;&#xA;echo -e ${YELLOW}cht.sh&#xA;echo &quot; &quot;&#xA;}&#xA;&#xA;function cht.sh() {&#xA;    curl cht.sh/$1&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25181" LastEditorUserId="25181" LastEditDate="2019-11-12T05:52:51.970" LastActivityDate="2019-11-12T05:52:51.970" Title="coc not working in latest vim" Tags="|autocompletion|plugin-vim-plug|plugin-coc|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21868" PostTypeId="2" ParentId="20077" CreationDate="2019-11-12T07:45:48.997" Score="0" Body="&lt;p&gt;I wrote a little plugin many years ago, and still use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/joeytwiddle/dotfiles/blob/master/.vim/plugin/highlight_word_under_cursor.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;highlight_word_under_cursor.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Previous versions used &lt;code&gt;:syntax&lt;/code&gt; but the last iteration uses &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#match-highlight&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:match&lt;/code&gt;&lt;/a&gt; so it might bug you if you wanted to use &lt;code&gt;:match&lt;/code&gt; yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you land on a word it will highlight other occurrences of that word.  But if you move the cursor and are still on the same word, it will stop the highlighting.  That is supposed to be convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh no I am embarrassed by the code now!  Certainly some room for cleanup.  Still it has been working pretty well in my experience.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2019-11-12T07:45:48.997" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21870" PostTypeId="1" AcceptedAnswerId="26770" CreationDate="2019-11-12T12:11:56.330" Score="2" ViewCount="1210" Body="&lt;p&gt;I try to write a vim syntax file for folding if-else statements with the syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;lt;condition&amp;gt; then &amp;lt;block to fold&amp;gt; [else &amp;lt;block to fold&amp;gt;] end if&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Current approach&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region Then start=&quot;then&quot; end=&quot;end if&quot; end=&quot;\(\s*else\)\@=&quot; transparent fold&#xA;syn region Else start=&quot;else&quot; end=&quot;end if&quot;                      transparent fold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Test file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if a&amp;gt;b then&#xA;  echo &quot;ab&quot;&#xA;else&#xA;  echo &quot;ba&quot;&#xA;end if&#xA;if a&amp;gt;c then&#xA;  if c&amp;gt;d then&#xA;    echo &quot;cd&quot;&#xA;  else  ' error: stops the outer if too&#xA;    echo &quot;dc&quot;&#xA;  end if&#xA;end if&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notes&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The else-block is optional.&lt;/li&gt;&#xA;&lt;li&gt;Keywords start on a new line.&lt;/li&gt;&#xA;&lt;li&gt;Blocks can contain if-else statements again recursively.&lt;/li&gt;&#xA;&lt;li&gt;Blocks optionally use indentation (leading space to be considered).&lt;/li&gt;&#xA;&lt;li&gt;Challenge: the &quot;else&quot; stops the previous block and starts a new one.&lt;/li&gt;&#xA;&lt;li&gt;Problem: in the test file above the commented else statement stops the inner and the outer then block.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So the question: how can it be done?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Outlook: once working, it shall be extended by optional elseif blocks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ... then ... [elseif &amp;lt;condition&amp;gt; then &amp;lt;block to fold&amp;gt;]* [else...] end if&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21338" LastEditorUserId="21338" LastEditDate="2019-11-12T13:12:36.950" LastActivityDate="2021-01-05T20:05:00.433" Title="How to fold nested &quot;if then else end if&quot; statements" Tags="|folding|syntax|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21871" PostTypeId="2" ParentId="21870" CreationDate="2019-11-12T12:53:43.307" Score="0" Body="&lt;p&gt;This answer is more of a hack than a real solution to your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the text you show, it seems you may rely on indentation for your folding.&#xA;If so, you can use &lt;code&gt;set foldmethod=indent&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A little function I use in such case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FoldAll()                                                                                                     &#xA;  set foldcolumn=1                                                                                                      &#xA;  set foldmethod=indent                                                                                                 &#xA;  redraw!                                                                                                               &#xA;  set foldmethod=manual                                                                                                 &#xA;endfunction                                                                                                             &#xA;command! FoldAll call FoldAll()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15134" LastActivityDate="2019-11-12T12:53:43.307" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21872" PostTypeId="1" CreationDate="2019-11-12T12:58:29.937" Score="3" ViewCount="1310" Body="&lt;p&gt;I know per my question &lt;a href=&quot;https://vi.stackexchange.com/questions/21862/remove-trailing-dashes-in-foldtext&quot;&gt;remove trailing dashes in foldtext&lt;/a&gt; that I can remove the trailing dashes from collapsed fold lines. When a fold is 'open', the sign column has pipe characters '|'. I looked at the help page and tried searching for fold, but no luck. Is there any way to change the pipe characters to something else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: &lt;code&gt;help foldcolumn&lt;/code&gt; says &lt;code&gt;&amp;amp;fdc&lt;/code&gt; is the width of the column. &lt;code&gt;help folding&lt;/code&gt; with a search for 'pipe' and 'character' unfortunately brings up nothing.&lt;/p&gt;&#xA;" OwnerUserId="25619" LastEditorUserId="1841" LastEditDate="2019-11-12T15:12:46.180" LastActivityDate="2021-11-09T14:25:15.903" Title="change fold sign character" Tags="|highlight|folding|signs|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21873" PostTypeId="1" AcceptedAnswerId="21875" CreationDate="2019-11-12T13:14:13.247" Score="0" ViewCount="88" Body="&lt;p&gt;I'm using &lt;code&gt;:term bash&lt;/code&gt; to show a terminal buffer as it is specified in &lt;code&gt;:h terminal-use&lt;/code&gt;. But the problem is that it is appeared on the top of the currently active vim buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a &lt;code&gt;vimrc&lt;/code&gt; configuration to make it be appeared on the bottom instead?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2019-11-12T13:47:49.507" Title="Is it possible to make a terminal frame to be appeared on the bottom, not on the top?" Tags="|vimrc|terminal|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21874" PostTypeId="2" ParentId="21872" CreationDate="2019-11-12T13:38:33.633" Score="1" Body="&lt;p&gt;(Moved to a separate answer for visibility)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to @Christian Brabandt the characters used for this purpose are hardcoded.&lt;/p&gt;&#xA;" OwnerUserId="25619" LastActivityDate="2019-11-12T13:38:33.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21875" PostTypeId="2" ParentId="21873" CreationDate="2019-11-12T13:47:49.507" Score="1" Body="&lt;p&gt;Any command opening a split in Vim is influenced by &lt;code&gt;splitbelow&lt;/code&gt; (horizontal) and &lt;code&gt;splitright&lt;/code&gt; (vertical) options. So terminal opens on top, because you have &lt;code&gt;set nosplitbelow&lt;/code&gt; (this is the default setting).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can either change a global setting, or use an additional &quot;modifier&quot; command as needed. These modifiers are &lt;code&gt;aboveleft&lt;/code&gt;, &lt;code&gt;belowright&lt;/code&gt;, &lt;code&gt;topleft&lt;/code&gt; and &lt;code&gt;botright&lt;/code&gt;. You probably need one of &lt;code&gt;:below term&lt;/code&gt;or &lt;code&gt;:bot term&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-12T13:47:49.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21876" PostTypeId="1" CreationDate="2019-11-12T14:13:52.003" Score="2" ViewCount="234" Body="&lt;p&gt;Last week, I turned off &lt;code&gt;'number'&lt;/code&gt; and have been using only &lt;code&gt;'relativenumber'&lt;/code&gt;, plus a line/column count in my status line. I don't really look at line numbers that much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now I've had a radical idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to turn off numbering completely, and only turn it (&lt;code&gt;'relativenumber'&lt;/code&gt;) back on&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;in visual mode, so I can jump around quickly&lt;/li&gt;&#xA;&lt;li&gt;on the ex command-line, so I can build ranges&lt;/li&gt;&#xA;&lt;li&gt;in operator-pending mode, so I can provide motions like &lt;code&gt;3j&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I can handle the command-line stuff with &lt;code&gt;CmdlineEnter&lt;/code&gt; and &lt;code&gt;CmdwinEnter&lt;/code&gt; (and corresponding exits).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Visual mode doesn't seem to have a &lt;code&gt;VisualEnter&lt;/code&gt; event (unlike Insert mode), so I would &lt;em&gt;probably&lt;/em&gt; have to map &lt;code&gt;v&lt;/code&gt;, &lt;code&gt;V&lt;/code&gt;, and &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; in normal mode (also &lt;code&gt;gv&lt;/code&gt;...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't want to remap every operator—it's simply not practical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to detect operator-pending mode, trigger some commands, and either resume mode, or use &lt;code&gt;feedkeys()&lt;/code&gt; to re-trigger it? Or is this attempt ill-fated?&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-12T16:00:04.613" Title="Visual/Operator-pending autocommand?" Tags="|visual-mode|line-numbers|operator-pending-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21877" PostTypeId="2" ParentId="21876" CreationDate="2019-11-12T16:00:04.613" Score="3" Body="&lt;p&gt;It's a hack, but you could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let [s:last_mode, s:last_state] = ['n', '']&#xA;let s:waiting_time = 10&#xA;call timer_start(s:waiting_time, {-&amp;gt; s:fire_missing_events()}, {'repeat': -1})&#xA;&#xA;fu! s:fire_missing_events() abort&#xA;    if reg_executing() isnot# '' | return | endif&#xA;    let [mode, state] = [mode(), state()]&#xA;    if s:last_mode is# 'n'&#xA;    \ &amp;amp;&amp;amp; index(['v', 'V', &quot;\&amp;lt;c-v&amp;gt;&quot;], mode) != -1&#xA;    \ &amp;amp;&amp;amp; exists('#User#VisualEnter')&#xA;        do &amp;lt;nomodeline&amp;gt; User VisualEnter&#xA;    elseif s:last_mode isnot# 'n'&#xA;    \ &amp;amp;&amp;amp; mode is# 'n'&#xA;    \ &amp;amp;&amp;amp; exists('#User#NormalEnter')&#xA;        do &amp;lt;nomodeline&amp;gt; User NormalEnter&#xA;    elseif s:last_state !~# 'o'&#xA;    \ &amp;amp;&amp;amp; state =~# 'o'&#xA;    \ &amp;amp;&amp;amp; exists('#User#OperatorPendingEnter')&#xA;        do &amp;lt;nomodeline&amp;gt; User OperatorPendingEnter&#xA;    elseif s:last_state =~# 'o'&#xA;    \ &amp;amp;&amp;amp; state !~# 'o'&#xA;    \ &amp;amp;&amp;amp; exists('#User#OperatorPendingLeave')&#xA;        do &amp;lt;nomodeline&amp;gt; User OperatorPendingLeave&#xA;    endif&#xA;    let [s:last_mode, s:last_state] = [mode, state]&#xA;endfu&#xA;&#xA;augroup set_rnu&#xA;    au!&#xA;    au User OperatorPendingEnter,VisualEnter setl rnu | redraw&#xA;    au User OperatorPendingLeave,NormalEnter setl nornu&#xA;    au CmdlineEnter : if state() !~# 'm' | setl rnu | redraw | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It requires the patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.2047&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;8.1.2047&lt;/code&gt;&lt;/a&gt; to be able to invoke the &lt;code&gt;state()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I briefly tested the code by writing it in &lt;code&gt;/tmp/vimrc&lt;/code&gt;, and then running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -Nu /tmp/vimrc +'norm! 14G' &amp;lt;(curl -Ls https://raw.githubusercontent.com/tmux/tmux/master/tools/UTF-8-demo.txt)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seemed to do what you want:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SWppb.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SWppb.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't know how reliable it is.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you notice a too big impact on Vim's performance, try to increase the value of &lt;code&gt;s:waiting_time&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h User&#xA;:h reg_executing(&#xA;:h mode(&#xA;:h state(&#xA;:h exists(&#xA;:h timer_start(&#xA;:h :do&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2019-11-12T16:00:04.613" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21878" PostTypeId="1" AcceptedAnswerId="21886" CreationDate="2019-11-12T16:34:09.910" Score="1" ViewCount="55" Body="&lt;p&gt;When jumping to a tag it seems that &quot;:&quot; are ignored for the purpose of &quot;under the cursor&quot; (I'm assuming it's &quot;word&quot; &quot;under the cursor&quot;). For example if I want to jump to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myTree::Node something&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want proper Node definition to be identified (I did run ctags with +q), rather than the plethora of system library nodes I have tagged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought I worked around this using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap ak &amp;lt;ESC&amp;gt;?[^a-zA-Z0-9:_]&amp;lt;CR&amp;gt;lv/[^a-zA-Z0-9:_]&amp;lt;CR&amp;gt;h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I could easily mark the full qualifier when I'm on top of it, then &lt;code&gt;ctrl-]&lt;/code&gt; and &lt;code&gt;g]&lt;/code&gt; work nicely. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately it seems the &lt;code&gt;ctrl-w&lt;/code&gt; commands ignore the mark, and still use only &quot;Node&quot; in the above example for the matching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want &lt;code&gt;&amp;lt;ctrl-w&amp;gt; &amp;lt;ctrl-]&amp;gt;&lt;/code&gt; to work as expected when the full qualifier is marked. Even better, I would like to change the definition of &quot;under the cursor&quot; or &quot;word&quot;, or the used text object to include &quot;:&quot; (this will probably only annoy in Python anyway) so I won't even need my mapping. Is this possible, and if so, how?&lt;/p&gt;&#xA;" OwnerUserId="25481" LastEditorUserId="25481" LastEditDate="2019-11-13T08:01:25.640" LastActivityDate="2019-12-13T08:01:45.307" Title="Change definition of &quot;under the cursor&quot; for ctags with C++ qualifiers" Tags="|ctags|custom-text-object|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21879" PostTypeId="1" AcceptedAnswerId="21880" CreationDate="2019-11-12T16:41:46.737" Score="3" ViewCount="207" Body="&lt;p&gt;I'm new to vim so I'm not sure if this is intended behavior or not, but it seems like a bug.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Desired Behavior&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;After sourcing vimrc from within nvim, don't duplicate the contents of my statusline. Or at the very least, provide a way to reset my statusline.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Bug Description&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Whenever I do &lt;code&gt;:source ~/.vim/vimrc&lt;/code&gt;, the contents of my statusline gets duplicated, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hUDyh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hUDyh.png&quot; alt=&quot;nvim statusline filename duplicated after sourcing vimrc&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I source vimrc once I'll get &lt;code&gt;[No Name][No Name]&lt;/code&gt;, if I source it again I get &lt;code&gt;[No Name][No Name][No Name]&lt;/code&gt;, and so on. It doesn't reset until I quit and open nvim again.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How to Reproduce Error&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;An example vimrc &lt;code&gt;~/.vim/vimrc_ex&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%.35f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's it. Now open with &lt;code&gt;nvim -u ~/.vim/vimrc_ex&lt;/code&gt; and do &lt;code&gt;:source ~/.vim/vimrc_ex&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="25625" LastActivityDate="2019-11-12T17:25:19.047" Title="Sourcing vimrc duplicates statusline in nvim" Tags="|vimrc|neovim|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21880" PostTypeId="2" ParentId="21879" CreationDate="2019-11-12T16:47:57.550" Score="6" Body="&lt;p&gt;When you use the &lt;code&gt;+=&lt;/code&gt; operator, you actually ask vim to append some new values to the &lt;code&gt;statusline&lt;/code&gt; variable. When you first open Vim &lt;code&gt;statusline&lt;/code&gt; is set to an emtpy value so adding &lt;code&gt;%.35f&lt;/code&gt; to it give you the expected behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when you source your config again, nothing empties the variable so you keep adding duplicate values to it. Thus you probably want to add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%.35f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you initialize your statusline to an empty value every time you source your configuration and when you append new stuff to the variable with &lt;code&gt;+=&lt;/code&gt; you don't create duplicates.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="10604" LastEditDate="2019-11-12T17:25:19.047" LastActivityDate="2019-11-12T17:25:19.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21881" PostTypeId="1" AcceptedAnswerId="21884" CreationDate="2019-11-12T17:05:45.583" Score="3" ViewCount="2380" Body="&lt;p&gt;I'm new to vimscript and writing a function to toggle a terminal buffer. Here is what I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:toggle_term = &quot;&amp;lt;C-j&amp;gt;&quot;&#xA;&#xA;let g:term_buf_nr = -1&#xA;function! ToggleTerminal()&#xA;    if g:term_buf_nr == -1&#xA;        execute &quot;bot term&quot;&#xA;        let g:term_buf_nr = bufnr(&quot;$&quot;)&#xA;    else&#xA;        execute &quot;bd! &quot; .g:term_buf_nr&#xA;        let g:term_buf_nr = -1&#xA;    endif&#xA;endfunction&#xA;&#xA;execute &quot;nnoremap &quot;.g:toggle_term .&quot; :call ToggleTerminal()&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function works fine and toggles the terminal buffer only in case the terminal buffer itself is not focused. If it is focused then pressing the &lt;code&gt;g:toggle_term&lt;/code&gt; combination does nothing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way make &lt;code&gt;g:toggle_term&lt;/code&gt; to toggle terminal even if the terminal buffer is currently focused?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastEditorUserId="9409" LastEditDate="2019-11-12T17:11:30.113" LastActivityDate="2020-06-18T19:56:50.397" Title="Toggle terminal buffer vimscript function" Tags="|vimrc|vimscript|terminal|terminal-buffer|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21882" PostTypeId="2" ParentId="21495" CreationDate="2019-11-12T21:38:57.093" Score="2" Body="&lt;p&gt;After Upgrading to Mac OS Catalina, I had the same issue with the same MacVim version. Updating MacVim, currently to 8.1.2234, solved the issue.&#xA;I simply used &quot;Check for Updates...&quot; in the menu.&lt;/p&gt;&#xA;" OwnerUserId="25628" LastActivityDate="2019-11-12T21:38:57.093" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21883" PostTypeId="2" ParentId="758" CreationDate="2019-11-13T00:46:38.587" Score="1" Body="&lt;p&gt;It's easiest to use buffers as the &quot;intermediate&quot; layout.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;buffers &gt; horizontal windows: &lt;code&gt;:ba&lt;/code&gt; (buffer all)&lt;/li&gt;&#xA;&lt;li&gt;buffers &gt; vertical windows: &lt;code&gt;:vert ba&lt;/code&gt; (vertical buffer all)&lt;/li&gt;&#xA;&lt;li&gt;buffers &gt; tabs: &lt;code&gt;:tab ba&lt;/code&gt; (tab buffer all)&lt;/li&gt;&#xA;&lt;li&gt;windows &gt; buffers: &lt;code&gt;:on&lt;/code&gt;, &lt;code&gt;:only&lt;/code&gt; (current window only)&lt;/li&gt;&#xA;&lt;li&gt;tabs &gt; buffers: &lt;code&gt;:tabo&lt;/code&gt;, &lt;code&gt;:tabonly&lt;/code&gt; (current tab only)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So if you want to convert all windows to tabs, first convert windows to buffers, then buffers to tabs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:on | tab ba&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6610" LastActivityDate="2019-11-13T00:46:38.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21884" PostTypeId="2" ParentId="21881" CreationDate="2019-11-13T07:17:25.803" Score="2" Body="&lt;p&gt;As @statox suggested in comments I should have used &lt;code&gt;tnoremap&lt;/code&gt; to implement it. The following works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;tnoremap &quot;.g:toggle_term .&quot; &amp;lt;C-w&amp;gt;:call ToggleTerminal()&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The mistake I initially made was the space right after the &lt;code&gt;N&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;tnoremap &quot;.g:toggle_term .&quot; &amp;lt;C-w&amp;gt;N :call ToggleTerminal()&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and since I rebound leader to &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; it did not work the way I wanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the declaration&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:term_buf_nr = -1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be script private and replaced with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:term_buf_nr = -1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9409" LastEditorUserId="9409" LastEditDate="2019-11-13T08:40:34.123" LastActivityDate="2019-11-13T08:40:34.123" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21885" PostTypeId="1" AcceptedAnswerId="21891" CreationDate="2019-11-13T07:42:39.567" Score="2" ViewCount="1124" Body="&lt;p&gt;When I'm in a modified buffer and try to open a file using &lt;code&gt;:e otherFile&lt;/code&gt; I get&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;E37: No write since last change (add ! to override)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Since this happens fairly often, I'd like to automatically save the current file before opening the new one.&lt;/p&gt;&#xA;&lt;p&gt;That's why I added this to my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufLeave * silent! wall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But this autocommand doesn't help when using &lt;code&gt;:e otherFile&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Using Neovim v0.4.3&lt;/p&gt;&#xA;" OwnerUserId="8558" LastEditorUserId="8558" LastEditDate="2021-11-04T20:05:07.203" LastActivityDate="2021-11-04T20:05:07.203" Title="Save buffer before opening new file" Tags="|buffers|autocmd|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21886" PostTypeId="2" ParentId="21878" CreationDate="2019-11-13T07:47:37.993" Score="0" Body="&lt;p&gt;As a workaround, I remapped &lt;code&gt;&amp;lt;C-w&amp;gt;&amp;lt;C-]&amp;gt;&lt;/code&gt;. I am still looking for other, more &quot;holistic&quot; solutions. Added these lines to my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;C-w&amp;gt;&amp;lt;C-]&amp;gt; :split&amp;lt;bar&amp;gt;normal vak&amp;lt;CR&amp;gt;g&amp;lt;C-]&amp;gt;&#xA;noremap &amp;lt;C-w&amp;gt;] :normal vak&amp;lt;CR&amp;gt;g&amp;lt;C-]&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which conveniently mark said custom text object, and jumps to it if there is a single definition, or opens a list of matches otherwise. The two variants either split the window or jump in the same one.&lt;/p&gt;&#xA;" OwnerUserId="25481" LastActivityDate="2019-11-13T07:47:37.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21887" PostTypeId="2" ParentId="21885" CreationDate="2019-11-13T07:49:51.320" Score="2" Body="&lt;p&gt;One way to achieve this is to&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;:set autowriteall&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;This will save the file before switching to another and also save it before quitting Vim. So every time you type commands like &lt;code&gt;:bn&lt;/code&gt;, short form for &lt;code&gt;:bnext&lt;/code&gt;, the buffer will be saved automatically and the buffer changed, in this case for the next one in a circular manner.&lt;/p&gt;&#xA;&lt;p&gt;Gleaned from &lt;code&gt;:help autowrite&lt;/code&gt; and &lt;code&gt;:help autowriteall&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Write the contents of the file, if it has been modified, on each&#xA;next, :rewind, :last, :first, :previous, :stop, :suspend, :tag, :!,&#xA;make, CTRL-] and CTRL-^ command; and when a :buffer, CTRL-O, CTRL-I&#xA;command takes you to a new file. Also write when using :edit, :enew,&#xA;:quit, :qall, :exit, :xit, :recover and closing the Vim window.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="8558" LastEditorUserId="31744" LastEditDate="2020-10-10T15:46:33.813" LastActivityDate="2020-10-10T15:46:33.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21888" PostTypeId="1" CreationDate="2019-11-13T10:33:21.717" Score="3" ViewCount="100" Body="&lt;p&gt;I have a file in Mediawiki format, containing internal links (in a Mediawiki installation)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* [[Topic A]]&#xA;* [[Topic B]]&#xA;* [[Vim]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The asterisks are how MediaWiki lists are formatted, they are not mandatory, as the solution should work on &lt;code&gt;[[Topic A]] [[Topic B]] [[Vim]]&lt;/code&gt; as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to open these links with their &lt;em&gt;full&lt;/em&gt; URL, e.g. &lt;code&gt;https://en.wikipedia.org/wiki/Vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can I e.g. use something like&#xA;&lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt; (which works on complete URLs) for an individual list entry, but having it complete the rest of the URL and opening it the browser?&lt;/li&gt;&#xA;&lt;li&gt;Is there a solution to open &lt;em&gt;all&lt;/em&gt; listed elements at once?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="25635" LastEditorUserId="-1" LastEditDate="2019-11-13T17:32:58.363" LastActivityDate="2019-11-13T17:32:58.363" Title="How to open internal MediaWiki links with their full URL from within Vim?" Tags="|external-command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21889" PostTypeId="2" ParentId="21682" CreationDate="2019-11-13T11:49:03.153" Score="0" Body="&lt;p&gt;No need for a plugin, just apply the substitution command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/(\(\([^()]\|\n\)*\))/[\1]/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notes&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Supports multiple matches per line: &lt;code&gt;(aa) (bb) -&amp;gt; [aa] [bb]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Supports multi-line content: &lt;code&gt;(aa \n bb) -&amp;gt; [aa \n bb]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Supports nested parenthesis: &lt;code&gt;((aa)) -&amp;gt; ([aa])&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Doesn't change unmatched characters: &lt;code&gt;a) (b)  -&amp;gt; a) [b]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;However it needs to be applied multiple times manually to substitute the outer parenthesis: &lt;code&gt;([aa]) -&amp;gt; [[aa]]&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Breakdown of the command&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:%s/&lt;/code&gt;    for all lines, substitute the pattern:&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(&lt;/code&gt;         start pattern with opening parenthesis&lt;/li&gt;&#xA;&lt;li&gt;outer &lt;code&gt;\(...\)&lt;/code&gt;   so that the content can be referred as &lt;code&gt;\1&lt;/code&gt; later&lt;/li&gt;&#xA;&lt;li&gt;inner &lt;code&gt;\(...\)*&lt;/code&gt;  any number of matches of ...&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^()]&lt;/code&gt;    any character that is not ( or )&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\|\n&lt;/code&gt;     or a line break to allow multi-line patterns&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;)&lt;/code&gt;    last character of the search pattern&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/[\1]&lt;/code&gt;    substitute by [ \1 = content form first &lt;code&gt;\(...\)&lt;/code&gt; in the pattern ]&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/g&lt;/code&gt;       globally, so any number of substitutions per line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Notes&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I hope I didn't get a typo now... &lt;/li&gt;&#xA;&lt;li&gt;If the command is too long to be remembered, it might be mapped to a key.&lt;/li&gt;&#xA;&lt;li&gt;If stored as a function, it might be called n times in one call to substitute&#xA;nested parenthesis. To be honest, I don't know functions, someone might want to comment on that.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21338" LastActivityDate="2019-11-13T11:49:03.153" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21891" PostTypeId="2" ParentId="21885" CreationDate="2019-11-13T12:51:42.477" Score="2" Body="&lt;p&gt;The usual solution is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set hidden&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows a buffer to be made « hidden », i.e., not physically shown in a window, while still unsaved. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without &lt;code&gt;'hidden'&lt;/code&gt; on, vim’s default behavior is to not allow closing a modified buffer without being forced (via &lt;code&gt;!&lt;/code&gt;s on commands). &lt;code&gt;'hidden'&lt;/code&gt; allows a third state between open and closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do note that &lt;code&gt;'confirm'&lt;/code&gt; may be useful here; I believe it instructs vim to confirm, when you quit, the save/don’t save state of any modified buffers. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-13T12:51:42.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21892" PostTypeId="1" AcceptedAnswerId="21897" CreationDate="2019-11-13T13:00:07.203" Score="3" ViewCount="2020" Body="&lt;p&gt;I was just started with Vim. While experimenting with basic customization techniques, it began to behave differently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Somehow the default configurations changed to very basic for both GVim and terminal version.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;No syntax highlighting.&lt;/li&gt;&#xA;&lt;li&gt;Links are shown in bars ( |example| ).&lt;/li&gt;&#xA;&lt;li&gt;No mouse support (for terminal version only).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Currently both &lt;code&gt;.vimrc&lt;/code&gt; and &lt;code&gt;.gvimrc&lt;/code&gt; files are empty and it was the same when it worked without issues.&lt;/strong&gt; I think I can change them by editing them. But I wonder how did this happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Gnome on debian 4.19. I tried reinstalling both Vim and GVim. It didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be highly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="25638" LastEditorUserId="25638" LastEditDate="2019-11-13T17:52:39.200" LastActivityDate="2019-11-13T17:52:39.200" Title="Syntax highlighting stopped working" Tags="|vimrc|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="21893" PostTypeId="2" ParentId="21888" CreationDate="2019-11-13T13:12:01.397" Score="2" Body="&lt;p&gt;&lt;code&gt;gx&lt;/code&gt; is normally processed by &lt;code&gt;netrw&lt;/code&gt; plugin. You can try to plug into it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function g:ExpandWiki(expr)&#xA;    &quot; perform standard expand() for netrw&#xA;    let l:url = expand(a:expr)&#xA;    &quot; check if it looks like &quot;wiki&quot; URL&#xA;    let l:wiki = matchstr(l:url, '\[\[\zs.*\ze\]\]')&#xA;    &quot; root should be patched to match your installation&#xA;    return empty(l:wiki) ? l:url : 'https://en.wikipedia.org/wiki/' . l:wiki&#xA;endfunction&#xA;&#xA;&quot; redefine &amp;lt;Plug&amp;gt;NetrwBrowseX to use our custom expansion&#xA;let rhs = maparg('&amp;lt;Plug&amp;gt;NetrwBrowseX', 'n')&#xA;if !empty(rhs)&#xA;    exe 'nn &amp;lt;silent&amp;gt;&amp;lt;Plug&amp;gt;NetrwBrowseX' substitute(rhs, 'expand(', 'ExpandWiki(', '')&#xA;else&#xA;    echoerr 'Netrw is not found!'&#xA;    echoerr 'Perhaps, you may want to run this code from ~/.vim/after/plugin'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-13T13:12:01.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21894" PostTypeId="1" AcceptedAnswerId="21896" CreationDate="2019-11-13T14:53:13.817" Score="11" ViewCount="1205" Body="&lt;p&gt;&lt;strong&gt;Use case:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a JS file, I have an expression like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code&gt;if (someVar === 'someValue') {&#xA;    statements;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and, for debugging purposes, I sometimes want to include a &lt;code&gt;console.log&lt;/code&gt; in the line above:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code&gt;console.log('someVar:', someVar);&#xA;if (someVar === 'someValue') {&#xA;    statements;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;(Working) Attempt:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to have some keybinding to achieve this, so I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;L &quot;ayiwOconsole.log(':', );&amp;lt;Esc&amp;gt;2F'&quot;apf &quot;ap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that basically yanks word under cursor to register &lt;code&gt;a&lt;/code&gt;, then writes an empty &lt;code&gt;console.log(':', );&lt;/code&gt; &lt;em&gt;template&lt;/em&gt; in the line above, moves to the desired positions and pastes register &lt;code&gt;a&lt;/code&gt; twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works, but it feels some-way dirty. Can you think of a more elegant way to do the same?&lt;/p&gt;&#xA;" OwnerUserId="11899" LastEditorUserId="1238" LastEditDate="2019-12-12T08:20:57.660" LastActivityDate="2019-12-12T08:20:57.660" Title="How to Insert a console.log for word under cursor in new line" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21895" PostTypeId="2" ParentId="21894" CreationDate="2019-11-13T15:27:37.720" Score="10" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can you guys think of a more elegant way to do the same?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, at least we can try our best :-)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;Leader&amp;gt;L :put! =printf('console.log(''%s:'',  %s);', expand('&amp;lt;cword&amp;gt;'), expand('&amp;lt;cword&amp;gt;'))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="10604" LastEditDate="2019-11-14T01:48:30.483" LastActivityDate="2019-11-14T01:48:30.483" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21896" PostTypeId="2" ParentId="21894" CreationDate="2019-11-13T15:38:13.513" Score="9" Body="&lt;p&gt;You can use &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; from insert mode to insert the contents of a register. That way you can insert the whole line at once, including the repeat of the variable name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;L &quot;ayiwOconsole.log('&amp;lt;C-R&amp;gt;a:', &amp;lt;C-R&amp;gt;a);&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might want to consider adding a visual mode mapping as well, in which case you can use that also to log the value of an expression, and not just a single variable that will match a word:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;Leader&amp;gt;L &quot;ayOconsole.log('&amp;lt;C-R&amp;gt;a:', &amp;lt;C-R&amp;gt;a);&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-R&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-R&lt;/code&gt;&lt;/a&gt; for more details on how &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; works in insert mode.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-11-13T15:38:13.513" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21897" PostTypeId="2" ParentId="21892" CreationDate="2019-11-13T16:04:13.327" Score="3" Body="&lt;p&gt;Empty &lt;code&gt;.vimrc&lt;/code&gt; is not the same as no &lt;code&gt;.vimrc&lt;/code&gt;. Once I deleted it, it worked fine as before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to &lt;a href=&quot;https://vi.stackexchange.com/users/22797/matt&quot;&gt;@Matt&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25638" LastActivityDate="2019-11-13T16:04:13.327" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21898" PostTypeId="1" CreationDate="2019-11-13T19:57:56.653" Score="0" ViewCount="194" Body="&lt;p&gt;I know how to make an abbreviation to a command in vim. For example to print the date, I have this in .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev mydate &amp;lt;C-R&amp;gt;=strftime(&quot;%a %d/%m/%Y&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I'm running a VM with FreeBSD as a guest. Base system has good old vi/nvi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can print the date with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r !date &quot;+%a %d/%M/%Y&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how can I make an abbreviation to the above command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ab mydate :r !date &quot;+%a %d/%M/%Y&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this will not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Correction. In vim I actually have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev mydate &amp;lt;C-R&amp;gt;=strftime(&quot;%a %d/%m/%Y&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;not &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ab date_ ^[:r!date -I^MkJA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The rest of the question stands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D. Ben Knoble,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a mess with the original question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vi/nvi on FreeBSD. (Version 2.1.3 (2015-04-08) The CSRG, University of California, Berkeley.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;iabbrev&quot; and &quot;nnoremap&quot; are Vim commands, not vi/nvi commands. &lt;/p&gt;&#xA;" OwnerUserId="25644" LastEditorUserId="1841" LastEditDate="2019-11-14T09:16:19.437" LastActivityDate="2019-11-15T18:47:19.703" Title="vi/nvi (FreeBSD) How to make an abbreviation to a shell command?" Tags="|abbreviations|nvi|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21901" PostTypeId="2" ParentId="21898" CreationDate="2019-11-14T01:51:36.110" Score="1" Body="&lt;p&gt;You can create a mapping for it&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap keys :read !date...&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can use &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev keys &amp;lt;C-o&amp;gt;:read !date...&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For historical (&lt;code&gt;vi&lt;/code&gt;) compatibility, I believe one can do &lt;code&gt;map!&lt;/code&gt; and &lt;code&gt;abbrev&lt;/code&gt;—these are listed in Vim under &lt;code&gt;:help vi-features&lt;/code&gt; as supported vi features (though I cannot find them in the &lt;a href=&quot;https://pubs.opengroup.org/onlinepubs/9699919799/&quot; rel=&quot;nofollow noreferrer&quot;&gt;POSIX spec&lt;/a&gt;, they are mentioned). Note that abbreviations are used in Insert, Replace, and Command mode, while &lt;code&gt;map!&lt;/code&gt;s are used in Insert and Command mode. Choose &lt;code&gt;keys&lt;/code&gt; carefully. You'll probably also need &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; to insert the literal, instead of &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Peter points to in the comments &lt;code&gt;&amp;lt;C-r&amp;gt;=get(systemlist('date'),0&lt;/code&gt;—not sure how this interacts with pure vi, however. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-11-15T18:47:19.703" LastActivityDate="2019-11-15T18:47:19.703" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21902" PostTypeId="1" CreationDate="2019-11-14T06:09:04.143" Score="3" ViewCount="11222" Body="&lt;p&gt;I want to make use of &lt;em&gt;Shift+Tab&lt;/em&gt; to left-shift (unindent) a block of text, instead of &lt;em&gt;Ctrl+d&lt;/em&gt;. How to do it?&lt;/p&gt;&#xA;" OwnerUserId="25650" LastActivityDate="2019-11-14T08:03:51.920" Title="How to set custom shortcut in vim?" Tags="|vimrc|indentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21903" PostTypeId="2" ParentId="21902" CreationDate="2019-11-14T08:03:51.920" Score="4" Body="&lt;p&gt;The basics of simple mappings are explained in Vim's excellent user manual at &lt;a href=&quot;https://vimhelp.appspot.com/usr_05.txt.html#05.4&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 05.4&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want some key combination (Shift + Tab) to do what's already provided by Vim's Ctrl + D command, so you &lt;em&gt;map&lt;/em&gt; &lt;code&gt;&amp;lt;S-Tab&amp;gt;&lt;/code&gt; (using &lt;a href=&quot;https://vimhelp.appspot.com/intro.txt.html#key-notation&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help key-notation&lt;/code&gt;&lt;/a&gt; now) to &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt;. As Vim is a &lt;em&gt;mode-based&lt;/em&gt; editor, you need to consider the mode; &lt;a href=&quot;https://vimhelp.appspot.com/IndentCommentPrefix.txt.html#i_CTRL-D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-D&lt;/code&gt;&lt;/a&gt; is for &lt;em&gt;insert mode&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As your target is a built-in Vim command, &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/05.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;you should use &lt;code&gt;:noremap&lt;/code&gt;&lt;/a&gt;; it makes the mapping immune to remapping and recursion.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;S-Tab&amp;gt; &amp;lt;C-d&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To try this out, just execute the above command (entering &lt;em&gt;command-line mode&lt;/em&gt; via &lt;code&gt;:&lt;/code&gt;, and concluding with Enter). To make this persist across Vim sessions, put it into your &lt;code&gt;~/.vimrc&lt;/code&gt; configuration, and restart Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The original &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; command will still work; you've just created an alias. As you've defined an alternative, you could remap that key now, or (if it bothers you, if you frequently mistakenly trigger it) turn it off by mapping to the special &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt; target:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-d&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-14T08:03:51.920" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21904" PostTypeId="2" ParentId="21840" CreationDate="2019-11-14T08:40:01.807" Score="3" Body="&lt;p&gt;You can try this vimscript (add to your vimrc and &lt;code&gt;call SetHLGreen()&lt;/code&gt; function)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;&quot;&quot; Get all highlights in a raw string&#xA;fun! GetHLStr()&#xA;    redir =&amp;gt; all_hl&#xA;    highlight&#xA;    redir END&#xA;    return all_hl&#xA;endfun&#xA;&#xA;&quot;&quot; Set all known highlight groups to green&#xA;fun! SetHLGreen()&#xA;    &quot; get highlight groups without printing it in vim&#xA;    silent let hl_str = GetHLStr()&#xA;&#xA;    &quot; make list of highlight groups&#xA;    let hl_list = split(hl_str, '\n')&#xA;&#xA;    &quot; remove non highlight groups (parts of prev highlight group definition)&#xA;    call filter(hl_list, {_,v -&amp;gt; v !~ '^\s.*'})&#xA;&#xA;    &quot; extract just the highlight group names&#xA;    call map(hl_list, {_,v -&amp;gt; matchstr(v, '^\S\+')})&#xA;&#xA;    &quot; set all highlight groups foreground to &quot;green&quot;&#xA;    for hl_group in hl_list&#xA;        exe 'hi ' . hl_group . ' guifg=green ctermfg=green'&#xA;    endfor&#xA;endfun&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS, it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u7jcH.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u7jcH.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PPS, it is even easier with &lt;code&gt;getcompletion&lt;/code&gt; func (didn't know about it, thx @Matt)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot; Set all known highlight groups to green&#xA;fun! SetHLGreen()&#xA;    &quot; set all of highlight groups to &quot;green&quot;&#xA;    for hl_group in getcompletion('', 'highlight')&#xA;        exe 'hi ' . hl_group . ' guifg=green ctermfg=green'&#xA;    endfor&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-11-14T09:04:29.600" LastActivityDate="2019-11-14T09:04:29.600" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21906" PostTypeId="1" AcceptedAnswerId="21915" CreationDate="2019-11-14T09:07:53.683" Score="1" ViewCount="8174" Body="&lt;p&gt;I am relatively new to vim and tried to understand &lt;a href=&quot;https://vim.fandom.com/wiki/Configuring_the_cursor#Disabling_cursor_blinking&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt; and also read &lt;code&gt;:help guicursor&lt;/code&gt; and inserted this line in my &lt;em&gt;.vimrc&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;set guicursor+=a:-blinkwait175-blinkoff150-blinkon175&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;But it didn't do anything. What is the problem here?&lt;/p&gt;&#xA;&lt;p&gt;PS: Sorry if I have to be spoon-fed. VIM is kinda intimidating for me right now.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I need it for the terminal VIM and not gVIM, so the mentioned method won't work I realised that right now. But what will?&lt;/p&gt;&#xA;" OwnerUserId="25650" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-11-14T13:46:22.127" Title="Enable cursor blink in all modes for terminal Vim" Tags="|vimrc|cursor|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21907" PostTypeId="2" ParentId="21906" CreationDate="2019-11-14T09:27:28.670" Score="0" Body="&lt;p&gt;The issue probably is that you don't use highlight group for the cursor you define.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See pic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pkNsM.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pkNsM.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is for GUI vim, not sure how it should be applied to terminal one.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-11-14T09:27:28.670" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="21908" PostTypeId="1" CreationDate="2019-11-14T10:37:42.037" Score="1" ViewCount="77" Body="&lt;p&gt;One of my filetypes has a special comment format that has a background color, and it would be useful if I could extend the highlighting to extend that background to the terminal width, rather than just whatever EOL is in the buffer's line. So, for example, if I have an 80x50 terminal, and have a comment like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# This is a comment&#xA;this('is not');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently, the entire length of the buffer line is highlighted. I.e., &lt;code&gt;# This is a comment&lt;/code&gt; has the syntax applied, as is normal. But I would like &lt;code&gt;# This is a comment[~61 spaces]&lt;/code&gt; to be highlighted (the rest of the terminal line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think I can match part of a string that isn't there at all, so maybe there's a way to specify a CLREOL (ANSI &lt;code&gt;\e[K&lt;/code&gt;) while still in the syntax color, or better yet, more portable/GUI-compatible equivalent?&lt;/p&gt;&#xA;" OwnerUserId="18854" LastActivityDate="2019-11-14T11:13:15.610" Title="Highlighting comments to EOL (terminal EOL, not buffer EOL)" Tags="|syntax-highlighting|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21909" PostTypeId="2" ParentId="21908" CreationDate="2019-11-14T11:13:15.610" Score="1" Body="&lt;p&gt;&lt;strong&gt;Syntax highlighting can only match what's actually inside the buffer; it will end at the final character of a line&lt;/strong&gt; (or wrap and continue with the next line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd simply accept that as it is. The only alternative are hacks like messing with the ANSI escape codes in the terminal, or mis-using different Vim features to highlight the entire line: If you specify a &lt;code&gt;linehl=...&lt;/code&gt; to &lt;a href=&quot;https://vimhelp.appspot.com/sign.txt.html#%3Asign-define&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:sign-define&lt;/code&gt;&lt;/a&gt;, that will cover the entire line, also past the end of text (but you'd have to maintain and update the sign positions yourself).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-14T11:13:15.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21910" PostTypeId="1" AcceptedAnswerId="21914" CreationDate="2019-11-14T12:17:14.133" Score="3" ViewCount="249" Body="&lt;p&gt;I have never used &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Acommand-register&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :command-register&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Creg%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h &amp;lt;reg&amp;gt;&lt;/a&gt; , trying to find an example, but failed to grep &lt;code&gt;\-register&lt;/code&gt; from my installed plugins,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The built in &lt;code&gt;:h :delete&lt;/code&gt; support a count and an optional register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]d[elete] [x] {count}&#xA;            Delete {count} lines, starting with [range]&#xA;            (default: current line |cmdline-ranges|) [into&#xA;            register x].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to create similar command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Failed Attempt&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function s:delete(reg, count) abort&#xA;  let reg = empty(a:reg) ? '&quot;' : a:reg&#xA;  exe 'delete' reg a:count&#xA;endfunction&#xA;command -nargs=1 -register Delete call s:delete('&amp;lt;reg&amp;gt;', &amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Test:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Delete 3&#xA;---------&#xA;E471: Argument required: Delete 3&#xA;&#xA;Delete 30&#xA;---------&#xA;Error detected while processing function &amp;lt;SNR&amp;gt;100_delete:&#xA;line    2:&#xA;E488: Trailing characters: delete 3 0&#xA;&#xA;Delete a 3&#xA;----------&#xA;works fine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't look like optional at all, it looks like it always use 1st char or 1st arg as register.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-11-14T12:23:20.360" LastActivityDate="2019-11-14T13:40:48.403" Title="How to create command with -register and &lt;reg&gt;?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21911" PostTypeId="1" AcceptedAnswerId="21925" CreationDate="2019-11-14T12:25:51.343" Score="4" ViewCount="2820" Body="&lt;p&gt;I use airline's tabline to show a list of my current buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'vim-airline/vim-airline'&#xA;let g:airline#extensions#tabline#enabled = 1 &quot; Use the airline tabline (replacement for buftabline)&#xA;let g:airline#extensions#tabline#show_tab_nr = 1&#xA;let g:airline#extensions#tabline#tab_nr_type = 1 &quot; tab number&#xA;let g:airline#extensions#tabline#excludes = ['branches', 'index']&#xA;let g:airline#extensions#tabline#buffer_idx_mode = 1&#xA;nmap &amp;lt;a-1&amp;gt; &amp;lt;Plug&amp;gt;AirlineSelectTab1&#xA;nmap &amp;lt;a-2&amp;gt; &amp;lt;Plug&amp;gt;AirlineSelectTab2&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9dJRC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9dJRC.png&quot; alt=&quot;airline&amp;#39;s tabline&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really enjoy moving between my buffers in this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to have a terminal buffer to, which shows up in this list as normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, unlike &lt;a href=&quot;https://vi.stackexchange.com/questions/20751/hide-terminal-buffer-from-buffer-list&quot;&gt;this question&lt;/a&gt; which complains about the opposite problem, my terminal buffer(s) &lt;em&gt;don't&lt;/em&gt; show up in airline's tabline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They're in &lt;code&gt;ls&lt;/code&gt; as &lt;code&gt;32 %aR  &quot;term://.//30852:/usr/bin/zsh&quot; line 1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get my tabline to show these buffers too?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using NVIM v0.4.2.&lt;/p&gt;&#xA;" OwnerUserId="2026" LastActivityDate="2022-10-08T10:09:21.017" Title="Show terminal buffer in airline's tabline" Tags="|neovim|plugin-airline|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21914" PostTypeId="2" ParentId="21910" CreationDate="2019-11-14T13:00:49.777" Score="6" Body="&lt;p&gt;The problem with &lt;code&gt;-reg&lt;/code&gt; is that anything that looks like a register is parsed as such, even when there's no separator to the following arguments. So &lt;code&gt;:Delete 30&lt;/code&gt; sets &lt;code&gt;&amp;lt;reg&amp;gt;&lt;/code&gt; to &lt;code&gt;3&lt;/code&gt; (numbered register) and &lt;code&gt;0&lt;/code&gt; as the argument. Unfortunately, &lt;code&gt;:delete&lt;/code&gt; itself seems to use different parsing rules; it doesn't accept a numbered register, so instead of getting &lt;code&gt;E939: Positive count required&lt;/code&gt; you see &lt;code&gt;E488&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of these problems, I tend to skip &lt;code&gt;-reg&lt;/code&gt; and do the parsing on my own (using &lt;a href=&quot;https://github.com/inkarkat/vim-ingo-library/blob/74cd607baa3436409bbad4fd2caa19ff1e0502e3/autoload/ingo/cmdargs/register.vim#L57-L80&quot; rel=&quot;noreferrer&quot;&gt;ingo#cmdargs#register#ParsePrependedWritableRegister()&lt;/a&gt; from my &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4433&quot; rel=&quot;noreferrer&quot;&gt;ingo-library plugin&lt;/a&gt;), enforcing whitespace separation between the register and further arguments. That may explain why you haven't found any plugins using &lt;code&gt;-reg&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make &lt;code&gt;:Delete 3&lt;/code&gt; work, you either have to use custom parsing that does not treat &lt;code&gt;3&lt;/code&gt; as a register, or make the arguments optional via &lt;code&gt;-nargs=?&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2019-11-14T13:40:48.403" LastActivityDate="2019-11-14T13:40:48.403" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21915" PostTypeId="2" ParentId="21906" CreationDate="2019-11-14T13:46:22.127" Score="2" Body="&lt;p&gt;Every strange question have quite simple answers. Refer &lt;a href=&quot;https://www.reddit.com/r/vim/comments/dw7w95/how_to_enable_cursor_blink_in_terminal_vim/f7h1x60?utm_source=share&amp;amp;utm_medium=web2x&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; thread. All that I had to do was enable cursor blinking in the terminal preference itself :/&lt;/p&gt;&#xA;" OwnerUserId="25650" LastActivityDate="2019-11-14T13:46:22.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21916" PostTypeId="1" AcceptedAnswerId="21917" CreationDate="2019-11-14T13:56:40.480" Score="5" ViewCount="741" Body="&lt;p&gt;I'm trying to re-map &lt;a href=&quot;https://github.com/majutsushi/tagbar&quot; rel=&quot;noreferrer&quot;&gt;tagbar&lt;/a&gt; toggling with &lt;code&gt;&amp;lt;C-&amp;amp;&amp;gt;&lt;/code&gt; that I get used to when working with IDEs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But setting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;nnoremap &amp;lt;C-&amp;amp;&amp;gt; :TagbarToggle&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does not have the desirable effect. When pressing 3 keys at once &lt;code&gt;CTRL-SHIFT-7&lt;/code&gt; where &lt;code&gt;SHIFT-7&lt;/code&gt; stands for &lt;code&gt;&amp;amp;&lt;/code&gt; it essentially acts as simple pressing &lt;code&gt;&amp;amp;&lt;/code&gt; without &lt;code&gt;CTRL&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way &lt;code&gt;&amp;lt;C-&amp;amp;&amp;gt;&lt;/code&gt; to behave differently other than &lt;code&gt;&amp;amp;&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastActivityDate="2019-11-14T14:32:32.840" Title="Map CTRL-&amp; in vimrc" Tags="|vimrc|key-bindings|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21917" PostTypeId="2" ParentId="21916" CreationDate="2019-11-14T14:21:00.107" Score="5" Body="&lt;p&gt;According to &lt;a href=&quot;https://bestasciitable.com&quot; rel=&quot;noreferrer&quot;&gt;one of our former mods&lt;/a&gt;, the answer is no:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Sending Control with a character from the 2nd column is useless. Control clears the 7th bit, but this is already 0, so Control+# will just send &quot;#&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Notice that &lt;code&gt;&amp;amp;&lt;/code&gt; in the second column has binary representation &lt;code&gt;01 00110&lt;/code&gt;, so clearing the &lt;code&gt;0&lt;/code&gt; doesn't help. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-14T14:21:00.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21918" PostTypeId="2" ParentId="21916" CreationDate="2019-11-14T14:32:32.840" Score="4" Body="&lt;p&gt;Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like &lt;kbd&gt;Ctrl&lt;/kbd&gt; + non-alphabetic cannot be mapped, and &lt;kbd&gt;Ctrl&lt;/kbd&gt; + letter vs. &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;Shift&lt;/kbd&gt; + letter cannot be distinguished. (Unless your terminal sends a distinct &lt;em&gt;termcap&lt;/em&gt; code for it, which most don't.) In insert or command-line mode, try typing the key combination. If nothing happens / is inserted, you cannot use that key combination. This also applies to &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-M&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; etc. (Only exception is &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-H&amp;gt;&lt;/code&gt;.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_dev/Ym6D-kWIsyo&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://groups.google.com/forum/#!topic/vim_dev/Ym6D-kWIsyo&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim release.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-14T14:32:32.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21919" PostTypeId="1" AcceptedAnswerId="21920" CreationDate="2019-11-14T19:02:00.900" Score="2" ViewCount="2285" Body="&lt;p&gt;Much like &lt;a href=&quot;https://vi.stackexchange.com/q/12640/11454&quot;&gt;this question&lt;/a&gt;, I've failed to put this together successfully on my own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to truncate lines in my file so that no line is over 100 characters in length. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can go to position 100 on each line and execute a &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt; (or just a &lt;kbd&gt;D&lt;/kbd&gt;), but what command will do this for every line in the file? Note: some lines are less than 100 characters.&lt;/p&gt;&#xA;" OwnerUserId="11454" LastEditorUserId="11454" LastEditDate="2019-11-15T15:42:18.730" LastActivityDate="2019-11-15T15:42:18.730" Title="How to truncate all lines at a certain length?" Tags="|global-command|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21920" PostTypeId="2" ParentId="21919" CreationDate="2019-11-14T19:18:27.223" Score="7" Body="&lt;h3&gt;Using a substitution&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/.\{100}\zs.*//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Find 100 characters, &lt;code&gt;.\{100}&lt;/code&gt; then start the match, &lt;code&gt;\zs&lt;/code&gt;, and select the rest of the line, &lt;code&gt;.*&lt;/code&gt;. Replace the match with nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :s&#xA;:h /\.&#xA;:h /\{&#xA;:h \zs&#xA;:h /\*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Using filter&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!cut -c 1-100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use filter, &lt;code&gt;:!&lt;/code&gt;, with a range of the entire file, &lt;code&gt;%&lt;/code&gt;. This will take the entire buffer and pass the text as stdin to &lt;code&gt;cut&lt;/code&gt; and replace the buffer text with the stdout of our command. Use &lt;code&gt;-c 1-100&lt;/code&gt; to get the first 100 characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!&#xA;:range&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Using &lt;code&gt;:normal&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm! v99lyVp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For every line, &lt;code&gt;%&lt;/code&gt;, run command, &lt;code&gt;{cmd}&lt;/code&gt; via &lt;code&gt;:normal! {cmd}&lt;/code&gt;. Select and yank the first 100 characters via &lt;code&gt;v99ly&lt;/code&gt;. Then replace the entire line, &lt;code&gt;V&lt;/code&gt; with the just yanked 100 characters, &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In theory, it would be nice to use &lt;code&gt;101|D&lt;/code&gt;, however &lt;code&gt;101|&lt;/code&gt; will just move to the end of the line for too short of lines. This will result short lines losing their trailing character. &lt;code&gt;|&lt;/code&gt; also jumps by screen columns so could be messed up by indention.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :norm&#xA;:h :range&#xA;:h v_p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastEditorUserId="778" LastEditDate="2019-11-14T19:38:09.680" LastActivityDate="2019-11-14T19:38:09.680" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21921" PostTypeId="1" CreationDate="2019-11-14T19:55:34.900" Score="0" ViewCount="95" Body="&lt;p&gt;I'm trying to make a small extension/bug fix to a plugin I rely on (referenced as &lt;code&gt;Plugin&lt;/code&gt; in the code snips), therefore I'm constrained by its existing API. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got the functionality I want somewhat working, however due to inconsistent typing to what the &lt;code&gt;Plugin&lt;/code&gt;'s API is expecting, it is not quite working fully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here's my somewhat functional code addition to &lt;code&gt;Plugin&lt;/code&gt;; with the context explained beneath:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:conditional_func(mode, ActionFnRef, key)&#xA;    if a:mode.Enabled&#xA;        call a:ActionFnRef(a:key)&#xA;    else&#xA;        call Plugin#Pass#Action(a:key)&#xA;    endif&#xA;endfunction&#xA;&#xA;&#xA;function! s:nop_exception_register(mode, key)&#xA;    let existing_keymap = Plugin#Get#Keymap()&#xA;    let ActionFnRef     = existing_keymap[a:mode][a:key]&#xA;&#xA;    call Plugin#Keymap#Register(function('s:conditional_func',&#xA;                                       \ [a:mode, ActionFnRef]),&#xA;                              \ &quot;Nop&quot;, a:key)&#xA;endfunction&#xA;&#xA;&#xA;&quot; s:nop_exception_register is later called via another function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;s:conditional_func&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;a:mode.Enabled&lt;/code&gt; is a boolean for the status of &lt;code&gt;a:mode&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;a:ActionFnRef&lt;/code&gt; will be some existing Plugin function, which I only want called (with its own &quot;key-pressed&quot; argument &lt;code&gt;a:key&lt;/code&gt;) when &lt;code&gt;a:mode.Enabled == 1&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;Plugin#Pass#Action&lt;/code&gt; is a Plugin function that effectively performs no operation when passed &lt;code&gt;a:key&lt;/code&gt; (in practice, it provides the user with a feedback message, but that's unimportant here)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;s:nop_exception_register&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;the &lt;code&gt;Plugin#Get#Keymap()&lt;/code&gt; returns a &lt;code&gt;dict&lt;/code&gt; of all existing keymaps, grouped by their modes, then by the actual keys within each mode&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;thereby the actual function defining the action to be performed when a key is pressed in its mode is captured by the assignment to &lt;code&gt;ActionFnRef&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;Plugin#Keymap#Register&lt;/code&gt; is the built-in API call for registering actions and their keys in the correct mode&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem Description&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function signature for &lt;code&gt;Plugin#Keymap#Register&lt;/code&gt; is actually (&lt;strong&gt;v:t_string&lt;/strong&gt;, v:t_string, v:t_string), and &lt;em&gt;NOT&lt;/em&gt; (&lt;strong&gt;v:t_func&lt;/strong&gt;, v:t_string, v:t_string).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, the name of the action function is passed as a string to &lt;code&gt;Plugin#Keymap#Register&lt;/code&gt;, which generates the Funcref itself by calling &lt;code&gt;function(&quot;actionFuncName&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm able to have the action working as desired (i.e. conditionally depending on the value of &lt;code&gt;s:mode.Enabled&lt;/code&gt;) because I guess calling &lt;code&gt;function&lt;/code&gt; with a Funcref like I did just returns the same Funcref.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However &lt;code&gt;Plugin#Keymap#Register&lt;/code&gt; also generates a &lt;code&gt;dict&lt;/code&gt; map of help descriptions, which uses the passed string names of the action functions as its keys. Therefore passing it a Funcref like I did eventually causes &lt;code&gt;Plugin&lt;/code&gt; code executed downstream of that to error. The help map can still be successfully initialized, which I've confirmed by inspecting it. It will contain items like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'A': 'Plugin#DoActionW'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'B': 'Plugin#DoActionX'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'C': function('Plugin#DoActionY')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;'D': function('Plugin#DoActionZ')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Where items keyed by &lt;code&gt;'A'&lt;/code&gt; &amp;amp; &lt;code&gt;'B'&lt;/code&gt; will work correctly, but &lt;code&gt;'C'&lt;/code&gt; &amp;amp; &lt;code&gt;'D'&lt;/code&gt; (added by my hack) not quite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Attempted Workarounds&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create a named Partial inside &lt;code&gt;s:nop_exception_register&lt;/code&gt;, and trying to pass its name as a string to &lt;code&gt;Plugin#Keymap#Register&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:nop_exception_register(mode, key)&#xA;    let existing_keymap = Plugin#Get#Keymap()&#xA;    let ActionFnRef     = existing_keymap[a:mode][a:key]&#xA;&#xA;    let CondPartial = function('s:conditional_func', [a:mode, ActionFnRef])&#xA;    call Plugin#Keymap#Register(&quot;CondPartial&quot;, &quot;Nop&quot;, a:key)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This causes a Vim error before it's even fully loaded, with &lt;code&gt;E700: Unknown function: CondPartial&lt;/code&gt; displayed in the terminal.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Place the logic of 's:conditional_func' inside of &lt;code&gt;s:nop_exception_register&lt;/code&gt; as a closure and pass that to &lt;code&gt;Plugin#Keymap#Register&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:nop_exception_register(mode, key)&#xA;    let existing_keymap = Plugin#Get#Keymap()&#xA;    let ActionFnRef     = existing_keymap[a:mode][a:key]&#xA;&#xA;    func! s:_cond_call_action(key) closure&#xA;        if a:mode.Enabled&#xA;            call ActionFnRef(a:key)&#xA;        else&#xA;            call Plugin#Pass#Action(a:key)            &#xA;        endif&#xA;    endfunc&#xA;&#xA;    call Plugin#Keymap#Register(&quot;s:_cond_call_action&quot;, &quot;Nop&quot;, a:key)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Same error: &lt;code&gt;E700: Unknown function: s:_cond_call_action&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Also tried to use &lt;code&gt;eval()&lt;/code&gt;, something like &lt;code&gt;string(eval(&quot;function('s:cond_return_func', [a:mode, ActionFnRef])&quot;))&lt;/code&gt;, where &lt;code&gt;s:cond_return_func&lt;/code&gt; basically returns a Partial like &lt;code&gt;CondPartial&lt;/code&gt; from workaround 1 above. This also errors, not on Vim startup, but at runtime when the relevant part of the &lt;code&gt;Plugin&lt;/code&gt; code is called: &lt;code&gt;E117: Unknown function: &amp;lt;evaluated representation of s:cond_return_func&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I've also considered &quot;dereferencing&quot; a Funcref to its string name if somehow possible, like how in Python one can do &lt;code&gt;&amp;lt;funcname&amp;gt;.__name__&lt;/code&gt; to get the string identifier of the function. Though intuitively this seems unlikely to be possible in Vimscript, as I don't believe functions/funcrefs in Vimscript are like objects in Python. But ofc, please correct me if I'm simply being ignorant here.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically, to me it looks like my problem is not fully understanding how to resolve variable/function scopes in Vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I know the two functions from the first code snippet I showed can almost certainly be refactored into one, which I plan on doing, once this more glaring issue is resolved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I apologize in advance for this long and verbose post, but I just wanted to make sure the problem is fully described. I'm pretty much at my wit's end, please help.&lt;/p&gt;&#xA;" OwnerUserId="24816" LastActivityDate="2019-11-15T03:07:27.873" Title="function variable scoping and arg types problems" Tags="|vimscript|functions|variables|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21922" PostTypeId="2" ParentId="21921" CreationDate="2019-11-15T03:07:27.873" Score="3" Body="&lt;p&gt;From what I can tell without seeing its implementation, &lt;code&gt;Plugin#Keymap#Register&lt;/code&gt; expects a string referring to a globally accessible function, which limits your options.  A closure with a single name won't quite work because its contents would keep changing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One option is to create a dynamically-named function for each value of outer key.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:nop_exception_register(mode, key)&#xA;    let existing_keymap = Plugin#Get#Keymap()&#xA;    let ActionFnRef     = existing_keymap[a:mode][a:key]&#xA;&#xA;    func! Cond_call_action_{a:key}(key_) closure&#xA;        if a:mode.Enabled&#xA;            call ActionFnRef(a:key_)&#xA;        else&#xA;            call Plugin#Pass#Action(a:key_)            &#xA;        endif&#xA;    endfunc&#xA;&#xA;    call Plugin#Keymap#Register('Cond_call_action_' + a:key, 'Nop', a:key)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes each instance an actual global function, i.e., you could &lt;code&gt;:call Cond_call_action_whatever(..)&lt;/code&gt; from the cmdline if you wanted.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is technically possible, though difficult, to use a &lt;code&gt;s:&lt;/code&gt; function here.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-11-15T03:07:27.873" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21923" PostTypeId="2" ParentId="21898" CreationDate="2019-11-15T09:40:19.203" Score="2" Body="&lt;p&gt;I finally found a solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I put this in ~/.nexrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ab mydate ^[:r !date &quot;+\%a \%d/\%m/\%Y&quot;^MkJA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^[&lt;/code&gt; = &lt;kbd&gt;CTRL+v&lt;/kbd&gt;+&lt;kbd&gt;ESC&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^M&lt;/code&gt; = &lt;kbd&gt;CTRL+v&lt;/kbd&gt;+&lt;kbd&gt;ENTER&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks to Antony_ on Freenode channel ##vi for the solution.&lt;/p&gt;&#xA;" OwnerUserId="25670" LastEditorUserId="1841" LastEditDate="2019-11-15T11:06:12.787" LastActivityDate="2019-11-15T11:06:12.787" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21924" PostTypeId="1" AcceptedAnswerId="21927" CreationDate="2019-11-15T10:52:40.707" Score="5" ViewCount="6835" Body="&lt;p&gt;How can I &lt;strong&gt;scroll&lt;/strong&gt; and &lt;strong&gt;hide&lt;/strong&gt; a floating window in Vim using the coc.nvim plugin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added these mappings to my &lt;code&gt;vim.rc&lt;/code&gt; file but I still cannot manage it.&#xA;I would expect if I press &lt;code&gt;ctrl+f&lt;/code&gt; once I have a floating window in &lt;code&gt;normal mode&lt;/code&gt; then it scrolls or if I press my leader key &lt;code&gt;\ + h&lt;/code&gt; then it hides it. What do I do wrong? Thank you!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;h &amp;lt;Plug&amp;gt;(coc-float-hide)&#xA;&#xA;&quot;coc#util#float_scroll({forward})&#xA;&quot;Return expr for scrolling a floating window forward or backward. ex: &amp;gt;&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt;&amp;lt;C-f&amp;gt; coc#util#has_float() ? coc#util#float_scroll(1) : &quot;\&amp;lt;C-f&amp;gt;&quot;&#xA;nnoremap &amp;lt;expr&amp;gt;&amp;lt;C-b&amp;gt; coc#util#has_float() ? coc#util#float_scroll(0) : &quot;\&amp;lt;C-b&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0DYyl.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0DYyl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25673" LastEditorUserId="5017" LastEditDate="2019-11-15T14:40:14.027" LastActivityDate="2019-11-16T13:39:44.580" Title="How can I hide and scroll popup window in coc.nvim in Vim?" Tags="|plugin-coc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21925" PostTypeId="2" ParentId="21911" CreationDate="2019-11-15T11:41:46.607" Score="6" Body="&lt;p&gt;Per &lt;code&gt;:help airline&lt;/code&gt;, the default value of things airline will filter out of the buffer list if not otherwise specified by the user is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline#extensions#tabline#ignore_bufadd_pat = '!|defx|gundo|nerd_tree|startify|tagbar|term://|undotree|vimfiler'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...where &lt;code&gt;!&lt;/code&gt; and &lt;code&gt;term:/&lt;/code&gt; are the respective ways of identifying terminals in VIM and Neovim respectively. Setting a value in your rc/init file that specifically excludes those should do the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:airline#extensions#tabline#ignore_bufadd_pat = 'defx|gundo|nerd_tree|startify|tagbar|undotree|vimfiler'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do note that if any excludes are later added to airline's default you would manually need to add them to your configuration.&lt;/p&gt;&#xA;" OwnerUserId="267" LastActivityDate="2019-11-15T11:41:46.607" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21927" PostTypeId="2" ParentId="21924" CreationDate="2019-11-15T14:38:54.207" Score="6" Body="&lt;p&gt;This is a general way to scroll &lt;code&gt;popup&lt;/code&gt; window &lt;s&gt;above or under&lt;/s&gt; around cursor, it first get &lt;code&gt;winid&lt;/code&gt; by test &lt;a href=&quot;https://vimhelp.org/popup.txt.html#popup_locate%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h popup_locate()&lt;/a&gt; with screen cursor position, then update &lt;code&gt;firstline&lt;/code&gt; of the found window.&lt;/p&gt;&#xA;&lt;p&gt;I didn't add the close map, AFAIK, it's closed automatically when you move your cursor.&lt;/p&gt;&#xA;&lt;p&gt;Note that the beginning and ending of scroll is affected by &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27scrolloff%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'scrolloff'&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;code update&lt;/strong&gt; :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Removed hardcoded binding.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;:h popup_getpos()&lt;/code&gt; to get &lt;code&gt;firstline&lt;/code&gt;, simplify scroll logic.&lt;/li&gt;&#xA;&lt;li&gt;Test entire rect instead of 2 corners in &lt;code&gt;find_cursor_popup()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;known issue&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I use &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; instead of &lt;code&gt;blank&lt;/code&gt; as &lt;code&gt;no operation&lt;/code&gt;, as &lt;code&gt;blank&lt;/code&gt; doesn't trigger popup window redraw. &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; will also trigger a &lt;code&gt;bell&lt;/code&gt;, you may use &lt;code&gt;set belloff+=esc&lt;/code&gt; to deal with it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-d&amp;gt; misc#popup#scroll_cursor_popup(1) ? '&amp;lt;esc&amp;gt;' : '&amp;lt;c-d&amp;gt;'&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-u&amp;gt; misc#popup#scroll_cursor_popup(0) ? '&amp;lt;esc&amp;gt;' : '&amp;lt;c-u&amp;gt;'&#xA;&#xA;function misc#popup#find_cursor_popup(...)&#xA;  let radius = get(a:000, 0, 2)&#xA;  let srow = screenrow()&#xA;  let scol = screencol()&#xA;&#xA;  &amp;quot; it's necessary to test entire rect, as some popup might be quite small&#xA;  for r in range(srow - radius, srow + radius)&#xA;    for c in range(scol - radius, scol + radius)&#xA;      let winid = popup_locate(r, c)&#xA;      if winid != 0&#xA;        return winid&#xA;      endif&#xA;    endfor&#xA;  endfor&#xA;&#xA;  return 0&#xA;endfunction&#xA;&#xA;function misc#popup#scroll_cursor_popup(down)&#xA;  let winid = misc#popup#find_cursor_popup()&#xA;  if winid == 0&#xA;    return 0&#xA;  endif&#xA;&#xA;  let pp = popup_getpos(winid)&#xA;  call popup_setoptions( winid,&#xA;        \ {'firstline' : pp.firstline + ( a:down ? 1 : -1 ) } )&#xA;&#xA;  return 1&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There is an open &lt;a href=&quot;https://github.com/neoclide/coc.nvim/issues/1160&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue&lt;/a&gt; about this.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-11-16T13:39:44.580" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21928" PostTypeId="1" CreationDate="2019-11-15T15:10:33.793" Score="4" ViewCount="1145" Body="&lt;p&gt;I know that I can run a search in vim using &lt;code&gt;/&lt;/code&gt;. I prefer having search highlighting turned on, but if I have a two splits with different files open, and I search for a term in one, they get highlighted as if I ran the same search or subsitution in both. Is there any way to disable this? The same thing occurs with tabs as well.&lt;/p&gt;&#xA;" OwnerUserId="25677" LastActivityDate="2019-11-22T04:06:11.073" Title="search highlighting only in the current buffer" Tags="|search|buffers|highlight|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21929" PostTypeId="1" CreationDate="2019-11-15T15:40:21.250" Score="2" ViewCount="835" Body="&lt;p&gt;&lt;strong&gt;Is it possible to configure vi to use a different location, say my home directory, for the uncompressed help files (or maybe to open them in RO if that's the problem)?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When attempting to open a help document from within &lt;strong&gt;vi&lt;/strong&gt; I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;quickref.txt.gz&quot; [readonly][noeol] 94L, 21071C&#xA;Error detected while processing function gzip#read:&#xA;line   41:&#xA;E484: Can't open file /tmp/vcl6GTZ/7&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function gzip#read:&#xA;line   44:&#xA;Error: Could not read uncompressed file&#xA;Press ENTER or type command to continue&#xA;E434: Can't find tag pattern&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This happens when pressing &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;]&lt;/kbd&gt; over &lt;em&gt;quickref&lt;/em&gt; from &lt;em&gt;help.txt&lt;/em&gt; (&lt;code&gt;:help&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dLIzb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dLIzb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, the raw, uncompressed &lt;em&gt;help.txt.gz&lt;/em&gt; file is opened and displayed:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PKBPK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PKBPK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was told by the company hosting this server that I don't have access to &lt;code&gt;tmp&lt;/code&gt; (though I can &lt;code&gt;ls&lt;/code&gt; it's contents).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt; (11/15/2019)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After adding $TMPDIR to env with &lt;code&gt;export TMPDIR=~/tmp&lt;/code&gt; I now get the following error (same error, different location). Maybe the underlying issue is with the &quot;tag pattern&quot; not being found, which occurs irrespective of the temp path's location:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;quickref.txt.gz&quot; [readonly][noeol] 94L, 21071C&#xA;Error detected while processing function gzip#read:&#xA;line   41:&#xA;E484: Can't open file /home1/&amp;lt;username&amp;gt;/tmp/vNQn0ab/3&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function gzip#read:&#xA;line   44:&#xA;Error: Could not read uncompressed file&#xA;Press ENTER or type command to continue&#xA;E434: Can't find tag pattern&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13655" LastEditorUserId="13655" LastEditDate="2019-11-15T20:43:23.687" LastActivityDate="2019-11-15T20:43:23.687" Title="Can the temp gzip decompression location for the integrated help documents be changed from /tmp?" Tags="|help-system|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21930" PostTypeId="1" CreationDate="2019-11-15T16:01:53.803" Score="1" ViewCount="360" Body="&lt;p&gt;Hi I'm a new vim user (1 week), I just switched my color scheme to monokai, however a point let me dissatisfied, c++ namespaces are not highlighted.&#xA;I tried :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi namespace guifg=[my color]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Namespace guifg=[my color]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;without any results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know a way around ?&lt;/p&gt;&#xA;" OwnerUserId="25680" LastEditorUserId="25680" LastEditDate="2019-11-15T16:29:57.677" LastActivityDate="2019-11-15T16:41:20.837" Title="Namespace color scheme" Tags="|colorscheme|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21931" PostTypeId="2" ParentId="21929" CreationDate="2019-11-15T16:17:25.737" Score="2" Body="&lt;p&gt;I've done some digging. (tpope's scriptease makes this really easy.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;plugin/gzip.vim&lt;/code&gt; reveals that most of the functionality is autoloaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autoload/gzip.vim&lt;/code&gt; reveals that the temporary paths are constructed using &lt;code&gt;tempname()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;tempname()&lt;/code&gt; reveals that &lt;code&gt;*tempfile*&lt;/code&gt; has the appropriate help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vim uses temporary files for filtering, generating diffs and also for&#xA;tempname().  For Unix, the file will be in a private directory (only&#xA;accessible by the current user) to avoid security problems (e.g., a symlink&#xA;attack or other people reading your file).  When Vim exits the directory and&#xA;all files in it are deleted.  When Vim has the setuid bit set this may cause&#xA;problems, the temp file is owned by the setuid user but the filter command&#xA;probably runs as the original user.&#xA;On MS-DOS and OS/2 the first of these directories that works is used: $TMP,&#xA;$TEMP, c:\TMP, c:\TEMP.&#xA;For Unix the list of directories is: $TMPDIR, /tmp, current-dir, $HOME.&#xA;For MS-Windows the GetTempFileName() system function is used.&#xA;For other systems the tmpnam() library function is used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, at least on *nix systems, you should be able to set the &lt;code&gt;TMPDIR&lt;/code&gt; environment variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that other programs may use this variable too, so you may want to only set it for vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; vimrc or other&#xA;let $TMPDIR = ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But any &lt;code&gt;:term&lt;/code&gt;s you start will inherit this (I'm not sure if it is exported, though, so I am not sure if other programs running from a shell could see it. &lt;code&gt;printenv&lt;/code&gt; sees it, at least.)&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-15T16:17:25.737" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21932" PostTypeId="1" AcceptedAnswerId="21937" CreationDate="2019-11-15T16:32:14.530" Score="1" ViewCount="631" Body="&lt;p&gt;I'm configuring a terminal buffer and now I have the following problem. I have only one terminal buffer and I need to make it active by its number to avoid lots of &lt;code&gt;CTRL-w j/k/l&lt;/code&gt; clicks.&lt;/p&gt;&#xA;&lt;p&gt;Here is what I tried:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Given &lt;code&gt;vim&lt;/code&gt; opened I typed &lt;code&gt;:bot term&lt;/code&gt; to create a new terminal buffer:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZJaFl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZJaFl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here we have a terminal buffer opened on the bottom.&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;I go to the top buffer and try to make terminal focused by its buffer number to type some commands (this particular case is simple, but in general navigation might be complicated).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I type the following commands right in vim one by one&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:let g:tn = bufnr(&amp;quot;$&amp;quot;)&#xA;:echo g:tn &amp;quot;prints 2&#xA;:b 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And here is where the problem comes. Instead of just activating the terminal I got 2 synchronized terminal buffers:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0rJfx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0rJfx.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So the top buffer became &amp;quot;a mirror&amp;quot; of the terminal buffer with the number 2.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to fix it? So just activate a terminal to type some more commands?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-11-15T21:07:36.003" Title="Make a buffer active by its number" Tags="|vimrc|vimscript|buffers|terminal|terminal-buffer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21933" PostTypeId="2" ParentId="21930" CreationDate="2019-11-15T16:37:31.760" Score="3" Body="&lt;p&gt;The identifier was &lt;code&gt;cppSTLnamespace&lt;/code&gt;.&#xA;Thanks to @D.Ben Knoble for his &lt;a href=&quot;https://github.com/benknoble/vim-synstax&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The full command is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi cppSTLbamespace guifg=...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25680" LastEditorUserId="10604" LastEditDate="2019-11-15T16:41:20.837" LastActivityDate="2019-11-15T16:41:20.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21934" PostTypeId="2" ParentId="21929" CreationDate="2019-11-15T16:48:43.343" Score="1" Body="&lt;p&gt;Yes, it is possible to override the location where the temporary decompressed files are stored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Unix-like platforms (including Linux or Mac OS), you can do so by setting the &lt;code&gt;$TMPDIR&lt;/code&gt; environment variable, which you can either do from your vimrc file, or from your &lt;code&gt;.bashrc&lt;/code&gt; or similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you create a &lt;code&gt;~/tmp&lt;/code&gt; directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ mkdir ~/tmp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can use the following in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let $TMPDIR = expand('~/tmp')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or define the environment variable in your &lt;code&gt;.bashrc&lt;/code&gt; or similar:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export TMPDIR=~/tmp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Exporting it in your shell is probably better, since there are other tools that depend on a writable temporary directory and that might  the same variable setting, so they'd benefit from this configuration too.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details, see &lt;a href=&quot;https://vimhelp.org/change.txt.html#tempfile&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help tempfile&lt;/code&gt;&lt;/a&gt; on how Vim will look for a temporary directory and how it varies per platform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also want to check &lt;code&gt;:help tempname()&lt;/code&gt;, which is the Vimscript function used by the &lt;code&gt;gzip.vim&lt;/code&gt; module to find a temporary directory. And &lt;code&gt;:help expand()&lt;/code&gt; which was mentioned above.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-11-15T16:48:43.343" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21935" PostTypeId="2" ParentId="21386" CreationDate="2019-11-15T18:33:15.747" Score="0" Body="&lt;p&gt;I have made the following code, just in case: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;D-I&amp;gt; :let @z=input('enter text: ') &amp;lt;bar&amp;gt; norm &quot;zp&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Simply, type new text to be inserted , where it is not effected by i-mappings or Ultisnip. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-11-15T18:33:15.747" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="21936" PostTypeId="2" ParentId="21932" CreationDate="2019-11-15T19:11:55.987" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;So the top buffer became &quot;a mirror&quot; of the terminal buffer with the number 2.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your problem is that you confuse &quot;buffer&quot; and &quot;window&quot;. Those &quot;rectangles&quot; you see are called &quot;windows&quot;, while their contents are called &quot;buffers&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the command &lt;code&gt;:b 2&lt;/code&gt; says &quot;I want a buffer number two to be shown in the current window&quot;. And that's not what you really wanted.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So just activate a terminal to type some more commands?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You have to find a terminal &lt;em&gt;window&lt;/em&gt; and then make it active.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for w in getwininfo()&#xA;    if w.terminal&#xA;        call win_gotoid(w.winid)&#xA;        break&#xA;    endif&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-11-15T21:07:36.003" LastActivityDate="2019-11-15T21:07:36.003" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21937" PostTypeId="2" ParentId="21932" CreationDate="2019-11-15T19:39:33.110" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Make a buffer active by its number&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can combine &lt;code&gt;win_gotoid()&lt;/code&gt; &amp;amp; &lt;code&gt;win_findbuf()&lt;/code&gt; to accomplish this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call win_gotoid(get(win_findbuf(g:tn), 0))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But we can do better for terminal like things by improving a few things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Automatically set our variable on &lt;code&gt;TerminalOpen&lt;/code&gt; autocmd&lt;/li&gt;&#xA;&lt;li&gt;Provide methods to send text to the terminal&lt;/li&gt;&#xA;&lt;li&gt;Provide a command to jump to the term or open it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Add the following to your &lt;code&gt;vimrc&lt;/code&gt; or better yet &lt;code&gt;~/.vim/packages/bundle/start/send-to-term/plugin/send-to-term.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup sent_to_term&#xA;  autocmd!&#xA;  autocmd BufWinEnter,TerminalOpen * if &amp;amp;buftype ==# 'terminal' |&#xA;        \   let t:sent_to_term_bufnr = +expand('&amp;lt;abuf&amp;gt;') |&#xA;        \ endif&#xA;augroup END&#xA;&#xA;function! s:term_op(type, ...)&#xA;  let [sel, rv, rt] = [&amp;amp;selection, @@, getregtype('&quot;')]&#xA;  let &amp;amp;selection = &quot;inclusive&quot;&#xA;&#xA;  if a:0 &#xA;    silent exe &quot;normal! `&amp;lt;&quot; . a:type . &quot;`&amp;gt;y&quot;&#xA;  elseif a:type == 'line'&#xA;    silent exe &quot;normal! '[V']y&quot;&#xA;  elseif a:type == 'block'&#xA;    silent exe &quot;normal! `[\&amp;lt;C-V&amp;gt;`]y&quot;&#xA;  else&#xA;    silent exe &quot;normal! `[v`]y&quot;&#xA;  endif&#xA;&#xA;  call s:send_to_term(@@)&#xA;&#xA;  let &amp;amp;selection = sel&#xA;  call setreg('&quot;', rv, rt)&#xA;endfunction&#xA;&#xA;function! s:get_current_term(...)&#xA;  if a:0&#xA;    let bufnr = bufnr(a:1)&#xA;  else&#xA;    let bufnr = get(t:, 'sent_to_term_bufnr', 0)&#xA;  endif&#xA;  if bufnr &amp;gt; 0 &amp;amp;&amp;amp; bufexists(bufnr) &amp;amp;&amp;amp; getbufvar(bufnr, '&amp;amp;buftype') ==# 'terminal'&#xA;    return bufnr&#xA;  else&#xA;    let v:errmsg = 'No Terminal'&#xA;    throw &quot;SendToTerm: &quot; . v:errmsg&#xA;  endif&#xA;endfunction&#xA;&#xA;function! s:send_to_term(keys, ...)&#xA;  let restore = bufnr('%')&#xA;  try&#xA;    let bufnr = call(function('s:get_current_term'), a:000)&#xA;    silent execute 'b ' . bufnr&#xA;    let lnum = line('$')&#xA;    normal! G$mp&#xA;    let keys = substitute(a:keys, '\n$', '', '')&#xA;    call term_sendkeys(bufnr, keys . &quot;\&amp;lt;cr&amp;gt;&quot;)&#xA;    echo &quot;Terminal: Sent &quot; . len(keys) . &quot; chars -&amp;gt; &quot; . bufname(bufnr)&#xA;    call setpos(&quot;'[&quot;, [bufnr, count(keys, &quot;\n&quot;) + 1 + lnum, 1, 1])&#xA;  catch /^SendToTerm:/&#xA;    echohl ErrorMsg &#xA;    echo &quot;Error: &quot; . v:errmsg&#xA;    echohl None&#xA;  finally&#xA;    silent execute 'b ' . restore&#xA;  endtry&#xA;endfunction&#xA;&#xA;function! s:goto_term(...)&#xA;  try&#xA;    let bufnr = call(function('s:get_current_term'), a:000)&#xA;    let winid = get(win_findbuf(bufnr), 0)&#xA;    if winid &amp;gt; 0&#xA;      call win_gotoid(winid)&#xA;    else&#xA;      execute 'sb ' . bufnr&#xA;    endif&#xA;  catch /^SendToTerm:/&#xA;    echohl ErrorMsg &#xA;    echo &quot;Error: &quot; . v:errmsg&#xA;    echohl None&#xA;  endtry&#xA;endfunction&#xA;&#xA;command! -range -bar -nargs=? -complete=buffer SendToTerm call s:send_to_term(join(getline(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;), &quot;\n&quot;), &amp;lt;f-args&amp;gt;)&#xA;command! -bar GotoTerm call s:goto_term()&#xA;nmap &amp;lt;script&amp;gt; &amp;lt;Plug&amp;gt;(send-to-term-line) :&amp;lt;c-u&amp;gt;SendToTerm&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;script&amp;gt; &amp;lt;Plug&amp;gt;(send-to-term) :&amp;lt;c-u&amp;gt;set opfunc=&amp;lt;SID&amp;gt;term_op&amp;lt;cr&amp;gt;g@&#xA;xmap &amp;lt;script&amp;gt; &amp;lt;Plug&amp;gt;(send-to-term) :&amp;lt;c-u&amp;gt;call &amp;lt;SID&amp;gt;term_op(visualmode(), 1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this you can use &lt;code&gt;:GotoTerm&lt;/code&gt; to jump to the last opened terminal buffer and use &lt;code&gt;:SendToTerm&lt;/code&gt; with a range to send a range of lines to the terminal buffer. I also provided &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mappings to send motions and visually selected text to the terminal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap yrr &amp;lt;Plug&amp;gt;(send-to-term-line)&#xA;nmap yr &amp;lt;Plug&amp;gt;(send-to-term)&#xA;xmap R &amp;lt;Plug&amp;gt;(send-to-term)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="778" LastActivityDate="2019-11-15T19:39:33.110" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21938" PostTypeId="1" AcceptedAnswerId="21939" CreationDate="2019-11-16T06:07:33.627" Score="1" ViewCount="1127" Body="&lt;p&gt;Suppose caret is on the line &lt;code&gt;10&lt;/code&gt; and I've recorded macros &lt;code&gt;@d&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to replay macros until line 25. If I know that macros move caret one line per execution, I can calculate that it should be executed &lt;code&gt;25 - 10 = 15&lt;/code&gt; times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the command will be &lt;code&gt;15@d&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But is it possible to use something like 'until line':&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:15@d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25612" LastActivityDate="2019-11-17T07:03:00.637" Title="Replay a vim macro until specified line number" Tags="|normal-mode|repeated-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21939" PostTypeId="2" ParentId="21938" CreationDate="2019-11-16T07:16:23.693" Score="6" Body="&lt;p&gt;I think you can use this for specific line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:10,15 norm! @d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want something like &lt;code&gt;until line&lt;/code&gt;, you can use this instead&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,15 norm! @d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or a more visual way, by selecting the lines you want to change via Visual mode and then execute the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:norm! @d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;15:&lt;/code&gt; from normal mode to execute the macro for the next 15 lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;15: norm! @d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks for @dedowsdi for the tip :D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#:range&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h range&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/various.html#:normal&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h normal&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/390194/9605555/&quot;&gt;https://stackoverflow.com/a/390194/9605555/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25689" LastEditorUserId="25689" LastEditDate="2019-11-17T07:03:00.637" LastActivityDate="2019-11-17T07:03:00.637" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21940" PostTypeId="2" ParentId="21798" CreationDate="2019-11-16T11:43:18.460" Score="1" Body="&lt;p&gt;A slight adaptation of @dedowsdi answer for neoterm. This plugin &lt;a href=&quot;https://github.com/kassio/neoterm&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kassio/neoterm&lt;/a&gt; that provides improved terminal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;you can use this in the bash_profile&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [[ ! -z &quot;$NVIM_LISTEN_ADDRESS&quot; ]]; then&#xA;hookvim&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I don't. Because in the code I assume that the terminal is in an opened tab to the right (switch to the window and back). one can upgrade the code a bit to avoid this. Notice that you also need to have neovim-remote for this to work. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cdv()&#xA;{&#xA;  #printf '\033]51;[&quot;call&quot;, &quot;Tapi_lcd&quot;, [&quot;%s&quot;]]\007' &quot;$(pwd)&quot;&#xA;  nvr --servername $NVIM_LISTEN_ADDRESS --remote-send '&amp;lt;c-\&amp;gt;&amp;lt;c-N&amp;gt;&amp;lt;c-w&amp;gt;h:lcd '&quot;$(pwd)&quot;'&amp;lt;CR&amp;gt;&amp;lt;c-w&amp;gt;li'&#xA;}&#xA;&#xA;cd_and_cdv()&#xA;{&#xA;  cd &quot;$@&quot; &amp;amp;&amp;amp; cdv&#xA;}&#xA;&#xA;hookvim()&#xA;{&#xA;alias cd=cd_and_cdv&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I open the terminal with (the argument is 0 for this to work) &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set splitright&#xA;function! TermOV(use_file_dir)    &#xA;    let k=g:neoterm.last_id+1&#xA;    vertical Tnew&#xA;    exe k.&quot;T . /etc/bashrc&quot;&#xA;    exe k.&quot;T . ~/.bash_profile&quot;&#xA;    if a:use_file_dir&#xA;        exe k.&quot;T cd &quot; . expand('%:p:h')&#xA;    else&#xA;        exe k.&quot;T hookvim&quot; &#xA;    endif  &#xA;&#xA;    exe k.&quot;Tclear&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-11-18T12:54:38.010" LastActivityDate="2019-11-18T12:54:38.010" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21941" PostTypeId="1" AcceptedAnswerId="21944" CreationDate="2019-11-16T16:07:17.967" Score="4" ViewCount="3200" Body="&lt;p&gt;I am new to vim and tmux.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;TL;DR&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I want to have tmux set up so that I have a pane for my (python) code and a pane for the output of the code.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What I know&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Now, from vim I can do a command like &lt;code&gt;:!python %&lt;/code&gt; to run/interpret my code, but the problem is that it displays the results, on the same screen, instead of the code. I have to end the program to see the code again.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What I found&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I can do something like &lt;code&gt;tmux run-shell -t 2 &quot;echo hello&quot;&lt;/code&gt; to send the output to a different pane, but this still replaces the code with &lt;code&gt;Press ENTER or type a command to continue&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What I'd like&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I'd love to know how can I send the output of the code to a different pane without disturbing my code pane.&lt;/p&gt;&#xA;" OwnerUserId="25692" LastEditorUserId="10604" LastEditDate="2019-11-16T19:29:46.367" LastActivityDate="2021-12-10T18:21:08.727" Title="Running code in a different tmux pane" Tags="|tmux|" AnswerCount="10" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21942" PostTypeId="2" ParentId="21941" CreationDate="2019-11-16T17:28:13.180" Score="2" Body="&lt;p&gt;OK so I found a bit of a work around that works.&#xA;I first declare a new command that gets as an input a command and executes the given command and then redraws the screen&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=1 Silent execute ':silent !'.&amp;lt;q-args&amp;gt; | execute ':redraw!'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And on the next line it uses that command to send the interpreter command to a different pane.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F6&amp;gt; :Silent tmux send-keys -t 2 C-z 'python %' Enter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25692" LastActivityDate="2019-11-16T17:28:13.180" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21943" PostTypeId="2" ParentId="21941" CreationDate="2019-11-16T18:06:08.377" Score="4" Body="&lt;p&gt;If you build tmux from Git master you can send the output to an empty pane, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mybuildcommand|tmux splitw -dI -c/my/source/directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know how to stop vim hiding the code while this is running however.&lt;/p&gt;&#xA;" OwnerUserId="25695" LastActivityDate="2019-11-16T18:06:08.377" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21944" PostTypeId="2" ParentId="21941" CreationDate="2019-11-16T19:41:45.343" Score="2" Body="&lt;p&gt;I ended up creating &lt;a href=&quot;https://github.com/benknoble/vim-simpl&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-simpl&lt;/a&gt; for this. One function allows you to create a REPL (mapped to &lt;code&gt;&amp;lt;leader&amp;gt;t&lt;/code&gt; in my config, as below), and another to load a file (mapped to &lt;code&gt;&amp;lt;localleader&amp;gt;l&lt;/code&gt; in my config). With some effort, I can add python support out-of-box. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you have vim8, it's easy to set up a mapping to open a &lt;code&gt;:terminal&lt;/code&gt;, to which you can then send commands (like build and run code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My workflow is something like&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Edit python code&lt;/li&gt;&#xA;&lt;li&gt;Try some code in the python interpreter (&lt;code&gt;&amp;lt;Leader&amp;gt;t&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Copy or write in the code&lt;/li&gt;&#xA;&lt;li&gt;Either tmux split, &lt;code&gt;:term&lt;/code&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;Z&lt;/kbd&gt;, or &lt;code&gt;:quit&lt;/code&gt; to run my script (with sessions, I can then get a semblance of where I was with &lt;code&gt;vim -S&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have seen several answers on this site dedicated to opening a &lt;code&gt;:term&lt;/code&gt; and sending commands to it. There are also tmux plugins for vim that might help you do this. My alternative (below) is to let the shell do its thing (run code), but provide a way to do that in vim. It also lets me play with interpreters in vim with a minimum of fuss.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the end, I do provide a possibility of something more like &quot;run code&quot; then &quot;run an interpreter.&quot; It is untested, however.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have these mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Terms and interpreters&#xA;&quot; set b:interpreter for filetypes to affect the term&#xA;nnoremap &amp;lt;Leader&amp;gt;t :call terminal#run('++close')&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;T :call terminal#run()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which use this code (I should just make this a plugin at this point):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; autoload/terminal.vim&#xA;&quot; Functions for dealing with the terminal&#xA;&#xA;&quot; Global function for calling terminal with the appropriate interpreter&#xA;&quot; b:interpreter controls the program run&#xA;function! terminal#run(...) abort&#xA;  let l:interpreter = get(b:, 'interpreter', &amp;amp;shell)&#xA;  let l:command = 'term'&#xA;  if a:0&#xA;    for l:opt in a:000&#xA;      let l:command .= printf(' %s', opt)&#xA;    endfor&#xA;  endif&#xA;  let l:command .= printf(' %s', l:interpreter)&#xA;  execute l:command&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, in &lt;code&gt;after/ftplugin/python.vim&lt;/code&gt;, I have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:interpreter = 'python'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have similar definitions for lisp (&lt;code&gt;clisp&lt;/code&gt;), ruby (&lt;code&gt;irb&lt;/code&gt;), and more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could probably even do something like &lt;code&gt;let b:interpreter = 'python '.expand('%')&lt;/code&gt;, so that the &quot;interpreter&quot; is actually &quot;run this file.&quot; Then you would prefer &lt;code&gt;&amp;lt;Leader&amp;gt;T&lt;/code&gt;, which, in my mappings, does not close the terminal when it finishes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'm not hating on tmux. I actually use it anytime I'm in a terminal. But for running code, it can be nice to pop open an integrated terminal, particularly for interpreted languages.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If the program is not interactive, the Clam plugin is quite useful. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-01-09T05:45:09.870" LastActivityDate="2020-01-09T05:45:09.870" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21945" PostTypeId="2" ParentId="21941" CreationDate="2019-11-16T20:11:47.410" Score="6" Body="&lt;p&gt;The run-shell example you mention looks identical to that in&#xA;&lt;a href=&quot;https://unix.stackexchange.com/questions/416453/run-build-command-from-vim-send-output-to-another-tmux-pane/416480#416480&quot;&gt;my 'Unix &amp;amp; Linux' post&lt;/a&gt;&#xA;on this topic so you may have read that. If so, at the very end I mention use of a mapping to prevent external commands (e.g. a 'make' command or equivalent) from interrupting the vim session in too disruptive a way. Admittedly, it's just a small update to the answer with a basic example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more substantive example might be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;X :!tmux run-shell -b -t 3 'cd mybuilddir &amp;amp;&amp;amp; make arg1 arg2... 2&amp;gt;&amp;amp;1'&amp;lt;CR&amp;gt;&amp;lt;C-L&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unlike the original this shows how to quote the shell command and use &lt;code&gt;2&amp;gt;&amp;amp;1&lt;/code&gt; to ensure that errors sent to stderr appear in the same pane as regular output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also included run-shell flag &lt;code&gt;-b&lt;/code&gt; which, as mentioned in the U&amp;amp;L answer, tells tmux to start the command in the background. If the shell command does anything wonky (like start by sleeping) this is an additional safeguard against interrupting the vim session. I'd try your own command with and without &lt;code&gt;-b&lt;/code&gt; and use whatever works best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, if you have a complex shell (Bash) command you might want to do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;X :!tmux run-shell -b -t 3 '{ cd mybuilddir; do this; do that; ... ; make arg1 arg2...; } 2&amp;gt;&amp;amp;1'&amp;lt;CR&amp;gt;&amp;lt;C-L&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This, for one, avoids having to specify &lt;code&gt;2&amp;gt;&amp;amp;1&lt;/code&gt; for each command. (Important: Bash requires that the braces be separated from the shell commands by whitespace and the last command, before &lt;code&gt;}&lt;/code&gt;, be followed by &lt;code&gt;;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have further questions on this approach let me know.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-11-16T20:46:24.537" LastActivityDate="2019-11-16T20:46:24.537" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21946" PostTypeId="2" ParentId="21941" CreationDate="2019-11-17T07:08:32.433" Score="0" Body="&lt;p&gt;I think a plugin usage will be better since you are not limiting yourself to plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now I think there are two plugins that is worth checking out&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/benmills/vimux&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimux&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/christoomey/vim-tmux-runner&quot; rel=&quot;nofollow noreferrer&quot;&gt;VTR&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Or if you prefer to show the result in vim quickfix window, you can use the &lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dispatch&lt;/a&gt; plugin instead&lt;/p&gt;&#xA;" OwnerUserId="25689" LastActivityDate="2019-11-17T07:08:32.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21947" PostTypeId="1" CreationDate="2019-11-17T10:28:43.853" Score="0" ViewCount="416" Body="&lt;p&gt;I just learned about the shortcuts that allow you to manipulate ranges, e.g. &lt;code&gt;:+5,+10co.&lt;/code&gt; to copy &lt;em&gt;after&lt;/em&gt; the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wondered if there is a way to copy and move at the &lt;em&gt;start&lt;/em&gt; of the current line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I have to move the cursor at the end of the preceding line in order to attain the desired result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To illustrate, given the following file, with the cursor being at line 5:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;  3 A&#xA;  4 B&#xA;→ 5&#xA;  6 C&#xA;  7 D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Applying a copy via &lt;code&gt;:+1,+2co.&lt;/code&gt; results in the undesired empty line at line 5:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;  3 A&#xA;  4 B&#xA;  5 &#xA;  6 C&#xA;→ 7 D &#xA;  8 C&#xA;  9 D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to copy at the start of the current line or is one limited to perform this command at the end of the preceding line?&lt;/p&gt;&#xA;" OwnerUserId="25637" LastActivityDate="2019-11-17T10:28:43.853" Title="Move/copy range to start of current line" Tags="|cut-copy-paste|range|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21948" PostTypeId="2" ParentId="21941" CreationDate="2019-11-17T16:14:22.920" Score="1" Body="&lt;p&gt;I've had great success with &lt;a href=&quot;https://github.com/jpalardy/vim-slime&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim-Slime&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin allows you to send selections of text (current line, highlighted entry, etc.) from Vim running in one tmux pane to another tmux pane. (It also supports GNU Screen.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't try to do bi-directional communication, which could be seen as a negative, but it's extremely flexible and lets you send text from Vim to &lt;em&gt;anything&lt;/em&gt; running in the other pane (bash, SQL, any language with a REPL, etc.).&lt;/p&gt;&#xA;" OwnerUserId="13161" LastActivityDate="2019-11-17T16:14:22.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21949" PostTypeId="1" AcceptedAnswerId="21950" CreationDate="2019-11-17T23:49:11.713" Score="3" ViewCount="140" Body="&lt;p&gt;There are times I want to comment List items:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let test_data = [&#xA;      \ &quot; description in comment&#xA;      \ complicated_data0&#xA;      \&#xA;      \ &quot; description in comment&#xA;      \ complicated_data1&#xA;      ...&#xA;      \ ]&#xA;&#xA;----&#xA;result error:&#xA;&#xA;E114: Missing quote: &quot; description in comment 0 ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;E114&lt;/code&gt; is thrown as it's missing the enclosing&lt;code&gt;&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the common workaround ? &lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-11-21T00:09:35.823" Title="How to comment List item?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21950" PostTypeId="2" ParentId="21949" CreationDate="2019-11-18T01:06:17.033" Score="5" Body="&lt;p&gt;Since patch 8.1.0369 you can comment continuation lines.  However, you must follow the &lt;code&gt;&quot;\&lt;/code&gt; syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let test_data = [&#xA;      &quot;\ description in comment&#xA;      \ complicated_data0&#xA;      \&#xA;      &quot;\ description in comment&#xA;      \ complicated_data1&#xA;      ...&#xA;      \ ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Prior to that, you would need to split the list up into pieces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; description in comment&#xA;let test_data = [&#xA;      \ 1,&#xA;      \ ]&#xA;&quot; description in comment&quot;,&#xA;let test_data += [&#xA;      \ 2,&#xA;      \ ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="5017" LastEditDate="2019-11-21T00:09:35.823" LastActivityDate="2019-11-21T00:09:35.823" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21951" PostTypeId="2" ParentId="18357" CreationDate="2019-11-18T07:45:11.940" Score="0" Body="&lt;p&gt;Ok, I had a time to check netrw code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looks like there is either a bug for a windows or just a bug (because it also doesn't work on my WSL debian).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code in question is in function &lt;code&gt;s:NetrwMarkFiles(islocal,...)&lt;/code&gt; on line &lt;code&gt;6660&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:NetrwMarkFiles(islocal,...)&#xA;&quot;  call Dfunc(&quot;s:NetrwMarkFiles(islocal=&quot;.a:islocal.&quot;...) a:0=&quot;.a:0)&#xA;  let curdir = s:NetrwGetCurdir(a:islocal)&#xA;  let i      = 1&#xA;  while i &amp;lt;= a:0&#xA;   if a:islocal&#xA;    if v:version &amp;gt; 704 || (v:version == 704 &amp;amp;&amp;amp; has(&quot;patch656&quot;))&#xA;     let mffiles= glob(fnameescape(a:{i}),0,1,1)&#xA;    else&#xA;     let mffiles= glob(fnameescape(a:{i}),0,1)&#xA;    endif&#xA;   else&#xA;    let mffiles= [a:{i}]&#xA;   endif&#xA;&quot;   call Decho(&quot;mffiles&quot;.string(mffiles),'~'.expand(&quot;&amp;lt;slnum&amp;gt;&quot;))&#xA;   for mffile in mffiles&#xA;&quot;    call Decho(&quot;mffile&amp;lt;&quot;.mffile.&quot;&amp;gt;&quot;,'~'.expand(&quot;&amp;lt;slnum&amp;gt;&quot;))&#xA;    call s:NetrwMarkFile(a:islocal,mffile)&#xA;   endfor&#xA;   let i= i + 1&#xA;  endwhile&#xA;&quot;  call Dret(&quot;s:NetrwMarkFiles&quot;)&#xA;endfun&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is &lt;code&gt;fnameescape&lt;/code&gt; function used to provide parameter to &lt;code&gt;glob&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if v:version &amp;gt; 704 || (v:version == 704 &amp;amp;&amp;amp; has(&quot;patch656&quot;))&#xA;     let mffiles= glob(fnameescape(a:{i}),0,1,1)&#xA;    else&#xA;     let mffiles= glob(fnameescape(a:{i}),0,1)&#xA;    endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it effectively escapes &lt;code&gt;*&lt;/code&gt; in &lt;code&gt;*.vim&lt;/code&gt; parameter so you can't select all &lt;code&gt;.vim&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fnameescape({string})                   *fnameescape()*&#xA;        Escape {string} for use as file name command argument.  All&#xA;        characters that have a special meaning, such as '%' and '|'&#xA;        are escaped with a backslash.&#xA;        For most systems the characters escaped are&#xA;---&amp;gt;    &quot; \t\n*?[{`$\\%#'\&quot;|!&amp;lt;&quot;.  For systems where a backslash&#xA;        appears in a filename, it depends on the value of 'isfname'.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And on the other hand netrw Help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    * One may use the :MF command, which takes a list of&#xA;      files (for local directories, the list may include&#xA;      wildcards -- see |glob()|) &amp;gt;&#xA;&#xA;        :MF *.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is kind of fails due to escaping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure where it should be reported -- vim github or directly to Charles Campbel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS, reported &lt;a href=&quot;https://github.com/vim/vim/issues/5239&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/issues/5239&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-11-18T08:22:45.043" LastActivityDate="2019-11-18T08:22:45.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21952" PostTypeId="1" AcceptedAnswerId="21953" CreationDate="2019-11-18T08:50:31.577" Score="1" ViewCount="273" Body="&lt;p&gt;I use in my vimrc the following option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viminfo+=%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows vim to open the last edited files if you don't pass any arguments to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to ignore some files? I want to disable the opening of files like COMMIT_EDITMSG, for example.&lt;/p&gt;&#xA;" OwnerUserId="20864" LastEditorUserId="1841" LastEditDate="2019-11-18T15:41:18.663" LastActivityDate="2019-11-18T15:41:18.663" Title="Ignore some files when using viminfo+=%" Tags="|buffers|startup|viminfo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21953" PostTypeId="2" ParentId="21952" CreationDate="2019-11-18T09:25:13.980" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#viminfo-%25&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help viminfo-%&lt;/code&gt;&lt;/a&gt; gives you some hints on how to achieve this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Quickfix ('buftype'), unlisted ('buflisted'), unnamed and buffers on removable media (|viminfo-r|) are not saved.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would simply make those files &lt;em&gt;unlisted&lt;/em&gt;; as Vim is invoked from the version control system for the commit message, and usually no other files are edited within that session, the buffer listing (&lt;code&gt;:ls&lt;/code&gt;) and naviation (&lt;code&gt;:bnext&lt;/code&gt;) isn't particularly important there, anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;COMMIT_EDITMSG&lt;/code&gt;, you can hook into the existing filetype detection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType gitcommit setlocal nobuflisted&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or set up your own pattern(s):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead COMMIT_EDITMSG setlocal nobuflisted&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-18T09:25:13.980" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21954" PostTypeId="1" CreationDate="2019-11-18T15:44:01.743" Score="1" ViewCount="184" Body="&lt;p&gt;When using the vimwiki plugin, when you want to convert any text into a link you can press &lt;code&gt;enter&lt;/code&gt; on the selection. Then you follow the link, create the file and work with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you push files into GitHub, the link is obviously broken, because there are no &lt;code&gt;link&lt;/code&gt; file - there's &lt;code&gt;link.md&lt;/code&gt;. How can I automatically append a file extension (&lt;code&gt;.md&lt;/code&gt;) to the links?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vimwiki_list = [{'path': '~/knowledge/', 'syntax': 'markdown', 'ext': '.md'}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25721" LastEditorUserId="1841" LastEditDate="2019-11-18T15:48:54.550" LastActivityDate="2024-02-20T04:11:06.370" Title="Appending file format while turning text into link (by pressing Enter) in Vimwiki" Tags="|plugin-vimwiki|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21955" PostTypeId="1" CreationDate="2019-11-18T17:26:49.560" Score="1" ViewCount="20" Body="&lt;p&gt;Well, the question is clear. I want to search only on text that is not inside \[  \] or $ $ . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some readymade code to do so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-11-18T17:26:49.560" Title="TeX file, search outside math" Tags="|filetype-tex|plugin-vimtex|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21957" PostTypeId="1" CreationDate="2019-11-18T18:51:17.900" Score="0" ViewCount="71" Body="&lt;p&gt;I have two lines in the command area. How to make a single line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CAcqn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CAcqn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25726" LastActivityDate="2019-11-18T18:51:17.900" Title="Two lines in command area how to make a single line" Tags="|vimrc|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21958" PostTypeId="1" CreationDate="2019-11-18T18:58:35.337" Score="2" ViewCount="268" Body="&lt;p&gt;Is it possible to use &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ctrl-P&lt;/a&gt; to search for directories in addition to searching for files? I want to be able to search for directories in my project in whatever mode (&lt;code&gt;CtrlP&lt;/code&gt;, &lt;code&gt;CtrlPMRU&lt;/code&gt;, or other) and when I select a directory from the options I want a netrw view of the directory to open in the window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example if my project structure is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;src&#xA;├── foo&#xA;│   └── foo.py&#xA;├── bar&#xA;│   └── bar.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I open Ctrl-P in &lt;code&gt;CtrlP&lt;/code&gt; mode I want the options to be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;src/&#xA;src/foo/&#xA;src/foo/foo.py&#xA;src/bar/&#xA;src/bar/bar.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then if I selected &lt;code&gt;src/foo/&lt;/code&gt;, I would want a netrw view of &lt;code&gt;src/foo/&lt;/code&gt;, i.e. showing something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;../&#xA;./&#xA;foo.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12658" LastEditorUserId="12658" LastEditDate="2019-11-18T23:21:07.860" LastActivityDate="2023-04-03T19:05:30.627" Title="Open netrw view of directory with Ctrl-P" Tags="|netrw|plugin-ctrlp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21959" PostTypeId="2" ParentId="21566" CreationDate="2019-11-18T22:05:28.533" Score="1" Body="&lt;p&gt;I don't use &lt;code&gt;git-grep&lt;/code&gt; as &lt;code&gt;grepprg&lt;/code&gt;, and here's why:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I mostly use &lt;code&gt;:vimgrep /pattern/ ##&lt;/code&gt; to search my argument list.&lt;/li&gt;&#xA;&lt;li&gt;I mostly use &lt;code&gt;ack&lt;/code&gt; to search at the command line, though &lt;code&gt;git-grep&lt;/code&gt; is helpful. Combined with &lt;code&gt;:Ack&lt;/code&gt;, I'm set.&lt;/li&gt;&#xA;&lt;li&gt;This function makes it easy to pop open vim with the quickfix ready to go:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vq () { &#xA;    if (($# &amp;gt; 0)); then&#xA;        vim -q &amp;lt;(&quot;$@&quot; 2&amp;gt;&amp;amp;1)&#xA;    else&#xA;        printf '%s\n' 'Usage: vq cmd' '' 'Use {cmd} output as quickfix list'&#xA;    fi&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;The script in &lt;code&gt;&quot;$(git --exec-path)&quot;/../../share/git-core/contrib/git-jump&lt;/code&gt; makes this even easier: &lt;code&gt;git jump grep foo&lt;/code&gt; opens up my editor similarly to how &lt;code&gt;vq&lt;/code&gt; above functions. It also has other neat functions.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;git-grep&lt;/code&gt; doesn't work well in non-git repos, as you've noticed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-18T22:05:28.533" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21960" PostTypeId="2" ParentId="18357" CreationDate="2019-11-18T22:12:22.620" Score="1" Body="&lt;p&gt;Please try v1671 of netrw from my website.  I agree that the fnameescape() should not be there: &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.drchip.org/astronaut/vim/index.html#NETRW&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="2377" LastActivityDate="2019-11-18T22:12:22.620" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21961" PostTypeId="1" AcceptedAnswerId="21964" CreationDate="2019-11-19T02:01:23.217" Score="3" ViewCount="743" Body="&lt;p&gt;For example, wanting to delete the last 3 words from the current line, I press &lt;code&gt;$d3b&lt;/code&gt; but I still have the last char from that line not deleted. Is that normal? Is there a better way to achieve what I'm trying to do?&lt;/p&gt;&#xA;" OwnerUserId="25181" LastEditorUserId="11357" LastEditDate="2019-11-19T17:20:18.283" LastActivityDate="2019-11-19T18:52:24.507" Title="Last char on the line is being &quot;left out&quot; in many situations" Tags="|cut-copy-paste|cursor-motions|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21962" PostTypeId="2" ParentId="21961" CreationDate="2019-11-19T02:52:51.687" Score="2" Body="&lt;p&gt;&lt;code&gt;b&lt;/code&gt; is an &lt;code&gt;:h exclusive&lt;/code&gt; motion, so it behaves this way: &quot;&lt;em&gt;the last character towards the end of the buffer is not included&lt;/em&gt;&quot;. Make sure you choose appropriate tools.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it's true for the normal mode. In the visual mode everything depends on &lt;code&gt;:h 'selection'&lt;/code&gt; option value. So, if &lt;code&gt;set selection=inclusive&lt;/code&gt; (default) then &lt;code&gt;$v3bd&lt;/code&gt; does what you want.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-19T02:52:51.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21963" PostTypeId="2" ParentId="21961" CreationDate="2019-11-19T03:56:25.413" Score="2" Body="&lt;p&gt;Matt's answer addresses the why, but requires the extra keypress of visual mode to solve your problem. (And &lt;a href=&quot;https://whileimautomaton.net/2008/11/vimm3/operator&quot; rel=&quot;nofollow noreferrer&quot;&gt;there are suggestions that visual mode is less &quot;vim-like&quot;&lt;/a&gt;, at least when alternatives are available.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For deleting the last 3 words, one sequence might be &lt;code&gt;$3bD&lt;/code&gt;, no longer than your original, where you position first and delete last.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A (much longer) regex oriented solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v(\w+\W*){3}$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-19T03:56:25.413" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21964" PostTypeId="2" ParentId="21961" CreationDate="2019-11-19T04:58:26.633" Score="6" Body="&lt;p&gt;As per &lt;a href=&quot;https://vi.stackexchange.com/a/21962/18609&quot;&gt;Matt's answer&lt;/a&gt;, &lt;code&gt;b&lt;/code&gt; is an exclusive motion. Using visual mode is a possible way to work around this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can also use &lt;code&gt;v&lt;/code&gt; as an operator (instead of entering visual mode), like so: &lt;code&gt;$d&lt;b&gt;v&lt;/b&gt;3b&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/motion.txt.html#o_v&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help o_v&lt;/code&gt;&lt;/a&gt;, which explains it:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;v&lt;/code&gt;: When used after an operator, before the motion command: Force the operator to work characterwise, also when the motion is linewise.  If the motion was linewise, it will become exclusive. &lt;strong&gt;If the motion already was characterwise, toggle inclusive/exclusive.&lt;/strong&gt;  This can be used to &lt;strong&gt;make an exclusive motion inclusive&lt;/strong&gt; and an inclusive motion exclusive.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-11-19T04:58:26.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21965" PostTypeId="2" ParentId="21187" CreationDate="2019-11-19T08:18:51.127" Score="0" Body="&lt;p&gt;There are two possibilities:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Move the check to after plugins have been loaded, e.g. by hooking into the &lt;code&gt;VimEnter&lt;/code&gt; event, as outlined by @ChristianBrabandt's answer.&lt;/li&gt;&#xA;&lt;li&gt;Force early loading of the plugin:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime! plugin/goyo.vim    &quot; Try loading the plugin.&#xA;if exists(&quot;:Goyo&quot;)&#xA;    &quot; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-19T08:18:51.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21966" PostTypeId="2" ParentId="21661" CreationDate="2019-11-19T09:12:56.623" Score="3" Body="&lt;p&gt;try: &lt;code&gt;hi clear Conceal&lt;/code&gt; at the bottom of your vimrc.&lt;/p&gt;&#xA;" OwnerUserId="25735" LastActivityDate="2019-11-19T09:12:56.623" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21967" PostTypeId="1" CreationDate="2019-11-19T13:44:28.380" Score="2" ViewCount="4209" Body="&lt;p&gt;I have .vimrc plugins&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;Plugin 'nanotech/jellybeans.vim'&#xA;&quot; Plugin 'vim-airline/vim-airline'&#xA;&quot; Plugin 'vim-airline/vim-airline-themes'&#xA;Plugin 'scrooloose/nerdtree'&#xA;Plugin 'kien/ctrlp.vim'&#xA;Plugin 'tpope/vim-surround'&#xA;&quot; JavaScript&#xA;Plugin 'pangloss/vim-javascript'&#xA;Plugin 'leafgarland/typescript-vim'&#xA;Plugin 'maxmellon/vim-jsx-pretty'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but highlighting doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;also, I have a rule&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax enable      &quot; syntax highlighting&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25726" LastEditorUserId="18609" LastEditDate="2020-06-08T13:32:32.170" LastActivityDate="2020-06-08T13:32:32.170" Title="VIM How to enable .ts .tsx .js (for front-end) code highlight?" Tags="|vimrc|syntax-highlighting|plugin-system|filetype-javascript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21968" PostTypeId="2" ParentId="21967" CreationDate="2019-11-19T14:45:14.107" Score="4" Body="&lt;p&gt;I tried to use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup SyntaxSettings&#xA;    autocmd!&#xA;    autocmd BufNewFile,BufRead *.tsx set filetype=typescript&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it works.&lt;/p&gt;&#xA;" OwnerUserId="25726" LastEditorUserId="1841" LastEditDate="2019-11-19T16:24:33.043" LastActivityDate="2019-11-19T16:24:33.043" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21969" PostTypeId="2" ParentId="16906" CreationDate="2019-11-19T15:09:54.170" Score="11" Body="&lt;p&gt;To format in a deterministic way, we need to sort the hash. None of the other answers did that for me, so I created my own:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FormatJson()&#xA;python &amp;lt;&amp;lt; EOF&#xA;import vim&#xA;import json&#xA;try:&#xA;    buf = vim.current.buffer&#xA;    json_content = '\n'.join(buf[:])&#xA;    content = json.loads(json_content)&#xA;    sorted_content = json.dumps(content, indent=4, sort_keys=True)&#xA;    buf[:] = sorted_content.split('\n')&#xA;except Exception, e:&#xA;    print e&#xA;EOF&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call FormatJson()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25742" LastEditorUserId="10604" LastEditDate="2019-11-19T15:25:43.867" LastActivityDate="2019-11-19T15:25:43.867" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21970" PostTypeId="2" ParentId="21967" CreationDate="2019-11-19T15:32:06.283" Score="4" Body="&lt;p&gt;The best thing to do is enable filetype detection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim defaults to setting &lt;code&gt;.tsx&lt;/code&gt; files as &lt;code&gt;typescriptreact&lt;/code&gt; (8.1.2100 for me at least). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To enable filetype-plugins and indent scripts (recommended):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-06-08T12:14:56.800" LastActivityDate="2020-06-08T12:14:56.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21971" PostTypeId="2" ParentId="21961" CreationDate="2019-11-19T18:52:24.507" Score="1" Body="&lt;p&gt;The other answers addressed why this happens. One way around this that I prefer is just to use forward motions instead of backwards motions. Because &lt;code&gt;w&lt;/code&gt; is an inclusive motion and &lt;code&gt;b&lt;/code&gt; is an exclusive motion, in general you can do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bdw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;db&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this particular case since you want to delete from the end of the line, you could use &lt;code&gt;D&lt;/code&gt; to delete to the end of line which is a bit shorter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$3bD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or a more general solution would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3bd3w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2920" LastActivityDate="2019-11-19T18:52:24.507" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21972" PostTypeId="1" AcceptedAnswerId="21977" CreationDate="2019-11-20T01:24:52.700" Score="2" ViewCount="102" Body="&lt;p&gt;I'm struggling to understand a character escaping situation involving &lt;code&gt;\|&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First I'm running the following search which matches either the &lt;code&gt;A&lt;/code&gt; character or &lt;code&gt;B&lt;/code&gt; character.  I'm using the default &lt;code&gt;magic&lt;/code&gt; option so the parentheses &lt;code&gt;()&lt;/code&gt; and alternatives separator &lt;code&gt;|&lt;/code&gt; must be preceded by backslashes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\(A\|B\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next I'd like to execute this as a &lt;code&gt;normal&lt;/code&gt; command, so I run the following command and it works as expected.  Since the search expression is now in a double quoted string, I have to escape each backslash character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;normal! /\\(A\\|B\\)\r&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally I'd like to create a normal mode mapping which executes this command.  I run the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Leader&amp;gt;h :&amp;lt;C-u&amp;gt;execute &quot;normal! /\\(A\\|B\\)\r&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when attempting to use this mapping, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E486: Pattern not found: \(A|B\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to get this mapping to work, I have to add an additional backslash before the &lt;code&gt;|&lt;/code&gt; character, but I don't have to add additional backslashes before the &lt;code&gt;(&lt;/code&gt; or &lt;code&gt;)&lt;/code&gt; characters!  The working command is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Leader&amp;gt;h :&amp;lt;C-u&amp;gt;execute &quot;normal! /\\(A\\\|B\\)\r&quot;&amp;lt;CR&amp;gt;&#xA;                                                 ^&#xA;                                                 |&#xA;                                   three backslashes instead of two&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is an extra backslash required here to make this work?  And why do the parentheses each not also require an extra backslash?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running Vim 8.0, patches 1-1453, compiled myself on WSL.&lt;/p&gt;&#xA;" OwnerUserId="25747" LastActivityDate="2019-11-20T03:07:55.770" Title="Why do the \| characters in an :execute &quot;normal ...&quot; mapping require extra escaping backslashes?" Tags="|key-bindings|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21973" PostTypeId="1" CreationDate="2019-11-20T02:06:41.467" Score="0" ViewCount="124" Body="&lt;p&gt;I am using gVim and Asynchronous Lint Engine (ALE) for linting Python scripts. I was capable to fully customize my own Python syntax highlighting, with one exception.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find a way to prevent ALE from changing the color of the character where the linted error was detected &lt;strong&gt;and&lt;/strong&gt; at the same keeping the blue/red underlines that indicate errors (notice the letter 'd' changes color):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7C8Qh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7C8Qh.png&quot; alt=&quot;s&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do &lt;code&gt;let g:ale_set_highlights = 0&lt;/code&gt;, ALE does not change the characters' colors, but then I also loose the blue/red underlining that you in the image above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I solve that?&lt;/p&gt;&#xA;" OwnerUserId="25748" LastEditorUserId="1841" LastEditDate="2019-11-20T08:09:15.370" LastActivityDate="2019-11-20T08:09:15.370" Title="In GVim, preven ALE from changing syntax color, but still underlines errors" Tags="|syntax-highlighting|plugin-ale|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21974" PostTypeId="2" ParentId="21972" CreationDate="2019-11-20T02:40:38.230" Score="0" Body="&lt;p&gt;This is a bit of a guess, but I suspect it has to with &lt;code&gt;|&lt;/code&gt; also being the ex command separator. So execute probably mangles things, and needs to see &lt;code&gt;\|&lt;/code&gt;, which in string form would &lt;code&gt;\\\|&lt;/code&gt;—in other words, &lt;code&gt;|&lt;/code&gt; needs to be escaped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternative ideas:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:/&lt;/code&gt; is an ex command that addresses the search pattern entered. If memory serves, it works rather like a normal &lt;code&gt;/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;You can also set the search register with &lt;code&gt;let @/ = ...&lt;/code&gt; and then simply &lt;code&gt;:normal! n&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-20T02:40:38.230" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21975" PostTypeId="1" AcceptedAnswerId="21976" CreationDate="2019-11-20T02:51:48.190" Score="8" ViewCount="3309" Body="&lt;p&gt;Assume buffer content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;aa bb&#xA;yy xx&#xA;aa bb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's the different between &lt;code&gt;/xx&lt;/code&gt; and &lt;code&gt;:/xx&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="4472" LastEditDate="2019-11-25T22:58:31.847" LastActivityDate="2019-11-25T22:58:31.847" Title="What's the difference between `/x` and `:/x`" Tags="|vimscript|search|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21976" PostTypeId="2" ParentId="21975" CreationDate="2019-11-20T02:53:25.280" Score="9" Body="&lt;p&gt;&lt;code&gt;/xx&lt;/code&gt; place cursor at &lt;code&gt;xx&lt;/code&gt;, it's a &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F&quot; rel=&quot;noreferrer&quot;&gt;:h /&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:/xx&lt;/code&gt; is a &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%3A%5Brange%5D&quot; rel=&quot;noreferrer&quot;&gt;:h :[range]&lt;/a&gt; , not &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#%3Arange&quot; rel=&quot;noreferrer&quot;&gt;:h :range&lt;/a&gt; , it's a valid ex command by itself, it's behavior is affected by &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27startofline%27&quot; rel=&quot;noreferrer&quot;&gt;:h 'startofline'&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;'startofline'&lt;/code&gt; is on (default), &lt;code&gt;:/xx&lt;/code&gt; place cursor at 1st non-blank of the line that contain &lt;code&gt;xx&lt;/code&gt;, it's the leading &lt;code&gt;y&lt;/code&gt; in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;'startofline'&lt;/code&gt; is off, &lt;code&gt;:/xx&lt;/code&gt; move cursor to the matching line without moving the column if possible (you have to move the column if target line is too short).&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-11-20T03:09:48.240" LastActivityDate="2019-11-20T03:09:48.240" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21977" PostTypeId="2" ParentId="21972" CreationDate="2019-11-20T03:07:55.770" Score="3" Body="&lt;p&gt;&lt;code&gt;|&lt;/code&gt; is used to separate a map command from the next one, you need to escape it or use &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; instead, read &lt;a href=&quot;https://vimhelp.org/map.txt.html#map-bar&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h map-bar&lt;/a&gt; for further detail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your map is unnecessarily complicated, &lt;code&gt;{rhs}&lt;/code&gt; of a &lt;code&gt;map&lt;/code&gt; without &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-%3Cexpr%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :map-&amp;lt;expr&gt;&lt;/a&gt; is applied as typed, no need to use &lt;code&gt;execute&lt;/code&gt; and &lt;code&gt;normal&lt;/code&gt; in this case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;h /\(A\&amp;lt;bar&amp;gt;B\)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-11-20T03:07:55.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21978" PostTypeId="1" AcceptedAnswerId="21980" CreationDate="2019-11-20T10:20:52.130" Score="0" ViewCount="77" Body="&lt;p&gt;When I press &lt;code&gt;0&lt;/code&gt; in Normal mode, the cursor goes to the second column and not the first one.&#xA;This is not the normal behavior stated in vim's &lt;code&gt;:help 0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried disabling the remaps to move between wrapped lines from my config (below) and the behavior is the same.&#xA;Is there any way to change this? Maybe a package it's interfering with the regular behavior but I cannot see which one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my .vimrc config file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set backspace=indent,eol,start &quot; backspace over everything in insert mode&#xA;set nocompatible               &quot; be improved, required&#xA;filetype off                   &quot; required&#xA;&#xA;&quot; vim-plug manager&#xA;&quot; Plugins will be downloaded under the specified directory.&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'lervag/vimtex'&#xA;let g:tex_flavor='latex'&#xA;let g:vimtex_view_method='zathura'&#xA;let g:vimtex_quickfix_mode=0&#xA;set conceallevel=1&#xA;let g:tex_conceal='abdmg'&#xA;&#xA;Plug 'sirver/ultisnips'&#xA;let g:UltiSnipsExpandTrigger = '&amp;lt;tab&amp;gt;'&#xA;let g:UltiSnipsJumpForwardTrigger = '&amp;lt;tab&amp;gt;'&#xA;let g:UltiSnipsJumpBackwardTrigger = '&amp;lt;s-tab&amp;gt;'&#xA;&#xA;Plug 'itchyny/lightline.vim'&#xA;&#xA;Plug 'sainnhe/gruvbox-material'&#xA;&#xA;Plug 'scrooloose/nerdcommenter'&#xA;&#xA;&quot; List ends here. Plugins become visible to Vim after this call.&#xA;call plug#end()&#xA;&#xA;&#xA;syntax enable&#xA;&quot;colorscheme monokai&#xA;set number&#xA;set ts=4&#xA;set expandtab&#xA;set autoindent&#xA;set wildmenu&#xA;set showmatch&#xA;set showmatch&#xA;set incsearch&#xA;set nohlsearch&#xA;set linebreak&#xA;set ttimeoutlen=0&#xA;set laststatus=2&#xA;set noshowmode&#xA;&quot; Lets you edit another file without saving the current&#xA;set hidden&#xA;&#xA;&quot; GUI enhancements&#xA;&quot; Set nice colors for 256 terminal&#xA;if !has('gui_running')&#xA;  set t_Co=256&#xA;endif&#xA;&quot; Set the airline colorscheme&#xA;let g:lightline = {'colorscheme' : 'gruvbox_material'}&#xA;&quot; Set colorscheme&#xA;set termguicolors&#xA;set background=dark&#xA;let g:gruvbox_material_background = 'medium'&#xA;colorscheme gruvbox-material&#xA;&#xA;&quot; REMAPS&#xA;&quot; Inserting a real Tab when pressing Shift + Tab&#xA;:inoremap &amp;lt;S-Tab&amp;gt; &amp;lt;C-V&amp;gt;Tab&amp;gt;&#xA;&quot; Move between wrapped lines&#xA;noremap &amp;lt;silent&amp;gt; k gk&#xA;noremap &amp;lt;silent&amp;gt; j gj&#xA;noremap &amp;lt;silent&amp;gt; 0 g0 &#xA;noremap &amp;lt;silent&amp;gt; $ g$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25750" LastActivityDate="2019-11-20T11:02:18.313" Title="Vim command 0 goes to second column instead of first one" Tags="|vimrc|cursor-movement|normal-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21980" PostTypeId="2" ParentId="21978" CreationDate="2019-11-20T11:02:18.313" Score="5" Body="&lt;p&gt;Result of &lt;code&gt;map 0&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  0           * g0&amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a space after &lt;code&gt;g0&lt;/code&gt;, remove it should solve your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put this to your vimrc to show trailing space, tab and other stuffs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;scriptencoding utf-8&#xA;set list listchars=trail:┄,tab:†·,extends:&amp;gt;,precedes:&amp;lt;,nbsp:+&#xA;scriptencoding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-11-20T11:02:18.313" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21981" PostTypeId="1" CreationDate="2019-11-20T12:12:49.907" Score="0" ViewCount="1588" Body="&lt;p&gt;I can't set neovim colors to follow terminal colors in &lt;code&gt;st&lt;/code&gt; terminal.&#xA;Here is a screenshot from the terminal:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/DVapp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DVapp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried different configurations of &lt;code&gt;set t_Co=256&lt;/code&gt; and &lt;code&gt;set termguicolors&lt;/code&gt; but all of them give different color schemes such as:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/RM299.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RM299.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/b6BqC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/b6BqC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is interesting is the fact that colors from terminal theme work by default in vim but do not work in neovim.&lt;/p&gt;&#xA;" OwnerUserId="2993" LastEditorUserId="1238" LastEditDate="2019-12-21T05:48:28.640" LastActivityDate="2019-12-21T05:48:28.640" Title="Can't set neovim colors to follow terminal colors in st terminal" Tags="|neovim|colorscheme|st|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21982" PostTypeId="2" ParentId="16260" CreationDate="2019-11-20T14:05:03.913" Score="0" Body="&lt;p&gt;My setup, for someone who may want to improve NERDTree behavior.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType nerdtree let t:nerdtree_winnr = bufwinnr('%')&#xA;autocmd BufWinEnter * call PreventBuffersInNERDTree()&#xA;&#xA;function! PreventBuffersInNERDTree()&#xA;  if bufname('#') =~ 'NERD_tree' &amp;amp;&amp;amp; bufname('%') !~ 'NERD_tree'&#xA;    \ &amp;amp;&amp;amp; exists('t:nerdtree_winnr') &amp;amp;&amp;amp; bufwinnr('%') == t:nerdtree_winnr&#xA;    \ &amp;amp;&amp;amp; &amp;amp;buftype == '' &amp;amp;&amp;amp; !exists('g:launching_fzf')&#xA;    let bufnum = bufnr('%')&#xA;    close&#xA;    exe 'b ' . bufnum&#xA;    call ToggleNerdTree()&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;close&quot; will close origin nerdtree pane, and ToggleNerdTree() will reopen it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function NotNerdTreePane()&#xA;  return bufname('%') !~# 'NERD_tree_' &amp;amp;&amp;amp; winnr(&quot;$&quot;) &amp;gt; 1 &amp;amp;&amp;amp; strlen(expand('%')) &amp;gt; 0 &amp;amp;&amp;amp; &amp;amp;modifiable &amp;amp;&amp;amp; exists(&quot;g:NERDTree&quot;)&#xA;endfunction&#xA;&#xA;function ToggleNerdTree()&#xA;  if g:NERDTree.IsOpen() &#xA;    :NERDTreeClose&#xA;  else &#xA;    :NERDTreeFind&#xA;  endif&#xA;endfunction&#xA;&#xA;autocmd BufEnter *  if (NotNerdTreePane() &amp;amp;&amp;amp; g:NERDTree.IsOpen()) | NERDTreeFind | wincmd p | endif&#xA;autocmd SessionLoadPost * if (NotNerdTreePane() &amp;amp;&amp;amp; !g:NERDTree.IsOpen()) | NERDTreeFind | wincmd p | endif &#xA;autocmd VimLeave * NERDTreeClose&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NotNerdTreePane() will check current pane and when you enter a buf, it will help to find current file to show in nerdtree.&lt;/p&gt;&#xA;" OwnerUserId="25754" LastEditorUserId="25754" LastEditDate="2019-11-21T02:05:32.707" LastActivityDate="2019-11-21T02:05:32.707" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21983" PostTypeId="2" ParentId="21958" CreationDate="2019-11-20T14:17:22.507" Score="1" Body="&lt;p&gt;I don't think it is possible to do what you are asking for because it means mixing to opposite concepts: CtrlP is a fuzzy finder and usually people use it to find files without having to worry about navigating in a netrw like view.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe you could have a look at &lt;a href=&quot;https://github.com/kien/ctrlp.vim/blob/6e4fb3b45faf96a7fb500d2920cfeeab24aa39fb/doc/ctrlp.txt#L1091-L1101&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :CtrlPDir&lt;/code&gt;&lt;/a&gt; which could help you searching files only in a specific directory.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-11-20T14:17:22.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21984" PostTypeId="1" CreationDate="2019-11-20T15:00:29.663" Score="6" ViewCount="177" Body="&lt;p&gt;At the moment, if I use Visual mode, whenever I select a block of text using the keyboard it ends up on my X primary selection (ie the clipboard that is filled using the mouse). Even if I just select the text then hit escape it still ends up there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want this, as I can just as well use &lt;code&gt;&quot;*y&lt;/code&gt; when I want this in my primary selection. However, selecting text with the mouse is still a useful X idiom that I want to work. Is it possible to make visual mode put this text on the clipboard but ONLY when the mouse is used to select it?&lt;/p&gt;&#xA;" OwnerUserId="25756" LastEditorUserId="1841" LastEditDate="2019-11-20T16:02:18.813" LastActivityDate="2019-11-20T16:02:18.813" Title="How to copy text to X primary selection only when visual mode is started with the mouse?" Tags="|cut-copy-paste|visual-mode|os-clipboard|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21985" PostTypeId="1" CreationDate="2019-11-20T16:16:45.953" Score="1" ViewCount="182" Body="&lt;p&gt;I use &lt;code&gt;:h&lt;/code&gt; command to open a help buffer. When I switch to other buffers, I can't go back to the opened help buffer. How can I show the name of a help buffer in the tabline of the airline?&lt;/p&gt;&#xA;" OwnerUserId="25759" LastEditorUserId="1841" LastEditDate="2019-11-20T17:11:48.497" LastActivityDate="2021-01-14T01:03:15.477" Title="How to show the name of a help buffer in the tabline of the airline?" Tags="|help-system|plugin-airline|hidden-buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21986" PostTypeId="2" ParentId="21941" CreationDate="2019-11-20T17:33:03.843" Score="1" Body="&lt;p&gt;Expanding on pdoherty926's suggestion of using &lt;a href=&quot;https://github.com/jpalardy/vim-slime&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-slime&lt;/a&gt;. I use the following functions in my vimrc combined with vim-slime to map the F7 key to send the current line to the python shell window, and F8 to send the current selection buffer (i.e. the previously yanked/copied lines)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F7&amp;gt; :call &amp;lt;SID&amp;gt;slime_runline()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;F8&amp;gt; :call &amp;lt;SID&amp;gt;slime_runselection()&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; send the line beneath the vim cursor to the tmux window&#xA;&quot; bound to F7 key&#xA;function! s:slime_runline()&#xA;   if getline('.') =~ &quot;^\s*$&quot;&#xA;      call cursor(getpos('.')[1]+1, col('.'))&#xA;      return&#xA;   endif&#xA;   let cmd = &quot;SlimeSend1 &quot;.getline('.')&#xA;   if matchstr(cmd, ':') != ''&#xA;      let cmd = cmd.&quot;\n&quot;&#xA;   endif&#xA;   exec cmd &#xA;   call cursor(getpos('.')[1]+1, col('.'))&#xA;endfunction&#xA;&#xA;&quot; send yanked lines to the tmux window&#xA;&quot; bound to F8 key&#xA;&quot; note that the operation works on the vim selection buffer,&#xA;&quot; regardless of whether or not yank was the last action&#xA;function! s:slime_runselection()&#xA;   if mode() ==&quot;v&quot;&#xA;      return&#xA;   endif&#xA;   let start = getpos(&quot;'&amp;lt;&quot;)[1]&#xA;   let end = getpos(&quot;'&amp;gt;&quot;)[1]&#xA;   let cmd = start.&quot;,&quot;.end.&quot;SlimeSend&quot;&#xA;   echo cmd &#xA;   exec cmd &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For simple configuration with tmux, i also include the following in my vimrc to send lines to the bottom tmux pane&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:slime_default_config = {&quot;socket_name&quot;: &quot;default&quot;, &quot;target_pane&quot;: &quot;{bottom-left}&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15664" LastActivityDate="2019-11-20T17:33:03.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21987" PostTypeId="1" AcceptedAnswerId="22035" CreationDate="2019-11-20T18:12:17.140" Score="1" ViewCount="252" Body="&lt;p&gt;When I open Vim for the first time and go to search using &lt;code&gt;ctrl+p&lt;/code&gt; &lt;strong&gt;fzf&lt;/strong&gt; then start typing my search it gets prepended with the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12;4$y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means if I have typed &lt;code&gt;searching&lt;/code&gt; it will become &lt;code&gt;12;4$ysearching&lt;/code&gt;.  This only happens when I first open Vim and hit the key sequence to start the &lt;strong&gt;fzf&lt;/strong&gt; finder before Vim has fully loaded.  I'm wanting to track down where in the startup process this is happening. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I track this oddity down?  &lt;a href=&quot;https://github.com/shadoath/dot_files/blob/master/.vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;My .vimrc dot_files&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8493" LastActivityDate="2019-11-25T17:17:35.587" Title="Tracking down odd behavior right after opening Vim and using fuzzy finder" Tags="|plugin-fzf|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="21988" PostTypeId="2" ParentId="15444" CreationDate="2019-11-20T21:26:31.110" Score="1" Body="&lt;pre&gt;&lt;code&gt;set fo-=or&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These options remove adding the comment leader automatically when pressing &lt;code&gt;o&lt;/code&gt; or &lt;code&gt;O&lt;/code&gt; in Normal mode, and when pressing  in Insert mode respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;see fo-table in vim help&#xA;&lt;code&gt;:h fo-table&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="25766" LastEditorUserId="10604" LastEditDate="2019-11-20T22:03:15.367" LastActivityDate="2019-11-20T22:03:15.367" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21989" PostTypeId="1" AcceptedAnswerId="21990" CreationDate="2019-11-21T00:38:29.940" Score="5" ViewCount="298" Body="&lt;p&gt;Lets say I have text &lt;code&gt;This is result file output_20DeC&lt;/code&gt;. Let's say my cursor is on &lt;code&gt;o&lt;/code&gt;. When I use the command &lt;code&gt;gf&lt;/code&gt;, it should open &lt;code&gt;output_20Dec.txt&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how do I tell vim to add a default extension to the word under my cursor before opening file?&lt;/p&gt;&#xA;" OwnerUserId="25002" LastEditorUserId="1238" LastEditDate="2019-11-28T08:36:53.740" LastActivityDate="2019-11-28T08:36:53.740" Title="tell vim to add default extention to word under my cursor before opening file" Tags="|vimscript|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21990" PostTypeId="2" ParentId="21989" CreationDate="2019-11-21T01:42:01.260" Score="6" Body="&lt;p&gt;To quote the help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *gf* *E446* *E447*&#xA;[count]gf       Edit the file whose name is under or after the cursor.&#xA;            Mnemonic: &quot;goto file&quot;.&#xA;            Uses the 'isfname' option to find out which characters&#xA;            are supposed to be in a file name.  Trailing&#xA;            punctuation characters &quot;.,:;!&quot; are ignored. Escaped&#xA;            spaces &quot;\ &quot; are reduced to a single space.&#xA;            Uses the 'path' option as a list of directory names to&#xA;            look for the file.  See the 'path' option for details&#xA;            about relative directories and wildcards.&#xA;            Uses the 'suffixesadd' option to check for file names&#xA;            with a suffix added.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key there is the section on &lt;code&gt;'suffixesadd'&lt;/code&gt;; setting to include &lt;code&gt;.txt&lt;/code&gt; should do the trick.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-21T01:42:01.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21991" PostTypeId="1" AcceptedAnswerId="21992" CreationDate="2019-11-21T05:06:41.117" Score="2" ViewCount="400" Body="&lt;p&gt;In insert mode, I want to call some function if &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; was typed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;InsertCharPre&lt;/code&gt; but it did not work.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="10604" LastEditDate="2019-11-21T13:36:34.447" LastActivityDate="2019-11-21T13:36:34.447" Title="Call a function after inserting a newline" Tags="|autocmd|insert-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21992" PostTypeId="2" ParentId="21991" CreationDate="2019-11-21T05:43:06.747" Score="4" Body="&lt;p&gt;The &lt;code&gt;InsertCharPre&lt;/code&gt; event doesn't trigger for characters such as &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, use an insert-mode mapping to call a function after pressing &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;&amp;lt;C-O&amp;gt;:call MyFunc()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or use a &lt;code&gt;map-&amp;lt;expr&amp;gt;&lt;/code&gt; and have your function return the string to be inserted. Start that with &lt;code&gt;&quot;\r&quot;&lt;/code&gt; if you'd like to preserve the newline that would be inserted.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; MyFunc()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :inoremap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help i_CTRL-O&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :map-&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-11-21T05:43:06.747" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21993" PostTypeId="1" CreationDate="2019-11-21T09:45:29.780" Score="2" ViewCount="790" Body="&lt;p&gt;I would like to have a file that contains all files that I opened with vim in the past. I know that there is the viminfo file but I want to have just a file with the filenames.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this I would like to write the list of open buffers with &lt;code&gt;autocmd VimLeave&lt;/code&gt; to a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;:ls | w &amp;gt;&amp;gt; test.txt&lt;/code&gt; but this does not work correctly.&lt;/p&gt;&#xA;" OwnerUserId="16973" LastEditorUserId="1841" LastEditDate="2019-11-21T10:26:37.550" LastActivityDate="2022-01-23T22:12:03.833" Title="Write buffer list to file" Tags="|vimscript|buffers|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="21994" PostTypeId="1" AcceptedAnswerId="22188" CreationDate="2019-11-21T10:03:04.647" Score="1" ViewCount="588" Body="&lt;p&gt;This is what I have in my &lt;code&gt;/usr/share/vim/vim80/filetype.vim&lt;/code&gt; (the only mention of &lt;code&gt;messages&lt;/code&gt; in the file) :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Messages (logs mostly)&#xA;au BufNewFile,BufRead */logs/couchdb/{,.log}{,.[0-9]*,-[0-9]*} setf couch_log&#xA;au BufNewFile,BufRead */log/{auth,cron,daemon,debug,kern,lpr,mail,messages,news/news,syslog,user}{,.log,.err,.info,.warn,.crit,.notice}{,.[0-9]*,-[0-9]*} setf messages&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following file exists : &lt;code&gt;/usr/share/vim/vim80/syntax/couch_log.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open &lt;code&gt;~/logs/couchdb/test.log&lt;/code&gt;, I am getting a &lt;code&gt;filetype=messages&lt;/code&gt; instead of the expected &lt;code&gt;filetype=couch_log&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing ?&lt;/p&gt;&#xA;" OwnerUserId="25787" OwnerDisplayName="Chapo" LastEditorUserId="9333" LastEditDate="2019-11-22T08:11:55.747" LastActivityDate="2019-12-06T08:59:37.583" Title="vim highlighting doesn't set the right type for a new filetype" Tags="|linux|syntax-highlighting|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="21995" PostTypeId="2" ParentId="21993" CreationDate="2019-11-21T10:19:16.917" Score="1" Body="&lt;p&gt;Try using &lt;code&gt;redir&lt;/code&gt; command (&lt;code&gt;:h redir&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! MyRedir() abort&#xA;    redir! &amp;gt; ~/test.txt&#xA;    :ls&#xA;    redir END&#xA;endfunc&#xA;&#xA;augroup save_files | au!&#xA;    au VimLeave * call MyRedir()&#xA;augroup end&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-11-21T10:31:17.063" LastActivityDate="2019-11-21T10:31:17.063" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21996" PostTypeId="2" ParentId="2410" CreationDate="2019-11-21T10:23:10.117" Score="19" Body="&lt;p&gt;Since &lt;a href=&quot;https://github.com/vim/vim/commit/42ae78cfff171fbd7412306083fe200245d7a7a6&quot; rel=&quot;noreferrer&quot;&gt;Vim 8.1.1310&lt;/a&gt; Vim also supports real optional function arguments.&lt;/p&gt;&#xA;&lt;p&gt;However, that means that most vim installation don't support this yet. Neovim has that feature since version 0.7.0.&lt;/p&gt;&#xA;&lt;p&gt;Example from &lt;a href=&quot;https://vimhelp.org/eval.txt.html#optional-function-argument&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help optional-function-argument&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  function Something(key, value = 10)&#xA;     echo a:key .. &amp;quot;: &amp;quot; .. a:value&#xA;  endfunction&#xA;  call Something('empty')   &amp;quot;empfty: 10&amp;quot;&#xA;  call Something('key', 20) &amp;quot;key: 20&amp;quot;   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21417" LastEditorUserId="21417" LastEditDate="2022-04-29T08:43:21.513" LastActivityDate="2022-04-29T08:43:21.513" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21997" PostTypeId="1" AcceptedAnswerId="21999" CreationDate="2019-11-21T10:42:43.147" Score="3" ViewCount="603" Body="&lt;p&gt;Right now, when I split a file in VIM, I need to use &lt;code&gt;CTRL-W + h/j/k/l&lt;/code&gt; to switch between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In spacevim (&lt;a href=&quot;https://spacevim.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://spacevim.org/&lt;/a&gt;), each file has a number visible in the bar (see picture), and I can just press &lt;code&gt;SPACE + &amp;lt;number&amp;gt;&lt;/code&gt; in command mode to go to that file. I find that way more convenient than the default &lt;code&gt;CTRL-W&lt;/code&gt; option. However, I don't want to install spacevim just for this, because it do a lot of other config that I don't like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aEjVh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aEjVh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how could I configure my vimrc to do the same?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank in advance for your help.&lt;/p&gt;&#xA;" OwnerUserId="25774" LastEditorUserId="23502" LastEditDate="2022-10-24T06:13:54.583" LastActivityDate="2022-10-24T06:13:54.583" Title="Switch between splitted file with SPACE + NUMBER instead of CTRL-W (like in spacevim)" Tags="|split|spacevim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21998" PostTypeId="2" ParentId="21993" CreationDate="2019-11-21T10:58:31.660" Score="2" Body="&lt;p&gt;You can have all buffer names that haven't been unloaded (or wiped out?) with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let files = filter(map(range(1,bufnr('$')), 'bufname(v:val)'), '!empty(v:val)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can save it with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call writefile(files, '/path/to/filename.txt')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2019-11-21T10:58:31.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21999" PostTypeId="2" ParentId="21997" CreationDate="2019-11-21T11:03:01.947" Score="5" Body="&lt;p&gt;To see window numbers you have to setup statusline (&lt;code&gt;:h statusline&lt;/code&gt;), for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=[%{winnr()}] &#xA;set statusline+=%([\%R%M]\ %)&#xA;set statusline+=%&amp;lt;%f&#xA;set statusline+=%(\ %y%)&#xA;set statusline+=%=&#xA;set statusline+=%4(%p%%%)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;winnr()&lt;/code&gt; function in the first line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To switch to the window with that number you can use built-in &lt;code&gt;2&lt;/code&gt; &lt;code&gt;C-ww&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;space&amp;gt;1 1&amp;lt;C-w&amp;gt;w&#xA;nnoremap &amp;lt;space&amp;gt;2 2&amp;lt;C-w&amp;gt;w&#xA;nnoremap &amp;lt;space&amp;gt;3 3&amp;lt;C-w&amp;gt;w&#xA;nnoremap &amp;lt;space&amp;gt;4 4&amp;lt;C-w&amp;gt;w&#xA;nnoremap &amp;lt;space&amp;gt;5 5&amp;lt;C-w&amp;gt;w&#xA;nnoremap &amp;lt;space&amp;gt;6 6&amp;lt;C-w&amp;gt;w&#xA;&quot;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Probably it could be done the other way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6Y9pY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6Y9pY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-11-21T11:12:59.653" LastActivityDate="2019-11-21T11:12:59.653" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22000" PostTypeId="1" AcceptedAnswerId="22001" CreationDate="2019-11-21T13:58:10.523" Score="3" ViewCount="300" Body="&lt;p&gt;I've used vim for ages and am really used to inserting four spaces by hitting tab, but then being deleting them one by one.  Now that I've switched to neovim this has changed to it inserting four spaces in one go but also deleting four in one go, which means I often delete far too much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my .vimrc file - some of it might be nonsense, it's &quot;evolved&quot; over the years, but thought I should show it in full here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; be iMproved, required&#xA;&#xA;source ~/.vim/plugins.vim&#xA;&#xA;execute pathogen#infect()&#xA;&#xA;syntax enable    &#xA;&#xA;&#xA;&quot;automatically source .vimrc whenever saved (instead of typing :so %)&#xA;augroup autocommands&#xA;    autocmd!&#xA;    autocmd BufWritePost .vimrc source %&#xA;augroup END&#xA;&#xA;&quot;--------------------------Mappings------------------------------&quot;&#xA;&#xA;&quot;quick route to editing vimrc file&#xA;nmap ,ev :tabedit $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&quot;add simple highlight removal&#xA;nmap ,&amp;lt;space&amp;gt; :nohlsearch&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;F1&amp;gt; :NERDTreeToggle&amp;lt;cr&amp;gt;&#xA;nmap &amp;lt;F2&amp;gt; &amp;lt;C-w&amp;gt;&amp;lt;C-w&amp;gt;&#xA;&#xA;filetype plugin indent on&#xA;set tabstop=4                       &quot; show existing tab with 4 spaces width&#xA;set shiftwidth=4                    &quot; when indenting with '&amp;gt;', use 4 spaces width&#xA;set expandtab                       &quot; On pressing tab, insert 4 spaces&#xA;&#xA;set nowrap                          &quot; no wrap&#xA;set number                          &quot; gutter numbers&#xA;&#xA;if has('mouse')&#xA;    set mouse=a                     &quot; mouse works&#xA;endif&#xA;&#xA;set backspace=start,indent,eol      &quot; set standard backspace behaviour&#xA;&#xA;set t_Co=256                        &quot; colourscheme stuff&#xA;colorscheme molokai                 &quot; colourscheme&#xA;highlight LineNr ctermfg=239        &quot; make gutter numbers more subtle&#xA;highlight LineNr ctermbg=233        &quot; make gutter numbers more subtle&#xA;&#xA;highlight ExtraWhitespace ctermbg=red guibg=red&#xA;match ExtraWhitespace /\s\+$/&#xA;&#xA;let php_sync_method = 0             &quot; this makes sure that the syntax highlighting always works&#xA;&#xA;&#xA;&quot; autocmd CursorMovedI * if pumvisible() == 0|pclose|endif&#xA;&quot; autocmd InsertLeave * if pumvisible() == 0|pclose|endif&#xA;&quot;&quot;&quot; autocmd FileType php set omnifunc=phpcomplete#CompletePHP&#xA;&quot;&quot; set completeopt=longest,menuone&#xA;&#xA;&quot; The encoding displayed.&#xA;set encoding=utf-8&#xA;&quot; The encoding written to file.&#xA;set fileencoding=utf-8&#xA;&#xA;&#xA;let g:netrw_banner = 0&#xA;let g:netrw_liststyle = 3&#xA;let g:netrw_browse_split = 4&#xA;let g:netrw_altv = 1&#xA;let g:netrw_winsize = 15&#xA;&#xA;autocmd bufenter * if (winnr(&quot;$&quot;) == 1 &amp;amp;&amp;amp; exists(&quot;b:NERDTree&quot;) &amp;amp;&amp;amp; b:NERDTree.isTabTree()) | q | endif&#xA;let g:NERDTreeDirArrowExpandable = '&amp;gt;'&#xA;let g:NERDTreeDirArrowCollapsible = 'V'&#xA;&#xA;if has('nvim')&#xA;    &quot; disable the auto-search - I prefer to finish typing and hit enter&#xA;    set nois&#xA;    &quot; disable the fact that you can delete 4 spaces in one go&#xA;    set softtabstop=0&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought from googling that adding that penultimate line &lt;code&gt;set softtabstop=0&lt;/code&gt; would make the difference, but it doesn't seem to.&lt;/p&gt;&#xA;" OwnerUserId="25778" LastActivityDate="2019-11-21T15:51:40.200" Title="Moved from vim to neovim and now &lt;BS&gt; deletes 4 spaces at a time, instead of 1 as I'm used to. How to fix?" Tags="|neovim|whitespace|softtabstop|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22001" PostTypeId="2" ParentId="22000" CreationDate="2019-11-21T15:01:21.713" Score="7" Body="&lt;p&gt;Neovim sets &lt;a href=&quot;https://neovim.io/doc/user/options.html#%27smarttab%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;smarttab&lt;/code&gt;&lt;/a&gt; by &lt;a href=&quot;https://neovim.io/doc/user/vim_diff.html#nvim-defaults&quot; rel=&quot;noreferrer&quot;&gt;default&lt;/a&gt;, which will cause this behaviour. Try turning it off:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set nosmarttab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-11-21T15:51:40.200" LastActivityDate="2019-11-21T15:51:40.200" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22002" PostTypeId="2" ParentId="21928" CreationDate="2019-11-21T22:41:59.430" Score="1" Body="&lt;p&gt;As far as I know, this isn’t possible. However, I found this neat mini-plugin in &lt;a href=&quot;https://github.com/paulirish/dotfiles/blob/master/.vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;Paul Irish’s vimrc&lt;/a&gt; which does something close to what you’re looking for. As it stands, it highlights occurrences of the current word but I’m sure it could be updated to highlight a given string. Just add it to your vimrc and hit 1-6 to highlight the word under cursor in various colors. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &quot; This mini-plugin provides a few mappings for highlighting words temporarily.&#xA;  &quot;&#xA;  &quot; Sometimes you're looking at a hairy piece of code and would like a certain&#xA;  &quot; word or two to stand out temporarily.  You can search for it, but that only&#xA;  &quot; gives you one color of highlighting.  Now you can use &amp;lt;leader&amp;gt;N where N is&#xA;  &quot; a number from 1-6 to highlight the current word in a specific color.&#xA;&#xA;  &quot; credit: https://github.com/paulirish/dotfiles/blob/master/.vimrc&#xA;&#xA;  function! HiInterestingWord(n) &quot; {{{&#xA;    &quot; Save our location.&#xA;    normal! mz&#xA;&#xA;    &quot; Yank the current word into the z register.&#xA;    normal! &quot;zyiw&#xA;&#xA;    &quot; Calculate an arbitrary match ID.  Hopefully nothing else is using it.&#xA;    let mid = 86750 + a:n&#xA;&#xA;    &quot; Clear existing matches, but don't worry if they don't exist.&#xA;    silent! call matchdelete(mid)&#xA;&#xA;    &quot; Construct a literal pattern that has to match at boundaries.&#xA;    let pat = '\V\&amp;lt;' . escape(@z, '\') . '\&amp;gt;'&#xA;&#xA;    &quot; Actually match the words.&#xA;    call matchadd(&quot;InterestingWord&quot; . a:n, pat, 1, mid)&#xA;&#xA;    &quot; Move back to our original location.&#xA;    normal! `z&#xA;  endfunction &quot; }}}&#xA;&#xA;  &quot; Mappings {{{&#xA;  nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;1 :call HiInterestingWord(1)&amp;lt;cr&amp;gt;&#xA;  nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;2 :call HiInterestingWord(2)&amp;lt;cr&amp;gt;&#xA;  nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;3 :call HiInterestingWord(3)&amp;lt;cr&amp;gt;&#xA;  nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;4 :call HiInterestingWord(4)&amp;lt;cr&amp;gt;&#xA;  nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;5 :call HiInterestingWord(5)&amp;lt;cr&amp;gt;&#xA;  nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;6 :call HiInterestingWord(6)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20329" LastEditorUserId="20329" LastEditDate="2019-11-22T04:06:11.073" LastActivityDate="2019-11-22T04:06:11.073" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22003" PostTypeId="1" AcceptedAnswerId="22005" CreationDate="2019-11-21T23:00:07.453" Score="1" ViewCount="681" Body="&lt;p&gt;Say that I have pattern &lt;code&gt;aaaaapple&lt;/code&gt; in my text file, and say that I configured vim so that it conceals &lt;code&gt;a\+&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What will happen is that, if &lt;code&gt;conceallevel=1&lt;/code&gt;, then &lt;code&gt;aaaaapple&lt;/code&gt; will become &lt;code&gt;_pple&lt;/code&gt;. Note that &lt;code&gt;aaaaa&lt;/code&gt; is replaced by a single space &lt;code&gt;_&lt;/code&gt; (I'm writing spaces as &lt;code&gt;_&lt;/code&gt; due to technical difficulties).  This causes the line to jiggle/dance every time I hover on the concealed word, due to the single space &lt;code&gt;_&lt;/code&gt; expanding into 5 characters &lt;code&gt;aaaaa&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want is to conceal &lt;code&gt;aaaaapple&lt;/code&gt; such that it becomes &lt;code&gt;_____pple&lt;/code&gt; instead of &lt;code&gt;_pple&lt;/code&gt;.  This way, when I move to the line where this conceal happened, the text won't jiggle/dance by expanding/shrinking.  I.e. it looks like &lt;code&gt;_____pple&lt;/code&gt; before hovering on it, and &lt;code&gt;aaaaapple&lt;/code&gt; after hovering on it.  No jiggling!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how to do this conceal such that &lt;em&gt;each&lt;/em&gt; concealed character is replaced by a space (and not replacing &lt;em&gt;all&lt;/em&gt; concealed characters by a single space)?&lt;/p&gt;&#xA;" OwnerUserId="14744" LastEditorUserId="14744" LastEditDate="2019-11-21T23:05:09.477" LastActivityDate="2019-11-21T23:15:19.487" Title="How to conceal multiple characters without making text dance upon hovering?" Tags="|conceal|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22004" PostTypeId="2" ParentId="22003" CreationDate="2019-11-21T23:09:51.650" Score="1" Body="&lt;p&gt;See &lt;code&gt;:h concealcursor&lt;/code&gt;. It controls which modes will be activated for conceal. In this case you want to disable it for normal mode. I recommend trying &lt;code&gt;setl concealcursor=vic&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16189" LastActivityDate="2019-11-21T23:09:51.650" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22005" PostTypeId="2" ParentId="22003" CreationDate="2019-11-21T23:15:19.487" Score="3" Body="&lt;p&gt;Instead of matching &lt;em&gt;all&lt;/em&gt; duplicate &quot;a&quot;s in a single match, try concealing &lt;em&gt;each&lt;/em&gt; extra &quot;a&quot; in its own, concealed group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match HideAa &quot;a\zea&quot; conceal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because this conceals only a single &quot;a&quot; with its own syntax group conceal, it will effectively apply a concealing space to each &quot;a&quot;.&lt;/p&gt;&#xA;" OwnerUserId="7549" LastActivityDate="2019-11-21T23:15:19.487" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22006" PostTypeId="2" ParentId="21786" CreationDate="2019-11-22T01:23:51.940" Score="2" Body="&lt;p&gt;I also have this problem. Unfortunately, I think the fault lies with Konsole.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open Konsole, I can click &lt;code&gt;Settings-&amp;gt; Edit Current Profile&lt;/code&gt; and it correctly edits my profile. Then I send the cursor change sequence (echo to the terminal, or from vim). If the font size has been changed, it will reset as described in the question. I then again go to &lt;code&gt;Settings-&amp;gt; Edit Current Profile&lt;/code&gt;, and now the profile name is empty, and there is a warning stating that it is empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect Konsole implements the cursor change command by making an adjustment to the current profile, and fails to consider any changes you have made since originally loading that profile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I were running a new version of Konsole, I would be inclined to file a bug report, but I'm rather out of date. So, my answer is to update your version and file a bug report if it still happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While this answer isn't terribly helpful to solve the problem, I think it may at least help with diagnosis.&lt;/p&gt;&#xA;" OwnerUserId="25785" LastActivityDate="2019-11-22T01:23:51.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22007" PostTypeId="2" ParentId="464" CreationDate="2019-11-22T02:44:25.407" Score="0" Body="&lt;p&gt;Old question, but since this comes up at the top in google search, I'll leave this here for future searches. As Bruno suggested, a fuzzy finder that supports buffer lists is the way to go. I personally use and recommend &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf-vim&lt;/a&gt;. It provides the command &lt;code&gt;:FZFBuffers&lt;/code&gt;, that looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bY2Gd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bY2Gd.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Buffer numbers are displayed to the left in case you need them, but with a fuzzy finder, you might never need to use them again. Just remember part of the file name, and it's usually 2-5 keystrokes away. Personally, I've mapped this command to a keystroke, and switching between buffers is almost instant for me!&lt;/p&gt;&#xA;" OwnerUserId="25789" LastEditorUserId="1841" LastEditDate="2019-11-22T08:41:48.467" LastActivityDate="2019-11-22T08:41:48.467" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22008" PostTypeId="1" CreationDate="2019-11-22T04:22:39.697" Score="0" ViewCount="207" Body="&lt;p&gt;I want to see trailing white space differences using internal diff. By default vim uses iwhilteeol. Is there a way to turn this option off?&lt;/p&gt;&#xA;" OwnerUserId="11022" LastActivityDate="2019-11-22T13:30:08.093" Title="vimdiff: disable option iwhiteeol in diffopt" Tags="|vimdiff|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22009" PostTypeId="2" ParentId="22008" CreationDate="2019-11-22T05:24:43.883" Score="2" Body="&lt;p&gt;My vim doesn't use &lt;code&gt;iwhiteeol&lt;/code&gt; by default:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *'dip'* *'diffopt'*&#xA;'diffopt' 'dip'     string  (default &quot;internal,filler&quot;)&#xA;            global&#xA;            {not available when compiled without the |+diff|&#xA;            feature}&#xA;    Option settings for diff mode.  It can consist of the following items.&#xA;    All are optional.  Items must be separated by a comma.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But to disable it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set diffopt-=iwhiteeol&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list listchars^=trail:.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to show trailing whitespace&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-11-22T13:30:08.093" LastActivityDate="2019-11-22T13:30:08.093" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22010" PostTypeId="2" ParentId="21994" CreationDate="2019-11-22T05:47:02.697" Score="1" Body="&lt;p&gt;Try the following minimal vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;syntax on&#xA;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For filetypes to be properly detected &lt;code&gt;filetype&lt;/code&gt; should be on (&lt;code&gt;:h filetype&lt;/code&gt;). By default it is off when vim is in &lt;code&gt;nocompatible&lt;/code&gt; mode which might be the case here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure what was in your vimrc before you have deleted it, but it looks like &lt;code&gt;filetype=messages&lt;/code&gt; was somehow set from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find that &lt;code&gt;couch_log.vim&lt;/code&gt; in my distribution, so I suspect this is external thing and you want to detect a filetype and apply it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the following in minimal vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;syntax on&#xA;filetype plugin indent on&#xA;&#xA;au BufNewFile,BufRead */logs/couchdb/{,.log}{,.[0-9]*,-[0-9]*} set ft=couch_log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE: there is difference in command compared to your initial one: &lt;code&gt;set ft=couch_log&lt;/code&gt; instead of &lt;code&gt;setf couch_log&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although proper way to do it is to follow what vim help states in &lt;code&gt;:h ftdetect&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *ftdetect*&#xA;   1. Create your user runtime directory.  You would normally use the first&#xA;      item of the 'runtimepath' option.  Then create the directory &quot;ftdetect&quot;&#xA;      inside it.  Example for Unix: &amp;gt;&#xA;    :!mkdir ~/.vim&#xA;    :!mkdir ~/.vim/ftdetect&#xA;&amp;lt;&#xA;   2. Create a file that contains an autocommand to detect the file type.&#xA;      Example: &amp;gt;&#xA;    au BufRead,BufNewFile *.mine        set filetype=mine&#xA;&amp;lt;     Note that there is no &quot;augroup&quot; command, this has already been done&#xA;      when sourcing your file.  You could also use the pattern &quot;*&quot; and then&#xA;      check the contents of the file to recognize it.&#xA;      Write this file as &quot;mine.vim&quot; in the &quot;ftdetect&quot; directory in your user&#xA;      runtime directory.  For example, for Unix: &amp;gt;&#xA;    :w ~/.vim/ftdetect/mine.vim&#xA;&#xA;&amp;lt;  3. To use the new filetype detection you must restart Vim.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-11-22T08:15:22.750" LastActivityDate="2019-11-22T08:15:22.750" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="22013" PostTypeId="1" AcceptedAnswerId="22030" CreationDate="2019-11-22T09:08:36.487" Score="2" ViewCount="252" Body="&lt;p&gt;Each time I want to save my work while editing a text file, I enter &lt;code&gt;:write&lt;/code&gt; to save the file, and &lt;code&gt;:edit&lt;/code&gt; to reload the file, with the side effect of resetting the undo/redo buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, an unwanted side effect of running &lt;code&gt;:edit&lt;/code&gt; is that the line under the cursor is recentered.  Can anyone tell me either (i) how to prevent &lt;code&gt;:edit&lt;/code&gt; from recentering the line, or (ii) if there's a different way of resetting the undo/redo buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="8599" LastActivityDate="2019-11-27T02:11:01.563" Title="How can I prevent Vim from centering the line under the cursor on `:edit`" Tags="|command-line|buffers|cursor-movement|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22014" PostTypeId="2" ParentId="2001" CreationDate="2019-11-22T10:18:02.647" Score="13" Body="&lt;p&gt;Saving a character on the accepted answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will take the cursor to the &lt;strong&gt;exact&lt;/strong&gt; point last edited and put you in insert mode, ready to continue typing. (It's also quicker to type!)&lt;/p&gt;&#xA;" OwnerUserId="22557" LastEditorUserId="22557" LastEditDate="2019-12-10T15:02:01.293" LastActivityDate="2019-12-10T15:02:01.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22015" PostTypeId="1" AcceptedAnswerId="22016" CreationDate="2019-11-22T11:20:05.173" Score="7" ViewCount="1204" Body="&lt;p&gt;I can catch the output of running a system command via &lt;code&gt;system()&lt;/code&gt; or &lt;code&gt;systemlist()&lt;/code&gt;, but that actually gives me the result of stdout and stderr combined. &#xA;As I am only interested in stdout (and may use stderr for other purposes), this isn't useful for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I separate the output of a system command between stdout and stderr?&lt;/p&gt;&#xA;" OwnerUserId="21417" LastEditorUserId="21417" LastEditDate="2020-01-29T11:23:07.903" LastActivityDate="2022-09-03T18:47:32.690" Title="separate stdout and stderr of system() command" Tags="|external-command|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22016" PostTypeId="2" ParentId="22015" CreationDate="2019-11-22T11:59:08.433" Score="8" Body="&lt;p&gt;Vim's &lt;code&gt;system()&lt;/code&gt; indeed captures both standard out and standard error by default. If you just want one of those, just use the normal shell means to redirect the other to the &lt;em&gt;null device&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, ignore stderr (&lt;code&gt;2&amp;gt;&lt;/code&gt;) with Bash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo system('grep root /etc/passwd /doesnotexist 2&amp;gt;/dev/null')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On Windows, you'd use &lt;code&gt;2&amp;gt;NUL&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could (temporarily) modify the &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27shellredir%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'shellredir'&lt;/code&gt;&lt;/a&gt; setting; e.g. by dropping the &lt;code&gt;2&amp;gt;&amp;amp;1&lt;/code&gt; from it to ignore stderr. (&lt;em&gt;Thanks @ChristianBrabandt for the tip!&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;separate stdout and stderr&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you need both (but separately), that's a bit tricky. You could:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;redirect one / both into a temp file and read that via &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#readfile%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;readfile()&lt;/code&gt;&lt;/a&gt;, or via another &lt;code&gt;system('cat /tmpfile')&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;invoke the command twice, ignoring first stdout and then stderr&lt;/li&gt;&#xA;&lt;li&gt;add prefixes (via &lt;code&gt;sed&lt;/code&gt;) to one / both (possible with fancy piping and redirections), read all in one fell swoop, and separate inside Vim&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2019-11-22T18:24:07.057" LastActivityDate="2019-11-22T18:24:07.057" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22017" PostTypeId="2" ParentId="21941" CreationDate="2019-11-22T12:01:49.643" Score="1" Body="&lt;p&gt;I use the following mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Save current file and rerun previous command in previous tmux window.&#xA;map &amp;lt;leader&amp;gt;t :up&amp;lt;CR&amp;gt;:execute 'silent !tmux select-window -t :{last} &amp;amp;&amp;amp; tmux send-keys Up Enter'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes that you are currently editing a script and that you have executed it already once in another tmux window. I detailed this approach &lt;a href=&quot;http://the-efficient-programmer.com/shell/faster-command-execution.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6357" LastEditorUserId="6357" LastEditDate="2019-11-26T20:22:20.400" LastActivityDate="2019-11-26T20:22:20.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22018" PostTypeId="1" AcceptedAnswerId="22020" CreationDate="2019-11-22T14:33:24.227" Score="3" ViewCount="746" Body="&lt;p&gt;In Insert mode, I want a mapping which will return to Normal mode, then call a plugin function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;a-1&amp;gt; &amp;lt;ESC&amp;gt;&amp;lt;Plug&amp;gt;AirlineSelectTab1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It exits Insert mode, but doesn't then call the plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, this works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-l&amp;gt; &amp;lt;ESC&amp;gt;&amp;lt;c-w&amp;gt;l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why can I do one but not the other?&lt;/p&gt;&#xA;" OwnerUserId="2026" LastEditorUserId="1238" LastEditDate="2019-12-12T13:16:29.257" LastActivityDate="2019-12-12T13:16:29.257" Title="Insert mode mapping to leave insert mode then invoke a plugin function" Tags="|key-bindings|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22019" PostTypeId="1" AcceptedAnswerId="22023" CreationDate="2019-11-22T14:42:20.843" Score="2" ViewCount="498" Body="&lt;p&gt;I have an &quot;optional&quot; plugin that depends on python (&lt;code&gt;pack/habamax/opt/myplugin&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in my settings I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('python') || has('python3')&#xA;    do some setup&#xA;    packadd myplugin&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This thing fails if there is no myplugin though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can add to an if statement to check if myplugin exists? &lt;code&gt;if packexists('myplugin')&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can probably have a &lt;code&gt;try catch&lt;/code&gt; to suppress errors but the thing is that there might be &lt;code&gt;elseif&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; if there is package myplugin and all dependencies&#xA;if has('python') || has('python3')&#xA;    do some setup&#xA;    packadd myplugin&#xA;else&#xA;&quot;use another plugin without dependencies&#xA;    do some setup&#xA;    packadd anotherplugin&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;@Matt,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pHYw1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pHYw1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I end up using &lt;code&gt;silent! packadd ...&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; try to load myplugin first&#xA;if has('python') || has('python3')&#xA;    do some setup&#xA;    silent! packadd myplugin&#xA;endif&#xA;&#xA;&quot;use another plugin without dependencies&#xA;if !exists(&quot;g:myplugin_loaded&quot;)&#xA;    do some setup&#xA;    packadd anotherplugin&#xA;endif&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-11-22T15:36:53.303" LastActivityDate="2019-11-22T17:04:02.497" Title="Guard packadd to not load an optional non-existent package" Tags="|vimscript|packages|" AnswerCount="3" CommentCount="19" ContentLicense="CC BY-SA 4.0" />
  <row Id="22020" PostTypeId="2" ParentId="22018" CreationDate="2019-11-22T14:48:34.587" Score="3" Body="&lt;p&gt;This happens because the &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; command is itself a mapping defined by a plug-in, so you need &lt;em&gt;recursive&lt;/em&gt; mappings in this case for it to work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;a-1&amp;gt; &amp;lt;ESC&amp;gt;&amp;lt;Plug&amp;gt;AirlineSelectTab1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The usual recommendation is to &lt;em&gt;always&lt;/em&gt; use the &lt;code&gt;nore&lt;/code&gt; (non-recursive) version of map commands, to prevent interference from mappings created by the user or by other plug-ins, but unfortunately that's not really possible with commands that use &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative, to minimize the number of keystrokes where you're considering recursive mappings (and can maybe help with &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; commands that are a whole prefix for another &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; command, surely a bad practice but you might find them) is to use &lt;code&gt;:normal&lt;/code&gt; (not &lt;code&gt;:normal!&lt;/code&gt;, which doesn't consider mappings) from your mapping expansion. That also requires using &lt;code&gt;:execute&lt;/code&gt; and marking the mapping as &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; so it doesn't prominently display the Ex command line during execution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;a-1&amp;gt; &amp;lt;ESC&amp;gt;:execute &quot;normal \&amp;lt;Plug&amp;gt;AirlineSelectTab1&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's probably not worth it for a simple case like this one, but might be relevant for more complex mappings that involve many keystrokes other than the call to the &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; command itself.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-11-22T15:31:36.887" LastActivityDate="2019-11-22T15:31:36.887" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22021" PostTypeId="2" ParentId="22019" CreationDate="2019-11-22T14:57:11.713" Score="2" Body="&lt;p&gt;You can use &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#exists%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h exists()&lt;/code&gt;&lt;/a&gt; to test if a variable, a command or a function provided by the plugin is defined. If it is defined then it means the plugin is available:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exists({expr})  The result is a Number, which is |TRUE| if {expr} is&#xA;        defined, zero otherwise.&#xA;&#xA;        The {expr} argument is a string, which contains one of these:&#xA;            &amp;amp;option-name    Vim option (only checks if it exists,&#xA;                    not if it really works)&#xA;            [...]&#xA;            *funcname   built-in function (see |functions|)&#xA;                    or user defined function (see&#xA;                    |user-functions|). Also works for a&#xA;                    variable that is a Funcref.&#xA;            [...]&#xA;            :cmdname    Ex command: built-in command, user&#xA;                    command or command modifier |:command|.&#xA;                    Returns:&#xA;                    1  for match with start of a command&#xA;                    2  full match with a command&#xA;                    3  matches several user commands&#xA;                    To check for a supported command&#xA;                    always check the return value to be 2.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the idea is to check for something defined by the plugin. For example if you want to test that GitGutter is installed you can check for the &lt;code&gt;g:loaded_gitgutter&lt;/code&gt; variable it defines like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (exists('g:loaded_gitgutter'))&#xA;    nnoremap &amp;lt;C-L&amp;gt; :nohlsearch\|GitGutter&amp;lt;CR&amp;gt;&amp;lt;C-L&amp;gt;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that most of the plugins should defined a variable of the form &lt;code&gt;g:loaded_pluginname&lt;/code&gt; as @Rich pointed out in the comments.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastEditorUserId="1841" LastEditDate="2019-11-22T15:14:38.017" LastActivityDate="2019-11-22T15:14:38.017" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="22022" PostTypeId="1" AcceptedAnswerId="22025" CreationDate="2019-11-22T15:06:39.697" Score="6" ViewCount="1613" Body="&lt;p&gt;Suddenly simple find&amp;amp;replace stopped working in one particular case. I'm selecting the code-block in visual-mode, so the final command looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;%s/someStuff/stuff/gI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Trailing characters&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's very strange behavior because the same commands worked very well earlier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/6714469/search-and-replace-in-vim-results-in-trailing-characters&quot;&gt;Search and replace in VIM results in trailing characters&lt;/a&gt; didn't help.&lt;/p&gt;&#xA;" OwnerUserId="25797" LastEditorUserId="1238" LastEditDate="2019-11-27T02:10:52.603" LastActivityDate="2019-11-27T02:10:52.603" Title="Trailing characters error in a substitution command" Tags="|visual-mode|replace|visual-block|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22023" PostTypeId="2" ParentId="22019" CreationDate="2019-11-22T15:06:51.800" Score="2" Body="&lt;p&gt;You could just&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! packadd &amp;lt;plugin&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-22T15:06:51.800" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22024" PostTypeId="2" ParentId="22013" CreationDate="2019-11-22T15:11:22.477" Score="1" Body="&lt;p&gt;I'll let @IngoKarkat write &lt;a href=&quot;https://vi.stackexchange.com/questions/22013/how-can-i-prevent-vim-from-centering-the-line-under-the-cursor-on-edit#comment39798_22013&quot;&gt;the answer that solves your real problem&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, for the benefit of future readers, you can also achieve what was originally requested by saving the view before executing &lt;code&gt;:edit&lt;/code&gt; and then restoring it afterwards:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let v = winsaveview()&#xA;:edit&#xA;:call winrestview(v)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-11-22T15:11:22.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22025" PostTypeId="2" ParentId="22022" CreationDate="2019-11-22T15:17:36.510" Score="8" Body="&lt;p&gt;You don't need &lt;code&gt;%&lt;/code&gt;, as you already have another range (&lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt;) for your command &lt;code&gt;s&lt;/code&gt;. So it must be simply &lt;code&gt;'&amp;lt;,'&amp;gt;s/SomeStuff/stuff/gI&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-22T15:17:36.510" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22026" PostTypeId="2" ParentId="22019" CreationDate="2019-11-22T15:51:18.623" Score="2" Body="&lt;p&gt;You can also use a &lt;code&gt;try&lt;/code&gt;/&lt;code&gt;catch&lt;/code&gt; block and a local variable to control whether you managed to load it successfully.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let has_myplugin = 0&#xA;&quot; if there is package myplugin and all dependencies&#xA;if has('python') || has('python3')&#xA;    do some setup&#xA;    try&#xA;        packadd myplugin&#xA;        let has_myplugin = 1&#xA;    catch /^Vim\%((\a\+)\)\=:E919:/&#xA;        &quot; Directory not found in packpath.&#xA;        &quot; Fallback to the ! has_myplugin case.&#xA;    endtry&#xA;endif&#xA;&#xA;if ! has_myplugin&#xA;    &quot; use another plugin without dependencies&#xA;    do some setup&#xA;    packadd anotherplugin&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also consider that you might want to use &lt;code&gt;packadd!&lt;/code&gt; if you're doing it from your &lt;code&gt;vimrc&lt;/code&gt; file. From &lt;code&gt;:help :packadd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the optional &lt;code&gt;!&lt;/code&gt; is added no plugin files or ftdetect scripts are loaded, only the matching  directories are added to &lt;code&gt;runtimepath&lt;/code&gt;.  This is    useful in your &lt;code&gt;.vimrc&lt;/code&gt;.  The plugins will then be loaded during initialization, see &lt;code&gt;load-plugins&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(See also: &lt;code&gt;:help :packloadall&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-11-22T17:04:02.497" LastActivityDate="2019-11-22T17:04:02.497" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22027" PostTypeId="1" CreationDate="2019-11-22T16:02:03.997" Score="0" ViewCount="65" Body="&lt;p&gt;New to vim, and learning python. After I run code I get debugging comments like you can see in this screenshot on the left (S&gt; and &gt;&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zOOH4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zOOH4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I move to a line marked S&gt; I can see below in my status bar a comment about an error or a suggestion regarding the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mentioning I'm using kite. Perhaps it's a kite feature? Or maybe something native to vim? I would like to know how to manually control it. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="25181" LastEditorUserId="25181" LastEditDate="2019-11-22T16:07:27.010" LastActivityDate="2020-08-18T20:06:40.760" Title="Can you recognise this debugging system? How can I switch it off?" Tags="|plugin-system|debugging|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22028" PostTypeId="2" ParentId="13518" CreationDate="2019-11-22T17:40:48.337" Score="1" Body="&lt;p&gt;Something like this may work: first, based on &lt;a href=&quot;https://vi.stackexchange.com/a/16047/25802&quot;&gt;this answer&lt;/a&gt;, you could create a separate location for all your swap files like this &lt;code&gt;set directory^=$HOME/.vim/swap//&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, using the answer from &lt;a href=&quot;https://vi.stackexchange.com/a/20621/25802&quot;&gt;here&lt;/a&gt;, place this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;LEADER&amp;gt;s &amp;lt;C-w&amp;gt;o:sav! ~/.vim/.recovered&amp;lt;CR&amp;gt;:vs&amp;lt;CR&amp;gt;&amp;lt;C-w&amp;gt;w:bn&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;LEADER&amp;gt;t  :wa&amp;lt;CR&amp;gt;:bp\|bd #&amp;lt;CR&amp;gt;&amp;lt;C-o&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into your vimrc, the way that I get to mine is by using the terminal I type &lt;code&gt;vim .vimrc&lt;/code&gt; which opens it and allows me to edit it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then follow this set of instructions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Upon reaching the ATTENTION: Found a swap file... prompt, I&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;type r to recover the swap&#xA;type &amp;lt;LEADER&amp;gt;s to save the swapped version as .recovered and open the original in a new split&#xA;type e at the swap prompt to edit the original file&#xA;type :windo diffthis to diff the two files&#xA;make any necessary changes to the original&#xA;type &amp;lt;LEADER&amp;gt;t to write the original file, close it, and reopen it&#xA;type d at the swap prompt to delete the swap file&#xA;close the .recovered file (typing something like :bp&amp;lt;CR&amp;gt;:bp\|bd #&amp;lt;CR&amp;gt;).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason that I placed the first step is because it seems as though it would be easier to delete all your .swp and .swo if they are in the same location. Hopefully this helps.&lt;/p&gt;&#xA;" OwnerUserId="25802" LastActivityDate="2019-11-22T17:40:48.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22029" PostTypeId="1" CreationDate="2019-11-22T18:11:46.987" Score="1" ViewCount="55" Body="&lt;p&gt;I have a .h and a .cpp with declarations and definitions, and I'd like to be able to &lt;code&gt;:tselect&lt;/code&gt; only the declarations, in order to see all the functions I've got that match a pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;some_file.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void add_x_to_y(int x, int y);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;some_file.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void add_x_t_y(int x, int y) { x + y; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to jump to the declaration, or at hide the definitions in &lt;code&gt;some_file.cpp&lt;/code&gt;. Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/20241/jumping-to-prototype-or-definition-of-a-function-using-tags&quot;&gt;Jumping to prototype or definition of a function using tags&lt;/a&gt; suggests using a tagfunc, but I'm hoping there's an alternative&lt;/p&gt;&#xA;" OwnerUserId="488" LastActivityDate="2019-11-22T18:11:46.987" Title="How to jump to or list a tag exclusively defined in a header?" Tags="|tags|ctags|filetype-c++|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22030" PostTypeId="2" ParentId="22013" CreationDate="2019-11-22T18:16:17.300" Score="3" Body="&lt;p&gt;As you're expressly using &lt;code&gt;:edit&lt;/code&gt; in order to reset the undo information, you could follow &lt;a href=&quot;https://vimhelp.appspot.com/undo.txt.html#clear-undo&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help clear-undo&lt;/code&gt;&lt;/a&gt; to do this without &lt;code&gt;:edit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would define a custom &lt;code&gt;:Write&lt;/code&gt; command that combines both:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar Write&#xA;\ write |&#xA;\ let old_undolevels = &amp;amp;undolevels |&#xA;\ set undolevels=-1 |&#xA;\ exe &quot;normal a \&amp;lt;BS&amp;gt;\&amp;lt;Esc&amp;gt;&quot; |&#xA;\ let &amp;amp;undolevels = old_undolevels |&#xA;\ unlet old_undolevels |&#xA;\ setlocal nomodified&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="1238" LastEditDate="2019-11-27T02:11:01.563" LastActivityDate="2019-11-27T02:11:01.563" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22031" PostTypeId="2" ParentId="22013" CreationDate="2019-11-22T18:21:29.063" Score="2" Body="&lt;p&gt;I guess your motivation of clearing the undo information on writes is to avoid going beyond the saved buffer state when undoing many steps (&lt;code&gt;uuuu...&lt;/code&gt;). I personally use a different approach: I've tweaked the &lt;code&gt;u&lt;/code&gt; command to stop and beep once when reaching the saved buffer state. I need to &lt;code&gt;u&lt;/code&gt; once more to go beyond.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My customization integrates with the &lt;em&gt;repeat.vim&lt;/em&gt; plugin; It also requires some utility functions from my &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=4433&quot; rel=&quot;nofollow noreferrer&quot;&gt;ingo-library plugin&lt;/a&gt; (it's now also available on &lt;a href=&quot;https://github.com/inkarkat/ingo-library&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime autoload/repeat.vim &quot; Must load the plugin now so that the plugin's mappings can be overridden.&#xA;let s:undoPosition = []&#xA;function! s:StopAtSavedPosition( action )&#xA;    &quot; Buffers of type &quot;nofile&quot; and &quot;nowrite&quot; never are 'modified', so only do&#xA;    &quot; the check for normal buffers representing files. (Otherwise, the warning&#xA;    &quot; annoyingly happens on every undo.)&#xA;    if ingo#buffer#IsPersisted() &amp;amp;&amp;amp; ! &amp;amp;l:modified &amp;amp;&amp;amp; s:undoPosition != ingo#record#PositionAndLocation(1)&#xA;        &quot; We've reached the undo position where the buffer contents correspond&#xA;        &quot; to the persisted file. Stop and beep, and only continue when undo is&#xA;        &quot; pressed again at the same position.&#xA;        call ingo#msg#WarningMsg(a:action . ' reached saved buffer state')&#xA;        execute &quot;normal! \&amp;lt;C-\&amp;gt;\&amp;lt;C-n&amp;gt;\&amp;lt;Esc&amp;gt;&quot; | &quot; Beep.&#xA;&#xA;        let s:undoPosition = ingo#record#PositionAndLocation(1)&#xA;        return 1&#xA;    else&#xA;        let s:undoPosition = []&#xA;        return 0&#xA;    endif&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; u     :&amp;lt;C-U&amp;gt;if ! &amp;amp;l:modifiable&amp;lt;Bar&amp;gt;execute 'normal! u'&amp;lt;Bar&amp;gt;elseif ! &amp;lt;SID&amp;gt;StopAtSavedPosition('Undo')&amp;lt;Bar&amp;gt;call repeat#wrap('u',v:count)&amp;lt;Bar&amp;gt;endif&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-R&amp;gt; :&amp;lt;C-U&amp;gt;if ! &amp;amp;l:modifiable&amp;lt;Bar&amp;gt;execute &quot;normal! \&amp;lt;lt&amp;gt;C-R&amp;gt;&quot;&amp;lt;Bar&amp;gt;elseif ! &amp;lt;SID&amp;gt;StopAtSavedPosition('Redo')&amp;lt;Bar&amp;gt;call repeat#wrap(&quot;\&amp;lt;Lt&amp;gt;C-R&amp;gt;&quot;,v:count)&amp;lt;Bar&amp;gt;endif&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-22T18:21:29.063" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22032" PostTypeId="2" ParentId="22027" CreationDate="2019-11-22T19:04:30.927" Score="1" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;Christian Brabandt&lt;/a&gt; replied: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set signcolumn=no&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;seems to solve the issue. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="25181" LastActivityDate="2019-11-22T19:04:30.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22033" PostTypeId="1" CreationDate="2019-11-22T20:02:51.333" Score="2" ViewCount="101" Body="&lt;p&gt;All,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a little function I'm trying to fix. I'd like to change my terminal Vim window size using the ASCII escape sequence &lt;code&gt;\e[8;40;130t&lt;/code&gt; so that my writing window size stays the same when I use a plugin like Tagbar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;printf '\e[8;40;130t'&lt;/code&gt; works within the terminal (iTerm2 with &lt;em&gt;Disable session-initiated window resizing&lt;/em&gt; unchecked in the profile preference). But the same command, issued through Vim using &lt;code&gt;exec system(&quot;printf '\e[8;40;130t'&quot;)&lt;/code&gt; doesn't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the full function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; 'F8' toggle Tagbar side-window tag browser&#xA;let g:is_tagbar=0&#xA;function AdjustWindowWidth()&#xA;&#xA;    exec 'TagbarToggle'&#xA;&#xA;    if (g:is_tagbar==0)&#xA;      let g:is_tagbar=1&#xA;      call system(&quot;printf '\e[8;40;130t'&quot;)&#xA;    else&#xA;      let g:is_tagbar=0&#xA;      call system(&quot;printf '\e[8;40;100t'&quot;)&#xA;    endif&#xA;endfunction&#xA;&#xA;noremap &amp;lt;F8&amp;gt; :exec AdjustWindowWidth()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone have a suggestion on how to fix the issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sean&lt;/p&gt;&#xA;" OwnerUserId="17674" LastEditorUserId="17674" LastEditDate="2019-11-23T14:46:09.787" LastActivityDate="2019-11-23T14:46:09.787" Title="Adjust terminal size using a system call from within Vim" Tags="|vimrc|neovim|external-command|vim-windows|functions|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22034" PostTypeId="1" CreationDate="2019-11-22T20:24:30.503" Score="1" ViewCount="430" Body="&lt;p&gt;I want to count the searching pattern and here is my code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute '%s/' &amp;lt;C-R&amp;gt;/ '/\=' . Count(submatch(0)) . '/gn'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my Count function: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Count(match)&#xA;  if has_key(b:types, a:match)&#xA;      let b:types[a:match]+=1&#xA;  else&#xA;      let b:types[a:match]=1&#xA;  endif&#xA;  return a:match&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I borrowed the function from this &lt;a href=&quot;https://vi.stackexchange.com/a/8914/1788&quot;&gt;answer&lt;/a&gt; by Christian Brabandt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried the following option to combine the searching part &lt;code&gt;&amp;lt;C-R&amp;gt;/&lt;/code&gt; and the function calling part &lt;code&gt;Count(submatch(0))&lt;/code&gt; and the rest but all cannot work: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute '%s/' . &amp;lt;C-R&amp;gt;/ . '/\=' . Count(submatch(0)) . '/gn'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I have read the help document by entering &lt;code&gt;:help execute&lt;/code&gt; and &lt;a href=&quot;http://learnvimscriptthehardway.stevelosh.com/chapters/28.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions would be very appreciated. Thanks in advance.  &lt;/p&gt;&#xA;" OwnerUserId="1788" LastActivityDate="2019-11-24T04:32:31.540" Title="How to execute with call and &lt;C-R&gt;/ matching?" Tags="|regular-expression|search|normal-mode|functions|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22035" PostTypeId="2" ParentId="21987" CreationDate="2019-11-23T00:02:47.410" Score="1" Body="&lt;p&gt;Thanks to some very helpful comments by @dedowsdi I have discovered some more about the vast world that is Vim.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You can test startup load time by running &lt;code&gt;vim --startuptime vtime.log&lt;/code&gt; and inspecting the log file.&lt;/li&gt;&#xA;&lt;li&gt;The main problem was due to my &lt;code&gt;viminfo&lt;/code&gt; file being 22k lines after the updates below it is only 2.5k.&lt;/li&gt;&#xA;&lt;li&gt;Updating my &lt;code&gt;.vimrc&lt;/code&gt; options changed the load time of my &lt;code&gt;viminfo&lt;/code&gt; to 008.324, more than 42x faster. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Current configuration inside my .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set history    =501&#xA;set viminfo    ='100,:100,@100,s10,\&quot;100,h,n$v/files/info/viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This took my load time from ~.4 a second to ~.2 second. The rest of this time is mostly plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extra notes: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/a/204693/157956&quot;&gt;Deleting Vim history&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/2816719/clear-certain-criteria-from-viminfo-file&quot;&gt;Understanding what &lt;code&gt;set viminfo&lt;/code&gt; options are on 7.4&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vim-jp.org/vimdoc-en/options.html#&amp;#39;viminfo&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;Docs on viminfo settings for 8.1&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Again thank you @dedowsdi for getting me going on tracking this all down.&#xA;&lt;strong&gt;Edited for current config&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="8493" LastEditorUserId="8493" LastEditDate="2019-11-25T17:17:35.587" LastActivityDate="2019-11-25T17:17:35.587" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22039" PostTypeId="2" ParentId="20233" CreationDate="2019-11-23T17:01:22.910" Score="2" Body="&lt;p&gt;You can&lt;/p&gt;&#xA;&#xA;&lt;p&gt;bookmark current Directory using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then go to that direct&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or if you have several bookmark&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{number}gb (ex - 1gb, 2gb, 3gb)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to see the list of bookmark&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qb&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to delete bookmark &lt;strong&gt;(notice that B is uppercase)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{number}mB&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25809" LastEditorUserId="25809" LastEditDate="2019-11-23T17:13:59.503" LastActivityDate="2019-11-23T17:13:59.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22040" PostTypeId="1" AcceptedAnswerId="22041" CreationDate="2019-11-23T17:41:40.397" Score="1" ViewCount="116" Body="&lt;p&gt;For example, &lt;code&gt;Ctrl-v_Ctrl-w&lt;/code&gt; gives &lt;code&gt;^[[27;5;119~&lt;/code&gt; instead of usual &lt;code&gt;^W&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does behave in such way only on (&lt;em&gt;u&lt;/em&gt;)&lt;em&gt;xterm&lt;/em&gt;. I've tested it on &lt;em&gt;st&lt;/em&gt;, &lt;em&gt;lxterminal&lt;/em&gt;, &lt;em&gt;xfce4-terminal&lt;/em&gt; and &lt;em&gt;rxvt&lt;/em&gt;. I'm also 98% positive that it works fine on &lt;em&gt;konsole&lt;/em&gt; and &lt;em&gt;gnome-terminal&lt;/em&gt; (based on &lt;a href=&quot;https://www.reddit.com/r/vim/comments/e0fe1h/cttlr_ctrlw_doesnt_work_in_uxterm/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this post&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, &lt;em&gt;xterm&lt;/em&gt; on Ubuntu doesn't have issues. Only on Arch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Outside Vim everything also is normal (i.e. &lt;code&gt;^W&lt;/code&gt;). Neovim doesn't have such problem either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody knows what could cause such behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specification:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Distro: Arch Linux&lt;/li&gt;&#xA;&lt;li&gt;Kernel: Linux alpha 5.3.12-arch1-1&lt;/li&gt;&#xA;&lt;li&gt;xterm: 351 (but also occurs on 348)&lt;/li&gt;&#xA;&lt;li&gt;Vim: 8.1.2268-2 (and 8.1.2337-1)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.reddit.com/r/vim/comments/e0fe1h/cttlr_ctrlw_doesnt_work_in_uxterm/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Related problem&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While it's highly unrelated (&lt;code&gt;vim -u NONE&lt;/code&gt; also doesn't work properly), but my configs:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Jorengarenar/dotfiles/blob/master/vim/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimrc&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Jorengarenar/dotfiles/blob/master/Xresources&quot; rel=&quot;nofollow noreferrer&quot;&gt;Xresources&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerDisplayName="user25807" LastEditorDisplayName="user25807" LastEditDate="2019-11-23T21:27:54.617" LastActivityDate="2019-11-27T11:37:00.360" Title="CTRL-V_CTRL-[key], instead of ^[key] gives ^[[27;5;[ASCII code of key]~ in xterm on Arch" Tags="|key-bindings|terminal|terminal-buffer|linux-arch|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22041" PostTypeId="2" ParentId="22040" CreationDate="2019-11-23T22:12:22.360" Score="1" Body="&lt;pre&gt;&lt;code&gt;set t_TE= t_TI=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This in &lt;em&gt;vimrc&lt;/em&gt; disables &lt;em&gt;modifyOtherKeys&lt;/em&gt; (&lt;code&gt;:h modifyOtherKeys&lt;/code&gt;), which was causing the problems&lt;/p&gt;&#xA;" OwnerDisplayName="user25807" LastEditorDisplayName="user25807" LastEditDate="2019-11-25T22:28:42.647" LastActivityDate="2019-11-25T22:28:42.647" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22042" PostTypeId="1" AcceptedAnswerId="22044" CreationDate="2019-11-23T23:37:50.097" Score="5" ViewCount="848" Body="&lt;p&gt;My &lt;code&gt;&amp;amp;guifont&lt;/code&gt; is set using &lt;code&gt;let &amp;amp;guifont=&quot;SauceCodePro NF 11,Source code pro 11&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calling &lt;code&gt;set guifont?&lt;/code&gt; returns the full option, &lt;code&gt;guifont=SauceCodePro NF 11,Source code pro 11&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to check which of the two fonts gvim eventually used, if any?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading &lt;code&gt;:h guifont&lt;/code&gt; didn't give me any ideas.&lt;/p&gt;&#xA;" OwnerUserId="16419" LastActivityDate="2019-11-25T06:43:58.790" Title="Discover which fallback font was used in gvim" Tags="|gvim|font|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22043" PostTypeId="2" ParentId="22034" CreationDate="2019-11-24T04:32:31.540" Score="1" Body="&lt;p&gt;You're mixing up a few concepts...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; from Insert or Command-line mode (when typing an Ex command after entering it with a &lt;code&gt;:&lt;/code&gt;) to insert the &lt;em&gt;literal&lt;/em&gt; contents of a register. (See &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_CTRL-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help c_CTRL-R&lt;/code&gt;&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can use that in a direct mapping (without the indirection of &lt;code&gt;:execute&lt;/code&gt;), like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;c :%s/&amp;lt;C-R&amp;gt;//\=Count(submatch(0))/gn&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When this mapping gets executed (with &lt;code&gt;&amp;lt;Leader&amp;gt;c&lt;/code&gt;, which defaults to &lt;code&gt;\c&lt;/code&gt; if you haven't set &lt;code&gt;mapleader&lt;/code&gt;), the &lt;code&gt;&amp;lt;C-R&amp;gt;/&lt;/code&gt; sequence will expand to the contents of the search register and will be inserted as part of the Ex command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, instead, you want to use &lt;code&gt;:execute&lt;/code&gt; (because you're not in the context of a mapping, for instance you're inside a function), then what you need is to assemble a &lt;em&gt;string&lt;/em&gt; with the full command you want to execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case, you want to use &lt;code&gt;@/&lt;/code&gt;, which returns the contents of the search register as a string, that you can use as part of an expression. (See &lt;a href=&quot;https://vimhelp.org/eval.txt.html#expression-syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help expression-syntax&lt;/code&gt;&lt;/a&gt;, which has an entry for &lt;code&gt;@r&lt;/code&gt; that evaluates to &quot;contents of register &lt;code&gt;r&lt;/code&gt;.&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another issue with your attempt is that you had &lt;code&gt;Count()&lt;/code&gt; as a function call, but you actually want it to be part of the string, since it's only supposed to be evaluated by the &lt;code&gt;\=&lt;/code&gt; in the replacement of the &lt;code&gt;:substitute&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute '%s/'.@/.'/\=Count(submatch(0))/gn'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, as pointed out in &lt;a href=&quot;https://vi.stackexchange.com/questions/22034/how-to-execute-with-call-and-c-r-matching#comment39858_22034&quot;&gt;this comment&lt;/a&gt; from &lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;Christian Brabandt&lt;/a&gt;, in this particular case you don't need to expand the search register at all, since if you use a &lt;code&gt;:substitute&lt;/code&gt; command without a pattern (empty pattern), the last searched pattern will be used instead. So you don't actually need &lt;code&gt;&amp;lt;C-R&amp;gt;/&lt;/code&gt;, &lt;code&gt;@/&lt;/code&gt; or &lt;code&gt;execute&lt;/code&gt; at all, all you need is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s//\=Count(submatch(0))/gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a function, this command will work directly (it's a valid Ex command.) In a mapping, all you need is to prepend &lt;code&gt;:&lt;/code&gt; and add a &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; at the end. Pretty straightforward!&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-11-24T04:32:31.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22044" PostTypeId="2" ParentId="22042" CreationDate="2019-11-24T04:52:28.627" Score="3" Body="&lt;p&gt;&lt;em&gt;If there really isn't a simple query to find the information then we'll have to brute-force it...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two key behaviors are described in &lt;code&gt;:h 'guifonts'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[If a list of fonts is given] the first valid font is used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[If a single font is given and] the font cannot be found you will get an error message. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That suggests something like this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! ReportFirstValidGuiFont()&#xA;    &quot; preserve existing value&#xA;    let l:fonts = &amp;amp;guifont&#xA;&#xA;    for font in split(l:fonts, &quot;,&quot;) &#xA;        try&#xA;            exe &quot;set guifont=&quot; . font&#xA;            echo &quot;Applied GUI font: &quot; . font&#xA;            return&#xA;        catch /E596/&#xA;            &quot; ie: Vim(set):E596: Invalid font(s): guifont=&amp;lt;font-name&amp;gt;&#xA;            echo v:exception&#xA;        finally&#xA;            &quot; always restore original value&#xA;            let &amp;amp;guifont = l:fonts&#xA;        endtry&#xA;    endfor&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Call with &lt;code&gt;:call ReportFirstValidGuiFont()&lt;/code&gt; and it will iterate over the comma separated font list, setting each font as the sole &lt;code&gt;guifonts&lt;/code&gt; value. It will print a message naming the first one that doesn't cause an error and exit. The printed name should be the font that is currently applied. &lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-11-25T06:43:58.790" LastActivityDate="2019-11-25T06:43:58.790" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22045" PostTypeId="1" AcceptedAnswerId="22047" CreationDate="2019-11-24T08:24:44.733" Score="4" ViewCount="753" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/De7zc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/De7zc.png&quot; alt=&quot;Indentation glitch?&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As seen from the image, Vim decides to highlight those indentations for no reason. I've tried &lt;code&gt;:noh&lt;/code&gt; and &lt;code&gt;:set nolist&lt;/code&gt; (&lt;code&gt;:set list&lt;/code&gt; seems to make it go away, but I don't want indentation marks) from a &lt;a href=&quot;https://stackoverflow.com/q/2851094/6276743&quot;&gt;related question&lt;/a&gt;, but they do not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's causing this issue? All my settings are default, here is my &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoindent&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;set softtabstop=4&#xA;set noexpandtab&#xA;color slate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user25814" LastEditorUserId="4472" LastEditDate="2019-11-29T16:34:42.033" LastActivityDate="2019-11-29T16:34:42.033" Title="Vim highlighting random indentations" Tags="|syntax-highlighting|indentation|colorscheme|highlight|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22046" PostTypeId="1" AcceptedAnswerId="22057" CreationDate="2019-11-24T12:54:21.730" Score="4" ViewCount="2945" Body="&lt;p&gt;I am okay with rest of the section z but I want to remove &lt;code&gt;㏑ :  1&lt;/code&gt; from the default section z configuration because I think it's not useful for me and takes up the space unnecessarily. Is there a way of doing this?&lt;/p&gt;&#xA;" OwnerUserId="15848" LastActivityDate="2019-11-25T09:04:16.253" Title="How to remove line column from Airline section z?" Tags="|plugin-airline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22047" PostTypeId="2" ParentId="22045" CreationDate="2019-11-24T16:16:45.680" Score="4" Body="&lt;p&gt;This is happening because Vim's HTML syntax will use style &lt;code&gt;htmlHead&lt;/code&gt; to the text within the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; block and it will link it to syntax group &lt;code&gt;PreProc&lt;/code&gt;. (The &lt;code&gt;PreProc&lt;/code&gt; group is meant for pre-processor directives, such as &lt;code&gt;#include&lt;/code&gt; or &lt;code&gt;#define&lt;/code&gt; in C/C++.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;slate&lt;/code&gt; colorscheme uses a white background (&lt;code&gt;guibg=white&lt;/code&gt;) for the &lt;code&gt;PreProc&lt;/code&gt; group, so it ends up styling the whitespace inside &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; that way. It doesn't affect the tags themselves (&lt;code&gt;&amp;lt;meta&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt;, etc.) because they're styled as &lt;code&gt;htmlTag&lt;/code&gt; and text within those tags because they're using more specific styles (for example, &lt;code&gt;htmlTitle&lt;/code&gt;) for the title.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to fix this is to override HTML syntax highlighting to unlink it from &lt;code&gt;PreProc&lt;/code&gt;, which you can do with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi link htmlHead None&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to make that permanent, add this command to your vimrc. (This will work because &lt;code&gt;html.vim&lt;/code&gt; sets it using &lt;code&gt;hi def link&lt;/code&gt; which won't override your settings from your vimrc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another alternative is to override the background color of theme &lt;code&gt;slate&lt;/code&gt;, which you can do with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi PreProc guibg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can make that stick by adding this command to your vimrc after &lt;code&gt;color slate&lt;/code&gt;, but the customization will go away if you change themes and then go back to &lt;code&gt;slate&lt;/code&gt;. (See &lt;a href=&quot;https://vi.stackexchange.com/q/21670/18609&quot;&gt;this question&lt;/a&gt; about how to override an existing color theme in a somewhat more reliable way.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-11-24T16:16:45.680" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22048" PostTypeId="1" CreationDate="2019-11-24T18:06:50.323" Score="1" ViewCount="140" Body="&lt;p&gt;I'm using SpaceVim with Neovim, and often times I'd experience this cursor jumping issue (as if &lt;code&gt;^&lt;/code&gt; has been pressed in normal mode) while using it. I doubt the bug is on the Neovim end, otherwise a lot more people definitely would've raised it by now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An issue has already been opened in SpaceVim about it: &lt;a href=&quot;https://github.com/SpaceVim/SpaceVim/issues/3159&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/SpaceVim/SpaceVim/issues/3159&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However we don't know how to reproduce it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've personally notice it occurring most often while:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;navigating a line with &lt;code&gt;w&lt;/code&gt; or &lt;code&gt;e&lt;/code&gt;; and when that becomes the case, doing something like &lt;code&gt;cw&lt;/code&gt; becomes extremely annoying as it ends up jumping the cursor to the first non-blank character of the line and changing that instead of the actual word I wanted&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;while saving the file with either the normal Vim command of &lt;code&gt;:w&lt;/code&gt; or the SpaceVim keybinding of &lt;code&gt;Space f s&lt;/code&gt;; thereby it doesn't appear those specific keybindings are the problem. And when this misbehavior is activated, this jumping to the line start reliably occurs on every subsequent saves&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It also appears to happen regardless of the filetypes (for myself those are most often: &lt;code&gt;.md&lt;/code&gt;, &lt;code&gt;.vim&lt;/code&gt;, &lt;code&gt;.lua&lt;/code&gt;, &lt;code&gt;.py&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only &quot;workaround&quot; I found is to activate another buffer by switching to it, either by just opening it if it's hidden, or switching to buffers in other tabs, or even opening a split (a help split works) in the same tab. This will suppress the problem for some time, could be for a long while, but also could happen again soon after a few more line navigations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point I'm not even quite sure how to go about to diagnose this bug. The submitter already went and disabled many of the layers (and thereby most of the plugins), and he claims it still occurs. Is it caused by some &lt;code&gt;autocmds&lt;/code&gt; perhaps? But that also seems dubious since it occurs very unpredictably while just navigating. Also the fact that switching to another buffer then switching back temporarily suppresses the problem leads me to think that maybe there's some buffer state variable/property that gets reset every time you exit and enter it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to proceed on fixing this is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="24816" LastActivityDate="2019-11-24T18:06:50.323" Title="cursor position jumps to first non-blank character of line unpredictably" Tags="|cursor-movement|cursor|spacevim|debugging|" AnswerCount="0" CommentCount="2" ClosedDate="2019-11-26T08:58:15.040" ContentLicense="CC BY-SA 4.0" />
  <row Id="22049" PostTypeId="1" CreationDate="2019-11-24T20:25:24.417" Score="3" ViewCount="174" Body="&lt;p&gt;Is it possible to provide a default if &lt;code&gt;$*&lt;/code&gt; is empty in a &lt;code&gt;:make&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to specify &lt;code&gt;:makeprg&lt;/code&gt; so that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:make&lt;/code&gt; runs &lt;code&gt;swift build&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:make foo bar&lt;/code&gt; runs &lt;code&gt;swift foo bar&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="25820" LastActivityDate="2019-11-24T21:01:07.147" Title="Default parameter for :make if $* is empty?" Tags="|makeprg|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22050" PostTypeId="1" AcceptedAnswerId="22052" CreationDate="2019-11-24T20:36:38.607" Score="2" ViewCount="154" Body="&lt;p&gt;Let's say I'm editing this text in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;People are helpful.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I am in normal mode, with my cursor currently on the &lt;code&gt;h&lt;/code&gt; letter of the &lt;code&gt;helpful&lt;/code&gt; word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I built a custom command that when run would automatically open in the current directory the file &lt;code&gt;helpful.md&lt;/code&gt; (if such a file does not exists, then nothing would happen or a new empty file would be opened, whatever is the easiest to implement).&lt;/p&gt;&#xA;" OwnerUserId="25821" LastActivityDate="2019-11-24T21:07:14.853" Title="Custom command to go to file whose name matches the current word under cursor?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22051" PostTypeId="2" ParentId="22049" CreationDate="2019-11-24T21:01:07.147" Score="1" Body="&lt;p&gt;This isn't really a vim answer, but consider having an actual makefile (or a shell script, but makefiles are beautiful for this kind of thing—see &lt;a href=&quot;https://blog.mindlessness.life/makefile/2019/11/17/the-language-agnostic-all-purpose-incredible-makefile.html?utm_medium=email&amp;amp;utm_source=topic+optin&amp;amp;utm_campaign=awareness&amp;amp;utm_content=20191123+prog+nl&amp;amp;mkt_tok=eyJpIjoiWm1FNVlUQTJNV0ZtTWpjMyIsInQiOiJjTTBaNmI5Y0hTeUlKdmdlelR4MUhER0dQUFFvdkFDc2R5eUJPQVVxUW1lcTRyVFlCVlwvcXg0aEdDNkV2OWRtdzQ0eERweFhIZnRGdml4VmNXY0VRTjd4TTNQbE9NQ1B2eHJjU0EzdVhwVUhMdnNvSWhtT2h0RnpGSDB0RURDaU0ifQ%3D%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;the language agnostic makefile&lt;/a&gt; and &lt;a href=&quot;http://anadoxin.org/blog/is-it-worth-using-make.html?utm_medium=email&amp;amp;utm_source=topic+optin&amp;amp;utm_campaign=awareness&amp;amp;utm_content=20191123+prog+nl&amp;amp;mkt_tok=eyJpIjoiWm1FNVlUQTJNV0ZtTWpjMyIsInQiOiJjTTBaNmI5Y0hTeUlKdmdlelR4MUhER0dQUFFvdkFDc2R5eUJPQVVxUW1lcTRyVFlCVlwvcXg0aEdDNkV2OWRtdzQ0eERweFhIZnRGdml4VmNXY0VRTjd4TTNQbE9NQ1B2eHJjU0EzdVhwVUhMdnNvSWhtT2h0RnpGSDB0RURDaU0ifQ%3D%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;is it worth using make&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, you don't need weird workarounds for vim's &lt;code&gt;$*&lt;/code&gt; (I had to look it up to be sure of what you were talking about).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example (pay attention to the tabs, which are showing as spaces, unfortunately):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;all: build_output&#xA;&#xA;build_output:&#xA;    swift build&#xA;&#xA;foo_output:&#xA;    swift foo&#xA;&#xA;bar_output:&#xA;    swift bar&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can simply &lt;code&gt;make&lt;/code&gt;, &lt;code&gt;make foo_output&lt;/code&gt;, or &lt;code&gt;make bar_output&lt;/code&gt;, where&#xA;&lt;code&gt;*_output&lt;/code&gt; is a file or directory tree generated by &lt;code&gt;swift *&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let make do its job. Don't beat it to death.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The equivalent shell script would have to be something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#! /usr/bin/env bash&#xA;&#xA;set -euo pipefail&#xA;&#xA;usage() {&#xA;  cat &amp;lt;&amp;lt;DOG&#xA;usage: $0 [args...]&#xA;DOG&#xA;}&#xA;&#xA;die() {&#xA;  local ex=&quot;${1:-1}&quot;&#xA;  exit &quot;$ex&quot;&#xA;}&#xA;&#xA;usage_and_die() { usage &amp;amp;&amp;amp; die; }&#xA;&#xA;build() {&#xA;  swift build&#xA;}&#xA;&#xA;foo() {&#xA;  swift foo&#xA;}&#xA;&#xA;bar() {&#xA;  swift bar&#xA;}&#xA;&#xA;main() {&#xA;  if (($# &amp;lt; 1)) ; then&#xA;    build&#xA;  else&#xA;    for param;&#xA;      case &quot;$param&quot; in&#xA;        -h|--help) usage_and_die ;;&#xA;        *) &quot;$param&quot; ;;&#xA;      esac&#xA;    done&#xA;  fi&#xA;}&#xA;&#xA;main &quot;$@&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the complexity of this beast will only grow. Just use make.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Vim?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I suppose you could do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=* Make if len(&amp;lt;q-args&amp;gt;) &amp;gt; 0 | make &amp;lt;q-args&amp;gt; | else | make build | endif&#xA;setlocal makeprg=swift&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then you have to use this new command, and maintain it, and all that garbage. Plus, if you have a workflow, why not encode that in your makefile, and let others benefit from seeing it?&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-24T21:01:07.147" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22052" PostTypeId="2" ParentId="22050" CreationDate="2019-11-24T21:07:14.853" Score="5" Body="&lt;p&gt;Using &lt;code&gt;gf&lt;/code&gt;, you can go to the file under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Combined with &lt;code&gt;set suffixesadd+=.md&lt;/code&gt;, you can achieve your desired behavior. (&lt;code&gt;suffixesadd&lt;/code&gt; asks &lt;code&gt;gf&lt;/code&gt; and many other friends to try adding any of the suffixes in its list to the file while searching).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you need to have &lt;code&gt;'path'&lt;/code&gt; correctly set (it's default is helpful for C programmers; tpope's apathy plugin sets it for many other filetypes). For this specific case, you probably just need &lt;code&gt;:set path+=.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help gf&lt;/code&gt; also mentions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            If you want to edit the file in a new window use&#xA;            |CTRL-W_CTRL-F|.&#xA;            If you do want to edit a new file, use: &amp;gt;&#xA;                :e &amp;lt;cfile&amp;gt;&#xA;&amp;lt;           To make gf always work like that: &amp;gt;&#xA;                :map gf :e &amp;lt;cfile&amp;gt;&amp;lt;CR&amp;gt;&#xA;&amp;lt;           If the name is a hypertext link, that looks like&#xA;            &quot;type://machine/path&quot;, you need the |netrw| plugin.&#xA;            For Unix the '~' character is expanded, like in&#xA;            &quot;~user/file&quot;.  Environment variables are expanded too&#xA;            |expand-env|.&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-24T21:07:14.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22053" PostTypeId="1" AcceptedAnswerId="22056" CreationDate="2019-11-25T00:34:03.670" Score="0" ViewCount="1449" Body="&lt;p&gt;I managed to hide the background of the seperator between open windows by using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi VertSplit term=NONE cterm=NONE gui=NONE guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However the &lt;code&gt;fillchars&lt;/code&gt; still show up, and from my research it seems like its impossible to completely remove the &lt;code&gt;fillchars&lt;/code&gt;. I figured there must be a way to make it &lt;code&gt;fillchars&lt;/code&gt; invisible, but I cant seem to figure out how.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bp2ra.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bp2ra.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OdKf4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OdKf4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25193" LastEditorUserId="25193" LastEditDate="2019-11-25T07:26:27.170" LastActivityDate="2019-11-25T07:26:27.170" Title="How to completely hide the seperator between windows?" Tags="|vimrc|colorscheme|vim-windows|highlight|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22054" PostTypeId="2" ParentId="22053" CreationDate="2019-11-25T03:08:51.717" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;it seems like its impossible to completely remove the fillchars&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can't really remove it, but you can make it invisible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; must be before setting your colorscheme&#xA;augroup nosplit | au!&#xA;    autocmd ColorScheme * hi VertSplit ctermfg=bg guifg=bg&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-11-25T03:39:41.820" LastActivityDate="2019-11-25T03:39:41.820" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22055" PostTypeId="2" ParentId="22053" CreationDate="2019-11-25T05:05:31.063" Score="0" Body="&lt;p&gt;While you have fixed &lt;code&gt;VertSplit&lt;/code&gt; highlighting I don't see anywhere here the replacement of the actual vert &lt;code&gt;'fillchar'&lt;/code&gt; value. We know removing it doesn't help as it will fall back to a default value but this seems to me to be a sufficient workaround:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set fillchars=vert:\ ,..the rest..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(That's an escaped Space char.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-11-25T05:05:31.063" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="22056" PostTypeId="2" ParentId="22053" CreationDate="2019-11-25T06:58:53.223" Score="2" Body="&lt;p&gt;You can try hiding it using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fillchars=vert:\ &#xA;hi! VertSplit guifg=black guibg=black ctermfg=black ctermbg=black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of &lt;code&gt;black&lt;/code&gt; use color of your terminal or colorscheme background (not sure about various fancy terminals out there)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: &lt;code&gt;vert:\&lt;/code&gt; the space at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mYSq9.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mYSq9.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also works with windows terminal (preview):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(you have to set fillchars, though)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GG9AN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GG9AN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-11-25T07:19:10.570" LastActivityDate="2019-11-25T07:19:10.570" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="22057" PostTypeId="2" ParentId="22046" CreationDate="2019-11-25T09:04:16.253" Score="4" Body="&lt;p&gt;You can inspect the default value of &lt;code&gt;g:airline_section_z&lt;/code&gt; by issuing &lt;code&gt;:echo g:airline_section_z&lt;/code&gt;. Note, this includes already the bold accents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In airline, the default is set to: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if airline#util#winwidth() &amp;gt; 79&#xA;    let g:airline_section_z = airline#section#create(['windowswap', 'obsession', '%3p%%'.spc, 'linenr', 'maxlinenr', spc.':%3v'])&#xA;  else&#xA;    let g:airline_section_z = airline#section#create(['%3p%%'.spc, 'linenr',  ':%3v'])&#xA;  endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(where &lt;code&gt;spc&lt;/code&gt; means &lt;code&gt;Space&lt;/code&gt;, and it depends on the terminal width, which parts are included).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can customize this by setting the &lt;code&gt;g:airline_section_z&lt;/code&gt; variable. Unfortunately, since by the time the vimrc file is read, vim-airline has not been read yet, so you need to postpone configuring the variable until vim-airline has been read. For that purpose, vim-airline exposes the &lt;code&gt;AirlineAfterInit&lt;/code&gt; autocommand event. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together, you would want to configure your section like this in your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au User AirlineAfterInit  :let g:airline_section_z = airline#section#create(['windowswap', 'obsession', '%3p%%', 'maxlinenr', ' :%3v'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or for a very simple one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au User AirlineAfterInit  :let g:airline_section_z = airline#section#create(['%3p%% %L:%3v'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the meanings of the &lt;code&gt;%-expandos&lt;/code&gt; have a look at &lt;a href=&quot;https://vimhelp.org/options.txt.html#&amp;#39;statusline&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'statusline'&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-11-25T09:04:16.253" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22058" PostTypeId="1" AcceptedAnswerId="22059" CreationDate="2019-11-25T10:57:56.860" Score="3" ViewCount="73" Body="&lt;p&gt;I find myself wanting to use vimgrep without having an open vim session. Then, I usually open a blank vim session (by calling &lt;code&gt;vim&lt;/code&gt; from the terminal) and then, for instance, &lt;code&gt;:vim /pattern/ *.tex&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering whether there is a direct way to call vimgrep from the terminal and end up with an open vim session and a populated quickfix list.&lt;/p&gt;&#xA;" OwnerUserId="25831" LastActivityDate="2019-11-25T14:13:58.117" Title="Call vimgrep from terminal" Tags="|terminal|vimgrep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22059" PostTypeId="2" ParentId="22058" CreationDate="2019-11-25T11:30:00.257" Score="2" Body="&lt;p&gt;It concerns more shell than an editor. I guess, adding this to shell's profile should work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimgrep() { $EDITOR &quot;+vimgrep $1 $2&quot; &quot;+copen&quot;; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To call from terminal do not forget to put single quotation marks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimgrep '/pattern/' '*.tex'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="25831" LastEditDate="2019-11-25T14:13:58.117" LastActivityDate="2019-11-25T14:13:58.117" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22061" PostTypeId="1" AcceptedAnswerId="22062" CreationDate="2019-11-25T23:53:24.090" Score="5" ViewCount="345" Body="&lt;p&gt;I frequently use &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; in insert mode to back up when I mistype things. I've noticed some odd behavior if I start insert mode when in the middle of  a word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I have the following line (cursor location indicated by &lt;code&gt;^&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I love to use CamelCase&#xA;                   ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I am at that cursor location and do the key combination &lt;code&gt;i&amp;lt;End&amp;gt;&amp;lt;C-w&amp;gt;&lt;/code&gt;, I am left with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I love to use Camel&#xA;                   ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I expected that &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; would erase up to the beginning of &lt;code&gt;CamelCase&lt;/code&gt; since that is a word. Is &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; only supposed to erase up to the beginning of where I started inserting? Or is there some setting I have to flip to get it to delete the entire word?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; again, it does erase the rest of the word. I just wasn't expecting a word boundary to appear where insert mode started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is using Vim 8.1 (2018 May 18) for Windows.&lt;/p&gt;&#xA;" OwnerUserId="25767" LastActivityDate="2020-08-04T06:47:42.070" Title="Ctrl-W in insert mode erases only up to where insert was started" Tags="|insert-mode|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22062" PostTypeId="2" ParentId="22061" CreationDate="2019-11-26T03:32:30.007" Score="5" Body="&lt;p&gt;This is documented behaviour. Deleting text before the insert start location is controlled by the 'backspace' option, and &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27backspace%27&quot; rel=&quot;noreferrer&quot;&gt;:help 'backspace'&lt;/a&gt; says this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;start: allow backspacing over the start of insert; CTRL-W and CTRL-U stop once at the start of insert.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you really want &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; to behave as you &quot;expect&quot;, here's a convoluted mapping (the different handling depending on whether the cursor is at the end of the line or not is to make sure that the last character is handled correctly: if you do &lt;code&gt;db&lt;/code&gt; when the cursor is at the end of the line, the last character is not deleted; if you do &lt;code&gt;vbd&lt;/code&gt; when the cursor is &lt;em&gt;not&lt;/em&gt; at the end of the line, the following character is deleted):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-w&amp;gt; col('.') == len(getline('.'))+1 ? &quot;\&amp;lt;C-o&amp;gt;vb\&quot;_d&quot; : &quot;\&amp;lt;C-o&amp;gt;\&quot;_db&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7549" LastEditorUserId="7549" LastEditDate="2019-11-26T03:47:39.153" LastActivityDate="2019-11-26T03:47:39.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22063" PostTypeId="1" CreationDate="2019-11-26T05:12:15.733" Score="9" ViewCount="6109" Body="&lt;p&gt;While I enter a regular expression on the vim command line, I would like to see what matches the partial expression I already wrote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, while writing the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/regular&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;all words &lt;code&gt;regular&lt;/code&gt; should be highlighted, and the text should be scrolled so that the first of them is visible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it is good enough if it does the highlight only for single line matches, because a match could easily multiple pages intermittently, even if I want to match only one line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Multiple pages means potentially gigabytes. Of course a single line can be multiple gigabytes itself. The point is: it may be slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this, or anything similar?&lt;/p&gt;&#xA;" OwnerUserId="925" LastEditorUserId="11054" LastEditDate="2020-07-05T15:32:34.407" LastActivityDate="2020-07-05T15:32:34.407" Title="Enable incremental search and highlight while typing a search term?" Tags="|regular-expression|command-line|highlight|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22064" PostTypeId="1" CreationDate="2019-11-26T05:17:56.470" Score="3" ViewCount="2767" Body="&lt;p&gt;Normal mode is also called command mode, and is different from command line mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems both can be used for &lt;code&gt;:&lt;/code&gt; commands, but what is the difference?&lt;/p&gt;&#xA;" OwnerUserId="925" LastActivityDate="2019-11-26T06:55:47.923" Title="What is the difference between normal mode and command line mode?" Tags="|command-line|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22065" PostTypeId="2" ParentId="22063" CreationDate="2019-11-26T06:38:12.900" Score="12" Body="&lt;p&gt;This is done by setting just two options: &lt;code&gt;set is hls&lt;/code&gt; (&lt;a href=&quot;https://vimhelp.org/options.txt.html#%27incsearch%27&quot; rel=&quot;noreferrer&quot;&gt;incremental search&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27hlsearch%27&quot; rel=&quot;noreferrer&quot;&gt;highlight all matches&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure you've also read the appropriate help topics, excerpted below: &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27incsearch%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'is'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;While typing a search command, show where the pattern, as it was typed&#xA;  so far, matches.  The matched string is highlighted.  If the pattern&#xA;  is invalid or not found, nothing is shown.  The screen will be updated&#xA;  often, this is only useful on fast terminals.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Note that the match will be shown, but the cursor will return to its&#xA;  original position when no match is found and when pressing&#xA;  &lt;kbd&gt;Esc&lt;/kbd&gt;.  You still need to finish the search command with&#xA;  &lt;kbd&gt;Enter&lt;/kbd&gt; to move the cursor to the match &amp;hellip;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27hlsearch%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h 'hls'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When there is a previous search pattern, highlight all its matches.&#xA;  The type of highlighting used can be set with the &lt;a href=&quot;https://vimhelp.org/syntax.txt.html#highlight-groups&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;l&lt;/code&gt;&lt;/a&gt;&#xA;  occasion in the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27highlight%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;highlight&lt;/code&gt;&lt;/a&gt; option.  This uses the&#xA;  &quot;Search&quot; highlight group by default.  Note that only the matching text&#xA;  is highlighted, any offsets are not applied &amp;hellip;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When you get bored looking at the highlighted matches, you can turn it&#xA;  off with &lt;code&gt;:nohlsearch&lt;/code&gt;.  As soon as you use a search command, the&#xA;  highlighting comes back &amp;hellip;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since &lt;a href=&quot;http://ftp.vim.org/pub/vim/patches/8.1/8.1.0271&quot; rel=&quot;noreferrer&quot;&gt;Patch 8.1.0271&lt;/a&gt;, &lt;code&gt;incsearch&lt;/code&gt; applies to &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Asubstitute&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:substitute&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Aglobal&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:global&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Av&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:vglobal&lt;/code&gt;&lt;/a&gt; (also known as &lt;code&gt;:s&lt;/code&gt;, &lt;code&gt;:g&lt;/code&gt;, and &lt;code&gt;:v&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Neovim &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27incsearch%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;incsearch&lt;/code&gt;&lt;/a&gt; still does not affect any command, but there exists another option called &lt;code&gt;:h 'inccommand'&lt;/code&gt;. Currently it highlights all matches only for &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Asubstitute&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :substitute&lt;/code&gt;&lt;/a&gt;. Besides this, it can also show a preview window with matched lines: &lt;code&gt;:set inccommand=split&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-12-25T09:20:44.693" LastActivityDate="2019-12-25T09:20:44.693" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="22066" PostTypeId="2" ParentId="22064" CreationDate="2019-11-26T06:53:06.967" Score="6" Body="&lt;p&gt;&lt;code&gt;:&lt;/code&gt; is a normal-mode key-sequence (command) that makes a switch into one of command-line submodes.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;From &lt;code&gt;:h :&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Command-line mode is used to enter Ex commands (&quot;:&quot;), search patterns&#xA;  (&quot;/&quot; and &quot;?&quot;), and filter commands (&quot;!&quot;).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So in command-line mode &lt;code&gt;:&lt;/code&gt; is just a prompt that shows you're allowed to input one Ex-command and then get back to the Normal mode (so it differs from the true Ex-mode).&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-26T06:53:06.967" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22067" PostTypeId="2" ParentId="22064" CreationDate="2019-11-26T06:55:47.923" Score="6" Body="&lt;p&gt;Normal mode is the mode you are in when you start Vim and the mode you should spend the most of time in. From this mode you can easily invoke other modes (&lt;code&gt;v&lt;/code&gt; for &lt;em&gt;visual&lt;/em&gt;, &lt;code&gt;i&lt;/code&gt; for &lt;em&gt;insert&lt;/em&gt;, &lt;code&gt;:&lt;/code&gt; for &lt;strong&gt;&lt;em&gt;command line&lt;/em&gt;&lt;/strong&gt; and so on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything you press in &lt;em&gt;normal mode&lt;/em&gt; can be some sort of command. &lt;code&gt;dd&lt;/code&gt;? It's a command saying &quot;&lt;em&gt;delete current line&lt;/em&gt;&quot;. Hence &lt;em&gt;command mode&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;em&gt;command line mode&lt;/em&gt; you use Ex and search commands, like &lt;code&gt;:s/a/b/g&lt;/code&gt; or &lt;code&gt;/pattern&lt;/code&gt;. For them to take effect you need to press &quot;Return&quot;* (after which you get back to &lt;em&gt;normal mode&lt;/em&gt; - there is also &lt;em&gt;Ex mode&lt;/em&gt;, where after pressing &quot;Return&quot; you stay in &lt;em&gt;command line&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In big approximation: &lt;em&gt;normal&lt;/em&gt; (&lt;em&gt;command&lt;/em&gt;) &lt;em&gt;mode&lt;/em&gt; is for keybindings and &lt;em&gt;command line&lt;/em&gt; is for &quot;shell&quot; commands (similarity to &lt;em&gt;Bash&lt;/em&gt;, &lt;em&gt;Zsh&lt;/em&gt;, &lt;em&gt;sh&lt;/em&gt;, &lt;em&gt;CMD&lt;/em&gt; etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;* return, enter, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user25807" LastActivityDate="2019-11-26T06:55:47.923" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22068" PostTypeId="1" CreationDate="2019-11-26T09:06:43.497" Score="5" ViewCount="452" Body="&lt;p&gt;I followed the instructions given in this answer: &lt;a href=&quot;https://vi.stackexchange.com/a/16436/25843&quot;&gt;https://vi.stackexchange.com/a/16436/25843&lt;/a&gt;, and I've set my shell to point to wsl.exe like this (wsl.exe path seems to be different on my machine compared to the linked answer):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;windows&quot;)&#xA;    set shell=C:\Windows\System32\wsl.exe&#xA;    set shellpipe=|&#xA;    set shellredir=&amp;gt;&#xA;    set shellcmdflag=&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I end up getting this error if I try to run, let's say &lt;code&gt;:!ls&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Windows\System32\wsl.exe  &quot;ls&quot;&#xA;'C:\Windows\System32\wsl.exe' is not recognized as an internal or external command,&#xA;operable program or batch file.&#xA;shell returned 1&#xA;Hit any key to close this window...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, directly running &lt;code&gt;C:\Windows\System32\wsl.exe  &quot;ls&quot;&lt;/code&gt; in the command line seems to work. Also, setting the shell to point to the PowerShell executable seems to work as well, so I'm confused about what I am missing here.&lt;/p&gt;&#xA;" OwnerUserId="25843" LastEditorUserId="1841" LastEditDate="2019-11-26T10:30:06.323" LastActivityDate="2019-11-26T16:41:10.823" Title="Unable to set WSL as the shell on gVim" Tags="|microsoft-windows|shell|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22069" PostTypeId="2" ParentId="22068" CreationDate="2019-11-26T10:30:53.437" Score="4" Body="&lt;p&gt;Ok, my bad. Turns out the path should really be &lt;code&gt;C:\Windows\Sysnative\wsl.exe&lt;/code&gt;, as mentioned in the linked question. I changed it to &lt;code&gt;System32&lt;/code&gt; because I couldn't find the &lt;code&gt;Sysnative&lt;/code&gt; folder under &lt;code&gt;C:\Windows&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently the &lt;code&gt;Sysnative&lt;/code&gt; folder is kind of a virtual folder which exists only from the perspective of 32-bit programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info can be found here:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/microsoft/WSL/issues/1598&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/microsoft/WSL/issues/1598&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/windows/win32/winprog64/running-32-bit-applications&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://docs.microsoft.com/en-us/windows/win32/winprog64/running-32-bit-applications&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="25843" LastEditorUserId="1841" LastEditDate="2019-11-26T16:41:10.823" LastActivityDate="2019-11-26T16:41:10.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22070" PostTypeId="1" CreationDate="2019-11-26T13:29:12.403" Score="1" ViewCount="186" Body="&lt;p&gt;I recorded info of terminal buffers in a dict, and want remove bufnr of closed ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you tell me &lt;strong&gt;how to start a terminal such that call a function on exit, eg,&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! myterm#remove(bufnr):&#xA;    call remove(s:terms, a:bufnr)&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2020-04-26T16:04:35.563" Title="How to start a terminal, so that on exit will call a function?" Tags="|terminal-buffer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22071" PostTypeId="1" AcceptedAnswerId="22237" CreationDate="2019-11-26T14:45:31.030" Score="1" ViewCount="209" Body="&lt;p&gt;Why is my &lt;code&gt;locale&lt;/code&gt; setting replaced when I run an external command with &lt;code&gt;:!cmd&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And which configurations should I check to find the cause of this problem? I've checked configs for my shell (zsh): &lt;code&gt;.zshenv&lt;/code&gt;, &lt;code&gt;.zshrc&lt;/code&gt;; my configs for neovim; my config for KDE. But I still don't understand why nvim seems to reset locale to &lt;code&gt;en&lt;/code&gt; from &lt;code&gt;en_GB&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Within vim, running &lt;code&gt;:!locale&lt;/code&gt; gives me this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;locale: Cannot set LC_ALL to default locale: No such file or directory&#xA;LANG=en&#xA;LC_CTYPE=&quot;en&quot;&#xA;LC_NUMERIC=&quot;en&quot;&#xA;LC_TIME=&quot;en&quot;&#xA;LC_COLLATE=&quot;en&quot;&#xA;LC_MONETARY=&quot;en&quot;&#xA;LC_MESSAGES=&quot;en&quot;&#xA;LC_PAPER=&quot;en&quot;&#xA;LC_NAME=&quot;en&quot;&#xA;LC_ADDRESS=&quot;en&quot;&#xA;LC_TELEPHONE=&quot;en&quot;&#xA;LC_MEASUREMENT=&quot;en&quot;&#xA;LC_IDENTIFICATION=&quot;en&quot;&#xA;LC_ALL=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In zsh I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[I] ➜ locale&#xA;LANG=en_GB.utf8&#xA;LC_CTYPE=&quot;en_GB.utf8&quot;&#xA;LC_NUMERIC=&quot;en_GB.utf8&quot;&#xA;LC_TIME=&quot;en_GB.utf8&quot;&#xA;LC_COLLATE=&quot;en_GB.utf8&quot;&#xA;LC_MONETARY=&quot;en_GB.utf8&quot;&#xA;LC_MESSAGES=&quot;en_GB.utf8&quot;&#xA;LC_PAPER=&quot;en_GB.utf8&quot;&#xA;LC_NAME=&quot;en_GB.utf8&quot;&#xA;LC_ADDRESS=&quot;en_GB.utf8&quot;&#xA;LC_TELEPHONE=&quot;en_GB.utf8&quot;&#xA;LC_MEASUREMENT=&quot;en_GB.utf8&quot;&#xA;LC_IDENTIFICATION=&quot;en_GB.utf8&quot;&#xA;LC_ALL=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;UPDATE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside nvim: &lt;code&gt;:!echo $SHELL&lt;/code&gt; gets &quot;/bin/zsh&quot;, &lt;code&gt;:set shell&lt;/code&gt;: &quot;shell=/bin/zsh&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;.zprofile&lt;/code&gt; and in &lt;code&gt;.zshenv&lt;/code&gt; there is nothing. In &lt;code&gt;.zshrc&lt;/code&gt; no changes to &lt;code&gt;locale&lt;/code&gt;, LANG.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE 2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is with hledger not being invoked correctly (with 'en' locale).&lt;/p&gt;&#xA;" OwnerUserId="25849" LastEditorUserId="25849" LastEditDate="2019-12-06T15:06:38.787" LastActivityDate="2019-12-12T08:49:37.130" Title="Why is my locale replaced when I run an external command?" Tags="|neovim|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22072" PostTypeId="1" CreationDate="2019-11-26T21:57:42.583" Score="5" ViewCount="2367" Body="&lt;p&gt;So, I have the following line where I would like to find all the {#}= and put them on a new line.  Of course there can be more then 9 value entries and there is more text on the line, so I am thinking of looking for something like comma, space, one or more digits, and finally the equal sign, then add a line feed between the comma and the space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is: how do I do that in vi across multiple lines?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  sion] ],{1=ValueEntry, 2=ValueEntry, 3=ValueEntry, 4=ValueEntry, 5=ValueEntry, 6=ValueEntry, 7=ValueEntry, 8=ValueEntry}]&#xA;&#xA;  sion] ],{1=ValueEntry, &#xA;  2=ValueEntry, &#xA;  3=ValueEntry, &#xA;  4=ValueEntry, &#xA;  5=ValueEntry, &#xA;  6=ValueEntry, &#xA;  7=ValueEntry, &#xA;  8=ValueEntry}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25854" LastActivityDate="2019-11-27T10:49:02.803" Title="search &amp; replace: how to add a line feed to break up a line?" Tags="|regular-expression|replace|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22073" PostTypeId="1" AcceptedAnswerId="22074" CreationDate="2019-11-27T04:53:21.143" Score="3" ViewCount="378" Body="&lt;p&gt;How to sort the output of let or get? E.g., I want to sort all global variables containing &quot;python&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filter python let g:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11022" LastEditorUserId="205" LastEditDate="2019-11-27T07:04:01.690" LastActivityDate="2019-11-27T09:01:22.007" Title="Sort output of let or set" Tags="|variables|sort|environment-variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22074" PostTypeId="2" ParentId="22073" CreationDate="2019-11-27T06:18:46.727" Score="5" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You can capture output with &lt;code&gt;execute()&lt;/code&gt; function and then pump it through &lt;code&gt;sort()&lt;/code&gt;. The whole command could be then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bang -nargs=1 -complete=command Sorted&#xA;    \ echo join(sort(split(execute(&amp;lt;q-mods&amp;gt; . ' ' . &amp;lt;q-args&amp;gt;), &quot;\n&quot;),&#xA;        \ {s1, s2 -&amp;gt; &amp;lt;bang&amp;gt;(s1 &amp;gt;# s2) - &amp;lt;bang&amp;gt;(s1 &amp;lt;# s2)}), &quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now you can do &lt;code&gt;:Sorted filter python let g:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;If it makes sense to create a more flexible solution, you can capture command output &lt;em&gt;into a temporary buffer&lt;/em&gt; instead. And once it's in a buffer, &lt;code&gt;:sort&lt;/code&gt;-ing (or any other kind of processing) becomes easy.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;x :put =trim(execute(input(':', '', 'command')))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now press &lt;code&gt;&amp;lt;leader&amp;gt;x&lt;/code&gt; and enter your command. When the output gets into a buffer you can &lt;code&gt;:sort&lt;/code&gt; it as usual.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-11-27T09:01:22.007" LastActivityDate="2019-11-27T09:01:22.007" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22075" PostTypeId="2" ParentId="22073" CreationDate="2019-11-27T07:32:32.180" Score="2" Body="&lt;p&gt;Here is a different approach. &lt;code&gt;:filter let&lt;/code&gt; will only look for matching variable names, so you can re-implement it using &lt;code&gt;filter()&lt;/code&gt; function and sort the resulting dict and output all matches afterwards. This is using the new method functionality of Vim 8.1 and a lambda expression.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for val in sort(keys((copy(g:)-&amp;gt;filter({k -&amp;gt; k =~# 'python'}))))|echo printf(&quot;%s: %s&quot;, val, g:[val])|endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: we are &lt;code&gt;copy()&lt;/code&gt;ing the global dict first, because &lt;code&gt;filter()&lt;/code&gt; filters the given dictionary in place, which we do not want here.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-11-27T07:32:32.180" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22076" PostTypeId="2" ParentId="22071" CreationDate="2019-11-27T07:52:45.050" Score="3" Body="&lt;p&gt;I believe Vim should not modify your current locale except for LC_NUMERIC, LC_CTYPE and possibly LC_MESSAGES. The reason being, that LC_NUMERIC is needed for handling floating point numbers and LC_CTYPE is needed for handling character classes and similar things for multibyte characters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can query the output of the locale inside your vim using the &lt;code&gt;:lang&lt;/code&gt; command. The difference to using the &lt;code&gt;:!locale&lt;/code&gt; command is, that in the later form, this will be run through another shell layer (which may or may not change the locale in the initialization scripts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I believe Vim only sets LC_CTYPE and LC_NUMERIC to a default of &lt;code&gt;C&lt;/code&gt; which should always be available on a POSIX like system. (There was once a bug, that the locale has been reset by the time the gtk/gnome libraries have been initialized, but that has been fixed long ago, and this should not apply to neovim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LC_MESSAGES, LC_CTYPE and LC_TIME can also be set using the &lt;code&gt;:lang [messages|ctype|time] value&lt;/code&gt; command and can be queried using the &lt;code&gt;v:lang&lt;/code&gt; (LC_MESSAGES), &lt;code&gt;v:ctype&lt;/code&gt; (LC_CTYPE) and &lt;code&gt;v:time&lt;/code&gt; (LC_TIME) internal variables.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-11-27T07:52:45.050" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22077" PostTypeId="2" ParentId="22072" CreationDate="2019-11-27T10:49:02.803" Score="5" Body="&lt;p&gt;You can add a line break by using the atom &lt;code&gt;\r&lt;/code&gt; in the replacement part of the &lt;code&gt;:s&lt;/code&gt; command (while in the pattern part, you would need to use &lt;code&gt;\n&lt;/code&gt; to &lt;strong&gt;match&lt;/strong&gt; a line break).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That allows to split your string using the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/,\ze \d\+=/&amp;amp;\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is search for a comma (and end the match there), followed by a space, at least one number and a &lt;code&gt;=&lt;/code&gt; and replace the comma in this case with itself (using the special atom &lt;code&gt;&amp;amp;&lt;/code&gt; which corresponds to the complete match) followed by a line break (&lt;code&gt;\r&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-11-27T10:49:02.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22078" PostTypeId="2" ParentId="22063" CreationDate="2019-11-27T11:13:25.167" Score="3" Body="&lt;p&gt;Prior to version 8.1.0271, in order to preview searches in this way you have to adjust your workflow slightly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, set up your regular expression by using a normal search, during which highlighting will be active:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/regular&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, you can re-use the regular expression from your search command by leaving the field blank in your substitute command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s//replacement&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An alternative method&amp;#8202;&amp;mdash;&amp;#8202;if you want to include the actual expression in your command and don't mind a couple of extra keystrokes&amp;#8202;&amp;mdash;&amp;#8202;is to actually insert the pattern into your &lt;code&gt;:substitute&lt;/code&gt; command by hitting &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;. This inserts the contents of the search register into the command line. See &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_CTRL-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help c_CTRL-R&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2019-11-27T11:46:13.757" LastActivityDate="2019-11-27T11:46:13.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22079" PostTypeId="2" ParentId="22040" CreationDate="2019-11-27T11:37:00.360" Score="1" Body="&lt;p&gt;As of patch &lt;a href=&quot;https://github.com/vim/vim/commit/fc4ea2a72d36de1196a3ce17352e72f8fe90f4bb&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.2350&lt;/a&gt;, &lt;code&gt;Ctrl-V&lt;/code&gt; will emit again the translated key, even if &lt;a href=&quot;https://vimhelp.org/map.txt.html#modifyOtherKeys&quot; rel=&quot;nofollow noreferrer&quot;&gt;modifyOtherKeys&lt;/a&gt; has been set. To get the raw escape sequence, you can instead use now &lt;code&gt;Ctrl-Shift-V&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-11-27T11:37:00.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22080" PostTypeId="2" ParentId="15587" CreationDate="2019-11-27T12:00:00.687" Score="1" Body="&lt;p&gt;FWIW: &#xA;:'a,'bs/foo//&lt;strong&gt;n&lt;/strong&gt;&#xA;substitute foo with nothing and choose 'no' when asked for the replacement.&#xA;afterwards just hit the next (n) to get to the next occurrence. &lt;/p&gt;&#xA;" OwnerUserId="25864" LastActivityDate="2019-11-27T12:00:00.687" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22081" PostTypeId="1" AcceptedAnswerId="22083" CreationDate="2019-11-27T17:03:16.470" Score="3" ViewCount="627" Body="&lt;p&gt;I was reading through the vim wiki about the power of g &lt;a href=&quot;https://vim.fandom.com/wiki/Power_of_g&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vim.fandom.com/wiki/Power_of_g&lt;/a&gt; and would like to do something similar to &lt;code&gt;:g/pattern/y A&lt;/code&gt; but a little bit different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an html file with tags that have a bunch of properties like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;the-tag&#xA;  prop=&quot;prop1&quot;&#xA;&amp;lt;/the-tag&amp;gt;&#xA;&amp;lt;the-tag&#xA;  prop=&quot;prop2&quot;&#xA;&amp;lt;/the-tag&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to append to register a, the value inside the prop quotes.  Is this possible using :g or some other method?  Here is what I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/prop/normal yi&quot; A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this just yanks the very last prop value instead of a whole list.  Of course I could do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/prop/y A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this would give me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;prop=&quot;prop1&quot;&#xA;prop=&quot;prop2&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is not what I'm looking for.  Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="25871" LastActivityDate="2019-11-27T20:18:40.713" Title="Using :g to yank in quotes across multiple lines" Tags="|cut-copy-paste|global-command|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22082" PostTypeId="2" ParentId="22081" CreationDate="2019-11-27T17:19:02.013" Score="1" Body="&lt;p&gt;Somebody had a similar problem: &lt;a href=&quot;https://stackoverflow.com/questions/23713617/vim-yank-all-matches-of-regex-group-into-register&quot;&gt;vim yank all matches of regex group into register&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case &lt;code&gt;regex&lt;/code&gt; will be &lt;code&gt;prop=&quot;\zs.*\ze&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\zs&lt;/code&gt; denotes where the match will start in the &quot;substitution&quot; (yanking to register), and &lt;code&gt;\ze&lt;/code&gt; where to end.&lt;/p&gt;&#xA;" OwnerDisplayName="user25807" LastActivityDate="2019-11-27T17:19:02.013" CommentCount="0" CommunityOwnedDate="2023-12-26T04:28:40.897" ContentLicense="CC BY-SA 4.0" />
  <row Id="22083" PostTypeId="2" ParentId="22081" CreationDate="2019-11-27T17:38:23.683" Score="5" Body="&lt;p&gt;You're confusing the passing of the register to &lt;code&gt;:yank&lt;/code&gt; (Ex command) vs. &lt;code&gt;y&lt;/code&gt; (normal mode). For the latter, instead of appending the register, it must come &lt;em&gt;before&lt;/em&gt; the &lt;code&gt;y&lt;/code&gt; command, and with the &lt;code&gt;&quot;&lt;/code&gt; prefix: &lt;code&gt;&quot;Ayi&quot;&lt;/code&gt; (&lt;em&gt;with register &lt;code&gt;A&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;ank the &lt;code&gt;i&lt;/code&gt;nner &lt;code&gt;&quot;&lt;/code&gt; double quoted text&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a = '' | g/prop/normal! &quot;Ayi&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that as the yank is &lt;em&gt;characterwise&lt;/em&gt;, all matches will be appended without any separator (resulting in &lt;code&gt;prop1prop2&lt;/code&gt;). You could add a separator like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a = '' | :g/prop/let @a .= &quot; &quot; | normal! &quot;Ayi&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastEditorUserId="970" LastEditDate="2019-11-27T20:18:40.713" LastActivityDate="2019-11-27T20:18:40.713" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22084" PostTypeId="2" ParentId="22081" CreationDate="2019-11-27T17:47:07.860" Score="0" Body="&lt;p&gt;A slightly different variation using &lt;code&gt;:h gn&lt;/code&gt; motion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a='' | g/prop=&quot;\zs.*\ze&quot;/normal! &quot;Aygn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-27T17:47:07.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22085" PostTypeId="2" ParentId="22071" CreationDate="2019-11-27T22:46:20.603" Score="0" Body="&lt;p&gt;Vim is probably running the external program under a non-login shell, and your configuration is setting the locale correctly only for login shells.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no experience with zsh, but under bash it would be checking if the locale is correctly set in &lt;code&gt;~/.bash_profile&lt;/code&gt; and not only on &lt;code&gt;~/.bashrc&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="10482" LastActivityDate="2019-11-27T22:46:20.603" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22086" PostTypeId="1" CreationDate="2019-11-28T01:07:55.100" Score="3" ViewCount="1053" Body="&lt;p&gt;I have an autocommand that is supposed to register a different autocommand whenever I enter a buffer where a certain condition is met:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let w:contextlist_open = 1&#xA;&#xA;augroup LaunchShowContext&#xA;    autocmd!&#xA;    autocmd BufEnter * &#xA;        \ if (exists(&quot;w:contextlist_open&quot;) &amp;amp;&amp;amp; w:contextlist_open == 1) &#xA;            \ | :autocmd CursorHold * call ShowContext()&#xA;        \ | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I fire up another buffer and switch back and forth, I get &lt;code&gt;Error detected while processing CursorHold Autocommands for &quot;*&quot;:&#xA;E580: :endif without :if:  endif&lt;/code&gt;. I suspect this is because Vim thinks the &lt;code&gt;endif&lt;/code&gt; belongs with the second autocommand rather than the first, and I'm not sure how to make it so that it goes with the correct one. I tried wrapping the &lt;code&gt;autocmd CursorHold * call ShowContext()&lt;/code&gt; in parentheses, but that seems to give me other problems.&lt;/p&gt;&#xA;" OwnerUserId="19915" LastActivityDate="2019-11-28T09:53:23.953" Title="autocommand within conditional autocommand" Tags="|autocmd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22087" PostTypeId="2" ParentId="11061" CreationDate="2019-11-28T06:00:46.063" Score="1" Body="&lt;p&gt;I would go with either&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; load Plugins.vim, searching it in &quot;all vim places&quot;&#xA;runtime Plugins.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; load Plugins.vim from the relative path of your vimrc&#xA;source &amp;lt;sfile&amp;gt;:h/.vim/Plugins.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-11-28T06:00:46.063" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22088" PostTypeId="2" ParentId="22086" CreationDate="2019-11-28T09:53:23.953" Score="4" Body="&lt;p&gt;Use &lt;code&gt;:execute&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup LaunchShowContext | au!&#xA;    autocmd BufEnter *&#xA;        \ if get(w:, 'contextlist_open')&#xA;            \ | execute 'autocmd! CursorHold &amp;lt;buffer&amp;gt; call ShowContext()'&#xA;        \ | endif&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But note (at least) three problems:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) You examine window-variable &lt;code&gt;contextlist_open&lt;/code&gt;, while expecting buffer-specific event &lt;code&gt;CursorHold&lt;/code&gt; to fire. That could be frustrating if your buffer is shown in several split windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) &lt;code&gt;unlet&lt;/code&gt;-ting &lt;code&gt;contextlist_open&lt;/code&gt; will not remove &lt;code&gt;au CursorHold&lt;/code&gt;, as one would expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) &lt;code&gt;execute&lt;/code&gt; will run under global &lt;code&gt;augroup&lt;/code&gt; context, so you still must find a way to prevent repeating &lt;code&gt;call ShowContext()&lt;/code&gt;'s due to multiple &lt;code&gt;BufEnter&lt;/code&gt; events. I put &lt;code&gt;au!&lt;/code&gt; for simplicity, but that could potentially conflict with other plugins, so you probably should explore another solution (create another &lt;code&gt;augroup mygroup&lt;/code&gt; then check if &lt;code&gt;exists('#mygroup#CursorHold#&amp;lt;buffer&amp;gt;')&lt;/code&gt; etc.).&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-28T09:53:23.953" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22089" PostTypeId="1" AcceptedAnswerId="22092" CreationDate="2019-11-28T10:21:07.140" Score="3" ViewCount="818" Body="&lt;p&gt;I would like to capture the result of a shell command into a vim variable inside of my vimrc file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using &lt;code&gt;let myvar = system(&quot;DIR&quot;)&lt;/code&gt; however it seems to crash vim when I put it in my vimrc file. I launch vim and then it just returns immediately without any error message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So instead I was wondering if I can do something like &lt;code&gt;let exe_path = &amp;lt;expr&amp;gt; :!pwd&lt;/code&gt; ? This is obviously the wrong way to do it so I was wondering if something like that is possible?&lt;/p&gt;&#xA;" OwnerUserId="25193" LastEditorUserId="25193" LastEditDate="2019-11-28T11:48:48.680" LastActivityDate="2019-11-28T16:06:06.293" Title="How to get put the result of a shell command in a variable?" Tags="|vimrc|microsoft-windows|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="22090" PostTypeId="2" ParentId="241" CreationDate="2019-11-28T13:33:01.493" Score="1" Body="&lt;p&gt;This post is old, the accepted answer doesn't concern about &lt;code&gt;terminal buffer&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The accepted answer use &lt;code&gt;session&lt;/code&gt; to do the trick, but &lt;code&gt;session&lt;/code&gt; can't completely restore &lt;code&gt;terminal buffer&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            *terminal-session*&#xA;A terminal window will be restored when using a session file, if possible and&#xA;wanted.&#xA;&#xA;If &quot;terminal&quot; was removed from 'sessionoptions' then no terminal windows will&#xA;be restored.&#xA;&#xA;If the job in the terminal was finished the window will not be restored.&#xA;...&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tommcdo's &lt;a href=&quot;https://vi.stackexchange.com/a/650/5017&quot;&gt;answer&lt;/a&gt; still works, &lt;code&gt;&amp;lt;c-w&amp;gt;:tab split&lt;/code&gt; works well on  &lt;code&gt;terminal buffer&lt;/code&gt; . It deserves a map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-w&amp;gt;&amp;lt;space&amp;gt; :tab split&amp;lt;cr&amp;gt;&#xA;tnoremap &amp;lt;c-w&amp;gt;&amp;lt;space&amp;gt; &amp;lt;c-w&amp;gt;:tab split&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-11-28T13:33:01.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22091" PostTypeId="2" ParentId="22070" CreationDate="2019-11-28T14:20:40.133" Score="1" Body="&lt;p&gt;The solution is using &lt;code&gt;job-exit_cb&lt;/code&gt; handler, (see &lt;code&gt;:help job-exit_cb&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A working example is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! g:Exit_cb(job, exit_code)&#xA;    echo term_getjob(2)&#xA;    let pid = matchstr(a:job, '^\%(process \)\zs\d\+')&#xA;    echom &quot;job &quot; . pid . &quot; finished with exit_code &quot; . a:exit_code&#xA;endfunc&#xA;&#xA;call term_start('bash', {'exit_cb': function('g:Exit_cb')})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Run above code, then close the newly created terminal, you will see&#xA;something like below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;job 61392 finished with exit_code 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;be echoed at the bottom, you can also verify with &lt;code&gt;:mess&lt;/code&gt; command. &lt;em&gt;(since `:echom is used)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2019-11-28T14:20:40.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22092" PostTypeId="2" ParentId="22089" CreationDate="2019-11-28T16:06:06.293" Score="4" Body="&lt;p&gt;&lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#system%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;system()&lt;/code&gt;&lt;/a&gt; is the right function; it &lt;em&gt;should&lt;/em&gt; work fine also inside &lt;code&gt;~/.vimrc&lt;/code&gt;, but is best avoided as each external command delays Vim's startup and makes the user wait.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, you'll be able to only invoke the external command once it's required for a user interaction (i.e. &lt;em&gt;lazily&lt;/em&gt;) - and then cache the information in case it's needed again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you absolutely need the information on startup already, and to work around your problem, you can hook into the &lt;a href=&quot;https://vimhelp.appspot.com/autocmd.txt.html#VimEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;VimEnter&lt;/code&gt;&lt;/a&gt; event that is fired at the &lt;em&gt;end&lt;/em&gt; of initialization:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:autocmd VimEnter * let myvar = system('pwd')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;The &lt;code&gt;pwd&lt;/code&gt; is only an example; you'd better use the built-in &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#getcwd%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getcwd()&lt;/code&gt;&lt;/a&gt; instead.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-28T16:06:06.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22095" PostTypeId="1" AcceptedAnswerId="22096" CreationDate="2019-11-29T03:50:26.847" Score="2" ViewCount="790" Body="&lt;p&gt;I am trying to load plugins based on file type. I have the following in ftplugin/python.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;packadd SimpylFold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When a python file is opened, not folding is done. If I issue the same command from the python buffer :packadd SimpylFold, no effect either, but if 'packadd SimpylFold' is added to vimrc, folding works fine. By experementing I found that adding the following two lines from plugin/SimpylFold.vim to ftplugin/python.vim does the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;packadd SimpylFold&#xA;\ | call SimpylFold#BufferInit()&#xA;\ | setlocal foldexpr=SimpylFold#FoldExpr(v:lnum)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Why running 'packadd SimpylFold' from the current buffer of&#xA;including in ftplugin do not work the same way as including it in&#xA;vimrc?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Why adding the following to ftplugin has no effect either?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:SimpylFold_docstring_preview = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11022" LastActivityDate="2019-11-29T05:41:11.257" Title="Why packadd from ftplugin does not work the same way as from vimrc" Tags="|packages|" AnswerCount="1" CommentCount="2" ClosedDate="2019-11-29T19:11:19.777" ContentLicense="CC BY-SA 4.0" />
  <row Id="22096" PostTypeId="2" ParentId="22095" CreationDate="2019-11-29T05:41:11.257" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I am trying to load plugins based on file type.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's a wrong idea. All plugins which do depend on file types should be &lt;code&gt;ftplugin&lt;/code&gt;-plugins (i.e. 2-nd level plugins). And &lt;code&gt;ftplugin&lt;/code&gt; already knows how load-on-demand. So don't try to re-invent the wheel.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My questions are&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The answer is on both. Roughly speaking, &lt;code&gt;packadd&lt;/code&gt; does two things: registers plugin's directories in &lt;code&gt;packpath&lt;/code&gt;; and executes stuff from &lt;code&gt;./plugin/&lt;/code&gt; subdirectory. But normally plugins have very little (or nothing) to be executed on load-time. In particular, &lt;code&gt;ftplugin&lt;/code&gt;-type plugins need only to wait until &lt;code&gt;ftplugin&lt;/code&gt; executes them. That takes place automatically after a buffer is read in. But in your case you register the plugin after that, so nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;if 'packadd SimpylFold' is added to vimrc&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In fact, you don't even need to put &lt;code&gt;packadd&lt;/code&gt; to vimrc. Just move the plugin under &lt;code&gt;pack/&amp;lt;whatever&amp;gt;/start&lt;/code&gt;, so it will get loaded automatically. From what was said above, it follows that &quot;the core functionality&quot; will be loaded on demand, and you don't need to worry about that.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-11-29T05:41:11.257" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22097" PostTypeId="1" CreationDate="2019-11-29T11:04:30.240" Score="3" ViewCount="1836" Body="&lt;p&gt;When I'm choosing an option from the autocomplete suggestions, it automatically puts my cursor in the following location:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function(|)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I type the value that I want, and in order to get out of the brackets (forward) I have to use the right arrow button, to yield:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function(value)|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is pretty inconvenient. Is there any better option?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: As mentioned in one of the comments, the &lt;code&gt;)&lt;/code&gt; char can be used, but for me personally it's not more convenient. I would like to &lt;code&gt;map'&lt;/code&gt;the return (&lt;kbd&gt;Enter&lt;/kbd&gt;) key to function as the right arrow key in this specific situation.&lt;/p&gt;&#xA;" OwnerUserId="25181" LastEditorUserId="10604" LastEditDate="2019-12-18T04:13:13.307" LastActivityDate="2019-12-19T14:38:44.587" Title="Easiest way to go to the closest closing bracket?" Tags="|key-bindings|autocompletion|plugin-ultisnips|plugin-auto-pairs|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="22098" PostTypeId="2" ParentId="22097" CreationDate="2019-11-29T11:43:57.237" Score="2" Body="&lt;p&gt;I use &lt;code&gt;&amp;lt;esc&amp;gt;A&lt;/code&gt;, it's 2.5 key strokes(0.5 for &lt;code&gt;shift&lt;/code&gt;), it's not the shortest solution, but it's the most natural one if you are used to move around in normal mode. IMO, &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; doesn't count as a keystroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;c-o&amp;gt;A&lt;/code&gt; works too, but I don't like it, I can't remember the last time i use &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-O&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h i_CTRL-O&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also create a map for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-l&amp;gt; &amp;lt;right&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change &lt;code&gt;&amp;lt;c-l&amp;gt;&lt;/code&gt; to whatever key you like, I wouldn't use it, this kind of map is unnatural, it's also a burden to create, maintain and remember maps for trivial stuff.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="1238" LastEditDate="2019-12-17T23:28:35.077" LastActivityDate="2019-12-17T23:28:35.077" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22099" PostTypeId="1" AcceptedAnswerId="22100" CreationDate="2019-11-29T14:07:51.800" Score="1" ViewCount="105" Body="&lt;p&gt;Following naive snippet highlights such headers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match asciidoctorH1 &quot;^\_s*\n\a.*\n====*&quot;&#xA;syn match asciidoctorH2 &quot;^\_s*\n\a.*\n----*&quot;&#xA;&#xA;hi link asciidoctorH1 Title&#xA;hi link asciidoctorH2 Title&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But for asciidoc(tor) it is incorrect. The issue is in length of the dashes -- it should be exactly the same as text above it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;correct:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;test header&#xA;===========&#xA;&#xA;he world&#xA;--------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;incorrect (shouldn't be highlighted):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;test header&#xA;=======&#xA;&#xA;he world&#xA;-----------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, is there a way to find the length of the text above dashes and apply it to dashes? Or any other way to do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LxC8c.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LxC8c.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-11-29T15:20:19.677" Title="Highlight setext-style (asciidoctor/markdown) headers" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22100" PostTypeId="2" ParentId="22099" CreationDate="2019-11-29T15:20:19.677" Score="2" Body="&lt;p&gt;You're running into the limitations of the regular expression-based syntax highlighting here. Though you can refer to previously matched text (&lt;a href=&quot;https://vimhelp.appspot.com/pattern.txt.html#%2F%5C1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\1&lt;/code&gt;&lt;/a&gt;), you cannot assert on the same number of characters or modify (turn all characters into literal &lt;code&gt;=&lt;/code&gt; matches) with it. The only option I see would be enumerating all likely lengths separately:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match asciidoctorH1 &quot;^\_s*\n\a.\{3}\n=\{4}$\|^\_s*\n\a.\{4}\n=\{5}$\|...&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That probably won't perform well, though :-(&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-11-29T15:20:19.677" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22101" PostTypeId="1" AcceptedAnswerId="22108" CreationDate="2019-11-29T16:30:12.610" Score="4" ViewCount="1161" Body="&lt;p&gt;I have this line in &lt;code&gt;.vimrc&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ruler&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which shows the percentage of current line. But for very large text files, it would just show &lt;code&gt;0%&lt;/code&gt; for first couple hundreds of lines, which is not quite useful. How can I &lt;code&gt;set ruler&lt;/code&gt; such that is would show, for example, &lt;code&gt;0.04%&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="25105" LastActivityDate="2019-11-30T09:40:53.477" Title="How to set ruler with decimals in .vimrc file?" Tags="|vimrc|ruler|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22102" PostTypeId="1" AcceptedAnswerId="22111" CreationDate="2019-11-29T17:14:46.680" Score="1" ViewCount="98" Body="&lt;p&gt;I am working with react. First I had a component with state I created methods and all that. Now I want to convert it into stateless component. I have add the word &lt;code&gt;function&lt;/code&gt; before each method name.&lt;/p&gt;&#xA;&lt;p&gt;This is my file:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import React, { Component } from &amp;quot;react&amp;quot;;&#xA;&#xA;const Form = ({ sumbitBtn, onSubmit, inputs, id }) =&amp;gt; {&#xA;   onSubmit() {&#xA;   }&#xA;   renderInputs() {&#xA;   }&#xA;   sendErrors(errors) {&#xA;   }&#xA;   return (&#xA;       ...&#xA;   );&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now I have tried to do it two ways but neither of them worked for me.&lt;/p&gt;&#xA;&lt;h3&gt;Using regular expression&lt;/h3&gt;&#xA;&lt;p&gt;I used the each of the following commands.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\w+\(\w*\)/function &amp;amp;/g&#xA;:%s/\w+\(\w*\)/function \0/g&#xA;:%s/(\w+\(\w*\))/function \1/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But unfortunately the names of methods are showing rather its showing like &lt;code&gt;function &amp;amp;&lt;/code&gt;, &lt;code&gt;function \0&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Using macros&lt;/h3&gt;&#xA;&lt;p&gt;Another idea that came into my mind was that I could use a macro. Which have steps but I was stuck in one of the step which is finding the next method using regular expression and jumping to it.&lt;/p&gt;&#xA;&lt;p&gt;My question is that how can we do this using both of the ways.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; the above file is just example file. The original file contains line breaks, comments between the methods.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I am using the vim extension on vscode.&lt;/p&gt;&#xA;&lt;p&gt;The result I want to get is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import React, { Component } from &amp;quot;react&amp;quot;;&#xA;&#xA;const Form = ({ sumbitBtn, onSubmit, inputs, id }) =&amp;gt; {&#xA;   function onSubmit() {&#xA;   }&#xA;   function renderInputs() {&#xA;   }&#xA;   function sendErrors(errors) {&#xA;   }&#xA;   return (&#xA;       ...&#xA;   );&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25893" LastEditorUserId="18609" LastEditDate="2021-04-24T14:32:56.643" LastActivityDate="2022-05-19T17:03:00.290" Title="How to add a certain word before the names of methods in Javascript?" Tags="|regular-expression|search|replace|macro|vscode|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="22103" PostTypeId="1" AcceptedAnswerId="22114" CreationDate="2019-11-29T19:22:07.747" Score="1" ViewCount="446" Body="&lt;p&gt;Are there any permission settings that need set on a file to get persistent undo to work? I close and open my vimrc file and I can keep hitting the u key to see my previous edits. But it does not work for production code files. Any ideas what could be the issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edited to Add:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a sample of my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Turn persistent undo on. This means that you can undo even when you close a&#xA;&quot; buffer/VIM.&#xA;if has(&quot;persistent_undo&quot;)&#xA;  if isdirectory(expand(&quot;~/.vim/temp_dirs/undodir&quot;))&#xA;    set undodir=~/.vim/temp_dirs/undodir&#xA;  elseif isdirectory(expand(&quot;~/vimfiles/temp_dirs/undodir&quot;))&#xA;    set undodir=~/vimfiles/temp_dirs/undodir&#xA;  else&#xA;    echomsg &quot;ERROR: undodir does not exist or is not writable.&quot;&#xA;  endif&#xA;&#xA;  set undofile&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My .vimrc has 644 permission and is owned by snrub:snrub.&#xA;An example of a file that does not have persistent undo would be &lt;code&gt;/var/www/html/sites/all/modules/custom/mymodule/mymodule.module&lt;/code&gt; (this is a Drupal 7 installation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This file has 664 permission and is owned by apache:apache. User snrub is a member of the apache group, so I do have write permission on the file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;verbose set undodir&lt;/code&gt; gives the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;undodir=~/.vim/temp_dirs/undodir&#xA;    Last set from ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...which is a directory that does exist.&lt;/p&gt;&#xA;" OwnerUserId="9047" LastEditorUserId="9047" LastEditDate="2019-11-30T12:18:35.060" LastActivityDate="2019-12-01T14:54:49.627" Title="persistent_undo works for vimrc file, but not for other files" Tags="|persistent-state|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22104" PostTypeId="1" CreationDate="2019-11-29T22:33:09.960" Score="2" ViewCount="51" Body="&lt;p&gt;I want to design my own vim color scheme, so I'm starting with an existing color scheme that I think is pretty good, and fixing the parts I don't like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The color scheme definition contains many syntax tags, a lot of which aren't totally clear. The task would be much easier if I could ask Vim:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Which syntax rule is determining the color of the character under my cursor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do it?&lt;/p&gt;&#xA;" OwnerUserId="23649" LastActivityDate="2019-11-29T23:15:38.453" Title="How to figure out which syntax rule is determining a character's color?" Tags="|colorscheme|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22105" PostTypeId="2" ParentId="22104" CreationDate="2019-11-29T23:15:38.453" Score="2" Body="&lt;p&gt;There are plenty. One is my own &lt;a href=&quot;https://github.com/benknoble/vim-synstax&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt;, the code of which is straightforward:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Show the highlight groups under the cursor&#xA;&quot; Maintainer:       David Ben Knoble &amp;lt;ben.knoble@gmail.com&amp;gt;&#xA;&quot; Last Change:      2018 May 11&#xA;&#xA;if !has(&quot;syntax&quot;) || &amp;amp;compatible&#xA;  echohl ErrorMsg&#xA;  echomsg &quot;vim-synstax requires the +syntax features&quot;&#xA;  echohl None&#xA;  finish&#xA;endif&#xA;&#xA;function! synstax#UnderCursor() abort&#xA;  let l:stack = synstax#Stack(line('.'), col('.'))&#xA;  if empty(l:stack)&#xA;    return &quot;No syntax highlight groups under cursor&quot;&#xA;  endif&#xA;  let l:names = synstax#Attributes(l:stack, 'name')&#xA;  return l:names&#xA;endfunction&#xA;&#xA;function! synstax#Stack(line, col) abort&#xA;  return synstack(a:line, a:col)&#xA;endfunction&#xA;&#xA;function! synstax#Attributes(stack, attr) abort&#xA;  let l:attr_func = printf('synIDattr(v:val, &quot;%s&quot;)', a:attr)&#xA;  return map(a:stack, l:attr_func)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-11-29T23:15:38.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22106" PostTypeId="2" ParentId="5213" CreationDate="2019-11-30T08:52:58.743" Score="2" Body="&lt;p&gt;change the mapping to what you want to use&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the undo is in case you use it on top of a space, since ciw will edit the space instead of the word (and there's no easy way to get to the right word reliably)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function SwapBool ()&#xA;  let s:w = expand(&quot;&amp;lt;cword&amp;gt;&quot;)&#xA;  if s:w == &quot;false&quot;&#xA;    normal ciwtrue&#xA;    if expand(&quot;&amp;lt;cword&amp;gt;&quot;) != &quot;true&quot;&#xA;      normal u&#xA;    endif&#xA;  elseif s:w == &quot;true&quot;&#xA;    normal ciwfalse&#xA;    if expand(&quot;&amp;lt;cword&amp;gt;&quot;) != &quot;false&quot;&#xA;      normal u&#xA;    endif&#xA;  endif&#xA;endfunction&#xA;noremap &amp;lt;C-F&amp;gt; :call SwapBool()^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;also note the ^M needs to be &lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;, not literally ^M&lt;/p&gt;&#xA;" OwnerUserId="25899" LastActivityDate="2019-11-30T08:52:58.743" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22107" PostTypeId="2" ParentId="22103" CreationDate="2019-11-30T09:23:38.333" Score="-2" Body="&lt;p&gt;Persistent undo is controlled by &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27undofile%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'undofile'&lt;/a&gt; option, it's off by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's on, vim store undo history under &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27undodir%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'undodir'&lt;/a&gt; when writing a buffer to a file, and restore undo history from the same file on buffer read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open your vimrc, and execute&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;verbose set undofile?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should tell you where it was set last time.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Personal opinion about persistent undo:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure if it's a good idea to turn on &lt;code&gt;'undofile'&lt;/code&gt;, if it's off, you can hold &lt;code&gt;u&lt;/code&gt; or execute &lt;code&gt;:undo 0&lt;/code&gt; to undo all the changes made in current session, if it's on, you have to use &lt;code&gt;:earlier 1h&lt;/code&gt; family command instead. It also cost more and more memory as your undo history getting bigger and bigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I prefer manual style undo history read and write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set undodir=$HOME/.vimundo//&#xA;&#xA;command WriteUndo setlocal undofile | w | setlocal noundofile&#xA;command ReadUndo setlocal undofile | e | setlocal noundofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;a href=&quot;https://vimhelp.org/undo.txt.html#%3Arundo&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :rundo&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/undo.txt.html#%3Awundo&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :wundo&lt;/a&gt; to manually read and write undo history if you prefer not to store the undo history file in &lt;code&gt;undodir&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update to address OP's update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a bit surprise that no error would occur if &lt;code&gt;undodir&lt;/code&gt; doesn't exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You setting is over complicated, AFAIK, &lt;code&gt;persistant-undo&lt;/code&gt; was added in &lt;code&gt;vim7.3&lt;/code&gt;, that's long long long ago, I also don't see the point of checking multiple undo directories, you might want to simplify it to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set undofile undodir=~/.vim/temp_dirs/undodir&#xA;if !isdirectory(&amp;amp;undodir)&#xA;  call system('mkdir -p ' . &amp;amp;undodir)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-11-30T12:48:12.853" LastActivityDate="2019-11-30T12:48:12.853" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="22108" PostTypeId="2" ParentId="22101" CreationDate="2019-11-30T09:40:53.477" Score="6" Body="&lt;p&gt;One possible solution is to do the calculation by yourself and add them in your status line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you will need a function which returns as a string your current position as a decimal percentage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetCurrentPosition()&#xA;    return printf('%.2f%%', ( 100.0 * line('.') / line('$') ))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function uses &lt;code&gt;line('.')&lt;/code&gt; to get the position of the cursor and &lt;code&gt;line('$')&lt;/code&gt; to get the total number of lines in the buffer. If also uses &lt;code&gt;printf()&lt;/code&gt; to convert the result to a string, keeping only 2 decimal numbers and using &lt;code&gt;%%&lt;/code&gt; to add a literal percent sign.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can add the result of this function to your statusline like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{GetCurrentPosition()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you should get your desired result:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u8pTt.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u8pTt.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-11-30T09:40:53.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22109" PostTypeId="2" ParentId="20474" CreationDate="2019-11-30T10:45:23.093" Score="1" Body="&lt;p&gt;If you just want to set the syntax always to &lt;code&gt;context&lt;/code&gt;, just put this in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd BufReadPost *.tex set syntax=context&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16706" LastActivityDate="2019-11-30T10:45:23.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22111" PostTypeId="2" ParentId="22102" CreationDate="2019-12-01T13:07:09.597" Score="1" Body="&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I have tested the above process in vim(not it vscode extension). It didn't worked so the answer is for general vim.&lt;/p&gt;&#xA;&lt;h3&gt;Using Regular expressions&lt;/h3&gt;&#xA;&lt;p&gt;The solution to the first problem is to use &amp;quot;very magic&amp;quot; mode of regex. In very magic mode the characters except &lt;code&gt;a-zA-Z0-9&lt;/code&gt; and  &lt;code&gt;_&lt;/code&gt;  have a special meaning. You can enable very magic mode by putting &lt;code&gt;\v&lt;/code&gt; in start of regex.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\v(\w+\(\w*\))/function \1/g&#xA;    ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you don't want to put \v each time check out &lt;a href=&quot;https://stackoverflow.com/questions/3760444/in-vim-is-there-a-way-to-set-very-magic-permanently-and-globally&quot;&gt;In vim, is there a way to set “very magic” permanently and globally?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Using macros&lt;/h3&gt;&#xA;&lt;p&gt;In the following steps you can record the macro.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;press &lt;code&gt;qm&lt;/code&gt; to start recording macro.&lt;/li&gt;&#xA;&lt;li&gt;Go the start of the line using &lt;code&gt;^&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;i&lt;/code&gt; to enter insert mode and enter &lt;code&gt;function &lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Go the normal mode.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;/\v(\w+\(\w*\))&lt;/code&gt; to search for next method.&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;n&lt;/code&gt; to go the next method. Press &lt;code&gt;q&lt;/code&gt; to complete recording macro.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Go the first method and use &lt;code&gt;n@m&lt;/code&gt; where &lt;code&gt;n&lt;/code&gt; is total number of methods to which you want add &lt;code&gt;function&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="25893" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-12-01T13:07:09.597" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22112" PostTypeId="1" CreationDate="2019-12-01T14:09:51.703" Score="0" ViewCount="128" Body="&lt;p&gt;I am using vim8 on windows 7. The problem is what whenever I try to paste a unicode character from somewhere else it doesn't work instead it shows. For example when I try to enter &lt;code&gt;⇛&lt;/code&gt; It shows a question mark inside a square &lt;code&gt;?&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output of of &lt;code&gt;:version&lt;/code&gt; is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled May 18 2018 18:36:07)&#xA;MS-Windows 32-bit GUI version with OLE support&#xA;Included patches: 1&#xA;Compiled by mool@tororo&#xA;Huge version with GUI.  Features included (+) or not (-):&#xA;+acl                +comments           +farsi              +linebreak          +packages           +startuptime        +user_commands&#xA;+arabic             +conceal            +file_in_path       +lispindent         +path_extra         +statusline         +vertsplit&#xA;+autocmd            +cryptv             +find_in_path       +listcmds           +perl/dyn           -sun_workshop       +virtualedit&#xA;+autoservername     +cscope             +float              +localmap           +persistent_undo    +syntax             +visual&#xA;+balloon_eval       +cursorbind         +folding            +lua/dyn            -postscript         +tag_binary         +visualextra&#xA;-balloon_eval_term  +cursorshape        -footer             +menu               +printer            +tag_old_static     +viminfo&#xA;+browse             +dialog_con_gui     +gettext/dyn        +mksession          +profile            -tag_any_white      +vreplace&#xA;++builtin_terms     +diff               -hangul_input       +modify_fname       +python/dyn         +tcl/dyn            -vtp&#xA;+byte_offset        +digraphs           +iconv/dyn          +mouse              +python3/dyn        -termguicolors      +wildignore&#xA;+channel            +directx            +insert_expand      +mouseshape         +quickfix           +terminal           +wildmenu&#xA;+cindent            -dnd                +job                +multi_byte_ime/dyn +reltime            -tgetent            +windows&#xA;+clientserver       -ebcdic             +jumplist           +multi_lang         +rightleft          -termresponse       +writebackup&#xA;+clipboard          +emacs_tags         +keymap             +mzscheme/dyn       +ruby/dyn           +textobjects        -xfontset&#xA;+cmdline_compl      +eval               +lambda             +netbeans_intg      +scrollbind         +timers             -xim&#xA;+cmdline_hist       +ex_extra           +langmap            +num64              +signs              +title              +xpm_w32&#xA;+cmdline_info       +extra_search       +libcall            +ole                +smartindent        +toolbar            -xterm_save&#xA;   system vimrc file: &quot;$VIM\vimrc&quot;&#xA;     user vimrc file: &quot;$HOME\_vimrc&quot;&#xA; 2nd user vimrc file: &quot;$HOME\vimfiles\vimrc&quot;&#xA; 3rd user vimrc file: &quot;$VIM\_vimrc&quot;&#xA;      user exrc file: &quot;$HOME\_exrc&quot;&#xA;  2nd user exrc file: &quot;$VIM\_exrc&quot;&#xA;  system gvimrc file: &quot;$VIM\gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME\_gvimrc&quot;&#xA;2nd user gvimrc file: &quot;$HOME\vimfiles\gvimrc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is my minimal vimrc file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fileencodings=utf-8&#xA;scriptencoding utf-8&#xA;if has(&quot;gui_running&quot;)&#xA;  if has(&quot;gui_gtk2&quot;)&#xA;    set guifont=Inconsolata\ 12&#xA;  elseif has(&quot;gui_macvim&quot;)&#xA;    set guifont=Menlo\ Regular:h14&#xA;  elseif has(&quot;gui_win32&quot;)&#xA;    set guifont=Consolas:h13&#xA;  endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Some the characters work fine. But majority doesn't.&lt;/p&gt;&#xA;" OwnerUserId="25893" LastActivityDate="2019-12-01T14:09:51.703" Title="Some of unicode characters doesn't work in vim" Tags="|vimrc|gvim|font|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22113" PostTypeId="1" AcceptedAnswerId="22115" CreationDate="2019-12-01T14:11:48.910" Score="1" ViewCount="541" Body="&lt;p&gt;I'm currently exploring ways to iterate through all buffers in vim and am confused by the behavior of &lt;code&gt;NERDTree&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I displayed the &lt;code&gt;NERDTree&lt;/code&gt; directory tree and expected that the viewport is bound to some buffer. But the &lt;code&gt;:ls&lt;/code&gt; command did not show the buffer that is diplayed in the &lt;code&gt;NERDTree&lt;/code&gt;'s viewport:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gadYH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gadYH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the viewport on which NERDTree displays the directory tree bound to some buffer? If no, how does NERDTree display the content?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastEditorUserId="1238" LastEditDate="2019-12-18T11:09:54.870" LastActivityDate="2019-12-18T11:09:54.870" Title="NERDTree is not displayed in buffer list" Tags="|vimrc|buffers|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22114" PostTypeId="2" ParentId="22103" CreationDate="2019-12-01T14:54:49.627" Score="0" Body="&lt;p&gt;After trying out many different ways of opening and editing the file, it appears the issue is that with the &quot;production code&quot; (.module) file, the user snrub was not the owner of the file. I guess in order for persistent undo to work, the user editing the file must be the owner. And &lt;code&gt;chmod&lt;/code&gt; file permissions are irrelevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Works:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim filename.module&lt;/code&gt; for file owned by &lt;code&gt;snrub:snrub&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sudo vim filename.module&lt;/code&gt; for file owned by &lt;code&gt;root:root&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does not work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim filename.module&lt;/code&gt; for file owned by &lt;code&gt;apache:apache&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sudo vim filename.module&lt;/code&gt; for file owned by &lt;code&gt;apache:apache&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9047" LastActivityDate="2019-12-01T14:54:49.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22115" PostTypeId="2" ParentId="22113" CreationDate="2019-12-01T15:09:02.943" Score="3" Body="&lt;p&gt;NERDTree does a great many things that are... unvim-like... in order to give the IDE “project drawer” experience. I consider most of them hacks, and I’m wary of a plugin which has to hack around default behaviors and usages to do something I don’t need (see &lt;a href=&quot;http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Oil and Vinegar&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of that said, one of its hacks is actually quite normal—it’s an unlisted buffer (I believe). You can check the &lt;code&gt;'buftype'&lt;/code&gt; option, or use &lt;code&gt;:ls!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Netrw actually does similar things most of the time, regarding unlisting buffers. It’s convenient not to have “non-file” buffers not appear in the regular buffer list. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-12-01T15:09:02.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22117" PostTypeId="1" CreationDate="2019-12-01T23:58:09.390" Score="0" ViewCount="46" Body="&lt;p&gt;Without &lt;code&gt;'undofile'&lt;/code&gt;, one can hold &lt;code&gt;u&lt;/code&gt; or execute &lt;code&gt;undo 0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;'undofile'&lt;/code&gt;, everything changed, hold &lt;code&gt;u&lt;/code&gt; will undo changes made in older sessions, &lt;code&gt;undo 0&lt;/code&gt; will undo the entire undo history, they became useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:earlier 2h&lt;/code&gt; family command only works on certain conditions, it's not so useful if you create a new vim session in a short time after you close one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the &lt;a href=&quot;https://github.com/mbbill/undotree&quot; rel=&quot;nofollow noreferrer&quot;&gt;undotree&lt;/a&gt; plugin, but have no idea how to use it to do this job, trying saved text state is not an option.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-12-01T23:58:09.390" Title="How to undo all changes in current session when undofile is on?" Tags="|undo-redo|" AnswerCount="0" CommentCount="5" ClosedDate="2019-12-02T03:07:22.690" ContentLicense="CC BY-SA 4.0" />
  <row Id="22118" PostTypeId="1" AcceptedAnswerId="27271" CreationDate="2019-12-02T01:56:40.623" Score="0" ViewCount="122" Body="&lt;p&gt;I want to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:asciiart = [&quot;&quot;, &quot;&quot;, s:hardinclude(system(&quot;command params&quot;)), &quot;&quot;, &quot;&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;command&lt;/code&gt; returns one string with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;art-line-1&quot;, &quot;art-line-2&quot;, &quot;art-line-3&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s:asciiart == [&quot;&quot;, &quot;&quot;, &quot;art-line-1&quot;, &quot;art-line-2&quot;, &quot;art-line-3&quot;, &quot;&quot;, &quot;&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make a working &lt;code&gt;s:hardinclude()&lt;/code&gt;? How? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="25873" LastEditorUserId="25873" LastEditDate="2019-12-02T02:02:27.477" LastActivityDate="2020-09-13T15:10:58.777" Title="&quot;Hard-include&quot; in vim script" Tags="|vimscript|external-command|include|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22119" PostTypeId="1" AcceptedAnswerId="22123" CreationDate="2019-12-02T04:46:02.427" Score="2" ViewCount="1008" Body="&lt;p&gt;I'm configuring my scripts to work with terminal in VIM and have a question regarding &lt;code&gt;:h special-buffers&lt;/code&gt;. Among mentioned kinds there were the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;unlisted    The buffer is not in the buffer list.  It is not used for&#xA;            normal editing, but to show a help file, remember a file name&#xA;            or marks.  The &amp;quot;:bdelete&amp;quot; command will also set this option,&#xA;            thus it doesn't completely delete the buffer.  Settings: &amp;gt;&#xA;            :setlocal nobuflisted&#xA;&#xA;terminal    A terminal window buffer, see |terminal|. The contents cannot&#xA;            be read or changed until the job ends.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Currently I create a terminal buffer with the function&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! CreateTerminalInstance()&#xA;    execute &amp;quot;terminal ++hidden&amp;quot; &#xA;    return bufnr(&amp;quot;$&amp;quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;then stores the &lt;code&gt;bufnr&lt;/code&gt; of the terminal and use it throughout the session.&lt;/p&gt;&#xA;&lt;p&gt;The problem is when switching between buffers containing code to be displayed in some window with &lt;code&gt;:bnext&lt;/code&gt; it sometimes displays the terminal in the window. This is because the terminal appears in the buffer list:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kE7e1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kE7e1.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So I considered making this buffer with &lt;code&gt;:setlocal nobuflisted&lt;/code&gt;, but it looks hacky since now the terminal buffer has two kinds: &lt;code&gt;terminal&lt;/code&gt; and &lt;code&gt;unlisted&lt;/code&gt; as I show above.&lt;/p&gt;&#xA;&lt;p&gt;What is the preferred way to achieve switching between buffers corresponding to regular opened files?&lt;/p&gt;&#xA;" OwnerUserId="9409" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-12-02T07:08:22.930" Title="Making terminal buffer unlisted" Tags="|vimrc|vimscript|buffers|terminal-buffer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22120" PostTypeId="2" ParentId="22118" CreationDate="2019-12-02T05:04:30.670" Score="0" Body="&lt;p&gt;Although it would still be fine to find out if a &quot;hard-include&quot; would be possible, I answer my own question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have changed my &lt;code&gt;command&lt;/code&gt; to return a CSV, as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;art-1,art-2,art3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then, from the vim script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:asciiart = [&quot;&quot;, &quot;&quot;] + split(system(&quot;command args&quot;), &quot;,&quot;) + [&quot;&quot;, &quot;&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...well, solved the problem, but did not exactly answered the question. Not sure if should be marked as solved.&lt;/p&gt;&#xA;" OwnerUserId="25873" LastActivityDate="2019-12-02T05:04:30.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22121" PostTypeId="2" ParentId="22118" CreationDate="2019-12-02T05:43:21.093" Score="2" Body="&lt;p&gt;If you can guarantee your original format, you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;split(system(command), ',\s\+')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But CSV (as in the self-answer) is probably cleanest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, have the outputs on their own lines and use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;systemlist(command)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim unfortunately doesn't have an &quot;explode&quot; operator that I am aware of.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-12-02T05:43:21.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22122" PostTypeId="2" ParentId="22118" CreationDate="2019-12-02T06:32:24.293" Score="1" Body="&lt;p&gt;As an alternative, you can use &lt;code&gt;:h eval()&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:asciiart = eval('[&quot;&quot;, &quot;&quot;, ' . trim(system(&quot;command args&quot;)) . ', &quot;&quot;, &quot;&quot;]')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;system()&lt;/code&gt; output includes extra newline(s), so you have to deal with it.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-02T06:32:24.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22123" PostTypeId="2" ParentId="22119" CreationDate="2019-12-02T07:08:22.930" Score="6" Body="&lt;p&gt;First, your function can be simplified into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let bufnr = term_start(&amp;amp;shell, {&quot;hidden&quot;: 1})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second, it's not a problem to have &lt;code&gt;buftype ==# 'terminal'&lt;/code&gt; and &lt;code&gt;set nobuflisted&lt;/code&gt; together, as these are two different options. So&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if bufnr&#xA;    call setbufvar(bufnr, &quot;buflisted&quot;, 0)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is very much okay. However, the real question is: why you create a terminal at all if you are never going to show it? Maybe, you want &lt;code&gt;job_start()&lt;/code&gt; instead?&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-02T07:08:22.930" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22124" PostTypeId="1" AcceptedAnswerId="22133" CreationDate="2019-12-02T10:27:58.953" Score="1" ViewCount="507" Body="&lt;p&gt;I'm having a problem with using imaps with &lt;code&gt;vimtex&lt;/code&gt; (i.e they don't work).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test the issue I went to &lt;code&gt;.vim/plugged/vimtex/test/examples/minimal&lt;/code&gt; and started &lt;code&gt;vim -u minivimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typing `a (which is a AltGr-7 and the &quot;a&quot; key, since I have a Hungarian keyboard) doesn't do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I manually set this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap `a \alpha&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then typing `a expands to \alpha, so I am really unsure what I am doing wrong. I quite new to vim, so maybe I just totall misunderstood how I should be using it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt;&#xA;I didn't know how to capture the output, so I made a screenshot of the output of &lt;code&gt;:imap `a&lt;/code&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/HLM0n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HLM0n.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25312" LastEditorUserId="25312" LastEditDate="2019-12-02T19:19:24.127" LastActivityDate="2019-12-03T00:57:40.623" Title="vimtex imap not working" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22125" PostTypeId="2" ParentId="2387" CreationDate="2019-12-02T12:28:34.130" Score="3" Body="&lt;p&gt;For me, this problem keeps showing up even if I delete the &lt;code&gt;~/.viminfo&lt;/code&gt; file - not right away, but a couple of days later. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just noticed there's a way to skip using the viminfo file entirely, as detailed here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://unix.stackexchange.com/a/332707/22734&quot;&gt;https://unix.stackexchange.com/a/332707/22734&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In summary, put the following in your &lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let skip_defaults_vim=1&#xA;set viminfo=&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9850" LastEditorUserId="9850" LastEditDate="2019-12-02T13:34:41.267" LastActivityDate="2019-12-02T13:34:41.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22126" PostTypeId="1" AcceptedAnswerId="22127" CreationDate="2019-12-02T13:19:12.963" Score="3" ViewCount="266" Body="&lt;p&gt;I am using nvim-qt on Windows and I have set up the &lt;code&gt;clipboard&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard=unnamedplus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found that text in Select mode will go to the &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;&quot;&lt;/code&gt; register after I start to type the replacement text. If I have copied something into the &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; register, it will get wiped out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to prevent this behavior? i.e., prevent text selected in Select mode from going into the &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; registers? I can't seem to find the documentation on this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I ask this question because the &lt;code&gt;link&lt;/code&gt; snippet in ultisnips will create a snippet template with &lt;code&gt;Text&lt;/code&gt; in Select mode, as soon as you start typing something, &lt;code&gt;Text&lt;/code&gt; disappears and is put into &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; register, which is really annoying.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastEditorUserId="15292" LastEditDate="2019-12-02T15:33:51.823" LastActivityDate="2019-12-02T15:33:51.823" Title="How not to let text in selection mode go to registers" Tags="|register|select-mode|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22127" PostTypeId="2" ParentId="22126" CreationDate="2019-12-02T14:07:41.447" Score="5" Body="&lt;p&gt;Vim doesn't want you to lose the deleted text, so it stores the replaced selection in the default register; due to your &lt;code&gt;'clipboard'&lt;/code&gt; configuration, this includes the clipboard. The usual way to avoid that is through specifying the &lt;a href=&quot;https://vimhelp.appspot.com/change.txt.html#quote_&quot; rel=&quot;noreferrer&quot;&gt;black hole register&lt;/a&gt;, but that's difficult in select mode. You can switch to &lt;em&gt;visual mode&lt;/em&gt; (&lt;code&gt;&amp;lt;C-G&amp;gt;&lt;/code&gt;) and then do the replacing via &lt;code&gt;&quot;_&lt;/code&gt; (black hole) &lt;code&gt;c&lt;/code&gt; (change selection): &lt;code&gt;&amp;lt;C-G&amp;gt;&quot;_c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: There are also the &lt;code&gt;autoselect[plus]&lt;/code&gt; values of &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27clipboard%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'clipboard'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27go-a%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help 'go-a'&lt;/code&gt;&lt;/a&gt; that already work when you just &lt;em&gt;make&lt;/em&gt; a selection. Based on what you describe, this doesn't apply to you.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-12-02T14:07:41.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22128" PostTypeId="2" ParentId="22126" CreationDate="2019-12-02T14:08:49.893" Score="2" Body="&lt;p&gt;You did two Evils, and then the third Evil came and seized you. So what is an advice you seek for? &quot;Select mode&quot; and &quot;Clipboard&quot; are pure evil. Remove them from your vimrc and forget for good. Always make it Vim-way, or switch to the Notepad for eternity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, seriously&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I can't seem to find the documentation on this.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:h select-mode&lt;/code&gt;: &quot;Printable characters, NL and CR cause the selection to be &lt;strong&gt;deleted&lt;/strong&gt;&quot;. In Vim &quot;deleted&quot; is the same as &quot;cut&quot; in other editors. Now, you've crippled your Vim to use a single plus-register for nearly everything, and then - surprise! - it gets overwritten. You really can't do anything about it.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-02T14:08:49.893" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22129" PostTypeId="1" AcceptedAnswerId="22131" CreationDate="2019-12-02T19:17:33.303" Score="12" ViewCount="2944" Body="&lt;p&gt;Is there a list of keys which aren't mapped by default in vim? / gvim?&lt;/p&gt;&#xA;" OwnerUserId="301" LastEditorUserId="301" LastEditDate="2023-01-24T06:36:56.410" LastActivityDate="2023-01-24T06:36:56.410" Title="Which keys are free / unmapped by default in VIM?" Tags="|key-bindings|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22130" PostTypeId="2" ParentId="13219" CreationDate="2019-12-02T19:42:44.663" Score="1" Body="&lt;p&gt;Assuming you have commands &lt;code&gt;decrypt&lt;/code&gt; and &lt;code&gt;encrypt&lt;/code&gt; that use stdout and stdin:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;# open vim using stdin&#xA;decrypt secret.msg | vim -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then after you edit the file in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;:w !encrypt secret2.msg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is equivalent to sending the vim buffer to the pipe &lt;code&gt;| encrypt secret2.msg&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that should avoid creating temporary files, assuming you have set all the &lt;a href=&quot;https://vi.stackexchange.com/questions/6177/the-simplest-way-to-start-vim-in-private-mode&quot;&gt;private vim options&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6610" LastActivityDate="2019-12-02T19:42:44.663" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22131" PostTypeId="2" ParentId="22129" CreationDate="2019-12-02T20:31:33.603" Score="16" Body="&lt;h1&gt;Free Keys&lt;/h1&gt;&#xA;&#xA;&lt;h2&gt;Normal Mode&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-K&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-_&amp;gt;&lt;/code&gt; (Same as &lt;code&gt;&amp;lt;C-/&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; (Same as &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-@&amp;gt;&lt;/code&gt; (Same as &lt;code&gt;&amp;lt;C-Space&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Visual Mode&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-T&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-K&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-@&amp;gt;&lt;/code&gt; (Same as &lt;code&gt;&amp;lt;C-Space&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Q&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Z&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-_&amp;gt;&lt;/code&gt; (Same as &lt;code&gt;&amp;lt;C-/&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt; (This is the &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; key)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Insert Mode&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-_&amp;gt;&lt;/code&gt; (Same as &lt;code&gt;&amp;lt;C-/&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-Z&amp;gt;&lt;/code&gt; (Unless &lt;code&gt;insertmode&lt;/code&gt; is set)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-B&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Command-line Mode&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-@&amp;gt;&lt;/code&gt; (Same as &lt;code&gt;&amp;lt;C-Space&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-Z&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-_&amp;gt;&lt;/code&gt; (Only active in default vim if &lt;code&gt;allowrevins&lt;/code&gt; is set, for right-to-left languages)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-X&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;All Modes&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All function keys&lt;/li&gt;&#xA;&lt;li&gt;All &lt;code&gt;ALT&lt;/code&gt; key combinations&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-S&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Used source: &lt;a href=&quot;https://vim.fandom.com/wiki/Unused_keys&quot; rel=&quot;noreferrer&quot;&gt;https://vim.fandom.com/wiki/Unused_keys&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This link points to a page listing unused keys in vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This page also lists keys that are synonyms of other keys in terms of functionality, meaning that these keys can be safely remapped.  &lt;/p&gt;&#xA;" OwnerUserId="20735" LastEditorUserId="20735" LastEditDate="2019-12-04T06:55:56.963" LastActivityDate="2019-12-04T06:55:56.963" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22132" PostTypeId="2" ParentId="11776" CreationDate="2019-12-02T22:22:21.990" Score="-1" Body="&lt;p&gt;Use &lt;code&gt;:[range]g/.*/put&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;[range]&lt;/code&gt; is what ex accepts (ie. &lt;code&gt;n,m&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt;, &lt;code&gt;.,$&lt;/code&gt;, etc.).&lt;/p&gt;&#xA;" OwnerUserId="25925" LastEditorUserId="10604" LastEditDate="2019-12-03T02:20:35.780" LastActivityDate="2019-12-03T02:20:35.780" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22133" PostTypeId="2" ParentId="22124" CreationDate="2019-12-03T00:57:40.623" Score="2" Body="&lt;p&gt;Please note that the &lt;code&gt;`a&lt;/code&gt; mapping is using &lt;code&gt;vimtex#imaps#wrap_math()&lt;/code&gt;, which only expands to the right hand side when typed in a math context. (See &lt;a href=&quot;https://github.com/lervag/vimtex/blob/02829dee17a3d70889b5a0151a2f747754a0e2c4/autoload/vimtex/imaps.vim#L119&quot; rel=&quot;nofollow noreferrer&quot;&gt;the code in vimtex&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, this mapping will only expand to &lt;code&gt;\alpha&lt;/code&gt; if typed in a math context, such as within &lt;code&gt;$...$&lt;/code&gt;, inside a &lt;code&gt;\begin{equation}...\end{equation}&lt;/code&gt; block, or in a similar context that is considered to be a &quot;math&quot; context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(vimtex uses the syntax engine to determine what is a &quot;math&quot; context, see &lt;a href=&quot;https://github.com/lervag/vimtex/blob/02829dee17a3d70889b5a0151a2f747754a0e2c4/autoload/vimtex/imaps.vim#L157&quot; rel=&quot;nofollow noreferrer&quot;&gt;definition of &lt;code&gt;is_math()&lt;/code&gt;&lt;/a&gt;. In particular, that means you need to have &lt;code&gt;syntax enable&lt;/code&gt; to be able to use that, since otherwise it won't recognize the &quot;math&quot; blocks correctly and will never apply the expansion.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-03T00:57:40.623" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22134" PostTypeId="1" AcceptedAnswerId="22165" CreationDate="2019-12-03T10:13:49.570" Score="1" ViewCount="663" Body="&lt;p&gt;For editing XML files I have the following in my init.vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Automatically enable folding of XML-files&#xA;augroup XML&#xA;  autocmd!&#xA;  autocmd FileType xml let g:xml_syntax_folding=1&#xA;  autocmd FileType xml setlocal foldmethod=syntax&#xA;  autocmd FileType xml :syntax on&#xA;  autocmd FileType xml :%foldopen!&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is fine for small files. From times to times I will edit large (huge) XML-files which open much faster without folding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My way of doing is to open an new buffer,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ft=xml  # Which yields an error message because the buffer is empty and no folds can be found&#xA;setlocal foldmethod=manual&#xA;:r &amp;lt;file&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better way of disabling folding for a buffer before the file is loaded?&lt;/p&gt;&#xA;" OwnerUserId="11633" LastEditorUserId="11633" LastEditDate="2019-12-03T10:30:57.937" LastActivityDate="2019-12-05T08:03:16.613" Title="Prevent VIM from folding a large file" Tags="|folding|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22135" PostTypeId="2" ParentId="22134" CreationDate="2019-12-03T10:44:12.527" Score="3" Body="&lt;h3&gt;Automatic detections&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1506&quot; rel=&quot;nofollow noreferrer&quot;&gt;LargeFile plugin&lt;/a&gt; automatically disables many options to increase performance, but its exact actions cannot be influenced, so it'll do more than what you have in mind (like completely turning off syntax highlighting for that buffer). You could re-use its mechanism (of hooking into &lt;a href=&quot;https://vimhelp.appspot.com/autocmd.txt.html#BufReadPre&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;BufReadPre&lt;/code&gt;&lt;/a&gt;) for your purpose, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is just for a particular set of XML files together with your config, I would probably just add a simple conditional:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType xml if line('$') &amp;gt; 9999 | setlocal nofoldenable | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of checking the number of lines, you could also check file size (&lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#getfsize%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getfsize()&lt;/code&gt;&lt;/a&gt;) or other file attributes.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Manual control&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Your current approach with &lt;code&gt;:read&lt;/code&gt; is ugly and has many downsides. Unfortunately, the filetype detection flow is not designed to be influenced; built-in features like &lt;a href=&quot;https://vimhelp.appspot.com/editing.txt.html#%2Bcmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help +cmd&lt;/code&gt;&lt;/a&gt; will run too late, so you cannot avoid the penalty of the very first parsing of folds. You'd have to somehow delay the application of &lt;code&gt;setlocal foldmethod=syntax&lt;/code&gt;, e.g. via a fire-once autocmd, in the worst case only on &lt;code&gt;CursorHold,CursorMoved&lt;/code&gt;. With that, you could load the xml via &lt;code&gt;:edit +let\ b:nofold=1 large.xml&lt;/code&gt; or as a compound filetype: &lt;code&gt;:edit +setf\ xml.large large.xml&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'd strongly favor the automatic detection, as you don't have to think about it.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-12-03T10:44:12.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22136" PostTypeId="2" ParentId="22134" CreationDate="2019-12-03T10:49:51.027" Score="0" Body="&lt;p&gt;I would do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; global variable only needs to be set once&#xA;let g:xml_syntax_folding=1&#xA;&#xA;augroup XML | au!&#xA;    &quot; start with all folds open for the current window&#xA;    &quot; or you can setglobal foldlevelstart=99&#xA;    &quot; if you like open folds for all file types&#xA;    autocmd FileType xml setlocal foldmethod=syntax foldlevel=99&#xA;&#xA;    &quot; what is huge exactly?&#xA;    &quot; btw. it should be line2byte(line('$')+1)-1 but we don't need to be precise&#xA;    autocmd FileType xml let &amp;amp;foldenable = (line2byte('$') &amp;lt; 1*1024*1024*1024)&#xA;&#xA;    &quot; do you really need this one?&#xA;    autocmd FileType xml syntax on&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-03T10:49:51.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22137" PostTypeId="1" CreationDate="2019-12-03T15:18:34.303" Score="1" ViewCount="83" Body="&lt;p&gt;I'm aware of vim menu and plugins such as &lt;code&gt;vim-venu&lt;/code&gt; and &lt;code&gt;quickmenu&lt;/code&gt;, but they need to be manually configured. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to populate vim menus with all commands available organized in a hierarchical structure based on (for instance) the installed plugins from which each command derives?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking to a way to find commands for which you don't remember the name. Something like spacemacs. You open the menu, see the options (e.g. plugins or integrated), chose one (e.g. plugins), chose a plugin (e.g. FZF), chose a command from that plugin... In all of this you don't have to exactly remember any name, neither the plugin itself, and you can also &quot;discover&quot; some new feature, maybe&lt;/p&gt;&#xA;" OwnerUserId="25936" LastEditorUserId="10604" LastEditDate="2019-12-04T13:35:27.027" LastActivityDate="2019-12-04T13:35:27.027" Title="Hierarchical auto-populated menu" Tags="|plugin-system|wildmenu|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22138" PostTypeId="1" CreationDate="2019-12-03T15:35:33.280" Score="0" ViewCount="367" Body="&lt;p&gt;I have set up Vim to trigger reformatting on save using ALE, but sometimes that doesn't fly very well, and  would like to disable it manually. But remembering what the right incantations are is always impossible, needing to grep my dotfiles for clues, so I'd like to be able to toggle it, say, using Alt-F8. That means some kind of vimscript function that just sets &lt;code&gt;let g:ale_fix_on_save = 0&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would such a function look and how do I bind it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Bonus points for showing how to toggle the value)&lt;/p&gt;&#xA;" OwnerUserId="1087" LastActivityDate="2019-12-04T00:01:01.623" Title="Toggle a setting using shortcut" Tags="|functions|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22139" PostTypeId="1" CreationDate="2019-12-03T15:48:43.263" Score="1" ViewCount="454" Body="&lt;p&gt;If I open a file, add a line (&lt;code&gt;o&lt;/code&gt;), and then delete that line (&lt;code&gt;dd&lt;/code&gt;) making the file exactly the same as when it was opened, upon exiting (&lt;code&gt;:q&lt;/code&gt;), Neovim states:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E37: No write since last change (add ! to override)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This behavior did not exist previously. I recently updated some packages though. How can I get back being able to exit without saving after making a change and then undoing that change?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Further Research&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If I undo the change (&lt;code&gt;u&lt;/code&gt;) instead of deleting the line that was added (&lt;code&gt;dd&lt;/code&gt;), Neovim will quit without requiring a save or ! to override.&lt;/p&gt;&#xA;" OwnerUserId="4624" LastEditorUserId="4624" LastEditDate="2019-12-03T15:54:47.753" LastActivityDate="2019-12-04T10:28:27.300" Title="After undoing changes, Neovim still requires saving file or ! before exit" Tags="|vimrc|neovim|" AnswerCount="1" CommentCount="4" ClosedDate="2019-12-05T12:35:59.970" ContentLicense="CC BY-SA 4.0" />
  <row Id="22140" PostTypeId="2" ParentId="22138" CreationDate="2019-12-03T16:31:05.643" Score="2" Body="&lt;p&gt;[While &lt;a href=&quot;https://vi.stackexchange.com/questions/22138/toggle-a-setting-using-shortcut#comment40044_22138&quot;&gt;B Layer is right&lt;/a&gt; that this question should demonstrate attempts (in order that answers address conceptual misunderstandings), the answer is at least straightforward.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To toggle a &quot;boolean&quot; variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let x = !x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the mapping is simply&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;your keys&amp;gt; :let g:ale_fix_on_save = !g:ale_fix_on_save&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-12-04T00:01:01.623" LastActivityDate="2019-12-04T00:01:01.623" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22141" PostTypeId="1" AcceptedAnswerId="22142" CreationDate="2019-12-03T16:38:42.887" Score="6" ViewCount="2129" Body="&lt;p&gt;When I have a very long line in vim it will be shown on the screen as multiple lines, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line no. | content                                           |&#xA;100      | this is a very looooooooooooooooooooooooooooooooo | &#xA;         | ooooooooooooooooooooooooooooooooooooooooooooooooo | &#xA;         | ooooooong line!                                   |&#xA;101      | this is the next line                             |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I type &lt;code&gt;k&lt;/code&gt; on line 101 I will jump to the first line of line 100 (which is very counter-intuitive for me), is there a way that I could type 3 &lt;code&gt;k&lt;/code&gt;s from line 101 to navigate the line 100?&lt;/p&gt;&#xA;" OwnerUserId="25941" LastEditorUserId="48490" LastEditDate="2023-08-30T13:30:46.457" LastActivityDate="2023-08-30T13:30:46.457" Title="How to navigate long lines like separate lines?" Tags="|cursor|wrapping|navigation|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22142" PostTypeId="2" ParentId="22141" CreationDate="2019-12-03T16:54:44.757" Score="11" Body="&lt;p&gt;You can use the &lt;code&gt;gj&lt;/code&gt; and &lt;code&gt;gk&lt;/code&gt; commands to move the cursor to the character in the next or previous &lt;em&gt;display&lt;/em&gt; lines, even when lines wrap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/motion.txt.html#gj&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help gj&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/motion.txt.html#gk&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help gk&lt;/code&gt;&lt;/a&gt; for details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like to navigate those display lines using &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt;, you can remap them in your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap j gj&#xA;nnoremap k gk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Beware that these remappings have side effects, for instance commands such as &lt;code&gt;dj&lt;/code&gt; will behave differently even on lines that are not wrapped, since &lt;code&gt;gj&lt;/code&gt; is not a linewise motion while &lt;code&gt;j&lt;/code&gt; is. (The original &lt;code&gt;dj&lt;/code&gt; will delete two lines, while the modified one won't.)&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="18609" LastEditDate="2019-12-04T11:25:27.443" LastActivityDate="2019-12-04T11:25:27.443" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22143" PostTypeId="2" ParentId="15944" CreationDate="2019-12-03T17:28:02.417" Score="3" Body="&lt;p&gt;Apart from the native support as indicated by @Hotschke, you may want to try &lt;a href=&quot;https://github.com/henrik/vim-indexed-search&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-indexed-search&lt;/a&gt;. This plugin also summarizes several similar plugins in its GitHub homepage.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-12-03T17:28:02.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22145" PostTypeId="1" CreationDate="2019-12-04T00:45:06.983" Score="4" ViewCount="4836" Body="&lt;p&gt;I am trying to map &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;(&lt;/kbd&gt; in insert mode. However, Vim does not recognize the key binding. This is what I currently have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Insert a pair of brackets using Ctrl-(&#xA;inoremap &amp;lt;C-(&amp;gt; ()&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does vim ignore the key binding?&lt;/p&gt;&#xA;" OwnerUserId="19712" LastActivityDate="2019-12-04T07:37:28.840" Title="How to map Ctrl-(?" Tags="|key-bindings|" AnswerCount="3" CommentCount="2" ClosedDate="2019-12-04T09:20:24.120" ContentLicense="CC BY-SA 4.0" />
  <row Id="22146" PostTypeId="2" ParentId="22145" CreationDate="2019-12-04T01:57:34.620" Score="1" Body="&lt;p&gt;Try &lt;code&gt;inoremap &amp;lt;C-9&amp;gt; ()&amp;lt;Left&amp;gt;&lt;/code&gt;. It seems that Vim does not recognize the &lt;code&gt;(&lt;/code&gt; in insert mapping.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-12-04T01:57:34.620" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22147" PostTypeId="1" AcceptedAnswerId="22148" CreationDate="2019-12-04T05:36:09.390" Score="1" ViewCount="95" Body="&lt;p&gt;I tried the following in my &lt;code&gt;.vimrc&lt;/code&gt; using the hints I found &lt;a href=&quot;https://vi.stackexchange.com/a/19070/6370&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;Tab&amp;gt; i4&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt;&#xA;map &amp;lt;F2&amp;gt; /79*&amp;lt;CR&amp;gt;79*/&amp;lt;CR&amp;gt;PROGRAM&amp;lt;Space&amp;gt;NAME&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first mapping inserts a &lt;code&gt;4&lt;/code&gt; while the behavior that I expected is to insert 4 whitespaces characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the second one throws the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E486: Pattern not found: 79*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;while I expected it to produce the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*******************************************************************************&#xA;PROGRAM NAME    :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there something up there that I'm doing wrong or there's something I'm missing here?&lt;/p&gt;&#xA;" OwnerUserId="6370" LastEditorUserId="1841" LastEditDate="2019-12-04T09:17:01.987" LastActivityDate="2019-12-04T09:17:01.987" Title="Repeat/copy a character sequence using commands" Tags="|key-bindings|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22148" PostTypeId="2" ParentId="22147" CreationDate="2019-12-04T06:14:39.537" Score="3" Body="&lt;p&gt;For the first one, exchange &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;4&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Tab&amp;gt; 4i&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt; &quot; inserts 4 space characters&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;i&lt;/code&gt; starts insert mode and whatever you &quot;type&quot; is inserted into text. If you pass &lt;code&gt;count&lt;/code&gt; before &lt;code&gt;i&lt;/code&gt;, whatever you type afterwards would be repeated &lt;code&gt;count&lt;/code&gt; times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the second one -- not sure what it is supposed to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;For the second one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; i/&amp;lt;esc&amp;gt;79a*&amp;lt;esc&amp;gt;oPROGRAM NAME    :&amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;i/&amp;lt;esc&amp;gt;&lt;/code&gt; -- insert &lt;code&gt;/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;79a*&amp;lt;esc&amp;gt;&lt;/code&gt; -- add 79 stars&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;oPROGRAM NAME    :&amp;lt;esc&amp;gt;&lt;/code&gt; -- &lt;code&gt;o&lt;/code&gt;pen new line and insert &lt;code&gt;PROGRAM NAME    :&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;better use &lt;code&gt;nnoremap&lt;/code&gt; instead of &lt;code&gt;map&lt;/code&gt; as it is more specific for normal mode and it uses no remapped key sequences (imagine you have remapped &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;o&lt;/code&gt; and other used keys to smth else...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PPS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally would go with functions, like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! CstyleHeader()&#xA;    let stars = repeat('*', 79)&#xA;    let lines = ['/' . stars, 'PROGRAM NAME    :', stars . '/']&#xA;    call append('.', lines)&#xA;endfunc&#xA;map &amp;lt;F2&amp;gt; :call CstyleHeader()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2019-12-04T06:35:50.097" LastActivityDate="2019-12-04T06:35:50.097" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22149" PostTypeId="1" AcceptedAnswerId="22621" CreationDate="2019-12-04T06:25:55.660" Score="2" ViewCount="453" Body="&lt;p&gt;I ran into a problem with cursor color being reset when using gruvbox color scheme on both Linux and Windows. During debugging I discovered that the &lt;strong&gt;color scheme is reloaded if vimrc is located in $VIM&lt;/strong&gt;. In my test case I have &lt;strong&gt;only two user files&lt;/strong&gt;: &lt;strong&gt;vimrc&lt;/strong&gt; and &lt;strong&gt;$VIM/vimfiles/colors/kgb.vim&lt;/strong&gt; (the rest is the standard vim installation). I set &lt;strong&gt;VIMINIT&lt;/strong&gt; to &lt;strong&gt;&lt;em&gt;&quot;source $VIM\vimrc&quot;&lt;/em&gt;&lt;/strong&gt; to control which vimrc is loaded.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set|grep VIM&#xA;MYVIMRC=C:\Users\Public\Vim\vimrc&#xA;VIM=C:\Users\Public\Vim&#xA;VIMINIT=source C:\Users\Public\Vim\vimrc&#xA;VIMRUNTIME=E:\Vim\vim81&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd %VIM%&#xA;&#xA;find vim*&#xA;vimfiles&#xA;vimfiles/colors&#xA;vimfiles/colors/kgb.vim&#xA;vimrc&#xA;&#xA;cat vimrc&#xA;echomsg &quot;Before colo: &quot; . execute(&quot;colo&quot;)&#xA;color kgb&#xA;echomsg &quot;After colo: &quot; . execute(&quot;colo&quot;)&#xA;&#xA;cat vimfiles/colors/kgb.vim&#xA;echomsg &quot;Executing script: &quot; . expand(&quot;&amp;lt;sfile&amp;gt;&quot;)&#xA;let g:colors_name=&quot;kgb&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim.exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:mes&#xA;Before colo: ^@default&#xA;Executing script: C:\Users\Public\Vim\vimfiles\colors\kgb.vim&#xA;After colo: ^@kgb&#xA;Before colo: ^@kgb&#xA;Executing script: C:\Users\Public\Vim\vimfiles\colors\kgb.vim&#xA;After colo: ^@kgb&#xA;Executing script: C:\Users\Public\Vim\vimfiles\colors\kgb.vim&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE: The above output shows that vimrc is loaded twice and colorscheme is loaded three times in Windows (only two times on Linux). If VIMINIT is not set and vimrc is located in $VIM, then vimrc is loaded only once, but colorsheme is still loaded twice on both Windows and Linux.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:scr&#xA;  1: C:\Users\Public\Vim\vimrc&#xA;  2: C:\Users\Public\Vim\vimfiles\colors\kgb.vim&#xA;  3: E:\Vim\vim81\plugin\getscriptPlugin.vim&#xA;  4: E:\Vim\vim81\plugin\gzip.vim&#xA;  5: E:\Vim\vim81\plugin\logiPat.vim&#xA;  6: E:\Vim\vim81\plugin\manpager.vim&#xA;  7: E:\Vim\vim81\plugin\matchparen.vim&#xA;  8: E:\Vim\vim81\plugin\netrwPlugin.vim&#xA;  9: E:\Vim\vim81\plugin\rrhelper.vim&#xA; 10: E:\Vim\vim81\plugin\spellfile.vim&#xA; 11: E:\Vim\vim81\plugin\tarPlugin.vim&#xA; 12: E:\Vim\vim81\plugin\tohtml.vim&#xA; 13: E:\Vim\vim81\plugin\vimballPlugin.vim&#xA; 14: E:\Vim\vim81\plugin\zipPlugin.vim&#xA; 15: E:\Vim\vim81\menu.vim&#xA; 16: E:\Vim\vim81\autoload\paste.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:quit&#xA;Error:&#xA;Executing script: C:\Users\Public\Vim\vimfiles\colors\kgb.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I move vimrc under vimfiles and set &lt;strong&gt;VIMINIT=&quot;source $VIM\vimfiles\vimrc&quot;&lt;/strong&gt; the scheme is loaded only once:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set|grep VIM&#xA;MYVIMRC=C:\Users\Public\Vim\vimfiles\vimrc&#xA;VIM=C:\Users\Public\Vim&#xA;VIMINIT=source C:\Users\Public\Vim\vimfiles\vimrc&#xA;VIMRUNTIME=E:\Vim\vim81&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim.exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:mes&#xA;Before colo: ^@default&#xA;Executing script: C:\Users\Public\Vim\vimfiles\colors\kgb.vim&#xA;After colo: ^@kgb&#xA;Executing script: C:\Users\Public\Vim\vimfiles\colors\kgb.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:quit&#xA;Error:&#xA;Executing script: C:\Users\Public\Vim\vimfiles\colors\kgb.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Any explanation why this is happening?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="11022" LastEditorUserId="11022" LastEditDate="2020-01-23T14:29:09.857" LastActivityDate="2020-01-23T14:29:09.857" Title="Why colorscheme is re-loaded if vimrc is located in $VIM?" Tags="|colorscheme|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22150" PostTypeId="2" ParentId="22145" CreationDate="2019-12-04T07:31:24.470" Score="5" Body="&lt;p&gt;Vim does not ignore the keybinding. It just can't be reliably detected. See the &lt;a href=&quot;https://vimhelp.org/vim_faq.txt.html#faq-20.5&quot; rel=&quot;noreferrer&quot;&gt;faq&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The only Ctrl-printable-key chords which Vim can reliably detect&#xA;  (because they are defined in the ASCII standard) are the following: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Ctrl-@                 0x00            NUL&#xA;    Ctrl-A to Ctrl-Z       0x01 to 0x1A&#xA;    Ctrl-a to Ctrl-z       0x01 to 0x1A&#xA;    Ctrl-[                 0x1B            ESC&#xA;    Ctrl-\                 0x1C&#xA;    Ctrl-]                 0x1D&#xA;    Ctrl-^                 0x1E&#xA;    Ctrl-_                 0x1F&#xA;    Ctrl-?                 0x7F            DEL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Most of these, however, already have a function in Vim (and some are&#xA;  aliases of other keys: Ctrl-H and Bsp, Ctrl-I and Tab, Ctrl-M and&#xA;  Enter, Ctrl-[ and Esc, Ctrl-? and Del).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The &quot;safest&quot; keys to use in Vim for the {lhs} of a mapping are the F&#xA;  keys, with or without Shift:  to  and  to .&#xA;  (Some OSes, including mine, intercept Ctrl-Fn and Alt-Fn, which never&#xA;  reach an application program such as vim or gvim).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You can try other combinations of Ctrl + any key, but they may either&#xA;  not work everywhere (e.g. the terminal might not pass that key to Vim,&#xA;  or they might have unintended side effects (e.g. mapping  means&#xA;  also to map ).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-12-04T07:31:24.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22151" PostTypeId="2" ParentId="22145" CreationDate="2019-12-04T07:37:28.840" Score="3" Body="&lt;p&gt;Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like &lt;kbd&gt;Ctrl&lt;/kbd&gt; + non-alphabetic cannot be mapped, and &lt;kbd&gt;Ctrl&lt;/kbd&gt; + letter vs. &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;Shift&lt;/kbd&gt; + letter cannot be distinguished. (Unless your terminal sends a distinct &lt;em&gt;termcap&lt;/em&gt; code for it, which most don't.) In insert or command-line mode, try typing the key combination. If nothing happens / is inserted, you cannot use that key combination. This also applies to &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-I&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-M&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; etc. (Only exception is &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;C-H&amp;gt;&lt;/code&gt;.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_dev/Ym6D-kWIsyo&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://groups.google.com/forum/#!topic/vim_dev/Ym6D-kWIsyo&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim release.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-12-04T07:37:28.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22152" PostTypeId="2" ParentId="22139" CreationDate="2019-12-04T10:28:27.300" Score="2" Body="&lt;p&gt;This is default behaviour of Vim. Vim notices, the buffer has been modified and just warns you of quitting and (possibly) losing your changes. This is done by setting the &lt;code&gt;modified&lt;/code&gt; option for the buffer you are currently editing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, despite its name, it does not mean that the current buffer differs from the state on disk, but rather whether a change has been done to the buffer being edited, even if it is a no-op, so e.g. &lt;kbd&gt;r&lt;/kbd&gt; with the same letter the cursor is on, will behave the same and set the &lt;code&gt;modified&lt;/code&gt; option, preventing you from an accidental &lt;code&gt;:q&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when undoing, Vim will reset the &lt;code&gt;modified&lt;/code&gt; flag, because this information is also stored in the undo buffer, so that's why it works differently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has been requested to change that behaviour (e.g. in this &lt;a href=&quot;https://github.com/vim/vim/issues/2700&quot; rel=&quot;nofollow noreferrer&quot;&gt;bug&lt;/a&gt;), but that would be a backward incompatible change and I tend to agree. In fact, I do actually like this feature.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-12-04T10:28:27.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22153" PostTypeId="1" CreationDate="2019-12-04T14:23:47.730" Score="1" ViewCount="61" Body="&lt;p&gt;Is there a way to close file after certain amount of time of user inactivity?&#xA;Lets say I have a encrypted file and I want to close it after 10 min. &#xA;Is it possible in Vim?&lt;/p&gt;&#xA;" OwnerUserId="16328" LastActivityDate="2019-12-04T14:40:47.817" Title="How to close file/buffer/tab after cerain time of inactivity?" Tags="|buffers|vim-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22154" PostTypeId="2" ParentId="22153" CreationDate="2019-12-04T14:40:47.817" Score="1" Body="&lt;p&gt;&lt;em&gt;Yes, but it doesn't come for free in the form of a ready-to-use option; some assembly required:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you define activity as changes done to the buffer, you can periodically sample &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#b%3Achangedtick&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;b:changedtick&lt;/code&gt;&lt;/a&gt;, and record (in a buffer-local variable) a timestamp (&lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#localtime%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help localtime()&lt;/code&gt;&lt;/a&gt;) when it changes. If activity includes movements, you can do the same with the cursor position (&lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#getpos%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getpos()&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That sampling can be done with &lt;a href=&quot;https://vimhelp.appspot.com/autocmd.txt.html#%3Aautocmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:autocmd&lt;/code&gt;&lt;/a&gt;; the &lt;a href=&quot;https://vimhelp.appspot.com/autocmd.txt.html#CursorHold&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;CursorHold&lt;/code&gt;&lt;/a&gt; event can be used for triggering (as long as you allow some flexibility about the time frame for enforcement; as it only fires when Vim is idle).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For closing, this is a lot easier if you're only interested in the &lt;em&gt;current&lt;/em&gt; buffer / tab page; you just need to sample the current buffer / all visible buffers, and can then use a simple &lt;a href=&quot;https://vimhelp.appspot.com/windows.txt.html#%3Abdelete&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:bdelete&lt;/code&gt;&lt;/a&gt; / &lt;a href=&quot;https://vimhelp.appspot.com/tabpage.txt.html#%3Atabclose&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:tabclose&lt;/code&gt;&lt;/a&gt;. If you also want to kick out other buffers, you'll need to use &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#getbufvar%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getbufvar()&lt;/code&gt;&lt;/a&gt; to sample all buffers (without moving to it).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-12-04T14:40:47.817" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22155" PostTypeId="1" AcceptedAnswerId="22156" CreationDate="2019-12-04T15:16:31.233" Score="1" ViewCount="88" Body="&lt;p&gt;Is it possible to silently run an external command, but show the output on the prompt only if there was any?&lt;/p&gt;&#xA;" OwnerUserId="25959" LastActivityDate="2019-12-04T16:03:18.837" Title="Showing external command output only if not empty" Tags="|neovim|command-line|external-command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22156" PostTypeId="2" ParentId="22155" CreationDate="2019-12-04T16:03:18.837" Score="0" Body="&lt;p&gt;If by external command you do mean shell commands then you can try using &lt;code&gt;system&lt;/code&gt; function &lt;code&gt;:h system()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No output (on Windows)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:output = system(&quot;title&quot;)&#xA;if s:output != ''&#xA;    echom s:output&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:output = system(&quot;date&quot;)&#xA;if s:output != ''&#xA;    echom s:output&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-12-04T16:03:18.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22157" PostTypeId="1" CreationDate="2019-12-04T18:39:58.137" Score="1" ViewCount="303" Body="&lt;p&gt;I want to search and replace occurrences of&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;$this-&amp;gt;close_db();&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$this-&amp;gt;stmt-&amp;gt;close();&#xA;$this-&amp;gt;database-&amp;gt;close();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which occurs on lines 73-74 (with indentations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is a quick and simple way of doing this without plugins? I'm also too lazy to write out &lt;code&gt;$this-&amp;gt;close_db()&lt;/code&gt; and would like to simply reference it via one of the the lines it is on (line 89), without indentations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something like &lt;code&gt;:%s/Trim@#89/#[73;;74]/g;AutoFormat&lt;/code&gt; (pseudocode)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: Feel free to share methods that use non-obscure plugins or scripts too.&lt;/p&gt;&#xA;" OwnerDisplayName="user25814" LastEditorDisplayName="user25814" LastEditDate="2019-12-04T20:33:30.337" LastActivityDate="2019-12-05T06:43:35.357" Title="Search a term and replace with line numbers" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22158" PostTypeId="2" ParentId="22157" CreationDate="2019-12-04T19:49:32.560" Score="1" Body="&lt;p&gt;I don't think it could be simplified more without using mappings or writing specialized commands and/or functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; setup search pattern&#xA;:let @/ = '\V' . trim(getline(89))&#xA;&quot; or you can input it interactively after the first :g/...&#xA;&quot; with the help of :h c_ctrl-r_=&#xA;&#xA;&quot; get replacement text&#xA;:73,74y&#xA;&quot; put (paste) with indent adjust&#xA;:g//normal! ]p&#xA;&quot; delete old stuff&#xA;:g//d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-12-05T06:43:35.357" LastActivityDate="2019-12-05T06:43:35.357" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22159" PostTypeId="1" AcceptedAnswerId="22164" CreationDate="2019-12-05T00:08:20.600" Score="5" ViewCount="9737" Body="&lt;p&gt;I want to create a regex that matches strings within single or double quotes in vim and that considers the fact that some strings might have escaped single quotes or double quotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, I've found &lt;a href=&quot;https://stackoverflow.com/questions/171480/regex-grabbing-values-between-quotation-marks&quot;&gt;this answer&lt;/a&gt; in an stackoverflow question which does the same thing but in Javascript regex flavor. By using the logic of that regex, I tried to write a regular expression but in vim regex flavor.  The reasoning I followed for translating the javascript regex to a vim regex is explained below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;([&quot;'])(?:(?=(\\?))\2.)*?\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;([&quot;'])&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Definition&lt;/strong&gt;: capture group of single or double quotes&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;vim&lt;/code&gt; equivalent&lt;/strong&gt;: &lt;code&gt;([&quot;'])&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;(?:(?=(\\?))\2.)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Definition&lt;/strong&gt;: Non-capturing group of &lt;code&gt;(?=(\\?))\2.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;vim&lt;/code&gt; equivalent&lt;/strong&gt;: &lt;code&gt;%((\\?)@=\2.)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(?=(\\?))&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Definition&lt;/strong&gt;: Positive lookahead of &lt;code&gt;(\\?)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;vim&lt;/code&gt; equivalent&lt;/strong&gt;: &lt;code&gt;(\\?)@=&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\2&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Definition&lt;/strong&gt;: Backreference to &lt;code&gt;\\?&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;vim&lt;/code&gt; equivalent&lt;/strong&gt;: &lt;code&gt;\2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Definition&lt;/strong&gt;: Matches any character different from line breaks&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;vim&lt;/code&gt; equivalent&lt;/strong&gt;: &lt;code&gt;.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;*?&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Definition&lt;/strong&gt;: Non-greedy operator of  &lt;code&gt;(?:(?=(\\?))\2.)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;vim&lt;/code&gt; equivalent&lt;/strong&gt;: &lt;code&gt;{-}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\1&lt;/code&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Definition&lt;/strong&gt;: Backreference to &lt;code&gt;[&quot;']&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;vim&lt;/code&gt; equivalent&lt;/strong&gt;: &lt;code&gt;\1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;By following the reasoning explained above, the following Javascript regex&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;([&quot;'])(?:(?=(\\?))\2.)*?\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would be equivalent to the following vim regex&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v([&quot;'])%((\\?)@=\2.){-}\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this regex does not completely mimick the behavior of the Javascript regex, because it matches some patterns (see image below) that are not matched by the Javascript regex presented above &lt;a href=&quot;https://regex101.com/r/z1ArJl/1/&quot; rel=&quot;nofollow noreferrer&quot;&gt;(see what the latter matches here)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/a2gt1m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/a2gt1m.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is the vim regex matching any character that follows a single quote or a double quotes given that the last character of the regex is a backreference to a single quote or a double quote?&lt;/p&gt;&#xA;" OwnerUserId="22995" LastEditorUserId="22995" LastEditDate="2020-05-31T20:13:42.007" LastActivityDate="2020-05-31T20:13:42.007" Title="Grabbing values between quotation marks" Tags="|regular-expression|search|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22160" PostTypeId="1" CreationDate="2019-12-05T00:24:01.097" Score="10" ViewCount="3164" Body="&lt;p&gt;I just started using buffers in Vim and I couldn't figure out how to list recent closed buffers. Is there a simple way (like &lt;code&gt;:ls&lt;/code&gt;) to list those? Are they actually stored by Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe I'm misusing buffers, but what I want to do is to glance at recent closed buffers and then reopen (&lt;code&gt;:e&lt;/code&gt;) one of those (of which at that moment I don't remember the (file)name).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched &lt;code&gt;windows.txt&lt;/code&gt; (from &lt;code&gt;:help buffers&lt;/code&gt;) for terms like &lt;code&gt;history&lt;/code&gt;, &lt;code&gt;closed buffer&lt;/code&gt;, &lt;code&gt;buffer closed&lt;/code&gt;, but none of them got me closer to doing what I want.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I tried &lt;code&gt;:oldfiles&lt;/code&gt; (as &lt;a href=&quot;https://vi.stackexchange.com/users/10604/d-ben-knoble&quot;&gt;D. Ben Knoble&lt;/a&gt; suggested) but that doesn't seem to work as I'd expect. When I'm viewing one file (buffer) &lt;code&gt;A.file&lt;/code&gt; and open another one &lt;code&gt;B.file&lt;/code&gt; (using NERDTree) and just after that I close &lt;code&gt;B.file&lt;/code&gt;, then &lt;code&gt;:oldfiles&lt;/code&gt; doesn't show &lt;code&gt;B.file&lt;/code&gt; on the list.&lt;/p&gt;&#xA;" OwnerUserId="22234" LastEditorUserId="22234" LastEditDate="2019-12-05T01:38:52.563" LastActivityDate="2022-01-23T18:14:03.393" Title="Is there a way to list recent buffer history?" Tags="|buffers|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22161" PostTypeId="2" ParentId="22159" CreationDate="2019-12-05T01:55:47.763" Score="3" Body="&lt;p&gt;In the department of simplified versions this may do...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v(['&quot;]).{-}[^\\]\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I say &quot;may&quot; as I wouldn't stake my life on there being zero failing corner cases but it passes your tests and and every other I've tried so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &quot;very magic&quot; that's...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;(['&quot;])&lt;/code&gt; - capture a quote&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.{-}&lt;/code&gt; - non-greedy slurp (of all but two characters...see next)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[^\\]\1&lt;/code&gt; - match non-escaped quote of the same type as the opener&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Seems almost too simple! But avoiding the potential performance hits of things like look(ahead|behind)s, if possible, is a good thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may have noticed that this ignores &quot;empty strings&quot; (&lt;code&gt;''&lt;/code&gt;, &lt;code&gt;&quot;&quot;&lt;/code&gt;). If we want to include them there's still no need to resort to complex atoms. Alternations, often overlooked as a KISS option, should work here. Something like...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(''|&quot;&quot;|(['&quot;]).{-}[^\\]\2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; A comment mentioned a corner case issue: pairs of backslashes. If you're concerned about that case this'll solve it. (Still look(ahead|behind) free but getting a little longer):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(['&quot;])(\\(\\|\1)|[^\\]){-}[^\\]*\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With empty string matching:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(&quot;&quot;|''|(['&quot;])(\\(\\|\2)|[^\\]){-}[^\\]*\2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-12-05T05:28:52.300" LastActivityDate="2019-12-05T05:28:52.300" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22162" PostTypeId="1" AcceptedAnswerId="22183" CreationDate="2019-12-05T02:34:22.623" Score="1" ViewCount="247" Body="&lt;p&gt;I have following line in my &lt;code&gt;.nvimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;au! BufWritePost *.elm ElmMake&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Each time I save an elm file vim tells me that this command does not exist.&#xA;However I am able to run this command in command more while editing elm file, so there is no doubt in my mind that this command does exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should point out that &lt;code&gt;ElmMake&lt;/code&gt; command came with filetype plugin so apparently commands in vimrc are ran in different filetype(&lt;code&gt;vim&lt;/code&gt;?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which leads me to my question how can  I access file type specific commands inside my vimrc?&lt;/p&gt;&#xA;" OwnerUserId="5827" LastActivityDate="2019-12-06T01:57:58.817" Title="Auto Command fails with file plugin command" Tags="|neovim|autocmd|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22163" PostTypeId="2" ParentId="22162" CreationDate="2019-12-05T04:11:31.963" Score="1" Body="&lt;p&gt;Looks like you try to add an autocommand but remove it instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3. Removing autocommands                *autocmd-remove*&#xA;&#xA;:au[tocmd]! [group] {event} {pat} [++once] [++nested] {cmd}&#xA;            Remove all autocommands associated with {event} and&#xA;            {pat}, and add the command {cmd}.&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try it without exclamation mark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, generally it is a good idea to put autocommands to autogroups, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup ELM_MAKE | autocmd!&#xA;    au BufWritePost *.elm ElmMake&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It creates autocommand group and cleans it up with &lt;code&gt;autocmd!&lt;/code&gt; before any autocommand definition. Otherwise each reload of your vimrc (&lt;code&gt;:so $MYVIMRC&lt;/code&gt; for example) would create duplicate autocommands.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-12-05T04:11:31.963" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22164" PostTypeId="2" ParentId="22159" CreationDate="2019-12-05T04:29:49.157" Score="7" Body="&lt;p&gt;You can solve that with this regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v(['&quot;])%(\1@![^\\]|\\.)*\1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will solve all of your test cases, plus others such as &lt;code&gt;&quot;\\&quot;&lt;/code&gt; or &lt;code&gt;'\\'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explaining it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\v&lt;/code&gt;: Use &quot;verymagic&quot; mode, so we don't need to backslash parens, etc.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(['&quot;])&lt;/code&gt;: Matches either a single or double quote and store it in &lt;code&gt;\1&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;%(...)*&lt;/code&gt;: Then match zero or more of:&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\1@![^\\]&lt;/code&gt;: A single character that does not match the quote itself (&lt;code&gt;\1@!&lt;/code&gt; is a negative lookahead for whatever is in the capture group) or a backslash. So any character other than those. (Or a newline, that's also not matched by the &lt;code&gt;[...]&lt;/code&gt; expression.)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;|&lt;/code&gt;: Or...&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\\.&lt;/code&gt;: A backslash followed by any character. Including a second backslash, or the quote, whatever the quoting style was.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\1&lt;/code&gt;: Finally, a matching closing quote.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The trick is to &quot;skip&quot; the character following the escaping backslash, whatever it is. This also has the effect that pairs of backslashes are fine, before the closing quote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The negative lookahead in this regex might turn out to be somewhat inconvenient and could make it expensive to run. An alternative is to expand it into two separate matches, for each style of quotes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; \v'%([^'\\]|\\.)*'|&quot;%([^&quot;\\]|\\.)*&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's exactly the same idea, just using the fact that we can shorten the single character match to &lt;code&gt;[^'\\]&lt;/code&gt; or &lt;code&gt;[^&quot;\\]&lt;/code&gt;, since we know exactly which quote was used to open the string in this case. We also no longer need the capturing group and the backreference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tested to match all of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;a&quot;&#xA;'a a'&#xA;'a&quot;a'&#xA;&quot;a''a&quot;&#xA;&quot;a'\&quot;\&quot;'a&quot;&#xA;&quot;\&quot;\&quot;\&quot;&quot;&#xA;&quot;\\&quot;&#xA;&quot;&quot;&#xA;''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And not to match any of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;a&#xA;&quot;\&quot;&#xA;&quot;a'&#xA;'a&quot;&#xA;'\\\'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-05T04:29:49.157" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22165" PostTypeId="2" ParentId="22134" CreationDate="2019-12-05T08:03:16.613" Score="0" Body="&lt;p&gt;First I applogize for answering my own question, I know this is bad style. However my preferred solution is a mixture of the answers given by @Matt and @Ingo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point is that for large files you really want to avoid foldmethod=syntax from the beginning. &lt;code&gt;foldenable&lt;/code&gt; just hides the folds, they still get &quot;computed&quot;. And it's the computation of the folds which costs a lot of time, not so much the display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My solution which works well is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup XML | au!&#xA;  autocmd FileType xml let g:xml_syntax_folding=1&#xA;  autocmd FileType xml if (line2byte('$') &amp;lt; 1*32*1024*1024) | setlocal foldmethod=syntax | endif&#xA;  autocmd FileType xml silent! :%foldopen!&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11633" LastActivityDate="2019-12-05T08:03:16.613" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22167" PostTypeId="2" ParentId="22160" CreationDate="2019-12-05T08:22:35.707" Score="0" Body="&lt;p&gt;You can try to improve my naive attempt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot; if you want real list&#xA;&quot; let g:mru_buffers = []&#xA;&quot;&quot; or just a string with newlines&#xA;let g:mru_buffers = &quot;&quot;&#xA;func! RecordMRU(file)&#xA;    if a:file != '' &quot; here you can add another check if buffer/file is in mru and either do nothing or move it in the list/string to top&#xA;        &quot; call insert(g:mru_buffers, a:file)&#xA;        let g:mru_buffers .= a:file . &quot;\n&quot;&#xA;    endif&#xA;endfunc&#xA;augroup mru_list | au!&#xA;    au BufDelete * call RecordMRU(expand('&amp;lt;afile&amp;gt;'))&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Having this you can list recently closed buffers with &lt;code&gt;echo g:mru_buffers&lt;/code&gt;, or make a command &lt;code&gt;:command MRU :echo g:mru_buffers&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't have persistence but one can easily add it.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-12-05T08:22:35.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22168" PostTypeId="1" AcceptedAnswerId="22170" CreationDate="2019-12-05T09:02:51.590" Score="3" ViewCount="422" Body="&lt;p&gt;I tried to use the arithmetic register with a fraction (7/8) and it returned 0! How do I exert better control over the register so that it gives me what I want?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The literal sequence I used, while in insert mode: &lt;code&gt;&amp;lt;C-R&amp;gt;=(7/8)&amp;lt;enter&amp;gt;&lt;/code&gt; result: &lt;code&gt;0&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="158" LastActivityDate="2019-12-05T09:29:24.523" Title="Expression register and fractions" Tags="|arithmetic|expression-register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22169" PostTypeId="2" ParentId="84" CreationDate="2019-12-05T09:12:07.033" Score="2" Body="&lt;h2&gt;&lt;a href=&quot;https://macvim-dev.github.io/macvim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MacVim&lt;/a&gt; &lt;code&gt;Cmd + x/c/v&lt;/code&gt; for cut/copy/paste&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you use MacVim, the usual &lt;code&gt;Cmd+x/c/v&lt;/code&gt; are defined in &lt;a href=&quot;https://github.com/macvim-dev/macvim/blob/master/runtime/macmap.vim#L48-L57&quot; rel=&quot;nofollow noreferrer&quot;&gt;$VIMRUNTIME/macmap.vim&lt;/a&gt; which is sourced by default and hence are available without configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;special&amp;gt; &amp;lt;D-x&amp;gt; &quot;+x&#xA;&#xA;vnoremap &amp;lt;special&amp;gt; &amp;lt;D-c&amp;gt; &quot;+y&#xA;&#xA;cnoremap &amp;lt;special&amp;gt; &amp;lt;D-c&amp;gt; &amp;lt;C-Y&amp;gt;&#xA;&#xA;nnoremap &amp;lt;special&amp;gt; &amp;lt;D-v&amp;gt; &quot;+gP&#xA;cnoremap &amp;lt;special&amp;gt; &amp;lt;D-v&amp;gt; &amp;lt;C-R&amp;gt;+&#xA;execute 'vnoremap &amp;lt;script&amp;gt; &amp;lt;special&amp;gt; &amp;lt;D-v&amp;gt;' paste#paste_cmd['v']&#xA;execute 'inoremap &amp;lt;script&amp;gt; &amp;lt;special&amp;gt; &amp;lt;D-v&amp;gt;' paste#paste_cmd['i']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, using them can lead to vim user who do not know the vim way and are lost on a foreign computer/environment.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-12-05T09:12:07.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22170" PostTypeId="2" ParentId="22168" CreationDate="2019-12-05T09:29:24.523" Score="7" Body="&lt;p&gt;As none of your numbers contains a decimal point (&lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#floating-point-format&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help floating-point-format&lt;/code&gt;&lt;/a&gt;), Vim treats the expression as &lt;em&gt;integer division&lt;/em&gt;, and also gives an integer result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply specify one or both numbers as floats, and you'll get the expected result: &lt;code&gt;&amp;lt;C-R&amp;gt;=7.0/8&amp;lt;CR&amp;gt;&lt;/code&gt; gives &lt;code&gt;0.875&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more control (number of digits, precision, padding), use &lt;a href=&quot;https://vimhelp.appspot.com/eval.txt.html#printf%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;printf()&lt;/code&gt;&lt;/a&gt; with the corresponding format specifications.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-12-05T09:29:24.523" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22171" PostTypeId="1" AcceptedAnswerId="22173" CreationDate="2019-12-05T09:46:46.363" Score="4" ViewCount="94" Body="&lt;p&gt;While I was studying Tpope's vim-commentary, I was struck by a line that contains the topic of this question.&#xA;I am referring to one of the lines in Tpope's vim-commentary:&#xA;&lt;a href=&quot;https://github.com/tpope/vim-commentary/blob/f8238d70f873969fb41bf6a6b07ca63a4c0b82b1/plugin/commentary.vim#L101&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tpope/vim-commentary/blob/f8238d70f873969fb41bf6a6b07ca63a4c0b82b1/plugin/commentary.vim#L101&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt;   &amp;lt;Plug&amp;gt;CommentaryLine &amp;lt;SID&amp;gt;go() . '_'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does &lt;code&gt;. '_'&lt;/code&gt; mean in the context where the statement is followed by a function call?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;SID&amp;gt;go()&lt;/code&gt; function has some side effect of transforming a text(i.e. &lt;a href=&quot;https://github.com/tpope/vim-commentary/blob/f8238d70f873969fb41bf6a6b07ca63a4c0b82b1/plugin/commentary.vim#L65&quot; rel=&quot;nofollow noreferrer&quot;&gt;commenting a line&lt;/a&gt;) and returns &lt;a href=&quot;https://github.com/tpope/vim-commentary/blob/f8238d70f873969fb41bf6a6b07ca63a4c0b82b1/plugin/commentary.vim#L74&quot; rel=&quot;nofollow noreferrer&quot;&gt;an empty string&lt;/a&gt;, does that mean &lt;code&gt;&amp;lt;SID&amp;gt;go()&lt;/code&gt; evaluates to empty string which is concatenated by '_' due to &lt;code&gt;. '_'&lt;/code&gt;? I am not so sure because of the name of the mapping &lt;code&gt;&amp;lt;Plug&amp;gt;CommentaryLine&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="25969" LastActivityDate="2019-12-05T17:25:23.207" Title="What does &lt;SID&gt;some_function() . '_' mean? in particular, . '_' part" Tags="|key-bindings|plugin-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22172" PostTypeId="2" ParentId="22171" CreationDate="2019-12-05T10:04:12.350" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;does that mean go() evaluates to empty string which is concatenated by &quot;_&quot;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In short, yes, it does. &lt;code&gt;_&lt;/code&gt; is a normal mode command to move cursor on the first nonblank character of the current line (when used without count). It gets executed due to &lt;code&gt;:h map-&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-05T10:04:12.350" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22173" PostTypeId="2" ParentId="22171" CreationDate="2019-12-05T17:07:47.743" Score="3" Body="&lt;p&gt;It turns out that, when called without arguments, &lt;code&gt;go()&lt;/code&gt; actually sets &lt;code&gt;'operatorfunc'&lt;/code&gt; and returns &lt;code&gt;'g@'&lt;/code&gt;. (See &lt;a href=&quot;https://github.com/tpope/vim-commentary/blob/f8238d70f873969fb41bf6a6b07ca63a4c0b82b1/plugin/commentary.vim#L28-L30&quot; rel=&quot;nofollow noreferrer&quot;&gt;this code snippet&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the concatenation of &lt;code&gt;'g@' . '_'&lt;/code&gt; results in the &lt;code&gt;g@_&lt;/code&gt; command being executed in normal mode. The &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; in the mapping makes Vim evaluate it as an expression and finally execute the string result as a normal mode command (similar to how &lt;code&gt;:execute normal!&lt;/code&gt; would do, in this particular case.) See &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-%3Cexpr%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :map-&amp;lt;expr&amp;gt;&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;g@&lt;/code&gt; command will wait for a motion and then apply the &lt;code&gt;'operatorfunc'&lt;/code&gt; to that motion. See &lt;a href=&quot;https://vimhelp.org/map.txt.html#g%40&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help g@&lt;/code&gt;&lt;/a&gt;. So you could use, for example, &lt;code&gt;g@}&lt;/code&gt; to apply it to the block going from the current line until the next blank line, or &lt;code&gt;g@ip&lt;/code&gt; to apply it to the paragraph under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;_&lt;/code&gt; motion moves to the beginning of the current line, so in that sense it's somewhat similar to the &lt;code&gt;^&lt;/code&gt; motion, but it has two very important differences from the latter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, it's a &lt;em&gt;linewise&lt;/em&gt; motion, so even though it will stay on the same line, when used as a motion for an operator, it will apply to the whole line and not just the characters from the cursor position to the beginning of the line. (For illustration, place the cursor in the middle of a line and see the difference between &lt;code&gt;d^&lt;/code&gt; and &lt;code&gt;d_&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, when used with a count, it will move to the beginning of the &lt;code&gt;[count] - 1&lt;/code&gt; line below the current one. So &lt;code&gt;5_&lt;/code&gt; will move down 4 lines and go to the beginning of that line (similar to &lt;code&gt;4j^&lt;/code&gt; or &lt;code&gt;4+&lt;/code&gt;.) But that's very useful in a motion for an operator, since when you include the current line up to 4 lines down, you end up with 5 lines, so &lt;code&gt;5_&lt;/code&gt; is actually selecting a block of 5 lines, starting with the current line. (For illustration, see how &lt;code&gt;5d_&lt;/code&gt; will delete 5 lines. That's equivalent to &lt;code&gt;d5_&lt;/code&gt;, the count may precede the operator-pending command as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In effect, many Vi shortcuts doubling a letter are in fact equivalent to using &lt;code&gt;_&lt;/code&gt;. For example, &lt;code&gt;dd&lt;/code&gt; is the same as &lt;code&gt;d_&lt;/code&gt; and &lt;code&gt;yy&lt;/code&gt; is the same as &lt;code&gt;y_&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/motion.txt.html#_&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help _&lt;/code&gt;&lt;/a&gt;. (Though, it's really brief, won't give you all these details and really draw attention to the two important details I highlighted here.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in short, &lt;code&gt;g@_&lt;/code&gt; here will apply the &lt;code&gt;'operatorfunc'&lt;/code&gt; to the current line. It will work on a line, since &lt;code&gt;_&lt;/code&gt; is a linewise motion. It will also take a count and act on a block of &lt;code&gt;[count]&lt;/code&gt; lines, due to the way &lt;code&gt;_&lt;/code&gt; behaves with a count. That's it!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We haven't really covered the &lt;code&gt;'operatorfunc'&lt;/code&gt; being used here. (It's a bit out of scope of your question, but hopefully still on topic.) It turns out the &lt;code&gt;go()&lt;/code&gt; function is using a slightly convoluted way to set &lt;code&gt;'operatorfunc'&lt;/code&gt; to itself. (See &lt;code&gt;:help &amp;lt;sfile&amp;gt;&lt;/code&gt; to see how you get to the function name.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;g@&lt;/code&gt; calls an &lt;code&gt;'operatorfunc'&lt;/code&gt; it passes it a single argument, which indicates whether the motion was linewise, characterwise or blockwise (see &lt;code&gt;:help g@&lt;/code&gt; again for details.) So in case of &lt;code&gt;g@_&lt;/code&gt;, it will call &lt;code&gt;go(&quot;line&quot;)&lt;/code&gt;. Being called with a single argument will arrive at &lt;a href=&quot;https://github.com/tpope/vim-commentary/blob/f8238d70f873969fb41bf6a6b07ca63a4c0b82b1/plugin/commentary.vim#L34&quot; rel=&quot;nofollow noreferrer&quot;&gt;this codepath&lt;/a&gt;, which will make it act on the lines going from &lt;code&gt;'[&lt;/code&gt; to &lt;code&gt;']&lt;/code&gt;, which are the marks set by &lt;code&gt;g@&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, as advertised in the help of the commentary plug-in, the &lt;code&gt;gcc&lt;/code&gt; (comment line) binding will work with a count.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-12-05T17:25:23.207" LastActivityDate="2019-12-05T17:25:23.207" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22174" PostTypeId="1" AcceptedAnswerId="22180" CreationDate="2019-12-05T18:54:31.570" Score="2" ViewCount="221" Body="&lt;p&gt;Consider you are editing the left table in Vim.  Your cursor (■) is at Line 14, Column 12.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Where you are now          Move the cursor&#xA;&#xA;11 +-------+-----+         11 +-------+-----+&#xA;12 | Name  | Age |         12 | Name  | Age |&#xA;13 +=======+=====+         13 +=======+=====+&#xA;14 | Alice | 5■  |   --&amp;gt;   14 | Alice | 5   |&#xA;15 +-------+-----+         15 +-------+-----+&#xA;   ...                        ...&#xA;95 +-------+-----+         95 +-------+-----+&#xA;96 | Zoe   |     |         96 | Zoe   |  ■  |&#xA;97 +-------+-----+         97 +-------+-----+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's the easy way to move your cursor at Line 96, Column 12, i.e., jump to this specific line without moving horizontally?&lt;/p&gt;&#xA;" OwnerUserId="25977" LastActivityDate="2019-12-05T23:33:38.830" Title="Jump to a specific line without moving the cursor horizontally" Tags="|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22175" PostTypeId="1" CreationDate="2019-12-05T19:12:33.667" Score="1" ViewCount="174" Body="&lt;p&gt;I have already &lt;code&gt;set mouse=&lt;/code&gt; and &lt;code&gt;set ttymouse=&lt;/code&gt; but I still get it intercepting paste when I'm trying to paste vim commands, like I want it to do some kind of complex &lt;code&gt;:map! ....&lt;/code&gt; so I copy that from another window and paste it in vim, and instead of having it execute the command it inserts the text at mouse pointer position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also pastes the text at the mouse pointer position instead of at the cursor position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want vim interacting with X11 at all, I want it to act like any other text mode program running in a terminal window or over ssh.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running: vim 8.1 on Raspberry pi.&lt;/p&gt;&#xA;" OwnerUserId="25978" LastActivityDate="2019-12-05T19:12:33.667" Title="How do I unconditionally disable all the &quot;smart&quot; terminal actions in vim" Tags="|terminal|x11|ssh|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22176" PostTypeId="2" ParentId="22174" CreationDate="2019-12-05T19:13:51.193" Score="0" Body="&lt;p&gt;Assuming the 96th line actually has column no. 12 (or &lt;code&gt;set virtualedit=all&lt;/code&gt;), you can do &lt;code&gt;96zz&lt;/code&gt; (or &lt;code&gt;96zt&lt;/code&gt;, or &lt;code&gt;96zb&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h scroll-cursor&lt;/code&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-05T19:13:51.193" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22178" PostTypeId="1" AcceptedAnswerId="22181" CreationDate="2019-12-05T21:38:50.740" Score="1" ViewCount="687" Body="&lt;p&gt;Regardless of which code completion plugin I use (I tried asyncomplete and YouCompleteMe), when there's a completion pop-up, up and down arrow keys select completion options in it instead of moving the cursor. How do I disable this behavior? For me, tab is enough to cycle through completions.&lt;/p&gt;&#xA;" OwnerUserId="25980" LastActivityDate="2019-12-05T23:54:22.597" Title="Completion pop-ups hijack arrow keys. Any way to disable that?" Tags="|key-bindings|autocompletion|plugin-you-complete-me|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22179" PostTypeId="1" CreationDate="2019-12-05T22:35:30.513" Score="1" ViewCount="67" Body="&lt;p&gt;Edit: on Windows, looks like it's opening in sysWOW64 instead of system32. Any ideas why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Title. Basically, both of these commands are supposed to open a new console, the former on my mac and the latter on Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For those familiar with Macs&lt;/strong&gt;, you'll notice when ever you open a application multiple times, for example open chrome and hit cmd+n, it'll open a new window, but it's still under the same &quot;application&quot; on the bottom dock bar. Whenever I do open -a terminal, it seems to pop open a totally new application on the bottom dock bar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For those familiar with Windows&lt;/strong&gt;, you'll notice when you open many instances of chrome or a cmd prompt, they kind of get &quot;shuffled&quot; together, where you can hover on the taskbar to see multiple running instances of the same application; however, similar to my mac, it'll open a totally new cmd prompt, instead of &quot;shuffling&quot; it together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;What's the reason behind this, and do I have to be worried about anything?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="25981" LastEditorUserId="25981" LastEditDate="2019-12-05T22:50:03.147" LastActivityDate="2020-01-18T01:00:45.113" Title="Why does :! open -a terminal or :! start cmd create totally new &quot;applications&quot;?" Tags="|vimscript|vim-windows|macos|shell|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22180" PostTypeId="2" ParentId="22174" CreationDate="2019-12-05T23:33:38.830" Score="4" Body="&lt;p&gt;Turn off &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27startofline%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h 'startofline'&lt;/a&gt; :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set nostartofline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And execute one of the following command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;96G&#xA;:96&#xA;:/Zoe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It will place cursor at target line without moving horizontally if target line is longer enough.&lt;/p&gt;&#xA;&lt;p&gt;Commands starts with &lt;code&gt;:&lt;/code&gt; are ex command, check this &lt;a href=&quot;https://vi.stackexchange.com/questions/21975/whats-the-difference-between-x-and-x&quot;&gt;question&lt;/a&gt; if you are confused about &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;:/&lt;/code&gt; .&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-12-05T23:33:38.830" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22181" PostTypeId="2" ParentId="22178" CreationDate="2019-12-05T23:54:22.597" Score="3" Body="&lt;p&gt;Remap &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt; key to close &lt;code&gt;popup menu&lt;/code&gt; and move cursor up when &lt;code&gt;popup menu&lt;/code&gt; is visible:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;up&amp;gt; pumvisible() ? '&amp;lt;c-e&amp;gt;&amp;lt;up&amp;gt;' : '&amp;lt;up&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :map-expression&lt;/a&gt;&lt;br /&gt;&#xA;&lt;a href=&quot;https://vimhelp.org/insert.txt.html#complete_CTRL-E&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h complete_CTRL-E&lt;/a&gt;&lt;br /&gt;&#xA;&lt;a href=&quot;https://vimhelp.org/eval.txt.html#pumvisible%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h pumvisible()&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-12-05T23:54:22.597" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22182" PostTypeId="1" AcceptedAnswerId="22184" CreationDate="2019-12-06T01:11:00.197" Score="2" ViewCount="119" Body="&lt;p&gt;My space bar no longer works unless I lean my weight on it.  The chances of getting the laptop replaced in a timely manner is close no nil.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mostly use vim or vi, even from the bash command line.  With combinations of the commands below, I've been able to replace &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; with &lt;code&gt;&amp;lt;C-j&amp;gt;&lt;/code&gt; in &lt;code&gt;Normal&lt;/code&gt; and &lt;code&gt;Insert&lt;/code&gt; modes, and even in &lt;code&gt;Command-Line&lt;/code&gt; mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-J&amp;gt; &amp;lt;Space&amp;gt;&#xA;map! &amp;lt;C-J&amp;gt; &amp;lt;Space&amp;gt;&#xA;omap &amp;lt;C-J&amp;gt; &amp;lt;Space&amp;gt;&#xA;map &amp;lt;C-J&amp;gt; &amp;lt;Space&amp;gt;&#xA;lmap &amp;lt;C-J&amp;gt; &amp;lt;Space&amp;gt;&#xA;omap &amp;lt;C-J&amp;gt; &amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't been able to create the mapping in the mode in which I press &lt;code&gt;f&lt;/code&gt;/&lt;code&gt;F&lt;/code&gt; to move forward/backward to the character that is typed next.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What mode would that be?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to map &lt;code&gt;&amp;lt;C-J&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; in that mode?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would have thought that falls under &lt;code&gt;Operator-pending&lt;/code&gt; mode, which falls under the &lt;code&gt;map&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="7041" LastEditorUserId="7041" LastEditDate="2019-12-06T04:56:07.357" LastActivityDate="2019-12-06T04:56:07.357" Title="Map &lt;C-J&gt; to &lt;Space&gt; in all possible modes" Tags="|key-bindings|map-operator|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22183" PostTypeId="2" ParentId="22162" CreationDate="2019-12-06T01:57:58.817" Score="2" Body="&lt;p&gt;I believe the problem you're having is due to the command being registered with &lt;code&gt;-buffer&lt;/code&gt;, which means it's only available in buffers of filetype &quot;elm&quot; and for some reason are not available in the autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why that is happening, I can't really tell... The event you're using (&lt;code&gt;BufWritePost&lt;/code&gt;) is a buffer-specific example and I'd also expect it to run while the buffer is still around... But I might be wrong about that part perhaps...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not the case that this will be evaluated in a filetype &lt;code&gt;vim&lt;/code&gt; context, the autocmd commands are only really evaluated when called, not when they're defined. So not really sure what's going on there...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can try to suggest a workaround though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/ElmCast/elm-vim/blob/165107a9fd2b20c8f050fc4f977b4e41c790b1e7/ftplugin/elm.vim#L44&quot; rel=&quot;nofollow noreferrer&quot;&gt;definition of the &lt;code&gt;ElmMake&lt;/code&gt; command&lt;/a&gt; reads:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -buffer -nargs=? -complete=file ElmMake call elm#Make(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So calling it without any arguments should be the equivalent to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call elm#Make()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So just call that directly from your autocmd instead. The function definition is global and should work from any context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For best practice, put it in an &lt;code&gt;augroup&lt;/code&gt; block, so it gets properly updated when you reload your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc_elm&#xA;  au!&#xA;  au BufWritePost *.elm call elm#Make()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hopefully that will solve the problem!&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-06T01:57:58.817" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22184" PostTypeId="2" ParentId="22182" CreationDate="2019-12-06T02:07:38.377" Score="2" Body="&lt;p&gt;If you look at &lt;code&gt;:h f&lt;/code&gt; you'll see            &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;|:lmap| mappings apply to {char} &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(as in &lt;code&gt;f{char}&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go to &lt;code&gt;:h mapmode-l&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;:lmap&quot; defines a mapping that applies to:&#xA;...&amp;lt;snip&amp;gt;...&#xA;- the argument of the commands that accept a text character, such as &quot;r&quot; and &quot;f&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;lmap &amp;lt;c-j&amp;gt; &amp;lt;space&amp;gt;&lt;/code&gt; ... note, though, that you may need to explicitly enable &lt;code&gt;lmap&lt;/code&gt; mappings by typing &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;^&lt;/kbd&gt; &lt;em&gt;while in Insert mode&lt;/em&gt;. Alternatively, ensure that &lt;code&gt;'iminsert'&lt;/code&gt; is set to 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The docs are misleading about this, btw. What I'm reading is that this setting only applies to use of &lt;code&gt;lmap&lt;/code&gt; mappings used in Insert mode. But a simple test reveals that it applies to the &lt;code&gt;f&lt;/code&gt; family of Normal mode commands. Anyone have a different interpretation of &lt;code&gt;:h 'imi'&lt;/code&gt; and &lt;code&gt;:h mapmode-l&lt;/code&gt;? Am I insane?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI: you can also solve your problem by brute forcing it with &lt;code&gt;:nnoremap f&amp;lt;c-j&amp;gt; f&amp;lt;space&amp;gt;&lt;/code&gt; and for &lt;code&gt;F&lt;/code&gt;,&lt;code&gt;t&lt;/code&gt;,&lt;code&gt;T&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-12-06T04:07:50.777" LastActivityDate="2019-12-06T04:07:50.777" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="22185" PostTypeId="2" ParentId="21439" CreationDate="2019-12-06T06:55:21.150" Score="1" Body="&lt;p&gt;There are currently two great plugins I found that can run commands asynchronously: &lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-dispatch&lt;/a&gt; and &lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;asyncrun.vim&lt;/a&gt;. The two plugins have async support for both Neovim and Vim, but you have to make sure you have relatively new versions of Neovim or Vim (see their home for exact version requirements.)&lt;/p&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-12-06T06:55:21.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22186" PostTypeId="1" AcceptedAnswerId="22187" CreationDate="2019-12-06T08:21:14.983" Score="5" ViewCount="40" Body="&lt;p&gt;Why does &lt;code&gt;y8j&lt;/code&gt; not move the cursor but &lt;code&gt;y8k&lt;/code&gt; does move it up?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What .vimrc entry would prevent yanking upwards moving the cursor?&lt;/p&gt;&#xA;" OwnerUserId="21804" LastActivityDate="2019-12-06T08:40:40.220" Title="Cursor Movement in y8k vs y8j" Tags="|cut-copy-paste|cursor-movement|" AnswerCount="1" CommentCount="1" ClosedDate="2019-12-06T12:55:51.203" ContentLicense="CC BY-SA 4.0" />
  <row Id="22187" PostTypeId="2" ParentId="22186" CreationDate="2019-12-06T08:40:40.220" Score="5" Body="&lt;p&gt;In general, for commands that involve &lt;code&gt;{motion}&lt;/code&gt;, the cursor is placed at the &lt;em&gt;beginning&lt;/em&gt; of the resulting text area. &lt;code&gt;y8j&lt;/code&gt; starts at the current position and moves down, so the cursor does not move. &lt;code&gt;y8k&lt;/code&gt; only includes the current line as the last yanked one, so it moves the cursor to the &lt;em&gt;first&lt;/em&gt; yanked line, i.e. up. The same happens with motions inside a single line, e.g. &lt;code&gt;y8w&lt;/code&gt; (does not move) / &lt;code&gt;y8ge&lt;/code&gt; (moves, as start is before cursor) / &lt;code&gt;yiw&lt;/code&gt; (moves if the cursor is inside the current word vs. at the start of it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To return the cursor to the original position, you can explicitly set a mark and return to it after the yank: &lt;code&gt;m'y8k&amp;#96;&amp;#96;&lt;/code&gt;. Some &lt;a href=&quot;https://vimhelp.appspot.com/motion.txt.html#jump-motions&quot; rel=&quot;noreferrer&quot;&gt;jump-motions&lt;/a&gt; automatically record a jump (but not &lt;code&gt;k&lt;/code&gt;), so you can skip the &lt;code&gt;m'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-12-06T08:40:40.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22188" PostTypeId="2" ParentId="21994" CreationDate="2019-12-06T08:59:37.583" Score="2" Body="&lt;p&gt;You seem to have a bug in your filename glob pattern. The one you showed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*/logs/couchdb/{,.log}{,.[0-9]*,-[0-9]*}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will indeed match files inside a &lt;code&gt;logs/couchdb/&lt;/code&gt; directory, but the last part will only match files named &lt;code&gt;.log&lt;/code&gt; or &lt;code&gt;.789&lt;/code&gt; or &lt;code&gt;-789&lt;/code&gt; or &lt;code&gt;.log.789&lt;/code&gt; or &lt;code&gt;.log-789&lt;/code&gt;. Yes, these are full filenames, only filenames starting with &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;-&lt;/code&gt; are valid. If you want to match any files with a log extension, you need to use &lt;code&gt;*.log&lt;/code&gt; instead. You can then add the second part to also include numbered log files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for example, it seems to me this would work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*/logs/couchdb/*.log{,.[0-9]*,-[0-9]*}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would match &lt;code&gt;test.log&lt;/code&gt; or &lt;code&gt;test.log.789&lt;/code&gt; or &lt;code&gt;test.log-789&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, you might want to just keep it simple and match on the directory name, match any filename, regardless of extension:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*/logs/couchdb/*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't really explain why you're getting a filetype of &lt;code&gt;messages&lt;/code&gt; on that &lt;code&gt;test.log&lt;/code&gt;, since that second pattern isn't really matching that filename either... So I can't really explain it. You might want to use &lt;code&gt;:verbose set filetype?&lt;/code&gt; to understand where it's being set (it will list the rule where it's coming from, with the file and line, so you can easily find it.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming the pattern with the proper &lt;code&gt;*&lt;/code&gt; wildcard for the filename solves your issue, there are a couple other things you might want to consider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, instead of modifying file &lt;code&gt;/usr/share/vim/vim80/filetype.vim&lt;/code&gt; of your Vim installation, create a new user-local file for your user instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a directory &lt;code&gt;~/.vim/ftdetect&lt;/code&gt;. Inside it, create &lt;code&gt;~/.vim/ftdetect/couch_log.vim&lt;/code&gt; with the single line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead */logs/couchdb/*.log{,.[0-9]*,-[0-9]*} set filetype=couch_log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you really want this configuration to be sustem-wide, you can do the same with a &lt;code&gt;ftdetect&lt;/code&gt; directory under &lt;code&gt;$VIMRUNTIME&lt;/code&gt; (probably somewhere under &lt;code&gt;/usr/share/vim&lt;/code&gt; in your system, check &lt;code&gt;:echo $VIMRUNTIME&lt;/code&gt; to find out exactly where.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main advantage of not modifying a system file is that you won't lose the setting if you upgrade or reinstall Vim on that machine, which would probably overwrite the file you modified. Also, by keeping it inside your &lt;code&gt;.vim&lt;/code&gt;, it's easy to take that with you to a different machine, since you can transport all your configurations together from a single &lt;code&gt;~/.vim&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't need to create an &lt;code&gt;augroup&lt;/code&gt; for this rule, Vim does that automatically for you as it sources &lt;code&gt;*.vim&lt;/code&gt; files from the &lt;code&gt;ftdetect&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you'll probably want to use &lt;code&gt;set filetype=couch_log&lt;/code&gt;, rather than &lt;code&gt;setf couch_log&lt;/code&gt;, in your filetype detection override.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason for it is that &lt;code&gt;set filetype=couch_log&lt;/code&gt; will always set the filetype unconditionally, even if the file name has already matched another pattern and has been assigned a filetype in a previous rule. &lt;code&gt;setf couch_log&lt;/code&gt;, on the other hand, will only set the filetype if one wasn't set yet. So you might end up skipping the setting if the file previously matched another filename pattern and was assigned a filetype already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you're writing your overrides, you'll probably want to always use the stronger &lt;code&gt;set filetype=...&lt;/code&gt;, since you probably want your rule to &quot;win&quot; in case a file matches multiple rules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/filetype.txt.html#ftdetect&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ftdetect&lt;/code&gt;&lt;/a&gt;, it has more details on Vim's handling of the &lt;code&gt;ftdetect&lt;/code&gt; directory and also spells out the differences between &lt;code&gt;set filetype&lt;/code&gt; and &lt;code&gt;setf&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-06T08:59:37.583" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22189" PostTypeId="2" ParentId="7681" CreationDate="2019-12-06T23:38:40.300" Score="2" Body="&lt;p&gt;This was changed in &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.2401&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.1.2401&lt;/a&gt;; now a shell pipe character does not need to be escaped anymore inside an expression containing a quoted shell command after &lt;code&gt;:cexpr&lt;/code&gt; and the five other variants:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cgetexpr&#xA;:caddexpr&#xA;:lexpr&#xA;:lgetexpr&#xA;:laddexpr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before the patch, an unescaped shell pipe would raise &lt;code&gt;E115&lt;/code&gt; and &lt;code&gt;E116&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -Nu NONE&#xA;:cexpr system('grep -Rn grail '..$VIMRUNTIME..' | grep -v tag')&#xA;E115: Missing quote: '&#xA;E116: Invalid arguments for function system('grep -Rn grail '..$VIMRUNTIME..'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, the same command edits the file &lt;code&gt;$VIMRUNTIME/doc/index.txt&lt;/code&gt;, and populates the quickfix list with this entry:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{'lnum': 1121,&#xA; 'bufnr': 2,&#xA; 'col': 0,&#xA; 'pattern': '',&#xA; 'valid': 1,&#xA; 'vcol': 0,&#xA; 'nr': -1,&#xA; 'type': '',&#xA; 'module': '',&#xA; 'text': 'You found it, Arthur!                         *holy-grail* *:smile*'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2019-12-06T23:38:40.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22190" PostTypeId="1" AcceptedAnswerId="22236" CreationDate="2019-12-07T00:01:07.357" Score="1" ViewCount="63" Body="&lt;p&gt;Please see line 20 and 21:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E7lWM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E7lWM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is about how vim decides to auto-indent line 21, and how to adjust that behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I took this screenshot I had &lt;code&gt;formatoptions=qrn1a&lt;/code&gt; set, however I believe even without &lt;code&gt;a&lt;/code&gt; set, if I format using &lt;code&gt;ggqG&lt;/code&gt; or &lt;code&gt;gqip&lt;/code&gt;, for example, the same thing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have many options set, pertaining to text formatting, and it's not clear to me which is doing that and why.&lt;/p&gt;&#xA;" OwnerUserId="158" LastEditorUserId="158" LastEditDate="2019-12-07T00:33:26.310" LastActivityDate="2019-12-11T23:15:24.300" Title="Why does my line indent?" Tags="|indentation|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22191" PostTypeId="1" CreationDate="2019-12-07T01:16:20.530" Score="0" ViewCount="892" Body="&lt;p&gt;I have just installed MacVim on my new Macbook.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I have a problem: on Linux I was able to scroll through my code—vertically moving my cursor—by using my trackpad. But on Macvim this doesn't work for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When scrolling in Macvim, the buffer/window scrolls but the cursor doesn't move.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a little video demonstrating the issue:&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=UeBIfwhRL5Q&amp;amp;feature=youtu.be&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; you see the buffer moving when I scroll using my trackpad, but not my cursor scrolling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to fix this error by using the command &lt;code&gt;:set mouse=a&lt;/code&gt;, but without success. I also took a look at MouseTerm (using SIBML), but this doesn't seem trustworthy and a little bit overkill to just enable good scrolling behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a solution which came close:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;ScrollWheelUp&amp;gt; k&#xA;nnoremap &amp;lt;ScrollWheelDown&amp;gt; j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this scrolling is not even close to smooth and I was hoping for a more elegant way to solve this than remapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, scrolling does work fine in the normal Vim using the Terminal as long as Mouse Reporting is enabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TL;DR: How to enable smooth scrolling behavior with trackpad in Macvim?&#xA;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="26000" LastEditorUserId="10604" LastEditDate="2019-12-07T15:13:16.660" LastActivityDate="2021-05-01T05:04:40.587" Title="Scrolling with trackpad not working Macvim" Tags="|macvim|scrolling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22192" PostTypeId="1" AcceptedAnswerId="22193" CreationDate="2019-12-07T01:31:41.320" Score="2" ViewCount="500" Body="&lt;p&gt;This question is related to &lt;a href=&quot;https://vi.stackexchange.com/questions/6016/do-a-forward-slash-search-but-dont-have-vim-immediately-jump-to-the-string&quot;&gt;Do a forward slash search but don&amp;#39;t have vim immediately jump to the string?&lt;/a&gt; but is not a dup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently updated my Linux box (clicked on the &quot;install updates&quot; button in my Fedora distro' gui), and it has definitely changed &lt;code&gt;Vim&lt;/code&gt;'s behavior:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Normal Mode, I used to perform the following keystroke sequence to replace all instances of the entire word under my cursor: &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt;, &lt;code&gt;s&lt;/code&gt;,&lt;code&gt;/&lt;/code&gt;,&lt;code&gt;\&lt;/code&gt;,&lt;code&gt;&amp;lt;&lt;/code&gt;,&lt;code&gt;Ctrl-r&lt;/code&gt;,&lt;code&gt;Ctrl-w&lt;/code&gt;,&lt;code&gt;\&lt;/code&gt;,&lt;code&gt;&amp;gt;&lt;/code&gt;,&lt;code&gt;/&lt;/code&gt;,&lt;em&gt;replacement&lt;/em&gt;,&lt;code&gt;/&lt;/code&gt;,&lt;code&gt;g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Post-update, things have changed such that after the first &lt;code&gt;/&lt;/code&gt; in that sequence, &lt;code&gt;vim&lt;/code&gt; immediately moves the cursor and starts searching. This effectively kills my ability to use the &lt;code&gt;Ctrl-r&lt;/code&gt;,&lt;code&gt;Ctrl-w&lt;/code&gt; sequence to insert the word &lt;em&gt;currently under the cursor&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the answer to the noted question, I tried modifying my keystroke sequence to insert a &lt;code&gt;:&lt;/code&gt; before the first &lt;code&gt;/&lt;/code&gt; in that sequence, but that does not work: the &lt;code&gt;Ctrl-r&lt;/code&gt;,&lt;code&gt;Ctrl-w&lt;/code&gt; sequence inserts some other word (not the word under the cursor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to just disable this &quot;search immediately if you type &lt;code&gt;/&lt;/code&gt;&quot; feature altogether?&lt;/strong&gt; (I.e. instead of having to change your key-sequence as per the noted question) &lt;strong&gt;Or what can I do to restore things so that the old, noted, &quot;replace everywhere&quot; keystroke-sequence works again?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version                                                                                 &#xA;VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 22 2019 12:17:41)&#xA;Included patches: 1-2198                                                                       &#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;                                                              &#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;...&#xA;$&#xA;$ cat ~/.vimrc&#xA;execute pathogen#infect()&#xA;&#xA;set backspace=indent,eol,start&#xA;set shiftwidth=2&#xA;set softtabstop=2&#xA;set expandtab&#xA;set smarttab&#xA;set cino+=(0&#xA;set statusline=&#xA;set statusline +=\[%n]    &quot; buffer number&#xA;set statusline +=\%F      &quot; File&#xA;set statusline +=%=%l/%L  &quot; currentLine/totalLine&#xA;set statusline +=%4v      &quot; virtual column&#xA;set laststatus=2&#xA;set number&#xA;set ruler                 &quot; show the cursor position all the time&#xA;set scrolloff=7           &quot; start scrolling when cursor is 7 lines from top/bottom&#xA;set t_Co=256&#xA;set textwidth=80&#xA;set formatoptions=croqlt  &quot; Hard-wrap when typing exceeds &amp;lt;textwidth&amp;gt;&#xA;set hlsearch&#xA;syntax on&#xA;filetype plugin indent on&#xA;autocmd FileType make set noexpandtab shiftwidth=4 softtabstop=0&#xA;colorscheme Base2Tone_MorningDark&#xA;&#xA;&quot; highlights&#xA;hi Search ctermfg=black ctermbg=yellow&#xA;hi LineNr ctermfg=yellow ctermbg=NONE&#xA;hi Normal ctermfg=NONE ctermbg=NONE&#xA;&#xA;&quot; syntastic stuff&#xA;let g:syntastic_check_on_open = 1&#xA;let g:syntastic_always_populate_loc_list = 1&#xA;let g:syntastic_check_on_wq = 1&#xA;let g:syntastic_c_checkers = ['cppcheck']&#xA;let g:syntastic_cpp_checkers = ['cppcheck']&#xA;let g:syntastic_python_checkers = ['flake8']&#xA;let g:syntastic_javascript_checkers = ['eslint']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't really know what version of &lt;code&gt;vim&lt;/code&gt; I had before the upgrade, and I'd have no idea how to go about unearthing that information now.&lt;/p&gt;&#xA;" OwnerUserId="11701" LastEditorUserId="11701" LastEditDate="2019-12-08T02:20:23.280" LastActivityDate="2019-12-08T02:35:01.243" Title="How to search &amp; replace the word under cursor without changing position?" Tags="|search|cursor-movement|cursor-motions|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22193" PostTypeId="2" ParentId="22192" CreationDate="2019-12-07T03:37:32.233" Score="4" Body="&lt;p&gt;This is due to an upgrade to &lt;code&gt;'incsearch'&lt;/code&gt;. Turning it off should do the trick. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S.: you could map the key stroke instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;cw :%s/&amp;lt;cword&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I prefer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;cw :let @/=expand('&amp;lt;cword&amp;gt;')&amp;lt;CR&amp;gt;cgn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which sets the search pattern, but doesn't highlight, and then uses the &lt;code&gt;.&lt;/code&gt;-repeatable &lt;code&gt;cgn&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-12-08T02:35:01.243" LastActivityDate="2019-12-08T02:35:01.243" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22194" PostTypeId="1" AcceptedAnswerId="22195" CreationDate="2019-12-07T06:58:54.253" Score="4" ViewCount="750" Body="&lt;p&gt;How to reproduce this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;a :DoSomething &amp;lt;C-r&amp;gt;=do_something_arguments()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;..in a function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The desired effect is to open command-line mode with some text filled in, and leave it at that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:normal&lt;/code&gt; only works on &quot;complete commands&quot;, same seems to be also true for &lt;code&gt;:exec&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reasoning behind this is to define an operator (using &lt;a href=&quot;https://github.com/kana/vim-operator-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-operator-user&lt;/a&gt;) that would prepopulate a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call operator#user#define('conf-entry', 'Op_command_conf_entry')&#xA;function! Op_command_conf_entry(motion_wiseness)&#xA;  normal! `[yv`]&#xA;&#xA;  let l:conf_path = '~/.vim/conf/_' . @&quot; . '/'&#xA;&#xA;  exec ':EditCreating ' . l:conf_path&#xA;endfunction&#xA;&#xA;nmap _c  &amp;lt;Plug&amp;gt;(operator-conf-entry)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, the &lt;code&gt;exec&lt;/code&gt; line executes immediately, which is the behavior I want to change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm probably looking for is the command-line-mode equivalent to &lt;code&gt;:startinsert&lt;/code&gt;, something like &lt;code&gt;:startcommand&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The alternative solution is to use &lt;code&gt;input()&lt;/code&gt; which can offer both prepopulating as well as enabling completion. However this is not exactly command-line-mode.&lt;/p&gt;&#xA;" OwnerUserId="25948" LastActivityDate="2019-12-07T08:13:07.413" Title="Open command-line-mode from VimScript function" Tags="|command-line|functions|map-operator|command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22195" PostTypeId="2" ParentId="22194" CreationDate="2019-12-07T08:13:07.413" Score="0" Body="&lt;p&gt;You should make use of &lt;code&gt;:h map-&amp;lt;expr&amp;gt;&lt;/code&gt;. That is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;instead of exec&#xA;return ':EditCreating ' . l:conf_path&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt;&amp;lt;Plug&amp;gt;(operator-conf-entry) ... whatever&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Probably, you'll need some more fixes in your code, but it's impossible to say without seeing the whole picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, there's no such thing as &lt;code&gt;startcommand&lt;/code&gt;, so only &lt;code&gt;feedkeys&lt;/code&gt; or &lt;code&gt;input&lt;/code&gt; remain.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-07T08:13:07.413" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22196" PostTypeId="1" AcceptedAnswerId="22198" CreationDate="2019-12-07T08:25:35.547" Score="3" ViewCount="110" Body="&lt;p&gt;This is what I'm trying to achieve:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;input&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(|)foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then pressing some key combination to get&lt;/p&gt;&#xA;&#xA;&lt;p&gt;output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(foo)|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(foo|)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know this can be done with the autopairs plugin. In the docs they write that the default binding is M-}. I am using Vim/iTerm2/Mac, and I can't seem to figure out how to use the meta key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the autopairs plugin they let you remap another feature which is called Fast Wrap and is used to enclose a line with brackets. As you can understand, this is not exactly what I'm looking for, but even with Fast Wrap, which is mapped to M-e, I was not able to remap it or used it as is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I googled and tried using the sed command in the terminal to see what the option key is outputting, then I tried to remap this output to M-}. Didn't work. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="25181" LastEditorUserId="25181" LastEditDate="2019-12-07T08:32:19.950" LastActivityDate="2019-12-07T09:23:30.387" Title="Move rest of line inside a closed pair?" Tags="|key-bindings|plugin-auto-pairs|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22197" PostTypeId="2" ParentId="22196" CreationDate="2019-12-07T09:11:46.260" Score="0" Body="&lt;p&gt;Maybe you can define another mapping for &lt;code&gt;&amp;lt;M-e&amp;gt;&lt;/code&gt; mapping in insert mode. &lt;code&gt;imap &amp;lt;M-e&amp;gt;&lt;/code&gt;  shows that it is mappped to &lt;code&gt;&amp;lt;C-R&amp;gt;=AutoPairsFastWrap()&amp;lt;CR&amp;gt;&lt;/code&gt;. So you can define another key map for that, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-e&amp;gt; &amp;lt;C-R&amp;gt;=AutoPairsFastWrap()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2019-12-07T09:11:46.260" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22198" PostTypeId="2" ParentId="22196" CreationDate="2019-12-07T09:23:30.387" Score="4" Body="&lt;p&gt;I don't think there's a need of having another mapping at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's enough to press &lt;kbd&gt;%&lt;/kbd&gt; once or twice to get on the right &quot;paren&quot;. Then &lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; and you're done.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-07T09:23:30.387" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22199" PostTypeId="2" ParentId="22191" CreationDate="2019-12-07T15:23:38.553" Score="1" Body="&lt;p&gt;Here's what I could find in the help&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When your mouse has a scroll wheel, it should work with Vim in the GUI.  How&#xA;it works depends on your system.  It might also work in an xterm&#xA;|xterm-mouse-wheel|.  By default only vertical scroll wheels are supported,&#xA;but some GUIs also support horizontal scroll wheels.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;For the X11 GUIs (Motif, Athena and GTK) scrolling the wheel generates key&#xA;presses &amp;lt;ScrollWheelUp&amp;gt;, &amp;lt;ScrollWheelDown&amp;gt;, &amp;lt;ScrollWheelLeft&amp;gt; and&#xA;&amp;lt;ScrollWheelRight&amp;gt;.  For example, if you push the scroll wheel upwards a&#xA;&amp;lt;ScrollWheelUp&amp;gt; key press is generated causing the window to scroll upwards&#xA;(while the text is actually moving downwards).  The default action for these&#xA;keys are:&#xA;    &amp;lt;ScrollWheelUp&amp;gt;     scroll three lines up   *&amp;lt;ScrollWheelUp&amp;gt;*&#xA;    &amp;lt;S-ScrollWheelUp&amp;gt;       scroll one page up      *&amp;lt;S-ScrollWheelUp&amp;gt;*&#xA;    &amp;lt;C-ScrollWheelUp&amp;gt;       scroll one page up      *&amp;lt;C-ScrollWheelUp&amp;gt;*&#xA;    &amp;lt;ScrollWheelDown&amp;gt;       scroll three lines down *&amp;lt;ScrollWheelDown&amp;gt;*&#xA;    &amp;lt;S-ScrollWheelDown&amp;gt;     scroll one page down    *&amp;lt;S-ScrollWheelDown&amp;gt;*&#xA;    &amp;lt;C-ScrollWheelDown&amp;gt;     scroll one page down    *&amp;lt;C-ScrollWheelDown&amp;gt;*&#xA;    &amp;lt;ScrollWheelLeft&amp;gt;       scroll six columns left *&amp;lt;ScrollWheelLeft&amp;gt;*&#xA;    &amp;lt;S-ScrollWheelLeft&amp;gt;     scroll one page left    *&amp;lt;S-ScrollWheelLeft&amp;gt;*&#xA;    &amp;lt;C-ScrollWheelLeft&amp;gt;     scroll one page left    *&amp;lt;C-ScrollWheelLeft&amp;gt;*&#xA;    &amp;lt;ScrollWheelRight&amp;gt;      scroll six columns right    *&amp;lt;ScrollWheelRight&amp;gt;*&#xA;    &amp;lt;S-ScrollWheelRight&amp;gt;    scroll one page right   *&amp;lt;S-ScrollWheelRight&amp;gt;*&#xA;    &amp;lt;C-ScrollWheelRight&amp;gt;    scroll one page right   *&amp;lt;C-ScrollWheelRight&amp;gt;*&#xA;This should work in all modes, except when editing the command line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and finally&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Note that horizontal scrolling only works if 'nowrap' is set.  Also, unless&#xA;the &quot;h&quot; flag in 'guioptions' is set, the cursor moves to the longest visible&#xA;line if the cursor line is about to be scrolled off the screen (similarly to&#xA;how the horizontal scrollbar works).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it may have something to do with &lt;code&gt;How it works depends on your system&lt;/code&gt;—the listed systems are mostly X11. I don't have a MacVim to check &lt;a href=&quot;https://github.com/macvim-dev/macvim/blob/master/runtime/doc/gui_mac.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;more relevant docs on though&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help mac&#xA;NOTE: This file is a bit outdated.  You might find more useful info here:&#xA;    http://macvim.org/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some more things I’ve learned—MacVim tries to scroll the window, rather than scrolling the cursor. This seems to be acceptable and even considered default behavior (though I agree it’s different from the terminal). Still looking for a solution, but I suspect it will require changing the way the mouse works with the gui. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-12-08T02:39:02.550" LastActivityDate="2019-12-08T02:39:02.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22201" PostTypeId="2" ParentId="807" CreationDate="2019-12-07T15:33:12.123" Score="7" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#rand()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;rand()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/eval.txt.html#srand()&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;srand()&lt;/code&gt;&lt;/a&gt; functions, provided your Vim binary includes the patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.2342&quot; rel=&quot;noreferrer&quot;&gt;8.1.2342&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As an example, to generate 10 random numbers separated by newlines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let seed = srand()&#xA;echo range(10)-&amp;gt;map({-&amp;gt; rand(g:seed)})-&amp;gt;join(&quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To generate 10 random numbers all inferior to 100:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let seed = srand()&#xA;echo range(10)-&amp;gt;map({-&amp;gt; rand(g:seed) % 100})-&amp;gt;join(&quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To generate 10 random alphabetical strings of 5 characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let seed = srand()&#xA;echo range(10)&#xA;   \ -&amp;gt;map({-&amp;gt; range(5)&#xA;   \           -&amp;gt;map({-&amp;gt; (97+rand(g:seed) % 26)-&amp;gt;nr2char()})-&amp;gt;join('')})&#xA;   \ -&amp;gt;join(&quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To generate 10 random words (taken from the dictionary file &lt;code&gt;/usr/share/dict/words&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let seed = srand()&#xA;let words = readfile('/usr/share/dict/words')&#xA;let len = len(words)&#xA;echo range(10)-&amp;gt;map({-&amp;gt; g:words[rand(g:seed) % g:len]})-&amp;gt;join(&quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To generate 10 sequences of 5 random words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let seed = srand()&#xA;let words = readfile('/usr/share/dict/words')&#xA;let len = len(words)&#xA;echo range(10)&#xA;   \ -&amp;gt;map({-&amp;gt; range(5)&#xA;   \           -&amp;gt;map({-&amp;gt; g:words[rand(g:seed) % g:len]})-&amp;gt;join()})&#xA;   \ -&amp;gt;join(&quot;\n&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To generate a random UUID version 4:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Based on this answer: https://stackoverflow.com/a/38191078/9780968&#xA;let seed = srand()&#xA;let random_numbers = range(30)-&amp;gt;map({-&amp;gt; rand(g:seed) % 16})&#xA;echo call('printf', ['%x%x%x%x%x%x%x%x-%x%x%x%x-4%x%x%x'] + random_numbers[:14])&#xA; \ ..call('printf', ['-X%x%x%x-%x%x%x%x%x%x%x%x%x%x%x%x'] + random_numbers[15:])&#xA; \   -&amp;gt;substitute('X', '89ab'[rand(seed) % 4], '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To apply a random color scheme:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let seed = srand()&#xA;let colorschemes = getcompletion('', 'color')&#xA;let len = colorschemes-&amp;gt;len()&#xA;exe 'colo '..colorschemes[rand(seed) % len]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-12-08T03:09:16.433" LastActivityDate="2019-12-08T03:09:16.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22202" PostTypeId="2" ParentId="10007" CreationDate="2019-12-07T20:51:17.280" Score="3" Body="&lt;p&gt;In case anyone is still looking for information on this, there are a few ways to resolve this issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;set the path to the file with a &lt;code&gt;-P|--source-path=&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;quiet the message with a disable directive&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Each of these can be done in a few places. I'll cover each in turn.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;In your &lt;code&gt;.shellcheckrc&lt;/code&gt; file:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;.shellcheckrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;# tell shellcheck to look for include files in the users current directory&#xA;source-path=SCRIPTDIR&#xA;&#xA;# or to disable these messages altogether (comma separated list)&#xA;# SC1090: Can't follow non-constant source. Use a directive to specify location.&#xA;disable=SC1090&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;In your source file:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;main_file.sh&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;&#xA;# provide the path relative to where you opened the file&#xA;# shellcheck source=includes/source_file.sh&#xA;&#xA;# if you've provided the path elsewhere (see below)&#xA;# or if the file is in your current path just the filename&#xA;# shellcheck source=source_file.sh&#xA;&#xA;# or to disable these messages altogether (comma separated list)&#xA;# shellcheck disable=SC1090&#xA;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;In your &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; tell shellcheck to look for include files in the users current directory&#xA;let g:syntastic_sh_shellcheck_args=&quot;--external-sources --source-path=.&quot;&#xA;&#xA;&quot; or to quiet these messages altogether:&#xA;let g:syntastic_quiet_messages = { 'regex': 'SC2090' }&#xA;&#xA;&quot; to quiet multiple messages:&#xA;let g:syntastic_quiet_messages = { 'regex': 'SC2034\|SC2068\|SC2086\|SC2154' }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Debugging&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Finally, it's worth noting that you can always run shellcheck from the command line. While this won't solve your vim problems directly, it can be useful for debugging. (One reason to keep disable directives in your shellcheckrc instead of vim.)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;$ shellcheck --help&#xA;$ shellcheck -x -P . main_file.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In vim, you can see what your checker is sending to shellcheck by looking at the syntastic global variables from the current buffer. More involved debugging information can be found with &lt;code&gt;:help syntastic-debug&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo g:syntastic_sh_shellcheck_args&#xA;:echo g:syntastic_quiet_messages&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;My solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The solution that I've come to favor uses a per-project vimrc file in combination with a ftplugin file (or filetype autocmd).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, to enable per-directory vimrc files:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  set exrc     &quot; load .vimrc files in the current directory&#xA;  set secure   &quot; limit commands run from .vimrc files outside of $HOME in some cases&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in the project directory:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;path/to/project/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_sh_include_dirs = 'src/include'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, in my &lt;code&gt;sh.vim&lt;/code&gt; file (&lt;a href=&quot;https://vimways.org/2018/from-vimrc-to-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vimways.org/2018/from-vimrc-to-vim/&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/.vim/ftplugin/sh.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:syntastic_sh_shellcheck_args=&quot;--external-sources&quot;&#xA;&#xA;&#xA;if exists('g:syntastic_sh_include_dirs')&#xA;  let g:syntastic_sh_shellcheck_args .= &quot; --source-path=&quot; .. g:syntastic_sh_include_dirs&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternately, in a vimrc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;function! SetIncludeDirs()&#xA;  if exists('g:syntastic_sh_include_dirs')&#xA;    let g:syntastic_sh_shellcheck_args .= &quot; --source-path=&quot; .. g:syntastic_sh_include_dirs&#xA;  endif&#xA;endfunction&#xA;&#xA;augroup sh&#xA;  autocmd!&#xA;  autocmd call SetIncludeDirs()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26009" LastEditorUserId="1238" LastEditDate="2019-12-08T02:43:55.267" LastActivityDate="2019-12-08T02:43:55.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22203" PostTypeId="1" CreationDate="2019-12-08T01:00:47.403" Score="1" ViewCount="176" Body="&lt;p&gt;I upgraded to Ubuntu 18.04 and this has Vim version 8.0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This newer version has MatchIt setup to ignore parenthesis, brackets, etc. found inside comments and strings. Although it is at times useful, I prefer to be able to match all of those characters because I often write code in my comments (i.e. for documentation purposes, showing examples).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although there are times when it is nice to have it this way (ignoring comments/strings), for me it is really rarely useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way for me to turn off that feature with one flag or another?&lt;/p&gt;&#xA;" OwnerUserId="9276" LastEditorUserId="9276" LastEditDate="2019-12-09T05:37:46.480" LastActivityDate="2019-12-09T05:37:46.480" Title="MatchIt not matching anymore if parenthesis, brackets, etc. are between quotes or in comments?" Tags="|comments|plugin-matchit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22204" PostTypeId="2" ParentId="5436" CreationDate="2019-12-08T05:24:58.837" Score="1" Body="&lt;p&gt;I'd play with &lt;code&gt;g^a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try &lt;code&gt;137i0^v137kg^a&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="26010" LastEditorUserId="10604" LastEditDate="2019-12-08T13:52:28.190" LastActivityDate="2019-12-08T13:52:28.190" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22205" PostTypeId="1" AcceptedAnswerId="22207" CreationDate="2019-12-08T12:43:48.577" Score="10" ViewCount="2887" Body="&lt;p&gt;&lt;code&gt;&quot;*p&lt;/code&gt; and &lt;code&gt;&quot;+p&lt;/code&gt; seem to behave the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;:help &quot;*&lt;/code&gt;, but it's talking about mouse selection, and &lt;code&gt;:help &quot;+&lt;/code&gt; tells me&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There are three documented X selections: PRIMARY (which is expected to&#xA;  represent the current visual selection - as in Vim's Visual mode), SECONDARY&#xA;  (which is ill-defined) and CLIPBOARD (which is expected to be used for&#xA;  cut, copy and paste operations).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Of these three, Vim uses PRIMARY when reading and writing the &lt;code&gt;&quot;*&lt;/code&gt; register&#xA;  (hence when the X11 selections are available, Vim sets a default value for&#xA;  'clipboard' of &quot;autoselect&quot;), and CLIPBOARD when reading and writing the &lt;code&gt;&quot;+&lt;/code&gt;&#xA;  register.  Vim does not access the SECONDARY selection.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But I don't understand this; what's it got to do with visual mode? What are X selections?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastEditorUserId="205" LastEditDate="2019-12-09T09:53:10.280" LastActivityDate="2019-12-09T17:00:47.687" Title="Difference between &quot;* and &quot;+ registers in +clipboard VIM?" Tags="|cut-copy-paste|os-clipboard|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22206" PostTypeId="2" ParentId="22205" CreationDate="2019-12-08T13:43:19.800" Score="6" Body="&lt;p&gt;The PRIMARY selection contains the currently selected text. You can paste it with the middle mouse button (or Shift+Insert in some terminals).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The CLIPBOARD selection needs to be set explicitly with Control+C, and can be inserted with Control+V. This is essentially how Windows and macOS work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I always remember because the &lt;em&gt;C&lt;/em&gt; from CLIPBOARD is for Control+&lt;em&gt;C&lt;/em&gt;, which contains a &lt;code&gt;+&lt;/code&gt; like the register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Windows and macOS the &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; registers are the same.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2019-12-08T13:43:19.800" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22207" PostTypeId="2" ParentId="22205" CreationDate="2019-12-08T20:31:07.787" Score="13" Body="&lt;p&gt;If you're on Mac or Windows, there's no difference. On Linux they are different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only work in Vim, you really don't need either of them (I mean that you can live without them), as they are best used to interact with the outside world.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, if you select something with your mouse (everywhere, not necessarily in the terminal; try by selecting some text in, say, Firefox), and then you go back to Vim, the &lt;code&gt;*&lt;/code&gt; register will contain that thing you selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If instead you copy some text with &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; or equivalent (again from anywhere), and then you go back to Vim, you will find that stuff in the &lt;code&gt;+&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clearly, if you select some text with your mouse &lt;strong&gt;and then&lt;/strong&gt; you hit &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; to copy it, and then you go back to Vim, you will find the same content in both registers. There are ways, however, to copy something to the clipboard without selecting it first (think about the &quot;copy to clipboard&quot; buttons that you sometimes find on a website), and in those cases you can preserve the primary selection while writing to the clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, in case you don't know, &lt;code&gt;:reg&lt;/code&gt; shows the content of the registers.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="2736" LastEditDate="2019-12-09T17:00:47.687" LastActivityDate="2019-12-09T17:00:47.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22208" PostTypeId="1" AcceptedAnswerId="22223" CreationDate="2019-12-09T03:28:30.897" Score="2" ViewCount="2597" Body="&lt;p&gt;per the recommendation in the &lt;code&gt;vim-plug&lt;/code&gt; wiki: &lt;a href=&quot;https://github.com/junegunn/vim-plug/wiki/extra&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/junegunn/vim-plug/wiki/extra&lt;/a&gt;, I've added the following snippet to my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Install missing plugins on Vim startup&#xA;autocmd VimEnter *&#xA;  \  if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))&#xA;  \|   PlugInstall --sync | q&#xA;  \| endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does indeed cause any missing plugins to be installed on Vim startup, but on subsequent launches on Ubuntu (18.04 LTS, with apt's version of vim and a version I built from source) the body of the if statement continues to evaluate to 1 (verified with &lt;code&gt;echomsg&lt;/code&gt;), so the plugin installation screen flashes every time I open vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not the case on macOS; once the plugins are installed for the first time, the body of the if statement no longer evaluates to 1, and the &lt;code&gt;PlugInstall&lt;/code&gt; screen no longer displays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I go about fixing this?&lt;/p&gt;&#xA;" OwnerUserId="16232" LastActivityDate="2019-12-10T16:16:57.347" Title="vim-plug: install plugins on startup not working properly on Ubuntu" Tags="|vimrc|linux-ubuntu|plugin-vim-plug|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22209" PostTypeId="2" ParentId="22203" CreationDate="2019-12-09T03:50:45.047" Score="2" Body="&lt;p&gt;Just looking at &lt;code&gt;:h matchit&lt;/code&gt; should reveal the answer. I see variable &lt;code&gt;b:match_skip&lt;/code&gt; is relevant. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Per the docs the default value of this would be set with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let b:match_skip = 's:comment\|string'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With that setting &lt;code&gt;%&lt;/code&gt; ignores brackets within or partially within comments, for instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting it to something that evaluates to 0 (i.e. nothing is skipped)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let b:match_skip = &quot;0&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and now I'm able to &lt;code&gt;%&lt;/code&gt; jump to/from brackets that are within or partially within comments.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-12-09T03:50:45.047" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22210" PostTypeId="1" CreationDate="2019-12-09T11:58:31.830" Score="3" ViewCount="1130" Body="&lt;p&gt;I am often working with multiple projects at the same time. For example one main project and 5 related librairies. I have some issue to properly search in one project or multiple. I would like to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Be able to search with CtrlP only in current git repo when I have a file open or in multiple git repo&lt;/li&gt;&#xA;&lt;li&gt;Easily view multiple selected repositories in netrw or similar&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="3357" LastEditorUserId="3357" LastEditDate="2019-12-09T13:40:02.320" LastActivityDate="2019-12-15T13:09:15.730" Title="How to work with multiple project folders in Vim?" Tags="|vim-windows|netrw|plugin-ctrlp|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22211" PostTypeId="2" ParentId="17523" CreationDate="2019-12-09T12:12:02.420" Score="1" Body="&lt;p&gt;Not sure if this what you want, but try reading: &lt;a href=&quot;https://vimways.org/2018/formatting-lists-with-vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vimways.org/2018/formatting-lists-with-vim/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have in my settings regarding list formatting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal formatoptions=tcqln&#xA;setlocal formatlistpat=^\\s*&#xA;setlocal formatlistpat+=[&#xA;setlocal formatlistpat+=\\[({]\\?&#xA;setlocal formatlistpat+=\\(&#xA;setlocal formatlistpat+=[0-9]\\+&#xA;setlocal formatlistpat+=\\\|&#xA;setlocal formatlistpat+=[a-zA-Z]&#xA;setlocal formatlistpat+=\\)&#xA;setlocal formatlistpat+=[\\]:.)}&#xA;setlocal formatlistpat+=]&#xA;setlocal formatlistpat+=\\s\\+&#xA;setlocal formatlistpat+=\\\|&#xA;setlocal formatlistpat+=^\\s*-\\s\\+&#xA;setlocal formatlistpat+=\\\|&#xA;setlocal formatlistpat+=^\\s*[*]\\+\\s\\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VhLyN.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VhLyN.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2019-12-09T12:12:02.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22212" PostTypeId="1" AcceptedAnswerId="22214" CreationDate="2019-12-09T14:43:08.127" Score="2" ViewCount="1098" Body="&lt;p&gt;I am using a convenient macro to list my buffers: &lt;code&gt;map &amp;lt;leader&amp;gt;bb :buffers&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to come up with a way to then switch to the buffer of interest with &lt;code&gt;&amp;lt;leader&amp;gt;b&amp;lt;number&amp;gt;&lt;/code&gt; but I haven't found how to catch a number in this map. I assume there should be some kind of delay involved in case I have a 2-digit number (highly unlikely), however, even single-digit number would suffice.&lt;/p&gt;&#xA;" OwnerUserId="26028" LastActivityDate="2019-12-09T15:56:16.463" Title="map &lt;leader&gt;b&lt;number&gt; :b&lt;number&gt;&lt;cr&gt;" Tags="|vimrc|buffers|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22213" PostTypeId="2" ParentId="22212" CreationDate="2019-12-09T15:50:09.697" Score="2" Body="&lt;p&gt;For single-digit buffers, you can actually hardcode 9 mappings, one for each digit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;b1 :buffer 1&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;b2 :buffer 2&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;b3 :buffer 3&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;b4 :buffer 4&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;b5 :buffer 5&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;b6 :buffer 6&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;b7 :buffer 7&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;b8 :buffer 8&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;b9 :buffer 9&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't like the repetition, you could use a &lt;code&gt;:for&lt;/code&gt; loop to produce these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for i in range(1, 9)&#xA;    execute 'nnoremap &amp;lt;Leader&amp;gt;b'.i.&#xA;        \ ' :buffer '.i.'&amp;lt;CR&amp;gt;'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the double-digit case, it can be tricky to do with a mapping. You can potentially use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#getchar%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getchar()&lt;/code&gt;&lt;/a&gt; to keep getting more characters and check whether they're valid digits. But you need a way to terminate the sequence, possibly by checking when you get a &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; from &lt;code&gt;getchar()&lt;/code&gt;, but that means the user will have to press an extra key to finish the sequence. (Though you could handle keys other than &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; or digits by terminating the sequence and feeding them back with &lt;code&gt;feedkeys()&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since an extra key is likely needed, you might consider using &lt;a href=&quot;https://vimhelp.org/eval.txt.html#input%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;input()&lt;/code&gt;&lt;/a&gt; instead, in which case you can even allow completion on buffer names!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SwitchBuffer()&#xA;    &quot; Start by listing existing buffers&#xA;    buffers&#xA;    let n = input('Switch to: ', '', 'buffer')&#xA;    execute 'buffer' n&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;Leader&amp;gt;bs :call SwitchBuffer()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could use such a mapping in addition to the single-digit mappings, for cases where you want to use buffer names or two-digit buffer numbers. Also, listing them first as part of the command might be useful as well.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-09T15:50:09.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22214" PostTypeId="2" ParentId="22212" CreationDate="2019-12-09T15:56:16.463" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I am using a convenient macro&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Just FYI, one can also do &lt;code&gt;:ls&amp;lt;CR&amp;gt;&lt;/code&gt; to achieve the same result. So that one does not look like &quot;a life saver&quot; to me.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;a way to then switch to the buffer of interest&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Again, that does not look so useful, as one can always do &lt;code&gt;:b[Number]&amp;lt;CR&amp;gt;&lt;/code&gt; without any hassle. But let's figure out how we can create a &quot;parameterized&quot; mapping for this particular example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, normal mode commands in Vim can have a count, but it must be supplied &lt;em&gt;before&lt;/em&gt; a command, not after it. So we aim to support &lt;code&gt;[Number]&amp;lt;leader&amp;gt;b&lt;/code&gt; and not vice versa. The counter then will be available in a special variable &lt;code&gt;v:count&lt;/code&gt; (or &lt;code&gt;v:count1&lt;/code&gt;). Also, a user can press just &lt;code&gt;&amp;lt;leader&amp;gt;b&lt;/code&gt; without any count supplied. And we must do something reasonable in this case, so let it be a &quot;next buffer&quot; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, we should make a command out of an expression (strings and numbers) and execute it. There are several ways to do so, but I think that &lt;code&gt;:h map-&amp;lt;expr&amp;gt;&lt;/code&gt; is the best suit for this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the mapping can be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt;&amp;lt;leader&amp;gt;b printf(&quot;:\&amp;lt;C-U&amp;gt;%s\n&quot;, v:count ? 'buffer' . v:count : 'bnext')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, &lt;code&gt;N&amp;lt;leader&amp;gt;b&lt;/code&gt; works as &lt;code&gt;:buffer N&lt;/code&gt;, and &lt;code&gt;&amp;lt;leader&amp;gt;b&lt;/code&gt; works as &lt;code&gt;:bnext&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-09T15:56:16.463" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22215" PostTypeId="2" ParentId="21981" CreationDate="2019-12-09T18:59:21.693" Score="2" Body="&lt;p&gt;&lt;strong&gt;SOLVED!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem was the background variable, which was set to dark.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=light&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;solves the issue.&lt;/p&gt;&#xA;" OwnerUserId="2993" LastActivityDate="2019-12-09T18:59:21.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22216" PostTypeId="1" CreationDate="2019-12-09T20:03:11.717" Score="10" ViewCount="881" Body="&lt;p&gt;If I am using IntelliJ and I hover over a close bracket for a scope that starts somewhere that is not currently visible, it shows a popup at the top of the window previewing the line where with the corresponding open bracket.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JGQPm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JGQPm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to do this in Vim? I tried searching but I don't know what this is called so it is hard to find any useful results. I think it should be possible using balloons, but even if there is a way that just shows a preview as the top visible line of the buffer that would be great.&lt;/p&gt;&#xA;" OwnerUserId="26037" LastEditorUserId="51" LastEditDate="2019-12-23T23:15:58.067" LastActivityDate="2019-12-23T23:15:58.067" Title="Is there a way to preview the line where the corresponding open bracket is for a close bracket?" Tags="|previewing|balloon|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22217" PostTypeId="2" ParentId="22216" CreationDate="2019-12-09T22:01:28.887" Score="1" Body="&lt;p&gt;You could &lt;em&gt;probably&lt;/em&gt; mess around with the new popup features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you &lt;em&gt;might&lt;/em&gt; be able to do something with &lt;code&gt;:ptag&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But your best bet is to learn the mighty &lt;code&gt;%&lt;/code&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To quote &lt;code&gt;:help %&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%           Find the next item in this line after or under the&#xA;            cursor and jump to its match. |inclusive| motion.&#xA;            Items can be:&#xA;            ([{}])      parenthesis or (curly/square) brackets&#xA;                    (this can be changed with the&#xA;                    'matchpairs' option)&#xA;            /* */       start or end of C-style comment&#xA;            #if, #ifdef, #else, #elif, #endif&#xA;                    C preprocessor conditionals (when the&#xA;                    cursor is on the # or no ([{&#xA;                    following)&#xA;            For other items the matchit plugin can be used, see&#xA;            |matchit-install|.  This plugin also helps to skip&#xA;            matches in comments.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this means is that for almost any construct that has a concept of &quot;matching,&quot; you can hit &lt;code&gt;%&lt;/code&gt; to jump to the next &quot;match.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of your switch example, from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (var) {&#xA;  // lots of code...&#xA;} // &amp;lt;- cursor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hitting &lt;code&gt;%&lt;/code&gt; takes you to the switch line, and &lt;code&gt;%&lt;/code&gt; takes you back. Easy-peasy.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-12-09T22:01:28.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22218" PostTypeId="2" ParentId="22216" CreationDate="2019-12-10T00:54:39.320" Score="8" Body="&lt;p&gt;Yes- the plugin match-up has this feature: &lt;a href=&quot;https://github.com/andymass/vim-matchup&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/andymass/vim-matchup&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0sAiT.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0sAiT.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZRd07.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZRd07.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the option &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:matchup_matchparen_offscreen = { 'method': 'popup' }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is also the ability to show the match in the statusline (the default):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:matchup_matchparen_offscreen = { 'method': 'status' }`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2019-12-10T00:54:39.320" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22219" PostTypeId="2" ParentId="22216" CreationDate="2019-12-10T01:31:10.003" Score="2" Body="&lt;p&gt;I guess you should use Mass's &lt;a href=&quot;https://github.com/andymass/vim-matchup&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugin&lt;/a&gt; in his &lt;a href=&quot;https://vi.stackexchange.com/a/22218/5017&quot;&gt;answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to know how to do it, you can check this answer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is a small task, you can do it with &lt;a href=&quot;https://vimhelp.org/popup.txt.html#popup&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h popup&lt;/a&gt; window&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|  1 hello bracket {&#xA;| 12&#xA;| 13&#xA;| 14&#xA;| 15&#xA;| 16&#xA;| 17&#xA;| 18&#xA;| 19&#xA;| 20 }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read comment as explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; show open pair on left top of current window if cursor on (, [ or {.&#xA;&quot; close popup window if cursor moved in normal, visual, insert mode.&#xA;augroup pair_popup_group | au!&#xA;  autocmd CursorHold * call s:popup_open_pair()&#xA;augroup end&#xA;&#xA;let s:pair_popup_winid = 0&#xA;&#xA;function s:popup_open_pair() abort&#xA;&#xA;  &quot; check if already popped up&#xA;  if s:pair_popup_winid != 0&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; check if current character is close pair character&#xA;  let c = matchstr( getline('.'), printf('\%%%dc.', col('.') ) )&#xA;  if stridx(')]}', c) == -1&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; check if open pair in current window.&#xA;  &quot; get matching pair line, add space padded line number to it.&#xA;  try&#xA;    let win_top_buf_lnum = line('.') - winline() + 1&#xA;    let cview = winsaveview()&#xA;    keepjumps norm! %&#xA;    if line('.') &amp;gt;= win_top_buf_lnum&#xA;      return&#xA;    endif&#xA;&#xA;    let content = printf( ' %*d %s', len( line('$') ), line('.'), getline('.') )&#xA;  finally&#xA;    call winrestview(cview)&#xA;  endtry&#xA;&#xA;  &quot; show matching pair line on first screen line of current window&#xA;  let wpos = win_screenpos( winnr() )&#xA;  let s:pair_popup_winid = popup_create(&#xA;        \ content, { 'line' : wpos[0], 'col' : wpos[1] })&#xA;&#xA;  &quot; close popup if cursor moved&#xA;  autocmd pair_popup_group CursorMoved,CursorMovedI * ++once&#xA;        \  call popup_close(s:pair_popup_winid)&#xA;        \| let s:pair_popup_winid = 0&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-12-10T02:12:02.780" LastActivityDate="2019-12-10T02:12:02.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22220" PostTypeId="1" AcceptedAnswerId="22221" CreationDate="2019-12-10T10:06:56.613" Score="2" ViewCount="343" Body="&lt;p&gt;Editing a Qt localization file, which actually is a XML.&#xA;I'd like to check spelling for a text inside tags, so executed a command &lt;code&gt;setlocal spell spelllang=fr&lt;/code&gt;&#xA;After that only attribute value become highlighted as wrong in the first line as you can see on the screen shot.&lt;/p&gt;&#xA;&lt;p&gt;How to make this work as expected?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Bz4Vk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Bz4Vk.png&quot; alt=&quot;screen shot&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;  Works with vim 8.2.0076.&lt;/p&gt;&#xA;" OwnerUserId="26042" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-01-04T10:31:12.293" Title="How to make spell check work for text inside a XML file?" Tags="|spell-checking|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22221" PostTypeId="2" ParentId="22220" CreationDate="2019-12-10T15:07:11.530" Score="6" Body="&lt;p&gt;Spellchecking inside tags has been requested &lt;a href=&quot;https://github.com/chrisbra/vim-xml-runtime/issues/19&quot; rel=&quot;noreferrer&quot;&gt;some time ago&lt;/a&gt; (and apparently was a long outstanding Debian wishlist bug) and was enabled in the vim-xml syntax file since &lt;a href=&quot;https://github.com/chrisbra/vim-xml-runtime/commit/96e2698663feaa2d471de2e1d3410af63841d7e5&quot; rel=&quot;noreferrer&quot;&gt;this commit&lt;/a&gt;. Just clone the runtime files inside your package directory and it should readily work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The soon to be awaited Vim 8.2 release already contains this commit and should then work as expected.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2019-12-10T15:07:11.530" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22222" PostTypeId="1" AcceptedAnswerId="22226" CreationDate="2019-12-10T15:15:27.113" Score="3" ViewCount="301" Body="&lt;p&gt;I am trying to open archive files in Vim (zip files, jar files), but they are unreadable when opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I created a zip file with one file in it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ touch testfile.txt&#xA;$ zip test.zip testfile.txt&#xA;  adding: testfile.txt (stored 0%)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I tried to open it via &lt;code&gt;vim test.zip&lt;/code&gt;, but it is mostly unreadable with strange characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PK^C^D&#xA;^@^@^@^@^@▒M~JO^@^@^@^@^@^@^@^@^@^@^@^@^L^@^\^@testfile.txtUT   ^@^C^U▒▒]^U▒▒]ux^K^@^A^Dd}R^@^Dd^@^@^@PK^A^B^^^C&#xA;^@^@^@^@^@▒M~JO^@^@^@^@^@^@^@^@^@^@^@^@^L^@^X^@^@^@^@^@^@^@^@^@▒~A^@^@^@^@testfile.txtUT^E^@^C^U▒▒]ux^K^@^A^Dd}R^@^Dd^@^@^@PK^E^F^@^@^@^@^A^@^A^@R^@^@^@F^@^@^@^@^@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I type &lt;code&gt;:scriptnames&lt;/code&gt;, I can see &lt;code&gt;zipPlugin.vim&lt;/code&gt; and &lt;code&gt;zip.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: /etc/vimrc&#xA;  2: /usr/share/vim/vim74/syntax/syntax.vim&#xA;  3: /usr/share/vim/vim74/syntax/synload.vim&#xA;  4: /usr/share/vim/vim74/syntax/syncolor.vim&#xA;  5: /usr/share/vim/vim74/filetype.vim&#xA;  6: /usr/share/vim/vim74/ftplugin.vim&#xA;  7: /usr/share/vim/vim74/plugin/getscriptPlugin.vim&#xA;  8: /usr/share/vim/vim74/plugin/gzip.vim&#xA;  9: /usr/share/vim/vim74/plugin/matchparen.vim&#xA; 10: /usr/share/vim/vim74/plugin/netrwPlugin.vim&#xA; 11: /usr/share/vim/vim74/plugin/rrhelper.vim&#xA; 12: /usr/share/vim/vim74/plugin/spellfile.vim&#xA; 13: /usr/share/vim/vim74/plugin/tarPlugin.vim&#xA; 14: /usr/share/vim/vim74/plugin/tohtml.vim&#xA; 15: /usr/share/vim/vim74/plugin/vimballPlugin.vim&#xA; 16: /usr/share/vim/vim74/plugin/zipPlugin.vim&#xA; 17: /usr/share/vim/vim74/autoload/zip.vim&#xA; 18: /usr/share/vim/vim74/syntax/tar.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is the output of &lt;code&gt;:messages&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Messages maintainer: Bram Moolenaar &amp;lt;Bram@vim.org&amp;gt;&#xA;&quot;~/tes/test.zip&quot; [noeol] 3L, 174C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my vim version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jul 18 2019 16:14:10)&#xA;Included patches: 1-207, 209-629&#xA;Modified by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Compiled by &amp;lt;bugzilla@redhat.com&amp;gt;&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl             +farsi           +mouse_netterm   +syntax&#xA;+arabic          +file_in_path    +mouse_sgr       +tag_binary&#xA;+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static&#xA;-balloon_eval    +float           +mouse_urxvt     -tag_any_white&#xA;-browse          +folding         +mouse_xterm     -tcl&#xA;++builtin_terms  -footer          +multi_byte      +terminfo&#xA;+byte_offset     +fork()          +multi_lang      +termresponse&#xA;+cindent         +gettext         -mzscheme        +textobjects&#xA;-clientserver    -hangul_input    +netbeans_intg   +title&#xA;-clipboard       +iconv           +path_extra      -toolbar&#xA;+cmdline_compl   +insert_expand   +perl            +user_commands&#xA;+cmdline_hist    +jumplist        +persistent_undo +vertsplit&#xA;+cmdline_info    +keymap          +postscript      +virtualedit&#xA;+comments        +langmap         +printer         +visual&#xA;+conceal         +libcall         +profile         +visualextra&#xA;+cryptv          +linebreak       +python/dyn      +viminfo&#xA;+cscope          +lispindent      -python3         +vreplace&#xA;+cursorbind      +listcmds        +quickfix        +wildignore&#xA;+cursorshape     +localmap        +reltime         +wildmenu&#xA;+dialog_con      -lua             +rightleft       +windows&#xA;+diff            +menu            -ruby            +writebackup&#xA;+digraphs        +mksession       +scrollbind      -X11&#xA;-dnd             +modify_fname    +signs           -xfontset&#xA;-ebcdic          +mouse           +smartindent     -xim&#xA;+emacs_tags      -mouseshape      -sniff           -xsmp&#xA;+eval            +mouse_dec       +startuptime     -xterm_clipboard&#xA;+ex_extra        +mouse_gpm       +statusline      -xterm_save&#xA;+extra_search    -mouse_jsbterm   -sun_workshop    -xpm&#xA;   system vimrc file: &quot;/etc/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  fall-back for $VIM: &quot;/etc&quot;&#xA; f-b for $VIMRUNTIME: &quot;/usr/share/vim/vim74&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE   -L/usr/local/lib -Wl,--as-needed -o vim        -lm -lnsl  -lselinux  -ltinfo -lacl -lattr -lgpm   -Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE  -fstack-protector  -L/usr/lib64/perl5/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't made any changes to the default settings, and I don't have a &lt;code&gt;~/.vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;unzip is also installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ unzip&#xA;UnZip 6.00 of 20 April 2009, by Info-ZIP.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why are archive files unreadable? What other settings can I check?&lt;/p&gt;&#xA;" OwnerUserId="10145" LastEditorUserId="10145" LastEditDate="2019-12-11T00:39:44.867" LastActivityDate="2019-12-11T02:37:13.760" Title="Archive files opened with Vim are unreadable, even with zip plugins installed" Tags="|plugin-zip|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22223" PostTypeId="2" ParentId="22208" CreationDate="2019-12-10T16:16:57.347" Score="2" Body="&lt;p&gt;Checking the output of &lt;code&gt;filter&lt;/code&gt; helped diagnose the problem, my vimrc also contained the following line: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; If installed using Homebrew&#xA;Plug '/usr/local/opt/fzf'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which referred to a program (&lt;a href=&quot;https://github.com/junegunn/fzf&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf&lt;/a&gt;) that wasn't installed but also couldn't be installed by &lt;code&gt;vim-plug&lt;/code&gt;. Installing it &lt;a href=&quot;https://github.com/junegunn/fzf#as-vim-plugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;properly&lt;/a&gt; fixed the problem.&lt;/p&gt;&#xA;" OwnerUserId="16232" LastActivityDate="2019-12-10T16:16:57.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22224" PostTypeId="1" AcceptedAnswerId="22239" CreationDate="2019-12-10T19:06:33.243" Score="3" ViewCount="2777" Body="&lt;p&gt;My Neovim cursor normally switches to a pipe symbol (&lt;code&gt;|&lt;/code&gt;) when I'm in &lt;code&gt;st&lt;/code&gt;, but it doesn't when &lt;code&gt;tmux&lt;/code&gt; is open in &lt;code&gt;st&lt;/code&gt;. Is there something special to do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Version:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Neovim: &lt;code&gt;v0.5.0-dev&lt;/code&gt;&lt;br&gt;&#xA;  Tmux: &lt;code&gt;2.9a&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My config files:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/AnatoleLucet/dotfile/tree/master/nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neovim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/AnatoleLucet/dotfile/tree/master/tmux&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tmux&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/AnatoleLucet/dotfile/tree/master/st&quot; rel=&quot;nofollow noreferrer&quot;&gt;St&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm not very experienced with these three programs, so if you need more information feel free to ask me!&lt;/p&gt;&#xA;" OwnerUserId="26050" LastEditorUserId="1238" LastEditDate="2019-12-10T20:42:12.837" LastActivityDate="2019-12-12T14:14:27.497" Title="Change Neovim cursor in insert mode under st (simple terminal) and tmux" Tags="|neovim|tmux|st|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22225" PostTypeId="2" ParentId="22224" CreationDate="2019-12-10T20:38:56.290" Score="0" Body="&lt;p&gt;For Vim (not NeoVim), it all has to do with special terminal escape sequences (see &lt;code&gt;:help terminal-options&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I remember, &lt;code&gt;tmux&lt;/code&gt; doesn't support the requisite codes out of the box (though apparently &lt;code&gt;st&lt;/code&gt; does?). Most GUI versions do automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to monkey around with it, the relevant options are documented at &lt;code&gt;:help termcap-cursor-shape&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-12-10T20:58:29.753" LastActivityDate="2019-12-10T20:58:29.753" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22226" PostTypeId="2" ParentId="22222" CreationDate="2019-12-11T02:37:13.760" Score="3" Body="&lt;p&gt;This was caused by my &lt;code&gt;umask&lt;/code&gt; setting in my &lt;code&gt;~/.bashrc&lt;/code&gt;. It was set to 133:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ umask&#xA;0133&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I set it to 033 and it fixed the issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ umask 033&#xA;$ umask&#xA;0033&#xA;$ vim test.zip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; zip.vim version v27&#xA;&quot; Browsing zipfile /home/badjr/tes/test.zip&#xA;&quot; Select a file with cursor and press ENTER&#xA;&#xA;testfile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not sure how that particular &lt;code&gt;umask&lt;/code&gt; was affecting this, but the difference in 0 and 1 in &lt;code&gt;umask&lt;/code&gt; is that 0 has directory permission &lt;code&gt;rwx&lt;/code&gt; as opposed to 1 having &lt;code&gt;rw-&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10145" LastActivityDate="2019-12-11T02:37:13.760" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22227" PostTypeId="1" CreationDate="2019-12-11T02:43:02.987" Score="1" ViewCount="586" Body="&lt;p&gt;I have many key mappings in my vimrc but for some reason no matter what I do q remains mapped to recording macros. I will post my full vimrc below, but the relevant part is that even if the last line in it is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;q&amp;gt; &amp;lt;b&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I press q it waits for another keypress then starts recording. I tried mapping to other things like  and  and those don't work either. If I do :map q it says no mapping found. I can remap everything else just fine, including  and .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my full vimrc if that might help &lt;a href=&quot;https://pastebin.com/6fDL2Ncb&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pastebin.com/6fDL2Ncb&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26055" LastActivityDate="2019-12-11T02:58:07.477" Title="Why can't I remap q" Tags="|key-bindings|terminal|macro|" AnswerCount="1" CommentCount="0" ClosedDate="2019-12-11T13:07:06.997" ContentLicense="CC BY-SA 4.0" />
  <row Id="22228" PostTypeId="2" ParentId="22227" CreationDate="2019-12-11T02:58:07.477" Score="2" Body="&lt;p&gt;I found the answer was I needed&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap q b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;without the &amp;lt;&gt;&lt;/p&gt;&#xA;" OwnerUserId="26055" LastActivityDate="2019-12-11T02:58:07.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22229" PostTypeId="1" CreationDate="2019-12-11T13:50:49.177" Score="1" ViewCount="100" Body="&lt;p&gt;I saw that it's possible to manually add types to highlight, according to this post: &lt;a href=&quot;https://stackoverflow.com/questions/20149478/how-can-i-teach-vim-about-additional-c-language-types-for-syntax-highlighting&quot;&gt;https://stackoverflow.com/questions/20149478/how-can-i-teach-vim-about-additional-c-language-types-for-syntax-highlighting&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I was wondering if it's possible for vim to automatically highlight typedefs?&lt;/p&gt;&#xA;" OwnerUserId="25193" LastActivityDate="2019-12-11T13:50:49.177" Title="How to correctly add syntax highlighting to all c typedef" Tags="|syntax-highlighting|filetype-c++|filetype-c|" AnswerCount="0" CommentCount="3" ClosedDate="2019-12-14T16:07:56.903" ContentLicense="CC BY-SA 4.0" />
  <row Id="22230" PostTypeId="1" CreationDate="2019-12-11T15:11:30.537" Score="2" ViewCount="226" Body="&lt;p&gt;Sometimes it takes a really long time to save a file out. Saving the same file after various changes takes various amounts of time. It does not seem to be related to file size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've disabled any plugins that could possibly do something at save time (I think). It is probably one of my autocommand groups so I'll be disabling them one at a time next.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this got me thinking. I know you can profile startup in a very detailed way. I was wondering if it was possible to do the same for save? Then I could see which plugin or autocommand group is taking the most time, make adjustments, and compare the actual times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to profile save times in a similar way to which we can profile startup times?&lt;/p&gt;&#xA;" OwnerUserId="1154" LastActivityDate="2019-12-11T15:11:30.537" Title="How to profile save time" Tags="|neovim|autocmd|plugin-system|save|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22231" PostTypeId="1" AcceptedAnswerId="22233" CreationDate="2019-12-11T17:51:17.130" Score="1" ViewCount="740" Body="&lt;p&gt;How do I disable vim-surround in visual (selection) mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IE.  If I hit &lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;S&lt;/kbd&gt; I want to replace all the lines I have currently selected ( the normal vim functionality )&lt;/p&gt;&#xA;" OwnerUserId="25120" LastEditorUserId="1238" LastEditDate="2019-12-12T13:23:40.397" LastActivityDate="2019-12-13T07:08:51.163" Title="Vim-Surround but not shift+S in visual mode" Tags="|plugin-vim-surround|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22232" PostTypeId="1" AcceptedAnswerId="22234" CreationDate="2019-12-11T18:23:59.040" Score="3" ViewCount="635" Body="&lt;p&gt;I want to be able to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:42y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:13p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;having it to paste the yanked line in a new line after 13, without taking my cursor away. So far, all solutions I have found involves going to the paste region, as calling&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:13&amp;lt;ENTER&amp;gt;p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(or similar) - but then loosing the cursor position.&lt;/p&gt;&#xA;" OwnerUserId="25873" LastActivityDate="2019-12-11T20:45:46.063" Title="Yank then Paste without moving cursor" Tags="|cut-copy-paste|normal-mode|cursor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22233" PostTypeId="2" ParentId="22231" CreationDate="2019-12-11T18:58:36.253" Score="3" Body="&lt;p&gt;You can simply unmap it just as any other mapping in Vim. But if doing this from vimrc you have to delay the unmap until the plugin was &lt;em&gt;actually&lt;/em&gt; loaded. If using Vim8 builtin &lt;code&gt;:h packages&lt;/code&gt; that happens &lt;em&gt;after&lt;/em&gt; your vimrc has been processed. Therefore some additional steps must be taken. The rest is how to deal with this particular problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several ways to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;0) Actually, you can tell the plugin to disable all builtin mappings and create ones you really use manually:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let g:surround_no_mappings = 1&#xA;    &quot; copied from plugin/surround.vim&#xA;    nmap ds  &amp;lt;Plug&amp;gt;Dsurround&#xA;    nmap cs  &amp;lt;Plug&amp;gt;Csurround&#xA;    nmap cS  &amp;lt;Plug&amp;gt;CSurround&#xA;    nmap ys  &amp;lt;Plug&amp;gt;Ysurround&#xA;    nmap yS  &amp;lt;Plug&amp;gt;YSurround&#xA;    nmap yss &amp;lt;Plug&amp;gt;Yssurround&#xA;    nmap ySs &amp;lt;Plug&amp;gt;YSsurround&#xA;    nmap ySS &amp;lt;Plug&amp;gt;YSsurround&#xA;    &quot; ----- remove these -----&#xA;    &quot;xmap S   &amp;lt;Plug&amp;gt;VSurround&#xA;    &quot;xmap gS  &amp;lt;Plug&amp;gt;VgSurround&#xA;    imap    &amp;lt;C-S&amp;gt; &amp;lt;Plug&amp;gt;Isurround&#xA;    imap    &amp;lt;C-G&amp;gt;s &amp;lt;Plug&amp;gt;Isurround&#xA;    imap    &amp;lt;C-G&amp;gt;S &amp;lt;Plug&amp;gt;ISurround&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;1) Unmap on VimEnter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    augroup vimrc_unmap | au!&#xA;        autocmd VimEnter * ++once xunmap S&#xA;        autocmd VimEnter * ++once xunmap gS&#xA;    augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2) Force early plugin load and then unmap it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    packadd vim-surround&#xA;    xunmap S&#xA;    xunmap gS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;3) &quot;Polish&quot; your setup from &lt;code&gt;after/plugin/&lt;/code&gt; subdirectory&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;~/.vim/after/plugin/final.vim&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    &quot; delete superfluous vim-surround mappings&#xA;    xunmap S&#xA;    xunmap gS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-12-13T07:08:51.163" LastActivityDate="2019-12-13T07:08:51.163" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22234" PostTypeId="2" ParentId="22232" CreationDate="2019-12-11T20:26:58.117" Score="5" Body="&lt;p&gt;You can define your special version of &quot;put&quot; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar -bang -range -register Put call append(&amp;lt;line2&amp;gt; - &amp;lt;bang&amp;gt;0, getreg(&amp;lt;q-reg&amp;gt;, 1, 1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;13Pu&lt;/code&gt; works without any jumping around.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-12-11T20:45:46.063" LastActivityDate="2019-12-11T20:45:46.063" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22235" PostTypeId="2" ParentId="17393" CreationDate="2019-12-11T22:12:10.163" Score="1" Body="&lt;p&gt;One thing I've just seen is that if &lt;code&gt;cpo&lt;/code&gt; contains &lt;code&gt;&amp;lt;&lt;/code&gt;, then special characters like &lt;code&gt;&amp;lt;leader&amp;gt;&lt;/code&gt; won't be handled right:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                *cpo-&amp;lt;*&#xA;        &amp;lt;   Disable the recognition of special key codes in |&amp;lt;&amp;gt;|&#xA;            form in mappings, abbreviations, and the &quot;to&quot; part of&#xA;            menu commands.  For example, the command&#xA;            &quot;:map X &amp;lt;Tab&amp;gt;&quot; results in X being mapped to:&#xA;                '&amp;lt;' included:   &quot;&amp;lt;Tab&amp;gt;&quot;  (5 characters)&#xA;                '&amp;lt;' excluded:   &quot;^I&quot;     (^I is a real &amp;lt;Tab&amp;gt;)&#xA;            Also see the 'k' flag above.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default for &lt;code&gt;vi&lt;/code&gt; (note: not &lt;code&gt;vim&lt;/code&gt;) is all flags—perhaps the global vimrc is being read by &lt;code&gt;vi&lt;/code&gt; or &lt;code&gt;vim&lt;/code&gt; in compatible mode?&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-12-11T22:12:10.163" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22236" PostTypeId="2" ParentId="22190" CreationDate="2019-12-11T23:15:24.300" Score="1" Body="&lt;p&gt;I eventually figured out it was &lt;code&gt;cindent&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="158" LastActivityDate="2019-12-11T23:15:24.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22237" PostTypeId="2" ParentId="22071" CreationDate="2019-12-12T08:49:37.130" Score="0" Body="&lt;p&gt;Carefully read what is inside your vim configuration. It turned out I was setting &lt;code&gt;let $LANG='en'&lt;/code&gt; in my &lt;code&gt;vimrc&lt;/code&gt; in part I took from &lt;a href=&quot;https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="25849" LastActivityDate="2019-12-12T08:49:37.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22239" PostTypeId="2" ParentId="22224" CreationDate="2019-12-12T14:09:06.450" Score="5" Body="&lt;p&gt;You need to tell Tmux how to translate the control sequences sent by Nvim to the outer terminal, here st.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is done by setting the unofficial extensions to terminfo &lt;code&gt;Ss&lt;/code&gt; and &lt;code&gt;Se&lt;/code&gt;.&#xA;From &lt;code&gt;man tmux&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;Ss, Se  Set or reset the cursor style.  If set, a sequence such as this&#xA;        may be used to change the cursor to an underline:&#xA;&#xA;              $ printf '\033[4 q'&#xA;&#xA;        If Se is not set, Ss with argument 0 will be used to reset the&#xA;        cursor style instead.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also &lt;code&gt;:h tui-cursor-tmux&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Nvim documentation suggests this setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it seems to contain 2 errors.&#xA;First &lt;code&gt;terminal-overrides&lt;/code&gt; is not a session option anymore, but a &lt;a href=&quot;https://github.com/tmux/tmux/blob/0d99519c3d3522e9281f8e0726e3d71fcf3e57f3/CHANGES#L890&quot; rel=&quot;noreferrer&quot;&gt;server option&lt;/a&gt;. So the &lt;code&gt;-g&lt;/code&gt; flag is useless; instead you should pass the &lt;code&gt;-s&lt;/code&gt; flag to &lt;code&gt;set-option&lt;/code&gt;. Although, in practice, it should not matter because Tmux is able to infer the type of an option from its name (except if it's a user option).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, the control sequence &lt;code&gt;\E[ q&lt;/code&gt; doesn't seem to match the &lt;code&gt;Se&lt;/code&gt; capability of st, nor the one of xterm.&#xA;At least on my machine, &lt;code&gt;Se&lt;/code&gt; contains the sequence &lt;code&gt;\E[2 q&lt;/code&gt;. You can check on yours by running the shell command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ infocmp -1x | grep Se&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All in all, you could try to add this line to your &lt;code&gt;tmux.conf&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set -as terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[2 q'&#xA;#                           │ ├┘ ├────────┘ ├┘ ├────┘&#xA;#                           │ │  │          │  └ override with this control sequence;&#xA;#                           │ │  │          │    restore the cursor shape to a block&#xA;#                           │ │  │          │&#xA;#                           │ │  │          └ `Se` capability in the terminfo database&#xA;#                           │ │  │&#xA;#                           │ │  └ override the current value with this new one;&#xA;#                           │ │    set the cursor shape to the one specified by&#xA;#                           │ │    the digit `%d`&#xA;#                           │ │&#xA;#                           │ └ `Ss` capability in the terminfo database&#xA;#                           │&#xA;#                           └ for all terminals (no matter the value of `$TERM`)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may need to change the control sequences assigned to the &lt;code&gt;Ss&lt;/code&gt; and &lt;code&gt;Se&lt;/code&gt; capabilities; make sure they match whatever &lt;code&gt;$ infocmp -1x | grep 'S[se]'&lt;/code&gt; outputs (ignore the trailing commas).&#xA;You may also want to limit the assignments to the st terminal; in that case, replace the leading &lt;code&gt;*&lt;/code&gt; terminal name pattern with something like &lt;code&gt;st&lt;/code&gt;, &lt;code&gt;st-256color&lt;/code&gt; or &lt;code&gt;st-*&lt;/code&gt;. Check the value of &lt;code&gt;$TERM&lt;/code&gt; in your st terminal, outside Tmux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the new value to take effect, you can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;restart the Tmux server after killing the current one (&lt;code&gt;$ tmux kill-server&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;start a new one (&lt;code&gt;$ tmux -Lx&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;detach your tmux client (&lt;code&gt;$ tmux detach-client&lt;/code&gt;) and re-attach it (&lt;code&gt;$ tmux attach-session&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-12-12T14:14:27.497" LastActivityDate="2019-12-12T14:14:27.497" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22240" PostTypeId="1" CreationDate="2019-12-12T23:01:48.353" Score="2" ViewCount="1656" Body="&lt;p&gt;Currently I am working a lot with objdump output (arm / thumb instructions): &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command (&lt;code&gt;arm-none-eabi-objdump -h -S main.elf &amp;gt; main.lst&lt;/code&gt;) creates a mixture of assembly (with addresses and hex representations) and c-code. Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;080009e4 &amp;lt;configure_led1&amp;gt;:&#xA;&#xA;// configure ccu4 of led1&#xA;void configure_led1(uint16_t off_time, uint16_t on_time){&#xA; 80009e4:       b480            push    {r7}&#xA; 80009e6:       b085            sub     sp, #20&#xA; 80009e8:       af00            add     r7, sp, #0&#xA; 80009ea:       4603            mov     r3, r0&#xA; 80009ec:       460a            mov     r2, r1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately the syntax highlighting of vim gets confused by this file. It uses assembly syntax highlighting for the file (&lt;code&gt;:set filetype?&lt;/code&gt; returns &lt;code&gt;asm&lt;/code&gt;). This syntax doesn't work well with the instruction addresses and hex representations in front of the actual assembly instructions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I need to configure vim to use correct highlighting? Does vim have a specific filetype for objdump output?&lt;/p&gt;&#xA;" OwnerUserId="16706" LastActivityDate="2019-12-13T09:58:54.260" Title="Syntax highlighting for objdump output" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22242" PostTypeId="2" ParentId="20958" CreationDate="2019-12-13T06:48:45.097" Score="2" Body="&lt;p&gt;python-language-server requires registration. (See &lt;a href=&quot;https://github.com/prabirshrestha/vim-lsp/wiki/Servers-Python&quot; rel=&quot;nofollow noreferrer&quot;&gt;Servers-Python&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Here are two options to do this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Install &lt;a href=&quot;https://github.com/prabirshrestha/vim-lsp&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-lsp&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Register the python-language-server in .vimrc&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre&gt;&lt;code&gt;if executable('pyls')&#xA;    au User lsp_setup call lsp#register_server({&#xA;        \ 'name': 'pyls',&#xA;        \ 'cmd': {server_info-&amp;gt;['pyls']},&#xA;        \ 'allowlist': ['python'],&#xA;        \ })&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11022" LastEditorUserId="11022" LastEditDate="2022-09-26T04:42:38.670" LastActivityDate="2022-09-26T04:42:38.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22243" PostTypeId="2" ParentId="22240" CreationDate="2019-12-13T09:52:14.377" Score="2" Body="&lt;p&gt;This is rather meant as a demonstration, not a full-featured syntax file. But it should work correctly against an example above (except only few assemblers, such as GNU, support C/C++ comments natively; in general such comments should be marked as C syntax region).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;~/.vim/syntax/objdump.vim&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; standard guard against syntax clash&#xA;if exists(&quot;b:current_syntax&quot;)&#xA;    finish&#xA;endif&#xA;&#xA;&quot; Asm is our main syntax; C is an extra one&#xA;runtime! syntax/asm.vim&#xA;unlet b:current_syntax&#xA;syntax include @C syntax/c.vim&#xA;unlet b:current_syntax&#xA;&#xA;&quot; a line starting with [A-Za-z_] is a C line&#xA;syntax region odCLine start=/^\h/ end=/$/ keepend contains=@C&#xA;&#xA;&quot; a line starting with a hex number is an objdump address/opcode&#xA;&quot; stop at [:xdigit:][:blank:][:blank:] to interpret the rest as asm instruction (default)&#xA;syntax region odHead start='^\s*\x\+\&amp;gt;' end=/\x\s\{2,}\|$/ keepend contains=odHex,asmIdentifier&#xA;&#xA;&quot; hex number w/o any prefix (deadbeef)&#xA;syntax match odHex '\&amp;lt;\x\+\&amp;gt;' contained&#xA;hi def link odHex hexNumber&#xA;&#xA;&quot; assign current syntax&#xA;let b:current_syntax = 'objdump'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, you still need filetype/ftdetect to make it working.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-12-13T09:58:54.260" LastActivityDate="2019-12-13T09:58:54.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22244" PostTypeId="1" AcceptedAnswerId="22245" CreationDate="2019-12-13T16:26:48.987" Score="4" ViewCount="431" Body="&lt;p&gt;I have a couple of &lt;code&gt;autocmd&lt;/code&gt;s in my vim config along the lines of this (the actual commands are quite long):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    au BufWritePost *.latex.md  silent! ...&#xA;    au BufWritePost *.md  silent! ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where writing files with &lt;code&gt;.md&lt;/code&gt; or &lt;code&gt;.latex.md&lt;/code&gt; extensions runs pandoc to convert my markdown files into the corresponding format. The problem I have (which you have probably guessed by looking at the example above) is that globbing for &lt;code&gt;*.md&lt;/code&gt; subsumes files with a &lt;code&gt;.latex.md&lt;/code&gt; extension. This means that files with that extension produce both HTML and a PDF, which is unnecessary. Is there any way to make the two autocommands mutually exlusive, or do I need to create a command or function that runs the correct command instead? &lt;/p&gt;&#xA;" OwnerUserId="26025" LastActivityDate="2019-12-14T10:06:40.570" Title="mutually exclusive Autocommands for similar file extensions" Tags="|autocmd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22245" PostTypeId="2" ParentId="22244" CreationDate="2019-12-13T16:40:30.113" Score="1" Body="&lt;p&gt;There's more to the autocmd pattern than &lt;code&gt;*&lt;/code&gt;. Using other wildcards should give more flexibility in crafting patterns that don't overlap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the pattern matching for autocmd is not standard/vim regex and it's not shell-like globbing. It's a modified version of vim regex. Example: &lt;code&gt;.&lt;/code&gt; represents a period not &quot;any character except newline&quot;. &lt;code&gt;:h file-pattern&lt;/code&gt; gives the details. From there we can try to come up with appropriate translations from standard to modified regex. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first I thought the translation rules were too restrictive to allow use of some of the more advanced regex atoms (e.g lookahead/lookbehind). But a comment from @user938271 made me rethink that and after some testing we come to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.latex.md ...&#xA;autocmd BufWritePost *{.latex}\@&amp;lt;!.md ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The negative lookbehind should ensure that the two autocmds are mutually exclusive (only one will be triggered for a given filename).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, all I had to do was replace &lt;code&gt;\(...\)&lt;/code&gt; with &lt;code&gt;{...}&lt;/code&gt;. Overthinking made this much harder than it should have been.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-12-14T10:06:40.570" LastActivityDate="2019-12-14T10:06:40.570" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="22246" PostTypeId="2" ParentId="22244" CreationDate="2019-12-13T16:55:55.323" Score="3" Body="&lt;p&gt;You can examine a match and then decide what to do. Whether to use multiple autocommands or &quot;bar-newline-backslash&quot; is a matter of style.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup mywritepost | au!&#xA;    autocmd BufWritePost *.md if expand(&quot;&amp;lt;afile&amp;gt;&quot;) =~? '\.latex\.md$'&#xA;    autocmd BufWritePost *.md     call s:makepdf()&#xA;    autocmd BufWritePost *.md else&#xA;    autocmd BufWritePost *.md     call s:makehtml()&#xA;    autocmd BufWritePost *.md endif&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-12-13T17:03:18.327" LastActivityDate="2019-12-13T17:03:18.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22247" PostTypeId="1" AcceptedAnswerId="27205" CreationDate="2019-12-13T18:01:35.673" Score="3" ViewCount="754" Body="&lt;p&gt;Working in an index with mucked up manual folds. Would like to delete folds from current line to end of file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,$zd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:.,$df&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far I've just done a visual selection from current line to end of file and keyed in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;zD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to delete all folds recursively in the selection. Works, but would be nice if there was a way to enter a range instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thoughts?&lt;/p&gt;&#xA;" OwnerUserId="23470" LastActivityDate="2020-09-09T04:23:34.307" Title="Deleting folds over a range" Tags="|folding|range|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22248" PostTypeId="2" ParentId="22247" CreationDate="2019-12-13T18:14:28.843" Score="0" Body="&lt;p&gt;I'm not sure if it's a good idea, but you can wrap it into Ex command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar -range DeleteFolds execute printf(&quot;normal! %dGV%dGzD&quot;, &amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-13T18:14:28.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22249" PostTypeId="1" AcceptedAnswerId="22250" CreationDate="2019-12-13T21:10:11.163" Score="1" ViewCount="116" Body="&lt;p&gt;Let's assume there is a macro stored in register 'r'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can obtain the contents of this register by executing &lt;code&gt;getreg('r')&lt;/code&gt;, but if I print this then it can often be unreadable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed though that if I execute &lt;code&gt;:registers&lt;/code&gt; that the contents of the 'r' register is displayed in a readable format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this without calling &lt;code&gt;:registers&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="132" LastActivityDate="2019-12-14T16:03:36.417" Title="How to convert register contents to something readable similar to :register command?" Tags="|vimscript|register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22250" PostTypeId="2" ParentId="22249" CreationDate="2019-12-14T16:03:36.417" Score="4" Body="&lt;p&gt;Assuming you want to put the register contents in a buffer use Normal mode command sequence &lt;code&gt;&quot;rp&lt;/code&gt;. That'll produce the same thing as you'd see with &lt;code&gt;:reg r&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing with &lt;code&gt;getreg()&lt;/code&gt; is that it doesn't attempt to output printable characters. For example, if register &quot;r&quot; contains a backspace and you send &lt;code&gt;getreg('r')&lt;/code&gt; output to a buffer (e.g. with &lt;code&gt;&amp;lt;C-R&amp;gt;=getreg('r')&lt;/code&gt; while in Insert mode) then the backspace will actually move the cursor back. &#xA;But if you paste the register directly you'll see printable translations of everything. (Example: for me backspace is displayed as &lt;code&gt;&amp;lt;80&amp;gt;kb&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that there is a function that does similar translation to printable characters on whatever you pass to it called &lt;code&gt;strtrans()&lt;/code&gt;. Modifying the Insert mode command mentioned above to be &lt;code&gt;&amp;lt;C-R&amp;gt;=strtrans(getreg('r'))&lt;/code&gt; will display the same thing as &lt;code&gt;&quot;rp&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2019-12-14T16:03:36.417" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22251" PostTypeId="2" ParentId="7684" CreationDate="2019-12-14T20:10:53.363" Score="4" Body="&lt;p&gt;I was facing same problem with &lt;code&gt;gvim&lt;/code&gt; on Linux.&lt;/p&gt;&#xA;&lt;p&gt;Put following in your &lt;code&gt;~/.gvimrc&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set guioptions+=!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Explanation from &lt;code&gt;:help guioptions&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;'!'    External commands are executed in a terminal window.  Without&#xA;this flag the MS-Windows GUI will open a console window to         execute&#xA;the command.  The Unix GUI will simulate a dumb       terminal to list the&#xA;command output.       The terminal window will be positioned at the&#xA;bottom, and grow      upwards as needed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="22052" LastEditorUserId="22052" LastEditDate="2020-07-05T12:54:44.017" LastActivityDate="2020-07-05T12:54:44.017" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22252" PostTypeId="2" ParentId="13509" CreationDate="2019-12-15T01:21:43.877" Score="2" Body="&lt;p&gt;I recently addressed this problem by writing a Vimscript function (tested and pasted below) that walks up the directory tree from the current file and sets as the tags file the first file named &quot;tags&quot; that it sees directly under a parent directory (i.e. the function doesn't explore sibling directories). I then make a mapping for the function. (I don't make it a BufNewFile/BufRead autocommand because personally I don't want the tags file changing unexpectedly on me.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! UseNearestParentTagsFile()&#xA;  let l:path = &quot;%:p&quot;&#xA;  while expand(l:path) != &quot;/&quot;&#xA;    let l:path = l:path . &quot;:h&quot;&#xA;    if filereadable(expand(l:path) . &quot;/tags&quot;)&#xA;      exe &quot;set tags=&quot; . expand(l:path) . &quot;/tags&quot;&#xA;      return&#xA;    endif&#xA;  endwhile&#xA;  echom &quot;No tags file found in path.&quot;&#xA;endfunction&#xA;command! UseNearestParentTagsFile call UseNearestParentTagsFile()&#xA;nnoremap &amp;lt;leader&amp;gt;st :UseNearestParentTagsFile&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In fact the above solves a problem slightly different yours because you asked about using the tags file closest to the &lt;em&gt;working&lt;/em&gt; directory, not the directory containing the file. For a version of the function above for the working directory, try the following (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! UseNearestParentTagsFile()&#xA;  let l:path = getcwd() . &quot;/&quot;&#xA;  while l:path != &quot;/&quot;&#xA;    let l:path = fnamemodify(l:path, &quot;:h&quot;)&#xA;    if filereadable(l:path . &quot;/tags&quot;)&#xA;      exe &quot;set tags=&quot; . l:path . &quot;/tags&quot;&#xA;      return&#xA;    endif&#xA;  endwhile&#xA;  echom &quot;No tags file found in path.&quot;&#xA;endfunction&#xA;command! UseNearestParentTagsFile call UseNearestParentTagsFile()&#xA;nnoremap &amp;lt;leader&amp;gt;st :UseNearestParentTagsFile&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for your criteria:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Simple: I would say yes. Just put the above somewhere like your vimrc file.&lt;/li&gt;&#xA;&lt;li&gt;Well-supported: I suppose not, except in the sense that there isn't really much to support.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19415" LastEditorUserId="19415" LastEditDate="2019-12-15T22:06:18.567" LastActivityDate="2019-12-15T22:06:18.567" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22253" PostTypeId="1" CreationDate="2019-12-15T05:55:28.593" Score="3" ViewCount="1520" Body="&lt;p&gt;In most cases, I want to use the same setting. However, when I write the makefile file, I need to use tab instead of space, so I need to execute the &lt;code&gt;:set noexpandtab&lt;/code&gt; for all the makefile file. In order to simplify this process, I want to write this to .vimrc, but I don't know how to execute this command according to the name of the file being edited.&lt;/p&gt;&#xA;" OwnerUserId="23637" LastActivityDate="2019-12-16T12:48:02.220" Title="How can I use different vim setting for different filename?" Tags="|original-vim|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22254" PostTypeId="2" ParentId="22253" CreationDate="2019-12-15T06:41:35.413" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;autocmd&lt;/code&gt; for this. First run the following command to know the FileType (while your makefile is open) -&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set filetype?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will show you the filetype. Then you can put the following in your &lt;code&gt;vimrc&lt;/code&gt; to set settings for specifice fitetype like this - &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup makefilesettings&#xA;    autocmd!&#xA;    autocmd FileType makefile setlocal noexpandtab&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9062" LastActivityDate="2019-12-15T06:41:35.413" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22255" PostTypeId="2" ParentId="22210" CreationDate="2019-12-15T12:51:25.293" Score="1" Body="&lt;p&gt;Use vim-ctrlspace. It allows managing workspaces(saving and restoring full state of vim) and loading tabs (tab workspaces ). &#xA;Handle tab for each project, and &#xA;use &lt;code&gt;lcd&lt;/code&gt;  to get different folders for different tabs, and have ctrlp look in the current directory (there is a command &lt;code&gt;:CtrlPCurWD&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also suggest my changes to vim-ctrlspace &lt;a href=&quot;https://github.com/eyalk5/vim-ctrlspace&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/eyalk5/vim-ctrlspace&lt;/a&gt; that allows managing all workspaces in single file, independently of the working folder. But it doesn't handle well &lt;code&gt;lcd&lt;/code&gt; (need to fix). So either fix that or work with the original.&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-12-15T13:09:15.730" LastActivityDate="2019-12-15T13:09:15.730" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22256" PostTypeId="2" ParentId="22253" CreationDate="2019-12-15T14:20:20.280" Score="6" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/15329/10604&quot;&gt;As I have written about extensively&lt;/a&gt;, the vim technique for this type of thing is called an &lt;code&gt;ftplugin&lt;/code&gt;, which stands for filetype-plugin. What that means is that certain filetypes have different settings than others. &lt;code&gt;make&lt;/code&gt; is one such filetype. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim comes with a set of filetype detecters that are enabled when you do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, you can ask vim to load any filetype-specific plugin code (which can be arbitrarily awesome!) and indent code with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Most vim users I know have this command in their vimrc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the default ftplugin for makefiles sets &lt;code&gt;noexpandtab&lt;/code&gt;, I believe. If not, you can place&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal noexpandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in your personal vim ftplugin for make, which typically lives at &lt;code&gt;~/.vim/after/ftplugin/make.vim&lt;/code&gt; (though other names are possible). The &lt;code&gt;setlocal&lt;/code&gt; version makes the change unique to that buffer, which means all make buffers. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Why not auto-commands? Because it’s vimrc clutter and because vim already has autocommands that fire on a Filetype—and all they do is source the appropriate runtime files. It’s inelegant not to use this mechanism. It separates out my filetype settings so I can quickly focus on only what I need. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Since we're doing &quot;vim proper,&quot; I am obligated to also mention &lt;code&gt;b:undo_ftplugin&lt;/code&gt;—it is &lt;code&gt;execute&lt;/code&gt;d if the filetype changes, so you generally want it to be properly set. If you don't switch filetypes, no harm done, but to be on the safe side:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Don't forget to add to 'b:undo_ftplugin'&#xA;&quot; I've got a specialized framework for that over at&#xA;&quot; https://github.com/benknoble/Dotfiles/blob/master/links/vim/autoload/ftplugin.vim&#xA;&quot; but this is simpler and should work for your purpose&#xA;let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')&#xA;if ! empty(b:undo_ftplugin)&#xA;  let b:undo_ftplugin .= ' | '&#xA;endif&#xA;let b:undo_ftplugin .= 'setlocal expandtab&amp;lt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-12-15T16:25:48.190" LastActivityDate="2019-12-15T16:25:48.190" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="22257" PostTypeId="1" CreationDate="2019-12-15T15:41:42.530" Score="8" ViewCount="1580" Body="&lt;p&gt;I sometimes want to type an expression like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;table[row][col] = std::max(table[row][col], other_table[row+1][col+1])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(this is C++ code. Unfortunately there's no way in C++ to eliminate the duplication except by writing a helper function like &lt;code&gt;void update_max(auto&amp;amp; a, auto const&amp;amp; b) { a = std::max(a, b); }&lt;/code&gt; but that possibility won't be considered here)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I type the repeated part (&lt;code&gt;table[row][col]&lt;/code&gt;) quickly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For simplicity, you may assume the expression is &quot;simple&quot; (you can match it with some simple regex such as &lt;code&gt;.*;(.\{-})=&lt;/code&gt;), but solution for the general case is okay too. (the problem is that C++ grammar is very complex)&lt;/p&gt;&#xA;" OwnerUserId="26108" LastActivityDate="2020-01-13T16:07:17.447" Title="How to quickly type a C expression where the assigned-to variable is repeated?" Tags="|vimrc|" AnswerCount="7" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22258" PostTypeId="2" ParentId="22257" CreationDate="2019-12-15T15:41:42.530" Score="3" Body="&lt;p&gt;It's possible to use a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; sf &amp;lt;c-r&amp;gt;&amp;lt;c-r&amp;gt;=getline('.')[:col('.')-2]-&amp;gt;substitute('.*;','','')-&amp;gt;substitute('=.*','','')-&amp;gt;trim()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or an abbreviation (if the keychain consists of only &quot;normal&quot; keys, it's preferred to mapping, as a mapping may conflict with a part of another word, such as &lt;code&gt;transform&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abbr &amp;lt;expr&amp;gt; sf getline('.')[:col('.')-2]-&amp;gt;substitute('.*;','','')-&amp;gt;substitute('=.*','','')-&amp;gt;trim()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(it's necessary to have &lt;code&gt;-2&lt;/code&gt; because &lt;code&gt;col()&lt;/code&gt; returns the 1-indexing index of the next character on the cursor, while &lt;code&gt;[:]&lt;/code&gt; takes the 0-indexing byte index of the last character to be included)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This uses &lt;a href=&quot;https://vimhelp.org/eval.txt.html#method&quot; rel=&quot;nofollow noreferrer&quot;&gt;function or &quot;method&quot; chaining&lt;/a&gt;, a feature &lt;a href=&quot;https://vimhelp.org/version8.txt.html#new-vimscript-8.2&quot; rel=&quot;nofollow noreferrer&quot;&gt;new to Vim 8.2&lt;/a&gt;. For older version where such method calls are not available it's possible to instead use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abbr &amp;lt;expr&amp;gt; sf trim(substitute(substitute(getline('.')[:col('.')-2],'.*;','',''),'=.*','',''))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you only need to type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;table[row][col] = std::max(&lt;b&gt;sf&lt;/b&gt;, other_table[row+1][col+1])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;sf&lt;/code&gt; typed will expand to &lt;code&gt;table[row][col]&lt;/code&gt; in this case.&lt;/p&gt;&#xA;" OwnerUserId="26108" LastEditorUserId="26108" LastEditDate="2019-12-18T03:24:17.753" LastActivityDate="2019-12-18T03:24:17.753" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22259" PostTypeId="2" ParentId="22257" CreationDate="2019-12-15T20:01:55.240" Score="12" Body="&lt;p&gt;You can repeat the last inserted text in insert mode using &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-R&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;CTRL-R .&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-A&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;CTRL-A&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you need to leave insert mode to complete the change.  Enter insert mode and type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;table[row][col]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then leave insert mode and re-enter using &lt;kbd&gt;Esc&lt;/kbd&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#a&quot; rel=&quot;noreferrer&quot;&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;/a&gt; and type the rest of the line before the repeated part&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;table[row][col] = std::max(&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, type &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-R&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;CTRL-R .&lt;/code&gt;&lt;/a&gt; (or &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/insert.html#i_CTRL-A&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;CTRL-A&lt;/code&gt;&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;table[row][col] = std::max(table[row][col]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and finish the line.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2019-12-17T03:48:14.663" LastActivityDate="2019-12-17T03:48:14.663" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22260" PostTypeId="1" CreationDate="2019-12-15T20:21:43.743" Score="2" ViewCount="297" Body="&lt;p&gt;Vim has compiler plugin feature which enables the user to write a compiler configuration, and then running &lt;code&gt;:make&lt;/code&gt; will trigger the command, and &lt;code&gt;errorformat&lt;/code&gt; will parse the output and will print any error in the quickfix. &lt;a href=&quot;https://github.com/vim/vim/tree/master/runtime/compiler&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim already comes with many compilers configured out of the box&lt;/a&gt;. However, at any point, only one compiler is configured, and it is usually the compiler of the language that I work on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case, I work with an environment that has multiple tools that could indicate issues/errors in the code. Consider java for example, I might run the compiler to compile the code, JUnit to run the tests, checkstyle, to check for any style issues, FindBug to find potential bugs, Fortify, to find security issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose that I can find a compiler plugin for all of these tools, how can I use all of them together (maybe something like &lt;code&gt;make build&lt;/code&gt;, &lt;code&gt;make test&lt;/code&gt;, &lt;code&gt;make checkstyle&lt;/code&gt;, &lt;code&gt;make findbug&lt;/code&gt;, where each one of these commands uses a different plugin, thus different &lt;code&gt;errorformat&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Btw, I use neovim if that makes any difference.&lt;/p&gt;&#xA;" OwnerUserId="22203" LastActivityDate="2019-12-15T20:21:43.743" Title="Configuring Multiple Compiler Plugins in a Single Project" Tags="|neovim|makeprg|errorformat|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22261" PostTypeId="1" CreationDate="2019-12-16T02:01:04.987" Score="2" ViewCount="100" Body="&lt;p&gt;Vim 8.2 has been released a couple of days ago and as I was reading I see that you can display somehow functions prototype, I am pretty exciting about this I hope documentations come pretty soon, anyway the main feature within this update are pop-up windows. If a pop-up window its what I think it is: like a small window but with more volatile purpose, then when you writte something like [I or :reg the window that show-up wouldnt be already a pop-up window?&#xA;&lt;a href=&quot;https://www.vim.org/vim-8.2-released.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.vim.org/vim-8.2-released.php&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extra: If you already know something about displaying function protoype that would be awesome. &lt;/p&gt;&#xA;" OwnerUserId="26054" LastActivityDate="2019-12-16T02:01:04.987" Title="What is a pop_up windows?" Tags="|vim-windows|version|" AnswerCount="0" CommentCount="2" ClosedDate="2019-12-18T16:23:02.873" ContentLicense="CC BY-SA 4.0" />
  <row Id="22262" PostTypeId="1" AcceptedAnswerId="22264" CreationDate="2019-12-16T07:39:11.310" Score="3" ViewCount="260" Body="&lt;p&gt;I find it very strange that I can't find this question anywhere...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a mapping &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;C /\u&amp;lt;CR&amp;gt;&lt;/code&gt; to go to the next capital letter. I thought it would be useful to edit camelCase stuff, so if I had something like &lt;code&gt;oneTwoThree&lt;/code&gt; and I wanted to change it to &lt;code&gt;oneFourThree&lt;/code&gt; I could just put cursor on the &lt;code&gt;T&lt;/code&gt; and do &lt;code&gt;c&amp;lt;leader&amp;gt;C&lt;/code&gt;. However this does not work. Is there an easy way to make this work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I accidentally found out that pressing &lt;code&gt;&amp;lt;leader&amp;gt;Cc&amp;lt;leader&amp;gt;&lt;/code&gt; does what I want, I don't understand why.&lt;/p&gt;&#xA;" OwnerUserId="21104" LastEditorUserId="21104" LastEditDate="2019-12-16T08:03:23.847" LastActivityDate="2019-12-16T18:25:58.750" Title="Create a motion?" Tags="|key-bindings|cursor-motions|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22263" PostTypeId="2" ParentId="22257" CreationDate="2019-12-16T08:54:27.353" Score="1" Body="&lt;p&gt;For the given example, I would first type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;table[row][col]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;yBA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;before continuing the statement, then leaving insert mode and pressing &lt;code&gt;p&lt;/code&gt; to paste the expression when needed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Esc&amp;gt; &quot; Leave insert mode&#xA;yB    &quot; Yank the preceding WORD (moving the cursor)&#xA;A     &quot; Move cursor to end of line and enter insert mode &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I do think &lt;a href=&quot;https://vi.stackexchange.com/a/22259/23564&quot;&gt;Mass's similar answer&lt;/a&gt; is better, if you can recall it. I wasn't aware of it before reading.&lt;/p&gt;&#xA;" OwnerUserId="23564" LastActivityDate="2019-12-16T08:54:27.353" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22264" PostTypeId="2" ParentId="22262" CreationDate="2019-12-16T09:06:20.440" Score="2" Body="&lt;p&gt;&lt;code&gt;nnoremap&lt;/code&gt; adds your mapping to Normal mode only. But after &lt;code&gt;c&lt;/code&gt; you are in Operator-pending mode, where &lt;code&gt;&amp;lt;leader&amp;gt;C&lt;/code&gt; has no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it suffices to do just &lt;code&gt;noremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;C /\u&amp;lt;CR&amp;gt;&lt;/code&gt; instead. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;noremap&lt;/code&gt; is a convenient command to register mapping in three modes (normal, visual and operator-pending) at once.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="1238" LastEditDate="2019-12-16T18:25:58.750" LastActivityDate="2019-12-16T18:25:58.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22265" PostTypeId="2" ParentId="22257" CreationDate="2019-12-16T11:34:28.850" Score="0" Body="&lt;p&gt;A simplified solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt;&amp;lt;C-G&amp;gt; get(split(getline('.'), '[[:blank:],;()]\+'), nr2char(getchar()) - 1, '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now pressing &lt;code&gt;&amp;lt;C-G&amp;gt;1&lt;/code&gt; while editing the line will insert the first &quot;word&quot; of it. &quot;The word&quot; is anything bounded by blanks, commas, parentheses and semicolons. Feel free to edit the regex as you wish.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-16T11:34:28.850" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22266" PostTypeId="2" ParentId="22253" CreationDate="2019-12-16T12:48:02.220" Score="1" Body="&lt;p&gt;You can simply put this in your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if expand('%:t')==&quot;Makefile&quot;&#xA;&quot; do your stuff&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18912" LastActivityDate="2019-12-16T12:48:02.220" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22267" PostTypeId="2" ParentId="22257" CreationDate="2019-12-16T16:48:40.123" Score="1" Body="&lt;p&gt;As a &quot;vi veteran&quot; (30+ years) I may appear &quot;old fashioned&quot; but I prefer solutions working everywhere and always (without preparing much in a &lt;code&gt;.vimrc&lt;/code&gt; file), even if they require a tiny amount of planning ahead:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First insert the line as:&#xA;&lt;code&gt;@ = std::max(@, other_table[row+1][col+1])&lt;/code&gt; (+ &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; of course)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then type:&#xA;&lt;code&gt;:s/@/table[row][col]/g&lt;/code&gt; (+ &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; of course)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the latter, if you need it again some time later, &lt;code&gt;q:&lt;/code&gt; may be your friend … though this requires vim … but it is one vim's features I consider to be priceless.&lt;/p&gt;&#xA;" OwnerUserId="26127" LastEditorUserId="26127" LastEditDate="2019-12-16T16:53:46.220" LastActivityDate="2019-12-16T16:53:46.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22268" PostTypeId="1" AcceptedAnswerId="22269" CreationDate="2019-12-16T17:20:59.500" Score="0" ViewCount="104" Body="&lt;p&gt;Without any plugins, I am able to autocomplete &lt;code&gt;:vsp filena&amp;lt;tab&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder why I don't get autocompletion of filenames with &lt;code&gt;:o&lt;/code&gt;. I have tried this in different installations, terminals and OS.&lt;/p&gt;&#xA;" OwnerUserId="25873" LastEditorUserId="1238" LastEditDate="2019-12-16T18:06:54.190" LastActivityDate="2019-12-16T18:06:54.190" Title=":o autocomplete" Tags="|autocompletion|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22269" PostTypeId="2" ParentId="22268" CreationDate="2019-12-16T17:57:14.840" Score="2" Body="&lt;p&gt;&lt;code&gt;:o[pen]&lt;/code&gt; comes from Vi. It's intended to support so called &quot;open mode&quot; which is no-op in Vim. You should use &lt;code&gt;:e[dit]&lt;/code&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-16T17:57:14.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22270" PostTypeId="1" AcceptedAnswerId="22271" CreationDate="2019-12-16T20:24:57.810" Score="6" ViewCount="1527" Body="&lt;p&gt;Hi is  there a way to map German umlaute like &quot;ö&quot;, &quot;ä&quot;, &quot;ü&quot; to some keyboard shortcut, i.e. when I press the keyboard shortcut, it inserts the umlaut.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am German and use an English keyboard layout, but sometimes write in German.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="22310" LastActivityDate="2019-12-17T08:17:09.273" Title="german umlaute mapping" Tags="|key-bindings|keyboard-layout|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22271" PostTypeId="2" ParentId="22270" CreationDate="2019-12-16T21:19:34.407" Score="7" Body="&lt;p&gt;You might want to look into digraphs, which give you a built-in solution to accents and umlauts in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For umlauted &quot;u&quot; you can type:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;K&lt;/kbd&gt;, &lt;kbd&gt;:&lt;/kbd&gt;, &lt;kbd&gt;u&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;K&lt;/kbd&gt;, &lt;kbd&gt;u&lt;/kbd&gt;, &lt;kbd&gt;:&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/digraph.txt.html#digraphs-use&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help digraphs-use&lt;/code&gt;&lt;/a&gt; for using digraphs, or &lt;a href=&quot;https://vimhelp.org/digraph.txt.html#digraphs-default&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help digraphs-default&lt;/code&gt;&lt;/a&gt; for a very comprehensive list of the digraphs defined by default that you can use. (You will find umlaut is listed as &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Diaeresis_(diacritic)&quot; rel=&quot;noreferrer&quot;&gt;Diaeresis&lt;/a&gt; in that list.)&lt;/p&gt;&#xA;&#xA;&#xA;" OwnerUserId="18609" LastEditorUserId="1238" LastEditDate="2019-12-17T08:17:09.273" LastActivityDate="2019-12-17T08:17:09.273" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22272" PostTypeId="1" AcceptedAnswerId="22273" CreationDate="2019-12-17T00:09:44.560" Score="1" ViewCount="40" Body="&lt;p&gt;When one triggers a  completion, vim guesses what was the expression (behind the cursor) that you want to complete. I don't fully understand the logic, but it seems that it assumes that the expression is a sequence of alphabetic chars+some additional. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I have a graph named &quot;G_{walk}&quot; (I do have - latex). I want to refer to it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can trigger a completion that would recognize it when I type &lt;code&gt;G_&amp;lt;c-x&amp;gt;&amp;lt;c-n&amp;gt;&lt;/code&gt;. But if I type &lt;code&gt;G_{&amp;lt;c-x&amp;gt;&amp;lt;c-n&amp;gt;&lt;/code&gt;, it regards whatever that follows &lt;code&gt;{&lt;/code&gt; as a completely different expression and it won't find &quot;G_{walk}&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how can I control the expression? &#xA;Sometimes I just want it to ignore all its stupid rules, and complete from the moment I press a key and until I tell it to stop. Can it be done? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS I did read about ins-completion. I don't understand how what I see in &lt;code&gt;syntax list&lt;/code&gt; or how &lt;code&gt;omnifunction&lt;/code&gt; related to the question  I asked about &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-n&amp;gt;&lt;/code&gt; as main example. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2019-12-17T00:22:01.713" LastActivityDate="2019-12-17T00:32:28.090" Title="Recognizing the right expression to complete in insert mode" Tags="|plugin-vimtex|ins-completion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22273" PostTypeId="2" ParentId="22272" CreationDate="2019-12-17T00:32:28.090" Score="2" Body="&lt;p&gt;Most of auto-completion works with &lt;strong&gt;keywords&lt;/strong&gt;, so the set of characters that make up possible completion prefixes and candidates is controlled by the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27iskeyword%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'iskeyword'&lt;/code&gt; setting&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, under &lt;a href=&quot;https://vimhelp.org/insert.txt.html#compl-current&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help compl-current&lt;/code&gt;&lt;/a&gt; you'll find:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If there is a keyword in front of the cursor (a name made out of alphabetic characters and characters in &lt;code&gt;'iskeyword'&lt;/code&gt;), it is used as the search pattern, with &lt;code&gt;&quot;\&amp;lt;&quot;&lt;/code&gt; prepended (meaning: start of a word). [...]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Most other types of completion will typically follow the same definition of keywords.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your particular case, in order to be able to complete &lt;code&gt;G_{walk}&lt;/code&gt;, you might want to consider including the curly brace characters in the set of valid keyword characters, which you can do with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set iskeyword+={,}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this might affect keyword splitting elsewhere, since &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; are used in TeX/LaTeX for parameters, some words that were previously considered keywords on their own will cease to do so. You should consider this trade-off if you decide to touch the &lt;code&gt;'iskeyword'&lt;/code&gt; setting.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-17T00:32:28.090" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22275" PostTypeId="1" CreationDate="2019-12-17T08:13:28.690" Score="1" ViewCount="397" Body="&lt;p&gt;How to make (N)Vim auto save buffer on Tmux &lt;code&gt;select-pane&lt;/code&gt;? In my &lt;code&gt;vimrc&lt;/code&gt; I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Auto save when buffer lose focus&#xA;autocmd FocusLost,BufLeave * silent! wa&#xA;&#xA;&quot; Save on buffer change&#xA;set autowrite &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it does not work. In Termite (terminal emulator), in Tmux while cursor in vim pane, I press &lt;code&gt;&amp;lt;C-|&amp;gt;l&lt;/code&gt; to select right pane (&lt;code&gt;select-pane&lt;/code&gt; command). My cursor goes to the right pane but the vim buffer is not saved. It does autosave when I use NVim-qt or when I use Termite with Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;.tmux.config&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setw -g mode-keys vi &#xA;&#xA;# Use other prefix.&#xA;unbind-key C-b&#xA;set -g prefix 'C-\'&#xA;bind-key 'C-\' send-prefix&#xA;&#xA;bind h select-pane -L&#xA;bind j select-pane -D&#xA;bind k select-pane -U&#xA;bind l select-pane -R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25849" LastActivityDate="2019-12-17T21:44:49.980" Title="Vim auto save buffer on Tmux `select-pane`" Tags="|autocmd|tmux|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22276" PostTypeId="2" ParentId="22275" CreationDate="2019-12-17T09:46:08.627" Score="3" Body="&lt;p&gt;I don't know if vim supports focus but if it does you will at least need to turn focus-events on in .tmux.conf:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set -g focus-events on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25695" LastActivityDate="2019-12-17T09:46:08.627" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22277" PostTypeId="2" ParentId="22275" CreationDate="2019-12-17T10:00:57.557" Score="4" Body="&lt;p&gt;I don't know whether it will work for you because I don't have termite, but you could try to add this line in your &lt;code&gt;tmux.conf&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set -s focus-events on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And these lines in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !has('nvim') &amp;amp;&amp;amp; !has('gui_running')&#xA;    let &amp;amp;t_ti ..= &quot;\e[?1004h&quot;&#xA;    let &amp;amp;t_te ..= &quot;\e[?1004l&quot;&#xA;    exe &quot;set &amp;lt;S-F18&amp;gt;=\e[O&quot;&#xA;    exe &quot;set &amp;lt;S-F19&amp;gt;=\e[I&quot;&#xA;&#xA;    nno &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;S-F18&amp;gt; &amp;lt;sid&amp;gt;do('FocusLost')&#xA;    nno &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;S-F19&amp;gt; &amp;lt;sid&amp;gt;do('FocusGained')&#xA;    ono &amp;lt;silent&amp;gt; &amp;lt;S-F18&amp;gt; &amp;lt;esc&amp;gt;:call &amp;lt;sid&amp;gt;do('FocusLost')&amp;lt;cr&amp;gt;&#xA;    ono &amp;lt;silent&amp;gt; &amp;lt;S-F19&amp;gt; &amp;lt;esc&amp;gt;:call &amp;lt;sid&amp;gt;do('FocusGained')&amp;lt;cr&amp;gt;&#xA;    vno &amp;lt;silent&amp;gt; &amp;lt;S-F18&amp;gt; &amp;lt;esc&amp;gt;:call &amp;lt;sid&amp;gt;do('FocusLost')&amp;lt;cr&amp;gt;gv&#xA;    vno &amp;lt;silent&amp;gt; &amp;lt;S-F19&amp;gt; &amp;lt;esc&amp;gt;:call &amp;lt;sid&amp;gt;do('FocusGained')&amp;lt;cr&amp;gt;gv&#xA;    ino &amp;lt;silent&amp;gt; &amp;lt;S-F18&amp;gt; &amp;lt;c-r&amp;gt;=&amp;lt;sid&amp;gt;do('FocusLost')&amp;lt;cr&amp;gt;&#xA;    ino &amp;lt;silent&amp;gt; &amp;lt;S-F19&amp;gt; &amp;lt;c-r&amp;gt;=&amp;lt;sid&amp;gt;do('FocusGained')&amp;lt;cr&amp;gt;&#xA;    cno &amp;lt;S-F18&amp;gt; &amp;lt;c-r&amp;gt;=&amp;lt;sid&amp;gt;do('FocusLost')&amp;lt;cr&amp;gt;&#xA;    cno &amp;lt;S-F19&amp;gt; &amp;lt;c-r&amp;gt;=&amp;lt;sid&amp;gt;do('FocusGained')&amp;lt;cr&amp;gt;&#xA;    exe 'tno &amp;lt;silent&amp;gt; &amp;lt;S-F18&amp;gt; '..&amp;amp;termwinkey..&quot;:call &amp;lt;sid&amp;gt;do('FocusLost')&amp;lt;cr&amp;gt;&quot;&#xA;    exe 'tno &amp;lt;silent&amp;gt; &amp;lt;S-F19&amp;gt; '..&amp;amp;termwinkey..&quot;:call &amp;lt;sid&amp;gt;do('FocusGained')&amp;lt;cr&amp;gt;&quot;&#xA;&#xA;    fu s:do(event) abort&#xA;        if maparg('&amp;lt;s-f18&amp;gt;', 'n', 0, 1).expr&#xA;            nno &amp;lt;silent&amp;gt; &amp;lt;S-F18&amp;gt; :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;do('FocusLost')&amp;lt;cr&amp;gt;&#xA;            nno &amp;lt;silent&amp;gt; &amp;lt;S-F19&amp;gt; :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;do('FocusGained')&amp;lt;cr&amp;gt;&#xA;        else&#xA;            if exists('#'..a:event)&#xA;                exe 'do &amp;lt;nomodeline&amp;gt; '..a:event&#xA;            endif&#xA;        endif&#xA;        return ''&#xA;    endfu&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works in xterm (with patch level 322).&#xA;However, this is a hack; it can create an issue &lt;a href=&quot;https://github.com/tmux/tmux/issues/1722&quot; rel=&quot;nofollow noreferrer&quot;&gt;in Tmux&lt;/a&gt;, where sometimes you can't copy some multi-line text in the output of a Vim Ex command via Tmux copy-mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can also create a similar issue &lt;a href=&quot;https://github.com/vim/vim/issues/4359&quot; rel=&quot;nofollow noreferrer&quot;&gt;in Vim&lt;/a&gt;, where a multi-line Ex command output is cleared after focusing a different program window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IIRC, it can also cause the screen not to be always correctly redrawn after you push a commit with &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-fugitive&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There is an item at &lt;code&gt;:h todo&lt;/code&gt; which mentions a Vim patch making &lt;code&gt;FocusGained&lt;/code&gt; and &lt;code&gt;FocusLost&lt;/code&gt; work in modern terminals:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Patch to make FocusGained and FocusLost work in modern terminals. (Hayaki&#xA;  Saito, 2013 Apr 24) Update 2016 Aug 12.&#xA;  Also see issue #609.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://gist.github.com/saitoha/a013bdfebe368cf1e0306a66b75621f4&quot; rel=&quot;nofollow noreferrer&quot;&gt;latest version&lt;/a&gt; of the patch is about 3 years old, so it probably needs to be updated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a &lt;a href=&quot;https://github.com/vim/vim/issues/609&quot; rel=&quot;nofollow noreferrer&quot;&gt;github issue&lt;/a&gt; which asks for these events to work in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, if an updated version of this patch was merged, you would not need the previous hack anymore, and you probably would not face the previously mentioned issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as &lt;a href=&quot;https://vi.stackexchange.com/a/22276/17449&quot;&gt;Nicholas Marriott&lt;/a&gt; explained, you'll still need the line &lt;code&gt;set -s focus-events on&lt;/code&gt; in your &lt;code&gt;tmux.conf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that in Nvim, &lt;code&gt;FocusGained&lt;/code&gt; and &lt;code&gt;FocusLost&lt;/code&gt; should work without the hack (hence why the guard contains &lt;code&gt;!has('nvim')&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-12-17T21:44:49.980" LastActivityDate="2019-12-17T21:44:49.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22278" PostTypeId="1" AcceptedAnswerId="22280" CreationDate="2019-12-17T10:14:04.110" Score="9" ViewCount="7046" Body="&lt;p&gt;When I use the following command to set the color of my vim,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:highlight Error ctermfg=#00afff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it prompts &lt;code&gt;E421: Color name or number not recognized: ctermfg=#00afff&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="26138" LastEditorUserId="1841" LastEditDate="2019-12-17T10:22:02.717" LastActivityDate="2019-12-17T10:31:14.610" Title="Why my vim doesn't support hex color code?" Tags="|syntax-highlighting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22279" PostTypeId="2" ParentId="22278" CreationDate="2019-12-17T10:21:31.577" Score="9" Body="&lt;p&gt;It's because &lt;a href=&quot;http://vimhelp.appspot.com/syntax.txt.html#highlight-ctermfg&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h highlight-ctermfg&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ctermbg={color-nr}              *highlight-ctermbg*&#xA;    The {color-nr} argument is a color number.  Its range is zero to&#xA;    (not including) the number of tui-colors available.&#xA;    The actual color with this number depends on the type of terminal&#xA;    and its settings.&#xA;&#xA;[...]&#xA;&#xA;The following (case-insensitive) names are recognized:&#xA;&#xA;                        *cterm-colors*&#xA;    NR-16   NR-8    COLOR NAME ~&#xA;    0       0       Black&#xA;    1       4       DarkBlue&#xA;    2       2       DarkGreen&#xA;    3       6       DarkCyan&#xA;    4       1       DarkRed&#xA;    5       5       DarkMagenta&#xA;    6       3       Brown, DarkYellow&#xA;    7       7       LightGray, LightGrey, Gray, Grey&#xA;    8       0*      DarkGray, DarkGrey&#xA;    9       4*      Blue, LightBlue&#xA;    10      2*      Green, LightGreen&#xA;    11      6*      Cyan, LightCyan&#xA;    12      1*      Red, LightRed&#xA;    13      5*      Magenta, LightMagenta&#xA;    14      3*      Yellow, LightYellow&#xA;    15      7*      White&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command is not supposed to support hex color mode.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2019-12-17T10:21:31.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22280" PostTypeId="2" ParentId="22278" CreationDate="2019-12-17T10:31:14.610" Score="16" Body="&lt;p&gt;&lt;code&gt;ctermfg&lt;/code&gt; and &lt;code&gt;ctermbg&lt;/code&gt; use indices into the limited color palettes (8 / 16 / 88 or 256 colors) of terminals and do not support the full 24-bit RGB values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you're looking for the &lt;a href=&quot;https://vimhelp.appspot.com/options.txt.html#%27termguicolors%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'termguicolors'&lt;/code&gt;&lt;/a&gt; option, which makes Vim apply the GUI color attributes to capable terminals. Colors (by name or #RGB) are specified via &lt;code&gt;guifg&lt;/code&gt; / &lt;code&gt;guibg&lt;/code&gt;; only &lt;code&gt;cterm&lt;/code&gt; is used for text attributes.&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-12-17T10:31:14.610" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22281" PostTypeId="1" CreationDate="2019-12-17T12:31:23.753" Score="1" ViewCount="1060" Body="&lt;p&gt;This question has been raised several times in several places.&#xA;You can't map &lt;code&gt;cmd&lt;/code&gt; out of the box when neovim is used in terminal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the answers were you can't or try karabiner. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is this solution&#xA;&lt;a href=&quot;https://github.com/neovim/neovim/issues/176#issuecomment-37070131&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neovim/neovim/issues/176#issuecomment-37070131&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Configuring &quot;CSI u&quot; is not enough, as I understand.&#xA;And it seems that I need a parsing lib, but it refers to a deprecated one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if installing it would be enough. Anyone did it successfully? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am with ITerm2, but any other terminal will do. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2019-12-17T12:31:23.753" Title="How to configure support for cmd key in terminal (neovim)" Tags="|key-bindings|neovim|iterm2|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22282" PostTypeId="1" CreationDate="2019-12-17T13:08:05.807" Score="3" ViewCount="593" Body="&lt;p&gt;Here is my &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=utf-8&#xA;scriptencoding utf-8&#xA;set list&#xA;set listchars=tab:→·&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open vim, it will show an error message &lt;code&gt;E474: Invalid argument: listchars=tab:→·&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim is &lt;code&gt;Vi IMproved 8.1 Huge version without GUI&lt;/code&gt; and the &lt;code&gt;multi_lang&lt;/code&gt; feature is enabled. I don't know why it doesn't support special characters &lt;code&gt;→·&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks Christian Brabandt for pointing my error that &lt;code&gt;tab&lt;/code&gt; need two characters. However, when I set &lt;code&gt;tab&lt;/code&gt; to &lt;code&gt;→·&lt;/code&gt;, it still didn't work. And finally, I find that this problem is caused by XShell because this configuration works well under GNOME. After changing the XShell Terminal Type to &lt;code&gt;linux&lt;/code&gt; or &lt;code&gt;ansi&lt;/code&gt; instead of &lt;code&gt;xterm&lt;/code&gt;, it works! But if I change it back, it still works. I don't know why. Maybe it's a bug.&lt;/p&gt;&#xA;" OwnerUserId="26138" LastEditorUserId="1841" LastEditDate="2020-01-03T09:06:43.970" LastActivityDate="2020-02-26T16:02:25.413" Title="Can't use special characters in listchars even if setting scriptencoding to utf-8" Tags="|vimrc|syntax-highlighting|encoding|listchars|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22284" PostTypeId="1" AcceptedAnswerId="22293" CreationDate="2019-12-18T05:34:37.990" Score="4" ViewCount="919" Body="&lt;p&gt;I'm not sure I'm using the right tool for the job here, but I'm trying to embed Lua syntax highlighting inside a block syntax. The only way I can make this work is with a &lt;code&gt;syn region&lt;/code&gt;. I can find the block easily enough with a &lt;code&gt;syn match&lt;/code&gt;, but trying to embed another syntax in there (e.g. with &lt;code&gt;contains=@Lua&lt;/code&gt; just ends up bleeding all other the place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is for the &lt;a href=&quot;https://github.com/sile-typesetter/vim-sile&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-sile&lt;/a&gt; syntax plugin. I've managed to do something similar embedding Lua for an inline syntax where the region &lt;em&gt;end&lt;/em&gt; actually is just a delimiter, so that is hilghlighted correctly. See for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin[papersize=a5]{document}&#xA;\nofolios&#xA;\font[family=Libertinus Serif]&#xA;\begin{script}&#xA;-- Lua comment&#xA;.myvar = &quot;mod4=&quot; .. 4 % 2&#xA;\end{script}&#xA;&#xA;\begin{raggedright}&#xA;% sile comment&#xA;Lorem ipsum...&#xA;\end{raggedright}&#xA;&#xA;\script{myvar = &quot;mod4=&quot; .. 4 % 2}&#xA;&#xA;lorem \emph{ipsum}...&#xA;\end{document}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note how the Lua code inside the &lt;code&gt;\script{...}&lt;/code&gt; command works great, but the same code in the &lt;code&gt;\begin{script}...\end{script}&lt;/code&gt; block does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mYpAQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mYpAQ.png&quot; alt=&quot;screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have matches already setup for parsing the details of &lt;code&gt;\begin{&amp;lt;command&amp;gt;}&lt;/code&gt; and those are nicely highlighted for &lt;em&gt;other&lt;/em&gt; possible values, but specifically for &lt;code&gt;script&lt;/code&gt; when Lua is going to be embedded I can't figure out how to use my regular highlighting for the delimiters &lt;em&gt;and&lt;/em&gt; use them in the start/end.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region sileBlockLua matchgroup=Delimiter start=&quot;\\begin{script}&quot;    end=&quot;\\end{script}&quot; contains=@LUA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This finds the blocks and does the Lua embedding right, but the start and end text ends up as &lt;code&gt;Delimiter&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I capture a region to embed another syntax, but also capture and highlgiht the start and end delimiters?&lt;/p&gt;&#xA;" OwnerUserId="267" LastEditorUserId="267" LastEditDate="2019-12-18T06:51:25.437" LastActivityDate="2019-12-19T05:21:20.093" Title="Highlight syntax in start and end delimiters of region" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22285" PostTypeId="2" ParentId="22097" CreationDate="2019-12-18T08:13:53.600" Score="0" Body="&lt;h2&gt;&lt;a href=&quot;https://github.com/tpope/vim-rsi&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-rsi&lt;/a&gt;: Readline key bindings&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The plugin vim-rsi by tpope provides readline style insert mode mappings. Following two might be of help in your case&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;                                        *rsi-CTRL-E*&#xA;&amp;lt;C-e&amp;gt;           Go to end of line.  Falls back to |i_CTRL-E| if&#xA;                already at the end of the line.  (|c_CTRL-E| already&#xA;                goes to end of line, so it is not mapped.)&#xA;&#xA;                                        *rsi-CTRL-F*&#xA;&amp;lt;C-f&amp;gt;           Move forward one character.  Falls back to&#xA;                |i_CTRL-F| or |c_CTRL-F| at the end of the line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2019-12-18T08:13:53.600" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22286" PostTypeId="2" ParentId="8451" CreationDate="2019-12-18T09:49:54.307" Score="5" Body="&lt;p&gt;A variation on your own response is to install &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;noreferrer&quot;&gt;fzf.vim&lt;/a&gt; and then bind to &lt;code&gt;:Marks&lt;/code&gt;, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ` :Marks&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has the benefit that it will show up in fzf's fuzzy search window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Caveat: It does require pressing &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; after you've found the item.)&lt;/p&gt;&#xA;" OwnerUserId="5808" LastActivityDate="2019-12-18T09:49:54.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22287" PostTypeId="2" ParentId="20078" CreationDate="2019-12-18T12:20:12.030" Score="1" Body="&lt;p&gt;Christian Wellenbrock (the author of the well regarded &lt;a href=&quot;https://github.com/wellle/targets.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;targets.vim&lt;/a&gt;) recently released a plugin that does this, called &lt;a href=&quot;https://github.com/wellle/context.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;context.vim&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/wellle/images/master/context-scroll.gif&quot; alt=&quot;blah&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be a good idea to try this out if you're looking for a more robust alternative to &lt;a href=&quot;https://vi.stackexchange.com/a/20089/343&quot;&gt;my answer&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2019-12-18T12:20:12.030" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22288" PostTypeId="1" AcceptedAnswerId="22291" CreationDate="2019-12-18T14:00:26.533" Score="6" ViewCount="399" Body="&lt;p&gt;I like to replace the default enter/return key functionality with actually inserting a new line, and the same with space (but inserting a line above), e.g. here is my map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;CR&amp;gt; O&amp;lt;ESC&amp;gt;&#xA;nnoremap &amp;lt;space&amp;gt; o&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the problem I have here is that it breaks selecting functionality. For example Omnisharp and Flake8 both bring up a new buffer which allows you to select errors, or browse found items. For example Flake8 lists any errors that it finds with the file, then you can select an item and press enter to navigate to that error. But if you do this with the enter/return key remapped then instead it will give the error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E21: Cannot make changes, 'modifiable' is off&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I can't find the default mapping for enter/return. Is there any other way to handle this? Or is there a way to change mapping based on what buffer you're currently in, as unmapping the enter/return key once mapped will restore this functionality. But any autocmd solutions with buffers I have came up with are poor and not very reliable.&lt;/p&gt;&#xA;" OwnerUserId="26165" LastActivityDate="2019-12-18T14:15:37.943" Title="How do I change the return/enter key functionality without breaking enter to select?" Tags="|vimrc|key-bindings|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22289" PostTypeId="1" AcceptedAnswerId="22290" CreationDate="2019-12-18T14:09:07.660" Score="7" ViewCount="221" Body="&lt;p&gt;I've been trying to record a rather simple macro with two substitutions. The whole macro is: &lt;code&gt;dd&quot;+pkdd:%s/\t/, /g&#xA;:%s/ \(kb\d\+\),/ \1.0,/g&#xA;&quot;+y$&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the second substitution is there to reformat numbers from a format &lt;code&gt;123&lt;/code&gt; to &lt;code&gt;123.0&lt;/code&gt; but the input does not always need the substitution so it fails. When it fails the whole macro stops so the last part (&lt;code&gt;&quot;+y$&lt;/code&gt;) does not execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to prevent this?&lt;/p&gt;&#xA;" OwnerUserId="26163" LastActivityDate="2019-12-18T14:11:22.640" Title="How to prevent stopping a macro on unsuccessful substitution?" Tags="|substitute|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22290" PostTypeId="2" ParentId="22289" CreationDate="2019-12-18T14:11:22.640" Score="7" Body="&lt;p&gt;I've figured it out thanks to &lt;a href=&quot;https://stackoverflow.com/questions/31093959/how-do-i-disable-error-messages-when-a-substitution-fails-inside-a-vim-function&quot;&gt;this&lt;/a&gt;. One needs to put an &lt;code&gt;e&lt;/code&gt; flag to the substitution so the substitution looks like this: &lt;code&gt;:%s/ \(kb\d\+\),/ \1.0,/ge&lt;/code&gt;. &lt;code&gt;e&lt;/code&gt; suppresses the error message and lets the macro finish.&lt;/p&gt;&#xA;" OwnerUserId="26163" LastActivityDate="2019-12-18T14:11:22.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22291" PostTypeId="2" ParentId="22288" CreationDate="2019-12-18T14:15:37.943" Score="8" Body="&lt;p&gt;I guess those plugins are using the &lt;a href=&quot;https://vimhelp.appspot.com/quickfix.txt.html#quickfix-window&quot; rel=&quot;noreferrer&quot;&gt;quickfix-window&lt;/a&gt;; if there were using &lt;em&gt;scratch buffers&lt;/em&gt;, they should set up &lt;em&gt;buffer-local&lt;/em&gt; mappings that would override your global ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Vim treats the quickfix buffer just like any other, your global mappings apply there as well. But fortunately, there's an easy fix: You just need to provide &lt;a href=&quot;https://vimhelp.appspot.com/map.txt.html#%3Amap-%3Cbuffer%3E&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :map-&amp;lt;buffer&amp;gt;&lt;/code&gt;&lt;/a&gt; mappings that restore the original commands. As Vim automatically sets a &lt;em&gt;filetype&lt;/em&gt; (cp. &lt;a href=&quot;https://vimhelp.appspot.com/filetype.txt.html#ft-qf-plugin&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help ft-qf-plugin&lt;/code&gt;&lt;/a&gt;), you can place those into &lt;code&gt;~/.vim/ftplugin/qf.vim&lt;/code&gt; (as long as you have &lt;code&gt;:filetype plugin on&lt;/code&gt;, which most people have), or prepend &lt;code&gt;:autocmd FileType qf&lt;/code&gt; to each line and put them into your &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Restore original selection functionality in quickfix windows.&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; &amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Space&amp;gt; &amp;lt;Space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2019-12-18T14:15:37.943" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22292" PostTypeId="1" CreationDate="2019-12-18T16:01:02.287" Score="1" ViewCount="19" Body="&lt;p&gt;I've been learning Vim recently and I decided to put a few lines in my vimrc for quick navigation without having to leave normal mode, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap jk &amp;lt;esc&amp;gt;&#xA;inoremap &amp;lt;c-h&amp;gt; &amp;lt;esc&amp;gt;i&#xA;inoremap &amp;lt;c-l&amp;gt; &amp;lt;esc&amp;gt;la&#xA;inoremap &amp;lt;c-k&amp;gt; &amp;lt;esc&amp;gt;ka&#xA;inoremap &amp;lt;c-j&amp;gt; &amp;lt;esc&amp;gt;ja&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This ended up breaking my backspace key so that in insert mode, it only moved back one space without deleting the character. After a bit of looking around, I found that the &lt;code&gt;&amp;lt;c-h&amp;gt;&lt;/code&gt; line was the culprit, due to it being connected somehow to backspace. Does this character combination represent the backspace key in all situations? Is there some way to map this without messing up backspace?&lt;/p&gt;&#xA;" OwnerUserId="22568" LastActivityDate="2019-12-18T16:01:02.287" Title="Does &lt;c-h&gt; represent a backspace when being mapped?" Tags="|vimrc|key-bindings|" AnswerCount="0" CommentCount="2" ClosedDate="2019-12-18T16:17:36.557" ContentLicense="CC BY-SA 4.0" />
  <row Id="22293" PostTypeId="2" ParentId="22284" CreationDate="2019-12-18T17:11:05.763" Score="5" Body="&lt;p&gt;This syntax rule works to highlight a Lua script inside a &lt;code&gt;\begin{script}&lt;/code&gt; block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;syn region sileBlockLua&#xA;    \ start=&quot;\\begin{script}&quot; end=&quot;\\end{script}&quot;&#xA;    \ contains=&lt;b&gt;sileBlock&lt;/b&gt;,@LUA &lt;b&gt;keepend&lt;/b&gt;&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add this rule to a file named &lt;code&gt;after/syntax/sile.vim&lt;/code&gt;, for instance under your &lt;code&gt;~/.vim&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The parts in bold are the ones that make it work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;contains=&lt;b&gt;sileBlock&lt;/b&gt;,@LUA&lt;/code&gt;, you're allowing the rules that match &lt;code&gt;\begin&lt;/code&gt; and &lt;code&gt;\end&lt;/code&gt; (including the following &lt;code&gt;{...}&lt;/code&gt; with a command) within this region, so this will end up highlighting the delimiters appropriately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;keepend&lt;/code&gt;, you're preventing the syntax engine from parsing Lua syntax past the end delimiter. This directive makes the match on the end delimiter stronger than the contained parts.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; An additional improvement is to remove the end tag from the region, so that incomplete Lua syntax doesn't affect it. That can be done with the further addition of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;syn region sileBlockLua&#xA;    \ start=&quot;\\begin{script}&quot; end=&quot;\\end{script}&quot;&lt;b&gt;me=s-1&lt;/b&gt;&#xA;    \ contains=sileBlock,@LUA keepend&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which indicates that the &lt;strong&gt;m&lt;/strong&gt;atch &lt;strong&gt;e&lt;/strong&gt;nd for that tag will be &lt;strong&gt;1&lt;/strong&gt; character before the &lt;strong&gt;s&lt;/strong&gt;tart of where the regular expression matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By having that match outside of the region, it will be unaffected by the Lua syntax rules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Thanks @Caleb for incorporating my suggestions into &lt;a href=&quot;https://github.com/sile-typesetter/vim-sile/commit/93a832d491252aa90300d2b693376970270057b3&quot; rel=&quot;nofollow noreferrer&quot;&gt;an upstream commit&lt;/a&gt;!)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-12-19T05:21:20.093" LastActivityDate="2019-12-19T05:21:20.093" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22294" PostTypeId="1" AcceptedAnswerId="22308" CreationDate="2019-12-18T19:54:17.727" Score="3" ViewCount="505" Body="&lt;p&gt;I have a bunch of (spagetti) fortran code that is in fixed form, but without the line length restrictions. As such, it gets some odd highlighting:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SdnJx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SdnJx.png&quot; alt=&quot;Standard highlighting&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried 3 different ways to get it to highlight correctly, but none of them work.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Add &lt;code&gt;setlocal textwidth=132&lt;/code&gt; to &lt;code&gt;.vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Add &lt;code&gt;let fortran_free_source=1; setlocal comments=:!,:*,:C,:c&lt;/code&gt; to &lt;code&gt;.vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Create new syntax file that implements both the above changes for &lt;code&gt;fortran_free_source=1&lt;/code&gt; and &lt;code&gt;fortran_fixed_source=1&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Option 1 does nothing. Option 2 doesn't recognize &lt;code&gt;C&lt;/code&gt; as a comment string. Option 3 also does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas what's wrong here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Also, running &lt;code&gt;:verbose set [setting]?&lt;/code&gt; in all the above cases returns the expected result (ie. For option 1, it'll say that &lt;code&gt;textwidth=132&lt;/code&gt; and that it was set from &lt;code&gt;.vimrc&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="18471" LastEditorUserId="10604" LastEditDate="2019-12-18T20:24:10.877" LastActivityDate="2019-12-21T03:51:54.367" Title="Can't get textwidth for syntax highlighting working" Tags="|syntax-highlighting|filetype-fortran|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22296" PostTypeId="2" ParentId="22179" CreationDate="2019-12-19T00:18:59.993" Score="1" Body="&lt;p&gt;On OS X, the &lt;code&gt;open&lt;/code&gt; command (according to &lt;code&gt;man open&lt;/code&gt;) acts &quot;as if you had double-clicked the file's icon&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The open command opens a file (or a directory or URL), just as if you had &#xA;double-clicked the file's icon. If no application name is specified, the default&#xA;application as determined via LaunchServices is used to open the specified files.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The man docs don't specify what happens when opening an application &lt;em&gt;without&lt;/em&gt; a file (something like this from within Vim: &lt;code&gt;:!open -a Terminal&lt;/code&gt;) but the behavior appears consistent with the described behavior about opening files – namely, that it opens a separate application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think there's anything surprising or concerning about this. Opening an application – such as by running &lt;code&gt;open -a TextEdit&lt;/code&gt; from a Terminal window – should open that application (which it does).&lt;/p&gt;&#xA;" OwnerUserId="5526" LastActivityDate="2019-12-19T00:18:59.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22297" PostTypeId="2" ParentId="22097" CreationDate="2019-12-19T14:38:44.587" Score="0" Body="&lt;p&gt;Here's a quick hack you could put in your .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Enter&amp;gt; &amp;lt;esc&amp;gt;:call DetectIfParens()&amp;lt;cr&amp;gt; i     // exits the insert mode and will return to it when the function ends&#xA;&#xA;function DetectIfParens()&#xA;    let char = getline('.')[col('.')]                 // here we are in normal mode; check if the character to the right of the cursor is a closing parenthesis&#xA;    if (char==&quot;)&quot;)&#xA;        normal l                                      // puts the cursor after the parenthesis (sends the &quot;l&quot; key in normal mode)&#xA;    endif&#xA;endfunction                                          // after the function ends, you'll be in insert mode again &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18912" LastActivityDate="2019-12-19T14:38:44.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22298" PostTypeId="2" ParentId="8741" CreationDate="2019-12-19T19:02:07.767" Score="7" Body="&lt;p&gt;I have found it more intuitive to remap the &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;L&lt;/kbd&gt; repaint to include &lt;code&gt;:nohls&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-L&amp;gt; :nohls&amp;lt;cr&amp;gt;&amp;lt;C-L&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26184" LastEditorUserId="10604" LastEditDate="2019-12-19T22:47:02.923" LastActivityDate="2019-12-19T22:47:02.923" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22299" PostTypeId="1" CreationDate="2019-12-19T21:43:14.510" Score="2" ViewCount="175" Body="&lt;p&gt;I have a file exported from some system, and in vi when I open the file, there's a green &lt;code&gt;&amp;lt;92&amp;gt;&lt;/code&gt; in it when I open it up where an &lt;code&gt;'&lt;/code&gt; ought to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It messed up my bash script and left a line that reads &lt;code&gt;Binary file (standard input) matches&lt;/code&gt; after I &lt;code&gt;grep'd&lt;/code&gt; it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;file&lt;/code&gt; against it, it says the file is encoded as &lt;code&gt;Non-ISO extended-ASCII text, with CRLF line terminators&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is that green &lt;code&gt;&amp;lt;92&amp;gt;&lt;/code&gt; and why is it binary and messing up grep?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="1065" LastEditDate="2019-12-19T21:50:29.013" LastActivityDate="2021-10-08T18:29:58.273" Title="What is the green &lt;92&gt; that's in my file?" Tags="|grep|ascii|file|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22300" PostTypeId="1" AcceptedAnswerId="22301" CreationDate="2019-12-20T04:21:48.220" Score="2" ViewCount="689" Body="&lt;p&gt;I have a plugin that only has install instructions for NeoBundle. I primarily use Plug, however. I tried copying the GitHub path from the NeoBundle instructions to a Plug command considering the two are set up similarly, but Plug will not let it install. Do I need to run both Plug and NeoBundle, or is there a way to run NeoBundle plugins in Plug?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, I'd like to use plugin &lt;a href=&quot;https://github.com/tiagofumo/vim-nerdtree-syntax-highlight&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-nerdtree-syntax-highlight&lt;/a&gt;, which lists as install instructions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NeoBundle 'tiagofumo/vim-nerdtree-syntax-highlight'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26189" LastEditorUserId="1238" LastEditDate="2019-12-21T05:50:19.243" LastActivityDate="2019-12-21T05:50:19.243" Title="Installing NeoBundle packages with Plug" Tags="|plugin-system|plugin-neobundle|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22301" PostTypeId="2" ParentId="22300" CreationDate="2019-12-20T07:06:09.167" Score="2" Body="&lt;p&gt;You can install this plug-in using vim-plug. Just use vim-plug's command for it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'tiagofumo/vim-nerdtree-syntax-highlight'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NeoBundle is a fork of Vundle and vim-plug is a successor of Vundle. This lineage means they share commonalities in managing plugins and they are fairly compatible with each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of Vundle, NeoBundle and vim-plug use very similar way of setting up plugins, with a stanza in the vimrc file delimited by calls to a &lt;code&gt;vundle#begin()&lt;/code&gt; and a &lt;code&gt;vundle#end()&lt;/code&gt; (or &lt;code&gt;neobundle&lt;/code&gt;, or &lt;code&gt;plug&lt;/code&gt;), having the list of plugins to load/install listed inside that block, using a command registered by the plugin itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most differences between these three are in how they manage installing and fetching plugins, but mainly in how the newer ones try to fetch plugins using more parallelism and asynchronous calls in order to provide faster install/update processes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of plugin layout, virtually all Vim plugins use the same layout, which was initially proposed by tpope's &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow noreferrer&quot;&gt;pathogen.vim&lt;/a&gt; (and can even be traced further back to vimball packages), which involves shipping the plugin files in the subdirectories recognized by Vim inside &lt;code&gt;~/.vim&lt;/code&gt; or &lt;code&gt;vimfiles&lt;/code&gt; or &lt;code&gt;$VIMRUNTIME&lt;/code&gt;, and then using the &lt;code&gt;'runtimepath'&lt;/code&gt; option to include all the plugin directories, so that their files will be found by Vim during runtime.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In fact, this process of registering plugins into &lt;code&gt;'runtimepath'&lt;/code&gt; was made into a first class feature of Vim 8, which introduced support for &quot;packages&quot; which implement this same procedure.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-20T07:06:09.167" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22302" PostTypeId="2" ParentId="10939" CreationDate="2019-12-20T17:35:59.777" Score="8" Body="&lt;p&gt;If you use &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;noreferrer&quot;&gt;vim-plug&lt;/a&gt;, it sets a variable called &lt;code&gt;plugs&lt;/code&gt; which lists all your loaded plugins, and some information about them.  I solved your question for myself when I needed to check whether I was running YCM or coc.nvim.  You can see if a plugin is loaded by running &lt;code&gt;has_key(plugs, &quot;name&quot;)&lt;/code&gt;, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has_key(plugs, 'YouCompleteMe')&#xA;        call YCM()&#xA;endif&#xA;if has_key(plugs, &quot;coc.nvim&quot;)&#xA;        call CocStart()&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: this only shows if it's currently listed in your &lt;code&gt;vimrc&lt;/code&gt;, and not, for example, if you have it set to lazy load, so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'}&#xA;    ...&#xA;if has_key(plugs, 'nerdtree')&#xA;        echo &quot;HAS NERDTREE&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will still print that at startup, even though &lt;code&gt;nerdtree&lt;/code&gt; hasn't been loaded yet.&lt;/p&gt;&#xA;" OwnerUserId="19428" LastEditorUserId="19428" LastEditDate="2019-12-20T17:42:38.713" LastActivityDate="2019-12-20T17:42:38.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22303" PostTypeId="1" AcceptedAnswerId="22305" CreationDate="2019-12-20T21:35:03.267" Score="1" ViewCount="405" Body="&lt;p&gt;I'm trying to write a plugin: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a variable with some text.&#xA;I want to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;create a new buffer &lt;/li&gt;&#xA;&lt;li&gt;place the contents of that variable in the new buffer&lt;/li&gt;&#xA;&lt;li&gt;open a new split that displays the new buffer&lt;/li&gt;&#xA;&lt;li&gt;keep focus on the current window (not the new one)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm having a &lt;em&gt;really&lt;/em&gt; hard time googling for 2 and 3 and I'm not 100% sure I'm doing 1 correctly either. I'm assuming 4 isn't hard. &lt;/p&gt;&#xA;" OwnerUserId="6838" LastActivityDate="2019-12-21T00:08:02.313" Title="how do i open a new window with a new buffer, containing a variable?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22304" PostTypeId="2" ParentId="21985" CreationDate="2019-12-20T22:07:01.800" Score="1" Body="&lt;p&gt;&lt;code&gt;:help&lt;/code&gt; opens an unlisted buffer (&lt;code&gt;:help unlisted-buffer&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can make the buffer listed (shown in &lt;code&gt;:buffers&lt;/code&gt;) with the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setlocal buflisted&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you will find the buffer in the list that &lt;code&gt;:buffers&lt;/code&gt; shows. &lt;/p&gt;&#xA;" OwnerUserId="1238" LastActivityDate="2019-12-20T22:07:01.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22305" PostTypeId="2" ParentId="22303" CreationDate="2019-12-21T00:08:02.313" Score="3" Body="&lt;p&gt;Works for &lt;code&gt;register&lt;/code&gt;, &lt;code&gt;String&lt;/code&gt;, and &lt;code&gt;List&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;&quot; don't use &amp;lt;q-args&amp;gt; here, we need expression&#xA;com -nargs=1 ShowVariable call s:show_var(&amp;lt;args&amp;gt;)&#xA;&#xA;function s:show_var(var) abort&#xA;&#xA;  &quot; split new buffer&#xA;  new&#xA;&#xA;  &quot; set buffer content&#xA;  if type(a:var) == v:t_string&#xA;&#xA;    &quot; split string into list, otherwise you see ^@ as newline&#xA;    call setline(1, split(a:var, &quot;\n&quot;))&#xA;  else&#xA;    call setline(1, a:var)&#xA;  endif&#xA;&#xA;  &quot; go back to original window&#xA;  wincmd p&#xA;endfunction&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/eval.txt.html#setline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h setline()&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Awincmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :wincmd&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ShowVariable @@&#xA;:ShowVariable string_variable_name&#xA;:ShowVariable list_variable_name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-12-21T00:08:02.313" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22306" PostTypeId="1" CreationDate="2019-12-21T01:54:19.563" Score="2" ViewCount="2268" Body="&lt;p&gt;I had vim working for a while and uninstalled it for no good reason. To reinstall it I gave the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get update&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get warnings that the respository &lt;code&gt;deadsnakes/ppa&lt;/code&gt; and &lt;code&gt;pycharm/ubuntu&lt;/code&gt; are not secure, but nothing that seems relevant (I guess)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get upgrade vim-runtime&#xA;sudo apt-get upgrade vim-common&#xA;sudo -i apt-get install vim&#xA;&#xA;vim : Depends: vim-common (= 2:8.1.0320-1ubuntu3.1) but 2:8.1.0875-5ubuntu2 is to be installed&#xA;      Depends: vim-runtime (= 2:8.1.0320-1ubuntu3.1) but 2:8.1.0875-5ubuntu2 is to be installed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then tried &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apt-get install -f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This appears to have done nothing since it says &lt;code&gt;0 upgraded, 0 newly installed, 0 to remove and 21 not upgraded&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I am pretty much stumped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After getting vim working again, I would like to enable the system clipboard. I read that this is accomplished by installing &lt;code&gt;vim-gnome&lt;/code&gt;. When I tried to do that, I encountered similar issues.&lt;/p&gt;&#xA;" OwnerUserId="26198" LastEditorUserId="10604" LastEditDate="2019-12-21T02:46:28.197" LastActivityDate="2019-12-21T14:31:20.670" Title="How can I fix my dependencies installing vim" Tags="|installing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22307" PostTypeId="1" AcceptedAnswerId="22327" CreationDate="2019-12-21T02:06:29.563" Score="5" ViewCount="1526" Body="&lt;p&gt;I'm trying to use NeoVim as a tmux replacement, and have found that no matter what I do, I can't get it to go into insert mode when I click in a pane that has a terminal in it.&lt;/p&gt;&#xA;&lt;p&gt;Here's the config I'm trying to use, with no luck.&#xA;Currently the config lets me navigate between panes, and when I enter the pane using the keyboard it switches to insert mode.&lt;/p&gt;&#xA;&lt;p&gt;But when I enter the pane by clicking the mouse, it goes back to normal mode, which I almost never want.&lt;/p&gt;&#xA;&lt;h3&gt;~/.config/nvim/init.vim&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=a&#xA;&#xA;if has('nvim')&#xA;    autocmd TermOpen term://* startinsert&#xA;    autocmd TermEnter term://* startinsert&#xA;    autocmd BufEnter term://* startinsert&#xA;endif&#xA;&#xA;&amp;quot; Edit files within Nvim's terminal without nesting sessions.&#xA;augroup prevent_nested_edit&#xA;  autocmd VimEnter * if !empty($NVIM_LISTEN_ADDRESS) &amp;amp;&amp;amp; $NVIM_LISTEN_ADDRESS !=# v:servername&#xA;          \ |let g:r=jobstart(['nc', '-U', $NVIM_LISTEN_ADDRESS],{'rpc':v:true})&#xA;          \ |let g:f=fnameescape(expand('%:p'))&#xA;          \ |noau bwipe&#xA;          \ |call rpcrequest(g:r, &amp;quot;nvim_command&amp;quot;, &amp;quot;edit &amp;quot;.g:f)&#xA;          \ |call rpcrequest(g:r, &amp;quot;nvim_command&amp;quot;, &amp;quot;call lib#SetNumberDisplay(1)&amp;quot;)&#xA;          \ |qa&#xA;          \ |endif&#xA;augroup END&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;NOTE: I have found very similar questions, but they don't seem to work for when I &amp;quot;click&amp;quot; in the terminal - they work for navigating into the terminal pane with the keyboard:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/3670/9850&quot;&gt;How to enter insert mode when entering neovim terminal pane?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9850" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-12-29T17:44:31.730" Title="NeoVim - Go into insert mode when clicking in a terminal in a pane?" Tags="|neovim|insert-mode|terminal-buffer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22308" PostTypeId="2" ParentId="22294" CreationDate="2019-12-21T03:51:54.367" Score="2" Body="&lt;p&gt;Looking at the Fortran syntax file, I could find that the source of that highlighting past column 72 is coming from &lt;a href=&quot;https://github.com/vim/vim/blob/v8.2.0/runtime/syntax/fortran.vim#L358&quot; rel=&quot;nofollow noreferrer&quot;&gt;this rule on line 358&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match fortranSerialNumber excludenl &quot;^.\{73,}$&quot;lc=72&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, columns 73 and 72 are hardcoded into this rule, so setting &lt;code&gt;'textwidth'&lt;/code&gt; will not really affect this particular rule and won't really work to fix this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(You can also see this rule is defined inside a &lt;code&gt;if (b:fortran_fixed_source == 1)&lt;/code&gt; and the &lt;code&gt;ftplugin/fortran.vim&lt;/code&gt; file &lt;a href=&quot;https://github.com/vim/vim/blob/v8.2.0/runtime/ftplugin/fortran.vim#L37-L39&quot; rel=&quot;nofollow noreferrer&quot;&gt;sets this buffer variable&lt;/a&gt; for files with the &lt;code&gt;.f&lt;/code&gt;, &lt;code&gt;.f77&lt;/code&gt; or &lt;code&gt;.for&lt;/code&gt; extensions. That also matches your comment regarding the extension of your file.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to work around this, one option is to undo the effect of that particular rule, which you can do by clearing it after the syntax file is loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do that, you can create a new file &lt;code&gt;~/.vim/after/syntax/fortran.vim&lt;/code&gt; and add the following line there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn clear fortranSerialNumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will undo the syntax highlighting past column 72 in your Fortran files. Placing the file being in the &lt;code&gt;after/&lt;/code&gt; directory ensures it's loaded after the main syntax highlighting rules, so it will have a rule to delete there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/syntax.txt.html#mysyntaxfile-add&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help mysyntaxfile-add&lt;/code&gt;&lt;/a&gt; for more details on customizing syntax rules in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that this change will affect &lt;em&gt;all&lt;/em&gt; Fortran files (more specifically, fixed source ones, which use this rule.) If you want something more localized, to a single project only, you might need to do some adjustments to only remove the rule depending on the specific file. (An option to consider to implement this is to use an alternative file type, on the &lt;code&gt;'filetype'&lt;/code&gt; setting, that will source the &lt;code&gt;fortran.vim&lt;/code&gt; files and add modifications. Another option is to use multiple filetypes in &lt;code&gt;'filetype'&lt;/code&gt;, separated by a dot &lt;code&gt;.&lt;/code&gt;, so you can keep &lt;code&gt;fortran&lt;/code&gt; and add one more for your specific customizations.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There's one more option to consider. Looking around the definition of the &lt;code&gt;fortranSerialNumber&lt;/code&gt;, it's inside a block that checks that the &lt;code&gt;fortran_have_tabs&lt;/code&gt; variable is unset (presumably because if you're using tab characters, it's harder to check for a specific column, since tab sizes can vary.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you might be able to prevent the definition of this rule by adding this to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:fortran_have_tabs = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The advantage of this approach is that you can simply configure it from your vimrc file, no need to mess with anything inside the &lt;code&gt;~/.vim&lt;/code&gt; tree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, setting this will have a few other side effects. There are two other rules inside that block that won't get set (the rules seem to highlight errors in labels, which seem to be expected in specific columns.) There's also another rule regarding tab characters themselves. If you're fine with these side effects (considering you're breaking some rules by going past column 72, I guess you might?), then consider this as a possible solution for the issue as well.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-21T03:51:54.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22309" PostTypeId="1" CreationDate="2019-12-21T06:07:46.773" Score="1" ViewCount="2454" Body="&lt;p&gt;I am just getting into vim and I'm trying to get the preview window for my Rg results to show up with nice looking colors. Currently I have most of the stuff looking nice; here is a picture of where I currently am:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AVW78.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AVW78.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is in my vimrc for how I setup the Rg with quickfix window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  command! -bang -nargs=* Rg&#xA;    \ call fzf#vim#grep('rg --smart-case --line-number --no-heading -- &#xA;      color=always --colors &quot;path:fg:93,169,245&quot; --colors &#xA;      &quot;line:fg:128,128,128&quot; --colors &quot;match:fg:195,232,141&quot; --no-hidden &#xA;      -- ignore '.shelles    cape(&amp;lt;q-args&amp;gt;),&#xA;    \ 0,&#xA;    \ fzf#vim#with_preview({'options': '-e --delimiter : --nth 3..'}),&#xA;    \ &amp;lt;bang&amp;gt;0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What settings could I tweak in order to get the preview window to be consistent with the normal text in the editor? Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="26201" LastEditorUserId="6698" LastEditDate="2019-12-21T10:40:20.743" LastActivityDate="2020-04-10T09:33:10.253" Title="How could I customize preview window coloring with results from Ripgrep and fzf?" Tags="|vimrc|plugin-fzf|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22310" PostTypeId="2" ParentId="22306" CreationDate="2019-12-21T07:16:34.390" Score="2" Body="&lt;p&gt;I fixed it with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo aptitude install vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When aptitude told me about the dependencies and offered to fix them, I had tried saying yes, but that did not help. However, saying &lt;code&gt;n&lt;/code&gt; caused aptitude to offer to downgrade the packages to their correct versions. When I said &lt;code&gt;Y&lt;/code&gt; to that, it successfully installed vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then it was easy to install vim-gnome with the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo aptitude install vim-gnome&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This, combined with the settings&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plugin 'repeat.vim'&#xA;Plugin 'vim-easyclip.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my vimrc allowed the paste operations to use the system clipboard, which was the ultimate goal. At least this last step is specific to vim and may be helpful to others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A happy ending if the downgrading of the vim common and runtime does not have side effects!&lt;/p&gt;&#xA;" OwnerUserId="26198" LastEditorUserId="10604" LastEditDate="2019-12-21T14:31:20.670" LastActivityDate="2019-12-21T14:31:20.670" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22311" PostTypeId="1" CreationDate="2019-12-21T15:19:37.570" Score="1" ViewCount="106" Body="&lt;p&gt;is there a way to configure &lt;a href=&quot;https://github.com/terryma/vim-expand-region&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/terryma/vim-expand-region&lt;/a&gt; (or any other plugin) to work with &lt;code&gt;js&lt;/code&gt;,&lt;code&gt;jsx&lt;/code&gt;,&lt;code&gt;ts&lt;/code&gt;,&lt;code&gt;tsx&lt;/code&gt; files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm new to vim, I'm not sure what to do.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The mentioned plugin is not active since 2013.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="25436" LastActivityDate="2019-12-21T15:19:37.570" Title="Expanding region/selection for javascript" Tags="|filetype-javascript|selection|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22312" PostTypeId="2" ParentId="19465" CreationDate="2019-12-21T15:23:13.533" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;what's the difference between these two methods?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/change.txt.html#p&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;p&lt;/code&gt;&lt;/a&gt; inserts the content of a register&#xA;as it is, regardless of the encoding, but &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-R_CTRL-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;CTRL-R CTRL-R&lt;/code&gt;&lt;/a&gt;&#xA;encodes sequences of bytes before inserting them.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Explanation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Special key combinations, such as &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;→&lt;/kbd&gt;, are translated&#xA;into terminal keycodes like &lt;code&gt;^[[1;5C&lt;/code&gt;, then into vim keycodes like &lt;code&gt;&amp;lt;C-Right&amp;gt;&lt;/code&gt;,&#xA;and finally into a sequence of bytes starting with &lt;code&gt;0x80&lt;/code&gt; like &lt;code&gt;&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;V&lt;/code&gt; (&lt;code&gt;&amp;lt;80&amp;gt;&lt;/code&gt; is &lt;code&gt;0x80&lt;/code&gt;)&#xA;&lt;sup&gt;&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/10249/what-is-the-difference-between-mapped-key-sequences-and-key-codes-timeoutl/10284#10284&quot;&gt;[1]&lt;/a&gt;&#xA;&lt;a href=&quot;https://vi.stackexchange.com/a/14446/6698&quot;&gt;[2]&lt;/a&gt;&#xA;&lt;a href=&quot;https://vimhelp.org/eval.txt.html#getchar%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;[3]&lt;/a&gt;&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/6088/using-c-causes-80%c3%bcd-to-flash-in-the-showcmd-area#comment18157_6088&quot;&gt;[4]&lt;/a&gt;&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/6088/using-c-causes-80%c3%bcd-to-flash-in-the-showcmd-area#comment18160_6088&quot;&gt;[5]&lt;/a&gt;&lt;/sup&gt;.&#xA;This is a special case where the vim keycode is different than the terminal keycode&#xA;&lt;sup&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/20347/6698&quot;&gt;[6]&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After assigning the register &lt;code&gt;q&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @q=&quot;\&amp;lt;C-Right&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the sequence of bytes is what's actually saved:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:registers q&#xA;Type Name Content&#xA;  c  &quot;q   &amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;V&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I went to insert mode and put this sequence by hand as &lt;a href=&quot;https://en.wikipedia.org/wiki/Code_point&quot; rel=&quot;nofollow noreferrer&quot;&gt;Unicode code points&lt;/a&gt;&#xA;&lt;sup&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/555/6698&quot;&gt;[7]&lt;/a&gt;&#xA;&lt;a href=&quot;https://vi.stackexchange.com/a/3558/6698&quot;&gt;[8]&lt;/a&gt;&#xA;&lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-V_digit&quot; rel=&quot;nofollow noreferrer&quot;&gt;[9]&lt;/a&gt;&lt;/sup&gt; (&lt;code&gt;V&lt;/code&gt; is &lt;code&gt;0x56&lt;/code&gt; here)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; &lt;kbd&gt;u&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;8&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt; for &lt;a href=&quot;https://codepoints.net/U+0080&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;80&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; &lt;kbd&gt;u&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; for &lt;a href=&quot;https://codepoints.net/U+00fd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;fd&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; &lt;kbd&gt;u&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;5&lt;/kbd&gt;&lt;kbd&gt;6&lt;/kbd&gt; for &lt;a href=&quot;https://codepoints.net/U+0056&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;V&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is what I would get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;80&amp;gt;ýV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is the same result as the one I would get if I pressed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;r&lt;/kbd&gt; &lt;kbd&gt;q&lt;/kbd&gt; in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have no idea what &lt;code&gt;&amp;lt;c2&amp;gt;&lt;/code&gt; is&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If the cursor is moved on the opening angle bracket &lt;code&gt;&amp;lt;&lt;/code&gt; in the previous output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;80&amp;gt;ýV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then press &lt;a href=&quot;https://vimhelp.org/various.txt.html#g8&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g8&lt;/code&gt;&lt;/a&gt; in normal mode, this is the output I'd get &lt;sup&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/560/6698&quot;&gt;[10]&lt;/a&gt;&lt;a href=&quot;https://vi.stackexchange.com/q/21471/6698&quot;&gt;[11]&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;c2 80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These are the hexadecimal numbers for the two-byte UTF-8 character under the cursor; so the &lt;code&gt;&amp;lt;c2&amp;gt;&lt;/code&gt; is the first byte of the two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a final note, what follows is the output of &lt;code&gt;&quot;qp&lt;/code&gt; in normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;80&amp;gt;&amp;lt;fd&amp;gt;V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I again move the cursor on the first &lt;code&gt;&amp;lt;&lt;/code&gt; and press &lt;code&gt;g8&lt;/code&gt; the output would be different:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;because that's not a UTF-8 character but just a binary one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to all the Vi and Vim community (including you) who made this answer possible.  I hope this answer is useful.&lt;/p&gt;&#xA;" OwnerUserId="6698" LastEditorUserId="6698" LastEditDate="2019-12-21T23:44:19.783" LastActivityDate="2019-12-21T23:44:19.783" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22313" PostTypeId="1" AcceptedAnswerId="22315" CreationDate="2019-12-21T20:16:59.337" Score="4" ViewCount="7895" Body="&lt;p&gt;Following the answers in  I have tried many varieties of setting the &lt;code&gt;font&lt;/code&gt; size and face in &lt;code&gt;~/.vimrc&lt;/code&gt; . None of them have any effect&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Menlo:h12&#xA;set guifont=Monaco:h12&#xA;set guifont=Menlo\ Regular:h12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that executing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set gfn=*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;does&lt;/em&gt; bring up a font chooser dialog - and I am able to choose either Monaco or Menlo or many others correctly.   But I don't want to have to choose every time - thus the &lt;code&gt;~/.vimrc&lt;/code&gt; . What might be wrong how to fix this?&lt;/p&gt;&#xA;" OwnerUserId="16428" OwnerDisplayName="javadba" LastEditorUserId="10604" LastEditDate="2019-12-22T04:03:44.657" LastActivityDate="2022-08-08T06:21:40.837" Title="Settings for the font in .vimrc are not working" Tags="|gvim|font|" AnswerCount="6" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22314" PostTypeId="1" AcceptedAnswerId="22316" CreationDate="2019-12-21T23:18:57.200" Score="4" ViewCount="1089" Body="&lt;p&gt;I currently use scratch buffers a lot for various uses such as when I read from STDIN to quickly analyze some data or take some very temporary notes. That way I don't have to worry about a swap file or the quit message when I leave the buffer. However, once in a while I decide to save the file for future reference. I'm wondering how to cause the buffer to switch to that new file automatically after saving instead of staying in my scratch buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I am referring to the scratch buffer, these are the commands I'm using to turn on and off the scratch buffer settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    command! TurnOnScratchBuffer setlocal buftype=nofile bufhidden=hide noswapfile&#xA;    command! TurnOffScratchBuffer setlocal buftype=&quot;&quot; bufhidden=&quot;&quot; swapfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I don't set the buffer as a scratch buffer in the first place or when I turn the scratch buffer on then off again, vim seems to already have the behavior I desire by immediately switching to the newly created file. However when I try to automate this with autocmds, then I get weird results that I believe have something to do with when various things trigger but I'm not sure. Here is an example of the current autocmds that I'm trying to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Turn on scratch buffer settings when reading from STDIN or working with &#xA;autocmd StdinReadPre,StdinReadPost * :TurnOnScratchBuffer&#xA;autocmd VimEnter,BufNew * if @% == &quot;&quot; &amp;amp;&amp;amp; &amp;amp;buftype == &quot;&quot; | execute ':TurnOnScratchBuffer' | endif&#xA;autocmd BufWrite * if (@% == &quot;&quot; || @% == &quot;-stdin-&quot;) &amp;amp;&amp;amp; &amp;amp;buftype == &quot;nofile&quot; | execute ':TurnOffScratchBuffer' | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An as a pure example of how I would like it to work, say I run &lt;code&gt;ls | vim -&lt;/code&gt; then what should happen is a scratch buffer should open with the listings of the current directory in a scratch buffer. If I then save this to a file &lt;code&gt;:w test&lt;/code&gt;, then it will smoothly move to a buffer that is for the &lt;code&gt;test&lt;/code&gt; file. If I save again, it should save directly to the &lt;code&gt;test&lt;/code&gt; file. If I try to exit after making some changes, it should prompt me to save as you would expect when editing any normal file in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first part of that example I can get to work just fine, but the saving part is not behaving how I would like and I'm unsure why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me know if there is another way of going about this too! Thanks for the help.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;UPDATE&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Finally got everything working thanks to the help of the wonderful people here. I learned so much from this little change that I can honestly say I'm better for it. I'm adding the final changes I made to simplify it for others that see this going forward.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar TurnOnScratchBuffer setlocal buftype=nofile bufhidden=hide noswapfile&#xA;command! -bar TurnOffScratchBuffer setlocal buftype= bufhidden= swapfile&#xA;command! -bar NewScratch new | TurnOnScratchBuffer&#xA;&#xA;augroup scratch_buffers &#xA;    autocmd!&#xA;    autocmd StdinReadPre * TurnOnScratchBuffer&#xA;    autocmd VimEnter * &#xA;        \   if @% == '' &amp;amp;&amp;amp; &amp;amp;buftype == ''&#xA;        \ |     TurnOnScratchBuffer&#xA;        \ | endif&#xA;    autocmd BufWritePost * ++nested&#xA;        \   if (empty(bufname()) || bufname() == '-stdin-') &amp;amp;&amp;amp; &amp;amp;buftype == 'nofile'&#xA;        \ |     TurnOffScratchBuffer&#xA;        \ |     setlocal nomodified&#xA;        \ |     edit &amp;lt;afile&amp;gt;&#xA;        \ | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26206" LastEditorUserId="26206" LastEditDate="2019-12-22T18:55:52.183" LastActivityDate="2019-12-22T18:55:52.183" Title="Saving a scratch buffer" Tags="|vimrc|autocmd|scratch-buffer|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22315" PostTypeId="2" ParentId="22313" CreationDate="2019-12-22T04:05:15.447" Score="4" Body="&lt;p&gt;Since font is specific to the GUI versions of vim (i.e. gvim and macvim), you &lt;s&gt;need to&lt;/s&gt; &lt;em&gt;should&lt;/em&gt; put the &lt;code&gt;set guifont=...&lt;/code&gt; line in your gvimrc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good place for that is &lt;code&gt;~/.vim/gvimrc&lt;/code&gt;, but you can read &lt;code&gt;help gvimrc&lt;/code&gt; for locations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;code&gt;setting-guifont&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                                        *setting-guifont*&#xA;When you use the same vimrc file on various systems, you can use something&#xA;like this to set options specifically for each type of GUI:&#xA;&#xA;if has(&quot;gui_running&quot;)&#xA;  if has(&quot;gui_gtk2&quot;)&#xA;    :set guifont=Luxi\ Mono\ 12&#xA;  elseif has(&quot;x11&quot;)&#xA;    &quot; Also for GTK 1&#xA;    :set guifont=*-lucidatypewriter-medium-r-normal-*-*-180-*-*-m-*-*&#xA;  elseif has(&quot;gui_win32&quot;)&#xA;    :set guifont=Luxi_Mono:h12:cANSI&#xA;  elseif has(&quot;gui_macvim&quot;)&#xA;    :set guifont=DejaVu\ Sans\ Mono:h13&#xA;  endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this would indicate &lt;code&gt;guifont&lt;/code&gt; should be set only when &lt;code&gt;has('gui_running')&lt;/code&gt; is true—i.e., when the gui is started or about to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find anything that &lt;em&gt;requires&lt;/em&gt; this in &lt;code&gt;help macvim&lt;/code&gt;, &lt;code&gt;help gui&lt;/code&gt;, or &lt;code&gt;help gui-init&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2019-12-22T15:56:45.533" LastActivityDate="2019-12-22T15:56:45.533" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22316" PostTypeId="2" ParentId="22314" CreationDate="2019-12-22T04:46:00.577" Score="3" Body="&lt;h2&gt;Some notes&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You don't need both &lt;code&gt;StdinReadPre&lt;/code&gt; and &lt;code&gt;StdinReadPost&lt;/code&gt;, one is enough.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strike&gt;&lt;code&gt;TurnOnScratchBuffer&lt;/code&gt; and &lt;code&gt;TurnOffScratchBuffer&lt;/code&gt; are valid &lt;code&gt;command&lt;/code&gt;, they can be executed directly without &lt;code&gt;execute&lt;/code&gt;, the leading &lt;code&gt;:&lt;/code&gt; is also redundant.&lt;/strike&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't use &lt;code&gt;&quot;&lt;/code&gt; with &lt;code&gt;:set&lt;/code&gt;, &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#%3Aquote&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :quote&lt;/a&gt; is used to comment, everything after it is ignored.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;autocmd&lt;/code&gt; should always be created inside &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#%3Aaugroup&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :augroup&lt;/a&gt; .&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Save a scratch buffer&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I thought i can use &lt;code&gt;:w path&lt;/code&gt; or &lt;code&gt;:saveas path&lt;/code&gt;, but they have side effects:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:w path&lt;/code&gt; write your scratch buffer content to a new file, a normal unlisted buffer is also created for that file, it becomes your alternate buffer.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:saveas path&lt;/code&gt; change your buffer filename, write to it, a normal blank buffer is also created, it becomes your alternate buffer.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that current buffer doesn't change in both case, their buffer type is still &lt;code&gt;nofile&lt;/code&gt;, an extra buffer is also created in both case, it's annoying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way is to use &lt;code&gt;:file&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com -nargs=1 -complete=file SaveScratch file &amp;lt;args&amp;gt; | set buftype= swapfile | w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's clean, no extra buffers.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another way to view stdin and quit without error message is to use the &lt;code&gt;-R&lt;/code&gt; option&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo 123 | vim -R -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can create an alias for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vless=&quot;vim -R -&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At last I prefer to create &lt;code&gt;scratch&lt;/code&gt; buffer with a customized command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-n&amp;gt;&amp;lt;c-s&amp;gt; :NewScratch&amp;lt;cr&amp;gt;&#xA;com NewScratch new | setlocal buftype=nofile bufhidden=hide noswapfile nobuflisted&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you prefer &lt;code&gt;:w path&lt;/code&gt;, you can use &lt;code&gt;&amp;lt;c-^&amp;gt;&lt;/code&gt; to switch to alternate buffer, it's a normal buffer of the saved file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to switch to it automatically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup scratch_auto_switch | au!&#xA;  autocmd BufWritePost * call s:switch_scratch()&#xA;augroup end&#xA;&#xA;function s:switch_scratch() abort&#xA;  if &amp;amp;buftype ==# 'nofile' &amp;amp;&amp;amp; expand('&amp;lt;afile&amp;gt;') == bufname('#')&#xA;    b #&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It relies on the fact that after &lt;code&gt;w path&lt;/code&gt;, alternate file is the same as &lt;code&gt;&amp;lt;afile&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-12-22T06:58:44.670" LastActivityDate="2019-12-22T06:58:44.670" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="22317" PostTypeId="2" ParentId="22314" CreationDate="2019-12-22T06:33:32.490" Score="1" Body="&lt;p&gt;That should be enough:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup scratch_write | au!&#xA;    autocmd BufWrite *&#xA;        \ if &amp;amp;bt ==# 'nofile' &amp;amp;&amp;amp; (empty(bufname()) || bufname() ==# '-stdin-') |&#xA;            \ set nomodified&#xA;            \ TurnOffScratchBuffer |&#xA;            \ silent file &amp;lt;afile&amp;gt; |&#xA;        \ endif&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also don't use quote inside &lt;code&gt;:set&lt;/code&gt; and add &lt;code&gt;:h command-bar&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar TurnOffScratchBuffer setlocal buftype= bufhidden= swapfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-12-22T10:31:33.930" LastActivityDate="2019-12-22T10:31:33.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22318" PostTypeId="1" AcceptedAnswerId="22319" CreationDate="2019-12-22T07:12:32.003" Score="4" ViewCount="341" Body="&lt;p&gt;This works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup au_test | au!&#xA;  autocmd BufNew * if 1 | echom 123 | endif&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com Test echom 123&#xA;augroup au_test | au!&#xA;  autocmd BufNew * if 1 | Test | endif&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It results in following error when i create new buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E488: Trailing characters:  Test | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This behavior was found by &lt;a href=&quot;https://vi.stackexchange.com/users/26206/samuel-jackson&quot;&gt;Samuel Jackson&lt;/a&gt; in this &lt;a href=&quot;https://vi.stackexchange.com/questions/22314/saving-a-scratch-buffer&quot;&gt;question&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-12-22T07:57:36.430" Title="Autocmd treat user defined command differently?" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22319" PostTypeId="2" ParentId="22318" CreationDate="2019-12-22T07:57:36.430" Score="5" Body="&lt;p&gt;Vimscript (well, Ex) is weird in that each command will determine whether they'll take &lt;code&gt;|&lt;/code&gt; as an argument or whether they'll allow it as a separator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of user-defined commands, they default to taking &lt;code&gt;|&lt;/code&gt; as an argument, but you can override that by passing a &lt;code&gt;-bar&lt;/code&gt; argument to the &lt;code&gt;:command&lt;/code&gt; definition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, defining &lt;code&gt;Test&lt;/code&gt; this way would have prevented the issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com -bar Test echom 123&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#%3Abar&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :bar&lt;/code&gt;&lt;/a&gt; for more details and a list of commands that take &lt;code&gt;|&lt;/code&gt; as an argument:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;These commands see the '|' as their argument, and can therefore not be followed by another Vim command:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;code&gt;:argdo&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;:autocmd&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;...&lt;/li&gt;&#xA;  &lt;li&gt;a user defined command without the &lt;code&gt;-bar&lt;/code&gt; argument&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;To be able to use another command anyway, use the &lt;code&gt;:execute&lt;/code&gt; command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Acommand&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :command&lt;/code&gt;&lt;/a&gt;, in particular the part that covers &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Acommand-bar&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;-bar&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-22T07:57:36.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22320" PostTypeId="1" AcceptedAnswerId="22323" CreationDate="2019-12-22T18:23:56.523" Score="4" ViewCount="1115" Body="&lt;p&gt;I'm using &lt;code&gt;nvim_get_mode&lt;/code&gt; to get the current mode of Neovim for a Rust-based plugin that I'm working on. However, a cursory look through Neovim's docs doesn't show a comprehensive list of the editor's possible modes and their mapped shortnames. Is there any place where I can find a list of modes and their shortnames for use?&lt;/p&gt;&#xA;" OwnerUserId="26214" LastActivityDate="2019-12-22T21:25:48.823" Title="API, Modes, and their Short-Names" Tags="|neovim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22321" PostTypeId="1" AcceptedAnswerId="22322" CreationDate="2019-12-22T18:49:48.900" Score="2" ViewCount="142" Body="&lt;p&gt;I can get the site package location here: &lt;a href=&quot;https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory&quot;&gt;https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone written a script that copies the results of that into path?&lt;/p&gt;&#xA;" OwnerUserId="26215" LastActivityDate="2019-12-22T19:07:26.107" Title="How do I configure the path to match Python's site-package location?" Tags="|path|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22322" PostTypeId="2" ParentId="22321" CreationDate="2019-12-22T19:07:26.107" Score="2" Body="&lt;p&gt;You might check out tpope's &lt;a href=&quot;https://github.com/tpope/vim-apathy&quot; rel=&quot;nofollow noreferrer&quot;&gt;apathy.vim&lt;/a&gt; for global site-packages.&lt;/p&gt;&#xA;" OwnerUserId="6698" LastActivityDate="2019-12-22T19:07:26.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22323" PostTypeId="2" ParentId="22320" CreationDate="2019-12-22T21:25:48.823" Score="3" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/22320/api-modes-and-their-short-names#comment40428_22320&quot;&gt;@Matt confirms in the comments&lt;/a&gt;, it is documented at &lt;code&gt;mode()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;           n        Normal, Terminal-Normal&#xA;           no       Operator-pending&#xA;           nov      Operator-pending (forced characterwise |o_v|)&#xA;           noV      Operator-pending (forced linewise |o_V|)&#xA;           noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|);&#xA;                CTRL-V is one character&#xA;           niI      Normal using |i_CTRL-O| in |Insert-mode|&#xA;           niR      Normal using |i_CTRL-O| in |Replace-mode|&#xA;           niV      Normal using |i_CTRL-O| in |Virtual-Replace-mode|&#xA;           v        Visual by character&#xA;           V        Visual by line&#xA;           CTRL-V   Visual blockwise&#xA;           s        Select by character&#xA;           S        Select by line&#xA;           CTRL-S   Select blockwise&#xA;           i        Insert&#xA;           ic       Insert mode completion |compl-generic|&#xA;           ix       Insert mode |i_CTRL-X| completion&#xA;           R        Replace |R|&#xA;           Rc       Replace mode completion |compl-generic|&#xA;           Rv       Virtual Replace |gR|&#xA;           Rx       Replace mode |i_CTRL-X| completion&#xA;           c        Command-line editing&#xA;           cv       Vim Ex mode |gQ|&#xA;           ce       Normal Ex mode |Q|&#xA;           r        Hit-enter prompt&#xA;           rm       The -- more -- prompt&#xA;           r?       A |:confirm| query of some sort&#xA;           !        Shell or external command is executing&#xA;           t        Terminal-Job mode: keys go to the job&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-12-22T21:25:48.823" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22324" PostTypeId="1" CreationDate="2019-12-23T09:27:07.337" Score="5" ViewCount="1169" Body="&lt;p&gt;I installed &lt;a href=&quot;https://github.com/scrooloose/nerdcommenter&quot; rel=&quot;noreferrer&quot;&gt;NERDCommenter&lt;/a&gt; plugin and its default bindings unfortunately conflict with my own. For instance I use &lt;code&gt;&amp;lt;Leader&amp;gt;-c&lt;/code&gt; and &lt;code&gt;&amp;lt;Leader&amp;gt;-v&lt;/code&gt; to emulate &lt;code&gt;CTRL-c&lt;/code&gt; and &lt;code&gt;CTRL-v&lt;/code&gt;. And since IDEs usually use &lt;code&gt;CTRL-/&lt;/code&gt; to toggle comments I'd like to preserve this behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following in my &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:NERDCommenterToggle = &quot;&amp;lt;C-/&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when reloading the &lt;code&gt;vimrc&lt;/code&gt; the old mapping &lt;code&gt;&amp;lt;Leader&amp;gt;c&amp;lt;Space&amp;gt;&lt;/code&gt; is still in effect; the &lt;code&gt;&amp;lt;C-/&amp;gt;&lt;/code&gt; mapping has no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to cancel all the default bindings introduced by &lt;code&gt;NERDCommenter&lt;/code&gt; and bind only &lt;code&gt;g:NERDCommenterToggle&lt;/code&gt; to &lt;code&gt;C-/&lt;/code&gt;? &lt;/p&gt;&#xA;" OwnerUserId="9409" LastEditorUserId="10604" LastEditDate="2019-12-23T22:22:31.780" LastActivityDate="2019-12-24T04:02:18.453" Title="Binding toggle comment to &lt;C-/&gt;" Tags="|vimrc|key-bindings|vimscript|plugin-nerdcommenter|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22325" PostTypeId="2" ParentId="22324" CreationDate="2019-12-23T10:34:24.077" Score="4" Body="&lt;p&gt;I'm just going by the help doc in github but it appears that &lt;code&gt;'NERDCreateDefaultMappings'&lt;/code&gt; does exactly what you want for the first part, ie. toggle on/off all mappings (bindings)...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If set to 0, none of the default mappings will be created.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then you can manually bind to your heart's content. The help for &lt;code&gt;NERDCommenterMappings&lt;/code&gt; has a bit of advice for that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To change a mapping just map another key combo to the internal  mapping. For example, to remap the |NERDCommenterComment| mapping to &quot;,omg&quot; you would put this line in your vimrc:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map ,omg &amp;lt;plug&amp;gt;NERDCommenterComment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; If you need more help let's look at how the default for &lt;code&gt;NERDCommenterToggle&lt;/code&gt; is constructed. It should be clear now that we don't override like a normal variable (&lt;code&gt;:let x = y&lt;/code&gt;) but rather we need to define a mapping. The relevant bits responsible for defining the default mapping...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call s:CreateMaps('nx', 'Toggle', 'Toggle', 'c&amp;lt;space&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Signature of &lt;code&gt;CreateMaps&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:CreateMaps(modes, target, desc, combo)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Actual map definition where &lt;code&gt;modes&lt;/code&gt; is split and iterated over such that &lt;code&gt;mode&lt;/code&gt; has each value, &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;x&lt;/code&gt;, in turn...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute mode . 'map &amp;lt;leader&amp;gt;' . a:combo . ' ' . plug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;plug&lt;/code&gt; is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let plug = '&amp;lt;plug&amp;gt;NERDCommenter' . a:target&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that translates to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;c&amp;lt;space&amp;gt; &amp;lt;plug&amp;gt;NERDCommenterToggle&#xA;xmap &amp;lt;leader&amp;gt;c&amp;lt;space&amp;gt; &amp;lt;plug&amp;gt;NERDCommenterToggle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you want&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;C-/&amp;gt; &amp;lt;plug&amp;gt;NERDCommenterToggle&#xA;xmap &amp;lt;C-/&amp;gt; &amp;lt;plug&amp;gt;NERDCommenterToggle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may not need the &lt;code&gt;xmap&lt;/code&gt; version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Don't forget you need to set &lt;code&gt;NERDCreateDefaultMappings&lt;/code&gt; to 0, too.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-12-24T04:02:18.453" LastActivityDate="2019-12-24T04:02:18.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22326" PostTypeId="2" ParentId="9767" CreationDate="2019-12-23T15:16:05.310" Score="1" Body="&lt;p&gt;As other answers point out, Pathogen manipulates the Vim runtime directories rather than managing plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Git to manage changes to my Vim configuration files (living in &lt;code&gt;~/.vim&lt;/code&gt;). Each of my plugins (including Pathogen itself) is installed into &lt;code&gt;~/.vim/bundle&lt;/code&gt; directory as Git sub-modules. This allows me to to use &lt;code&gt;git submodule&lt;/code&gt; to pull in all changes&#xA;from the remote repository.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change into the repository working directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ensure that each git sub-module has the &lt;code&gt;master&lt;/code&gt; branch checked out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git submodule foreach git checkout master&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ensure that the remote-tracking branch is set to the origin remote:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git branch --set-upstream-to=origin/master master&#xA;# git submodule foreach git config branch.master.remote origin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Update each sub-module:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git submodule foreach git pull&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1608" LastActivityDate="2019-12-23T15:16:05.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22327" PostTypeId="2" ParentId="22307" CreationDate="2019-12-23T15:32:49.497" Score="9" Body="&lt;p&gt;Neovim's terminal has &quot;a specialty&quot;: a mouse click automatically switches it to &quot;Terminal-Normal&quot; mode. (BTW. That's not a case for Vim, so it does not suffer from this issue.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it won't work from &lt;code&gt;&amp;lt;LeftMouse&amp;gt;&lt;/code&gt;, but we can map &lt;code&gt;&amp;lt;LeftRelease&amp;gt;&lt;/code&gt; instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('nvim')&#xA;    augroup terminal_setup | au!&#xA;        autocmd TermOpen * nnoremap &amp;lt;buffer&amp;gt;&amp;lt;LeftRelease&amp;gt; &amp;lt;LeftRelease&amp;gt;i&#xA;        &quot; more stuff&#xA;    augroup end&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-12-24T05:08:21.840" LastActivityDate="2019-12-24T05:08:21.840" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22328" PostTypeId="1" CreationDate="2019-12-23T18:29:07.757" Score="1" ViewCount="36" Body="&lt;p&gt;when writing the following line a word by word:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;word1 word2 word3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to be able to undo like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;word1 word2 word&#xA;word1 word2 wor&#xA;word1 word2 w&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If I use &lt;code&gt;u&lt;/code&gt;, it will remove the entire line. &lt;/p&gt;&#xA;" OwnerUserId="25436" LastActivityDate="2019-12-23T18:29:07.757" Title="partial redo/undo" Tags="|undo-redo|" AnswerCount="0" CommentCount="1" ClosedDate="2019-12-28T20:34:31.140" ContentLicense="CC BY-SA 4.0" />
  <row Id="22329" PostTypeId="1" AcceptedAnswerId="22345" CreationDate="2019-12-23T22:19:13.277" Score="6" ViewCount="152" Body="&lt;p&gt;According to the &lt;code&gt;:help startup-options&lt;/code&gt;, this is &lt;code&gt;-w&lt;/code&gt;'s behviour&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-w {scriptout}  All the characters that you type are recorded in the file&#xA;                &quot;scriptout&quot;, until you exit Vim.  This is useful if you want&#xA;                to create a script file to be used with &quot;vim -s&quot; or&#xA;                &quot;:source!&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Specifically, it mentions the &lt;code&gt;-s&lt;/code&gt; flag as a useful application of &lt;code&gt;-w&lt;/code&gt;'s output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Testing this, it seems there isn't a 1-1 mapping of the two flags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For all standard keycodes, &lt;code&gt;-s&lt;/code&gt; behaves as expected when running &lt;code&gt;-w&lt;/code&gt;'s output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when &quot;special&quot; keycodes are used when running with &lt;code&gt;-w&lt;/code&gt; (e.g. &lt;code&gt;&amp;lt;Del&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt;, ...), Vim will output a special abstraction of these keycodes, that according to the documentation is a terminal-independent representation - for example, &lt;code&gt;&amp;lt;Del&amp;gt;&lt;/code&gt; is written in &lt;code&gt;-w&lt;/code&gt;'s output as &lt;code&gt;&amp;lt;80&amp;gt;&amp;lt;6b&amp;gt;&amp;lt;44&amp;gt; (hexa)&lt;/code&gt; (&lt;code&gt;&amp;lt;80&amp;gt;kD&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I expected Vim's behaviour to interpret the above sequence (&lt;code&gt;&amp;lt;80&amp;gt;&amp;lt;6b&amp;gt;&amp;lt;44&amp;gt;&lt;/code&gt;) as &lt;code&gt;&amp;lt;Del&amp;gt;&lt;/code&gt; when it is part of &lt;code&gt;-s&lt;/code&gt;'s input, but that is not the case. It appears to do something different which I have not been able to fully decipher yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I trying to use &lt;code&gt;-s&lt;/code&gt; in ways that are not intended? Or perhaps there is some hidden Vim option to make this work? Or is it simply a bug in Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any input will be greatly appreciated, thanks!&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Some details I gathered:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;80&amp;gt;&lt;/code&gt; is interpreted as a literal &lt;code&gt;&amp;lt;80&amp;gt;&lt;/code&gt; through &lt;code&gt;-s&lt;/code&gt;, which ends up as &lt;code&gt;&amp;lt;80&amp;gt;&amp;lt;fe&amp;gt;X&lt;/code&gt;. I don't think this is the intended behaviour.&lt;/li&gt;&#xA;&lt;li&gt;The suggestion to use &lt;code&gt;execute 'normal!'&lt;/code&gt; ended up not being suited for my use case as macros are disabled when running through &lt;code&gt;normal&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My use case actually required &quot;replaying&quot; user input for a fork of a python implementation of the vimgolf client :) (&lt;a href=&quot;https://github.com/dankilman/vimgolf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/dankilman/vimgolf&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ended up using &lt;code&gt;feedkeys(&quot;&amp;lt;key sequence&amp;gt;&quot;, 't')&lt;/code&gt; which met all my requirements.&lt;/p&gt;&#xA;" OwnerUserId="7725" LastEditorUserId="7725" LastEditDate="2019-12-26T11:27:04.200" LastActivityDate="2019-12-26T19:12:26.390" Title="Should the output of the -w {scriptout} flag work to replay actions using the -s {scriptin} flag?" Tags="|repeated-commands|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22330" PostTypeId="1" AcceptedAnswerId="22331" CreationDate="2019-12-24T07:15:59.393" Score="7" ViewCount="1973" Body="&lt;p&gt;I'm editing an HTML file, and my cursor is inside a tag, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;textarea class=&quot;code-area&quot;&amp;gt;&amp;lt;/textarea&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I'm trying to wrap all of this tag inside a &lt;code&gt;div&lt;/code&gt; tag, so that it'd be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;    &amp;lt;textarea class=&quot;code-area&quot;&amp;gt;&amp;lt;/textarea&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can use &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;noreferrer&quot;&gt;vim-surround&lt;/a&gt; and type &lt;code&gt;yss&amp;lt;div&amp;gt;&lt;/code&gt;, but it'll change it into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &amp;lt;div&amp;gt;&amp;lt;textarea id=&quot;code-area&quot;&amp;gt;&amp;lt;/textarea&amp;gt;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I wrap it so that it adds newlines as well?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the &lt;code&gt;yss&amp;lt;div&amp;gt;&lt;/code&gt; command only wraps the current line. I'm interested in wrapping an entire tag, no matter how many lines it has.&lt;/p&gt;&#xA;" OwnerUserId="26169" LastEditorUserId="26169" LastEditDate="2019-12-24T07:39:41.507" LastActivityDate="2020-12-14T21:10:54.597" Title="HTML - Wrap current tag inside another tag" Tags="|filetype-html|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22331" PostTypeId="2" ParentId="22330" CreationDate="2019-12-24T08:06:57.360" Score="9" Body="&lt;p&gt;In &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;noreferrer&quot;&gt;vim-surround&lt;/a&gt; &lt;code&gt;ys{motion}&lt;/code&gt; puts &quot;a surround text&quot; on the same line. To place it on a line of its own with indent you should use &lt;code&gt;yS{motion}&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, a motion you want for this case is &lt;code&gt;:h at&lt;/code&gt; (a tag). So this results in &lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;S&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;&amp;lt;&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;&gt;&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-24T08:06:57.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22332" PostTypeId="1" CreationDate="2019-12-24T11:31:57.370" Score="1" ViewCount="53" Body="&lt;p&gt;I am using bspwm so I added this line to my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWritePost $XDG_CONFIG_HOME/sxhkd/sxhkdrc silent exec &quot;!pkill -USR1 -x sxhkd &amp;amp;&amp;amp; sxhkd &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that when I edit sxhkdrc, it automatically reloads it. However, even though I added &quot;silent exec&quot;, it still prints a lot of junk all over the text, forcing me to do &lt;code&gt;redraw!&lt;/code&gt;. I thought of adding &lt;code&gt;| redraw!&lt;/code&gt; and the end of the above line, but the junk still appears, I believe because it will redraw before sxhkd prints all the crap over the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the best way to &quot;fix&quot; this? I could make a function that sleeps some time and only redraws after, but that doesn't feel very clean, is there a better way?&lt;/p&gt;&#xA;" OwnerUserId="21104" LastActivityDate="2019-12-24T17:13:01.033" Title="execute command after it print junk text?" Tags="|external-command|redraw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22333" PostTypeId="2" ParentId="22329" CreationDate="2019-12-24T13:33:16.213" Score="1" Body="&lt;p&gt;It looks like a nasty bug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When writing a script out, Vim uses its &quot;&amp;lt;&gt;-notation&quot; for keycodes, i.e. &lt;code&gt;&quot;\&amp;lt;BS&amp;gt;&quot;&lt;/code&gt; (&lt;code&gt;&amp;lt;80&amp;gt;kb&lt;/code&gt;) for backspace key, &lt;code&gt;&quot;\&amp;lt;del&amp;gt;&quot;&lt;/code&gt; (&lt;code&gt;&amp;lt;80&amp;gt;kD&lt;/code&gt;) for delete key, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, they only get converted back into &quot;real&quot; keys if pumped through &lt;code&gt;:normal&lt;/code&gt;. While &lt;code&gt;-s&lt;/code&gt; or &lt;code&gt;:source!&lt;/code&gt; simply allow them to pass through!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also interesting to note that Neovim seems to suffer from the same problem, except &quot;backspace&quot; key, as it gets written out as &lt;code&gt;&amp;lt;8&amp;gt;&lt;/code&gt;, so it eventually works. But &lt;code&gt;&quot;\&amp;lt;del&amp;gt;&quot;&lt;/code&gt; and others are just the same as in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So as a workaround you can do the following: &lt;code&gt;:execute 'normal!' readfile('scriptout', 'b')[0]&lt;/code&gt; Otherwise, I believe, it should be reported as a bug.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-12-26T13:59:06.757" LastActivityDate="2019-12-26T13:59:06.757" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22334" PostTypeId="1" AcceptedAnswerId="22336" CreationDate="2019-12-24T14:18:11.700" Score="5" ViewCount="589" Body="&lt;p&gt;I want to enable some configurations only when the distribution is Fedora. Here is my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:os = system(&quot;sed -n 's/^NAME=\(.*\)/\1/p' /etc/os-release&quot;)&#xA;echo s:os&#xA;if s:os == &quot;Fedora&quot;&#xA;        &quot; some configurations&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This snippet doesn't work and the &lt;code&gt;s:os&lt;/code&gt; is an empty string. However, the sed command works well when I run it in shell directly. I don't know why it doesn't work in vimrc.&lt;/p&gt;&#xA;" OwnerUserId="26138" LastActivityDate="2019-12-27T03:35:39.317" Title="`system()` can't get output of shell command in vimrc" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22335" PostTypeId="2" ParentId="22334" CreationDate="2019-12-24T16:46:55.937" Score="3" Body="&lt;p&gt;@Matt is absolutely right; you might use double backslashes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:os = system(&quot;sed -n 's/^NAME=\\(.*\\)/\\1/p' /etc/os-release&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or switch to a single-quoted string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:os = system('sed -n &quot;s/^NAME=\(.*\)/\1/p&quot; /etc/os-release')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But here's a tidbit: &lt;a href=&quot;https://en.wikipedia.org/wiki/Here_document&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here documents&lt;/a&gt; are also available as of &lt;a href=&quot;https://github.com/vim/vim/commit/c79745a82faeb5a6058e915ca49a4c69fa60ea01&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim 8.1.1362&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:command =&amp;lt;&amp;lt; trim END&#xA;    sed -n &quot;s/^NAME=\(.*\)/\1/p&quot; /etc/os-release&#xA;END&#xA;let s:os = system(s:command[0])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Alet-heredoc&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :let-heredoc&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Happy Vimming!&lt;/p&gt;&#xA;" OwnerUserId="6698" LastActivityDate="2019-12-24T16:46:55.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22336" PostTypeId="2" ParentId="22334" CreationDate="2019-12-24T16:47:08.177" Score="2" Body="&lt;p&gt;The trouble you're having is with the backslashes inside the string (as @Matt correctly pointed out in the comments.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim strings (using double-quotes as delimiters) interpret the backslash as a special character, so you need to escape them with an additional backslash if you want to use them in a double-quoted string.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:os = system(&quot;sed -n 's/^NAME=\\(.*\\)/\\1/p' /etc/os-release&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you might want to use single-quoted strings in Vim, since those do not treat the backslash as special and don't require escaping it. This is pretty fine in this particular case, since using double-quotes for the sed expression in the shell command is OK, since they do not contain any shell metacharacters such as &lt;code&gt;$&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:os = system('sed -n &quot;s/^NAME=\(.*\)/\1/p&quot; /etc/os-release')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the other hand, you could actually do that same operation using Vimscript primitives only, which should be more efficient (since you're not spawning a couple of external processes anymore) and more portable (since it doesn't depend on which particular shell you're using or whether a &lt;code&gt;sed&lt;/code&gt; can even be found in &lt;code&gt;$PATH&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider using the following snippet instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:os = matchlist(readfile('/etc/os-release'), '^NAME=\(.*\)')[1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/eval.txt.html#readfile%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help readfile()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/eval.txt.html#matchlist%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help matchlist()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to add some error handling, in case the file doesn't exist or the variable match can't be found there.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="1238" LastEditDate="2019-12-27T03:35:39.317" LastActivityDate="2019-12-27T03:35:39.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22337" PostTypeId="2" ParentId="22332" CreationDate="2019-12-24T17:13:01.033" Score="1" Body="&lt;p&gt;The output you're getting in your terminal that is messing up the text in Vim is likely from the running &lt;code&gt;sxhkd&lt;/code&gt; binary that you're spawning in background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a possible way to fix this, you can redirect its output to &lt;code&gt;/dev/null&lt;/code&gt; when you launch it from the autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of ending the external command with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sxhkd &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sxhkd &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe even use a redirect for stdin as well, to insure even less interference with Vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sxhkd &amp;lt;/dev/null &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Consider that launching a background process from Vim might have undesirable side effects, such as inheriting the environment variables and the terminal where it's started from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have the option, consider starting sxhkd from your system manager. If you're using systemd, you can configure user services in &lt;code&gt;~/.config/systemd/user/*.service&lt;/code&gt; and if you do so, you can restart it with &lt;code&gt;systemctl --user restart sxhkd.service&lt;/code&gt; which happens in foreground and will be completed before you're back to Vim. (If you're interested in that, consider asking in &lt;a href=&quot;https://unix.stackexchange.com/&quot;&gt;Unix &amp;amp; Linux SE&lt;/a&gt; for help to configure it.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-24T17:13:01.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22338" PostTypeId="1" AcceptedAnswerId="22339" CreationDate="2019-12-24T19:16:37.420" Score="1" ViewCount="343" Body="&lt;p&gt;Let's say I want to indent everything between lines 40 and 60 (both lines included). One way of doing this is to go to line 40 and indent 21 lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:40&#xA;21&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am slightly bothered by having to enter two commands to do this. Is there a single command that lets me indent everything between two line numbers without having to compute the number of lines between the two lines?&lt;/p&gt;&#xA;" OwnerUserId="26231" OwnerDisplayName="user1124109" LastEditorUserId="26231" LastEditDate="2019-12-24T19:30:53.237" LastActivityDate="2019-12-24T19:34:07.207" Title="How to indent text between specific line numbers in vim?" Tags="|indentation|shell|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22339" PostTypeId="2" ParentId="22338" CreationDate="2019-12-24T19:28:06.380" Score="4" Body="&lt;p&gt;See the last command mentioned here &lt;a href=&quot;https://vimhelp.org/change.txt.html#shift-left-right&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h shift-left-right&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]&amp;gt; {count} [flags]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So for your example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:40&amp;gt; 21&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if you don't want to do any arithmetic in your head:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:40,60&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2019-12-24T19:34:07.207" LastActivityDate="2019-12-24T19:34:07.207" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22340" PostTypeId="1" AcceptedAnswerId="22341" CreationDate="2019-12-25T00:40:31.617" Score="4" ViewCount="277" Body="&lt;p&gt;vimdoc says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BufUnload&#xA;Before unloading a buffer.  &#xA;...&#xA;NOTE: When this autocommand is executed, the&#xA;current buffer &quot;%&quot; may be different from the&#xA;buffer being unloaded &quot;&amp;lt;afile&amp;gt;&quot;.&#xA;Don't change to another buffer or window, it&#xA;will cause problems!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the current buffer isn't the deleted/unloaded buffer, then can I access b: variables? I have a buffer that has a temp file and if the buffer goes away, I want to clean up the temp file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:example_tempfile = tempname()&#xA;augroup example&#xA;    au!&#xA;    au BufUnload &amp;lt;buffer&amp;gt; call delete(b:example_tempfile)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2045" LastEditorUserId="10604" LastEditDate="2019-12-25T01:09:31.107" LastActivityDate="2019-12-25T01:09:31.107" Title="How can I access buffer variables from BufUnload/BufDelete?" Tags="|buffers|autocmd|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22341" PostTypeId="2" ParentId="22340" CreationDate="2019-12-25T01:04:05.280" Score="8" Body="&lt;p&gt;Use &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#%3Cafile%3E&quot; rel=&quot;noreferrer&quot;&gt;:h &amp;lt;afile&amp;gt;&lt;/a&gt; to get unloading buffer name, use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#getbufvar%28%29&quot; rel=&quot;noreferrer&quot;&gt;:h getbufvar()&lt;/a&gt; to get buffer local variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:example_tempfile = tempname()&#xA;augroup example&#xA;    au!&#xA;    au BufUnload &amp;lt;buffer&amp;gt; echom getbufvar( expand('&amp;lt;afile&amp;gt;'), 'example_tempfile' )&#xA;augroup END&#xA;bunload %&#xA;&#xA;--------------------------------&#xA;/tmp/vovl8Be/48&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2019-12-25T01:04:05.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22342" PostTypeId="1" AcceptedAnswerId="22343" CreationDate="2019-12-26T07:58:46.307" Score="2" ViewCount="1700" Body="&lt;p&gt;I have a variable that I would set to the current result I get from &lt;code&gt;:pwd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following, which obviously doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:let b:projectroot = expand(&quot;pwd&quot;)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this is essentially what I want to do. I want to switch to a directory using &lt;code&gt;:cd&lt;/code&gt; and set that as the value for the variable &lt;code&gt;b:projectroot&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="25193" LastActivityDate="2019-12-26T08:24:28.210" Title="Expand `pwd` inside a vim command" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22343" PostTypeId="2" ParentId="22342" CreationDate="2019-12-26T08:24:28.210" Score="4" Body="&lt;p&gt;The usual way to get the printed output of an Ex command such as &lt;code&gt;:pwd&lt;/code&gt; is to use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#execute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;execute()&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in this specific case, you can get the current directory in a more straightforward way by simply calling &lt;a href=&quot;https://vimhelp.org/eval.txt.html#getcwd%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getcwd()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:projectroot = getcwd()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue with &lt;code&gt;execute()&lt;/code&gt; in this particular case is that you get leading whitespace in your result, so you also need to use &lt;code&gt;trim()&lt;/code&gt; (or another similar string cleanup function) to get only the directory name:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:projectroot = trim(execute('pwd'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-26T08:24:28.210" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22344" PostTypeId="2" ParentId="4022" CreationDate="2019-12-26T09:56:10.660" Score="1" Body="&lt;p&gt;By default &lt;code&gt;vim -d&lt;/code&gt; (at least my version, 7.4) will open files in vertical mode, i.e. side by side.  (This is equivalent to using &lt;code&gt;-O&lt;/code&gt; option.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To open files in &quot;stacked&quot; mode, i.e. one below another, add &lt;code&gt;-o&lt;/code&gt; option.&lt;/p&gt;&#xA;" OwnerUserId="9204" LastEditorUserId="10604" LastEditDate="2019-12-26T12:53:55.547" LastActivityDate="2019-12-26T12:53:55.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22345" PostTypeId="2" ParentId="22329" CreationDate="2019-12-26T19:12:26.390" Score="2" Body="&lt;p&gt;This is a bug registered on &lt;a href=&quot;https://github.com/vim/vim/commit/26967617a30e55aedc98b8f14b841d88469abd0e#diff-38d7929bd26d74d92ceddf984bbfc8dbR164-R173&quot; rel=&quot;nofollow noreferrer&quot;&gt;March 17th,&#xA;2019&lt;/a&gt;&#xA;and reported on &lt;a href=&quot;https://github.com/vim/vim/issues/4041&quot; rel=&quot;nofollow noreferrer&quot;&gt;February 24th, 2019&lt;/a&gt;. From &lt;a href=&quot;https://vimhelp.org/todo.txt.html#known-bugs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help known-bugs&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bug: script written with &quot;-W scriptout&quot; contains Key codes, while the script&#xA;read with &quot;-s scriptin&quot; expects escape codes.  Probably &quot;scriptout&quot; needs to&#xA;be adjusted. (Daniel Steinberg, 2019 Feb 24, #4041)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As of this writing, it doesn't have a priority classification so it might take&#xA;a while before we get a fix for it. A similar issue reported on &lt;a href=&quot;https://stackoverflow.com/q/3981535/1121933&quot;&gt;October 20th,&#xA;2010&lt;/a&gt; (and related issue on &lt;a href=&quot;https://groups.google.com/d/topic/vim_dev/bUByeZXCetk/discussion&quot; rel=&quot;nofollow noreferrer&quot;&gt;March 4th,&#xA;2013&lt;/a&gt;) suggests this bug is in place (at least) since then.&lt;/p&gt;&#xA;" OwnerUserId="6698" LastActivityDate="2019-12-26T19:12:26.390" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22346" PostTypeId="1" AcceptedAnswerId="22349" CreationDate="2019-12-26T21:31:57.237" Score="4" ViewCount="788" Body="&lt;p&gt;In the type of  &lt;code&gt;c&lt;/code&gt; programming that I do day to day, I often have to &quot;fill&quot; struct members in order to pass them to an API. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct measurement {&#xA;double start_time;&#xA;double end_time;&#xA;double elapsed_ms;&#xA;// …&#xA;}&#xA;&#xA;struct measurement my_measurement;&#xA;my_measurement.start_time = 0.0;&#xA;my_measurement.end_time = 1.0;&#xA;my_measurement.elapsed_time = 1.0;&#xA;// …&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can get pretty tedious, so I was wondering if there's a plugin that would just expand every field of the struct when pressing a keymap. For example if you imagine that &lt;code&gt;|&lt;/code&gt; is my cursor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;struct measurement my_measurement;|&lt;/code&gt; &lt;code&gt;&amp;lt;leader&amp;gt;&amp;lt;tab&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim would output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_measurement.start_time = ;&#xA;my_measurement.end_time = ;&#xA;my_measurement.elapsed_time = ;&#xA;// ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25193" LastEditorUserId="1292" LastEditDate="2019-12-27T00:46:24.720" LastActivityDate="2020-06-07T01:36:26.347" Title="Is it possible to create a snippet to &quot;expand&quot; struct members to fill?" Tags="|vimscript|filetype-c|snippets|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22347" PostTypeId="2" ParentId="22346" CreationDate="2019-12-26T23:40:08.437" Score="1" Body="&lt;p&gt;At this time, I have something extremely similar in my &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-cpp&lt;/a&gt; plugin for C++. Within a class context, I type &lt;code&gt;:Constructor init&lt;/code&gt;, and my plugin will fetch all the member data (thanks to the API of two other plugins of mine: &lt;a href=&quot;https://github.com/LucHermitte/lh-dev/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-dev&lt;/a&gt; + &lt;a href=&quot;https://github.com/LucHermitte/lh-tags/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-tags&lt;/a&gt;) and generate the constructor. We aren't far from what you wish to accomplish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first step will be to extract the type of your variable. Then, we just need to run (universal!) ctags on the current buffer (in its present state, not necessarily saved), extract the attributes and transform them into lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Expecting the cursor is on the line where the variable is defined, it can be done with the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:init_struct(...) abort&#xA;  &quot; 1- extract the struct type&#xA;  let linenr = get(a:, 1, '.')&#xA;  let [all, struct, variable; tail] = matchlist(getline(linenr), '\v&amp;lt;struct&amp;gt;\s+(\k+)\s+(\k+)')&#xA;  if empty(struct)&#xA;    throw &quot;no struct variable definition on this line&quot;&#xA;  endif&#xA;&#xA;  &quot; 2- extract the members&#xA;  &quot; from lh-dev + lh-tags&#xA;  let attributes = lh#dev#class#attributes(struct, 1)&#xA;&#xA;  &quot; 3- transform the members into the lines to produce&#xA;  let lines = map(copy(attributes), {k,v -&amp;gt; substitute(v.name, v.struct.'::', variable.'.', ''). ' = '.lh#marker#txt().';'})&#xA;&#xA;  &quot; 4- insert them!&#xA;  put=lines&#xA;&#xA;  &quot; 5- and align!&#xA;  '[,']normal! ==&#xA;endfunction&#xA;&#xA;command! -nargs=0 InitStruct echo s:init_struct()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NB: that code requires lh-dev, lh-tags, and &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-vim-lib&lt;/a&gt;. The &lt;code&gt;lh#marker#txt()&lt;/code&gt; function produces a placeholder and comes from lh-brackets. If you use a snippet plugin other than my mu-template one (which is more than likely), you will have use its approach to produce and lines and the placeholders where the cursor will be able to jump to.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2019-12-27T14:11:40.547" LastActivityDate="2019-12-27T14:11:40.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22349" PostTypeId="2" ParentId="22346" CreationDate="2019-12-27T06:36:14.527" Score="6" Body="&lt;h2&gt;readtags&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;universal-ctags&lt;/code&gt; provide &lt;a href=&quot;https://docs.ctags.io/en/latest/news.html#readtags&quot; rel=&quot;nofollow noreferrer&quot;&gt;readtags&lt;/a&gt; to filter tags:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read all members of a &lt;code&gt;struct&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;readtags -Q '(and (eq? $kind &quot;member&quot;) (eq? $scope-name &quot;struct_name&quot;) )' -l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;(and (...) (...))&lt;/code&gt;:  &lt;code&gt;(...)&lt;/code&gt; and &lt;code&gt;(...)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(eq? $kind &quot;member&quot;)&lt;/code&gt; restrict &lt;code&gt;kind&lt;/code&gt; to &lt;code&gt;member&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(eq? $scope-name &quot;struct_name&quot;)&lt;/code&gt; restrict &lt;code&gt;scope-name&lt;/code&gt; to &lt;code&gt;struct_name&lt;/code&gt;, your tag fields must include &lt;code&gt;Z&lt;/code&gt; for this to work.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Read all enumerators of a &lt;code&gt;enum&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;readtags -Q '(and (eq? $kind &quot;enumerator&quot;) (eq? $scope-name &quot;enum_name&quot;) )' -l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read members or enumerators:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;readtags -Q '(and&#xA;             (or (prefix? &quot;member&quot; $kind) (prefix? &quot;enumerator&quot; $kind) )&#xA;             (eq? $scope-name &quot;galaxy::BulletClip&quot;)&#xA;             )' -l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(prefix? ...)&lt;/code&gt; is used instead of &lt;code&gt;(eq? ...)&lt;/code&gt; to make sure it works for both single letter and full name &lt;code&gt;kind&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Shell script&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;One drawback of &lt;code&gt;readtags&lt;/code&gt; is that it can not read from multiple tag files. We must call it for every tags in &lt;code&gt;:h tagfiles()&lt;/code&gt; . It's also a bit hard to use directly, so I build a small script on top of it, I call it &lt;a href=&quot;https://github.com/dedowsdi/dotfiles/blob/master/.ddd/script/readtagsi&quot; rel=&quot;nofollow noreferrer&quot;&gt;readtagsi&lt;/a&gt;, it's used to read tag that have a scope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Get member kind, output name only&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;readtagsi -ok m struct_name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Get member or enumerator kind, output name only&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;readtagsi -ok m -k e scope_name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Call it in vim&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;At last create trivial map and command in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap _m :ReadtagsI -ok m -k e &amp;lt;c-r&amp;gt;&amp;lt;c-A&amp;gt;&amp;lt;cr&amp;gt;&#xA;com -nargs=+ ReadtagsI call s:readtags_i(&amp;lt;q-args&amp;gt;)&#xA;&#xA;function s:readtags_i(args) abort&#xA;  let cmd = printf( 'readtagsi %s %s',&#xA;              \ join( map( tagfiles(), { i,v-&amp;gt; printf('-t &quot;%s&quot;', v)  } ) ),&#xA;              \ a:args )&#xA;  call append( line('.'), systemlist(cmd) )&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now you can place your cursor at struct or enum name, and do &lt;code&gt;_m&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-06-07T01:36:26.347" LastActivityDate="2020-06-07T01:36:26.347" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22350" PostTypeId="2" ParentId="22346" CreationDate="2019-12-27T10:56:39.880" Score="0" Body="&lt;p&gt;Here is a dirty and incomplete but &quot;more or less&quot; working solution without any external dependencies.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; search and expand struct fields at cursor position&#xA;&quot; input: [tagname, varname]&#xA;function s:expand_struct(id) abort&#xA;    if empty(a:id)&#xA;        return&#xA;    endif&#xA;    &quot; save current buffer and line number&#xA;    let [l:bufnr, l:lnum] = [bufnr(), line('.')]&#xA;    &quot; jump to struct definition (current or included file)&#xA;    &quot; note: fails if no match is found&#xA;    execute 'hide ijump' a:id[0]&#xA;    &quot; copy everything inside {}&#xA;    normal! ]my]M&#xA;    &quot; get back&#xA;    execute 'buffer' l:bufnr&#xA;    call cursor(l:lnum, 1)&#xA;    &quot; save current indent&#xA;    let l:indent = indent(l:lnum)&#xA;    &quot; now process the yanked text&#xA;    for l:line in split(@@, &quot;\n&quot;)&#xA;        &quot; to keep it simple: 'field' is any ident which ends in ';'&#xA;        let l:field = matchstr(l:line, '\K\k*\ze;')&#xA;        if !empty(l:field)&#xA;            put =repeat(' ', l:indent) . a:id[1] . '.' . l:field . ' = ;'&#xA;        endif&#xA;    endfor&#xA;endfunction&#xA;&#xA;&quot; a mapping to make use of the code above:&#xA;&quot; matches 'struct tagname ident' in the current line&#xA;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;x :call &amp;lt;SID&amp;gt;expand_struct(matchlist(getline('.'), '\vstruct\s+(\K\k*)\s+(\K\k*)')[1:2])&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-27T10:56:39.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22351" PostTypeId="1" AcceptedAnswerId="22354" CreationDate="2019-12-27T13:30:34.273" Score="2" ViewCount="1104" Body="&lt;p&gt;I would like to handle a &lt;em&gt;drag &amp;amp; drop&lt;/em&gt; event of a file into gvim in order to insert the file name into the buffer I am dropping it. This should happen only when such file is an image, e.g. &lt;code&gt;.png&lt;/code&gt;, or &lt;code&gt;.jpg&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of the default behavior of opening after dropping the file I want to paste the file name only if I detect it is an image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already checked &lt;code&gt;:help autocmd-events-abc&lt;/code&gt; but there was nothing related to drag and drop functionality or event associated to it. Is it written anywhere else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already know that &lt;code&gt;ftdetect&lt;/code&gt; directory is used to detect the filetypes depending on the file extension, among other possibilities.&lt;/p&gt;&#xA;" OwnerUserId="8939" LastActivityDate="2019-12-27T18:00:47.020" Title="How to handle a drag &amp; drop event in vim in order to paste the file path instead of opening it" Tags="|gvim|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22352" PostTypeId="1" AcceptedAnswerId="22353" CreationDate="2019-12-27T16:48:41.520" Score="1" ViewCount="357" Body="&lt;p&gt;I like what the shortcut &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; does, but I want to have a vertical split instead of horizontal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I managed to achieve this by defining the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-w&amp;gt;f :vertical wincmd f&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in normal mode it works perfectly. But I failed to do the same for &lt;strong&gt;visual mode&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have tried so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This yields 'E481: No range allowed&#xA;vnoremap &amp;lt;c-w&amp;gt;f :vertical wincmd f&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; This just ignores my selection and behaves like &amp;lt;c-w&amp;gt;f in normal mode,&#xA;&quot; i.e. attempts to open the file under cursor&#xA;vnoremap &amp;lt;c-w&amp;gt;f :&amp;lt;c-u&amp;gt;vertical wincmd f&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do such a thing for the visual mode?&lt;/p&gt;&#xA;" OwnerUserId="12475" LastActivityDate="2019-12-27T17:59:56.173" Title="Split window vertically and edit visually selected file" Tags="|vim-windows|split|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22353" PostTypeId="2" ParentId="22352" CreationDate="2019-12-27T17:52:06.817" Score="3" Body="&lt;p&gt;After you press &lt;code&gt;:&lt;/code&gt; you got into cmdline-mode. And there's no direct way back into Visual from it (except &lt;code&gt;normal! gv&lt;/code&gt; and such, but that's indirect through Normal). See &lt;code&gt;:h mode-switching&lt;/code&gt;, because it's essential to understand how Vim works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, you must do it in a different manner: while still in the Visual yank the selection and put it into the command line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;c-w&amp;gt;f y:vsplit +find&amp;lt;bslash&amp;gt;&amp;lt;space&amp;gt;&amp;lt;c-r&amp;gt;&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: if file name contains spaces you might also want to use &lt;code&gt;:h escape()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW. The Normal mode mapping could also be rewritten in a similar manner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-w&amp;gt;f :vsplit +find&amp;lt;bslash&amp;gt;&amp;lt;space&amp;gt;&amp;lt;c-r&amp;gt;&amp;lt;c-f&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's a single problem though: it always splits first, even if a file name was not found in path.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-12-27T17:59:56.173" LastActivityDate="2019-12-27T17:59:56.173" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22354" PostTypeId="2" ParentId="22351" CreationDate="2019-12-27T18:00:47.020" Score="3" Body="&lt;p&gt;According to &lt;code&gt;:help drag-n-drop&lt;/code&gt; and &lt;code&gt;:help :drop&lt;/code&gt;, it doesn't seem like this behavior is change-able.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The help also says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If Vim happens to be editing a command line, the names of the dropped files&#xA;and directories will be inserted at the cursor.  This allows you to use these&#xA;names with any Ex command.  Special characters (space, tab, double quote and&#xA;'|'; backslash on non-MS-Windows systems) will be escaped.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, you can instead do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:normal! a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(without hitting &lt;kbd&gt;Enter&lt;/kbd&gt;), drag-n-drop your file, then press &lt;kbd&gt;Enter&lt;/kbd&gt;. Rebind to a key for easier access, if you prefer.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-12-27T18:00:47.020" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22355" PostTypeId="1" AcceptedAnswerId="22356" CreationDate="2019-12-27T18:24:02.030" Score="2" ViewCount="278" Body="&lt;p&gt;A very helpful comment led me to investigate &lt;code&gt;:help mode-switching&lt;/code&gt; where after typing &lt;code&gt;:help mode&lt;/code&gt; I used autocomplete to explore which additional help topics contained &lt;code&gt;mode&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This was a very large number and now I wonder if &lt;code&gt;:help&lt;/code&gt; provides something like &lt;code&gt;apropos&lt;/code&gt;: return a list of all topics that contain a certain word in their title.&lt;/p&gt;&#xA;" OwnerUserId="1238" LastActivityDate="2019-12-27T19:12:31.007" Title=":help - is there something like apropos?" Tags="|help-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22356" PostTypeId="2" ParentId="22355" CreationDate="2019-12-27T18:31:15.223" Score="4" Body="&lt;p&gt;You're probably looking for &lt;code&gt;:helpgrep&lt;/code&gt;, which is mentioned in &lt;code&gt;:help helphelp&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-12-27T18:31:15.223" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22357" PostTypeId="2" ParentId="22355" CreationDate="2019-12-27T19:12:31.007" Score="1" Body="&lt;p&gt;To elaborate on @DBenKnoble answer, in VimHelp the asterisks are normally used to mark topics. So you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helpgrep *mode-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To eliminate the most of &quot;false positives&quot;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-27T19:12:31.007" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22358" PostTypeId="1" AcceptedAnswerId="22367" CreationDate="2019-12-27T20:05:02.727" Score="1" ViewCount="653" Body="&lt;p&gt;What I want to achieve is simply set up some auto command that will detect anytime I create a new file and based on the name of the file I want to insert a couple of lines of text in that file. So if the file name matches my string it will insert lines of text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know how to insert text if a new a file was created via &lt;code&gt;vim myfile&lt;/code&gt; but if within vim I do &lt;code&gt;tabnew myfile&lt;/code&gt; nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope I was clear, thanks!&lt;/p&gt;&#xA;" OwnerUserId="22782" LastEditorUserId="22782" LastEditDate="2019-12-29T04:33:38.563" LastActivityDate="2019-12-29T13:42:13.700" Title="How do I tell vim to detect when a new file was created and do some action?" Tags="|vimscript|autocmd|" AnswerCount="1" CommentCount="5" ClosedDate="2019-12-30T11:13:14.217" ContentLicense="CC BY-SA 4.0" />
  <row Id="22359" PostTypeId="1" AcceptedAnswerId="22360" CreationDate="2019-12-27T20:47:39.190" Score="8" ViewCount="5261" Body="&lt;p&gt;I have Vim 7 installed from my distro's package manager, and I compiled Vim 8 from source. Vim 8 is all in /usr/local. Then I created a new directory in $HOME called &quot;.vim8&quot;. I have all my Vim 7 stuff in $HOME/.vim/, and I want a clean directory for Vim 8 in $HOME/.vim8/.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Vim 8, I'm calling it like this: &lt;code&gt;/usr/local/bin/vim8 -u &quot;${HOME}/.vim8/vimrc&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That sets the vimrc to the right file. But it still doesn't load other things in &lt;code&gt;${HOME}/.vim8/&lt;/code&gt;. For example, I have the NERDTree plugin installed in pack:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ tree -L 5 $HOME/.vim8/&#xA;/home/todd/.vim8/&#xA;├── pack&#xA;│   └── vendor&#xA;│       └── start&#xA;│           └── nerdtree&#xA;│               ├── autoload&#xA;│               ├── CHANGELOG.md&#xA;│               ├── doc&#xA;│               ├── lib&#xA;│               ├── LICENCE&#xA;│               ├── nerdtree_plugin&#xA;│               ├── plugin&#xA;│               ├── README.markdown&#xA;│               ├── screenshot.png&#xA;│               └── syntax&#xA;└── vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet the plugin doesn't load. When I open vim8 I can't use NERDTree. It says it's not an editor command. Thinking about why this would be happening, I came up with a possibility: maybe it's using &lt;code&gt;$HOME/.vim8/vimrc&lt;/code&gt; as the rc file, but it's &lt;em&gt;not&lt;/em&gt; using &lt;code&gt;$HOME/.vim8&lt;/code&gt; for everything else. So I did this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim8 -u &quot;${HOME}/.vim8/vimrc&quot; -T dumb -c ':scriptnames|:q'&#xA;&#xA;  1: ~/.vim8/vimrc&#xA;  2: /usr/local/share/vim/vim82/syntax/syntax.vim&#xA;  3: /usr/local/share/vim/vim82/syntax/synload.vim&#xA;  4: /usr/local/share/vim/vim82/syntax/syncolor.vim&#xA;  5: ~/.vim/filetype.vim&#xA;  6: /usr/local/share/vim/vim82/filetype.vim&#xA;     [ ...and a bunch of other files from local... ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Aha! It appears I'm right. Vim is still looking in the .vim/ directory. So then I try setting runtimepath:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim8 -u &quot;${HOME}/.vim8/vimrc&quot; --cmd ':set runtimepath=~/.vim8/,$VIMRUNTIME' -T dumb -c ':scriptnames|:q'&#xA;&#xA;  1: ~/.vim8/vimrc&#xA;  2: /usr/local/share/vim/vim82/syntax/syntax.vim&#xA;  3: /usr/local/share/vim/vim82/syntax/synload.vim&#xA;  4: /usr/local/share/vim/vim82/syntax/syncolor.vim&#xA;  5: /usr/local/share/vim/vim82/filetype.vim&#xA;     [ ...and a bunch of other files from local... ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now it's not loading anything from .vim/. That's good. But also still not loading anything from .vim8/. NERDTree is still not available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I tell Vim to use an alternate user directory for runtime files? I want to keep the 7 and 8 configuration separate and side-by-side. Is there anything I can do make Vim 8 use &lt;code&gt;$HOME/.vim8/&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="9766" LastActivityDate="2019-12-29T01:22:47.050" Title="How to change location of ~/.vim" Tags="|vimrc|linux|environment-variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22360" PostTypeId="2" ParentId="22359" CreationDate="2019-12-27T23:12:16.607" Score="9" Body="&lt;p&gt;The specific path you're using (&lt;code&gt;&lt;b&gt;pack/&lt;/b&gt;vendor&lt;b&gt;/start/&lt;/b&gt;nerdtree&lt;/code&gt;) is using the &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#packages&quot; rel=&quot;noreferrer&quot;&gt;&quot;packages&quot; feature&lt;/a&gt;, which is a new Vim 8 feature that automates manipulation of &lt;code&gt;'runtimepath'&lt;/code&gt; in a way similar to how plug-in managers have been implemented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why your attempt setting &lt;code&gt;'runtimepath'&lt;/code&gt; from &lt;code&gt;--cmd&lt;/code&gt; doesn't work, since packages actually use a separate &lt;code&gt;'packpath'&lt;/code&gt; setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The location of &lt;code&gt;~/.vim&lt;/code&gt; is only set in Vim as part of those two options: &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27runtimepath%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'runtimepath'&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27packpath%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'packpath'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can override that to &lt;code&gt;~/.vim8&lt;/code&gt; by simply resetting these two options in the &lt;code&gt;.vimrc&lt;/code&gt; you use with Vim 8:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;set runtimepath=&lt;b&gt;~/.vim8&lt;/b&gt;,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,&lt;b&gt;~/.vim8/after&lt;/b&gt;&#xA;set packpath=&lt;b&gt;~/.vim8&lt;/b&gt;,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,&lt;b&gt;~/.vim8/after&lt;/b&gt;&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should be enough to have Vim read files from the separate directory.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you're building Vim 8 from sources, you might also want to consider patching it so it defaults to looking at &lt;code&gt;~/.vim8&lt;/code&gt; rather than &lt;code&gt;~/.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change those default paths &lt;a href=&quot;https://github.com/vim/vim/blob/v8.2.0/src/os_unix.h#L371-L382&quot; rel=&quot;noreferrer&quot;&gt;in &lt;code&gt;src/os_unix.h&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While at it, you might want to consider changing the &lt;a href=&quot;https://github.com/vim/vim/blob/v8.2.0/src/os_unix.h#L263&quot; rel=&quot;noreferrer&quot;&gt;location of the vimrc file&lt;/a&gt; and also the &lt;a href=&quot;https://github.com/vim/vim/blob/v8.2.0/src/os_unix.h#L272&quot; rel=&quot;noreferrer&quot;&gt;second vimrc file&lt;/a&gt; which is typically under &lt;code&gt;~/.vim&lt;/code&gt;, so you might want to update that one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Please note that some plug-ins (in particular, plug-in managers) might use &lt;code&gt;~/.vim&lt;/code&gt; as their default as well (or even hardcode that path), so you might need to deal with those separately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, Vundle &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim/blob/v0.10.2/autoload/vundle.vim#L63&quot; rel=&quot;noreferrer&quot;&gt;defaults to using &lt;code&gt;~/.vim/bundle&lt;/code&gt;&lt;/a&gt;, but you can easily override that in the &lt;code&gt;vundle#begin()&lt;/code&gt; call by passing a directory as an argument. (vim-plug, a more modern plug-in manager and in a way successor to Vundle, doesn't have this problem and will use the first path in &lt;code&gt;'runtimepath'&lt;/code&gt; instead as its default.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also consider whether you &lt;em&gt;really&lt;/em&gt; want and need to keep separate &lt;code&gt;~/.vim&lt;/code&gt; directories for Vim 7 and Vim 8. Vim has enough features that should make it possible/easy to keep a single config that works in multiple versions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, with Vim 8 packages, you can use a check such as &lt;code&gt;if has('packages')&lt;/code&gt; to check whether the feature is enabled or not. If support for packages is not available, you can use &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;noreferrer&quot;&gt;vim-pathogen&lt;/a&gt; to load the plug-ins from the package directories, so you can have selective backwards compatibility for those too.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2019-12-29T01:22:47.050" LastActivityDate="2019-12-29T01:22:47.050" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22361" PostTypeId="2" ParentId="22359" CreationDate="2019-12-28T09:47:27.537" Score="3" Body="&lt;p&gt;Starting from &lt;a href=&quot;http://ftp.vim.org/pub/vim/patches/7.4/7.4.1384&quot; rel=&quot;nofollow noreferrer&quot;&gt;Patch 7.4.1384&lt;/a&gt; Vim has &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27packpath%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'packpath'&lt;/code&gt;&lt;/a&gt; option for searching plugins. By default &lt;code&gt;'packpath'&lt;/code&gt; is equal to &lt;code&gt;'runtimepath'&lt;/code&gt; (until &lt;code&gt;'runtimepath'&lt;/code&gt; finally gets inflated by the plugins loaded), so you must keep them sync in your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For Vim 8, I'm calling it like this: /usr/local/bin/vim8 -u &quot;${HOME}/.vim8/vimrc&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can add the following lines on top of your &quot;main&quot; vimrc instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; check if we have version-specific config&#xA;let s:dotvim = '~/.vim' . (v:version / 100)&#xA;if isdirectory(expand(s:dotvim))&#xA;    &quot; setup runtimepath and packpath&#xA;    set runtimepath=$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after&#xA;    execute 'set runtimepath^=' . s:dotvim&#xA;    execute 'set runtimepath+=' . s:dotvim . '/after'&#xA;    if exists('&amp;amp;packpath')&#xA;        let &amp;amp;packpath = &amp;amp;runtimepath&#xA;    endif&#xA;    &quot; proceed with special config&#xA;    execute 'source' s:dotvim . '/vimrc'&#xA;    finish&#xA;endif&#xA;&quot; default stuff (if any) follows...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now an appropriate configuration will be chosen automatically.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-28T09:47:27.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22363" PostTypeId="1" AcceptedAnswerId="22365" CreationDate="2019-12-28T19:29:47.910" Score="3" ViewCount="187" Body="&lt;p&gt;Is there a place where the &lt;code&gt;netrw&lt;/code&gt; source code repository is hosted, so I can view its revision history? If not, is there at least a changelog somewhere?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do &lt;code&gt;git log&lt;/code&gt; on &lt;code&gt;netrw.vim&lt;/code&gt; in the &lt;code&gt;vim&lt;/code&gt; repository, all I see is &quot;Update runtime files&quot; commits, which changes bunch of plugins at the same time and is not informative at all.&lt;/p&gt;&#xA;" OwnerUserId="13992" LastEditorUserId="1238" LastEditDate="2019-12-28T20:33:39.877" LastActivityDate="2019-12-28T20:44:54.117" Title="Where can I see netrw plugin revision history or changelog?" Tags="|netrw|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22364" PostTypeId="2" ParentId="4022" CreationDate="2019-12-28T19:35:50.280" Score="0" Body="&lt;p&gt;To extend on accepted answer: you can just read exactly same number of bytes from both files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff &amp;lt;(hexdump -C -n $(stat -c %s small) big) &amp;lt;(hexdump -C small)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On Mac OSX, the command will instead be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimdiff &amp;lt;(hexdump -C -n $(stat -f %z small) big) &amp;lt;(hexdump -C small)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13992" LastActivityDate="2019-12-28T19:35:50.280" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22365" PostTypeId="2" ParentId="22363" CreationDate="2019-12-28T20:00:32.350" Score="3" Body="&lt;p&gt;Not quite a repository but &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1075&quot; rel=&quot;nofollow noreferrer&quot;&gt;netrw script&lt;/a&gt; seems to fit the bill (at least until 2014, or netrw v. 150).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From then on you can find the complete history in the file &lt;code&gt;vim/runtime/doc/pi_netrw.txt&lt;/code&gt;, the reference manual for &lt;code&gt;netrw&lt;/code&gt;, in chapter &lt;strong&gt;12 - History&lt;/strong&gt;. You can find that information at &lt;a href=&quot;https://vimhelp.org/pi_netrw.txt.html#netrw-history&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help netrw-history&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under &lt;a href=&quot;https://vimhelp.org/pi_netrw.txt.html#netrw-debug&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help netrw-debug&lt;/code&gt;&lt;/a&gt;, the author lists &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow noreferrer&quot;&gt;an URL&lt;/a&gt; where to find the latest development version of the plug-in, but it seems only a Vimball (zip file) is available from there, no links to a public source control repository, so it seems one is not really made available by the original author.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;(thanks for giving me the impetus to find that :-))&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="1238" LastEditorUserId="18609" LastEditDate="2019-12-28T20:44:54.117" LastActivityDate="2019-12-28T20:44:54.117" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22366" PostTypeId="1" AcceptedAnswerId="22369" CreationDate="2019-12-29T06:51:50.833" Score="7" ViewCount="289" Body="&lt;p&gt;Is there some way to resize windows without using the mouse, such that I can control which border moves?&lt;/p&gt;&#xA;&lt;p&gt;It seems like it's ordinarily the bottom border or right border that moves, relative to the window my cursor is in. I've found some cases where this is not the case (for example, expanding the vertical size of window 3 in the image below causes its &lt;em&gt;top&lt;/em&gt; border to move up).&lt;/p&gt;&#xA;&lt;p&gt;In the image below, I am trying to make window 5 larger by moving its top border up. However, I am not sure how to do this without using the mouse. Expanding the size of window 5 (&lt;code&gt;&amp;lt;c-w&amp;gt;+&lt;/code&gt;) causes its bottom border to move down (as opposed to having window 5's top border move up). Shrinking the size of windows 3 or 4 (&lt;code&gt;&amp;lt;c-w&amp;gt;-&lt;/code&gt;) causes their top borders to move down (as opposed to having window 5's top border move up).&lt;/p&gt;&#xA;&lt;p&gt;(note: the window number labels used here don't correspond to the actual Vim window numbers)&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zm7aq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zm7aq.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26249" LastEditorUserId="26249" LastEditDate="2022-06-01T15:17:19.370" LastActivityDate="2022-06-01T15:17:19.370" Title="How to force which border shifts when resizing windows?" Tags="|vim-windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22367" PostTypeId="2" ParentId="22358" CreationDate="2019-12-29T13:42:13.700" Score="3" Body="&lt;p&gt;As a first resource on files, buffers, tabs, etc., I recommend &lt;a href=&quot;https://stackoverflow.com/q/26708822/4400820&quot;&gt;this QA and the many links to be found there&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As for autocommands, they are indeed an advanced topic, so having a good grasp of the fundamentals is crucial. In particular, when you start editing a file in a new tab (such as via &lt;code&gt;:tabedit&lt;/code&gt;), either &lt;code&gt;BufRead&lt;/code&gt; or &lt;code&gt;BufNewFile&lt;/code&gt; should fire (&lt;a href=&quot;https://learnvimscriptthehardway.stevelosh.com/chapters/12.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Learn Vimscript the Hard Way&lt;/a&gt; has a great resource on autocommands, but I do recommend getting used to &lt;code&gt;:help&lt;/code&gt; first).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can use something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyGroup&#xA;  au!&#xA;  au BufRead,BufNewFile myPat normal! GAmy text&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use the &lt;code&gt;append()&lt;/code&gt;, though from mobile I don’t have the syntax offhand (something like &lt;code&gt;call append(line('$'), 'my text')&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, if your specific filename is actually detected as a filetype, and you want to trigger for all filetypes, I would recommend reading about filetype-plugins. Start with the help, and then there are some great resources here (search ftplugin). &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-12-29T13:42:13.700" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22368" PostTypeId="1" AcceptedAnswerId="28823" CreationDate="2019-12-29T17:33:26.597" Score="5" ViewCount="3876" Body="&lt;p&gt;Vim is my main editor but for typescript it's hard to see what the inferred type of a variable is. Whether it is a complex type or just a simple one, it'd be great to see the typescript inferred type&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Asked here but no response&#xA;&lt;a href=&quot;https://github.com/Quramy/tsuquyomi/issues/297&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Quramy/tsuquyomi/issues/297&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21883" LastEditorUserId="21883" LastEditDate="2021-04-04T04:29:54.290" LastActivityDate="2022-09-08T13:34:43.407" Title="See inferred type of a variable in typescript?" Tags="|filetype-typescript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22369" PostTypeId="2" ParentId="22366" CreationDate="2019-12-30T00:31:25.177" Score="4" Body="&lt;p&gt;It's decided by which kind of split they belong to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can tell the split type by the cross, if it's a &lt;code&gt;|&lt;/code&gt;, then it's two cols, each col has two rows, if it's blank, then it's two rows, each row has two cols, they are quite different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Window 1 and window 3 belong to the same &lt;strong&gt;col&lt;/strong&gt;, if you resize them vertically, only the bar1-3 moves, if you try to resize them horizontally, they can't do it, they have to hand the job to their parent, their parent window13 share a &lt;strong&gt;row&lt;/strong&gt; with window24, so bar13-24 moves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Window 5 , window 6, and parent of window13 and window24  belong to the same &lt;strong&gt;col&lt;/strong&gt;, when you resize window5 vertically, bar5-6 moves, it's the same as having 3 horizontal splits, vim prefer to move the bar below current window unless it's the bottom window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to move top bar of window 5, you have to make sure window 3 and 4 share the same row, so when you resize one of them vertically, their parent will move the top bar of window 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another interesting thing is &lt;strong&gt;the &quot;same&quot; layout will give you different window number&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you split your window into two rows, each row has two cols. The right top window has window number 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you split your window into two cols, each col has two rows. The right top window has window number 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Siblings are counted before cousins&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2019-12-30T03:00:15.520" LastActivityDate="2019-12-30T03:00:15.520" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22370" PostTypeId="1" CreationDate="2019-12-30T05:51:06.030" Score="1" ViewCount="501" Body="&lt;p&gt;editor: NVIM v0.4.3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following syntax file at &lt;code&gt;~/.config/nvim/after/syntax/javascript.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax clear javaScriptFunction&#xA;syntax match javaScriptFunction /\&amp;lt;module.exports\&amp;gt;/ nextgroup=javaScriptFuncName skipwhite conceal cchar=@&#xA;hi! link Conceal javaScriptFunction`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The plugin I am using &lt;a href=&quot;https://github.com/pangloss/vim-javascript&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/pangloss/vim-javascript&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My conceal code works fine if I don't enable vim-javascript plugin. But does not work with it. Is there a way to make it work with the plugin?&lt;/p&gt;&#xA;" OwnerUserId="25917" LastEditorUserId="25917" LastEditDate="2019-12-30T15:07:08.787" LastActivityDate="2024-01-09T17:02:35.423" Title="Unable to use conceal with vim-javascript plugin" Tags="|neovim|conceal|filetype-javascript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22371" PostTypeId="2" ParentId="17446" CreationDate="2019-12-30T15:59:35.693" Score="2" Body="&lt;p&gt;A solution that's more internal to vim, is to override &lt;code&gt;indentexpr&lt;/code&gt; with a custom indent expression (most likely just overriding the builtin &lt;code&gt;indentexpr&lt;/code&gt; for your specific instance).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The steps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;define a filetype override, either in an &lt;code&gt;autocmd&lt;/code&gt; (group) or in a &lt;code&gt;ftplugin&lt;/code&gt; override (preferred).&lt;/li&gt;&#xA;&lt;li&gt;define a new (global, i.e. starting with a capital letter) function, say &lt;code&gt;MyYamlIndent(lnum)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Add logic that detects the dash led entries. The main workhorse is likely &lt;code&gt;getline(v:lnum)&lt;/code&gt; and&lt;code&gt;getline(v:lnum-1)&lt;/code&gt;. The goal:&lt;/li&gt;&#xA;&lt;li&gt;find the indent count (in spaces) for the previous line.&lt;/li&gt;&#xA;&lt;li&gt;check if the current line contains a dash, if not, return the default (&lt;code&gt;GetYAMLIndent(v:lnum)&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;If there is a leading dash, return the previous line's leading indent (in count of spaces)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="26290" LastActivityDate="2019-12-30T15:59:35.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22372" PostTypeId="1" CreationDate="2019-12-30T16:16:06.877" Score="1" ViewCount="269" Body="&lt;p&gt;I would like to put in the quickfix the files &lt;strong&gt;not matching&lt;/strong&gt; a pattern. That it, these files don't have any line matching the search pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that for finding files whose content match a pattern I may use the &lt;code&gt;:vimgrep&lt;/code&gt; command, that alongside with &lt;code&gt;:cnext&lt;/code&gt; or &lt;code&gt;:cnf&lt;/code&gt; makes the possibility of navigate through the matches.&lt;/p&gt;&#xA;" OwnerUserId="8939" LastEditorUserId="10604" LastEditDate="2020-06-22T14:36:35.803" LastActivityDate="2020-06-22T14:36:35.803" Title="Put in quickfix list the files whose content does not match a pattern inside it" Tags="|quickfix|vimgrep|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22373" PostTypeId="1" AcceptedAnswerId="22407" CreationDate="2019-12-30T17:17:26.217" Score="2" ViewCount="1030" Body="&lt;p&gt;NeoVim is not recognising &lt;a href=&quot;https://solidity.readthedocs.io/en/v0.6.0/#&quot; rel=&quot;nofollow noreferrer&quot;&gt;Solidity&lt;/a&gt; filetypes (which end with the extension &lt;code&gt;.sol&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When editing a &lt;code&gt;.sol&lt;/code&gt; file typing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set filetype?&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;generates a &lt;code&gt;filetype=&lt;/code&gt; (e.g. blank).  This is in contrast to html, md, php, etc files which all produce the expected result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My initial reaction was that the Solidity programming language was not known to NeoVim (it isn't exactly C...).  However typing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:echo getcompletion('sol', 'filetype')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;produces &lt;code&gt;['solhint', 'solidity']&lt;/code&gt;.  NeoVim should therefore recognise the language.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can set this manually with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set filetype=solidity&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(which also means that &lt;code&gt;:ALEInfo&lt;/code&gt; recognises the file) however this is forgotten when I restart NeoVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appreciate that it is possible to configure NeoVim to &lt;a href=&quot;https://neovim.io/doc/user/filetype.html#new-filetype&quot; rel=&quot;nofollow noreferrer&quot;&gt;recognise unknown filetypes&lt;/a&gt;; but I'd rather have it work as it is meant to, than add workarounds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a NeoVim bug, am I doing something wrong or is my configuration flawed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am experiencing this issue using NVIM 0.3.8 on Ubuntu 18.04 and NVIM 0.4.3 on Ubuntu 19.10. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB - I also get the blank &lt;code&gt;filetype=&lt;/code&gt; using VIM 8.1.1401 on Ubuntu 19.10, but interestingly &lt;code&gt;:echo getcompletion('sol', 'filetype')&lt;/code&gt; returns &lt;code&gt;[]&lt;/code&gt;, i.e. nothing.&lt;/p&gt;&#xA;" OwnerUserId="20086" LastEditorUserId="20086" LastEditDate="2019-12-30T18:12:19.083" LastActivityDate="2020-01-05T15:48:05.683" Title="Solidity (*.sol) filetype not recognised in neovim" Tags="|neovim|filetype|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22374" PostTypeId="1" AcceptedAnswerId="22376" CreationDate="2019-12-30T19:22:41.067" Score="5" ViewCount="278" Body="&lt;p&gt;I see the following common pattern in the beginning of vim plugins (where &lt;code&gt;NAME&lt;/code&gt; is a placeholder for some plugin identifier):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;g:loaded_NAME&quot;)&#xA;  finish&#xA;endif&#xA;&#xA;let g:loaded_NAME = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example:&#xA;&lt;a href=&quot;https://github.com/tpope/vim-eunuch/blob/75efe06ccc63b7cd50b193b99cce83e3ad3e60cb/plugin/eunuch.vim#L5-L8&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/tpope/vim-eunuch/blob/75efe06ccc63b7cd50b193b99cce83e3ad3e60cb/plugin/eunuch.vim#L5-L8&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Presumably this type of guard is intended to prevent the script from executing multiple times. I am curious why such a guard is necessary. In what scenarios would a plugin load multiple times?&lt;/p&gt;&#xA;" OwnerUserId="26249" LastActivityDate="2019-12-31T05:15:28.333" Title="Why are inclusion guards used in vim plugins?" Tags="|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22375" PostTypeId="2" ParentId="22372" CreationDate="2019-12-30T21:37:15.580" Score="2" Body="&lt;p&gt;One way to do it would be to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;use &lt;code&gt;:args&lt;/code&gt; to populate the arglist with all the files in which you're interested&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;search()&lt;/code&gt; to check whether your pattern can be found in each file, and if it does not, add its path to a list&lt;/li&gt;&#xA;&lt;li&gt;give that list to &lt;code&gt;getqflist()&lt;/code&gt; to transform it into a quickfix list, and invoke &lt;code&gt;setqflist()&lt;/code&gt; to add it onto the stack of quickfix lists&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For example, if you're looking for all the files matching the glob &lt;code&gt;/etc/*.conf&lt;/code&gt;, but not containing the pattern &lt;code&gt;network&lt;/code&gt;, you could execute these 3 lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;args /etc/*.conf&#xA;let lines = [] | sil argdo if ! search('network', 'nW') | let lines += [expand('%:p')] | endif&#xA;call setqflist(getqflist({'lines': lines, 'efm': '%f'}).items) | cw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To make this easier, you could wrap the code inside a function and call it from a custom Ex command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com -nargs=* Vimgrepv call s:vimgrepv(&amp;lt;q-args&amp;gt;)&#xA;fu s:vimgrepv(args) abort&#xA;    let usage =&amp;lt;&amp;lt; trim END&#xA;        Vimgrepv /some pattern/ file ...&#xA;        Vimgrepv pattern file ...&#xA;    END&#xA;    let pat = '^\(\i\@!.\)\(.\{-}\)\1\s\+\(.*\)'&#xA;    let g = [2, 3]&#xA;    if match(a:args, pat) == -1&#xA;        let pat = '\(\S\+\)\s\+\(.*\)'&#xA;        let g = [1, 2]&#xA;    endif&#xA;    try&#xA;        let [pat, files] = matchlist(a:args, pat)[g[0]:g[1]]&#xA;    catch /^Vim\%((\a\+)\)\=:E688:/&#xA;        echo join(usage, &quot;\n&quot;) | return&#xA;    endtry&#xA;    arglocal | let curbuf = bufnr('%')&#xA;    exe 'args '..files&#xA;    let lines = []&#xA;    sil argdo if ! search(pat, 'nW') | let lines += [expand('%:p')] | endif&#xA;    argglobal | exe 'b '..curbuf&#xA;    call setqflist(getqflist({'lines': lines, 'efm': '%f'}).items) | cw&#xA;    call setqflist([], 'a', {'title': printf('files in %s NOT containing %s', files, pat)})&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It installs the custom command &lt;code&gt;Vimgrepv&lt;/code&gt;, which you could use like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Vimgrepv /some pattern/ file ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Vimgrepv pattern file ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more info, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :args&#xA;:h :argdo&#xA;:h search()&#xA;:h getqflist()&#xA;:h setqflist()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-12-31T08:06:23.703" LastActivityDate="2019-12-31T08:06:23.703" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22376" PostTypeId="2" ParentId="22374" CreationDate="2019-12-30T22:56:32.507" Score="7" Body="&lt;p&gt;It allows the user to disable a specific plugin.&#xA;See &lt;code&gt;:h use-cpo-save&lt;/code&gt;, and search for &lt;code&gt;NOT LOADING&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;NOT LOADING&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;It's possible that a user doesn't always want to load this plugin.  Or the&#xA;  system administrator has dropped it in the system-wide plugin directory, but a&#xA;  user has his own plugin he wants to use.  Then the user must have a chance to&#xA;  disable loading this specific plugin.  This will make it possible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;6 if exists(&quot;g:loaded_typecorr&quot;)&#xA;7   finish&#xA;8 endif&#xA;9 let g:loaded_typecorr = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This also avoids that when the script is loaded twice it would cause error&#xA;  messages for redefining functions and cause trouble for autocommands that are&#xA;  added twice.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The name is recommended to start with &quot;loaded_&quot; and then the file name of the&#xA;  plugin, literally.  The &quot;g:&quot; is prepended just to avoid mistakes when using&#xA;  the variable in a function (without &quot;g:&quot; it would be a variable local to the&#xA;  function).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Using &quot;finish&quot; stops Vim from reading the rest of the file, it's much quicker&#xA;  than using if-endif around the whole file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It's also useful if you want to use a custom version of a default plugin.&#xA;By placing your custom version in a directory of the runtime path which comes before the one of the default plugin, yours will be sourced first (and set &lt;code&gt;g:loaded_...&lt;/code&gt;); and when the default plugin will be sourced, the guard will prevent its interface from being installed and overwriting yours.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It can also be useful in a file under &lt;code&gt;autoload/&lt;/code&gt;.&#xA;Suppose &lt;code&gt;autoload/someplugin.vim&lt;/code&gt; contains the function &lt;code&gt;someplugin#func()&lt;/code&gt;.&#xA;You call the function, which causes &lt;code&gt;autoload/someplugin.vim&lt;/code&gt; to be sourced.&#xA;Now you call it a second time, but you make a typo:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call someplugin#funx()&#xA;                    ^&#xA;                    ✘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function won't be found and &lt;code&gt;E117&lt;/code&gt; will be raised; but – without a guard – &lt;code&gt;autoload/someplugin.vim&lt;/code&gt; will have been sourced a second time. This can cause an issue if the script tracks some state via a global or script-local variable which is initialized outside a function then updated at runtime; the state will be reset which may lead to all sorts of unexpected behaviors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make sure not to clash with a &lt;code&gt;g:loaded_&lt;/code&gt; variable, you can use the prefix &lt;code&gt;autoloaded_&lt;/code&gt; instead of &lt;code&gt;loaded_&lt;/code&gt; (see &lt;a href=&quot;https://github.com/tpope/vim-fugitive/blob/3bf602b13d86b7aef57fec4a2df29467b61435cb/autoload/fugitive.vim#L4-L7&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;vim-fugitive&lt;/code&gt;&lt;/a&gt; for an example) for files under &lt;code&gt;autoload/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Setting the &lt;code&gt;g:loaded_&lt;/code&gt; variable allows you to inspect whether the plugin has been loaded.&#xA;As an example, I use this info to avoid configuring the plugin when it's temporarily disabled (e.g. with &lt;a href=&quot;https://github.com/lacygoill/config/blob/05245b132a57072d75edd83072a0062185b3044c/.vim/plugin/matchup.vim#L1&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;vim-matchup&lt;/code&gt;&lt;/a&gt; and with &lt;a href=&quot;https://github.com/lacygoill/config/blob/05245b132a57072d75edd83072a0062185b3044c/.vim/after/plugin/sandwich.vim#L1&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;vim-sandwich&lt;/code&gt;&lt;/a&gt;), typically when debugging some issue.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2019-12-31T05:15:28.333" LastActivityDate="2019-12-31T05:15:28.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22377" PostTypeId="1" CreationDate="2019-12-31T02:48:27.670" Score="1" ViewCount="304" Body="&lt;p&gt;When I press and hold &lt;kbd&gt;j&lt;/kbd&gt; or &lt;kbd&gt;k&lt;/kbd&gt;, they are repeated by the OS interface (I presume). Vim seems to scroll on each character produced by the keyboard. This makes the scroll pause shortly right after holding the key down, and then only being repeated at a speed I can not configure for vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like the scrolling to repeat immediately after holding the key down, and I would like to configure the rate at which the &lt;kbd&gt;j&lt;/kbd&gt;/&lt;kbd&gt;k&lt;/kbd&gt; command is executed while the key is being held. So it would be useful to map commands to a key up event, so I could maybe set scrolling on and off when the key is being released.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could you achieve this?&lt;/p&gt;&#xA;" OwnerUserId="17840" LastEditorUserId="10604" LastEditDate="2020-01-01T21:09:10.550" LastActivityDate="2020-01-01T21:09:10.550" Title="How to map commands to key release events" Tags="|key-bindings|scrolling|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22378" PostTypeId="1" AcceptedAnswerId="22379" CreationDate="2019-12-31T03:14:03.880" Score="2" ViewCount="123" Body="&lt;p&gt;As we know, we can set a highlight color while searching a keyword.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if I can set a timer task to clear the highlight color after a few seconds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now, I have to type &lt;code&gt;:noh&amp;lt;CR&amp;gt;&lt;/code&gt; to clear the highlight color. If setting a timer task is possible, I'd like to set a timer task as below:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;searching a keyword&lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;5 seconds later, &lt;code&gt;:noh&amp;lt;CR&amp;gt;&lt;/code&gt; is executed automatically&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="1238" LastEditDate="2020-01-02T01:14:08.237" LastActivityDate="2020-01-02T01:14:08.237" Title="Is it possible to set a timer task in vim7" Tags="|vimscript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22379" PostTypeId="2" ParentId="22378" CreationDate="2019-12-31T07:33:29.867" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;:noh is executed automatically&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Well, that's kind of prohibited.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;:h function-search-undo&lt;/p&gt;&#xA;&lt;p&gt;The last used search pattern and the redo command &amp;quot;.&amp;quot; will not be changed by the function.  This also implies that the effect of |:nohlsearch| is undone when the function returns.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Note that internally all autocommands are functions, so &lt;code&gt;:noh&lt;/code&gt; inside an autocommand won't have any effect either.&lt;/p&gt;&#xA;&lt;p&gt;Therefore, you are more or less confined to &lt;code&gt;feedkeys()&lt;/code&gt; like that&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup autonoh | au!&#xA;    autocmd CursorHold * if v:hlsearch | call feedkeys(&amp;quot;:noh\&amp;lt;CR&amp;gt;&amp;quot;, 'n') | endif&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;(Don't try to make use of &lt;code&gt;timer_start()&lt;/code&gt; even if you have it in Vim7, as for this case you'll certainly also need &lt;code&gt;SafeState&lt;/code&gt;, but it's available in Vim 8.1+ only).&lt;/p&gt;&#xA;&lt;p&gt;Still, that does not feel good to me, so I believe that a mapping (&lt;code&gt;nnoremap &amp;lt;C-L&amp;gt; :noh&amp;lt;CR&amp;gt;&amp;lt;C-L&amp;gt;&lt;/code&gt;, or whatever) should be preferred.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2019-12-31T08:39:52.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22380" PostTypeId="2" ParentId="22372" CreationDate="2019-12-31T08:24:16.033" Score="1" Body="&lt;p&gt;I believe using an external tool is much easier in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's suppose your &lt;code&gt;set grepprg=/usr/bin/grep\ -n&lt;/code&gt; is GNU grep (i.e. it supports &lt;code&gt;grep -L&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set gfm=%f&#xA;:silent grep -L 'pattern' files&#xA;:set gfm&amp;amp;&#xA;:copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does it. See also &lt;code&gt;:h :grep&lt;/code&gt;, &lt;code&gt;:h 'grepprg'&lt;/code&gt; and &lt;code&gt;:h 'grepformat'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do this often, you may want to pack it into a user-command.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2019-12-31T08:30:45.940" LastActivityDate="2019-12-31T08:30:45.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22381" PostTypeId="2" ParentId="22370" CreationDate="2019-12-31T10:04:08.430" Score="0" Body="&lt;p&gt;I am using the same plugin here's my config&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;js syntax folding&#xA;&#xA;augroup javascript_folding&#xA;&#xA;    au!&#xA;&#xA;    au filetype javascript setlocal foldmethod=syntax&#xA;&#xA;augroup END&#xA;&#xA;let g:javascript_conceal_function = &quot;ƒ&quot;&#xA;&#xA;let g:javascript_conceal_null = &quot;ø&quot;&#xA;&#xA;let g:javascript_conceal_this = &quot;@&quot;&#xA;&#xA;let g:javascript_conceal_return = &quot;⇚&quot;&#xA;&#xA;let g:javascript_conceal_undefined = &quot;¿&quot;&#xA;let g:javascript_conceal_NaN = &quot;N&quot;&#xA;let g:javascript_conceal_prototype = &quot;¶&quot;&#xA;let g:javascript_conceal_static = &quot;•&quot;&#xA;let g:javascript_conceal_super = &quot;Ω&quot;&#xA;let g:javascript_conceal_arrow_function = &quot;⇒&quot;&#xA;let g:javascript_conceal_noarg_arrow_function = &quot;&quot;&#xA;let g:javascript_conceal_underscore_arrow_function = &quot;&quot;&#xA;&#xA;set conceallevel =3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26071" LastActivityDate="2019-12-31T10:04:08.430" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22382" PostTypeId="1" AcceptedAnswerId="22383" CreationDate="2019-12-31T13:28:21.797" Score="0" ViewCount="47" Body="&lt;p&gt;I am using Vim 7.4. According to vim's help on persistent undo: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;An undo file is also ignored if its owner differs from the owner of the edited file. &#xA;Set 'verbose' to get a message about that when opening a file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where do I set &lt;code&gt;verbose&lt;/code&gt;? In my vimrc I have the following as my persistent undo-related code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;persistent_undo&quot;)&#xA;  if isdirectory(expand(&quot;~/.vim/temp_dirs/undodir&quot;))&#xA;    verbose set undodir=~/.vim/temp_dirs/undodir&#xA;  else&#xA;    echomsg &quot;ERROR: undodir does not exist or is not writable.&quot;&#xA;  endif&#xA;&#xA;  verbose set undofile&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I edit a file of which I am not the owner, I get no such message.&lt;/p&gt;&#xA;" OwnerUserId="9047" LastEditorUserId="10604" LastEditDate="2020-01-01T21:08:10.357" LastActivityDate="2020-01-01T21:08:10.357" Title="How do I receive an alert message indicating that persistent undo will be ignored?" Tags="|vimrc|undo-redo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22383" PostTypeId="2" ParentId="22382" CreationDate="2019-12-31T15:08:38.207" Score="1" Body="&lt;p&gt;The sentence&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Set 'verbose' to get a message about that when opening a file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Refers to the &lt;em&gt;option&lt;/em&gt; &lt;code&gt;verbose&lt;/code&gt;—you can tell because it's enclosed in single-quotes, and if you place your cursor on it and press &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;]&lt;/kbd&gt;, you jump to the same section as &lt;code&gt;:help 'verbose'&lt;/code&gt; would.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not clear what level of verbosity you would need, but try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set verbose=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then increase from there.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2019-12-31T15:08:38.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22384" PostTypeId="1" CreationDate="2019-12-31T17:17:15.577" Score="2" ViewCount="2467" Body="&lt;p&gt;Using Vim 7.4. My ~/.vimrc file consists &lt;em&gt;only&lt;/em&gt; of the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;filetype off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I run vim with verbose logging level 2 by using the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -V2./file.log .vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...it gives the following error in file.log:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line 5: sourcing &quot;/usr/share/vim/vim74/ftoff.vim&quot;&#xA;Error detected while processing /usr/share/vim/vim74/ftoff.vim:&#xA;line   11:&#xA;E216: No such group or event: filetypedetect *&#xA;finished sourcing /usr/share/vim/vim74/ftoff.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The ftoff.vim file is the following (sans comments):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;did_load_filetypes&quot;)&#xA;  unlet did_load_filetypes&#xA;endif&#xA;&#xA;&quot; Remove all autocommands in the filetypedetect group&#xA;silent! au! filetypedetect *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it appears there is an error in ftoff.vim? If not, is there a better way to set filetype off than the &lt;code&gt;filetype off&lt;/code&gt; command?&lt;/p&gt;&#xA;" OwnerUserId="9047" LastActivityDate="2019-12-31T19:43:32.207" Title="Initial vim startup with small vimrc gives error &quot;No such group or event: filetypedetect&quot;" Tags="|filetype|startup|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22385" PostTypeId="2" ParentId="22384" CreationDate="2019-12-31T17:39:00.657" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;is there a better way to set filetype off than the filetype off command?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;filetype&lt;/code&gt; is off by default in Vim (but note: no vimrc means sourcing &lt;code&gt;defaults.vim&lt;/code&gt; which &lt;strong&gt;does&lt;/strong&gt; enable &lt;code&gt;filetype&lt;/code&gt;). Therefore, you should just remove the 2nd line.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So it appears there is an error in ftoff.vim?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;silent!&lt;/code&gt; stands there to shut up any error if &lt;code&gt;filetypedetect&lt;/code&gt; does not exist (yet). So it should be okay to do &lt;code&gt;filetype off&lt;/code&gt; even if &lt;code&gt;filetype&lt;/code&gt; was never ever &quot;ON&quot; before. You see something only because of &lt;code&gt;verbose&lt;/code&gt; option, which normally should be off.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2019-12-31T17:39:00.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22386" PostTypeId="1" AcceptedAnswerId="22389" CreationDate="2019-12-31T17:47:24.147" Score="3" ViewCount="150" Body="&lt;p&gt;Is there some way to repeat something like &lt;code&gt;cit&lt;/code&gt; and be left in insert mode instead of automatically repeating the previously entered text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, suppose I have the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;th&amp;gt;one&amp;lt;/th&amp;gt;&#xA;&amp;lt;th&amp;gt;one&amp;lt;/th&amp;gt;&#xA;&amp;lt;th&amp;gt;one&amp;lt;/th&amp;gt;&#xA;&amp;lt;th&amp;gt;one&amp;lt;/th&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to individually replace the text inside the last three tags so I end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;th&amp;gt;one&amp;lt;/th&amp;gt;&#xA;&amp;lt;th&amp;gt;two&amp;lt;/th&amp;gt;&#xA;&amp;lt;th&amp;gt;three&amp;lt;/th&amp;gt;&#xA;&amp;lt;th&amp;gt;four&amp;lt;/th&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I start by going to the second line and type &lt;code&gt;cittwo&amp;lt;esc&amp;gt;&lt;/code&gt;, it'll replace &quot;one&quot; with &quot;two&quot;.  If I then go to the next line and press &lt;code&gt;.&lt;/code&gt;, it'll repeat the last command and again replace the &quot;one&quot; with &quot;two&quot;.  Instead, I was hoping for a way to just delete the contents of the tag and be left in insert mode so I can type whatever I needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I could make a macro that does this, but for some reason I feel like there is a more basic way of doing it that is currently escaping me.&lt;/p&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2019-12-31T20:01:47.763" Title="Repeat last &quot;change inside text object&quot; command without the inserted text" Tags="|cursor-motions|repeated-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22387" PostTypeId="2" ParentId="130" CreationDate="2019-12-31T19:39:03.850" Score="1" Body="&lt;p&gt;This is an extension on work in:&#xA;&lt;a href=&quot;https://vi.stackexchange.com/a/8130/26305&quot;&gt;https://vi.stackexchange.com/a/8130/26305&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Uses replace to handle existing comments not in specific indentation, instead of vim key commands and allows a dictionary of filetypes which can be easily toggled with 'set filetype=X'&#xA;&lt;br&gt;&lt;br&gt;Paste the following, declare your missing filetype in dictionary (default comment char is '#') and use Ctrl-m to toggle comment on one or multiple lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let commentTextMap = {&#xA;        \'c': '\/\/',&#xA;        \'h': '\/\/',&#xA;        \'cpp': '\/\/',&#xA;        \'java': '\/\/',&#xA;        \'php': '\/\/',&#xA;        \'javascript': '\/\/',&#xA;        \'groovy': '\/\/',&#xA;        \'python': '#',&#xA;        \'sh': '#',&#xA;        \'vim': '&quot;',&#xA;        \'make': '#',&#xA;        \'conf': '#',&#xA;\}&#xA;noremap &amp;lt;silent&amp;gt; &amp;lt;expr&amp;gt; &amp;lt;C-m&amp;gt; ((synIDattr(synID(line(&quot;.&quot;), col(&quot;.&quot;), 0), &quot;name&quot;) =~ 'comment\c') ?&#xA;        \ ':&amp;lt;S-Right&amp;gt;:s/^\([ \t]*\)' . get(commentTextMap, &amp;amp;filetype, '#') . '/\1/&amp;lt;CR&amp;gt;' :&#xA;        \ ':&amp;lt;S-Right&amp;gt;:s/^/' . get(commentTextMap, &amp;amp;filetype, '#') . '/&amp;lt;CR&amp;gt;:nohl&amp;lt;CR&amp;gt;'&#xA;        \ ) . ':nohl&amp;lt;CR&amp;gt;:call histdel(&quot;/&quot;, -1)&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26305" LastEditorUserId="26305" LastEditDate="2020-05-24T15:04:02.640" LastActivityDate="2020-05-24T15:04:02.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22388" PostTypeId="2" ParentId="22384" CreationDate="2019-12-31T19:43:32.207" Score="2" Body="&lt;p&gt;The fact that you are getting this message on your verbose log file is expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Vim source code has &lt;a href=&quot;https://github.com/vim/vim/blob/v7.4/src/message.c#L625,L628&quot; rel=&quot;nofollow noreferrer&quot;&gt;an explicit comment about that&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * When using &quot;:silent! cmd&quot; ignore error messages.&#xA; * But do write it to the redirection file.&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I linked to the code in Vim 7.4, but Vim 8.2 still has the same exact snippet and exhibits the same behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume this behavior exists because you'd enable verbosity and a redirect file when you're debugging an issue. In those circumstances, logging errors that would otherwise be silented can be quite helpful. Also, there's little harm in printing those messages, since they're not interrupting the user, but simply going to the verbose redirect file.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So it appears there is an error in ftoff.vim? If not, is there a better way to set filetype off than the &lt;code&gt;filetype off&lt;/code&gt; command?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I wouldn't call it a bug, since &lt;em&gt;you're asking for debugging information&lt;/em&gt; and you're simply getting what you asked for. You're likely to get that from many more Vimscript snippets that are using &lt;code&gt;:silent&lt;/code&gt; and will have their silented errors logged if you run with verbose logging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, the implementation in &lt;code&gt;ftoff.vim&lt;/code&gt; will not print any errors (even to the redirected verbose file) if the &lt;code&gt;filetypedetect&lt;/code&gt; augroup was ever created (in other words, if &lt;code&gt;filetype&lt;/code&gt; was ever enabled.) Note that it doesn't really remove the augroup, it simply clears it, so disabling filetype repeatedly after ever enabling it will not really print errors (to the redirect file.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;could&lt;/em&gt; argue it would have been best to check whether the augroup actually exists before trying to clear it, but arguably using &lt;code&gt;:silent!&lt;/code&gt; is a much shorter way to accomplish that and it doesn't really present significant drawbacks (perhaps having the error hit the verbose redirect log being a &lt;em&gt;minor annoyance&lt;/em&gt;, at most.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-31T19:43:32.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22389" PostTypeId="2" ParentId="22386" CreationDate="2019-12-31T20:01:47.763" Score="2" Body="&lt;p&gt;There isn't really a native command to repeat a change &lt;em&gt;without&lt;/em&gt; including the inserted text as part of the repeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You mentioned using a macro, but recording it (using the &lt;code&gt;q&lt;/code&gt; command) can be tricky, since you want to end it inside insert mode. It turns out you can actually do that using &lt;code&gt;qacit&amp;lt;C-O&amp;gt;q&lt;/code&gt; to record only &lt;code&gt;cit&lt;/code&gt; in &lt;code&gt;@a&lt;/code&gt;, which you can use to repeatedly call it. You can also use an assignment directly to create the macro.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a = 'cit'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not sure if the macro really gets you anything, since you're still typing two characters &lt;code&gt;@a&lt;/code&gt; instead of three &lt;code&gt;cit&lt;/code&gt;. Granted, after the first usage, you can simply hit the same key twice &lt;code&gt;@@&lt;/code&gt;, but that's not a huge win...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps creating a mapping temporarily would be better:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap , cit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can even map &lt;code&gt;.&lt;/code&gt; so it &quot;feels&quot; like you're repeating a command &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you're done, remove it with &lt;code&gt;:nunmap ,&lt;/code&gt; (or &lt;code&gt;.&lt;/code&gt;, or whatever you decide to use.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One advantage of using a mapping (or a macro) is that you can incorporate the search for the next location to replace, whether you simply use a &lt;code&gt;n&lt;/code&gt; command or if you use a text object more aware of HTML tags to find the location. In that case, you'll be gaining more than a couple keystrokes by defining a macro or mapping.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2019-12-31T20:01:47.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22390" PostTypeId="1" CreationDate="2019-12-31T20:37:58.477" Score="5" ViewCount="39" Body="&lt;p&gt;Neovim makes directories in my home folder (presumably to store swapfiles, etc.) of the form &lt;code&gt;nvimzOvQcg&lt;/code&gt;, &lt;code&gt;nvim098eqo&lt;/code&gt;, &lt;code&gt;nvimUyUGZ8&lt;/code&gt;, etc.&#xA;Upon exit, the contents of these directories are cleaned up but the directories themselves are not removed.&#xA;This occurs even if I remove all of my rc files and plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone experienced this before/have a solution?&lt;/p&gt;&#xA;" OwnerUserId="26306" LastActivityDate="2019-12-31T20:37:58.477" Title="Neovim makes spurious directories and doesn't clean them up on exit" Tags="|neovim|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22391" PostTypeId="1" CreationDate="2020-01-01T04:41:50.483" Score="2" ViewCount="128" Body="&lt;p&gt;If I have this vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;nnoremap &amp;lt;C-m&amp;gt; ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try to open a file from the quickfix window by pressing enter nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I comment out the last line, so the vimrc is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&quot; nnoremap &amp;lt;C-m&amp;gt; ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the quickfix window works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that those two lines are the &lt;em&gt;entire&lt;/em&gt; vimrc file. No plugins are being loaded either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've had the above mapping in my vimrc for over a decade and have always had strange issues with the quickfix window. I finally figured out what's causing it but I'm still stumped, what's going on here?&lt;/p&gt;&#xA;" OwnerUserId="26310" LastActivityDate="2020-01-01T13:21:02.833" Title="Why does this binding break the quickfix window?" Tags="|vimrc|quickfix|" AnswerCount="1" CommentCount="2" ClosedDate="2020-01-09T11:09:50.620" ContentLicense="CC BY-SA 4.0" />
  <row Id="22393" PostTypeId="1" CreationDate="2020-01-01T12:43:20.503" Score="5" ViewCount="3523" Body="&lt;p&gt;I found out that a plugin I really like doesn't support the plugin manager I like, So the question is, can I use multiple plugin managers at the same time with vim? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, I think I can use another plugin manager just for that plugin. Please correct me if I am wrong. I fairly new to Vim.&lt;/p&gt;&#xA;" OwnerUserId="26314" LastActivityDate="2020-01-01T17:45:41.503" Title="Multiple plugin managers" Tags="|plugin-system|plugin-coc|" AnswerCount="1" CommentCount="5" ClosedDate="2020-01-02T04:46:16.010" ContentLicense="CC BY-SA 4.0" />
  <row Id="22394" PostTypeId="2" ParentId="22391" CreationDate="2020-01-01T13:21:02.833" Score="2" Body="&lt;p&gt;I figured this out, and decided to just remove the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's happening because (at least in my environment, using vim in a terminal over SSH) there's no distinction between &lt;code&gt;&amp;lt;C-m&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, they're one and the same to vim. If I remap &lt;code&gt;&amp;lt;C-m&amp;gt;&lt;/code&gt; in normal mode, I'm also remapping &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in normal mode. I don't tend to press enter in normal mode so I didn't notice, except in the quickfix window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could modify the mapping to not apply in the quickfix window as suggested in the comments, but in this case I just removed the mapping, as it seems like an all around bad idea.&lt;/p&gt;&#xA;" OwnerUserId="26310" LastActivityDate="2020-01-01T13:21:02.833" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22395" PostTypeId="1" CreationDate="2020-01-01T16:45:41.547" Score="3" ViewCount="68" Body="&lt;p&gt;Using &lt;code&gt;:h wildignore&lt;/code&gt;, I can ignore certain types of files or certain folders when searching through them to open one of them. But that also means those files and directories will be ignored when I try to insert their filepath with &lt;code&gt;:h i_CTRL-X_CTRL-F&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can ignore, say, all &lt;code&gt;jpg&lt;/code&gt; files when trying to open them using &lt;code&gt;:edit&lt;/code&gt; but not ignore them when trying to insert their filepath using &lt;code&gt;:h i_CTRL-X_CTRL-F&lt;/code&gt; in a file?&lt;/p&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="13728" LastEditDate="2020-01-02T16:50:46.737" LastActivityDate="2020-09-28T20:01:20.157" Title="Ignore a filetype when opening but not when using insert-mode popup-menu" Tags="|ins-completion|" AnswerCount="1" CommentCount="3" ClosedDate="2022-09-26T15:37:53.403" ContentLicense="CC BY-SA 4.0" />
  <row Id="22396" PostTypeId="2" ParentId="22393" CreationDate="2020-01-01T17:23:57.937" Score="2" Body="&lt;p&gt;Plug-in managers are largely interoperable in Vim, all modern plug-in managers work by updating &lt;code&gt;'runtimepath'&lt;/code&gt; to include the root of the plug-in in the list of paths, which is how &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pathogen&lt;/a&gt; works (you could call Pathogen the &quot;grandfather&quot; of plug-in managers.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your specific case, you are trying to install &lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;coc.nvim&lt;/a&gt; using &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vundle&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you reported in &lt;a href=&quot;https://github.com/neoclide/coc.nvim/issues/1210&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue #1210&lt;/a&gt;, coc.nvim complains that the engine is missing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;$ vim src/java/GetSystemProperties.java &#xA;[coc.nvim] javascript file not found, please compile the code or use release branch.&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is likely because you're missing the release branch, or the post-update hook from the &lt;a href=&quot;https://github.com/neoclide/coc.nvim/blob/master/Readme.md#quick-start&quot; rel=&quot;nofollow noreferrer&quot;&gt;installation instructions&lt;/a&gt;, for vim-plug users:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;&quot; Use release branch (Recommend)&#xA;Plug 'neoclide/coc.nvim', &lt;b&gt;{'branch': 'release'}&lt;/b&gt;&#xA;&#xA;&quot; Or build from source code by use yarn: https://yarnpkg.com&#xA;Plug 'neoclide/coc.nvim', &lt;b&gt;{'do': 'yarn install --frozen-lockfile'}&lt;/b&gt;&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It turns out Vundle doesn't support either option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could emulate both with Vundle:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;To use the &quot;release&quot; branch, you could go into the plug-in directory and manually &lt;code&gt;git checkout&lt;/code&gt; the &lt;code&gt;release&lt;/code&gt; branch.&lt;/li&gt;&#xA;&lt;li&gt;To run the post-update hook, you could go into the plug-in directory and manually run the required &lt;code&gt;yarn install --frozen-lockfile&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, it's quite possible that you'll have to manually fix those again whenever you update the plug-in, which might become quite of a hassle. You &lt;em&gt;could&lt;/em&gt; freeze the plug-in version using &lt;code&gt;{&quot;pinned&quot;: 1}&lt;/code&gt; so Vundle doesn't update it, but that pretty much defeats much of the purpose of using a plug-in manager...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your particular case, my recommendation is that you &lt;strong&gt;upgrade from Vundle to vim-plug&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the word &quot;upgrade&quot; here, rather than &quot;migrate&quot;, since you could actually consider vim-plug to be a successor of Vundle. Vundle stopped being maintained many years ago and was superceded by other plug-in managers. There's really no reason to be using Vundle nowadays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim-plug uses the same model as Vundle (so if Pathogen is the &quot;grandfather&quot;, Vundle is the &quot;father&quot;.) Its configuration in your vimrc is about the same (main difference is using the &lt;code&gt;Plug&lt;/code&gt; command rather than &lt;code&gt;Plugin&lt;/code&gt;, and &lt;code&gt;plug#begin&lt;/code&gt;/&lt;code&gt;plug#end&lt;/code&gt; rather than &lt;code&gt;vundle#begin&lt;/code&gt;/&lt;code&gt;vundle#end&lt;/code&gt;) and supports a similar set of commands (again, with slightly different names, &lt;code&gt;PlugUpdate&lt;/code&gt; rather than &lt;code&gt;VundleUpdate&lt;/code&gt; or &lt;code&gt;PluginUpdate&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's quite probable that you could migrate to vim-plug while keeping the same plug-in directory and not having to touch it or any of the plug-ins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just follow the other installation instructions for vim-plug (which amounts to downloading a single &lt;code&gt;plug.vim&lt;/code&gt; file into your autoload directory) and remove the references to &lt;code&gt;Vundle.vim&lt;/code&gt;, rename the commands in vimrc and you're essentially done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do upgrade to vim-plug, you'll get full support for the coc.nvim setup, while not missing out on anything you've been getting from your current plug-in manager.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-01-01T17:45:41.503" LastActivityDate="2020-01-01T17:45:41.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22397" PostTypeId="2" ParentId="2462" CreationDate="2020-01-01T18:22:26.540" Score="8" Body="&lt;p&gt;As of &lt;a href=&quot;https://github.com/vim/vim/commit/8b530c1ff91f07cf6b0289a536992b7dfbc86598&quot; rel=&quot;nofollow noreferrer&quot;&gt;October 2019&lt;/a&gt;, we have &lt;a href=&quot;https://vimhelp.org/motion.txt.html#gM&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;gM&lt;/code&gt;&lt;/a&gt;, which moves the cursor to the middle of the line. This requires Vim 8.1.2231 or later.&lt;/p&gt;&#xA;" OwnerUserId="22844" LastEditorUserId="21251" LastEditDate="2021-07-11T16:29:02.357" LastActivityDate="2021-07-11T16:29:02.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22398" PostTypeId="1" AcceptedAnswerId="22414" CreationDate="2020-01-01T18:25:02.563" Score="3" ViewCount="2817" Body="&lt;p&gt;I would like to disable or hide Lightline (i.e. vim's statusline) when my cursor is in Nerdtree, while keeping it activated for other buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I mean: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://framapic.org/CaRviW01Eb9Y/OFmRKWj4qMLo.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lightline's developper says it is not possible with Lightline itself : &#xA;&lt;a href=&quot;https://github.com/itchyny/lightline.vim/issues/193&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue 193&lt;/a&gt;, &lt;a href=&quot;https://github.com/itchyny/lightline.vim/issues/76&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue 76&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I tried &lt;code&gt;setlocal statusline=%#Normal#&lt;/code&gt; when I &lt;code&gt;BufEnter&lt;/code&gt; nerdtree filetype, as suggested &lt;a href=&quot;https://stackoverflow.com/questions/24466037/hide-lightline-for-minibufexplorer&quot;&gt;here&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetype_nerdtree&#xA;    autocmd!&#xA;    autocmd BufEnter,FileType nerdtree setlocal statusline=%#Normal#&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... which seems to work only when I &lt;em&gt;toggle&lt;/em&gt; Nerdtree (&lt;code&gt;:NERDTreeToggle&lt;/code&gt;). As soon I move my cursor to another buffer, Lightline fills vim's statusline up again with whatever I put in my &lt;code&gt;g:lightline&lt;/code&gt; variable (in both Nerdreee and other buffers). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use neovim 0.3.8.&lt;/p&gt;&#xA;" OwnerUserId="26181" LastEditorUserId="26181" LastEditDate="2020-01-01T20:52:16.793" LastActivityDate="2020-01-04T04:54:59.413" Title="Disable Lightline on Nerdtree" Tags="|neovim|statusline|plugin-nerdtree|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22399" PostTypeId="2" ParentId="18195" CreationDate="2020-01-01T21:04:51.970" Score="1" Body="&lt;p&gt;From &lt;a href=&quot;https://vi.stackexchange.com/questions/18195/need-to-run-pluginstall-on-each-open#comment31342_18195&quot;&gt;Hotschke in the comments&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Please read &lt;a href=&quot;https://vimhelp.appspot.com/starting.txt.html#load-plugins&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help load-plugins&lt;/code&gt;&lt;/a&gt;: In step (4) basically &lt;code&gt;:runtime! plugin/**/*.vim&lt;/code&gt; happens which is before your gvimrc is sourced (step (8)) and &lt;code&gt;runtimepath&lt;/code&gt; has been changed by vim-plug. You can remove the error by appending to your gvimrc &lt;code&gt;runtime! plugin/**/*.vim&lt;/code&gt;. However, I recommend to use vimrc and stick to the given source order by vim itself&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And &lt;a href=&quot;https://vi.stackexchange.com/questions/18195/need-to-run-pluginstall-on-each-open#comment31343_18195&quot;&gt;OP's follow-up&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It turned out putting plug-related stuff to .vimrc solved the issue&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-01-01T21:04:51.970" CommentCount="0" CommunityOwnedDate="2020-01-01T21:04:51.970" ContentLicense="CC BY-SA 4.0" />
  <row Id="22400" PostTypeId="1" AcceptedAnswerId="22401" CreationDate="2020-01-01T21:46:13.080" Score="3" ViewCount="1764" Body="&lt;p&gt;I like using vim to edit csv files.&#xA;But I often have to resort to localc when doing actual maths on them.&#xA;Is there a way to use Math inside a vim Macro? Basicly adding 2 cells together and outputting them to a new third one?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;7,6,(13)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23073" LastActivityDate="2021-07-05T20:25:59.340" Title="How can I do calculations with vim Macros?" Tags="|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22401" PostTypeId="2" ParentId="22400" CreationDate="2020-01-02T04:53:08.150" Score="11" Body="&lt;p&gt;Yes, you can perform arithmetic expressions in Vim by using the &lt;a href=&quot;https://vimhelp.org/change.txt.html#quote%3D&quot; rel=&quot;noreferrer&quot;&gt;expression register&lt;/a&gt;, which you can access from insert mode using &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-R&quot; rel=&quot;noreferrer&quot;&gt;CTRL-R&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another alternative is to use &lt;a href=&quot;https://vimhelp.org/change.txt.html#sub-replace-expression&quot; rel=&quot;noreferrer&quot;&gt;expressions in the replacement of a &lt;code&gt;:substitute&lt;/code&gt; command&lt;/a&gt;, which can be helpful when performing batch operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your specific case, assuming you have a line with two columns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;7,6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you want to add a third with the sum:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;7,6,13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I'm assuming you don't want the parens around the result, since then it's still a valid numeric field in CSV.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So one way to do it using a macro would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa^&quot;xywf,l&quot;yywA,&amp;lt;C-R&amp;gt;=@x+@y&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;+q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that &lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt; actually means pressing CTRL-R, &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; means pressing Enter and &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; means pressing Escape.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Breaking this down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qa&lt;/code&gt;: Start recording a macro, save it on register &lt;code&gt;a&lt;/code&gt;, so you can later use the &lt;code&gt;@a&lt;/code&gt; command to repeat it.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;^&lt;/code&gt;: Move to the first non-blank character of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;xyw&lt;/code&gt;: Yank a word into register &lt;code&gt;x&lt;/code&gt;, that should be your first number.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;f,l&lt;/code&gt;: Forward to the comma and then move one more character right. This should get you to the start of the second number.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;yyw&lt;/code&gt;: Yank a word into register &lt;code&gt;y&lt;/code&gt;, which will now contain your second number.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;A&lt;/code&gt;: Append at the end of the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;,&lt;/code&gt;: Insert a literal comma.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-R&amp;gt;=&lt;/code&gt;: Insert contents of register &lt;code&gt;=&lt;/code&gt;, but the expression register is special in that you'll get prompted for an expression to insert.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@x+@y&amp;lt;CR&amp;gt;&lt;/code&gt;: That's the expression to evaluate. &lt;code&gt;@x&lt;/code&gt; and &lt;code&gt;@y&lt;/code&gt; are accessing the &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; &lt;em&gt;registers&lt;/em&gt;, since that's where the two numbers were stored. The final &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; ends the expression, which gets evaluated and its result gets inserted, and you get back to insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;: Leave insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;+&lt;/code&gt;: Move to the start of the next line, which might come in handy if you want to repeat this macro to process multiple lines.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt;: Stop recording.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After recording this macro, you can apply it to further lines with &lt;code&gt;@a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to use this sequence is with &lt;code&gt;:g/.../normal!&lt;/code&gt;, in which case you can add a &lt;code&gt;:execute&lt;/code&gt; to be able to escape the special keystrokes such as CTRL-R:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\d/execute &quot;normal! ^\&quot;xywf,l\&quot;yywA,\&amp;lt;C-R&amp;gt;=@x+@y\&amp;lt;CR&amp;gt;\&amp;lt;Esc&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(In this case, all characters are typed literally, this one can be used with copy &amp;amp; paste. Vim will know how to interpret &lt;code&gt;&quot;\&amp;lt;C-R&amp;gt;&quot;&lt;/code&gt; as equivalent to a CTRL-R keystroke.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command above will execute the same explained sequence on all lines starting with a digit (assuming a CSV would have a first line with the headers, that wouldn't match it.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned at the start, another possibility is to use &lt;code&gt;:s&lt;/code&gt; with an expression in the result. For &lt;code&gt;:s&lt;/code&gt;, you can use the &lt;code&gt;submatch()&lt;/code&gt; function to access groups matched in the pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\(.*\),\(.*\)/\=submatch(0).','.(submatch(1)+submatch(2))/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, starting the replacement with a &lt;code&gt;\=&lt;/code&gt; indicates an expression is used and should be evaluated for every match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;submatch(0)&lt;/code&gt; part repeats the whole matched string (to preserve the original columns), then the string concatenation operator &lt;code&gt;.&lt;/code&gt; is used to add a comma and the result of the sum of the numbers in the two matched groups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that Vim will convert the expressions to numbers and back to strings as needed, that's expected. (In effect, that's why the string concatenation operator &lt;code&gt;.&lt;/code&gt; is distinct from the arithmetic add operator &lt;code&gt;+&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While these operations are somewhat low-level, they demonstrate some of the possibilities for manipulating numbers in Vim.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-02T04:53:08.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22402" PostTypeId="2" ParentId="22398" CreationDate="2020-01-02T07:51:08.350" Score="3" Body="&lt;p&gt;Of course, your attempt won't work, because Lightline forcefully updates status line content on many auto events. That's quite obvious from its code and was clearly stated by the author in the issues you've quoted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only solution is to exclude some specific buffers from such update, but, again, as the author said he is not going to do so for several reasons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, you have either (1) fork Lightline and add such functionality yourself, or (2) drop it and build a status line of your own, preferably without any tricky event-driven auto-updates, so Vim can manage everything by himself (using expression re-evaluation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I prefer (2) even though Vim is not perfect and things may go out of sync on rare occasions.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-01-02T07:51:08.350" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22403" PostTypeId="2" ParentId="22400" CreationDate="2020-01-02T09:18:06.170" Score="7" Body="&lt;p&gt;When I see the not so short vim solution &lt;code&gt;:s/\(.*\),\(.*\)/\=submatch(0).','.(submatch(1)+submatch(2))/&lt;/code&gt; following statement from &lt;a href=&quot;https://vimways.org/2019/vim-and-the-shell/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vimways.org/2019/vim-and-the-shell/&lt;/a&gt; comes to my mind:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;“Vim is not meant to be a universal answer to all problems.”&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There are also dedicated tools you might consider using. A list can be found here:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/dbohdan/structured-text-tools#dsv&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/dbohdan/structured-text-tools#dsv&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Pre-installed on most systems is &lt;code&gt;awk&lt;/code&gt;. Assuming following file and you want to add a new column based on combining existing columns by a mathematical expression, e.g. &lt;code&gt;+&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;data.csv&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1,2&#xA;4,18&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;&lt;a href=&quot;https://www.gnu.org/software/gawk/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Awk&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;awk -F',' 'BEGIN{OFS=&amp;quot;,&amp;quot;}{print $0, $1+$2}' data.csv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;with reordering&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;awk -F',' 'BEGIN{OFS=&amp;quot;,&amp;quot;}{print $2, $1, $1+$2}' data.csv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;&lt;a href=&quot;https://miller.readthedocs.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Miller&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Miller is like awk, sed, cut, join, and sort for name-indexed data such as CSV, TSV, and tabular JSON.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Doing the same as awk would look like:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ mlr -N --csv put '$3=$1+$2' data.csv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;We need to tell Miller that we want again csv format with &lt;code&gt;--csv&lt;/code&gt; and the input does not have a headerline with &lt;code&gt;-N&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As quoted Miller is designed for data with name-indexed data:&lt;/p&gt;&#xA;&lt;p&gt;named_cols.csv&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;col1,col2&#xA;1,2&#xA;4,18&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ mlr --csv put '$sum = $col1 + $col2' named_cols.csv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This expression does not rely on the order of your columns and in contrast to an awk equivalent expression does not need to handle the header line separately. IMHO working with named columns is more readable and less error prone.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2021-07-05T20:25:59.340" LastActivityDate="2021-07-05T20:25:59.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22404" PostTypeId="1" AcceptedAnswerId="22405" CreationDate="2020-01-02T09:52:16.333" Score="2" ViewCount="1285" Body="&lt;p&gt;I'm using vim for writing LaTeX documents. I also have &lt;a href=&quot;http://vim-latex.sourceforge.net&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-latex&lt;/a&gt; installed. While I'm writing my documents &lt;em&gt;in the editor&lt;/em&gt;, I get ligatures for that piece of text which is meaningful for the LaTeX language. For example, when I type an &lt;em&gt;en-dash&lt;/em&gt; as defined by the language (&lt;code&gt;--&lt;/code&gt;), I get a continuous dash line which is the size of two consecutive dashes, instead. I don't find this feature helpful and sometimes even confusing. So I want to see the document as it is while I'm using the editor. Is there any option to set this feature off?&lt;/p&gt;&#xA;" OwnerUserId="23287" LastEditorUserId="1292" LastEditDate="2020-01-02T23:03:47.687" LastActivityDate="2020-01-02T23:03:47.687" Title="How to disable ligatures &quot;inside the editor&quot; while using vim for latex documents?" Tags="|filetype-tex|plugin-vim-latex|conceal|" AnswerCount="1" CommentCount="1" ClosedDate="2020-01-03T12:44:46.543" ContentLicense="CC BY-SA 4.0" />
  <row Id="22405" PostTypeId="2" ParentId="22404" CreationDate="2020-01-02T10:02:46.820" Score="4" Body="&lt;p&gt;This is a part of standard filetype plugin, see &lt;code&gt;:h tex.vim&lt;/code&gt; for a complete info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That particular feature is controlled by &lt;code&gt;:h g:tex_conceal&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it's enough to add &lt;code&gt;let g:tex_conceal = ''&lt;/code&gt; to your vimrc (or to disable only ligatures and accents: &lt;code&gt;let g:tex_conceal = 'dmgs'&lt;/code&gt;, i.e. no 'a' in tex_conceal's value).&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-01-02T10:02:46.820" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22406" PostTypeId="2" ParentId="22395" CreationDate="2020-01-02T18:00:31.477" Score="1" Body="&lt;p&gt;One solution I have is to disable &lt;code&gt;'wildignore'&lt;/code&gt; while in Insert mode. I haven't found any untoward side-effects, but it would have been nice to have a pre-complete/post-complete pair of events (&lt;code&gt;CompleteDone&lt;/code&gt; is almost pre-complete, but &lt;code&gt;CompleteChanged&lt;/code&gt; is not pre).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup NoWildignoreInsert&#xA;  au!&#xA;  au InsertEnter *&#xA;        \ if !exists('b:old_wildignore') |&#xA;        \   let b:old_wildignore=&amp;amp;wildignore |&#xA;        \   set wildignore&amp;amp; |&#xA;        \ endif&#xA;  au InsertLeave *&#xA;        \ if exists('b:old_wildignore') |&#xA;        \   let &amp;amp;wildignore=b:old_wildignore |&#xA;        \   unlet b:old_wildignore |&#xA;        \ endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-01-02T18:00:31.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22407" PostTypeId="2" ParentId="22373" CreationDate="2020-01-02T18:06:06.587" Score="2" Body="&lt;p&gt;Vim 8.1.2250 does not ship with filetype detection for solidity. (One can confirm with &lt;code&gt;:edit $VIMRUNTIME/filetype.vim&lt;/code&gt; and then &lt;code&gt;:global /sol/&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ALE has Solidity linters, but they require the filetype to be set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest solution is to create &lt;code&gt;~/.vim/ftdetect/solidity.vim&lt;/code&gt; and add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.sol setfiletype solidity&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, &lt;a href=&quot;https://github.com/tomlion/vim-solidity&quot; rel=&quot;nofollow noreferrer&quot;&gt;this plugin&lt;/a&gt; provides filetype detection (and possibly more).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After any of these methods, ALE's linters should work.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-01-04T17:14:23.667" LastActivityDate="2020-01-04T17:14:23.667" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22408" PostTypeId="1" AcceptedAnswerId="22427" CreationDate="2020-01-02T20:32:07.507" Score="3" ViewCount="1905" Body="&lt;p&gt;When I place the cursor on the parenthesis of the below line, the two parenthesis get highlighted in a cyan color. When I place the cursor on the curly braces, however, no highlighting happens.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// cmake example&#xA;set(CMAKE_CXX_FLAGS &quot;${CMAKE_CXX_FLAGS} -std=c++17&quot;)&#xA;   ^                  ^               ^            ^&#xA;   |                  |               |            |&#xA;   |                  +------+--------+            |&#xA;   |                         |                     |&#xA;   |                         +--- no highlighting  |&#xA;   |                                               |&#xA;   +-------------------------+---------------------+&#xA;                             |&#xA;                             +--- expected highlighting works&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the set may need to be inside a sub-block to fail (i.e inside an &lt;code&gt;if(SOMETHING) ... endif(SOMETHING)&lt;/code&gt; block for example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is another example with C++ code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// C++ example&#xA;a = &quot;this (string) here&quot;;   // this one fails, it's inside a string&#xA;a = string(&quot;here&quot;);         // here the highlight works&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As we can see the parenthesis are outside of a string and the curly braces are inside the string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the same problem in comments and various other types of string-like regions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get this highlighting to work in strings and comments like it was in older versions of Vim?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here are a couple of screenshots. The vertical bar is the cursor placed just before the parenthesis or curly braces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uJGvn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uJGvn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4el5n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4el5n.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note 1: Yes. The highlighting works just fine with curly braces outside of a string, and also square brackets, &lt;code&gt;&amp;lt;,&amp;gt;&lt;/code&gt;, etc.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note 2: The &lt;code&gt;%&lt;/code&gt; key works as expected, so I can find the matching character, but that's not as practical as the highlighting.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So far, this has shown up in nearly all the files formats I used (C++, Go, JavaScript, Ruby, CMakeLists.txt, etc.) However, at least the parenthesis and curly braces do work fine in a shell script (&lt;code&gt;sh&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the matched pairs, I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matchpairs=(:),{:},[:],&amp;lt;:&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I added the &lt;code&gt;&amp;lt;:&amp;gt;&lt;/code&gt; in my settings, but the problem occurred before I added those and whether I specify &lt;code&gt;matchit&lt;/code&gt; or not:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set matchpairs+=&amp;lt;:&amp;gt;&#xA;packadd! matchit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Further, I tried to comment out all of my entries in my &lt;code&gt;~/.vimrc&lt;/code&gt; and the results are the same.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On my clean install, I see the same issues. I tried to add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matchadd! matchit&#xA;let b:match_skip = &quot;0&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to my &lt;code&gt;~/.vimrc&lt;/code&gt; and that had no effect on the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just in case, here is the &lt;code&gt;/usr/share/vim/vim80/debian.vim&lt;/code&gt; file that gets loaded through the &lt;code&gt;/etc/vim/vim.vim&lt;/code&gt; (I removed the full line comments to make it shorter):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after&#xA;set nocompatible    &quot; Use Vim defaults instead of 100% vi compatibility&#xA;set backspace=indent,eol,start  &quot; more powerful backspacing&#xA;set history=50      &quot; keep 50 lines of command line history&#xA;set ruler       &quot; show the cursor position all the time&#xA;set nomodeline&#xA;set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc&#xA;if &amp;amp;term =~ &quot;xterm-debian&quot; || &amp;amp;term =~ &quot;xterm-xfree86&quot;&#xA;  set t_Co=16&#xA;  set t_Sf=[3%dm&#xA;  set t_Sb=[4%dm&#xA;endif&#xA;if has(&quot;autocmd&quot;)&#xA;  if has('gui')&#xA;    function! &amp;lt;SID&amp;gt;MapExists(name, modes)&#xA;      for mode in split(a:modes, '\zs')&#xA;        if !empty(maparg(a:name, mode))&#xA;          return 1&#xA;        endif&#xA;      endfor&#xA;      return 0&#xA;    endfunction&#xA;    autocmd GUIEnter * if !&amp;lt;SID&amp;gt;MapExists(&quot;&amp;lt;S-Insert&amp;gt;&quot;, &quot;nvso&quot;) | execute &quot;map &amp;lt;S-Insert&amp;gt; &amp;lt;MiddleMouse&amp;gt;&quot; | endif&#xA;    autocmd GUIEnter * if !&amp;lt;SID&amp;gt;MapExists(&quot;&amp;lt;S-Insert&amp;gt;&quot;, &quot;ic&quot;) | execute &quot;map! &amp;lt;S-Insert&amp;gt; &amp;lt;MiddleMouse&amp;gt;&quot; | endif&#xA;  endif&#xA;endif&#xA;if filereadable(&quot;/etc/papersize&quot;)&#xA;  let s:papersize = matchstr(readfile('/etc/papersize', '', 1), '\p*')&#xA;  if strlen(s:papersize)&#xA;    exe &quot;set printoptions+=paper:&quot; . s:papersize&#xA;  endif&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See related question: &lt;a href=&quot;https://vi.stackexchange.com/questions/22203&quot;&gt;MatchIt not matching anymore if parenthesis, brackets, etc. are between quotes or in comments?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9276" LastEditorUserId="9276" LastEditDate="2020-01-04T16:38:15.533" LastActivityDate="2020-01-04T16:38:15.533" Title="Matching parenthesis and such not being highlighted in strings since VIM 8.0 on Ubuntu 18.04, how do I get this highlighting back?" Tags="|highlight|vim8|plugin-matchit|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="22409" PostTypeId="1" AcceptedAnswerId="22411" CreationDate="2020-01-02T23:34:45.057" Score="4" ViewCount="285" Body="&lt;p&gt;I can open a file with vim on the command line like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim fnord.txt +50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it will take me to the 50th line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do the same thing with &lt;code&gt;:split&lt;/code&gt;? So far I haven't been able to figure out how to do it. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:split fnord.txt +50&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:split fnord.txt ++50&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:split fnord.txt:50&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;None of these work, and I didn't see anything searching for &lt;code&gt;line&lt;/code&gt; within &lt;code&gt;:help split&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5574" LastActivityDate="2020-01-03T16:40:24.060" Title="Can I :split and go directly to a line?" Tags="|split|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22410" PostTypeId="2" ParentId="22409" CreationDate="2020-01-03T00:42:35.720" Score="1" Body="&lt;p&gt;&lt;code&gt;:split file | :50&lt;/code&gt; should work, from command line.&#xA;The separator separate commands. A number typed as command  jumps to that line number. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="343" LastEditDate="2020-01-03T16:40:24.060" LastActivityDate="2020-01-03T16:40:24.060" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22411" PostTypeId="2" ParentId="22409" CreationDate="2020-01-03T02:38:45.310" Score="8" Body="&lt;p&gt;You are so close:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:split +50 fnord.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All commands in vim that create new buffer has prototype:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmd [++opt] [+cmd] [file]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All commands in vim that write buffer to your disk has prototype:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmd [++opt] [file]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/editing.txt.html#%2B%2Bopt&quot; rel=&quot;noreferrer&quot;&gt;:h ++opt&lt;/a&gt; is only used for special options that should be set before read or write a buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e ++fileformat=dos file&#xA;:e ++encoding=latin1 file&#xA;:e ++binary file&#xA;:e ++nobinary file&#xA;:e ++bad=?&#xA;:w ++enc=latin1 newfile&#xA;read ++edit file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the last &lt;code&gt;read ++edit file&lt;/code&gt; change &lt;code&gt;'fileformat'&lt;/code&gt; and &lt;code&gt;'fileencoding'&lt;/code&gt; to values the same as &lt;code&gt;:e file&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/editing.txt.html#%2Bcmd&quot; rel=&quot;noreferrer&quot;&gt;:h +cmd&lt;/a&gt; can be used to do any ex command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e +50 file&#xA;:e +/main file&#xA;:e +echo\ &quot;blah\ blah&quot; file&#xA;:e +setlocal\ textwidth=120 file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2020-01-03T02:38:45.310" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22412" PostTypeId="1" AcceptedAnswerId="22413" CreationDate="2020-01-03T03:17:47.753" Score="0" ViewCount="818" Body="&lt;p&gt;In vimL, how to get a string from cursor to end of &lt;code&gt;&amp;lt;cWORD&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know &lt;code&gt;expand('&amp;lt;cWORD&amp;gt;'&lt;/code&gt;, but don't known how to keep only right part of cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;given text &lt;code&gt;pre abc-xyz.xxx:123 post&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with cursor at &lt;code&gt;-&lt;/code&gt;, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;return string &lt;code&gt;-xyz.xxx:123&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2020-01-03T11:20:52.950" Title="get string from cursor to end of &lt;CWORD&gt;" Tags="|vimscript|functions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22413" PostTypeId="2" ParentId="22412" CreationDate="2020-01-03T04:52:26.350" Score="4" Body="&lt;p&gt;One option is to take the current line, then the substring starting at the current position, split it into multiple words and take the first one. Or, in Vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let word = split(getline('.')[col('.')-1:])[0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One alternative is to use a normal mode command such as &lt;code&gt;yW&lt;/code&gt; and then access the contents of the default register (or, better, use a named register.) You can save and restore the contents of the register, so that accessing their contents after the call to the function will still return the original value.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetWord()&#xA;    let save_reg = getreg('x')&#xA;    let save_type = getregtype('x')&#xA;    normal! &quot;xyW&#xA;    let word = @x&#xA;    call setreg('x', save_reg, save_type)&#xA;    return word&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-03T04:52:26.350" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22414" PostTypeId="2" ParentId="22398" CreationDate="2020-01-03T08:54:01.747" Score="5" Body="&lt;p&gt;It's a hack, but you could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup filetype_nerdtree&#xA;    au!&#xA;    au FileType nerdtree call s:disable_lightline_on_nerdtree()&#xA;    au WinEnter,BufWinEnter,TabEnter * call s:disable_lightline_on_nerdtree()&#xA;augroup END&#xA;&#xA;fu s:disable_lightline_on_nerdtree() abort&#xA;    let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -&amp;gt; getbufvar(winbufnr(v), '&amp;amp;ft')}), 'nerdtree') + 1&#xA;    call timer_start(0, {-&amp;gt; nerdtree_winnr &amp;amp;&amp;amp; setwinvar(nerdtree_winnr, '&amp;amp;stl', '%#Normal#')})&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm still trying to understand what your snippet do because I am new to vim scripting. But I guess it basically sets window's statusline to%#Normal# whenever the corresponding buffer is equal to 'nerdtree', on WinLeave and TabEnter events, does it ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, that's what it does. Although, now I think that &lt;code&gt;WinEnter&lt;/code&gt;, &lt;code&gt;BufWinEnter&lt;/code&gt; and &lt;code&gt;TabEnter&lt;/code&gt; is a better set of events.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This displays the number of the last window in the current tab page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo winnr('$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This displays the numbers of all the windows in the current tab page, as a list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo range(1, winnr('$'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This displays the filetypes of the buffers displayed in all the windows of the current tab page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                   ┌ iterates over the numbers of the windows&#xA;                                   │              ┌ evaluates to the number of the buffer displayed in the window whose number is v&#xA;                                   │              ├─────────┐&#xA;:echo map(range(1, winnr('$')), {_,v -&amp;gt; getbufvar(winbufnr(v), '&amp;amp;ft')})&#xA;                                        ├───────────────────────────┘&#xA;                                        └ evaluates to the filetype of the buffer whose number is winbufnr(v)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This displays the number of the window displaying a nerdtree buffer (or &lt;code&gt;0&lt;/code&gt; if there is none):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo index(map(range(1, winnr('$')), {_,v -&amp;gt; getbufvar(winbufnr(v), '&amp;amp;ft')}), 'nerdtree') + 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, this sets the local value of the &lt;code&gt;'statusline'&lt;/code&gt; option bound to the window displaying the nerdtree buffer to &lt;code&gt;%#Normal#&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call setwinvar(index(map(range(1, winnr('$')), {_,v -&amp;gt; getbufvar(winbufnr(v), '&amp;amp;ft')}), 'nerdtree') + 1, '&amp;amp;stl', '%#Normal#')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you could execute this last function call directly from an autocmd, but there would still be 2 issues:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the function would be called even when there is no nerdtree buffer displayed in the tab page, which would disable the status line in the current window&lt;/li&gt;&#xA;&lt;li&gt;Lightline would still update the status line contents of the nerdtree window &lt;em&gt;after&lt;/em&gt; your function call, undoing your reset&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To fix &lt;code&gt;1.&lt;/code&gt;, you need a guard which makes sure that a window is currently displaying a nerdtree buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -&amp;gt; getbufvar(winbufnr(v), '&amp;amp;ft')}), 'nerdtree') + 1&#xA;if nerdtree_winnr&#xA;    call setwinvar(nerdtree_winnr, '&amp;amp;stl', '%#Normal#')&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To fix &lt;code&gt;2.&lt;/code&gt;, you need to delay the function call until Lightline has finished updating all the status lines.&#xA;You can do so with a timer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call timer_start(0, {-&amp;gt; nerdtree_winnr &amp;amp;&amp;amp; setwinvar(nerdtree_winnr, '&amp;amp;stl', '%#Normal#')})&#xA;     ^^^^^^^^^^^        ^^^^^^^^^^^^^^^^^&#xA;     timer              guard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can make the nesting of function calls inside &lt;code&gt;index()&lt;/code&gt; a little more readable, using the method call operator &lt;code&gt;-&amp;gt;&lt;/code&gt; (introduced in &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.1803&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;8.1.1803&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let nerdtree_winnr = winnr('$')-&amp;gt;range()-&amp;gt;map({_,v -&amp;gt; winbufnr(v+1)-&amp;gt;getbufvar('&amp;amp;ft')})-&amp;gt;index('nerdtree') + 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It works very well, I don't see any flickering.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I can definitely see some flickering. If – in the future – you do too, try to replace the timer with a one-shot autocmd listening to the &lt;code&gt;SafeState&lt;/code&gt; event (introduced in &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.2044&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;8.1.2044&lt;/code&gt;&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -&amp;gt; getbufvar(winbufnr(v), '&amp;amp;ft')}), 'nerdtree') + 1&#xA;if nerdtree_winnr&#xA;    exe 'au SafeState * ++once call setwinvar('..nerdtree_winnr..', &quot;&amp;amp;stl&quot;, &quot;%#Normal#&quot;)'&#xA;    &quot;                   ^^^^^^&#xA;    &quot;                   fire only once&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;During my limited tests, it seemed to fix the issue.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If one day you decide to use your own status line, you could use this template to achieve a similar effect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype on&#xA;set ls=2&#xA;fu s:snr() abort&#xA;    return matchstr(expand('&amp;lt;sfile&amp;gt;'), '.*\zs&amp;lt;SNR&amp;gt;\d\+_')&#xA;endfu&#xA;let s:snr = get(s:, 'snr', s:snr())&#xA;let &amp;amp;stl = '%!'..s:snr..'stl()'&#xA;fu s:stl() abort&#xA;    return getbufvar(winbufnr(g:statusline_winid), '&amp;amp;ft', '') is# 'nerdtree'&#xA;        \ ? '%#Normal#'&#xA;        \ : '...'&#xA;    &quot;        ^^^&#xA;    &quot;        here, write the contents of your status line for filetypes other than nerdtree&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It requires the patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.1372&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;8.1.1372&lt;/code&gt;&lt;/a&gt; to be able to inspect &lt;code&gt;g:statusline_winid&lt;/code&gt;.&#xA;The latter is a temporary global variable which contains the ID of the window to which the status line currently being drawn belongs.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that neither the method call operator &lt;code&gt;-&amp;gt;&lt;/code&gt;, nor the &lt;code&gt;SafeState&lt;/code&gt; event, nor the &lt;code&gt;g:statusline_winid&lt;/code&gt; variable are available in Nvim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you know C, you could try to &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-Vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;port the relevant Vim patches&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more info, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h index()&#xA;:h map()&#xA;:h range()&#xA;:h winnr()&#xA;:h getbufvar()&#xA;:h winbufnr()&#xA;:h setwinvar()&#xA;:h timer_start()&#xA;:h lambda&#xA;:h SafeState&#xA;:h autocmd-once&#xA;:h g:statusline_winid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-01-04T04:54:59.413" LastActivityDate="2020-01-04T04:54:59.413" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22415" PostTypeId="2" ParentId="22412" CreationDate="2020-01-03T11:20:52.950" Score="4" Body="&lt;p&gt;Method 1.1&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; from start of cWORD to cursor&#xA;echo matchstr(getline('.'), '\S*\%'. col('.') .'c.')&#xA;&quot; from cursor to end of cWORD&#xA;echo matchstr(getline('.'), '\%'. col('.') .'c.\S*')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2020-01-03T11:20:52.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22416" PostTypeId="1" AcceptedAnswerId="22421" CreationDate="2020-01-03T12:33:59.630" Score="6" ViewCount="5141" Body="&lt;p&gt;Is there a shortcut for going to the trailing curly brace in a long piece of code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a few editors if I double click the &lt;code&gt;{&lt;/code&gt; it takes me to the trailing brace &lt;code&gt;}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While writing large pieces of code I seem to forget to add this at times and  also it would make debugging easy if such an implementation is available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the shortcut for searching words, take the cursor on the word and press &lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;8&lt;/kbd&gt;. Is there any similar shortcut for finding ending braces?&lt;/p&gt;&#xA;" OwnerUserId="26339" LastEditorUserId="1238" LastEditDate="2020-01-04T04:58:08.807" LastActivityDate="2020-01-04T04:58:08.807" Title="Shortcut for going to the trailing curly brace &quot;}&quot;" Tags="|key-bindings|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22417" PostTypeId="1" CreationDate="2020-01-03T13:22:36.580" Score="1" ViewCount="862" Body="&lt;p&gt;I am really new to vim and have been trying to use it more over the past months. Issue is I cannot get the plugins to work, I have followed the steps on vim plug github and some other sites.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am on windows and when I use the &lt;code&gt;:set path&lt;/code&gt; in vim itself it shows the vim directory but appending to it is a folder called &lt;code&gt;vimfiles&lt;/code&gt;, is this just a general name for all associated files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added the plug lines to my &lt;code&gt;_vimrc&lt;/code&gt; but when I run &lt;code&gt;:PlugInstall&lt;/code&gt; it throws a error saying it's not a command. Is there any up to date info on windows installations ? This feels like a easy issue but I cannot figure it out and without syntax higlighting or anything it is kind of rough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to know is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;where to put files for vim plug?&lt;/li&gt;&#xA;&lt;li&gt;why vim plug is not loading?&lt;/li&gt;&#xA;&lt;li&gt;Why do I have 3 auto load folders spread over separate folders?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="26340" LastEditorUserId="1841" LastEditDate="2020-01-03T14:54:57.620" LastActivityDate="2020-02-13T19:23:29.047" Title="Plugin management on Windows?" Tags="|microsoft-windows|plugin-system|plugin-vim-plug|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22418" PostTypeId="2" ParentId="22417" CreationDate="2020-01-03T13:30:10.063" Score="-1" Body="&lt;p&gt;&lt;code&gt;:PluginInstall&lt;/code&gt; is the install command for Vundle. If it does not work Vundle is not installed correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/VundleVim/Vundle.vim#quick-start&quot; rel=&quot;nofollow noreferrer&quot;&gt;Installation Instructions&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2689" LastActivityDate="2020-01-03T13:30:10.063" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22419" PostTypeId="2" ParentId="22409" CreationDate="2020-01-03T13:35:13.203" Score="0" Body="&lt;p&gt;&lt;code&gt;vim [file] +50 +split&lt;/code&gt; to split horizontally&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim [file] +50 +vs&lt;/code&gt;to split vertically&lt;/p&gt;&#xA;" OwnerUserId="2689" LastActivityDate="2020-01-03T13:35:13.203" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22420" PostTypeId="2" ParentId="22417" CreationDate="2020-01-03T13:50:47.470" Score="1" Body="&lt;p&gt;I cleaned out the installation and pulled the zip of vim-plug. Extracted the files into the autoload folder in vim82. Before I used the powershell solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that I made a custom plugin folder and gave it read/write permission.&#xA;Now it seems to work. Unsure what the issue was but these are the things that I changed. Also I should have mentioned that I am using vim-plug.&lt;/p&gt;&#xA;" OwnerUserId="26340" LastEditorUserId="26340" LastEditDate="2020-02-13T19:23:29.047" LastActivityDate="2020-02-13T19:23:29.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22421" PostTypeId="2" ParentId="22416" CreationDate="2020-01-03T14:57:11.370" Score="13" Body="&lt;p&gt;Are you looking for &lt;a href=&quot;http://vimhelp.appspot.com/motion.txt.html#%25&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h %&lt;/code&gt;&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%           Find the next item in this line after or under the&#xA;            cursor and jump to its match. |inclusive| motion.&#xA;            Items can be:&#xA;            ([{}])      parenthesis or (curly/square) brackets&#xA;                    (this can be changed with the&#xA;                    'matchpairs' option)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;%&lt;/kbd&gt; in normal mode when the cursor is before or on an item like a parenthesis will jump to the matching item.&lt;/p&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2020-01-03T14:57:11.370" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22422" PostTypeId="2" ParentId="6364" CreationDate="2020-01-03T18:25:41.703" Score="0" Body="&lt;p&gt;To manually add &lt;code&gt;other.snippets&lt;/code&gt; to current buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UltiSnipsAddFiletypes other&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Say you want add &lt;code&gt;pygame.snippets&lt;/code&gt; to some python files, besides &lt;code&gt;python.snippets&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ftplugin/python.vim&#xA;UltiSnipsAddFiletypes python.pygame&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2020-01-03T18:25:41.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22423" PostTypeId="1" AcceptedAnswerId="22424" CreationDate="2020-01-03T19:45:30.150" Score="2" ViewCount="1221" Body="&lt;p&gt;Vim/Neovim (this is an issue in both as far as I can tell) does not seem to like files with '@' in the name, even though I have &lt;code&gt;isfname&lt;/code&gt; is set to the default, which is &lt;code&gt;@,48-57,/,.,-,_,+,,,#,$,%,~,=&lt;/code&gt;, which makes me think that this all should work. Steps to reproduce:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;foo&quot; &amp;gt; /tmp/bar@file&#xA;echo &quot;/tmp/bar@file&quot; | vim -u NONE -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;gf&lt;/code&gt; command will not go to the file, saying &lt;code&gt;E447: Can't find file &quot;/tmp/bar&quot; in path&lt;/code&gt;. Am I missing something here?&lt;/p&gt;&#xA;" OwnerUserId="26346" LastEditorUserId="26346" LastEditDate="2020-01-03T19:55:55.330" LastActivityDate="2020-01-03T20:04:45.713" Title="'@' in file names and 'gf' (go to file)" Tags="|command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22424" PostTypeId="2" ParentId="22423" CreationDate="2020-01-03T20:04:45.713" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Am I missing something here?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, as written in &lt;code&gt;:h 'isfname'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If the character is '@', all characters where isalpha() returns TRUE&#xA;  are included.  Normally these are the characters a to z and A to Z,&#xA;  plus accented characters.  To include '@' itself use &quot;@-@&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;@&lt;/code&gt; in &lt;code&gt;isfname&lt;/code&gt;, &lt;code&gt;iskeyword&lt;/code&gt; etc. actually means &quot;all alphas&quot;, not literal &quot;@&quot;. And you still need to add &lt;code&gt;set isfname+=@-@&lt;/code&gt; to your vimrc.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-01-03T20:04:45.713" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22425" PostTypeId="2" ParentId="22416" CreationDate="2020-01-04T00:17:25.193" Score="2" Body="&lt;p&gt;If your &lt;code&gt;{}&lt;/code&gt; is on first column:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;]]&lt;/code&gt; goto next &lt;code&gt;{&lt;/code&gt; in first column, it's the open &lt;code&gt;{&lt;/code&gt; of next function.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;][&lt;/code&gt; goto next &lt;code&gt;}&lt;/code&gt; in first column, it's the close &lt;code&gt;}&lt;/code&gt; of current function.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[[&lt;/code&gt; goto previous &lt;code&gt;{&lt;/code&gt; in first column, it's the open &lt;code&gt;{&lt;/code&gt; of current function.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[]&lt;/code&gt; goto previous &lt;code&gt;}&lt;/code&gt; in first column, it's the close &lt;code&gt;}&lt;/code&gt; of previous function.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It doesn't care how many nested &lt;code&gt;{}&lt;/code&gt; there are, it only looks for &lt;code&gt;{}&lt;/code&gt; in first column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;]}&lt;/code&gt; and &lt;code&gt;[{&lt;/code&gt; to goto &lt;code&gt;}&lt;/code&gt; and &lt;code&gt;{&lt;/code&gt; of current &lt;code&gt;{}&lt;/code&gt; block.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2020-01-04T00:17:25.193" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22426" PostTypeId="2" ParentId="16248" CreationDate="2020-01-04T03:40:28.867" Score="4" Body="&lt;p&gt;The &lt;code&gt;winnr&lt;/code&gt; function was &lt;a href=&quot;https://github.com/vim/vim/commit/46ad288b9b2a6eb0430cf802ff5ce68a58629897&quot; rel=&quot;nofollow noreferrer&quot;&gt;updated&lt;/a&gt; to take movement arguments as patch 8.1.1140 on April 8, 2019. If your version of Vim has this updated function, &lt;code&gt;:echo has('patch-8.1.1140')&lt;/code&gt; will output &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The movement argument can be &lt;code&gt;'h'&lt;/code&gt;, &lt;code&gt;'j'&lt;/code&gt;, &lt;code&gt;'k'&lt;/code&gt;, or  &lt;code&gt;'l'&lt;/code&gt;, optionally preceeded by a count. For example, &lt;code&gt;winnr('h')&lt;/code&gt; will return the window number of the window to the left of the current window. If there is no window to the left, the current window's window number will be returned. This can be used to check whether the current window has a neighbor to the left, where &lt;code&gt;winnr() !=# winnr('h')&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="26249" LastEditorUserId="26249" LastEditDate="2020-01-04T03:54:10.887" LastActivityDate="2020-01-04T03:54:10.887" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22427" PostTypeId="2" ParentId="22408" CreationDate="2020-01-04T09:00:09.967" Score="4" Body="&lt;p&gt;I did a little investigation. At first I could not reproduce, but I think I have found the problem (part of it was, you did not mention what version you were using :/)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a local machine with an Ubuntu 18.04.03 LTS installed. In it, I could reproduce the problem when using the system vim (I usually compile my own), that is version &lt;em&gt;8.0.1453&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I traced the problem to the matchparen plugin. The matchparen plugin tries to find a matching parenthesis to the one where the cursor is while skipping special syntax groups like &lt;code&gt;string&lt;/code&gt; or &lt;code&gt;comment&lt;/code&gt;, &lt;em&gt;if the cursor is not also in such a group&lt;/em&gt;. If the cursor is in such a group, it will not skip any match, by setting the special &lt;code&gt;s_skip&lt;/code&gt; variable to &lt;code&gt;0&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, there was a patch &lt;a href=&quot;http://github.com/vim/vim/commit/48570488f17e397183ea7&quot; rel=&quot;nofollow noreferrer&quot;&gt;8.0.1239&lt;/a&gt;, that allows to use partials, funcrefs and strings as skip-expressions. At the same time, using a number as a skip expression would not work anymore and would silently return &lt;strong&gt;no-match&lt;/strong&gt;. So that unfortunately regressed the default matchparen plugin, that comes with vim. (I think later on, &lt;em&gt;searchpair&lt;/em&gt; and related functions did actually throw an error in that case.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem was noticed and finally fixed by patch &lt;a href=&quot;https://github.com/vim/vim/commit/b7a5ab112ab2267c54acdb6a326642afcd797bc4&quot; rel=&quot;nofollow noreferrer&quot;&gt;v8.1.0115&lt;/a&gt; which makes sure, that the matchparen plugin uses a &lt;em&gt;string&lt;/em&gt; for the skip expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What to do?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, copy the plugin that comes from the distribution to your local runtime directory (create the ~/.vim/plugin folder if it does not exist yet):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cp /usr/share/vim/vim80/plugin/matchparen.vim ~/.vim/plugin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now edit that file and apply this patch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim&#xA;index 4f68fd87b..0fa5c4d22 100644&#xA;--- a/runtime/plugin/matchparen.vim&#xA;+++ b/runtime/plugin/matchparen.vim&#xA;@@ -114,7 +114,7 @@ function! s:Highlight_Matching_Pair()&#xA;   &quot; within those syntax types (i.e., not skip).  Otherwise, the cursor is&#xA;   &quot; outside of the syntax types and s_skip should keep its value so we skip any&#xA;   &quot; matching pair inside the syntax types.&#xA;-  execute 'if' s_skip '| let s_skip = 0 | endif'&#xA;+  execute 'if' s_skip '| let s_skip = &quot;0&quot; | endif'&#xA;&#xA;   &quot; Limit the search to lines visible in the window.&#xA;   let stoplinebottom = line('w$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;e.g. change line 117 and from &lt;code&gt;... = 0&lt;/code&gt; to &lt;code&gt;... = &quot;0&quot;&lt;/code&gt; (notice the double quotes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then restart Vim and it should work again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(An alternative would be to install a Vim newer than 8.1.0115, which comes with updated runtime files.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="18609" LastEditDate="2020-01-04T09:03:55.937" LastActivityDate="2020-01-04T09:03:55.937" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22428" PostTypeId="2" ParentId="22160" CreationDate="2020-01-04T14:51:04.697" Score="1" Body="&lt;p&gt;Use &lt;code&gt;_u&lt;/code&gt;  to open last buffer,&lt;code&gt;_U&lt;/code&gt; to view last buffers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be improved.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:lastWindows= []&#xA;let g:lastWinName = &quot;&quot;&#xA;&#xA;function! SaveLastWindow()&#xA;  if &amp;amp;bt == '' || &amp;amp;bt == 'help' || &amp;amp;ft == 'netranger' &quot;|| &amp;amp;bt == 'nofile'&#xA;    let cur= expand( '&amp;lt;afile&amp;gt;' )&#xA;&#xA;    if cur == g:lastWinName || cur ==&quot;&quot;&#xA;      return&#xA;    endif &#xA;&#xA;    call add(g:lastWindows,cur) &#xA;&#xA;    let g:lastWinName=cur&#xA;  endif&#xA;endfunction &#xA;&#xA;augroup bufclosetrack&#xA;  au!&#xA;  autocmd BufWinLeave * call SaveLastWindow()&#xA;augroup END&#xA;&#xA;function! LastWindow()&#xA;  exe &quot;split &quot; . g:lastWinName&#xA;endfunction&#xA;&#xA;command -nargs=0 LastWindow call LastWindow()&#xA;&#xA;nmap _u :LastWindow&amp;lt;CR&amp;gt;&#xA;nmap _U :call fzf#vim#cust_history(g:lastWindows)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in autoload/fzf/vim.vim add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! fzf#vim#cust_history(src,...)&#xA;  return s:fzf('history-files', {&#xA;  \ 'source':  a:src,&#xA;  \ 'options': ['-m', '--header-lines', !empty(expand('%')), '--prompt', 'Hist&amp;gt; ']&#xA;  \}, a:000)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="10604" LastEditDate="2020-01-04T15:24:30.280" LastActivityDate="2020-01-04T15:24:30.280" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22429" PostTypeId="1" AcceptedAnswerId="22431" CreationDate="2020-01-05T04:17:18.640" Score="2" ViewCount="1059" Body="&lt;p&gt;The string that I have is this &lt;code&gt;aaabbbb&lt;/code&gt;.  &lt;code&gt;aaa&lt;/code&gt; must become red, &lt;code&gt;bbbb&lt;/code&gt; must become blue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; here xB is not matched&#xA;syntax match xA /^a\+/&#xA;syntax match xB /^a\+\zsb\+/&#xA;highlight xA ctermfg=red&#xA;highlight xB ctermfg=blue&#xA;&#xA;&quot; here xB is matched&#xA;syntax match xB /^a\+\zsb\+/&#xA;highlight xB ctermfg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it fails.  1st one only matches &lt;code&gt;aaa&lt;/code&gt; into red, and misses &lt;code&gt;bbbb&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 2nd one matches &lt;code&gt;bbbb&lt;/code&gt; into blue, but obviously leaves &lt;code&gt;aaa&lt;/code&gt; uncolored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea what's going on?  &lt;/p&gt;&#xA;" OwnerUserId="14744" LastActivityDate="2020-01-06T15:07:44.267" Title="Syntax highlighting with multiple matches with `\zs`" Tags="|syntax-highlighting|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22430" PostTypeId="2" ParentId="22429" CreationDate="2020-01-05T04:57:26.250" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/58160050/4400820&quot;&gt;I ran into this once.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The short answer is even though &lt;code&gt;\zs&lt;/code&gt; causes the match to start later, it « consumes » the &lt;code&gt;a&lt;/code&gt;s before it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The workaround is to use lookahead/behind, I believe. I’m not a master of vim’s syntax for that though; see &lt;code&gt;:help pattern&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you just need &lt;code&gt;/\(^a\+\)\@&amp;lt;=b\+/&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-01-05T15:13:29.693" LastActivityDate="2020-01-05T15:13:29.693" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22431" PostTypeId="2" ParentId="22429" CreationDate="2020-01-05T05:45:26.513" Score="3" Body="&lt;p&gt;This won't work because Vim won't scan the same text twice trying to match a different regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though the &lt;code&gt;\zs&lt;/code&gt; makes the resulting match only include the &lt;code&gt;b&lt;/code&gt;s, Vim needs to see all the &lt;code&gt;a&lt;/code&gt;s to be able to match that regex and it won't do so if it already matched the &lt;code&gt;a&lt;/code&gt;s to the other pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do a small experiment to see this behavior, by doing a simple search for the two regexes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^a\+\|^a\+\zsb\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll see that the search will match the &lt;code&gt;a&lt;/code&gt;s, but not the &lt;code&gt;b&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(On the other hand, replacing the &lt;code&gt;a&lt;/code&gt; in the first regex with a different character matches both lines starting with that other character &lt;em&gt;and&lt;/em&gt; lines with the &lt;code&gt;b&lt;/code&gt;s following the &lt;code&gt;a&lt;/code&gt;s, which proves the regex otherwise works as expected.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To work around this issue, use a zero-width lookup match, using &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%40%3C%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\@&amp;lt;=&lt;/code&gt;&lt;/a&gt; to match the series of &lt;code&gt;a&lt;/code&gt;s at the start of the line preceding the &lt;code&gt;b&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use this match instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match xB /\(^a\+\)\@&amp;lt;=b\+/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll notice this pattern also works correctly in the search experiment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^a\+\|\(^a\+\)\@&amp;lt;=b\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason why this works is that Vim will first search for &lt;code&gt;b&lt;/code&gt;s and then look behind to see if that other part of the regex also matches. So the pattern gets anchored on &lt;code&gt;b&lt;/code&gt; rather than &lt;code&gt;a&lt;/code&gt; and doesn't suffer from the issue of trying to start a match on a region that already matched another expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that zero-width lookups such as this one can have performance side effects, if the regex is too generic Vim might end up going pretty far trying to look for the start of a match. See &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%40%3C%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\@&amp;lt;=&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-05T05:45:26.513" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22432" PostTypeId="2" ParentId="21439" CreationDate="2020-01-05T11:14:07.780" Score="5" Body="&lt;h3&gt;&lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-dispatch&lt;/a&gt; &lt;code&gt;:Make&lt;/code&gt; instead of &lt;code&gt;:make&lt;/code&gt;&lt;/h3&gt;&#xA;&lt;p&gt;You &lt;em&gt;cannot&lt;/em&gt; run the built-in command &lt;code&gt;:make&lt;/code&gt; asynchronously in Vim8 or NeoVim.&lt;/p&gt;&#xA;&lt;p&gt;You have to take the value of &lt;code&gt;'makeprg'&lt;/code&gt; and insert it into vim8 &lt;code&gt;job_start()&lt;/code&gt; or neovim &lt;code&gt;jobstart()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I personally like the convenience of plugins which take care of vim8/neovim differences, parsing the result and inserting it into the quickfix/location list, ...&lt;/p&gt;&#xA;&lt;p&gt;As often the case for vim, there are many plugins you can choose from:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-dispatch&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/neomake/neomake&quot; rel=&quot;nofollow noreferrer&quot;&gt;neomake&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;asyncrun&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/yegappan/asyncmake&quot; rel=&quot;nofollow noreferrer&quot;&gt;asyncmake&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/pgdouyon/vim-accio&quot; rel=&quot;nofollow noreferrer&quot;&gt;Accio&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/stevearc/overseer.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;overseer.nvim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I would recommend to try first &lt;code&gt;vim-dispatch&lt;/code&gt; by tpope. It provides&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;familiar command names &lt;code&gt;:Make&lt;/code&gt;, &lt;code&gt;:Copen&lt;/code&gt;, ...&lt;/li&gt;&#xA;&lt;li&gt;a convenience command &lt;code&gt;:Dispatch&lt;/code&gt; to activate compiler/linter and run it in one step.&lt;/li&gt;&#xA;&lt;li&gt;IMHO nice default maps &lt;code&gt; `m&lt;/code&gt; for &lt;code&gt;:Make&lt;/code&gt; and &lt;code&gt; `&amp;lt;Space&amp;gt;&lt;/code&gt; for &lt;code&gt;:Dispatch&amp;lt;Space&amp;gt;&lt;/code&gt; and more&lt;/li&gt;&#xA;&lt;li&gt;limited feature set&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Some people like to use different plugins for following reason&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;limitations of &lt;code&gt;'errorformat'&lt;/code&gt; for parsing of compiler/linter results&lt;/li&gt;&#xA;&lt;li&gt;vim-dispatch does not open the quickfix list automatically in case of warnings and errors (issue &lt;a href=&quot;https://github.com/tpope/vim-dispatch/issues/226&quot; rel=&quot;nofollow noreferrer&quot;&gt;#226&lt;/a&gt;) (see e.g. neomake)&lt;/li&gt;&#xA;&lt;li&gt;handling of several linter/static code analyzer/...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;BTW good companion plugins are&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-projectionist&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-projectionist&lt;/a&gt;: e.g. helpful for out-of-source builds when using &lt;a href=&quot;https://cmake.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;CMake&lt;/a&gt; (similar for &lt;a href=&quot;https://mesonbuild.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;meson&lt;/a&gt;). You can define heuristics to detect out-of-source builds. I often put the out-of source build next to &lt;code&gt;&amp;lt;project&amp;gt;/CMakeLists.txt&lt;/code&gt; into &lt;code&gt;&amp;lt;project&amp;gt;/_builds/debug&lt;/code&gt; which means I set in my vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  let g:projectionist_heuristics = {&#xA;        \ &amp;quot;CMakeLists.txt&amp;amp;builds/debug/Makefile&amp;quot;: {&#xA;        \   &amp;quot;*&amp;quot;: {&#xA;        \            &amp;quot;make&amp;quot;: &amp;quot;make -C {project}/builds/debug -j8&amp;quot;,&#xA;        \            &amp;quot;compiler&amp;quot;: &amp;quot;gcc&amp;quot;,&#xA;        \     }&#xA;        \   }&#xA;        \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;vim-projectionist&lt;/code&gt; can detect your build directory automatically and allows you to press &lt;code&gt; `m&lt;/code&gt; to compile in this directory.&#xA;You have to modify this to your personal preference. You can also define several heuristics.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-unimpaired&lt;/a&gt;: nice additional non-clashing maps &lt;code&gt;]q&lt;/code&gt;, &lt;code&gt;[q&lt;/code&gt;, &lt;code&gt;]Q&lt;/code&gt;, &lt;code&gt;[Q&lt;/code&gt; to navigate the quickfix list.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Furthermore, &lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-fugitive&lt;/a&gt; uses &lt;code&gt;:Make&lt;/code&gt; if available for &lt;code&gt;git push/pull&lt;/code&gt; which means it runs them async as well.&#xA;You can also use other plugins for this. For example, define &lt;code&gt;:Make&lt;/code&gt; using neomake:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;command! -bang -nargs=* -complete=file Make NeomakeProject &amp;lt;args&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you have added the above line, vim-fugitive runs git push/pull without blocking the editor but uses neomake and not vim-dispatch.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="6748" LastEditDate="2022-10-29T07:16:41.953" LastActivityDate="2022-10-29T07:16:41.953" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22433" PostTypeId="1" AcceptedAnswerId="22434" CreationDate="2020-01-05T14:29:20.680" Score="1" ViewCount="293" Body="&lt;p&gt;Following &lt;a href=&quot;https://vi.stackexchange.com/questions/22429/syntax-highlighting-with-multiple-matches-with-zs/22431#22431&quot;&gt;my previous question&lt;/a&gt;, I have the same string &lt;code&gt;aaabbbb&lt;/code&gt; that I am colorizing in the same way, except with the addition that I am now also trying to conceal the &lt;code&gt;a&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the best that I got so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; here xB is not matched&#xA;syntax match xA /^a\+/ conceal transparent&#xA;syntax match xB /\(^a\+\)\@&amp;lt;=b\+/&#xA;highlight xA ctermfg=red&#xA;highlight xB ctermfg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the problem is that, while the &lt;code&gt;a&lt;/code&gt;s get concealed as expected, they don't get colorized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, if I remove the concealment, colorization works fine.  I.e. this colorizes just fine (but obviously doesn't conceal the &lt;code&gt;a&lt;/code&gt;s):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; here xB is not matched&#xA;syntax match xA /^a\+/&#xA;syntax match xB /\(^a\+\)\@&amp;lt;=b\+/&#xA;highlight xA ctermfg=red&#xA;highlight xB ctermfg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Q1:&lt;/strong&gt; How to colorize and conceal at the same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Q2:&lt;/strong&gt; I feel that I am missing some fundamental knowledge about how &lt;code&gt;vim&lt;/code&gt; applies match/highlight.  What is going on here?  Is the concealment causing vim to not see the text during the syntax highlighting stage? I mean, it's the same match statement.  So vim saw the text and applied the concealment, but somehow thought to not apply the color to it.  What's am I missing in the internal vim workflow?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Update:&lt;/em&gt; This seems to work, but I am not sure why.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; here xB is not matched&#xA;syntax match xA /^a\+/&#xA;syntax match xB /\(^a\+\)\@&amp;lt;=b\+/&#xA;highlight xA ctermfg=red&#xA;highlight xB ctermfg=blue&#xA;syntax match xAConceal /^a\+/ conceal transparent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14744" LastEditorUserId="14744" LastEditDate="2020-01-05T14:34:37.397" LastActivityDate="2020-01-05T15:32:56.780" Title="Concealment causes color highlighting to not apply" Tags="|syntax-highlighting|conceal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22434" PostTypeId="2" ParentId="22433" CreationDate="2020-01-05T15:32:56.780" Score="2" Body="&lt;p&gt;IIRC, &lt;code&gt;transparent&lt;/code&gt; prevents coloring the text in any ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would expect the following to work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match xA /^a\+/ conceal&#xA;syntax match xB /\(^a\+\)\@&amp;lt;=b\+/&#xA;highlight xA ctermfg=red&#xA;highlight xB ctermfg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-01-05T15:32:56.780" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22435" PostTypeId="1" CreationDate="2020-01-05T15:39:05.893" Score="2" ViewCount="523" Body="&lt;p&gt;I have been trying to get persistent undo to work for over a day now. I keep having a quite unusual bug. I tried the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Let's save undo info!&#xA;if !isdirectory($HOME.&quot;/.vim&quot;)&#xA;    call mkdir($HOME.&quot;/.vim&quot;, &quot;&quot;, 0770)&#xA;endif&#xA;if !isdirectory($HOME.&quot;/.vim/undo-dir&quot;)&#xA;    call mkdir($HOME.&quot;/.vim/undo-dir&quot;, &quot;&quot;, 0700)&#xA;endif&#xA;set undodir=~/.vim/undo-dir&#xA;set undofile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then open an existing file make a few edits and close the file.&#xA;Open the file and type 'u' - The entire buffer is emptied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then looking through the documentation I found this snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufReadPost * call ReadUndo()&#xA;au BufWritePost * call WriteUndo()&#xA;func ReadUndo()&#xA;  if filereadable(expand('%:h') . '/UNDO/' . expand('%:t'))&#xA;    rundo %:h/UNDO/%:t&#xA;  endif&#xA;endfunc&#xA;func WriteUndo()&#xA;  let dirname = expand('%:h') . '/UNDO'&#xA;  if !isdirectory(dirname)&#xA;    call mkdir(dirname)&#xA;  endif&#xA;  wundo %:h/UNDO/%:t&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to work better, but I am still getting an undo at the beginning of&#xA;every file that removes all content (i.e. pressing u to many times results in&#xA;an empty file no matter what I started with) - is there a way to avoid this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My version info:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NVIM v0.4.3&#xA;Build type: Release&#xA;LuaJIT 2.0.5&#xA;Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.3/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include&#xA;Compiled by builduser&#xA;&#xA;Features: +acl +iconv +tui&#xA;See &quot;:help feature-compile&quot;&#xA;&#xA;   system vimrc file: &quot;$VIM/sysinit.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/nvim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26366" LastEditorUserId="26366" LastEditDate="2020-01-05T23:51:13.080" LastActivityDate="2020-02-05T01:01:10.113" Title="Persistent undo erases my file" Tags="|neovim|undo-redo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22436" PostTypeId="2" ParentId="22373" CreationDate="2020-01-05T15:48:05.683" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is this a NeoVim bug, am I doing something wrong or is my configuration flawed?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After further investigation this does not appear to be a NeoVim bug; therefore I must have been doing something wrong or had configuration snags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An &lt;a href=&quot;https://github.com/neovim/neovim/issues/11666&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue&lt;/a&gt; was raised on the NeoVim repository, and subsequently closed as the bug could not be replicated.  I subsequently booted up off a Kubuntu 18.04 LiveUSB, installed a fresh nvim AppImage and was also no longer able to replicate the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo getcompletion('sol', 'filetype')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;now returned a &lt;code&gt;[]&lt;/code&gt; as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB - Although NeoVim does not have inbuilt solidity detection, the &lt;a href=&quot;https://github.com/tomlion/vim-solidity&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-solidity&lt;/a&gt; plugin does provide filetype detection and enable ALE linting.  Thanks to @D.BenKnoble for highlighting this.&lt;/p&gt;&#xA;" OwnerUserId="20086" LastActivityDate="2020-01-05T15:48:05.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22437" PostTypeId="2" ParentId="22435" CreationDate="2020-01-06T00:12:12.397" Score="1" Body="&lt;p&gt;I found what the problem was. It was caused by a plugin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;auxiliary/vim-layout&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure why it causes such strange behavior, but I have uninstalled it and now my undo history works fine.&lt;/p&gt;&#xA;" OwnerUserId="26366" LastActivityDate="2020-01-06T00:12:12.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22438" PostTypeId="1" CreationDate="2020-01-06T09:36:50.087" Score="2" ViewCount="206" Body="&lt;p&gt;My version is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ve &#xA;Version nvi-1.81.6nb5 (2009-08-11) The CSRG, University of California, Berkeley.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to save a file at regular intervals in vi/nvi?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there is an &quot;autowrite&quot; option, but that's only when writing to multiple files and switching back an forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help will be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="26374" LastEditorUserId="1841" LastEditDate="2020-01-06T10:04:13.313" LastActivityDate="2020-06-04T11:05:20.507" Title="Is there an autosave option for vi/nvi" Tags="|save|nvi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22439" PostTypeId="2" ParentId="22438" CreationDate="2020-01-06T09:51:10.650" Score="-1" Body="&lt;p&gt;Use the autosave plugin.&#xA;Be aware that it sometimes gets you out of visual mode and problematic in general.&#xA;&lt;a href=&quot;https://vimawesome.com/plugin/vim-auto-save&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vimawesome.com/plugin/vim-auto-save&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2020-01-06T09:51:10.650" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22440" PostTypeId="2" ParentId="22429" CreationDate="2020-01-06T14:40:57.710" Score="3" Body="&lt;p&gt;There's an alternative and arguably cleaner method of achieving your goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By using Vim's syntax features to make &lt;code&gt;xA&lt;/code&gt; a group that can only be found within &lt;code&gt;xB&lt;/code&gt;, you can remove your &lt;code&gt;\zs&lt;/code&gt; entirely, resulting in much simpler regular expressions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match xA /^a\+/ containedin=xB contained&#xA;syntax match xB /^a\+b\+/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.org/syntax.txt.html#:syn-containedin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;containedin=XB&lt;/code&gt;&lt;/a&gt; means that &lt;code&gt;xA&lt;/code&gt; can be found within &lt;code&gt;xB&lt;/code&gt;, and &lt;a href=&quot;http://vimhelp.org/syntax.txt.html#:syn-contained&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;contained&lt;/code&gt;&lt;/a&gt; means that it cannot be found anywhere else (or more precisely, at the top level).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a little unclear from your question, but if you want &lt;code&gt;aaa&lt;/code&gt; to be red even when it's not followed by &lt;code&gt;bbbb&lt;/code&gt;, you can simplify even further:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match xA /^a\+/ nextgroup=xB&#xA;syntax match xB /b\+/ contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.org/syntax.txt.html#:syn-nextgroup&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;nextgroup=xB&lt;/code&gt;&lt;/a&gt; means that after a match for &lt;code&gt;xA&lt;/code&gt;, Vim will check to see if &lt;code&gt;xB&lt;/code&gt; immediately follows. As in the previous solution, &lt;code&gt;contained&lt;/code&gt; in the &lt;code&gt;xB&lt;/code&gt; definition means that strings of &lt;code&gt;b&lt;/code&gt; characters elsewhere in the file will not be matched.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-06T15:07:44.267" LastActivityDate="2020-01-06T15:07:44.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22441" PostTypeId="1" AcceptedAnswerId="22442" CreationDate="2020-01-06T14:42:59.150" Score="2" ViewCount="104" Body="&lt;p&gt;Suppose I am defining a few commands that are similar in functionality. In this particular case, I am defining a few commands that each echoes a particular message: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EchoMessage(text)&#xA;    echom text&#xA;endfunction&#xA;&#xA;let thousand_chars = &quot;天地玄黃，宇宙洪荒。日月盈昃，辰宿列張。 寒來暑往，秋收冬藏。閏餘成歲，律呂調陽 ...&quot;&#xA;let lorem_ipsum = &quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit, ...&quot;&#xA;let brown_fox = &quot;The quick brown fox jumps over the lazy dog.&quot;&#xA;&#xA;command! ThousandCharacters call EchoMessage(thousand_chars)&#xA;command! LoremIpsum call EchoMessage(lorem_ipsum)&#xA;command! BrownFox call EchoMessage(brown_fox)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have written it in this way to be able to reuse &lt;code&gt;EchoMessage&lt;/code&gt; for many commands. Unfortunately, an error is produced when any of the commands (e.g. &lt;code&gt;:LoremIpsum&lt;/code&gt;) are called, because vim will not provide &lt;code&gt;text&lt;/code&gt; when &lt;code&gt;EchoMessage&lt;/code&gt; is called using a command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I structure my code so that the commands can make use of a common function (e.g. &lt;code&gt;EchoMessage&lt;/code&gt;) with one argument provided in the script itself (e.g. &lt;code&gt;brown_fox&lt;/code&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="19712" LastEditorUserId="19712" LastEditDate="2020-01-06T22:20:49.170" LastActivityDate="2020-01-06T22:20:49.170" Title="How to define a command if the function needs to take an argument from the script itself?" Tags="|command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22442" PostTypeId="2" ParentId="22441" CreationDate="2020-01-06T15:02:41.893" Score="4" Body="&lt;p&gt;The problem is that, in the body of your &lt;code&gt;EchoMessage()&lt;/code&gt; function, &lt;code&gt;text&lt;/code&gt; does not refer to the value passed in, but instead to a different local variable. Use &lt;code&gt;a:&lt;/code&gt; to refer to parameters passed in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echom a:text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/eval.txt.html#internal-variables&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help internal-variables&lt;/code&gt;&lt;/a&gt; (and specifically &lt;a href=&quot;https://vimhelp.org/eval.txt.html#function-argument&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help function-argument&lt;/code&gt;&lt;/a&gt;) for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-06T15:08:38.940" LastActivityDate="2020-01-06T15:08:38.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22443" PostTypeId="2" ParentId="10937" CreationDate="2020-01-06T19:54:38.940" Score="2" Body="&lt;p&gt;Sure, just disable folding in insert mode, and restore it when you leave:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup folds&#xA;  au!&#xA;  au InsertEnter * let w:oldfen = &amp;amp;l:foldenable \| set nofoldenable&#xA;  au InsertLeave *&#xA;        \ if exists('w:oldfen')&#xA;        \   let &amp;amp;l:foldenable = w:oldfen&#xA;        \   unlet w:oldfen&#xA;        \ endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-01-06T19:54:38.940" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22444" PostTypeId="1" AcceptedAnswerId="22445" CreationDate="2020-01-06T21:39:41.273" Score="3" ViewCount="58" Body="&lt;p&gt;I have these in my .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set notimeout&#xA;nnoremap &amp;lt;leader&amp;gt;n :set rnu!&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;h :&amp;lt;C-u&amp;gt;call Toggle_colorcolumn()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;leader&amp;gt;n&lt;/code&gt; works instantly; &lt;code&gt;&amp;lt;leader&amp;gt;h&lt;/code&gt; waits until I press Return or Escape key. Why does vim wait? I want it to take effect immediately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the function definition just in case the problem is there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Toggle_colorcolumn()&#xA;    if &amp;amp;colorcolumn != 80&#xA;        exec('set colorcolumn=80')&#xA;    else&#xA;        exec('set colorcolumn=0')&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26387" LastEditorUserId="10604" LastEditDate="2020-01-06T23:11:27.843" LastActivityDate="2020-01-06T23:12:04.933" Title="Use mapped shortcut without timeout" Tags="|vimrc|key-bindings|vimscript|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22445" PostTypeId="2" ParentId="22444" CreationDate="2020-01-06T22:22:12.357" Score="2" Body="&lt;p&gt;I had another binding that &lt;code&gt;&amp;lt;leader&amp;gt;h&lt;/code&gt; was a prefix and I had forgotten about; it was &lt;code&gt;&amp;lt;leader&amp;gt;html&lt;/code&gt;. Removing it solved the problem.&lt;/p&gt;&#xA;" OwnerUserId="26387" LastEditorUserId="10604" LastEditDate="2020-01-06T23:12:04.933" LastActivityDate="2020-01-06T23:12:04.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22446" PostTypeId="1" CreationDate="2020-01-07T04:47:40.577" Score="1" ViewCount="206" Body="&lt;p&gt;I am using Vim on Windows. My installation directory is &lt;code&gt;C:\Program Files\Vim\vim82&lt;/code&gt;. As I am trying to use Vundle, I installed it in &lt;code&gt;.\plugin\Vundle.vim&lt;/code&gt;. Then, I added these to &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible              &quot; required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+='C:\Program Files\Vim\vim82\plugin\Vundle.vim'&#xA;call vundle#begin('C:\Program Files\Vim\vim82\plugin')&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'gmarik/Vundle.vim'&#xA;&#xA;&quot; All of your Plugins must be added before the following line&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I put &lt;code&gt;:PluginInstall&lt;/code&gt; in Vim, it says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &quot; Installing plugins to C:\Users\&amp;lt;user name&amp;gt;\.vim\bundle&#xA;+ Plugin 'VundleVim/Vundle.vim'&#xA;* Helptags &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What should I change? Should I actually do a reinstall and put the entire Vim in &lt;code&gt;C:\Users\&amp;lt;user name&amp;gt;\.vim&lt;/code&gt;, because that seems to be the assumed default for most resources I see online?&lt;/p&gt;&#xA;" OwnerUserId="26389" LastActivityDate="2020-01-07T06:06:36.043" Title="Vundle keeps installing plugins to C:\Users\&lt;user name&gt; despite being told not to in .vimrc" Tags="|plugin-vundle|working-directory|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22447" PostTypeId="2" ParentId="22446" CreationDate="2020-01-07T06:06:36.043" Score="1" Body="&lt;p&gt;There are many mistakes in your current configuration. I can't really tell &lt;em&gt;why&lt;/em&gt; you're seeing the behavior you're currently seeing or &lt;em&gt;why&lt;/em&gt; things are apparently working that weren't supposed to...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, let's unpack it and address the mistakes.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;As I am trying to use Vundle, I installed it in &lt;code&gt;.\plugin\Vundle.vim&lt;/code&gt;. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is the first problem. The &lt;code&gt;vim82&lt;/code&gt; or &lt;code&gt;vimfiles&lt;/code&gt; directory is special for Vim and it will expect a specific directory structure there and treat directories and files with specific names in a special way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, &lt;strong&gt;&lt;code&gt;plugin&lt;/code&gt;&lt;/strong&gt; is one such special name. Vim expects to find &lt;code&gt;*.vim&lt;/code&gt; files that it will run after your vimrc every time it gets started. (Other special directories are &lt;code&gt;autoload&lt;/code&gt;, &lt;code&gt;ftplugin&lt;/code&gt;, &lt;code&gt;ftdetect&lt;/code&gt;, &lt;code&gt;indent&lt;/code&gt;, &lt;code&gt;syntax&lt;/code&gt;, &lt;code&gt;doc&lt;/code&gt;, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that the sense in which the word plug-in is used in this &lt;code&gt;plugin&lt;/code&gt; directory is &lt;strong&gt;not&lt;/strong&gt; the same sense in which people talk about Vim plug-ins, such as the ones plug-in managers such as Vundle manage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, placing your &lt;code&gt;Vundle.vim&lt;/code&gt; directory under Vim's &lt;code&gt;plugin&lt;/code&gt; directory is incorrect and quite likely to cause problems.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;set rtp+='C:\Program Files\Vim\vim82\plugin\Vundle.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The syntax of this command is incorrect, as you're not allowed to use quotes on strings when using the &lt;code&gt;set&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The correct way to add this Windows path to your &lt;code&gt;'runtimepath'&lt;/code&gt; would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp+=C:\\Program\ Files\\Vim\\vim82\\plugin\\Vundle.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the actual backslashes are doubled, and the space is escaped by another backslash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, again, please note that using this &lt;code&gt;plugin&lt;/code&gt; directory is incorrect and you shouldn't really use this path!&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;call vundle#begin('C:\Program Files\Vim\vim82\plugin')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's fine to use quotes here. Single-quotes are preferred as they don't interfere with the backslashes.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What should I change? Should I actually do a reinstall and put the entire Vim in &lt;code&gt;C:\Users\&amp;lt;user name&amp;gt;\.vim&lt;/code&gt;, because that seems to be the assumed default for most resources I see online?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, you should leave your Vim &lt;em&gt;installation&lt;/em&gt; (the software, the program, the runtime and support files) under &lt;code&gt;C:\Program Files\Vim&lt;/code&gt; where they currently are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you should maintain your Vim &lt;em&gt;configuration&lt;/em&gt; for your user under your user's home, in particular use &lt;code&gt;C:\Users\&amp;lt;username&amp;gt;\.vim&lt;/code&gt; (or actually &lt;code&gt;C:\Users\&amp;lt;username&amp;gt;\vimfiles&lt;/code&gt;, which I believe is the default on Windows) for your plug-in manager and the plug-ins you install with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at &lt;code&gt;:version&lt;/code&gt; or at &lt;code&gt;:set rtp?&lt;/code&gt; to find where Vim wants to find your configuration files, and use those directories...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One reason to keep your Vim &lt;em&gt;installation&lt;/em&gt; separate from your &lt;em&gt;configuration&lt;/em&gt; is that then you're free to upgrade or reinstall Vim as needed and that shouldn't touch any of your configuration for it, which lives in a separate location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another reason to keep it separate is that you can easily transfer it to another machine where you also use Vim. You can easily backup your Vim configuration, or store it on GitHub or similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One final recommendation is that you should look into using the &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt; plug-in manager rather than Vundle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim-plug is very similar to Vundle in the way it works (it's an easy to use plug-in manager), but it's more modern and has more features than Vundle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be easy to install vim-plug on Windows. It should be easy to convert from Vundle configuration to vim-plug (mainly just renaming &lt;code&gt;Plugin 'xyz'&lt;/code&gt; to &lt;code&gt;Plug 'xyz'&lt;/code&gt;) and the commands are very similar too (instead of &lt;code&gt;:PluginInstall&lt;/code&gt;, use &lt;code&gt;:PlugInstall&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The README file for vim-plug has easy to follow instructions for &lt;a href=&quot;https://github.com/junegunn/vim-plug/blob/master/README.md#windows-powershell&quot; rel=&quot;nofollow noreferrer&quot;&gt;installing on Windows&lt;/a&gt;, using PowerShell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also vim-plug's tips for &lt;a href=&quot;https://github.com/junegunn/vim-plug/wiki/tips#migrating-from-other-plugin-managers&quot; rel=&quot;nofollow noreferrer&quot;&gt;migrating from Vundle&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-07T06:06:36.043" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22448" PostTypeId="1" AcceptedAnswerId="22449" CreationDate="2020-01-07T06:07:03.850" Score="8" ViewCount="769" Body="&lt;p&gt;I have a function definition in my &lt;code&gt;.vimrc&lt;/code&gt;. This &lt;code&gt;.vimrc&lt;/code&gt; is sufficient to demonstrate the problem I'm asking about:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Greet()&#xA;    echo &quot;hello&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to be able use the same &lt;code&gt;.vimrc&lt;/code&gt; with a version of vim configured with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--with-features=tiny&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't expect the function to be defined, but I don't want error messages on startup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, if I run a tiny vim, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /home/kst/.vimrc:&#xA;line    1:&#xA;E319: Sorry, the command is not available in this version: function! Greet()&#xA;line    2:&#xA;E319: Sorry, the command is not available in this version:     echo &quot;hello&quot;&#xA;line    3:&#xA;E319: Sorry, the command is not available in this version: endfunction&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm looking for something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;function&quot;)&#xA;    function! Greet()&#xA;        echo &quot;hello&quot;&#xA;   endfunction&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that doesn't do the job because &lt;code&gt;has()&lt;/code&gt; doesn't recognize &lt;code&gt;&quot;function&quot;&lt;/code&gt;. (The result is that the function definition is disabled even for versions of vim that support functions.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't see anything obvious in the documentation for &lt;code&gt;has()&lt;/code&gt;, and web searches with the word &quot;function&quot; give me a lot of irrelevant hits.&lt;/p&gt;&#xA;" OwnerUserId="2380" LastActivityDate="2020-01-08T00:30:27.607" Title="Detecting whether vim supports functions" Tags="|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22449" PostTypeId="2" ParentId="22448" CreationDate="2020-01-07T06:24:26.077" Score="15" Body="&lt;p&gt;The problem is that &quot;tiny&quot; is missing the &lt;code&gt;+eval&lt;/code&gt; feature and that's what prevents it from seeing your function definitions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you could try something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('eval')&#xA;    function! Greet()&#xA;        echo &quot;hello&quot;&#xA;    endfunction&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it turns out you can go even simpler than that, as &lt;a href=&quot;https://vimhelp.org/eval.txt.html#no-eval-feature&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help no-eval-feature&lt;/code&gt;&lt;/a&gt; suggests:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the &lt;code&gt;+eval&lt;/code&gt; feature was disabled at compile time, none of the expression&#xA;  evaluation commands are available.  To prevent this from causing Vim scripts&#xA;  to generate all kinds of errors, the &lt;code&gt;:if&lt;/code&gt; and &lt;code&gt;:endif&lt;/code&gt; commands are still&#xA;  recognized, though the argument of the &lt;code&gt;:if&lt;/code&gt; and everything between the &lt;code&gt;:if&lt;/code&gt;&#xA;  and the matching &lt;code&gt;:endif&lt;/code&gt; is ignored.  Nesting of &lt;code&gt;:if&lt;/code&gt; blocks is allowed, but&#xA;  only if the commands are at the start of the line.  The &lt;code&gt;:else&lt;/code&gt; command is not&#xA;  recognized.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you can simply use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if 1&#xA;    function! Greet()&#xA;        echo &quot;hello&quot;&#xA;    endfunction&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I strongly suggest adding a comment to indicate why you're using &lt;code&gt;if 1&lt;/code&gt;, why it makes sense, why it's needed!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking inside &lt;code&gt;$VIMRUNTIME/defaults.vim&lt;/code&gt;, there's a snippet there that uses a hack to only run a command whenever &lt;code&gt;+eval&lt;/code&gt; is not available. Adapting that to your specific case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use a trick to break out when the&#xA;&quot; +eval feature is missing.&#xA;silent! while 0&#xA;    finish&#xA;silent! endwhile&#xA;&#xA;function! Greet()&#xA;    echo &quot;hello&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;+eval&lt;/code&gt; is missing, it won't recognize the &lt;code&gt;while&lt;/code&gt; statement and will &lt;code&gt;finish&lt;/code&gt;, breaking out of the script and skipping everything that follows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;+eval&lt;/code&gt; is present, the &lt;code&gt;while 0&lt;/code&gt; block will be skipped, since the condition is false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/eval.txt.html#no-eval-feature&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help no-eval-feature&lt;/code&gt;&lt;/a&gt; section also mentions this technique (with a different command as example) and explains it:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the &lt;code&gt;+eval&lt;/code&gt; feature is available the command is skipped because of the&#xA;  &lt;code&gt;while 0&lt;/code&gt;.  Without the &lt;code&gt;+eval&lt;/code&gt; feature the &lt;code&gt;while 0&lt;/code&gt; is an error, which is&#xA;  silently ignored, and the command is executed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-01-08T00:30:27.607" LastActivityDate="2020-01-08T00:30:27.607" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="22450" PostTypeId="1" AcceptedAnswerId="22452" CreationDate="2020-01-07T09:56:54.490" Score="0" ViewCount="236" Body="&lt;p&gt;In normal mode I want to be able to select a word and when I press &lt;code&gt;&amp;lt;leader&amp;gt;i&lt;/code&gt; yield the following string in next line, &lt;code&gt;The word is &amp;lt;word_that_was_highlighted&amp;gt;&lt;/code&gt;. Is it possible to do this in vim? I attempted a solution using &lt;code&gt;nnoremap&lt;/code&gt; like as follows but that didn't work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;i :let @h=@*&amp;lt;c-r&amp;gt;&quot;hp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here I was attempting to paste the content of register * into h, and then paste that onto a new line.&lt;/p&gt;&#xA;" OwnerUserId="23265" LastEditorUserId="1238" LastEditDate="2020-01-07T18:12:14.763" LastActivityDate="2020-01-07T18:12:14.763" Title="Paste word under cursor into new line" Tags="|normal-mode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22451" PostTypeId="1" AcceptedAnswerId="22453" CreationDate="2020-01-07T10:08:35.877" Score="1" ViewCount="271" Body="&lt;p&gt;From the Vim's help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo matchlist('acd', '\v(a)?(b)?(c)?(.*)')&#xA;Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand why the 3rd element is an empty string: 'b' is not present in the string, but what's up with those 5 empty strings at the end?&lt;/p&gt;&#xA;" OwnerUserId="11022" LastEditorUserId="626" LastEditDate="2020-01-07T16:02:32.983" LastActivityDate="2020-01-07T16:53:39.840" Title="Why does matchlist() return empty strings at the end of the result?" Tags="|vimscript|regular-expression|matchlist|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22452" PostTypeId="2" ParentId="22450" CreationDate="2020-01-07T10:20:29.293" Score="6" Body="&lt;p&gt;As discussed in the comments you are looking for the following mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;i yiwoThe word is &amp;lt;Esc&amp;gt;p&#xA;                   yiw                     Yank the word under the cursor&#xA;                      o                    Create a new line under the current one and enter insert mode&#xA;                       The word is         Type this string literraly&#xA;                                   &amp;lt;Esc&amp;gt;   Switch back to normal mode&#xA;                                        p  Past the word you yanked before&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2020-01-07T10:20:29.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22453" PostTypeId="2" ParentId="22451" CreationDate="2020-01-07T10:25:11.863" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;what's up with those 5 empty strings at the end?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;matchlist()&lt;/code&gt; &lt;strong&gt;always&lt;/strong&gt; returns the list of 10 items (the matched string and nine submatches - just like &lt;code&gt;\0, \1, ..., \9&lt;/code&gt; in &lt;a href=&quot;https://vimhelp.org/change.txt.html#sub-replace-special&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h sub-replace-special&lt;/code&gt;&lt;/a&gt;). The last five weren't used, so they are set to empty strings.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2020-01-07T16:53:39.840" LastActivityDate="2020-01-07T16:53:39.840" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22454" PostTypeId="2" ParentId="22451" CreationDate="2020-01-07T16:02:00.413" Score="3" Body="&lt;p&gt;As it has been explained, this function will always assume 9 submatches can exist and it will return an entry in the result list for all possible submatch. Hence the 5 extra elements returned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a practical note, this means that we cannot call it this way&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let [all, a, b, c, end] = matchlist('acd', '\v(a)?(b)?(c)?(.*)') &quot; fails&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But we don't have to fill 5 dummy variables either&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let [all, a, b, c, end, dummy5, dummy6, dummy7, dummy8, dummy9] = matchlist('acd', '\v(a)?(b)?(c)?(.*)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead, we can use &lt;code&gt;;&lt;/code&gt;. See &lt;em&gt;List unpack&lt;/em&gt; chapter just  before &lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#list%2dmodification&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h list-modification&lt;/code&gt;&lt;/a&gt; chapter in Vim documentation -- unfortunately, there is no &lt;code&gt;:h list-unpack&lt;/code&gt; entry at this time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means the following, with the semicolon, works fine&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let [all, a, b, c, end; dummy_tail] = matchlist('acd', '\v(a)?(b)?(c)?(.*)')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2020-01-07T16:02:00.413" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22455" PostTypeId="1" CreationDate="2020-01-07T16:22:38.487" Score="1" ViewCount="1068" Body="&lt;p&gt;I'm currently using Vim 8.1 on Ubuntu 18.04, and I would like to override the default behavior of &lt;strong&gt;deleting local files/directories 'forever'&lt;/strong&gt; when using netrw.&lt;/p&gt;&#xA;&lt;p&gt;The doc says that this plugin uses a function called &lt;code&gt;delete()&lt;/code&gt; on latest versions of vim. My guess is that this function simple uses &lt;code&gt;rm&lt;/code&gt; to delete files, how could I override this behavior to use e.g. a command from trash-cli or simply moving file/directory to a different folder?&lt;/p&gt;&#xA;" OwnerUserId="25347" LastEditorUserId="23502" LastEditDate="2024-02-15T15:07:49.813" LastActivityDate="2024-02-15T15:07:49.813" Title="How to override netrw-delete behavior?" Tags="|cut-copy-paste|netrw|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22456" PostTypeId="1" CreationDate="2020-01-07T16:41:56.787" Score="2" ViewCount="947" Body="&lt;p&gt;Can anyone show me how to catch the last badly spelled word when vim says ...hit BOTTOM? I tried to do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while 1&#xA;    try&#xA;        &quot; Jump to the next&#xA;        silent keepjumps normal! ]s                                                                                &#xA;        let counter += 1&#xA;    catch /^Vim[^)]\+):E38[45]\D/&#xA;        &quot; do some stuff&#xA;        break&#xA;    endtry&#xA;endwhile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cycling through the badly spelled words works (as it seems to me) like cycling through the searched words. Indeed, if I replace &lt;code&gt;]s&lt;/code&gt; with &lt;code&gt;n&lt;/code&gt; and then do some search the try-catch works fine.&lt;/p&gt;&#xA;" OwnerUserId="26395" LastActivityDate="2020-01-07T17:11:59.723" Title="Catch the “search hit BOTTOM, continuing at TOP” when cycle through the badly spelled words" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22457" PostTypeId="2" ParentId="22456" CreationDate="2020-01-07T17:11:59.723" Score="3" Body="&lt;p&gt;Why don't you disable the wrapping momentarily while the function is executing?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CountAll() abort&#xA;  let ws = &amp;amp;wrapscan&#xA;  set nowrapscan&#xA;  try&#xA;    keepjumps normal! gg&#xA;    &quot; FIXME: If the first word is an error, count it&#xA;    &quot; - may be with a reverse search? &#xA;    &quot; - Or by testing the syntax highlighting under the cursor&#xA;    let nb = 0&#xA;    let p = getcurpos()&#xA;    while 1&#xA;      silent! keepjumps normal! ]s&#xA;&#xA;      let p2 = getcurpos()&#xA;      if p == p2&#xA;        &quot; echomsg &quot;No more errors&quot;&#xA;        break&#xA;      endif&#xA;      &quot; else, found...&#xA;      let p = p2&#xA;      let nb += 1&#xA;    endwhile&#xA;  finally&#xA;    let &amp;amp;wrapscan = ws&#xA;  endtry&#xA;  return nb&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: I was hoping that &lt;code&gt;catch&lt;/code&gt; would be able to recognize the &lt;em&gt;&quot;no more error&quot;&lt;/em&gt; case. Alas, with &lt;code&gt;:silent&lt;/code&gt; it just makes Vim blink. We need to track cursor positions.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2020-01-07T17:11:59.723" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22458" PostTypeId="2" ParentId="22455" CreationDate="2020-01-07T18:10:08.663" Score="1" Body="&lt;p&gt;Well, it's not supposed to be user-modifiable. But we can &quot;hack&quot; it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; helper function to find Script Number (aka SNR)&#xA;function! GetSNR(sfile)&#xA;    &quot; slash &amp;lt;-&amp;gt; bslash translation&#xA;    let l:sfile = exists('+shellslash') &amp;amp;&amp;amp; !&amp;amp;shellslash ?&#xA;        \ tr(a:sfile, '/', '\') : tr(a:sfile, '\', '/')&#xA;    &quot; get 'number:', 'scriptfile' pairs&#xA;    let l:scripts = split(execute('scriptnames'))&#xA;    &quot; find script file of interest&#xA;    let l:pos = index(l:scripts, l:sfile)&#xA;    &quot; return SNR or zero&#xA;    return l:pos &amp;gt; 0 ? str2nr(l:scripts[l:pos - 1]) : 0&#xA;endfunction&#xA;&#xA;&quot; force autoloaded script to load&#xA;call netrw#GX()&#xA;&#xA;&quot; replace script-local function s:NetrwDelete()&#xA;&quot; bug or feature, however this works!&#xA;execute printf('function! &amp;lt;SNR&amp;gt;%d_NetrwDelete(path)',&#xA;    \ GetSNR($VIMRUNTIME . '/autoload/netrw.vim'))&#xA;    &quot; ***** Do something instead of delete() *****&#xA;    echom 'Attempt to delete ' . a:path&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-01-07T18:10:08.663" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22459" PostTypeId="1" AcceptedAnswerId="22505" CreationDate="2020-01-07T20:40:49.877" Score="5" ViewCount="741" Body="&lt;p&gt;My issue happens with the key combination &lt;code&gt;gx&lt;/code&gt; in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problems happens in Vim, (I have also tried in NeoVim and it correctly opens the link in firefox directly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a test file /tmp/go-to-stackoverflow.markdown which contains the url &lt;a href=&quot;http://www.stackoverflow.com&quot;&gt;http://www.stackoverflow.com&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I hit &lt;code&gt;gx&lt;/code&gt; while the cursor is on the link:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it opens a new buffer window at the bottom which contains only one line with the link written in it&lt;/li&gt;&#xA;&lt;li&gt;it displays during a few milliseconds (I had to redo it several times to get each words) the message &lt;code&gt;netrw --No Line In Buffer--&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any idea what might be wrong in my configuration, how to fix the issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use vim 8.1 on NixOs 19.09.&lt;/p&gt;&#xA;" OwnerUserId="1682" LastEditorUserId="1682" LastEditDate="2020-01-07T22:11:46.977" LastActivityDate="2022-01-07T17:57:06.897" Title="gx doesn't open the url and complains: netrw --No Line In Buffer--" Tags="|netrw|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22460" PostTypeId="2" ParentId="10937" CreationDate="2020-01-07T22:00:15.407" Score="3" Body="&lt;p&gt;If you're looking to completely disable folding (i.e. open all folds) while typing, see &lt;a href=&quot;https://vi.stackexchange.com/a/22443/26400&quot;&gt;D. Ben Knoble's answer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you'd just like to prevent Vim from opening and closing folds based on syntax while typing, leaving closed folds closed, check out Vim tip &lt;a href=&quot;https://vim.fandom.com/wiki/Keep_folds_closed_while_inserting_text&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Keep folds closed while inserting text&quot;&lt;/a&gt; or the &lt;a href=&quot;https://github.com/Konfekt/FastFold&quot; rel=&quot;nofollow noreferrer&quot;&gt;FastFold plugin&lt;/a&gt;.  These use a variation on that theme with &lt;code&gt;foldmethod=manual&lt;/code&gt; instead of &lt;code&gt;nofoldenable&lt;/code&gt; during Insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup folds&#xA;  au!&#xA;  au InsertEnter * let w:oldfdm = &amp;amp;l:foldmethod | setlocal foldmethod=manual&#xA;  au InsertLeave *&#xA;        \ if exists('w:oldfdm') |&#xA;        \   let &amp;amp;l:foldmethod = w:oldfdm |&#xA;        \   unlet w:oldfdm |&#xA;        \ endif |&#xA;        \ normal! zv&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;normal! zv&lt;/code&gt; at the end serves to ensure that, if you typed something that would result in a new fold, your cursor doesn't get folded into it when you leave Insert mode.  You could also experiment with &lt;code&gt;zx&lt;/code&gt;, or just remove it if that doesn't matter to you.&lt;/p&gt;&#xA;" OwnerUserId="26400" LastEditorUserId="26400" LastEditDate="2020-01-07T22:12:19.637" LastActivityDate="2020-01-07T22:12:19.637" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22461" PostTypeId="1" CreationDate="2020-01-08T08:47:57.867" Score="0" ViewCount="275" Body="&lt;p&gt;As title howto source all files under a folder recursively except files that end with &lt;code&gt;.bak&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2020-01-09T20:23:32.610" Title="Recursively source files under a folder except *.bak" Tags="|vimrc|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22462" PostTypeId="2" ParentId="22461" CreationDate="2020-01-08T09:21:12.070" Score="1" Body="&lt;p&gt;You can only 'source' a file at a time. Therefore, build the list of files first, and then source them one by one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildignore=*.bak&#xA;let s:prefix = '/path/to/folder'&#xA;&#xA;for s:fname in glob(s:prefix . '/**', 0, 1)&#xA;    execute 'source' s:fname&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, normally you should only source *.vim files, so then it becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:prefix = '/path/to/folder'&#xA;&#xA;for s:fname in glob(s:prefix . '/**/*.vim', 1, 1)&#xA;    execute 'source' s:fname&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But note that file system search does not guarantee order, so there can be some side-effects.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-01-08T09:21:12.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22463" PostTypeId="2" ParentId="22455" CreationDate="2020-01-08T12:39:37.027" Score="3" Body="&lt;p&gt;Let us be not too insane :-) and provide a different solution using mappings and netrw public API.&lt;/p&gt;&#xA;&lt;p&gt;Beware that the code is neither complete nor was tested properly!&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; our custom delete routine&#xA;function! g:MyNetrw_DoDelete(flist)&#xA;    echom 'Deleting ' a:flist&#xA;endfunction&#xA;&#xA;&amp;quot; setup netrw mappings (:h g:Netrw_UserMaps)&#xA;let g:Netrw_UserMaps = [['D', 'g:MyNetrw_D'], [&amp;quot;\&amp;lt;Del&amp;gt;&amp;quot;, 'g:MyNetrw_D']]&#xA;&#xA;&amp;quot; unfortunately, the visual mode is not supported by Netrw_UserMaps,&#xA;&amp;quot; so implement it with the help of augroup/autocmd&#xA;&amp;quot; (although netrw is very peculiar about its mappings,&#xA;&amp;quot; it seems to work okay too)&#xA;augroup MyNetrw | au!&#xA;    autocmd FileType netrw vnoremap &amp;lt;buffer&amp;gt;D :call g:MyNetrw_vD()&amp;lt;CR&amp;gt;&#xA;augroup end&#xA;&#xA;&amp;quot; implement normal mode deletion&#xA;function! g:MyNetrw_D(islocal)&#xA;    if a:islocal&#xA;        &amp;quot; get selected file list (:h netrw-mf)&#xA;        let l:flist = netrw#Expose('netrwmarkfilelist')&#xA;        if l:flist is# 'n/a'&#xA;            &amp;quot; no selection -- get name under cursor&#xA;            let l:flist = [b:netrw_curdir . '/' . netrw#GX()]&#xA;        else&#xA;            &amp;quot; remove selection as files will be deleted soon&#xA;            call netrw#Call('NetrwUnmarkAll')&#xA;        endif&#xA;        &amp;quot; do delete and refresh view&#xA;        call g:MyNetrw_DoDelete(l:flist)&#xA;        return 'refresh'&#xA;    endif&#xA;&#xA;    &amp;quot; this is to handle remote deletion&#xA;    &amp;quot; hope it works...&#xA;    call netrw#Call('RemotePathAnalysis', b:netrw_curdir)&#xA;    let l:usermach = netrw#Expose('user') . '@' . netrw#Expose('machine')&#xA;    let l:path = netrw#Expose('path')&#xA;    call netrw#Call('NetrwRemoteRm', l:usermach, l:path)&#xA; endfunction&#xA;&#xA;&amp;quot; implement delete over Visual range&#xA;function! g:MyNetrw_vD() range&#xA;    if isdirectory(b:netrw_curdir)&#xA;        &amp;quot; assume it's local dir&#xA;        &amp;quot; get all file names over selected lines&#xA;        let l:flist = []&#xA;        for l:lnum in range(a:firstline, a:lastline)&#xA;            execute l:lnum&#xA;            call add(l:flist, b:netrw_curdir . '/' . netrw#GX())&#xA;        endfor&#xA;        &amp;quot; do delete and then refresh view&#xA;        call g:MyNetrw_DoDelete(l:flist)&#xA;        call netrw#Call('NetrwRefresh', 1, b:netrw_curdir)&#xA;        return&#xA;    endif&#xA;&#xA;    &amp;quot; remote delete over visual range -- NOT IMPLEMENTED&#xA;    &amp;quot; Note: call() cannot supply non-trivial range,&#xA;    &amp;quot; so we have to process line range manually (sigh),&#xA;    &amp;quot; and then call `s:NetrwRemoteRmFile()` in a loop&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="9024" LastEditDate="2024-02-15T08:18:23.510" LastActivityDate="2024-02-15T08:18:23.510" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22466" PostTypeId="2" ParentId="6792" CreationDate="2020-01-09T00:15:49.173" Score="0" Body="&lt;p&gt;You can do this in a round about way by first casting the float to a string then casting it to number for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;echom str2nr(string(log10(200)))&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps people searching in the future.&lt;/p&gt;&#xA;" OwnerUserId="22630" LastActivityDate="2020-01-09T00:15:49.173" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22467" PostTypeId="1" AcceptedAnswerId="22472" CreationDate="2020-01-09T04:06:59.810" Score="5" ViewCount="863" Body="&lt;p&gt;When I use the &lt;code&gt;--startuptime &amp;lt;file&amp;gt;&lt;/code&gt; option, &lt;code&gt;vim&lt;/code&gt; generates an output file. I've included an example at the bottom of this post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I interpret the output? I can't find documentation to verify my assumptions (I checked &lt;code&gt;:help startuptime&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The preamble suggests that lines are of one of two forms:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;clock   self+sourced   self:  sourced script&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;clock   elapsed:              other lines&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Interpreting &lt;em&gt;form 1&lt;/em&gt; lines seems straightforward, with times corresponding to the described event. However, I'm not sure what exactly is meant by &lt;code&gt;other lines&lt;/code&gt; (assuming I've interpreted the preamble correctly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the &lt;em&gt;form 2&lt;/em&gt; lines, what are the definitions of &lt;code&gt;self+sourced&lt;/code&gt; and &lt;code&gt;self&lt;/code&gt;? I have assumed the former corresponds to loading time &lt;em&gt;including&lt;/em&gt; time for recursively &lt;code&gt;:source&lt;/code&gt;'d files, and the latter corresponds to loading time &lt;em&gt;excluding&lt;/em&gt; time for recursively &lt;code&gt;:source&lt;/code&gt;'d files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does the &lt;code&gt;sourcing vimrc file(s)&lt;/code&gt; line's time represent? There is a separate line for &lt;code&gt;$HOME/.vimrc&lt;/code&gt;, with a time greater than given for &lt;code&gt;sourcing vimrc file(s)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, what does the &lt;code&gt;loading plugins&lt;/code&gt; line's time represent? The preceding lines also correspond to plugins, and the sum of the times does not match the &lt;code&gt;loading plugins&lt;/code&gt; time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;times in msec&#xA; clock   self+sourced   self:  sourced script&#xA; clock   elapsed:              other lines&#xA;&#xA;000.011  000.011: --- VIM STARTING ---&#xA;000.149  000.138: Allocated generic buffers&#xA;000.757  000.608: locale set&#xA;000.761  000.004: clipboard setup&#xA;000.770  000.009: window checked&#xA;001.565  000.795: inits 1&#xA;001.577  000.012: parsing arguments&#xA;001.578  000.001: expanding arguments&#xA;012.666  011.088: shell init&#xA;013.157  000.491: Termcap init&#xA;013.174  000.017: inits 2&#xA;013.360  000.186: init highlight&#xA;015.671  001.128  001.128: sourcing /usr/local/share/vim/vim82/syntax/syncolor.vim&#xA;015.851  001.490  000.362: sourcing /usr/local/share/vim/vim82/syntax/synload.vim&#xA;023.584  007.559  007.559: sourcing /usr/local/share/vim/vim82/filetype.vim&#xA;023.644  009.518  000.469: sourcing /usr/local/share/vim/vim82/syntax/syntax.vim&#xA;023.810  000.024  000.024: sourcing /usr/local/share/vim/vim82/filetype.vim&#xA;023.968  000.021  000.021: sourcing /usr/local/share/vim/vim82/filetype.vim&#xA;024.170  000.056  000.056: sourcing /usr/local/share/vim/vim82/ftplugin.vim&#xA;024.326  000.021  000.021: sourcing /usr/local/share/vim/vim82/filetype.vim&#xA;024.524  000.056  000.056: sourcing /usr/local/share/vim/vim82/indent.vim&#xA;025.633  011.850  002.154: sourcing $HOME/.vimrc&#xA;025.641  000.431: sourcing vimrc file(s)&#xA;026.743  000.087  000.087: sourcing /usr/local/share/vim/vim82/plugin/getscriptPlugin.vim&#xA;027.089  000.265  000.265: sourcing /usr/local/share/vim/vim82/plugin/gzip.vim&#xA;027.499  000.326  000.326: sourcing /usr/local/share/vim/vim82/plugin/logiPat.vim&#xA;027.651  000.050  000.050: sourcing /usr/local/share/vim/vim82/plugin/manpager.vim&#xA;027.965  000.234  000.234: sourcing /usr/local/share/vim/vim82/plugin/matchparen.vim&#xA;028.739  000.692  000.692: sourcing /usr/local/share/vim/vim82/plugin/netrwPlugin.vim&#xA;028.956  000.038  000.038: sourcing /usr/local/share/vim/vim82/plugin/rrhelper.vim&#xA;029.179  000.093  000.093: sourcing /usr/local/share/vim/vim82/plugin/spellfile.vim&#xA;029.526  000.228  000.228: sourcing /usr/local/share/vim/vim82/plugin/tarPlugin.vim&#xA;029.757  000.135  000.135: sourcing /usr/local/share/vim/vim82/plugin/tohtml.vim&#xA;030.055  000.211  000.211: sourcing /usr/local/share/vim/vim82/plugin/vimballPlugin.vim&#xA;030.379  000.219  000.219: sourcing /usr/local/share/vim/vim82/plugin/zipPlugin.vim&#xA;031.020  000.382  000.382: sourcing /usr/local/share/vim/vim82/pack/dist/opt/matchit/plugin/matchit.vim&#xA;032.073  000.812  000.812: sourcing /usr/local/share/vim/vim82/pack/dist/opt/termdebug/plugin/termdebug.vim&#xA;032.081  002.668: loading plugins&#xA;032.198  000.117: loading packages&#xA;032.245  000.047: loading after plugins&#xA;032.251  000.006: inits 3&#xA;041.476  009.225: reading viminfo&#xA;041.548  000.072: setting raw mode&#xA;041.556  000.008: start termcap&#xA;041.574  000.018: clearing screen&#xA;041.684  000.110: opening buffers&#xA;041.745  000.061: BufEnter autocommands&#xA;041.751  000.006: editing files in windows&#xA;042.152  000.401: VimEnter autocommands&#xA;042.154  000.002: before starting main loop&#xA;043.052  000.898: first screen update&#xA;043.054  000.002: --- VIM STARTED ---&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26249" LastEditorUserId="11357" LastEditDate="2020-07-29T15:39:28.587" LastActivityDate="2020-07-29T15:39:28.587" Title="Interpreting the output when using --startuptime" Tags="|startup|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22469" PostTypeId="1" AcceptedAnswerId="22478" CreationDate="2020-01-09T07:41:47.620" Score="3" ViewCount="1065" Body="&lt;p&gt;I am very new to vim, and I have a csv file with this format :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;1006&quot;,&quot;text:xxx&quot;&#xA;&quot;2007&quot;,&quot;text:xxx&quot;&#xA;&quot;3008&quot;,&quot;text:xxx&quot;&#xA;&quot;4009&quot;,&quot;text:xxx&quot;&#xA;&quot;5001&quot;,&quot;text:xxx&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;every &quot;xxx&quot; is replaced by an increment+1 of numbers at the start of each line. &#xA;athe result should be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;1006&quot;,&quot;text:1007&quot;&#xA;&quot;2007&quot;,&quot;text:2008&quot;&#xA;&quot;3008&quot;,&quot;text:3009&quot;&#xA;&quot;4009&quot;,&quot;text:4010&quot;&#xA;&quot;5001&quot;,&quot;text:5002&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26424" LastEditorUserId="1841" LastEditDate="2020-01-09T11:06:36.990" LastActivityDate="2020-01-09T12:39:09.340" Title="how to increment a specific number in a csv file" Tags="|substitute|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22470" PostTypeId="1" AcceptedAnswerId="22475" CreationDate="2020-01-09T07:42:50.743" Score="3" ViewCount="765" Body="&lt;p&gt;I have a file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 2 3  &#xA;4 5 6  &#xA;7 8 9  &#xA;0 1 2  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to change a block-wise visual selection area, e.g. &lt;code&gt;5&lt;/code&gt; and &lt;code&gt;8&lt;/code&gt;. I want to substitute them by multiplying the figures by &lt;code&gt;0.7&lt;/code&gt; and I want to round  to 3 digits, e.g. &lt;code&gt;5&lt;/code&gt; changed to &lt;code&gt;3.500&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know &lt;code&gt;submatch&lt;/code&gt; can work the math, but I don’t know how to define the grouped part. &lt;/p&gt;&#xA;" OwnerUserId="26425" LastEditorUserId="1841" LastEditDate="2020-01-09T11:08:30.823" LastActivityDate="2020-01-09T11:08:30.823" Title="Substitute figure by math" Tags="|substitute|visual-block|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22471" PostTypeId="2" ParentId="22470" CreationDate="2020-01-09T07:55:32.223" Score="4" Body="&lt;h3&gt;Visual Block: Colon commands will still apply to whole lines&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You find in the user manual section 10.3 'Command ranges' following note (almost at the end of &lt;a href=&quot;https://vimhelp.org/usr_10.txt.html#10.3&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h 10.3&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: When using Visual mode to select part of a line, or using CTRL-V&#xA;  to select a block of text, the colon commands will still apply to&#xA;  whole lines. This might change in a future version of Vim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A substitute command operating on the whole line would look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\(\d*\s*\)\(\d*\)\(\s*.*\)/\=printf('%d %.3f %d', submatch(1), str2nr(submatch(2))*0.7, submatch(3))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternative, filter lines through &lt;code&gt;awk&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!awk '{printf &quot;\%d \%.3f \%d\n&quot;, $1, $2*0.7, $3}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;\%V&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Please note the answer by &lt;a href=&quot;https://vi.stackexchange.com/a/22475/1292&quot;&gt;@user938271&lt;/a&gt; using the special atom &lt;code&gt;\%V&lt;/code&gt; in a pattern. This circumvents the limitation that colon commands work always on whole lines for the &lt;code&gt;:substitute&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2020-01-09T09:40:45.300" LastActivityDate="2020-01-09T09:40:45.300" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22472" PostTypeId="2" ParentId="22467" CreationDate="2020-01-09T08:31:01.780" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I interpret the output? I can't find documentation to verify my assumptions (I checked :help startuptime).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See just below &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#:profd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h :profd&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You must always start with a &quot;:profile start fname&quot; command.  The resulting&#xA;  file is written when Vim exits.  Here is an example of the output, with line&#xA;  numbers prepended for the explanation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1 FUNCTION  Test2() ~&#xA;  2 Called 1 time ~&#xA;  3 Total time:   0.155251 ~&#xA;  4  Self time:   0.002006 ~&#xA;  5  ~&#xA;  6 count  total (s)   self (s) ~&#xA;  7   9          0.000096   for i in range(8) ~&#xA;  8   8   0.153655   0.000410     call Test3() ~&#xA;  9   8          0.000070   endfor ~&#xA; 10                 &quot; Ask a question ~&#xA; 11   1          0.001341   echo input(&quot;give me an answer: &quot;) ~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;The header (lines 1-4) gives the time for the whole function.  The &quot;Total&quot;&#xA;  time is the time passed while the function was executing.  The &quot;Self&quot; time is&#xA;  the &quot;Total&quot; time reduced by time spent in:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;other user defined functions&lt;/li&gt;&#xA;  &lt;li&gt;sourced scripts&lt;/li&gt;&#xA;  &lt;li&gt;executed autocommands&lt;/li&gt;&#xA;  &lt;li&gt;external (shell) commands&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Lines 7-11 show the time spent in each executed line.  Lines that are not&#xA;  executed do not count.  Thus a comment line is never counted.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The Count column shows how many times a line was executed.  Note that the&#xA;  &quot;for&quot; command in line 7 is executed one more time as the following lines.&#xA;  That is because the line is also executed to detect the end of the loop.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The time Vim spends waiting for user input isn't counted at all.  Thus how&#xA;  long you take to respond to the input() prompt is irrelevant.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Profiling should give a good indication of where time is spent, but keep in&#xA;  mind there are various things that may clobber the results:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;p&gt;The accuracy of the time measured depends on the gettimeofday() system&#xA;  function.  It may only be as accurate as 1/100 second, even though the times&#xA;  are displayed in micro seconds.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Real elapsed time is measured, if other processes are busy they may cause&#xA;  delays at unpredictable moments.  You may want to run the profiling several&#xA;  times and use the lowest results.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;If you have several commands in one line you only get one time.  Split the&#xA;  line to see the time for the individual commands.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;The time of the lines added up is mostly less than the time of the whole&#xA;  function.  There is some overhead in between.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Functions that are deleted before Vim exits will not produce profiling&#xA;  information.  You can check the |v:profiling| variable if needed: &gt;&#xA;      :if !v:profiling&#xA;      :   delfunc MyFunc&#xA;      :endif&#xA;  &amp;lt;&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Profiling may give weird results on multi-processor systems, when sleep&#xA;  mode kicks in or the processor frequency is reduced to save power.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;The &quot;self&quot; time is wrong when a function is used recursively.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The preamble suggests that lines are of one of two forms:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;clock   self+sourced   self:  sourced script&#xA;clock   elapsed:              other lines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Interpreting form 1 lines seems straightforward, with times corresponding to the described event. However, I'm not sure what exactly is meant by other lines (assuming I've interpreted the preamble correctly).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are 2 types of lines in the output; those with 4 fields:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;015.671  001.128       001.128:  sourcing /usr/local/share/vim/vim82/syntax/syncolor.vim&#xA;^^^^^^^  ^^^^^^^       ^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&#xA;field 1  field 2       field 3   field 4&#xA;clock    self+sourced  self:     sourced script&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And those with 3 fields:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;000.149  000.138:  Allocated generic buffers&#xA;^^^^^^^  ^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^^^^&#xA;field 1  field 2   field 3&#xA;clock    elapsed   other lines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;other lines&quot; refers to the third field in lines with only 3 fields.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For the form 2 lines, what are the definitions of self+sourced and self? I have assumed the former corresponds to loading time including time for recursively :source'd files, and the latter corresponds to loading time excluding time for recursively :source'd files.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;self&lt;/code&gt; has the same meaning as in the output of &lt;code&gt;:prof start&lt;/code&gt;, it's documented like this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The &quot;Self&quot; time is the &quot;Total&quot; time reduced by time spent in:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;other user defined functions&lt;/li&gt;&#xA;  &lt;li&gt;sourced scripts&lt;/li&gt;&#xA;  &lt;li&gt;executed autocommands&lt;/li&gt;&#xA;  &lt;li&gt;external (shell) commands&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What does the sourcing vimrc file(s) line's time represent? There is a separate line for $HOME/.vimrc, with a time greater than given for sourcing vimrc file(s).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Just a guess, but it may be the time taken by Vim to find the vimrc file on your system...&#xA;If you want to look at the source code, the relevant line is &lt;a href=&quot;https://github.com/vim/vim/blob/28e4c8d9f0e976dfa05b2ea97cfbe926f88d403c/src/main.c#L2706&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Similarly, what does the loading plugins line's time represent? The preceding lines also correspond to plugins, and the sum of the times does not match the loading plugins time.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Again, just a guess, but it may be the time taken by Vim to find all your plugin files on your system (i.e. all the files in your runtime path matching the glob &lt;code&gt;plugin/**/*.vim&lt;/code&gt;)...&#xA;If you want to look at the source code, the relevant line is &lt;a href=&quot;https://github.com/vim/vim/blob/28e4c8d9f0e976dfa05b2ea97cfbe926f88d403c/src/main.c#L568&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-01-09T08:38:22.673" LastActivityDate="2020-01-09T08:38:22.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22473" PostTypeId="2" ParentId="22470" CreationDate="2020-01-09T08:33:24.497" Score="1" Body="&lt;h3&gt;&lt;code&gt;:Substitute&lt;/code&gt; for visual block from plugin &lt;a href=&quot;https://github.com/chrisbra/csv.vim#substitute-in-columns&quot; rel=&quot;nofollow noreferrer&quot;&gt;csv.vim&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;For single-space separated data you have to initialize the plugin csv.vim manually as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim mydata&#xA;:setf csv&#xA;:let g:csv_delim=' '&#xA;:CSVInit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use the &lt;code&gt;:Substitute&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Select part of a column with a visual block (e.g. &lt;code&gt;5\n8&lt;/code&gt;) and then run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;Substitute \d*/\=printf('%.3f', str2nr(submatch(0))*0.7)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2020-01-09T09:07:05.233" LastActivityDate="2020-01-09T09:07:05.233" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22474" PostTypeId="2" ParentId="22470" CreationDate="2020-01-09T08:46:49.703" Score="2" Body="&lt;h3&gt;&lt;code&gt;:B&lt;/code&gt; from plugin &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1195&quot; rel=&quot;nofollow noreferrer&quot;&gt;vis.vim&lt;/a&gt; by &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#VIS&quot; rel=&quot;nofollow noreferrer&quot;&gt;DrChip&lt;/a&gt;: &lt;code&gt;:B s/pattern/becomes/&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This plugin provides a general command to make all colon commands to operate only on the visual block selection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;B s/\d*/\=printf('%.3f', str2nr(submatch(0))*0.7)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2020-01-09T09:07:14.943" LastActivityDate="2020-01-09T09:07:14.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22475" PostTypeId="2" ParentId="22470" CreationDate="2020-01-09T08:54:27.710" Score="6" Body="&lt;p&gt;You could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V\d*\%V\d/\=printf('%.3f', str2nr(submatch(0))*0.7)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more info, see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h /\%V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h printf()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Figure could be 5, 5.0, 5.00 or 5.000, 12345678.000, 3 digits at most. How can we define a more general grouped part?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Try a more permissive pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V\d*\.\=\d*\%V\d/\=printf('%.3f', str2float(submatch(0))*0.7)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-01-09T10:06:56.500" LastActivityDate="2020-01-09T10:06:56.500" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22476" PostTypeId="2" ParentId="15234" CreationDate="2020-01-09T09:21:38.003" Score="1" Body="&lt;p&gt;Try plugin &lt;a href=&quot;https://github.com/jaxbot/semantic-highlight.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/jaxbot/semantic-highlight.vim&lt;/a&gt; (see also the &lt;a href=&quot;https://medium.com/@evnbr/coding-in-color-3a6db2743a1e&quot; rel=&quot;nofollow noreferrer&quot;&gt;article&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To install (with Plug plugin manager), set in .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'jaxbot/semantic-highlight.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Default colors fight with colorscheme I use (tender), so I set in  vimrc colors to: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:semanticTermColors = [3,124,30,32,33,64,66,67,69,99,101,102,103,104,132,133,135,136,137,164,165,166,167,168,169,170,198,200]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="983" LastActivityDate="2020-01-09T09:21:38.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22477" PostTypeId="1" CreationDate="2020-01-09T09:33:29.983" Score="2" ViewCount="421" Body="&lt;p&gt;I now use plugin &lt;a href=&quot;https://github.com/pangloss/vim-javascript&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-javascript&lt;/a&gt; just to have a nice syntax highlight for &lt;a href=&quot;https://jsdoc.app/&quot; rel=&quot;nofollow noreferrer&quot;&gt;JsDoc&lt;/a&gt; comments in my Javascript files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/pangloss/vim-javascript&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-javascript&lt;/a&gt; provides nice colors highlight but it conflict with all  parentheses highlighters plugins I tried, like nice &lt;a href=&quot;https://github.com/luochen1990/rainbow&quot; rel=&quot;nofollow noreferrer&quot;&gt;rainbow&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I want to dismiss &lt;a href=&quot;https://github.com/pangloss/vim-javascript&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-javascript&lt;/a&gt; that seems the cause of conflict.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question:&#xA;there is any vim stand-alone plugin to just do JsDoc syntax highlight (substituting vim-javascript highlighting) that doesn't conflict with parentheses highlighters?&lt;/p&gt;&#xA;" OwnerUserId="983" LastActivityDate="2020-01-09T09:33:29.983" Title="Javascript syntax-highlight for JsDoc comments" Tags="|syntax-highlighting|comments|filetype-javascript|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22478" PostTypeId="2" ParentId="22469" CreationDate="2020-01-09T11:06:05.740" Score="6" Body="&lt;p&gt;You could use a substitution command like this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&quot;\(\d\+\).*:\zs.\+\ze&quot;/\=submatch(1)+1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command can be decomposed in these several parts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt; is the range of lines you want to apply the command to. &lt;code&gt;%&lt;/code&gt; is all the lines in the buffer, check &lt;a href=&quot;http://vimhelp.appspot.com/cmdline.txt.html#%3Arange&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h :range&lt;/code&gt;&lt;/a&gt; for more options&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s/ [...] / [...]&lt;/code&gt; is the substitution which will replace the first part by a second one&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;\(\d\+\).*:\zs.\+\ze&quot;&lt;/code&gt; This is the part used to match the text you want to act on, several things are going on here:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;&lt;/code&gt; is the first litteral &lt;code&gt;&quot;&lt;/code&gt; before the number you want to increment&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\d\+&lt;/code&gt; is the number you will need to increment&lt;/li&gt;&#xA;&lt;li&gt;the number is surrounded by &lt;code&gt;\( ... \)&lt;/code&gt; to tell vim that we should capture this value to reuse it later on&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.*:&lt;/code&gt; are all the characters between the end of your number and the &lt;code&gt;xxx&lt;/code&gt; you'll need to replace&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs ... \ze&lt;/code&gt; are used to say to vim that the part we actually want to change is between these two markers see &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5czs&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h /\zs&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5cze&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h /\ze&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.\+&lt;/code&gt; inside the &lt;code&gt;\zs ... \ze&lt;/code&gt;  is are all the characters we want to replace (your &lt;code&gt;xxx&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\=submatch(1)+1&lt;/code&gt; is the second part of the command: what we will replace our text with&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\=&lt;/code&gt; indicates that we will replace with the result of the evaluated expression following on. See &lt;a href=&quot;http://vimhelp.appspot.com/change.txt.html#sub-replace-expression&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h sub-replace-expression&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;submatch(1)&lt;/code&gt; is used to get the value of the captured string in the first part. &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#%2f%5c%3d&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h /\=&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;and finally &lt;code&gt;+1&lt;/code&gt; is used to increment the value&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2020-01-09T11:06:05.740" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22479" PostTypeId="2" ParentId="22469" CreationDate="2020-01-09T12:39:09.340" Score="5" Body="&lt;p&gt;You can do this with a macro. Start by placing your cursor at the very start of the file &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;g&lt;/kbd&gt; and then type the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;Ctrl-A&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This records a macro that will update a single line in the way you require. Then undo your changes &lt;kbd&gt;u&lt;/kbd&gt;&lt;kbd&gt;u&lt;/kbd&gt; and play the macro on every line of the file by entering the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm @q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How the macro works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; Start recording a macro into register &lt;code&gt;&quot;q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;&quot;&lt;/kbd&gt; Yank the contents of the next double-quoted string on the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt; Jump to the second &lt;code&gt;x&lt;/code&gt; after the cursor.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; Visually select the word &lt;code&gt;xxx&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;p&lt;/kbd&gt; Replace the visual selection with the yanked text.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-A&lt;/kbd&gt; Increment the number.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt; Stop recording.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-01-09T12:39:09.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22480" PostTypeId="1" CreationDate="2020-01-09T13:11:46.670" Score="1" ViewCount="1249" Body="&lt;p&gt;I am using the setup I found in this answer: &lt;a href=&quot;https://stackoverflow.com/a/22253548/2241241&quot;&gt;UltiSnips and YouCompleteMe&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;namely:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; if you use Vundle, load plugins:&#xA;Bundle 'ervandew/supertab'&#xA;Bundle 'Valloric/YouCompleteMe'&#xA;Bundle 'SirVer/ultisnips'&#xA;&#xA;&amp;quot; make YCM compatible with UltiSnips (using supertab)&#xA;let g:ycm_key_list_select_completion = ['&amp;lt;C-n&amp;gt;', '&amp;lt;Down&amp;gt;']&#xA;let g:ycm_key_list_previous_completion = ['&amp;lt;C-p&amp;gt;', '&amp;lt;Up&amp;gt;']&#xA;let g:SuperTabDefaultCompletionType = '&amp;lt;C-n&amp;gt;'&#xA;&#xA;&amp;quot; better key bindings for UltiSnipsExpandTrigger&#xA;let g:UltiSnipsExpandTrigger = &amp;quot;&amp;lt;tab&amp;gt;&amp;quot;&#xA;let g:UltiSnipsJumpForwardTrigger = &amp;quot;&amp;lt;tab&amp;gt;&amp;quot;&#xA;let g:UltiSnipsJumpBackwardTrigger = &amp;quot;&amp;lt;s-tab&amp;gt;&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I am working on a &lt;code&gt;tex&lt;/code&gt; document, and trying to insert the snippet in the screenshot. Pressing tab, or ctrl-n will cycle me through the options presented, but I can't for the life of me insert the snippet. Pressing enter, space of just continuing with { just behaves as if I were typing (which I guess is what is to be expected, but I had no better idea).&lt;/p&gt;&#xA;&lt;p&gt;What do I need to do to insert the snippet shown there?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oobmW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oobmW.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25312" LastEditorUserId="23502" LastEditDate="2023-01-24T15:07:01.370" LastActivityDate="2024-02-18T17:06:10.697" Title="How to insert a snippet with UltiSnips?" Tags="|plugin-you-complete-me|plugin-ultisnips|snippets|plugin-supertab|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22481" PostTypeId="2" ParentId="22461" CreationDate="2020-01-09T20:23:32.610" Score="2" Body="&lt;p&gt;Setting &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;wildignore&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;wildignore&lt;/a&gt; can have quite a  few side effects (especially if done globally).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I would do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:prefix = '/path/to/folder'&#xA;&#xA;let files = filter(glob(prefix . '/**/*.bak', 1, 1), &quot;fnamemodify(v:val, ':e') != 'bak'&quot;)&#xA;&#xA;for fname in files&#xA;    execute 'source' fname&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22630" LastActivityDate="2020-01-09T20:23:32.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22482" PostTypeId="2" ParentId="22480" CreationDate="2020-01-09T23:12:54.297" Score="0" Body="&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:UltiSnipsExpandTrigger = '&amp;lt;c-g&amp;gt;'&#xA;    &quot;strange that I have to change this&#xA;    let g:SuperTabMappingForward = '&amp;lt;s-tab&amp;gt;'&#xA;    let g:SuperTabMappingBackward = '&amp;lt;tab&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;go to the snip option in the menu, and press &lt;code&gt;ctrl-g&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Originally, it supposed to be tab, what expands. But supertab has taken control over tab. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2020-01-10T11:38:51.567" LastActivityDate="2020-01-10T11:38:51.567" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22483" PostTypeId="2" ParentId="13630" CreationDate="2020-01-09T23:58:02.117" Score="0" Body="&lt;p&gt;Let's consider our cursor at the first line, column zero&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f' ....................... jumps to the first single quote&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use visual block selection to cut the three first lines&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ctrl-v ................... starts visual block selection&#xA;2j ....................... expands to the next two lines&#xA;$ ........................ makes selection expand to the end of the lines&#xA;A;&amp;lt;Esc&amp;gt; .................. inserts semicolon at the end of selected lines&#xA;gv ....................... repeat selection&#xA;x ........................ cut contents&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now lets jump to the second part&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3j ........................ goes down to the fourth line&#xA;A ......................... starts insert at the end of the third line&#xA;Ctrl-r Ctrl-o &quot; ........... paste our cutted lines&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more see: &lt;code&gt;:h i_Ctrl-r&lt;/code&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt; inserts the content of a register literally and don't autoindent&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to set all these keystrokes as a macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=&quot;gg0f'\&amp;lt;c-v&amp;gt;2j$A;\&amp;lt;esc&amp;gt;gvx3jA\&amp;lt;c-r&amp;gt;\&amp;lt;c-o&amp;gt;\&quot;\&amp;lt;esc&amp;gt;&quot;&#xA;@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="7339" LastEditDate="2020-01-10T00:09:02.153" LastActivityDate="2020-01-10T00:09:02.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22484" PostTypeId="1" AcceptedAnswerId="22488" CreationDate="2020-01-10T09:12:38.077" Score="6" ViewCount="854" Body="&lt;h2&gt;Background&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have a code file and I like to place comments inside my code. Sometimes, these comments are boxed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;defmodule BananasModule do&#xA;&#xA;    ##############&#xA;    # Public API #&#xA;    ##############&#xA;&#xA;    def function_blabla do .....&#xA;end&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Objective&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;My objective is to have a key sequence (a macro, for example) that surrounds the line I am at with a boxed comment. For example, given the following file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;defmodule BananasModule do&#xA;&#xA;&#xA;    &amp;lt;cursor&amp;gt; Public API&#xA;&#xA;    def function_blabla do .....&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After using some command, I would ideally get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;defmodule BananasModule do&#xA;&#xA;    ##############&#xA;    # Public API #&#xA;    ##############&#xA;&#xA;end&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do notice how the comment box &lt;em&gt;is indented&lt;/em&gt;. This is very important. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What I have tried&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have tried out the &lt;a href=&quot;https://github.com/preservim/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDCommenter&lt;/a&gt; plugin, but unfortunately it doesn't have this feature. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried to create a macro &lt;a href=&quot;https://vi.stackexchange.com/questions/16989/vim-comment-box-macro&quot;&gt;following this discussion&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a = &quot;I## \&amp;lt;Esc&amp;gt;A ##\&amp;lt;Esc&amp;gt;yyPVr#jpVr#&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the commend box I get after executing &lt;code&gt;@a&lt;/code&gt; is not indented:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;defmodule BananasModule do&#xA;&#xA;####################&#xA;    ## Public API ##&#xA;####################&#xA;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Although I feel like I came close, I don't know enough about macros and configurations to make my comment boxes indented.&lt;/p&gt;&#xA;" OwnerUserId="26431" LastEditorUserId="10604" LastEditDate="2020-01-11T16:29:31.543" LastActivityDate="2023-05-22T21:40:54.027" Title="Create indented comment box vim" Tags="|comments|text-generation|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22485" PostTypeId="1" AcceptedAnswerId="22490" CreationDate="2020-01-10T09:25:57.307" Score="2" ViewCount="263" Body="&lt;p&gt;I'm trying to get &lt;code&gt;%&lt;/code&gt; to match custom keyword pairs&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With vim matchit, I can do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:match_words=&#xA;            \ '\&amp;lt;Start\&amp;gt;:\&amp;lt;Stop\&amp;gt;' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to match &lt;code&gt;Start&lt;/code&gt; and &lt;code&gt;Stop&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to match &lt;code&gt;Start&lt;/code&gt; with either &lt;code&gt;Stop&lt;/code&gt; or &lt;code&gt;Stop2&lt;/code&gt;. How can I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:match_words=&#xA;            \ '\&amp;lt;Start\&amp;gt;:\&amp;lt;Stop\&amp;gt;,' .&#xA;            \ '\&amp;lt;Start\&amp;gt;:\&amp;lt;Stop2\&amp;gt;' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but then &lt;code&gt;%&lt;/code&gt; only jumps from &lt;code&gt;Stop&lt;/code&gt;/&lt;code&gt;Stop2&lt;/code&gt; to &lt;code&gt;Start&lt;/code&gt; but not from &lt;code&gt;Start&lt;/code&gt; to &lt;code&gt;Stop2&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have instances where I'd like where multiple possible start words should match with a single stop word (I don't think I have one where both the start and the stop have multiple spellings, if this matters.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can this kind of matching be done in vim?&lt;/p&gt;&#xA;" OwnerUserId="4738" LastEditorUserId="4738" LastEditDate="2020-01-10T09:32:12.040" LastActivityDate="2020-01-10T10:26:45.187" Title="Alternate ending word in vim matchit pairs" Tags="|plugin-matchit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22487" PostTypeId="1" AcceptedAnswerId="22489" CreationDate="2020-01-10T09:42:46.323" Score="6" ViewCount="1972" Body="&lt;p&gt;I would like to save files without exiting the INSERT mode. Is it possible? How?&lt;/p&gt;&#xA;" OwnerUserId="26408" LastActivityDate="2020-01-10T10:49:23.970" Title="Saving file from INSERT mode" Tags="|insert-mode|save|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22488" PostTypeId="2" ParentId="22484" CreationDate="2020-01-10T10:10:38.550" Score="7" Body="&lt;p&gt;Well, &quot;put text into a box&quot; is a well-known Vim excercise. I'm not sure where I saw it for the first time, but the most elegant solution, IMO, is to use &lt;code&gt;:h v_r&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;# I#&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt;A&amp;lt;Space&amp;gt;#&amp;lt;Esc&amp;gt;yy2P&amp;lt;C-V&amp;gt;$r#2j.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;I#&amp;lt;Space&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; --- add &quot;# &quot; at the start of line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;A&amp;lt;Space&amp;gt;#&amp;lt;Esc&amp;gt;&lt;/code&gt; --- add &quot; #&quot; at the end of line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;yy2P&lt;/code&gt; --- make 2 copies of the current line (so we have three identical &lt;code&gt;# text #&lt;/code&gt; lines)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-V&amp;gt;$r#&lt;/code&gt; --- change the top line into &lt;code&gt;#####&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;2j.&lt;/code&gt; -- and the same for bottom line&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2020-01-10T12:03:32.353" LastActivityDate="2020-01-10T12:03:32.353" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22489" PostTypeId="2" ParentId="22487" CreationDate="2020-01-10T10:11:00.420" Score="7" Body="&lt;p&gt;Yes, just use the &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-O&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;&lt;/a&gt; keystroke to temporarily leave insert mode for a single command. You can then run &lt;code&gt;:w&amp;lt;CR&amp;gt;&lt;/code&gt; to write the file and you'll be back to insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use that to create a mapping in insert mode and assign that to a key combination such as &lt;code&gt;&amp;lt;F3&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt;, using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;F3&amp;gt; &amp;lt;C-O&amp;gt;:w&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Avoid a keystroke such as &lt;code&gt;&amp;lt;C-S&amp;gt;&lt;/code&gt; (&quot;S&quot; for &quot;Save&quot;) since that specific keystroke can be a problem in many terminals or sometimes through remote connections... &lt;code&gt;&amp;lt;C-S&amp;gt;&lt;/code&gt; is the code for XOFF, which historically has been used to pause a terminal and it's still a valid terminal command in most modern terminals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use a key such as &lt;code&gt;&amp;lt;F3&amp;gt;&lt;/code&gt;, you might want to also map it in normal mode (without the &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; in that case) and visual mode, etc. so that it works regardless of which mode you're currently on.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-01-10T10:49:23.970" LastActivityDate="2020-01-10T10:49:23.970" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22490" PostTypeId="2" ParentId="22485" CreationDate="2020-01-10T10:26:45.187" Score="3" Body="&lt;p&gt;The matchit plug-in takes regular expressions for its matches from &lt;code&gt;b:match_words&lt;/code&gt;, so you can easily use a regular expression that matches both possible end keywords to accomplish that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your specific case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:match_words= '\&amp;lt;Start\&amp;gt;:\&amp;lt;Stop2\?\&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But assuming the end keywords a don't have any common parts, let's say &lt;code&gt;Stop&lt;/code&gt; or &lt;code&gt;Finish&lt;/code&gt;, then you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:match_words= '\&amp;lt;Start\&amp;gt;:\&amp;lt;\(Stop\|Finish\)\&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/vim/vim/blob/v8.2.0/runtime/pack/dist/opt/matchit/doc/matchit.txt#L244&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help b:match_words&lt;/code&gt;&lt;/a&gt; for all the details on what is supported through that setting.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-10T10:26:45.187" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22491" PostTypeId="1" AcceptedAnswerId="22494" CreationDate="2020-01-10T15:19:15.923" Score="3" ViewCount="78" Body="&lt;p&gt;I'm trying to utilize &lt;code&gt;section&lt;/code&gt; movement via &lt;code&gt;[[&lt;/code&gt;, &lt;code&gt;]]&lt;/code&gt; and friends, but I'm not seeing the behavior I'm expecting given my understanding of the documentation.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A section begins after a form-feed () in the first column and at each of&#xA;  a set of section macros, specified by the pairs of characters in the&#xA;  a set of section macros, specified by the pairs of characters in the&#xA;  'sections' option.  The default is &quot;SHNHH HUnhsh&quot;, which defines a section to&#xA;  start at the nroff macros &quot;.SH&quot;, &quot;.NH&quot;, &quot;.H&quot;, &quot;.HU&quot;, &quot;.nh&quot; and &quot;.sh&quot;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The &quot;]&quot; and &quot;[&quot; commands stop at the '{' or '}' in the first column.  This is&#xA;  useful to find the start or end of a function in a C program.  Note that the&#xA;  first character of the command determines the search direction and the&#xA;  second character the type of brace found.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Granted, I don't understand nroff macros, so maybe that's the gap, but the second paragraph mentions moving to the next '{' or '}' character in the first column. However, when I type &lt;code&gt;]]&lt;/code&gt; or &lt;code&gt;[[&lt;/code&gt;, I move to the bottom or top of the file, instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested in JS, CSS, HTML, and PHP files, and since vim's defaults are mostly for C, I tried again in a C file, but all with the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something I'm missing about this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tested in vim and nvim with &lt;code&gt;-u NONE&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the C file (which I expect to work the best) that I'm testing against.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;// My comment&#xA;&#xA;void main() {&#xA;   void a, b;&#xA;&#xA;   a = 11;&#xA;   b = 99;&#xA;&#xA;   printf(&quot;Values before swapping - \n a = %d, b = %d \n\n&quot;, a, b);&#xA;&#xA;   a = a + b;  // ( 11 + 99 = 110)&#xA;   b = a - b;  // ( 110 - 99 = 11)&#xA;   a = a - b;  // ( 110 - 11 = 99)&#xA;&#xA;   // another comment&#xA;   printf(&quot;Values after swapping - \n a = %d, b = %d \n&quot;, a, b);&#xA;}&#xA;&#xA;int yo() {&#xA;    printf(&quot;hi there&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14" LastEditorUserId="14" LastEditDate="2020-01-10T19:19:33.417" LastActivityDate="2020-01-11T07:52:26.880" Title="&quot;[[&quot; and &quot;]]&quot; jump to top and bottom of file instead of expected behavior" Tags="|movement|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22492" PostTypeId="2" ParentId="22484" CreationDate="2020-01-10T16:15:02.640" Score="1" Body="&lt;p&gt;This can be best accomplished with &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ultisnips&lt;/a&gt; and &lt;a href=&quot;https://github.com/honza/vim-snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-snippet&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim-snippets provides a snippet &lt;a href=&quot;https://github.com/honza/vim-snippets/blob/master/UltiSnips/all.snippets#L22&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;box&lt;/code&gt;&lt;/a&gt; which can create a bounded box. It is just what you want. I have tested on a Python source file and it works great. Give it a try.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastEditorUserId="15292" LastEditDate="2020-05-06T02:11:20.717" LastActivityDate="2020-05-06T02:11:20.717" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22493" PostTypeId="1" AcceptedAnswerId="22496" CreationDate="2020-01-10T20:29:45.177" Score="1" ViewCount="75" Body="&lt;p&gt;For generating different placeholders like emails, names, and passwords, &lt;a href=&quot;https://github.com/tkhren/vim-fake&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-fake&lt;/a&gt; looks like a really useful tool. The problem is that I'm using &lt;a href=&quot;https://github.com/sirver/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt; and vim-fake is seemingly designed for &lt;a href=&quot;https://github.com/Shougo/neosnippet.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;neosnippet&lt;/a&gt;—the snippets can be found &lt;a href=&quot;https://gist.github.com/tkhren/9fbc7227c2e9d2f4319c&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&#xA;Taking this simple code which is written for neosnippet,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet fakeint&#xA;abbr    fake#int()&#xA;options word&#xA;    `fake#int()`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way to write something equivalent for UltiSnips environment? I already tried the following codes but got no results.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet fakeint&#xA;`fake#int()`&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and also,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet fakeint&#xA;`echo fake#int()`&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23287" LastActivityDate="2020-01-10T22:12:42.320" Title="How to make vim-fake compatible with UltiSnips?" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22494" PostTypeId="2" ParentId="22491" CreationDate="2020-01-10T21:38:10.017" Score="2" Body="&lt;p&gt;You’re misunderstanding the motions. &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt; both only move to a &lt;code&gt;{&lt;/code&gt; character in the first column (backwards and forwards, respectively), which your file does not have. To jump to a &lt;code&gt;}&lt;/code&gt; you need to use &lt;code&gt;[]&lt;/code&gt; and &lt;code&gt;][&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to find this hard to remember until someone on this site suggested that the way to remember it is that the first bracket tells you the direction of travel and then you press it again for the start of the function or press the other bracket for the end.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-10T23:28:48.377" LastActivityDate="2020-01-10T23:28:48.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22495" PostTypeId="1" CreationDate="2020-01-10T22:00:26.813" Score="1" ViewCount="382" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/vim-airline/vim-airline&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-airline&lt;/a&gt; plugin for my statusline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to install &lt;a href=&quot;https://kite.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;kite&lt;/a&gt; which suggests adding a section to the statusline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried adding using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%{kite#statusline()}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that just messes up my statusline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do it properly?&lt;/p&gt;&#xA;" OwnerUserId="26459" LastEditorUserId="26459" LastEditDate="2020-01-10T22:08:41.890" LastActivityDate="2020-01-10T22:08:41.890" Title="Add to statusline" Tags="|vimrc|statusline|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22496" PostTypeId="2" ParentId="22493" CreationDate="2020-01-10T22:12:42.320" Score="1" Body="&lt;p&gt;The syntax to use a Vimscript expression in UltiSnips is &lt;code&gt;`!v ...`&lt;/code&gt;, so I think what you're looking for is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet fakeint&#xA;`!v fake#int()`&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/96026a4df27899b9e4029dd3b2977ad2ed819caf/doc/UltiSnips.txt#L822&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help UltiSnips-vimscript&lt;/code&gt;&lt;/a&gt; for all the details.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that you don't necessarily need to use a snippet manager to use the vim-fake functions, in Insert mode you could simply use &lt;code&gt;CTRL-R =&lt;/code&gt; to insert the contents of an expression, then type the expression itself &lt;code&gt;fake#int()&lt;/code&gt; (note that Tab completion should help you here) and finally press Enter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This technique should allow you to insert the result of any Vimscript expressions in your text without having to configure them in your snippet manager.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-10T22:12:42.320" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22497" PostTypeId="1" AcceptedAnswerId="41716" CreationDate="2020-01-11T00:46:17.523" Score="7" ViewCount="2136" Body="&lt;p&gt;I've been doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufWrite * if ! &amp;amp;bin | silent! %s/\s\+$//ge | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that it moves the cursor sometimes when I save the file.&lt;/p&gt;&#xA;" OwnerUserId="26215" LastActivityDate="2023-04-01T18:01:23.673" Title="How do I trim whitespace automatically?" Tags="|autocmd|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22498" PostTypeId="2" ParentId="22497" CreationDate="2020-01-11T00:55:42.747" Score="8" Body="&lt;p&gt;Try this:   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePre * %s/\s\+$//e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you want to do this for BufReadPre as well you can&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/356126/how-can-you-automatically-remove-trailing-whitespace-in-vim&quot;&gt;https://stackoverflow.com/questions/356126/how-can-you-automatically-remove-trailing-whitespace-in-vim&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22630" LastActivityDate="2020-01-11T00:55:42.747" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22499" PostTypeId="1" CreationDate="2020-01-11T03:31:05.230" Score="2" ViewCount="196" Body="&lt;p&gt;I know it should be easy, but somehow I don’t get it right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got a text with &lt;strong&gt;artist_id&lt;/strong&gt;, &lt;strong&gt;album_id&lt;/strong&gt;,... and want to replace them with just &lt;strong&gt;id&lt;/strong&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;:%s/[a-z]+_id/id/gc&lt;/code&gt;, but it did not work.&lt;/p&gt;&#xA;" OwnerUserId="26464" LastEditorUserId="28" LastEditDate="2020-01-11T12:45:46.103" LastActivityDate="2020-01-12T12:44:48.347" Title="How to search and replace more than character and a string in vim" Tags="|regular-expression|search|replace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22500" PostTypeId="2" ParentId="22499" CreationDate="2020-01-11T03:43:47.097" Score="4" Body="&lt;p&gt;If you read &lt;code&gt;:help pattern&lt;/code&gt;, you’ll see you need &lt;code&gt;\+&lt;/code&gt;. Vim’s patterns are not quite like PCRE or POSIX B/ERE&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-01-11T15:01:32.450" LastActivityDate="2020-01-11T15:01:32.450" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22501" PostTypeId="2" ParentId="10787" CreationDate="2020-01-11T05:35:43.867" Score="0" Body="&lt;p&gt;Just a quick test on &lt;code&gt;:VimwikiSearchTags&lt;/code&gt; vs &lt;code&gt;Ripgrep&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FTW - I'm going to stick with &lt;a href=&quot;https://github.com/jremmen/vim-ripgrep&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/jremmen/vim-ripgrep&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Rg -i :tag-example&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26466" LastEditorUserId="10604" LastEditDate="2020-01-11T16:26:42.380" LastActivityDate="2020-01-11T16:26:42.380" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22503" PostTypeId="2" ParentId="22491" CreationDate="2020-01-11T07:52:26.880" Score="1" Body="&lt;h3&gt;&lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt; for Egyptian style of curly braces&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;vim help &lt;code&gt;(:h section)&lt;/code&gt; suggests following remapping if you add the opening curly brace to the end of the function header and not on a separate line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map [[ ?{&amp;lt;CR&amp;gt;w99[{&#xA;map ]] j0[[%/{&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They are not perfect, e.g. they mess up your search history.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Btw: following ftplugins redefine &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt; for you with this style of coding in mind:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/3c2881dc1195f53ebafc387378399ddd6cb677a7/runtime/ftplugin/rust.vim#L106-L112&quot; rel=&quot;nofollow noreferrer&quot;&gt;$VIMRUNTIME/ftplugin/rust.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/9a7224b5a0639c26c843c10afcafa5bf149271fd/runtime/ftplugin/php.vim#L69-L72&quot; rel=&quot;nofollow noreferrer&quot;&gt;$VIMRUNTIME/ftplugin/php.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/fatih/vim-go/blob/c4377cd924b3138fe007b96e1d177e9258363c3f/ftplugin/go.vim#L66-L74&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/fatih/vim-go&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For c/c++ there is &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-cpp&lt;/a&gt; which also redefines &lt;code&gt;[[&lt;/code&gt; and &lt;code&gt;]]&lt;/code&gt;. However, it depends IMHO on too many plugins (&lt;code&gt;lh-vim-lib&lt;/code&gt;, &lt;code&gt;lh-style&lt;/code&gt;, &lt;code&gt;lh-brackets&lt;/code&gt;, &lt;code&gt;mu-template&lt;/code&gt;, &lt;code&gt;lh-dev&lt;/code&gt;, &lt;code&gt;alternate-lite&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am still looking for a more lightweight solution. Maybe the inclusion of treesitter  in neovim can help here too. Other relevant projects are: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/libclang-vim/libclang-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/libclang-vim/libclang-vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/libclang-vim/vim-textobj-clang&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/libclang-vim/vim-textobj-clang&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2020-01-11T07:52:26.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22504" PostTypeId="2" ParentId="22257" CreationDate="2020-01-11T08:39:46.920" Score="0" Body="&lt;p&gt;Consider using &lt;a href=&quot;https://github.com/garbas/vim-snipmate&quot; rel=&quot;nofollow noreferrer&quot;&gt;snipmate&lt;/a&gt; and defining snippets for these operations.&lt;/p&gt;&#xA;" OwnerUserId="26215" LastActivityDate="2020-01-11T08:39:46.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22505" PostTypeId="2" ParentId="22459" CreationDate="2020-01-11T13:31:41.357" Score="4" Body="&lt;p&gt;As pointed in the comments, it is a current bug that is still open.&#xA;There is a workaround:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add in the vimrc configuration file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gx :!xdg-open &amp;lt;cWORD&amp;gt; &amp;amp;&amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The original github discussion was referencing to this one below, but comments made it possible an improved version.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap gx yiW:!xdg-open &amp;lt;cWORD&amp;gt;&amp;lt;CR&amp;gt; &amp;lt;C-r&amp;gt;&quot; &amp;amp; &amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1682" LastEditorUserId="1682" LastEditDate="2020-01-11T16:24:44.343" LastActivityDate="2020-01-11T16:24:44.343" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22507" PostTypeId="1" AcceptedAnswerId="22509" CreationDate="2020-01-12T00:33:31.940" Score="1" ViewCount="290" Body="&lt;p&gt;I'm trying to remove (non-consecutive) duplicate lines in a file I have loaded in vim (without sorting them). In several places on the web I've found the nugget &lt;code&gt;awk '!x[$0]++'&lt;/code&gt; as a pipe command that will do this, and indeed if I run this from my shell directly, i.e. &lt;code&gt;cat myfile | awk '!x[$0]++'&lt;/code&gt;, it works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in vim, I've tried selecting some lines in line-wise visual mode, then typing &lt;code&gt;:'&amp;lt;,'&amp;gt;!awk '!x[$0]++'&lt;/code&gt;, and I get an error of &lt;code&gt;cannot read file /tmp/nvimQFXXXX/31&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess would that in some way my syntax is not quite right, and maybe I need to somehow escape some of the characters? I've tried &lt;code&gt;\&lt;/code&gt; to escape various characters though, and I can't figure it out. I've looked in the help, but I don't see anything about escaping characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus points if you can wrap this up in a mapping and/or function; that's my end goal!&lt;/p&gt;&#xA;" OwnerUserId="91" LastEditorUserId="91" LastEditDate="2020-01-12T21:55:39.483" LastActivityDate="2020-01-15T15:55:27.427" Title="How can I create a command to remove non-consecutive duplicate lines?" Tags="|external-command|shell|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22508" PostTypeId="2" ParentId="22507" CreationDate="2020-01-12T01:41:08.277" Score="4" Body="&lt;p&gt;When I run &lt;code&gt;:%!awk '!x[$0]++'&lt;/code&gt; in my vim, I get &lt;code&gt;E34: No previous command&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I fixed it by escaping the &lt;code&gt;!&lt;/code&gt; (see &lt;code&gt;:help :!&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vim/autoload/uniq.vim&#xA;function uniq#operator(type, ...) abort&#xA;  let l:visual = a:0&#xA;  if l:visual&#xA;    '&amp;lt;,'&amp;gt;!awk '\!x[$0]++'&#xA;  else&#xA;    '[,']!awk '\!x[$0]++'&#xA;  endif&#xA;endfunction&#xA;&#xA;&quot; ~/.vim/plugin/uniq.vim&#xA;nnoremap U :set operatorfunc=uniq#operator&amp;lt;CR&amp;gt;g@&#xA;vnoremap U :&amp;lt;C-u&amp;gt;call uniq#operator(visualmode(), 1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The key &lt;code&gt;U&lt;/code&gt; is somewhat arbitrary. Replace at your leisure.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This follows my &lt;a href=&quot;https://github.com/benknoble/vimsort&quot; rel=&quot;nofollow noreferrer&quot;&gt;operator&lt;/a&gt; &lt;a href=&quot;https://github.com/benknoble/vimpbcopy&quot; rel=&quot;nofollow noreferrer&quot;&gt;plugins&lt;/a&gt; format, and defines a new operator. It works with any motion, though of course will always be linewise. It also works with visual mode.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-01-12T01:41:08.277" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22509" PostTypeId="2" ParentId="22507" CreationDate="2020-01-12T01:52:16.553" Score="3" Body="&lt;p&gt;From &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Arange%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :range!&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            Filter {range} lines through the external program&#xA;            {filter}.  Vim replaces the optional bangs with the&#xA;            latest given command and appends the optional [arg].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second &lt;code&gt;!&lt;/code&gt; is replaced with last shell cmd, I guess it expand to some command that read&#xA;the temp file, escape it should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;! awk '\!a[$0]++'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now wrapper it in a &lt;code&gt;command&lt;/code&gt; and &lt;code&gt;map&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;lt;leader&amp;gt;uu :UnsortUniq&amp;lt;cr&amp;gt;&#xA;command -range UnsortUniq &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;! awk '\!a[$0]++'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can also be done without &lt;code&gt;awk&lt;/code&gt;, although it's ugly compared to &lt;code&gt;awk&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:d={} | g/^/ if has_key(g:d, getline('.')) | d | else | let g:d[getline('.')]=1 | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It gets uglier if you wrapper it in a command that support range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -range UnsortUniq2 let g:d={} | &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;g/^/&#xA;      \ if has_key(g:d, getline('.')) | d | else | let g:d[getline('.')]=1 | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2020-01-12T01:52:16.553" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22510" PostTypeId="1" AcceptedAnswerId="22511" CreationDate="2020-01-12T03:18:53.970" Score="4" ViewCount="1720" Body="&lt;p&gt;In gVim there's &lt;code&gt;guioptions&lt;/code&gt; which lets you disable the gui-specific features. I'm curious if I can configure this in Neovim somehow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it can't be done across the board, what I want most is it be able to change the keyword completion menu, as it's not obeying the &lt;code&gt;Pmenu&lt;/code&gt; highlight group and the gray on gray is very hard to see.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0YZbi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0YZbi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24943" LastEditorUserId="24943" LastEditDate="2020-01-12T03:31:22.150" LastActivityDate="2020-01-12T09:20:39.823" Title="Can I configure nvim-qt to look like a terminal?" Tags="|neovim|neovim-qt|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22511" PostTypeId="2" ParentId="22510" CreationDate="2020-01-12T09:14:53.613" Score="5" Body="&lt;p&gt;Popup menu in neovim-qt is controlled by &lt;code&gt;GuiPopupmenu&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should add it to you &lt;code&gt;ginit.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GuiPopupmenu 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/33QGp.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/33QGp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not documented that well, I've found it somewhere in github issues.&#xA;You can also try look into neovim-qt shim layer to find out what else is there:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6zdvQ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6zdvQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-01-12T09:20:39.823" LastActivityDate="2020-01-12T09:20:39.823" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22512" PostTypeId="1" CreationDate="2020-01-12T09:20:19.390" Score="5" ViewCount="91" Body="&lt;p&gt;I run a Linux/GNOME laptop where the focus follows the mouse, and I have vim's &lt;code&gt;mousefocus&lt;/code&gt; feature turned on, so the selected viewport follows the mouse, too. But when I try to switch viewports using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; &lt;kbd&gt;j&lt;/kbd&gt; or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; &lt;kbd&gt;k&lt;/kbd&gt; (AKA, in vim help, &lt;code&gt;CTRL-W_j&lt;/code&gt; or &lt;code&gt;CTRL-W_k&lt;/code&gt;), the active viewport stays as whichever one the mouse is over. [&lt;strong&gt;UPDATE&lt;/strong&gt;: I've looked at this issue more carefully, and what actually happens is that the mouse cursor jumps to the centre of vim—not the centre of what vim calls a 'window', but what the window manager calls a window. And then whatever vim 'window' is under the cursor gets the focus.]&lt;/p&gt;&#xA;&lt;p&gt;The thing is, this is a new problem. I have a .vimrc file that's evolved since the 1990s, through dozens of machines on multiple platforms, and I don't remember having to deal with this issue before. Unfortunately, I don't have my old laptop to compare it with, and for various reasons, I made do without my .vimrc file on my new laptop until today. But other than it being an updated laptop, running a newer version of Linux Mint (Cinnamon) and a newer version of vim, and loading (seemingly unrelated) extensions via a plug-in manager, it's essentially the same setup I've had for years. (I have &lt;code&gt;set mouse=a&lt;/code&gt;, FWIW, which again is what it's been set to since before the turn of the century.)&lt;/p&gt;&#xA;&lt;p&gt;I think what happened on my previous laptops is that the mouse followed the active viewport in vim, if I used &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; &lt;kbd&gt;j&lt;/kbd&gt; or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt; &lt;kbd&gt;k&lt;/kbd&gt; to change it. I've been looking for a plugin or setting to make it do that again, but I can't find it. So perhaps this behaviour has changed between version 7.3 and 8.0?&lt;/p&gt;&#xA;&lt;p&gt;Any ideas how to fix this?&lt;/p&gt;&#xA;" OwnerUserId="25952" LastEditorUserId="25952" LastEditDate="2020-07-19T19:57:54.663" LastActivityDate="2020-07-19T19:57:54.663" Title="gvim: Make the mouse follow CTRL-W_j and CTRL-W_k" Tags="|gvim|vim-windows|linux|mouse|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22513" PostTypeId="2" ParentId="22499" CreationDate="2020-01-12T12:44:48.347" Score="2" Body="&lt;p&gt;In addition to other answers, look in the docs for &lt;code&gt;\v&lt;/code&gt; which, at the beginning of the search string, makes it behave as &quot;very magic&quot;, which means that &lt;code&gt;+&lt;/code&gt; will work the way you want, while &lt;code&gt;\+&lt;/code&gt; will refer to the literal plus sign.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastActivityDate="2020-01-12T12:44:48.347" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22514" PostTypeId="1" AcceptedAnswerId="22517" CreationDate="2020-01-12T13:50:32.957" Score="17" ViewCount="15623" Body="&lt;p&gt;I have a markdown file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Irish Bands:&#xA;1. U2&#xA;2. The Cranberries&#xA;3. The Dubliners&#xA;English Bands:&#xA;1. Queen&#xA;2. Duran Duran&#xA;3. The Beatles&#xA;American Bands:&#xA;1. Nirvana&#xA;2. Blondie&#xA;3. The Doors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to modify it to look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Irish Bands:&#xA;1. U2&#xA;2. The Cranberries&#xA;3. The Dubliners&#xA;English Bands:&#xA;4. Queen&#xA;5. Duran Duran&#xA;6. The Beatles&#xA;American Bands:&#xA;7. Nirvana&#xA;8. Blondie&#xA;9. The Doors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What would be the best way to go about making a change like this? The actual file is a lot bigger&lt;/p&gt;&#xA;" OwnerUserId="15158" LastActivityDate="2020-01-13T13:44:50.053" Title="Increment numbers in text" Tags="|number-formatting|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22515" PostTypeId="2" ParentId="22514" CreationDate="2020-01-12T14:11:52.043" Score="0" Body="&lt;p&gt;As usual, not the vim-way but fast.&lt;br&gt;&#xA;use &lt;code&gt;vim-visual-multi&lt;/code&gt; (&lt;a href=&quot;https://github.com/mg979/vim-visual-multi&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/mg979/vim-visual-multi&lt;/a&gt;) .  &lt;code&gt;\\/^\d*\.&lt;/code&gt;  followed by  &lt;code&gt;\\A&lt;/code&gt; will mark all numbers (if I am not mistaken).&#xA;Then simply delete all of them with &lt;code&gt;d&lt;/code&gt;. Now use &lt;code&gt;\\n&lt;/code&gt; to replace them with numbers using &lt;code&gt;1/1/.&lt;/code&gt;. &#xA;See &lt;a href=&quot;https://github.com/mg979/vim-visual-multi/wiki/Special-commands&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/mg979/vim-visual-multi/wiki/Special-commands&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2020-01-12T14:19:56.670" LastActivityDate="2020-01-12T14:19:56.670" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22516" PostTypeId="2" ParentId="22514" CreationDate="2020-01-12T14:28:18.940" Score="11" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let c=0|g/^\d\+\ze\./let c+=1|s//\=c&#xA;├─────┘ ├───────────┘├──────┘ ├─┘├─┘&#xA;│       │            │        │  └ with the current value of the counter (i.e. new number)&#xA;│       │            │        └ replace last used pattern (i.e. old number)&#xA;│       │            └ for every matched line, increment the counter&#xA;│       └ iterate over the lines starting with a number followed by a dot&#xA;└ initialize counter to 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h :g&#xA;:h :s&#xA;:h :s\=&#xA;:h /^&#xA;:h /\d&#xA;:h /\+&#xA;:h /\ze&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2020-01-12T14:28:18.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22517" PostTypeId="2" ParentId="22514" CreationDate="2020-01-12T16:10:02.607" Score="21" Body="&lt;p&gt;Another simple way to accomplish this is to use the &lt;a href=&quot;https://vimhelp.org/change.txt.html#v_g_CTRL-A&quot; rel=&quot;noreferrer&quot;&gt;g CTRL-A&lt;/a&gt; command in Visual mode, which increments all numbers by successively higher counts on each line that starts with a number. (See &lt;code&gt;:help v_g_CTRL-A&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to be able to use it, start by replacing all numbers with zeroes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\d\+\./0./&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then visually select everything:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ggVG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And finally increment them using &lt;code&gt;g&amp;lt;C-A&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first numbered line will become &lt;code&gt;1.&lt;/code&gt; the second &lt;code&gt;2.&lt;/code&gt;, the third &lt;code&gt;3.&lt;/code&gt; and so on, which matches what you requested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd say one advantage of this approach is that it doesn't require any plug-ins and will work in any Vim. Additionally, it builds on simple commands (a very simple substitution, visual mode and a very handy increment command that can be super helpful in many situations!), rather than using heavier Vimscript and Vim variables to accomplish the task.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;One problem with this approach is if you have categories that contain numbers, such as &lt;code&gt;80's Bands&lt;/code&gt; or &lt;code&gt;Bands from the 90's&lt;/code&gt;, in which case &lt;code&gt;g CTRL-A&lt;/code&gt; will increment those numbers too. (It acts on the first number it finds on a line of text.) So such categories need to be avoided, or preprocessed in a way that will prevent the command from acting on them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As pointed out by &lt;a href=&quot;https://vi.stackexchange.com/users/343/rich&quot;&gt;@Rich&lt;/a&gt;, using Visual Block selection can help avoid the problem with the latter form (&lt;code&gt;Bands from the 90's&lt;/code&gt;), by doing a visual block selection of the first few columns instead of a linewise selection of the entire file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in the middle step you could use something like &lt;code&gt;gg&lt;/code&gt;, followed by &lt;code&gt;CTRL-V&lt;/code&gt; (for visual block mode), &lt;code&gt;G&lt;/code&gt; and then &lt;code&gt;3l&lt;/code&gt; to move three characters right, selecting the four first columns and incrementing numbers appearing on those columns only.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-01-13T13:44:50.053" LastActivityDate="2020-01-13T13:44:50.053" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22518" PostTypeId="2" ParentId="10078" CreationDate="2020-01-12T17:00:26.103" Score="3" Body="&lt;p&gt;As suggested by CrashNeb, &lt;code&gt;%\\@=&lt;/code&gt; means &lt;code&gt;\\@=&lt;/code&gt; as in regexp, which does a lookup ahead without actually consuming the characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%[%^\ ]&lt;/code&gt;, is &lt;code&gt;[^\ ]&lt;/code&gt; (don't match &lt;code&gt;\&lt;/code&gt; or &lt;code&gt;&lt;/code&gt;) but escaped (&lt;code&gt;[&lt;/code&gt; and &lt;code&gt;^&lt;/code&gt; needs to be escaped using &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;%Z%[%^\ ]%\\@=%m&lt;/code&gt; means if the line doesn't start with a space or &lt;code&gt;\&lt;/code&gt;, end the multiline (&lt;code&gt;%Z&lt;/code&gt;) errors and use THE FULL LINE as a the message. Without the &lt;code&gt;%\\@=&lt;/code&gt;, &lt;code&gt;%m&lt;/code&gt; will be missing the first character (used to test if it was space or not).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the documentation (errorformat)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Pattern matching&#xA;&#xA;The scanf()-like &quot;%*[]&quot; notation is supported for backward-compatibility&#xA;with previous versions of Vim.  However, it is also possible to specify&#xA;(nearly) any Vim supported regular expression in format strings.&#xA;Since meta characters of the regular expression language can be part of&#xA;ordinary matching strings or file names (and therefore internally have to&#xA;be escaped), meta symbols have to be written with leading '%':&#xA;  %\    The single '\' character.  Note that this has to be&#xA;      escaped (&quot;%\\&quot;) in &quot;:set errorformat=&quot; definitions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%\\&lt;/code&gt; is just the way to escape &lt;code&gt;\&lt;/code&gt; in an errorfmt context, so that &lt;code&gt;%\\@=&lt;/code&gt; translates to &lt;code&gt;\@=&lt;/code&gt; as in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\@= Matches the preceding atom with zero width.&#xA;  Like &quot;(?=pattern)&quot; in Perl.&#xA;  Example     matches ~&#xA;  foo\(bar\)\@=   &quot;foo&quot; in &quot;foobar&quot;&#xA;  foo\(bar\)\@=foo  nothing&#xA;              */zero-width*&#xA;  When using &quot;\@=&quot; (or &quot;^&quot;, &quot;$&quot;, &quot;\&amp;lt;&quot;, &quot;\&amp;gt;&quot;) no characters are included&#xA;  in the match.  These items are only used to check if a match can be&#xA;  made.  This can be tricky, because a match with following items will&#xA;  be done in the same position.  The last example above will not match&#xA;  &quot;foobarfoo&quot;, because it tries match &quot;foo&quot; in the same position where&#xA;  &quot;bar&quot; matched.&#xA;&#xA;  Note that using &quot;\&amp;amp;&quot; works the same as using &quot;\@=&quot;: &quot;foo\&amp;amp;..&quot; is the&#xA;  same as &quot;\(foo\)\@=..&quot;.  But using &quot;\&amp;amp;&quot; is easier, you don't need the&#xA;  braces.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25991" LastActivityDate="2020-01-12T17:00:26.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22519" PostTypeId="2" ParentId="5176" CreationDate="2020-01-12T17:18:25.853" Score="0" Body="&lt;p&gt;To insert a char at the end of a word (instead of at the cursor position), use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-a&amp;gt; a &amp;lt;ESC&amp;gt;r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This maps to &lt;code&gt;Ctrl + a&lt;/code&gt;, you can map it to anything else of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the two in my &lt;code&gt;.vimrc&lt;/code&gt; just so I don't hustle much :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Insert char at cursor position&#xA;nnoremap &amp;lt;C-i&amp;gt; i &amp;lt;ESC&amp;gt;r&#xA;&quot; Append char after cursor position&#xA;nnoremap &amp;lt;C-a&amp;gt; a &amp;lt;ESC&amp;gt;r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22643" LastEditorUserId="22643" LastEditDate="2020-01-12T17:24:14.100" LastActivityDate="2020-01-12T17:24:14.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22520" PostTypeId="1" CreationDate="2020-01-12T18:44:18.877" Score="1" ViewCount="207" Body="&lt;p&gt;The default message displayed on the prompt when one saves a file is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&amp;lt;file_name&amp;gt;&quot; &amp;lt;nlines&amp;gt;L, &amp;lt;ncharacters&amp;gt;C written&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it remains in the prompt until another message is to be displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to change this by using a custom message which should remain on the prompt for 1-2 seconds and then go away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="26480" LastEditorUserId="1238" LastEditDate="2020-01-13T11:49:51.037" LastActivityDate="2020-01-13T11:49:51.037" Title="Custom prompt message when saving file" Tags="|custom-text-object|message|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22521" PostTypeId="2" ParentId="22514" CreationDate="2020-01-12T23:01:19.213" Score="2" Body="&lt;p&gt;Here's a couple of different (but related) methods, both of which perform the edits using regular normal mode editing commands that yank each line's number and then paste and increment it on the next line:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Using &lt;code&gt;:global&lt;/code&gt; and &lt;code&gt;:normal&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First, populate the unnamed register with a &lt;code&gt;0&lt;/code&gt; by typing &lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then run the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\d/norm!viwp^Ayiw&#xA;&#xA;                ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works by running a series of normal mode commands on each line that matches the regular expression &lt;code&gt;^\d&lt;/code&gt; i.e. has a number at the start of the line:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;viw&lt;/code&gt; Visually select the first word on the line.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; Paste the contents of the unnamed register. On the first matching line, this is &lt;code&gt;0&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Ctrl-A&lt;/code&gt; Increment the number you just pasted.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yiw&lt;/code&gt; Yank the incremented number, ready to paste (and then increment) on the next matching line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that the &lt;code&gt;^A&lt;/code&gt; highlighted above denotes a literal Ctrl-A character, which you enter by typing &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Ctrl-A&lt;/kbd&gt;. An alternative, copy-pastable method of entering the same command is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\d/exe &quot;norm!viwp\&amp;lt;C-A&amp;gt;yiw&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Using a recursive macro&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First switch off &lt;code&gt;'wrapscan'&lt;/code&gt;, so that searches won't wrap around from the end to the start of the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setl nows&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then type the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;^&lt;/kbd&gt;&lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;kbd&gt;Ctrl-A&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Broken down, these commands do the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;^&lt;/kbd&gt;&lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; Search for a number at the start of the line. Presuming your cursor begins at the start of the file, this will be a &lt;code&gt;1&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; Clear out the &lt;code&gt;&quot;q&lt;/code&gt; register by starting a macro recording and immediately finishing it. This will be necessary later on.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; Start recording a macro in register &lt;code&gt;&quot;q&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; Yank the number the cursor is currently on.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;n&lt;/kbd&gt; Jump to the next number.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt; Select and replace the current number with the one we yanked in step 4.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl-A&lt;/kbd&gt; Increment it.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; Playback the macro in the &lt;code&gt;&quot;q&lt;/code&gt; register. Because we emptied it in step 2, this step does nothing right now, but when we run the macro, it will cause the macro to repeat.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;q&lt;/kbd&gt; End the recording.&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;@&lt;/kbd&gt;&lt;kbd&gt;q&lt;/kbd&gt; Playback the recursive macro.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-12T23:08:46.787" LastActivityDate="2020-01-12T23:08:46.787" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22522" PostTypeId="2" ParentId="22520" CreationDate="2020-01-13T00:34:44.997" Score="-1" Body="&lt;p&gt;I believe one could do this with something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MyWriteMsg&#xA;  au!&#xA;  au BufWritePost echom 'my message'&#xA;augroup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Though you would want to use a timer to clear it. I’m not sure I see the value in doing that though, as it’s only more complexity for what (as far as &lt;em&gt;I&lt;/em&gt; can see) is no benefit. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-01-13T00:34:44.997" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22523" PostTypeId="1" AcceptedAnswerId="22525" CreationDate="2020-01-13T03:43:38.057" Score="5" ViewCount="867" Body="&lt;p&gt;I run Vim using both gVim and in terminal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I want to enable a certain colorscheme in my vimrc but only when in gVim, as the theme looks terrible in terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="26481" LastActivityDate="2020-01-13T04:06:19.280" Title="How to enable part of my vimrc to only apply in gVim?" Tags="|vimrc|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22524" PostTypeId="2" ParentId="14535" CreationDate="2020-01-13T03:53:59.163" Score="2" Body="&lt;p&gt;You can get a workflow that's close to what you want without configuring vim at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can jump to the nth buffer using &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; (&lt;code&gt;ctrl&lt;/code&gt; + &lt;code&gt;6&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you type a digit while viewing the output of &lt;code&gt;ls&lt;/code&gt;, then that digit is stored and can be passed to the next command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to produce the fake vim screenshots, I increased the font size so I can only see a few lines, and set the following listchars.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute(&quot;set listchars=eol:\xc2\xac,tab:&amp;gt;\\ ,trail:\xe2\x81\x9b,extends:&amp;gt;,precedes:&amp;lt;,space:\\ &quot;) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, if you do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ mkdir -p /tmp/vim-example&#xA;$ cd /tmp/vim-example&#xA;$ vim ./a ./b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then your screen will look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;¬                                 &#xA;~                                 &#xA;~                                 &#xA;~                                 &#xA;~                                 &#xA;~                                 &#xA;./a              0,0-1         All&#xA;&quot;./a&quot; [New File] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can look at the files by pressing &lt;code&gt;:ls&amp;lt;cr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:ls                               &#xA;  1 %a   &quot;./a&quot;                    &#xA;      line 1                      &#xA;  2      &quot;./b&quot;                    &#xA;      line 0                      &#xA;Press ENTER or type command to con&#xA;tinue  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From there, if you type &lt;code&gt;2&lt;/code&gt; and then &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt; you will be taken to the next buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;¬                                 &#xA;~                                 &#xA;~                                 &#xA;~                                 &#xA;~                                 &#xA;~                                 &#xA;./b              0,0-1         All&#xA;&quot;./b&quot; [New File]  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2020-01-13T03:53:59.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22525" PostTypeId="2" ParentId="22523" CreationDate="2020-01-13T04:06:19.280" Score="7" Body="&lt;p&gt;You can check if your vim runs in gui:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;gui_running&quot;)&#xA;    colo koehler&#xA;else&#xA;    colo darkblue&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;gvimrc&lt;/code&gt; file (&lt;code&gt;:h gvimrc&lt;/code&gt;) instead.&#xA;The drawback is that you would have colorscheme run twice (one in vimrc, another in gvimrc) for gVim unless you guard it in vimrc, again, with &lt;code&gt;has(&quot;gui_running&quot;)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !has(&quot;gui_running&quot;)&#xA;    colo darkblue&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gvimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;colo koehler&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-01-13T04:06:19.280" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22526" PostTypeId="1" AcceptedAnswerId="22527" CreationDate="2020-01-13T04:39:58.740" Score="3" ViewCount="4738" Body="&lt;p&gt;I use &lt;code&gt;foldmethod=indent&lt;/code&gt;but I hate how it starts each file pre-folded. To get around this I put &lt;code&gt;au BufWinEnter * normal zi&lt;/code&gt; in my vimrc. That had worked fine so far, but now that I started using CoC, My error messages are getting auto-folded, which is obviously not what I want. I tried adding &lt;code&gt;MenuPopup&lt;/code&gt; to the autocommand but no luck. How can I get this... window? (Idk what it is as far as Vim is concerned) to no automatically fold its text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DltDA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DltDA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24943" LastActivityDate="2023-10-02T18:10:12.483" Title="How do you disable automatic code folding?" Tags="|folding|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22527" PostTypeId="2" ParentId="22526" CreationDate="2020-01-13T04:44:22.843" Score="5" Body="&lt;p&gt;Put &lt;code&gt;set nofoldenable&lt;/code&gt; in your vimrc. This will also accomplish what your autocommand does.&lt;/p&gt;&#xA;" OwnerUserId="24943" LastActivityDate="2020-01-13T04:44:22.843" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22528" PostTypeId="1" CreationDate="2020-01-13T09:19:40.660" Score="4" ViewCount="18886" Body="&lt;p&gt;I'd like to map a button to toggle Vim's background between transparent (to see stuff on other apps) and dark.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;My current settings&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I'm using onedark theme. There's currently no other background setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Part of) my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set encoding=utf-8&#xA;set nocompatible&#xA;set rnu nu&#xA;set wildmode=longest,list,full&#xA;set wildmenu&#xA;filetype plugin on&#xA;syntax on&#xA;&#xA;&quot; Theme&#xA;colorscheme onedark&#xA;&#xA;&quot; Toggle transparent background&#xA;let t:is_transparent = 0&#xA;function! Toggle_transparent()&#xA;    if t:is_transparent == 0&#xA;        hi Normal guibg=NONE ctermbg=NONE&#xA;        let t:is_transparent = 1&#xA;    else&#xA;        set background=dark&#xA;        let t:is_tranparent = 0&#xA;    endif&#xA;endfunction&#xA;nnoremap &amp;lt;F1&amp;gt; : call Toggle_transparent()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Stuff I've tried&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Manually using &lt;code&gt;:hi Normal guibg=NONE ctermbg=NONE&lt;/code&gt; didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this script (I've added it to my &lt;code&gt;vimrc&lt;/code&gt;) which also doesn't make my background transparent and the toggling seems to fail after the first couple of toggles:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let t:is_transparent = 0&#xA; 25 function! Toggle_transparent()&#xA; 26     if t:is_transparent == 0&#xA; 27         hi Normal guibg=NONE ctermbg=NONE&#xA; 28         let t:is_transparent = 1&#xA; 29     else&#xA; 30         set background=dark&#xA; 31         let t:is_tranparent = 0&#xA; 32     endif&#xA; 33 endfunction&#xA; 34 nnoremap &amp;lt;F1&amp;gt; : call Toggle_transparent()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's wrong with &lt;code&gt;hi Normal guibg=NONE ctermbg=NONE&lt;/code&gt;? How can I actually make &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I'm using Manjaro KDE&lt;/li&gt;&#xA;&lt;li&gt;I have &lt;code&gt;gvim&lt;/code&gt; installed after &lt;code&gt;vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Transparency works fine in the terminal&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="25859" LastEditorUserId="343" LastEditDate="2020-03-15T21:18:49.347" LastActivityDate="2021-12-08T16:50:13.513" Title="Toggle Vim background transparency: how to setup?" Tags="|vimrc|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22529" PostTypeId="2" ParentId="18710" CreationDate="2020-01-13T09:55:48.537" Score="0" Body="&lt;p&gt;What about just remap ctrl-v in insert mode to paste from system clipboard?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-v&amp;gt; &amp;lt;esc&amp;gt;&quot;+p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does this work for you?&lt;/p&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2020-01-13T09:55:48.537" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22530" PostTypeId="2" ParentId="18309" CreationDate="2020-01-13T14:21:00.773" Score="1" Body="&lt;p&gt;I think the main problem is that the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#search%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;search()&lt;/code&gt;&lt;/a&gt; function is moving your cursor. You can fix this by passing the &lt;code&gt;'n'&lt;/code&gt; flag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let newBG = search(searchString, 'n') != 0 ? &quot;green&quot; : &quot;red&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you have the problem that when you first type &lt;code&gt;/&lt;/code&gt; the code highlights the status line according to the previous search. The cleanest way to fix is this not to run the code if no search has yet been entered:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !empty(searchString)&#xA;  let newBG = search(searchString, 'n') != 0 ? &quot;green&quot; : &quot;red&quot;&#xA;  execute(&quot;hi StatusLine ctermfg=&quot; . newBG)&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Extra credit&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you really needed to clear the previous search for some reason, you could do so by setting the &lt;a href=&quot;https://vimhelp.org/change.txt.html#quote%2F&quot; rel=&quot;nofollow noreferrer&quot;&gt;last search pattern register, &quot;/&lt;/a&gt;, which contains the contents of the previous search. You can do so with either of the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#:let-register&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:let&lt;/code&gt;&lt;/a&gt; command or the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#setreg%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;setreg()&lt;/code&gt;&lt;/a&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @/=''&#xA;&#xA;:call setreg=('/', [])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-01-13T14:21:00.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22531" PostTypeId="1" CreationDate="2020-01-13T16:03:36.447" Score="2" ViewCount="148" Body="&lt;p&gt;I've been trying to integrate Mathematica with my Vimtex set-up, inspired by this article: &lt;a href=&quot;https://castel.dev/post/lecture-notes-1/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://castel.dev/post/lecture-notes-1/&lt;/a&gt; The basic idea is to use UltiSnips to run an operation in Wolfram Script without leaving Vim, for quick computations. I've been having some issues with printing the result in TeXForm, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following in my UltiSnips: (essentially same as the article)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;priority 10&#xA;snippet math &quot;mathematica block&quot; i&#xA;math $1 math$0&#xA;endsnippet&#xA;&#xA;priority 100&#xA;snippet 'math(.*)math' &quot;evaluate mathematica&quot; wr&#xA;`!p&#xA;import subprocess&#xA;code = 'ToString[' + match.group(1) + ', TeXForm]'&#xA;snip.rv = subprocess.check_output(['wolframscript', '-code', code])&#xA;`&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I run an operation, I have some serious issues. All the backslashes \ are doubled (so \frac{1}{2} turns into \\frac{1}{2}), and the entire output is wrapped in b' and \n'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;math 1+1 math&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;expands to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b'2\n'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;math Roots[x^2-1/2 == 0, x] math&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;expands to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b'x=\\frac{1}{\\sqrt{2}}\\lor x=-\\frac{1}{\\sqrt{2}}\n'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've fixed this temporarily by defining the b' - \n' as a text object, then recording an operation that deletes the text object and replaces all &quot;\\&quot; with &quot;\&quot;. However, I really don't like this solution, and I feel like there's probably more issues that I haven't run into yet since I haven't used this setup for very long. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="26494" LastEditorUserId="343" LastEditDate="2020-01-13T16:22:11.993" LastActivityDate="2020-02-14T10:05:52.057" Title="Using Mathematica in Vim produces errors when printing in TeXForm (double backslash, &quot; b'-/n' &quot;)" Tags="|plugin-ultisnips|plugin-vimtex|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22532" PostTypeId="2" ParentId="22257" CreationDate="2020-01-13T16:07:17.447" Score="1" Body="&lt;p&gt;I couldn't resist &lt;a href=&quot;http://vimgolf.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;golfing&lt;/a&gt; this one, and came up with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3itable[row][col]&amp;lt;Esc&amp;gt;i+1&amp;lt;Esc&amp;gt;F].;a, other_&amp;lt;Esc&amp;gt;3;a = std::max(&amp;lt;Esc&amp;gt;A)&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works by inserting &lt;em&gt;three&lt;/em&gt; copies of &lt;code&gt;table[row][col]&lt;/code&gt; by using a &lt;a href=&quot;http://vimhelp.org/intro.txt.html#count&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;[count]&lt;/code&gt;&lt;/a&gt; with the &lt;a href=&quot;http://vimhelp.org/insert.txt.html#i&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;i&lt;/code&gt;&lt;/a&gt; command and then jumping backwards to fill in the missing parts of the statement&amp;#8202;&amp;mdash;&amp;#8202;each of which is conveniently adjacent to a &lt;code&gt;]&lt;/code&gt; character&amp;#8202;&amp;mdash;&amp;#8202;with the &lt;a href=&quot;http://vimhelp.org/motion.txt.html#F&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;F&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://vimhelp.org/motion.txt.html#;&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;;&lt;/code&gt;&lt;/a&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It improves on &lt;a href=&quot;https://vi.stackexchange.com/a/22259/343&quot;&gt;Mass's (actually far more appropriate) solution&lt;/a&gt; by 5 &quot;keystrokes&quot; (55 vs 60), but would only actually be quicker to use in anger if you are &lt;em&gt;exceedingly&lt;/em&gt; good at eyeballing &lt;code&gt;f&lt;/code&gt; motion targets.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-01-13T16:07:17.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22533" PostTypeId="1" AcceptedAnswerId="22536" CreationDate="2020-01-13T16:35:06.140" Score="0" ViewCount="406" Body="&lt;p&gt;I'm trying to create a buffer for a specific purpose, and for that, I need to add newlines to it to get it to be the same height as my current window. My first idea, using &lt;code&gt;call append(&quot;^&quot;, repeat(&quot;\r&quot;, winheight(win_getid())))&lt;/code&gt; didn't work (all it did was append &lt;code&gt;^M&lt;/code&gt; several times over to a single line), and I can't seem to find a solution anywhere else.&lt;/p&gt;&#xA;" OwnerUserId="26214" LastActivityDate="2022-02-09T04:01:21.277" Title="Appending multiple new lines to a buffer (instead of &quot;^M&quot;)" Tags="|buffers|functions|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22535" PostTypeId="2" ParentId="22533" CreationDate="2020-01-13T17:15:01.400" Score="2" Body="&lt;p&gt;First off, are you sure you need to add actual content to your buffer? If the goal is just to get it the same height as a single, current window, there's a much simpler method in normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;C-W&amp;gt;=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or in Vimscript:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:wincmd =&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with your append command is that you're passing a string, which explicitly tells it add the content to a single line. To add multiple lines, you should instead pass a list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call append(&quot;^&quot;, repeat([''], winheight(win_getid())))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-13T17:22:43.107" LastActivityDate="2020-01-13T17:22:43.107" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22536" PostTypeId="2" ParentId="22533" CreationDate="2020-01-13T17:15:15.530" Score="1" Body="&lt;p&gt;&lt;code&gt;append()&lt;/code&gt; (or &lt;code&gt;appendbufline()&lt;/code&gt;) do not allow &lt;code&gt;\r&lt;/code&gt; or &lt;code&gt;\n&lt;/code&gt; to insert new lines. You should use List instead. For instance,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call appendbufline(l:bufnr, '$', repeat([''], winheight(winnr())))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-01-13T17:15:15.530" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22538" PostTypeId="1" AcceptedAnswerId="22539" CreationDate="2020-01-13T20:28:31.497" Score="1" ViewCount="597" Body="&lt;p&gt;&lt;strong&gt;Consider the following scenario&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Content of the buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I saw the water in a thermal bath.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Commands issued:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:set incsearch&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/th^R^W^R^W^R^W^R^W&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;thewaterIII&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What exactly is the algorithm of the incremental search autocomplete in this case? Why does it behave in such a strange way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;why does it add &lt;code&gt;water&lt;/code&gt; without a space?&lt;/li&gt;&#xA;&lt;li&gt;why does it add only the first &lt;code&gt;I&lt;/code&gt; letter of the next word &lt;code&gt;in&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;why is that letter capitalized?&lt;/li&gt;&#xA;&lt;li&gt;why does it get stuck there and does not proceed further?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would have expected something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^R^W the&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^R^W^R^W the water&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^R^W^R^W^R^W the water in&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;... etc&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9602" LastActivityDate="2020-01-14T09:28:34.953" Title="Autocomplete incremental search behaviour" Tags="|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22539" PostTypeId="2" ParentId="22538" CreationDate="2020-01-13T21:02:37.707" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;why does it add water&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;C-r C-w&lt;/code&gt; inserts the word positioned under your cursor; however, if &lt;code&gt;'incsearch'&lt;/code&gt; is set, and there is a match in the buffer for the current contents of the command-line, Vim doesn't use the cursor position anymore, but the end of the match.  From &lt;code&gt;:h c^r^w&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;When 'incsearch' is set the cursor position at the end of the&#xA;currently displayed match is used.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When your command-line contains &lt;code&gt;the&lt;/code&gt;, the end of the match is here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I saw the water in a thermal bath.&#xA;         ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no word at that position, so Vim inserts the next word which is &lt;code&gt;water&lt;/code&gt;.&#xA;I guess Vim uses a similar algorithm as with the &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#star&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;*&lt;/code&gt; command&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*                       Search forward for the [count]'th occurrence of the&#xA;                        word nearest to the cursor.  The word used for the&#xA;                        search is the first of:&#xA;                                1. the keyword under the cursor |'iskeyword'|&#xA;                                2. the first keyword after the cursor, in the&#xA;                                   current line&#xA;                                3. the non-blank word under the cursor&#xA;                                4. the first non-blank word after the cursor,&#xA;                                   in the current line&#xA;                        Only whole keywords are searched for, like with the&#xA;                        command &quot;/\&amp;lt;keyword\&amp;gt;&quot;.  |exclusive|&#xA;                        'ignorecase' is used, 'smartcase' is not.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;without a space?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I guess that's because &lt;code&gt;C-r C-w&lt;/code&gt; is meant to insert a word, and a space character is not considered as being part of a word.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;why does it add only the first I letter of the next word in?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's not the first letter of the next word; it's the word under your cursor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I saw the water in a thermal bath.&#xA;^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When your search command-line contains &lt;code&gt;thewater&lt;/code&gt;, Vim can't use the end of the match as the position of the word because there is no match for &lt;code&gt;thewater&lt;/code&gt; in your buffer; so it falls back to your cursor position.&#xA;And under your cursor, the word is &lt;code&gt;I&lt;/code&gt;, not &lt;code&gt;in&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;why is that letter capitalized?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Again, it's not just a capitalized letter; it's the word under your cursor.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;why does it get stuck there and does not proceed further?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Because no matter how many &lt;code&gt;I&lt;/code&gt; you insert, there is still no match in the buffer; so Vim keeps using the cursor position to decide which word to insert.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To insert multiple words from the current line, you could also:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;press &lt;code&gt;C-r C-l&lt;/code&gt; to insert the whole contents of the line (see &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_CTRL-R_CTRL-L&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h c^r^l&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;use traditional editing commands to remove the words you're not interested in (see &lt;a href=&quot;https://vimhelp.org/index.txt.html#ex-edit-index&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h ex-edit-index&lt;/code&gt;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;c^r^l&lt;/code&gt; requires the patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.0.1787&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;8.0.1787&lt;/code&gt;&lt;/a&gt;.  Without, you could try some custom mapping (e.g. &lt;code&gt;cno &amp;lt;c-r&amp;gt;&amp;lt;c-l&amp;gt; &amp;lt;c-r&amp;gt;&amp;lt;c-r&amp;gt;=getline('.')&amp;lt;cr&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-01-13T21:25:03.397" LastActivityDate="2020-01-13T21:25:03.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22540" PostTypeId="2" ParentId="22538" CreationDate="2020-01-13T22:33:54.803" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/22539/343&quot;&gt;user938271's great answer&lt;/a&gt; already answers your explicit questions about what happens when you press &lt;kbd&gt;Ctrl-R&lt;/kbd&gt;&lt;kbd&gt;Ctrl-W&lt;/kbd&gt; during an incremental search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just wanted to suggest that you might want to try pressing &lt;kbd&gt;Ctrl-L&lt;/kbd&gt; instead. During a search with &lt;code&gt;'incsearch'&lt;/code&gt; set, this adds the next character after the current match each time it is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So with your example, typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/th^L^L^L^L^L^L^L&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will result in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/the water&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(You can of course hold down the keys to auto-repeat.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#%2F_CTRL-L&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /_CTRL-L&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-14T09:28:34.953" LastActivityDate="2020-01-14T09:28:34.953" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22541" PostTypeId="1" CreationDate="2020-01-13T23:38:19.243" Score="1" ViewCount="16" Body="&lt;p&gt;I am not sure why, but when I tried to create a new java file and paste some java code into it, &lt;code&gt;vim&lt;/code&gt; turned them into comments and added additional indentation to the code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 16 // import com.myproject.queue.BatchQueueDriver;&#xA; 17 //&#xA; 18 // import com.codahale.metrics.health.HealthCheckRegistry;&#xA; 19 // import org.apache.curator.framework.CuratorFramework;&#xA; 20 // import org.springframework.context.ConfigurableApplicationContext;&#xA; 21 //&#xA; 22 // import java.util.concurrent.TimeUnit;&#xA; 23 // import java.util.function.BooleanSupplier;&#xA; 24 //&#xA; 25 // public class WorkerLauncher extends AbstractLauncher {&#xA; 26 //&#xA; 27 //   private final ConfigurableApplicationContext ctx;&#xA; 28 //     private final CuratorFramework curator;&#xA; 29 //       private final BatchQueueDriver&amp;lt;?&amp;gt; jobQueue1Driver;&#xA; 30 //         private final BatchQueueDriver&amp;lt;?&amp;gt; jobQueue2Driver;&#xA; 31 //           private final BatchQueueDriver&amp;lt;?&amp;gt; jobQueue3Driver;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I disable this behaviour?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Version 8.0.1365 on OSX mojave&lt;/p&gt;&#xA;" OwnerUserId="22238" LastActivityDate="2020-01-13T23:38:19.243" Title="How to disable this 'make text in clipboard into comment' feature with java file?" Tags="|filetype-java|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22543" PostTypeId="1" AcceptedAnswerId="22545" CreationDate="2020-01-14T02:11:10.123" Score="5" ViewCount="423" Body="&lt;p&gt;When working in &lt;code&gt;vim&lt;/code&gt;, I like to have a toggle-able terminal window that I can bring with me from tab to tab. This works by tracking a buffer, and opening it in a new &lt;code&gt;bot&lt;/code&gt; split (if it isn't visible), or hiding the split (if it is visible). However, my current solution only allows me to use a single terminal buffer at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to write a set of functions that allows me to manage and toggle a &quot;set&quot; of terminal buffers, all of which are next to each other and at the bottom of the screen. My method so far is to store a list of each terminal window as it is opened, with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[{'bufnr': 2, 'type': 'root'}, {'bufnr': 3, 'type': 'v'}, {'bufnr': 4, 'type': 'h'}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can then iterate through these and open them in the same order that they were originally opened. This is fine, except for when any of the buffers in the set is closed. There are a ton of different edge cases, so I've been looking for a better solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim&lt;/code&gt; provides the function &lt;code&gt;winlayout()&lt;/code&gt; that I could potentially filter down to only windows that are in the terminal set, but I am having an incredibly hard time parsing out the information that it returns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone help me figure out how to parse the output of &lt;code&gt;winlayout()&lt;/code&gt; to reproduce the layout it defines? Or, if there is a better way to do this, I am always open to ideas.&lt;/p&gt;&#xA;" OwnerUserId="25455" LastEditorUserId="10604" LastEditDate="2020-01-21T02:44:40.203" LastActivityDate="2020-01-21T02:44:40.203" Title="Parsing winlayout() For Toggling Multiple Windows At Once" Tags="|vim-windows|terminal-buffer|window-management|original-vim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22544" PostTypeId="1" AcceptedAnswerId="22546" CreationDate="2020-01-14T02:32:00.343" Score="1" ViewCount="2259" Body="&lt;p&gt;I write this line to the &lt;code&gt;~/.vim/ftplugin/c.vim&lt;/code&gt; file, but nothing happens when I create a new C file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile *.c read ~/skeleton/c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Afterwards, I added this line to $MYVIMRC:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile *.c echo 123&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the skeleton started to be added to new C files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why?&lt;/p&gt;&#xA;" OwnerUserId="26502" LastEditorUserId="18609" LastEditDate="2020-01-14T03:04:51.960" LastActivityDate="2020-01-14T08:07:36.757" Title="Why does this autocmd not work" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22545" PostTypeId="2" ParentId="22543" CreationDate="2020-01-14T05:10:52.773" Score="7" Body="&lt;h2&gt;Full restore&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you want to restore layout with multiple termina buffers, you must restore other windows and buffers too, so it's in fact a full buffer layout restore, it's usage is not limited to terminal buffers. Three things must be done to achive that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Split windows according to saved layout. We can use result of &lt;code&gt;winlayout()&lt;/code&gt; to do this.&lt;/li&gt;&#xA;&lt;li&gt;Load buffer in each window. We must record &lt;code&gt;bufnr&lt;/code&gt; in each window when we save &lt;code&gt;winlayout()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Resize each window. We can use &lt;code&gt;:h winrestcmd()&lt;/code&gt; to do this.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Two recursions are used to save and restore layout:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command SaveBufferLayout call s:save_buffer_layout()&#xA;command RestoreBufferLayout call s:restore_buffer_layout()&#xA;&#xA;function s:save_buffer_layout() abort&#xA;  let s:buf_layout = winlayout()&#xA;  let s:resize_cmd = winrestcmd()&#xA;  call s:add_buf_to_layout(s:buf_layout)&#xA;endfunction&#xA;&#xA;&quot; add bufnr to leaf&#xA;function s:add_buf_to_layout(layout) abort&#xA;  if a:layout[0] ==# 'leaf'&#xA;    call add(a:layout, winbufnr(a:layout[1]))&#xA;  else&#xA;    for child_layout in a:layout[1]&#xA;      call s:add_buf_to_layout(child_layout)&#xA;    endfor&#xA;  endif&#xA;endfunction&#xA;&#xA;function s:restore_buffer_layout() abort&#xA;  if !has_key(s:, 'buf_layout')&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; create clean window&#xA;  new&#xA;  wincmd o&#xA;&#xA;  &quot; recursively restore buffers&#xA;  call s:apply_layout(s:buf_layout)&#xA;&#xA;  &quot; resize&#xA;  exe s:resize_cmd&#xA;endfunction&#xA;&#xA;function s:apply_layout(layout) abort&#xA;&#xA;  if a:layout[0] ==# 'leaf'&#xA;    if bufexists(a:layout[2])&#xA;      exe printf('b %d', a:layout[2])&#xA;    endif&#xA;  else&#xA;&#xA;    &quot; split cols or rows, split n-1 times&#xA;    let split_method = a:layout[0] ==# 'col' ? 'rightbelow split' : 'rightbelow vsplit'&#xA;    let wins = [win_getid()]&#xA;    for child_layout in a:layout[1][1:]&#xA;      exe split_method&#xA;      let wins += [win_getid()]&#xA;    endfor&#xA;&#xA;    &quot; recursive into child windows&#xA;    for index in range(len(wins) )&#xA;      call win_gotoid(wins[index])&#xA;      call s:apply_layout(a:layout[1][index])&#xA;    endfor&#xA;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's possible to make it work for multiple layouts, you can the newest script &lt;a href=&quot;https://github.com/dedowsdi/.vim/blob/master/autoload/misc/layout.vim&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Original manual workaround&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It's trouble and buggy to toggle multiple terminal windows, you can step back, split by manual, then load the hided terminal buffer by &lt;code&gt;mark&lt;/code&gt; or buffer number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create global mark for terminal buffer by &lt;code&gt;&amp;lt;c-w&amp;gt;:mark X&lt;/code&gt; or &lt;code&gt;&amp;lt;c-w&amp;gt;:kX&lt;/code&gt;, hide it, and load it back with &lt;code&gt;'X&lt;/code&gt;, here is a map that let you create mark with &lt;code&gt;&amp;lt;c-w&amp;gt;m{capital letter}&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tnoremap &amp;lt;expr&amp;gt; &amp;lt;c-w&amp;gt;m printf('&amp;lt;c-w&amp;gt;:mark %s&amp;lt;cr&amp;gt;',  nr2char(getchar()))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you can also combine the &lt;code&gt;split&lt;/code&gt; and &lt;code&gt;load&lt;/code&gt; together in a single command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;new +'X&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;:ls R&lt;/code&gt; or &lt;code&gt;:ls F&lt;/code&gt; to list terminal buffer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;winlayout&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h winlayout()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;        The result is a nested List containing the layout of windows&#xA;        in a tabpage.&#xA;                ...&#xA;        For a leaf window, it returns:&#xA;            ['leaf', {winid}]&#xA;        For horizontally split windows, which form a column, it&#xA;        returns:&#xA;            ['col', [{nested list of windows}]]&#xA;        For vertically split windows, which form a row, it returns:&#xA;            ['row', [{nested list of windows}]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;leaf&lt;/code&gt; item contains &lt;code&gt;:h winid&lt;/code&gt; , it's an uique id across &lt;code&gt;tabs&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a horizontally splited &lt;code&gt;col&lt;/code&gt;, it has 3 leafs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;┌─────┐&#xA;│     │&#xA;├─────┤&#xA;│     │&#xA;├─────┤&#xA;│     │&#xA;└─────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a vertically splited &lt;code&gt;row&lt;/code&gt;, it has 3 leafs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;┌────┬────┬────┐&#xA;│    │    │    │&#xA;└────┴────┴────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They can be &lt;code&gt;nested&lt;/code&gt;, this layout is a &lt;code&gt;row&lt;/code&gt;, it's splited into two &lt;code&gt;col&lt;/code&gt;, each&#xA;&lt;code&gt;col&lt;/code&gt; is splited into two leafs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ┌──────┬──────┐&#xA; │  1   │  3   │&#xA; ├──────│──────┤&#xA; │  2   │  4   │&#xA; └──────┴──────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this layout is a &lt;code&gt;col&lt;/code&gt;, it's splited into two &lt;code&gt;row&lt;/code&gt;, each&#xA;&lt;code&gt;row&lt;/code&gt; is splited into two leafs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ┌──────┬──────┐&#xA; │  1   │  2   │&#xA; ├─────────────┤&#xA; │  3   │  4   │&#xA; └──────┴──────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;:h winnr()&lt;/code&gt; for above two layouts are different.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-01-20T23:56:21.603" LastActivityDate="2020-01-20T23:56:21.603" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22546" PostTypeId="2" ParentId="22544" CreationDate="2020-01-14T05:24:55.313" Score="4" Body="&lt;p&gt;Well, actually it works, but probably not the way you think.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Autocommands are invoked in sequence. It's &lt;code&gt;BufNewFile&lt;/code&gt; and/or &lt;code&gt;BufRead&lt;/code&gt; that are used by &lt;code&gt;ftplugin&lt;/code&gt; to &lt;code&gt;set filetype&lt;/code&gt; which results in &lt;code&gt;FileType&lt;/code&gt; autocommand which, in turn, does &lt;code&gt;source&lt;/code&gt; all your stuff. So you've already missed &lt;code&gt;BufNewFile&lt;/code&gt; &lt;em&gt;for that particualr buffer&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Nonetheless, &lt;code&gt;autocmd&lt;/code&gt; without &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; specification &lt;em&gt;is global&lt;/em&gt;, so you've set it up for later. And did it wrong: each time &lt;code&gt;FileType c&lt;/code&gt; is triggered, you add another instance of &lt;code&gt;read&lt;/code&gt; for later buffers.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So your options are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Add it to vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup MySkeletons | au!&#xA;    autocmd BufNewFile *.c read ~/skeleton/c&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Manually check if the current buffer is empty:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;~/.vim/after/ftplugin/c.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if line('$') == 1 &amp;amp;&amp;amp; empty(getline(1))&#xA;    read ~/skeleton/c&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="205" LastEditDate="2020-01-14T08:07:36.757" LastActivityDate="2020-01-14T08:07:36.757" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22547" PostTypeId="1" CreationDate="2020-01-14T07:05:42.977" Score="0" ViewCount="1426" Body="&lt;p&gt;I often press &lt;code&gt;ESC&lt;/code&gt;/&lt;code&gt;^[&lt;/code&gt; to ensure that I've left insert mode and entered normal mode. However, if I'm already in normal mode, Vim displays an annoying flashy screen effect:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HcZPD.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HcZPD.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I prevent Vim from making this flashy screen effect, when pressing &lt;code&gt;ESC&lt;/code&gt;/&lt;code&gt;^[&lt;/code&gt; in normal mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus: I guess it has no effect of pressing &lt;code&gt;ESC&lt;/code&gt;/&lt;code&gt;^[&lt;/code&gt; in normal mode, other than cancelling the current command e.g. &lt;code&gt;d&lt;/code&gt;, so why does Vim makes this flashy screen effect?&lt;/p&gt;&#xA;" OwnerUserId="26505" LastActivityDate="2020-01-14T07:11:58.600" Title="How to prevent Vim from making a flashy screen effect when pressing `ESC` or `^[` in normal mode?" Tags="|terminal|insert-mode|normal-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22548" PostTypeId="2" ParentId="22547" CreationDate="2020-01-14T07:11:58.600" Score="3" Body="&lt;p&gt;That's a bell (&lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27visualbell%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;a visual bell&lt;/a&gt;). You can turn off bells for Esc in normal mode using &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27belloff%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;belloff&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        *'belloff'* *'bo'*&#xA;'belloff' 'bo'      string  (default &quot;&quot;)&#xA;            global&#xA;    Specifies for which events the bell will not be rung. It is a comma&#xA;    separated list of items. For each item that is present, the bell&#xA;    will be silenced. This is most useful to specify specific events in&#xA;    insert mode to be silenced.&#xA;&#xA;    item        meaning when present    ~&#xA;    all     All events.&#xA;    [...]&#xA;    esc     hitting &amp;lt;Esc&amp;gt; in |Normal-mode|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set belloff=esc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="205" LastActivityDate="2020-01-14T07:11:58.600" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22549" PostTypeId="1" CreationDate="2020-01-14T07:57:47.697" Score="1" ViewCount="181" Body="&lt;p&gt;I often find myself wanting to open multiple tabs at the same time from within vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabnew src/Class.*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which would open all matching files in separate tabs. Is there a way to get this functionality?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2020-01-14T11:36:53.253" Title="Is there a way to use a wildcard with :tabnew" Tags="|tabbed-user-interface|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22553" PostTypeId="2" ParentId="22549" CreationDate="2020-01-14T11:02:50.387" Score="2" Body="&lt;p&gt;To open a bunch of files you can use &lt;code&gt;:h :args&lt;/code&gt; and &lt;code&gt;:h :all&lt;/code&gt;. That is, to open all &lt;code&gt;Class.*&lt;/code&gt; files (and only such files!) in the current tab you can do just &lt;code&gt;args Class.* | all&lt;/code&gt; (or &lt;code&gt;args Class.* | tab all&lt;/code&gt; to open each file in a new tab).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It requires a bit more work if you want to keep all opened windows/tabs intact and to preserve the global arglist. The target command can be defined like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar -nargs=+ -complete=file Tabedit tabnew | arglocal |&#xA;    \ args &amp;lt;args&amp;gt; | silent execute 'argdo tabedit' | tabclose&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;Tabedit Class.*&lt;/code&gt; should do the job.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2020-01-14T11:36:53.253" LastActivityDate="2020-01-14T11:36:53.253" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22554" PostTypeId="2" ParentId="22507" CreationDate="2020-01-14T11:44:04.333" Score="3" Body="&lt;p&gt;It's possible to get Vim to handle all the necessary escaping for you by calling &lt;a href=&quot;https://vimhelp.org/eval.txt.html#shellescape%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;shellescape()&lt;/code&gt;&lt;/a&gt;. If you pass in a non-zero value for its second argument, this will escape characters in a manner suitable for passing as a command line argument to a &lt;code&gt;!&lt;/code&gt; command or filter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;'&amp;lt;,'&amp;gt;!awk&quot; shellescape('!x[$0]++', 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can wrap this into a command that takes a range (or defaults to the entire file) like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -range=% RemoveDups execute '&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;!awk' shellescape('!x[$0]++', 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can invoke this command from a visual mode mapping like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;leader&amp;gt;rd :RemoveDups&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-15T15:55:27.427" LastActivityDate="2020-01-15T15:55:27.427" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22555" PostTypeId="1" CreationDate="2020-01-14T17:08:10.170" Score="1" ViewCount="17" Body="&lt;p&gt;I want to &lt;code&gt;:map &amp;lt;C-t&amp;gt; :some-ex-command&lt;/code&gt; with a space at the end so I can continue typing the command and execute it with enter. I cannot find the syntax for how to do this. I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;C-t&amp;gt; :some-ex-command &quot; &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which of course inserts literal &lt;code&gt;&quot;&lt;/code&gt; characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can this be done?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2020-01-14T17:08:10.170" Title="How can I :map a key to something containing spaces?" Tags="|key-bindings|map-operator|" AnswerCount="0" CommentCount="1" ClosedDate="2020-01-14T19:05:31.067" ContentLicense="CC BY-SA 4.0" />
  <row Id="22556" PostTypeId="1" AcceptedAnswerId="22559" CreationDate="2020-01-14T18:38:07.870" Score="1" ViewCount="239" Body="&lt;p&gt;I recently upgraded to vim 8.2.0100 on Mac, and the markdown highlighting appears to have changed to be buggy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Normal syntax *Highlighting has started* Highlight continues&#xA;Highlight continues...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;meaning the second &lt;code&gt;*&lt;/code&gt; does not stop the highlighting on italics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see that &lt;code&gt;echo &amp;amp;filetype&lt;/code&gt; returns &lt;code&gt;markdown&lt;/code&gt;, and that &lt;code&gt;:scriptnames&lt;/code&gt; includes (among many other files) &lt;code&gt;/usr/local/Cellar/vim/8.2.0100/share/vim/vim82/syntax/markdown.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the markdown syntax file, I see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; start matches a non-whitespace character if preceeded by a * OR a * followed by a non-whitespace character.&#xA;&quot; end   matches a non-whitespace character if preceeded by a * OR a * followed by a non-whitespace character&#xA;exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start=&quot;\S\@&amp;lt;=\*\|\*\S\@=&quot; end=&quot;\S\@&amp;lt;=\*\|\*\S\@=&quot; skip=&quot;\\*&quot; contains=markdownLineStart,@Spell' . s:concealends&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The comments are my own attempt to understand the syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried changing it a bunch, including just setting &lt;code&gt;start=&quot;ic&quot;&lt;/code&gt; and &lt;code&gt;end=&quot;xc&quot;&lt;/code&gt;, but that &lt;strong&gt;doesn't work&lt;/strong&gt;; I have the same problem where the start turns on the highlighting, but the end fails to turn it off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This happens &lt;strong&gt;even with &lt;code&gt;vim &amp;lt;filename&amp;gt; -u NONE&lt;/code&gt;&lt;/strong&gt; (after I set the filetype to markdown and turn on syntax), meaning my &lt;code&gt;.vimrc&lt;/code&gt; is not related&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing in how to edit syntax files, or why doesn't the &lt;code&gt;end&lt;/code&gt; get any matches?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I have noticed that it also does not work with &lt;strong&gt;Bold&lt;/strong&gt; (&lt;code&gt;**Bold**&lt;/code&gt;), and the bold will continue on through the rest of the document. Other segments, notably &lt;code&gt;```&lt;/code&gt;, do stop their changes.&lt;/p&gt;&#xA;" OwnerUserId="17205" LastEditorUserId="17205" LastEditDate="2020-01-14T20:42:41.530" LastActivityDate="2020-01-14T20:53:09.747" Title="Vim syntax group not stopping" Tags="|syntax-highlighting|filetype-markdown|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22557" PostTypeId="1" CreationDate="2020-01-14T20:09:10.013" Score="1" ViewCount="77" Body="&lt;p&gt;I use &lt;code&gt;:terminal&lt;/code&gt; in neovim to run a dev server. But whenever I switch to other opened buffer(s), the terminal kills the process. Is there a way to keep the terminal running in neovim?&lt;/p&gt;&#xA;" OwnerUserId="15848" LastEditorUserId="15848" LastEditDate="2020-01-14T20:45:20.490" LastActivityDate="2020-01-14T20:45:20.490" Title="neovim: Keep :terminal active when I switch to other buffers" Tags="|neovim|terminal|terminal-buffer|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22559" PostTypeId="2" ParentId="22556" CreationDate="2020-01-14T20:47:29.423" Score="3" Body="&lt;p&gt;Turns out it's just broke in 8.2.0100.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the committed fix: &lt;a href=&quot;https://github.com/tpope/vim-markdown/commit/e875717243fbea38189f5590a25a05809f03672b&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tpope/vim-markdown/commit/e875717243fbea38189f5590a25a05809f03672b&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem was with the &lt;code&gt;skip=&quot;\\*&quot;&lt;/code&gt;. It was supposed to match the literal characters &lt;code&gt;\*&lt;/code&gt;, so that you could display a literal &lt;code&gt;*&lt;/code&gt; in markdown. However, &lt;code&gt;\\&lt;/code&gt; makes a literal &lt;code&gt;\&lt;/code&gt;, so he was instead skipping any amount of &lt;code&gt;\&lt;/code&gt; characters, which included 0 backslash characters, which meant &quot;skip everything&quot;. &lt;code&gt;\\\*&lt;/code&gt; instead matches a literal &lt;code&gt;\*&lt;/code&gt;, which is what you should write to display a literal &lt;code&gt;*&lt;/code&gt; in your markdown output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TL;DR: Change all instances of &lt;code&gt;skip=&quot;\\*&quot;&lt;/code&gt; in &lt;code&gt;markdown.vim&lt;/code&gt; to &lt;code&gt;skip=&quot;\\\*&quot;&lt;/code&gt; and everything works.&lt;/p&gt;&#xA;" OwnerUserId="17205" LastEditorUserId="17205" LastEditDate="2020-01-14T20:53:09.747" LastActivityDate="2020-01-14T20:53:09.747" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22560" PostTypeId="1" CreationDate="2020-01-14T23:28:02.270" Score="2" ViewCount="580" Body="&lt;p&gt;Select text in vim and convert it to a hex dump...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!xxd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note 2 hex characters represent a single letter...in whatever encoding I did this in...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Select a hex dump in vim and convert it back to text...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!xxd -r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Select text in vim and convert it to a binary dump...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!xxd -b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do you convert it back from the binary dump?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="205" LastEditDate="2020-01-15T05:13:04.160" LastActivityDate="2021-02-08T21:51:06.587" Title="Convert a binary dump back to text in vi?" Tags="|xxd|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22561" PostTypeId="1" CreationDate="2020-01-15T00:47:15.610" Score="1" ViewCount="51" Body="&lt;p&gt;Is there any way to take a &lt;code&gt;fileencoding&lt;/code&gt; setting (for instance utf8 or cp1252) that you might set and find out what it's valid hex range is?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When a character falls outside the range, it is displayed with a &lt;code&gt;&amp;lt;XY&amp;gt;&lt;/code&gt; &lt;a href=&quot;https://vi.stackexchange.com/questions/22299/what-is-the-green-92-thats-in-my-file&quot;&gt;hex code in the file&lt;/a&gt;, so vim knows what the range is, but how do I the user display it?&lt;/p&gt;&#xA;" OwnerUserId="1065" LastActivityDate="2020-01-15T00:47:15.610" Title="How to list the hex range of an a fileencoding in vim?" Tags="|range|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22562" PostTypeId="1" AcceptedAnswerId="22569" CreationDate="2020-01-15T01:20:22.487" Score="0" ViewCount="150" Body="&lt;p&gt;I would like to change it to make something like a separator between &lt;code&gt;!python %&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change this(my computer is in spanish):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Nt97X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Nt97X.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hello World&#xA;&#xA;---------------&#xA;Hello World&#xA;&#xA;---------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All I have found are answers to disable it but not to change it&lt;/p&gt;&#xA;" OwnerUserId="24844" LastEditorUserId="24844" LastEditDate="2020-01-15T06:31:56.973" LastActivityDate="2020-01-18T00:54:20.223" Title="Is there a way to change the message &quot;press ENTER or type command to continue&quot; to something else?" Tags="|terminal|external-command|shell|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22563" PostTypeId="1" AcceptedAnswerId="22564" CreationDate="2020-01-15T03:21:15.193" Score="1" ViewCount="164" Body="&lt;p&gt;When i do a &lt;code&gt;ls -l /usr/bin/vimdifff&lt;/code&gt; it shows following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/bin/vimdiff -&amp;gt; vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does this mean &lt;code&gt;vimdiff&lt;/code&gt; and &lt;code&gt;vim&lt;/code&gt; are the same?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that we can use vim for diff by giving &lt;code&gt;-d&lt;/code&gt;. But how does linking like this makes the &lt;code&gt;vim&lt;/code&gt; work as a difftool.&lt;/p&gt;&#xA;" OwnerUserId="23047" LastActivityDate="2020-01-15T05:11:20.067" Title="How vimdiff links to vim" Tags="|vimdiff|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22564" PostTypeId="2" ParentId="22563" CreationDate="2020-01-15T05:11:20.067" Score="4" Body="&lt;p&gt;The &lt;code&gt;vim&lt;/code&gt; binary is able to answer by many names and it will tweak its behavior based on which name it is called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a somewhat common practice in Unix, where a program will support checking the name by which it's invoked and will behave differently depending on that name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At installation time, a single binary will be copied, but symbolic links or hardlinks will be created to make it available under all possible names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case of &lt;code&gt;vim&lt;/code&gt;, it actually supports being called under quite a variety of names. You can see a comprehensive list under &lt;a href=&quot;https://vimhelp.org/starting.txt.html#vim-arguments&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help vim-arguments&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The startup mode can be changed by using another name instead of &lt;code&gt;vim&lt;/code&gt;, which is equal to giving options:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;code&gt;ex&lt;/code&gt; (&lt;code&gt;vim -e&lt;/code&gt;): Start in Ex mode. &lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;exim&lt;/code&gt; (&lt;code&gt;vim -E&lt;/code&gt;): Start in improved Ex mode.&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;view&lt;/code&gt; (&lt;code&gt;vim -R&lt;/code&gt;): Start in read-only mode.    &lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;gvim&lt;/code&gt; (&lt;code&gt;vim -g&lt;/code&gt;): Start the GUI.      &lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;gex&lt;/code&gt; (&lt;code&gt;vim -eg&lt;/code&gt;): Start the GUI in Ex mode.       &lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;gview&lt;/code&gt; (&lt;code&gt;vim -Rg&lt;/code&gt;): Start the GUI in read-only mode.  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;rvim&lt;/code&gt; (&lt;code&gt;vim -Z&lt;/code&gt;): Like &lt;code&gt;vim&lt;/code&gt;, but in restricted mode.&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;rview&lt;/code&gt; (&lt;code&gt;vim -RZ&lt;/code&gt;): Like &lt;code&gt;view&lt;/code&gt;, but in restricted mode.&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;rgvim&lt;/code&gt; (&lt;code&gt;vim -gZ&lt;/code&gt;): Like &lt;code&gt;gvim&lt;/code&gt;, but in restricted mode.&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;rgview&lt;/code&gt; (&lt;code&gt;vim -RgZ&lt;/code&gt;): Like &lt;code&gt;gview&lt;/code&gt;, but in restricted mode.&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;evim&lt;/code&gt; (&lt;code&gt;vim -y&lt;/code&gt;): Easy Vim: set &lt;code&gt;'insertmode'&lt;/code&gt;.&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;eview&lt;/code&gt; (&lt;code&gt;vim -yR&lt;/code&gt;): Like &lt;code&gt;evim&lt;/code&gt; in read-only mode.&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;vimdiff&lt;/code&gt; (&lt;code&gt;vim -d&lt;/code&gt;): Start in diff mode.&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;gvimdiff&lt;/code&gt; (&lt;code&gt;vim -gd&lt;/code&gt;): Start in diff mode.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-15T05:11:20.067" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22565" PostTypeId="1" AcceptedAnswerId="22580" CreationDate="2020-01-15T06:55:13.807" Score="1" ViewCount="378" Body="&lt;p&gt;I am new to vim, I just wonder if I want to actually type the keyword in some cases, how do I do it? Do I need to disable the snippets?&#xA;For example, if I use &lt;code&gt;impd&lt;/code&gt; as keyword for &lt;code&gt;import pandas as pd&lt;/code&gt;, then how do I actually type &lt;code&gt;impd&lt;/code&gt; without triggering the snippet? &#xA;I am using Plugin Ultisnip, &#xA;here's the relevant part in my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'SirVer/ultisnips'  &#xA;Plug 'honza/vim-snippets' &#xA;let g:UltiSnipsExpandTrigger = '&amp;lt;tab&amp;gt;' &#xA;let g:UltiSnipsJumpForwardTrigger ='&amp;lt;tab&amp;gt;' &#xA;let g:UltiSnipsJumpBackwardTrigger = '&amp;lt;s-tab&amp;gt;' &#xA;let g:UltiSnipsSnippetDirectories=[&quot;UltiSnips&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I config the plugin with the following two snippets for LaTeX copied from internet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet beg &quot;begin{} / end{}&quot; bA&#xA;\begin{$1}&#xA;    $0&#xA;\end{$1}&#xA;endsnippet&#xA;&#xA;snippet mk &quot;Math&quot; wA&#xA;$${1}$`!p&#xA;if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:&#xA;    snip.rv = ' '&#xA;else:&#xA;    snip.rv = ''&#xA;`$2&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the behavior is: the snippet &lt;code&gt;beg&lt;/code&gt; only triggers if I type it in a new line, and &lt;code&gt;mk&lt;/code&gt; triggers no matter where I type, is there a way to, say, type &quot;mk&quot; without triggering it or disabling the snippet? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="26513" LastEditorUserId="26513" LastEditDate="2020-01-16T02:59:46.627" LastActivityDate="2020-01-16T04:05:39.177" Title="How to type snippet keywords when you need it" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22566" PostTypeId="1" CreationDate="2020-01-15T09:16:03.193" Score="4" ViewCount="849" Body="&lt;p&gt;I need to test a vim plugin. The problem: I already have my vim setup in current env, so &lt;code&gt;~/.vimrc&lt;/code&gt; is occupied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to issue a command like &lt;code&gt;vim -u &amp;lt;blah..blah&amp;gt;&lt;/code&gt; that maybe specifies the plugin path and has some other options to enable testing the plugin only.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="1238" LastEditDate="2020-01-18T15:29:32.183" LastActivityDate="2020-02-03T07:01:59.120" Title="Howto enable only one plugin to test?" Tags="|vimrc|plugin-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22567" PostTypeId="2" ParentId="22566" CreationDate="2020-01-15T10:18:32.187" Score="2" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp-=~/.vim&#xA;set rtp-=~/.vim/after&#xA;set rtp^=/path/to/some-plugin&#xA;set rtp+=/path/to/some-plugin/after&#xA;&#xA;set vif=NONE&#xA;filetype plugin indent on&#xA;syntax enable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Write the code in a file, e.g. &lt;code&gt;/tmp/vimrc&lt;/code&gt;, then start Vim with this shell command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -Nu /tmp/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-u&lt;/code&gt; argument specifies the path to a custom vimrc, while the &lt;code&gt;-N&lt;/code&gt; argument resets &lt;code&gt;'compatible'&lt;/code&gt;.&#xA;&lt;code&gt;-N&lt;/code&gt; is necessary, because:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;you probably don't want &lt;code&gt;'compatible'&lt;/code&gt; to be set&lt;/li&gt;&#xA;&lt;li&gt;when you pass any value different than &lt;code&gt;DEFAULTS&lt;/code&gt; to &lt;code&gt;-u&lt;/code&gt;, &lt;code&gt;'compatible'&lt;/code&gt; is set&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h -u&lt;/code&gt; and &lt;code&gt;:h -N&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;'compatible'&lt;/code&gt; is always disabled in Nvim (see &lt;code&gt;:h nvim-defaults&lt;/code&gt;), so you don't need &lt;code&gt;-N&lt;/code&gt; for the latter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim -u /tmp/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If the plugin you're testing doesn't contain an &lt;code&gt;after/&lt;/code&gt; directory, you can remove this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp+=/path/to/some-plugin/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;'viminfofile'&lt;/code&gt; to &lt;code&gt;NONE&lt;/code&gt; makes sure your viminfo file is not read; the contents of the latter could interfere while you're testing your plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that in Nvim, &lt;code&gt;'viminfofile'&lt;/code&gt; is deprecated in favor of &lt;code&gt;'shadafile'&lt;/code&gt;; if you use it, replace &lt;code&gt;set vif=NONE&lt;/code&gt;, with &lt;code&gt;set sdf=NONE&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you use Nvim, you may be interested in making &lt;code&gt;'guicursor'&lt;/code&gt; empty:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set gcr=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because Nvim sets &lt;code&gt;'guicursor'&lt;/code&gt; by default (&lt;a href=&quot;https://github.com/neovim/neovim/issues/6778#issuecomment-302945056&quot; rel=&quot;nofollow noreferrer&quot;&gt;even with &lt;code&gt;-u NONE&lt;/code&gt;&lt;/a&gt;), which makes it send escape sequences to set the shape of the cursor; these sequences may not always be correctly understood by your terminal, and may interfere while you're testing your plugin.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If for some reason, you need some of your plugins to be sourced (matching &lt;code&gt;~/.vim/plugin/**/*.vim&lt;/code&gt; or &lt;code&gt;~/.vim/after/plugin/**/*.vim&lt;/code&gt;), try this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp-=~/.vim&#xA;set rtp-=~/.vim/after&#xA;set rtp^=/path/to/some-plugin&#xA;set rtp+=/path/to/some-plugin/after&#xA;set rtp^=~/.vim&#xA;set rtp+=~/.vim/after&#xA;&#xA;set vif=NONE&#xA;filetype plugin indent on&#xA;syntax enable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If your plugin doesn't need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;syntax scripts, remove &lt;code&gt;syntax enable&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;indent scripts, remove &lt;code&gt;indent&lt;/code&gt; in &lt;code&gt;filetype plugin indent on&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;filetype scripts, remove &lt;code&gt;plugin&lt;/code&gt; in &lt;code&gt;filetype plugin indent on&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;any of the above, remove the lines &lt;code&gt;filetype plugin indent on&lt;/code&gt; and &lt;code&gt;syntax enable&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt;, you could try this snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet vimrc &quot;Minimal vimrc to test a plugin&quot; bm&#xA;set rtp-=~/.vim&#xA;set rtp-=~/.vim/after&#xA;set rtp^=${1:~/.vim/plugged/vim-${2:foo}}${3:&#xA;set rtp+=$1/after}${4:&#xA;set rtp^=~/.vim}${5:&#xA;set rtp+=~/.vim/after}&#xA;&#xA;${6:set `!v has('nvim') ? 'sdf=NONE gcr=' : 'vif=NONE'`&#xA;}${7:filetype plugin indent on&#xA;syntax enable}&#xA;&#xA;$0&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some of the paths which are used in the &lt;code&gt;set rtp&lt;/code&gt; settings assume you're using &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-plug&lt;/code&gt;&lt;/a&gt; as a plugin manager; if that's not the case, you'll need to edit this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rtp^=${1:~/.vim/plugged/vim-${2:foo}}${3:&#xA;             ^^^^^^^^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that the path points to the directory of your plugin.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-01-15T17:56:59.460" LastActivityDate="2020-01-15T17:56:59.460" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22568" PostTypeId="2" ParentId="358" CreationDate="2020-01-15T12:10:07.860" Score="3" Body="&lt;p&gt;You can also the command&lt;code&gt;:only&lt;/code&gt;. It's the same with &lt;code&gt;C-W C-O&lt;/code&gt; couple. More on &lt;code&gt;:h only&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user26514" LastEditorDisplayName="user26514" LastEditDate="2020-01-15T12:35:57.083" LastActivityDate="2020-01-15T12:35:57.083" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22569" PostTypeId="2" ParentId="22562" CreationDate="2020-01-15T13:44:42.100" Score="0" Body="&lt;p&gt;Afaik this string is hardcoded into vim (and translated). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would have to patch and recompile vim yourself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant code is &lt;a href=&quot;https://github.com/vim/vim/blob/94b6fb78c578caab014fea4029bb534246a95f6f/src/po/es.po#L4914&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; (thanks @Rich). &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-01-18T00:54:20.223" LastActivityDate="2020-01-18T00:54:20.223" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22570" PostTypeId="1" CreationDate="2020-01-15T14:18:01.113" Score="6" ViewCount="1621" Body="&lt;p&gt;Suppose I have a defined text object. For example, I have a &lt;code&gt;ii&lt;/code&gt; text block which defines all the contiguous lines around the cursor at the same level of indentation or deeper. I know what it means to, say, yank or delete this text block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a consequence, as I move through the document, there is a well defined &quot;start of this type of block&quot; and &quot;end of this type of block&quot;. I would like to have a motion which would take me to these positions. For example, given: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a piece of &#xA;  indented&#xA;  text&#xA;    with&#xA;  some words&#xA;in it&#xA;  and some&#xA;  more&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if I were to do something like &lt;code&gt;geii&lt;/code&gt; (&quot;go end inner indent?&quot;) from &lt;code&gt;indented&lt;/code&gt;, I would end up at &quot;some words&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would similarly be nice to be able to go to the &quot;next start&quot; of a block. In this case, the &quot;next start&quot; of an indentation block would be any time the indentation increases. So from the top, you would move to &quot;indented&quot;, then &quot;with&quot;, then to &quot;and some&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin that achieves this? All the better if it's independent of the specific kind of text block.&lt;/p&gt;&#xA;" OwnerUserId="17288" LastActivityDate="2020-01-15T17:14:32.117" Title="Is there a way to &quot;move to the beginning of the next text object&quot;?" Tags="|cursor-motions|custom-text-object|object-motions|plugin-textobj-user|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22572" PostTypeId="2" ParentId="22570" CreationDate="2020-01-15T14:46:53.030" Score="4" Body="&lt;p&gt;This doesn't answer your more general question about text objects, but you can achieve the behaviour in your specific indentation-based example with folds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal foldmethod=indent&#xA;setlocal shiftwidth=2&#xA;setlocal foldlevel=99&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27foldmethod%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'foldmethod'&lt;/code&gt;&lt;/a&gt; tells Vim that you want to use indentation based folding. Setting &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27shiftwidth%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'shiftwidth'&lt;/code&gt;&lt;/a&gt; tells Vim the size of each indentation level, and setting &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27foldlevel%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'foldlevel'&lt;/code&gt;&lt;/a&gt; tells Vim always to display the folds as open. (You can omit this if you actually want to &lt;em&gt;use&lt;/em&gt; the folding feature, instead of just borrowing its motions.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can use &lt;a href=&quot;https://vimhelp.org/fold.txt.html#]z&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;]z&lt;/code&gt;&lt;/a&gt; as your &quot;go end inner indent&quot; command and for your &quot;next start&quot; command, you can use &lt;a href=&quot;https://vimhelp.org/fold.txt.html#zj&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;zj&lt;/code&gt;&lt;/a&gt;. You can also use &lt;a href=&quot;https://vimhelp.org/fold.txt.html#[z&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;[z&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/fold.txt.html#zk&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;zk&lt;/code&gt;&lt;/a&gt; to move up the file in a similar manner. &lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-15T14:54:12.303" LastActivityDate="2020-01-15T14:54:12.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22573" PostTypeId="2" ParentId="22570" CreationDate="2020-01-15T15:17:40.877" Score="5" Body="&lt;p&gt;For the general case, you can try &lt;a href=&quot;http://vimhelp.org/map.txt.html#:map-operator&quot; rel=&quot;nofollow noreferrer&quot;&gt;creating new operators&lt;/a&gt;, &lt;code&gt;gs&lt;/code&gt; and &lt;code&gt;ge&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GoStart(type) abort&#xA;  normal! `[&#xA;endfunction&#xA;&#xA;function! GoEnd(type) abort&#xA;  normal! `]&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; gs :set opfunc=GoStart&amp;lt;CR&amp;gt;g@&#xA;nnoremap &amp;lt;silent&amp;gt; ge :set opfunc=GoEnd&amp;lt;CR&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When Vim invokes the operator functions after you type your text-object, it sets the &lt;code&gt;'[&lt;/code&gt; and &lt;code&gt;']&lt;/code&gt; marks to be the start and end of that text-object. The functions themselves simply jump to the locations of these marks by using the &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Anormal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:normal&lt;/code&gt;&lt;/a&gt; command to execute the  &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%60%5B&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;`[&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/motion.txt.html#%60%5D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;`]&lt;/code&gt;&lt;/a&gt; motions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't tested these with your &lt;code&gt;ii&lt;/code&gt; text object as you don't say how you've defined that, but they work fine with the various text objects I have tested them with, e.g. &lt;code&gt;gsis&lt;/code&gt;, &lt;code&gt;geip&lt;/code&gt;, &lt;code&gt;gsa(&lt;/code&gt;, &lt;code&gt;gea{&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, note this proviso &lt;a href=&quot;https://github.com/tommcdo/vim-ninja-feet/issues/3#issuecomment-348757810&quot; rel=&quot;nofollow noreferrer&quot;&gt;as described by&lt;/a&gt; the author of the related &lt;a href=&quot;https://vi.stackexchange.com/a/22574/343&quot;&gt;ninja-feet plugin&lt;/a&gt;, &lt;a href=&quot;https://vi.stackexchange.com/users/64/tommcdo&quot;&gt;Tom McDonald&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It's easy to make an operator that does nothing but move the cursor. This gives us free compatibility with all motions (built-in and user-defined), but it has an unacceptable side-effect: as all operators are repeatable, it overrides the previous operation to be repeated by [the dot command] &lt;code&gt;.&lt;/code&gt;. This would be quite jarring to a user.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-15T17:14:32.117" LastActivityDate="2020-01-15T17:14:32.117" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22574" PostTypeId="2" ParentId="22570" CreationDate="2020-01-15T16:48:04.853" Score="3" Body="&lt;h2&gt;Plugin &lt;a href=&quot;https://github.com/tommcdo/vim-ninja-feet&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-ninja-feet&lt;/a&gt; by tommcdo&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Currently, this plugin provides following square bracket mappings (do not overlook the square in the definition):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{operator}[{text object}&#xA;                        Perform {operator} from the cursor to the beginning&#xA;                        of the text object defined by {text object}.&#xA;{operator}]{text object}&#xA;                        Perform {operator} from the cursor to the end of the&#xA;                        text object defined by {text object}.&#xA;&#xA;z[{text object}              Enter |Insert| mode at the beginning of {text object}.&#xA;&#xA;z]{text object}              Enter |Insert| mode at the end of {text object}.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are probably interested in &lt;a href=&quot;https://github.com/tommcdo/vim-ninja-feet/issues/3&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue #3 Make it work in Normal mode&lt;/a&gt;: you can change &lt;code&gt;z[{text object}&lt;/code&gt; and &lt;code&gt;z]{text object}&lt;/code&gt; to not automatically switch to insert mode by following diff yourself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/.vim/pack/tommcdo/opt/ninja-feet/plugin master*&#xA;❯ git diff&#xA;diff --git a/plugin/ninja-feet.vim b/plugin/ninja-feet.vim&#xA;index 4a2a9f1..ee07408 100644&#xA;--- a/plugin/ninja-feet.vim&#xA;+++ b/plugin/ninja-feet.vim&#xA;@@ -28,13 +28,11 @@ function! s:ninja_strike(mode)&#xA; endfunction&#xA;&#xA; function! s:ninja_insert(mode)&#xA;-       let op = a:mode == 'line' ? 'O' : 'i'&#xA;-       call feedkeys('`['.op, 'n')&#xA;+       call feedkeys('`[', 'n')&#xA; endfunction&#xA;&#xA; function! s:ninja_append(mode)&#xA;-       let op = a:mode == 'line' ? 'o' : 'a'&#xA;-       call feedkeys('`]'.op, 'n')&#xA;+       call feedkeys('`]', 'n')&#xA; endfunction&#xA;&#xA; function! s:map_expr(sid, type, direction, count)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2020-01-15T16:48:04.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22575" PostTypeId="1" CreationDate="2020-01-15T17:44:54.410" Score="3" ViewCount="518" Body="&lt;p&gt;I want to replace the default behavior of the arrows in insert mode, so that they behave like gk and gj, I have used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;up&amp;gt; &amp;lt;Esc&amp;gt;gka&#xA;inoremap &amp;lt;down&amp;gt; &amp;lt;Esc&amp;gt;gja&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this doesn't hold the cursor well. What's the right way to do it?&lt;/p&gt;&#xA;" OwnerUserId="26521" LastEditorUserId="26521" LastEditDate="2020-01-15T18:21:43.820" LastActivityDate="2020-01-15T18:21:43.820" Title="Change &lt;up&gt;/&lt;down&gt; to gk/gj in insert mode" Tags="|key-bindings|cursor-motions|insert-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22576" PostTypeId="2" ParentId="22575" CreationDate="2020-01-15T18:03:55.130" Score="2" Body="&lt;p&gt;I assume &quot;doesn't hold the cursor&quot; applies to the corner case when the cursor is at the end of the line and &lt;code&gt;virtualedit&lt;/code&gt; is empty (then &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; will move cursor one position backward, to the last existing character). That's often an issue for insert-mode mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's :h i_ctrl-\_ctrl-o which executes one normal mode command without touching the cursor position.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;down&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-o&amp;gt;gj&#xA;inoremap &amp;lt;up&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-o&amp;gt;gk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-01-15T18:03:55.130" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22577" PostTypeId="1" AcceptedAnswerId="22581" CreationDate="2020-01-15T18:24:59.747" Score="3" ViewCount="1806" Body="&lt;p&gt;I want to move the cursor to the indentation of the line above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As seen from the example below, when I move the cursor down (&lt;code&gt;j&lt;/code&gt; or &lt;code&gt;arrow-down&lt;/code&gt;), it goes to the start of the line. This is both true for insert and normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I'm in normal mode and press &lt;code&gt;o&lt;/code&gt; to insert a line below the current line, then Vim knows it should move the cursor to the indentation of the line above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OjxMR.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OjxMR.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26505" LastEditorUserId="26505" LastEditDate="2020-01-27T18:40:17.590" LastActivityDate="2020-01-27T18:40:17.590" Title="How to ident the cursor to the indentation of the above line?" Tags="|insert-mode|normal-mode|macos|" AnswerCount="1" CommentCount="17" ContentLicense="CC BY-SA 4.0" />
  <row Id="22578" PostTypeId="1" CreationDate="2020-01-15T19:42:44.627" Score="5" ViewCount="230" Body="&lt;p&gt;I have two nearly identical very large files (890,000+ rows of exactly 899 characters each fixed length file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On rows 289141-289148 one file has a pipe character in column 38, and the other file has a space in that position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I force vimdiff to look at them line by line, it finds the difference.  For example, if I delete and reinsert the line, vim finds the difference.  But, when I first opened the files, vim presented them as having no differences. Also, when I run &lt;code&gt;:diffupdate&lt;/code&gt;, vim does not recognize the difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a defect in VimDiff, or can you think of something I might be doing incorrectly?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From first file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ABCDEFGH            ABCDEFGHI44    }&quot;|                           S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From second file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ABCDEFGH            ABCDEFGHI44    }&quot;                            S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also note: I tested the theory that it was something special about the pipe character.  Even when I replaced the pipes with a normal character (e.g., &lt;code&gt;j&lt;/code&gt;), it still had the same behavior of not recognizing the difference.  &lt;/p&gt;&#xA;" OwnerUserId="26523" LastEditorUserId="1238" LastEditDate="2020-01-18T15:29:54.357" LastActivityDate="2020-01-18T15:29:54.357" Title="VIMDIFF missing small differences" Tags="|vimdiff|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22579" PostTypeId="2" ParentId="11061" CreationDate="2020-01-15T20:48:10.393" Score="0" Body="&lt;p&gt;Inside my vimrc I have a line that loads my plugins like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source ~/.vim/rc/bundles.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then inside my bundles.vim I do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/bundle')&#xA;  Plug 'foo/vim-someplugin'&#xA;  source ~/.vim/rc/plugins/someplugin.vim&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you don't want to use hard coded paths I recommend something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'source' fnamemodify(expand('&amp;lt;sfile&amp;gt;'), ':h') . '/path/to/file.vim'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source &amp;lt;sfile&amp;gt;:h/.vim/Plugins.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as Maxim pointed out&lt;/p&gt;&#xA;" OwnerUserId="22630" LastActivityDate="2020-01-15T20:48:10.393" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22580" PostTypeId="2" ParentId="22565" CreationDate="2020-01-16T03:51:25.713" Score="1" Body="&lt;p&gt;Those snippets mentioned in the question have the &lt;strong&gt;auto-expand option&lt;/strong&gt; enabled, as there is an 'A' included in the options of each snippet (eg. &lt;code&gt;bA&lt;/code&gt;, &lt;code&gt;wA&lt;/code&gt;). To disable auto-expansion of a snippet, remove the 'A'. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet mk &quot;Math&quot; w&#xA;$${1}$`!p&#xA;if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:&#xA;    snip.rv = ' '&#xA;else:&#xA;    snip.rv = ''&#xA;`$2&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, with &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; as the trigger, typing &lt;code&gt;mk&lt;/code&gt; stays as is, but &lt;code&gt;mk&amp;lt;tab&amp;gt;&lt;/code&gt; expands to &lt;code&gt;$$&lt;/code&gt;, with the cursor in between the &lt;code&gt;$&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, have a look at the various snippet options &lt;code&gt;:h Ultisnips-snippet-options&lt;/code&gt; (you may need to run &lt;code&gt;:helptags ALL&lt;/code&gt; before this).&lt;/p&gt;&#xA;" OwnerUserId="21495" LastEditorUserId="21495" LastEditDate="2020-01-16T04:05:39.177" LastActivityDate="2020-01-16T04:05:39.177" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22581" PostTypeId="2" ParentId="22577" CreationDate="2020-01-16T11:18:26.677" Score="3" Body="&lt;p&gt;The reason that &lt;code&gt;o&lt;/code&gt; works the way it does is that, with &lt;code&gt;autoindent&lt;/code&gt; or &lt;code&gt;smartindent&lt;/code&gt; set, it will &lt;em&gt;insert&lt;/em&gt; whitespace in order to match the indentation of the previous line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you move downwards in normal mode without entering insert mode, the line remains empty and no text is added, so the cursor moves to the start of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest way to achieve your goal is to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Accept the fact that when you move to an empty line in normal mode the cursor will move to the start of the line, and&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a more sophisticated method of auto indentation, and start editing the line by typing either &lt;code&gt;S&lt;/code&gt; or &lt;code&gt;cc&lt;/code&gt;. For the language in your screenshot (Go?) &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27cindent%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'cindent'&lt;/code&gt;&lt;/a&gt; should work fine, and when it is set &lt;code&gt;S&lt;/code&gt; or &lt;code&gt;cc&lt;/code&gt; on an empty line will insert indent as you desire, but even better than this would be to use Vim's included &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27indentexpr%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'indentexpr'&lt;/code&gt;&lt;/a&gt; for this language. You can do this by allowing Vim to set up indentation when it sets the &lt;a href=&quot;https://vimhelp.org/filetype.txt.html#filetype&quot; rel=&quot;nofollow noreferrer&quot;&gt;filetype&lt;/a&gt;, which you can achieve by adding the following line to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this in place, &lt;code&gt;'indentexpr'&lt;/code&gt; will be set to &lt;code&gt;GoIndent(v:lnum)&lt;/code&gt; when you start editing a Go file, and using &lt;code&gt;cc&lt;/code&gt; or &lt;code&gt;S&lt;/code&gt; on an empty line will insert the appropriate indent.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/usr_30.txt.html#30.3&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 30.3&lt;/code&gt;&lt;/a&gt; for more details on automatic indenting.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-16T12:06:56.313" LastActivityDate="2020-01-16T12:06:56.313" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22582" PostTypeId="1" CreationDate="2020-01-16T14:59:53.123" Score="1" ViewCount="205" Body="&lt;p&gt;I'm trying to clean out erroneous entries in my command history. Though I could (in theory) use &lt;code&gt;:call histdel(&quot;expression&quot;)&lt;/code&gt; it would be easier for me to just delete the entries from the &lt;code&gt;.viminfo&lt;/code&gt; file. Also, for some reason I can't get &lt;code&gt;hisdel()&lt;/code&gt; to work, but that's a separate problem (probably).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try editing the file I'm told it is read only. When I try to save I'm told I can't do that because it's read only. I tried using &lt;code&gt;sudo vim ~/path/to/home/.viminfo&lt;/code&gt;, but I get the same error. I tried &lt;code&gt;chmod 744 ~/.viminfo&lt;/code&gt;. I even tried &lt;code&gt;chmod 777&lt;/code&gt;. In every case I'm told the file is read only. I checked the file permissions afterward to make sure vim didn't change the permissions, but they are still the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was able to edit the file with &lt;code&gt;nano&lt;/code&gt;, but I hate nano, so I'm guessing it isn't a file permission issue, but rather something Vim does not want the user to do...despite the file containing the words &quot;You may edit it if you're careful!&quot;.&lt;/p&gt;&#xA;" OwnerUserId="18462" LastEditorUserId="18462" LastEditDate="2020-01-16T15:08:34.877" LastActivityDate="2020-01-16T15:08:34.877" Title=".viminfo is read-only even after chmod 744" Tags="|viminfo|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22583" PostTypeId="1" CreationDate="2020-01-16T19:13:51.003" Score="0" ViewCount="692" Body="&lt;p&gt;Is there a &quot;good&quot; way to rename the terminal buffer in neovim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that renaming is possible with the &lt;code&gt;:file&lt;/code&gt; command, and that works fine for current session. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with this approach is that it breaks &lt;code&gt;:mksession&lt;/code&gt;. If you change the terminal window name with &lt;code&gt;:file&lt;/code&gt; and save the session, upon restore it will no longer create a terminal window, but a regular file buffer instead. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to avoid this.&lt;/p&gt;&#xA;" OwnerUserId="13992" LastEditorUserId="1238" LastEditDate="2020-01-18T11:01:45.607" LastActivityDate="2021-01-26T13:41:54.687" Title="Rename neovim terminal buffer without breaking :mksession" Tags="|neovim|terminal|terminal-buffer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22585" PostTypeId="1" CreationDate="2020-01-17T02:44:57.607" Score="1" ViewCount="393" Body="&lt;p&gt;I have a weird problem with VIM, both at work and at home (2 different computers):&#xA;When I open a text in VIM, sometimes it is displaying it correctly, sometime not (I'd say 1 every 3 it works fine, others not, it's random)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/1BrHe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1BrHe.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KpnoM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KpnoM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26539" LastActivityDate="2020-01-17T02:44:57.607" Title="gVim 8.2, display problem" Tags="|font|color|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22586" PostTypeId="2" ParentId="22583" CreationDate="2020-01-17T05:52:21.537" Score="1" Body="&lt;p&gt;From &lt;code&gt;:h terminal-start&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the terminal starts, the buffer contents are updated and the buffer is&#xA;  named in the form of &lt;code&gt;term://{cwd}//{pid}:{cmd}&lt;/code&gt;. This naming scheme is used&#xA;  by |:mksession| to restore a terminal buffer (by restarting the {cmd}).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Therefore you can not do this, unless you manually &quot;swap&quot; buffer names before &lt;code&gt;:mksession&lt;/code&gt; and on &lt;code&gt;autocmd SessionLoadPost&lt;/code&gt;. But I don't believe such oversophisticated scheme is worth.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-01-17T05:52:21.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22587" PostTypeId="1" CreationDate="2020-01-17T06:36:33.920" Score="5" ViewCount="2085" Body="&lt;p&gt;Just noticed that this doesn't work for me. I have to hit &lt;code&gt;Ctrl-Shift-6&lt;/code&gt; (&lt;code&gt;Ctrl-^&lt;/code&gt;) to activate the shortcut. Launching up my Vim it worked just fine so it's not something weird going on with my machine. Any idea what could be up with this? (I've disabled all my plugins (except the default plugins) and my &lt;code&gt;init.vim&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neovim 0.4.3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim 8.1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Windows 10&lt;/p&gt;&#xA;" OwnerUserId="24943" LastActivityDate="2020-01-18T12:31:20.117" Title="Ctrl-6 doesn't switch to the last buffer (Neovim)" Tags="|neovim|neovim-qt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22588" PostTypeId="2" ParentId="22587" CreationDate="2020-01-17T08:29:47.640" Score="5" Body="&lt;p&gt;justinmk (current neovim leader?) states &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ctrl-6 only works by accident in some terminals. The actual builtin mapping is &lt;code&gt;&amp;lt;C-^&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/onivim/oni/issues/2002#issuecomment-377688787&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/onivim/oni/issues/2002#issuecomment-377688787&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;a href=&quot;https://github.com/equalsraf/neovim-qt/issues/170&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/equalsraf/neovim-qt/issues/170&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it just doesn't work for neovim (nvim.exe and nvim-qt.exe) even though  neovim help is the same as vim for the &lt;code&gt;:h CTRL-6&lt;/code&gt; chapter.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-01-17T08:29:47.640" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22589" PostTypeId="1" AcceptedAnswerId="22590" CreationDate="2020-01-17T11:03:49.057" Score="2" ViewCount="553" Body="&lt;p&gt;I often repeat the following commands when I edit code:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;yy&lt;/code&gt; - yank the line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gcc&lt;/code&gt; - comment out the line (so that I can visually see all the changes later)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; - paste back the copied version what I will edit&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;i&lt;/code&gt; - jump into insert mode&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I tried to do the mapping as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap yc yygccpi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem seems to be with the commentary plugin's key-combination. Even if I remap &lt;code&gt;gcc&lt;/code&gt; to &lt;code&gt;yc&lt;/code&gt;, nothing happens. Other bindings, like &lt;code&gt;yyp&lt;/code&gt; and &lt;code&gt;3l&lt;/code&gt;, are working.&#xA;The &lt;code&gt;nnoremap&lt;/code&gt; is at the end of my vimrc, well after the &lt;code&gt;packloadall&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I accomplish this keymapping, and what was the problem?&lt;/p&gt;&#xA;" OwnerUserId="17773" LastEditorUserId="10604" LastEditDate="2020-01-17T20:33:46.337" LastActivityDate="2020-01-17T20:33:46.337" Title="How can I use a plugin mapping in my own mapping?" Tags="|key-bindings|plugin-vim-commentary|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22590" PostTypeId="2" ParentId="22589" CreationDate="2020-01-17T11:42:06.743" Score="5" Body="&lt;p&gt;Change you mapping to &lt;code&gt;nmap&lt;/code&gt; instead of &lt;code&gt;nnoremap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap&lt;/code&gt; uses &quot;default&quot; mappings on the right mapped side (it doesn't allow nested mappings, like &lt;code&gt;gcc&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap yc yygccpi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-01-17T11:47:13.980" LastActivityDate="2020-01-17T11:47:13.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22591" PostTypeId="2" ParentId="22566" CreationDate="2020-01-17T12:29:05.730" Score="4" Body="&lt;p&gt;A general recommendation when debugging an issue is to start vim with &lt;code&gt;-u NONE&lt;/code&gt;, which skips all initialization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just want to start vim without plugins and with a custom .vimrc file start vim with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --noplugin -u &amp;lt;test_vimrc_file&amp;gt; &amp;lt;your_file_name&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then issue the command &lt;code&gt;:packadd &amp;lt;package_name&amp;gt;&lt;/code&gt; to load the plugin you want to test.&lt;/p&gt;&#xA;" OwnerUserId="17773" LastEditorUserId="17773" LastEditDate="2020-02-03T07:01:59.120" LastActivityDate="2020-02-03T07:01:59.120" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22592" PostTypeId="1" CreationDate="2020-01-17T21:41:33.110" Score="2" ViewCount="257" Body="&lt;p&gt;after some tinkering with xprop and window resizing, I'm almost certain it's (neo)vim, not the terminal emulator or the window manager that's shortening the x11 window title name (one of these x11 window attributes &lt;code&gt;_NET_WM_ICON_NAME&lt;/code&gt;, &lt;code&gt;_NET_WM_NAME&lt;/code&gt;, &lt;code&gt;WM_ICON_NAME&lt;/code&gt;, &lt;code&gt;WM_NAME&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;specifically it's shortening anything before &quot; - NVIM&quot;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I just remembered that useful window names with file name and current directory path is not default behavior, and is enabled with &lt;code&gt;set title&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="20087" LastEditorUserId="20087" LastEditDate="2020-01-17T22:07:00.900" LastActivityDate="2020-01-18T02:41:11.053" Title="how to stop vim from shortening window title to terminal width?" Tags="|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22593" PostTypeId="1" CreationDate="2020-01-18T01:59:35.980" Score="1" ViewCount="571" Body="&lt;p&gt;Thanks to a comment on reddit I was able to move my FZF search to a floating window and whilst it looks cool my main gain was that it's faster or at least it feels faster because it's no longer messing with my splits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I Was wondering, would it be possible to display NERDtree in floating window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so How?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked through NERDtree's source code but I can't find the functionality to intercept/override to provide my own custom functionality for where to display NERDTree's buffer.&lt;/p&gt;&#xA;" OwnerUserId="11603" LastActivityDate="2022-08-17T03:49:13.233" Title="How to display NERDtree buffer in a floating window" Tags="|neovim|plugin-nerdtree|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22594" PostTypeId="2" ParentId="22587" CreationDate="2020-01-18T02:12:12.760" Score="2" Body="&lt;p&gt;I am using Neovim both on Linux, Mac and Windows. For terminal Neovim, it seems that &lt;code&gt;ctrl + 6&lt;/code&gt; works as expected for me. On Windows, &lt;code&gt;Ctrl-6&lt;/code&gt; does not work. FYI, the terminal I am using for different platform:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Windows: &lt;a href=&quot;https://github.com/equalsraf/neovim-qt&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvim-qt&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Linux: &lt;a href=&quot;https://mintty.github.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;mintty&lt;/a&gt; (Connected to remote Linux server via ssh)&lt;/li&gt;&#xA;&lt;li&gt;Mac: Either &lt;a href=&quot;https://iterm2.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;iterm2&lt;/a&gt;, &lt;a href=&quot;https://github.com/alacritty/alacritty&quot; rel=&quot;nofollow noreferrer&quot;&gt;Alacritty&lt;/a&gt;, &lt;a href=&quot;https://sw.kovidgoyal.net/kitty/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kitty&lt;/a&gt; works.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For Neovim GUI client, you can add the following mapping to your &lt;code&gt;ginit.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;C-6&amp;gt; &amp;lt;C-^&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15292" LastEditorUserId="15292" LastEditDate="2020-01-18T12:31:20.117" LastActivityDate="2020-01-18T12:31:20.117" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22595" PostTypeId="2" ParentId="22592" CreationDate="2020-01-18T02:41:11.053" Score="2" Body="&lt;p&gt;it looks like there's no option to configure that, but you can set the title by setting &lt;code&gt;titlestring&lt;/code&gt; (for more info see &lt;code&gt;:help titlestring&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you can set &lt;code&gt;titlestring&lt;/code&gt; on each buffer enter with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autocmd bufenter * let &amp;amp;titlestring = expand('%:p').' - NVIM'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You use &lt;code&gt;autocmd bufenter *&lt;/code&gt; to run something on each buffer enter, the asterisk means the file extension doesn't matter,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and use &lt;code&gt;let&lt;/code&gt; with Vim options by prefixing the option name with a &lt;code&gt;&amp;amp;&lt;/code&gt; (see &lt;code&gt;:help :let-option&lt;/code&gt;) &lt;sup&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/17983/20087&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and use &lt;code&gt;expand('%:p')&lt;/code&gt; to get the full path of the file opened in current buffer &lt;sup&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/1885/20087&quot;&gt;[2]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="20087" LastActivityDate="2020-01-18T02:41:11.053" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22596" PostTypeId="1" AcceptedAnswerId="22597" CreationDate="2020-01-18T03:07:05.250" Score="7" ViewCount="1160" Body="&lt;p&gt;I am getting some unexpected behavior when trying to run the &lt;code&gt;zip&lt;/code&gt; shell command using Vim's &lt;code&gt;job_start()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, suppose I have two images (&lt;code&gt;im1.png&lt;/code&gt; and &lt;code&gt;im2.jpg&lt;/code&gt;) in the directory &lt;code&gt;/home/username/test_dir/&lt;/code&gt; and I want to zip them. This shell command will zip the files:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;cd /home/username/test_dir/ &amp;amp;&amp;amp; zip ims.zip im1.png im2.jpg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, I make a simple vimrc file (&lt;code&gt;/home/username/test_dir/simple_vimrc&lt;/code&gt;) containing only a function that runs that command via &lt;code&gt;job_start()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;function! Test()&#xA;    let job = job_start(['/bin/sh', '-c', 'cd /home/username/test_dir/ &amp;amp;&amp;amp; zip ims.zip im1.png im2.jpg'])&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I open Vim as&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;vim --clean -u /home/username/test_dir/simple_vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I run &lt;code&gt;:call Test()&lt;/code&gt;, the &lt;code&gt;zip&lt;/code&gt; command does not seem to work - instead of producing a zip file it just produces an empty file with a random name. But here are some interesting observations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Adding the job option &lt;code&gt;{'err_io': 'buffer'}&lt;/code&gt; to the &lt;code&gt;job_start()&lt;/code&gt; command makes it work. But it fails with all other &lt;code&gt;'err_io'&lt;/code&gt; options (&lt;code&gt;'out'&lt;/code&gt;, &lt;code&gt;'null'&lt;/code&gt;, &lt;code&gt;'pipe'&lt;/code&gt;, and &lt;code&gt;'file'&lt;/code&gt;). This seems strange because no error is produced anyway.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I added the job options &lt;code&gt;'out_cb'&lt;/code&gt;, &lt;code&gt;'err_cb'&lt;/code&gt;, &lt;code&gt;'close_cb'&lt;/code&gt;, and &lt;code&gt;'exit_cb'&lt;/code&gt; to the &lt;code&gt;job_start()&lt;/code&gt; command with blank callback functions (I tested each option individually). Strangely, all options except &lt;code&gt;'exit_cb'&lt;/code&gt; made the command work.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The command works if I run the &lt;code&gt;let job = ...&lt;/code&gt; command directly in Vim's colon command line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I tried all cases above by replacing the &lt;code&gt;zip&lt;/code&gt; command with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a &lt;code&gt;pdflatex&lt;/code&gt; command to compile a simple Latex file (succeeded/failed in all the same cases as the &lt;code&gt;zip&lt;/code&gt; command)&lt;/li&gt;&#xA;&lt;li&gt;a&lt;code&gt;gcc&lt;/code&gt; command to compile a simple C file (succeeded in all cases)&lt;/li&gt;&#xA;&lt;li&gt;a &lt;code&gt;python&lt;/code&gt; command to run a simple Python file (succeeded in all cases)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm confused as to why &lt;code&gt;job_start()&lt;/code&gt; successfully runs the command only in these certain cases. Is this expected behavior or a bug I should report?&lt;/p&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2020-01-18T03:07:05.250" Title="job_start() command only works with seemingly random job options" Tags="|external-command|job-control|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22597" PostTypeId="2" ParentId="22596" CreationDate="2020-01-18T03:07:05.250" Score="9" Body="&lt;p&gt;I think I figured this out myself. I believe the problem was that my job was being deleted before the &lt;code&gt;zip&lt;/code&gt; command finished. I guess Vim deletes a job object if there are no references to it. So the solution was to turn my &lt;code&gt;job&lt;/code&gt; variable into a script-local variable to prevent it from being deleted. So, I changed my line &lt;code&gt;let job = ...&lt;/code&gt; to &lt;code&gt;let s:job = ...&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured this out by reading through Vim's help pages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help job_start&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;...&#xA;                Note that the job object will be deleted if there are no&#xA;                references to it.  This closes the stdin and stderr, which may&#xA;                cause the job to fail with an error.  To avoid this keep a&#xA;                reference to the job.  Thus instead of:&#xA;        call job_start(&amp;apos;my-command&amp;apos;)&#xA;                use:&#xA;        let myjob = job_start(&amp;apos;my-command&amp;apos;)&#xA;                and unlet &amp;quot;myjob&amp;quot; once the job is not needed or is past the&#xA;                point where it would fail (e.g. when it prints a message on&#xA;                startup).  Keep in mind that variables local to a function&#xA;                will cease to exist if the function returns.  Use a&#xA;                script-local variable if needed:&#xA;        let s:myjob = job_start(&amp;apos;my-command&amp;apos;)&#xA;...&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2020-01-18T03:07:05.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22598" PostTypeId="1" AcceptedAnswerId="22600" CreationDate="2020-01-18T14:18:25.387" Score="1" ViewCount="500" Body="&lt;p&gt;I'm trying to do the following mapping in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; / :call &amp;lt;SID&amp;gt;FooFunction()&amp;lt;CR&amp;gt;&amp;lt;BAR&amp;gt;norm! /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I press &lt;code&gt;/&lt;/code&gt;, instead of running the function and then starting the search prompt, I get this text inserted to my buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rm! /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also tried to put the normal command to as the last line of &lt;code&gt;FooFunction&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:FooFunction() abort&#xA;    ...&#xA;    ...&#xA;    norm! /&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but then I don't get any prompt after pressing &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this?&lt;/p&gt;&#xA;" OwnerUserId="21062" LastEditorUserId="21062" LastEditDate="2020-01-18T17:46:22.733" LastActivityDate="2020-01-19T06:55:35.987" Title="How to start search `/` from a mapping?" Tags="|vimrc|key-bindings|search|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22599" PostTypeId="1" CreationDate="2020-01-18T14:43:13.700" Score="0" ViewCount="191" Body="&lt;p&gt;I am trying to configure &lt;a href=&quot;https://tabnine.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;TabNine&lt;/a&gt; and &lt;a href=&quot;https://intelephense.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Intelephense&lt;/a&gt; with &lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;coc&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like the autosuggestions offered by TabNine. But Intelephense plugin is enabled, I am seeing suggestions from only Intelephense and not TabNine (probably because Intelephense is much faster).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use TabNine for autocompletion, but continue to use the other  features of Intelephense engine like validation, function signature overlay, go to definition etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I turn off the autocomplete feature of Intelephense, or prioritize TabNine over Intelephense? &lt;/p&gt;&#xA;" OwnerUserId="25529" LastActivityDate="2024-01-29T16:04:20.760" Title="Prioritize TabNine autosuggestion over Intelephense with Coc" Tags="|plugin-coc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22600" PostTypeId="2" ParentId="22598" CreationDate="2020-01-18T14:49:50.927" Score="1" Body="&lt;p&gt;Figured out the the &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; was hiding the search prompt, and also the mapping can be done just like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap / :call &amp;lt;SID&amp;gt;FooFunction()&amp;lt;CR&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21062" LastActivityDate="2020-01-18T14:49:50.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22601" PostTypeId="1" AcceptedAnswerId="22602" CreationDate="2020-01-18T14:53:04.600" Score="2" ViewCount="730" Body="&lt;p&gt;I just started using &lt;code&gt;vim&lt;/code&gt; and I installed &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow noreferrer&quot;&gt;tpope/vim-pathogen&lt;/a&gt; and then &lt;a href=&quot;https://github.com/vim-airline/vim-airline-themes&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-airline/vim-airline-themes&lt;/a&gt; plugin to use these themes. Then I changed my &lt;code&gt;.vimrc&lt;/code&gt; to set up the &lt;code&gt;papercolor&lt;/code&gt; theme, &lt;code&gt;powerline&lt;/code&gt; fonts and line numbers permanently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;syntax on&#xA;filetype plugin indent on&#xA;&#xA;&quot;Theme Section&#xA;let g:airline_theme='papercolor'&#xA;let g:airline_powerline_fonts = 1&#xA;set nu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The theme works and it's dope. But there's the main issue—there is no custom background, whatever theme I use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you can look at the screenshot:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4rXnP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4rXnP.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the theme is supposed to look like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/h10kD.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h10kD.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;code&gt;KDE Konsole&lt;/code&gt; and &lt;code&gt;zsh&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~ &#xA;✦ ➜ echo $TERM&#xA;xterm-256color&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my &lt;code&gt;.zshrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# If you come from bash you might have to change your $PATH.&#xA;# export PATH=$HOME/bin:/usr/local/bin:$PATH&#xA;&#xA;# Path to your oh-my-zsh installation.&#xA;export ZSH=&quot;/home/dagoth/.oh-my-zsh&quot;&#xA;&#xA;ZSH_THEME=&quot;spaceship&quot;&#xA;&#xA;plugins=(git)&#xA;plugins=(zsh-autosuggestions)&#xA;ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE=&quot;fg=#ffbf00,underline&quot;&#xA;&#xA;ZSH_DISABLE_COMPFIX=true&#xA;&#xA;source $ZSH/oh-my-zsh.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26562" LastEditorUserId="10604" LastEditDate="2020-01-20T14:22:23.163" LastActivityDate="2020-01-20T14:22:23.163" Title="How to turn on airline theme's background in vim?" Tags="|vimrc|vimscript|colorscheme|plugin-airline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22602" PostTypeId="2" ParentId="22601" CreationDate="2020-01-18T15:29:11.530" Score="1" Body="&lt;p&gt;This looks as expected. Airline is a statusline plugin (read &lt;code&gt;:help statusline&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To set the editor's colorscheme, use &lt;code&gt;:colorscheme [name]&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-01-18T15:29:11.530" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22603" PostTypeId="1" AcceptedAnswerId="22604" CreationDate="2020-01-18T23:56:39.040" Score="1" ViewCount="441" Body="&lt;p&gt;Is there a way search backward from the cursor for a line that doesn't contain a pattern?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, many of my lines match the regular expression &lt;code&gt;^   adding: \i\+&lt;/code&gt;.  I want to find the first line above the current line which doesn't match this pattern, even if it is an empty line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to use zero-width matching expressions because I don't want to have to specify a non-zero-width matching portion, which could cause the search to miss some qualifying lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also avoided global commands, including the inverse global command &lt;code&gt;:v&lt;/code&gt;, because I want to search backward from the cursor to the first occurrence.&lt;/p&gt;&#xA;" OwnerUserId="7041" LastActivityDate="2020-01-19T01:34:39.067" Title="Search backward for first line not matching a pattern?" Tags="|search|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22604" PostTypeId="2" ParentId="22603" CreationDate="2020-01-19T01:34:39.067" Score="2" Body="&lt;p&gt;In your specific case, you can use a zero-width negative match and still have it work on empty lines.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't want to use zero-width matching expressions because I don't want to have to specify a non-zero-width matching portion, which could cause the search to miss some qualifying lines.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you can use the &lt;code&gt;^&lt;/code&gt; as the matching portion outside the zero-width negative lookahead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;?^\( adding: \i\+\)\@!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will properly skip the &lt;code&gt;adding:&lt;/code&gt; lines and it will stop on all other lines, including empty ones.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-19T01:34:39.067" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22605" PostTypeId="2" ParentId="22598" CreationDate="2020-01-19T06:55:35.987" Score="3" Body="&lt;p&gt;It seems you've already found a working solution, but I wanted to address the issues with your attempted approaches.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But when I press &lt;code&gt;/&lt;/code&gt;, instead of running the function and then starting the search prompt, I get this text inserted to my buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rm! /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You're getting this result because you're using &lt;code&gt;&amp;lt;BAR&amp;gt;&lt;/code&gt; in your mapping &lt;em&gt;after&lt;/em&gt; you already left command-line mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;:call &amp;lt;SID&gt;FooFunction()&lt;b&gt;&amp;lt;CR&gt;&lt;/b&gt;&amp;lt;BAR&gt;norm! /&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You're using a &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, which means you're back in normal mode, so &lt;code&gt;&amp;lt;BAR&amp;gt;norm! /&lt;/code&gt; (or, equivalent, &lt;code&gt;|norm! /&lt;/code&gt;) is evaluated as a series of normal mode commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Command &lt;code&gt;|&lt;/code&gt; moves to a column based on count, without a count, it moves to first column. &lt;code&gt;n&lt;/code&gt; repeats the last search. &lt;code&gt;o&lt;/code&gt; inserts a new line below the current line and starts insert mode. As you're now in insert mode, the rest of the mapping, &lt;code&gt;rm! /&lt;/code&gt;, gets inserted as text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Removing the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; would fix that part of the issue, however that'd be equivalent to your second approach, which doesn't work either, let's take a look:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I also tried to put the normal command to as the last line of &lt;code&gt;FooFunction&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:FooFunction() abort&#xA;    ...&#xA;    ...&#xA;    norm! /&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;but then I don't get any prompt after pressing &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's because the &lt;code&gt;norm!&lt;/code&gt; command expects to execute a complete command, it doesn't allow for a prompt to be pending at the end of its execution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help :normal&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;{commands}&lt;/code&gt; should be a complete command.  If &lt;code&gt;{commands}&lt;/code&gt; does not finish a command, the last one will be aborted as if &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-C&amp;gt;&lt;/code&gt; was typed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;:norm! /&lt;/code&gt; doesn't work, the search gets cancelled as the command completes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative you can use in a function is to call &lt;code&gt;feedkeys()&lt;/code&gt;, which doesn't exhibit this behavior. For example, this would have worked:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:FooFunction() abort&#xA;    ...&#xA;    ...&#xA;    call feedkeys('/')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, as you've noticed, an even easier approach is to simply use &lt;code&gt;/&lt;/code&gt; directly in your mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap / :call &amp;lt;SID&amp;gt;FooFunction()&amp;lt;CR&amp;gt;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-19T06:55:35.987" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22607" PostTypeId="1" CreationDate="2020-01-19T17:12:09.380" Score="4" ViewCount="290" Body="&lt;p&gt;What I want to do is have two mappings.  One mapped to &lt;code&gt;&amp;lt;s-k&amp;gt;&lt;/code&gt;, and one mapped to &lt;code&gt;&amp;lt;s-k&amp;gt;&amp;lt;s-k&amp;gt;&lt;/code&gt;.  What happens right now is that if I press &lt;code&gt;&amp;lt;s-k&amp;gt;&lt;/code&gt; &lt;code&gt;vim&lt;/code&gt; delays for &lt;code&gt;timeoutlen&lt;/code&gt;ms, and if I don't press anything it does the &lt;code&gt;&amp;lt;s-k&amp;gt;&lt;/code&gt; action, and if I press another &lt;code&gt;&amp;lt;s-k&amp;gt;&lt;/code&gt; in that time it does the &lt;code&gt;&amp;lt;s-k&amp;gt;&amp;lt;s-k&amp;gt;&lt;/code&gt; action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, what I want it to do is do BOTH, i.e. if I press &lt;code&gt;&amp;lt;s-k&amp;gt;&lt;/code&gt; it will do the &lt;code&gt;&amp;lt;s-k&amp;gt;&lt;/code&gt; action immediately, and if I press another &lt;code&gt;&amp;lt;s-k&amp;gt;&lt;/code&gt; in the &lt;code&gt;timeoutlen&lt;/code&gt; period, it will do the second command as well.&lt;/p&gt;&#xA;" OwnerUserId="19428" LastEditorUserId="19428" LastEditDate="2020-01-19T20:36:09.140" LastActivityDate="2020-01-20T17:26:19.280" Title="Do not delay mapped keys with common prefix" Tags="|vimrc|key-bindings|vimscript|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22608" PostTypeId="1" AcceptedAnswerId="22609" CreationDate="2020-01-19T17:59:21.147" Score="3" ViewCount="199" Body="&lt;p&gt;I have a syntax I'm trying do make. It's &lt;code&gt;yaml&lt;/code&gt; embedded in &lt;code&gt;markdown&lt;/code&gt; for use with &lt;a href=&quot;https://gohugo.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hugo&lt;/a&gt;. The &lt;code&gt;yaml&lt;/code&gt; region is enclosed by &lt;code&gt;---&lt;/code&gt; and this &lt;em&gt;must&lt;/em&gt; be at the top of the file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---&#xA;[yaml front matter stuff]&#xA;.&#xA;.&#xA;.&#xA;---&#xA;# Here starts the markdown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've defined a region that specifies where the &lt;code&gt;yaml&lt;/code&gt; region should start:&#xA;&lt;code&gt;syn region yamlBlock matchgroup=quasiQuote start=/^---/ end=/^---/ contains=@yaml&lt;/code&gt;&#xA;(inspired by &lt;a href=&quot;https://github.com/pbrisbin/vim-syntax-shakespeare/blob/master/after/syntax/haskell.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;this embedded haskell syntax file&lt;/a&gt;) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I want this region to only apply if it is at the very top of the file.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried adding an &lt;code&gt;if&lt;/code&gt; statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if getline(1) =~ '---'&#xA;    syn region yamlBlock matchgroup=quasiQuote start=/^---/ end=/^---/ contains=@yaml&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this will only update when the buffer is reloaded. ie. If I have it open and add a blank line at the top of the file, the code inside &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---&#xA;[....]&#xA;---&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will still be highlighted as &lt;code&gt;yaml&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="18471" LastActivityDate="2020-01-20T03:31:58.900" Title="Syntax region only if at top of file" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22609" PostTypeId="2" ParentId="22608" CreationDate="2020-01-19T18:15:32.757" Score="4" Body="&lt;p&gt;Try tweaking your region start pattern to match the start of the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;start=/\%^---/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://vimhelp.appspot.com/pattern.txt.html#start-of-file&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help start-of-file&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="205" LastEditDate="2020-01-20T03:31:58.900" LastActivityDate="2020-01-20T03:31:58.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22610" PostTypeId="2" ParentId="22599" CreationDate="2020-01-20T06:29:50.497" Score="0" Body="&lt;p&gt;Managed to do this by setting &lt;code&gt;intelephense.completionProvider.maxItems&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt; in &lt;code&gt;coc-settings.json&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="25529" LastActivityDate="2020-01-20T06:29:50.497" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22611" PostTypeId="1" AcceptedAnswerId="22614" CreationDate="2020-01-20T07:54:42.570" Score="1" ViewCount="700" Body="&lt;p&gt;Lets say I have &lt;code&gt;&quot;string&quot;&lt;/code&gt; and I want to dupplicate the double quotes. What is the shortest way to do it?.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have done a search of double quotes using &lt;code&gt;/&quot;&lt;/code&gt;.&#xA;Then I navigate to the different occurences using &lt;code&gt;n&lt;/code&gt; command and I apply this sequence of commands: &lt;code&gt;xPP&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this can be done also using these commands: &lt;code&gt;xPp&lt;/code&gt; or &lt;code&gt;xP.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Excluding macros and function definitions, is there a shorter key combination to achieve that? &lt;/p&gt;&#xA;" OwnerUserId="8939" LastActivityDate="2020-01-20T12:44:00.927" Title="Duplicate single char with the shortest keys combinations" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22612" PostTypeId="1" CreationDate="2020-01-20T10:19:59.887" Score="1" ViewCount="30" Body="&lt;p&gt;I usually do this with &lt;code&gt;&quot;*y&lt;/code&gt; (from visual mode), but on the linux box I'm working with (lubuntu) when I press &lt;code&gt;*&lt;/code&gt; after &lt;code&gt;&quot;&lt;/code&gt; in visual mode, vim doesn't insert &lt;code&gt;*&lt;/code&gt; (it just ignores the whole &lt;code&gt;&quot;*&lt;/code&gt;). If I check &lt;code&gt;*&lt;/code&gt; register with &lt;code&gt;:reg&lt;/code&gt;, I find it empty. There must be some option which interferes. I checked &lt;code&gt;mkvimrc&lt;/code&gt;, but didn't find any map instruction which involved &lt;code&gt;*&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="26580" LastActivityDate="2020-01-20T10:19:59.887" Title="Problem copying form vim to system clipboard" Tags="|vimrc|cut-copy-paste|" AnswerCount="0" CommentCount="3" ClosedDate="2020-01-20T11:00:15.657" ContentLicense="CC BY-SA 4.0" />
  <row Id="22613" PostTypeId="2" ParentId="15431" CreationDate="2020-01-20T10:55:41.423" Score="1" Body="&lt;p&gt;The best solution for me: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Create a function to open a neovim terminal in a small split window and run python &#xA;function! Termpy()&#xA;  exec winheight(0)/4.&quot;split&quot; | terminal python3 %&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then use the solution above to map it to your prefered key combination: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Press CTRL+R to run python script into separate term window &#xA;nnoremap &amp;lt;C-R&amp;gt; :call Termpy() &amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other cool things you can do is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a command like :Pyrun&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command Pyrun execute &quot;:w&amp;lt;CR&amp;gt;:vert ter python3 &quot;%&quot;&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use leader + p to save and run the script&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;p :w&amp;lt;CR&amp;gt;:!python3 %&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;python2 and python3 are different,so change it for your projects or you can create different functions&lt;/p&gt;&#xA;" OwnerUserId="26581" LastActivityDate="2020-01-20T10:55:41.423" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22614" PostTypeId="2" ParentId="22611" CreationDate="2020-01-20T12:02:41.500" Score="6" Body="&lt;p&gt;I would do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/&quot;&lt;/code&gt; to search for the character&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yl&lt;/code&gt; to copy the character&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;p&lt;/code&gt; to paste the character&lt;/li&gt;&#xA;&lt;li&gt;then alternate between &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt; to search and replace&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="22922" LastActivityDate="2020-01-20T12:02:41.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22615" PostTypeId="2" ParentId="22611" CreationDate="2020-01-20T12:44:00.927" Score="5" Body="&lt;p&gt;If you don't mind using the plugin &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;noreferrer&quot;&gt;vim-surround&lt;/a&gt; it can be as short as &lt;code&gt;ysa&quot;&quot;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Put your cursor on the word you want to surround&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ys&lt;/code&gt; is the vim surround command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&quot;&lt;/code&gt; is the text object to operate on, it could also be &lt;code&gt;aW&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;&lt;/code&gt; is the character you want to use to surround the text object&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And as a bonus you can to the reverse operation i.e removing the surrounding quotes with &lt;code&gt;ds&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Without a plugin I would go for &lt;code&gt;:s/&quot;[^&quot;]\+&quot;/&quot;&amp;amp;&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;[^&quot;]\+&quot;&lt;/code&gt; allows you to capture a quote followed by any number of characters other than &lt;code&gt;&quot;&lt;/code&gt; followed by &lt;code&gt;&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;&amp;amp;&quot;&lt;/code&gt; here &lt;code&gt;&amp;amp;&lt;/code&gt; is a reference to the whole matched text which as to be surrounded by two quotes.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1841" LastActivityDate="2020-01-20T12:44:00.927" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22616" PostTypeId="2" ParentId="22607" CreationDate="2020-01-20T14:21:00.673" Score="3" Body="&lt;p&gt;I think something like this would do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:pressed = 0&#xA;&#xA;function KFunc() abort&#xA;  let s:pressed += 1&#xA;  if s:pressed == 1&#xA;    &quot; do one&#xA;  else if s:pressed == 2&#xA;    &quot; do two&#xA;    let s:pressed = 0&#xA;  endif&#xA;endfunction&#xA;&#xA;augroup ResetPressed&#xA;  au!&#xA;  au CursorMoved,CursorMovedI,CursorHold,CursorHoldI * let s:pressed = 0&#xA;augroup END&#xA;&#xA;nnoremap K :call KFunc()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I included the insert mode variants of cursor moved/hold, but you probably don't need them unless it's an insert-mode map.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @Rich points out in the comments, CursorHold and friends fire after &lt;code&gt;'updatetime'&lt;/code&gt;, not &lt;code&gt;'timeoutlen'&lt;/code&gt;. Changing &lt;code&gt;'updatetime'&lt;/code&gt; has implications for swap files, and fixing the code seems tedious. That said, I changed &lt;code&gt;'updatetime'&lt;/code&gt; to 250ms (down from the default 4s) without any adverse effects.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-01-20T16:05:17.413" LastActivityDate="2020-01-20T16:05:17.413" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22617" PostTypeId="2" ParentId="22607" CreationDate="2020-01-20T15:40:56.033" Score="4" Body="&lt;p&gt;It's not possible to achieve this with regular mappings of &lt;code&gt;K&lt;/code&gt; and &lt;code&gt;KK&lt;/code&gt;. If the &lt;code&gt;K&lt;/code&gt; mapping fires then Vim is necessarily no longer waiting to see if &lt;code&gt;KK&lt;/code&gt; is typed, and there are no configuration options that can change this behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are ways to workaround this, however. filbranden suggested one possible method &lt;a href=&quot;https://vi.stackexchange.com/questions/22607/do-not-delay-mapped-keys-with-common-prefix#comment40919_22607&quot;&gt;in the comments&lt;/a&gt; which &lt;a href=&quot;https://vi.stackexchange.com/a/22616/343&quot;&gt;D. Ben Knoble has implemented&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than rely on autocommands to reset the state, I'd probably check the time since we last fired the mapping directly in the mapping itself by using &lt;a href=&quot;http://vimhelp.org/eval.txt.html#reltime%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;reltime()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function KFunc() abort&#xA;  if !exists(&quot;s:last_press&quot;) || reltimefloat(reltime(s:last_press)) &amp;gt; &amp;amp;timeoutlen / 1000.0&#xA;    &quot; do one&#xA;&#xA;    &quot; remember when we fired the mapping&#xA;    let s:last_press = reltime()&#xA;&#xA;  else&#xA;    &quot; do two&#xA;&#xA;    &quot; reset the time&#xA;    unlet s:last_press&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap K :call KFunc()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-20T17:26:19.280" LastActivityDate="2020-01-20T17:26:19.280" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22618" PostTypeId="1" CreationDate="2020-01-20T20:46:21.540" Score="5" ViewCount="284" Body="&lt;p&gt;I want to make a script with FZF (Fuzzy Finder) and I want to show only those file which can be opened with Vim. So, I don't want to list mp4, jpg, pdf etc files in FZF.&lt;/p&gt;&#xA;&lt;p&gt;So, is there any way to decide whether a file can be opened in Vim or not?&lt;/p&gt;&#xA;" OwnerUserId="26582" LastEditorUserId="23502" LastEditDate="2023-10-02T08:16:15.540" LastActivityDate="2024-02-29T10:06:40.743" Title="How can I decide whether a file can be opened in Vim or not?" Tags="|vimrc|vimscript|fzf|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22619" PostTypeId="2" ParentId="22618" CreationDate="2020-01-21T00:36:21.103" Score="0" Body="&lt;h3&gt;Customize fzf search command&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can pass a &lt;code&gt;dict&lt;/code&gt; with custom &lt;code&gt;source&lt;/code&gt; to &lt;code&gt;fzf&lt;/code&gt; functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-p&amp;gt; :call fzf#vim#files('', {'source': g:fzf_project_source})&amp;lt;cr&amp;gt;&#xA;&#xA;let g:fzf_project_source = 'find . \( -name &quot;.hg&quot; -o -name &quot;.git&quot; -o -name &quot;build&quot;&#xA;            \ -o -name &quot;.vscode&quot; -o -name &quot;.clangd&quot; \) -prune -o -type f -print'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Customize fzf action&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;It's actually not bad to list media files, you can open it with specific program like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:fzf_action = {&#xA;      \ 'ctrl-o': '!gio open',&#xA;      \ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gio open&lt;/code&gt; works for me under &lt;code&gt;ubuntu18.04&lt;/code&gt;, you might need to change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is one edge case you need to know:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If current buffer is an empty new buffer, &lt;code&gt;fzf&lt;/code&gt; always open choosen file in &lt;code&gt;vim&lt;/code&gt; with &lt;code&gt;e&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Not sure if it's a bug.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-01-21T01:22:15.150" LastActivityDate="2020-01-21T01:22:15.150" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22620" PostTypeId="2" ParentId="84" CreationDate="2020-01-21T09:36:54.497" Score="5" Body="&lt;p&gt;I was struggling with the system clipboard and &lt;code&gt;vim&lt;/code&gt; inside &lt;code&gt;tmux&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It was solved by using &lt;code&gt;xsel&lt;/code&gt; or &lt;code&gt;xclip&lt;/code&gt;, like in this example:&lt;/p&gt;&#xA;&lt;p&gt;1.) visually select a block text in normal mode: &lt;code&gt;V&amp;lt;motionkey&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;2.a) with &lt;code&gt;xsel&lt;/code&gt; run ex: &lt;code&gt;:'&amp;lt;,'&amp;gt;w !xsel -b&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;2.b) with &lt;code&gt;xclip&lt;/code&gt; run ex: &lt;code&gt;:'&amp;lt;,'&amp;gt;w !xclip -selection clipboard&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;2.c) &lt;code&gt;:.w !xsel -b&lt;/code&gt; to copy arbitrary selection or the current line (see &amp;quot;additional tip&amp;quot; below)&lt;/p&gt;&#xA;&lt;p&gt;3.) paste into another program&lt;/p&gt;&#xA;&lt;p&gt;... and now assign this to your favorite key-mapping.&lt;/p&gt;&#xA;&lt;p&gt;The options &lt;code&gt;-b&lt;/code&gt; or &lt;code&gt;-selection clipboard&lt;/code&gt; basically mean, that the program (xsel or xclip) is sent to the background and wait for another program to paste the content, so that it can &amp;quot;interfere&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;(tested on manjaro with i3, xfce4-terminal, tmux)&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;additional tip:&#xA;to copy the current line (where the cursor is located) very fast I map this command &lt;code&gt;:.w !xsel -b&lt;/code&gt; to a key of choice - so copy works with and without a visual selection&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="2239" LastEditorUserId="2239" LastEditDate="2021-09-28T08:49:07.110" LastActivityDate="2021-09-28T08:49:07.110" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22621" PostTypeId="2" ParentId="22149" CreationDate="2020-01-21T11:39:50.250" Score="3" Body="&lt;h2&gt;Why the colorscheme is loaded twice&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is slightly speculative, since your excellent and detailed question nevertheless still doesn't contain quite enough information about your setup to be certain, but I believe what is happening is this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When Vim starts up, one of the first things it does is load your &lt;code&gt;$VIM/vimrc&lt;/code&gt; file, which loads your colorscheme, thus setting &lt;code&gt;g:colors_name&lt;/code&gt;. &lt;strong&gt;However, note that &lt;code&gt;$VIM/vimrc&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; considered a user vimrc file, but is instead a &lt;em&gt;system&lt;/em&gt; vimrc&lt;/strong&gt;. (See &lt;a href=&quot;https://vimhelp.org/starting.txt.html#system-vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help system-vimrc&lt;/code&gt;&lt;/a&gt; and check the output of &lt;code&gt;:version&lt;/code&gt; to confirm that Vim is using this location for its system vimrc.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Presuming you don't have another &lt;code&gt;vimrc&lt;/code&gt; in any of the locations described in &lt;a href=&quot;https://vimhelp.org/starting.txt.html#_vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help _vimrc&lt;/code&gt;&lt;/a&gt; point &lt;strong&gt;3.c.II&lt;/strong&gt;, then Vim will then load the &lt;code&gt;defaults.vim&lt;/code&gt; file, as described in point &lt;strong&gt;3.c.V&lt;/strong&gt;, because no &lt;em&gt;user&lt;/em&gt; vimrc has been found.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;defaults.vim&lt;/code&gt; executes the command &lt;code&gt;:syntax on&lt;/code&gt;, &lt;a href=&quot;https://vimhelp.org/syntax.txt.html#syntax-loading&quot; rel=&quot;nofollow noreferrer&quot;&gt;which sources the file&lt;/a&gt; &lt;code&gt;$VIMRUNTIME/syntax/syntax.vim&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;syntax.vim&lt;/code&gt; executes the command &lt;a href=&quot;https://github.com/vim/vim/blob/f0764e8bb6511aa3bf1d6f52852b4284676ee661/runtime/syntax/syntax.vim#L19&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:runtime syntax/synload.vim&lt;/code&gt;&lt;/a&gt;, which &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#:runtime&quot; rel=&quot;nofollow noreferrer&quot;&gt;will find and source&lt;/a&gt; the file &lt;code&gt;$VIMRUNTIME/syntax/synload.vim&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;synload.vim&lt;/code&gt; contains &lt;a href=&quot;https://github.com/vim/vim/blob/f0764e8bb6511aa3bf1d6f52852b4284676ee661/runtime/syntax/synload.vim#L17&quot; rel=&quot;nofollow noreferrer&quot;&gt;the following code&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set the default highlighting colors.  Use a color scheme if specified.&#xA;if exists(&quot;colors_name&quot;)&#xA;  exe &quot;colors &quot; . colors_name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;colors_name&lt;/code&gt; was set in Step 1, so execution enters the &lt;code&gt;if&lt;/code&gt; block, the &lt;code&gt;:colorscheme&lt;/code&gt; command is run, and your colorscheme is reloaded.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you view the output of the command &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#:scriptnames&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:scriptnames&lt;/code&gt;&lt;/a&gt;, you should be able to trace (roughly) the execution of Vim's startup procedure through these files.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How to fix your problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are several ways you could prevent the double-load, but there's a simpler and more robust method of solving your actual issue, which is that you want to ensure your cursor color is set correctly. You can do this by setting up &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#ColorScheme&quot; rel=&quot;nofollow noreferrer&quot;&gt;an autocommand that fires whenever the colorscheme is set&lt;/a&gt; e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup SetCursorColor&#xA;  autocmd!&#xA;  autocmd ColorScheme * highlight Cursor guibg=red guifg=NONE&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#autocmd-patterns&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;pattern&lt;/code&gt;&lt;/a&gt; is matched against the colorscheme name, so if you only want to use this cursor colour in gruvbox, you can specify this like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd ColorScheme gruvbox highlight Cursor guibg=red guifg=NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-21T16:32:24.500" LastActivityDate="2020-01-21T16:32:24.500" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="22622" PostTypeId="2" ParentId="9951" CreationDate="2020-01-21T13:22:48.990" Score="3" Body="&lt;p&gt;As of Vim 8.2.0139, there are no configuration options to specify this behaviour. Furthermore, any changes to the behaviour of Vim's soft wrapping via &lt;code&gt;'wrap'&lt;/code&gt; will require implementing in the source code: there is no workaround possible by using Vimscript.*&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;https://github.com/vim/vim/issues/1661&quot; rel=&quot;nofollow noreferrer&quot;&gt;feature request that Ryan Lue (who asked this question) added to the Vim project's issue tracker&lt;/a&gt; after brief discussion in the comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As of January 21st 2020, this issue remains open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* Except, I guess, an &lt;em&gt;extremely&lt;/em&gt; hacky and difficult-to-implement-properly one which worked by actually using hard-wrapping and converting to soft-wrapping on save.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-01-21T13:22:48.990" CommentCount="0" CommunityOwnedDate="2020-01-31T09:50:21.713" ContentLicense="CC BY-SA 4.0" />
  <row Id="22623" PostTypeId="2" ParentId="11002" CreationDate="2020-01-21T13:52:01.577" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/11002/vim-zz-lost-output-with-autocommand#comment38716_11002&quot;&gt;Thunderbeef explained in the comments&lt;/a&gt; that this is caused by the difference in the way normal and command-line commands show output. With a command-line command, you see the whole output, but with a normal command, you only see the last line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can work around this limitation by displaying all the desired output from your call to &lt;code&gt;input()&lt;/code&gt;, which &lt;a href=&quot;https://vimhelp.org/eval.txt.html#input%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;allows you to include newlines in its prompt&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function CheckBeforeQuit()&#xA;  call input(&quot;Hello\nWorld\nPress enter&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your &lt;code&gt;Hello&lt;/code&gt; and &lt;code&gt;World&lt;/code&gt; strings are not hard-coded, but are actually generated within the function, you can instead build a string to pass to &lt;code&gt;input()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function CheckBeforeQuit()&#xA;  let quit_notification = 'Hello'&#xA;  let quit_notification .= &quot;\n&quot; . 'World'&#xA;  let quit_notification .= &quot;\n&quot; . 'Press enter'&#xA;&#xA;  call input(quit_notification)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your &lt;code&gt;Hello&lt;/code&gt; and &lt;code&gt;World&lt;/code&gt; aren't actually strings at all, but instead result from the output of other commands, then you can capture these in your message by using the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#execute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;execute() function&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function CheckBeforeQuit()&#xA;  let quit_notification = execute('echo &quot;Hello&quot;')&#xA;  let quit_notification .= execute('echo &quot;World&quot;')&#xA;  let quit_notification .= &quot;\n&quot; . 'Press enter'&#xA;&#xA;  call input(quit_notification)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-21T13:57:40.733" LastActivityDate="2020-01-21T13:57:40.733" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22624" PostTypeId="1" CreationDate="2020-01-21T16:07:05.853" Score="0" ViewCount="36" Body="&lt;p&gt;I'm using this plugin: &lt;a href=&quot;https://github.com/ggVGc/vim-fuzzysearch/blob/master/plugin/fuzzysearch.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-fuzzysearch&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I have long file (I need to press &lt;code&gt;ctrl-f/ctrl-b&lt;/code&gt; to scroll)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps to produces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. Turn on `hlsearch` + vim-fuzzysearch and search for a keyword&#xA;2. Immediately press `ctrl-f` to scroll down&#xA;3. Observe highlight lost of matched patterns on the file (like nohlsearch is set)&#xA;4. Press `n` and re-try `ctrl-f/ctrl-b`, now hlsearch on matched patterns recovered.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I don't use vim-fuzzyearch then there's no issue, I observe no highlight lost of matched patterns.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastActivityDate="2020-01-21T16:07:05.853" Title="Lose hlsearch when using with vim-fuzzysearch" Tags="|vimscript|highlight|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22625" PostTypeId="2" ParentId="14145" CreationDate="2020-01-21T23:55:27.383" Score="3" Body="&lt;p&gt;Update: neovim now (January 2020) supports perl as well as &lt;code&gt;has('perl')&lt;/code&gt;. I update neovim very often to the latest development version, and I only noticed the feature today when running &lt;code&gt;checkhealth&lt;/code&gt;. If you are using a stable version of neovim, you probably will not see support for perl yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aa5Kh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aa5Kh.jpg&quot; alt=&quot;Output of &amp;lt;code&amp;gt;checkhealth&amp;lt;/code&amp;gt; showing perl support&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7933" LastActivityDate="2020-01-21T23:55:27.383" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22626" PostTypeId="1" CreationDate="2020-01-22T14:06:13.653" Score="1" ViewCount="312" Body="&lt;p&gt;I'm running a long, blocking command using &lt;code&gt;execute&lt;/code&gt; in Vim as part of a script. Vim shows the underlying terminal while executing the command, which is pretty distracting.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! DoSomething(query)&#xA;  execute &quot;silent grep! &quot; . a:query&#xA;endfuntcion&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use the output in a latter part of the script, so running it asynchronously using &lt;code&gt;&amp;amp;&lt;/code&gt; is out of the question. Is there any way to make Vim hang while executing the command without going back to the terminal?&lt;/p&gt;&#xA;" OwnerUserId="2526" LastEditorUserId="2526" LastEditDate="2020-01-22T14:14:08.963" LastActivityDate="2020-01-22T14:14:08.963" Title="How do I prevent Vim from showing my terminal when executing an external command?" Tags="|terminal|external-command|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22627" PostTypeId="1" AcceptedAnswerId="22628" CreationDate="2020-01-22T14:11:22.130" Score="12" ViewCount="1709" Body="&lt;p&gt;When wanting to edit another file, I'm a big fan of typing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then tab (or a few characters before) to see the wildmenu pop up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem is that the way it works, arrows keys up and down go 'down' or 'up' in the hierarchy and left and right lets you navigate through file within the same hierarchy level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is very unintuitive for me as I would like the up and down arrows to select file and the side arrows to change hierarchical level. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know how to remap keys in general, but I never had to remap keys specifically for one command and I'm unsure how to do it the proper way.&lt;/p&gt;&#xA;" OwnerUserId="26611" LastActivityDate="2021-10-06T19:10:10.480" Title="Switching arrow key mappings for wildmenu tab completion" Tags="|key-bindings|command-line|wildmenu|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22628" PostTypeId="2" ParentId="22627" CreationDate="2020-01-22T15:02:45.063" Score="14" Body="&lt;p&gt;You can do this by mapping the keys to behave differently when the wildmenu is visible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildcharm=&amp;lt;C-Z&amp;gt;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;up&amp;gt; wildmenumode() ? &quot;\&amp;lt;left&amp;gt;&quot; : &quot;\&amp;lt;up&amp;gt;&quot;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;down&amp;gt; wildmenumode() ? &quot;\&amp;lt;right&amp;gt;&quot; : &quot;\&amp;lt;down&amp;gt;&quot;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;left&amp;gt; wildmenumode() ? &quot;\&amp;lt;up&amp;gt;&quot; : &quot;\&amp;lt;left&amp;gt;&quot;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;right&amp;gt; wildmenumode() ? &quot; \&amp;lt;bs&amp;gt;\&amp;lt;C-Z&amp;gt;&quot; : &quot;\&amp;lt;right&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These use an &lt;a href=&quot;https://vimhelp.org/map.txt.html#:map-expression&quot; rel=&quot;noreferrer&quot;&gt;expression mapping&lt;/a&gt; that checks whether the wildmenu is showing with the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#wildmenumode%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;wildmenumode()&lt;/code&gt;&lt;/a&gt; function returning the altered keystroke if that it is, and returning the regular keystroke if it isn't (so that the keys still work normally when you're not using the wildmenu).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a slight complication in the mapping for the right arrow key, which is that it appears that the &quot;go into subdirectory&quot; behaviour is implemented internally as a macro that does something along the lines of &lt;code&gt;&amp;lt;space&amp;gt;&amp;lt;bs&amp;gt;&amp;lt;tab&amp;gt;&lt;/code&gt;, but because &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27wildchar%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'wildchar'&lt;/code&gt;&lt;/a&gt; cannot be used in a macro, the &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; is instead inserted literally in the command line, appearing as CTRL-I: &lt;code&gt;^I&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've worked around this by using &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27wildcharm%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'wildcharm'&lt;/code&gt;&lt;/a&gt; and mapping to that instead of directly to &lt;code&gt;&amp;lt;down&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make the mappings more precise, you can also check the current contents of the command-line to make sure it's an &lt;code&gt;:e&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildcharm=&amp;lt;C-Z&amp;gt;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;up&amp;gt; getcmdline()[:1] is 'e ' &amp;amp;&amp;amp; wildmenumode() ? &quot;\&amp;lt;left&amp;gt;&quot; : &quot;\&amp;lt;up&amp;gt;&quot;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;down&amp;gt; getcmdline()[:1] is 'e ' &amp;amp;&amp;amp; wildmenumode() ? &quot;\&amp;lt;right&amp;gt;&quot; : &quot;\&amp;lt;down&amp;gt;&quot;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;left&amp;gt; getcmdline()[:1] is 'e ' &amp;amp;&amp;amp; wildmenumode() ? &quot;\&amp;lt;up&amp;gt;&quot; : &quot;\&amp;lt;left&amp;gt;&quot;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;right&amp;gt; getcmdline()[:1] is 'e ' &amp;amp;&amp;amp; wildmenumode() ? &quot; \&amp;lt;bs&amp;gt;\&amp;lt;C-Z&amp;gt;&quot; : &quot;\&amp;lt;right&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you also need the mappings to work for the other variants of the &lt;code&gt;:e&lt;/code&gt; command: &lt;code&gt;:ed&lt;/code&gt;, &lt;code&gt;:edi&lt;/code&gt;, and &lt;code&gt;:edit&lt;/code&gt;, you can instead use a regular expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildcharm=&amp;lt;C-Z&amp;gt;&#xA;let edit_re = 'e\%[dit] '&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;up&amp;gt; getcmdline() =~# edit_re &amp;amp;&amp;amp; wildmenumode() ? &quot;\&amp;lt;left&amp;gt;&quot; : &quot;\&amp;lt;up&amp;gt;&quot;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;down&amp;gt; getcmdline() =~# edit_re &amp;amp;&amp;amp; wildmenumode() ? &quot;\&amp;lt;right&amp;gt;&quot; : &quot;\&amp;lt;down&amp;gt;&quot;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;left&amp;gt; getcmdline() =~# edit_re &amp;amp;&amp;amp; wildmenumode() ? &quot;\&amp;lt;up&amp;gt;&quot; : &quot;\&amp;lt;left&amp;gt;&quot;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;right&amp;gt; getcmdline() =~# edit_re &amp;amp;&amp;amp; wildmenumode() ? &quot; \&amp;lt;bs&amp;gt;\&amp;lt;C-Z&amp;gt;&quot; : &quot;\&amp;lt;right&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I couldn't find any way of checking whether the &lt;code&gt;wildmenu&lt;/code&gt; is completing filenames (&lt;a href=&quot;https://vimhelp.org/eval.txt.html#complete_info%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;complete_info()&lt;/code&gt;&lt;/a&gt; only appears to work for insert mode completion, and I couldn't find a similar function for command-line completion), so there doesn't appear to be a better method of applying it to &lt;em&gt;all&lt;/em&gt; filename wildmenu completions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need this, you will have either use the original version which applies regardless of what the wildmenu is completing, or use a more complicated regular expression to check for all the commands where you need the mappings to be in effect.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-22T16:21:19.720" LastActivityDate="2020-01-22T16:21:19.720" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="22629" PostTypeId="1" CreationDate="2020-01-22T15:24:57.347" Score="1" ViewCount="49" Body="&lt;p&gt;Not even sure I can describe this well, but I work in markdown with one line per paragraph, due to some issues that are outside of my control, and i would like the screen to scroll down following the &lt;em&gt;visual&lt;/em&gt; lines rather than the &lt;em&gt;actual&lt;/em&gt; lines. In markdown I have remapped &lt;kbd&gt;j&lt;/kbd&gt; and &lt;kbd&gt;k&lt;/kbd&gt; to &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; and &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt;, but when I get to the end of the screen the whole document jumps several lines down, breaking the flow of reading. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would basically like to be able to emulate normal scroll behavior with its &lt;kbd&gt;g&lt;/kbd&gt;-cousins and I don't even know where to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;System: ArchLinux, neovim, termite&lt;/p&gt;&#xA;" OwnerUserId="26614" LastEditorUserId="1238" LastEditDate="2020-01-27T05:16:52.693" LastActivityDate="2020-01-27T05:16:52.693" Title="How to visually scroll one line at the time with long lines?" Tags="|neovim|" AnswerCount="0" CommentCount="4" ClosedDate="2020-01-22T19:18:49.440" ContentLicense="CC BY-SA 4.0" />
  <row Id="22630" PostTypeId="1" AcceptedAnswerId="22632" CreationDate="2020-01-22T20:46:38.473" Score="1" ViewCount="461" Body="&lt;p&gt;I have a CSV file in which data in a row are present in following way: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ID, Name, State, Score, Rank&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the &lt;code&gt;Name&lt;/code&gt; Column, data are in &lt;code&gt;&quot;some Name&quot;&lt;/code&gt; form. But there are many entries in which a comma is present in the name like: &lt;code&gt;&quot;some name, Again&quot;&lt;/code&gt; which makes that row inconsistent with other rows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have many CSV files in this format. So, how can I delete the comma character that are present in between two &quot; from every line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample Data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ABC, &quot;Ujjwal Gupta&quot;, XYZ, 35, 1&#xA;DEF, &quot;Abhishek Kumar, Gupta&quot;, RST, 23, 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see 2nd line can create inconsistencies.&lt;/p&gt;&#xA;" OwnerUserId="26582" LastEditorUserId="10604" LastEditDate="2020-01-26T17:49:24.133" LastActivityDate="2020-01-26T17:49:24.133" Title="How to delete a character that is present between two specific characters from every line in VIM?" Tags="|vimrc|original-vim|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22631" PostTypeId="2" ParentId="22630" CreationDate="2020-01-22T20:56:52.343" Score="0" Body="&lt;p&gt;The vim pattern &lt;code&gt;&quot;[^&quot;]*\zs,\ze[^&quot;]*&quot;&lt;/code&gt; should match only the comma. However, if you have data like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;abc&quot;,&quot;ab,c&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it will match both commas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pattern matches&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a quote (&lt;code&gt;&quot;&lt;/code&gt;), followed by&lt;/li&gt;&#xA;&lt;li&gt;a bunch of &quot;not-quotes&quot; (&lt;code&gt;[^&quot;]*&lt;/code&gt;), followed by&lt;/li&gt;&#xA;&lt;li&gt;a comma (&lt;code&gt;,&lt;/code&gt;), but we &lt;em&gt;only&lt;/em&gt; keep the comma as the match (&lt;code&gt;\zs,\ze&lt;/code&gt;), followed by&lt;/li&gt;&#xA;&lt;li&gt;more &quot;not-quotes&quot; (&lt;code&gt;[^&quot;]*&lt;/code&gt;), followed by&lt;/li&gt;&#xA;&lt;li&gt;a quote (&lt;code&gt;&quot;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;We need the &quot;not-quotes&quot; to avoid something like &lt;code&gt;&quot;.*&quot;&lt;/code&gt;, which matches all of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;abc&quot;def&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;because &lt;code&gt;.&lt;/code&gt; matches the &lt;code&gt;&quot;&lt;/code&gt; in the middle, too. We could accomplish the same with non-greedy patterns (&lt;code&gt;&quot;.\{-}\zs,\ze.\{-}&quot;&lt;/code&gt;), but I find those harder to read.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Assuming that the pattern works for you (test it with &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;n&lt;/code&gt;—preferably with &lt;code&gt;hlsearch&lt;/code&gt; set, to make sure it only matches the commas you want), you can carry out the change with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%substitute//;/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The short form is &lt;code&gt;:%s//;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I am intentionally omitting the &lt;code&gt;g&lt;/code&gt; global flag here.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-01-22T22:03:09.433" LastActivityDate="2020-01-22T22:03:09.433" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22632" PostTypeId="2" ParentId="22630" CreationDate="2020-01-23T05:50:40.913" Score="3" Body="&lt;p&gt;This situation is frustrating.  Technically speaking, the CSV file you describe is within MicroSoft's CSV spec - the double-quotes escape the comma, so it's not considered a separator.  However, there's a lot of programs out there that don't honor any method of saying the comma isn't a value separator, or don't honor that one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only have a single double-quoted term, it's easier to deal with, because you can just deal with any separator between those quotes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\(&quot;[^&quot;,]*\),\(.*&quot;\)/\1\2/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This just looks for a double quote, followed by anything that's not a comma or a double quote, which it puts into group 1, and then a comma, followed by whatever ending with a double quote, which goes in group 2.  The comma wasn't included in either group, so we just replace with the groups and the comma is gone.  I'm not using the g modifier there because that case was defined to be only one double-quoted term, and since it's matching both of the double-quotes around that term, it's not going to work more than once per line.  If you can have multiple double-quoted sections, it can be much harder.  Unfortunately, to make sure we're not thwacking commas that really are separators, we're going to have to start each match at the beginning of the line, and this will only work for CSVs which do not have quoted line endings (another thing that's allowed and annoying in MicroSoft's spec.  At least, annoying from the perspective of someone trying to parse it with simple tools.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^\(\([^,&quot;]*,\|&quot;[^,&quot;]*&quot;,\)*&quot;[^,&quot;]*\),\([^&quot;]*&quot;\)/\1\3/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Like the first one, we simply put everything we want, up to the close double quote after our unwanted character, into two groups, and concatenate them, without including what we don't want.  But this time, the first group is preceded with an anchored expression that matches any number of elements that either aren't enclosed in double quotes or are enclosed in double quotes but don't contain any commas, so we're &quot;fixing&quot; the first value with the issue, most specifically the first comma from that value.  The 'any number of values without the pattern' is handled using another group block, so instead of replacing with &lt;code&gt;\1\2&lt;/code&gt;, we replace with &lt;code&gt;\1\3&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to talk about that portion specifically, namely &lt;code&gt;\([^,&quot;]*,\|&quot;[^,&quot;]*&quot;,\)*&lt;/code&gt;, this includes an &lt;code&gt;\|&lt;/code&gt; in the middle, which says that it matches if it's either the &lt;code&gt;[^,&quot;]*,&lt;/code&gt; on the left or the &lt;code&gt;&quot;[^,&quot;]*&quot;,&lt;/code&gt; on the right.  The &lt;code&gt;*&lt;/code&gt; after the end of the group repeats the whole grouping regex as many times as is necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This isn't a particularly fast regular expression, and it needs to be re-run as many times as the maximum number of double-quoted commas on one line.  But it works within the context of the environment you're asking for it to.  It would probably be a better answer to tell whatever program is having the problem with these CSVs how to properly handle quotes, or to turn the other commas into some character that's not already in the file, such as possibly a tab, so that the file could be parsed using that other character as a separator instead, because that's something that would be easier to do with a single pass.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I feel it's probably important to note that by making the change you're looking for to name fields, you're changing the semantic meaning of those names.  Based on your username, I would guess you understand this particular thing, but this answer is also for anyone else who's looking into handling this situations, so I felt important to say that it's usually a better approach to replace the separator with a different separator, such as &lt;code&gt;;&lt;/code&gt;, which isn't otherwise used within the data, but could be converted back to a comma when you're only dealing with that one value later on.&lt;/p&gt;&#xA;" OwnerUserId="20713" LastActivityDate="2020-01-23T05:50:40.913" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22634" PostTypeId="1" CreationDate="2020-01-23T13:56:12.403" Score="1" ViewCount="36" Body="&lt;p&gt;Can the insert-completion of file names &lt;kbd&gt;CTRL+X&lt;/kbd&gt;&lt;kbd&gt;CTRL+F&lt;/kbd&gt; can be used to complete filenames that are not in the current working directory ? But rather in any in the &lt;code&gt;path&lt;/code&gt; variable ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can we, for example, override (with pain I guess) the &lt;kbd&gt;CTRL+X&lt;/kbd&gt;&lt;kbd&gt;CTRL+F&lt;/kbd&gt; mapping to take &lt;code&gt;path&lt;/code&gt; (or only the path of the current buffer) into account ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;code&gt;:h compl-filename&lt;/code&gt; says&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: the 'path' option is not used here (yet).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Are there any effort in making the &quot;(yet)&quot; part obsolete ? How hard would it be to implement it ?&lt;/p&gt;&#xA;" OwnerUserId="22929" LastActivityDate="2020-01-23T13:56:12.403" Title="Ins-completion C-X C-F and the path variable" Tags="|insert-mode|path|ins-completion|" AnswerCount="0" CommentCount="1" ClosedDate="2020-01-29T06:25:55.143" ContentLicense="CC BY-SA 4.0" />
  <row Id="22635" PostTypeId="1" AcceptedAnswerId="22636" CreationDate="2020-01-23T17:00:31.870" Score="3" ViewCount="1831" Body="&lt;p&gt;I am currently attempting to create a custom colorscheme for vim by using &lt;code&gt;ctermfg&lt;/code&gt; and &lt;code&gt;ctermbg&lt;/code&gt; values, and checking what the colorscheme looks like with the highlight test file provided by Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I do not understand is why &lt;code&gt;ctermfg&lt;/code&gt; and &lt;code&gt;ctermbg&lt;/code&gt; appear backwards, and also incorrect, for certain highlighting groups. &lt;code&gt;StatusLine&lt;/code&gt;, for instance, is set to have a black foreground and a white background, but instead has a white foreground and a gray background. Is there something special about specific highlighting groups that I should keep in mind when I set their colors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gYa55.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gYa55.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26632" LastActivityDate="2020-01-23T17:33:27.893" Title="ctermbg and ctermfg are backwards or incorrect for certain highlighting groups" Tags="|terminal|colorscheme|statusline|color|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22636" PostTypeId="2" ParentId="22635" CreationDate="2020-01-23T17:33:27.893" Score="6" Body="&lt;p&gt;You're probably overlooking the additional attributes set in the &lt;code&gt;cterm=&lt;/code&gt; field for those highlights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, after I set &lt;code&gt;ctermfg=black ctermbg=white&lt;/code&gt; for &lt;code&gt;StatusLine&lt;/code&gt;, I get this when I query it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi StatusLine&#xA;StatusLine     xxx term=bold,reverse cterm=bold,reverse&#xA;                   ctermfg=0 ctermbg=15 gui=bold,reverse&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll see the &lt;code&gt;cterm=bold,reverse&lt;/code&gt; there, which is part of the defaults for &lt;code&gt;StatusLine&lt;/code&gt;. In particular, &lt;code&gt;reverse&lt;/code&gt; will swap fg &amp;amp; bg colors, which is the effect you're seeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since those attributes are set in a separate field (&lt;code&gt;cterm=&lt;/code&gt;), which you're not overriding, the defaults are being preserved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To undo the effects of this field, you could set it explicitly, with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi StatusLine cterm=bold&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, to also drop the &lt;code&gt;bold&lt;/code&gt; attribute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi StatusLine cterm=reverse&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could just decide to embrace the default of using reverse colors on the &lt;code&gt;StatusLine&lt;/code&gt; and perhaps some other highlight groups and just set your fg &amp;amp; bg colors in reverse, to then have the reversing applied by &lt;code&gt;cterm=&lt;/code&gt; get the colors as you actually want them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also consider the &lt;code&gt;term=&lt;/code&gt; (for B&amp;amp;W terminals) and &lt;code&gt;gui=&lt;/code&gt; (for gvim) attributes, if you're considering setting custom highlighting that you'd like to work on those environments as well.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-23T17:33:27.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22637" PostTypeId="1" AcceptedAnswerId="22638" CreationDate="2020-01-24T01:17:05.373" Score="3" ViewCount="5423" Body="&lt;p&gt;My &lt;code&gt;init.vim&lt;/code&gt; is just&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType * echom &quot;test&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I open a file, neovim-qt will not echo &lt;code&gt;test&lt;/code&gt;. If I load a new file while the window is open, it will also not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have managed to find one case where it will fire. If I run &lt;code&gt;mks&lt;/code&gt;, open &lt;code&gt;Session.vim&lt;/code&gt; and then source it (&lt;code&gt;so%&lt;/code&gt;), it will run this for every file that gets opened from that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea what's going on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: running &lt;code&gt;set filetype...&lt;/code&gt; will cause it to trigger.&lt;/p&gt;&#xA;" OwnerUserId="24943" LastEditorUserId="24943" LastEditDate="2020-01-24T02:01:05.580" LastActivityDate="2022-06-18T00:56:22.653" Title="FileType autocommand not working in Neovim" Tags="|neovim|autocmd|neovim-qt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22638" PostTypeId="2" ParentId="22637" CreationDate="2020-01-24T01:45:07.623" Score="3" Body="&lt;p&gt;&lt;em&gt;It was a long, winding road to reach the root cause. Jump to &amp;quot;Final Update&amp;quot; below if you're only interested in the destination, not the journey.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Per &lt;a href=&quot;https://neovim.io/doc/user/autocmd.html#FileType&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h FileType&lt;/code&gt;&lt;/a&gt; the &lt;code&gt;FileType&lt;/code&gt; event doesn't do anything unless &lt;code&gt;'filetype'&lt;/code&gt; is set. The standard way to set that is to have this in your vimrc/init.vim:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:filetype on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This &amp;quot;enables file type detection&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;You don't have anything in your init.vim so that's surely why this stuff isn't working &amp;quot;out of the box&amp;quot;. Your &lt;code&gt;Session.vim&lt;/code&gt; file, which contains a bunch of config, likely was created when filtype &lt;em&gt;was&lt;/em&gt; enabled. That's why things work after you source it.&lt;/p&gt;&#xA;&lt;p&gt;BTW, you should be doing autocommands like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup myautocmds&#xA;  autocmd!&#xA;  au FileType * echom &amp;quot;test&amp;quot;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This allows you to safely re-source the file containing your autocommand(s).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Okay, current state of affairs is that everything is working with above, generally speaking, but &lt;code&gt;echom&lt;/code&gt; doesn't not produce any visible output. I use &lt;code&gt;echom&lt;/code&gt; in autocommands in Vim but I'm wondering if &lt;code&gt;filetype&lt;/code&gt; event specifically poses a problem. Other actions, e.g. setting a variable, work fine. Investigating further...&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; After it's all said and done it looks like it boils down to this: &lt;code&gt;echom&lt;/code&gt; with &lt;code&gt;FileType&lt;/code&gt; autocommands is not reliable. Works with other event types. Works with Vim. Not with Neovim and file type. If OP happened to use a different command (e.g. set a variable and checked the value) they might not have ended up here at all.&lt;/p&gt;&#xA;&lt;p&gt;(Opening a bug with Neovim might be prudent.)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update 3:&lt;/strong&gt; Just to formalize the conclusions I automated some tests so I could be sure that there is a discrepancy between Neovim's behavior and Vim's...as opposed to some human error leaking in. Tests were parameterized over several permutations of auto-command event types, auto-command patterns and minor variations of the actual commands run.  Specifically, I tried both direct and indirect calls to &lt;code&gt;echom&lt;/code&gt;. (Indirect: &lt;code&gt;echom&lt;/code&gt; put in a function and the autocommand calls the function.) For the indirect cases I also wrapped the &lt;code&gt;echom&lt;/code&gt; calls in &lt;code&gt;redir&lt;/code&gt; so, in theory anyways, the messages would appear in both &lt;code&gt;mess&lt;/code&gt; command output and in a temporary file.&lt;/p&gt;&#xA;&lt;p&gt;Results didn't turn up any surprises...&lt;/p&gt;&#xA;&lt;p&gt;Vim (and gvim) consistently showed &lt;code&gt;echom&lt;/code&gt; messages in real-time and when viewed with &lt;code&gt;mess&lt;/code&gt; for all tested event types as long as the pattern used was valid. For the indirect command calls all messages also showed up in the &lt;code&gt;redir&lt;/code&gt; files.&lt;/p&gt;&#xA;&lt;p&gt;Neovim had less consistent results. For event type &lt;code&gt;BufEnter&lt;/code&gt; everything worked exactly as it did for Vim. For the &lt;code&gt;FileType&lt;/code&gt;, &lt;code&gt;BufRead&lt;/code&gt; and &lt;code&gt;BufReadPre&lt;/code&gt; events the messages never showed up real-time or in &lt;code&gt;mess&lt;/code&gt; output. The only cases that the &lt;code&gt;echom&lt;/code&gt; call could be verified to have occurred at all with these events is with the indirect/redir test variations. In those cases the &lt;code&gt;echom&lt;/code&gt; output always appeared in the &lt;code&gt;redir&lt;/code&gt; file.&lt;/p&gt;&#xA;&lt;p&gt;Anyways, I believe this concludes matters as far as StackExchange activities go. Next step, if someone wants to move things forward, would be to see what the Neovim maintainers have to say about it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Final Update&lt;/strong&gt;: Apparently this is due to a &lt;a href=&quot;https://github.com/neovim/neovim/wiki/FAQ#calling-inputlist-echomsg--in-filetype-plugins-and-autocmd-does-not-work&quot; rel=&quot;nofollow noreferrer&quot;&gt;different default than Vim for &lt;code&gt;'shortmess'&lt;/code&gt;&lt;/a&gt; and removing &lt;code&gt;F&lt;/code&gt; from its value will match Vim's behavior. Doesn't make me feel too much better about things as the behavior (affecting this autocmd but not that autocmd) is apt to cause confusion. (There have been a number of bug reports filed over this thing.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="42312" LastEditDate="2022-06-18T00:56:22.653" LastActivityDate="2022-06-18T00:56:22.653" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22639" PostTypeId="1" CreationDate="2020-01-24T02:44:43.723" Score="1" ViewCount="449" Body="&lt;p&gt;I would like to swap my left &lt;kbd&gt;shift&lt;/kbd&gt; key with my left &lt;kbd&gt;alt&lt;/kbd&gt; key, and I would like to know if it’s possible to achieve this with vim key mapping. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe not swapping but copy the whole &lt;kbd&gt;shift&lt;/kbd&gt; key map to &lt;kbd&gt;alt&lt;/kbd&gt;?&lt;/p&gt;&#xA;" OwnerUserId="26638" LastEditorUserId="1238" LastEditDate="2020-01-27T05:17:00.597" LastActivityDate="2020-07-26T13:06:30.603" Title="Can I make left Alt act the same as shift key using key map?" Tags="|vimrc|key-bindings|keyboard-layout|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22640" PostTypeId="2" ParentId="22639" CreationDate="2020-01-24T05:21:09.240" Score="1" Body="&lt;p&gt;In vim, nvi, vi, and so forth (all of the terminal vi clones, to be precise), no.  A terminal session doesn't transmit the modifier key presses separate from the keys they're modifying.  It's true that terminal emulators have come a long way since when they were first made, and they have a lot more capabilities now.  But that's something that's pretty fundamental to the data flow on how old terminals worked, and I don't see it as something that would be possible to change without breaking compatibility with all sorts of things they're supposed to be compatible with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've checked to see if there's a gvim capability to do this.  As of 8.2, based on my reading of &lt;code&gt;:help :map&lt;/code&gt;, especially the section &lt;code&gt;:help :map-alt-keys&lt;/code&gt;, there does not appear to be.  gvim &lt;em&gt;does&lt;/em&gt; recognize the modifier keys itself, but it appears to fundamentally not make a distinction between the left or right modifier key of any set that has a pair, and it fundamentally doesn't recognize the modifier key presses except when there's also a non-modifier key pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only things that would stop you from doing a full list of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap &amp;lt;A-A&amp;gt; &amp;lt;A-a&amp;gt;&#xA;:noremap &amp;lt;A-a&amp;gt; &amp;lt;A-A&amp;gt;&#xA;:norelmap &amp;lt;A-A&amp;gt; &amp;lt;A-a&amp;gt;&#xA;:norelmap &amp;lt;A-a&amp;gt; &amp;lt;A-A&amp;gt;&#xA;:noremap &amp;lt;A-B&amp;gt; &amp;lt;A-b&amp;gt;&#xA;:noremap &amp;lt;A-b&amp;gt; &amp;lt;A-B&amp;gt;&#xA;:norelmap &amp;lt;A-B&amp;gt; &amp;lt;A-b&amp;gt;&#xA;:norelmap &amp;lt;A-b&amp;gt; &amp;lt;A-B&amp;gt;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would be your patience with going through all of them and the confusion factor from the amount that you've already gotten used to them being the thing they are by default.  I don't know of a way to get a listing of all of the keycodes that actually &lt;em&gt;do&lt;/em&gt; something, so there's no way I know of to be thorough for all the keys that matter but not bother with the ones that don't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, simply mapping the shifted alt keys to the unshifted alt keys would cause you to lose access to the shifted alt keys' functions, unless you mapped something &lt;em&gt;else&lt;/em&gt; to get there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I'm using the &lt;code&gt;:noremap&lt;/code&gt; command there because a simple &lt;code&gt;:map&lt;/code&gt; both directions like that would result in an infinite loop.  I'm using both &lt;code&gt;:noremap&lt;/code&gt; and &lt;code&gt;:norelmap&lt;/code&gt; because you didn't indicate what contexts you want the remap to happen, and that's the simplest way to get virtually all contexts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a table of map commands at &lt;code&gt;:help map-modes&lt;/code&gt;, which was very confusing to me when I first started using vim, but it should be helpful to you here.  My confusion was because the three columns of commands aren't marked.  The first column is recursive mappings (that is, after the key press is translated, the new code gets looked up to see if it gets mapped in some way, too), the second column is non-recursive mappings (what I naturally expected from map commands), and the third is how to undo either type of mapping.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That having been said, if you have access to your OS keyboard layout, you can do that sort of change.  The simplest way would make that change for everything on the system.  The details of how to do that would probably be under either an OS specific SE, or Super User SE.&lt;/p&gt;&#xA;" OwnerUserId="20713" LastEditorUserId="20713" LastEditDate="2020-01-24T05:52:41.100" LastActivityDate="2020-01-24T05:52:41.100" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22641" PostTypeId="1" AcceptedAnswerId="22649" CreationDate="2020-01-24T06:41:25.730" Score="5" ViewCount="829" Body="&lt;p&gt;One thing I hate about a lot of the default Vim plugins is that they add &lt;code&gt;o&lt;/code&gt; to &lt;code&gt;formatoptions&lt;/code&gt;. In Vim I would get around this by using &lt;code&gt;au FileType * set formatoptions-=o&lt;/code&gt; in my vimrc, but for some reason this no longer works when using Neovim. How can I go about achieving this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Details: Using Neovim 0.4.3 on neovim-qt&lt;/p&gt;&#xA;" OwnerUserId="24943" LastEditorUserId="24943" LastEditDate="2020-01-27T06:34:35.910" LastActivityDate="2020-01-27T06:34:35.910" Title="How to override ftplugin set commands in Neovim" Tags="|vimrc|neovim|autocmd|neovim-qt|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22642" PostTypeId="1" AcceptedAnswerId="22643" CreationDate="2020-01-24T09:04:07.997" Score="1" ViewCount="1491" Body="&lt;p&gt;Currently for &lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;CoC&lt;/a&gt; I am setting the nodejs path like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:coc_node_path = '/usr/local/.nvm/versions/node/v12.4.0/bin/node'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I want this variable to be set to the output of &lt;code&gt;which node&lt;/code&gt;. How can I do this? The CoC config guide does not mention this, and it's my understanding that this is a vim script specific feature.&lt;/p&gt;&#xA;" OwnerUserId="23265" LastActivityDate="2020-01-24T09:11:14.650" Title="Set CoC nodejs path dynamically" Tags="|vimscript|plugin-coc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22643" PostTypeId="2" ParentId="22642" CreationDate="2020-01-24T09:11:14.650" Score="2" Body="&lt;p&gt;Perhaps I should have searched the internet more before I asked this question. I was able to accomplish what I needed using the &lt;code&gt;system&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here I needed to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:coc_node_path = substitute(system('which node'), '\n', '', '')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;substitute&lt;/code&gt; is necessary because we need to get rid of the new line at the end of the output, otherwise the path is invalid.&lt;/p&gt;&#xA;" OwnerUserId="23265" LastActivityDate="2020-01-24T09:11:14.650" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22644" PostTypeId="1" CreationDate="2020-01-24T11:57:06.180" Score="1" ViewCount="1400" Body="&lt;p&gt;I know that I can use the GUI to navigate to the panel for setting &lt;code&gt;guifont&lt;/code&gt;, and I can also issue &lt;code&gt;:set guifont=*&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to list all options as text?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to capture them in a register using &lt;code&gt;:redir @a&lt;/code&gt;, then paste them into a buffer and turn each one into a &lt;code&gt;set guifont&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=The\ first\ font&#xA;set guifont=The\ second\ font&#xA;set guifont=The\ third\ font&#xA;set guifont=The\ fourth\ font&#xA;     ... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would them be simple to yank each one into register &lt;code&gt;&quot;&lt;/code&gt; and paste them into the command line.  Depending on what I see, I can re-order the list from best to last (or best smallest to best biggest).  I can retry each one as desired to refine the ordering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Current work-around&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My aim was to identify a series of fonts and sizes to which to map&#xA; to .  My work-around is below.  I would still be&#xA;interested in whether there is a way to render into text all the font&#xA;names (family, weight, slant, size) in the &lt;code&gt;guifont&lt;/code&gt; selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I manually transcribed the font family names from the selection&#xA;list for &lt;code&gt;guifont&lt;/code&gt; into a text file, then added the font size and&#xA;vertical line spacing.  Comparably small fonts are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Comparable small sizes of palatable font families&#xA;----------------------&#xA;set guifont=Lucida\ Console\ Regular\ 9 linespace=0&#xA;set guifont=Monospace\ Regular\ 8 linespace=0&#xA;set guifont=Liberation\ Mono\ Regular\ 8 linespace=0&#xA;set guifont=DejaVu\ Sans\ Mono\ Book\ 8 linespace=0&#xA;set guifont=Consolas\ Regular\ 9 linespace=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used the following test text to view the various fonts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Test text&#xA;---------&#xA;The quick brown fox jumped over the lazy dogs&#xA;The quick brown fox jumped over the lazy dogs&#xA;The quick brown fox jumped over the lazy dogs&#xA;The quick brown fox jumped over the lazy dogs&#xA;The quick brown fox jumped over the lazy dogs&#xA;The quick brown fox jumped over the lazy dogs&#xA;The quick brown fox jumped over the lazy dogs&#xA;The quick brown fox jumped over the lazy dogs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then replicated each font enough times to perturb the font size&#xA;through a healthy range of sizes, truncating this range for fonts&#xA;that I didn't really like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Step through sizes for each family&#xA;----------------------------------&#xA;set guifont=Consolas\ Regular\ 9 linespace=0&#xA;set guifont=Consolas\ Regular\ 10 linespace=0&#xA;set guifont=Consolas\ Regular\ 11 linespace=0&#xA;set guifont=Consolas\ Regular\ 12 linespace=0&#xA;set guifont=Consolas\ Regular\ 13 linespace=0&#xA;set guifont=Consolas\ Regular\ 14 linespace=0&#xA;set guifont=Consolas\ Regular\ 15 linespace=0&#xA;set guifont=Consolas\ Regular\ 16 linespace=0&#xA;set guifont=Consolas\ Regular\ 17 linespace=0&#xA;&#xA;set guifont=DejaVu\ Sans\ Mono\ Book\ 8 linespace=0&#xA;set guifont=DejaVu\ Sans\ Mono\ Book\ 9 linespace=0&#xA;set guifont=DejaVu\ Sans\ Mono\ Book\ 10 linespace=0&#xA;set guifont=DejaVu\ Sans\ Mono\ Book\ 11 linespace=0&#xA;set guifont=DejaVu\ Sans\ Mono\ Book\ 12 linespace=0&#xA;set guifont=DejaVu\ Sans\ Mono\ Book\ 13 linespace=0&#xA;set guifont=DejaVu\ Sans\ Mono\ Book\ 14 linespace=0&#xA;&#xA;set guifont=Inconsolata\ Medium\ 8 linespace=0&#xA;set guifont=Inconsolata\ Medium\ 9 linespace=0&#xA;set guifont=Inconsolata\ Medium\ 10 linespace=0&#xA;set guifont=Inconsolata\ Medium\ 11 linespace=0&#xA;set guifont=Inconsolata\ Medium\ 12 linespace=0&#xA;set guifont=Inconsolata\ Medium\ 13 linespace=0&#xA;set guifont=Inconsolata\ Medium\ 14 linespace=0&#xA;&#xA;set guifont=Liberation\ Mono\ Regular\ 8 linespace=0&#xA;set guifont=Liberation\ Mono\ Regular\ 9 linespace=0&#xA;set guifont=Liberation\ Mono\ Regular\ 10 linespace=0&#xA;set guifont=Liberation\ Mono\ Regular\ 11 linespace=0&#xA;set guifont=Liberation\ Mono\ Regular\ 12 linespace=0&#xA;set guifont=Liberation\ Mono\ Regular\ 13 linespace=0&#xA;set guifont=Liberation\ Mono\ Regular\ 14 linespace=0&#xA;&#xA;setl guifont=Lucida\ Console\ Regular\ 9 linespace=0&#xA;setl guifont=Lucida\ Console\ Regular\ 10 linespace=0&#xA;setl guifont=Lucida\ Console\ Regular\ 11 linespace=0&#xA;setl guifont=Lucida\ Console\ Regular\ 12 linespace=0&#xA;setl guifont=Lucida\ Console\ Regular\ 13 linespace=0&#xA;setl guifont=Lucida\ Console\ Regular\ 14 linespace=0&#xA;setl guifont=Lucida\ Console\ Regular\ 15 linespace=0&#xA;&#xA;set guifont=Monospace\ Regular\ 8 linespace=0&#xA;set guifont=Monospace\ Regular\ 9 linespace=0&#xA;set guifont=Monospace\ Regular\ 10 linespace=0&#xA;set guifont=Monospace\ Regular\ 11 linespace=0&#xA;set guifont=Monospace\ Regular\ 12 linespace=0&#xA;set guifont=Monospace\ Regular\ 13 linespace=0&#xA;set guifont=Monospace\ Regular\ 14 linespace=0&#xA;&#xA;set guifont=Source\ Code\ Pro\ Regular\ 9 linespace=0&#xA;set guifont=Source\ Code\ Pro\ Regular\ 10 linespace=0&#xA;set guifont=Source\ Code\ Pro\ Regular\ 11 linespace=0&#xA;&#xA;set guifont=Source\ Code\ Pro\ Medium\ 9 linespace=0&#xA;set guifont=Source\ Code\ Pro\ Medium\ 10 linespace=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I liked &lt;code&gt;Lucida Console Regular&lt;/code&gt; best through all the sizes,&#xA;including vertical spacing.  So in my vimrc, I created the following&#xA;mappings for quick font size switching:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    ... snip ...&#xA;&#xA;elseif hostname() ==? &quot;Name_of_laptop&quot;&#xA;&#xA;   map &amp;lt;C-F2&amp;gt; :setl guifont=Lucida\ Console\ Regular\ 7.5 linespace=0&amp;lt;CR&amp;gt;&#xA;   map &amp;lt;C-F3&amp;gt; :setl guifont=Lucida\ Console\ Regular\ 8 linespace=0&amp;lt;CR&amp;gt;&#xA;   map &amp;lt;C-F4&amp;gt; :setl guifont=Lucida\ Console\ Regular\ 9 linespace=0&amp;lt;CR&amp;gt;&#xA;   map &amp;lt;C-F5&amp;gt; :setl guifont=Lucida\ Console\ Regular\ 11 linespace=0&amp;lt;CR&amp;gt;&#xA;   map &amp;lt;C-F6&amp;gt; :setl guifont=Lucida\ Console\ Regular\ 12 linespace=0&amp;lt;CR&amp;gt;&#xA;   map &amp;lt;C-F7&amp;gt; :setl guifont=Lucida\ Console\ Regular\ 13 linespace=0&amp;lt;CR&amp;gt;&#xA;   map &amp;lt;C-F8&amp;gt; :setl guifont=Lucida\ Console\ Regular\ 14 linespace=0&amp;lt;CR&amp;gt;&#xA;   map &amp;lt;C-F9&amp;gt; :setl guifont=Lucida\ Console\ Regular\ 15 linespace=0&amp;lt;CR&amp;gt;&#xA;   map &amp;lt;C-F10&amp;gt; :setl guifont=Lucida\ Console\ Regular\ 16 linespace=0&amp;lt;CR&amp;gt;&#xA;   map &amp;lt;C-F11&amp;gt; :setl guifont=Lucida\ Console\ Regular\ 17 linespace=0&amp;lt;CR&amp;gt;&#xA;   map &amp;lt;C-F12&amp;gt; :setl guifont=Lucida\ Console\ Regular\ 18 linespace=0&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7041" LastEditorUserId="7041" LastEditDate="2020-01-25T03:19:00.530" LastActivityDate="2020-01-25T03:19:00.530" Title="gvim: List all options for guifont as text?" Tags="|gvim|font|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22645" PostTypeId="2" ParentId="9616" CreationDate="2020-01-24T14:02:24.840" Score="1" Body="&lt;p&gt;If you are using RHEL7, it might be that you don't have gui fonts installed, especially if you started with a server.  Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# yum groupinstall fonts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A lot of the responses to stack exchange threads involve something about saying that the default GVIM font looks bad if you don't have certain fonts installed. So I just installed the yum group package for fonts and it worked. Probably the same for other distros too, especially if you started with a server build without a gui.&lt;/p&gt;&#xA;" OwnerUserId="26643" LastEditorUserId="26643" LastEditDate="2020-01-28T01:44:24.963" LastActivityDate="2020-01-28T01:44:24.963" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22646" PostTypeId="1" CreationDate="2020-01-24T22:38:48.493" Score="2" ViewCount="1710" Body="&lt;p&gt;In gvim, &lt;strong&gt;&lt;code&gt;:set guifont=*&lt;/code&gt;&lt;/strong&gt; brings up a &lt;strong&gt;GUI panel&lt;/strong&gt; from which one can choose a font family, weight, slant, and size.  &lt;strong&gt;Where does gVim find these fonts?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm using Cygwin's X-windows.  While the scheme for making fonts available to X-window clients has always come across as complicated to me, I wonder if the fonts of which gVim are aware are the same as those made available by X-windows to all clients?&lt;/p&gt;&#xA;&lt;p&gt;I found this question &lt;a href=&quot;https://groups.google.com/forum/#!topic/vim_use/dn1CXxsdQyU&quot; rel=&quot;nofollow noreferrer&quot;&gt;posted before,&lt;/a&gt; but no answer.&lt;/p&gt;&#xA;" OwnerUserId="7041" LastEditorUserId="23502" LastEditDate="2023-10-10T04:23:39.193" LastActivityDate="2024-03-08T06:02:50.210" Title="Where does gVim find font options for its `guifont` pick list?" Tags="|gvim|font|cygwin|x11|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22647" PostTypeId="1" AcceptedAnswerId="22648" CreationDate="2020-01-24T22:46:13.967" Score="5" ViewCount="1383" Body="&lt;p&gt;I have multiple tab pages. Some tab pages only have open files, some only have &lt;code&gt;:terminal&lt;/code&gt;s open, and some have a mix of files and terminals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the end of the day, I want to quit Vim. Normally, I go through every tab page and close every window manually. But is there a better way? I tried &lt;code&gt;:wqa&lt;/code&gt;, but that doesn't work because I have terminals running in some of my tab pages.&lt;/p&gt;&#xA;" OwnerUserId="22095" LastEditorUserId="22095" LastEditDate="2020-01-25T17:29:26.207" LastActivityDate="2020-01-25T17:29:26.207" Title="How to close all tabs with windows and terminals so I can quit" Tags="|tabbed-user-interface|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22648" PostTypeId="2" ParentId="22647" CreationDate="2020-01-25T00:55:25.493" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;:qa!&lt;/code&gt; to force vim to exit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:qa[ll]!    Exit Vim.  Any changes to buffers are lost.&#xA;        Also see |:cquit|, it does the same but exits with a non-zero&#xA;        value.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As &lt;code&gt;:qa!&lt;/code&gt; doesn't save buffer, you should use &lt;code&gt;:wqa&lt;/code&gt; before that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:qa!&lt;/code&gt; can be dangerous, a half-way stopped terminal might leave you garbage files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;ls R&lt;/code&gt; to list running terminal buffers and load them with &lt;code&gt;:b bufnr&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a command to list all running terminal buffers and modified readonly buffers in a new tab :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com ListUndead ListBuffers R =+&#xA;com -nargs=+ ListBuffers call s:list_buffers(&amp;lt;f-args&amp;gt;)&#xA;&#xA;function s:list_buffers(...) abort&#xA;&#xA;  let bufs = {}&#xA;&#xA;  for flags in a:000&#xA;    let l = split( execute( printf('ls! %s', flags) ), &quot;\n&quot; )&#xA;    let l = map(l, { i,v -&amp;gt; matchstr(v, '\v^\s*\zs\d+') })&#xA;    for buf in l&#xA;      let bufs[ buf ] = buf&#xA;    endfor&#xA;  endfor&#xA;&#xA;  let first = 1&#xA;  for buf in keys(bufs)&#xA;    if first&#xA;      exe 'tab sbuffer' buf&#xA;      let first = 0&#xA;    else&#xA;      exe 'sbuffer' buf&#xA;    endif&#xA;  endfor&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2020-01-25T00:55:25.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22649" PostTypeId="2" ParentId="22641" CreationDate="2020-01-25T01:07:31.583" Score="5" Body="&lt;p&gt;You can use a &lt;code&gt;BufWinEnter&lt;/code&gt; event instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's a late event, which should happen after all the filetype detection and setup is finished.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWinEnter * set formatoptions-=o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The docs in &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html?#BufRead&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help BufRead&lt;/code&gt;&lt;/a&gt; suggest possibly using this event:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html?#BufWinEnter&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;BufWinEnter&lt;/code&gt;&lt;/a&gt; for when you need to do something after processing the modelines.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;While your case is not directly about modelines, that was a hint that this event might be useful...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note this event may be triggered more than once for a specific buffer. If the command you're running is idempotent (which is the case with your command), that should be fine.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-25T01:07:31.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22650" PostTypeId="2" ParentId="22646" CreationDate="2020-01-25T03:17:52.500" Score="0" Body="&lt;p&gt;This is a speculative answer only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect that &lt;code&gt;gvim&lt;/code&gt; has its own set of fonts.  Here are the unbolded,&#xA;unslanted monospace fonts, manually transcribed from the selection&#xA;list from &lt;code&gt;:set guifont=*&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Consolas Regular&#xA;DejaVu Sans Mono Book&#xA;Inconsolata Medium&#xA;Liberation Mono Regular&#xA;Lucida Console Regular&#xA;Monospace Regular&#xA;Source Code Pro Regular&#xA;Source Code Pro Medium&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following are the X-windows fonts.  There is very little overlap.&#xA;So unless there is some aliasing, the set of font families seem to be&#xA;different:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xlsfonts | sed -e 's/-.*//' | sort -u&#xA;&#xA;10x20&#xA;12x24&#xA;12x24kana&#xA;12x24romankana&#xA;5x7&#xA;5x8&#xA;6x10&#xA;6x12&#xA;6x13&#xA;6x13bold&#xA;6x9&#xA;7x13&#xA;7x13bold&#xA;7x13euro&#xA;7x13eurobold&#xA;7x14&#xA;7x14bold&#xA;8x13&#xA;8x13bold&#xA;8x16&#xA;8x16kana&#xA;8x16romankana&#xA;9x15&#xA;9x15bold&#xA;a14&#xA;cursor&#xA;decw$cursor&#xA;decw$session&#xA;fixed&#xA;hanzigb16fs&#xA;hanzigb16st&#xA;hanzigb24st&#xA;heb6x13&#xA;heb8x13&#xA;k14&#xA;kana14&#xA;kanji16&#xA;kanji24&#xA;lucidasans&#xA;lucidasanstypewriter&#xA;micro&#xA;nil2&#xA;olcursor&#xA;olglyph&#xA;r14&#xA;r16&#xA;r24&#xA;rk14&#xA;rk16&#xA;rk24&#xA;variable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The very odd thing is that &lt;code&gt;/usr/share/fonts&lt;/code&gt; contains folders with names that correspond to font families:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;adobe-source-code-pro/  dejavu/       liberation/  terminus/&#xA;adobe-source-sans-pro/  inconsolata/  microsoft/   urw-base35/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While they resemble the &lt;code&gt;gvim&lt;/code&gt; font names more than the X11 font names, none of the folders contain a file that looks like any variation of lucida.  Lucida appears in both &lt;code&gt;gvim&lt;/code&gt; and X11 lists of fonts above.  There is no file with a name containing the string &lt;code&gt;alias&lt;/code&gt; in any of these folders.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Additional information from searching for X11 fonts&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a Cygwin package for font aliases, I found that the &lt;a href=&quot;https://cygwin.com/packages/summary/font-alias.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;usual alias&#xA;files are&#xA;obsolete&lt;/a&gt;. The&#xA;entire package has been replaced by &lt;code&gt;xorg-x11-fonts-misc&lt;/code&gt;, along with&#xA;&lt;a href=&quot;https://cygwin.com/cgi-bin2/package-grep.cgi?grep=xorg-x11-fonts-misc&amp;amp;arch=x86_64&quot; rel=&quot;nofollow noreferrer&quot;&gt;many other font&#xA;packages&lt;/a&gt;.&#xA;Package&#xA;&lt;a href=&quot;https://cygwin.com/cgi-bin2/package-cat.cgi?file=x86_64%2Fxorg-x11-fonts-misc%2Fxorg-x11-fonts-misc-7.5-4&amp;amp;grep=xorg-x11-fonts-misc&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;xorg-x11-fonts-misc&lt;/code&gt;&lt;/a&gt;&#xA;contains &quot;X11 core fonts&quot; in folder tree &lt;code&gt;/usr/share/X11/fonts&lt;/code&gt;,&#xA;binned into the following categories:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;100dpi/  75dpi/  encodings/  misc/  Type1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;misc&lt;/code&gt; folder in particular seems to contain the font family names&#xA;for many of the above families from &lt;code&gt;xlsfonts&lt;/code&gt;, e.g., a series of&#xA;files &lt;code&gt;10x20-ISO8859-*.pcf.gz&lt;/code&gt;, where &lt;code&gt;*&lt;/code&gt; seems to be merely a file&#xA;sequencing number rather than an &lt;code&gt;xfontsel&lt;/code&gt; parameter.  From &lt;code&gt;find *&#xA;-type f | grep -i luc&lt;/code&gt;, none of the gzipped font files in the&#xA;&lt;code&gt;/use/share/X11/fonts&lt;/code&gt; tree seem to have a name containing the string&#xA;&lt;code&gt;luc&lt;/code&gt; (for Lucida).  I tried peering in the gunzipped *.pcf files, but&#xA;they are binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;cygcheck -lv&lt;/code&gt; and searching for (i) &lt;code&gt;/usr/share/fonts&lt;/code&gt; and/or&#xA;(ii) &lt;code&gt;/use/share/X11/fonts&lt;/code&gt;, it becomes obvious that the fonts&#xA;in these two directories come from different packages.  I am now&#xA;floundering in the X-windows font scheme documentation to find a way&#xA;to make fonts in folder (i) available to X-windows (e.g., as&#xA;&lt;code&gt;.Xresources&lt;/code&gt; fonts for &lt;code&gt;xterm&lt;/code&gt;).  Currently, &lt;code&gt;xfontsel&lt;/code&gt; does not show&#xA;the fonts available to &lt;code&gt;gvim&lt;/code&gt;, at least not by their &lt;code&gt;gvim&lt;/code&gt; names.&#xA;The reason for consolidating the two sets of fonts is that, after&#xA;spending a lot of time finding a good set of fonts for &lt;code&gt;gvim&lt;/code&gt;, I would&#xA;like to be able to just use those fonts for &lt;code&gt;xterm&lt;/code&gt; rather than&#xA;searching through an entirely new (and seemingly bigger) pool of&#xA;X11 fonts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it turns out, some of the font category folders in &lt;code&gt;/use/share/X11/fonts&lt;/code&gt;&#xA;contain alias definitions that match the font family names&#xA;from &lt;code&gt;xlsfonts&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;head $(find * -name '*alias*')&#xA;&#xA;==&amp;gt; 100dpi/fonts.alias &amp;lt;==&#xA;lucidasans-bolditalic-8 -b&amp;amp;h-lucida-bold-i-normal-sans-11-80-100-100-p-69-iso8859-1&#xA;lucidasans-bolditalic-10 -b&amp;amp;h-lucida-bold-i-normal-sans-14-100-100-100-p-90-iso8859-1&#xA;lucidasans-bolditalic-12 -b&amp;amp;h-lucida-bold-i-normal-sans-17-120-100-100-p-108-iso8859-1&#xA;lucidasans-bolditalic-14 -b&amp;amp;h-lucida-bold-i-normal-sans-20-140-100-100-p-127-iso8859-1&#xA;lucidasans-bolditalic-18 -b&amp;amp;h-lucida-bold-i-normal-sans-25-180-100-100-p-159-iso8859-1&#xA;lucidasans-bolditalic-24 -b&amp;amp;h-lucida-bold-i-normal-sans-34-240-100-100-p-215-iso8859-1&#xA;lucidasans-bold-8 -b&amp;amp;h-lucida-bold-r-normal-sans-11-80-100-100-p-70-iso8859-1&#xA;lucidasans-bold-10 -b&amp;amp;h-lucida-bold-r-normal-sans-14-100-100-100-p-89-iso8859-1&#xA;lucidasans-bold-12 -b&amp;amp;h-lucida-bold-r-normal-sans-17-120-100-100-p-108-iso8859-1&#xA;lucidasans-bold-14 -b&amp;amp;h-lucida-bold-r-normal-sans-20-140-100-100-p-127-iso8859-1&#xA;&#xA;==&amp;gt; 75dpi/fonts.alias &amp;lt;==&#xA;lucidasans-bolditalic-8 -b&amp;amp;h-lucida-bold-i-normal-sans-8-80-75-75-p-49-iso8859-1&#xA;lucidasans-bolditalic-10 -b&amp;amp;h-lucida-bold-i-normal-sans-10-100-75-75-p-67-iso8859-1&#xA;lucidasans-bolditalic-12 -b&amp;amp;h-lucida-bold-i-normal-sans-12-120-75-75-p-79-iso8859-1&#xA;lucidasans-bolditalic-14 -b&amp;amp;h-lucida-bold-i-normal-sans-14-140-75-75-p-92-iso8859-1&#xA;lucidasans-bolditalic-18 -b&amp;amp;h-lucida-bold-i-normal-sans-18-180-75-75-p-119-iso8859-1&#xA;lucidasans-bolditalic-24 -b&amp;amp;h-lucida-bold-i-normal-sans-24-240-75-75-p-151-iso8859-1&#xA;lucidasans-bold-8 -b&amp;amp;h-lucida-bold-r-normal-sans-8-80-75-75-p-50-iso8859-1&#xA;lucidasans-bold-10 -b&amp;amp;h-lucida-bold-r-normal-sans-10-100-75-75-p-66-iso8859-1&#xA;lucidasans-bold-12 -b&amp;amp;h-lucida-bold-r-normal-sans-12-120-75-75-p-79-iso8859-1&#xA;lucidasans-bold-14 -b&amp;amp;h-lucida-bold-r-normal-sans-14-140-75-75-p-92-iso8859-1&#xA;&#xA;==&amp;gt; misc/fonts.alias &amp;lt;==&#xA;! $Xorg: fonts.alias,v 1.3 2000/08/21 16:42:31 coskrey Exp $&#xA;fixed        -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1&#xA;variable     -*-helvetica-bold-r-normal-*-*-120-*-*-*-*-iso8859-1&#xA;5x7          -misc-fixed-medium-r-normal--7-70-75-75-c-50-iso8859-1&#xA;5x8          -misc-fixed-medium-r-normal--8-80-75-75-c-50-iso8859-1&#xA;6x9          -misc-fixed-medium-r-normal--9-90-75-75-c-60-iso8859-1&#xA;6x10         -misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1&#xA;6x12         -misc-fixed-medium-r-semicondensed--12-110-75-75-c-60-iso8859-1&#xA;6x13         -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1&#xA;6x13bold     -misc-fixed-bold-r-semicondensed--13-120-75-75-c-60-iso8859-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This fills in the picture a bit more about where &lt;code&gt;xlsfonts&lt;/code&gt; gets its&#xA;fonts, but not how the fonts in &lt;code&gt;/usr/share/fonts&lt;/code&gt; (where &lt;code&gt;gvim&lt;/code&gt; likely&#xA;gets its fonts) can be &quot;registered&quot; for use by other X-windows clients.&lt;/p&gt;&#xA;" OwnerUserId="7041" LastEditorUserId="7041" LastEditDate="2020-01-26T20:29:35.877" LastActivityDate="2020-01-26T20:29:35.877" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22651" PostTypeId="2" ParentId="18515" CreationDate="2020-01-25T03:56:53.480" Score="0" Body="&lt;p&gt;Realize this is really old, but for me, substituting WinEnter and WinLeave for FocusGained and FocusLost fixed the problem in my VIM terminal.&lt;/p&gt;&#xA;" OwnerUserId="26651" LastActivityDate="2020-01-25T03:56:53.480" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22652" PostTypeId="1" CreationDate="2020-01-25T06:05:05.340" Score="1" ViewCount="175" Body="&lt;p&gt;&lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-K&amp;gt;&lt;/code&gt; allows for dictionary completion, and &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-T&amp;gt;&lt;/code&gt; for thesaurus completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get both completions at once?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, is there a way I can add the thesaurus results to the bottom of the dictionary results?&lt;/p&gt;&#xA;" OwnerUserId="22553" LastActivityDate="2020-04-22T12:20:42.483" Title="how to get dictionary and thesaurus completion" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22653" PostTypeId="1" AcceptedAnswerId="22656" CreationDate="2020-01-25T06:20:57.600" Score="1" ViewCount="232" Body="&lt;p&gt;I'm trying to bind the key &lt;code&gt;^&lt;/code&gt; so that it runs &lt;code&gt;^&lt;/code&gt; in normal mode by default, but calls the function bound to &lt;code&gt;-&lt;/code&gt; in netrw. &lt;code&gt;-&lt;/code&gt; is bound to &lt;code&gt;NetrwBrowseUpDir&lt;/code&gt; in &lt;code&gt;netrw.vim&lt;/code&gt;, &lt;a href=&quot;https://github.com/vim/vim/blob/7f51bbe0d19f1f0cb0321326f45a17b4f5155f89/runtime/autoload/netrw.vim#L5126&quot; rel=&quot;nofollow noreferrer&quot;&gt;definition here&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my first attempt to bind &lt;code&gt;^&lt;/code&gt; to &lt;code&gt;-&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt;  ^  &amp;amp;ft ==? &quot;netrw&quot; ? &quot;-&quot; : &quot;^&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This snippet will correctly detect whether the current buffer is a netrw view or not, but calls the ordinary &lt;code&gt;-&lt;/code&gt; command, which moves to the first non-whitespace character of the previous line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I call the plugin's function directly? In the definition I linked it's script-local, so I'm not sure how get a reference to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motivation for this is that I use &lt;code&gt;-&lt;/code&gt; and &lt;code&gt;=&lt;/code&gt; to scroll pagewise, and so I need to shift around the default netrw bindings so they don't conflict.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap - &amp;lt;c-d&amp;gt; &#xA;nnoremap = &amp;lt;c-u&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2020-01-26T03:55:49.810" Title="explicitly call netrw function in binding" Tags="|key-bindings|netrw|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22654" PostTypeId="1" AcceptedAnswerId="22669" CreationDate="2020-01-25T08:41:35.300" Score="3" ViewCount="345" Body="&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt;&#xA;I want to spell check latex documents which were mostly generated by software (R). Some contain a modeline specifying &lt;code&gt;spelllang&lt;/code&gt;. &#xA;At the moment I'm manually checking them, but replacing in the generated text doesn't make much sense as they will regenerate wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was experimenting with aspell/ispell but I'm disappointed so far. They do a much worse job than the vim spell checker (which I have nicely configured for my needs by now) to identify environments that shouldn't be checked. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The majority of content is tables and text inside Tikz figures - so it's not trivial to figure out what should be checked. The errors are mostly from bad entries in my input data, but also a few wrong (automatic) plurals and accidentally missing word separators.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&#xA;Is there a way I can call the vim spellchecker non-interactively in a way similar to &lt;code&gt;aspell list&lt;/code&gt; so it will give me a list of bad words? And preferable respects the &lt;code&gt;spelllang&lt;/code&gt; in the modeline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Details&lt;/strong&gt;&#xA;I was asked to add more details. So I will add my train of thoughts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The workflow I'm looking for is to have some kind of unit test to quickly check my generated tex files for errors.&lt;br&gt;&#xA;The main problem I'm battling that I currently drown in &quot;spelling errors&quot; of latex parameters, formulas, citation keys and chemical names. And while I can reasonable exclude blocks, there are sub items that I want to have checked again. E.g. in a figure I don't want the drawing commands checked, but I do need the labels to be checked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Over the last year I have developed a reasonable configuration for vim by extending the syntax definition of tex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that &lt;code&gt;aspell&lt;/code&gt; and the like would fit my workflow better. I gave it a  try and notice I will need to create my own &lt;code&gt;.aspell.conf&lt;/code&gt;. What put me down is that the default config for tex lacks not only definitions for macros I consider standard (like &lt;code&gt;babel&lt;/code&gt; and &lt;code&gt;natbib&lt;/code&gt;) but I also saw no way how to configure it to spell check, when I didn't want the parent spell checked (the figure example). I gave &lt;code&gt;ispell&lt;/code&gt; a shorter try but quickly was frustrated, as information about defining tex statements was practically non-existent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Talking about the modeline - sometimes it contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% vim: spelllang=de&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;TLDR:&lt;/em&gt; not sure if a configuration like I require is possible at all, definitely requires serious configuration. As I have already a reasonable configured utility at hand I would prefer to use that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Examples&lt;/em&gt;&#xA;Unfortunately I can't share my actual files, but my main issues would be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Text inside equations, that should be spelled:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\[ \textrm{Let } x = \textrm{ number of cats} \]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Avoiding additional errors from environments that take an option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{tabular}{lcc}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1120" LastEditorUserId="1120" LastEditDate="2020-01-27T16:33:09.290" LastActivityDate="2020-01-28T06:30:22.090" Title="Can the vim spell checker be used non-interactively?" Tags="|spell-checking|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22655" PostTypeId="2" ParentId="22647" CreationDate="2020-01-25T14:24:44.300" Score="0" Body="&lt;p&gt;If you don’t want to quit, but close all tabs, pick one and do &lt;code&gt;:tabonly&lt;/code&gt; to keep it. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-01-25T14:24:44.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22656" PostTypeId="2" ParentId="22653" CreationDate="2020-01-25T14:42:36.533" Score="3" Body="&lt;p&gt;There is a hacky way to get a scripts &lt;code&gt;&amp;lt;SID&amp;gt;&lt;/code&gt; and use it in mappings, but I always forget it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to do it would be with&lt;code&gt;:nmap&lt;/code&gt;, but this probably only works if you don’t already have a mapping for &lt;code&gt;-&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;expr&amp;gt; ^ &amp;amp;ft ==# 'netrw' ? '-' : '^'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I’ve looked at the docs and do not see a configuration variable for netrw’s mappings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, Matt mentions a &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; mapping in the comments, so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;expr&amp;gt; ^ &amp;amp;ft ==# 'netrw' ? &quot;\&amp;lt;Plug&amp;gt;NetrwBrowseUpDir&quot; : '^'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-01-25T15:25:29.997" LastActivityDate="2020-01-25T15:25:29.997" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22657" PostTypeId="2" ParentId="12495" CreationDate="2020-01-26T00:42:43.333" Score="1" Body="&lt;p&gt;This error occurs because the subsequent files were opened without having been actually loaded: In other words, you never switched to that buffer. So, a way of fixing this would be to cycle through all your files right as you open vim. Adding this to your .vimrc should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; do one full loop through each file given through the commandline&#xA;if argc() &amp;gt; 1&#xA;    for _ in range(argc() - 1)&#xA;      next&#xA;    endfor&#xA;    first&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26656" LastEditorUserId="26656" LastEditDate="2020-02-13T23:18:13.317" LastActivityDate="2020-02-13T23:18:13.317" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22658" PostTypeId="2" ParentId="22653" CreationDate="2020-01-26T03:55:49.810" Score="0" Body="&lt;p&gt;Rather than using a global mapping and checking for the filetype in an expression, just set this mapping in a ftplugin for netrw and set it as a buffer-local mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create file &lt;code&gt;~/.vim/after/ftplugin/netrw.vim&lt;/code&gt; with the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;buffer&amp;gt; ^ &amp;lt;Plug&amp;gt;NetrwBrowseUpDir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 1:&lt;/strong&gt; The &lt;a href=&quot;https://github.com/vim/vim/blob/v8.2.0/runtime/autoload/netrw.vim#L6377&quot; rel=&quot;nofollow noreferrer&quot;&gt;original mapping&lt;/a&gt; also uses &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt;, you might consider adding those yourself as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 2:&lt;/strong&gt; Usually, when you add settings from a script in &lt;code&gt;ftplugin&lt;/code&gt;, you also want to append a snippet to &lt;a href=&quot;https://vimhelp.org/usr_41.txt.html?#undo_ftplugin&quot; rel=&quot;nofollow noreferrer&quot;&gt;the &lt;code&gt;b:undo_ftplugin&lt;/code&gt; variable&lt;/a&gt; with commands to undo the effects of the script. In this case, that's probably not really necessary, since the &lt;code&gt;netrw&lt;/code&gt; filetype is quite specific to &lt;code&gt;netrw&lt;/code&gt; buffers and those don't really use &lt;code&gt;undo_ftplugin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE 3:&lt;/strong&gt; The code that sets up the mapping for &lt;code&gt;-&lt;/code&gt; checks whether there's already a mapping for &lt;code&gt;&amp;lt;Plug&amp;gt;NetrwBrowseUpDir&lt;/code&gt; and skips that mapping if one already exists. If you create your mapping from the &lt;code&gt;ftplugin&lt;/code&gt;, your mapping will be created last, so the &lt;code&gt;-&lt;/code&gt; command will continue to work on &lt;code&gt;netrw&lt;/code&gt; buffers.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-26T03:55:49.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22659" PostTypeId="1" AcceptedAnswerId="22664" CreationDate="2020-01-26T05:29:22.957" Score="1" ViewCount="242" Body="&lt;p&gt;I'm trying to create a command that would accept arguments, and then call &lt;code&gt;vimgrep&lt;/code&gt; with those arguments and display the quickfix window. I set up my command like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=* Vsearch :call &amp;lt;SID&amp;gt;VimGrepSeach(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and my &lt;code&gt;&amp;lt;SID&amp;gt;VimGrepSearch&lt;/code&gt; is defined by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function &amp;lt;SID&amp;gt;VimGrepSearch(query) &#xA;    execute &quot;normal! q:vimgrep /\\v&quot; . a:query . '\g' escape('**/*', ' \')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will search all of the current directory and display the results in a quickfix window, if the equivalent is ran directly from command mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I run this as a command, I get the quickfix quickly popping up, but then it's immediately hidden. What's going on here? Why does the quickfix window appear and then hide, and how can I have it stay open?&lt;/p&gt;&#xA;" OwnerUserId="21269" LastActivityDate="2020-01-26T16:55:38.610" Title="Calling vimgrep from a comand" Tags="|vimgrep|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22660" PostTypeId="1" AcceptedAnswerId="22662" CreationDate="2020-01-26T09:30:25.810" Score="4" ViewCount="245" Body="&lt;p&gt;Is there a built-in way in Vim to search for a pattern in a case-insensitive way, and substituting the occurrence conserving its case? (Something like an &lt;code&gt;s/abcd/efgh&lt;/code&gt; that matches &lt;code&gt;AbCd&lt;/code&gt; and replaces it with &lt;code&gt;EfGh&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="26580" LastActivityDate="2020-01-26T14:42:01.227" Title="Case insensitive conservative substitution" Tags="|search|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22661" PostTypeId="1" CreationDate="2020-01-26T13:05:58.633" Score="1" ViewCount="58" Body="&lt;p&gt;I have a question about vim regexp, How can I match as many as possible in a iterm group?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ther string is &lt;code&gt;op    test&lt;/code&gt; or &lt;code&gt;op test&lt;/code&gt; or &lt;code&gt;optest&lt;/code&gt;, I want to match &lt;code&gt;test&lt;/code&gt;, my expr is &lt;code&gt;\(op\s*\)\@&amp;lt;=[^ ]*&lt;/code&gt;, but it does not work.&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2020-01-26T16:16:06.747" Title="How to match as many as possible in group?" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22662" PostTypeId="2" ParentId="22660" CreationDate="2020-01-26T14:42:01.227" Score="3" Body="&lt;p&gt;There are ways to match characters case-sensitively, and replacement special forms that uppercase or lowercase their arguments, but there is not a native way to do that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, tpope has the excellent &lt;a href=&quot;https://github.com/tpope/vim-abolish&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-abolish&lt;/a&gt; which provides a command &lt;code&gt;:Subvert&lt;/code&gt; that can accomplish this&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-01-26T14:42:01.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22663" PostTypeId="2" ParentId="22661" CreationDate="2020-01-26T16:16:06.747" Score="1" Body="&lt;p&gt;Consider using the &lt;a href=&quot;https://vimhelp.org/pattern.txt.html?#%2F%5Czs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\zs&lt;/code&gt;&lt;/a&gt; marker for the start of the captured match. That way you don't need to deal with zero matches and you can drop at least one grouped expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to match &lt;code&gt;test&lt;/code&gt; in &lt;code&gt;optest&lt;/code&gt; or &lt;code&gt;op test&lt;/code&gt;, then you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;op\s*\zstest&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to match any words (not just &lt;code&gt;test&lt;/code&gt;) coming after &lt;code&gt;op&lt;/code&gt;, then use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;op\s*\zs\w*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Or use &lt;code&gt;\S&lt;/code&gt; instead of &lt;code&gt;\w&lt;/code&gt; if you want to match any non-blank characters and not just keyword characters.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-26T16:16:06.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22664" PostTypeId="2" ParentId="22659" CreationDate="2020-01-26T16:55:38.610" Score="2" Body="&lt;p&gt;The function should just be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'vimgrep /\v' . a:query . '/g **/*'&#xA;copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could do this with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -nargs=* Vsearch vimgrep /\v&amp;lt;args&amp;gt;/g **/* | copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-01-26T16:55:38.610" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22665" PostTypeId="1" AcceptedAnswerId="22667" CreationDate="2020-01-26T19:05:57.550" Score="1" ViewCount="65" Body="&lt;p&gt;Does VIM support comments in command-line mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried the most popular variants including .VIMRC comments but neither worked:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo &quot;hello&quot; // echo usage&#xA;:echo &quot;hello&quot; /* echo usage */&#xA;:echo &quot;hello&quot; &quot;echo usage&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or do the comments in this mode just don't fit in the VIM paradigm?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;:&#xA;It seems there is a problem with the commands that end with &quot;. Because all the others work, e.g. copying a buffer content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let @a=@0 &quot; buffer copying&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There must be some escaping. The suggested solution with |&quot; seems to work for&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo &quot;hello&quot; |&quot; echo usage&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but doesn't work for user-defined commands (those that are defined in .vimrc and whose names start with a capital letter) e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SearchHyphenation &quot; user-defined&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18651" LastEditorUserId="18651" LastEditDate="2020-01-27T18:28:36.533" LastActivityDate="2020-01-27T18:28:36.533" Title="Are there comments in command-line mode?" Tags="|command-line|comments|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22666" PostTypeId="1" AcceptedAnswerId="22673" CreationDate="2020-01-26T21:09:44.840" Score="1" ViewCount="91" Body="&lt;p&gt;I upgraded my Cygwin X-windows after 5 years. I found that there is no&#xA;more &lt;code&gt;/usr/share/vim/vimfiles&lt;/code&gt;, so I copied my files from the &lt;code&gt;after&lt;/code&gt;,&#xA;&lt;code&gt;colors&lt;/code&gt;, &lt;code&gt;plugin&lt;/code&gt;, &lt;code&gt;spell&lt;/code&gt;, and &lt;code&gt;syntax&lt;/code&gt; folders directly into the&#xA;corresponding folders in &lt;code&gt;/usr/share/vim/vim81&lt;/code&gt;.  This is far from&#xA;ideal, as it doesn't separate my custoimization files from the gvim&#xA;package files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;What is the most robust way to maintain a separate tree of&#xA;customization files, i.e., with minimal customization of environmental&#xA;variables and paths?  Is there a default location where gvim looks for&#xA;a site-specific file tree that differs from the packaged ones?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Context&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like most people, my laptop is primarily used by myself. The different&#xA;accounts are only so that I can work with a non-administrator account&#xA;for normal stuff, i.e., not maintenance or housekeeping.  In both&#xA;administrator and non-administrator accounts, I want the same vim&#xA;environment.  Therefore, I will not be using user-specific vimrc&#xA;files, run time paths, etc.  These will be system-wide, hence my&#xA;description of the situation as a site/machine-specific setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I've found so far&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found relevant factors from &lt;code&gt;:help startup&lt;/code&gt;.  By default, my Cygwin&#xA;installation does not set up $VIM, $VIMINIT, or $MYVIMRC.  In this&#xA;situation, according to the help, all folders in the &lt;code&gt;runtimepath&lt;/code&gt;&#xA;(&lt;code&gt;rtp&lt;/code&gt;) setting are searched for plugins.  Fortunately,&#xA;&lt;code&gt;/usr/share/vim/vimfiles&lt;/code&gt; precedes &lt;code&gt;/usr/share/vim/vim81&lt;/code&gt; in my &lt;code&gt;rtp&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtimepath=~/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim81,/usr/share/vim/vimfiles/after,~/.vim/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The leading &lt;code&gt;~/vim&lt;/code&gt; is a holdover from an old user-specific vimrc&#xA;file, before I decided to do things system-wide.  It led to headaches&#xA;keeping the various vimrc files synchronized.  I'm going to leave it&#xA;in because there may be occassion to take advantage of it, but I just&#xA;won't have a ~/vim by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because it is present in &lt;code&gt;rtp&lt;/code&gt;&#xA;all I have to do create &lt;code&gt;/usr/share/vim/vimfiles&lt;/code&gt;  and unpack my&#xA;personal &lt;code&gt;after&lt;/code&gt;, &lt;code&gt;colors&lt;/code&gt;, &lt;code&gt;plugin&lt;/code&gt;, &lt;code&gt;spell&lt;/code&gt;, and &lt;code&gt;syntax&lt;/code&gt; folders&#xA;directly into it.  According to &lt;code&gt;:help rtp&lt;/code&gt;, all of these folders&#xA;are searched for in the paths specified by &lt;code&gt;rtp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like I've answered my own question, but I'd appreciate it if&#xA;someone could confirm its correctness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Mitigating pollution of virgin vim 8.1 package files&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's too late for me now.  I already polluted the&#xA;&lt;code&gt;/usr/share/vim/vim81&lt;/code&gt; file tree with my custom files.  However, I&#xA;think I just selectively copied files into locations wherein they did&#xA;not exist.  I can use bash to find the relative paths &#xA;of my customization files in the &lt;code&gt;vim81&lt;/code&gt; tree&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /path/to/my/customization/file/tree&#xA;for file in $( find * -type f )&#xA;do&#xA;    diff -qs $file /usr/share/vim/vim81/$file&#xA;done&#xA;&#xA;Files after/ftplugin/netrw.vim and ../vim81/after/ftplugin/netrw.vim are identical&#xA;Files after/syntax/tex.vim and ../vim81/after/syntax/tex.vim are identical&#xA;Files colors/mine.vim and ../vim81/colors/mine.vim are identical&#xA;Files plugin/bufexplorer.vim and ../vim81/plugin/bufexplorer.vim are identical&#xA;Files plugin/ChristiansHi20150126.vim and ../vim81/plugin/ChristiansHi20150126.vim are identical&#xA;diff: ../vim81/spell/en.latin1.add: No such file or directory&#xA;diff: ../vim81/syntax/asy.vim: No such file or directory&#xA;Files syntax/texmf.vim and ../vim81/syntax/texmf.vim differ&#xA;diff: ../vim81/syntax/vbnet.vim: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Every occurrence of &lt;code&gt;..&lt;/code&gt; represents the absolute path&#xA;&lt;code&gt;/user/share/vim&lt;/code&gt;.  The only files I copied into the &lt;code&gt;vim81&lt;/code&gt; tree are&#xA;those found to be identical.  If there is no corresponding file in the&#xA;&lt;code&gt;vim81&lt;/code&gt; tree, it means I dispensed with copying that file because&#xA;there seemed to be another file with a different name but for the same&#xA;purpose, and more recent.  On the other hand, if the files with the same name differed in content, it means I chose to&#xA;rely on the newer file in the &lt;code&gt;vim81&lt;/code&gt; tree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My custom files now exist in both &lt;code&gt;vim81&lt;/code&gt; and &lt;code&gt;vimfiles&lt;/code&gt;.  The command&#xA;&lt;code&gt;:scriptnames&lt;/code&gt; shows that the occurrence in &lt;code&gt;vimfiles&lt;/code&gt; precedes the&#xA;occurrence in &lt;code&gt;vim81&lt;/code&gt;.  This is good, but still redundant.  I can&#xA;repeat the above code pattern to locate the redundant occurrences in&#xA;&lt;code&gt;vim81&lt;/code&gt;, extract their paths, and submit them to the remove command&#xA;&lt;code&gt;rm&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /usr/share/vim/vimfiles&#xA;for file in $(find * -type f); do diff -qs $file ../vim81/$file; done 2&amp;gt;&amp;amp;1 | grep identical | sed -e 's=.* \(\S\+\) are identical=\1=' | xargs rm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As this is now a system-wide custoimization, I had to ensure that all&#xA;accounts had read access to files/folders in &lt;code&gt;vimfiles&lt;/code&gt;, and all execution&#xA;rights to directories therein (so that they can actually descend into them):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /usr/share/vim&#xA;&#xA;# Directories&#xA;find vimfiles -type d | xargs chmod a+rx,o-w&#xA;find vimfiles/ -type d | xargs ls -ldF # Visually confirm permissions&#xA;&#xA;# Files&#xA;find vimfiles -type f | xargs chmod a-x,a+r&#xA;find vimfiles/ -type f | xargs ls -ldF # Visually confirm permissions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7041" LastEditorUserId="7041" LastEditDate="2020-01-27T01:47:29.923" LastActivityDate="2020-01-27T05:57:41.183" Title="Machine-specific gvim customization file tree with otherwise minimal customization?" Tags="|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22667" PostTypeId="2" ParentId="22665" CreationDate="2020-01-26T22:46:53.983" Score="4" Body="&lt;p&gt;Vimscript does have comments and they're started by the &lt;code&gt;&quot;&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They always work at the beginning of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; echo usage&#xA;echo &quot;hello&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They &lt;em&gt;sometimes&lt;/em&gt; work inline, but not always. It depends on the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html?#%3Acomment&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :comment&lt;/code&gt;&lt;/a&gt;, which says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;&quot;&lt;/code&gt; after a command causes the rest of the line to be ignored.  This can be used&#xA;  to add comments.  [...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;It is not possible to add a comment to a shell command  [...] and a few others (mainly commands that expect expressions) that see the &lt;code&gt;&quot;&lt;/code&gt; as part of their argument:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;code&gt;:argdo&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;:autocmd&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;[...]&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;:echo&lt;/code&gt; (and the like)&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-26T22:46:53.983" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22668" PostTypeId="1" AcceptedAnswerId="23002" CreationDate="2020-01-26T22:47:06.447" Score="1" ViewCount="176" Body="&lt;p&gt;I have 3 blocks of text with the same number of lines that I want to merge each block by line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# block 1&#xA;[ Card &quot;Skwortul&quot;    &#xA;, Card &quot;Scorchander&quot; &#xA;, Card &quot;Seedasaur&quot;   &#xA;, Card &quot;Kapichu&quot;     &#xA;, Card &quot;Elecdude&quot;    &#xA;, Card &quot;Garydose&quot;    &#xA;, Card &quot;Moisteon&quot;    &#xA;, Card &quot;Grasseon&quot;    &#xA;, Card &quot;Spicyeon&quot;    &#xA;, Card &quot;Sparkeon&quot;    &#xA;]&#xA;# Block 2&#xA;Wet False&#xA;Hot False&#xA;Leafy False&#xA;Spark False&#xA;Spark False&#xA;Wet True&#xA;Wet False&#xA;Leafy False&#xA;Hot False&#xA;Spark True&#xA;# Block 3 &#xA;[Move &quot;Squirt&quot; 20]&#xA;[Move &quot;Scorch&quot; 20]&#xA;[Move &quot;Allergize&quot; 20]&#xA;[Move &quot;Poke&quot; 10 , Move &quot;Zap&quot; 30]&#xA;[Move &quot;Asplode&quot; 50]&#xA;[Move &quot;Gary's move&quot; 40]&#xA;[Move &quot;Soggy&quot; 3]&#xA;[Move &quot;Leaf Cut&quot; 30]&#xA;[Move &quot;Capsaicisize&quot; 40]&#xA;[Move &quot;Shock&quot; 40 , Move &quot;Battery&quot; 50]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to end up with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ Card &quot;Skwortul&quot; Wet False [Move &quot;Squirt&quot; 20]&#xA;, Card &quot;Scorchander&quot; Hot False [Move &quot;Scorch&quot; 20]&#xA;, Card &quot;Seedasaur&quot; Leafy False [Move &quot;Allergize&quot; 20]&#xA;, Card &quot;Kapichu&quot; Spark False [Move &quot;Poke&quot; 10 , Move &quot;Zap&quot; 30]&#xA;, Card &quot;Elecdude&quot; Spark False [Move &quot;Asplode&quot; 50]&#xA;, Card &quot;Garydose&quot; Wet True [Move &quot;Gary's move&quot; 40]&#xA;, Card &quot;Moisteon&quot; Wet False [Move &quot;Soggy&quot; 3]&#xA;, Card &quot;Grasseon&quot; Leafy False [Move &quot;Leaf Cut&quot; 30]&#xA;, Card &quot;Spicyeon&quot; Hot False [Move &quot;Capsaicisize&quot; 40]&#xA;, Card &quot;Sparkeon&quot; Spark True [Move &quot;Shock&quot; 40 , Move &quot;Battery&quot; 50]&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22705" LastActivityDate="2020-02-26T15:24:19.340" Title="Yank multiple lines and paste at end of lines" Tags="|cut-copy-paste|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22669" PostTypeId="2" ParentId="22654" CreationDate="2020-01-26T23:42:51.823" Score="2" Body="&lt;p&gt;While vim can be run in &quot;batch mode&quot; by passing commands you want to run from the command-line, spellchecking is a very interactive affair that doesn't translate to such a workflow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the next question to ask is whether some vimscript could be written to accomplish something like that. Well, there's a glimmer of hope due to the existence of a function called &lt;code&gt;spellbadword()&lt;/code&gt;. It has two modes. With the first you pass it a sentence and it will return the first spelling error it identifies. The second mode is the relevant one: pass nothing and it'll check words under or after the cursor to the end of the cursor line. If something is found the word is returned and the cursor moved to it. Otherwise empty string is returned and the cursor left where it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So one can imagine a script that marches line by line through a file(s) and dumps all the reported bad words. Run vim in the aforementioned batch mode wherein the command to invoke the script is specified along with the files to check. It might be slow but it could work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this sounds usable to you I could write such a script fairly easily I think. Otherwise I believe the answer to the question about using vim how you suggest is: &quot;not possible&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; Whipped this up as a proof-of-concept. Not going to win any awards for it but it works...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! SpellCheckBatch(outfile, ...)&#xA;    try&#xA;        set spell&#xA;        exe &quot;redi! &amp;gt;&amp;gt;&quot; . fnameescape(a:outfile)&#xA;        argdo call SpellCheckFile(a:0 ? a:1 : 0)&#xA;    finally&#xA;        redi END&#xA;        set nospell&#xA;    endtry&#xA;endfunc&#xA;&#xA;func! SpellCheckFile(limit)&#xA;    let currline = nextnonblank(1)&#xA;    let found = 0&#xA;    while currline&#xA;        call setpos(&quot;.&quot;, [0, currline, 1,  0])&#xA;        let spellret = spellbadword()&#xA;&#xA;        while len(spellret[0])&#xA;            &quot; ignoring: 'rare', 'local' (region), 'caps'&#xA;            if spellret[1] ==# 'bad'&#xA;                let curpos = getcurpos()&#xA;                echom &quot;File:&quot; bufname(&quot;&quot;) &quot;Line:&quot; curpos[1] &quot;Col:&quot; curpos[2] &quot;Word:&quot; spellret[0]&#xA;&#xA;                let found += 1&#xA;                if a:limit &amp;amp;&amp;amp; found == a:limit&#xA;                    return&#xA;                endif&#xA;            endif&#xA;&#xA;            &quot; move cursor to next word. for now hack it with norm&#xA;            norm! W&#xA;            let spellret = spellbadword()&#xA;        endwhile&#xA;&#xA;        let currline = nextnonblank(currline + 1)&#xA;    endwhile&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vim invocation...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -R -e -S SCRIPTFILE -c ':call SpellCheckBatch(&quot;OUTFILE&quot;)' -c 'q!' file1 file2...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where SCRIPTFILE is a file containing the two functions above, OUTFILE is wherever you want the results to go, and file1, file2, etc are the files to spellcheck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 2:&lt;/strong&gt; I modified the script so you can optionally supply a limit to the number of spell errors identified per file. The vim invocation above has no limit. If you want to display no more than one spell error per file add a parameter with value 1 to the function call. So that part of the command line would look like:  &lt;code&gt;':call SpellCheckBatch(&quot;OUTFILE&quot;, 1)'&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt; So turning to your original questions we can summarize like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Is there a way I can call the vim spellchecker non-interactively...?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, though some scripting is required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;...in a way similar to aspell list so it will give me a list of bad words?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, as demonstrated. The exact output format is flexible...the script can be modified to suit individual needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;...preferable respects the spelllang in the modeline?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes. Tested this by running an input file containing German text and modeline &lt;code&gt;vim: spelllang=de&lt;/code&gt; through the script. Test passed. &lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-01-28T06:30:22.090" LastActivityDate="2020-01-28T06:30:22.090" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22670" PostTypeId="1" AcceptedAnswerId="22671" CreationDate="2020-01-26T23:56:24.697" Score="2" ViewCount="989" Body="&lt;p&gt;Well, I have had these cases before. I sometimes did unmap, but I don't want to do this for every case. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I define &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;nowait&amp;gt; &amp;lt;leader&amp;gt;h :wincmd h&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it does wait for me typing longer normal commands after the &lt;code&gt;\h&lt;/code&gt;.&#xA;Is it because they are defined afterwards?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map \h&lt;/code&gt; returns the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n  \hp          @&amp;lt;Plug&amp;gt;(GitGutterPreviewHunk)&#xA;n  \hu          @&amp;lt;Plug&amp;gt;(GitGutterUndoHunk)&#xA;n  \hs          @&amp;lt;Plug&amp;gt;(GitGutterStageHunk)&#xA;x  \hs          @&amp;lt;Plug&amp;gt;(GitGutterStageHunk)&#xA;n  \h          * :wincmd h&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the meaning of the * btw?&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2020-01-27T00:02:39.667" LastActivityDate="2020-01-27T01:16:40.410" Title="nowait doesn't seem to work" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22671" PostTypeId="2" ParentId="22670" CreationDate="2020-01-27T00:20:41.753" Score="5" Body="&lt;p&gt;&lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; is intended for cases where a global mapping &lt;code&gt;\hs&lt;/code&gt; (for example) exists and you would like to create a buffer-local mapping &lt;code&gt;\h&lt;/code&gt; (for example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose then the following would work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType * nnoremap &amp;lt;nowait&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;leader&amp;gt;h :wincmd h&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;:map&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt; means created with &lt;code&gt;nnoremap&lt;/code&gt; etc, i.e., &quot;not re-mappable.&quot;&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="18375" LastEditDate="2020-01-27T01:16:40.410" LastActivityDate="2020-01-27T01:16:40.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22672" PostTypeId="2" ParentId="22668" CreationDate="2020-01-27T01:29:11.907" Score="1" Body="&lt;p&gt;It might be best to do it by macro.&#xA;Over the first relevant line(in the block) do &#xA;&lt;code&gt;qa/#block&amp;lt;CR&amp;gt;+&quot;bd$/#block&amp;lt;CR&amp;gt;+&quot;cd$&amp;lt;c-o&amp;gt;&amp;lt;c-o&amp;gt;&quot;bp&quot;cp+q&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I might interpret this later. Hopefully, I am not wrong. (&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; is to press enter, you might just want to type it once) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;then do @a for all the relevant lines (a number indicates the number of times to execute )&lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2020-01-27T01:29:11.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22673" PostTypeId="2" ParentId="22666" CreationDate="2020-01-27T05:57:41.183" Score="1" Body="&lt;p&gt;As you have figured out, even though a &lt;code&gt;vimfiles&lt;/code&gt; directory isn't shipped as part of the Vim package in Cygwin, if you create one and populate it, Vim (and gVim) will use it in its search path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is controlled by the &lt;code&gt;'runtimepath'&lt;/code&gt; setting. And &lt;a href=&quot;https://vimhelp.org/options.txt.html?#%27runtimepath%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'runtimepath'&lt;/code&gt;&lt;/a&gt; confirms that the default is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;           Unix: &quot;$HOME/.vim,&#xA;                  $VIM/vimfiles,&#xA;                  $VIMRUNTIME,&#xA;                  $VIM/vimfiles/after,&#xA;                  $HOME/.vim/after&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Cygwin is Unix emulation on Windows, so the Unix defaults are used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The order of entries in your &lt;code&gt;'runtimepath'&lt;/code&gt; corresponds exactly to the default. (You mentioned &lt;code&gt;~/.vim&lt;/code&gt; as a holdover from an old user-specific vimrc file, but that's actually the default, I don't think you're customizing these. If you are, maybe you don't need to. It's also normal that &lt;code&gt;vimfiles&lt;/code&gt; and &lt;code&gt;vimfiles/after&lt;/code&gt; come before and after &lt;code&gt;$VIMRUNTIME&lt;/code&gt;, so that your files will have the correct priority.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is normal for the &lt;code&gt;$VIM&lt;/code&gt;, &lt;code&gt;$VIMRUNTIME&lt;/code&gt; and similar environment variables &lt;em&gt;not&lt;/em&gt; to be set. (In effect, I haven't ever seen a situation in which those are set outside of Vim.) They're typically initialized by Vim itself. See &lt;a href=&quot;https://vimhelp.org/starting.txt.html?#%24VIM&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help $VIM&lt;/code&gt;&lt;/a&gt; for details on how these are set up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Installing your custom files under &lt;code&gt;/usr/share/vim/vimfiles&lt;/code&gt; is a good approach. As you also found out, you need to ensure they're world-readable, since all users will try to source them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding keeping your Cygwin installation pristine, you can try to reinstall the package that owns the Vim runtime files (I imagine the package might be called &lt;code&gt;vim-runtime&lt;/code&gt; or similar.) From Cygwin's &lt;code&gt;setup.exe&lt;/code&gt; you can manage Cygwin's packages and there's an option to reinstall a specific package. For complete cleanup, try to &lt;em&gt;uninstall&lt;/em&gt; the package that ships the Vim runtimes, then remove any files left in &lt;code&gt;/usr/share/vim/vim81&lt;/code&gt; and finally installing that package back. (There's also a &lt;code&gt;cygcheck&lt;/code&gt; command you can use to inspect packages in Cygwin.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Installing, reinstalling or checking Cygwin packages is a bit off topic for Vi &amp;amp;Vim, consider asking on &lt;a href=&quot;https://superuser.com/&quot;&gt;Superuser Stack Exchange&lt;/a&gt; if you have any follow up questions about Cygwin.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-27T05:57:41.183" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22675" PostTypeId="1" CreationDate="2020-01-27T14:28:01.147" Score="2" ViewCount="1079" Body="&lt;p&gt;I'm trying to do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.py :!isort % | :edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;isort&lt;/code&gt; command in this case is writing to the buffer and so I'd like to reload the buffer to see the changes to the file I'm currently viewing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But i find that because I've triggered a shell command &lt;code&gt;!&lt;/code&gt; the pipe is interpreted as part of the shell command and not as part of a chained vim Ex command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried grouping the shell command so it was separate from the pipe/Ex command (In my head I imagined some magic making this work sort of like a subprocess):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufWritePost *.py :(!isort %) | :edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that was invalid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="22173" LastActivityDate="2020-01-27T15:31:59.970" Title="How to chain shell command with vim Ex command?" Tags="|shell|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22676" PostTypeId="2" ParentId="22675" CreationDate="2020-01-27T15:17:38.557" Score="6" Body="&lt;p&gt;The help for &lt;code&gt;:!&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;A '|' in {cmd} is passed to the shell, you cannot use&#xA;it to append a Vim command.  See |:bar|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The usual workaround is to use &lt;code&gt;:execute&lt;/code&gt;, which can be followed by &lt;code&gt;|&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute '!isort %' | edit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One last note, though: it is possible to use the &lt;code&gt;:!&lt;/code&gt; form as a filter (see &lt;code&gt;:help :range!&lt;/code&gt;), meaning I would use the following code instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!isort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This runs &lt;code&gt;isort&lt;/code&gt; with stdin as the contents of the buffer. It replaces the buffer with the output of the command.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-01-27T15:31:59.970" LastActivityDate="2020-01-27T15:31:59.970" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22678" PostTypeId="1" AcceptedAnswerId="22681" CreationDate="2020-01-27T18:38:17.490" Score="2" ViewCount="581" Body="&lt;p&gt;I previously asked the following question on how to indent the cursor to the identation of the above line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/22577/how-to-ident-the-cursor-to-the-indentation-of-the-above-line&quot;&gt;How to ident the cursor to the indentation of the above line?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A correct answer was provided for how to achieve this in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if it's possible to do the same in insert mode, so that I don't first have to enter normal mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I only know how to use &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;t&lt;/kbd&gt; and &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt; to increase and decrease indentation, respectively, in insert mode.&lt;/p&gt;&#xA;" OwnerUserId="26505" LastEditorUserId="1238" LastEditDate="2020-01-31T08:51:05.110" LastActivityDate="2020-01-31T08:51:05.110" Title="How to indent the cursor to the indentation of the above line in insert mode?" Tags="|insert-mode|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22679" PostTypeId="2" ParentId="22678" CreationDate="2020-01-27T19:14:58.260" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;so that I don't first have to enter normal mode?`&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What's the point of that? Normal mode is 'normal'. Do as much in it as you can. For instance, use &lt;code&gt;==&lt;/code&gt; to fix line's indent in Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another problem is why you keep doing manual indent too much? That could be an indication that something is wrong with your setup (and that was the real point of the previous question). Normally one simply keeps typing while Vim fixes all indents on the fly.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-01-27T19:14:58.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22680" PostTypeId="1" CreationDate="2020-01-27T19:47:42.827" Score="2" ViewCount="1206" Body="&lt;p&gt;I faced an issue&lt;a href=&quot;https://i.stack.imgur.com/E21Cg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E21Cg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;As you can see on the screenshot, &lt;code&gt;vim&lt;/code&gt; does not show tabs with specified &lt;code&gt;airline&lt;/code&gt; theme and it shows me this annoying &lt;code&gt;X&lt;/code&gt; button at the end of the tabline.&#xA;Here's my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute pathogen#infect()&#xA;syntax on&#xA;filetype plugin indent on&#xA;&#xA;&quot;Theme Section&#xA;colo minimalist&#xA;let g:airline_theme='minimalist'&#xA;let g:airline_powerline_fonts = 1&#xA;let g:airline#extensions#tabline#enabled = 1&#xA;let g:airline#extensions#tabline#show_close_button = 0&#xA;set nu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've created another tab:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Qkqte.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qkqte.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;If I go back to the previous one, my &lt;code&gt;airline&lt;/code&gt; theme resets to the default one:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/XUq81.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XUq81.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;And if I switch to the new tab, this default theme stays and annoys me.&#xA;&lt;strong&gt;But&lt;/strong&gt;, here's some &lt;em&gt;magic&lt;/em&gt;:&lt;a href=&quot;https://i.stack.imgur.com/CXvz9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CXvz9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;If I open a directory using &lt;code&gt;vim&lt;/code&gt;, &lt;code&gt;airline&lt;/code&gt; themed tabline seems to be working.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/OCBXJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OCBXJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;When I switch tabs, &lt;code&gt;airline&lt;/code&gt; tabline theme resets again:&lt;a href=&quot;https://i.stack.imgur.com/UR3mk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UR3mk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;Help me, please.&lt;/p&gt;&#xA;" OwnerUserId="26562" LastEditorUserId="26562" LastEditDate="2020-01-27T21:45:34.223" LastActivityDate="2024-02-07T02:06:45.827" Title="vim-airline tabs don't work. resetting airline theme when switching tabs" Tags="|vimrc|plugin-airline|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22681" PostTypeId="2" ParentId="22678" CreationDate="2020-01-27T19:47:46.220" Score="5" Body="&lt;p&gt;There is an insert mode command for this, although it's a bit obscure. I use it frequently when I've hit, e.g., backspace too much, and need to reindent the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Press &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;f&lt;/kbd&gt; in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The docs are at &lt;code&gt;:help i_CTRL-F&lt;/code&gt;, in a section on &lt;code&gt;'indentkeys'&lt;/code&gt; format.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-01-27T19:47:46.220" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22682" PostTypeId="2" ParentId="11903" CreationDate="2020-01-27T23:08:58.843" Score="4" Body="&lt;p&gt;As of vim8, &lt;code&gt;mkview&lt;/code&gt; by default stores current directory for every buffer. You can find &lt;code&gt;lcd &amp;lt;path&amp;gt;&lt;/code&gt; lines inside your views.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To disable this: &lt;code&gt;set viewoptions-=curdir&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="26682" LastActivityDate="2020-01-27T23:08:58.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22683" PostTypeId="1" AcceptedAnswerId="22684" CreationDate="2020-01-28T07:16:37.753" Score="2" ViewCount="3023" Body="&lt;p&gt;I integrated &lt;code&gt;luacheck&lt;/code&gt; in &lt;code&gt;vim&lt;/code&gt; with the following simple function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! LuaCheck()&#xA;  let errors=system(&quot;luacheck &quot; . expand(&quot;%&quot;))&#xA;  cexpr errors&#xA;  cwindow 5&#xA;endfunction&#xA;autocmd FileType lua nnoremap &amp;lt;buffer&amp;gt; &amp;lt;c-f&amp;gt; :call LuaCheck()&amp;lt;cr&amp;gt;&#xA;autocmd FileType lua set efm=%f:%l:%c:\ %m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is working, but here is a problem: &lt;code&gt;luacheck&lt;/code&gt; doesn't have interactive mode, it works only with files. So I have to use &lt;code&gt;expand(&quot;%&quot;)&lt;/code&gt; instead of &lt;code&gt;getline(1, &quot;$&quot;)&lt;/code&gt;. When I changed something in buffer I need to save it before checking - it is bad practice. I want to create a temporary file, save content of buffer to it, check temporary file and remove it. But I don't know how to create the temporary file in &lt;code&gt;vimscript&lt;/code&gt;. Is this possible? Or I need use external tools for it?&lt;/p&gt;&#xA;" OwnerUserId="20084" LastEditorUserId="1841" LastEditDate="2020-01-28T08:36:27.697" LastActivityDate="2020-01-28T09:40:59.853" Title="Creating and destroying temporary files by vim" Tags="|vimscript|filesystem|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22684" PostTypeId="2" ParentId="22683" CreationDate="2020-01-28T08:27:42.217" Score="3" Body="&lt;p&gt;You can create temporary file name with &lt;code&gt;:h tempname()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let tempname = tempname()&#xA;call writefile([ &quot;hello world&quot; ], tempname)&#xA;&quot; do something with tempname file&#xA;&quot; ...&#xA;call delete(tempname)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-01-28T08:27:42.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22685" PostTypeId="1" AcceptedAnswerId="22688" CreationDate="2020-01-28T08:59:59.567" Score="2" ViewCount="368" Body="&lt;p&gt;At the moment, I'm trying to highlight the spaces/tabs used for indentation and the end-of-line with special characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I prefer tabs over spaces I also need the spaces highlighted in order to easily differentiate spaces against tabs if there is an indentation mistake I made or see the spaces when I'm coding in Haskell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the above, the related configuration in my &lt;code&gt;.vimrc&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=2▸▸ ▸ ▸ ▸ ▸ &quot; number of visual spaces per TAB¬&#xA;set shiftwidth=2▸ ▸ ▸ ▸ &quot; number of space characters inserted for indentation¬&#xA; set softtabstop=2▸▸ ▸ ▸ &quot; number of spaces in a tab while editing¬&#xA;set noexpandtab▸▸ ▸ ▸ ▸ &quot; tabs are tabs, not spaces¬&#xA;set autoindent¬&#xA;set list listchars=tab:▸\ ,eol:¬,precedes:• &quot; show invisibles¬&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As can be seen, the &lt;code&gt;listchars&lt;/code&gt; options work fine for the tabs and end-of-line but I can't make the preceding space before a line get marked with the character I've defined(I've intentionally left out a preceding space in the above config. In the actual file, a preceding space is just a space but not the character I've defined it to be).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I went through the documentation and tried various options but couldn't get my head around it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something or is there a configuration conflict that I'm not aware of since I'm preferring tabs over spaces?&lt;/p&gt;&#xA;" OwnerUserId="9894" LastEditorUserId="1238" LastEditDate="2020-01-31T08:16:31.980" LastActivityDate="2020-01-31T08:16:31.980" Title="Listchar for Preceding Indentation Space" Tags="|vimrc|whitespace|listchars|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22686" PostTypeId="2" ParentId="22683" CreationDate="2020-01-28T09:40:59.853" Score="2" Body="&lt;p&gt;There are different approaches to this problem. Assuming your Vim &lt;code&gt;has('job')&lt;/code&gt; you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let temp = bufadd('noname')&#xA;call setbufvar(temp, '&amp;amp;buftype', 'nofile')&#xA;call bufload(temp)&#xA;let job = job_start('luacheck', #{in_io: 'buffer', in_buf: bufnr(),&#xA;    \ out_io: 'buffer', out_buf: temp,&#xA;    \ exit_cb: {id, status -&amp;gt; execute(printf('cb %d | bw %d | cw 5', temp, temp))}&#xA;    \ })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-01-28T09:40:59.853" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22687" PostTypeId="1" CreationDate="2020-01-28T10:36:30.663" Score="2" ViewCount="354" Body="&lt;p&gt;Couldn't find anything in &lt;code&gt;autocommand-events&lt;/code&gt;, but is there may be a way to be notified if window split size was changed (with mouse or with &lt;code&gt;C-w +&lt;/code&gt;)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I try to achieve is to be able to auto-save the window layout if size was changed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: that is for my WIP plugin &lt;a href=&quot;https://github.com/habamax/vim-winlayout&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/habamax/vim-winlayout&lt;/a&gt; which is heavily inspired by and uses code from &lt;a href=&quot;https://vi.stackexchange.com/questions/22543/parsing-winlayout-for-toggling-multiple-windows-at-once/22545#22545&quot;&gt;@dedowsdi answer&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-01-29T03:44:13.187" Title="Split window size change event" Tags="|vimscript|autocmd|split|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22688" PostTypeId="2" ParentId="22685" CreationDate="2020-01-28T10:59:47.400" Score="2" Body="&lt;p&gt;The &lt;code&gt;precedes&lt;/code&gt; suboption of the &lt;code&gt;listchars&lt;/code&gt; option, is used to indicate, if the line has some content before the first visible character. It has nothing to do with showing preceding spaces or such.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to highlight spaces in addition, you can add the &lt;code&gt;spaces&lt;/code&gt; key to the &lt;code&gt;listchars&lt;/code&gt; option. However, this will mark all spaces in the current window, which might be a bit too much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to show preceeding spaces, you can instead use concealing using the &lt;code&gt;match()&lt;/code&gt; functions. Something like this could be working for your:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; call matchadd('Conceal', '\(^ *\)\@&amp;lt;= ', 0, -1, {'conceal': '-'})&#xA; set conceallevel=2 concealcursor=nv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, this is local per window, so you might need to add some autocommands to have this apply to every window you open (or every file you open).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2020-01-28T10:59:47.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22689" PostTypeId="1" AcceptedAnswerId="22690" CreationDate="2020-01-28T12:44:11.553" Score="2" ViewCount="49" Body="&lt;p&gt;I have a json file and I want to change keys of json file.&#xA;For example &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA; name: &quot;John&quot;,&#xA; age: 31,&#xA; city:&quot;New York&quot;,&#xA; school:&quot;xyz&quot;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to make all keys &lt;code&gt;uppercase&lt;/code&gt;. How can I do this with min keystroke in Vim?&lt;/p&gt;&#xA;" OwnerUserId="5890" LastActivityDate="2020-01-28T13:23:03.023" Title="Select upto a given delimeter across multiple lines" Tags="|gvim|macvim|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22690" PostTypeId="2" ParentId="22689" CreationDate="2020-01-28T12:58:25.350" Score="2" Body="&lt;p&gt;As I mentioned in comment, min keystrokes are not always the most convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would go with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/^.*:/\U&amp;amp;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, align all text with vim-easy-align:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gaip:&#xA;CTRL-V (and select all keys)&#xA;U&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this has a side effect of all keys aligned with &lt;code&gt;:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or without a plugin:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/name&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gUiw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;j.j.j.&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Or with normal command:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;vap&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;norm! wgUiw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; is inserted automatically&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS, some visuals:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/lrjuH.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lrjuH.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-01-28T13:23:03.023" LastActivityDate="2020-01-28T13:23:03.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22691" PostTypeId="1" AcceptedAnswerId="22693" CreationDate="2020-01-28T13:02:12.200" Score="1" ViewCount="797" Body="&lt;p&gt;For example, if I run some external program (formatter) from vim and write result of it to some variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let result=system(&quot;some_program&quot;, getline(1, &quot;$&quot;))&#xA;&quot; do something with result&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How I can replace all current buffer content by the &lt;code&gt;result&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS result must be same as &lt;code&gt;%!some_program&lt;/code&gt;, but I can not use this. If program failed it return not &lt;code&gt;0&lt;/code&gt; code and error message with line and column of error, I use this message for create &lt;code&gt;cbuffer&lt;/code&gt;. So I need write result of program to variable, check return code and handle it.&lt;/p&gt;&#xA;" OwnerUserId="20084" LastEditorUserId="20084" LastEditDate="2020-01-28T14:36:28.077" LastActivityDate="2020-01-29T07:26:10.383" Title="How to replace all buffer content by some string?" Tags="|vimscript|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22692" PostTypeId="2" ParentId="485" CreationDate="2020-01-28T13:23:31.140" Score="7" Body="&lt;p&gt;Building on the previous answer, with this bash function you can open vim and the required file will be displayed with colours instead of codes in a new window &amp;quot;a little bit later&amp;quot; (depending on the size of $1).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ansivim ()                               &#xA;{                                        &#xA;    vim -c &amp;quot;:term ++hidden ++open cat $1&amp;quot;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;++hidden&lt;/code&gt; runs the command wihout any open viewport (i.e. window) on it, and&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;++open&lt;/code&gt; will open a window on the buffer only when &amp;quot;the job terminates&amp;quot; i.e. when the &lt;code&gt;cat&lt;/code&gt; command has finished printing the file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In summary this effectively makes the window with the file content open only when &lt;code&gt;cat&lt;/code&gt; has returned in order to have Vim start directly instead of lagging when &lt;code&gt;cat&lt;/code&gt;-ting large files.&lt;/p&gt;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ansivim build.log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11383" LastEditorUserId="48942" LastEditDate="2023-10-23T07:17:46.440" LastActivityDate="2023-10-23T07:17:46.440" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22693" PostTypeId="2" ParentId="22691" CreationDate="2020-01-28T13:34:33.977" Score="2" Body="&lt;p&gt;You can try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent let result=systemlist(&quot;some_program&quot;, getline(1, &quot;$&quot;))&#xA;&quot; do something with result&#xA;&quot; cleanup buffer&#xA;normal! gg_dG&#xA;call setline(1, result)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent let result=system(&quot;some_program&quot;, getline(1, &quot;$&quot;))&#xA;&quot; do something with result&#xA;&quot; cleanup buffer&#xA;:%delete _&#xA;call setline(1, split(result, '\n'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want specific buffer to be replaced, use &lt;code&gt;setbufline&lt;/code&gt; and adjust &quot;cleanup buffer&quot; command.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-01-29T07:26:10.383" LastActivityDate="2020-01-29T07:26:10.383" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22694" PostTypeId="2" ParentId="22680" CreationDate="2020-01-28T17:05:00.780" Score="0" Body="&lt;p&gt;Setting everything up with &lt;code&gt;Vundle&lt;/code&gt; (instead of &lt;code&gt;Pathogen&lt;/code&gt;) fixed the bug. Now everything works!&#xA;&lt;a href=&quot;https://i.stack.imgur.com/PXIfm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PXIfm.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26562" LastActivityDate="2020-01-28T17:05:00.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22695" PostTypeId="1" CreationDate="2020-01-28T17:19:06.040" Score="7" ViewCount="2033" Body="&lt;p&gt;I'd like to mimic the behaviour of i.e. TextMate and VScode and friends, in a GUI-vim: &quot;closing&quot; the last actual-content-window simply leaves me with an empty Vim window, and then &quot;closing&quot; that is what finally quits the actual editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, I'd like to ensure that, when the last window is closed,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If that window was attached to content or saved to disk: a new, empty buffer is created instead, so that Vim doesn't exit;&lt;/li&gt;&#xA;&lt;li&gt;If the current, last-closed buffer  was empty and not saved to disk: Vim actually exits.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What's the most idiomatic way to achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Bonus points: the above, but &lt;a href=&quot;https://github.com/mhinz/vim-startify&quot; rel=&quot;noreferrer&quot;&gt;:Startify&lt;/a&gt; or some other plugin invocation, instead of an empty buffer)&lt;/p&gt;&#xA;" OwnerUserId="6108" LastEditorUserId="1238" LastEditDate="2020-01-29T15:59:49.390" LastActivityDate="2020-02-05T19:57:44.163" Title="How can I ensure Vim doesn't quit entirely when the last window is closed, unless it's empty?" Tags="|buffers|quit|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22696" PostTypeId="1" CreationDate="2020-01-28T20:04:38.650" Score="0" ViewCount="265" Body="&lt;p&gt;When in Normal mode in a Terminal buffer (as in :terminal) there's the Neovim's cursor and the shell's cursor. Going into Terminal-mode forgets your Neovim cursor and you're then using the shell's cursor where you left it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I have it work like standard Vi, where you start inserting where your cursor is (unless not on the current modifiable command-line)? And have I/A take you to the start/end of the command line before putting you in Terminal-mode?&lt;/p&gt;&#xA;" OwnerUserId="26698" LastEditorUserId="26698" LastEditDate="2020-01-29T09:40:34.810" LastActivityDate="2020-01-29T09:40:34.810" Title="Positioning the terminal emulator cursor in Neovim" Tags="|neovim|terminal-buffer|cursor|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22697" PostTypeId="2" ParentId="11974" CreationDate="2020-01-29T00:29:45.043" Score="4" Body="&lt;p&gt;Use &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;f&lt;/kbd&gt; from cmdline or open cmdline by prefixing your command with &lt;code&gt;q&lt;/code&gt; (e.g., &lt;code&gt;q/&lt;/code&gt;) to open the cmdline window, which is a buffer for entering Ex commands. From here, you should be able to use your completion mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help cmdline-window&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could map a command to open the window when you try to do completion in cmdline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmap &amp;lt;Tab&amp;gt; &amp;lt;C-f&amp;gt;a&amp;lt;Tab&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm intentionally using &lt;code&gt;cmap&lt;/code&gt; instead of &lt;code&gt;cnoremap&lt;/code&gt; to allow &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; to invoke your completion plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;, you should also change 'wildchar' so you can still access the incredibly useful &lt;code&gt;wildmenu&lt;/code&gt;. See &lt;code&gt;:help wildmenu&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want completion but your current system doesn't support cmdline-window (or you don't don't want to use it), you can use vim's has built-in vim completion: &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt; &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; for vim completion and &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;n&lt;/kbd&gt; for ins-completion. You can differentiate &lt;code&gt;/&lt;/code&gt; from &lt;code&gt;:&lt;/code&gt; cmdline with &lt;code&gt;getcmdtype()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; getcmdtype() == ':' ? '&amp;lt;C-f&amp;gt;A&amp;lt;C-x&amp;gt;&amp;lt;C-v&amp;gt;' : '&amp;lt;C-f&amp;gt;A&amp;lt;C-n&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2045" LastEditorUserId="2045" LastEditDate="2020-01-31T21:57:43.750" LastActivityDate="2020-01-31T21:57:43.750" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22698" PostTypeId="2" ParentId="22687" CreationDate="2020-01-29T03:44:13.187" Score="3" Body="&lt;p&gt;One undocumented trick is to use &lt;code&gt;%{MyFunc()}&lt;/code&gt; expression in the statusline syntax. &lt;code&gt;MyFunc()&lt;/code&gt; is always called whenever something happens so you can check the window size in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, You can see the window height/width in the statusline.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EchoWinSize()&#xA;   return winheight(0) . '/' . winwidth(0)&#xA;endfunction&#xA;let &amp;amp;statusline = &quot;%{EchoWinSize()}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As well as the statusline, guitablabel, iconstring, rulerformat, tabline, titlestring options support the statusline syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am not sure about its negative side effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this trick since&#xA;I have been looking for something like a WindowScrolled event,&#xA;but not yet implemented.&#xA;In my plugin, I am thinking to use iconstring, which seems not to be used so common, to check the window scroll.&lt;/p&gt;&#xA;" OwnerUserId="1641" LastActivityDate="2020-01-29T03:44:13.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22699" PostTypeId="1" CreationDate="2020-01-29T04:20:52.933" Score="0" ViewCount="95" Body="&lt;p&gt;For me the &lt;kbd&gt;&gt;&lt;/kbd&gt; and &lt;kbd&gt;&amp;lt;&lt;/kbd&gt; are set to 8 spaces. I would like them to be set to 4 spaces. What setting corresponds to this?&lt;/p&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="1238" LastEditDate="2020-01-31T08:51:34.783" LastActivityDate="2020-01-31T08:51:34.783" Title="What vim setting determines the amount of indentation change by pressing &gt; or &lt; (greater than or less than)?" Tags="|indentation|" AnswerCount="1" CommentCount="0" ClosedDate="2020-01-31T08:52:36.353" ContentLicense="CC BY-SA 4.0" />
  <row Id="22700" PostTypeId="2" ParentId="22699" CreationDate="2020-01-29T04:31:28.010" Score="1" Body="&lt;p&gt;This is controlled by &lt;code&gt;shiftwidth&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set sw=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5078" LastActivityDate="2020-01-29T04:31:28.010" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22701" PostTypeId="1" AcceptedAnswerId="22702" CreationDate="2020-01-29T06:40:06.930" Score="7" ViewCount="1333" Body="&lt;p&gt;I have some boilerplate code in one of my vimscript functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Save register 'a' so we don't clobber it&#xA;let savereg = @a&#xA;&#xA;&quot; Yank the current WORD into register 'a' and save it to 'input'&#xA;normal &quot;ayiW&#xA;let input = @a&#xA;&#xA;&quot; Restore register 'a' so we don't clobber it&#xA;let @a = l:savereg&#xA;&#xA;&quot;&#xA;&quot; ... Do work on 'l:input'&#xA;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to do what I want? That is, to operate on a &lt;code&gt;WORD&lt;/code&gt; (or any text object, really) without clobbering a register?&lt;/p&gt;&#xA;" OwnerUserId="14861" LastActivityDate="2020-01-29T10:26:04.460" Title="Is there a way to yank directly to a vimscript variable?" Tags="|vimscript|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22702" PostTypeId="2" ParentId="22701" CreationDate="2020-01-29T07:15:51.253" Score="6" Body="&lt;p&gt;First, if your script runs from a mapping than you probably should support &lt;code&gt;v:register&lt;/code&gt; - let the user decide what to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, if your operation is a sort of &quot;visual replacement&quot; (get selection, modify and put it back) it makes sense to model it after &lt;code&gt;:h v_p&lt;/code&gt; (maybe even end it with &lt;code&gt;gvp&lt;/code&gt; or such).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case either &lt;code&gt;@-&lt;/code&gt; (for &quot;less-than-a-line&quot; selection) or &lt;code&gt;@9&lt;/code&gt; (for a multiline selection) will be overwritten anyway, so you can make use of one of them in your script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, I prefer simply to clobber &lt;code&gt;@0&lt;/code&gt; as it seems like a natural choice. Anyway, it gets overwritten quite often, and it could also be a good idea to spare &quot;original input&quot; for the user.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-01-29T07:15:51.253" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22703" PostTypeId="2" ParentId="22701" CreationDate="2020-01-29T10:26:04.460" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a better way to do what I want? That is, to operate on a &lt;code&gt;WORD&lt;/code&gt; (or any text object, really) without clobbering a register?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you want the current &lt;code&gt;WORD&lt;/code&gt; in specific, then this works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let input = expand('&amp;lt;cWORD&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's not a general solution, but it seems to fit what you're after in this particular instance.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-29T10:26:04.460" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22704" PostTypeId="2" ParentId="11974" CreationDate="2020-01-29T13:00:51.110" Score="1" Body="&lt;p&gt;I answer myself to my old question, sharing a solution &lt;strong&gt;partially satisfying&lt;/strong&gt; to myself (just to reciprocate people answers):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;searches autocompletion&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use plugin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plug 'vim-scripts/CmdlineComplete'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;quoting from: &lt;a href=&quot;https://github.com/vim-scripts/CmdlineComplete&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim-scripts/CmdlineComplete&lt;/a&gt; :&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When editing the command-line ( &lt;code&gt;:&lt;/code&gt; &lt;code&gt;/&lt;/code&gt; etc.), &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;press &lt;code&gt;Ctrl-P&lt;/code&gt; or &lt;code&gt;Ctrl-N&lt;/code&gt; to complete the word before the cursor, using keywords in the current&#xA;  file. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;E.g: you want to search for &lt;em&gt;elephant&lt;/em&gt; in the buffer, just type&#xA;  &lt;code&gt;/ele&lt;/code&gt; and press &lt;code&gt;Ctrl-P&lt;/code&gt;. So long as &lt;em&gt;elephant&lt;/em&gt; is in the buffer, you&#xA;  will get &lt;em&gt;ele&lt;/em&gt; completed into &lt;em&gt;elephant&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Command line commands history (not a real autocompletion)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just use &lt;code&gt;Up-Arrow&lt;/code&gt; and &lt;code&gt;Down-Arrow&lt;/code&gt; to retrieve recent commands history&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="983" LastActivityDate="2020-01-29T13:00:51.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22705" PostTypeId="1" AcceptedAnswerId="22706" CreationDate="2020-01-29T13:40:47.727" Score="3" ViewCount="617" Body="&lt;p&gt;I have the following code and I want to define a syntax highlight rule that will show all lines as commented out starting at the line with &lt;code&gt;##&lt;/code&gt; till the indentation ends just before the last print line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The indentation works like that in python.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function test a b&#xA;    arg Int a b&#xA;    ## if a&amp;gt;b&#xA;        show &quot;Bigger&quot;&#xA;        another command&#xA;    print &quot;More stuff&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think I should use something like the following, but how do I define the end condition based on indentation ? The start condition should somehow remember its indentation and the end condition should use that information. But how ?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region myComment start=/\v##/ skip=/\v\\./ end=???&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The comment highligthing should also stop when encountering a blank line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function test a b&#xA;    arg Int a b&#xA;    ## if a&amp;gt;b&#xA;       show &quot;Bigger&quot;&#xA;&#xA;function more a b&#xA;    arg Int a b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26705" LastEditorUserId="10604" LastEditDate="2020-01-29T21:33:26.093" LastActivityDate="2020-01-29T21:33:26.093" Title="Syntax highlight rule for a block comment using indentation" Tags="|vimscript|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22706" PostTypeId="2" ParentId="22705" CreationDate="2020-01-29T15:38:44.640" Score="1" Body="&lt;p&gt;You can try following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region Comment start=/^\z(\s*\)##/ end=/^\z1\ze\S/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h /\z(\)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically it saves whitespace indentation in &lt;code&gt;\z1&lt;/code&gt; and use it in &lt;code&gt;end&lt;/code&gt; of region just before first non-whitespace. Also see &lt;code&gt;:h /\ze&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zXiSJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zXiSJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For Edited part of question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make it also end on empty line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region Comment start=/^\z(\s*\)##/ end=/\(^\z1\ze\S\)\|\(^\s*$\)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by adding empty line regex to the &lt;code&gt;end&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/COj3F.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/COj3F.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bear in mind that it probably wouldn't work if you mix tabs and spaces.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-01-29T18:55:50.540" LastActivityDate="2020-01-29T18:55:50.540" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22707" PostTypeId="2" ParentId="18265" CreationDate="2020-01-29T15:51:15.123" Score="6" Body="&lt;p&gt;The issue seems to be solved by installing &lt;a href=&quot;https://github.com/tpope/vim-rhubarb&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/tpope/vim-rhubarb&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12893" LastActivityDate="2020-01-29T15:51:15.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22708" PostTypeId="1" AcceptedAnswerId="22709" CreationDate="2020-01-29T15:56:34.957" Score="2" ViewCount="131" Body="&lt;p&gt;I am using &lt;kbd&gt;F5&lt;/kbd&gt; to compile my programs&lt;br&gt;&#xA;From my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set makeprg=make\ -f\ ~/makefile\ %&amp;lt;&#xA;noremap &amp;lt;F5&amp;gt; :make&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I want to add one other way to compile my programs which compiles a bit slowly and use some other key say &lt;kbd&gt;F4&lt;/kbd&gt;. I tried inserting another such statement below these lines but then &lt;kbd&gt;F5&lt;/kbd&gt; also compiles with the new makefile. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&lt;br&gt;&#xA;As asked in comments:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set makeprg=make\ -f\ ~/makefile\ %&amp;lt;&#xA;noremap &amp;lt;F5&amp;gt; :make&amp;lt;CR&amp;gt;&#xA;&quot; slow compilation but more flags for more checks&#xA;set makeprg=make\ -f\ ~/makefile1\ %&amp;lt;&#xA;noremap &amp;lt;F4&amp;gt; :make&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22152" LastEditorUserId="22152" LastEditDate="2020-01-29T16:12:16.153" LastActivityDate="2020-01-29T17:37:30.190" Title="How to have two different makefile mapped to two different keys?" Tags="|key-bindings|makeprg|compile-vim|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="22709" PostTypeId="2" ParentId="22708" CreationDate="2020-01-29T17:27:02.067" Score="4" Body="&lt;p&gt;My understanding is that the &lt;code&gt;makeprg&lt;/code&gt; setting is primarily used to change the actual make/build program and in your case the program isn't changing...it's always 'make'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;:make&lt;/code&gt; accepts arguments I suggest leaving &lt;code&gt;'makeprg'&lt;/code&gt; alone and passing your build command args to &lt;code&gt;:make&lt;/code&gt; in the two mappings...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F4&amp;gt; :make -f ~/makefile1 %&amp;lt;&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;F5&amp;gt; :make -f ~/makefile %&amp;lt;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Regarding &lt;code&gt;%&amp;lt;&lt;/code&gt;, which expands to the current filename minus its extension, in my comments I wavered on whether this would work or if you would need to use &lt;code&gt;:exe&lt;/code&gt; and call &lt;code&gt;expand()&lt;/code&gt; like so....&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;F4&amp;gt; :exe &quot;make -f ~/makefile1 &quot; . expand('%&amp;lt;')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Actually, you should be okay with the shorter versions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, &lt;code&gt;%&amp;lt;&lt;/code&gt; is there for backwards compatibility with a very old version of vim, per &lt;code&gt;:h :_%&amp;lt;&lt;/code&gt;. The synonym, &lt;code&gt;:r&lt;/code&gt;, is now &quot;preferred&quot;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-01-29T17:37:30.190" LastActivityDate="2020-01-29T17:37:30.190" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22710" PostTypeId="2" ParentId="7701" CreationDate="2020-01-30T09:30:51.193" Score="0" Body="&lt;p&gt;To leave the input mode and get back to terminal press esc :qa!&lt;/p&gt;&#xA;" OwnerUserId="26715" LastActivityDate="2020-01-30T09:30:51.193" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22711" PostTypeId="2" ParentId="22695" CreationDate="2020-01-30T10:56:23.097" Score="9" Body="&lt;p&gt;This is something I wanted when I first started using Vim, but I no longer do. From looking at your account, I can see you've been using Vim for several years, but for the benefit of other readers who &lt;em&gt;are&lt;/em&gt; new users, I thought I'd explain why I no longer feel the need for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim offers several different methods for closing windows and buffers, and these have slightly different behaviours. In my use, I know what my goal is, and so I run whichever command that will achieve it.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/editing.txt.html#%3Aq&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:q&lt;/code&gt;&lt;/a&gt; This will close a window, and, if it is the last window, it will quit Vim. So if I don't want to quit Vim, I don't run this command!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Abd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:bd&lt;/code&gt;&lt;/a&gt; This will delete a buffer, and in doing so, it will close any window that is currently displaying that buffer. But if you run it when you only have one window open, then Vim will &lt;em&gt;not&lt;/em&gt; quit, and instead, one of your hidden buffers will be displayed. If you don't have any other buffers open, then a new, empty buffer will be displayed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:%bd&lt;/code&gt; If you don't want to switch to another existing buffer, but instead want to close &lt;em&gt;all&lt;/em&gt; visible and hidden buffers and start editing a new empty buffer, then you can pass a &lt;code&gt;%&lt;/code&gt; range into the &lt;code&gt;:bd&lt;/code&gt; command, to tell it to delete &lt;em&gt;all&lt;/em&gt; your buffers. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/editing.txt.html#%3Aenew&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:enew&lt;/code&gt;&lt;/a&gt; If I only have one window open and I have some other hidden buffers that I &lt;em&gt;don't&lt;/em&gt; want closed, then I will instead use this command to switch from my current buffer to a new empty one.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Aclose&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:close&lt;/code&gt;&lt;/a&gt; or &lt;kbd&gt;Ctrl-W&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt; Close a window, but if there is only one window remaining, don't close it. For some reason I sometimes use &lt;kbd&gt;Ctrl-W&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt; to close a window instead of &lt;code&gt;:q&lt;/code&gt;. It's not because of the difference in behaviour (if I only have one window open I don't ever use this command because I know it won't do anything!); it seems to be just what I feel like typing at the time.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So to address the actual question, when I only have one window open, I know in advance of running a command whether I want to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start editing a new empty buffer, or&lt;/li&gt;&#xA;&lt;li&gt;Quit Vim.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For 2, I use &lt;code&gt;:q&lt;/code&gt;. For 1, I use &lt;code&gt;:enew&lt;/code&gt;, &lt;code&gt;:bd&lt;/code&gt;, or occasionally &lt;code&gt;:%bd&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-01-30T10:56:23.097" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22712" PostTypeId="2" ParentId="21724" CreationDate="2020-01-30T10:56:49.360" Score="2" Body="&lt;p&gt;It turns out it was another plugin causing the interference: &lt;a href=&quot;https://github.com/Townk/vim-autoclose&quot; rel=&quot;nofollow noreferrer&quot;&gt;townk/vim-autoclose&lt;/a&gt;. After uninstalling it, the issue went away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am now using &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;jiangmiao/auto-pairs&lt;/a&gt; without problems.&lt;/p&gt;&#xA;" OwnerUserId="25482" LastActivityDate="2020-01-30T10:56:49.360" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22713" PostTypeId="1" AcceptedAnswerId="22714" CreationDate="2020-01-30T16:45:07.870" Score="3" ViewCount="467" Body="&lt;p&gt;I'm executing an external command that takes as input a range of lines within my file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!copy_stuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running this runs &lt;code&gt;copy_stuff&lt;/code&gt; correctly with the currently selected visual range (and it also works fine with any other range). However, since &lt;code&gt;copy_stuff&lt;/code&gt; doesn't write anything to stdout, it also deletes that range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to pass a range as input to a command without deleting the lines in that range?&lt;/p&gt;&#xA;" OwnerUserId="2526" LastActivityDate="2020-01-30T17:26:15.980" Title="How can I use a range as input for an external command without deleting it?" Tags="|external-command|range|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22714" PostTypeId="2" ParentId="22713" CreationDate="2020-01-30T17:14:26.133" Score="7" Body="&lt;p&gt;You can use &lt;code&gt;:write&lt;/code&gt; for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;w !copy_stuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more details, see &lt;a href=&quot;https://vimhelp.org/editing.txt.html#%3Aw_c&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :write_c&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Execute {cmd} with [range] lines as standard input&#xA;              (note the space in front of the '!').&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-01-30T17:14:26.133" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22715" PostTypeId="2" ParentId="22713" CreationDate="2020-01-30T17:26:15.980" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/22714/18609&quot;&gt;Rich's answer&lt;/a&gt; using &lt;code&gt;:'&amp;lt;,'&amp;gt;w !copy_stuff&lt;/code&gt; is the right answer!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;One alternative is to use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html?#system%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;system()&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can pass it a string as input, which you can get from a register that captures the text in your range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's convenient to define a user command for this purpose, since then you can easily pass it a range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, with your &lt;code&gt;copy_stuff&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CopyStuff(line1, line2)&#xA;    let save_reg = getreg('&quot;')&#xA;    let save_type = getregtype('&quot;')&#xA;    silent execute a:line1 ',' a:line2 'y'&#xA;    call system('copy_stuff', @&quot;)&#xA;    call setreg('&quot;', save_reg, save_type)&#xA;endfunction&#xA;&#xA;command! -range=% -bar CopyStuff call CopyStuff(&amp;lt;line1&amp;gt;, &amp;lt;line2&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first two lines and last line of the function body are saving and restoring the default register (so that it doesn't affect your put commands.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third line yanks the range (passed as arguments) into the default register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the &lt;code&gt;system()&lt;/code&gt; call passes the contents of the default register as input for the external command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The user-defined command is using &lt;code&gt;-range=%&lt;/code&gt;, which allows it to take a range, and defaults to the whole buffer if one isn't passed (you can omit the &lt;code&gt;=%&lt;/code&gt; part if you prefer to default to the current line.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;line1&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;line2&amp;gt;&lt;/code&gt; placeholders are replaced with the first and last line of the range when the command is executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-bar&lt;/code&gt; is there because it's good to have it, always, to be able to put another command on the same line after a &lt;code&gt;|&lt;/code&gt;. (Only exception if you want to handle &lt;code&gt;|&lt;/code&gt;s yourself in arguments, but that's seldom the case.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Invoke it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:CopyStuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or from visual mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;CopyStuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/map.txt.html?#%3Acommand&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :command&lt;/code&gt;&lt;/a&gt; for more options available for user-defined commands (such as arguments).&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-01-30T17:26:15.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22716" PostTypeId="1" CreationDate="2020-01-31T09:01:32.200" Score="2" ViewCount="283" Body="&lt;p&gt;As I'm using Neovim, I'm noticing my marks are just disappearing mid session. I keep having to define them over and over again. I swear it's got to be a bug, either in Neovim or a plugin I'm using, but I'm curious if there's any possible way to debug this—something along the lines of &lt;code&gt;verbose&lt;/code&gt; perhaps. This is getting really annoying.&lt;/p&gt;&#xA;" OwnerUserId="24943" LastActivityDate="2020-01-31T17:29:58.037" Title="Can I debug marks being deleted?" Tags="|neovim|neovim-qt|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22717" PostTypeId="2" ParentId="14425" CreationDate="2020-01-31T09:46:24.647" Score="0" Body="&lt;p&gt;I finally got around to posting &lt;a href=&quot;https://github.com/vim/vim/issues/5559&quot; rel=&quot;nofollow noreferrer&quot;&gt;this as a bug on Vim's issue tracker&lt;/a&gt; after stumbling across it in the &lt;a href=&quot;https://vi.stackexchange.com/unanswered/tagged/?tab=votes&quot;&gt;Unanswered Questions&lt;/a&gt; section.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, after a bit more investigation (which is included in the linked issue), I suspect that the problem is that the size/position of tabs is calculated &lt;em&gt;before&lt;/em&gt; text is concealed, and that this issue will therefore be hard to address. I don't hold out too much hope that a fix is coming any time soon.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-01-31T09:46:24.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22718" PostTypeId="1" AcceptedAnswerId="22719" CreationDate="2020-01-31T10:50:51.290" Score="3" ViewCount="140" Body="&lt;p&gt;I often want to select the whitespace on the line I'm editing to remove it. For instance I have a couple of lines that I want to bring onto one. Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var kernel = new StandardKernel(&#xA;                new TestDbContextBindings());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var kernel = new StandardKernel(                new TestDbContextBindings());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Desired result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var kernel = new StandardKernel(new TestDbContextBindings());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to get to the &quot;desired result&quot; what key combo is most efficient please?&lt;/p&gt;&#xA;" OwnerUserId="26637" LastActivityDate="2020-01-31T11:38:11.907" Title="keystroke to move to end of whitespace" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22719" PostTypeId="2" ParentId="22718" CreationDate="2020-01-31T11:33:02.180" Score="3" Body="&lt;p&gt;For your specific example, starting with the cursor anywhere on the first line, I would type &lt;kbd&gt;J&lt;/kbd&gt;&lt;kbd&gt;x&lt;/kbd&gt;. (See &lt;a href=&quot;https://vimhelp.org/change.txt.html#J&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help J&lt;/code&gt;&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More generally, for whitespace that already exists on a single line, I would use something like &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt; to remove it, &lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt; to visually select it, or &lt;kbd&gt;t&lt;/kbd&gt;&lt;kbd&gt;[char]&lt;/kbd&gt; to just move the cursor to the end of the whitespace that is followed by a &lt;code&gt;[char]&lt;/code&gt; character. There's no shortage of other solutions, but these are pretty simple and easy to use.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-31T11:38:11.907" LastActivityDate="2020-01-31T11:38:11.907" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22720" PostTypeId="1" AcceptedAnswerId="22721" CreationDate="2020-01-31T15:49:34.600" Score="4" ViewCount="83" Body="&lt;p&gt;I use vim to write my to-do list in markdown format.&lt;br&gt;&#xA;To mark a certain task &quot;done&quot; I just make it strikethrough with two tildes(~).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to automatically move all strikethrough text to a different section(#Things done, for example)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And also is there a way to add a date to each task done?&lt;/p&gt;&#xA;" OwnerUserId="26740" LastActivityDate="2020-01-31T16:36:50.083" Title="Move lines with tildes to a certain section of a file" Tags="|filetype-markdown|plugin-vimwiki|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22721" PostTypeId="2" ParentId="22720" CreationDate="2020-01-31T16:13:19.233" Score="5" Body="&lt;h2&gt;Moving completed tasks&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Presuming that a done line looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- ~A completed task~&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can do so with a &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Ag&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:global&lt;/code&gt;&lt;/a&gt; command that performs a &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Am&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:move&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^- \~.*\~$/m/^# Things done/+1&#xA;:g                                  # find lines that match&#xA;  /^- \~.*\~$/                      # the regular expression /^- \~.*\~$/&#xA;              m                     # and move them below&#xA;                               +1   # one line below&#xA;               /^# Things done/     # the line that matches /# Things done/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The regular expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/^- \~.*\~$/&#xA; ^            # the start of the line&#xA;  -           # a markdown list item&#xA;    \~        # a tilde&#xA;      .*      # anything&#xA;        \~    # another tilde&#xA;          $   # the end of the line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You're probably not going to want to type this out every time, so why not make it into a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;c :g/^- \~.*\~$/m/^# Things done/+1&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can move completed items just by pressing &lt;kbd&gt;\&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Appending the time&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can use a similar command to append the current date:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^- \~.*\~$/call setline('.', getline('.') . ' ' . strftime('%x'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works very similarly, but instead of moving the lines, it appends the current date to them. (See &lt;a href=&quot;http://vimhelp.org/eval.txt.html#strftime%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help strftime&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://vimhelp.org/eval.txt.html#getline%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help getline&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;http://vimhelp.org/eval.txt.html#setline%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help setline&lt;/code&gt;&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Doing both at once&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you don't want two separate mappings, you can wrap them in a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function CompleteTasks() abort&#xA;  g/^- \~.*\~$/m/^# Things done/+1&#xA;  g/^- \~.*\~$/call setline('.', getline('.') . ' ' . strftime('%c'))&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;c :call CompleteTasks()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-01-31T16:36:50.083" LastActivityDate="2020-01-31T16:36:50.083" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22722" PostTypeId="2" ParentId="22716" CreationDate="2020-01-31T17:29:58.037" Score="2" Body="&lt;p&gt;As far as I'm aware, Vim does not include any features that will help you track down what's causing this issue, so you have two options, neither of which are very appealing.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You can follow statox's advice, and attempt to narrow down what part of your configuration is causing the issue by &lt;a href=&quot;https://vi.stackexchange.com/q/2003/1841&quot;&gt;selectively disabling&lt;/a&gt; parts of your vimrc and disabling/removing your plugins systematically. This is a pain for this sort of issue because the fact that it just occurs randomly after a period of time means that it's going to take you ages to track down the problem, and while you are doing so you'll be missing parts of your Vim environment making using it more difficult. Unpleasant.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can download the Vim source code, set up a dev environment, learn how to debug C code (if you don't already know how to do so) figure out which bits of the Vim source code are run when a mark is removed/reset, set breakpoints on these, and then carry out your normal tasks until the breakpoint is hit. If you're not already a C programmer, this is not really feasible, and even if you are, it's a big task.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Sorry!&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-01-31T17:29:58.037" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22723" PostTypeId="1" AcceptedAnswerId="23100" CreationDate="2020-01-31T17:32:31.623" Score="3" ViewCount="399" Body="&lt;p&gt;I comment sections in python via a centered title surrounded by &lt;code&gt;#&lt;/code&gt;. What I would like is to make a command so that I can automatically generate such headers. For example, to generate a line like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;############################### Logging ################################&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and also a line to close a section (which is just n &lt;code&gt;#&lt;/code&gt; symbols in a row.&lt;/p&gt;&#xA;" OwnerUserId="26743" LastActivityDate="2020-03-05T10:48:08.800" Title="Pretty python comments" Tags="|comments|filetype-python|plugin-nerdcommenter|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22724" PostTypeId="1" AcceptedAnswerId="22725" CreationDate="2020-01-31T20:52:01.583" Score="2" ViewCount="453" Body="&lt;p&gt;I'm trying to download Vim-Plug from here: &lt;a href=&quot;https://github.com/junegunn/vim-plug/wiki/tutorial&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/junegunn/vim-plug/wiki/tutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It says that I should &quot;download a single VimScript file&quot; and links to this &lt;a href=&quot;https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&lt;/a&gt; but to me that just looks like a text file. Do I download that text file? And save it as what?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any advice would be so appreciated. I know this is probably very simple and easy, but I'm so confused and it's frustrating. Thank you!&lt;/p&gt;&#xA;" OwnerUserId="26746" LastActivityDate="2020-01-31T21:16:19.133" Title="How do I download Vim-Plug?" Tags="|plugin-system|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22725" PostTypeId="2" ParentId="22724" CreationDate="2020-01-31T21:16:19.133" Score="1" Body="&lt;p&gt;Right below the section you quote are the commands to download &amp;amp; install the file for both Vim and Neovim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Vim (~/.vim/autoload)&#xA;curl -fLo ~/.vim/autoload/plug.vim --create-dirs \&#xA;    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;&#xA;# Neovim (~/.local/share/nvim/site/autoload)&#xA;curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \&#xA;    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, yes, you download the text file, and put it in the appropriate directory, based on whether you are using Vim or Neovim.&lt;/p&gt;&#xA;" OwnerUserId="5298" LastActivityDate="2020-01-31T21:16:19.133" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22726" PostTypeId="1" AcceptedAnswerId="22727" CreationDate="2020-02-01T08:25:47.433" Score="2" ViewCount="177" Body="&lt;p&gt;I am having an issue, which I was able to reduce to the following sequence of commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setf c&#xA;syntax region templatyExpression matchgroup=Special start='{{' end='}}'&#xA;syntax region templatyStatement matchgroup=Special start='{%' end='%}'&#xA;syntax match templatyIdentifier '\v[a-zA-Z][a-zA-Z0-9]*' contained containedin=templatyStatement,templatyExpression&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the moment I type the last command, the following C code is improperly highlighted in a test file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define FOO 1&#xA;mdddddd ddd n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;strong&gt;m&lt;/strong&gt; stands for macro-coloured highlighting, &lt;strong&gt;d&lt;/strong&gt; for default highlighting and &lt;strong&gt;n&lt;/strong&gt; for the highlighting associated with numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: why is that? From what I have understood, &lt;code&gt;contained&lt;/code&gt;, together with &lt;code&gt;containedin&lt;/code&gt;, should only apply the highlighter when within something like &lt;code&gt;{{ foo }}&lt;/code&gt; and leave everything else untouched. The rest of my highlighting code works as expected. Is there something obvious I'm missing?&lt;/p&gt;&#xA;" OwnerUserId="26755" LastActivityDate="2020-02-01T11:27:04.887" Title="Why does a custom 'contained' highlight match interfere with the C syntax highlighting?" Tags="|vimscript|syntax-highlighting|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22727" PostTypeId="2" ParentId="22726" CreationDate="2020-02-01T11:27:04.887" Score="2" Body="&lt;p&gt;There is &lt;code&gt;contains=CONTAINED&lt;/code&gt; you can define for regions. See &lt;code&gt;:h syn-contains&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;contains=CONTAINED&#xA;        If the first item in the contains list is &quot;CONTAINED&quot;, then&#xA;        all groups will be accepted that have the &quot;contained&quot;&#xA;        argument.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it means that no matter if you specified &lt;code&gt;contained containedin=GROUP&lt;/code&gt; to be contained in &lt;code&gt;GROUP&lt;/code&gt; it would also be contained in every other regions that have &lt;code&gt;contains=CONTAINED&lt;/code&gt; or &lt;code&gt;contains=ALL&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-02-01T11:27:04.887" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22728" PostTypeId="1" AcceptedAnswerId="22745" CreationDate="2020-02-01T12:25:59.563" Score="0" ViewCount="103" Body="&lt;p&gt;I was writing a simple Vim plug-in for a generic code generator called &lt;a href=&quot;https://github.com/samvv/Templaty&quot; rel=&quot;nofollow noreferrer&quot;&gt;Templaty&lt;/a&gt;. The generator can theoretically work with any programming language, and I'd like Vim to automatically apply the correct highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From experiments, I have noticed Vim automatically loads the correct highlighter if I do something like &lt;code&gt;set ft=c.templaty&lt;/code&gt;. Now, I was wondering if there's a generic way to auto-detect the first part of this string. Right now, I brute-force it by keeping track of a small dictionary of file extensions and their corresponding file type, then doing &lt;code&gt;exec &quot;setfiletype&quot; (filetype . &quot;.templaty&quot;)&lt;/code&gt;, but this is far from ideal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim already has &lt;code&gt;ftdetect&lt;/code&gt;-logic, quite possibly with lots of user-defined ones. How would I be able to query this information programmatically?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As suggested in the comments, I could just read &lt;code&gt;b:current_syntax&lt;/code&gt;, but the problem is that the additional &lt;code&gt;.tply&lt;/code&gt; file extension might prevent the default &lt;code&gt;ftdetect&lt;/code&gt;-logic from working. Would it be possible to tell Vim to try detecting the correct file type &lt;em&gt;as if&lt;/em&gt; the file was without the &lt;code&gt;.tply&lt;/code&gt; extension?&lt;/p&gt;&#xA;" OwnerUserId="26755" LastEditorUserId="26755" LastEditDate="2020-02-03T10:25:41.040" LastActivityDate="2020-02-03T13:33:10.933" Title="Is there a nice way to programmatically call the file auto-detection algorithm?" Tags="|vimscript|filetype|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="22729" PostTypeId="2" ParentId="18183" CreationDate="2020-02-01T18:43:22.557" Score="2" Body="&lt;p&gt;This is a nice technique. Thanks Maxim Kim.&lt;p&gt;&#xA;This description may be helpful. All codes are literal key entries except:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;C-v for [control][v] keys combination &lt;/li&gt;&#xA;&lt;li&gt;ESC for [escape] key&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To insert (spaces that end with char: #) on a vertical line, with cursor anywhere on the first line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ve=all         . enable full screen block cursor access&#xA;$                   . cursor to top right position for vertical line start&#xA;C-v                 . enable select (vertical line) mode&#xA;8j                  . move cursor down 8 lines (selects a vertical line)&#xA;s#ESC               . substitute # char in highlighted area, actuate by escape key&#xA;:set ve=            . restore default mode (mine is unset, could be: block)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;notes: can also append a char or word using an uppercase key append: A, or use insert: I&lt;/p&gt;&#xA;" OwnerUserId="26761" LastActivityDate="2020-02-01T18:43:22.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22730" PostTypeId="1" AcceptedAnswerId="22731" CreationDate="2020-02-01T19:17:35.013" Score="6" ViewCount="1194" Body="&lt;p&gt;This is best explained with an example:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Start by block selecting some text:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9yQI8.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9yQI8.png&quot; alt=&quot;selected&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Yank and paste it somewhere else:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ULLUG.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ULLUG.png&quot; alt=&quot;after paste&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the existing &lt;code&gt;x&lt;/code&gt; characters were pushed over to the side, rather than being replaced.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Desired &quot;Replace&quot; Behavior&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5yWr0.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5yWr0.png&quot; alt=&quot;desired&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command that achieves the above desired result?&lt;/p&gt;&#xA;" OwnerUserId="5373" LastActivityDate="2020-02-01T19:33:02.980" Title="Paste a block in &quot;replace&quot; mode" Tags="|cut-copy-paste|visual-block|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22731" PostTypeId="2" ParentId="22730" CreationDate="2020-02-01T19:33:02.980" Score="8" Body="&lt;p&gt;There's &lt;code&gt;:h put-Visual-mode&lt;/code&gt;. Just select the visual block of the same dimension to make it work as one-to-one replace: &lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-01T19:33:02.980" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22732" PostTypeId="1" CreationDate="2020-02-02T01:15:39.353" Score="3" ViewCount="706" Body="&lt;p&gt;Let's say I record a macro &lt;code&gt;n&lt;/code&gt; that generates the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;2&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I ask for the content with &lt;code&gt;&quot;np&lt;/code&gt; it outputs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;i1^M2^M^[&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I append in &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @n = 'i1^M2^M^['&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if I save &lt;code&gt;.vimrc&lt;/code&gt; and then I call it with &lt;code&gt;@n&lt;/code&gt; in a new file, it outputs the string above literally.....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I represent the newline key in configuration file?&lt;/p&gt;&#xA;" OwnerUserId="6950" LastEditorUserId="1238" LastEditDate="2020-02-03T05:01:55.520" LastActivityDate="2020-07-02T06:01:25.127" Title="newline in macro recording" Tags="|macro|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22733" PostTypeId="1" CreationDate="2020-02-02T08:10:23.633" Score="5" ViewCount="168" Body="&lt;p&gt;when typing Korean, I quite frequently have a space error, and it seems happening randomly.&lt;/p&gt;&#xA;&lt;p&gt;Suppose I am trying to write the sentence &amp;quot;I do not know&amp;quot; in Korean.&#xA;When I hit the space key after 'not' to write 'know', the location of space is supposed to be after 'not', but sometimes it is between 'o' and 't' like 'no t'.&lt;/p&gt;&#xA;&lt;p&gt;I do not have this problem when typing in English and have no clue why.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u9Sku.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u9Sku.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;on the third line, I wrote even the same word, and the error randomly took place.&lt;/p&gt;&#xA;&lt;p&gt;here is a part of my .vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; set encoding=utf-8&#xA; set fileencoding=utf-8&#xA; set guifont=Menlo:h14&#xA; set guifontwide=NanumGothicCoding:h14&#xA; set formatoptions+=mB&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26764" LastEditorUserId="10604" LastEditDate="2023-03-13T22:25:58.687" LastActivityDate="2023-03-13T22:25:58.687" Title="Space Error when typing Korean" Tags="|multibyte|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22734" PostTypeId="1" CreationDate="2020-02-02T08:48:52.713" Score="2" ViewCount="401" Body="&lt;p&gt;I would like to be able to get the current usual mode of vim inside a vim script (and not only inside the statusline).&#xA;I need this functionality to build a vim script linked with ruby script to be able to change keyboard keys colors depend of vim current mode and motion state.&#xA;My problem is that vim doesn't know to provide his mode state inside vim script (only inside statusline), or i failed to get it.&#xA;I think it should have a point there to make vim better by provide a helpful mode() function who can really provide vim current mode (not only in normal mode and not only for statusline).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way dev's users would be able without pain to build script to recognize current vim mode and then build interactive script.&#xA;Also, i'm now able to get FocusGained (i'm not Windows user, my OS is archlinux and sometimes FreeBSD) with adding ugly/tricky vimscript and i think this point can also be increase for vim source code to be not only for gvim or Windows users.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to imagine you want to create a script for color rgb keyboard keys to show currenty mode and aviable keys to hit depend on mode and motion/other state... how to do that if FocusGained and mode() only works for some very limited situations ?&lt;/p&gt;&#xA;" OwnerUserId="26765" LastEditorUserId="26765" LastEditDate="2020-02-04T09:22:40.590" LastActivityDate="2020-02-04T09:22:40.590" Title="get current vim mode inside vimscript code" Tags="|vimscript|linux|" AnswerCount="0" CommentCount="18" ContentLicense="CC BY-SA 4.0" />
  <row Id="22736" PostTypeId="2" ParentId="22732" CreationDate="2020-02-02T12:06:21.770" Score="3" Body="&lt;p&gt;The solution I've found is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let @n = &quot;i1\n2\n\e&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;however the following does not work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let @n = 'i1\n2\n\e'&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2020-02-02T12:06:21.770" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22737" PostTypeId="1" AcceptedAnswerId="22738" CreationDate="2020-02-02T18:19:27.190" Score="2" ViewCount="695" Body="&lt;p&gt;I know the &lt;code&gt;breakindent&lt;/code&gt; option works with &lt;code&gt;linebreak&lt;/code&gt; to preserve indent on wrapped lines. However, when I want to hard wrap lines (using the &lt;code&gt;textwidth&lt;/code&gt; option so &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;/code&gt; is inserted when a line reaches the length specified by &lt;code&gt;textwidth&lt;/code&gt;), &lt;code&gt;breakindent&lt;/code&gt; has no effect (e.g. the new line created has no indentation). I assume &lt;code&gt;breakindent&lt;/code&gt; is not intended to work with &lt;code&gt;textwidth&lt;/code&gt; the way I was expecting. Is there an existing solution to this, or do I have to write a vimscript function to do what I want?&lt;/p&gt;&#xA;" OwnerUserId="26025" LastActivityDate="2020-02-02T18:33:48.103" Title="Keeping indent (like breakindent) when using hard wrap with textwidth" Tags="|indentation|wrapping|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22738" PostTypeId="2" ParentId="22737" CreationDate="2020-02-02T18:33:48.103" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/options.txt.html?#%27autoindent%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'autoindent'&lt;/code&gt;&lt;/a&gt; option enables this behavior:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When autoindent is on, formatting (with the &lt;code&gt;gq&lt;/code&gt; command or &lt;em&gt;when you reach &lt;code&gt;'textwidth'&lt;/code&gt; in Insert mode&lt;/em&gt;) uses the indentation of the first line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that this option has interactions with other options such as &lt;code&gt;'smartindent'&lt;/code&gt; and &lt;code&gt;'cindent'&lt;/code&gt;. Also, if an &lt;code&gt;'indentexpr'&lt;/code&gt; is set, it can often override what &lt;code&gt;'autoindent'&lt;/code&gt; does. An &lt;code&gt;'indentexpr'&lt;/code&gt; is often set if you have filetype indent on, so watch out for those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in general, this should be enough:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-02T18:33:48.103" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22739" PostTypeId="1" CreationDate="2020-02-02T19:03:44.720" Score="3" ViewCount="348" Body="&lt;p&gt;I know the &lt;code&gt;linebreak&lt;/code&gt; option can be used to soft-wrap lines within vim (without inserting any newlines into the file being edited). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I often need to navigate over long lines that have been wrapped. I am aware that &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;k&lt;/kbd&gt; and &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; allow moving up and down display lines, rather than real lines in the file, but I need to be able to achieve this behaviour with other motions like &lt;kbd&gt;$&lt;/kbd&gt; (which should go to the end of the current display line, rather than going to the real end, which may be several display lines down). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Being able to manipulate display lines with linewise-visual mode would also be extremely useful. Is there any succinct way to achieve this? I know creating mappings, such as &lt;code&gt;0 g0&lt;/code&gt;, &lt;code&gt;$ g$&lt;/code&gt; is an option, but I want this to work with &lt;strong&gt;all&lt;/strong&gt; motions that deal in some way with lines, and making that many mappings would be quite inconvenient.&lt;/p&gt;&#xA;" OwnerUserId="26025" LastEditorUserId="1238" LastEditDate="2020-02-03T12:43:37.440" LastActivityDate="2020-02-03T12:43:37.440" Title="Treating lines wrapped with `linebreak` as separate lines" Tags="|wrapping|line-breaks|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22740" PostTypeId="1" CreationDate="2020-02-03T00:52:59.713" Score="4" ViewCount="1767" Body="&lt;p&gt;To make it easier to edit my &lt;code&gt;~/.vimrc&lt;/code&gt; file, I set up the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cnoremap ev :&amp;lt;C-u&amp;gt;vsplit $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, to open &lt;code&gt;~/.vimrc&lt;/code&gt; in a split I just enter command mode and enter &lt;code&gt;ev&lt;/code&gt;. However, I would like do the same thing entering &lt;code&gt;ev&lt;/code&gt; and then &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; (just like the other default commands), so I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cnoremap ev&amp;lt;cr&amp;gt; :&amp;lt;C-u&amp;gt;vsplit $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gives &lt;code&gt;E492: Not an editor command: ev&lt;/code&gt;.&#xA;Why is this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my full &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader=&quot; &quot;&#xA;&#xA;&quot; Plugins (using 'plugged') ----------- {{{&#xA;call plug#begin('~/.vim/plugged')&#xA;Plug 'preservim/nerdtree'&#xA;Plug 'itchyny/lightline.vim'&#xA;call plug#end()&#xA;&quot; }}}&#xA;&#xA;&quot; Some basics&#xA;    set mouse=a&#xA;    set nocompatible&#xA;    set laststatus=2&#xA;    filetype plugin on&#xA;    filetype indent plugin on&#xA;    syntax on&#xA;&quot; Tabs amount to 4 blank spaces&#xA;    set tabstop=4&#xA;    set shiftwidth=4&#xA;    set expandtab&#xA;&quot; Splits open at the the bottom and on the right&#xA;    set splitright splitbelow&#xA;&quot; All folds are closed upon entering a file&#xA;    set foldlevelstart=0 &#xA;&#xA;&quot; Vimscript file settings -------------- {{{    &#xA;    augroup filetype_vim&#xA;        autocmd!&#xA;        autocmd FileType vim setlocal foldmethod=marker&#xA;    augroup END&#xA;&quot; }}}&#xA;&#xA;&quot; NERDTree ---------------------- {{{&#xA;&quot; NERDTree Toggle shortcut remap&#xA;    nnoremap &amp;lt;F5&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; NERDTress File highlighting&#xA;function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)&#xA; exec 'autocmd filetype nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg&#xA; exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'&#xA;endfunction&#xA;&#xA;call NERDTreeHighlightFile('cpp', 'green', 'none', 'green', '#151515')&#xA;call NERDTreeHighlightFile('h', 'green', 'none', 'green', '#151515')&#xA;call NERDTreeHighlightFile('py', 'Red', 'none', '#ffa500', '#151515')&#xA;&quot; }}}&#xA;&#xA;&quot; remapping keys for general use&#xA;    :nnoremap j &amp;lt;Left&amp;gt;&#xA;    :nnoremap m &amp;lt;Down&amp;gt;&#xA;    :nnoremap h &amp;lt;Nop&amp;gt;&#xA;    :vnoremap j &amp;lt;Left&amp;gt;&#xA;    :vnoremap m &amp;lt;Down&amp;gt;&#xA;    :vnoremap h &amp;lt;Nop&amp;gt;&#xA;    :noremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;    :noremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;    :noremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;    :noremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;    :inoremap &amp;lt;Left&amp;gt; &amp;lt;Nop&amp;gt;&#xA;    :inoremap &amp;lt;Right&amp;gt; &amp;lt;Nop&amp;gt;&#xA;    :inoremap &amp;lt;Up&amp;gt; &amp;lt;Nop&amp;gt;&#xA;    :inoremap &amp;lt;Down&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26778" LastActivityDate="2020-02-03T03:46:24.207" Title="Problem remapping key bindings in command line mode" Tags="|vimrc|key-bindings|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22741" PostTypeId="2" ParentId="22723" CreationDate="2020-02-03T01:43:44.763" Score="0" Body="&lt;p&gt;You can call &lt;code&gt;winwidth()&lt;/code&gt; to get the number of chars in line that fit the screen. &#xA;And use  &lt;code&gt;printf('%#'. width. 's' , str)&lt;/code&gt;. It should fill it with #, in a similar way to zero fill (I believe).&#xA;You can encapsulate it in a function to be called by a command. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2020-02-03T01:43:44.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22743" PostTypeId="2" ParentId="22740" CreationDate="2020-02-03T03:46:24.207" Score="7" Body="&lt;p&gt;I can't reproduce your exact issue. The &lt;code&gt;ev&amp;lt;cr&amp;gt;&lt;/code&gt; mapping works fine for me. I don't see the &lt;code&gt;E492: Not an editor command: ev&lt;/code&gt; error you're seeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I wanted to write an answer to recommend that you &lt;em&gt;don't&lt;/em&gt; use &lt;code&gt;cnoremap&lt;/code&gt; for this purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many limitations to the way &lt;code&gt;cnoremap&lt;/code&gt; works that make it really inconvenient for this purpose:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It will expand anywhere in the command line, not only at the beginning of the line, where an Ex command is expected.&lt;/li&gt;&#xA;&lt;li&gt;It will expand not only in command mode (for Ex commands) but for search strings as well (so now &lt;code&gt;/ev&lt;/code&gt; will search for &lt;code&gt;vsplit $MYVIMRC&lt;/code&gt; instead!)&lt;/li&gt;&#xA;&lt;li&gt;It will &quot;eat&quot; keystrokes and not display them in full trying to match a mapping. Feels funny to start typing and not seeing the characters in feedback as you expect.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There's a way to accomplish something &lt;em&gt;very&lt;/em&gt; close to what you want (see solution #3 below.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I have two suggestions that accomplish something &lt;em&gt;similar&lt;/em&gt; to what you're asking for, not exactly the same, that I think are superior.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;1. User-defined Command&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can define &lt;a href=&quot;https://vimhelp.org/map.txt.html?#user-commands&quot; rel=&quot;noreferrer&quot;&gt;user commands&lt;/a&gt; in Vim, which is really close to what you seem to want here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main constraint is that user commands need to start with a capital letter, so you can't really use &lt;code&gt;ev&lt;/code&gt; exactly, you'd have to use &lt;code&gt;EV&lt;/code&gt; or &lt;code&gt;Ev&lt;/code&gt; instead. (I tend to find the former easier to type, by holding down the shift key while typing the &quot;E&quot; and &quot;V&quot;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, it's pretty straightforward to define a user command for this purpose:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar EV vsplit $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once that's defined, you can use it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:EV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One advantage of user commands is that they support a whole range of features, you can have commands that use arguments, ranges, completion (for example, filenames), a second version with a bang (&lt;code&gt;:EV!&lt;/code&gt;), etc.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;2. Normal mode Mapping&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Another option is to use a normal mode mapping. An advantage of that approach is that it's usually quicker to access it than using the command-line. (You need the &lt;code&gt;:&lt;/code&gt; to enter command mode, plus the &quot;Enter&quot; at the end. Plus, if you're using user commands, you need uppercase, which means holding the &quot;Shift&quot; key.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could simply use &lt;code&gt;&amp;lt;Leader&amp;gt;ev&lt;/code&gt; in Normal mode (three keystrokes) to accomplish the same. &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; defaults to backslash, but many use &lt;code&gt;,&lt;/code&gt; or &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; to make it even easier to access.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use a normal mapping with &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt;, this is all you need:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Leader&amp;gt;ev :vsplit $MYVIMRC&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also define a similar &lt;code&gt;xnoremap&lt;/code&gt; mapping so it also works in Visual mode, in which case use &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; to delete the range first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Access it with &lt;code&gt;\ev&lt;/code&gt; from Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;3. Command-mode abbreviation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can use a command-line &lt;em&gt;abbreviation&lt;/em&gt; (instead of mapping) to get closer to the intended result of making &lt;code&gt;:ev&amp;lt;cr&amp;gt;&lt;/code&gt; work. The abbreviation will not have the unintended side-effect of &quot;eating&quot; keystrokes while finding a match, since it only looks for matches when whole words were typed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, by using an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; abbreviation, you can only make it trigger for commands (not when typing a search pattern) and only trigger when it's typed as the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a start:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cabbrev &amp;lt;expr&amp;gt; ev getcmdtype() ==# ':' &amp;amp;&amp;amp; getcmdline() ==# 'ev' ? 'vsplit $MYVIMRC' : 'ev'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This checks whether it's in command-line mode (see &lt;code&gt;:help getcmdtype()&lt;/code&gt; for more details) and whether the &lt;em&gt;whole&lt;/em&gt; command-line matches &lt;code&gt;ev&lt;/code&gt; exactly (which means it's the command, since it's the first item) and only then expands it to the &lt;code&gt;vsplit&lt;/code&gt; command. Otherwise, expands to &lt;code&gt;ev&lt;/code&gt; itself, to keep no changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this will produce a slightly weird behavior if you press a key other than &quot;Enter&quot; after &lt;code&gt;:ev&lt;/code&gt;. If you press &quot;Space&quot;, it will show the expansion with the space at the end. Even more odd if you type some other non-word character like &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;#&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a way for you to only expand the abbreviation if an &quot;Enter&quot; was typed by looking at &lt;code&gt;getchar(0)&lt;/code&gt; from the abbreviation. But it's not enough to test it, you'll have to save it to include it in the abbreviation, since you'll have consumed the character... You'll need a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EditVimrc()&#xA;    if getcmdtype() ==# ':' &amp;amp;&amp;amp; getcmdline() ==# 'ev'&#xA;        let c = nr2char(getchar(0))&#xA;        if c ==# &quot;\r&quot;&#xA;            return &quot;vsplit $VIMRC\r&quot;&#xA;        endif&#xA;        return 'ev' . c&#xA;    endif&#xA;    return 'ev'&#xA;endfunction&#xA;&#xA;cabbrev &amp;lt;expr&amp;gt; ev EditVimrc()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to do exactly what you wanted. It even works if you mistype a character and go back to correct it. It won't work if you have additional spaces in the line though. And the implementation is pretty complex...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'd really recommend you go with #1 or #2 instead. But if you want the exact interface you described, this is the closest you'll get.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-03T03:46:24.207" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22744" PostTypeId="1" CreationDate="2020-02-03T05:02:45.077" Score="0" ViewCount="20" Body="&lt;p&gt;I used this map:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map ,w v/\([^ a-z]*\|[^ A-Z]*\)&amp;lt;cr&amp;gt;h&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the idea is to select&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in the words&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mysuperTest&#xA;MYSUPER_TEST&#xA;mysuper_test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to be able to select 'test' and 'mysuper' depending if the caret is at the beginning, or the end of the string. The regex should work for mysuper but it doesnt. Not sure how to handle test&lt;/p&gt;&#xA;" OwnerUserId="26780" LastEditorUserId="26780" LastEditDate="2020-02-03T05:57:11.067" LastActivityDate="2020-02-03T05:57:11.067" Title="Select first char up to first non camelCase or non upper case char or up to first snake case _ in vim" Tags="|regular-expression|" AnswerCount="0" CommentCount="3" ClosedDate="2020-02-07T19:57:30.963" ContentLicense="CC BY-SA 4.0" />
  <row Id="22745" PostTypeId="2" ParentId="22728" CreationDate="2020-02-03T13:28:00.017" Score="2" Body="&lt;p&gt;So the whole point is that if &lt;code&gt;&amp;amp;filetype&lt;/code&gt; is of the form &lt;code&gt;x.y&lt;/code&gt; then Vim automatically loads indents and syntaxes from &lt;em&gt;both&lt;/em&gt; &lt;code&gt;x.vim&lt;/code&gt; and &lt;code&gt;y.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the code in &lt;code&gt;syntax/y.vim&lt;/code&gt; must take this into account and keep the previous value of &lt;code&gt;b:current_syntax&lt;/code&gt;. So instead of usual: &lt;code&gt;if exists('b:current_syntax') | finish | endif&lt;/code&gt;, or &lt;code&gt;unlet b:current_syntax&lt;/code&gt; it should start with something like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !exists('b:current_syntax')&#xA;    &quot; cannot be the first syntax!&#xA;    finish&#xA;endif&#xA;&quot; append the new syntax instead of overwriting it&#xA;let b:current_syntax .= '.y'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;As suggested in the comments, I could just read b:current_syntax, but the problem is that the additional .tply file extension might prevent the default ftdetect-logic from working. Would it be possible to tell Vim to try detecting the correct file type as if the file was without the .tply extension?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you want to also make an auto-detection working then you have to write a file-detection script and put it under &lt;code&gt;ftdetect/&lt;/code&gt; subdirectory (the file name does not matter, as detection scripts are always preloaded):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead ?\+.tply&#xA;    \ exe 'doau filetypedetect BufRead' fnameescape(expand('&amp;lt;afile&amp;gt;:r')) |&#xA;    \ if did_filetype() |&#xA;    \     let &amp;amp;ft .= '.templaty' |&#xA;    \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that filetype will be set twice, but it should not be important, as &quot;standard&quot; syntaxes/indents have a guard against double inclusion.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2020-02-03T13:33:10.933" LastActivityDate="2020-02-03T13:33:10.933" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22746" PostTypeId="2" ParentId="10869" CreationDate="2020-02-03T14:29:34.793" Score="2" Body="&lt;h2&gt;Why this happens&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;When you close the file with &lt;code&gt;:x&lt;/code&gt;, it saves the buffer and closes the window/tab, but Vim does &lt;em&gt;not&lt;/em&gt; forget about the file. If you execute the &lt;code&gt;:ls&lt;/code&gt; command after doing so, you will see the buffer is still there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, when you re-open the file, Vim will notice that it already has a buffer with the &quot;same&quot; filename (because your file system is case-preserving but case-insensitive, &lt;code&gt;fizzbuzz.java&lt;/code&gt; and &lt;code&gt;FizzBuzz.java&lt;/code&gt; are equivalent with respect to the file's identity), and reuse the buffer, with the lower-case file name.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In order to prevent this, instead of merely closing the window, you need to tell Vim to discard the buffer entirely, by using the &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Abw&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:bwipeout&lt;/code&gt;&lt;/a&gt; command. This completely removes the buffer from Vim, and so when you reopen it, it treats it as an entirely new buffer, and uses the upper-case file name from the filesystem.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;An alternative workaround&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;:bwipeout&lt;/code&gt; has &lt;a href=&quot;https://vi.stackexchange.com/a/2213/343&quot;&gt;some other effects&lt;/a&gt;. If these are an issue, you can instead use the workaround &lt;a href=&quot;https://vi.stackexchange.com/questions/10869/dealing-with-case-insensitive-filenames-on-windows#comment19086_10869&quot;&gt;suggested by Antony in the comments&lt;/a&gt;, which is to allow Vim to open the file using the lower-case file name, but then rename the buffer to match the upper-case name with the &lt;a href=&quot;https://vimhelp.org/editing.txt.html#%3Afile_f&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:file {name}&lt;/code&gt;&lt;/a&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:f %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-02-03T14:29:34.793" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22748" PostTypeId="1" AcceptedAnswerId="22751" CreationDate="2020-02-03T17:06:39.340" Score="4" ViewCount="4976" Body="&lt;p&gt;I was reading here &lt;a href=&quot;https://vi.stackexchange.com/questions/300/other-ways-to-exit-insert-mode-besides-escape&quot;&gt;Other ways to exit Insert mode besides Escape&lt;/a&gt; and in various other places.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I have is if I enter visual select mode I cannot use &lt;kbd&gt;j&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; or &lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; to exit that mode, because &lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; is used to travel up and down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there another way to exit that mode there without using &lt;kbd&gt;esc&lt;/kbd&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using ideavim&lt;/p&gt;&#xA;" OwnerUserId="26780" LastEditorUserId="1238" LastEditDate="2020-02-03T23:15:00.253" LastActivityDate="2023-07-14T21:53:19.803" Title="Exit visual selection mode with different shortcut / hotkey" Tags="|key-bindings|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22749" PostTypeId="1" CreationDate="2020-02-03T18:10:46.770" Score="2" ViewCount="56" Body="&lt;p&gt;I'm trying to wrap my head around this line of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;normal! gg/for .\\+ in .\\+:\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand that it's executing in normal mode (ignoring remappings) the command that starts with &lt;code&gt;gg&lt;/code&gt;. It goes up to the first line and searches for the word &quot;for&quot;. Then I'm lost. Can anyone help me?&lt;/p&gt;&#xA;" OwnerUserId="26778" LastActivityDate="2020-02-03T22:02:03.710" Title="Difficulty with regular expressions" Tags="|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22750" PostTypeId="2" ParentId="22749" CreationDate="2020-02-03T18:43:02.913" Score="2" Body="&lt;p&gt;The upshot is that what follows &lt;code&gt;normal!&lt;/code&gt; is &lt;em&gt;almost&lt;/em&gt; what you would type on your keyboard except for having to deal with some tricky double-escaping (&lt;code&gt;\\+&lt;/code&gt;) and the special &lt;code&gt;\&amp;lt;cr&amp;gt;&lt;/code&gt; notation. (If the &lt;code&gt;:&lt;/code&gt; is throwing you don't let it. It's just a literal colon in the search string.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you're right about &lt;code&gt;gg&lt;/code&gt;. Following that is a search with this vim regular expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for .\+ in .\+:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...which matches strings of the form&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for &amp;lt;blah&amp;gt; in &amp;lt;bleh&amp;gt;:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...where &amp;lt;blah&gt; and &amp;lt;bleh&gt; each must have at least one (non-newline) character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's the right regular expression then something happened to one of the &lt;code&gt;\&lt;/code&gt;s preceding each &lt;code&gt;+&lt;/code&gt;. Where'd they go? The double escaping is a byproduct of two things. First, we know that the wildcard &lt;code&gt;+&lt;/code&gt; in a vim regexp requires one &lt;code&gt;\&lt;/code&gt; (unless we use &lt;em&gt;very-magic&lt;/em&gt; mode...see below).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next is the fact that the double quoted string's contents are not executed as is. The string is a parameter for the &lt;code&gt;:execute&lt;/code&gt; command which takes whatever is passed to it, &quot;evaluates&quot; it and executes the result. (Which we hope is a valid Vim expression at this point.) Evaluation involves things like resolving variables into their values and, relevant to us, looking for special chars occurring after escape chars.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since we need the escaping to get through to search (&lt;code&gt;/&lt;/code&gt;) we add an extra escape to cope with &lt;code&gt;:execute&lt;/code&gt;s inclination to strip them. (&lt;code&gt;:execute&lt;/code&gt; will see an escaped &lt;code&gt;\&lt;/code&gt; and an escaped &lt;code&gt;\&lt;/code&gt; is not special. In that context it's just a backslash.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the &lt;code&gt;\&amp;lt;cr&amp;gt;&lt;/code&gt; at the end, that's simpler. Vim's rules around key codes say we have to escape them in expressions like this (exception: in a mapping it's not required). This one, of course, will resolve into the equivalent of pressing the Enter key...just like you'd press it yourself if entering the command manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the &quot;very magic&quot; mode mentioned above, this is enabled by pre-pending the regexp with &lt;code&gt;\v&lt;/code&gt;. Just like &lt;code&gt;\+&lt;/code&gt; there's escaping here but we &lt;em&gt;could&lt;/em&gt; trade two instances of double-escaping for one and perhaps make it a little more familiar...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute &quot;normal! gg/\\vfor .+ in .+:\&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-02-03T22:02:03.710" LastActivityDate="2020-02-03T22:02:03.710" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22751" PostTypeId="2" ParentId="22748" CreationDate="2020-02-04T02:34:08.693" Score="6" Body="&lt;p&gt;At least in Vim, there are a few more ways to leave Visual mode. Not sure if they're available in ideavim, but you might consider giving them a try.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The combination &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; is a synonym for &lt;kbd&gt;Esc&lt;/kbd&gt;, it produces the same keycode. So if you're avoiding the Esc key because it's in an awkward position (or your keyboard doesn't have one), you might like that combination.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; combination is the usual keystroke to cancel commands and (at least in Vim) it ends Visual mode. You can try to see if it works in ideavim as well.&lt;/li&gt;&#xA;&lt;li&gt;You can also leave Visual mode by pressing one of &lt;kbd&gt;v&lt;/kbd&gt;, &lt;kbd&gt;V&lt;/kbd&gt; (which is &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;) or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt;, depending on which Visual mode you're in (character-wise, linewise or blockwise.) Pressing one of this while on another Visual mode will switch you to the Visual mode enabled by this keystroke, but if you press it while on that Visual mode already Vim will leave Visual mode. So one nice trick is to just press &lt;kbd&gt;v&lt;/kbd&gt;, then if you're still in Visual mode, just press &lt;kbd&gt;v&lt;/kbd&gt; again and you'll be out.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can set up a mapping to generate &lt;kbd&gt;Esc&lt;/kbd&gt; in Visual mode when pressing a different key (or combination of keys.) For example, to leave Visual mode on pressing the spacebar:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;lt;Space&amp;gt; &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(Note that &lt;code&gt;xnoremap&lt;/code&gt; is the command to create a mapping for Visual mode only.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, if the issue you have is that you don't have an &quot;Escape&quot; key, consider using some mapping at the O.S. keyboard driver level to map another key (such as &quot;Caps Lock&quot;) to &quot;Escape&quot;. In the MacOS, you'll find such an option under keyboard preferences. (Search Google or other StackExchange sites and you'll find instructions on how to set that up.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-02-04T09:46:35.603" LastActivityDate="2020-02-04T09:46:35.603" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22752" PostTypeId="1" AcceptedAnswerId="22757" CreationDate="2020-02-04T04:38:10.730" Score="1" ViewCount="82" Body="&lt;p&gt;I have some text like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    a x=&quot;true&quot; i q={1}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, a line of text prefixed with 4 space characters. Then letters with spaces in between.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to transform the text to this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    a&#xA;x=&quot;true&quot;&#xA;i&#xA;q={1}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(So keep the 4 spaces at the beginning and replace every next space with a line break.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I tried &lt;code&gt;s/ /\r/g&lt;/code&gt;, but then I realized that substitution also replaces the leading 4 spaces. However, I want to keep the 4 leading spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to use substitutions on parts of lines, instead of whole lines?&lt;/p&gt;&#xA;" OwnerUserId="22095" LastEditorUserId="1238" LastEditDate="2020-02-04T21:12:18.840" LastActivityDate="2020-02-05T13:17:49.047" Title="Is it possible to apply substitutions on parts of lines, instead of whole lines?" Tags="|substitute|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22753" PostTypeId="1" CreationDate="2020-02-04T07:59:21.807" Score="1" ViewCount="441" Body="&lt;p&gt;I moved from org mode to VimWiki. I used to write &quot;logs&quot; like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* 2020-02-04&#xA;&#xA;  FeatureA&#xA;    - progress&#xA;&#xA;  Feature B&#xA;    - progress&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The file can get pretty long as you can imagine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now with VimWiki I'd have to make this one big list it looks like I can only do that if I do lists (not fold by headers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can achieve folding of whole sections, not just lists?&#xA;I tried enabling folding by indentation but that doesn't let me to fold big sections like that.&lt;/p&gt;&#xA;" OwnerUserId="12905" LastActivityDate="2020-02-04T07:59:21.807" Title="Folding in VimWiki like in org mode?" Tags="|folding|plugin-vimwiki|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22754" PostTypeId="2" ParentId="21798" CreationDate="2020-02-04T08:38:19.303" Score="0" Body="&lt;p&gt;This plugin could be halpful with given cases: &lt;a href=&quot;https://github.com/skywind3000/vim-terminal-help&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/skywind3000/vim-terminal-help&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following settings allow to open current terminal dir in vim in one key:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:terminal_edit=&quot;edit&quot;&#xA;tmap &amp;lt;F6&amp;gt; drop .&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11971" LastEditorUserId="11971" LastEditDate="2020-02-04T12:43:54.257" LastActivityDate="2020-02-04T12:43:54.257" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22755" PostTypeId="1" CreationDate="2020-02-04T12:03:39.080" Score="4" ViewCount="515" Body="&lt;p&gt;There are commands such as &lt;code&gt;:Break&lt;/code&gt; and &lt;code&gt;:Continue&lt;/code&gt;, but I would like an &lt;code&gt;:Until&lt;/code&gt; to run to the current line without setting a breakpoint.  Is it possible to add this myself, or would it need a vim feature request?&lt;/p&gt;&#xA;" OwnerUserId="26795" LastEditorUserId="10604" LastEditDate="2020-02-04T22:59:45.263" LastActivityDate="2020-02-05T01:25:15.110" Title="customising Termdebug commands" Tags="|terminal|debugging|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22756" PostTypeId="2" ParentId="22755" CreationDate="2020-02-04T12:44:00.993" Score="2" Body="&lt;p&gt;It's documented at &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#termdebug_shortcuts&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h termdebug_shortcuts&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ,u :call TermDebugSendCommand( printf( 'until %d', line('.') ) )&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's add at &lt;a href=&quot;https://github.com/vim/vim/commit/b3307b5e7e&quot; rel=&quot;nofollow noreferrer&quot;&gt;patch 8.1.0071&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tons of bugs have been fixed since 8.0, update to 8.1 or 8.2 if you can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to stay in 8.0, you can try to replace your termdebug.vim with &lt;a href=&quot;https://github.com/vim/vim/blob/master/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;master version&lt;/a&gt;, it's located at &lt;code&gt;$VIMRUNTIME/pack/dist/opt/termdebug/plugin/termdebug.vim&lt;/code&gt;, note that you should back up the original version, I'm not sure if it would work.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-02-05T01:25:15.110" LastActivityDate="2020-02-05T01:25:15.110" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22757" PostTypeId="2" ParentId="22752" CreationDate="2020-02-04T12:47:24.100" Score="2" Body="&lt;p&gt;&lt;em&gt;Jump to the end for the simplest solution. I decided to thumb my nose at the KISS principle for a while before snapping out of it and posting the easy answer.&lt;/em&gt; :P&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At least three ways come to mind to handle this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first uses the &lt;code&gt;%v&lt;/code&gt; pattern &quot;atom&quot; (see &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#/%5C%v&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h /\%v&lt;/code&gt;&lt;/a&gt;). This is used to pin the search after/before a column number. For example this matches all text up to column 17: &lt;code&gt;/^.*\%17v&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We'll use it to skip over the opening four spaces and then substitute line feeds for every space afterwards:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\%&amp;gt;4v /\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another option is to use &quot;look arounds&quot;. Specifically a &quot;negative lookbehind&quot; (&lt;code&gt;:h /\@&amp;lt;!&lt;/code&gt;). We want to change all spaces to line feed except for those that are at the beginning of the line or separated from the beginning of the line by only whitespace.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\%(^\s*\)\@&amp;lt;!\s/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that says to match any whitespace, &lt;code&gt;\s&lt;/code&gt;, &lt;em&gt;as long as there is no match preceding it&lt;/em&gt; (&lt;code&gt;\@&amp;lt;!&lt;/code&gt;) made up of the beginning of the line plus optional whitespace characters (&lt;code&gt;\%(^\s*\)&lt;/code&gt;). This actually will work for any length of opening indent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that lookaround expressions don't actually consume any of the target string. This explains: &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2fzero-width&quot; rel=&quot;nofollow noreferrer&quot;&gt;/zero-width&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These answers are specifically targeting your stated use case (four-space indent followed by the &quot;sentence&quot; to modify). But the subject asks a more general question (&quot;apply substitution on parts of lines&quot;). That question has been asked before and you can find some more generalized discussion there: &lt;a href=&quot;https://vi.stackexchange.com/questions/20704/how-to-run-a-substitute-command-on-only-a-certain-part-of-the-line/20706#20706&quot;&gt;How to run a substitute command on only a certain part of the line&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, to understand my third solution I recommend you read my answer there. This approach is probably overkill for the relatively simple problem we're looking at here (though I maintain this isn't as complicated as some folks make it out to be). For the sake of thoroughness I give you the &lt;em&gt;sub-replace expression&lt;/em&gt; solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/^\s\+\zs\(.*\)/\=substitute(submatch(0), ' ', '\r', 'g')/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Silly me, I left out the easiest solution. This despite the fact that I posted something similar in a comment above (though that was targeting an earlier, easier version of the question)...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\(\S\+\) /\1\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, match every sequence of non-whitespace characters (&lt;code&gt;\S\+&lt;/code&gt;) followed by a space (&lt;code&gt;&lt;/code&gt;). Surround all but the space in a capturing group (&lt;code&gt;\(...\)&lt;/code&gt;). Each occurrence of this pattern in the line will be replaced with the captured characters (&lt;code&gt;\1&lt;/code&gt;) and then a line feed (&lt;code&gt;\r&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-02-05T13:17:49.047" LastActivityDate="2020-02-05T13:17:49.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22758" PostTypeId="2" ParentId="22748" CreationDate="2020-02-04T15:21:52.137" Score="1" Body="&lt;p&gt;If you're already using &lt;kbd&gt;k&lt;/kbd&gt;&lt;kbd&gt;j&lt;/kbd&gt; to get from insert mode to normal mode, there's no reason you can't do the same for visual mode. It shouldn't really interfere with movements, because you won't generally move the cursor up and then immediately down again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your existing insert mode mapping won't work in visual mode; you'll need a specific visual mode mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap kj &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-02-04T15:21:52.137" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22759" PostTypeId="2" ParentId="20704" CreationDate="2020-02-04T16:24:14.690" Score="2" Body="&lt;p&gt;Here's another method that no-one else has mentioned yet. First, note that, in your example, &quot;within the quotes&quot; is equivalent to &quot;after the first quote&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, you can run the following substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\v(&quot;.*)@&amp;lt;=_/ /g&#xA; '&amp;lt;,'&amp;gt;                   # In the visual selection&#xA;      s/                 # substitute&#xA;        \v               # using &quot;very magic&quot; (this just means we don't need&#xA;                         # as many backslash escapes)&#xA;                  _      # match any underscore&#xA;               @&amp;lt;=       # that follows&#xA;          (   )          # a group containing&#xA;           &quot;             # a quote&#xA;            .*           # followed by anything&#xA;                   / /   # replacing it with a space.&#xA;                      g  # globally within each line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An alternative version that uses a slightly simpler regular expression is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/&quot;.*\zs_/ /&#xA; '&amp;lt;,'&amp;gt;              # In the visual selection&#xA;      s/            # substitute&#xA;        &quot;           # a quote&#xA;         .*         # followed by anything&#xA;           \zs      # start the match (this means that anything before this&#xA;                    # won't be included in the replacement)&#xA;              _     # followed by an underscore&#xA;               / /  # with a space.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this will only replace the last underscore on the line, even if you use the &lt;code&gt;g&lt;/code&gt; flag (because the expression can only match the quote once). Therefore to replace the remaining underscores in the visual area, you can repeat the substitution many times by typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;9@:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will re-run the previous command-line command 9 times. You can increase the count if necessary.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-02-04T16:24:14.690" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22760" PostTypeId="1" AcceptedAnswerId="22765" CreationDate="2020-02-04T19:33:22.920" Score="3" ViewCount="188" Body="&lt;p&gt;When using the &quot;Add Childnode&quot;, &quot;Move Node&quot;, &quot;Copy Node&quot;, etc. options through the &quot;m&quot; menu, it opens up a text field to type in the name of the destination file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I cannot figure out how to edit this text using normal mode vim keybindings.  For example, using &lt;code&gt;b&lt;/code&gt; to go backwards, or making a visual selection.&lt;/p&gt;&#xA;" OwnerUserId="19428" LastActivityDate="2020-02-05T00:47:15.380" Title="Edit NERDTree text using normal mode vim keybindings" Tags="|key-bindings|normal-mode|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22761" PostTypeId="1" AcceptedAnswerId="22764" CreationDate="2020-02-04T20:21:24.850" Score="0" ViewCount="73" Body="&lt;p&gt;I'm often switching between files with a unix encoding and those with a dos encoding.  I find that when I start with a unix encoded file, and then open a dos encoded file, vim attempts to use the settings from the first file, and thus can't read the modelines in the latter file to get the proper encoding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course I get &lt;code&gt;:E518: Unknown option: ^M&lt;/code&gt;, because yeah, if it doesn't read the encoding properly it'll see a &lt;code&gt;^M&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know modelines have their [security] problems, but is there any way around this problem?  Right now I've been just re-opening the file (&lt;code&gt;:e&lt;/code&gt;) which loads the file properly and executes the modelines, but not having to do this all the time would be great.&lt;/p&gt;&#xA;" OwnerUserId="7658" LastActivityDate="2020-02-05T00:34:13.737" Title="modelines not executed when opening new file in new tab" Tags="|encoding|modeline|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22762" PostTypeId="1" AcceptedAnswerId="22767" CreationDate="2020-02-04T22:48:25.657" Score="1" ViewCount="203" Body="&lt;p&gt;I have an autocmd set up like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWritePost *.sh,*.zsh,.zshrc silent exec &quot;!ctags --language-force=sh %&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;:!!&amp;lt;cr&amp;gt;&lt;/code&gt; after saving a file, the command &lt;code&gt;!ctags --language-force=sh %&lt;/code&gt; is being run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This does not happen on vim 8.1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I prevent neovim from doing that ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First - My mistake, this happens also in vim 8.1 so it's not neovim specific. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second - I wish to clarify my workflow:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Edit a script &lt;/li&gt;&#xA;&lt;li&gt;Save it &lt;/li&gt;&#xA;&lt;li&gt;Run it with &lt;code&gt;:!./%&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Edit again. &lt;/li&gt;&#xA;&lt;li&gt;Run it again with &lt;code&gt;:!!&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;When I have the above autocmd in place, &lt;code&gt;#5&lt;/code&gt; breaks and the autocmd command replaces the last &lt;code&gt;:!./%&amp;lt;cr&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I wish to fix.&lt;/p&gt;&#xA;" OwnerUserId="26802" LastEditorUserId="26802" LastEditDate="2020-02-05T07:06:45.893" LastActivityDate="2020-02-05T14:00:43.307" Title="Preventing an autocmd from overriding last cmd - :&lt;bang&gt;&lt;bang&gt; (:!!)" Tags="|autocmd|repeated-commands|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22763" PostTypeId="2" ParentId="22762" CreationDate="2020-02-04T23:04:35.720" Score="1" Body="&lt;p&gt;Do note that vim's documentation says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:{range}![!]{filter} [!][arg]               *:range!*&#xA;            Filter {range} lines through the external program&#xA;            {filter}.  Vim replaces the optional bangs with the&#xA;            latest given command and appends the optional [arg].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;:!!&lt;/code&gt; should reuse the latest-given command. It's unclear which of the two behaviours (treating autcommands + silent + exec differently or not) is more &quot;correct,&quot; but at any rate you could file an issue with NeoVim to change the behaviour.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-02-05T14:00:43.307" LastActivityDate="2020-02-05T14:00:43.307" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22764" PostTypeId="2" ParentId="22761" CreationDate="2020-02-04T23:14:59.810" Score="3" Body="&lt;p&gt;I think you might be misunderstanding how the &lt;code&gt;'fileformats'&lt;/code&gt; (plural) setting is used. This setting is a global &lt;em&gt;list&lt;/em&gt; of file formats that Vim tries when opening any file in order to see which matches the format of the file. When it has detected the format, Vim sets the per-file &lt;code&gt;'fileformat'&lt;/code&gt; (singular) option for that individual file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are setting &lt;code&gt;'fileformats'&lt;/code&gt; to e.g. &lt;code&gt;dos&lt;/code&gt; in a modeline, you are instructing Vim to consider &lt;em&gt;all&lt;/em&gt; files to have dos line endings, regardless of the actual content of the file, so when you subsequently open a file with &lt;code&gt;unix&lt;/code&gt; endings, Vim is still forced to treat it as a &lt;code&gt;dos&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this &lt;em&gt;only&lt;/em&gt; affects files that you open later on, as when you opened the first file &lt;code&gt;'fileformats'&lt;/code&gt; was set to the default value of &lt;code&gt;unix,dos&lt;/code&gt; (or &lt;code&gt;dos,unix&lt;/code&gt;): Vim is correctly detecting the format of the first file, and &lt;em&gt;then&lt;/em&gt; reading the modeline which changes the value used for detection from that point on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also that when you open the second file, its modeline &lt;em&gt;is&lt;/em&gt; being executed (which you can see if you run the command &lt;code&gt;:verbose set ffs?&lt;/code&gt;), but, like before, the updated &lt;code&gt;'fileformats'&lt;/code&gt; doesn’t take effect until the &lt;em&gt;next&lt;/em&gt; time you read a file, which you are doing by manually invoking &lt;code&gt;:e&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you remove all the &lt;code&gt;ffs&lt;/code&gt; settings from your modelines, Vim will use the default &lt;code&gt;'fileformats'&lt;/code&gt; value of &lt;code&gt;unix,dos&lt;/code&gt; (or &lt;code&gt;dos,unix&lt;/code&gt;) and correctly set the per-file &lt;code&gt;'fileformat'&lt;/code&gt; based on the content of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, however, you are dead set on hard-coding your file formats into your modelines, you should at the very least change your &lt;code&gt;ffs&lt;/code&gt; modelines into &lt;code&gt;ff&lt;/code&gt; modelines. In this way, Vim will still detect the file format based on the content of the file on opening, but will then immediately override the file format (changing the line endings if necessary and marking the file as modified), so if you somehow accidentally change the &lt;code&gt;'fileformat'&lt;/code&gt; before writing (which you mention doing in a comment), this will be corrected the next time you open the file in Vim.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-02-05T00:34:13.737" LastActivityDate="2020-02-05T00:34:13.737" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22765" PostTypeId="2" ParentId="22760" CreationDate="2020-02-05T00:47:15.380" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;CTRL-F&lt;/code&gt; from that input box to open the command-line window, which lets you use Normal mode commands and even access history to reuse a name you previously typed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you read &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html?#c_CTRL-F&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help c_CTRL-F&lt;/code&gt;&lt;/a&gt; to see more details on how it works. Note that most of that help section talks about it in the context of the &lt;em&gt;command-line&lt;/em&gt; (where you can type Ex commands), but most of that is also available for &lt;code&gt;input()&lt;/code&gt;, which is what NERDTree uses to prompt for your input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some parts of it are not relevant in this context. For example, the &lt;code&gt;q:&lt;/code&gt; command to open the command-line window from Normal mode. You can only access it with &lt;code&gt;CTRL-F&lt;/code&gt; from the &lt;code&gt;input()&lt;/code&gt; prompt. Otherwise, most of the information in that section (about navigating and closing the command-line window) is relevant.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-05T00:47:15.380" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22766" PostTypeId="1" CreationDate="2020-02-05T11:11:38.760" Score="1" ViewCount="81" Body="&lt;p&gt;I know that previous yanks are kept in numbered yank registers, a preview available with &lt;code&gt;:registers&lt;/code&gt;. However this requires to keep a mental model which yank went where, with these numbers ever changing as yanks happen during editing. Additionally &lt;code&gt;:registers&lt;/code&gt; is not very helpful while in the progress of editing, it breaks the flow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way / a plugin which helps me &lt;em&gt;while&lt;/em&gt; in&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;normal mode when pre-prending a put with a register selection prefix &lt;code&gt;&quot;&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;in insert mode when pressing &lt;code&gt;^R&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;to preview the contents of the registers?&lt;/p&gt;&#xA;" OwnerUserId="11633" LastEditorUserId="1238" LastEditDate="2020-02-06T07:05:55.997" LastActivityDate="2020-02-06T07:05:55.997" Title="Preview previously yanked text before put" Tags="|cut-copy-paste|register|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22767" PostTypeId="2" ParentId="22762" CreationDate="2020-02-05T12:59:15.027" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;system()&lt;/code&gt; instead of &lt;code&gt;:!&lt;/code&gt;. As the question is specific to Neovim, it makes sense to pass command as a List (not supported in Vim!) to execute the application directly (w/o shell):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWritePost *.sh,*.zsh,.zshrc&#xA;    \ silent call system(['ctags', '--language-force=sh', fnameescape(expand('%'))])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also note that shell quoting rules won't apply then, but you still must escape (at least) spaces in file name.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-05T12:59:15.027" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22768" PostTypeId="1" CreationDate="2020-02-05T13:25:04.353" Score="4" ViewCount="316" Body="&lt;p&gt;After typing &lt;code&gt;tds&lt;/code&gt; I would like to see it replaced with the current time stamp in Markdown files, but eg. NOT while editing C source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following mostly works (stripped for brevity) except that the the abbreviation &lt;code&gt;tds&lt;/code&gt; is available in every buffer (mode) not just a markdown mode buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup TXT | au!&#xA;autocmd BufRead,BufNewFile *.asciidoc,*.md,README,TODO,CHANGELOG,NOTES,ABOUT&#xA;\ setlocal autoindent expandtab tabstop=8 softtabstop=2 shiftwidth=2 |&#xA;\ :iab &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; tds strftime(&quot;%F %b %T&quot;)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I define an abbreviation to be available in certain buffer modes only?&lt;/p&gt;&#xA;" OwnerUserId="11633" LastActivityDate="2020-02-06T09:04:40.173" Title="Abbreviations for local filtype buffers only" Tags="|autocmd|abbreviations|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22769" PostTypeId="2" ParentId="22768" CreationDate="2020-02-05T13:44:13.633" Score="1" Body="&lt;p&gt;What you want is to run the abbreviation command only for that buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType markdown iab &amp;lt;buffer&amp;gt; tds strftime(&quot;%F %b %T&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also made it into a &lt;code&gt;FileType&lt;/code&gt; event autocommand, instead of a &lt;code&gt;BufRead,BufNewFile&lt;/code&gt;. So it changes this stuff when filetype is set. I think it's more suitable, but in most cases won't make a lot of difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got most of this from &lt;a href=&quot;https://learnvimscriptthehardway.stevelosh.com/chapters/12.html#filetype-events&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learnvimscriptthehardway.stevelosh.com/chapters/12.html#filetype-events&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18498" LastEditorUserId="1238" LastEditDate="2020-02-06T09:04:40.173" LastActivityDate="2020-02-06T09:04:40.173" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22770" PostTypeId="2" ParentId="22768" CreationDate="2020-02-05T15:03:52.227" Score="3" Body="&lt;p&gt;When creating an autocommand, the &lt;code&gt;:au&lt;/code&gt; part interprets &lt;code&gt;|&lt;/code&gt; as a command separator. Just like for mappings, you need to escape it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au setlocal autoindent expandtab tabstop=8 softtabstop=2 shiftwidth=2 \| inoreabbrev &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; tds strftime(&quot;%F %b %T&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, use two autocommands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au setlocal autoindent expandtab tabstop=8 softtabstop=2 shiftwidth=2&#xA;au inoreabbrev &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; tds strftime(&quot;%F %b %T&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, my preferred solution, put it in &lt;code&gt;~/.vim/after/ftplugin/markdown.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal autoindent expandtab tabstop=8 softtabstop=2 shiftwidth=2&#xA;inoreabbrev &amp;lt;buffer&amp;gt; &amp;lt;expr&amp;gt; tds strftime(&quot;%F %b %T&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-02-05T15:03:52.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22771" PostTypeId="1" CreationDate="2020-02-05T15:44:56.507" Score="2" ViewCount="165" Body="&lt;p&gt;I'm looking to set up Vim for Latex editing and I came across this very simple and useful plugin,&#xA;&lt;a href=&quot;https://github.com/brennier/quicktex&quot; rel=&quot;nofollow noreferrer&quot;&gt;QuickTex&lt;/a&gt;. However, I doesn't seem to be compatible with &lt;a href=&quot;https://github.com/Townk/vim-autoclose&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-autoclose&lt;/a&gt; nor with &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;auto-pairs&lt;/a&gt; (which are plugins that automatically close matching brackets among other stuff). This has also been addressed by QuickTex's developer (see &lt;a href=&quot;https://github.com/brennier/quicktex/issues/9&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;), but no solution was found. This dates back to a year or two ago. Has anyone looked into it since? Does anyone have any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="26816" LastActivityDate="2020-02-05T15:44:56.507" Title="Vim - QuickTex is incompatible with Auto-Pairs or Auto-Close" Tags="|filetype-tex|plugin-auto-pairs|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22772" PostTypeId="2" ParentId="8378" CreationDate="2020-02-05T17:23:16.753" Score="0" Body="&lt;p&gt;the best solution is with the asyncrun plugin (requiring vim8+):&#xA;&lt;a href=&quot;https://github.com/skywind3000/asyncrun.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/skywind3000/asyncrun.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:AsyncRun -mode=term -pos=bottom -rows=15 -cols=40 -focus=0 pwd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will open a 15 rows terminal at bottom, run the linux command pwd and display the output there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;read its wiki for more info.&lt;/p&gt;&#xA;" OwnerUserId="26818" LastActivityDate="2020-02-05T17:23:16.753" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22773" PostTypeId="1" CreationDate="2020-02-05T17:37:24.273" Score="5" ViewCount="114" Body="&lt;p&gt;Is there a way to push out a vimrc change to all open windows and instances of vim without having to write/change any buffers or reopen vim? I'd like vim to be able to behave like a modern day IDE for this as I change my vimrc a lot and am trying to learn more vim scripting. &lt;/p&gt;&#xA;" OwnerUserId="16545" LastActivityDate="2020-03-07T14:13:27.473" Title="How push a vimrc change to all open windows without doing anything extra each time?" Tags="|vimrc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22774" PostTypeId="1" CreationDate="2020-02-05T18:11:06.033" Score="1" ViewCount="70" Body="&lt;p&gt;I often find myself patching projects that add a relatively big (23 lines out of a 37-line file? ) license-header to every. single. file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a plugin or straightforward way I can add a global pattern-match to all filetypes that will turn that entire comment into a fold, allowing me to &lt;code&gt;ggzc&lt;/code&gt; it out of view no matter what I'm editing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The complexity here is probably to do with various commenting-characters in different languages, although I know Vim already has some level of built-in support for that ...)&lt;/p&gt;&#xA;" OwnerUserId="6108" LastEditorUserId="1238" LastEditDate="2020-02-06T09:05:05.217" LastActivityDate="2020-02-06T14:54:55.127" Title="Automatically fold particular content, in any filetype" Tags="|folding|comments|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22775" PostTypeId="1" AcceptedAnswerId="22788" CreationDate="2020-02-05T18:46:48.750" Score="2" ViewCount="132" Body="&lt;p&gt;And, to get back again: how do I make the &lt;code&gt;l&lt;/code&gt; key go to next tab, if at end of file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd also like to make &lt;code&gt;hh&lt;/code&gt; go to previous buffer, and &lt;code&gt;ll&lt;/code&gt; go to next buffer. I know that'll add a delay to recognising the &lt;code&gt;h&lt;/code&gt;/&lt;code&gt;l&lt;/code&gt; keys, and slow down navigation, and I wonder is there a way to tell vim to&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Only check for &quot;hh&quot; at start of file, and only check for &quot;ll&quot; at end of file&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="182" LastActivityDate="2020-02-13T14:09:10.160" Title="How do I make the h key go to prev tab if at start of file?" Tags="|key-bindings|buffers|tabbed-user-interface|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22776" PostTypeId="2" ParentId="22773" CreationDate="2020-02-05T19:44:31.827" Score="1" Body="&lt;p&gt;&lt;em&gt;If&lt;/em&gt; your vimrc is reloadable, you can simply do &lt;code&gt;:source $MYVIMRC&lt;/code&gt; (I have that bound to a command &lt;code&gt;:Reload&lt;/code&gt;, which is bound to a keystroke &lt;code&gt;&amp;lt;leader&amp;gt;r&lt;/code&gt;). In practice, this means avoiding messing with local settings, using &lt;code&gt;augroups&lt;/code&gt;, and not unconditionally calling &lt;code&gt;colorscheme&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other tips:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you are editing an ftplugin or syntax file, you can usually do &lt;code&gt;:edit&lt;/code&gt; to force-reload those in a file you're in (but note that any mappings and settings that were there may stick around)&lt;/li&gt;&#xA;&lt;li&gt;If you are working on a file in the &lt;code&gt;plugin&lt;/code&gt; directory, you can use &lt;code&gt;:runtime&lt;/code&gt;—or, better, &lt;code&gt;:Runtime&lt;/code&gt; from tpope's scriptease plugin—to load the file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Causing all open instances of vim to do this would be tricky, though. If you could send signals to vim, it might be possible, but I couldn't find a way to make it respond to, e.g., &lt;code&gt;USR1&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-03-07T14:13:27.473" LastActivityDate="2020-03-07T14:13:27.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22777" PostTypeId="2" ParentId="22695" CreationDate="2020-02-05T19:57:44.163" Score="0" Body="&lt;p&gt;How about the following command? It doesn't implement your specifications precisely, but I think it should achieve your goals. (If not, let me know in what situations it doesn't work for you and I'll tweak it.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Quit() abort&#xA;  if winnr('$') &amp;gt; 1 || getline(1, '$') == [''] &amp;amp;&amp;amp; bufname('%') == ''&#xA;    quit&#xA;  else&#xA;    enew&#xA;  endif&#xA;endfunction&#xA;&#xA;command Quit call Quit()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-02-05T19:57:44.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22778" PostTypeId="2" ParentId="22773" CreationDate="2020-02-05T20:42:14.840" Score="1" Body="&lt;p&gt;I use the following &lt;code&gt;autocmd&lt;/code&gt; which reloads my &lt;code&gt;.vimrc&lt;/code&gt; whenever I've finished editing it and close it.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup reloadvimrc&#xA;  autocmd!&#xA;  &quot; auto source whenever vimrc fully closed&#xA;  &quot; nested because (as of vim 8.0 patch 1-823) needed to do ColorScheme cmds&#xA;  &quot; autocmd BufWinLeave $MYVIMRC nested source $MYVIMRC &#xA;  autocmd BufWinLeave $HOME/.vimrc nested source $HOME/.vimrc&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Further, I use the following mapping to make it easy to edit my &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; \V open ~/.vimrc&#xA;&quot; nmap &amp;lt;leader&amp;gt;V :-tabf $MYVIMRC&amp;lt;CR&amp;gt;&#xA;&quot; bc neovim&#xA;nnoremap &amp;lt;leader&amp;gt;V :-tabf $HOME/.vimrc&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;leader&amp;gt;V :-tabf $HOME/.vimrc&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In general, this is going to handle most of the cases you're worried about. My understanding is you can never truly accomplish a full, clean reload without restarting Vim because of items like &lt;code&gt;VimEnter&lt;/code&gt; and statefulness.&lt;/p&gt;&#xA;" OwnerUserId="13731" LastEditorUserId="13731" LastEditDate="2020-02-05T20:48:11.250" LastActivityDate="2020-02-05T20:48:11.250" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22779" PostTypeId="1" AcceptedAnswerId="22780" CreationDate="2020-02-06T02:54:15.767" Score="8" ViewCount="4287" Body="&lt;p&gt;Is there a way to make vim (or nvim) open all new splits vertically by default? There's &lt;code&gt;splitright&lt;/code&gt; to control which side vertical splits open on, but as far as I can tell there's no built in option to make splits vertical by default. Does anyone know of a workaround? I found one for the help command specifically, but I'm looking for something that will make &lt;em&gt;all&lt;/em&gt; splits vertical.&lt;/p&gt;&#xA;" OwnerUserId="6732" LastActivityDate="2022-09-07T13:13:06.137" Title="How to open files in vertical splits by default?" Tags="|split|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22780" PostTypeId="2" ParentId="22779" CreationDate="2020-02-06T03:45:07.913" Score="3" Body="&lt;p&gt;There's not really an option that does that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can accomplish that by using an &lt;code&gt;autocmd&lt;/code&gt;, more specifically catching the &lt;code&gt;WinNew&lt;/code&gt; event and moving the newly created window so that it's a vertical one rather than horizontal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd WinNew * wincmd L&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Don't forget to add this to an appropriate &lt;code&gt;augroup&lt;/code&gt; and clear the &lt;code&gt;augroup&lt;/code&gt; first, so if you reload your vimrc it won't duplicate the rules.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also that this isn't always the same as using &lt;code&gt;vertical&lt;/code&gt;, since &lt;code&gt;wincmd L&lt;/code&gt; will always make the new window the rightmost vertical &lt;em&gt;top-level&lt;/em&gt; window. It's also somewhat hard to override it (you can use the &lt;code&gt;:noautocmd&lt;/code&gt; modifier, but that will disable &lt;em&gt;all&lt;/em&gt; &lt;code&gt;autocmd&lt;/code&gt;s.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But perhaps this is close enough to what you're looking for.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-06T03:45:07.913" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22781" PostTypeId="2" ParentId="22779" CreationDate="2020-02-06T06:54:00.693" Score="8" Body="&lt;p&gt;&lt;code&gt;:split&lt;/code&gt;, &lt;code&gt;:new&lt;/code&gt; and such &lt;strong&gt;are&lt;/strong&gt; &quot;horizontal&quot; commands. But they all have &quot;vertical&quot; counterparts: &lt;code&gt;:vsplit&lt;/code&gt;, &lt;code&gt;:vnew&lt;/code&gt; etc. Take a habit to choose the right ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you're not allowed to redefine Vim builtin commands (except a few starting with a capital letter), but, if you wish, you can redefine key mappings, such as &lt;code&gt;nnoremap &amp;lt;c-w&amp;gt;n &amp;lt;c-w&amp;gt;v&lt;/code&gt; and so on.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-06T06:54:00.693" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22782" PostTypeId="2" ParentId="22779" CreationDate="2020-02-06T06:59:51.227" Score="1" Body="&lt;p&gt;There’s no option because there’s an specific command: &lt;code&gt;:vsplit&lt;/code&gt; (&lt;code&gt;:vs&lt;/code&gt;). It takes a filename as an argument, just as &lt;code&gt;:sp&lt;/code&gt; does. In fact the option you mentioned, &lt;code&gt;splitright&lt;/code&gt;,  affects the behaviour of &lt;code&gt;:vs&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="786" LastEditorUserId="1238" LastEditDate="2020-02-07T09:09:03.310" LastActivityDate="2020-02-07T09:09:03.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22783" PostTypeId="1" CreationDate="2020-02-06T13:08:09.567" Score="2" ViewCount="856" Body="&lt;p&gt;Inside of my editor (almost fresh install of neovim) there is no visual way to distinguish between a file that ends in a newline and a file that doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my command line (zsh default?) there is a nice visual indicator that shows stdout didn't end in a newline:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9iZRY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9iZRY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command output ends in a inverted-colors &lt;code&gt;%&lt;/code&gt; percent sign.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like it if (neo)vim showed me a similar symbol at the end of the file if there is no ending newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, a &lt;code&gt;%&lt;/code&gt; sign in the same style as the faded whitespaces in &lt;code&gt;set list&lt;/code&gt; or &lt;code&gt;^M&lt;/code&gt; characters&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Yhw90.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Yhw90.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I enable such a feature?&lt;/p&gt;&#xA;" OwnerUserId="9024" LastActivityDate="2020-02-06T14:15:17.200" Title="Visual indicator for a file that doesn't end in newline" Tags="|neovim|whitespace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22784" PostTypeId="2" ParentId="22783" CreationDate="2020-02-06T14:10:17.120" Score="3" Body="&lt;p&gt;When opening a file w/o the last newline, Neovim (just as Vim) prints the message with the text &quot;[noeol]&quot; (or &quot;[Incomplete last line]&quot; depending on &lt;code&gt;&amp;amp;shm&lt;/code&gt; option) included. Also, you can query it anytime with the command &lt;code&gt;:set eol?&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another point is that Vim/Neovim will fix the missing newline upon file write automatically, if &lt;code&gt;&amp;amp;fixeol&lt;/code&gt; is on (the default).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still want the visual indicator I suggest adding it to the status line instead. The exact instructions how to do this will differ depending on your status line plugin (or no plugin at all).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you insist on adding the indicator into the buffer, I should admit I can't think of an easy way to add an extra character, but you'll still be able to add &quot;a colored space&quot; instead. For instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup no_eol | au!&#xA;    autocmd BufWinEnter * execute '2match' &amp;amp;eol ? 'NONE' : 'Visual /\%$/'&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-06T14:10:17.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22785" PostTypeId="2" ParentId="22783" CreationDate="2020-02-06T14:15:17.200" Score="2" Body="&lt;p&gt;I don't know if it's possible to show it at the end of the line in question, but an alternative if you use a status line is to show that information in the status line. For example, &lt;code&gt;:se statusline=%{&amp;amp;eol?'':'[noeol]'}&lt;/code&gt; will show &lt;code&gt;[noeol]&lt;/code&gt; on the status line for the window showing the buffer with the &quot;endless&quot; line.&lt;/p&gt;&#xA;" OwnerUserId="26819" LastActivityDate="2020-02-06T14:15:17.200" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22786" PostTypeId="2" ParentId="22774" CreationDate="2020-02-06T14:54:55.127" Score="1" Body="&lt;p&gt;Ok, so I have a prototype of a license concealer (not fold) written, but I think because of the way &lt;code&gt;conceal&lt;/code&gt; and &lt;code&gt;cchar&lt;/code&gt; work, I can't get the lines to collapse into one. For that, folding may be better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick example, that doesn't work with comments (yet):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let text =&amp;lt;&amp;lt; trim END&#xA;MIT License&#xA;&#xA;Copyright (c) 2016 David Ben Knoble&#xA;&#xA;Permission is hereby granted, free of charge, to any person obtaining a copy&#xA;of this software and associated documentation files (the &quot;Software&quot;), to deal&#xA;in the Software without restriction, including without limitation the rights&#xA;to use, copy, modify, merge, publish, distribute, sublicense, and/or sell&#xA;copies of the Software, and to permit persons to whom the Software is&#xA;furnished to do so, subject to the following conditions:&#xA;&#xA;The above copyright notice and this permission notice shall be included in all&#xA;copies or substantial portions of the Software.&#xA;&#xA;THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR&#xA;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,&#xA;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE&#xA;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER&#xA;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,&#xA;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE&#xA;SOFTWARE.&#xA;END&#xA;&#xA;let text = text-&amp;gt;copy()-&amp;gt;filter({s -&amp;gt; !match(s, '\s*')})-&amp;gt;join('\%(\s\|\n\)*')&#xA;&#xA;exec printf('syn match license /%s/ conceal cchar=L', text-&amp;gt;escape('/'))&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-02-06T14:54:55.127" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22788" PostTypeId="2" ParentId="22775" CreationDate="2020-02-06T16:54:06.370" Score="3" Body="&lt;p&gt;Like Ben and statox, I wouldn't necessarily recommend this, but it is possible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function FirstPress(c1) abort&#xA;  let now = reltime()&#xA;  while reltimefloat(reltime(now)) &amp;lt; &amp;amp;timeoutlen / 1000.0&#xA;    &quot; See if the user has typed another character&#xA;    let c2 = getchar(0)&#xA;&#xA;    if c2 != 0&#xA;      &quot; The user typed something. Was it another h?&#xA;      if c2 == char2nr(a:c1)&#xA;        &quot; The user typed a double h, switch buffers&#xA;        if a:c1 == 'h'&#xA;          bprevious&#xA;        else&#xA;          bnext&#xA;        endif&#xA;      else&#xA;        &quot; The user typed something else. Switch tabs and replay what they typed&#xA;        call feedkeys((a:c1 == 'h' ? 'gT' : 'gt') . nr2char(c2), 't')&#xA;      endif&#xA;      return&#xA;    endif&#xA;  endwhile&#xA;&#xA;  &quot; The user didn't press anything. Switch Tabs&#xA;  if a:c1 == 'h'&#xA;    tabprevious&#xA;  else&#xA;    tabnext&#xA;  endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;expr&amp;gt; h (getpos('.')[1] == 1 &amp;amp;&amp;amp; getpos('.')[2] == 1) ? ':call FirstPress(&quot;h&quot;)&amp;lt;CR&amp;gt;' : 'h'&#xA;nnoremap &amp;lt;expr&amp;gt; l (getpos('.')[1] == line('$') &amp;amp;&amp;amp; (getpos('.')[2] == col('$') - 1 \|\| col('$') == 1)) ? ':call FirstPress(&quot;l&quot;)&amp;lt;CR&amp;gt;' : 'l'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works by mapping the single &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt; keypresses only, and then in that mapping, checking if the user presses the given key a second time, and acting accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also my answer to &lt;a href=&quot;https://vi.stackexchange.com/a/22617/343&quot;&gt;this recent similar, but slightly different question&lt;/a&gt; where the OP wanted to do the first mapping immediately and then perform the second as well if performed within &lt;code&gt;timeoutlen&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-02-13T14:09:10.160" LastActivityDate="2020-02-13T14:09:10.160" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22790" PostTypeId="2" ParentId="1983" CreationDate="2020-02-06T21:44:05.993" Score="2" Body="&lt;p&gt;My answer is very similar to Martin Tournoij (full credit to him).&#xA;This just makes it in a single-line command. When you run this, it will disable continuation of comment permanently:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo 'au FileType * set fo-=c fo-=r fo-=o' &amp;gt;&amp;gt; ~/.vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21892" LastEditorUserId="28" LastEditDate="2020-02-07T13:36:50.857" LastActivityDate="2020-02-07T13:36:50.857" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22791" PostTypeId="1" AcceptedAnswerId="22792" CreationDate="2020-02-07T07:43:39.637" Score="1" ViewCount="669" Body="&lt;p&gt;I have selected a JS block such as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function map(xs: string[], cb: Function) : string[] {&#xA;  const result: string[] = [];&#xA;  for(let i = 0; i++; i &amp;lt; xs.length) {&#xA;    result.push(cb(xs[i]));&#xA;  }&#xA;&#xA;  return result;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to go to the beginning of each line and comment out each line in the block (inserting &lt;code&gt;//&lt;/code&gt; at the beginning of each line). How can I do this in the fastest way possible using text objects? I am aware that this is also possible by doing column selection &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;V&lt;/kbd&gt;, &lt;code&gt;&amp;lt;number&amp;gt;&lt;/code&gt;&lt;kbd&gt;j&lt;/kbd&gt;, &lt;kbd&gt;I&lt;/kbd&gt;, &lt;code&gt;//&lt;/code&gt; and &lt;kbd&gt;ESC&lt;/kbd&gt; sequence. But I want to do this in the fastest way possible.&lt;/p&gt;&#xA;" OwnerUserId="23265" LastEditorUserId="1238" LastEditDate="2020-02-07T21:40:57.877" LastActivityDate="2020-02-07T21:40:57.877" Title="Inserting text at the beginning of all lines selected in visual line mode" Tags="|visual-block|custom-text-object|" AnswerCount="2" CommentCount="0" ClosedDate="2020-02-10T10:51:34.930" ContentLicense="CC BY-SA 4.0" />
  <row Id="22792" PostTypeId="2" ParentId="22791" CreationDate="2020-02-07T08:01:50.873" Score="3" Body="&lt;p&gt;You can try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vip&amp;lt;Ctrl-v&amp;gt;I//&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;vip&lt;/code&gt; select paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Ctrl-v&amp;gt;&lt;/code&gt; make selection blockwise&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;I//&lt;/code&gt; insert &lt;code&gt;//&lt;/code&gt; into begining of a selection block&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0FD4H.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0FD4H.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I would suggest to use vim-commentary plugin from Tim Pope where it would be simple &lt;code&gt;gcip&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-02-07T08:17:59.527" LastActivityDate="2020-02-07T08:17:59.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22793" PostTypeId="2" ParentId="22791" CreationDate="2020-02-07T11:36:13.937" Score="0" Body="&lt;p&gt;I think the fastest would be using the commentary plugin as Maxim Kim mentioned: just type &lt;code&gt;gc&lt;/code&gt; since you already have the lines selected. But if you want another option using vanilla vim, you could try using regex substitution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s&amp;amp;^&amp;amp;//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use other characters instead of &lt;code&gt;&amp;amp;&lt;/code&gt;; I used that one because it's next to &lt;code&gt;^&lt;/code&gt; on my keyboard. I use it instead of the standard &lt;code&gt;/&lt;/code&gt; to avoid having to escape the slashes in the substitution, as in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/^/\/\/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that also works.&lt;/p&gt;&#xA;" OwnerUserId="26819" LastEditorUserId="26819" LastEditDate="2020-02-07T11:45:50.840" LastActivityDate="2020-02-07T11:45:50.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22794" PostTypeId="1" AcceptedAnswerId="22837" CreationDate="2020-02-07T11:46:36.023" Score="3" ViewCount="179" Body="&lt;p&gt;I like running gVim in a single instance, i.e. a single gui window with separate tabs for each file I'm editing.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also run a linux desktop environment that has multiple desktop workspaces.  E.g. GNOME, KDE or Xfce.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to have a single instance of gVim per desktop workspace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently alias &lt;code&gt;gvim&lt;/code&gt; to &lt;code&gt;gvim --remote-tab-silent&lt;/code&gt;.  Unfortunately this create a single instance (gui window) which has tabs for all of the files open in gVim from all of my workspaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As each workspace I use is for a different git branch it's easy to get confused as to which branch a file I'm editing is in from.&lt;/p&gt;&#xA;" OwnerUserId="26817" LastActivityDate="2020-02-11T15:08:54.200" Title="How do I run gVim in a single instance per desktop workspace on linux?" Tags="|gvim|tabbed-user-interface|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22795" PostTypeId="2" ParentId="22779" CreationDate="2020-02-07T12:35:55.687" Score="4" Body="&lt;p&gt;Unfortunately, this is not possible and not all commands that open windows (e.g. &lt;code&gt;:sp&lt;/code&gt;), have vertical counterparts (e.g. &lt;code&gt;:vsp&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a couple of years ago, I made the &lt;a href=&quot;https://github.com/chrisbra/vim-mq-patches/blob/master/verstplit&quot; rel=&quot;nofollow noreferrer&quot;&gt;splitvertical&lt;/a&gt; patch, that introduces the 'splitvertical'  option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, it has never been included.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2020-02-07T12:35:55.687" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22796" PostTypeId="2" ParentId="22775" CreationDate="2020-02-07T14:16:35.527" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;how do I make the l key go to next tab, if at end of file&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For this part make a function which checks that the following two conditions are satisfied: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The value of &lt;code&gt;line(&quot;.&quot;)&lt;/code&gt;, which is the current line number, and &lt;code&gt;line(&quot;$&quot;)&lt;/code&gt;, which is the number of all lines in a file, match&lt;/li&gt;&#xA;&lt;li&gt;The current column value, obtained with &lt;code&gt;col(&quot;.&quot;)&lt;/code&gt;, and the length of the current line, obtained with &lt;code&gt;strlen(getline(&quot;.&quot;))&lt;/code&gt;, match.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This means that you're on the last line, on the last column (i.e. the last character in the file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this pushes you in the right direction.&lt;/p&gt;&#xA;" OwnerUserId="18912" LastActivityDate="2020-02-07T14:16:35.527" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22799" PostTypeId="2" ParentId="20512" CreationDate="2020-02-07T15:32:03.047" Score="1" Body="&lt;p&gt;On GNOME terminal use shift + mouseleft + drag to select. Ctrl + Shift + C to copy. Ctrl + Shift + V to Paste.&lt;/p&gt;&#xA;" OwnerUserId="23663" LastActivityDate="2020-02-07T15:32:03.047" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22800" PostTypeId="1" AcceptedAnswerId="22801" CreationDate="2020-02-07T16:55:00.443" Score="2" ViewCount="535" Body="&lt;p&gt;I am following &lt;a href=&quot;https://realpython.com/vim-and-python-a-match-made-in-heaven/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this guide from realpython.com&lt;/a&gt; to fine tune vim for Python development. It suggests the following section in the &lt;code&gt;.vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.py&#xA;    \ set tabstop=4&#xA;    \ set softtabstop=4&#xA;    \ set shiftwidth=4&#xA;    \ set textwidth=79&#xA;    \ set expandtab&#xA;    \ set autoindent&#xA;    \ set fileformat=unix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This produces the following error when I open a Python file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing BufNewFile Auto commands for &quot;*.py&quot;:&#xA;E518: Unknown option: set &#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As it turns out, the error goes away if the &lt;code&gt;softtabstop&lt;/code&gt; instruction is commented out. How should it be set up?&lt;/p&gt;&#xA;" OwnerUserId="26408" LastEditorUserId="1238" LastEditDate="2020-02-08T07:42:39.570" LastActivityDate="2020-02-08T07:42:39.570" Title="Setting softtabstop for Python" Tags="|softtabstop|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22801" PostTypeId="2" ParentId="22800" CreationDate="2020-02-07T17:49:10.423" Score="4" Body="&lt;p&gt;Backslash is a line-continuation in Vim script. Hence your code is interpreted as &lt;code&gt;set tabstop=4 set softtabstop=4 ...&lt;/code&gt; and so on. And, obviously, it's a syntax error. Your options are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Merge options into a single &quot;set&quot; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4 softtabstop=4 shiftwidth=4 ...&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &quot;bar&quot; to mark command's end:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tabstop=4 | set softtabstop=4 | set shiftwidth=4 | ...&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Split into several autocommands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufNewFile,BufRead *.py set tabstop=4&#xA;au BufNewFile,BufRead *.py set softtabstop=4&#xA;au BufNewFile,BufRead *.py set shiftwidth=4&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;However, in this case it's even better to create a dedicated script for standard &quot;ftplugin&quot; to process. The file name should be &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt; (or &lt;code&gt;$HOME/vimfiles/after/ftplugin/python.vim&lt;/code&gt; under Windows). The content is simply a number of &quot;set&quot; commands. You don't have to trap an autocommand yourself as the plugin will do this for you. You have only to enable the plugin with &lt;code&gt;filetype plugin on&lt;/code&gt; which is probably switched on anyway.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-07T17:49:10.423" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22802" PostTypeId="1" AcceptedAnswerId="22803" CreationDate="2020-02-07T18:46:44.497" Score="1" ViewCount="114" Body="&lt;p&gt;I want to replace the lines :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;https://www.dailymotion.com/video/whatever_1 # The Serie - S2 E4 - Grin and Bear It&#xA;https://www.dailymotion.com/video/whatever_2 # The Serie - S2 E3 - Betty's Wait Problem&#xA;https://www.dailymotion.com/video/whatever_3 # The Serie - S1 E21 - Secretaries Day&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by these lines :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;https://www.dailymotion.com/video/whatever_1 # The Serie - S2 E4 - whatever_79&#xA;https://www.dailymotion.com/video/whatever_2 # The Serie - S2 E3 - whatever_78&#xA;https://www.dailymotion.com/video/whatever_3 # The Serie - S1 E21 - whatever_77&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I tried different combinations of the following vim command :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i=79 | g/^http/s/\(S[0-9]\+ E[0-9]\+\).*$/\1 - whatever_\=i/ | let i=i-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but none has worked and I got this instead :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;https://www.dailymotion.com/video/whatever_1 # The Serie - S2 E4 - whatever_=i&#xA;https://www.dailymotion.com/video/whatever_2 # The Serie - S2 E3 - whatever_=i&#xA;https://www.dailymotion.com/video/whatever_3 # The Serie - S1 E21 - whatever_=i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you help me ?&lt;/p&gt;&#xA;" OwnerUserId="14229" LastEditorUserId="14229" LastEditDate="2020-02-07T19:37:40.007" LastActivityDate="2020-02-08T00:21:15.983" Title="Vim decremental replace not working" Tags="|substitute|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22803" PostTypeId="2" ParentId="22802" CreationDate="2020-02-07T20:40:23.977" Score="2" Body="&lt;p&gt;If you want to use &lt;code&gt;\=&lt;/code&gt;, it needs to be at the start of the replacement, and the whole replacement expression becomes an expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;code&gt;submatch()&lt;/code&gt; function to access your backreferences, since &lt;code&gt;\1&lt;/code&gt; will not work from a &lt;code&gt;\=&lt;/code&gt; replacement expression.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After you do that, all you need is &lt;code&gt;&quot; - whatever_&quot;.i&lt;/code&gt; to produce the replacement using a string concatenation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i=79 | g/^http/s/\(S[0-9]\+ E[0-9]\+\).*$/\=submatch(1).&quot; - whatever_&quot;.i/ | let i=i-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's easier to do that if you don't need the backreference. In this particular case, you can easily avoid the backreference by using &lt;code&gt;\zs&lt;/code&gt;, which marks the start of the match, the part that actually gets replaced:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let i=79 | g/^http/s/S[0-9]\+ E[0-9]\+\zs.*$/\=&quot; - whatever_&quot;.i/ | let i=i-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-02-08T00:21:15.983" LastActivityDate="2020-02-08T00:21:15.983" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22804" PostTypeId="2" ParentId="4050" CreationDate="2020-02-08T01:40:07.517" Score="0" Body="&lt;p&gt;There is no option but to write a dedicated function for this.&#xA;I wrote a function that searches the string you want and only stops if either:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;it runs out of matches &lt;/li&gt;&#xA;&lt;li&gt;there is  a match which is inside math environment(it will stop on the match)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You just call it with the string you want to search.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Finmath(nextstr)&#xA;    while 1&#xA;        if search(a:nextstr)==0&#xA;            break&#xA;        endif&#xA;        if searchpairpos('\(', '','\)','n')!=[0,0]&#xA;            break&#xA;        endif&#xA;        if searchpairpos('\[', '','\]','n')!=[0,0]&#xA;            break&#xA;        endif&#xA;        let a = getcurpos() &#xA;        if count(strpart(getline('.'),0,a[2]),'$')%2==1&#xA;            break&#xA;        endif &#xA;    endwhile &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I intend to write a similar function for GrammerousCheck that only stops on grammar errors outside math. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2020-02-08T01:40:07.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22805" PostTypeId="1" CreationDate="2020-02-08T01:57:54.273" Score="1" ViewCount="185" Body="&lt;p&gt;I use Linux and usually run Vim in a terminal. Lately, I've been using Vim's clientserver functionality to interact with Vim remotely. I'm wondering if there's a way to focus the terminal/Vim window when interacting with Vim in this way. For example, in one terminal I run Vim as:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;$ vim --servername VIM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in another terminal I call the following command to open a text file in the first terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;$ vim --remote /path/to/file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This command is successful, but doesn't focus the first terminal. Note that I tested this in Arch Linux with both Gnome and i3 window manager, and with both &lt;code&gt;gnome-terminal&lt;/code&gt; and &lt;code&gt;xterm&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I've tried using Vim's &lt;code&gt;foreground()&lt;/code&gt; command via &lt;code&gt;vim --remote-send ':call foreground()&amp;lt;CR&amp;gt;'&lt;/code&gt;, as well as the &lt;code&gt;vim -f&lt;/code&gt; option. These commands didn't work for me, and based on Vim's documentation, I don't believe they should when Vim is run in a terminal. But please correct me if I'm wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, I know that I could probably accomplish my goal by combining the Vim remote commands with a shell command that interacts with windows (e.g. &lt;code&gt;xdotool&lt;/code&gt; or &lt;code&gt;wmctrl&lt;/code&gt;). But I'm wondering if there's a better (and preferably native) way to do this.&lt;/p&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2020-02-11T10:18:17.533" Title="how to remotely focus Vim through the clientserver" Tags="|clientserver|window-management|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22806" PostTypeId="2" ParentId="5651" CreationDate="2020-02-08T14:33:54.653" Score="5" Body="&lt;p&gt;I understand the question differently: when answering &quot;No&quot; to the &quot;Do you want me to try downloading it [the spell file]?&quot; question, the option to download does not present itself again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got around it by deleting &lt;code&gt;~/.viminfo&lt;/code&gt;—surely this isn't the best way, but it does answer the question (to my interpretation, at least).&lt;/p&gt;&#xA;" OwnerUserId="26863" LastEditorUserId="10604" LastEditDate="2020-02-08T19:47:20.050" LastActivityDate="2020-02-08T19:47:20.050" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22808" PostTypeId="1" AcceptedAnswerId="22809" CreationDate="2020-02-08T17:00:33.940" Score="1" ViewCount="209" Body="&lt;p&gt;I have written a vimscript function. I want to use &lt;code&gt;autocmd&lt;/code&gt; to call this function when a character is deleted with the &lt;code&gt;x&lt;/code&gt; key. But autocmd requires an event name. Which event is triggered when a character is deleted with the &lt;code&gt;x&lt;/code&gt; key?&lt;/p&gt;&#xA;" OwnerUserId="10077" LastActivityDate="2020-02-08T17:55:09.733" Title="Which event is triggered by deleting a character with the x key?" Tags="|vimscript|autocmd|microsoft-windows|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22809" PostTypeId="2" ParentId="22808" CreationDate="2020-02-08T17:55:09.733" Score="2" Body="&lt;p&gt;There is no such event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is TextChanged event that is generally called when text was changed in normal mode (including &lt;code&gt;x&lt;/code&gt; I guess). I am not sure this what you need though...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why not remap &lt;code&gt;x&lt;/code&gt; key to delete a character and call your function?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! MyFunc()&#xA;    echo printf(&quot;You have just deleted '%s'&quot;, getreg(v:register))&#xA;endfunc&#xA;noremap x x:call MyFunc()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-02-08T17:55:09.733" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22811" PostTypeId="2" ParentId="6019" CreationDate="2020-02-09T08:09:57.307" Score="4" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1TZt6.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1TZt6.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;I made a Vim plugin which is to jump to Vim script's last error or load errors to current loclist. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/rbtnn/vim-vimscript_lasterror&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/rbtnn/vim-vimscript_lasterror&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like, you can try it.&lt;/p&gt;&#xA;" OwnerUserId="26869" LastEditorUserId="26871" LastEditDate="2020-02-09T19:17:40.937" LastActivityDate="2020-02-09T19:17:40.937" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22812" PostTypeId="1" AcceptedAnswerId="22817" CreationDate="2020-02-09T09:13:44.343" Score="5" ViewCount="581" Body="&lt;p&gt;When editing a buffer and initiating a search-and-replace, I use &lt;code&gt;:s/oldword/newword/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the word 'oldword' will be in the buffer I am editing, and sometimes it is a long word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be helpful if I was able to auto-complete somehow the words 'oldword' and 'newword' from the contents of the buffer to save some typing, say by typing just &lt;code&gt;:s/ol&lt;/code&gt; then TAB to cycle through matches in the buffer, and then similarly for 'newword'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is something like this possible without plugin ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, is there a way of getting completion suggestions from the current buffer to assemble the &lt;code&gt;:&lt;/code&gt; command line ?&lt;/p&gt;&#xA;" OwnerUserId="21293" LastEditorUserId="205" LastEditDate="2020-02-10T05:54:38.753" LastActivityDate="2020-02-10T05:54:38.753" Title="How do I use the contents of the buffer to save some typing/autocomplete on the command line?" Tags="|command-line|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22813" PostTypeId="1" CreationDate="2020-02-09T09:14:15.233" Score="3" ViewCount="143" Body="&lt;p&gt;I usually have one tab containing the code I am working on, and another containing vimwiki. I mostly use neovim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the code I prefer the working directory sticking to the project root.  For vimwiki I have set in the &lt;code&gt;ftplugin/vimwiki.vim&lt;/code&gt;: &lt;code&gt;lcd %:p:h&lt;/code&gt;.&#xA;I switch the tabs with &lt;code&gt;gt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a few edits - not immediately - in both tabs I notice the path of the &quot;code&quot; tab has been changed to the path of my current vimwiki page. Very annoying as the file name completion no longer gives me the project files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe I'm doing things wrong - but isn't it the main point of the &lt;code&gt;:lcd&lt;/code&gt; command that it will leave other tabs and windows alone?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any tips what could be going wrong? Or how I might debug this?&lt;/p&gt;&#xA;" OwnerUserId="1120" LastEditorUserId="1238" LastEditDate="2020-02-09T22:52:05.557" LastActivityDate="2020-02-09T22:52:05.557" Title="How to keep lcd from affecting other windows?" Tags="|tabbed-user-interface|path|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22814" PostTypeId="1" CreationDate="2020-02-09T10:56:47.947" Score="0" ViewCount="49" Body="&lt;p&gt;I Have this function :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test1()&#xA;     let myWord = &quot;accroche-coeur&quot;&#xA;     let cont1 = &quot;-&quot;&#xA;     if match(myWord,cont1)&amp;gt;=0  &quot; if myWord contains cont1&#xA;         echo &quot;Ok&quot;&#xA;     else&#xA;         echo &quot;No&quot;&#xA;     endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I vould like make a function like that :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test2()&#xA;   let cont1 = &quot;irr&quot;&#xA;   let myRep = &quot;YesOrNo&quot;&#xA;   silent! exe  '1,1 s/[A-Z-a-z-à-ù]*[A-Z-a-z-à-ù]/\=execute(if (search,cont1)&amp;gt;=0 then myRep=&quot;Yes&quot; endif)'&#xA;   echo myRep&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could you tell me please what I have to insert between the parenthesis of execute( ... ) for that returns &quot;Yes&quot; if my text contains cont1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I have this text :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Books are the m&lt;strong&gt;irr&lt;/strong&gt;or of the soul.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This function has to return &quot;Yes&quot;&lt;/p&gt;&#xA;" OwnerUserId="26872" LastActivityDate="2020-02-09T10:56:47.947" Title="Match (Search, Letters)" Tags="|search|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22815" PostTypeId="1" AcceptedAnswerId="22816" CreationDate="2020-02-09T11:34:44.270" Score="0" ViewCount="492" Body="&lt;p&gt;I am using the code &lt;code&gt;getline(&quot;.&quot;)[col(&quot;.&quot;)-1]&lt;/code&gt; to get the character under the cursor. How can I check if the character under the cursor is a tab ?&lt;/p&gt;&#xA;" OwnerUserId="10077" LastActivityDate="2020-02-09T12:11:48.033" Title="How to check if the character under the cursor is a tab?" Tags="|vimscript|tab-characters|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22816" PostTypeId="2" ParentId="22815" CreationDate="2020-02-09T12:11:48.033" Score="5" Body="&lt;p&gt;Just compare the character you got with a tab, which can be represented with the &lt;code&gt;\t&lt;/code&gt; escape sequence. That is,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getline(&quot;.&quot;)[col(&quot;.&quot;)-1] == &quot;\t&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The expression will return 1 if the character is tab, 0 if not.&lt;/p&gt;&#xA;" OwnerUserId="26819" LastActivityDate="2020-02-09T12:11:48.033" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22817" PostTypeId="2" ParentId="22812" CreationDate="2020-02-09T12:26:56.393" Score="4" Body="&lt;p&gt;I don't know if there's a way to do exactly what you are asking, but there are two alternatives I think are close enough:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If you open a command-line window with &lt;code&gt;q:&lt;/code&gt; (from normal mode) or &lt;code&gt;CTRL-F&lt;/code&gt; (from command-line mode), you can edit your commands with the full power of Vim. This includes using &lt;code&gt;CTRL-P&lt;/code&gt; for autocompletion, which depending on the value of your &lt;code&gt;'complete'&lt;/code&gt; setting, can look for matches in your current buffer (include &lt;code&gt;.&lt;/code&gt; in the value of the setting for that).&lt;/li&gt;&#xA;&lt;li&gt;Not autocompletion, but if you have the long word under the cursor while editing the buffer, you could yank it first, and then paste it into the command line with &lt;code&gt;CTRL-R {register}&lt;/code&gt; when editing the command line.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="26819" LastEditorUserId="26819" LastEditDate="2020-02-09T12:44:40.013" LastActivityDate="2020-02-09T12:44:40.013" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22818" PostTypeId="1" AcceptedAnswerId="22843" CreationDate="2020-02-09T12:43:35.453" Score="0" ViewCount="129" Body="&lt;p&gt;I have written a vimscript function to toggle comments on/off on lines selected in visual mode. The function successfully &lt;strong&gt;adds&lt;/strong&gt; comments but freezes when I try to uncomment selected lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Function to automatically toggle comments (on visual selection)&#xA;function! ToggleComments()&#xA;    let cFamilyTypes = ['c', 'cpp', 'cc', 'cxx', 'cs', 'java']&#xA;    let commentString = &quot;&quot;&#xA;    let commentChar = ''&#xA;    let counter = 0 &quot; Indicates if the line was commented, so don't comment again&#xA;    if index(cFamilyTypes, &amp;amp;filetype) != -1&#xA;        let commentString = &quot;//&quot;&#xA;        let commentChar = '/'&#xA;    endif&#xA;    if &amp;amp;filetype == 'vim'&#xA;        let commentString = &quot;\&quot;&quot;&#xA;        let commentChar = '&quot;'&#xA;    endif&#xA;&#xA;    &quot; Check if comments exist at the beginning of the current line and&#xA;    &quot; delete them&#xA;    call feedkeys(&quot;0&quot;)&#xA;    while getline(&quot;.&quot;)[col(&quot;.&quot;)-1] == commentChar || getline(&quot;.&quot;)[col(&quot;.&quot;)-1] == ' '  || getline(&quot;.&quot;)[col(&quot;.&quot;)-1] == '\t'     &#xA;        if getline(&quot;.&quot;)[col(&quot;.&quot;)-1] == commentChar&#xA;            call feedkeys(&quot;x&quot;)&#xA;            let counter += 1&#xA;            continue&#xA;        endif&#xA;        call feedkeys(&quot;l&quot;)&#xA;    endwhile&#xA;    &quot; Code to check and delete existing comments ends here&#xA;&#xA;    &quot; If counter was not incremented, the line is uncommented. So add&#xA;    &quot; comments&#xA;    if counter == 0&#xA;        call feedkeys(&quot;0&quot;)&#xA;        execute &quot;normal! i&quot; . commentString . &quot;\&amp;lt;ESC&amp;gt;&quot;&#xA;        let counter = 0&#xA;    endif&#xA;    &quot; Code to add comments ends here&#xA;&#xA;endfunction&#xA;&quot; Function to automatically toggle comments ends here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I call the function by &lt;code&gt;:'&amp;lt;,'&amp;gt;call ToggleComments()&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am a beginner to vimscript so can someone tell me what I am doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="10077" LastActivityDate="2020-02-11T23:43:50.373" Title="Deleting comments from the beginning of selected lines" Tags="|vimrc|vimscript|visual-mode|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22819" PostTypeId="2" ParentId="22812" CreationDate="2020-02-09T13:08:58.283" Score="3" Body="&lt;p&gt;Ideas:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;yank the word and paste it while typing (&lt;code&gt;&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;type the command in the buffer and use &lt;code&gt;:exec getline('.')&lt;/code&gt; to run it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I prefer the &lt;code&gt;q:&lt;/code&gt;/&lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; from the other answer though. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-02-09T13:08:58.283" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22820" PostTypeId="2" ParentId="11526" CreationDate="2020-02-09T13:09:36.077" Score="3" Body="&lt;p&gt;If, like me, despite having compiled &lt;code&gt;vim&lt;/code&gt; with &lt;code&gt;python3&lt;/code&gt; support, you get an error that &lt;code&gt;python3&lt;/code&gt; support is missing, make sure it loads the correct &lt;code&gt;dll&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Check feature exists&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;+python3/dyn&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Python3 is missing during runtime&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo has('python3')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Incorrect DDL used&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set pythondll?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;libpython2.7.so.1.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.reddit.com/r/vim/comments/7fyvgz/easiest_way_to_have_vim_with_python3_support_from/dqfh9gt?utm_source=share&amp;amp;utm_medium=web2x&quot; rel=&quot;nofollow noreferrer&quot;&gt;This comment&lt;/a&gt; deserves the credit for suggesting this option.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Solution&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Adding &lt;code&gt;set pythondll=libpython3.8.so&lt;/code&gt; to .vimrc solved the issue by telling vim to use that &lt;code&gt;dll&lt;/code&gt; when it needs &lt;code&gt;python3&lt;/code&gt;. Vim's &lt;code&gt;:help python-dynamic&lt;/code&gt; explains it&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The 'pythondll' or 'pythonthreedll' option can be used to specify the Python       &#xA;shared library file instead of DYNAMIC_PYTHON_DLL or DYNAMIC_PYTHON3_DLL file      &#xA;what were specified at compile time.  The version of the shared library must       &#xA;match the Python 2.x or Python 3 version Vim was compiled with.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I couldn't find an explicit way to query what value &lt;code&gt;DYNAMIC_PYTHON3_DLL&lt;/code&gt; was at compile time. At the time of this writing, I assumed it's the system's version.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;What is python3-dynamic (python3/dyn)&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;For those curious, this is included in &lt;code&gt;:help python-dynamic&lt;/code&gt;, too.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;On MS-Windows and Unix the Python library can be loaded dynamically.  The :version output then includes +python/dyn or +python3/dyn.                      &#xA;&#xA;This means that Vim will search for the Python DLL or shared library file only  &#xA;when needed.  When you don't use the Python interface you don't need it, thus   &#xA;you can use Vim without this file.  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26873" LastActivityDate="2020-02-09T13:09:36.077" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22821" PostTypeId="2" ParentId="22812" CreationDate="2020-02-09T17:29:35.380" Score="4" Body="&lt;p&gt;With &lt;code&gt;set incsearch&lt;/code&gt; you can complete  using &lt;code&gt;ctrl-L&lt;/code&gt; in &lt;code&gt;/&lt;/code&gt; and &lt;code&gt;:s/&lt;/code&gt; command lines (see &lt;code&gt;:help /_CTRL-L&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2020-02-09T17:29:35.380" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22822" PostTypeId="2" ParentId="16582" CreationDate="2020-02-09T18:13:48.983" Score="1" Body="&lt;p&gt;I had issues setting up &lt;code&gt;nvim&lt;/code&gt; as &lt;code&gt;MANPAGER&lt;/code&gt; because the following error appeared every time I tried to open a &lt;code&gt;man&lt;/code&gt; page (such as &lt;code&gt;man man&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fuse: mount failed: Permission denied&#xA;&#xA;Cannot mount AppImage, please check your FUSE setup.&#xA;You might still be able to extract the contents of this AppImage&#xA;if you run it with the --appimage-extract option.&#xA;See https://github.com/AppImage/AppImageKit/wiki/FUSE&#xA;for more information&#xA;open dir error: No such file or directory&#xA;man: command exited with status 127: sed -e '/^[[:space:]]*$/{ N; /^[[:space:]]*\n[[:space:]]*$/D; }' | LESS=-ix8RmPm Manual page man(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page man(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$ MAN_PN=man(1) nvim -c set ft=man - &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Looking for alternatives, which I could not find, I ended up with the following &lt;code&gt;zsh&lt;/code&gt; function and alias:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function my_man {&#xA;    $EDITOR +&quot;Man $1|on&quot;&#xA;}&#xA;alias man=&quot;my_man&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to activate a &lt;code&gt;vim&lt;/code&gt; plugin that comes shipped with &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;nvim&lt;/code&gt; by adding the following line to your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime! ftplugin/man.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19268" LastActivityDate="2020-02-09T18:13:48.983" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22824" PostTypeId="1" AcceptedAnswerId="22825" CreationDate="2020-02-10T00:39:27.960" Score="3" ViewCount="582" Body="&lt;p&gt;When I'm working in vim and someone comes over to help/write some code into the editor and they don't know vim, they get totally stuck and  we have to switch to a different editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know if there is a plugin that turns off modes/vim specific things, so that they can edit like in a basic graphical editor?&lt;/p&gt;&#xA;" OwnerUserId="18632" LastActivityDate="2020-02-10T01:31:42.327" Title="Non-vim user mode" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22825" PostTypeId="2" ParentId="22824" CreationDate="2020-02-10T01:31:42.327" Score="6" Body="&lt;p&gt;You have a few options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start vim with &lt;code&gt;evim&lt;/code&gt; (or &lt;code&gt;vim -y&lt;/code&gt;). This puts vim in &quot;easy&quot; mode: it sets &lt;code&gt;'insertmode'&lt;/code&gt; and behaves like a point-and-click editor (from the docs).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:source $VIMRUNTIME/evim.vim&lt;/code&gt;—basically the same. Note that it sets up mappings (&lt;code&gt;:help evim-keys&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You might be able to find or write a script to undo this whole thing, but it may also be easier to quit and restart after doing this. Sessions (such as via tpope/Obsession) make this less painful than it sounds.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-02-10T01:31:42.327" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22827" PostTypeId="1" AcceptedAnswerId="22831" CreationDate="2020-02-10T16:30:39.807" Score="8" ViewCount="1841" Body="&lt;p&gt;I search a way to paste/merge 2 block of text&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apple&#xA;pear&#xA;banana&#xA;&#xA;tomato&#xA;beans&#xA;potato&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;like this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apple tomato&#xA;pear beans&#xA;banana potato&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The lines have different length but same number of lines of course.&#xA;I don't want different number of spaces like in visual block paste, and I search a way without using macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's something we can easily do in sublime text, but I can't find an easy way to do it in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thx&lt;/p&gt;&#xA;" OwnerUserId="26885" LastActivityDate="2020-02-15T01:57:48.983" Title="Paste append multiple lines" Tags="|multiple-lines|paste|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22828" PostTypeId="1" CreationDate="2020-02-10T20:09:17.403" Score="1" ViewCount="764" Body="&lt;p&gt;Is there any way to do this for multiple files in NERDTree? Something similar along the lines of vifm. From the &lt;strong&gt;m&lt;/strong&gt; menu I see that it is only possible for one file at a time.&lt;/p&gt;&#xA;" OwnerUserId="25275" LastActivityDate="2020-02-10T20:09:17.403" Title="How to do operations like copy, rename, delete on multiple files in NERDTree vim?" Tags="|multiple-files|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22829" PostTypeId="2" ParentId="22827" CreationDate="2020-02-11T00:32:41.107" Score="5" Body="&lt;p&gt;I am going to suggest using &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;v&lt;/kbd&gt; (&lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;) to make a block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds as if putting the second block after the first doesn't do what you want.  However, if you put the &lt;em&gt;first&lt;/em&gt; block in front of the second block, it should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To move the first paragraph to before the second paragraph you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vip&amp;lt;C-v&amp;gt;$x&quot;_d)P&#xA;&#xA;vip              # Visually select the first [Inner] Paragraph (cursor inside first block)&#xA;   &amp;lt;C-v&amp;gt;$        # Change to Visual Block mode and select all the way to end of line&#xA;         x       # Cut the first paragraph into default register&#xA;          &quot;_d)   # Delete paragraph into black hole register to remove leftover empty lines&#xA;              P  # Prepend the first paragraph (line-wise) before second paragraph&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, that doesn't leave any space between items. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;apple&#xA;&#xA;tomato&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;turns into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;appletomato&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One way to fix this is to append a space to every item in the first block&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vip:s/$/ &amp;lt;enter&amp;gt;&#xA;&#xA;vip              # select the first paragraph&#xA;   :             # enter command mode&#xA;    s            # substitute command&#xA;     /$          # replace End of line...&#xA;       / /       # with a space (the second '/' here is optional)&#xA;         &amp;lt;enter&amp;gt; # press enter to complete the substitution command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Altogether:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vip:s/$/ &amp;lt;enter&amp;gt;vip&amp;lt;C-v&amp;gt;$x&quot;_d)P&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Original answer: (similar in idea to above solution, but not as generic). See more explanations in an &lt;a href=&quot;https://vi.stackexchange.com/revisions/22829/1&quot;&gt;earlier revision&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vjj:s/$/ /&amp;lt;enter&amp;gt;C^v2k$x4jPgg4dd&#xA;^---------------^       ^^ ^---^&#xA;Put a space @ end       *1    *3&#xA;                 ^-----^  ^&#xA;                 Cut top  2&#xA;*1 - Go down&#xA;*2 - Paste&#xA;*3 - Cleanup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Freebee alternative&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A completely different solution that &lt;em&gt;would&lt;/em&gt; require macros because it only does the move one line at a time. It jumps between top and bottom blocks and combines them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One iteration is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;)jD&amp;lt;C-o&amp;gt;pkJj&#xA;&#xA;)j           # Move down to the second paragraph and onto first line&#xA;  D          # Delete the top line of the second paragraph&#xA;   &amp;lt;C-o&amp;gt;     # Jump back to the top paragraph (Ctrl+o)&#xA;        pk   # Put line from bottom below and move back to top line&#xA;          J  # Join the two lines (white space is taken care of, leaves a single space)&#xA;           j # Move down a line, ready to do it again&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This moves&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     Run once:           Repeat            Repeat&#xA;apple    =&amp;gt;  apple tomato  =&amp;gt;  apple tomato  =&amp;gt;  apple tomato&#xA;pear         pear              pear beans        pear beans&#xA;banana       banana            banana            banana potato&#xA;&#xA;tomato       beans             potato&#xA;beans        potato&#xA;potato&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To create and use this as a macro do &lt;code&gt;qt)jD&amp;lt;C-o&amp;gt;pkJjq&lt;/code&gt; and &lt;code&gt;2@t&lt;/code&gt;. (create and use a macro in register &lt;code&gt;t&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="8458" LastEditorUserId="8458" LastEditDate="2020-02-15T01:57:48.983" LastActivityDate="2020-02-15T01:57:48.983" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22830" PostTypeId="2" ParentId="7656" CreationDate="2020-02-11T09:26:53.347" Score="3" Body="&lt;p&gt;Great tip with the slash and the &lt;code&gt;\ws&lt;/code&gt;, thx!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have entered the following into my &lt;code&gt;.vimrc&lt;/code&gt; (). Hope it helps someone:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Markdown for multiple vimwiki's&#xA;&quot;&#xA;let g:vimwiki_list = [{'path': '~/Documents/myWiki/', 'syntax': 'markdown', 'ext': '.md'},&#xA;                     \ {'path': '~/Documents/myScripts.wiki/', 'syntax': 'markdown', 'ext': '.md'}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;\ws&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1   /Users/username/Documents/myWiki/&#xA;2   /Users/username/Documents/myScripts.wiki/&#xA;Select Wiki (specify number):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I run &lt;code&gt;vim&lt;/code&gt; &lt;code&gt;version 8.2.200&lt;/code&gt; on Mac&lt;/p&gt;&#xA;" OwnerUserId="26814" LastActivityDate="2020-02-11T09:26:53.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22831" PostTypeId="2" ParentId="22827" CreationDate="2020-02-11T09:53:32.917" Score="6" Body="&lt;p&gt;This would be very easy with a macro, but you've stated don't want to use one, so here's a few alternative methods. I think they're all more complicated than a simple macro-based solution, but they show off some interesting features of Vim that readers might want to use in other scenarios.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Using &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Anormal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:normal&lt;/code&gt;&lt;/a&gt; edits&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5,7norm!d$4kA ^R&quot;&#xA;&#xA; 5,7                # On lines 5 through 7&#xA;    norm!           # run normal mode commands that&#xA;         d$         # delete to the end of the line,&#xA;           4k       # move up 4 lines,&#xA;             A      # append a space, and&#xA;               ^R   # insert the contents of (note that this is a literal CTRL-R:&#xA;                    #                         to insert it type &amp;lt;C-V&amp;gt;&amp;lt;C-R&amp;gt;&#xA;                 &quot;  # the unnamed register   (i.e. the text we deleted)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Using &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Amove&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:move&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Ajoin&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:join&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5m.|-1j|+1&#xA;&#xA; 5m.         # Move line 5 below this line&#xA;    |        # and then&#xA;     -1j     # join the two lines&#xA;        |    # and then&#xA;         +1  # move down a line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will append the 5th line to the current line. You can then repeat it twice to complete the edits by typing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2@:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Thanks to &lt;a href=&quot;https://vi.stackexchange.com/questions/22827/paste-append-multiple-lines/22831?noredirect=1#comment41388_22831&quot;&gt;D. Ben Knoble in the comments&lt;/a&gt; for the suggestion to use &lt;code&gt;:join&lt;/code&gt;.&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also perform the join with the normal mode command &lt;code&gt;J&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:5m.|norm!kJj&#xA;&#xA; 5m.           # Move line 5 below this line&#xA;    |          # and then&#xA;     norm!     # run normal mode commands that&#xA;          k    # move up a line,&#xA;           J   # join the line below, and&#xA;            j  # move down a line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Using &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3As&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:substitute&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,3s/$/\= ' '.getline(line('.') + 4)&#xA;&#xA; 1,3                                   # On lines 1 through 3&#xA;    s/                                 # substitute&#xA;      $                                # the end of the line&#xA;       /                               # with&#xA;        \=                             # the result of the expression&#xA;           ' '                         # a space&#xA;              .                        # followed by&#xA;               getline(             )  # the contents of the line&#xA;                       line('.') + 4   # four lines below this one.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This leaves the original second block of lines in place. You can then remove them with the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:4,7d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-02-11T14:40:07.947" LastActivityDate="2020-02-11T14:40:07.947" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22832" PostTypeId="2" ParentId="22805" CreationDate="2020-02-11T10:18:17.533" Score="1" Body="&lt;p&gt;I don't believe this is possible, other than by the methods you have already suggested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think Vim knows whether or not the terminal it is in has focus, and it definitely has no method of changing the window manager's state (except &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3A!&quot; rel=&quot;nofollow noreferrer&quot;&gt;shell&lt;/a&gt;/&lt;a href=&quot;https://vimhelp.org/eval.txt.html#system%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;system&lt;/a&gt; commands such as those you mention).&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-02-11T10:18:17.533" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22833" PostTypeId="2" ParentId="8020" CreationDate="2020-02-11T10:27:59.993" Score="1" Body="&lt;p&gt;I'm afraid the solution you suggest isn't possible. Vim's highlighting and colorscheme commands are global: any colours you set are set &lt;em&gt;everywhere&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best you could do is to change the colours everywhere when the quickfix window opens and then change them back when it closes, (or perhaps change them when entering the buffer and change them back when you leave it), but there is no way of having different highlighting applying in different windows simultaneously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this shouldn't prevent you from fixing the root problem. The quickfix window uses several colours that are separate from any other syntax colouring (&lt;code&gt;QuickFixLine&lt;/code&gt;, &lt;code&gt;qfLine&lt;/code&gt;, &lt;code&gt;qfError&lt;/code&gt; etc.) so you should be able to resolve any such visibility issues by using these rather than changing &lt;code&gt;Search&lt;/code&gt; as you suggest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are still experiencing this issue (I realise your question is almost 4 years old now) then if you could add a few more details about exactly what the problem is in the quickfix, I'm sure we could help you solve it.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-02-11T10:27:59.993" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22834" PostTypeId="1" AcceptedAnswerId="22836" CreationDate="2020-02-11T11:27:38.740" Score="1" ViewCount="86" Body="&lt;p&gt;Similar question, yet not duplicate of: &lt;a href=&quot;https://vi.stackexchange.com/questions/458/how-can-i-reload-all-buffers-at-once&quot;&gt;How can I reload all buffers at once?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;:wa&lt;/code&gt; writes all, would not &lt;code&gt;:ea&lt;/code&gt; be expected to reload all?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could one script &lt;code&gt;:ea&lt;/code&gt; to behave this way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the cases when &lt;code&gt;a&lt;/code&gt; append works or not?&lt;/p&gt;&#xA;" OwnerUserId="25873" LastEditorUserId="25873" LastEditDate="2020-02-12T18:13:19.747" LastActivityDate="2020-02-12T18:13:19.747" Title="`a` append to buffer commands" Tags="|command-line|buffers|load|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22835" PostTypeId="2" ParentId="22834" CreationDate="2020-02-11T13:50:54.300" Score="4" Body="&lt;p&gt;While I cannot answer design questions, not being a designer, I would hazard a guess that &lt;code&gt;:wall&lt;/code&gt; was provided as a shortcut for a very common operation (&lt;code&gt;:bufdo write&lt;/code&gt; or similar), while we are left with &lt;code&gt;:bufdo&lt;/code&gt; (and &lt;code&gt;:argdo&lt;/code&gt;, &lt;code&gt;:cdo&lt;/code&gt;, &lt;code&gt;:windo&lt;/code&gt;, etc.) for the rest. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A user command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -bar -bang Eall bufdo&amp;lt;bang&amp;gt; edit&amp;lt;bang&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(You may not want both bangs; they do different things, so pick the ones that make sense to you.)&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-02-11T13:50:54.300" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22836" PostTypeId="2" ParentId="22834" CreationDate="2020-02-11T14:04:56.047" Score="3" Body="&lt;p&gt;I think D. Ben Knoble's guess is as good as any as to why &lt;code&gt;:editall&lt;/code&gt; hasn't been implemented to do what you want it to. Note that &lt;code&gt;:ea&lt;/code&gt; already has a function (It's short for &lt;code&gt;:earlier&lt;/code&gt;), and it's unlikely that this will ever be changed, as that would break backwards compatability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to make &lt;code&gt;:ea&lt;/code&gt; instead reload all the buffers, you can use an abbreviation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cabbrev &amp;lt;expr&amp;gt; ea (getcmdtype() == ':' &amp;amp;&amp;amp; getcmdpos() == 3) ? 'bufdo edit' : 'ea'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for other commands that support an &lt;code&gt;a[ll]&lt;/code&gt; suffix, here's a possibly incomplete list gleaned from the command: &lt;code&gt;:helpgrep :\k*all\&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:qa[ll]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:wqa[ll]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:doautoa[ll]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:xa[ll]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:ba[ll]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:packl[oadall]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:sal[l]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:sba[ll]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:spellr[epall]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:al[l]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(Just in case you weren't already aware of this, all command-line commands can be abbreviated to the shortest non-ambiguous prefix, hence the square brackets &lt;code&gt;[]&lt;/code&gt; denoting the optional characters in the command.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="1238" LastEditDate="2020-02-11T16:20:22.320" LastActivityDate="2020-02-11T16:20:22.320" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22837" PostTypeId="2" ParentId="22794" CreationDate="2020-02-11T15:08:54.200" Score="1" Body="&lt;p&gt;Creating a function for this works&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function gv () { &#xA;  WS=`xprop -root -notype _NET_CURRENT_DESKTOP | awk '{print $3}'`;&#xA;  gvim --servername $WS --remote-tab-silent $@&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that tab completion doesn't work for me for the function so I alias something to this function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;xprop ... returns the workspace number in column 3&#xA;awk extracts just column 3&lt;/p&gt;&#xA;" OwnerUserId="26817" LastActivityDate="2020-02-11T15:08:54.200" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22838" PostTypeId="1" AcceptedAnswerId="22863" CreationDate="2020-02-11T18:45:16.583" Score="4" ViewCount="1798" Body="&lt;p&gt;I'm trying to filter specific lines through external command. I think knowing how to do this would be extremely beneficial to me, so I'm trying to find a way to do this. As an example, I wanted to count the occurrence of a specific word or line in a file. I was trying to do this with a filter, using the following command:&#xA;&lt;code&gt;:g/http/w !wc -l&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this ran &lt;code&gt;w !wc -l&lt;/code&gt; for every line matching the file, so I got the total number of lines in the file, a number of times equal to the number of matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I was expecting, was something akin to this line:&#xA;&lt;code&gt;:%!grep http | wc -l&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is something like this possible in vim using filters or commands? If not, I'm fine using the grep wc solution, but it would be nice having a clean way to do this from vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also noticed that &lt;code&gt;:g/http/p&lt;/code&gt; prints all the matching lines, but I don't have the option of piping the output to an external command using the print command. Is there anything else I could use?&lt;/p&gt;&#xA;" OwnerUserId="26910" LastActivityDate="2020-06-01T13:36:00.387" Title="Filter specific lines matching a pattern through external command" Tags="|external-command|ex-command|filter|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22839" PostTypeId="2" ParentId="22838" CreationDate="2020-02-11T19:23:39.577" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;but I don't have the option of piping the output to an external command&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Actually you do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo system('wc -l', execute('g/http/'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, note that &lt;code&gt;execute()&lt;/code&gt; &lt;strong&gt;prepends&lt;/strong&gt; a newline to the resulting string, while &lt;strong&gt;not appending&lt;/strong&gt; a newline after it. Hence the result of &lt;code&gt;wc -l&lt;/code&gt; remains the same, but it could matter under different circumstances.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-11T19:23:39.577" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22840" PostTypeId="1" AcceptedAnswerId="22858" CreationDate="2020-02-11T20:00:16.487" Score="2" ViewCount="513" Body="&lt;p&gt;The following line in my &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi Comment ctermfg=gray&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does not take effect unless I start Vim and then use &lt;code&gt;:source&lt;/code&gt; to reload &lt;code&gt;.vimrc&lt;/code&gt;. As far as I can tell, all of the other &lt;code&gt;hi&lt;/code&gt; commands work without reloading &lt;code&gt;.vimrc&lt;/code&gt;. What could be causing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my full &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent plugin on                                                       &#xA;syntax on                                                                       &#xA;&#xA;set number                                                                      &#xA;set relativenumber                                                              &#xA;&#xA;set colorcolumn=80                                                              &#xA;&#xA;set showcmd                                                                     &#xA;&#xA;set expandtab                                                                   &#xA;set shiftwidth=4                                                                &#xA;set smarttab                                                                    &#xA;&#xA;set list                                                                        &#xA;set listchars=tab:&amp;gt;-,trail:~                                                    &#xA;&#xA;hi ColorColumn ctermbg=0                                                        &#xA;hi LineNr ctermfg=gray                                                          &#xA;hi CursorLineNr ctermfg=gray                                                    &#xA;hi Comment ctermfg=gray                                                         &#xA;hi Function ctermfg=darkgreen                                                   &#xA;&#xA;hi pythonStatement ctermfg=lightblue                                            &#xA;hi pythonConditional ctermfg=lightblue                                          &#xA;hi pythonRepeat ctermfg=lightblue                                               &#xA;hi pythonException ctermfg=lightblue                                            &#xA;hi pythonDecoratorName ctermfg=lightblue                                        &#xA;let python_no_number_highlight = 1                                                                                                               &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; The output of &lt;code&gt;:verbose hi Comment&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Comment        xxx term=bold ctermfg=14 guifg=#80a0ff&#xA;        Last set from /usr/share/vim/vim80/syntax/syncolor.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it appears that my setting is being overridden by the default syntax file. I will investigate how to solve this when I have time, but would appreciate any tips from more experienced users :)&lt;/p&gt;&#xA;" OwnerUserId="26912" LastEditorUserId="26912" LastEditDate="2020-02-13T06:25:21.387" LastActivityDate="2020-02-13T07:50:51.123" Title="Comment highlight group does not work without reloading .vimrc" Tags="|vimrc|syntax-highlighting|comments|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22841" PostTypeId="2" ParentId="22838" CreationDate="2020-02-11T21:16:22.657" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;:%s/pattern/gn&lt;/code&gt;&#xA;The n tells it to count the g to count every occurrence. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2020-02-11T21:16:22.657" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22842" PostTypeId="2" ParentId="22838" CreationDate="2020-02-11T22:27:13.170" Score="3" Body="&lt;p&gt;I'm not aware of any builtin, &lt;em&gt;compact&lt;/em&gt; functionality that let's you filter the output of any vim command through any external command. With a little one-time scripting, though, you could get something like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:MyFilt g/http/ | wc -l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To start, put this in your vimrc...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! MyFilt(cmd)&#xA;    let parts = split(a:cmd, '|')&#xA;    let vimcmd = trim(parts[0])&#xA;    let shcmd = trim(parts[1])&#xA;    echom trim(system(shcmd, execute(vimcmd)))&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The base command here is pretty much what Matt showed in his answer plus a bunch of junk trimming.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We could use this like...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call MyFilt('g/http/ | wc -l')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But we can distill it down further using a &lt;code&gt;:command&lt;/code&gt; (also goes in your vimrc)...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command -nargs=1 MyFilt call MyFilt(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now your call can be of the form &lt;code&gt;:MyFilt &amp;lt;vim-command&amp;gt; | &amp;lt;sh-filter&amp;gt;&lt;/code&gt; as show above...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:MyFilt g/http/ | wc -l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The uniqueness of a one-arg &lt;code&gt;:command&lt;/code&gt;'s param processing is to thank here. It just takes &lt;em&gt;everything&lt;/em&gt; after the command name and passes it as a single string param to the designated function.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-02-11T23:24:16.743" LastActivityDate="2020-02-11T23:24:16.743" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22843" PostTypeId="2" ParentId="22818" CreationDate="2020-02-11T23:43:50.373" Score="2" Body="&lt;p&gt;The issue is that you're calling &lt;code&gt;feedkeys()&lt;/code&gt; and that function adds the keypresses to the end of the typeahead buffer, which means they don't execute right away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://vimhelp.org/eval.txt.html?#feedkeys%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help feedkeys()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;By default the string is added to the end of the typeahead buffer, thus if a mapping is still being executed the characters come after them.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are flags you can pass to &lt;code&gt;feedkeys()&lt;/code&gt; to change this behavior... But in any case, the actual &lt;em&gt;intent&lt;/em&gt; of your commands here is to run Normal mode commands and using &lt;a href=&quot;https://vimhelp.org/various.txt.html?#%3Anormal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:normal!&lt;/code&gt;&lt;/a&gt; is a much better way to accomplish that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I suggest you change your code to use &lt;code&gt;normal! 0&lt;/code&gt;, &lt;code&gt;normal! x&lt;/code&gt; and &lt;code&gt;normal! l&lt;/code&gt; instead of the &lt;code&gt;feedkeys()&lt;/code&gt; calls, that should solve the issue for you.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-11T23:43:50.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22844" PostTypeId="1" CreationDate="2020-02-12T00:16:46.157" Score="0" ViewCount="65" Body="&lt;p&gt;I've recently downloaded nvim and have been using it for a few weeks with no problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm getting this every time I start nvim:&#xA;&lt;code&gt;&quot;raw&quot; &quot;raw&quot; [readonly] 5L, 190C&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't figure out how this happened or how to revert back to edit mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Help would be appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;Connor&lt;/p&gt;&#xA;" OwnerUserId="26503" LastActivityDate="2020-02-12T00:16:46.157" Title="neovim: How to exit &quot;raw&quot; &quot;raw&quot; [readonly] 5L, 190C" Tags="|neovim|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22845" PostTypeId="1" AcceptedAnswerId="22846" CreationDate="2020-02-12T10:00:54.417" Score="0" ViewCount="95" Body="&lt;p&gt;I've needed to switch to &lt;code&gt;chcp 65001&lt;/code&gt; to properly display some Unicode characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I've noticed that my Vim isn't displaying characters properly when &lt;code&gt;chcp&lt;/code&gt; is set to &lt;code&gt;65001&lt;/code&gt; as opposed to &lt;code&gt;437&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what it looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3ayoY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3ayoY.png&quot; alt=&quot;Screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which Vim setting do I need to change to have it properly display with &lt;code&gt;chcp 65001&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update: It appears that this is an issue specific to Console2 the command-line program I'm using. It does not happen in cmd when I set the chcp to 65001. Any suggestions are welcome.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="26924" OwnerDisplayName="Gnosis" LastEditorUserId="26924" LastEditDate="2020-02-12T10:08:14.577" LastActivityDate="2020-02-12T10:14:45.313" Title="Vim Looks Very Weird When Using chcp 65001" Tags="|cygwin|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22846" PostTypeId="2" ParentId="22845" CreationDate="2020-02-12T10:14:45.313" Score="2" Body="&lt;p&gt;Fixed by adding &lt;code&gt;set encoding=utf-8&lt;/code&gt; to &lt;code&gt;.vimrc&lt;/code&gt; (called &lt;code&gt;_vimrc&lt;/code&gt; on Windows).&lt;/p&gt;&#xA;" OwnerUserId="26924" LastActivityDate="2020-02-12T10:14:45.313" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22847" PostTypeId="1" AcceptedAnswerId="22865" CreationDate="2020-02-12T11:31:38.960" Score="3" ViewCount="236" Body="&lt;p&gt;I am trying to implement a way to get automatic completion when typing Latex environments. Consider the following situation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{|}&#xA;\end{}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;|&lt;/code&gt; stands for the position of the cursor. Then I type the name of the environment, say &lt;code&gt;tabular&lt;/code&gt; and press &lt;code&gt;Enter&lt;/code&gt; and I would like it to automatically fill the brackets after &lt;code&gt;\end&lt;/code&gt;.&#xA;I originally thought of using double cursors but then I read the plugins for multiple cursors are not so sturdy. By the way, is it really so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regardless, I came up with the following solution. I have a plugin (namely &lt;a href=&quot;https://github.com/brennier/quicktex&quot; rel=&quot;nofollow noreferrer&quot;&gt;quicktex&lt;/a&gt;) that allows me to enter some keys in insert mode and substitute them with arbitrary commands, so I set &lt;code&gt;&amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt;&lt;/code&gt; to be replaced by &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;\\begin{}\&amp;lt;CR&amp;gt;\\end{}\&amp;lt;CR&amp;gt;&amp;lt;++&amp;gt;\&amp;lt;ESC&amp;gt;2?}\&amp;lt;CR&amp;gt;:call InEnv(1)\&amp;lt;CR&amp;gt;i&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I put the following code in my &lt;code&gt;tex.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Am I in environment mode?&#xA;    let s:env = 0&#xA;&#xA;&quot; Enter/exit environment mode&#xA;    function! InEnv(on)&#xA;        let s:env = a:on&#xA;        if a:on ==? 1&#xA;            inoremap &amp;lt;CR&amp;gt; &amp;lt;ESC&amp;gt;:call BuildEnv()&amp;lt;CR&amp;gt;A&amp;lt;CR&amp;gt;&#xA;        elseif a:on ==? 0&#xA;            iunmap &amp;lt;CR&amp;gt;&#xA;        endif&#xA;    endfunction&#xA;&#xA;&quot; Finds out the length of the environment name (when cursor is inside the brackets relative to \begin)&#xA;    function! EnvNameLength()&#xA;        call search(&quot;}&quot;, &quot;cz&quot;)&#xA;        execute &quot;normal! h&quot;&#xA;        let s:end = col(&quot;.&quot;)&#xA;        call search(&quot;{&quot;, &quot;b&quot;)&#xA;        return s:end - col(&quot;.&quot;)&#xA;    endfunction&#xA;&#xA;&quot; Copies environment name and pastes it&#xA;    function! CopyEnvName()&#xA;        let s:len = EnvNameLength()&#xA;        execute &quot;normal! lv&quot; . (s:len-1) . &quot;ly&quot;&#xA;        call search(&quot;end{&quot;, &quot;e&quot;)&#xA;        execute &quot;normal! p&quot;&#xA;    endfunction&#xA;&#xA;&quot; Builds environment&#xA;    function! BuildEnv()&#xA;        if s:env ==? 1&#xA;            call CopyEnvName()&#xA;            call search(&quot;begin&quot;, &quot;b&quot;)&#xA;        endif&#xA;        call InEnv(0)&#xA;    endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works perfectly but I feel it's a bit clumsy because of the continuous mapping/unmapping of the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; key. I would like to avoid remapping any keys. Is there any way to accomplish that?&lt;/p&gt;&#xA;" OwnerUserId="26917" LastEditorUserId="26917" LastEditDate="2020-02-12T18:41:22.527" LastActivityDate="2020-11-07T14:51:48.187" Title="Automatic completion in Latex environments" Tags="|filetype-tex|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22848" PostTypeId="1" AcceptedAnswerId="22853" CreationDate="2020-02-12T12:00:05.590" Score="3" ViewCount="588" Body="&lt;p&gt;It's possible to create a placeholder inside a python interpolation block?.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to do a snippet for my grammar exercises.&#xA;I'm currently in this snippet.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet &quot;ej(ercicio)?( (\d+))?&quot; &quot;Ejercicios - grammar&quot; br&#xA;${1:unidad}.${2:ejercicio} )$0`!p&#xA;num = match.group(3) if match.group(2) is not None else 2&#xA;for var in range(2, int(num)+1):&#xA;→   snip += str(var) + &quot; -&amp;gt; $&quot;+str(var + 1)`&#xA;&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it outputs &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ej 8&amp;lt;tab&amp;gt;&#xA;&#xA;unidad.ejercicio )¬&#xA;2 -&amp;gt; $3¬&#xA;3 -&amp;gt; $4¬&#xA;4 -&amp;gt; $5¬&#xA;5 -&amp;gt; $6¬&#xA;6 -&amp;gt; $7¬&#xA;7 -&amp;gt; $8¬&#xA;8 -&amp;gt; $9¬&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(the first it's always an example, so i don't print it)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any clue?&lt;/p&gt;&#xA;" OwnerUserId="26922" LastActivityDate="2020-02-12T15:13:49.220" Title="Ultisnips - Create a placeholder/tabstop inside a python interpolation?" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22849" PostTypeId="1" CreationDate="2020-02-12T12:30:21.167" Score="2" ViewCount="476" Body="&lt;p&gt;I have been using &lt;code&gt;nvim-qt&lt;/code&gt; and I like it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I want to switch to regular &lt;code&gt;nvim&lt;/code&gt;, but like other users I have had trouble with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So then I thought maybe I will just use plain &lt;code&gt;vim&lt;/code&gt;. The issue is that I like the default colors of &lt;code&gt;nvim-qt&lt;/code&gt;, so I would like to keep them. However, I can't seem to duplicate them. I tried a &lt;code&gt;.vimrc&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set term=xterm-256color&#xA;set termguicolors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;nvim-qt&lt;/code&gt;, I get good looking colors like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/60531334/74301023-54c4ed80-4d17-11ea-84b5-0643786fbd9c.png&quot; alt=&quot;Untitled&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but with &lt;code&gt;vim&lt;/code&gt; I get this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/60531334/74301042-63130980-4d17-11ea-9851-d66bb52079f2.png&quot; alt=&quot;2&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's pretty close but some bolding is different. How can I resolve this? Note I am using Windows with Mintty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://gist.github.com/tycho/73401cd6aed7e733fc2b97a8de1ca03e&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gist.github.com/tycho/73401cd6aed7e733fc2b97a8de1ca03e&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="11357" LastEditDate="2020-04-10T23:29:55.850" LastActivityDate="2020-04-10T23:29:55.850" Title="Using Nvim-Qt colors with regular Vim" Tags="|neovim|colorscheme|color|neovim-qt|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22850" PostTypeId="1" AcceptedAnswerId="22851" CreationDate="2020-02-12T13:29:24.270" Score="3" ViewCount="320" Body="&lt;p&gt;I'm editing a file with the following pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# stock comment&#xA;# stock comment&#xA;# stock comment&#xA;# stock comment&#xA;# stock comment&#xA;&#xA;conf&#xA;conf&#xA;&#xA;conf&#xA;conf&#xA;&#xA;very_long_conf_line_xxxxxx (600+ chars)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's the stock layout and the file name ends with &lt;code&gt;.conf&lt;/code&gt;, so Vim picked it up with &lt;code&gt;ft=conf&lt;/code&gt;. It's actually some Nginx configuration, so I inserted a modeline like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# stock comment&#xA;# stock comment&#xA;# stock comment&#xA;# stock comment&#xA;# stock comment&#xA;# vim: set filetype=nginx:&#xA;&#xA;conf&#xA;conf&#xA;&#xA;conf&#xA;conf&#xA;&#xA;very_long_conf_line (600+ chars)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when opening the file again, it's still taken as &lt;code&gt;ft=conf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:verbose se ml?&lt;/code&gt; shows &lt;code&gt;modeline&lt;/code&gt; and last set from &lt;code&gt;~/.vimrc line xx&lt;/code&gt;, and &lt;code&gt;:verbose se ft?&lt;/code&gt; shows &lt;code&gt;filetype=conf&lt;/code&gt; and last set from &lt;code&gt;/usr/share/vim/vim81/filetype.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why isn't my mode line working? How do I get it to work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running Vim 8.1 from Ubuntu Eoan.&lt;/p&gt;&#xA;" OwnerUserId="16096" LastActivityDate="2020-02-12T13:52:57.783" Title="Mode line not working even if everything seems correct" Tags="|modeline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22851" PostTypeId="2" ParentId="22850" CreationDate="2020-02-12T13:52:57.783" Score="4" Body="&lt;p&gt;Vim only checks for &quot;a number of lines at the beginning of the end of the file&quot;. By default, only the first and last 5 lines are checked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help 'modeline'&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If 'modeline' is on 'modelines' gives the number of lines that is&#xA;      checked for set commands&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And from &lt;code&gt;help: 'modelines'&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'modelines' 'mls'  number  (default 5)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you wish, you can &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:set modelines&lt;/code&gt; to a larger number, or &lt;/li&gt;&#xA;&lt;li&gt;place the modeline(s) at the beginning or end of the file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21495" LastActivityDate="2020-02-12T13:52:57.783" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22852" PostTypeId="1" CreationDate="2020-02-12T14:09:58.783" Score="2" ViewCount="280" Body="&lt;p&gt;I'm experiencing the problem with gvim taking ~20 secs to start when I have  &lt;code&gt;guioptions-=T&lt;/code&gt; in my .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tried both version 8.1.0875 and 8.2.0121&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this bug report which is now closed, but the proposed solution didn't work for me: &lt;a href=&quot;https://github.com/vim/vim/issues/5246&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/issues/5246&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone else has this problem and knows a solution?&lt;/p&gt;&#xA;" OwnerUserId="2746" LastActivityDate="2020-02-12T14:09:58.783" Title="gVim very slow start with guioptions-=T" Tags="|vimrc|gvim|startup|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22853" PostTypeId="2" ParentId="22848" CreationDate="2020-02-12T15:13:49.220" Score="3" Body="&lt;p&gt;Thanks to husB for point me the &lt;a href=&quot;https://github.com/SirVer/ultisnips/blob/master/doc/examples/tabstop-generation/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;dynamic tabstop generation&lt;/a&gt;, i don't know why it isn't in the doc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The final snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global !p&#xA;def create_line_plhldr(snip):&#xA;&#xA;    num = int(snip.buffer[snip.line].strip())&#xA;&#xA;    snip.buffer[snip.line] = ''&#xA;&#xA;    anon_snippet_body = '${1:unidad}.${2:ejercicio} )'&#xA;    for var in range(2, int(num)+1):&#xA;        anon_snippet_body += '\n' + str(var) + &quot; -&amp;gt; $&quot;+str(var + 1)&#xA;&#xA;    snip.expand_anon(anon_snippet_body)&#xA;endglobal&#xA;&#xA;post_jump &quot;create_line_plhldr(snip)&quot;&#xA;snippet &quot;ej(ercicio)?( (\d+))?&quot; &quot;Ejercicios - grammar&quot; br&#xA;`!p snip.rv = match.group(3) if match.group(2) is not None else 2 `&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26922" LastActivityDate="2020-02-12T15:13:49.220" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22854" PostTypeId="1" CreationDate="2020-02-12T18:01:44.093" Score="2" ViewCount="31" Body="&lt;p&gt;I usually start vim at the root of my project. Then I open tabs with windows inside. Usually one of the windows has a &lt;code&gt;:terminal&lt;/code&gt;. In the &lt;code&gt;:terminal&lt;/code&gt;, I usually &lt;code&gt;cd to/some/subfolder&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the end of the day, I run &lt;code&gt;:mksession&lt;/code&gt; to save my tab/window layout. However, one thing I notice is that my &lt;code&gt;:terminal&lt;/code&gt;s forget what folder I was in. This means at the start of every day I have to go to each &lt;code&gt;:terminal&lt;/code&gt; window and run &lt;code&gt;cd to/some/subfolderA&lt;/code&gt;, &lt;code&gt;cd to/some/subfolderB&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to record the current working directory of each of my &lt;code&gt;:terminal&lt;/code&gt; windows in my &lt;code&gt;:mksession&lt;/code&gt; file? The cwd of the vim process is fine at the root of my project. I only care about the subterminals that vim creates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally this would be able to be done without a plugin or as little config as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are my session options.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sessionoptions=blank,buffers,curdir,folds,help,options,tabpages,winsize,terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22095" LastEditorUserId="22095" LastEditDate="2020-02-12T22:41:15.683" LastActivityDate="2020-02-12T22:41:15.683" Title="Save terminal buffer's current working directory with mksession" Tags="|terminal-buffer|sessions|" AnswerCount="0" CommentCount="0" ClosedDate="2020-02-13T17:11:36.017" ContentLicense="CC BY-SA 4.0" />
  <row Id="22855" PostTypeId="1" CreationDate="2020-02-13T01:18:03.160" Score="0" ViewCount="768" Body="&lt;p&gt;I would like to write a script, maybe even using Python, that captures a key stroke in a Vim window.&#xA;Let's say I am in insert mode and I type the letter &lt;code&gt;g&lt;/code&gt;.&#xA;I would like this key stroke to trigger some action, that I configure, while still typing in the letter.&#xA;Also, this behaviour should not depend on the key that has been hit (in that case a simple remapping would do).&#xA;So, I guess what I'm looking for is some kind of key-hit event I can exploit. Is such a thing available in Vimscript (possibly integrated with Python)?&lt;/p&gt;&#xA;" OwnerUserId="26917" LastActivityDate="2020-02-13T05:16:18.307" Title="Capturing key stroke" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22856" PostTypeId="2" ParentId="22855" CreationDate="2020-02-13T04:56:54.653" Score="2" Body="&lt;p&gt;There is an &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;auto-command&lt;/a&gt; event &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#InsertCharPre&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;InsertCharPre&lt;/code&gt;&lt;/a&gt; that detects entry of any character while in Insert mode yet still inserts it into the buffer. Here's a dead simple example (put this in your vimrc, for instance):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup InterceptKeyPress&#xA;    autocmd!&#xA;    autocmd InsertCharPre * :echo localtime()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can run any vimscript you want in response to the  event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick test confirms it works as expected. The impact on overall usability is something you'll have to evaluate for yourself. :)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-02-13T05:16:18.307" LastActivityDate="2020-02-13T05:16:18.307" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22857" PostTypeId="1" CreationDate="2020-02-13T06:26:11.863" Score="3" ViewCount="196" Body="&lt;p&gt;I'm able to get the auto complete menu to come up with &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt;/&lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;o&lt;/kbd&gt; combos, but would like to have the window pop-up automatically. Is there a mapping that would enable this? &lt;/p&gt;&#xA;" OwnerUserId="26936" LastEditorUserId="1238" LastEditDate="2020-02-13T19:12:45.670" LastActivityDate="2020-02-13T19:12:45.670" Title="Vim - Auto complete without doing ctrl x + ctrl o" Tags="|neovim|plugin-vim-go|" AnswerCount="0" CommentCount="1" ClosedDate="2020-04-26T11:26:32.050" ContentLicense="CC BY-SA 4.0" />
  <row Id="22858" PostTypeId="2" ParentId="22840" CreationDate="2020-02-13T07:50:51.123" Score="2" Body="&lt;p&gt;I can confirm this with the latest vim-nightly.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;your &lt;code&gt;vimrc&lt;/code&gt; loads first (where you have defined your highlighing)&lt;/li&gt;&#xA;&lt;li&gt;then &lt;code&gt;syntax/synload.vim&lt;/code&gt; does override it with:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Set the default highlighting colors.  Use a color scheme if specified.&#xA;if exists(&quot;colors_name&quot;)&#xA;  exe &quot;colors &quot; . colors_name&#xA;else&#xA;  runtime! syntax/syncolor.vim&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;syntax/syncolor.vim&lt;/code&gt; is the one that defines default colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:colors_name = &quot;mycolorscheme&quot;&#xA;let colors_name = &quot;mycolorscheme&quot;&#xA;hi Comment guibg=green&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it still thinks &lt;code&gt;colors_name&lt;/code&gt; doesn't exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Back to solution: Solution 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest to create your own colorscheme &lt;code&gt;.vim/colors/mycolorscheme.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set background=light&#xA;&#xA;hi clear&#xA;if exists('syntax_on')&#xA;    syntax reset&#xA;endif&#xA;&#xA;let g:colors_name = 'mycolorscheme'&#xA;&#xA;hi ColorColumn ctermbg=0                                                        &#xA;hi LineNr ctermfg=gray                                                          &#xA;hi CursorLineNr ctermfg=gray                                                    &#xA;hi Comment ctermfg=gray                                                         &#xA;hi Function ctermfg=darkgreen                                                   &#xA;&#xA;hi pythonStatement ctermfg=lightblue                                            &#xA;hi pythonConditional ctermfg=lightblue                                          &#xA;hi pythonRepeat ctermfg=lightblue                                               &#xA;hi pythonException ctermfg=lightblue                                            &#xA;hi pythonDecoratorName ctermfg=lightblue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in your &lt;code&gt;vimrc&lt;/code&gt; use it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent plugin on                                                       &#xA;syntax on                                                                       &#xA;&#xA;set number                                                                      &#xA;set relativenumber                                                              &#xA;&#xA;set colorcolumn=80                                                              &#xA;&#xA;set showcmd                                                                     &#xA;&#xA;set expandtab                                                                   &#xA;set shiftwidth=4                                                                &#xA;set smarttab                                                                    &#xA;&#xA;set list                                                                        &#xA;set listchars=tab:&amp;gt;-,trail:~ &#xA;&#xA;let python_no_number_highlight = 1&#xA;&#xA;colorscheme mycolorscheme&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just add &lt;code&gt;colorscheme default&lt;/code&gt; before your highlight definitions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent plugin on                                                       &#xA;syntax on                                                                       &#xA;&#xA;set number                                                                      &#xA;set relativenumber                                                              &#xA;&#xA;set colorcolumn=80                                                              &#xA;&#xA;set showcmd                                                                     &#xA;&#xA;set expandtab                                                                   &#xA;set shiftwidth=4                                                                &#xA;set smarttab                                                                    &#xA;&#xA;set list                                                                        &#xA;set listchars=tab:&amp;gt;-,trail:~                                                    &#xA;&#xA;colorscheme default&#xA;&#xA;hi ColorColumn ctermbg=0                                                        &#xA;hi LineNr ctermfg=gray                                                          &#xA;hi CursorLineNr ctermfg=gray                                                    &#xA;hi Comment ctermfg=gray                                                         &#xA;hi Function ctermfg=darkgreen                                                   &#xA;&#xA;hi pythonStatement ctermfg=lightblue                                            &#xA;hi pythonConditional ctermfg=lightblue                                          &#xA;hi pythonRepeat ctermfg=lightblue                                               &#xA;hi pythonException ctermfg=lightblue                                            &#xA;hi pythonDecoratorName ctermfg=lightblue                                        &#xA;let python_no_number_highlight = 1  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS, looks like &lt;code&gt;colorscheme&lt;/code&gt; command does smth that sets up &lt;code&gt;colors_name&lt;/code&gt; variable properly?&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-02-13T07:50:51.123" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22859" PostTypeId="2" ParentId="14374" CreationDate="2020-02-13T09:00:53.980" Score="0" Body="&lt;p&gt;If you are old-fashioned, you might want an alias such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vi='vi --noplugin'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can again rely on your own intelligence rather than vi's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the &quot;modern&quot; plug-ins are rather annoying if you are not used to them.&lt;/p&gt;&#xA;" OwnerUserId="26938" LastEditorUserId="10604" LastEditDate="2020-02-13T13:47:47.110" LastActivityDate="2020-02-13T13:47:47.110" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22860" PostTypeId="1" CreationDate="2020-02-13T11:52:40.710" Score="3" ViewCount="280" Body="&lt;p&gt;If I have many buffers opened and, if the cursor (focus) is within NERDTree, when I change the buffer with &lt;code&gt;:bn&lt;/code&gt; or &lt;code&gt;:bp&lt;/code&gt;, the content of buffer loads within NERDTree.&lt;/p&gt;&#xA;&lt;p&gt;There's a way to, before buffer enter, check if cursor is focus on NERDTree and type &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; to prevent buffer loads within NERDTree?&lt;/p&gt;&#xA;" OwnerUserId="26842" LastEditorUserId="23502" LastEditDate="2023-03-26T18:10:46.170" LastActivityDate="2023-12-21T21:05:40.753" Title="Prevent buffer loads within NERDTree" Tags="|vimrc|neovim|plugin-nerdtree|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22861" PostTypeId="1" CreationDate="2020-02-13T12:43:12.243" Score="2" ViewCount="89" Body="&lt;p&gt;Is it possible to setup vim for auto updating on changing of file content?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think about working with logs that can extend if new event happened.&lt;br&gt;&#xA;What I expect is that vim will spot a file change and update the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid &quot;merge conflicts&quot; I can run in read-only mode and just&#xA;use vim as a perfect viewer with all search capability and well&#xA;known user interface&lt;/p&gt;&#xA;" OwnerUserId="22255" LastEditorUserId="1238" LastEditDate="2020-02-13T17:56:56.770" LastActivityDate="2020-02-13T17:56:56.770" Title="Auto updating for file content similar to tail -f" Tags="|buffers|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22862" PostTypeId="2" ParentId="22861" CreationDate="2020-02-13T14:00:55.443" Score="3" Body="&lt;p&gt;Tracking file change automatically is OS-dependent, so by default Vim only checks file timestamps (&lt;code&gt;:checktime&lt;/code&gt;) on focus gain (works in GUI) and after executing shell commands. But you can force it any moment using a bit of scripting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, check by timer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! PollBuffer(bufnr, msec)&#xA;    &quot; make sure autoread is on, so Vim won't ask any questions&#xA;    call setbufvar(a:bufnr, '&amp;amp;autoread', 1)&#xA;    &quot; check timestamp by timer event&#xA;    return timer_start(a:msec, {_ -&amp;gt; execute(a:bufnr..'checktime')}, {'repeat': -1})&#xA;endfunction&#xA;&#xA;let timerID = PollBuffer(bufnr('foobar.txt'), 5000)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-13T14:00:55.443" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22863" PostTypeId="2" ParentId="22838" CreationDate="2020-02-13T14:21:28.470" Score="1" Body="&lt;p&gt;Thanks to @B Layers and @Matts answers, I've written this function which serves my purposes perfectly. I'm sharing it here for future reference, if anyone needs the same functionality.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Function to pipe output of vim command to external command.&#xA;&quot; The 'trim' argument determines whether the vim command&#xA;&quot; output will be trimmed before piping it to the external&#xA;&quot; command. The 'cmd' argument is the full command, including&#xA;&quot; the vim command. The vim command is separated from the&#xA;&quot; external command with a '|' character, and everything from&#xA;&quot; the first '|' character to the end of the line is considered&#xA;&quot; the external command, so external pipes work as well.&#xA;function! Pipe(trim, cmd)&#xA;    &quot; Split the command&#xA;    let l:cmds = split(a:cmd, '|')&#xA;&#xA;    &quot; Save the state of the number and relativenumber option&#xA;    let l:number = &amp;amp;number&#xA;    let l:relativenumber = &amp;amp;relativenumber&#xA;&#xA;    &quot; Disable the two options, so that the vim output doesn't have line numbers&#xA;    setlocal nonumber norelativenumber&#xA;&#xA;    &quot; Run the vim command&#xA;    let l:vimresult = execute(trim(l:cmds[0]))&#xA;&#xA;    &quot; Restore the two saved options&#xA;    let &amp;amp;l:number = l:number&#xA;    let &amp;amp;l:relativenumber = l:relativenumber&#xA;&#xA;    &quot; Trim the vim command if necessary&#xA;    if a:trim&#xA;        let l:vimresult = trim(l:vimresult)&#xA;    endif&#xA;&#xA;    &quot; If there was no external command, return the output of the vim command&#xA;    if len(l:cmds) &amp;lt;= 1&#xA;        return l:vimresult&#xA;    endif&#xA;&#xA;    &quot; Run the external command and return the output&#xA;    return trim(system(join(l:cmds[1:], '|'), l:vimresult))&#xA;endfunction&#xA;&#xA;&quot; Define a command called Pipe for calling the Pipe() function&#xA;command! -nargs=1 -bang -complete=command Pipe echo Pipe(&amp;lt;bang&amp;gt;1, &amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using it is simple, just do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Pipe[!] g/test/ | wc -l&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the bang is present, the function won't trim the vim command output, which is, for example, needed for wc to correctly output the number of lines, since it counts all the newlines found in the text.&lt;/p&gt;&#xA;" OwnerUserId="26910" LastEditorUserId="26910" LastEditDate="2020-06-01T13:36:00.387" LastActivityDate="2020-06-01T13:36:00.387" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22864" PostTypeId="2" ParentId="22847" CreationDate="2020-02-13T17:23:35.980" Score="1" Body="&lt;p&gt;I think you should be able to address your specific issue of remapping the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; by using an expression map.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is untested, but it (or something similar) might work for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; (s:env ==? 1) ? '&amp;lt;ESC&amp;gt;:call BuildEnv()&amp;lt;CR&amp;gt;A&amp;lt;CR&amp;gt;' : '&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's slightly different from your existing code in that it changes the behaviour of &lt;kbd&gt;Enter&lt;/kbd&gt; based on the &lt;em&gt;current&lt;/em&gt; value of &lt;code&gt;s:env&lt;/code&gt; rather than the value that existed at the time the mapping was made.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't studied your code in enough detail to figure out whether this is a drop in replacement for your existing &lt;code&gt;if&lt;/code&gt; block, or if you might need to rework your code a little.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-02-13T17:23:35.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22865" PostTypeId="2" ParentId="22847" CreationDate="2020-02-13T17:32:26.810" Score="2" Body="&lt;p&gt;I've actually looked at what your code is intended to do, now, and have come up with a couple of alternatives:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;A simple solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;How about something a bit simpler that simply asks for the environment?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function EnvThing() abort&#xA;  let env = input('Enter env: ')&#xA;  return '\begin{'.x.&quot;}\&amp;lt;CR&amp;gt;end{&quot;.x.'}'&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Space&amp;gt;&amp;lt;Space&amp;gt; EnvThing()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;A fully automated solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Instead of using mappings this autocommand automatically updates the nearest &lt;code&gt;\end{}&lt;/code&gt; whenever you edit the &lt;code&gt;\begin{}&lt;/code&gt; in insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EnviroThing() abort&#xA;  let state = winsaveview()&#xA;  try&#xA;    let l = getline('.')&#xA;    let c = col('.')&#xA;    if l[:c - 1] =~# '\\begin{[^}]*' &amp;amp;&amp;amp; l[c - 1:] =~# '[^}]*}'&#xA;      norm!yi}&#xA;      call search('\\end{', 'eW')&#xA;      execute &quot;norm!ci}\&amp;lt;C-R&amp;gt;0&quot;&#xA;    endif&#xA;  finally&#xA;    call winrestview(state)&#xA;  endtry&#xA;endfunction&#xA;&#xA;augroup EnviroThing&#xA;  autocmd!&#xA;  autocmd TextChangedI *.latex call EnviroThing()&#xA;  autocmd TextChanged *.latex call EnviroThing()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are a number of ways this could be polished further, e.g. it doesn't work well with mismatched begin/ends, so you're probably going to want to keep your quicktex shortcut or an &lt;code&gt;iabbrev&lt;/code&gt; in place so that you never enter a &lt;code&gt;\begin{}&lt;/code&gt; without a corresponding end, and it might be nice if it worked in the other direction, updating the &lt;code&gt;\begin{}&lt;/code&gt; when you change the content of the &lt;code&gt;\end{}&lt;/code&gt;. I also don't really know LaTeX well enough to vouch for its robustness in all documents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it works quite well for simple cases, and should be enough to get you started on a more complete solution.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-02-14T09:53:32.860" LastActivityDate="2020-02-14T09:53:32.860" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22866" PostTypeId="1" AcceptedAnswerId="22867" CreationDate="2020-02-13T19:41:24.503" Score="1" ViewCount="41" Body="&lt;p&gt;Known: &lt;code&gt;&amp;lt;Ctrl&amp;gt;w&lt;/code&gt; then any of &lt;code&gt;hjkl&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Known: &lt;code&gt;:tab_&amp;lt;CR&amp;gt;&lt;/code&gt; where &lt;code&gt;_&lt;/code&gt; is either &lt;code&gt;rlpn&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is there not  a &lt;code&gt;&amp;lt;Ctrl&amp;gt;&lt;/code&gt; navigation for tabs nor a &lt;code&gt;:&lt;/code&gt; for splits? Why do the navigation commands differ in terminology?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One does not seek &lt;code&gt;nmap&lt;/code&gt; solutions; one wants to learn Vim's native wormholes.&lt;/p&gt;&#xA;" OwnerUserId="25873" LastEditorUserId="10604" LastEditDate="2020-02-14T02:17:42.730" LastActivityDate="2020-02-14T02:17:42.730" Title="Why are split and tab navigations distinct?" Tags="|key-bindings|split|tabbed-user-interface|navigation|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22867" PostTypeId="2" ParentId="22866" CreationDate="2020-02-13T21:24:05.533" Score="4" Body="&lt;p&gt;Tab navigation is one dimensional, so it has commands which mirror similar commands, &lt;code&gt;:bn&lt;/code&gt;, &lt;code&gt;:cp&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Window navigation is two dimensional, so it has commands that align with the two dimensional normal mode motions, &lt;code&gt;hjkl&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should also be noted, in addition to the commands you listed, there are also both normal mode tab navigation commands: &lt;code&gt;gt&lt;/code&gt;, &lt;code&gt;gT&lt;/code&gt;, and command line window navigation commands: &lt;code&gt;:wincmd h&lt;/code&gt;, &lt;code&gt;:wincmd j&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-02-13T21:24:05.533" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22868" PostTypeId="1" CreationDate="2020-02-13T21:33:07.023" Score="2" ViewCount="892" Body="&lt;p&gt;I work on my dotfiles periodically throughout my day work or non work related (that bonsai tree that's never done). I've written a couple of markdown documents that have become rather large to navigate in vim and for the most part i just go to the top of the document using &lt;kbd&gt;gg&lt;/kbd&gt; in command mode to search for what it is i'm looking for. it works a portion of the time, but it'd be ideal if i could navigate a markdown document &lt;code&gt;.md&lt;/code&gt; using &lt;a href=&quot;https://ctags.io&quot; rel=&quot;nofollow noreferrer&quot;&gt;universal-ctags&lt;/a&gt; as most of the documents i work with have a TOC within them, so popping open the TOC within the document and doing a &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;]&lt;/kbd&gt; to go to the heading under my cursor could become super useful for navigating my markdown documents, (a local wiki of notes i maintain for referencing tips tricks and howto's throughout my day).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;universal-ctags comes with some regex matching for &lt;code&gt;.md&lt;/code&gt; (Markdown) documents out of the box, and i can navigate to a heading that does not have spaces in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example: markdown document structure&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;git-Notes.md&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;&amp;lt;a id=&quot;contents&quot;&amp;gt;&amp;lt;/a&amp;gt;&#xA;&#xA;## Contents&#xA;&#xA; - [Gotchas](#git-gotchas)&#xA; - [Useful Links](#useful-links)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I move the cursor under &lt;code&gt;[Gotchas]&lt;/code&gt; and i'm able to move to that particular position in the document using ctags, but if i try to navigate to the &lt;code&gt;[Useful Links]&lt;/code&gt; section of the document it's a &lt;em&gt;no go&lt;/em&gt; as I'm pretty sure uctags is running into an issue with the heading containing a &lt;em&gt;space&lt;/em&gt; within it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I literally was able to get ctags installed just a few days, and, that was a completely &lt;a href=&quot;https://github.com/universal-ctags/homebrew-universal-ctags/issues/23#issuecomment-583781848&quot; rel=&quot;nofollow noreferrer&quot;&gt;separate issue upon itself&lt;/a&gt;, but i do have &lt;em&gt;uctags&lt;/em&gt; installed and working now, but have no idea how it uses regex's to aid in the generation of a &lt;code&gt;tags&lt;/code&gt; file for a particular project / repo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously the more information one could provide the better it would be in helping understand what is going on, as I've tried a couple of different regex examples on the internet, and they seem to fail, either in building the &lt;code&gt;tags&lt;/code&gt; file due to a syntax error thus preventing a &lt;code&gt;tags&lt;/code&gt; file being generated at all, or they fail in navigating through headings that contain &lt;em&gt;spaces&lt;/em&gt; in them, ie. &lt;em&gt;Useful Links&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="10550" LastActivityDate="2020-02-14T05:14:32.293" Title="navigating markdown documents using ctags with vim and neovim" Tags="|ctags|filetype-markdown|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22869" PostTypeId="1" CreationDate="2020-02-13T22:57:56.697" Score="8" ViewCount="4230" Body="&lt;p&gt;At work I use neovim on Windows, and set the shell to bash using the bash executable that comes with Git for Windows (gitbash), which is in my PATH. The settings in the minimal init.vim pasted below mean that &lt;em&gt;almost&lt;/em&gt; everything works as expected, but either reading or writing temporary files does not.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;win32&quot;)&#xA; let &amp;amp;shell='bash.exe'&#xA; let &amp;amp;shellcmdflag = '-c'&#xA; let &amp;amp;shellredir = '&amp;gt;%s 2&amp;gt;&amp;amp;1'&#xA; set shellquote= shellxescape=&#xA; &quot; set noshelltemp&#xA; set shellxquote=&#xA; let &amp;amp;shellpipe='2&amp;gt;&amp;amp;1| tee'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, executing &lt;code&gt;:%!cat&lt;/code&gt; in nvim results in:&#xA;&lt;code&gt;E485: Cannot read file C:\Users\GREAF7~1.GLA\AppData\Local\Temp\nvimdVFZaL\1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I immediately check in that directory, there is indeed no such file, so  I assume writing the temp file is the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I uncomment the line &lt;code&gt;&quot; set noshelltemp&lt;/code&gt; then the command described will run successfully, but this isn't a solution because plugins such as Fugitive fail with temp-file related errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing (or not doing) wrong?&lt;/p&gt;&#xA;" OwnerUserId="26944" LastActivityDate="2020-03-18T18:01:45.340" Title="How can neovim on Windows be configured to use gitbash as the shell without breaking temp files?" Tags="|neovim|microsoft-windows|bash|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22870" PostTypeId="2" ParentId="22868" CreationDate="2020-02-14T05:14:32.293" Score="3" Body="&lt;p&gt;A simple approach (that fails if you have embedded code comments) is to do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global/^#/#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then type &lt;code&gt;:&lt;/code&gt; and the displayed line number of the match you want. You could assign the commands to a mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, yank the words you want to search and do &lt;code&gt;/^#\+ &amp;lt;C-r&amp;gt;&quot;&lt;/code&gt;, which could be assigned to an operator for fun: e.g., &lt;code&gt;ghi]&lt;/code&gt; would take you to the header matching for the words im brackets. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-02-14T05:14:32.293" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22871" PostTypeId="2" ParentId="22531" CreationDate="2020-02-14T10:05:52.057" Score="2" Body="&lt;p&gt;I do not know whether you have found a solution in the mean time, but&#xA;according to this post &lt;a href=&quot;https://stackoverflow.com/questions/606191/convert-bytes-to-a-string&quot;&gt;https://stackoverflow.com/questions/606191/convert-bytes-to-a-string&lt;/a&gt;&#xA;you have to decode the bytes object, so that the snippet becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet 'math(.*)math' &quot;math&quot; wr&#xA;`!p&#xA;import subprocess&#xA;code = match.group(1)&#xA;code = 'ToString[' + code + ',TeXForm]'&#xA;res = subprocess.check_output(['wolframscript', '-code', code])&#xA;snip.rv=res.decode('utf-8')&#xA;`&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by the way thank you for the very cool ideas you posted on &lt;a href=&quot;https://castel.dev/post/lecture-notes-1/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://castel.dev/post/lecture-notes-1/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26948" LastActivityDate="2020-02-14T10:05:52.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22872" PostTypeId="1" CreationDate="2020-02-14T11:00:56.753" Score="0" ViewCount="158" Body="&lt;p&gt;I've installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When run on an example script I get the expected output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ shadow test_shadowing.go &#xA;&#xA;test_shadowing.go:10:3: declaration of &quot;foo&quot; shadows declaration at line 8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when configuring ALE to use this shadow tool, it doesn't appear to notify me of any issues...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ale_go_govet_options = '-vettool=$(which shadow)'&#xA;let g:ale_linters = {'go': ['gopls']}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: I've also tried an absolute path instead of a subprocess (e.g. &lt;code&gt;let g:ale_go_govet_options = '-vettool=/Users/me/go/bin/shadow'&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I manually execute the shadow command from vim it works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!shadow '%'&#xA;&#xA;/Users/me/Code/test_shadowing.go:10:3: declaration of &quot;foo&quot; shadows declaration at line 8&#xA;&#xA;shell returned 3&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But of course I'd prefer ALE to highlight these issues to me.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;UPDATE&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I was asked to provide &lt;code&gt;:ALEInfo&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Current Filetype: go&#xA;Available Linters: ['bingo', 'gobuild', 'gofmt', 'golangci-lint', 'golint', 'gometalinter', 'gopls', 'gosimple', 'gotype', 'govet', 'golangserver', 'staticcheck']&#xA;   Linter Aliases:&#xA;'gobuild' -&amp;gt; ['go build']&#xA;'govet' -&amp;gt; ['go vet']&#xA;  Enabled Linters: ['gopls']&#xA; Suggested Fixers:&#xA;  'gofmt' - Fix Go files with go fmt.&#xA;  'goimports' - Fix Go files imports with goimports.&#xA;  'remove_trailing_lines' - Remove all blank lines at the end of a file.&#xA;  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.&#xA; Linter Variables:&#xA;let g:ale_go_go_executable = 'go'&#xA;let g:ale_go_golangci_lint_executable = 'golangci-lint'&#xA;let g:ale_go_golangci_lint_options = '--enable-all'&#xA;let g:ale_go_golangci_lint_package = 0&#xA;let g:ale_go_gopls_executable = 'gopls'&#xA;let g:ale_go_gopls_options = '--mode stdio'&#xA;let g:ale_go_langserver_executable = 'go-langserver'&#xA;let g:ale_go_langserver_options = ''&#xA; Global Variables:&#xA;let g:ale_cache_executable_check_failures = v:null&#xA;let g:ale_change_sign_column_color = 0&#xA;let g:ale_command_wrapper = v:null&#xA;let g:ale_completion_delay = v:null&#xA;let g:ale_completion_enabled = 0&#xA;let g:ale_completion_max_suggestions = v:null&#xA;let g:ale_echo_cursor = 1&#xA;let g:ale_echo_msg_error_str = 'Error'&#xA;let g:ale_echo_msg_format = '%code: %%s'&#xA;let g:ale_echo_msg_info_str = 'Info'&#xA;let g:ale_echo_msg_warning_str = 'Warning'&#xA;let g:ale_enabled = 1&#xA;let g:ale_fix_on_save = 0&#xA;let g:ale_fixers = {}&#xA;let g:ale_history_enabled = 1&#xA;let g:ale_history_log_output = 1&#xA;let g:ale_keep_list_window_open = 0&#xA;let g:ale_lint_delay = 200&#xA;let g:ale_lint_on_enter = 1&#xA;let g:ale_lint_on_filetype_changed = 1&#xA;let g:ale_lint_on_insert_leave = 1&#xA;let g:ale_lint_on_save = 1&#xA;let g:ale_lint_on_text_changed = 'normal'&#xA;let g:ale_linter_aliases = {}&#xA;let g:ale_linters = {'go': ['gopls']}&#xA;let g:ale_linters_explicit = 0&#xA;let g:ale_list_vertical = 0&#xA;let g:ale_list_window_size = 10&#xA;let g:ale_loclist_msg_format = '%code: %%s'&#xA;let g:ale_lsp_root = {}&#xA;let g:ale_max_buffer_history_size = v:null&#xA;let g:ale_max_signs = -1&#xA;let g:ale_maximum_file_size = v:null&#xA;let g:ale_open_list = 0&#xA;let g:ale_pattern_options = v:null&#xA;let g:ale_pattern_options_enabled = v:null&#xA;let g:ale_set_balloons = 0&#xA;let g:ale_set_highlights = 1&#xA;let g:ale_set_loclist = 1&#xA;let g:ale_set_quickfix = 0&#xA;let g:ale_set_signs = 1&#xA;let g:ale_sign_column_always = 0&#xA;let g:ale_sign_error = '✗'&#xA;let g:ale_sign_info = '▲'&#xA;let g:ale_sign_offset = 1000000&#xA;let g:ale_sign_style_error = '✗'&#xA;let g:ale_sign_style_warning = '▲'&#xA;let g:ale_sign_warning = '▲'&#xA;let g:ale_sign_highlight_linenrs = 0&#xA;let g:ale_statusline_format = v:null&#xA;let g:ale_type_map = {}&#xA;let g:ale_use_global_executables = v:null&#xA;let g:ale_virtualtext_cursor = 0&#xA;let g:ale_warn_about_trailing_blank_lines = 1&#xA;let g:ale_warn_about_trailing_whitespace = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22173" LastEditorUserId="22173" LastEditDate="2020-02-20T12:45:44.837" LastActivityDate="2020-02-20T12:45:44.837" Title="ALE ale_go_govet_options not working with Shadow command" Tags="|plugin-ale|filetype-go|plugin-vim-go|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22873" PostTypeId="1" AcceptedAnswerId="22878" CreationDate="2020-02-14T11:46:58.837" Score="5" ViewCount="453" Body="&lt;p&gt;I would like to use search in file with folded functions to search only in functions titles. But common vim search searches inside folding and unfolds any hidden text. Is there a way to search only in open text ignoring the rest?&lt;/p&gt;&#xA;" OwnerUserId="11971" LastActivityDate="2023-09-19T08:27:16.053" Title="How to search only in a text which is not folded?" Tags="|search|folding|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22874" PostTypeId="1" AcceptedAnswerId="22875" CreationDate="2020-02-14T16:00:15.983" Score="8" ViewCount="329" Body="&lt;p&gt;Let's say I recovered a bunch of swapfiles in quick succession:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim -r .swv&#xA;gvim -r .swu&#xA;gvim -r .swt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then cycled through them all a few times before finding that one of them was nonsense. I want to now know which swap file is represented by this buffer of useless contents, so that I may delete it so as not to have known garbage floating around on my hard drive. How can I switch to that buffer/window and then query the name of the swapfile associated with that particular buffer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="26954" LastActivityDate="2020-02-14T17:54:36.780" Title="How can I view the name of the swapfile being used for the current buffer?" Tags="|buffers|swap-file|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22875" PostTypeId="2" ParentId="22874" CreationDate="2020-02-14T17:22:35.520" Score="9" Body="&lt;pre&gt;&lt;code&gt;:swapname&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will show the filename of the swapfile for the current buffer. (For example: &lt;code&gt;/c/path/.swu&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this (after a few tries) by typeing &lt;kbd&gt;:&lt;/kbd&gt;&lt;kbd&gt;s&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;TAB&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also found this question: &lt;a href=&quot;https://vi.stackexchange.com/questions/16037/vim-swap-file-best-practices/#16047&quot;&gt;VIM swap-file best practices?&lt;/a&gt;, which includes some other interesting and useful commands.&lt;/p&gt;&#xA;" OwnerUserId="8458" LastEditorUserId="8458" LastEditDate="2020-02-14T17:54:36.780" LastActivityDate="2020-02-14T17:54:36.780" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22876" PostTypeId="2" ParentId="22528" CreationDate="2020-02-14T18:03:22.950" Score="3" Body="&lt;p&gt;The toggling in the terminal vim works fine for me if I do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let t:is_transparent = 0                     &#xA;function! Toggle_transparent_background()                      &#xA;  if t:is_transparent == 0                   &#xA;    hi Normal guibg=#111111 ctermbg=black                     &#xA;    let t:is_transparent = 1&#xA;  else&#xA;    hi Normal guibg=NONE ctermbg=NONE                    &#xA;    let t:is_transparent = 0                        &#xA;  endif                    &#xA;endfunction               &#xA;nnoremap &amp;lt;C-x&amp;gt;&amp;lt;C-t&amp;gt; :call Toggle_transparent_background()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19497" LastEditorUserId="2347" LastEditDate="2021-12-08T16:50:13.513" LastActivityDate="2021-12-08T16:50:13.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22878" PostTypeId="2" ParentId="22873" CreationDate="2020-02-15T02:39:58.717" Score="3" Body="&lt;p&gt;You could use &lt;code&gt;:folddoopen&lt;/code&gt; to capture the addresses of the lines which are not in open folds, then build a sub-expression describing those lines (see &lt;code&gt;:h \%l&lt;/code&gt;, &lt;code&gt;:h \%&amp;gt;l&lt;/code&gt;, &lt;code&gt;:h \%&amp;lt;l&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cno &amp;lt;c-o&amp;gt; &amp;lt;c-r&amp;gt;=&amp;lt;sid&amp;gt;limit_search_to_open_folds(1)&amp;lt;cr&amp;gt;&amp;lt;c-c&amp;gt;&#xA;fu s:limit_search_to_open_folds(step) abort&#xA;    if a:step == 1&#xA;        let s:pat = getcmdline()&#xA;        call timer_start(0, {-&amp;gt; s:limit_search_to_open_folds(2)})&#xA;    else&#xA;        let s:pat = get(s:, 'pat', '')..'\m\%('&#xA;        folddoopen let s:pat ..= '\%'..line('.')..'l\|'&#xA;        let s:pat = substitute(s:pat, '\\|$', '\\)', '')&#xA;        call feedkeys('/'..s:pat, 'in')&#xA;    endif&#xA;    return ''&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Write your pattern, then press &lt;code&gt;C-o&lt;/code&gt;.  It should append a sub-expression which limits the search to the lines which are not in closed folds.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If the sub-expression is too long, try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cno &amp;lt;c-o&amp;gt; &amp;lt;c-r&amp;gt;=&amp;lt;sid&amp;gt;limit_search_to_open_folds(1)&amp;lt;cr&amp;gt;&amp;lt;c-c&amp;gt;&#xA;fu s:limit_search_to_open_folds(step) abort&#xA;    if a:step == 1&#xA;        let s:cmdline = getcmdline()&#xA;        call timer_start(0, {-&amp;gt; s:limit_search_to_open_folds(2)})&#xA;    else&#xA;        let lnums = []&#xA;        folddoopen let lnums += [line('.')]&#xA;        let ranges = []&#xA;        for i in range(len(lnums))&#xA;            if i &amp;gt; 0 &amp;amp;&amp;amp; lnums[i] == lnums[i-1] + 1&#xA;                if type(ranges[-1]) == type(0)&#xA;                    let ranges[-1] = [ranges[-1], ranges[-1]+1]&#xA;                else&#xA;                    let ranges[-1][1] += 1&#xA;                endif&#xA;            else&#xA;                let ranges += [lnums[i]]&#xA;            endif&#xA;        endfor&#xA;        call map(ranges, {_,v -&amp;gt; type(v) == type(0) ? '\%'..v..'l' : '\%&amp;gt;'..(v[0]-1)..'l\%&amp;lt;'..(v[1]+1)..'l'})&#xA;        let pat = get(s:, 'cmdline', '')&#xA;            \ ..'\m\%('&#xA;            \ ..join(ranges, '\|')&#xA;            \ ..'\)'&#xA;        call feedkeys('/'..pat, 'in')&#xA;    endif&#xA;    return ''&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2020-02-15T02:39:58.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22879" PostTypeId="1" CreationDate="2020-02-15T05:18:52.923" Score="2" ViewCount="424" Body="&lt;p&gt;I've tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader=&quot;&amp;lt;C+k&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader=&quot;\&amp;lt;C+k&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it seems that both of them can't work.&lt;/p&gt;&#xA;" OwnerUserId="26960" LastActivityDate="2020-03-16T16:01:00.223" Title="How to set &lt;C+k&gt; as vim leader key?" Tags="|leader|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22880" PostTypeId="1" CreationDate="2020-02-15T06:22:19.243" Score="1" ViewCount="9339" Body="&lt;p&gt;I tried installing &lt;a href=&quot;https://github.com/ryanoasis/vim-devicons&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-devicons&lt;/a&gt; to be used with nerdtree(using vim-plugin). I tried &lt;a href=&quot;https://github.com/ryanoasis/vim-devicons/wiki/FAQ-&amp;amp;-Troubleshooting#why-isnt-it-working-how-come-i-dont-see-any-icons&quot; rel=&quot;nofollow noreferrer&quot;&gt;devicons FAQ&lt;/a&gt;, everything is fine except &quot;check if you are able to see the characters, from ex mode:&quot;, i tried running&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:echo g:WebDevIconsUnicodeDecorateFileNodesDefaultSymbol&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this command gives no icons result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also it says that devicons is to be used with &lt;a href=&quot;https://github.com/ryanoasis/nerd-fonts&quot; rel=&quot;nofollow noreferrer&quot;&gt;NerdFonts&lt;/a&gt;, I had trouble installing that. Can anybody guide me through the commands used to install &lt;a href=&quot;https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Ubuntu/Regular/complete&quot; rel=&quot;nofollow noreferrer&quot;&gt;regular ubuntu font&lt;/a&gt; on my ubuntu 18.04?&lt;/p&gt;&#xA;" OwnerUserId="26961" LastActivityDate="2020-02-15T13:38:53.353" Title="Vim-devicons not working at all" Tags="|plugin-nerdtree|linux-ubuntu|plugin-devicons|" AnswerCount="1" CommentCount="2" ClosedDate="2020-02-17T10:00:25.347" ContentLicense="CC BY-SA 4.0" />
  <row Id="22881" PostTypeId="1" CreationDate="2020-02-15T07:04:45.047" Score="0" ViewCount="1647" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/preservim/nerdtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nerd-tree&lt;/a&gt; for vim. Whenever I use &lt;code&gt;:NERDTreeToggle&lt;/code&gt; key, it opens up two directory windows instead of one, like so&lt;a href=&quot;https://i.stack.imgur.com/c2COr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/c2COr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's only when I type &lt;code&gt;:q&lt;/code&gt;on one of the windows does it become like this&#xA;&lt;a href=&quot;https://i.stack.imgur.com/nPFt9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nPFt9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;strong&gt;How do I get it to only open one window on pressing the nerd-toggle key?&lt;/strong&gt;&#xA;Here's the &lt;a href=&quot;https://gist.github.com/benawad/b768f5a5bbd92c8baabd363b7e79786f&quot; rel=&quot;nofollow noreferrer&quot;&gt;content of my .vimrc&lt;/a&gt;(not created by me).&lt;/p&gt;&#xA;" OwnerUserId="26961" LastActivityDate="2021-07-17T17:09:22.690" Title="NerdTreeToggle always opens up two directory windows instead of one" Tags="|plugin-nerdtree|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22882" PostTypeId="2" ParentId="22879" CreationDate="2020-02-15T07:05:01.717" Score="3" Body="&lt;p&gt;The correct syntax is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader=&quot;\&amp;lt;C-k&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works as expected.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-15T07:05:01.717" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22883" PostTypeId="2" ParentId="22881" CreationDate="2020-02-15T08:51:38.073" Score="1" Body="&lt;p&gt;I found &lt;a href=&quot;https://stackoverflow.com/questions/1759737/auto-open-nerdtree-in-vim&quot;&gt;this answer.&lt;/a&gt; Putting this code in my .vimrc file helped solve the issue, now I only get one directory window instead of two.&lt;br&gt;&#xA;&lt;code&gt;au VimEnter *  NERDTree&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="26961" LastActivityDate="2020-02-15T08:51:38.073" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22884" PostTypeId="1" CreationDate="2020-02-15T12:12:31.020" Score="10" ViewCount="5468" Body="&lt;p&gt;I try to delete some non-empty folder in netrw by pressing &lt;kbd&gt;Shift d&lt;/kbd&gt; and, after press &lt;code&gt;y&lt;/code&gt;, I got this error:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;(netrw) unable to delete directory {path}&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;I already put this variable in my &lt;code&gt;.config/nvim/init.vim&lt;/code&gt; file and doesn't works: &lt;code&gt;let g:netrw_localrmdir='rm -r'&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;As I read, this variable only works with vim 7.4 and earlier.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to delete non-empty directories with netrw in Vim 8+ or Neovim?&lt;/p&gt;&#xA;&lt;p&gt;My setup:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;OS: MacOs Catalina&#xA;NVIM v0.4.3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;My intention is to use as few plugins as possible, but, &lt;code&gt;netrw&lt;/code&gt; has some other bugs, so U gave up using &lt;code&gt;netrw&lt;/code&gt; and installed &lt;code&gt;NERDTree&lt;/code&gt; again.&lt;/p&gt;&#xA;" OwnerUserId="26842" LastEditorUserId="23502" LastEditDate="2023-04-04T08:31:06.483" LastActivityDate="2023-04-04T08:31:06.483" Title="How to delete non-empty directories in netrw (Vim 8 or Neovim)?" Tags="|neovim|netrw|vim8|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22885" PostTypeId="2" ParentId="22880" CreationDate="2020-02-15T13:38:53.353" Score="3" Body="&lt;p&gt;Installing &lt;a href=&quot;https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Ubuntu/Regular/complete&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nerd fonts&lt;/a&gt; for my ubuntu 18.04 &lt;strong&gt;&lt;em&gt;worked&lt;/em&gt;&lt;/strong&gt;. As the devicons &lt;a href=&quot;https://github.com/ryanoasis/vim-devicons/wiki/FAQ-&amp;amp;-Troubleshooting&quot; rel=&quot;nofollow noreferrer&quot;&gt;FAQ&lt;/a&gt; page said, it was designed for nerd fonts.&lt;/p&gt;&#xA;" OwnerUserId="26961" LastActivityDate="2020-02-15T13:38:53.353" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22886" PostTypeId="1" AcceptedAnswerId="22889" CreationDate="2020-02-15T14:15:54.377" Score="5" ViewCount="1762" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How to highlight all occurrences of a search without moving the cursor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I want to highlight all occurrences of a word in the neighbourhood of the cursor without moving the cursor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, if I use &lt;code&gt;*&lt;/code&gt; or &lt;code&gt;#&lt;/code&gt; to highlight all occurrences of the word under the cursor, then I have to press &lt;code&gt;N&lt;/code&gt; to get back.&lt;/p&gt;&#xA;" OwnerUserId="26505" LastActivityDate="2020-02-15T16:57:35.880" Title="How to highlight all occurrences of a search without moving the cursor?" Tags="|search|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22887" PostTypeId="2" ParentId="22886" CreationDate="2020-02-15T14:26:36.407" Score="1" Body="&lt;p&gt;Maybe like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;h :execute 'match Search /\V'..escape(expand('&amp;lt;cword&amp;gt;'), '\/')..'/'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But note that you'll need &lt;code&gt;:match none&lt;/code&gt; to switch it off.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-15T14:26:36.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22888" PostTypeId="2" ParentId="22886" CreationDate="2020-02-15T15:10:31.617" Score="3" Body="&lt;p&gt;Traditionally, one uses a mapping like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap * *N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using matches and cursorhold has also been done&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-02-15T15:10:31.617" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22889" PostTypeId="2" ParentId="22886" CreationDate="2020-02-15T15:13:32.143" Score="7" Body="&lt;p&gt;I have run into the same problem before and spent some time to figure it out. Here is my answer. It works great.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Space&amp;gt;* &amp;lt;Cmd&amp;gt;let @/='\&amp;lt;'.expand('&amp;lt;cword&amp;gt;').'\&amp;gt;'&amp;lt;bar&amp;gt;set hlsearch&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/&lt;/code&gt; is a register which stores search pattern. We use &lt;code&gt;let&lt;/code&gt; command to set it to the pattern you want to search and set hightlight to ensure it will be hightlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, the above only works in &lt;code&gt;neovim&lt;/code&gt;. If you are using normal &lt;code&gt;vim&lt;/code&gt;, it should be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;Space&amp;gt;* :let @/='\&amp;lt;'.expand('&amp;lt;cword&amp;gt;').'\&amp;gt;'&amp;lt;bar&amp;gt;set hlsearch&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25618" LastEditorUserId="25618" LastEditDate="2020-02-15T16:57:35.880" LastActivityDate="2020-02-15T16:57:35.880" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22890" PostTypeId="2" ParentId="22879" CreationDate="2020-02-15T15:47:01.653" Score="2" Body="&lt;p&gt;filbranden is right. Another solution would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader=&quot;^K&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^K&lt;/code&gt; is inserted by typing &lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;C-K&amp;gt;&lt;/code&gt;.&#xA;A key typed after &lt;code&gt;&amp;lt;C-V&amp;gt;&lt;/code&gt; will be inserted literally. It's very useful. See &lt;code&gt;:h i_CTRL-V&lt;/code&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="25618" LastEditorUserId="25618" LastEditDate="2020-02-15T15:52:11.753" LastActivityDate="2020-02-15T15:52:11.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22891" PostTypeId="1" AcceptedAnswerId="22893" CreationDate="2020-02-15T15:57:36.797" Score="2" ViewCount="320" Body="&lt;p&gt;I want a shortcut for evaluating a yanked expression and pasting the result after the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I've written &lt;code&gt;i1+1&amp;lt;ESC&amp;gt;0y$$&lt;/code&gt;, now I'd like to paste the result of that, &lt;code&gt;2&lt;/code&gt;, after the cursor. Is that possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can take that expression and replace it using bc, e.g. &lt;code&gt;i1+1&amp;lt;ESC&amp;gt;!!bc&amp;lt;CR&amp;gt;&lt;/code&gt;, but that's not what I want (although it's quite neat).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can evaluate expressions and insert them into the text using &lt;code&gt;i&amp;lt;C-R&amp;gt;=1+1&amp;lt;CR&amp;gt;&lt;/code&gt;. I have &lt;code&gt;set clipboard=unnamedplus&lt;/code&gt; so I could take my yanked expression and paste it with ctrl+shift+v into the &lt;code&gt;i&amp;lt;C-R&amp;gt;=&lt;/code&gt; prompt, and then I pretty much have what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now then, how do I create a shortcut of that, i.e. of (pseudo) &lt;code&gt;i&amp;lt;C-R&amp;gt;=&amp;lt;C-Shift-V&amp;gt;&amp;lt;CR&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you know any other way of doing this sort of thing then that's fine too, thanks.&lt;/p&gt;&#xA;" OwnerUserId="15223" LastActivityDate="2020-02-15T17:05:19.120" Title="Calculate expression and paste after cursor" Tags="|expression-register|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22892" PostTypeId="1" CreationDate="2020-02-15T16:01:32.463" Score="4" ViewCount="408" Body="&lt;p&gt;For the python command vim uses the python exetuable it finds first in the $PATH variable. However, for me this can change depending what project I work on (using virtual environments). Is there a way to fix this to one particular executable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB. On the internet I find a lot of sources vim uses the python executable it is compiled with. It seems this has changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output of &lt;code&gt;:version&lt;/code&gt; of vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Nov 09 2019 12:59:40)&#xA;Included patches: 1-2269&#xA;Modified by team+vim@tracker.debian.org&#xA;Compiled by team+vim@tracker.debian.org&#xA;Huge version with GTK3 GUI.  Features included (+) or not (-):&#xA;+acl               +cmdline_compl     +emacs_tags        +insert_expand     +modify_fname      +netbeans_intg     +ruby              +termguicolors     +visualextra&#xA;+arabic            +cmdline_hist      +eval              +job               +mouse             +num64             +scrollbind        +terminal          +viminfo&#xA;+autocmd           +cmdline_info      +ex_extra          +jumplist          +mouseshape        +packages          +signs             +terminfo          +vreplace&#xA;+autochdir         +comments          +extra_search      +keymap            +mouse_dec         +path_extra        +smartindent       +termresponse      +wildignore&#xA;-autoservername    +conceal           -farsi             +lambda            +mouse_gpm         +perl              +sound             +textobjects       +wildmenu&#xA;+balloon_eval      +cryptv            +file_in_path      +langmap           -mouse_jsbterm     +persistent_undo   +spell             +textprop          +windows&#xA;+balloon_eval_term +cscope            +find_in_path      +libcall           +mouse_netterm     +postscript        +startuptime       +timers            +writebackup&#xA;+browse            +cursorbind        +float             +linebreak         +mouse_sgr         +printer           +statusline        +title             +X11&#xA;++builtin_terms    +cursorshape       +folding           +lispindent        -mouse_sysmouse    +profile           -sun_workshop      +toolbar           -xfontset&#xA;+byte_offset       +dialog_con_gui    -footer            +listcmds          +mouse_urxvt       -python            +syntax            +user_commands     +xim&#xA;+channel           +diff              +fork()            +localmap          +mouse_xterm       +python3           +tag_binary        +vartabs           +xpm&#xA;+cindent           +digraphs          +gettext           +lua               +multi_byte        +quickfix          -tag_old_static    +vertsplit         +xsmp_interact&#xA;+clientserver      +dnd               -hangul_input      +menu              +multi_lang        +reltime           -tag_any_white     +virtualedit       +xterm_clipboard&#xA;+clipboard         -ebcdic            +iconv             +mksession         -mzscheme          +rightleft         +tcl               +visual            -xterm_save&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0&#xA;-I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/libdrm -I/usr/include/pango-1.0 -I/usr/includ&#xA;e/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/us&#xA;r/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time  -&#xA;g -O2 -fdebug-prefix-map=/build/vim-yrDlon/vim-8.1.2269=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -L. -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lpangocairo-&#xA;1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinu&#xA;x  -lcanberra -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.30/CORE -lperl -ldl -lm -lpthrea&#xA;d -lcrypt  -L/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu -lpython3.7m -lcrypt -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-2.&#xA;5 -lpthread -lgmp -ldl -lcrypt -lm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18386" LastEditorUserId="10604" LastEditDate="2020-02-15T20:37:11.183" LastActivityDate="2020-02-15T20:37:11.183" Title="How to fix which python executable vim is using?" Tags="|vimscript-python|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22893" PostTypeId="2" ParentId="22891" CreationDate="2020-02-15T17:05:19.120" Score="2" Body="&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html?#c_CTRL-R&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;C-R&amp;gt;&lt;/code&gt;&lt;/a&gt; from the prompt of the &lt;code&gt;=&lt;/code&gt; expression to insert the contents of a register. For example, &lt;code&gt;&amp;lt;C-R&amp;gt;&quot;&lt;/code&gt; for the contents of the default register, which is where your yanked expression is stored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would work to insert the result of the expression in the default register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i&amp;lt;C-R&amp;gt;=&amp;lt;C-R&amp;gt;&quot;&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;&amp;lt;C-R&amp;gt;.&lt;/code&gt; for your last insertion (so you don't even need to yank an expression.) After &lt;code&gt;i1+1&amp;lt;Esc&amp;gt;&lt;/code&gt;, you can use &lt;code&gt;i&amp;lt;C-R&amp;gt;=&amp;lt;C-R&amp;gt;.&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to insert the result of the inserted expression at the current location.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-15T17:05:19.120" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22894" PostTypeId="1" CreationDate="2020-02-15T21:59:10.943" Score="2" ViewCount="46" Body="&lt;p&gt;I have the &lt;code&gt;display&lt;/code&gt; option set to &lt;code&gt;lastline&lt;/code&gt; so that the last line is shown even if all it doesn't fit on the window. When moving down visual lines with &lt;code&gt;gj&lt;/code&gt; to the last line that is only partially visible, vim seems to scroll the window down extra visual lines so that the whole line is visible. This leads to a 'jumpy' scrolling, and it is especially obnoxious if a logical line spans across many visual lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, a gif of the 'jump' when moving to the last line:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4nY3e.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4nY3e.gif&quot; alt=&quot;Screen cap gif showing the &amp;#39;jump&amp;#39;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar behavior occurs when moving above to a logical line that does not fit in one visual line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I go about removing this 'jump' that vim does to fit the line on the window?&lt;/p&gt;&#xA;" OwnerUserId="26972" LastActivityDate="2020-02-15T21:59:10.943" Title="Remove 'jumps' when moving to last and first line in Vim" Tags="|cursor-movement|scrolling|multiple-lines|" AnswerCount="0" CommentCount="1" ClosedDate="2020-08-04T14:48:30.903" ContentLicense="CC BY-SA 4.0" />
  <row Id="22895" PostTypeId="1" AcceptedAnswerId="22899" CreationDate="2020-02-16T02:13:20.310" Score="0" ViewCount="107" Body="&lt;p&gt;If I press &lt;kbd&gt;Alt&lt;/kbd&gt;&lt;kbd&gt;o&lt;/kbd&gt;, it prints &lt;code&gt;ï&lt;/code&gt;. I would prefer it not do&#xA;anything. I tried these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:unmap &amp;lt;M-o&amp;gt;&#xA;:iunmap &amp;lt;M-o&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it just says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E31: No such mapping&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the comments, I have also tried these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gvim -u NONE -N&#xA;gvim --clean&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I tried the release without runtime files as well:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://ftp.nluug.nl/pub/vim/pc/gvim82.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://ftp.nluug.nl/pub/vim/pc/gvim82.zip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;also &lt;code&gt;set keymap&lt;/code&gt; returns &lt;code&gt;keymap=&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="7184" LastEditDate="2020-02-16T06:18:58.577" LastActivityDate="2020-03-17T12:59:39.450" Title="Unmap accented characters" Tags="|key-bindings|gvim|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22897" PostTypeId="1" CreationDate="2020-02-16T05:45:54.477" Score="3" ViewCount="1817" Body="&lt;p&gt;Say I have a couple of .py files open in vim.&lt;br&gt;&#xA;How do I ensure that the previous setup will be opened as it is every time I start vim(&lt;strong&gt;Just like VS code&lt;/strong&gt;).&lt;/p&gt;&#xA;" OwnerUserId="26961" LastEditorUserId="26961" LastEditDate="2020-02-16T06:49:57.857" LastActivityDate="2020-02-16T16:06:02.453" Title="How to get the previous session every time I start vim?" Tags="|vimrc|" AnswerCount="3" CommentCount="1" ClosedDate="2020-02-17T16:22:30.030" ContentLicense="CC BY-SA 4.0" />
  <row Id="22898" PostTypeId="2" ParentId="22897" CreationDate="2020-02-16T06:49:44.360" Score="3" Body="&lt;p&gt;Found 3 answers-&lt;br&gt;&#xA;1) Place these in your ~/.vimrc to write and load sessions with F2, F3&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;F2&amp;gt; :mksession! ~/vim_session &amp;lt;cr&amp;gt; &quot; Quick write session with F2&#xA;map &amp;lt;F3&amp;gt; :source ~/vim_session &amp;lt;cr&amp;gt;     &quot; And load session with F3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/1416572/vi-vim-restore-opened-files&quot;&gt;1st&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Put this in your ~/.vimrc to automate the process&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Automatically save the session when leaving Vim&#xA;autocmd! VimLeave * mksession&#xA;&quot; Automatically load the session when entering vim&#xA;autocmd! VimEnter * source ~/Session.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/7867/remember-previous-session&quot;&gt;2nd&lt;/a&gt;(though this requires ~/Session.vim)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;3)More information&#xA;&lt;a href=&quot;https://vimhelp.org/starting.txt.html?#session-file&quot; rel=&quot;nofollow noreferrer&quot;&gt;3rd&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26961" LastActivityDate="2020-02-16T06:49:44.360" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22899" PostTypeId="2" ParentId="22895" CreationDate="2020-02-16T07:32:08.147" Score="0" Body="&lt;p&gt;This works for upper and lower:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;M-O&amp;gt; &amp;lt;Nop&amp;gt;&#xA;imap &amp;lt;M-o&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-02-16T07:32:08.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22900" PostTypeId="1" AcceptedAnswerId="22925" CreationDate="2020-02-16T07:36:14.420" Score="1" ViewCount="309" Body="&lt;p&gt;What I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :nnoremap &amp;lt;C-w&amp;gt;n &amp;lt;Enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Expected result:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When pressing &lt;kbd&gt;Ctrl+w&lt;/kbd&gt; then &lt;kbd&gt;n&lt;/kbd&gt;, just an &lt;kbd&gt;Enter&lt;/kbd&gt; is simulated rather than horizontally splitting a window. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Actual result: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The mapping sometimes works but sometimes not.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What I noticed:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When lhs of &lt;code&gt;:map&lt;/code&gt; is of the form &lt;code&gt;&amp;lt;C-X&amp;gt;Y&lt;/code&gt; where &lt;code&gt;X&lt;/code&gt; and &lt;code&gt;Y&lt;/code&gt; are arbitrary characteres, mapping works only when you press &lt;kbd&gt;Ctrl+X&lt;/kbd&gt; and then &lt;strong&gt;rapidly&lt;/strong&gt; press &lt;kbd&gt;Y&lt;/kbd&gt;. If there is a delay (maybe hundreds milliseconds or so) before pressing &lt;kbd&gt;Y&lt;/kbd&gt;, mapping does not work and original key-binding is used. By &quot;original key-binding&quot;, I mean the un-mapped version of &lt;kbd&gt;Ctrl+X&lt;/kbd&gt; + &lt;kbd&gt;Y&lt;/kbd&gt;, not just &lt;kbd&gt;Y&lt;/kbd&gt;. So it seems this strange behavior doesn't come from time-out of &lt;kbd&gt;Ctrl+X&lt;/kbd&gt;. (If so, it would be natural that un-mapped version of &lt;strong&gt;just&lt;/strong&gt; &lt;kbd&gt;Y&lt;/kbd&gt; is simulated.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Environment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~ $ vi --version&#xA;VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Feb 15 2020 13:52:40)&#xA;Included patches: 1-259&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I map to Ctrl+w n? Or does the behavior natural?&lt;/p&gt;&#xA;" OwnerUserId="16502" LastEditorUserId="16502" LastEditDate="2020-02-16T07:58:52.980" LastActivityDate="2020-02-18T04:15:39.653" Title="Mapping sometimes works but sometimes not" Tags="|key-bindings|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22901" PostTypeId="1" AcceptedAnswerId="22902" CreationDate="2020-02-16T09:18:32.920" Score="3" ViewCount="2585" Body="&lt;p&gt;I want to replace all adjacent spaces with one space but the replacement should only take place if they aren't at the line begin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example (I use brackets to demarcate line begin and end):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Hello,     world!   ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be replaced with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Hello, world! ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[     Hello,     world!   ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[     Hello, world! ]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.s/\v([^\s])(\s){2,}/\1\2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it replaces leading spaces too. I'm not sure why it's applied to leading spaces. Because I explicitly tell vim to replace only those adjacent spaces who follow a non-whitespace character &lt;code&gt;...[^\s]...&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is the line begin character &lt;code&gt;^&lt;/code&gt; considered as a character and I've to involve it either?&#xA;Ok, I also tried this one but without success:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.s/\v([^\s^])(\s){2,}/\1\2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I'm lost here...&lt;/p&gt;&#xA;" OwnerUserId="18651" LastActivityDate="2020-02-16T11:53:49.420" Title="Replace multiple spaces with one" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22902" PostTypeId="2" ParentId="22901" CreationDate="2020-02-16T09:47:09.430" Score="4" Body="&lt;p&gt;&lt;code&gt;\s&lt;/code&gt; doesn't work in &lt;code&gt;[]&lt;/code&gt;. It seems that only &lt;code&gt;\t&lt;/code&gt; works. Weird, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, &lt;code&gt;\S&lt;/code&gt; is the opposite of &lt;code&gt;\s&lt;/code&gt;. Use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\S\zs\s\+/ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It substitute all whitespaces following a non-whitespace character with one space.&#xA;&lt;code&gt;\zs&lt;/code&gt; restarts the match so &lt;code&gt;\S&lt;/code&gt; is not replaced.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I also figured out a hard way to retain the type of whitespace (tab or space):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\v(^\s*\S.{-})@&amp;lt;=(\s)\2+/\2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;@&amp;lt;=&lt;/code&gt; is like &lt;code&gt;\zs&lt;/code&gt; with a little difference. &lt;code&gt;^\s*&lt;/code&gt; matches leading whitespaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;\2&lt;/code&gt; is the same as &lt;code&gt;\s&lt;/code&gt;: If &lt;code&gt;\s&lt;/code&gt; matches tab, then &lt;code&gt;\2&lt;/code&gt; must be tab, no space, and vice versa.&lt;/p&gt;&#xA;" OwnerUserId="25618" LastEditorUserId="25618" LastEditDate="2020-02-16T11:53:49.420" LastActivityDate="2020-02-16T11:53:49.420" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22903" PostTypeId="1" AcceptedAnswerId="22906" CreationDate="2020-02-16T14:50:58.610" Score="3" ViewCount="1094" Body="&lt;p&gt;I have several open buffers and want to open a buffer in &lt;code&gt;:ls&lt;/code&gt; in a new tab or window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found a way to do accomplish this, either by first executing &lt;code&gt;tabnew&lt;/code&gt; or &lt;code&gt;C-w v&lt;/code&gt; and then selecting the buffer using &lt;code&gt;:b&amp;lt;N&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can the same be accomplished using a single command?&lt;/p&gt;&#xA;" OwnerUserId="26505" LastActivityDate="2020-02-16T15:30:56.440" Title="How to create a new tab or window from a buffer?" Tags="|buffers|tabbed-user-interface|command-line-window|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22904" PostTypeId="2" ParentId="22897" CreationDate="2020-02-16T14:57:57.650" Score="6" Body="&lt;p&gt;The other answer recommends using sessions, which is correct, but I’m not a huge fan of blindly always creating them and restoring them. Sometimes I don’t want that, and then this would get in my way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, I recommend one of two approaches:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Manually run &lt;code&gt;:mksession&lt;/code&gt; when you want one; or,&lt;/li&gt;&#xA;&lt;li&gt;Install tpope’s Obsession plugin, and tun &lt;code&gt;:Obsession&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;With either one, you can jump into the session with &lt;code&gt;vim -S sessionfile.vim&lt;/code&gt;. Since both the vim commands and the &lt;code&gt;-S&lt;/code&gt; option default to the name &lt;code&gt;Session.vim&lt;/code&gt;, there’s very little typing (&lt;code&gt;vim -S&lt;/code&gt; is usually enough).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The big things Obsession provides are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;only storing sane things in the session, and&lt;/li&gt;&#xA;&lt;li&gt;automatically keeping the session file up-to-date&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-02-16T14:57:57.650" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22905" PostTypeId="1" AcceptedAnswerId="22915" CreationDate="2020-02-16T15:05:46.040" Score="2" ViewCount="148" Body="&lt;p&gt;In gvim the command &lt;code&gt;:browse confirm e&lt;/code&gt; launches a GTK file browser. The default file mask in this window depends on the filetype from which the browse window is invoked. I would like to change that default file mask depending on the filetype. For example from &lt;code&gt;.cpp&lt;/code&gt; file the mask is &lt;code&gt;*.cpp *.c++&lt;/code&gt; and I want to add &lt;code&gt;*.hpp *.ipp&lt;/code&gt; there. From python file the mask is &lt;code&gt;*.py&lt;/code&gt; I would like it to be &lt;code&gt;*&lt;/code&gt;. And so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use gvim version 8.1.141 on linux devuan beowulf.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gwwt1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gwwt1.png&quot; alt=&quot;The GTK browser invoked by gvim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I could not find proper tags for this question, I tried to use tags: file browser, gtk, wildcard, glob, mask)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far by grepping gvim sources I have found:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;grep -E &quot;\*\.cpp \*\.c++&quot; . -r --color&#xA;&#xA;./runtime/ftplugin/pyrex.vim:                   \ &quot;C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n&quot; .&#xA;./runtime/ftplugin/c.vim:    let b:browsefilter = &quot;C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n&quot; .&#xA;./runtime/ftplugin/c.vim:         \ &quot;C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n&quot; .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So what is &lt;code&gt;b:browsefilter&lt;/code&gt; and how to use it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:h browsefilter&lt;/code&gt; says that &quot;You can override the filter setting on a per-buffer basis by setting the b:browsefilter variable.&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I want to override it not per-buffer, but per-filetype from where the browse dialog was invoked.&lt;/p&gt;&#xA;" OwnerUserId="14986" LastEditorUserId="14986" LastEditDate="2020-02-16T17:11:58.833" LastActivityDate="2020-02-17T07:50:59.520" Title="How to change in gvim GTK file browser the default file mask wildcard (glob)?" Tags="|gvim|linux|options|filetype-c++|load|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22906" PostTypeId="2" ParentId="22903" CreationDate="2020-02-16T15:26:30.003" Score="6" Body="&lt;p&gt;Create a new window from a buffer: &lt;code&gt;:sb&amp;lt;N&amp;gt;&lt;/code&gt;(horizontally) or &lt;code&gt;:vert sb&amp;lt;N&amp;gt;&lt;/code&gt;(vertically).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a new tab from a buffer: &lt;code&gt;:tab sb&amp;lt;N&amp;gt;&lt;/code&gt;&#xA;        or create a new window and then press &lt;code&gt;&amp;lt;C-W&amp;gt;T&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="25618" LastActivityDate="2020-02-16T15:26:30.003" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22907" PostTypeId="2" ParentId="22903" CreationDate="2020-02-16T15:30:56.440" Score="5" Body="&lt;p&gt;While editing command line a &quot;special&quot; &lt;code&gt;#n&lt;/code&gt; (see &lt;code&gt;:h cmdline-special&lt;/code&gt;) is replaced with the n-th buffer name. Hence, all of the following work in Vim (&lt;code&gt;:h 42&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:edit #42&#xA;:split #42&#xA;:tabedit #42&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And so on.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-16T15:30:56.440" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22908" PostTypeId="2" ParentId="22897" CreationDate="2020-02-16T16:06:02.453" Score="2" Body="&lt;p&gt;Currently I use the following approach which I find both compact and flexible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimStartup | au!&#xA;    &quot; ... other stuff here&#xA;    &quot; save session on exit (:h v:this_session)&#xA;    autocmd VimLeavePre *&#xA;        \   if !empty(v:this_session)&#xA;        \ |     execute 'mksession!' v:this_session&#xA;        \ | endif&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if using &lt;code&gt;vim -S&lt;/code&gt; or &lt;code&gt;nvim &quot;+so ~/Session.vim&quot;&lt;/code&gt; to start then the session will be both loaded and saved. Otherwise nothing will happen. &quot;To start tracking&quot; session manually simply use &lt;code&gt;:so ~/Session.vim&lt;/code&gt; or &lt;code&gt;:mks!&lt;/code&gt; anytime. Then &quot;stop tracking&quot; session with &lt;code&gt;:let v:this_session = ''&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I found no use in installing an extra plugin for session management.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-16T16:06:02.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22909" PostTypeId="1" CreationDate="2020-02-16T20:17:03.907" Score="1" ViewCount="49" Body="&lt;p&gt;I would like to create a file people.txt which has contents such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;George Bush&#xA;Hillary Clinton&#xA;Santa Clause&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I am in vi and type &quot;Clau&quot;, vi suggests &quot;Santa Clause&quot;.&#xA;Likewise, if I type &quot;eorg&quot;, vi suggests &quot;George Bush&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to manually update the people.txt file&#xA;and have the new completions to work automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has this been done? If so, suggestions are welcome.&lt;/p&gt;&#xA;" OwnerUserId="13329" LastEditorUserId="1238" LastEditDate="2020-02-18T04:16:55.700" LastActivityDate="2020-02-18T04:16:55.700" Title="Word or phrase completion based on file" Tags="|autocompletion|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22912" PostTypeId="1" AcceptedAnswerId="22924" CreationDate="2020-02-17T01:03:08.513" Score="2" ViewCount="1458" Body="&lt;p&gt;If I have a file &lt;code&gt;a.js&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a1 = [&#xA;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I press &lt;kbd&gt;Enter&lt;/kbd&gt; at the end of the first line, a Tab is inserted. I do not want this, so I added a setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but then if I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a1 = [&#xA;   10,&#xA;   20&#xA;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to manually add tabs for each item. So I added another setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set autoindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These two settings solve the existing problems, but introduce a new problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I move the cursor to the start of one of the indented lines, and press &lt;kbd&gt;Enter&lt;/kbd&gt; the indentation is removed. Can I change a setting to resolve this issue? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To respond to an answer, I can use these settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent off&#xA;set smartindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and redo the second example. However, after I press &lt;kbd&gt;Enter&lt;/kbd&gt;, if I then press &lt;kbd&gt;Up&lt;/kbd&gt; or &lt;kbd&gt;Down&lt;/kbd&gt;, the indentation is removed, repeating the problem.&lt;/p&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="1238" LastEditDate="2020-02-18T22:37:35.273" LastActivityDate="2020-02-18T22:37:35.273" Title="Pressing Enter removes indentation" Tags="|indentation|cursor-movement|tab-characters|set|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22913" PostTypeId="2" ParentId="22912" CreationDate="2020-02-17T01:35:17.850" Score="2" Body="&lt;p&gt;I think the setting &lt;code&gt;set smartindent&lt;/code&gt; has the behavior you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use the following &lt;code&gt;.vimrc&lt;/code&gt; on &lt;code&gt;a.js&lt;/code&gt;, then you can see what's happening when you create a new line and press &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; in normal mode while the cursor is over the indentation section of the new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the setting set list to make ends of lines visible (as &lt;code&gt;$&lt;/code&gt;) and tabs visible (as &lt;code&gt;^I&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set list&#xA;filetype plugin on&#xA;filetype indent off&#xA;set smartindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this setting on, no tab is inserted in the first example.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a1 = [$&#xA;$&#xA;];$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the second example, a line beginning with some indentation characters is moved in a reasonable way&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a1 = [$&#xA;^I10,$&#xA;$&#xA;^I20$&#xA;];$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want the leading tab to be preserved in the middle line of the second example, then you can use &lt;code&gt;I&lt;/code&gt; or [ &lt;code&gt;^&lt;/code&gt; and then &lt;code&gt;i&lt;/code&gt; ] to move your cursor to the first non-whitespace character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you start with the buffer below as &lt;code&gt;a.js&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a1 = [$&#xA;^Ia1$&#xA;^I20$&#xA;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then type the command &lt;code&gt;3GI&amp;lt;cr&amp;gt;&lt;/code&gt;, then this will be the result.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let a1 = [$&#xA;^Ia1$&#xA;^I$&#xA;^I20$&#xA;];$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6420" LastEditorUserId="6420" LastEditDate="2020-02-17T02:33:25.713" LastActivityDate="2020-02-17T02:33:25.713" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22914" PostTypeId="1" AcceptedAnswerId="22926" CreationDate="2020-02-17T05:31:09.873" Score="0" ViewCount="174" Body="&lt;p&gt;Currently I am outputting AWS help to vim, and then searching through it, but to my horror, I am realising displays underlines, for example, &lt;strong&gt;NAME&lt;/strong&gt; will be displayed as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;N^HNA^HAM^HME^HE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;^H&lt;/code&gt; is the &lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;C-H&amp;gt;&lt;/code&gt; (Ctrl V, Ctrl H), special character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Removing &lt;code&gt;^H&lt;/code&gt; does not yield amazing results &lt;code&gt;%s/^H//g&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NNAAMMEE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which still renders my document unreadable in many ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I deal with this problem in a sane way? I don't always want to have to clean output form the terminal before reading it in vim. I'm capturing allot of output from the cli for different purposes with Vim, and would love it if there was a setting in Vim to just forget about bold, italic, underlines etc.&lt;/p&gt;&#xA;" OwnerUserId="26973" LastActivityDate="2020-02-18T04:32:15.573" Title="How do I deal with shell text which has underlines, bold, etc" Tags="|vimscript|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22915" PostTypeId="2" ParentId="22905" CreationDate="2020-02-17T07:50:59.520" Score="3" Body="&lt;p&gt;The browsefilter variable is a convenient way to add custom glob like filters for the graphical &lt;code&gt;:browse&lt;/code&gt; dialog and select only the relevant filetypes for display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you discovered, those are usually set in the filetype plugins. If you want to customize those filters, create a file in &lt;code&gt;~/.vim/after/ftplugin/&amp;lt;filetype&amp;gt;.vim&lt;/code&gt; (replace &lt;code&gt;&amp;lt;filetype&amp;gt;&lt;/code&gt; by the wanted filetype, e.g. &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;python&lt;/code&gt;) and add the following content (this example is for your c filetype):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;b:browsefilter&quot;)&#xA;    let b:browsefilter = &quot;My C Source Files (cpp,c++,hpp,ipp)\t*.cpp;*.c++;*.hpp;*.ipp\n&quot;. b:browsefilter&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is important to place this in the &lt;code&gt;after&lt;/code&gt; directory, as the default filetype needs to be run first to initialize the &lt;code&gt;b:browsefilter&lt;/code&gt; variable that you can than customize further.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2020-02-17T07:50:59.520" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22916" PostTypeId="2" ParentId="356" CreationDate="2020-02-17T12:18:57.007" Score="3" Body="&lt;p&gt;I mostly do coding in vim (version 7.4) and I have added the below two lines in my .vimrc to maintain a &quot;colorcolumn&quot; for 100 character length.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set colorcolumn=100                                                                                &#xA;:hi ColorColumn ctermbg=lightcyan guibg=blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My environment is a color-xterm so I usually populate the &quot;ctermbg&quot; argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For someone curious, to find the available colour names in your vim, open vim and run the below command. It will show you a list of colour names that can be used as argument values.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:so $VIMRUNTIME/syntax/colortest.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26992" LastActivityDate="2020-02-17T12:18:57.007" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22918" PostTypeId="1" AcceptedAnswerId="22928" CreationDate="2020-02-17T15:43:20.853" Score="1" ViewCount="285" Body="&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt;&#xA;To achieve filename/path completion relative to current file directory using file name completion &lt;code&gt;CTRL-X CTRL-F&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I open all my files contained in a base directory such that &lt;code&gt;:pwd&lt;/code&gt; in &lt;em&gt;some_file&lt;/em&gt; outputs &lt;code&gt;/some/path/to/base_directory&lt;/code&gt;. This lets me search for other files relative to base_directory, that I want.&lt;/p&gt;&#xA;&lt;p&gt;The problem with using &lt;code&gt;CTRL-X CTRL-F&lt;/code&gt; is that by default it prompts for filename/directory relative to base_directory. So, if one has to use a path name that is relative to current file directory, something like &lt;code&gt;../../../some_file&lt;/code&gt; pathname, one is out of luck, as this path name is of &lt;em&gt;some_file&lt;/em&gt; in three directory level up from &lt;em&gt;base_directory&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I am trying to write a mapping that can switch between &lt;em&gt;base_directory&lt;/em&gt; and current file directory to make efficient use of &lt;code&gt;CTRL-X CTRL-F&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Attempt:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; temporarily switch to current file directory&#xA;function! SwitchCwd()&#xA;  &amp;quot; on first execution of function from a window&#xA;  if exists(&amp;quot;w:baseCwd&amp;quot;)==0&#xA;    &amp;quot; store the base directory path in w:baseCwd&#xA;    let w:baseCwd=getcwd()&#xA;    let w:tmpCwd=expand(&amp;quot;%:p:h&amp;quot;)&#xA;    &amp;quot; when this mapping is run first time from a window, switch to current file directory&#xA;    lcd %:p:h&#xA;  elseif w:tmpCwd==expand(&amp;quot;%:p:h&amp;quot;)&#xA;    echo w:baseCwd&#xA;    &amp;quot; on subsequent executions of this function from same window&#xA;    w:tmpCwd=w:baseCwd&#xA;    &amp;quot; switch to base directory&#xA;    lcd w:baseCwd&#xA;  else&#xA;    echo &amp;quot;inside else&amp;quot;&#xA;    lcd %:p:h&#xA;  endif&#xA;endfunction&#xA;&#xA;&amp;quot;Path prompt mapping&#xA;nnoremap &amp;lt;leader&amp;gt;cd :call SwitchCwd()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I run this mapping with &lt;code&gt;&amp;lt;leader&amp;gt;cd&lt;/code&gt; for the first time, vim successfully switches to current file directory.&lt;/p&gt;&#xA;&lt;p&gt;Any subsequent command &lt;code&gt;&amp;lt;leader&amp;gt;cd&lt;/code&gt; results in &lt;strong&gt;error:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function SwitchCwd:&#xA;line   13:&#xA;E13: File exists (add ! to override)&#xA;line   14:&#xA;E344: Can't find directory &amp;quot;w:baseCwd&amp;quot; in cdpath&#xA;E472: Command failed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;echo w:baseCwd&lt;/code&gt; in &lt;code&gt;elseif&lt;/code&gt; outputs the correct absolute path of &lt;em&gt;base_directory&lt;/em&gt;, but throws an error in assignment &lt;code&gt;w:tmpCwd=w:baseCwd&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="26997" LastEditorUserId="343" LastEditDate="2022-10-07T09:47:40.470" LastActivityDate="2022-10-19T16:19:54.880" Title="switch current directory between a base directory and current file directory" Tags="|vimscript|variables|working-directory|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22919" PostTypeId="2" ParentId="9757" CreationDate="2020-02-17T16:04:01.763" Score="1" Body="&lt;p&gt;I just made this mistake! :-)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# BAD&#xA;Plugin 'file:///Users/jamesjones/src/github/burnttoast256/colors'&#xA;&#xA;# GOOD&#xA;Plugin 'file:///Users/jamesjones/src/github/burnttoast256'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You want to point to the root of the git repo for your plugin, not a subdirectory within your repo, ie where the &lt;code&gt;.git&lt;/code&gt; directory is.&lt;/p&gt;&#xA;" OwnerUserId="26758" LastEditorUserId="26758" LastEditDate="2023-03-23T15:41:45.890" LastActivityDate="2023-03-23T15:41:45.890" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22920" PostTypeId="1" CreationDate="2020-02-17T16:38:28.693" Score="1" ViewCount="1311" Body="&lt;p&gt;I am experiencing a behavior as depicted in the picture below: vim marks the redundant spacing in red. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9AeI3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9AeI3.png&quot; alt=&quot;Marking of redundant spacing in red&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to completely remove this behavior. At the moment my &lt;code&gt;.vimrc&lt;/code&gt; file reads as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;set nocompatible              &quot; required&#xA;filetype off                  &quot; required&#xA;&#xA;&quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&quot; alternatively, pass a path where Vundle should install plugins&#xA;&quot;call vundle#begin('~/some/path/here')&#xA;&#xA;&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'gmarik/Vundle.vim'&#xA;Plugin 'dense-analysis/ale'&#xA;Plugin 'sheerun/vim-polyglot'&#xA;Plugin 'tmsvg/pear-tree'&#xA;Plugin 'godlygeek/tabular'&#xA;Plugin 'preservim/nerdtree'&#xA;Plugin 'arcticicestudio/nord-vim'&#xA;Plugin 'morhetz/gruvbox'&#xA;&quot; All of your Plugins must be added before the following line&quot;&#xA;call vundle#end()            &quot; required&#xA;filetype plugin indent on    &quot; required&#xA;&#xA;&quot;Automaticaly open nerdTREE&quot;&#xA;autocmd StdinReadPre * let s:std_in=1&#xA;autocmd VimEnter * if argc() == 0 &amp;amp;&amp;amp; !exists(&quot;s:std_in&quot;) | NERDTree | endif&#xA;nmap &amp;lt;F1&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;&#xA;&#xA;&quot;Python settings&quot;&#xA;au BufNewFile, BufRead *.py&#xA;    \ set tabstop=4&#xA;    \ set softtabstop=4&#xA;    \ set shiftwidth=4&#xA;    \ set textwidth=79&#xA;    \ set expandtab&#xA;    \ set autoindent&#xA;    \ set fileformat=unix&#xA;    \ set encoding=utf-8&#xA;&#xA;colorscheme gruvbox&#xA;set background=dark&#xA;let g:gruvbox_contrast_dark = 'soft'&#xA;nnoremap &amp;lt;C-Left&amp;gt; :tabprevious&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;C-Right&amp;gt; :tabnext&amp;lt;CR&amp;gt;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At some point I had this part of code which I think precisely initialized such behavior:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But since then I have purged vim from my computer with all other info as well, reinstalled it but the problem still is here.&lt;/p&gt;&#xA;" OwnerUserId="27000" LastEditorUserId="1238" LastEditDate="2020-02-19T14:02:00.210" LastActivityDate="2020-02-19T14:02:00.210" Title="Disable automatic whitespace marking in red" Tags="|vimrc|whitespace|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22921" PostTypeId="1" AcceptedAnswerId="22923" CreationDate="2020-02-17T17:26:38.020" Score="3" ViewCount="552" Body="&lt;p&gt;I seem to have messed with some settings which have resulted in the area where I enter commands now being 2 characters in height. See the screenshot below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PTpG8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PTpG8.png&quot; alt=&quot;vim-command-entry-form&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I have to set in my init.vim file (I am using Neovim) to return this area to being 1 character in height?&lt;/p&gt;&#xA;" OwnerUserId="26955" LastActivityDate="2020-02-17T21:43:45.963" Title="How do I reduce the height of the area where commands are entered?" Tags="|normal-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22922" PostTypeId="2" ParentId="22869" CreationDate="2020-02-17T17:42:03.057" Score="3" Body="&lt;p&gt;Adding &lt;code&gt;let $TMP=&quot;/tmp&quot;&lt;/code&gt; to init.vim, which should perhaps have been obvious, solved this with the exception of a couple of plugins which assume cmd.exe as the shell on Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had previously tried setting it to various other directories, but I was always making the mistake of specifying them with the Windows path format.&lt;/p&gt;&#xA;" OwnerUserId="26944" LastActivityDate="2020-02-17T17:42:03.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22923" PostTypeId="2" ParentId="22921" CreationDate="2020-02-17T21:43:45.963" Score="4" Body="&lt;p&gt;It's possible that this is caused by the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27cmdheight%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'cmdheight'&lt;/code&gt;&lt;/a&gt; option, which configures the number of screen lines to use for the command-line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can reset it to its default of 1 with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cmdheight&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the default is to keep just one row for the command-line, it's possible you got this configured in your vimrc, so just removing it from there should solve the issue for you.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-17T21:43:45.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22924" PostTypeId="2" ParentId="22912" CreationDate="2020-02-18T03:02:06.630" Score="0" Body="&lt;p&gt;After trying the methods in the question, I then tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent off&#xA;function F_indent()&#xA;   return indent(prevnonblank(v:lnum - 1))&#xA;endfunction&#xA;set indentexpr=F_indent()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/eval.html#prevnonblank()&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/eval.html#prevnonblank()&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which passes the 2 tests in the question, but I noticed another problem. With&#xA;the second example, if I put the cursor at the beginning of the last line and&#xA;Press Enter, it inserts a Newline and a Tab. In addition, throughout these&#xA;tests I have also noticed that all the previous methods remove indentation on&#xA;empty lines:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/3612/unindenting-empty-lines&quot;&gt;How do I prevent Vim from unindenting empty lines?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So Ideally I wanted whatever I came up with to pass these tests:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;whitespace removed only with backspace or delete&lt;/li&gt;&#xA;&lt;li&gt;if cursor position greater than indent, match indent&lt;/li&gt;&#xA;&lt;li&gt;if cursor position less or equal to indent, match position&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To that end, I came up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent off&#xA;function F_ind()&#xA;   let n_ind = indent(line('.'))&#xA;   let n_col = col('.') - 1&#xA;   if n_col &amp;gt; n_ind&#xA;      return &quot;\n&quot; . repeat(&quot;\t&quot;, n_ind / 3)&#xA;   else&#xA;      return &quot;\n&quot; . repeat(&quot;\t&quot;, n_col / 3)&#xA;   endif&#xA;endfunction&#xA;imap &amp;lt;expr&amp;gt; &amp;lt;CR&amp;gt; F_ind()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note I use &lt;code&gt;softtabstop=3&lt;/code&gt;, so adjust the &lt;code&gt;/ 3&lt;/code&gt; as needed, or remove if you&#xA;use hard tabs.&lt;/p&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-02-18T03:02:06.630" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22925" PostTypeId="2" ParentId="22900" CreationDate="2020-02-18T04:15:39.653" Score="2" Body="&lt;p&gt;So, first, the breakdown on mappings and &quot;timing out&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'timeout'       boolean (default on)&#xA;'ttimeout'      boolean (default off, set in |defaults.vim|)&#xA;    These two options together determine the behavior when part of a&#xA;    mapped key sequence or keyboard code has been received:&#xA;&#xA;    'timeout'    'ttimeout'     action&#xA;       off      off             do not time out&#xA;       on       on or off       time out on :mappings and key codes&#xA;       off      on              time out on key codes&#xA;&#xA;    [snipped]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Essentially, by default, vim will time out on &lt;code&gt;:map&lt;/code&gt;ped sequences and special key codes (like the &lt;code&gt;&amp;lt;Esc&amp;gt;.&lt;/code&gt; that is the equivalent of pressing &lt;code&gt;&amp;lt;A-.&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can control the length of said timeout with &lt;code&gt;timeoutlen&lt;/code&gt; and &lt;code&gt;ttimeoutlen&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'timeoutlen'    number  (default 1000)&#xA;'ttimeoutlen'   number  (default -1, set to 100 in |defaults.vim|)&#xA;    The time in milliseconds that is waited for a key code or mapped key&#xA;    sequence to complete.  Also used for CTRL-\ CTRL-N and CTRL-\ CTRL-G&#xA;    when part of a command has been typed.&#xA;    Normally only 'timeoutlen' is used and 'ttimeoutlen' is -1.  When a&#xA;    different timeout value for key codes is desired set 'ttimeoutlen' to&#xA;    a non-negative number.&#xA;&#xA;        ttimeoutlen mapping delay      key code delay&#xA;           &amp;lt; 0      'timeoutlen'       'timeoutlen'&#xA;          &amp;gt;= 0      'timeoutlen'       'ttimeoutlen'&#xA;&#xA;    The timeout only happens when the 'timeout' and 'ttimeout' options&#xA;    tell so.  A useful setting would be&#xA;        :set timeout timeoutlen=3000 ttimeoutlen=100&#xA;    (time out on mapping after three seconds, time out on key codes after&#xA;    a tenth of a second).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it sounds like by default, you should get at least 1 second for mappings and key-codes alike, unless you're using the line from &lt;code&gt;defaults.vim&lt;/code&gt; such that key-codes only get 100s.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Options for a solution&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Disable timeouts entirely (&lt;code&gt;set notimeout nottimeout&lt;/code&gt;)—personally, I don't recommend this, but YMMV.&lt;/li&gt;&#xA;&lt;li&gt;Enable timeouts on mappings as longer, and keycodes as shorter (&lt;code&gt;set timeoutlen=3000 ttimeoutlen=100&lt;/code&gt;)—this is what I've been using and I've not had any issues. Your mapping works for me with this setup.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Understanding where the issue might be&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Try running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;verbose set timeout? ttimeout? timeoutlen? ttimeoutlen?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The results should be informative.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-02-18T04:15:39.653" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22926" PostTypeId="2" ParentId="22914" CreationDate="2020-02-18T04:22:02.027" Score="3" Body="&lt;p&gt;Ripping from &lt;code&gt;ftplugin/man.vim&lt;/code&gt; to deal with this kind of backspace-bold hack:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%substitute/.\b//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using Christian's &lt;code&gt;col&lt;/code&gt; solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!col -b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command that creates output | vim +MANPAGER -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-02-18T04:32:15.573" LastActivityDate="2020-02-18T04:32:15.573" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22927" PostTypeId="2" ParentId="22920" CreationDate="2020-02-18T09:47:30.430" Score="1" Body="&lt;p&gt;I believe this is &lt;a href=&quot;https://github.com/sheerun/vim-polyglot/issues/333&quot; rel=&quot;nofollow noreferrer&quot;&gt;caused by an option&lt;/a&gt; in &lt;a href=&quot;https://github.com/vim-python/python-syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;the python highlighting used by&lt;/a&gt; your &lt;em&gt;vim-polyglot&lt;/em&gt; plugin. You can disable this by setting the following variable in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:python_highlight_space_errors = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-02-18T09:56:59.703" LastActivityDate="2020-02-18T09:56:59.703" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22928" PostTypeId="2" ParentId="22918" CreationDate="2020-02-18T09:55:57.647" Score="3" Body="&lt;p&gt;There are two separate issues in your code:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;In most situations, if you want to use the &lt;em&gt;contents&lt;/em&gt; of a variable in a Vim command, you need to use &lt;code&gt;:execute&lt;/code&gt; to achieve this. &lt;code&gt;lcd w:baseCwd&lt;/code&gt; will attempt to change to a directory named &lt;code&gt;w:baseCwd&lt;/code&gt;. To change to the directory currently stored in that variable, use &lt;code&gt;:execute 'lcd' w:baseCwd&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You cannot assign to a variable simply by writing &lt;code&gt;x = y&lt;/code&gt;. You need to use &lt;code&gt;:let&lt;/code&gt;. The line &lt;code&gt;w:tmpCwd=w:baseCwd&lt;/code&gt; doesn't assign to a variable: it attempts to write the current buffer to the file &lt;code&gt;:tmpCwd=w:baseCwd&lt;/code&gt;. The first time you do this, it will succeed. The second time you do it (with a different buffer) it will fail with the &lt;code&gt;File Exists&lt;/code&gt; error you are seeing.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-02-18T10:43:15.447" LastActivityDate="2020-02-18T10:43:15.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22929" PostTypeId="1" CreationDate="2020-02-18T11:25:16.507" Score="0" ViewCount="185" Body="&lt;p&gt;I opened up vim and noticed that nothing is displaying properly. mI have no idea of the cause as last time I was in vim there was nothing of the sort. I have tried setting the encoding&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kkpYC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kkpYC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="27014" LastActivityDate="2020-02-18T11:25:16.507" Title="Vim not displaying character values correctly" Tags="|vimrc|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22930" PostTypeId="1" AcceptedAnswerId="22932" CreationDate="2020-02-18T12:59:41.033" Score="2" ViewCount="1347" Body="&lt;p&gt;I'm a user of the &lt;code&gt;surround.vim&lt;/code&gt; plugin that lets me surround words with quotes, brackets, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm facing an issue with surrounding a single character with e.g. quotes, when the character is adjacent to other characters. Thus, I cannot use &lt;code&gt;ysw&quot;&lt;/code&gt; to quote the single character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I operate on a single character? I'm used to using &lt;code&gt;x&lt;/code&gt; to delete a single character, but I'm not familiar with a motion like &lt;code&gt;w&lt;/code&gt; that describes a single character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/tpope/vim-surround&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26505" LastActivityDate="2020-02-18T23:24:58.233" Title="How to use surround.vim to quote a single character?" Tags="|plugin-vim-surround|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22931" PostTypeId="2" ParentId="22930" CreationDate="2020-02-18T13:16:08.683" Score="1" Body="&lt;p&gt;&lt;code&gt;S&lt;/code&gt; in visual mode with an argument wraps the selected text. So:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Put your cursor on the character you want to quote.&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;v&lt;/code&gt; to select it.&lt;/li&gt;&#xA;&lt;li&gt;Press &lt;code&gt;S&quot;&lt;/code&gt; to quoto.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="25618" LastActivityDate="2020-02-18T13:16:08.683" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22932" PostTypeId="2" ParentId="22930" CreationDate="2020-02-18T13:42:17.463" Score="4" Body="&lt;p&gt;Faster than visual mode: &lt;code&gt;ysl&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use both text-objects and motions with any operator, and &lt;code&gt;hjkl&lt;/code&gt; are motions!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that according to &lt;code&gt;:help x&lt;/code&gt;, the command &lt;code&gt;x&lt;/code&gt; is equivalent to &lt;code&gt;dl&lt;/code&gt;, while &lt;code&gt;X&lt;/code&gt; is equivalent to &lt;code&gt;dh&lt;/code&gt;. They have a kind of paradoxical definition that turns out to be nicely intuitive in practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason they work this is both are &lt;code&gt;exclusive&lt;/code&gt; motions, which means the last character of the selection is not included. This &quot;last character&quot; is always determined relative to the buffer end: in other words, characters closer to &lt;code&gt;G$&lt;/code&gt; are &quot;later&quot; than characters closer to &lt;code&gt;gg0&lt;/code&gt;! So &lt;code&gt;yl&lt;/code&gt; will only yank the character you're on, while &lt;code&gt;yh&lt;/code&gt; yanks the previous character. This holds for any operator, including the surround version given at the top.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-02-18T23:24:58.233" LastActivityDate="2020-02-18T23:24:58.233" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22935" PostTypeId="1" AcceptedAnswerId="22936" CreationDate="2020-02-18T18:43:03.940" Score="3" ViewCount="1655" Body="&lt;p&gt;I am attempting to use to the &lt;code&gt;:help&lt;/code&gt; command in Neovim however the following error is returned:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E432: Tags file not sorted: /Users/seeker/.config/nvim/plugged/nerdtree/doc/tags&#xA;E432: Tags file not sorted: /Users/seeker/.config/nvim/plugged/fzf.vim/doc/tags&#xA;E432: Tags file not sorted: /Users/seeker/.config/nvim/plugged/emmet-vim/doc/tags&#xA;E432: Tags file not sorted: /Users/seeker/.config/nvim/plugged/coc.nvim/doc/tags&#xA;E432: Tags file not sorted: /usr/local/Cellar/neovim/0.4.2/share/nvim/runtime/doc/tags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I resolve this?&lt;/p&gt;&#xA;" OwnerUserId="26955" LastEditorUserId="26955" LastEditDate="2020-02-19T04:05:48.933" LastActivityDate="2021-09-16T08:03:55.027" Title="`:help` returns an “E432: Tags file not sorted” error" Tags="|help-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22936" PostTypeId="2" ParentId="22935" CreationDate="2020-02-18T19:10:46.703" Score="3" Body="&lt;p&gt;This is an indication that the &lt;code&gt;tags&lt;/code&gt; files that work as indices for the help system are not sorted as expected. Vim/NeoVim wants those to be sorted so it can quickly find a help item in those files without having to read the whole contents of all those files&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try to regenerate the &lt;code&gt;tags&lt;/code&gt; files for all doc directories with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:helptags ALL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since these indices are created from the documentation files, you can always safely recreate them. But it's hard to tell whether that's enough to fix your issue or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've had this issue one time, with Vim, on a somewhat odd platform. I didn't manage to understand why the &lt;code&gt;tags&lt;/code&gt; files were created incorrectly, but I noticed that I could work around the issue by enabling the &lt;code&gt;'ignorecase'&lt;/code&gt; option (possibly also &lt;code&gt;'smartcase'&lt;/code&gt;), which makes Vim search the tags file for case-insensitive matches, in which case it doesn't really depend on the sort order of the files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(So while they're possibly still unsorted and you don't get the quick binary search that's possible when they are, you're effectively opting out of that by requesting case-insensitivity. I didn't have noticeable performance issues using the help system and following tags there with this option set. YMMV.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; According to &lt;a href=&quot;https://github.com/vim/vim/commit/27fc8cab227e30f649f52e74efd58ad56d21e9bb&quot; rel=&quot;nofollow noreferrer&quot;&gt;this commit&lt;/a&gt; it's a bug related to how lseek() works on specific platforms, and it seems it's broken on MacOS Catalina.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has been fixed upstream, so latest NeoVim or Vim will be fixed. (In the case of Vim, version 8.1.2152 or later will contain the fix.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-02-19T00:26:58.653" LastActivityDate="2020-02-19T00:26:58.653" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22937" PostTypeId="1" AcceptedAnswerId="22939" CreationDate="2020-02-18T19:13:45.953" Score="2" ViewCount="291" Body="&lt;p&gt;I am new to Vim and I would like to make a key binding to compile my LaTeX source. I have the following &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType tex :nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F5&amp;gt; :!pdflatex %&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is working very well but &lt;strong&gt;I would like it to run in the background&lt;/strong&gt;.&#xA;I know there are options with &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; but I can't make them work. &lt;/p&gt;&#xA;" OwnerDisplayName="user27022" LastActivityDate="2020-04-16T07:14:23.340" Title="Compile LaTeX source file in the background without any plugin" Tags="|key-bindings|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22938" PostTypeId="1" AcceptedAnswerId="22943" CreationDate="2020-02-18T20:07:36.500" Score="3" ViewCount="5597" Body="&lt;p&gt;I am trying to use Python in &lt;code&gt;vim&lt;/code&gt;, but it doesn't work despite &lt;code&gt;vim&lt;/code&gt; having the &lt;code&gt;+python3&lt;/code&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:python print(&quot;hello&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E319: Sorry, the command is not available in this version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How can this problem be fixed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:version&lt;/code&gt; command's output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 06 2019 17:31:41)&#xA;Included patches: 1-1453&#xA;Modified by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Compiled by pkg-vim-maintainers@lists.alioth.debian.org&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               -dnd               +listcmds          +postscript        +timers&#xA;+arabic            -ebcdic            +localmap          +printer           +title&#xA;+autocmd           +emacs_tags        -lua               +profile           -toolbar&#xA;-autoservername    +eval              +menu              -python            +user_commands&#xA;-balloon_eval      +ex_extra          +mksession         +python3           +vertsplit&#xA;+balloon_eval_term +extra_search      +modify_fname      +quickfix          +virtualedit&#xA;-browse            +farsi             +mouse             +reltime           +visual&#xA;++builtin_terms    +file_in_path      -mouseshape        +rightleft         +visualextra&#xA;+byte_offset       +find_in_path      +mouse_dec         -ruby              +viminfo&#xA;+channel           +float             +mouse_gpm         +scrollbind        +vreplace&#xA;+cindent           +folding           -mouse_jsbterm     +signs             +wildignore&#xA;-clientserver      -footer            +mouse_netterm     +smartindent       +wildmenu&#xA;-clipboard         +fork()            +mouse_sgr         +startuptime       +windows&#xA;+cmdline_compl     +gettext           -mouse_sysmouse    +statusline        +writebackup&#xA;+cmdline_hist      -hangul_input      +mouse_urxvt       -sun_workshop      -X11&#xA;+cmdline_info      +iconv             +mouse_xterm       +syntax            -xfontset&#xA;+comments          +insert_expand     +multi_byte        +tag_binary        -xim&#xA;+conceal           +job               +multi_lang        +tag_old_static    -xpm&#xA;+cryptv            +jumplist          -mzscheme          -tag_any_white     -xsmp&#xA;+cscope            +keymap            +netbeans_intg     -tcl               -xterm_clipboard&#xA;+cursorbind        +lambda            +num64             +termguicolors     -xterm_save&#xA;+cursorshape       +langmap           +packages          +terminal&#xA;+dialog_con        +libcall           +path_extra        +terminfo&#xA;+diff              +linebreak         -perl              +termresponse&#xA;+digraphs          +lispindent        +persistent_undo   +textobjects&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14024" LastEditorUserId="1238" LastEditDate="2020-02-18T21:44:08.900" LastActivityDate="2020-02-19T13:06:58.043" Title="The :python command doesn't work - E319: Sorry, the command is not available in this version" Tags="|vimscript-python|compile-vim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22939" PostTypeId="2" ParentId="22937" CreationDate="2020-02-18T23:29:00.990" Score="2" Body="&lt;p&gt;If you just want a non-disruptive process to run, consider tpope's Dispatch plugin: if you have a &lt;code&gt;makeprg&lt;/code&gt; setup well for LaTex, you could use it's &lt;code&gt;:Make&lt;/code&gt;; otherwise, you'll want to &lt;code&gt;:Start pdflatex ...&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To silence a &lt;em&gt;mapping&lt;/em&gt;, use &lt;code&gt;nnoremap &amp;lt;silent&amp;gt; ...&lt;/code&gt;. But note that this just prevents echoing of the simulated characters being typed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To silence a command, do &lt;code&gt;:silent[!] command&lt;/code&gt;. With &lt;code&gt;!&lt;/code&gt;, all error messages are suppressed.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-02-20T18:13:46.563" LastActivityDate="2020-02-20T18:13:46.563" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22940" PostTypeId="2" ParentId="22938" CreationDate="2020-02-18T23:30:02.960" Score="1" Body="&lt;p&gt;Check &lt;code&gt;:help if-pyth&lt;/code&gt;: you need to use &lt;code&gt;:python3&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-02-19T13:06:58.043" LastActivityDate="2020-02-19T13:06:58.043" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22941" PostTypeId="1" AcceptedAnswerId="22942" CreationDate="2020-02-19T04:08:12.793" Score="1" ViewCount="126" Body="&lt;p&gt;I'm getting some really weird behavior when trying to write a simple keybinding in my vimrc. the following key map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F2&amp;gt; gdi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;only works if the cursor is not over the first declaration of a variable. If it is, it won't go into insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code sample I'm working with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hangman :: IO ()&#xA;hangman = do word &amp;lt;- getLine&#xA;         guessword word $ concat $ replicate (length word) &quot;-&quot;&#xA;&#xA;guessword :: String -&amp;gt; String -&amp;gt; IO ()&#xA;guessword a b = do putStrLn b&#xA;           guess &amp;lt;- getLine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I open the file and run the command on the first instance of &quot;hangman&quot;, it just won't enter insert mode. If I run it on the second instance, it will.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I just type gdi manually (without using the key binding), it will always enter insert mode, wherever I type it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why this discrepancy between running the key binding and actually typing the command in Vim? Can anyone else reproduce this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using neovim if it matters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: It appears that the key binding is actually dropping any key presses after gd. Anything I add to the key binding after gd is disregarded, but only if I'm on the first instance of the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get around this, I'm using the following workaround using a regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;r &quot;gg:/\\&amp;lt;&quot; .expand(&quot;&amp;lt;cword&amp;gt;&quot;) . &quot;\\&amp;gt;/&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which allows me do what I was originally intending to do, which was write a key binding that renames a variable. The following works for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;r &quot;gg:/\\&amp;lt;&quot; .expand(&quot;&amp;lt;cword&amp;gt;&quot;) . &quot;\\&amp;gt;/&amp;lt;CR&amp;gt;cgn&quot; . input(&quot;Enter new name: &quot;) . &quot;&amp;lt;esc&amp;gt;:%norm .&amp;lt;CR&amp;gt;&amp;lt;C-O&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27025" LastEditorUserId="27025" LastEditDate="2020-02-19T06:05:06.337" LastActivityDate="2020-02-19T06:42:02.637" Title="Vim keymapping for &quot;gdi&quot; will not work if the cursor is over the definition of a variable, but works in normal mode?" Tags="|key-bindings|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22942" PostTypeId="2" ParentId="22941" CreationDate="2020-02-19T06:42:02.637" Score="0" Body="&lt;p&gt;It seems that &lt;code&gt;gd&lt;/code&gt; actually fails if you're in the definition itself (even though Vim doesn't print an error message.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see that somewhat if you use &lt;code&gt;gd&lt;/code&gt; on the middle of the definition keyword, while I'd expect it to move to the beginning of the word, it keeps the cursor where it is. So together with the other evidence, I take it that this command is failing. It's unclear to me why it fails in this particular case, whether the authors decided it should fail in this case and for what reason. The documentation doesn't seem to spell out this particular case either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, when a command fails, a mapping is interrupted and the commands that follow will not be executed.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You mentioned at the end of your question that your actual objective is to replace the first occurrence of the word under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can accomplish that easily in a mapping, for example using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;F2&amp;gt; :let @/ = '\V\&amp;lt;'.escape(expand('&amp;lt;cword&amp;gt;'), '\').'\&amp;gt;'&amp;lt;CR&amp;gt;ggcgn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Setting the &lt;code&gt;@/&lt;/code&gt; makes it the search term. Using &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; around the word means you'll only match whole words only. Using &lt;code&gt;\V&lt;/code&gt; (very non-magic) means only the backslash character will be special, and for extra care we're escaping the backslashes in the current word (even though it's very unlikely you'd get them anyways, unless you redefined &lt;code&gt;'iskeyword'&lt;/code&gt; to include backslashes, but hey let's be super safe here.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This part of the mapping is similar to what the &lt;code&gt;*&lt;/code&gt; command does. (In fact, implementing the mapping by simply using &lt;code&gt;*ggcgn&lt;/code&gt; is probably possible too.) The main difference is that setting &lt;code&gt;@/&lt;/code&gt; will not jump to the next search term, while &lt;code&gt;*&lt;/code&gt; does. (But that might not matter, since you're jumping back to the beginning of the buffer right afterwards.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After setting the default search term, we execute &lt;code&gt;gg&lt;/code&gt; to go to the top and &lt;code&gt;cgn&lt;/code&gt; to start replacing the next occurrence of the search term, leaving you in insert mode ready to replace that identifier.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-19T06:42:02.637" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22943" PostTypeId="2" ParentId="22938" CreationDate="2020-02-19T06:56:08.840" Score="2" Body="&lt;p&gt;The problem was solved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:python3&lt;/code&gt; or &lt;code&gt;:pythonx&lt;/code&gt; (&lt;code&gt;:py3&lt;/code&gt; or &lt;code&gt;:pyx&lt;/code&gt;) should be used instead of the simple &lt;code&gt;:python&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h python3&lt;/code&gt; and &lt;code&gt;:h pythonx&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;:py3 print(&quot;hello&quot;)&lt;/code&gt; gives &lt;code&gt;hello&lt;/code&gt; as expected.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also, to see what version of Python is being used, do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:pyx import sys&#xA;:pyx print(sys.version)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my case it gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3.6.9 (default, Nov  7 2019, 10:44:02)&#xA;[GCC 8.3.0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14024" LastActivityDate="2020-02-19T06:56:08.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22944" PostTypeId="1" AcceptedAnswerId="22945" CreationDate="2020-02-19T14:57:50.360" Score="3" ViewCount="881" Body="&lt;p&gt;I have no vi customizations at all and really like the default behavior where on a search using  /  the cursor immediately jumps to the match without having to hit enter&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem is once I create file  ~/.vimrc and add anything like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set ts=4&#xA;set ic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the desired default behavior mentioned above goes away.  How to keep the system defaults yet make the slightest customization ?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;version 8.1.2269   &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vi --version&#xA;VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 18 2020 06:30:35)&#xA;Included patches: 1-2269&#xA;Modified by team+vim@tracker.debian.org&#xA;Compiled by team+vim@tracker.debian.org&#xA;Huge version without GUI.  Features included (+) or not (-):&#xA;+acl               -farsi             -mouse_sysmouse    -tag_any_white&#xA;+arabic            +file_in_path      +mouse_urxvt       -tcl&#xA;+autocmd           +find_in_path      +mouse_xterm       +termguicolors&#xA;+autochdir         +float             +multi_byte        +terminal&#xA;-autoservername    +folding           +multi_lang        +terminfo&#xA;-balloon_eval      -footer            -mzscheme          +termresponse&#xA;+balloon_eval_term +fork()            +netbeans_intg     +textobjects&#xA;-browse            +gettext           +num64             +textprop&#xA;++builtin_terms    -hangul_input      +packages          +timers&#xA;+byte_offset       +iconv             +path_extra        +title&#xA;+channel           +insert_expand     -perl              -toolbar&#xA;+cindent           +job               +persistent_undo   +user_commands&#xA;-clientserver      +jumplist          +postscript        +vartabs&#xA;-clipboard         +keymap            +printer           +vertsplit&#xA;+cmdline_compl     +lambda            +profile           +virtualedit&#xA;+cmdline_hist      +langmap           -python            +visual&#xA;+cmdline_info      +libcall           +python3           +visualextra&#xA;+comments          +linebreak         +quickfix          +viminfo&#xA;+conceal           +lispindent        +reltime           +vreplace&#xA;+cryptv            +listcmds          +rightleft         +wildignore&#xA;+cscope            +localmap          -ruby              +wildmenu&#xA;+cursorbind        -lua               +scrollbind        +windows&#xA;+cursorshape       +menu              +signs             +writebackup&#xA;+dialog_con        +mksession         +smartindent       -X11&#xA;+diff              +modify_fname      +sound             -xfontset&#xA;+digraphs          +mouse             +spell             -xim&#xA;-dnd               -mouseshape        +startuptime       -xpm&#xA;-ebcdic            +mouse_dec         +statusline        -xsmp&#xA;+emacs_tags        +mouse_gpm         -sun_workshop      -xterm_clipboard&#xA;+eval              -mouse_jsbterm     +syntax            -xterm_save&#xA;+ex_extra          +mouse_netterm     +tag_binary        &#xA;+extra_search      +mouse_sgr         -tag_old_static    &#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-3deAkt/vim-8.1.2269=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       &#xA;Linking: gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lcanberra -lacl -lattr -lgpm -ldl     -L/usr/lib/python3.8/config-3.8-x86_64-linux-gnu -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm -lm    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am on linux ubuntu &lt;/p&gt;&#xA;" OwnerUserId="15795" LastEditorUserId="28" LastEditDate="2020-02-20T11:41:09.237" LastActivityDate="2020-02-20T11:41:09.237" Title="How to keep defaults yet make customization?" Tags="|default-settings|" AnswerCount="1" CommentCount="1" ClosedDate="2020-02-20T11:40:53.383" ContentLicense="CC BY-SA 4.0" />
  <row Id="22945" PostTypeId="2" ParentId="22944" CreationDate="2020-02-19T15:13:57.337" Score="5" Body="&lt;p&gt;Add these two lines to the top of your newly created &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unlet! skip_defaults_vim&#xA;source $VIMRUNTIME/defaults.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For details, see &lt;a href=&quot;https://vimhelp.org/starting.txt.html#defaults.vim&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help defaults.vim&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If Vim is started normally and no user vimrc file is found, the &lt;code&gt;$VIMRUNTIME/defaults.vim&lt;/code&gt; script is loaded.  This will set &lt;code&gt;'compatible'&lt;/code&gt; off, switch on syntax highlighting and a few more things.  See the script for&#xA;  details.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; this is done since Vim 8.0, not in Vim 7.4. (it was added in patch 7.4.2111 to be exact).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This should work well for new Vim users.  If you create your own &lt;code&gt;.vimrc&lt;/code&gt;, it is recommended to add these lines somewhere near the top:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unlet! skip_defaults_vim&#xA;source $VIMRUNTIME/defaults.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Then Vim works like before you had a &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You might want to take a look inside the &lt;a href=&quot;https://github.com/vim/vim/blob/v8.2.0/runtime/defaults.vim&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;defaults.vim&lt;/code&gt; file&lt;/a&gt; shipped with Vim, the comments in the file might be helpful as well.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-19T15:13:57.337" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22946" PostTypeId="2" ParentId="18315" CreationDate="2020-02-19T17:37:34.063" Score="1" Body="&lt;p&gt;Maybe you should try the plugin I wrote. &lt;a href=&quot;https://github.com/kevinhwang91/rnvimr&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kevinhwang91/rnvimr&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It gives you full control over Ranger. It uses RPC to communicate with Ranger.&lt;/p&gt;&#xA;" OwnerUserId="27035" LastActivityDate="2020-02-19T17:37:34.063" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22947" PostTypeId="1" AcceptedAnswerId="22949" CreationDate="2020-02-19T22:32:17.950" Score="13" ViewCount="5083" Body="&lt;p&gt;I'm going through vimtutor and just learned about using &lt;code&gt;:!&amp;lt;CMD&amp;gt;&lt;/code&gt; to execute a shell command from within vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read a bit up on why not to use just &lt;code&gt;:&amp;lt;CMD&amp;gt;&lt;/code&gt; and apparently it's because some character sequences like &lt;code&gt;ls&lt;/code&gt; are used by vim itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alright, but the first thing I tried afterwards already didn't go as expected:&#xA;I typed &lt;code&gt;:!cd some_directory&lt;/code&gt; but this had no effect, I just stayed in the current directory as confirmed by &lt;code&gt;:!pwd&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, doing &lt;code&gt;:cd some_directory&lt;/code&gt; &lt;strong&gt;did&lt;/strong&gt; change the working directory to &lt;code&gt;some_directory&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a bit confused here. Why didn't &lt;code&gt;:!cd&lt;/code&gt; work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I understand now that :! starts a new shell, but if I read correctly, so far none of the answers have explained why the &lt;code&gt;:cd some_directory&lt;/code&gt; &lt;strong&gt;does&lt;/strong&gt; change the directory. Is this a command which is executed in the shell vim itself is running in? If yes, then wouldn't one want to have an escape symbol (e.g. &lt;code&gt;:|&amp;lt;CMD&amp;gt;&lt;/code&gt;) which always redirects commands to the original shell? This way one would have consistency in the way that both &lt;code&gt;:|ls&lt;/code&gt; and &lt;code&gt;:|cd&lt;/code&gt; would work as expected from a normal shell. Or what am I missing here? &lt;/p&gt;&#xA;" OwnerUserId="27037" LastEditorUserId="27037" LastEditDate="2020-02-21T00:43:38.860" LastActivityDate="2020-02-21T08:36:39.160" Title="Why does !cd not change the directory" Tags="|shell|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22948" PostTypeId="2" ParentId="22947" CreationDate="2020-02-20T01:22:50.987" Score="2" Body="&lt;p&gt;&lt;code&gt;:cd&lt;/code&gt; is vim command&#xA;&lt;code&gt;:!&lt;/code&gt; is used to execute bash commands.&#xA;In this case, cd. The cur dir is saved as variable in vim. &#xA;Bash executes new session every time you do &lt;code&gt;!&lt;/code&gt;, so it is not kept, I am quite sure. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2020-02-20T01:29:10.027" LastActivityDate="2020-02-20T01:29:10.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22949" PostTypeId="2" ParentId="22947" CreationDate="2020-02-20T02:48:09.057" Score="19" Body="&lt;p&gt;I assume you are aware, generally, of the notion of parent and child processes. Particularly with respect to shells. Let's say I'm in the shell. My prompt shows the current directory (&lt;code&gt;$PWD&lt;/code&gt;)...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[/bar] $ sh     # launch child shell&#xA;[/bar] $ cd /foo&#xA;[/foo] $ exit&#xA;[/bar] $        # back in the parent it's still /bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[/bar] $ sh     # launch child shell&#xA;[/bar] $ myvar=something&#xA;[/bar] $ exit&#xA;[/bar] $ echo $myvar&#xA;&#xA;[/bar] $        # parent knows nothing about myvar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Parent processes are, broadly speaking, not altered by the things that occur in their children. It is no different when Vim is the parent of a shell process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally, if the parent wants to see what happens in the child the parent needs to look for it. In the case of Vim the primary way to look in at the child/shell is to capture its commands' output using the &lt;code&gt;system()&lt;/code&gt; function or to use &lt;code&gt;:r !cmds&lt;/code&gt; to read the output into a buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;As for the other version of the question that OP indicated interest in, &quot;Why does :cd change the directory?&quot; I'll assume &quot;the directory&quot; here refers to the current working directory of a subsequently launched shell ...if we were talking about Vim's working directory a fair answer to that would be &quot;Because that's what the command does.&quot;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:cd&lt;/code&gt; is a Vim command operating in the Vim program space and the directory it changes is associated with the Vim process. One way this is useful is if you try to edit a file without a path (e.g. &lt;code&gt;foo.txt&lt;/code&gt;) Vim will look in this directory for the file. A subsequently launched shell process inherits Vim's working directory because, well, that's how they've implemented it. They didn't have to do it that way. Vim is not a &quot;shell process&quot; it's a Vim process. But it's a natural way to do things&lt;sup&gt;1&lt;/sup&gt; and many are accustomed to partial inheritance with nested shell processes...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[/bar] $ myvar=this                # ordinary variable&#xA;[/bar] $ MYVAR=that; export MYVAR  # environment variable&#xA;[/bar] $ cd /foo                   # change current working dir&#xA;[/foo] $ sh                        # launch child shell&#xA;[/foo] $ echo $MYVAR               # c.w.d. inherited&#xA;that                               # env vars inherited&#xA;[/foo] $ echo $myvar&#xA;                                   # regular vars NOT inherited&#xA;[/foo] $ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running a shell command from Vim mimics such behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; &lt;sub&gt;In fact, most common operating systems support this behavior automatically and by default. That is when you exec or fork or whatever to launch a new process there is inheritance of some defined subset of the parent process' context/environment&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-02-21T08:36:39.160" LastActivityDate="2020-02-21T08:36:39.160" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22950" PostTypeId="2" ParentId="22947" CreationDate="2020-02-20T07:34:26.447" Score="8" Body="&lt;p&gt;Since &lt;code&gt;vim&lt;/code&gt; is not a shell and you executed a shell command, you must have also executed a shell. You then told that shell to execute the &lt;code&gt;cd&lt;/code&gt; command, which will change its working directory. The shell then terminated. The net effect of asking a shell to change its working directory and then terminate is nothing since the shell never did anything that was affected by its working directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to ask &lt;code&gt;vim&lt;/code&gt; to change &lt;em&gt;its&lt;/em&gt; working directory. That cannot be done by executing a shell command that changes that shell's working directory.&lt;/p&gt;&#xA;" OwnerUserId="27042" LastActivityDate="2020-02-20T07:34:26.447" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22951" PostTypeId="1" CreationDate="2020-02-20T12:14:17.180" Score="1" ViewCount="487" Body="&lt;p&gt;How could I get something like a buffer/argument list or a filter for individual windows, with a chosen subset of the buffers? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I could have a window just for header files in C (files ending in .h), which I can quickly cycle through, and navigate with a substring in a command like :b. But say there's both main.c and main.h, because it's looking at only *.h, using &lt;code&gt;:&amp;lt;dream-command-like-b&amp;gt; main&lt;/code&gt; won't complain there's both main.c and main.h and will take me to main.h.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see location lists are window-local but I don't think they're what I'm looking for.&lt;/p&gt;&#xA;" OwnerUserId="26698" LastActivityDate="2022-07-27T18:23:44.490" Title="Buffer list per window" Tags="|buffers|vim-windows|list|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22952" PostTypeId="1" CreationDate="2020-02-20T14:17:59.610" Score="1" ViewCount="565" Body="&lt;p&gt;I want the behavior of &lt;code&gt;:vnew term://make ts run-server&lt;/code&gt; but using the &lt;code&gt;make&lt;/code&gt; command instead of invoking &lt;code&gt;term&lt;/code&gt;. I have tried &lt;code&gt;:make ts run-server | vert copen&lt;/code&gt; but that still takes over the entire terminal until it's finished, and then it opens a vertically split buffer, but I want it to open a vertically split buffer and have all the output in that new buffer only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for why I want this, 2 reasons: 1) I'm curious how to do it, and 2) using &lt;code&gt;term&lt;/code&gt; doesn't give me the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I want to do this without plugins. If this functionality isn't possible without a plugin, I will content myself with &lt;code&gt;:vnew term://make ts run-server&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="25625" LastEditorUserId="25625" LastEditDate="2020-02-20T16:08:14.280" LastActivityDate="2020-02-20T16:08:14.280" Title="How to show make command's output in vertically split buffer?" Tags="|makeprg|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22953" PostTypeId="2" ParentId="22952" CreationDate="2020-02-20T15:31:12.627" Score="3" Body="&lt;p&gt;Your first command was closer: &lt;code&gt;:vnew&lt;/code&gt; makes a new vertical window. &lt;code&gt;:vertical&lt;/code&gt; is the modifier that changes how other commands work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vertical terminal make ts run-server&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will get you the terminal. If you want that &lt;em&gt;and&lt;/em&gt; the quickfix list, try tpope's Dispatch plugin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Dispatch make ts run-server&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-02-20T15:31:12.627" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22954" PostTypeId="1" AcceptedAnswerId="22967" CreationDate="2020-02-20T16:47:40.453" Score="2" ViewCount="346" Body="&lt;p&gt;Whenever I copy with &lt;code&gt;&quot;+y&lt;/code&gt; it only works for the instance of vim I am running and I would expect it to write to my system clipboard, that I can access both outside of vim and from other vim instances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked into previous posts on the forum and they don't solve my issue.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When I run &lt;code&gt;vim --version&lt;/code&gt;, the output contains &lt;code&gt;+X11&lt;/code&gt; and &lt;code&gt;gtk-3.0&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I'm using &lt;code&gt;vimx&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;set clipboard=unnamedplus,unnamed&lt;/code&gt; doesn't help.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Here's my output from &lt;code&gt;:reg&lt;/code&gt;:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Type Name Content&#xA;  1   c  &quot;&quot;   ^JType Name Content^J&amp;lt;d0&amp;gt;&#xA;  2   c  &quot;0   ^JType Name Content^J  c  &quot;&quot;   ^JType Name Content^J&amp;lt;d0&amp;gt;^J &amp;lt;bc&amp;gt;Sy)V&#xA;  3   l  &quot;1   set clipboard^=unnamed^J&#xA;  4   l  &quot;2   &quot; Use standard clipboard ^J&#xA;  5   l  &quot;3   set clipboard=unnamedplus^J&#xA;  6   l  &quot;4   unname^J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27053" LastActivityDate="2020-02-22T05:56:27.513" Title="Copying to unnamedplus doesn't work across instances" Tags="|os-clipboard|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="22955" PostTypeId="1" CreationDate="2020-02-20T19:50:42.080" Score="1" ViewCount="356" Body="&lt;p&gt;I'm attempting to configure ctags for a Node.js project that I'm using, and having some difficulty getting off the ground. My goal is to have my &lt;code&gt;tags&lt;/code&gt; file live in the &lt;code&gt;.git&lt;/code&gt; directory. I've browsed through a number of different questions, but none have resolved this specific issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running on MacOS Catalina (version 10.15.3), and using iTerm2 as my terminal (version 3.3.7). &#xA;I began by installing ctags using &lt;code&gt;brew install ctags&lt;/code&gt;. For the sake of eliminating potential issues with multiple instances of ctags, I generated my tags file with the full path to the ctags executable installed by brew:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/local/Cellar/ctags/5.8_1/bin/ctags -R -f .git/tags --exclude=node_modules&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I verified that this created the tags file, and that it's populated with data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there, I opened a file in vim, and used &lt;code&gt;&amp;lt;ctrl + ]&amp;gt;&lt;/code&gt; to attempt to jump to a tag. I get this error: &lt;code&gt;E433: No tags file&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've gone through a number of iterations of trying to set the tags variable, and none have worked to this point. In my current state, here's the output of &lt;code&gt;:set tags?&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; tags=~/path/to/my/project/.git/tags,.git/tags;~,./tags;~,./tags,tags&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what further troubleshooting steps I can take from here, so any additional advice would be appreciated. Thanks in advance for the help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've created a simple reproduction case that exhibits the same behavior. I created a new Node project at &lt;code&gt;~/Documents/Sandbox/node/ctags_test&lt;/code&gt;. I initialized it with &lt;code&gt;npm init&lt;/code&gt; and &lt;code&gt;git init&lt;/code&gt;, and installed Express with &lt;code&gt;npm install express&lt;/code&gt;. I created this simple &lt;code&gt;index.js&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var express = require('express');&#xA;&#xA;var app = express();&#xA;&#xA;app.get('/', function(req, res) {&#xA;    res.send('Hello, world!');&#xA;});&#xA;&#xA;app.listen(8080, function () {&#xA;    console.log('Ctags server running');&#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After this point, I ran the same steps I ran above to generate my tags file in the &lt;code&gt;.git&lt;/code&gt; directory. After verifying that the tags file was generated, I opened &lt;code&gt;index.js&lt;/code&gt;, and moved the cursor over the word &quot;express&quot; in line 3, and hit &lt;code&gt;&amp;lt;ctrl + ]&amp;gt;&lt;/code&gt;. I got the same error as in the previous case.&lt;/p&gt;&#xA;" OwnerUserId="27056" LastEditorUserId="27056" LastEditDate="2020-02-20T23:13:40.807" LastActivityDate="2020-02-20T23:13:40.807" Title="Configuring ctags for a Node.js project: No tags file" Tags="|ctags|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="22956" PostTypeId="2" ParentId="3670" CreationDate="2020-02-20T20:38:41.260" Score="16" Body="&lt;p&gt;On neovim, you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;          autocmd TermOpen * startinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Found in &lt;code&gt;:help :terminal&lt;/code&gt; . &lt;/p&gt;&#xA;" OwnerUserId="27058" LastEditorUserId="1238" LastEditDate="2020-02-21T10:38:51.703" LastActivityDate="2020-02-21T10:38:51.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22957" PostTypeId="1" AcceptedAnswerId="22959" CreationDate="2020-02-21T01:43:01.877" Score="2" ViewCount="204" Body="&lt;p&gt;I was editing a small configure script and noticed that vim's indentation of the file was not working properly.  A sample of the original source follows:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;while getopts 'dgSsx' opt; do&#xA;    case $opt in&#xA;    d) DEBUG=true ;;&#xA;    g) USE_GDB=true ;;&#xA;        S) USE_GEB=TRUE SMALL=true ;;&#xA;        s) SMALL=true ;;&#xA;        x) XFT=true ;;&#xA;    ?) for line in \&#xA;            '-d enable debugging with verbose log output' \&#xA;                '-g enable debug symbols' \&#xA;                '-s optimize for size' \&#xA;                '-x use Xft fonts' \&#xA;        '-? show usage'; \&#xA;        do echo $line; done ;;&#xA;    esac&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After running &lt;strong&gt;&lt;em&gt;gg=G&lt;/em&gt;&lt;/strong&gt;, the source looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;while getopts 'dgSsx' opt; do&#xA;case $opt in&#xA;d) DEBUG=true ;;&#xA;g) USE_GDB=true ;;&#xA;S) USE_GEB=TRUE SMALL=true ;;&#xA;s) SMALL=true ;;&#xA;x) XFT=true ;;&#xA;?) for line in \&#xA;'-d enable debugging with verbose log output' \&#xA;'-g enable debug symbols' \&#xA;'-s optimize for size' \&#xA;'-x use Xft fonts' \&#xA;'-? show usage'; \&#xA;do echo $line; done ;;&#xA;esac&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Auto-indent works fine while editing.  What is necessary to get vim's whole-file indentation to work on shell scripts?&lt;/p&gt;&#xA;" OwnerUserId="27062" LastActivityDate="2020-02-21T08:01:30.167" Title="What is necessary to properly indent shell scripts with gg=G?" Tags="|indentation|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22958" PostTypeId="2" ParentId="7902" CreationDate="2020-02-21T01:58:01.743" Score="0" Body="&lt;p&gt;If you are using Linux, here is a bit of a hacky solution. You can augment your &lt;code&gt;gvim&lt;/code&gt; command with a shell command that interacts with windows, like &lt;code&gt;xdotool&lt;/code&gt; or &lt;code&gt;wmctrl&lt;/code&gt;. Here's an example using &lt;code&gt;xdotool&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;xdotool getactivewindow &gt; /tmp/gvim_wid.txt &amp;&amp; \&#xA;gvim --servername DEBUG --remote-tab-silent +&lt;i&gt;line_number&lt;/i&gt; &lt;i&gt;file_name&lt;/i&gt; &amp;&amp; \&#xA;gvim --servername DEBUG --remote-expr &quot;system('cat /tmp/gvim_wid.txt | xargs xdotool windowactivate')&quot;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explanation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;line 1&lt;/em&gt;: use &lt;code&gt;xdotool&lt;/code&gt; to get the window ID of the debugger window, and save it to a file (&lt;code&gt;/tmp/gvim_wid.txt&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;line 2&lt;/em&gt;: run your &lt;code&gt;gvim&lt;/code&gt; command&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;line 3&lt;/em&gt;: run another &lt;code&gt;gvim&lt;/code&gt; command which executes an &lt;code&gt;xdotool&lt;/code&gt; command to focus the debugger window (using the window ID from the file)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A similar approach would be to save the window ID to a shell variable instead of a file, and run the final &lt;code&gt;xdotool&lt;/code&gt; command directly from the shell. However, I was only able to make that method work by adding a &lt;code&gt;sleep&lt;/code&gt; command before the final &lt;code&gt;xdotool&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I don't know if there is an &lt;code&gt;xdotool&lt;/code&gt; alternative in Windows, but I imagine there must be something similar.&lt;/p&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2020-02-21T01:58:01.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22959" PostTypeId="2" ParentId="22957" CreationDate="2020-02-21T06:58:13.297" Score="3" Body="&lt;p&gt;After I did &lt;code&gt;gg=G&lt;/code&gt; for the buffer with &lt;code&gt;set ft=sh&lt;/code&gt; I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while getopts 'dgSsx' opt; do&#xA;    case $opt in&#xA;        d) DEBUG=true ;;&#xA;        g) USE_GDB=true ;;&#xA;        S) USE_GEB=TRUE SMALL=true ;;&#xA;        s) SMALL=true ;;&#xA;        x) XFT=true ;;&#xA;        ?) for line in \&#xA;            '-d enable debugging with verbose log output' \&#xA;            '-g enable debug symbols' \&#xA;            '-s optimize for size' \&#xA;            '-x use Xft fonts' \&#xA;            '-? show usage'; \&#xA;        do echo $line; done ;;&#xA;    esac&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which looks ok for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I turned off &lt;code&gt;filetype indent off&lt;/code&gt; and in a new buffer did the same I got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while getopts 'dgSsx' opt; do&#xA;case $opt in&#xA;d) DEBUG=true ;;&#xA;g) USE_GDB=true ;;&#xA;S) USE_GEB=TRUE SMALL=true ;;&#xA;s) SMALL=true ;;&#xA;x) XFT=true ;;&#xA;?) for line in \&#xA;        '-d enable debugging with verbose log output' \&#xA;        '-g enable debug symbols' \&#xA;        '-s optimize for size' \&#xA;        '-x use Xft fonts' \&#xA;        '-? show usage'; \&#xA;        do echo $line; done ;;&#xA;esac&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which looks almost like what you have.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do you have &lt;code&gt;filetype indent on&lt;/code&gt; in your vimrc?&lt;/li&gt;&#xA;&lt;li&gt;What is your vim version? (I have the latest nightly so it might be something that was fixed)&lt;/li&gt;&#xA;&lt;li&gt;What is the output of &lt;code&gt;verbose set indentexpr?&lt;/code&gt; ?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turn on indent plugins by adding &lt;code&gt;filetype indent on&lt;/code&gt; to your vimrc.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-02-21T08:01:30.167" LastActivityDate="2020-02-21T08:01:30.167" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22960" PostTypeId="1" AcceptedAnswerId="22961" CreationDate="2020-02-21T08:45:32.477" Score="3" ViewCount="318" Body="&lt;p&gt;Say I want to match a buffer with no filename.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can use the pattern &lt;code&gt;*&lt;/code&gt;, then manually check the filename, like &lt;code&gt;autocmd myVimrc BufEnter * if @% == &quot;&quot; | echom 'blank filename' | endif&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a pattern to match just blank filenames?&lt;/p&gt;&#xA;" OwnerUserId="16419" LastActivityDate="2020-02-21T08:45:32.477" Title="Autocmd pattern to match empty file/no filename" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22961" PostTypeId="2" ParentId="22960" CreationDate="2020-02-21T08:45:32.477" Score="2" Body="&lt;p&gt;&lt;code&gt;{}&lt;/code&gt; seems to work for just blank filenames.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;code&gt;autocmd myVimrc BufEnter {} echom 'blank filename'&lt;/code&gt;. Much cleaner&lt;/p&gt;&#xA;" OwnerUserId="16419" LastActivityDate="2020-02-21T08:45:32.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22962" PostTypeId="1" AcceptedAnswerId="22963" CreationDate="2020-02-21T14:42:12.617" Score="1" ViewCount="1042" Body="&lt;p&gt;I am trying to install the vim-grammarous plugin for Vim 8.0.1453. I have cloned the repo into my .vim/plugin directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now every time I open Vim I get an error message which also occurs when I  try to use the plugin.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing ~/.vim/plugin/vim-grammarous/autoload/grammarous.vim:&#xA;line    4:&#xA;E117: Unknown function: vital#grammarous#new&#xA;E15: Invalid expression: vital#grammarous#new()&#xA;line    5:&#xA;E121: Undefined variable: s:V&#xA;E15: Invalid expression: s:V.import('Web.XML')&#xA;line    6:&#xA;E121: Undefined variable: s:V&#xA;E15: Invalid expression: s:V.import('OptionParser')&#xA;line    7:&#xA;E121: Undefined variable: s:V&#xA;E15: Invalid expression: s:V.import('Process')&#xA;line  501:&#xA;E121: Undefined variable: s:O&#xA;E15: Invalid expression: s:O.new().on('--lang=VALUE', 'language to check', &#xA;  {'default' : g:grammarous#default_lang}).on('--[no-]preview',  &#xA;   'enable auto preview', {'default' : 1}).on('--[no-]comments-only',  &#xA;   'check comment only',  {'default' : ''}).on('--[no-]move-to-first-error', &#xA;   'move to first error', {'default' : g:grammarous#move_to_first_error}).on('--&#xA;    reinstall-languagetool',   'reinstall LanguageTool', {'default' : 0})&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get vim-grammarous to work?&lt;/p&gt;&#xA;" OwnerUserId="27075" LastActivityDate="2020-02-21T15:51:10.957" Title="Error detected while processing grammarous.vim: E117: Unknown function" Tags="|vimscript|plugin-system|functions|error|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22963" PostTypeId="2" ParentId="22962" CreationDate="2020-02-21T15:35:35.303" Score="2" Body="&lt;p&gt;The &lt;code&gt;.vim/plugin&lt;/code&gt; directory is &lt;em&gt;not&lt;/em&gt; where you want to unpack your plug-ins! (Yes, I known the name would suggest so...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use Vim 8 packages (which I believe you do), then you should unpack it under a directory named &lt;code&gt;~/.vim/pack/*/start&lt;/code&gt;, where the component after &lt;code&gt;pack&lt;/code&gt; can be named anything (suggestions are &lt;code&gt;bundle&lt;/code&gt;, &lt;code&gt;vendor&lt;/code&gt; or your username.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#packages&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help packages&lt;/code&gt;&lt;/a&gt; for more information about Vim packages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One alternative to Vim packages is to use a Vim plug-in manager to manage your plug-ins (they can load, install and update them.) If you decide to use a plug-in manager, I'd recommend &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt;, which is simple to install (just download a single file), to configure and to use.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;About the &lt;code&gt;~/.vim/plugin&lt;/code&gt; directory, that's a much simpler concept of plug-in and it simply includes Vim script files that are &lt;em&gt;always unconditionally&lt;/em&gt; loaded by Vim on startup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Vim evolved, the need for Vim scripts that would loaded in different situations arose, and new directories were added for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;dynamically loaded Vim scripts, loaded when a function in that namespace is first called (&lt;code&gt;autoload&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;scripts that are loaded for files of specific types, for example code in specific languages (&lt;code&gt;ftplugin&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;scripts to detect what the type of a file should be, based on its extension or even file contents (&lt;code&gt;ftdetect&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;scripts implementing syntax highlighting (&lt;code&gt;syntax&lt;/code&gt;) or indentation (&lt;code&gt;indent&lt;/code&gt;) for a specific file type.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A &quot;modern&quot; Vim plug-in is in fact a package that will typically include Vim scripts split into one or more of these directories. (In fact, a large part of plug-ins will not even ship anything in the &lt;code&gt;plugin&lt;/code&gt; directory, which means they typically don't incur any cost at Vim startup and only get loaded when they're used, either through a filetype or when an autoloaded function is invoked.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the term &lt;code&gt;plugin&lt;/code&gt; was already used, Vim 8 decided to call these &quot;packages&quot;, but of course the common term for those is still a &quot;Vim plug-in,&quot; which unfortunately causes this confusion.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-02-21T15:51:10.957" LastActivityDate="2020-02-21T15:51:10.957" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22964" PostTypeId="1" AcceptedAnswerId="22965" CreationDate="2020-02-21T18:26:42.210" Score="2" ViewCount="192" Body="&lt;p&gt;Is there a way to save the value of a setting to a buffer or a file?  For example, when I type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set guifont&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It displays the setting I want to use but as soon as I start typing in the buffer it disappears.  I'm trying to do this using gvim on Windows but I suspect the answer will be generic.&lt;/p&gt;&#xA;" OwnerUserId="2399" LastActivityDate="2020-02-21T19:16:46.337" Title="Saving setting to buffer" Tags="|gvim|buffers|default-settings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22965" PostTypeId="2" ParentId="22964" CreationDate="2020-02-21T19:16:46.337" Score="4" Body="&lt;p&gt;There are too(?) many ways to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) :mkexrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:mkexrc [file]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;writes all mappings and changed options to a file (.exrc by default)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Option window&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:options&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;opens a buffer with extra UI to change options (the code is in $VIMRUNTIME/optwin.vim); of course, the buffer is accessible by standard Vim commands too&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Expression register&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i&amp;lt;C-R&amp;gt;=&amp;amp;guifont&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will insert the value of option &lt;code&gt;guifont&lt;/code&gt; into the current buffer&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) execute()&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;x :-1put=trim(execute(input(\&quot;:\&quot;)))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;press &lt;code&gt;&amp;lt;leader&amp;gt;x&lt;/code&gt; and then input any Vim command (e.g. &lt;code&gt;set&lt;/code&gt;); the output will be inserted into the current buffer&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anything else I forgot?&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-21T19:16:46.337" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22966" PostTypeId="2" ParentId="22937" CreationDate="2020-02-22T00:20:11.303" Score="0" Body="&lt;p&gt;You can use Vim's &lt;code&gt;job_start()&lt;/code&gt; function to run a command asynchronously. This does not require any plugins, but does require Vim to be compiled with the &lt;code&gt;+job&lt;/code&gt; feature (you can check this by running the &lt;code&gt;:version&lt;/code&gt; command).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a long one-liner to apply your command:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;autocmd FileType tex :nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;F5&amp;gt;&#xA;    \ :let b:job = job_start(['/bin/sh', '-c', 'pdflatex ' . expand('%:p')])&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;pdflatex&lt;/code&gt; command only works if your tex file is in Vim's current working directory. So you may want to consider using &lt;code&gt;latexmk&lt;/code&gt; instead, which provides a &lt;code&gt;-cd&lt;/code&gt; option. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I've noticed that in some cases, &lt;code&gt;job_start()&lt;/code&gt; will slightly mess up the screen. If this happens, you may want to add a callback function to redraw the screen (see &lt;a href=&quot;https://vi.stackexchange.com/a/20481/16602&quot;&gt;this answer&lt;/a&gt; to a related question).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2020-02-22T00:20:11.303" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22967" PostTypeId="2" ParentId="22954" CreationDate="2020-02-22T05:56:27.513" Score="3" Body="&lt;p&gt;On Linux/Unix, the Vim clipboard support communicates with the X11 system to synchronize the selection referred to by the &lt;code&gt;&quot;+&lt;/code&gt; and &lt;code&gt;&quot;*&lt;/code&gt; registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this feature to work, Vim needs to be able to communicate with the X11 server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;X11 is designed in a way that allows you to run multiple instances on the same host (multiple &quot;displays&quot;) and applications use the &lt;code&gt;$DISPLAY&lt;/code&gt; environment variable to determine &lt;em&gt;which&lt;/em&gt; X11 display to use (in other words, which X11 server to connect to.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, you noticed you had &lt;code&gt;DISPLAY=:0&lt;/code&gt; inside tmux, where you're running Vim... While outside of tmux your terminal emulator reports &lt;code&gt;DISPLAY=:1&lt;/code&gt;... What that means is that Vim inside tmux is &lt;em&gt;trying to connect to the wrong X11 server.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;export DISPLAY=:1&lt;/code&gt; in your shell inside tmux fixes your problem, by having Vim inside tmux connect to the correct X11 server. (You might need to also reset this in other tmux windows/panes or in new shells that you open in tmux.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem is most likely related to you having started tmux on one X11 session, then later reconnecting to it from another X11 session (perhaps you logged out from the GUI and logged in again, or a similar operation.) Since the selection of X11 display is controlled by an environment variable, once you start tmux in a specific display, it will by default stick to that display, which will also be inherited by shells and processes spawned in that tmux instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Unfortunately, there doesn't seem to be a more general solution to this problem that doesn't involve updating the &lt;code&gt;$DISPLAY&lt;/code&gt; variable once you reconnect, or once you notice the issue...)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-22T05:56:27.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22968" PostTypeId="1" AcceptedAnswerId="22969" CreationDate="2020-02-22T14:36:04.463" Score="4" ViewCount="132" Body="&lt;p&gt;I'm writing a paper on logic where I mention the rule &lt;em&gt;modus ponens&lt;/em&gt; often.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neither &lt;em&gt;modus&lt;/em&gt; nor &lt;em&gt;ponens&lt;/em&gt; are words in English, and the ideal spell checker should mark them as incorrect. However, &lt;em&gt;modus ponens&lt;/em&gt; is a correct word, and should be marked correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do something like this with the Vim spellchecker?&lt;/p&gt;&#xA;" OwnerUserId="2526" LastActivityDate="2020-02-22T15:14:24.230" Title="How can I add a definition with several words to the spell checker?" Tags="|spell-checking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22969" PostTypeId="2" ParentId="22968" CreationDate="2020-02-22T14:55:25.820" Score="5" Body="&lt;p&gt;In normal mode, &lt;code&gt;zg&lt;/code&gt; adds the word under cursor as a &lt;strong&gt;g&lt;/strong&gt;ood word to &lt;code&gt;'spellfile'&lt;/code&gt;. In visual mode, the selected text is added. So selecting the word &lt;em&gt;modus ponens&lt;/em&gt; and pressing &lt;code&gt;zg&lt;/code&gt; will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;em&gt;modus&lt;/em&gt; is recognized as a good word in &lt;code&gt;Vim&lt;/code&gt;. Use &lt;code&gt;zw&lt;/code&gt; to mark it as &lt;strong&gt;w&lt;/strong&gt;rong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may need to put this line of code in your &lt;code&gt;.vimrc&lt;/code&gt; to specify the path to &lt;code&gt;'spellfile'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set spellfile=$HOME/.vim/spell/en.utf-8.add&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25618" LastEditorUserId="25618" LastEditDate="2020-02-22T15:14:24.230" LastActivityDate="2020-02-22T15:14:24.230" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22970" PostTypeId="2" ParentId="11629" CreationDate="2020-02-23T00:12:56.583" Score="1" Body="&lt;p&gt;I was having the same issue. On Ubuntu, set backupcopy=yes was set and yet multiple file writes were happening. I disabled all plugins and saw there was only a single write. I added each plugin back one-by-one and found that &lt;code&gt;polyglot&lt;/code&gt; broke it. It then ended up being &lt;code&gt;ElmCast/elm-vim&lt;/code&gt; which is installed by polyglot which does the double file writes. I turned it off via &lt;code&gt;let g:elm_format_autosave = 0&lt;/code&gt; and things worked again.&lt;/p&gt;&#xA;" OwnerUserId="27095" LastActivityDate="2020-02-23T00:12:56.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22971" PostTypeId="1" CreationDate="2020-02-23T01:33:45.243" Score="1" ViewCount="37" Body="&lt;p&gt;I want iskeyword to only affect completion.&lt;/p&gt;&#xA;&lt;p&gt;I need that in the case of Latex. I want &lt;code&gt;\chi_{23}&lt;/code&gt; to be a single object with regard to complition. But changing &lt;code&gt;iskeyword&lt;/code&gt; also makes &lt;code&gt;\dosomething{crap}&lt;/code&gt; a single object which means I can't get to crap using w.&lt;/p&gt;&#xA;&lt;p&gt;I know I can reimplement all w,b, and so on as they were in the original form. It is not simple at all. Any quicker way?&lt;/p&gt;&#xA;&lt;p&gt;Any plugin that already implemented it or something?&lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2021-01-25T20:32:21.230" LastActivityDate="2021-01-25T20:32:21.230" Title="A quick way to restore motion after changing iskeyword" Tags="|cursor-motions|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22972" PostTypeId="1" AcceptedAnswerId="23070" CreationDate="2020-02-23T01:43:27.523" Score="4" ViewCount="170" Body="&lt;p&gt;Is there a quick way to delete brackets &lt;code&gt;( some string )&lt;/code&gt; and then select &quot;some string&quot;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ds(&lt;/code&gt; deletes them (using the &lt;code&gt;surround&lt;/code&gt; plugin). &lt;code&gt;vi(&lt;/code&gt; selects but only when they exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;looking for normal mode. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="26819" LastEditDate="2020-03-03T02:49:00.190" LastActivityDate="2020-03-03T02:49:00.190" Title="delete brackets and select region" Tags="|cursor-motions|normal-mode|plugin-vim-surround|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22973" PostTypeId="1" CreationDate="2020-02-23T06:09:53.543" Score="2" ViewCount="103" Body="&lt;p&gt;Is there an easy way to wrap LaTeX source? Using &lt;code&gt;gwip&lt;/code&gt; is great for individual paragraphs,&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-latex prettyprint-override&quot;&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed&#xA;do eiusmod tempor incididunt ut labore et dolore magna&#xA;aliqua. Ut enim ad minim veniam, quis nostrud exercitation&#xA;ullamco laboris nisi ut aliquip ex ea commodo consequat.&#xA;Duis aute irure dolor in reprehenderit in voluptate velit&#xA;esse cillum dolore eu fugiat nulla pariatur.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...but it fails more generally for other situations such as itemize environments:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-latex prettyprint-override&quot;&gt;&lt;code&gt;\begin{itemize}&#xA;  \item Lorem ipsum dolor sit amet, consectetur adipiscing&#xA;    elit, sed do eiusmod tempor incididunt ut labore et&#xA;    dolore magna aliqua.&#xA;  \item Ut enim ad minim veniam, quis nostrud exercitation&#xA;    ullamco laboris nisi ut aliquip ex ea commodo consequat.&#xA;  \item Duis aute irure dolor in reprehenderit in voluptate&#xA;    velit esse cillum dolore eu fugiat nulla pariatur.&#xA;\end{itemize}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or captions:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-latex prettyprint-override&quot;&gt;&lt;code&gt;\begin{figure}&#xA;  \caption[Lorem ipsum]{%&#xA;    Lorem ipsum dolor sit amet, consectetur adipiscing elit,&#xA;    sed do eiusmod tempor incididunt ut labore et dolore&#xA;    magna aliqua. Ut enim ad minim veniam, quis nostrud&#xA;    exercitation ullamco laboris nisi ut aliquip ex ea&#xA;    commodo consequat. Duis aute irure dolor in&#xA;    reprehenderit in voluptate velit esse cillum dolore eu&#xA;    fugiat nulla pariatur.%&#xA;  }&#xA;\end{figure}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Issues:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using &lt;code&gt;gw&lt;/code&gt; in visual mode is not very fast. (&lt;code&gt;gwip&lt;/code&gt; with the &lt;code&gt;ip&lt;/code&gt; text-object is far easier and doesn't require manual selection.)&lt;/li&gt;&#xA;&lt;li&gt;Using &lt;code&gt;textwidth=80&lt;/code&gt; is great for auto-wrapping when writing a fresh paragraph, but not very helpful when editing text in the middle of a paragraph.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Autowrapping within a middle of a paragraph can be accomplished with &lt;code&gt;set formatoptions+=a&lt;/code&gt;, but that also ends up wrapping everything &lt;em&gt;after&lt;/em&gt; the paragraph too:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-latex prettyprint-override&quot;&gt;&lt;code&gt;\begin{figure}&#xA;  \caption[Lorem ipsum]{%&#xA;    Lorem ipsum dolor sit amet, consectetur adipiscing elit,&#xA;    sed do eiusmod tempor incididunt ut labore et dolore&#xA;    magna aliqua.% } \end{figure}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7070" LastEditorUserId="7070" LastEditDate="2020-02-23T06:40:43.897" LastActivityDate="2020-02-23T17:18:16.907" Title="gw text wrapping for LaTeX" Tags="|filetype-tex|wrapping|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22974" PostTypeId="1" AcceptedAnswerId="22976" CreationDate="2020-02-23T09:12:48.690" Score="1" ViewCount="479" Body="&lt;p&gt;I am trying to make a plugin, which will be displaying a content of registers in the side bar and updating this side bar at every register's changing.&#xA;To accomplish this task I decided to set a hook on the &lt;code&gt;TextYankPost&lt;/code&gt; event and to write a changed register's dictionary into the side bar window when this event happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there is a problem - the &lt;code&gt;autocmd&lt;/code&gt; doesn't allow writing commands like &lt;code&gt;:put&lt;/code&gt; inside a called function, so when I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Write_to_buffer()&#xA;    put ='hello'&#xA;endfunction&#xA;&#xA;autocmd TextYankPost * :call Write_to_buffer()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get an error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function Write_to_buffer:&#xA;line    1:&#xA;E523: Not allowed here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without a writing command all works as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Write_to_buffer()&#xA;    echo 'hello'&#xA;endfunction&#xA;&#xA;autocmd TextYankPost * :call Write_to_buffer()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;:h E523&lt;/code&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When on, &quot;:autocmd&quot;, shell and write commands are not allowed in&#xA;  &quot;.vimrc&quot; and &quot;.exrc&quot; in the current directory and map commands are&#xA;  displayed.  Switch it off only if you know that you will not run into&#xA;  problems, or when the 'exrc' option is off.  On Unix this option is&#xA;  only used if the &quot;.vimrc&quot; or &quot;.exrc&quot; is not owned by you.  This can be&#xA;  dangerous if the systems allows users to do a &quot;chown&quot;.  You better set&#xA;  'secure' at the end of your ~/.vimrc then.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Both &lt;code&gt;secure&lt;/code&gt; and &lt;code&gt;exrc&lt;/code&gt; options are &lt;strong&gt;off&lt;/strong&gt; in my case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo printf('secure = %s, exrc = %s', &amp;amp;secure, &amp;amp;exrc)&#xA;&quot; Output: secure = 0, exrc = 0 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So the questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is the usage of the &lt;code&gt;autocmd&lt;/code&gt; for tracking register changes right/optimal?&lt;/li&gt;&#xA;&lt;li&gt;How can a function called by the &lt;code&gt;autocmd&lt;/code&gt; be used for writing into a buffer?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="14024" LastEditorUserId="14024" LastEditDate="2020-02-23T09:18:27.067" LastActivityDate="2020-02-23T10:12:15.127" Title="Usage of a autocmd to write into a buffer - E523: Not allowed here" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22975" PostTypeId="1" AcceptedAnswerId="22977" CreationDate="2020-02-23T09:13:00.840" Score="2" ViewCount="357" Body="&lt;p&gt;I'm a total beginner that sees vim as a potential simple IDE,&#xA;(as well as a text editor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had several questions, but that was confusing, so I'll stick with just one already answered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like using the  key to switch from panel to panel, but it doesn't seem to work for terminal buffers.&#xA;Is there a command for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[edit]&#xA;never mind, I've discovered that I don't want it like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is my configuration file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;~/.vimrc&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Switch syntax highlighting on when the terminal has colors or when using the&#xA;&quot; GUI (which always has colors).&#xA;if &amp;amp;t_Co &amp;gt; 2 || has(&quot;gui_running&quot;)&#xA;  &quot; Revert with &quot;:syntax off&quot;.&#xA;  syntax on&#xA;&#xA;  &quot; I like highlighting strings inside C comments.&#xA;  &quot; Revert with &quot;:unlet c_comment_strings&quot;.&#xA;  let c_comment_strings=1&#xA;endif&#xA;&#xA;&quot; Directory tree configuration&#xA;let g:netrw_banner = 0&#xA;let g:netrw_liststyle = 3&#xA;let g:netrw_browse_split = 4&#xA;let g:netrw_altv = 1&#xA;let g:netrw_winsize = 25&#xA;&#xA;&quot; Number lines configuration and execution&#xA;highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey&#xA;set number&#xA;&#xA;&quot; To put the terminal at the bottom &#xA;set splitbelow&#xA;&#xA;&quot; Change window by pressing tab&#xA;noremap &amp;lt;Tab&amp;gt; &amp;lt;C-W&amp;gt;w&#xA;&#xA;&quot; Toggle to IDE mode&#xA;noremap ` :NERDTree&amp;lt;CR&amp;gt; &amp;lt;C-W&amp;gt;w :terminal&amp;lt;CR&amp;gt; &amp;lt;C-W&amp;gt;w :resize +10&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Mappings for dvorak keyboard layout&#xA;source ~/.livim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27098" LastEditorUserId="27098" LastEditDate="2020-02-23T16:44:21.817" LastActivityDate="2020-02-23T16:44:21.817" Title="Remapping keys doesn't seem to work in the terminal-buffer" Tags="|vim-windows|terminal-buffer|" AnswerCount="1" CommentCount="2" ClosedDate="2020-02-24T16:50:53.380" ContentLicense="CC BY-SA 4.0" />
  <row Id="22976" PostTypeId="2" ParentId="22974" CreationDate="2020-02-23T10:12:15.127" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is the usage of the autocmd for tracking register changes right/optimal?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, there are many ways to change a register. Something like &lt;code&gt;:let @0 = 'Some text'&lt;/code&gt; will change the register 0 just like &lt;code&gt;yank&lt;/code&gt; does. So you can't make it truly robust. That's simply impossible, I believe (unless you poll the timer, but that does not seem like a nice way to deal with this either).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can a function called by the autocmd be used for writing into a buffer?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This problem doesn't apply to autocommands in general (i.e. you &lt;strong&gt;can&lt;/strong&gt; write to buffer while inside an autocommand). It's specific to this individual autocommand. A quote from &lt;code&gt;:h TextYankPost&lt;/code&gt;: &quot;It is not allowed to change the buffer text, see :h textlock&quot;. So, for example, you can save &quot;a pending update&quot; in a list, and apply it later (maybe from within &lt;code&gt;:h CursorHold&lt;/code&gt;, or &lt;code&gt;:h SafeStateAgain&lt;/code&gt; or by a timer etc.).&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-23T10:12:15.127" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22977" PostTypeId="2" ParentId="22975" CreationDate="2020-02-23T16:00:21.893" Score="2" Body="&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; This answer reflects the first version of the question, before edits that made it more focused on a specific problem. Leaving this answer here in case it's useful to the original poster or others.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Resizing the terminal&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can give the &lt;code&gt;:terminal&lt;/code&gt; command a &lt;code&gt;++rows=20&lt;/code&gt; or &lt;code&gt;++cols=100&lt;/code&gt; argument to size it from the start. You can use &lt;code&gt;:vertical&lt;/code&gt; to open it in a vertical split if you like. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vertical rightbelow terminal ++cols=20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get a thin terminal window on the right side of the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#%3Aterminal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :terminal&lt;/code&gt;&lt;/a&gt; for the full range of options taken by the &lt;code&gt;:terminal&lt;/code&gt; command. (Also, &lt;code&gt;:help :vertical&lt;/code&gt;, &lt;code&gt;:help :rightbelow&lt;/code&gt;, &lt;code&gt;:help :resize&lt;/code&gt; if you decide to create a split first and run the terminal on that window with &lt;code&gt;++curwin&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Remapping the window change key in the terminal&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:tnoremap&lt;/code&gt; to create key bindings for the terminal. The terminal mappings are used in a terminal window, when typing keys for the job running in the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help :tnoremap&lt;/code&gt;, more specifically &lt;a href=&quot;https://vimhelp.org/map.txt.html#mapmode-t&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help mapmode-t&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#terminal-typing&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help terminal-typing&lt;/code&gt;&lt;/a&gt; which describes a lot of the pre-defined key bindings, many of which using &lt;code&gt;CTRL-W&lt;/code&gt; as a prefix (&lt;code&gt;CTRL-\&lt;/code&gt; is also already a prefix) that you can consider to use if you don't want to introduce new special keys for the terminal mode.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Three-split treeview/...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Suggestion: You might want to consider using NERDTree rather than netrw, since NERDTree was primarily designed as a &quot;project drawer&quot; and perhaps fits the treeview role better than netrw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to read the somewhat popular &lt;a href=&quot;http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Oil and Vinegar&lt;/a&gt; article, which talks about how the &quot;project drawer&quot; model doesn't fit Vim very well. (But don't worry too much about it, in practice NERDTree works quite well for most use cases, it might suit you well.)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Should I use GNU screen?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Personally, I think the built-in terminal is pretty nice and the fact you can set key bindings, have it in a split that doesn't span a full dimension, can yank and paste on it and you can start one on demand for a single command makes it very interesting compared to one running outside of Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you decide to use an external terminal window manager, I'd suggest you go with tmux rather than screen, tmux is more modern, more featureful and you'll likely find more tools (and more featureful, well maintained tools) integrating Vim with tmux rather than screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, there's &lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-tmux-navigator&lt;/a&gt; to use the usual &lt;code&gt;CTRL-W&lt;/code&gt; key bindings to navigate between Vim windows and tmux panes more seamlessly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, again, my personal choice would be the built-in terminal... But if you decide to go with an external tool, look into tmux.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Hopefully you'll find my comments here useful! Your question is too broad so it's hard to address everything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess my main advice is to get familiar with the &lt;code&gt;:help&lt;/code&gt; system in Vim, you can find a &lt;em&gt;lot&lt;/em&gt; of useful information there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Get familiar with the built-in terminal and see how much you can get from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Think twice before trying to completely reproduce the workflow you had from a previous IDE into Vim... You might get close to it, but &lt;em&gt;maybe&lt;/em&gt; that's not the best, most efficient way to use Vim productively. So think about spending some time trying to learn the Vim way of solving specific problems, if you start by bringing your own, you won't have an opportunity to explore them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck! It's a journey, but a worthy one!&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-02-23T16:12:17.907" LastActivityDate="2020-02-23T16:12:17.907" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="22978" PostTypeId="2" ParentId="22973" CreationDate="2020-02-23T17:18:16.907" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt; plug-in can help here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Among its &lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/README.md#features&quot; rel=&quot;nofollow noreferrer&quot;&gt;features&lt;/a&gt; you'll find it support custom text objects:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;code&gt;ic ac&lt;/code&gt; Commands&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;id ad&lt;/code&gt; Delimiters&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;ie ae&lt;/code&gt; LaTeX environments&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;i$ a$&lt;/code&gt; Inline math structures&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;iP aP&lt;/code&gt; Sections&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your case, it seems to me that &lt;code&gt;gwie&lt;/code&gt; would do what you're looking for, selecting the text inside an environment, which is the block delimited by &lt;code&gt;\begin{...}&lt;/code&gt; and &lt;code&gt;\end{...}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you also install the &lt;a href=&quot;https://github.com/wellle/targets.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;targets.vim&lt;/a&gt; plug-in, you can enable additional text objects for environments, see &lt;a href=&quot;https://github.com/lervag/vimtex/blob/master/doc/targets-textobj-cheatsheet.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;targets-textobj-cheatsheet.md&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-23T17:18:16.907" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22979" PostTypeId="2" ParentId="3951" CreationDate="2020-02-23T18:29:38.970" Score="3" Body="&lt;h2&gt;Paste without new line&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Put this in your .vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Paste yanked line without line breaks before/after cursor position&#xA;nnoremap gP i&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;PkJxJx&#xA;nnoremap gp a&amp;lt;CR&amp;gt;&amp;lt;Esc&amp;gt;PkJxJx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;span style=&quot;color:&quot;&amp;gt;danger&amp;lt;/span&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can type &lt;code&gt;gp&lt;/code&gt; to insert &lt;code&gt;#D51B3F&lt;/code&gt; after &lt;code&gt;color:&lt;/code&gt; while my cursor is at &lt;code&gt;:&lt;/code&gt; in Normal mode.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Yank without new line&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Use flukus' answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Delete current line without yanking the line breaks&#xA;nnoremap dil ^d$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as acronym of &lt;em&gt;delete inner line&lt;/em&gt;. This also gets rid of leading indentation.&lt;/p&gt;&#xA;" OwnerUserId="27100" LastActivityDate="2020-02-23T18:29:38.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22980" PostTypeId="1" CreationDate="2020-02-24T02:08:28.750" Score="1" ViewCount="163" Body="&lt;p&gt;vim 8 support terminal, and has a api to let command in terminal to communicate back to vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vim, define function like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; .vimrc&#xA;let g:cnt = get(g:, 'cnt', 0)&#xA;func! Tapi_Command_finish(bufnum, arglist) abort&#xA;    let g:cnt += 1&#xA;endfunc &quot; Tapi_Command_finish&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;open a terminal buffer, run command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf '\033]51;[&quot;call&quot;,&quot;Tapi_%s&quot;, [&quot;%s&quot;]]\007' Command_finish&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then go back to vim, &lt;code&gt;:echo g:cnt&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt; will be echoed, demonstrate function &lt;code&gt;Tapi_Command_finish&lt;/code&gt; being called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works in linux, &lt;strong&gt;but when i tried on windows gvim 8, it did not work.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I search around, some say &lt;code&gt;cmd&lt;/code&gt; do not support ansi escape sequence. (not sure if &lt;code&gt;\033]51...&lt;/code&gt; is ansi escape sequence or not.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to use terminal api on windows gvim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;== &lt;strong&gt;EDIT&lt;/strong&gt; == (The echo part)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below are 3 ways I can thought of to reproduce the echo part.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 cat file approach&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;under posix shell, eg, cygwin&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printf '\033]51;[&quot;call&quot;,&quot;Tapi_%s&quot;, [&quot;%s&quot;]]\007' Command_finish &amp;gt; xx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;cp&lt;/code&gt; or &lt;code&gt;scp&lt;/code&gt; to current directory. then in terminal buffer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;type xx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;2 use python&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;create file &lt;code&gt;yy.py&lt;/code&gt;, with content&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print('\033]51;[&quot;call&quot;,&quot;Tapi_%s&quot;, [&quot;%s&quot;]]\007' % (&quot;Command_finish&quot;,&quot;&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then in terminal buffer, run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python yy.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;3 use &lt;code&gt;echo&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;not tried, since I don't know how to reliably send '\033'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of the 3 ways, both 1 &amp;amp; 2 works on cygwin.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastEditorUserId="10254" LastEditDate="2020-02-24T05:15:18.393" LastActivityDate="2020-02-24T05:57:13.243" Title="terminal api not working on gvim" Tags="|gvim|terminal|microsoft-windows|terminal-buffer|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22981" PostTypeId="1" CreationDate="2020-02-24T05:24:30.127" Score="3" ViewCount="98" Body="&lt;pre&gt;&lt;code&gt;vim file +80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will open &lt;code&gt;file&lt;/code&gt; in vim, with cursor at line 80&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim file +/if/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will open &lt;code&gt;file&lt;/code&gt; in vim, with cursor at first line containing &lt;code&gt;if&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;vim file +80&lt;/code&gt;, inside vim, there is &lt;code&gt;gF&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The question:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside vim is there any equivalent of &lt;code&gt;vim file +/if/&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which open &lt;code&gt;&amp;lt;cfile&amp;gt;&lt;/code&gt; and go to first line that match a pattern.&lt;/p&gt;&#xA;" OwnerUserId="10254" LastActivityDate="2020-02-24T05:24:30.127" Title="gf with search pattern instead of line number" Tags="|find|file|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22983" PostTypeId="2" ParentId="22980" CreationDate="2020-02-24T05:57:13.243" Score="1" Body="&lt;p&gt;So &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#terminal-communication&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help terminal-communication&lt;/code&gt;&lt;/a&gt; lists &lt;code&gt;term_sendkeys()&lt;/code&gt;, then the JSON API you can access with the escape sequence, then finally:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use the &lt;code&gt;client-server&lt;/code&gt; mechanism. This works on machines with an X server &lt;em&gt;and on MS-Windows&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if that's meant to say that the other mechanisms will &lt;em&gt;not&lt;/em&gt; work on MS-Windows, but at least they're saying this one &lt;em&gt;should&lt;/em&gt; work there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#terminal-client-server&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help terminal-client-server&lt;/code&gt;&lt;/a&gt; describes that in more detail. You need to have your Vim instance register a server name (which it might do automatically, but you might need to do yourself.) Then, when you open a new &lt;code&gt;:terminal&lt;/code&gt;, the server name will be available in an environment variable, &lt;code&gt;$VIM_SERVERNAME&lt;/code&gt; (I believe this will be the case in &lt;code&gt;cmd.exe&lt;/code&gt; as well, though probably it will be &lt;code&gt;%VIM_SERVERNAME%&lt;/code&gt; there.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there, you can call a &lt;code&gt;gvim --remote&lt;/code&gt; command, to either open a file on that Vim server, or to actually evaluate an expression or send keystrokes to be executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The exame from the help page, opening a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim --servername $VIM_SERVERNAME --remote +123 some_file.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But you'll probably want to look into &lt;a href=&quot;https://vimhelp.org/remote.txt.html#--remote-expr&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help --remote-expr&lt;/code&gt;&lt;/a&gt; (and possibly &lt;code&gt;--remote-send&lt;/code&gt; as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this mechanism is &lt;em&gt;a lot more powerful&lt;/em&gt; than the JSON API, since you can use it to evaluate arbitrary expressions, call arbitrary functions, send keystrokes. It's also synchronous and bidirectional, since you can evaluate expressions and get their result from the command running on the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, it's heavier (need to invoke the Vim binary), less portable and might require some setup (ensuring the server is running and has a server name set.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, you might want to consider that as an option, since it seems to be perfectly suited for the environment you're on.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-24T05:57:13.243" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22984" PostTypeId="1" CreationDate="2020-02-24T10:10:06.620" Score="1" ViewCount="99" Body="&lt;p&gt;I am trying to set &lt;code&gt;'foldtext'&lt;/code&gt;, but it seems I misunderstand expressions, types, etc. of Vim fundamentally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does the following refuse to work?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set foldtext=v:folddashes.&quot;TEST&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whereas this works?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func Test()&#xA;    return &quot;TEST&quot;&#xA;endfunc&#xA;set foldtext=v:folddashes.Test()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I assume the &lt;code&gt;.&lt;/code&gt; is not string concatenation in this context, but what is it instead?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, why does Vim don't &quot;recover&quot; if &lt;code&gt;'foldtext'&lt;/code&gt; is restored to default (or any other valid value)?&lt;/p&gt;&#xA;" OwnerUserId="11861" LastActivityDate="2020-02-24T10:10:06.620" Title="&quot;Invalid expression&quot; setting 'foldtext', what is wrong?" Tags="|vimscript|folding|set|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22985" PostTypeId="2" ParentId="21102" CreationDate="2020-02-24T13:09:19.563" Score="17" Body="&lt;p&gt;You can add the following to your .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1. function FormatBuffer()&#xA;2.   if &amp;amp;modified &amp;amp;&amp;amp; !empty(findfile('.clang-format', expand('%:p:h') . ';'))&#xA;3.     let cursor_pos = getpos('.')&#xA;4.     :%!clang-format&#xA;5.     call setpos('.', cursor_pos)&#xA;6.   endif&#xA;7. endfunction&#xA;8. &#xA;9. autocmd BufWritePre *.h,*.hpp,*.c,*.cpp,*.vert,*.frag :call FormatBuffer()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;What this does&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Defines the function &lt;code&gt;FormatBuffer&lt;/code&gt;.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can call this at any time like so &lt;code&gt;:call FormatBuffer()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Check whether the current buffer has been modified, and check if a &lt;code&gt;.clang-format&lt;/code&gt; file is present in the same directory as the current file or any parent directories.&lt;/li&gt;&#xA;&lt;li&gt;Save the current location of the cursor in the buffer.&lt;/li&gt;&#xA;&lt;li&gt;Pass the contents of the current buffer to clang-format and replace the buffer contents with the output.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Note that this does mean if an error occurs during formatting, the current buffer will be replaced with the error message (e.g. if there is a syntax error in the .clang-format file). Of course the buffer contents can be recovered with a simple undo.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Restore the previous location of the cursor within the buffer.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Since the entire buffer gets erased and rewritten the cursor ends up at the beginning of the buffer.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Register a command hook that:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is invoked just before a file is saved.&lt;/li&gt;&#xA;&lt;li&gt;Only applies to C, CPP and GLSL files based on the file extension.&lt;/li&gt;&#xA;&lt;li&gt;Calls the &lt;code&gt;FormatBuffer&lt;/code&gt; function.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;Sources:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/options.txt.html#%27modified%27&quot; rel=&quot;noreferrer&quot;&gt;&amp;amp;mod, &amp;amp;modified&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;boolean (default off)&lt;/em&gt;, &lt;em&gt;local to buffer&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When on, the buffer is considered to be modified.  This option is set&#xA;  when:&lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;A change was made to the text since it was last written.  Using the&#xA;  undo command to go back to the original text will reset the&#xA;  option.  But undoing changes that were made before writing the&#xA;  buffer will set the option again, since the text is different from&#xA;  when it was written.&lt;/li&gt;&#xA;  &lt;li&gt;'fileformat' or 'fileencoding' is different from its original&#xA;  value.  The original value is set when the buffer is read or&#xA;  written.  A &quot;:set nomodified&quot; command also resets the original&#xA;  values to the current values and the 'modified' option will be&#xA;  reset.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimhelp.appspot.com/eval.txt.html#findfile%28%29&quot; rel=&quot;noreferrer&quot;&gt;findfile() builtin&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;findfile({name} [, {path} [, {count}]])&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Just like finddir(), but find a file instead of a directory.&#xA;  Uses 'suffixesadd'.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Example: &#xA;  &lt;code&gt;:echo findfile(&quot;tags.vim&quot;, &quot;.;&quot;)&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Searches from the directory of the current file upwards until&#xA;  it finds the file &quot;tags.vim&quot;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;finddir({name} [, {path} [, {count}]])&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Find directory {name} in {path}.  Supports both downwards and&#xA;  upwards recursive directory searches.  See &lt;code&gt;file-searching&lt;/code&gt;&#xA;  for the syntax of {path}.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Returns the path of the first found match.  When the found&#xA;  directory is below the current directory a relative path is&#xA;  returned.  Otherwise a full path is returned.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If {path} is omitted or empty then 'path' is used.&#xA;  If the optional {count} is given, find {count}'s occurrence of&#xA;  {name} in {path} instead of the first one.&#xA;  When {count} is negative return all the matches in a List.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This is quite similar to the ex-command :find.&#xA;  {only available when compiled with the +file_in_path&#xA;  feature}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/editing.txt.html#file-searching&quot; rel=&quot;noreferrer&quot;&gt;File search syntax&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;2) Upward search:&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Here you can give a directory and then search the directory tree upward for&#xA;  a file.  You could give stop-directories to limit the upward search.  The&#xA;  stop-directories are appended to the path (for the 'path' option) or to&#xA;  the filename (for the 'tags' option) with a ';'.  If you want several&#xA;  stop-directories separate them with ';'.  If you want no stop-directory&#xA;  (&quot;search upward till the root directory) just use ';'. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;/usr/include/sys;/usr&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;will search in: &lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;code&gt;/usr/include/sys&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;/usr/include&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;/usr&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;If you use a relative path the upward search is started in Vim's current&#xA;  directory or in the directory of the current file (if the relative path&#xA;  starts with './' and 'd' is not included in 'cpoptions').&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If Vim's current path is &lt;code&gt;/u/user_x/work/release&lt;/code&gt; and you do &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;:set path=include;/u/user_x&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;and then search for a file with gf the file is searched in: &lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;code&gt;/u/user_x/work/release/include&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;/u/user_x/work/include&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;/u/user_x/include&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/cmdline.html#filename-modifiers&quot; rel=&quot;noreferrer&quot;&gt;Filename Modifiers&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;:_%: ::8 ::p ::. ::~ ::h ::t ::r ::e ::s ::gs&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;%:8 %:p %:. %:~ %:h %:t %:r %:e %:s %:gs&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The file name modifiers can be used after &quot;%&quot;, &quot;#&quot;, &quot;#n&quot;, &quot;&quot;, &quot;&quot;,&#xA;  &quot;&quot; or &quot;&quot;.  They are also used with the |fnamemodify()| function.&#xA;  These are not available when Vim has been compiled without the |+modify_fname|&#xA;  feature.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;These modifiers can be given, in this order:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;:p&lt;/strong&gt;  Make file name a full path.  Must be the first modifier.  Also&#xA;  changes &quot;~/&quot; (and &quot;~user/&quot; for Unix and VMS) to the path for&#xA;  the home directory.  If the name is a directory a path&#xA;  separator is added at the end.  For a file name that does not&#xA;  exist and does not have an absolute path the result is&#xA;  unpredictable.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;:h&lt;/strong&gt;  Head of the file name (the last component and any separators&#xA;  removed).  Cannot be used with :e, :r or :t.&#xA;  Can be repeated to remove several components at the end.&#xA;  When the file name ends in a path separator, only the path&#xA;  separator is removed.  Thus &quot;:p:h&quot; on a directory name results&#xA;  on the directory name itself (without trailing slash).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When the file name is an absolute path (starts with &quot;/&quot; for&#xA;  Unix; &quot;x:\&quot; for MS-DOS, WIN32, OS/2; &quot;drive:&quot; for Amiga), that&#xA;  part is not removed.  When there is no head (path is relative&#xA;  to current directory) the result is empty.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Examples, when the file name is &quot;src/version.c&quot;, current dir&#xA;  &quot;/home/mool/vim&quot;:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;:p            /home/mool/vim/src/version.c&lt;/li&gt;&#xA;  &lt;li&gt;:p:.                     src/version.c&lt;/li&gt;&#xA;  &lt;li&gt;:p:~               ~/vim/src/version.c&lt;/li&gt;&#xA;  &lt;li&gt;:h                       src&lt;/li&gt;&#xA;  &lt;li&gt;:p:h          /home/mool/vim/src&lt;/li&gt;&#xA;  &lt;li&gt;:p:h:h        /home/mool/vim&lt;/li&gt;&#xA;  &lt;li&gt;:t                       version.c&lt;/li&gt;&#xA;  &lt;li&gt;:p:t                     version.c&lt;/li&gt;&#xA;  &lt;li&gt;:r                       src/version&lt;/li&gt;&#xA;  &lt;li&gt;:p:r          /home/mool/vim/src/version&lt;/li&gt;&#xA;  &lt;li&gt;:t:r                     version&lt;/li&gt;&#xA;  &lt;li&gt;:e                           c&lt;/li&gt;&#xA;  &lt;li&gt;:s?version?main?             src/main.c&lt;/li&gt;&#xA;  &lt;li&gt;:s?version?main?:p    /home/mool/vim/src/main.c&lt;/li&gt;&#xA;  &lt;li&gt;:p:gs?/?\?       \home\mool\vim\src\version.c&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://elias.rhi.hi.is/vim/autocmd.html#autocmd-define&quot; rel=&quot;noreferrer&quot;&gt;Defining autocmds&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;:au[tocmd] [group] {event} {pat} [nested] {cmd}&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;em&gt;Add {cmd} to the list of commands that Vim will&#xA;  execute automatically on {event} for a file matching&#xA;  {pat}.  Vim always adds the {cmd} after existing&#xA;  autocommands, so that the autocommands execute in the&#xA;  order in which they were given.  See |autocmd-nested|&#xA;  for [nested].&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://elias.rhi.hi.is/vim/autocmd.html#autocmd-events&quot; rel=&quot;noreferrer&quot;&gt;Events&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;BufWrite&lt;/strong&gt; or &lt;strong&gt;BufWritePre&lt;/strong&gt;&#xA;  &lt;em&gt;Before writing the whole buffer to a file.&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;BufWritePost&lt;/strong&gt;&#xA;  &lt;em&gt;After writing the whole buffer to a file&#xA;                   (should undo the commands for BufWritePre)&lt;/em&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;BufWriteCmd&lt;/strong&gt;&#xA;  &lt;em&gt;Before writing the whole buffer to a file.&#xA;  Should do the writing of the file and reset&#xA;  'modified' if successful.  The buffer contents&#xA;  should not be changed. &lt;code&gt;|Cmd-event|&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://elias.rhi.hi.is/vim/eval.html#:function&quot; rel=&quot;noreferrer&quot;&gt;Defining functions&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;:fu[nction][!] {name}([arguments]) [range] [abort]&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Define a new function by the name {name}.  The name&#xA;  must be made of alphanumeric characters and '_', and&#xA;  must start with a capital or &quot;s:&quot; (see above).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;em&gt;function-argument&lt;/em&gt; &lt;em&gt;a:var&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;An argument can be defined by giving its name.  In the&#xA;  function this can then be used as &quot;a:name&quot; (&quot;a:&quot; for&#xA;  argument).&#xA;  Up to 20 arguments can be given, separated by commas.&#xA;  Finally, an argument &quot;...&quot; can be specified, which&#xA;  means that more arguments may be following.  In the&#xA;  function they can be used as &quot;a:1&quot;, &quot;a:2&quot;, etc.  &quot;a:0&quot;&#xA;  is set to the number of extra arguments (which can be&#xA;  0).&#xA;  When not using &quot;...&quot;, the number of arguments in a&#xA;  function call must be equal to the number of named&#xA;  arguments.  When using &quot;...&quot;, the number of arguments&#xA;  may be larger.&#xA;  It is also possible to define a function without any&#xA;  arguments.  You must still supply the () then.&#xA;  The body of the function follows in the next lines,&#xA;  until the matching |:endfunction|.  It is allowed to&#xA;  define another function inside a function body.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;em&gt;E127&lt;/em&gt; &lt;em&gt;E122&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When a function by this name already exists and [!] is&#xA;  not used an error message is given.  When [!] is used,&#xA;  an existing function is silently replaced.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;em&gt;a:firstline&lt;/em&gt; &lt;em&gt;a:lastline&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When the [range] argument is added, the function is&#xA;  expected to take care of a range itself.  The range is&#xA;  passed as &quot;a:firstline&quot; and &quot;a:lastline&quot;.  If [range]&#xA;  is excluded, &quot;:{range}call&quot; will call the function for&#xA;  each line in the range, with the cursor on the start&#xA;  of each line.  See |function-range-example|.&#xA;  When the [abort] argument is added, the function will&#xA;  abort as soon as an error is detected.&#xA;  The last used search pattern and the redo command &quot;.&quot;&#xA;  will not be changed by the function.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;:endf[unction]&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The end of a function definition.  Must be on a line&#xA;  by its own, without other commands.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="21312" LastEditorUserId="21312" LastEditDate="2020-02-28T14:22:29.770" LastActivityDate="2020-02-28T14:22:29.770" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="22986" PostTypeId="1" CreationDate="2020-02-24T14:14:24.810" Score="0" ViewCount="82" Body="&lt;p&gt;I use Vim to write LaTeX, in particular professional, academic papers.  I rely on the default vim dictionary (in &lt;code&gt;/usr/local/share/vim/vim81/spell/en.utf-8.spl&lt;/code&gt;).  I recently noticed a vulgarity (variant of &quot;shift&quot;) was not marked as spelled incorrect.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked the vim dictionary via &lt;code&gt;:spelldump&lt;/code&gt; and noticed a slew of vulgarities.  Is there a way for all such words to not appear in the dictionary by default?  The &quot;shift&quot; error is one example where an unintentionally misspelled vulgarity would be marked as spelled correctly.&lt;/p&gt;&#xA;" OwnerUserId="23199" LastEditorUserId="23199" LastEditDate="2020-02-24T17:01:36.560" LastActivityDate="2020-02-24T17:01:36.560" Title="Vulgarities in the vim Default Dictionary" Tags="|spell-checking|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="22987" PostTypeId="2" ParentId="2758" CreationDate="2020-02-24T14:22:39.490" Score="1" Body="&lt;pre&gt;&lt;code&gt;    1&#xA;   1 1&#xA;  1   1&#xA; 1111111&#xA; 1     1&#xA; 1     1&#xA; 1     1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Picture a row of three different block letters like the one above.&#xA;&lt;code&gt;^V&lt;/code&gt; selecting the above, I couldn't change all the ones to &lt;code&gt;A&lt;/code&gt; in the last letter in the row due to unequal length lines. The previous block letters worked fine with&#xA;&lt;code&gt;:s/\%V1/T/g&lt;/code&gt;   &quot;Previous Block letter was a T made from '1's. Change &lt;code&gt;/T/&lt;/code&gt; to whatever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But selecting the last block letter shown above it only changed all the '1's to 'A's to the point of the A*, and the rest remained ones. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;*The shortest line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make all the lines the same length I padded them with spaces.&#xA;(I am new to vim, so I am sure a better script could be written.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: The peak of the A started on line 2.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let Maxlen = 0&#xA;&quot; Find longest line&#xA;for i in range(2,8)&#xA;    let t = getline(i)&#xA;    let a = strlen(t)&#xA;    if a &amp;gt; Maxlen&#xA;        Maxlen = a&#xA;    endif&#xA;endfor&#xA;&#xA;&quot; Append spaces 'til all lines are the same length.&#xA;for i in range(2,8)&#xA;    let t = getline(i)&#xA;    let a = strlen(t)&#xA;    if a &amp;lt; Maxlen&#xA;        let b = Maxlen - a&#xA;        execute &quot;normal!&quot; . i . &quot;gg0&quot; . b . &quot;A &quot;&#xA;    endif&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After this, &lt;code&gt;:s/\%V1/T/g&lt;/code&gt;  worked as advertised on the last block letter in the row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I read that the &lt;code&gt;execute&lt;/code&gt; line above should work without the dots, but it didn't work for me.&lt;/p&gt;&#xA;" OwnerUserId="26987" LastEditorUserId="1841" LastEditDate="2020-02-27T09:32:43.353" LastActivityDate="2020-02-27T09:32:43.353" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22989" PostTypeId="1" CreationDate="2020-02-24T16:07:24.067" Score="0" ViewCount="263" Body="&lt;p&gt;&lt;strong&gt;I am writing a mapping to autocomplete tags&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pattern:&lt;/strong&gt; &lt;code&gt;&amp;lt;.*?&amp;gt;&lt;/code&gt;, matches complete HTML tags only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The goal is to lookbehind and see if there exists a text like &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Mapping:&lt;/strong&gt; &lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;&amp;lt; TagComplete()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! TagComplete() {&#xA;  let match=search('&amp;lt;.*?&amp;gt;', 'b', '.')&#xA;  return match&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once I run the Mapping in insert mode after typing &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt;, on execution of function &lt;code&gt;TagComplete&lt;/code&gt;, if the pattern is matched, the &lt;code&gt;match&lt;/code&gt; variable should have value &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; and at the cursor position &amp;lt;\html&gt; should be inserted. Once done the editor should be in insert mode, keeping the cursor between the tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am having difficulty in returning the &lt;code&gt;match&lt;/code&gt; applying &lt;code&gt;search()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also vim does not understand  non-greedy &lt;code&gt;?&lt;/code&gt; in pattern.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to print closing tag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;C-V&amp;gt; AutoCompleteTag()&#xA;&#xA;func! AutoCompleteTag()&#xA;  let l:match = search('&amp;lt;[^/].\{-}&amp;gt;', 'bn', line(&quot;.&quot;))&#xA;  let l:pat=&quot;&amp;lt;\zs\/.\{-}\ze&amp;gt;&quot;&#xA;  if l:match &amp;gt; 0 &#xA;    let l:lastMatch=MatchStrLast(getline(l:match), '&amp;lt;\zs.\{-}\ze&amp;gt;')&#xA;    if l:lastMatch!~&quot;\/.*&quot;&#xA;      return '&amp;lt;/'.l:lastMatch.'&amp;gt;'                                                                                                                                                                           &#xA;    endif&#xA;  endif&#xA;endfunc&#xA;&#xA;&quot; use the {count} parameter for matchstr() to increment your way through the&#xA;&quot; string &#xA;function! MatchStrLast(expr, pat, ...)&#xA;  let start = a:0 ? a:1 : 0 &#xA;  let last = ''&#xA;  let cnt = 1 &#xA;  let found = match(a:expr, a:pat, start, cnt)&#xA;  while found != -1&#xA;    let last=matchstr(a:expr, a:pat, start, cnt)&#xA;    let cnt += 1&#xA;    let found = match(a:expr, a:pat, start, cnt)&#xA;  endwhile&#xA;  return last &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;search('&amp;lt;[^/].\{-}&amp;gt;', 'bn', line(&quot;.&quot;))&lt;/code&gt;, I am searching to see if a valid tag pattern exits on current line. If yes, store line number in &lt;code&gt;l:match&lt;/code&gt;. Is there a way to search backwards from cursor position and match the opening tag.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;MatchStrLast(getline(l:match), '&amp;lt;\zs.\{-}\ze&amp;gt;')&lt;/code&gt;, gets the name of the tag.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Concerns:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not able to find a way to move the cursor so that it is in the middle of the tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the mapping is run, it prints a 0 if the match is not found. How not to print anything in case the regexp does not match the pattern?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in if condition &lt;code&gt;if l:lastMatch!~&quot;\/.*&quot;&lt;/code&gt;, I tried the pattern &lt;code&gt;&amp;lt;\zs\/.\{-}\ze&amp;gt;&lt;/code&gt; in place of &lt;code&gt;\/.*&lt;/code&gt;, that I expected to match string &quot;/S.Component&quot;, but it did not. &lt;strong&gt;Reason?&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since, I am new to vimscript, I appreciate anyone pointing out an anti-pattern and please suggest improvements.&lt;/p&gt;&#xA;" OwnerUserId="26997" LastEditorUserId="26997" LastEditDate="2020-02-26T15:24:22.460" LastActivityDate="2020-03-10T12:07:41.593" Title="search a pattern preceding cursor position, modify it and insert the modified string" Tags="|key-bindings|vimscript|regular-expression|search|functions|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22990" PostTypeId="1" AcceptedAnswerId="22991" CreationDate="2020-02-24T21:25:17.270" Score="2" ViewCount="55" Body="&lt;p&gt;If I'm in command mode with default vim and I press the right angle key, the cursor switches from the normal block to a short version. What is the function of this? (Sometimes it seems related to indent.)&lt;/p&gt;&#xA;" OwnerUserId="27023" LastEditorUserId="5298" LastEditDate="2020-02-25T21:44:35.283" LastActivityDate="2020-02-26T21:56:05.110" Title="What is the purpose of the short cursor in command mode?" Tags="|cursor|operator-pending-mode|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22991" PostTypeId="2" ParentId="22990" CreationDate="2020-02-24T21:50:30.703" Score="3" Body="&lt;p&gt;The angled brackets &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; are the shift commands. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason it's a short block is that vim enters &lt;em&gt;operator-pending-mode&lt;/em&gt;, and is waiting for you to complete the command. &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; is used to shift the current line by one &lt;code&gt;shiftwidth&lt;/code&gt; right, and &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; is used to shift the current line one &lt;code&gt;shiftwidth&lt;/code&gt; left. The brackets can also be followed by a motion command to shift multiple lines or blocks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From vim's help file: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;operator-pending-mode &lt;em&gt;is like normal mode, but after an operator command has started, and Vim is waiting for a {motion} to specify the text that the operator will work on.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For more information, read &lt;code&gt;:help shift-left-right&lt;/code&gt; and the Vim wiki page on &lt;a href=&quot;https://vim.fandom.com/wiki/Shifting_blocks_visually&quot; rel=&quot;nofollow noreferrer&quot;&gt;shifting blocks visually&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="5298" LastEditorUserId="1238" LastEditDate="2020-02-26T21:56:05.110" LastActivityDate="2020-02-26T21:56:05.110" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22992" PostTypeId="1" AcceptedAnswerId="22993" CreationDate="2020-02-24T22:56:35.003" Score="0" ViewCount="772" Body="&lt;p&gt;I am trying to get the plugin &lt;a href=&quot;https://github.com/daeyun/vim-matlab&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-matlab&lt;/a&gt; for neovim working, but with no success. When I try to call any command from nvim ( like &lt;code&gt;:MatlabCliHelp&lt;/code&gt; ), I get the following output. Do you have any ideas what I am doing wrong? &#xA;Thank you for your answers&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function remote#define#CommandBootstrap[5]..remote#define#request:&#xA;line    2:                                                                                                                                                                                        &#xA;error caught in request handler '/home/kuntik/.config/nvim/bundle/vim-matlab/rplugin/python/vim_matlab:command:MatlabCliHelp ()':&#xA;Traceback (most recent call last):&#xA;  File &quot;/home/kuntik/.config/nvim/bundle/vim-matlab/rplugin/python/vim_matlab/__init__.py&quot;, line 121, in matlab_cli_help&#xA;    self.activate_cli()&#xA;  File &quot;/home/kuntik/.config/nvim/bundle/vim-matlab/rplugin/python/vim_matlab/__init__.py&quot;, line 81, in activate_cli&#xA;    self.cli_controller = MatlabCliController()&#xA;  File &quot;/home/kuntik/.config/nvim/bundle/vim-matlab/rplugin/python/vim_matlab/matlab_cli_controller.py&quot;, line 16, in __init__&#xA;    self.connect_to_server()&#xA;  File &quot;/home/kuntik/.config/nvim/bundle/vim-matlab/rplugin/python/vim_matlab/matlab_cli_controller.py&quot;, line 20, in connect_to_server&#xA;    self.sock.connect((self.host, self.port))&#xA;  File &quot;/usr/lib/python2.7/socket.py&quot;, line 228, in meth&#xA;    return getattr(self._sock,name)(*args)&#xA;error: [Errno 111] Connection refused&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27118" LastEditorUserId="1238" LastEditDate="2020-02-26T04:26:44.633" LastActivityDate="2020-02-26T04:26:44.633" Title="Vim-Matlab plugin" Tags="|neovim|matlab|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22993" PostTypeId="2" ParentId="22992" CreationDate="2020-02-24T23:10:12.013" Score="0" Body="&lt;p&gt;It's trying to connect to the server, but it looks like the server just isn't running...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the plug-in's &lt;a href=&quot;https://github.com/daeyun/vim-matlab/blob/master/README.md#usage&quot; rel=&quot;nofollow noreferrer&quot;&gt;usage&lt;/a&gt;, which tells you how you need to start the server first, with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./scripts/vim-matlab-server.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the README file:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This will start a Matlab REPL and redirect commands received from Vim to Matlab. When Matlab crashes (e.g. segfault during MEX development), it will launch another process.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Then open Vim in another terminal and start editing .m files.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Alternatively, launch a server instance from Vim using &lt;code&gt;:MatlabLaunchServer&lt;/code&gt;. The server will be launched either in a Neovim terminal buffer or a tmux split (see &lt;code&gt;g:matlab_server_launcher&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So starting it with a &lt;code&gt;:MatlabLaunchServer&lt;/code&gt; command seems to be an option too.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-24T23:10:12.013" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22995" PostTypeId="1" AcceptedAnswerId="23096" CreationDate="2020-02-25T03:11:45.993" Score="1" ViewCount="321" Body="&lt;p&gt;In VIM when I execute &lt;code&gt;set mouse=a&lt;/code&gt;, then I can use mouse to navigate. That's good. And when I need a new window for editing, I can double click on a tab. VIM will open an empty window for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have an annoying problem. I found that when I click on a tab and move the mouse (usually, the move is not on purpose. Accidentally.), it will also create a new window. This annoys me so much such that I cannot browser every tab quickly (should be very careful to click on tab).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone also have this issue and know how to disable the feature (or bug?) of DRAG to open a new window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;THe OS is Linux running KDE Plasma with konsole terminal application.&lt;/p&gt;&#xA;" OwnerUserId="27122" LastEditorUserId="27122" LastEditDate="2020-02-27T02:03:14.703" LastActivityDate="2020-03-06T06:31:19.660" Title="Mouse click on VIM tab to create new window" Tags="|vimrc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22996" PostTypeId="1" AcceptedAnswerId="22997" CreationDate="2020-02-25T17:49:43.917" Score="0" ViewCount="194" Body="&lt;p&gt;I want to update one buffer content from another buffer periodically, for this I need to delete all lines from the target buffer firstly, then to write new lines to it. The number of lines are varying, so the extra lines which are left from the previous update should be deleted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this moment I found two ways to solve this task, but both are not ideal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Buffer_update()&#xA;    &quot; Buffer information saving&#xA;    let l:save_cur_pos = getcurpos()&#xA;    let l:save_buf_nr = bufnr('%')&#xA;&#xA;    &quot; Moving to the target buffer and cleaning its content&#xA;    buffer one &#xA;    silent %d _&#xA;&#xA;    &quot; Simulation of the varying number of lines&#xA;    for l:num in range(system('echo $((RANDOM % 10 + 1))'))&#xA;        call setbufline('one', l:num, 'hello')&#xA;    endfor&#xA;&#xA;    &quot; Buffer information restoring&#xA;    execute 'buffer' . l:save_buf_nr&#xA;    call setpos('.', l:save_cur_pos)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt; (buffer one)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ODHmE.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ODHmE.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Drawback:&lt;/strong&gt; I don't like switching between buffers to achieving a desired result. It can be solved without switching, like in the second variant, but there is some problem too. It will be perfect to have &lt;code&gt;delbufline()&lt;/code&gt; function like &lt;code&gt;setbufline()&lt;/code&gt;, but I didn't find such one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Second&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Buffer_update()&#xA;    &quot; Simulation of the varying number of lines&#xA;    for l:num in range(system('echo $((RANDOM % 10 + 1))'))&#xA;        call setbufline('one', l:num, 'hello')&#xA;    endfor&#xA;&#xA;    &quot; Deleting of extra lines from the previous update&#xA;    while l:num &amp;lt;= len(getbufline('one', 1, '$'))&#xA;        call setbufline('one', l:num, '')&#xA;        let l:num += 1&#xA;    endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt; (buffer one)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oQj2u.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oQj2u.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Drawback:&lt;/strong&gt; This solution leaves blank lines. In other words, it doesn't delete lines, just makes them empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Does some &lt;code&gt;delbufline()&lt;/code&gt; function exist, similar to &lt;code&gt;setbufline()&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Maybe someone can suggest more suitable solution, without aforementioned drawbacks?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="14024" LastEditorUserId="14024" LastEditDate="2020-02-25T18:41:35.003" LastActivityDate="2020-02-26T08:13:08.953" Title="Updating buffer content from another buffer" Tags="|buffers|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22997" PostTypeId="2" ParentId="22996" CreationDate="2020-02-25T18:00:21.723" Score="2" Body="&lt;p&gt;The function is called &lt;code&gt;deletebufline()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let l:bufnr = bufnr('thatbuf')&#xA;if l:bufnr != -1&#xA;    silent call deletebufline(l:bufnr, 1, '$')&#xA;    call setbufline(l:bufnr, 1, GetListOfLines())&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;UPD. &lt;code&gt;deletebufline()&lt;/code&gt; was added in Vim 8.1.0039&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2020-02-26T08:13:08.953" LastActivityDate="2020-02-26T08:13:08.953" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22998" PostTypeId="1" AcceptedAnswerId="23000" CreationDate="2020-02-26T02:55:44.960" Score="4" ViewCount="1833" Body="&lt;p&gt;Suppose I have the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;begin&#xA;asdf&#xA;&#xA;asdf&#xA;end&#xA;&#xA;begin&#xA;&#xA;asdf&#xA;end&#xA;&#xA;begin&#xA;asdfasdf&#xA;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I use something like the global command to delete every empty line in between 'begin' and 'end'?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:/begin/,/end/ g/^$/d&lt;/code&gt; only deletes the space in the first begin/end block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help!&lt;/p&gt;&#xA;" OwnerUserId="16483" LastActivityDate="2020-02-26T08:54:59.047" Title="Delete blank lines within range" Tags="|range|global-command|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22999" PostTypeId="2" ParentId="22998" CreationDate="2020-02-26T05:15:52.260" Score="1" Body="&lt;p&gt;You could instead try this: &lt;code&gt;:g/begin/,/end/ s/^$//&lt;/code&gt;. I don't think &lt;code&gt;g&lt;/code&gt; works recursively, so using &lt;code&gt;s&lt;/code&gt; instead seems to do the job.&lt;/p&gt;&#xA;" OwnerUserId="5178" LastActivityDate="2020-02-26T05:15:52.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23000" PostTypeId="2" ParentId="22998" CreationDate="2020-02-26T08:54:59.047" Score="5" Body="&lt;p&gt;In the very general case, the &lt;code&gt;:g&lt;/code&gt; command cannot be called recursively. There is one exception:&#xA;Since Vim patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.0.0630&quot; rel=&quot;noreferrer&quot;&gt;8.0.0630&lt;/a&gt;, one can call a recursive &lt;code&gt;:g&lt;/code&gt; command, if it operates only within a single line. So you can do something like (quoting the &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#E147&quot; rel=&quot;noreferrer&quot;&gt;help&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the command is used recursively, it only works on one line. &#xA;  Giving a range is then not allowed. This is useful to find all lines&#xA;  that match a pattern and do not match another pattern: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    :g/found/v/notfound/{cmd}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This first finds all lines containing &quot;found&quot;, but only executes {cmd} &#xA;  when there is no match for &quot;notfound&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However that means, this does not apply to your use case here. You would need to call &lt;code&gt;:g&lt;/code&gt; to mark all &lt;code&gt;begin/end&lt;/code&gt; regions, and then call another &lt;code&gt;:g&lt;/code&gt; command to find empty lines (to be deleted).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in your case, you can use the &lt;code&gt;:s&lt;/code&gt; command like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/begin/,/end/s/^\n//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: We are searching for line start (&lt;code&gt;^&lt;/code&gt;), followed by a line break (&lt;code&gt;\n&lt;/code&gt;), because we want to remove this line break, effectively deleting the empty line. For that reason using the pattern &lt;code&gt;^$&lt;/code&gt; to the &lt;code&gt;:s&lt;/code&gt; command would not work, as it would leave the empty line intact (keep the line break).&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2020-02-26T08:54:59.047" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23001" PostTypeId="1" CreationDate="2020-02-26T09:17:34.670" Score="5" ViewCount="181" Body="&lt;p&gt;I know that &lt;code&gt;syn match&lt;/code&gt; can work with the regular expression to do some custom highlight settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking if it can work dynamically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I'm doing a c++ project and I want to highlight all class/struct names. It's not hard to highlight these names while defining, I can do this with the help of &lt;code&gt;syn match&lt;/code&gt; as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi hiCppCustomClassName guifg=NONE guibg=NONE guisp=NONE gui=bold ctermfg=lightgreen ctermbg=NONE cterm=bold&#xA;syn match cppCustomClassName &quot;\(^class\s*\)\@&amp;lt;=\w\+&quot;&#xA;syn match cppCustomStructName &quot;\(^struct\s*\)\@&amp;lt;=\w\+&quot;&#xA;hi def link cppCustomClassName hiCppCustomClassName&#xA;hi def link cppCustomStructName hiCppCustomClassName&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, I match all words following the key word &lt;code&gt;class&lt;/code&gt; and &lt;code&gt;struct&lt;/code&gt; and highlight them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I define an object with some class, it won't be highlighted, which means that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Test{}; // Test is highlighted&#xA;Test t;       // Test it not highlighted&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As there are many cases, such as &lt;code&gt;sizeof(Test)&lt;/code&gt;, &lt;code&gt;(Test)obj&lt;/code&gt;, the &lt;code&gt;syn match&lt;/code&gt; with regular expression can not cover all of them, now I'm thinking if there is some dynamic mechanism so that I can find all class/struct names, put all of them into an array, loop this array and highlight all of them while coding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I know there are some other ways to get a perfect highlight, for example, &lt;a href=&quot;https://github.com/jeaye/color_coded&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/jeaye/color_coded&lt;/a&gt;, but these are kind of too heavy, for now I only want to get some simple, light way.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-02-26T09:17:34.670" Title="Is it possible to use syn match dynamically" Tags="|syntax-highlighting|regular-expression|highlight|syntax|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23002" PostTypeId="2" ParentId="22668" CreationDate="2020-02-26T15:24:19.340" Score="1" Body="&lt;p&gt;You could certainly do it with visual blocks, with a caveat. Visual blocks need to be rectangular, so by selecting blocks with &lt;code&gt;Ctrl-V&lt;/code&gt; followed by the necessary motions and yanking and pasting, you actually end up with something looking like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ Card &quot;Skwortul&quot;    Wet False   [Move &quot;Squirt&quot; 20]                    &#xA;, Card &quot;Scorchander&quot; Hot False   [Move &quot;Scorch&quot; 20]                    &#xA;, Card &quot;Seedasaur&quot;   Leafy False [Move &quot;Allergize&quot; 20]                 &#xA;, Card &quot;Kapichu&quot;     Spark False [Move &quot;Poke&quot; 10 , Move &quot;Zap&quot; 30]      &#xA;, Card &quot;Elecdude&quot;    Spark False [Move &quot;Asplode&quot; 50]                   &#xA;, Card &quot;Garydose&quot;    Wet True    [Move &quot;Gary's move&quot; 40]               &#xA;, Card &quot;Moisteon&quot;    Wet False   [Move &quot;Soggy&quot; 3]                      &#xA;, Card &quot;Grasseon&quot;    Leafy False [Move &quot;Leaf Cut&quot; 30]                  &#xA;, Card &quot;Spicyeon&quot;    Hot False   [Move &quot;Capsaicisize&quot; 40]              &#xA;, Card &quot;Sparkeon&quot;    Spark True  [Move &quot;Shock&quot; 40 , Move &quot;Battery&quot; 50] &#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which differs from what you requested in your question in that it has extra spaces. If the spaces are not significant for your application, you are done. (You might even argue that it looks better because the columns are aligned!) But if you want to remove the spaces, you could do it with &lt;code&gt;:%s/  */ /g&lt;/code&gt;. This works as long as there are no repeated spaces that you do want to keep (your example appears to have none).&lt;/p&gt;&#xA;" OwnerUserId="26819" LastActivityDate="2020-02-26T15:24:19.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23003" PostTypeId="1" CreationDate="2020-02-26T15:30:39.190" Score="0" ViewCount="77" Body="&lt;p&gt;I wonder whether there is a way in gvim to select the font used for buffer names in tab headings (after using &lt;code&gt;:tabnew&lt;/code&gt;). I know the guifont option, but this applies to the buffer editing area. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I would like to choose the font family and size.&lt;/p&gt;&#xA;" OwnerUserId="27144" LastEditorUserId="1238" LastEditDate="2020-02-27T13:56:18.920" LastActivityDate="2020-02-27T13:56:18.920" Title="select font for tab headers in gvim" Tags="|gvim|tabbed-user-interface|font|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23004" PostTypeId="1" AcceptedAnswerId="23007" CreationDate="2020-02-26T18:07:56.800" Score="20" ViewCount="1747" Body="&lt;p&gt;I'm checking spelling in a document. I find a misspelled word and intend to press &lt;code&gt;z=&lt;/code&gt; to get suggestions, but I accidentally press &lt;code&gt;zg&lt;/code&gt;, marking this as a &quot;good&quot; spelling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I undo that?&lt;/p&gt;&#xA;" OwnerUserId="7702" LastEditorUserId="4472" LastEditDate="2020-03-03T02:49:04.890" LastActivityDate="2020-03-03T02:49:04.890" Title="How can I undo `zg`?" Tags="|spell-checking|undo-redo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23006" PostTypeId="2" ParentId="19358" CreationDate="2020-02-26T19:01:13.963" Score="1" Body="&lt;p&gt;I had a similar issue, when I wanted to map &lt;kbd&gt;Ctrl+4&lt;/kbd&gt; and &lt;kbd&gt;Ctrl+6&lt;/kbd&gt; keys, but those codes were not recognized. The output of &lt;kbd&gt;Ctrl+v&lt;/kbd&gt;&lt;kbd&gt;Ctrl+4&lt;/kbd&gt; was &lt;code&gt;^[[1;5t&lt;/code&gt;, which usually would lead to a mapping like e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map ^[[1;5t &amp;lt;End&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that did not work. The solution was to replace &lt;code&gt;^[&lt;/code&gt; with &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt; in the mapping command, like e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;ESC&amp;gt;[1;5t &amp;lt;End&amp;gt;&#xA;imap &amp;lt;ESC&amp;gt;[1;5t &amp;lt;End&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13697" LastActivityDate="2020-02-26T19:01:13.963" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23007" PostTypeId="2" ParentId="23004" CreationDate="2020-02-26T19:59:31.973" Score="27" Body="&lt;p&gt;From the help&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;zuw                         *zug* *zuw*&#xA;zug         Undo |zw| and |zg|, remove the word from the entry in&#xA;            'spellfile'.  Count used as with |zg|.&#xA;&#xA;zuW                         *zuG* *zuW*&#xA;zuG         Undo |zW| and |zG|, remove the word from the internal&#xA;            word list.  Count used as with |zg|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-02-26T19:59:31.973" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23008" PostTypeId="1" AcceptedAnswerId="23013" CreationDate="2020-02-26T22:37:45.173" Score="2" ViewCount="566" Body="&lt;p&gt;I found project called &lt;a href=&quot;http://ex-vi.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Traditional Vi&lt;/a&gt;, but I think that description, readme and manual don't provide exact information about compliancy with POSIX. I tried looking for other implementations that meet the requirements, but with no luck. I'm wondering, are there any POSIX compliant vi implementations? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="27152" LastActivityDate="2020-02-27T09:42:14.493" Title="POSIX compliant vi implementations" Tags="|posix|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23009" PostTypeId="2" ParentId="23008" CreationDate="2020-02-27T02:51:21.447" Score="4" Body="&lt;p&gt;Vim has a special mode for POSIX compliance, which you can enable by setting the &lt;code&gt;$VIM_POSIX&lt;/code&gt; environment variable to a non-empty value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/vi_diff.txt.html#posix&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help posix&lt;/code&gt;&lt;/a&gt;, which explains it:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In 2005 the POSIX test suite was run to check the compatibility of Vim. Most&#xA;  of the test was executed properly. There are the few things where Vim is not POSIX compliant, even when run in Vi compatibility mode.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Set the &lt;code&gt;$VIM_POSIX&lt;/code&gt; environment variable to have &lt;code&gt;'cpoptions'&lt;/code&gt; include the POSIX flags when Vim starts up.  This makes Vim run as POSIX as it can. That's&#xA;  a bit different from being Vi compatible.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That section of the docs also goes into details of differences between Vim (even in Vi compatible mode) and POSIX, and why the differences exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also the &lt;a href=&quot;https://vimhelp.org/options.txt.html#cpo-%23&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'cpoptions'&lt;/code&gt; that are only enabled in POSIX mode&lt;/a&gt;. Vim option &lt;code&gt;'cpoptions'&lt;/code&gt; allows granular control of all compatibility settings.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-27T02:51:21.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23011" PostTypeId="1" CreationDate="2020-02-27T08:25:19.430" Score="2" ViewCount="41" Body="&lt;p&gt;I'm using Vim with Rails Vim plugin. When trying to tab-complete command &lt;code&gt;:Emodel U&lt;/code&gt; or &lt;code&gt;:Econtroller U&lt;/code&gt; and then &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; it won't recognize the &lt;code&gt;user.rb&lt;/code&gt; or &lt;code&gt;user_controller.rb&lt;/code&gt; file. But works fine for &lt;code&gt;:Eviews&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;:verbose command Eview&lt;/code&gt; gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Eview * customlist :execute s:viewEdit(&quot;&amp;lt;mods&amp;gt; E&amp;lt;bang&amp;gt;&quot;,&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and for &lt;code&gt;:verbose command Emodel&lt;/code&gt; it prints&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Emodel * customlist :execute s:CommandEdit('&amp;lt;mods&amp;gt; E&amp;lt;bang&amp;gt;','model',[{'pattern': 'app/models/*.rb', 'affinity': 'model'}],&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;:Emodel!&amp;lt;Tab&amp;gt;&lt;/code&gt; or any of MVC with &lt;code&gt;!&lt;/code&gt; will allow me to search through existing files in folder. How can I change it so all MVC modes work the same way?&lt;/p&gt;&#xA;" OwnerUserId="27158" LastEditorUserId="1841" LastEditDate="2020-02-27T09:30:30.543" LastActivityDate="2020-03-28T19:03:05.420" Title="Rails Vim tab completition for model and controller works different than for views" Tags="|autocompletion|filetype-ruby|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="23012" PostTypeId="2" ParentId="22639" CreationDate="2020-02-27T09:08:05.447" Score="0" Body="&lt;p&gt;Is this close to what you want?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:str='abcdefghijklmnopqrstuvwxyz'&#xA;for i in range(len(s:str))&#xA;    let s:c=s:str[i]&#xA;    exe 'map &amp;lt;A-'.s:c.'&amp;gt; &amp;lt;S-'.s:c.'&amp;gt;'&#xA;    exe 'lmap &amp;lt;A-'.s:c.'&amp;gt; &amp;lt;S-'.s:c.'&amp;gt;'&#xA;    exe 'tmap &amp;lt;A-'.s:c.'&amp;gt; &amp;lt;S-'.s:c.'&amp;gt;'&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;s:&lt;/code&gt; specify the scope of the variables (see &lt;code&gt;:help s:&lt;/code&gt;) and command &lt;code&gt;exe&lt;/code&gt; executes the string following it. &lt;code&gt;.&lt;/code&gt;  concatenates strings together. For example, if &lt;code&gt;i&lt;/code&gt; is 3, then &lt;code&gt;s:c&lt;/code&gt; becomes &lt;code&gt;d&lt;/code&gt;, and &lt;code&gt;map &amp;lt;A-d&amp;gt; &amp;lt;S-d&amp;gt;&lt;/code&gt; will be executed.&lt;/p&gt;&#xA;" OwnerUserId="25618" LastEditorUserId="25618" LastEditDate="2020-02-27T12:24:41.700" LastActivityDate="2020-02-27T12:24:41.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23013" PostTypeId="2" ParentId="23008" CreationDate="2020-02-27T09:42:14.493" Score="3" Body="&lt;p&gt;There are a couple of vi clones besides the traditional &lt;a href=&quot;http://ex-vi.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ex-vi&lt;/a&gt;, that claim to be compatible to traditional vi. However I am not sure, if all meet complete POSIX specs and in the past, there were at least some contradictions between traditional vi and POSIX specs (think of multibyte text, regex flavors, undo and such). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could have a look at &lt;a href=&quot;https://www.busybox.net/about.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;busybox vi&lt;/a&gt;, &lt;a href=&quot;https://github.com/aligrudi/neatvi&quot; rel=&quot;nofollow noreferrer&quot;&gt;neat-vi&lt;/a&gt;, &lt;a href=&quot;https://repo.or.cz/nvi.git&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvi&lt;/a&gt; and &lt;a href=&quot;https://github.com/lichray/nvi2&quot; rel=&quot;nofollow noreferrer&quot;&gt;nvi2&lt;/a&gt;. Most of those, at least extend the POSIX specs I believe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For finding out, if they are compliant, I believe you will have to find out and compare against the POSIX specs. I believe there is also a POSIX test suite available, but not sure if it includes vi behaviour tests (and if so how comprehensive it is)&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2020-02-27T09:42:14.493" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23014" PostTypeId="1" CreationDate="2020-02-27T11:19:59.497" Score="0" ViewCount="72" Body="&lt;p&gt;Not sure why but if I open vim, and try and use &lt;code&gt;FZF&lt;/code&gt;, I get a bell noise when using my mappings for it. Doing &lt;code&gt;:FZF&lt;/code&gt; will work just fine, but I have a mapping &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;ff :FZF&amp;lt;cr&amp;gt;&lt;/code&gt; And that gives me the bell error noise! Seems after doing other actions my mapping works, have no idea why this is happening.&lt;/p&gt;&#xA;" OwnerUserId="26973" LastActivityDate="2020-02-27T11:19:59.497" Title="FZF Immediately Gives me the Dreaded Bell When first Tyring to use it" Tags="|plugin-fzf|fzf|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23015" PostTypeId="1" AcceptedAnswerId="23016" CreationDate="2020-02-27T13:09:16.830" Score="4" ViewCount="996" Body="&lt;p&gt;I've got a file, containing some output log.&#xA;It consists of several blocks of information, that start and end with some fixed patterns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to put a summary for each block in the beginning of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, I'd like to study vim scripting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've developed a couple of functions: one of them processes line range and returns a string with the summary, and another one puts this string in the first line of a file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GetBlockSummary(first, last)&#xA;    &quot; some text processing&#xA;endfunction&#xA;&#xA;function! ProcessBlock() range&#xA;    let summary = GetBlockSummary(a:firstline, a:lastline)&#xA;    call append(0, summary)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I call them: &lt;code&gt;:/startpattern/;/endpattern/ call ProcessBlock()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I've got two problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There are many blocks in the file, and it is tedious to repeat the command by hands. This can be solved with putting the call into a macro and then calling that macro with count prefix (say, &lt;code&gt;90@q&lt;/code&gt;, if I have known that there are 90 blocks in the file, and have put the call into the &lt;code&gt;@q&lt;/code&gt; register)&lt;/li&gt;&#xA;&lt;li&gt;But different files have different amount of blocks, and I have to call &lt;code&gt;grep&lt;/code&gt; to count them.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, I'm looking for some &lt;code&gt;while&lt;/code&gt; loop example, implementing following pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while /startpattern/ is found&#xA;    execute :/startpattern/;/endpattern/ call ProcessBlock()&#xA;endwile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the example. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Original file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;start/weights-e55_ta0.98_va0.96.ckpt&#xA;Extracting frames &#xA;Using precomputed keys&#xA;Done, 1247 frames&#xA;acc1 1&#xA;acc2 2&#xA;acc3 3&#xA;acc4 5&#xA;end&#xA;start/weights-e18_ta0.84_va0.12.ckpt&#xA;Extracting frames &#xA;Using precomputed keys&#xA;Done, 1247 frames&#xA;acc1 5&#xA;acc2 2&#xA;acc3 3&#xA;acc4 4&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each block starts from &lt;code&gt;start/....&lt;/code&gt; and ends with &lt;code&gt;end&lt;/code&gt;. Numbers after &quot;e&quot; in &lt;code&gt;weights-e...&lt;/code&gt; denote block numbers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this example I'd like to have this file prepended with block numbers and &lt;code&gt;acc&lt;/code&gt;'s that equal 5. It is guaranteed that only one &lt;code&gt;acc\d 5&lt;/code&gt; appears in the block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Block 55: acc4&#xA;Block 18: acc1&#xA;start/weights-e55_ta0.98_va0.96.ckpt&#xA;Extracting frames &#xA;Using precomputed keys&#xA;.... the rest of text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5545" LastEditorUserId="5545" LastEditDate="2020-02-28T21:39:26.687" LastActivityDate="2020-02-28T21:39:26.687" Title="How to iterate over pattern matches?" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23016" PostTypeId="2" ParentId="23015" CreationDate="2020-02-27T13:41:29.953" Score="3" Body="&lt;p&gt;You can try this approach, using &lt;code&gt;:h global&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/startpattern/.;/endpattern/ call ProcessBlock&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;:g/startpattern/&lt;/code&gt; search for &lt;code&gt;startpattern&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.;/endpattern/call ProcessBlock&lt;/code&gt; when found, use range from current line to &lt;code&gt;endpattern&lt;/code&gt; and call your function. (it should be defined with range)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ADD&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ProcessBlock() range&#xA;    &quot; get block number&#xA;    let block = matchstr(getline(a:firstline), '-e\zs\d\d')&#xA;    &quot; get acc 5&#xA;    let acc = ''&#xA;    for linenr in range(a:firstline+1, a:lastline)&#xA;        let line = getline(linenr)&#xA;        if line =~ 'acc\d 5'&#xA;            let acc = matchstr(line, 'acc\d')&#xA;            break&#xA;        endif&#xA;    endfor&#xA;    call append(0, printf(&quot;Block %s: %s&quot;, block, acc))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/start/.;/end/call ProcessBlock()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dKTPg.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dKTPg.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-02-27T14:17:03.097" LastActivityDate="2020-02-27T14:17:03.097" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="23017" PostTypeId="1" AcceptedAnswerId="23020" CreationDate="2020-02-27T15:39:46.367" Score="0" ViewCount="62" Body="&lt;p&gt;Let's say with the cursor I'm on &lt;code&gt;b&lt;/code&gt; in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def f(a=1,&#xA;      b=2,&#xA;      c=3,&#xA;      e=4&#xA;      )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and we want to delete the whole argument including the line break, so that we get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def f(a=1,&#xA;      c=3,&#xA;      e=4&#xA;      )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but without deleting the preceding character (i.e. it should also be applicable to deleting &lt;code&gt;a...&lt;/code&gt;) What is the shortest way to do so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm asking because in non-vim texteditors you could do so by selecting the whole line using &lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;down arrow&lt;/kbd&gt; and then deleting the selection using &lt;kbd&gt;del&lt;/kbd&gt;, and so far I have not found an efficient way to do so in vim, the best I could come up with is using visual mode: &lt;kbd&gt;v&lt;/kbd&gt;, &lt;kbd&gt;j&lt;/kbd&gt;, &lt;kbd&gt;h&lt;/kbd&gt;, &lt;kbd&gt;d&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also imagine a similar situation with something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y = a * xa + \&#xA;    b * xb + \&#xA;    c * xc &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27165" LastEditorUserId="27165" LastEditDate="2020-02-27T15:48:21.623" LastActivityDate="2020-02-27T16:31:59.893" Title="How to delete entry from indented argument from list?" Tags="|indentation|normal-mode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23018" PostTypeId="2" ParentId="23017" CreationDate="2020-02-27T15:48:00.110" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;the best I could come up with is using visual mode: v, j, h, d&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;h&lt;/code&gt; is needed, because you've &lt;code&gt;set selection=inclusive&lt;/code&gt; (this is default). To make the selection behave like in a majority of other text editors use &lt;code&gt;set selection=exclusive&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, if you want &lt;code&gt;shift+arrow&lt;/code&gt; to start the selection you should &lt;code&gt;set keymodel=startsel&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &quot;delete&quot; normally works the same way as &lt;code&gt;x&lt;/code&gt;, so having set the two options above you should be able to do &quot;shift+down+delete&quot; to do the job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, as you see, the whole difference is due to the &quot;unusual&quot; default settings.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2020-02-27T16:16:43.177" LastActivityDate="2020-02-27T16:16:43.177" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23019" PostTypeId="1" CreationDate="2020-02-27T15:58:27.363" Score="1" ViewCount="409" Body="&lt;p&gt;When using &lt;code&gt;&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&lt;/code&gt;, vim opens a signature preview window which is different from the one opened when using &lt;code&gt;:ptag&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to open that one when not completing like when reviewing in normal mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want the full file for preview like with &lt;code&gt;:ptag&lt;/code&gt;. Just the signature and some type metadata from tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set &lt;code&gt;omnifunc=syntaxcomplete#Complete&lt;/code&gt;. Not using any completion plugins.&lt;/p&gt;&#xA;" OwnerUserId="27166" LastActivityDate="2023-12-26T12:06:50.913" Title="How to explicitly open the signature preview window when not completing?" Tags="|autocompletion|ctags|previewwindow|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="23020" PostTypeId="2" ParentId="23017" CreationDate="2020-02-27T16:31:59.893" Score="5" Body="&lt;p&gt;You could do, &lt;code&gt;DJx&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;D -&amp;gt; delete rest of the line&#xA;J -&amp;gt; join the next line&#xA;x -&amp;gt; delete the space added by join&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27166" LastActivityDate="2020-02-27T16:31:59.893" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23021" PostTypeId="1" AcceptedAnswerId="23025" CreationDate="2020-02-27T17:11:16.553" Score="0" ViewCount="147" Body="&lt;p&gt;I am looking to create a new syntax. This is what I have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match jl_comment &quot;^# .*&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I have noticed other examples using pattern like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;^# .*$&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/vim/vim/blob/12f20038/runtime/syntax/sh.vim#L385&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim/vim/blob/12f20038/runtime/syntax/sh.vim#L385&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is confusing to me. With my example, the &lt;code&gt;.&lt;/code&gt; matches anything, so it&#xA;will continue until the end of line. So it seems the &lt;code&gt;$&lt;/code&gt; is redundant. Is that&#xA;the case, or am I misunderstanding the rules?&lt;/p&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-03-29T01:01:05.140" Title="syntax match: redundant end of line marker &quot;$&quot;" Tags="|syntax-highlighting|regular-expression|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23022" PostTypeId="2" ParentId="23011" CreationDate="2020-02-27T18:17:19.207" Score="1" Body="&lt;p&gt;I've finally uninstalled and then again installed tpope/vim-rails and also tpope/vim-projectionist. That fixed the problem. I've deleted question stackoverflow.com/q/60361162/9447571. &lt;/p&gt;&#xA;" OwnerUserId="27158" LastEditorUserId="27158" LastEditDate="2020-02-27T18:29:42.740" LastActivityDate="2020-02-27T18:29:42.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23023" PostTypeId="2" ParentId="3875" CreationDate="2020-02-27T20:22:55.120" Score="0" Body="&lt;p&gt;I think the easiest is of course &lt;code&gt;o&lt;/code&gt; and then &lt;code&gt;Esc&lt;/code&gt; and then for as many lines as you need, you either keep pressing &lt;code&gt;.&lt;/code&gt; or do it like &lt;code&gt;5.&lt;/code&gt; (say if you want 5 blank new lines)&lt;/p&gt;&#xA;" OwnerUserId="27172" LastActivityDate="2020-02-27T20:22:55.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23024" PostTypeId="1" AcceptedAnswerId="23027" CreationDate="2020-02-27T22:02:53.880" Score="4" ViewCount="11565" Body="&lt;p&gt;On Macbook Pro, Terminal, standard Vim, VimPlug&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I start vim I get the following message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing /Users/me/.vimrc:&#xA;line 159:&#xA;E117: Unknown function: plug#begin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my .vimrc I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin('~/.vim/plugged')&#xA;[a bunch of plugins]&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as I can tell the setup is correct but vim doesn't recognize the function so it can't load any of my plugins. Everything was working before. I figured this has something to do with the plug.vim in ~/.vim/autoload. However when I try to access the autoload directory I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd: permission denied: autoload&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This might explain why vim isn't able to call the plug#begin function, but I don't know how to fix it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; Output of &lt;code&gt;ls -l ~/.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;total 0&#xA;drwxr-x---    5 root  wheel    160 Feb 27 10:27 autoload&#xA;drwxr-xr-x    8 gabe  staff    256 Nov 27 14:40 colors&#xA;drwxr-xr-x   30 gabe  staff    960 Feb 27 10:19 plugged&#xA;drwxr-xr-x  370 gabe  staff  11840 Feb 27 17:13 view&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27173" LastEditorUserId="18609" LastEditDate="2020-02-28T03:59:58.337" LastActivityDate="2020-12-01T20:03:21.067" Title="VimPlug, Vim won't load plugins: E117: Unknown function : plug#begin;" Tags="|vimrc|plugin-vim-plug|autoload|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="23025" PostTypeId="2" ParentId="23021" CreationDate="2020-02-28T00:12:28.603" Score="0" Body="&lt;p&gt;An alternative is to define a Region instead of Match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region jl_comment start=/^# / end=/$/&#xA;hi link jl_comment Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also has the benefit of allowing different highlighting for the marker,&#xA;should you want to do that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn region comment_text matchgroup=comment_mark start=/^# / end=/$/&#xA;hi link comment_mark Delimiter&#xA;hi link comment_text Comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-02-28T00:12:28.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23026" PostTypeId="1" AcceptedAnswerId="23058" CreationDate="2020-02-28T02:05:09.870" Score="1" ViewCount="203" Body="&lt;p&gt;I recently launched a RHEL instance on an EC2 container. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got the apache web server to launch, now I'm trying to write some html in &lt;code&gt;/var/www/html&lt;/code&gt; to get my website going. I open &lt;code&gt;index.html&lt;/code&gt; in vi , write my code, save it and it doesn't work. The text is all there but it looks similar to a regular .txt file, no color, no syntax hilighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to even rewrite the html file on my computer and scp the file to &lt;code&gt;/var/www/html&lt;/code&gt; and still no results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully its an easy fix, I'm new to all this so any help would be appreciated!&lt;/p&gt;&#xA;" OwnerUserId="27177" LastEditorUserId="1238" LastEditDate="2020-03-01T14:52:06.593" LastActivityDate="2020-03-03T15:39:30.277" Title="why wont vi recognize html?" Tags="|syntax-highlighting|original-vi|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="23027" PostTypeId="2" ParentId="23024" CreationDate="2020-02-28T04:04:08.343" Score="4" Body="&lt;p&gt;Looks like you created the &lt;code&gt;autoload&lt;/code&gt; directory (or ran the &lt;code&gt;wget&lt;/code&gt; command to install vim-plug) under &lt;code&gt;sudo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running it under &lt;code&gt;sudo&lt;/code&gt; will be bad because it will create files and directories that only root will be able to access!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix that now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sudo chown -Rh gabe:staff ~/.vim&#xA;$ chmod -R a+rX,u+w,go-w ~/.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should reset the ownership of all the files and directories under &lt;code&gt;.vim&lt;/code&gt; to your user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will also reset the file permissions to their default. Not strictly necessary, but cleaner that way.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-02-28T13:11:34.283" LastActivityDate="2020-02-28T13:11:34.283" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="23028" PostTypeId="1" CreationDate="2020-02-28T07:06:30.053" Score="3" ViewCount="1255" Body="&lt;p&gt;I have &lt;code&gt;ctags&lt;/code&gt; installed on my &lt;code&gt;Windows&lt;/code&gt; machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following mappings in my &lt;code&gt;vimrc&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tags=./tags;/&#xA;nnoremap &amp;lt;F5&amp;gt; :!ctags -R .&amp;lt;CR&amp;gt;&#xA;nnoremap ,dd :exec(&quot;tag &quot;.expand(&quot;&amp;lt;cword&amp;gt;&quot;))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to navigate a big project which has many classes. There are many functions that have the same name but defined in different classes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It happens a lot that when trying to jump to the funtion's definition, it jumps to a function defintion but in a different class. As I'm new to the project, I may not recognize that this is not the right function's definition every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make jumping to function's definition &lt;strong&gt;&lt;em&gt;smarter&lt;/em&gt;&lt;/strong&gt; that it jumps to the function's definition in the right class?&lt;/p&gt;&#xA;" OwnerUserId="16800" LastActivityDate="2022-09-13T03:24:24.480" Title="Smart jump to definition" Tags="|ctags|navigation|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="23029" PostTypeId="1" CreationDate="2020-02-28T12:39:34.917" Score="1" ViewCount="877" Body="&lt;p&gt;When I start &lt;code&gt;vim&lt;/code&gt; on my Mac using &lt;code&gt;iterm&lt;/code&gt; or &lt;code&gt;MacVim&lt;/code&gt; I receive the following error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E575: viminfo: Illegal starting char in line: ^A&amp;lt;ce&amp;gt;^Y^C&amp;lt;f1&amp;gt;H&amp;lt;85&amp;gt;&amp;lt;a9&amp;gt;generator&amp;lt;c4&amp;gt;^Dnvim&amp;lt;a7&amp;gt;version&amp;lt;c4&amp;gt;^KNVIM v0.4.3&amp;lt;a9&amp;gt;max_kbyte&#xA;E575: viminfo: Illegal starting char in line: &amp;lt;a3&amp;gt;pid&amp;lt;cd&amp;gt;^I^Q&amp;lt;a8&amp;gt;encoding&amp;lt;c4&amp;gt;^Eutf-8^C&#xA;E575: viminfo: Illegal starting char in line: &amp;lt;ce&amp;gt;^X^I&amp;lt;86&amp;gt;I&amp;lt;83&amp;gt;&amp;lt;a1&amp;gt;f&amp;lt;c4&amp;gt;&amp;gt;/usr/local/Cellar/neovim/0.4.3/share/nvim/runtime/doc/nvim.txt&amp;lt;a1&amp;gt;l^G&amp;lt;a1&amp;gt;c^N^D&amp;lt;ce&amp;gt;^W&amp;lt;b6&amp;gt;&amp;lt;d9&amp;gt;^M&amp;lt;92&amp;gt;&#xA;Press ENTER or type command to continue &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I press ENTER &lt;code&gt;vim&lt;/code&gt; starts. I have deleted &lt;code&gt;.viminfo&lt;/code&gt; file at the &lt;code&gt;home&lt;/code&gt; folder. I suspect that it has something to do with &lt;code&gt;neovim&lt;/code&gt;but I am not sure. &lt;/p&gt;&#xA;" OwnerUserId="27182" LastActivityDate="2020-07-28T00:03:10.320" Title="Error E575 when starting VIM" Tags="|neovim|error|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23031" PostTypeId="1" AcceptedAnswerId="23032" CreationDate="2020-02-28T16:41:12.090" Score="1" ViewCount="146" Body="&lt;p&gt;I would like to set up &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-fzf&lt;/a&gt; to do &lt;code&gt;git grep&lt;/code&gt;/&lt;code&gt;rg&lt;/code&gt;/&lt;code&gt;ag&lt;/code&gt;/&lt;em&gt;whatever&lt;/em&gt; on the word my cursor is over.  With vim-grepper I was able to do &lt;em&gt;gs&lt;strong&gt;iw&lt;/em&gt;&lt;/strong&gt; for this and it was fantastic.  With fzf I can't seem to figure out how to set that up. (My colleague accomplishes the same task by entering &lt;code&gt;&amp;lt;CTRL-R&amp;gt;&amp;lt;CTRL-W&amp;gt;&lt;/code&gt; at the grep prompt, but I figure this could be done better.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general though, for the &lt;em&gt;in word&lt;/em&gt; commands, how are they set up? (&lt;em&gt;e.g.&lt;/em&gt; &lt;code&gt;yiw&lt;/code&gt;, &lt;code&gt;ciw&lt;/code&gt;, &lt;em&gt;etc.&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I had a function &lt;code&gt;foo&lt;/code&gt;, how could I send the &lt;em&gt;in word&lt;/em&gt; as an argument? &lt;em&gt;i.e.&lt;/em&gt; how would I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;leader&amp;gt;m :call foo(getreg(*in word*))&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For my specific question, I bet I'll be remapping the call to &lt;code&gt;fzf#vim#grep&lt;/code&gt;, but I thought I'd ask this because I don't even know how to properly refer to the &lt;em&gt;in word&lt;/em&gt; stuff.&lt;/p&gt;&#xA;" OwnerUserId="7658" LastActivityDate="2020-02-28T16:46:54.120" Title="How do I setup a command to use the &quot;in word&quot; as an argument" Tags="|register|fzf|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23032" PostTypeId="2" ParentId="23031" CreationDate="2020-02-28T16:46:54.120" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;how could I send the in word as an argument?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expand('&amp;lt;cword&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;code&gt;:h expand()&lt;/code&gt; for a full list of specials.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-02-28T16:46:54.120" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23033" PostTypeId="1" AcceptedAnswerId="23059" CreationDate="2020-02-28T19:09:33.807" Score="1" ViewCount="70" Body="&lt;p&gt;I sometimes need to insert auto_incremented, numbered columns on other people's machines so I'm looking for a good way to do so without relying on any custom plugins, macros, or scripts; standard Vim commands only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example going from :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line a&#xA;line b&#xA;line c&#xA;...&#xA;line x&#xA;line y&#xA;line z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becoming then : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line a&#xA;line b&#xA;line 3 c&#xA;...&#xA;line 24 x&#xA;line 25 y&#xA;line z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doing something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:3,25 something&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If older versions of vim or vi have different ways of doing it I'd appreciate hearing about those solutions, too .&lt;/p&gt;&#xA;" OwnerUserId="27161" LastEditorUserId="11054" LastEditDate="2020-02-29T18:16:39.977" LastActivityDate="2020-03-02T00:56:47.317" Title="Most efficient way to insert numbered columns into formatted text using standard Vim commands?" Tags="|original-vim|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23034" PostTypeId="1" AcceptedAnswerId="23035" CreationDate="2020-02-28T19:37:38.513" Score="2" ViewCount="67" Body="&lt;p&gt;I have a leader key set up, and a mapping that allows me to exit windows without typing &lt;code&gt;:&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mapleader = 'f'&#xA;map &amp;lt;leader&amp;gt;q = :q&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Today I installed &lt;code&gt;MattesGroeger/vim-bookmarks&lt;/code&gt; using Vundle, and everything went fine. However when I view the annotations list using &lt;code&gt;ma&lt;/code&gt;, and then I try to exit it using &lt;code&gt;fq&lt;/code&gt;, vim spits out this error phrase:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E21: Cannot make changes, 'modifiable' is off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I can exit it just fine if I manually type out &lt;code&gt;:q&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other answers I've seen so far regarding the &lt;code&gt;modifiable&lt;/code&gt;/&lt;code&gt;nonmodifiable&lt;/code&gt; attributes of buffers imply that a solution is to set the buffer as modifiable, however that seems like a hack. It looks like &lt;code&gt;map&lt;/code&gt; and friends are restricted in use in buffers without &lt;code&gt;modifiable&lt;/code&gt; set, so is there a specific kind of &lt;code&gt;map&lt;/code&gt; that will allow me to use this mapping across all buffers?&lt;/p&gt;&#xA;" OwnerUserId="27194" LastActivityDate="2020-02-28T20:44:48.057" Title="Can't exit buffer using leader mapping - 'cannot make changes'" Tags="|buffers|error|map-operator|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23035" PostTypeId="2" ParentId="23034" CreationDate="2020-02-28T20:44:48.057" Score="2" Body="&lt;p&gt;The problem is with the &lt;code&gt;=&lt;/code&gt; in your command. It's being taken as part of the expansion for the mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's triggering &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;the &lt;code&gt;=&lt;/code&gt; command&lt;/a&gt;, which typically reformats a block of code. Since you have a space after the &lt;code&gt;=&lt;/code&gt;, that's being swallowed as the &quot;motion&quot; for &lt;code&gt;=&lt;/code&gt; (which is roughly equivalent to the motion of going right one character.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess this reformatting wasn't doing anything on your regular buffers, so it wasn't leaving your buffer in a modified state, which would have interfered with the second part of the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But with a read-only buffer, that's likely to be a problem, since the command will fail early, in the way you experienced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map &amp;lt;leader&amp;gt;q :q&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But you might also want to make this mapping non-recursive (usually a best practice) and probably only allow it in normal mode (and not visual or select modes):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;q :q&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-28T20:44:48.057" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23036" PostTypeId="1" AcceptedAnswerId="23056" CreationDate="2020-02-28T21:33:59.303" Score="1" ViewCount="2598" Body="&lt;p&gt;I recently upgraded my Cygwin from a 2015 installation (5 years ago) to the current &quot;2020&quot; version.  Gvim now automatically indents by &lt;code&gt;shiftwidth&lt;/code&gt; columns when I press return after a curly brace &lt;code&gt;{&lt;/code&gt; on a line by itself.  From an initial web search, I think this might be related to the &lt;code&gt;cindent&lt;/code&gt; option, so I issued the command &lt;code&gt;set nocindent&lt;/code&gt;.  The behaviour still persists.  &lt;em&gt;Can someone suggest what help page to look at next?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt; I've been using autoindent for years, but that only matches the indentation of a new line to the indentation of the preceding line, which is what I want.  What I'm trying to disable is indentation that is &lt;code&gt;shiftwidth&lt;/code&gt; more than in the preceding line.  I am using the same &lt;code&gt;vimrc&lt;/code&gt; file as before the 2020 upgrade of Cygwin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some key options in my vim session:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;indentexpr=GetTeXIndent()&#xA;tabstop=3&#xA;shiftwidth=3&#xA;nocindent&#xA;nosmartindent&#xA;filetype=tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a minimum working example (MWE) file &lt;code&gt;test.tex&lt;/code&gt; that exhibits my problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;% test.tex&#xA;%---------&#xA;%        1         2&#xA;%234567890123456789012345   &amp;lt;-- Physical character column number&#xA;      navigation and direct manipulation of the data.\footnote&#xA;      {%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I position my cursor on the &lt;code&gt;{&lt;/code&gt; in column 7 and, in normal mode, press &lt;code&gt;S&lt;/code&gt; or &lt;code&gt;C&lt;/code&gt; to enter insert mode (and overwrite the text).  I then enter &lt;code&gt;{%&amp;lt;CR&amp;gt;&lt;/code&gt;, which creates a new line and positions the insertion point on column 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even as I was typing the preceding paragraph and this paragraph, whenever I press &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to start a new line following a line containing the &lt;code&gt;{&lt;/code&gt; character, the insertion point gets indented to column 4 instead of being positioned on column 1.  (Yes, all of this text was composed in the file &lt;code&gt;test.tex&lt;/code&gt;).  The &lt;code&gt;:map&lt;/code&gt; command shows that the key &lt;code&gt;{&lt;/code&gt; is not mapped to anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;For those who have tried the MWE, even if you don't know the answer, it would be helpful in identifying the cause of the problem to know whether you get the same behaviour.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;New info&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The unwanted extra indentation only afflicts a text file if the file name extension is &lt;code&gt;*.tex&lt;/code&gt;, not if it is &lt;code&gt;*.txt&lt;/code&gt;.  It seems that I need to delve into how syntax-dependent behaviour controlled by the file type.  I peeked into &lt;code&gt;/usr/share/vim/vim81/syntax/tex.vim&lt;/code&gt;, but I think that deciphering it will be a long-term endeavour.&lt;/p&gt;&#xA;" OwnerUserId="7041" LastEditorUserId="7041" LastEditDate="2020-03-01T02:05:20.747" LastActivityDate="2020-03-02T15:17:40.720" Title="Auto-indent after carriage return after line containing open curly brace" Tags="|indentation|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="23037" PostTypeId="1" AcceptedAnswerId="23039" CreationDate="2020-02-28T22:29:31.580" Score="2" ViewCount="45" Body="&lt;p&gt;Just like the title says. How do I identify (and goto) a line based on its word count? For example, what if I want to go to the next line containing more than 5 words?&lt;/p&gt;&#xA;" OwnerUserId="26732" LastActivityDate="2020-03-03T02:49:22.490" Title="How to go to a line based on number of words on a line?" Tags="|search|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23038" PostTypeId="2" ParentId="23033" CreationDate="2020-02-28T22:30:49.997" Score="3" Body="&lt;p&gt;I'd solve this using blockwise Visual mode and the &lt;kbd&gt;g&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;A&lt;/kbd&gt; Visual mode command, that increments each line in the selection by a successive number, effectively creating an incrementing sequence. (See &lt;a href=&quot;https://vimhelp.org/change.txt.html#v_g_CTRL-A&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help v_g_CTRL-A&lt;/code&gt;&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the way I'd do it (especially if I was playing &lt;a href=&quot;https://www.vimgolf.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimgolf&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/c&amp;lt;CR&amp;gt;&lt;/code&gt; to put the cursor on the &lt;code&gt;c&lt;/code&gt; character at the start of the block.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-V&amp;gt;&lt;/code&gt; to begin &lt;a href=&quot;https://vimhelp.org/visual.txt.html#blockwise-visual&quot; rel=&quot;nofollow noreferrer&quot;&gt;blockwise Visual mode&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/y&amp;lt;CR&amp;gt;&lt;/code&gt; to move to the &lt;code&gt;y&lt;/code&gt; character that ends the selection.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;I2 &amp;lt;Esc&amp;gt;&lt;/code&gt; to insert a &lt;code&gt;2&lt;/code&gt; and a space on that column. Note that in blockwise Visual mode, this will insert the contents on &lt;em&gt;every&lt;/em&gt; line of the selection. We're using &lt;code&gt;2&lt;/code&gt; here instead of &lt;code&gt;3&lt;/code&gt; because then we can increment &lt;em&gt;every&lt;/em&gt; line of the selection and we don't need to shrink it on the second step.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gv&lt;/code&gt; to restore the selection once again. This will keep the column of &lt;code&gt;2&lt;/code&gt;s selected.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;g&amp;lt;C-A&amp;gt;&lt;/code&gt; to increment them all.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Ta-da!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you had inserted &lt;code&gt;3&lt;/code&gt; instead of &lt;code&gt;2&lt;/code&gt;, you can still use this method, by skipping the increment on the first line. After &lt;code&gt;gv&lt;/code&gt; you can use &lt;code&gt;o&lt;/code&gt; to jump to the other end of the selection and then &lt;code&gt;j&lt;/code&gt; to shrink the selection, removing the first line from it. After that, &lt;code&gt;g&amp;lt;C-A&amp;gt;&lt;/code&gt; will increment from second to last line, achieving the desired result.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-28T22:30:49.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23039" PostTypeId="2" ParentId="23037" CreationDate="2020-02-28T23:09:18.843" Score="3" Body="&lt;p&gt;Use regular expressions to match lines containing at least four words (sequences of at least one non-blank character) followed by spaces (sequences of at least one blank character), plus a fifth non-blank character indicating the fifth word.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5CS&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\S&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Cs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\s&lt;/code&gt;&lt;/a&gt; to match non-blanks and blanks. You can use &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%7B&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\{4}&lt;/code&gt;&lt;/a&gt; to match 4 of a pattern. And &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F+&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\+&lt;/code&gt;&lt;/a&gt; to match the repeats of non-blanks and blanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend using &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Cv&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;very magic&quot;&lt;/a&gt; regular expressions, which will save you from having to type (even more) backslashes!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To match &lt;em&gt;exactly&lt;/em&gt; 5 words on a line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v^\s*(\S+\s+){4}\S+\s*$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Matches optional whitespace, followed by 4 repetitions of a word with spaces after it, followed by a fifth word, optional whitespace and the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To match &lt;em&gt;at least&lt;/em&gt; 5 words on a line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v(\S+\s+){4}\S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can make use of a substring match in that case. As long as you're seeing the 4 sets of spaces in between words, you know there are at least 5 words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use a different definition of a word (for example, sequences of &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Cw&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\w&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Ck&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\k&lt;/code&gt;&lt;/a&gt; characters) then use the corresponding opposite (&lt;code&gt;\W&lt;/code&gt; or &lt;code&gt;\K&lt;/code&gt;) for the separators in between the words.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="26732" LastEditDate="2020-03-03T02:49:22.490" LastActivityDate="2020-03-03T02:49:22.490" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23040" PostTypeId="2" ParentId="23029" CreationDate="2020-02-28T23:51:05.130" Score="1" Body="&lt;p&gt;In the &lt;code&gt;vimrc&lt;/code&gt; file the following snippet overrides the location of the &lt;code&gt;viminfo&lt;/code&gt; file from the &lt;code&gt;home&lt;/code&gt; folder to &lt;code&gt;~/.vim/dirs&lt;/code&gt; folder:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viminfo+=n~/.vim/dirs/viminfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, deleting the &lt;code&gt;viminfo&lt;/code&gt;file in this folder solves this error.&lt;/p&gt;&#xA;" OwnerUserId="27182" LastActivityDate="2020-02-28T23:51:05.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23042" PostTypeId="1" AcceptedAnswerId="23043" CreationDate="2020-02-29T04:25:45.270" Score="1" ViewCount="551" Body="&lt;p&gt;I'm working on a plugin that needs to parse a YAML-like list and I can't quite nail the pattern needed to split the string. The pattern needs to match a comma delimited list that can have both singly quoted fields and embedded (doubled) single quotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pattern in question is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:pattern = '\m\%(^\|,\)\%(\s*\%([^''][^,]*\)\|\%(''\%(''''\|[^'']\)*''\)\s*\%(,\|$\)\)\@='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The crux of the issue seems to come down to choosing one of the following two inner branches to match either a field that is not quoted, or one that is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[^''][^,]*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;''\%(''''\|[^'']\)*''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I use only one of these sub-patterns I'm able to match successfully, however combining the two seems to fail for some reason. I've tried every variety of lookaround I can think of to no avail. At this point, I'm ready to give up using an expression and switch to a pushdown automaton.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TIA!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Example input/output (the last case is probably the gnarliest):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'a, b, c, d' -&amp;gt; 'a, b, c, d'&#xA;'a', 'b', 'c', 'd' -&amp;gt; 'a', 'b', 'c', 'd'&#xA;'a,''b'',c', d -&amp;gt; 'a,'b',c', d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27198" LastEditorUserId="27198" LastEditDate="2020-02-29T16:11:31.210" LastActivityDate="2020-03-01T15:33:01.840" Title="Trouble Splitting a YAML-Like List" Tags="|vimscript|regular-expression|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23043" PostTypeId="2" ParentId="23042" CreationDate="2020-02-29T06:01:54.070" Score="1" Body="&lt;p&gt;You have a few problems with your regex that I can see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the zero-width forward lookup with &lt;code&gt;@=&lt;/code&gt; covers essentially &lt;em&gt;all&lt;/em&gt; of the match, so highlighting your matches only gets the commas or beginning of lines.&lt;/li&gt;&#xA;&lt;li&gt;your &lt;code&gt;\|&lt;/code&gt; is splitting the two alternatives in a way that the first (&lt;code&gt;[^''][^,]*&lt;/code&gt;) isn't really anchored to the end (&lt;code&gt;\%(,\|$\)&lt;/code&gt;), so it doesn't match &lt;em&gt;all&lt;/em&gt; the way to a comma or end of line.&lt;/li&gt;&#xA;&lt;li&gt;the &lt;code&gt;[^'']&lt;/code&gt; match is too weak, in fact it can match a whitespace or a comma, it should be more restrictive.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I tweaked your regex and got to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let pattern = '\m\%(^\|,\)\s*\zs\([^'' \t,][^,]*\|''\%(''''\|[^'']\)*''\)\ze\s*\%(,\|$\)\@='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; to match the strings themselves, which makes the pattern useful for use in a search. It's also friendly to &lt;code&gt;matchstr()&lt;/code&gt; or &lt;code&gt;matchstrpos()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change that if you're planning to use it differently (for example, in &lt;code&gt;split()&lt;/code&gt; or similar.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same as you, I'm starting at the beginning of the line, or a comma. Then skip whitespace and then branch into either a literal or a single quoted string. The match for the first character of the literal is stronger, we reject &lt;code&gt;'&lt;/code&gt; but also whitespace (space or tab) and a comma. (From the YAML specification, we could decide to reject even more characters here.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After matching one of those, we skip whitespace again (if needed) and then doing a zero-width forward lookup for a comma or the end of the string. (The forward lookup can be important if you're searching repeatedly with &lt;code&gt;n&lt;/code&gt;, since you want the comma to match again on the next use of the pattern.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last suggestion I'd have is to use &quot;very magic&quot; mode for the regular expression, which lets us get rid of 13 backslashes in total!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let pattern = '\v%(^|,)\s*\zs([^'' \t,][^,]*|''%(''''|[^''])*'')\ze\s*%(,|$)@='&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I still see two issues with this pattern:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If a literal has trailing whitespace, it will be returned as part of the expression. Perhaps we could tighten the first regex even more to ensure the last matched character will always be a non-blank character.&lt;/li&gt;&#xA;&lt;li&gt;When the string doesn't follow the correct syntax, the match may be misleading. For example, if there are literal characters after a quoted string that has a comma inside it, it will match the comma and think that the second part (including a single quote on its own) will form a literal. Depending on how you plan to use this regex (for example, calling &lt;code&gt;matchstrpos()&lt;/code&gt; repeatedly?), you can use stronger anchors that will help you catch invalid syntax.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I tested the pattern with a search, by enabling highlighting, setting the search register and pressing &lt;code&gt;n&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set hlsearch&#xA;:let @/ = pattern&#xA;n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I recommend this as a way to debug regular expressions such as this one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; Since the problem is &lt;em&gt;splitting&lt;/em&gt; a YAML list rather than using the pattern in a search, we need to take a slightly different approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;split()&lt;/code&gt; is problematic, since the regex matches are not anchored, so it's really hard to match a comma that's guaranteed to be outside of a quoted string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better approach is to call &lt;code&gt;matchlist()&lt;/code&gt; repeatedly, always starting the match at the position we last stopped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case, we can &lt;em&gt;always&lt;/em&gt; anchor the pattern on &lt;code&gt;^&lt;/code&gt; (since &lt;code&gt;matchlist()&lt;/code&gt; with a position will match that to that specific position, not the very beginning of the string.) We should also consume the ending comma and whitespace as we match. Since we now need the full match (to advance the position counter), we'll use a capture group to get the part that interests us, which is the YAML literal or quoted string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an implementation of this method:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SplitYamlList(expr)&#xA;    let pattern = '\v^\s*([^'' \t,]%([^,]*[^ \t,])?|''%(''''|[^''])*'')\s*%(,|$)'&#xA;    let result = []&#xA;    let pos = 0&#xA;    let end = len(a:expr)&#xA;    while pos &amp;lt; end&#xA;        let match = matchlist(a:expr, pattern, pos)&#xA;        if empty(match)&#xA;            throw &quot;Parse error, can't match at position &quot;.pos&#xA;        endif&#xA;        let [mstr, mgroup; _] = match&#xA;        call add(result, mgroup)&#xA;        let pos += len(mstr)&#xA;    endwhile&#xA;    return result&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function will also be able to detect malformed items (such as a quoted string with trailing characters) and it will &lt;code&gt;throw&lt;/code&gt; an error in that case, indicating the position in which the syntax error was found.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-03-01T15:33:01.840" LastActivityDate="2020-03-01T15:33:01.840" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23047" PostTypeId="1" AcceptedAnswerId="34731" CreationDate="2020-02-29T14:20:57.063" Score="1" ViewCount="261" Body="&lt;p&gt;I used to use chromium before and then, I could press &lt;code&gt;gx&lt;/code&gt; on an url and vim would open it in a new tab if a chromium instance was already running, otherwise create a new window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in firefox, when I press &lt;code&gt;gx&lt;/code&gt; on an url, vim opens a new firefox instance that is not even signed into my firefox account.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I change the behavior of &lt;code&gt;gx&lt;/code&gt; so that it opens a new tab of an already opened firefox instance?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;N.B.&lt;/strong&gt; The output of &lt;code&gt;lsb_release -a&lt;/code&gt; is as follows.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;enan@elariel:~$ lsb_release -a&#xA;No LSB modules are available.&#xA;Distributor ID: Ubuntu&#xA;Description:    Ubuntu 18.04.3 LTS&#xA;Release:    18.04&#xA;Codename:   bionic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16280" LastEditorUserId="10604" LastEditDate="2020-03-18T16:26:14.133" LastActivityDate="2021-10-09T03:36:53.457" Title="Change behavior of `gx` key" Tags="|key-bindings|netrw|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="23048" PostTypeId="1" AcceptedAnswerId="23049" CreationDate="2020-02-29T17:08:48.373" Score="3" ViewCount="1968" Body="&lt;p&gt;All I was trying to do is enable syntax highlighting on my local machine that matches the syntax highlighting on my remote. I googled around and someone explained that all that was needed was a modification to the local .vimrc file. Somehow, though, I think I have managed to screw up vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I try to open vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;username ~ $ vim&#xA;Error detected while processing /Users/username/.vimrc:&#xA;line   52:&#xA;E33: No previous substitute regular expression&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing enter opens vim, but I'd still like to resolve this error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I cd'd into the proper directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;username ~ $ cd /Users/username&#xA;username ~ $ vim .vimrc&#xA;Error detected while processing /Users/username/.vimrc:&#xA;line   52:&#xA;E33: No previous substitute regular expression&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I press enter, and then I get my .vimrc file (I copy/pasted the vimrc file that has the syntax highlighting I want from a remote (Linux) to my local (Mac), which might be the issue but I'm too much of a n00b to understand why):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by&#xA;&quot; the call to :runtime you can find below.  If you wish to change any of those&#xA;&quot; settings, you should do it in this file (/etc/vim/vimrc), since debian.vim&#xA;&quot; will be overwritten everytime an upgrade of the vim packages is performed.&#xA;&quot; It is recommended to make changes after sourcing debian.vim since it alters&#xA;&quot; the value of the 'compatible' option.&#xA;&#xA;&quot; This line should not be removed as it ensures that various options are&#xA;&quot; properly set to work with the Vim-related packages available in Debian.&#xA;runtime! debian.vim&#xA;&#xA;&quot; Uncomment the next line to make Vim more Vi-compatible&#xA;&quot; NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous&#xA;&quot; options, so any other options should be set AFTER setting 'compatible'.&#xA;&quot;set compatible&#xA;&#xA;&quot; Vim5 and later versions support syntax highlighting. Uncommenting the next&#xA;&quot; line enables syntax highlighting by default.&#xA;if has(&quot;syntax&quot;)&#xA;  syntax on&#xA;endif&#xA;&quot; If using a dark background within the editing area and syntax highlighting&#xA;&quot; turn on this option as well&#xA;&quot;set background=dark&#xA;&#xA;&quot; Uncomment the following to have Vim jump to the last position when&#xA;&quot; reopening a file&#xA;&quot;if has(&quot;autocmd&quot;)&#xA;&quot;  au BufReadPost * if line(&quot;'\&quot;&quot;) &amp;gt; 1 &amp;amp;&amp;amp; line(&quot;'\&quot;&quot;) &amp;lt;= line(&quot;$&quot;) | exe &quot;normal! g'\&quot;&quot; | endif&#xA;&quot;endif&#xA;&#xA;&quot; Uncomment the following to have Vim load indentation rules and plugins&#xA;&quot; according to the detected filetype.&#xA;&quot;if has(&quot;autocmd&quot;)&#xA;&quot;  filetype plugin indent on&#xA;&quot;endif&#xA;&#xA;&quot; The following are commented out as they cause vim to behave a lot&#xA;&quot; differently from regular Vi. They are highly recommended though.&#xA;&quot;set showcmd            &quot; Show (partial) command in status line.&#xA;&quot;set showmatch          &quot; Show matching brackets.&#xA;&quot;set ignorecase         &quot; Do case insensitive matching&#xA;&quot;set smartcase          &quot; Do smart case matching&#xA;&quot;set incsearch          &quot; Incremental search&#xA;&quot;set autowrite          &quot; Automatically save before commands like :next and :make&#xA;&quot;set hidden             &quot; Hide buffers when they are abandoned&#xA;&quot;set mouse=a            &quot; Enable mouse usage (all modes)&#xA;:set shiftwidth=4&#xA;:set autoindent&#xA;:set smartindent&#xA;~&#xA;&quot; Source a global configuration file if available&#xA;if filereadable(&quot;/etc/vim/vimrc.local&quot;)&#xA;  source /etc/vim/vimrc.local&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I have two questions here: how can I enable syntax highlighting, and how can I fix whatever it is that I screwed up?&lt;/p&gt;&#xA;" OwnerUserId="27204" LastActivityDate="2020-02-29T18:43:14.907" Title="vimrc error E33 and syntax highlighting" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23049" PostTypeId="2" ParentId="23048" CreationDate="2020-02-29T18:43:14.907" Score="4" Body="&lt;p&gt;The problem you're having is on line 52. Looking at your vimrc, you'll see the &lt;code&gt;~&lt;/code&gt; by itself in a line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3A%7E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :~&lt;/code&gt;&lt;/a&gt; can tell you, that's the command to &lt;em&gt;&quot;repeat last substitute with same substitute string but with last used search pattern.&quot;&lt;/em&gt; So it makes sense that you're getting the error message complaining that there's no previous pattern to repeat...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably got that line in a copy &amp;amp; paste from Vim on another machine, since Vim typically shows a string of &lt;code&gt;~&lt;/code&gt; at the end of the file and you might have copied the first of them by mistake...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding syntax highlighting, typically what you need is &lt;code&gt;syntax on&lt;/code&gt; (or &lt;code&gt;syntax enable&lt;/code&gt;, but &lt;code&gt;syntax on&lt;/code&gt; is stronger and that's ok.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably also need to enable filetype support, so I'd recommend adding at least &lt;code&gt;filetype on&lt;/code&gt;, but better is to uncomment the block including &lt;code&gt;filetype plugin indent on&lt;/code&gt; that also gets you indentation rules and plugins per filetype.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-02-29T18:43:14.907" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23050" PostTypeId="1" AcceptedAnswerId="23052" CreationDate="2020-03-01T00:07:03.903" Score="1" ViewCount="188" Body="&lt;p&gt;I've been running &lt;code&gt;gvim -w /dev/shm/vim_keystrokes&lt;/code&gt; for some time, to collect keystrokes for later analysis. But now I'm looking for some guidance on how to make sense of the binary log file. Here's a snippet, asking &lt;code&gt;less&lt;/code&gt;  to render binary data:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uf7Zv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uf7Zv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking for at minimum enough information to tokenize this stream, even if I can't make sense of all the tokens. But ideally I'd like to be pointed to a document that can help me properly parse the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is some prior art but with no comments:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.drbunsen.org/vim-croquet/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.drbunsen.org/vim-croquet/&lt;/a&gt;&#xA;&lt;a href=&quot;https://github.com/dstokes/vim-stream&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/dstokes/vim-stream&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this SO question suggests gvim is writing garbage to the log in some way, but doesn't provide any clarity:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/3981535/using-the-w-option-of-vim&quot;&gt;https://stackoverflow.com/questions/3981535/using-the-w-option-of-vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: It looks like three byte sequences starting with 0x80 can be filtered out and represent window events in some way, though I need to look closer.&lt;/p&gt;&#xA;" OwnerUserId="22849" LastEditorUserId="22849" LastEditDate="2020-03-01T00:41:54.457" LastActivityDate="2020-03-01T05:17:51.430" Title="parsing / lexing scriptout log file from gvim -w" Tags="|gvim|linux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23051" PostTypeId="2" ParentId="23036" CreationDate="2020-03-01T03:02:32.307" Score="0" Body="&lt;p&gt;Based on &lt;a href=&quot;https://vi.stackexchange.com/questions/20560/why-does-vim-still-auto-indent-latex-after-i-set-noai-noci-nosi&quot;&gt;this page&lt;/a&gt;, I found that &lt;code&gt;:set indentexpr=&lt;/code&gt; removed &lt;code&gt;tex&lt;/code&gt; file-dependent extraneous indentation.  I intend to put it in my &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just a cautionary note: As &lt;em&gt;filbranden&lt;/em&gt; said, this solution might not be persistent.  If you are able to get any of his solutions working, it will less of a hack than &lt;code&gt;:set indentexpr=&lt;/code&gt;.  If for some reason you are running into problems, however, and don't have the time to troubleshoot and experiment, then &lt;code&gt;:set indentexpr=&lt;/code&gt; might get you going for the immediate present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To possibly save others time, based on &lt;a href=&quot;https://vim.fandom.com/wiki/How_to_stop_auto_indenting&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt;, I also tried the following without success:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filetype indent off&#xA;filetype indent plugin off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7041" LastEditorUserId="7041" LastEditDate="2020-03-02T15:17:40.720" LastActivityDate="2020-03-02T15:17:40.720" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23052" PostTypeId="2" ParentId="23050" CreationDate="2020-03-01T04:45:15.477" Score="0" Body="&lt;p&gt;Someone else has done this kind of processing, also open source (Ruby): &lt;a href=&quot;https://github.com/igrigorik/vimgolf/tree/master/lib/vimgolf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/igrigorik/vimgolf/tree/master/lib/vimgolf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Players of Vim Golf have their keystrokes recorded also with &lt;code&gt;-w&lt;/code&gt; (well, &lt;code&gt;-W&lt;/code&gt; actually, but same idea) and the library decodes it into nice human readable form. I discuss at some length here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/14443/11054&quot;&gt;How does vimgolf record all keystrokes?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The triple-byte sequences beginning with 0x80 are, indeed, special. This is touched upon in the linked answer. (They include all non-printing and control inputs that can't be easily represented by a typed character. &lt;kbd&gt;Esc&lt;/kbd&gt;, &lt;kbd&gt;Tab&lt;/kbd&gt;, &lt;kbd&gt;Enter&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;+whatever,  etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the suggestion that garbage is being printed, I may have stumbled upon the same issue (a certain terminal code needed to be nulled in my vimrc...also mentioned in my post).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bottom line: Unless you have zero coding experience it should be relatively easy to incorporate the vimgolf lookup tables (hash maps) into whatever you want to do. Maybe you just want confirmation that you can ignore certain inputs. Regardless, feel free to ask follow up questions if you're not sure about something.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-03-01T05:17:51.430" LastActivityDate="2020-03-01T05:17:51.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23053" PostTypeId="1" AcceptedAnswerId="23054" CreationDate="2020-03-01T12:25:04.553" Score="1" ViewCount="389" Body="&lt;p&gt;I have written a function which capitalises the first letter of each word like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CamelCase() range&#xA;  let old = getline(a:firstline, a:lastline)&#xA;  for line in old&#xA;      let x = substitute(line,'\v&amp;lt;(.)(\w*)', '\u\1\L\2', 'g')&#xA;      echom x&#xA;  endfor&#xA;endfunction&#xA;&#xA;command! -range=% CamelCase &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call CamelCase()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently &lt;code&gt;:CamelCase()&lt;/code&gt;displays the output in &lt;code&gt;:messsages&lt;/code&gt; (because of &lt;code&gt;echom&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do i modify the function so it modifies the current buffer directly instead ? I have tried removing &lt;code&gt;echom x&lt;/code&gt; and &lt;code&gt;let x=&lt;/code&gt; but I get a large number of errors.&lt;/p&gt;&#xA;" OwnerUserId="21293" LastActivityDate="2020-03-01T14:40:16.837" Title="vimscript : How do I apply a function on the current buffer?" Tags="|vimscript|neovim|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23054" PostTypeId="2" ParentId="23053" CreationDate="2020-03-01T14:40:16.837" Score="2" Body="&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#setline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;setline()&lt;/code&gt;&lt;/a&gt; to set the contents of a line in the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which, in your case, should be enough, since you're changing line contents in place and not inserting or deleting lines. (There's &lt;a href=&quot;https://vimhelp.org/eval.txt.html#appendbufline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;appendbufline()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/eval.txt.html#deletebufline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;deletebufline()&lt;/code&gt;&lt;/a&gt; which can help with that.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that in your case you don't need to have your function be a &lt;code&gt;range&lt;/code&gt; function, since the behavior of &lt;code&gt;:call&lt;/code&gt; of a non-range function with a range is to call it repeatedly for each line in the range. So that would implicitly loop over the lines for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should be enough:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CamelCase()&#xA;    call setline('.',&#xA;       \ substitute(getline('.'),&#xA;       \ '\v&amp;lt;(.)(\w*)', '\u\1\L\2', 'g'))&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can keep the exact same command definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=% CamelCase &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call CamelCase()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-01T14:40:16.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23055" PostTypeId="2" ParentId="23042" CreationDate="2020-03-01T15:22:53.900" Score="1" Body="&lt;p&gt;It looks like there's an issue with how splits operate versus run of the mill pattern matching. I wasn't able to come up with a good explanation for why this problem exists, so I ended up taking a more iterative approach similar to @filbranden's suggestion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const s:list_pattern =&#xA;        \ '^\s*(%(''%(''''|[^''])*'')|%([^'',][^,]*))\s*%(,|$)')&#xA;&#xA;function! s:list_split(val) abort&#xA;  let list = []&#xA;  let idx = 0&#xA;  while idx &amp;lt; strlen(a:val)&#xA;    let [match, str ; _] = matchlist(a:val[idx:], s:list_pattern)&#xA;      let idx += strlen(match)&#xA;      call add(list, str)&#xA;  endwhile&#xA;  return list&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27198" LastEditorUserId="27198" LastEditDate="2020-03-01T15:26:15.433" LastActivityDate="2020-03-01T15:26:15.433" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23056" PostTypeId="2" ParentId="23036" CreationDate="2020-03-01T16:10:19.653" Score="2" Body="&lt;p&gt;This behavior is being enabled by the &lt;a href=&quot;https://github.com/vim/vim/blob/v8.2.0/runtime/indent/tex.vim#L169&quot; rel=&quot;nofollow noreferrer&quot;&gt;custom indentation function&lt;/a&gt; for the &lt;code&gt;tex&lt;/code&gt; filetype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can configure the behavior of that function, by setting some variables in your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your specific case, to disable indentation after braces, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tex_indent_brace = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;tex&lt;/code&gt; indentation also indents &lt;code&gt;\item&lt;/code&gt; elements in a special way, which you can disable with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:tex_indent_items = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to &lt;strong&gt;completely block&lt;/strong&gt; Vim indentation for filetype &lt;code&gt;tex&lt;/code&gt;, one good way to do it is to create an &lt;code&gt;indent/tex.vim&lt;/code&gt; file that supercedes the one you want to block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create a file &lt;code&gt;~/.vim/indent/tex.vim&lt;/code&gt;, which comes earlier than the one in Vim runtimes in the search path, and add the following contents to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let b:did_indent = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, when the one you want to block gets to run, it will see that indentation is already configured and so it will skip it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(That's better than messing with permissions or removing the &lt;code&gt;indent/tex.vim&lt;/code&gt; in runtimes, since an operating system update will probably revert those changes.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that you can't really avoid the indentation function by unsetting &lt;code&gt;indentexpr&lt;/code&gt; from your vimrc. The indentation plugin will always load when the filetype is determined, which happens much later than your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disabling indentation plugins altogether from your vimrc &lt;em&gt;will&lt;/em&gt; work, so &lt;code&gt;filetype plugin off&lt;/code&gt; works as long as nothing else is re-enabling it later on. (Check with a plain &lt;code&gt;:filetype&lt;/code&gt;, which will tell you which items are enabled.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's unclear why you started getting these starting with an upgrade, since that code in &lt;code&gt;indent/tex.vim&lt;/code&gt; seems to be around for quite a long time... Perhaps you didn't have the Vim runtime files installed and now you do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possibility is that, starting with Vim 8, if you don't have a vimrc file, a default one will be loaded, which will most likely enable all filetype support and have these plug-ins start to load when previously they wouldn't. See &lt;a href=&quot;https://vimhelp.org/starting.txt.html#defaults.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help defaults.vim&lt;/code&gt;&lt;/a&gt; for details on that. In any case, the solution for that one is simple, just create a vimrc file, even if it's an empty one, that will prevent you from getting the settings from the defaults file.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-03-02T03:41:18.613" LastActivityDate="2020-03-02T03:41:18.613" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="23057" PostTypeId="2" ParentId="8333" CreationDate="2020-03-01T16:24:13.640" Score="0" Body="&lt;p&gt;Seems that plugins have &quot;actions&quot; that you can call with &lt;code&gt;:call&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example to map &lt;code&gt;Alt+;&lt;/code&gt; to nerdcomment toggle:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;M-;&amp;gt; :call NERDComment(0,&quot;toggle&quot;)&amp;lt;CR&amp;gt;&#xA;vnoremap &amp;lt;M-;&amp;gt; :call NERDComment(0,&quot;toggle&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Related answer: &lt;a href=&quot;https://stackoverflow.com/a/30831547/1663462&quot;&gt;https://stackoverflow.com/a/30831547/1663462&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13656" LastActivityDate="2020-03-01T16:24:13.640" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23058" PostTypeId="2" ParentId="23026" CreationDate="2020-03-01T16:27:27.523" Score="0" Body="&lt;p&gt;Have you tried ':syntax on'? If this works for you, add it to your ~/.vimrc so you don't have to do it manually each time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a reference page with more details if needed:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.tecmint.com/enable-syntax-highlighting-in-vi-editor/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.tecmint.com/enable-syntax-highlighting-in-vi-editor/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="27215" LastActivityDate="2020-03-01T16:27:27.523" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23059" PostTypeId="2" ParentId="23033" CreationDate="2020-03-01T16:42:49.853" Score="3" Body="&lt;p&gt;I’d actually do this using either &lt;a href=&quot;https://vi.stackexchange.com/a/23038/343&quot;&gt;filbranden’s answer&lt;/a&gt; or possibly a macro recording, but as you specifically requested an ex command that takes a &lt;code&gt;3,25&lt;/code&gt; range, how about using a substitute command that uses as its replacement an expression that calls the &lt;code&gt;line()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:3,25s/line \zs/\=line('.') . ' '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or alternatively, a normal command using the same function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:3,25norm!ea ^R=line('.')^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that in the above, ^R is a literal CTRL-R character, and ^M is a CTRL-M. To insert them into the command line you need to type &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Ctrl-R&lt;/kbd&gt; and &lt;kbd&gt;Ctrl-V&lt;/kbd&gt;&lt;kbd&gt;Enter&lt;/kbd&gt;, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/23033/most-efficient-way-to-insert-numbered-columns-into-formatted-text-using-standard/23059?noredirect=1#comment41846_23059&quot;&gt;D. Ben Knoble points out in the comments&lt;/a&gt;, you can avoid one of these special characters by &quot;putting&quot; the contents of the expression register, instead of inserting it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:3,25norm! e&quot;=line('.')^Mpi &#xA;                           ^ note the space at the end of the line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Further details&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First command:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help /\zs&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help sub-replace-expression&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help line()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Second command:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help :normal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help i_CTRL-R&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help quote_&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-03-02T00:56:47.317" LastActivityDate="2020-03-02T00:56:47.317" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23060" PostTypeId="2" ParentId="23033" CreationDate="2020-03-01T18:28:28.950" Score="3" Body="&lt;p&gt;While I was experimenting with &lt;a href=&quot;https://vi.stackexchange.com/a/23059/10604&quot;&gt;Rich's answer&lt;/a&gt;, I came up with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/./put =line('.')|join&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be shortened to &lt;code&gt;:g/./pu =line('.')|j&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And yes, you can adjust the range of &lt;code&gt;:global&lt;/code&gt;—&lt;code&gt;:3,25g/./pu =line('.')|j&lt;/code&gt; will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: this puts the line number at the &lt;em&gt;beginning&lt;/em&gt; of the line, at which point you might as well work with &lt;code&gt;:3,25s/^/\=line('.')&lt;/code&gt;. Since you need the number in the middle, you could do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:3,25global/./put =line('.')|join|normal! 0dawwp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But at this point, again, you might as well use something else.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-03-01T18:28:28.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23061" PostTypeId="1" CreationDate="2020-03-01T19:04:44.027" Score="3" ViewCount="221" Body="&lt;p&gt;Typical mark placement using &lt;code&gt;m&lt;/code&gt; places the mark at the cursor. When the cursor is on the last character of a line, this means that jumping to that mark for the purpose of copying text starts the copying before the last character of the line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if I have the sentence &lt;code&gt;Vim is a great editor.&lt;/code&gt; and place a mark with my cursor on the &lt;code&gt;.&lt;/code&gt; using &lt;code&gt;ma&lt;/code&gt;, then move up some number of lines and hit &lt;code&gt;y`a&lt;/code&gt;, I yank those lines plus &lt;code&gt;Vim is a great editor&lt;/code&gt; but not the entire sentence. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to place a mark after the period so that I can yank the entire line in situations like this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize that if I never add more characters to that particular line, I can use &lt;code&gt;y'a&lt;/code&gt;, but sometimes I want to maintain the flexibility to add more characters later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is not possible, are there other features of Vim I can use to accomplish the same thing? For instance, is there some &quot;yank until after cursor&quot; command?&lt;/p&gt;&#xA;" OwnerUserId="27216" LastActivityDate="2020-03-01T21:11:41.930" Title="Is it possible to place marks at the end of a line?" Tags="|cut-copy-paste|normal-mode|mark|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23063" PostTypeId="1" CreationDate="2020-03-01T19:10:10.447" Score="2" ViewCount="161" Body="&lt;p&gt;When I run &lt;code&gt;:echo execute('echo &quot;oh&quot;')&lt;/code&gt; I get a leading blank line before the &quot;oh&quot; message. This happens with when I use no vimrc as well. Why is this?&lt;/p&gt;&#xA;" OwnerUserId="26698" LastActivityDate="2020-03-02T04:36:08.187" Title="Leading blank line with execute function()" Tags="|whitespace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23064" PostTypeId="2" ParentId="23061" CreationDate="2020-03-01T19:25:55.257" Score="4" Body="&lt;p&gt;I found the answer &lt;a href=&quot;https://stackoverflow.com/a/27754274/12542129&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Another easy way is to just add &lt;code&gt;v&lt;/code&gt; right after &lt;code&gt;y&lt;/code&gt;, no setting or Visual&#xA;  mode selection necessary.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;`a&quot;ryv`b&#xA;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;y`b&lt;/code&gt; yanks to mark &lt;code&gt;b&lt;/code&gt; excluding the character under mark &lt;code&gt;b&lt;/code&gt;, whereas &lt;code&gt;yv`b&lt;/code&gt;&#xA;  yanks to mark &lt;code&gt;b&lt;/code&gt; including the character under it.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;See &lt;code&gt;:h o_v&lt;/code&gt; for more info.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="27216" LastEditorUserId="18609" LastEditDate="2020-03-01T21:11:41.930" LastActivityDate="2020-03-01T21:11:41.930" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23065" PostTypeId="2" ParentId="23063" CreationDate="2020-03-02T04:36:08.187" Score="2" Body="&lt;p&gt;Indeed, you do get a leading newline at the beginning of the result of &lt;code&gt;execute()&lt;/code&gt; whenever the command running inside it produces any output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the Vim source code, it looks like that's coming from &lt;a href=&quot;https://github.com/vim/vim/blob/v8.2.0/src/message.c#L1384,L1386&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* when redirecting, may need to start a new line. */&#xA;if (!did_return)&#xA;    redir_write((char_u *)&quot;\n&quot;, -1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, it's adding a newline character to the redirection target file/register/variable each time a new line is &lt;em&gt;started&lt;/em&gt;, which I believe will also happen with the first command producing output inside the redirection, generating the leading newline at the start of the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's another question, from quite a few years back, asking about this in the context of &lt;code&gt;:redir&lt;/code&gt;, &lt;a href=&quot;https://stackoverflow.com/q/8453211/9447571&quot;&gt;How do I capture the output of a vim command in a register, without the newlines?&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;However, the problem with using &lt;code&gt;:redir&lt;/code&gt; is that it causes 3 or 4 extra newlines in front of the output, and they appear to be difficult to remove using the substitute function.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It seems you get even more leading newlines if the commands are run without using &lt;code&gt;:silent&lt;/code&gt;, and &lt;code&gt;execute()&lt;/code&gt; defaults to using &lt;code&gt;silent&lt;/code&gt; (the second optional argument controls it), so you only get one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it seems that this is a long-standing issue and there don't seem to be many more references to it around, or a bug report or suggested patches to fix it...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd say that's &lt;em&gt;probably&lt;/em&gt; because the suggested usage of these commands involve splitting the output into lines. &lt;a href=&quot;https://vimhelp.org/eval.txt.html#execute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help execute()&lt;/code&gt;&lt;/a&gt; even mentions that explicitly:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To get a list of lines use &lt;code&gt;split()&lt;/code&gt; on the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;    split(execute('args'), &quot;\n&quot;)&#xA;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The default behavior for &lt;code&gt;split()&lt;/code&gt; is to suppress empty groups at the start and end of the list, so it ends up &lt;em&gt;naturally&lt;/em&gt; solving this issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess my recommendation would be that you try to work with the output of &lt;code&gt;execute()&lt;/code&gt; that way, splitting it into lines. Or, if you want the variable with the multi-line string, a simple call to &lt;code&gt;trim()&lt;/code&gt; should filter out the extraneous leading newline.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-02T04:36:08.187" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23066" PostTypeId="1" AcceptedAnswerId="23067" CreationDate="2020-03-02T07:54:31.500" Score="4" ViewCount="11109" Body="&lt;p&gt;I activated a cursorline for Vim on the terminal which by default seems to underline the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Npvw0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Npvw0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would like it to be more like what the cursorcolumn looks like. Is there a way to change the appearance?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already tried to set colors but that had no effect&lt;/p&gt;&#xA;" OwnerUserId="27219" LastEditorUserId="10604" LastEditDate="2020-03-02T16:04:24.430" LastActivityDate="2020-03-02T16:04:24.430" Title="Change Cursorline Style" Tags="|cursorline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23067" PostTypeId="2" ParentId="23066" CreationDate="2020-03-02T08:32:44.177" Score="10" Body="&lt;p&gt;The style of these two settings is defined by the CursorLine and CursorColumn highlight groups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I query these two on my Vim, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi CursorColumn&#xA;CursorColumn   xxx term=reverse ctermbg=242 guibg=Grey40&#xA;:hi CursorLine&#xA;CursorLine     xxx term=underline cterm=underline&#xA;                   guibg=Grey40&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So what we want to do is make CursorLine look more like CursorColumn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For terminal Vim, with colors, we're most interested in the &lt;code&gt;cterm&lt;/code&gt; group of settings (&lt;code&gt;term=reverse&lt;/code&gt; is for B&amp;amp;W terminal, the &lt;code&gt;gui&lt;/code&gt; ones are primarily for gvim.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So one simple way is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi CursorLine cterm=NONE ctermbg=242&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another way forward is to &quot;link&quot; these styles so they look the same:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi clear CursorLine&#xA;hi link CursorLine CursorColumn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you also enable line numbers, you might want to look at this group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi CursorLineNr&#xA;CursorLineNr   xxx term=bold cterm=underline ctermfg=11&#xA;                   gui=bold guifg=Yellow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's the highlighting for the line numbers on the current line. You might want to have them match the background you're using for the rest of the line and disable the underlines there as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These might be controlled by your &lt;code&gt;colorscheme&lt;/code&gt;, so if you set them in your vimrc you might want to do so &lt;em&gt;after&lt;/em&gt; you set a colorscheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That might still not be enough if you tend to switch colorschemes or switch background from dark to light or vice-versa. To have these always apply after a colorscheme, you can also create an autocmd that sets them up after a colorscheme is loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup cursorline&#xA;  au!&#xA;  au ColorScheme * hi clear CursorLine&#xA;               \ | hi link CursorLine CursorColumn&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also add any commands you decide to use for CursorLineNr to this group as well.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-02T08:32:44.177" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23068" PostTypeId="1" AcceptedAnswerId="23072" CreationDate="2020-03-02T08:58:45.890" Score="1" ViewCount="29" Body="&lt;p&gt;When comparing a buffer to it's on disk file, I regularly do (omitting the &lt;code&gt;diffthis&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:botright vnew&#xA;:r ++edit #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;https://vimhelp.org/insert.txt.html#%3Aread&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vimhelp.org/insert.txt.html#%3Aread&lt;/a&gt; the option ++edit should set the options of fileformat and fileencoding for the buffer to what regularly &lt;code&gt;:edit&lt;/code&gt;ing &lt;code&gt;file&lt;/code&gt; would give, unless I interpret the documentation wrong. Problem is, that none of the options of fileformat, fileencoding , ... get set for the &lt;code&gt;:vnew&lt;/code&gt; buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit (what I am expecting):&lt;/strong&gt; Assume I am editing a file minimal.yaml.  What I get with &lt;code&gt;:e minimal.yaml&lt;/code&gt; is syntax highlighting for that file (could be json, whatever file format).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If another process changes that file on disk and I revisit that file in a &lt;code&gt;vnew | r ++edit #&lt;/code&gt; buffer, that new buffer has no fileformat set, while I expect it to be of type yaml.&lt;/p&gt;&#xA;" OwnerUserId="11633" LastEditorUserId="11633" LastEditDate="2020-03-02T12:58:14.027" LastActivityDate="2020-03-02T15:02:15.377" Title="Why does :read ++edit doesn't set fileformat, fileencoding?" Tags="|file-formats|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23069" PostTypeId="2" ParentId="17296" CreationDate="2020-03-02T11:38:46.033" Score="4" Body="&lt;p&gt;Uploaded my personal config &lt;a href=&quot;https://github.com/DarioHett/tvp-repl&quot; rel=&quot;nofollow noreferrer&quot;&gt;tvp-repl&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Copy from one pane with Ctrl+c and paste to another (requires &lt;strong&gt;xclip&lt;/strong&gt;)&lt;br&gt;&#xA;vim with +clipboard, .vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set clipboard=unnamedplus&#xA;vnoremap &amp;lt;C-c&amp;gt; &quot;+y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;tmux bindings to dump the clipboard .tmux.conf:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bind-key Enter run &quot;tmux send-keys -t 0 C-c&quot; \; &#xA;run &quot;tmux select-pane -t 1&quot; \; &#xA;run &quot;tmux set-buffer \&quot;$(xclip -o -sel clipboard)\&quot;; tmux paste-buffer&quot; \; &#xA;run &quot;tmux send-keys -t 1 Enter&quot; \; &#xA;run &quot;tmux select-pane -t 0&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Execution&lt;/strong&gt;:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Enter&lt;/kbd&gt; in tmux will send &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; to Pane 0 (vim).&lt;br&gt;&#xA;We bind &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; in vim, to copy to the system clipboard.  &lt;/li&gt;&#xA;&lt;li&gt;We select Pane 1, where we want to paste the content.  &lt;/li&gt;&#xA;&lt;li&gt;Next the system clipboard will be extracted with xclip to the tmux buffer and immediately paste the buffer into the current selection   (Pane 1).  &lt;/li&gt;&#xA;&lt;li&gt;Lastly, we send &lt;kbd&gt;Enter&lt;/kbd&gt; and jump back to Pane 0 (vim).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The .tmux.conf is pretty human-readable. I personally call tmux with vim in 0 and ipython in 1 and prefer to keep it hard-coded. Alternatively, you could use &lt;code&gt;run &quot;tmux last-pane&quot;&lt;/code&gt; to jump between the next and previous pane.&lt;/p&gt;&#xA;" OwnerUserId="27226" LastEditorUserId="27226" LastEditDate="2020-03-05T23:47:28.667" LastActivityDate="2020-03-05T23:47:28.667" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23070" PostTypeId="2" ParentId="22972" CreationDate="2020-03-02T13:33:07.337" Score="2" Body="&lt;pre&gt;&lt;code&gt;vi(&amp;lt;Esc&amp;gt;ds(gvhoh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Breakdown:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;vi(&lt;/code&gt; selects visual region within the brackets using the surround plugin.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; stops the visual selection mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ds(&lt;/code&gt; deletes the surrounding brackets using the surround plugin.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;gv&lt;/code&gt; restarts visual selection mode with the most recent visual selection&lt;/strong&gt;, however it's tripped by the now missing brackets and the selection is shifted to the right by one character i.e. length of first surrounding character, here the &lt;code&gt;(&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;h&lt;/code&gt; begins correcting the original position of the visual selection by  moving the right edge of visual selection leftwards by one character.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;o&lt;/code&gt; transports cursor to the other end of the visual selection.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;h&lt;/code&gt; moves the left edge of visual selection leftwards by one character.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Essentially this solution is based on &lt;code&gt;gv&lt;/code&gt; which reselects the most recent visual selection. You can adapt the rest of the key sequence to take care of any edge cases like if located at the end of line, or length of surrounding characters being more then 1 and uneven lengths, for e.g.  html tags like &lt;code&gt;&amp;lt;strong&amp;gt;&amp;lt;/strong&amp;gt;&lt;/code&gt; etc.&lt;/p&gt;&#xA;" OwnerUserId="397" LastEditorUserId="397" LastEditDate="2020-03-02T14:39:50.980" LastActivityDate="2020-03-02T14:39:50.980" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23071" PostTypeId="1" CreationDate="2020-03-02T14:47:55.537" Score="1" ViewCount="592" Body="&lt;p&gt;I have function to perform a git diff, after calling git diff I wish to emulate the following keypresses in the terminal window:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;G&lt;/code&gt; move to the end of the file&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;a&lt;/code&gt; append&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&amp;lt;cr&amp;gt;&lt;/code&gt; type q to quit the &quot;terminal scrolling mode&quot; then enter&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;gg&lt;/code&gt; return to the top of the file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function GitDiff()&#xA;  terminal git diff --word-diff %&#xA;  normal Gaq&amp;lt;Esc&amp;gt;gg&#xA;endfunction&#xA;:nmap &amp;lt;leader&amp;gt;t :call GitDiff()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However the keypresses dont seem to be executed as expected. I wonder if it needs a delay to wait for the terminal command to finish executing?&lt;/p&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-11-29T17:04:05.340" Title="NeoVim: Move the cursor after running a command in :terminal" Tags="|neovim|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="23072" PostTypeId="2" ParentId="23068" CreationDate="2020-03-02T15:02:15.377" Score="2" Body="&lt;p&gt;You're confusing &lt;code&gt;fileformat&lt;/code&gt; (dos or unix) and &lt;code&gt;fileencoding&lt;/code&gt; (utf-8, iso-8859-1) with &lt;code&gt;filetype&lt;/code&gt; (yaml, c, python, tex, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;++edit&lt;/code&gt;, the &lt;code&gt;:read&lt;/code&gt; command will set the former two (so you can read a Latin-1 file with CRLF line endings), but it won't trigger filetype detection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's hard to do so, since a lot of filetype detection depends on the file name and file extension and Vim will look at the buffer file name to get that information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming the purpose of using &lt;code&gt;:read&lt;/code&gt; is to prevent modifications to the original file, consider just opening the file with &lt;code&gt;:edit&lt;/code&gt; or &lt;code&gt;:view&lt;/code&gt; (so all the filetype logic is triggered) and then setting options to prevent that buffer from ever saving back to the original file again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See, for example, &lt;a href=&quot;https://vimhelp.org/windows.txt.html#special-buffers&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help special-buffers&lt;/code&gt;&lt;/a&gt;, which tells you how to configure a scratch buffer:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;scratch&lt;/strong&gt;: Contains text that can be discarded at any time. It is kept when closing the window, it must be deleted explicitly. Settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;    :setlocal buftype=nofile&#xA;    :setlocal bufhidden=hide&#xA;    :setlocal noswapfile&#xA;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;The buffer name can be used to identify the buffer, if you give it a meaningful name.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Another approach to consider (possibly to combine with some of the scratch buffer support) is to set the buffer filename using the &lt;code&gt;:file&lt;/code&gt; command (see &lt;a href=&quot;https://vimhelp.org/editing.txt.html#%3Afile_f&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :file_f&lt;/code&gt;&lt;/a&gt;), which you can use to tell Vim whenever the buffer is to be saved, you want it to try to write it to the file you specify instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using some of these settings together can help you get the desired effect on the buffer you're creating.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-02T15:02:15.377" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23073" PostTypeId="1" AcceptedAnswerId="23074" CreationDate="2020-03-02T21:31:45.527" Score="1" ViewCount="79" Body="&lt;p&gt;I enabled spell checking in a buffer with &lt;code&gt;set spell spelllang=en&lt;/code&gt; which works. If I save the session with &lt;code&gt;mksession!&lt;/code&gt; and later source it back with &lt;code&gt;vim -S Session.vim&lt;/code&gt;, spellchecking is no longer enabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I save spell checking an spell language in a Session file (and apply it)?&lt;/p&gt;&#xA;" OwnerUserId="11633" LastActivityDate="2020-03-03T00:30:16.813" Title="Remember spelling settings in session file" Tags="|spell-checking|sessions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23074" PostTypeId="2" ParentId="23073" CreationDate="2020-03-03T00:30:16.813" Score="1" Body="&lt;p&gt;The &lt;code&gt;spell&lt;/code&gt; and &lt;code&gt;spelllang&lt;/code&gt; options are local options and by default sessions only store global options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change this behavior by updating &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27sessionoptions%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;sessionoptions&lt;/code&gt;&lt;/a&gt; to also include &lt;code&gt;localoptions&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set sessionoptions+=localoptions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason why local options are typically not stored in a session file is that they're normally managed by per-filetype plugins, and those plug-ins will be reloaded when the session is restored. Not storing local options gives the plug-ins the opportunity to set options differently, which might be useful or relevant when restoring a session after upgrading plug-ins.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-03T00:30:16.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23075" PostTypeId="1" CreationDate="2020-03-03T01:27:10.093" Score="1" ViewCount="216" Body="&lt;p&gt;I recently bought a Windows 10 laptop, TravelMate P2410-G2-M.  The resolution is set to the native physical resolution of the display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, my Gvim text displays with some pixel columns/rows smeared over multiple display pixel column/rows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2w1ZE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2w1ZE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I identify fonts whose pixels map one-to-one with the pixels on the display?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above is a general question, but the specific system I'm using is configured as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Using Windows 10 and 64-bit Cygwin's X-windows, downloaded and installed circa start of 2020&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The above screen shot of bleeding pixels was using the Gvim option guifont=Lucida\ Console\ Regular\ 9&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7041" LastEditorUserId="7041" LastEditDate="2020-03-03T01:40:42.903" LastActivityDate="2024-03-12T12:07:05.897" Title="Choose Gvim font that maps pixel-to-pixel with display?" Tags="|gvim|font|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23076" PostTypeId="1" AcceptedAnswerId="23077" CreationDate="2020-03-03T03:17:27.220" Score="0" ViewCount="60" Body="&lt;p&gt;If I start with this file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;https://example.com&#xA;&amp;lt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and press &lt;code&gt;ddp&lt;/code&gt;, I expect to get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;https://example.com&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but instead I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;&amp;gt;&#xA;https://example.com&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-03-05T18:35:05.753" Title="Paste at cursor instead of below" Tags="|cut-copy-paste|cursor-movement|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23077" PostTypeId="2" ParentId="23076" CreationDate="2020-03-03T03:35:07.410" Score="0" Body="&lt;p&gt;Instead of &lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;d&lt;/kbd&gt;, can use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;D&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;d&lt;/kbd&gt;&lt;kbd&gt;End&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://fprintf.net/vimCheatSheet.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://fprintf.net/vimCheatSheet.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-03-03T03:35:07.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23078" PostTypeId="1" CreationDate="2020-03-03T06:17:44.153" Score="2" ViewCount="1166" Body="&lt;p&gt;I'm trying to use &lt;kbd&gt;Ctrl&lt;/kbd&gt; &lt;kbd&gt;w&lt;/kbd&gt; &lt;kbd&gt;+&lt;/kbd&gt; and &lt;kbd&gt;-&lt;/kbd&gt; to change my split width and height, but it's changing the font size instead. Any ideas about what's going wrong?&lt;/p&gt;&#xA;" OwnerUserId="27236" LastEditorUserId="10604" LastEditDate="2020-03-03T15:37:52.330" LastActivityDate="2020-11-28T17:03:45.340" Title="Ctrl w +/- not working as expected" Tags="|key-bindings|split|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23079" PostTypeId="2" ParentId="23078" CreationDate="2020-03-03T06:22:12.347" Score="2" Body="&lt;p&gt;You're probably pressing &lt;code&gt;Ctrl-W&lt;/code&gt;, &lt;code&gt;Ctrl-+&lt;/code&gt; and the terminal will catch &lt;code&gt;Ctrl-+&lt;/code&gt; and interpret that as a command to change the font size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just make sure you're releasing the &lt;code&gt;Ctrl&lt;/code&gt; key before you execute the second keystroke of the command: &lt;code&gt;Ctrl-W&lt;/code&gt;, then release &lt;code&gt;Ctrl&lt;/code&gt;, then press &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;-&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-03T06:22:12.347" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23080" PostTypeId="1" AcceptedAnswerId="23082" CreationDate="2020-03-03T06:32:07.370" Score="3" ViewCount="1256" Body="&lt;p&gt;When connected to a remote headless Linux server via SSH, I want to be able to do 3 things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;select text using the mouse and copy the selection into my local X clipboard &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;paste from local X clipboard into the remote document I'm editing&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;position editing cursor using the mouse (&lt;code&gt;:set mouse=a&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Please suggest the best way to achieve all three of these features together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's where I am in my attempts. I'm running KDE and my terminal is Konsole. I get the first two things &quot;free&quot; with Konsole (it just works) but I dont' get the last feature, which would have to be enabled in vim (or neovim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I invoke &lt;code&gt;:set mouse=a&lt;/code&gt; to get that last feature, I lose both of the other two. My goal is to have all 3 features at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my research I checked this question: &lt;a href=&quot;https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim&quot; title=&quot;How can I copy text to the system clipboard from Vim? - Vi and Vim Stack Exchange&quot;&gt;How can I copy text to the system clipboard from Vim?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My situation bumps into every gotcha listed in that question:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;the remote system is not running X. It is a headless Linux server.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;the CentOS &lt;code&gt;vim&lt;/code&gt; package is compiled with &quot;-clipboard&quot;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I cannot use X11Forwarding with SSH (due to policy and due to remote system not having X)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As far as I know, I cannot use scp to edit files. I have to have root permissions to edit many files, but I cannot make an ssh connection as root (by policy / sshd_config settings on remote system).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;the last option suggested there is &lt;code&gt;neovim&lt;/code&gt; which is available for me to use. But again, the remote system doesn't have X. However, I understand I may be able to use tmux, but haven't gotten that to work yet.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What is the usual way someone would achieve what I'm trying to do?&lt;/strong&gt; Are there solutions I have overlooked?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the best option is neovim + tmux, how do I get that to work? Should I use one of these?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/roxma/vim-tmux-clipboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;roxma/vim-tmux-clipboard: seamless integration for vim and tmux's clipboard&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/cazador481/fakeclip.neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;cazador481/fakeclip.neovim&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="27235" LastActivityDate="2020-03-03T06:56:00.380" Title="copy-paste selection locally when editing files on remote headless server" Tags="|neovim|os-clipboard|mouse|ssh|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23081" PostTypeId="2" ParentId="23075" CreationDate="2020-03-03T06:34:15.833" Score="0" Body="&lt;p&gt;Normally in Windows you should specify your font using separate fields for the font face, height and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, perhaps this will work better:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Lucida_Console:h9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/gui.txt.html#E244&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help E244&lt;/code&gt;&lt;/a&gt; for the details of the fields you can set for the font.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, take a look at the &lt;code&gt;q&lt;/code&gt; parameter, for font quality, which includes settings such as PROOF, DRAFT, ANTIALIASED, NONANTIALIASED, or CLEARTYPE. Perhaps using a NONANTIALIASED font quality is what you're after?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, consider using a font picker, which you can launch with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set guifont=*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might be able to tweak details of the font in the font dialog and it's possible that you'll get a preview of what the font will look like in that dialog too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you're happy with a selection, you can query &lt;code&gt;:set guifont?&lt;/code&gt; to save that selection to your vimrc file.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-03T06:34:15.833" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="23082" PostTypeId="2" ParentId="23080" CreationDate="2020-03-03T06:56:00.380" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I cannot use X11Forwarding with SSH (due to policy and due to remote system not having X)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's a very restrictive one...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you don't need an X11 server running at your remote machine. All you need is the X11 libraries installed. You also would need a build of Vim that has &lt;code&gt;+clipboard&lt;/code&gt; feature, which you can typically find in a &lt;code&gt;gvim&lt;/code&gt; binary if one is installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a &lt;code&gt;gvim&lt;/code&gt; binary available, you can use &lt;code&gt;gvim -v&lt;/code&gt; to start it in Vim mode, meaning it will run in the terminal and not use X11 forwarding. But it will still be able to use X11 for the clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some distributions also ship a &lt;code&gt;vimx&lt;/code&gt; binary which doesn't include GUI support but do include &lt;code&gt;+clipboard&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you &lt;em&gt;were&lt;/em&gt; able to use SSH with X11 forwarding and you &lt;em&gt;had&lt;/em&gt; a gvim or vimx binary on your server, then all you would need would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set mouse=a&#xA;set mousemodel=extend&#xA;set clipboard=unnamed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;mousemodel&lt;/code&gt; one is the default, and the &lt;code&gt;clipboard&lt;/code&gt; setting is so that Vim will always sync yanks and pastes with the X11 selection (a.k.a &quot;primary&quot;; use &lt;code&gt;unnamedplus&lt;/code&gt; if you prefer to use the X11 &quot;clipboard&quot; instead.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at the help for these options if you plan to employ them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using X11 forwarding also might present some problems if you're running Vim as root under sudo, since sometimes X11 forwarding will break under that setup (xauth token needs to be forwarded.) It's possible to set up sudo so that it works, but you might need to spend even more time testing that and researching it to make all of it works seamlessly...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another approach to keep both &lt;code&gt;mouse=a&lt;/code&gt; &lt;em&gt;and&lt;/em&gt; copy and paste from your terminal is to look into your terminal support for bypassing mouse capture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most terminal emulators will allow mouse capture by the application running on the terminal, but they'll also bypass it if you make a selection while holding one (or more?) of the modifier keys: Shift, Ctrl or Alt. Perhaps try that on Konsole and see if that works? That way you still keep &lt;code&gt;mouse=a&lt;/code&gt;, but you're able to use Konsole to copy &amp;amp; paste when needed, while not depending on X11 forwarding for clipboard synchronization.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-03T06:56:00.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23084" PostTypeId="1" CreationDate="2020-03-03T09:40:00.960" Score="1" ViewCount="47" Body="&lt;p&gt;I cannot for the love of me figure out the configuration needed to use &lt;a href=&quot;https://github.com/zefei/vim-wintabs-powerline&quot; rel=&quot;nofollow noreferrer&quot;&gt;wintabs powerline&lt;/a&gt; in &lt;a href=&quot;https://github.com/zefei/vim-wintabs&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim wintabs&lt;/a&gt;. Please help me. I want to make my vim look beautiful.&lt;/p&gt;&#xA;" OwnerUserId="27236" LastActivityDate="2020-03-03T09:40:00.960" Title="How to use powerline fonts in wintab" Tags="|vimrc|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23085" PostTypeId="1" CreationDate="2020-03-03T14:40:55.833" Score="5" ViewCount="407" Body="&lt;p&gt;I'm trying to make a syntax file for &lt;a href=&quot;https://raku.org/&quot; rel=&quot;noreferrer&quot;&gt;Raku&lt;/a&gt;. The major challenge I'm running into is that I have no automated means to test that my highlighting works as expected. I have to keep another tab open, switch to it, source the syntax file, and then visually inspect the highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like some way to specify what I want the highlighting to look like and then run an automated test to verify that a syntax file does or does not produce the expected results.&lt;/p&gt;&#xA;" OwnerUserId="22268" LastActivityDate="2020-03-03T14:40:55.833" Title="How can I test and debug my syntax files?" Tags="|syntax-highlighting|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23086" PostTypeId="2" ParentId="23026" CreationDate="2020-03-03T15:39:30.277" Score="2" Body="&lt;p&gt;As mentioned &lt;a href=&quot;https://vi.stackexchange.com/questions/23026/why-wont-vi-recognize-html#comment41779_23026&quot;&gt;by Christian Brabandt&lt;/a&gt;, the OP has &lt;a href=&quot;https://vi.stackexchange.com/questions/23026/why-wont-vi-recognize-html#comment41794_23026&quot;&gt;small vim&lt;/a&gt;. The solution is to &lt;a href=&quot;https://vi.stackexchange.com/questions/23026/why-wont-vi-recognize-html#comment41795_23026&quot;&gt;install the vim package&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One can usually tell the difference with &lt;code&gt;vim --version&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-03-03T15:39:30.277" CommentCount="0" CommunityOwnedDate="2020-03-03T15:39:30.277" ContentLicense="CC BY-SA 4.0" />
  <row Id="23087" PostTypeId="1" AcceptedAnswerId="23104" CreationDate="2020-03-03T16:12:04.927" Score="1" ViewCount="202" Body="&lt;p&gt;I use a custom docker container to build my project so my &quot;make&quot; command is actually &lt;code&gt;docker run --rm -v $(pwd):/src container make $arg&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to type &lt;code&gt;:make $arg&lt;/code&gt; in command mode and have it trigger the docker container with the argument.&lt;/p&gt;&#xA;" OwnerUserId="22251" LastEditorUserId="1841" LastEditDate="2020-03-05T09:23:21.513" LastActivityDate="2020-03-05T09:23:21.513" Title="How do I remap the :make command to run a docker container?" Tags="|makeprg|user-commands|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23089" PostTypeId="1" CreationDate="2020-03-03T17:23:14.883" Score="1" ViewCount="81" Body="&lt;p&gt;I have next files in the directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls -1 file_*&#xA;&#xA;file_1&#xA;file_101&#xA;file_2&#xA;file_202&#xA;file_3&#xA;file_4&#xA;file_5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;strong&gt;Vim&lt;/strong&gt; I want to have these files in a numerically ordered list, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['file_1', 'file_2', 'file_3', 'file_4', 'file_5', 'file_101', 'file_202']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;glob()&lt;/code&gt; function returns this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo glob('file_*', 0, 1)&#xA;&#xA;&quot; Result&#xA;['file_1', 'file_101', 'file_2', 'file_202', 'file_3', 'file_4', 'file_5']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have found a workaround &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Compare(i1, i2) &#xA;    let l:f = str2nr(matchstr(a:i1, '[0-9]\+'))&#xA;    let l:s = str2nr(matchstr(a:i2, '[0-9]\+'))&#xA;    return l:f == l:s ? 0 : l:f &amp;gt; l:s ? 1 : -1&#xA;endfunction&#xA;&#xA;echo sort(glob('file_*', 0, 1), 'Compare')&#xA;&#xA;&quot; Result&#xA;['file_1', 'file_2', 'file_3', 'file_4', 'file_5', 'file_101', 'file_202']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but interested, is it possible to force &lt;code&gt;glob()&lt;/code&gt; function to work as I want?&lt;/p&gt;&#xA;" OwnerUserId="14024" LastActivityDate="2020-03-03T17:23:14.883" Title="How to force glob() to make result in numerical order?" Tags="|sort|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23090" PostTypeId="1" AcceptedAnswerId="23095" CreationDate="2020-03-03T18:36:09.867" Score="2" ViewCount="200" Body="&lt;p&gt;I'm looking for a way to make a line be &lt;em&gt;only logically&lt;/em&gt; broken at the end of the available space. Here's an example: let's suppose I have a really long line (i.e. a string without any &lt;code&gt;\n&lt;/code&gt; in it), and to render it on the screen, ViM must split it, so, by turning on line numbers I see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1: This is the beginning of my very very very long line that does not fit &#xA;ViM's window and therefore it must be split into two lines.&#xA;2: And this is another line of text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, if I'm in normal mode, I can move from line 1 to line 2 by using &lt;code&gt;j&lt;/code&gt;, but I have no ways to move from the word &quot;beginning&quot; to the word &quot;therefore&quot;, apart from &lt;code&gt;gj&lt;/code&gt; which I find slow. I tried to remap &lt;code&gt;j&lt;/code&gt; to &lt;code&gt;gj&lt;/code&gt;, only for the filetypes I'm interested in (I wouldn't ever do this with C source files for example), but this gives me another issue: relative numbers do not work anymore. If I'm on line 1 and type &lt;code&gt;d1j&lt;/code&gt; only the first two &quot;logical lines&quot; are deleted (which in my example they correspond to the whole line 1). So I'm looking for a way to move inside the lines pretending they're logical lines (i.e. by &lt;code&gt;gj&lt;/code&gt;ing  or &lt;code&gt;gk&lt;/code&gt;ing) and work with the physical lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried with the &lt;code&gt;textwidth&lt;/code&gt; option, but it physically breaks the lines, so it's not exactly what I'm looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="22833" LastEditorUserId="22833" LastEditDate="2020-03-05T14:27:30.987" LastActivityDate="2020-03-05T14:27:30.987" Title="Break logical lines" Tags="|multiple-lines|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="23091" PostTypeId="1" AcceptedAnswerId="23097" CreationDate="2020-03-03T16:43:49.423" Score="1" ViewCount="558" Body="&lt;p&gt;When using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;w&lt;/kbd&gt; &lt;kbd&gt;s&lt;/kbd&gt; the window is split horizontally and the current buffer is loaded. Why should I open two windows to edit the same buffer?&lt;/p&gt;&#xA;" OwnerUserId="27247" OwnerDisplayName="dgruending" LastEditorUserId="11357" LastEditDate="2020-03-23T10:21:53.330" LastActivityDate="2020-03-23T10:21:53.330" Title="What is the use case of vim Ctrl+w s?" Tags="|window-management|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23092" PostTypeId="2" ParentId="23091" CreationDate="2020-03-03T16:59:44.387" Score="7" Body="&lt;p&gt;I tend to use nano much more frequently than vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An editor-agnostic answer: There have been more than a few times that I needed to edit a bash script that is hundreds of lines long, and one section of the script refers to or otherwise impacts another section. It is often helpful to have both sections visible at the same time and to be able to independently scroll between the reference window and the window being actively edited.&lt;/p&gt;&#xA;" OwnerDisplayName="RudyB" LastActivityDate="2020-03-03T18:54:20.593" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23093" PostTypeId="1" AcceptedAnswerId="23094" CreationDate="2020-03-04T01:28:45.850" Score="0" ViewCount="168" Body="&lt;p&gt;If I have a file like this in Insert Mode (pipe is cursor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sunday&#xA;|&#xA;Monday&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can press Backspace or Delete to remove the empty line. However in Normal&#xA;Mode, neither of those work. I have been working around this by using &lt;code&gt;dd&lt;/code&gt;, but&#xA;is a better option available?&lt;/p&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-03-04T03:48:44.567" Title="Normal mode Backspace and Delete" Tags="|cut-copy-paste|insert-mode|normal-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23094" PostTypeId="2" ParentId="23093" CreationDate="2020-03-04T03:48:44.567" Score="1" Body="&lt;p&gt;Another option is &lt;code&gt;J&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Join [count] lines, with a minimum of two lines. Remove the indent and insert&#xA;  up to two spaces.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/change.html#J&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://vimdoc.sourceforge.net/htmldoc/change.html#J&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-03-04T03:48:44.567" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23095" PostTypeId="2" ParentId="23090" CreationDate="2020-03-04T05:21:26.353" Score="4" Body="&lt;p&gt;I can think of two solutions to this:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;1:  Use normal mode mappings only; do not use an operator-pending mode mapping&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As @D.Ben Knoble mentioned in his comment, instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap j gj&#xA;noremap k gk &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap j gj&#xA;nnoremap k gk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The former maps &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; in normal, visual, and operator-pending modes, while the latter maps &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; only in normal mode. With the latter mappings, after an operator (such as &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;, or &lt;code&gt;y&lt;/code&gt;), &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; remain as-is.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;2: Use an expression mapping to check if a count is given&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;expr&amp;gt; j v:count ? 'j' : 'gj'&#xA;noremap &amp;lt;expr&amp;gt; k v:count ? 'k' : 'gk'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These check if a count has been supplied. If there is a count, &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt; is used; otherwise &lt;code&gt;gj&lt;/code&gt; or &lt;code&gt;gk&lt;/code&gt; is used. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this way, &lt;code&gt;1j&lt;/code&gt; or &lt;code&gt;1k&lt;/code&gt; moves up or down a whole line, while &lt;code&gt;j&lt;/code&gt; or &lt;code&gt;k&lt;/code&gt; moves up or down a screen line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information, see &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h map-modes&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h map-expression&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h count-variable&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21495" LastActivityDate="2020-03-04T05:21:26.353" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23096" PostTypeId="2" ParentId="22995" CreationDate="2020-03-04T05:40:10.253" Score="0" Body="&lt;p&gt;I have a workaround to quickly close accidentally creating new tab by adding right click to close it though I don't like this workaround.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;RightMouse&amp;gt; :tabclose&amp;lt;CR&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Finally, I found this is related to the problem of terminal application (KDE konsole). After I switch to other terminal application, simple terminal, the problem is gone.&lt;/p&gt;&#xA;" OwnerUserId="27122" LastEditorUserId="27122" LastEditDate="2020-03-06T06:31:19.660" LastActivityDate="2020-03-06T06:31:19.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23097" PostTypeId="2" ParentId="23091" CreationDate="2020-03-04T08:49:50.550" Score="3" Body="&lt;p&gt;Having multiple &lt;em&gt;views&lt;/em&gt; of the same buffer allows you to quickly compare or copy-and-paste without moving back and forth, as @RudyB's answer explains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another use case is the opening of another file; of course, with plain Vim commands, you can achieve this by using &lt;code&gt;:split&lt;/code&gt; instead of &lt;code&gt;:edit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, many people have plugins (that provide most recently used files, a speeddial, quick addressing within the current project, access to remote files, and so on), and not all of them have the functionality to open that file in a split (or it might be there, but using an obscure mapping, or inconsistent mappings, as Vim doesn't have a good precedence for this functionality to base custom mappings on). Opening files in the current window is the default functionality. So, you'll just first create the target window, and then invoke the plugin to jump to another file. Splitting the current window and duplicating the displayed buffer contents is the easiest way (and avoids the creation of a new empty buffer, as &lt;code&gt;CTRL-W n&lt;/code&gt; would do).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this approach can also be used for splitting to a new tab page (which even fewer plugins support directly): You just need to remember the Vim command to split to a new tab page (&lt;code&gt;:tab split&lt;/code&gt;, but many have a custom mapping for that).&lt;/p&gt;&#xA;" OwnerUserId="970" LastActivityDate="2020-03-04T08:49:50.550" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23098" PostTypeId="1" AcceptedAnswerId="23099" CreationDate="2020-03-04T10:22:20.813" Score="2" ViewCount="579" Body="&lt;p&gt;I made up keybindings to compile &lt;code&gt;tex&lt;/code&gt; file in Vim but sometimes it doesn't work because the file is identified as a &lt;code&gt;plaintex&lt;/code&gt; file. I'd like to understand the difference. I have also noticed that this always happens when creating a new file with &lt;code&gt;vim test.tex&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user27022" LastActivityDate="2020-03-05T12:55:59.467" Title="Difference between tex and plaintex Vim file type" Tags="|filetype-tex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23099" PostTypeId="2" ParentId="23098" CreationDate="2020-03-04T10:37:53.607" Score="4" Body="&lt;p&gt;Take a look at this question and its answers on &lt;a href=&quot;https://tex.stackexchange.com/questions/97520/what-is-plain-tex/&quot;&gt;TeX.SX&lt;/a&gt; to understand the difference between TeX and plainTeX. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can make a single keybinding working for &lt;code&gt;tex&lt;/code&gt; and &lt;code&gt;plaintex&lt;/code&gt; or you can force Vim to interpret each &lt;code&gt;.tex&lt;/code&gt; file as a &lt;code&gt;tex&lt;/code&gt; file.  According to &lt;code&gt;:help tex_flavor&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If the first line of a *.tex file has the form&#xA;        %&amp;amp;&amp;lt;format&amp;gt;&#xA;then this determined the file type:  plaintex (for plain TeX), context (for&#xA;ConTeXt), or tex (for LaTeX).  Otherwise, the file is searched for keywords to&#xA;choose context or tex.  If no keywords are found, it defaults to plaintex.&#xA;You can change the default by defining the variable g:tex_flavor to the format&#xA;(not the file type) you use most.  Use one of these:&#xA;        let g:tex_flavor = &quot;plain&quot;&#xA;        let g:tex_flavor = &quot;context&quot;&#xA;        let g:tex_flavor = &quot;latex&quot;&#xA;Currently no other formats are recognized.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:let g:tex_flavor = &quot;latex&quot;&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt; will do the work.&lt;/p&gt;&#xA;" OwnerDisplayName="user27259" LastEditorDisplayName="user27259" LastEditDate="2020-03-05T12:55:59.467" LastActivityDate="2020-03-05T12:55:59.467" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23100" PostTypeId="2" ParentId="22723" CreationDate="2020-03-04T12:53:13.647" Score="1" Body="&lt;p&gt;You can start with the following (add it to you vimrc)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! MyComment(text)&#xA;    let width = 80&#xA;    let text = printf(&quot; %s &quot;, a:text)&#xA;    let chrome = repeat('#', width/2 - strdisplaywidth(text)/2)&#xA;    call setline('.', chrome . text . chrome)&#xA;endfunc&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;c :call MyComment(input(&quot;Header: &quot;))&amp;lt;CR&amp;gt;&#xA;&#xA;nnoremap &amp;lt;leader&amp;gt;d :call MyComment(getline('.'))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I believe you will be able to tune it to get a line with all &lt;code&gt;#&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Xvxms.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Xvxms.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-03-04T12:53:13.647" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23101" PostTypeId="1" AcceptedAnswerId="23102" CreationDate="2020-03-04T15:02:47.090" Score="2" ViewCount="497" Body="&lt;p&gt;I deleted lines in a file with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^\s*key3/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and now have a file like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;entry{entryname1,&#xA;    key1 = {text},&#xA;    key2 = {text},&#xA;}&#xA;&#xA;entry{entryname2,&#xA;    anotherkey = {text},&#xA;    yetanotherkey = {text}&#xA;}&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to delete the trailing comma after key2 (the name of the last key can change) on multiple lines in the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command (or multiple commands) that does the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for each line with the pattern ^}$:&#xA;  if the last character in the previous line is a comma:&#xA;    delete that comma&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27263" LastActivityDate="2020-03-07T15:43:36.967" Title="Delete specific character on previous line" Tags="|cut-copy-paste|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23102" PostTypeId="2" ParentId="23101" CreationDate="2020-03-04T15:35:10.233" Score="2" Body="&lt;p&gt;You can use &lt;code&gt;:g&lt;/code&gt; again with a regular expression, but use a line offset of -1 to have the global command act on the lines above the match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can use that to apply a &lt;code&gt;:s&lt;/code&gt; command to remove any trailing commas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^{$/-1s/,$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These offsets are explained in &lt;a href=&quot;https://vimhelp.org/usr_10.txt.html#10.3&quot; rel=&quot;nofollow noreferrer&quot;&gt;section 10.3&lt;/a&gt; of the Vim manual:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;ADD AND SUBTRACT&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;There is a slight error in the above command: If the title of the next chapter&#xA;  had included &quot;grey&quot; it would be replaced as well.  Maybe that's what you wanted, but what if you didn't?  Then you can specify an offset.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;To search for a pattern and then use the line above it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;/Chapter/-1&#xA;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Documentation under &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#cmdline-ranges&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help cmdline-ranges&lt;/code&gt;&lt;/a&gt; has more advanced examples. Even though the discussion is mainly around ranges preceding a command, many of those expressions will work after &lt;code&gt;:g&lt;/code&gt; as well.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-04T15:35:10.233" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23103" PostTypeId="2" ParentId="23101" CreationDate="2020-03-04T15:38:01.477" Score="3" Body="&lt;p&gt;I can think of a number of ways to make this work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First would be only the &lt;code&gt;key2&lt;/code&gt; case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global/key2/substitute/,$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, in the general case, I believe you want to do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global/^}$/-substitute/,$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:global&lt;/code&gt; can be abbreviated to &lt;code&gt;:g&lt;/code&gt; and &lt;code&gt;:substitute&lt;/code&gt; to &lt;code&gt;:s&lt;/code&gt;. &lt;code&gt;-&lt;/code&gt; in the range here is equivalent to &lt;code&gt;-1&lt;/code&gt;, as explained at &lt;code&gt;:help [range]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's one other way to note: &lt;code&gt;:g/^}$/-normal! 0f,x&lt;/code&gt; should work if there's only one comma in the lines you want to modify, and none in the lines you want to leave alone—this works because &lt;code&gt;normal!&lt;/code&gt; will stop if any of the given commands fail. Since &lt;code&gt;f,&lt;/code&gt; will fail when there's no comma, &lt;code&gt;x&lt;/code&gt; will never be executed.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-03-04T15:38:01.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23104" PostTypeId="2" ParentId="23087" CreationDate="2020-03-04T15:47:52.423" Score="3" Body="&lt;p&gt;Using &lt;code&gt;'makeprg'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set makeprg=docker\ run\ --rm\ -v\ $(pwd):/src\ container\ make&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the &lt;code&gt;\&lt;/code&gt; are necessary for &lt;code&gt;set&lt;/code&gt; to keep the spaces; single quoting won't work here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can run &lt;code&gt;:make [arguments]&lt;/code&gt; and have it expanded to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!docker run --rm -v $(pwd):/src container make [arguments] {shellpipe} {errorfile}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(see &lt;code&gt;:help :make&lt;/code&gt; and scroll down a bit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a useful general technique: many languages have default &lt;code&gt;'makeprg'&lt;/code&gt; that can be set using the command &lt;code&gt;:compiler&lt;/code&gt;—these usually also set the &lt;code&gt;'errorformat'&lt;/code&gt; option so that the quickfix list is presented properly (I don't know how to do that for Docker builds, but the documentation is extensive). If you like this idea, consider creating &lt;code&gt;~/.vim/compiler/docker.vim&lt;/code&gt; (or similar) with the contents&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if exists(&quot;current_compiler&quot;)&#xA;  finish&#xA;endif&#xA;let current_compiler = &quot;docker&quot;&#xA;&#xA;&quot; older Vim always used :setlocal&#xA;if exists(&quot;:CompilerSet&quot;) != 2&#xA;  command -nargs=* CompilerSet setlocal &amp;lt;args&amp;gt;&#xA;endif&#xA;&#xA;CompilerSet makeprg=docker\ run\ --rm\ -v\ $(pwd):/src\ container\ make&#xA;&quot; CompilerSet errorfromat=...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can do &lt;code&gt;:compiler docker&lt;/code&gt; followed by &lt;code&gt;:make&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More docs at &lt;code&gt;:help :compiler&lt;/code&gt; and &lt;code&gt;:help :write-compiler-plugin&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-03-04T15:47:52.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23105" PostTypeId="2" ParentId="23071" CreationDate="2020-03-04T16:11:04.410" Score="1" Body="&lt;p&gt;Terminal buffer is not modifiable while the child process is running. You must send keys instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With Neovim you have to use &lt;code&gt;chansend()&lt;/code&gt;. Assuming the terminal runs in the current buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call chansend(&amp;amp;channel, &quot;q\r&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-03-04T16:11:04.410" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23106" PostTypeId="2" ParentId="23101" CreationDate="2020-03-04T21:57:37.760" Score="2" Body="&lt;p&gt;I interpret your question thus: wherever in the file you have comma followed by new-line that contains only }, delete all such commas.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/,\n}$/\r}/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;\n in the pattern identifies a line break, \r in replacement inserts a line break. I've no idea why they should be different.&lt;/p&gt;&#xA;" OwnerUserId="5220" LastEditorUserId="343" LastEditDate="2020-03-07T15:43:36.967" LastActivityDate="2020-03-07T15:43:36.967" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23107" PostTypeId="1" AcceptedAnswerId="23129" CreationDate="2020-03-04T22:44:18.513" Score="1" ViewCount="106" Body="&lt;p&gt;In macOS Catalina, from Terminal, bash, vim 8.1, I launch &lt;code&gt;vi &amp;lt;(command1)&lt;/code&gt; to see the output of a command.&lt;br&gt;&#xA;From another terminal, I launch another &lt;code&gt;vi &amp;lt;(command2)&lt;/code&gt;.&lt;br&gt;&#xA;Then vim complains that it's already found a swap file of that name.&lt;br&gt;&#xA;(In the process listing, all commands appear as &lt;code&gt;vi /dev/fd/63&lt;/code&gt;.  Always 63.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Linux, the swapfiles are named differently, e.g. &lt;code&gt;'pipe:[267258].swp'&lt;/code&gt; for some random number 267258.&lt;br&gt;&#xA;Can macOS's vim do this too, instead of always using &lt;code&gt;63.swp&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="12809" LastActivityDate="2020-03-07T22:03:23.787" Title="simultaneous &quot;vi &lt;(command)&quot; in macOS" Tags="|macos|swap-file|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23108" PostTypeId="2" ParentId="22723" CreationDate="2020-03-05T10:27:51.790" Score="0" Body="&lt;p&gt;Here's an alternative approach:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Doing it manually with built in commands&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To convert a line that contains just your title you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Run the command &lt;code&gt;:center&lt;/code&gt; to move the title to the centre of the line.*&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To add the &lt;code&gt;#&lt;/code&gt; characters type the following normal mode commands:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;h&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;&lt;kbd&gt;0&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;#&lt;/kbd&gt;&lt;kbd&gt;y&lt;/kbd&gt;&lt;kbd&gt;w&lt;/kbd&gt;&lt;kbd&gt;A&lt;/kbd&gt;&lt;kbd&gt;Space&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is not self explanatory, just try typing them in!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* Vim calculates the position based on your &lt;code&gt;'textwidth'&lt;/code&gt; setting, using a value of &lt;code&gt;80&lt;/code&gt; if &lt;code&gt;'textwidth'&lt;/code&gt; is set to 0. You can pass in a different value if necessary: &lt;code&gt;:center 72&lt;/code&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To add an &quot;end of section&quot; line below the cursor, you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Type in the normal mode command to add a line containing a single &lt;code&gt;#&lt;/code&gt; character &lt;kbd&gt;o&lt;/kbd&gt;&lt;kbd&gt;#&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run the command &lt;code&gt;:right&lt;/code&gt; to right align it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fill in the entire line with &lt;code&gt;#&lt;/code&gt; characters with the normal mode commands: &lt;kbd&gt;V&lt;/kbd&gt;&lt;kbd&gt;r&lt;/kbd&gt;&lt;kbd&gt;#&lt;/kbd&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Creating command-line commands&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can easily convert these into commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command StartComment center | execute &quot;normal! hhv0r#ywA \&amp;lt;Esc&amp;gt;p&quot;&#xA;:command EndComment execute &quot;normal! o#&quot; | right | normal! Vr#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that we use &lt;code&gt;:execute&lt;/code&gt; in the first command in order to &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Anorm&quot; rel=&quot;nofollow noreferrer&quot;&gt;more easily include an &lt;kbd&gt;Esc&lt;/kbd&gt; keypress&lt;/a&gt;, and we use it again in the second line in order to end insert mode so we can continue with another ex command.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Creating normal mode mappings&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;And it's even easier to create mappings instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;c :center&amp;lt;CR&amp;gt;hhv0r#ywA &amp;lt;Esc&amp;gt;p&#xA;:nnoremap &amp;lt;leader&amp;gt;e o#&amp;lt;Esc&amp;gt;:right&amp;lt;CR&amp;gt;Vr#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Extra credit&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Eagle-eyed readers might have spotted that depending on whether your title has an odd or even number of characters, the resulting comment will end in the 79th or 80th column. If this is an issue, here's a slightly more complicated mapping that always creates an exactly 80 character heading by first creating an entire line of 80 &lt;code&gt;#&lt;/code&gt; characters and then moving the title into the middle of that line with &lt;a href=&quot;http://vimhelp.org/visual.txt.html#blockwise-visual&quot; rel=&quot;nofollow noreferrer&quot;&gt;blockwise visual mode&lt;/a&gt; yank/put:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;leader&amp;gt;c :center&amp;lt;CR&amp;gt;o#&amp;lt;Esc&amp;gt;:right&amp;lt;CR&amp;gt;Vr#kA &amp;lt;Esc&amp;gt;v^hyj1vpkdd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's left as an exercise to the reader to convert this into a command-line command.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Watch out for &lt;code&gt;'noexpandtab'&lt;/code&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Note that none of the above will work well if you have &lt;code&gt;'expandtab'&lt;/code&gt; set, because each tab will be replaced with a single &lt;code&gt;#&lt;/code&gt; character. But you're writing Python, so &lt;em&gt;of course&lt;/em&gt; you're indenting with the PEP 8 mandated four spaces, so this won't be an issue!&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-03-05T10:48:08.800" LastActivityDate="2020-03-05T10:48:08.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23109" PostTypeId="2" ParentId="23076" CreationDate="2020-03-05T18:27:57.680" Score="1" Body="&lt;p&gt;Like husB commented you have to use a characterwise motion.&#xA;Note that &lt;code&gt;D&lt;/code&gt; deletes from the current cursor position to the end of the line and doesn't delete the line itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could overwrite what &lt;code&gt;dd&lt;/code&gt; does but I would recommend you map your expected behaviour to a new command, &lt;code&gt;&amp;lt;leader&amp;gt;d&lt;/code&gt; in the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nmap &amp;lt;leader&amp;gt;d 0D&quot;_dd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command does the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt;: go to the beginning of the line&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; includes whitespace, use &lt;code&gt;^&lt;/code&gt; or &lt;code&gt;_&lt;/code&gt; instead to go to the first non-blank character&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;D&lt;/code&gt;: cut characterwise to the end of the line&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;also includes whitespace, can be replaced by &lt;code&gt;dg_&lt;/code&gt; to cut to the last non-blank character instead, see &lt;a href=&quot;https://vi.stackexchange.com/questions/3308/go-to-last-non-whitespace-character-of-previous-next-line&quot;&gt;this answer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;_&lt;/code&gt; is the &quot;black hole register&quot; to keep your default register (used by &lt;code&gt;p&lt;/code&gt;) clean&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;dd&lt;/code&gt;: cuts the now empty line into &lt;code&gt;&quot;_&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="27263" LastEditorUserId="27263" LastEditDate="2020-03-05T18:35:05.753" LastActivityDate="2020-03-05T18:35:05.753" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23110" PostTypeId="1" AcceptedAnswerId="23111" CreationDate="2020-03-05T18:42:50.587" Score="2" ViewCount="2222" Body="&lt;p&gt;When pasting text into Vim without tmux, it shows a normal paste:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. &#xA;&#xA;Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. &#xA;&#xA;Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, when using Vim inside tmux, the indentation breaks and the paste shows like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. &#xA;&#xA;  Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. &#xA;&#xA;    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How can this be solved?&lt;/p&gt;&#xA;" OwnerUserId="21996" LastEditorUserId="21996" LastEditDate="2024-04-04T20:30:06.207" LastActivityDate="2024-04-04T20:30:06.207" Title="Pasting text on Vim inside tmux breaks indentation" Tags="|indentation|cut-copy-paste|terminal|insert-mode|tmux|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23111" PostTypeId="2" ParentId="23110" CreationDate="2020-03-05T20:14:54.613" Score="5" Body="&lt;p&gt;So using &lt;code&gt;:set paste&lt;/code&gt; first can resolv the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as you asked here is my tmuxrc but it is very short : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:~$ cat ~/.tmuxrc&#xA;set -g status-utf8 on&#xA;:~$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I don't think it is special&lt;/p&gt;&#xA;" OwnerUserId="27161" LastEditorUserId="27161" LastEditDate="2020-03-05T20:35:11.370" LastActivityDate="2020-03-05T20:35:11.370" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23114" PostTypeId="1" AcceptedAnswerId="23115" CreationDate="2020-03-06T06:36:31.037" Score="1" ViewCount="714" Body="&lt;p&gt;I'm trying to move my work from vim8 to NeoVim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got an issue in NeoVim. The first 5 function keys &lt;code&gt;F1, F2, ... F5&lt;/code&gt; are automatically maped to letter &lt;code&gt;'A' 'B' 'C' 'D' 'E'&lt;/code&gt; and cannot be re-mapped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This issue only occurs on terminal nvim. In &lt;strong&gt;nvim-qt&lt;/strong&gt;, there is no problem. And the &lt;strong&gt;vim8&lt;/strong&gt; in same environment works well. I didn't install any plugin or put any script in init.vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does Anybody know how to fix it or if it is a known issue of nvim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The nvim I indstalled is verion v0.5.0-404-g49cd750d6 which was downloaded from &lt;a href=&quot;https://github.com/neovim/neovim/releases&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neovim/neovim/releases&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below picture is the output that I tried to click from &lt;code&gt;F1&lt;/code&gt; to &lt;code&gt;F12&lt;/code&gt; in INSERT mod.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/P1NDq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/P1NDq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26468" LastActivityDate="2020-03-06T06:40:38.093" Title="Function Keys In NeoVim are maped to letter keys automatically" Tags="|neovim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23115" PostTypeId="2" ParentId="23114" CreationDate="2020-03-06T06:40:38.093" Score="1" Body="&lt;p&gt;It is a known bug, I created an issue sometime ago, check &lt;a href=&quot;https://github.com/neovim/neovim/issues/11773&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neovim/neovim/issues/11773&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-03-06T06:40:38.093" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23116" PostTypeId="1" AcceptedAnswerId="24774" CreationDate="2020-03-06T10:42:13.937" Score="0" ViewCount="578" Body="&lt;p&gt;I am using iTerm2, which is working well for me. I've been using VIM for almost 2 years now, with MacVim. Then suddenly I became curious whether my coding experience will improve when I use terminal inside VIM, rather than using 2 separate apps.&lt;/p&gt;&#xA;" OwnerUserId="26719" LastActivityDate="2020-04-22T15:43:07.483" Title="Whats the benefit of using :term inside Vim compared to a separate terminal emulator app?" Tags="|gvim|terminal|macvim|bash|iterm2|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23117" PostTypeId="2" ParentId="18344" CreationDate="2020-03-06T14:56:54.437" Score="2" Body="&lt;p&gt;I had exactly the same problem as yours, which annoyed me years. Now I add a &lt;a href=&quot;https://github.com/sevenever/vim/pull/1&quot; rel=&quot;nofollow noreferrer&quot;&gt;trimjumplist&lt;/a&gt; function to vim so I can use below code and it works for me but you will have to compile vim. Hope this will help.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TrimJumpListAndCscopeFind(action, word)&#xA;    if has('jumplist')&#xA;        if exists('*trimjumplist')&#xA;            let jl = getjumplist()&#xA;            call trimjumplist(len(jl[0]) - str2nr(jl[1]))&#xA;        endif&#xA;    endif&#xA;    call CscopeFind(a:action, a:word)&#xA;endfunction&#xA;&#xA;nnoremap  &amp;lt;leader&amp;gt;fg :call TrimJumpListAndCscopeFind('g', expand('&amp;lt;cword&amp;gt;'))&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27279" LastEditorUserId="27279" LastEditDate="2020-03-07T09:45:04.617" LastActivityDate="2020-03-07T09:45:04.617" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23118" PostTypeId="1" CreationDate="2020-03-06T15:55:57.780" Score="2" ViewCount="624" Body="&lt;p&gt;Currently all my colors are defined through Xresources and being set in vim through &lt;code&gt;ctermfg=2&lt;/code&gt; for example. Lately there have been many improvements that rely on termguicolors being enabled (pumblend for example) that I can't use since I set my colors through cterm. Is there either a way to query the value of what &lt;code&gt;ctermfg=2&lt;/code&gt; would be set to so I can assign it to guifg and then use termguicolors. This way my colors can still be defined through Xresources and I'd be able to use all the termguicolors dependent features as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT for clarity: by setting ctermfg=2, what is the RGB value of color &quot;2&quot; and how can that be queried?&lt;/p&gt;&#xA;" OwnerUserId="9660" LastEditorUserId="9660" LastEditDate="2020-03-08T00:21:42.050" LastActivityDate="2020-03-08T00:21:42.050" Title="get cterm color value" Tags="|neovim|colorscheme|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="23119" PostTypeId="1" AcceptedAnswerId="23120" CreationDate="2020-03-06T22:19:34.313" Score="3" ViewCount="1089" Body="&lt;p&gt;As title, when there're tens of suggestions, the popup can expand the entire window. How to set a maximum window height for auto completion popup? I'd like to have a scrolling window.&lt;/p&gt;&#xA;" OwnerUserId="27290" LastActivityDate="2020-03-07T02:16:23.790" Title="How to set a maximum popup window height for auto completion?" Tags="|autocompletion|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23120" PostTypeId="2" ParentId="23119" CreationDate="2020-03-07T00:37:26.877" Score="4" Body="&lt;p&gt;There's an option called &lt;code&gt;'pumheight'&lt;/code&gt;. Thanks @D.BenKnoble!&lt;/p&gt;&#xA;" OwnerUserId="27290" LastEditorUserId="10604" LastEditDate="2020-03-07T02:16:23.790" LastActivityDate="2020-03-07T02:16:23.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23121" PostTypeId="2" ParentId="7902" CreationDate="2020-03-07T03:10:08.367" Score="1" Body="&lt;p&gt;A solution to this problem is mentioned in Vim's documentation (&lt;code&gt;:h --remote&lt;/code&gt;). The following command should open &lt;em&gt;filename&lt;/em&gt; to &lt;em&gt;line_number&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;gvim --servername DEBUG --remote-send &amp;quot;&amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;:tab drop &lt;i&gt;filename&lt;/i&gt;&amp;lt;CR&amp;gt;&lt;i&gt;line_number&lt;/i&gt;G&amp;quot;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this seems to neither raise nor focus Vim. And I believe that opening the file using &lt;code&gt;:tab drop filename&lt;/code&gt; should work similar to &lt;code&gt;vim --remote-tab-silent filename&lt;/code&gt;. Also, note that I tested this using the &lt;code&gt;i3&lt;/code&gt; and &lt;code&gt;awesome&lt;/code&gt; window managers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;:h --remote &lt;hr&gt;   --remote [+{cmd}] {file} ...                                 *--remote*&#xA;                                Open the file list in a remote Vim.  When&#xA;                                there is no Vim server, execute locally.&#xA;                                There is one optional init command: +{cmd}.&#xA;                                This must be an Ex command that can be&#xA;                                followed by &amp;quot;|&amp;quot;. &#xA;                                The rest of the command line is taken as the&#xA;                                file list.  Thus any non-file arguments must&#xA;                                come before this.&#xA;                                You cannot edit stdin this way |--|.&#xA;                                The remote Vim is raised.  If you don&amp;apos;t want&#xA;                                this use&#xA;                                 vim --remote-send &amp;quot;&amp;lt;C-\&amp;gt;&amp;lt;C-N&amp;gt;:n filename&amp;lt;CR&amp;gt;&amp;quot;&lt;/pre&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2020-03-07T03:10:08.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23122" PostTypeId="1" AcceptedAnswerId="24480" CreationDate="2020-03-07T06:13:37.557" Score="4" ViewCount="566" Body="&lt;p&gt;I try to parse output with ANSI codes and I can't cope with definition errorformat.&#xA;Example output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[[0;31;49mtestdata/examples.rb:3^[[0m Array#shuffle.first is slower than Array#sample.$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After parse I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|| testdata/examples.rb:3 Array#shuffle.first is slower than Array#sample.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this example use ANSI code red color: ^[[0;31;49m. Character ^[ is &amp;lt;1b&gt; in HEX. I tried use this character in efm:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;%s/&amp;lt;1b&amp;gt;%p[0;31;49m%f:%l%s/&amp;lt;1b&amp;gt;%p[0m %m&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it didn't work.&#xA;Also I tried to use \033 character (^[ in octal):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;\033%p[0;31;49m%f:%l\033%p[0m %m&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it doesn't work too.&lt;/p&gt;&#xA;" OwnerUserId="27293" LastActivityDate="2020-04-06T16:51:48.413" Title="Vim errorformat to parse output with ANSI color codes" Tags="|errorformat|" AnswerCount="1" CommentCount="6" ClosedDate="2020-04-07T07:48:12.620" ContentLicense="CC BY-SA 4.0" />
  <row Id="23124" PostTypeId="1" AcceptedAnswerId="23127" CreationDate="2020-03-07T11:29:30.147" Score="1" ViewCount="481" Body="&lt;p&gt;As title, how to get syntax highlighting for the embeded python within vimscript? Is there a plugin that does syntax highlighting for embeded script?&lt;/p&gt;&#xA;" OwnerUserId="27290" LastEditorUserId="22797" LastEditDate="2020-03-07T15:34:02.920" LastActivityDate="2020-03-07T17:22:07.323" Title="How to get syntax highlighting for the embeded python within vimscript?" Tags="|neovim|syntax-highlighting|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23125" PostTypeId="2" ParentId="4488" CreationDate="2020-03-07T12:27:43.160" Score="0" Body="&lt;p&gt;This works for &lt;code&gt;Syntax&lt;/code&gt; autocommands, where the pattern (&lt;code&gt;&amp;lt;match&amp;gt;&lt;/code&gt;) is just the filetype.  It excludes any &lt;code&gt;rst&lt;/code&gt; files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au Syntax *\(^rst\)\@&amp;lt;! …&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2899" LastActivityDate="2020-03-07T12:27:43.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23127" PostTypeId="2" ParentId="23124" CreationDate="2020-03-07T15:32:53.560" Score="1" Body="&lt;p&gt;So the enabled embedded syntaxes in VimScript are ruled by &lt;code&gt;:h g:vimsyn_embed&lt;/code&gt; variable. However, Vim and Neovim has different default settings in this regard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim's &lt;code&gt;syntax/vim.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Allows users to specify the type of embedded script highlighting&#xA;&quot; they want:  (perl/python/ruby/tcl support)&#xA;&quot;   g:vimsyn_embed == 0   : don't embed any scripts&#xA;&quot;   g:vimsyn_embed =~# 'l' : embed lua      (but only if vim supports it)&#xA;&quot;   g:vimsyn_embed =~# 'm' : embed mzscheme (but only if vim supports it)&#xA;&quot;   g:vimsyn_embed =~# 'p' : embed perl     (but only if vim supports it)&#xA;&quot;   g:vimsyn_embed =~# 'P' : embed python   (but only if vim supports it)&#xA;&quot;   g:vimsyn_embed =~# 'r' : embed ruby     (but only if vim supports it)&#xA;&quot;   g:vimsyn_embed =~# 't' : embed tcl      (but only if vim supports it)&#xA;if !exists(&quot;g:vimsyn_embed&quot;)&#xA;    let g:vimsyn_embed = &quot;lmpPr&quot;&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, in Neovim the last but one line is changed to &lt;code&gt;let g:vimsyn_embed = 0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence, &lt;code&gt;let g:vimsyn_embed = 'P'&lt;/code&gt; must be added to init.vim to enable this feature in Neovim. While in Vim it should work by default.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-03-07T15:32:53.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23128" PostTypeId="1" CreationDate="2020-03-07T21:37:56.247" Score="4" ViewCount="720" Body="&lt;p&gt;After going blind from using Gvim with non-bitmapped fonts, I tried to narrow my question from the previous attempts &lt;a href=&quot;https://vi.stackexchange.com/questions/22646/where-does-gvim-find-font-options-for-its-guifont-pick-list/22650#22650&quot;&gt;(1)&lt;/a&gt; and &lt;a href=&quot;https://superuser.com/questions/1530098/choose-gvim-font-that-maps-pixel-to-pixel-with-display&quot;&gt;(2)&lt;/a&gt; (with older attempts going back years).  Specifically, I wanted to find a means to force visibility of X11 fonts to Gvim. &lt;a href=&quot;http://linuxdocs.org/HOWTOs/XWindow-User-HOWTO-7.html#ss7.2&quot; rel=&quot;nofollow noreferrer&quot;&gt;This X11 font info page&lt;/a&gt; explains that I need bitmapped fonts to avoid the horrible mixing of brightness from adjacent (logical) pixels, and even identifies the font directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, Gvim doesn't recognize such fonts.  For example, my &lt;code&gt;xterm&lt;/code&gt; can be set to (say) &lt;code&gt;-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-1&lt;/code&gt;, but if I set Gvim's &lt;code&gt;guifont&lt;/code&gt; to this, it just defaults to the same spaced-out font that it does when supplied with an unrecognized font specification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Web search indicates that one reason why the fonts may not be visible to Gvim is that the host folder is not in the &quot;font path&quot;.   X11 fonts are so complicated that I could not find out how to display the font path (I can set it using &lt;code&gt;xset&lt;/code&gt;). Further web search says that it is set in an &lt;code&gt;xorg.conf&lt;/code&gt; file, but a &lt;code&gt;find&lt;/code&gt; command issued for &lt;code&gt;xorg.conf*&lt;/code&gt; yields nothing (an Ubuntu page suggested possible path &lt;code&gt;/etc/X11/xorg.conf&lt;/code&gt;).  Further search unearths frequent mention that &lt;code&gt;xorg.conf&lt;/code&gt; is no longer used these days.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I'm using Cygwin, I fortunately found a &lt;a href=&quot;https://x.cygwin.com/docs/man1/Xserver.1.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;font page&lt;/a&gt; indicating that the font path is set in &lt;code&gt;/etc/X11/fontpath.d/&lt;/code&gt;.  At last, something that actually rings true in my system:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls -l /etc/X11/fontpath.d/ | sed -e 's/.*[0-9][0-9]:[0-9][0-9] //'&#xA;total 5&#xA;terminus:unscaled -&amp;gt; /usr/share/fonts/terminus/&#xA;xorg-x11-fonts-100dpi:unscaled:pri=30 -&amp;gt; /usr/share/X11/fonts/100dpi/&#xA;xorg-x11-fonts-75dpi:unscaled:pri=20 -&amp;gt; /usr/share/X11/fonts/75dpi/&#xA;xorg-x11-fonts-misc:unscaled:pri=10 -&amp;gt; /usr/share/X11/fonts/misc/&#xA;xorg-x11-fonts-Type1 -&amp;gt; /usr/share/X11/fonts/Type1/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've unsuccessfully tried to peek into the files therein before, but I'm not sure if that would actually help.  What the above shows is that the idea of X11 bitmapped fonts in the font path is satisfied, and the reason why Gvim can't see them must be some other reason.  This is a problem that is very specific to Gvim, and I have thus far been unable to find anything online for what determines the fonts that Gvim sees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gvim has been around for decades -- surely this is a well-known detail?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Helpful background found&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/338047/how-does-fontconfig-actually-work&quot;&gt;This&lt;/a&gt; explanation of &lt;code&gt;fontconfig&lt;/code&gt; fills in some of my void of knowledge.  It tells me that I want to avoid Type 1 fonts.  Using &lt;code&gt;fc-list&lt;/code&gt;, I found that the &quot;recognized&quot; (registered?) fonts include those in the folder subtrees rooted in &lt;em&gt;both&lt;/em&gt; &lt;code&gt;/usr/share/fonts and&lt;/code&gt;/usr/share/X11/fonts.  I am disturbed by the phrase &quot;XFT allows scaling of the old bitmap fonts to look like Type1 fonts&quot;. Maybe that's why my fonts looks so bad, but it doesn't explain why this&#xA;only afflicts Gvim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://askubuntu.com/questions/6710/how-can-i-use-bitmap-fonts-in-gvim&quot;&gt;This&lt;/a&gt; page on &lt;em&gt;using bitmap fonts in Gvim&lt;/em&gt; is very relevant, but I have no &lt;code&gt;/etc/fonts/conf.d/70-no-bitmaps.conf&lt;/code&gt; to remove and no &lt;code&gt;/etc/fonts/conf.avail/70-yes-bitmaps.conf&lt;/code&gt; to link.  Indeed, I have no &lt;code&gt;/etc/fonts/conf.avail&lt;/code&gt; folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above page is linked to by &lt;a href=&quot;https://askubuntu.com/questions/90001/how-can-i-activate-bitmap-fonts&quot;&gt;this&lt;/a&gt; page on &lt;em&gt;activating bitmap fonts,&lt;/em&gt; but I don't have &lt;code&gt;70-force-bitmaps&lt;/code&gt; to link to either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also came across the suggestion to set the &lt;code&gt;antialias&lt;/code&gt; option, but in my Gvim, that option is apparently not supported.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Computer_font&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; Wikipedia page on &lt;em&gt;computer fonts&lt;/em&gt; says that PCF is bitmap, and &lt;a href=&quot;http://cygwin.1069669.n5.nabble.com/Fonts-look-ugly-in-X-with-gvim-td34119.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; Cygwin/Gvim page corroborates this in saying &quot;You're better off using the PCF form of the font&quot;.  However, its suggestion of such a font is &lt;code&gt;:set gfn=LucidaTypewriter\ 17&lt;/code&gt;, which definitely doesn't look bitmapped, judging by the foreground/background color averaging on some pixels.  It may be the case that the underlying font is bitmapped, but there's scaling/antialiasing occuring between the font itself and Gvim, possibly done by X.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.x.org/archive/X11R7.5/doc/fonts/fonts.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fonts in X11R7.5&lt;/a&gt; page contains an &lt;a href=&quot;https://www.x.org/archive/X11R7.5/doc/fonts/fonts.html#SEC-INSTALLING&quot; rel=&quot;nofollow noreferrer&quot;&gt;Installing fonts&lt;/a&gt; section.  It contains a &lt;a href=&quot;https://www.x.org/archive/X11R7.5/doc/fonts/fonts.html#SEC-TROUBLESHOOTING-CORE&quot; rel=&quot;nofollow noreferrer&quot;&gt;Troubleshooting&lt;/a&gt; subsection listing the extensions of bitmap fonts (and &lt;em&gt;freetype&lt;/em&gt; fonts, which I'm not interested in right now):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;bitmap&quot;: bitmap fonts ('*.bdf', '*.pcf' and '*.snf');&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;freetype&quot;: TrueType fonts ('*.ttf' and '*.ttc'), OpenType fonts ('*.otf' and '*.otc') and Type 1 fonts ('*.pfa' and '*.pfb').&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I found the extensions of files in the &lt;code&gt;/usr/share/fonts&lt;/code&gt; &lt;code&gt;/usr/share/X11/fonts&lt;/code&gt; file trees, taking care to preserve extensions of gzipped files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find /usr/share/fonts/ /usr/share/X11/fonts/ -type f \&#xA;| sed -e 's=.*\(\.[[:alnum:]]\{1,3\}.gz\)$=\1=' \&#xA;      -e '/\.gz$/!s=.*\(\.[[:alnum:]]\{1,\}$\)=\1=' \&#xA;| sort -u | tr '\n' ' '&#xA;&#xA;    .afm .alias .dir .enc.gz .otf .pcf.gz&#xA;    .pfa .pfb .scale .t1 .ttf .uuid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Comparing to the above &lt;code&gt;bitmap&lt;/code&gt; and &lt;code&gt;freetype&lt;/code&gt; file extensions above, we see that the only bitmap fonts have &lt;code&gt;*.pcf&lt;/code&gt; extension.  All the others are &lt;code&gt;freetype&lt;/code&gt;, with &lt;em&gt;exception&lt;/em&gt; of extensions &lt;code&gt;*.afm&lt;/code&gt;, &lt;code&gt;*.alias&lt;/code&gt;, &lt;code&gt;*.dir&lt;/code&gt;, &lt;code&gt;*.scale&lt;/code&gt;, and &lt;code&gt;*.uuid&lt;/code&gt;.  Based on the extensions alone, we can speculate that all these exceptions serve purpose other than housing actual fonts (well, perhaps &lt;code&gt;*.afm&lt;/code&gt; looks like it may be a font).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The folders containing the identified &lt;code&gt;bitmap&lt;/code&gt; fonts are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find /usr/share/fonts/ /usr/share/X11/fonts/&#xA;    -type f -name '*.pcf.gz' \&#xA;| sed -e 's=/[^/]*$==' | sort -u&#xA;&#xA;    /usr/share/fonts/terminus&#xA;    /usr/share/X11/fonts/100dpi&#xA;    /usr/share/X11/fonts/75dpi&#xA;    /usr/share/X11/fonts/misc&#xA;&#xA;ls \&#xA;/usr/share/fonts/terminus \&#xA;/usr/share/X11/fonts/100dpi \&#xA;/usr/share/X11/fonts/75dpi \&#xA;/usr/share/X11/fonts/misc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;ls&lt;/code&gt; command shows that only the &lt;code&gt;terminus&lt;/code&gt; folder contains fonts with a common filename root, e.g.,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/fonts/terminus:&#xA;fonts.dir&#xA;fonts.scale&#xA;ter-112b.pcf.gz&#xA;ter-112n.pcf.gz&#xA;ter-114b.pcf.gz&#xA;&amp;lt;...etc...&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All the other folders contain a diversity of fonts with different font names.  I was hoping that I can easily find bitmap font names matching those from &lt;code&gt;:set guifont=*&lt;/code&gt;, but the only easily recognizable Gvim font name is &lt;code&gt;terminus&lt;/code&gt; -- or rather, &lt;code&gt;Terminus&lt;/code&gt; in the &lt;code&gt;guifont&lt;/code&gt; picker.  It seems to be free from the mixing of brightness between foregroound and background, indicating that not only is it a bitmap font, but that it also behaves like a bitmap font in Cygwin's X11.  However, it is not a good looking font.  :(&lt;/p&gt;&#xA;" OwnerUserId="7041" LastEditorUserId="7041" LastEditDate="2020-03-19T19:38:51.877" LastActivityDate="2020-03-19T19:38:51.877" Title="Why does Gvim not see my X11 fonts?" Tags="|gvim|font|cygwin|x11|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="23129" PostTypeId="2" ParentId="23107" CreationDate="2020-03-07T22:03:23.787" Score="1" Body="&lt;p&gt;The reason why command redirection through &lt;code&gt;&amp;lt;(...)&lt;/code&gt; resolves to a unique name on Linux is due to the Linux kernel exposing these as virtual symlinks to such unique name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can easily verify that, on Linux, with a command such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls -l &amp;lt;(echo hello)&#xA;lr-x------ 1 filbranden filbranden 64 Mar  7 13:37 /proc/self/fd/63 -&amp;gt; 'pipe:[75220421]'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One way to work around the fact that Vim sees these command substitutions as the same file on Mac OS is to simply have Vim read the contents of the file through standard input, by passing it a &lt;a href=&quot;https://vimhelp.org/starting.txt.html#--&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;-&lt;/code&gt; as the filename&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ command1 | vi -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In that case Vim will use a swap file with an empty name (&lt;code&gt;./.swp&lt;/code&gt;) but when running the same for further commands, Vim will know it's not the same file and it will create separate swap files (&lt;code&gt;./.swo&lt;/code&gt;, then &lt;code&gt;./.swn&lt;/code&gt; etc.) for them, which should work around the issue you're experiencing.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-07T22:03:23.787" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23130" PostTypeId="1" AcceptedAnswerId="23133" CreationDate="2020-03-08T00:16:43.153" Score="10" ViewCount="20275" Body="&lt;p&gt;I'm using the latest version of vim 8.2.148 on the latest version of arch linux 5.5.6-arch1-1 with the latest version of Openbox window manager version 3.6.1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have written a document in vim and need to yank parts of it and paste them into a web form.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command in vim to yank to the system wide / openbox clipboard so that I can paste into the chromium web form?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yank seems to work inside vim only.&lt;/p&gt;&#xA;" OwnerUserId="27300" LastActivityDate="2021-01-01T15:47:50.730" Title="how to yank from vim to system clipboard?" Tags="|cut-copy-paste|" AnswerCount="1" CommentCount="1" ClosedDate="2021-01-01T21:45:24.660" ContentLicense="CC BY-SA 4.0" />
  <row Id="23131" PostTypeId="1" AcceptedAnswerId="23132" CreationDate="2020-03-08T03:01:42.013" Score="1" ViewCount="65" Body="&lt;p&gt;In vim, one could describe the &quot;state&quot; as the position of the cursor, the position of the screen view (ratio of screen viewable above cursor vs below), and the values of all latent variables and file buffers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know vim keeps track/history of cursor positions using jumplist, but does it also do that for the screen view?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use case:&#xA;Let's say I wanted to see if a term exists in the current screen view. So I search for it using &lt;code&gt;/Foo&lt;/code&gt;, but since that word isn't in the current view, Vim jumps to the next occurrence. I can return the cursor to the previous position from where I searched, but that doesn't reset the screen view.&lt;/p&gt;&#xA;" OwnerUserId="27301" LastActivityDate="2020-03-08T05:52:38.717" Title="Does Vim keep track of screen views?" Tags="|cursor-movement|command-history|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23132" PostTypeId="2" ParentId="23131" CreationDate="2020-03-08T05:52:38.717" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I know vim keeps track/history of cursor positions using jumplist, but does it also do that for the screen view?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, a jumplist is only a jumplist. If you need to save/restore the view you have to do it manually. The relevant VimScript functions are &lt;code&gt;:h winsaveview()&lt;/code&gt; and &lt;code&gt;:h winrestview()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-03-08T05:52:38.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23133" PostTypeId="2" ParentId="23130" CreationDate="2020-03-08T09:29:59.723" Score="14" Body="&lt;p&gt;First get into an appropriate visual mode. &lt;code&gt;v&lt;/code&gt; selects the standard visual mode, &lt;code&gt;SHIFT-v&lt;/code&gt; selects visual-line mode, and &lt;code&gt;CTRL-v&lt;/code&gt; selects visual block mode. Next, select the text that you want to select. Finally, &lt;code&gt;&quot;+y&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;&quot;&lt;/code&gt; means register. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;+&lt;/code&gt; specifies the system clipboard register. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;y&lt;/code&gt; is yank. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;&quot;+y&lt;/code&gt; yanks into the system clipboard register. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;more info on registers: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;:help reg&lt;/code&gt; inside vim&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Tutorial on vim registers: &lt;a href=&quot;https://www.brianstorti.com/vim-registers/&quot; rel=&quot;noreferrer&quot;&gt;https://www.brianstorti.com/vim-registers/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="26732" LastEditorUserId="26732" LastEditDate="2020-03-08T09:40:10.830" LastActivityDate="2020-03-08T09:40:10.830" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="23134" PostTypeId="1" AcceptedAnswerId="23137" CreationDate="2020-03-08T10:31:44.100" Score="2" ViewCount="296" Body="&lt;h2&gt;Background&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I would like to disable arrow keys in all modes. This is what I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;EDIT: added remap for &amp;lt;esc&amp;gt; as per the comments&#xA;inoremap &amp;lt;esc&amp;gt; &amp;lt;nop&amp;gt;&#xA;&#xA;inoremap &amp;lt;up&amp;gt; &amp;lt;nop&amp;gt;&#xA;inoremap &amp;lt;down&amp;gt; &amp;lt;nop&amp;gt;&#xA;inoremap &amp;lt;left&amp;gt; &amp;lt;nop&amp;gt;&#xA;inoremap &amp;lt;right&amp;gt; &amp;lt;nop&amp;gt;&#xA;&quot;inoremap &amp;lt;ESC&amp;gt;oA &amp;lt;nop&amp;gt;&#xA;&quot;inoremap &amp;lt;ESC&amp;gt;oB &amp;lt;nop&amp;gt;&#xA;&quot;inoremap &amp;lt;ESC&amp;gt;oC &amp;lt;nop&amp;gt;&#xA;&quot;inoremap &amp;lt;ESC&amp;gt;oD &amp;lt;nop&amp;gt;&#xA;nnoremap &amp;lt;up&amp;gt; &amp;lt;nop&amp;gt;&#xA;nnoremap &amp;lt;down&amp;gt; &amp;lt;nop&amp;gt;&#xA;nnoremap &amp;lt;left&amp;gt; &amp;lt;nop&amp;gt;&#xA;nnoremap &amp;lt;right&amp;gt; &amp;lt;nop&amp;gt;&#xA;vnoremap &amp;lt;up&amp;gt; &amp;lt;nop&amp;gt;&#xA;vnoremap &amp;lt;down&amp;gt; &amp;lt;nop&amp;gt;&#xA;vnoremap &amp;lt;left&amp;gt; &amp;lt;nop&amp;gt;&#xA;vnoremap &amp;lt;right&amp;gt; &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine for normal and visual modes, but in insert mode it starts writing funny characters if I press the arrow keys, like &lt;code&gt;OCOCOCOCOCODODODODODOAOAOAOBOB&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;What is the reason that the arrow keys behave differently in insert mode than normal/visual modes? (Or do they actually behave the same, and &lt;code&gt;OCOAOB&lt;/code&gt; has no effect in normal/visual modes?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: It turned out that the cause for the behaviour was the remapping of the &lt;code&gt;esc&lt;/code&gt; key (thanks to @filbranden for &lt;a href=&quot;https://vi.stackexchange.com/questions/23134/why-do-arrow-keys-behave-differently-in-insert-mode-than-in-other-modes#comment42002_23134&quot;&gt;pointing that out&lt;/a&gt;!)&#xA;However, the question is still open: why do the remapped arrow keys in &lt;em&gt;insert&lt;/em&gt; mode behave differently, if the &lt;code&gt;esc&lt;/code&gt; key is also remapped?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Remarks&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I am running Ubuntu and using Vim in a &lt;em&gt;local&lt;/em&gt; terminal (i.e. not ssh'ing somewhere remotely)&lt;/li&gt;&#xA;&lt;li&gt;I already found this &lt;a href=&quot;https://stackoverflow.com/a/23558540/3398271&quot;&gt;answer&lt;/a&gt;, and tried to change all kinds of terminal settings/nocompatible mode. The only difference I could achieve was this: &lt;code&gt;[C[C[C[C[D[D[D[D[D[C[C[A[B[D[C&lt;/code&gt;. (&lt;strong&gt;EDIT&lt;/strong&gt;: this is caused e.g. by &lt;code&gt;:set term=ansi&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;The issue is reproducible also with a minimal &lt;code&gt;.vimrc&lt;/code&gt; containing only the lines above (i.e., it is not due to a plugin interferring).&lt;/li&gt;&#xA;&lt;li&gt;By uncommenting the commented lines, the problem is fixed, but 1. I would really like to understand what is going on; 2. that solution feels a bit hacky to me, although it works.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Answer to comments&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set term? t_ku?&#xA;&#xA;&#xA;term=screen-256color&#xA;t_ku &amp;lt;Up&amp;gt;        ^[OA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Platform, OS: Ubuntu 19.04 on x86_64, terminal vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pressing arrows in terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat&#xA;^[[A^[[B^[[A^[[C^[[D^[[C^[[B^[[A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NONE -N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;--&gt; problem is not reproducible&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Contents of &lt;code&gt;/etc/vim/vimrc&lt;/code&gt; (comments removed):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime! debian.vim&#xA;&#xA;if has(&quot;syntax&quot;)&#xA;  syntax on&#xA;endif&#xA;&#xA;if filereadable(&quot;/etc/vim/vimrc.local&quot;)&#xA;  source /etc/vim/vimrc.local&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9602" LastEditorUserId="9602" LastEditDate="2020-03-08T22:02:51.550" LastActivityDate="2020-03-08T22:25:13.547" Title="Why do arrow keys behave differently in insert mode than in other modes?" Tags="|key-bindings|insert-mode|movement|" AnswerCount="1" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="23135" PostTypeId="1" AcceptedAnswerId="23136" CreationDate="2020-03-08T12:47:58.430" Score="1" ViewCount="1977" Body="&lt;p&gt;There is this feature or module in Vim which auto back-indents words during writing if/else statements. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if a == 1:&#xA;   xx   &amp;lt;-- here when I press enter cursor goes right below end of word &quot;xx&quot;.&#xA;else   &amp;lt;-- however as soon as I fully type word &quot;else&quot; this line gets automatically indented backwards&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What module/feature allows this auto-back-indent when typing word 'else'? As in, how do I enable this functionality?&lt;/p&gt;&#xA;" OwnerUserId="27304" LastEditorUserId="1238" LastEditDate="2020-03-09T04:00:55.757" LastActivityDate="2020-03-09T08:46:10.290" Title="Auto back-indent word 'else' in if/else statement in Vim" Tags="|plugin-system|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23136" PostTypeId="2" ParentId="23135" CreationDate="2020-03-08T14:38:17.927" Score="10" Body="&lt;p&gt;Let's start from the beginning. There are quite a few (local to buffer) options in Vim to work with indenting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;autoindent&lt;/code&gt; is the most basic setting; it simply makes a new line to have an equivalent number (influenced by &lt;code&gt;copyindent&lt;/code&gt; and &lt;code&gt;preserveindent&lt;/code&gt; options) of leading spaces/tabs as in a previous line;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;smartindent&lt;/code&gt; is a &quot;lightweight&quot; thing for a C-like language. It indents/unindents braces and hashes, and also &lt;em&gt;indents&lt;/em&gt; after a few keywords, such as &quot;if&quot;, &quot;while&quot; etc. (See &lt;code&gt;:h 'cinwords'&lt;/code&gt;) But it lacks an &lt;em&gt;unindent&lt;/em&gt; for keywords, such as &quot;else&quot;;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;cindent&lt;/code&gt; option (and the corresponding VimScript function &lt;code&gt;cindent()&lt;/code&gt;) is a full-featured builtin C/C++ indenter; it's also used as a fallback by many C-like languages, such as Java, Rust and so on; however, it's of a little use for Python and such;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;also, there's a builtin indenter for LISP language, but it's probably of a little interest now;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;indentexpr&lt;/code&gt; is the most flexible option; it could be set to a VimScript expression (normally, a function call) to be evaluated in runtime;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, as one may guess, for almost all programming languages Vim computes indents by re-evaluating an expression stored in &lt;code&gt;indentexpr&lt;/code&gt;. But, of course, an ordinary vimmer doesn't want to implement &lt;code&gt;function GetPythonIndent()&lt;/code&gt; himself, so it's written as a part of standard plugin shipped with Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The core Vim command to enable this functionality is &lt;code&gt;:h filetype&lt;/code&gt;. If entered without arguments, it prints the current state:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:filetype&amp;lt;CR&amp;gt;&#xA;filetype detection:ON plugin:ON indent:ON&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So there are (at least) three subsystems designed to work together: filetype detection, filetype settings and indent settings. But let's focus only on &lt;code&gt;indent&lt;/code&gt;. Concerning &lt;code&gt;ftdetect&lt;/code&gt; it's enough to say that the file type must be somehow detected before a relevant indent subplugin can do its job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if &lt;code&gt;indent:ON&lt;/code&gt; then Vim simply sources &lt;code&gt;$VIMRUNTIME/indent.vim&lt;/code&gt; which sets a trap for all subsequent &lt;code&gt;FileType&lt;/code&gt; events (see &lt;code&gt;:h :autocmd&lt;/code&gt;). Then if we got some &lt;code&gt;x.y.z&lt;/code&gt; filetype the code in &lt;code&gt;indent.vim&lt;/code&gt; sources all &lt;code&gt;indent/x.vim&lt;/code&gt;, &lt;code&gt;indent/y.vim&lt;/code&gt; and &lt;code&gt;indent/z.vim&lt;/code&gt; found on &lt;code&gt;:h 'runtimepath'&lt;/code&gt;. A standard implementation for &lt;code&gt;setlocal indentexpr=GetPythonIndent(v:lnum)&lt;/code&gt; is then found in &lt;code&gt;$VIMRUNTIME/indent/python.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;$VIMRUNTIME/defaults.vim&lt;/code&gt; (note: Vim8+ only) there's a line &lt;code&gt;filetype plugin indent on&lt;/code&gt;, so if you source the recommended defaults for Vim (e.g. &lt;code&gt;runtime defaults.vim&lt;/code&gt; on top of your vimrc), then you don't have to enable ftplugin functionality manually. In Neovim, &lt;code&gt;filetype plugin indent on&lt;/code&gt; is a builtin default setting.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-03-08T14:38:17.927" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="23137" PostTypeId="2" ParentId="23134" CreationDate="2020-03-08T22:25:13.547" Score="1" Body="&lt;p&gt;So the issue is that the mapping for &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; is interfering with other mappings. Since most special keys generate sequences that start with an ESC character (which typically shows up as &lt;code&gt;^[&lt;/code&gt;), the mapping is causing Vim to take that initial ESC from the first mapping, which is ignoring the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, then keeping the rest of the characters (&lt;code&gt;OA&lt;/code&gt;) as a normal sequence to be inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim can usually handle mappings that involve prefixes, by waiting for further characters or until a timeout happens. That's how Vim can usually detect between an unmapped &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; and a special key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's unclear why it's not doing so when you're remapping &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;... It possibly has something to do with Vim converting the sequence for the &lt;code&gt;&amp;lt;Up&amp;gt;&lt;/code&gt; key into &lt;code&gt;&amp;lt;80&amp;gt;ku&lt;/code&gt; internally (where &lt;code&gt;&amp;lt;80&amp;gt;&lt;/code&gt; is ASCII character 0x80), which might make Vim no longer think it's a longer sequence starting with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing is that when you create a longer mapping that starts with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, such as the one for &lt;code&gt;&amp;lt;Esc&amp;gt;oA&lt;/code&gt; that you had commented, that &lt;em&gt;will&lt;/em&gt; trigger the behavior of waiting for a timeout before triggering the macro, so that fixes your other mappings by not triggering the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; macro right away. Note, in particular, that &lt;code&gt;&amp;lt;Esc&amp;gt;oA&lt;/code&gt; isn't even what the Up arrow generates (it generates an uppercase &lt;code&gt;O&lt;/code&gt; instead of a lowercase one.) But &lt;em&gt;any&lt;/em&gt; sequence starting with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; would be enough to trigger this behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I'd suggest using this as a workaround to remap both &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; and special keys:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Esc&amp;gt;&amp;lt;nop&amp;gt; &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will never match anything (as you don't have a way to produce &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; as a keystroke), but it will have the intended side effect of delaying the initial &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; mapping enough for sequences starting with &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; to translate into special keys and match those mappings instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Make sure you add a nice comment to that mapping, so you'll later recall &lt;em&gt;why&lt;/em&gt; it's needed!)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-08T22:25:13.547" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23138" PostTypeId="1" CreationDate="2020-03-09T00:15:50.587" Score="1" ViewCount="141" Body="&lt;p&gt;vim (version 8.0) shows &amp;lt;200C&gt; when I insert &lt;a href=&quot;https://en.wikipedia.org/wiki/Zero-width_non-joiner&quot; rel=&quot;nofollow noreferrer&quot;&gt;zero-width non-joiner&lt;/a&gt; character via Persian keyboard.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tbnwv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tbnwv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17786" LastActivityDate="2020-03-09T00:15:50.587" Title="vim shows code point of zero-width non-joiner character" Tags="|keyboard-layout|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23139" PostTypeId="1" CreationDate="2020-03-09T06:31:04.150" Score="1" ViewCount="25" Body="&lt;p&gt;I often use HPP files when separating a template header from its implementation. In this scheme an&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&quot;impl.hpp&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is inserted in the &lt;code&gt;.h&lt;/code&gt; (the header) file after all relevant definitions. As such, there is no real need to include said header in the &lt;code&gt;.hpp&lt;/code&gt; file as the &lt;code&gt;.hpp&lt;/code&gt; itself is what is being included.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using Syntastic, the plugin uses the headers to determine which symbols exist. Thus, the implementation which depends on symbols in the header comes up with errors on the check. The easy way to fix this is to include the header itself in the &lt;code&gt;.h&lt;/code&gt; file. When working in groups who do not have this redundant inclusion, I do not want to add it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Is there a way to either have Syntastic use symbols from another file (the name is always the same base name &lt;code&gt;.h&lt;/code&gt;) when checking the file? Or maybe a secret &lt;code&gt;g++&lt;/code&gt; option I missed (note: a file with symbols, not an include directory)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, is there a safe way to add a line to the top of a file when opening an &lt;code&gt;hpp&lt;/code&gt; file on a temporary base, such that it will not be saved to the file but still used by Syntastic? The fact it is not saved to the actual file needs to survive a crash for example.&lt;/p&gt;&#xA;" OwnerUserId="25481" LastEditorUserId="25481" LastEditDate="2020-03-09T08:57:16.770" LastActivityDate="2020-03-09T08:57:16.770" Title="Adding an header when checking an HPP file on the fly" Tags="|autocmd|filetype-c++|plugin-syntastic|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23140" PostTypeId="2" ParentId="22951" CreationDate="2020-03-09T06:32:44.750" Score="0" Body="&lt;p&gt;Use &lt;a href=&quot;https://github.com/vim-ctrlspace/vim-ctrlspace&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim-ctrlspace/vim-ctrlspace&lt;/a&gt; . It attaches  buffers to a tab. &lt;code&gt;Ctrl-space + w&lt;/code&gt; to navigate buffers in the tab(by default). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that is the default but I might have changed the plugin locally. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2020-03-09T08:24:04.550" LastActivityDate="2020-03-09T08:24:04.550" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23141" PostTypeId="2" ParentId="23135" CreationDate="2020-03-09T08:46:10.290" Score="2" Body="&lt;p&gt;@Matt has already given a correct (and good) answer, but here's answer from someone who is old enough to have learned to love vi in it's original form, without fancy bits. I keep boring people stiff with this subject, so beware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indentation discipline is, of course, a really good idea, as it helps the eye see how the code is structured, logically. And it is mildly annoying that you have to use ^D to 'outdent' (?) - 'backdent' (?) - whatever the word may be, so my solution has been to simply do what some of the early IDEs later adopted: write the end-of-block marker as soon as you write the start of the block - so, when you write '{' in C, you write '}' on the next line, at the same indentation, when you write 'then' in ksh, you immediately add a 'fi;' on the next line, etc. That way, don't forget to close your blocks, and the indentation works coveniently as well.&lt;/p&gt;&#xA;" OwnerUserId="20900" LastActivityDate="2020-03-09T08:46:10.290" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23142" PostTypeId="1" AcceptedAnswerId="23147" CreationDate="2020-03-09T09:59:56.890" Score="4" ViewCount="806" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How to autocomplete filenames in sub-directories when opening them for editing using e.g. &lt;code&gt;:e &amp;lt;/path/to/file&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When opening files in sub-directories for editing using e.g. &lt;code&gt;:e &amp;lt;/path/to/file&amp;gt;&lt;/code&gt;, I often press &lt;code&gt;TAB&lt;/code&gt; multiple times to autocomplete file and/or directory names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that using &lt;code&gt;TAB&lt;/code&gt; for auto-completion, I cannot move into the targeted subdirectory. Instead subsequent &lt;code&gt;TAB&lt;/code&gt;s return filenames in the current directory cyclically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By pressing &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; and deleting it again after having auto-completed the targeted sub-directory, I'm able to move into the sub-directory and autocomplete filenames in that directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a smarter way to move into a sub-directories when &lt;code&gt;TAB&lt;/code&gt;'ing for filename auto-completion?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Targeted sub-directory&lt;/strong&gt;: &lt;code&gt;watchdog_io&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bJU9K.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bJU9K.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Targeted file in sub-directory&lt;/strong&gt;: &lt;code&gt;io.py&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/51HRw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/51HRw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26505" LastEditorUserId="10604" LastEditDate="2020-03-18T16:25:24.140" LastActivityDate="2020-03-18T16:25:24.140" Title="How to auto-complete filenames in sub-directories when opening them for editing using e.g. `:e &lt;/path/to/file&gt;`?" Tags="|autocompletion|file|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23143" PostTypeId="2" ParentId="23142" CreationDate="2020-03-09T10:44:20.677" Score="1" Body="&lt;p&gt;Put this in your .vimrc:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set path+=**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will also search in all subdirectories. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then use the &lt;code&gt;:find&lt;/code&gt; command. Start writing a part of the filename, for example...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:find io&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and then when you press Tab, it will autocomplete or offer possible matches from which you can choose. It will find io.py even if it's in a subdirectory.&lt;/p&gt;&#xA;" OwnerUserId="18912" LastActivityDate="2020-03-09T10:44:20.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23144" PostTypeId="1" CreationDate="2020-03-09T10:57:29.600" Score="1" ViewCount="39" Body="&lt;p&gt;When using plugins, splits are often created to show something, e.g. a quickfixlist or the taglist. If the split is opened (especially for horizontal splits), the original window is automatically scrolled, depending on the cursor position. If the cursor is on top (&lt;code&gt;H&lt;/code&gt;), no scrolling is done. However, if the cursor is in the middle or the bottom, the window is scrolled. I personally find this very irritating. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a generic way to prevent this automatic scrolling? A desirable solution would be to not use &lt;code&gt;H&lt;/code&gt; to get to the top and then open the split (like &lt;a href=&quot;https://stackoverflow.com/questions/12897276/how-to-prevent-vim-scrolling-when-splitting-a-window&quot;&gt;this&lt;/a&gt; or &lt;a href=&quot;https://vi.stackexchange.com/questions/2816/how-to-prevent-vim-from-scrolling-buffers-when-i-open-split&quot;&gt;that&lt;/a&gt; solution). Thanks and BR.&lt;/p&gt;&#xA;" OwnerUserId="27030" LastActivityDate="2020-03-09T10:57:29.600" Title="No automatic scrolling when opening splits" Tags="|split|scrolling|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23145" PostTypeId="1" CreationDate="2020-03-09T11:25:57.340" Score="1" ViewCount="312" Body="&lt;p&gt;Is it possible to add a thousands separator to a number or a selection of numbers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Before&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;42&#xA;4815162342&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;After&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;42&#xA;4.815.162.342&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to perform this operation quite often, which is why I would like for it to be automated and easy to repeat.&lt;/p&gt;&#xA;" OwnerUserId="25637" LastActivityDate="2020-04-08T12:00:28.573" Title="How do I add a thousand seperator to a number?" Tags="|regular-expression|substitute|number-formatting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23146" PostTypeId="2" ParentId="23145" CreationDate="2020-03-09T11:25:57.340" Score="1" Body="&lt;p&gt;As I am still relatively new to vim, if there is a better alternative or if there are improvements to be made, please do let me know.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Setup&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The solution I ended up with makes use of a regular expression that is saved to a separate &lt;code&gt;regex.vim&lt;/code&gt; file, which is sourced in &lt;code&gt;init.vim&lt;/code&gt;. The full explanation can be found here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/a/2201584/1113913&quot;&gt;Save commonly used regex patterns in Vim?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;init.vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Regular expressions&#xA;source ~/.config/nvim/regex.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;regex.vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Inserts a thousand separator after \0&#xA;let sep = 's/\d\(\%\(\d\{3\}\)\+\(\d\)\@!\)\@=/\0'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source the added &lt;code&gt;regex.vim&lt;/code&gt; before continuing.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Usage&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Upon visually selecting a number or multiple numbers with &lt;kbd&gt;v&lt;/kbd&gt;, press &lt;kbd&gt;:&lt;/kbd&gt; to enter Command-line mode.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;kbd&gt;Ctrl + r&lt;/kbd&gt;, followed by &lt;kbd&gt;=&lt;/kbd&gt; to allow for an expression to be entered. Type the name that you gave to the regular expression in &lt;code&gt;regex.vim&lt;/code&gt;, e.g. &lt;code&gt;sep&lt;/code&gt; and press &lt;kbd&gt;Enter&lt;/kbd&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As displayed below, entering any character after the above operation should add it as the separator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iDOmS.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iDOmS.gif&quot; alt=&quot;Animation showing the usage of aforementioned script&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25637" LastActivityDate="2020-03-09T11:25:57.340" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23147" PostTypeId="2" ParentId="23142" CreationDate="2020-03-09T14:04:33.913" Score="3" Body="&lt;p&gt;Don’t do the &lt;code&gt;'path'&lt;/code&gt; trick. &lt;a href=&quot;https://github.com/tpope/vim-apathy&quot; rel=&quot;nofollow noreferrer&quot;&gt;The &lt;code&gt;'path'&lt;/code&gt; option affects many of vim’s best navigational techniques.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead (and I only learned about this recently—see &lt;code&gt;:help 'wildmenu'&lt;/code&gt;), when you’re dealing with directories:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use &lt;kbd&gt;Down&lt;/kbd&gt; to “drill down” into the subdirectory and start completing filenames below&lt;/li&gt;&#xA;&lt;li&gt;use &lt;kbd&gt;Up&lt;/kbd&gt; to “move up” into the parent directory and complete filenames above&lt;/li&gt;&#xA;&lt;li&gt;use your &lt;code&gt;'wildchar'&lt;/code&gt; to cycle in the current directory (as you’ve already noted) &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-03-09T20:02:09.097" LastActivityDate="2020-03-09T20:02:09.097" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23148" PostTypeId="1" AcceptedAnswerId="23161" CreationDate="2020-03-09T14:16:01.950" Score="17" ViewCount="4350" Body="&lt;p&gt;Vim has &lt;code&gt;:sort&lt;/code&gt; command, which sorts using case-sensitive by default. I would like to sort several lines using case-insensitive. I tried using &lt;code&gt;:isort&lt;/code&gt;, however this command is not defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I have found the solution in &lt;code&gt;:help sort&lt;/code&gt;, the command is &lt;code&gt;:sort i&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="147" LastActivityDate="2020-03-10T03:15:39.880" Title="How to sort case-insensitive?" Tags="|sort|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23149" PostTypeId="1" AcceptedAnswerId="23154" CreationDate="2020-03-09T15:47:29.053" Score="1" ViewCount="547" Body="&lt;p&gt;I was reading a blog post for &lt;a href=&quot;https://medium.com/@kpereksta/setting-up-a-c-development-environment-with-vim-on-debian-ea42d5b810&quot; rel=&quot;nofollow noreferrer&quot;&gt;Settings up a C# Development Environment with Vim on Debian&lt;/a&gt; and I got most of this going except I have an issue with the &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; inoremap'ing. I am running both Vim 8.2 and NeoVim 0.4.3 on WSL on Windows 10. &lt;a href=&quot;https://github.com/OmniSharp/omnisharp-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;OmniSharp-Vim&lt;/a&gt; seems to have installed and started OmniSharp-roslyn as when I do &lt;code&gt;ps aux&lt;/code&gt; I see the &lt;code&gt;/home/user01/.cache/omnisharp-vim/omnisharp-roslyn/bin/mono /home/user01/.cache/omnisharp-vim/omnisharp-roslyn/omnisharp/OmniSharp.exe&lt;/code&gt; command running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The original line is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; pumvisible() ? '&amp;lt;C-n&amp;gt;' :                                                                                                                    &#xA;\ getline('.')[col('.')-2] =~# '[[:alnum:].-_#$]' ? '&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;' : '&amp;lt;Tab&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I thought to wrap it in an &lt;code&gt;augroup&lt;/code&gt; with an &lt;code&gt;autocmd&lt;/code&gt; so its not always running.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup phil_omnisharp_settings&#xA;  autocmd FileType cs inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; pumvisible() ? '&amp;lt;C-n&amp;gt;' : \ getline('.')[col('.')-2] =~# '[[:alnum:].-_#$]' ? '&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;' : '&amp;lt;Tab&amp;gt;'&#xA;&#xA;  &quot;autocmd FileType cs remap &amp;lt;C-o&amp;gt;&amp;lt;C-u&amp;gt; :OmniSharpFindUsages&amp;lt;CR&amp;gt;&#xA;  autocmd FileType cs nnoremap &amp;lt;C-o&amp;gt;&amp;lt;C-d&amp;gt; :OmniSharpGotoDefinition&amp;lt;CR&amp;gt;&#xA;  autocmd FileType cs nnoremap &amp;lt;C-o&amp;gt;&amp;lt;C-d&amp;gt;&amp;lt;C-p&amp;gt; :OmniSharpPreviewDefinition&amp;lt;CR&amp;gt;&#xA;  autocmd FileType cs nnoremap &amp;lt;C-o&amp;gt;&amp;lt;C-r&amp;gt; :!dotnet run&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will start as expected, but when I get to a &lt;code&gt;System.Console.&amp;lt;Tab&amp;gt;&lt;/code&gt; I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E15: Invalid expression: \ getline('.')[col('.')-2] =~# '[[:alnum:].-_#$]' ? '^X^O' : '^I'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;code&gt;System.Console.&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; sequence I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-- Omni completion (^O^N^P) Pattern not found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would just run Vim/NeoVim on Windows, but I ran into issues with neither having &lt;code&gt;+python&lt;/code&gt; or &lt;code&gt;+python3&lt;/code&gt; support enabled. Vim 8.2 had something called &lt;code&gt;+python/dyn&lt;/code&gt; enabled, which OmniSharp didn't seem to like either if I used the HTTP method, and the socket method didn't work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GitHub Gist: &lt;a href=&quot;https://gist.github.com/predatorian3/01525f9d82b71972f16882de789e6569&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gist.github.com/predatorian3/01525f9d82b71972f16882de789e6569&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11559" LastEditorUserId="11559" LastEditDate="2020-03-10T19:03:17.783" LastActivityDate="2020-04-22T00:12:25.770" Title="Vim8/NeoVim Invalid Expression remapping &lt;C-x&gt;&lt;C-o&gt; to &lt;Tab&gt; for OmniShap-vim" Tags="|vimscript|neovim|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23150" PostTypeId="1" AcceptedAnswerId="23153" CreationDate="2020-03-09T17:02:19.607" Score="0" ViewCount="694" Body="&lt;p&gt;I am using Vim 8 in WSL Ubuntu. While copying text into a file the terminal crashed. I don't believe it is the WSL as Task Manager does not show 'Not Responding'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried using &lt;a href=&quot;https://vi.stackexchange.com/questions/5354/how-do-i-close-vim-externally/5500#5500&quot;&gt;this answer&lt;/a&gt; which works on new terminals but not on the one that crashed, where it simply does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can see the unsaved text on the unresponsive terminal running Vim and the &lt;code&gt;vim -r&lt;/code&gt; command tells me &lt;code&gt;process ID: 1062 (still running)&lt;/code&gt; but when opened with the read only option the unsaved text is not there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to recover this file?&lt;/p&gt;&#xA;" OwnerUserId="27075" LastActivityDate="2020-03-14T20:49:11.933" Title="How to recover unsaved text without a swap file after Vim crashed?" Tags="|microsoft-windows|swap-file|linux-ubuntu|crash-recovery|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23151" PostTypeId="1" CreationDate="2020-03-09T18:00:04.437" Score="2" ViewCount="236" Body="&lt;p&gt;I have Vim 8.1.1 on Windows 7. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can click on the file with right mouse button, and there will be an option &quot;Edit with Vim&quot;. Then, if I click another file, there will be two options: &quot;Edit with Vim&quot; and &quot;Edit with existing Vim&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I understand, the second option should open the file as a new buffer of the existing Vim. But actually it simply does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(To open multiple files as different buffers, the following way works fine:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Select multiple files,&lt;/li&gt;&#xA;&lt;li&gt;click on them,&lt;/li&gt;&#xA;&lt;li&gt;and select &quot;Edit with single Vim&quot;. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, I'm wondering why &quot;Edit with existing Vim&quot; doesn't work as I expected.)&lt;/p&gt;&#xA;" OwnerUserId="7200" LastActivityDate="2020-03-09T18:00:04.437" Title="&quot;Edit with existing Vim&quot; - how does it work?" Tags="|gvim|microsoft-windows|multiple-files|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23153" PostTypeId="2" ParentId="23150" CreationDate="2020-03-09T18:10:44.640" Score="0" Body="&lt;p&gt;It turns out that the problem was with WSL after all. I followed &lt;a href=&quot;https://stackoverflow.com/a/58130873/9506872&quot;&gt;this answer&lt;/a&gt; and pressed &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; this made the terminal responsive again allowing me to save my file. Also here to add, fullscreen On Off shortcut F11 will always fix crash.&lt;/p&gt;&#xA;" OwnerUserId="27075" LastEditorUserId="27075" LastEditDate="2020-03-14T20:49:11.933" LastActivityDate="2020-03-14T20:49:11.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23154" PostTypeId="2" ParentId="23149" CreationDate="2020-03-09T18:12:11.433" Score="2" Body="&lt;p&gt;If you want to generate key sequences as strings, you need to use double-quoted strings and quote the &lt;code&gt;&amp;lt;&lt;/code&gt; with a backslash. Such as &lt;code&gt;&quot;\&amp;lt;C-x&amp;gt;\&amp;lt;C-o&amp;gt;&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/eval.txt.html#expr-quote&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help expr-quote&lt;/code&gt;&lt;/a&gt; for more details (single quote strings are under &lt;code&gt;:help literal-string&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; :&#xA;\ getline('.')[col('.')-2] =~# '[[:alnum:].-_#$]' ? &quot;\&amp;lt;C-x&amp;gt;\&amp;lt;C-o&amp;gt;&quot; : &quot;\&amp;lt;Tab&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-09T18:12:11.433" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="23155" PostTypeId="1" CreationDate="2020-03-09T19:16:37.330" Score="1" ViewCount="387" Body="&lt;p&gt;There are numerous occasions where you might want to have another optional argument in your snippet. Lets say I want to have a numbered list for example. Preferably I'd call something like enum3 which would&#xA;generate this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;begin{enumerate} &#xA;    \item  $1 &#xA;    \item  $2&#xA;    \item  $3&#xA;\end{enumerate}&#xA;$0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm able to get generate vim conventional placeholders like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\begin{enumerate} &#xA;    \item &amp;lt;++&amp;gt; &#xA;    \item &amp;lt;++&amp;gt;&#xA;    \item &amp;lt;++&amp;gt;&#xA;\end{enumerate}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However is there any more elegant way in ultisnips to give an arbitrary number of placeholders?&lt;/p&gt;&#xA;" OwnerUserId="27321" LastActivityDate="2020-03-09T19:16:37.330" Title="Provide arbitrary arguments to a snippet in UltiSnips" Tags="|vimscript|plugin-ultisnips|snippets|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23156" PostTypeId="1" AcceptedAnswerId="23158" CreationDate="2020-03-09T21:04:33.877" Score="1" ViewCount="391" Body="&lt;p&gt;I use the &lt;a href=&quot;https://wiki.archlinux.org/index.php/Rxvt-unicode&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;URxvt&lt;/code&gt;&lt;/a&gt; terminal emulator, and &lt;code&gt;echo $TERM&lt;/code&gt; returns &lt;code&gt;rxvt-unicode-256color&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;vim&lt;/code&gt;, if I run &lt;code&gt;:echo $TERM&lt;/code&gt;, I get the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I open a terminal window with &lt;code&gt;:term&lt;/code&gt; and enter &lt;code&gt;echo $TERM&lt;/code&gt; in that, I get just &lt;code&gt;xterm&lt;/code&gt;, which results in a non colored prompt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not that the colors are totally absent; for instance, if I enter &lt;code&gt;ls -a&lt;/code&gt;, the directories &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;..&lt;/code&gt; are colored in blue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I have &lt;code&gt;vim&lt;/code&gt; use &lt;code&gt;TERM=rxvt-unicode-256color&lt;/code&gt; for the &lt;code&gt;:terminal&lt;/code&gt; window, so that fancy coloring is available?&lt;/p&gt;&#xA;" OwnerUserId="6498" LastActivityDate="2020-03-10T00:02:49.837" Title="Setting coloring in :term on urxvt" Tags="|terminal-buffer|color|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23157" PostTypeId="1" CreationDate="2020-03-09T22:26:43.687" Score="2" ViewCount="3565" Body="&lt;p&gt;My file contains multiple blocks looking like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some Test &quot;^M&#xA;^M&#xA;^M&#xA;&quot;some more text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to remove these passages (including the &lt;code&gt;&quot;&lt;/code&gt;), but can't seem to fine the right regex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I already know about the escape sequence &lt;code&gt;^M&lt;/code&gt; and how to add it into the regex (&lt;code&gt;CTRL-V&lt;/code&gt; + &lt;code&gt;CTRL-M&lt;/code&gt;) but I struggle to find the right regex. In words the search looks like this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The passage starts and ends with the &lt;code&gt;&quot;&lt;/code&gt; character in between there are only &lt;em&gt;newlines&lt;/em&gt; and &lt;code&gt;^M&lt;/code&gt; (the actual number of characters between the &lt;code&gt;&quot;&lt;/code&gt; varies, but there is &lt;em&gt;at least one&lt;/em&gt; &lt;code&gt;^M&lt;/code&gt;). &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I was thinking about something like this &lt;code&gt;\&quot;^M\_s\+&lt;/code&gt; but this expression doesn't work. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="27325" LastEditorUserId="27325" LastEditDate="2020-03-10T12:01:38.513" LastActivityDate="2020-03-10T15:21:59.230" Title="Search for Pattern &quot;^M*&quot;" Tags="|regular-expression|search|replace|escape|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23158" PostTypeId="2" ParentId="23156" CreationDate="2020-03-10T00:02:49.837" Score="2" Body="&lt;p&gt;This is expected. Vim implements a terminal emulator for &lt;code&gt;:terminal&lt;/code&gt; (since it needs to keep it inside its window) and it implements one that's compatible with &quot;xterm&quot; (since it needs to pick a specific terminal to implement and &quot;xterm&quot; is a very popular one.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can still enable 256-color support by setting &lt;code&gt;TERM=xterm-256color&lt;/code&gt; in your Vim terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#terminal-unix&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help terminal-unix&lt;/code&gt;&lt;/a&gt;, which documents that behavior:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;&lt;code&gt;TERM&lt;/code&gt;&lt;/strong&gt;: the name of the terminal, from the &lt;code&gt;'term'&lt;/code&gt; option or &lt;code&gt;$TERM&lt;/code&gt; in the GUI; &lt;strong&gt;falls back to &quot;xterm&quot; if it does not start with &quot;xterm&quot;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(Emphasis mine.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-10T00:02:49.837" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23159" PostTypeId="2" ParentId="23157" CreationDate="2020-03-10T00:16:32.550" Score="7" Body="&lt;p&gt;Characters displayed by &lt;code&gt;^&lt;/code&gt; followed by a capital letter (or a small number of other symbols, such as &lt;code&gt;^[&lt;/code&gt;) are the usual notation for the ASCII character produced by pressing that letter while holding the &lt;kbd&gt;Control&lt;/kbd&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim will typically show these in a distinct color or highlight (to indicate it's displaying a Control-sequence and not two separate characters, the caret character followed by another character.) Furthermore, when you move the cursor through this character, the cursor will &quot;jump&quot; through the second character and will only stop on the &lt;code&gt;^&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;^M&lt;/code&gt; is actually the way to display &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;M&lt;/kbd&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But simply pressing that character while in insert mode or while entering a search term will not work, since that control character has a special purpose, which is the same as the &quot;Return&quot; character. (Many/most other control sequences have special purposes as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to be able to enter it, you need to escape it, and you can use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; for that purpose. (See &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_CTRL-V&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help c_CTRL-V&lt;/code&gt;&lt;/a&gt; for more details.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in order to search for it, you can start search with &lt;kbd&gt;/&lt;/kbd&gt;, then press &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt;, then &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;M&lt;/kbd&gt;. You'll see the &lt;code&gt;^M&lt;/code&gt; notation. You can then search for that character. It's fine to mix in other characters as part of the search expression as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(As a small aside, the &lt;code&gt;^M&lt;/code&gt; character is also a bit special because it is used in DOS line endings, so having your lines ending with a &lt;code&gt;^M&lt;/code&gt; typically indicates a DOS file format. If you have &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27fileformats%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'fileformats'&lt;/code&gt;&lt;/a&gt; include &lt;code&gt;dos&lt;/code&gt;, Vim is usually able to detect your file is using DOS fileformat and convert that from you on reading the file. You can also typically force that by using &lt;code&gt;:e ++ff=dos ...&lt;/code&gt; when reading the file, see &lt;a href=&quot;https://vimhelp.org/editing.txt.html#%2B%2Bff&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help ++ff&lt;/code&gt;&lt;/a&gt; for details.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: If you want to match this character in a regular expression, you can also use &lt;code&gt;\r&lt;/code&gt;, which is specifically for the &lt;code&gt;^M&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to match a double quote followed by a sequence of whitespace &lt;em&gt;including&lt;/em&gt; &lt;code&gt;^M&lt;/code&gt; characters, you can use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&quot;\r\_[ \t\r]\+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to replace those with a single newline after the double quote:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/&quot;\r\_[ \t\r]\+/&quot;\r/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to use a &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2Fcollection&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\_[]&lt;/code&gt; group&lt;/a&gt;, a simple &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Cs&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\_s&lt;/code&gt;&lt;/a&gt; doesn't work since &lt;code&gt;\s&lt;/code&gt; expands to &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; alone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;_&lt;/code&gt; takes care of the newline (also possible to use &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5B%5Cn%5D&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;\n&lt;/code&gt;&lt;/a&gt; inside the group), then you need to consider space and tab (&lt;code&gt;[ \t]&lt;/code&gt;), same as &lt;code&gt;\s&lt;/code&gt; would, and include &lt;code&gt;\r&lt;/code&gt; for the &lt;code&gt;^M&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that on the replacement side of a &lt;code&gt;:s&lt;/code&gt; command, &lt;code&gt;\r&lt;/code&gt; (or even &lt;code&gt;^M&lt;/code&gt; entered with &lt;code&gt;^V^M&lt;/code&gt; or &lt;code&gt;^V&lt;/code&gt;, &quot;Enter&quot;) means adding a line break! So you should use that rather than &lt;code&gt;\n&lt;/code&gt; on that side of the command. See &lt;a href=&quot;https://vimhelp.org/change.txt.html#s%2F%5Cr&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help s/\r&lt;/code&gt;&lt;/a&gt; for details on that.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-03-10T15:21:59.230" LastActivityDate="2020-03-10T15:21:59.230" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23160" PostTypeId="1" CreationDate="2020-03-10T02:56:23.153" Score="7" ViewCount="15886" Body="&lt;p&gt;In neovim, we can get default standard path via stdpath() function. I wonder if there is any way to do that in vim.&lt;/p&gt;&#xA;&lt;p&gt;below is the &lt;a href=&quot;https://neovim.io/doc/user/builtin.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;help doc about &lt;code&gt;stdpath()&lt;/code&gt;&lt;/a&gt; in neovim:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;stdpath({what})                 *stdpath()* *E6100*&#xA;        Returns |standard-path| locations of various default files and&#xA;        directories.&#xA;&#xA;        {what}       Type    Description &#xA;        cache        String  Cache directory. Arbitrary temporary&#xA;                             storage for plugins, etc.&#xA;        config       String  User configuration directory. The&#xA;                             |init.vim| is stored here.&#xA;        config_dirs  List    Additional configuration directories.&#xA;        data         String  User data directory. The |shada-file|&#xA;                             is stored here.&#xA;        data_dirs    List    Additional data directories.&#xA;&#xA;        Example:&#xA;            :echo stdpath(&amp;quot;config&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26468" LastEditorUserId="48403" LastEditDate="2023-07-28T11:52:52.813" LastActivityDate="2023-07-28T11:52:52.813" Title="Is there any similar way in vim to get standard path like neovim stdpath function" Tags="|neovim|gvim|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23161" PostTypeId="2" ParentId="23148" CreationDate="2020-03-10T03:15:39.880" Score="28" Body="&lt;p&gt;&lt;code&gt;:sort i&lt;/code&gt; - sorts case-insensitive. &lt;/p&gt;&#xA;" OwnerUserId="147" LastActivityDate="2020-03-10T03:15:39.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23162" PostTypeId="2" ParentId="16906" CreationDate="2020-03-10T09:44:08.557" Score="5" Body="&lt;p&gt;I use this &lt;code&gt;:Jsonf&lt;/code&gt; command. It's can format unicode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Jsonf :execute '%!python -c &quot;import json,sys,collections,re; sys.stdout.write(re.sub(r\&quot;\\\u[0-9a-f]{4}\&quot;, lambda m:m.group().decode(\&quot;unicode_escape\&quot;).encode(\&quot;utf-8\&quot;),json.dumps(json.load(sys.stdin, object_pairs_hook=collections.OrderedDict), indent=2)))&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27329" LastActivityDate="2020-03-10T09:44:08.557" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23163" PostTypeId="1" AcceptedAnswerId="23167" CreationDate="2020-03-10T11:02:32.710" Score="4" ViewCount="6779" Body="&lt;p&gt;I am working on a Chromebook. Mostly I code in an online IDE, which supports Vim mode, but from time to time I need full Vim support. For example, I need it to be able to use macros and filter content through typical Linux commands, e.g. &lt;code&gt;:%!sort | uniq -c | sort -n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've &lt;a href=&quot;https://www.google.com/?q=vim%20chrome%20extension&quot; rel=&quot;nofollow noreferrer&quot;&gt;searched for extensions that run Vim in Chrome&lt;/a&gt;, but looks like there are only extensions that allow navigating the page with Vim shortcuts, not the editor itself. Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="27330" LastEditorUserId="27330" LastEditDate="2020-03-10T14:40:58.050" LastActivityDate="2023-05-05T13:55:30.213" Title="How to run Vim on a Chromebook?" Tags="|macro|filter|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23164" PostTypeId="1" CreationDate="2020-03-10T11:54:02.550" Score="1" ViewCount="289" Body="&lt;p&gt;So i am using abduco.&#xA;I have an abduco session and lets say I reattach to it at a later point. Then, for some reason, I am not able to move around in vim. Specifically the mouse and the keys stop working. This can probably be fixed in abduco (I don't know though). But I did notice that if I quit vim and started it again then I was able to navigate using the keys and mouse. So I wanted to know if there was a quick way to restart vim with all the windows as they are.&lt;/p&gt;&#xA;" OwnerUserId="26043" LastActivityDate="2020-03-11T01:56:48.063" Title="How to restart vim in the state it is?" Tags="|input-devices|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23165" PostTypeId="2" ParentId="22989" CreationDate="2020-03-10T12:02:06.237" Score="2" Body="&lt;p&gt;I feel like this is all overly complicated, you can realize this with just a few lines of regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/&amp;lt;\(\w\+\)&amp;gt;\%#/&amp;amp;&amp;lt;\/\1&amp;gt;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This expression will allow you to add a closing tag after the cursor:&lt;br&gt;&#xA;- &lt;code&gt;&amp;lt;&lt;/code&gt; matches the start of the opening tag&lt;br&gt;&#xA;- &lt;code&gt;\w\+&lt;/code&gt; matches the tag content, we include it in braces so that we can use it in the replacement&lt;br&gt;&#xA;- &lt;code&gt;&amp;gt;&lt;/code&gt; matches the end of the existing tag&lt;br&gt;&#xA;- &lt;code&gt;\%#&lt;/code&gt; matches the cursor (this is specific to vim &lt;code&gt;:h ordinary-atom&lt;/code&gt;)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And for the replacement:&lt;br&gt;&#xA;- &lt;code&gt;&amp;amp;&lt;/code&gt; will repeat the whole match (so the opening tag)&lt;br&gt;&#xA;- &lt;code&gt;&amp;lt;\/&lt;/code&gt; starts the closing tag&lt;br&gt;&#xA;- &lt;code&gt;\1&lt;/code&gt; repeats what was in the braces (the tag name)&lt;br&gt;&#xA;- &lt;code&gt;&amp;gt;&lt;/code&gt; ends the closing tag&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once we're there, the tag is successfully closed, but the cursor moves! We can prevent that by setting marks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! AutoCompleteTag()&#xA;    let saveMMark = getpos(&quot;'m&quot;)&#xA;    let saveSearch = @/&#xA;&#xA;    call setpos(&quot;'m&quot;, getpos(&quot;.&quot;))&#xA;    sil! s/&amp;lt;\(\w\+\)&amp;gt;\%#/&amp;amp;&amp;lt;\/\1&amp;gt;/g&#xA;    call setpos(&quot;.&quot;, getpos(&quot;'m&quot;))&#xA;&#xA;    call setpos(&quot;'m&quot;, saveMMark)&#xA;    let @/ = saveSearch&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I also save and restore the search pattern and the &lt;code&gt;m&lt;/code&gt; cursor position there)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last small problem: you can repeat this operation an therefore close the tag multiple times... This can be prevented by... More regex!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/&amp;lt;\(\w\+\)&amp;gt;\%#\ze\(.*&amp;lt;\/\1&amp;gt;\)\@!/&amp;amp;&amp;lt;\/\1&amp;gt;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, we use &lt;code&gt;\(...\)\@!&lt;/code&gt; to say that we do &lt;strong&gt;not&lt;/strong&gt; want this&#xA;That only works if the closing tag is on the same line though, if you want to extend it to work on multiple lines, you might be interested in &lt;code&gt;searchpairpos()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for the &lt;code&gt;\@!&lt;/code&gt;, look into &lt;code&gt;:h pattern-overview&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;:&lt;br&gt;&#xA;Here's the last version of the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! AutoCompleteTag()&#xA;    let saveMMark = getpos(&quot;'m&quot;)&#xA;    let saveSearch = @/&#xA;&#xA;    call setpos(&quot;'m&quot;, getpos(&quot;.&quot;))&#xA;    sil! s/&amp;lt;\(\w\+\)&amp;gt;\%#\ze\(.*&amp;lt;\/\1&amp;gt;\)\@!/&amp;amp;&amp;lt;\/\1&amp;gt;/g&#xA;    call setpos(&quot;.&quot;, getpos(&quot;'m&quot;))&#xA;&#xA;    call setpos(&quot;'m&quot;, saveMMark)&#xA;    let @/ = saveSearch&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;C-v&amp;gt; &amp;lt;CMD&amp;gt;call AutoCompleteTag()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="27331" LastEditDate="2020-03-10T12:07:41.593" LastActivityDate="2020-03-10T12:07:41.593" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23166" PostTypeId="2" ParentId="23164" CreationDate="2020-03-10T14:54:43.327" Score="5" Body="&lt;p&gt;The best move here is to use sessions. As @Maxim Kim notes in the comments, one way to do that is with &lt;code&gt;:mksession&lt;/code&gt; and &lt;code&gt;:source Session.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'll show you two other tricks.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;vim&lt;/code&gt; has a &lt;code&gt;-S&lt;/code&gt; flag that can be used to source an arbitrary vimscript file; it &lt;em&gt;defaults&lt;/em&gt; to &lt;code&gt;Session.vim&lt;/code&gt;—so this means you can just type &lt;code&gt;vim -S&lt;/code&gt; in your shell to start back from a session!&lt;/li&gt;&#xA;&lt;li&gt;I actually use a (bash) function in my shell for this same trick:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vs () { &#xA;  if (($# &amp;gt; 0)); then&#xA;    local session=&quot;$1&quot;&#xA;    shift&#xA;    vim &quot;$@&quot; -S &quot;$session&quot;&#xA;  else&#xA;    vim -S&#xA;  fi&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;I use tpope’s &lt;a href=&quot;https://github.com/tpope/vim-obsession&quot; rel=&quot;nofollow noreferrer&quot;&gt;Obsession&lt;/a&gt; for easy session management. It has a host of benefits, but the main ones include&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;automatic session updating,&lt;/li&gt;&#xA;&lt;li&gt;saves only the relevant stuff&lt;/li&gt;&#xA;&lt;li&gt;a statusline indicator to let me know when I'm actually using a obsession session&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;From its README (10th March 2020):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Instead of making me remember to capture the session immediately before exiting Vim, allow me to do it at any time, and automatically re-invoke &lt;code&gt;:mksession&lt;/code&gt; immediately before exit.&lt;/li&gt;&#xA;  &lt;li&gt;Also invoke &lt;code&gt;:mksession&lt;/code&gt; whenever the layout changes (in particular, on &lt;code&gt;BufEnter&lt;/code&gt;), so that even if Vim exits abnormally, I'm good to go.&lt;/li&gt;&#xA;  &lt;li&gt;If I load an existing session, automatically keep it updated as above.&lt;/li&gt;&#xA;  &lt;li&gt;If I try to create a new session on top of an existing session, don't refuse to overwrite it. Just do what I mean.&lt;/li&gt;&#xA;  &lt;li&gt;If I pass in a directory rather than a file name, just create a &lt;code&gt;Session.vim&lt;/code&gt; inside of it.&lt;/li&gt;&#xA;  &lt;li&gt;Don't capture options and maps. Options are sometimes mutilated and maps just interfere with updating plugins.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Use &lt;code&gt;:Obsess&lt;/code&gt; (with optional file/directory name) to start recording to a session file and &lt;code&gt;:Obsess!&lt;/code&gt; to stop and throw it away. That's it. Load a session in the usual manner: &lt;code&gt;vim -S&lt;/code&gt;, or &lt;code&gt;:source&lt;/code&gt; it.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;There's also an indicator you can put in &lt;code&gt;'statusline'&lt;/code&gt;, &lt;code&gt;'tabline'&lt;/code&gt;, or &lt;code&gt;'titlestring'&lt;/code&gt;. See &lt;code&gt;:help obsession-status&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-03-11T01:56:48.063" LastActivityDate="2020-03-11T01:56:48.063" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="23167" PostTypeId="2" ParentId="23163" CreationDate="2020-03-10T15:00:49.763" Score="4" Body="&lt;p&gt;If you have a recent enough and powerful enough Chromebook, then you should consider &lt;a href=&quot;https://chromium.googlesource.com/chromiumos/docs/+/master/containers_and_vms.md#Quickstart&quot; rel=&quot;nofollow noreferrer&quot;&gt;Crostini&lt;/a&gt;, which can give you a Linux container running in a lean virtual machine in your Chromebook.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have an older Chromebook, you can consider &lt;a href=&quot;https://github.com/dnschneid/crouton/blob/master/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;Crouton&lt;/a&gt;, which can give you a chroot with a Linux distribution into your Chromebook.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both approaches will allow you to install a Linux distribution such as Debian or Ubuntu into your Chromebook, which will allow you to have a native Vim package which is able to spawn a shell and run all the standard Linux utilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage of the former approach, Crostini, is that you're running on a lean virtual machine that allows you to keep all your Chromebook security features enabled, so you should prefer that approach if it's available for your Chromebook.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The latter, Crouton, requires that you switch your Chromebook to developer mode. There are security implications to switching to developer mode, so make sure you understand them well. The Crouton page and wiki include pointers to information about that, so I'd recommend you start with those.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-10T15:00:49.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23168" PostTypeId="2" ParentId="13623" CreationDate="2020-03-10T15:49:53.700" Score="22" Body="&lt;p&gt;Create &lt;code&gt;~/.vim/ftdetect/SOME_EXTENSION.vim&lt;/code&gt; and add this line to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.SOME_EXTENSION set filetype=SOME_FILETYPE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if you wanted vim to use the filetype &lt;code&gt;html&lt;/code&gt; for all files with an &lt;code&gt;.Rhtml&lt;/code&gt; extension you would add this to &lt;code&gt;~/.vim/ftdetect/rhtml.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.Rhtml set filetype=html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1554" LastEditorUserId="1554" LastEditDate="2020-03-10T17:47:49.723" LastActivityDate="2020-03-10T17:47:49.723" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23170" PostTypeId="1" AcceptedAnswerId="23171" CreationDate="2020-03-11T10:19:49.590" Score="5" ViewCount="2377" Body="&lt;p&gt;I enjoy using Vim and like it better than IDEs on most points. One common IDE feature that I miss, though, is inline diff highlighting:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0KU7I.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0KU7I.png&quot; alt=&quot;Changed lines highlighted in blue, new lines in green&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;In this example changed lines are highlighted in blue and entirely new lines in green. Red for removed lines and beige for lines with changed whitespace are also common colorings. I know of tools that can show a diff in two windows, but is there any feature or plug-in that can do it like this? Preferably compared to version control.&lt;/p&gt;&#xA;" OwnerUserId="23564" LastEditorUserId="23564" LastEditDate="2020-03-11T12:08:13.713" LastActivityDate="2020-03-11T12:08:13.713" Title="IDE-like inline diff highlighting in Vim" Tags="|highlight|vimdiff|git|ide|version-control-systems|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23171" PostTypeId="2" ParentId="23170" CreationDate="2020-03-11T11:53:39.440" Score="7" Body="&lt;p&gt;You can do this with the &lt;a href=&quot;https://github.com/airblade/vim-gitgutter&quot; rel=&quot;noreferrer&quot;&gt;vim-gitgutter plugin&lt;/a&gt;. If you're not using git, then &lt;a href=&quot;https://github.com/mhinz/vim-signify&quot; rel=&quot;noreferrer&quot;&gt;Signify&lt;/a&gt; has a similar feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After installing vim-gitgutter, you can &lt;a href=&quot;https://github.com/airblade/vim-gitgutter#activation&quot; rel=&quot;noreferrer&quot;&gt;switch the highlighting on and off&lt;/a&gt; with the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;turn on with :GitGutterLineHighlightsEnable&#xA;turn off with :GitGutterLineHighlightsDisable&#xA;toggle with :GitGutterLineHighlightsToggle.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, to enable highlighting by default, &lt;a href=&quot;https://github.com/airblade/vim-gitgutter#to-turn-on-line-highlighting-by-default&quot; rel=&quot;noreferrer&quot;&gt;add the following line to your .vimrc&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:gitgutter_highlight_lines = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also &lt;a href=&quot;https://github.com/airblade/vim-gitgutter#line-highlights&quot; rel=&quot;noreferrer&quot;&gt;customize the colours used&lt;/a&gt; by &lt;a href=&quot;https://vimhelp.org/syntax.txt.html#%3Ahighlight&quot; rel=&quot;noreferrer&quot;&gt;specifying the highlighting&lt;/a&gt; for the following groups:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GitGutterAddLine          &quot; default: links to DiffAdd&#xA;GitGutterChangeLine       &quot; default: links to DiffChange&#xA;GitGutterDeleteLine       &quot; default: links to DiffDelete&#xA;GitGutterChangeDeleteLine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-03-11T11:59:23.103" LastActivityDate="2020-03-11T11:59:23.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23172" PostTypeId="1" AcceptedAnswerId="23173" CreationDate="2020-03-11T17:08:09.017" Score="2" ViewCount="185" Body="&lt;p&gt;v^ and v_ both select to the first non-blank character on the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;d^ deletes to the first non-blank character on the line, but d_ deletes the entire line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this? Is there any reason to use it over dd?&lt;/p&gt;&#xA;" OwnerUserId="26698" LastActivityDate="2020-03-11T18:20:04.797" Title="Why doesn't d_ delete to the first non-blank character on the line?" Tags="|normal-mode|operator|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23173" PostTypeId="2" ParentId="23172" CreationDate="2020-03-11T17:31:40.690" Score="5" Body="&lt;p&gt;&lt;code&gt;_&lt;/code&gt; is a &lt;strong&gt;linewise&lt;/strong&gt; motion operator (&lt;code&gt;:h linewise&lt;/code&gt;), its primary purpose is to move your cursor to &lt;code&gt;&amp;lt;count&amp;gt; - 1&lt;/code&gt; lines below your current position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;br&gt;&#xA;&lt;code&gt;5_&lt;/code&gt; will move your cursor 4 lines down&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motion to the beginning of the line is just a side effect of that move. So when you type &lt;code&gt;d_&lt;/code&gt;, the delete operation is applied from the current line to &lt;code&gt;0&lt;/code&gt; lines below the current line. Result is, the current line gets deleted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;^&lt;/code&gt; is a &lt;strong&gt;characterwise&lt;/strong&gt; motion operator (&lt;code&gt;:h characterwise&lt;/code&gt;), that's why it doesn't delete the whole line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case, since the visual mode doesn't change the text, you don't see the &lt;strong&gt;linewise&lt;/strong&gt; / &lt;strong&gt;characterwise&lt;/strong&gt; difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think &lt;code&gt;d_&lt;/code&gt; has any difference with &lt;code&gt;dd&lt;/code&gt; in terms of performances or behavior, you can use one or the other.&lt;/p&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="27331" LastEditDate="2020-03-11T18:20:04.797" LastActivityDate="2020-03-11T18:20:04.797" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23174" PostTypeId="1" AcceptedAnswerId="23176" CreationDate="2020-03-11T18:29:06.113" Score="0" ViewCount="136" Body="&lt;p&gt;There are lots of posts about how to search and replace a single column of a file, using &lt;code&gt;\%Nc&lt;/code&gt; syntax. I want extend this syntax to replace multiple columns in all lines that meet some criterion. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PWITHDRAWAL BY EFTPOS 0240331 BWS&#xA;PEFTPOS DEBIT 0000409 GROUNDS&#xA;PEFTPOS DEBIT 0074959 ASQ INTE&#xA;PWITHDRAWAL BY EFTPOS 0510811 COLES&#xA;PWITHDRAWAL BY EFTPOS 0043699 XIAN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need to modify columns 23-29 (the columns with numbers) on each line containing &lt;code&gt;WITHDRAWAL BY EFTPOS&lt;/code&gt;. Obviously there are lots of ad hoc ways to do this.   For example,&#xA;&lt;code&gt;g/PWITHDRAWAL BY EFT/s/\%23c/X&lt;/code&gt; will change column 23 in the three selected lines to &lt;code&gt;X&lt;/code&gt;.   I could repeat the command for each column that needs changing, but there's presumably something like  &lt;code&gt;g/BY EFT/s/\%23c-\%29c/X/&lt;/code&gt; that would do it in a single command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anybody advise please?&lt;/p&gt;&#xA;" OwnerUserId="4667" LastActivityDate="2020-03-11T18:45:42.017" Title="Changing multiple columns of all lines that meet a search criterion" Tags="|regular-expression|search|replace|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23176" PostTypeId="2" ParentId="23174" CreationDate="2020-03-11T18:45:42.017" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;there's presumably something like g/BY EFT/s/\%23c-\%29c/X/ that would do it in a single command.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;23-29 is the same as 7 columns/chars starting from 23.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/WITHDRAWAL BY EFT/s/\%23c.\{7\}/XXXXXXX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it's guaranteed to be the first 7-digit number in the string &quot;WITHDRAWAL&quot; you can change it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/WITHDRAWAL BY EFT/s/\d\{7\}/XXXXXXX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-03-11T18:45:42.017" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23177" PostTypeId="1" AcceptedAnswerId="23178" CreationDate="2020-03-12T01:50:13.497" Score="1" ViewCount="263" Body="&lt;p&gt;I am trying to create some keybinds (in my &lt;em&gt;.vimrc&lt;/em&gt;) for &lt;em&gt;vim&lt;/em&gt;, used from Cygwin's &lt;em&gt;mintty&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found and extended some code for the &lt;em&gt;.vimrc&lt;/em&gt; that translates the keycodes used by &lt;em&gt;mintty&lt;/em&gt; (&lt;a href=&quot;https://github.com/mintty/mintty/wiki/Keycodes&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/mintty/mintty/wiki/Keycodes&lt;/a&gt;) back into the correct input.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for [key, code] in [&#xA;        \[&quot;&amp;lt;F1&amp;gt;&quot;, &quot;\eOP&quot;],&#xA;        \[&quot;&amp;lt;F2&amp;gt;&quot;, &quot;\eOQ&quot;],&#xA;        \[&quot;&amp;lt;F3&amp;gt;&quot;, &quot;\eOR&quot;],&#xA;        \[&quot;&amp;lt;F4&amp;gt;&quot;, &quot;\eOS&quot;],&#xA;        \[&quot;&amp;lt;F5&amp;gt;&quot;, &quot;\e[15~&quot;],&#xA;        \[&quot;&amp;lt;Home&amp;gt;&quot;, &quot;\e[H&quot;],&#xA;        \[&quot;&amp;lt;End&amp;gt;&quot;, &quot;\e[F&quot;],&#xA;        \[&quot;&amp;lt;S-Up&amp;gt;&quot;, &quot;\e[1;2A&quot;],&#xA;        \[&quot;&amp;lt;S-Down&amp;gt;&quot;, &quot;\e[1;2B&quot;],&#xA;        \[&quot;&amp;lt;S-Right&amp;gt;&quot;, &quot;\e[1;2C&quot;],&#xA;        \[&quot;&amp;lt;S-Left&amp;gt;&quot;, &quot;\e[1;2D&quot;],&#xA;    \]&#xA;    execute &quot;set&quot; key.&quot;=&quot;.code&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Most of these work fine, but when I press shift and the down-arrow in insert mode, &lt;em&gt;vim&lt;/em&gt; simply prints &lt;em&gt;[1;2A&lt;/em&gt;, similar for Shift-Down. What is the problem?&lt;/p&gt;&#xA;" OwnerUserId="27367" LastEditorUserId="27367" LastEditDate="2020-03-12T04:16:30.590" LastActivityDate="2020-03-12T11:32:56.547" Title="Mapping Shift-Up &amp; Shift-Down, mintty keycodes" Tags="|key-bindings|terminal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23178" PostTypeId="2" ParentId="23177" CreationDate="2020-03-12T11:32:56.547" Score="1" Body="&lt;p&gt;I'm not familiar with mintty, but a quick google search returned the following:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;1. &lt;a href=&quot;https://github.com/mintty/mintty/wiki/Tips#unexpected-behaviour-with-certain-applications-eg-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;mintty tips&lt;/a&gt;:&lt;/h2&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h2&gt;Unexpected behaviour with certain applications (e.g. vim)&lt;/h2&gt;&#xA;  &#xA;  &lt;p&gt;If for example the PgUp and PgDn keys do not work in your editor, the&#xA;  reason may be that in the mintty Options, the Terminal Type was set to&#xA;  &quot;vt100&quot; and based on the resulting setting of the environment variable&#xA;  TERM, the application expects other key sequences than mintty sends.&#xA;  (While mintty could be changed to send VT100 application keypad codes&#xA;  in that case, the current behaviour is compatible with xterm.)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;(...)&lt;/p&gt;&#xA;  &#xA;  &lt;h3&gt;Avoiding escape timeout issues in vim&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;It’s a historical flaw of Unix terminals that the keycode of the&#xA;  escape key, i.e. the escape character, also appears at the start of&#xA;  many other keycodes. This means that on seeing an escape character, an&#xA;  application cannot be sure whether to treat it as an escape key press&#xA;  or whether to expect more characters to complete a longer keycode.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Therefore they tend to employ a timeout to decide. The delay on the&#xA;  escape key can be annoying though, particularly with the&#xA;  mode-dependent cursor above enabled. The timeout approach can also&#xA;  fail on slow connections or a heavily loaded machine.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Mintty’s “application escape key mode” can be used to avoid this by&#xA;  switching the escape key to an unambiguous keycode. Add the following&#xA;  to ~/.vimrc to employ it in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;t_ti.=&quot;\e[?7727h&quot;&#xA;let &amp;amp;t_te.=&quot;\e[?7727l&quot;&#xA;noremap &amp;lt;Esc&amp;gt;O[ &amp;lt;Esc&amp;gt;&#xA;noremap! &amp;lt;Esc&amp;gt;O[ &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h2&gt;2. possibly related question in SO: &lt;a href=&quot;https://stackoverflow.com/a/23971202/717124&quot;&gt;vim mintty/putty mapping  &lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can try to set the &lt;a href=&quot;http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;terminal's&#xA;  keycodes&lt;/a&gt;&#xA;  to vim's keycodes like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set &amp;lt;c-tab&amp;gt;=^[[1;5I&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Similar to the description of that question, you can verify what Vim receives when you press the code following the steps at &lt;a href=&quot;http://vimhelp.appspot.com/vim_faq.txt.html#faq%2d20%2e4&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Vim faq-20.4&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1405" LastActivityDate="2020-03-12T11:32:56.547" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23179" PostTypeId="1" AcceptedAnswerId="23180" CreationDate="2020-03-12T12:03:03.883" Score="22" ViewCount="5499" Body="&lt;p&gt;I know you would normally enter into vimdiff mode from the terminal with&#xA;&lt;code&gt;vimdiff file1 file2&lt;/code&gt;. However, I frequently find myself already in vim with multiple different splits, and I'd like to run vimdiff on two specific splits, and then turn vimdiff off. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I go about this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;N.B. there might be other splits in my vim session that I don't want to be comparing. So I might have 4 vertical splits and I want to run vimdiff on split 1 with split 3, look at some differences, and then turn the diff off.&lt;/p&gt;&#xA;" OwnerUserId="27376" LastActivityDate="2022-08-10T05:00:57.440" Title="How do I enter into vimdiff mode given two splits are already open?" Tags="|vimdiff|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23180" PostTypeId="2" ParentId="23179" CreationDate="2020-03-12T12:08:22.880" Score="24" Body="&lt;p&gt;The command is called &lt;code&gt;:diffthis&lt;/code&gt;. It must be executed in every window you want to add to the comparison. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The inverse is &lt;code&gt;:diffoff&lt;/code&gt; which exits diff mode in the current window. To exit diff mode in all applicable windows add a &lt;em&gt;bang&lt;/em&gt;: &lt;code&gt;:diffoff!&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="11054" LastEditDate="2020-03-13T07:55:47.970" LastActivityDate="2020-03-13T07:55:47.970" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23181" PostTypeId="1" CreationDate="2020-03-12T13:58:23.937" Score="14" ViewCount="19474" Body="&lt;p&gt;I'm using the &lt;a href=&quot;https://github.com/psf/black&quot; rel=&quot;noreferrer&quot;&gt;psf/black&lt;/a&gt; plugin, I install and load it with vimplug: &lt;code&gt;Plug 'psf/black'&lt;/code&gt;&#xA;and I use it with &lt;code&gt;&amp;lt;leader&amp;gt;f&lt;/code&gt;: &lt;code&gt;autocmd FileType python nmap &amp;lt;leader&amp;gt;f :Black&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use and prefer 2 space indentation with JavaScript (Prettier), Python and most of the other programming languages I use, that's why I have the following in my init.vim (nvim config):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    set ignorecase&#xA;    set smartcase&#xA;    filetype plugin indent on&#xA;    &quot; show existing tab with 2 spaces width&#xA;    &quot; delete 2 spaces on backspace&#xA;    set softtabstop=2&#xA;    &quot; when indenting with '&amp;gt;', use 2 spaces width&#xA;    set shiftwidth=2&#xA;    &quot; On pressing tab, insert 2 spaces&#xA;    set expandtab&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't get the Black plugin to indent 2 spaces instead of 4, I have  tried making an .editorconfig file with &lt;code&gt;indent_size = 2&lt;/code&gt; and it didn't work.&lt;/p&gt;&#xA;" OwnerUserId="20087" LastActivityDate="2021-02-18T18:40:06.350" Title="How can I configure Black the python code formatter to indent 2 spaces instead of 4?" Tags="|neovim|filetype-python|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23182" PostTypeId="2" ParentId="23181" CreationDate="2020-03-12T13:58:23.937" Score="4" Body="&lt;p&gt;It looks like the Black Python code formatter &lt;a href=&quot;https://github.com/psf/black/issues/378#issuecomment-400112373&quot; rel=&quot;nofollow noreferrer&quot;&gt;intentionally&lt;/a&gt; does not allow you to configure whether to use 2 or 4 spaces, &#xA;which makes me wonder why, I can't imagine this change requiring anything other than a minimal change to the code,&#xA;the lack of the explanation to why they are not and won't support it makes me think that it is not a matter of religiously sticking to a subset of PEP8 (which recommended 4 spaces, in 2001) but a matter of enforcing their personal preference on the world.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like the forks that implemented this feature are abandoned or not as maintained as the upstream repository.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'd recommend to keep using this plugin and use a simple command that replaces each 4 spaces at the beginning of each line with 2. which its implementation turned out to be suspiciously simple:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import pynvim&#xA;import re&#xA;&#xA;&#xA;@pynvim.plugin&#xA;class Iindent(object):&#xA;  &quot;&quot;&quot; Iindent plugin: Black can't stop me from using 2 spaces &quot;&quot;&quot;&#xA;  def __init__(self, nvim):&#xA;    self.nvim = nvim&#xA;    self.pattern = re.compile(r&quot;^(\s\s\s\s)+&quot;)&#xA;&#xA;  @pynvim.command(&quot;Iindent&quot;, nargs=&quot;*&quot;, range=&quot;&quot;)&#xA;  def iindent(self, args, range):&#xA;    buffer = self.nvim.current.buffer&#xA;    new_buffer = []&#xA;    for line in buffer:&#xA;      x = self.pattern.search(line)&#xA;      if x:&#xA;        _, end = x.span()&#xA;        line = re.sub(self.pattern, &quot; &quot; * int(end / 2), line)&#xA;      new_buffer += [line]&#xA;      print(line)&#xA;    buffer[:] = new_buffer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it uses and depends on &lt;a href=&quot;https://github.com/neovim/pynvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;pynvim&lt;/a&gt;, install it with pip &lt;code&gt;pip install --user pynvim&lt;/code&gt; or better yet install it with your distro's package manager which upgrades it with vim automatically for you, I use Arch so I installed it with &lt;code&gt;Sudo pacman -S python-pynvim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;make a directory for this new plugin in the plugged directory which is in your vim config directory:&#xA;&lt;code&gt;mkdir -p ~/.vim/plugged/iindent/rplugin/python3&lt;/code&gt;&#xA;make a new python file in it:&#xA;&lt;code&gt;touch ~/.vim/plugged/iindent/rplugin/python3/iindent.py&lt;/code&gt;&#xA;and add to it the code above, then install with vimplug/your-plugin-manager by adding &lt;code&gt;Plug '~/.vim/plugged/iindent'&#xA;&lt;/code&gt; to your vim config and running &lt;code&gt;:UpdateRemotePlugins&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then change your &lt;code&gt;&amp;lt;leader&amp;gt;f&lt;/code&gt; keybinding command to run this command after Black:&#xA;&lt;code&gt;autocmd FileType python nmap &amp;lt;leader&amp;gt;f :Black&amp;lt;CR&amp;gt; :Iindent&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a down-side to this approach is that it adds an extra indentation change to history in-addition-to/after the formatter change, however the upside is that you keep using the maintained plugin and formatter.&lt;/p&gt;&#xA;" OwnerUserId="20087" LastEditorUserId="20087" LastEditDate="2020-03-12T14:15:23.177" LastActivityDate="2020-03-12T14:15:23.177" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23184" PostTypeId="1" AcceptedAnswerId="23185" CreationDate="2020-03-13T02:41:24.863" Score="3" ViewCount="292" Body="&lt;p&gt;&lt;code&gt;:find&lt;/code&gt; and &lt;code&gt;:edit&lt;/code&gt; both edit files and appear to need the relative or absolute path provided if the file isn't in the current directory.  What is the extra part that &lt;code&gt;:find&lt;/code&gt; brings?  What is &lt;code&gt;'path'&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Help for &lt;code&gt;:find&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:fin[d][!] [++opt] [+cmd] {file}&lt;br&gt;&#xA;                          Find {file} in 'path' and then :edit it.&lt;br&gt;&#xA;                          {not in Vi} {not available when the +file_in_path&lt;br&gt;&#xA;                          feature was disabled at compile time}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Help for &lt;code&gt;:edit&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;:e[dit] [++opt] [+cmd] {file}&lt;br&gt;&#xA;                          Edit {file}.&lt;br&gt;&#xA;                          This fails when changes have been made to the current&lt;br&gt;&#xA;                          buffer, unless 'hidden' is set or 'autowriteall' is&lt;br&gt;&#xA;                          set and the file can be written.&lt;br&gt;&#xA;                          Also see ++opt and +cmd.&lt;br&gt;&#xA;                          {Vi: no ++opt}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="27388" LastActivityDate="2020-03-13T05:40:38.943" Title="What is the difference between :find and :edit" Tags="|find|edit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23185" PostTypeId="2" ParentId="23184" CreationDate="2020-03-13T04:25:12.513" Score="5" Body="&lt;p&gt;The difference is that &lt;code&gt;:find&lt;/code&gt; will actually &lt;em&gt;search&lt;/em&gt; for a file by that name in the list of directories specified in &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27path%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'path'&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default &lt;code&gt;'path'&lt;/code&gt; contains &lt;code&gt;.&lt;/code&gt; (which is the path of the &lt;em&gt;current&lt;/em&gt; file), then &lt;code&gt;/usr/include&lt;/code&gt; (on Unix platforms, like Linux and Mac OS) and then an &quot;empty&quot; entry, corresponding to the current directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which means if you're editing &lt;code&gt;src/main/main.c&lt;/code&gt; and you use &lt;code&gt;:find args.c&lt;/code&gt;, Vim will first search for it in &lt;code&gt;src/main/&lt;/code&gt;, which makes the default useful when you open many files in the same directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You notice your file includes &lt;code&gt;&amp;lt;stdio.h&amp;gt;&lt;/code&gt; and you would like to open this header file, then &lt;code&gt;:find stdio.h&lt;/code&gt; will find that in the system include directory. (An especially useful shortcut to this one is &lt;a href=&quot;https://vimhelp.org/editing.txt.html#gf&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;gf&lt;/code&gt;&lt;/a&gt;, which will &lt;code&gt;:find&lt;/code&gt; the file name under the cursor, also using &lt;code&gt;'path'&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, if you use a path relative to the current directory, one that will work with &lt;code&gt;:edit&lt;/code&gt;, it will also work with &lt;code&gt;:find&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And the behavior of &lt;code&gt;:find&lt;/code&gt; can be easily customized, by changing &lt;code&gt;'path'&lt;/code&gt; to a setting that's more appropriate for your filetype (programming language) and specific project, to make it really easy to navigate between related files and browse files in a runtime's standard library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give you some ideas of how powerful &lt;code&gt;'path'&lt;/code&gt; can be, consider these settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set path=.git/..;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will traverse &lt;em&gt;up&lt;/em&gt; the tree, trying to find a &lt;code&gt;.git&lt;/code&gt; directory, then use the parent of that directory. In other words, this simple expression will look for the root of your git checkout and allow you to use &lt;code&gt;:find&lt;/code&gt; to access paths relative to this directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another powerful example is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set path=**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will traverse &lt;em&gt;down&lt;/em&gt; the tree and allow you to open a file under any subdirectory in the tree. (Note that you should &lt;em&gt;avoid&lt;/em&gt; this setting, it's preferable to have &lt;code&gt;'path'&lt;/code&gt; set in a semantically appropriate way for your language and/or project, which allows you to quickly access &lt;em&gt;included&lt;/em&gt; files following the same path search as the language.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to consider enhancing this experience with plug-ins, in which case some recommendations are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tpope/vim-apathy&quot; rel=&quot;noreferrer&quot;&gt;apathy.vim&lt;/a&gt;: Set &lt;code&gt;'path'&lt;/code&gt; and friends for languages such as C, Python, JavaScript and Go.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tpope/vim-projectionist&quot; rel=&quot;noreferrer&quot;&gt;projectionist.vim&lt;/a&gt;: Understands your project's paths and sets &lt;code&gt;'path'&lt;/code&gt; appropriately.&lt;/li&gt;&#xA;&lt;li&gt;Other language-specific plug-ins, such as &lt;a href=&quot;https://github.com/vim-ruby/vim-ruby&quot; rel=&quot;noreferrer&quot;&gt;vim-ruby&lt;/a&gt; for the Ruby language.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-03-13T05:40:38.943" LastActivityDate="2020-03-13T05:40:38.943" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23186" PostTypeId="1" AcceptedAnswerId="23187" CreationDate="2020-03-13T18:04:11.783" Score="1" ViewCount="690" Body="&lt;p&gt;I am trying to add some custom highlighting to my Vim. But my regex matching is not working correctly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let ignoreHiInComments = '^\s*\(\/\/.*\)\@&amp;lt;!'    &quot;Ignore highlighting in C++ comments&#xA;call matchadd('UserTypes', ignoreHiInComments.'\zs\w\+\ze::.\+')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will do the following highlighting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myclass::myclass() {}     // Correctly highlights &quot;myclass&quot; and not &quot;::myclass()&quot;  &#xA;myclass::~myclass() {}    // Correctly highlights &quot;myclass&quot; and not &quot;::~myclass()&quot;&#xA;bool myclass::myfunc() {}  // Does not highlight &quot;myclass&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I change out &lt;code&gt;\w&lt;/code&gt; with &lt;code&gt;.&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call matchadd('UserTypes', ignoreHiInComments.'\zs.\+\ze::.\+')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I get this highlighting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myclass::myclass() {}      // Correctly highlights &quot;myclass&quot; and not &quot;::myclass()&quot;&#xA;myclass::~myclass() {}     // Correctly highlights &quot;myclass&quot; and not &quot;::~myclass()&quot;&#xA;bool myclass::myfunc() {}  // Highlights all of &quot;bool myclass&quot;, this is incorrect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I try to match whole words like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call matchadd('UserTypes', ignoreHiInComments.'\&amp;lt;\zs.\+\ze::.\+\&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I get this result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myclass::myclass() {}     // Correctly highlights &quot;myclass&quot; and not &quot;::myclass()&quot;  &#xA;myclass::~myclass() {}    // Correctly highlights &quot;myclass&quot; and not &quot;::~myclass()&quot;&#xA;bool myclass::myfunc() {}  // Does not highlight &quot;myclass&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have also tried adding various white space matching elements to my regex, but it hasn't worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me understand what I am doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="20186" LastActivityDate="2020-03-13T19:06:52.843" Title="Regex missing matching words" Tags="|syntax-highlighting|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23187" PostTypeId="2" ParentId="23186" CreationDate="2020-03-13T19:02:15.537" Score="2" Body="&lt;p&gt;From &lt;code&gt;pattern.txt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                            */\@&amp;lt;!*&#xA;\@&amp;lt;!    Matches with zero width if the preceding atom does NOT match just&#xA;before what follows.  Thus this matches if there is no position in the&#xA;current or previous line where the atom matches such that it ends just&#xA;before what follows.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the word &lt;strong&gt;atom&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The definition of atom:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                        */atom*&#xA;An atom can be one of a long list of items.  Many atoms match one character&#xA;in the text.  It is often an ordinary character or a character class.&#xA;Braces can be used to make a pattern into an atom.  The &quot;\z(\)&quot; construct&#xA;is only for syntax highlighting.&#xA;&#xA;   atom    ::=      ordinary-atom&#xA;        or  \( pattern \)&#xA;        or  \%( pattern \)&#xA;        or  \z( pattern \)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus, &lt;code&gt;\@&amp;lt;!&lt;/code&gt; only affect the atom &lt;code&gt;\(\/\/.*\)&lt;/code&gt; in &lt;code&gt;ignoreHiInComments&lt;/code&gt; and the &lt;code&gt;^\s*&lt;/code&gt; part must be matched, which is not what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix it, you can either let the atom include more (&lt;code&gt;\(^\s*\/\/.*\)\@&amp;lt;!&lt;/code&gt;), or simply delete &lt;code&gt;^\s*&lt;/code&gt; (&lt;code&gt;\(\/\/.*\)\@&amp;lt;!&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="25618" LastActivityDate="2020-03-13T19:02:15.537" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23188" PostTypeId="2" ParentId="23186" CreationDate="2020-03-13T19:06:52.843" Score="1" Body="&lt;p&gt;The problem is with the &lt;code&gt;^\s*&lt;/code&gt; in &lt;code&gt;ignoreHiInComments&lt;/code&gt;, that's outside of the negative look-behind match, so it will always only match from the first word of the line since it needs to match &lt;code&gt;^\s*&lt;/code&gt; first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did you mean to include that inside the negative look-behind match?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let ignoreHiInComments = '\(^\s*\/\/.*\)\@&amp;lt;!' &quot;Ignore highlighting in C++ comments &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will work, but only when the comment is the only thing in the line. So it should fix a case such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// bool myclass::myfunc won't be highlighted.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But won't work for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myclass::myclass() {} // myclass::myclass constructor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In which case both will be highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to just drop the &lt;code&gt;^\s*&lt;/code&gt; altogether, though this might potentially give you trouble if &lt;code&gt;//&lt;/code&gt; happens inside a string, which would mean it's not really a comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, hopefully these pointers are enough to help you figure out which match is right for your particular use case.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-13T19:06:52.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23189" PostTypeId="1" CreationDate="2020-03-13T20:30:18.953" Score="1" ViewCount="653" Body="&lt;p&gt;Using  Vim 8.0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to make a table where the first column is the name of a file and the second column the creation date of such file, to which I have access by the exif data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to achieve this in one line, just to learn how.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I'm using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:!ls&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get all the filenames I'll be working with. (If I want to filter .pdf files from this, how can I grep them out?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I would like to run something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:read !exif -t 0x9003 -m&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(which writes the date in the next line) but having the output append to the same line where the filename is, leaving a space or comma to separate the columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Was thinking that maybe I should write the ouput of &lt;code&gt;!exif -t 0x9003 -m&lt;/code&gt; to a register &lt;code&gt;@a&lt;/code&gt; and then use &lt;code&gt;:normal $a&amp;lt;C-R&amp;gt;a&lt;/code&gt; to append it, but, again, failed to figure out how to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another idea was to use &lt;code&gt;:execute ':normal A ' . &quot;foo&quot;&lt;/code&gt; ,this almost works, but cannot figure out a way to use the output of &lt;code&gt;exif&lt;/code&gt; instead of &quot;foo&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much.&lt;/p&gt;&#xA;" OwnerUserId="25077" LastActivityDate="2021-08-06T10:02:31.647" Title="How can I make external command use current line as input and append output to end of same line?" Tags="|normal-mode|external-command|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23190" PostTypeId="2" ParentId="23189" CreationDate="2020-03-13T20:50:51.703" Score="1" Body="&lt;p&gt;There are two ways to approach this. Go heavy on the Vim or do what a rational person would do in the real world: lean heavily on the shell and let it do all the work as that's its strength. Though this is Vi/Vim SE I'm going to be contrarian and show the practical solution. ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say you use Bash and you want to run &lt;code&gt;exif&lt;/code&gt; on all PNG files in a certain directory. One way is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for f in ~/images/*.png; do&#xA;    printf &quot;%s : %s\n&quot; &quot;$f&quot; &quot;$(exif -t XXX -m &quot;$f&quot;)&quot;&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key to this one is the &quot;process substitution&quot; feature &lt;code&gt;$(exif -t XXX -m &quot;$f&quot;)&lt;/code&gt;. You'll get each PNG file name followed by a &lt;code&gt;:&lt;/code&gt; and then the &lt;code&gt;exif&lt;/code&gt; command output for that file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can just cram that all on a Vim command line like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r !for f in ~/images/*.png; do printf &quot;\%s : \%s\n&quot; &quot;$f&quot; &quot;$(exif &quot;$f&quot;)&quot;; done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that you have to escape &lt;code&gt;%&lt;/code&gt; here as otherwise Vim interprets them as special characters.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can put those shell commands in a script and just do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:r !myscript.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW, if you want to loop over all files in a dir except PDFs then you can use &lt;code&gt;for f in ~/images/*.!(pdf)&lt;/code&gt; but you'll need to first enable that syntax with &lt;code&gt;shopt -s extglob&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-03-13T20:59:30.560" LastActivityDate="2020-03-13T20:59:30.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23191" PostTypeId="2" ParentId="23189" CreationDate="2020-03-13T21:10:53.400" Score="1" Body="&lt;p&gt;Since the bulk of the action is happening on external commands here, using a shell script is probably most appropriate in this particular case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do want to execute this inside Vim, then using the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#system%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;system()&lt;/code&gt;&lt;/a&gt; function is a great way to execute an external command and get the result into a string. (You can then use &lt;code&gt;trim()&lt;/code&gt; to remove the trailing newline. You can also use &lt;code&gt;shellescape()&lt;/code&gt; to escape filenames to safely pass them as arguments to the external command.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To modify lines in place, I'd recommend using a &lt;code&gt;:s&lt;/code&gt; command, in particular using &lt;a href=&quot;https://vimhelp.org/change.txt.html#sub-replace-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\=&lt;/code&gt;&lt;/a&gt; in the replacement part to use the result of a Vimscript expression as the replacement. You can then use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#submatch%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;submatch(0)&lt;/code&gt;&lt;/a&gt; to access the original matched text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you can use &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Avglobal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:v&lt;/code&gt;&lt;/a&gt; to exclude the lines which have filenames with the &lt;code&gt;.pdf&lt;/code&gt; extension.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:v/\.pdf$/s/.\+/\=submatch(0).&quot;\t&quot;.trim(system(&quot;exif -t 0x9003 -m &quot;.shellescape(submatch(0))))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will append the EXIF info to the lines with the filenames, using a Tab character as a separator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assumes your input was acquired with &lt;code&gt;:0read !ls&lt;/code&gt; or similar, the buffer has a list of filenames to handle. Empty lines will be skipped by the &lt;code&gt;.\+&lt;/code&gt; match, so they're ok too.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-13T21:10:53.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23192" PostTypeId="1" CreationDate="2020-03-13T22:46:18.340" Score="2" ViewCount="293" Body="&lt;p&gt;I need to be able to run vi on a machine that I access through Citrix lite in the browser.  However I've come across a number of problems because of conflicts around &lt;kbd&gt;esc&lt;/kbd&gt; and &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;w&lt;/kbd&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, although I am trying to have vi revert to command mode or another window operation, the browser intercepts &lt;kbd&gt;esc&lt;/kbd&gt; as having by focusing to the URL bar or leaving fullscreen, and &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;w&lt;/kbd&gt; to close the tab.  Maybe there is some kind of remapping plugin for either chrome or firefox that addresses this, or is there any other strategy that vi users adopt?&lt;/p&gt;&#xA;" OwnerUserId="27399" LastEditorUserId="1238" LastEditDate="2020-03-14T00:16:33.533" LastActivityDate="2020-03-14T00:31:48.990" Title="escape, ctrl-w through citrix lite in browser" Tags="|key-bindings|tab-characters|escape|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23193" PostTypeId="2" ParentId="23192" CreationDate="2020-03-14T00:31:48.990" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Maybe there is some kind of remapping plugin for either chrome or firefox that addresses this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Regarding Citrix, Citrix Lite and the browser, you'll have more luck asking about it on &lt;a href=&quot;https://superuser.com/&quot;&gt;Superuser&lt;/a&gt;, so I suggest you post a question there for a solution from that front.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there any other strategy that vi users adopt?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You should be able to use Vim mappings to work around this issue, remapping keys that don't conflict with your browser to replace or supplement the ones that don't work for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the &quot;Escape&quot; key, you usually need it when you're in Insert mode, so it might be tricky to find a mapping for it, since most keystrokes are typically inserted... There is a common practice of using the sequence &quot;jk&quot; as a replacement for &quot;Escape&quot;, since the &quot;jk&quot; sequence usually results in no motion in Normal mode (move down one line, then back up one line) and the sequence &quot;jk&quot; is uncommon in most languages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create a mapping from &quot;jk&quot; to do the same as the &quot;Escape&quot; key in Insert mode with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap jk &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add this same command into your &lt;code&gt;_vimrc&lt;/code&gt; file. In that case, you can omit the &lt;code&gt;:&lt;/code&gt; from the beginning of the line. (See also &lt;a href=&quot;https://learnvimscriptthehardway.stevelosh.com/chapters/10.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Training your fingers&quot;&lt;/a&gt; from &quot;Learn Vimscript The Hard Way&quot; by Steve Losh for more on the motivations for the &lt;code&gt;jk&lt;/code&gt; mapping, if you're interested.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another alternative is to remap a keystroke that doesn't usually produce output, such as a key sequence involving the &quot;Control&quot; key, or perhaps one of the F-keys such as F1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also two options that might work out of the box, without any special configuration. One is that the sequence &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; is equivalent to &quot;Escape&quot; in Vim. It's possible that your browser in your platform is not trapping &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; the same way it's catching &lt;kbd&gt;Esc&lt;/kbd&gt;, so if that's the case, you could use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;[&lt;/kbd&gt; on Vim through Citrix. If this works, it will be &lt;em&gt;exactly equivalent&lt;/em&gt; to the &quot;Escape&quot; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt;. This keystroke is also used in Vim to leave Insert mode, so you can also typically use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; instead of &lt;kbd&gt;Esc&lt;/kbd&gt;. Note that this is &lt;em&gt;not&lt;/em&gt; exactly equivalent to the behavior of &quot;Esape&quot;, there are some cases where the behavior of &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; and &lt;kbd&gt;Esc&lt;/kbd&gt; are &lt;em&gt;slightly&lt;/em&gt; different. But the difference is quite small, so in most cases you should be fine. (As one example, if you use a &quot;count&quot; with the command you use to enter Insert mode, when you leave it with &lt;kbd&gt;Esc&lt;/kbd&gt; the count will be respected and the insertion will be repeated, while &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;C&lt;/kbd&gt; will cancel the count and simply leave Insert mode without executing the repetition.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Regarding &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt;, for window operations, you can use a simple Normal mode mapping. One that's easy to remember and convenient is to use &lt;code&gt;&amp;lt;Leader&amp;gt;w&lt;/code&gt;. The default configuration has &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; set to &lt;kbd&gt;\&lt;/kbd&gt;, the backslash key. You can configure such a mapping with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Leader&amp;gt;w &amp;lt;C-w&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this mapping in place, you can then use &lt;kbd&gt;\&lt;/kbd&gt;, &lt;kbd&gt;w&lt;/kbd&gt; wherever you were using &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;W&lt;/kbd&gt;. For example, to switch to the next window in the list, use &lt;kbd&gt;\&lt;/kbd&gt;, &lt;kbd&gt;w&lt;/kbd&gt;, &lt;kbd&gt;w&lt;/kbd&gt;. To switch to the window below this one, &lt;kbd&gt;\&lt;/kbd&gt;, &lt;kbd&gt;w&lt;/kbd&gt;, &lt;kbd&gt;j&lt;/kbd&gt;. To move the current window, turn it into the leftmost window in the display, &lt;kbd&gt;\&lt;/kbd&gt;, &lt;kbd&gt;w&lt;/kbd&gt;, &lt;kbd&gt;H&lt;/kbd&gt;. And so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same as above, you can make this setting permanent by adding it to your &lt;code&gt;_vimrc&lt;/code&gt;, in which case you can omit the initial &lt;code&gt;:&lt;/code&gt;, it's not needed in that context.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-14T00:31:48.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23196" PostTypeId="1" CreationDate="2020-03-14T08:06:26.557" Score="0" ViewCount="1019" Body="&lt;p&gt;I have this string :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;content htp://ww.mySite.com/image/123kw9ykjm-065n/640/568/25452583.suite /&amp;gt;meta property=&amp;quot;twitter:suite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and I want to get the link to add it in a list;&lt;/p&gt;&#xA;&lt;p&gt;Here is my function :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function MyCodeSource()&#xA;    execute &amp;quot;normal! gg&amp;quot; &#xA;    let myList = [] &#xA;    silent! exe '%s/\&amp;lt;https.*suite/\=add(myList, submatch(0))/gn'&#xA;    execute &amp;quot;normal! u&amp;quot; &#xA;    echo myList&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The result is :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;htp://ww.mySite.com/image/123kw9ykjm-065n/640/568/25452583.suite /&amp;gt;meta property=&amp;quot;twitter:suite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;instead of :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;htp://ww.mySite.com/image/123kw9ykjm-065n/640/568/25452583.suite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Can you help me to get this link alone, please?&lt;/p&gt;&#xA;" OwnerUserId="26872" LastEditorUserId="10604" LastEditDate="2020-12-09T15:53:35.147" LastActivityDate="2020-12-09T15:53:35.147" Title="Searching between two words" Tags="|regular-expression|search|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23197" PostTypeId="2" ParentId="23196" CreationDate="2020-03-14T13:04:18.577" Score="0" Body="&lt;p&gt;You could just use \ze after suite, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;silent! exe '%s/\&amp;lt;https.*suite\ze/\=add(myList, submatch(0))/gn'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will set the end of the match at that position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:help /\ze&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27411" LastActivityDate="2020-03-14T13:04:18.577" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23198" PostTypeId="1" AcceptedAnswerId="23203" CreationDate="2020-03-14T13:55:53.480" Score="3" ViewCount="1155" Body="&lt;p&gt;I am trying to output the contents of a file opened in vim ex mode to stdout.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi -es +'%write !tee' +'q' ./testfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, it does not write anything, although if I open the file in ex mode, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi -e ./testfile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and issue the same command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%write !tee&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then the file contents are shown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, there are other vi commands I would issue before writing to stdout but first I would like to make this one work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I also tried the &lt;code&gt;print&lt;/code&gt; and &lt;code&gt;list&lt;/code&gt; commands, however, they replace tabs (and I want to keep them as they are in the file).&lt;/p&gt;&#xA;" OwnerUserId="27202" LastActivityDate="2020-05-29T22:30:21.890" Title="vim ex mode write to stdout" Tags="|ex-mode|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23199" PostTypeId="2" ParentId="23196" CreationDate="2020-03-14T13:58:24.217" Score="1" Body="&lt;p&gt;The problem you're having is that it's matching all the way to the &lt;em&gt;last&lt;/em&gt; occurrence of the pattern &lt;code&gt;suite&lt;/code&gt; on the line.&lt;/p&gt;&#xA;&lt;p&gt;To solve that, you can either use a non-greedy multi or you can restrict your match to non-whitespace characters only.&lt;/p&gt;&#xA;&lt;p&gt;A non-greedy multi such as &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%7B-&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\{-}&lt;/code&gt;&lt;/a&gt; would solve your issue:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;\{-}&lt;/code&gt; matches 0 or more of the preceding atom, as few as possible.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This would match only until the &lt;em&gt;first&lt;/em&gt; occurrence of &lt;code&gt;suite&lt;/code&gt; in the line:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/\&amp;lt;https.\{-}suite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Another approach is to use &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5CS&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\S&lt;/code&gt;&lt;/a&gt; instead of &lt;code&gt;.&lt;/code&gt; in your match, to match on non-whitespace characters only.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/\&amp;lt;https\S*suite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;That would prevent the regex from going past the whitespace coming after the URL, which would also solve the problem.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-12-09T14:47:26.267" LastActivityDate="2020-12-09T14:47:26.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23200" PostTypeId="1" AcceptedAnswerId="23201" CreationDate="2020-03-14T15:28:33.730" Score="3" ViewCount="1077" Body="&lt;p&gt;Let's say I have my directory/file tree as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&#xA;|_home&#xA;  |_myPC&#xA;    |_script.sh&#xA;    |_test.sh&#xA;|_etc&#xA;  |_log.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm working on &lt;code&gt;script.sh&lt;/code&gt; and Vim has nothing like &lt;code&gt;firejail&lt;/code&gt; to stop it from accessing stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, I'm able to, with &lt;a href=&quot;https://vimawesome.com/plugin/ctrlp-vim-everything-has-changed&quot; rel=&quot;nofollow noreferrer&quot;&gt;ctrlp&lt;/a&gt;, auto-complete with stuff already in &lt;code&gt;script.sh&lt;/code&gt;. However, when I type &lt;code&gt;cat ~/t&lt;/code&gt; and use &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; (with ctrlp), I want it to auto-complete to &lt;code&gt;cat ~/test.sh&lt;/code&gt; or offer that. However, ctrlp alone only seems to access stuff already in &lt;code&gt;script.sh&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make Vim auto-complete with the system file tree? Is there a plugin for that?&lt;/p&gt;&#xA;" OwnerUserId="25859" LastActivityDate="2020-03-15T13:06:08.373" Title="How to make Vim autocomplete with file system?" Tags="|autocompletion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23201" PostTypeId="2" ParentId="23200" CreationDate="2020-03-14T15:57:54.873" Score="4" Body="&lt;p&gt;You can use &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; to enter filename completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim will understand the partial path already typed and offer you suggestions from paths in the filesystem. You can use the usual &lt;code&gt;&amp;lt;C-p&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; to navigate the completion menu, also &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; works the same as &lt;code&gt;&amp;lt;C-n&amp;gt;&lt;/code&gt; in this specific menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you pick a directory name, you can use an additional &lt;code&gt;&amp;lt;C-x&amp;gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; to start completing the next path component, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt; to accept the current entry and leave completion, or &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; to cancel it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't actually need any plug-ins, this is all a built-in feature of Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/insert.txt.html#compl-filename&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help compl-filename&lt;/code&gt;&lt;/a&gt; for filename completion in specific, though you might want to have a look at the whole &lt;a href=&quot;https://vimhelp.org/insert.txt.html#ins-completion&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ins-completion&lt;/code&gt;&lt;/a&gt; for a more complete overview of insert mode completion in Vim.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="10604" LastEditDate="2020-03-15T13:06:08.373" LastActivityDate="2020-03-15T13:06:08.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23202" PostTypeId="2" ParentId="23019" CreationDate="2020-03-14T19:30:55.167" Score="0" Body="&lt;p&gt;Maybe you can use &lt;code&gt;:set cot=&lt;/code&gt;. To know more info see &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27cot%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;cot&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23663" LastEditorUserId="23663" LastEditDate="2020-03-15T06:40:26.833" LastActivityDate="2020-03-15T06:40:26.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23203" PostTypeId="2" ParentId="23198" CreationDate="2020-03-15T05:26:20.070" Score="2" Body="&lt;p&gt;This is a hack but if a direct solution can't be found perhaps it will do (I have an idea of how to do it purely with vim but need to try it later).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the &lt;em&gt;print&lt;/em&gt; command &lt;code&gt;:[range][p]rint [flags]&lt;/code&gt; with &lt;code&gt;l&lt;/code&gt; as a flag. This will replace tabs with &lt;code&gt;^I&lt;/code&gt; (two characters). Then use &lt;code&gt;sed&lt;/code&gt; to replace with actual tabs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to output an entire file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; vim -e -s -c'%p l|q!' foo.txt | sed 's/^I/\t/g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The &lt;code&gt;-s&lt;/code&gt; (silent mode) flag keeps the screen from jumping.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Okay, I'm not seeing any simple way to do this. Almost everything strips the tabs. Best I can come up with is still hacky but at least it's pure vim. It'll only work with *nix systems with the special file &lt;code&gt;/dev/stdout&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a custom function. One approach is to put it in a file and source it. Here's the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! DumpToStdout()&#xA;    redi! &amp;gt; /dev/stdout&#xA;    for line in getline(1, '$')&#xA;        echo line&#xA;    endfor&#xA;    redi END&#xA;endfunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I put it in, say, &lt;code&gt;dump.vim&lt;/code&gt; then the &lt;code&gt;vim&lt;/code&gt;/&lt;code&gt;ex&lt;/code&gt; command is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -e -S dump.vim -s -c 'call DumpToStdout()' -c 'q!' foo.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Actually, you could probably cram the function contents into the command line and avoid the need for the extra file but...yuck.)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-03-15T16:50:40.350" LastActivityDate="2020-03-15T16:50:40.350" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="23204" PostTypeId="1" AcceptedAnswerId="23211" CreationDate="2020-03-15T16:00:32.607" Score="5" ViewCount="858" Body="&lt;p&gt;When a vim plugin is developed in a mixed script of vim script and python, can we set breakpoints and debug the python script. I tried to use &lt;a href=&quot;https://docs.python.org/3/library/pdb.html&quot; rel=&quot;noreferrer&quot;&gt;PDB&lt;/a&gt; module, but vim is dead when it go to the &lt;code&gt;pdb.set_trace()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This post -- &lt;a href=&quot;http://candidtim.github.io/vim/2017/08/11/write-vim-plugin-in-python.html&quot; rel=&quot;noreferrer&quot;&gt;Writing Vim plugin in Python&lt;/a&gt; -- says &quot;You can test and debug it outside Vim with whatever tools you typically use.&quot; But when the python script &lt;code&gt;import vim&lt;/code&gt;, it cannot run outside Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I'm not asking how I can debug python code in vim like a python IDE. When I google for my question, all I got is to answer this different question. :(&lt;/p&gt;&#xA;" OwnerUserId="26468" LastActivityDate="2020-03-16T13:35:13.613" Title="Can I set breakpoint in a vim plugin script written in python?" Tags="|vimscript|gvim|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23205" PostTypeId="1" AcceptedAnswerId="23207" CreationDate="2020-03-16T02:47:16.173" Score="1" ViewCount="471" Body="&lt;p&gt;With other text editors, if you press Home, it first takes you to the indent,&#xA;then all the way to the left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible with Vim?&lt;/p&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="1238" LastEditDate="2020-03-19T20:13:56.397" LastActivityDate="2020-04-22T04:01:01.700" Title="Create a mapping for a &quot;smart&quot; Home key" Tags="|vimrc|key-bindings|indentation|functions|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23206" PostTypeId="2" ParentId="23205" CreationDate="2020-03-16T03:41:18.870" Score="1" Body="&lt;p&gt;Yes, it is possible to create a mapping for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, a mapping that will go to the indent if you're elsewhere in the line, but go to the first character if you're on the indent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap  &amp;lt;expr&amp;gt; &amp;lt;Home&amp;gt; col('.') == match(getline('.'), '\S') + 1 ? &quot;\&amp;lt;Home&amp;gt;&quot; : &quot;^&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;Home&amp;gt; col('.') == match(getline('.'), '\S') + 1 ? &quot;\&amp;lt;Home&amp;gt;&quot; : &quot;\&amp;lt;C-O&amp;gt;^&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first mapping will work in Normal, Visual and Select modes. The second will work in Insert mode. Both use the &lt;code&gt;^&lt;/code&gt; command to go to the indent, only the Insert mode mapping uses a &lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt; prefix to run just that motion in Normal mode, before returning to Insert mode at the new location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior of these mappings when you're at the indent is to just use the original behavior of &lt;code&gt;&amp;lt;Home&amp;gt;&lt;/code&gt;, exactly as Vim implements it by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mappings use &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mappings to evaluate a Vimscript expression. In this case, they're looking at whether the current column (&lt;code&gt;col('.')&lt;/code&gt;) matches the first non-blank character of the line (we use a &lt;code&gt;match()&lt;/code&gt; with a regular expression matching a non-blank &lt;code&gt;'\S'&lt;/code&gt; to locate that column.) Based on whether these two match or not, we decide how to behave and which keys to emulate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These mappings create a kind of &quot;toggle&quot; behavior, since from the indent you go to the beginning of the line and from the beginning of the line you go to the indent, so pressing &lt;code&gt;&amp;lt;Home&amp;gt;&lt;/code&gt; repeatedly will toggle between the two locations. (If you wanted a different behavior, it should be easy to modify the mappings to adapt to your exact requirements.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this command will break the undo tree when used, but that's also the default behavior of &lt;code&gt;&amp;lt;Home&amp;gt;&lt;/code&gt; in Insert mode, so I imagine that's acceptable.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-16T03:41:18.870" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23207" PostTypeId="2" ParentId="23205" CreationDate="2020-03-16T04:07:16.817" Score="0" Body="&lt;p&gt;This is what I came up with. It is not as short as other options, but seems to&#xA;do the job:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func Cursor()&#xA;   let n_cur = col('.') - 1&#xA;   let n_ind = indent(line('.'))&#xA;   return [n_cur, n_ind]&#xA;endfunc&#xA;&#xA;func Home()&#xA;   let [n_cur, n_ind] = Cursor()&#xA;   if n_cur &amp;gt; n_ind&#xA;      normal ^&#xA;   else&#xA;      normal 0&#xA;   endif&#xA;endfunc&#xA;&#xA;nmap &amp;lt;Home&amp;gt; :call Home()&amp;lt;CR&amp;gt;&#xA;imap &amp;lt;Home&amp;gt; &amp;lt;C-O&amp;gt;:call Home()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="7184" LastEditDate="2020-04-22T04:01:01.700" LastActivityDate="2020-04-22T04:01:01.700" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23208" PostTypeId="1" AcceptedAnswerId="23209" CreationDate="2020-03-16T04:44:58.040" Score="2" ViewCount="207" Body="&lt;p&gt;I'm trying to modify my filetype.vim such that it highlights a unified diff file with diff syntax, overriding whatever syntax is normally associated with the file's extension.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, I'm just trying to see if the first line in the file begins with &lt;code&gt;---&lt;/code&gt;. However, what I have will treat the file as a diff if &lt;em&gt;any&lt;/em&gt; line begins with &lt;code&gt;---&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *&#xA;  \ if search('^---', &quot;n&quot;) |&#xA;  \   set filetype=diff |&#xA;  \ endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried various combinations of setting the cursor position, adding a stop parameter to &lt;code&gt;search&lt;/code&gt;, but nothing I've tried works.&lt;/p&gt;&#xA;" OwnerUserId="27424" LastActivityDate="2020-03-16T13:31:14.007" Title="How can I write a filetype plugin that evaluates the first lines of the file?" Tags="|search|filetype|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23209" PostTypeId="2" ParentId="23208" CreationDate="2020-03-16T05:19:21.607" Score="2" Body="&lt;p&gt;One simple tweak is to use &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#start-of-file&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\%^&lt;/code&gt;&lt;/a&gt; which only matches at the start of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll also want to pass &lt;code&gt;search()&lt;/code&gt; a &lt;code&gt;'c'&lt;/code&gt; flag, to match at the current cursor position (which should be the start of the file.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *&#xA;  \ if search('\%^---', &quot;cn&quot;) |&#xA;  \   set filetype=diff |&#xA;  \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another option would be to use &lt;code&gt;getline(1)&lt;/code&gt; to get the contents of the first line only and then use &lt;code&gt;match()&lt;/code&gt; on it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if match(getline(1), '^---') &amp;gt;= 0 | ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use the pattern matching operator &lt;a href=&quot;https://vimhelp.org/eval.txt.html#expr-%3D%7E%23&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;=~#&lt;/code&gt;&lt;/a&gt; instead of &lt;code&gt;match()&lt;/code&gt;. (The &lt;code&gt;#&lt;/code&gt; at the end makes it case insensitive, which doesn't matter much in this example but it's a good practice to use it explicitly.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if getline(1) =~# '^---' | ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Either should be fine for your use case.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-03-16T13:31:14.007" LastActivityDate="2020-03-16T13:31:14.007" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23210" PostTypeId="2" ParentId="23205" CreationDate="2020-03-16T11:45:55.953" Score="1" Body="&lt;p&gt;I have &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp/blob/master/plugin/homeLikeVC%2B%2B.vim#L61&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; since 2002 it seems&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also handles &lt;code&gt;&amp;lt;end&amp;gt;&lt;/code&gt; key&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; &amp;lt;c-o&amp;gt;@=&amp;lt;SID&amp;gt;HomeLikeVCpp()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; @=&amp;lt;SID&amp;gt;HomeLikeVCpp()&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;Home&amp;gt; @=&amp;lt;SID&amp;gt;HomeLikeVCpp()&amp;lt;cr&amp;gt;&#xA;&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;@=&amp;lt;SID&amp;gt;EndLikeVCpp()&amp;lt;cr&amp;gt;a&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt; @=&amp;lt;SID&amp;gt;EndLikeVCpp()&amp;lt;cr&amp;gt;&#xA;vnoremap &amp;lt;silent&amp;gt; &amp;lt;End&amp;gt; @=&amp;lt;SID&amp;gt;EndLikeVCpp()&amp;lt;cr&amp;gt;&#xA;&#xA;function! s:HomeLikeVCpp()&#xA;  let ll = strpart(getline('.'), -1, col('.'))&#xA;  if ll =~ '^\s\+$' | return '0'&#xA;  else              | return '^'&#xA;  endif&#xA;endfunction&#xA;&#xA;&#xA;function! s:EndLikeVCpp()&#xA;  let l = strpart(getline('.'), col('.')-1)&#xA;  let ll = match(l, '^\S\s*$')&#xA;&#xA;  if getline('.') =~ '^\s*$'&#xA;    if col('.') + (mode()!='v') == col('$') | return 'g_'&#xA;    else                                    | return '$'&#xA;    endif&#xA;  else&#xA;    if ll &amp;gt;= 0 | return '$'&#xA;    else       | return 'g_'&#xA;    endif&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2020-03-16T11:45:55.953" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23211" PostTypeId="2" ParentId="23204" CreationDate="2020-03-16T13:35:13.613" Score="4" Body="&lt;p&gt;I find a way myself -- a python module &lt;a href=&quot;https://pypi.org/project/rpdb/&quot; rel=&quot;nofollow noreferrer&quot;&gt;rpdb - remote debugger based on pdb&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works for me. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Install using &lt;code&gt;pip install rpdb&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Set breakpoint with &lt;code&gt;rpdb.set_trace()&lt;/code&gt; in plugin python script.&lt;/li&gt;&#xA;&lt;li&gt;Try to active the plugin in vim. The vim will hang-up.&lt;/li&gt;&#xA;&lt;li&gt;Use telnet to connect the vim process. &lt;code&gt;telnet localhost 4444&lt;/code&gt;. It will be same as &lt;code&gt;pdb&lt;/code&gt; to use.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="26468" LastActivityDate="2020-03-16T13:35:13.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23212" PostTypeId="1" CreationDate="2020-03-16T21:39:48.470" Score="0" ViewCount="128" Body="&lt;p&gt;I have a line in my vimrc that enables me to save and run python program in a single click while it's opened:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F9&amp;gt; :w &amp;lt;bar&amp;gt; :exec '!python3' shellescape(@%, 1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can also call vim to open a folder in navigation/explorer mode that lets me edit files in that folder. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim folder&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I open a python file in that folder in vim by hitting enter and hit F9 to save and run the file, vim does not go back to the shell (zsh) and display results, which it usually does.&#xA;How can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="27429" LastEditorUserId="10604" LastEditDate="2020-03-16T23:22:51.463" LastActivityDate="2020-03-17T00:58:08.893" Title="&lt;buffer&gt; mapping after opening file from Netrw" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23213" PostTypeId="2" ParentId="23212" CreationDate="2020-03-16T23:26:12.503" Score="2" Body="&lt;p&gt;I suspect, but cannot confirm because information is missing, that the line is &quot;bare&quot; in the OP's vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means it would execute, no matter what, for the first buffer vim opens. Because of &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;, that mapping is &lt;em&gt;only&lt;/em&gt; available in that buffer!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you should put the mapping in &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F9&amp;gt; :write &amp;lt;bar&amp;gt; :exec '!python3' shellescape(@%, 1)&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But note that you can also use &lt;code&gt;&amp;lt;LocalLeader&amp;gt;&lt;/code&gt; instead of &lt;code&gt;&amp;lt;F9&amp;gt;&lt;/code&gt; to have special &quot;local&quot; maps (I find it hard to remember what function keys do what)—I do this when I have similar mappings for many filetypes. For examples, &lt;code&gt;&amp;lt;LocalLeader&amp;gt;t&lt;/code&gt; is my &quot;run tests&quot; mapping, but what it actually does is different depending on the filetype.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-03-17T00:58:08.893" LastActivityDate="2020-03-17T00:58:08.893" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23214" PostTypeId="2" ParentId="22895" CreationDate="2020-03-17T12:59:39.450" Score="2" Body="&lt;p&gt;This is a normal behaviour of gui flavours of vim like gvim. &lt;code&gt;&amp;lt;m-i&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;a-i&amp;gt;&lt;/code&gt; and &lt;code&gt;é&lt;/code&gt; are the same thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually people aren't bothered by meta+key inserting an accentuated character, but the other way around. See the very old issue with French people needing to insert &lt;code&gt;é&lt;/code&gt; in LaTeX document which in turn triggers &lt;code&gt;\item&lt;/code&gt; insertion (IIRC) with vim-latex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My opinion on the subject: don't bother with it and learn not to type &lt;code&gt;&amp;lt;m-o&amp;gt;&lt;/code&gt; needlessly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: while I was looking for the recent discussion I've seen in my mailbox on this topic, I've found the vim &lt;a href=&quot;https://webcache.googleusercontent.com/search?q=cache:q4EcJkfOtEMJ:https://github.com/vim/vim/issues/5644&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue # 5644&lt;/a&gt; that OP has probably initiated (given the timestamps). Why is this question active today?&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2020-03-17T12:59:39.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23215" PostTypeId="1" AcceptedAnswerId="23216" CreationDate="2020-03-18T03:08:04.297" Score="1" ViewCount="1002" Body="&lt;p&gt;In writing markdown files, I may use code blocks with ``` and `. Is there a way I can use code highlighting and checking on just the code blocks inside markdown files?&lt;/p&gt;&#xA;" OwnerUserId="25859" LastActivityDate="2020-03-18T04:29:31.167" Title="How to use code highlighting and checking in markdown?" Tags="|syntax-highlighting|filetype-markdown|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23216" PostTypeId="2" ParentId="23215" CreationDate="2020-03-18T04:17:34.423" Score="5" Body="&lt;p&gt;If you use default markdown filetype which is bundled with vim (tpope's markdown):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;make sure you have &lt;code&gt;let g:markdown_fenced_languages = ['dart', 'python', 'ruby', 'go']&lt;/code&gt; in your vimrc. This is the list of vim filetypes to be highlighted in markdown. Of course, your list would be different.&lt;/li&gt;&#xA;&lt;li&gt;in your markdown file use code blocks with filetypes.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;```python&#xA;def hello():&#xA;    print(&quot;hello world&quot;)&#xA;```&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KGbrT.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KGbrT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-03-18T04:29:31.167" LastActivityDate="2020-03-18T04:29:31.167" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23217" PostTypeId="1" AcceptedAnswerId="23218" CreationDate="2020-03-18T09:20:45.853" Score="2" ViewCount="1028" Body="&lt;p&gt;I'm now using Vim 8 and its new feature: &lt;code&gt;:term&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, it's great but I don't know how to move the cursor out of the terminal without the mouse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim 7, we can type &lt;code&gt;&amp;lt;C-w&amp;gt;&amp;lt;C-h&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C-w&amp;gt;&amp;lt;C-l&amp;gt;&lt;/code&gt; etc to move the cursor quickly, but now when the cursor has been in the terminal, it doesn't seem there is some good way to move the cursor quickly...&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-03-18T10:29:31.293" Title="How to move the cursor out of the terminal" Tags="|terminal|cursor-movement|vim-windows|vim8|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23218" PostTypeId="2" ParentId="23217" CreationDate="2020-03-18T10:29:31.293" Score="2" Body="&lt;p&gt;See &lt;code&gt;:h Terminal-mode&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Terminal-Job and Terminal-Normal mode &#xA;                                                Terminal-mode Terminal-Job&#xA;When the job is running the contents of the terminal is under control of the&#xA;job.  That includes the cursor position.  Typed keys are sent to the job.&#xA;The terminal contents can change at any time.  This is called Terminal-Job&#xA;mode.&#xA;&#xA;Use CTRL-W N (or 'termwinkey' N) to switch to Terminal-Normal mode.  Now the&#xA;contents of the terminal window is under control of Vim, the job output is&#xA;suspended.  CTRL-\ CTRL-N does the same.&#xA;&#xA;[...]&#xA;&#xA;                                                Terminal-Normal E946&#xA;In Terminal-Normal mode you can move the cursor around with the usual Vim&#xA;commands, Visually mark text, yank text, etc.  But you cannot change the&#xA;contents of the buffer.  The commands that would start insert mode, such as&#xA;'i' and 'a', return to Terminal-Job mode.  The window will be updated to show&#xA;the contents of the terminal. :startinsert is ineffective.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, you can do &lt;code&gt;&amp;lt;C-w&amp;gt;N&lt;/code&gt;, then &lt;code&gt;&amp;lt;C-w&amp;gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, though it isn't mentioned in the quoted section, &lt;code&gt;&amp;lt;C-w&amp;gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; cycles through windows even when started from Terminal mode.&lt;/p&gt;&#xA;" OwnerUserId="205" LastActivityDate="2020-03-18T10:29:31.293" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23219" PostTypeId="1" CreationDate="2020-03-18T12:17:23.423" Score="1" ViewCount="202" Body="&lt;p&gt;For more than a year, I have &lt;code&gt;unmap &amp;lt;C-X&amp;gt;&lt;/code&gt; in my .vimrc because I can't figure out where this mapping comes from. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used &lt;code&gt;verbose map &amp;lt;C-X&amp;gt;&lt;/code&gt; as suggested in another topic, it returns &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;v  &amp;lt;C-X&amp;gt;        &quot;*d&lt;/code&gt; &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and I don't know what that means. There is nothing that maps &lt;code&gt;&amp;lt;C-X&amp;gt;&lt;/code&gt; to anything in my .vimrc, yet that &lt;code&gt;unmap&lt;/code&gt; command doesn't even give an error, which means it's mapped somehow.&lt;/p&gt;&#xA;" OwnerUserId="27443" LastEditorUserId="1238" LastEditDate="2020-03-19T20:14:18.173" LastActivityDate="2024-03-26T11:08:46.153" Title="Can't figure out where this mapping comes from" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="23220" PostTypeId="1" CreationDate="2020-03-18T13:38:56.087" Score="1" ViewCount="1147" Body="&lt;p&gt;I would like to have the behavior where I can run &lt;code&gt;:Vex&amp;lt;CR&amp;gt;&lt;/code&gt; when pressing &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; in normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Tab&amp;gt; :Vex&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... to open the netrw file tree window and then I would like to close this window when I press &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; again in any other window in this tab. Is there some way how I can get the window ID when opening the netrw window and then close it by its ID in the same tab?&lt;/p&gt;&#xA;" OwnerUserId="17840" LastActivityDate="2021-02-09T18:41:36.870" Title="How to close the netrw buffer/window from any other window" Tags="|key-bindings|buffers|vim-windows|netrw|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23221" PostTypeId="2" ParentId="23220" CreationDate="2020-03-18T13:53:56.797" Score="0" Body="&lt;p&gt;The best I could come up with for now. It does not respect the current tab page yet, but maybe this could be achieved with using some kind of map data structure&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Tab&amp;gt; :call OpenNetRW()&amp;lt;CR&amp;gt;&#xA;&#xA;let g:netrw_buffer=0&#xA;&#xA;function OpenNetRW()&#xA;  Vexplore&#xA;  let g:netrw_buffer=bufnr(&quot;%&quot;)&#xA;  nnoremap &amp;lt;Tab&amp;gt; :call CloseNetRW()&amp;lt;CR&amp;gt;&#xA;endfunction&#xA;&#xA;function CloseNetRW()&#xA;  exe &quot;bd&quot;.g:netrw_buffer&#xA;  let g:netrw_buffer=0&#xA;  nnoremap &amp;lt;Tab&amp;gt; :call OpenNetRW()&amp;lt;CR&amp;gt;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17840" LastEditorUserId="17840" LastEditDate="2020-03-19T14:20:21.840" LastActivityDate="2020-03-19T14:20:21.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23223" PostTypeId="1" CreationDate="2020-03-18T14:13:03.177" Score="7" ViewCount="5428" Body="&lt;p&gt;I am getting an error message about my terminal setting when I start Vim, but it just appears on the screen for a second, so it is hard to read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;:messages&lt;/code&gt; but it is not shown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can get access to the message text?&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="1238" LastEditDate="2020-03-19T20:14:14.787" LastActivityDate="2020-03-19T20:14:14.787" Title="How can I show the error messages that may appear at startup?" Tags="|error|" AnswerCount="0" CommentCount="4" ClosedDate="2022-12-16T23:11:57.573" ContentLicense="CC BY-SA 4.0" />
  <row Id="23224" PostTypeId="2" ParentId="14907" CreationDate="2020-03-18T15:58:49.813" Score="2" Body="&lt;p&gt;Almost all the proposed solutions try to execute or not execute the code if the plugin is loaded or not. But I think that what you want is to execute some action when the plugin gets loaded. So it is not a matter of not executing the code, but executing it at the right moment.&#xA;According to Plug documentation, when the plugin is loaded an &lt;code&gt;User&lt;/code&gt; event with the name of the plugin is triggered, then you can use that event in autocmd commands.&#xA;For example, in my case I want to execute the register function of the plugin called &lt;code&gt;vim-wich-key&lt;/code&gt;. My Vimrc is split into several files, but I will put everything togheter in this example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }&#xA;&#xA;autocmd! User vim-which-key call which_key#register('&amp;lt;Space&amp;gt;', &quot;g:which_key_map&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, the plugin is loaded on the first call to one of it's functions and my register call only happens when the plugin gets loaded. I verified that this works perfectly.&lt;/p&gt;&#xA;" OwnerUserId="27445" LastActivityDate="2020-03-18T15:58:49.813" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23225" PostTypeId="1" CreationDate="2020-03-18T18:43:48.630" Score="2" ViewCount="144" Body="&lt;p&gt;I am trying to do a diff between a couple of csv files. I have performed &lt;code&gt;column -t -s&quot;,&quot;&lt;/code&gt; on both the files to be able to compare better. The first row contains the column names and I want to lock it when I do vimdiff on the two files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did vimdiff on the two files and then &lt;code&gt;:1sp&lt;/code&gt; on both the split windows to see the first row. When I do &lt;code&gt;$&lt;/code&gt; I am able to move to the end of the line and all the splits move together. I can see the last column name. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I move to the next page, the first line of the page gets displayed in the 1sp windows instead of the column names. I need the column names (first line of the file) to be fixed there with horizontal scrolling and no vertical scrolling so that the column name remains there when I move to the bottom of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried various versions of &lt;code&gt;:set noscb&lt;/code&gt; and &lt;code&gt;:set scrollopt-=ver&lt;/code&gt;, &lt;code&gt;:set scrollopt=hor&lt;/code&gt;, &lt;code&gt;:set scrollopt=&lt;/code&gt;, &lt;code&gt;:set scrollopt=hor,jump&lt;/code&gt; but no luck. Has anyone faced this issue?&lt;/p&gt;&#xA;" OwnerUserId="25561" LastActivityDate="2020-03-18T18:43:48.630" Title="Lock the first line when doing diff between two files in vimdiff" Tags="|vimdiff|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23226" PostTypeId="2" ParentId="63" CreationDate="2020-03-18T19:54:52.923" Score="2" Body="&lt;p&gt;I'll mostly second &lt;a href=&quot;https://vi.stackexchange.com/a/134/10604&quot;&gt;@janos's answer&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I learned vim by&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Running &lt;code&gt;vimtutor&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Deciding I would program exclusively in vim&lt;/li&gt;&#xA;&lt;li&gt;Reading &lt;code&gt;:help&lt;/code&gt; top-to-bottom&lt;/li&gt;&#xA;&lt;li&gt;Continuing to program exclusively in vim&lt;/li&gt;&#xA;&lt;li&gt;Reading &lt;a href=&quot;http://vimcasts.org/publications/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Practical Vim by Drew Neil&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;More programming in vim&lt;/li&gt;&#xA;&lt;li&gt;&amp;amp;c.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I now spend a lot of time on &lt;a href=&quot;https://vi.stackexchange.com&quot;&gt;Vi &amp;amp; Vim&lt;/a&gt;, as well as writing VimScript.&lt;/p&gt;&#xA;&lt;p&gt;I'll add that my choice to program in vim led to learning the ins-and-outs of other tools (e.g., &lt;code&gt;make&lt;/code&gt;, &lt;code&gt;javac&lt;/code&gt;) to facilitate my programming. I also developed a strong value for good CLI tooling and now have a gut instinct for the quality of CLI programs (hint: I always ask myself, &amp;quot;Could I use this from Vim? And would it be &lt;em&gt;easy&lt;/em&gt;?&amp;quot;). In the same way, I've developed a gut instinct for the quality of vim plugins: I much prefer those that enhance existing behavior or fit nicely into vim's concepts (e.g., operators and motions) over those that seek to retrofit other concepts on top of vim. (This purism is not for everyone, and is not even the most extreme vi(m)-purism out there. It works for me, though, because I like the language of vim, and want my commands and plugin mappings to make sense in the context of vim.)&lt;/p&gt;&#xA;&lt;p&gt;I don't live in vim. I live in a terminal (usually in tmux). But I am in-and-out of vim all day long, and that makes a difference for learning how to use it.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;One last piece of advice: make it easy to get into vim. Here's a short listing of code that has helped me along the way.&lt;/p&gt;&#xA;&lt;h3&gt;Shell functions&lt;/h3&gt;&#xA;&lt;p&gt;Most up-to-date is always in &lt;a href=&quot;https://github.com/benknoble/Dotfiles/blob/master/links/bash/vim.bash&quot; rel=&quot;nofollow noreferrer&quot;&gt;my Dotfiles&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;v() {&#xA;  vim &amp;quot;$@&amp;quot;&#xA;}&#xA;&#xA;vv() {&#xA;  vim +'edit $MYVIMRC' &amp;quot;$@&amp;quot;&#xA;}&#xA;&#xA;vq() {&#xA;  if (($# &amp;gt; 0)); then&#xA;    vim -q &amp;lt;(&amp;quot;$@&amp;quot; 2&amp;gt;&amp;amp;1)&#xA;  else&#xA;    printf '%s\n' 'Usage: vq cmd' '' 'Use {cmd} output as quickfix list'&#xA;  fi&#xA;}&#xA;&#xA;vf() {&#xA;  if (($# &amp;gt; 0)); then&#xA;    vim $(&amp;quot;$@&amp;quot;)&#xA;  else&#xA;    printf '%s\n' 'Usage: vf cmd' '' 'Use {cmd} output as filenames' \&#xA;      'Brittle: {cmd} output will be word-split'&#xA;  fi&#xA;}&#xA;&#xA;vff() {&#xA;  if (($# == 1)) ; then&#xA;    # equivalent to vf ack -g &amp;quot;$1&amp;quot;&#xA;    vim $(ack -g &amp;quot;$1&amp;quot;)&#xA;  else&#xA;    printf '%s\n' 'Usage: vff filename' '' 'Find {filename} to edit' \&#xA;      'Relies on ack(1)'&#xA;  fi&#xA;}&#xA;&#xA;vc() {&#xA;  if (($# &amp;gt; 0)); then&#xA;    if pushd &amp;quot;$1&amp;quot; &amp;gt;/dev/null ; then&#xA;      # ${@[0]} = $0 = name&#xA;      # ${@[1]} = $1 = directory&#xA;      # ${@:2}  = remaining args&#xA;      vim &amp;quot;${@:2}&amp;quot;&#xA;      # this must work because pushd succeeded&#xA;      popd &amp;gt;/dev/null&#xA;    fi&#xA;  else&#xA;    printf '%s\n' 'Usage: vc dir [args]' '' 'Execute vim in {dir}'&#xA;  fi&#xA;}&#xA;&#xA;vs() {&#xA;  if (($# &amp;gt; 0)); then&#xA;    local session=&amp;quot;$1&amp;quot;&#xA;    shift&#xA;    vim &amp;quot;$@&amp;quot; -S &amp;quot;$session&amp;quot;&#xA;  else&#xA;    vim -S&#xA;  fi&#xA;}&#xA;&#xA;# Start vim with its last cursor position&#xA;lvim() {&#xA;  vim +'normal '&amp;quot;'&amp;quot;'0' &amp;quot;$@&amp;quot;&#xA;}&#xA;&#xA;vh() {&#xA;  vim +&amp;quot;help $*&amp;quot; +only&#xA;}&#xA;&#xA;vgrep() {&#xA;  local pattern=&amp;quot;${1////\\/}&amp;quot;&#xA;  for f in &amp;quot;${@:2}&amp;quot; ; do&#xA;    if [[ -f &amp;quot;$f&amp;quot; ]]; then&#xA;      ex -N -i NONE -n -- &amp;quot;$f&amp;quot; &amp;lt;&amp;lt;&amp;lt;&amp;quot;argdo global/$pattern/print&amp;quot; \&#xA;        | sed &amp;quot;s/^/${f////\\/}:/&amp;quot;&#xA;    # else&#xA;    #   printf '%s\n' &amp;quot;${FUNCNAME[0]}: $f: Is a directory&amp;quot; &amp;gt;&amp;amp;2&#xA;    fi&#xA;  done&#xA;}&#xA;&#xA;vw() {&#xA;  if [[ &amp;quot;$(type -t &amp;quot;$@&amp;quot;)&amp;quot; != file ]]; then&#xA;    printf '%s\n' 'Usage: vw cmd' '' 'edit file defining {cmd}'&#xA;  else&#xA;    vim &amp;quot;$(command -v &amp;quot;$@&amp;quot;)&amp;quot;&#xA;  fi&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Shell variables&lt;/h3&gt;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;EDITOR=vim&#xA;VISUAL=vim&#xA;MANPAGER=vim -M +MANPAGER -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Tmux bindings&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;# create a throwaway vim&#xA;bind-key v new-window -a vim&#xA;bind-key V command-prompt -p 'vim +' { new-window -a vim +&amp;quot;%%&amp;quot; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-09-06T15:42:05.430" LastActivityDate="2020-09-06T15:42:05.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23227" PostTypeId="1" CreationDate="2020-03-19T01:02:05.690" Score="1" ViewCount="4227" Body="&lt;p&gt;I've been using vim for 3 years and this is the first time I hear about this mode. This is also quite embarrassing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea what did I type, I didn't intend to enter this mode. Vim will write to the buffer every single keystroke or mouse input that I do: if I click, I see a &lt;code&gt;^[[&amp;lt;0;84;22m^[[&amp;lt;0;84;22M&lt;/code&gt; on the screen. If I type ANYTHING, it's be written to the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried doing &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;q&lt;/kbd&gt;, &lt;kbd&gt;CTRL&lt;/kbd&gt;+&lt;kbd&gt;e&lt;/kbd&gt;, etc..  Literally &lt;kbd&gt;CTRL&lt;/kbd&gt;+ every single key in the keyboard, and also every single key without &lt;kbd&gt;CTRL&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have unsaved changes, is there a way for me to save and restart neovim?&lt;/p&gt;&#xA;" OwnerUserId="9717" LastEditorUserId="1238" LastEditDate="2020-03-19T20:14:00.420" LastActivityDate="2020-03-19T20:14:00.420" Title="Stuck on X mode (INSERT COMPL), how do I quit?" Tags="|ins-completion|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23228" PostTypeId="1" CreationDate="2020-03-19T01:54:20.000" Score="2" ViewCount="63" Body="&lt;p&gt;Movement and actions using &lt;code&gt;)&lt;/code&gt; and &lt;code&gt;(&lt;/code&gt; are very powerful: I use them all the time. However, when writing and editing LaTeX, I have run into the following problem: vim cannot recognize the end of some LaTeX sentences. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-latex prettyprint-override&quot;&gt;&lt;code&gt;This is a test. This is only a test. Instead, according to Gottlieb, Socrates&#xA;has two audiences, the in-crowd and the outsiders.\footcite[][278]{gottlieb-1992}&#xA;The in-crowd know what Socrates means, but Socrates deceives the outsiders. I am&#xA;still testing. Test?\footcite[Blah, blah][456]{gottlieb-1992} Moar testing.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you see it? The end of the first sentence is, well, kind of at &lt;code&gt;outsiders.&lt;/code&gt;, &#xA; which is right before &lt;code&gt;\footcite&lt;/code&gt;. But really the sentence ends after the citation &lt;code&gt;{gottlieb-1992}&lt;/code&gt;. Either way, it's a moot point: vim thinks that the third and fourth sentences are &lt;em&gt;one sentence&lt;/em&gt;. The same goes for the last two sentences: vim sees them as &lt;em&gt;one sentence&lt;/em&gt;. The problem, I think, is that the end of sentence (&lt;code&gt;.&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;) is hidden by &lt;code&gt;\footcite&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tl;dr: sentence endings in LaTeX can involve citations after the final punctuation. As a result, vanilla {neo,}vim cannot handle them. Does anyone know of a trick or a plugin to help vim deal with them?&lt;/p&gt;&#xA;" OwnerUserId="7933" LastEditorUserId="7933" LastEditDate="2020-03-20T16:56:53.737" LastActivityDate="2020-03-20T22:51:43.943" Title="How to (more reliably) recognize the end of sentences in LaTeX?" Tags="|filetype-tex|movement|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23229" PostTypeId="1" AcceptedAnswerId="23230" CreationDate="2020-03-19T06:09:09.513" Score="3" ViewCount="163" Body="&lt;p&gt;Is it possible to comment out one element of a multiline list? Or, in general, can you combine line continuations with comments?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Lightly modified from my vimrc)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&#xA;    \'eslint',&#xA;    \'tsserver',&#xA;    \'xo'&#xA;\]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27455" LastEditorUserId="27455" LastEditDate="2020-03-21T01:51:42.923" LastActivityDate="2020-03-21T01:51:42.923" Title="Commenting out an element of a multiline list" Tags="|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23230" PostTypeId="2" ParentId="23229" CreationDate="2020-03-19T06:16:42.953" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Or, in general, can you combine line continuations with comments?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, but it must consist of three symbols (see &lt;code&gt;:h line-continuation-comment&lt;/code&gt;): quote, backslash and &lt;strong&gt;space&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it stands in your example code right now, it won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following will work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&#xA;    &quot;\ 'eslint',&#xA;    \'tsserver',&#xA;    \'xo'&#xA;\]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="18609" LastEditDate="2020-03-19T13:11:43.123" LastActivityDate="2020-03-19T13:11:43.123" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23231" PostTypeId="2" ParentId="23228" CreationDate="2020-03-19T19:23:24.797" Score="0" Body="&lt;p&gt;That depends on what causes Vim to think that the sentence ends at another spot than what you intend. You could have a look at the &lt;em&gt;csquotes&lt;/em&gt; package. &lt;a href=&quot;http://ftp.lyx.org/pub/tex-archive/macros/latex/contrib/csquotes/csquotes.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://ftp.lyx.org/pub/tex-archive/macros/latex/contrib/csquotes/csquotes.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="27470" LastActivityDate="2020-03-19T19:23:24.797" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23232" PostTypeId="1" CreationDate="2020-03-19T21:57:03.467" Score="0" ViewCount="106" Body="&lt;p&gt;I am on Mint 18.3 Sylvia. I tried to install different versions of vim to have python support, following diverse advices (vim/vim.bacic/vim.gnome/vim.gtk/vim.gtk3/vim compiled from git). I have now the choice between 6 alternatives. None of them happen to have python support. Some of them have python3, which seems totally useless to me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi --version | grep &quot;python&quot;&#xA;+cryptv          +linebreak       -python          +vreplace&#xA;+cscope          +lispindent      +python3         +wildignore&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try to install my plugins with Vumble I have the following error: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error: Required vim compiled with +python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27474" LastActivityDate="2020-03-19T21:57:03.467" Title="Can't have a proper version of vim with Python" Tags="|vimrc|functions|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="23233" PostTypeId="1" CreationDate="2020-03-19T22:04:13.383" Score="0" ViewCount="25" Body="&lt;p&gt;I'd like to redefine the &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; motions to operate &quot;linewise&quot; when used with the &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;d&lt;/code&gt; operators.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be concrete, given the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;The quick brown&#xA;fox j|umps over&#xA;the lazy dog&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;code&gt;d}&lt;/code&gt;, with the default behaviour, I am left with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;The quick brown&#xA;fox j&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I would prefer to be left with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;The quick brown&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly, going in the other direction, &lt;code&gt;d{&lt;/code&gt; currently yields&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;umps over&#xA;The lazy dog&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;the lazy dog&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And of course the equivalent for &lt;code&gt;c&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The desired is consistent with with that of other motions which span multiple lines, e.g. &lt;code&gt;dj&lt;/code&gt;, &lt;code&gt;dG&lt;/code&gt;, and feels more natural to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the simplest way of implementing this change?&lt;/p&gt;&#xA;" OwnerUserId="27473" LastActivityDate="2020-03-20T04:24:38.773" Title="Delete to the end of a paragaph, including all of the current line" Tags="|neovim|cut-copy-paste|cursor-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23234" PostTypeId="1" AcceptedAnswerId="23237" CreationDate="2020-03-19T22:16:06.123" Score="1" ViewCount="385" Body="&lt;p&gt;I don't have a personal vimrc.  I use &lt;code&gt;/etc/vimrc&lt;/code&gt;.  The last 2 lines are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let testvar=999&#xA;filetype indent off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I confirmed execution at the vim prompt using &lt;code&gt;:echo testver&lt;/code&gt;, which displays &lt;code&gt;999&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to create a Matlab file using &lt;code&gt;gvim RndSquare.m&lt;/code&gt;.  My first typed line is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function m = RndSqure( n )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following line always start indented, which I don't want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way to prevent it seems to be to create &lt;code&gt;~/.vim/indent/matlab.vim&lt;/code&gt; containing &lt;code&gt;let b:did_indent = 1&lt;/code&gt;.  I also had to create &lt;code&gt;tex.vim&lt;/code&gt; containing the same line, for the same reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to create a gazillion files, one for each file extension, and all containing the same line.  &lt;strong&gt;Why are the last 2 lines in my &lt;code&gt;vimrc&lt;/code&gt; ignored?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul 28 2019 14:56:47)&#xA;Included patches: 1-1772&#xA;Modified by &amp;lt;cygwin@cygwin.com&amp;gt;&#xA;Compiled by &amp;lt;cygwin@cygwin.com&amp;gt;&#xA;Huge version with GTK3 GUI.  Features included (+) or not (-):&#xA;+acl               -farsi             -mouse_sysmouse    -tag_any_white&#xA;+arabic            +file_in_path      +mouse_urxvt       -tcl&#xA;+autocmd           +find_in_path      +mouse_xterm       +termguicolors&#xA;+autochdir         +float             +multi_byte        +terminal&#xA;-autoservername    +folding           +multi_lang        +terminfo&#xA;+balloon_eval      -footer            -mzscheme          +termresponse&#xA;+balloon_eval_term +fork()            +netbeans_intg     +textobjects&#xA;+browse            +gettext           +num64             +textprop&#xA;++builtin_terms    -hangul_input      +packages          +timers&#xA;+byte_offset       +iconv             +path_extra        +title&#xA;+channel           +insert_expand     +perl/dyn          +toolbar&#xA;+cindent           +job               +persistent_undo   +user_commands&#xA;+clientserver      +jumplist          +postscript        +vartabs&#xA;+clipboard         +keymap            +printer           +vertsplit&#xA;+cmdline_compl     +lambda            +profile           +virtualedit&#xA;+cmdline_hist      +langmap           +python/dyn        +visual&#xA;+cmdline_info      +libcall           +python3/dyn       +visualextra&#xA;+comments          +linebreak         +quickfix          +viminfo&#xA;+conceal           +lispindent        +reltime           +vreplace&#xA;+cryptv            +listcmds          +rightleft         +wildignore&#xA;+cscope            +localmap          +ruby/dyn          +wildmenu&#xA;+cursorbind        +lua/dyn           +scrollbind        +windows&#xA;+cursorshape       +menu              +signs             +writebackup&#xA;+dialog_con_gui    +mksession         +smartindent       +X11&#xA;+diff              +modify_fname      +sound             -xfontset&#xA;+digraphs          +mouse             +spell             +xim&#xA;+dnd               +mouseshape        +startuptime       +xpm&#xA;-ebcdic            +mouse_dec         +statusline        +xsmp_interact&#xA;+emacs_tags        -mouse_gpm         -sun_workshop      +xterm_clipboard&#xA;+eval              -mouse_jsbterm     +syntax            -xterm_save&#xA;+ex_extra          +mouse_netterm     +tag_binary&#xA;+extra_search      +mouse_sgr         -tag_old_static&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7041" LastActivityDate="2020-03-20T04:20:01.253" Title="Vim ignores `filetype indent off`" Tags="|vimrc|indentation|indent|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23235" PostTypeId="1" AcceptedAnswerId="23236" CreationDate="2020-03-19T23:33:56.300" Score="3" ViewCount="78" Body="&lt;p&gt;I was looking at a global command that I saved from long time ago. I did not understand how it was a valid syntax, but apparently the syntax was valid because the command worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command: &lt;code&gt;:g/\v\{/+1,/\v}/-1 sort&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you run it against a file with content like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const something = {&#xA;   c:  'x',&#xA;   b:  'x',&#xA;   a:  'x',&#xA;   d:  'x',&#xA;}&#xA;&#xA;const else = {&#xA;   d: 'x',&#xA;   c: 'x',&#xA;   a: 'x',&#xA;   b: 'x',&#xA;}&#xA;&#xA;const c = 'bar'    &#xA;const a = 'hello'&#xA;const b = 'foo'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;It worked.&lt;/strong&gt; It sorted all keys inside &lt;code&gt;something&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt; objects only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I looked at &lt;code&gt;:h :global&lt;/code&gt;, it says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]g[lobal]/{pattern}/[cmd]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I had trouble distinguishing range and pattern in this command. However, I am inclined to think this part (&lt;code&gt;/\v\{/+1,/\v}/-1&lt;/code&gt;) was a range and not a pattern, because:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It had comma, like most ranges.&lt;/li&gt;&#xA;&lt;li&gt;There was no delimiter (/) right before &lt;code&gt;sort&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So I am made to assume that it was a range. But if it was a range, I am left with more questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shouldn't range always go before global command? If range always goes before g, how did this script still work? And where was the pattern? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question for this post is, can someone clarify how does the syntax of that command work, even though it looks contrary to what &lt;code&gt;:h :g&lt;/code&gt; gives?&lt;/p&gt;&#xA;" OwnerUserId="27477" LastEditorUserId="51" LastEditDate="2021-01-27T03:06:59.527" LastActivityDate="2021-03-24T01:00:19.760" Title="Syntax clarification on a global sort command" Tags="|global-command|sort|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23236" PostTypeId="2" ParentId="23235" CreationDate="2020-03-20T01:31:54.757" Score="3" Body="&lt;p&gt;Add space between &lt;code&gt;pattern&lt;/code&gt;, &lt;code&gt;cmd&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;g /\v\{/ +1,/\v}/-1 sort&#xA;        ^------------------separation between pattern and command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It's a good habit to leave space between &lt;code&gt;pattern&lt;/code&gt; and &lt;code&gt;cmd&lt;/code&gt; if your &lt;code&gt;cmd&lt;/code&gt; takes a range.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;+1,/\v}/-1&lt;/code&gt; is a range from the line after the &lt;code&gt;{&lt;/code&gt; found by the &lt;code&gt;:g&lt;/code&gt; command to the line preceding the next occurrence of &lt;code&gt;}&lt;/code&gt;. Check &lt;code&gt;:h :range&lt;/code&gt; If you have doubts. This range is used for &lt;code&gt;cmd&lt;/code&gt;, not for &lt;code&gt;global&lt;/code&gt;. &lt;code&gt;range&lt;/code&gt; for &lt;code&gt;global&lt;/code&gt; must appears before &lt;code&gt;global&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="11054" LastEditDate="2021-03-24T01:00:19.760" LastActivityDate="2021-03-24T01:00:19.760" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23237" PostTypeId="2" ParentId="23234" CreationDate="2020-03-20T04:20:01.253" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't have a personal vimrc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then Vim sources &lt;code&gt;$VIMRUNTIME/defaults.vim&lt;/code&gt; You can see this by issuing &lt;code&gt;:scriptnames&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why are the last 2 lines in my vimrc ignored?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;They are not. The last line gets effectively cancelled by the line &lt;code&gt;filetype plugin indent on&lt;/code&gt; from &lt;code&gt;defaults.vim&lt;/code&gt;, because it gets sourced after it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The last 2 lines are:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is a huge mistake, because you are trying to abandon indenting, while you rely on defaults to switch filetype on. That cannot work. So you must create &lt;code&gt;~/.vimrc&lt;/code&gt; If you need at least filetype stuff without indents you have to add &lt;code&gt;filetype plugin on&lt;/code&gt; to it. Otherwise you can keep it empty.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-03-20T04:20:01.253" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="23238" PostTypeId="2" ParentId="23233" CreationDate="2020-03-20T04:24:38.773" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I'd like to redefine the { and } motions to operate &quot;linewise&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Motions are typed in the operator-pending mode. The &quot;linewise&quot; &lt;code&gt;:h forced-motion&lt;/code&gt; is performed with &lt;code&gt;:h o_V&lt;/code&gt; So you have to type &lt;code&gt;dV}&lt;/code&gt;, &lt;code&gt;cV}&lt;/code&gt; etc.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-03-20T04:24:38.773" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23239" PostTypeId="1" CreationDate="2020-03-20T06:42:36.017" Score="0" ViewCount="849" Body="&lt;p&gt;Coming from emacs, jumping to the end of the line is easy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CTRL + E&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have been recently trying out Vim, and I found out you need to first exit insert mode to then use commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in Vim, I need to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;go to normal mode: &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;jump to end of line: &lt;code&gt;$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;go to insert mode: &lt;code&gt;i&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is there any way to automate this?&lt;/p&gt;&#xA;" OwnerUserId="27479" LastEditorUserId="10604" LastEditDate="2020-03-20T15:23:55.167" LastActivityDate="2020-03-20T15:23:55.167" Title="Automatic insert mode and normal mode switching" Tags="|key-bindings|insert-mode|normal-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23240" PostTypeId="2" ParentId="23239" CreationDate="2020-03-20T07:03:31.583" Score="4" Body="&lt;p&gt;If your terminal has support, you can simply press &lt;kbd&gt;End&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, use &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;O&lt;/kbd&gt; to get into normal mode for a single command only. So &lt;code&gt;Ctrl-O&lt;/code&gt; and then &lt;code&gt;$&lt;/code&gt; (or &lt;code&gt;A&lt;/code&gt;) will do the trick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In principle, you can remap &lt;code&gt;Ctrl-E&lt;/code&gt; to do &lt;code&gt;Ctrl-O $&lt;/code&gt; (like &lt;code&gt;inoremap &amp;lt;c-e&amp;gt; &amp;lt;c-o&amp;gt;$&lt;/code&gt;), but &lt;code&gt;:h i_ctrl-e&lt;/code&gt; is sometimes useful in Vim on its own.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-03-20T07:03:31.583" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23241" PostTypeId="1" CreationDate="2020-03-20T10:26:11.357" Score="0" ViewCount="112" Body="&lt;p&gt;I want to save multiple positions in vimscript, and make sure that they stay at the right place, even after the buffer changes&#xA;Here are the solutions I found so far, and why I want something else:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Save them in an array&lt;/strong&gt;&lt;br&gt;&#xA;If lines are added by the user above the saved positions, they become incorrect (see below GIF, the gray position line &lt;code&gt;5&lt;/code&gt; is the saved pos)&#xA;&lt;img src=&quot;https://i.stack.imgur.com/bxVxx.gif&quot; alt=&quot;demo saving positions&quot;&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Position marks&lt;/strong&gt;&#xA;This works better, but there's a limit of saveable position (52 for the 26 uppercases letters and 26 lowercases), and the user would be able to change them, I don't want that...&lt;img src=&quot;https://i.stack.imgur.com/Cltpm.gif&quot; alt=&quot;demo saving marks&quot;&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Position signs&lt;/strong&gt;&#xA;I haven't tried this one yet, but I don't really like it because it sets unnecessary signs on the left side of the editor, and it doesn't save the horizontal position...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="27331" LastActivityDate="2020-03-20T13:46:24.157" Title="VimScript - Save specific positions consistently even after buffer changes" Tags="|vimscript|cursor|mark|signs|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23242" PostTypeId="1" CreationDate="2020-03-20T11:17:00.570" Score="0" ViewCount="265" Body="&lt;p&gt;I am very often typing &lt;code&gt;:Te&lt;/code&gt; and use tab to auto complete this value to &lt;code&gt;:Texplore&lt;/code&gt;. However, when I misstype to &lt;code&gt;:te&lt;/code&gt;, it will autocomplete to &lt;code&gt;:terminal&lt;/code&gt;, which opens a terminal in the current buffer, so I am losing my currently opened file, which is really a pain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I am using nvim in tmux, so there is actually no need for me to use the terminal emulator included in nvim. So I was wondering if there is some option to disable or remove the &lt;code&gt;:terminal&lt;/code&gt; command, but I couldn't find anything.&lt;/p&gt;&#xA;" OwnerUserId="17932" LastActivityDate="2020-03-20T12:16:33.617" Title="Deactive the :terminal command" Tags="|neovim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23243" PostTypeId="2" ParentId="23242" CreationDate="2020-03-20T12:16:33.617" Score="1" Body="&lt;p&gt;There's no way to disable built-in commands but you can use &lt;code&gt;:cabbr&lt;/code&gt; to map &lt;code&gt;:te&lt;/code&gt; to &lt;code&gt;:Texplore&lt;/code&gt;: &lt;code&gt;cabbr te Texplore&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that on normal mode on any buffer (including the terminal) you can press &lt;code&gt;Ctrl-^&lt;/code&gt; to go back to the previous one&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-03-20T12:16:33.617" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23244" PostTypeId="2" ParentId="23241" CreationDate="2020-03-20T13:46:24.157" Score="2" Body="&lt;p&gt;What about the new &lt;a href=&quot;http://vimhelp.appspot.com/textprop.txt.html#text-properties&quot; rel=&quot;nofollow noreferrer&quot;&gt;text-properties&lt;/a&gt;? They seem to have the &lt;em&gt;property&lt;/em&gt; (sic) to follow.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Text properties can be attached to text in a buffer.  They will move with the&#xA;  text: If lines are deleted or inserted the properties move with the text they&#xA;  are attached to.  Also when inserting/deleting text in the line before the&#xA;  text property.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="626" LastActivityDate="2020-03-20T13:46:24.157" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23245" PostTypeId="1" CreationDate="2020-03-20T17:07:04.103" Score="0" ViewCount="2396" Body="&lt;p&gt;I just started using vim. As I understand it, using  a plugin manager is the easiest way of installing plugins for vim. So I thought I would try vim-plug which I installed using curl as explained &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. Then I looked for plugins on &lt;a href=&quot;https://vimawesome.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimawesome&lt;/a&gt; and I thought I would try to install &lt;a href=&quot;https://vimawesome.com/plugin/vim-colors-solarized-ours&quot; rel=&quot;nofollow noreferrer&quot;&gt;solarized colors&lt;/a&gt;. I just put this in my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin()&#xA;Plug 'altercation/vim-colors-solarized'&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then I opened vim and did PlugInstall and PlugUpdate but when I open a new vim I don't get the solarized colors. What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the suggestion but when I type &lt;code&gt;:colorscheme solarized&lt;/code&gt; I get the following &#xA;&lt;a href=&quot;https://i.stack.imgur.com/xbQfR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xbQfR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="27485" LastEditorUserId="27485" LastEditDate="2020-03-20T17:36:57.787" LastActivityDate="2020-04-03T21:00:01.393" Title="I can't get solarized plugin to work in vim (I am using vim-plug)" Tags="|vimrc|vimscript|plugin-solarized|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23246" PostTypeId="2" ParentId="23245" CreationDate="2020-03-20T17:20:30.597" Score="2" Body="&lt;p&gt;You need to load it. Add &lt;code&gt;colorscheme solarized&lt;/code&gt; to your &lt;code&gt;.vimrc&lt;/code&gt;. You can also load it on the fly executing &lt;code&gt;:colorscheme solarized&lt;/code&gt; on the Vim command line &lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-03-20T17:20:30.597" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23247" PostTypeId="1" AcceptedAnswerId="23249" CreationDate="2020-03-20T18:11:28.433" Score="1" ViewCount="238" Body="&lt;p&gt;A few months ago, someone in a programming class showed me a vim plugin he found that used Unicode to make source code &quot;look pretty.&quot; I remember, specifically, that one of the things it did was make HTML comments (&lt;code&gt;&amp;lt;!--&lt;/code&gt; and &lt;code&gt;--&amp;gt;&lt;/code&gt;) joined and look like one Unicode &quot;thing.&quot; Note that this is just during rendering; the file itself still didn't have those Unicode chars.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of the sort of transformations it did would be how the code looks like on this demo page of a programming language that is not related to the question: &lt;a href=&quot;https://blog.usejournal.com/introduction-to-clio-40dbbf9c250b&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://blog.usejournal.com/introduction-to-clio-40dbbf9c250b&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specificlly: &lt;a href=&quot;https://i.stack.imgur.com/2JeFS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2JeFS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see the &lt;code&gt;-&amp;gt;&lt;/code&gt; is being rendered &quot;as one character,&quot; as is the &lt;code&gt;=&amp;gt;&lt;/code&gt;. (likely using conceal)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There &lt;em&gt;is&lt;/em&gt; &lt;a href=&quot;https://www.emacswiki.org/emacs/PrettySymbol&quot; rel=&quot;nofollow noreferrer&quot;&gt;an Emacs plugin that does this,&lt;/a&gt; but I'm 80% sure I saw it was for vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware of the implications and downsides to a plugin such as this, however, I would still like to know, what is this lost plugin? Where does it live, and how would I install it using plug?&lt;/p&gt;&#xA;" OwnerUserId="27486" LastEditorUserId="27486" LastEditDate="2020-03-20T20:56:02.630" LastActivityDate="2020-03-20T21:21:59.333" Title="Vim plugin for making source code pretty using unicode" Tags="|unicode|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23248" PostTypeId="1" CreationDate="2020-03-20T18:26:20.360" Score="6" ViewCount="1808" Body="&lt;p&gt;I have a file in my &lt;code&gt;~/.vim/ftdetect&lt;/code&gt; directory, which includes configuration such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufRead,BufNewFile,BufWritePost .envrc.template set filetype=sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I also have the &lt;code&gt;vim-polyglot&lt;/code&gt; plugin installed (in &lt;code&gt;~/.vim/pack/packager/start/vim-polyglot/ftdetect/polyglot.vim&lt;/code&gt;, which includes the (less specific) instruction:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.template setlocal filetype=json&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The loading order appears to ensure that the latter &lt;code&gt;autocmd&lt;/code&gt; takes priority, which means that files called &lt;code&gt;.envrc.template&lt;/code&gt; are incorrectly detected as JSON files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I elegantly fix this? Ideally I'd like to keep the &lt;code&gt;vim-polyglot&lt;/code&gt; plugin installed; and use the &lt;code&gt;~/.vim/ftdetect&lt;/code&gt; directory as I think it's intended. Is there a way to change the order in which the autocmds are applied?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;An extract of the output of &lt;code&gt;:scriptnames&lt;/code&gt; (edited for privacy and with large sections of files in similar/identical paths removed for length) below. Note the relative positions of lines 5 and 96.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: /etc/xdg/nvim/sysinit.vim&#xA;  2: /usr/share/nvim/archlinux.vim&#xA;  3: ~/.vim/init.vim&#xA;  4: /usr/share/nvim/runtime/filetype.vim&#xA;  5: ~/.vim/after/ftdetect/all.vim&#xA;  6: /usr/share/vim/vimfiles/ftdetect/dockerfile.vim&#xA;  ...&#xA;  8: /usr/share/nvim/runtime/ftplugin.vim&#xA;  9: /usr/share/nvim/runtime/indent.vim&#xA; 10: /usr/share/nvim/runtime/syntax/syntax.vim&#xA; 11: /usr/share/nvim/runtime/syntax/synload.vim&#xA; 12: /usr/share/nvim/runtime/syntax/syncolor.vim&#xA; ...&#xA; 17: ~/.vim/plugin/completion.vim&#xA; 18: ~/.vim/plugin/diff.vim&#xA; ...&#xA; 36: /usr/share/nvim/runtime/plugin/gzip.vim&#xA; 37: /usr/share/nvim/runtime/plugin/health.vim&#xA; ...&#xA; 96: ~/.vim/pack/packager/start/vim-polyglot/ftdetect/polyglot.vim&#xA; ...&#xA;127: ~/.vim/after/plugin/vim-pencil.vim&#xA;128: ~/.vim/after/plugin/vim-polyglot.vim&#xA; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'runtimepath'&lt;/code&gt; as per Ben Knoble's question (again, edited for length) is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/user/.config/nvim&#xA;...&#xA;/Users/user/.config/nvim/pack/packager/start/vim-polyglot&#xA;...&#xA;/Users/user/.config/nvim/pack/packager/start/ale&#xA;/etc/xdg/nvim&#xA;/Users/user/.local/share/nvim/site&#xA;/usr/local/share/nvim/site&#xA;/usr/share/nvim/site&#xA;/usr/local/Cellar/neovim/0.4.3/share/nvim/runtime&#xA;/usr/local/Cellar/neovim/0.4.3/share/nvim/runtime/pack/dist/opt/matchit&#xA;/usr/share/nvim/site/after&#xA;/usr/local/share/nvim/site/after&#xA;/Users/user/.local/share/nvim/site/after&#xA;/etc/xdg/nvim/after&#xA;/Users/user/.config/nvim/after&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="91" LastEditorUserId="91" LastEditDate="2020-03-22T13:09:32.813" LastActivityDate="2021-12-23T02:00:26.473" Title="How do I elegantly override file type detection patterns with more specific patterns" Tags="|autocmd|filetype|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23249" PostTypeId="2" ParentId="23247" CreationDate="2020-03-20T21:07:38.550" Score="1" Body="&lt;p&gt;HAHA! I found it(?), after much research. (thanks to @Maxim Kim for reminding me that they are called ligatures)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there are actually &lt;em&gt;multiple&lt;/em&gt; that do this (makes sense to me).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ehamberg/vim-cute-python&quot; rel=&quot;nofollow noreferrer&quot;&gt;This one is for python&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/khzaw/vim-conceal&quot; rel=&quot;nofollow noreferrer&quot;&gt;This one looks like it's for lots of things&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also, there are fonts that do it without the need of help from vim.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/tonsky/FiraCode&quot; rel=&quot;nofollow noreferrer&quot;&gt;FiraCode&lt;/a&gt; is one example&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/i-tu/Hasklig/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Haskling&lt;/a&gt; is another&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="27486" LastEditorUserId="27486" LastEditDate="2020-03-20T21:21:59.333" LastActivityDate="2020-03-20T21:21:59.333" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23250" PostTypeId="2" ParentId="23228" CreationDate="2020-03-20T22:51:43.943" Score="1" Body="&lt;p&gt;There is a plugin that helps: &lt;a href=&quot;https://github.com/reedes/vim-textobj-sentence&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-sentence&lt;/a&gt;. It replaces vim's built-in &lt;code&gt;)&lt;/code&gt; and &lt;code&gt;(&lt;/code&gt;, and it does a better job on many LaTeX sentences. However, it also has some issues of its own. For example, it doesn't recognize sentences within parentheses. (I'm putting this here for people who find this question via Google, but I'm not going to accept this answer yet.)&lt;/p&gt;&#xA;" OwnerUserId="7933" LastActivityDate="2020-03-20T22:51:43.943" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23251" PostTypeId="2" ParentId="23248" CreationDate="2020-03-20T23:02:52.397" Score="5" Body="&lt;p&gt;You're in luck: the &lt;code&gt;after&lt;/code&gt; directory exists for exactly this reason. &lt;code&gt;~/.vim/after&lt;/code&gt; is &lt;em&gt;usually&lt;/em&gt; the last entry of &lt;code&gt;'runtimepath'&lt;/code&gt;, so that whatever a user puts there overrides anything before it. Since it can house a full runtime, you can put anything you would put in &lt;code&gt;~/.vim&lt;/code&gt; in &lt;code&gt;~/.vim/after&lt;/code&gt;! I use this commonly for &lt;code&gt;~/.vim/after/ftplugin&lt;/code&gt; to override previous settings (but still allow them to execute).&lt;/p&gt;&#xA;&lt;p&gt;Long story short, put your custom detector in &lt;code&gt;~/.vim/after/ftdetect/...&lt;/code&gt; and it should take precedence over polyglot because its autocommand will fire later—thereby overwriting the filetype set in polyglot. Now, this will have some bizarre effects if whatever is happening in polyglot doesn't set &lt;code&gt;b:undo_ftplugin&lt;/code&gt; properly, because the actual sequence of events will be&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;setlocal filetype=json&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;setlocal filetype=sh&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;And if &lt;code&gt;b:undo_ftplugin&lt;/code&gt; doesn't work right, you might have some stuff leftover from your json filetype scripts.&lt;/p&gt;&#xA;&lt;p&gt;(Plus, I checked, and &lt;code&gt;filetype.vim&lt;/code&gt; just does &lt;code&gt;runtime! ftdetect/*.vim&lt;/code&gt;, which searches in order of &lt;code&gt;'runtimepath'&lt;/code&gt;.)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;All of this said, this is why &lt;code&gt;setfiletype&lt;/code&gt; exists (and plugins should use it).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For those in the comments struggling with this approach, please make sure your &lt;code&gt;runtimepath&lt;/code&gt; has &lt;code&gt;~/.vim/after&lt;/code&gt; near the end (certainly after anything you want to override). Packages are automatically added in the correct place (&lt;em&gt;i.e.&lt;/em&gt;, before &lt;code&gt;~/.vim/after&lt;/code&gt;), but some plugin managers may not know they need to do this (and &lt;code&gt;set runtimepath+=foo&lt;/code&gt; will put &lt;code&gt;foo&lt;/code&gt; at the end, potentially overriding &lt;code&gt;~/.vim/after&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2021-09-04T15:22:05.613" LastActivityDate="2021-09-04T15:22:05.613" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="23252" PostTypeId="1" CreationDate="2020-03-20T23:07:39.123" Score="3" ViewCount="338" Body="&lt;p&gt;I was playing with netrw and was amazed by the possibility. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to mark some files with 'mf' and move it to a folder using 'mt'. However, when I press 't', vim seems to interprets it as &quot;open a tab', because it open another instance of netrw in a splitted window. How can I do to mark it as target ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem seems to be with the &quot;t&quot; shortcut in NETRW&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t   Enter the file/directory under the cursor in a new tab|netrw-t|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help !&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Vim version : 8.1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Plugins&lt;/strong&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 2: /usr/share/vim/vim81/debian.vim&#xA;  3: /usr/share/vim/vim81/syntax/syntax.vim&#xA;  4: /usr/share/vim/vim81/syntax/synload.vim&#xA;  5: /usr/share/vim/vim81/syntax/syncolor.vim&#xA;  6: /usr/share/vim/vim81/filetype.vim&#xA;  7: ~/.vim/ftdetect/solidity.vim&#xA;  8: ~/.vim/ftdetect/typescript.vim&#xA;  9: ~/.vimrc&#xA; 10: /usr/share/vim/vim81/plugin/getscriptPlugin.vim&#xA; 11: /usr/share/vim/vim81/plugin/gzip.vim&#xA; 12: /usr/share/vim/vim81/plugin/logiPat.vim&#xA; 13: /usr/share/vim/vim81/plugin/manpager.vim&#xA; 14: /usr/share/vim/vim81/plugin/matchparen.vim&#xA; 15: /usr/share/vim/vim81/plugin/netrwPlugin.vim&#xA; 16: /usr/share/vim/vim81/plugin/rrhelper.vim&#xA; 17: /usr/share/vim/vim81/plugin/spellfile.vim&#xA; 18: /usr/share/vim/vim81/plugin/tarPlugin.vim&#xA; 19: /usr/share/vim/vim81/plugin/tohtml.vim&#xA; 20: /usr/share/vim/vim81/plugin/vimballPlugin.vim&#xA; 21: /usr/share/vim/vim81/plugin/zipPlugin.vim&#xA; 22: /usr/share/vim/vim81/autoload/netrw.vim&#xA; 23: ~/.vim/.netrwhist&#xA; 24: /usr/share/vim/vim81/scripts.vim&#xA; 25: /usr/share/vim/vim81/syntax/netrw.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here my .vimrc :&#xA;set splitright&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; NETRW&#xA;&quot; open file explorer at startup&#xA;autocmd VimEnter * Vexplore .&#xA;&#xA;&quot; Resize file explorer&#xA;autocmd VimEnter * vertical resize 50&#xA;autocmd VimEnter * wincmd w&#xA;&#xA;&quot; NETRW : set view type as TREE&#xA;let g:netrw_liststyle=3&#xA;&#xA;&quot; Disable header : I&#xA;let g:netrw_banner=0&#xA;&#xA;&quot; Open file in previous split&#xA;let g:netrw_browse_split=4&#xA;&#xA;&quot; hide vim swap files&#xA;let g:netrw_list_hide='.*\.swp$'&#xA;&#xA;&quot; To insert space characters whenever the tab key is pressed, set the 'expandtab' option: &#xA;:set tabstop=4&#xA;:set shiftwidth=4&#xA;set expandtab&#xA;&#xA;&quot; fold indented text automatically at opening.&#xA;&quot; to disable/toggle folding : zi&#xA;&quot; za : toggle current indented block&#xA;setlocal foldmethod=indent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In netrw, :verbose map command return :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose map t&#xA;n  t           *@:call &amp;lt;SNR&amp;gt;22_NetrwSplit(4)&amp;lt;CR&amp;gt;&#xA;        Modifié la dernière fois dans /usr/share/vim/vim81/autoload/netrw.vim&#xA;&#xA;:verbose map mt&#xA;n  mt          *@:&amp;lt;C-U&amp;gt;call &amp;lt;SNR&amp;gt;22_NetrwMarkFileTgt(1)&amp;lt;CR&amp;gt;&#xA;        Modifié la dernière fois dans /usr/share/vim/vim81/autoload/netrw.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;mf command is working great. I see difference when file is marked : Items marked become bold. I think this should be the same for 'mt'. However a tab is opened when I press 't' immediately after 'm'. Name of the folder doesn't become &quot;bold&quot; (marked).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 2&lt;/strong&gt;    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set showcmd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;'m' is correctly displayed at the bottom of the screen.&#xA;'m' disappear just after pressing 't' key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below logs from debug mode (9) :&#xA;(translate from french)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function &amp;lt;SNR&amp;gt;22_NetrwMarkFileTgt[63]..&amp;lt;SNR&amp;gt;22_LocalBrowseRefresh[57]..&amp;lt;SNR&amp;gt;22_NetrwRefresh[16]..netrw#LocalBrowseCheck[23]..&amp;lt;SNR&amp;gt;22_NetrwBrowse[237]..&amp;lt;SNR&amp;gt;22_PerformListing[231]..&amp;lt;SNR&amp;gt;22_NetrwWideListing :&#xA;line   67 :&#xA;E31: No such mapping&#xA;Error detected while processing function &amp;lt;SNR&amp;gt;22_NetrwMarkFileTgt[63]..&amp;lt;SNR&amp;gt;22_LocalBrowseRefresh[57]..&amp;lt;SNR&amp;gt;22_NetrwRefresh[16]..netrw#LocalBrowseCheck[23]..&amp;lt;SNR&amp;gt;22_NetrwBrowse[237]..&amp;lt;SNR&amp;gt;22_PerformListing[231]..&amp;lt;SNR&amp;gt;22_NetrwWideListing :                            &#xA;line   70 :&#xA;E31: No such mapping&#xA;No such mapping: @$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Line 67 and 70 in function :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;/usr/share/vim/vim81/autoload/netrw.vim&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NetrwWideListing&#xA;...&#xA;   if hasmapto(&quot;w&quot;,&quot;n&quot;)&#xA;    line 67 -&amp;gt; sil! nunmap &amp;lt;buffer&amp;gt; w&#xA;   endif&#xA;   if hasmapto(&quot;b&quot;,&quot;n&quot;)&#xA;    line 70 -&amp;gt; sil! nunmap &amp;lt;buffer&amp;gt; b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I don't know if this is really the function that is the root cause of vim prefering to apply the other 't' shortcut.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if I do &quot;nmap&quot;, I don't see &quot;w&quot; nor &quot;b&quot; mapping :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n  a           *@:&amp;lt;C-U&amp;gt;call &amp;lt;SNR&amp;gt;22_NetrwHide(1)&amp;lt;CR&amp;gt;&#xA;n  c           *@:&amp;lt;C-U&amp;gt;call &amp;lt;SNR&amp;gt;22_NetrwLcd(b:netrw_curdir)&amp;lt;CR&amp;gt;&#xA;n  d           *@:call &amp;lt;SNR&amp;gt;22_NetrwMakeDir(&quot;&quot;)&amp;lt;CR&amp;gt;&#xA;....&#xA;n  v           *@:call &amp;lt;SNR&amp;gt;22_NetrwSplit(5)&amp;lt;CR&amp;gt;&#xA;n  x           *@:&amp;lt;C-U&amp;gt;call netrw#BrowseX(&amp;lt;SNR&amp;gt;22_NetrwBrowseChgDir(1,&amp;lt;SNR&amp;gt;22_NetrwGetWord(),0),0)&quot;&amp;lt;CR&amp;gt;&#xA;n  &amp;lt;F1&amp;gt;        *@:he netrw-quickhelp&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;strange...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 3&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set up debug loglevel to 14.&#xA;It seems to be a bug.&#xA;When I press 't' just after 'm' ('mt' command to mark as target), a process/command SynSet seem to be launched in infinite loop (CPU fan begin to work harder). Log file contains same text in loop. Please find below link to pastebin that contain log file part that is repeated infinitely.&#xA;(Sorry but log are in french...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://pastebin.com/aKJyiTgg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://pastebin.com/aKJyiTgg&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="27489" LastEditorUserId="27489" LastEditDate="2020-03-21T21:48:29.873" LastActivityDate="2023-04-16T12:27:08.180" Title="Netrw problem - 'mt' open new tab instead of marking as target folder" Tags="|netrw|filesystem|" AnswerCount="0" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="23253" PostTypeId="1" CreationDate="2020-03-21T04:22:17.420" Score="0" ViewCount="72" Body="&lt;p&gt;I have this list :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let myList1 = [&quot;short-term&quot;]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I want to get this second list with my first :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let myList2 = [&quot;short&quot;, &quot;term&quot;]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for elem in myList1&#xA;     let myList2 = []&#xA;     code ???????????/\=add(myList2, submatch(0) &#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you help me, please ?&lt;/p&gt;&#xA;" OwnerUserId="26872" LastActivityDate="2024-02-23T16:05:20.600" Title="Check items of a list" Tags="|list|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23254" PostTypeId="2" ParentId="23253" CreationDate="2020-03-21T05:26:10.330" Score="0" Body="&lt;p&gt;Here is my good function :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! myFunction()&#xA;&#xA;   let myList1 = [&quot;short-term&quot;]&#xA;   let myList2 = []&#xA;   for elem in myList1  &#xA;       call extend(myList2, split(elem, &quot;-&quot;))&#xA;   endfor&#xA;endfunction &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26872" LastActivityDate="2020-03-21T05:26:10.330" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23256" PostTypeId="1" CreationDate="2020-03-21T10:26:58.807" Score="2" ViewCount="66" Body="&lt;p&gt;So I recently downloaded &lt;a href=&quot;https://github.com/nanotech/jellybeans.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jellybeans.vim&lt;/a&gt;, and it was working fine until today when I opened &lt;code&gt;.vimrc&lt;/code&gt; and to add something to the bottom of the file I pressed &lt;code&gt;G&lt;/code&gt; , this happened:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wDBLB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wDBLB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I pressed &lt;code&gt;gg&lt;/code&gt; to go the top of the file and this happened:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ApRqK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ApRqK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I went down line by line and all was okay :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YXG9q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YXG9q.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The weird part is that this only happens in &lt;code&gt;.vimrc&lt;/code&gt;. Everything else (even &lt;code&gt;.bashrc&lt;/code&gt;) works normally. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use WSL in HyperTerm. When I tried during the same by running WSL in CMD Prompt it worked just fine. Also, in Hyper other .vim scripts work fine too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on why this is happening ?&lt;/p&gt;&#xA;" OwnerUserId="27496" LastEditorUserId="10604" LastEditDate="2020-03-21T13:21:21.393" LastActivityDate="2020-03-21T13:21:21.393" Title="Weird highlighting when navigating vimrc" Tags="|colorscheme|highlight|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="23257" PostTypeId="1" AcceptedAnswerId="23258" CreationDate="2020-03-21T10:37:07.700" Score="2" ViewCount="687" Body="&lt;p&gt;Within some run time files I would like to source a file relative to the $MYVIMRC file. My best efforts have lead me to this (which does not work):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source expand(&quot;$MYVIMRC:p:h&quot;) . &quot;/vimrc/env.vim&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-03-22T07:13:57.057" Title="Get the dir of $MYVIMRC and concatenate a different file path" Tags="|vimrc|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23258" PostTypeId="2" ParentId="23257" CreationDate="2020-03-21T10:51:47.937" Score="3" Body="&lt;p&gt;Your best effort:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source expand(&quot;$MYVIMRC:p:h&quot;) . &quot;/vimrc/env.vim&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;has issues:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;source&lt;/code&gt; command doesn't work with &lt;code&gt;&quot;strings&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;even if it worked with strings, you have strange last unbalanced &lt;code&gt;)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can try using &lt;code&gt;:execute&lt;/code&gt; statement with composed &lt;code&gt;source&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;source &quot; . fnamemodify(&quot;$MYVIMRC&quot;, &quot;:p:h&quot;) . &quot;/vimrc/env.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;expand(&quot;$MYVIMRC:p:h&quot;)&lt;/code&gt; will not work as expected, but &lt;code&gt;fnamemodify&lt;/code&gt; will.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option I personally use is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source &amp;lt;sfile&amp;gt;:h/statusline.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;&amp;lt;sfile&amp;gt;&lt;/code&gt; when executing a &quot;:source&quot; command, is replaced with the file name of the sourced file.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-03-22T07:13:57.057" LastActivityDate="2020-03-22T07:13:57.057" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23259" PostTypeId="2" ParentId="23257" CreationDate="2020-03-21T10:52:27.507" Score="2" Body="&lt;p&gt;A possible solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute printf('source %s/vimrc/env.vim', fnamemodify($MYVIMRC, ':h'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-03-21T10:52:27.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23260" PostTypeId="1" CreationDate="2020-03-21T11:59:59.657" Score="2" ViewCount="307" Body="&lt;p&gt;Suppose I have a line of LaTeX code as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;We have two equations $E=mc^2$ and $F=ma$.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I quickly jump between inline math equations? Let's say I'm editing the first equation &lt;code&gt;$E=mc^2$&lt;/code&gt;, how do I quickly move my cursor to be inside the second equation &lt;code&gt;$F=ma$&lt;/code&gt;?&#xA;Obviously I can do &lt;code&gt;fF&lt;/code&gt; is this case, but I would like a more systematic way to help me navigate to the next &lt;code&gt;$..$&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="27497" LastEditorUserId="1292" LastEditDate="2020-03-23T09:27:26.470" LastActivityDate="2020-03-23T09:27:26.470" Title="How to quickly jump between inline equations in vimtex?" Tags="|filetype-tex|plugin-vimtex|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23261" PostTypeId="2" ParentId="23260" CreationDate="2020-03-21T17:28:42.867" Score="1" Body="&lt;p&gt;You can use a match for a &lt;code&gt;\$&lt;/code&gt;, using a look-behind to match other equations enclosed in pairs of &lt;code&gt;$&lt;/code&gt;s. That way you'll know you're always matching the first &lt;code&gt;$&lt;/code&gt; of each equation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This search will work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\(^\([^$]\|\$[^$]\+\$\)\+\)\@&amp;lt;=\$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5C%40%3C%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help /\@&amp;lt;=&lt;/code&gt;&lt;/a&gt; for the look-behind operator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rest of the regex should be (relatively) straightforward, the look-behind part is matching sequences of &lt;code&gt;$...$&lt;/code&gt; or characters other than &lt;code&gt;$&lt;/code&gt;. The look-behind is anchored at the beginning of the line, to ensure it's capturing all pairs in the line correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works as expected on the example you provided.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Cv&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;very magic&quot; mode&lt;/a&gt; to avoid having to escape so many metacharacters with backslashes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/\v(^([^$]|\$[^$]+\$)+)@&amp;lt;=\$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also consider extending the match to the whole expression inside &lt;code&gt;$...$&lt;/code&gt;, that way search highlighting will be more useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can consider adding mappings to these commands (search it forward and backward) when editing LaTeX files, since typing the whole search expression is definitely cumbersome. Consider adding the mappings in both directions.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-21T17:28:42.867" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="23262" PostTypeId="1" AcceptedAnswerId="23263" CreationDate="2020-03-21T21:13:34.457" Score="1" ViewCount="288" Body="&lt;p&gt;I want to replace in highlighted text the angle brackets &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; with &lt;code&gt;&amp;amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;amp;gt;&lt;/code&gt;. The following line in my .vimrc doesn't seem to work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vmap &amp;lt;F9&amp;gt; :'&amp;lt;,'&amp;gt;s/&amp;lt;/\&amp;amp;lt;/g | '&amp;lt;,'&amp;gt;s/&amp;gt;/\&amp;amp;gt;/g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="15501" LastActivityDate="2020-03-22T03:05:12.867" Title="vimrc command not working - vmap &lt;F9&gt; :'&lt;,'&gt;s/&lt;/\&amp;lt;/g | '&lt;,'&gt;s/&gt;/\&amp;gt;/g" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23263" PostTypeId="2" ParentId="23262" CreationDate="2020-03-21T21:29:38.383" Score="1" Body="&lt;p&gt;There are several issues. First of all what happens when you make a visual selection and then go to the command line with &lt;code&gt;:&lt;/code&gt;? You see how it's pre-populated with &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt;. You should drop that from the first substitution in your mapping as it's redundant. (Or you can leave it in and make the first part of your mapping &lt;code&gt;&amp;lt;C-U&amp;gt;&lt;/code&gt; as in &lt;code&gt;Ctrl-U&lt;/code&gt;. That will clear the &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; from the command line before the rest of your mapped commands are inserted.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next issue is that you can't combine commands with &lt;code&gt;|&lt;/code&gt; in a mapping unless you escape that character with backslash. Alternatively you can use &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; instead of &lt;code&gt;\|&lt;/code&gt;. If you don't do this then the second command will be run &lt;em&gt;when you run the map command itself&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you are missing a key part of any command. The carriage return that submits it for execution. In a mapping you can specify this with &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that all adds up to either one of these (I'm showing both ways to handle the implied &lt;code&gt;'&amp;lt;,'&amp;gt;&lt;/code&gt; here)...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vnoremap &amp;lt;F9&amp;gt; :s/&amp;lt;/\&amp;amp;lt;/g &amp;lt;bar&amp;gt; '&amp;lt;,'&amp;gt;s/&amp;gt;/\&amp;amp;gt;/g&amp;lt;CR&amp;gt;&#xA;:vnoremap &amp;lt;F9&amp;gt; :&amp;lt;C-U&amp;gt;'&amp;lt;,'&amp;gt;s/&amp;lt;/\&amp;amp;lt;/g &amp;lt;bar&amp;gt; '&amp;lt;,'&amp;gt;s/&amp;gt;/\&amp;amp;gt;/g&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I'm using &lt;code&gt;vnoremap&lt;/code&gt; here. As a rule of thumb, unless you know the difference between the two and you know that you truly need  &lt;code&gt;vmap&lt;/code&gt; you should always use the &quot;noremap&quot; version. This holds for other mapping types, too, like &lt;code&gt;nmap/nnoremap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pro Tip: You may notice when using this mapping that you get output from the substitutions like &quot;5 substitutions on 3 lines&quot; and you must hit enter to clear it. To avoid this you can just append &lt;code&gt;&amp;lt;C-L&amp;gt;&lt;/code&gt; to the end of the mapping above and that will automatically clear things for you.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-03-22T03:05:12.867" LastActivityDate="2020-03-22T03:05:12.867" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="23264" PostTypeId="1" CreationDate="2020-03-21T21:43:56.780" Score="3" ViewCount="833" Body="&lt;p&gt;I recently learned the very hard way that vim-plug will only load plugins AFTER the vimrc is completely sourced: &lt;a href=&quot;https://stackoverflow.com/questions/21322520/why-wont-vim-recognise-a-plugin-command-in-the-vimrc-but-it-will-recognise-it&quot;&gt;https://stackoverflow.com/questions/21322520/why-wont-vim-recognise-a-plugin-command-in-the-vimrc-but-it-will-recognise-it&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is that I have a plugin where I define functions that I would like to use inside my vimrc. Specifically my plugin is here: &lt;a href=&quot;https://github.com/Erotemic/vimtk&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Erotemic/vimtk&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I would like to call the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Make default vimtk remaps.&#xA;:call VimTK_default_remap()&#xA;&#xA;&quot; Swap colon and semicolon&#xA;:call vimtk#swap_keys(':', ';')&#xA;&#xA;&quot; Register files you use all the time with quickopen&#xA;&quot; (use &amp;lt;leader&amp;gt;i&amp;lt;char&amp;gt; as a shortcut to specific files&#xA;:call vimtk#quickopen(',', '~/.vimrc')&#xA;:call vimtk#quickopen('5', '~/.bashrc')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my vimrc. These lines define special remappings, so I think it makes sense that they are called on startup time and not via an autocmd. My current workaround is just to explicitly source the plugin file: &lt;code&gt;source $HOME/.vim/bundle/vimtk/plugin/vimtk.vim&lt;/code&gt; before calling these commands, but that's not very satisfying. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to force plugins to load such that you can call their functions inside your vimrc?&lt;/p&gt;&#xA;" OwnerUserId="27503" LastActivityDate="2020-04-05T22:00:03.683" Title="Can you use plugins inside of your vimrc?" Tags="|vimrc|plugin-system|plugin-vim-plug|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="23265" PostTypeId="1" CreationDate="2020-03-22T03:25:16.263" Score="0" ViewCount="132" Body="&lt;p&gt;Hi I'm trying to make emmet expand only Html tags. For example &lt;code&gt;div&amp;lt;c-y&amp;gt;,&lt;/code&gt; should be expanded to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;abc&amp;lt;c-y&amp;gt;,&lt;/code&gt; should not be expanded. By default emmet expands every word, I wonder if there's a setting to expand only html tags. Any help would be much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="27505" LastActivityDate="2020-03-22T03:25:16.263" Title="Emmet expand only HTML tags" Tags="|filetype-html|plugin-emmet-vim|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23266" PostTypeId="2" ParentId="2387" CreationDate="2020-03-22T11:47:55.733" Score="0" Body="&lt;p&gt;I had the same issue. I think it occurred after I deleted a repo from my computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I first noticed it when trying to do a git merge from terminal, so I originally assumed it was an issue with git.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As describe above it is an issue with the &lt;code&gt;~/.viminfo&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I resolved it by opening the &lt;code&gt;~/.viminfo&lt;/code&gt; in a text editor and removing the leading &lt;code&gt;&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now everything seems to work fine again.&lt;/p&gt;&#xA;" OwnerUserId="27511" LastEditorUserId="51" LastEditDate="2020-03-25T22:21:54.810" LastActivityDate="2020-03-25T22:21:54.810" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23267" PostTypeId="1" CreationDate="2020-03-22T12:44:42.233" Score="0" ViewCount="631" Body="&lt;p&gt;I would like vim to only ever insert a space character when I touch the space bar.  Instead vim decides that sometimes tabs should be 4 spaces.  How do I force vim to always and forever use tabs regardless of what any other vim config in my system says to do?  No matter what I place in .vimrc it still gives me spaces.&lt;/p&gt;&#xA;" OwnerUserId="27513" LastActivityDate="2020-03-22T13:23:33.740" Title="Tabs and only tabs for any file type" Tags="|vimrc|tab-characters|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23268" PostTypeId="1" CreationDate="2020-03-22T12:21:54.280" Score="1" ViewCount="261" Body="&lt;p&gt;I want to make something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;makerpg = '[ -f Makefile] &amp;amp;&amp;amp; make || cd build &amp;amp;&amp;amp; [ -f Makefile ] &amp;amp;&amp;amp; make || cd ../build &amp;amp;&amp;amp; [ -f Makefile ] &amp;amp;&amp;amp; make || echo &quot;Error&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My goal is to make &lt;code&gt;make&lt;/code&gt; to work in any place if it is within this kind of tree:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Proyect-root&#xA; /src&#xA; /build&#xA; /include&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: Actually I already have a pretty similar map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;F4&amp;gt; :wa&amp;lt;bar&amp;gt;cd ../build&amp;lt;bar&amp;gt;make&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;:cd -&amp;lt;cr&amp;gt;:echo 'Done'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's quite simple but obviously it doesn't work if I am in the root of my project.&lt;/p&gt;&#xA;" OwnerUserId="27515" OwnerDisplayName="Nanozet" LastEditorUserId="11357" LastEditDate="2020-04-10T23:29:11.027" LastActivityDate="2020-04-10T23:29:11.027" Title="Bind makeprg to a shell command" Tags="|key-bindings|makeprg|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23269" PostTypeId="2" ParentId="23268" CreationDate="2020-03-22T13:16:28.537" Score="2" Body="&lt;p&gt;If you need to do sh/bash commands, you should run it via &lt;code&gt;sh -c&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;makeprg = 'sh -c &quot;...&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-03-22T13:16:28.537" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23270" PostTypeId="2" ParentId="23267" CreationDate="2020-03-22T13:23:33.740" Score="2" Body="&lt;p&gt;If I’ve understood you correctly, you want to do something like this in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup&#xA;  au!&#xA;  au FileType * setlocal noexpandtab&#xA;augroup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I cannot guarantee this works (i.e., something might get triggered after this autocommand that sets &lt;code&gt;expandtab&lt;/code&gt;). I think you could establish a buffer-local &lt;code&gt;BufEnter&lt;/code&gt; autocommand inside the &lt;code&gt;FileType&lt;/code&gt; autocommand, but that will be needless complexity if you never run into a situation where this doesn’t work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also cannot really recommend this... for one, I prefer spaces :) but additionally, this is very difficult to override when you &lt;em&gt;want&lt;/em&gt; spaces!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;em&gt;far&lt;/em&gt; better approach is to put &lt;code&gt;setlocal noexpandtab&lt;/code&gt; in &lt;code&gt;~/.vim/after/ftplugin/{filetype}.vim&lt;/code&gt; anytime you run into a filetype that is using spaces where you want tabs. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-03-22T13:23:33.740" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23271" PostTypeId="1" AcceptedAnswerId="23272" CreationDate="2020-03-22T14:07:47.613" Score="1" ViewCount="309" Body="&lt;p&gt;I want to set some options on a particular window number. What I've been doing is go to the window by &lt;code&gt;{winnr} wincmd w&lt;/code&gt;, set some options and do some work then come back. But this creates a UI flash (you can see you changed window for a short amount of time).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to modify window options without going there programmatically?&lt;/p&gt;&#xA;" OwnerUserId="27290" LastActivityDate="2020-03-22T15:06:00.413" Title="Set option on window without going to the window and come back" Tags="|vimscript|vim-windows|window-management|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23272" PostTypeId="2" ParentId="23271" CreationDate="2020-03-22T14:13:55.887" Score="1" Body="&lt;p&gt;The function &lt;code&gt;setwinvar&lt;/code&gt; can change options using the &lt;code&gt;&amp;amp;&lt;/code&gt; syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setwinvar(1, &quot;&amp;amp;list&quot;, 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can execute any code in the context of another window using &lt;code&gt;win_execute&lt;/code&gt; (vim only):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call win_execute(winid, 'set syntax=python')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In neovim there is also &lt;code&gt;nvim_win_set_option&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call nvim_win_set_option(win, 'list', 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2020-03-22T15:06:00.413" LastActivityDate="2020-03-22T15:06:00.413" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="23273" PostTypeId="1" AcceptedAnswerId="23332" CreationDate="2020-03-22T15:34:40.763" Score="2" ViewCount="98" Body="&lt;p&gt;I am using the FZF vim plugin and when I open it using &lt;code&gt;:FZF&amp;lt;cr&amp;gt;&lt;/code&gt; it then shows me the prompt to input what I want to search for. If I type something and then press backspace to erase (For example because I made a typo in what I want to search for) the window just closes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this normal?&lt;/p&gt;&#xA;" OwnerUserId="25193" LastActivityDate="2020-03-26T16:16:15.980" Title="Is it normal that I can't erase an input to FZF?" Tags="|plugin-fzf|fzf|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23274" PostTypeId="1" CreationDate="2020-03-23T07:20:54.923" Score="1" ViewCount="389" Body="&lt;p&gt;I've succeeded in configuring a vim-c++ environment based on the plugin YCM and the plugin &lt;a href=&quot;https://github.com/dense-analysis/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ale&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use YCM to do the auto-completion and ALE to hint me errors and warnings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added the config as below to update the status line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%#warningmsg#&#xA;function! LinterStatus() abort&#xA;    let l:counts = ale#statusline#Count(bufnr(''))&#xA;    let l:fst = ale#statusline#FirstProblem(bufnr(''), 'error')&#xA;    let l:all_errors = l:counts.error + l:counts.style_error&#xA;    let l:all_non_errors = l:counts.total - l:all_errors&#xA;    return l:counts.total == 0 ? 'OK' : printf(&#xA;    \   '%dW %dE(%d)',&#xA;    \   all_non_errors,&#xA;    \   all_errors,&#xA;    \   fst.lnum&#xA;    \)&#xA;endfunction&#xA;set statusline+=%{LinterStatus()}&#xA;set statusline+=%*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It worked as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the c++ code as below will show &lt;code&gt;0W 1E(3)&lt;/code&gt; at the status line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main()&#xA;{&#xA;    xxxx&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I'm trying to configure a vim-golang environment with the plugin YCM and the plugin ALE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've built the YCM with the command &lt;code&gt;./install.py --go-completer&lt;/code&gt;. For ALE, I used the same config as above and I add one line to configure golang:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;let g:ale_linters = {'go': ['gopls', 'golangci-lint', 'gofmt']}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the status line always show me &lt;code&gt;OK&lt;/code&gt;, meaning that there is no error, no matter how I create an error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DKaut.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DKaut.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, there does exist an error but the status line shows me an &lt;code&gt;OK&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:ALEInfo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Current Filetype: go&#xA;Available Linters: ['bingo', 'gobuild', 'gofmt', 'golangci-lint', 'golint', 'gometalinter', 'gopls', 'gosimple', 'gotype', 'govet', 'golangserver', 'staticcheck']&#xA;   Linter Aliases:&#xA;'gobuild' -&amp;gt; ['go build']&#xA;'govet' -&amp;gt; ['go vet']&#xA;  Enabled Linters: ['gofmt', 'golangci-lint', 'gopls']&#xA; Suggested Fixers:&#xA;  'gofmt' - Fix Go files with go fmt.&#xA;  'goimports' - Fix Go files imports with goimports.&#xA;  'remove_trailing_lines' - Remove all blank lines at the end of a file.&#xA;  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.&#xA; Linter Variables:&#xA;&#xA;let g:ale_go_go_executable = 'go'&#xA;let g:ale_go_golangci_lint_executable = 'golangci-lint'&#xA;let g:ale_go_golangci_lint_options = '--enable-all'&#xA;let g:ale_go_golangci_lint_package = 0&#xA;let g:ale_go_gopls_executable = 'gopls'&#xA;let g:ale_go_gopls_options = '--mode stdio'&#xA;let g:ale_go_langserver_executable = 'go-langserver'&#xA;let g:ale_go_langserver_options = ''&#xA; Global Variables:&#xA;&#xA;let g:ale_cache_executable_check_failures = v:null&#xA;let g:ale_change_sign_column_color = 0&#xA;let g:ale_command_wrapper = ''&#xA;let g:ale_completion_delay = v:null&#xA;let g:ale_completion_enabled = 0&#xA;let g:ale_completion_max_suggestions = v:null&#xA;let g:ale_echo_cursor = 1&#xA;let g:ale_echo_msg_error_str = 'Error'&#xA;let g:ale_echo_msg_format = '%code: %%s'&#xA;let g:ale_echo_msg_info_str = 'Info'&#xA;let g:ale_echo_msg_warning_str = 'Warning'&#xA;let g:ale_enabled = 1&#xA;let g:ale_fix_on_save = 0&#xA;let g:ale_fixers = {}&#xA;let g:ale_history_enabled = 1&#xA;let g:ale_history_log_output = 1&#xA;let g:ale_keep_list_window_open = 0&#xA;let g:ale_lint_delay = 200&#xA;let g:ale_lint_on_enter = 1&#xA;let g:ale_lint_on_filetype_changed = 1&#xA;let g:ale_lint_on_insert_leave = 1&#xA;let g:ale_lint_on_save = 1&#xA;let g:ale_lint_on_text_changed = 'normal'&#xA;let g:ale_linter_aliases = {}&#xA;let g:ale_linters = {'go': ['gopls', 'golangci-lint', 'gofmt']}&#xA;let g:ale_linters_explicit = 0&#xA;let g:ale_list_vertical = 0&#xA;let g:ale_list_window_size = 10&#xA;let g:ale_loclist_msg_format = '%code: %%s'&#xA;let g:ale_lsp_root = {}&#xA;let g:ale_max_buffer_history_size = 20&#xA;let g:ale_max_signs = -1&#xA;let g:ale_maximum_file_size = v:null&#xA;let g:ale_open_list = 0&#xA;let g:ale_pattern_options = v:null&#xA;let g:ale_pattern_options_enabled = v:null&#xA;let g:ale_set_balloons = 0&#xA;let g:ale_set_highlights = 1&#xA;let g:ale_set_loclist = 1&#xA;let g:ale_set_quickfix = 0&#xA;let g:ale_set_signs = 1&#xA;let g:ale_sign_column_always = 0&#xA;let g:ale_sign_error = '&amp;gt;&amp;gt;'&#xA;let g:ale_sign_info = '--'&#xA;let g:ale_sign_offset = 1000000&#xA;let g:ale_sign_style_error = '&amp;gt;&amp;gt;'&#xA;let g:ale_sign_style_warning = '--'&#xA;let g:ale_sign_warning = '--'&#xA;let g:ale_sign_highlight_linenrs = 0&#xA;let g:ale_statusline_format = v:null&#xA;let g:ale_type_map = {}&#xA;let g:ale_use_global_executables = v:null&#xA;let g:ale_virtualtext_cursor = 0&#xA;let g:ale_warn_about_trailing_blank_lines = 1&#xA;let g:ale_warn_about_trailing_whitespace = 1&#xA;  Command History:&#xA;&#xA;(executable check - success) gofmt&#xA;(finished - exit code 0) ['/bin/bash', '-c', '''gofmt'' -e ''/tmp/vmCvq7C/1/test.go''']&#xA;&#xA;&amp;lt;&amp;lt;&amp;lt;NO OUTPUT RETURNED&amp;gt;&amp;gt;&amp;gt;&#xA;&#xA;(executable check - success) golangci-lint&#xA;(finished - exit code 3) ['/bin/bash', '-c', 'cd ''/home/zyh/tmp/src'' &amp;amp;&amp;amp; ''golangci-lint'' run ''test.go'' --enable-all']&#xA;&#xA;&amp;lt;&amp;lt;&amp;lt;NO OUTPUT RETURNED&amp;gt;&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="51" LastEditDate="2021-01-27T03:10:39.500" LastActivityDate="2021-01-27T03:10:39.500" Title="ale can't update the status line for golang" Tags="|plugin-you-complete-me|plugin-ale|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="23275" PostTypeId="2" ParentId="23260" CreationDate="2020-03-23T08:09:09.910" Score="2" Body="&lt;h2&gt;Combine &lt;a href=&quot;https://github.com/tommcdo/vim-ninja-feet&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;vim-ninja-feet&lt;/em&gt;&lt;/a&gt; and &lt;a href=&quot;https://github.com/wellle/targets.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;targets.vim&lt;/em&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;h3&gt;Preliminary steps&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Change &lt;code&gt;$&lt;/code&gt; from separator to quote&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup mytargets&#xA;    autocmd!&#xA;    autocmd User targets#mappings#user call targets#mappings#extend({&#xA;        \ '$':{'quote': [{'d': '\$'}]},&#xA;        \ })&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do not know how to make this change filetype-specific. If someone knows this, feel free to adjust this section&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vimtex&lt;/code&gt;&lt;/a&gt; user&lt;/strong&gt;&lt;br&gt;&#xA;Since the OP has added the tag &lt;code&gt;plugin-vimtex&lt;/code&gt;, I assume that the text objects &lt;code&gt;i$&lt;/code&gt; and &lt;code&gt;a$&lt;/code&gt; are defined by &lt;code&gt;vimtex&lt;/code&gt;. To have consistent experience you should unmap them to use &lt;code&gt;i$&lt;/code&gt; and &lt;code&gt;a$&lt;/code&gt; from &lt;code&gt;targets.vim&lt;/code&gt;. To do this add following lines to &lt;code&gt;~/vim/after/ftplugin/tex.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Unmap vimtex versions of i$ and a$ to use versions of targets.vim:&#xA;xunmap &amp;lt;buffer&amp;gt; i$&#xA;ounmap &amp;lt;buffer&amp;gt; i$&#xA;xunmap &amp;lt;buffer&amp;gt; a$&#xA;ounmap &amp;lt;buffer&amp;gt; a$&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now we can combine:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;z[&lt;/code&gt;/&lt;code&gt;z]&lt;/code&gt; + &lt;code&gt;in$&lt;/code&gt;,&lt;code&gt;il$&lt;/code&gt;, ...&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;To illustrate how this works, consider the line from the OP&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;We have two equations $&amp;lt;CURSOR&amp;gt;E=mc^2$ and $&amp;lt;JUMP HERE&amp;gt;F=ma$.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Return to normal mode when in the first equation and then press&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;z[in$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to jump at the beginning of the next equation and switch into insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have many variations at your disposal:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;z]&lt;/code&gt; + &lt;code&gt;in$&lt;/code&gt; jump to the end within the next equation&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;z]&lt;/code&gt; + &lt;code&gt;il$&lt;/code&gt; jump to the end within the previous equation&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;z]&lt;/code&gt; + &lt;code&gt;2in$&lt;/code&gt; jump to the end within the 2nd next equation&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, at the moment staying in normal mode is not supported by &lt;code&gt;vim-ninja-feet&lt;/code&gt; (see &lt;a href=&quot;https://github.com/tommcdo/vim-ninja-feet/issues/3&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue 3 'Make it work in Normal mode'&lt;/a&gt; on github).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Relevant excerpts from the docs:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vim-ninja-feet:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;z[{motion}              Enter |Insert| mode at the beginning of {motion}. For&#xA;                        |characterwise| motions, this is like pressing `i`;&#xA;                        for |linewise| motions, this is like pressing `O`.&#xA;&#xA;&#xA;z]{motion}              Enter |Insert| mode at the end of {motion}. For&#xA;                        |characterwise| motions, this is like pressing `a`;&#xA;                        for |linewise| motions, this is like pressing `o`.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;targets.vim&lt;/code&gt; provides many text objects and many variations of them, please consult the webpage and the full documentation. I just add the beginning of the section about the quote text objects:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;QUOTE TEXT OBJECTS                                *targets-quote-text-objects*&#xA;&#xA;These text objects are similar to the built in text objects such as |i'|.&#xA;Supported trigger characters:&#xA;&#xA;    '         (work on single quotes)&#xA;    &quot;         (work on double quotes)&#xA;    `         (work on back ticks)&#xA;&#xA;These quote text objects try to be smarter than the default ones. They count&#xA;the quotation marks from the beginning of the line to decide which of these&#xA;are the beginning of a quote and which ones are the end.&#xA;&#xA;If you type `ci&quot;` on the `,` in the example below, it will automatically skip&#xA;and change `world` instead of changing `,` between `hello` and `world`.&#xA;&#xA;    join(&quot;hello&quot;, &quot;world&quot;) ~&#xA;         └─────┘  └─────┘     proper quotes&#xA;               └──┘           false quotes&#xA;&#xA;&#xA;Quote text objects work over multiple lines and support |targets-quote-seek|.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Following features of targets.vim are in particular relevant in this context:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/wellle/targets.vim#next-and-last-quote&quot; rel=&quot;nofollow noreferrer&quot;&gt;Next and Last Quote (also with counts)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/wellle/targets.vim#quote-seek&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quote Seek&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2020-03-23T09:19:57.330" LastActivityDate="2020-03-23T09:19:57.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23276" PostTypeId="1" AcceptedAnswerId="23278" CreationDate="2020-03-23T11:08:31.783" Score="2" ViewCount="76" Body="&lt;p&gt;I am making a plugin, and it needs to create files and store them and read them back later. Is there a standard folder to do this? If yes, what's that folder and how to get the path for it in the runtime?&lt;/p&gt;&#xA;" OwnerDisplayName="user27528" LastActivityDate="2020-03-23T14:39:59.550" Title="Where (and how) should plugin generated files be kept" Tags="|plugin-managers|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="23277" PostTypeId="1" AcceptedAnswerId="23285" CreationDate="2020-03-23T13:31:22.273" Score="1" ViewCount="46" Body="&lt;p&gt;I'm attempting to write a Vim macro that will allow me to replace a single variable of a single service across multiple Icinga configuration files. Services are syntactically very similar so I constructed a multi-tier search before replacing the variable.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Writing the Macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qd&#xA;/SERVICE_2&#xA;/max_check_attempts&#xA;:s/5/10/g&#xA;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running the Macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim config-file-*.cfg &#xA;:argdo @d &#xA;:wqall&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Executing this macro however results in only a single file being written, the first one in the args list, whereas I want to make the change to multiple config files (config-file-1.cfg, config-file-2.cfg, etc.). Where am I going wrong? and how do I resolve this issue?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Further Details&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Vim Register for @d:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;d   /SERVICE_2^M/max_check_attempts^M:s/5/10g&amp;lt;80&amp;gt;kb/g^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Args of vim config-file-*.cfg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[config-file-10.cfg] config-file-1.cfg config-file-2.cfg config-file-3.cfg confi&#xA;g-file-4.cfg config-file-5.cfg config-file-6.cfg config-file-7.cfg config-file-8&#xA;.cfg config-file-9.cfg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example contents of a config file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;define service{&#xA;        use                             generic-service &#xA;        host_name                       host1&#xA;        service_description             SERVICE_1&#xA;        is_volatile                     0&#xA;        check_period                    mainperiod&#xA;        max_check_attempts              5&#xA;        normal_check_interval           4&#xA;        retry_check_interval            30&#xA;        contact_groups                  mycontacts&#xA;        notification_interval           15&#xA;        notification_period             mainperiod&#xA;        notification_options            w,u,c,r&#xA;        check_command                   check_service_1&#xA;}&#xA;&#xA;define service{&#xA;        use                             generic-service&#xA;        host_name                       host1&#xA;        service_description             SERVICE_2&#xA;        is_volatile                     0&#xA;        check_period                    mainperiod&#xA;        max_check_attempts              5&#xA;        normal_check_interval           13&#xA;        retry_check_interval            7&#xA;        contact_groups                  mycontacts&#xA;        notification_interval           15&#xA;        notification_period             mainperiod&#xA;        notification_options            w,u,c,r&#xA;        check_command                   check_service_2&#xA;}&#xA;&#xA;define service{&#xA;        use                             generic-service    &#xA;        host_name                       host1&#xA;        service_description             SERVICE_3&#xA;        is_volatile                     0&#xA;        check_period                    mainperiod&#xA;        max_check_attempts              5&#xA;        normal_check_interval           7&#xA;        retry_check_interval            9&#xA;        contact_groups                  mycontacts&#xA;        notification_interval           15&#xA;        notification_period             mainperiod&#xA;        notification_options            w,u,c,r&#xA;        check_command                   check_service_3&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any help offered as well as any quality-of-life and best practices suggestions. &lt;/p&gt;&#xA;" OwnerUserId="27530" LastEditorUserId="27530" LastEditDate="2020-03-23T15:13:03.783" LastActivityDate="2020-03-23T23:07:40.327" Title="Search and Replace - How do you change a specific string across syntactically similar files?" Tags="|search|replace|macro|multiple-files|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23278" PostTypeId="2" ParentId="23276" CreationDate="2020-03-23T14:30:55.263" Score="1" Body="&lt;p&gt;There isn't what I'd call a standard place to put files created by your plugin but there are a handful of accepted practices depending on the exact nature of the generated file(s).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not applicable in your case but worth mentioning is the creation of temporary files. A good idea here is to use methods that are provided by the system for managing such files or, even better, use higher level methods that abstract away the system-specific details (e.g. which directory to store the files in... user's home dir? system wide dir like &lt;code&gt;/tmp&lt;/code&gt;?) Vim provides just such a facility through the &lt;code&gt;tempname()&lt;/code&gt; function.  See &lt;code&gt;:help tempname()&lt;/code&gt; if interested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For non-temporary files one option is to put files in the user's home directory or a newly created subdir thereof. Oftentimes the top level dir name or file name will start with &lt;code&gt;.&lt;/code&gt; so that it is normally hidden in directory listings. You may want to give the user the option of naming this directory/file...or even let them specify any location on disk they'd like to contain the file(s).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second common approach and one we'll go into a bit more detail on is to store the file(s) in a directory that contains the plugin's own files within Vim's user-specific directory (e.g. &lt;code&gt;~/.vim&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We're assuming a typical&lt;sup&gt;1&lt;/sup&gt; plugin that consists of multiple files packaged in its own directory or directories. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim-myplugin&#xA;├── autoload&#xA;│   └── myplugin.vim&#xA;├── doc&#xA;│   └── myplugin.txt&#xA;├── plugin&#xA;│   └── myplugin.vim&#xA;└── README.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the user uses one of the common plugin manager's this tree will often be found in a top level directory of the Vim home with a name like &quot;bundle&quot; or &quot;plugin&quot;.  In any case, we don't want to have to worry about such specifics since they vary from user to user. To allow a dynamic lookup of the plugin location we can use the special keyword &lt;code&gt;&amp;lt;sfile&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's look at how this is used by an actual plugin, unicode.vim, authored by an esteemed contributor to this site. It provides some nice utilities for managing entry and lookup of Unicode characters. A list of the characters and their codes and definitions is usually downloaded to local disk to allow for quick look-ups of the latest information. The download is done by the autoload script starting with this line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:directory = expand(&quot;&amp;lt;sfile&amp;gt;:p:h&quot;).&quot;/unicode&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That variable will be initialized the first time the script is loaded/sourced. The value of &lt;code&gt;&amp;lt;sfile&amp;gt;&lt;/code&gt; alone would be a path to the script file itself. With the modifiers the value will be the &lt;em&gt;full&lt;/em&gt; path (&lt;code&gt;:p&lt;/code&gt;) of the directory containing the script (&lt;code&gt;:h&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since that script is in the autoload dir the root of the plugin can be found by adding one more &lt;code&gt;:h&lt;/code&gt;....&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:pluginroot = expand(&quot;&amp;lt;sfile&amp;gt;:p:h:h&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I imagine you can take it from and figure out how to integrate this into your own project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; &lt;sub&gt;I'd consider single-file plugins less typical and, anyways, not really suited to this use case.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-03-23T14:39:59.550" LastActivityDate="2020-03-23T14:39:59.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23279" PostTypeId="1" CreationDate="2020-03-23T15:39:06.073" Score="0" ViewCount="224" Body="&lt;p&gt;I have this text :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;He's a &lt;strong&gt;self made man&lt;/strong&gt; who gets what he wants. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The small blue &lt;strong&gt;forget me not&lt;/strong&gt; flower was first used by the Grand&#xA;  Lodge.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyFunction()&#xA;let myList1 = [&quot;self made man&quot;, &quot;gorget me not&quot;]&#xA;for elem in MyList1&#xA;        if search(&quot;=/elem&quot;, 'W') == 0&#xA;           echo &quot;I want to replace space by hyphen between this three words&quot;  &#xA;           ---&amp;gt; CODE&#xA;        endif&#xA;endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to get this text after executing the function :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;He's a &lt;strong&gt;self-made-man&lt;/strong&gt; who gets what he wants. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The small blue &lt;strong&gt;forget-me-not&lt;/strong&gt; flower was first used by the Grand&#xA;  Lodge.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Can you help me to write the missing line (&lt;code&gt;---&amp;gt; CODE&lt;/code&gt;) ?&lt;/p&gt;&#xA;" OwnerUserId="26872" LastEditorUserId="10604" LastEditDate="2020-03-24T13:03:00.647" LastActivityDate="2022-10-30T15:06:55.850" Title="How to replace spaces inside a selection" Tags="|regular-expression|replace|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23280" PostTypeId="2" ParentId="23279" CreationDate="2020-03-23T15:46:22.857" Score="1" Body="&lt;p&gt;You're looking for the &lt;code&gt;substitute()&lt;/code&gt; function...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;substitute({expr}, {pat}, {sub}, {flags})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;expr&lt;/code&gt; is the string to work on&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;pat&lt;/code&gt; is the pattern similar to &lt;code&gt;:s/pat/sub/g&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sub&lt;/code&gt; is the substitution similar to &lt;code&gt;sub&lt;/code&gt; in the same &lt;code&gt;:s&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;flags&lt;/code&gt;, should include &quot;g&quot; as in global (again, like &lt;code&gt;:s&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let elem = substitute(elem, ' ', '-', 'g')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second param could also be &lt;code&gt;'\s'&lt;/code&gt; indicating a single whitespace char.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2020-03-23T15:46:22.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23281" PostTypeId="1" AcceptedAnswerId="23292" CreationDate="2020-03-23T15:55:00.187" Score="4" ViewCount="1198" Body="&lt;p&gt;Often times I use vim as a scratchpad - I just want to throw some text in there, maybe copy it to the clipboard, or munge it a bit, but it's not really important to keep it around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the time I do &lt;code&gt;vim /tmp/foo.txt&lt;/code&gt; or whatever, but this gets a bit annoying. I combined &lt;a href=&quot;https://vi.stackexchange.com/a/12230/5574&quot;&gt;this answer&lt;/a&gt; with some responses on a previous question of mine and came up with this solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim +noswapfile +&quot;set buftype=nofile&quot; +&quot;set bufhidden=hide&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which actually works! But... it's a bit wordy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a shorter way to start vim with a scratch buffer (without using a plugin)?&lt;/p&gt;&#xA;" OwnerUserId="5574" LastActivityDate="2020-03-25T21:22:56.970" Title="Is there a shorter way to start vim with scratch buffer?" Tags="|startup|scratch-buffer|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23282" PostTypeId="2" ParentId="23281" CreationDate="2020-03-23T16:05:45.203" Score="1" Body="&lt;p&gt;Create a function, and then call said function from console when opening vim with the &lt;code&gt;-c&lt;/code&gt; flag?&lt;/p&gt;&#xA;" OwnerUserId="27444" LastEditorUserId="27444" LastEditDate="2020-03-23T18:41:38.227" LastActivityDate="2020-03-23T18:41:38.227" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23283" PostTypeId="2" ParentId="23279" CreationDate="2020-03-23T16:31:45.073" Score="-1" Body="&lt;p&gt;Here's my function (based on &lt;a href=&quot;https://vi.stackexchange.com/a/23280/10604&quot;&gt;@BLayer’s answer&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;He's a &lt;strong&gt;self made man&lt;/strong&gt; who gets what he wants. The small blue&#xA;  &lt;strong&gt;forget me not&lt;/strong&gt; flower was first used by the Grand Lodge.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyFunction()&#xA;     let myList1 = [&quot;self made man&quot;, &quot;forget me not&quot;]&#xA;     for elem1 in myList1&#xA;        if search(&quot;=/elem1&quot;, 'W') == 0&#xA;           let elem2 = substitute(elem1, ' ', '-', 'g')&#xA;           exe '%s/'elem1.'/'elem2&#xA;        endif&#xA;     endfor&#xA;endfunction&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;He's a &lt;strong&gt;self-made-man&lt;/strong&gt; who gets what he wants. The small blue&#xA;  &lt;strong&gt;forget-me-not&lt;/strong&gt; flower was first used by the Grand Lodge.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="26872" LastEditorUserId="10604" LastEditDate="2020-03-24T13:05:07.777" LastActivityDate="2020-03-24T13:05:07.777" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23285" PostTypeId="2" ParentId="23277" CreationDate="2020-03-23T23:07:40.327" Score="3" Body="&lt;p&gt;&lt;code&gt;:argdo @d&lt;/code&gt; doesn’t act like executing &lt;code&gt;@d&lt;/code&gt; in every buffer in the arg list: it instead runs &lt;code&gt;:@d&lt;/code&gt; in each buffer. It doesn’t execute the contents of the d register as a &lt;em&gt;macro&lt;/em&gt;: it executes them as an &lt;em&gt;Ex command&lt;/em&gt;. See &lt;code&gt;:help argdo&lt;/code&gt; and &lt;code&gt;:help :@&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try &lt;code&gt;:argdo norm!@d&lt;/code&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-03-23T23:07:40.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23286" PostTypeId="2" ParentId="23281" CreationDate="2020-03-24T04:07:14.673" Score="1" Body="&lt;p&gt;There might be better approaches (e.g. alias to &lt;code&gt;vim +noswapfile +&quot;set buftype=nofile&quot; +&quot;set bufhidden=hide&quot;&lt;/code&gt;) but you can also use &lt;code&gt;VimEnter&lt;/code&gt; autocommand to set up initial things, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! ScratchBuffer() abort&#xA;    if bufname() == ''&#xA;        setl buftype=nofile&#xA;        setl bufhidden=hide&#xA;        setl noswapfile&#xA;    endif&#xA;endfunc&#xA;&#xA;augroup vim_start | au!&#xA;    au VimEnter * call ScratchBuffer()&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not sure if check for an empty buffer name is enough but a quick test I did turned out ok for me.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-03-24T04:07:14.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23287" PostTypeId="1" CreationDate="2020-03-24T06:41:52.763" Score="4" ViewCount="705" Body="&lt;p&gt;I have this function which insert 2 dates in a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MaFunction()&#xA;    put =strftime(\&quot;%c\&quot;)&#xA;    exe 'w'&#xA;    exe 'call Function1()'&#xA;    put = strftime(\&quot;%c\&quot;)&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;24/03/2020 07:31:22&#xA;24/03/2020 07:31:28&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to know how long Function1 takes to run and display it like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;Duration = &quot;+ result + &quot; seconds.&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Duration = 6 seconds.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you help me please?&lt;/p&gt;&#xA;" OwnerUserId="26872" LastEditorUserId="51" LastEditDate="2020-03-24T08:04:53.197" LastActivityDate="2020-03-24T11:02:09.470" Title="How can I calculate the duration of a function call?" Tags="|vimscript|date-and-time|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23288" PostTypeId="2" ParentId="23287" CreationDate="2020-03-24T07:36:19.483" Score="1" Body="&lt;p&gt;You can try using &lt;code&gt;strptime&lt;/code&gt; function, if available, to convert both dates to unix time, substract and get number of seconds. Unfortunately on my win box this func is not available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this, &lt;strong&gt;NOT TESTED&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let u_time1 = strptime(&quot;%c&quot;, &quot;24/03/2020 07:31:22&quot;)&#xA;let u_time2 =  strptime(&quot;%c&quot;, &quot;24/03/2020 07:31:28&quot;)&#xA;&#xA;echo &quot;Duration = &quot; . (u_time2 - u_time1) . &quot; seconds.&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS, well of course there will be no seconds but milliseconds, so divide it by 1000.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PPS, or not milliseconds :), depends on implementation and I can't check it :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Another update.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you will use &lt;code&gt;localtime()&lt;/code&gt; function instead of &lt;code&gt;strftime&lt;/code&gt; (and if you don't need human readable dates) then it would be easy (&lt;code&gt;for&lt;/code&gt; cycle is for testing purposes to get ~4 seconds between &lt;code&gt;localtime&lt;/code&gt; calls):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let u_time1 = localtime()&#xA;&#xA;for x in range(100000)&#xA;    echo x&#xA;endfor&#xA;&#xA;let u_time2 = localtime()&#xA;&#xA;echom &quot;Duration = &quot; . (u_time2 - u_time1) . &quot; seconds.&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-03-24T07:50:18.373" LastActivityDate="2020-03-24T07:50:18.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23289" PostTypeId="2" ParentId="23287" CreationDate="2020-03-24T08:02:56.260" Score="7" Body="&lt;p&gt;There is the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#reltime%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;reltime()&lt;/code&gt;&lt;/a&gt; function to get relative times, and &lt;a href=&quot;https://vimhelp.org/eval.txt.html#reltimestr%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;reltimestr()&lt;/code&gt;&lt;/a&gt; to display that as the number of seconds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let start = reltime()&#xA;:echo reltime(start)&#xA;[65, 11796]&#xA;:echo reltimestr(reltime(start))&#xA; 71.267801&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in your case, you would do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MaFunction()&#xA;    let start = reltime()&#xA;    call Function1()&#xA;    echom printf('Duration = %s seconds', reltimestr(reltime(start)))   &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2020-03-24T08:02:56.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23290" PostTypeId="1" AcceptedAnswerId="23316" CreationDate="2020-03-24T08:39:58.723" Score="2" ViewCount="1672" Body="&lt;p&gt;I'm configuring a vim environment with YCM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the Vundle to manage the vim plugins and here is my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;filetype off&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&quot; let Vundle manage Vundle, required&#xA;Plugin 'VundleVim/Vundle.vim'&#xA;&#xA;Plugin 'Valloric/YouCompleteMe'&#xA;Plugin 'rdnetto/YCM-Generator'&#xA;&#xA;call vundle#end()&#xA;&#xA;filetype plugin indent on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, after executing &lt;code&gt;&quot;PluginInstall&lt;/code&gt; in my vim, I find that YCM is not loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then Google tells me that I need to add &lt;code&gt;set rtp+=~/.vim/bundle/YouCompleteMe&lt;/code&gt; into my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, it works but as the Vundle is a plugin manager, can't it load the plugin YCM automatically?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My colleague used another plugin manager: &lt;code&gt;pathogen&lt;/code&gt;, I'm not sure but it seems that calling the function &lt;code&gt;pathogen#infect()&lt;/code&gt; may load YCM automatically? So &lt;code&gt;pathogen&lt;/code&gt; is better than &lt;code&gt;Vundle&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2020-03-24T09:08:45.693" LastActivityDate="2020-03-25T16:40:31.370" Title="Why can't YCM be loaded automatically" Tags="|plugin-you-complete-me|plugin-vundle|plugin-pathogen|plugin-managers|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23291" PostTypeId="2" ParentId="23287" CreationDate="2020-03-24T11:02:09.470" Score="1" Body="&lt;p&gt;In my plugin library, I define the &lt;a href=&quot;https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/time.vim#L51&quot; rel=&quot;nofollow noreferrer&quot;&gt;following&lt;/a&gt; to help running a function n times in order to have an estimation of the time it takes to execute&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's meant to be used this way&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo lh#time#bench_n(10000, function('Function1'), the, list, of, parameters)[1] / 10000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;lh#time#bench_n()&lt;/code&gt; returns a list of two elements: the 10000 results of the 10000 function calls (in order to check the function, and the benchmark, execute correctly -- when the parameters are lists, there are some mishaps sometimes and we need to control we are benchmarking something meaningful), and the total execution time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The becnhmarking functions are defined this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; # Bench&#xA; {{{2&#xA;&quot; Function: lh#time#bench(F) {{{3&#xA;if exists('*reltimefloat')&#xA;  function! lh#time#bench(F, ...) abort&#xA;    let t0 = reltime()&#xA;    let res = call(a:F, a:000)&#xA;    let t = reltime()&#xA;    return [res, reltimefloat(reltime(t0, t))]&#xA;  endfunction&#xA;elseif exists('*reltime')&#xA;  function! lh#time#bench(F, ...) abort&#xA;    let t0 = reltime()&#xA;    let res = call(a:F, a:000)&#xA;    let t = reltime()&#xA;    return [res, eval(reltimestr(reltime(t0, t)))]&#xA;  endfunction&#xA;else&#xA;  function! lh#time#bench(F, ...) abort&#xA;    let res = call(a:F, a:000)&#xA;    return [res, 0]&#xA;  endfunction&#xA;endif&#xA;&#xA;&quot; Function: lh#time#bench_n(n, F, ...) {{{3&#xA;function! lh#time#bench_n(n, F, ...) abort&#xA;  let tot = 0&#xA;  for i in range(1, a:n)&#xA;    let [res, b] = call('lh#time#bench', [a:F] + deepcopy(a:000))&#xA;    let tot += b&#xA;  endfor&#xA;  return [res, tot]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2020-03-24T11:02:09.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23292" PostTypeId="2" ParentId="23281" CreationDate="2020-03-24T13:12:13.660" Score="1" Body="&lt;p&gt;A &lt;code&gt;sh&lt;/code&gt;/&lt;code&gt;bash&lt;/code&gt; answer (even though the site is vi)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vtmp () {&#xA;  vim +noswapfile +&quot;setlocal buftype=nofile&quot; +&quot;setlocal bufhidden=hide&quot; &quot;$@&quot;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A vim answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put this function in your vimrc or in a &lt;code&gt;plugin/&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Scratch()&#xA;  setlocal noswapfile&#xA;  setlocal buftype=nofile&#xA;  setlocal bufhidden=hide&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then call vim as &lt;code&gt;vim -c 'call Scratch()'&lt;/code&gt;, or make a sh function similar to the above. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-03-25T21:22:56.970" LastActivityDate="2020-03-25T21:22:56.970" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23293" PostTypeId="1" AcceptedAnswerId="23295" CreationDate="2020-03-24T15:26:39.857" Score="2" ViewCount="270" Body="&lt;p&gt;What is that X on the corner? What is it for and what does it do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I opened Vim with &lt;code&gt;vim -p tab1 tab2&lt;/code&gt; on Windows 10 and in WLS with Ubuntu and they both have it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dIJ0r.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dIJ0r.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="27075" LastActivityDate="2020-03-24T16:34:39.800" Title="What is the X that appears on the top right corner when multiple tabs are open?" Tags="|tabbed-user-interface|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23294" PostTypeId="1" AcceptedAnswerId="23298" CreationDate="2020-03-24T15:59:45.243" Score="1" ViewCount="229" Body="&lt;p&gt;I have numbers&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0.655&#xA;1.455&#xA;1.21&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I increment/decrement these numbers by their thousandths digit such that &lt;code&gt;901&amp;lt;c-a&amp;gt;&lt;/code&gt; produces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.556&#xA;2.356&#xA;2.111&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I saw this question, which may be applicable here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/20177/custom-number-format-for-ctrla&quot;&gt;Custom Number Format for CTRL+A&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9755" LastActivityDate="2020-04-07T02:53:09.717" Title="Ctrl-A/Ctrl-X for numbers with a decimal number" Tags="|key-bindings|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23295" PostTypeId="2" ParentId="23293" CreationDate="2020-03-24T16:34:39.800" Score="4" Body="&lt;p&gt;Allows you to close a tab with a mouse. (You'll probably need to enable mouse support enabled)&lt;/p&gt;&#xA;" OwnerUserId="27444" LastActivityDate="2020-03-24T16:34:39.800" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23296" PostTypeId="2" ParentId="93" CreationDate="2020-03-24T22:57:09.667" Score="38" Body="&lt;p&gt;Nowdays (meaning Vim  &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.1270&quot; rel=&quot;noreferrer&quot;&gt;8.1.1270&lt;/a&gt;) you can use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set shortmess-=S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to enable a count of &lt;code&gt;[x/y]&lt;/code&gt; showing in the bottom right corner every time you do a &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt; search.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9XJw2.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9XJw2.png&quot; alt=&quot;native search count&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/options.txt.html#%27shortmess%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;Relavant section from the Vim help&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that if the search finds more than 99 results, Vim unfortunately just shows &lt;code&gt;[x/&amp;gt;99]&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8I5Hp.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8I5Hp.png&quot; alt=&quot;native search count over 99&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;For this reason, I personally use &lt;a href=&quot;https://github.com/google/vim-searchindex&quot; rel=&quot;noreferrer&quot;&gt;google/vim-searchindex&lt;/a&gt;, which works for any amount of results:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hFBxp.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hFBxp.png&quot; alt=&quot;vim-search-index search count&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;(By default the plugin is limited to files with &amp;quot;only&amp;quot; less than 100k lines, this can be adjusted with &lt;code&gt;let g:searchindex_line_limit=1000000&lt;/code&gt; though.)&lt;/p&gt;&#xA;" OwnerUserId="21062" LastEditorUserId="21062" LastEditDate="2021-01-06T20:17:40.633" LastActivityDate="2021-01-06T20:17:40.633" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="23297" PostTypeId="1" AcceptedAnswerId="23299" CreationDate="2020-03-24T23:57:15.403" Score="3" ViewCount="238" Body="&lt;p&gt;Please explain following two lines found in &lt;code&gt;synload.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:cpo_save = &amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is &lt;code&gt;vim&lt;/code&gt; in the last expression? What is result of such an expression, and what does it affect?&lt;/p&gt;&#xA;" OwnerUserId="25325" LastEditorUserId="10604" LastEditDate="2020-03-26T14:41:21.033" LastActivityDate="2020-03-26T14:41:21.033" Title="Why does vimscript use `set cpo&amp;vim`?" Tags="|vimscript|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="23298" PostTypeId="2" ParentId="23294" CreationDate="2020-03-25T00:07:02.063" Score="1" Body="&lt;p&gt;I wrote something similar recently, I changed it again to make &lt;code&gt;&amp;lt;c-a&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; work on any step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may get the command &lt;a href=&quot;https://github.com/dedowsdi/.vim/blob/cd6b90fdb29a49c4ffd8b04bc90049015773ee8e/plugin/misc.vim#L247&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and the function &lt;a href=&quot;https://github.com/dedowsdi/.vim/blob/cd6b90fdb29a49c4ffd8b04bc90049015773ee8e/autoload/misc.vim#L637&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It support &lt;code&gt;123.24&lt;/code&gt; or &lt;code&gt;123.&lt;/code&gt; or &lt;code&gt;123&lt;/code&gt; or &lt;code&gt;.123&lt;/code&gt; style number, &lt;code&gt;count&lt;/code&gt; is also supported now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# change slide step to 0.000001, &#xA;Slide 0.000001&#xA;&#xA;# change slide step to 0.1, save after slide. I use this to&#xA;# trigger some hot reload.&#xA;Slide! 0.1&#xA;&#xA;# retrieve default behavior&#xA;Slide 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-04-07T02:53:09.717" LastActivityDate="2020-04-07T02:53:09.717" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="23299" PostTypeId="2" ParentId="23297" CreationDate="2020-03-25T00:21:23.883" Score="6" Body="&lt;p&gt;It resets &lt;a href=&quot;http://vimhelp.appspot.com/options.txt.html#%27cpo%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'cpo'&lt;/code&gt;&lt;/a&gt;&#xA; value to its default value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some people may be running vim in compatible mode, by choice or not. In those cases, various things would be inhibited, things we usually rely upon when writing plugins -- in particular &lt;a href=&quot;http://vimhelp.appspot.com/repeat.txt.html#line%2dcontinuation&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:h line-continuation&lt;/code&gt;&lt;/a&gt;. As a consequence, the plugins would emit many error messages. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Resetting &lt;code&gt;'cpo'&lt;/code&gt; to its &lt;em&gt;factory&lt;/em&gt; setting, the plugin becomes resilient to these hostile (IMO) configurations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This syntax could be used with many (all?) vim options. Before doing that, we record the old value in order to properly restore it afterward&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:cpo_save = &amp;amp;cpo&#xA;set cpo&amp;amp;vim&#xA;.&#xA;. plugin code&#xA;.&#xA;let &amp;amp;cpo = s:cpo_save&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2020-03-25T14:34:58.407" LastActivityDate="2020-03-25T14:34:58.407" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23300" PostTypeId="1" CreationDate="2020-03-25T01:52:23.337" Score="1" ViewCount="77" Body="&lt;p&gt;I'm trying to toggle some ctrl maps in command directly, it didn't work as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com Test0 nnoremap &amp;lt;c-j&amp;gt; :echo &quot;c-j&quot;&amp;lt;cr&amp;gt;&#xA;com Test1 nnoremap &amp;lt;c-h&amp;gt; :echo &quot;c-h&quot;&amp;lt;cr&amp;gt;&#xA;com Test2 exe 'nnoremap &amp;lt;c-l&amp;gt; :echo &quot;c-l&quot;&amp;lt;cr&amp;gt;'&#xA;com Test3 exe 'nnoremap &amp;lt;c-right&amp;gt; :echo &quot;c-right&quot;&amp;lt;cr&amp;gt;'&#xA;&#xA;&quot; uncomment this, I see results of :map and &quot;E15: invalid expression: ^M&quot;&#xA;&quot; Test0&#xA;Test1&#xA;Test2&#xA;Test3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Only &lt;code&gt;Test1&lt;/code&gt; and &lt;code&gt;Test2&lt;/code&gt; works. &#xA;&lt;code&gt;Test0&lt;/code&gt; works like &lt;code&gt;:map&lt;/code&gt;, have no idea why that happens.&#xA;If I execute the &lt;code&gt;exe ...&lt;/code&gt; or &lt;code&gt;nnoremap ...&lt;/code&gt; sub command in command line, everything works. what am I missing?&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-03-25T02:15:01.897" LastActivityDate="2020-03-25T05:40:50.713" Title="How to create ctrl map in command directly?" Tags="|key-bindings|command|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23301" PostTypeId="2" ParentId="23300" CreationDate="2020-03-25T03:16:20.390" Score="1" Body="&lt;p&gt;Hmm. This is interesting. Here's what get saved as the command (&lt;code&gt;:com Test0&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;NL&amp;gt; :echom &quot;c-j&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;&amp;lt;C-J&amp;gt;&lt;/code&gt; is equivalent to &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; in Vim)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what do we know about the &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; format? That it can be used in mappings and abbreviations as a substitute for the represented keys/chars. That it can be used in &lt;code&gt;exe&lt;/code&gt; command arguments the same way but only if escaped (e.g. &lt;code&gt;\&amp;lt;Tab&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that command is entered directly it works. It would make sense that it should do the same when run by the operation generated by &lt;code&gt;com&lt;/code&gt;. But it doesn't. Instead the &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; is acting like Enter key and when &lt;code&gt;Test0&lt;/code&gt; is run it submits the &lt;code&gt;nnoremap&lt;/code&gt; alone, immediately. And, actually, we can't assume that something executed indirectly follows the exact same documented behavior as for the directly entered equivalent and obviously it's not here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without diving into the code (which I might just do) I can only surmise. There &lt;em&gt;is&lt;/em&gt; something that makes &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; different from other key(codes). Along with &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; it is the only thing that can submit commands for execution (&lt;code&gt;:h c_&amp;lt;NL&amp;gt;&lt;/code&gt;: &quot;start entered command&quot;). I'd assume that's a crucial detail here with respect to why other special keycodes (e.g. &lt;code&gt;&amp;lt;c-h&amp;gt;&lt;/code&gt;) don't behave differently than expected. Note that if you skim through the results of, for example, &lt;code&gt;:helpgrep &amp;lt;NL&amp;gt;&lt;/code&gt; you'll see there are various places where &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; have exceptional behavior and/or are treated differently than most other special characters. So I don't think what we're seeing here, while a head-scratcher, is totally unexpected or unprecedented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, for now I at least can offer a working version. This successfully escapes the mapped key...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com! Test0 exe 'nnoremap \&amp;lt;c-j&amp;gt; :echom &quot;c-j&quot;&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Funny things is, this just adds to the mystery, really. Now we're sort of doing double indirection/interpretation and it works the way we'd expect! Interesting.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-03-25T05:40:50.713" LastActivityDate="2020-03-25T05:40:50.713" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="23303" PostTypeId="1" CreationDate="2020-03-25T09:17:30.493" Score="-2" ViewCount="63" Body="&lt;p&gt;I have text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I want to select nest and not nestlé in this text. Only the word nest!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and a list :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myList = [&quot;nest&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyFunction()&#xA;  myList = [&quot;nest&quot;]&#xA;  for elem in MyList&#xA;        if search(&quot;=/elem&quot;, 'W') == 0&#xA;           exe '%s/'elem '\{0\}/REPLACE/g'&#xA;        endif&#xA;  endfor&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you help me, please, to get strightly the word &lt;code&gt;\&amp;lt;nest\&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="26872" LastEditorUserId="10604" LastEditDate="2020-03-25T12:50:35.917" LastActivityDate="2020-03-25T14:25:19.247" Title="How to research strightly a word in a loop?" Tags="|search|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23304" PostTypeId="2" ParentId="23303" CreationDate="2020-03-25T09:56:47.233" Score="2" Body="&lt;p&gt;You have a text (where? in a buffer? in a variable?) and you want replace words given in a list in the text with &lt;code&gt;REPLACE&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TEXT:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I want to select nest and not nestlé in this text. Only the word nest!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;LIST OF WORDS:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;['nest', 'this']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;RESULT:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I want to select REPLACE and not nestlé in REPLACE text. Only the word REPLACE!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming TEXT is in buffer on a first row:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for word in ['nest', 'this']&#xA;    &quot; replace text in the first row&#xA;    exe printf('1s/\&amp;lt;%s\&amp;gt;/%s/g', word, 'REPLACE')&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BITl5.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BITl5.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If text is in variable, use &lt;code&gt;substitute&lt;/code&gt; function instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:text = 'I want to select nest and not nestlé in this text. Only the word nest!'&#xA;&#xA;for word in ['nest', 'this']&#xA;    let s:text = substitute(s:text, '\&amp;lt;'.word.'\&amp;gt;', 'REPLACE', 'g')&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YX4rX.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YX4rX.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here of course you can be creative, for example use for loop to generate regex with all words combined and apply substitute only once or smth else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt; if you want to substitute text in a whole buffer you can do following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for word in ['nest', 'this']&#xA;    &quot; replace text in the whole buffer&#xA;    exe printf('%%s/\&amp;lt;%s\&amp;gt;/%s/g', word, 'REPLACE')&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE: &lt;code&gt;%%&lt;/code&gt; is to escape percent char, otherwise &lt;code&gt;printf&lt;/code&gt; will substitute &lt;code&gt;%s&lt;/code&gt; command with &lt;code&gt;word&lt;/code&gt; which is not what you want.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-03-25T14:25:19.247" LastActivityDate="2020-03-25T14:25:19.247" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23306" PostTypeId="1" AcceptedAnswerId="23312" CreationDate="2020-03-25T10:49:03.333" Score="2" ViewCount="1117" Body="&lt;p&gt;I'm trying to wrap my head around how Vim deals with line endings in different file formats. Say you have a file with DOS line endings, file.txt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo -en 'line1\nline2' &amp;gt; file.txt&#xA;unix2dos file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I open this one in Vim,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -u NORC -b file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm given the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line1^M&#xA;line2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far so good. I'm expecting &lt;code&gt;^M&lt;/code&gt; which is how Vim displays the DOS carriage return. &lt;strong&gt;But how do I edit this file - without changing the file format - and having the correct set of new line characters?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do &lt;code&gt;vim -u NORC -c 'set ff=dos' -b file.txt&lt;/code&gt; and add some newlines, they do not show up with a &lt;code&gt;^M&lt;/code&gt; carriage return when I save and reopen the file. Is this to be expected? Am I missing some Vim configuration?&lt;/p&gt;&#xA;" OwnerUserId="27563" LastEditorUserId="18609" LastEditDate="2020-03-25T14:44:37.583" LastActivityDate="2020-03-26T08:48:14.157" Title="Why does not Vim feed the correct set of newline characters?" Tags="|line-breaks|file-formats|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23307" PostTypeId="2" ParentId="23303" CreationDate="2020-03-25T11:03:34.810" Score="-2" Body="&lt;p&gt;I have found :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe printf('1,'.line('$').'s/\&amp;lt;%s\&amp;gt;/%s/g', elem, 'REPLACE')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26872" LastActivityDate="2020-03-25T11:03:34.810" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23308" PostTypeId="1" AcceptedAnswerId="23311" CreationDate="2020-03-25T11:29:48.430" Score="3" ViewCount="2510" Body="&lt;p&gt;When working on a file, I often open another file by&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;looking for the file by opening the file browser in a vertical split with &lt;code&gt;:Vex&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Opening the file&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;it's actually nice to have the file browser show up on the left side, but I would like to have the 2nd file then open on the right split. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar in case I want to open a file based on a horizontal split with &lt;code&gt;:Hex&lt;/code&gt;. I then would like to have the browser showing up on top and the file to open at the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried with adding&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set splitright&#xA;set splitbelow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to my .vimrc, but that only affects splits initiated by &lt;code&gt;:vsp&lt;/code&gt; and &lt;code&gt;:sp&lt;/code&gt; for a vertical and horizontal split, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can rotate the splits afterwards with &lt;code&gt;Ctl+W&lt;/code&gt; followed by &lt;code&gt;r&lt;/code&gt;, but I would love to immediately have it like described.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any ideas!&lt;/p&gt;&#xA;" OwnerUserId="27564" LastActivityDate="2020-11-07T11:16:04.043" Title="How to make :Vex / :Hex open on the right side / below" Tags="|split|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23309" PostTypeId="1" CreationDate="2020-03-25T13:37:56.607" Score="1" ViewCount="53" Body="&lt;p&gt;Basically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat -&amp;gt; horse&#xA;CAT -&amp;gt; HORSE&#xA;Cat -&amp;gt; Horse&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know this is underspecified (e.g. unclear what cAt should become). However, is there a canonical solution for this?&lt;/p&gt;&#xA;" OwnerUserId="15077" LastActivityDate="2020-03-25T13:53:07.153" Title="How can I replace a word while keeping the original casing?" Tags="|replace|letter-case|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23310" PostTypeId="2" ParentId="23309" CreationDate="2020-03-25T13:53:07.153" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/tpope/vim-abolish&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-abolish&lt;/a&gt; plug-in implements a &lt;code&gt;:Subvert&lt;/code&gt; command that performs substitutions taking case in consideration. (It can also preserve plurals, including exceptions in plural forms.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/tpope/vim-abolish/blob/master/README.markdown#substitution&quot; rel=&quot;nofollow noreferrer&quot;&gt;the README file&lt;/a&gt; with examples, specifically on case:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Oh, but the case variants!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;:%s/Facility/Building/g&#xA;:%s/FACILITY/BUILDING/g&#xA;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Abolish.vim has your back. One command to do all six, and you can repeat it with &lt;code&gt;&amp;amp;&lt;/code&gt; too!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;:%Subvert/facilit{y,ies}/building{,s}/g&#xA;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-25T13:53:07.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23311" PostTypeId="2" ParentId="23308" CreationDate="2020-03-25T14:03:10.620" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How to make &lt;code&gt;:Vex&lt;/code&gt; / &lt;code&gt;:Hex&lt;/code&gt; open on the right side / below?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Both these commands have a variant with &lt;code&gt;!&lt;/code&gt; that switches to splitting on the opposite side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can use &lt;code&gt;:Vex!&lt;/code&gt; and &lt;code&gt;:Hex!&lt;/code&gt; to open on the right side, and below, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/pi_netrw.txt.html#netrw-%3AVexplore&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help netrw-:Vexplore&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;:[N]Vexplore  [dir]&lt;/code&gt; does an &lt;code&gt;:Explore&lt;/code&gt; with &lt;code&gt;:leftabove&lt;/code&gt;  vertical splitting.&lt;br&gt;&#xA;  &lt;code&gt;:[N]Vexplore! [dir]&lt;/code&gt; does an &lt;code&gt;:Explore&lt;/code&gt; with &lt;code&gt;:rightbelow&lt;/code&gt; vertical splitting.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And quite similarly on &lt;a href=&quot;https://vimhelp.org/pi_netrw.txt.html#netrw-%3AHexplore&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help netrw-:Hexplore&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-25T14:03:10.620" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23312" PostTypeId="2" ParentId="23306" CreationDate="2020-03-25T15:14:49.937" Score="6" Body="&lt;p&gt;There are two problems with your approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First is using &lt;code&gt;-b&lt;/code&gt; which turns on the &lt;code&gt;'binary'&lt;/code&gt; setting and the binary setting will &lt;em&gt;ignore&lt;/em&gt; fileformat. See this snippet of &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27binary%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'binary'&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also, &lt;code&gt;'fileformat'&lt;/code&gt; and &lt;code&gt;'fileformats'&lt;/code&gt; options will not be used, the file is read and written like &lt;code&gt;'fileformat'&lt;/code&gt; was &quot;unix&quot; (a single &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt; separates lines).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The second part is that using &lt;code&gt;-c&lt;/code&gt; to set fileformat is too late, since &lt;code&gt;-c&lt;/code&gt; only executes after the file given on the command-line has been already opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;can&lt;/em&gt; work around that by using a &lt;a href=&quot;https://vimhelp.org/starting.txt.html#--cmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;--cmd&lt;/code&gt;&lt;/a&gt; argument in the command-line, though it's not ideal because &lt;code&gt;--cmd&lt;/code&gt; is executed too early (before any vimrc is read) and ideally you'd want to be more specific about opening &lt;em&gt;that&lt;/em&gt; file with DOS format only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, this will work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim -u NORC --cmd 'set ff=dos' file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(BTW, I really recommend you also pass &lt;code&gt;-N&lt;/code&gt; here to set nocompatible mode.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that when you properly open the file with DOS fileformat, you &lt;em&gt;won't&lt;/em&gt; see any &lt;code&gt;^M&lt;/code&gt;s displayed inside Vim. That's the whole point, Vim has parsed the file from its file format, so now it's no longer a &quot;DOS newline&quot; but simply a &quot;newline&quot;, so Vim will just show it as such. Vim still knows this file was a DOS fileformat file, so when it writes it back to disk, it will preserve that format and use &quot;DOS newlines&quot;. That is, unless you change fileformat while editing or right before saving it, which is useful to have Vim convert file formats.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your file also doesn't have a newline at the end of the file. Vim should correctly point that out when you open the file by setting &lt;code&gt;noeol&lt;/code&gt;. (If you're not in nocompatible mode, then Vim reports this loudly as &lt;code&gt;[Incomplete last line]&lt;/code&gt;.) Which is fine, Vim can properly deal with such files. But the default behavior is for Vim to &quot;fix&quot; that when writing the file, by adding a newline to the last line. That is controlled by the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27fixendofline%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'fixendofline'&lt;/code&gt;&lt;/a&gt; option, which defaults to being enabled. If you want to preserve your last line without a newline, you can just &lt;code&gt;set nofixeol&lt;/code&gt; in addition to your other options.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I previously mentioned that using &lt;code&gt;--cmd 'set ff=dos'&lt;/code&gt; was too strong of a workaround. A better approach to use a specific file format while opening a file is using a &lt;a href=&quot;https://vimhelp.org/editing.txt.html#%2B%2Bopt&quot; rel=&quot;nofollow noreferrer&quot;&gt;++opt&lt;/a&gt; to the &lt;code&gt;:e&lt;/code&gt; command. So after you start Vim, passing it no file in the command-line, you can:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e ++ff=dos file.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will open &lt;em&gt;that&lt;/em&gt; file only forcing a DOS fileformat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;++bin&lt;/code&gt; to open a file in binary mode.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Finally, it's possible that binary mode is what you'd really like, for full control of each and every byte in the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But beware that fileformat doesn't really work with binary mode (it makes sense, since it's meant to be a raw mode, so you wouldn't want any preprocessing.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use binary mode and you still want to have &quot;DOS newlines&quot;, you'll need to add the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; characters yourself. Perhaps manually with &lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;C-M&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-V&amp;gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;, or perhaps using a global substitution to add a &lt;code&gt;^M&lt;/code&gt; character to lines that don't have it, once you're done editing the file.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-03-26T08:48:14.157" LastActivityDate="2020-03-26T08:48:14.157" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23313" PostTypeId="1" CreationDate="2020-03-25T16:10:17.740" Score="1" ViewCount="1590" Body="&lt;p&gt;I'm doing some Ansible work (on RHEL 8), so I want the YAML configs for vim.  I have a yaml.vim file containing the syntax/etc, and a ~/.vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.yaml,*.yml so ~/.vim/yaml.vim&#xA;autocmd FileType yaml,yml set ai ts=2 sw=2 et number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While logged in as user ansible, that worked just peachy with *.yml files.  But then I copied the same files to the same places under ~ (root), and when I was root (via su or su -), vim was clueless about yaml.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried changing the ~/.vim/yaml.vim in .vimrc to ~root/.vim/yaml.vim -- no joy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With some digging I discovered that vi doesn't read .vimrc when you're root but vim does!!??  But vim didn't work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Out of exasperation I tried rebooting my Linux server.  Now it doesn't work for user ansible either!!??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried :source ~/.vimrc and it kinda worked.  That picked up the .vimrc settings but not the syntax-highlight stuff in yaml.vim, even if I did a :e! to force it to re-read the file and see the file suffix.  But that only worked for root!?  And only a few times.  Now it doesn't work.  :source ~/.vim/yaml.vim doesn't do anything either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked at &lt;code&gt;vim -V&lt;/code&gt; and &lt;code&gt;:scriptnames&lt;/code&gt; and both indicate .vimrc and yaml.vim are being sourced.  E.g. :scriptnames output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1: ~/.vimrc&#xA;  2: /usr/share/vim/vim80/plugin/getscriptPlugin.vim&#xA;  3: /usr/share/vim/vim80/plugin/gzip.vim&#xA;  4: /usr/share/vim/vim80/plugin/logiPat.vim&#xA;  5: /usr/share/vim/vim80/plugin/manpager.vim&#xA;  6: /usr/share/vim/vim80/plugin/matchparen.vim&#xA;  7: /usr/share/vim/vim80/plugin/netrwPlugin.vim&#xA;  8: /usr/share/vim/vim80/plugin/rrhelper.vim&#xA;  9: /usr/share/vim/vim80/plugin/spellfile.vim&#xA; 10: /usr/share/vim/vim80/plugin/tarPlugin.vim&#xA; 11: /usr/share/vim/vim80/plugin/tohtml.vim&#xA; 12: /usr/share/vim/vim80/plugin/vimballPlugin.vim&#xA; 13: /usr/share/vim/vim80/plugin/zipPlugin.vim&#xA; 14: ~/.vim/yaml.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So why am I not picking up the FileType settings (&lt;code&gt;set ai ts=2 sw=2 et number&lt;/code&gt;) from .vimrc (item 1) or the YAML syntax highlighting from yaml.vim (item 14)?  Especially since this worked, for non-root, until I rebooted !?  &lt;/p&gt;&#xA;" OwnerUserId="27568" LastActivityDate="2020-03-25T16:10:17.740" Title="Trouble sourcing YAML syntax highlighting" Tags="|vimrc|syntax-highlighting|filetype-yaml|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="23314" PostTypeId="1" CreationDate="2020-03-25T16:27:20.593" Score="1" ViewCount="42" Body="&lt;p&gt;I was wondering whether to autocomplete e.g. &lt;code&gt;jj&lt;/code&gt; to &lt;code&gt;print('')&lt;/code&gt; and then navigate within those ticks: is it better to have a macro, or a remap, or neither? Obviously a remap doesn't allow moving after the fact, unless there's something I'm missing.&lt;/p&gt;&#xA;" OwnerUserId="17381" LastEditorUserId="10604" LastEditDate="2020-03-25T20:56:00.300" LastActivityDate="2020-03-25T20:56:00.300" Title="How can I auto-complete a few letters then navigate to a fixed location within them?" Tags="|key-bindings|macro|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23315" PostTypeId="1" CreationDate="2020-03-25T16:30:58.583" Score="0" ViewCount="71" Body="&lt;p&gt;I have a file (myWords.txt) which contains one word on each line :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Word 1&#xA;Word 2&#xA;---&#xA;---&#xA;Word 3000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this file, I create a list :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction()&#xA;        let start = reltime()&#xA;        exe 'e myWords.txt'&#xA;        let myList = []&#xA;        exe '%s/.*/\=add(myList, submatch(0))/g'&#xA;        exe 'bd!'&#xA;        echom printf('Duration = %s seconds', reltimestr(reltime(start))) &#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It takes me 34.1666367 seconds&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do to download my list more quickly ? Could you help me, please ?&lt;/p&gt;&#xA;" OwnerUserId="26872" LastActivityDate="2020-03-25T17:29:00.373" Title="How to import a list?" Tags="|list|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23316" PostTypeId="2" ParentId="23290" CreationDate="2020-03-25T16:40:31.370" Score="2" Body="&lt;p&gt;It seems to me that the issue you're having is that your plug-in manager is correctly loading the YouCompleteMe plug-in, however it's not working right after being installed by the plug-in manager because the external steps required by YouCompleteMe are not completed yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm going to go ahead and strongly recommend you switch from Vundle to &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt; as a plug-in manager. Not only it's much improved from Vundle (it's faster, more efficient, easier to set up), it also supports post-update hooks that can be used to automate execution of external steps needed to complete installation/update of plugins such as YouCompleteMe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be useful to cover how the plugin managers in this particular family fit together. Pathogen can be considered as the &quot;grandfather&quot; of plugin managers, it was instrumental to define what a plugin layout looks like and to establish updating &lt;code&gt;'runtimepath'&lt;/code&gt; to list all plugins there. (Some other plugin managers worked by merging files from all plugins into a single tree.) Pathogen only covers that part, it doesn't cover installing or updating plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vundle came along, embracing the Pathogen model, introducing configuration through vimrc commands (&lt;code&gt;Bundle&lt;/code&gt;, &lt;code&gt;Vundle&lt;/code&gt; or &lt;code&gt;Plugin&lt;/code&gt;) and adding special commands to install, update and otherwise manage the plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim-plug builds on the Vundle model but uses modern Vim features to speed up operations and make them parallel. It also simplified setup (just download a single file, no need to be ultra careful with filetype commands) and introduced new features, such as post-update hooks. vim-plug is very similar to Vundle, so it should be quite familiar to Vundle users. The command syntax is different (&lt;code&gt;Plug&lt;/code&gt; vs. &lt;code&gt;Plugin&lt;/code&gt;, &lt;code&gt;PlugInstall&lt;/code&gt; vs. &lt;code&gt;PluginInstall&lt;/code&gt;, etc.) but for the most part there's a 1:1 correspondence between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The vim-plug &lt;a href=&quot;https://github.com/junegunn/vim-plug/wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;wiki&lt;/a&gt; has a tip on &lt;a href=&quot;https://github.com/junegunn/vim-plug/wiki/tips#migrating-from-other-plugin-managers&quot; rel=&quot;nofollow noreferrer&quot;&gt;migrating from other plugin managers&lt;/a&gt; which covers Vundle specifically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The README file mentions YouCompleteMe specifically under &lt;a href=&quot;https://github.com/junegunn/vim-plug/blob/master/README.md#post-update-hooks&quot; rel=&quot;nofollow noreferrer&quot;&gt;post-update hooks&lt;/a&gt;, since that's about the canonical example of that (though fzf also comes to mind):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There are some plugins that require extra steps after installation or update. In that case, use &lt;code&gt;do&lt;/code&gt; option to describe the task to be performed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }&#xA;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;If you need more control, you can pass a reference to a Vim function that takes a single argument.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;function! BuildYCM(info)&#xA;  [...]&#xA;endfunction&#xA;&#xA;Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }&#xA;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Both forms of post-update hook are executed inside the directory of the plugin and only run when the repository has changed, but you can force it to run unconditionally with the bang-versions of the commands: &lt;code&gt;PlugInstall!&lt;/code&gt; and &lt;code&gt;PlugUpdate!&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I believe this should get you covered. In any case (regardless of YouCompleteMe), I really recommend you migrate from Vundle to vim-plug for all the other advantages. But it should nicely cover the YouCompleteMe set up from start to finish.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-25T16:40:31.370" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23317" PostTypeId="2" ParentId="23315" CreationDate="2020-03-25T16:42:04.190" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I have a file (myWords.txt) which contains one word on each line&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then simply&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let mylist = readfile('myWords.txt')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-03-25T16:42:04.190" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23319" PostTypeId="2" ParentId="23315" CreationDate="2020-03-25T17:29:00.373" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/23317/343&quot;&gt;Matt's answer&lt;/a&gt; is the &lt;em&gt;best&lt;/em&gt; way to do this, but here's an alternative. After you load your file into the buffer, you can call &lt;a href=&quot;http://vimhelp.org/eval.txt.html#getline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;getline()&lt;/code&gt;&lt;/a&gt; which returns the lines you ask for as a List:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let myList = getline(1, '$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a side note, I'd also like to point out that none of your uses of &lt;code&gt;exe&lt;/code&gt; are necessary. You can write all of these Ex commands directly into your function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    e myWords.txt&#xA;    %s/.*/\=add(myList, submatch(0))/g&#xA;    bd!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-03-25T17:29:00.373" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23320" PostTypeId="2" ParentId="23314" CreationDate="2020-03-25T17:45:25.403" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;&amp;lt;Left&amp;gt;&lt;/code&gt; to move the cursor to inside the single quotes after you do the expansion. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap jj print('')&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The main problem with using an insert-mode mapping here is that typing a single &lt;code&gt;j&lt;/code&gt; in insert mode is weird and blocks waiting for another character... Also, typing &lt;code&gt;jj&lt;/code&gt; in any context, including inside a word, also gets affected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An abbreviation works a little bit better here in that &lt;code&gt;jj&lt;/code&gt; (or whatever you pick) will &lt;em&gt;only&lt;/em&gt; expand when it's typed as a single word. A naive attempt would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iabbrev jj print('')&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But now the problem with this approach is that you need to type a whitespace or otherwise non-keyword character after &lt;code&gt;jj&lt;/code&gt; to trigger the abbreviation (well, you can actually use &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-]&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;CTRL-]&lt;/code&gt;&lt;/a&gt; to explicitly trigger the abbreviation, but that's not too handy.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can work around the issue by having your abbreviation expansion &quot;eat&quot; the whitespace using &lt;code&gt;getchar()&lt;/code&gt; calls. This is mentioned in an example in &lt;a href=&quot;https://vimhelp.org/map.txt.html#abbreviations&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help abbreviations&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func Eatchar(pat)&#xA;    let c = nr2char(getchar(0))&#xA;    return (c =~ a:pat) ? '' : c&#xA;endfunc&#xA;iabbrev &amp;lt;silent&amp;gt; jj print('')&amp;lt;Left&amp;gt;&amp;lt;Left&amp;gt;&amp;lt;C-R&amp;gt;=Eatchar('[ \t\r\n]')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I also adapted the example to &quot;eat&quot; any of &lt;code&gt;[ \t\r\n]&lt;/code&gt; to cover eating the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; in &lt;code&gt;jj&amp;lt;CR&amp;gt;&lt;/code&gt;, which ends up matching &lt;code&gt;\r&lt;/code&gt; which isn't covered by &lt;code&gt;\s&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you type a non-keyword argument after &lt;code&gt;jj&lt;/code&gt;, it actually ends up inserted into the printed string, so &lt;code&gt;jj*&lt;/code&gt; expands to &lt;code&gt;print('*')&lt;/code&gt; with the cursor right after the &lt;code&gt;*&lt;/code&gt;. I believe that's desirable, acceptable, intuitive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With an abbreviation, you're also free to use a prefix that's not so unique as &lt;code&gt;jj&lt;/code&gt;. For instance, using something like &lt;code&gt;pr&lt;/code&gt; would be totally acceptable, as long as you're not using that as a keyword or variable name in the language you're coding on.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-25T17:45:25.403" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23321" PostTypeId="1" AcceptedAnswerId="23322" CreationDate="2020-03-25T21:35:52.633" Score="1" ViewCount="193" Body="&lt;p&gt;I'm new to vim and I'm trying to setup my environment for c++ development, and I want to configure vim in a way that like vscode, if I push f5 key, It would compile the program in the existing tmux pane in same window.&#xA;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="27569" LastEditorUserId="27569" LastEditDate="2020-03-25T21:55:02.817" LastActivityDate="2020-03-25T22:18:41.190" Title="Compile program in same tmux window" Tags="|tmux|ide|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23322" PostTypeId="2" ParentId="23321" CreationDate="2020-03-25T22:18:41.190" Score="1" Body="&lt;p&gt;Using &lt;code&gt;:make&lt;/code&gt; is the standard way to compile stuff in Vim; you can map that to e.g. F5 with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :silent! :wa&amp;lt;CR&amp;gt;:make&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I personally like to write all the files first; adjust according to preferences (I actually have it mapped to &lt;code&gt;MM&lt;/code&gt;, which is a bit more convenient IMO).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can call tmux from this as well, if you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let &amp;amp;makeprg = &quot;tmux send-keys -t '=myproj:=make.2' make Enter&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although, arguably, using &lt;code&gt;:make&lt;/code&gt; with tmux like that doesn't make too much sense, since there will never be any compiler errors to show in the quickfix window, so you can also just map it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;F5&amp;gt; :!tmux send-keys -t 'myproj:make.2' make Enter&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not going to go in details on how tmux scripting works; &lt;code&gt;tmux(1)&lt;/code&gt; is very useful, and I also wrote a small &lt;a href=&quot;https://www.arp242.net/tmux.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Scripting tmux&lt;/a&gt; article a while ago which may be of interest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend looking in to &lt;code&gt;:make&lt;/code&gt; though, since you get the quickfix window so you can easily jump to errors and the like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that Vim also comes with &lt;code&gt;:terminal&lt;/code&gt; now, which may be preferable over tmux panes. There are also many plugins which enhance &lt;code&gt;:make&lt;/code&gt; with all sorts of things, and there probably is a tmux plugin or the like as well. This is just a simple non-automagic solution :-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2020-03-25T22:18:41.190" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23323" PostTypeId="1" AcceptedAnswerId="24384" CreationDate="2020-03-26T02:10:58.100" Score="4" ViewCount="3191" Body="&lt;p&gt;I successfully installed CoC in my Vim to have some code-suggestions/completions while coding in Rust.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works fine, but I want make the suggestion-box only show up when I press a key-shortcut (E.g Cmd + x)&lt;/p&gt;&#xA;" OwnerUserId="26000" LastEditorUserId="9333" LastEditDate="2020-03-30T07:52:08.523" LastActivityDate="2021-10-04T20:30:20.140" Title="Configuring CoC -- open suggestion-box with shortcut only" Tags="|vimrc|key-bindings|plugin-coc|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23325" PostTypeId="1" AcceptedAnswerId="23326" CreationDate="2020-03-26T06:59:43.657" Score="3" ViewCount="241" Body="&lt;p&gt;I can set a file format to unix or windows by using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ff=unix&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to check the file format ?&lt;/p&gt;&#xA;" OwnerUserId="27573" LastActivityDate="2020-03-26T07:57:54.560" Title="What is the opposite of set ff command?" Tags="|file|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23326" PostTypeId="2" ParentId="23325" CreationDate="2020-03-26T07:57:54.560" Score="3" Body="&lt;p&gt;You can use &lt;code&gt;set ff?&lt;/code&gt; to check current file format 'interactively'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to check it in a vimscript, you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if &amp;amp;ff ==# 'unix'&#xA;   &quot;do smth if file format is unix&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h let-&amp;amp;&lt;/code&gt; and &lt;code&gt;:h expr-option&lt;/code&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-03-26T07:57:54.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23327" PostTypeId="1" CreationDate="2020-03-26T10:59:38.297" Score="0" ViewCount="43" Body="&lt;p&gt;I have a function that I'd like to run every time the command line is changed, where by command line I mean the line where text is written when I save a file, get a warning, an error, or echo messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought &lt;code&gt;CmdlineChanged&lt;/code&gt; was what I needed, but after saving a file or issuing a command that doesn't exist to get an error my function isn't executed.&lt;/p&gt;&#xA;" OwnerUserId="26480" LastEditorUserId="343" LastEditDate="2020-03-26T14:57:08.870" LastActivityDate="2020-03-26T14:57:08.870" Title="What is the event triggered when the command line changes?" Tags="|autocmd|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23328" PostTypeId="1" AcceptedAnswerId="24382" CreationDate="2020-03-26T14:42:37.983" Score="15" ViewCount="15190" Body="&lt;p&gt;I successfully installed CoC in my Vim to have some code-suggestions/completions while coding in Rust.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works fine, but I want to change the color and basic looks of the suggestion box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried achieving this by editing the JSON file that's opened after executing &lt;code&gt;:CocConfig&lt;/code&gt;. This is it's content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    &quot;suggest.completionItemKindLabels&quot;: {&#xA;        &quot;keyword&quot;: &quot;\u0000&quot;,&#xA;        &quot;variable&quot;: &quot;\ue79b&quot;,&#xA;        &quot;value&quot;: &quot;\uf89f&quot;,&#xA;        &quot;operator&quot;: &quot;\u03a8&quot;,&#xA;        &quot;function&quot;: &quot;\u0192&quot;,&#xA;        &quot;reference&quot;: &quot;\ufa46&quot;,&#xA;        &quot;constant&quot;: &quot;\uf8fe&quot;,&#xA;        &quot;method&quot;: &quot;\uf09a&quot;,&#xA;        &quot;struct&quot;: &quot;\ufb44&quot;,&#xA;        &quot;class&quot;: &quot;\uf0e8&quot;,&#xA;        &quot;interface&quot;: &quot;\uf417&quot;,&#xA;        &quot;text&quot;: &quot;\ue612&quot;,&#xA;        &quot;enum&quot;: &quot;\uf435&quot;,&#xA;        &quot;enumMember&quot;: &quot;\uf02b&quot;,&#xA;        &quot;module&quot;: &quot;\uf40d&quot;,&#xA;        &quot;color&quot;: &quot;\u0000&quot;,&#xA;        &quot;property&quot;: &quot;\ue624&quot;,&#xA;        &quot;field&quot;: &quot;\uf9be&quot;,&#xA;        &quot;unit&quot;: &quot;\uf475&quot;,&#xA;        &quot;event&quot;: &quot;\ufacd&quot;,&#xA;        &quot;file&quot;: &quot;\uf723&quot;,&#xA;        &quot;folder&quot;: &quot;\uf114&quot;,&#xA;        &quot;snippet&quot;: &quot;\ue60b&quot;,&#xA;        &quot;typeParameter&quot;: &quot;\uf728&quot;,&#xA;        &quot;default&quot;: &quot;\u0000&quot;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to change the color of the suggestion-box with that code as a test, but nothing has changed (even after restarting Vim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I doing something wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;vimrc file after suggestion Maxim Kim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;&quot; Initialisation de pathogen&#xA;call pathogen#infect()&#xA;call pathogen#helptags()&#xA;&#xA;set number&#xA;set tabstop=4&#xA;set shiftwidth=4&#xA;set expandtab&#xA;set smartindent&#xA;set autoindent&#xA;&#xA;filetype plugin indent on&#xA;syntax on&#xA;runtime! config/**/*.vim&#xA;&#xA;autocmd VimEnter * NERDTree&#xA;autocmd BufWinEnter * NERDTreeMirror&#xA;&quot;autocmd BufWinEnter * NERDTreeMinor&#xA;&#xA;set guifont=Source\ Code\ Pro\ SemiBold:h16&#xA;&#xA;let NERDTreeMinimalUI = 1&#xA;let NERDTreeDirArrows = 1&#xA;set laststatus=2&#xA;&#xA;let g:airline_powerline_fonts = 1&#xA;let g:airline_theme='minimalist'&#xA;&#xA;colorscheme afterglow&#xA;&#xA;&#xA;set guioptions-=r  &quot;remove right-hand scroll bar&#xA;set guioptions-=L&#xA;&#xA;set scrolloff=5&#xA;&#xA;&#xA;&quot;nnoremap &amp;lt;ScrollWheelUp&amp;gt; k&#xA;&quot;nnoremap &amp;lt;ScrollWheelDown&amp;gt; j&#xA;&#xA;autocmd bufenter * if (winnr(&quot;$&quot;) == 1 &amp;amp;&amp;amp; exists(&quot;b:NERDTree&quot;) &amp;amp;&amp;amp; b:NERDTree.isTabTree()) | q | endif&#xA;&#xA;&#xA;&quot;OMNISHARP C# CONFIG&#xA;&quot;&quot; Use the vim-plug plugin manager: https://github.com/junegunn/vim-plug&#xA;&quot; Remember to run :PlugInstall when loading this vimrc for the first time, so&#xA;&quot; vim-plug downloads the plugins listed.&#xA;silent! if plug#begin('~/.vim/plugged')&#xA;Plug 'OmniSharp/omnisharp-vim'&#xA;Plug 'w0rp/ale'&#xA;call plug#end()&#xA;endif&#xA;&#xA;&quot; Note: this is required for the plugin to work&#xA;filetype plugin indent on&#xA;&#xA;&quot; Use the stdio OmniSharp-roslyn server&#xA;let g:OmniSharp_server_stdio = 1&#xA;&#xA;&quot; Set the type lookup function to use the preview window instead of echoing it&#xA;&quot;let g:OmniSharp_typeLookupInPreview = 1&#xA;&#xA;&quot; Timeout in seconds to wait for a response from the server&#xA;let g:OmniSharp_timeout = 5&#xA;&#xA;&quot; Don't autoselect first omnicomplete option, show options even if there is only&#xA;&quot; one (so the preview documentation is accessible). Remove 'preview' if you&#xA;&quot; don't want to see any documentation whatsoever.&#xA;set completeopt=longest,menuone,preview&#xA;&#xA;&quot; Fetch full documentation during omnicomplete requests.&#xA;&quot; By default, only Type/Method signatures are fetched. Full documentation can&#xA;&quot; still be fetched when you need it with the :OmniSharpDocumentation command.&#xA;&quot;let g:omnicomplete_fetch_full_documentation = 1&#xA;&#xA;&quot; Set desired preview window height for viewing documentation.&#xA;&quot; You might also want to look at the echodoc plugin.&#xA;set previewheight=5&#xA;&#xA;&quot; Tell ALE to use OmniSharp for linting C# files, and no other linters.&#xA;let g:ale_linters = { 'cs': ['OmniSharp'] }&#xA;&#xA;&quot; Update semantic highlighting after all text changes&#xA;let g:OmniSharp_highlight_types = 3&#xA;&quot; Update semantic highlighting on BufEnter and InsertLeave&#xA;&quot; let g:OmniSharp_highlight_types = 2&#xA;&#xA;augroup omnisharp_commands&#xA;    autocmd!&#xA;&#xA;    &quot; Show type information automatically when the cursor stops moving&#xA;    autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation()&#xA;&#xA;    &quot; The following commands are contextual, based on the cursor position.&#xA;    autocmd FileType cs nnoremap &amp;lt;buffer&amp;gt; gd :OmniSharpGotoDefinition&amp;lt;CR&amp;gt;&#xA;    autocmd FileType cs nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;fi :OmniSharpFindImplementations&amp;lt;CR&amp;gt;&#xA;    autocmd FileType cs nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;fs :OmniSharpFindSymbol&amp;lt;CR&amp;gt;&#xA;    autocmd FileType cs nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;fu :OmniSharpFindUsages&amp;lt;CR&amp;gt;&#xA;&#xA;    &quot; Finds members in the current buffer&#xA;    autocmd FileType cs nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;fm :OmniSharpFindMembers&amp;lt;CR&amp;gt;&#xA;&#xA;    autocmd FileType cs nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;fx :OmniSharpFixUsings&amp;lt;CR&amp;gt;&#xA;    autocmd FileType cs nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;tt :OmniSharpTypeLookup&amp;lt;CR&amp;gt;&#xA;    autocmd FileType cs nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;dc :OmniSharpDocumentation&amp;lt;CR&amp;gt;&#xA;    autocmd FileType cs nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-\&amp;gt; :OmniSharpSignatureHelp&amp;lt;CR&amp;gt;&#xA;    autocmd FileType cs inoremap &amp;lt;buffer&amp;gt; &amp;lt;C-\&amp;gt; &amp;lt;C-o&amp;gt;:OmniSharpSignatureHelp&amp;lt;CR&amp;gt;&#xA;&#xA;    &quot; Navigate up and down by method/property/field&#xA;    autocmd FileType cs nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-k&amp;gt; :OmniSharpNavigateUp&amp;lt;CR&amp;gt;&#xA;    autocmd FileType cs nnoremap &amp;lt;buffer&amp;gt; &amp;lt;C-j&amp;gt; :OmniSharpNavigateDown&amp;lt;CR&amp;gt;&#xA;&#xA;    &quot; Find all code errors/warnings for the current solution and populate the quickfix window&#xA;    autocmd FileType cs nnoremap &amp;lt;buffer&amp;gt; &amp;lt;Leader&amp;gt;cc :OmniSharpGlobalCodeCheck&amp;lt;CR&amp;gt;&#xA;augroup END&#xA;&#xA;&quot; Contextual code actions (uses fzf, CtrlP or unite.vim when available)&#xA;nnoremap &amp;lt;Leader&amp;gt;&amp;lt;Space&amp;gt; :OmniSharpGetCodeActions&amp;lt;CR&amp;gt;&#xA;&quot; Run code actions with text selected in visual mode to extract method&#xA;xnoremap &amp;lt;Leader&amp;gt;&amp;lt;Space&amp;gt; :call OmniSharp#GetCodeActions('visual')&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Rename with dialog&#xA;nnoremap &amp;lt;Leader&amp;gt;nm :OmniSharpRename&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;F2&amp;gt; :OmniSharpRename&amp;lt;CR&amp;gt;&#xA;&quot; Rename without dialog - with cursor on the symbol to rename: `:Rename newname`&#xA;command! -nargs=1 Rename :call OmniSharp#RenameTo(&quot;&amp;lt;args&amp;gt;&quot;)&#xA;&#xA;nnoremap &amp;lt;Leader&amp;gt;cf :OmniSharpCodeFormat&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Start the omnisharp server for the current solution&#xA;nnoremap &amp;lt;Leader&amp;gt;ss :OmniSharpStartServer&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;Leader&amp;gt;sp :OmniSharpStopServer&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Enable snippet completion&#xA;let g:OmniSharp_want_snippet=1&#xA;&#xA;&#xA;&#xA;&quot; For Rust&#xA;call plug#end()&#xA;Plug 'neoclide/coc.nvim', {'branch': 'release'}&#xA;&#xA;call plug#end()&#xA;&#xA;&quot; Rust Pmenu color&#xA; &quot;&quot;&quot; Customize colors&#xA;func! s:my_colors_setup() abort&#xA;    &quot; this is an example&#xA;    hi Pmenu guibg=#000000 gui=NONE&#xA;    hi PmenuSel guibg=#000000 gui=NONE&#xA;    hi PmenuSbar guibg=#000000&#xA;    hi PmenuThumb guibg=#000000&#xA;endfunc&#xA;&#xA;augroup colorscheme_coc_setup | au!&#xA;    au ColorScheme * call s:my_colors_setup()&#xA;augroup END&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26000" LastEditorUserId="26000" LastEditDate="2020-03-30T10:08:50.903" LastActivityDate="2021-11-14T05:47:05.630" Title="Change color of CoC suggestion box" Tags="|vimrc|plugin-coc|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23329" PostTypeId="1" CreationDate="2020-03-26T14:58:31.813" Score="2" ViewCount="68" Body="&lt;p&gt;as I said in the title I'm talking about &lt;a href=&quot;https://github.com/vim-pandoc/vim-rmarkdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-rmarkdown&lt;/a&gt;, I have this in my &lt;code&gt;init.vim&lt;/code&gt; (I'm using neovim) to compile the &lt;code&gt;.rmd&lt;/code&gt; file to a pdf.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Filetype rmd nnoremap &amp;lt;F5&amp;gt; :w&amp;lt;Space&amp;gt;&amp;lt;bar&amp;gt;&amp;lt;Space&amp;gt;RMarkdown!&amp;lt;Space&amp;gt;pdf&amp;lt;Space&amp;gt;latex_engine=&quot;pdflatex&quot;&amp;lt;enter&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The plugin opens the pdf on it's own but the process is not disowned so I can't leave it open and continue working in vim. I've tried several things but every time I add something behind the &lt;code&gt;:RMarkdown!&lt;/code&gt; command it always takes it as a argument for rendering the pdf (even with &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt;), so I always end up with failed rendering. Thanks for any help!&lt;/p&gt;&#xA;" OwnerUserId="27584" LastEditorUserId="343" LastEditDate="2020-03-26T15:00:52.023" LastActivityDate="2020-03-26T15:00:52.023" Title="How to disown a process opened by plugin? (vim-rmarkdown)" Tags="|vimrc|neovim|filetype-markdown|plugin-vim-rmarkdown|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23330" PostTypeId="1" CreationDate="2020-03-26T15:05:44.797" Score="2" ViewCount="376" Body="&lt;p&gt;I want to copy strings that spans across multiple lines between two markers in a large file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the below example file, start marker is &lt;code&gt;&amp;lt;ROW&amp;gt;&lt;/code&gt; and end marker is &lt;code&gt;&amp;lt;/ROW&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;ROW&amp;gt;&#xA;    &amp;lt;SOURCE&amp;gt;ANIMAL&amp;lt;/SOURCE&amp;gt;&#xA;    &amp;lt;QTY&amp;gt;1.00&amp;lt;/QTY&amp;gt;&#xA;    &amp;lt;UNIT_PRICE&amp;gt;123.75&amp;lt;/UNIT_PRICE&amp;gt;&#xA;    &amp;lt;NARRATIVE&amp;gt;DOG100&amp;lt;/NARRATIVE&amp;gt;&#xA;    &amp;lt;OUR_REFERENCE&amp;gt;BILLING&amp;lt;/OUR_REFERENCE&amp;gt;&#xA;&amp;lt;/ROW&amp;gt;&#xA;&amp;lt;ROW&amp;gt;&#xA;    &amp;lt;SOURCE&amp;gt;ANIMAL&amp;lt;/SOURCE&amp;gt;&#xA;    &amp;lt;QTY&amp;gt;1.00&amp;lt;/QTY&amp;gt;&#xA;    &amp;lt;UNIT_PRICE&amp;gt;150.00&amp;lt;/UNIT_PRICE&amp;gt;&#xA;    &amp;lt;NARRATIVE&amp;gt;DOG200&amp;lt;/NARRATIVE&amp;gt;&#xA;    &amp;lt;OUR_REFERENCE&amp;gt;BILLING&amp;lt;/OUR_REFERENCE&amp;gt;&#xA;&amp;lt;/ROW&amp;gt;&#xA;&amp;lt;ROW&amp;gt;&#xA;    &amp;lt;SOURCE&amp;gt;ANIMAL&amp;lt;/SOURCE&amp;gt;&#xA;    &amp;lt;QTY&amp;gt;1.00&amp;lt;/QTY&amp;gt;&#xA;    &amp;lt;UNIT_PRICE&amp;gt;170.00&amp;lt;/UNIT_PRICE&amp;gt;&#xA;    &amp;lt;NARRATIVE&amp;gt;CAT300&amp;lt;/NARRATIVE&amp;gt;&#xA;    &amp;lt;OUR_REFERENCE&amp;gt;BILLING&amp;lt;/OUR_REFERENCE&amp;gt;&#xA;&amp;lt;/ROW&amp;gt;&#xA;&amp;lt;ROW&amp;gt;&#xA;    &amp;lt;SOURCE&amp;gt;BIRD&amp;lt;/SOURCE&amp;gt;&#xA;    &amp;lt;QTY&amp;gt;1.00&amp;lt;/QTY&amp;gt;&#xA;    &amp;lt;UNIT_PRICE&amp;gt;200.00&amp;lt;/UNIT_PRICE&amp;gt;&#xA;    &amp;lt;NARRATIVE&amp;gt;PARROT300&amp;lt;/NARRATIVE&amp;gt;&#xA;    &amp;lt;OUR_REFERENCE&amp;gt;BILLING&amp;lt;/OUR_REFERENCE&amp;gt;&#xA;&amp;lt;/ROW&amp;gt;&#xA;.&#xA;.&#xA;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to search and copy the string between &lt;code&gt;&amp;lt;ROW&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;/ROW&amp;gt;&lt;/code&gt; (including) that matches the text DOG&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;ROW&amp;gt;&#xA;    &amp;lt;SOURCE&amp;gt;ANIMAL&amp;lt;/SOURCE&amp;gt;&#xA;    &amp;lt;QTY&amp;gt;1.00&amp;lt;/QTY&amp;gt;&#xA;    &amp;lt;UNIT_PRICE&amp;gt;123.75&amp;lt;/UNIT_PRICE&amp;gt;&#xA;    &amp;lt;NARRATIVE&amp;gt;DOG100&amp;lt;/NARRATIVE&amp;gt;&#xA;    &amp;lt;OUR_REFERENCE&amp;gt;BILLING&amp;lt;/OUR_REFERENCE&amp;gt;&#xA;&amp;lt;/ROW&amp;gt;&#xA;&amp;lt;ROW&amp;gt;&#xA;    &amp;lt;SOURCE&amp;gt;ANIMAL&amp;lt;/SOURCE&amp;gt;&#xA;    &amp;lt;QTY&amp;gt;1.00&amp;lt;/QTY&amp;gt;&#xA;    &amp;lt;UNIT_PRICE&amp;gt;150.00&amp;lt;/UNIT_PRICE&amp;gt;&#xA;    &amp;lt;NARRATIVE&amp;gt;DOG200&amp;lt;/NARRATIVE&amp;gt;&#xA;    &amp;lt;OUR_REFERENCE&amp;gt;BILLING&amp;lt;/OUR_REFERENCE&amp;gt;&#xA;&amp;lt;/ROW&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I do this in gvim?&lt;/p&gt;&#xA;" OwnerUserId="2737" LastEditorUserId="343" LastEditDate="2020-03-26T15:18:00.017" LastActivityDate="2020-03-26T19:04:36.373" Title="Search and copy the text between two markers in gvim" Tags="|search|cut-copy-paste|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23331" PostTypeId="2" ParentId="23330" CreationDate="2020-03-26T16:11:32.680" Score="3" Body="&lt;p&gt;If you have &lt;a href=&quot;https://github.com/michaeljsmith/vim-indent-object/tree/5c5b24c959478929b54a9e831a8e2e651a465965&quot; rel=&quot;nofollow noreferrer&quot;&gt;indent-object&lt;/a&gt;, you could do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/DOG/normal &quot;Ayii&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven’t come up with a simple vanilla answer yet, but maybe&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/DOG/ ?ROW?,/ROW/yank A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/23333/10604&quot;&gt;@Lie Ryan&lt;/a&gt; reminded me of the &lt;code&gt;at&lt;/code&gt; text-object, giving&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/DOG/normal &quot;Ay2at&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Otherwise I’d use a dedicated XML parser and copy the output. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-03-26T19:04:36.373" LastActivityDate="2020-03-26T19:04:36.373" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23332" PostTypeId="2" ParentId="23273" CreationDate="2020-03-26T16:16:15.980" Score="1" Body="&lt;p&gt;No, it isn't the normal behavior for fzf.vim. I was able to backspace normally to delete typed text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check your mappings by running &lt;code&gt;:map &amp;lt;Backspace&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="632" LastActivityDate="2020-03-26T16:16:15.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23333" PostTypeId="2" ParentId="23330" CreationDate="2020-03-26T16:39:37.263" Score="2" Body="&lt;p&gt;You can use the HTML/XML tag text object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/DOG/norm v2at&quot;AY&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you have a way to &lt;a href=&quot;https://vim.fandom.com/wiki/Pretty-formatting_XML&quot; rel=&quot;nofollow noreferrer&quot;&gt;reformat the XML afterwards&lt;/a&gt;, then this shorter command also works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/DOG/norm y2at&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both should work in standard vim without plugins.&lt;/p&gt;&#xA;" OwnerUserId="632" LastActivityDate="2020-03-26T16:39:37.263" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23334" PostTypeId="1" CreationDate="2020-03-26T18:38:18.287" Score="1" ViewCount="40" Body="&lt;p&gt;Is there a handy way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My input:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#   A&#xA;# - B&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Desired output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# - A&#xA;#   B&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My current solution is &lt;code&gt;xjphxkP&lt;/code&gt;, which seems like a lot of keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize I could record a macro, but it seems like with &quot;visual block&quot; selection (&lt;code&gt;ctrl-v&lt;/code&gt;) there should be a way to do it with one operation, enabling the &lt;code&gt;.&lt;/code&gt; operator.&lt;/p&gt;&#xA;" OwnerUserId="27587" LastEditorUserId="10604" LastEditDate="2020-03-26T19:05:10.073" LastActivityDate="2020-03-26T19:49:47.363" Title="Swap characters, vertically" Tags="|visual-block|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23337" PostTypeId="1" AcceptedAnswerId="23338" CreationDate="2020-03-27T10:40:26.237" Score="2" ViewCount="958" Body="&lt;p&gt;I'm trying to make it so urls are highlighted and a shortcut can be used when the cursor is on top of one to open it in browser. Added this to a syntax file: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match matchURL '/http[s]\?:\/\/[[:alnum:]%\/_#.-]*/'&#xA;hi matchURL ctermfg=14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tested with &lt;code&gt;https://www.archlinux.org&lt;/code&gt; but it didn't get highlighted. (Ofc I tested simpler syn matches and highlights to ensure that syntax highlighting is working, so I conclude the regex is probably wrong?). How to make highlight urls then?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also once urls are highlighted, is there a simple way to copy to a register/variable the text that is highlighted under the cursor?&lt;/p&gt;&#xA;" OwnerDisplayName="user27528" LastActivityDate="2020-03-27T11:45:00.950" Title="Match and highlight urls" Tags="|syntax-highlighting|regular-expression|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23338" PostTypeId="2" ParentId="23337" CreationDate="2020-03-27T10:57:21.650" Score="1" Body="&lt;p&gt;You have extra quotes in your regex, it should look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match matchURL /http[s]\?:\/\/[[:alnum:]%\/_#.-]*/&#xA;hi matchURL ctermfg=14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, to save the match under the cursor in a variable, you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let link = expand('&amp;lt;cWORD&amp;gt;')&#xA;let link = matchstr(link, 'http[s]\?:\/\/[[:alnum:]%\/_#.-]*')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27331" LastActivityDate="2020-03-27T10:57:21.650" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23339" PostTypeId="1" CreationDate="2020-03-27T11:28:10.107" Score="1" ViewCount="42" Body="&lt;p&gt;When typing in the command line, and one wishes to make a correction, I am aware one can press &lt;code&gt;^f&lt;/code&gt; to bring up a cmdline mini buffer where one can use &lt;code&gt;normal&lt;/code&gt; and &lt;code&gt;insert&lt;/code&gt; mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this make me wonder, why if you press escape in the command line, does it not go to normal mode for the command line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...all you would have do is find a different hotkey for cancel the current command (since &lt;code&gt;&amp;lt;escape&amp;gt;&lt;/code&gt; is now taken)&lt;/p&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-03-27T11:28:10.107" Title="Why is the command line not like a mini buffer in normal mode?" Tags="|command-line|" AnswerCount="0" CommentCount="3" ClosedDate="2020-03-29T01:21:21.467" ContentLicense="CC BY-SA 4.0" />
  <row Id="23340" PostTypeId="2" ParentId="23337" CreationDate="2020-03-27T11:45:00.950" Score="1" Body="&lt;p&gt;To highlight URL, you can use &lt;a href=&quot;https://github.com/itchyny/vim-highlighturl&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-highlighturl&lt;/a&gt;, which can highlight all kinds of URLs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To open URL in browser, you can use &lt;a href=&quot;https://github.com/tyru/open-browser.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;open-browser.vim&lt;/a&gt; and define the following shortcut to open URL in browser:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap ob &amp;lt;Plug&amp;gt;(openbrowser-smart-search)&#xA;vmap ob &amp;lt;Plug&amp;gt;(openbrowser-smart-search)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2020-03-27T11:45:00.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23341" PostTypeId="2" ParentId="20641" CreationDate="2020-03-27T14:35:25.340" Score="1" Body="&lt;p&gt;As mentioned &lt;a href=&quot;https://vi.stackexchange.com/questions/20641/maps-literally-read-and-instead-of-the-actual-character#comment36081_20641&quot;&gt;in the comments&lt;/a&gt;, you need to make sure &lt;code&gt;cpoptions&lt;/code&gt; does not contain the &lt;code&gt;k&lt;/code&gt; and &lt;code&gt;&amp;lt;&lt;/code&gt; flags before defining your mappings (this explains why netrw broke too).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The likely culprit is that vim was running in compatible mode (this should not be the case if you have a &lt;code&gt;.vimrc&lt;/code&gt; file, but it's possible to do some funky things with the invocation to end up in compatible mode). I do not recommend putting &lt;code&gt;set nocompatible&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt; though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, I would investigate why &lt;code&gt;compatible&lt;/code&gt; was set, or at least why &lt;code&gt;cpoptions&lt;/code&gt; had those flags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple trick to discover if they were set from a file is &lt;code&gt;:verbose set compatible? cpoptions?&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-03-27T14:35:25.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23342" PostTypeId="1" AcceptedAnswerId="23346" CreationDate="2020-03-27T14:40:17.183" Score="2" ViewCount="166" Body="&lt;p&gt;In command mode there is no delete from cursor to the end of line (like &lt;code&gt;CTRL-k&lt;/code&gt; in bash).&#xA;So to delete a long line of trailing text, I press and hold delete, which works fine until it runs out of characters to the right of cursor, and which points it starts steam rolling over the part of the command I wish to keep (i.e. starts backspacing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway to turn off this unusual behaviour, as confirmed by the help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Del&amp;gt;       Delete the character under the cursor (at end of line:&#xA;            character before the cursor).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS I know about &lt;code&gt;CTRL-F&lt;/code&gt; to see the &lt;code&gt;cmdline&lt;/code&gt;, but sometimes I wish to quickly change the end of an existing command.&lt;/p&gt;&#xA;" OwnerUserId="27110" LastEditorUserId="10604" LastEditDate="2020-03-27T21:09:30.907" LastActivityDate="2020-03-27T21:25:02.803" Title="In command mode make delete not act like backspace" Tags="|key-bindings|command|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23343" PostTypeId="2" ParentId="16161" CreationDate="2020-03-27T14:40:33.667" Score="4" Body="&lt;p&gt;Short answer: you cannot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long answer: &lt;code&gt;&amp;lt;C-i&amp;gt;&lt;/code&gt; being equivalent to &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; isn't a vim quirk or builtin. It's a quirk of how terminals represent characters (cf. &lt;a href=&quot;https://bestasciitable.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://bestasciitable.com&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You simply cannot avoid this fact. Now, it may be possible to force your mapping to take precedence over the tab-behavior of inserting tabs/spaces, but I haven't done much investigating there. I would recommend choosing another mapping.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-03-27T14:40:33.667" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23344" PostTypeId="2" ParentId="16161" CreationDate="2020-03-27T15:53:56.187" Score="11" Body="&lt;p&gt;With a recent enough Vim binary, and for some terminals – including &lt;a href=&quot;https://invisible-island.net/xterm/&quot; rel=&quot;noreferrer&quot;&gt;xterm&lt;/a&gt; and &lt;a href=&quot;https://vi.stackexchange.com/questions/16161/how-to-map-c-i-separate-from-tab/23344#comment46205_23344&quot;&gt;iterm2&lt;/a&gt; if you enable the &lt;a href=&quot;https://iterm2.com/documentation-csiu.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;CSI u&lt;/code&gt; option&lt;/a&gt; – Vim can distinguish &lt;code&gt;C-i&lt;/code&gt; from &lt;code&gt;Tab&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You need at least the Vim patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.2134&quot; rel=&quot;noreferrer&quot;&gt;8.1.2134&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And you may need to add these lines in your vimrc:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let &amp;amp;t_TI = &amp;quot;\&amp;lt;Esc&amp;gt;[&amp;gt;4;2m&amp;quot;&#xA;let &amp;amp;t_TE = &amp;quot;\&amp;lt;Esc&amp;gt;[&amp;gt;4;m&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Unless your Vim binary also includes the patch &lt;a href=&quot;https://github.com/vim/vim/releases/tag/v8.1.2194&quot; rel=&quot;noreferrer&quot;&gt;8.1.2194&lt;/a&gt;, in which case it should have been done automatically if Vim has properly detected it's running in xterm.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;As a simple test, run this shell command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim -Nu NONE +'nno &amp;lt;C-i&amp;gt; :echom &amp;quot;C-i was pressed&amp;quot;&amp;lt;cr&amp;gt;' +'nno &amp;lt;tab&amp;gt; :echom &amp;quot;Tab was pressed&amp;quot;&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then press &lt;code&gt;Tab&lt;/code&gt; followed by &lt;code&gt;C-i&lt;/code&gt;.  The first keypress should log the message &lt;code&gt;Tab was pressed&lt;/code&gt;, while the second one should log the message &lt;code&gt;C-i was pressed&lt;/code&gt; (check out the output of &lt;code&gt;:messages&lt;/code&gt; if you somehow missed the messages).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kWzal.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kWzal.gif&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Make sure to install the &lt;code&gt;Tab&lt;/code&gt; mapping &lt;em&gt;after&lt;/em&gt; the &lt;code&gt;C-i&lt;/code&gt; mapping; otherwise, the &lt;code&gt;Tab&lt;/code&gt; mapping may be removed.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Vim can distinguish between many other keys; like &lt;code&gt;C-a&lt;/code&gt; and &lt;code&gt;C-S-a&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim -Nu NONE +'nno &amp;lt;C-a&amp;gt; :echom &amp;quot;C-a was pressed&amp;quot;&amp;lt;cr&amp;gt;' +'nno &amp;lt;C-S-a&amp;gt; :echom &amp;quot;C-S-a was pressed&amp;quot;&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here &lt;code&gt;C-&lt;/code&gt; and &lt;code&gt;S-&lt;/code&gt; stand for resp. the control and shift modifiers.&lt;/p&gt;&#xA;&lt;p&gt;Or &lt;code&gt;A-b&lt;/code&gt; and &lt;code&gt;A-C-b&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;vim -Nu NONE +'nno &amp;lt;A-b&amp;gt; :echom &amp;quot;A-b was pressed&amp;quot;&amp;lt;cr&amp;gt;' +'nno &amp;lt;A-C-b&amp;gt; :echom &amp;quot;A-C-b was pressed&amp;quot;&amp;lt;cr&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here &lt;code&gt;A-&lt;/code&gt; stands for the Alt modifier.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For more info, see &lt;a href=&quot;https://vimhelp.org/map.txt.html#modifyOtherKeys&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:h modifyOtherKeys&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-06-21T15:12:47.227" LastActivityDate="2020-06-21T15:12:47.227" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23345" PostTypeId="2" ParentId="23342" CreationDate="2020-03-27T17:02:01.767" Score="2" Body="&lt;p&gt;You can use the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function KillEnd()&#xA;  let l:cmd = getcmdline()&#xA;  let l:pos = getcmdpos()&#xA;  let l:newcmd = strpart(l:cmd, 0, l:pos - 1)&#xA;  return l:newcmd&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use it on the command line, you need to do (I choose &lt;code&gt;&amp;lt;C-x&amp;gt;&lt;/code&gt; arbitrarily since it wasn't used for anything else, and reminds me of &lt;code&gt;X&lt;/code&gt; in normal mode):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;C-x&amp;gt; &amp;lt;C-\&amp;gt;eKillEnd()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help c_CTRL-\_e&lt;/code&gt; for details on the mapping; the &lt;code&gt;&amp;lt;C-\&amp;gt;e&lt;/code&gt; sequence uses an expression to replace the entire command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function returns a substring of the command line based on the cursor position.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you wanted a one-liner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;C-x&amp;gt; &amp;lt;C-\&amp;gt;estrpart(getcmdline(), 0, getcmdpos() - 1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-03-27T17:02:01.767" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23346" PostTypeId="2" ParentId="23342" CreationDate="2020-03-27T21:25:02.803" Score="2" Body="&lt;p&gt;To change the behavior of &lt;code&gt;&amp;lt;Del&amp;gt;&lt;/code&gt; so that it only deletes the character under the cursor and doesn't behave like backspace when at the end of the line, you can use the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;Del&amp;gt; getcmdpos() &amp;lt;= strlen(getcmdline()) ? &quot;\&amp;lt;Del&amp;gt;&quot; : &quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vi.stackexchange.com/a/23345/18609&quot;&gt;@D.BenKnoble's answer&lt;/a&gt; for a solution to deleting until the end of the line (similar to what &lt;code&gt;&amp;lt;C-K&amp;gt;&lt;/code&gt; does in bash and other readline-based programs.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-27T21:25:02.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23348" PostTypeId="1" AcceptedAnswerId="23349" CreationDate="2020-03-27T23:31:49.247" Score="3" ViewCount="1306" Body="&lt;p&gt;I am trying to save a file with today's date as part of name. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To save file, we can just do &lt;code&gt;:w myFile&lt;/code&gt;. To get today's date, we can use &lt;code&gt;strftime&lt;/code&gt;. Ex: &lt;code&gt;:echo strftime(&quot;%F&quot;) &quot; returns 2020-03-27&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I would like to combine both - to save with today's date. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w 'myFile-(strftime(&quot;%F&quot;)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to save file with today's date (&lt;code&gt;myFile-2020-03-27&lt;/code&gt;.) in Vim?&lt;/p&gt;&#xA;" OwnerUserId="27477" LastActivityDate="2020-03-28T02:31:05.833" Title="How to save file with today's date?" Tags="|save|date-and-time|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23349" PostTypeId="2" ParentId="23348" CreationDate="2020-03-28T00:15:38.613" Score="2" Body="&lt;p&gt;There are two ways to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first one is interactive, using &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_CTRL-R_%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;CTRL-R =&lt;/code&gt;&lt;/a&gt; in the Ex command-line to enter an expression and evaluate it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start by typing the command as usual: &lt;code&gt;:w myFile-&lt;/code&gt;, then press &lt;code&gt;CTRL-R&lt;/code&gt;, &lt;code&gt;=&lt;/code&gt;. You'll now have a &lt;code&gt;=&lt;/code&gt; prompt where you can enter an expression. Enter &lt;code&gt;strftime(&quot;%F&quot;)&lt;/code&gt; and press &quot;Enter&quot;, Vim will evaluate that to 2020-03-27 (assuming that's today's date) and will now display the command-line as &lt;code&gt;:w myFile-2020-03-27&lt;/code&gt;, which you can then execute or further edit as you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:execute&lt;/code&gt;&lt;/a&gt; command to execute a string as an Ex command. In which case you can simply use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 'w myFile-'.strftime(&quot;%F&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;.&lt;/code&gt; is the string concatenation operator here. This latter form with &lt;code&gt;:execute&lt;/code&gt; is particularly useful in Vim scripts or functions.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-28T00:15:38.613" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23351" PostTypeId="2" ParentId="23348" CreationDate="2020-03-28T02:31:05.833" Score="2" Body="&lt;p&gt;If you frequently find yourself wanting to insert the current date into command-line commands you could set up a mapping like this using something similar to what's in the existing answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cnoremap YMD &amp;lt;C-R&amp;gt;=strftime(&quot;%Y-%m-%d&quot;)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your use case then would be to enter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w myFile-YMD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which, right after you hit &lt;kbd&gt;D&lt;/kbd&gt;, will be converted to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w myFile-2020-03-27&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then you just hit &lt;kbd&gt;Enter&lt;/kbd&gt; to submit it. I have this in my vimrc and it comes in handy.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2020-03-28T02:31:05.833" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23352" PostTypeId="1" CreationDate="2020-03-28T02:53:42.437" Score="0" ViewCount="1188" Body="&lt;p&gt;I'm using vim 8 to code C++11.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've installed the vim plugins: YCM, ALE, &lt;a href=&quot;https://github.com/tomasiser/vim-code-dark&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-code-dark&lt;/a&gt; and &lt;a href=&quot;https://github.com/octol/vim-cpp-enhanced-highlight&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-cpp-enhanced-highlight&lt;/a&gt;, however, it seems that there is some error on syntax highlighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/W0qM6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/W0qM6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you see, &lt;code&gt;scene&lt;/code&gt; and &lt;code&gt;arg&lt;/code&gt; are highlighted with yellow, but they are variables, which shouldn't be highlighted, just like &lt;code&gt;isColor&lt;/code&gt;, it seems that both of them are regarded as functions, I think the reason is the way of initialization: &lt;code&gt;string arg(&quot;XXX&quot;);&lt;/code&gt;. It seems that this kind of initialization is regarded as a declaration of function, instead of a variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know who is controlling this mechanism. Is it vim 8? or the vim plugins, such as YCM, ALE?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way to fix this error?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-03-28T02:53:42.437" Title="vim 8: C++ syntax highlighting has some minor fault" Tags="|syntax-highlighting|colorscheme|plugin-system|plugin-you-complete-me|plugin-ale|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="23353" PostTypeId="1" CreationDate="2020-03-28T06:17:19.537" Score="-1" ViewCount="61" Body="&lt;p&gt;I have this function :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MaFonction10()&#xA;     let myList1 = [&quot;self-made-man&quot;, &quot;rendez-vous&quot;, &quot;forget-me-not&quot;]&#xA;     for elem in myList1&#xA;        echo len(elem)&#xA;     endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I vould like to get the number of hyphens or letter &quot;a&quot;s (for example) in each item, instead of the total number of letters.&lt;/p&gt;&#xA;" OwnerUserId="26872" LastEditorUserId="10604" LastEditDate="2020-03-28T13:58:10.387" LastActivityDate="2020-03-28T16:43:08.297" Title="Counting a character in items" Tags="|counting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23355" PostTypeId="2" ParentId="23353" CreationDate="2020-03-28T10:08:10.787" Score="0" Body="&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/eval.txt.html?#split%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;split()&lt;/code&gt;&lt;/a&gt; on a string, with a pattern of &lt;code&gt;\zs&lt;/code&gt;, to split it into a list of characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can use &lt;a href=&quot;https://vimhelp.org/eval.txt.html?#filter%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;filter()&lt;/code&gt;&lt;/a&gt; on that list to only keep the matching character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you can take the &lt;code&gt;len()&lt;/code&gt; of the resulting list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to count the number of dashes in &quot;elem&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo len(filter(split(elem, '\zs'), {_, val -&amp;gt; val ==# &quot;-&quot;}))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As suggested by @D.BenKnoble, using the more modern &lt;a href=&quot;https://vimhelp.org/eval.txt.html?#method&quot; rel=&quot;nofollow noreferrer&quot;&gt;method&lt;/a&gt; syntax makes this nicer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo elem-&amp;gt;split('\zs')-&amp;gt;filter({_, val -&amp;gt; val ==# &quot;-&quot;})-&amp;gt;len()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As noticed by @ArseneAsedrith, we don't need to go through all this trouble with splitting and filtering, since the &lt;a href=&quot;https://vimhelp.org/eval.txt.html?#count%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;count()&lt;/code&gt;&lt;/a&gt; function takes care of this exact case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo count(elem, &quot;-&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo elem-&amp;gt;count(&quot;-&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-03-28T16:43:08.297" LastActivityDate="2020-03-28T16:43:08.297" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23356" PostTypeId="1" AcceptedAnswerId="23357" CreationDate="2020-03-28T10:16:57.037" Score="1" ViewCount="1895" Body="&lt;p&gt;I'm writing a plugin that often needs to write text to specific buffers. &#xA;My current solution is to make the script execute normal commands that open a split with the buffer, write the text and then close it thus returning to the previous split.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although this is fast enough for the intended purposes, it feels a bit dirty. Is there a more clean/efficient way to do this?&lt;/p&gt;&#xA;" OwnerDisplayName="user27528" LastActivityDate="2020-03-28T11:08:47.087" Title="Commands to write text to a buffer" Tags="|vimscript|command-line|buffers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23357" PostTypeId="2" ParentId="23356" CreationDate="2020-03-28T11:01:44.987" Score="1" Body="&lt;p&gt;Check vim help for the following entries:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:h function-list&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h setbufline()&lt;/code&gt; -- what you probably need&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h getbufline()&lt;/code&gt; -- and also this.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:h appendbufline()&lt;/code&gt; -- and this.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-03-28T11:08:47.087" LastActivityDate="2020-03-28T11:08:47.087" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23358" PostTypeId="2" ParentId="5806" CreationDate="2020-03-28T11:46:07.573" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;yl&lt;/code&gt; or &lt;code&gt;yv&lt;/code&gt; to copy a character which is on the cursor.&lt;/p&gt;&#xA;" OwnerUserId="27615" LastActivityDate="2020-03-28T11:46:07.573" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23359" PostTypeId="2" ParentId="23353" CreationDate="2020-03-28T11:47:10.610" Score="-1" Body="&lt;p&gt;Thank you. I have an other solution too :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! MyFunction()&#xA;let myPonct = [&quot;-&quot;]&#xA;let myList = [&quot;self-made-man&quot;, &quot;rendez-vous&quot;, &quot;forget-me-not&quot;]&#xA;For elem in myPonct&#xA;        for elem2 in myList&#xA;            echo count(elem2,elem) &#xA;        endfor&#xA;Endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26872" LastActivityDate="2020-03-28T11:47:10.610" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23360" PostTypeId="1" AcceptedAnswerId="24358" CreationDate="2020-03-28T13:48:34.547" Score="2" ViewCount="56" Body="&lt;p&gt;If &lt;code&gt;ddkP&lt;/code&gt; is typed in normal mode on the first line then nothing happens¹. If &lt;code&gt;:nnoremap + ddkP&lt;/code&gt; is executed and then &lt;code&gt;+&lt;/code&gt; is pressed, the line is deleted. Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;¹(if file only has one line then a new empty line appears but otherwise the behaviour is the same)&lt;/p&gt;&#xA;" OwnerDisplayName="user27528" LastActivityDate="2020-03-28T14:47:58.890" Title="Mapping behaves differently than manually typing" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24358" PostTypeId="2" ParentId="23360" CreationDate="2020-03-28T14:47:58.890" Score="2" Body="&lt;p&gt;Mappings abort on errors, and trying to move further « up » than the first line is an error, so the &lt;code&gt;P&lt;/code&gt; never gets executed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have some &lt;a href=&quot;https://github.com/benknoble/Dotfiles/blob/master/links/vim/plugin/bubble.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;other « bubble » mappings&lt;/a&gt; you might be interested in. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-03-28T14:47:58.890" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24359" PostTypeId="1" AcceptedAnswerId="24361" CreationDate="2020-03-28T15:41:13.207" Score="2" ViewCount="200" Body="&lt;p&gt;When I set &lt;code&gt;tw&lt;/code&gt; vim will auto wrap lines at &lt;code&gt;tw&lt;/code&gt;. When breaking that line vim usually places some spaces to keep the indentation of the previous line. Example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo&#xA;  bar&amp;lt;suppose that a wrap happens here&amp;gt;&#xA;  tar&#xA;## &amp;lt;- this amount of space is added to keep the line idented&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What are the options that control this behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-- edit&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be more precise I was editing markdown and it indents lists this way&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- foo bar tar &amp;lt;wrap happens!&amp;gt;&#xA;    tick tack&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While I expect&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- foo bar tar &amp;lt;wrap happens!&amp;gt;&#xA;  tick tack&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just don't want to tie the response to markdown so that I can apply it to other formats.&lt;/p&gt;&#xA;" OwnerUserId="19897" LastEditorUserId="18609" LastEditDate="2020-03-28T17:45:13.840" LastActivityDate="2020-03-28T18:22:30.397" Title="What option controls how much space is added after a new line?" Tags="|indentation|whitespace|filetype-markdown|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="24360" PostTypeId="2" ParentId="11025" CreationDate="2020-03-28T17:34:25.887" Score="1" Body="&lt;p&gt;You can also copy the part you want to use and use &lt;code&gt;&amp;lt;C-r&amp;gt;&quot;&lt;/code&gt; to paste it.&#xA;For example, if you want to run &lt;code&gt;myCommand&lt;/code&gt; like feh, firefox etc on a the line&#xA;&lt;code&gt;:map mapping Vy:!myCommand &amp;lt;C-r&amp;gt;&quot;&amp;lt;Cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="28618" LastActivityDate="2020-03-28T17:34:25.887" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24361" PostTypeId="2" ParentId="24359" CreationDate="2020-03-28T18:22:30.397" Score="3" Body="&lt;p&gt;There are too many such options to be able to answer this quesion in a general manner. However, they are mostly programming-languages oriented or exotic ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case of a &quot;text document&quot;, such as markdown, you likely have to deal with only &lt;code&gt;autoindent&lt;/code&gt; (an alternative is &lt;code&gt;smartindent&lt;/code&gt;, as &lt;code&gt;si&lt;/code&gt; is sometimes set default in some vimrc's, but &lt;code&gt;si&lt;/code&gt; is a sort of &quot;universal programming language&quot; indenter, and you should better keep it off for markdown and such). Also note that &lt;code&gt;autoindent&lt;/code&gt; is off by default, so you probably have &lt;code&gt;set ai&lt;/code&gt; in your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also several options which influence number / structure of tabs / spaces in an (auto-)indent, but, I guess, it's not the point of your interest right now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also speaking of markdown, it's worth to note that there's &lt;code&gt;formatlistpat&lt;/code&gt; option (set by ftplugin) to detect &quot;lists&quot;. So &quot;the list items&quot; in markdown will get indented even if &lt;code&gt;set noautoindent&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the last but not least, &lt;code&gt;autoindent&lt;/code&gt; will come in play if you have &lt;code&gt;textwidth&lt;/code&gt; set. Not &lt;code&gt;wrap&lt;/code&gt; and &lt;code&gt;wrapmargin&lt;/code&gt;. The point is that &lt;code&gt;textwidth&lt;/code&gt; results in adding &quot;real&quot; newlines in your file (and hence &lt;code&gt;autoindent&lt;/code&gt; will do its job). While &lt;code&gt;wrapmargin&lt;/code&gt; results in &quot;on-screen&quot; wrapping.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-03-28T18:22:30.397" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24362" PostTypeId="1" AcceptedAnswerId="24364" CreationDate="2020-03-28T21:03:30.963" Score="2" ViewCount="426" Body="&lt;p&gt;According to &lt;a href=&quot;https://vi.stackexchange.com/a/24358/27528&quot;&gt;this answer&lt;/a&gt;, if a error occurs during the execution of a mapping, its execution is aborted. Why is it like that and:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Is there a way to prevent this from happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) In the case of the above answer, the error is invisible: if i press up in the first line in vim, theres no notification of an error, and &lt;code&gt;:echo errmsg&lt;/code&gt; also doesn't display anything new. How to view those errors? &lt;/p&gt;&#xA;" OwnerDisplayName="user27528" LastActivityDate="2020-03-28T21:47:24.820" Title="Why do mappings abort on errors?" Tags="|key-bindings|error|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24364" PostTypeId="2" ParentId="24362" CreationDate="2020-03-28T21:47:24.820" Score="3" Body="&lt;p&gt;This is documented under &lt;a href=&quot;https://vimhelp.org/map.txt.html#map-error&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help map-error&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that when an error is encountered (that causes an error message or beep)&#xA;  the rest of the mapping is not executed.  This is Vi-compatible.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Regarding this part of your question:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2) In the case of the above answer, the error is invisible: if i press up in the first line in vim, theres no notification of an error, and &lt;code&gt;:echo errmsg&lt;/code&gt; also doesn't display anything new. How to view those errors? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your &lt;a href=&quot;https://vi.stackexchange.com/q/23360/18609&quot;&gt;previous question&lt;/a&gt; involved using &lt;code&gt;k&lt;/code&gt; on the first line of the document. That falls under category of producing a &quot;beep&quot;, so you don't really get a notification that this command failed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(It's the same outside of a mapping. If you press &lt;code&gt;k&lt;/code&gt; on line 1, you don't really get an error message anywhere, it just &quot;beeps&quot; [but you might not hear it since they're quite possibly disabled] and otherwise does nothing.)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;1) Is there a way to prevent this from happening?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There's &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Asilent&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:silent!&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When &lt;code&gt;!&lt;/code&gt; is added, error messages will also be skipped, and commands and &lt;em&gt;mappings will not be aborted&lt;/em&gt; when an error is detected.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But it's often too coarse, since it hides errors globally. Also, if you want to use it with normal mode commands, you also need &lt;code&gt;:normal!&lt;/code&gt;. And you typically also need to mark your mapping with &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; to prevent it from displaying the &lt;code&gt;:silent! normal! ...&lt;/code&gt; in the command-line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would work to prevent the error in the mapping from your &lt;a href=&quot;https://vi.stackexchange.com/q/23360/18609&quot;&gt;previous question&lt;/a&gt;, when it's run from the first line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;silent&amp;gt; + :silent! normal! ddkP&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I wouldn't actually recommend using this for the mapping, as there are better solutions to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess the right answer is: You should write your mappings defensively, so that errors won't happen where you don't want them. A better approach:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; + line('.') &amp;gt; 1 ? 'ddkP' : ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also lets you handle the case of running it on the last line of the buffer, in which case deleting the line will also move you one line up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; + line('.') == line('$') ? 'ddP' : line('.') &amp;gt; 1 ? 'ddkP' : ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But even then, the &lt;a href=&quot;https://github.com/benknoble/Dotfiles/blob/master/links/vim/plugin/bubble.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;«bubble» mappings&lt;/a&gt; in &lt;a href=&quot;https://vi.stackexchange.com/a/24358/18609&quot;&gt;@D.BenKnoble's answer&lt;/a&gt; using the &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Amove&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:move&lt;/code&gt;&lt;/a&gt; command are a much more superior way to accomplish the same:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&#xA;&quot; Bubble single lines up and down&#xA;nnoremap - :.move +1&#xA;nnoremap _ :.move -2&#xA;&quot; Bubble lines up and down in visual mode&#xA;vnoremap - :'move '&gt;+1 \| normal! gv&#xA;vnoremap _ :'move '&#xA;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;One final point is that breaking execution on error for mappings and macros is actually a &lt;em&gt;feature&lt;/em&gt;. For example, if you have a recursive mapping or macro, if you want to process each line, you know you can simply move on to the next line and call the mapping/macro again, since you know there's a stop condition at the point where you can't move on to the next line again (end of the file.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly for when you're doing searches with &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt;. You know the mapping/macro will stop if you search for a term that doesn't exist anymore. Or if you set &lt;code&gt;'nowrapscan'&lt;/code&gt;, you know you'll stop at the last match of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In both of those cases, silently continuing after a failure would be really problematic, since it would make it much harder to implement recursion and it would potentially keep executing commands meant for a match when no match was found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in short, try to prevent errors when you can. Try to write your mappings in a way that is unlikely to trigger errors. Use breaking on errors to your favor.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-28T21:47:24.820" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24365" PostTypeId="1" AcceptedAnswerId="24374" CreationDate="2020-03-29T01:57:42.947" Score="1" ViewCount="359" Body="&lt;p&gt;I have a vimscript which needs to query a environment variable which gets set on terminal buffers. How can I do this? I tried looking through the help to see what term / job commands could be used to query but didn't see anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for buffer in term_list()&#xA;    let variable = s:get_variable(buffer, &quot;$SOMETHING&quot;)&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16073" LastActivityDate="2020-03-30T01:52:30.200" Title="Query an environment variable in a terminal buffer" Tags="|terminal-buffer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24366" PostTypeId="2" ParentId="8621" CreationDate="2020-03-29T10:33:45.790" Score="1" Body="&lt;p&gt;My attempt &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%norm 4ftdwx&#xA;&#xA;:%norm ......... execute in normal mode over the whole file  &#xA;4ft ............ the 4th t matches the start of the second temp&#xA;dw ............. deletes the current word&#xA;x .............. deletes the dot&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2020-03-29T10:33:45.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24367" PostTypeId="1" AcceptedAnswerId="24372" CreationDate="2020-03-29T11:46:33.333" Score="1" ViewCount="439" Body="&lt;p&gt;Consider the following code snippet, which aims to provide &lt;code&gt;y&lt;/code&gt; without moving the cursor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Yank_fixed_cursor()&#xA;    let save_cursor = getcurpos()&#xA;    call feedkeys(&quot;y&quot;, 'nitx')&#xA;    call setpos('.', save_cursor)&#xA;endfunction&#xA;nnoremap y :call Yank_fixed_cursor()&amp;lt;cr&amp;gt;&#xA;nnoremap yr :echom &quot;Another mapping&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tested this (wrapped in a file &lt;code&gt;minimal.vim&lt;/code&gt;) using either&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim -u minimal.vim test.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -uN minimal.vim test.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;test.txt&lt;/code&gt; is pretty much any file.&#xA;A couple of questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;In both &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;nvim&lt;/code&gt;, the command &lt;code&gt;y&lt;/code&gt; works as expected with one-character motions (e.g. &lt;code&gt;y{&lt;/code&gt;, &lt;code&gt;yG&lt;/code&gt;, &lt;code&gt;y0&lt;/code&gt;),&#xA;but it doesn't work with motions that take more characters (e.g. &lt;code&gt;ygg&lt;/code&gt;, &lt;code&gt;y5k&lt;/code&gt;).&#xA;Why, and can this be fixed?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Without the &lt;code&gt;yr&lt;/code&gt; mapping (or any other mapping that starts with &lt;code&gt;y&lt;/code&gt;), the code does not work in either &lt;code&gt;vim&lt;/code&gt; or &lt;code&gt;nvim&lt;/code&gt;. Why?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11125" LastEditorUserId="11125" LastEditDate="2020-03-29T17:16:36.423" LastActivityDate="2020-03-29T18:16:14.483" Title="Unexpected behavior with feedkeys" Tags="|cursor-motions|functions|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24368" PostTypeId="2" ParentId="12104" CreationDate="2020-03-29T12:53:07.243" Score="3" Body="&lt;p&gt;Vim is just using you term colors, if you configure something on darkyellow vim will change it to yellow when you change the background mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the colors codes are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*cterm-colors*&#xA;&#xA;NR-16   NR-8    COLOR NAME &#xA;0       0       Black&#xA;1       4       DarkBlue&#xA;2       2       DarkGreen&#xA;3       6       DarkCyan&#xA;4       1       DarkRed&#xA;5       5       DarkMagenta&#xA;6       3       Brown, DarkYellow&#xA;7       7       LightGray, LightGrey, Gray, Grey&#xA;8       0*      DarkGray, DarkGrey&#xA;9       4*      Blue, LightBlue&#xA;10      2*      Green, LightGreen&#xA;11      6*      Cyan, LightCyan&#xA;12      1*      Red, LightRed&#xA;13      5*      Magenta, LightMagenta&#xA;14      3*      Yellow, LightYellow&#xA;15      7*      White&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use an RGB code to configure there will be no change.&#xA;So prefer to use a maximum term color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example with my .vimrc in dark mode or light mode and my term colors&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lqKZG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lqKZG.png&quot; alt=&quot;dark and light&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2510" LastActivityDate="2020-03-29T12:53:07.243" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24369" PostTypeId="1" CreationDate="2020-03-29T13:52:51.237" Score="2" ViewCount="814" Body="&lt;p&gt;Is there a function like &lt;code&gt;setpos&lt;/code&gt; that lets change the cursor position in a different window (split), given the window number?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, even better, is there a command to execute a command in specific window?&lt;/p&gt;&#xA;" OwnerDisplayName="user27528" LastEditorDisplayName="user27528" LastEditDate="2020-03-29T19:39:24.830" LastActivityDate="2020-03-30T22:37:43.627" Title="Change cursor position in another window" Tags="|split|cursor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24370" PostTypeId="1" AcceptedAnswerId="24371" CreationDate="2020-03-29T14:33:31.820" Score="1" ViewCount="37" Body="&lt;p&gt;For example if in normal mode &lt;code&gt;4:&lt;/code&gt; is pressed, in the command line there will be &lt;code&gt;:.,.+3&lt;/code&gt;. What does this mean and what is it used for?&lt;/p&gt;&#xA;" OwnerDisplayName="user27528" LastActivityDate="2020-03-29T20:00:00.317" Title="Why does `.,.+[count]` appear in command box when typing [count+1] before :" Tags="|command-line|count|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24371" PostTypeId="2" ParentId="24370" CreationDate="2020-03-29T15:18:03.917" Score="1" Body="&lt;p&gt;This is a line range (see &lt;code&gt;:h :range&lt;/code&gt;). &quot;The dot&quot; means the current line. So it's the current line and the next three ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The operation to perform over this line range, of course, depends on the command you type in the command-line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;4:&lt;/code&gt; is just a handy &quot;shortcut&quot; to input line range.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="11054" LastEditDate="2020-03-29T20:00:00.317" LastActivityDate="2020-03-29T20:00:00.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24372" PostTypeId="2" ParentId="24367" CreationDate="2020-03-29T18:16:14.483" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Without the &lt;code&gt;yr&lt;/code&gt; mapping (or any other mapping that starts with &lt;code&gt;y&lt;/code&gt;), the code does not work. Why?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's because you're calling &lt;code&gt;feedkeys()&lt;/code&gt; with the &lt;code&gt;'x'&lt;/code&gt; option, which will also process the typeahead buffer. So you need the next keypress to be in that buffer in order to execute the full command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you type &lt;code&gt;yG&lt;/code&gt;, you need the &lt;code&gt;G&lt;/code&gt; to be on the buffer &lt;em&gt;at the time the function is called.&lt;/em&gt; Having another longer mapping defined with the same prefix ensures that Vim will wait for more keystrokes (up to &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27timeoutlen%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'timeoutlen'&lt;/code&gt;&lt;/a&gt;, depending on &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27timeout%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'timeout'&lt;/code&gt;&lt;/a&gt; being enabled). If the additional keystrokes don't match a mapping, the additional keystrokes will end up in the typeahead buffer, which is exactly what you wanted.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the command &lt;code&gt;y&lt;/code&gt; works as expected with one-character motions (e.g. &lt;code&gt;y{&lt;/code&gt;, &lt;code&gt;yG&lt;/code&gt;, &lt;code&gt;y0&lt;/code&gt;), but it doesn't work with motions that take more characters (e.g. &lt;code&gt;ygg&lt;/code&gt;, &lt;code&gt;y5k&lt;/code&gt;). Why, and can this be fixed?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's because the full motion is not in the typeahead buffer at the time the function is called. Since &lt;code&gt;yg&lt;/code&gt; doesn't match our longer dummy mapping &lt;code&gt;yr&lt;/code&gt;, that means Vim will call the function with only &lt;code&gt;g&lt;/code&gt; in the typeahead buffer, which means feedkeys will execute &lt;code&gt;yg&lt;/code&gt;, which doesn't make sense...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can work around that, to some extent, with a similar trick you used for the original prefix itself. You could define a mapping longer than &lt;code&gt;yg&lt;/code&gt; that will make Vim wait for one more character after those two:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ygr :echom &quot;Yet another mapping.&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, perhaps cleaner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap y&amp;lt;Esc&amp;gt; &amp;lt;Nop&amp;gt;&#xA;nnoremap yg&amp;lt;Esc&amp;gt; &amp;lt;Nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; is cleaner than &lt;code&gt;r&lt;/code&gt; and using &lt;code&gt;&amp;lt;Nop&amp;gt;&lt;/code&gt; works similarly to &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; simply cancelling the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will fix &lt;code&gt;ygg&lt;/code&gt; or &lt;code&gt;yg$&lt;/code&gt;, &lt;code&gt;ygm&lt;/code&gt;, etc. But not other prefixes. If you consider counts, such as &lt;code&gt;y5k&lt;/code&gt;, it gets really tricky to cover them all.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is feedkeys robust? &lt;em&gt;Should I use it for this purpose?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;While feedkeys is a fine function and there are places where using it makes sense. However, there's a much better way to implement what you're trying to accomplish here: &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-operator&quot; rel=&quot;nofollow noreferrer&quot;&gt;operator-pending mappings&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way you use it is by setting &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27operatorfunc%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'operatorfunc'&lt;/code&gt;&lt;/a&gt; to point to a function you defined and then call the &lt;a href=&quot;https://vimhelp.org/map.txt.html#g%40&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g@&lt;/code&gt;&lt;/a&gt; command at the end of your mapping, which will keep waiting for a &lt;code&gt;{motion}&lt;/code&gt; and then executes the set operator function when it gets the motion. That way you can manage to run some code (in your case, &lt;code&gt;setpos()&lt;/code&gt; to restore the cursor) after the operation is executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a &lt;em&gt;very&lt;/em&gt; naive example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Yank_fixed_cursor()&#xA;    let g:save_cursor = getcurpos()&#xA;    set operatorfunc=Yank_restore_cursor&#xA;    return 'g@'&#xA;endfunction&#xA;function! Yank_restore_cursor(type)&#xA;    if a:type == 'line'&#xA;        silent exe &quot;normal! '[V']y&quot;&#xA;    else&#xA;        silent exe &quot;normal! `[v`]y&quot;&#xA;    endif&#xA;    call setpos('.', g:save_cursor)&#xA;endfunction&#xA;nnoremap &amp;lt;expr&amp;gt; y Yank_fixed_cursor()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, the &lt;code&gt;Yank_fixed_cursor&lt;/code&gt; function now sets up the operator by using a separate function, &lt;code&gt;Yank_restore_cursor&lt;/code&gt;, to execute the yank and restore the cursor. It finally returns &lt;code&gt;g@&lt;/code&gt;, which is used in an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping to create an operator-pending mapping, which will wait for a motion and execute the operator function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;Yank_restore_cursor&lt;/code&gt; gets from Vim more context about the motion, such as an argument indicating whether it was a linewise or character-wise motion and the markers &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; set to the block around the motion. We then use that to execute the yank operation. Finally, we can restore the cursor to the saved position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the save and restore of the cursor happen in different functions, you'll need a global variable to preserve the information in between the two function calls. (If you're in a plug-in, you can use a &lt;code&gt;s:&lt;/code&gt; variable, which leaves you on an isolated namespace and makes it harder for some other script to interfere with your global state.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are quite a few shortcomings with this naive implementation, you need a lot more to make it completely robust. Some of the items missing:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Using &lt;code&gt;yy&lt;/code&gt; won't work, since &lt;code&gt;y&lt;/code&gt; by itself is not a valid motion... You can fix that with an additional &lt;code&gt;nmap yy y_&lt;/code&gt; mapping, since &lt;code&gt;_&lt;/code&gt; is a valid motion corresponding to the double letter commands (&lt;code&gt;yy&lt;/code&gt;, &lt;code&gt;dd&lt;/code&gt;, etc.) You might also want to map &lt;code&gt;Y&lt;/code&gt; with &lt;code&gt;nmap Y y_&lt;/code&gt;. Note you need &lt;em&gt;recursive&lt;/em&gt; mappings for those, to trigger your original &lt;code&gt;y&lt;/code&gt; mapping.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You should handle yanking to a non-default register. You can look at &lt;code&gt;v:register&lt;/code&gt; to execute your operation. Note that you'll get your register information in &lt;code&gt;Yank_fixed_cursor&lt;/code&gt;, so that's also something you'll want to save in a global variable to later use in &lt;code&gt;Yank_restore_cursor&lt;/code&gt; when you actually execute the operation.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Same for counts, for example &lt;code&gt;5yj&lt;/code&gt;. You can look at &lt;code&gt;v:count&lt;/code&gt; in &lt;code&gt;Yank_fixed_cursor&lt;/code&gt; to check whether there was a count. Since in this case you want to &quot;translate&quot; it into &lt;code&gt;y5j&lt;/code&gt; (i.e. use the count on the &lt;em&gt;motion&lt;/em&gt;), you can handle this by returning &lt;code&gt;'g@'.v:motion&lt;/code&gt; from &lt;code&gt;Yank_fixed_cursor&lt;/code&gt; when a count is passed, since this will leave the count pending when the motion is expected, and will then apply to the motion.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You might want to map &lt;code&gt;y&lt;/code&gt; in Visual mode as well. In many cases you can reuse the execution function &lt;code&gt;Yank_restore_cursor&lt;/code&gt; between both operator-pending mode and Visual mode. You typically do that by taking a variable number of arguments and having the Visual mode mappings pass an extra argument to indicate it was called in that context. See the examples in &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-operator&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :map-operator&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As you can see, this can get quite complex very quickly. There are many corner cases and covering them all takes work. There is quite a bit of complexity involved, but Vim gives you the tools to cover these in order to emulate a command that looks and behaves same as a native command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this topic interests you, you might want to read &lt;a href=&quot;https://learnvimscriptthehardway.stevelosh.com/chapters/33.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Grep Operator&quot;&lt;/a&gt; from &quot;Learn Vimscript the Hard Way&quot;, by Steve Losh.(You'll actually want to read the whole material, but pointing you at the relevant section so you'll see that's thoroughly covered here.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-29T18:16:14.483" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24373" PostTypeId="2" ParentId="2674" CreationDate="2020-03-29T18:25:27.300" Score="0" Body="&lt;p&gt;This works for me if you want something simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Move selection up&#xA;xmap &amp;lt;kMinus&amp;gt; :move '&amp;lt;-2&amp;lt;CR&amp;gt;gv&#xA;&quot; Move selection down&#xA;xmap &amp;lt;kPlus&amp;gt; :move '&amp;gt;+1&amp;lt;CR&amp;gt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-03-29T18:25:27.300" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24374" PostTypeId="2" ParentId="24365" CreationDate="2020-03-29T19:38:06.923" Score="3" Body="&lt;p&gt;&lt;em&gt;I linked a bunch of Bash stuff here. Sorry if that's off the mark but the points made are almost all *nix and shell flavor agnostic.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you are looking to read an environment variable form a shell running in one of Vim's terminal buffers. Unfortunately, such variables are located in the shell process's memory and the internals of a process, including said memory, are locked down tight from access by other processes...for obvious security reasons. This holds&#xA;true even for the process that created it (the &quot;parent&quot;). Yes, a child inherits a lot&#xA;of things from the parent when it is created but that's a one way mechanism and there's no other inherent capability allowing the parent to see what's going on inside it while it's running&lt;sup&gt;1&lt;/sup&gt;. Going the other way &lt;em&gt;a child process can never affect any part of the parent's environment, which includes its variables, its current working directory, its open files, its resource limits, etc&lt;/em&gt; (&lt;a href=&quot;http://mywiki.wooledge.org/BashFAQ/060&quot; rel=&quot;nofollow noreferrer&quot;&gt;BashFAQ 060&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The story doesn't end there, though. Obviously processes &lt;em&gt;can&lt;/em&gt; communicate with each&#xA;other. Typical mechanims for this are shared memory, sockets, and &lt;a href=&quot;http://mywiki.wooledge.org/NamedPipes&quot; rel=&quot;nofollow noreferrer&quot;&gt;named pipes aka FIFOs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim doesn't provide anything that's directly relevant but if you're determined then you can fairly easily set something up yourself in Vim and the child shell. The simplest approach would have to be to just have the child dump the data of interest into a temporary file and have Vim read it from there. If you're not dealing with production systems or anything serious like that you might want to go that route. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or if you want to try something a little more complex you could look at FIFOs which are pretty accessible in shell scripts (thus the above link to some relevant info). Also, one of the things a child inherits is the parent's open file descriptors so that might be useful...in combination with FIFOs or otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;sub&gt;The parent does have some lifecycle control, can send signals to the child (hello &lt;code&gt;kill&lt;/code&gt;) and can read its exit code upon termination...none of which help here. (Note that I'm ignoring various hacks and other risky behaviors as well as debuggers and the like to avoid a trip into the weeds.)&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For a bit more discussion around Vim, shells, parent-child relationships and inheritance see &lt;a href=&quot;https://vi.stackexchange.com/questions/22947/why-does-cd-not-change-the-directory/22949#22949&quot;&gt;Why does !cd not change the directory&lt;/a&gt;. For a deep dive beyond Vim, check out &lt;a href=&quot;http://mywiki.wooledge.org/ProcessManagement&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bash Process Management&lt;/a&gt;...chock full of juicy details.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-03-30T01:52:30.200" LastActivityDate="2020-03-30T01:52:30.200" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24375" PostTypeId="1" CreationDate="2020-03-29T20:54:31.113" Score="1" ViewCount="143" Body="&lt;p&gt;I love that when working in python I can hover my cursor over a keyword a (e.g. math) and see docs in a less format to briefly read the api and then go back to writing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed in python, vim is loading python2.7 docs.  Is there a way to change the default to 3?'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;running OSX Catalina vim version 8.1.1312 and use homebrew for python3.X&lt;/p&gt;&#xA;" OwnerUserId="28633" LastActivityDate="2020-04-28T23:00:45.067" Title="how to change &lt;shift-K&gt; to lookup python3 keyword instead of python2.7" Tags="|manpages|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24376" PostTypeId="1" AcceptedAnswerId="24378" CreationDate="2020-03-29T22:02:57.017" Score="0" ViewCount="75" Body="&lt;p&gt;If I want the output &lt;code&gt;g&lt;/code&gt;, I can create a map like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;F2&amp;gt; &amp;lt;C-V&amp;gt;U10400g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However for output &lt;code&gt;f&lt;/code&gt;, it causes a problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;F2&amp;gt; &amp;lt;C-V&amp;gt;U10400f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as the &lt;code&gt;f&lt;/code&gt; is confused as part of the character. I can work around by adding&#xA;leading zeros:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;F2&amp;gt; &amp;lt;C-V&amp;gt;U00010400f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I would prefer a terminating key if possible. I came up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;F2&amp;gt; &amp;lt;C-V&amp;gt;U10400&amp;lt;CR&amp;gt;f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it puts a newline between the two characters. Is it possible to do what I am&#xA;trying to do?&lt;/p&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-03-29T22:29:51.937" Title="Map hex character" Tags="|key-bindings|insert-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24377" PostTypeId="2" ParentId="24375" CreationDate="2020-03-29T22:10:34.203" Score="2" Body="&lt;p&gt;Vim uses the &lt;code&gt;pydoc&lt;/code&gt; command to display Python help, so if your system has a &lt;code&gt;pydoc&lt;/code&gt; that defaults to Python 3, its setup will work as expected out of the box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I imagine that's perhaps not the case with Mac OS X and Python 3 from Homebrew. So you can consider updating your Vim setup to use a more appropriate &lt;code&gt;pydoc&lt;/code&gt; that matches your system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This setting is controlled by the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27keywordprg%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'keywordprg'&lt;/code&gt;&lt;/a&gt; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Python filetype support shipped with Vim doesn't allow much customization for this particular option, so the best way for you to override it is to write your own custom Python filetype plug-in, that will run &lt;em&gt;after&lt;/em&gt; the one in Vim runtimes, that will override &lt;code&gt;'keywordprg'&lt;/code&gt; to the setting that makes sense to your system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a file named &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt; and add this single line to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal keywordprg=pydoc3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's assuming you can use a &lt;code&gt;pydoc3&lt;/code&gt; command that's in your &lt;code&gt;$PATH&lt;/code&gt; to look up Python 3 docs. If that's not the right command, update to one that will work for you. You can use a full path if needed. If you need spaces, escape them with backslashes. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setlocal keywordprg=/usr/local/bin/python3\ -m\ pydoc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-29T22:10:34.203" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24378" PostTypeId="2" ParentId="24376" CreationDate="2020-03-29T22:29:51.937" Score="1" Body="&lt;p&gt;The documentation explicitly recommends using the maximum number of digits. See &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-V_digit&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-V_digit&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Normally you would type the maximum number of characters.  Thus to enter a&#xA;  space (value 32) you would type &lt;code&gt;&amp;lt;C-V&amp;gt;032&lt;/code&gt;.  You can omit the leading zero, in which case the character typed after the number must be a non-digit.  This&#xA;  happens for the other modes as well: As soon as you type a character that is&#xA;  invalid for the mode, the value before it will be used and the &quot;invalid&quot;&#xA;  character is dealt with in the normal way.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have found, however, that a command such as &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-%5D&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;CTRL-]&lt;/code&gt;&lt;/a&gt;, which triggers abbreviation, without inserting a character, is enough to break the sequence, without an undesirable side effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to work fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;F2&amp;gt; &amp;lt;C-V&amp;gt;U10400&amp;lt;C-]&amp;gt;f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'd still recommend the solution using the three leading zeroes, as it's less &quot;hacky&quot; and it's the one recommended in the documentation.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-03-29T22:29:51.937" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24379" PostTypeId="2" ParentId="24369" CreationDate="2020-03-29T23:04:07.783" Score="1" Body="&lt;p&gt;You should use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#win_execute%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;win_execute()&lt;/code&gt;&lt;/a&gt; command to run commands in a different window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It takes your command to be executed as a string, or it can also take a list of strings to execute multiple commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main advantage of using &lt;code&gt;win_execute()&lt;/code&gt; over switching to a window is that it will avoid pitfalls such as window event triggers, modifications to the previous window, modifications to the height of squashed windows. It's also necessary for popup windows, as switching to those windows is not allowed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;setpos()&lt;/code&gt; by itself didn't trigger an update on the other window. Even though the cursor position &lt;em&gt;was&lt;/em&gt; changed, the view didn't reflect it until I changed to that window. One option is to run both that command and a &lt;code&gt;redraw&lt;/code&gt; to force that to happen:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call win_execute(1010, ['call setpos(&quot;.&quot;, [0, 1, 1, 1])', 'redraw'])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another option is to use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#winrestview%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;winrestview()&lt;/code&gt;&lt;/a&gt;, since that command seems to work correctly without any redraws:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call win_execute(1010, 'call winrestview({&quot;col&quot;: 1, &quot;lnum&quot;: 1})')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Another advantage of &lt;code&gt;winrestview()&lt;/code&gt; is that it also offers control of the first line and column of the window, not just the cursor position.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing to watch for with &lt;code&gt;win_execute()&lt;/code&gt; is that it will fail silently if the window doesn't exist, you don't get any indication that the command failed because the window id is invalid. So make sure you get a valid window id before you execute that command.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-03-30T22:37:43.627" LastActivityDate="2020-03-30T22:37:43.627" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24380" PostTypeId="2" ParentId="20495" CreationDate="2020-03-30T03:23:43.143" Score="1" Body="&lt;p&gt;Before saving a file, I frequently verify changes before saving using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:w !diff - %     (diff &amp;lt;memory copy&amp;gt;  &amp;lt;original file&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quickly see changes in a simple diff style  without changing the file. &lt;/p&gt;&#xA;" OwnerUserId="28638" LastActivityDate="2020-03-30T03:23:43.143" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24381" PostTypeId="1" AcceptedAnswerId="24404" CreationDate="2020-03-30T06:14:35.377" Score="2" ViewCount="170" Body="&lt;p&gt;I'm using vim to do my code job and I installed Nerdtree and YCM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;a href=&quot;https://github.com/ycm-core/YouCompleteMe/pull/1814&quot; rel=&quot;nofollow noreferrer&quot;&gt;this merge&lt;/a&gt;, YCM has two functions, which allows us to get the error and warning counts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd VimEnter * NERDTree&#xA;autocmd CursorHold,CursorHoldI * update&#xA;set statusline+=%#warningmsg#&#xA;set statusline+=%{youcompleteme#GetErrorCount()}&#xA;set statusline+=%*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I execute &lt;code&gt;vim&lt;/code&gt;, I will get some errors as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function 191[2]..192[20]..195[8]..159[25]..157[23]..nerdtree#echo[1]..youcompleteme#GetEr&#xA;rorCount:&#xA;line    1:&#xA;Traceback (most recent call last):&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function 191[2]..192[20]..195[8]..159[25]..157[23]..nerdtree#echo[1]..youcompleteme#GetEr&#xA;rorCount:&#xA;line    1:&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function 191[2]..192[20]..195[8]..159[25]..157[23]..nerdtree#echo[1]..youcompleteme#GetEr&#xA;rorCount:&#xA;line    1:&#xA;NameError: name 'ycm_state' is not defined&#xA;Press ENTER or type command to continue&#xA;Error detected while processing function 191[2]..192[20]..195[8]..159[25]..157[23]..nerdtree#echo[1]..youcompleteme#GetEr&#xA;rorCount:&#xA;line    1:&#xA;E858: Eval did not return a valid python object&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, I type &lt;code&gt;enter&lt;/code&gt;, everything works fine, I can see the error counts at the status line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't quite know why but it seems that when I execute &lt;code&gt;vim&lt;/code&gt;, it first loads the plugin Nerdtree, and the function &lt;code&gt;youcompleteme#GetErrorCount()&lt;/code&gt; cause some error. After typing &lt;code&gt;enter&lt;/code&gt;, it loads some files into buffer, then &lt;code&gt;youcompleteme#GetErrorCount()&lt;/code&gt; can work well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can we solve this issue?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-04-01T01:53:23.603" Title="YCM causes some error while loading nerdtree" Tags="|plugin-you-complete-me|plugin-nerdtree|error|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24382" PostTypeId="2" ParentId="23328" CreationDate="2020-03-30T07:43:23.847" Score="19" Body="&lt;p&gt;I don't use &lt;code&gt;coc&lt;/code&gt;, so I will just share my vision on how you can try to fix this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume that by suggestion box you mean regular vim Pmenu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to make sure if it is actually Pmenu:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;run &lt;code&gt;:hi Pmenu&lt;/code&gt; and check the colors:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GKgFF.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GKgFF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;if it really is, then changing it would be simple, add to your &lt;code&gt;vimrc&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot; Customize colors&#xA;func! s:my_colors_setup() abort&#xA;    &quot; this is an example&#xA;    hi Pmenu guibg=#d7e5dc gui=NONE&#xA;    hi PmenuSel guibg=#b7c7b7 gui=NONE&#xA;    hi PmenuSbar guibg=#bcbcbc&#xA;    hi PmenuThumb guibg=#585858&#xA;endfunc&#xA;&#xA;augroup colorscheme_coc_setup | au!&#xA;    au ColorScheme * call s:my_colors_setup()&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;if it is not, then try to figure out what highlights coc uses either by looking into coc doc or coc source files or try to &quot;look&quot; into &lt;code&gt;:hi&lt;/code&gt; command output:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5BaJz.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5BaJz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;if found something related to coc, try to change color of the group using &lt;code&gt;:hi coc-group guibg=red&lt;/code&gt; or smth similar. (&lt;code&gt;coc-group&lt;/code&gt; is an example here). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if you have found what coc highlight group you want to change -- make amends to 2. and you are ok&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If it is not &lt;code&gt;Pmenu&lt;/code&gt; (maybe it is float window of neovim or popup of vim) then you'll have to dig out how coc passes colors to them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ColorScheme&lt;/code&gt; autocommand is triggered when colorscheme is changed. You change colorscheme before autocommand is defined.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;put &lt;code&gt;colorscheme afterglow&lt;/code&gt; after augroup and autocommand definition&lt;/li&gt;&#xA;&lt;li&gt;NOTE that if you use terminal vim without &lt;code&gt;termguicolors&lt;/code&gt; option, then gui colors wouldn't work. You have to add &lt;code&gt;ctermbg&lt;/code&gt; and &lt;code&gt;ctermfg&lt;/code&gt; parameters. (I don't know what palette do you use 16 or 256, for default palette colors consult &lt;a href=&quot;https://jonasjacek.github.io/colors/&quot; rel=&quot;noreferrer&quot;&gt;https://jonasjacek.github.io/colors/&lt;/a&gt; -- &lt;code&gt;ctermbg=67&lt;/code&gt; should be SteelBlue or smth)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    hi Pmenu ctermbg=black ctermfg=white&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-03-30T10:28:53.240" LastActivityDate="2020-03-30T10:28:53.240" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="24383" PostTypeId="2" ParentId="15764" CreationDate="2020-03-30T08:10:25.560" Score="0" Body="&lt;p&gt;Thanks to @statox, I had a go at writing something that can be used with &lt;code&gt;formatprg&lt;/code&gt;. At the time of writing it's still a big rough but it will do what you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use it, you need to install my vim script:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;clone the repo, it has a helper vim script and the NodeJS script that does the formatting&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/tomsaleeba/js-string-literal-breaker.git /tmp/jsslb&#xA;# note, we're cloning to /tmp for this demo but if you like the script, clone&#xA;# somewhere more permanent&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;start vim with your test case in a buffer&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat &amp;lt;&amp;lt;EOF | vim&#xA;console.log(&#xA;   &quot;This is a really long line that I want to format, and it is inside of a quote&quot;&#xA;)&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;source my vim script&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:source /tmp/jsslb/script.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;enable the formatter&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;leader&amp;gt;j&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;move the cursor to line 2&lt;/li&gt;&#xA;&lt;li&gt;run the formatter &lt;code&gt;gqq&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;the buffer should now look like&#xA;&#xA;&lt;pre&gt;&lt;code&gt;console.log(&#xA;   &quot;This is a really long line that I want to format, and it is inside of a &quot; +&#xA;   &quot;quote&quot;&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="18750" LastActivityDate="2020-03-30T08:10:25.560" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24384" PostTypeId="2" ParentId="23323" CreationDate="2020-03-30T08:19:22.297" Score="6" Body="&lt;p&gt;According to &lt;code&gt;coc&lt;/code&gt; readme you can trigger completion manually with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use &amp;lt;c-space&amp;gt; to trigger completion.&#xA;inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;c-space&amp;gt; coc#refresh()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE that not every terminal supports &lt;code&gt;&amp;lt;c-space&amp;gt;&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know for sure how to map &lt;code&gt;cmd&lt;/code&gt; in vim... Probably &lt;code&gt;D&lt;/code&gt; or something:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use &amp;lt;CMD-x&amp;gt; to trigger completion.&#xA;inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;D-x&amp;gt; coc#refresh()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example with &lt;code&gt;&amp;lt;C-k&amp;gt;&lt;/code&gt; that should work with most terminals:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use &amp;lt;C-k&amp;gt; to trigger completion.&#xA;inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;C-k&amp;gt; coc#refresh()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To turn off autocompletion for coc -- as stated in coc help, you have to add configuration to coc json file:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;run &lt;code&gt;:CocConfig&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;in the opened &lt;code&gt;coc-settings.json&lt;/code&gt; file add:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  &quot;suggest.autoTrigger&quot;: &quot;none&quot;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For reference, see &lt;code&gt;:h CocConfig&lt;/code&gt; and &lt;code&gt;:h coc-configuration&lt;/code&gt; (search for &lt;code&gt;autoTrigger&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-03-30T11:08:06.483" LastActivityDate="2020-03-30T11:08:06.483" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="24385" PostTypeId="2" ParentId="2239" CreationDate="2020-03-30T10:05:17.773" Score="1" Body="&lt;p&gt;Just use command &lt;code&gt;:set listchars=tab:\ \  list&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I intentionally put &lt;code&gt;list&lt;/code&gt; in the end to preserve the space after last backslash in the &lt;code&gt;listchars&lt;/code&gt; option value.&lt;/p&gt;&#xA;" OwnerUserId="6224" LastEditorUserId="6224" LastEditDate="2020-03-30T10:18:58.843" LastActivityDate="2020-03-30T10:18:58.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24386" PostTypeId="1" CreationDate="2020-03-30T17:58:19.010" Score="1" ViewCount="65" Body="&lt;p&gt;I'd like to be able to yank a visual selection and then append it to another file at a certain line (according to a pattern).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular (as shown in the attached screenshot), as an example i'd like to copy text from test.txt into a register perhaps create a visual selection and then, use the the w: command to send that to test2.txt (shown).&#xA;In the screenshot, I tried:&#xA;1. Get visual selection ;&#xA;2. Hit : followed by w +/John test2.txt&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It says that it can't open test2.txt&lt;a href=&quot;https://i.stack.imgur.com/wQsRv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wQsRv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="28649" LastEditorUserId="28649" LastEditDate="2020-03-31T14:37:47.257" LastActivityDate="2020-03-31T14:37:47.257" Title="How can I send a visual selection to another file, at a line with a certain pattern?" Tags="|vimscript|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24387" PostTypeId="1" AcceptedAnswerId="24388" CreationDate="2020-03-30T20:05:26.763" Score="1" ViewCount="205" Body="&lt;p&gt;When I run &lt;code&gt;:make&lt;/code&gt; or &lt;code&gt;:grep&lt;/code&gt; from vim on Linux I see the make/grep progress in the standard output as it occurs and then, when the command completes, I can use &lt;code&gt;:copen&lt;/code&gt; to navigate through the quickfix list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I run either of these two commands on Windows (either from gvim or console vim), I see nothing until the command completes. Once the command completes, I can use &lt;code&gt;:copen&lt;/code&gt; like I do on Linux, but I get no realtime output progress like I do on Linux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing different between Linux/Windows is that the make command on Windows is redirected to a temporary file, like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;!nmake -f Make-mvc.make &amp;gt; C:\Users\doug\AppData\Local\Temp\VIe4397.tmp 2&amp;gt;&amp;amp;1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This appears to be the reason I get no realtime output as the command is running, but I don't know why the redirect is necessary (this does not occur on Linux) and I also don't know if there is a way to workaround the issue.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Here is a demonstration of what happens when I try to build vim from source, just as an example of of using the :make command.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Run the following commands from CMD.exe to checkout vim source code and start gvim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone git@github.com:vim/vim.git&#xA;cd vim/src&#xA;gvim -u NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run the following vim commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set makeprg=nmake&#xA;:make -f Make_mvc.make&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can see &lt;code&gt;!nmake -f Make-mvc.make &amp;gt; C:\Users\doug\AppData\Local\Temp\VIe4397.tmp 2&amp;gt;&amp;amp;1&lt;/code&gt; appear in the vim command line window, but no other output appears until the command completes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WNdam.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WNdam.png&quot; alt=&quot;Running :make -f Make_mvc.make&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="27554" LastActivityDate="2020-03-30T21:53:00.723" Title="How to get realtime progress from :make and :grep on Windows" Tags="|microsoft-windows|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24388" PostTypeId="2" ParentId="24387" CreationDate="2020-03-30T20:35:10.750" Score="1" Body="&lt;h2&gt;console vim solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help os_win32.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Q. How do I get to see the output of &quot;:make&quot; while it's running?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A. Basically what you need is to put a tee program that will copy its&#xA;  input (the output from make) to both stdout and to the errorfile. &#xA;  You can find a copy of tee (and a number of other GNU tools) at&lt;br&gt;&#xA;  &lt;a href=&quot;http://gnuwin32.sourceforge.net&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://gnuwin32.sourceforge.net&lt;/a&gt; or &lt;a href=&quot;http://unxutils.sourceforge.net&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://unxutils.sourceforge.net&lt;/a&gt;&lt;br&gt;&#xA;  Alternatively, try the more recent Cygnus version of the GNU tools at &#xA;  &lt;a href=&quot;http://www.cygwin.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.cygwin.com&lt;/a&gt;  Other Unix-style tools for Win32 are listed at &#xA;  &lt;a href=&quot;http://directory.google.com/Top/Computers/Software/Operating_Systems/Unix/Win32/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://directory.google.com/Top/Computers/Software/Operating_Systems/Unix/Win32/&lt;/a&gt;&#xA;  When you do get a copy of tee, you'll need to add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set shellpipe=\|\ tee&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;to your _vimrc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h2&gt;gvim solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Under gvim, a separate console window is started minimized. If you restore the minimized window, you can observe the output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the window to start restored (not minimized), then you'll have to make the following source change to &lt;a href=&quot;https://github.com/vim/vim/blob/9be61bbb170ed3df0e408c8ac12516e772dc0b75/src/os_win32.c#L3940-L3947&quot; rel=&quot;nofollow noreferrer&quot;&gt;src/os_win32.c&lt;/a&gt; and compile gvim yourself.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     si.lpDesktop = NULL;&#xA;     si.lpTitle = NULL;&#xA;     si.dwFlags = STARTF_USESHOWWINDOW;&#xA;-    /*&#xA;-     * It's nicer to run a filter command in a minimized window.&#xA;-     * Don't activate the window to keep focus on Vim.&#xA;-     */&#xA;-    if (options &amp;amp; SHELL_DOOUT)&#xA;-       si.wShowWindow = SW_SHOWMINNOACTIVE;&#xA;-    else&#xA;-       si.wShowWindow = SW_SHOWNORMAL;&#xA;+    si.wShowWindow = SW_SHOWNORMAL;&#xA;     si.cbReserved2 = 0;&#xA;     si.lpReserved2 = NULL;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27554" LastEditorUserId="27554" LastEditDate="2020-03-30T21:53:00.723" LastActivityDate="2020-03-30T21:53:00.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24389" PostTypeId="1" CreationDate="2020-03-30T20:48:29.740" Score="4" ViewCount="175" Body="&lt;p&gt;I often find myself doing something like this with a tiny header file with only a few lines:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;W&lt;/kbd&gt;, &lt;kbd&gt;^&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;W&lt;/kbd&gt;, &lt;kbd&gt;j&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;50&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;W&lt;/kbd&gt;, &lt;kbd&gt;-&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;50&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;W&lt;/kbd&gt;, &lt;kbd&gt;-&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;30&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;W&lt;/kbd&gt;, &lt;kbd&gt;-&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;10&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;W&lt;/kbd&gt;, &lt;kbd&gt;-&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;… or similar, to slowly &quot;zero in&quot; my window-height on the height of the actual file's contents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I'd like the sort of “inverse” of &lt;code&gt;'scrolloff'&lt;/code&gt; — “for new splits, if there's &lt;code&gt;&amp;lt;= 'lines'&lt;/code&gt; of text in the buffer, then set &lt;code&gt;'winheight'&lt;/code&gt; to &lt;code&gt;'lines' + N&lt;/code&gt;”; but if that's not possible, a hotkey to achieve the same for the current window would probably suffice!&lt;/p&gt;&#xA;" OwnerUserId="6108" LastEditorUserId="23502" LastEditDate="2023-10-04T09:19:32.920" LastActivityDate="2023-10-04T09:21:18.260" Title="Is there a way to resize a split such that it exactly fits its content (plus/minus N lines of buffer-space)?" Tags="|key-bindings|split|window-management|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24390" PostTypeId="1" CreationDate="2020-03-30T21:41:44.587" Score="0" ViewCount="32" Body="&lt;p&gt;When &lt;a href=&quot;https://stackoverflow.com/q/60818926/430766&quot;&gt;searching&lt;/a&gt; for a command to enable me to open multiple tabs in normal mode, I &lt;a href=&quot;https://vi.stackexchange.com/a/2110/852&quot;&gt;found&lt;/a&gt; a custom command to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Open multiple tabs at once&#xA;fun! OpenMultipleTabs(pattern_list)&#xA;    for p in a:pattern_list&#xA;        for c in glob(l:p, 0, 1)&#xA;            execute 'tabedit ' . l:c&#xA;        endfor&#xA;    endfor&#xA;endfun&#xA;&#xA;command! -bar -bang -nargs=+ -complete=file Tabedit call OpenMultipleTabs([&amp;lt;f-args&amp;gt;])&#xA;&#xA;&quot; less typing:&#xA;map &amp;lt;C-n&amp;gt; :Multitab &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However&lt;/strong&gt;, this doesn't work when trying to open a path that doesn't exist yet. So one cannot use this to create new files. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Tabedit *.c&#xA;&quot; works: opens all matching .c files&#xA;:!touch existing-file.txt&#xA;:Tabedit existing-file.txt&#xA;&quot; works: opens the existing file&#xA;:Tabedit new-file.txt&#xA;&quot; doesn't do anything at all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So what I want is for strings that don't require expansion, to open the same as with &lt;code&gt;:tabedit&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="852" LastActivityDate="2020-08-27T23:00:55.110" Title="How can I modify OpenMultipleTabs so that I can open buffers for new files?" Tags="|tabbed-user-interface|filesystem|multiple-files|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24391" PostTypeId="2" ParentId="24390" CreationDate="2020-03-30T21:57:09.060" Score="1" Body="&lt;p&gt;My crude solution is to test whether &lt;code&gt;glob&lt;/code&gt; finds any files and otherwise just to open the expression previously passed to &lt;code&gt;glob&lt;/code&gt;. There is probably a more elegant way to do this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! OpenMultipleTabs(pattern_list)&#xA;    for p in a:pattern_list&#xA;        let gl = glob(l:p, 0, 1)&#xA;        if empty(gl)&#xA;            let gl = [ l:p ]&#xA;        endif&#xA;        for c in gl&#xA;            execute 'tabedit ' . l:c&#xA;        endfor&#xA;    endfor&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="852" LastActivityDate="2020-03-30T21:57:09.060" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24392" PostTypeId="1" AcceptedAnswerId="24405" CreationDate="2020-03-30T23:01:41.510" Score="1" ViewCount="553" Body="&lt;p&gt;I'm trying to do something relatively simple: Editing a file in &lt;code&gt;src&lt;/code&gt; and pointing Vim to the header file located in &lt;code&gt;include&lt;/code&gt;. My .vimrc file has &lt;code&gt;set modeline&lt;/code&gt; on, and the first line in my file is: &lt;code&gt;// vim: set path += ../include&lt;/code&gt; (I've also tried &lt;code&gt;include&lt;/code&gt;, &lt;code&gt;include;&lt;/code&gt;, and several other variations). When I look at the &lt;code&gt;path&lt;/code&gt; variable:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;echo &amp;amp;path&lt;/code&gt; gives me &lt;code&gt;.,/usr/include,,&lt;/code&gt;; the path doesn't change regardless of what I put in the modeline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;echo path&lt;/code&gt; gives me nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing incorrectly here?&lt;/p&gt;&#xA;" OwnerUserId="4675" LastActivityDate="2020-04-01T07:31:43.940" Title="Vim's &quot;path&quot; variable isn't changing or updating with modeline setting (finding header file in different directory)" Tags="|path|modeline|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24393" PostTypeId="1" CreationDate="2020-03-31T02:42:01.617" Score="2" ViewCount="298" Body="&lt;p&gt;I’ve been developing a Vim syntax file for ISC Bind 9.15+&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The stock named.vim that came with Vim is quite outdated (V9.4) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;About 89 syntaxes out of 498 have been completed so far to catch up.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the new named.vim is now 2000+ lines long.  It’s still very fast.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I’m looking for HOWTOs or debugging techniques on large syntax files.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently doing a [dual Vim terminal sessions (as described in &lt;a href=&quot;https://egbert.net/blog/articles/debugging-bind9-syntax-file-of-vim.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Egbert&lt;/a&gt;) using &lt;a href=&quot;http://www.drchip.org/astronaut/vim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dr. Chip&lt;/a&gt;’s &lt;a href=&quot;http://www.drchip.org/astronaut/vim/vbafiles/hilinks.vba.gz&quot; rel=&quot;nofollow noreferrer&quot;&gt;HiTraceLinks/HiLinks&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where can i find such syntax debugging resources? &lt;/p&gt;&#xA;" OwnerUserId="18880" LastEditorUserId="18880" LastEditDate="2020-03-31T02:53:44.080" LastActivityDate="2020-03-31T02:53:44.080" Title="Resource for highlight syntax debugging" Tags="|vimrc|vimscript|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24394" PostTypeId="2" ParentId="24389" CreationDate="2020-03-31T03:34:37.827" Score="1" Body="&lt;h3&gt;Manual approach&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;2&amp;lt;c-w&amp;gt;0&lt;/code&gt; to resize current window to fit buffer, with &lt;code&gt;2&lt;/code&gt; extra lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's fully commented, read comment as explanation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Resize window to fit buffer + &amp;lt;count&amp;gt;. It works the same as &amp;lt;c-w&amp;gt;_ if there&#xA;&quot; are too many lines to fit.&#xA;command -count WinFitBuf call s:win_fit_buf(&amp;lt;count&amp;gt;)&#xA;nnoremap &amp;lt;expr&amp;gt; &amp;lt;c-w&amp;gt;0 printf(':&amp;lt;c-u&amp;gt;%dWinFitBuf&amp;lt;cr&amp;gt;', v:count)&#xA;&#xA;function s:win_fit_buf(extra_lines) abort&#xA;&#xA;  &quot; save old view&#xA;  let cview = winsaveview()&#xA;&#xA;  try&#xA;&#xA;    &quot; I must find screen line count for current buffer, I don't know how to do&#xA;    &quot; it directly, so I decide to maximize current window first, then shrink to&#xA;    &quot; fit, I only need last screen line of current buffer this way.&#xA;    wincmd _&#xA;&#xA;    &quot; Clear scroll, goto last byte. I start this with ex 0 and $, but they don't&#xA;    &quot; clear scroll until script finished.&#xA;    keepjump norm! ggG$&#xA;&#xA;    &quot; resize to fit&#xA;    exe printf('%dwincmd _',  winline() + a:extra_lines)&#xA;&#xA;  finally&#xA;&#xA;    &quot; restore old view&#xA;    cal winrestview(cview)&#xA;  endtry&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Automatic&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;It's tricky to do it automatically:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can't do it with &lt;code&gt;WinNew&lt;/code&gt;, as you don't know new buffer line count in&#xA;this moment, the &lt;code&gt;&amp;lt;afile&amp;gt;&lt;/code&gt; and &lt;code&gt;bufname()&lt;/code&gt; all points to the old buffer&#xA;name.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can't do it with &lt;code&gt;WinBufEnter&lt;/code&gt;, as &lt;code&gt;:e file&lt;/code&gt; will trigger it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You must also make sure new window is in a &lt;code&gt;col&lt;/code&gt; layout.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;You must make sure it's not a blank buffer.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I didn't do it, it looks complicate and fragile.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-03-31T23:17:12.933" LastActivityDate="2020-03-31T23:17:12.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24395" PostTypeId="1" CreationDate="2020-03-31T10:45:23.243" Score="0" ViewCount="137" Body="&lt;p&gt;I wanted to know if it's possible through plugin mechanism to insert another &quot;pane&quot; in the middle of the buffer I'm editing. The ultimate feature that I want is inlining piece code which exists in some other file. A very good example is how brackets code editor lets you edit css from another file within html:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/B2nRP.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't find any existing vim plugin to do this, so I thought I'll begin by asking if there are any fundamental (perhaps terminal-GUI level) limitations which could prevent you from doing this&lt;/p&gt;&#xA;" OwnerUserId="12650" LastActivityDate="2020-03-31T15:40:04.790" Title="Is it possible to have a &quot;quick edit&quot; (inline-editing of another file, nested buffers) feature through plugins?" Tags="|vim-windows|plugin-system|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24396" PostTypeId="2" ParentId="7258" CreationDate="2020-03-31T11:05:03.187" Score="10" Body="&lt;p&gt;If you are using &lt;a href=&quot;https://github.com/Yggdroot/indentLine&quot; rel=&quot;noreferrer&quot;&gt;indentLine&lt;/a&gt; and want to &lt;em&gt;keep&lt;/em&gt; it working but want to prevent Vim from hiding things in JSON and Markdown, the solution is to ask your syntax highlighting to not use the conceal feature.&lt;/p&gt;&#xA;&lt;p&gt;For the JSON and Markdown syntax files included in &lt;a href=&quot;https://github.com/sheerun/vim-polyglot&quot; rel=&quot;noreferrer&quot;&gt;vim-polyglot&lt;/a&gt;, that's accomplished using the following three lines:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:vim_json_syntax_conceal = 0&#xA;let g:vim_markdown_conceal = 0&#xA;let g:vim_markdown_conceal_code_blocks = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20566" LastEditorUserId="20566" LastEditDate="2020-08-04T03:40:43.760" LastActivityDate="2020-08-04T03:40:43.760" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24397" PostTypeId="1" CreationDate="2020-03-31T14:27:39.513" Score="-1" ViewCount="263" Body="&lt;p&gt;I have a buffer that contains this sentence :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I go to a rendez-vous this evening.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I have this function :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyFunction()&#xA;  let myList = [&quot;rendez-vous&quot;]&#xA;  let myFile = readfile(bufname(1))&#xA;  for elem in myList&#xA;      if match(myFile,elem)!=-1&#xA;              echo elem&#xA;          let elem2 = substitute(elem, '-', 'µ', 'gn')&#xA;          echo elem2&#xA;          exe '%s/'elem.'/'elem2    &#xA;      endif&#xA;  endfor&#xA;endfunction &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my buffer, rendez-vous not become rendezµvous. Could you tell me why, please ?&lt;/p&gt;&#xA;" OwnerUserId="26872" LastActivityDate="2020-03-31T18:42:21.213" Title="Replace in a loop" Tags="|replace|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24398" PostTypeId="2" ParentId="24395" CreationDate="2020-03-31T15:40:04.790" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;if there are any fundamental (perhaps terminal-GUI level) limitations&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Normal windows are always tiled, popup windows are read-only. Hence if you &quot;insert another pane in the middle&quot;, then you can't edit it anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim is designed with split window / switch buffer paradigm in mind. Just get used to this.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-03-31T15:40:04.790" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24400" PostTypeId="2" ParentId="24397" CreationDate="2020-03-31T18:42:21.213" Score="-1" Body="&lt;p&gt;This is the solution :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyFunction()&#xA;  let myList = [&quot;rendez-vous&quot;]&#xA;  let myFile = readfile(bufname(1))&#xA;  for elem in myList&#xA;      if match(myFile,elem)!=-1&#xA;              echo elem&#xA;          let elem2 = substitute(elem, '-', 'µ', 'g')&#xA;          echo elem2&#xA;          exe '%s/'.elem.'/'.elem2.'/gn'    &#xA;      endif&#xA;  endfor&#xA;endfunction &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26872" LastActivityDate="2020-03-31T18:42:21.213" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24401" PostTypeId="2" ParentId="7815" CreationDate="2020-03-31T18:59:29.253" Score="2" Body="&lt;p&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;;&lt;/kbd&gt; is not a valid control sequence, so vim cannot capture it. You will need to use gvim or to configure your terminal emulator to translate &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;;&lt;/kbd&gt; to something vim can capture&lt;/p&gt;&#xA;" OwnerUserId="28674" LastEditorUserId="10604" LastEditDate="2020-04-01T14:26:40.447" LastActivityDate="2020-04-01T14:26:40.447" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24403" PostTypeId="2" ParentId="4518" CreationDate="2020-03-31T22:55:18.633" Score="2" Body="&lt;p&gt;TLDR: Make sure that &lt;a href=&quot;https://github.com/kana/vim-submode/blob/d29de4f55c40a7a03af1d8134453a703d6affbd2/doc/submode.txt#L228-L230&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;g:submode_keyseqs_to_leave&lt;/code&gt;&lt;/a&gt; does not include the &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either reset it to an empty list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:submode_keyseqs_to_leave = []&#xA;                                 ^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or double the &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; key:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:submode_keyseqs_to_leave = ['&amp;lt;esc&amp;gt;&amp;lt;esc&amp;gt;']&#xA;                                        ^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the latter case, you'll need to press &lt;code&gt;Esc&lt;/code&gt; twice to leave the submode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure to set the variable &lt;em&gt;before&lt;/em&gt; invoking &lt;code&gt;submode#enter_with()&lt;/code&gt; and &lt;code&gt;submode#map()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My problem is that I don't understand why this happens&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Suppose you want &lt;code&gt;&amp;lt;c-w&amp;gt;-&lt;/code&gt; to be repeatable by just pressing &lt;code&gt;-&lt;/code&gt;, without any plugin.  A first attempt could look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;c-w&amp;gt;- &amp;lt;c-w&amp;gt;-&amp;lt;c-w&amp;gt;&#xA;                  ^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mapping preserves the original meaning of &lt;code&gt;&amp;lt;c-w&amp;gt;-&lt;/code&gt;, and simply appends &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; in the rhs so that you don't have to press it again the next time you want to resize the window.  Note that the first &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; in the rhs is not remapped; which is why &lt;code&gt;&amp;lt;c-w&amp;gt;-&lt;/code&gt; is not replaced with itself indefinitely:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;If the {rhs} starts with {lhs}, the first character is not mapped&#xA;again (this is Vi compatible).&#xA;For example: &amp;gt;&#xA;   :map ab abcd&#xA;will execute the &quot;a&quot; command and insert &quot;bcd&quot; in the text.  The &quot;ab&quot; in the&#xA;{rhs} will not be mapped again.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h recursive_mapping&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, something unexpected may happen if you add another mapping like &lt;code&gt;nno &amp;lt;c-w&amp;gt;i dd&lt;/code&gt;.  If you press &lt;code&gt;&amp;lt;c-w&amp;gt;-&lt;/code&gt; followed by a few &lt;code&gt;-&lt;/code&gt;, the window will be correctly resized; but if you then press &lt;code&gt;i&lt;/code&gt; to enter insert mode, Vim will instead delete the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution is to introduce an ad-hoc prefix which – contrary to the &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; prefix – can't be typed interactively, and thus should not trigger another user mapping.  The special key name &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; is a good fit for this (&lt;code&gt;&amp;lt;sid&amp;gt;&lt;/code&gt; would work too; see &lt;code&gt;:h map-&amp;lt;sid&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;c-w&amp;gt;- &amp;lt;c-w&amp;gt;-&amp;lt;plug&amp;gt;(prefix)&#xA;                  ^^^^^^^^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this creates another issue; when you press &lt;code&gt;-&lt;/code&gt; after &lt;code&gt;&amp;lt;c-w&amp;gt;-&lt;/code&gt;, the window is not resized again.&#xA;You need a second mapping for your ad-hoc prefix to be able to play the role of &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;c-w&amp;gt;- &amp;lt;c-w&amp;gt;-&amp;lt;plug&amp;gt;(prefix)&#xA;nno &amp;lt;plug&amp;gt;(prefix)- &amp;lt;c-w&amp;gt;-&#xA;    ^^^^^^^^^^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will allow you to repeat &lt;code&gt;&amp;lt;c-w&amp;gt;-&lt;/code&gt; by pressing &lt;code&gt;-&lt;/code&gt;, but only once.&#xA;If you want to be able to repeat &lt;code&gt;&amp;lt;c-w&amp;gt;-&lt;/code&gt; as many times as desired, the second mapping needs to be recursive:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;c-w&amp;gt;- &amp;lt;c-w&amp;gt;-&amp;lt;plug&amp;gt;(prefix)&#xA;nmap &amp;lt;plug&amp;gt;(prefix)- &amp;lt;c-w&amp;gt;-&#xA;^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After pressing &lt;code&gt;&amp;lt;c-w&amp;gt;-&lt;/code&gt; once, as long as you press &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;&amp;lt;plug&amp;gt;(prefix)&lt;/code&gt; will always be written in the typeahead buffer; you may see it on your command-line if &lt;code&gt;'showcmd'&lt;/code&gt; is set; actually, you may see its internal representation in Vim, which is&lt;code&gt;ýS(prefix)&lt;/code&gt; on my machine (&lt;code&gt;vim-submode&lt;/code&gt; hides this by appending 5 no-break spaces to the prefix).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reciprocally, as long as this ad-hoc prefix is written in the typeahead buffer, you don't have to press &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; anymore to execute &lt;code&gt;&amp;lt;c-w&amp;gt;-&lt;/code&gt;, which gives you the impression of being in a submode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, that's basically what &lt;code&gt;vim-submode&lt;/code&gt; does; it emulates a submode by making sure that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;an ad-hoc and non-interactively typable prefix is always fed to the typeahead buffer&lt;/li&gt;&#xA;&lt;li&gt;this ad-hoc prefix can play the role of the original prefix (the one you press interactively, like &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Getting back to your original code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call submode#enter_with('test', 'n', '', '&amp;lt;leader&amp;gt;&amp;lt;UP&amp;gt;', '&amp;lt;C-w&amp;gt;-')&#xA;call submode#map('test', 'n', '', '&amp;lt;UP&amp;gt;', '&amp;lt;C-w&amp;gt;-')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a &lt;em&gt;gross&lt;/em&gt; simplification of what &lt;code&gt;submode#enter_with()&lt;/code&gt; and &lt;code&gt;submode#map()&lt;/code&gt; do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;&amp;lt;up&amp;gt;       &amp;lt;c-w&amp;gt;-&amp;lt;plug&amp;gt;(prefix)&#xA;nmap &amp;lt;plug&amp;gt;(prefix)&amp;lt;up&amp;gt; &amp;lt;c-w&amp;gt;-&amp;lt;plug&amp;gt;(prefix)&#xA;nmap &amp;lt;plug&amp;gt;(prefix)     :echom 'restoring some settings, and leaving submode'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;#enter_with()&lt;/code&gt; also &lt;a href=&quot;https://github.com/kana/vim-submode/blob/d29de4f55c40a7a03af1d8134453a703d6affbd2/autoload/submode.vim#L198&quot; rel=&quot;nofollow noreferrer&quot;&gt;maps escape inside the submode&lt;/a&gt;, with something similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;plug&amp;gt;(prefix)&amp;lt;esc&amp;gt; &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you write these 4 lines of code in a minimal vimrc and start Vim with it, you should be able to reproduce your issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim -Nu NONE -S &amp;lt;(cat &amp;lt;&amp;lt;'EOF'&#xA;    nmap &amp;lt;leader&amp;gt;&amp;lt;up&amp;gt;        &amp;lt;c-w&amp;gt;-&amp;lt;plug&amp;gt;(prefix)&#xA;    nmap &amp;lt;plug&amp;gt;(prefix)&amp;lt;up&amp;gt;  &amp;lt;c-w&amp;gt;-&amp;lt;plug&amp;gt;(prefix)&#xA;    nmap &amp;lt;plug&amp;gt;(prefix)      :echom 'restoring some settings, and leaving submode'&amp;lt;cr&amp;gt;&#xA;    nmap &amp;lt;plug&amp;gt;(prefix)&amp;lt;esc&amp;gt; &amp;lt;nop&amp;gt;&#xA;EOF&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, pressing &lt;code&gt;&amp;lt;leader&amp;gt;&amp;lt;up&amp;gt;&lt;/code&gt; works, but &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt; does not repeat &lt;code&gt;&amp;lt;c-w&amp;gt;-&lt;/code&gt;; instead, it inserts &lt;code&gt;A&lt;/code&gt; in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what happens:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;you press &lt;code&gt;&amp;lt;leader&amp;gt;&amp;lt;up&amp;gt;&lt;/code&gt; which writes &lt;code&gt;&amp;lt;c-w&amp;gt;-&amp;lt;plug&amp;gt;(prefix)&lt;/code&gt; in the typeahead buffer&lt;/li&gt;&#xA;&lt;li&gt;Vim processes &lt;code&gt;&amp;lt;c-w&amp;gt;-&lt;/code&gt; by decreasing the height of the current window; &lt;code&gt;&amp;lt;plug&amp;gt;(prefix)&lt;/code&gt; remains unprocessed because there's an ambiguity (3 mappings start with this plug key), and Vim must wait until the timeout to decide what to do&lt;/li&gt;&#xA;&lt;li&gt;you press &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt; and Vim receives &lt;code&gt;Esc O A&lt;/code&gt;; now the typeahead buffer contains &lt;code&gt;&amp;lt;plug&amp;gt;(prefix) Esc O A&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Vim expands &lt;code&gt;&amp;lt;plug&amp;gt;(prefix) Esc&lt;/code&gt; into &lt;code&gt;&amp;lt;nop&amp;gt;&lt;/code&gt; – which does nothing – because of the last mapping; now the typeahead buffer contains &lt;code&gt;O A&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Vim processes what remains from the typeahead buffer (i.e. &lt;code&gt;O A&lt;/code&gt;), and opens a new line above the current line, as well as inserts &lt;code&gt;A&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It could be a Vim bug, because on linux Vim should wait 1s (provided &lt;code&gt;'timeout'&lt;/code&gt;, &lt;code&gt;'ttimeout'&lt;/code&gt;, &lt;code&gt;'timeoutlen'&lt;/code&gt; and &lt;code&gt;'ttimeoutlen'&lt;/code&gt; have their default values) to decide whether &lt;code&gt;Esc O A&lt;/code&gt; is a sequence of key codes matching &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt;, or just 3 separate keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like &lt;a href=&quot;https://github.com/vim/vim/issues/2216&quot; rel=&quot;nofollow noreferrer&quot;&gt;this other issue&lt;/a&gt; where a Terminal-Job mode mapping using &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; in its lhs breaks the arrow keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solutions to both these issues are identical:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;either remove the mapping with &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; in its lhs&lt;/li&gt;&#xA;&lt;li&gt;or make sure &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; can't be confused with the start of a sequence of key codes produced by a special key (like &lt;code&gt;&amp;lt;f1&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;A-b&amp;gt;&lt;/code&gt;...)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that Nvim does not seem to be affected by either of these.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Btw, here's an even simpler code example which suffers from the same issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nno &amp;lt;up&amp;gt;  :echom 'up'&amp;lt;cr&amp;gt;&#xA;nno &amp;lt;esc&amp;gt; :echom 'esc'&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first mapping works as expected by itself, but not anymore once you add the second mapping.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Bottom line: don't use &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; in the lhs of a mapping, or, if you have to, build your lhs so that &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; can never be parsed as the start of a sequence of key codes (on my machine, doubling &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; seems to achieve this goal).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Knowing that, here's how you could have debug the issue.  Start by running this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:new|pu=execute('nno')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should dump all your normal-mode mappings in a new buffer.  Now look for the pattern &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; in the lhs of a mapping, and you should find these lines (&lt;code&gt;:v/\c&amp;lt;esc&amp;gt;/d_&lt;/code&gt; may help reduce the noise):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n  &amp;lt;Plug&amp;gt;(submode-rhs:test:for:&amp;lt;Esc&amp;gt;) * &amp;lt;Nop&amp;gt;&#xA;n  &amp;lt;Plug&amp;gt;(submode-prefix:test)     &amp;lt;Esc&amp;gt;   &amp;lt;Plug&amp;gt;(submode-rhs:test:for:&amp;lt;Esc&amp;gt;)&amp;lt;Plug&amp;gt;(submode-leave:test)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then ask Vim from where these mappings were installed, with the &lt;code&gt;:verbose&lt;/code&gt; modifier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verb nno &amp;lt;Plug&amp;gt;(submode-rhs:test:for:&amp;lt;Esc&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The answer should contain something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Last set from /path/to/vim-submode/autoload/submode.vim line 247&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you then look for the line 247 inside the script, you should find:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute s:map_command(a:mode, s:filter_flags(a:options, 'r'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From there, you just have to walk back the function calls.&#xA;The line 247 is written inside the function &lt;code&gt;s:define_submode_mapping()&lt;/code&gt;, which is only called from &lt;code&gt;submode#map()&lt;/code&gt;, which itself is only called from &lt;code&gt;submode#leave_with()&lt;/code&gt;, which in turn is called from &lt;a href=&quot;https://github.com/kana/vim-submode/blob/d29de4f55c40a7a03af1d8134453a703d6affbd2/autoload/submode.vim#L197-L199&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;s:define_entering_mapping()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for keyseq in g:submode_keyseqs_to_leave&#xA;  call submode#leave_with(a:submode, a:mode, a:options, keyseq)&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here, you can see a global variable used to configure the plugin.  If you then look at its documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;*g:submode_keyseqs_to_leave*&#xA;g:submode_keyseqs_to_leave    list of strings (default: ['&amp;lt;Esc&amp;gt;'])&#xA;The default key sequences to leave a submode.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You should see the problematic &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; in the default value.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-04-01T00:27:09.410" LastActivityDate="2020-04-01T00:27:09.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24404" PostTypeId="2" ParentId="24381" CreationDate="2020-04-01T01:53:23.603" Score="0" Body="&lt;p&gt;Well, I can't figure out exactly what the problem is but the reason probably is YCM is not ready while loading Nerdtree. So I add a &lt;code&gt;if&lt;/code&gt; condition to check if YCM is ready.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline+=%#warningmsg#&#xA;function! YCMStatusLine() abort&#xA;    if exists(':YcmDiag')&#xA;        let l:errCounts = youcompleteme#GetErrorCount()&#xA;        let l:wrnCounts = youcompleteme#GetWarningCount()&#xA;&#xA;        return printf(&#xA;        \   '%dW %dE',&#xA;        \   wrnCounts,&#xA;        \   errCounts,&#xA;        \)&#xA;    endif&#xA;    return ''&#xA;endfunction&#xA;set statusline+=%{YCMStatusLine()}&#xA;set statusline+=%*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;:YcmDiag&lt;/code&gt; exists, it means that YCM has been loaded, if not, return an empty string.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-04-01T01:53:23.603" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24405" PostTypeId="2" ParentId="24392" CreationDate="2020-04-01T06:13:56.760" Score="1" Body="&lt;p&gt;There are basically, two forms of &lt;a href=&quot;https://vimhelp.org/options.txt.html#modeline&quot; rel=&quot;nofollow noreferrer&quot;&gt;modelines&lt;/a&gt;. Let me copy in the most important parts here together with an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; There are two forms of modelines.  The first form:&#xA;   [text{white}]{vi:vim:ex:}[white]{options}&#xA; [...]&#xA; Examples:&#xA;   vi:noai:sw=3 ts=6&#xA; [...]&#xA; The second form (this is compatible with some versions of Vi):&#xA;   [text{white}]{vi:vim:|Vim:ex:}[white]se[t] {options}:[text]&#xA; [...]&#xA; Examples:&#xA;   /* vim: set ai tw=75: */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since you have been using the &lt;code&gt;:set&lt;/code&gt; command, this means you are trying to create the latter form. There are two things to note here: First, you cannot use whitespace in the option value, otherwise Vim will parse those as separate options. The second is, you need to add a trailing &lt;code&gt;:&lt;/code&gt; to indicate where the modeline ends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means, in your case, the complete line with the modeline should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// vim: set path+=../include:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a simple tip, I use when creating a modeline. After reloading the file (&lt;code&gt;:e&lt;/code&gt;), you can check the value of the options from the modeline by using &lt;code&gt;:verbose set path?&lt;/code&gt;. Vim will output something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  path=.,,,../include&#xA;  Last set from modeline line 8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2020-04-01T07:31:43.940" LastActivityDate="2020-04-01T07:31:43.940" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24406" PostTypeId="1" CreationDate="2020-04-01T08:54:20.517" Score="0" ViewCount="116" Body="&lt;p&gt;I built a cpp environment with YCM, EasyGrep and some other plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With YCM, I can jump to declaration/definition, with EasyGrep, I can grep a keyword easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I found something weird:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Saying that I'm coding a c++ project, I put the cursor under &lt;code&gt;#include &amp;lt;iostream&amp;gt;&lt;/code&gt; and then type &lt;code&gt;YCMCompleter GoToDefinitionElseDeclaration&lt;/code&gt; to jump to the file &lt;code&gt;iostream&lt;/code&gt;. After that, I type &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; to jump back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if I use &lt;code&gt;EasyGrep&lt;/code&gt; to grep some keyword, such as &lt;code&gt;cout&lt;/code&gt;, the searching path will include the file &lt;code&gt;iostream&lt;/code&gt;. Obviously it is because I just jumped to that file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As my understanding, vim buffers all of files that are opened by me so that the searching path of &lt;code&gt;EasyGrep&lt;/code&gt; now includes the file &lt;code&gt;iostream&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some way, such as reloading the buffer of vim, to limit the searching path? &lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="18609" LastEditDate="2020-04-01T11:14:06.893" LastActivityDate="2020-04-01T11:14:06.893" Title="How to reload vim buffer" Tags="|search|buffers|plugin-you-complete-me|grep|plugin-easygrep|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24407" PostTypeId="2" ParentId="625" CreationDate="2020-04-01T12:25:37.250" Score="7" Body="&lt;p&gt;For NeoVim, you can setup your &lt;code&gt;~/.gitconfig&lt;/code&gt; with the following commands&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git config --global merge.tool nvim&#xA;git config --global mergetool.keepBackup false&#xA;git config --global mergetool.nvim.cmd $'nvim -d $LOCAL $REMOTE $MERGED -c \'$wincmd w\' -c \'wincmd J\''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your &lt;code&gt;~/.gitconfig&lt;/code&gt; should then look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[merge]&#xA;    tool = nvim&#xA;&#xA;[mergetool]&#xA;    keepBackup = false&#xA;&#xA;[mergetool &quot;nvim&quot;]&#xA;    cmd = nvim -d $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Refer to &lt;a href=&quot;https://neovim.io/doc/user/diff.html&quot; rel=&quot;noreferrer&quot;&gt;Nvim documentation: diff&lt;/a&gt; for more info on how to configure it to your liking.&lt;/p&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-04-01T12:25:37.250" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24408" PostTypeId="2" ParentId="19971" CreationDate="2020-04-01T12:31:51.210" Score="4" Body="&lt;pre&gt;&lt;code&gt;set completeopt+=noinsert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;noinsert&lt;/strong&gt; - do not insert any text for a match until the user selects a match from the menu. Only works in combination with &quot;menu&quot; or &quot;menuone&quot;. No effect if &quot;longest&quot; is present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more info:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h completeopt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="28694" LastActivityDate="2020-04-01T12:31:51.210" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24409" PostTypeId="1" CreationDate="2020-04-01T14:04:28.367" Score="1" ViewCount="57" Body="&lt;p&gt;I often find myself using the up arrow at the vim command prompt &lt;code&gt;:&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to 'favourite' some? Or at least an easy way to search through previous commands?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I couldn't remember how to prettify some json and had to google for the vim command (which, for me, is &lt;code&gt;:%!python -m json.tool&lt;/code&gt;); it would have been great if I could do something like &lt;code&gt;:fav-pj&lt;/code&gt; or &lt;code&gt;Ctrl+f+p&lt;/code&gt; or similar.&lt;/p&gt;&#xA;" OwnerUserId="26637" LastEditorUserId="10604" LastEditDate="2020-04-01T14:25:35.913" LastActivityDate="2020-04-01T14:25:35.913" Title="Save &amp; recall favourite vim :commands" Tags="|key-bindings|repeated-commands|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24410" PostTypeId="1" CreationDate="2020-04-01T14:31:37.470" Score="6" ViewCount="1273" Body="&lt;p&gt;I'm using vim as note-taking software.   My notes grow to thousands of lines across 7 different files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I was writing code, I would be able to jump to a function definition in a different file with a vim plugin.   Or if I open a list of compile errors or grep matches in vim, I could jump to a line in a different file with just two keypresses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that I want to jump to one note file from another.   This will probably involve tagging the location i wish to jump to.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully you know what I'm asking now.  I can't type in a reference to a second file, (other than using the exact line number file:999 ), but I still need a way to type in references in the files, since I want to organize the same tasks across different note-files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?  Would writing in markdown help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://superuser.com/questions/290082/how-can-i-configure-custom-vim-tags-for-my-text-file-notes&quot;&gt;https://superuser.com/questions/290082/how-can-i-configure-custom-vim-tags-for-my-text-file-notes&lt;/a&gt; offers a solution by binding a key to vimgrep&lt;/p&gt;&#xA;" OwnerUserId="28695" LastEditorUserId="4472" LastEditDate="2020-04-02T21:26:15.250" LastActivityDate="2020-05-22T14:54:16.833" Title="How do I jump to tags instead of lines?" Tags="|tags|plugin-vimwiki|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24411" PostTypeId="1" CreationDate="2020-04-01T14:30:35.413" Score="1" ViewCount="25" Body="&lt;p&gt;I'm using vim as note-taking software.   My notes grow to thousands of lines across 7 different files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I was writing code, I would be able to jump to a function definition in a different file with a vim plugin.   Or if I open a list of compile errors or grep matches in vim, I could jump to a line in a different file with just two keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that I want to jump to one note file from another.   This will probably involve tagging the location i wish to jump to.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully you know what I'm asking now.  I can't type in a reference to a second file, (other than using the exact line number file:999 ), but I still need a way to type in references in the files, since I want to organize the same tasks across different note-files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?  Would writing in markdown help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://superuser.com/questions/290082/how-can-i-configure-custom-vim-tags-for-my-text-file-notes&quot;&gt;How can I configure custom vim tags for my text file notes?&lt;/a&gt; offers a solution by binding a key to vimgrep.&lt;/p&gt;&#xA;" OwnerUserId="28695" OwnerDisplayName="marinara" LastEditorUserId="10604" LastEditDate="2020-05-22T14:47:01.813" LastActivityDate="2020-05-22T14:47:01.813" Title="Jumping to tags instead of lines in a text-file opened by vim" Tags="|tags|" AnswerCount="0" CommentCount="1" ClosedDate="2020-04-01T15:12:38.473" ContentLicense="CC BY-SA 4.0" />
  <row Id="24413" PostTypeId="2" ParentId="24410" CreationDate="2020-04-01T21:26:58.113" Score="5" Body="&lt;p&gt;There are probably better ways but you could the help functionality as long as the filetype being help is ok. I basically use it to write down things I'm learning as I keep learning how to use gvim, it's only been 20 years :). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment I have one file that I edit elsewhere then copy to where the help file is as an archive. It's hit 1600 lines so I'll start breaking it up into separate files, ie a index and section by section. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the bottom or top of each document you need something like&#xA;&lt;code&gt;vim:tw=88:ts=4:sw=4:ft=help:norl:foldmethod=indent:foldclose=all:modifiable:noreadonly:conceallevel=3&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The important bits&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;vim&lt;/code&gt; - Thanks to @D. Benknoble it sets the file up to load vim related flags, poor summary :(&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;tw=88&lt;/code&gt; - Sets the text width. I use a big screen&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ts=4&lt;/code&gt; - Sets tab spaces to 4&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ft=help&lt;/code&gt; - &lt;strong&gt;Important&lt;/strong&gt; Sets the filetype to text&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;noreadonly&lt;/code&gt; - Probably dangerous as it allows edits&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;foldmethod=indent&lt;/code&gt; - I use indenting to separate the top level headings and the detail heading, dunno the vim word for headings :)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then you define a help topic as follows&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;|sf-search-flags|&lt;/code&gt; - &lt;code&gt;|&lt;/code&gt; sets the tag and allows jumping between tags using &lt;code&gt;CTRL-]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the sub topics as so &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;*sf-search-flags*&lt;/code&gt; - Where &lt;code&gt;CTRL-]&lt;/code&gt; takes you. You can go to the previous tag using &lt;code&gt;CTRL-o&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like this &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2tWi9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2tWi9.png&quot; alt=&quot;Help Topic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Ctrl-]&lt;/code&gt; on &lt;code&gt;sf-search-flags&lt;/code&gt; takes you to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sUwqA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sUwqA.png&quot; alt=&quot;The note&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The colours are syntax formatting I'm playing with to make things stand out with out bold etc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After you save the file you need to use&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:helptags {dir}&lt;/code&gt; (&lt;code&gt;dir&lt;/code&gt;) is Optional if you are in the directory) to build the help file tags&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;See&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;h :help&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;h :helptags&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help modeline&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Fixed an error and added a better screenshot&lt;/p&gt;&#xA;" OwnerUserId="1313" LastEditorUserId="1313" LastEditDate="2020-04-01T22:05:04.037" LastActivityDate="2020-04-01T22:05:04.037" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24414" PostTypeId="1" AcceptedAnswerId="24416" CreationDate="2020-04-02T03:56:12.637" Score="1" ViewCount="509" Body="&lt;p&gt;I'm trying to write a vim-script function, which allows me to &lt;code&gt;grep&lt;/code&gt; the word under cursor easily in my project.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomGrep()&#xA;    vimgrep expand(&quot;&amp;lt;cword&amp;gt;&quot;) **/*.h **/*.hpp **/*.c **/*.cpp&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I executed &lt;code&gt;:call CustomGrep()&lt;/code&gt; in my vim, I got an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E480: No match: expand(&quot;&amp;lt;cword&amp;gt;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Did I do something wrong here?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-04-02T07:01:13.760" Title="vimscript: No match error" Tags="|vimscript|vimgrep|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24415" PostTypeId="2" ParentId="24414" CreationDate="2020-04-02T05:09:42.660" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Did I do something wrong here?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:vimgrep&lt;/code&gt; is a command which takes a string. &lt;code&gt;expand()&lt;/code&gt; is a function call. You must use &lt;code&gt;execute&lt;/code&gt; then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'vimgrep' expand('&amp;lt;cword&amp;gt;') '**/*.h ...'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-04-02T05:09:42.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24416" PostTypeId="2" ParentId="24414" CreationDate="2020-04-02T06:35:06.173" Score="2" Body="&lt;p&gt;You can just use &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt; directly here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomGrep()&#xA;    vimgrep &amp;lt;cword&amp;gt; **/*.h **/*.hpp **/*.c **/*.cpp&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you look up &lt;code&gt;:help &amp;lt;cword&amp;gt;&lt;/code&gt; you'll see it's on a section about &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html?#cmdline-special&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Ex special characters&quot;&lt;/a&gt;, which also cover special characters you might be familiar with, such as &lt;code&gt;%&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; (as in, &lt;code&gt;:e #&lt;/code&gt;, to edit the alternate buffer.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That section also mentions (a little above &lt;code&gt;&amp;lt;cword&amp;gt;&lt;/code&gt;) that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;These can also be used in the expression&#xA;  function &lt;code&gt;expand()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In other words, they're primarily meant to be used &lt;em&gt;directly&lt;/em&gt; in Ex commands, and only available through &lt;code&gt;expand()&lt;/code&gt; for the cases where you actually need them as a string.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-02T07:01:13.760" LastActivityDate="2020-04-02T07:01:13.760" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24417" PostTypeId="1" AcceptedAnswerId="24418" CreationDate="2020-04-02T13:38:15.267" Score="3" ViewCount="434" Body="&lt;p&gt;To turn on syntax we normally use: &lt;code&gt;:syntax on&lt;/code&gt; and to turn it off we do: &lt;code&gt;:syntax off&lt;/code&gt;. I would like to define a single key, maybe using &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; to toggle syntax. My problem is how to get the current syntax state, so I can use it in a ternary operator.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;Leader&amp;gt;s SyntaxState() ? &quot;:syntax off&quot; : &quot;:syntax on&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastEditorUserId="51" LastEditDate="2021-01-27T03:06:46.350" LastActivityDate="2021-01-27T03:06:46.350" Title="How to toggle syntax with a single key" Tags="|key-bindings|normal-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24418" PostTypeId="2" ParentId="24417" CreationDate="2020-04-02T13:47:32.267" Score="4" Body="&lt;p&gt;You actually want &lt;code&gt;syntax enable&lt;/code&gt; (for good reasons which I’ll leave to the &lt;code&gt;:help&lt;/code&gt; to explain).&lt;/p&gt;&#xA;&lt;p&gt;I created this custom command to toggle syntax; you could adjust the mapping similarly:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;command SynToggle&#xA;      \ if exists(&amp;quot;g:syntax_on&amp;quot;) |&#xA;      \   syntax off |&#xA;      \ else |&#xA;      \   syntax enable |&#xA;      \ endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This leaves you with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; &amp;lt;leader&amp;gt;s exists('g:syntax_on') ? ':syntax off&amp;lt;CR&amp;gt;' : ':syntax enable&amp;lt;CR&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-08-20T13:29:10.973" LastActivityDate="2020-08-20T13:29:10.973" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24419" PostTypeId="1" CreationDate="2020-04-02T14:01:53.413" Score="1" ViewCount="729" Body="&lt;p&gt;I have a big monitor and sometimes it can be difficult to locate the small blinking underscore that is the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to temporarily make the cursor more prominent and visible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, I am using just plain virtual consoles, so there is no windowing system or GUI or anything like that.&lt;/p&gt;&#xA;" OwnerUserId="6952" LastEditorUserId="6952" LastEditDate="2020-04-02T14:24:22.520" LastActivityDate="2020-04-02T22:51:30.363" Title="Locate cursor on the screen" Tags="|cursor|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24420" PostTypeId="2" ParentId="24419" CreationDate="2020-04-02T14:54:25.263" Score="2" Body="&lt;p&gt;Damian Conway wrote some functions to help him find his cursor when jumping around with &lt;code&gt;n&lt;/code&gt;. I'm sure they could be adapted for your use case (i.e., instead of the right-hand side being &lt;code&gt;n:call ...&lt;/code&gt;, just do the &lt;code&gt;call&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; This rewires n and N to do the highlighing...&#xA;nnoremap &amp;lt;silent&amp;gt; n   n:call HLNext(0.4)&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; N   N:call HLNext(0.4)&amp;lt;cr&amp;gt;&#xA;&#xA;&quot; EITHER blink the line containing the match...&#xA;function! HLNext (blinktime)&#xA;    set invcursorline&#xA;    redraw&#xA;    exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'&#xA;    set invcursorline&#xA;    redraw&#xA;endfunction&#xA;&#xA;&quot; OR ELSE ring the match in red...&#xA;function! HLNext (blinktime)&#xA;    highlight RedOnRed ctermfg=red ctermbg=red&#xA;    let [bufnum, lnum, col, off] = getpos('.')&#xA;    let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))&#xA;    echo matchlen&#xA;    let ring_pat = (lnum &amp;gt; 1 ? '\%'.(lnum-1).'l\%&amp;gt;'.max([col-4,1]) .'v\%&amp;lt;'.(col+matchlen+3).'v.\|' : '')&#xA;            \ . '\%'.lnum.'l\%&amp;gt;'.max([col-4,1]) .'v\%&amp;lt;'.col.'v.'&#xA;            \ . '\|'&#xA;            \ . '\%'.lnum.'l\%&amp;gt;'.max([col+matchlen-1,1]) .'v\%&amp;lt;'.(col+matchlen+3).'v.'&#xA;            \ . '\|'&#xA;            \ . '\%'.(lnum+1).'l\%&amp;gt;'.max([col-4,1]) .'v\%&amp;lt;'.(col+matchlen+3).'v.'&#xA;    let ring = matchadd('RedOnRed', ring_pat, 101)&#xA;    redraw&#xA;    exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'&#xA;    call matchdelete(ring)&#xA;    redraw&#xA;endfunction&#xA;&#xA;&quot; OR ELSE briefly hide everything except the match...&#xA;function! HLNext (blinktime)&#xA;    highlight BlackOnBlack ctermfg=black ctermbg=black&#xA;    let [bufnum, lnum, col, off] = getpos('.')&#xA;    let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))&#xA;    let hide_pat = '\%&amp;lt;'.lnum.'l.'&#xA;            \ . '\|'&#xA;            \ . '\%'.lnum.'l\%&amp;lt;'.col.'v.'&#xA;            \ . '\|'&#xA;            \ . '\%'.lnum.'l\%&amp;gt;'.(col+matchlen-1).'v.'&#xA;            \ . '\|'&#xA;            \ . '\%&amp;gt;'.lnum.'l.'&#xA;    let ring = matchadd('BlackOnBlack', hide_pat, 101)&#xA;    redraw&#xA;    exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'&#xA;    call matchdelete(ring)&#xA;    redraw&#xA;endfunction&#xA;&#xA;&quot; OR ELSE just highlight the match in red...&#xA;function! HLNext (blinktime)&#xA;    let [bufnum, lnum, col, off] = getpos('.')&#xA;    let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))&#xA;    let target_pat = '\c\%#\%('.@/.'\)'&#xA;    let ring = matchadd('WhiteOnRed', target_pat, 101)&#xA;    redraw&#xA;    exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'&#xA;    call matchdelete(ring)&#xA;    redraw&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Video: &lt;a href=&quot;https://www.youtube.com/watch?v=aHm36-na4-4&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=aHm36-na4-4&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Code: &lt;a href=&quot;https://is.gd/IBV2013&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://is.gd/IBV2013&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-02T14:54:25.263" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="24421" PostTypeId="2" ParentId="14493" CreationDate="2020-04-02T15:28:10.897" Score="2" Body="&lt;p&gt;I'm late but here is my current solution based on @mike's work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap cri mmva[&amp;lt;bar&amp;gt;:s/\v:(\w+),?/\1/g&amp;lt;bar&amp;gt;s/\v(\[([^\]])*\])/%i\1/g&amp;lt;bar&amp;gt;:nohlsearch&amp;lt;bar&amp;gt;:normal `m&amp;lt;Return&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Short breakdown:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap cri&lt;/code&gt; maps &lt;code&gt;cri&lt;/code&gt; in normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;mm&lt;/code&gt; marks the current position&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;va[&lt;/code&gt; select the array around the cursor position&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; pipes another command&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:s/\v:(\w+),?/\1/g&amp;lt;bar&amp;gt;s/\v(\[([^\]])*\])/%i\1/g&lt;/code&gt; the substution in two steps&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:nohlsearch&lt;/code&gt; highlight off&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;normal 'm&lt;/code&gt; back to the marked position&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And if you try to do the same thing for arrays of strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap crw mmva[&amp;lt;bar&amp;gt;:s/\v([&quot;'])(\w+)\1,?/\2/g&amp;lt;bar&amp;gt;s/\v(\[([^\]])*\])/%w\1/g&amp;lt;bar&amp;gt;:nohlsearch&amp;lt;bar&amp;gt;:normal `m&amp;lt;Return&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="28715" LastActivityDate="2020-04-02T15:28:10.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24422" PostTypeId="1" CreationDate="2020-04-02T16:25:03.393" Score="1" ViewCount="108" Body="&lt;p&gt;My current keybinding for compiling cpp files is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd filetype cpp nnoremap &amp;lt;F2&amp;gt; :!g++ -g %&amp;lt;CR&amp;gt;:!./a.out&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press &lt;kbd&gt;F2&lt;/kbd&gt;, vim escapes to the shell and a.out executes well uptil taking input. But, it does not wait for output and returns back to the editor. This never happened earlier when I typed the command manually, vim used to wait for me to read the output and then I got a line saying: &quot;Press ENTER or type command to continue.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[Update]&#xA;I changed the command to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd filetype cpp nnoremap &amp;lt;F2&amp;gt; :!g++ -g %&amp;lt;CR&amp;gt;:!./a.out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when I press &lt;kbd&gt;F2&lt;/kbd&gt;, it finally writes &lt;code&gt;:!./a.out&lt;/code&gt; below and I manually press &lt;kbd&gt;Enter&lt;/kbd&gt;. This time it actually waits for me in the terminal. Why is this happening? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try reproducing by using both the keybindings this one and the former.&lt;/p&gt;&#xA;" OwnerUserId="25620" LastEditorUserId="25620" LastEditDate="2020-04-02T20:23:22.720" LastActivityDate="2020-04-28T17:04:42.900" Title="Cannot read output of ./a.out" Tags="|terminal|compile-vim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24423" PostTypeId="1" CreationDate="2020-04-02T18:51:20.397" Score="2" ViewCount="1260" Body="&lt;p&gt;I use vim 8 and ALE plugin. On a markdown page, I see the following from &lt;code&gt;ALEInfo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Current Filetype: markdown&#xA;Available Linters: ['alex', 'languagetool', 'markdownlint', 'mdl', 'proselint', 'redpen', 'remark_lint', 'textlint', 'vale', 'writegood']&#xA;   Linter Aliases:&#xA;'remark_lint' -&amp;gt; ['remark-lint']&#xA;'writegood' -&amp;gt; ['write-good']&#xA;  Enabled Linters: ['alex', 'languagetool', 'markdownlint', 'mdl', 'proselint', 'redpen', 'remark_lint', 'textlint', 'vale', 'writegood']&#xA; Suggested Fixers:&#xA;  'prettier' - Apply prettier to a file.&#xA;  'remove_trailing_lines' - Remove all blank lines at the end of a file.&#xA;  'textlint' - Fix text files with textlint --fix&#xA;  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My markdown file has certain lines that have trailing whitespace - they're legitimate as a  way to prevent markdown rendering from collapsing the newlines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I disable the warnings about trailing whitespace on these lines?&lt;/p&gt;&#xA;" OwnerUserId="7596" LastActivityDate="2022-03-06T23:15:52.153" Title="Disable trailing whitespace lint warnings for Markdown file" Tags="|filetype-markdown|plugin-ale|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24424" PostTypeId="1" CreationDate="2020-04-02T18:57:32.203" Score="4" ViewCount="939" Body="&lt;p&gt;I uninstalled vim 8.1 which is the available version through my package manager and installed 8.2 from source. But Backspace and Delete buttons behave in a different way in this version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are in insert mode and press Backspace then it does not delete or move indentation to the left. Delete button in insert mode deletes up to the end of the current line and does not continue to the next one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why these changes in behavior and how do I revert to the previous one?&lt;/p&gt;&#xA;" OwnerUserId="28718" LastActivityDate="2020-04-02T19:28:43.147" Title="VIM 8.2 Backspace Delete behavior" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ClosedDate="2020-04-03T03:42:50.677" ContentLicense="CC BY-SA 4.0" />
  <row Id="24425" PostTypeId="2" ParentId="24424" CreationDate="2020-04-02T19:28:43.147" Score="1" Body="&lt;p&gt;I looked at the docs. You need to set:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;set backspace=indent,eol,start&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My previous installation was vim-gtk. I suppose this package has this value set as default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now both backspace and delete work as before.&lt;/p&gt;&#xA;" OwnerUserId="28718" LastActivityDate="2020-04-02T19:28:43.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24426" PostTypeId="1" CreationDate="2020-04-02T21:09:10.823" Score="1" ViewCount="103" Body="&lt;p&gt;I use Vim to write Latex code and I would like to have autoindent when adding environments.&#xA;I am aware of the smartindent capabilities that can be toggle on and off by inspecting the &lt;code&gt;$VIMRUNTIME/indent/tex/tex.vim&lt;/code&gt; file.&#xA;When I type &#xA;&lt;code&gt;\section{...}&lt;/code&gt; and hit enter, I would like the cursor to be automatically indented:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\section{First section}&#xA;    This is a new section.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, I would like to avoid using plugins if possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a built-in way to do so?&lt;/p&gt;&#xA;" OwnerUserId="26917" LastActivityDate="2020-04-02T21:09:10.823" Title="Autoindentation in .tex files" Tags="|indentation|filetype-tex|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24427" PostTypeId="1" AcceptedAnswerId="24428" CreationDate="2020-04-02T21:31:08.353" Score="0" ViewCount="61" Body="&lt;ul&gt;&#xA;&lt;li&gt;You can go forward, to the beginning of next word, with &lt;code&gt;w&lt;/code&gt;/&lt;code&gt;W&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You can go forward, to the end of the word, with &lt;code&gt;e&lt;/code&gt;/&lt;code&gt;E&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;You can go backward, to the beginning of the word whit &lt;code&gt;b&lt;/code&gt;/&lt;code&gt;B&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;How do you go backward, to the end of the previous word ?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;... except for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map &amp;lt;F1&amp;gt; bbe&#xA;:map &amp;lt;S-F1&amp;gt; BBE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="28719" LastActivityDate="2020-04-02T21:58:27.633" Title="Is there a backward equivalent to w?" Tags="|navigation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24428" PostTypeId="2" ParentId="24427" CreationDate="2020-04-02T21:58:27.633" Score="2" Body="&lt;p&gt;There's probably a duplicate of this, but the commands are &lt;code&gt;ge&lt;/code&gt; and &lt;code&gt;gE&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-02T21:58:27.633" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24429" PostTypeId="2" ParentId="24419" CreationDate="2020-04-02T22:51:30.363" Score="4" Body="&lt;p&gt;You can set the &lt;code&gt;cursorcolumn&lt;/code&gt; and/or the &lt;code&gt;cursorline&lt;/code&gt; to highlight the line and/or column the cursor is on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set cursorcolumn cursorline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By adding a &lt;code&gt;!&lt;/code&gt; to the end of the option you can toggle the value, which is useful especially if you want to map this to a key, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;F2&amp;gt;      :set cursorcolumn! cursorline!&amp;lt;CR&amp;gt;&#xA;:inoremap &amp;lt;F2&amp;gt; &amp;lt;C-o&amp;gt;:set cursorcolumn! cursorline!&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can configure the appearance with the &lt;code&gt;CursorColumn&lt;/code&gt; and &lt;code&gt;CursorLine&lt;/code&gt; highlight groups.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2020-04-02T22:51:30.363" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24430" PostTypeId="2" ParentId="24410" CreationDate="2020-04-03T03:08:05.490" Score="3" Body="&lt;p&gt;I think with vim-wiki you can set anchors (from the help):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Anchors~&#xA;&#xA;A wikilink, interwiki link or diary link can be followed by a '#' and the name&#xA;of an anchor.  When opening a link, the cursor jumps to the anchor. &amp;gt;&#xA;  [[Todo List#Tomorrow|Tasks for tomorrow]]&#xA;&#xA;To jump inside the current wiki file you can omit the file: &amp;gt;&#xA;  [[#Tomorrow]]&#xA;&#xA;See |vimwiki-anchors| for how to set an anchor.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-03T03:08:05.490" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24431" PostTypeId="1" AcceptedAnswerId="24441" CreationDate="2020-04-03T03:45:59.347" Score="1" ViewCount="216" Body="&lt;p&gt;I wrote a vim-script function, which allows me to grep a keyword in my project.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomGrep(...)&#xA;    if a:0 == 0&#xA;        silent vimgrep &amp;lt;cword&amp;gt; **/*.h **/*.hpp **/*.c **/*.cpp&#xA;    else&#xA;        silent execute 'vimgrep' a:1 '**/*.h **/*.hpp **/*.c **/*.cpp'&#xA;    endif&#xA;    &quot;cope&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to write another function, which can replace a keyword:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomReplace(target, newWord)&#xA;    call CustomGrep(a:target)&#xA;    &quot; loop --- how to loop?&#xA;    execute 's/'.a:target.'/'.a:newWord.'/gc'&#xA;    cnext&#xA;    &quot; end loop&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, I need a loop in the function, which looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let cnt = CustomGrep(a:target)&#xA;for from 1 to cnt&#xA;execute 's/'.a:target.'/'.a:newWord.'/gc'&#xA;cnext&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I don't know how to get the number of the output of &lt;code&gt;vimgrep&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I know there have been some plugins, such as &lt;code&gt;EasyGrep&lt;/code&gt;, but I still want to make a new one.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-04-03T14:59:47.643" Title="How to get the number of the output of `vimgrep`" Tags="|vimscript|vimgrep|grep|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24432" PostTypeId="1" AcceptedAnswerId="24433" CreationDate="2020-04-03T07:04:20.657" Score="7" ViewCount="1705" Body="&lt;p&gt;I use &lt;code&gt;:%s/'/&amp;quot;/g&lt;/code&gt;&#xA;to replace all single quotes &lt;code&gt;'&lt;/code&gt; with double quotes &lt;code&gt;&amp;quot;&lt;/code&gt; in a plain-text file&lt;/p&gt;&#xA;&lt;p&gt;but when I want to put this command in a vim macro in .vimrc&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;let @r=':%s/'/&amp;quot;/g'&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;opening vim will give me this error&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;E114: Missing quote: &amp;quot;/g'&lt;/p&gt;&#xA;&lt;p&gt;E15: Invalid expression: ':%s/'/&amp;quot;/g'&lt;/p&gt;&#xA;&lt;p&gt;Press ENTER or type command to continue&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I've tried not including the surrounding single-quotes&#xA;&lt;code&gt;let @r=:%s/'/&amp;quot;/g&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;it still gives me a similar error.&lt;/p&gt;&#xA;&lt;p&gt;how do I include commands with single-quotes in a vim macro?&lt;/p&gt;&#xA;" OwnerUserId="27295" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-04-03T07:18:22.430" Title="How to put quotation marks (') in the content of a vim macro?" Tags="|vimrc|macro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24433" PostTypeId="2" ParentId="24432" CreationDate="2020-04-03T07:18:22.430" Score="9" Body="&lt;p&gt;you add another single quote to escape your single quote inside your vim macro&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let @r=':%s/''/&amp;quot;/g'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;from &lt;a href=&quot;https://vim.fandom.com/wiki/Macros&quot; rel=&quot;noreferrer&quot;&gt;https://vim.fandom.com/wiki/Macros&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;if your register must itself contain single quote characters, you use&#xA;a second single-quote character to escape it.&lt;/p&gt;&#xA;&lt;p&gt;For example, if you want&#xA;your register to contain &amp;quot;Vim's quote handling is a little tricky&amp;quot; you&#xA;would type :let @a='&amp;quot;Vim''s quote handling is a little tricky&amp;quot;'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="28729" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-04-03T07:18:22.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24434" PostTypeId="2" ParentId="24431" CreationDate="2020-04-03T07:32:24.517" Score="1" Body="&lt;p&gt;With the help of @ChristianBrabandt, I finished this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomReplace(target, newWord)&#xA;    call CustomGrep(a:target)&#xA;    let x = 0&#xA;    let cnt = len(getqflist())&#xA;    while x &amp;lt; cnt&#xA;        execute 's/'.a:target.'/'.a:newWord.'/gc'&#xA;        w&#xA;        if x != cnt - 1&#xA;            cnext&#xA;        endif&#xA;        let x = x + 1&#xA;    endwhile&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;getqflist()&lt;/code&gt; to get the number to control the loop, that's it.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-04-03T07:32:24.517" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24435" PostTypeId="1" AcceptedAnswerId="24436" CreationDate="2020-04-03T10:33:16.707" Score="0" ViewCount="29" Body="&lt;p&gt;I have a bunch of csv files which look sort of like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;date,receiver,client,article_id,amount&#xA;5-12-2019,thomas,thomas,2,23&#xA;5-12-2019,joe,joe,2,14&#xA;6-12-2019,tobias,bob,4,1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;now I would like to search for every line where receiver and client are identical.&#xA;Can this be done with a regex search?&lt;/p&gt;&#xA;" OwnerUserId="23073" LastActivityDate="2020-04-03T13:45:56.783" Title="delete every line which has double entries with a regex" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24436" PostTypeId="2" ParentId="24435" CreationDate="2020-04-03T10:50:34.347" Score="4" Body="&lt;p&gt;So you want to skip the first column (comma delimited) and search for everything, where the second column is the same as the third column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a regex this can be written like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[^,]*,\zs\([^,]*\),\1&#xA;|  |  |  | |  |   || └ Same match as what was captured&#xA;|  |  |  | |  |   |└   Comma &#xA;|  |  |  | |  |   └    End of captured group&#xA;|  |  |  | |  └        Any number of non-commas&#xA;|  |  |  | └           Capture the following&#xA;|  |  |  └             Start the match here&#xA;|  |  └                A comma&#xA;|  └                   Any number of non-commas&#xA;└                      Start of line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;:set hls&lt;/code&gt; to have a visual indication of what lines match the pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you want to delete those matching lines, you can simply use a &lt;code&gt;:g&lt;/code&gt; command, which basically means, do for all lines that match a certain pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g/^[^,]*,\zs\([^,]*\),\1/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, if you already have the pattern in the search register (e.g. all matching lines are already colored), you can even simplify this call to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:g//d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means, delete all the lines that match the last entered search pattern.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="10604" LastEditDate="2020-04-03T13:45:56.783" LastActivityDate="2020-04-03T13:45:56.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24438" PostTypeId="2" ParentId="23220" CreationDate="2020-04-03T12:31:14.420" Score="2" Body="&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Lexplore&lt;/code&gt; bug mentioned below is &lt;a href=&quot;https://github.com/vim/vim/blob/a853089479b60b829bab1c4a0a737a073415f8a7/runtime/autoload/netrw.vim#L1275&quot; rel=&quot;nofollow noreferrer&quot;&gt;fixed&lt;/a&gt; (also see &lt;a href=&quot;https://github.com/vim/vim/issues/1016#issuecomment-640274307&quot; rel=&quot;nofollow noreferrer&quot;&gt;the github comment&lt;/a&gt;), so you can now use a single mapping to toggle the netrw window:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Tab&amp;gt; :Lexplore&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, see the comment in the code, repeated invoking of &lt;code&gt;Lexplore&lt;/code&gt; is not the intended use.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Original answer:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There is a &lt;code&gt;Lexplore&lt;/code&gt; command to toggle a netrw window on the left-hand side. However, &lt;a href=&quot;https://github.com/vim/vim/issues/1016&quot; rel=&quot;nofollow noreferrer&quot;&gt;there is a bug&lt;/a&gt; that executing it multiple times will generate a lot of empty buffers.&lt;/p&gt;&#xA;&lt;p&gt;For now, I think stimulate's answer is quite good. I created my single-function version based on that answer (I am not a vim expert, so not sure if this is better):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;Tab&amp;gt; :call ToggleNetRW()&amp;lt;CR&amp;gt;&#xA;function ToggleNetRW()&#xA;    if exists(&amp;quot;g:netrw_buffer&amp;quot;) &amp;amp;&amp;amp; bufexists(g:netrw_buffer)&#xA;        exe &amp;quot;bd&amp;quot;.g:netrw_buffer | unlet g:netrw_buffer&#xA;    else&#xA;        Vexplore | let g:netrw_buffer=bufnr(&amp;quot;%&amp;quot;)&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="28732" LastEditorUserId="22375" LastEditDate="2021-02-09T18:41:36.870" LastActivityDate="2021-02-09T18:41:36.870" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24439" PostTypeId="1" AcceptedAnswerId="24440" CreationDate="2020-04-03T14:21:19.323" Score="0" ViewCount="59" Body="&lt;h1&gt;Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;How can I read a file into the current buffer and do some template substitution on it automatically?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Background&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I'm working on a simple bash-driven logging / journaling capability. &lt;a href=&quot;https://github.com/jodavaho/bashlog&quot; rel=&quot;nofollow noreferrer&quot;&gt;(on github, fyi)&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a file that contains a templated todo item called &lt;code&gt;daily.tmpl&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- [ ] Check this weeks todo: 2020-$WW.md&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to be able to read that into my daily todo, and substitute &lt;code&gt;$WW&lt;/code&gt; with the week. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can capture the week number using &lt;code&gt;date +%W&lt;/code&gt;. Or in vim: &lt;code&gt;:let weeknumber=date +%W&lt;/code&gt; (with appropriate escaping omitted for clarity).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can read the templated file to the top using &lt;code&gt;:read daily.tmpl&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I have created a bash alias that can open a daily todo item with a file name by date as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias todo=vim -c 'read daily.tmpl' `date`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Option 1&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;What command can I execute to substitute, after read, &lt;code&gt;$WW&lt;/code&gt; for the local vim variable &lt;code&gt;weeknumber&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Option 2&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Is there another, better way to do this?&lt;/p&gt;&#xA;" OwnerUserId="28735" LastActivityDate="2020-04-03T17:37:05.000" Title="How can I read a file and do template substitution?" Tags="|substitute|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24440" PostTypeId="2" ParentId="24439" CreationDate="2020-04-03T14:54:08.990" Score="2" Body="&lt;p&gt;First, &lt;code&gt;let weeknumber=date +%W&lt;/code&gt; won't work at all. You want something like &lt;code&gt;let weeknumber=strftime(&quot;%W&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, the command for the substitution would be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/$WW/substitute//\=weeknumber/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But simpler is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:/$WW/substitute//\=strftime(&quot;%W&quot;)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there  a better way&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could put the vimscript into a file (e.g., &lt;code&gt;todo.vim&lt;/code&gt;) and run &lt;code&gt;vim -S todo.vim filename...&lt;/code&gt;. Taking this further, you could use a here-document if your shell supports it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vim filename -S &amp;lt;(cat &amp;lt;&amp;lt;DOG&#xA;/$WW/substitute//\=strftime(&quot;%W&quot;)/&#xA;DOG&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help -S&lt;/code&gt;, &lt;code&gt;:help :substitute&lt;/code&gt;, &lt;code&gt;:help range&lt;/code&gt;, and &lt;code&gt;:help s/\=&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-04-03T17:37:05.000" LastActivityDate="2020-04-03T17:37:05.000" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24441" PostTypeId="2" ParentId="24431" CreationDate="2020-04-03T14:59:47.643" Score="2" Body="&lt;p&gt;Simpler is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomReplace(target, newWord)&#xA;  call CustomGrep(a:target)&#xA;  cdo execute 's/'.a:target.'/'.a:newWord.'/gc'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or with &lt;code&gt;cfdo&lt;/code&gt; and &lt;code&gt;%s&lt;/code&gt;, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomReplace(target, newWord)&#xA;  call CustomGrep(a:target)&#xA;  cfdo execute '%s/'.a:target.'/'.a:newWord.'/gc'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-03T14:59:47.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24442" PostTypeId="1" CreationDate="2020-04-03T18:15:06.253" Score="4" ViewCount="1197" Body="&lt;p&gt;When I search a text file for a word from within Vim, it will highlight all matches for the word by changing their background color -- to olive green on my terminal; your color may vary. I am looking for a way to highlight the background color behind the current cursor position in this way. (This would make the cursor easier for me to see than it is by default.)&lt;/p&gt;&#xA;&lt;p&gt;By reading the Vim documentation and searching the web, I found &lt;em&gt;plenty&lt;/em&gt; of information on highlighting the &lt;em&gt;line&lt;/em&gt; the cursor is currently on. But that is &lt;em&gt;not&lt;/em&gt; what I'm looking for right now. I am &lt;em&gt;specifically&lt;/em&gt; looking for a way to highlight the &lt;em&gt;character&lt;/em&gt; at the current cursor position, &lt;em&gt;specifically&lt;/em&gt; by changing its background color in the way Vim already does with matches to text searches&lt;/p&gt;&#xA;&lt;p&gt;How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="28738" LastEditorUserId="23502" LastEditDate="2023-08-22T19:18:20.303" LastActivityDate="2023-08-22T19:25:36.177" Title="How can I highlight the current cursor position (not just the line)?" Tags="|highlight|cursor|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24443" PostTypeId="1" AcceptedAnswerId="24450" CreationDate="2020-04-03T19:49:14.793" Score="12" ViewCount="1794" Body="&lt;p&gt;I am very fond of Vim's &lt;code&gt;:terminal&lt;/code&gt;, though whenever I use &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;w&lt;/kbd&gt; (expecting to erase the last typed word at prompt), Vim captures the key press and enters pane navigation mode. So I end up having to &lt;kbd&gt;esc&lt;/kbd&gt; and then perform multiple backspaces. This wastes precious milliseconds of life. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;Backspace&lt;/kbd&gt; (default behavior in many GUIs) and also nothing. What could be a workaround?&lt;/p&gt;&#xA;" OwnerUserId="25873" LastEditorUserId="25873" LastEditDate="2020-04-10T18:25:19.470" LastActivityDate="2023-07-10T14:49:51.380" Title="Ctrl-W at :terminal (default terminal behavior expected)" Tags="|key-bindings|terminal|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24444" PostTypeId="2" ParentId="24442" CreationDate="2020-04-03T19:52:03.407" Score="1" Body="&lt;p&gt;You can turn on search match highlights like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set hlsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To turn it off until the next time you search, use this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To change highlight to a specific color:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:hi Cursor guibg=#rrggbb&#xA;or&#xA;:hi Search guibg=&amp;lt;colorname&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="28740" LastActivityDate="2020-04-03T19:52:03.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24445" PostTypeId="1" AcceptedAnswerId="24448" CreationDate="2020-04-03T20:42:41.447" Score="0" ViewCount="276" Body="&lt;p&gt;For example this function signature has several braces &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What it means? Unnecessary argument?&lt;/p&gt;&#xA;" OwnerUserId="20084" LastEditorUserId="51" LastEditDate="2020-04-03T23:15:05.827" LastActivityDate="2020-04-05T23:47:03.307" Title="What does [ .. ] mean in a function signature?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24448" PostTypeId="2" ParentId="24445" CreationDate="2020-04-03T23:09:14.037" Score="2" Body="&lt;p&gt;Yes, you've got it. It's an optional argument.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo [, bar])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can be called as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo, bar)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the latter case the function will usually have some predetermined value assigned to &lt;code&gt;bar&lt;/code&gt; (usually noted in the function's documentation.) Or it might ignore it altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nested square brackets indicate that an optional parameter inside of another can't be supplied unless the outer one is as well.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo [, bar [, baz]])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Good:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo, bar, baz)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Good:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo, bar)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Bad:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func(foo, baz)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With cases like the last some caution is in order. If &lt;code&gt;bar&lt;/code&gt; and &lt;code&gt;baz&lt;/code&gt; are defined as having the same value &quot;type&quot; (e.g. the function expects numbers for both) then the call could still go through even though you, for example, may have just mistakenly forgotten to include &lt;code&gt;bar&lt;/code&gt;. The ultimate result of mistakes like this could be anything from a loud, immediate failure to some subtly flawed behavior that occurs only after a delay. The latter type of problems are often very hard to diagnose so proceed carefully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, if &lt;code&gt;bar&lt;/code&gt; is supposed to have one type (say, an integer) and &lt;code&gt;baz&lt;/code&gt; is supposed to be an instance of another type (e.g. a string) then the fault is easier to detect. Note, though that in an interpreted, dynamically typed language like Vimscript code may have to be added explicitly to identify such problems. (Versus a compiled, statically typed language where the function signature defines the type, e.g. &lt;code&gt;func(float foo, integer bar, string baz)&lt;/code&gt;, and calling code with mixed up types won't even compile).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Yes, I've gone waaay beyond what was required to answer the question. Hopefully, someone down the line will find the extra info useful.&lt;/em&gt; :)&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-04-05T23:47:03.307" LastActivityDate="2020-04-05T23:47:03.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24449" PostTypeId="2" ParentId="24443" CreationDate="2020-04-03T23:46:33.637" Score="12" Body="&lt;p&gt;You can set &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27termwinkey%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'termwinkey'&lt;/code&gt;&lt;/a&gt; to a sequence other than &lt;code&gt;&amp;lt;C-W&amp;gt;&lt;/code&gt; to use a different keystroke to access the special sequences on the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set termwinkey=&amp;lt;C-X&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set termwinkey=&amp;lt;F1&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#terminal-typing&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help terminal-typing&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-03T23:46:33.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24450" PostTypeId="2" ParentId="24443" CreationDate="2020-04-04T01:30:07.020" Score="8" Body="&lt;p&gt;To send the original keystroke, you can use &lt;code&gt;&amp;lt;C-w&amp;gt;.&lt;/code&gt; (note the period).&lt;/p&gt;&#xA;&lt;p&gt;That said, I too find it annoying to have to remember.&lt;/p&gt;&#xA;&lt;p&gt;Useful reference: &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#terminal-typing&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vimhelp.org/terminal.txt.html#terminal-typing&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2023-07-10T14:49:51.380" LastActivityDate="2023-07-10T14:49:51.380" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24451" PostTypeId="2" ParentId="22309" CreationDate="2020-04-04T08:19:12.897" Score="1" Body="&lt;p&gt;If installed, fzf vim uses &lt;a href=&quot;https://github.com/sharkdp/bat&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;bat&lt;/code&gt;&lt;/a&gt; to add syntax highlighting to the preview. &lt;code&gt;bat&lt;/code&gt; comes with several themes available. You can choose a theme by setting the &lt;code&gt;BAT_THEME&lt;/code&gt; environment variable. For example, you can add this line to your &lt;code&gt;.bashrc&lt;/code&gt; or &lt;code&gt;.zshrc&lt;/code&gt; to set the &lt;code&gt;TwoDark&lt;/code&gt; theme:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; export BAT_THEME=&quot;TwoDark&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To preview the available themes run in your shell:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bat --list-themes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also add your own themes in case you are not happy with the available ones (as explained &lt;a href=&quot;https://github.com/sharkdp/bat#adding-new-themes&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="27039" LastEditorUserId="27039" LastEditDate="2020-04-10T09:33:10.253" LastActivityDate="2020-04-10T09:33:10.253" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24452" PostTypeId="1" AcceptedAnswerId="24477" CreationDate="2020-04-04T09:51:47.563" Score="1" ViewCount="1083" Body="&lt;p&gt;I'm trying to get omnicomplete working in neovim (0.3.4) on debian 10 with Ruby 2.6.6 (rbenv).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have these plugins: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Plug 'vim-ruby/vim-ruby'                &quot; ruby                                                                                                                        &#xA;Plug 'tpope/vim-rails'                  &quot; rails &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With these settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1                                                                                                     &#xA;autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1                                                                                                  &#xA;autocmd FileType ruby,eruby let g:rubycomplete_rails = 1 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get this error when trying omnicomplete:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;option 'omnifunc' is not set&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I add this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get this error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Error: falling back to syntax completion&lt;br&gt;&#xA;  E117: Unknown function: rubycomplete#Complete&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But after I click this error away it seems to work?&#xA;What am I doing wrong?&#xA;(I'm not interested in other plugins like deoplete, ...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;br&gt;&#xA;When I change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType ruby,eruby set omnifunc=syntaxcomplete#Complete &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it seems to work. Not sure if that is the correct way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Neovim you can check if Ruby is installed with &lt;code&gt;:checkhealth&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Debian 10 you can install ruby-neovim if you use the system Ruby version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I use rbenv I did this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gem install neovim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.vimrc settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:ruby_host_prog = '~/.rbenv/shims/neovim-ruby-host'&#xA;let g:ruby_path = system('echo $HOME/.rbenv/shims')&#xA;let g:rubycomplete_buffer_loading = 1&#xA;let g:rubycomplete_classes_in_global = 1&#xA;let g:rubycomplete_rails = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There was also a bug in vim-ruby for the completion, but that is now fixed: &lt;a href=&quot;https://github.com/vim-ruby/vim-ruby/pull/415&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vim-ruby/vim-ruby/pull/415&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="28752" LastEditorUserId="28752" LastEditDate="2020-04-12T14:15:58.513" LastActivityDate="2020-04-12T14:15:58.513" Title="neovim ruby/rails omnicomplete" Tags="|neovim|autocompletion|filetype-ruby|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24453" PostTypeId="1" AcceptedAnswerId="24471" CreationDate="2020-04-04T09:59:57.383" Score="5" ViewCount="2730" Body="&lt;p&gt;I'm trying to use Vim as a hex editor.&lt;/p&gt;&#xA;&lt;p&gt;I am using the &lt;code&gt;%!xxd&lt;/code&gt; / &lt;code&gt;%!xxd -r&lt;/code&gt; method, and it worked fine until I tried a some bytes that didn't work as expected :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;00000000: 1337 6161 6161 6161 6161 6161 6161 6161  .7aaaaaaaaaaaaaa&#xA;00000010: 6161 6161 6161 6161 6161 6161 6161 62ff  aaaaaaaaaaaaaabR&#xA;00000020: 3713 0000 0a                             7....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With this in the Vim buffer, running &lt;code&gt;%!xxd -r&lt;/code&gt; and then &lt;code&gt;%!xxd&lt;/code&gt; will produce :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;00000000: 1337 6161 6161 6161 6161 6161 6161 6161  .7aaaaaaaaaaaaaa&#xA;00000010: 6161 6161 6161 6161 6161 6161 6161 62c3  aaaaaaaaaaaaaab.&#xA;00000020: bf37 1300 000a                           .7....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Notice the difference at the end of the second line.&lt;/p&gt;&#xA;&lt;p&gt;Now you might think that &lt;code&gt;xxd&lt;/code&gt; is not used correctly, however running this : &lt;code&gt;cat bytes | xxd -r | xxd&lt;/code&gt; will yield :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;00000000: 1337 6161 6161 6161 6161 6161 6161 6161  .7aaaaaaaaaaaaaa&#xA;00000010: 6161 6161 6161 6161 6161 6161 6161 62ff  aaaaaaaaaaaaaab.&#xA;00000020: 3713 0000 0a                             7....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which is what I was expecting to see in Vim.&lt;/p&gt;&#xA;&lt;p&gt;Do you have any idea of what I am doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="28755" LastEditorUserId="10604" LastEditDate="2023-08-30T13:32:15.600" LastActivityDate="2023-09-05T14:42:03.593" Title="Vim hex editor with xxd not working as intended" Tags="|debugging|binary-file|xxd|" AnswerCount="2" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24454" PostTypeId="1" AcceptedAnswerId="24455" CreationDate="2020-04-04T11:50:53.293" Score="3" ViewCount="373" Body="&lt;p&gt;I've been a vim fan for almost 5 years right now and never moved to any other editor. Since my background in deep learning and NLP, I realized that there a lot of new development in source code parsing that we can use to build better programming language tools. The downside is that I have no idea where to start writing my first vim plugin? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example the BERT language model. I thought of training the model over C++ source code to get a line-by-line prediction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know or may assist with how I can start?&lt;/p&gt;&#xA;" OwnerUserId="16709" LastActivityDate="2020-04-04T15:14:52.370" Title="Building a Vim Plugin for Autocompletion" Tags="|vimscript|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24455" PostTypeId="2" ParentId="24454" CreationDate="2020-04-04T15:14:52.370" Score="1" Body="&lt;p&gt;That's very ambitious and impactful! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My recommendation, though, is that you should look into whether you can implement this &lt;em&gt;outside&lt;/em&gt; of Vim. More specifically, if you can use the &lt;a href=&quot;https://microsoft.github.io/language-server-protocol/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Language Server Protocol&lt;/a&gt; to implement this style of AI-powered code completion enhancements. (See also the &lt;a href=&quot;https://en.wikipedia.org/wiki/Language_Server_Protocol&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt; page on LSP and also &lt;a href=&quot;http://langserver.org].&quot; rel=&quot;nofollow noreferrer&quot;&gt;langserver.org&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do implement this as an LSP, you'll have a wealth of LSP clients on Vim that are able to query it. Straight LSP clients, such as &lt;a href=&quot;https://github.com/prabirshrestha/vim-lsp&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-lsp&lt;/a&gt; or &lt;a href=&quot;https://github.com/natebosch/vim-lsc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-lsc&lt;/a&gt;, but also integration with established code completion tools such as &lt;a href=&quot;https://github.com/neoclide/coc.nvim&quot; rel=&quot;nofollow noreferrer&quot;&gt;CoC.nvim&lt;/a&gt; and also linting engines such as &lt;a href=&quot;https://github.com/dense-analysis/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ALE&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, since LSP is not specific to Vim, by implementing something as an LSP means immediately you get it available in most other programmer editors, since LSP support is widespread among IDEs these days.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, it's quite possible that LSP will not really export the kind of methods or queries that you think would be useful or required to implement an AI-powered completion engine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'd still encourage you to try to implement this as an extension of LSP, using the same protocol, only exposing new objects/methods through its JSON-RPC interface. The biggest advantage of this approach is that you can then use any of the existing clients as a base to prototype your code and you don't need to start from scratch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, as LSP is evolving, features for smarter and better completion are likely to make it into the protocol. (Or perhaps some standard way of adding extensions to the protocol that a client and server would agree on.) So by building a successful prototype for AI-powered completion on top of LSP, you can influence LSP's evolution to support this kind of use case.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-04T15:14:52.370" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24456" PostTypeId="1" AcceptedAnswerId="24458" CreationDate="2020-04-04T15:30:38.227" Score="1" ViewCount="275" Body="&lt;p&gt;I want to open and edit files in FileZilla with gvim without opening a new window every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched online and found this but it doesn't open in same gvim window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Filetype associations&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;. /usr/local/bin/gvim -p&#xA;thtml /usr/local/bin/gvim -p&#xA;php /usr/local/bin/gvim -p&#xA;html /usr/local/bin/gvim -p&#xA;css /usr/local/bin/gvim -p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help would be great there is little information about this online.&lt;/p&gt;&#xA;" OwnerUserId="27446" LastActivityDate="2020-04-04T17:11:19.467" Title="Opening gvim in new tab (filezilla)" Tags="|gvim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24458" PostTypeId="2" ParentId="24456" CreationDate="2020-04-04T17:11:19.467" Score="3" Body="&lt;p&gt;I believe &lt;code&gt;gvim --remote&lt;/code&gt; is what you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If no GVim is running, it will start a new instance of it, but if an instance is already running, &lt;code&gt;gvim --remote&lt;/code&gt; will open the file on that instance and raise its window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/remote.txt.html#--remote&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help --remote&lt;/code&gt;&lt;/a&gt; for details. You might also like &lt;a href=&quot;https://vimhelp.org/remote.txt.html#--remote-tab&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;--remote-tab&lt;/code&gt;&lt;/a&gt; to open the file in a new tab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you set your file associations to use &lt;code&gt;gvim --remote&lt;/code&gt;, that should take care of opening files from FileZilla on a single GVim instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the record, the &lt;code&gt;gvim -p&lt;/code&gt; command you have in the sample file associations in your question will open many files one per tab, but only when you pass GVim multiple file names on the same command-line. It won't reuse an existing GVim window when one is already open.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-04T17:11:19.467" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24459" PostTypeId="1" AcceptedAnswerId="24464" CreationDate="2020-04-04T18:27:02.753" Score="9" ViewCount="10331" Body="&lt;p&gt;Maybe a stupid question but is it possible to run neovim on a GUI like gvim or mvim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need some GUI to do remote work within Filezilla&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="27446" LastEditorUserId="27446" LastEditDate="2020-04-04T19:12:38.320" LastActivityDate="2021-07-09T16:28:16.637" Title="Can you use neovim in a gui like mvim or gvim? (Mac OS X)" Tags="|neovim|gvim|macvim|macos|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24460" PostTypeId="1" AcceptedAnswerId="24461" CreationDate="2020-04-05T02:42:32.943" Score="1" ViewCount="484" Body="&lt;p&gt;I have this file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Another comment&#xA;program&#xA;start&#xA;&#xA;end&#xA;This is a comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Anything after &lt;code&gt;end&lt;/code&gt; or before &lt;code&gt;program&lt;/code&gt; must be highlighted as a &lt;code&gt;Comment&lt;/code&gt;.&#xA;I've battled with vim for hours, what am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region Comment start=/\%^/ end=/\zeprogram/&#xA;syntax region Comment start=/end\zs/ end=/\%$/&#xA;&#xA;syntax keyword PreProc end start program&#xA;&#xA;let b:current_syntax = 'minor'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before &lt;code&gt;program&lt;/code&gt; is working, after &lt;code&gt;end&lt;/code&gt; is not.&lt;/p&gt;&#xA;" OwnerUserId="3160" LastActivityDate="2020-04-05T05:33:38.497" Title="Highlight region with keyword in it" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24461" PostTypeId="2" ParentId="24460" CreationDate="2020-04-05T05:33:38.497" Score="2" Body="&lt;p&gt;This won't work, since it would require that the Vim syntax engine would parse &lt;code&gt;end&lt;/code&gt; twice, first as the keyword and second as the region start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though &lt;code&gt;\zs&lt;/code&gt; makes the match start only after &lt;code&gt;end&lt;/code&gt;, the regex engine needs to go through the &lt;code&gt;end&lt;/code&gt; part to be able to match it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can offer a few alternatives, some of which work better than the others... In order of worst to best:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Look-behind zero-width match (almost works)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The usual workaround for when &lt;code&gt;\zs&lt;/code&gt; doesn't work because it needs to go twice through the text is to replace it with a look-behind match:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region Comment start=/\(end\)\@&amp;lt;=/ end=/\%$/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, this &lt;em&gt;almost&lt;/em&gt; works. But it only really seems to work when there's a trailing whitespace after &lt;code&gt;end&lt;/code&gt;. It seems Vim won't try to match at the end of line after a match that consumes all the way to the last character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The look-behind successfully works around the issue with scanning the same word twice, because it actually starts the match later and then backtracks, effectively scanning the text twice...&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Using &lt;code&gt;matchgroup=&lt;/code&gt; for delimiters&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Another option is to use &lt;code&gt;matchgroup=PreProc&lt;/code&gt; to highlighting the &quot;start&quot; and &quot;end&quot; delimiters of the region with the &lt;code&gt;PreProc&lt;/code&gt; group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the opposite delimiters are zero-width matches (start or end of document), highlighting them also is not a problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region Comment matchgroup=PreProc start=/\%^/ end=/program/&#xA;syntax region Comment matchgroup=PreProc start=/end/ end=/\%$/&#xA;syntax keyword PreProc start program&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;end&lt;/code&gt; can't be a keyword anymore, otherwise we have the same problem again where that prevents it from matching the second Comment region start.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Hierarchy of syntax groups contained within each other&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is the solution I'd most likely recommend, since it gives you the most control, doesn't prevent you from using all keywords and works reliably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to mark the groups with &quot;contained&quot;, so they only match explicitly where allowed, and use &quot;contains&quot; to list the groups allowed to match inside that region.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have Comment matching everything, then it contains a Normal section from &lt;code&gt;program&lt;/code&gt; to &lt;code&gt;end&lt;/code&gt;, and the PreProc keywords can match inside Normal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax region Comment start=/\%^/ end=/\%$/ contains=Normal&#xA;syntax region Normal start=/program/ end=/end/ keepend contained contains=PreProc&#xA;syntax keyword PreProc end start program contained&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We need to use &lt;code&gt;keepend&lt;/code&gt; on Normal to be able to match the &quot;end&quot; part even though that also matches a keyword.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-05T05:33:38.497" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24462" PostTypeId="1" AcceptedAnswerId="24463" CreationDate="2020-04-05T06:56:00.620" Score="39" ViewCount="13361" Body="&lt;p&gt;The latest version of Vim, 8.2, has a new feature called &quot;popups&quot; or &quot;popup windows&quot;. They sound interesting but I'm not quite sure what they're good for. Can you enlighten me...preferably with some examples?&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2021-09-07T19:27:27.093" LastActivityDate="2022-08-05T01:35:17.173" Title="What are the new &quot;popup windows&quot; in Vim 8.2?" Tags="|vimscript|vim-windows|popup-menu|popup|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24463" PostTypeId="2" ParentId="24462" CreationDate="2020-04-05T06:56:00.620" Score="62" Body="&lt;p&gt;&lt;em&gt;Background: I have a plugin for navigating sections in markup documents and wanted to show the section hierarchy in a popup. I distilled what I learned while implementing this down to the following introduction in hopes of getting others up and running quickly...&lt;/em&gt;&lt;/p&gt;&#xA;&lt;h2&gt;Overview&lt;/h2&gt;&#xA;&lt;p&gt;Vim 8.2's popup windows allow Vimscript authors and plugin developers to create one or more floating, modal windows that, among other things, can be used for tool tips, notifications/alerts, dialog boxes and transient menus.&lt;/p&gt;&#xA;&lt;h2&gt;Window and Buffer&lt;/h2&gt;&#xA;&lt;p&gt;Each popup consists of a Vim window and an associated buffer. The window and buffer have a number of unique characteristics including:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Popup windows will be positioned on top of regular Vim windows.&lt;/li&gt;&#xA;&lt;li&gt;Popups can be stacked on each other with stacking order determined by the relative values of their &lt;code&gt;zindex&lt;/code&gt; attributes.&lt;/li&gt;&#xA;&lt;li&gt;The buffer is &lt;code&gt;'bufhidden'&lt;/code&gt;, is not &lt;code&gt;'buflisted'&lt;/code&gt; (it won't show up in a buffer listing), and has a &lt;code&gt;'buftype'&lt;/code&gt; of &amp;quot;popup&amp;quot;.&lt;/li&gt;&#xA;&lt;li&gt;There is no cursor in a popup. (Oddly, if the cursor in the underlying window is below the popup it will remain visible.)&lt;/li&gt;&#xA;&lt;li&gt;The buffer has no swapfile or undo capability and is not editable by normal means but the content can be modified post-creation with &lt;code&gt;popup_settext()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;A popup's initial contents are specified via a parameter to one of the create functions. The content can be in a string or a list of strings. Alternatively, you can pass the number of an existing buffer containing your content. (To create a buffer solely for the popup see &lt;code&gt;bufadd()&lt;/code&gt;.)&lt;/li&gt;&#xA;&lt;li&gt;The window/buffer look and feel is highly customizable.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Creation&lt;/h2&gt;&#xA;&lt;p&gt;There are six different functions for creating popup windows. That's a lot but five of them are basically wrappers around &lt;code&gt;popup_create()&lt;/code&gt; that provide &amp;quot;pre-packaged&amp;quot; configurations for particular purposes. Here they all are with brief descriptions taken from &lt;code&gt;:h popup-functions&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;popup_create()&lt;/code&gt; - centered in the screen&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;popup_atcursor()&lt;/code&gt; - just above the cursor position, closes on mouse move&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;popup_beval()&lt;/code&gt; - at pos indicated by v:beval_ variables, closes on mouse move&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;popup_notification()&lt;/code&gt; - show a notification for three seconds&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;popup_dialog()&lt;/code&gt; - centered with padding and border&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;popup_menu()&lt;/code&gt; - prompt for selecting an item from a list&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Customization&lt;/h2&gt;&#xA;&lt;p&gt;Text appearance can be controlled with syntax highlighting or using text properties (another major new feature in Vim 8.2...like syntax highlighting except it sticks to associated text as it moves in the buffer). There are also a number of attributes or &amp;quot;options&amp;quot; that control certain other look-and-feel characteristics. This is a sampling of those options.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;Placement/Size:&lt;/em&gt; &lt;code&gt;line&lt;/code&gt;, &lt;code&gt;col&lt;/code&gt;, &lt;code&gt;pos&lt;/code&gt; (e.g. &amp;quot;botright&amp;quot;), &lt;code&gt;resize&lt;/code&gt; (with mouse), &lt;code&gt;drag&lt;/code&gt; (with mouse), &lt;code&gt;minwidth&lt;/code&gt;&lt;sup&gt;*&lt;/sup&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Appearance:&lt;/em&gt; &lt;code&gt;padding&lt;/code&gt;, &lt;code&gt;border&lt;/code&gt;, &lt;code&gt;borderchars&lt;/code&gt;, &lt;code&gt;highlight&lt;/code&gt; (a la &lt;code&gt;:hi&lt;/code&gt;), &lt;code&gt;title&lt;/code&gt;, &lt;code&gt;mask&lt;/code&gt; (see example below)&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Behavior:&lt;/em&gt; &lt;code&gt;time&lt;/code&gt; (until close), &lt;code&gt;callback&lt;/code&gt; (function), &lt;code&gt;filter&lt;/code&gt; (input processing)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Option values can be defined on creation of a popup window or afterwards through the &lt;code&gt;popup_setoptions()&lt;/code&gt; function.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sub&gt;* It's worth noting that popup window dimensions are, by default, dictated by the contained text. You can override this behavior, within limits, using &lt;code&gt;minwidth&lt;/code&gt;, &lt;code&gt;maxwidth&lt;/code&gt;, &lt;code&gt;minheight&lt;/code&gt;, &lt;code&gt;maxheight&lt;/code&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;h2&gt;Interaction&lt;/h2&gt;&#xA;&lt;p&gt;A popup's lifetime can be controlled several ways including by timer, upon mouse movement or user input or programmatically with &lt;code&gt;popup_close()&lt;/code&gt;. The nuclear option, &lt;code&gt;popup_clear()&lt;/code&gt;, will dismiss any and all existing popups.&lt;/p&gt;&#xA;&lt;p&gt;How a popup processes user input can be controlled with so-called &amp;quot;filters&amp;quot;. There are a couple of builtin filters including the &amp;quot;yesno&amp;quot; filter demonstrated in the examples below.&lt;/p&gt;&#xA;&lt;p&gt;Each popup can have an assigned callback function. When the popup is closed this function is called with the &amp;quot;result&amp;quot;. This is most applicable for popups acting as menus. The result, in that case, is usually just the number of the row that the user selected. We'll see this in action, too, below.&lt;/p&gt;&#xA;&lt;h2&gt;Examples&lt;/h2&gt;&#xA;&lt;p&gt;Finally, we get to the good stuff!&lt;/p&gt;&#xA;&lt;h3&gt;Notification&lt;/h3&gt;&#xA;&lt;p&gt;For a time-limited notification popup:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;call popup_notification(&amp;quot;Get the hell out of Dodge!&amp;quot;, &#xA;     \ #{ line: 5, col: 10, highlight: 'WildMenu', } )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ajp1e.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ajp1e.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As noted above this will show for three seconds then close.&lt;/p&gt;&#xA;&lt;h3&gt;Menu&lt;/h3&gt;&#xA;&lt;p&gt;Now for a simple menu:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func! MenuCB(id, result)&#xA;    echo &amp;quot;You chose item #&amp;quot;.a:result&#xA;endfunc&#xA;&#xA;call popup_menu(['The quick fox...', '...jumped over...', '...the lazy dogs!'], &#xA;     \ #{ title: &amp;quot;Well? Pick one&amp;quot;, callback: 'MenuCB', line: 25, col: 40, &#xA;     \ highlight: 'Question', border: [], close: 'click',  padding: [1,1,0,1]} )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7etfo.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7etfo.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note the &lt;code&gt;padding&lt;/code&gt; option which I used to put a little space between the menu items and the top and side borders.&lt;/p&gt;&#xA;&lt;p&gt;Choosing the last row results in...&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eprZ6.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eprZ6.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Yes/No Dialog&lt;/h3&gt;&#xA;&lt;p&gt;In this example we'll use the builtin filter &lt;code&gt;popup_filter_yesno&lt;/code&gt;. This will wait until the user has clicked a close key (&lt;code&gt;x&lt;/code&gt; or &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;) or one of &lt;code&gt;Y&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;N&lt;/code&gt;, or &lt;code&gt;n&lt;/code&gt;. Yes replies cause the callback to be called with result 1. No sends result 0.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func! YayOrNay(id, result)&#xA;    if a:result | echo &amp;quot;You said 'yay'&amp;quot; | endif&#xA;endfunc&#xA;&#xA;call popup_dialog('[y]ay or [n]ay?', #{ filter: 'popup_filter_yesno', callback: 'YayOrNay'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IN0od.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IN0od.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If I choose &lt;code&gt;Y&lt;/code&gt; or &lt;code&gt;y&lt;/code&gt; the message (&amp;quot;You said 'yay'&amp;quot;) will show on the status line.&lt;/p&gt;&#xA;&lt;p&gt;If you specify your own filter function then you can intercept a subset of key presses, handling them in whatever way you choose and pass the rest on to the generic filter, &lt;code&gt;popup_filter_menu()&lt;/code&gt;. There's an example at &lt;code&gt;:h popup-examples&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;The Base Case&lt;/h3&gt;&#xA;&lt;p&gt;Let's try the primary function, &lt;code&gt;popup_create()&lt;/code&gt;, with no options...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;call popup_create(poplist, #{ })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;poplist&lt;/code&gt; is a list of strings representing a hierarchical menu, with appropriate numbering and spacing included.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6uOC4.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6uOC4.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So by default we get a popup window positioned in the middle of the main window, having no borders or padding and with dimensions determined by the content.&lt;/p&gt;&#xA;&lt;h3&gt;The Z-Index and Masking&lt;/h3&gt;&#xA;&lt;p&gt;Finally, let's see the z-index functionality and, for amusement mostly, demonstrate the mask attribute. With 'mask' you can&#xA;specify popup coordinates and those sections of the popup will be rendered as transparent. I've yet to think of a practical use for this so I just cut off a couple corners and poked a couple big holes in the thing.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;call popup_create(poplist, #{ zindex: 20, line: 5, col: 20,&#xA;     \ mask: [[1, 10, 1, 3], [-10, -4, 3, 5], [10, 23, -5, -2], [-10, -1, -3, -1]] })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UuevJ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UuevJ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Normally one would expect additional popups to be placed over existing ones but by specifying a lower value for the &lt;code&gt;zindex&lt;/code&gt; attribute....&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;call popup_create(poplist, #{ zindex: 10, line: 7, col: 25, highlight: 'CursorLine' })&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;...we can make it a pop-under:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vq9wl.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vq9wl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The garish pink? That's the default color for popups in many color schemes. (Completion menu users will likely have seen it before! :P) Override with the new highlight groups &lt;code&gt;Popup&lt;/code&gt; and &lt;code&gt;PopupSel&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Other Features&lt;/h2&gt;&#xA;&lt;p&gt;Well, I hope that gives you a good sense of what popups are capable of. There are certainly some features I haven't covered or only mentioned briefly including:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Asynchronous content fill-in&lt;/li&gt;&#xA;&lt;li&gt;Popup manipulation functions (e.g. &lt;code&gt;popup_move()&lt;/code&gt;, &lt;code&gt;popup_setoptions()&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;User-defined filters&lt;/li&gt;&#xA;&lt;li&gt;Key mappings&lt;/li&gt;&#xA;&lt;li&gt;Building a popup from a user-created buffer.&lt;/li&gt;&#xA;&lt;li&gt;Running a terminal in a popup window&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To learn more about those and everything else popup related visit &lt;code&gt;:h popup&lt;/code&gt; for a thousand-plus lines of juicy popup goodness.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2022-08-05T01:35:17.173" LastActivityDate="2022-08-05T01:35:17.173" CommentCount="20" ContentLicense="CC BY-SA 4.0" />
  <row Id="24464" PostTypeId="2" ParentId="24459" CreationDate="2020-04-05T08:27:45.743" Score="7" Body="&lt;p&gt;There are several GUIs for Neovim because it externalises the user interface elements, so any GUI can draw these in different ways. There's &lt;a href=&quot;https://github.com/neovim/neovim/wiki/Related-projects#gui&quot; rel=&quot;noreferrer&quot;&gt;a list&lt;/a&gt; that tracks the status of these projects. My favourites are &lt;a href=&quot;https://github.com/yatli/fvim&quot; rel=&quot;noreferrer&quot;&gt;FVim&lt;/a&gt; and &lt;a href=&quot;https://github.com/akiyosi/goneovim&quot; rel=&quot;noreferrer&quot;&gt;goneovim&lt;/a&gt; and both support remote sessions&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-05T08:27:45.743" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24465" PostTypeId="1" AcceptedAnswerId="24466" CreationDate="2020-04-05T08:41:43.743" Score="0" ViewCount="48" Body="&lt;p&gt;How using vim serach and replace change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;title: &amp;lt;Translation {...messages.title} /&amp;gt;,&#xA;title: &amp;lt;Translation {...messages.header} /&amp;gt;,&#xA;title: &amp;lt;Translation {...messages.message} /&amp;gt;,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;title: &amp;lt;Translation id=&quot;key.subkey.title&quot; /&amp;gt;,&#xA;title: &amp;lt;Translation id=&quot;key.subkey.header&quot;  /&amp;gt;,&#xA;title: &amp;lt;Translation id=&quot;key.subkey.message&quot;  /&amp;gt;,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've thought about something like:&#xA;&lt;code&gt;%s/{...messages\.[a-zA-Z ]*\}/id=&quot;\1&quot;/g&lt;/code&gt;&#xA;But I don't know how to make &lt;code&gt;[a-zA-Z ]*\&lt;/code&gt; a reference to be used to paste in the new form.&lt;/p&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2020-04-05T10:34:36.950" Title="How to find and replace a group while keeping the word" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24466" PostTypeId="2" ParentId="24465" CreationDate="2020-04-05T10:34:36.950" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;But I don't know how to make &lt;code&gt;[a-zA-Z]*&lt;/code&gt; a reference to be used to paste in the new form&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Just put it inside &lt;code&gt;\(&lt;/code&gt; and &lt;code&gt;\)&lt;/code&gt;, that way you can refer to it in the replacement as &lt;code&gt;\1&lt;/code&gt; (assuming that's the first group inside parentheses.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;%s/{\.\.\.messages\.&lt;b&gt;\([a-zA-Z]*\)&lt;/b&gt;}/id=&quot;key.subkey.&lt;b&gt;\1&lt;/b&gt;&quot;/&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://vimhelp.org/change.txt.html#s%2F%5C1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help s/\1&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-05T10:34:36.950" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24467" PostTypeId="1" AcceptedAnswerId="24470" CreationDate="2020-04-05T12:27:13.893" Score="3" ViewCount="70" Body="&lt;p&gt;The documentation of Latex-Suite says I can customize the generated environment boilerplates by defining &lt;code&gt;g:Tex_Env_...&lt;/code&gt; variables. This works for me. Nevertheless, it goes on to say that for environment names containing special characters I have to use a special syntax. An explicit example for &lt;code&gt;align*&lt;/code&gt; is given &lt;a href=&quot;http://vim-latex.sourceforge.net/documentation/latex-suite.html#customizing-macros&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Tex_Env_{'align*'} = &quot;\\begin{align*}\&amp;lt;CR&amp;gt;&amp;lt;++&amp;gt; &amp;amp;= &amp;lt;++&amp;gt;\&amp;lt;CR&amp;gt;\\end{align*}&amp;lt;++&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I try this, copied verbatim, vim complains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E461: Illegal variable name: Tex_Env_align*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suppose the documentation contains an error, or was written for a different version of vim (I'm using 8.2.343). What syntax should I use instead?&lt;/p&gt;&#xA;" OwnerUserId="10136" LastActivityDate="2020-04-05T18:06:23.870" Title="Customizing Latex-Suite star environments" Tags="|variables|plugin-vim-latex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24468" PostTypeId="1" CreationDate="2020-04-05T17:01:11.213" Score="2" ViewCount="350" Body="&lt;p&gt;I'm trying to type the following latex in nvim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f_{high}=\{1209,1336,1477,1633\}Hz.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason, nvim is rendering this as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fₕᵢgₕ= \{ 1209, 1336, 1477, 1633\}\si{Hz}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I fix this?&lt;/p&gt;&#xA;" OwnerUserId="28780" LastEditorUserId="1292" LastEditDate="2020-04-06T08:46:39.880" LastActivityDate="2020-04-06T08:46:39.880" Title="Latex Subscripts Rendering Weirdly" Tags="|filetype-tex|plugin-vim-latex|conceal|" AnswerCount="2" CommentCount="2" ClosedDate="2020-04-09T00:26:46.197" ContentLicense="CC BY-SA 4.0" />
  <row Id="24469" PostTypeId="2" ParentId="24468" CreationDate="2020-04-05T17:47:43.037" Score="1" Body="&lt;p&gt;Do you by any chance have the plugin &lt;code&gt;KeitaNakamura/tex-conceal.vim&lt;/code&gt; installed? Try putting the following in &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set conceallevel=0&#xA;let g:tex_conceal='abdgm'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope this solves your problem.&lt;/p&gt;&#xA;" OwnerUserId="16884" LastActivityDate="2020-04-05T17:47:43.037" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24470" PostTypeId="2" ParentId="24467" CreationDate="2020-04-05T18:06:23.870" Score="3" Body="&lt;p&gt;This sent me on quite the archeological mission...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out this syntax worked on Vim 6.3.82 (from CentOS 4) but didn't work anymore on Vim 7.0.237 (from CentOS 5.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The commits that &lt;a href=&quot;https://github.com/vim-latex/vim-latex/commit/4bee11364d2afd7b9763848aa8906e64555d7f5a&quot; rel=&quot;nofollow noreferrer&quot;&gt;introduced the feature&lt;/a&gt; and &lt;a href=&quot;https://github.com/vim-latex/vim-latex/commit/837aff7b277432fb1ceab7da1daf0ca3dbf38d9e&quot; rel=&quot;nofollow noreferrer&quot;&gt;documented it&lt;/a&gt; in vim-latex are from September 2003, which is around the time of Vim 6. (Vim 6 was released on September 2001 and Vim 7 on May 2006.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like this is not a very popular feature... Or it's mostly used with rules other than &lt;code&gt;align*&lt;/code&gt; which cause the invalid variable name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This was clearly developed before Vim had dicts, since dicts are a way more appropriate way to store this information.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-05T18:06:23.870" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24471" PostTypeId="2" ParentId="24453" CreationDate="2020-04-05T19:02:52.313" Score="3" Body="&lt;p&gt;This will happen if you start editing the &lt;code&gt;xxd&lt;/code&gt;-dumped version of the binary file, in which case Vim will assume a UTF-8 encoding (which you can confirm with &lt;code&gt;:set fenc?&lt;/code&gt; returning &lt;code&gt;fileencoding=utf-8&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you turn the file back into binary form, the character still looks correct (using &lt;code&gt;ga&lt;/code&gt; on top of it shows &lt;code&gt;&amp;lt;ÿ&amp;gt; 255, Hex 00ff, Oct 377, Digr y:&lt;/code&gt;), but that's actuall not considering the encoding, so if you were to save this file now, the UTF-8 encoding will kick in and will turn &lt;code&gt;\u00ff&lt;/code&gt; into the bytes &lt;code&gt;\xc3\xbf&lt;/code&gt;, which are the UTF-8 encoded version of this Unicode character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possible workaround is to use a different file encoding such as &lt;code&gt;latin1&lt;/code&gt;, which is a 8-bit encoding and shouldn't expand characters above 127.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better solution is to use &lt;code&gt;vim -b&lt;/code&gt; to enable the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27binary%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'binary'&lt;/code&gt;&lt;/a&gt; option. (You can also use &lt;code&gt;:set binary&lt;/code&gt; from inside Vim.) Enabling &lt;code&gt;'binary'&lt;/code&gt; will disable a file encoding completely (&lt;code&gt;:set fenc?&lt;/code&gt; returns &lt;code&gt;fileencoding=&lt;/code&gt;) and should preserve 8-bit characters as they are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out this works OK with the &lt;code&gt;xxd&lt;/code&gt;-dumped output since &lt;code&gt;xxd&lt;/code&gt; only uses 7-bit ASCII characters in its output, so using &lt;code&gt;'binary'&lt;/code&gt; doesn't really hurt it too much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(From a purist's point of view, an ideal solution here would use two separate buffes in Vim, one for the &lt;code&gt;xxd&lt;/code&gt;-dumped output and a separate one with &lt;code&gt;'binary'&lt;/code&gt; set for the binary encoded output of &lt;code&gt;xxd&lt;/code&gt;. A plug-in facilitating binary editing would probably help manage the separate buffers and set the right options on all of them.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-05T19:02:52.313" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24472" PostTypeId="2" ParentId="24468" CreationDate="2020-04-05T19:06:01.237" Score="4" Body="&lt;p&gt;The problem is that the subscript for &lt;code&gt;g&lt;/code&gt; doesn't exist, and those for &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt; look &quot;off.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As noted, you can either&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;turn off the conceal feature altogether (&lt;code&gt;set conceallevel=0&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;turn off conceal in tex files just for these kinds of things (&lt;code&gt;let g:tex_conceal = 'abdmg'&lt;/code&gt;)—see &lt;code&gt;:help g:tex_conceal&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-05T19:06:01.237" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24473" PostTypeId="1" AcceptedAnswerId="24478" CreationDate="2020-04-05T20:11:00.347" Score="3" ViewCount="1495" Body="&lt;p&gt;Vim packages work by updating &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27runtimepath%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'runtimepath'&lt;/code&gt;&lt;/a&gt; to include the top directories of the plug-ins in each package (and also the &lt;code&gt;after/&lt;/code&gt; directory), but the Vim documentation on &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#packages&quot; rel=&quot;nofollow noreferrer&quot;&gt;packages&lt;/a&gt; isn't absolutely clear on which ordering is used to add the packages into &lt;code&gt;'runtimepath'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems plug-ins are added &lt;em&gt;after&lt;/em&gt; the Vim directory in your home (&lt;code&gt;~/.vim&lt;/code&gt; or &lt;code&gt;$HOME/vimfiles&lt;/code&gt; on Windows) and &lt;em&gt;before&lt;/em&gt; the Vim system-wide runtimes (there's actually two directories for those, &lt;code&gt;$VIM/vimfiles&lt;/code&gt; and &lt;code&gt;$VIMRUNTIME&lt;/code&gt;.) The &lt;code&gt;after/&lt;/code&gt; directories of plug-ins are added &lt;em&gt;after&lt;/em&gt; the Vim runtimes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These general guidelines seem intuitive and make sense, since you typically want the files directly in your home to supercede plug-ins (so come as early as possible), then have plug-ins supercede the Vim runtimes (since you might use a plug-in with a richer or more featureful version of what upstream ships) and the &lt;code&gt;after/&lt;/code&gt; directory exists specifically for when you specifically need to have something as late as possible in &lt;code&gt;'runtimepath'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But: &lt;strong&gt;What are the exact rules used to splice package plug-in directories into &lt;code&gt;'runtimepath'&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if you changed your &lt;code&gt;'runtimepath'&lt;/code&gt;, or you're using a non-standard directory for the Vim runtimes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the same vein, Vim 8 packages seem to follow on the tracks of &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow noreferrer&quot;&gt;pathogen.vim&lt;/a&gt;, which started establishing adding plug-in directories to &lt;code&gt;'runtimepath'&lt;/code&gt; as a way to manage plug-ins, which was later embraced by plug-in managers such as &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vundle&lt;/a&gt; and &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt;. But it seems none of those is very explicit in documenting the rules for manipulation of &lt;code&gt;'runtimepath'&lt;/code&gt; either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So: &lt;strong&gt;What are the rules for splicing &lt;code&gt;'runtimepath'&lt;/code&gt; used by these popular plug-in managers? Are those the same ones later adopted by Vim packages?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-06T05:25:50.833" Title="Order in runtimepath of Vim packages or similar plug-in managers" Tags="|plugin-system|plugin-vim-plug|plugin-vundle|plugin-pathogen|packages|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24474" PostTypeId="1" AcceptedAnswerId="24476" CreationDate="2020-04-05T21:08:05.823" Score="11" ViewCount="6517" Body="&lt;p&gt;How do I write control characters in a file using Vim? For example, I want to write the backspace character, which is invoked using ^? (or the dedicated Backspace) key on the keyboard, to a file. But I can't seem to do that - everything I try just erases a character. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The Unix Programming Environment&lt;/em&gt; by Kernighan and Pike says (§2.1 &lt;em&gt;The basics of files&lt;/em&gt;): &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It is important in each case to distinguish between how the character is&#xA;  stored in a file and how it is interpreted in various situations. For example,&#xA;  when you type a backspace on your keyboard (and assuming that your erase&#xA;  character is backspace), the kernel interprets it to mean that you want to discard whatever character you typed previously. Both that character and the&#xA;  backspace disappear, but the backspace is echoed to your terminal, where it&#xA;  makes the cursor move one position backwards.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If you type the sequence&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\←&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;(i.e., &lt;code&gt;\&lt;/code&gt; followed by a backspace), however, the kernel interprets that to mean that you want a literal backspace in your input, so the &lt;code&gt;\&lt;/code&gt; is discarded and the byte &lt;code&gt;010&lt;/code&gt; winds up in your file. When the backspace is echoed on your terminal, it moves the cursor to sit on top of the &lt;code&gt;\&lt;/code&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;When you &lt;em&gt;print&lt;/em&gt; a file that contains a backspace, the backspace is passed&#xA;  uninterpreted to your terminal, which again will move the cursor one position&#xA;  backwards. When you use &lt;code&gt;od&lt;/code&gt; to display a file that contains a backspace, it&#xA;  appears as a byte with value &lt;code&gt;010&lt;/code&gt;, or, with the &lt;code&gt;-c&lt;/code&gt; option, as &lt;code&gt;\b&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Basically, it's saying that writing a backslash before backspace character should work (at least for ed). However I'm not able to write it using Vim. How can I write uncommon control characters into the file (such as backspace)&lt;/p&gt;&#xA;" OwnerUserId="28786" LastEditorUserId="1081" LastEditDate="2020-04-06T10:10:12.950" LastActivityDate="2022-02-15T15:12:48.630" Title="Vim: How to write control characters in file" Tags="|control-character|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24475" PostTypeId="2" ParentId="23264" CreationDate="2020-04-05T22:00:03.683" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;These lines define special remappings, so I think it makes sense that they are called on startup time and not via an autocmd.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that there's a specific autocmd event which is essentially for &quot;startup time&quot;, but after plugins were loaded and executed, which is the VimEnter event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#VimEnter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help VimEnter&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;VimEnter&lt;/code&gt;: After doing all the startup stuff, including loading .vimrc files, executing the &lt;code&gt;-c cmd&lt;/code&gt; arguments, creating all windows and loading the buffers in them.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Defining a function and having that executed in VimEnter would be an appropriate solution.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My current workaround is just to explicitly source the plugin file: &lt;code&gt;source $HOME/.vim/bundle/vimtk/plugin/vimtk.vim&lt;/code&gt; before calling these commands&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Slightly better would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime! plugin/vimtk.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since that doesn't depend on the specific directory used by your plugin manager to store the vimtk plugin, it only depends on the specific name of the &lt;code&gt;*.vim&lt;/code&gt; file inside it. It matches what Vim does when it &lt;a href=&quot;https://vimhelp.org/starting.txt.html#load-plugins&quot; rel=&quot;nofollow noreferrer&quot;&gt;loads plugins&lt;/a&gt; after the vimrc file is processed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it's still not very satisfying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One issue with this approach is that the plugin file will be executed again when Vim loads all plugins. So it works better if the plugin file detects whether it was already sourced (for example, by setting a global variable) and skips execution if it was previously loaded.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and I would like to call the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;&quot; Make default vimtk remaps.&#xA;:call VimTK_default_remap()&#xA;&#xA;&quot; Swap colon and semicolon&#xA;:call vimtk#swap_keys(':', ';')&#xA;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that it should be &lt;em&gt;possible&lt;/em&gt; to call the latter type of functions &lt;code&gt;vimtk#...&lt;/code&gt; from your vimrc. These are &lt;a href=&quot;https://vimhelp.org/eval.txt.html#autoload&quot; rel=&quot;nofollow noreferrer&quot;&gt;autoloaded&lt;/a&gt; functions and as long as rhe plugins have been registered into &lt;code&gt;'runtimepath'&lt;/code&gt; (which happens early on, when you configure your plugin manager), Vim should be able to load them just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only issue is when those functions depend on some initialization that happens or is triggered from one of the &lt;code&gt;plugin/*.vim&lt;/code&gt; files, as that's the step that will happen after vimrc is processed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this particular case, it's clear that global function &lt;code&gt;VimTK_default_remap()&lt;/code&gt; is not autoloaded, so it must be registered by the &lt;code&gt;plugin/vimtk.vim&lt;/code&gt; script and will only be accessible after its execution. (That's also often the case when plugins register new Vim user commands, that you might want to use during initialization, but using them from the vimrc file is problematic.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One more option to consider is to write your late initialization commands into a separate file under &lt;code&gt;~/.vim/after/plugin/*.vim&lt;/code&gt;. This file will be executed at the same stage when the Vim plugins are loaded, but being on an &lt;code&gt;after/&lt;/code&gt; directory ensures it will be at the end of &lt;code&gt;'runtimepath'&lt;/code&gt;, which means it will be executed after all plugins have been loaded and initialized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the &lt;em&gt;specific&lt;/em&gt; case of your vimtk initialization, it turns out you don't really need to configure it by calling these functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, as @Matt pointed out, you can do &lt;code&gt;let g:vimtk_default_mappings = 1&lt;/code&gt; and postpone that call until the plugin is sourced normally. And the &lt;code&gt;swapkeys&lt;/code&gt; and &lt;code&gt;quickopen&lt;/code&gt; can use a &lt;code&gt;g:vimtk_extra_mappings&lt;/code&gt; dict specifying your custom mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the initialization ordering of Vim plugins is &lt;em&gt;very well known&lt;/em&gt; to plugin authors, they will usually (or often) export enough knobs through global variables that can be easily set from the vimrc file &lt;em&gt;before&lt;/em&gt; plugin initialization happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So look for those first, as they'll often be able to solve what you're trying to configure without having to resort to using a VimEnter autocmd, or a vim script under &lt;code&gt;~/.vim/after&lt;/code&gt;, or a hack sourcing the plugin script from inside the vimrc file...&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-05T22:00:03.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24476" PostTypeId="2" ParentId="24474" CreationDate="2020-04-05T22:23:52.293" Score="16" Body="&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-V&quot; rel=&quot;noreferrer&quot;&gt;CTRL-V&lt;/a&gt; in Insert mode as a prefix to insert the next key as a literal expression.&lt;/p&gt;&#xA;&lt;p&gt;So if you enter &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;V&lt;/kbd&gt; followed by &lt;kbd&gt;Backspace&lt;/kbd&gt;, you'll get a &lt;code&gt;^?&lt;/code&gt; character inserted.&lt;/p&gt;&#xA;&lt;p&gt;Another option, if you want to enter a character by its number, is to use &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;V&lt;/kbd&gt; followed by a set of digits. (See &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-V_digit&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-V_digit&lt;/code&gt;&lt;/a&gt;.) A backspace character has code 127, so you can enter it with  &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;V&lt;/kbd&gt; followed by &lt;kbd&gt;1&lt;/kbd&gt;&lt;kbd&gt;2&lt;/kbd&gt;&lt;kbd&gt;7&lt;/kbd&gt;, resulting on the same &lt;code&gt;^?&lt;/code&gt; character.&lt;/p&gt;&#xA;&lt;p&gt;(You can inspect the &lt;code&gt;^?&lt;/code&gt; character with the &lt;a href=&quot;https://vimhelp.org/various.txt.html#ga&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;ga&lt;/code&gt;&lt;/a&gt; command, which will show &lt;code&gt;&amp;lt;^?&amp;gt;  127,  Hex 7f,  Oct 177, Digr DT&lt;/code&gt;, including the character code in decimal, hexadecimal and octal.)&lt;/p&gt;&#xA;&lt;p&gt;In fact, one more way to enter this character is using Vim's &lt;a href=&quot;https://vimhelp.org/digraph.txt.html&quot; rel=&quot;noreferrer&quot;&gt;digraph&lt;/a&gt; support. In this case, you can use &lt;kbd&gt;CTRL&lt;/kbd&gt;-&lt;kbd&gt;K&lt;/kbd&gt; followed by &lt;kbd&gt;D&lt;/kbd&gt;, then &lt;kbd&gt;T&lt;/kbd&gt;, both uppercase, to enter the same &lt;code&gt;^?&lt;/code&gt; character. You can use the &lt;code&gt;:digraphs&lt;/code&gt; command to get a table with all available digraphs.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="23564" LastEditDate="2022-02-15T15:12:48.630" LastActivityDate="2022-02-15T15:12:48.630" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24477" PostTypeId="2" ParentId="24452" CreationDate="2020-04-06T00:32:36.210" Score="1" Body="&lt;p&gt;From the error message you're getting, it seems your Vim doesn't have Ruby support compiled in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/vim/vim/blob/v8.2.0/runtime/autoload/rubycomplete.vim#L20,L26&quot; rel=&quot;nofollow noreferrer&quot;&gt;this code snippet&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;if !has('ruby')&#xA;    call s:ErrMsg( &quot;Error: Rubycomplete requires vim compiled with +ruby&quot; )&#xA;    call s:ErrMsg( &quot;&lt;b&gt;Error: falling back to syntax completion&lt;/b&gt;&quot; )&#xA;    &quot; lets fall back to syntax completion&#xA;    setlocal omnifunc=syntaxcomplete#Complete&#xA;    finish&#xA;endif&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error message in bold is the one you're seeing. (If you type &lt;code&gt;:messages&lt;/code&gt; you'll probably see the other, more explicit error message, about support for Ruby missing.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can confirm that Ruby support is missing by using the &lt;code&gt;:version&lt;/code&gt; command in Vim to get a list of features. You'll see &lt;code&gt;-ruby&lt;/code&gt;, since you're missing Ruby support. (You'd see &lt;code&gt;+ruby&lt;/code&gt; if it was available.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From your question, you're using NeoVim on Debian Buster, so maybe try installing the &lt;a href=&quot;https://packages.debian.org/buster/ruby-neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;ruby-neovim&lt;/code&gt; package&lt;/a&gt; to see if that solves the problem and enables Ruby support on your NeoVim?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;set omnifunc=syntaxcomplete#Complete&lt;/code&gt; seems to work. Not sure if that is the correct way?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is going to give you &lt;em&gt;some&lt;/em&gt; completion, but probably not as rich as the Ruby-specific completion from &lt;code&gt;rubycomplete&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;syntaxcomplete#Complete&lt;/code&gt; function will use Vim's syntax highlighting rules to offer insert completion, which for the most part covers language keywords that are highlighted by syntax rules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/insert.txt.html#ft-syntax-omni&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help ft-syntax-omni&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vim has the ability to color syntax highlight nearly 500 languages.  Part of&#xA;  this highlighting includes knowing what keywords are part of a language.  Many&#xA;  filetypes already have custom completion scripts written for them, the&#xA;  syntaxcomplete plugin provides basic completion for all other filetypes.  It&#xA;  does this by populating the omni completion list with the text Vim already&#xA;  knows how to color highlight.  It can be used for any filetype and provides a&#xA;  minimal language-sensitive completion.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So this might be adequate and better than nothing... But I'd expect you'd get superior completion by using &lt;code&gt;rubycomplete&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;With these settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1&#xA;autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1&#xA;autocmd FileType ruby,eruby let g:rubycomplete_rails = 1&#xA;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;These are globals and are intended to be set &lt;em&gt;directly&lt;/em&gt; from your vimrc and not in a filetype autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This might be important since you might have ordering issues (these are only set after the vim-ruby plugins try to inspect them, producing the incorrect result), or you might get different behavior from the first Ruby file you edit to the subsequent ones (since the first one sets them &lt;em&gt;globally&lt;/em&gt;, they'll already be set when the second file is opened.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just avoid these issues altogether by setting them directly, as intended:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:rubycomplete_buffer_loading = 1&#xA;let g:rubycomplete_classes_in_global = 1&#xA;let g:rubycomplete_rails = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-06T00:32:36.210" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24478" PostTypeId="2" ParentId="24473" CreationDate="2020-04-06T05:18:45.137" Score="4" Body="&lt;p&gt;As I don't know where to find the &quot;written&quot; rules, I digged into the source code instead. Also note that there are both Vim and Neovim, but it looks that they still share almost the same code in this regard, so the following applies to both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, let me remind that there is rtp-order and load-order, and they are different, as it becomes clear from comparing the output of &lt;code&gt;:set rtp?&lt;/code&gt; and &lt;code&gt;:scriptnames&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So Vim does the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Execute &lt;code&gt;:h --cmd&lt;/code&gt; if any&lt;/li&gt;&#xA;&lt;li&gt;Source startup scripts (like &lt;code&gt;.vimrc&lt;/code&gt; and stuff). Note that &lt;code&gt;.vimrc&lt;/code&gt; may use &lt;code&gt;:packloadall&lt;/code&gt; and such to force early plugins load&lt;/li&gt;&#xA;&lt;li&gt;Save a copy of &lt;code&gt;&amp;amp;rtp&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Add plugins directories to &lt;code&gt;&amp;amp;rtp&lt;/code&gt; (needed to make sure all &lt;code&gt;autoload&lt;/code&gt;'s are found).&lt;/li&gt;&#xA;&lt;li&gt;Load standard plugins (i.e. &lt;code&gt;plugin/**/*.vim&lt;/code&gt; from saved &lt;code&gt;&amp;amp;rtp&lt;/code&gt;, except for &lt;code&gt;after&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Load user plugins (i.e. &lt;code&gt;pack/*/start/*&lt;/code&gt; from &lt;code&gt;&amp;amp;packpath&lt;/code&gt;!)&lt;/li&gt;&#xA;&lt;li&gt;Source &lt;code&gt;after&lt;/code&gt;-plugins from new (current) &lt;code&gt;&amp;amp;rtp&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now you ask about step (4) explicitly. On this step Vim finds every &lt;code&gt;pack/*/start/*&lt;/code&gt; from &lt;code&gt;&amp;amp;packpath&lt;/code&gt; and, if it's not yet in &lt;code&gt;&amp;amp;rtp&lt;/code&gt;, adds it. The relevant code is in function named &lt;code&gt;add_pack_dir_to_rtp()&lt;/code&gt; found in &lt;code&gt;src/scriptfile.c&lt;/code&gt; (Vim) or &lt;code&gt;src/ex_cmds2.c&lt;/code&gt; (Neovim).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I understand, it simply takes the path prefix (before &lt;code&gt;pack/...&lt;/code&gt; part) and tries to find the first match (like &lt;code&gt;strncmp()&lt;/code&gt; with the length of the prefix) in the current &lt;code&gt;&amp;amp;rtp&lt;/code&gt; and put it just after it. Hence all the user plugins paths normally go after &lt;code&gt;~/.vim&lt;/code&gt; but in reverse order (compared to their natural find-and-load-order). If no match was found then the item is appended to &lt;code&gt;&amp;amp;rtp&lt;/code&gt; (with respect to &lt;code&gt;after&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2020-04-06T05:25:50.833" LastActivityDate="2020-04-06T05:25:50.833" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24479" PostTypeId="1" CreationDate="2020-04-06T08:32:16.987" Score="0" ViewCount="47" Body="&lt;p&gt;I want to go to the search result in the right-window, identified after performing a &lt;code&gt;/urllib&lt;/code&gt; search in the left window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;code&gt;n\N&lt;/code&gt; doesn't proceed to search results in other windows. How can I proceed to search results in other windows?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/l2t3B.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/l2t3B.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26505" LastActivityDate="2020-05-10T17:10:11.340" Title="How to go to search results located in other windows?" Tags="|search|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24480" PostTypeId="2" ParentId="23122" CreationDate="2020-04-06T16:51:48.413" Score="1" Body="&lt;p&gt;After all I solved this problem using &lt;strong&gt;sed&lt;/strong&gt; linux utilit. My solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some-cli | sed &quot;s/\x1b\[[0-9;]*m//g&quot; | some-errorformat-vim-tool&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;sed &quot;s/\x1b\[[0-9;]*m//g&quot;&lt;/code&gt; remove all ansi-codes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This answer helped my: &lt;a href=&quot;https://vi.stackexchange.com/questions/485/can-vim-interpret-terminal-color-escape-codes&quot;&gt;Can Vim interpret terminal color escape codes?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="27293" LastActivityDate="2020-04-06T16:51:48.413" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24482" PostTypeId="1" CreationDate="2020-04-07T03:12:42.000" Score="1" ViewCount="883" Body="&lt;p&gt;While ssh'd into my server, vim hangs for a variable amount of time (about 2 seconds, but can be longer or shorter) when opening and closing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's worth noting that (to my eyes) the delay is the exact same while opening and closing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This delay is the exact same when using &lt;code&gt;vim -u NONE&lt;/code&gt; which, to me, implies this isn't an issue with my plugins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried startup profiling but nothing jumped out to me, though this could just be me not knowing what to look for.&#xA;EDIT: I've confirmed that the delay happens &lt;em&gt;before&lt;/em&gt; Vim starts, meaning that any vim profiling I do is irrelevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was just going to deal with this until I found a big clue:&#xA;Setting &lt;code&gt;t_ti=&quot;&quot;&lt;/code&gt; and &lt;code&gt;t_te=&quot;&quot;&lt;/code&gt; almost completely got rid of the delay!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has the unfortunate side effect of not returning my terminal to what it looked like before opening Vim, which, unfortunately, is a deal breaker for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With all of this information, does anyone have any idea how I might diagnose/fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm happy to add additional diagnostics, please just let me know what you'd find useful.&#xA;I also have some recordings demonstrating this behavior that I could share.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;System information:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Remote OS: Ubuntu 16.04.6 LTS&#xA;Local OS: Windows 10&#xA;Local emulator: Cmndr ( https://cmder.net/ )&#xA;Remote terminal: xterm (I manually set this so that my terminal is retained after exiting vim)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Remote vim install info:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 31 2018 12:22:50)&#xA;Included patches: 1-501&#xA;Compiled by user@host&#xA;Huge version with GTK2 GUI.  Features included (+) or not (-):&#xA;+acl               +extra_search      +mouse_netterm     +tag_old_static&#xA;+arabic            +farsi             +mouse_sgr         -tag_any_white&#xA;+autocmd           +file_in_path      -mouse_sysmouse    -tcl&#xA;+autochdir         +find_in_path      +mouse_urxvt       +termguicolors&#xA;-autoservername    +float             +mouse_xterm       +terminal&#xA;+balloon_eval      +folding           +multi_byte        +terminfo&#xA;+balloon_eval_term -footer            +multi_lang        +termresponse&#xA;+browse            +fork()            -mzscheme          +textobjects&#xA;++builtin_terms    +gettext           +netbeans_intg     +timers&#xA;+byte_offset       -hangul_input      +num64             +title&#xA;+channel           +iconv             +packages          +toolbar&#xA;+cindent           +insert_expand     +path_extra        +user_commands&#xA;+clientserver      +job               -perl              +vartabs&#xA;+clipboard         +jumplist          +persistent_undo   +vertsplit&#xA;+cmdline_compl     +keymap            +postscript        +virtualedit&#xA;+cmdline_hist      +lambda            +printer           +visual&#xA;+cmdline_info      +langmap           +profile           +visualextra&#xA;+comments          +libcall           -python            +viminfo&#xA;+conceal           +linebreak         +python3           +vreplace&#xA;+cryptv            +lispindent        +quickfix          +wildignore&#xA;+cscope            +listcmds          +reltime           +wildmenu&#xA;+cursorbind        +localmap          +rightleft         +windows&#xA;+cursorshape       -lua               -ruby              +writebackup&#xA;+dialog_con_gui    +menu              +scrollbind        +X11&#xA;+diff              +mksession         +signs             -xfontset&#xA;+digraphs          +modify_fname      +smartindent       +xim&#xA;+dnd               +mouse             +startuptime       +xpm&#xA;-ebcdic            +mouseshape        +statusline        +xsmp_interact&#xA;+emacs_tags        +mouse_dec         -sun_workshop      +xterm_clipboard&#xA;+eval              -mouse_gpm         +syntax            -xterm_save&#xA;+ex_extra          -mouse_jsbterm     +tag_binary&#xA;   system vimrc file: &quot;$VIM/vimrc&quot;&#xA;     user vimrc file: &quot;$HOME/.vimrc&quot;&#xA; 2nd user vimrc file: &quot;~/.vim/vimrc&quot;&#xA;      user exrc file: &quot;$HOME/.exrc&quot;&#xA;  system gvimrc file: &quot;$VIM/gvimrc&quot;&#xA;    user gvimrc file: &quot;$HOME/.gvimrc&quot;&#xA;2nd user gvimrc file: &quot;~/.vim/gvimrc&quot;&#xA;       defaults file: &quot;$VIMRUNTIME/defaults.vim&quot;&#xA;    system menu file: &quot;$VIMRUNTIME/menu.vim&quot;&#xA;  fall-back for $VIM: &quot;/usr/local/share/vim&quot;&#xA;Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1&#xA;Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -ldl     -L/usr/lib/python3.5/config -lpython3.5m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10484" LastEditorUserId="10484" LastEditDate="2020-04-07T19:40:46.827" LastActivityDate="2020-05-09T13:06:05.770" Title="Vim takes a long time to close over SSH?" Tags="|vimrc|terminal|performance|linux-ubuntu|ssh|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24483" PostTypeId="1" AcceptedAnswerId="24487" CreationDate="2020-04-07T03:31:45.017" Score="5" ViewCount="1337" Body="&lt;p&gt;I understand that we can use &lt;code&gt;da{&lt;/code&gt; to delete a whole &lt;code&gt;{}&lt;/code&gt; block in vim. I am wondering if there is a corresponding version with &lt;code&gt;{&lt;/code&gt; replaced by &lt;code&gt;$&lt;/code&gt; (similarly for &lt;code&gt;di{&lt;/code&gt;) as this would be very useful for people typing latex with vim (math enviroments are enclosed between 2 &lt;code&gt;$&lt;/code&gt; symbols).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to make my own&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map da$ ?\$?&amp;lt;CR&amp;gt;v/\$/e&amp;lt;CR&amp;gt;d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it's very slow.&lt;/p&gt;&#xA;" OwnerUserId="28806" LastEditorUserId="10604" LastEditDate="2020-04-07T14:42:38.927" LastActivityDate="2020-05-06T10:15:18.090" Title="Delete text between two $ symbols in gvim" Tags="|key-bindings|filetype-tex|operator-pending-mode|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24484" PostTypeId="1" AcceptedAnswerId="24490" CreationDate="2020-04-07T03:43:50.203" Score="3" ViewCount="3421" Body="&lt;p&gt;This problem that seems trivial is beating me real hard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to create a couple of syntax highlighting directives for a custom language that is structured in paragraphs separated by at least one empty line. The language specifies that paragraphs can eiter:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;End with punctuation&lt;/li&gt;&#xA;&lt;li&gt;End without punctuation&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Each of these cases must have different highlighting properties. On the images below I have one example structure demonstrating what I need to achieve:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Case 1: Paragraphs that ends with some punctuation comprises one highlighting group:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KkMhl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KkMhl.png&quot; alt=&quot;Case 1: Paragraphs that ends with punctuation&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Case 2: Paragraphs that ends without punctuation comprises another highlighting group:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/im6TE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/im6TE.png&quot; alt=&quot;Case 2: Paragraphs that ends without punctuation&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got no luck with &lt;code&gt;syn region&lt;/code&gt;, since there are no constant start/end characters surrounding the blocks of text, so I'm trying to solve this with &lt;code&gt;syn match&lt;/code&gt; and thus I'm exploring the possibilities with complete regexes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First I've verified that &lt;code&gt;\n$&lt;/code&gt; correctly maps to the end of every paragraph, and that &lt;code&gt;^$\n&lt;/code&gt; correctly maps the empty lines, so I composed them as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^$\n\_.\{-}\n$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which matches all paragraphs except the first one. So I implemented:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(\%^\|^$\n\)\_.\{-}\n$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which correctly matches all paragraphs, but when I tried to account for the punctuation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(\%^\|^$\n\)\_.\{-}\.\n$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It became clear that the &lt;code&gt;\_.&lt;/code&gt; operator, even with the non-greedy multi &lt;code&gt;\{-}&lt;/code&gt; just ignores the &lt;code&gt;\.&lt;/code&gt; bit on the rule, and will match every paragraph from the start of the file, even the ones that do not end with a &lt;code&gt;.&lt;/code&gt;, up to the last paragraph on the file that ends with a &lt;code&gt;.&lt;/code&gt; . The weird thing to me is that even that it matches every paragraph on the file up to the last one ending with a &lt;code&gt;.&lt;/code&gt;, the match returns a distinct result count (more than one result). In this case I would expect a single match. What is happening here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I've read all the manuals and I'm clueless regarding what strategy to use from here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help will be greatly appreciated. Thank you!&lt;/p&gt;&#xA;" OwnerUserId="28804" LastActivityDate="2021-07-30T08:45:44.500" Title="How to match paragraphs of text ending with a character?" Tags="|regular-expression|macvim|syntax|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24485" PostTypeId="2" ParentId="24483" CreationDate="2020-04-07T08:39:11.227" Score="0" Body="&lt;p&gt;I tried these and seemed to work and be fast:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap ca$ f$vF$c &quot;Change with $&#xA;nnoremap da$ f$vF$d &quot;Delete with $&#xA;nnoremap ci$ f$hvF$lc &quot;Change in $&#xA;nnoremap di$ f$hvF$lc &quot;Delete in $&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes that you can't have a $ inside $..$. What it does is it searches for the first next occurance of $ then does a visual block. Then does a reverse search to find the previous $. Having selected visually the $...$ it just does a c for change or d for delete. Same for the 2 below which all they do is they move one to the left and to the right so it doesn't select the $. &lt;/p&gt;&#xA;" OwnerUserId="8403" LastActivityDate="2020-04-07T08:39:11.227" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24486" PostTypeId="2" ParentId="24483" CreationDate="2020-04-07T09:06:14.270" Score="3" Body="&lt;p&gt;If you are not against plugins, you can try &lt;code&gt;targets.vim&lt;/code&gt; &lt;a href=&quot;https://github.com/wellle/targets.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/wellle/targets.vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has &lt;code&gt;$&lt;/code&gt; separator text object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SEPARATOR TEXT OBJECTS                        *targets-separator-text-objects*&#xA;&#xA;These text objects are based on single separator characters like the comma in&#xA;one of our |targets-examples|. The text between two instances of the separator&#xA;character can be operated on with these targets.&#xA;&#xA;Supported separators:&#xA;&#xA;    , . ; : + - = ~ _ * # / | \ &amp;amp; $ ~&#xA;&#xA;Separator text objects work over multiple lines and support&#xA;|targets-separator-seek|.&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-04-07T09:06:14.270" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24487" PostTypeId="2" ParentId="24483" CreationDate="2020-04-07T09:06:17.123" Score="3" Body="&lt;p&gt;Such a mapping is quite hard to get right, including all corner cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically, you should try to use an &quot;operator-pending&quot; mapping to define the &lt;code&gt;a$&lt;/code&gt; part, so you can use it in &lt;code&gt;da$&lt;/code&gt; but also in commands such as &lt;code&gt;ya$&lt;/code&gt;, &lt;code&gt;ca$&lt;/code&gt;, etc. In fact if you define other custom commands that take a &quot;motion&quot;, then &lt;code&gt;a$&lt;/code&gt; will be a valid one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A naive solution using an operator-pending mapping &lt;em&gt;and&lt;/em&gt; assuming the &lt;code&gt;$...$&lt;/code&gt; expression is in a single line (for inline math in TeX/LaTeX) would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;silent&amp;gt; a$ :&amp;lt;C-U&amp;gt;normal! F$v,&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this has some shortcomings, such as it only working from inside the &lt;code&gt;$...$&lt;/code&gt; block (not from the cursor being right at the first &lt;code&gt;$&lt;/code&gt;) or if you have two &lt;code&gt;$...$&lt;/code&gt; blocks on the same line this mapping &lt;em&gt;will&lt;/em&gt; select the text between the two if your cursor is on that region.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get Vim to use more advanced logic to select the delimiters for such a region very precisely, but that probably involves writing a Vimscript function to handle all corner cases correctly. (You can also do that to handle more complex matches such as a math environment covering multiple lines.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately, there are plug-ins which can help you with that!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to define your own, then the &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-user&lt;/a&gt; plug-in can help you create new operator-pending mappings (and also visual mappings) based on patterns you define. This plug-in hides a lot of the complexity of these mappings in a way that avoids many of the pitfalls. Also, in many cases, using a simple regex to define the region to use as a text object is a much simpler approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're looking specifically into TeX/LaTeX, then consider the &lt;a href=&quot;https://github.com/lervag/vimtex&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimtex&lt;/a&gt; plug-in, which already defines an &lt;code&gt;a$&lt;/code&gt; text object for inline math structures. Also an &lt;code&gt;ae&lt;/code&gt; for LaTeX environments, which you might find useful as well.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-07T09:06:17.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24489" PostTypeId="1" CreationDate="2020-04-07T16:54:11.717" Score="1" ViewCount="232" Body="&lt;p&gt;I'm highlighting folds and color columns in colors different from the background and from each other. Here's an excerpt of my vimrc with all (potentially) relevant lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.vimrc&#xA;&#xA;...&#xA;&#xA;&quot; Folding                &amp;lt;- maybe relevant?&#xA;set foldmethod=syntax&#xA;set foldcolumn=1&#xA;set foldclose=&#xA;&#xA;...&#xA;&#xA;set termguicolors&#xA;set t_Co=256&#xA;set background=dark&#xA;&quot; colorscheme ...        &amp;lt;- none other than default&#xA;&#xA;highlight ColorColumn guibg=darkslategray  &quot; incomplete&#xA;highlight Folded      guibg=black          &quot; incomplete&#xA;&#xA;syntax on&#xA;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This highlights the folds a bit darker than my background and the color columns a bit lighter. What bugs me is that the color columns are drawn on top of the folds, i.e., are vertically continuous, breaking up the folds in the horizontal. I'd prefer it the other way round (as in my mind it makes more sense for the color columns to be folded into the folds along with the overlying text).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is is possible to highlight folds on top of color columns rather than below?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;PS: My setup: Vim v8.2 in a PuTTY v0.73 terminal (Manjaro Virtualbox on Windows 10).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;PPS: I'm well aware that the &lt;code&gt;highlight&lt;/code&gt;s are not robust/portable in this form as they are missing entries like &lt;code&gt;ctermbg&lt;/code&gt; etc. -- this is just what works in my current setup.&lt;/p&gt;&#xA;" OwnerUserId="2100" LastActivityDate="2020-04-07T16:54:11.717" Title="Highlight color columns on top of folds (not below)" Tags="|vimrc|folding|colorcolumn|highlighting|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24490" PostTypeId="2" ParentId="24484" CreationDate="2020-04-07T18:40:59.933" Score="1" Body="&lt;p&gt;Here's what I came up with:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Solution 1&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To match the paragraphs ending with a dot:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(\%^\|^\n\)\zs\(.\+\n\)*.\+[.]\ze\(\n\n\|\n*\%$\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To match the paragraphs ending with no dot:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(\%^\|^\n\)\zs\(.\+\n\)*.\+[^.]\ze\(\n\n\|\n*\%$\)&#xA;#                            ^&#xA;#                      This is added&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or with the &lt;code&gt;very magic&lt;/code&gt; flag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\v(%^|^\n)\zs(.+\n)*.+[.]\ze(\n\n|\n*%$)&#xA;# AND&#xA;\v(%^|^\n)\zs(.+\n)*.+[^.]\ze(\n\n|\n*%$)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Explanations&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;(%^|^\n)&lt;/code&gt; marks the beggining of a paragraph, might be the begging of the file as well so we add &lt;code&gt;%^&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(.+\n)&lt;/code&gt; is one line, it can contain anything as long as it's not empty&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;*&lt;/code&gt; We want our paragraph to have as many line as it wants&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.+[.]&lt;/code&gt; is the &lt;strong&gt;last line&lt;/strong&gt;, which has to end with a dot&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(\n\n|\n*%$)&lt;/code&gt; Is the end of the paragraph, which might also be the endo of the file (&lt;code&gt;%$&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Solution 2&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here's another solution that looks a bit more like your initial idea:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(^\n\|\%^\)\zs\(\_.\(\n\n\)\@!\)*[.]\ze\(\n$\|\%$\)&#xA;\(^\n\|\%^\)\zs\(\_.\(\n\n\)\@!\)*[^.]\ze\(\n$\|\%$\)&#xA;&#xA;# With the Very special flag:&#xA;&#xA;\v(^\n|%^)\zs(\_.(\n\n)@!)*[.]\ze(\n$|%$)&#xA;\v(^\n|%^)\zs(\_.(\n\n)@!)*[^.]\ze(\n$|%$)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Explanations:&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;(^\n|%^)&lt;/code&gt; to start the paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(\_.(\n\n)@!)&lt;/code&gt; is any character (including newline) which is &lt;strong&gt;not followed by 2 newlines&lt;/strong&gt;. in other words, any character which is not the end of a paragraph. (It's a negative look ahead, &lt;code&gt;:help \@!&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;*&lt;/code&gt; We want that character as many times as possible&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;[.]&lt;/code&gt; is the &lt;strong&gt;last character of the paragraph&lt;/strong&gt; (could be replaced by &lt;code&gt;\.&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(\n$|%$)&lt;/code&gt; to end the paragraph&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="27331" LastEditDate="2020-04-07T19:17:35.717" LastActivityDate="2020-04-07T19:17:35.717" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24491" PostTypeId="1" AcceptedAnswerId="24508" CreationDate="2020-04-07T23:19:14.950" Score="1" ViewCount="142" Body="&lt;p&gt;Preface: I might be asking the wrong question, so I'll just say what my problem is first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever I use &lt;code&gt;^Z&lt;/code&gt; to background vim, then later (can be hours later) run &lt;code&gt;fg&lt;/code&gt; to bring it back, YouCompleteMe doesn't do any completion (however, it &lt;em&gt;does&lt;/em&gt; sometimes say below the status line that it needs to be restarted)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A workaround has been to run &lt;code&gt;:YcmRestartServer&lt;/code&gt; whenever I foreground vim manually, but I'd like to have that run automatically (if it isn't already running).&lt;/p&gt;&#xA;" OwnerUserId="27486" LastActivityDate="2020-04-09T17:40:42.520" Title="How to automatically run a command after foregrounding" Tags="|plugin-you-complete-me|command|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24492" PostTypeId="1" AcceptedAnswerId="24498" CreationDate="2020-04-07T23:48:09.777" Score="3" ViewCount="206" Body="&lt;p&gt;I have matched parentheses, but highlighting failed as it transcends up the recursion stack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/M0WvK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/M0WvK.png&quot; alt=&quot;Example named.conf simplified syntax&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just need to know if there is a solution to tracking pairs of delimiters during Vim highlight syntax of nested curly braces.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Details&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Was adapting &lt;a href=&quot;https://github.com/isc-projects/bind9&quot; rel=&quot;nofollow noreferrer&quot;&gt;ISC Bind9&lt;/a&gt; named configuration file using &lt;a href=&quot;https://kb.isc.org/docs/aa-01493&quot; rel=&quot;nofollow noreferrer&quot;&gt;their documentation&lt;/a&gt; full of BNF syntax into Vim syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One is the &lt;code&gt;address_match_list&lt;/code&gt; whose BNF is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;address_match_list :=  ( name | number | address_match_list ) ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's easy to make that Vim syntax for above BNF for 1st time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, the actual usage of &lt;code&gt;address_match_list&lt;/code&gt; in a recursive manner, it lost the tracking of closing curly braces and no longer highlights on the way back up the recursion stack (if there is any).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match xyz_Semicolon contained /;/ skipwhite skipempty&#xA;\ containedin=xyz_AML&#xA;&#xA;syn match xyz_Number contained &quot;\&amp;lt;\d\{1,10}\&amp;gt;&quot; skipwhite skipempty&#xA;\ nextgroup=xyz_Semicolon&#xA;\ containedin=xyz_AML&#xA;&#xA;&quot; { ... }  ;&#xA;syn region xyz_AML contained start=+{+ end=+}+ skipwhite skipempty&#xA;\ nextgroup=&#xA;\    xyz_Number,&#xA;\    xyz_Semicolon&#xA;&#xA;&quot; &amp;lt;acl_name&amp;gt; ( &amp;lt;number&amp;gt; | { ... } ) ;&#xA;syn match xyz_ACLIdent contained /\&amp;lt;[0-9a-zA-Z\-_]\{1,63}\&amp;gt;/ skipwhite&#xA;\ nextgroup=&#xA;\    xyz_AML,&#xA;\    xyz_Number&#xA;&#xA;syn match xyz_Keywords /\_^\s*\&amp;lt;acl\&amp;gt;/ skipempty skipwhite&#xA;\ nextgroup=xyz_ACLIdent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the condensed (but working) config file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;acl e 127;&#xA;acl internal-net {&#xA;    127; 10; 192;&#xA;};&#xA;acl an_internal_vps_ntwk {&#xA;    192;&#xA;    {&#xA;        172;&#xA;        {&#xA;            5;&#xA;        };&#xA;        6;&#xA;    };&#xA;    112;&#xA;};  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All files can be found in PasteBin&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pastebin.com/rQqw58Eh&quot; rel=&quot;nofollow noreferrer&quot;&gt;syntax/mytest.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pastebin.com/Kn6euVgn&quot; rel=&quot;nofollow noreferrer&quot;&gt;ftdetect/mytest.vim&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pastebin.com/35sa1C8y&quot; rel=&quot;nofollow noreferrer&quot;&gt;example-mytest.conf&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18880" LastEditorUserId="18880" LastEditDate="2020-04-08T18:50:18.310" LastActivityDate="2020-04-08T18:50:18.310" Title="Rules for 2-tier recursive syntaxes" Tags="|syntax-highlighting|delimiter-matching|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24493" PostTypeId="1" AcceptedAnswerId="24494" CreationDate="2020-04-08T07:02:27.690" Score="7" ViewCount="1916" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Does Vim have functionality similar to tmux's &lt;code&gt;display-panes&lt;/code&gt; command&#xA;  for selecting (goto) a specific window by number?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sometimes when I've many windows open, it can be a pain to navigate them by &lt;code&gt;C-w h&lt;/code&gt; (left), &lt;code&gt;C-w j&lt;/code&gt; (down), &lt;code&gt;C-w k&lt;/code&gt; (up), and &lt;code&gt;C-w l&lt;/code&gt; (right). In that case, I miss functionality similar to &lt;code&gt;tmux&lt;/code&gt;'s &lt;code&gt;display-panes&lt;/code&gt; command, which lets me select (goto) a specific pane by its number:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bind-key    -T prefix       q                     display-panes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does &lt;code&gt;vim&lt;/code&gt; have similar functionality?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/edza8.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/edza8.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26505" LastActivityDate="2022-12-05T12:36:19.943" Title="Does Vim have functionality similar to tmux's `display-panes` command for selecting (goto) a specific window by number?" Tags="|terminal|vim-windows|tmux|mouse|jump|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24494" PostTypeId="2" ParentId="24493" CreationDate="2020-04-08T07:21:19.687" Score="7" Body="&lt;p&gt;I'm not aware of any Vim feature or even plugin that does that; in fact, up until recently it would be rather hard to display it like that, but with Vim 8.2's &lt;a href=&quot;https://vi.stackexchange.com/q/24462/51&quot;&gt;popup windows&lt;/a&gt; it wouldn't be too hard; you just have to loop over all visible windows and create a new popup window displaying the window number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest thing you can get, which may actually be enough, is displaying the window number in the statusline by adding &lt;code&gt;%{winnr()}&lt;/code&gt;; you can then use &lt;code&gt;[nr]&amp;lt;C-w&amp;gt;w&lt;/code&gt; to switch to a specific window.&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-04-08T13:06:59.823" LastActivityDate="2020-04-08T13:06:59.823" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24496" PostTypeId="1" CreationDate="2020-04-08T16:22:37.770" Score="3" ViewCount="242" Body="&lt;p&gt;Using &lt;code&gt;set confirm&lt;/code&gt; or the confirm-quit plugin makes it so that vim always confirms quit. But in &lt;strong&gt;gvim&lt;/strong&gt;, if you just press the X at the top, it always quits -- no confirmation (unless the file is unsaved)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes I open 3+ tabs with several buffers in each -- if I reflexively hit that X when everything is saved, then &quot;Boom&quot;, the whole workspace is gone. I'd really like a confirmation box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0vAZX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0vAZX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="28833" LastActivityDate="2020-04-08T16:22:37.770" Title="How to make gvim always confirm quit when pressing the X button on the window" Tags="|gvim|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24497" PostTypeId="1" CreationDate="2020-04-08T18:12:56.233" Score="0" ViewCount="501" Body="&lt;p&gt;I've noticed that sometimes in ViM the status bar shows me the command I've just executed (for instance, if I keep the key 'l' pressed to keep going right, I see at the bottom right of the screen a blinking 'l'). This is useful if I'm typing a composite command such as &lt;code&gt;d3j&lt;/code&gt;, but it's annoying to see this &quot;immediate&quot; commands blinking at the bottom of the screen. Is there a way to disable this behavior only for the latter (i.e. &quot;immediate&quot;) commands?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I noticed it happens only with python files (.py). I do not know if this helps...&lt;/p&gt;&#xA;" OwnerUserId="22833" LastEditorUserId="22833" LastEditDate="2020-04-08T20:57:55.590" LastActivityDate="2020-04-08T20:57:55.590" Title="Remove command echo in status bar" Tags="|normal-mode|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24498" PostTypeId="2" ParentId="24492" CreationDate="2020-04-08T18:28:29.660" Score="3" Body="&lt;p&gt;After reading the syn-extend and the use of &lt;a href=&quot;https://vimhelp.org/syntax.txt.html#%3asyn-extend&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;keepend&lt;/code&gt; and &lt;code&gt;extend&lt;/code&gt;&lt;/a&gt; keywords, I used &lt;code&gt;Error&lt;/code&gt; for my first region syntax and &lt;code&gt;Todo&lt;/code&gt; for that last character after the region (semicolon). My recursive &lt;code&gt;region&lt;/code&gt; is foreground white-colored.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a bit of a bit of trial and error, got it to work:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dKWDR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dKWDR.png&quot; alt=&quot;Working 2-tiered recursion of Vim syntaxes&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then started to pare-down all non-essential keywords until it just works.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syn match xyz_Semicolon contained /;/&#xA;&#xA;syn match xyz_AML_Nested_Semicolon contained /;/ skipwhite skipempty&#xA;\ nextgroup=&#xA;\    xyz_AML_Placeholder&#xA;&#xA;syn match xyz_Number &quot;\&amp;lt;\d\{1,10}\&amp;gt;&quot; skipwhite skipempty&#xA;\ nextgroup=&#xA;\    xyz_AML_Nested_Semicolon&#xA;&#xA;syn region xyz_AML_Placeholder contained start=+{+ end=+}+ keepend extend&#xA;\ contains=&#xA;\    xyz_Number,&#xA;\    xyz_AML_Nested_Semicolon&#xA;\ nextgroup=&#xA;\    xyz_AML_Nested_Semicolon&#xA;&#xA;&quot; acl &amp;lt;acl_name&amp;gt; { ... } ;&#xA;syn region xyz_AML contained start=+{+ end=+}+  skipwhite skipempty&#xA;\ contains=&#xA;\    xyz_Number,&#xA;\    xyz_AML_Nested_Semicolon&#xA;\ nextgroup=&#xA;\    xyz_Semicolon&#xA;&#xA;&quot; acl &amp;lt;acl_name&amp;gt; { ... } &#xA;syn match xyz_ACLIdent contained /\&amp;lt;[0-9a-zA-Z\-_]\{1,63}\&amp;gt;/ skipwhite skipempty&#xA;\ nextgroup=&#xA;\    xyz_AML&#xA;&#xA;&quot; acl &amp;lt;acl_name&amp;gt; ...&#xA;syn match xyz_Keywords /acl/ skipwhite skipempty&#xA;\ nextgroup=xyz_ACLIdent&#xA;&#xA;syn match xyz_Keywords /test/ skipwhite skipempty&#xA;\ nextgroup=xyz_Number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Analysis:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The key thing during your Vim syntax debugging effort (other than the constant reloading) is to make use of:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Error&lt;/code&gt; highlight to color your &lt;code&gt;region&lt;/code&gt; as red and &lt;/li&gt;&#xA;&lt;li&gt;a bright color (&lt;code&gt;Todo&lt;/code&gt;) for its last character after the region (semicolon).  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;While you debug (or randomly try) new syntax, and you get that last character to stay properly colorized as &lt;code&gt;xyz_Semicolon&lt;/code&gt;, you will then be able to rock the rest of the syntaxes until you're happy, knowingly that you preserved your multiple nesting (recursive syntax).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case, I had two cases of near-duplication of the same &lt;code&gt;region&lt;/code&gt; syntax.  Most of you wouldn't be facing this (unless you're a NeoVim or a Python Vim syntax maintainer).  Reason is I need two similar &lt;code&gt;region&lt;/code&gt; syntaxes, is to perform a &quot;tee-off&quot; of limited capability before going into full-recursion syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full recursion is the following BNF:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;address_match_list :== ( number | address_match_list ) ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I had to wrap the &lt;code&gt;address_match_list&lt;/code&gt; with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;acl_keyword :== 'acl'&#xA;acl_identifier :== [a-zA-Z0-9_\.\-]{1,63}&#xA;acl_AML :== '{' + address_match_list + '}' + ';'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Working test files are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pastebin.com/bFqaYu3m&quot; rel=&quot;nofollow noreferrer&quot;&gt;test named.conf file&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://pastebin.com/4thVn4f1&quot; rel=&quot;nofollow noreferrer&quot;&gt;working syntax/mytest.vim file&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18880" LastActivityDate="2020-04-08T18:28:29.660" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24500" PostTypeId="1" CreationDate="2020-04-09T08:31:41.683" Score="3" ViewCount="2140" Body="&lt;p&gt;I know this question has been asked many times, but what I've noticed is that the majority of them seem to be for gVim or Vim for Windows rather than Linux command line Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm just wondering how I'd be able to change the font style for my terminal Vim. Doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set guifont=Consolas&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't do anything, probably because I'm not using a GUI. Doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set font=Consolas&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives an error because it's an unrecognized line of code.&lt;/p&gt;&#xA;" OwnerUserId="25053" LastActivityDate="2020-04-09T09:45:08.900" Title="How to change font style in Linux terminal?" Tags="|font|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24501" PostTypeId="2" ParentId="24500" CreationDate="2020-04-09T09:45:08.900" Score="4" Body="&lt;p&gt;To change the font used by terminal Vim or Neovim, you need to change the font the your terminal emulator uses. The exact settings vary between different terminal emulators.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you are connecting to your Linux server on Windows via &lt;a href=&quot;https://mintty.github.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;mintty terminal&lt;/a&gt;, you can go to &lt;code&gt;Options --&amp;gt; Text&lt;/code&gt; to change the font.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For other terminal emulators, you can consult their official documentation.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastActivityDate="2020-04-09T09:45:08.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24502" PostTypeId="1" AcceptedAnswerId="24505" CreationDate="2020-04-09T12:07:07.857" Score="2" ViewCount="2516" Body="&lt;p&gt;Here is a typical workflow I would like to follow:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;copy some data from Excel spreadsheet into the clipboard&lt;/li&gt;&#xA;&lt;li&gt;in vim , delete the data in the file using &lt;code&gt;ggdG&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;then paste the data into the file from the clipboard (I use &lt;code&gt;CTRL-V&lt;/code&gt; as I am under Windows)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This does not work because step 2 copies the deleted data into the clipboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to delete without affecting the clipboard ?&lt;/p&gt;&#xA;" OwnerUserId="21293" LastActivityDate="2020-04-09T21:07:55.777" Title="Deleting without copying to clipboard in Windows?" Tags="|cut-copy-paste|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24503" PostTypeId="2" ParentId="24482" CreationDate="2020-04-09T12:31:46.273" Score="1" Body="&lt;p&gt;If &lt;code&gt;$DISPLAY&lt;/code&gt; is (incorrectly) set in your SSH environment, then Vim may be timing out trying to connect to an X server that doesn't exist.  It does this for functionality like copying to/from the X selections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can verify this in a couple of ways.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Check if &lt;code&gt;vim -X&lt;/code&gt; removes the delay&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;a href=&quot;https://vi.stackexchange.com/a/191/15&quot;&gt;&lt;code&gt;vim --startuptime&lt;/code&gt;&lt;/a&gt; to see details about what Vim does when starting up.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The benefit of 2. is that you not only can verify whether the delay is due to the X connection (time will show up in the &lt;code&gt;clipboard setup&lt;/code&gt; line item), but you can see what &lt;em&gt;else&lt;/em&gt; might be affecting your startup time.&lt;/p&gt;&#xA;" OwnerUserId="15" LastActivityDate="2020-04-09T12:31:46.273" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24504" PostTypeId="2" ParentId="24502" CreationDate="2020-04-09T13:51:26.703" Score="2" Body="&lt;p&gt;Of course, everything is possible in Vim!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a register system in vim, and the clipboard is the register &lt;code&gt;+&lt;/code&gt; (or &lt;code&gt;*&lt;/code&gt;, it depends)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, the text you cut is put in the clipboard register, but you can put it in a black hole register (&lt;code&gt;:h quote_&lt;/code&gt;) like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg&quot;_dG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&quot;_&lt;/code&gt; here tells vim to put what you're about to cut in a black hole register, so your &lt;code&gt;+&lt;/code&gt; register (a.k.a. your clipboard) stays untouched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the magic doesn't stop there, if it's a task you do often, you can set up a &lt;strong&gt;mapping&lt;/strong&gt; to do that, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gd gg&quot;_dG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that next time you need to delete a whole file, you just need to hit &lt;code&gt;gd&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally have a mapping on my &lt;code&gt;\&lt;/code&gt; key like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap \ &quot;_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when I need to keep my clipboard, I begin my keystrokes with &lt;code&gt;\&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="27331" LastEditDate="2020-04-09T15:09:33.860" LastActivityDate="2020-04-09T15:09:33.860" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="24505" PostTypeId="2" ParentId="24502" CreationDate="2020-04-09T14:46:10.920" Score="4" Body="&lt;p&gt;When deleting the buffer contents in Vim, you can send it to the &lt;em&gt;black hole&lt;/em&gt; register &lt;code&gt;&quot;_&lt;/code&gt;. From &lt;a href=&quot;https://vimhelp.org/change.txt.html#quote_&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help quote_&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When writing to this register, nothing happens.  This can be used to delete&#xA;  text without affecting the normal registers.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So simply use this command in your step 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gg&quot;_dG&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can also use the &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Adelete&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:delete&lt;/code&gt;&lt;/a&gt; command with a range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%d _&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This Ex command deletes every line into the black hole register.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-09T15:22:02.247" LastActivityDate="2020-04-09T15:22:02.247" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24506" PostTypeId="1" CreationDate="2020-04-09T15:04:26.010" Score="0" ViewCount="12" Body="&lt;p&gt;I'm using vim's built in helptags command to create a tags file in LaTeX. While LaTeX files are not the txt files normally used, helptags seems to work just fine, and generates an empty &quot;tags&quot; file and a file titled &quot;tags_te&quot; which is actually the tags file. I add the tags_te file with &quot;set tags+=tags_te&quot; and &lt;em&gt;almost&lt;/em&gt; everything works perfectly. Strangely enough, it &lt;em&gt;did&lt;/em&gt; work perfectly the first time, but every time thereafter, I have had the following problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I search for a tag, whether using &quot;:tag InformationTopography&quot; or  Vim correctly navigates to the first instance of *InformationTopography*. However, entering &quot;:tnext&quot; takes me to the first instance of *InformationTopography* in the &lt;em&gt;next file&lt;/em&gt; not to the next instance in the same file. Strangely the 'tags_te' file has all the instances listed correctly. I have tried moving the tags_te file to be the tags file, but no difference.&lt;/p&gt;&#xA;" OwnerUserId="16156" LastActivityDate="2020-04-09T15:04:26.010" Title="&quot;tnext&quot; command skips to next file" Tags="|ctags|tags|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24507" PostTypeId="1" CreationDate="2020-04-09T15:10:44.610" Score="0" ViewCount="15" Body="&lt;p&gt;I am working with latex files. &#xA;I want to have a normal mode remapping which compiles my current file and a latex file named main.tex (both in my current working directory). The  command to compile is: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pdflatex -synctex=1 -interaction=nonstopmode &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get the behavior I want, I have tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;cv :w \|! pdflatex -synctex=1 -interaction=nonstopmode %  &amp;lt;CR&amp;gt;&amp;lt;CR&amp;gt; \|! pdflatex -synctex=1 -interaction=nonstopmode main.tex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't work however. I get the following results:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dfPNu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dfPNu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then after hitting enter I get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vfkyd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vfkyd.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and finally, all this &quot;log &quot; info gets written to my file as shown:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/3Z71r.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3Z71r.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want these compile commands to happen in the background and of course have nothing written into the file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;at the start to blame possibly. &#xA;Any help is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="28649" LastActivityDate="2020-04-09T15:10:44.610" Title="Trouble creating a remap that compiles the current open latex file along with one other latex file in the current directory" Tags="|vimrc|vimscript|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24508" PostTypeId="2" ParentId="24491" CreationDate="2020-04-09T15:13:41.943" Score="0" Body="&lt;p&gt;So setting aside that there may be an issue with YCM, you can put the following in your .vimrc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup RestartYCM&#xA;  autocmd!&#xA;  autocmd FocusGained * :YcmRestartServer&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16156" LastEditorUserId="10604" LastEditDate="2020-04-09T17:40:42.520" LastActivityDate="2020-04-09T17:40:42.520" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24509" PostTypeId="2" ParentId="24479" CreationDate="2020-04-09T15:19:30.293" Score="0" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/questions/24479/how-to-go-to-search-results-located-in-other-windows#comment42637_24479&quot;&gt;@D. Ben Knoble said in the comments&lt;/a&gt;, you have to change focus to the new window, for example &lt;code&gt;&amp;lt;c-w&amp;gt;w&lt;/code&gt;, if there are only two windows open. Then hit 'n'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is an issue you frequently encounter, consider creating a mapping. In this case, to make &lt;code&gt;&amp;lt;c-s&amp;gt;&lt;/code&gt; the way to search in the new window you could add to your .vimrc the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-s&amp;gt; &amp;lt;c-w&amp;gt;wn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16156" LastEditorUserId="10604" LastEditDate="2020-04-09T17:41:27.773" LastActivityDate="2020-04-09T17:41:27.773" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24510" PostTypeId="1" CreationDate="2020-04-09T15:37:44.763" Score="2" ViewCount="442" Body="&lt;p&gt;One can change the search color of search terms with the &lt;code&gt;Search&lt;/code&gt; highlight scheme.&#xA;Similarly one can change the color of a line in the quickfix window with &lt;code&gt;QuickFixLine&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, how does one change the colour of the search phrase within listing in the quick fix window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A picture is worth 1000 word, hence in the following image, I &lt;code&gt;:vimgrep&lt;/code&gt; searched for 'buffer', and I underlined some matches in yellow with a screen grab tool, is it possible to highlight them in vim (in particular Neovim)?:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/5ixvh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5ixvh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2023-01-16T19:32:23.097" Title="Highlight search phrase within quickfix window listing" Tags="|syntax-highlighting|highlight|highlighting|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24511" PostTypeId="1" CreationDate="2020-04-09T15:47:06.023" Score="1" ViewCount="103" Body="&lt;p&gt;I'm using &lt;code&gt;gnome-terminal&lt;/code&gt; for first time (after using xterm for many years).&lt;/p&gt;&#xA;&lt;p&gt;And the one keystroke that no longer works within gnome-terminal from my Vim application is Function Key F10.&lt;/p&gt;&#xA;&lt;p&gt;I've turned off Menu Accelerator (F10) option in the Gnome-Terminal's &lt;code&gt;Edit&lt;/code&gt;-&amp;gt;&lt;code&gt;Preferences&lt;/code&gt;, then &lt;code&gt;General&lt;/code&gt; tab:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EPyFE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EPyFE.png&quot; alt=&quot;Gnome-Terminal Preferences-&amp;gt;General&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But my remapped Vim F10 key is still not firing.&lt;/p&gt;&#xA;&lt;p&gt;Any intermediate troubleshooting steps that I can try?&lt;/p&gt;&#xA;&lt;p&gt;:-/&lt;/p&gt;&#xA;" OwnerUserId="18880" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-04-09T15:47:06.023" Title="F10 is not yet available to Vim via gnome-terminal" Tags="|key-bindings|terminal|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24512" PostTypeId="2" ParentId="24510" CreationDate="2020-04-09T17:46:23.270" Score="4" Body="&lt;p&gt;Two ideas:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If you just want to highlight them, search with &lt;code&gt;/buffer&lt;/code&gt; and make sure &lt;code&gt;hlsearch&lt;/code&gt; is on. Or, for a more permanent solution, navigate to the quickfix window and use &lt;code&gt;:match Search /buffer/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;If you care more about filtering, I would do &lt;code&gt;:packadd cfilter&lt;/code&gt;, which provides the &lt;code&gt;:Cfilter&lt;/code&gt; command. Then a &lt;code&gt;:Cfilter /buffer/&lt;/code&gt; gives you only entries with &lt;code&gt;buffer&lt;/code&gt;, and &lt;code&gt;:colder&lt;/code&gt; restores the original. (Of course, given that the original search was &lt;code&gt;buffer&lt;/code&gt;, OP won't be able to limit in this way.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-09T17:46:23.270" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24513" PostTypeId="1" AcceptedAnswerId="24516" CreationDate="2020-04-09T20:30:59.467" Score="0" ViewCount="35" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/yegappan/mru&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/yegappan/mru&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I remember in the past having an option to set the length of the list, but can't find it now?i&lt;/p&gt;&#xA;" OwnerUserId="13656" LastActivityDate="2020-04-10T08:54:15.163" Title="How can I set the length of the MRU plugin?" Tags="|vimrc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24514" PostTypeId="2" ParentId="18706" CreationDate="2020-04-09T20:43:01.947" Score="1" Body="&lt;p&gt;I think I had the same problem. There are two issues I encountered when I exited the denite buffer without selecting an entry: when using the &lt;code&gt;preview&lt;/code&gt; action the preview window didn't close, and when using the &lt;code&gt;highlight&lt;/code&gt; action the cursor stayed at the position that was being highlighted (instead of going back to where I was before opening the denite buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think what's going on is that denite runs some code when exiting the buffer to &quot;clean up&quot; these things like the preview window and when you simply close the window like any other window, this code isn't being executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was able to solve that by defining the key mapping for quitting denite via the &lt;code&gt;denite#do_map&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType denite call s:denite_my_settings()&#xA;function! s:denite_my_settings() abort&#xA;    nnoremap &amp;lt;silent&amp;gt;&amp;lt;buffer&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;ESC&amp;gt; denite#do_map('quit')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This maps the &lt;code&gt;ESC&lt;/code&gt; key to the &lt;code&gt;quit&lt;/code&gt; action in the denite buffer. Then the two aforementioned issues were solved for me.&lt;/p&gt;&#xA;" OwnerUserId="28858" LastActivityDate="2020-04-09T20:43:01.947" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24515" PostTypeId="2" ParentId="24502" CreationDate="2020-04-09T21:07:55.777" Score="2" Body="&lt;p&gt;You could visual select with &lt;code&gt;v&lt;/code&gt; or select the whole line with &lt;code&gt;V&lt;/code&gt; and then press &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;P&lt;/code&gt; to replace the selected text with the one in clipboard (I think it will work with yours Ctrl+v as well).&lt;/p&gt;&#xA;" OwnerUserId="18912" LastActivityDate="2020-04-09T21:07:55.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24516" PostTypeId="2" ParentId="24513" CreationDate="2020-04-09T22:00:39.410" Score="0" Body="&lt;p&gt;I'm not quite sure what you mean by length, but in the &lt;a href=&quot;https://github.com/yegappan/mru/wiki/User-Manual&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt;, there seem to be multiple properties that could be what you're looking for:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;MRU_Window_Height&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;MRU_Max_Entries&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;They can be set like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let MRU_Window_Height = 40&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="13656" LastEditDate="2020-04-10T08:54:15.163" LastActivityDate="2020-04-10T08:54:15.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24517" PostTypeId="1" CreationDate="2020-04-10T00:12:53.523" Score="0" ViewCount="244" Body="&lt;p&gt;I have &lt;code&gt;netrw_browse_split&lt;/code&gt; set to 4, so typing &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; on a file on netrw will open it on the previous window.&#xA;But if the previous window have a file, it will be closed.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make opening a file with netrw on the previous window not close the file on that window, but instead open it on a new buffer, so that I can have several files open on a single window but swap between then with netrw?&lt;/p&gt;&#xA;" OwnerUserId="28862" LastActivityDate="2020-04-10T00:12:53.523" Title="Make netrw not close previous buffer but open a new buffer" Tags="|netrw|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24518" PostTypeId="1" CreationDate="2020-04-10T06:42:48.183" Score="4" ViewCount="263" Body="&lt;p&gt;I know that in insert mode &lt;code&gt;CTRL-Y&lt;/code&gt; can insert the character above the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way of inserting the word above the cursor in insert mode ?&lt;/p&gt;&#xA;" OwnerUserId="21293" LastActivityDate="2020-09-09T06:55:15.207" Title="Insert the word which is above the cursor?" Tags="|insert-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24519" PostTypeId="2" ParentId="24518" CreationDate="2020-04-10T07:11:09.623" Score="0" Body="&lt;p&gt;What you can do via a series of commands, is as following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;From insert mode, go to normal mode: &lt;code&gt;ESC&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Go one line up: &lt;code&gt;k&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Yank a word (or in word, whatever you want to choose): &lt;code&gt;yaw&lt;/code&gt; or &lt;code&gt;yiw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Go the original line: &lt;code&gt;j&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Put the word before the cursor: 'P'&lt;/li&gt;&#xA;&lt;li&gt;Go on appending after the cursor: 'a'&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In short, &lt;code&gt;:inoremap ,&amp;lt;C-Y&amp;gt; &amp;lt;ESC&amp;gt;kyiwjPa&lt;/code&gt; should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change a few things here and there according to your choices.&lt;/p&gt;&#xA;" OwnerUserId="28840" LastEditorUserId="28840" LastEditDate="2020-04-10T07:18:13.583" LastActivityDate="2020-04-10T07:18:13.583" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24520" PostTypeId="1" AcceptedAnswerId="24521" CreationDate="2020-04-10T08:02:00.307" Score="1" ViewCount="472" Body="&lt;p&gt;I have a function that builds my status line by appending values with &lt;code&gt;statusline+=&lt;/code&gt; depending on the context. Everything works, except that if I try to call a function in the following form:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;setlocal statusline=%{MyFunction(a:my_parameter)}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It fails with&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;E121: Undefined variable a:my_parameter&lt;/p&gt;&#xA;&lt;p&gt;E116: Invalid arguments for function MyFunction&lt;/p&gt;&#xA;&lt;p&gt;E15: Invalid expression: MyFunction(a:my_parameter)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Of course I checked that &lt;code&gt;a:my_parameter&lt;/code&gt; is in scope and I can echo its value just before the function call. What is more, if I use a local variable instead (i.e. &lt;code&gt;l:my_parameter&lt;/code&gt;) it fails in the same way, but I can pass hardcoded values without problem. I think it may be a limitation of &lt;code&gt;%{}&lt;/code&gt;, but I cannot find anything in the documentation.&lt;/p&gt;&#xA;&lt;p&gt;So, is it possible to pass variables to functions inside &lt;code&gt;%{}&lt;/code&gt; somehow?&lt;/p&gt;&#xA;" OwnerUserId="786" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-04-11T10:42:14.253" Title="Is it possible to pass local variables to functions inside statusline=%{}?" Tags="|vimscript|statusline|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24521" PostTypeId="2" ParentId="24520" CreationDate="2020-04-10T08:17:00.903" Score="2" Body="&lt;p&gt;it is possible, at least I do pass variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    set statusline=%{misc#unicode_number(winnr())}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not sure what is &lt;code&gt;set local statusline&lt;/code&gt; though. Did you mean &lt;code&gt;setlocal&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Btw, &lt;code&gt;a:&lt;/code&gt; variables implies you set statusline from the function? Bear in mind that statusline is evaluated quite often and it calls functions being bound to it without knowing local scoped parameters (no closures I guess?). So it literally calls &lt;code&gt;MyFunction(a:my_parameter)&lt;/code&gt; in a context where &lt;code&gt;a:my_parameter&lt;/code&gt; is unknown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not 100% sure but you can try to pass your parameter as real evaluated value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exe 'set statusline=%{MyFunction(&quot;' . a:parameter . '&quot;)}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS, indeed this doesn't work. I believe (?) in statusline context there is just no way to access local variables and functions. You can pass parameter to a function used in statusline if that parameter is global/autoloaded function call or a buffer/global variable. Take this info with a grain of salt, I don't know for sure :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This stupid exmaple works&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! MyFunc(value) abort&#xA;    return a:value * 3&#xA;endfunc&#xA;func! MyOtherFunc(value) abort&#xA;    return a:value . &quot; WORLD!!!&quot;&#xA;endfunc&#xA;&#xA;set statusline=%{MyFunc(123)}&#xA;set statusline+=%{MyOtherFunc('hello')}&#xA;set statusline+=%{MyFunc(10)}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this also works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! Test(parameter)&#xA;    return &quot;hello world &quot; . a:parameter&#xA;endfunc&#xA;func! MyStatus(value) abort&#xA;    let &amp;amp;statusline=&quot;%{Test('&quot;. a:value .&quot;')}&quot;&#xA;endfunc&#xA;call MyStatus(&quot;value for my status&quot;)&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-04-10T10:39:24.240" LastActivityDate="2020-04-10T10:39:24.240" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24523" PostTypeId="2" ParentId="24493" CreationDate="2020-04-10T10:01:12.267" Score="4" Body="&lt;p&gt;You are looking for &lt;a href=&quot;https://github.com/t9md/vim-choosewin&quot; rel=&quot;nofollow noreferrer&quot;&gt;Choosewin&lt;/a&gt;, sadly &lt;a href=&quot;https://github.com/t9md/vim-choosewin/issues/45#issuecomment-450544629&quot; rel=&quot;nofollow noreferrer&quot;&gt;it's not being actively developed anymore&lt;/a&gt;, but for the simplest use cases it works great.&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-10T10:01:12.267" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24524" PostTypeId="1" AcceptedAnswerId="24525" CreationDate="2020-04-10T10:06:43.960" Score="2" ViewCount="894" Body="&lt;p&gt;This is better shown than explained. The first image shows how line wrapping works in VScode, and the second in vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EOPzA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EOPzA.png&quot; alt=&quot;VScode&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/9tpJj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9tpJj.png&quot; alt=&quot;vim&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In VScode the wrapped line continues at the indentation level of the line, rather than at the beginning of the document, however this is not the case in vim. For some tasks, the VScode way of wrapping is much cleaner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to get this functionality in vim?&lt;/p&gt;&#xA;" OwnerUserId="28867" LastActivityDate="2020-04-10T11:07:20.513" Title="How can I wrap text from the indentation level rather than the beginning of the line" Tags="|wrapping|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24525" PostTypeId="2" ParentId="24524" CreationDate="2020-04-10T10:54:35.280" Score="2" Body="&lt;p&gt;Yes, see &lt;code&gt;:h breakindent&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'breakindent' 'bri' boolean (default off)&#xA;            local to window&#xA;            {not available when compiled without the |+linebreak|&#xA;            feature}&#xA;    Every wrapped line will continue visually indented (same amount of&#xA;    space as the beginning of that line), thus preserving horizontal blocks&#xA;    of text.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And also &lt;code&gt;:h breakindentopt&lt;/code&gt;. I use &lt;code&gt;set breakindentopt=sbr&lt;/code&gt; and it places &lt;code&gt;showbreak&lt;/code&gt; symbol to first column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XDCh8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XDCh8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For list items it wouldn't indent wrapped lines to be under the text, though. And actually, your vscode example does the same.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-04-10T11:07:20.513" LastActivityDate="2020-04-10T11:07:20.513" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24526" PostTypeId="1" CreationDate="2020-04-10T11:18:33.560" Score="4" ViewCount="228" Body="&lt;p&gt;I often select a region in visual mode for properly indenting it. However, after pressing for example &lt;code&gt;3&amp;gt;&lt;/code&gt;, visual mode exits and the selection disappears.&lt;/p&gt;&#xA;&lt;p&gt;How can I re-select the previously selected region, so that I may further edit it?&lt;/p&gt;&#xA;" OwnerUserId="26505" LastEditorUserId="25061" LastEditDate="2022-02-12T23:48:03.360" LastActivityDate="2022-02-12T23:48:03.360" Title="How to re-select a previously selected region in visual mode?" Tags="|visual-mode|selection|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24527" PostTypeId="2" ParentId="24526" CreationDate="2020-04-10T11:31:48.050" Score="5" Body="&lt;p&gt;If I get you right it is &lt;code&gt;gv&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also remap &lt;code&gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xnoremap &amp;gt; &amp;gt;gv&#xA;xnoremap &amp;lt; &amp;lt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-04-10T12:19:16.450" LastActivityDate="2020-04-10T12:19:16.450" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24528" PostTypeId="1" CreationDate="2020-04-10T13:40:15.087" Score="3" ViewCount="1052" Body="&lt;p&gt;I am looking for a simple few key command which would move till the last occurrence of a character in the line. Is there anything already existing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The alternative is to jump to the next specified character and repeat the jump as many times as you need. It is not terrible; I am just curious whether there is there is something built into vim which could speed this up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A use case could be to strip the absolute path only to the last directory.&lt;/p&gt;&#xA;" OwnerUserId="17773" LastActivityDate="2020-10-20T02:15:54.033" Title="Simple keycombination to move to the last occurance of a character in a line" Tags="|cursor-movement|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24529" PostTypeId="2" ParentId="24493" CreationDate="2020-04-10T13:44:45.123" Score="0" Body="&lt;p&gt;It might not be a direct answer, but if you just need to jump between buffers you can use &lt;code&gt;:bN&lt;/code&gt;, where &lt;code&gt;N&lt;/code&gt; is the number of the buffer, which you can check with the &lt;code&gt;:ls&lt;/code&gt; command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I rarely need to use more than 3 panes in one direction and I just use the &lt;code&gt;:bN&lt;/code&gt; command. If you work long enough with the files, you will remember their buffer number.&lt;/p&gt;&#xA;" OwnerUserId="17773" LastActivityDate="2020-04-10T13:44:45.123" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24530" PostTypeId="2" ParentId="24528" CreationDate="2020-04-10T13:59:05.670" Score="3" Body="&lt;p&gt;Assuming that &lt;code&gt;&amp;amp;virtualedit&lt;/code&gt; is &lt;code&gt;all&lt;/code&gt; or &lt;code&gt;onemore&lt;/code&gt; it's &lt;kbd&gt;$&lt;/kbd&gt;&lt;kbd&gt;l&lt;/kbd&gt;&lt;kbd&gt;F&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt; (i.e. get one character past the end of the string, in case it ends in a searching character, and find char backward).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More robust variant (not to depend on &lt;code&gt;&amp;amp;virtualedit&lt;/code&gt;) is &lt;kbd&gt;A&lt;/kbd&gt;&lt;kbd&gt;Ctrl-\&lt;/kbd&gt;&lt;kbd&gt;Ctrl-O&lt;/kbd&gt;&lt;kbd&gt;T&lt;/kbd&gt;&lt;kbd&gt;/&lt;/kbd&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;to jump to the next specified character and repeat the jump as many times as you need&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[count]f{char}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also to repeat by pressing semicolon (;)&lt;/p&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2020-04-10T14:06:15.190" LastActivityDate="2020-04-10T14:06:15.190" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24531" PostTypeId="2" ParentId="9338" CreationDate="2020-04-10T15:36:03.803" Score="1" Body="&lt;p&gt;&lt;code&gt;command! Sov source $MYVIMRC | e %&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:Sov&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="28875" LastActivityDate="2020-04-10T15:36:03.803" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24532" PostTypeId="1" AcceptedAnswerId="24559" CreationDate="2020-04-10T17:31:51.830" Score="1" ViewCount="174" Body="&lt;p&gt;I have modified a function from &lt;a href=&quot;https://github.com/CKolkey/.dotfiles/blob/master/nvim_init.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;CKolkey's dotfiles&lt;/a&gt; - &lt;code&gt;ToggleTerminalDrawer&lt;/code&gt; (line 230) so that it works for Vim8.2 (instead of neovim). Here is my modified function now in my vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;/           :call ToggleTerminalDrawer()&amp;lt;CR&amp;gt;&#xA;tnoremap &amp;lt;silent&amp;gt;&amp;lt;leader&amp;gt;/ &amp;lt;C-\&amp;gt;&amp;lt;C-n&amp;gt;:call ToggleTerminalDrawer()&amp;lt;CR&amp;gt;&#xA;&#xA;let g:terminal_drawer = { 'win_id': v:null, 'buffer_id': v:null }&#xA;function! ToggleTerminalDrawer() abort&#xA;  if win_gotoid(g:terminal_drawer.win_id)&#xA;    hide&#xA;    set laststatus=2 showmode ruler&#xA;  else&#xA;    botright new&#xA;    if !g:terminal_drawer.buffer_id&#xA;      call term_start($SHELL)&#xA;      let g:terminal_drawer.buffer_id = bufnr(&quot;&quot;)&#xA;    else&#xA;      exec &quot;buffer&quot; g:terminal_drawer.buffer_id&#xA;      call RemoveEmptyBuffers()&#xA;    endif&#xA;&#xA;    exec &quot;resize&quot; float2nr(&amp;amp;lines * 0.25)&#xA;    setlocal laststatus=0 noshowmode noruler&#xA;    setlocal nobuflisted&#xA;    startinsert!&#xA;    let g:terminal_drawer.win_id = win_getid()&#xA;&#xA;  endif&#xA;endfunction&#xA;&#xA;function! RemoveEmptyBuffers()&#xA;  let buffers = filter(range(1, bufnr('$')), 'buflisted(v:val) &amp;amp;&amp;amp; empty(bufname(v:val)) &amp;amp;&amp;amp; bufwinnr(v:val)&amp;lt;0 &amp;amp;&amp;amp; !getbufvar(v:val, &quot;&amp;amp;mod&quot;)')&#xA;  if !empty(buffers)&#xA;      silent exe 'bw ' . join(buffers, ' ')&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works great most of the time. It toggles a terminal pane at the bottom of the editor, and always uses the same terminal buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when the toggle is run and a Terminal buffer doesn't yet exist, it creates one terminal buffer (good, intended) and an extra blank buffer editor which I can write in - this is unintended. When this happens I always have to do &lt;code&gt;:q&lt;/code&gt; to get rid of it. How do I modify this function to not cause that side effect?&lt;/p&gt;&#xA;" OwnerUserId="28878" LastActivityDate="2020-04-12T13:43:13.120" Title="Function to toggle terminal creates extra empty buffer" Tags="|vimscript|terminal-buffer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24533" PostTypeId="2" ParentId="10087" CreationDate="2020-04-10T17:45:27.760" Score="0" Body="&lt;p&gt;I figured it out a solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\%x19/ /g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;TIP: The value &lt;code&gt;\x19&lt;/code&gt; can be expressed on Unicode by &lt;code&gt;\u0019&lt;/code&gt;. So you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/ /\=&quot;\u0019&quot;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you press &lt;code&gt;ga&lt;/code&gt; you can see the hex value, if it has less than four digits fill it with zeros and you have the Unicode value&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example &lt;code&gt;Xex 20&lt;/code&gt; (space), can be &lt;code&gt;\u0020&lt;/code&gt; and in the search pattern we have to use backslash + percent + (u|x|o) followed by its number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the substitution portion, you have to use an expression register if we want to use any (unicode|hex|octal) replacement.&lt;/p&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2020-04-10T17:45:27.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24534" PostTypeId="2" ParentId="3990" CreationDate="2020-04-11T05:30:18.560" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/users/51/martin-tournoij&quot;&gt;Martin Tournoij&lt;/a&gt;'s &lt;a href=&quot;https://vi.stackexchange.com/a/4003/16249&quot;&gt;otherwise excellent answer&lt;/a&gt; fails to behave as expected for me – probably due to my leveraging &lt;a href=&quot;https://github.com/diraol&quot; rel=&quot;nofollow noreferrer&quot;&gt;diraol&lt;/a&gt;'s &lt;a href=&quot;https://github.com/python-mode/python-mode&quot; rel=&quot;nofollow noreferrer&quot;&gt;phenomenal &lt;code&gt;python-mode&lt;/code&gt; plugin&lt;/a&gt; rather than Vim's default syntax file for Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid highlighting URIs in Python comments, strings, or docstrings under &lt;code&gt;python-mode&lt;/code&gt;, add the following concise one-liner to your user-specific &lt;code&gt;~/.vim/after/syntax/python.vim&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax match NoSpellUriPython '\w\+:\/\/[^[:space:]]\+' transparent contained containedin=pythonComment,python.*String contains=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;That's it.&lt;/strong&gt; Crucially, note that this compresses what would have been &lt;em&gt;twelve&lt;/em&gt; separate lines in Martin's answer into a single line. How? Elementary, my dear Vim-based Watson. We add:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;code&gt;transparent&lt;/code&gt; keyword, instructing Vim to inherit the highlight properties for this child syntax from its parent syntax (e.g., comments, strings). This enables us to avoid explicitly restating &lt;code&gt;highlight def link&lt;/code&gt; for each child syntax group.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;contained&lt;/code&gt; keyword, preventing this child syntax from extending past the boundaries of its parent syntax (e.g., EOL for comments, string delimiters for strings).&lt;/li&gt;&#xA;&lt;li&gt;All parent syntax groups delimited by commas to the &lt;code&gt;containedin&lt;/code&gt; keyword. The &lt;code&gt;.*&lt;/code&gt; regex operator enables us to cleverly match &lt;em&gt;all&lt;/em&gt; Python string syntax groups (i.e., &lt;code&gt;pythonString&lt;/code&gt;, &lt;code&gt;pythonUniString&lt;/code&gt;, &lt;code&gt;pythonRawString&lt;/code&gt;, &lt;code&gt;pythonUniRawString&lt;/code&gt;, &lt;code&gt;pythonDocstring&lt;/code&gt;) with minimal pain and maximal forward compatibility.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Although technically valid, the vimscript embedded in Martin's answer violates the DRY (Don't Repeat Yourself) principle. See also &lt;a href=&quot;https://stackoverflow.com/a/2952965/2809027&quot;&gt;this similar answer for further details&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But wait... &lt;em&gt;there's more.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Unasked-for Improvements for Great Glory&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I'm sufficiently annoyed by both Vim's overly naïve default spell checking &lt;em&gt;and&lt;/em&gt; third-party plugins (e.g., &lt;a href=&quot;https://github.com/kamykn/spelunker.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Spelunker&lt;/a&gt;, which unconditionally spell checks the entire buffer rather than merely code comments and strings) that I've decided... &lt;strong&gt;to actually do something about that.&lt;/strong&gt; &lt;code&gt;&amp;lt;/gasp&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/leycec/vimrc/blob/github/.vim/after/syntax/python.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;well-tested Vim snippet below&lt;/a&gt; intelligently avoids spell checking all of the following within Python comments and strings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;URIs (as above).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;CamelCase&lt;/code&gt; identifiers.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;snake_case&lt;/code&gt; identifiers.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;UPPERCASE&lt;/code&gt;  identifiers.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;@&lt;/code&gt;-prefixed identifiers (e.g., &lt;code&gt;@muhdecorator&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&quot;&lt;/code&gt;-delimited filetyped filenames (e.g., &lt;code&gt;&quot;muh_module.py&quot;&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:&lt;/code&gt;-delimited substrings (e.g., the &lt;code&gt;:func:&lt;/code&gt; in :func:`re.sub`).&lt;/li&gt;&#xA;&lt;li&gt;`-delimited substrings (e.g., the &lt;code&gt;re.sub&lt;/code&gt; in :func:`re.sub`).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Add some or all of the following to your user-specific &lt;code&gt;~/.vim/after/syntax/python.vim&lt;/code&gt; file and gasp in delight as Vim actually spell checks the RightStuff™ for once:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Avoid spell checking URIs.&#xA;syntax match NoSpellPythonUri /\v\w+:\/\/[^[:space:]]+/ transparent contained containedin=pythonComment,python.*String contains=@NoSpell&#xA;&#xA;&quot; Avoid spell checking both CamelCase-formatted identifiers and uppercase&#xA;&quot; identifiers. Since most languages (excluding Raku) prohibit Unicode in&#xA;&quot; identifiers, these matches are intentionally confined to ASCII codepoints&#xA;&quot; (e.g., &quot;[A-Z]&quot; rather than &quot;[[:upper:]]&quot;).&#xA;syntax match NoSpellPythonCaps /\v&amp;lt;[A-Z]([A-Z0-9]{-1,}|[a-z0-9]+[A-Z0-9].{-})&amp;gt;/ transparent contained containedin=pythonComment,python.*String contains=@NoSpell&#xA;&#xA;&quot;FIXME: For unknown reasons, enabling this and *ONLY* this &quot;syntax&quot; statement&#xA;&quot;causes subtle (but horrible) failures across &quot;python-mode&quot; indentation and&#xA;&quot;syntax highlighting. While lamentable, we need &quot;python-mode&quot; more than we need&#xA;&quot;to avoid spell checking snake_case-formatted identifiers. See also this&#xA;&quot;currently unresolved upstream issue:&#xA;&quot;    https://github.com/python-mode/python-mode/issues/1083&#xA;&quot;&#xA;&quot; &quot; Avoid spell checking snake_case-formatted identifiers.&#xA;&quot; syntax match NoSpellPythonSnake&#xA;&quot;   \ /\v&amp;lt;\w+_.{-1,}&amp;gt;/ transparent&#xA;&quot;   \ contained containedin=pythonComment,python.*String contains=@NoSpell&#xA;&#xA;&quot; Avoid spell checking &quot;@&quot;-prefixed identifiers.&#xA;syntax match NoSpellPythonDecorator /\v\@[a-zA-Z].{-}&amp;gt;/ transparent contained containedin=pythonComment,python.*String contains=@NoSpell&#xA;&#xA;&quot; Avoid spell checking &quot;:&quot;-delimited substrings.&#xA;syntax match NoSpellPythonColons /\v:[^:]+:/ transparent contained containedin=pythonComment,python.*String contains=@NoSpell&#xA;&#xA;&quot; Avoid spell checking &quot;`&quot;-delimited substrings.&#xA;syntax match NoSpellPythonTicks /\v`[^`]+`/ transparent contained containedin=pythonComment,python.*String contains=@NoSpell&#xA;&#xA;&quot; Avoid spell checking '&quot;'-delimited filetyped filenames matched as a&#xA;&quot; double-quoted substring containing a filename prefix, a period, and one to&#xA;&quot; four characters comprising a filetype.&#xA;syntax match NoSpellPythonPath /\v&quot;[^&quot;]+.[^&quot;]{1,4}&quot;/ transparent contained containedin=pythonComment,python.*String contains=@NoSpell&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, all of the above could (and possibly should) be reduced to a single one-liner matching one Godzilla-like regular expression that no one including myself would ever be able to maintain or even read. For everyone's sanity, I didn't do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone who is &lt;em&gt;not&lt;/em&gt; me would like to make a GitHub-hosted Vim plugin expanding the above to other popular languages, that'd be just great. Vim's default spell checking implementation is &lt;em&gt;almost&lt;/em&gt; there, folks; it just needs a helping hand from the open-source community.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Until then, may the StackOverflow be with you always!&lt;/p&gt;&#xA;" OwnerUserId="16249" LastEditorUserId="16249" LastEditDate="2020-05-18T05:08:10.467" LastActivityDate="2020-05-18T05:08:10.467" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24535" PostTypeId="1" AcceptedAnswerId="24545" CreationDate="2020-04-11T09:34:02.207" Score="1" ViewCount="278" Body="&lt;p&gt;I use Neovim in a Linux (Arch Linux) environment. I have written a function to help me preview my markdown documents in PDF format without using a whole plugin. I've also added a simple command named &quot;Prev&quot; to call this function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the relevant part of my vimrc file :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:pdf_preview()&#xA;    ! pandoc % -s -f markdown -t odt -o ~/.cache/%:t:r.odt &amp;gt; ~/.cache/%:t:r_Prev_log.txt 2&amp;gt;&amp;amp;1&#xA;    ! soffice --headless --convert-to pdf --outdir ~/.cache ~/.cache/%:t:r.odt &amp;gt;&amp;gt; ~/.cache/%:t:r_Prev_log.txt 2&amp;gt;&amp;amp;1&#xA;    ! zathura ~/.cache/%:t:r.pdf &amp;gt;&amp;gt; ~/.cache/%:t:r_Prev_log.txt 2&amp;gt;&amp;amp;1&#xA;endfunction&#xA;command Prev call s:pdf_preview()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note : I'm using &lt;code&gt;soffice&lt;/code&gt; to convert from odt to pdf to avoid installing a LaTeX processor (which I think would be required by pandoc for a direct conversion from markdown to pdf).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to improve this function in two ways :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;save the current file in the .cache folder before the &quot;! pandoc&quot; command, so that I can use this temporary file for the preview instead of having to save my document each time ;&lt;/li&gt;&#xA;&lt;li&gt;delete the temporary files (the odt and the pdf files) once the preview with zathura is closed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thanx for any help !&lt;/p&gt;&#xA;" OwnerUserId="28889" LastActivityDate="2020-04-12T08:56:02.003" Title="Nvim external commands to write and delete files inside a function" Tags="|external-command|functions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24536" PostTypeId="1" CreationDate="2020-04-11T10:40:00.297" Score="1" ViewCount="38" Body="&lt;p&gt;I'm looking for three functions (line, col, cursor) in nvim that takes an extra parameter window number so that I don't need to first navigate to the window and then navigate away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason is if I navigate the window, I will see a quick flash on the screen.&lt;/p&gt;&#xA;" OwnerUserId="27290" LastActivityDate="2020-04-11T10:40:00.297" Title="Get/set window line, column without navigating to window" Tags="|neovim|vim-windows|functions|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24537" PostTypeId="1" AcceptedAnswerId="24555" CreationDate="2020-04-11T12:08:28.980" Score="3" ViewCount="612" Body="&lt;p&gt;How to map &lt;code&gt;d&lt;/code&gt; to call a function without getting into waiting mode? If I just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; d :call Function()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After I press d, it will wait for a while before it execute the function.&lt;/p&gt;&#xA;" OwnerUserId="27290" LastActivityDate="2020-04-12T05:16:20.027" Title="Map d to a function without waiting" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24538" PostTypeId="1" CreationDate="2020-04-11T14:15:27.073" Score="2" ViewCount="26" Body="&lt;p&gt;Is it possible to get around syntax, and set text color directly in vim?&lt;/p&gt;&#xA;" OwnerUserId="27290" LastActivityDate="2020-04-11T14:15:27.073" Title="In vim, is it possible to set a particular line text into a specific color without defining syntax?" Tags="|syntax-highlighting|syntax|" AnswerCount="0" CommentCount="2" ClosedDate="2020-04-12T18:35:50.067" ContentLicense="CC BY-SA 4.0" />
  <row Id="24539" PostTypeId="2" ParentId="7167" CreationDate="2020-04-11T14:54:14.747" Score="2" Body="&lt;p&gt;Instead of using the above config, you can easily use &lt;code&gt;a&amp;lt;&lt;/code&gt; from visual mode to select around closing tag, &lt;code&gt;i&amp;lt;&lt;/code&gt; to select inner a closing tag.&lt;/p&gt;&#xA;" OwnerUserId="28895" LastEditorUserId="51" LastEditDate="2020-04-11T19:40:56.670" LastActivityDate="2020-04-11T19:40:56.670" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24540" PostTypeId="1" AcceptedAnswerId="24543" CreationDate="2020-04-11T15:34:19.470" Score="1" ViewCount="18" Body="&lt;p&gt;I've been searching far and wide around tutorials, :help command, source code, Stacks but maybe I just can't form my query correctly in the vimscript lingo.&lt;br&gt;&#xA;My goal is to have a short command for switching buffers like:&lt;br&gt;&#xA;&lt;code&gt;42B&lt;/code&gt; or &lt;code&gt;B42&lt;/code&gt; that will switch the view to 42nd buffer. I don't want to monkey-map all the series &lt;code&gt;B1&lt;/code&gt;, &lt;code&gt;B2&lt;/code&gt;, &lt;code&gt;B3&lt;/code&gt; ..., though. So I want to treat 42 as an argument to some underlying function that chooses the appropriate buffer.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pls halp.&lt;/p&gt;&#xA;" OwnerUserId="28897" LastActivityDate="2020-04-11T16:56:44.797" Title="How can I replicate behaviour of go-to command? (42gg, 42G)" Tags="|key-bindings|vimscript|functions|command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24541" PostTypeId="1" AcceptedAnswerId="24542" CreationDate="2020-04-11T15:47:51.050" Score="2" ViewCount="1013" Body="&lt;p&gt;While editing my &lt;code&gt;vimrc&lt;/code&gt; I noticed that some keywords get highlighted at the beginning of lines, like &lt;code&gt;Note:&lt;/code&gt; and &lt;code&gt;Reminder:&lt;/code&gt;. I tried to find this syntax group in the &lt;code&gt;vim.vim&lt;/code&gt; syntax file, but to no avail. I also looked through all the &lt;code&gt;:help&lt;/code&gt; files I could think of. Does anyone have a complete list of these handy keywords? Which syntax file are they located in?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question references a similar type of keyword that might be in the same list, if these words are not limited to Vimscript:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/11545/how-do-i-add-syntax-keywords-globally-for-any-filetype&quot;&gt;How do I add syntax keywords globally for any filetype?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="28874" LastActivityDate="2020-04-11T16:37:39.413" Title="List of Vimscript comment keyword highlights" Tags="|vimscript|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24542" PostTypeId="2" ParentId="24541" CreationDate="2020-04-11T16:32:23.900" Score="1" Body="&lt;p&gt;If we look through &lt;code&gt;:syn list&lt;/code&gt; we see some elements which are the same color as the highlighted words, in particular, &lt;code&gt;vimCommentTitle&lt;/code&gt;.  Using &lt;code&gt;:syn list vimCommentTitle&lt;/code&gt; we see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vimCommentTitle xxx match /&quot;\s*\%([sS]:\|\h\w*#\)\=\u\w*\(\s\+\u\w*\)*:/hs=s+1  &#xA;contained contains=vimCommentTitleLeader,vimTodo,@vimCommentGroup&#xA;               links to PreProc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the list of words is given by a regex, roughly:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Word:&lt;/li&gt;&#xA;&lt;li&gt;s:Word:&lt;/li&gt;&#xA;&lt;li&gt;S:Word:&lt;/li&gt;&#xA;&lt;li&gt;He Llo World:&lt;/li&gt;&#xA;&lt;li&gt;Hello#World:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The purpose of this seems to be highlighting sections and function names in a vim script (although the pattern does not cover all possible function names).  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Some Functions: {{{&#xA;&#xA;&quot; module#Function: this surely does something&#xA;fu! module#Function()&#xA;endf&#xA;&#xA;&quot; s:Func2: this does something privately&#xA;fu! s:Func2()&#xA;endf&#xA;&#xA;&quot; }}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2020-04-11T16:37:39.413" LastActivityDate="2020-04-11T16:37:39.413" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24543" PostTypeId="2" ParentId="24540" CreationDate="2020-04-11T16:56:44.797" Score="1" Body="&lt;p&gt;There actually is a built-in map which does this, &lt;code&gt;&amp;lt;c-^&amp;gt;&lt;/code&gt; or control+^&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't like this (it is indeed difficult to press), you can remap it simply.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap gb &amp;lt;c-^&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I am using &lt;code&gt;gb&lt;/code&gt; here since &lt;code&gt;B&lt;/code&gt; is already a vim command.  You can use &lt;code&gt;B&lt;/code&gt; if you really want, but be aware that you would be overriding a built-in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also going to show how to make this map if there &lt;em&gt;weren't&lt;/em&gt; already a command &lt;code&gt;&amp;lt;c-^&amp;gt;&lt;/code&gt;.  Since there is an ex-command &lt;code&gt;:buffer N&lt;/code&gt; which does what we need, the map would take the following pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; gb :&amp;lt;c-u&amp;gt;buffer &amp;lt;c-r&amp;gt;=v:count&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only tricky parts are &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt; which eliminates the &lt;em&gt;line-oriented&lt;/em&gt; address vim places after &lt;code&gt;:&lt;/code&gt; by default and &lt;code&gt;&amp;lt;c-r&amp;gt;=v:count&amp;lt;cr&amp;gt;&lt;/code&gt; which means enter the current &lt;em&gt;count&lt;/em&gt; into the cmdline.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2020-04-11T16:56:44.797" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24544" PostTypeId="1" CreationDate="2020-04-11T17:37:19.890" Score="0" ViewCount="262" Body="&lt;p&gt;With regards to this line (full code at the bottom):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let savestatus  = &quot;%{&amp;amp;modified ? '%#StatusUnsaved#[+++]%*' : &amp;amp;modifiable ? '[---] ' : '[ R ]'}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the file is modified, I wish to print &lt;code&gt;[+++]&lt;/code&gt; with the highlighting face of &lt;code&gt;StatusUnsaved&lt;/code&gt;.&#xA;However with my code, it literally prints &lt;code&gt;%#StatusUnsaved#}[+++]%*&lt;/code&gt; in the status line instead of just printing &lt;code&gt;[+++]&lt;/code&gt; with the highlighting face applied.&#xA;I have tried nested &lt;code&gt;%{}&lt;/code&gt; but that generates errors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From reading the help it explains the statusline is just a stringf in which string &lt;code&gt;%&lt;/code&gt; substitutions occur. So it's like I need to call a function like &lt;code&gt;RenderStatusLine('%#StatusUnsaved#}[+++]%*')&lt;/code&gt;, and return that result. I have searched for a function like that but can't find it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my full status line code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyStatusLine()&#xA;    let prefix      = '%{expand(&quot;%:h&quot;)}'   &quot;Show file path head&#xA;    let prefix      = prefix . '/'&#xA;    let prefix      = prefix . '%#StatusLineNC#'   &quot;Change to StatusLineNC highlighting&#xA;    let prefix      = prefix . ' %t '      &quot;filename only no path (Tail)&#xA;    let prefix      = prefix . '%*'        &quot;Return to default color StatusLine / StatusLineNC&#xA;    let savestatus  = &quot;%{&amp;amp;modified ? '%#StatusUnsaved#[+++]%*' : &amp;amp;modifiable ? '[---] ' : '[ R ]'}&quot;&#xA;    let sep         = ' %= '               &quot;Left/Right separator&#xA;    let fug         = &quot;%{exists('g:loaded_fugitive') ? fugitive#statusline() : ''}&quot;&#xA;    let position    = ' %6l'               &quot;Current line number&#xA;    let position    = position . ',%-3c'   &quot;Current column number, left aligned 3 characters wide&#xA;    let position    = position . ' %P '    &quot; Percentage through the file&#xA;    return prefix.savestatus.sep.fug.position&#xA;endfunction&#xA;set statusline=%!MyStatusLine()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-04-13T12:31:50.110" Title="Require nested evaluation within the status line, a render status line function?" Tags="|statusline|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24545" PostTypeId="2" ParentId="24535" CreationDate="2020-04-11T18:01:38.167" Score="1" Body="&lt;p&gt;You can use &lt;code&gt;:write {filename}&lt;/code&gt; to save your file in a different location without changing the active buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding your second question, you could look at &lt;code&gt;:help job-control&lt;/code&gt; which describes how to start asynchronous process in Neovim. The &lt;code&gt;on_exit&lt;/code&gt; callback may be what you need. For example the following snippet prints a message after then seconds&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Echo(job_id, data, event)&#xA;    echo &quot;CLOSED!&quot;&#xA;endfunction&#xA;&#xA;call jobstart (&#xA;    \ [&#xA;    \ 'bash',&#xA;    \ '-c',&#xA;    \ 'for i in {1..10}; do echo hello $i!; sleep 1; done'],&#xA;    \ {'on_exit': 'Echo'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, &lt;code&gt;jobstart&lt;/code&gt; takes two arguments, the first is a list with the command to execute, and the second is a dictionary that maps events to functions. You only care about exiting Zathura, that's why the example only includes the &lt;code&gt;on_exit&lt;/code&gt; event. You could try to write a function mapped to the &lt;code&gt;on_exit&lt;/code&gt; event that deletes the file when called, and a script executed by &lt;code&gt;jobstart&lt;/code&gt; that launches Zathura and returns the control to Neovim when it is closed&lt;/p&gt;&#xA;" OwnerUserId="786" LastEditorUserId="786" LastEditDate="2020-04-12T08:56:02.003" LastActivityDate="2020-04-12T08:56:02.003" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="24546" PostTypeId="2" ParentId="24544" CreationDate="2020-04-11T20:46:05.463" Score="2" Body="&lt;p&gt;&lt;strike&gt;Since &lt;code&gt;%!&lt;/code&gt; statusline functions are re-evaluated (at what frequency, I do not know), you can do this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let savestatus  = &amp;amp;modified ? '%#StatusUnsaved#[+++]%*' : &amp;amp;modifiable ? '[---] ' : '[ R ]'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;code&gt;:help statusline&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    When the option starts with &quot;%!&quot; then it is used as an expression,&#xA;    evaluated and the result is used as the option value.  Example: &amp;gt;&#xA;        :set statusline=%!MyStatusLine()&#xA;&amp;lt;   The *g:statusline_winid* variable will be set to the |window-ID| of the&#xA;    window that the status line belongs to.&#xA;    The result can contain %{} items that will be evaluated too.&#xA;    Note that the &quot;%!&quot; expression is evaluated in the context of the&#xA;    current window and buffer, while %{} items are evaluated in the&#xA;    context of the window that the statusline belongs to.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Therefore, &lt;code&gt;%{}&lt;/code&gt; &lt;em&gt;should&lt;/em&gt; be evaluated, so it is bizarre that it is not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fundamentally, I believe the problem is the same as if you do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set statusline=%{&amp;amp;modified?'%1*[+++]%*':&amp;amp;modifiable?'[---]':'[R]'}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because the &lt;code&gt;%1*&lt;/code&gt; &quot;just some string,&quot; it doesn't get evaluated.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;However, you might be interested in &lt;code&gt;%m&lt;/code&gt; and &lt;code&gt;%r&lt;/code&gt; flags (and their capital variants). You'll have less control over the exact text, but they just work, and you can color them how you see fit.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-04-12T00:35:08.510" LastActivityDate="2020-04-12T00:35:08.510" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24547" PostTypeId="1" AcceptedAnswerId="24552" CreationDate="2020-04-11T21:26:02.167" Score="5" ViewCount="1173" Body="&lt;p&gt;Other editors I have used are able to decode URLs. For example these can take a&#xA;string like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;https://nim-lang.github.io/Nim/osproc#waitForExit%2CProcess%2Cint&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and produce this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;https://nim-lang.github.io/Nim/osproc#waitForExit,Process,int&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought about using this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/%2C/,/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but then it fails with other strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;https://nim-lang.github.io/Nim/osproc#startProcess%2Cstring%2Cstring%2C&#xA;openArray%5Bstring%5D%2CStringTableRef%2Cset%5BProcessOption%5D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is a better option available?&lt;/p&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="7184" LastEditDate="2020-04-11T23:23:33.187" LastActivityDate="2022-11-13T08:11:27.857" Title="Decode URL (percent decoding)" Tags="|key-bindings|replace|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24548" PostTypeId="1" CreationDate="2020-04-11T21:58:17.537" Score="4" ViewCount="411" Body="&lt;p&gt;Having the cursor on a &lt;code&gt;017&lt;/code&gt; and doing a &lt;kbd&gt;ctrl&lt;/kbd&gt;-&lt;kbd&gt;a&lt;/kbd&gt; increases it to &lt;code&gt;020&lt;/code&gt;, when I would have expected &lt;code&gt;018&lt;/code&gt;. Is this a bug (vim 8.0 on Ubuntu 18.04) or why would one want this?&lt;/p&gt;&#xA;" OwnerUserId="2774" LastEditorUserId="4472" LastEditDate="2020-04-16T21:16:25.687" LastActivityDate="2020-04-16T21:16:25.687" Title="ctrl-a increasing 017 to 020" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24549" PostTypeId="2" ParentId="24547" CreationDate="2020-04-11T22:30:40.087" Score="5" Body="&lt;p&gt;tpope's &lt;a href=&quot;https://github.com/tpope/vim-unimpaired/&quot; rel=&quot;nofollow noreferrer&quot;&gt;unimpaired plugin&lt;/a&gt; defines some (I think experimental) mappings for this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ENCODING AND DECODING                           *unimpaired-encoding*&#xA;&#xA;Each of these operations has a map that takes a motion, a map that&#xA;targets [count] lines, and a visual mode map.  The linewise variant integrates&#xA;with repeat.vim.&#xA;&#xA;Mnemonic: encoding always comes before decoding; &amp;quot;[&amp;quot; always comes before &amp;quot;]&amp;quot;.&#xA;&#xA;                                                *[x* *[xx* *v_[x*&#xA;[x{motion}              XML encode.&#xA;[xx                     &amp;lt;foo bar=&amp;quot;baz&amp;quot;&amp;gt; =&amp;gt; &amp;amp;lt;foo bar=&amp;amp;quot;baz&amp;amp;quot;&amp;amp;gt;&#xA;{Visual}[x&#xA;&#xA;                                                *]x* *]xx* *v_]x*&#xA;]x{motion}              XML decode.  HTML entities are handled as well.&#xA;]xx&#xA;{Visual}]x&#xA;&#xA;                                                *[u* *[uu* *v_[u*&#xA;[u{motion}              URL encode.&#xA;[uu                     foo bar =&amp;gt; foo%20bar&#xA;{Visual}[u&#xA;&#xA;                                                *]u* *]uu* *v_]u*&#xA;]u{motion}              URL decode.&#xA;]uu&#xA;{Visual}]u&#xA;&#xA;                                                *[y* *[yy* *v_[y*&#xA;[y{motion}              C String encode.  Backslash escape control&#xA;[yy                     characters, quotation marks, and backslashes.&#xA;{Visual}[y&#xA;&#xA;                                                *]y* *]yy* *v_]y*&#xA;]y{motion}              C String decode.&#xA;]yy&#xA;{Visual}]y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="51" LastEditDate="2022-03-06T14:48:34.990" LastActivityDate="2022-03-06T14:48:34.990" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24550" PostTypeId="2" ParentId="24548" CreationDate="2020-04-11T22:32:44.760" Score="8" Body="&lt;p&gt;This is vim expecting &lt;code&gt;017&lt;/code&gt; to be octal and doing the sensible thing for an octal number (&lt;code&gt;017&lt;/code&gt; = 8+7 = 15; &lt;code&gt;020&lt;/code&gt; = 2*8 = 16).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To tell vim you don't use octal numbers, &lt;code&gt;set nrformats-=octal&lt;/code&gt;. More at &lt;code&gt;:help 'nrformats'&lt;/code&gt; and &lt;code&gt;:help CTRL-A&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-11T22:32:44.760" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24551" PostTypeId="1" AcceptedAnswerId="24553" CreationDate="2020-04-12T02:12:32.083" Score="0" ViewCount="40" Body="&lt;p&gt;I am trying to do a key mapping in vim, yet it doesn't appear to be working how I want it to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my &lt;code&gt;~.vimrc&lt;/code&gt; file I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax on&#xA;colorscheme delek&#xA;nnoremap &amp;lt; gt&#xA;nnoremap &amp;gt; gT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I only include the first two comments to show that I know my &lt;code&gt;.vimrc&lt;/code&gt; is working). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet, after I save the file, using &lt;code&gt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;gt;&lt;/code&gt; does not do anything, though &lt;code&gt;gt&lt;/code&gt; and &lt;code&gt;gT&lt;/code&gt; are still changing tabs as expected. What is wrong with my character mapping? Or do I need to 'refresh vim' or something, the equivalent of &lt;code&gt;$ source ~/.bash_profile&lt;/code&gt; ? &lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-12T02:45:33.587" Title="Mapping tab changes in vim" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24552" PostTypeId="2" ParentId="24547" CreationDate="2020-04-12T02:18:58.077" Score="1" Body="&lt;p&gt;This is a naive solution, but in general I prefer limited simple solutions to&#xA;robust complicated solutions. So maybe this will be helpful to someone:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func URL_Decode()&#xA;   sub/%2C/,/ge&#xA;   sub/%3A/:/ge&#xA;   sub/%5B/[/ge&#xA;   sub/%5D/]/ge&#xA;endfunc&#xA;&#xA;nmap c :call URL_Decode()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7184" LastEditorUserId="7184" LastEditDate="2020-04-20T22:45:33.523" LastActivityDate="2020-04-20T22:45:33.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24553" PostTypeId="2" ParentId="24551" CreationDate="2020-04-12T02:45:33.587" Score="2" Body="&lt;p&gt;I can confirm that there is nothing wrong with your mapping, and that you are correct about needing to reload/refresh your configuration for it to actually be available. One way to do so is to restart Vim, but we can do it faster with the &lt;code&gt;:so&lt;/code&gt; (short for &lt;code&gt;:source&lt;/code&gt;) command and the &lt;code&gt;$MYVIMRC&lt;/code&gt; environment variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:so $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I originally posted this answer to your question on Stack Overflow, but I will post it here as well for those who only browse this site.&lt;/p&gt;&#xA;" OwnerUserId="652" LastActivityDate="2020-04-12T02:45:33.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24554" PostTypeId="1" AcceptedAnswerId="24577" CreationDate="2020-04-12T05:05:51.933" Score="4" ViewCount="5603" Body="&lt;p&gt;To advance to the next/previous character match on a line I can do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;f&lt;/code&gt; &lt;code&gt;&amp;lt;char&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, I find myself wanting to match against two characters on that line, for example, something like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;f&lt;/code&gt; &lt;code&gt;='&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is this possible to do? Or do I need to do a full search at the bottom (starting with &lt;code&gt;/&lt;/code&gt;). I find the search to be a bit 'out of the way' and prefer using &lt;code&gt;f&lt;/code&gt;/&lt;code&gt;F&lt;/code&gt; when I can!&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-14T03:30:39.463" Title="Advance to next (multi)characters on a line" Tags="|search|cursor-movement|find|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24555" PostTypeId="2" ParentId="24537" CreationDate="2020-04-12T05:16:20.027" Score="9" Body="&lt;p&gt;Vim will wait for more keystrokes when there is a longer mapping that starts with the same prefix. Vim is trying to resolve &lt;em&gt;which&lt;/em&gt; of the mappings to trigger, so it will take enough characters to decide whether the user was typing the sequence for the longer one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my particular case, when I tried to reproduce your issue, I had a mapping for &lt;code&gt;ds&lt;/code&gt; from the &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;noreferrer&quot;&gt;vim-surround&lt;/a&gt; plug-in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can list all the normal mode mappings with &lt;code&gt;d&lt;/code&gt; as a prefix with the &lt;code&gt;:map d&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:map d&#xA;n  d           *@:call Function()&amp;lt;CR&amp;gt;&#xA;n  ds            &amp;lt;Plug&amp;gt;Dsurround&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when you type only &lt;code&gt;d&lt;/code&gt;, Vim will wait for the next character to figure out if it's an &lt;code&gt;s&lt;/code&gt; (for &lt;code&gt;ds&lt;/code&gt;), or if it's a different character, in which case it will execute the &lt;code&gt;d&lt;/code&gt; mapping and then execute the extra character as a separate normal mode command, once the &lt;code&gt;d&lt;/code&gt; mapping has finished.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to trigger the shorter mapping is to wait for a timeout (assuming &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27timeout%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'timeout'&lt;/code&gt;&lt;/a&gt; is enabled and &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27timeoutlen%27&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;'timeoutlen'&lt;/code&gt;&lt;/a&gt; configured, the default is enabled at 1s.) But this is of course not ideal, since you still need to wait for the timeout for the mapping to trigger...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution worth mentioning, since you asked about a local mapping on a buffer, is to use the &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-nowait&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt;&lt;/a&gt; modifier. The way &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; works is when you have a &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; mapping (such as your &lt;code&gt;d&lt;/code&gt;) for which global mappings exist which start with the same prefix (such as &lt;code&gt;ds&lt;/code&gt; from vim-surround.) In that case, using &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; will make the local mapping trigger right away, without waiting for more keystrokes to potentially match the longer mapping. This, in effect, disables global longer mappings if any existed. If that's the problem you're also having, this is a potential solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;nowait&amp;gt; d :call Function()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Mapping a command such as &lt;code&gt;d&lt;/code&gt; is an odd choice... You're clobbering the &quot;delete&quot; command, which is pretty central to Vim and text editing. Picking an alternative mapping (such as &lt;code&gt;&amp;lt;Leader&amp;gt;d&lt;/code&gt;) might be advisable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless you're working on using Vim to drive a completely separate user interface (for example, netrw which implements a file browser) and you're planning to reimplement most or all commands. In that case, using &lt;code&gt;&amp;lt;nowait&amp;gt;&lt;/code&gt; to essentially &lt;em&gt;disable&lt;/em&gt; longer global mappings is probably a good idea.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-12T05:16:20.027" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24556" PostTypeId="1" AcceptedAnswerId="24557" CreationDate="2020-04-12T09:03:45.077" Score="0" ViewCount="210" Body="&lt;p&gt;In the case below, how would I find what the definition of &lt;code&gt;[cmd]&lt;/code&gt; or &lt;code&gt;[range]&lt;/code&gt; or &lt;code&gt;{pattern}&lt;/code&gt; is ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KjkjB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KjkjB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried &lt;code&gt;CTRL-]&lt;/code&gt; with my cursor on these, but this does not do anything.&lt;/p&gt;&#xA;" OwnerUserId="21293" LastActivityDate="2020-04-12T12:53:07.780" Title="Help navigating help files" Tags="|help-system|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24557" PostTypeId="2" ParentId="24556" CreationDate="2020-04-12T12:53:07.780" Score="2" Body="&lt;p&gt;&lt;code&gt;CTRL-]&lt;/code&gt; jump is tag based, meaning that it will take word under cursor and jump to the first tag matching it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;somewhere in &lt;code&gt;:help help&lt;/code&gt; and &lt;code&gt;/Jump to speci&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Jump to specific subjects by using tags.  This can be done in two ways:&#xA;- Use the &quot;CTRL-]&quot; command while standing on the name of a command or option.&#xA;  This only works when the tag is a keyword.  &quot;&amp;lt;C-Leftmouse&amp;gt;&quot; and&#xA;  &quot;g&amp;lt;LeftMouse&amp;gt;&quot; work just like &quot;CTRL-]&quot;.&#xA;- use the &quot;:ta {subject}&quot; command.  This also works with non-keyword&#xA;  characters.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-04-12T12:53:07.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24558" PostTypeId="2" ParentId="2380" CreationDate="2020-04-12T13:29:51.210" Score="0" Body="&lt;h3&gt;Map &lt;code&gt;Cmd&lt;/code&gt;+&lt;code&gt;Opt&lt;/code&gt; if pressed alone to &lt;code&gt;/&lt;/code&gt; with &lt;a href=&quot;https://karabiner-elements.pqrs.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Karabiner Elements&lt;/a&gt;&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Install Karabiner Elements&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Install following custom complex modification:  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre class=&quot;lang-json prettyprint-override&quot;&gt;&lt;code&gt;{&#xA;  &quot;title&quot;: &quot;Change Cmd_L and Option_L to Slash (/)&quot;,&#xA;  &quot;rules&quot;: [&#xA;    {&#xA;      &quot;description&quot;: &quot;Change Command_L + Option_L (Alt) to slash (/) if pressed at the same time and without any other key.&quot;,&#xA;      &quot;manipulators&quot;: [&#xA;        {&#xA;          &quot;type&quot;: &quot;basic&quot;,&#xA;          &quot;from&quot;: {&#xA;            &quot;key_code&quot;: &quot;left_option&quot;,&#xA;            &quot;modifiers&quot;: {&#xA;              &quot;mandatory&quot;: [&#xA;                &quot;left_command&quot;&#xA;              ],&#xA;              &quot;optional&quot;: [&#xA;                &quot;any&quot;&#xA;              ]&#xA;            }&#xA;          },&#xA;          &quot;to_if_alone&quot;: [&#xA;            {&#xA;              &quot;key_code&quot;: &quot;slash&quot;&#xA;            }&#xA;          ],&#xA;          &quot;to&quot;: [&#xA;            {&#xA;              &quot;key_code&quot;: &quot;left_option&quot;,&#xA;                &quot;modifiers&quot;: [&#xA;                    &quot;left_command&quot;&#xA;                 ]&#xA;            }&#xA;          ]&#xA;        },&#xA;        {&#xA;          &quot;type&quot;: &quot;basic&quot;,&#xA;          &quot;from&quot;: {&#xA;            &quot;key_code&quot;: &quot;left_command&quot;,&#xA;            &quot;modifiers&quot;: {&#xA;              &quot;mandatory&quot;: [&#xA;                &quot;left_option&quot;&#xA;              ],&#xA;              &quot;optional&quot;: [&#xA;                &quot;any&quot;&#xA;              ]&#xA;            }&#xA;          },&#xA;          &quot;to_if_alone&quot;: [&#xA;            {&#xA;              &quot;key_code&quot;: &quot;slash&quot;&#xA;            }&#xA;          ],&#xA;          &quot;to&quot;: [&#xA;            {&#xA;              &quot;key_code&quot;: &quot;left_command&quot;,&#xA;              &quot;modifiers&quot;: [&#xA;                    &quot;left_option&quot;&#xA;                 ]&#xA;            }&#xA;          ]&#xA;        }&#xA;      ]&#xA;    }&#xA;  ]&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i) Copy json file to the correct location:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cp cmd-opt-alone-to-slash.json ~/.config/karabiner/assets/complex_modifications&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ii) Import rules from Karabiner-Elements Preferences.&#xA;    &lt;code&gt;Karabiner-Elements Preferences &amp;gt; Complex Modifications &amp;gt; Rules &amp;gt; Add rule&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1292" LastActivityDate="2020-04-12T13:29:51.210" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24559" PostTypeId="2" ParentId="24532" CreationDate="2020-04-12T13:43:13.120" Score="1" Body="&lt;p&gt;Fixed by removing &lt;code&gt;botright new&lt;/code&gt; and then calling &lt;code&gt;botright call term_start($SHELL)&lt;/code&gt; (to start a Terminal buffer if one doesn't exist) or &lt;code&gt;execute 'botright sbuffer' . g:terminal_drawer.buffer_id&lt;/code&gt; (to show the buffer) fixed it. Here is the full function now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:terminal_drawer = { 'win_id': v:null, 'buffer_id': v:null }&#xA;function! ToggleTerminalDrawer() abort&#xA;  if win_gotoid(g:terminal_drawer.win_id)&#xA;    hide&#xA;    set laststatus=2 showmode ruler&#xA;  else&#xA;    if !g:terminal_drawer.buffer_id&#xA;      botright call term_start($SHELL)&#xA;      let g:terminal_drawer.buffer_id = bufnr(&quot;$&quot;)&#xA;    else&#xA;      execute 'botright sbuffer' . g:terminal_drawer.buffer_id&#xA;      exec 'normal! i'&#xA;    endif&#xA;&#xA;    exec &quot;resize&quot; float2nr(&amp;amp;lines * 0.25)&#xA;    setlocal laststatus=0 noshowmode noruler&#xA;    setlocal nobuflisted&#xA;    let g:terminal_drawer.win_id = win_getid()&#xA;&#xA;  endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="28878" LastActivityDate="2020-04-12T13:43:13.120" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24560" PostTypeId="1" CreationDate="2020-04-12T14:13:33.277" Score="0" ViewCount="1232" Body="&lt;h1&gt;My goal&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I'm using Neovim under Linux (Arch Linux), but I think it would be just the same with original vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to use nvim with the same colors in a virtual console (tty1, tty2...) without X, and in my terminal emulator (rxvt-unicode) under X (with tmux or not).&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;What I've done already&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I've chosen a theme in my &lt;code&gt;vimrc&lt;/code&gt; file: &lt;code&gt;colorscheme peachpuff&lt;/code&gt; (it seems to be the default one, anyway). I've chosen this theme on purpose since it's a 16 color theme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've reset the colors in my &lt;code&gt;.bashrc&lt;/code&gt; to match the peachpuff theme colors :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [ &quot;$TERM&quot; = &quot;linux&quot; ]; then&#xA;    echo -en &quot;\e]P0343742&quot; #black&#xA;    echo -en &quot;\e]P1F5958B&quot; #darkred&#xA;    echo -en &quot;\e]P2B7E48C&quot; #darkgreen&#xA;    echo -en &quot;\e]P3FFFFB9&quot; #brown&#xA;    echo -en &quot;\e]P47EB6FF&quot; #darkblue&#xA;    echo -en &quot;\e]P5C5C8C6&quot; #darkmagenta&#xA;    echo -en &quot;\e]P6C2EFFF&quot; #darkcyan&#xA;    echo -en &quot;\e]P7DDDDDD&quot; #lightgrey&#xA;    echo -en &quot;\e]P8CCCCCC&quot; #darkgrey&#xA;    echo -en &quot;\e]P9FF8D80&quot; #red&#xA;    echo -en &quot;\e]PADBFFB3&quot; #green&#xA;    echo -en &quot;\e]PBFFBE64&quot; #yellow&#xA;    echo -en &quot;\e]PCA8CEEA&quot; #blue&#xA;    echo -en &quot;\e]PDE296FF&quot; #magenta&#xA;    echo -en &quot;\e]PE9CE9FF&quot; #cyan&#xA;    echo -en &quot;\e]PFEEEEEE&quot; #white&#xA;    #clear #for background artifacting&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;What works&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;It mostly works: the colors are approximately the same in a virtual console as in my terminal emulator. Using &lt;code&gt;tmux&lt;/code&gt; in both of them changes nothing: the colors remain the same. So far, so good!&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;What doesn't work&lt;/h1&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The colors are mostly the same (the blue is blue, the red is red, etc.), but in fact they are much more pale in the virtual console; to the point that it's sometimes hard to tell if a color (e.g. the blue one) is used or not, whereas there's no doubt in my terminal emulator. Why is that? Does it default to a near and more pale color, or is there another reason? And how can I avoid it?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The vim/nvim background in a terminal emulator is always black (&lt;code&gt;#000000&lt;/code&gt;, which seems weird to me, since it's not defined anywhere in my colorscheme), whereas in a virtual console it matches the black color defined in the &lt;code&gt;.bashrc&lt;/code&gt; (&lt;code&gt;echo -en &quot;\e]P0343742&quot; #black&lt;/code&gt;, which seems more logical). How can I have them match together, without setting the black color to &lt;code&gt;#000000&lt;/code&gt; (since it's used in the theme as a gray-ish color)? Another way to ask it would be: is there a way to set the virtual console background separately?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;Bonus question&lt;/h1&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Does anyone know of a 16 color scheme anywhere that would have a matching &lt;code&gt;.bashrc&lt;/code&gt; theme, that would just work, and save me the pain to find all this by myself? I wonder why it is so hard to find this; I'm surprised no one seems to have done this before, since if it worked, I could live in a virtual console most of the time, without running X and a terminal emulator...&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="28889" LastEditorUserId="28889" LastEditDate="2020-04-12T18:35:10.410" LastActivityDate="2020-04-12T18:35:10.410" Title="Same colors everywhere : terminal, tty, tmux" Tags="|colorscheme|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="24561" PostTypeId="1" CreationDate="2020-04-12T15:21:12.483" Score="5" ViewCount="6393" Body="&lt;p&gt;I would like to use vim as a c++ IDE. Is there a possibility to run &quot;make&quot; and see the &quot;make&quot; progression in a separate (newly opened) pane. Also, the consecutive execution of the binary would be nice.&lt;/p&gt;&#xA;" OwnerUserId="28911" LastActivityDate="2020-04-17T11:04:12.540" Title="Running make from vim" Tags="|makeprg|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24562" PostTypeId="2" ParentId="24561" CreationDate="2020-04-12T15:42:13.787" Score="5" Body="&lt;p&gt;Yes, Vim has the built in &lt;code&gt;:make&lt;/code&gt; command which executes &lt;code&gt;make&lt;/code&gt; by default, but you can set up other build systems by setting &lt;code&gt;makeprg&lt;/code&gt;. There’s no progress visualisation by default, but once &lt;code&gt;:make&lt;/code&gt; is done you can move through errors an earnings encountered with &lt;code&gt;:cnext&lt;/code&gt; and &lt;code&gt;:cprev&lt;/code&gt;. Calling &lt;code&gt;:copen&lt;/code&gt; will show you all of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One disadvantage though is that &lt;code&gt;:make&lt;/code&gt; is synchronous so your Vim instance will be blocked until compilation finish. There are plugins like &lt;a href=&quot;https://github.com/neomake/neomake&quot; rel=&quot;noreferrer&quot;&gt;Neomake&lt;/a&gt; that implement similar functionality using the asynchronous API.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There’s no default way to run your compiled program, but you can define a custom mapping or command to run it after compilation  &lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-12T15:42:13.787" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24563" PostTypeId="1" AcceptedAnswerId="24568" CreationDate="2020-04-12T21:47:05.283" Score="1" ViewCount="33" Body="&lt;p&gt;I've found that neovim-qt is storing my .swp files in &lt;code&gt;AppData/Local/nvim-data/swap&lt;/code&gt; and I was wondering if it's possible to change this to get the standard vim behaviour of creating them locally.&lt;/p&gt;&#xA;" OwnerUserId="24943" LastActivityDate="2020-04-13T09:56:04.657" Title="Can I use local .swp files with neovim-qt?" Tags="|neovim-qt|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24564" PostTypeId="2" ParentId="10598" CreationDate="2020-04-12T21:59:00.580" Score="0" Body="&lt;p&gt;Sorry, because I dont know anymore where I found this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; share data between nvim instances (registers etc)&#xA;augroup SHADA&#xA;    autocmd!&#xA;    autocmd CursorHold,TextYankPost,FocusGained,FocusLost *&#xA;                \ if exists(':rshada') | rshada | wshada | endif&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2020-04-12T21:59:00.580" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24566" PostTypeId="1" CreationDate="2020-04-13T07:18:34.510" Score="1" ViewCount="55" Body="&lt;p&gt;How do I make sure that my keymap only works in insert mode and nowhere else. Now it also becomes active in search and I don't want this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A secondary question I also have is: why is my keymap becoming active in denite&#xA;search windows. This is regardless of whether my keymap is turned on or off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I would like my keymap to work in INSERT mode absolutely nowhere else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&lt;/p&gt;&#xA;" OwnerUserId="28793" LastEditorUserId="28793" LastEditDate="2020-04-13T08:12:53.133" LastActivityDate="2020-05-13T10:04:05.413" Title="how make `set keymap` only work in insert mode, NOT search" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24567" PostTypeId="2" ParentId="24566" CreationDate="2020-04-13T07:57:02.447" Score="1" Body="&lt;p&gt;I’ve never used &lt;code&gt;keymap&lt;/code&gt; before, but my understanding of &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/options.html#&amp;#39;imsearch&amp;#39;&quot; rel=&quot;nofollow noreferrer&quot;&gt;the documentation&lt;/a&gt; is that you should set &lt;code&gt;imsearch&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="786" LastEditorUserId="786" LastEditDate="2020-04-13T09:39:58.837" LastActivityDate="2020-04-13T09:39:58.837" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24568" PostTypeId="2" ParentId="24563" CreationDate="2020-04-13T09:56:04.657" Score="3" Body="&lt;p&gt;One of the goals of Neovim is to provide defaults that work for the majority of its users, and &lt;a href=&quot;https://github.com/neovim/neovim/issues/4481#issuecomment-241683244&quot; rel=&quot;nofollow noreferrer&quot;&gt;to avoid users disabling swap files, they changed their default location&lt;/a&gt;. You can go back to the Vim default with &lt;code&gt;set directory=.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW you may want to consult &lt;code&gt;:help nvim-defaults&lt;/code&gt; which lists all default changes that Neovim introduced&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-13T09:56:04.657" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24569" PostTypeId="2" ParentId="24544" CreationDate="2020-04-13T12:31:50.110" Score="1" Body="&lt;p&gt;With the help of &lt;a href=&quot;https://vi.stackexchange.com/users/10604/d-ben-knoble&quot;&gt;D. Ben Knoble&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi StatusLine           guifg=#000000 guibg=#00CC00 gui=none &quot; WARNING! By default gui set to reverse, need to overide it with none&#xA;hi StatusLineNC         guifg=#192224 guibg=#ABABAB gui=none &quot; Status line None current&#xA;hi _StatusFileName      guifg=#FFFFFF guibg=#007700 gui=bold&#xA;hi _StatusFileNameNC    guifg=#FFFFFF guibg=#777777 gui=bold&#xA;hi _StatusModified      guifg=#FFFFFF guibg=#FF0000 gui=BOLD&#xA;hi _StatusGit           guifg=#009900 guibg=#00CC00&#xA;hi _StatusGitNC         guifg=#777777 guibg=#ABABAB&#xA;&#xA;function MyStatusLine(currentWindow)&#xA;    let s = &quot;&quot;&#xA;    let s .= &quot;%{&amp;amp;l:modifiable?expand('%:h').'/':''}&quot;    &quot; Show file path head for modifiable files&#xA;    let s .= &quot;%{(&amp;amp;readonly||!&amp;amp;modifiable)?'[R]':''}&quot;    &quot; If readonly file, show [R] instead of filepath&#xA;    if a:currentWindow&#xA;        let s .= &quot;%#_StatusFileName#&quot;                   &quot; Change to StatusFileName highlighting&#xA;    else&#xA;        let s .= &quot;%#_StatusFileNameNC#&quot;                 &quot; Change to StatusFileNameNC highlighting&#xA;    endif&#xA;    let s .= &quot; %t &quot;                                     &quot; filename only no path (Tail)&#xA;    let s .= &quot;%*&quot;                                       &quot; Return to default color StatusLine / StatusLineNC&#xA;    let s .= &quot;%#_StatusModified#%{&amp;amp;modified?' +++ ':''}%*&quot;&#xA;    let s .= &quot; %= &quot;                                     &quot; Left/Right separator&#xA;    if exists('g:loaded_fugitive')&#xA;        if a:currentWindow&#xA;            let s .= &quot;%*%#_StatusGit#%{&amp;amp;l:modifiable ? fugitive#statusline() : ''}%*&quot;&#xA;        else&#xA;            let s .= &quot;%*%#_StatusGitNC#%{&amp;amp;l:modifiable ? fugitive#statusline() : ''}%*&quot;&#xA;        endif&#xA;    endif&#xA;    let s .= &quot; %6l&quot;                                     &quot; Current line number&#xA;    let s .= &quot;,%-3c&quot;                                    &quot; Current column number, left aligned 3 characters wide&#xA;    let s .= &quot; %P &quot;                                     &quot; Percentage through the file&#xA;    return s&#xA;endfunction&#xA;&quot;set statusline=%!MyStatusLine('Enter')&#xA;autocmd BufWinEnter,WinEnter * setlocal statusline=%!MyStatusLine(1)&#xA;autocmd WinLeave * setlocal statusline=%!MyStatusLine(0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-04-13T12:31:50.110" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24570" PostTypeId="2" ParentId="24561" CreationDate="2020-04-13T12:58:23.987" Score="1" Body="&lt;h3&gt;Throw away make&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;make&lt;/code&gt; is synchronous, that's it, just throw it away.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Async tool&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;One can use &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#%3Aterminal&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :terminal&lt;/a&gt;  or &lt;a href=&quot;https://vimhelp.org/terminal.txt.html#term_start%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h term_start()&lt;/a&gt; to do async stuff in &lt;code&gt;vim&lt;/code&gt;.&#xA;We will use &lt;code&gt;term_start&lt;/code&gt; here as the basic async tool.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Goal&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Async make, update &lt;code&gt;quickfix&lt;/code&gt; after it, user should see the making progress just like make in terminal.&lt;/li&gt;&#xA;&lt;li&gt;Show &lt;code&gt;make successful&lt;/code&gt; message if no error, no warning happens.&lt;/li&gt;&#xA;&lt;li&gt;Show &lt;code&gt;found n qf entries&lt;/code&gt; if there exists &lt;code&gt;quickfix&lt;/code&gt; entry with specific buffer number and line number.&lt;/li&gt;&#xA;&lt;li&gt;Toggle making buffer if user request &lt;code&gt;make&lt;/code&gt; again during &lt;code&gt;making&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Spawn new make, delete last making buffer if user request &lt;code&gt;make&lt;/code&gt; during &lt;code&gt;idle&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Interface&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;f7&amp;gt; :Make&amp;lt;cr&amp;gt;&#xA;command -nargs=* Make call s:make(&amp;lt;q-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Spawn async job&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:making = 0&#xA;&#xA;function s:make(args) abort&#xA;&#xA;  if s:making&#xA;    if bufwinid(s:make_buf) == -1&#xA;      &quot; show making buffer&#xA;      exe 'sbuffer' s:make_buf&#xA;      wincmd p&#xA;    else&#xA;      &quot; hide making buffer&#xA;      exe printf('%d wincmd q', bufwinnr(s:make_buf))&#xA;    endif&#xA;    return&#xA;  endif&#xA;&#xA;  &quot; delete last result&#xA;  if exists('s:make_buf') &amp;amp;&amp;amp; bufexists(s:make_buf)&#xA;    silent! exe 'bdelete' s:make_buf&#xA;  endif&#xA;&#xA;  &quot; spawn new make&#xA;  let cmd = 'make'&#xA;  if !empty(a:args)&#xA;    let cmd .= ' ' . a:args&#xA;  endif&#xA;&#xA;  let options = {'close_cb': function('s:make_callback'), 'term_rows': 16}&#xA;&#xA;  let s:make_buf = term_start(cmd, options)&#xA;  let s:making = 1&#xA;&#xA;  wincmd p&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;The subtle handler&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func s:make_callback(channel)&#xA;&#xA;  &quot; look, you can not get buffer content directly here.&#xA;  call timer_start(10, function('s:make_callback_impl'))&#xA;endfunction&#xA;&#xA;function s:make_callback_impl(timer) abort&#xA;&#xA;  exe 'cgetbuffer' s:make_buf&#xA;&#xA;  &quot; consider entry with num zero bufnr and lnum an error or warning&#xA;  let qfl = filter(getqflist(), {k,v -&amp;gt; v.bufnr != 0 &amp;amp;&amp;amp; v.lnum != 0})&#xA;&#xA;  if empty(qfl)&#xA;    echo &quot;make successful&quot;&#xA;  else&#xA;    echohl WarningMsg&#xA;    echom printf('found %d qf entries', len(qfl))&#xA;    echohl None&#xA;  endif&#xA;&#xA;  let s:making = 0&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Be careful here, one might try to get buffer directly at &lt;code&gt;s:make_callback&lt;/code&gt;, that won't work, see&#xA; &lt;a href=&quot;https://vi.stackexchange.com/questions/20402/how-to-flush-job-output-in-vim8&quot;&gt;this question&lt;/a&gt; for detail.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-04-16T08:49:25.537" LastActivityDate="2020-04-16T08:49:25.537" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24572" PostTypeId="2" ParentId="24554" CreationDate="2020-04-13T16:12:40.127" Score="1" Body="&lt;p&gt;Some plugins make it possible. The one I tried out is called &lt;a href=&quot;https://github.com/justinmk/vim-sneak&quot; rel=&quot;nofollow noreferrer&quot;&gt;sneak&lt;/a&gt; and is quite good. Its readme list other similar plugins that you can try&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-13T16:12:40.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24573" PostTypeId="1" CreationDate="2020-04-13T18:35:59.190" Score="3" ViewCount="88" Body="&lt;p&gt;In my vimrc I use &lt;code&gt;:setg tabstop=4 shiftwidth=4&lt;/code&gt;. Why aren't unnamed buffers set correctly with these values? Using VIM 8.2.460 (2019 Dec 12)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I opened vim with some piped output and noticed tab width was 8. So I typed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:setglobal tabstop?&#xA;  tabstop=4&#xA;        Last set from /etc/vim/vimrc.local line 36&#xA;&#xA;:setlocal tabstop?&#xA;  tabstop=8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I use &lt;code&gt;:setlocal&lt;/code&gt;, some options are shown but tabstop is not in the list. This means it's picking the vim default (8).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone have any ideas about this? Aren't global options supposed to be used for new buffers?&lt;/p&gt;&#xA;" OwnerUserId="22416" LastEditorUserId="51" LastEditDate="2020-04-14T05:21:35.180" LastActivityDate="2020-04-14T16:09:38.650" Title="Unnamed buffer not using options from my vimrc" Tags="|vimrc|options|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24574" PostTypeId="1" AcceptedAnswerId="24627" CreationDate="2020-04-13T21:49:32.553" Score="1" ViewCount="403" Body="&lt;p&gt;I would like to format Markdown headings to titlecase, and I have a bash command that works to format input:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;convert to title&quot; | awk 'BEGIN{split(&quot;a the to at in on with and but or&quot;,w); for(i in w)nocap[w[i]]}function cap(word){return toupper(substr(word,1,1)) tolower(substr(word,2))}{for(i=1;i&amp;lt;=NF;++i){printf &quot;%s%s&quot;,(i==1||i==NF||!(tolower($i) in nocap)?cap($i):tolower($i)),(i==NF?&quot;\n&quot;:&quot; &quot;)}}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to format all my Markdown headings in the current buffer to have this conversion done. I know I need to use &lt;code&gt;!&lt;/code&gt; somehow, basically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;IF line begins with # or ## or ### &#xA;  THEN run the line through the external command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The vimscript is too advanced for me... can anyone help?&lt;/p&gt;&#xA;" OwnerUserId="28938" LastActivityDate="2020-04-17T09:33:17.070" Title="How can I format all Markdown # headings using a bash command?" Tags="|vimscript|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24575" PostTypeId="2" ParentId="24574" CreationDate="2020-04-14T01:23:51.753" Score="3" Body="&lt;p&gt;All you need is the global command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/^#/.!your awk command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This says « for all lines matching &lt;code&gt;^#&lt;/code&gt;, filter them through &lt;code&gt;your awk command&lt;/code&gt; ». The &lt;code&gt;.&lt;/code&gt; is explicitly needed here (where it usually isn't) because &lt;code&gt;:!&lt;/code&gt; runs a command, but &lt;code&gt;:[range]!&lt;/code&gt; runs the command as a filter. While &lt;code&gt;:global&lt;/code&gt; usually acts like a range, in this odd case it doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;%&lt;/code&gt; is always current filename, you need to escape it as &lt;code&gt;\%&lt;/code&gt;. And when running &lt;code&gt;!&lt;/code&gt; commands, &lt;code&gt;!&lt;/code&gt; will be replaced by the last &lt;code&gt;!&lt;/code&gt; command. To avoid that, you can escape it too: &lt;code&gt;\!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This gives&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global/^#/.!awk 'BEGIN{split(&quot;a the to at in on with and but or&quot;,w); for(i in w)nocap[w[i]]}function cap(word){return toupper(substr(word,1,1)) tolower(substr(word,2))}{for(i=1;i&amp;lt;=NF;++i){printf &quot;\%s\%s&quot;,(i==1||i==NF||\!(tolower($i) in nocap)?cap($i):tolower($i)),(i==NF?&quot;\n&quot;:&quot; &quot;)}}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As was pointed out in the comments, an even more compose-able/reusable way of doing this would be to create a script something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#! /usr/bin/awk -f&#xA;&#xA;BEGIN {&#xA;    split(&quot;a the to at in on with and but or&quot;,w)&#xA;    for(i in w)&#xA;        nocap[w[i]]&#xA;}&#xA;function cap(word) {&#xA;    return toupper(substr(word,1,1)) tolower(substr(word,2))&#xA;}&#xA;{&#xA;    for(i=1;i&amp;lt;=NF;++i) {&#xA;        printf &quot;%s%s&quot;, (i==1 || i==NF || !(tolower($i) in nocap) ? cap($i) : tolower($i)), (i==NF?&quot;\n&quot;:&quot; &quot;)&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you save this on somewhere on your &lt;code&gt;PATH&lt;/code&gt; (call it, say, &lt;code&gt;titlecase&lt;/code&gt;) and &lt;code&gt;chmod u+x&lt;/code&gt; it, then you can call it from your shell and from vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:global/^#/.!titlecase&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One benefit this has is you don't need the escaping at all.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-04-16T01:19:44.423" LastActivityDate="2020-04-16T01:19:44.423" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24577" PostTypeId="2" ParentId="24554" CreationDate="2020-04-14T03:11:00.170" Score="6" Body="&lt;p&gt;Vim provides the &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt; or &lt;code&gt;F&lt;/code&gt;, &lt;code&gt;T&lt;/code&gt; command to jump forward or backward to a character in current line, and you can repeat the action by pressing &lt;code&gt;,&lt;/code&gt; or &lt;code&gt;;&lt;/code&gt;. While these commands are useful, they are not powerful enough to be of real value:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The movement is restricted to current line.&lt;/li&gt;&#xA;&lt;li&gt;There are possibly many repetitions since you can only provide one character.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/justinmk/vim-sneak&quot; rel=&quot;noreferrer&quot;&gt;vim-sneak&lt;/a&gt; solves these two issues neatly. With vim-sneak, you can go anywhere your eyes can see in just four key strokes in most cases, which is one of the most amazing plugins I have ever seen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After installing this plugin, add the following minimal settings to your configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:sneak#label = 1&#xA;nmap f &amp;lt;Plug&amp;gt;Sneak_s&#xA;nmap F &amp;lt;Plug&amp;gt;Sneak_S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above settings will map &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;F&lt;/code&gt; to search forward and backward respectively and use the sneak label mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you want to go to the character &lt;code&gt;i&lt;/code&gt; which is followed by &lt;code&gt;m&lt;/code&gt;, first press &lt;code&gt;f&lt;/code&gt;, then press &lt;code&gt;im&lt;/code&gt;, all occurrences of im will be highlighted and given a label.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Press the character in a label, the cursor will jump to that location, which is really amazing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another similar vim plugin is &lt;a href=&quot;https://github.com/easymotion/vim-easymotion&quot; rel=&quot;noreferrer&quot;&gt;vim-easymotion&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ref: &lt;a href=&quot;https://jdhao.github.io/2019/06/26/movement_navigation_inside_nvim/#precise-cursor-movement&quot; rel=&quot;noreferrer&quot;&gt;precise cursor movement in vim&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15292" LastEditorUserId="15292" LastEditDate="2020-04-14T03:30:39.463" LastActivityDate="2020-04-14T03:30:39.463" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24578" PostTypeId="1" CreationDate="2020-04-14T04:30:03.443" Score="0" ViewCount="65" Body="&lt;p&gt;I often find myself using the following no matter what the program is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Cmd&lt;/code&gt; &lt;code&gt;s&lt;/code&gt; to save.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Cmd&lt;/code&gt; &lt;code&gt;a&lt;/code&gt; to select-all&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Cmd&lt;/code&gt; &lt;code&gt;t&lt;/code&gt; to open a new tab&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Cmd&lt;/code&gt; &lt;code&gt;c&lt;/code&gt; to copy&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Cmd&lt;/code&gt; &lt;code&gt;v&lt;/code&gt; to paste&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Cmd&lt;/code&gt; &lt;code&gt;z&lt;/code&gt; to undo&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Cmd&lt;/code&gt; &lt;code&gt;Shift&lt;/code&gt; z to redo&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That how it works in most computers, regardless of what mode I'm in or whatever. What would be a good keyboard mapping I can use in &lt;code&gt;vim&lt;/code&gt; to do something similar? I don't believe &lt;code&gt;cmd&lt;/code&gt; is supposed (without doing some odd mapping). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also am not a big fan of using &lt;code&gt;ctrl&lt;/code&gt; as I often use that in other programs to advance to the start of a line &lt;code&gt;ctrl&lt;/code&gt; &lt;code&gt;a&lt;/code&gt; or advance to the end of the line &lt;code&gt;ctrl&lt;/code&gt; &lt;code&gt;e&lt;/code&gt;, and I'm already familiar with &lt;code&gt;ctrl&lt;/code&gt; &lt;code&gt;v&lt;/code&gt; for visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What might be a good mapping where I can do something that might feel close to doing the &lt;code&gt;cmd&lt;/code&gt;-&lt;code&gt;letter&lt;/code&gt; input, i.e. and it will work across all modes (that is, I should be able to select-all whether I'm in normal mode or insert mode)? Additionally, if useful, I'm using vim on mac and (mainly) ubuntu.&lt;/p&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="51" LastEditDate="2020-04-14T05:15:48.767" LastActivityDate="2020-04-18T18:26:36.913" Title="Suggested short-cuts for &quot;Command&quot; shortcuts used across most programs" Tags="|vimrc|key-bindings|macos|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24579" PostTypeId="1" AcceptedAnswerId="24581" CreationDate="2020-04-14T07:24:32.590" Score="1" ViewCount="676" Body="&lt;p&gt;I've used two plugins with vim: &lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nerdtree&lt;/a&gt; and &lt;a href=&quot;https://github.com/vim-scripts/taglist.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Taglist&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n6QT6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n6QT6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I quit the opened file and open another file in the Nerdtree, it will become:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8Hh69.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8Hh69.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which means that the new opened file is displayed at the bottom right corner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to manage the windows properly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initial state:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|          |             |         |&#xA;| Nerdtree | opened file | taglist |&#xA;|          |             |         |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;close the opened file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|                    |         |&#xA;|      Nerdtree      | taglist |&#xA;|                    |         |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;reopen another file (this is not what I expected)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|                    |   taglist   |&#xA;|      Nerdtree      |-------------|&#xA;|                    | opened file |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I expected is to get the layout just like the initial state.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|          |             |         |&#xA;| Nerdtree | opened file | taglist |&#xA;|          |             |         |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2020-04-14T11:18:47.263" LastActivityDate="2020-04-14T11:18:47.263" Title="How to manage windows properly" Tags="|vim-windows|plugin-nerdtree|window-management|plugin-taglist|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24580" PostTypeId="2" ParentId="24579" CreationDate="2020-04-14T09:57:50.870" Score="2" Body="&lt;p&gt;I don’t use NERDTree myself, but reading the documentation it looks like you want the &lt;code&gt;s&lt;/code&gt; map, which opens the selected file in a new vertical split. You may also need to add &lt;code&gt;set splitright&lt;/code&gt; to your &lt;code&gt;.vimrc&lt;/code&gt; to ensure that the split is created at the right of the NERDTree window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep in mind though that as your layouts get more complex your workflow may suffer. &lt;a href=&quot;http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here is an alternative that always work in a predictable way&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-14T09:57:50.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24581" PostTypeId="2" ParentId="24579" CreationDate="2020-04-14T10:15:25.960" Score="1" Body="&lt;p&gt;Nerdtree is the beast on its own (don't like it personally but anyway)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try following snippet of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;func! MyOpen() abort&#xA;    let selected = g:NERDTreeFileNode.GetSelected()&#xA;    if selected != {}&#xA;        &quot;remove everyother window&#xA;        wincmd o&#xA;&#xA;        &quot;open selected file in vertical split&#xA;        exe &quot;vsplit &quot; . selected.path.str()&#xA;&#xA;        &quot;open taglist in a vertical split&#xA;        &quot;I don't have taglist installed so, use whatever taglist command is&#xA;        &quot;instead of vslpit and enew.&#xA;        vsplit&#xA;        enew&#xA;    endif&#xA;endfunc&#xA;augroup nerdtree_open | au!&#xA;    au FileType nerdtree nnoremap &amp;lt;buffer&amp;gt; &amp;lt;CR&amp;gt; :call MyOpen()&amp;lt;CR&amp;gt;&#xA;augroup end&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And use taglist commands instead of the last &lt;code&gt;vsplit&lt;/code&gt; and &lt;code&gt;enew&lt;/code&gt; (I don't have taglist installed and didn't find it on github)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, it will always remove all your windows except nerdtree and vertically split selected filename, plus if you add there taglist commands -- it would probably what you want. But I am not sure. :)&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-04-14T10:15:25.960" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24582" PostTypeId="1" AcceptedAnswerId="24583" CreationDate="2020-04-14T10:16:02.227" Score="1" ViewCount="192" Body="&lt;p&gt;I have an R file of results, such as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filename run1 run2 run3&#xA;file1.py 109 103 100&#xA;file2.py 14123 14323 14333  &#xA;...&#xA;filen.py 2007 2130 2001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the easiest way to use VIM for adding decimal mark three places (from back, div 1000) to each number in each line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;filename run1 run2 run3&#xA;file1.py 0.109 0.103 0.100&#xA;file2.py 14.123 14.323 14.333  &#xA;...&#xA;filen.py 2.007 2.130 2.001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As @BLayer commented:&#xA;Updated the example to make it more clear. For example numbers 1 and 10 should remain the same but three digit numbers like 100 should become  0.100.  &lt;/p&gt;&#xA;" OwnerUserId="19670" LastEditorUserId="19670" LastEditDate="2020-04-15T11:14:40.297" LastActivityDate="2020-04-15T11:14:40.297" Title="Add decimal mark to each number of each line" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24583" PostTypeId="2" ParentId="24582" CreationDate="2020-04-14T11:01:54.740" Score="4" Body="&lt;p&gt;here's the simplest way of doing it from my point of view:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\d\{3}\&amp;gt;/.&amp;amp;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Explanation&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%s&lt;/code&gt; is here to search and replace&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\d\{3}&lt;/code&gt; represents 3 digits&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\&amp;gt;&lt;/code&gt; represents the end of a word (here the end of the number)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt; is a dot&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;&lt;/code&gt; repeats what you matched&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/users/11054/b-layer&quot;&gt;@BLayer&lt;/a&gt; noted, this solution can create numbers starting with a dot (e.g. &quot;&lt;code&gt;.123&lt;/code&gt;&quot;).&lt;br&gt;&#xA;If That's not something you want, you can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Exclude the 3 digits numbers from the search:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\d\zs\d\{3}\&amp;gt;/.&amp;amp;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Add a leading 0:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\D\zs\d\{3}\&amp;gt;/0.&amp;amp;/g&#xA;:%s/\d\zs\d\{3}\&amp;gt;/.&amp;amp;/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="27331" LastEditDate="2020-04-15T08:27:16.643" LastActivityDate="2020-04-15T08:27:16.643" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24584" PostTypeId="1" AcceptedAnswerId="24585" CreationDate="2020-04-14T14:48:16.270" Score="1" ViewCount="205" Body="&lt;p&gt;I want to run a command when I change the textwidth.&#xA;I have tried&#xA;     autocmd CmdlineLeave * call Myfunction()&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I do &lt;code&gt;:set tw=40&lt;/code&gt;, the function is called before tw is changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to do this ?&lt;/p&gt;&#xA;" OwnerUserId="2510" LastActivityDate="2020-04-14T15:39:42.383" Title="event on command executed" Tags="|autocmd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24585" PostTypeId="2" ParentId="24584" CreationDate="2020-04-14T15:39:42.383" Score="5" Body="&lt;p&gt;There's &lt;code&gt;OptionSet&lt;/code&gt; autocommand. For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup test | au!&#xA;    autocmd OptionSet textwidth call NewTextWidth(v:option_type, v:option_new)&#xA;augroup end&#xA;&#xA;function! NewTextWidth(type, value)&#xA;    echom 'set' a:type 'textwidth' a:value&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-04-14T15:39:42.383" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24586" PostTypeId="2" ParentId="24573" CreationDate="2020-04-14T16:09:38.650" Score="1" Body="&lt;p&gt;This is the first buffer only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While vimrc is being sourced the buffer #1 already exists (but unloaded), and so it has its local option values (default ones). Now when you &lt;code&gt;setglobal tabstop&lt;/code&gt; you don't change it, so it's still eight.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-04-14T16:09:38.650" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24587" PostTypeId="1" AcceptedAnswerId="24623" CreationDate="2020-04-14T20:28:48.957" Score="2" ViewCount="1402" Body="&lt;p&gt;On an up-to-date Arch system, I set up marker-based folds in &lt;code&gt;vim&lt;/code&gt; and &lt;code&gt;python&lt;/code&gt; scripts like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extracted from my &lt;code&gt;~/.vimrc&lt;/code&gt; [&lt;a href=&quot;https://github.com/Cbhihe/dotfiles/blob/master/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible  &quot; default&#xA;filetype plugin indent on&#xA;set nofoldenable&#xA;set foldlevel=1&#xA;set foldcolumn=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Along with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat ~/.vim/after/ftplugin/vim.vim&#xA;setlocal foldmethod=marker&#xA;setlocal foldmarker={{{,}}}  &quot; Default for fdm=marker&#xA;&#xA;$ cat ~/.vim/after/ftplugin/python.vim&#xA;setlocal foldmethod=marker&#xA;setlocal foldmarker={{{,}}}  &quot; Default for fdm=marker&#xA;setlocal foldnestmax=3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works for vim scripts but not for python. I've been at it most of one day already and frankly I am missing something. I am currently resorting to committing the content of &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt; directly to &lt;code&gt;~/.vimrc&lt;/code&gt; and setting the corresponding parameters globally instead of locally.  That works well, but that also excludes the possibility of differentiating settings, e.g.: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;marker-based folds in &lt;code&gt;vim&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;indent-based or syntax-based folds in &lt;code&gt;python&lt;/code&gt; or in &lt;code&gt;bash&lt;/code&gt; scripts. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;What am I doing wrong ?&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;With all setting committed globaly to &lt;code&gt;~/.vimrc&lt;/code&gt;, what I get in the &lt;code&gt;vim&lt;/code&gt; buffer of any python module is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;: verbose set filetype? foldmethod? foldmarker?&#xA;      filetype=python&#xA;            Last set from /usr/share/vim/vim82/filetype.vim line 1291                                                      &#xA;      foldmethod=marker&#xA;            Last set from ~/.vim/view/~=+Documents=+Work=+Projects=+xxx-data=+Src=+proof_demo.py= line 67&#xA;      foldmarker={{{,}}}&#xA;            Last set from ~/.vim/view/~=+Documents=+Work=+Projects=+xxx-data=+Src=+proof_demo.py= line 66 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;What &quot;it doesn't work&quot; means&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;It doesn't fold at all when I do &lt;code&gt;zc&lt;/code&gt;, other than where I have previously set fold(s) manually. &lt;code&gt;zM&lt;/code&gt; has no effect at all (for example when &lt;code&gt;foldmethod=indent&lt;/code&gt; in &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt;), again except when markers are set manually (provided &lt;code&gt;foldmethod=marker&lt;/code&gt; in &lt;code&gt;~/.vimrc&lt;/code&gt;). Same behavior for all python files, which tells me it is probably some deep-seated issue, not malformed python file. Same in shell scripts with a similarly built &lt;code&gt;~/.vim/after/ftplugin/sh.vim&lt;/code&gt;, so it's not python specific.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Views info&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The most interesting use case in that context is when &lt;code&gt;foldmethod=manual&lt;/code&gt; because, without views, manually set folds are lost upon closing the buffer. But I need views to be able to go back to the buffer's last cursor position (line + col) when re-opening a file with vim. I need views for that because the alternative I did implement before I started using folds, based on &lt;a href=&quot;https://vim.fandom.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim.fandom.com/wiki/…&lt;/a&gt;, is incompatible with implementing any kind of folds apparently. It just fails silently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out my use of &quot;views&quot; is not compatible with parsing settings from &lt;code&gt;~/.vim/after/ftplugin/*.vim&lt;/code&gt; files. &quot;Why ?&quot; is beyond me. I am not sure whether it is the execution context I build by means of my &lt;code&gt;~/.vimrc&lt;/code&gt; or a bug. I would tend to favor the first, although I really don't have much special in &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4547" LastEditorUserId="10604" LastEditDate="2020-05-01T16:03:40.070" LastActivityDate="2020-05-01T16:03:40.070" Title="Changing foldmarker per filetype with vim 8.2" Tags="|vimrc|folding|filetype|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24588" PostTypeId="1" AcceptedAnswerId="24590" CreationDate="2020-04-14T21:40:17.440" Score="1" ViewCount="68" Body="&lt;p&gt;I have a function that animates the insertion of the contents of the last modified register at the cursor's location as if someone was typing it:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! AnimateInsertion() abort&#xA;    &amp;quot; split contents of last modified reg in individual chars&#xA;    let s:line = split(getreg(v:register), '\zs')&#xA;    &amp;quot; iterate through each character&#xA;    for s:char in s:line&#xA;        sleep 100m&#xA;        exe 'normal!a' s:char&#xA;        redraw&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I run this function with the text &lt;code&gt;Try me&lt;/code&gt; inside the last modified register, the following text gets inserted:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; T r y   m e &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Evidently, there is a problem with the &lt;code&gt;exe 'normal!a' s:char&lt;/code&gt; line. Why are the spaces between the letter being inserted? What is the proper way of doing this?&lt;/p&gt;&#xA;" OwnerUserId="27039" LastEditorUserId="27039" LastEditDate="2021-08-10T21:37:06.350" LastActivityDate="2021-08-10T21:37:06.350" Title="Problem when inserting text from a function in a for loop" Tags="|vimscript|insert-mode|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24589" PostTypeId="1" CreationDate="2020-04-14T21:45:22.517" Score="2" ViewCount="1733" Body="&lt;p&gt;The download page clearly states that the gvim82.exe installer has an option to choose which version of vim to install, a 32- or a 64-bit. I cannot find this option. The installed vim is 32-bit, while I need a 64-bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="28961" LastEditorUserId="11054" LastEditDate="2020-04-15T17:36:04.533" LastActivityDate="2021-06-14T04:30:40.460" Title="How do you install 64-bit version of vim 8.2 from gvim82.exe?" Tags="|installing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24590" PostTypeId="2" ParentId="24588" CreationDate="2020-04-14T21:51:31.567" Score="2" Body="&lt;p&gt;By default, arguments to &lt;code&gt;:execute&lt;/code&gt; are separated with a space. &lt;code&gt;:execute '123' '456'&lt;/code&gt; is the same as &lt;code&gt;:execute '123 456'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid the space, use &lt;code&gt;.&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execute 'normal! a'.s:char&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-14T21:51:31.567" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24591" PostTypeId="2" ParentId="24589" CreationDate="2020-04-14T22:27:48.390" Score="1" Body="&lt;p&gt;I don't think it clearly states what you say it does, actually. It says...&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;[this installer] includes GUI and console versions, for 32 bit and 64 bit systems.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;That means the GUI and console versions will work on 64-bit systems. It doesn't mean the executable is 64-bit.&lt;/p&gt;&#xA;&lt;p&gt;If you continue reading...&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;There are &lt;em&gt;also&lt;/em&gt; 64bit versions which only run on 64 bit MS-Windows and use a lot more memory, but is compatible with 64 bit plugins.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;(My emphasis on the &amp;quot;also&amp;quot;.)&lt;/p&gt;&#xA;&lt;p&gt;They don't recommend using the 64-bit version so they don't provide ready access to it. (It also used to say that &amp;quot;it wasn't used much and maintenance stopped&amp;quot; but that was removed at some point.)&lt;/p&gt;&#xA;&lt;p&gt;I use the 32-bit version, personally, despite being what you could call an &amp;quot;advanced&amp;quot; user. I recommend doing likewise unless you are using plugins available only in 64-bit. (This is not particularly common.)&lt;/p&gt;&#xA;&lt;p&gt;Generally speaking, for small footprint programs there's not all that much of an advantage to compiling to 64-bit. On 64-bit Windows, the &lt;code&gt;c:\program files (x86)&lt;/code&gt; folder contains installed 32-bit executable apps and you'll notice there are a lot of them. Unless you need to address very large amounts of memory or have some other, less common need, there's not much to be gained with a 64-bit runtime. There may even be downsides to it such as consumption of more memory versus the 32-bit version (as mentioned by Vim's download page).&lt;/p&gt;&#xA;&lt;p&gt;Now if you have some unavoidable compatibility issue (or you weren't convinced by any of the above) then head over to &lt;a href=&quot;https://vi.stackexchange.com/questions/6097/how-can-i-install-64-bit-vim-on-windows&quot;&gt;How can I install 64-bit Vim on Windows?&lt;/a&gt; for guidance. Alternatively, if you don't mind using a possibly less stable version of Vim you can find 64-bit Vim among the &lt;a href=&quot;https://github.com/vim/vim-win32-installer/releases&quot; rel=&quot;nofollow noreferrer&quot;&gt;official nightly builds&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2021-06-14T04:30:40.460" LastActivityDate="2021-06-14T04:30:40.460" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24592" PostTypeId="1" CreationDate="2020-04-15T03:52:10.553" Score="1" ViewCount="867" Body="&lt;p&gt;If I've already opened a tab with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:tabe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to load the file in that tab? For example, to do something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:o ~/.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, instead of doing &lt;code&gt;:tabe ~/.vimrc&lt;/code&gt;, can I do that in two commands (one to open the new tab and another to open that file)?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="-1" LastEditDate="2021-08-01T16:15:56.507" LastActivityDate="2021-08-01T16:15:56.507" Title="Open a file from a new blank tab in vim" Tags="|vimrc|vimscript|tabbed-user-interface|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24593" PostTypeId="1" AcceptedAnswerId="24598" CreationDate="2020-04-15T07:00:59.180" Score="6" ViewCount="347" Body="&lt;h2&gt;The problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In shell scripting, conditionals and loops don't use curly braces to indicate blocks, but rather special keywords: &lt;code&gt;if [ ... ]; then&lt;/code&gt; statements close with &lt;code&gt;fi&lt;/code&gt;, &lt;code&gt;while [ ... ]; do&lt;/code&gt; statements close with &lt;code&gt;done&lt;/code&gt;, and &lt;code&gt;case&lt;/code&gt; statements close with &lt;code&gt;esac&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without mappings, the normal protocol to complete, e.g., a then...fi pair would be the following sequence of keys, starting in insert mode: &lt;code&gt;then&amp;lt;CR&amp;gt;&amp;lt;BS&amp;gt;fi&amp;lt;Esc&amp;gt;O&lt;/code&gt;. I'm not very fond of this workflow since it takes so many keystrokes and exits insert mode, so I've come up with my own solution. I'm not sure if this is the best solution though, so I'd appreciate recommendations if you have any.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;My current solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I use the following mappings to facilitate easier completion of pairs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; if statements:&#xA;inoremap fi&amp;lt;CR&amp;gt; &amp;lt;BS&amp;gt;fi&amp;lt;Esc&amp;gt;O&#xA;&quot; case statements:&#xA;inoremap c&amp;lt;CR&amp;gt; c&amp;lt;Esc&amp;gt;O&#xA;&quot; for, while, until, and select loops:&#xA;inoremap one&amp;lt;CR&amp;gt; one&amp;lt;Esc&amp;gt;O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This leads to the following workflow when creating then...fi, do...done, and case...esac pairs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;then...fi pairs:   then&amp;lt;CR&amp;gt;fi&amp;lt;CR&amp;gt;&#xA;do...done pairs:   do&amp;lt;CR&amp;gt;done&amp;lt;CR&amp;gt;&#xA;case...esac pairs: case[...]&amp;lt;CR&amp;gt;esac&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Things I want the mapping to do&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I want a mapping to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Allow me to complete pairs without manually exiting insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;End with my cursor between the two lines and indented one tab, like so (cursor indicated with [ ]):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if [ ... ]&#xA;then&#xA;        []&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;Be a similar calling workflow for all 3 pair types.&lt;/li&gt;&#xA;&lt;li&gt;Require the least amount of keystrokes while avoiding things I don't want, as described below.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Things I want the mapping to NOT do&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I want to avoid the following problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Trigger in situations when I wouldn't want it to. For example, I wouldn't want the mapping &lt;code&gt;inoremap do&amp;lt;CR&amp;gt; do&amp;lt;CR&amp;gt;done&amp;lt;Esc&amp;gt;O&lt;/code&gt; since that would also trigger when I'm writing do...while loops in C++. If this can be worked around to only trigger in files with certain file extensions, that would be an exception.&lt;/li&gt;&#xA;&lt;li&gt;Be distracting while writing code normally. For example, I mapped &lt;code&gt;one&amp;lt;CR&amp;gt;&lt;/code&gt; instead of &lt;code&gt;done&amp;lt;CR&amp;gt;&lt;/code&gt; since I want to be able to see the letters as I type them unless I'm probably trying to use the mapping (i.e. &lt;code&gt;done&amp;lt;CR&amp;gt;&lt;/code&gt; would hide my characters while typing &lt;code&gt;do&lt;/code&gt; until I typed a character other than &lt;code&gt;n&lt;/code&gt;, which I don't like).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Do you have recommendations for changes? Or do you think my mappings best fit what I want and don't want? &lt;/p&gt;&#xA;" OwnerUserId="27539" LastActivityDate="2020-04-15T13:23:58.697" Title="Shell scripting: A more elegant way to complete then...fi, do...done, case...esac pairs?" Tags="|vimrc|autocompletion|bash|shell|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24594" PostTypeId="1" CreationDate="2020-04-15T07:57:15.080" Score="0" ViewCount="302" Body="&lt;p&gt;In Vim I use the forward slash on my numpad a lot for searching. Thinking of getting a TKL keyboard I was wondering how that works without a numpad. I tried the forward slash on the regular keys, but that doesn't have the same effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to make this work? &#xA;I'm thinking rebinding the key in Vim would do the trick, but there must be a built-in solution I don't know.&lt;/p&gt;&#xA;" OwnerUserId="8831" LastActivityDate="2020-04-15T07:57:15.080" Title="Numpad forward slash to search without numpad?" Tags="|search|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24595" PostTypeId="1" CreationDate="2020-04-15T08:22:13.737" Score="1" ViewCount="22" Body="&lt;p&gt;I'm currently using &lt;a href=&quot;https://github.com/dense-analysis/ale&quot; rel=&quot;nofollow noreferrer&quot;&gt;ALE&lt;/a&gt; and pretty much enjoying it. By default, it puts its loc-list at the bottom of the screen. This is great on a vertical monitor, but when I'm using my laptop, I want it to be at the right of my screen. Is it possible to get the screen dimensions in vimrc, so that I can move the list to the right when I'm not using a vertical monitor?&lt;/p&gt;&#xA;" OwnerUserId="14410" LastActivityDate="2020-04-15T08:22:13.737" Title="Aspect-ratio-dependent configuration" Tags="|vimrc|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24597" PostTypeId="1" AcceptedAnswerId="24609" CreationDate="2020-04-15T08:31:41.183" Score="1" ViewCount="532" Body="&lt;p&gt;I am using a macbook with touchbar. As many others I would like to map a different key to the esc key, since the touchbar esc is a bit inconvenient. My problem is that I have some weird behaviour of the §-key which I would like to use as alternative. I had to remove the &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map § &amp;lt;esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;since the §-key doesn't work in the first place. I assume this has something to do with how I configured vim. I use vim inside zsh and have almost the same vimrc as this one &lt;a href=&quot;https://github.com/amix/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/amix/vimrc&lt;/a&gt;. I also have installed tabnine-vim which might interferes in some way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In normal mode the §-key does nothing. Expect my mac beeps shortly. In Insert mode the §-key goes on character left but then remains there if I press it again. The Insert mode is not left. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key works normal in the zsh. Also the key works if I write for example &lt;code&gt;:§&lt;/code&gt;. By accident I also noted that whenever I type some ° characters, those get replaced by &lt;code&gt;&amp;lt;80&amp;gt;kl&lt;/code&gt; when I hit the §-key on them in Insert mode. As far as I know this means left, and so far this replacement only appeared on ° characters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I debug this? I have searched the vimrc if a remapping of the §-key already exists but could not find anything so far. I am rather new to vim. I still can't see how one best debuggs problems like this. &lt;/p&gt;&#xA;" OwnerUserId="28972" LastEditorUserId="18609" LastEditDate="2020-04-15T17:51:32.627" LastActivityDate="2020-04-15T17:51:32.627" Title="Problem remapping § to esc in vim on a macbook with touch-bar" Tags="|key-bindings|escape|map-operator|plugin-auto-pairs|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="24598" PostTypeId="2" ParentId="24593" CreationDate="2020-04-15T08:45:45.710" Score="3" Body="&lt;p&gt;Here's what I would go for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType sh iab &amp;lt;buffer&amp;gt; then then&amp;lt;CR&amp;gt;fi&amp;lt;C-o&amp;gt;O&amp;lt;SPACE&amp;gt;&amp;lt;BS&amp;gt;&amp;lt;C-o&amp;gt;z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's for the then...fi, but you can apply it for the 2 other solutions as well&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Explanation&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;autocmd&lt;/code&gt; allows you to &lt;strong&gt;specify a filetype&lt;/strong&gt; (among other things), here &lt;code&gt;sh&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;I use &lt;strong&gt;abbreviations&lt;/strong&gt; (&lt;code&gt;iab&lt;/code&gt;) instead of mapping, as this doesn't hide the characters as you type them. The downside though is that the mapping won't be triggered by &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;, but by &lt;code&gt;&amp;lt;SPACE&amp;gt;&lt;/code&gt;, or &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; limits this abbreviation to the current buffer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And about the mapping:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;then&lt;/code&gt; is what you need to type in order to trigger the abbreviation&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;then&lt;/code&gt; (again) is there because we actually want to write &quot;then&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; We enter a newline&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;fi&lt;/code&gt; The characters &quot;fi&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-o&amp;gt;O&lt;/code&gt; We create a newline above&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;SPACE&amp;gt;&amp;lt;BS&amp;gt;&lt;/code&gt; This is just here to avoid the indent to collapse when we enter normal mode&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-o&amp;gt;z&lt;/code&gt; is here to cancel the &lt;code&gt;&amp;lt;SPACE&amp;gt;&lt;/code&gt; that's about to be entered (iab always enters the triggering character at the end of the abbreviation)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to be fancy, you can even write a little function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CloseSh(start, end, before)&#xA;    &quot; Entering the actual start&#xA;    exe&quot;norm!i&quot;.a:start&#xA;&#xA;    &quot; Making sure that the 'before' is on the same line,&#xA;    &quot; or one line before cursor&#xA;    if search('.*'.a:before.'.*\n\?.*\%#', 'n') == '0'&#xA;        &quot; If it's not the case, we behave as if nothing happened&#xA;        exe&quot;norm!a\&amp;lt;SPACE&amp;gt;&quot;&#xA;        call setpos('.', [0, line('.'), 1000, 0, 1000])&#xA;        return&#xA;    endif&#xA;&#xA;    &quot; If match found, we can continue:&#xA;    &quot; adding the end tag bellow&#xA;    exe&quot;norm!o&quot;.a:end&#xA;    &quot; new line above&quot;&#xA;    exe&quot;norm!O\&amp;lt;SPACE&amp;gt;\&amp;lt;BS&amp;gt;&quot;&#xA;    &quot; force cursor at the end of line&#xA;    call setpos('.', [0, line('.'), 1000, 0, 1000])&#xA;endfunction&#xA;&#xA;autocmd FileType sh inoreab &amp;lt;buffer&amp;gt; then :call CloseSh('then', 'fi', '\&amp;lt;if\&amp;gt;')&amp;lt;CR&amp;gt;&amp;lt;C-o&amp;gt;z&#xA;autocmd FileType sh inoreab &amp;lt;buffer&amp;gt; in :call CloseSh('in', 'esac', '\&amp;lt;case\&amp;gt;')&amp;lt;CR&amp;gt;&amp;lt;C-o&amp;gt;z&#xA;autocmd FileType sh inoreab &amp;lt;buffer&amp;gt; do :call CloseSh('do', 'done', '\&amp;lt;while\&amp;gt;')&amp;lt;CR&amp;gt;&amp;lt;C-o&amp;gt;z&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function will make sure that the tag you're typing is preceded by the right thing (e.g. &quot;then&quot; is preceded by &quot;if&quot;) so that it doesn't trigger when writing comments for example&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also, as &lt;a href=&quot;https://vi.stackexchange.com/users/18609/filbranden&quot;&gt;@filbranden&lt;/a&gt; said:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;❝ instead of creating &lt;code&gt;autocmd FileType sh&lt;/code&gt; you could simply store these iabs in a file &lt;em&gt;after/ftplugin/sh.vim&lt;/em&gt; in your &lt;em&gt;~/.vim/&lt;/em&gt; ❞&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="27331" LastEditDate="2020-04-15T13:23:58.697" LastActivityDate="2020-04-15T13:23:58.697" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24599" PostTypeId="1" CreationDate="2020-04-15T04:03:12.087" Score="0" ViewCount="557" Body="&lt;p&gt;I have the following search and replace expression where I am trying to format a document in a single step using multiple commands separated by &lt;strong&gt;&lt;code&gt;|&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\s\{6}...\d\d\s/  /g | %s/\(.*Inlet.*\|.*AIR.*\)/\0 false | %s/\(===)/\0 #  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know the problem is that the interpreter does not understand that after the word &quot;false&quot; it needs to start with the next command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried using parenthesis and different delimiters, but it does not work.&lt;/p&gt;&#xA;" OwnerDisplayName="Chris" LastActivityDate="2020-05-15T13:06:20.687" Title="gvim editor -- E488 Trailing characters after search and replace questions" Tags="|regular-expression|gvim|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24600" PostTypeId="1" CreationDate="2020-04-15T09:45:03.943" Score="1" ViewCount="99" Body="&lt;p&gt;I have searched through a &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/autocmd.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;list of all the autocmd's&lt;/a&gt; and can't find one which is fired when a built in VIM command is run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does one run some custom code after a person calls an existing vim command, e.g. &lt;code&gt;:noh&lt;/code&gt;? (something like the Emacs advice function).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For those who will ask why not create a new command to call both... within a quickfix window I auto highlight some terms using &lt;code&gt;match&lt;/code&gt;, and wish &lt;code&gt;:noh&lt;/code&gt; to intuitively &lt;code&gt;clearmatches()&lt;/code&gt; too. Hence I wish to run &lt;code&gt;clearmatches()&lt;/code&gt; after &lt;code&gt;:noh&lt;/code&gt; is run within a filetype of &lt;code&gt;ftplugin/qf.vim&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-04-15T09:45:03.943" Title="Run custom code after a vim command" Tags="|autocmd|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24601" PostTypeId="2" ParentId="24593" CreationDate="2020-04-15T12:21:57.433" Score="3" Body="&lt;p&gt;Personally, I’ve used &lt;a href=&quot;https://github.com/tpope/vim-endwise&quot; rel=&quot;nofollow noreferrer&quot;&gt;endwise&lt;/a&gt; for a few years and been satisfied. It’s easy enough to add other languages if necessary, but it supports shell (among many others) out of the box. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will automatically insert « ending » statements when you hit enter, so &lt;code&gt;if ... &amp;lt;CR&amp;gt;&lt;/code&gt; and the &lt;code&gt;fi&lt;/code&gt; is added. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps my favorite part is endwise is smart enough not to add the end if one is already there. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-15T12:21:57.433" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24602" PostTypeId="1" AcceptedAnswerId="24607" CreationDate="2020-04-15T12:28:56.133" Score="1" ViewCount="379" Body="&lt;p&gt;Suppose I had tabstop set to 4 in &lt;code&gt;~/.vimrc&lt;/code&gt;. When I edit a file, I set the tabstop to 5 with &lt;code&gt;:set tabstop=5&lt;/code&gt;. After that, I close vim and restarted the terminal. When I open the file again, the tabstop for that file is still set to 5. How to make vim forget all settings (not just tabstop) I made (which I forgot) in that specific file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, when I open a previously opened file, it restores everything (settings, cursor position, etc) the way they were when I last left it. I'm not sure what causes this though. Here's my &lt;a href=&quot;https://github.com/imambungo/dotfiles/blob/master/.vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;.vimrc&lt;/a&gt;, I guess it has something to do with &lt;a href=&quot;https://github.com/imambungo/dotfiles/blob/d073e9a0abad39e4cdfc5d4b5e2b3d3069758fb9/.vimrc#L132&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;BufWinLeave&lt;/code&gt; and &lt;code&gt;BufWinEnter&lt;/code&gt; there&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;reset all settings with &lt;code&gt;:set all&amp;amp;&lt;/code&gt; and reload vimrc with &lt;code&gt;:source $MYVIMRC&lt;/code&gt;. Somehow the syntax highlighting is off afterward.&lt;/li&gt;&#xA;&lt;li&gt;Create a duplicate file, delete the original one, rename the duplicate file to the original one. No effect.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="20429" LastEditorUserId="20429" LastEditDate="2020-04-15T12:45:03.083" LastActivityDate="2021-10-18T11:06:46.927" Title="How to forget specific file settings and treat it like a new file" Tags="|vimrc|default-settings|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="24603" PostTypeId="2" ParentId="24592" CreationDate="2020-04-15T12:31:31.217" Score="2" Body="&lt;p&gt;You’re looking for &lt;code&gt;:tabnew&lt;/code&gt; followed by &lt;code&gt;:edit file&lt;/code&gt; (but why? &lt;code&gt;:tabedit&lt;/code&gt; does the same and is shorter). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe &lt;code&gt;&amp;lt;C-w&amp;gt;T&lt;/code&gt; will also break the current window into a new tab. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-15T12:31:31.217" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24604" PostTypeId="2" ParentId="24599" CreationDate="2020-04-15T12:34:20.943" Score="1" Body="&lt;p&gt;The syntax of &lt;code&gt;:substitute&lt;/code&gt; is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]substitute/pattern/replacement/[flags]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Although &lt;code&gt;/&lt;/code&gt; can actually be any character, which is helpful for when the pattern contains slashes.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that the delimiter after &lt;code&gt;replacement&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; optional. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-15T12:34:20.943" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24605" PostTypeId="2" ParentId="17073" CreationDate="2020-04-15T13:07:22.770" Score="2" Body="&lt;p&gt;I think this is a bug.&#xA;I my case, in vim 8.2, I can't highlight CursorLineNR when 'relativenumber' is set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the doc:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;CursorLineNr  Like LineNr when 'cursorline' is set and 'cursorlineopt' is&#xA;          set to &quot;number&quot; or &quot;both&quot;, &lt;strong&gt;or 'relativenumber' is set&lt;/strong&gt;, for&#xA;          the cursor line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, here's my workaround:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;set 'cursorline'&lt;/li&gt;&#xA;&lt;li&gt;highlight cursorline with the same values as for 'normal'&lt;/li&gt;&#xA;&lt;li&gt;then highlight 'cursorlinenr'&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I hope this helps :)&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2020-04-29T00:27:32.030" LastActivityDate="2020-04-29T00:27:32.030" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24606" PostTypeId="2" ParentId="24597" CreationDate="2020-04-15T13:19:58.373" Score="1" Body="&lt;p&gt;So thanks to @filbranden I was able to find the source of the error. This plugin causes it: &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/jiangmiao/auto-pairs&lt;/a&gt;&#xA;I have yet no clue how the error is produced. The plugin should not care about § characters. Also the § character does not appear a single time in the repository. I actually like the plugin. If I find an alternative my problem would be solved. Despite that I would like to find the error to get a better understanding of vim and its plugins. But thats probably something for another question :)&lt;/p&gt;&#xA;" OwnerUserId="28972" LastActivityDate="2020-04-15T13:19:58.373" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24607" PostTypeId="2" ParentId="24602" CreationDate="2020-04-15T13:22:51.407" Score="3" Body="&lt;p&gt;The lines that restore your settings are&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;autocmd BufWinLeave &lt;em&gt;.&lt;/em&gt; mkview&lt;br&gt;&#xA;autocmd BufWinEnter &lt;em&gt;.&lt;/em&gt; silent loadview&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;They respectively save and load your settings for any file you open.&lt;/p&gt;&#xA;&lt;p&gt;From the doc (&lt;code&gt;:h mkview&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;:mkvie[w][!] [file]&lt;br&gt;&#xA;Write a Vim script that restores the contents of the&#xA;current window.&lt;br&gt;&#xA;When [!] is included an existing file is overwritten.&#xA;When [file] is omitted or is a number from 1 to 9, a&#xA;name is generated and 'viewdir' prepended.  When the&#xA;last path part of 'viewdir' does not exist, this&#xA;directory is created.  E.g., when 'viewdir' is&#xA;&amp;quot;$VIM/vimfiles/view&amp;quot; then &amp;quot;view&amp;quot; is created in&#xA;&amp;quot;$VIM/vimfiles&amp;quot;.&lt;br&gt;&#xA;An existing file is always overwritten then.  Use&#xA;|:loadview| to load this view again.&#xA;When [file] is the name of a file ('viewdir' is not&#xA;used), a command to edit the file is added to the&#xA;generated file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;And (&lt;code&gt;:h loadview&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;:lo[adview] [nr]&lt;br&gt;&#xA;Load the view for the current file.  When [nr] is&#xA;omitted, the view stored with &amp;quot;:mkview&amp;quot; is loaded.&#xA;When [nr] is specified, the view stored with &amp;quot;:mkview&#xA;[nr]&amp;quot; is loaded.&lt;br&gt;&#xA;The combination of &amp;quot;:mkview&amp;quot; and &amp;quot;:loadview&amp;quot; can be used to store up to ten different views of a file.  These are remembered in the directory specifiedwith the 'viewdir' option.  The views are stored using the file name.  If a file is renamed or accessed through a (symbolic) link the view will not be&#xA;found.&lt;br&gt;&#xA;You might want to clean up your 'viewdir' directory now and then.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;To forget those settings, you'll have to delete the view file associated to your file. All view files should be located in &lt;code&gt;~/.vim/view&lt;/code&gt; by default.&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2021-10-18T11:06:46.927" LastActivityDate="2021-10-18T11:06:46.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24608" PostTypeId="2" ParentId="11454" CreationDate="2020-04-15T14:19:48.533" Score="1" Body="&lt;p&gt;Go to your Konsole's profile at &lt;code&gt;~/.local/share/konsole/&lt;/code&gt; and under the &lt;code&gt;[General]&lt;/code&gt; section add the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TerminalMargin=4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This example is taken from &lt;a href=&quot;https://www.reddit.com/r/kde/comments/9lqtzv/does_anyone_know_how_to_add_padding_to_konsole/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Reddit&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="28979" LastActivityDate="2020-04-15T14:19:48.533" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24609" PostTypeId="2" ParentId="24597" CreationDate="2020-04-15T15:44:02.767" Score="3" Body="&lt;p&gt;TL;DR: To prevent conflicts with mapping the § key and the auto-pairs plug-in, add the following to your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:AutoPairsMoveCharacter = '()[]{}&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The root of the problem is that Vim sees the &lt;kbd&gt;§&lt;/kbd&gt; key the same as it sees the combination &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;'&lt;/kbd&gt;, or &lt;kbd&gt;Meta&lt;/kbd&gt;+&lt;kbd&gt;'&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Section_sign&quot; rel=&quot;nofollow noreferrer&quot;&gt;§&lt;/a&gt; symbol has character code U+00A7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To represent keystrokes involving the Alt or Meta key, Vim OR's the character code with 0x80 hexadecimal. This is historically how this has been done back in the days of ASCII, of 8-bit character encodings, before Unicode and UTF-8. But Vim still uses that representation internally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, U+0027 is the character code for the &lt;code&gt;'&lt;/code&gt; symbol. So in Vim, &lt;code&gt;&amp;lt;M-'&amp;gt;&lt;/code&gt; (corresponding to the aforementioned &lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;'&lt;/kbd&gt;) will clash with &lt;code&gt;§&lt;/code&gt;, particularly in a mapping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be easily demonstrated, by creating a mapping for &lt;code&gt;&amp;lt;M-'&amp;gt;&lt;/code&gt;, such as &lt;code&gt;inoremap &amp;lt;M-'&amp;gt; something&lt;/code&gt; and then triggering it by pressing the &lt;code&gt;§&lt;/code&gt; key, which should have Vim expand it to &lt;code&gt;something&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out the auto-pairs plug-in creates a mapping for &lt;code&gt;&amp;lt;M-'&amp;gt;&lt;/code&gt;. More exactly, it &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs/blob/v2.0.0/plugin/auto-pairs.vim#L510,L513&quot; rel=&quot;nofollow noreferrer&quot;&gt;creates mappings&lt;/a&gt; for all keys in &lt;code&gt;g:AutoPairsMoveCharacter&lt;/code&gt; with the Meta modifier. This variable &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs/blob/v2.0.0/plugin/auto-pairs.vim#L53&quot; rel=&quot;nofollow noreferrer&quot;&gt;defaults&lt;/a&gt; to include the &lt;code&gt;()[]{}&quot;'&lt;/code&gt; characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(For the point of these mappings, see &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs/commit/6afc850e2429e6832a1b093e32a31e0b5eff477d&quot; rel=&quot;nofollow noreferrer&quot;&gt;the commit that introduced the quick move feature&lt;/a&gt;, although I find it doesn't work as well with the quotes and I don't much see the point of the open braces either. I'd say using the surround.vim plug-in in normal mode is a much better way of accomplishing that goal.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, to prevent auto-pairs from creating the &lt;code&gt;&amp;lt;M-'&amp;gt;&lt;/code&gt; mapping that clashes with the &lt;code&gt;§&lt;/code&gt;, you can simply set the &lt;code&gt;g:AutoPairsMoveCharacter&lt;/code&gt; variable not to include the &lt;code&gt;'&lt;/code&gt; character. (But note that means it won't then work for the aforementioned auto-pairs feature.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to preserve all others:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:AutoPairsMoveCharacter = '()[]{}&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to only keep the closing braces, which seem to be the most useful ones for this feature:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:AutoPairsMoveCharacter = ')]}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to disable the feature altogether:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:AutoPairsMoveCharacter = ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After removing the &lt;code&gt;'&lt;/code&gt; from this variable, it should be safe to create a mapping for &lt;code&gt;§&lt;/code&gt; and at the same time keep the auto-pairs plug-in enabled. The plug-in will no longer clobber your mapping.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-15T15:44:02.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24610" PostTypeId="2" ParentId="12867" CreationDate="2020-04-15T19:51:09.017" Score="4" Body="&lt;p&gt;Just adding '#' at the end plus a counter 'c'&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let c=0 | g/^#\d\+.*/ let c+=1 | s//\='#' . c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The global part &lt;code&gt;g/^#\d\+.*/ let c+=1&lt;/code&gt; allow us to increment&#xA;the counter only in the lines that have a pattern&lt;/p&gt;&#xA;" OwnerUserId="7339" LastActivityDate="2020-04-15T19:51:09.017" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24611" PostTypeId="1" AcceptedAnswerId="24741" CreationDate="2020-04-15T19:54:31.593" Score="1" ViewCount="137" Body="&lt;p&gt;I started using c-support recently. When I open a c file, some predefined lines are added automatically to it along with &lt;code&gt;#define &amp;lt;stdlib.h&amp;gt;&lt;/code&gt; line. I want to modify this default template. I searched for help regarding c-support inside vim (&lt;code&gt;:help csupport&lt;/code&gt;) but I couldn't understand how to change the default template file. I doubt that help talks of templates which can be added by shortcuts but not the one I want to modify. Any help on this?&lt;/p&gt;&#xA;" OwnerUserId="22672" LastActivityDate="2020-05-21T21:01:15.207" Title="How can I change the default template files for c-support?" Tags="|plugin-c.vim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24612" PostTypeId="1" AcceptedAnswerId="24613" CreationDate="2020-04-16T03:19:30.670" Score="1" ViewCount="417" Body="&lt;p&gt;I recorded this macro to register &lt;code&gt;a&lt;/code&gt; in Neovim by first pressing &lt;code&gt;qa&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Macro&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- Registers ---&#xA;&quot;a   f1F1i-^[la0^[j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I pressed &lt;code&gt;q&lt;/code&gt; and my cursor was left in normal mode at the position marked by &lt;code&gt;|&lt;/code&gt; (so that &lt;code&gt;m&lt;/code&gt; is highlighted) in the below JavaScript snippet (on line &lt;code&gt;4&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;JavaScript snippet&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  timeout = setTimeout(function() {&#xA;    mw_panel.style.left=&quot;-10em&quot;;&#xA;    mw_head.style.left=&quot;-10em&quot;;&#xA;    content.style.left=&quot;1e|m&quot;;&#xA;    left_navigation.style.left=&quot;1em&quot;;&#xA;    footer.style.left=&quot;1em&quot;;&#xA;  }, 350);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I tried to apply the macro with &lt;code&gt;@a&lt;/code&gt; but nothing happened. I tried the same in Vim and nothing happened. Though the macro will move the cursor to the &lt;code&gt;1&lt;/code&gt; if I move it away before using it. Am I not understanding something about how Vim macros work?&lt;/p&gt;&#xA;" OwnerUserId="28990" LastActivityDate="2020-04-16T05:24:09.783" Title="Why doesn't this Vim macro work?" Tags="|neovim|macro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24613" PostTypeId="2" ParentId="24612" CreationDate="2020-04-16T03:46:28.137" Score="2" Body="&lt;p&gt;Macros abort when they fail at some point. In your example, &lt;code&gt;f1&lt;/code&gt; fails since there is no &lt;code&gt;1&lt;/code&gt; after the cursor. To solve it, you can set &lt;code&gt;&quot;a&lt;/code&gt; to, say, &lt;code&gt;0f1i-^[la0^[j&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="25618" LastEditorUserId="25618" LastEditDate="2020-04-16T04:01:29.670" LastActivityDate="2020-04-16T04:01:29.670" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24614" PostTypeId="2" ParentId="24612" CreationDate="2020-04-16T05:24:09.783" Score="0" Body="&lt;p&gt;I would use sdp's suggestion &lt;code&gt;0f1i-^[la0^[j&lt;/code&gt; in a case like this, but my original macro could &quot;directly&quot; be made to work by absorbing the errors by the method described in &lt;a href=&quot;https://superuser.com/a/337825&quot;&gt;this answer&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:try|exe &quot;norm! f1&quot;|endtry|try|exe &quot;norm! F1&quot;|endtry^Mi-^[la0^[j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="28990" LastActivityDate="2020-04-16T05:24:09.783" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24615" PostTypeId="2" ParentId="13433" CreationDate="2020-04-16T06:32:12.650" Score="0" Body="&lt;p&gt;&lt;strong&gt;Fastest way to add diff hunks to quickfix&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quickfix is very handy feature. It is even has it's own format definition, but it is not easy expand. I found more easy to reformat diff to format of compilation errors: &quot;$file:$line:$message&quot;. Reformatting works as standalone filter function. It combination with vim option -q it very easy to use and resuse, no need to additional installations and configutaions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my the shortest solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diff_to_quickfix()&#xA;{&#xA;     perl -ne '/^\+\+\+ (.+)/ &amp;amp;&amp;amp; { $f=&quot;$1&quot;};/@@.*\+(\d+)/ &amp;amp;&amp;amp; print &quot;$f:$1:$_\n&quot;'&#xA;}&#xA;&#xA;vim -q &amp;lt;(git show -U0 --no-prefix | diff_to_quickfix)&#xA;&#xA;&#xA;vim -q &amp;lt;(git diff -U0 --no-prefix | diff_to_quickfix)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6229" LastEditorUserId="6229" LastEditDate="2020-04-17T16:16:27.027" LastActivityDate="2020-04-17T16:16:27.027" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24616" PostTypeId="2" ParentId="22937" CreationDate="2020-04-16T07:14:23.340" Score="0" Body="&lt;p&gt;The way I like to do this is by using &lt;a href=&quot;https://github.com/tmux/tmux/wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;tmux&lt;/a&gt; to send the compilation command to another terminal. I like this method because it behaves as if you had typed the command in that terminal yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add this to your &lt;code&gt;.vimrc&lt;/code&gt;  (note this code uses &lt;code&gt;latexmk&lt;/code&gt; instead of &lt;code&gt;pdflatex&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;function! TmuxSend()&#xA;    let tex_file = expand('%:p')&#xA;    let tex_cmd = 'latexmk -pdf -interaction=nonstopmode -cd ' . tex_file&#xA;    let tmux_cmd = 'tmux send-keys -t vim_output.0 &quot;' . tex_cmd . '&quot; ENTER'&#xA;    let output = system(tmux_cmd)   &#xA;endfunction&#xA;&#xA;autocmd FileType tex :nnoremap &amp;lt;silent&amp;gt; &amp;lt;buffer&amp;gt; &amp;lt;F5&amp;gt; :call TmuxSend()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, open another terminal and create a tmux session named &quot;vim_output&quot;: &lt;code&gt;tmux new-session -s vim_output&lt;/code&gt;. Now, when you press &lt;kbd&gt;F5&lt;/kbd&gt; in Vim, the &lt;code&gt;latexmk&lt;/code&gt; command will be run in the terminal you just created.&lt;/p&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2020-04-16T07:14:23.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24617" PostTypeId="2" ParentId="16622" CreationDate="2020-04-16T08:43:23.320" Score="20" Body="&lt;p&gt;I'm on Windows 10, update 1909, and I've resolved this by overriding high DPI settings for gVim to System(Enhanced). Setting GUI font size did not help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right click on gVim icon -&gt; Properties -&gt; Compatibility -&gt; Change high DPI settings -&gt; check box &quot;Override high DPI scaling behavior&quot; in the bottom of the dialog window and set &quot;Scaling performed by:&quot; to &quot;System (Enhanced)&quot;&lt;/p&gt;&#xA;" OwnerUserId="5545" LastEditorUserId="5545" LastEditDate="2020-04-16T09:12:31.723" LastActivityDate="2020-04-16T09:12:31.723" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24619" PostTypeId="2" ParentId="24561" CreationDate="2020-04-16T10:59:58.663" Score="2" Body="&lt;p&gt;You can make use of vim &lt;code&gt;terminal&lt;/code&gt; in vim 8.0 and later to handle asynchronous jobs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, to launch &lt;code&gt;make&lt;/code&gt; in a vertical split, you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vertical terminal make&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a small function (with a command) to do exactly this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(&amp;lt;q-args&amp;gt;)&#xA;function! s:RunShellCommand(cmdline) abort&#xA;    exe 'vert terminal '. a:cmdline&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can do &lt;code&gt;:Shell any_command&lt;/code&gt; to launch a command in a vertical split (i.e &lt;code&gt;:Shell find /&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;make&lt;/code&gt; specifically, I use it in conjunction with those mappings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;csm :Shell make&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;csr :Shell make re&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;cst :Shell make ex&amp;lt;cr&amp;gt;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ex&lt;/code&gt; is a rule in my Makefile that launches my tests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One caveat is that &lt;code&gt;make&lt;/code&gt; rules auto-completion does not work.&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2020-04-17T11:04:12.540" LastActivityDate="2020-04-17T11:04:12.540" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24620" PostTypeId="2" ParentId="13433" CreationDate="2020-04-16T12:34:02.720" Score="5" Body="&lt;h3&gt;Plugin Fugitive v3.2 (Jan 2020)&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-fugitive&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-fugitive&lt;/a&gt; has added new commands since the OP raised this question which can do exactly what the OP has asked.&lt;/p&gt;&#xA;&lt;p&gt;Now you can call&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Git difftool&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or the abbreviated version&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:G difft[tab complete]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This loads all changesets into the quickfix list. If files have several changes, they occur several times in the quickfix list. I like this. However, if you prefer to have only each file once, run&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; :G difftool --name-only&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1292" LastEditorUserId="1292" LastEditDate="2022-02-12T08:12:42.310" LastActivityDate="2022-02-12T08:12:42.310" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24621" PostTypeId="2" ParentId="13433" CreationDate="2020-04-16T13:12:23.590" Score="5" Body="&lt;p&gt;Here are two related approaches. Both use &lt;code&gt;git-*&lt;/code&gt; scripts; if you put them on your &lt;code&gt;PATH&lt;/code&gt;, you can invoke them as if they were subcommands of git. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Use the contrib script &lt;a href=&quot;https://github.com/git/git/tree/master/contrib/git-jump&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;git-jump&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;git-jump&lt;/code&gt; script provides a handy way to load diff hunks, grep results, or whitespace errors into an editor that supports quickfix formats. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;git jump diff&lt;/code&gt; forwards its arguments to diff, and since you’re interested in the last commit, you can do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git jump diff @^ @&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Use my &lt;a href=&quot;https://github.com/benknoble/Dotfiles/blob/master/links/bin/git-ed&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;git-ed&lt;/code&gt;&lt;/a&gt; script&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;git-ed&lt;/code&gt; script was written before I knew about &lt;code&gt;git-jump&lt;/code&gt;. I used it a lot then (less now). It’s only purpose is to open in an editor the changed files (either currently, in a single commit, or in a range of commits). So simply invoke&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git ed @&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And use the argument list. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-16T13:12:23.590" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24622" PostTypeId="1" CreationDate="2020-04-16T13:41:40.040" Score="0" ViewCount="36" Body="&lt;p&gt;It's not easy to articulate the question, as I touched something I don't understand. I am using a vim extension of VS-CODE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I pressed something, that turned my next pressed key, into a literal, namely &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is this functionality called? How can I tap it again?&lt;/p&gt;&#xA;" OwnerUserId="10866" LastEditorUserId="18609" LastEditDate="2020-04-16T16:56:36.363" LastActivityDate="2020-04-16T16:56:36.363" Title="Printed &lt;tab&gt; on pressing the tab key" Tags="|tab-characters|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24623" PostTypeId="2" ParentId="24587" CreationDate="2020-04-16T15:29:09.703" Score="3" Body="&lt;p&gt;&lt;em&gt;[Thanks to @DBenKnoble for his insight. It led me right to the solution.]&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using &quot;views&quot; to store &lt;code&gt;vim&lt;/code&gt; sessions snapshots, watch for the value(s) of the &lt;code&gt;vop&lt;/code&gt; option parameter. For more info &lt;code&gt;:h vop&lt;/code&gt;. Its default is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viewoptions=cursor,folds,options,curdir&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use of &lt;code&gt;folds&lt;/code&gt; in the above conflicts with the use of &lt;code&gt;~/.vim/after/ftplugin/*.vim&lt;/code&gt; files. You can take &lt;code&gt;folds&lt;/code&gt;out and go on using the two &lt;code&gt;autocmd&lt;/code&gt; lines below in your &lt;code&gt;~/.vimrc&lt;/code&gt;. Both call on &quot;views&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufWinLeave * mkview&#xA;au VimEnter * silent loadview&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can go back to using &lt;code&gt;~/.vim/after/ftplugin/python.vim&lt;/code&gt; as you did.  You can check that for any python module:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:verbose set filetype? foldmethod? foldmarker?&#xA;    filetype=python&#xA;         Last set from /usr/share/vim/vim82/filetype.vim line 1291&#xA;    foldmethod=marker&#xA;         Last set from ~/.vim/view/~=+.vimrc line 67&#xA;    foldmarker={{{,}}}&#xA;         Last set from ~/.vim/view/~=+.vimrc line 65&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the best thing is to stick to &lt;code&gt;views&lt;/code&gt; and just suppress the &lt;code&gt;folds&lt;/code&gt; option in &lt;code&gt;viewoptions&lt;/code&gt; in your &lt;code&gt;~/.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set viewoptions=cursor,options,curdir &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4547" LastEditorUserId="4547" LastEditDate="2020-04-20T20:19:46.900" LastActivityDate="2020-04-20T20:19:46.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24624" PostTypeId="2" ParentId="10049" CreationDate="2020-04-16T16:20:23.567" Score="2" Body="&lt;p&gt;With the help of &lt;a href=&quot;https://vi.stackexchange.com/a/14474/20429&quot;&gt;this&lt;/a&gt;, &lt;a href=&quot;https://unix.stackexchange.com/a/544418/307359&quot;&gt;this&lt;/a&gt;, and &lt;a href=&quot;https://superuser.com/a/207521/943615&quot;&gt;this&lt;/a&gt;, I come up with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;gt;&amp;gt; 0i&amp;lt;tab&amp;gt;&amp;lt;esc&amp;gt;^&#xA;nnoremap &amp;lt;&amp;lt; :norm 0ldF&amp;lt;tab&amp;gt;&amp;lt;enter&amp;gt;^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For multiline selection (works on &lt;code&gt;VISUAL&lt;/code&gt;, &lt;code&gt;VISUAL BLOCK&lt;/code&gt; and &lt;code&gt;VISUAL LINE&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnoremap &amp;gt; :norm 0i&amp;lt;tab&amp;gt;&amp;lt;enter&amp;gt;gv&#xA;vnoremap &amp;lt; :norm 0ldF&amp;lt;tab&amp;gt;&amp;lt;enter&amp;gt;gv&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put them on your &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="20429" LastActivityDate="2020-04-16T16:20:23.567" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24625" PostTypeId="1" CreationDate="2020-04-16T17:21:43.200" Score="1" ViewCount="19" Body="&lt;p&gt;I'm writting a function to integrates &lt;a href=&quot;https://github.com/preservim/nerdtree&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDTree&lt;/a&gt; with &lt;a href=&quot;https://github.com/mileszs/ack.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ack&lt;/a&gt;.&#xA;The goal is to create a &quot;Find in Directory&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I create this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Fif_NERDTreeGetPath()&#xA;  let nodePath = g:NERDTreeFileNode.GetSelected().path.str()&#xA;  return nodePath&#xA;endfunction&#xA;:command! -nargs=+ Fif :Ack &quot;&amp;lt;args&amp;gt;&quot; Fif_NERDTreeGetPath()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;Fif_NERDTreeGetPath()&lt;/code&gt; returns the correct path for the directory that cursor is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, when I execute &lt;code&gt;Fif word&lt;/code&gt; it return:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:ack -s -H --nopager --nocolor --nogroup --column &quot;word&quot; Fif_NERDTreeGetPath()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's almost right. The problem is the path is not being returned. I'm expecting something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:ack -s -H --nopager --nocolor --nogroup --column &quot;word&quot; /path/to/directory/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my first vim function. I don't know how to solve. Tks!&lt;/p&gt;&#xA;" OwnerUserId="26842" LastActivityDate="2020-04-16T17:21:43.200" Title="Return value to custom function" Tags="|neovim|plugin-nerdtree|" AnswerCount="0" CommentCount="2" ClosedDate="2020-04-17T15:16:54.837" ContentLicense="CC BY-SA 4.0" />
  <row Id="24626" PostTypeId="1" AcceptedAnswerId="24629" CreationDate="2020-04-16T17:36:44.020" Score="1" ViewCount="45" Body="&lt;p&gt;Consider the following function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Exp()&#xA;    call feedkeys(&quot;:new ~/.vimrc\&amp;lt;CR&amp;gt;&quot;)&#xA;    call search('F')&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My expectation from Exp() was that if I call Exp() then&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) I see my vimrc file opened in a new window, and&lt;br&gt;&#xA;2) the first instance of 'F' is searched in the vimrc file with the cursor landing on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, what I see is that only the first expectation meets reality. In fact, the second line &lt;code&gt;call search('F')&lt;/code&gt; seems to be ignored by vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: Please feel free if you have a suggestion to improve my code.&lt;/p&gt;&#xA;" OwnerUserId="2369" LastActivityDate="2020-04-16T19:23:39.563" Title="How to open a new window and edit it in an automated fashion?" Tags="|buffers|vim-windows|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="24627" PostTypeId="2" ParentId="24574" CreationDate="2020-04-16T17:59:21.660" Score="3" Body="&lt;p&gt;The question was about using external command to change the headings to title case. Anyway I would propose a Vim only solution - for me it looks simpler than awk ;-).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;words that should not be changed to title case&#xA;let s:TC_IGN_WORDS = [ 'a', 'is', 'the', 'to', 'at', 'in', 'on', 'with', 'and', 'but', 'or' ]&#xA;&#xA;function! Tc_Word(word)&#xA;    if index(s:TC_IGN_WORDS, a:word) &amp;gt;= 0&#xA;        return a:word&#xA;    else&#xA;        return toupper(a:word[0]) . a:word[1:]&#xA;    endif&#xA;endfunction&#xA;&#xA;command TcHeaders g/^#/s/\&amp;lt;\w\+\&amp;gt;/\u\0/|s/\&amp;lt;\w\+\&amp;gt;/\=Tc_Word(submatch(0))/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The command &lt;code&gt;TcHeaders&lt;/code&gt; runs a substitution on all markdown headings (&lt;code&gt;g/^#/&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The substitution takes every word, feeds it to the function &lt;code&gt;Tc_Word()&lt;/code&gt; and replaces it with what &lt;code&gt;Tc_Word()&lt;/code&gt; returns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The search pattern could be further refined like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\&amp;lt;\l\w*\&amp;gt;&lt;/code&gt;: Only words that begin with a lower case character&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\&amp;lt;\l\w\w+\&amp;gt;&lt;/code&gt;: Begins with a lower case and is at least three chars long.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note: I didn't lowercase the second part of the word, as this would replace something like &lt;code&gt;HTTP&lt;/code&gt; with &lt;code&gt;Http&lt;/code&gt;. I'm not sure this is intended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help s/\\=&lt;/code&gt;, &lt;code&gt;:help submatch&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2020-04-17T09:33:17.070" LastActivityDate="2020-04-17T09:33:17.070" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24628" PostTypeId="1" AcceptedAnswerId="24696" CreationDate="2020-04-16T18:18:44.173" Score="2" ViewCount="176" Body="&lt;p&gt;So far, I managed to implement a function that adds a delay after &quot;putting&quot; each character contained in a register to the screen:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! AnimateInsertion() abort&#xA;    &quot; split contents of last modified reg in individual chars&#xA;    let s:line = split(getreg(v:register), '\zs')&#xA;    &quot; iterate through each character&#xA;    for s:char in s:line&#xA;        sleep 100m&#xA;        exe 'normal!a'.s:char&#xA;        redraw&#xA;    endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/huWUJ.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/huWUJ.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this approach treats the contents of the register as a literal string. In other words, this implementation prints an 'i' instead of actually treating it as a command that makes Vim go into insert mode. How could I execute the contents of the register as commands (just like &lt;code&gt;@&amp;lt;reg&amp;gt;&lt;/code&gt; does) and add a delay after each command is executed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: I encountered &lt;a href=&quot;https://stackoverflow.com/q/42740081/1706778&quot;&gt;this&lt;/a&gt; 3-year-old question yesterday. It asks pretty much the same as this one. Unfortunately nobody has been able to come up with a solution yet.&lt;/p&gt;&#xA;" OwnerUserId="27039" LastEditorUserId="27039" LastEditDate="2020-04-19T20:33:56.090" LastActivityDate="2020-04-20T11:21:58.987" Title="Execute the contents of a register with a delay after each command" Tags="|register|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24629" PostTypeId="2" ParentId="24626" CreationDate="2020-04-16T18:36:07.983" Score="2" Body="&lt;p&gt;You rarely need &lt;a href=&quot;https://vimhelp.org/eval.txt.html#feedkeys%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;feedkeys()&lt;/code&gt;&lt;/a&gt;, which does things with vim’s user input lookahead buffer and can cause weird effects. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just want to run an ex command, you can do so literally in vimscript (which is just ex commands):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;new $MYVIMRC&#xA;&quot; alternately: split $MYVIMRC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="18609" LastEditDate="2020-04-16T19:23:39.563" LastActivityDate="2020-04-16T19:23:39.563" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24630" PostTypeId="1" CreationDate="2020-04-16T21:23:49.977" Score="0" ViewCount="579" Body="&lt;p&gt;I am trying to do a remapping when I'm in insert mode to insert a comment but am having a tough time figuring out what all the keys map to. What I am trying to do is:&lt;/p&gt;&#xA;&lt;p&gt;:inoremap &lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;space&lt;/kbd&gt; ==&amp;gt; &lt;kbd&gt;esc&lt;/kbd&gt;&lt;kbd&gt;leader&lt;/kbd&gt;&lt;kbd&gt;c&lt;/kbd&gt;&lt;kbd&gt;space&lt;/kbd&gt;&lt;kbd&gt;i&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;p&gt;Basically, if I'm in insert mode I want to get out of insert mode to insert the comment (leader+c+space) and then go back into insert mode.&lt;/p&gt;&#xA;&lt;p&gt;What would the correct &lt;code&gt;:inoremap&lt;/code&gt; mapping for this be? What I have right now is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;leader&amp;gt;c&amp;lt;space&amp;gt; &amp;lt;Esc&amp;gt;&amp;lt;Leader&amp;gt;c&amp;lt;space&amp;gt;i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But this doesn't seem to work (at least the latter half of it -- it does seem to be executing the mapping command). Note: the plugin I'm trying to remap is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/preservim/nerdcommenter&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/preservim/nerdcommenter&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;[count]&amp;lt;leader&amp;gt;c&amp;lt;space&amp;gt; |NERDCommenterToggle|&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Toggles the comment state of the selected line(s). If the topmost selected line is commented, all selected lines are uncommented and vice versa.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-04-17T00:19:43.480" Title="Map leader command for NerdCommenter" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24631" PostTypeId="1" AcceptedAnswerId="24632" CreationDate="2020-04-16T21:42:23.157" Score="0" ViewCount="85" Body="&lt;p&gt;How do I search and replace in a visual block only?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'&amp;lt;,'&amp;gt;s/search/replace/&lt;/code&gt; works on entire lines, not visual blocks only.&lt;/p&gt;&#xA;" OwnerUserId="5224" LastActivityDate="2020-04-16T22:25:02.977" Title="Search and replace visual block only?" Tags="|search|visual-block|" AnswerCount="1" CommentCount="0" ClosedDate="2020-04-16T22:30:10.687" ContentLicense="CC BY-SA 4.0" />
  <row Id="24632" PostTypeId="2" ParentId="24631" CreationDate="2020-04-16T22:25:02.977" Score="2" Body="&lt;p&gt;You can use the &lt;code&gt;\%V&lt;/code&gt; (&lt;code&gt;:h \%V&lt;/code&gt;) to do that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/\%Vsearch/replace/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27331" LastActivityDate="2020-04-16T22:25:02.977" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24633" PostTypeId="2" ParentId="24630" CreationDate="2020-04-17T00:19:43.480" Score="1" Body="&lt;p&gt;Couple of thoughts:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The &quot;do one normal command in insert mode&quot; is &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt;, so you could go with (&lt;code&gt;&amp;lt;plug&amp;gt;NERDCommenterComment&lt;/code&gt; is the &quot;comment map&quot;):&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;Leader&amp;gt;c&amp;lt;space&amp;gt; &amp;lt;C-o&amp;gt;&amp;lt;plug&amp;gt;NERDCommenterComment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that won't work, because &lt;code&gt;noremap&lt;/code&gt; prevents &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mappings from working (well it prevents all mappings on the right hand side, including &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;You could then try&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;Leader&amp;gt;c&amp;lt;space&amp;gt; &amp;lt;C-o&amp;gt;&amp;lt;plug&amp;gt;NERDCommenterComment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;But at this point, since you're using recursive maps, you might as well do&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;Leader&amp;gt;c&amp;lt;space&amp;gt; &amp;lt;C-o&amp;gt;&amp;lt;Leader&amp;gt;c&amp;lt;space&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But make sure you don't map &lt;code&gt;&amp;lt;C-o&amp;gt;&lt;/code&gt; in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;P.S. If you ever have to type &lt;code&gt;&amp;lt;Leader&amp;gt;c&amp;lt;space&amp;gt;&lt;/code&gt;, this mapping will get in your way... (e.g., my leader is space, although many use comma—what if you have to type that for some reason?). Recommended usage is to use normal mode for most things (like triggering commenting) and insert mode for, well, inserting things.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-17T00:19:43.480" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24634" PostTypeId="1" AcceptedAnswerId="24635" CreationDate="2020-04-17T00:20:23.957" Score="3" ViewCount="429" Body="&lt;p&gt;When I search for something with &lt;code&gt;/&lt;/code&gt; I get a series of finds, and as I press &lt;code&gt;n&lt;/code&gt; for next, it highlights the next one. I always think I'm on the wrong one. Maybe my eyes see green and red, and they think I'm on green. I don't know, but I have to adjust those two colors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do that? Code is also in the screenshot below...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AzJLY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AzJLY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can only edit the green background by changing &lt;code&gt;Search&lt;/code&gt; but I can't seem to change the red background which signifies the item I'm currently on.&lt;/p&gt;&#xA;" OwnerUserId="1596" LastEditorUserId="51" LastEditDate="2020-04-30T13:02:06.003" LastActivityDate="2021-02-11T08:05:03.797" Title="How can I change the syntax highlighting for currently highlighted search item?" Tags="|syntax-highlighting|colorscheme|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24635" PostTypeId="2" ParentId="24634" CreationDate="2020-04-17T02:18:13.363" Score="1" Body="&lt;p&gt;The current search colour is set by the &lt;code&gt;IncSearch&lt;/code&gt; highlight group.&lt;br&gt;&#xA;That's the colour you'll see, &lt;em&gt;while&lt;/em&gt; typing your search, on the current item (by the way, you can use &lt;code&gt;&amp;lt;c-t&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-g&amp;gt;&lt;/code&gt; while typing to select previous / next item).&lt;/p&gt;&#xA;&lt;p&gt;But once you hit &lt;code&gt;enter&lt;/code&gt;, vim should display only one colour (from the &lt;code&gt;search&lt;/code&gt; group), so I guess you are using a plugin to display a different colour for the current item.&lt;/p&gt;&#xA;&lt;h1&gt;EDIT&lt;/h1&gt;&#xA;&lt;p&gt;That was driving me crazy. I wrote a function that highlights the match in a different colour.&#xA;Well, it's probably not the way to go, since a mapping is needed on &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;N&lt;/code&gt; (and anything that starts a search, really), and it keeps the 'search hit bottom' from disappearing until the screen is moved.&lt;/p&gt;&#xA;&lt;p&gt;Besides this caveat, it works quite fine.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! HLCurrentMatch() abort&#xA;    call matchadd('IncSearch', '\c\%#'.@/, 101)&#xA;    redraw&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; n n:call HLCurrent()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; N N:call HLCurrent()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My vimscript skills are poor, but here's the main things to make it more viable in my opinion:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Check if we're back to the first match, in order to, say, use a different match, which would even be better than the 'back to first match' message&lt;/li&gt;&#xA;&lt;li&gt;Enable it right when a new match is defined (with &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;#&lt;/code&gt;...)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;FINAL&lt;/h1&gt;&#xA;&lt;p&gt;Here it is. This will use different highlight groups for the current match and for the edge matches.&#xA;Courtesy to @Zorzi for his help on &lt;a href=&quot;https://vi.stackexchange.com/a/25033/22375&quot;&gt;this question&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! HLCurrent() abort&#xA;    if exists(&amp;quot;currmatch&amp;quot;)&#xA;        call matchdelete(currmatch)&#xA;    endif&#xA;    &amp;quot; match only on cursor&#xA;    let patt = '\c\%#'.@/&#xA;    &amp;quot; check prev and next match&#xA;    let prevmatch = search(@/, 'bWn')&#xA;    let nextmatch = search(@/, 'Wn')&#xA;    &amp;quot; if on first or last match&#xA;    if prevmatch == 0 || nextmatch == 0&#xA;        let currmatch = matchadd('EdgeSearch', patt, 101)&#xA;    else&#xA;        let currmatch = matchadd('IncSearch', patt, 101)&#xA;    endif&#xA;    redraw&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; n n:call HLCurrent()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; N N:call HLCurrent()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You'll need to define a &amp;quot;EdgeSearch&amp;quot; highlight group, for example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;highlight EdgeSearch guibg=green ctermbg=black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As for the &amp;quot;search hit bottom&amp;quot; message, it's not needed any more. It can be disabled with &lt;code&gt;set shortmess+=s&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The code I use may change over time and can be found &lt;a href=&quot;https://github.com/Biggybi/dotfiles/blob/master/vim/plugin/search.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2021-02-11T08:05:03.797" LastActivityDate="2021-02-11T08:05:03.797" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24636" PostTypeId="1" AcceptedAnswerId="24637" CreationDate="2020-04-17T03:15:21.790" Score="2" ViewCount="314" Body="&lt;p&gt;I'd like to write commands that work with :tab and :vert. Say I have a command that opens a new split window as shown below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! FooSplit()&#xA;    let l:message=&quot;hello world&quot;&#xA;    new&#xA;    put! =l:message&#xA;endfunction&#xA;command! -complete=command Foo call FooSplit()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like it to make it so that &lt;code&gt;:tab Foo&lt;/code&gt; and &lt;code&gt;:vert Foo&lt;/code&gt; will open in a new tab and vertical split respectively. &lt;/p&gt;&#xA;" OwnerUserId="16662" LastEditorUserId="5017" LastEditDate="2020-04-17T05:18:07.953" LastActivityDate="2020-04-17T05:18:07.953" Title="How to add modifier to user defined command?" Tags="|vimscript|command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24637" PostTypeId="2" ParentId="24636" CreationDate="2020-04-17T03:40:39.293" Score="4" Body="&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Cmods%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h &amp;lt;mods&amp;gt;&lt;/a&gt; to do this, it expands to modifier or nothing. It's added at &lt;a href=&quot;https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90&quot; rel=&quot;nofollow noreferrer&quot;&gt;patch 7.4.1898&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;command Foo call FooSplit(&amp;lt;q-mods&amp;gt;)&#xA;&#xA;function FooSplit(mods)&#xA;  exe a:mods 'new'&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Above example use &lt;code&gt;&amp;lt;q-mods&amp;gt;&lt;/code&gt; instead of &lt;code&gt;&amp;lt;mods&amp;gt;&lt;/code&gt;, as you need it as a string.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-04-17T04:15:57.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24638" PostTypeId="1" AcceptedAnswerId="24643" CreationDate="2020-04-17T04:49:43.943" Score="5" ViewCount="2649" Body="&lt;h3&gt;An example:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A visual selection of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; echo -e &quot;hello&#xA; \bworld&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;followed by &lt;code&gt;:w !bash&lt;/code&gt; prints:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello &#xA;world &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I get the same result if my starting point is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello&#xA;\bworld&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;More details:&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I would like to pass a visual selection to a command that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;some_command -some_flag &quot;selection_from_vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The visual selection from vim should be &lt;strong&gt;placed inside quotes&lt;/strong&gt; in the command line command.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Like in the example, I would like to be able to select several lines. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="26170" LastEditorUserId="10604" LastEditDate="2020-04-17T15:36:49.793" LastActivityDate="2020-04-17T15:36:49.793" Title="How do I run a shell command using the current selection as arguments?" Tags="|command-line|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="24639" PostTypeId="2" ParentId="2958" CreationDate="2020-04-17T07:52:52.723" Score="2" Body="&lt;p&gt;You can achieve this by adding &lt;code&gt;set signcolumn=number&lt;/code&gt; to your .vimrc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Showing signs in the number column was added in &lt;a href=&quot;https://github.com/vim/vim/commit/394c5d8870b15150fc91a4c058dc571fd5eaa97e&quot; rel=&quot;nofollow noreferrer&quot;&gt;v8.1.1564&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="29007" LastActivityDate="2020-04-17T07:52:52.723" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24642" PostTypeId="1" AcceptedAnswerId="24654" CreationDate="2020-04-17T10:53:24.893" Score="1" ViewCount="320" Body="&lt;p&gt;Is it possible to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Foo(func_ref) abort&#xA;  nnoremap &amp;lt;buffer&amp;gt; &amp;lt;cr&amp;gt; :find_a_way_to_call_func_ref&#xA;endfunction&#xA;&#xA;function s:callback() abort&#xA;  echo &quot;123&quot;&#xA;endfunction&#xA;&#xA;command Test call Foo(function('s:callback'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To be clear, &lt;code&gt;:h Funcref&lt;/code&gt; is not &lt;code&gt;String&lt;/code&gt;, it's type is &lt;code&gt;v:t_func&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-04-18T07:40:13.523" LastActivityDate="2020-04-18T07:40:13.523" Title="Is it possible to create map to call Funcref (including lambda)?" Tags="|key-bindings|vimscript|functions|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24643" PostTypeId="2" ParentId="24638" CreationDate="2020-04-17T11:41:22.247" Score="3" Body="&lt;p&gt;There's a shell solution for your issue and a Vim solution to it.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Shell solution&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The shell solution to your issue is to have the shell read the contents (two lines with &lt;code&gt;hello&lt;/code&gt; and &lt;code&gt;\bworld&lt;/code&gt;) from standard input, then assemble the &lt;code&gt;echo -e ...&lt;/code&gt; command and execute it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do so using the shell's &lt;code&gt;eval&lt;/code&gt; command, to reinterpret the assembled string as a shell command. You can use &lt;code&gt;$(cat)&lt;/code&gt; to capture the standard input as a string in the command to be &lt;code&gt;eval&lt;/code&gt;uated.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !eval 'echo -e &quot;'&quot;$(cat)&quot;'&quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this is a concatenation of three strings, first being &lt;code&gt;echo -e &quot;&lt;/code&gt;, including the opening double quote and the last being a single double quote. The middle one &lt;code&gt;&quot;$(cat)&quot;&lt;/code&gt; is itself inside double quotes in order to preserve spaces and newlines (that's before &lt;code&gt;eval&lt;/code&gt; has a run on it.) Note that this solution is fragile, as if your input has any &lt;code&gt;&quot;&lt;/code&gt;s in it, it will potentially break the command. But it's the closest one to your original example and to what you specified.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Vim solution&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A solution within Vim is to use the &lt;code&gt;:!&lt;/code&gt; command instead and assemble the shell command, in this case &lt;code&gt;echo&lt;/code&gt;, inside Vim itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:execute&lt;/code&gt;&lt;/a&gt; to run the command from a Vim string, and &lt;a href=&quot;https://vimhelp.org/eval.txt.html#shellescape%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;shellescape()&lt;/code&gt;&lt;/a&gt; to quote the argument to &lt;code&gt;echo&lt;/code&gt;. Note that in this case you'll need to pass a non-zero second argument to &lt;code&gt;shellescape()&lt;/code&gt;, so it escapes the newlines with a backslash, which makes it work correctly with &lt;code&gt;:!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First yank the visual selection into the default register with a &lt;code&gt;y&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then execute the external command with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute '! echo -e '.shellescape(@&quot;, 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Here &lt;code&gt;@&quot;&lt;/code&gt; is the default register.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution is quite robust to characters in the input, since &lt;code&gt;shellescape()&lt;/code&gt; is doing the job of escaping special characters &lt;em&gt;and&lt;/em&gt; quoting the string. (Note how we don't have any &lt;code&gt;&quot;&lt;/code&gt;s or &lt;code&gt;'&lt;/code&gt;s that are passed to the shell, those are only Vim strings here.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a small difference in how Vim runs &lt;code&gt;:w !{cmd}&lt;/code&gt; and &lt;code&gt;:!{cmd}&lt;/code&gt; here, in that &lt;a href=&quot;https://vi.stackexchange.com/q/24645/18609&quot;&gt;with the former it doesn't clear the screen (switch back from the alternate screen) but does so with the latter&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One hacky workaround is to still use &lt;code&gt;:w !{cmd}&lt;/code&gt; for the second case, perhaps with a small range of the current line. It will pass the external command that line as standard input, but as long as the command doesn't use the standard input, that shouldn't make a difference.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute '.w !echo -e '.shellescape(@&quot;, 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-17T12:17:54.527" LastActivityDate="2020-04-17T12:17:54.527" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24644" PostTypeId="2" ParentId="24642" CreationDate="2020-04-17T11:42:07.403" Score="0" Body="&lt;p&gt;Sure, you want to use the &lt;code&gt;execute&lt;/code&gt; command, which acts like an eval:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Foo(func_ref) abort&#xA;  exe&quot;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;cr&amp;gt; :&quot;.func_ref.&quot;()&amp;lt;cr&amp;gt;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27331" LastActivityDate="2020-04-17T11:42:07.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24645" PostTypeId="1" AcceptedAnswerId="24943" CreationDate="2020-04-17T12:16:13.353" Score="7" ViewCount="366" Body="&lt;p&gt;On a Linux platform I see this difference of behavior between running a shell command with &lt;code&gt;:!{cmd}&lt;/code&gt; (which just runs the command directly) and with &lt;code&gt;:w !{cmd}&lt;/code&gt; (which passes the buffer as standard input to the command.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;:!{cmd}&lt;/code&gt; will switch back from the alternate screen back to the main screen, which means the Vim buffer and UI are hidden and the screen on the shell where I ran Vim are presented back, then the command output is printed and the &quot;hit return&quot; prompt is issued.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I start &lt;code&gt;vim&lt;/code&gt;, then run &lt;code&gt;:!echo hello&lt;/code&gt;, the result I see is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim&#xA;&#xA;hello&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That text is also present after I exit Vim, since it's been output into the main screen, not the alternate screen that Vim is managing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, if I run the same command with &lt;code&gt;:w !{cmd}&lt;/code&gt;, Vim simply prints the output of the command below the Ex command-line. For &lt;code&gt;:w !echo hello&lt;/code&gt;, what I end up seeing is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~&#xA;~&#xA;~&#xA;[No Name]                             0,0-1          All&#xA;:w !echo hello&#xA;hello&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll recognize the &lt;code&gt;~&lt;/code&gt;s as Vim's empty lines at the end of the buffer, and the &lt;code&gt;[No Name]&lt;/code&gt; line as Vim's status line. The Ex command is also not cleared.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why the difference?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation isn't very clear about it. The closest thing mentioned in &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3A%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :!&lt;/code&gt;&lt;/a&gt; is that &lt;em&gt;&quot;Vim redraws the screen after the command is finished, because it may have printed any text&quot;&lt;/em&gt;, but that doesn't really explain why it needs to switch back to the main screen. It also mentions using &lt;code&gt;:silent&lt;/code&gt; to prevent redrawing, but that prevents any output altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Documentation in &lt;a href=&quot;https://vimhelp.org/editing.txt.html#%3Awrite_c&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :write_c&lt;/code&gt;&lt;/a&gt; doesn't help much either, it says *&quot;&lt;code&gt;{cmd}&lt;/code&gt; is executed like with &lt;code&gt;:!{cmd}&lt;/code&gt;&quot;, but it's actually referring to how &lt;code&gt;!&lt;/code&gt;s are special in the command itself...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make &lt;code&gt;:!{cmd}&lt;/code&gt; behave like &lt;code&gt;:w !{cmd}&lt;/code&gt;, without switching back from the alternate screen?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is there another way to run an external command on the alternate screen, that doesn't involve passing it lines from the current buffer as standard input?&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-24T17:56:11.793" LastActivityDate="2020-04-28T15:46:36.293" Title="Difference between `:!{cmd}` and `:w !{cmd}` regarding alternate screen" Tags="|terminal|external-command|shell|filter|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="24646" PostTypeId="1" CreationDate="2020-04-17T12:45:17.493" Score="2" ViewCount="41" Body="&lt;p&gt;I'm trying to do a long blocking read call inside a python script supplied with the &lt;code&gt;python&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python3 &amp;lt;&amp;lt; EOF&#xA;import ctypes&#xA;libc=ctypes.CDLL(&quot;libc.so.6&quot;)&#xA;ch = ctypes.create_string_buffer(1)&#xA;r = libc.read(3,ch,1) #raw syscall, because pythons os.read restarts on EINTR&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like for the &lt;code&gt;read&lt;/code&gt; call to be breakable with signal-generated signals such as &lt;code&gt;SIGINT&lt;/code&gt; (generated by &lt;code&gt;Ctrl+C&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, vim seems to run the python snippet with the terminal set not to generated this signal upon a &lt;code&gt;Ctrl+C&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I run this snippet so that &lt;code&gt;Ctlr+C&lt;/code&gt; continues to generates &lt;code&gt;SIGINT&lt;/code&gt; even inside of the snippet? Also, how can the vimscript that calls the python snippet tell if the python succeeded or not?&lt;/p&gt;&#xA;" OwnerUserId="4738" LastEditorUserId="1292" LastEditDate="2020-09-08T05:10:53.437" LastActivityDate="2020-09-08T05:10:53.437" Title="Running a python command with terminal-generated signals enabled" Tags="|terminal|vimscript-python|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24647" PostTypeId="2" ParentId="24642" CreationDate="2020-04-17T13:36:06.537" Score="2" Body="&lt;p&gt;I don't think it is possible to directly call this funcref from within mapping -- by the time you press mapped key funcref is already disposed/freed/unavailable.&lt;/p&gt;&#xA;&lt;p&gt;You can try to persist funcref though (either in global or script local dict):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;let g:my_funcs={}&#xA;&#xA;function! Foo(func_ref) abort&#xA;    let g:my_funcs.f = a:func_ref&#xA;    nnoremap &amp;lt;buffer&amp;gt; &amp;lt;cr&amp;gt; :call g:my_funcs.f()&amp;lt;CR&amp;gt;&#xA;endfunction&#xA;&#xA;function! Callback() abort&#xA;  echom &amp;quot;123&amp;quot;&#xA;endfunction&#xA;&#xA;command! Test call Foo(function('Callback'))&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bLNiF.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bLNiF.gif&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It is not necessary to use dictionary, you can have regular global var I think. But for the dictionary you can come up with some clever things, like having array of functions, caching or whatever else.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-04-17T13:36:06.537" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24648" PostTypeId="1" AcceptedAnswerId="24649" CreationDate="2020-04-17T14:34:51.870" Score="1" ViewCount="169" Body="&lt;p&gt;I would like to populate a register with the text inside quotes for a range of lines. The register should contain all yanked text separated with new line characters. Example lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The &quot;black&quot; cat&#xA;A &quot;tall&quot; tree&#xA;A long &quot;tail&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Intuitively I tried to clear my &lt;code&gt;q&lt;/code&gt; register with &lt;code&gt;qqq&lt;/code&gt;, select the lines in visual mode and run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;norm &quot;Qyi&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then all the text is on the same line which is not what I want. I would not want to use regular expressions because it is very easy to build a normal mode set of commands to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My next attempt was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;g/.*/execute 'normal &quot;Qyi&quot;' | let @q .= &quot;\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used the &lt;code&gt;global&lt;/code&gt; command matching all line of the selection because the &lt;code&gt;execute&lt;/code&gt; command doesn't accept a range. After the yank of text in the normal command I attempt to add a new line character but my &lt;code&gt;q&lt;/code&gt; register ends up like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;black^Jtall^J^Jtail^J^J&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which has a mix of one and two new line characters between the yanked words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the right way to do this? Ideally still using the normal mode commands to yank the text.&lt;/p&gt;&#xA;" OwnerUserId="25399" LastEditorUserId="205" LastEditDate="2020-11-01T19:11:32.410" LastActivityDate="2020-11-01T19:11:32.410" Title="Yank inside quotes of a range of lines to a register and separate them with a new line character" Tags="|cut-copy-paste|normal-mode|register|range|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24649" PostTypeId="2" ParentId="24648" CreationDate="2020-04-17T15:14:31.747" Score="2" Body="&lt;p&gt;Include the &lt;code&gt;&amp;gt;&lt;/code&gt; flag in &lt;code&gt;'cpoptions'&lt;/code&gt;, so that Vim automatically adds a new line before appending to a register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set cpo+=&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:h cpo-&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I would like a more general solution so that I can understand how to solve future problems.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @q = '' | *g/^/exe 'norm! &quot;Qyi&quot;' | call setreg('q', &quot;\n&quot;, 'ac')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your command didn't work because appending a newline with &lt;code&gt;:let&lt;/code&gt; changes the type of the register from characterwise to linewise. See &lt;code&gt;:h :let-register&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If the result of {expr1} ends in a &amp;lt;CR&gt; or &amp;lt;NL&gt;, the&#xA;  register will be linewise, otherwise it will be set to&#xA;  characterwise.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For instance, what if I wanted to separate each yanked text by commas?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @q = '' | *g/^/exe 'norm! &quot;Qyi&quot;' | let @q .= ','&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-04-17T16:05:21.163" LastActivityDate="2020-04-17T16:05:21.163" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24650" PostTypeId="1" CreationDate="2020-04-17T15:40:30.007" Score="1" ViewCount="783" Body="&lt;p&gt;I'm using a tip from &lt;a href=&quot;https://vim.fandom.com/wiki/Highlight_unwanted_spaces&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page of the vim wiki&lt;/a&gt; to highlight trailing spaces when I'm not in insert mode :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight ExtraWhitespace ctermbg=red&#xA;match ExtraWhitespace /\s\+$/&#xA;autocmd BufWinEnter * match ExtraWhitespace /\s\+$/&#xA;autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@&amp;lt;!$/&#xA;autocmd InsertLeave * match ExtraWhitespace /\s\+$/&#xA;autocmd BufWinLeave * call clearmatches()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I would like to disable this highlighting (just like all the other ones) with &lt;code&gt;:syntax off&lt;/code&gt;. It turns out that it disables my colorscheme, but not this specific highlight group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to add those lines to my colorscheme file, instead of my &lt;code&gt;.vimrc&lt;/code&gt;, but it doesn't work either. The &lt;code&gt;ExtraWhitespace&lt;/code&gt; group is always highlighted, even with &lt;code&gt;:syntax off&lt;/code&gt;. How can I disable it ?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I think there's a bug in vim/Neovim here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume that the answer to my question would be the following one (suggested by D. Ben Knoble, thank you!):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! TrailingSpaces()&#xA;   if exists(&quot;syntax_on&quot;)&#xA;      match ExtraWhitespace /\s\+$/&#xA;   else&#xA;      match NONE&#xA;   endif&#xA;endfunction&#xA;autocmd Syntax * call s:TrailingSpaces()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;highlight&lt;/code&gt; command should then be put in the theme file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or the following one should work too with the original code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd Syntax * if exists(&quot;syntax_on&quot;) | hi ExtraWhitespace ctermbg=red | else | hi clear ExtraWhitespace | endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in fact, none of them is working. It seems that the &lt;code&gt;syntax&lt;/code&gt; event is never triggered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code &lt;em&gt;should&lt;/em&gt; do something, right?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Test()&#xA;   echo &quot;This is a test.&quot;&#xA;endfunction&#xA;autocmd Syntax * call Test()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But nothing ever happens when I set &lt;code&gt;:syntax off&lt;/code&gt; or &lt;code&gt;:syntax on&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tested with a clean vimrc, both with vim and Neovim (latest versions from the Arch Linux repos).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something here? Could anyone confirm this?&lt;/p&gt;&#xA;" OwnerUserId="28889" LastEditorUserId="1841" LastEditDate="2020-04-23T10:09:57.137" LastActivityDate="2020-04-23T10:09:57.137" Title="How to disable highlighting for custom group" Tags="|highlight|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24652" PostTypeId="2" ParentId="10787" CreationDate="2020-04-17T16:28:17.930" Score="0" Body="&lt;p&gt;After searching with &lt;code&gt;:VimwikiSearchTags&lt;/code&gt;, use &lt;code&gt;:lopen&lt;/code&gt;. This will open a Vim 'split'. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After selecting the note you want in the split, you can close the split created with &lt;code&gt;:lopen&lt;/code&gt; by pressing &lt;code&gt;ctrl+o&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you decide to leave the split open so you can move between notes, you can navigate splits using &lt;code&gt;ctrl+w&lt;/code&gt; then &lt;code&gt;h, j, k, or l&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="29024" LastActivityDate="2020-04-17T16:28:17.930" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24653" PostTypeId="1" AcceptedAnswerId="24655" CreationDate="2020-04-17T17:12:13.017" Score="0" ViewCount="1098" Body="&lt;p&gt;I would like to use vim to do the following operation in vim:&#xA;I would like to determine the number of entries with avg_deg greater then &quot;'avg_deg': 5.50&quot; from a simple .log file as well as the average of all avg_degs. Afterwards I would like to repeat the same for all entries smaller than &quot;5.00&quot; (the smallest entry in the log is &quot;4.63&quot; and the biggest is at &quot;6.04&quot;). Simply searching and counting the values manually is not possible in realistic time since the file is about 31 MB big.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The file contains many entries with some string in apostrophes with colon following a number but it is necessary to observe only numbers directly following the string &quot;'avg_deg': &quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would have copied parts of the file as example but even single variables are too big to put them here - at least my browser dies and the website doesn't react anymore when I do so. &lt;/p&gt;&#xA;" OwnerUserId="6816" LastEditorUserId="6816" LastEditDate="2020-04-17T17:48:13.083" LastActivityDate="2020-04-17T18:55:36.057" Title="I would like to find and count number of entries bigger than a certain number in front of a certain string" Tags="|search|find|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24654" PostTypeId="2" ParentId="24642" CreationDate="2020-04-17T17:25:40.820" Score="3" Body="&lt;p&gt;It's really doable with &lt;code&gt;execute&lt;/code&gt;... and &lt;code&gt;call()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Foo(func_ref) abort&#xA;    execute printf('nnoremap &amp;lt;buffer&amp;gt;&amp;lt;cr&amp;gt; :call call(%s, [])&amp;lt;CR&amp;gt;',&#xA;        \ string(get(a:func_ref, 'name')))&#xA; endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastEditorUserId="22797" LastEditDate="2020-04-18T05:33:20.327" LastActivityDate="2020-04-18T05:33:20.327" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="24655" PostTypeId="2" ParentId="24653" CreationDate="2020-04-17T18:27:10.137" Score="1" Body="&lt;p&gt;If it is one off task you can try this &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;avgs greater than 5.50 till 5.99 (remember number of matches)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/avg_deg': [5]\.[56789]\d//gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;avgs greater than 6.00 (remember number of matches)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/avg_deg': [6789]\.\d\d//gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;avgs smaller than 5.00 (remember number of matches)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/avg_deg': [01234]\.\d\d//gn&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can sum those number of matches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;command explanation, sort of&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%s&lt;/code&gt; - is to substitute a regexp&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;//g&lt;/code&gt; - substitute all matches with nothing... but we have &lt;code&gt;n&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;n&lt;/code&gt; - report the number of matches, do not actually substitute&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZU2od.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZU2od.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9333" LastEditorUserId="9333" LastEditDate="2020-04-17T18:55:36.057" LastActivityDate="2020-04-17T18:55:36.057" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24657" PostTypeId="1" AcceptedAnswerId="24658" CreationDate="2020-04-17T20:41:12.027" Score="2" ViewCount="152" Body="&lt;p&gt;Here is a problem I am able to solve in Sublime in seconds but has me stumped in Vim:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given text like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bob@bobshop.com Bob Potato&#xA;peter@petershop.co.uk Peter Carrot&#xA;thomas.cucumber@thomasstore.org Thomas Cucumber&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to delete either all the names in one go, and then the email addresses, or all the email addresses and then the names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm hoping there is a way that doesn't require 10th Dan Regex skills?&lt;/p&gt;&#xA;" OwnerUserId="24880" LastActivityDate="2020-04-17T21:45:35.483" Title="How to do multiline non-rectangular deletion?" Tags="|multiple-lines|selection|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24658" PostTypeId="2" ParentId="24657" CreationDate="2020-04-17T20:58:30.497" Score="2" Body="&lt;p&gt;To delete all emails first:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vip:norm! dW&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vip&lt;/code&gt; select paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:norm! dW&lt;/code&gt; execute normal mode commands: delete WORD&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then you end up having only names -- delete them as usual I guess?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To delete all names first:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;vip:norm! WD&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vip&lt;/code&gt; select paragraph&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:norm! WD&lt;/code&gt; execute normal mode commands: move cursor 1 WORD and delete to the end of line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-04-17T20:58:30.497" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24659" PostTypeId="2" ParentId="24657" CreationDate="2020-04-17T20:58:35.260" Score="0" Body="&lt;p&gt;The easiest way to do that would be to use a macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given you are on the 1st line 1st col:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; To delete the emails:&#xA;qa0dWjq2@a&#xA;&#xA;&quot; To delete the names:&#xA;qa0ElDjq2@a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Though I would admit that it's far from being as intuitive as Sublime or VScode with the multi cursors.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Or, as you mentioned, we can use holy regex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; To delete the emails:&#xA;s/^\S\+//g&#xA;&#xA;&quot; To delete the names:&#xA;s/^\S\zs\s.*$//g &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Or, you could use the &lt;code&gt;norm&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; To delete the emails:&#xA;vip:norm!dW&#xA;&#xA;&quot; To delete the names:&#xA;vip:norm!ElD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27331" LastActivityDate="2020-04-17T20:58:35.260" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24660" PostTypeId="2" ParentId="24657" CreationDate="2020-04-17T21:18:15.877" Score="1" Body="&lt;p&gt;1st Dan needed to delete the names. The delimiter is the first space. So delete everything from the first space to end of line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/ .*$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To delete the emails, a 2nd Dan is needed. Delete any non-space and the first space from the beginning of the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/^[^ ]* //&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: This answer assumes, that the delimiter is a single space character. If the delimiter between the email and the name is a &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt; or multiple spaces or any combination of it, we have to move to the 3rd Dan:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\s.*$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This deletes from the first whitespace (be it a space or a tab) till the end of line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/^\S*\s\+//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This deletes from the beginning of the line (&lt;code&gt;^&lt;/code&gt;) all non-whitespace characters (&lt;code&gt;\S*&lt;/code&gt;) including the following one or more whitespaces (&lt;code&gt;\s\+&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help /\s&lt;/code&gt;, &lt;code&gt;:help /^&lt;/code&gt; and &lt;code&gt;:help /\+&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now ranges:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest case is if you want to act on the entire file, just use &lt;code&gt;%&lt;/code&gt; like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/ .*$//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it is only a part of the file, the easiest way is to visually select the lines and then hit &lt;code&gt;:&lt;/code&gt; and enter one of the substitution commands from above.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2020-04-17T21:45:35.483" LastActivityDate="2020-04-17T21:45:35.483" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24661" PostTypeId="1" CreationDate="2020-04-17T21:49:17.330" Score="0" ViewCount="791" Body="&lt;p&gt;I made my own vim wrapper around ripgrep (I know there is vim-grepper, but I wanted to try customize some things).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The crux of it is I populate a quickfix window as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let searchString = input('Search in Files '.getcwd().': ')&#xA;silent cexpr system('rg -H --no-heading --column '.searchString)&#xA;silent copen&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are two problems with this &lt;code&gt;cexpr&lt;/code&gt; approach:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It jumps to the first match (which I find disorientating).&lt;/li&gt;&#xA;&lt;li&gt;It blocks editing. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To solve these issues, I have searched around, andit seems asynchronous jobs require hundreds of lines of code, or plugin helpers (which I am trying to avoid so I can hopefully  turn this tool into a plugin). One way seems to be just to use Neovim's terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        terminal rg -H --no-heading --column 'search expression'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is quite easy to do.  However the only part I don't know how to do is pull in the lines into a quickfix window. Under [:h cexpr] There seems to be a hint about pulling in certain lines from a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cexpr getline(1, '$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How does one reference the lines from the terminal buffer, so one can pull them into the quick fix window? And even better update the Quickfix window in realtime as entries are found?&lt;/p&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2021-01-13T13:08:30.883" Title="Neovim, read entries from the terminal into quickfix buffer" Tags="|quickfix|terminal-buffer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24662" PostTypeId="1" AcceptedAnswerId="24663" CreationDate="2020-04-17T23:53:16.460" Score="2" ViewCount="243" Body="&lt;p&gt;Are there any differences between using &lt;code&gt;vimdiff x.py y.py&lt;/code&gt; and &lt;code&gt;vim -d x.py y.py&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="27301" LastActivityDate="2020-04-18T00:51:15.690" Title="Any difference between vimdiff and vim -d?" Tags="|vimdiff|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24663" PostTypeId="2" ParentId="24662" CreationDate="2020-04-18T00:51:15.690" Score="5" Body="&lt;p&gt;If your vim supports diff mode (which is in most cases), there is no difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a minor difference though, if your vim is compiled without the &lt;code&gt;+diff&lt;/code&gt; feature, &lt;code&gt;vimdiff a b&lt;/code&gt; will produce the error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This Vim was not compiled with the diff feature.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;vim -d a b&lt;/code&gt; will silently accept without entering diff mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless you are on amiga, in which case the &lt;code&gt;-d&lt;/code&gt; is interpreted as a device name for use as a terminal. &lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2020-04-18T00:51:15.690" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24664" PostTypeId="1" AcceptedAnswerId="24668" CreationDate="2020-04-18T03:02:53.280" Score="6" ViewCount="2602" Body="&lt;p&gt;I'm using vim 8 with some plugins and shortcuts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set a shortcut for &lt;code&gt;:term&lt;/code&gt; to open a terminal in vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :wa&amp;lt;CR&amp;gt; \| :term&amp;lt;CR&amp;gt;&#xA;command Q qa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when I type &lt;code&gt;F5&lt;/code&gt;, a terminal will popup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I try to type &lt;code&gt;:Q&lt;/code&gt; to close all of windows and quit vim, I get an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E947: Job still running in buffer &quot;!/bin/bash&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, I have to type &lt;code&gt;&amp;lt;C-d&amp;gt;&lt;/code&gt; to close the terminal first, then &lt;code&gt;:Q&lt;/code&gt; could work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to append some command for my &lt;code&gt;command Q qa | ???&lt;/code&gt; but I don't know how.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that &lt;code&gt;&amp;lt;C-w&amp;gt;&amp;lt;C-c&amp;gt;&lt;/code&gt; can close the terminal, but what if I opened two or three terminals? What I need is to make my command &lt;code&gt;Q&lt;/code&gt; to close all of windows and quit vim immediately.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-04-18T08:06:24.570" Title="Job still running in buffer while :qa" Tags="|terminal|quit|vim8|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24666" PostTypeId="1" CreationDate="2020-04-18T06:18:38.760" Score="2" ViewCount="116" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/preservim/nerdtree/blob/master/doc/NERDTree.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;NERDTree.txt&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;go.......Open selected file, but leave cursor in the NERDTree......|NERDTree-go|&#xA;         Open selected bookmark dir in current NERDTree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I typo &lt;code&gt;go&lt;/code&gt; in a NERDTree buffer, selected file is opened in the current window, same as &lt;code&gt;o&lt;/code&gt;.&#xA;I expect the file is opened in background buffer, is it right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Disable all other plugins.&lt;/li&gt;&#xA;&lt;li&gt;Remove .vimrc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ubuntu 18.04 LTS&lt;/li&gt;&#xA;&lt;li&gt;vim 8.0&lt;/li&gt;&#xA;&lt;li&gt;NERDTree 6.7.7 via vim 8 pack&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="29035" LastEditorUserId="51" LastEditDate="2020-04-18T09:35:04.700" LastActivityDate="2024-01-17T13:02:15.303" Title="NERDTree-go does not leave cursor in the NERDTree" Tags="|plugin-nerdtree|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24668" PostTypeId="2" ParentId="24664" CreationDate="2020-04-18T08:06:24.570" Score="9" Body="&lt;p&gt;Running process in a terminal buffer is treated mostly the same way as &quot;an unsaved file&quot;. So you can do &lt;code&gt;:qa!&lt;/code&gt; or &lt;code&gt;:set confirm&lt;/code&gt; etc.etc. Well, anything to allow exit from Vim with buffers unsaved. But, of course, that will modify Vim's behaviour with respect to all buffers, not only terminals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you only want to allow silent terminal closing, you should provide an extra option: &lt;code&gt;:term ++kill=term&lt;/code&gt;. This instructs Vim to send &lt;code&gt;SIGTERM&lt;/code&gt; to the running process if the terminal buffer needs to be closed.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-04-18T08:06:24.570" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24669" PostTypeId="2" ParentId="24661" CreationDate="2020-04-18T10:04:06.787" Score="2" Body="&lt;p&gt;Paging through the help this morning, I stumbled across &lt;code&gt;cbuffer&lt;/code&gt;, which reads values from a buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cb[uffer][!] [bufnr]   Read the error list from the current buffer.&#xA;            When [bufnr] is given it must be the number of a&#xA;            loaded buffer.  That buffer will then be used instead&#xA;            of the current buffer.&#xA;            A range can be specified for the lines to be used.&#xA;            Otherwise all lines in the buffer are used.&#xA;            See |:cc| for [!].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-04-18T10:04:06.787" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24670" PostTypeId="1" AcceptedAnswerId="24672" CreationDate="2020-04-18T11:16:22.890" Score="7" ViewCount="1344" Body="&lt;p&gt;I want to run &lt;a href=&quot;https://stackoverflow.com/questions/7588531/vim-set-color-theme-based-off-time-of-day&quot;&gt;https://stackoverflow.com/questions/7588531/vim-set-color-theme-based-off-time-of-day&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if strftime(&quot;%H&quot;) &amp;lt; 12&#xA;  set background=light&#xA;else&#xA;  set background=dark&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But for this to be invoked every hour, rather than only once when opening vim. Does vim or neovim support running a periodic action?&lt;/p&gt;&#xA;" OwnerUserId="13656" LastActivityDate="2020-04-18T12:58:09.407" Title="How can I run a function / action every period of time (once an hour)?" Tags="|vimscript|neovim|autocmd|functions|date-and-time|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24671" PostTypeId="2" ParentId="24670" CreationDate="2020-04-18T11:26:44.883" Score="3" Body="&lt;p&gt;As a workaround one can instead target the common &lt;code&gt;FocusLost&lt;/code&gt; / &lt;code&gt;FocusGained&lt;/code&gt; events.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function DynamicColorThemeSwitch()&#xA;  if strftime(&quot;%H&quot;) &amp;lt; 18&#xA;    set background=light&#xA;    colorscheme zellner&#xA;  else&#xA;    set background=dark&#xA;    colorscheme nightfly&#xA;  endif&#xA;endfunction&#xA;&#xA;autocmd FocusLost,FocusGained * call DynamicColorThemeSwitch()&#xA;call DynamicColorThemeSwitch()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13656" LastActivityDate="2020-04-18T11:26:44.883" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24672" PostTypeId="2" ParentId="24670" CreationDate="2020-04-18T11:30:05.537" Score="6" Body="&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#timer_start%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;timer_start()&lt;/code&gt;&lt;/a&gt; to set &quot;timers&quot; to run a function every &lt;em&gt;n&lt;/em&gt; milliseconds. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:set_bg(timer_id)&#xA;    let &amp;amp;background = (strftime('%H') &amp;lt; 12 ? 'light' : 'dark')&#xA;endfun&#xA;call timer_start(1000 * 60, function('s:set_bg'), {'repeat': -1})&#xA;call s:set_bg(0)  &quot; Run on startup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will run &lt;code&gt;s:set_bg()&lt;/code&gt; every 1 minute (60,000 milliseconds), and by setting &lt;code&gt;repeat&lt;/code&gt; to &lt;code&gt;-1&lt;/code&gt; it will run indefinitely (rather than just once).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I've been able to see in my (short) testing, this doesn't cause any side-effects such as slow-downs or flickering. You can consider changing the logic to set &lt;code&gt;background&lt;/code&gt; only if it differs from the current value if it does (but looks like Vim is smart enough on its own).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that resetting the colour scheme (as you did in your own answer), &lt;em&gt;does&lt;/em&gt; cause some flicking for me; you can get the current scheme name with &lt;code&gt;g:colors_name&lt;/code&gt;, and use something like this to change it only when needed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:set_bg(timer_id)&#xA;        let l:hour = strftime('%H')&#xA;&#xA;        if l:hour &amp;lt; 18 &amp;amp;&amp;amp; g:colors_name isnot# 'zellner'&#xA;                set background=light&#xA;                colorscheme zellner&#xA;        elseif l:hour &amp;gt; 18 &amp;amp;&amp;amp; g:colors_name isnot# 'nightfly'&#xA;                set background=dark&#xA;                colorscheme nightfly&#xA;        endif&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can probably make this a bit shorter if you want, but should get the idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to be able to disable the switching at runtime, then return the timer ID from &lt;code&gt;timer_start()&lt;/code&gt; and call &lt;code&gt;timer_stop()&lt;/code&gt; on it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Support for timers was added in Vim 7.4.1578 (March 2016), and some &lt;em&gt;very&lt;/em&gt; old installations may not have it (this is also why the SO question you link doesn't mention it, as that was asked before this feature existed).&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-04-18T12:58:09.407" LastActivityDate="2020-04-18T12:58:09.407" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24674" PostTypeId="1" CreationDate="2020-04-18T16:14:47.507" Score="1" ViewCount="93" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QLsOA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QLsOA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The interactive GetType popup is a great feature, but I would love to set it so it spawns beneath the cursor, due to the fact that I sometimes need to read the above lines to know what parameters to give the function below.&#xA;I've searched the docs for an option but couldn't find any that references the position of popups. &#xA;Would appreciate any help, thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="29044" LastActivityDate="2020-04-18T16:14:47.507" Title="Change YouCompleteMe GetType popup position?" Tags="|plugin-you-complete-me|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24675" PostTypeId="1" AcceptedAnswerId="24685" CreationDate="2020-04-18T16:15:30.123" Score="1" ViewCount="78" Body="&lt;p&gt;I have an auto command that changes some color scheme values so I can avoid forking them when all I need is small changes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup FixColorSchemes&#xA;    autocmd!&#xA;    autocmd ColorScheme *&#xA;        \ highlight EndOfBuffer guibg=bg guifg=bg |&#xA;        \ highlight FoldColumn guibg=bg |&#xA;        \ highlight! link Folded FoldColumn |&#xA;        \ highlight MatchParen guibg=bg guifg=red gui=bold |&#xA;        \ highlight SpecialKey guibg=bg |&#xA;        \ highlight TermCursorNC guibg=bg guifg=bg&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like the background of the column separating vertical splits to have the same color of the &lt;code&gt;Normal&lt;/code&gt; highlight's background, and its foreground to be the same color of the background of the status line (so I would get a thin line the same color of the status line). This is what I'm trying&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\ let s:output = execute('highlight ' . 'StatusLineNC') |&#xA;\ let s:reverse = matchstr(s:output, 'inverse\|reverse') |&#xA;\ echo s:reverse |&#xA;\ let s:splitcolor = s:reverse == ''&#xA;    \ ? matchstr(s:output, 'guibg' . '=\zs\S*')&#xA;    \ : matchstr(s:output, 'guifg' . '=\zs\S*') |&#xA;\ highlight! VertSplit guibg=bg guifg=s:splitcolor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to work, but the colour returned, although is part of the current color scheme, is not necessarily a color used in the status line. Any idea why it doesn't work as expected?&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-19T08:43:33.660" Title="Can I apply individual colours from one highlight in another one?" Tags="|colorscheme|highlight|highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24676" PostTypeId="2" ParentId="18092" CreationDate="2020-04-18T18:20:27.897" Score="1" Body="&lt;p&gt;Another possibility is to add a commandline-mode mapping with &lt;code&gt;:cmap&lt;/code&gt; to add &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt;; so then you'd type &lt;code&gt;hello&lt;/code&gt;, press e.g. &lt;code&gt;&amp;lt;F1&amp;gt;&lt;/code&gt;, and that will transform it to &lt;code&gt;\&amp;lt;hello\&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple version might look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;expr&amp;gt; &amp;lt;F1&amp;gt; index(['/', '?'], getcmdtype()) is -1 ? &quot;\&amp;lt;F1&amp;gt;&quot; : &quot;\&amp;lt;Home&amp;gt;\\&amp;lt;\&amp;lt;End&amp;gt;\\&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It just sends &lt;code&gt;&amp;lt;Home&amp;gt;\&amp;lt;&amp;lt;End&amp;gt;\&amp;gt;&lt;/code&gt;. This is a bit naïve since it doesn't check whether there already are angled brackets, and it frobs with the cursor position. A better, but longer, version might look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! s:wrap()&#xA;    let l = getcmdline()&#xA;    let pos = getcmdpos()&#xA;&#xA;    &quot; Remove&#xA;    if l[:1] is '\&amp;lt;' &amp;amp;&amp;amp; l[-2:] is '\&amp;gt;'&#xA;        call setcmdpos(pos - 2)&#xA;        return l[2:len(l)-3]&#xA;    endif&#xA;&#xA;    &quot; Add&#xA;    if l[:1] isnot '\&amp;lt;'&#xA;        let l = '\&amp;lt;' . l&#xA;        let pos += 2&#xA;    endif&#xA;    if l[-2:] isnot '\&amp;gt;'&#xA;        let l .= '\&amp;gt;'&#xA;    endif&#xA;    call setcmdpos(pos)&#xA;    return l&#xA;endfun&#xA;&#xA;cnoremap &amp;lt;expr&amp;gt; &amp;lt;F1&amp;gt; index(['/', '?'], getcmdtype()) is -1 ? &quot;\&amp;lt;F1&amp;gt;&quot; : &quot;\&amp;lt;C-\&amp;gt;e&amp;lt;SID&amp;gt;wrap()\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;&amp;lt;C-\&amp;gt;e&lt;/code&gt; the return value of a function is inserted, the function removes &lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; if they exist, or adds them if they don't. If also preserves the cursor position.&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2020-04-18T18:20:27.897" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24677" PostTypeId="2" ParentId="24578" CreationDate="2020-04-18T18:26:36.913" Score="1" Body="&lt;p&gt;I would suggest installing &lt;a href=&quot;https://macvim-dev.github.io/macvim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MacVim&lt;/a&gt; which already comes with many (all?) of these keybindings set as default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Within MacVim, I found I could use &lt;code&gt;&amp;lt;D-key&amp;gt;&lt;/code&gt; in mappings, to capture &lt;kbd&gt;Cmd-key&lt;/kbd&gt; presses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Undo and redo&#xA;nnoremap &amp;lt;D-Z&amp;gt; u&#xA;nnoremap &amp;lt;D-S-Z&amp;gt; &amp;lt;C-R&amp;gt;&#xA;# Navigate back and forwards&#xA;nnoremap &amp;lt;D-[&amp;gt; &amp;lt;C-O&amp;gt;&#xA;nnoremap &amp;lt;D-]&amp;gt; &amp;lt;C-I&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know if these will work for vim in a terminal.  They might.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2020-04-18T18:26:36.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24678" PostTypeId="1" CreationDate="2020-04-18T21:33:52.797" Score="0" ViewCount="1038" Body="&lt;p&gt;I'm trying to set up MathJax to work with vimwiki. According to the manual:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;using the MathJax server for rendering (needs an internet connection). Add to your HTML template the following line:&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot;&amp;gt;&amp;lt;/script&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which I did: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&amp;gt;&#xA;&amp;lt;html&amp;gt;&#xA;&amp;lt;head&amp;gt;&#xA;        &amp;lt;title&amp;gt;%title%&amp;lt;/title&amp;gt;&#xA;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/config/TeX-AMS-MML_HTMLorMML.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&#xA;    &amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=%encoding%&quot;&amp;gt;&#xA;&amp;lt;/head&amp;gt;&#xA;&amp;lt;body&amp;gt;&#xA;    %content%&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it didn't work. MathJax equations don't render on my browser, they show up like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\(\frac {1} {1 + \alpha} \)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20443" LastActivityDate="2022-11-13T19:54:36.090" Title="Vimwiki: Setting up mathjax" Tags="|plugin-vimwiki|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24679" PostTypeId="1" CreationDate="2020-04-18T22:00:31.777" Score="2" ViewCount="34" Body="&lt;p&gt;I have a percent sign in my viminfo string, so my buffer list is saved when I exit vim, and restored when I restart.  When I start vim with a filename argument, the buffer list isn't restored, which is what is described in the vim help.  However, it's still saved when I exit, which overwrites my longer buffer list.  This seems strange behavior.  Is there a way to configure vim so I don't lose my saved buffer list when I start vim with a filename argument?  The best workaround I can think of is to conditionally add % to my viminfo string in vimrc, when there is no filename argument.&lt;/p&gt;&#xA;" OwnerUserId="29049" LastActivityDate="2020-04-18T22:00:31.777" Title="Don't want buffer list to be overwritten when I launch vim with filename argument" Tags="|viminfo|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24681" PostTypeId="1" AcceptedAnswerId="24682" CreationDate="2020-04-18T23:38:28.410" Score="1" ViewCount="321" Body="&lt;p&gt;I apologise if this was asked before, but I couldn't find anything similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to write a simple command to jump to a test file, using the current file name. I have managed to achieve this using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command Spec :find %:r.spec.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If my current buffer name is &lt;code&gt;foo.js&lt;/code&gt; this will try to jump to &lt;code&gt;foo.spec.js&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is some projects use the &lt;code&gt;*.test.js&lt;/code&gt; extension therefore I would like to be able to look for both and to jump to either available. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command Spec :find %:r.(spec|test).js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this does not work. I have tried escaping the atom but vim then just treats it as a literal. Is there any way to achieve this &lt;strong&gt;without any plugin&lt;/strong&gt;? I should mention that using bash commands are also not an option since I use Windows quite a lot as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, if multiple files are found, I would get a wildmenu, but I'd be happy with opening the first found too.&lt;/p&gt;&#xA;" OwnerUserId="28745" LastActivityDate="2020-04-20T18:43:18.770" Title=":find multiple file names" Tags="|find|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24682" PostTypeId="2" ParentId="24681" CreationDate="2020-04-19T01:01:23.083" Score="2" Body="&lt;p&gt;In vim globs (like those used in find), alternation between two words can be done using the &lt;code&gt;{a,b}&lt;/code&gt; syntax.  This will work interactively, presenting a wildmenu, if you press tab.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:find %:r.{spec,test}.js&amp;lt;TAB&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, it won't work from a &quot;Spec&quot; command wrapper, since &lt;code&gt;:find&lt;/code&gt; does not tolerate multiple matches.  Here is one solution using &lt;code&gt;glob()&lt;/code&gt; and &lt;code&gt;inputlist()&lt;/code&gt;.  Typing &lt;code&gt;:Spec&lt;/code&gt; will present a choice if there are multiple matches.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; function! Spec(bang)&#xA;    let files = glob('%:r.{spec,test}.js', 1, 1)&#xA;    if empty(files)&#xA;        echohl Error | echo 'nothing found' | echohl None&#xA;        return&#xA;    endif&#xA;    if len(files) == 1&#xA;        execute 'edit' . a:bang files[0]&#xA;        return&#xA;    endif&#xA;&#xA;    let choice = inputlist(map(copy(files), 'v:key+1 . &quot;: &quot; . v:val'))&#xA;    if choice &amp;gt; 0&#xA;        execute 'edit' . a:bang files[choice-1]&#xA;    endif&#xA;endfunction&#xA;&#xA;command! -bang Spec :call Spec('&amp;lt;bang&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2020-04-20T18:43:18.770" LastActivityDate="2020-04-20T18:43:18.770" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="24683" PostTypeId="1" CreationDate="2020-04-19T01:34:54.470" Score="4" ViewCount="1051" Body="&lt;p&gt;Is there a way to enable autocomplete for writing in English? For example, if I write &lt;code&gt;giv&lt;/code&gt;, I want Vim to automatically suggest &lt;code&gt;give&lt;/code&gt;, &lt;code&gt;given&lt;/code&gt;, &lt;code&gt;gives&lt;/code&gt;, &lt;code&gt;giving&lt;/code&gt;, &lt;code&gt;giveaway&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Emacs, this is easy to enable when using the company-mode package (&lt;a href=&quot;https://emacs.stackexchange.com/questions/18304/optimal-settings-for-auto-complete-for-writing-papers-prose-in-natural-languag&quot;&gt;source&lt;/a&gt;). How can I do this in Vim?&lt;/p&gt;&#xA;" OwnerUserId="19712" LastActivityDate="2021-03-04T17:23:58.047" Title="How to enable autocomplete for writing in English?" Tags="|autocompletion|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24684" PostTypeId="2" ParentId="24683" CreationDate="2020-04-19T03:11:26.040" Score="2" Body="&lt;p&gt;Yes, you can use the &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;X&lt;/kbd&gt;, &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;K&lt;/kbd&gt; sequence to initiate completion from keywords in a dictionary. See &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-X_CTRL-K&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help i_CTRL-X_CTRL-K&lt;/code&gt;&lt;/a&gt; for an entry point to configuring and using this feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps the best way to enable this feature is to &lt;a href=&quot;https://vimhelp.org/spell.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;enable spell checking&lt;/a&gt;, since Vim is able to use the spell checking dictionaries (typically shipped with the Vim runtimes) to complete keywords with the default setting. Typically all you need to do is issue a &lt;code&gt;:set spell&lt;/code&gt; command to enable spell checking and that will unlock keyword completion with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative is to set the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27dictionary%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'dictionary'&lt;/code&gt;&lt;/a&gt; option to point to one or more files (such as &lt;code&gt;/usr/share/dict/words&lt;/code&gt; on Linux and other Unix-like systems) containing lists of words to use for keyword completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also combine both options of spell checking dictionaries and word list files by including a special literal &lt;code&gt;spell&lt;/code&gt; as part of the list of paths in the &lt;code&gt;'dictionary'&lt;/code&gt; setting. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set dictionary=spell,/usr/share/dict/words&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One more advantage of leveraging the spell checking system for dictionary keyword completion is that you have a handy way of adding new acceptable completion targets, by simply marking them as good words for the spell checking system, which you can easily do with the &lt;a href=&quot;https://vimhelp.org/spell.txt.html#zg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;zg&lt;/code&gt;&lt;/a&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-19T03:11:26.040" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24685" PostTypeId="2" ParentId="24675" CreationDate="2020-04-19T05:52:55.197" Score="1" Body="&lt;p&gt;I tried it manually and the last line gave me this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E254: Cannot allocate color s:splitcolor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the &lt;code&gt;guifg&lt;/code&gt; value isn't set to anything. (The &lt;code&gt;guibg&lt;/code&gt; value &lt;em&gt;is&lt;/em&gt; set so that may explain why you noticed some change to the VertSplit appearance.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that this command doesn't evaluate the parameter values unlike, for example, the way &lt;code&gt;:echo s:splitcolor&lt;/code&gt; will evaluate unrecognized symbols.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Scenarios like this are almost always solved by using &lt;code&gt;:exe&lt;/code&gt; which will evaluate everything passed to it before executing the result.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe 'highlight! VertSplit guibg=bg guifg=' . s:splitcolor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-04-19T08:43:33.660" LastActivityDate="2020-04-19T08:43:33.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24686" PostTypeId="1" AcceptedAnswerId="24703" CreationDate="2020-04-19T08:29:43.843" Score="2" ViewCount="96" Body="&lt;h2&gt;tl;dr&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Are there any undesirable side-effects connected to the use of &lt;code&gt;:highlight! default link {from-group} {to-group}&lt;/code&gt; as compared to &lt;code&gt;:highlight default …&lt;/code&gt; that I should be aware of when editing/creating a syntax file?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;em&gt;Director's cut&lt;/em&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In the context of trying to understand how syntax highlighting works in Vim, I tend to have opened the syntax file for a given language and a sample of code written in that language, so that I can see the effects on the latter of editing the former simply by &lt;code&gt;sourcing&lt;/code&gt; my &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have seen that some type of edit is not reflected unless I open the file in another session of Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I changed this line in &lt;code&gt;sed.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi def link sedError       Error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi def link sedError       NONE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then &lt;code&gt;source&lt;/code&gt;d my &lt;code&gt;.vimrc&lt;/code&gt; in a flawed &lt;code&gt;file.sed&lt;/code&gt; I had open beside; I saw the &lt;code&gt;Error&lt;/code&gt; highlight disappear. This is what I expected. Then I restored the line above as it was, sourced my &lt;code&gt;.vimrc&lt;/code&gt; again, but the color did not come back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on what I read in &lt;code&gt;:h :hi-link&lt;/code&gt;, it seems I could simply add &lt;code&gt;!&lt;/code&gt; to the &lt;code&gt;hi&lt;/code&gt;light command; I have tried, and it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have observed that only &lt;code&gt;fortran.vim&lt;/code&gt; and &lt;code&gt;chicken.vim&lt;/code&gt; make links like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi! def link fortranTypeR       fortranType&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;whereas all other syntax files use something like this (from &lt;code&gt;cpp.vim&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi def link cppBoolean      Boolean&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;therefore I started suspecting that there could be something not advisable in using &lt;code&gt;hi!&lt;/code&gt; instead of &lt;code&gt;hi&lt;/code&gt; in this situation.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="6498" LastEditDate="2020-04-19T19:40:13.063" LastActivityDate="2020-04-20T09:01:27.247" Title="Any reason why one should avoid to force the linking of highlight groups in syntax files?" Tags="|syntax-highlighting|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24687" PostTypeId="1" AcceptedAnswerId="24690" CreationDate="2020-04-19T13:09:01.923" Score="3" ViewCount="106" Body="&lt;h3&gt;Situation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Recently I was investigating the behaviour of word motions in vim and to me it seems like &lt;code&gt;ge&lt;/code&gt; is grossly inconsistent with the other 3. Here is an example with &lt;code&gt;^&lt;/code&gt; showing the cursor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;word1 word2        de:  wo word2         dw:   woword2&#xA;  ^&#xA;&#xA;word1 word2        db:  word1 rd2        dge:  wordd2&#xA;        ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to me that &lt;code&gt;dge&lt;/code&gt; is inconsistent in 2 ways:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It deletes the character the cursor is on (inconsistent with db)&lt;/li&gt;&#xA;&lt;li&gt;It deletes the last character of the previous word (inconsistent with dw)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h3&gt;What I tried&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The following fixed the issue with leaving the character the cursor was on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap ge vge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the following fixes the issue with leaving the last character on the previous word:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap &amp;lt;expr&amp;gt; ge &quot;:&amp;lt;c-u&amp;gt;normal! gel&amp;lt;cr&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I cannot find a convenient way to combine these two behaviours.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Question&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;How can I remap &lt;code&gt;ge&lt;/code&gt; so it behaves this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;word1 word2        dge:  word1rd2&#xA;        ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, maybe my perception about &lt;code&gt;ge&lt;/code&gt; being inconsistent is wrong?&lt;br&gt;&#xA;Would be very interested in hearing comments disputing that.&lt;/p&gt;&#xA;" OwnerUserId="307" LastEditorUserId="18609" LastEditDate="2020-04-19T14:10:32.777" LastActivityDate="2020-04-19T20:44:46.613" Title="custom mapping to make dge consistent with dw, de, and db?" Tags="|key-bindings|cursor-motions|keyword|operator-pending-mode|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24688" PostTypeId="5" CreationDate="2020-04-19T13:20:58.723" Score="0" Body="&lt;h1&gt;Definition&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;After a user types an operator command Vim will be waiting for a motion or a text-object. This state is called &quot;operator-pending mode.&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                *Operator-pending* *Operator-pending-mode*&#xA;Operator-pending mode   This is like Normal mode, but after an operator&#xA;                        command has started, and Vim is waiting for a {motion}&#xA;                        to specify the text that the operator will work on.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Example of operator-pending mode&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;daw&lt;/code&gt; in Normal mode will delete the word under the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;d&lt;/code&gt; is an operator and &lt;code&gt;aw&lt;/code&gt; is a text object that specifies where the operator will be applied. Operator-pending mode is entered after typing the &lt;code&gt;d&lt;/code&gt; command but before specifying the text object &lt;code&gt;aw&lt;/code&gt; for the operator to work on.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Use this tag if...&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you have questions about operator-pending mode&lt;/li&gt;&#xA;&lt;li&gt;you have questions about creating operator-pending mode mappings (&lt;a href=&quot;/questions/tagged/key-bindings&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;key-bindings&amp;#39;&quot; rel=&quot;tag&quot;&gt;key-bindings&lt;/a&gt; will usually also be appropriate)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Do not use this tag if...&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you have questions about operators&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="307" LastEditorUserId="10604" LastEditDate="2020-04-19T14:35:42.050" LastActivityDate="2020-04-19T14:35:42.050" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24689" PostTypeId="4" CreationDate="2020-04-19T13:20:58.723" Score="0" Body="For questions about operator-pending mode, which is the mode after triggering an operator but before specifying a motion or text-object to operate on." OwnerUserId="307" LastEditorUserId="10604" LastEditDate="2020-04-19T14:30:08.980" LastActivityDate="2020-04-19T14:30:08.980" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24690" PostTypeId="2" ParentId="24687" CreationDate="2020-04-19T13:57:59.480" Score="4" Body="&lt;p&gt;One easy way to fix &lt;code&gt;ge&lt;/code&gt; is to make a backwards search:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap ge :call search('\&amp;gt;', 'b')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use a more complex regex if you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, you could also move to the right position using the &lt;code&gt;normal&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onoremap ge :normal!ge&amp;lt;SPACE&amp;gt;&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Or, with working counts (version from @Karolis_Koncevičius):&#xA;&#xA;onoremap ge :execute &quot;normal! &quot; . v:count1 . &quot;ge&amp;lt;space&amp;gt;&quot;&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that we use &lt;code&gt;&amp;lt;SPACE&amp;gt;&lt;/code&gt; here, and not &lt;code&gt;l&lt;/code&gt; or &lt;code&gt;&amp;lt;RIGHT&amp;gt;&lt;/code&gt;, because &lt;code&gt;&amp;lt;SPACE&amp;gt;&lt;/code&gt; will allow us to get back on the right line if we use &lt;code&gt;dge&lt;/code&gt; on the fist word of the line. &lt;strong&gt;Disclaimer&lt;/strong&gt; - This breaks if the line above ends with whitespaces.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As you underline in the comments, those 2 functions can break in some cases. For a foolproof &lt;code&gt;ge&lt;/code&gt;, I see no other way than to write a small function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! BetterGE()&#xA;    let curline = line('.')&#xA;    normal! gel&#xA;&#xA;    if line('.') != curline&#xA;        call setpos('.', [0, curline, 1, 0])&#xA;    endif&#xA;endfunction&#xA;&#xA;onoremap ge :call BetterGE()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function will call the default &lt;code&gt;ge&lt;/code&gt;, move one character to the right, and if the line is not the same as the initial one, we bring back the cursor on the 1st column of the initial line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This doesn't seem to break in any of the mentioned cases.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;ge&lt;/code&gt; motion seem inconsistent indeed, but it makes sense: it's an inclusive character-wise motion, which means that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When inclusive, the start and end position of the motion are included in the operation.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(from &lt;code&gt;:h inclusive&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that's why the character under the cursor and the last character of the previous word are deleted&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, as &lt;a href=&quot;https://vi.stackexchange.com/users/18609/filbranden&quot;&gt;@filbranden&lt;/a&gt; noted:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;exclusive motions are always exclusive to the right, not to the direction the motion is going. That's why db being an exclusive motion excludes the character the cursor was on... And that's why ge isn't an exclusive motion, because exclusive-to-the-left would make sense, but the regular exclusive doesn't make as much sense&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="18609" LastEditDate="2020-04-19T20:44:46.613" LastActivityDate="2020-04-19T20:44:46.613" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="24691" PostTypeId="1" CreationDate="2020-04-19T17:57:47.347" Score="1" ViewCount="769" Body="&lt;p&gt;While using VimWiki, I linked to a file on my computer using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[[file:/path/to/file.py]]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I hit enter, it opens the file with VSCode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already when to the file in Finder, clicked 'Get Info' and selected 'Open with:' -&gt; 'Other' but 'Vim' is not an option there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there are to have a file link in VimWiki and when I hit enter have it open that python inside of vim?&lt;/p&gt;&#xA;" OwnerUserId="29062" LastActivityDate="2020-04-19T17:57:47.347" Title="How to make VimWiki open file directly in vim instead of VSCode" Tags="|plugin-vimwiki|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24692" PostTypeId="2" ParentId="24681" CreationDate="2020-04-19T18:52:41.587" Score="1" Body="&lt;p&gt;One possible simple approach is to use a &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Atry&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:try&lt;/code&gt;&lt;/a&gt; block to catch an error while trying the &lt;code&gt;*.spec.js&lt;/code&gt; filename and then fallback to the &lt;code&gt;*.test.js&lt;/code&gt; filename if that fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps something as simple as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Spec try | find %:t:r.spec.js | catch /^Vim(find):E345:/ | find %:t:r.test.js | endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note I used &lt;code&gt;%:t:r&lt;/code&gt; to use just the basename of the file, so that &lt;code&gt;:find&lt;/code&gt; gets a filename only and will use &lt;code&gt;'path'&lt;/code&gt; to locate it. That's not the case if the original file was in a subdirectory and you used &lt;code&gt;%:r&lt;/code&gt;, in which case it would only look for the &lt;code&gt;*.spec.js&lt;/code&gt; file in the same directory as the original file.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One small issue with this solution is that, when neither file exists, it will only complain about the latter &lt;code&gt;*.test.js&lt;/code&gt;, which might give the user the wrong impression that that's the preferred filename...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can fix that by using a second &lt;code&gt;:try&lt;/code&gt; block and issuing a more appropriate error message in that case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command gets longer already, so I'll start breaking lines for clarity:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Spec&#xA;  \   try&#xA;  \ |   find %:t:r.spec.js&#xA;  \ | catch /^Vim(find):E345:/&#xA;  \ |   try&#xA;  \ |     find %:t:r.test.js&#xA;  \ |   catch /^Vim(find):E345:/&#xA;  \ |     echoerr &quot;E345: Can't find file \&quot;&quot;.expand(&quot;%:t:r&quot;).&quot;.spec.js\&quot; or \&quot;&quot;.expand(&quot;%:t:r&quot;).&quot;.test.js\&quot; in path&quot;&#xA;  \ |   endtry&#xA;  \ | endtry&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At this point it already makes sense to break this out into a function, and have the &lt;code&gt;Spec&lt;/code&gt; command call the function...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use a function, you might want to consider using &lt;a href=&quot;https://vimhelp.org/eval.txt.html#findfile%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;findfile()&lt;/code&gt;&lt;/a&gt; to locate an existing file, possibly use a list and a loop to handle possible extensions in a more flexible way, perhaps consider creating or offering to create the file if it doesn't exist...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then, you're already halfway through writing your own plug-in for this feature, so you might consider adopting one. The &lt;a href=&quot;https://github.com/tpope/vim-projectionist&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-projectionist&lt;/a&gt; plug-in by Tim Pope is a great plug-in for jumping between related files in a project and it's quite flexible so you can configure it to match the paths in your project.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-19T19:29:42.660" LastActivityDate="2020-04-19T19:29:42.660" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24693" PostTypeId="1" AcceptedAnswerId="24716" CreationDate="2020-04-20T00:08:12.467" Score="1" ViewCount="236" Body="&lt;p&gt;I'm working with python 2.7 scripts that I need to update to python 3.8 while maintaining backwards compatibility. &lt;a href=&quot;https://github.com/nvie/vim-flake8&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-flake8&lt;/a&gt; on my mac has been working great up until now for python 2.7, but I can't find a why to easily swap between python 2 and 3 on the fly. This is because Flake8 is &quot;smart&quot; about whether to use 2 or 3 based on which one runs it - there doesn't appear to be an option/argument. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I tell vim-flake8 which python version to evaluate my scripts as?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I would like to have two hotkeys (F2, F3) that allow me to run either, similar to 'python -m flake8' or 'python3 -m flake8'. I could write this directly into my vimrc, but the flake8 plugin has some really nice features to help quickly make fixes. I could not find any mention of swapping python versions on the vim-flake8 github.&lt;/p&gt;&#xA;" OwnerUserId="28955" LastActivityDate="2020-04-21T07:23:09.383" Title="How to easily switch flake8 between python 2 and 3" Tags="|filetype-python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24694" PostTypeId="2" ParentId="24493" CreationDate="2020-04-20T03:06:34.493" Score="2" Body="&lt;h1&gt;With vim only&lt;/h1&gt;&#xA;&lt;p&gt;There's a few options to make navigation between files less tedious in vanilla vim.&lt;/p&gt;&#xA;&lt;p&gt;First, you probably want to have &lt;code&gt;set switchbuf=useopen&lt;/code&gt; in your vimrc (&lt;code&gt;:h 'switchbuf'&lt;/code&gt;) to reuse a split, instead of opening the buffer in the current split.&lt;/p&gt;&#xA;&lt;p&gt;If you have the buffer number in &lt;code&gt;'statusline'&lt;/code&gt; (i.e &lt;code&gt;%n&lt;/code&gt;), you can then easily switch to a split by number with &lt;code&gt;:sbuffer buffnumber&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This will also work if you give a unique pattern from the name. If you are in the split 'foo' and have two more splits 'bar' and 'baz', &lt;code&gt;:sbuffer az&lt;/code&gt; will switch to the 'baz' split.&lt;/p&gt;&#xA;&lt;p&gt;You can have a mapping to make it easier: &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :sbuffer &lt;/code&gt; (there's a space at the end).&lt;/p&gt;&#xA;&lt;p&gt;Also, those mappings help switch to different splits (&lt;code&gt;:h windows&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;t&lt;/code&gt; -&amp;gt; top left split&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;b&lt;/code&gt; -&amp;gt; bottom right split&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;p&lt;/code&gt; -&amp;gt; last used split&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1&gt;With FZF&lt;/h1&gt;&#xA;&lt;p&gt;Besides, could use &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf.vim&lt;/a&gt; plugin (requires &lt;a href=&quot;https://github.com/junegunn/fzf/wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf&lt;/a&gt;) and its &lt;code&gt;:Buffers&lt;/code&gt; command.&lt;/p&gt;&#xA;&lt;p&gt;Similarly to &lt;code&gt;switchbuf=useopen&lt;/code&gt;, you'll want &lt;code&gt;let g:fzf_buffers_jump = 1&lt;/code&gt; in your vimrc to reuse an open split.&lt;/p&gt;&#xA;&lt;p&gt;The command will show a list of buffers which you can strip down with fuzzy search, and navigate with &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-k&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; will then switch to the split if already open, or else use the current one. &lt;code&gt;&amp;lt;c-v&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;c-t&amp;gt;&lt;/code&gt; will open the buffer in a new vertical split, horizontal split or tab.&lt;/p&gt;&#xA;&lt;p&gt;You could have a mapping to launch &lt;code&gt;:Buffers&lt;/code&gt; like &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :Buffers&amp;lt;cr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-04-28T09:47:17.913" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24695" PostTypeId="1" AcceptedAnswerId="24701" CreationDate="2020-04-20T03:53:45.920" Score="0" ViewCount="167" Body="&lt;p&gt;I wanted to be able to move/rename a currently open file using netrw. The typical concerns are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Closing the old buffer&lt;/li&gt;&#xA;&lt;li&gt;Actually moving to preserve file attributes (so no :saveas)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm aware of some of the plugins and custom functions for this purpose but I wanted to try it using netrw in a single keybind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I have so far:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;Sm :argadd&amp;lt;CR&amp;gt;:enew&amp;lt;bar&amp;gt;bd #&amp;lt;CR&amp;gt;:1argdo Explore&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This successfully adds the current file to arglist, opens temporary new buffer, deletes the previous old file buffer, and opens netrw to the dir of the file in arglist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there, what I have to do manually is &lt;code&gt;mA&lt;/code&gt; to mark the file from the arglist, then &lt;code&gt;R&lt;/code&gt; to move/rename. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I append the last two key-presses to the original mapping? The following does not work for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;Sm :argadd&amp;lt;CR&amp;gt;:enew&amp;lt;bar&amp;gt;bd #&amp;lt;CR&amp;gt;:1argdo Explore&amp;lt;CR&amp;gt;mAR&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once netrw is entered, the key-presses seem to stop.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;Sm :let fn=expand('%:t')&amp;lt;bar&amp;gt;enew&amp;lt;bar&amp;gt;bw #&amp;lt;bar&amp;gt;Explore %:p:h&amp;lt;bar&amp;gt;call search(expand(fn))&amp;lt;bar&amp;gt;redraw!&amp;lt;CR&amp;gt;mfR&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;nmap&lt;/code&gt; allowed the key-presses to continue&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;redraw!&lt;/code&gt; allowed me to actually see &lt;code&gt;netrw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;added &lt;code&gt;enew&amp;lt;bar&amp;gt;bw #&amp;lt;bar&amp;gt;&lt;/code&gt; to delete the old buffer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="28987" LastEditorUserId="28987" LastEditDate="2020-04-20T21:32:07.980" LastActivityDate="2020-04-20T21:32:07.980" Title="Keybind for moving a file using netrw from outside of netrw" Tags="|vimrc|key-bindings|netrw|original-vim|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24696" PostTypeId="2" ParentId="24628" CreationDate="2020-04-20T06:43:37.267" Score="2" Body="&lt;p&gt;This is fun:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com -nargs=+ Type call s:type(&amp;lt;q-args&amp;gt;)&#xA;&#xA;let g:type_interval='200ms'&#xA;&#xA;function s:type(cmd) abort&#xA;&#xA;  &quot; spawn a timer_start for every char, the inner lambda call feedkeys with&#xA;  &quot; captured current char.&#xA;  call map(split(a:cmd, '\zs'),&#xA;        \ { i,v -&amp;gt; timer_start( g:type_interval * i, { t -&amp;gt; feedkeys(v) } ) })&#xA;endfunction&#xA;&#xA;exe &quot;Type Gohello\&amp;lt;esc&amp;gt;oworld\&amp;lt;esc&amp;gt;ciwvim\&amp;lt;esc&amp;gt;dddd&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;source it, it will jump to end of file, typing &lt;code&gt;hello world&lt;/code&gt;, then change &lt;code&gt;world&lt;/code&gt; to &lt;code&gt;vim&lt;/code&gt;, then delete lines one by one. If you type in the middle, you will mess it, I hope that's not a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works like every character is typed one by one, it doesn't care about&#xA;&lt;code&gt;mapping delay&lt;/code&gt; and &lt;code&gt;keycode delay&lt;/code&gt;, something like this will never wrok:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; turn on timeout, make sure timeoutlen is greater than type interval&#xA;set timeout&#xA;let &amp;amp;timeoutlen=1000&#xA;let g:type_interval='100ms'&#xA;&#xA;nnoremap abc dd&#xA;Type abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;a&lt;/code&gt; never get it's &lt;code&gt;bc&lt;/code&gt;, can't tell why.  It also breaks if you use multi&#xA;bytes keycodes (such as &lt;code&gt;&quot;\&amp;lt;c-right&amp;gt;&quot;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update to address comment&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to place the command in a register and hide the execution part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @x = &quot;Type Gohello\&amp;lt;esc&amp;gt;oworld\&amp;lt;esc&amp;gt;ciwvim\&amp;lt;esc&amp;gt;dddd&quot;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;x :exe @x&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To support abort&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can't use command to abort, the animation will mess our typing, we can only use single key map to do it, we need to create map in all mods:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap &amp;lt;f4&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;:call timer_stopall()&amp;lt;cr&amp;gt;&#xA;noremap! &amp;lt;f4&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;:call timer_stopall()&amp;lt;cr&amp;gt;&#xA;tnoremap &amp;lt;f4&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-n&amp;gt;:call timer_stopall()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;timer_stopall()&lt;/code&gt; for simplicity here. If you want to be precise, you can record it in the &lt;code&gt;s:type&lt;/code&gt; and loop them one by one to stop it.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-04-20T11:21:58.987" LastActivityDate="2020-04-20T11:21:58.987" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="24697" PostTypeId="2" ParentId="14663" CreationDate="2020-04-20T07:02:33.860" Score="0" Body="&lt;p&gt;I've been experimenting with using Vim keyboard bindings for OneNote 2016 using this library: &lt;a href=&quot;https://github.com/rcmdnk/vim_ahk&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/rcmdnk/vim_ahk&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Blogged about it here: &lt;a href=&quot;https://davemateer.com/2020/04/10/OneNote-with-Vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://davemateer.com/2020/04/10/OneNote-with-Vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is so nice to be able to edit in OneNote using Vim bindings!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 23rd April 2020&lt;/strong&gt;&#xA;Thanks to @D.Ben Knoble for pointing out that I really should answer this more fully. So this isn't really an answer to the question but rather a thought that OneNote 2016 (which is now supported again) with Vim bindings work quite well:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use Autohotkey&lt;/li&gt;&#xA;&lt;li&gt;Use bindings to give a Vim like experience&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;a href=&quot;https://github.com/ililim/dual-key-remap&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ililim/dual-key-remap&lt;/a&gt; to map the caps-lock key to escape (which is a C library, and I found preferable to another Autohotkey binding)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="20404" LastEditorUserId="20404" LastEditDate="2020-04-23T13:11:40.320" LastActivityDate="2020-04-23T13:11:40.320" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24698" PostTypeId="1" AcceptedAnswerId="24699" CreationDate="2020-04-20T08:35:34.790" Score="1" ViewCount="118" Body="&lt;p&gt;I'm using vim 8 with YCM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When YCM finds an error, a symbol will popup as below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7amyp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7amyp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you see, there is a symbol before line &lt;code&gt;26&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that it will make the whole window move to right a little to get some spaces to show the symbol &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is if it is possible to avoid this move?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need this because vim 8 runs based on a kind of async mechanism. So if I type fast, the error symbol will appear and disappear alternately and this gonna make the window sway.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-04-20T08:48:34.837" Title="How to leave spaces for error symbols" Tags="|plugin-you-complete-me|vim8|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24699" PostTypeId="2" ParentId="24698" CreationDate="2020-04-20T08:48:34.837" Score="1" Body="&lt;p&gt;Those symbols are displayed in what's called the &lt;em&gt;signcolumn&lt;/em&gt;. Fortunately, there's some degree of control over it using the &lt;code&gt;'signcolumn'&lt;/code&gt; setting. Available values will cause the column to be shown:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   &quot;auto&quot;       only when there is a sign to display&#xA;   &quot;no&quot;         never&#xA;   &quot;yes&quot;        always&#xA;   &quot;number&quot;     display signs in the 'number' column. If the number&#xA;                column is not present, then behaves like &quot;auto&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default is &quot;auto&quot; which results in the behavior you're seeing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try setting it to &quot;yes&quot; (&lt;code&gt;:set signcolumn=yes&lt;/code&gt;) or, if you don't even care to see the symbols, &quot;no&quot;. Both will stop transient symbols from making your text jump around.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastActivityDate="2020-04-20T08:48:34.837" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24700" PostTypeId="1" AcceptedAnswerId="24702" CreationDate="2020-04-20T08:51:10.257" Score="2" ViewCount="131" Body="&lt;p&gt;Sometimes it is possible to accidentally hit some numeric keys. I have a lot of binds and for most of them there is nothing to be gained by allowing them to repeat with a prefix. Let's suppose that there are some commands that can be semi-disastrous (ones that make &lt;code&gt;tmux&lt;/code&gt; calls) if they get repeated. Is there a way to prevent this behavior for a mapping?&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="390" LastEditDate="2020-04-20T16:08:57.073" LastActivityDate="2020-04-20T16:08:57.073" Title="Is it possible to prevent a mapping from being repeated with a prefix number (vim range)?" Tags="|repeated-commands|movement|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24701" PostTypeId="2" ParentId="24695" CreationDate="2020-04-20T08:55:28.087" Score="1" Body="&lt;p&gt;I didn't follow the same approach as you did to get to the file, but I ran into the same problem. For me, a simple &lt;code&gt;redraw!&lt;/code&gt; made it work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my final command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;LEADER&amp;gt;Sm :let fn=expand('%:t') &amp;lt;BAR&amp;gt; Explore %:p:h &amp;lt;BAR&amp;gt; call search(fn) &amp;lt;BAR&amp;gt; redraw!&amp;lt;CR&amp;gt;mfR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="27331" LastEditDate="2020-04-20T21:15:33.633" LastActivityDate="2020-04-20T21:15:33.633" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24702" PostTypeId="2" ParentId="24700" CreationDate="2020-04-20T09:01:08.013" Score="2" Body="&lt;p&gt;If you're using the command line, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;LEADER&amp;gt;t :!echo &quot;Yay&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(just an example)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add &lt;code&gt;&amp;lt;C-u&amp;gt;&lt;/code&gt; after the &lt;code&gt;:&lt;/code&gt; to erase all undesired characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;LEADER&amp;gt;t :&amp;lt;C-u&amp;gt;!echo &quot;Yay&quot;&amp;lt;CR&amp;gt;&#xA;&#xA;&quot; Also works with `&amp;lt;CMD&amp;gt;` in neovim:&#xA;&#xA;nnoremap &amp;lt;LEADER&amp;gt;t &amp;lt;CMD&amp;gt;!echo &quot;Yay&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What happens is that by default, when you hit numbers followed by &lt;code&gt;:&lt;/code&gt;, a &lt;strong&gt;range&lt;/strong&gt; will automatically be added to your command by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A range basically allows you to run a command on multiple lines at once, For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,5s/this/that/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Executes the substitute command on the lines 1 to 5.  Line 5 is included.&#xA;The range is always placed before the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;above example from the vim doc&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To learn more about ranges:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help 10.3&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help cmdline-ranges&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="27331" LastEditDate="2020-04-20T12:06:43.880" LastActivityDate="2020-04-20T12:06:43.880" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24703" PostTypeId="2" ParentId="24686" CreationDate="2020-04-20T09:01:27.247" Score="1" Body="&lt;p&gt;I suspect the reason not all syntax scripts use &lt;code&gt;!&lt;/code&gt; when linking highlight definitions is that users could have a preferred way to show certain things in certain ways, and declare these on their &lt;code&gt;.vimrc&lt;/code&gt;. Syntax scripts are loaded when a &lt;code&gt;FileType&lt;/code&gt; event occurs, i.e. after the &lt;code&gt;.vimrc&lt;/code&gt; file is sourced, so if the syntax script uses &lt;code&gt;hi! link&lt;/code&gt; it doesn't matter that the user had something like &lt;code&gt;hi! def link cppBoolean Function&lt;/code&gt;, the former will overwrite the latter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often switch colour schemes, and I have seen weird results because of the lack of &lt;code&gt;!&lt;/code&gt; in links (and also lack of &lt;code&gt;gui&lt;/code&gt; and &lt;code&gt;cterm&lt;/code&gt; defaults), so I think the lack of &lt;code&gt;!&lt;/code&gt; should be considered carefully when defining a highlight. If users really want to overwrite some link, they can define them (with &lt;code&gt;!&lt;/code&gt;) in &lt;a href=&quot;https://vi.stackexchange.com/questions/10035/how-can-i-make-highlighting-commands-in-vimrc-take-effect-immediately-with-vim/10036#10036&quot;&gt;scripts in their &lt;code&gt;after&lt;/code&gt; directory&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-20T09:01:27.247" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24705" PostTypeId="1" CreationDate="2020-04-20T10:12:11.630" Score="1" ViewCount="59" Body="&lt;p&gt;A few days ago, accidentally, I create a shortcut/keys association and now I can't use the '&amp;lt;&gt;' key within Vim (outside of Vim, the key works just fine). That's a Spanish keyboard from which I can use all the other keys with its respective character/s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, when I press the key, it paste whatever text I have copied/selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been looking inside &lt;code&gt;:help index&lt;/code&gt;, &lt;code&gt;:verbose map&lt;/code&gt;, &lt;code&gt;/etc/vimrc&lt;/code&gt; and &lt;code&gt;~/.vimrc&lt;/code&gt;  for the association and I can't find it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where/how should I look for this? Any ideas about how to solve it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I have &lt;strong&gt;no&lt;/strong&gt; admin rights, I'm using linux Suse at work and my vim is vim72.&lt;/p&gt;&#xA;" OwnerUserId="29145" OwnerDisplayName="Mike" LastEditorUserId="11357" LastEditDate="2020-05-11T20:37:49.663" LastActivityDate="2020-05-11T20:37:49.663" Title="Undo a shortcut association, Vim" Tags="|key-bindings|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="24706" PostTypeId="1" CreationDate="2020-04-20T13:31:09.790" Score="0" ViewCount="19" Body="&lt;p&gt;I am trying to write a function that will only let me call nmap b when the cursor is not on the first column in the current window. This is to make b only work on the current line and encourage more efficient navigation bindings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a function which does what I want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function CurrentLineB() &#xA;  let column = getcurpos()[2]&#xA; echo column&#xA; if column != 1&#xA;   normal b%&#xA; endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I call it with &lt;code&gt;:call CurrentLineB()&lt;/code&gt; without binding it to &lt;code&gt;b&lt;/code&gt;, it works as expected. When I map the function with &lt;code&gt;nnoremap b :call CurrentLineB()&lt;/code&gt; the function keeps recurring without exiting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I avoid this recursion, and make the function work as it did when it was not bound to b?&lt;/p&gt;&#xA;" OwnerUserId="29074" LastActivityDate="2020-04-20T14:17:36.477" Title="Binding a function which contains the movement command 'b' to 'nmap b'" Tags="|functions|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24707" PostTypeId="2" ParentId="24706" CreationDate="2020-04-20T14:17:36.477" Score="2" Body="&lt;p&gt;The issue with your function is that you're using plain &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Anormal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;normal&lt;/code&gt;&lt;/a&gt;, when you need &lt;code&gt;normal!&lt;/code&gt; to make it non-recursive, which you need to ignore the &lt;code&gt;b&lt;/code&gt; mapping you created. That should be enough to fix the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But a simpler way to implement what you're trying to accomplish is to use an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping and the ternary operator, to expand to &lt;code&gt;b&lt;/code&gt; when on a column after 1, or to an empty string otherwise.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; b col('.') &amp;gt; 1 ? 'b' : ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also used &lt;a href=&quot;https://vimhelp.org/eval.txt.html#col%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;col()&lt;/code&gt;&lt;/a&gt;, which is a more direct way to get the column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this mapping still doesn't work if you have a line with indentation, in which case it will move to the preceding line when sitting on the first character of the first indented word, or on an indentation character other than the first... You can use &lt;code&gt;indent()&lt;/code&gt; to check for the indentation of the current line and compare it to &lt;code&gt;virtcol()&lt;/code&gt; (to properly account for tabs):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;expr&amp;gt; b virtcol('.') &amp;gt; indent('.') + 1 ? 'b' : ''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-20T14:17:36.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24708" PostTypeId="1" CreationDate="2020-04-20T15:12:40.807" Score="2" ViewCount="1966" Body="&lt;p&gt;Developing in nodejs I have a lot of custom module require statements in my javascript source files, like this one:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code&gt;//&#xA;// my nodejs program: &#xA;// path/to/projecthome/lib/someModule.js&#xA;//&#xA;const EMOJI = require('../lib/emoji')&#xA;const {rand} = require('../lib/random')&#xA;const {search} = require('../lib/search')&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In .vimrc, I have these settings (a TAB completion plugin and some &lt;code&gt;set complete&lt;/code&gt; settings):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-vim prettyprint-override&quot;&gt;&lt;code&gt;&quot; ~/.vimrc&#xA;&quot; TAB autocompletion&#xA;Plug 'ervandew/supertab'&#xA;&#xA;set complete=.,w,b,u,t,i,k&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I usually edit all files from project home (root) directory:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-bash prettyprint-override&quot;&gt;&lt;code&gt;$ cd path/to/projecthome/&#xA;$ vim lib/someModule.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When in inserting mode on above mentioned file, I would like to be assisted by an autocompletion of required filenames (possibly, with TAB completion, or with everything else). By example, inserting (during a file update) this line:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code&gt;// path/to/projecthome/lib/someModule.js&#xA;&#xA;                                     +---- cursor position, in insert mode&#xA;                                     v&#xA; const {search} = require('../lib/sea|')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;hitting &lt;kbd&gt;TAB&lt;/kbd&gt; after the word &lt;code&gt;sea&lt;/code&gt;, I would like to be completed in existing file &lt;code&gt;search.js&lt;/code&gt;&#xA;( with reference to: &lt;code&gt;../lib/search.js&lt;/code&gt;), but it's not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I know that is possible to have file name omni completion, using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;Ctrl-X&lt;/kbd&gt;&lt;kbd&gt;Ctrl-F&lt;/kbd&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;but also the omni completion seems to me not working in the above case (maybe because the relative pathnames?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is:&#xA;In general, TAB plugin a part, there is any way to have a file auto completion for (relative path) filenames? Maybe does exist a nodejs require completion plugin for that ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just discovered that with &lt;kbd&gt;Ctrl-X&lt;/kbd&gt;&lt;kbd&gt;Ctrl-F&lt;/kbd&gt; mode, relative paths are autocompleted! They will use the directory that Vim was launched from (PWD) as the root. So in the example above, autocompletion works if I put in vim command mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:cd lib&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="983" LastEditorUserId="983" LastEditDate="2020-04-20T18:01:56.067" LastActivityDate="2020-04-20T18:01:56.067" Title="How to (auto) complete filenames?" Tags="|autocompletion|filenames|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24709" PostTypeId="2" ParentId="7258" CreationDate="2020-04-20T17:31:36.703" Score="5" Body="&lt;p&gt;If you are using &lt;a href=&quot;https://github.com/plasticboy/vim-markdown&quot; rel=&quot;noreferrer&quot;&gt;plasticboy/vim-markdown&lt;/a&gt; plugin, put in your &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vim_markdown_conceal = 0&#xA;let g:vim_markdown_conceal_code_blocks = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29076" LastActivityDate="2020-04-20T17:31:36.703" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24710" PostTypeId="1" CreationDate="2020-04-20T18:36:16.547" Score="1" ViewCount="72" Body="&lt;p&gt;Can someone please tell me how to write a snippet which can emulate/simulate the behaviour of pressing the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; etc keys from keyboard?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following doesn't work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet undo &quot;just for argument's sake&quot;&#xA;&amp;lt;esc&amp;gt;&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;neither does this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet undo &quot;i want this to result in pressing the esc key&quot;&#xA;`!p&amp;lt;esc&amp;gt;`&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;nor this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet undo &quot;simulate esc behaviour&quot;&#xA;`!p snip.rv=&amp;lt;esc&amp;gt;`&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29070" LastActivityDate="2020-04-20T18:36:16.547" Title="UltiSnips snippet to emulate `&lt;Esc&gt;`" Tags="|plugin-ultisnips|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24711" PostTypeId="1" CreationDate="2020-04-20T20:00:02.297" Score="1" ViewCount="154" Body="&lt;p&gt;Any way to copy folds to a copied file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: file1 has several folds, now I create a new file &lt;code&gt;cp file2 newfile&lt;/code&gt;. &lt;code&gt;newfile&lt;/code&gt; doesn't have folds that I had created in vim, of course it won't as &lt;code&gt;cp&lt;/code&gt; and &lt;code&gt;vim&lt;/code&gt; are different commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way to copy folds of &lt;code&gt;file1&lt;/code&gt; to &lt;code&gt;newfile&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8092" LastActivityDate="2022-03-04T09:37:26.407" Title="vim - copy folds to a copied file" Tags="|folding|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24712" PostTypeId="6" CreationDate="2020-04-20T21:08:17.550" Score="0" Body="&lt;p&gt;Hi!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My name is Filipe, I live in Seattle and I would like to nominate myself for moderator at Vi &amp;amp; Vim Stack Exchange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm fairly new at Stack Exchange, have had an account for a bit over two years only. After a stint of very high activity on Unix &amp;amp; Linux, I found Vi &amp;amp; Vim and decided to make it my primary home here on Stack Exchange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though I have used Vim for 25 years or so, I have only recently started to become what I'd consider a Power User. I still have a fairly bare vimrc and actually feel pretty comfortable without any plug-ins installed (though of course I do have my favorite plug-ins, I think vim-surround and vim-unimpaired being the ones I miss the most when I don't have them.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I actually use the site and answer most questions on my phone, which makes for a lot of &lt;em&gt;&quot;fun&quot;&lt;/em&gt; testing and reproducing issues on DroidVim, URLencoding links to help topics on vimhelp (which is better than vimdoc) and I found out how Firefox on Android is much better than Chrome for browsing source on GitHub (when looking at plug-ins and Vim source code.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe I've had a positive impact on the site ever since I joined and I'd be happy to do more by becoming a moderator!&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-20T21:08:17.550" LastActivityDate="2020-04-20T21:08:17.550" CommentCount="7" CommunityOwnedDate="2020-04-20T21:08:17.550" ContentLicense="CC BY-SA 4.0" />
  <row Id="24713" PostTypeId="1" AcceptedAnswerId="24720" CreationDate="2020-04-21T00:47:47.627" Score="2" ViewCount="61" Body="&lt;p&gt;This behaviour seems a bit strange (&lt;code&gt;^&lt;/code&gt; is the cursor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoreabbrev @@t &amp;lt;esc&amp;gt;0&#xA;&#xA;what@@t&#xA;what&#xA; ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoreabbrev @@t &amp;lt;esc&amp;gt;0h&#xA;&#xA;what@@t&#xA;what&#xA;^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why using &lt;code&gt;0&lt;/code&gt; is not enough to put the cursor at the beginning of the line after abbreviation?&lt;/p&gt;&#xA;" OwnerUserId="307" LastActivityDate="2020-04-21T09:36:13.520" Title="Why does iabbrev end at second character, even after using 0 at the end of command chain?" Tags="|cursor|abbreviations|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24714" PostTypeId="6" CreationDate="2020-04-21T01:32:21.587" Score="0" Body="&lt;p&gt;My name is D. Ben Knoble. Everyone calls me Ben (though&#xA;&lt;a href=&quot;https://vi.stackexchange.com/questions/24419/locate-cursor-on-the-screen/24420?noredirect=1#comment43016_24420&quot;&gt;DBK&lt;/a&gt;&#xA;will do too). I'll tell you the story behind the name if you ask.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a community leader, I wish to be seen as someone&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;with the patience to consider relevant details before acting;&lt;/li&gt;&#xA;&lt;li&gt;with the self-awareness to know when I am in over my head (and to then ask for&#xA;guidance!);&lt;/li&gt;&#xA;&lt;li&gt;with the kindness of spirit to assume best intentions;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and someone&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;who upholds civil discourse and scholarly disagreement;&lt;/li&gt;&#xA;&lt;li&gt;who upholds the principle that every person be treated with the utmost&#xA;kindness and respect;&lt;/li&gt;&#xA;&lt;li&gt;who is an ally, support, and friend to all minority groups;&lt;/li&gt;&#xA;&lt;li&gt;who welcomes each member, new or old;&lt;/li&gt;&#xA;&lt;li&gt;and who upholds the community by upholding its members.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I spend my free time on Vi and Vim and the &lt;a href=&quot;/questions/tagged/vim&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;vim&amp;#39;&quot; rel=&quot;tag&quot;&gt;vim&lt;/a&gt; tag on StackOverflow. I&#xA;mostly deal in welcoming comments and edits now, since Filipe and a few others&#xA;are so quick to answer :) But I like to think I can still contribute my&#xA;expertise and leadership, where I always see myself as guide and obstacle&#xA;remover.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-04-21T01:32:21.587" LastActivityDate="2020-04-21T01:32:21.587" CommentCount="3" CommunityOwnedDate="2020-04-21T01:32:21.587" ContentLicense="CC BY-SA 4.0" />
  <row Id="24715" PostTypeId="2" ParentId="17218" CreationDate="2020-04-21T06:27:10.500" Score="2" Body="&lt;p&gt;If by move between buffers you mean -- doing it with a single window (no splits) then the only(?) option is to use autocommands. As an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup fold_params | au!&#xA;    au BufRead,BufNewFile *.py :setl fdm=indent | setl foldenable&#xA;    au BufRead,BufNewFile *.c :setl fdm=syntax | setl nofoldenable&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Options &lt;code&gt;foldmethod&lt;/code&gt; and &lt;code&gt;foldenable&lt;/code&gt; are local to window so you have to redefine them as soon as you open other file/buffer in the same window.&lt;/p&gt;&#xA;" OwnerUserId="9333" LastActivityDate="2020-04-21T06:27:10.500" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24716" PostTypeId="2" ParentId="24693" CreationDate="2020-04-21T07:23:09.383" Score="0" Body="&lt;p&gt;This set of commands allowed me to run flake8 through either python 2 or 3 at a whim. It uses the &lt;code&gt;g:flake8_cmd&lt;/code&gt; command as recommended in the comments by filbranden and it is in fact listed on the &lt;a href=&quot;https://github.com/nvie/vim-flake8&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-flake8 github&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This isn't 100% however because there is some odd behavior. For one the highlighting seems slightly off; but vim-flake also didn't error handle quite right as initially vim couldn't find python3 but was still saying &lt;code&gt;Flake8 check OK&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function Python2Flake()&#xA;   let g:flake8_cmd = &quot;python -m flake8&quot;&#xA;   call flake8#Flake8()&#xA;&#xA;:endfunction&#xA;&#xA;autocmd Filetype python map &amp;lt;buffer&amp;gt; &amp;lt;F2&amp;gt; :call Python2Flake()&#xA;&#xA;function Python3Flake()&#xA;    let g:flake8_cmd = &quot;python3 -m flake8&quot;&#xA;    call flake8#Flake8()&#xA;&#xA;:endfunction&#xA;&#xA;autocmd Filetype python map &amp;lt;buffer&amp;gt; &amp;lt;F3&amp;gt; :call Python3Flake()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="28955" LastActivityDate="2020-04-21T07:23:09.383" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24717" PostTypeId="1" CreationDate="2020-04-21T08:04:11.287" Score="2" ViewCount="15" Body="&lt;p&gt;I have g++ alias defined in my &lt;code&gt;.bashrc&lt;/code&gt; file as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias g++='g++ -Wall -DLOCAL=1'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am invoking following command from vim command/normal mode to compile a program -&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;!g++ %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue is, this command is working, but this is not picking the alias that's defined in bashrc file. It appears vim is invoking the original g++. To be precise, it looks like vim is not executing the command in current shell/env setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;g++ file.cpp&lt;/code&gt; from bash commandline the alias is being picked up correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ofcourse I can dump the entire required command in the command mode, but I would like vim to pickup the alias defined in &lt;code&gt;.bashrc&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="8092" LastActivityDate="2020-04-21T08:04:11.287" Title="vim command mode g++ doesn't pick the bash alias" Tags="|normal-mode|bash|" AnswerCount="0" CommentCount="1" ClosedDate="2020-04-21T15:07:06.183" ContentLicense="CC BY-SA 4.0" />
  <row Id="24718" PostTypeId="1" AcceptedAnswerId="24768" CreationDate="2020-04-21T09:23:31.583" Score="0" ViewCount="97" Body="&lt;p&gt;instead of the default display of the MiniBufExpl window on the bottom, I would like to have it on the top, is this possible?&lt;/p&gt;&#xA;" OwnerUserId="27564" LastActivityDate="2020-04-22T11:56:41.190" Title="How to display MiniBufExpl window on the top" Tags="|buffers|vim-windows|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24719" PostTypeId="1" CreationDate="2020-04-21T09:23:45.970" Score="1" ViewCount="25" Body="&lt;p&gt;Vim wraps text around as most other text editors, but does not allow the same kind of navigation within wrapped lines. Take for instance a piece of text composed of several long paragraphs. If the user hits the down key within a certain paragraph Vim hops down to the next paragraph. In an editor like GEdit the down key moves the cursor to the following wrapped line within the paragraph. This behaviour in Vim makes it rather cumbersome to edit text in the middle of an existing paragraph, it takes a while just to get the cursor to the right position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can Vim be instructed to navigated within paragraphs in the same way as GEdit? With the down and up keys moving the cursor within the paragraph and not hopping between paragraphs.&lt;/p&gt;&#xA;" OwnerUserId="26408" LastActivityDate="2020-04-21T09:23:45.970" Title="Navigating wrapped paragraph as multiple lines" Tags="|wrapping|navigation|" AnswerCount="0" CommentCount="3" ClosedDate="2020-04-21T17:10:04.493" ContentLicense="CC BY-SA 4.0" />
  <row Id="24720" PostTypeId="2" ParentId="24713" CreationDate="2020-04-21T09:36:13.520" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Why using 0 is not enough to put the cursor at the beginning of the line after abbreviation?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When you press space, Vim expands &lt;code&gt;@@t&lt;/code&gt; into &lt;code&gt;&amp;lt;esc&amp;gt;0&lt;/code&gt;, then the space command is executed.  In insert mode, the space command inserts a space, but in normal mode it moves the cursor 1 character forward (see &lt;code&gt;:h &amp;lt;space&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prevent the space from interfering, you can consume it with &lt;code&gt;getchar()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inorea &amp;lt;silent&amp;gt; @@t &amp;lt;esc&amp;gt;0@=&amp;lt;sid&amp;gt;eat_space()&amp;lt;cr&amp;gt;&#xA;fu s:eat_space() abort&#xA;    let c = nr2char(getchar(0))&#xA;    return c =~# '\s' ? '' : c&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:helpgrep Eatchar&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2020-04-21T09:36:13.520" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24721" PostTypeId="1" AcceptedAnswerId="33055" CreationDate="2020-04-21T10:40:22.353" Score="0" ViewCount="504" Body="&lt;p&gt;Every time I run &lt;code&gt;vim&lt;/code&gt; I receive the following error message that disappear afterwords. What can I do to get rid of that message or to get rid of the problem?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[deoplete] [yarp] [deoplete] job is dead. failed establishing channel for ['python3', '-u', '/home/sb/.vim/plugged/nvim-yarp/pythonx/yarp.py', '/tmp/vxXiDJM/0', 2, 'deoplete']&#xA;[deoplete] function deoplete#enable[9]..deoplete#initialize[1]..deoplete#init#_initialize[15]..deoplete#init#_channel[24]..yarp#core#notify[1]..yarp#core#wait_channel, line 13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27182" LastActivityDate="2021-08-09T09:43:52.667" Title="How to get rid of an error message from 'deoplete'" Tags="|error|plugin-deoplete|message|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24722" PostTypeId="2" ParentId="300" CreationDate="2020-04-21T10:52:32.993" Score="1" Body="&lt;p&gt;Here's a no-config, Mac-only alternative that I &lt;a href=&quot;https://daringfireball.net/2020/04/the_ipad_magic_keyboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;only just learned about&lt;/a&gt;. In macOS's Terminal.app and in MacVim's GUI version, (but not, notably, in the iTerm2 terminal*,) the standard macOS key combination &lt;kbd&gt;⌘&lt;/kbd&gt;&lt;kbd&gt;.&lt;/kbd&gt; (Command-period)  can be used to emulate an &lt;kbd&gt;Esc&lt;/kbd&gt; keystroke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* At least, not using any configuration options I could find in the preferences.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-04-21T10:52:32.993" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24723" PostTypeId="1" CreationDate="2020-04-21T10:54:18.167" Score="0" ViewCount="129" Body="&lt;p&gt;Say I have the text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a test!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If my cursor is on the first character, &quot;T&quot;, and then I do &lt;code&gt;d4w&lt;/code&gt;, then I am left with just &lt;code&gt;!&lt;/code&gt;. However, if instead I do &lt;code&gt;v4wd&lt;/code&gt; then I'm left with nothing (i.e. the entire string was selected and deleted).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this the case? I saw there are some &lt;a href=&quot;https://vi.stackexchange.com/a/6197/29040&quot;&gt;special cases&lt;/a&gt; with words when searching for an answer, but it doesn't seem to exactly apply from my understanding.&lt;/p&gt;&#xA;" OwnerUserId="29040" LastActivityDate="2020-04-21T13:30:48.517" Title="Visual mode word behaves differently than in normal mode?" Tags="|visual-mode|normal-mode|vi-words|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24724" PostTypeId="2" ParentId="24723" CreationDate="2020-04-21T11:25:11.933" Score="0" Body="&lt;p&gt;It's not a special case, the examples are different. In the first one you say &quot;delete 4 words&quot;, in the second you say &quot;move 4 words to the right and then delete all that was selected&quot;, they mean different things. In the first case the first word to be deleted is &lt;code&gt;This&lt;/code&gt; and the fourth word to be deleted is &lt;code&gt;test&lt;/code&gt;, in the second case the first word the cursor is moved to is &lt;code&gt;is&lt;/code&gt; and that the fourth word is &lt;code&gt;!&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see it better by typing &lt;code&gt;4w&lt;/code&gt; in normal mode with the cursor in &lt;code&gt;T&lt;/code&gt;, you will see that the cursor is on top of &lt;code&gt;!&lt;/code&gt;, just like in visual mode&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-21T11:25:11.933" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24725" PostTypeId="1" CreationDate="2020-04-21T11:54:07.433" Score="0" ViewCount="23" Body="&lt;p&gt;With &lt;code&gt;set wrap&lt;/code&gt;, is there any way to not show the whole logical line when scrolling after the last line or before the first with &lt;code&gt;gj&lt;/code&gt; and &lt;code&gt;gk&lt;/code&gt;, but only the visual line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The goal is to prevent jerky movements when 'scrolling', especially when dealing with very long lines (prose) or narrow splits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I'd like my cursor to stay on the same line when scrolling, which should be the bottom most line when 'scrolloff' is set to zero when scrolling down (or the top most when going up).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this is not the intended behavior of Vim, but I think some kind of script could do the trick. No answer on the internet seems to provide this, though, and I'm not sure how I could achieve this (my knowledge of vimscript is basic to say the least).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;set tw=winwidth(0)&lt;/code&gt; but it does not affect the behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/88/how-do-i-deal-with-very-long-lines-in-text-500-characters&quot;&gt;This topic&lt;/a&gt; does not answer the question and is five years old.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your time!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: &lt;code&gt;CTRL-E&lt;/code&gt; and &lt;code&gt;CTRL-Y&lt;/code&gt; are behaving the same (scrolling by logical line, I guess for the same reason), &lt;code&gt;display=lastline&lt;/code&gt; does not affect the behavior, neither does &lt;code&gt;scrolloff&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my &lt;a href=&quot;https://github.com/Biggybi/dotfiles/blob/master/vimrc&quot; rel=&quot;nofollow noreferrer&quot;&gt;vimrc&lt;/a&gt;, just in case.&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2020-04-21T19:08:57.523" LastActivityDate="2020-04-21T19:08:57.523" Title="display visual lastline instead of whole line with 'wrap' on" Tags="|scrolling|wrapping|" AnswerCount="0" CommentCount="3" ClosedDate="2020-04-22T12:57:01.927" ContentLicense="CC BY-SA 4.0" />
  <row Id="24726" PostTypeId="1" AcceptedAnswerId="24732" CreationDate="2020-04-21T12:05:35.167" Score="0" ViewCount="64" Body="&lt;p&gt;I'm using vim to code and I &lt;code&gt;set autoindent&lt;/code&gt; in my &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if I code as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (a == 1)&#xA;{|     // the cursor is here and I type ENTER&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After typing the ENTER, the code becomes as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (a == 1)&#xA;{&#xA;    |     // Now the cursor is here, it indented automatically&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (a == 1)&#xA;{&#xA;|}   // the corsor is here and I type ENTER&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (a == 1)&#xA;{&#xA;&#xA;|}   // the corsor is here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I type &lt;code&gt;k&lt;/code&gt; to move the cursor up and it will become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if (a == 1)&#xA;    {&#xA;|       // the corsor is here now, this is NOT what I expected&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (a == 1)&#xA;{&#xA;    |       // after typing `k`, the cursor will indent automatically&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well, this might not be a big issue but I still want to make it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do so?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-05-21T14:08:10.807" Title="How to make the indentation more smart" Tags="|indentation|indent|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24727" PostTypeId="2" ParentId="24726" CreationDate="2020-04-21T12:39:43.700" Score="0" Body="&lt;p&gt;Well, I found another way to avoid this issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-v&amp;gt;&amp;lt;Enter&amp;gt; &amp;lt;CR&amp;gt;&amp;lt;C-o&amp;gt;O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, if I code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (a == 1)&#xA;{|}    // the cursor is here with INSERT mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I can type &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;C-Enter&amp;gt;&lt;/code&gt; to get what I expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a better way, please feel free to pose your answer and I'll accept it.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-04-21T12:39:43.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24728" PostTypeId="1" AcceptedAnswerId="24735" CreationDate="2020-04-21T13:00:10.990" Score="1" ViewCount="124" Body="&lt;p&gt;I am using a function in my vimrc to detect contents similar to those of a modeline and use that to highlight specific words in the file contents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function I'm using is from the answer to &lt;a href=&quot;https://vi.stackexchange.com/questions/17116/match-pattern-and-highlight-it-in-modeline-for-a-specific-filetype&quot;&gt;my previous question on the topic&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! s:confhighlight()&#xA;    let l:matches = matchlist(getline('$'), '^# highlight: \(.*\)$')&#xA;    if len(l:matches)&#xA;        let s:matchid = matchadd('Todo', l:matches[1])&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I modify this function to highlight multiple words instead of just one expression?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see that here, we're trying to match &lt;code&gt;\(.*\)$')&lt;/code&gt; but that would match only all characters till the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to match words separated by spaces as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# highlight: first second&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I expect that all matches of &lt;code&gt;first&lt;/code&gt; and &lt;code&gt;second&lt;/code&gt; will be highligted in the current buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="14274" LastEditorUserId="18609" LastEditDate="2020-04-21T15:29:41.253" LastActivityDate="2020-04-26T15:01:03.463" Title="Highlight multiple words from modeline-like tag?" Tags="|vimrc|vimscript|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="24729" PostTypeId="1" AcceptedAnswerId="24730" CreationDate="2020-04-21T13:06:12.083" Score="1" ViewCount="184" Body="&lt;p&gt;I'm coding c++ with vim and I want to set a shortcut while typing parenthesis and new line. Here is an example, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (a == 1) {}|  // the cursor is at the end of the line and the vim is under INSERT mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I need is to set a shortcut to make this piece of code as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (a == 1) {&#xA;    |  // the cursor is here now and the vim is under INSERT mode&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-v&amp;gt;&amp;lt;Enter&amp;gt; &amp;lt;C-o&amp;gt;i&amp;lt;CR&amp;gt;&amp;lt;C-o&amp;gt;O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But with this setting, if I type &lt;code&gt;&amp;lt;C-v&amp;gt;&amp;lt;C-Enter&amp;gt;&lt;/code&gt;, the code will become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (a == 1) {}&#xA;|    // the cursor is here now and the vim is under INSERT mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm confused now. Because I've tested with my vim and it should work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (a == 1) {}|   // the cursor is here with INSERT mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Typing &lt;code&gt;&amp;lt;C-o&amp;gt;i&lt;/code&gt;: &lt;code&gt;if (a == 1) {|}  // the cursor is here now with INSERT mode&lt;/code&gt;&lt;br&gt;&#xA;Then, typing &lt;code&gt;CR&amp;lt;C-o&amp;gt;O&lt;/code&gt; could make the code become what I expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (a == 1) {&#xA;    |  // the cursor is here with INSERT mode&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you see, it worked as expected, but why can't it work with &lt;code&gt;inoremap&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-04-21T13:26:33.733" Title="Why doesn't inoremap work in this case" Tags="|key-bindings|insert-mode|normal-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24730" PostTypeId="2" ParentId="24729" CreationDate="2020-04-21T13:26:33.733" Score="0" Body="&lt;p&gt;What about of simply using the following?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:inoremap &amp;lt;buffer&amp;gt; µ &amp;lt;left&amp;gt;&amp;lt;cr&amp;gt;&amp;lt;esc&amp;gt;O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: in my bracketing plugin, I test on &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; whether my cursor is between brackets to trigger that behaviour (without the left part as I start from &lt;code&gt;{|}&lt;/code&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="626" LastActivityDate="2020-04-21T13:26:33.733" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24731" PostTypeId="2" ParentId="24723" CreationDate="2020-04-21T13:30:48.517" Score="1" Body="&lt;p&gt;In Vim motions can be either inclusive (&quot;include the rightmost character&quot;), or exclusive (&quot;exclude rightmost character&quot;). &lt;code&gt;w&lt;/code&gt; is made exclusive (so you delete exactly four words: &quot;this&quot; &quot;is&quot; &quot;a&quot; &quot;test&quot;). If you want to make it inclusive add &lt;code&gt;:h o_v&lt;/code&gt; to the target command: &lt;code&gt;d4vw&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, in Visual mode all motions are governed by a global option called &lt;code&gt;:h 'selection'&lt;/code&gt;. By default, it's &lt;code&gt;:set selection=inclusive&lt;/code&gt;, so &lt;code&gt;!&lt;/code&gt; gets into the visual selection. Add &lt;code&gt;:set selection=exclusive&lt;/code&gt; to your vimrc if you don't like it.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-04-21T13:30:48.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24732" PostTypeId="2" ParentId="24726" CreationDate="2020-04-21T13:46:12.417" Score="0" Body="&lt;p&gt;The simpler solution is to create a small function and to map &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; to this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Enter()&#xA;&#xA;    &quot; When the cursor is between 2 curvy braces&#xA;    if search('{\%#}', 'n')&#xA;&#xA;        &quot; new line and insert line above&#xA;        return &quot;\&amp;lt;CR&amp;gt;\&amp;lt;C-o&amp;gt;O&quot;&#xA;    endif&#xA;&#xA;    &quot; Otherwise, simple newline&#xA;    return &quot;\&amp;lt;CR&amp;gt;&quot;&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;CR&amp;gt; &amp;lt;C-r&amp;gt;=Enter()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is actually what some auto tag closing plugins do.&#xA;(like &lt;code&gt;autopairs&lt;/code&gt; for example)&lt;/p&gt;&#xA;" OwnerUserId="27331" LastActivityDate="2020-04-21T13:46:12.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24733" PostTypeId="1" AcceptedAnswerId="24734" CreationDate="2020-04-21T14:22:07.577" Score="3" ViewCount="162" Body="&lt;p&gt;I have a map which allows me to navigate with hjkl in insert mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; In insert or command mode, move normally by using Ctrl&#xA;inoremap &amp;lt;C-h&amp;gt; &amp;lt;Left&amp;gt;&#xA;inoremap &amp;lt;C-j&amp;gt; &amp;lt;Down&amp;gt;&#xA;inoremap &amp;lt;C-k&amp;gt; &amp;lt;Up&amp;gt;&#xA;inoremap &amp;lt;C-l&amp;gt; &amp;lt;Right&amp;gt;&#xA;cnoremap &amp;lt;C-h&amp;gt; &amp;lt;Left&amp;gt;&#xA;cnoremap &amp;lt;C-j&amp;gt; &amp;lt;Down&amp;gt;&#xA;cnoremap &amp;lt;C-k&amp;gt; &amp;lt;Up&amp;gt;&#xA;cnoremap &amp;lt;C-l&amp;gt; &amp;lt;Right&amp;gt;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All maps works, except &lt;code&gt;&amp;lt;c-h&amp;gt;&lt;/code&gt;. In insert mode, when a I press &lt;code&gt;&amp;lt;c-h&amp;gt;&lt;/code&gt;, backspace occours.&#xA;I know that &lt;code&gt;^H&lt;/code&gt; is the ASCII for backspace, but I would like to know if there's some way to make my &lt;code&gt;&amp;lt;c-h&amp;gt;&lt;/code&gt; works as &lt;code&gt;&amp;lt;left&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run: &lt;code&gt;:verbose inoremap &amp;lt;c-h&amp;gt;&lt;/code&gt; it returns&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i  &amp;lt;C-H&amp;gt;       *@&amp;lt;C-R&amp;gt;=AutoPairsDelete()&amp;lt;CR&amp;gt;                                                                                                                            │ost/site/content/themes/sc5&#xA;        Last set from ~/.vim/plugged/auto-pairs/plugin/auto-pairs.vim line 549                                                                                          │0k/gulpfile.js&#xA;i  &amp;lt;C-H&amp;gt;       * &amp;lt;Left&amp;gt;                                                                                                                                                 │[10:29:37] Starting 'watch'&#xA;        Last set from ~/.dotfiles/nvim/init.vim line 264&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A courious thing is that in &lt;code&gt;command mode&lt;/code&gt;, &lt;code&gt;&amp;lt;c-h&amp;gt;&lt;/code&gt; works fine!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using iTerm2 in MacOS Catalina with tmux and neovim.&lt;/p&gt;&#xA;" OwnerUserId="26842" LastActivityDate="2020-04-21T14:43:06.350" Title="Setting to prevent &lt;c-h&gt; to erase text" Tags="|key-bindings|neovim|insert-mode|iterm2|ascii|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24734" PostTypeId="2" ParentId="24733" CreationDate="2020-04-21T14:43:06.350" Score="4" Body="&lt;p&gt;Thanks to your output of &lt;code&gt;verbose inoremap &amp;lt;c-h&amp;gt;&lt;/code&gt; it's really easy to see what is happening here!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are using the &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;auto-pairs&lt;/a&gt; plug-in and it's installing buffer-local mappings for the bracket keys, but also for keys such as Enter and Backspace. It maps backspace so it can &quot;undo&quot; a close bracket action if you type backspace to erase a mistake of yours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, there's actually a difference between &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; and &quot;backspace&quot;. While historically the backspace key would produce the &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; sequence, that's no longer the case and most modern terminal emulators will produce a different sequence for the &quot;backspace&quot; key (unless they're configured to produce the &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; sequence for backward compatibility reasons, but that's more and more rare nowadays.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For historical reasons, auto-pairs (and probably most other plug-ins that map backspace) will by default map &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; &lt;em&gt;as well as&lt;/em&gt; &quot;backspace&quot;, so that if you have an old terminal or have it misconfigured, everything will keep working the same with &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; as it does with the &quot;backspace&quot; key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(It's true that the default action of Vim for &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt; is the same as backspace, for much of the same reasons.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately, auto-pairs allows you to control these two mappings individually, by setting global variables from your vimrc, you have &lt;code&gt;g:AutoPairsMapBS&lt;/code&gt; to create the mapping for the backspace key, and &lt;code&gt;g:AutoPairsMapCh&lt;/code&gt; to create the mapping for &lt;code&gt;&amp;lt;C-h&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can fix your issue simply by adding this line to your vimrc file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:AutoPairsMapCh = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-21T14:43:06.350" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24735" PostTypeId="2" ParentId="24728" CreationDate="2020-04-21T16:00:53.087" Score="1" Body="&lt;p&gt;As &lt;a href=&quot;https://vi.stackexchange.com/users/18609/filbranden&quot;&gt;@filbranden&lt;/a&gt; suggested, there's a simple solution using &lt;code&gt;split&lt;/code&gt; and a &lt;code&gt;for&lt;/code&gt; loop, here it is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! ClearConfHilights()&#xA;    for id in getwinvar(win_getid(), 'confHiIds', [])&#xA;        call matchdelete(id)&#xA;    endfor&#xA;    let w:confHiIds = []&#xA;endfunction&#xA;function! Confhighlight()&#xA;    call ClearConfHilights()&#xA;    let l:raw_matches = matchlist(getline('$'), '^# highlight: \(\S.*\)$')&#xA;    if len(l:raw_matches) &amp;gt;= 1&#xA;        let l:matches = split(l:raw_matches[1])&#xA;        for match in l:matches&#xA;            call add(w:confHiIds, matchadd('Todo', match))&#xA;        endfor&#xA;    endif&#xA;endfunction&#xA;&#xA;autocmd BufWinEnter *.conf call Confhighlight()&#xA;&#xA;&quot; To auto update highlights:&#xA;autocmd TextChanged,InsertLeave *.conf if line('.') == line('.') | call Confhighlight() | endif&#xA;&#xA;&quot; To update the highlights when you hit `&amp;lt;F2&amp;gt;`:&#xA;nnoremap &amp;lt;F2&amp;gt; :&amp;lt;C-u&amp;gt;call Confhighlight()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There are 2 functions here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;ClearConfHighlights&lt;/strong&gt;&lt;br&gt;&#xA;Its role is to delete all the present conf highlights, and initialize the highlights list to an empty array.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Confhighlight&lt;/strong&gt;&lt;br&gt;&#xA;Looks at the last line of the file to find (or not) the pattern &lt;code&gt;# highlight: ...&lt;/code&gt;, and highlights the words one by one, adding them to the highlight list at the same time.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;autocmd&lt;/code&gt; is here to reset the highlight on buffer change&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Note&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;As you can see, the highlight list is local to windows, and not buffers. That's because the matches created by &lt;code&gt;matchadd&lt;/code&gt; are themselves local to windows.&lt;/p&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="27331" LastEditDate="2020-04-26T15:01:03.463" LastActivityDate="2020-04-26T15:01:03.463" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="24736" PostTypeId="1" AcceptedAnswerId="24739" CreationDate="2020-04-21T16:32:31.860" Score="1" ViewCount="256" Body="&lt;p&gt;When I open a &lt;code&gt;.task&lt;/code&gt; file I don't want to see all the comments at the top.  I want the screen to be scrolled down...  I can do that manually when vim's already running via &lt;code&gt;zt&lt;/code&gt; and I want this to be done automatically when the file is loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an autocommand but it won't act on &lt;code&gt;zt&lt;/code&gt; or &lt;code&gt;normal zt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works &lt;code&gt;autocmd BufRead,BufNewFile task.*.task normal 23G22|&lt;/code&gt; but I'm not able to then get the screen to redraw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  function GotoTaskLine()&#xA;    normal 23G22|&#xA;    normal zt&#xA;  endfunction&#xA;  autocmd BufRead,BufNewFile task.*.task call GotoTaskLine()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I've tried these variations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  autocmd BufRead,BufNewFile task.*.task normal 23G22| | zt&#xA;  autocmd BufRead,BufNewFile task.*.task normal 23G22| zt&#xA;  autocmd BufRead,BufNewFile task.*.task normal 23G22| | normal zt&#xA;  autocmd BufRead,BufNewFile task.*.task normal 23G22| normal zt&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but none of them successfully do both: navigate to line23/column22 &lt;em&gt;and&lt;/em&gt; redraw screen with cursor position at the top.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there another way &lt;code&gt;zt&lt;/code&gt; can be invoked?  In reading through &lt;code&gt;:help redraw&lt;/code&gt; and &lt;code&gt;:help zt&lt;/code&gt; I wasn't able to find anything that pointed me towards freedom.  Can you shine any light here?&lt;/p&gt;&#xA;" OwnerUserId="6189" LastActivityDate="2020-04-27T15:36:38.033" Title="how to redraw screen (with cursor at top like `zt`) from autocommand" Tags="|autocmd|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24737" PostTypeId="2" ParentId="21712" CreationDate="2020-04-21T16:43:54.580" Score="0" Body="&lt;p&gt;Assuming you're talking about the &lt;code&gt;__init__&lt;/code&gt; docstring...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just follow the &lt;code&gt;triple_quotes()&lt;/code&gt; calls. They mark the start and end of the relevant code...all of this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        `!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined.}`!p&#xA;snip.rv = &quot;&quot;&#xA;snip &amp;gt;&amp;gt; 2&#xA;&#xA;args = get_args(t[4])&#xA;&#xA;write_docstring_args(args, snip)&#xA;if args:&#xA;    snip.rv += '\n' + snip.mkline('', indent='')&#xA;    snip += '{0}'.format(triple_quotes(snip))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All those function calls are Python functions defined in the same file as the snippet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had no idea what &quot;change the entire format to Google's&quot; meant but the I noticed that right below &lt;code&gt;write_docstring_args()&lt;/code&gt; there's a function &lt;code&gt;write_google_docstring_args()&lt;/code&gt;. It takes the same arguments so I bet you can just drop that in as a substitute for &lt;code&gt;write_docstring_args()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[&lt;em&gt;Update: The answer posted after this one mentions using the variable &lt;code&gt;g:ultisnips_python_style&lt;/code&gt; to enable google style. In fact, setting that will have the exact same effect as substituting the function as I just described. Obviously, using the variable is a lot more convenient.&lt;/em&gt;]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the &quot;Raises&quot; part, you probably can't bank on someone fully implementing that for you but I can offer pointers. One approach would be to extend the snippet discussed above and copy relevant parts in &lt;code&gt;write_google_docstring_args()&lt;/code&gt; that handle other sections and modify to match the new section.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need to communicate to the function whether you need the Raises text added or not. If you add a new trigger for exception type at &quot;slot&quot; 6 (&lt;code&gt;${6:...}&lt;/code&gt;) the user-entered text for it can be read from &lt;code&gt;t[6]&lt;/code&gt; (like the use of &lt;code&gt;t[4]&lt;/code&gt; in the above code). You might pass that as an additional param to the function. Then you can build the Raises text from that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the vimdocs for Ultisnips for lots of useful info. And look at what other Python snippets are doing for further insight. If you have zero coding experience see how far you can get. Then come back with follow up questions in the comments...I'll see what I can do to help.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-04-22T07:10:35.587" LastActivityDate="2020-04-22T07:10:35.587" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24739" PostTypeId="2" ParentId="24736" CreationDate="2020-04-21T19:25:47.613" Score="1" Body="&lt;p&gt;I got it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup SkipTaskComments&#xA;    autocmd!&#xA;    autocmd FileType taskedit autocmd! BufEnter,BufRead &amp;lt;buffer&amp;gt; silent!&#xA;        \ normal 12gg22|zt&#xA;augroup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;normal zt&lt;/code&gt; was wrong, should be &lt;code&gt;zt&lt;/code&gt; only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;augroup&lt;/code&gt; is for convenience. &lt;code&gt;autocmd!&lt;/code&gt; will delete it's content if you source your &lt;code&gt;vimrc&lt;/code&gt;, preventing pile-up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added an extra autocmd to check the buffer type, and apply your commands to the &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;. I think it's cleaner. &lt;code&gt;silent!&lt;/code&gt; is totally optional, that's just how I usually write that type of autocmd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can replace &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt; with your original regex if this is really needed&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au FileType taskedit au! BufEnter,BufRead task*.*task silent!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even just remove the guilty &lt;code&gt;normal&lt;/code&gt; from your code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufEnter,BufRead task*.*task&#xA;    \ normal 12gg22|zt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should keep the &lt;code&gt;augroup&lt;/code&gt;, though.&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2020-04-27T15:36:38.033" LastActivityDate="2020-04-27T15:36:38.033" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24741" PostTypeId="2" ParentId="24611" CreationDate="2020-04-21T20:24:02.687" Score="1" Body="&lt;p&gt;After peeking through some files inside the directories the plugin I found a file named &lt;code&gt;c.comments.template&lt;/code&gt; inside &lt;code&gt;c-support&lt;/code&gt; directory. Inside this file, the predefined skeleton (which is added everytime a new C file is created) exists. In that file search for &lt;code&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/code&gt; and replace it with &lt;code&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/code&gt; .&lt;/p&gt;&#xA;" OwnerUserId="22672" LastActivityDate="2020-04-21T20:24:02.687" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24742" PostTypeId="1" CreationDate="2020-04-21T22:07:01.370" Score="0" ViewCount="23" Body="&lt;p&gt;If I want to copy and paste the next 5 lines and paste those 5 lines below the next 5 lines, I would do &lt;code&gt;5yy5jp&lt;/code&gt;. How would I use command to say something like &lt;code&gt;5yyp&lt;/code&gt; to paste the next 5 lines and automatically jump down to the beginning of the pasted text?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line 1&#xA;Line 2&#xA;Line 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line 1&#xA;Line 2&#xA;Line 3&#xA;&#xA;Line 1&#xA;Line 2&#xA;Line 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2021" LastEditorUserId="2021" LastEditDate="2020-04-21T22:26:02.053" LastActivityDate="2020-04-21T22:26:02.053" Title="Automating a yank and paste operation" Tags="|cut-copy-paste|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24743" PostTypeId="2" ParentId="23149" CreationDate="2020-04-21T23:30:05.677" Score="2" Body="&lt;p&gt;In an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping there is actually nothing wrong with using single quotes. An &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping expects a string which it interprets as the mapping RHS when it is invoked. So the original mapping is perfectly correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your error comes in because the original mapping is split over 2 lines, which requires a line continuation character &lt;code&gt;\&lt;/code&gt;. When you have joined it into a single line, you must remove the backslash. So to use that line in an autocmd, it should become:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Original version, for comparison:&#xA;&quot; autocmd FileType cs inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; pumvisible() ? '&amp;lt;C-n&amp;gt;' : \ getline('.')[col('.')-2] =~# '[[:alnum:].-_#$]' ? '&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;' : '&amp;lt;Tab&amp;gt;'&#xA;&quot;                                                        remove this ^&#xA;  autocmd FileType cs inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; pumvisible() ? '&amp;lt;C-n&amp;gt;' : getline('.')[col('.')-2] =~# '[[:alnum:].-_#$]' ? '&amp;lt;C-x&amp;gt;&amp;lt;C-o&amp;gt;' : '&amp;lt;Tab&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; I see you eventually worked that out in the comments, but I'll still post this answer to make it clear what the actual fix for your error was.&lt;/p&gt;&#xA;" OwnerUserId="7549" LastEditorUserId="7549" LastEditDate="2020-04-22T00:12:25.770" LastActivityDate="2020-04-22T00:12:25.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24744" PostTypeId="2" ParentId="21712" CreationDate="2020-04-21T23:38:02.090" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Change the entire format to Google's...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's not documented, but the Python snippets file from &lt;strong&gt;vim-snippets&lt;/strong&gt; &lt;a href=&quot;https://github.com/honza/vim-snippets/blob/5d259617f5198e511a759ccf4fb3000921abae21/UltiSnips/python.snippets#L123&quot; rel=&quot;nofollow noreferrer&quot;&gt;does allow you to specify docstring style&lt;/a&gt;. Simply add &lt;code&gt;let g:ultisnips_python_style = 'google'&lt;/code&gt; to your configuration, and the snippet will behave accordingly.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When adding exception in a forward trigger, the docstring will add a &quot;Raises&quot; section (using Google's format)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm really not sure what you mean here, but you will have to implement this yourself by either writing your own snippet or extending the one that comes with &lt;strong&gt;vim-snippets&lt;/strong&gt;. You'll likely want to add a function that performs whatever check you need, and then if you decide to extend the existing Python snippet file, somewhere in the Python interpolation block beginning at the &lt;strong&gt;end&lt;/strong&gt; of &lt;a href=&quot;https://github.com/honza/vim-snippets/blob/5d259617f5198e511a759ccf4fb3000921abae21/UltiSnips/python.snippets#L274&quot; rel=&quot;nofollow noreferrer&quot;&gt;this line&lt;/a&gt; is where you'd add the relevant snippet code to include your &quot;Raises&quot; section. Alternatively, you may find it easier to simply create a &quot;raises&quot; snippet separate from the &quot;class&quot; snippet that does what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either way, you'll probably want to refer to the Ultisnips documentation for how to use its Python interpolation and its built-in API surrounding the &lt;code&gt;snip&lt;/code&gt; variable; it's all rather powerful. Best of luck.&lt;/p&gt;&#xA;" OwnerUserId="1452" LastActivityDate="2020-04-21T23:38:02.090" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24745" PostTypeId="1" CreationDate="2020-04-22T02:54:50.013" Score="0" ViewCount="52" Body="&lt;p&gt;Is it possible to redirect messages(&lt;code&gt;:messages&lt;/code&gt;) to file (as I do now), just with higher verbosity than the verbosity level of the displayed messages? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The intention is that it would be the constant setting to be able to debug better unexpected errors&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mean for example: All messages of level 5 or less would be written to log file and displayed to user. All messages of level 20 or less would be just written to a log file. &lt;/p&gt;&#xA;" OwnerUserId="18375" LastEditorUserId="18375" LastEditDate="2020-04-23T22:57:57.983" LastActivityDate="2020-04-23T23:19:00.660" Title="Redirect with higher verbosity" Tags="|message|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24746" PostTypeId="2" ParentId="24745" CreationDate="2020-04-22T03:25:42.843" Score="1" Body="&lt;p&gt;You can use &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Averbose&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :verbose&lt;/a&gt; to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume we use a &lt;code&gt;Less&lt;/code&gt; command to capture &lt;code&gt;vim&lt;/code&gt; output, we can see what &lt;code&gt;set filetype&lt;/code&gt; really do like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Less 20verbose set filetype=cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;20&lt;/code&gt; is used to specify &lt;code&gt;'verbose'&lt;/code&gt; for the sub command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;Less&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com -nargs=+ -complete=command Less call &amp;lt;sid&amp;gt;less(&amp;lt;q-args&amp;gt;, &amp;lt;q-mods&amp;gt;)&#xA;&#xA;function s:less(cmd, mods)&#xA;  let winid = win_getid()&#xA;  exe a:mods 'new'&#xA;  setlocal buftype=nofile bufhidden=wipe noswapfile nobuflisted modifiable&#xA;  exe printf('put! =win_execute(%d, %s)', winid, string(a:cmd))&#xA;  1&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have &lt;code&gt;win_execute&lt;/code&gt;, you can replace it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &quot; get outout in original window&#xA;  let output = execute(some_command)&#xA;&#xA;  &quot; split&#xA;  ... new&#xA;  ...&#xA;&#xA;  &quot; paste&#xA;  put! =output&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-04-23T23:19:00.660" LastActivityDate="2020-04-23T23:19:00.660" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24748" PostTypeId="1" AcceptedAnswerId="24754" CreationDate="2020-04-22T04:08:53.590" Score="0" ViewCount="625" Body="&lt;p&gt;Say I have a session like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sunday|Monday&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;|&lt;/code&gt; is the cursor in insert mode. If I press &lt;code&gt;Esc&lt;/code&gt;, I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sunda█Monday&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I want this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sunday█onday&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As I want to select the second &quot;word&quot;, and if I go into visual mode, the &lt;code&gt;y&lt;/code&gt;&#xA;will be part of the selection. I found that I can use &lt;code&gt;Ctrl + O&lt;/code&gt; instead of&#xA;&lt;code&gt;Esc&lt;/code&gt; and the cursor is correct, but it only allows one command and goes back&#xA;into insert mode. I want to stay in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is some key available for this purpose?&lt;/p&gt;&#xA;" OwnerUserId="7184" LastActivityDate="2020-04-22T07:34:44.090" Title="Cursor difference with &quot;Esc&quot; and &quot;Ctrl + O&quot;" Tags="|key-bindings|insert-mode|normal-mode|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24749" PostTypeId="2" ParentId="24748" CreationDate="2020-04-22T06:09:33.000" Score="3" Body="&lt;p&gt;This is regular vi compatible behaviour. After pressing &lt;kbd&gt;Esc&lt;/kbd&gt; the cursor is always moved one character back. I believe the reason is the following: If the cursor in insert mode is at the end of the entered text and you press &lt;kbd&gt;Esc&lt;/kbd&gt;, there is no text on which to place the cursor, therefore it is moved back to the last entered character. The one exception to this rule is, if the cursor is on the start of the line, in which case it obviously cannot be moved to the left and will be placed on an empty cell (press &lt;kbd&gt;g&lt;/kbd&gt;&lt;kbd&gt;a&lt;/kbd&gt; on it and notice the &lt;code&gt;NUL&lt;/code&gt; result, which basically means there is no character)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want that behavior, I would suggest to map it to a behavior that you want, e.g. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;esc&amp;gt; col('.')&amp;gt;1&amp;amp;&amp;amp;col('$')&amp;lt;col('.')?'&amp;lt;esc&amp;gt;l':'&amp;lt;esc&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses an &lt;a href=&quot;https://vimhelp.org/map.txt.html#:map-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;expression mapping&lt;/a&gt; that checks whether the cursor is either after column 1 or before the last column in the current row and only in those cases will try to move the cursor after pressing &lt;kbd&gt;Esc&lt;/kbd&gt; in insert mode back to the character it was in insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Slightly related, you might want to also allow to put the cursor after the last character. This can be done using &lt;code&gt;:set ve=onemore&lt;/code&gt;. In that case, you do not need the condition &lt;code&gt;&amp;amp;&amp;amp;col('$')&amp;lt;col('.')&lt;/code&gt; above and you can skip that.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2020-04-22T06:09:33.000" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24750" PostTypeId="1" CreationDate="2020-04-22T06:14:25.307" Score="2" ViewCount="195" Body="&lt;p&gt;I have the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return err&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And would like to replace that to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return fmt.Errorf(&quot;: %w&quot;, \1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is done easily with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/return \v(\k+)/return fmt.Errorf(&quot;: %w&quot;, \1)/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with this is that after the &lt;code&gt;:s&lt;/code&gt; my cursor position will be at the start of the line (the &lt;code&gt;r&lt;/code&gt; in &lt;code&gt;return&lt;/code&gt;), while it would be much more useful to place it on the &lt;code&gt;:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to set the cursor position in the substitute replace pattern?&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2022-09-09T14:00:00.053" Title="Is there any way to position the cursor in a :substitute replace pattern?" Tags="|substitute|cursor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24751" PostTypeId="1" AcceptedAnswerId="24752" CreationDate="2020-04-22T06:34:56.693" Score="5" ViewCount="7299" Body="&lt;p&gt;To comment out a block in vim, &lt;a href=&quot;https://dev.to/grepliz/3-ways-to-comment-out-blocks-of-code-in-vi-6j4&quot; rel=&quot;noreferrer&quot;&gt;I enter visual mode with &lt;code&gt;v&lt;/code&gt; or Control-v, select some lines, then hit &lt;code&gt;I&lt;/code&gt; (Shift-i).&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However,  &lt;code&gt;I&lt;/code&gt;  takes me out of visual mode and into Insert mode (which makes sense, as that is what &lt;code&gt;I&lt;/code&gt;  usually does). So what am I doing wrong? How do I comment out a block?&lt;/p&gt;&#xA;" OwnerUserId="18468" LastActivityDate="2020-04-22T09:04:36.920" Title="Comment-out in vim with Shift-i not working" Tags="|visual-mode|comments|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24752" PostTypeId="2" ParentId="24751" CreationDate="2020-04-22T06:46:15.957" Score="9" Body="&lt;p&gt;It depends on the way you entered visual mode. If you used &lt;kbd&gt;V&lt;/kbd&gt; for line based visual selections, &lt;kbd&gt;I&lt;/kbd&gt; will only enter insert mode for the very first line. However when you used &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt;, &lt;kbd&gt;I&lt;/kbd&gt; will also take you into insert mode for the very first line, but after you press &lt;kbd&gt;Esc&lt;/kbd&gt; everything that was entered will also be copied to all the other lines of the selection. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From within visual mode, you can switch the different visual mode settings by pressing &lt;kbd&gt;v&lt;/kbd&gt; for switching to characterwise visual mode, &lt;kbd&gt;V&lt;/kbd&gt; to switch to linewise visual mode or &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; to switch to blockwise visual mode.&lt;/p&gt;&#xA;" OwnerUserId="71" LastEditorUserId="71" LastEditDate="2020-04-22T09:04:36.920" LastActivityDate="2020-04-22T09:04:36.920" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24753" PostTypeId="1" AcceptedAnswerId="24761" CreationDate="2020-04-22T06:48:09.307" Score="1" ViewCount="320" Body="&lt;p&gt;I want to code a vim function, which searches backwards a specific char from the cursor at the current line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I've done:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomSearch()&#xA;    let currentLine = getline(&quot;.&quot;)&#xA;&#xA;    &quot; how to loop backwards `currentLine`?&#xA;    &quot; something like this:&#xA;    &quot; for (int i = currentLine.size() - 1; i &amp;gt;= 0; i--)&#xA;    &quot;     if (currentLine[i] == 'a')&#xA;    &quot;         echo 'found a'&#xA;    &quot;     endif&#xA;    &quot; endfor&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;C-v&amp;gt;&amp;lt;C-b&amp;gt; :call CustomSearch()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2021-07-28T09:42:23.583" Title="How to loop backwards through getline" Tags="|key-bindings|insert-mode|functions|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24754" PostTypeId="2" ParentId="24748" CreationDate="2020-04-22T07:34:44.090" Score="2" Body="&lt;p&gt;You can press &lt;kbd&gt;Ctrl-O&lt;/kbd&gt;&lt;kbd&gt;Ctrl-C&lt;/kbd&gt;. Control-C effectively cancels any pending mode and takes you into Normal in the current cursor position. Of course, you can create some mapping if you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make things working also for the last character on line, make sure you have &lt;code&gt;:set ve=all&lt;/code&gt; or &lt;code&gt;:set ve=onemore&lt;/code&gt; in your vimrc. Or use &lt;kbd&gt;Ctrl-\&lt;/kbd&gt;&lt;kbd&gt;Ctrl-O&lt;/kbd&gt; instead of just &lt;kbd&gt;Ctrl-O&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-04-22T07:34:44.090" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24755" PostTypeId="1" AcceptedAnswerId="24756" CreationDate="2020-04-22T07:34:57.007" Score="4" ViewCount="364" Body="&lt;h1&gt;tldr&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Moving in ex command line is slow because common readline motions (like in bash) are not supported. Are there any improvements for this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I often find myself with an ex command in the command line and the need to e.g. edit something at the very beginning. For instance, I may have entered ex mode and pressed &lt;kbd&gt;↑&lt;/kbd&gt; to repeat the last ex command. I then have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e src/Sensors/Camera/SimulatedCameraSensor.cpp|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the command line, with &lt;code&gt;|&lt;/code&gt; being the cursor. In readline-enabled programms, I could use &lt;kbd&gt;Ctrl-A&lt;/kbd&gt; or &lt;kbd&gt;Alt- ←&lt;/kbd&gt; to quickly move to the beginning of the line, but in vim I seem to have to press the left arrow and move over individual characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any configuration or are there any shortcuts which will speed up cursor motions?&lt;/p&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2020-04-22T12:20:19.780" Title="Does vim's ex command line support (readline-like) motions?" Tags="|cursor-motions|ex-mode|" AnswerCount="2" CommentCount="0" ClosedDate="2020-04-22T13:00:19.020" ContentLicense="CC BY-SA 4.0" />
  <row Id="24756" PostTypeId="2" ParentId="24755" CreationDate="2020-04-22T07:45:22.617" Score="5" Body="&lt;p&gt;I have found two workarounds:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ryvnf/readline.vim&quot; rel=&quot;noreferrer&quot;&gt;This plugin&lt;/a&gt; adds some readline motions to command mode&lt;/li&gt;&#xA;&lt;li&gt;As outlined &lt;a href=&quot;https://stackoverflow.com/a/7189573/2397253&quot;&gt;here&lt;/a&gt;, one can press Ctrl-f in command mode to make the current command editable like in normal mode. This is incompatible with the option 1.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1066" LastActivityDate="2020-04-22T07:45:22.617" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24757" PostTypeId="1" AcceptedAnswerId="24758" CreationDate="2020-04-22T08:23:33.483" Score="2" ViewCount="1237" Body="&lt;p&gt;I'm using vim to code C++ and I want to handle the parenthesis more easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I knew that there was a plugin named &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1697&quot; rel=&quot;nofollow noreferrer&quot;&gt;Surround&lt;/a&gt;, which can help us but it is not what I expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set some shortcuts as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &quot; &quot;&quot;&amp;lt;left&amp;gt;&#xA;inoremap ' ''&amp;lt;left&amp;gt;&#xA;inoremap ( ()&amp;lt;left&amp;gt;&#xA;inoremap [ []&amp;lt;left&amp;gt;&#xA;inoremap &amp;lt; &amp;lt;&amp;gt;&amp;lt;left&amp;gt;&#xA;inoremap { {}&amp;lt;left&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With their help, if I type &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;()&lt;/code&gt; will be printed and the cursor will be located between &lt;code&gt;(&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt;. See below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(|)  # | is the cursor and the vim is under INSERT mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, what I expected is if I type Backspace now, it will delete &lt;code&gt;(&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt; together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do so?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-12-23T16:56:10.773" Title="How to delete a pair of parenthesis with backspace" Tags="|key-bindings|vimscript|cut-copy-paste|insert-mode|functions|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24758" PostTypeId="2" ParentId="24757" CreationDate="2020-04-22T09:00:06.973" Score="3" Body="&lt;p&gt;It is possible. There are plugins like &lt;a href=&quot;https://github.com/cohama/lexima.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lexima&lt;/a&gt;, &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;auto-pairs&lt;/a&gt; and others that handle deletion, but handling pairs of characters doesn't seem to be easy to solve in insert mode: I've used both and there's always a corner case that doesn't give you the right result. I think Surround is more reliable&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-22T09:00:06.973" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24759" PostTypeId="2" ParentId="24757" CreationDate="2020-04-22T09:20:36.923" Score="4" Body="&lt;p&gt;I saw the previous answer, but if you don't want to burden yourself with a plugin, you can achieve that with a function and a mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:couples = ['(#)', '[#]', '{#}', '&amp;lt;#&amp;gt;', '&amp;lt;div&amp;gt;#&amp;lt;/div&amp;gt;']&#xA;function BetterBS()&#xA;&#xA;    for l:couple in g:couples&#xA;        if ! (l:couple =~ '#')&#xA;            continue&#xA;        endif&#xA;        let l:regex = substitute(escape(l:couple, '/\^$*.[~'), '#', '\\%#', '')&#xA;        if search(l:regex, 'n')&#xA;            let l:out = repeat(&quot;\&amp;lt;BS&amp;gt;&quot;, len(matchstr(l:couple, '^.\{-}\ze#')))&#xA;            let l:out .= repeat(&quot;\&amp;lt;DEL&amp;gt;&quot;, len(matchstr(l:couple, '#\zs.\{-}$')))&#xA;            return l:out&#xA;        endif&#xA;    endfor&#xA;&#xA;    return &quot;\&amp;lt;BS&amp;gt;&quot;&#xA;endfunction&#xA;inoremap &amp;lt;silent&amp;gt; &amp;lt;BS&amp;gt; &amp;lt;C-r&amp;gt;=BetterBS()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You just have to modify the &lt;code&gt;g:couples&lt;/code&gt; variable and you're good to go! (&lt;code&gt;#&lt;/code&gt; identifies the position of the cursor)&lt;/p&gt;&#xA;" OwnerUserId="27331" LastActivityDate="2020-04-22T09:20:36.923" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24761" PostTypeId="2" ParentId="24753" CreationDate="2020-04-22T09:29:56.067" Score="3" Body="&lt;p&gt;Here's what you're looking for:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomSearch()&#xA;    let currentLine = getline(&amp;quot;.&amp;quot;)&#xA;    let col = col('.')&#xA;&#xA;    while col &amp;gt; 0&#xA;        let col -= 1&#xA;        if currentLine[col] == 'a'&#xA;            echo 'found a!'&#xA;            break&#xA;        endif&#xA;    endwhile&#xA;endfunction&#xA;&#xA;inoremap &amp;lt;C-v&amp;gt;&amp;lt;C-b&amp;gt; &amp;lt;C-o&amp;gt;:call CustomSearch()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I'm not sure what you want to do with that, but I feel like it would be much simpler with regex:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-v&amp;gt;&amp;lt;C-b&amp;gt; &amp;lt;C-o&amp;gt;:if search('^.*a.*\%#', 'n') &amp;lt;BAR&amp;gt; echo 'Found a!' &amp;lt;BAR&amp;gt; endif&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="27331" LastEditDate="2021-07-28T09:42:23.583" LastActivityDate="2021-07-28T09:42:23.583" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24762" PostTypeId="1" AcceptedAnswerId="24767" CreationDate="2020-04-22T09:32:26.113" Score="2" ViewCount="678" Body="&lt;p&gt;In Vim, using the text object &lt;code&gt;i&amp;gt;&lt;/code&gt;, you can edit an inner tag, and using the built-in matchit plugin, you can even use &lt;code&gt;%&lt;/code&gt; to jump between matching opening and closing tags. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say you want to change matching &lt;code&gt;div&lt;/code&gt; tags to something else, such as &lt;code&gt;section&lt;/code&gt;. One way to go about it would be to get to the opening tag with a &lt;code&gt;/&lt;/code&gt; search, reach the closing one with &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;[count]n&lt;/code&gt;, and press &lt;code&gt;.&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if the contents of the &lt;code&gt;div&lt;/code&gt; are very lengthy and comprise many other &lt;code&gt;div&lt;/code&gt; tags? For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;main&amp;gt;&#xA;    &amp;lt;div&amp;gt;&#xA;    &amp;lt;/div&amp;gt;&#xA;    &amp;lt;div id=&quot;foo&quot;&amp;gt;&#xA;        &amp;lt;div class=&quot;bar&quot;&amp;gt;&#xA;        &amp;lt;/div&amp;gt;&#xA;        &amp;lt;div class=&quot;bar&quot;&amp;gt;&#xA;        &amp;lt;/div&amp;gt;&#xA;        &amp;lt;div class=&quot;bar&quot;&amp;gt;&#xA;        &amp;lt;/div&amp;gt;&#xA;    &amp;lt;/div&amp;gt; &amp;lt;!-- Closing tag out of view  --&amp;gt;&#xA;&amp;lt;/main&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I navigate to the opening tag and change &lt;code&gt;div&lt;/code&gt; to &lt;code&gt;section&lt;/code&gt;. But now that I've changed the opening tag, I can't use &lt;code&gt;%&lt;/code&gt; anymore to jump to the closing one and change it. One way to get to the closing one, then, would be to search for it using its indentation e.g. &lt;code&gt;/    &amp;lt;&lt;/code&gt; but that seems overly complicated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a builtin feature or existing plugin that would allow something like jumping to a matching tag with &lt;code&gt;%&lt;/code&gt; even after modifying one of them, or (better) a text-object (say &lt;code&gt;mt&lt;/code&gt;) that selects the name of matching tags? e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;main&amp;gt;&#xA;    &amp;lt;div&amp;gt;&#xA;    &amp;lt;/div&amp;gt;&#xA;    &amp;lt;di█ id=&quot;foo&quot;&amp;gt;&#xA;        ...&#xA;    &amp;lt;/div&amp;gt; &#xA;&amp;lt;/main&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Input: &lt;code&gt;cmtsection&amp;lt;Esc&amp;gt;&lt;/code&gt;&#xA;Result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;main&amp;gt;&#xA;    &amp;lt;div&amp;gt;&#xA;    &amp;lt;/div&amp;gt;&#xA;    &amp;lt;section id=&quot;foo&quot;&amp;gt;&#xA;        ....&#xA;    &amp;lt;/section&amp;gt; &#xA;&amp;lt;/main&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29117" LastActivityDate="2020-04-22T11:06:49.700" Title="Is there an instant way of editing matching inner tags?" Tags="|search|filetype-html|custom-text-object|filetype-xml|plugin-matchit|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24763" PostTypeId="2" ParentId="24757" CreationDate="2020-04-22T09:36:25.153" Score="3" Body="&lt;p&gt;It's really not that complicated, you don't even need &lt;code&gt;regex&lt;/code&gt; for this to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;bs&amp;gt; &amp;lt;sid&amp;gt;remove_pair()&#xA;imap &amp;lt;c-h&amp;gt; &amp;lt;bs&amp;gt;&#xA;&#xA;function s:remove_pair() abort&#xA;  let pair = getline('.')[ col('.')-2 : col('.')-1 ]&#xA;  return stridx('&quot;&quot;''''()[]&amp;lt;&amp;gt;{}', pair) % 2 == 0 ? &quot;\&amp;lt;del&amp;gt;\&amp;lt;c-h&amp;gt;&quot; : &quot;\&amp;lt;bs&amp;gt;&quot;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works by test the current pair string with all pair string, if the result index is even, you are good to go. If you map &lt;code&gt;&amp;lt;bs&amp;gt;&lt;/code&gt;, you should also map &lt;code&gt;&amp;lt;c-h&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also want to use &lt;code&gt;&amp;lt;c-g&amp;gt;U&lt;/code&gt; to reserve undo:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &quot; &quot;&quot;&amp;lt;c-g&amp;gt;U&amp;lt;left&amp;gt;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have used &lt;code&gt;auto-pairs&lt;/code&gt; before, the corner cases is so annoying that I throw it away eventually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;Surround&lt;/code&gt; now, but when I need to type blank pair, I do it by hand, &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; don't count as key stroke IMO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whatever approach you choose to go with, make sure it doesn't surprise you.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-04-22T09:45:30.970" LastActivityDate="2020-04-22T09:45:30.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24764" PostTypeId="2" ParentId="24750" CreationDate="2020-04-22T09:38:31.070" Score="1" Body="&lt;p&gt;Unfortuately, that's not possible, but hey, vimscript is here to help you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Sub(search, replacement, flags)&#xA;    norm!^&#xA;&#xA;    let pos = searchpos(a:search, a:flags.'n')&#xA;&#xA;    exe ':s/'.a:search.'/'.a:replacement.'/'.a:flags&#xA;&#xA;    call setpos('.', [0] + pos + [0])&#xA;&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function acts exactly like &lt;code&gt;:s/.../.../...&lt;/code&gt; except it leaves your cursor on the replaced part&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not perfect, especially if you're used to type &lt;code&gt;:s/....&lt;/code&gt; to replace, but It gets the job done&lt;/p&gt;&#xA;" OwnerUserId="27331" LastActivityDate="2020-04-22T09:38:31.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24765" PostTypeId="2" ParentId="24762" CreationDate="2020-04-22T10:46:21.113" Score="2" Body="&lt;p&gt;I found that something like that is possible with the plugin &lt;code&gt;tpope/vim-surround&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;di█ id=&quot;foo&quot;&amp;gt;&#xA;    &amp;lt;div class=&quot;bar&quot;&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div id=&quot;foo&quot;&amp;gt;&#xA;  █ &amp;lt;div class=&quot;bar&quot;&amp;gt;&amp;lt;/div&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Input: &lt;code&gt;cst&amp;lt;section&lt;/code&gt; | Result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;section id=&quot;foo&quot;&amp;gt;&#xA;  █ &amp;lt;div class=&quot;bar&quot;&amp;gt;&amp;lt;/div&amp;gt;&#xA;&amp;lt;/section&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29117" LastActivityDate="2020-04-22T10:46:21.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24766" PostTypeId="1" AcceptedAnswerId="24801" CreationDate="2020-04-22T10:55:55.467" Score="2" ViewCount="376" Body="&lt;p&gt;I have a strange issue. Sometimes (not every time, but often enough) the startup is extremely slow (ten seconds or more). Most of the time, when I run vim next time, it starts reasonably fast. Then in a few minutes or hours it starts up slowly again, just once. I can never reproduce the issue at will.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to profile vim with &lt;code&gt;--startuptime&lt;/code&gt; option. Normally the output looks like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;079.057  000.613  000.468: sourcing /usr/share/vim/vim80/ftplugin/cpp.vim&#xA;209.450  136.220: opening buffers&#xA;209.540  000.090: BufEnter autocommands&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when the startup is slow, it may look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;077.801  000.340  000.268: sourcing /usr/share/vim/vim80/ftplugin/cpp.vim&#xA;10408.516  10333.252: opening buffers&#xA;10408.686  000.170: BufEnter autocommands&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is always the &quot;opening buffers&quot; line. No other action is abnormally long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The intermittent nature of this slowness makes it very hard to debug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What tools are at my disposal to troubleshoot the issue?&lt;/p&gt;&#xA;" OwnerUserId="24876" LastEditorUserId="24876" LastEditDate="2020-04-22T11:48:31.533" LastActivityDate="2020-04-23T06:01:26.933" Title="Intermittent slow startup" Tags="|startup|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24767" PostTypeId="2" ParentId="24762" CreationDate="2020-04-22T11:06:49.700" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;text-object (say &lt;code&gt;mt&lt;/code&gt;) that selects the name of matching tags?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's hard to think about handling this one with a text object, because a text object is all about &lt;em&gt;selecting&lt;/em&gt; some text and then the operation will act on that selection. There's not really a way to select both matching tags at the same time, or to apply the same operation to both...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, there are ways you can handle that tag replacement. (With or without plug-ins.)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;vim-surround plug-in&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;One plug-in that can help you here is &lt;a href=&quot;https://github.com/tpope/vim-surround&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-surround&lt;/a&gt; by Tim Pope, which includes a &lt;a href=&quot;https://github.com/tpope/vim-surround/blob/v2.1/doc/surround.txt#L41&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;cs&lt;/code&gt;&lt;/a&gt; operation to &quot;change surroundings&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your cursor is anywhere over your &lt;code&gt;&amp;lt;div id=&quot;foo&quot;&amp;gt;&lt;/code&gt;, you can use &lt;code&gt;cst&lt;/code&gt; followed by &lt;code&gt;&amp;lt;section id=&quot;foo&quot;&amp;gt;&lt;/code&gt; to execute your desired replacement. vim-surround is smart to locate the matching closing tag and replace it with &lt;code&gt;&amp;lt;/section&amp;gt;&lt;/code&gt; as you would expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One downside of this approach is that you need to write the whole new tag, including the &lt;code&gt;id=&quot;foo&quot;&lt;/code&gt; attribute that you were keeping from the original tag. For this particular example, it's not &lt;em&gt;that&lt;/em&gt; bad, but it can get quite inconvenient if you have a long list of long attributes...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; From your own answer, I see that using a tag replacement without the ending &lt;code&gt;&amp;gt;&lt;/code&gt; will preserve the attributes. So using &lt;code&gt;cst&lt;/code&gt; followed by &lt;code&gt;&amp;lt;section&lt;/code&gt; and pressing &quot;Enter&quot; does exactly what you want. That's awesome!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim-surround is very generic, in fact it allows you to manage about all kinds of surroundings... You could even replace the tags with double quotes or with a pair of &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; brackets if you wanted to. So that comes at the cost of its support for tags not going as far as you might have liked it to...&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;using &lt;code&gt;%&lt;/code&gt; from matchit&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;It's true that once you replace a tag, you're no longer able to use &lt;code&gt;%&lt;/code&gt; to jump to the matching closing tag to fix it anymore...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that doesn't mean you can't use it to fix this particular case!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply jump first. Then fix the end tag, and jump back to your previous location (not using the &lt;code&gt;%&lt;/code&gt; motion, but &lt;code&gt;''&lt;/code&gt; or &lt;code&gt;Ctrl+O&lt;/code&gt;) and then replace the matching block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, with the cursor on top of &lt;code&gt;div&lt;/code&gt;, you can use&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;%&lt;/code&gt;: Jump to matching closing tag, cursor will be on &lt;code&gt;/&lt;/code&gt; of &lt;code&gt;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;l&lt;/code&gt;: Move cursor right, inside the &lt;code&gt;div&lt;/code&gt; tag name.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ciw&lt;/code&gt;: Replace a word. To change the tag name.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;section&lt;/code&gt;: Enter the new tag name.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;: Leave insert mode.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-O&amp;gt;&lt;/code&gt;: Move to last cursor position in jump list.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.&lt;/code&gt;: Repeat the last &lt;code&gt;ciw&lt;/code&gt; operation.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You're done!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So while it's true that &lt;code&gt;%&lt;/code&gt; will be broken to get you to the matching tag after you replace one of them, it doesn't mean you can't use it for this purpose, just use it first, while it works, then use a different method to jump back to the original location after it will have stopped working.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;honorable mention: emmet-vim plug-in&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you're editing HTML, you should strongly consider adopting the &lt;a href=&quot;https://github.com/mattn/emmet-vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;emmet-vim&lt;/a&gt; plug-in by Yasuhiro Matsumoto, which makes generating HTML tag structures much easier by allowing you to expand abbreviations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While emmet-vim doesn't seem to have a direct operation to handle this particular case, you should be able to use a combination of removing a tag followed by adding a new tag, or a similar sequence of commands to achieve this particular goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One advantage of emmet-vim over vim-surround is that it's specifically tailored for HTML tags, so you can abbreviate a lot of the syntax and it will expand tags and attributes for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this particular case, using the &lt;code&gt;%&lt;/code&gt; from matchit to find the closing tag and a jump back motion still seems like the best alternative. But for complex HTML manipulation, you'll want emmet-vim.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-22T11:06:49.700" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24768" PostTypeId="2" ParentId="24718" CreationDate="2020-04-22T11:56:41.190" Score="2" Body="&lt;p&gt;To quote the docs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;To control where the new split window goes relative to the current window, use&#xA;the setting:&#xA;&#xA;  let g:miniBufExplBRSplit = 0   &quot; Put new window above&#xA;                                 &quot; current or on the&#xA;                                 &quot; left for vertical split&#xA;  let g:miniBufExplBRSplit = 1   &quot; Put new window below&#xA;                                 &quot; current or on the&#xA;                                 &quot; right for vertical split&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So set it to 0 and you should be good. &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-22T11:56:41.190" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24769" PostTypeId="2" ParentId="24755" CreationDate="2020-04-22T12:20:19.780" Score="2" Body="&lt;p&gt;I’ll add my most common alternatives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use the default &lt;code&gt;:&lt;/code&gt;-editing bindings (&lt;code&gt;:help commandline-editing&lt;/code&gt; or something similar, if anyone has the reference offhand feel free to edit). &lt;code&gt;&amp;lt;C-b&amp;gt;&lt;/code&gt; is beginning, &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; is end, and there are others&lt;/li&gt;&#xA;&lt;li&gt;Use the wonderful &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; if you started a &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;?&lt;/code&gt;, or &lt;code&gt;/&lt;/code&gt; and want to edit like it’s a normal vim buffer. &lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;q:&lt;/code&gt;, &lt;code&gt;q?&lt;/code&gt;, or &lt;code&gt;q/&lt;/code&gt; if you know you need this when you start. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have &lt;code&gt;&amp;lt;leader&amp;gt;;&lt;/code&gt; mapped to &lt;code&gt;q:&lt;/code&gt; so a vim-edited command-line is very quick access. (I prefer not to switch &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;:&lt;/code&gt; in my everyday editing, but I’m considering it.)&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-22T12:20:19.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24770" PostTypeId="2" ParentId="22652" CreationDate="2020-04-22T12:20:42.483" Score="1" Body="&lt;p&gt;You can set &lt;code&gt;'complete'&lt;/code&gt; to &lt;code&gt;kspell,s&lt;/code&gt;, then use &lt;code&gt;CTRL-N&lt;/code&gt; instead of the mappings you referred to. See &lt;code&gt;:h compl-generic&lt;/code&gt; and &lt;code&gt;:h 'complete'&lt;/code&gt; for details&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-22T12:20:42.483" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24771" PostTypeId="2" ParentId="6040" CreationDate="2020-04-22T12:23:40.883" Score="3" Body="&lt;p&gt;I’ll add my most common alternatives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use the default &lt;code&gt;:&lt;/code&gt;-editing bindings (&lt;code&gt;:help commandline-editing&lt;/code&gt; or something similar, if anyone has the reference offhand feel free to edit). &lt;code&gt;&amp;lt;C-b&amp;gt;&lt;/code&gt; is beginning, &lt;code&gt;&amp;lt;C-e&amp;gt;&lt;/code&gt; is end, and there are others&lt;/li&gt;&#xA;&lt;li&gt;Use the wonderful &lt;code&gt;&amp;lt;C-f&amp;gt;&lt;/code&gt; if you started a &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;?&lt;/code&gt;, or &lt;code&gt;/&lt;/code&gt; and want to edit like it’s a normal vim buffer. &lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;q:&lt;/code&gt;, &lt;code&gt;q?&lt;/code&gt;, or &lt;code&gt;q/&lt;/code&gt; if you know you need this when you start. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have &lt;code&gt;&amp;lt;leader&amp;gt;;&lt;/code&gt; mapped to &lt;code&gt;q:&lt;/code&gt; so a vim-edited command-line is very quick access. (I prefer not to switch &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;:&lt;/code&gt; in my everyday editing, but I’m considering it.)&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-22T12:23:40.883" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24772" PostTypeId="2" ParentId="24757" CreationDate="2020-04-22T15:03:41.680" Score="2" Body="&lt;p&gt;I'm maintaining &lt;a href=&quot;https://github.com/LucHermitte/lh-brackets&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-brackets&lt;/a&gt; that provides several things here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;redoable insertion of various pair of brackets&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;adding a new pair is quite easy e.g. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:Brackets &amp;lt;+ +&amp;gt;&#xA;:Brackets &amp;lt;div&amp;gt; &amp;lt;/div&amp;gt; -trigger=&amp;lt;m-d&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;removal of empty pairs on &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; when the cursor is in the middle of the pair (note that it works with the previous (&lt;code&gt;&amp;lt;+|+&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;div&amp;gt;|&amp;lt;/div&amp;gt;&lt;/code&gt;). The removal is redo-friendly as well.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it also takes care of the optional (but activated by default) placeholders&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;various ways to jumps over one or several closing bracket sequences are provided&lt;/li&gt;&#xA;&lt;li&gt;surrounding is also provided, not in a vim way (like Tim Pope's surround plugin), but with more direct actions: just type  &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt;, &lt;code&gt;&amp;lt;leader&amp;gt;[&lt;/code&gt;, &lt;code&gt;''&lt;/code&gt; (double), &lt;code&gt;&quot;&quot;&lt;/code&gt;, etc. to surround the current selection or the current word (or line...)&lt;/li&gt;&#xA;&lt;li&gt;removing bracket pairs around a non empty sequence is also provided (&lt;code&gt;&amp;lt;m-b&amp;gt;&amp;lt;del&amp;gt;&lt;/code&gt; with gvim, I don't remember the default keybinding for vim in terminal)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The only annoying corner cases I haven't solved yet are related to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;unbalanced pairs (when we manually delete the opening or the closing sequence), &lt;/li&gt;&#xA;&lt;li&gt;symmetric pairs (like quotes): When the cursor is in front of a quote, it can be difficult to distinguish whether we want to jump-over the quote (i.e. close the current string), or whether we want to insert a new string.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I don't see any situation were hitting &lt;code&gt;&amp;lt;BS&amp;gt;&lt;/code&gt; in &lt;code&gt;(|)&lt;/code&gt; case is problematic.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2020-04-22T15:08:51.677" LastActivityDate="2020-04-22T15:08:51.677" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24773" PostTypeId="2" ParentId="24753" CreationDate="2020-04-22T15:04:22.447" Score="3" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#range%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;range()&lt;/code&gt;&lt;/a&gt; function, which accepts a second and third optional arguments and can take a negative stride of -1 to iterate backwards:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomSearch()&#xA;  let currentLine = getline(&quot;.&quot;)&#xA;&#xA;  for i in range(len(currentLine) - 1, 0, -1)&#xA;    if currentLine[i] ==# 'a'&#xA;      echo 'found a'&#xA;    endif&#xA;  endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you'll typically want to &lt;a href=&quot;https://learnvimscriptthehardway.stevelosh.com/chapters/22.html#code-defensively&quot; rel=&quot;nofollow noreferrer&quot;&gt;use &lt;code&gt;==#&lt;/code&gt; for your string comparisons&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, as &lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;@ChristianBrabandt&lt;/a&gt; points out, indexing a string with &lt;code&gt;currentLine[col]&lt;/code&gt; will not work with multibyte characters. See &lt;a href=&quot;https://vimhelp.org/eval.txt.html#strchars%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;strchars()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/eval.txt.html#strcharpart%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;strcharpart()&lt;/code&gt;&lt;/a&gt; for functions that would allow you to index characters rather than bytes. But using a regex match is typically the best way to handle multibyte correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: Also pointed out by &lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;@ChristianBrabandt&lt;/a&gt;, using &lt;a href=&quot;https://vimhelp.org/eval.txt.html#split%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;split()&lt;/code&gt;&lt;/a&gt; with a regex of &lt;code&gt;'\zs'&lt;/code&gt; will split a string into individual characters. Using that together with &lt;a href=&quot;https://vimhelp.org/eval.txt.html#reverse%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;reverse()&lt;/code&gt;&lt;/a&gt; allows you to iterate over characters directly. Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomSearch()&#xA;  let currentLine = getline(&quot;.&quot;)&#xA;&#xA;  for c in reverse(split(currentLine, '\zs'))&#xA;    if c ==# 'a'&#xA;      echo 'found a'&#xA;    endif&#xA;  endfor&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-22T17:02:12.160" LastActivityDate="2020-04-22T17:02:12.160" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24774" PostTypeId="2" ParentId="23116" CreationDate="2020-04-22T15:43:07.483" Score="1" Body="&lt;p&gt;I agree any answer to this question will be somehow subjective, but I also agree with Eyal Karin that there may be an objective component too. I've been using the Neovim terminal as my main terminal for at least two years now, maybe more, even while SSH to a remote machine, and despite its rough edges, I cannot go back to a dedicated one, not because my coding experience improved, but my terminal experience is better:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I have all motion and operators to navigate the terminal output and yank text. I can navigate and operate on windows using Vim's default mappings. I can use BRE to search the buffer, and I can jump to a specific file with &lt;code&gt;gf&lt;/code&gt; from the output of a compiler or Git or other tool &lt;/li&gt;&#xA;&lt;li&gt;It is easier to get everything to look and feel the same. Same colour schemes, same status line, same custom mappings&lt;/li&gt;&#xA;&lt;li&gt;Vim's plugins may make sense in the terminal too. I started to use EasyMotion again, mainly to jump to far lines without needing number lines and it's so cool I can use it in the terminal too&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I think all of the above are &quot;objective&quot; advantages, even when some people don't consider them that important. I know tmux users with big configurations won't switch, and it's understandable. Is up to you to decide, and it doesn't hurt to try, even when running it inside Vim inside iTerm may feel a bit redundant (that's what I do and feels that way).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I mentioned before, Neovim's terminal has some rough edges (for example text may disappear from the buffer if the window width is reduced, this is a really ugly one), but the previous features overweight them IMHO. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep in mind that Vim's implementation is different. I don't know how they compare. Probably you can do with it all that I mentioned, and maybe it has less bugs&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-22T15:43:07.483" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24775" PostTypeId="1" CreationDate="2020-04-22T16:45:31.757" Score="1" ViewCount="113" Body="&lt;p&gt;The following python code uses ansi escape sequences to clear the terminal screen and change the text color to red. It then prints &quot;Hello from Vim.&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print ('\033c\033[31m Hello from Vim.')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Vim I use the command &lt;code&gt;:!python3 %&lt;/code&gt; and everything works as expected. It clears the screen and prints in red. However, when I load the same code into Gvim and use the same command I get :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;?c?[31m  Hello from Vim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It neither clears the screen nor prints in red. If from Gvim I split to the terminal with &lt;code&gt;:term&lt;/code&gt; and then enter &lt;code&gt;python3 tester.py&lt;/code&gt;, then code works correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is : Why does the command &lt;code&gt;:!python3 %&lt;/code&gt; not work the same in Gvim as it does in Vim when it comes to ansi escape codes and what can I do to correct that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your assistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;Additionally when I run this python script in Gvim :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i = input ('test: ')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and try to use the Backspace key to change the input, I get &lt;strong&gt;^H&lt;/strong&gt; printed out instead of the cursor backing over the input.&lt;/p&gt;&#xA;" OwnerUserId="28787" LastEditorUserId="28787" LastEditDate="2020-04-24T20:11:41.433" LastActivityDate="2020-04-24T20:11:41.433" Title="Why does Gvim treat ansi escape codes differently than Vim in python code?" Tags="|command-line|gvim|python|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24776" PostTypeId="2" ParentId="24753" CreationDate="2020-04-22T17:57:52.457" Score="2" Body="&lt;p&gt;I would start from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo match(reverse(split(getline('.')[:col('.')-2], '\zs')), the_char)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that is likely to be much more efficient than any loop in vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, what is the exact objective? There are many more possibilities depending on what you are exactly looking for: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a boolean that indicates whether there is one char? (=&gt; no need to reverse)&lt;/li&gt;&#xA;&lt;li&gt;a character position? (=&gt; subtract the previous result from the list length)&lt;/li&gt;&#xA;&lt;li&gt;a cursor position (they may not be the same because of tab and of multi-bytes characters)?&lt;/li&gt;&#xA;&lt;li&gt;a substring? (a &lt;code&gt;matchstr(getline('.')[:col('.')-2], escape(the_char, '.*\^$[').'[^'.the_char.']*$')&lt;/code&gt; should do it -- not 100% sure about all the characters that need to be escaped) The performance of this solution should be compared against split|reverse|match.&lt;/li&gt;&#xA;&lt;li&gt;to move the cursor? (=&gt; use &lt;code&gt;search()&lt;/code&gt; or  &lt;code&gt;:exe &quot;normal! T&quot;.thechar&lt;/code&gt;/&lt;code&gt;:normal F&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2020-04-22T18:11:35.390" LastActivityDate="2020-04-22T18:11:35.390" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24777" PostTypeId="1" AcceptedAnswerId="24778" CreationDate="2020-04-22T18:05:43.377" Score="3" ViewCount="3240" Body="&lt;p&gt;I'd like to read the contents of a file, and put this into a variable - so I can later use it in a command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this? &lt;/p&gt;&#xA;" OwnerUserId="13656" LastActivityDate="2020-04-22T18:10:58.367" Title="How to read a file into a variable vimscript?" Tags="|vimscript|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24778" PostTypeId="2" ParentId="24777" CreationDate="2020-04-22T18:10:58.367" Score="5" Body="&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/eval.txt.html#readfile%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help readfile()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Read file &lt;code&gt;{fname}&lt;/code&gt; and return a |List|, each line of the file as an item. Lines are broken at NL characters. [...]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As general advice, try to get familiar with Vim's help system. In the beginning, it might be hard to find what you need in there, but once you get used to it, it's a very powerful way to quickly find what you need.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-22T18:10:58.367" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24779" PostTypeId="1" AcceptedAnswerId="24781" CreationDate="2020-04-22T20:12:51.370" Score="2" ViewCount="688" Body="&lt;p&gt;I am trying to create a macro which reproduces the behaviour of CtrlP as in this webpage: &lt;a href=&quot;https://www.edwinwenink.xyz/posts/48-vim_fast_creating_and_linking_notes/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.edwinwenink.xyz/posts/48-vim_fast_creating_and_linking_notes/&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, even if fzf can easily select a file, I don't know how to get its result inside a function so as to insert a snippet (a markdown link in this case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas ?  Thanks&lt;/p&gt;&#xA;" OwnerUserId="29126" LastActivityDate="2020-04-22T20:39:41.627" Title="How can I get a path with fzf.vim and use to insert a snippet?" Tags="|fzf|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24780" PostTypeId="1" AcceptedAnswerId="24784" CreationDate="2020-04-22T20:16:59.143" Score="1" ViewCount="190" Body="&lt;p&gt;What are the possible uses of the &lt;code&gt;inner-something&lt;/code&gt; command in vim? For example, the following three items work:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ci)&lt;/code&gt; in &lt;code&gt;(&quot;hello&quot;)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ci'&lt;/code&gt; in &lt;code&gt;'hello'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ci]&lt;/code&gt; in &lt;code&gt;([var])&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But the following two do not:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ci#&lt;/code&gt; in &lt;code&gt;# TODO #&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ci&quot;&lt;/code&gt; in:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot;&#xA;This is a python docstring.&#xA;&quot;&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What are the various limitations then or possibilities in using the &lt;code&gt;i&lt;/code&gt; (as in &quot;inner&quot;) command?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-22T22:49:41.820" Title="Inner-object possibilities" Tags="|object-motions|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24781" PostTypeId="2" ParentId="24779" CreationDate="2020-04-22T20:39:41.627" Score="1" Body="&lt;p&gt;You can do something like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HandleFZF(file)&#xA;    echo a:file&#xA;endfunction&#xA;command! -nargs=1 HandleFZF :call HandleFZF(&amp;lt;f-args&amp;gt;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, to invoke fzf, run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call fzf#run({'sink': 'HandleFZF'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27331" LastActivityDate="2020-04-22T20:39:41.627" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24782" PostTypeId="1" CreationDate="2020-04-22T21:55:30.040" Score="1" ViewCount="55" Body="&lt;p&gt;As background: I am a beginner in VIM and I want to go through the built-in vim manual, but with my own copy (not the system copy) so that I can practice in the manual text as I go along  (I also bought the book Practical VIM and went through vimtutor). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this I went to the location where these manuals are located: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/local/cellar/macvim/8.1-161/MacVim.app/Contents/Resources/vim/runtime/doc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and copied the contents to a directory in my documents directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo cp * ~/Documents/vim_learning/vim_doc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I want to navigate this documentation using &lt;code&gt;ctl-]&lt;/code&gt; and &lt;code&gt;ctl-o&lt;/code&gt; but I can't in the versions I copied, and also when I just open a copy in the main &lt;code&gt;doc&lt;/code&gt; folder using vim.  I get &lt;code&gt;E426 tag not found: foo&lt;/code&gt; error. Of course can navigate like I want to when I use the &lt;code&gt;:help user-manual&lt;/code&gt; command. To get around this I presumed that I had to tell vim to use the tags file tried adding &lt;code&gt;set tags=./tags;&lt;/code&gt; to my vimrc, which I verified was working by adding and removing lines to change the color scheme. This did not work. Is there any quick way to make these navigation tags work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running this vim version:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar  3 2020 12:05:00)&#xA;macOS version&#xA;Included patches: 1-319&#xA;Compiled by travis@Traviss-Mac.local  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and path_extra feature is enabled. &#xA;I am running it in the mac terminal with this alias set in my .zshrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alias vi='mvim -v'&#xA;alias vim='mvim -v'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29128" LastActivityDate="2020-04-22T21:55:30.040" Title="How do I navigate using tags in a personal copy of the vim documentation?" Tags="|macvim|tags|navigation|" AnswerCount="0" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24783" PostTypeId="1" AcceptedAnswerId="24800" CreationDate="2020-04-22T22:25:33.427" Score="3" ViewCount="932" Body="&lt;pre&gt;&lt;code&gt;  execute &quot;normal! :echo &quot;. system('echo hello')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above results in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E121: Undefined variable: hello &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why? I'm expecting it to evaluate as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  execute &quot;normal! :echo hello&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13656" LastActivityDate="2020-04-23T05:55:52.940" Title="Execute with system function results in error of `undefined variable`" Tags="|vimscript|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24784" PostTypeId="2" ParentId="24780" CreationDate="2020-04-22T22:49:41.820" Score="2" Body="&lt;p&gt;All of the text-objects are documented under &lt;code&gt;:help text-objects&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Excerpted from &lt;code&gt;:help objects&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;|v_iquote|  i&quot;         double quoted string without the quotes&#xA;|v_i'|      i'         single quoted string without the quotes&#xA;|v_i(|      i(         same as ib&#xA;|v_i)|      i)         same as ib&#xA;|v_i&amp;lt;|      i&amp;lt;         &quot;inner &amp;lt;&amp;gt;&quot; from '&amp;lt;' to the matching '&amp;gt;'&#xA;|v_i&amp;gt;|      i&amp;gt;         same as i&amp;lt;&#xA;|v_iB|      iB         &quot;inner Block&quot; from &quot;[{&quot; and &quot;]}&quot;&#xA;|v_iW|      iW         &quot;inner WORD&quot;&#xA;|v_i[|      i[         &quot;inner []&quot; from '[' to the matching ']'&#xA;|v_i]|      i]         same as i[&#xA;|v_i`|      i`         string in backticks without the backticks&#xA;|v_ib|      ib         &quot;inner block&quot; from &quot;[(&quot; to &quot;])&quot;&#xA;|v_ip|      ip         &quot;inner paragraph&quot;&#xA;|v_is|      is         &quot;inner sentence&quot;&#xA;|v_it|      it         &quot;inner tag block&quot;&#xA;|v_iw|      iw         &quot;inner word&quot;&#xA;|v_i{|      i{         same as iB&#xA;|v_i}|      i}         same as iB&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-22T22:49:41.820" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24785" PostTypeId="1" CreationDate="2020-04-23T00:28:34.957" Score="1" ViewCount="20" Body="&lt;p&gt;I am tryng to use &lt;a href=&quot;https://github.com/terryma/vim-multiple-cursors&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/terryma/vim-multiple-cursors&lt;/a&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Default mapping&#xA;let g:multi_cursor_start_word_key      = '&amp;lt;C-n&amp;gt;'&#xA;let g:multi_cursor_select_all_word_key = '&amp;lt;A-n&amp;gt;'&#xA;let g:multi_cursor_start_key           = 'g&amp;lt;C-n&amp;gt;'&#xA;let g:multi_cursor_select_all_key      = 'g&amp;lt;A-n&amp;gt;'&#xA;let g:multi_cursor_next_key            = '&amp;lt;C-n&amp;gt;'&#xA;let g:multi_cursor_prev_key            = '&amp;lt;C-p&amp;gt;'&#xA;let g:multi_cursor_skip_key            = '&amp;lt;C-x&amp;gt;'&#xA;let g:multi_cursor_quit_key            = '&amp;lt;Esc&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does each of these mean? I presses Ctrl + n, and nothing gets selected. What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="11753" LastActivityDate="2020-04-23T00:28:34.957" Title="How to set vim keymappings?" Tags="|vimrc|" AnswerCount="0" CommentCount="0" ClosedDate="2020-04-23T19:59:40.460" ContentLicense="CC BY-SA 4.0" />
  <row Id="24786" PostTypeId="2" ParentId="24783" CreationDate="2020-04-23T01:16:39.663" Score="2" Body="&lt;p&gt;The bug is not in the first command, but in the second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just run the Ex command directly, you get the same E121 error about undefined variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo hello&#xA;E121: Undefined variable: hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So what's wrong with the second command? Well, you're missing a &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; there to actually execute the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3Anormal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :normal&lt;/code&gt;&lt;/a&gt; states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;{commands}&lt;/code&gt; should be a complete command.  If &lt;code&gt;{commands}&lt;/code&gt; does not finish a command, &lt;strong&gt;the last one will be aborted as if &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-C&amp;gt;&lt;/code&gt; was typed.&lt;/strong&gt;  This implies that an insert command must be completed.  &lt;strong&gt;A &quot;:&quot; command must be completed as well.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can reproduce the same error with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:execute &quot;normal! :echo hello\&amp;lt;CR&amp;gt;&quot;&#xA;E121: Undefined variable: hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is actually equivalent to the command that uses &lt;code&gt;system()&lt;/code&gt;, since &lt;code&gt;system()&lt;/code&gt; will actually preserve the newline added by the &lt;code&gt;echo&lt;/code&gt; command. You can see that with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo strtrans(system('echo hello'))&#xA;hello^@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;^@&lt;/code&gt; is normally a NUL byte, but it's how Vim represents a newline internally. If you just &lt;code&gt;:echo&lt;/code&gt; the result of that &lt;code&gt;system()&lt;/code&gt; command you will notice a newline at the end, just it's not as visible as with &lt;code&gt;strtrans()&lt;/code&gt; since it's, well, a newline.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So all in all this error is expected, it's only omitted from your second example because that Ex command is being cancelled as it's incomplete.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-23T01:16:39.663" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24787" PostTypeId="1" AcceptedAnswerId="24789" CreationDate="2020-04-23T02:22:29.140" Score="22" ViewCount="9226" Body="&lt;p&gt;Is there a way to delete a full line and start with an insert? Normally I would do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; (go to start of line)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C&lt;/code&gt; (delete to end of line and start insert)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But is there a command to do the above without having to first enter the &lt;code&gt;0&lt;/code&gt;? Normally it's something like &lt;code&gt;ciw&lt;/code&gt; or so to delete the 'wrapping' stuff (in this case the wrap is the line break).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best I've gotten so far is now:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;-&lt;kbd&gt;v&lt;/kbd&gt; (go to visual line mode)&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;c&lt;/kbd&gt; (change at the start)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="10604" LastEditDate="2020-04-25T21:54:44.687" LastActivityDate="2020-04-25T21:54:44.687" Title="Change an entire line in Vim" Tags="|normal-mode|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24788" PostTypeId="2" ParentId="24787" CreationDate="2020-04-23T03:15:51.130" Score="14" Body="&lt;p&gt;&lt;code&gt;cc&lt;/code&gt; does what you want, I think?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help cc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&quot;x]cc      Delete [count] lines [into register x] and start&#xA;            insert |linewise|.  If 'autoindent' is on, preserve&#xA;            the indent of the first line.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="51" LastActivityDate="2020-04-23T03:15:51.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24789" PostTypeId="2" ParentId="24787" CreationDate="2020-04-23T03:16:38.997" Score="48" Body="&lt;p&gt;In the same way that &lt;code&gt;yy&lt;/code&gt; copies the current line and &lt;code&gt;dd&lt;/code&gt; deletes it, you can use &lt;code&gt;cc&lt;/code&gt; to change it (i. e. yank it, delete it and enter insert mode). &lt;code&gt;S&lt;/code&gt; is a synonym for &lt;code&gt;cc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="786" LastEditorUserId="2347" LastEditDate="2020-04-24T07:47:00.423" LastActivityDate="2020-04-24T07:47:00.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24790" PostTypeId="1" AcceptedAnswerId="24809" CreationDate="2020-04-23T03:23:16.443" Score="2" ViewCount="1316" Body="&lt;p&gt;Is it possible for vim navigation to be as quick as a normal point-and-click navigation? For example, I've taken the following example here where I've created four points that need to be clicked:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gLkBq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gLkBq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without any practice or thinking, I'm able to click those four points in 3.9 seconds, video &lt;a href=&quot;https://gyazo.com/da9546cbd4b144229fa790ab7eeaeaa0&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. What would be the fastest that someone could get to those four locations in vim? I mean if someone were not to &quot;think about it&quot;, i.e., just given four random points spaced across a screen what would be the fastest way to get there (fastest, as in lowest amount of time, not fewest keystrokes)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am a vim beginner, and my first attempt took about 40s (!!) -- &lt;a href=&quot;https://gyazo.com/377ca4a30a12c0814ad8b6255b761075&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gyazo.com/377ca4a30a12c0814ad8b6255b761075&lt;/a&gt;. Mostly due to trying to do a search and it basically starting from the top of the document every time. What would be some ways that this can be improved? Note: it seems like I had a bad search option (it was starting from the top of the file), so when I fixed that I was able to click the four points in about ~13.5s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If helpful, here's the method if someone wants to use that for their answer (can insert ~1500 blank lines above the method):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def build_data(self, build_data=True):&#xA;        processing_start_time = time.time()&#xA;        log.info('Building data...')&#xA;&#xA;        self.begin_build_data()&#xA;&#xA;        if build_data is True:&#xA;            self.pre_build_data()&#xA;            self.update_status('URLS')&#xA;            self._build_data()&#xA;            self.post_build_data()&#xA;&#xA;        # Sample the Data to make sure it's OK -- underscores ignored&#xA;        ACCEPTABLE_KEYS = set(['Platform', 'ArtworkURL', 'BaseURL', 'CollectionTitleIDs', 'Credits', 'CustomerRatingAverage', 'CustomerRatingVolume', 'EpisodeNumber', 'Genres', 'LanguageOfMetadata', 'Languages', 'Locales', 'Name', 'PlatformID', 'Products', 'ReleaseDate', 'ReleaseYear', 'RuntimeInMinutes', 'SeasonNumber', 'Studio', 'Synopsis', 'TVSeriesID', 'TrailerURL', 'Type', 'HighestResolution'])&#xA;        for num, key in enumerate(self.data):&#xA;            if unicode(key).startswith('_'): continue&#xA;            if num % 20 == 0:&#xA;                keys = set([i for i in self.data[key].keys() if not i.startswith('_')])&#xA;                bad_keys = keys - ACCEPTABLE_KEYS&#xA;                if len(bad_keys) &amp;gt; 0:&#xA;                    print bad_keys, key, keys&#xA;                    raise('Bad Keys Found!')&#xA;&#xA;        log.info('Finished building data in %s' % (time.time() - processing_start_time))&#xA;&#xA;        self.create_sorted_keys()&#xA;&#xA;        try:&#xA;            items, avails = self.get_number_items_and_avails()&#xA;        except:&#xA;            pass # PS resets IP and breaks this.&#xA;&#xA;        data_file = '%s_%s.txt' % (self.date_stem, self.platform.lower())&#xA;        log.info('Writing data to %s...' % data_file)&#xA;&#xA;        self._write_data(archive=False)&#xA;        self.update_status('Saved')&#xA;&#xA;        self.end_build_data()&#xA;&#xA;        log.info('%.4fs to build data' % (time.time() - processing_start_time))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="28904" LastEditDate="2020-04-23T05:21:13.810" LastActivityDate="2020-04-23T21:19:32.807" Title="Fastest way to navigate various points in vim" Tags="|navigation|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24791" PostTypeId="1" AcceptedAnswerId="24795" CreationDate="2020-04-23T03:24:43.577" Score="2" ViewCount="626" Body="&lt;p&gt;I'm trying to create an abbreviation with the command &lt;code&gt;ab&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if I type &lt;code&gt;if (&lt;/code&gt; under INSERT mode, I want some piece of code to be printed immediately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ab if&amp;lt;Space&amp;gt;( if&amp;lt;Space&amp;gt;()&amp;lt;Space&amp;gt;{&amp;lt;CR&amp;gt;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I always get an error: &lt;code&gt;E474: Invalid argument&lt;/code&gt;. It seems that &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt; causes some error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to create an abbreviation with &lt;code&gt;&amp;lt;Space&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-04-23T18:05:53.417" Title="How to create an abbreviation with space" Tags="|functions|abbreviations|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24792" PostTypeId="1" AcceptedAnswerId="24798" CreationDate="2020-04-23T03:44:09.080" Score="2" ViewCount="1068" Body="&lt;p&gt;I want to copy contents of the recently used &lt;code&gt;&quot;&lt;/code&gt; register automatically into my system clipboard after a yank command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I achieve this now is by &lt;code&gt;nnoremap &amp;lt;C-@&amp;gt; :call system(&quot;wl-copy&quot;, @&quot;)&amp;lt;CR&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;wl-copy&lt;/code&gt; is a &lt;a href=&quot;https://github.com/bugaevc/wl-clipboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;Command-line copy/paste utilities for Wayland&lt;/a&gt; and it will copy the input you give it to system clipboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What my mapping above achieves is&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;take the contents of the &lt;code&gt;&quot;&lt;/code&gt; register, &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;denoted by the &lt;code&gt;@&quot;&lt;/code&gt; argument&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and pass contents of &lt;code&gt;@&quot;&lt;/code&gt; as an argument to the system &lt;code&gt;wl-copy&lt;/code&gt; function&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;shown by &lt;code&gt;:call system(&quot;wl-copy&quot;, @&quot;)&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But it requires me to press &lt;code&gt;Ctrl + @&lt;/code&gt; when I want to populate my system clipboard with contents of the &lt;code&gt;&quot;&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I automatically execute &lt;code&gt;:call system(&quot;wl-copy&quot;, @&quot;)&lt;/code&gt; after a yank command successfully finishes (I'd like to preserve &lt;code&gt;y{motion}&lt;/code&gt; but not have to continuously poll to see if the &lt;code&gt;&quot;&lt;/code&gt; register changed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other solutions that achieve this effect are welcome.&lt;/p&gt;&#xA;" OwnerUserId="19213" LastActivityDate="2020-04-23T06:29:02.523" Title="How to automatically perform a command after yanking text [Vim wayland clipboard]" Tags="|cut-copy-paste|os-clipboard|wayland|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24793" PostTypeId="1" AcceptedAnswerId="24796" CreationDate="2020-04-23T03:49:49.400" Score="4" ViewCount="442" Body="&lt;p&gt;For example, I have the following code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range Test call TestFunc()&#xA;function! TestFunc() abort&#xA;  &quot; if run with range&#xA;  &quot;   get selected content&#xA;  &quot; else&#xA;  &quot;   get current word under the cursor&#xA;  &quot; endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to differentiate whether users run &lt;code&gt;:Test&lt;/code&gt; or &lt;code&gt;:'&amp;lt;,'&amp;gt;Test&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tested &lt;code&gt;mode()&lt;/code&gt; function doesn't work here. Also &lt;code&gt;&amp;lt;line1&amp;gt;&lt;/code&gt;,&lt;code&gt;&amp;lt;line2&amp;gt;&lt;/code&gt; do not help because they always give me the same result(current line number) when I run it with range(select the current line) or not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if there are any solutions for this?&lt;/p&gt;&#xA;" OwnerUserId="17515" LastActivityDate="2020-04-23T05:11:27.420" Title="How to check whether a command is run with range or not?" Tags="|vimscript|command-line|visual-mode|functions|range|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24794" PostTypeId="1" AcceptedAnswerId="24797" CreationDate="2020-04-23T04:50:12.527" Score="6" ViewCount="1956" Body="&lt;p&gt;I like the simple auto completion provided by &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;N&lt;/kbd&gt; but not typing &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;N&lt;/kbd&gt; everytime to get the completion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like it to work similar to how &lt;a href=&quot;https://github.com/ycm-core/YouCompleteMe&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouCompleteMe&lt;/a&gt; works with automatic suggestions. If possible, I would also like to cycle through the completion menu with &lt;kbd&gt;Tab&lt;/kbd&gt; without losing the functionality to indent.&lt;/p&gt;&#xA;" OwnerUserId="29130" LastEditorUserId="10604" LastEditDate="2020-04-23T13:43:03.677" LastActivityDate="2020-04-24T13:22:01.547" Title="How to get auto completion provided by &lt;C-N&gt; without typing &lt;C-N&gt;?" Tags="|autocompletion|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24795" PostTypeId="2" ParentId="24791" CreationDate="2020-04-23T05:05:19.913" Score="2" Body="&lt;p&gt;This is not directly possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/map.txt.html#abbreviations&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help abbreviations&lt;/code&gt;&lt;/a&gt; which talks about the three types of abbreviations, but even the (least restrictive) &quot;non-id&quot; type mentions &lt;em&gt;&quot;the other characters may be of any type, excluding space and tab.&quot;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And also:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Examples of strings that cannot be abbreviations: &lt;code&gt;a.b&lt;/code&gt;, &lt;code&gt;#def&lt;/code&gt;, &lt;strong&gt;&lt;code&gt;a b&lt;/code&gt;&lt;/strong&gt;, &lt;code&gt;_$r&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can work around this, by using an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; abbreviation that triggers a function that checks the words preceding the one currently being abbreviated and decide to expand it or not (not expanding it means expanding it to the same text.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But even that doesn't really help much in your particular case, since &lt;em&gt;&quot;an abbreviation is only recognized when you type a non-keyword character.&quot;&lt;/em&gt; So you would have to expect a symbol or whitespace after the &lt;code&gt;(&lt;/code&gt; to trigger the abbreviation, but you're quite likely to find a variable name or function call there, which would be an alphanumeric character and would &lt;em&gt;not&lt;/em&gt; expand and abbreviation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps a more convenient way to handle this is to use an &lt;code&gt;inoremap&lt;/code&gt;, since that will trigger when the key itself is pressed and not after the whole word is entered as a word. You could use an &lt;code&gt;inoremap &amp;lt;expr&amp;gt; ( ...&lt;/code&gt; to trigger the mapping when the &lt;code&gt;(&lt;/code&gt; is typed, then check whether it's preceded by an &lt;code&gt;if&lt;/code&gt; word and, in that case, expand the sequence you wanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vi.stackexchange.com/q/20515/18609&quot;&gt;this answer&lt;/a&gt; for an &lt;code&gt;iabbrev &amp;lt;expr&amp;gt;&lt;/code&gt; that inspects the preceding word when deciding whether to expand an abbreviation, and &lt;a href=&quot;https://vi.stackexchange.com/a/20966/18609&quot;&gt;this answer&lt;/a&gt; for an advanced use of &lt;code&gt;inoremap &amp;lt;expr&amp;gt;&lt;/code&gt; that might be somewhat similar to yours.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But if you're &lt;em&gt;really&lt;/em&gt; serious about having Vim type your code for you, you should really look into a snippet engine such as &lt;a href=&quot;https://github.com/SirVer/ultisnips&quot; rel=&quot;nofollow noreferrer&quot;&gt;UltiSnips&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UltiSnips allows you to define your snippets using a much higher level templating language and it takes care of the low-level details such as the Vim mappings needed to make the snippets work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also allows you to define &quot;fields&quot; through markers in your templates, which you'll find you &lt;em&gt;really&lt;/em&gt; need for a template to an &lt;code&gt;if&lt;/code&gt; or a &lt;code&gt;for&lt;/code&gt;, since you typically want to enter one or more expressions before the cursor lands in the inner code block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd seriously recommend that you'd take a look into it.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-23T05:05:19.913" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24796" PostTypeId="2" ParentId="24793" CreationDate="2020-04-23T05:11:27.420" Score="7" Body="&lt;p&gt;A range with commands is always about lines. It seems you want to work with line/column positions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whether a range was given can be checked by using &lt;code&gt;&amp;lt;range&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range Test call TestFunc(&amp;lt;range&amp;gt;,&amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;)&#xA;function! TestFunc(r,l1,l2) abort&#xA;    if a:r == 0&#xA;        echo &quot;No range&quot;&#xA;    elseif a:r == 1&#xA;        echo &quot;Single Line given (like :22Test)&quot;&#xA;    else&#xA;        echo &quot;Line range given (like 1,23Test, '&amp;lt;,'&amp;gt;Test or %Test)&quot;&#xA;    endif&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: You might need to &lt;code&gt;set cmdheight=2&lt;/code&gt; to see the echo in all cases.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2020-04-23T05:11:27.420" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24797" PostTypeId="2" ParentId="24794" CreationDate="2020-04-23T05:19:44.063" Score="4" Body="&lt;p&gt;Take a look at the &lt;a href=&quot;https://github.com/othree/vim-autocomplpop&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-autocomplpop&lt;/a&gt; plug-in, which triggers the completion menu automatically as you type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For using &quot;Tab&quot; instead of Ctrl+N &lt;strong&gt;in&lt;/strong&gt; the completion menu, you can use a simple mapping such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;Tab&amp;gt; pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; : &quot;\&amp;lt;Tab&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As an alternative, you might want to consider the &lt;a href=&quot;https://github.com/ervandew/supertab&quot; rel=&quot;nofollow noreferrer&quot;&gt;SuperTab&lt;/a&gt; plug-in. It doesn't really do &quot;as-you-type&quot; completion and requires you to use the &quot;Tab&quot; key to initiate completion, but it's quite powerful and it has nice features you might like. (Note that I wouldn't expect SuperTab to work well with autocomplpop, so you might be able to pick one or the other, unlikely to be able to pick both.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-23T05:19:44.063" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24798" PostTypeId="2" ParentId="24792" CreationDate="2020-04-23T05:40:33.127" Score="3" Body="&lt;p&gt;You can use a &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#TextYankPost&quot; rel=&quot;nofollow noreferrer&quot;&gt;TextYankPost&lt;/a&gt; autocmd to trigger the copy to system clipboard whenever text is yanked into a register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A very simple version of that is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup wayland_clipboard&#xA;  au!&#xA;  au TextYankPost * call system(&quot;wl-copy&quot;, @&quot;)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will trigger the operation whenever a yank into &lt;em&gt;any&lt;/em&gt; register happens, which is a bit wasteful but probably not too bad... You can refine it by inspecting which register was yanked into from the &lt;code&gt;v:event&lt;/code&gt; special variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#TextYankPost&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help TextYankPost&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/eval.txt.html#v%3Aevent&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help v:event&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-23T05:40:33.127" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24800" PostTypeId="2" ParentId="24783" CreationDate="2020-04-23T05:55:52.940" Score="4" Body="&lt;p&gt;There are a couple of problems here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, you want to run an ex command, so you don't need the &lt;code&gt;:norm!&lt;/code&gt; command to execute an &lt;strong&gt;ex&lt;/strong&gt; command. A simple &lt;code&gt;:echo&lt;/code&gt; works. &#xA;(In fact, you can and probably should get rid of the &lt;code&gt;:exe&lt;/code&gt; command and use &lt;code&gt;:echo&lt;/code&gt; directly, but I'll come back to this later).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, if you want to see what will be executed, use &lt;code&gt;:echo&lt;/code&gt; instead of &lt;code&gt;:exe&lt;/code&gt;. So this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;:echo &quot;. system('echo hello')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will output &lt;code&gt;:echo hello&lt;/code&gt;. So what is the problem here? Have a look at the documentation at &lt;a href=&quot;https://vimhelp.org/eval.txt.html#:echo&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :echo&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;:ec[ho] {expr1} ..      Echoes each {expr1}, with a space in between.  The&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note the word &lt;code&gt;expr1&lt;/code&gt;. So &lt;code&gt;:echo&lt;/code&gt; expects an expression. What that means is, either a variable, or a &lt;strong&gt;quoted&lt;/strong&gt; string (or some other special types like numbers, options, etc, see again the help at &lt;a href=&quot;https://vimhelp.org/eval.txt.html#expression-syntax&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h expression-syntax&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the way &lt;code&gt;hello&lt;/code&gt; is used, &lt;code&gt;:echo&lt;/code&gt; expects it to be a variable. But Vim cannot find a variable called &lt;code&gt;hello&lt;/code&gt;, because it does not exist. So try this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :let g:hello='Hello my dear'&#xA; :exe ':echo ' system('echo hello')&#xA; Hello my dear&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, since you are using string concatenation, to concatenate the output of the &lt;code&gt;system()&lt;/code&gt; function with the &lt;code&gt;:echo&lt;/code&gt; command. However, if you get rid of the indirection and simply use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:echo system('echo hello')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can see directly the result of the echo system command. Because in this case, echo knows that the &lt;code&gt;system('echo hello')&lt;/code&gt; command is a correct expression and it will simply output the result.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2020-04-23T05:55:52.940" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24801" PostTypeId="2" ParentId="24766" CreationDate="2020-04-23T06:01:26.933" Score="2" Body="&lt;p&gt;Run vim under &lt;code&gt;strace&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a wrapper binary called &lt;code&gt;vim&lt;/code&gt; in your home directory (e.g. &lt;code&gt;~/bin/vim&lt;/code&gt; or &lt;code&gt;~/.local/bin/vim&lt;/code&gt;) and make sure that directory comes first in &lt;code&gt;$PATH&lt;/code&gt;. If you start Vim as &lt;code&gt;vi&lt;/code&gt; or other names, create similar wrappers too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the contents of the wrapper script, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;exec strace -f -tt -s 1024 -o /tmp/strace.vim.$(date +%s).$$ /usr/bin/vim ${1+&quot;$@&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure you make the script executable, with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ chmod +x ~/bin/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Test it to make sure it works, then check that these &lt;code&gt;/tmp/strace.vim.*&lt;/code&gt; files are being created as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next time you have a 10s delay, look at the strace files under &lt;code&gt;/tmp&lt;/code&gt; and find the one corresponding to the invocation that had the delay (it should be the last one and they should be listed in chronological order), then see if that sheds a light into what is delaying your startup. If it's anything related to filesystems or reading or looking up files, it will probably show up there. (On the other hand, if it's an issue that is triggering the CPU to go spinning for that amount of time, that typically won't show on strace. But I think your chances are good that it will show there.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have some overhead of running Vim under strace all the time, which isn't great but I wouldn't expect it to be &lt;em&gt;too&lt;/em&gt; painful...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Diskspace might be a problem as the strace files start to accumulate and grow in your &lt;code&gt;/tmp&lt;/code&gt; directory. You might want to consider adding a &lt;code&gt;tmpwatch&lt;/code&gt; configuration to prune those files somewhat aggressively to prevent them to filling up your disk. (Also consider whether &lt;code&gt;/tmp&lt;/code&gt; is the best location on your system to store those, quite possibly a different location will work better in your system.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully this will help you identify the root cause, or at least give you additional data points that you can use to narrow it down.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-23T06:01:26.933" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24802" PostTypeId="2" ParentId="24794" CreationDate="2020-04-23T06:26:19.013" Score="3" Body="&lt;p&gt;You can get completions as you type with &lt;a href=&quot;https://github.com/lifepillar/vim-mucomplete&quot; rel=&quot;nofollow noreferrer&quot;&gt;MUconplete&lt;/a&gt;. For me the advantage over similar plugins is that it is lightweight, doesn’t have dependencies (is pure Vim script) and although it only cares about Vim native sources it works quite well if you hook an LSP to &lt;code&gt;omnifunc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To manually trigger the menu, MUcomplete maps Tab, but you can override that. I never use them. Once the menu is open you can navigate with Tab and Shift+Tab without problems &lt;/p&gt;&#xA;" OwnerUserId="786" LastEditorUserId="786" LastEditDate="2020-04-24T13:22:01.547" LastActivityDate="2020-04-24T13:22:01.547" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24803" PostTypeId="2" ParentId="24790" CreationDate="2020-04-23T08:56:32.680" Score="1" Body="&lt;p&gt;Here's what i did to reach the 4 points:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given I start from the 1st point,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;/Coll&amp;lt;ENTER&amp;gt;tT&lt;/code&gt;&lt;br&gt;&#xA;Just basic searching, and then using &lt;code&gt;t&lt;/code&gt; to reach the next occurrence of a specific character on the same line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;1600G&lt;/code&gt;&lt;br&gt;&#xA;Move to the line number 1600, The cursor is already a the end of the line. It might be easier if you have the option &lt;code&gt;relativenumber&lt;/code&gt; set, so that you can hit &lt;code&gt;7j&lt;/code&gt; or &lt;code&gt;7&amp;lt;DOWN&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;GB&lt;/code&gt;&lt;br&gt;&#xA;The &lt;code&gt;G&lt;/code&gt; brings me to the end of the last line, and &lt;code&gt;B&lt;/code&gt;, to the first white space preceding the cursor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I was able to do this in around 5 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's my flow without thinking, but there are a thousand ways to do those moves, and half of them would be faster than what I did I'm sure!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some other that I usually use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;H&lt;/code&gt;, &lt;code&gt;M&lt;/code&gt; and &lt;code&gt;L&lt;/code&gt; to go to the top, middle and bottom of the current view&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;[(&lt;/code&gt; and &lt;code&gt;])&lt;/code&gt; to go to the beginning / end of the current paragraph&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;[{&lt;/code&gt; and &lt;code&gt;]}&lt;/code&gt; to go to the opening brace before the cursor, or closing after the cursor (useless with a language like python)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Plugins&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If the native vim motions are not enough for you, there are some great plugins that could help you, &lt;a href=&quot;https://github.com/easymotion/vim-easymotion&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-easymotion&lt;/a&gt; is a great one&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;My motions&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Now, in my above example, I limited myself to the native vim commands, but in reality, I rely &lt;strong&gt;a lot&lt;/strong&gt; on my custom motions.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Hitting &lt;code&gt;&amp;lt;down&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt; several time in a row will make the cursor go faster&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    function MoveFaster(num, count)&#xA;        let g:num = a:num&#xA;        let g:count = a:count&#xA;        if a:count &amp;gt; 0&#xA;            if a:num &amp;lt; 0&#xA;                let curline = line('.')&#xA;                call setpos('.', [0, 2*curline - a:count, col('.'), 0])&#xA;            elseif a:num &amp;gt; 0&#xA;                call setpos('.', [0, a:count, col('.'), 0])&#xA;            endif&#xA;        endif&#xA;        let b:tap = getbufvar(bufnr(), 'tap', 0)&#xA;        let lastTap = b:tap&#xA;        if a:num &amp;gt; 0&#xA;            let out = &quot;\&amp;lt;DOWN&amp;gt;&quot;&#xA;        elseif a:num &amp;lt; 0&#xA;            let out = &quot;\&amp;lt;UP&amp;gt;&quot;&#xA;        endif&#xA;&#xA;        if a:num &amp;gt; 0 &amp;amp;&amp;amp; lastTap &amp;gt; 0 || a:num &amp;lt; 0 &amp;amp;&amp;amp; lastTap &amp;lt; 0&#xA;            let out = repeat(out, abs(lastTap))&#xA;&#xA;            if abs(b:tap) &amp;lt; 10&#xA;                let b:tap = lastTap + a:num&#xA;            endif&#xA;        elseif b:tap != 0&#xA;            let b:tap = 0&#xA;        else&#xA;            let b:tap = lastTap + a:num&#xA;        endif&#xA;&#xA;        exe &quot;norm!&quot;.out&#xA;    endfunction&#xA;&#xA;    set updatetime=130&#xA;    command! -nargs=1 -range MoveFast call MoveFaster(&quot;&amp;lt;args&amp;gt;&quot;, &quot;&amp;lt;count&amp;gt;&quot;)&#xA;    nnoremap &amp;lt;silent&amp;gt; &amp;lt;DOWN&amp;gt; :MoveFast 1&amp;lt;CR&amp;gt;&#xA;    nnoremap &amp;lt;silent&amp;gt; &amp;lt;UP&amp;gt; :MoveFast -1&amp;lt;CR&amp;gt;&#xA;    nnoremap &amp;lt;silent&amp;gt; &amp;lt;RIGHT&amp;gt; :let b:tap=0&amp;lt;CR&amp;gt;&amp;lt;RIGHT&amp;gt;&#xA;    nnoremap &amp;lt;silent&amp;gt; &amp;lt;LEFT&amp;gt; :let b:tap=0&amp;lt;CR&amp;gt;&amp;lt;LEFT&amp;gt;&#xA;    autocmd InsertEnter,InsertLeave,CursorHold * let b:tap=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;&amp;lt;CTRL&amp;gt;+&amp;lt;LEFT/RIGHT&amp;gt;&lt;/code&gt; will be more &lt;em&gt;clever&lt;/em&gt; and skip to the next uppercase or &lt;code&gt;_&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    nnoremap &amp;lt;silent&amp;gt; &amp;lt;c-left&amp;gt; :&amp;lt;c-u&amp;gt;call search('\&amp;lt;\&amp;lt;bar&amp;gt;\u\l\&amp;lt;bar&amp;gt;_[a-z]\&amp;lt;bar&amp;gt;^', 'b')&amp;lt;cr&amp;gt;&#xA;    nnoremap &amp;lt;silent&amp;gt; &amp;lt;c-right&amp;gt; :&amp;lt;c-u&amp;gt;call search('\w\&amp;gt;\&amp;lt;bar&amp;gt;\u\l\&amp;lt;bar&amp;gt;_[a-z]\&amp;lt;bar&amp;gt;$')&amp;lt;cr&amp;gt;&#xA;    inoremap &amp;lt;silent&amp;gt; &amp;lt;c-left&amp;gt; :&amp;lt;c-u&amp;gt;call search('\&amp;lt;\&amp;lt;bar&amp;gt;\u\l\&amp;lt;bar&amp;gt;_[a-z]\&amp;lt;bar&amp;gt;^', 'b')&amp;lt;cr&amp;gt;&#xA;    inoremap &amp;lt;silent&amp;gt; &amp;lt;c-right&amp;gt; :&amp;lt;c-u&amp;gt;call search('\&amp;gt;\zs\&amp;lt;bar&amp;gt;\u\l\&amp;lt;bar&amp;gt;_[a-z]\&amp;lt;bar&amp;gt;$')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;&amp;lt;S-down/up&amp;gt;&lt;/code&gt; go to beggining/end of current indented block&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    function! IndentJump(direction)&#xA;        let curline = line('.')&#xA;        let indent = matchstr(getline(curline), '^\s*')&#xA;        if a:direction &amp;gt;= 0&#xA;            let nextLineNum = search('^.*\S.*$', 'n')&#xA;        else&#xA;            let nextLineNum = search('^.*\S.*\n\_.*\%#', 'nb')&#xA;        endif&#xA;        let nextIndent = matchstr(getline(nextLineNum), '^\s*')&#xA;&#xA;        if len(nextIndent) &amp;lt; len(indent) || len(indent) == 0&#xA;            if a:direction &amp;gt;= 0&#xA;                let flag = ''&#xA;            else&#xA;                let flag = 'b'&#xA;            endif&#xA;            call search('^.*\S.*\zs$', flag)&#xA;        else&#xA;            if a:direction &amp;gt;= 0&#xA;                call search('^\('.indent.'\).*\n\(\1.*\n\|\s*\n\)*\1.*\zs')&#xA;            else&#xA;                call search('^\('.indent.'\)\S.*\zs\ze\n\(\1.*\n\|\s*\n\)*.*\%#')&#xA;            endif&#xA;        endif&#xA;    endfunction&#xA;    noremap &amp;lt;silent&amp;gt; &amp;lt;S-UP&amp;gt; :&amp;lt;C-u&amp;gt;call IndentJump(-1)&amp;lt;CR&amp;gt;&#xA;    noremap &amp;lt;silent&amp;gt; &amp;lt;S-DOWN&amp;gt; :&amp;lt;C-u&amp;gt;call IndentJump(1)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Documentation&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:help various-motions&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help t&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:help G&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="27331" LastEditDate="2020-04-23T12:33:30.180" LastActivityDate="2020-04-23T12:33:30.180" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24805" PostTypeId="1" CreationDate="2020-04-23T00:27:27.290" Score="1" ViewCount="125" Body="&lt;p&gt;I am tryng to use &lt;a href=&quot;https://github.com/terryma/vim-multiple-cursors&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/terryma/vim-multiple-cursors&lt;/a&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Default mapping&#xA;let g:multi_cursor_start_word_key      = '&amp;lt;C-n&amp;gt;'&#xA;let g:multi_cursor_select_all_word_key = '&amp;lt;A-n&amp;gt;'&#xA;let g:multi_cursor_start_key           = 'g&amp;lt;C-n&amp;gt;'&#xA;let g:multi_cursor_select_all_key      = 'g&amp;lt;A-n&amp;gt;'&#xA;let g:multi_cursor_next_key            = '&amp;lt;C-n&amp;gt;'&#xA;let g:multi_cursor_prev_key            = '&amp;lt;C-p&amp;gt;'&#xA;let g:multi_cursor_skip_key            = '&amp;lt;C-x&amp;gt;'&#xA;let g:multi_cursor_quit_key            = '&amp;lt;Esc&amp;gt;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does each of these mean? I presses Ctrl + n, and nothing gets selected. What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="11753" OwnerDisplayName="user2167582" LastActivityDate="2020-04-23T09:08:21.423" Title="How to set vim keymappings?" Tags="|vimrc|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24806" PostTypeId="1" AcceptedAnswerId="24807" CreationDate="2020-04-23T09:11:38.467" Score="4" ViewCount="4917" Body="&lt;p&gt;I'm using vim 8 and I set a shortcut to open a terminal in my vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F5&amp;gt; :wa&amp;lt;CR&amp;gt; \| :term ++kill=term&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works except that it opens a terminal vertically as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--------------------&#xA;|        |some file|&#xA;|nerdtree|----------&#xA;|        |terminal |&#xA;--------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I need is to put the terminal on the right side:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-----------------------------&#xA;|        |         |        |&#xA;|nerdtree|some file|terminal|&#xA;|        |         |        |&#xA;-----------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I change the shortcut of &lt;code&gt;&amp;lt;F5&amp;gt;&lt;/code&gt; to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2022-01-11T13:36:43.717" Title="How to open a terminal horizontally on the right side of vim" Tags="|terminal|vim-windows|vim8|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24807" PostTypeId="2" ParentId="24806" CreationDate="2020-04-23T10:26:38.367" Score="5" Body="&lt;p&gt;Use the &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Avertical&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:vertical&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Abotright&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:botright&lt;/code&gt;&lt;/a&gt; modifiers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;nnoremap &amp;lt;F5&gt; :wa \| &lt;b&gt;vertical botright&lt;/b&gt; term ++kill=term&amp;lt;CR&gt;&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;nnoremap &amp;lt;F5&gt; :wa&amp;lt;CR&gt;&lt;b&gt;:vertical botright&lt;/b&gt; term ++kill=term&amp;lt;CR&gt;&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Also note that you need one of &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;\|&lt;/code&gt;, not both. Your original command ends up executing the &lt;a href=&quot;https://vimhelp.org/motion.txt.html#bar&quot; rel=&quot;noreferrer&quot;&gt;Normal mode &lt;code&gt;|&lt;/code&gt; motion&lt;/a&gt;, which moves the cursor to the first column, followed by a space that moves it to column two.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-23T10:26:38.367" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24808" PostTypeId="1" CreationDate="2020-04-23T11:14:50.373" Score="2" ViewCount="928" Body="&lt;p&gt;Is there any way I can concatenate a command &lt;em&gt;after&lt;/em&gt; &lt;code&gt;:terminal&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example &lt;code&gt;:terminal | &amp;lt;some_other_vim_command&amp;gt;&lt;/code&gt; will pass &lt;code&gt;| &amp;lt;some_other_vim_command&amp;gt;&lt;/code&gt; to the terminal that just opened, but how can I prevent that from happening?&lt;/p&gt;&#xA;" OwnerUserId="20640" LastActivityDate="2020-04-23T15:46:10.093" Title="Concatenate vim command after :terminal" Tags="|vimscript|terminal-buffer|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24809" PostTypeId="2" ParentId="24790" CreationDate="2020-04-23T11:26:10.360" Score="5" Body="&lt;p&gt;I'd like to primarily challenge the premise of your question/challenge/race:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What would be the fastest that someone could get to those four locations in vim? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When you're editing text, you're not only moving to specific locations on the text, you're moving to those points and &lt;em&gt;adding or modifying text there&lt;/em&gt;, before moving on to the next location and editing that one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The claim that using keyboard commands in Vim allow someone to edit code faster than someone who only has a mouse (and arrow keys) is essentially about how moving your hand between keyboard and mouse constantly takes significant time and breaks/interrupts your flow, while keeping your hands on the keyboard while alternating between motion (normal-mode) and editing (insert-mode) can be more efficient for many common editing tasks.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;just given four random points&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You typically don't move to random points on the text while editing. In general, you're moving between related parts of the text while performing edits. For example, if you're refactoring code, you're looking at all uses of the same variable or all calls of a specific function. If you're writing new code, you're typically just working on one (or a few) short blocks of code.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;spaced across a screen&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That assumes that all the locations you are jumping to can fit in one screen and that's rarely the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the typical cases where mouse-based navigation quickly breaks down is when the locations you want to jump too are off the screen and you need to scroll.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;em&gt;logical&lt;/em&gt; (move to next paragraph, or next function, or next class, or next occurrence of the word under the cursor, etc.) rather than physical (point-and-click) motions help with moving to the locations you want, even if you don't necessarily see them on the current screen.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Without any practice or thinking, I'm able to click those four points in 3.9 seconds, video here.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;can&lt;/em&gt; use the mouse in Vim, &lt;a href=&quot;https://stackoverflow.com/q/28616232/9447571&quot;&gt;even on the terminal&lt;/a&gt;. There are many times where &quot;using a mouse&quot; &lt;em&gt;is&lt;/em&gt; the right answer and nothing really precludes the use of the mouse in Vim.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;what would be the fastest way to get there (fastest, as in lowest amount of time, not fewest keystrokes)? I am a vim beginner, and my first attempt took about 40s (!!) -&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Learning more motions definitely helps!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can take a long time to really master Vim motion commands and be super effective with them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My advice is next time you find yourself having trouble jumping to a &lt;em&gt;specific&lt;/em&gt; point in the text, take a break and try to think hard about it. What's the conceptual nature of this motion? Is it generic enough? How does it relate to the programming language this file is written in?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then try to find/research motions that will get you there quickly. That might involve searching for them in &lt;code&gt;:help&lt;/code&gt;, looking for motion plug-ins that can help, looking for plug-ins that improve handling of the file type you're editing, or even asking on this site how one would move from A to B most efficiently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The upside of this learning process is that next time you need the same kind of motion, you will know one that works (or at least gets you closer quicker.) With time, you'll be able to move there quickly without really thinking about it. It takes effort to create habits, but once you have them, deploying them is easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned by @Zorzi, there are some settings (such as &lt;code&gt;set relativenumber&lt;/code&gt;) and plug-ins (such as vim-easymotion) that you might want to consider looking into pretty soon. I'd say these are some of the obvious starting points for beginners, you might want to begin there and see if/how that helps.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-23T11:26:10.360" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24810" PostTypeId="2" ParentId="24791" CreationDate="2020-04-23T11:36:32.990" Score="1" Body="&lt;p&gt;The way to do it is to have a mapping on &lt;code&gt;(&lt;/code&gt; that detects its context: &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt;... and expands depending on this context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I've chosen in my &lt;a href=&quot;https://github.com/LucHermitte/lh-cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-cpp plugin&lt;/a&gt; is instead to have an abbreviation on &lt;code&gt;if&lt;/code&gt; that expands into the full control-statement snippet if, and only if, we are not in the context of a comment or of a string. I also provide snippets not based on abbreviations but on a snippet/template engine. Plus abbreviations and snippets that surround with control statements.&#xA;Bracket placement... can be tuned through &lt;a href=&quot;https://lh-style.readthedocs.io/en/latest/code-formatting.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;lh-style options&lt;/a&gt; that lh-cpp depends upon.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2020-04-23T18:05:53.417" LastActivityDate="2020-04-23T18:05:53.417" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24811" PostTypeId="2" ParentId="2319" CreationDate="2020-04-23T12:55:37.243" Score="3" Body="&lt;h1&gt;Recommended Solution&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Created by @filbranden &lt;a href=&quot;https://vi.stackexchange.com/a/24856/27110&quot;&gt;in response to my question here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Create text-object `A` which operates on the whole buffer (i.e. All)&#xA;&quot; Keeps the cursor position in the same position&#xA;function TextObjectAll()&#xA;    let g:restore_position = winsaveview()&#xA;    normal! ggVG&#xA;    &quot; For delete/change ALL, we don't wish to restore cursor position.&#xA;    if index(['c','d'], v:operator) == -1&#xA;        call feedkeys(&quot;\&amp;lt;Plug&amp;gt;(RestoreView)&quot;)&#xA;    end&#xA;endfunction&#xA;onoremap A :&amp;lt;C-U&amp;gt;call TextObjectAll()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(RestoreView) :call winrestview(g:restore_position)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;1 Liner Solution&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Use operator pending mode to visually select the whole buffer&#xA;&quot; e.g. dA = delete buffer ALL, yA = copy whole buffer ALL&#xA;onoremap &amp;lt;silent&amp;gt; A :&amp;lt;C-u&amp;gt;normal! ggVG&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Visual mode&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I used to have this, but when in visual mode, if you press &lt;code&gt;A&lt;/code&gt; to append at the end of the lines, it override it with select ALL. You could map it to something else:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Allow one to press A in visual mode to select the whole buffer (ALL)&#xA;xnoremap &amp;lt;silent&amp;gt; A :&amp;lt;C-U&amp;gt;normal! ggVG&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27110" LastEditorUserId="27110" LastEditDate="2020-05-09T15:06:43.707" LastActivityDate="2020-05-09T15:06:43.707" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24812" PostTypeId="2" ParentId="24790" CreationDate="2020-04-23T13:16:06.040" Score="3" Body="&lt;p&gt;FWIW, I tried it out, and without thinking about it, this is what I ended up typing:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;/def&amp;lt;CR&amp;gt;w&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/Tit&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/print&amp;lt;CR&amp;gt;$&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/- p&amp;lt;CR&amp;gt;nw&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I was a little unclear as to whether you wanted the cursor exactly on the red dots, or on the more significant characters next to the dots. If I guessed wrong, there may be slight adjustments required to the above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In real life, I almost definitely &lt;em&gt;wouldn't&lt;/em&gt; have actually used search for all of these, but since you primed me with &quot;jump fast to a bunch of arbitrary positions on screen&quot; I was predisposed to do so: search is very often the quickest method for moving to a position &lt;em&gt;that is conceptually unrelated to my current position.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't time it, but the &lt;em&gt;vast&lt;/em&gt; majority of my time was spent looking back at your picture to find where the next red dot was. I'd be amazed if I could do this quicker with the mouse presuming I also had to move my hands back and forth between the keyboard and mouse between every movement (which I would do if I were editing code at each position: as others have stated, if you're not performing edits, there's no reason to move the cursor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I &lt;em&gt;weren't&lt;/em&gt; performing edits and were instead just randomly moving the cursor around (for fun?) then I'd probably be slightly quicker with the mouse, but if I were a better typist, I doubt I still would be for this test.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-04-23T21:19:32.807" LastActivityDate="2020-04-23T21:19:32.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24813" PostTypeId="1" CreationDate="2020-04-23T13:35:43.450" Score="1" ViewCount="691" Body="&lt;p&gt;I am a recent and very happy Vim User.&#xA;I write Mathematics and Computer Science Lecture Notes in Markdown Files, organized in a Vimwiki.&#xA;I use the UltiSnips Snippet Plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This plugin provides me with the possibility of defining snippets which only expand in a &lt;code&gt;TexMathZone&lt;/code&gt; (&quot;UltiSnips-context-snippets&quot;).&#xA;This happens through a Python function (see [1] below) returning true if the cursor is in a &lt;code&gt;TexMathZone&lt;/code&gt;. That means that snippet expands when within &lt;code&gt;$&lt;/code&gt; or &lt;code&gt;$$&lt;/code&gt; delimiters (&lt;code&gt;TexMathZoneX&lt;/code&gt;, &lt;code&gt;TexMathZoneY&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works perfectly in &lt;code&gt;.tex&lt;/code&gt; Files, but not in &lt;code&gt;.md&lt;/code&gt; Files.&#xA;Setting the syntax to Tex by &lt;code&gt;:set syntax=tex&lt;/code&gt; makes it work, but breaks markdown preview and syntax highlighting, which is unwanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect this is because the syntax file for the markdown filetype does not define &lt;code&gt;TexMathZone&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I define or extend a markdown syntax file, such that the function in [1] delivers the same behaviour in markdown files as in Tex files? It should not inherit the other Tex syntax, and it should keep markdown syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;br&gt;&#xA;[1] Minimal &lt;code&gt;markdown.snippets&lt;/code&gt; file, as seen on &lt;a href=&quot;https://github.com/gillescastel/latex-snippets/blob/master/tex.snippets&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gilles Castel's Snippet Configuration File&lt;/a&gt; : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global !p&#xA;texMathZones = ['texMathZone' + x for x in ['A', 'AS', 'B', 'BS', 'C', 'CS', 'D', 'DS', 'E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS', 'J', 'JS', 'K', 'KS', 'L', 'LS', 'DS', 'V', 'W', 'X', 'Y', 'Z', 'AmsA', 'AmsB', 'AmsC', 'AmsD', 'AmsE', 'AmsF', 'AmsG', 'AmsAS', 'AmsBS', 'AmsCS', 'AmsDS', 'AmsES', 'AmsFS', 'AmsGS' ]]&#xA;texIgnoreMathZones = ['texMathText']&#xA;texMathZoneIds = vim.eval('map('+str(texMathZones)+&quot;, 'hlID(v:val)')&quot;)&#xA;texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+&quot;, 'hlID(v:val)')&quot;)&#xA;ignore = texIgnoreMathZoneIds[0]&#xA;def math():&#xA;    synstackids = vim.eval(&quot;synstack(line('.'), col('.') - (col('.')&amp;gt;=2 ? 1 : 0))&quot;)&#xA;    try:&#xA;        first = next(i for i in reversed(synstackids) if i in texIgnoreMathZoneIds or i in texMathZoneIds)&#xA;        return first != ignore&#xA;    except StopIteration:&#xA;        return False&#xA;endglobal&#xA;&#xA;context &quot;math()&quot;&#xA;snippet t &quot;test&quot; iAe&#xA;test!&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29132" LastEditorUserId="29132" LastEditDate="2020-04-23T14:01:55.087" LastActivityDate="2024-03-27T16:52:18.150" Title="How to use TexMathZones in Markdown Syntax, for Snippets?" Tags="|vimscript|filetype-tex|vimscript-python|plugin-ultisnips|filetype-markdown|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24814" PostTypeId="1" AcceptedAnswerId="24815" CreationDate="2020-04-23T15:34:42.130" Score="0" ViewCount="379" Body="&lt;p&gt;How can I copy &lt;strong&gt;continue close current&lt;/strong&gt; into buffer without getting into visual mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sHM7J.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sHM7J.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, how to copy N words from cursor?&lt;/p&gt;&#xA;" OwnerUserId="1132" LastActivityDate="2020-04-23T15:40:55.453" Title="How to copy N words under cursor and to right of cursor?" Tags="|gvim|cut-copy-paste|vi-words|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24815" PostTypeId="2" ParentId="24814" CreationDate="2020-04-23T15:40:55.453" Score="3" Body="&lt;p&gt;You can do &lt;code&gt;y3w&lt;/code&gt; if you are at beginning of a word (so: yank 3 words) or &lt;code&gt;by3w&lt;/code&gt; to get at the beginning of the word first (so: back yank 3 words)  &lt;/p&gt;&#xA;" OwnerUserId="27584" LastActivityDate="2020-04-23T15:40:55.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24816" PostTypeId="2" ParentId="24808" CreationDate="2020-04-23T15:46:10.093" Score="4" Body="&lt;p&gt;Not all Ex commands allow &lt;code&gt;|&lt;/code&gt; to be used as a command separator, some Ex commands want to take &lt;code&gt;|&lt;/code&gt; as an argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The common workaround is to use &lt;code&gt;:execute&lt;/code&gt; to wrap those commands that do not allow &lt;code&gt;|&lt;/code&gt; as a command separator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#%3Abar&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :bar&lt;/code&gt; or &lt;code&gt;:help :|&lt;/code&gt;&lt;/a&gt; for more details and a list of commands that take &lt;code&gt;|&lt;/code&gt; as an argument:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;These commands see the '|' as their argument, and can therefore not be followed by another Vim command:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;code&gt;:argdo&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;:autocmd&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;...&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;:normal&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;...&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;:windo&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;:write !&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;:[range]!&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Most Ex commands (such as &lt;code&gt;:!&lt;/code&gt;) that take a shell command as an argument will not allow &lt;code&gt;|&lt;/code&gt; as a command separator, since shell commands typically use &lt;code&gt;|&lt;/code&gt; as a pipe between shell commands, so they'll pass the &lt;code&gt;|&lt;/code&gt; literally to the shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;:terminal&lt;/code&gt; is not on that list (as of Vim 8.2.598) but that's just an omission in the documentation and &lt;a href=&quot;https://vi.stackexchange.com/users/71/christian-brabandt&quot;&gt;@ChristianBrabandt&lt;/a&gt; offered to push a documentation patch to fix that in Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation in &lt;code&gt;:help :|&lt;/code&gt; also mentions:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To be able to use another command anyway, use the &lt;code&gt;:execute&lt;/code&gt; command.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Example (append the output of &quot;ls&quot; and jump to the first line):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;:execute 'r !ls' | '[&#xA;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :execute&lt;/code&gt;&lt;/a&gt; also mentions that type of usage:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;:execute&lt;/code&gt; can be used to append a command to commands that don't accept a &lt;code&gt;|&lt;/code&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;:execute '!ls' | echo &quot;theend&quot;&#xA;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your particular case, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exe &quot;terminal&quot; | &amp;lt;some_other_vim_command&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-23T15:46:10.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24817" PostTypeId="1" CreationDate="2020-04-23T16:28:41.543" Score="0" ViewCount="350" Body="&lt;p&gt;I can move down until the last line of a file with no issues. However, when move up the text that was out of screen bounds does not render (as shown by the figure) until i press &lt;code&gt;Ctrl + L&lt;/code&gt; to force rendering.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/qTUJV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qTUJV.png&quot; alt=&quot;Text not rendered&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My terminal is st.&#xA;This is my .vimrc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; All system-wide defaults are set in $VIMRUNTIME/archlinux.vim (usually just&#xA;&quot; /usr/share/vim/vimfiles/archlinux.vim) and sourced by the call to :runtime&#xA;&quot; you can find below.  If you wish to change any of those settings, you should&#xA;&quot; do it in this file (/etc/vimrc), since archlinux.vim will be overwritten&#xA;&quot; everytime an upgrade of the vim packages is performed.  It is recommended to&#xA;&quot; make changes after sourcing archlinux.vim since it alters the value of the&#xA;&quot; 'compatible' option.&#xA;&#xA;&quot; Disable Background Color Erase (BCE) so that color schemes&#xA;&quot; render properly when inside 256-color tmux and GNU screen.&#xA;if &amp;amp;term =~ '256color'&#xA;    set t_ut=&#xA;endif&#xA;&#xA;&quot; This line should not be removed as it ensures that various options are&#xA;&quot; properly set to work with the Vim-related packages.&#xA;runtime! archlinux.vim&#xA;&#xA;&quot; If you prefer the old-style vim functionalty, add 'runtime! vimrc_example.vim'&#xA;&quot; Or better yet, read /usr/share/vim/vim80/vimrc_example.vim or the vim manual&#xA;&quot; and configure vim to your own liking!&#xA;&#xA;&quot; do not load defaults if ~/.vimrc is missing&#xA;&quot;let skip_defaults_vim=1&#xA;&#xA;&quot; adding my configs&#xA;:set lazyredraw &#xA;:set history=500&#xA;:set number&#xA;:set mouse=a&#xA;:set clipboard+=unnamed  &quot; use the clipboards of vim and win&#xA;:set paste               &quot; Paste from a windows or from vim&#xA;:set go+=a               &quot; Visual selection automatically copied to the clipboard&#xA;:set laststatus=2&#xA;&#xA;&quot; now this is configurations for plugins&#xA;&#xA;if empty(glob('~/.vim/autoload/plug.vim'))&#xA;  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs&#xA;    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC&#xA;endif&#xA;&#xA;&quot; Specify a directory for plugins&#xA;&quot; - For Neovim: stdpath('data') . '/plugged'&#xA;&quot; - Avoid using standard Vim directory names like 'plugin'&#xA;call plug#begin('~/.vim/plugged')&#xA;&#xA;Plug 'itchyny/lightline.vim'&#xA;&#xA;&quot; Initialize plugin system&#xA;call plug#end()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29142" LastEditorUserId="18609" LastEditDate="2020-04-23T17:51:09.407" LastActivityDate="2020-04-23T17:51:09.407" Title="Vim not rendering text when moving up" Tags="|terminal|scrolling|original-vim|redraw|st|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24818" PostTypeId="1" CreationDate="2020-04-23T18:17:32.253" Score="0" ViewCount="533" Body="&lt;p&gt;I am trying to copy text onto my clipboard on a local mac and paste it onto a remote linux server. I am able to yank the text from my local machine onto my machine's clipboard using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;*yy&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I can copy/paste this into another buffer/window/program locally. It also says at the bottom:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;76 lines yanked into &quot;*&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I know it's working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I try and copy/paste that remotely it doesn't appear to copy it over from my system's clipboard and says &lt;code&gt;&quot;Nothing in register&quot;&lt;/code&gt;. Here is a video showing copying it over locally (which works) and remotely (which doesn't): &lt;a href=&quot;https://gyazo.com/4f67eead477a2b054455c5f0f16ab32b&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gyazo.com/4f67eead477a2b054455c5f0f16ab32b&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the proper way to copy over to a remote server?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="28904" LastEditDate="2020-04-23T18:37:58.437" LastActivityDate="2020-04-23T18:37:58.437" Title="How to copy/paste from a local machine to a remote server" Tags="|vimrc|register|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24819" PostTypeId="1" AcceptedAnswerId="24821" CreationDate="2020-04-23T18:27:09.043" Score="3" ViewCount="4945" Body="&lt;p&gt;To clear a file I find myself doing something like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1G&lt;/li&gt;&#xA;&lt;li&gt;1000cc (or some large number)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is there a simpler way to do this for clearing a file? On a normal text editor I normally would do &lt;code&gt;Cmd-A&lt;/code&gt; and then start typing.&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-24T14:07:45.453" Title="How to clear all contents of a file" Tags="|buffers|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24820" PostTypeId="1" AcceptedAnswerId="24825" CreationDate="2020-04-23T18:37:08.883" Score="1" ViewCount="393" Body="&lt;p&gt;I want to have predefined register that will jump to the location matched by regular expression, i.e. in &lt;code&gt;vimrc&lt;/code&gt; I add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a=&quot;/=\&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will be useful for me when I want to navigate to the next entry point in HTML tag, such as &lt;code&gt;class=&quot;&quot;&lt;/code&gt; or &lt;code&gt;method=&quot;&quot;&lt;/code&gt;. But when I test it I see the command appears at the bottom, but doesn't get executed until I press &lt;code&gt;Enter&lt;/code&gt;. How can I embed a &lt;code&gt;&amp;lt;Return&amp;gt;&lt;/code&gt; in the register, so the search is executed on &lt;code&gt;@a&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="25325" LastEditorUserId="10604" LastEditDate="2020-04-24T14:08:12.477" LastActivityDate="2020-05-24T15:03:10.320" Title="Embed &lt;Return&gt; within register" Tags="|vimrc|vimscript|macro|register|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24821" PostTypeId="2" ParentId="24819" CreationDate="2020-04-23T19:17:25.337" Score="5" Body="&lt;p&gt;&lt;code&gt;ggdG&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;gg&lt;/code&gt;: Move to the first line in the file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;d&lt;/code&gt;: Delete&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;G&lt;/code&gt;: [until] last line in file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;G           Goto line [count], default last line, on the first&#xA;            non-blank character linewise.  If 'startofline' not&#xA;            set, keep the same column.&#xA;            G is one of the jump-motions.&#xA;...&#xA;gg          Goto line [count], default first line, on the first&#xA;            non-blank character |linewise|.  If 'startofline' not&#xA;            set, keep the same column.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Substitute &lt;code&gt;d&lt;/code&gt; with &lt;code&gt;c&lt;/code&gt; if you want to be in insert mode instantly.&lt;/p&gt;&#xA;" OwnerUserId="29152" LastActivityDate="2020-04-23T19:17:25.337" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24822" PostTypeId="1" AcceptedAnswerId="24832" CreationDate="2020-04-23T19:21:13.677" Score="2" ViewCount="673" Body="&lt;p&gt;I'm trying to install the last version of &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow noreferrer&quot;&gt;netrw&lt;/a&gt;, which is distributed as a &lt;strong&gt;vimball&lt;/strong&gt; file, but can't find the way of doing it in Neovim. So far I've tried:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Unzip the file&lt;/li&gt;&#xA;&lt;li&gt;Run:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:packadd vimball&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Inside neovim, moved to the directory where the netrw.vba file is and run:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:vim netrw.vba&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get the error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E683: File name missing or invalid pattern&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is, does Neovim really has support to install vimball files? If so, how?&lt;/p&gt;&#xA;" OwnerUserId="29151" LastActivityDate="2020-04-24T15:25:27.703" Title="Does Neovim support vimball plugins?" Tags="|neovim|vimball|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24823" PostTypeId="2" ParentId="24820" CreationDate="2020-04-23T20:01:26.200" Score="0" Body="&lt;p&gt;I think you're mistaking &lt;code&gt;buffers&lt;/code&gt;, &lt;code&gt;registers&lt;/code&gt; and &lt;code&gt;macros&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;@a&lt;/code&gt; here is a register. It can contain any text, like a variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you hit &lt;code&gt;@a&lt;/code&gt;, you execute a &lt;code&gt;macro&lt;/code&gt;, which will type what's written in the register as if you typed it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;code&gt;buffer&lt;/code&gt; in the other hand:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A buffer is a file loaded into memory for editing. All opened files are associated with a buffer. There are also buffers not associated with any file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(from the &lt;a href=&quot;https://vim.fandom.com/wiki/Vim_buffer_FAQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim fandom&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what you want to do here is to record a macro in the register &lt;code&gt;a&lt;/code&gt;. to do so, you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qa/=&quot;&amp;lt;ENTER&amp;gt;q&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Where &lt;code&gt;&amp;lt;ENTER&amp;gt;&lt;/code&gt; is you, pressing the enter key)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;qa&lt;/code&gt; will &lt;strong&gt;start recording&lt;/strong&gt; the macro in the &lt;code&gt;a&lt;/code&gt; register&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;/=&quot;&amp;lt;ENTER&amp;gt;&lt;/code&gt; this is what you want the macro to do&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; to &lt;strong&gt;Stop the macro&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then, once that's done, the macro is contained into the &lt;code&gt;a&lt;/code&gt; register, accessible via as a variable in &lt;code&gt;@a&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To print a register, from normal mode, you can:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;ap&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From Vim doc:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;&quot;&lt;/code&gt; Use register {a-zA-Z0-9.%#:-&quot;} for next delete, yank or put (use uppercase character to append with delete and yank) ({.%#:} only work with put).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So once you printed the content of the register (it should contain some weird character &lt;code&gt;^M&lt;/code&gt; maybe, that's the enter), you simply have to wrap it in quotes and add &lt;code&gt;let @a =&lt;/code&gt; before it&lt;/p&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="27331" LastEditDate="2020-04-23T20:08:11.640" LastActivityDate="2020-04-23T20:08:11.640" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24824" PostTypeId="1" AcceptedAnswerId="24826" CreationDate="2020-04-23T20:39:11.860" Score="3" ViewCount="71" Body="&lt;p&gt;Perhaps this is a trivial question, but I have seen both of the following ways to enter in lines into the &lt;code&gt;vimrc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:imap &amp;lt;leader&amp;gt;I &amp;lt;C-O&amp;gt;v &amp;lt;C-O&amp;gt;g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imap &amp;lt;leader&amp;gt;I &amp;lt;C-O&amp;gt;v &amp;lt;C-O&amp;gt;g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, with/without the leading &lt;code&gt;:&lt;/code&gt;. What is the proper way to do this, and is there any difference in the two?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-23T21:01:56.250" Title="Proper way to enter in commands/lines in vimrc" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="0" ClosedDate="2020-05-22T14:44:56.710" ContentLicense="CC BY-SA 4.0" />
  <row Id="24825" PostTypeId="2" ParentId="24820" CreationDate="2020-04-23T20:41:54.690" Score="2" Body="&lt;p&gt;TL;DR: You need either this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a = &quot;/=\&quot;\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setreg('a', &quot;/=\&quot;\&amp;lt;Return&amp;gt;&quot;, 'c')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There are a few ways to enter a &lt;code&gt;&amp;lt;Return&amp;gt;&lt;/code&gt; character in a double-quoted string. See &lt;a href=&quot;https://vimhelp.org/eval.txt.html#expr-quote&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help expr-quote&lt;/code&gt;&lt;/a&gt; for details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, you can use the &lt;code&gt;\&amp;lt;Return&amp;gt;&lt;/code&gt; notation, which you can actually use with any special keystroke to enter the keycode for that key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this string would produce the search and execute the command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;/=\&quot;\&amp;lt;Return&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or also:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;/=\&quot;\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(You'll often find &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; used more often than &lt;code&gt;&amp;lt;Return&amp;gt;&lt;/code&gt; in Vim documentation or plug-ins. They are synonymous. Also &lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way is to use &lt;code&gt;\r&lt;/code&gt; which is exactly the same as &lt;code&gt;\&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;\&amp;lt;Return&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;/=\&quot;\r&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The &lt;code&gt;\r&lt;/code&gt; sequence comes from languages such as C and later adopted by many other languages, it's the sequence that expands to a &quot;carriage return&quot; character, which is also what &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; means.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there's a problem with using any of these three strings in a &lt;code&gt;:let&lt;/code&gt; expression on a register, so this will &lt;strong&gt;not&lt;/strong&gt; work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a = &quot;/=\&quot;\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will actually produce register contents that include an extra &lt;code&gt;\n&lt;/code&gt; at the end. If you read &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Alet-register&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :let-register&lt;/code&gt;&lt;/a&gt;, you'll see an explanation of why that happens:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[...] If the result of &lt;code&gt;{expr1}&lt;/code&gt; ends in a &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt;, &lt;strong&gt;the register will be linewise&lt;/strong&gt;, otherwise it will be set to characterwise.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When a register is linewise, Vim will &lt;em&gt;always&lt;/em&gt; include a newline character &lt;code&gt;\n&lt;/code&gt; at the end of it. So it will find the &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; and add a &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt;. The result is that using the &lt;code&gt;@a&lt;/code&gt; macro will look for the &lt;code&gt;=&quot;&lt;/code&gt; string, find the next match, and then jump to the next line as if you had pressed &quot;Enter&quot; again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This one will actually work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let @a = &quot;/=\&quot;\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\n&lt;/code&gt; sequence is the &quot;newline&quot; character and is typically used as a line break on Linux/Unix systems. It's not really the most accurate one to use, since when you press the &quot;Enter&quot; or &quot;Return&quot; key on your keyboard, the key code that is actually produced is &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt; or &lt;code&gt;\r&lt;/code&gt; and not &lt;code&gt;\n&lt;/code&gt; or &lt;code&gt;&amp;lt;NL&amp;gt;&lt;/code&gt;. But the &lt;code&gt;\n&lt;/code&gt; &lt;em&gt;works&lt;/em&gt; to execute the search. And it doesn't have the side-effect of having &lt;code&gt;:let&lt;/code&gt; add an &lt;em&gt;extra&lt;/em&gt; newline at the end of the register when it's stored as a linewise register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possible approach is to use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#setreg%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;setreg()&lt;/code&gt;&lt;/a&gt; function instead of the &lt;code&gt;:let&lt;/code&gt; command. The &lt;code&gt;setreg()&lt;/code&gt; function takes an optional third argument which lets you pick whether you want a characterwise, linewise or blockwise register. So you can pass a &lt;code&gt;c&lt;/code&gt; to force it to be characterwise, even though it ends in a &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setreg('a', &quot;/=\&quot;\&amp;lt;CR&amp;gt;&quot;, 'c')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setreg('a', &quot;/=\&quot;\&amp;lt;Return&amp;gt;&quot;, 'c')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also the same as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setreg('a', &quot;/=\&quot;\r&quot;, 'c')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-23T20:41:54.690" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24826" PostTypeId="2" ParentId="24824" CreationDate="2020-04-23T21:01:56.250" Score="4" Body="&lt;p&gt;In script files the leading &lt;code&gt;:&lt;/code&gt; are optional. A script file is just a bunch of ex commands, that’s why they are allowed there, even when they are not necessary most of the time. Specifically the documentation says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The &quot;:&quot; characters are not really needed here.  You only need to use them when you type a command.  In a Vim script file they can be left out.  We will use them here anyway to make clear these are colon commands and make them stand out from Normal mode commands.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help vim-script-intro&lt;/code&gt; for details &lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-23T21:01:56.250" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24827" PostTypeId="1" CreationDate="2020-04-23T21:51:55.183" Score="1" ViewCount="31" Body="&lt;p&gt;To do a mapping for &lt;kbd&gt;return&lt;/kbd&gt; I can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;When in normal mode, treat an enter like insert+enter&#xA;:nnoremap &amp;lt;CR&amp;gt; i&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I would also like to map a shift-enter as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Shift-CF&amp;gt; O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What would be the proper way to enter this in?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this but it doesn't do anything -- regardless of whether I hold shift or not, the mapping always does the first one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;When in normal mode, treat an enter like insert+enter&#xA;:nnoremap &amp;lt;CR&amp;gt; i&amp;lt;CR&amp;gt;      &amp;lt;-- always doing this one (maybe overwriting the other?)&#xA;:nnoremap &amp;lt;s-CR&amp;gt; O&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: it seems this is not possible, see: &lt;a href=&quot;https://stackoverflow.com/questions/16359878/vim-how-to-map-shift-enter&quot;&gt;https://stackoverflow.com/questions/16359878/vim-how-to-map-shift-enter&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="28904" LastEditDate="2020-04-23T21:59:31.570" LastActivityDate="2020-04-23T21:59:31.570" Title="How to do a keyboard mapping for CR and Shift-CR" Tags="|vimrc|key-bindings|keyboard-layout|" AnswerCount="0" CommentCount="3" ClosedDate="2020-05-14T14:53:50.480" ContentLicense="CC BY-SA 4.0" />
  <row Id="24828" PostTypeId="1" CreationDate="2020-04-23T22:10:02.247" Score="1" ViewCount="1297" Body="&lt;p&gt;There's a very weird thing that occurs when I type a comment that it inserts a newline after a max-width which I don't want to have done. For example: here is me typing it in: &lt;a href=&quot;https://gyazo.com/7dd2fccd0d988082abf2e6f8a9be945e&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gyazo.com/7dd2fccd0d988082abf2e6f8a9be945e&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does this occur? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only (hackish) way I was able to disable it is to set &lt;code&gt;:set paste&lt;/code&gt;, but hopefully there's a better way to disable this autowrapping?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    &quot;When in normal mode, treat an enter like insert -- as I continue typing this&#xA;    line it automatically adds a new line&#xA;    :nmap &amp;lt;leader&amp;gt;&amp;amp;  O&#xA;    :nmap &amp;lt;CR&amp;gt; i&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-23T22:10:02.247" Title="Disable text wrapping in vim" Tags="|formatting|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24829" PostTypeId="2" ParentId="20105" CreationDate="2020-04-23T23:44:54.270" Score="0" Body="&lt;p&gt;Some mappings to know what inside each register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ctrl_q+REG&lt;/code&gt; for insert mode. 'R+REG' for other modes. Displays the content of register REG. For example, &lt;code&gt;R0&lt;/code&gt; - displays register 0 content.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replaced the not so useful R.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This function maps all registers so that we know what we have in each.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;R R&#xA;func! MapR()&#xA;    let lst=['+','*']&#xA;    for i in range(10)&#xA;        call add(lst,string(i))&#xA;    endfor&#xA;    let k=char2nr('a')&#xA;    for j in range(26)&#xA;        call add(lst,nr2char(k+j))&#xA;    endfor &#xA;    echo lst&#xA;for i in lst &#xA;        exec 'nmap R'. i .' :echo getreg(&quot;'.i .'&quot;)&amp;lt;CR&amp;gt;'&#xA;        exec 'vmap R'. i .' &amp;lt;CMD&amp;gt;:echo getreg(&quot;'.i .'&quot;)&amp;lt;CR&amp;gt;'&#xA;        exec 'imap &amp;lt;c-q&amp;gt;'. i .' &amp;lt;CMD&amp;gt;:echo getreg(&quot;'.i .'&quot;)&amp;lt;CR&amp;gt;'&#xA;endfor &#xA;endf&#xA;&#xA;call MapR()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2020-04-23T23:44:54.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24830" PostTypeId="1" CreationDate="2020-04-24T00:18:26.143" Score="0" ViewCount="16" Body="&lt;p&gt;&lt;code&gt;z=&lt;/code&gt; on misspelled words shows a dialog (set spelling before). Can I get the dialog by a function?  &lt;/p&gt;&#xA;" OwnerUserId="18375" LastActivityDate="2020-04-24T00:18:26.143" Title="Any way to raise a dialog similar to `z=`?" Tags="|vim-windows|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24831" PostTypeId="2" ParentId="24787" CreationDate="2020-04-24T01:11:33.777" Score="9" Body="&lt;p&gt;Three ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;S&lt;/code&gt; &lt;em&gt;[an abbreviation for &lt;code&gt;cc&lt;/code&gt;]&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Vs&lt;/code&gt; &lt;em&gt;[line-wise selection, then substitute]&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C&lt;/code&gt; &lt;em&gt;[assuming the cursor is at the start of the line]&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;plus various ways to visually select all the text on the line followed by one of &lt;code&gt;s&lt;/code&gt; or &lt;code&gt;c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you can replace multiple lines using &lt;code&gt;V&lt;/code&gt;, by moving the cursor down or using &lt;code&gt;%&lt;/code&gt; to select a block, then &lt;code&gt;s&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14114" LastEditorUserId="14114" LastEditDate="2020-04-24T09:25:45.547" LastActivityDate="2020-04-24T09:25:45.547" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24832" PostTypeId="2" ParentId="24822" CreationDate="2020-04-24T01:33:35.743" Score="2" Body="&lt;p&gt;The problem you're having is with your step 3. You need to &lt;em&gt;open&lt;/em&gt; the vimball file in NeoVim and the command to do so is &lt;a href=&quot;https://vimhelp.org/editing.txt.html#%3Ae&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:e&lt;/code&gt;&lt;/a&gt; and not &lt;code&gt;:vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/quickfix.txt.html#%3Avim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:vim&lt;/code&gt;&lt;/a&gt; is actually a shorthand for &lt;code&gt;:vimgrep&lt;/code&gt;, that's why your error message is talking about &lt;em&gt;&quot;invalid pattern&quot;&lt;/em&gt;, it's expecting at least two arguments, one pattern and one base path where to run a recursive grep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After loading the vimball package with &lt;code&gt;:packadd vimball&lt;/code&gt; and opening the netrw vimball with &lt;code&gt;:e netrw.vba&lt;/code&gt;, all you need is to run it with &lt;code&gt;:so %&lt;/code&gt; to install it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;By default, the vimball plug-in will unpack the plug-in files directly under your &lt;code&gt;~/.config/nvim&lt;/code&gt;. That's the older scheme pre-&lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pathogen&lt;/a&gt; where you would merge all the plug-in files into a single directory, rather than update &lt;code&gt;'runtimepath'&lt;/code&gt; to include the root directory of each of your plug-ins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to unpack the vimball into an alternate location, you can also call &lt;a href=&quot;https://vimhelp.org/pi_vimball.txt.html#%3AUseVimball&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:UseVimball&lt;/code&gt;&lt;/a&gt; directly instead of calling &lt;code&gt;:so %&lt;/code&gt; after opening the &lt;code&gt;*.vba&lt;/code&gt; inside NeoVim/Vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to turn the netrw vimball into a NeoVim package:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!mkdir -p ~/.local/share/nvim/site/pack/netrw/start/netrw&#xA;:UseVimball ~/.local/share/nvim/site/pack/netrw/start/netrw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(For Vim, you can do the same, just use &lt;code&gt;~/.vim/pack&lt;/code&gt; on Linux/Mac/Unix or &lt;code&gt;$HOME/vimfiles/pack&lt;/code&gt; on Windows as the base package directory.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-24T15:25:27.703" LastActivityDate="2020-04-24T15:25:27.703" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24833" PostTypeId="1" CreationDate="2020-04-24T02:23:27.787" Score="0" ViewCount="162" Body="&lt;p&gt;This issue may be a kind of nonsense but I still want to know if it is possible to make some dynamic stuff in vim 7 or vim 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, load a file and make if move from left to right (just like &lt;a href=&quot;https://askubuntu.com/questions/686710/why-do-i-get-a-train-when-i-run-ls&quot;&gt;https://askubuntu.com/questions/686710/why-do-i-get-a-train-when-i-run-ls&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2020-04-24T02:23:27.787" Title="Is it possible to make some animation in vim" Tags="|buffers|vim-windows|plugin-system|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24834" PostTypeId="1" CreationDate="2020-04-24T02:52:08.227" Score="2" ViewCount="561" Body="&lt;p&gt;I'm having a hard time writing regexes in vim -- it seems everything I try either requires an escape character or isn't supported. For example, I have a SQL statement that includes something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;max(if(s.name like 'iTunes' and completion_date is not null, 'Complete', if(s.name like 'iTunes', 'X', null))) iTunes,&#xA;max(if(s.name like 'amazon' and completion_date is not null, 'Complete', if(s.name like 'Amazon', 'X', null))) Amazon&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I want to change it from &lt;code&gt;'itunes'&lt;/code&gt; to &lt;code&gt;'%%itunes%%'&lt;/code&gt; for the like statement to work. My first attempt was:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;kbd&gt;shift&lt;/kbd&gt;&lt;kbd&gt;v&lt;/kbd&gt; to highlight the lines I want to replace&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;s/'([a-z]+)'/'%%\1%%'&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To which I get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;E486: Pattern not found: '([a-z]+)'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How would I enter in that regex, and is there a good place to learn about regex use in vim (specifically what's supported and what needs to be escaped)?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: even though it's a bit dry, the docs are great here for a comprehensive reference: &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;pattern&lt;/code&gt;&lt;/a&gt;. And the regex that worked was:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;s/'\(\a\{2,}\)'/'%%\1%%'/g&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A few notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There is no &lt;code&gt;[a-z]&lt;/code&gt;. Need to use &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5Cl&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\l&lt;/code&gt;&lt;/a&gt; (lowercase) or or &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5Ca&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\a&lt;/code&gt;&lt;/a&gt; (lower or uppercase) instead.&lt;/li&gt;&#xA;&lt;li&gt;Capturing groups need to be escaped on both sides: &lt;code&gt;\(...\)&lt;/code&gt; and then reference it with &lt;code&gt;\1&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;For a repetition, the first part needs to be escaped: &lt;code&gt;\{2,}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Basically, just keep the reference handy as there are a lot of real quirky things here!&lt;/p&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="28904" LastEditDate="2020-04-24T04:19:32.520" LastActivityDate="2020-04-24T22:02:00.803" Title="Regex flavor in vim for doing substitutions" Tags="|vimrc|regular-expression|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24835" PostTypeId="2" ParentId="24834" CreationDate="2020-04-24T03:48:52.410" Score="3" Body="&lt;p&gt;Yeah, the Vim flavor of regex is a bit different from what you'll find in languages such as Python or Perl.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, you need to escape the sets of parens that mark a group. Also, the &lt;code&gt;+&lt;/code&gt; to repeat one or more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;[a-z]&lt;/code&gt; itself works as expected. (Not that there's anything wrong with &lt;code&gt;\a&lt;/code&gt;, which is in many senses better... But I just wanted to point out that a character range such as &lt;code&gt;[a-z]&lt;/code&gt; will work in Vim regexes.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/'\([a-z]\+\)'/'%%\1%%'/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But will it match only lowercase letters? Well, it depends! If you have either &lt;code&gt;set ignorecase&lt;/code&gt; or &lt;code&gt;set smartcase&lt;/code&gt;, then it will match either lowercase or uppercase words, since either of those will make this regex match case-insensitively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to look into the &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Cv&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\v&lt;/code&gt;&lt;/a&gt; modifier for the &quot;verymagic&quot; mode, which make regexes work closer to how they work in other languages. Parens and &lt;code&gt;+&lt;/code&gt; are now metacharacters by default.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\v'([a-z]+)'/'%%\1%%'/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also force &lt;code&gt;'ignorecase'&lt;/code&gt; behavior by including a &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Cc&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\c&lt;/code&gt;&lt;/a&gt; anywhere in your regex (or make it match case exactly with &lt;code&gt;\C&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One quite unique feature of Vim regexes is that you can use &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Czs&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\zs&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Cze&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;\ze&lt;/code&gt;&lt;/a&gt; to mark the start and end of the actual match. So you can replace a word within quotes without capture groups.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/\v\c'\zs[a-z]+\ze'/%%&amp;amp;%%/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are many more features of the Vim regex engine. Hopefully these pointers here will get you started. The docs are really good, so read those too.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-24T03:48:52.410" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24836" PostTypeId="1" CreationDate="2020-04-24T03:53:43.757" Score="5" ViewCount="153" Body="&lt;p&gt;I want to completely disable the mouse but mouse scrolling in normal mode is not disabled. I have disabled other mouse function but scrolling in normal mode is still on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To disable the mouse I have used &lt;code&gt;set mouse=&lt;/code&gt; and &lt;code&gt;ttymouse=&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user26049" LastActivityDate="2024-03-27T19:00:50.093" Title="How to disable mouse scroll wheel when in normal mode?" Tags="|normal-mode|mouse|original-vi|set|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24837" PostTypeId="1" CreationDate="2020-04-24T06:10:33.897" Score="2" ViewCount="6819" Body="&lt;p&gt;I've recently switched to Neovim, and some days in, I realized that there was no &lt;code&gt;search hit BOTTOM, continuing at TOP&lt;/code&gt; message when jumping from the last to the first search result (or vice versa), which I'm relying on fairly regularly. I did some experimenting and figured out that the current pattern shown in the status bar (e.g., &lt;code&gt;/\&amp;lt;foo\&amp;gt;&lt;/code&gt;) overwrites the error message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The message can be restored by silencing the search navigation commands with the following (otherwise empty) config and &lt;code&gt;--noplugin&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; ~/.config/nvim/init.vim&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; * *&#xA;nnoremap &amp;lt;silent&amp;gt; n n&#xA;&quot; ... (omitting backward, g*, etc.)&#xA;&#xA;set shortmess=&#xA;&quot; set shortmess+=s  &quot; don't give &quot;search hit BOTTOM, continuing at TOP&quot; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with this approach is twofold:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;search hit BOTTOM...&lt;/code&gt; does not disappear when jumping from the first to the second result after wrap-jumping from the last to the first;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The current search pattern (and &lt;code&gt;[i/n]&lt;/code&gt; counter) is no longer shown.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;While I still prefer this state to the former, the ideal situation would be as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The current search result with counter is shown by default after starting a search or jumping between results.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;However, when jumping from the first to the last search result in the file (or vice versa), the message &lt;code&gt;search hit BOTTOM, continuing at TOP&lt;/code&gt; (or vice versa) is shown instead -- but disappears on further movement, e.g., when jumping on to the second result.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How can this be achieved?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;PS: I'm running &lt;code&gt;NVIM V0.4.3&lt;/code&gt; (&lt;code&gt;LuaJIT 2.0.5&lt;/code&gt;, &lt;code&gt;Features: +acl +iconv +tui&lt;/code&gt;) on Manjaro Linux.&lt;/p&gt;&#xA;" OwnerUserId="2100" LastEditorUserId="2100" LastEditDate="2020-04-24T08:54:15.397" LastActivityDate="2020-04-24T08:54:15.397" Title="Restore &quot;search hit BOTTOM, continuing at TOP&quot; when search navigation wraps aound end of file" Tags="|neovim|search|navigation|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24838" PostTypeId="1" AcceptedAnswerId="24840" CreationDate="2020-04-24T06:15:59.967" Score="4" ViewCount="1015" Body="&lt;p&gt;I have mapped a key shortcut to copy all lines to system clipboard, which is working fine&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; nnoremap &amp;lt;localleader&amp;gt;o :silent %w !pbcopy&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to display the message as 'Copied' in the status bar. Reading other answers, I found &lt;code&gt;echom&lt;/code&gt; or &lt;code&gt;echo&lt;/code&gt; can be used to display the messages&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; nnoremap &amp;lt;localleader&amp;gt;o :silent %w !pbcopy&amp;lt;cr&amp;gt;|:echom &quot;Copied&quot;&#xA; nnoremap &amp;lt;localleader&amp;gt;o :silent %w !pbcopy&amp;lt;cr&amp;gt;|echom &quot;Copied&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These lines are placed in &lt;code&gt;.vimrc&lt;/code&gt;. It appears lines are getting copied to clipboard, but the message is not being displayed anywhere. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) How do I display the message from mapped command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) On opening a file, I see the 'Copied' message, and a line that says 'Press Enter to continue'. It appears the mapping is being invoked on sourcing the vimrc. The message should not be echoed while sourcing the vimrc file. How do I stop this?&lt;/p&gt;&#xA;" OwnerUserId="8092" LastActivityDate="2020-04-24T06:45:42.213" Title="vim display message on execution of mapping" Tags="|key-bindings|echo|message|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24839" PostTypeId="2" ParentId="24834" CreationDate="2020-04-24T06:37:13.237" Score="1" Body="&lt;p&gt;Vim regex &lt;a href=&quot;https://vi.stackexchange.com/a/13600/786&quot;&gt;are Basic Regular Expression&lt;/a&gt; which predate PCRE. IMHO the former are better for text edition and the latter for scripting. I’ve noticed that often I use search and replace with literal characters, for example, when I need to find &lt;code&gt;myFunction(&lt;/code&gt;, and Vim’s default behaviour is good for that. So that’s why you need to escape things like &lt;code&gt;(&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you need to write complicated regexes you can change the characters that need to be escaped in scripts and in runtime! I know at first it is confusing, but now I think it is an awesome feature. See &lt;code&gt;:help magic&lt;/code&gt; for details, and read &lt;a href=&quot;https://vi.stackexchange.com/a/2279/786&quot;&gt;this answer&lt;/a&gt;, it changed my mind about BRE and helped me understand the &lt;code&gt;magic&lt;/code&gt; thing.&lt;/p&gt;&#xA;" OwnerUserId="786" LastEditorUserId="18609" LastEditDate="2020-04-24T22:02:00.803" LastActivityDate="2020-04-24T22:02:00.803" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24840" PostTypeId="2" ParentId="24838" CreationDate="2020-04-24T06:45:42.213" Score="4" Body="&lt;p&gt;From &lt;a href=&quot;https://vimhelp.org/various.txt.html#%3A%21&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :!&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A '|' in {cmd} is passed to the shell, you cannot use&#xA;it to append a Vim command.  See :bar.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An alternative would be to use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#system%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;system()&lt;/code&gt;&lt;/a&gt; function, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:call system('pbcopy', getline(1, '$'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second argument is the stdin; in this case all all lines (like the &lt;code&gt;%&lt;/code&gt; range).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a mapping, it might look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;localleader&amp;gt;o :silent :call system('pbcopy', getline(1, '$')) \| :echom 'Copied'&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that I used &lt;code&gt;\|&lt;/code&gt; here, since otherwise Vim will see use the &lt;code&gt;|&lt;/code&gt; to seperate &lt;code&gt;echom&lt;/code&gt; from &lt;code&gt;nnoremap&lt;/code&gt;, which isn't what we want. See &lt;a href=&quot;https://vimhelp.org/map.txt.html#map-bar&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help map-bar&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim stores the command's exit code in &lt;code&gt;v:shell_error&lt;/code&gt;, so you can improve a bit on always showing &quot;copied&quot; by checking the value of that; for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;localleader&amp;gt;o :silent :call system('pbcopy', getline(1, '$'))&#xA;          \ \| :echom (v:shell_error &amp;gt; 0 ? ('Error: ' . v:shell_error) : 'Copied')&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also display the &lt;code&gt;pbcopy&lt;/code&gt; output on error instead of just the status code, but that's left as an exercise for the reader ;-)&lt;/p&gt;&#xA;" OwnerUserId="51" LastActivityDate="2020-04-24T06:45:42.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24841" PostTypeId="2" ParentId="21824" CreationDate="2020-04-24T09:12:46.147" Score="1" Body="&lt;p&gt;This is one of the differences between Vim and Neovim. The latter supports XDG, the former doesn't. That being said, you can make Vim to respect XDG by manually setting some locations, but you have to decide what kind of stuff you want to put on &lt;code&gt;$XDG_CONFIG_CACHE&lt;/code&gt;. For example you could put your &lt;code&gt;.viminfo&lt;/code&gt; there: &lt;code&gt;set viminfo+=n$XDG_CACHE_HOME/vim/viminfo&lt;/code&gt;. Also backups and swap files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set directory=$XDG_CACHE_HOME/vim&#xA;set backupdir=$XDG_CACHE_HOME/vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Neovim consider these data, so they go in &lt;code&gt;$XDG_DATA_HOME&lt;/code&gt; instead).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, to have all your configuration on &lt;code&gt;$XDG_CONFIG_HOME&lt;/code&gt; you can use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set runtimepath=$XDG_CONFIG_HOME/vim,$XDG_CONFIG_HOME/vim/after,$VIM,$VIMRUNTIME&#xA;let $MYVIMRC=&quot;$XDG_CONFIG_HOME/vim/vimrc&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-24T09:12:46.147" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24842" PostTypeId="1" CreationDate="2020-04-24T11:05:08.473" Score="1" ViewCount="130" Body="&lt;p&gt;I want to empty inner columns in a latex table, ie all the words between 2 &amp;amp;. How I can do it ?&#xA;I have tried quite a few formulas like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/&amp;amp;*&amp;amp;/\&amp;amp; \&amp;amp;/gc    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I just can't find the right pattern to match.&#xA;Thanks for your help.&lt;/p&gt;&#xA;" OwnerUserId="29170" LastEditorUserId="786" LastEditDate="2020-04-24T12:02:06.110" LastActivityDate="2020-05-24T17:01:25.110" Title="Empty space between two &amp;" Tags="|regular-expression|filetype-tex|original-vim|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24844" PostTypeId="2" ParentId="24819" CreationDate="2020-04-24T14:07:45.453" Score="10" Body="&lt;p&gt;Fastest is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%delete&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which can be abbreviated to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;%&lt;/code&gt; is a range standing for “whole file.”&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use a particular register (e.g., black hole):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%d_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-24T14:07:45.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24845" PostTypeId="1" CreationDate="2020-04-24T14:13:00.933" Score="2" ViewCount="144" Body="&lt;p&gt;I have the annoying issue that I have a .php file with HTML, CSS, Javascript and PHP. I use Vim. But the autoindent is always messed up and only works for one language in the whole file. Is there a vim-plugin which detects what language I am writing (by looking at the &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;?php&lt;/code&gt; tags maybe?) and indent in the right way with the right syntax color and stuff?&lt;/p&gt;&#xA;" OwnerUserId="26000" LastEditorUserId="51" LastEditDate="2020-04-24T17:44:03.613" LastActivityDate="2023-05-11T23:10:06.203" Title="Vim plugin for different languages in one webfile" Tags="|indentation|filetype-php|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24846" PostTypeId="1" AcceptedAnswerId="24847" CreationDate="2020-04-24T14:13:17.003" Score="7" ViewCount="944" Body="&lt;p&gt;Similarly to plug-ins, color schemes are commonly distributed as clone-able Git repositories, which make it less desirable to directly edit their source files (as sometimes suggested) when wanting to customize their behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of plug-ins, Vim offers the &lt;code&gt;after-directory&lt;/code&gt; mechanism, which allows &lt;em&gt;personal preferences to overrule or add to the distributed defaults or system-wide settings&lt;/em&gt;. For example, &lt;code&gt;~/.vim/after/ftplugin/fortran.vim&lt;/code&gt;, if it exists, will automatically be read following the distributed &lt;code&gt;fortran.vim&lt;/code&gt; while files in &lt;code&gt;after/plugin/&lt;/code&gt; may be used in a similar way to customize individual plug-ins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this behaviour isn't supported for &lt;code&gt;colors/&lt;/code&gt; as documented:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;:colo[rscheme] {name}&lt;/code&gt; searches &lt;code&gt;'runtimepath'&lt;/code&gt; for the file &lt;code&gt;&quot;colors/{name}.vim&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The first one that is found is loaded.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Given that color schemes may be dynamically re-loaded (&lt;em&gt;e.g.&lt;/em&gt; after setting &lt;code&gt;'background'&lt;/code&gt;), simply patching it in &lt;code&gt;.vimrc&lt;/code&gt; once it has been loaded is not enough. Furthermore, this does not scale well when managing many color schemes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation for &lt;code&gt;:colorscheme&lt;/code&gt; suggests:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To customize a colorscheme use another name, &lt;em&gt;e.g.&lt;/em&gt; &lt;code&gt;~/.vim/colors/mine.vim&lt;/code&gt;, and use &lt;code&gt;:runtime&lt;/code&gt; to load the original colorscheme:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime colors/evening.vim&#xA;hi Statement ctermfg=Blue guifg=Blue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, this is inconsistent with and seems less transparent than what is&#xA;described above (&lt;em&gt;e.g.&lt;/em&gt; requiring another name). So, How can I can obtain&#xA;the automatic behavior of &lt;code&gt;after-directory&lt;/code&gt; for color schemes?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/10897&quot;&gt;How do I customize vimdiff colors?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/3355&quot;&gt;Why do custom highlights in my vimrc get cleared or reset to default?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vi.stackexchange.com/questions/12796&quot;&gt;vim 8.0 not honoring custom colors&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On Stackoverflow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/19520433&quot;&gt;How to set color after pathogen load colorscheme in VIM&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="23696" LastEditorUserId="23696" LastEditDate="2020-04-24T15:05:40.667" LastActivityDate="2020-04-25T12:30:15.277" Title="How to customize colorschemes without editing their source files?" Tags="|colorscheme|plugin-system|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24847" PostTypeId="2" ParentId="24846" CreationDate="2020-04-24T14:13:17.003" Score="7" Body="&lt;p&gt;The &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=1641&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;AfterColors&lt;/code&gt;&lt;/a&gt; plug-in (&lt;a href=&quot;https://github.com/vim-scripts/AfterColors.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub mirror&lt;/a&gt;) provides an &lt;code&gt;after-directory&lt;/code&gt; auto-loading mechanism for color schemes. This can however be easily achieved in modern Vim by using the &lt;code&gt;ColorScheme&lt;/code&gt; autocommand event (triggered after loading a color scheme and added in &lt;a href=&quot;https://github.com/vim/vim/commit/b95186fd36bae9716181bfdd203fb27f410e3c4f&quot; rel=&quot;nofollow noreferrer&quot;&gt;v7.0164&lt;/a&gt;) and &lt;code&gt;&amp;lt;amatch&amp;gt;&lt;/code&gt; (which holds the new color scheme name and was added in &lt;a href=&quot;https://github.com/vim/vim/commit/b95186fd36bae9716181bfdd203fb27f410e3c4f&quot; rel=&quot;nofollow noreferrer&quot;&gt;v7.4.109&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd ColorScheme {pat} runtime &quot;after/colors/&quot; . expand(&quot;&amp;lt;amatch&amp;gt;&quot;) . &quot;.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will read &lt;code&gt;after/colors/{scheme}.vim&lt;/code&gt; whenever the color scheme named &lt;code&gt;{scheme}&lt;/code&gt;&#xA;(based on &lt;code&gt;g:colors_name&lt;/code&gt;) is loaded, as long as &lt;code&gt;{sheme}&lt;/code&gt; corresponds to the&#xA;globbing pattern &lt;code&gt;{pat}&lt;/code&gt;. The pattern &lt;code&gt;*&lt;/code&gt; can be used to match any scheme:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd ColorScheme * runtime &quot;after/colors/&quot; . expand(&quot;&amp;lt;amatch&amp;gt;&quot;) . &quot;.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which also supports color schemes missing &lt;code&gt;after/colors/&lt;/code&gt; custom scripts as&#xA;non-existing arguments aren't considered as errors by &lt;code&gt;runtime&lt;/code&gt;. This one-liner allows you to structure your color scheme customization under your &lt;code&gt;after-directory&lt;/code&gt; (typically &lt;code&gt;~/.vim/after/colors/&lt;/code&gt;) by using a file per scheme.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As auto-commands obviously have to be declared before being called, make sure&#xA;to place the &lt;code&gt;autocmd&lt;/code&gt; calls &lt;strong&gt;before&lt;/strong&gt; calling &lt;code&gt;:colorscheme&lt;/code&gt;, in your&#xA;&lt;code&gt;.vimrc&lt;/code&gt;. Finally, multiple autocommands may listen to the same event and will be&#xA;triggered sequentially in the order in which they were defined so that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd ColorScheme * runtime &quot;after/colors/&quot; . expand(&quot;&amp;lt;amatch&amp;gt;&quot;) . &quot;.vim&quot;&#xA;autocmd ColorScheme * runtime &quot;after/colors/common.vim&quot;&#xA;colorscheme {scheme}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will read both &lt;code&gt;after/colors/{scheme}.vim&lt;/code&gt; (if it exists) and &lt;code&gt;after/colors/common.vim&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, sharing customization between schemes &lt;code&gt;{A}&lt;/code&gt; and &lt;code&gt;{B}&lt;/code&gt; may be done through&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd ColorScheme {A} runtime &quot;after/colors/{B}.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or by appending the following to &lt;code&gt;after/colors/{A}.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime &quot;after/colors/{B}.vim&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the former is more powerful given that a globbing pattern &lt;code&gt;{pat}&lt;/code&gt; may be used.&lt;/p&gt;&#xA;" OwnerUserId="23696" LastEditorUserId="23696" LastEditDate="2020-04-25T12:30:15.277" LastActivityDate="2020-04-25T12:30:15.277" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24848" PostTypeId="1" AcceptedAnswerId="24849" CreationDate="2020-04-24T14:29:09.777" Score="1" ViewCount="1428" Body="&lt;p&gt;When editing long markdown documents it is really good to be able to navigate in them with the &lt;code&gt;:Toc&lt;/code&gt; option from &lt;a href=&quot;https://github.com/plasticboy/vim-markdown&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-markdown&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also edit long .Rmd documents from vim (when the content is more about text than about R code). &#xA;I have added the following to my ~/.vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:vim_markdown_auto_extension_ext = 'Rmd'                                                  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:Toc&lt;/code&gt; works fine in &lt;code&gt;.md&lt;/code&gt; documents, but when I enter &lt;code&gt;:Toc&lt;/code&gt; in a .Rmd document, I get the error: &quot;E492: Not an editor command: Toc&quot;.&lt;/p&gt;&#xA;" OwnerUserId="6671" OwnerDisplayName="Paul Rougieux" LastActivityDate="2020-04-24T15:12:44.520" Title="How to use vim-markdown :Toc: for documents with extension other than .md" Tags="|filetype-markdown|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24849" PostTypeId="2" ParentId="24848" CreationDate="2020-04-24T15:12:44.520" Score="1" Body="&lt;p&gt;The vim-markdown documentation isn't really very clear about &lt;code&gt;g:vim_markdown_auto_extension_ext&lt;/code&gt;, but that's actually about the extension it will add to URLs it builds from links in your markdown. It will default to &lt;code&gt;.md&lt;/code&gt;, but you can override it here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, it will only &lt;a href=&quot;https://github.com/plasticboy/vim-markdown/blob/master/ftdetect/markdown.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;recognize&lt;/a&gt; a few extensions such as &lt;code&gt;*.md&lt;/code&gt;, &lt;code&gt;*.markdown&lt;/code&gt; and a few others as being of type &quot;markdown&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to accept &lt;code&gt;*.Rmd&lt;/code&gt; as a markdown, you should add your own autocmd for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can either create a new file under &lt;code&gt;~/.vim/ftdetect&lt;/code&gt;, such as &lt;code&gt;~/.vim/ftdetect/Rmd.vim&lt;/code&gt; with the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.Rmd set ft=markdown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can add a new augroup block to your vimrc instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; augroup filetypedetect_markdown&#xA;   au!&#xA;   au BufRead,BufNewFile *.Rmd set ft=markdown&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-24T15:12:44.520" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24850" PostTypeId="1" AcceptedAnswerId="24856" CreationDate="2020-04-24T15:57:25.800" Score="4" ViewCount="471" Body="&lt;p&gt;I've done extensive reading including &lt;code&gt;:h omap-info&lt;/code&gt; and &lt;a href=&quot;https://learnvimscriptthehardway.stevelosh.com/chapters/15.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim the hardway operator pending mode&lt;/a&gt;, this part is espcially good:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A good way to keep the multiple ways of creating operator-pending&#xA;mappings straight is to remember the following two rules:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If your operator-pending mapping ends with some text visually selected, Vim will operate on that text.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Otherwise, Vim will operate on the text between the original cursor position and the new position.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I feel have been fighting point 2 above for days, so I have lot's of questions, if you could answer even one that would be awesome:&lt;/p&gt;&#xA;&lt;h1&gt;Question 1&lt;/h1&gt;&#xA;&lt;p&gt;An omap consists of movement commands, or creating a visual range&#xA;e.g. To operate on the whole buffer:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function MyTest_E()&#xA;    normal! ggVG&#xA;endfun&#xA;onoremap E :&amp;lt;C-u&amp;gt; call MyTest_E()&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The above works, but what if I wish to perform some function before or after. This does not restore the position (which is my purpose for trying to figure this out):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function MyTest_F()&#xA;    let restore_position = winsaveview()&#xA;    normal! ggVG&#xA;    call winrestview(restore_position)&#xA;endfun&#xA;onoremap F :&amp;lt;C-u&amp;gt; call MyTest_F()&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Question 2&lt;/h1&gt;&#xA;&lt;p&gt;How does one cancel an operator pending command, so one can &amp;quot;hi-jack&amp;quot; it, e.g.:&#xA;If one calls the below function with &lt;code&gt;dA&lt;/code&gt;, it should end up YANKING the whole buffer, but I can't force the existing operator pending command to cancel, but always ends up executing the orginal function (i.e. &lt;code&gt;d&lt;/code&gt; in this case) after &lt;code&gt;ggVGy&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function MyTest_H()&#xA;    normal \&amp;lt;Esc&amp;gt;&#xA;    call feedkeys(&amp;quot;\e&amp;quot;)&#xA;    call feedkeys(&amp;quot;\&amp;lt;Esc&amp;gt;&amp;quot;)&#xA;    call feedkeys(&amp;quot;\&amp;lt;Esc&amp;gt;&amp;quot;, &amp;quot;ix&amp;quot;)&#xA;    call feedkeys(&amp;quot;\&amp;lt;Esc&amp;gt;&amp;quot;, &amp;quot;tx&amp;quot;)&#xA;    call feedkeys(&amp;quot;\&amp;lt;Esc&amp;gt;&amp;quot;, &amp;quot;itx&amp;quot;)&#xA;    let restore_position = winsaveview()&#xA;    normal! ggVGy&#xA;    call winrestview(restore_position)&#xA;endfun&#xA;onoremap H :&amp;lt;C-u&amp;gt; call MyTest_H()&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I also tried to change &lt;code&gt;opfunc&lt;/code&gt; to nothing (&lt;code&gt;Dummy()&lt;/code&gt; below) so that when it exits the motion handler, it does not perform the orginal &lt;code&gt;opfunc&lt;/code&gt;, but it didnt work, the orginal opfunc is still run:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! Dummy()&#xA;    echom &amp;quot;Psyc!&amp;quot;&#xA;endfun&#xA;function! MyTest_J(op)&#xA;    echom &amp;quot;J orig_op: &amp;quot;.a:op&#xA;    set opfunc=Dummy&#xA;    normal ggVG&#xA;endfun&#xA;onoremap J :call MyTest_J(v:operator)&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What the flip does it take to abort an operator in motion, and run one's own function instead??&lt;/p&gt;&#xA;&lt;h1&gt;Question 3&lt;/h1&gt;&#xA;&lt;p&gt;Can one simply return a range within an &lt;code&gt;omap&lt;/code&gt; e.g. &lt;code&gt;:1,$&lt;/code&gt; to mean all lines. The best I could come up with is as follows, but I feel there must be a much simpler way:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function MyTest_H()&#xA;    let restore_position = winsaveview()&#xA;    let startpos = [0,1,0,'off']&#xA;    let endpos   = [0,line(&amp;quot;$&amp;quot;),0,'off']&#xA;    call setpos(&amp;quot;'&amp;lt;&amp;quot;, startpos)&#xA;    call setpos(&amp;quot;'&amp;gt;&amp;quot;, endpos)&#xA;    normal gv&#xA;    call winrestview(restore_position)&#xA;endfun&#xA;onoremap H :&amp;lt;C-u&amp;gt; call MyTest_H()&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Question 4&lt;/h1&gt;&#xA;&lt;p&gt;Maybe I am on the wrong track, and instead of trying to restore the position in the motion, I should be doing it after the operator. I am not a fan of this, because this means one would have to create a custom mapping for every operator. Is it possible to change the y command to map to something like the code below?&#xA;(I have tried with g@ but get errors about it being too recursive):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:call SavePosition()|y{motion}|:call RestorePosition()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note: Using NeoVim if that makes any difference.&lt;/p&gt;&#xA;" OwnerUserId="27110" LastEditorUserId="27110" LastEditDate="2020-06-22T09:50:37.050" LastActivityDate="2020-06-22T09:50:37.050" Title="Creating custom text objects via omap - How to run functions after the motion" Tags="|operator|operator-pending-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24851" PostTypeId="2" ParentId="24842" CreationDate="2020-04-24T16:17:29.197" Score="2" Body="&lt;p&gt;Try it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s/&amp;amp;\zs.\{-}\ze&amp;amp;/ /gc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Disassembled:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;&lt;/code&gt; is the literal ampersand&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\zs&lt;/code&gt; sets the start of the match&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;.\{-}&lt;/code&gt; matches any characters - but as &lt;em&gt;few&lt;/em&gt; as possible&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\ze&lt;/code&gt; sets the end of the match&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;&lt;/code&gt; is the literal ampersand&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are two special things here= &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First &lt;code&gt;\zs...\ze&lt;/code&gt;: The part between them are the matched text, the ampersand before and after are just &quot;anchors&quot;. This is important, as otherwise the matches would overlap like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &amp;amp;  This Stuff   &amp;amp;  Other Stuff  &amp;amp;&#xA; |-- 1st match --|&#xA;                 |-- 2nd match --|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second &lt;code&gt;.\{-}&lt;/code&gt;: The dot matches any character and the &lt;code&gt;\{-}&lt;/code&gt; defines zero or more matches, but as few as possible. The next character in the match is a &lt;code&gt;&amp;amp;&lt;/code&gt;. So it matches zero or more chars until it finds a ampersand. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The replacement is just a simple whitespace, as we just replace the part between the ampersands.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2020-04-24T16:23:13.863" LastActivityDate="2020-04-24T16:23:13.863" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24852" PostTypeId="1" AcceptedAnswerId="24853" CreationDate="2020-04-24T18:23:18.413" Score="4" ViewCount="1228" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;If you have an American English keyboard, pressing Ctrl-[ (control plus left square bracket) is equivalent to pressing Esc. This provides an easy way to exit from insert mode. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;source: &lt;a href=&quot;https://vim.fandom.com/wiki/Avoid_the_escape_key&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vim.fandom.com/wiki/Avoid_the_escape_key&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I just learned this after spending the last 3 months full time going nuts over why pressing escape double for me activated some function that I didn't want. Because obviously double escape should not be different from single escape.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So turns out I have the &lt;code&gt;Ctrl-[&lt;/code&gt; key in use... Which turns out is something poisoned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yeah so I'm gonna keep myself civil and not ask why on earth this is a thing, but just kindly ask if there is a way to turn that &quot;feature&quot; off?&lt;/p&gt;&#xA;" OwnerUserId="29177" LastEditorUserId="28" LastEditDate="2020-04-30T09:17:36.307" LastActivityDate="2020-04-30T09:17:36.307" Title="How to remove the mapping from Ctrl-[ to Escape?" Tags="|key-bindings|escape|" AnswerCount="1" CommentCount="2" ClosedDate="2020-04-30T13:42:15.470" ContentLicense="CC BY-SA 4.0" />
  <row Id="24853" PostTypeId="2" ParentId="24852" CreationDate="2020-04-24T18:40:39.840" Score="9" Body="&lt;p&gt;Vim is a terminal based program and has its key handling from the terminal. Also the GUI variants still act like this (with a few extensions).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a terminal &lt;code&gt;Ctrl-A&lt;/code&gt; is ASCII &lt;code&gt;0x01&lt;/code&gt;, &lt;code&gt;Ctrl-B&lt;/code&gt; is ASCII &lt;code&gt;0x02&lt;/code&gt; and so on.&#xA;&lt;code&gt;Ctrl-Z&lt;/code&gt; is &lt;code&gt;0x1A&lt;/code&gt; and &lt;code&gt;Ctrl-[&lt;/code&gt; is &lt;code&gt;0x1B&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;code&gt;0x1B&lt;/code&gt; is also the ASCII code for &lt;code&gt;ESC&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vim can't differentiate between &lt;code&gt;ESC&lt;/code&gt; and &lt;code&gt;Ctrl-[&lt;/code&gt;, because it gets the same key code when either is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the same reason it can't differentiate between &lt;code&gt;Ctrl-I&lt;/code&gt; and &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt;. Both produce &lt;code&gt;0x09&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2020-04-24T18:40:39.840" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24854" PostTypeId="1" CreationDate="2020-04-24T19:05:02.597" Score="1" ViewCount="147" Body="&lt;p&gt;I have the following in my &lt;code&gt;~/vim/syntax/xrc.vim&lt;/code&gt; to spell check contents of specific tags when editing XRC files that are just XML files with predefined schema:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runtime syntax/xml.vim&#xA;&#xA;&quot; check spelling for the user-visible strings.&#xA;syn region xrcString matchgroup=xmlTagName start=&quot;&amp;lt;\z(label\|text\|tooltip\|value\)&amp;gt;&quot; end=&quot;&amp;lt;/\z1&amp;gt;&quot; contains=xmlEntity,@Spell&#xA;&#xA;&quot; and also highlight them as such.&#xA;hi link xrcString xmlString&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it works without problems -- as long as I don't also try doing &lt;code&gt;let g:xml_syntax_folding=1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I enable syntax folding for XML, my region definition is not taken into account any longer (at least not with Vim 8.2). It seems to be due to the different &lt;code&gt;xmlRegion&lt;/code&gt; definition in this case in Vim own &lt;code&gt;syntax/xml.vim&lt;/code&gt;, but I'm not really sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I'd like to have both folding and spell checking for my tags. Does anybody know how to do this?&lt;/p&gt;&#xA;" OwnerUserId="372" LastActivityDate="2020-04-24T19:05:02.597" Title="XML syntax folding and custom tag spell checking" Tags="|folding|spell-checking|filetype-xml|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24855" PostTypeId="1" AcceptedAnswerId="24880" CreationDate="2020-04-24T20:33:36.250" Score="1" ViewCount="246" Body="&lt;p&gt;I usually keep &lt;code&gt;*.in&lt;/code&gt; files open in split and edit them. I would like vim to autosave the &lt;code&gt;*.in&lt;/code&gt; files whenever I switch between splits. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Searching other answers I found &lt;code&gt;BufLeave&lt;/code&gt; that suits my case. I have below in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd BufLeave *.in :w!&amp;lt;cr&amp;gt;   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this gives below error when I switch out of the split that has a &lt;code&gt;*.in&lt;/code&gt; file open:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing BufLeave Auto commands for &quot;*.in&quot;:&#xA;E13: File exists (add ! to override)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am able to normally execute &lt;code&gt;:w&lt;/code&gt; and &lt;code&gt;:w!&lt;/code&gt; in the vim window successfully, but this auto save short cut is not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vim details&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ vim --version&#xA;VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Dec  3 2019 04:38:39)&#xA;Included patches: 1-503, 505-680, 682-1283, 1365&#xA;Compiled by root@apple.com&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What could be the issue? Any help?&lt;/p&gt;&#xA;" OwnerUserId="8092" LastEditorUserId="8092" LastEditDate="2020-04-25T07:15:38.320" LastActivityDate="2020-04-25T16:01:20.473" Title="BufLeave: Auto save split file not working" Tags="|autocmd|split|save|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24856" PostTypeId="2" ParentId="24850" CreationDate="2020-04-24T20:58:45.193" Score="5" Body="&lt;p&gt;Interesting question! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading your attempts of code made me think of the order in which the operations are actually executed, which is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The &lt;code&gt;omap&lt;/code&gt; motion or text object is executed and selected.&lt;/li&gt;&#xA;&lt;li&gt;The operator command (&lt;code&gt;y&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;g~&lt;/code&gt;, etc.) is executed on that block of text.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It seems to me that some of your assumptions have the model backwards and assume that the operator command is somehow already &quot;pending&quot; when the &lt;code&gt;omap&lt;/code&gt; function is executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that in mind, let's address your more specific questions one-by-one:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question 1&lt;/h2&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But what if I wish to perform some function before or after? This does not restore the position (which is my purpose for trying to figure this out.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you think of the order, you'll see that the &lt;code&gt;omap&lt;/code&gt; function will run to completion first and &lt;em&gt;then&lt;/em&gt; the operator will execute. To have something execute &lt;em&gt;after&lt;/em&gt; the operator you need to have that action pending to only be processed after that action finished.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out that you &lt;em&gt;can&lt;/em&gt; do that using &lt;a href=&quot;https://vimhelp.org/eval.txt.html#feedkeys%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;feedkeys()&lt;/code&gt;&lt;/a&gt;, since it only adds keystrokes to the typeahead buffer and will only process them once it's done with the current action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the second action will take place out of the context of the current function, you'll have to preserve the information (in this case the &lt;code&gt;restore_position&lt;/code&gt;) in some kind of global variable. You can use either &lt;code&gt;g:&lt;/code&gt;, &lt;code&gt;s:&lt;/code&gt; or &lt;code&gt;b:&lt;/code&gt;, whatever works best in your case. (In my case I'll use global ones for simplicity, but it should just work in all other cases as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A first solution to this problem (a little bit naive):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyTest_F()&#xA;    let g:restore_position = winsaveview()&#xA;    normal! ggVG&#xA;    call feedkeys(&quot;:call winrestview(g:restore_position)\&amp;lt;CR&amp;gt;&quot;, &quot;n&quot;)&#xA;endfunction&#xA;onoremap F :&amp;lt;C-U&amp;gt;call MyTest_F()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will work as you expect. &lt;code&gt;yF&lt;/code&gt; will yank the whole buffer, but leave the cursor in the same place. Also a nice test is &lt;code&gt;g~F&lt;/code&gt; to swap case of the whole buffer, again leaving the cursor and window view where they currently are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One small shortcoming here is that &lt;code&gt;yF&lt;/code&gt; will not show you the &lt;code&gt;44 lines yanked&lt;/code&gt; message, instead the &lt;code&gt;:call winrestview(...)&lt;/code&gt; command will be left in the command-line. You can clear the command-line by adding a &lt;code&gt;&quot;\&amp;lt;C-L&amp;gt;&quot;&lt;/code&gt; to the end of that feedkeys, but a better solution is to use a separate normal-mode mapping to execute the second part of the mapping, make that one &lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt; and feed the keys for that one instead. You can use the &lt;code&gt;&amp;lt;Plug&amp;gt;&lt;/code&gt; special key for that purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a better solution is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyTest_F()&#xA;    let g:restore_position = winsaveview()&#xA;    normal! ggVG&#xA;    call feedkeys(&quot;\&amp;lt;Plug&amp;gt;(MyTest_RestoreView)&quot;)&#xA;endfunction&#xA;onoremap F :&amp;lt;C-U&amp;gt;call MyTest_F()&amp;lt;CR&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Plug&amp;gt;(MyTest_RestoreView) :call winrestview(g:restore_position)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should also preserve the message printed by the operator, whenever one is printed!&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question 2&lt;/h2&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How does one cancel an operator pending command, so one can &quot;hi-jack&quot; it?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Again, if you think of the order, first the &lt;code&gt;omap&lt;/code&gt; happens and selects a region and then the operator is executed on that region. So you can't really &lt;em&gt;send&lt;/em&gt; a cancellation keystroke (like &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-C&amp;gt;&lt;/code&gt;) the the operator... But what you &lt;em&gt;can&lt;/em&gt; do is send it an &lt;em&gt;empty&lt;/em&gt; region, in which case it will do &lt;em&gt;nothing&lt;/em&gt;, which in essence is the same as &lt;em&gt;cancelling&lt;/em&gt; it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So with this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyTest_H()&#xA;    let restore_position = winsaveview()&#xA;    normal! ggyG&#xA;    call winrestview(restore_position)&#xA;endfun&#xA;onoremap H :&amp;lt;C-U&amp;gt;call MyTest_H()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;dH&lt;/code&gt; will yank the whole buffer and not delete anything. (In fact, with this specific function you'll even get the &lt;code&gt;44 lines yanked&lt;/code&gt; message.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out you can even access &lt;code&gt;v:register&lt;/code&gt; from inside your &lt;code&gt;omap&lt;/code&gt; function, so you can even have &lt;code&gt;&quot;adH&lt;/code&gt; yank the whole buffer into the &lt;code&gt;&quot;a&lt;/code&gt; register, with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyTest_H()&#xA;    let restore_position = winsaveview()&#xA;    silent execute &quot;normal! gg\&quot;&quot;.v:register.&quot;yG&quot;&#xA;    call winrestview(restore_position)&#xA;endfun&#xA;onoremap H :&amp;lt;C-U&amp;gt;call MyTest_H()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that hijacking an operator this way looks pretty hacky... Yeah it works, but is it really a good idea to do so? In any case, I guess the key here is that creating an &lt;em&gt;empty&lt;/em&gt; motion is a simple way to cancel the original operation, which I guess is what you were trying to determine here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the &lt;code&gt;opfunc&lt;/code&gt; attempt, setting &lt;code&gt;opfunc&lt;/code&gt; is not really applicable unless you're going to use &lt;code&gt;g@&lt;/code&gt; at some point, which you're not really doing here.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Question 3&lt;/h2&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can one simply return a range within an &lt;code&gt;omap&lt;/code&gt; e.g. &lt;code&gt;:1,$&lt;/code&gt; to mean all lines. The best I could come up with is as follows, but I feel there must be a much simpler way.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, you need to have a visual selection at the end of your function (assuming you don't want the cursor position in any of the two extremities of the selection), so no I don't think there's a much easier way than this one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call setpos(&quot;.&quot;, startpos)&#xA;normal! v&#xA;call setpos(&quot;.&quot;, endpos)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that's about the same thing, so probably not that much simpler...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you can't have a &lt;code&gt;winrestview()&lt;/code&gt; there, it will undo your visual selection, so you'll be left with nothing. (See question #1 again for a way to handle restoring the view after the operator has finished.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the small simplification I have to suggest is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function MyTest_H()&#xA;    let startpos = [0,1,0,'off']&#xA;    let endpos   = [0,line(&quot;$&quot;),0,'off']&#xA;    call setpos(&quot;.&quot;, startpos)&#xA;    normal! v&#xA;    call setpos(&quot;.&quot;, endpos)&#xA;endfun&#xA;onoremap H :&amp;lt;C-U&amp;gt;call MyTest_H()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Question 4&lt;/h2&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Instead of trying to restore the position in the motion, I should be doing it after the operator. Is it possible to change the &lt;code&gt;y&lt;/code&gt; command to map to something like the code below? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, it is possible to create a &lt;code&gt;y&lt;/code&gt; operator that will restore the cursor to its original position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to do so, you set an &lt;code&gt;opfunc&lt;/code&gt; that will execute the yanking and then you call &lt;code&gt;g@&lt;/code&gt; to take a motion for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here there's a question of order of operations again, since by the time your &lt;code&gt;opfunc&lt;/code&gt; starts to execute, &lt;em&gt;your cursor will have already moved&lt;/em&gt; as a result of the motion or &lt;code&gt;omap&lt;/code&gt; captured by &lt;code&gt;g@&lt;/code&gt;. So you need to save your view &lt;em&gt;before&lt;/em&gt; you execute &lt;code&gt;g@&lt;/code&gt;. Which means you'll have to save it and restore it in two different contexts, meaning again you'll need to use a global to preserve it between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a way to make that work, creating a separate &lt;code&gt;\y&lt;/code&gt; (or &lt;code&gt;&amp;lt;leader&amp;gt;y&lt;/code&gt;) mapping that will preserve the cursor position after the yank:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! YankRestore(type, ...) abort&#xA;    if a:type == 'line'&#xA;        normal! '[y']&#xA;    else&#xA;        normal! `[y`]&#xA;    endif&#xA;    call winrestview(g:restore_position)&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;y :let g:restore_position=winsaveview()&amp;lt;Bar&amp;gt;set opfunc=YankRestore&amp;lt;CR&amp;gt;g@&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-operator&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help :map-operator&lt;/code&gt;&lt;/a&gt; for an example of writing an appropriate &lt;code&gt;opfunc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also want to have your function handle visual mode and create a corresponding &lt;code&gt;xnoremap&lt;/code&gt; to handle &lt;code&gt;&amp;lt;leader&amp;gt;y&lt;/code&gt; the same way from visual mode. (You could even have it preserve the visual selection, by running &lt;code&gt;gv&lt;/code&gt; after the yank!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully this advice has been useful and this answer will improve your understanding of how operators and &lt;code&gt;omap&lt;/code&gt; functions work!&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-24T20:58:45.193" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24857" PostTypeId="1" AcceptedAnswerId="24860" CreationDate="2020-04-24T21:05:47.653" Score="0" ViewCount="79" Body="&lt;p&gt;When I type &lt;code&gt;:set inc&lt;/code&gt; it doesn't work and below status bar shows &lt;code&gt;include=^\s*\(from\|import\)&lt;/code&gt;. Even when I turn on &lt;strong&gt;GVim&lt;/strong&gt; it shows &lt;code&gt;include=^\s*#\s*include&lt;/code&gt; error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my &lt;code&gt;.vimrc&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocp&#xA;filetype plugin indent on&#xA;set hls inc ar ai wrap lbr nu rnu et magic sc acd aw sb spr mouse=a sw=4 sts=4 ts=4 ls=2 bs=indent,eol,start&#xA;autocm BufNewFile *.cpp -r ~/Templates/CP_C++.cpp&#xA;let mapleader = &quot;,&quot;&#xA;nnoremap &amp;lt;F9&amp;gt; :w&amp;lt;BAR&amp;gt;:!clear &amp;amp;&amp;amp; g++ -Wall -g -std=gnu++14 -static -DLOCAL &quot;%:p&quot; &amp;amp;&amp;amp; ./a.out&amp;lt;CR&amp;gt;&#xA;imap &amp;lt;F9&amp;gt; &amp;lt;ESC&amp;gt;&amp;lt;F9&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;b :ls&amp;lt;CR&amp;gt;:buffer&amp;lt;Space&amp;gt;&#xA;inoremap &amp;lt;leader&amp;gt;; &amp;lt;ESC&amp;gt;&#xA;nnoremap &amp;lt;leader&amp;gt;f :let @+ = expand(&quot;%:p&quot;)&amp;lt;CR&amp;gt;&#xA;noremap &amp;lt;leader&amp;gt;a ggVG&#xA;noremap &amp;lt;leader&amp;gt;c &quot;+y&#xA;noremap &amp;lt;leader&amp;gt;d &quot;_d&#xA;inoremap {&amp;lt;CR&amp;gt; {&amp;lt;CR&amp;gt;}&amp;lt;ESC&amp;gt;O&#xA;inoremap ( ()&amp;lt;left&amp;gt;&#xA;inoremap [ []&amp;lt;left&amp;gt;&#xA;inoremap &quot; &quot;&quot;&amp;lt;left&amp;gt;&#xA;inoremap ' ''&amp;lt;left&amp;gt;&#xA;vnoremap fb &amp;lt;ESC&amp;gt;`&amp;gt;a)&amp;lt;ESC&amp;gt;`&amp;lt;i(&amp;lt;ESC&amp;gt;&#xA;vnoremap qq &amp;lt;ESC&amp;gt;`&amp;gt;a&quot;&amp;lt;ESC&amp;gt;`&amp;lt;i&quot;&amp;lt;ESC&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29180" LastActivityDate="2020-04-24T22:40:33.153" Title="'include=^\s*\(from\|import\)' error in vim" Tags="|terminal|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24858" PostTypeId="1" AcceptedAnswerId="24879" CreationDate="2020-04-24T21:23:55.813" Score="1" ViewCount="189" Body="&lt;p&gt;Is it possible to set color for the warning message &quot;Swap file XXX already exists! ...&quot;? I couldn't figure out which highlight group it belongs to.&lt;/p&gt;&#xA;" OwnerUserId="29181" LastActivityDate="2020-04-25T10:47:08.637" Title="How to set colors for vim warnings about existing swap files" Tags="|highlight|color|original-vim|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24860" PostTypeId="2" ParentId="24857" CreationDate="2020-04-24T22:40:33.153" Score="1" Body="&lt;p&gt;This is expected. You're simply asking Vim what the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27inc%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'include'&lt;/code&gt;&lt;/a&gt; option (short name &lt;code&gt;'inc'&lt;/code&gt;) is currently set to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use &lt;code&gt;:set&lt;/code&gt; with an option that takes a value but don't include any &lt;code&gt;=&lt;/code&gt;s, Vim will simply tell you what that option is set to, which is what you're seeing here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From our discussion in comments, we established you were actually trying to enable &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27incsearch%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'incsearch'&lt;/code&gt;&lt;/a&gt; instead, which you can do with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set incsearch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can shorten it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set is&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-24T22:40:33.153" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24861" PostTypeId="1" AcceptedAnswerId="24867" CreationDate="2020-04-24T23:39:21.783" Score="1" ViewCount="389" Body="&lt;p&gt;To grab a full word from anywhere in the word I can do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;viw&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And to grab an entire line from start to finish I can do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, is there a section that grabs all text from the first char to the last? For example, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LJGCx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LJGCx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find myself selecting the line of text (from anywhere in the line) quite frequently and it seems like this is a pretty common thing to do.&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-25T11:42:11.340" Title="Selector for line of text?" Tags="|vimrc|cursor-motions|custom-text-object|selection|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24862" PostTypeId="1" AcceptedAnswerId="24864" CreationDate="2020-04-24T23:42:42.940" Score="6" ViewCount="1213" Body="&lt;p&gt;I find myself often selecting text and then wanting to go to the start of that selection rather than the end. For example in the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3l9XP.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3l9XP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;code&gt;esc&lt;/code&gt;, it will take me to the end of the selection, but often I find myself wanting to go to the beginning of a visual selection. Is there an easy way to do this?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-12-26T17:39:46.513" Title="How to go back to the start of a visual selection?" Tags="|cursor-motions|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24863" PostTypeId="1" CreationDate="2020-04-25T00:08:09.287" Score="3" ViewCount="311" Body="&lt;p&gt;I use ruler format like this,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set rulerformat=%36(%5l,%-6(%c%V%)\ %f%)%*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LXtC7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LXtC7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if the filename gets too long, it will be broken. So I like to align left, but It can't be align like statusline &lt;code&gt;%=&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="29186" LastActivityDate="2020-04-25T00:08:09.287" Title="How to set rulerformat to align left and full width in vim?" Tags="|vimrc|neovim|ruler|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24864" PostTypeId="2" ParentId="24862" CreationDate="2020-04-25T00:31:55.790" Score="11" Body="&lt;p&gt;You can use the &lt;a href=&quot;https://vimhelp.org/visual.txt.html#v_o&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;o&lt;/code&gt;&lt;/a&gt; visual-mode command to jump to the &quot;other&quot; end of the visual selection.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-25T00:31:55.790" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24865" PostTypeId="1" AcceptedAnswerId="24869" CreationDate="2020-04-25T01:25:32.957" Score="0" ViewCount="102" Body="&lt;p&gt;When I enter a search it shows me the input in the command bar, for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ygrn3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ygrn3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I enter in a command from the command history, for example clicking enter on line 50:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ktwnk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ktwnk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't shown any visual indicator that the string being searched is &quot;Hello&quot;. Is there a way to make it such that all commands show up in the command-bar at the bottom?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-25T11:51:43.727" Title="How to always show a command" Tags="|command-line|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24866" PostTypeId="1" AcceptedAnswerId="24868" CreationDate="2020-04-25T01:34:45.830" Score="1" ViewCount="2379" Body="&lt;p&gt;Sometimes I enter in characters and my screen shows &quot;Mark not set&quot;, and it seems like I have to either press escape or q a bunch of times to get out of that 'mode'. So, related to this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What does 'Mark not set' mean?&lt;/li&gt;&#xA;&lt;li&gt;How is it that I'm normally coming across that (for example, what keys am I probably unknowingly pressing to get there?)&lt;/li&gt;&#xA;&lt;li&gt;Once that happens, what's the quickest way to 'dismiss' that and get back to a normal mode?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-25T02:20:30.343" Title="Understanding and navigating Mark / Mark not set" Tags="|vimrc|mark|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24867" PostTypeId="2" ParentId="24861" CreationDate="2020-04-25T02:05:29.623" Score="2" Body="&lt;p&gt;The fastest I can come up with is really &lt;code&gt;^vg_&lt;/code&gt; to be precise about start and end of line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, by way of challenge, perhaps you really need &lt;code&gt;dd&lt;/code&gt;, &lt;code&gt;yy&lt;/code&gt;, &lt;code&gt;cc&lt;/code&gt;, or similar? Even &lt;code&gt;guu&lt;/code&gt; and &lt;code&gt;g~~&lt;/code&gt; work.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you can do it with an ex command, &lt;code&gt;.&lt;/code&gt; is the shortest &quot;this line&quot; range; note that many commands take it by default.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-04-25T02:23:55.813" LastActivityDate="2020-04-25T02:23:55.813" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24868" PostTypeId="2" ParentId="24866" CreationDate="2020-04-25T02:20:30.343" Score="3" Body="&lt;p&gt;The ways to jump to a mark are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;'m&lt;/code&gt; jump to line of mark &lt;code&gt;m&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;`m&lt;/code&gt; jump to line and column of mark &lt;code&gt;m&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;you can technically do &lt;code&gt;:'m&lt;/code&gt;, since the range &lt;code&gt;:'m&lt;/code&gt; is the line of mark &lt;code&gt;m&lt;/code&gt;, and entering a range as an ex command goes to the first line (or last, if one is provided).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;More at &lt;code&gt;:help mark-motions&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I usually hit &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-25T02:20:30.343" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24869" PostTypeId="2" ParentId="24865" CreationDate="2020-04-25T02:23:05.437" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#E199&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;C-c&amp;gt;&lt;/code&gt;&lt;/a&gt; in any of the command-line windows puts the current line into the command-line, just like I'd never left. This re-enables things like &lt;code&gt;hlsearch&lt;/code&gt; and other features.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-04-25T11:51:43.727" LastActivityDate="2020-04-25T11:51:43.727" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24870" PostTypeId="1" AcceptedAnswerId="24873" CreationDate="2020-04-25T02:31:00.097" Score="2" ViewCount="130" Body="&lt;p&gt;I've come across regex substitutions in vim, but was wondering if there was more the concept of something like &lt;code&gt;regex.group()&lt;/code&gt; in vim. For example, from the site &quot;VimGolf&quot;, here is one example input:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;john doe &amp;lt;john.doe@mail.com&amp;gt;; alice hoover &amp;lt;alice.hoover@mail.com&amp;gt;; justin teen &amp;lt;jteen@mail.com&amp;gt;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The goal here is to capture the emails only. Normally I would do this with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; re.findall(r'&amp;lt;(.+?)&amp;gt;',s)&#xA;# ['john.doe@mail.com', 'alice.hoover@mail.com', 'jteen@mail.com']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet I haven't come across the idea of only gathering items matched by a regex as opposed to doing a substitution. Is something like that possible to do in vim, or what?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regex I'd use for substitution here would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/[^&amp;lt;]\+&amp;lt;\([^&amp;gt;]\+\)&amp;gt;;/\1 /g&#xA;&quot; john.doe@mail.com alice.hoover@mail.com jteen@mail.com &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this seems like a very crude approach where grouping should be used. &lt;/p&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="28904" LastEditDate="2020-04-25T02:39:51.347" LastActivityDate="2020-04-25T11:10:47.713" Title="Gathering groups (only) in regex" Tags="|regular-expression|" AnswerCount="1" CommentCount="0" ClosedDate="2020-04-25T21:50:00.683" ContentLicense="CC BY-SA 4.0" />
  <row Id="24871" PostTypeId="1" AcceptedAnswerId="24874" CreationDate="2020-04-25T02:55:14.430" Score="0" ViewCount="2000" Body="&lt;p&gt;Is there any difference between doing the following two commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,19g!/let/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,19v/let/d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or is &lt;code&gt;v&lt;/code&gt; an alias for &lt;code&gt;g!&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-25T04:10:10.843" Title="g! vs v in vim command" Tags="|command-line|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24872" PostTypeId="1" AcceptedAnswerId="24875" CreationDate="2020-04-25T03:49:47.410" Score="2" ViewCount="1650" Body="&lt;p&gt;I'm coming to Vim from VSCode. So far, it's been great although I've noticed I have some muscle memory movements that I've had trouble moving to Vim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I write something like this (cursor is denoted by the underscore: &lt;code&gt;_&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;updateCollections: collectionMap =&amp;gt; {_}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I hit enter, in VSCode a new indented line is inserted and the closing bracket is shifted below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;updateCollections: collectionMap =&amp;gt; {&#xA;  _&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I hit enter in Vim, the closing bracket remains on the right side:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;updateCollections: collectionMap =&amp;gt; {&#xA;  _}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's not a big deal, but kind of forces me to hit enter, and use my arrow keys to go up which leads me to the beginning of the line, so I have to keep pressing the right arrow key until I'm in the right position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a setting or command to automate this? I already have &lt;code&gt;smartindent&lt;/code&gt; and &lt;code&gt;autoindent&lt;/code&gt; on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below are my vim settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; VIM General&#xA;&quot; ==================================&#xA;let mapleader=&quot;,&quot;&#xA;&quot; nmap &amp;lt;silent&amp;gt; gd &amp;lt;Plug&amp;gt;(coc-definition)&#xA;set smarttab&#xA;set cindent&#xA;set autoindent&#xA;set smartindent&#xA;set nocompatible&#xA;set relativenumber&#xA;set splitright&#xA;set splitbelow&#xA;syntax on&#xA;set number &quot; show line number&#xA;set cursorline &quot; highligh current line&#xA;highlight Normal ctermbg=None&#xA;highlight LineNr ctermfg=DarkGrey&#xA;colorscheme onedark &quot; Set color scheme&#xA;set hlsearch &quot; Highlight matching search patterns&#xA;set incsearch &quot; Enable incremental search&#xA;nnoremap &amp;lt;Leader&amp;gt;&amp;lt;space&amp;gt; :noh&amp;lt;Enter&amp;gt; &#xA;set showmatch &quot; Show matching brackets.&#xA;set ignorecase &quot; Do case insensitive matching&#xA;set smartcase &quot; Include only uppercase words with uppercase search term&#xA;set tabstop=2&#xA;set shiftwidth=2&#xA;set encoding=UTF-8&#xA;set showmode&#xA;set encoding=utf-8&#xA;set termguicolors&#xA;set t_Co=256&#xA;set background=dark&#xA;imap jj &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29190" LastActivityDate="2023-05-12T09:42:41.150" Title="Creating a new indented line with a closing bracket below when hitting enter" Tags="|vimrc|indent|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24873" PostTypeId="2" ParentId="24870" CreationDate="2020-04-25T03:50:42.123" Score="2" Body="&lt;p&gt;The easiest way to handle this in vim script is probably using 'g' substitute.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let list = []&#xA;call substitute(string, '&amp;lt;\zs[^&amp;gt;]\+\ze&amp;gt;', '\=add(list, submatch(0))', 'g')&#xA;echo join(list, ' ')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An more tedious alternative is to loop over matches using &lt;code&gt;matchstrpos()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a too-clever solution with &lt;code&gt;split()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let list = string-&amp;gt;split('&amp;lt;[^&amp;gt;]\+&amp;gt;\zs', 1)[0:-2]-&amp;gt;map({_,x-&amp;gt;x-&amp;gt;matchstr('&amp;lt;\zs[^&amp;gt;]\+')})&#xA;echo list-&amp;gt;join(' ')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is to split &lt;em&gt;on&lt;/em&gt; your pattern using &lt;code&gt;\zs&lt;/code&gt; to keep the desired matches around, then grab the matches in each part.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2020-04-25T11:10:47.713" LastActivityDate="2020-04-25T11:10:47.713" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24874" PostTypeId="2" ParentId="24871" CreationDate="2020-04-25T04:10:10.843" Score="1" Body="&lt;p&gt;Yes, they're the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Av&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :v&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Same as &lt;code&gt;:g!&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(That's the whole contents of that help entry.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll find the description for &lt;code&gt;:g!&lt;/code&gt; under &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Ag&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :g&lt;/code&gt;&lt;/a&gt;, just below the description of &lt;code&gt;:g&lt;/code&gt; itself:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;:[range]g[lobal]!/{pattern}/[cmd]&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;blockquote&gt;&#xA;    &lt;p&gt;Execute the Ex command &lt;code&gt;[cmd]&lt;/code&gt; (default &lt;code&gt;:p&lt;/code&gt;) on the lines within &lt;code&gt;[range]&lt;/code&gt; where &lt;code&gt;{pattern}&lt;/code&gt; does &lt;strong&gt;NOT&lt;/strong&gt; match.&lt;/p&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-25T04:10:10.843" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24875" PostTypeId="2" ParentId="24872" CreationDate="2020-04-25T04:51:19.560" Score="2" Body="&lt;p&gt;My recommendation to get this resulting effect is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Right after typing &lt;code&gt;{&lt;/code&gt; at the end of the first line, press &quot;Enter&quot;, you will get something like below, with the cursor on an indented line:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&#xA;updateCollections: collectionMap =&gt; {&#xA;    _&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Then, &lt;em&gt;and only then&lt;/em&gt;, press &lt;code&gt;}&lt;/code&gt;. This will unindent the line and you'll get this, with the cursor on the &lt;code&gt;}&lt;/code&gt;:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&#xA;updateCollections: collectionMap =&gt; {&#xA;}&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Press &quot;Esc&quot; to leave Insert mode.&lt;/li&gt;&#xA;&lt;li&gt;Type &lt;a href=&quot;https://vimhelp.org/insert.txt.html#O&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;O&lt;/code&gt;&lt;/a&gt; to start insert mode on a line above the current one. As long as &lt;code&gt;'cinkeys'&lt;/code&gt; (or &lt;code&gt;'indentkeys'&lt;/code&gt;) includes &lt;code&gt;O&lt;/code&gt; (it does by default), the inserted line will be indented, and you'll end up with the desired:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&#xA;updateCollections: collectionMap =&gt; {&#xA;    _&#xA;}&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you already have the &lt;code&gt;{}&lt;/code&gt; pair, then the auto-indentation will not &lt;em&gt;always&lt;/em&gt; help you with the &lt;code&gt;}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will normally get the &lt;code&gt;}&lt;/code&gt; properly unindented to match the statement where the opening &lt;code&gt;{&lt;/code&gt; is if you set a proper filetype and you use an indent plug-in for that language. (At least for &lt;code&gt;filetype=c&lt;/code&gt; the indent plug-in will get this right.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's not the case and the &lt;code&gt;}&lt;/code&gt; is indented, then I'd use &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-D&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ctrl+D&lt;/a&gt; (in Insert mode) to unindent it back to match the opening line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I'd use the same &quot;Esc&quot;, &lt;code&gt;O&lt;/code&gt; technique to insert an indented line inside the block.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;One more handy shortcut here is that instead of &quot;Esc&quot;, &lt;code&gt;O&lt;/code&gt; to insert a line above the &lt;code&gt;}&lt;/code&gt;, you can also use &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-O&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ctrl+O&lt;/a&gt; followed by &lt;code&gt;O&lt;/code&gt;. The Ctrl+O key allows you to enter a single normal mode command from insert mode. But if that command (in this case &lt;code&gt;O&lt;/code&gt;) is bringing you back to insert mode, that's the same thing as the original sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might find typing Ctrl+O, &lt;code&gt;O&lt;/code&gt; easier than the sequence with &quot;Esc&quot;, since you're pressing the same key twice, only with different modifiers (first Ctrl, then Shift.) If you don't find that easier, then just use the original sequence &quot;Esc&quot;, &lt;code&gt;O&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to consider using a plug-in to help you here, then take a look at &lt;a href=&quot;https://github.com/jiangmiao/auto-pairs&quot; rel=&quot;nofollow noreferrer&quot;&gt;auto-pairs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With auto-pairs, when you type &lt;code&gt;{&lt;/code&gt;, you'll get &lt;code&gt;{}&lt;/code&gt; with the cursor inside the pair. If you then type &quot;Enter&quot;, you'll get the closing bracket on a line of its own, with the right indentation, and the cursor on an indented line inside the block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, when using that plug-in, just typing &quot;Enter&quot; on your original situation will get you to your desired result right away!&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-25T04:51:19.560" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24876" PostTypeId="2" ParentId="24861" CreationDate="2020-04-25T06:19:36.750" Score="3" Body="&lt;p&gt;Here's an &lt;code&gt;il&lt;/code&gt; operator that behaves like &lt;code&gt;iw&lt;/code&gt; but selects a line, from first to last non-blank character in the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! SelectLine(count) abort&#xA;  normal! gv&#xA;  if visualmode() !=# 'v'&#xA;    normal! v&#xA;  endif&#xA;  let startpos = getpos(&quot;'&amp;lt;&quot;)&#xA;  let endpos = getpos(&quot;'&amp;gt;&quot;)&#xA;  if startpos == endpos&#xA;    execute &quot;normal! ^o&quot;.a:count.&quot;g_&quot;&#xA;    return&#xA;  endif&#xA;  let curpos = getpos('.')&#xA;  if curpos == endpos&#xA;    normal! g_&#xA;    let curpos = getpos('.')&#xA;    if curpos == endpos&#xA;      execute &quot;normal!&quot; (a:count+1).&quot;g_&quot;&#xA;    elseif a:count &amp;gt; 1&#xA;      execute &quot;normal!&quot; a:count.&quot;g_&quot;&#xA;    endif&#xA;  else&#xA;    normal! ^&#xA;    let curpos = getpos('.')&#xA;    if curpos == startpos&#xA;      execute &quot;normal!&quot; a:count.&quot;-&quot;&#xA;    elseif a:count &amp;gt; 1&#xA;      execute &quot;normal!&quot; (a:count-1).&quot;-&quot;&#xA;    endif&#xA;  endif&#xA;endfunction&#xA;xnoremap &amp;lt;silent&amp;gt; il :&amp;lt;C-U&amp;gt;call SelectLine(v:count1)&amp;lt;CR&amp;gt;&#xA;onoremap &amp;lt;silent&amp;gt; il :&amp;lt;C-U&amp;gt;execute &quot;normal! ^v&quot;.v:count1.&quot;g_&quot;&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Supports usage in visual mode (e.g.&lt;code&gt;vil&lt;/code&gt;) or in operator mode (&lt;code&gt;yil&lt;/code&gt; to yank the line in characterwise mode.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Supports usage with a count (&lt;code&gt;v3il&lt;/code&gt; or &lt;code&gt;y3il&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In visual mode, it supports adding to the visual selection with further &lt;code&gt;il&lt;/code&gt;s adding more lines of text. Works both forward (when the cursor is at the end of the visual selection) or backward (when the cursor is at the start.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know that this operator is really that useful, considering in many cases you could just as well use a linewise operator or linewise visual mode instead... But I found myself wanting to yank a line in characterwise mode before, and this does it, so here it is if you find it useful.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-25T10:48:45.887" LastActivityDate="2020-04-25T10:48:45.887" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24877" PostTypeId="1" CreationDate="2020-04-25T07:00:23.707" Score="4" ViewCount="44" Body="&lt;p&gt;Suppose you are writing a vim plugin hosted on Github (which seems to be a standard for now). You don't want to maintain two help files: &lt;code&gt;README.md&lt;/code&gt; (Markdown) and &lt;code&gt;doc/your_plugin.txt&lt;/code&gt; (vim help) with quite the same content but different markup language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it would be useful to have original help content in one place and automatically convert it to other. Or even better to have templates you can include in both places to have slightly different version of help to new user and search enginges (README.md) and active user (vim help).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to make this templating or conversion?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD&lt;/strong&gt; I've found another discussion: &lt;a href=&quot;https://vi.stackexchange.com/questions/3752/how-do-i-generate-vim-documentation-from-markdown-notes-or-inline-comments-or-a&quot;&gt;How do I generate Vim documentation from Markdown notes or inline comments, or are there better ways to add documentation?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5182" LastEditorUserId="51" LastEditDate="2021-01-27T22:00:35.267" LastActivityDate="2021-01-27T22:00:35.267" Title="Convert VIM doc (vim help) to Markdown or vice versa" Tags="|help-system|" AnswerCount="0" CommentCount="6" ClosedDate="2020-06-18T11:11:40.623" ContentLicense="CC BY-SA 4.0" />
  <row Id="24878" PostTypeId="1" CreationDate="2020-04-25T10:20:17.027" Score="1" ViewCount="130" Body="&lt;p&gt;I have the following in my vimrc to open pdfs externally with &lt;code&gt;xpdf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! OpenPdfExternally()&#xA;  silent execute &quot;!xpdf &quot; . shellescape(expand(&quot;%:p&quot;)) . &quot; &amp;amp;&amp;gt;/dev/null &amp;amp;&quot;&#xA;  edit # &#xA;  bdelete #&#xA;  redraw!&#xA;  syntax on&#xA;  &quot; let @# = g:saved_altfile&#xA;endfunction&#xA;  &quot; autocmd BufReadPre *.pdf let g:saved_altfile = expand('#')&#xA;autocmd BufRead *.pdf call OpenPdfExternally()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works pretty well, but I would like to keep the alternate file that was set before opening the pdf and returning to the edited file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried the commented code, saving the alternative file before the pdf is read and then restoring it after the edited file is returned to, but no luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I keep the alternative file in this case?&lt;/p&gt;&#xA;" OwnerUserId="3316" LastActivityDate="2020-04-26T05:13:26.187" Title="Saving and resetting alternate file" Tags="|functions|alternate-file|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24879" PostTypeId="2" ParentId="24858" CreationDate="2020-04-25T10:47:08.637" Score="2" Body="&lt;p&gt;It is a bit surprising: my first guess was that one of &lt;code&gt;ErrorMsg&lt;/code&gt;, &lt;code&gt;Question&lt;/code&gt;, or &lt;code&gt;WarningMsg&lt;/code&gt; would work. Turns out the highlight group you are looking for is &lt;code&gt;MoreMsg&lt;/code&gt;, e.g.: &lt;code&gt;:highlight MoreMsg guifg=red&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-25T10:47:08.637" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24880" PostTypeId="2" ParentId="24855" CreationDate="2020-04-25T10:59:35.870" Score="3" Body="&lt;p&gt;Took me a while before I saw it. The problem is the&lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;.&#xA;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup autosave_buffer&#xA;  au!&#xA;  au BufLeave *.in :w&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you check your current directory, you will find a file named &lt;code&gt;'&amp;lt;cr&amp;gt;'&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2020-04-25T11:19:45.980" LastActivityDate="2020-04-25T11:19:45.980" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24881" PostTypeId="2" ParentId="23028" CreationDate="2020-04-25T11:06:20.257" Score="0" Body="&lt;p&gt;ctags creates a static index of language objects. When several objects share the same name it jumps to the first one in the index, I guess. It doesn't have a context, like which file you are editing, the imported modules, additional bindings, so it cannot be smarter, that's why language servers are currently the best option available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looks like you need a language server for C or C++. I haven't tried any of these, but besides ccls, there's &lt;a href=&quot;https://github.com/cquery-project/cquery&quot; rel=&quot;nofollow noreferrer&quot;&gt;cquery&lt;/a&gt; and &lt;a href=&quot;https://clangd.llvm.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;clangd&lt;/a&gt;, the latter seems to be the easier to install.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know COC is the most popular Vim client for language servers, but I think it's overly complex. If it gets hard to configure COC I suggest you try &lt;a href=&quot;https://github.com/autozimu/LanguageClient-neovim&quot; rel=&quot;nofollow noreferrer&quot;&gt;LanguageClient&lt;/a&gt;. Despite its repository name it also supports Vim&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-25T11:06:20.257" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24882" PostTypeId="1" AcceptedAnswerId="24884" CreationDate="2020-04-25T11:40:46.003" Score="1" ViewCount="189" Body="&lt;p&gt;I have this command to open the pdf created by a latex document:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType tex nnoremap &amp;lt;leader&amp;gt;p :silent !open $(echo &quot;%:p&quot; \| sed s/.tex/.pdf/g)&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which works, but I'd like to make 2 modifications:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the command should be executed silently, without appearing on the command line;&lt;/li&gt;&#xA;&lt;li&gt;if there is no pdf document associated with the tex file, I'd like to display an error message saying something like 'No pdf file...'&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;how can I do this?&lt;/p&gt;&#xA;" OwnerUserId="26480" LastActivityDate="2020-04-25T16:05:38.267" Title="Command to open pdf file when editing a latex document" Tags="|autocmd|filetype-tex|shell|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24883" PostTypeId="2" ParentId="24861" CreationDate="2020-04-25T11:42:11.340" Score="1" Body="&lt;p&gt;You can use plug-in &lt;a href=&quot;https://github.com/kana/vim-textobj-user&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-textobj-user&lt;/a&gt; to define custom text objects using patterns or higher level functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, vim-textobj-user uses &lt;code&gt;il&lt;/code&gt; as &lt;a href=&quot;https://github.com/kana/vim-textobj-user/blob/master/README.md#complex-text-objects-defined-by-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;an example&lt;/a&gt; of how to use the plug-in:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h2&gt;Complex text objects defined by functions&lt;/h2&gt;&#xA;  &#xA;  &lt;p&gt;Define &lt;code&gt;al&lt;/code&gt; to select the current line, and define &lt;code&gt;il&lt;/code&gt; to select the current line without indentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;call textobj#user#plugin('line', {&#xA;\   '-': {&#xA;\     'select-a-function': 'CurrentLineA',&#xA;\     'select-a': 'al',&#xA;\     'select-i-function': 'CurrentLineI',&#xA;\     'select-i': 'il',&#xA;\   },&#xA;\ })&#xA;&#xA;function! CurrentLineA()&#xA;  normal! 0&#xA;  let head_pos = getpos('.')&#xA;  normal! $&#xA;  let tail_pos = getpos('.')&#xA;  return ['v', head_pos, tail_pos]&#xA;endfunction&#xA;&#xA;function! CurrentLineI()&#xA;  normal! ^&#xA;  let head_pos = getpos('.')&#xA;  normal! g_&#xA;  let tail_pos = getpos('.')&#xA;  let non_blank_char_exists_p = getline('.')[head_pos[2] - 1] !~# '\s'&#xA;  return&#xA;  \ non_blank_char_exists_p&#xA;  \ ? ['v', head_pos, tail_pos]&#xA;  \ : 0&#xA;endfunction&#xA;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-25T11:42:11.340" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24884" PostTypeId="2" ParentId="24882" CreationDate="2020-04-25T12:35:21.203" Score="1" Body="&lt;p&gt;To execute the mapping silently, without the command appearing in the command-line, you should use the &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-silent&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;silent&amp;gt;&lt;/code&gt;&lt;/a&gt; modifier to &lt;code&gt;nnoremap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check that the file exists, you can use the &lt;a href=&quot;https://vimhelp.org/eval.txt.html#filereadable%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;filereadable()&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have to generate the PDF filename within Vim, but that shouldn't be hard, by using the additional &lt;code&gt;:r&lt;/code&gt; modifier to remove the extension. You'll also need &lt;code&gt;expand()&lt;/code&gt; to perform that expansion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's easier to use a separate function for the action, so you don't need to escape so many special characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One more note is that for a filetype mapping, you probably want to create a &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-local&quot; rel=&quot;nofollow noreferrer&quot;&gt;local mapping&lt;/a&gt; on the buffers with TeX files only. You might also want to use the &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3CLocalLeader%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;LocalLeader&amp;gt;&lt;/code&gt;&lt;/a&gt; prefix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When running the external shell command, you'll want to use &lt;code&gt;shellescape()&lt;/code&gt; to ensure the file name is safe and that you can properly handle paths with spaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! OpenPdf() abort&#xA;  let fname = expand('%:p:r').'.pdf'&#xA;  if filereadable(fname)&#xA;    execute 'silent !open '.shellescape(fname, 1)&#xA;  else&#xA;    echohl ErrorMsg&#xA;    echomsg 'No pdf file &quot;'.fname.'&quot;'&#xA;    echohl None&#xA;  endif&#xA;endfunction&#xA;&#xA;augroup tex_pdf&#xA;  au!&#xA;  au FileType tex nnoremap &amp;lt;buffer&amp;gt; &amp;lt;silent&amp;gt; &amp;lt;LocalLeader&amp;gt;p :&amp;lt;C-U&amp;gt;call OpenPdf()&amp;lt;CR&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-25T16:05:38.267" LastActivityDate="2020-04-25T16:05:38.267" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24885" PostTypeId="1" AcceptedAnswerId="24886" CreationDate="2020-04-25T14:38:13.063" Score="2" ViewCount="537" Body="&lt;p&gt;Is there any way to map same command to multiple key without repeating mapping. Like mapping this one&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap ) &amp;lt;right&amp;gt;&#xA;inoremap &quot; &amp;lt;right&amp;gt;&#xA;inoremap ] &amp;lt;right&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into something like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap ) &amp;lt;or&amp;gt; &quot; &amp;lt;or&amp;gt; ] &amp;lt;right&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible?&lt;/p&gt;&#xA;" OwnerUserId="29180" LastActivityDate="2020-04-25T15:33:03.477" Title="Shortcut for binding same command to multiple key" Tags="|vimrc|key-bindings|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24886" PostTypeId="2" ParentId="24885" CreationDate="2020-04-25T15:33:03.477" Score="3" Body="&lt;p&gt;It isn't possible unfortunately, but if it's something you tend to do often, you can write a function to do it for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CustomMap(commands, rhs, type)&#xA;    for l:command in a:commands&#xA;        sil!exe a:type.&quot;map &quot;.l:command.&quot; &quot;.a:rhs&#xA;    endfor&#xA;endfunction&#xA;&#xA;call CustomMap([')', '&quot;', ']'], '&amp;lt;right&amp;gt;', 'inore')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27331" LastActivityDate="2020-04-25T15:33:03.477" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24887" PostTypeId="1" AcceptedAnswerId="24896" CreationDate="2020-04-25T17:41:05.930" Score="1" ViewCount="1188" Body="&lt;p&gt;I have both &lt;code&gt;Vim version 8.1.1550&lt;/code&gt; and &lt;code&gt;NVIM v0.4.3&lt;/code&gt; on MacOS 10.14.6&lt;/p&gt;&#xA;&lt;p&gt;I wrote the following lines in my &lt;code&gt;.vimrc&lt;/code&gt; file as recommended &lt;a href=&quot;https://stackoverflow.com/questions/19932906/syntax-coloring-with-vim-and-fish-shell&quot;&gt;in this Stack Overflow answer&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set nocompatible&#xA;filetype off&#xA;&#xA;set rtp+=~/.vim/bundle/vundle/&#xA;call vundle#rc()&#xA;&#xA;Bundle 'gmarik/vundle'&#xA;Bundle 'dag/vim-fish'&#xA;&#xA;filetype plugin indent on    &amp;quot; required&#xA;highlight LineNr ctermfg=grey&#xA;&#xA;&amp;quot; set the runtime path to include Vundle and initialize&#xA;set rtp+=~/.vim/bundle/Vundle.vim&#xA;call vundle#begin()&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As indicated &lt;a href=&quot;https://github.com/dag/vim-fish&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, I also created a &lt;code&gt;~/.vim/ftplugin/fish.vim&lt;/code&gt; file and inserted the following in it:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; Set up :make to use fish for syntax checking.&#xA;compiler fish&#xA;&#xA;&amp;quot; Set this to have long lines wrap inside comments.&#xA;setlocal textwidth=79&#xA;&#xA;&amp;quot; Enable folding of block structures in fish.&#xA;setlocal foldmethod=expr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However I don't have highlighting for the following &lt;code&gt;fish_prompt.fish&lt;/code&gt; file when opening it with vim&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function fish_prompt&#xA;    set_color $fish_color_cwd&#xA;    echo ' [' (prompt_pwd) ' ] &amp;gt; '&#xA;end&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23561" LastEditorUserId="7244" LastEditDate="2022-06-30T13:48:41.840" LastActivityDate="2022-06-30T13:48:41.840" Title="Syntax highlighting for fish script not working" Tags="|syntax-highlighting|filetype|plugin-vundle|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24888" PostTypeId="1" AcceptedAnswerId="24889" CreationDate="2020-04-25T17:57:29.027" Score="3" ViewCount="201" Body="&lt;p&gt;I often have a situation where I will direct some output to a file then open it in vim and use ex commands (substitution, keep lines, delete lines, etc) to massage the output to a form I want. However sometimes I end up wanting to apply the same transformation to another set of text soon afterwards. I have to up arrow through all the commands and try and apply them in the same order again, which is slow and error prone. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to see if there is something like &lt;code&gt;Ctrl-o&lt;/code&gt; in the shell where you can select a certain history item then just replay all the commands after that in order by repeating a key. Does such a thing exist in vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Just to preempt any comments that try to point this out, I know that if I was going to be doing this transformation frequently I should just make a shell command. This is for one-off jobs where the feedback in vim is useful.)&lt;/p&gt;&#xA;" OwnerUserId="29197" LastActivityDate="2020-04-25T18:44:22.900" Title="How to replay ex commands in order?" Tags="|substitute|ex-mode|repeated-commands|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24889" PostTypeId="2" ParentId="24888" CreationDate="2020-04-25T18:31:33.270" Score="2" Body="&lt;p&gt;FWIW, I have &lt;a href=&quot;https://github.com/lacygoill/vim-readline/blob/fdca0b4a3170c1162d39a9cb0a18c2cd4344e081/plugin/readline.vim#L182&quot; rel=&quot;nofollow noreferrer&quot;&gt;a similar mapping on &lt;code&gt;C-o&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extracted as a standalone script, it should give something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cno &amp;lt;expr&amp;gt; &amp;lt;c-o&amp;gt; &amp;lt;sid&amp;gt;operate_and_get_next()&#xA;&#xA;augroup operate_and_get_next&#xA;    au!&#xA;    au CmdlineEnter : call timer_start(0, {-&amp;gt; s:operate_and_get_next_remember('on_leave')})&#xA;augroup END&#xA;&#xA;let s:HISTORY_MAX_SIZE = 10&#xA;fu s:operate_and_get_next() abort&#xA;    let cmdline = getcmdline()&#xA;    let history = get(s:, 'cmdline_history', [])&#xA;    let s:pos_in_history = (index(history, cmdline) + 1) % len(history)&#xA;    if len(history) == 0&#xA;        return ''&#xA;    endif&#xA;    let seq = history[s:pos_in_history]&#xA;    return &quot;\&amp;lt;cr&amp;gt;:&quot;..seq&#xA;endfu&#xA;&#xA;fu s:operate_and_get_next_remember(when) abort&#xA;    if mode() isnot# 'c'&#xA;        return&#xA;    endif&#xA;    if a:when is# 'on_leave'&#xA;        au CmdlineLeave : ++once call s:operate_and_get_next_remember('now')&#xA;    else&#xA;        let cmdline = getcmdline()&#xA;        let history = get(s:, 'cmdline_history', [])&#xA;        if cmdline is# ''&#xA;            return&#xA;        endif&#xA;        let s:cmdline_history = history + [cmdline]&#xA;        if len(history) &amp;gt; s:HISTORY_MAX_SIZE&#xA;            call remove(s:cmdline_history, 0)&#xA;        endif&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No idea how reliable it is because in practice, I rarely use it.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2020-04-25T18:31:33.270" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24890" PostTypeId="2" ParentId="24888" CreationDate="2020-04-25T18:44:22.900" Score="2" Body="&lt;p&gt;One great way to have access to multiple commands in your history is to use the command-line window, which you can access with the &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#q%3A&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;q:&lt;/code&gt;&lt;/a&gt; normal-mode command, or by pressing Ctrl+F from the Ex &lt;code&gt;:&lt;/code&gt; command-line prompt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From that window, you can yank the sequence of commands you're interested on (e.g. using a motion or visual mode), then quit the command window (with &lt;code&gt;:q&lt;/code&gt;) and put the commands back into a normal buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there, you can edit/tweak/reorder your Ex commands and then use any method to store and execute multiple Ex commands repeatedly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way to do it probably being storing the sequence of commands into a &lt;code&gt;*.vim&lt;/code&gt; file and then using the &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3Asource&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:source&lt;/code&gt;&lt;/a&gt; command to execute the script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can turn the sequence into a &lt;a href=&quot;https://vimhelp.org/eval.txt.html#user-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;function&lt;/a&gt; and storing it in your vimrc or a file that gets loaded automatically when Vim is started (such as a file named &lt;code&gt;*.vim&lt;/code&gt; under &lt;code&gt;~/.vim/plugin/&lt;/code&gt;), then use &lt;code&gt;:call&lt;/code&gt; to invoke the function or perhaps define a &lt;a href=&quot;https://vimhelp.org/map.txt.html#user-commands&quot; rel=&quot;nofollow noreferrer&quot;&gt;user command&lt;/a&gt; for improved usability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, one quick way to reuse them that doesn't involve creating new files is to yank the sequence of commands into a register and use the &lt;a href=&quot;https://vimhelp.org/repeat.txt.html#%3A%40&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:@&quot;&lt;/code&gt;&lt;/a&gt; command (assuming the default register, &lt;code&gt;:@a&lt;/code&gt; to use &lt;code&gt;&quot;a&lt;/code&gt;, etc.) to execute the contents of the register as an Ex command.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-25T18:44:22.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24892" PostTypeId="1" CreationDate="2020-04-25T19:34:16.777" Score="1" ViewCount="973" Body="&lt;p&gt;My completion mappings scheme with &lt;a href=&quot;https://github.com/neoclide/coc.nvim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;coc&lt;/a&gt; is the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-@&amp;gt;&lt;/code&gt; (ctrl-space): trigger the menu / use the selected item (or the first one)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-k&amp;gt;&lt;/code&gt;: navigate the list (or also trigger the menu)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-n&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt;: jump between snippets placeholders&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Which translates as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-@&amp;gt; pumvisible() ? coc#_select_confirm() : coc#refresh()&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-j&amp;gt; pumvisible() ? &quot;\&amp;lt;C-n&amp;gt;&quot; : coc#refresh()&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-k&amp;gt; pumvisible() ? &quot;\&amp;lt;C-p&amp;gt;&quot; : coc#refresh()&#xA;let g:coc_snippet_next = &amp;lt;c-n&amp;gt;&#xA;let g:coc_snippet_prev = &amp;lt;c-p&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works pretty well (and I'm glad each key does only one thing and my &quot;tab&quot; and &quot;enter&quot;, which are &lt;code&gt;&amp;lt;c-i&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-m&amp;gt;&lt;/code&gt;, are not remapped).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, when the popup completion menu is shown, the default behavior (navigate the menu) takes over the global variable given by the plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following (and more) to definitely shut the mapping when the menu is visible, with no success:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-n&amp;gt; pumvisible() ? &quot;\&amp;lt;c-y&amp;gt;&quot; : &quot;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-n&amp;gt; pumvisible() ? &quot;\&amp;lt;nop&amp;gt;&quot; : &quot;\&amp;lt;nop&amp;gt;&quot;&#xA;inoremap &amp;lt;expr&amp;gt; &amp;lt;c-n&amp;gt; &quot;\&amp;lt;nop&amp;gt;&quot;&#xA;inoremap &amp;lt;c-n&amp;gt; &amp;lt;nop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doing so, I noticed &lt;code&gt;&amp;lt;c-n&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-p&amp;gt;&lt;/code&gt; seem to be affected only by the &lt;code&gt;pumvisible()&lt;/code&gt; check for the regular pop menu, and not by the &lt;code&gt;coc&lt;/code&gt; pop menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's really driving me nuts since the above mappings, which use the same check, do work as intended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, there's something in the help from &lt;code&gt;coc&lt;/code&gt; which could possibly point the the right direction:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    inoremap &amp;lt;silent&amp;gt;&amp;lt;expr&amp;gt; &amp;lt;cr&amp;gt; pumvisible() ? coc#_select_confirm()&#xA;            \: &quot;\&amp;lt;C-g&amp;gt;u\&amp;lt;CR&amp;gt;\&amp;lt;c-r&amp;gt;=coc#on_enter()\&amp;lt;CR&amp;gt;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses &lt;code&gt;coc&lt;/code&gt;'s functions, which are not documented. I guess there's one to jump between placeholders, but I'm not able to find id.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your time!&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2020-04-25T20:20:34.990" LastActivityDate="2020-12-01T11:38:02.070" Title="Unmap &lt;c-n&gt; / &lt;c-p&gt; in completion menu to use as previous / next snippet placeholder with Coc" Tags="|autocompletion|snippets|ins-completion|plugin-coc|popup-menu|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24893" PostTypeId="2" ParentId="16071" CreationDate="2020-04-25T19:52:16.477" Score="1" Body="&lt;p&gt;You can also use &lt;code&gt;&amp;lt;c-r&amp;gt;=variable&amp;lt;cr&amp;gt;&lt;/code&gt; to expand variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let snippet_home = &quot;$HOME/.vim/templates/&quot;&#xA;nnoremap \html :-1read &amp;lt;c-r&amp;gt;=snippet_home&amp;lt;cr&amp;gt;/html_basic.snippet&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let text = &quot;Hello I am from Bangladesh&quot;&#xA;inoremap &amp;lt;f5&amp;gt; &amp;lt;c-r&amp;gt;=text&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you press &lt;kbd&gt;F5&lt;/kbd&gt; in insert mode, this will put &lt;code&gt;Hello I am from Bangladesh&lt;/code&gt; under your cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;N.B:&lt;/strong&gt; Using &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt; in the variable won't work as expected. You will need to use actual pipe ( &lt;code&gt;|&lt;/code&gt; ) instead of &lt;code&gt;&amp;lt;bar&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="29180" LastEditorUserId="29180" LastEditDate="2020-04-25T20:16:19.523" LastActivityDate="2020-04-25T20:16:19.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24894" PostTypeId="1" AcceptedAnswerId="24900" CreationDate="2020-04-25T20:41:00.333" Score="1" ViewCount="527" Body="&lt;p&gt;I can open and split multiple file like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:split file1&#xA;:split file2&#xA;:split file3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But is there any way to open multiple files in a single command? Something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:split file1 file2 file3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29180" LastActivityDate="2022-08-28T09:39:53.437" Title="How to open multiple file with single split command?" Tags="|vim-windows|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24895" PostTypeId="1" AcceptedAnswerId="24904" CreationDate="2020-04-25T21:30:03.710" Score="3" ViewCount="1317" Body="&lt;p&gt;Vim has both Visual and Select modes. Select mode is similar to Visual mode in some senses, but different in that when a printable character is typed, Vim will replace the selection with that character and continue in Insert mode (similar to how selections work on Notepad or Word or other text editors.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://vimhelp.org/map.txt.html#mapmode-v&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vmap&lt;/code&gt;&lt;/a&gt; command creates custom key mappings for both Visual &lt;em&gt;and&lt;/em&gt; Select mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's fine if you're mapping a key combination that starts with a non-printable character, such as &lt;code&gt;&amp;lt;F5&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;C-y&amp;gt;&lt;/code&gt;. But it's problematic when creating a mapping that starts with a printable character, such as &lt;code&gt;g&lt;/code&gt;, or &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt; that are often used for text objects in Visual mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The correct way to create such mappings is using &lt;code&gt;xmap&lt;/code&gt; (or, more precisely, &lt;code&gt;xnoremap&lt;/code&gt;, mappings should be created non-recursive whenever possible.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But since &lt;code&gt;vmap&lt;/code&gt; starts with a &lt;code&gt;v&lt;/code&gt; and &lt;strong&gt;V&lt;/strong&gt;isual mode both starts with a &quot;v&quot; and is entered with the &lt;code&gt;v&lt;/code&gt;, &lt;code&gt;V&lt;/code&gt; and &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; commands, a common mistake is for users to create Visual mode mappings using &lt;code&gt;vmap&lt;/code&gt;, even when they start with printable characters, such as the ones mentioned above or with &lt;code&gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;LocalLeader&amp;gt;&lt;/code&gt; which are by default and typically set to a printable character (such as &lt;code&gt;,&lt;/code&gt;) as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is of course not helped by Vim users not being very familiar with Select mode, since its use cases are more &quot;niche&quot; and typically Visual mode is the one used interactively. (Select mode is typically used by snippet engines, when highlighting fields that are meant to be replaced as the user types a value for the field.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So: &lt;strong&gt;Why did we get into this situation, in which &lt;code&gt;vmap&lt;/code&gt; also creates mappings for Select mode, even though many (most?) such mappings tend to just break Select mode?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Digging a little bit into the history of it, it seems Visual mode has been present at least since Vim 3.0 (1994, or even earlier.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Select mode was introduced in Vim 5.2 (August 1998.) At that point, &lt;code&gt;vmap&lt;/code&gt; was reused for Selection mode. (See &lt;code&gt;:help version5&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The separate &lt;code&gt;xmap&lt;/code&gt; and &lt;code&gt;smap&lt;/code&gt; commands were only introduced in Vim 7 (May 2006.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess the introduction of the separate mapping commands on Vim 7 acknowledges the mistake of reusing the same &lt;code&gt;vmap&lt;/code&gt; mapping for both Visual and Select mode back when the latter was introduced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then: &lt;strong&gt;Why not have &lt;code&gt;vmap&lt;/code&gt; return to affect Visual mode only and introduce a the new command (&lt;code&gt;xmap&lt;/code&gt;?) to affect both?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Was that perhaps a second mistake in how to handle this (admittedly difficult) situation? I can see the dilemma of how to fix it, since either way you're breaking backwards compatibility... But why fix it this way and not the other way around?&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="10604" LastEditDate="2020-04-26T12:47:15.070" LastActivityDate="2020-04-26T14:53:06.730" Title="Why is `vmap` for both Visual *and* Select mode?" Tags="|key-bindings|visual-mode|history-of|original-vim|select-mode|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24896" PostTypeId="2" ParentId="24887" CreationDate="2020-04-25T21:44:34.010" Score="1" Body="&lt;p&gt;Your Vundle configuration looks incorrect. You should call &lt;code&gt;vundle#begin()&lt;/code&gt; at the start, before the &lt;code&gt;Bundle&lt;/code&gt; commands. And you should call &lt;code&gt;vundle#end()&lt;/code&gt; at the end of that section, before you re-enable filetype detection and plug-ins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The &lt;code&gt;vundle#rc()&lt;/code&gt; function is an old way to initialize Vundle, it's deprecated now in favor of &lt;code&gt;vundle#begin()&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim/blob/master/README.md#quick-start&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vundle Getting Started page&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably also need to have &lt;code&gt;syntax enable&lt;/code&gt; somewhere in your vimrc (not sure if it's there, only not showing in your small snippet.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also use the canonical and more modern &lt;code&gt;'VundleVim/Vundle.vim'&lt;/code&gt; location for Vundle itself. (You might need to reinstall it into that location, see the first steps in the Getting Started guide for instructions on that.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also switched the plug-in declarations to use the more modern &lt;code&gt;Plugin&lt;/code&gt; instead of the older &lt;code&gt;Bundle&lt;/code&gt;. (Vundle went through a few iterations of renaming things...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;set nocompatible&#xA;filetype off&#xA;&#xA;set rtp+=~/.vim/bundle/&lt;b&gt;Vundle.vim&lt;/b&gt;&#xA;call vundle#&lt;b&gt;begin&lt;/b&gt;()&#xA;&#xA;&lt;b&gt;Plugin 'VundleVim/Vundle.vim'&lt;/b&gt;&#xA;&lt;b&gt;Plugin&lt;/b&gt; 'dag/vim-fish'&#xA;&#xA;&lt;b&gt;call vundle#end()&lt;/b&gt;&#xA;&#xA;filetype plugin indent on    &quot; required&#xA;&lt;b&gt;syntax enable&lt;/b&gt;&#xA;highlight LineNr ctermfg=grey&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hopefully straightening up your Vundle setup will get your fish syntax highlighting working as expected.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Personally, I'd actually recommend that you consider migrating from Vundle to &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-plug&lt;/a&gt;, which is a much more modern take on a plug-in manager that is still similar to Vundle (such that users of Vundle will see a familiar environment in vim-plug.) You could say vim-plug is in a way a &lt;em&gt;successor&lt;/em&gt; to Vundle in that sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can simply &lt;a href=&quot;https://github.com/junegunn/vim-plug/blob/master/README.md#installation&quot; rel=&quot;nofollow noreferrer&quot;&gt;install&lt;/a&gt; vim-plug with a simple shell command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \&#xA;      https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After installing it, update your vimrc to the following configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;call &lt;b&gt;plug#begin()&lt;/b&gt;&#xA;&#xA;&lt;b&gt;Plug&lt;/b&gt; 'dag/vim-fish'&#xA;&#xA;call &lt;b&gt;plug#end()&lt;/b&gt;&#xA;&#xA;filetype plugin indent on  &quot; optional!&#xA;syntax enable&#xA;highlight LineNr ctermfg=grey&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's all! No messing with &lt;code&gt;rtp&lt;/code&gt; or having to set &lt;code&gt;filetype off&lt;/code&gt; and back &lt;code&gt;on&lt;/code&gt; in the right order and locations...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you start Vim with this configuration, simply run &lt;code&gt;:PlugInstall&lt;/code&gt; to have your plug-ins installed by vim-plug. (Similar to how you would have used &lt;code&gt;:VundleInstall&lt;/code&gt; or &lt;code&gt;:PluginInstall&lt;/code&gt; on Vundle.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See vim-plug's &lt;a href=&quot;https://github.com/junegunn/vim-plug/blob/master/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; for more. In particular, you might want to take a look at this section on &lt;a href=&quot;https://github.com/junegunn/vim-plug/wiki/tips#migrating-from-other-plugin-managers&quot; rel=&quot;nofollow noreferrer&quot;&gt;migrating from other plug-in managers, Vundle in particular&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-25T21:56:27.653" LastActivityDate="2020-04-25T21:56:27.653" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24898" PostTypeId="1" CreationDate="2020-04-25T23:31:40.803" Score="1" ViewCount="1836" Body="&lt;p&gt;I'm using the regular Vim that comes with Ubuntu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following line of code in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd filetype py nnoremap &amp;lt;F10&amp;gt; :w &amp;lt;bar&amp;gt; !python3 %&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's not working, although I have a similar setup with &lt;code&gt;&amp;lt;F10&amp;gt;&lt;/code&gt; for cpp files.&lt;/p&gt;&#xA;" OwnerUserId="29204" LastEditorUserId="10604" LastEditDate="2020-04-26T14:33:08.843" LastActivityDate="2020-04-26T14:33:08.843" Title="Autocmd with a python file not working" Tags="|key-bindings|filetype-python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24899" PostTypeId="2" ParentId="24898" CreationDate="2020-04-26T03:33:20.013" Score="3" Body="&lt;p&gt;The correct FileType is &quot;python&quot; and not &quot;py&quot;. You can check for that by opening a Python file in Vim and checking the detected FileType with the &lt;code&gt;:set ft?&lt;/code&gt; command, which I'd expect will return the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set ft?&#xA;  filetype=python&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you create a mapping for a specific filetype (such as &quot;python&quot; in your case), make sure you create a &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Amap-local&quot; rel=&quot;nofollow noreferrer&quot;&gt;local mapping&lt;/a&gt; using &lt;code&gt;&amp;lt;buffer&amp;gt;&lt;/code&gt;. Otherwise the mapping will be global and will work on every buffer and not only those with Python source files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use an &lt;code&gt;autocmd&lt;/code&gt; in your vimrc, make sure you wrap it in an &lt;a href=&quot;https://vimhelp.org/autocmd.txt.html#%3Aaugroup&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;augroup&lt;/code&gt;&lt;/a&gt; to prevent getting duplicated commands if you reload your vimrc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting it all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup vimrc_python&#xA;  au!&#xA;  au FileType python nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F10&amp;gt; :w &amp;lt;bar&amp;gt; !python3 %&amp;lt;CR&amp;gt;&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can add filetype mappings for Python in a file &lt;code&gt;~/.vim/ftplugin/python.vim&lt;/code&gt; (or &lt;code&gt;python_*.vim&lt;/code&gt;, or &lt;code&gt;python/*.vim&lt;/code&gt;, inside that &lt;code&gt;ftplugin&lt;/code&gt; directory), which gets automatically loaded by Vim whenever a file of type Python is loaded. (That way you don't need to use explicit &lt;code&gt;autocmd&lt;/code&gt;s, Vim will take care of those details on your behalf.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use that approach, all you need inside that file to create this mapping is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F10&amp;gt; :w &amp;lt;bar&amp;gt; !python3 %&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-26T03:33:20.013" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24900" PostTypeId="2" ParentId="24894" CreationDate="2020-04-26T04:41:37.803" Score="3" Body="&lt;p&gt;This isn't possible with the default &lt;code&gt;:split&lt;/code&gt; command; you'll have to use a custom command such as &lt;code&gt;:Split&lt;/code&gt; (capital S) which loops over all the commandline arguments and calls &lt;code&gt;:split&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -nargs=+ -complete=file Split&#xA;            \  for s:f in [&amp;lt;f-args&amp;gt;]&#xA;            \|   exe 'split' fnameescape(s:f)&#xA;            \| endfor&#xA;            \| unlet s:f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can improve that a bit more by calling &lt;code&gt;glob()&lt;/code&gt;, so that &lt;code&gt;:Split *.vim&lt;/code&gt; will work as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -nargs=+ -complete=file Split&#xA;            \  for s:f in [&amp;lt;f-args&amp;gt;]&#xA;            \|   for s:m in glob(s:f, 0, 1)&#xA;            \|     exe 'split' fnameescape(s:m)&#xA;            \|   endfor&#xA;            \| endfor&#xA;            \| unlet s:f | unlet s:m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wrote &lt;a href=&quot;https://github.com/arp242/globedit.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;a little plugin&lt;/a&gt; a few years ago which does that for &lt;code&gt;:Tabedit&lt;/code&gt;, &lt;code&gt;:Edit&lt;/code&gt;, &lt;code&gt;:Split&lt;/code&gt;, and &lt;code&gt;:Vsplit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Related: &lt;a href=&quot;https://vi.stackexchange.com/q/2108/51&quot;&gt;How can I open multiple tabs at once?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="51" LastEditorUserId="51" LastEditDate="2020-04-26T05:39:29.340" LastActivityDate="2020-04-26T05:39:29.340" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24901" PostTypeId="2" ParentId="24878" CreationDate="2020-04-26T05:13:26.187" Score="1" Body="&lt;p&gt;This worked for me, but I'd say it's pretty hacky. I tested it somewhat, but it might be quite fragile.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! OpenPdfExternally()&#xA;  let saved_curfile = bufnr('#')&#xA;  silent execute &quot;!echo &quot;.shellescape(expand(&quot;%:p&quot;), 1).&quot; &amp;gt;&amp;gt;~/xpdf.log&quot;&#xA;  if bufexists(g:saved_altfile)&#xA;    execute &quot;buf&quot; g:saved_altfile&#xA;    bwipeout #&#xA;    execute &quot;buf&quot; saved_curfile&#xA;  else&#xA;    execute &quot;buf&quot; saved_curfile&#xA;    bwipeout #&#xA;  endif&#xA;  redraw!&#xA;  syntax on&#xA;endfunction&#xA;augroup openpdf&#xA;  au!&#xA;  au BufRead *.pdf call OpenPdfExternally()&#xA;  au BufEnter * let g:saved_altfile = bufnr('#')&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem saving the alternate file is that by the time we're processing events for the &lt;code&gt;*.pdf&lt;/code&gt; file, that's too late, since by then &lt;code&gt;%&lt;/code&gt; will be the buffer with the PDF and &lt;code&gt;#&lt;/code&gt; will be our previous current buffer... Our previous alternate buffer is gone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To work around that, I added a BufEnter event to always keep saving the last alternate buffer, so we can query it from our function triggered by the BufRead on &lt;code&gt;*.pdf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to restore the alternate file, we actually jump back to it &lt;em&gt;first&lt;/em&gt;, then we cleanup the &lt;code&gt;*.pdf&lt;/code&gt; buffer, then we jump to the buffer that's supposed to be the current buffer again. Since we just previously jumped to the alternate file, that file will once again be the alternate buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;bwipeout&lt;/code&gt; instead of &lt;code&gt;bdelete&lt;/code&gt;. That makes a difference in case there's no alternate file, in which case &lt;code&gt;bdelete&lt;/code&gt; will still leave the &lt;code&gt;*.pdf&lt;/code&gt; file as the alternate file, even if that buffer is unlisted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I'm tracking buffer numbers and not really filenames. I think it's generally easier that way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While this worked to some extent, I still think it's pretty hacky and I can think of quite a few scenarios in which this might just start misbehaving.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it would be much better if you could avoid this being triggered by an &lt;code&gt;:e document.pdf&lt;/code&gt; command and used a separate command for this purpose. Having said that, I don't really know your whole use case, so I can't tell why you need this particular sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I wonder whether a solution using BufReadCmd would be possible, since it allows you to hijack reading the &lt;code&gt;*.pdf&lt;/code&gt; file, but I think at the time it's invoked it already created a buffer for the file too. So not sure whether it can solve this problem in a more elegant way, but maybe it's worth taking a closer look.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-26T05:13:26.187" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24902" PostTypeId="2" ParentId="24894" CreationDate="2020-04-26T07:28:53.327" Score="2" Body="&lt;p&gt;This answer is based on Martin's &lt;a href=&quot;https://vi.stackexchange.com/a/24900/5017&quot;&gt;solution&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It add &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Cmods%3E&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h &amp;lt;mods&gt;&lt;/a&gt; to let you choose the split style, and &lt;a href=&quot;https://vimhelp.org/map.txt.html#%3Acommand-bang&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :command-bang&lt;/a&gt; to let you decide whether existing windows or tabs should be closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's implemented by &lt;code&gt;lambda&lt;/code&gt;, this &lt;code&gt;lambda&lt;/code&gt; is composed of two &lt;code&gt;execute(...)&lt;/code&gt; connected by &lt;code&gt;.&lt;/code&gt;(All expressions within one level are parsed from left to right).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com -nargs=+ -bang -complete=file Split&#xA;      \ call map( [&amp;lt;f-args&amp;gt;], { i,v -&amp;gt; execute('&amp;lt;mods&amp;gt; split ' . fnameescape(v) )&#xA;      \ . ( i == 0 &amp;amp;&amp;amp; &amp;lt;bang&amp;gt;0 &amp;amp;&amp;amp;&#xA;      \    execute('&amp;lt;mods&amp;gt;' =~# 'tab' ? 'tabonly' : 'wincmd o') ) } )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# split 3 new windows&#xA;Split a b c&#xA;&#xA;# close existing windows, split 3 new right below windows&#xA;rightbelow Split! a b c&#xA;&#xA;# close existing tabs, split 3 new tabs&#xA;tab Split! a b c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I didn't add the &lt;code&gt;glob&lt;/code&gt; part, you can use &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#c_CTRL-A&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h c_CTRL-A&lt;/a&gt; to expand the pattern into command line directly.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-04-26T11:19:15.367" LastActivityDate="2020-04-26T11:19:15.367" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24903" PostTypeId="2" ParentId="24894" CreationDate="2020-04-26T12:21:09.303" Score="2" Body="&lt;p&gt;I'd use the argument list for this.&lt;/p&gt;&#xA;&lt;p&gt;First, populate it with the file you need with &lt;code&gt;:args&lt;/code&gt; (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/editing.html#:args&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :args&lt;/a&gt;).&#xA;Then, use it to open its entries in a split with &lt;code&gt;:all&lt;/code&gt; (&lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/windows.html#:all&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h all&lt;/a&gt;) (or &lt;code&gt;:vert all&lt;/code&gt; for vertical splits).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:args file* | all&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;(&lt;code&gt;file*&lt;/code&gt; will grab any file name starting with &lt;code&gt;file&lt;/code&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2022-08-28T09:39:53.437" LastActivityDate="2022-08-28T09:39:53.437" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24904" PostTypeId="2" ParentId="24895" CreationDate="2020-04-26T14:30:08.590" Score="3" Body="&lt;p&gt;At the time we (maintainers of snippet/template engines) had mappings using &lt;code&gt;:vmap&lt;/code&gt; which were targetting the select mode. I still have a few traces of that in my lh-brackets plugin. Also the mswin.vim beasts were using &lt;code&gt;vmap&lt;/code&gt; instead of &lt;code&gt;smap&lt;/code&gt;, IIRC. I'm not sure if there were other big users of the select mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Evolutions that break what is already working, even imperfectly, are not really acceptable. We still have &lt;code&gt;:map&lt;/code&gt; and &lt;code&gt;:map!&lt;/code&gt;, and yet do they really still make sense?&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2020-04-26T14:53:06.730" LastActivityDate="2020-04-26T14:53:06.730" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24905" PostTypeId="2" ParentId="8333" CreationDate="2020-04-26T14:44:09.333" Score="1" Body="&lt;p&gt;Like many other plug-ins, NERDCommenter creates internal mappings using the &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; virtual key as a prefix, that you can use to map your own key-bindings to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/preservim/nerdcommenter/blob/c62e618a1ab5a50a4028e3296500ba29d9b033d8/doc/NERD_commenter.txt#L872&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help NERDCommenterMappings&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To change a mapping just map another key combo to the internal &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mapping.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;For example, to remap the &lt;code&gt;NERDCommenterComment&lt;/code&gt; mapping to &lt;code&gt;,omg&lt;/code&gt; you would put&#xA;  this line in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;map ,omg NERDCommenterComment&#xA;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;This will &lt;em&gt;stop the corresponding default mappings from being created&lt;/em&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;See the &lt;em&gt;help for the mapping in question&lt;/em&gt; to see which &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mapping to&#xA;  map to.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You can find which &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mapping to use by looking it up at the help for the original mapping.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;NERDCommenter will not add its default mapping if it finds another mapping pointing to the &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mapping already, so you can use that to prevent it from creating its own mappings (such as &lt;code&gt;&amp;lt;leader&amp;gt;cc&lt;/code&gt;), potentially overwriting yours.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that these mappings need to be recursive, since the &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; ones are mappings themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, I believe this is what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;cc &amp;lt;plug&amp;gt;NERDCommenterInvert &#xA;xmap &amp;lt;leader&amp;gt;cc &amp;lt;plug&amp;gt;NERDCommenterInvert &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This mapping is relevant in Normal and Visual modes, therefore remapping it with &lt;code&gt;nmap&lt;/code&gt; and &lt;code&gt;xmap&lt;/code&gt; here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also that since you're using a default mapping of NERDCommenter, you'll need to remap &lt;em&gt;that&lt;/em&gt; &lt;code&gt;&amp;lt;plug&amp;gt;&lt;/code&gt; mapping to some other key, in order to prevent NERDCommenter from overwriting your mapping. For example, to use &lt;code&gt;&amp;lt;leader&amp;gt;ci&lt;/code&gt; for the Comment mapping (effectively swapping the two keys):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;ci &amp;lt;plug&amp;gt;NERDCommenterComment&#xA;xmap &amp;lt;leader&amp;gt;ci &amp;lt;plug&amp;gt;NERDCommenterComment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But note that you don't need to use &lt;code&gt;&amp;lt;leader&amp;gt;ci&lt;/code&gt; here, you can use &lt;em&gt;any&lt;/em&gt; other key combination.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you would like to prevent NERDCommenter from adding &lt;em&gt;all&lt;/em&gt; its mappings, you can use this in your vimrc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:NERDCreateDefaultMappings = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/preservim/nerdcommenter/blob/c62e618a1ab5a50a4028e3296500ba29d9b033d8/doc/NERD_commenter.txt#L641&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help 'NERDCreateDefaultMappings'&lt;/code&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately it seems there's no granular way to prevent it from adding &lt;em&gt;one&lt;/em&gt; mapping only (if you wanted to leave one or a few functions without key-bindings), it's all or nothing.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-26T14:44:09.333" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24906" PostTypeId="1" AcceptedAnswerId="24910" CreationDate="2020-04-26T14:44:24.107" Score="0" ViewCount="397" Body="&lt;p&gt;Here's my section for &lt;code&gt;Easymotion&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:EasyMotion_do_mapping = 0&#xA;let g:EasyMotion_smartcase = 1&#xA;let g:EasyMotion_startofline = 0&#xA;&#xA;nnoremap fw &amp;lt;Plug&amp;gt;(easymotion-bd-w)&#xA;nnoremap fW &amp;lt;Plug&amp;gt;(easymotion-bd-W)&#xA;nnoremap fe &amp;lt;Plug&amp;gt;(easymotion-bd-e)&#xA;nnoremap fE &amp;lt;Plug&amp;gt;(easymotion-bd-E)&#xA;nnoremap fb &amp;lt;Plug&amp;gt;(easymotion-bd-b)&#xA;nnoremap fB &amp;lt;Plug&amp;gt;(easymotion-bd-B)&#xA;nnoremap ff{char} &amp;lt;Plug&amp;gt;(easymotion-s)&#xA;nnoremap ft{char} &amp;lt;Plug&amp;gt;(easymotion-bd-t)&#xA;nnoremap F &amp;lt;Plug&amp;gt;(easymotion-repeat)&#xA;nnoremap &amp;lt;C-f&amp;gt; &amp;lt;Plug&amp;gt;(easymotion-next)&#xA;nnoremap &amp;lt;C-F&amp;gt; &amp;lt;Plug&amp;gt;(easymotion-prev)&#xA;nnoremap fj &amp;lt;Plug&amp;gt;(easymotion-sol-j)&#xA;nnoremap fk &amp;lt;Plug&amp;gt;(easymotion-sol-k)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Expected behavior: like the default bindings but replacing &lt;code&gt;&amp;lt;Leader&amp;gt;&amp;lt;Leader&amp;gt;&lt;/code&gt; with &lt;code&gt;f&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reality: pressing &lt;code&gt;ff&lt;/code&gt; (and the other bindings) doesn't seem to do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried this with &lt;code&gt;nnoremap&lt;/code&gt; and &lt;code&gt;map&lt;/code&gt; but neither works. How should I fix this mapping?&lt;/p&gt;&#xA;" OwnerUserId="25859" LastActivityDate="2020-04-27T09:32:40.137" Title="Easymotion remapping not working (does nothing)" Tags="|key-bindings|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24907" PostTypeId="2" ParentId="24845" CreationDate="2020-04-26T17:06:11.470" Score="1" Body="&lt;p&gt;According to &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/usr_44.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim syntax documentation&lt;/a&gt;, you can define blocks of syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;syntax include @PHP syntax/php.vim&#xA;syntax include @CSS syntax/css.vim&#xA;syntax include @JS syntax/javascript.vim&#xA;syntax include @HTML syntax/html.vim&#xA;syntax region PHP  start=+&amp;lt;?php+ keepend end=+?&amp;gt;+  contains=@PHP&#xA;syntax region CSS  start=+&amp;lt;style&amp;gt;+ keepend end=+&amp;lt;/style&amp;gt;+  contains=@PHP&#xA;syntax region JS  start=+&amp;lt;script&amp;gt;+ keepend end=+&amp;lt;/script&amp;gt;+  contains=@PHP&#xA;syntax region HTML  start=+&amp;lt;html&amp;gt;+ keepend end=+&amp;lt;/html&amp;gt;+  contains=@PHP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22724" LastActivityDate="2020-04-26T17:06:11.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24908" PostTypeId="1" CreationDate="2020-04-26T19:39:13.483" Score="2" ViewCount="32" Body="&lt;p&gt;Assuming I have defined 2 commands in &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MultipleEmptyLinesToOne&#xA;RemoveExcessiveSpaces&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can run them in command-line mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:exec &quot;'&amp;lt;,'&amp;gt;MultipleEmptyLinesToOne&quot; | exec &quot;'&amp;lt;,'&amp;gt;RemoveExcessiveSpaces&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However this method doesn't support auto-completion while typing the commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can create a new user-defined command that runs them in a sequence:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range RemoveExcessiveSpaces2 exec &quot;'&amp;lt;,'&amp;gt;MultipleEmptyLinesToOne&quot; | exec &quot;'&amp;lt;,'&amp;gt;RemoveExcessiveSpaces&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it would be still great to know whether I can type (chain) any user-defined commands in command-line mode and have auto-completion at the same time.&lt;/p&gt;&#xA;" OwnerUserId="18651" LastActivityDate="2020-04-26T19:39:13.483" Title="Chaining user-defined commands" Tags="|command-line|user-commands|" AnswerCount="0" CommentCount="5" ClosedDate="2020-05-09T16:23:56.780" ContentLicense="CC BY-SA 4.0" />
  <row Id="24909" PostTypeId="2" ParentId="9366" CreationDate="2020-04-27T07:47:50.787" Score="-1" Body="&lt;p&gt;I looked to see which files/paths that &lt;code&gt;vim&lt;/code&gt; attempted to load, using &lt;code&gt;strace&lt;/code&gt; (as described &lt;a href=&quot;https://stackoverflow.com/a/3495323/550454&quot;&gt;here&lt;/a&gt;), then created a &lt;code&gt;~/.vim/after/plugin/&lt;/code&gt; directory (it was the last config location that &lt;code&gt;vim&lt;/code&gt; attempted to load), then symlinked my &lt;code&gt;~/.vimrc&lt;/code&gt; into that location:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mkdir -p ~/.vim/after/plugin/&#xA;ln -s ~/.vimrc ~/.vim/after/plugin/ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;What I did with &lt;code&gt;strace&lt;/code&gt;:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Basically, I ran:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strace -o ~/vim_strace vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...then immediately quit &lt;code&gt;vim&lt;/code&gt; (&lt;code&gt;:q!&lt;/code&gt;). Next, I loaded up &lt;code&gt;~/vim_strace&lt;/code&gt; (&lt;code&gt;$ vim ~/vim_strace&lt;/code&gt;) and went to the end (&lt;code&gt;:$&lt;/code&gt;). Then I started reading from the bottom looking for lines beginning with &lt;code&gt;openat(AT_FDCWD, &quot;/home/karl/.....&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing I see is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;openat(AT_FDCWD, &quot;/home/karl/.viminfo&quot;, O_RDONLY) = 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that isn't where I want my config options. The next line, right above the &lt;code&gt;.viminfo&lt;/code&gt; line, was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;openat(AT_FDCWD, &quot;/home/karl/.vim/after/plugin/&quot;, O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...&quot;No such file or directory&quot;, eh? Seems like a winner. So, that's the one I chose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, works perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this help someone somewhere.&lt;/p&gt;&#xA;" OwnerUserId="15211" LastActivityDate="2020-04-27T07:47:50.787" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24910" PostTypeId="2" ParentId="24906" CreationDate="2020-04-27T09:32:40.137" Score="1" Body="&lt;p&gt;I've solved the problem by using &lt;code&gt;map&lt;/code&gt; instead of &lt;code&gt;nnoremap&lt;/code&gt; and removing the &lt;code&gt;{char}&lt;/code&gt;s. The following code now works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map fw &amp;lt;Plug&amp;gt;(easymotion-w)&#xA;map fW &amp;lt;Plug&amp;gt;(easymotion-W)&#xA;map fe &amp;lt;Plug&amp;gt;(easymotion-bd-e)&#xA;map fE &amp;lt;Plug&amp;gt;(easymotion-bd-E)&#xA;map fb &amp;lt;Plug&amp;gt;(easymotion-b)&#xA;map fB &amp;lt;Plug&amp;gt;(easymotion-B)&#xA;map ff &amp;lt;Plug&amp;gt;(easymotion-s)&#xA;map ft &amp;lt;Plug&amp;gt;(easymotion-bd-t)&#xA;map F &amp;lt;Plug&amp;gt;(easymotion-repeat)&#xA;map &amp;lt;C-f&amp;gt; &amp;lt;Plug&amp;gt;(easymotion-next)&#xA;map &amp;lt;C-F&amp;gt; &amp;lt;Plug&amp;gt;(easymotion-prev)&#xA;map fj &amp;lt;Plug&amp;gt;(easymotion-sol-j)&#xA;map fk &amp;lt;Plug&amp;gt;(easymotion-sol-k)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25859" LastActivityDate="2020-04-27T09:32:40.137" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24911" PostTypeId="1" CreationDate="2020-04-27T10:31:59.230" Score="2" ViewCount="204" Body="&lt;p&gt;I got some code that &lt;code&gt;jobstart()&lt;/code&gt; a ripgrep, but if there is an error I wish to show it.&#xA;At the &lt;code&gt;on_exit&lt;/code&gt; callback a summary message is &lt;code&gt;echom&lt;/code&gt;'ed after whether it was successfull or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I only ever see the exit summary message, not the &quot;error&quot; message from &lt;code&gt;SearchOnStderr&lt;/code&gt; below:&#xA;Note: The reason I am not using &quot;echoerr&quot; is because I don't wish to have the line number and some other info printed (however echoerr does pause the messages to one can read it). Although &lt;code&gt;echo&lt;/code&gt; can print multiline, it is not added to the &lt;code&gt;:messages&lt;/code&gt;, hence I did not use that either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use an &lt;code&gt;input&lt;/code&gt; (like below), then I only see the &lt;code&gt;&quot;Press &amp;lt;ENTER&amp;gt; ...&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let dummy = input(&quot;Press &amp;lt;ENTER&amp;gt; ...&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:h echo-redraw&lt;/code&gt; talks about using redraws to prevent losing messages. But I have never gotten &lt;code&gt;redraw&lt;/code&gt; to help at all.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! myautoload#SearchOnStderr(job_id, data, event)&#xA;    let height_bak = &amp;amp;cmdheight&#xA;    set cmdheight=12&#xA;    redraw&#xA;    echom &quot;SEARCH ERROR, job_id:&quot;.a:job_id.&quot; event:&quot;.a:event&#xA;    echohl errormsg&#xA;    for errorLine in a:data&#xA;        echom errorLine&#xA;    endfor&#xA;    echohl normal&#xA;    &quot; ... WAIT HERE for enter to be pressed ...&#xA;    exe &quot;set cmdheight=&quot;.height_bak&#xA;endfun&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Desired output (With maybe a press enter to continue after it) is shown in the image below. This message is displayed too fast to read, so one has to look at &lt;code&gt;:messages&lt;/code&gt; to read it:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/2mcsv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2mcsv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDITS: Adding requested additional info. Yes I'm using Neovim.&#xA;Here's some of parts of the code of interest:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! myautoload#SearchInFiles()&#xA;    let g:searchString = input('Search in Files '.getcwd().': ')&#xA;    let g:search_errors = 0&#xA;    let rg_cmd = 'rg -H --no-heading --column --line-number --smart-case '.g:searchString&#xA;&#xA;    &quot; Clear the quickfix of entries&#xA;    silent copen &quot; Must be first so over operate on quickfix window&#xA;    let title = &quot; &quot;.g:searchString. &quot;     Command: &quot;.rg_cmd&#xA;    let context = {'cmd' : rg_cmd}&#xA;    call setqflist([], ' ', {'title' : title, 'context' : context})&#xA;    echom &quot;--------------------------------------------------&quot;&#xA;    echom &quot;About to start job...&quot;&#xA;    let opts_dict = {'on_exit': 'myautoload#SearchOnExit', 'on_stdout': 'myautoload#SearchOnStdout', 'on_stderr': 'myautoload#SearchOnStderr'}&#xA;    let terminal_buf_nr = jobstart(rg_cmd, opts_dict)&#xA;endfunction&#xA;&#xA;&#xA;&#xA;function! myautoload#SearchOnExit(job_id, data, event)&#xA;    &quot; Refer to :h getqflist-examples*&#xA;    let num_entries = getqflist({'size' : 0}).size&#xA;&#xA;    if g:search_errors&#xA;        echom &quot;Complete with ERRORS. &quot;.num_entries.&quot; entries for: &quot;.g:searchString&#xA;    else&#xA;        echom &quot;COMPLETE. &quot;.num_entries.&quot; entries for: &quot;.g:searchString&#xA;    endif&#xA;endfun&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27110" LastEditorUserId="27110" LastEditDate="2020-04-30T13:10:31.867" LastActivityDate="2020-04-30T13:10:31.867" Title="echom a multline message, and force pause" Tags="|echo|message|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="24912" PostTypeId="1" CreationDate="2020-04-27T10:42:27.127" Score="4" ViewCount="308" Body="&lt;p&gt;I want to join all the lines within a &lt;code&gt;{}&lt;/code&gt; block.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  'a': 1,&#xA;  'b': 2,&#xA;  'c': 3,&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;⬇︎&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ 'a': 1, 'b': 2, 'c': 3, }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;J&lt;/code&gt; doesn't take a range, like &lt;code&gt;d&lt;/code&gt; or &lt;code&gt;c&lt;/code&gt;, the best command I found to do this is going through virtual mode: &lt;code&gt;Va{J&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a nicer way to do the same?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is not a duplicated of &lt;a href=&quot;https://vi.stackexchange.com/questions/21674/why-doesnt-gjip-turn-a-paragraph-into-a-line&quot;&gt;Why doesn't gJip turn a paragraph into a line?&lt;/a&gt; since that question doesn't ask &lt;em&gt;how&lt;/em&gt; to turn a paragraph into a line. The proper answer of that question is &quot;&lt;code&gt;gJ&lt;/code&gt; doesn't work like that&quot;.&lt;/p&gt;&#xA;" OwnerUserId="2526" LastEditorUserId="8953" LastEditDate="2020-10-01T18:42:19.050" LastActivityDate="2020-10-01T18:42:19.050" Title="How to join lines within a block with `J`?" Tags="|object-motions|join|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24913" PostTypeId="2" ParentId="24912" CreationDate="2020-04-27T11:19:33.963" Score="5" Body="&lt;p&gt;This is called &quot;a motion&quot;. Even though linewise motions result in a line range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, it's enough to do &lt;code&gt;5J&lt;/code&gt; and there's no need for &quot;join&quot; operator. However, if you really want it, you can make use of &lt;code&gt;:h g@&lt;/code&gt; and &lt;code&gt;:h 'opfunc'&lt;/code&gt; A simplified example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; very basic &quot;join&quot; operator&#xA;nnoremap &amp;lt;silent&amp;gt;J :set opfunc=OperJoin&amp;lt;CR&amp;gt;g@&#xA;function! OperJoin(type) abort&#xA;    '[,']join&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;Ja{&lt;/code&gt; will do the job.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-04-27T11:19:33.963" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24914" PostTypeId="2" ParentId="17073" CreationDate="2020-04-27T12:39:32.057" Score="0" Body="&lt;p&gt;In Vim you need to set number highlighting on first:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if !has('nvim')&#xA;    set cursorline&#xA;    set cursorlineopt=number&#xA;endif&#xA;&#xA;highlight LineNR cterm=none ctermfg=Yellow ctermbg=none&#xA;highlight CursorLineNR cterm=bold ctermfg=Black ctermbg=none&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Neovim behaves slightly differently in that &lt;code&gt;cursorlineopt&lt;/code&gt; doesn't exist and &lt;code&gt;set cursorline&lt;/code&gt; will act as &lt;code&gt;set cursorline | set cursorlineopt=both&lt;/code&gt; in Vim.&lt;/p&gt;&#xA;" OwnerUserId="25897" LastActivityDate="2020-04-27T12:39:32.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24915" PostTypeId="1" AcceptedAnswerId="24941" CreationDate="2020-04-27T13:39:59.853" Score="2" ViewCount="227" Body="&lt;p&gt;I inserted the 'datetime' snippet from vim-snippets/all.snippet right at the beginning of my document.&lt;/p&gt;&#xA;&lt;p&gt;The problem is that the time keeps on updating whenever I scroll, as if vim is redrawing the screen and executing the snippet at the same time. What this leads to is, I end up with the time at which the file is closed. Please help me fix the issue.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;snippet datetime &amp;quot;YYYY-MM-DD hh:mm&amp;quot; w&#xA;`!v strftime(&amp;quot;Date: %d %B, %Y | Time: %X&amp;quot;)`&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;UPDATE 1:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/egZ6o.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/egZ6o.gif&quot; alt=&quot;A gif of the same&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;UPDATE 2:&lt;/p&gt;&#xA;&lt;p&gt;base_file&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;snippet base_file &amp;quot;Competitive Programming Template File&amp;quot; b&#xA;/*&#xA;**    Date: `!v strftime(&amp;quot;%A, %d %B, %Y&amp;quot;)`&#xA;**    Time: `!v strftime(&amp;quot;%X&amp;quot;)`&#xA;*/&#xA;&#xA;#include &amp;lt;bits/stdc++.h&amp;gt;&#xA;using namespace std;&#xA;&#xA;typedef long long ll;&#xA;typedef unsigned long long ull;&#xA;typedef long double ld;&#xA;&#xA;#define sz(x) (int)x.size()&#xA;#define rep(a, b, i) for (int i = a; i &amp;lt; b; i++)&#xA;#define repi(a, b, i) for (int i = a; i &amp;gt; b; i--)&#xA;#define F first&#xA;#define S second&#xA;#define pb push_back&#xA;#define all(x) (x).begin(), (x).end()&#xA;#define __                                                                     \&#xA;  ios_base::sync_with_stdio(false);                                            \&#xA;  cin.tie(0);                                                                  \&#xA;  cout.tie(0)&#xA;#define CPU                                                                    \&#xA;  cerr &amp;lt;&amp;lt; &amp;quot;Time elapsed: &amp;quot; &amp;lt;&amp;lt; 1.0 * clock() / CLOCKS_PER_SEC &amp;lt;&amp;lt; &amp;quot; s.&amp;quot; &amp;lt;&amp;lt; endl;&#xA;&#xA;typedef vector&amp;lt;int&amp;gt; vi;&#xA;typedef vector&amp;lt;vi&amp;gt; vvi;&#xA;typedef pair&amp;lt;int, int&amp;gt; pii;&#xA;typedef vector&amp;lt;pii&amp;gt; vpii;&#xA;&#xA;const int MOD = 1e9 + 7;&#xA;const ll inf = 1e18 + 5;&#xA;const ld pi = 3.141592653589793;&#xA;const int maxn = 1e5 + 5;&#xA;&#xA;int32_t main() {&#xA;  __;&#xA;&#xA;  int t;&#xA;  cin &amp;gt;&amp;gt; t;&#xA;  while (t--) {&#xA;    ${1}&#xA;  }&#xA;  return 0;&#xA;}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;outputs:&lt;/p&gt;&#xA;&lt;p&gt;:autocmd CursorHold and :autocmd SafeState are &lt;code&gt;empty&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;:autocmd CursorMoved&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;--- Autocommands ---&#xA;matchparen  CursorMoved&#xA;    *         call s:Highlight_Matching_Pair()&#xA;ycmcompletemecursormove  CursorMoved&#xA;    *         call s:OnCursorMovedNormalMode()&#xA;UltiSnips  CursorMoved&#xA;    *         call UltiSnips#CursorMoved()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I randomly tried entering this command: &lt;code&gt;:call UltiSnips#CursorMoved()&lt;/code&gt;&#xA;The same thing happened, i.e. the time updated. I think there is some problem with this command.&lt;/p&gt;&#xA;" OwnerUserId="25620" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-04-28T14:49:07.647" Title="Vim executing UltiSnips snippet every time I scroll the page" Tags="|vimscript|gvim|plugin-ultisnips|" AnswerCount="1" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24916" PostTypeId="2" ParentId="24912" CreationDate="2020-04-27T13:45:09.803" Score="1" Body="&lt;p&gt;The commandline command you're looking for is 'j':&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1,5j&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29237" LastEditorUserId="29237" LastEditDate="2020-04-27T13:51:32.400" LastActivityDate="2020-04-27T13:51:32.400" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24917" PostTypeId="1" AcceptedAnswerId="24918" CreationDate="2020-04-27T16:56:44.867" Score="2" ViewCount="188" Body="&lt;p&gt;I am using &lt;code&gt;UltiSnips&lt;/code&gt;with &lt;code&gt;vimtex&lt;/code&gt; as explained &lt;a href=&quot;https://castel.dev/post/lecture-notes-1/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and trying to use the snippet for &lt;code&gt;Inline Math&lt;/code&gt; for &lt;code&gt;LaTeX&lt;/code&gt; as shown in the link above. Everytime I try to execute the snippet it executes but immediately an error pops up in my &lt;code&gt;vim&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the snippet definition I am using : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet im &quot;create an inline math environment&quot; wAm&#xA;${$1}$`!p&#xA;if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:&#xA;    snip.rv = ' '&#xA;    else:&#xA;    snip.rv = ''&#xA;    `$2&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is the error I am getting from &lt;code&gt;vim&lt;/code&gt; : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;An error occured. This is either a bug in UltiSnips or a bug in a&#xA;snippet definition. If you think this is a bug, please report it to&#xA;https://github.com/SirVer/ultisnips/issues/new&#xA;Please read and follow:&#xA;https://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs&#xA;&#xA;Following is the full stack trace:&#xA;Traceback (most recent call last):&#xA;  File &quot;/home/nitin/.vim/plugged/ultisnips/pythonx/UltiSnips/err_to_scratch_buffer.py&quot;, line 18, in wrapper&#xA;    return func(self, *args, **kwds)&#xA;  File &quot;/home/nitin/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py&quot;, line 896, in _track_change&#xA;    self._try_expand(autotrigger_only=True)&#xA;  File &quot;/home/nitin/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py&quot;, line 804, in _try_expand&#xA;    self._do_snippet(snippet, before)&#xA;  File &quot;/home/nitin/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py&quot;, line 757, in _do_snippet&#xA;    text_before, self._visual_content, parent, start, end&#xA;  File &quot;/home/nitin/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/definition/base.py&quot;, line 488, in launch&#xA;    snippet_instance.update_textobjects(vim_helper.buf)&#xA;  File &quot;/home/nitin/.vim/plugged/ultisnips/pythonx/UltiSnips/text_objects/snippet_instance.py&quot;, line 93, in update_textobjects&#xA;    if obj._update(done, buf):&#xA;  File &quot;/home/nitin/.vim/plugged/ultisnips/pythonx/UltiSnips/text_objects/python_code.py&quot;, line 268, in _update&#xA;    exec(code, self._locals)  # pylint:disable=exec-used&#xA;  File &quot;&amp;lt;string&amp;gt;&quot;, line 4&#xA;    else:&#xA;       ^&#xA;SyntaxError: invalid syntax&#xA;&#xA;Executed snippet code:&#xA;  1&#xA;  2   if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:&#xA;  3       snip.rv = ' '&#xA;  4       else:&#xA;  5       snip.rv = ''&#xA;  6 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone please help me figure out what is wrong and how to fix it?&lt;/p&gt;&#xA;" OwnerUserId="29070" LastActivityDate="2020-04-27T18:14:02.847" Title="UltiSnips shows error with Python `If-Else`" Tags="|plugin-ultisnips|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24918" PostTypeId="2" ParentId="24917" CreationDate="2020-04-27T17:23:04.597" Score="2" Body="&lt;p&gt;It seems that when you copied the snippet you forgot to add the indentation spaces in the python snippet conditional code as shown in the error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Executed snippet code:&#xA;  1&#xA;  2   if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:&#xA;  3       snip.rv = ' '&#xA;  4       else:&#xA;  5       snip.rv = ''&#xA;  6 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try to change it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;snippet im &quot;create an inline math environment&quot; wAm&#xA;${$1}$`!p&#xA;if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:&#xA;    snip.rv = ' '&#xA;&lt;b&gt;else:&lt;/b&gt;&#xA;    snip.rv = ''&#xA;    `$2&#xA;endsnippet&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="14652" LastEditorUserId="18609" LastEditDate="2020-04-27T18:14:02.847" LastActivityDate="2020-04-27T18:14:02.847" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24919" PostTypeId="1" AcceptedAnswerId="24922" CreationDate="2020-04-27T19:20:54.300" Score="3" ViewCount="29" Body="&lt;p&gt;I've got the following code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 const unrelated = 3;&#xA;2&#xA;3 const XYZ = styled.div`&#xA;4   display: inline-block;&#xA;5   position: absolute;&#xA;6   &#xA;7   margin: auto;&#xA;8 `;&#xA;9&#xA;10 const unrelated2 = 6;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With my cursor in line 6, how can I line-select lines 3 to 8? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vi`V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doesn't seem to work.&lt;/p&gt;&#xA;" OwnerUserId="29245" LastActivityDate="2020-04-28T02:00:14.450" Title="How to line-select a block within a back-ticked string" Tags="|selection|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24920" PostTypeId="2" ParentId="17057" CreationDate="2020-04-27T20:56:20.143" Score="2" Body="&lt;p&gt;To change the divider for the none current window you can do this with (look up &lt;code&gt;:help fillchars&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set fillchars=stlnc:-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To change some content depending on whether it is the current or none current window:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function SomeText(nr)&#xA;    let activebuffer = (a:nr == win_getid()) ? &quot;Active Window&quot; : &quot;None Current Window&quot;&#xA;    let buf_type = &amp;amp;buftype&#xA;    return activebuffer.&quot; &amp;amp; &quot;.buf_type&#xA;endfun&#xA;function MyStatusLineWrapper() abort&#xA;    let startup_win_id = win_getid()&#xA;    let s = &quot;%{SomeText(&quot;.startup_win_id.&quot;)} &quot;.startup_win_id&#xA;    return s&#xA;endfun&#xA;&#xA;set statusline=%!MyStatusLineWrapper()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27110" LastEditorUserId="51" LastEditDate="2020-04-28T04:49:40.023" LastActivityDate="2020-04-28T04:49:40.023" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24921" PostTypeId="1" AcceptedAnswerId="24939" CreationDate="2020-04-28T01:09:01.230" Score="2" ViewCount="2099" Body="&lt;p&gt;I have fuzzy file finder (FZF) set up and working:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YLUvC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YLUvC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And when I do &lt;code&gt;:History&lt;/code&gt; it also shows a preview of the file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rKeJr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rKeJr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been able to do a &lt;code&gt;find&lt;/code&gt; with passing an &quot;empty&quot; preview to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:FZF --preview 'cat'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rXfAP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rXfAP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as soon as I pass any argument (actually anything more than a single argument, regardless of what it is), I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:FZF --preview 'cat {}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error running '/Users/david/.vim/plugged/fzf/bin/fzf'  '--multi' '--prompt' '~/' '-&#xA;-preview' ''\''cat' '{}'\''' --expect=ctrl-v,ctrl-x,ctrl-t --height=16 &amp;gt; /var/folde&#xA;rs/b1/mmc6r_jj00ldzr2prvqzy56m0000gp/T/vsmz6fL/47&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What seems to be the issue here, and how can I fix it? Tried it both on mac and linux and get the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: this exact same command works from the command-line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ /Users/david/.vim/plugged/fzf/bin/fzf --multi --prompt ~/ --preview 'cat {}' --expect=ctrl-v,ctrl-x,ctrl-t --height=16 &amp;gt; /var/folders/b1/mmc6r_jj00ldzr2prvqzy56m0000gp/T/vsmz6fL/47&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="10604" LastEditDate="2020-04-28T12:03:24.527" LastActivityDate="2020-04-28T21:03:27.303" Title="FZF showing error on preview" Tags="|vimrc|command-line|fzf|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24922" PostTypeId="2" ParentId="24919" CreationDate="2020-04-28T02:00:14.450" Score="2" Body="&lt;p&gt;The &lt;code&gt;vi`&lt;/code&gt; motion from stock Vim will not work, since &lt;code&gt;i`&lt;/code&gt; (and &lt;code&gt;a`&lt;/code&gt; or &lt;code&gt;i'&lt;/code&gt; or &lt;code&gt;i&quot;&lt;/code&gt;) only work on a single line of code. See &lt;a href=&quot;https://vimhelp.org/motion.txt.html#v_a%60&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help v_a`&lt;/code&gt;&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it turns out there's a plug-in that helps here, plug-in &lt;a href=&quot;https://github.com/wellle/targets.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;wellle/targets.vim&lt;/a&gt; extends many of the built-in motions and text objects, `i`` included, to make them more powerful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, it supports multi-line contents inside quotes. As stated in &lt;a href=&quot;https://github.com/wellle/targets.vim/blob/master/README.md#pair-text-objects&quot; rel=&quot;nofollow noreferrer&quot;&gt;the README file&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h3&gt;Quote Text Objects&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;These text objects are similar to the built in text objects such as &lt;code&gt;i'&lt;/code&gt;. [...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;These quote text objects try to be smarter than the default ones. They count the quotation marks from the beginning of the line to decide which of these are the beginning of a quote and which ones are the end. [...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Quote text objects work over multiple lines&lt;/strong&gt; and support seeking. [...]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The targets.vim defines many other very useful text objects, such as function arguments and also using &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt; to match the &quot;next&quot; or &quot;last&quot; (previous) text object of that kind (e.g. &lt;code&gt;in'&lt;/code&gt; for the next single quoted string, &lt;code&gt;ip'&lt;/code&gt; for the previous one.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-28T02:00:14.450" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24924" PostTypeId="2" ParentId="12680" CreationDate="2020-04-28T03:56:12.357" Score="20" Body="&lt;h3&gt;This works for me.&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;kbd&gt;esc&lt;/kbd&gt;&#xA;&lt;kbd&gt;:&lt;/kbd&gt; to enter vim command mode&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/^\s*//g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Meaning:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%s/&amp;lt;REGEX TO REPLACE&amp;gt;/&amp;lt;REPLACEMENT TEXT&amp;gt;/&lt;/code&gt; for string substitution&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;g&lt;/code&gt; for global (all lines)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regex matching leading whitespace is &lt;code&gt;^\s*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Voila&lt;/p&gt;&#xA;" OwnerUserId="29251" LastActivityDate="2020-04-28T03:56:12.357" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24925" PostTypeId="1" AcceptedAnswerId="24938" CreationDate="2020-04-28T03:58:28.650" Score="7" ViewCount="8102" Body="&lt;p&gt;I was trying to set a timeout length to apply to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Key combination presses (for example, pressing &lt;code&gt;gh&lt;/code&gt; in netrw); and&lt;/li&gt;&#xA;&lt;li&gt;Exiting modes (for example, zero delay when exiting visual mode).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is a portion of what the docs say in &lt;code&gt;:h timeoutlen&lt;/code&gt; as an example:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;   :set timeout timeoutlen=3000 ttimeoutlen=100&#xA;    (time out on mapping after three seconds, time out on key codes after&#xA;    a tenth of a second).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I still have a hard time understanding what this referring to. What actually would be the difference between the two?  For example if I pressed &lt;code&gt;g&lt;/code&gt; then &lt;code&gt;h&lt;/code&gt; for the &lt;code&gt;gh&lt;/code&gt; combination in &lt;code&gt;netrw&lt;/code&gt; which one(s) would apply to that? What about exiting the visual mode? Which would apply to that?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-29T02:03:58.287" Title="Usage of timeoutlen and ttimeoutlen" Tags="|vimrc|key-bindings|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24926" PostTypeId="2" ParentId="11526" CreationDate="2020-04-28T04:06:45.827" Score="7" Body="&lt;p&gt;In order to support python-mode you need to have +python AND +python3. This should get you there (at least on macOS):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./configure --prefix=/opt/local --with-features=huge --enable-pythoninterp --enable-python3interp&#xA;&#xA;make&#xA;&#xA;sudo make install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29252" LastActivityDate="2020-04-28T04:06:45.827" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24927" PostTypeId="1" AcceptedAnswerId="24931" CreationDate="2020-04-28T04:14:48.913" Score="3" ViewCount="3458" Body="&lt;p&gt;Often I am in some 'general' directory when I open files, such as &lt;code&gt;~&lt;/code&gt; or &lt;code&gt;Desktop&lt;/code&gt;. &lt;code&gt;FZF&lt;/code&gt; by default opens the user's &lt;code&gt;pwd&lt;/code&gt;, for example, if I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Desktop $ vim ~/.vim/vimrc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:FZF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will search in &lt;code&gt;Desktop&lt;/code&gt; by default. How can I pass a parameter equivalent to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:FZF dir(current_file)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:FZF expand('%:p:h')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-11-24T14:38:39.353" Title="Open FZF in current directory of file I am viewing" Tags="|vimrc|plugin-fzf|fzf|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24928" PostTypeId="1" CreationDate="2020-04-28T05:00:25.450" Score="1" ViewCount="181" Body="&lt;p&gt;I am using a mac, and I usually paste things in by doing the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;:set paste!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;cmd&lt;/kbd&gt;&lt;kbd&gt;p&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;:set paste!&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is really the only way I've been able to paste things into vim reliably (with the help of iTerm), whether it's on a local or remote server (i.e., on a remote server having &lt;code&gt;&quot;a&lt;/code&gt; yanked locally means nothing). I was wondering if there was some way to automate this behavior, either in &lt;code&gt;vim&lt;/code&gt; or outside it. I don't think it's possible entirely in vim, as it doesn't recognize mac's &lt;kbd&gt;cmd&lt;/kbd&gt; character. What might be a good way to do this?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="28904" LastEditDate="2020-04-28T05:12:42.593" LastActivityDate="2020-04-28T12:31:03.737" Title="Command-P 'paste script/shortcut'" Tags="|vimrc|vimscript|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24929" PostTypeId="2" ParentId="24928" CreationDate="2020-04-28T05:30:19.673" Score="1" Body="&lt;p&gt;I have been using the paste mappings from &lt;a href=&quot;https://github.com/tpope/vim-unimpaired&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-unimpaired&lt;/a&gt; by Tim Pope, which will drop you on insert mode under &lt;code&gt;set paste&lt;/code&gt; and restore &lt;code&gt;nopaste&lt;/code&gt; as soon as you leave insert mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/tpope/vim-unimpaired/blob/master/doc/unimpaired.txt#L108&quot; rel=&quot;nofollow noreferrer&quot;&gt;mappings&lt;/a&gt; are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;[op&lt;/code&gt;: Paste above the current line (similar to &lt;code&gt;O&lt;/code&gt; but with &lt;code&gt;set paste&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;]op&lt;/code&gt;: Paste below the current line (similar to &lt;code&gt;o&lt;/code&gt; but with &lt;code&gt;set paste&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;yop&lt;/code&gt;: Paste replacing the current line (similar to &lt;code&gt;S&lt;/code&gt; but with &lt;code&gt;set paste&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So one could use the sequence:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;]op&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Cmd&lt;/kbd&gt;+&lt;kbd&gt;P&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since leaving Insert mode with &quot;Esc&quot; is enough to restore &lt;code&gt;nopaste&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I also like to paste from when I'm &lt;em&gt;already&lt;/em&gt; in Insert mode, for example if I want to write something above the text I'm about to paste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that, I use the following mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;C-e&amp;gt; &amp;lt;C-g&amp;gt;u&amp;lt;C-o&amp;gt;:normal &amp;lt;Plug&amp;gt;unimpairedPaste&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will use the Ctrl+E key in Insert mode to switch to &lt;code&gt;set paste&lt;/code&gt; mode, while setting up the restoring of &lt;code&gt;nopaste&lt;/code&gt; after leaving Insert mode. It reuses the internal mapping from vim-unimpaired. Before setting up for pasting, it issues a &lt;a href=&quot;https://vimhelp.org/insert.txt.html#i_CTRL-G_u&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;&amp;lt;C-g&amp;gt;u&lt;/code&gt;&lt;/a&gt; sequence, to break the &quot;undo&quot; tree, meaning you can undo the paste operation on its own, without undoing the additional text you wrote before your paste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So then the sequence is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;i&lt;/code&gt; (or similar), to enter Insert mode&lt;/li&gt;&#xA;&lt;li&gt;enter any text that should precede the paste&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;E&lt;/kbd&gt;, to &lt;code&gt;set paste&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Cmd&lt;/kbd&gt;+&lt;kbd&gt;P&lt;/kbd&gt;, to actually paste the contents of the clipboard&lt;/li&gt;&#xA;&lt;li&gt;&lt;kbd&gt;Esc&lt;/kbd&gt;, to leave Insert mode&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-28T05:30:19.673" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24930" PostTypeId="2" ParentId="24925" CreationDate="2020-04-28T05:54:00.587" Score="2" Body="&lt;p&gt;The timeouts are applicable when you have entered a key and its ambiguous whether a mapping will come next or if there is a choice for the next key due to multiple mappings starting with the same character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I've mapped &lt;code&gt;ab&lt;/code&gt; and &lt;code&gt;ac&lt;/code&gt; to something and I press &lt;code&gt;a&lt;/code&gt; Vim doesn't know whether I want to enter only &lt;code&gt;a&lt;/code&gt; or &lt;code&gt;ab&lt;/code&gt; or &lt;code&gt;ac&lt;/code&gt; so the timeout, if set, will be triggered in this scenario if you wait long enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without timeouts enabled then a scenario like this is handled like so, per the Vim help docs:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If both options are off, Vim will wait until either the complete mapping or key sequence has been received, or it is clear that there is no mapping or key sequence for the received characters. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So specifically to your first question, the timeout will come into play only after the &lt;code&gt;g&lt;/code&gt;. You will, of course, lose the opportunity to execute a mapped sequence if you let the timeout expire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Regarding the second question, about visual mode, I'm not sure what you mean. Exiting visual mode, e.g. with &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt;, happens immediately. If I'm missing a scenario please clarify.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that keycode timeout (enabled unless both &lt;code&gt;'timeout'&lt;/code&gt; and &lt;code&gt;'ttimeout'&lt;/code&gt; are off) is something you are unlikely to encounter very often, if at all. About the only scenario that I've seen come up (rarely) is if you have an Insert mode mapping that includes &lt;code&gt;&amp;lt;esc&amp;gt;&lt;/code&gt; (then you must also have setting &lt;code&gt;'esckeys'&lt;/code&gt; enabled).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on all this, you mostly just need to ask yourself if you want timeouts for mapped keys, ie. those created with the &lt;code&gt;:map&lt;/code&gt; family of commands. If so the easiest thing to do then is probably to turn &lt;code&gt;'timeout'&lt;/code&gt; and &lt;code&gt;'ttimeout'&lt;/code&gt; on, set &lt;code&gt;'ttimeoutlen'&lt;/code&gt; to a negative number and then you'll control both timeout durations with &lt;code&gt;'timeoutlen'&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Matt's answer better addresses the key code issue IF your implementation uses keycodes (admittedly the more common case). But for some gvim versions, like Windows, they aren't used and you'll only deal with associated timeouts with rare scenarios like  the one mentioned above. You can see what you have with  &lt;code&gt;:set termcap&lt;/code&gt;. They'll be under the &lt;code&gt;--- Terminal keys ---&lt;/code&gt; header.&lt;/p&gt;&#xA;" OwnerUserId="11054" LastEditorUserId="11054" LastEditDate="2020-04-29T02:03:58.287" LastActivityDate="2020-04-29T02:03:58.287" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24931" PostTypeId="2" ParentId="24927" CreationDate="2020-04-28T06:56:35.157" Score="6" Body="&lt;p&gt;You can use &lt;code&gt;:Files [PATH]&lt;/code&gt; for this. See the &lt;a href=&quot;https://github.com/junegunn/fzf.vim#commands&quot; rel=&quot;noreferrer&quot;&gt;command reference&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To pass in the directory: &lt;code&gt;:Files %:p:h&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can also use &lt;code&gt;lcd&lt;/code&gt; to change the directory for the current window, then use FZF as normal.&lt;/p&gt;&#xA;" OwnerUserId="29255" LastActivityDate="2020-04-28T06:56:35.157" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24932" PostTypeId="2" ParentId="24928" CreationDate="2020-04-28T09:09:59.020" Score="1" Body="&lt;p&gt;There is something called &quot;bracketed paste mode&quot;, see &lt;code&gt;:h xterm-bracketed-paste&lt;/code&gt;. &#xA;Check if iTerm supports it. If it does, make sure you don't unset &lt;code&gt;t_BE&lt;/code&gt; and &lt;code&gt;t_BD&lt;/code&gt; in your configuration. (I don't have a Mac, so I can't test.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't work: I have configures &lt;kbd&gt;F9&lt;/kbd&gt; to toggle paste mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set pastetoggle=&amp;lt;F9&amp;gt;    &quot; toggle paste option&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19763" LastEditorUserId="19763" LastEditDate="2020-04-28T12:31:03.737" LastActivityDate="2020-04-28T12:31:03.737" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24933" PostTypeId="1" AcceptedAnswerId="24937" CreationDate="2020-04-28T12:07:30.913" Score="0" ViewCount="633" Body="&lt;p&gt;Firstly, Im using NeoVim (as you can tell by the &lt;code&gt;winhighlight&lt;/code&gt; command). When entering the command line by pressing &lt;code&gt;:&lt;/code&gt;, I change the command line window foreground/background. The following very ugly hack works for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup mythemecmdLine&#xA;    autocmd!&#xA;    autocmd CmdlineEnter : set winhighlight=Normal:Normal | redraw | hi! Normal guifg=black guibg=white&#xA;    autocmd CmdlineLeave : hi Normal guifg=white guibg=black&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It relies on the rest of the screen not being redrawn until exiting the command line window. What I dont understand the difference between &lt;code&gt;CmdlineEnter&lt;/code&gt; vs &lt;code&gt;CmdwinEnter&lt;/code&gt;. The above code only works for the former. Reading the &lt;code&gt;:help&lt;/code&gt; on each one leaves me with the impression that &lt;code&gt;CmdwinEnter&lt;/code&gt; is only triggered when one types commands, whereas &lt;code&gt;CmdLineEnter&lt;/code&gt; is triggered by scripts too. However with my code snipped above, even when I type &lt;code&gt;:&lt;/code&gt;  the autocmd &lt;code&gt;CmdwinEnter&lt;/code&gt; is not fired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading the help I can't figure out what the distincition is between the command line and command line window, my impression is they are the same thing, which I assume must be a wrong assumption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't get &lt;code&gt;CmdwinEnter&lt;/code&gt; to fire, so what is it's purpose?&lt;/p&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2021-04-04T13:03:28.490" Title="CmdlineEnter vs CmdwinEnter (In the context of changing Cmdline background color)" Tags="|neovim|autocmd|cmdline|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24934" PostTypeId="1" AcceptedAnswerId="24942" CreationDate="2020-04-28T12:29:05.983" Score="2" ViewCount="213" Body="&lt;p&gt;I want to write a zsh vi-mode helper to wrangle complex commands but ran into a snag using &lt;code&gt;\r&lt;/code&gt; in a &lt;code&gt;substitute()&lt;/code&gt; function invocation. It results in &lt;code&gt;\r&lt;/code&gt; replaced with control characters &lt;code&gt;^M&lt;/code&gt; in output. This works for command mode invocations, both mapping and creating a custom user command.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried using single/double quotes for the {sub} string and surrounding the function declaration with &lt;code&gt;set cpo+=C&lt;/code&gt; and &lt;code&gt;set cpo-=C&lt;/code&gt; and replacing&lt;br&gt;&#xA;&lt;code&gt;\r&lt;/code&gt; with &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;v&lt;/kbd&gt; &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;m&lt;/kbd&gt; (to get &lt;code&gt;^M&lt;/code&gt;) but no joy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The snippet below works for &lt;code&gt;&amp;lt;leader&amp;gt;s&lt;/code&gt;, &lt;code&gt;:Split&lt;/code&gt; but not for &lt;code&gt;:Test&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; .../after/ftplugin/zsh.vim&#xA;&quot;&#xA;setlocal ts=2 sw=2 et sts=2 ai si&#xA;&#xA;&quot; For zsh vi-mode command split&#xA;&quot; splits a single line command on every -- or -,&#xA;&quot; appends \ on every eol&#xA;&quot; mnemonic: cs = command split&#xA;&#xA;&quot; mapping shortcut to command works&#xA;&quot; 1: Create a map, ask for confirmation&#xA;nmap &amp;lt;leader&amp;gt;s  :s:\(\s\{1,}\)\(-\+\): \\\r  \2:g&amp;lt;CR&amp;gt;  | noh | retab&#xA;nmap &amp;lt;leader&amp;gt;sq :s:\(\s\{1,}\)\(-\+\): \\\r  \2:cg&amp;lt;CR&amp;gt; | noh | retab&#xA;&#xA;&quot; user command works &#xA;&quot; 2: Create a User Command&#xA;command! -nargs=0 Split  s:\(\s\{1,}\)\(-\+\): \\\r\t\t\2:g  | noh | retab&#xA;command! -nargs=0 Splitq s:\(\s\{1,}\)\(-\+\): \\\r\t\t\2:cg | noh | retab&#xA;&#xA;&quot; 3: VimScript function doesn't work&#xA;&quot; Fails with: ls -l -a&#xA;&quot; EXPECT:&#xA;&quot; ls\&#xA;&quot;   -l\&#xA;&quot;   -a&#xA;&quot;&#xA;&quot; GOT    : ls\^M -l\^M -a&#xA;&#xA;command! -nargs=0 Test call SplitCommandLine()&#xA;&#xA;func! SplitCommandLine()&#xA;  let pat    = '\(\s\{1,}\)\(-\+\)'&#xA;  let sub    = '\\\r \2'&#xA;  let flags  = 'g'&#xA;  let line   = getline('.')&#xA;  call setline('.', substitute(line, pat, sub, flags))&#xA;endf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29240" LastEditorUserId="1238" LastEditDate="2020-04-28T19:57:30.777" LastActivityDate="2020-04-28T19:57:30.777" Title="using \r in {sub} of substitute() function call" Tags="|vimscript|substitute|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24935" PostTypeId="2" ParentId="24921" CreationDate="2020-04-28T12:32:16.600" Score="5" Body="&lt;p&gt;I'm not sure why this error occurs (I have exactly the same here), however there's a workaround. So this is not a direct answer, but I hope it helps nonetheless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can set defaults options for FZF in your shell config file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case, my &lt;code&gt;.bashrc&lt;/code&gt; holds those lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export FZF_DEFAULT_OPTS=&quot;-m&quot;&#xA;FZF_DEFAULT_OPTS+=&quot; --color='light'&quot;&#xA;FZF_DEFAULT_OPTS+=&quot; --height 40%&quot;&#xA;FZF_DEFAULT_OPTS+=&quot; --bind 'ctrl-u:preview-up,ctrl-d:preview-down,ctrl-o:toggle+up,ctrl-i:toggle+down,ctrl-space:toggle-preview'&quot;&#xA;FZF_DEFAULT_OPTS+=&quot; --preview 'head -500 {}'&quot;&#xA;FZF_DEFAULT_OPTS+=&quot; --preview-window=:hidden&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the relevant one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FZF_DEFAULT_OPTS+=&quot; --preview 'head -500 {}'&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These settings will be used in vim.&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2020-04-28T16:04:51.503" LastActivityDate="2020-04-28T16:04:51.503" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24936" PostTypeId="1" CreationDate="2020-04-28T12:39:08.080" Score="0" ViewCount="410" Body="&lt;p&gt;I installed YouCompleteMe and UltiSnips together in order to use snippets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my &lt;code&gt;.vimrc&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;call plug#begin() &#xA;Plug 'preservim/NERDTree'&#xA;Plug 'ycm-core/YouCompleteMe'&#xA;Plug 'SirVer/ultisnips'&#xA;call plug#end()&#xA;&#xA;let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py'&#xA;&#xA;&quot; Trigger configuration. Do not use &amp;lt;tab&amp;gt; if you use https://github.com/Valloric/YouCompleteMe.&#xA;let g:UltiSnipsExpandTrigger=&quot;&amp;lt;s-tab&amp;gt;&quot;&#xA;let g:UltiSnipsJumpForwardTrigger=&quot;&amp;lt;c-b&amp;gt;&quot;&#xA;let g:UltiSnipsJumpBackwardTrigger=&quot;&amp;lt;c-z&amp;gt;&quot;&#xA;&#xA;&quot; If you want :UltiSnipsEdit to split your window.&#xA;let g:UltiSnipsEditSplit=&quot;vertical&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to expand snippets by pressing &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;Tab&lt;/kbd&gt;, but instead of expanding it is reverse scrolling through suggestions. This happens even though I've updated in my &lt;code&gt;.vimrc&lt;/code&gt; for &lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;Tab&lt;/kbd&gt;. What should I do now?&lt;/p&gt;&#xA;" OwnerUserId="29263" LastEditorUserId="18609" LastEditDate="2020-04-28T20:10:07.473" LastActivityDate="2020-04-28T20:10:07.473" Title="UltiSnips snippets not expanding in vim" Tags="|vimrc|key-bindings|plugin-you-complete-me|plugin-ultisnips|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24937" PostTypeId="2" ParentId="24933" CreationDate="2020-04-28T13:31:03.397" Score="3" Body="&lt;p&gt;The event    &lt;code&gt;CmdLineEnter&lt;/code&gt; refers to entering the command line via &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, or &lt;code&gt;?&lt;/code&gt;, including non-interactively.&lt;/p&gt;&#xA;&lt;p&gt;There is also &lt;code&gt;CmdWinEnter&lt;/code&gt;, referring to entering the command window. There are 2 ways for each type of command like above to enter the command window:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;q&lt;/code&gt; followed by the command (e.g., &lt;code&gt;q:&lt;/code&gt;), or&lt;/li&gt;&#xA;&lt;li&gt;From any of the command lines, press &lt;kbd&gt;Ctrl&lt;/kbd&gt;-&lt;kbd&gt;f&lt;/kbd&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2021-04-04T13:03:28.490" LastActivityDate="2021-04-04T13:03:28.490" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24938" PostTypeId="2" ParentId="24925" CreationDate="2020-04-28T14:11:38.930" Score="12" Body="&lt;p&gt;&lt;code&gt;timeout&lt;/code&gt; and &lt;code&gt;timeoutlen&lt;/code&gt; apply to &lt;strong&gt;mappings&lt;/strong&gt;, such as netrw's &lt;code&gt;gh&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are pretty straightforward: if you increase the length of &lt;code&gt;timeoutlen&lt;/code&gt;, then Vim will wait for longer after each keystroke of the mapping before aborting it and carrying out the behaviour of the keys typed so far. If you instead unset &lt;code&gt;timeout&lt;/code&gt;, then Vim will wait &lt;em&gt;forever&lt;/em&gt; for you to either type the complete mapping or type something which doesn't match any of your mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ttimeout&lt;/code&gt; and &lt;code&gt;ttimeoutlen&lt;/code&gt; apply to &lt;strong&gt;key codes&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A common example of something sends key codes is the arrow keys. In the terminal presses of the arrow keys are generally represented by &lt;em&gt;sequences&lt;/em&gt; of characters. You can see what (Vim thinks) your terminal is sending when you press e.g. the left arrow key by executing the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set &amp;lt;left&amp;gt;?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my terminal, when I run the above, Vim outputs the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t_kl &amp;lt;Left&amp;gt;     ^[O*D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means that what my terminal sends to Vim when I press the arrow key is the sequences of characters: &lt;kbd&gt;Escape&lt;/kbd&gt;&lt;kbd&gt;O&lt;/kbd&gt;&lt;kbd&gt;*&lt;/kbd&gt;&lt;kbd&gt;D&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;(&lt;code&gt;^[&lt;/code&gt; is a plain-text representation of the &lt;strong&gt;ESC&lt;/strong&gt; character)&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way that Vim can distinguish these sequences from actual keypresses is the speed with which it receives them, and you configure this with the &lt;code&gt;ttimeout&lt;/code&gt; and &lt;code&gt;ttimeoutlen&lt;/code&gt; settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, if you set &lt;code&gt;ttimeoutlen&lt;/code&gt; to a sufficiently large value (try &lt;code&gt;5000&lt;/code&gt;: five seconds) then you can move your cursor to the left by literally typing &lt;kbd&gt;Escape&lt;/kbd&gt;&lt;kbd&gt;O&lt;/kbd&gt;&lt;kbd&gt;*&lt;/kbd&gt;&lt;kbd&gt;D&lt;/kbd&gt; on your keyboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this &lt;em&gt;also&lt;/em&gt; means that if you press &lt;kbd&gt;Escape&lt;/kbd&gt; in visual mode, then Vim will wait 5 seconds to whether you actually pressed &lt;kbd&gt;Escape&lt;/kbd&gt; (to exit visual mode) or in fact just pressed &lt;kbd&gt;Left&lt;/kbd&gt; in an extremely slow terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally, you want to set &lt;code&gt;timeout&lt;/code&gt; and &lt;code&gt;timeoutlen&lt;/code&gt; according to how quickly you generally type mappings, and you should set &lt;code&gt;ttimeoutlen&lt;/code&gt; to a pretty small value: &lt;code&gt;defaults.vim&lt;/code&gt; sets this to 100 milliseconds, but you can probably go a fair bit shorter than this without unwanted consequences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Longer values of &lt;code&gt;ttimeoutlen&lt;/code&gt; are only required for &quot;slow terminals or very busy systems&quot; when key codes are timing out, but as processor and network speeds increase this is less and less of an issue in practice.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-04-28T15:19:46.727" LastActivityDate="2020-04-28T15:19:46.727" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24939" PostTypeId="2" ParentId="24921" CreationDate="2020-04-28T14:19:58.853" Score="4" Body="&lt;p&gt;The arguments you pass to &lt;code&gt;:FZF&lt;/code&gt; are split at spaces and tabs, because &lt;a href=&quot;https://github.com/junegunn/fzf/blob/e6d33f77da8cc36786c814f499f6cb3405e8c4c1/plugin/fzf.vim#L937&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:FZF&lt;/code&gt; uses the escape sequence &lt;code&gt;&amp;lt;f-args&amp;gt;&lt;/code&gt;&lt;/a&gt;.  This means that Vim splits the arguments on these 2 spaces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:FZF --preview 'cat {}'&#xA;              ^    ^&#xA;              ✔    ✘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You don't want Vim to split the arguments at the second space.  Instead you want the space to be embedded into the arguments.  To do so, you need to escape it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:FZF --preview 'cat\ {}'&#xA;                   ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But there is still one issue. &lt;code&gt;&amp;lt;f-args&amp;gt;&lt;/code&gt; quotes each argument individually.  So, &lt;code&gt;s:cmd()&lt;/code&gt; receives these 2 arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'--preview'&#xA;'''cat\ {}'''&#xA; ^^       ^^&#xA; embedded single quotes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the command-line, you provided &lt;code&gt;cat\ {}&lt;/code&gt; as a string, which Vim has embedded inside another string.  This will prevent the shell from splitting the command name (here &lt;code&gt;cat(1)&lt;/code&gt;) from its file argument.  To avoid this, remove the quotes around &lt;code&gt;cat\ {}&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:FZF --preview cat\ {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-04-28T21:03:27.303" LastActivityDate="2020-04-28T21:03:27.303" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24940" PostTypeId="1" AcceptedAnswerId="24944" CreationDate="2020-04-28T14:26:16.843" Score="4" ViewCount="530" Body="&lt;p&gt;I can't understand the vim help for &lt;code&gt;:command-range&lt;/code&gt;, it states&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    -range=N    A count (default N) which is specified in the line&#xA;            number position (like :split); allows for zero line&#xA;            number.&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The documentation for &lt;code&gt;:split&lt;/code&gt; is not helpful either. I'd also like to know the meaning of &lt;code&gt;-range=0&lt;/code&gt; if not obvious from the description of &lt;code&gt;-range=N&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="18405" LastActivityDate="2020-04-28T15:55:59.090" Title="What does the command option '-range=N' do?" Tags="|range|command|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24941" PostTypeId="2" ParentId="24915" CreationDate="2020-04-28T14:49:07.647" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;https://www.youtube.com/watch?v=JJQYwt6Diro&amp;amp;t=184&quot; rel=&quot;nofollow noreferrer&quot;&gt;this video&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;UltiSnips evaluates each text object that might have a dependency on some types of text multiple times, to make sure that all dependencies are properly updated.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To prevent the date from being updated several times, you could switch to a python interpolation, and use the guard &lt;code&gt;if not snip.c&lt;/code&gt;.  For example, you could replace this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;**    Time: `!v strftime(&quot;%X&quot;)`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;**    Time: `!p&#xA;if not snip.c:&#xA;    from datetime import datetime&#xA;    snip.rv = datetime.now().strftime('%X')`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, try to move your cursor outside the snippet to end its expansion; if you can't, run this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sil! py3 UltiSnips_Manager._current_snippet_is_done()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more info about &lt;code&gt;snip.c&lt;/code&gt;, read &lt;code&gt;:h UltiSnips-python&lt;/code&gt;.&#xA;See &lt;a href=&quot;https://github.com/SirVer/ultisnips/issues/1021#issuecomment-451630866&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for a similar issue.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2020-04-28T14:49:07.647" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24942" PostTypeId="2" ParentId="24934" CreationDate="2020-04-28T15:20:12.760" Score="1" Body="&lt;p&gt;The problem is not really with &lt;code&gt;substitute()&lt;/code&gt;, but with &lt;a href=&quot;https://vimhelp.org/eval.txt.html#setline%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;setline()&lt;/code&gt;&lt;/a&gt;, which will not break lines on &lt;code&gt;^M&lt;/code&gt; and won't really offer a direct way to insert new lines at the place where the current line is being replaced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can pass &lt;code&gt;setline()&lt;/code&gt; a list (which you can easily get by &lt;code&gt;split()&lt;/code&gt;ing on &lt;code&gt;&quot;\r&quot;&lt;/code&gt;), but that will actually &lt;em&gt;replace&lt;/em&gt; the following lines, rather than inserting new lines for the continuation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in order to make this work, you need to use &lt;code&gt;setline()&lt;/code&gt; for the current line, followed by &lt;a href=&quot;https://vimhelp.org/eval.txt.html#append%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;append()&lt;/code&gt;&lt;/a&gt; for the following lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code below will do so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;func! SplitCommandLine()&#xA;  let pat    = '\(\s\{1,}\)\(-\+\)'&#xA;  let sub    = '\\\r \2'&#xA;  let flags  = 'g'&#xA;  let line   = getline('.')&#xA;  &lt;b&gt;let repl   = split(substitute(line, pat, sub, flags), &quot;\r&quot;)&#xA;  call setline('.', repl[0])&#xA;  call append('.', repl[1:])&lt;/b&gt;&#xA;endfunction&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But arguably the best solution here is to stick to the &lt;code&gt;:s&lt;/code&gt; Ex command (which you can easily call from a function), which already does what you need, without you having to jump through hoops to make it do it...&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-28T15:20:12.760" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24943" PostTypeId="2" ParentId="24645" CreationDate="2020-04-28T15:41:55.360" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;is there another way to run an external command on the alternate screen, that doesn't involve passing it lines from the current buffer as standard input?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Try to remove &lt;code&gt;^[[?1049h&lt;/code&gt; from &lt;code&gt;'t_ti'&lt;/code&gt; and &lt;code&gt;^[[?1049l&lt;/code&gt; from &lt;code&gt;'t_te'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup NoAltScreen&#xA;    au!&#xA;    au VimEnter * call s:altscreen(v:true)&#xA;    au VimLeave * call s:altscreen(v:false)&#xA;augroup END&#xA;&#xA;fu s:altscreen(disable) abort&#xA;    if a:disable&#xA;        let [s:t_ti_save, s:t_te_save] = [&amp;amp;t_ti, &amp;amp;t_te]&#xA;        let &amp;amp;t_ti = substitute(&amp;amp;t_ti, '\e\[?1049h', '', '')&#xA;        let &amp;amp;t_te = substitute(&amp;amp;t_te, '\e\[?1049l', '', '')&#xA;    else&#xA;        if exists('s:t_te_save')&#xA;            let &amp;amp;t_te = s:t_te_save&#xA;            let &amp;amp;t_ti = s:t_ti_save&#xA;        endif&#xA;    endif&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Look at &lt;a href=&quot;https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Functions-using-CSI-_-ordered-by-the-final-character_s_&quot; rel=&quot;nofollow noreferrer&quot;&gt;xterm's documentation&lt;/a&gt;, in particular the sequence &lt;code&gt;CSI ? Pm h&lt;/code&gt;, and the line starting with &lt;code&gt;Ps = 1 0 4 9&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;CSI ? Pm h&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Ps = 1 0 4 9  ⇒  Save cursor as in DECSC, xterm.  After sav-&#xA;  ing the cursor, switch to the Alternate Screen Buffer, clear-&#xA;  ing it first.  This may be disabled by the titeInhibit&#xA;  resource.  This control combines the effects of the 1 0 4 7&#xA;  and 1 0 4 8  modes.  Use this with terminfo-based applications&#xA;  rather than the 4 7  mode.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is what the plugin &lt;a href=&quot;https://github.com/fcpg/vim-altscreen&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;vim-altscreen&lt;/code&gt;&lt;/a&gt; does to prevent the output of a shell command from being displayed in the original screen buffer from which you started Vim.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Don't make the value empty, it may contain some sequences which you might want to keep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, I use &lt;code&gt;'t_ti'&lt;/code&gt; and &lt;code&gt;'t_te'&lt;/code&gt; to &lt;a href=&quot;https://github.com/lacygoill/vim-xterm/blob/dc6f82e33bbe466484f4f537330db8592a48aef3/plugin/xterm.vim#L189&quot; rel=&quot;nofollow noreferrer&quot;&gt;set the cursor shape&lt;/a&gt;, and in the past to &lt;a href=&quot;https://github.com/lacygoill/vim-xterm/blob/dc6f82e33bbe466484f4f537330db8592a48aef3/plugin/xterm.vim#L347&quot; rel=&quot;nofollow noreferrer&quot;&gt;restore the focus events&lt;/a&gt; in the terminal.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-04-28T15:45:18.720" LastActivityDate="2020-04-28T15:45:18.720" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24944" PostTypeId="2" ParentId="24940" CreationDate="2020-04-28T15:43:46.117" Score="5" Body="&lt;p&gt;Using the &lt;code&gt;-range&lt;/code&gt; flag when defining a user-command usually allows the user to provide a range to the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command -range Mine echo &amp;lt;range&amp;gt; &amp;lt;line1&amp;gt; ',' &amp;lt;line2&amp;gt;&#xA;%Mine&#xA;1,/bar/Mine&#xA;&quot; the next one is equivalent to .Mine by default&#xA;Mine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, sometimes you want to be able to do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0Mine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or else use the number provided as a &lt;code&gt;&amp;lt;count&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -range=1 Mine echo &amp;lt;count&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use the &lt;code&gt;-count&lt;/code&gt; attribute for this, though then the count is allowed to come as the first argument or in the range position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this paragraph:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Range handling ~&#xA;                *E177* *E178* *:command-range* *:command-count*&#xA;By default, user-defined commands do not accept a line number range.  However,&#xA;it is possible to specify that the command does take a range (the -range&#xA;attribute), or that it takes an arbitrary count value, either in the line&#xA;number position (-range=N, like the |:split| command) or as a &quot;count&quot;&#xA;argument (-count=N, like the |:Next| command).  The count will then be&#xA;available in the argument with |&amp;lt;count&amp;gt;|.&#xA;&#xA;Possible attributes are:&#xA;&#xA;    -range      Range allowed, default is current line&#xA;    -range=%    Range allowed, default is whole file (1,$)&#xA;    -range=N    A count (default N) which is specified in the line&#xA;            number position (like |:split|); allows for zero line&#xA;            number.&#xA;    -count=N    A count (default N) which is specified either in the line&#xA;            number position, or as an initial argument (like |:Next|).&#xA;    -count      acts like -count=0&#xA;&#xA;Note that -range=N and -count=N are mutually exclusive - only one should be&#xA;specified.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Re: &lt;code&gt;:split&lt;/code&gt;, there's something easy to miss in this line from the docs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;:&lt;b&gt;[N]&lt;/b&gt;sp[lit] [++opt] [+cmd] [file]            *:sp* *:split*&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That sneaky little &lt;code&gt;[N]&lt;/code&gt; is what indicates a count can be given as a range (usually, &lt;code&gt;N&lt;/code&gt; is used for counts and &lt;code&gt;[range]&lt;/code&gt; for ranges). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then later, we read&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        Make the new window N high (default is to use half the height&#xA;        of the current window).  Reduces the current window height to&#xA;        create room (and others, if the 'equalalways' option is set,&#xA;        'eadirection' isn't &quot;hor&quot;, and one of them is higher than the&#xA;        current or the new window).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the count in this case is used to set the window-height, à la &lt;code&gt;:10split&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="10604" LastEditDate="2020-04-28T15:55:59.090" LastActivityDate="2020-04-28T15:55:59.090" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24945" PostTypeId="2" ParentId="24422" CreationDate="2020-04-28T17:04:42.900" Score="1" Body="&lt;p&gt;I somehow figured out what was going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem was due to a trailing whitespace at the very end of the keybinding. That was acting as extra key to escape back from the terminal. Removing it resolved the issue.&lt;/p&gt;&#xA;" OwnerUserId="25620" LastActivityDate="2020-04-28T17:04:42.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24946" PostTypeId="1" AcceptedAnswerId="24953" CreationDate="2020-04-28T17:30:16.147" Score="2" ViewCount="76" Body="&lt;p&gt;When I'm in the GUI, I like to have a large-ish vim window: 161 columns, so I can &lt;code&gt;:vsplit&lt;/code&gt; it into two 80 column windows (with 1 extra column for the gutter.) This works perfectly fine if I do it by hand, but if I try to &lt;code&gt;:vsplit&lt;/code&gt; in my &lt;code&gt;.vimrc&lt;/code&gt;, I get a 40 column window and a 120 column window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The appropriate part of my &lt;code&gt;.vimrc&lt;/code&gt; is here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has(&quot;gui_running&quot;)&#xA;    &quot; GUI is running or is about to start.&#xA;    set lines=51 columns=161&#xA;    set guioptions -=T&#xA;    set guifont=InputMono:h10&#xA;    &quot; Split the window&#xA;    set equalalways&#xA;    vsplit&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone say what's going on here?&lt;/p&gt;&#xA;" OwnerUserId="29272" LastEditorUserId="1238" LastEditDate="2020-04-28T20:10:30.553" LastActivityDate="2020-04-29T00:07:25.997" Title="Vsplit in resized GUI Window in .vimrc" Tags="|gvim|split|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24947" PostTypeId="1" CreationDate="2020-04-28T17:32:39.433" Score="1" ViewCount="239" Body="&lt;p&gt;I wonder if it is possible to use fzf inside vim the same way it can be used on the command line. So, on the command line I can do &lt;code&gt;vim file**&lt;/code&gt; and it will use fzf to search 'file'. I wonder if this is possible inside vim with &lt;code&gt;:e&lt;/code&gt;/&lt;code&gt;:sp&lt;/code&gt;/&lt;code&gt;:vsp&lt;/code&gt;, so using it as &lt;code&gt;:e file**&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;vim by itself does support the option to search for a file with &lt;code&gt;:e **/file&lt;/code&gt;, but it does not search the file &quot;fuzzily&quot; and cannot ignore &lt;code&gt;.gitignore&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware of fzf.vim &lt;code&gt;:Files&lt;/code&gt; command, but you need &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;X&lt;/kbd&gt; / &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;V&lt;/kbd&gt; to open in a split and it isn't just a one-to-one replacing of the preferred command line functionality. &lt;/p&gt;&#xA;" OwnerUserId="18386" LastEditorUserId="1238" LastEditDate="2020-04-28T19:23:43.413" LastActivityDate="2020-04-28T19:23:43.413" Title="Using fzf inside vim with double star completion" Tags="|buffers|split|plugin-fzf|fzf|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24948" PostTypeId="1" AcceptedAnswerId="24951" CreationDate="2020-04-28T18:41:40.510" Score="1" ViewCount="875" Body="&lt;p&gt;If I am editing a command, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set paste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And my cursor is between the &lt;code&gt;p&lt;/code&gt; and &lt;code&gt;a&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set pa|ste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can go to the end of the command text by doing &lt;code&gt;ctrl-e&lt;/code&gt;. However it doesn't seem like &lt;code&gt;ctrl-a&lt;/code&gt; works to go to the start of the text. Is there a shortcut that I can use to go to the start of a command I'm typing? For example, I'd like to be able to enter a key(s) to be able to get to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:|set paste&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can that be done?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-05-01T04:57:45.143" Title="How to go to the beginning of a command" Tags="|command-line|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24949" PostTypeId="1" CreationDate="2020-04-28T19:19:57.610" Score="1" ViewCount="84" Body="&lt;p&gt;Is it possible to use &lt;code&gt;Vim's power&lt;/code&gt; (Vim buffers...) while doing 3 way merge in &lt;code&gt;Meld&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can see in Meld you can change the default editor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;edit -&amp;gt; Preferences -&amp;gt; Editor -&amp;gt; default editor&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to change that to vim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I can not use Vim's power in the meld. Is there a way to do that ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="22212" LastEditorUserId="18609" LastEditDate="2020-04-28T20:25:40.130" LastActivityDate="2020-04-28T20:25:40.130" Title="Is it possible to use Vim's power (Vim buffers...) while doing 3 way merge in Meld?" Tags="|vimdiff|merge|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24950" PostTypeId="2" ParentId="24948" CreationDate="2020-04-28T20:15:52.057" Score="4" Body="&lt;p&gt;By default, Vim command line uses &lt;code&gt;Ctrl-B&lt;/code&gt; to go to the beginning of the line. Execute &lt;code&gt;:h cmdline-editing&lt;/code&gt; to see more key bindings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most command line tools follow the Emacs key bindings, and you can write your own mappings if you want. See &lt;code&gt;:help cnoremap&lt;/code&gt; for details. There are also plugins, like &lt;a href=&quot;https://github.com/tpope/vim-rsi&quot; rel=&quot;nofollow noreferrer&quot;&gt;rsi&lt;/a&gt; that do it for you&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-04-28T20:15:52.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24951" PostTypeId="2" ParentId="24948" CreationDate="2020-04-28T20:15:53.113" Score="2" Body="&lt;p&gt;You can set command line mappings with &lt;code&gt;cmap&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cnoremap &amp;lt;c-a&amp;gt; &amp;lt;Home&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22375" LastActivityDate="2020-04-28T20:15:53.113" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24952" PostTypeId="2" ParentId="24946" CreationDate="2020-04-28T20:51:27.227" Score="1" Body="&lt;p&gt;I don't know exactly what causes this, but I would try the following workarounds if it's important to you to setup the splits on startup (it usually isn't for me—I either have a session with saved layouts, or I don't):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Try &lt;code&gt;wincmd =&lt;/code&gt; to equalize the windows after &lt;code&gt;vsplit&lt;/code&gt;ting them; or,&lt;/li&gt;&#xA;&lt;li&gt;Try &lt;code&gt;execute (&amp;amp;columns / 2) &quot;vsplit&quot;&lt;/code&gt; to split in half&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;P.S. Usually, it's best to keep gui-related configuration in &lt;code&gt;~/.gvimrc&lt;/code&gt; or &lt;code&gt;~/.vim/gvimrc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-04-28T20:51:27.227" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24953" PostTypeId="2" ParentId="24946" CreationDate="2020-04-28T21:06:26.273" Score="3" Body="&lt;p&gt;I guess that &lt;code&gt;set columns=161&lt;/code&gt; does not take effect immediately.  Maybe not until Vim displays a window, which according to &lt;code&gt;:h startup&lt;/code&gt; happens after the vimrc is read.  The latter is processed in the third step of the documentation, while the windows are still not displayed in the 11th step:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;11&quot;&gt;&#xA;  &lt;li&gt;Open all windows&#xA;      When the |-o| flag was given, windows will be opened (&lt;strong&gt;but not displayed yet&lt;/strong&gt;).&#xA;      When the |-p| flag was given, tab pages will be created (&lt;strong&gt;but not displayed yet&lt;/strong&gt;).&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In any case, try to delay &lt;code&gt;:vsplit&lt;/code&gt; until &lt;code&gt;VimEnter&lt;/code&gt; (12th and last step in the initialization process), so that you're sure that all the initializations have been performed, and a Vim window with the correct geometry is currently displayed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au VimEnter * vsplit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if has('gui_running') &amp;amp;&amp;amp; has('vim_starting')&#xA;    &quot; GUI is running or is about to start.&#xA;    set lines=51 columns=161&#xA;    set guioptions -=T&#xA;    set guifont=InputMono:h10&#xA;    &quot; Split the window&#xA;    set equalalways&#xA;    au VimEnter * vsplit&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-04-29T00:07:25.997" LastActivityDate="2020-04-29T00:07:25.997" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24955" PostTypeId="1" CreationDate="2020-04-28T22:13:37.080" Score="0" ViewCount="114" Body="&lt;p&gt;I'm running Vim 8 on Linux and I would like to use packages, but I have a few questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Between the following directories, where do I create the &lt;code&gt;~/.vim/pack&lt;/code&gt; directory?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;system vimrc&lt;/li&gt;&#xA;&lt;li&gt;user vimrc&lt;/li&gt;&#xA;&lt;li&gt;2nd user vimrc&lt;/li&gt;&#xA;&lt;li&gt;user exrc file&lt;/li&gt;&#xA;&lt;li&gt;defaults file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: I am totally confused. I am wanting to do two things. I want to be able to edit my vimrc so that I can do things like set options. When I run &lt;code&gt;vim --version&lt;/code&gt; I get.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;system vimrc: &lt;code&gt;$VIM/vimrc&lt;/code&gt;  ---? what does &lt;code&gt;$VIM&lt;/code&gt; mean?&lt;/li&gt;&#xA;&lt;li&gt;user vimrc: &lt;code&gt;$HOME/.vimrc&lt;/code&gt;  ---? what does &lt;code&gt;$HOME&lt;/code&gt; mean?&lt;/li&gt;&#xA;&lt;li&gt;do I create these? I assume this is home directory for vim not my linux system.&lt;/li&gt;&#xA;&lt;li&gt;what do I need to do or understand in order to work with the vimrc file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The second thing that I want to do is be able to use plug ins or packages in vim 8&#xA;what do I do to have this working?&lt;/p&gt;&#xA;" OwnerUserId="29278" LastEditorUserId="18609" LastEditDate="2020-05-03T03:58:49.877" LastActivityDate="2020-05-03T03:58:49.877" Title="vim 8 packages on linux" Tags="|vimrc|packages|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24956" PostTypeId="1" AcceptedAnswerId="24959" CreationDate="2020-04-29T00:09:37.270" Score="1" ViewCount="953" Body="&lt;p&gt;In Textmate I can do something like when I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;    &amp;lt;p&amp;gt;new&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I press &lt;kbd&gt;opt&lt;/kbd&gt;&lt;kbd&gt;shift&lt;/kbd&gt;&lt;kbd&gt;.&lt;/kbd&gt; it will add in the matching tag. So when I press it once, it will look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;    &amp;lt;p&amp;gt;new&amp;lt;/p&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I press it a second time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;    &amp;lt;p&amp;gt;new&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if I press it a third time, nothing will happen as there are no open tags. What is the best way to do this in vim?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="10604" LastEditDate="2020-06-18T11:12:03.473" LastActivityDate="2020-06-18T11:12:03.473" Title="Add matching html tag" Tags="|vimrc|filetype-html|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24957" PostTypeId="2" ParentId="24956" CreationDate="2020-04-29T00:35:54.347" Score="4" Body="&lt;p&gt;You could use the plugin called &lt;a href=&quot;https://github.com/alvan/vim-closetag&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-closetag&lt;/a&gt; which does exactly this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The big advantage over the default omni-completion is you don't need to type as much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The matching closing tag will be automatically inserted after your cursor. Just type &lt;code&gt;&amp;gt;&lt;/code&gt; by default to insert a new line between those new tags, pretty convenient.&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2020-04-29T00:54:35.450" LastActivityDate="2020-04-29T00:54:35.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24959" PostTypeId="2" ParentId="24956" CreationDate="2020-04-29T00:43:28.197" Score="4" Body="&lt;p&gt;In vim, you can complete open html tags and close tags using &lt;em&gt;omni-completion&lt;/em&gt;, invoked via &lt;kbd&gt;ctrl-x&lt;/kbd&gt;&lt;kbd&gt;ctrl-o&lt;/kbd&gt;. To do this though, you must first type &lt;code&gt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;lt;/&lt;/code&gt; depending on which tag you want.  For close, the tag corresponding to the nearest unclosed open tag will be chosen, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;&#xA;  &amp;lt;p&amp;gt;asdf&amp;lt;/p&amp;gt;&#xA;&amp;lt;/[]    &amp;lt;-- PRESS ctrl-x ctrl-o HERE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a little bit inconvenient, so we can make a mapping for close tag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-b&amp;gt; &amp;lt;/&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pressing &lt;kbd&gt;ctrl-b&lt;/kbd&gt; in insert mode will enter the desired close tag.&#xA;This map works, but isn't ideal because it will enter &lt;code&gt;&amp;lt;/&amp;gt;&lt;/code&gt; when no close tab is appropriate.  We can modify the map to help&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inoremap &amp;lt;c-b&amp;gt; &amp;lt;c-\&amp;gt;&amp;lt;c-o&amp;gt;a&amp;lt;/&amp;lt;c-x&amp;gt;&amp;lt;c-o&amp;gt;&amp;lt;c-r&amp;gt;=get(v:completed_item, 'word', '&amp;gt;') ==# '&amp;gt;' ? &quot;\&amp;lt;lt&amp;gt;c-u&amp;gt;&quot; : ''&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea behind this map is if only &lt;code&gt;&amp;gt;&lt;/code&gt; was inserted, backspace the inserted text.  The point of &lt;code&gt;&amp;lt;c-\&amp;gt;&amp;lt;c-o&amp;gt;a&lt;/code&gt; is to limit the amount backspaced over with &lt;code&gt;&amp;lt;c-u&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2020-04-29T01:04:51.757" LastActivityDate="2020-04-29T01:04:51.757" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24960" PostTypeId="1" AcceptedAnswerId="25004" CreationDate="2020-04-29T01:04:52.263" Score="1" ViewCount="108" Body="&lt;p&gt;I am writing code in R, specifically using the Tidyverse packages. There is extensive use of the pipe &lt;code&gt;%&amp;gt;%&lt;/code&gt; to chain functions together. The lines become long, so it is &lt;a href=&quot;https://style.tidyverse.org/pipes.html#long-lines-2&quot; rel=&quot;nofollow noreferrer&quot;&gt;recommended&lt;/a&gt; to break them up on this character. I do it manually right now, but I'm sure there's a smarter way of doing it. Here's an example.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iris %&amp;gt;% group_by(Species) %&amp;gt;% summarise(Sepal.Length = mean(Sepal.Length))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to select this line in visual mode and hit a simple keystroke to convert it to the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iris %&amp;gt;%&#xA;  group_by(Species) %&amp;gt;%&#xA;  summarise(Sepal.Length = mean(Sepal.Length))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Perhaps it's asking too much, but it would be really nice if the function arguments could be formatted, as follows. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iris %&amp;gt;% group_by(Species) %&amp;gt;% summarise(Sepal.Length = mean(Sepal.Length),Sepal.Width = mean(Sepal.Width),Species = n_distinct(Species) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iris %&amp;gt;%&#xA;  group_by(Species) %&amp;gt;%&#xA;  summarise(&#xA;    Sepal.Length = mean(Sepal.Length),&#xA;    Sepal.Width = mean(Sepal.Width),&#xA;    Species = n_distinct(Species)&#xA;  )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18196" LastEditorUserId="18196" LastEditDate="2020-04-30T11:23:59.033" LastActivityDate="2020-04-30T15:07:06.700" Title="Reformat code: breaking lines and aligning on a character" Tags="|indentation|formatting|alignment|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24961" PostTypeId="1" AcceptedAnswerId="24965" CreationDate="2020-04-29T01:34:24.193" Score="2" ViewCount="212" Body="&lt;p&gt;If I have a &lt;code&gt;&amp;lt;table&amp;gt;&lt;/code&gt; element it indents &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/j38aW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/j38aW.png&quot; alt=&quot;table&amp;gt;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I do the same thing with a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag, it does not indent:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tZ4zh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tZ4zh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why the difference here? Is there a way I can get it to indent equally after every html/xml tag? (for example, like it does for the &lt;code&gt;table&lt;/code&gt; item)?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-29T04:29:36.190" Title="Why do only some tags indent in html?" Tags="|vimrc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24962" PostTypeId="1" AcceptedAnswerId="24967" CreationDate="2020-04-29T02:34:19.047" Score="4" ViewCount="355" Body="&lt;p&gt;I seem to be using a hack approach to getting to the start of an html tag. For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rhglC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rhglC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get to my cursor to be on the &lt;code&gt;t&lt;/code&gt; after the tag, I end up doing &lt;code&gt;yit&lt;/code&gt; -- this yanks the component (which I don't care about). Is there a way to just do something like &quot;it&quot; to get to that &lt;code&gt;t&lt;/code&gt; without doing anything (also doing &lt;code&gt;ft&lt;/code&gt; gets me stuck at the &lt;code&gt;t&lt;/code&gt; before so that becomes a hassle). And then, what about going to the end of the text, that is the 't' right before the &lt;code&gt;&amp;lt;/td&amp;gt;&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-04-29T03:39:49.577" Title="Easiest way to go to start/end of html element" Tags="|vimrc|filetype-html|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24963" PostTypeId="1" AcceptedAnswerId="24968" CreationDate="2020-04-29T02:34:43.910" Score="2" ViewCount="641" Body="&lt;p&gt;I have a big source code base on both Mac and Windows on which I work on this with MacVim/NeoVim.&#xA;When using &lt;code&gt;CTRL-]&lt;/code&gt; to search tag through a 1.6G tags file, &#xA;I got immediate result with MacVim while surfering about 5s to get search result from NeoVim.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to profile this action &lt;code&gt;CTRL-]&lt;/code&gt;? &#xA;Vim profile seems need to call a function like &lt;code&gt;profile func *&lt;/code&gt;, however I don't know the underneath callee functionname.&lt;/li&gt;&#xA;&lt;li&gt;Is there like a &lt;code&gt;exe&lt;/code&gt; application called by action &lt;code&gt;CTRL-]&lt;/code&gt;, which causing such bad performance.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any ideas to this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NeoVim version is v0.4.3&#xA;MacVim version is 8.2&#xA;MacVim and NeoVim share the same vimrc.&#xA;Source code base on both windows and mac are placed on SSD.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Finally I solved my problem by reducing (1.6GB-&gt;0.6GM) the size of the tags file which is thought to be the main cause. If your encountered similar problems as mine. You may fellow steps as below.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;make sure virus scanner is innocent&lt;/li&gt;&#xA;&lt;li&gt;check your vimrc, make sure &lt;code&gt;tagbsearch&lt;/code&gt; and &lt;code&gt;tagcase&lt;/code&gt; config are correct for binary tag searching.&lt;/li&gt;&#xA;&lt;li&gt;make sure only the information that you concerned remain in your tags file. try to use &lt;code&gt;ctags.exe&lt;/code&gt; with &lt;code&gt;--exclude={regex you want to ignore}&lt;/code&gt; or &lt;code&gt;--languages={languages you want to ignore}&lt;/code&gt; to reduce the size of tags on windows. (wildcard &lt;code&gt;*&lt;/code&gt; is only available when you see &lt;code&gt;+wildcards&lt;/code&gt; in &lt;code&gt;ctags.exe --version&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;After all, NeoVim or gVim on windows seem have a lower threshold for the size of tags file than MacVim. When the threshold is bypassed, &lt;code&gt;CTRL-]&lt;/code&gt; will become slow apparently.&lt;/p&gt;&#xA;" OwnerUserId="16803" LastEditorUserId="16803" LastEditDate="2020-04-29T14:10:36.000" LastActivityDate="2020-04-29T14:10:36.000" Title="Jump to definition (CTRL-]) slow on windows" Tags="|ctags|tags|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24964" PostTypeId="1" AcceptedAnswerId="24969" CreationDate="2020-04-29T02:54:43.157" Score="0" ViewCount="281" Body="&lt;p&gt;I would like to have the &lt;code&gt;delete&lt;/code&gt; key work similarly in &lt;code&gt;normal&lt;/code&gt; mode as it does in &lt;code&gt;insert&lt;/code&gt; mode, and it's been a bit tricky to map this. Here is what I have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;Backspace&amp;gt; i&amp;lt;BS&amp;gt;&amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this doesn't work too well and letters accumulate to the right of the cursor. What would be a better mapping for this? I think the main issue is in pressing the &lt;code&gt;esc&lt;/code&gt; in that the cursor floats to the right a bit.&lt;/p&gt;&#xA;" OwnerUserId="28904" LastEditorUserId="28904" LastEditDate="2020-04-29T03:09:15.247" LastActivityDate="2020-04-29T05:38:27.550" Title="Simulate backspace in normal mode" Tags="|vimrc|key-bindings|autocmd|insert-mode|normal-mode|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24965" PostTypeId="2" ParentId="24961" CreationDate="2020-04-29T02:59:47.343" Score="2" Body="&lt;p&gt;The authors of the HTML indentation script shipped by Vim seem to have decided not to indent inside tags such as &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; because they are &quot;self-closing&quot; tags, meaning that the closing &lt;code&gt;&amp;lt;/p&amp;gt;&lt;/code&gt; is optional. I imagine the rationale for that is that, if a &lt;code&gt;&amp;lt;/p&amp;gt;&lt;/code&gt; was omitted by the user, the indentation wouldn't have been retracted, so each new paragraph would get indented further and further.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/vim/vim/blob/v8.2.0/runtime/indent/html.vim#L217-L220&quot; rel=&quot;nofollow noreferrer&quot;&gt;this comment&lt;/a&gt; in &lt;code&gt;$VIMRUNTIMES/indent/html.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Self-closing tags and tags that are sometimes self-closing (e.g., &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;) are not here (when encountering &lt;code&gt;&amp;lt;/p&amp;gt;&lt;/code&gt; we can find the matching &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;, but not the other way around).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Known self-closing tags: &lt;code&gt;p&lt;/code&gt;, &lt;code&gt;img&lt;/code&gt;, &lt;code&gt;source&lt;/code&gt;, &lt;code&gt;area&lt;/code&gt;, &lt;code&gt;keygen&lt;/code&gt;, &lt;code&gt;track&lt;/code&gt;, &lt;code&gt;wbr&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can override this behavior and extend the list of tags that increment indentation by setting the &lt;code&gt;g:html_indent_inctags&lt;/code&gt; to a comma-separated list of additional tags that should require indentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:html_indent_inctags = 'p'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="19763" LastEditDate="2020-04-29T04:29:36.190" LastActivityDate="2020-04-29T04:29:36.190" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24966" PostTypeId="2" ParentId="24962" CreationDate="2020-04-29T03:10:06.423" Score="2" Body="&lt;p&gt;You can use the optional plugin &lt;code&gt;:h matchit&lt;/code&gt; , it's an extension for the built in &lt;code&gt;:h %&lt;/code&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add this to your vimrc and restart vim.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;packadd! matchit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can jump between &lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;\td&amp;gt;&lt;/code&gt; by &lt;code&gt;%&lt;/code&gt;, note you must not place your cursor at &lt;code&gt;&amp;lt;&lt;/code&gt; or &lt;code&gt;&amp;gt;&lt;/code&gt; for this to work, otherwise it jump between &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are in the body and you want to jump to the open or close tag, use &lt;code&gt;[%&lt;/code&gt; or &lt;code&gt;]%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If you want to go to start of the inner body&lt;/strong&gt;, use &lt;code&gt;[%%l&lt;/code&gt;, &lt;code&gt;[%&lt;/code&gt; jump to &lt;code&gt;&amp;lt;&lt;/code&gt; of &lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt; jump to &lt;code&gt;&amp;gt;&lt;/code&gt;. use &lt;code&gt;]%%h&lt;/code&gt; for the other direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also Mass's &lt;a href=&quot;https://github.com/andymass/vim-matchup&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim-matchup&lt;/a&gt; , it provides highlight, more motions, and textobjects.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-04-29T03:39:49.577" LastActivityDate="2020-04-29T03:39:49.577" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24967" PostTypeId="2" ParentId="24962" CreationDate="2020-04-29T03:39:10.643" Score="3" Body="&lt;p&gt;Although vim provides text objects for tags, it doesn't have motions for tags.&#xA;One options is to reuse &lt;code&gt;it&lt;/code&gt; to create a pair of maps &lt;code&gt;[t&lt;/code&gt; and &lt;code&gt;]t&lt;/code&gt; somewhat analogous to &lt;code&gt;[b&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap [t vit&amp;lt;esc&amp;gt;`&amp;lt;&#xA;nnoremap ]t vit&amp;lt;esc&amp;gt;`&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These both work by temporarily visually selecting the inner tag and then moving to the start and end of the visual selection.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2020-04-29T03:39:10.643" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24968" PostTypeId="2" ParentId="24963" CreationDate="2020-04-29T05:21:34.983" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;search tag through a 1.6G tags file, I got immediate result with MacVim while surfering about 5s to get search result from NeoVim.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From the symptoms you describe, it seems to me that you're getting &lt;strong&gt;binary search&lt;/strong&gt; from MacVim while you're not getting it from NeoVim on Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Binary search in the tags file is controlled by the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27tagbsearch%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'tagbsearch'&lt;/code&gt;&lt;/a&gt; option, but I'd expect that to be enabled on both systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for binary search to work, the tags file needs to be properly sorted, so there are other factors that can cause Vim to execute a linear search even when &lt;code&gt;'tagbsearch'&lt;/code&gt; is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the most frequent reasons why Vim would degrade to a linear search is if it's doing case-insensitive search on a tags file that wasn't generated with case folding (which would allow for a case-insensitive binary search.) If you're looking for a case-insensitive match, but the file has been sorted case-sensitively, you need to degrade back to linear search to find the matches with different case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tag case sensitive search is primarily controlled by the &lt;a href=&quot;https://vimhelp.org/options.txt.html#%27tagcase%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;'tagcase'&lt;/code&gt;&lt;/a&gt; option, but depending on the value of that option, it might also depend on whether &lt;code&gt;'ignorecase'&lt;/code&gt; or &lt;code&gt;'smartcase'&lt;/code&gt; are set. (By default, it depends on &lt;code&gt;'ignorecase'&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try to &lt;code&gt;:set tagcase=match&lt;/code&gt; to force case-sensitive search and see if that solves the problem right away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your tags file needs to be properly sorted for the binary search to succeed. If Vim is trying to perform binary search and, while doing so, encounters entries that are out of order, it might fallback to linear search. But in that case, Vim would issue an &lt;code&gt;E432: Tags file not sorted&lt;/code&gt; warning. Since you didn't report seeing this warning, it seems this is not what's happening with you... (I'm betting on the tag case search, I once actually &lt;em&gt;enabled&lt;/em&gt; that to fix an instance of this particular warning.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, make sure you're running the latest version of Vim/NeoVim on your machines. There was recently a bug that would break tag binary search on Vim/NeoVim. It got fixed on &lt;a href=&quot;https://github.com/vim/vim/commit/27fc8cab227e30f649f52e74efd58ad56d21e9bb&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vim 8.1.2152&lt;/a&gt; and I believe &lt;a href=&quot;https://github.com/neovim/neovim/commit/319c69a4a5e2b2daa392f24d34e27febc9692123&quot; rel=&quot;nofollow noreferrer&quot;&gt;NeoVim 0.4.3&lt;/a&gt;. The particular issue actually happened on Mac OS and it would trigger the &lt;code&gt;E432&lt;/code&gt; warning, so I don't think that explains what you're saying, but just in case it's related, you might want to make sure you're using a newer version of Vim/NeoVim where this bug has already been fixed.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-04-29T05:21:34.983" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24969" PostTypeId="2" ParentId="24964" CreationDate="2020-04-29T05:32:39.480" Score="2" Body="&lt;p&gt;I'll post this as an answer since it seems to have worked for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:nnoremap &amp;lt;expr&amp;gt; &amp;lt;Backspace&amp;gt; col('.') == 1 ? 'kgJ' : 'X'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usually this does the same as the &lt;a href=&quot;https://vimhelp.org/change.txt.html#X&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;X&lt;/code&gt;&lt;/a&gt; Normal-mode command, that deletes one character to the left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then it uses an &lt;code&gt;&amp;lt;expr&amp;gt;&lt;/code&gt; mapping to check whether we're executing it on the first column of the line, in which case it uses &lt;code&gt;k&lt;/code&gt; to move up one line followed by &lt;a href=&quot;https://vimhelp.org/change.txt.html#gJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;gJ&lt;/code&gt;&lt;/a&gt; to join lines without adding any spaces between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This mapping has shortcomings, for instance, it won't work with a count.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My personal recommendation is that you're better off without such a mapping. I find that this kind of mapping will encourage you to use inefficient movements (such as hitting backspace repeatedly) rather than more efficient movements and text objects comprised of words, sentences, paragraphs, blocks, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of a backspace mapping (or even abuse of the &lt;code&gt;X&lt;/code&gt; command), try to use more powerful and efficient motions to select and move around your text in Vim.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-29T05:38:27.550" LastActivityDate="2020-04-29T05:38:27.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24971" PostTypeId="1" CreationDate="2020-04-29T08:35:44.170" Score="2" ViewCount="389" Body="&lt;p&gt;I am using &lt;code&gt;vimtex&lt;/code&gt; with &lt;code&gt;latexmk&lt;/code&gt; and using &lt;code&gt;conceal&lt;/code&gt; setting provided by &lt;code&gt;vim&lt;/code&gt; and extending it with an additional plug-in : &lt;a href=&quot;https://github.com/KeitaNakamura/tex-conceal.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;KeitaNakamura/tex-conceal.vim&lt;/code&gt;&lt;/a&gt;. Additionally, I use a package &lt;code&gt;braket&lt;/code&gt; to encode &lt;code&gt;\langle&lt;/code&gt;, &lt;code&gt;\rangle&lt;/code&gt; and &lt;code&gt;|&lt;/code&gt; nicely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;braket&lt;/code&gt; package comes with commands which are used like : &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;\bra{A}&lt;/code&gt; ( it will print into pdf as &lt;code&gt;&amp;lt;A|&lt;/code&gt; and I want to conceal in my tex file so that it appears like : &lt;code&gt;&amp;lt;A|&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;\ket{A}&lt;/code&gt; ( it will print into pdf as &lt;code&gt;|A&amp;gt;&lt;/code&gt; and I want to conceal in my tex file so that it appears like : &lt;code&gt;|A&amp;gt;&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;\bracket{A|B}&lt;/code&gt; ( it will print into pdf as &lt;code&gt;&amp;lt;A|B&amp;gt;&lt;/code&gt; and I want to conceal in my tex file so that it appears like : &lt;code&gt;&amp;lt;A|B&amp;gt;&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My aim is to use conceal feature of &lt;code&gt;vim&lt;/code&gt; on the commands that come with the &lt;code&gt;braket&lt;/code&gt; package which is not available by default or by the plug-in I am using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Short of asking the developer of the plug-in to include support for &lt;code&gt;braket&lt;/code&gt; package is there any other method by which I can achieve this? Writing some custom code or using some other plugin?&lt;/p&gt;&#xA;" OwnerUserId="29070" LastEditorUserId="10604" LastEditDate="2020-05-01T14:50:37.820" LastActivityDate="2021-12-09T14:16:40.240" Title="Concealing the code for `braket` package for LaTeX with vimtex + `tex-conceal`" Tags="|syntax-highlighting|conceal|plugin-vimtex|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24972" PostTypeId="1" CreationDate="2020-04-29T10:47:14.400" Score="2" ViewCount="224" Body="&lt;p&gt;How do I run an external filtering program on a part of a line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;!myfilter&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it always filters the whole line regardless of whether the whole line is selected or just a part of it.&lt;/p&gt;&#xA;" OwnerUserId="29291" LastActivityDate="2020-04-29T13:41:32.853" Title="How to run an external filter on a part of a line?" Tags="|filter|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24973" PostTypeId="2" ParentId="24971" CreationDate="2020-04-29T12:59:52.933" Score="1" Body="&lt;p&gt;You can do something like the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; ~/.vim/after/syntax/tex.vim&#xA;syntax match texMathSymbol /\\bra{\%([^}]*}\)\@=/ conceal cchar=&amp;lt;&#xA;syntax match texMathSymbol /\%(\\bra{[^}]*\)\@&amp;lt;=}/ conceal cchar=|&#xA;syntax match texMathSymbol /\\ket{\%([^}]*}\)\@=/ conceal cchar=|&#xA;syntax match texMathSymbol /\%(\\ket{[^}]*\)\@&amp;lt;=}/ conceal cchar=&amp;gt;&#xA;syntax match texMathSymbol /\\braket{\%([^}]*}\)\@=/ conceal cchar=&amp;lt;&#xA;syntax match texMathSymbol /\%(\\braket{[^}]*\)\@&amp;lt;=}/ conceal cchar=&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you want to keep the highlight group when not concealing, you’ll need to get the highlight group for commands like &lt;code&gt;\langle&lt;/code&gt; (&lt;code&gt;texStatement&lt;/code&gt;, I believe) and replace &lt;code&gt;bra&lt;/code&gt;, &lt;code&gt;ket&lt;/code&gt;, and &lt;code&gt;braket&lt;/code&gt; with it.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;For the curious, the weapons of choice here are&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;\%(\)&lt;/code&gt; non-capturing groups (they're slightly more performant)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\@=&lt;/code&gt; matches the preceding atom with zero-width &lt;em&gt;and doesn't consume the match&lt;/em&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;\@&amp;lt;=&lt;/code&gt; matches the preceding atom with zero-width only if what follows also matches &lt;em&gt;and doesn't consume the match&lt;/em&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We need this &amp;quot;non-consuming&amp;quot; behavior—&lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; could be used to build the right patterns, but because we are creating overlaps we need to not consume anything. &lt;code&gt;\zs&lt;/code&gt; and &lt;code&gt;\ze&lt;/code&gt; will consume the matches they make which prevents vim's syntax engine from examining that text again.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;We can't use &lt;code&gt;region&lt;/code&gt; because we need two different conceal characters (one on each end of the region). This is not supported natively, so workarounds like double-matches are required.&lt;/p&gt;&#xA;" OwnerUserId="10604" LastEditorUserId="39041" LastEditDate="2021-12-09T14:16:40.240" LastActivityDate="2021-12-09T14:16:40.240" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24974" PostTypeId="2" ParentId="457" CreationDate="2020-04-29T13:14:12.023" Score="3" Body="&lt;p&gt;As a vim user, I appreciate the speed of using normal mode keys to move around the text. I prefer using &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt; to &lt;code&gt;left arrow&lt;/code&gt; and &lt;code&gt;right arrow&lt;/code&gt; so my hands do not need to move to reach those keys. When I use other computer keyboards, arrow keys move, but normal mode keys still at their expected place.&lt;/p&gt;&#xA;&lt;p&gt;When I type &lt;code&gt;:%s/oldtext/newtext/gc&lt;/code&gt; to make a search and replace operation,&#xA;I no longer can use normal mode keys to move around this line.&lt;/p&gt;&#xA;&lt;p&gt;I prefer typing &lt;code&gt;q:&lt;/code&gt; and going to a command editor in normal mode to edit my command the way I edit the rest of the file.&lt;/p&gt;&#xA;&lt;p&gt;By the way, typing &lt;code&gt;q:&lt;/code&gt; lets me view the history of commands.&lt;/p&gt;&#xA;&lt;p&gt;I have &lt;code&gt;inoremap q; q:i&lt;/code&gt; in my  &lt;code&gt;.vimrc&lt;/code&gt; to use &lt;code&gt;q;&lt;/code&gt; instead of &lt;code&gt;q:&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="29294" LastEditorUserId="21495" LastEditDate="2022-03-29T07:41:19.590" LastActivityDate="2022-03-29T07:41:19.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24975" PostTypeId="1" AcceptedAnswerId="24983" CreationDate="2020-04-29T13:40:53.117" Score="4" ViewCount="168" Body="&lt;p&gt;I'm using &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;space&amp;gt;&lt;/code&gt; to open current terminal buffer in a new tab:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tnoremap &amp;lt;c-w&amp;gt;&amp;lt;space&amp;gt; &amp;lt;c-w&amp;gt;:tab split&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This map cause &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; trigger mapping delay in terminal mode, why would that happen? Are there any relation between &lt;code&gt;&amp;lt;space&amp;gt;&lt;/code&gt; (0x20) and &lt;code&gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; (0x17) ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;space&amp;gt;&lt;/code&gt; works fine, it doesn't trigger mapping delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have created an rc file with this single command and tested it with &lt;code&gt;vim -Nu rc&lt;/code&gt;, the result didn't change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FWIW, I also use this map in normal mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;c-w&amp;gt;&amp;lt;space&amp;gt; :tab split&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works fine, it doesn't affect &lt;code&gt;&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;&lt;/code&gt;  int normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using vim8.1-2300, ubuntu 18.04.4, zsh 5.4.2&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="5017" LastEditDate="2020-04-29T13:48:22.870" LastActivityDate="2020-04-29T20:36:18.757" Title="Why does custom map of &lt;c-w&gt;&lt;space&gt; cause mapping delay in terminal mode?" Tags="|key-bindings|terminal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24976" PostTypeId="2" ParentId="24972" CreationDate="2020-04-29T13:41:32.853" Score="1" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :s/\%V.*\%V./\=system('myfilter', submatch(0))[:-2]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As an example, consider this text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;one  zwei three&#xA;four fünf six&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Visually select the block containing the german numbers &lt;code&gt;zwei&lt;/code&gt; and &lt;code&gt;fünf&lt;/code&gt;, and run this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V.*\%V./\=system('trans -brief', submatch(0))[:-2]/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should translate the numbers into english:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;one  two three&#xA;four five six&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FSQWm.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FSQWm.gif&quot; alt=&quot;filter visual block to translate german numbers into english&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Requires the shell utility &lt;a href=&quot;https://github.com/soimort/translate-shell&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;translate-shell&lt;/code&gt;&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To make the process a little easier, you could install this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xno &amp;lt;c-g&amp;gt;s :s/\%V.*\%V./\=system('', submatch(0))[:-2]/&amp;lt;c-r&amp;gt;=setcmdpos(28)[-1]&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Press &lt;code&gt;C-g s&lt;/code&gt; while selecting your text. It should populate the command-line with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:'&amp;lt;,'&amp;gt;s/\%V.*\%V./\=system('', submatch(0))[:-2]/&#xA;                            ^&#xA;                            cursor right before&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the cursor should be correctly positioned to let you immediately type the name of the filter you want to use.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more info, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h /\%V&#xA;:h system()&#xA;:h submatch()&#xA;:h setcmdpos()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2020-04-29T13:41:32.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24977" PostTypeId="1" CreationDate="2020-04-29T14:03:33.270" Score="12" ViewCount="1441" Body="&lt;p&gt;Is there a way to perform a simultaneous find and replace?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.: I want to replace all &lt;code&gt;1&lt;/code&gt; for &lt;code&gt;0&lt;/code&gt; and simultaneously all &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&#xA;    [1, 1, 1, 1, 1, 0],&#xA;    [1, 1, 1, 1, 0, 1],&#xA;    [1, 1, 1, 0, 1, 1],&#xA;    [1, 1, 0, 1, 1, 1],&#xA;    [1, 0, 1, 1, 1, 1],&#xA;    [0, 1, 1, 1, 1, 1],&#xA;    [1, 1, 1, 1, 1, 0],&#xA;]&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27582" LastEditorUserId="1238" LastEditDate="2020-04-29T17:40:01.010" LastActivityDate="2020-05-25T03:18:17.993" Title="Simultaneous find and replace" Tags="|replace|find|" AnswerCount="10" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24978" PostTypeId="2" ParentId="24977" CreationDate="2020-04-29T14:11:30.740" Score="8" Body="&lt;p&gt;In your specific use case, i think what you can do is this handy oneline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/0\|1/\=!submatch(0)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That basically inverts the match.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2020-04-29T14:11:30.740" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24979" PostTypeId="2" ParentId="24977" CreationDate="2020-04-29T14:12:25.660" Score="7" Body="&lt;p&gt;Sure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/[01]/\=&quot;10&quot;[submatch(0)]/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Matches either a &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt; and replaces it with either&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;10&quot;[0]&lt;/code&gt; = &lt;code&gt;1&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;10&quot;[1]&lt;/code&gt; = &lt;code&gt;0&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2020-04-29T14:12:25.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24980" PostTypeId="2" ParentId="24977" CreationDate="2020-04-29T14:13:08.893" Score="18" Body="&lt;p&gt;Yes, you can do that by using an expression. For this particular case, you can use Vim arithmetic and calculate &lt;code&gt;1-x&lt;/code&gt;, which will turn 0 into 1 and 1 into 0.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/\d/\=1-submatch(0)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For a more general replacement case, you can use a Dict to store the mapping of match to replacement string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to turn the digits into written numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:let repl = {&quot;0&quot;: &quot;zero&quot;, &quot;1&quot;: &quot;one&quot;}&#xA;:s/\d/\=repl[submatch(0)]/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/change.txt.html#sub-replace-expression&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help sub-replace-expression&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/pattern.txt.html#%2F%5Cd&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help /\d&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/eval.txt.html#submatch%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help submatch()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://vimhelp.org/eval.txt.html#Dict&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;:help Dict&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-04-29T14:39:42.937" LastActivityDate="2020-04-29T14:39:42.937" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24981" PostTypeId="2" ParentId="24977" CreationDate="2020-04-29T14:30:47.357" Score="7" Body="&lt;p&gt;This answer is longer than others, it didn't take the specific data value advantage, it's a general solution to replace n different values with n different replacements:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let d={0:1,1:0} | %s/\v(0|1)/\=d[submatch(0)]/g | unlet d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if you want to change &lt;code&gt;Hello vim 8&lt;/code&gt; to &lt;code&gt;Oh god 9&lt;/code&gt; in a single replacement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let d={'Hello':'Oh','vim':'god',8:9} | %s/\v(Hello|vim|8)/\=d[submatch(0)]/g | unlet d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5017" LastActivityDate="2020-04-29T14:30:47.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24982" PostTypeId="1" CreationDate="2020-04-29T14:49:40.683" Score="3" ViewCount="559" Body="&lt;p&gt;Back from emacs recently, in emacs I can list all the existing buffers in a emacs buffer, where I can do search, delete or jumping etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Vim, if I type &lt;code&gt;:browse oldfiles&lt;/code&gt;, a long list may be returned below the command line buffer and I can only move the buffer up&amp;amp;down or just a number to jump to corresponding file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will be convenient, if I can search the long list given by &lt;code&gt;:browse oldfiles&lt;/code&gt;, &lt;code&gt;:ls&lt;/code&gt; or &lt;code&gt;:tselect&lt;/code&gt; etc.&#xA;I know that &lt;code&gt;redir&lt;/code&gt; can be used in my case, but it's a bit annoying when you have to do it every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if there's a more vim-way to handle this scenario such as &lt;code&gt;quickfix windows&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16803" LastEditorUserId="16803" LastEditDate="2020-04-29T16:38:23.017" LastActivityDate="2020-04-29T16:38:23.017" Title="How to search the output of vim command line commands like `:ls`, `:browse oldfiles`" Tags="|vimrc|search|quickfix|" AnswerCount="0" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24983" PostTypeId="2" ParentId="24975" CreationDate="2020-04-29T15:00:37.047" Score="4" Body="&lt;p&gt;For some reason, &lt;code&gt;C-w&lt;/code&gt; is not written in the typeahead immediately (not printed in the &lt;code&gt;'showcmd'&lt;/code&gt; area).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that Vim waits for &lt;code&gt;&amp;amp;timeoutlen&lt;/code&gt; ms to determine whether the key must be remapped or executed with its default meaning (start a C-W command).  I guess that the key assigned to &lt;code&gt;'termwinkey'&lt;/code&gt; is handled differently in Terminal-Job mode compared to &lt;code&gt;C-w&lt;/code&gt; in normal mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could somewhat get around the timeout by installing this mapping:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tno &amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt; &amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works under the assumption that you didn't reset &lt;code&gt;'termwinkey'&lt;/code&gt;, and as a result Vim uses &lt;code&gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; to start a C-W command.  This wouldn't work if you've reset the option to, let's say, &lt;code&gt;&amp;lt;C-s&amp;gt;&lt;/code&gt;, and you press &lt;code&gt;&amp;lt;C-s&amp;gt;&amp;lt;C-w&amp;gt;&lt;/code&gt; to focus another window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For something more reliable, you could try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;augroup termwinkey_no_timeout&#xA;    au!&#xA;    au TerminalWinOpen * let b:_twk = &amp;amp;l:twk == '' ? '&amp;lt;c-w&amp;gt;' : &amp;amp;l:twk&#xA;      \ | exe printf('tno &amp;lt;buffer&amp;gt;&amp;lt;nowait&amp;gt; %s&amp;lt;c-w&amp;gt; %s&amp;lt;c-w&amp;gt;', b:_twk , b:_twk)&#xA;      \ | unlet! b:_twk&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-04-29T20:36:18.757" LastActivityDate="2020-04-29T20:36:18.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24984" PostTypeId="2" ParentId="5441" CreationDate="2020-04-29T15:36:03.597" Score="7" Body="&lt;h1&gt;Ftplugin&lt;/h1&gt;&#xA;&lt;p&gt;As mentioned do put settings pertaining to a certain file type in ftplugin.&lt;/p&gt;&#xA;&lt;h1&gt;Separate into Files&lt;/h1&gt;&#xA;&lt;p&gt;Break up code into different files. For example where my vimrc file is, there is a sub &lt;code&gt;init/&lt;/code&gt; dir which contains other files I wish to load at startup. To load them I use the below code. &lt;code&gt;&amp;lt;sfile&amp;gt;&lt;/code&gt; evaulates to the current file (&lt;code&gt;init.vim&lt;/code&gt; or &lt;code&gt;.vimrc&lt;/code&gt; in this case), and &lt;code&gt;:h&lt;/code&gt; means the head of it (the dir it is within). Here I am loading the files &lt;code&gt;env.vim&lt;/code&gt;, then &lt;code&gt;git.vim&lt;/code&gt;, etc..&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;source &amp;lt;sfile&amp;gt;:h/init/env.vim&#xA;source &amp;lt;sfile&amp;gt;:h/init/git.vim&#xA;source &amp;lt;sfile&amp;gt;:h/init/myplugins.vim&#xA;source &amp;lt;sfile&amp;gt;:h/init/visual.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Folds&lt;/h1&gt;&#xA;&lt;p&gt;I used to separate my init.vim into many other files, but it makes startup a little bit (insignificantly?) slower, but the main thing is ones setup becomes very fragmented, and constantly have to switch buffers when working on config. I moved to using folds. Refer to &lt;code&gt;:help usr_28&lt;/code&gt; for help on folds. Search down in particular for the section &lt;code&gt;*28.6* Folding with markers&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;I break apart my init file as shown below. It shows a level1 &lt;code&gt;KEYMAPPINGS&lt;/code&gt; fold expanded. There are many level2 subsections (folds) such as &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;map!&lt;/code&gt;, &lt;code&gt;function keys&lt;/code&gt;, &lt;code&gt;visual mode&lt;/code&gt; within the main level1 section. In the image a level2 fold is expanded (&lt;code&gt;Popup Menu&lt;/code&gt; keymappings`).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/P46tB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/P46tB.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Firstly to enable &lt;code&gt;{{{&lt;/code&gt; and style folds set these options:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set foldmethod=marker&#xA;set foldcolumn=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I use the following code to highlight the Level1 and Level2 section headings of the folds. &lt;code&gt;_FoldLevel1&lt;/code&gt; and &lt;code&gt;_FoldLevel2&lt;/code&gt; are highlight groups defined next.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;augroup match_folds&#xA;    autocmd!&#xA;    &amp;quot; VimEnter handles at start up, WinNew for each window created AFTER startup.&#xA;    &amp;quot; Regex matches { { { with an empty group in the middle so that vim does&#xA;    &amp;quot; not create a fold in this code, then either a 1 or 2 then a space. Then&#xA;    &amp;quot; zs is the start of the match which is the rest of the line then ze is&#xA;    &amp;quot; the end of the match. Refer to :help pattern-overview&#xA;    autocmd VimEnter,WinNew * let w:_foldlevel1_id = matchadd('_FoldLevel1', '{{\(\){1\ \zs.\+\ze', -1)&#xA;    autocmd VimEnter,WinNew * let w:_foldlevel2_id = matchadd('_FoldLevel2', '{{\(\){2\ \zs.\+\ze', -1)&#xA;augroup END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I style my folds with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; {{{ Folds&#xA;hi Folded               guifg=#FF9999 guibg=#005050 gui=bold,italic&#xA;hi FoldColumn           guifg=#FF9999 guibg=#005050 gui=bold&#xA;hi _FoldLevel1          guifg=#005050 guibg=#FF9999 gui=bold,italic&#xA;hi _FoldLevel2          guifg=#003030 guibg=#CC8080 gui=bold,italic&#xA;&amp;quot; }}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now place &lt;code&gt;{{{1&lt;/code&gt; to Create a level 1 esction, &lt;code&gt;{{{2&lt;/code&gt; to create a level 2 section: (I trimmed the file down, to a skeleton, normally each section is about a screen long).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot; {{{1 GUI computer&#xA;set mouse=a                 &amp;quot; Enable use of the mouse for all modes&#xA;set number                  &amp;quot; Display line numbers on the left&#xA;set relativenumber&#xA;&#xA;&amp;quot; {{{1 KEY MAPPINGS&#xA;&amp;quot; Can show a list of mappings with :map&#xA;&amp;quot; Note!!! Comments on a separate line.&#xA;&#xA;&amp;quot; {{{2 All modes&#xA;map ; :&#xA;map! &amp;lt;M-;&amp;gt; &amp;lt;Esc&amp;gt;:&#xA;&#xA;&amp;quot; {{{2 Map&#xA;&amp;quot; Map backspace to other buffer&#xA;noremap &amp;lt;BS&amp;gt; &amp;lt;C-^&amp;gt;&#xA;noremap &amp;lt;BS&amp;gt; &amp;lt;C-^&amp;gt;&#xA;&amp;quot; }}}2 &amp;lt;- OPTIONAL way to force closure of a section, if you want to create a blank line before the next section is automatically made with {{{1 or {{{2 etc&#xA;&#xA;&amp;quot; {{{1 ANOTHER HEADING&#xA;&amp;quot; More stuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27110" LastEditorUserId="27110" LastEditDate="2020-11-16T19:11:55.800" LastActivityDate="2020-11-16T19:11:55.800" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24988" PostTypeId="2" ParentId="19828" CreationDate="2020-04-29T20:18:53.523" Score="1" Body="&lt;p&gt;I managed to fix my vimwiki ultisnippets by changing the vimwiki file extension to &lt;code&gt;.mdvimwiki&lt;/code&gt; and registering it with @ranebrown the &lt;code&gt;UltisnipsAddFiletypes&lt;/code&gt; tip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I did not need&lt;/strong&gt; the &lt;code&gt;let g:vimwiki_table_mappings = 0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I added to my vim.init:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType mdvimwiki UltiSnipsAddFiletypes vimwiki&#xA;&#xA;&quot; use my custom folder, markdown syntax and custom extension&#xA;let g:vimwiki_list = [{'path': '~/.config/mynotes/',&#xA;                    \ 'syntax': 'markdown', 'ext': '.mdvimwiki'}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29119" LastActivityDate="2020-04-29T20:18:53.523" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24989" PostTypeId="2" ParentId="21881" CreationDate="2020-04-29T21:27:46.450" Score="1" Body="&lt;p&gt;I slightly refactored your function and made it more robust. After quitting the terminal, with for example &lt;code&gt;exit&lt;/code&gt; command in Windows, you will get an error when trying to invoke your &lt;code&gt;ToggleTerminal()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let s:term_buf_nr = -1&#xA;function! s:ToggleTerminal() abort&#xA;    if s:term_buf_nr == -1&#xA;        execute &quot;botright terminal&quot;&#xA;        let s:term_buf_nr = bufnr(&quot;$&quot;)&#xA;    else&#xA;        try&#xA;            execute &quot;bdelete! &quot; . s:term_buf_nr&#xA;        catch&#xA;            let s:term_buf_nr = -1&#xA;            call &amp;lt;SID&amp;gt;ToggleTerminal()&#xA;            return&#xA;        endtry&#xA;        let s:term_buf_nr = -1&#xA;    endif&#xA;endfunction&#xA;&#xA;nnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;t :call &amp;lt;SID&amp;gt;ToggleTerminal()&amp;lt;CR&amp;gt;&#xA;tnoremap &amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;t &amp;lt;C-w&amp;gt;N:call &amp;lt;SID&amp;gt;ToggleTerminal()&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By enclosing the &lt;code&gt;else&lt;/code&gt; part of the code in try-catch block, you can react to the aforementioned problem accordingly. I bet you can also &lt;code&gt;let s:term_buf_nr&lt;/code&gt; on even of closing the terminal, but I don't know how to do it (I didn't bother, as this solution works for me just fine).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing I don't like about it yet is the fact that it destroys the buffer instead of hiding it somehow, but that's different topic :)&lt;/p&gt;&#xA;" OwnerUserId="23424" LastActivityDate="2020-04-29T21:27:46.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24990" PostTypeId="1" CreationDate="2020-04-29T21:41:34.143" Score="1" ViewCount="19" Body="&lt;p&gt;The following function, when at the prompt, if one presses &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, then it will print &lt;code&gt;EXIT&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Testinput()&#xA;    let g:searchString = input(&quot;Enter search string: &quot;, 'default', 'syntax')&#xA;    if g:searchString == '' || g:searchString == '\n'&#xA;        echom &quot;EXIT&quot;&#xA;    else&#xA;        echom &quot;CONTINUIE&quot;&#xA;    endif&#xA;endfun&#xA;call Testinput()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I mapped &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; because when multiline appending or inserting, if one presses &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;, then all the line are updated, however if one press &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt;, then they arent. I tried to fix that inconsistent behaviour with the following mapping to my init.vim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap! &amp;lt;C-[&amp;gt; &amp;lt;Esc&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However when one tries to abort the above function, it always says &quot;CONTINUE&quot;. I remapped &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt;, didnt change &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-04-29T21:41:34.143" Title="Mapping &lt;C-[&gt; causes input() to not be abortable" Tags="|key-bindings|user-input|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24991" PostTypeId="1" AcceptedAnswerId="24996" CreationDate="2020-04-29T22:07:05.393" Score="0" ViewCount="320" Body="&lt;p&gt;I am trying to add autocompletion, with suggestions from the currently edited buffer when reading input from the user for a search string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! Testinput()&#xA;    return input(&quot;Enter search string: &quot;, 'default', 'syntax')&#xA;endfun&#xA;call Testinput()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above snippet, &lt;code&gt;syntax&lt;/code&gt; is the &lt;code&gt;{completion}&lt;/code&gt; argument, from the help:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;  The optional {completion} argument specifies the type of&#xA;  completion supported for the input.  Without it completion is&#xA;  not performed.  The supported completion types are the same as&#xA;  that can be supplied to a user-defined command using the&#xA;  &quot;-complete=&quot; argument.  Refer to |:command-completion| for&#xA;  more information.  Example: &amp;gt;&#xA;      let fname = input(&quot;File: &quot;, &quot;&quot;, &quot;file&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I looked though the list available &lt;code&gt;:help command-completion&lt;/code&gt;, the closest matches I could find are: &lt;code&gt;syntax&lt;/code&gt;, &lt;code&gt;tags&lt;/code&gt; (error about not having ctags), i.e. neither one worked. I tested it with &lt;code&gt;file&lt;/code&gt; and I indeed had file autocompletion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Surely its quite a common use case to auto complete using the buffere's auto complete (or the text in the buffer)? I tried to figure out what auto complete function is currently in use and could not find it (e.g. omnifunc is set to nothing), and the help shows one how to make an autocomplete function.&lt;/p&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-04-30T12:01:21.630" Title="Use the buffers auto completion in an input() dialogue" Tags="|autocompletion|user-input|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24992" PostTypeId="1" AcceptedAnswerId="24993" CreationDate="2020-04-29T22:34:58.013" Score="2" ViewCount="417" Body="&lt;p&gt;I have the following function that runs &lt;code&gt;eslint&lt;/code&gt; project wise:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! EslintProject()&#xA;  &quot; Allows using eslint --format compact output with quickfix list&#xA;  set errorformat+=%f:\ line\ %l\\,\ col\ %c\\,\ %trror\ -\ '%*[^']'\ %m&#xA;  set errorformat+=%f:\ line\ %l\\,\ col\ %c\\,\ %tarning\ -\ '%*[^']'\ %m&#xA;  &quot; Is lines which don't match the format&#xA;  set errorformat+=%-G%.%#&#xA;&#xA;  if executable('yarn')&#xA;    !yarn run --silent eslint . --ext .js,.jsx,.ts,.tsx,.vue --no-color -f compact&#xA;  elseif executable('npm')&#xA;    !npm run --silent eslint . --ext .js,.jsx,.ts,.tsx,.vue --no-color -f compact&#xA;  else&#xA;    echoerr 'No ESLint found'&#xA;  endif&#xA;&#xA;&#xA;  &quot; Restore values&#xA;  set errorformat-=%f:\ line\ %l\\,\ col\ %c\\,\ %trror\ -\ '%*[^']'\ %m&#xA;  set errorformat-=%f:\ line\ %l\\,\ col\ %c\\,\ %tarning\ -\ '%*[^']'\ %m&#xA;  set errorformat-=%-G%.%#&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to define a command for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -bar EslintProject call EslintProject() | cexpr | cw | redraw!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the quickfix list is not populated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way of populating the quickfix list from a function call which executes external commands?&lt;/p&gt;&#xA;" OwnerUserId="8066" LastActivityDate="2020-04-30T01:41:57.467" Title="How to put the output of a function call into quickfix list?" Tags="|external-command|quickfix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24993" PostTypeId="2" ParentId="24992" CreationDate="2020-04-29T23:18:20.713" Score="2" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com -bar EslintProject call EslintProject()&#xA;&#xA;fu EslintProject() abort&#xA;  if executable('yarn')&#xA;    let cmd = 'yarn run --silent eslint . --ext .js,.jsx,.ts,.tsx,.vue --no-color -f compact'&#xA;  elseif executable('npm')&#xA;    let cmd = 'npm run --silent eslint . --ext .js,.jsx,.ts,.tsx,.vue --no-color -f compact'&#xA;  else&#xA;    echoerr 'No ESLint found'&#xA;  endif&#xA;&#xA;  let efm = &amp;amp;efm&#xA;  let efm ..= ',%f: line %l\, col %c\, %trror - ''%*[^'']'' %m'&#xA;  let efm ..= ',%f: line %l\, col %c\, %tarning - ''%*[^'']'' %m'&#xA;  let efm ..= ',%-G%.%#'&#xA;&#xA;  sil let qfl = getqflist({'lines': systemlist(cmd), 'efm': efm})&#xA;  call setqflist(get(qfl, 'items', []))&#xA;  cw&#xA;endfu&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the error format doesn't work as expected, visit &lt;a href=&quot;https://reviewdog.github.io/errorformat-playground/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this site&lt;/a&gt; to build a better one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can get a quickfix list resulting from the parsing of the output of an arbitrary shell command, with an arbitrary error format, with this expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getqflist({'lines': systemlist('my shell command'), 'efm': 'my error format'})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As an example, this snippet should populate a valid quickfix list with all the files in &lt;code&gt;/etc&lt;/code&gt; whose name end with &lt;code&gt;.conf&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let qfl = getqflist({'lines': systemlist('find /etc/ -name &quot;*.conf&quot;'), 'efm': '%f'})&#xA;call setqflist(get(qfl, 'items', []))&#xA;cw&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more info, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:h getqflist()&#xA;:h setqflist()&#xA;:h getqflist-examples&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17449" LastEditorUserId="17449" LastEditDate="2020-04-30T01:41:57.467" LastActivityDate="2020-04-30T01:41:57.467" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24994" PostTypeId="1" AcceptedAnswerId="24998" CreationDate="2020-04-29T23:34:50.370" Score="1" ViewCount="96" Body="&lt;p&gt;When I&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Execute &lt;code&gt;vim A&lt;/code&gt; command from shell&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Edit the file &lt;code&gt;A&lt;/code&gt; in some way (now &lt;code&gt;&amp;amp;modified == 1&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Execute &lt;code&gt;:Lexplore&lt;/code&gt; &lt;sup&gt;†1&lt;/sup&gt; to enable the side pane of netrw&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press &lt;kbd&gt;Enter&lt;/kbd&gt; on an arbitary file &lt;code&gt;B&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;, the file &lt;code&gt;B&lt;/code&gt; is opened in the window in which &lt;code&gt;A&lt;/code&gt; was opened &lt;strong&gt;without&lt;/strong&gt; any prompt and, as a result, the modification to &lt;code&gt;A&lt;/code&gt; is totally lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this an expected behavior? How can I get along with this buggy behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;†1: Edit: it turns out the problem is not specific to &lt;code&gt;:Lexplore&lt;/code&gt; command. Netrw opened via &lt;code&gt;:Explore&lt;/code&gt; or &lt;code&gt;:e&lt;/code&gt; also shows the behavior. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Current Status&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect the behavior is unexpected (i.e. a bug). I'm debugging &lt;code&gt;netrw&lt;/code&gt; according to the instructions found in &lt;code&gt;:help netrw&lt;/code&gt; and have located the cause; &lt;code&gt;e!&lt;/code&gt; is called in &lt;code&gt;autoload/netrw.vim&lt;/code&gt;. Just replacing two &lt;code&gt;e!&lt;/code&gt; with &lt;code&gt;e&lt;/code&gt; solved the discarding behavior. But I still have to keep analyzing the code to know what kind of side effects will happen if &lt;code&gt;e!&lt;/code&gt; is replaced with &lt;code&gt;e&lt;/code&gt; and the operation fails due to &lt;code&gt;&amp;amp;modified == 1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;.vimrc&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm using a minimal &lt;code&gt;.vimrc&lt;/code&gt; which has only the following two lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set nocp&#xA;filetype plugin on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Environments&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could reproduce the problem under multiple environments.&lt;/p&gt;&#xA;" OwnerUserId="16502" LastEditorUserId="16502" LastEditDate="2020-04-30T05:32:06.617" LastActivityDate="2020-05-07T01:28:46.970" Title="Netrw discards changes without asking" Tags="|netrw|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24995" PostTypeId="1" CreationDate="2020-04-30T00:13:08.597" Score="1" ViewCount="134" Body="&lt;p&gt;I wrote the function below,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/ryuta69/dotfiles/blob/master/dotfiles/.vimrc#L129-L146&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ryuta69/dotfiles/blob/master/dotfiles/.vimrc#L129-L146&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fun! DeoEnter()&#xA;    if !pumvisible()&#xA;        return &quot;\n&quot;&#xA;    endif&#xA;&#xA;    if vsnip#available(1)&#xA;        call vsnip#expand()&#xA;        return &quot;\&amp;lt;C-y&amp;gt;&quot;&#xA;    endif&#xA;&#xA;    call UltiSnips#ExpandSnippetOrJump()&#xA;    if g:ulti_expand_or_jump_res &amp;gt; 0&#xA;        return &quot;&quot;&#xA;    endif&#xA;&#xA;    return &quot;\&amp;lt;C-y&amp;gt;&quot;&#xA;endfun&#xA;ino &amp;lt;CR&amp;gt; &amp;lt;C-R&amp;gt;=DeoEnter()&amp;lt;CR&amp;gt;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;, however, I found it should separate conditions if the cursor is on pumvisible suggestions. neosnippet has &lt;code&gt;neosnippet#expandable&lt;/code&gt;, however deoplete itself seems not to have such a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="29186" LastActivityDate="2020-04-30T00:13:08.597" Title="Is there anyway to check if cursor is on pumvisible suggestion or not?" Tags="|vimrc|neovim|functions|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24996" PostTypeId="2" ParentId="24991" CreationDate="2020-04-30T01:50:59.153" Score="3" Body="&lt;p&gt;&quot;tags&quot; is probably the closest built-in, if you want to complete project contents, but you'd need a tags file.  There doesn't seem to be a method for buffer contents.  We can write a custom one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CompleteWords(ArgLead, CmdLine, ...)&#xA;  return getline(1, '$')-&amp;gt;join(' ')-&amp;gt;split('\s\+')&#xA;        \ -&amp;gt;filter({_,x-&amp;gt;match(x, '^\h\w\+$') &amp;gt; -1})&#xA;        \ -&amp;gt;filter({_,x-&amp;gt;match(x, '^' . a:CmdLine) &amp;gt; -1})&#xA;        \ -&amp;gt;sort()-&amp;gt;uniq()&#xA;endfunction&#xA;&#xA;call input('file: ', '', 'customlist,CompleteWords')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This function just gets the current buffer's text, and splits it word-by-word, filters to the current entered text, and then unique-sorts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not efficient if your buffer is huge, but for moderate size buffers it should work.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastActivityDate="2020-04-30T01:50:59.153" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24997" PostTypeId="1" AcceptedAnswerId="25001" CreationDate="2020-04-30T02:42:04.010" Score="1" ViewCount="1606" Body="&lt;p&gt;I'm using nVim &lt;code&gt;v0.4.3&lt;/code&gt; and I'm having trouble getting multiline inserts to work in visual blockwise mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check this asciinema to see what I'm doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://asciinema.org/a/sgoQGZlIwkAM1QkKSZptIc5d9&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://asciinema.org/a/sgoQGZlIwkAM1QkKSZptIc5d9&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you'll see there, the sequence I'm using is &lt;code&gt;&amp;lt;S-v&amp;gt;jjj&amp;lt;S-i&amp;gt;test &amp;lt;ESC&amp;gt;&lt;/code&gt; and what I end up with is the first line is modified but not the rest.&#xA;am I missing something?&lt;/p&gt;&#xA;" OwnerUserId="29306" LastActivityDate="2022-10-11T05:08:23.777" Title="blockwise visual mode multi line prepend doesn't work for me" Tags="|neovim|insert-mode|visual-block|" AnswerCount="1" CommentCount="5" ClosedDate="2020-04-30T11:00:22.623" ContentLicense="CC BY-SA 4.0" />
  <row Id="24998" PostTypeId="2" ParentId="24994" CreationDate="2020-04-30T05:01:45.903" Score="1" Body="&lt;p&gt;It seems the behavior is a bug. Here's the patch to fix it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--- netrw_before.vim    2020-04-30 13:12:10.225394138 +0900&#xA;+++ netrw.vim   2020-04-30 13:03:50.746727412 +0900&#xA;@@ -4899,9 +4899,19 @@&#xA;      &quot; some like c-^ to return to the last edited file&#xA;      &quot; others like c-^ to return to the netrw buffer&#xA;      if exists(&quot;g:netrw_altfile&quot;) &amp;amp;&amp;amp; g:netrw_altfile&#xA;-      exe &quot;NetrwKeepj keepalt e! &quot;.fnameescape(dirname)&#xA;+      try&#xA;+       exe &quot;NetrwKeepj keepalt e &quot;.fnameescape(dirname)&#xA;+      catch&#xA;+       echoerr &quot;No write since last change&quot;&#xA;+       let __local_file_opening_error = 1&#xA;+      endtry&#xA;      else&#xA;-      exe &quot;NetrwKeepj e! &quot;.fnameescape(dirname)&#xA;+      try&#xA;+       exe &quot;NetrwKeepj e &quot;.fnameescape(dirname)&#xA;+      catch&#xA;+       echoerr &quot;No write since last change&quot;&#xA;+       let __local_file_opening_error = 1&#xA;+      endtry&#xA;      endif&#xA; &quot;     call Decho(&quot;edit-a-file: after e! &quot;.dirname.&quot;: hidden=&quot;.&amp;amp;hidden.&quot; bufhidden&amp;lt;&quot;.&amp;amp;bufhidden.&quot;&amp;gt; mod=&quot;.&amp;amp;mod,'~'.expand(&quot;&amp;lt;slnum&amp;gt;&quot;))&#xA;      call s:NetrwCursor()&#xA;@@ -4912,7 +4922,9 @@&#xA;     else&#xA; &quot;     call Decho(&quot;edit-a-file: remote file: NetrwBrowse will edit it&quot;,'~'.expand(&quot;&amp;lt;slnum&amp;gt;&quot;))&#xA;     endif&#xA;-    let dolockout= 1&#xA;+    if !exists(&quot;__local_file_opening_error&quot;)&#xA;+     let dolockout= 1&#xA;+    endif&#xA;&#xA;     &quot; handle g:Netrw_funcref -- call external-to-netrw functions&#xA;     &quot;   This code will handle g:Netrw_funcref as an individual function reference&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, however, the patch is written for me and &lt;strong&gt;not tested very well&lt;/strong&gt; (at least by me).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/your-diary/netrw_avoid_discarding_modified_buffer&quot; rel=&quot;nofollow noreferrer&quot;&gt;my GitHub repository&lt;/a&gt; to get the latest version of the patch and detailed explanations about the cause, the algorithm of the patch, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;del&gt;I've already sent an e-mail about this bug to the author of &lt;code&gt;netrw&lt;/code&gt;. I hope it will be fixed soon.&lt;/del&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; The patch has been adopted in &lt;code&gt;netrw 170f (April 30, 2020)&lt;/code&gt;. However, I suspect it will take long for the version of &lt;code&gt;netrw&lt;/code&gt; to be included in the upstream of &lt;code&gt;vim&lt;/code&gt;. Till the day, if you'd like to remove the bug, manually download the plugin from the &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#NETRW&quot; rel=&quot;nofollow noreferrer&quot;&gt;official&lt;/a&gt; and install it.&lt;/p&gt;&#xA;" OwnerUserId="16502" LastEditorUserId="16502" LastEditDate="2020-05-07T01:28:46.970" LastActivityDate="2020-05-07T01:28:46.970" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24999" PostTypeId="1" AcceptedAnswerId="25000" CreationDate="2020-04-30T06:19:29.490" Score="1" ViewCount="137" Body="&lt;p&gt;I have the GVim 8.1 compiled with &lt;code&gt;+terminal&lt;/code&gt; flag. After I enter Vim via &lt;code&gt;vim -u NONE&lt;/code&gt;, I try to execute simple command, like &lt;code&gt;:terminal cd&lt;/code&gt; or &lt;code&gt;:terminal dir&lt;/code&gt; just to check the output. Instead of the command being executed, I get the &lt;code&gt;CreateProces failed&lt;/code&gt; error. How can I debug this? Does anybody know what might be the cause of it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I can use &lt;code&gt;:!&amp;lt;command&amp;gt;&lt;/code&gt; syntax, but I'm testing the &lt;code&gt;terminal&lt;/code&gt; syntax so that I can configure it in the future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="23424" LastActivityDate="2020-04-30T06:56:48.160" Title="Cannot run basic Windows commands using :terminal" Tags="|gvim|terminal|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25000" PostTypeId="2" ParentId="24999" CreationDate="2020-04-30T06:56:48.160" Score="2" Body="&lt;p&gt;&lt;code&gt;dir&lt;/code&gt; and &lt;code&gt;cd&lt;/code&gt; are not external utilities, but shell builtins. They cannot be executed directly. You have to open &lt;code&gt;:terminal&lt;/code&gt; without parameters to run cmd.exe and only after that enter a command like &lt;code&gt;dir&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;:!&lt;/code&gt; differs, as it prepends &lt;code&gt;:h 'shell'&lt;/code&gt; and &lt;code&gt;:h 'shellcmdflag'&lt;/code&gt; before your command automatically.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-04-30T06:56:48.160" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25001" PostTypeId="2" ParentId="24997" CreationDate="2020-04-30T08:02:58.687" Score="2" Body="&lt;h2&gt;TL;DR use &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; instead of &lt;code&gt;V&lt;/code&gt;&lt;/h2&gt;&#xA;&lt;p&gt;the reason is that &lt;code&gt;S-v&lt;/code&gt; is used instead of &lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt;(&lt;code&gt;V&lt;/code&gt;) before &lt;code&gt;S-i&lt;/code&gt;(&lt;code&gt;I&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;vim block&lt;/code&gt; &lt;code&gt;put&lt;/code&gt; command works only for &lt;code&gt;Vertical blocks&lt;/code&gt;, not for selected lines.&lt;/p&gt;&#xA;&lt;h2&gt;Difference between &lt;code&gt;V&lt;/code&gt; and &lt;code&gt;C-v&lt;/code&gt;&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;V&lt;/code&gt; (&lt;code&gt;&amp;lt;S-v&amp;gt;&lt;/code&gt;) is for selecting whole line$&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;C-v&amp;gt;&lt;/code&gt; starts selecting &lt;code&gt;Visual block&lt;/code&gt;:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;With CTRL-V (blockwise Visual mode) the highlighted text will be a rectanglebetween start position and the cursor.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h2&gt;&lt;code&gt;I&lt;/code&gt; in &lt;code&gt;insert&lt;/code&gt; vs &lt;code&gt;visual&lt;/code&gt; modes&lt;/h2&gt;&#xA;&lt;p&gt;In &lt;code&gt;insert&lt;/code&gt; mode &lt;code&gt;I&lt;/code&gt; just inserts text before the cursor:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I Insert text before the first non-blank in the line [count] times.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;To insert before every selected lines use &lt;code&gt;Visual block&lt;/code&gt; mode:&#xA;See &lt;code&gt;I block insert v_b_I&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Visual-block Insert (&lt;code&gt;v_b_I&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;With a blockwise selection, I{string} will insert {string} at the startof block on every line of the block, provided that the line extends into theblock.  Thus lines that are short will remain unmodified.  TABs are split toretain visual columns.See v_b_I_example.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="22724" LastEditorUserId="22724" LastEditDate="2022-10-11T05:08:23.777" LastActivityDate="2022-10-11T05:08:23.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25002" PostTypeId="2" ParentId="24977" CreationDate="2020-04-30T09:51:30.743" Score="17" Body="&lt;p&gt;There's a bunch of excellent answers here already, but for the sake of completeness I feel like I should point out that, in most &lt;em&gt;practical&lt;/em&gt; respects, if you concatenate multiple ex commands with the &lt;a href=&quot;https://vimhelp.org/cmdline.txt.html#%3Abar&quot; rel=&quot;noreferrer&quot;&gt;bar character &lt;code&gt;|&lt;/code&gt;&lt;/a&gt;, they act like a single operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, they will lead to a single item in each of the &lt;a href=&quot;https://vimhelp.org/usr_32.txt.html&quot; rel=&quot;noreferrer&quot;&gt;undo tree&lt;/a&gt; and &lt;a href=&quot;https://vimhelp.org/motion.txt.html#changelist&quot; rel=&quot;noreferrer&quot;&gt;changelist&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such, the following acts like a simultaneous change of 1 to 0 and 0 to 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/1/TEMP/g | %s/0/1/g | %s/TEMP/0/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-04-30T09:51:30.743" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25003" PostTypeId="2" ParentId="24977" CreationDate="2020-04-30T10:36:28.070" Score="5" Body="&lt;p&gt;I'm quite certain I've already gave an answer to the general case either here on vi.SE, or on stackoverflow, but impossible to find the Q/A...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that answer I provide the command &lt;code&gt;CycleSubstitute&lt;/code&gt; that could be used in your case in the following way&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:[range]CycleSubstitute/0/1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've packaged it &lt;a href=&quot;https://github.com/LucHermitte/lh-misc/blob/master/plugin/rotate_substitute.vim#L36&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. And it's implemented in the following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:command! -bang -nargs=1 -range CycleSubstitute &amp;lt;line1&amp;gt;,&amp;lt;line2&amp;gt;call s:CycleSubstitute(&quot;&amp;lt;bang&amp;gt;&quot;, &amp;lt;f-args&amp;gt;)&#xA;&#xA;function! s:CycleSubstitute(bang, repl_arg) range&#xA;  let do_loop = a:bang != &quot;!&quot;&#xA;  let sep = a:repl_arg[0]&#xA;  let fields = split(a:repl_arg, sep)&#xA;  let cleansed_fields = map(copy(fields), 'substitute(v:val, &quot;\\\\[&amp;lt;&amp;gt;]&quot;, &quot;&quot;, &quot;g&quot;)')&#xA;  &quot; build the action to execute&#xA;  let action = '\=s:DoCycleSubst('.do_loop.',' . string(cleansed_fields) . ', &quot;^&quot;.submatch(0).&quot;$&quot;)'&#xA;  &quot; prepare the :substitute command&#xA;  let args = [join(fields, '\|'), action ]&#xA;  let cmd = a:firstline . ',' . a:lastline . 's'&#xA;        \. sep . join(fields, '\|')&#xA;        \. sep . action&#xA;        \. sep . 'g'&#xA;  &quot; echom cmd&#xA;  &quot; and run it&#xA;  exe cmd&#xA;endfunction&#xA;&#xA;function! s:DoCycleSubst(do_loop, fields, what)&#xA;  let idx = (match(a:fields, a:what) + 1) % len(a:fields)&#xA;  return a:fields[idx]&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="626" LastActivityDate="2020-04-30T10:36:28.070" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25004" PostTypeId="2" ParentId="24960" CreationDate="2020-04-30T10:37:23.660" Score="3" Body="&lt;p&gt;In the absence of a complete solution, I thought I'd just write a quick answer that shows one way you can achieve the first part of your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the following mapping (for F3):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;F3&amp;gt; :s/%&amp;gt;%/&amp;amp;\r/g&amp;lt;CR&amp;gt;V``j=gv&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;How it works&lt;/h2&gt;&#xA;&#xA;&lt;h3&gt;Splitting the line&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;First, it breaks the line on the pipes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:s/%&amp;gt;%/&amp;amp;\r/g&#xA;:s/           # substitute&#xA;   %&amp;gt;%        # pipes&#xA;      /       # with&#xA;       &amp;amp;      # the matched text (See &quot;:help s/\\&amp;amp;&quot;)&#xA;        \r    # followed by a newline&#xA;          /g  # everywhere on the line&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Reindenting&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This splits the line, but doesn't result in your desired indentation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iris %&amp;gt;%&#xA; group_by(Species) %&amp;gt;%&#xA; summarise(Sepal.Length = mean(Sepal.Length)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it then reindents using Vim's R filetype's automatic indentation (which is an &lt;a href=&quot;https://vimhelp.org/indent.txt.html#indent-expression&quot; rel=&quot;nofollow noreferrer&quot;&gt;indent expression&lt;/a&gt;) with the following normal mode commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V``j=&#xA;V      # enter linewise visual mode&#xA; ``    # jump back&#xA;   j   # move down one line&#xA;    =  # reindent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Indent more!&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;However, this appears to just align the subsequent lines with the first line&amp;#8202;&amp;mdash;&amp;#8202;which still isn't what you want&amp;#8202;&amp;mdash;&amp;#8202;so it then indents these further with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gv&amp;gt;&amp;gt;&#xA;gv    # reselect the previous visual mode selection&#xA;  &amp;gt;&amp;gt;  # indent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Going the rest of the way&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You should be able to adapt this to write a similar mapping that splits the function parameters into multiple lines, but performing both sets of changes with a single keystroke is probably outside the scope of a single-line mapping: you're likely to need to write a more sophisticated context-sensitive &lt;a href=&quot;https://vimhelp.com/eval.txt.html#user-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;function&lt;/a&gt; to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before embarking on such a venture, I'd definitely do a bit more research into whether anyone else has already solved this problem. You might like to look into Andrew Radev's &lt;a href=&quot;https://github.com/AndrewRadev/splitjoin.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;splitjoin plugin&lt;/a&gt; which performs precisely this sort of edit. A brief skim of the README suggests it doesn't support R, but it might be possible to configure or adapt it to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;filbranden also suggests &lt;a href=&quot;https://github.com/FooSoft/vim-argwrap&quot; rel=&quot;nofollow noreferrer&quot;&gt;ArgWrap&lt;/a&gt; in &lt;a href=&quot;https://vi.stackexchange.com/questions/24960/reformat-code-breaking-lines-and-aligning-on-a-character/25004?noredirect=1#comment43688_25004&quot;&gt;the comments&lt;/a&gt;, which looks like it should handle the arguments, but perhaps not the pipes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if neither of the above works for you, it wouldn't surprise me in the least to discover there is another plugin that &lt;em&gt;does&lt;/em&gt; do this for R.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-04-30T15:07:06.700" LastActivityDate="2020-04-30T15:07:06.700" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="25005" PostTypeId="2" ParentId="24991" CreationDate="2020-04-30T12:01:21.630" Score="0" Body="&lt;p&gt;I'm using Neovim if that makes a difference. @Mass's answer did not work for me until I modified it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CompleteWords(ArgLead, CmdLine, ...)&#xA;    let str = getline(1, '$')&#xA;    let str  = join(str, ' ')&#xA;    let slist = split(str, '\s\+')&#xA;    call filter(slist, {_, x -&amp;gt; match(x, '^\h\w\+$') &amp;gt; -1})&#xA;    call filter(slist, {_, x -&amp;gt; match(x, '^' . a:CmdLine) &amp;gt; -1})&#xA;    call sort(slist)&#xA;    call uniq(slist)&#xA;    return slist&#xA;endfunction&#xA;call input('file: ', '', 'customlist,CompleteWords')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additionally it was not finding some of the matches, so I made it a bit smarter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! CompleteFromBufferWords(ArgLead, CmdLine, ...)&#xA;    let str = getline(1, '$')&#xA;    let str  = join(str, ' ')&#xA;    &quot; Split on whitespace and unusual characters (excludes - and _)&#xA;    let slist = split(str, '[ \t~!@#$%^&amp;amp;*+=()&amp;lt;&amp;gt;{}[\];:|,.?&quot;\\/'']\+')&#xA;    call filter(slist, {_, x -&amp;gt; len(x) &amp;gt; 2 &amp;amp;&amp;amp; match(x, '^[a-zA-Z_]\+') &amp;gt; -1})&#xA;    &quot; If must start with the word:&#xA;    &quot;call filter(slist, {_, x -&amp;gt; match(x, '^' . a:CmdLine) &amp;gt; -1})&#xA;    &quot; If must only contain the word:&#xA;    call filter(slist, {_, x -&amp;gt; match(x, a:CmdLine) &amp;gt; -1})&#xA;    call sort(slist)&#xA;    call uniq(slist)&#xA;    return slist&#xA;endfunction&#xA;call input('file: ', '', 'customlist,CompleteFromBufferWords')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-04-30T12:01:21.630" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25006" PostTypeId="2" ParentId="24977" CreationDate="2020-04-30T13:29:15.593" Score="5" Body="&lt;p&gt;Similar to @LucHermitte's answer, the &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#SWAPSTRINGS&quot; rel=&quot;noreferrer&quot;&gt;SwapStrings plugin&lt;/a&gt; lets you do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%SwapStrings 0 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My own &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=4602&quot; rel=&quot;noreferrer&quot;&gt;PatternsOnText plugin&lt;/a&gt; provides (among many others) a &lt;code&gt;:SubstituteMultiple&lt;/code&gt; command that can do swaps as a corner case of doing multiple substitutions atomically (that is, without introducing a temp replacement):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%SubstituteMultiple /0/1/ /1/0/ g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="970" LastActivityDate="2020-04-30T13:29:15.593" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25007" PostTypeId="2" ParentId="24977" CreationDate="2020-04-30T20:12:35.360" Score="6" Body="&lt;p&gt;I'm actually surprised there is no native &lt;a href=&quot;https://en.wikipedia.org/wiki/Tr_(Unix)&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;tr&lt;/code&gt;&lt;/a&gt; in vi/vim, but if your platform is UNIXy enough, there's an external command for just this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%!tr 01 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is what I would personally use, but it may not be portable enough for you.&lt;/p&gt;&#xA;" OwnerUserId="6389" LastActivityDate="2020-04-30T20:12:35.360" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25008" PostTypeId="1" AcceptedAnswerId="25020" CreationDate="2020-04-30T21:14:53.803" Score="3" ViewCount="1018" Body="&lt;p&gt;For better readability I'd like to split if-statements with multiple expression into multiple lines.&#xA;But when executing such a statement via a register vim always complains about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if 1==1 &amp;amp;&amp;amp; 2==2&#xA;  echo '1'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if 1==1&#xA;    \ &amp;amp;&amp;amp; 2==2&#xA;  echo '1'&#xA;endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives &lt;code&gt;E10: \ should be followed by /, ? or &amp;amp;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it really not possible to use line-continuation for if-statements?&lt;/p&gt;&#xA;" OwnerUserId="21417" LastEditorUserId="21417" LastEditDate="2020-05-15T10:09:06.010" LastActivityDate="2020-06-18T09:42:55.240" Title="line-continuation in an an if-statement" Tags="|vimscript|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25009" PostTypeId="2" ParentId="25008" CreationDate="2020-04-30T21:31:39.223" Score="2" Body="&lt;p&gt;According to &lt;code&gt;:help E10&lt;/code&gt;, &lt;code&gt;:set nocp&lt;/code&gt; while editing the &lt;code&gt;if&lt;/code&gt; statement will fix the issue. That is, after setting it, command line continuation will be enabled.&lt;/p&gt;&#xA;" OwnerUserId="28840" LastActivityDate="2020-04-30T21:31:39.223" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25010" PostTypeId="1" AcceptedAnswerId="25014" CreationDate="2020-04-30T21:48:39.590" Score="1" ViewCount="874" Body="&lt;p&gt;I am using nvim v0.4.3. This is the latest version available in repository. I have an Arch build with the most up to date packages and kernel 5.6.4-arch1-1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the below function in my &lt;code&gt;~/.vimrc&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; function&#xA;function! ReSource()    &#xA;    let l:winview = winsaveview()    &#xA;    :source ~/.vimrc&amp;lt;cr&amp;gt;    &#xA;    call winrestview(l:winview)    &#xA;endfunction    &#xA;&#xA;&quot; function call    &#xA;nnoremap &amp;lt;leader&amp;gt;z :call ReSource()&amp;lt;cr&amp;gt;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I call it, NeoVim complains about my re-sourcing the .vimrc file, but the file permissions for &lt;code&gt;~/.vimrc&lt;/code&gt; are OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function should save the exact cursor position and screen buffer when I press &lt;code&gt;\z&lt;/code&gt; and then return to this exact layout after (re)sourcing my vimrc. That is why I use the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error I get when I hit &lt;code&gt;\z&lt;/code&gt; to call the function is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing function ReSource:                                                                          &#xA;line    3:&#xA;E484: Cannot open file ~/.vimrc&amp;lt;cr&amp;gt;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And yet when I use the below simple single line instead, without the function, it sources and re loads .vimrc perfectly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;z :source ~/.vimrc&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's wrong with the function?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Additional Information&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Within the function, if &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I remove the &lt;code&gt;:&lt;/code&gt; and &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; from &lt;code&gt;:source ~/.vimrc&amp;lt;cr&amp;gt;&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;save my &lt;code&gt;~/.vimrc&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;close it,&lt;/li&gt;&#xA;&lt;li&gt;reopen it,&lt;/li&gt;&#xA;&lt;li&gt;and press &lt;code&gt;\z&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error detected while processing ~/.vimrc:                                                               &#xA;line  399:&#xA;E127: Cannot redefine function ReSource: It is in use&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Line 399 is the &lt;code&gt;endfunction&lt;/code&gt; line&lt;/p&gt;&#xA;" OwnerUserId="27300" LastEditorUserId="10604" LastEditDate="2020-05-01T01:25:45.927" LastActivityDate="2020-05-01T01:25:45.927" Title="sourcing .vimrc function does not work" Tags="|functions|" AnswerCount="2" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25011" PostTypeId="2" ParentId="25008" CreationDate="2020-04-30T21:59:00.390" Score="2" Body="&lt;p&gt;As stated in the comment to &lt;a href=&quot;https://vi.stackexchange.com/a/25009/21417&quot;&gt;https://vi.stackexchange.com/a/25009/21417&lt;/a&gt; this has nothing to do with if-statements (or 'compatible' being set). But there obviously is a difference between running that code by sourcing a vimscript file or by running it from a register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case I was just testing a function and didn't bother to &lt;code&gt;:source&lt;/code&gt; the whole script that contains the function, but instead copied the function into the clipboard and then executed the content of that clipboard register via &lt;code&gt;:@&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume it must be the result of some special escaping rules when copying to (or executing from) a register that break line-continuation.&lt;/p&gt;&#xA;" OwnerUserId="21417" LastActivityDate="2020-04-30T21:59:00.390" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25012" PostTypeId="2" ParentId="25010" CreationDate="2020-04-30T22:48:21.077" Score="3" Body="&lt;p&gt;First, &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; in the mapping validates the command -- as we do interactively in the command/ex mode. In a script/function, we shall not add &lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt; to commands -- each line validates a command. TL;DR: It should be &lt;code&gt;source ~/.vimrc&lt;/code&gt; in the &lt;code&gt;.vimrc&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, as the error message says: we cannot redefine a function while it's being executed. IOW, a function defined within a script cannot source that script. The function definition shall be protected.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ! get(s:, 'reloading', 0)&#xA;    &quot; Useful when our vimrc isn't $VIMRC (it's my case to ease portability between windows and *nix)&#xA;    let s:script = expand('&amp;lt;sfile&amp;gt;:p')&#xA;    function! s:Reload() abort&#xA;        let s:reloading = 1&#xA;        try&#xA;            exe 'source '.s:script&#xA;        finally&#xA;            unlet s:reloading&#xA;        endtry&#xA;    endfunction&#xA;endif&#xA;nnoremap &amp;lt;leader&amp;gt;z :&amp;lt;c-u&amp;gt;call &amp;lt;sid&amp;gt;Reload()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it worth the trouble? I don't think so.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2020-04-30T22:54:36.407" LastActivityDate="2020-04-30T22:54:36.407" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25013" PostTypeId="2" ParentId="24977" CreationDate="2020-05-01T00:19:18.240" Score="1" Body="&lt;pre&gt;&lt;code&gt;:%s/\([01]\)/\=1-submatch(1)/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following is taking place in the substitute command&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Search for 1 or 0, remember it as submatch 1 (between the first / and second /)&lt;/li&gt;&#xA;&lt;li&gt;Replace with the value by subtracting from 1 (between the second / and third /)&lt;/li&gt;&#xA;&lt;li&gt;1 becomes 0 and 0 becomes 1&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;\= is interpreted as the beginning of a mathematical expression in the substituted section &lt;/p&gt;&#xA;" OwnerUserId="29322" LastEditorUserId="29322" LastEditDate="2020-05-01T03:53:34.600" LastActivityDate="2020-05-01T03:53:34.600" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25014" PostTypeId="2" ParentId="25010" CreationDate="2020-05-01T01:09:59.103" Score="2" Body="&lt;p&gt;As @LucHermitte pointed out, the problem causing the E127 error is that you're trying to redefine function &lt;code&gt;ReSource()&lt;/code&gt; &lt;em&gt;while&lt;/em&gt; that function is running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you don't &lt;em&gt;need&lt;/em&gt; to use a function to save and restore the cursor while sourcing your vimrc, only thing is that you'll end up using a global variable, but you can clean up after yourself in the same mapping.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;leader&amp;gt;z :let vimrc_winview = winsaveview()&amp;lt;Bar&amp;gt;source ~/.vimrc&amp;lt;Bar&amp;gt;call winrestview(vimrc_winview)&amp;lt;Bar&amp;gt;unlet vimrc_winview&amp;lt;CR&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's a long command-line... But it should work and wouldn't cause the issue with redefining a function. (Redefining a mapping while it's running should be just fine.)&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-05-01T01:09:59.103" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="25015" PostTypeId="2" ParentId="9839" CreationDate="2020-05-01T01:36:49.700" Score="1" Body="&lt;p&gt;I'm not sure if this is doable in mintty, but I have a workaround for iTerm on Mac OS and the same would work for alacritty which is cross platform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In vim I have this mapping&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;C-n&amp;gt;i &amp;lt;C-i&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In teminal preferences I have set up ^i to send hex codes &quot;0xe 0x69&quot; to the shell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For alacritty you need to add this to the key mapping section of your alacritty.xml&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- { key: I,        mods: Control, chars:  &quot;\x0e\x69&quot;                       }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29323" LastActivityDate="2020-05-01T01:36:49.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25016" PostTypeId="1" CreationDate="2020-05-01T03:52:48.643" Score="0" ViewCount="187" Body="&lt;p&gt;I'm using nVim &lt;code&gt;v0.4.3&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't seem to get anything but the default syntax highlighting working. (I'm especially trying to get &lt;code&gt;yats&lt;/code&gt; typescript syntax highlighting working)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried disabling every plugin.&#xA;Then every plugin except for &lt;code&gt;HerringtonDarkholme/yats.vim&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's absolutely no difference in the highlighting. (And the default leaves a lot to be desired).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also checked &lt;code&gt;:scriptnames&lt;/code&gt; to ensure yats wasn't being loaded without my knowledge etc...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without yats&#xA;&lt;a href=&quot;https://i.stack.imgur.com/9YhyV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9YhyV.png&quot; alt=&quot;without yats&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With yats&#xA;&lt;a href=&quot;https://i.stack.imgur.com/18pCh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/18pCh.png&quot; alt=&quot;with yats&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have enabled right now&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1Pxr9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1Pxr9.png&quot; alt=&quot;current plugins&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do differently?&lt;/p&gt;&#xA;" OwnerUserId="29306" LastActivityDate="2020-05-01T03:52:48.643" Title="Only default syntax highlighting works" Tags="|neovim|syntax-highlighting|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="25017" PostTypeId="1" AcceptedAnswerId="25019" CreationDate="2020-05-01T04:23:59.700" Score="2" ViewCount="231" Body="&lt;p&gt;I have a snippet for C-like languages that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet { &quot;braces&quot;&#xA;{&#xA;    $0&#xA;}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to restrict this snippet to expand only if the tab trigger occurs at the end of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use a regex trigger instead (&lt;code&gt;{$&lt;/code&gt;) without success. To quote the documentation: &quot;The snippet is expanded if the recently typed characters match the regular expression&quot;.&lt;/p&gt;&#xA;" OwnerUserId="29325" LastEditorUserId="29325" LastEditDate="2020-05-01T04:49:37.740" LastActivityDate="2020-05-01T05:36:18.150" Title="Ultisnips - trigger expansion only at end of line" Tags="|plugin-ultisnips|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25018" PostTypeId="2" ParentId="24948" CreationDate="2020-05-01T04:57:45.143" Score="1" Body="&lt;p&gt;&lt;code&gt;Ctrl-F&lt;/code&gt; is very handy as it puts the current command line in an editable window, that also shows history. You can use all the Vim commands here to edit the current command, including traversing earlier commands in history.&lt;/p&gt;&#xA;" OwnerUserId="29326" LastActivityDate="2020-05-01T04:57:45.143" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25019" PostTypeId="2" ParentId="25017" CreationDate="2020-05-01T05:36:18.150" Score="2" Body="&lt;p&gt;Nevermind, I figured out how to implement it as a custom context snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;snippet { &quot;braces&quot; &quot;snip.column == len(snip.buffer[snip.line]) - 1&quot; e&#xA;{&#xA;    $0&#xA;}&#xA;endsnippet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29325" LastActivityDate="2020-05-01T05:36:18.150" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25020" PostTypeId="2" ParentId="25008" CreationDate="2020-05-01T08:11:29.273" Score="5" Body="&lt;p&gt;As it was noted, the problem is that neither &lt;code&gt;:h :@&lt;/code&gt;, nor &lt;code&gt;:h execute()&lt;/code&gt; know anything about &lt;code&gt;:h line-continuation&lt;/code&gt;. Only &lt;code&gt;:h :source&lt;/code&gt; supports it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the piece of code taken from my config to deal with this problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; preprocess VimScript to allow&#xA;&quot; :h line-continuation and :h line-continuation-comment&#xA;function s:preprocess(script)&#xA;    if stridx(&amp;amp;cpo, 'C') &amp;lt; 0&#xA;        let [l:curr, l:last] = [1, len(a:script) - 1]&#xA;        while l:curr &amp;lt;= l:last&#xA;            &quot; match line-continuation or line-continuation-comment&#xA;            let l:cont = matchlist(a:script[l:curr], '\v^\s*(\\|&quot;\\ )(.*)')&#xA;            if empty(l:cont)&#xA;                &quot; skip over normal line&#xA;                let l:curr += 1&#xA;            else&#xA;                &quot; join line-continuation&#xA;                if l:cont[1] ==# '\'&#xA;                    let a:script[l:curr - 1] .= l:cont[2]&#xA;                endif&#xA;                unlet a:script[l:curr]&#xA;                let l:last -= 1&#xA;            endif&#xA;        endwhile&#xA;    endif&#xA;    return a:script&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now something like &lt;code&gt;call execute(s:preprocess(getreg('', 1, 1)), '')&lt;/code&gt; should work ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to make it useful we still need some dedicated operators/commands/mappings and such. I have my implementation in &lt;a href=&quot;https://github.com/matveyt/vimfiles&quot; rel=&quot;noreferrer&quot;&gt;my Vim config&lt;/a&gt;. However, it lacks documentation and isn't available as a separate plugin, so you're at your own risk trying to figure out the details.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-05-01T08:11:29.273" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25021" PostTypeId="1" AcceptedAnswerId="25022" CreationDate="2020-05-01T11:13:42.407" Score="1" ViewCount="1235" Body="&lt;p&gt;I have the following &lt;code&gt;windows.json&lt;/code&gt; file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[{&#xA;    &quot;id&quot;:5178,&#xA;    &quot;pid&quot;:40345,&#xA;    &quot;app&quot;:&quot;Alacritty&quot;,&#xA;    &quot;title&quot;:&quot;Alacritty&quot;,&#xA;    &quot;frame&quot;:{&#xA;        &quot;w&quot;:880.0000,&#xA;        &quot;h&quot;:531.0000&#xA;    }&#xA;},{&#xA;    &quot;id&quot;:5780,&#xA;    &quot;pid&quot;:44378,&#xA;    &quot;app&quot;:&quot;Skim&quot;,&#xA;    &quot;title&quot;:&quot;Brezis.pdf&quot;,&#xA;    &quot;frame&quot;:{&#xA;        &quot;w&quot;:980.0000,&#xA;        &quot;h&quot;:532.0000&#xA;    }&#xA;},{&#xA;    &quot;id&quot;:5771,&#xA;    &quot;pid&quot;:44378,&#xA;    &quot;app&quot;:&quot;Skim&quot;,&#xA;    &quot;title&quot;:&quot;struct.pdf&quot;,&#xA;    &quot;frame&quot;:{&#xA;        &quot;w&quot;:980.0000,&#xA;        &quot;h&quot;:532.0000&#xA;    }&#xA;}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'd like to do three things:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) get the elements whose app is &quot;Skim&quot; and store them in a variable;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) count how many elements there are with the app &quot;Skim&quot;, and store that in a variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) get the &lt;code&gt;title&lt;/code&gt;s of all the elements with the app &quot;Skim&quot;, and store them in a list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can do the first two in a shell with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ Skim_windows=$(cat ~/windows.json | jq -r &quot;.[] | select(.app==\&quot;Skim\&quot;)&quot;)&#xA;$ Skim_windows_count=$(echo $Skim_windows | jq -r &quot;.id&quot; | wc -l)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I'm trying to replicate that inside a vim function. The code I currently have is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let Skim_windows = system(&quot;cat ~/windows.json | jq -r \&quot;.[] | select(.app==\\\&quot;Skim\\\&quot;)\&quot;&quot;)&#xA;let Skim_windows_count = system(&quot;echo &quot;.shellescape(Skim_windows,1).(&quot; | jq -r \&quot;.id\&quot; | wc -l&quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which doesn't work, because if I &lt;code&gt;echo Skim_windows_count&lt;/code&gt; I get the error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;parse error: Invalid numeric literal at line 2, column 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also have no idea how to get all the &lt;code&gt;title&lt;/code&gt;s and assign them to a list (in vim).&lt;/p&gt;&#xA;" OwnerUserId="26480" LastActivityDate="2020-05-01T12:42:20.280" Title="Parsing output of json file with jq" Tags="|vimscript|shell|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25022" PostTypeId="2" ParentId="25021" CreationDate="2020-05-01T12:22:22.030" Score="6" Body="&lt;p&gt;VimScript has a JSON parser of its own. There's no need to invoke an external utility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A sample code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; read in file&#xA;let s:js_data = readfile('windows.json')&#xA;&quot; decode into Vim variable&#xA;let s:list = js_decode(join(s:js_data))&#xA;&quot; filter out the skims&#xA;let s:skims = filter(s:list, 'v:val.app==&quot;Skim&quot;')&#xA;&quot; do whatever...&#xA;echo s:skims&#xA;echo len(s:skims)&#xA;for s:item in s:skims&#xA;    echom s:item.title&#xA;endfor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-05-01T12:22:22.030" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25023" PostTypeId="2" ParentId="25021" CreationDate="2020-05-01T12:42:20.280" Score="5" Body="&lt;p&gt;As @Matt points out, you can parse JSON natively in Vimscript, that's the best solution to your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But still, two main recommendations here, for interacting with external commands from Vimscript:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#systemlist%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;systemlist()&lt;/code&gt;&lt;/a&gt; instead of &lt;a href=&quot;https://vimhelp.org/eval.txt.html#system%28%29&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;system()&lt;/code&gt;&lt;/a&gt;. &lt;code&gt;systemlist()&lt;/code&gt; returns a list of lines, which ends up being more natural to handle in Vimscript.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Both &lt;code&gt;systemlist()&lt;/code&gt; and &lt;code&gt;system()&lt;/code&gt; take a second optional &lt;code&gt;{input}&lt;/code&gt; argument, with a list of lines that is to be passed to the external command as its standard input.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;With the two of these together, you can implement this all without using any pipes at all. It might also help with quoting, you won't need to do too much shell quoting anymore.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;1) get the elements whose app is &quot;Skim&quot; and store them in a variable;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;2) count how many elements there are with the app &quot;Skim&quot;, and store that in a variable.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let windows_lines = readfile(expand('~/windows.json'))&#xA;let skim_windows = systemlist('jq -r &quot;.[] | select(.app==\&quot;Skim\&quot;)&quot;', windows_lines)&#xA;let skim_windows_ids = systemlist('jq -r &quot;.id&quot;', skim_windows)&#xA;let skim_windows_count = len(skim_windows_id)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since you have a list in Vim, you can simply use &lt;code&gt;len(...)&lt;/code&gt; to get its length, bypassing the need for an external &lt;code&gt;wc -l&lt;/code&gt; call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note that you could also merge the two &lt;code&gt;jq&lt;/code&gt; commands into one, but I kept your original expressions to illustrate how you can still chain these together with multiple calls to &lt;code&gt;systemlist()&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;3) get the titles of all the elements with the app &quot;Skim&quot;, and store them in a list.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let skim_windows_titles = systemlist('jq -r &quot;.title&quot;', skim_windows)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could have used the titles for counting too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps simpler is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let windows_lines = readfile(expand('~/windows.json'))&#xA;let skim_windows_titles = systemlist('jq -r &quot;.[] | select(.app==\&quot;Skim\&quot;) | .title&quot;', windows_lines)&#xA;let skim_windows_count = len(skim_windows_titles)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if you happen to be editing the &lt;code&gt;windows.json&lt;/code&gt; file in the current buffer, you can then use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let windows_lines = getline(1, '$')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get the contents of the current buffer as a list of lines.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-05-01T12:42:20.280" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25024" PostTypeId="2" ParentId="3177" CreationDate="2020-05-01T14:22:00.627" Score="2" Body="&lt;p&gt;Within cpp.vim put:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;source &amp;lt;sfile&amp;gt;:h/c.vim&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;sfile&amp;gt;&lt;/code&gt; expands to the currently sourced file, and &lt;code&gt;:h&lt;/code&gt; means the head of it.&lt;/p&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-05-01T14:22:00.627" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="25025" PostTypeId="1" CreationDate="2020-05-01T16:08:41.227" Score="2" ViewCount="968" Body="&lt;h2&gt;Working Base Test&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Working on a plugin, and it wasnt working on windows, so I reduced it to this test scenario:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! myautoload#OnStdout(job_id, data, event)&#xA;    for line in a:data&#xA;        echom &quot;&amp;gt;&amp;gt;&amp;gt;&quot;.string(line)&#xA;    endfor&#xA;endfun&#xA;function! myautoload#OnStderr(job_id, data, event)&#xA;    echom &quot;My STDERR, job_id:&quot;.a:job_id.&quot; event:&quot;.a:event.&quot; data:&quot;.string(a:data)&#xA;endfun&#xA;function! myautoload#OnExit(job_id, data, event)&#xA;    echom &quot;My EXIT, job_id:&quot;.a:job_id.&quot; event:&quot;.a:event.&quot; data:&quot;.string(a:data)&#xA;endfun&#xA;function! myautoload#TestJobStart()&#xA;    echom  &quot;------------------------------------&quot;&#xA;    echom &quot;About to start job...&quot;&#xA;    let opts_dict = {'on_exit': 'myautoload#OnExit', 'on_stdout': 'myautoload#OnStdout', 'on_stderr': 'myautoload#OnStderr'}&#xA;    let cmd = &quot;ls -la&quot;       &quot; &amp;lt;--- Line of interest!!!&#xA;    let terminal_buf_nr = jobstart(cmd, opts_dict)&#xA;    echom &quot;Start search for &quot;.g:searchString.&quot; got return start up value: &quot;.terminal_buf_nr&#xA;endfunction&#xA;call myautoload#TestJobStart()&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which works and prints the following in Windows and Ubuntu (&lt;code&gt;:messages&lt;/code&gt; to view it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;------------------------------------&#xA;About to start job...&#xA;Start search for  got return start up value: 48&#xA;&amp;gt;&amp;gt;&amp;gt;'total 100'&#xA;&amp;gt;&amp;gt;&amp;gt;'drwxr-xr-x 13 michael michael  4096 May  1 15:05 .'&#xA;&amp;gt;&amp;gt;&amp;gt;'drwx------ 31 michael michael  4096 Apr 27 15:52 ..'&#xA;&amp;gt;&amp;gt;&amp;gt;'drwxr-xr-x  2 michael michael  4096 Apr 30 19:12 autoload'&#xA;&amp;gt;&amp;gt;&amp;gt;'-rw-r--r--  1 michael michael  1083 May  1 15:05 coc-settings.json'&#xA;&amp;gt;&amp;gt;&amp;gt;...etc&#xA;&amp;gt;&amp;gt;&amp;gt;''&#xA;&amp;gt;&amp;gt;&amp;gt;''&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Introduce Ripgrep&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Then I added back the command I am actually trying to run, ripgrep, so I changed the above line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let cmd = &quot;ls -la&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let cmd = &quot;rg --vimgrep endfunction&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;code&gt;endfunction&lt;/code&gt; is just the term I am grepping for. This works on Ubuntu, but NOT on Windows. On windows I get no STDOUT, i.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;------------------------------------&#xA;About to start job...&#xA;Start search for  got return start up value: 16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Strange. Further more if I change the command to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let cmd = &quot;rg&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I receive STDERR on Windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;------------------------------------&#xA;About to start job...&#xA;Start search for  got return start up value: 20&#xA;&amp;gt;&amp;gt;&amp;gt;''&#xA;My STDERR, job_id:20 event:stderr data:['error: The following required arguments were not provided:', '    &amp;lt;PATTERN&amp;gt;', '', 'USAGE:', '    ', '    rg [OPTIONS] PATTERN [PATH ...]', '    rg [OPTIONS] [-e PATTERN ...] [-f PATTERNFILE ...] [PATH ...]', '    rg [OPTIONS] --files [PATH ...]', '    rg [OPTIONS] --type-list', '    command | rg [OPTIONS] PATTERN', '', 'For more information try --help', '', '']&#xA;My STDERR, job_id:20 event:stderr data:['']&#xA;My EXIT, job_id:20 event:exit data:2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Strange that I can receive STDERR but not STDOUT when running on windows. But I received STDOUT on windows with &lt;code&gt;ls -la&lt;/code&gt; If I run the command like this in vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:!rg --vimgrep endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;let cmd = ['rg', '--vimgrep', 'endfunction']&lt;/code&gt;, didnt help. The end goal is to make it async, i.e. from reading the help I think I add to &lt;code&gt;opts_dict&lt;/code&gt; the pair &lt;code&gt;'detach': 1&lt;/code&gt;.  When I add that, then even the test with &lt;code&gt;ls -la&lt;/code&gt; also gives no output, so I suspect it is something to do with threading and it not being attached. If someone could point me in the right direction, or what to read up that would be great!&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Update&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I have been trying every argument : &lt;code&gt;pty&lt;/code&gt;, &lt;code&gt;stdout_buffered&lt;/code&gt;, &lt;code&gt;rpc&lt;/code&gt;... for some reason &lt;code&gt;pty&lt;/code&gt; is kind of working. However then I get extra characters which mess up the output (e.g. &lt;code&gt;^[[0K^M'&lt;/code&gt;). I First thought it was color ouput mess it up, but even with adding &lt;code&gt;--color never&lt;/code&gt; it produces the same output.&lt;/p&gt;&#xA;" OwnerUserId="27110" LastEditorUserId="27110" LastEditDate="2020-05-03T03:06:42.523" LastActivityDate="2020-05-03T18:20:20.697" Title="Neovim Jobstart(), not receiving STDOUT sometimes (if async I think)" Tags="|neovim|job-control|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25026" PostTypeId="2" ParentId="10897" CreationDate="2020-05-01T16:43:02.617" Score="25" Body="&lt;p&gt;&lt;a href=&quot;https://vi.stackexchange.com/a/10898/21817&quot;&gt;Extending Ingo Karkat's solution&lt;/a&gt; to terminal,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi DiffAdd      ctermfg=NONE          ctermbg=Green&#xA;hi DiffChange   ctermfg=NONE          ctermbg=NONE&#xA;hi DiffDelete   ctermfg=LightBlue     ctermbg=Red&#xA;hi DiffText     ctermfg=Yellow        ctermbg=Red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Below are the &lt;code&gt;cterm-colors&lt;/code&gt;, if you want to add your preferred color instead of the ones I used.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;       NR-16   NR-8    COLOR NAME&#xA;        0       0       Black&#xA;        1       4       DarkBlue&#xA;        2       2       DarkGreen&#xA;        3       6       DarkCyan&#xA;        4       1       DarkRed&#xA;        5       5       DarkMagenta&#xA;        6       3       Brown, DarkYellow&#xA;        7       7       LightGray, LightGrey, Gray, Grey&#xA;        8       0*      DarkGray, DarkGrey&#xA;        9       4*      Blue, LightBlue&#xA;        10      2*      Green, LightGreen&#xA;        11      6*      Cyan, LightCyan&#xA;        12      1*      Red, LightRed&#xA;        13      5*      Magenta, LightMagenta&#xA;        14      3*      Yellow, LightYellow&#xA;        15      7*      White&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21817" LastActivityDate="2020-05-01T16:43:02.617" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25027" PostTypeId="1" AcceptedAnswerId="25038" CreationDate="2020-05-01T16:43:52.060" Score="2" ViewCount="9866" Body="&lt;p&gt;I am using NeoVim v0.4.3. &#xA;This is the latest version available in repository.&#xA;I have an Arch build with the most up to date packages and kernel 5.6.4-arch1-1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Occasionally I edit a file with nvim that I don't have permissions to edit.&#xA;I only realise this as I am about to save my work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently I edited&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/etc/pulse/default.pa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nvim /etc/pulse/default.pa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and no use of sudo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This file has the following permissions&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls -la /etc/pulse/default.pa&#xA;-rw-r--r-- 1 root root 4966 Jan 11 18:25 default.pa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I did some googling and tried to save it with  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !sudo tee %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and got this error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo: a terminal is required to read the password; &#xA;either use the -S option to read from standard &#xA;input or configure an askpass helper&#xA;&#xA;shell returned 1&#xA;&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It also showed, on the highlighted bar, at the base of the screen, the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/etc/pulse/default_2.pa [+][RO] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This did'nt work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !echo password | sudo -S tee %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It then displayed the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !echo password | sudo -S tee %                                                                                      &#xA;[sudo] password for user:&#xA;W12: Warning: File &quot;/etc/pulse/default.pa&quot; has changed and the buffer was changed in Vim as well&#xA;See &quot;:help W12&quot; for more info.&#xA;[O]K, (L)oad File:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I pressed &lt;code&gt;O&lt;/code&gt; and nothing happened.&#xA;I then tried &lt;code&gt;:wq&lt;/code&gt; and it complained the file was read only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then went through the process  again and this time pressed &lt;code&gt;L&lt;/code&gt; and it showed&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:w !echo password | sudo -S tee %&#xA;[sudo] password for user:&#xA;W12: Warning: File &quot;/etc/pulse/default.pa&quot; has changed and the buffer was changed in Vim as well&#xA;See &quot;:help W12&quot; for more info.&#xA;&quot;/etc/pulse/default.pa&quot; [readonly] 0L, 0C&#xA;Press ENTER or type command to continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and nvim left me with a blank screen and an overwritten &lt;code&gt;etc/pulse/default.pa&lt;/code&gt; file with nothing in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've recovered the file but want to know how to &lt;code&gt;tee&lt;/code&gt; the file down to disk when I open the file without the correct permissions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm quite new to vim and think I got this working before but can't for the life of me remember how?&lt;/p&gt;&#xA;" OwnerUserId="27300" LastEditorUserId="27300" LastEditDate="2020-05-01T17:11:48.687" LastActivityDate="2021-11-19T13:39:25.540" Title="Saving a non user file with NeoVim, eg root owned /etc/pulse/default.pa" Tags="|sudo|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="25028" PostTypeId="1" AcceptedAnswerId="25029" CreationDate="2020-05-01T18:18:06.323" Score="1" ViewCount="37" Body="&lt;p&gt;I am looking for a way how to transfer this (and similar) block of text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dollar_value: str = field(init=False)&#xA;dollar_symbol: str = field(init=False)&#xA;dollar_unit: str = field(init=False)&#xA;euro_value: str = field(init=False)&#xA;euro_symbol: str = field(init=False)&#xA;euro_unit: str = field(init=False)&#xA;bitcoin_value: str = field(init=False)&#xA;bitcoin_symbol: str = field(init=False)&#xA;bitcoint_unit: str = field(init=False)&#xA;ether_value: str = field(init=False)&#xA;ether_symbol: str = field(init=False)&#xA;ether_unit: str = field(init=False)&#xA;litecoin_value: str = field(init=False)&#xA;litecoin_symbol: str = field(init=False)&#xA;litecoin_unit: str = field(init=False)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dollar_value: str = field(init=False)&#xA;euro_value: str = field(init=False)&#xA;bitcoin_value: str = field(init=False)&#xA;ether_value: str = field(init=False)&#xA;litecoin_value: str = field(init=False)&#xA;dollar_symbol: str = field(init=False)&#xA;euro_symbol: str = field(init=False)&#xA;bitcoin_symbol: str = field(init=False)&#xA;ether_symbol: str = field(init=False)&#xA;litecoin_symbol: str = field(init=False)&#xA;dollar_unit: str = field(init=False)&#xA;euro_unit: str = field(init=False)&#xA;bitcoint_unit: str = field(init=False)&#xA;ether_unit: str = field(init=False)&#xA;litecoin_unit: str = field(init=False)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I though maybe in this particular case a retrograde sorting macro would be helpful (like normal sorting, but starting with the last letter of the word or line, progressing towards the first letter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do retrograde sort in vim? Or what would be a possible approch to this?&lt;/p&gt;&#xA;" OwnerUserId="20114" LastActivityDate="2020-05-01T19:23:54.777" Title="Retrograde sorting" Tags="|macro|sort|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="25029" PostTypeId="2" ParentId="25028" CreationDate="2020-05-01T19:23:54.777" Score="3" Body="&lt;p&gt;Vim's &lt;code&gt;:sort&lt;/code&gt; command can take an optional regex to indicate where to start sorting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://vimhelp.org/change.txt.html#%3Asort&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help :sort&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When &lt;code&gt;/{pattern}/&lt;/code&gt; is specified and there is no &lt;code&gt;[r]&lt;/code&gt; flag the text matched with &lt;code&gt;{pattern}&lt;/code&gt; is skipped, so that you sort on what comes after the match.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So this should be enough to sort lines, considering the text coming after the underscore:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sort /_/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The sort is stable, so it will sort all &quot;symbols&quot;, followed by all &quot;units&quot; and then all &quot;values&quot;, preserving their relative order, which is the expected result you wanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems you wanted &quot;values&quot; first, but that should be a simple operation of cutting them from the end of the list and pasting them back at the beginning, getting to exactly the result you wanted.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastActivityDate="2020-05-01T19:23:54.777" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25030" PostTypeId="1" AcceptedAnswerId="25031" CreationDate="2020-05-01T19:46:18.247" Score="6" ViewCount="1537" Body="&lt;p&gt;Mentioned here as well: &lt;a href=&quot;https://stackoverflow.com/questions/13312794/inotify-dont-treat-vim-editting-as-a-modification-event&quot;&gt;https://stackoverflow.com/questions/13312794/inotify-dont-treat-vim-editting-as-a-modification-event&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Really frustrating issue, how can I force vim to write the file? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems Vim does something strange when writing a file. It does not seem to invoke any of the  &lt;code&gt;[Create, Modify, CloseWrite, Move]&lt;/code&gt; inotify events. Only initially. on the first change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seems that it &quot;deletes&quot; the file, and hence the inotify watch becomes invalid (hence only works once)... How can I work around this?&lt;/p&gt;&#xA;" OwnerUserId="13656" LastEditorUserId="13656" LastEditDate="2020-05-01T19:52:41.207" LastActivityDate="2023-05-24T11:07:40.837" Title="Vim not firing inotify events when writing file" Tags="|save|file|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25031" PostTypeId="2" ParentId="25030" CreationDate="2020-05-01T20:03:00.510" Score="1" Body="&lt;p&gt;Found a hint to one solution here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/188873/using-inotifywait-along-with-vim&quot;&gt;https://unix.stackexchange.com/questions/188873/using-inotifywait-along-with-vim&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:set backupcopy=yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Seems there may be some risk with this approach though.&lt;/p&gt;&#xA;" OwnerUserId="13656" LastActivityDate="2020-05-01T20:03:00.510" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="25032" PostTypeId="1" AcceptedAnswerId="25033" CreationDate="2020-05-01T20:22:40.740" Score="0" ViewCount="195" Body="&lt;p&gt;I am trying to write a function which I bind to &quot;n&quot; and &quot;N&quot; to highlight the current search pattern. That part works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to detect when the cursor wraps to the first match in the buffer (when 'search hit BOTTOM' is shown), and use a different highlight then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I fail getting the line where the search pattern first appears.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know hot to get a list of lines with a global and &lt;code&gt;p&lt;/code&gt; flag but am not sure if and how I should trim it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/pattern/p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can also use &lt;code&gt;search()&lt;/code&gt; with &lt;code&gt;n&lt;/code&gt; flag (not to move the cursor), but I am only able to get the previous match with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I tried to hack my way around the problem by setting the cursor position to the top of the file, then using &lt;code&gt;search()&lt;/code&gt; to get the first line including the pattern, then restoring the cursor position. It seems to get the next search despite moving the cursor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's what it looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! HLCurrent() abort&#xA;    if exists(&quot;currmatch&quot;)&#xA;        call matchdelete(currmatch)&#xA;    endif&#xA;&#xA;    let patt = '\c\%#'.@/                                  &quot;set pattern&#xA;    let currline = line('.')                               &quot;save current line&#xA;    let currcol = col('.')                                 &quot;save current column&#xA;    call cursor(1, 1)                                      &quot;move to top of file&#xA;    let firstmatchline = search(patt)                      &quot;get first line with pattern&#xA;    call cursor(currline, currcol)                         &quot;restore cursor&#xA;&#xA;&#xA;    if firstmatchline == getline('.')                      &quot;always true&#xA;        let currmatch = matchadd('Todo', match, 101)&#xA;    else                                                   &quot;never in else&#xA;        let currmatch = matchadd('IncSearch', match, 101)&#xA;    endif&#xA;    redraw&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; n n:call HLCurrent()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; N N:call HLCurrent()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;TL;DR&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;So the question is, how can I get the line of the first occurrence of a pattern properly?&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2020-05-01T20:45:57.517" LastActivityDate="2020-05-01T21:09:55.447" Title="get line of first occurence of pattern in buffer" Tags="|search|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="25033" PostTypeId="2" ParentId="25032" CreationDate="2020-05-01T21:09:55.447" Score="2" Body="&lt;p&gt;From my point of view, the easiest way to know if your cursor is at the first occurrence of the word is to search backwards with the &lt;code&gt;W&lt;/code&gt; flag:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;  {flags} is a String, which can contain these character flags:&#xA;&#xA;                      [...]&#xA;&#xA;  'W'     don't Wrap around the end of the file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If there is no match found, then it's the 1st one:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function! HLCurrent() abort&#xA;    if exists(&amp;quot;currmatch&amp;quot;)&#xA;        call matchdelete(currmatch)&#xA;    endif&#xA;&#xA;    let prevOccurence = search(@/, 'bWn')&#xA;&#xA;    if prevOccurence == 0&#xA;        &amp;quot; First occurence&#xA;        let currmatch = matchadd('Todo', match, 101)&#xA;    else&#xA;        &amp;quot; Not first occurence&#xA;        let currmatch = matchadd('IncSearch', match, 101)&#xA;    endif&#xA;&#xA;    redraw&#xA;endfunction&#xA;nnoremap &amp;lt;silent&amp;gt; n n:call HLCurrent()&amp;lt;cr&amp;gt;&#xA;nnoremap &amp;lt;silent&amp;gt; N N:call HLCurrent()&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27331" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-05-01T21:09:55.447" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25034" PostTypeId="2" ParentId="25027" CreationDate="2020-05-01T21:41:19.377" Score="8" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/lambdalisue/suda.vim&quot; rel=&quot;noreferrer&quot;&gt;There’s a plugin for this&lt;/a&gt;. The reason the old &lt;code&gt;:w !sudo tee %&lt;/code&gt; doesn't work with Neovim has to do with the &lt;a href=&quot;https://github.com/neovim/neovim/issues/1496#issuecomment-63695965&quot; rel=&quot;noreferrer&quot;&gt;refactoring following a client-server architecture&lt;/a&gt;, the team is working on a solution though that &lt;a href=&quot;https://github.com/neovim/neovim/issues/1496#issuecomment-555181129&quot; rel=&quot;noreferrer&quot;&gt;hopefully will be shipped with 0.5&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="786" LastActivityDate="2020-05-01T21:41:19.377" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25035" PostTypeId="1" AcceptedAnswerId="25088" CreationDate="2020-05-01T21:59:07.440" Score="0" ViewCount="1096" Body="&lt;p&gt;To my &lt;code&gt;.vimrc&lt;/code&gt; I added a hook which automates entering the quickfix after &lt;code&gt;:grep&lt;/code&gt; processing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd QuickFixCmdPost [^l]* nested cwindow 20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another thing I care about but can't achieve is automation of applying highlight/color of all found occurrences while being in the quickfix. What I observed, it's really easy to do manually:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/pattern&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by re-typing the same pattern which went to the &lt;code&gt;:grep&lt;/code&gt; we will get all occurrences highlighted in all of the files referenced by the quickfix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to program it so that vim will know the &lt;code&gt;grep&lt;/code&gt;'s matches (or at least the pattern passed) and automatically perform the &lt;code&gt;/pattern&lt;/code&gt; search command after &lt;code&gt;:cwindow&lt;/code&gt; is executed - or perform any other method to apply that highlight?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming we can deliver a custom command for &lt;code&gt;:grep&lt;/code&gt; in &lt;code&gt;.vimrc&lt;/code&gt;, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! -nargs=+ G execute &quot;grep -rIn &amp;lt;args&amp;gt; .&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;now the pattern itself is provided by the means of a custom command which might be helpful(?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I admit I'm not a good vim programmer. Can it all be somehow chained together (as another &lt;code&gt;autocmd&lt;/code&gt;/&lt;code&gt;function&lt;/code&gt; and preserving the effect of &lt;code&gt;cwindow&lt;/code&gt; hook) to get that highlight to be applied?&lt;/p&gt;&#xA;" OwnerUserId="27523" LastEditorUserId="27523" LastEditDate="2020-05-02T08:37:06.747" LastActivityDate="2023-06-02T12:13:09.150" Title="Highlight results of :grep while in quickfix window" Tags="|highlight|quickfix|grep|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25036" PostTypeId="2" ParentId="19120" CreationDate="2020-05-01T22:01:40.550" Score="3" Body="&lt;p&gt;Works only in neovim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;highlight CustomError ctermfg=red guifg=red&#xA;sign define error numhl=CustomError&#xA;sign place 2 name=error line=7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Have a look, at &lt;code&gt;:h sign&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://asciinema.org/a/6Qjr11BFHmwYVoQJBTIkL06tC&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://asciinema.org/a/6Qjr11BFHmwYVoQJBTIkL06tC.svg&quot; alt=&quot;asciicast&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12523" LastActivityDate="2020-05-01T22:01:40.550" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25037" PostTypeId="2" ParentId="25035" CreationDate="2020-05-01T22:27:38.317" Score="2" Body="&lt;h2&gt;Option 1 Hack&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A hack... you could get the title of the quickfix window, and then strip off the parts that arent the search term:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    let pattern = getqflist({'title' : 0}).title&#xA;    let pattern = strip_off_not_search_parts(pattern)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then add a match with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    call clearmatches()&#xA;    silent call matchadd('Search', pattern) &quot; Hi group / pattern&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have found it hard to get the search highlighting as if you typed it, you could try &lt;code&gt;feedkeys()&lt;/code&gt; but I had little joy with it.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Option 2 Wrapper&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You are going to want to improve it as time passes by :)&#xA;I recommend &lt;code&gt;vim the hardway&lt;/code&gt;, and &lt;code&gt;:help input&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function! GrepWithHighlight()&#xA;    let searchString = input(&quot;Input search string: &quot;)&#xA;    if searchString == '' || searchString == '\n'&#xA;        echom &quot;Aborted Search.&quot;&#xA;        return&#xA;    endif&#xA;    exe 'vimgrep /'.searchString.'/ **/*'&#xA;    &quot; Open the quickfix window first so match applies to it&#xA;    copen&#xA;    call clearmatches()&#xA;    silent call matchadd('Search', searchString) &quot; Hi group / pattern&#xA;endfunction&#xA;noremap &amp;lt;leader&amp;gt;v :call GrepWithHighlight()&amp;lt;Cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27110" LastEditorUserId="27110" LastEditDate="2020-05-02T09:03:33.960" LastActivityDate="2020-05-02T09:03:33.960" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="25038" PostTypeId="2" ParentId="25027" CreationDate="2020-05-01T23:50:55.223" Score="1" Body="&lt;p&gt;You could try this &lt;code&gt;:W&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;com -bar W exe 'w !sudo tee &amp;gt;/dev/null %:p:S' | setl nomod&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Broken down:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;               ┌ write the buffer on the standard input of a shell command (`:h w_c`)&#xA;&quot;               │ and execute the latter&#xA;&quot;               │&#xA;&quot;               │   ┌ raise the rights of the `tee(1)` process so that it can write in&#xA;&quot;               │   │ a file owned by any user&#xA;&quot;               ├─┐ │&#xA;com -bar W exe 'w !sudo tee &amp;gt;/dev/null %:p:S' | setl nomod&#xA;&quot;                           ├────────┘ │ &#xA;&quot;                           │          └ but write in the current file&#xA;&quot;                           │&#xA;&quot;                           └ don't write in the terminal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may also need to tell &lt;code&gt;sudo(8)&lt;/code&gt; which helper program should be executed to read your password.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;code&gt;man sudo&lt;/code&gt;, there are 2 ways to do it.&#xA;You can either export the environment variable &lt;code&gt;SUDO_ASKPASS&lt;/code&gt;, and assign it the path to the helper program; e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;export SUDO_ASKPASS='/usr/lib/ssh/x11-ssh-askpass'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, the helper program is provided by the Ubuntu package &lt;code&gt;x11-ssh-askpass&lt;/code&gt;; the name of the package, and the location of the file may differ on your OS.  Export the variable from an init file sourced by your shell (e.g. &lt;code&gt;~/.bash_profile&lt;/code&gt;, &lt;code&gt;~/.zshenv&lt;/code&gt;, ...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can edit the &lt;code&gt;sudo.conf(5)&lt;/code&gt; file, and include this directive inside:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Path askpass /usr/lib/ssh/x11-ssh-askpass&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more info about the cause of the issue, see &lt;a href=&quot;https://github.com/neovim/neovim/wiki/FAQ#-and-system-do-weird-things-with-interactive-processes&quot; rel=&quot;nofollow noreferrer&quot;&gt;this entry&lt;/a&gt; in the Neovim FAQ and the links it provides.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2020-05-01T23:50:55.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25039" PostTypeId="1" CreationDate="2020-05-02T00:42:24.420" Score="1" ViewCount="108" Body="&lt;p&gt;I'm trying to add some functionality by adding &lt;code&gt;ftplugin&lt;/code&gt; files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance I want to add &lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;F5&amp;gt; :source %&amp;lt;CR&amp;gt;&lt;/code&gt; to &lt;code&gt;ftplugin/vim.vim&lt;/code&gt;, but when I try it, it looks like vim it's only sourcing the plugin for the first instance of a &lt;code&gt;vim&lt;/code&gt; filetype.&#xA;eg.&#xA;Opening &lt;code&gt;init.vim&lt;/code&gt; works perfectly but then I open (in the same instance of &lt;code&gt;nvim&lt;/code&gt;), &lt;code&gt;ftplugin/python.vim&lt;/code&gt; and this file shows with no filetype no syntax highlighting, and no mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be going on in this case?&lt;/p&gt;&#xA;" OwnerUserId="19307" LastActivityDate="2020-05-02T00:42:24.420" Title="Extending filetype functionality?" Tags="|filetype|" AnswerCount="0" CommentCount="3" ClosedDate="2020-05-06T17:24:43.567" ContentLicense="CC BY-SA 4.0" />
  <row Id="25040" PostTypeId="2" ParentId="25030" CreationDate="2020-05-02T05:46:50.920" Score="6" Body="&lt;p&gt;Which inotify events are fired depends on how Vim writes the file. This is&#xA;controlled by multiple options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a typical setup it works like this. Assume Vim wants to write the file &lt;code&gt;e.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Vim moves the file &lt;code&gt;e.txt&lt;/code&gt; to &lt;code&gt;e.txt~&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Vim creates a new file &lt;code&gt;e.txt&lt;/code&gt; and writes its content&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In this case the event &lt;code&gt;MOVE_SELF&lt;/code&gt; would be fired. As tools like &lt;code&gt;inotifywait&lt;/code&gt;&#xA;(with &lt;code&gt;-m&lt;/code&gt; for &quot;monitor&quot;) monitor the file by inode, so it would now in fact&#xA;monitor the backup file &lt;code&gt;e.txt~&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If Vim writes the same file again, the sequence is like this (note: the backup file already exists):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Vim deletes the backup file &lt;code&gt;e.txt~&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Vim moves the file &lt;code&gt;e.txt&lt;/code&gt; to &lt;code&gt;e.txt~&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Vim creates a new file &lt;code&gt;e.txt&lt;/code&gt; and writes its content&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So a monitoring &lt;code&gt;inotifywait&lt;/code&gt; will receive a &lt;code&gt;DELETE_SELF&lt;/code&gt; because the backup&#xA;file is deleted. Now it listens to changes to an unused inode and will not&#xA;print anything anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the file &lt;code&gt;e.txt&lt;/code&gt; is in fact a symbolic link to the file &lt;code&gt;tgt.txt&lt;/code&gt;, Vim acts different:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Vim copies the content of &lt;code&gt;tgt.txt&lt;/code&gt; (the symlinked file) to the backup file &lt;code&gt;e.txt~&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Vim writes the content to &lt;code&gt;tgt.txt&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In this case a monitoring &lt;code&gt;inotifywait&lt;/code&gt; will see the &lt;code&gt;CLOSE_WRITE&lt;/code&gt; (and other) events.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior how Vim saves the file is controlled by the option &lt;code&gt;backupcopy&lt;/code&gt;.&#xA;In &lt;code&gt;nocompatible&lt;/code&gt; mode it is set to &lt;code&gt;auto&lt;/code&gt;. This means that Vim decides which&#xA;is the best way to save a file. Hence the two different behaviors described above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;backupcopy&lt;/code&gt; is set to &lt;code&gt;yes&lt;/code&gt;, Vim will always create the backup file by copying the original file. In this case &lt;code&gt;inotifywait&lt;/code&gt; is able to monitor the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;backupcopy&lt;/code&gt; is set to &lt;code&gt;no&lt;/code&gt;, Vim will always create the backup file by&#xA;moving the original file. In this case &lt;code&gt;inotifywait&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; able to monitor&#xA;the file. This also has the disadvantage that it will break symbolic links.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;code&gt;:help 'backupcopy'&lt;/code&gt;. This describes the pros and cons of the different values. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So back to &lt;code&gt;inotify&lt;/code&gt;: How to monitor a file saved by Vim?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you want to monitor the file &lt;code&gt;/home/joedoe/e.txt&lt;/code&gt; for &lt;code&gt;CLOSE_WRITE&lt;/code&gt;&#xA;events in a shell script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;file=/home/joedoe/e.txt&#xA;file_dir=&quot;$(dirname &quot;$file&quot;)&quot;&#xA;inotifywait -mqe close_write --format &quot;%w%f&quot; &quot;$file_dir&quot; |&#xA;    while read -r filename; do&#xA;        if [ &quot;$filename&quot; = &quot;$file&quot; ]; then&#xA;            # do what needs to be done&#xA;            ....&#xA;        fi&#xA;    done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you are independent from the strategy Vim uses for saving the file.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2020-05-02T05:46:50.920" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25041" PostTypeId="1" AcceptedAnswerId="25044" CreationDate="2020-05-02T07:26:58.473" Score="5" ViewCount="1153" Body="&lt;p&gt;From the help: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                             i_CTRL-X_CTRL-I&#xA;CTRL-X CTRL-I           Search for the first keyword in the current and&#xA;                        included files&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://github.com/tpope/vim-apathy&quot; rel=&quot;noreferrer&quot;&gt;Tim Pope's Gitub&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[i: display the first line in the current file or an included file containing the keyword under the cursor.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'm struggling to find a definition, or examples, of what includes files are.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, where is the vim reference for included files?  I'd like to be able to list them, add to them, that sort of thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;think&lt;/em&gt; that vim scans a file for lines that match the 'include' search pattern, put them through the 'includexpr' conversion and stores those files someone, to be used in other commands, but I can't even find a list of commands that aren't the ones listed above...&lt;/p&gt;&#xA;" OwnerUserId="8792" LastActivityDate="2020-05-04T21:27:47.263" Title="What is an included file in vim?" Tags="|include|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25042" PostTypeId="1" AcceptedAnswerId="25047" CreationDate="2020-05-02T07:55:23.227" Score="6" ViewCount="1895" Body="&lt;p&gt;The task I have in mind is I have grown files containing multiline definitions. &#xA;Currently I'm working on a file containing acronyms for latex - many entries like this, but most much more complex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\DeclareAcronym{AUC}{&#xA;  short = {AUC},&#xA;  long = {Area Under Curve},&#xA;  extra = {long text with \many{macros} and $math$}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is by joining more definitions the entries get mixed up and harder to deal with.&#xA;I would prefer them sorted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know vim has great functionality sorting lines - I could just join everything into one line, but then I would need to rearrange it afterwards.&#xA;I suppose I could come up with something for the trivial entries but the complex extra blocks (and other non shown) give me a hard time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any functionality organizing such blocks in vim?&lt;/p&gt;&#xA;" OwnerUserId="1120" LastActivityDate="2020-05-02T16:13:36.107" Title="How can I sort multiline blocks in vim?" Tags="|multiple-lines|sort|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25043" PostTypeId="1" AcceptedAnswerId="25050" CreationDate="2020-05-02T08:57:43.157" Score="0" ViewCount="142" Body="&lt;p&gt;I use a completely remapped layout to match the traditional qwerty action position over a bépo layout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lately, using &lt;code&gt;NVIM v0.4.3&lt;/code&gt;, my binding to map the &lt;code&gt;%&lt;/code&gt; to &lt;code&gt;=&lt;/code&gt; (format auto) ceased to work. This is very strange as all other binding seems to work fine, and actually if I run &lt;code&gt;noremap % =&lt;/code&gt; at run time, everything comes back at the expected behaviour. Before manual intervention, a session will act like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:noremap %&#xA;o  %             &amp;lt;Plug&amp;gt;(MatchitOperationForward)                                                                                                                                              &#xA;x  %             &amp;lt;Plug&amp;gt;(MatchitVisualForward)                                                                                                                                                 &#xA;n  %             &amp;lt;Plug&amp;gt;(MatchitNormalForward)                                                                                                                                                 &#xA;s  %           * =                                                                                                                                                                            &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More information about my configuration&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat ~/.config/nvim/init.vim &#xA;source ~/.config/vim/general&#xA;&#xA;cat ~/.config/vim/general &#xA;source ~/.config/vim/mapleader&#xA;source ~/.config/vim/paths&#xA;source ~/.config/vim/browse&#xA;source ~/.config/vim/indent-policy&#xA;source ~/.config/vim/rendering&#xA;source ~/.config/vim/save-policy&#xA;source ~/.config/vim/buffers&#xA;source ~/.config/vim/filetype&#xA;source ~/.config/vim/bépo&#xA;&#xA;tail ~/.config/vim/bépo&#xA;noremap 4 $&#xA;noremap 5 %&#xA;noremap 6 ^&#xA;noremap 7 &amp;amp;&#xA;noremap 8 *&#xA;noremap 9 (&#xA;noremap 0 )&#xA;noremap ° _&#xA;noremap ` +&#xA;noremap % =&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, as far as my custom configuration &lt;code&gt;noremap % =&lt;/code&gt; is the last instruction and shouldn't be overwritten by something else as I don't have any &lt;code&gt;after/ftplugin&lt;/code&gt; in my personal vim directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="11597" LastActivityDate="2020-05-02T16:00:46.527" Title="Why is my 'noremap % =' not taken into account?" Tags="|vimrc|key-bindings|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="25044" PostTypeId="2" ParentId="25041" CreationDate="2020-05-02T09:16:32.317" Score="7" Body="&lt;p&gt;First I did a &lt;code&gt;:helpgrep included files&lt;/code&gt;, then went through the most promising matches until I found:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;:help included-search&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;6. Include file searches        *include-search* *definition-search*&#xA;                            *E387* *E388* *E389*&#xA;&#xA;These commands look for a string in the current file and in all encountered&#xA;included files (recursively).  This can be used to find the definition of a&#xA;variable, function or macro.  If you only want to search in the current&#xA;buffer, use the commands listed at |pattern-searches|.&#xA;&#xA;These commands are not available when the |+find_in_path| feature was disabled&#xA;at compile time.&#xA;&#xA;When a line is encountered that includes another file, that file is searched&#xA;before continuing in the current buffer.  Files included by included files are&#xA;also searched.  When an include file could not be found it is silently&#xA;ignored.  Use the |:checkpath| command to discover which files could not be&#xA;found, possibly your 'path' option is not set up correctly.  Note: the&#xA;included file is searched, not a buffer that may be editing that file.  Only&#xA;for the current file the lines in the buffer are used.&#xA;&#xA;The string can be any keyword or a defined macro.  For the keyword any match&#xA;will be found.  For defined macros only lines that match with the 'define'&#xA;option will be found.  The default is &quot;^#\s*define&quot;, which is for C programs.&#xA;For other languages you probably want to change this.  See 'define' for an&#xA;example for C++.  The string cannot contain an end-of-line, only matches&#xA;within a line are found.&#xA;&#xA;When a match is found for a defined macro, the displaying of lines continues&#xA;with the next line when a line ends in a backslash.&#xA;&#xA;The commands that start with &quot;[&quot; start searching from the start of the current&#xA;file.  The commands that start with &quot;]&quot; start at the current cursor position.&#xA;&#xA;The 'include' option is used to define a line that includes another file.  The&#xA;default is &quot;\^#\s*include&quot;, which is for C programs.  Note: Vim does not&#xA;recognize C syntax, if the 'include' option matches a line inside&#xA;&quot;#ifdef/#endif&quot; or inside a comment, it is searched anyway.  The 'isfname'&#xA;option is used to recognize the file name that comes after the matched&#xA;pattern.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Seems to be related to c file include styles, but can be customised.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Extra side note:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;When looking up a term in the help, one has auto completion (like command line completion). Try add this to you &lt;code&gt;init.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set wildmenu&#xA;set wildmode=longest,list:full&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then type: &lt;code&gt;:h cmdline-c&lt;/code&gt; then type &lt;code&gt;&amp;lt;TAB&amp;gt;&lt;/code&gt; or &lt;code&gt;CTRL-d&lt;/code&gt; to select &lt;code&gt;cmdline-completion&lt;/code&gt;. Note: &lt;code&gt;:h&lt;/code&gt; is short for &lt;code&gt;:help&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="27110" LastEditorUserId="27110" LastEditDate="2020-05-04T21:27:47.263" LastActivityDate="2020-05-04T21:27:47.263" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25045" PostTypeId="2" ParentId="25042" CreationDate="2020-05-02T10:33:44.360" Score="4" Body="&lt;p&gt;There is no direct functionality for that. (At least non I know of.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Assuming&lt;/strong&gt; that none of the field &lt;code&gt;short&lt;/code&gt;, &lt;code&gt;long&lt;/code&gt; and &lt;code&gt;extra&lt;/code&gt; contains any line-breaks:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First join the lines into a single line. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g/^\\DeclareAcronym/,/}}$/join&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This selects the lines from &lt;code&gt;\Declare&lt;/code&gt; to a line that ends with &lt;code&gt;}}&lt;/code&gt; and joins those line into a single line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And finally break the lines again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%s/\([{,]\) \(short\|long\|extra\)/\1\r  \2/g&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This inserts the line breaks and two space indent before &lt;code&gt;short&lt;/code&gt;, &lt;code&gt;long&lt;/code&gt; and &lt;code&gt;extra&lt;/code&gt;.&#xA;If any of the fields contains a line-break this last step would not recreate the original formatting.&lt;/p&gt;&#xA;" OwnerUserId="19763" LastActivityDate="2020-05-02T10:33:44.360" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25046" PostTypeId="1" AcceptedAnswerId="25053" CreationDate="2020-05-02T12:23:00.073" Score="2" ViewCount="1480" Body="&lt;p&gt;I am currently trying to write myself a function the will let me show or hide (toggle) the &lt;code&gt;:terminal&lt;/code&gt; window. The only way to hide it, as far as I currently know, is to just navigate to that window and close it with &lt;code&gt;ZQ&lt;/code&gt;, &lt;code&gt;:q&lt;/code&gt; or whatever. I have a problem though:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have the buffer number &lt;code&gt;N&lt;/code&gt; opened in some split, but I don't know how to navigate to the window that has the buffer &lt;code&gt;N&lt;/code&gt; opened. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I thought &lt;code&gt;switchbuf&lt;/code&gt; might help, but I found out that it works only for &lt;code&gt;quickfix&lt;/code&gt; commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aMg8h.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aMg8h.png&quot; alt=&quot;Example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the picture above I have the cursor in buffer number 1. Which command lets me move to the terminal at the bottom (buffer number 15 in my case) instead of opening the terminal in buffer 1 or creating it in new split? The buffer numbers are of course arbitrary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="23424" LastActivityDate="2020-05-03T11:54:29.453" Title="Move to window if specified buffer is opened" Tags="|buffers|vim-windows|hidden-buffers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25047" PostTypeId="2" ParentId="25042" CreationDate="2020-05-02T12:57:11.787" Score="8" Body="&lt;p&gt;Peter Rincker's SortGroup is the go-to script for this kind of work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://gist.github.com/PeterRincker/582ea9be24a69e6dd8e237eb877b8978&quot; rel=&quot;noreferrer&quot;&gt;https://gist.github.com/PeterRincker/582ea9be24a69e6dd8e237eb877b8978&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Somewhat differently to vim's &lt;code&gt;:sort&lt;/code&gt;, it takes a pattern which is supposed to match the text declaring lines as the start of a group.  For example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:SortGroup /^\DeclareAcronym{/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will sort all the DeclareAcronym commands intact, by the text on the line.  If every line starts with DeclareAcronym, this will &quot;do the right thing&quot; and sort by the keys, but if lines might start with different commands, the command name will be used.&lt;/p&gt;&#xA;" OwnerUserId="13728" LastEditorUserId="13728" LastEditDate="2020-05-02T13:06:15.610" LastActivityDate="2020-05-02T13:06:15.610" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25048" PostTypeId="1" AcceptedAnswerId="25049" CreationDate="2020-05-02T14:11:47.263" Score="4" ViewCount="2225" Body="&lt;p&gt;I'm trying to understand how can I use Lua to extend Neovim, following a baby steps approach. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-lua prettyprint-override&quot;&gt;&lt;code&gt;-- ~/.config/nvim/lua/test.lua&#xA;&#xA;local api = vim.api&#xA;local firstmodule = {}&#xA;&#xA;function firstmodule.hello_world()&#xA;  api.nvim_command('echo &quot;hello world&quot;')&#xA;end&#xA;&#xA;return firstmodule&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in my &lt;strong&gt;init.vim&lt;/strong&gt; I import the module to a command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;command! Greet lua require 'test'.hello_world()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I get a command &lt;code&gt;:Greet&lt;/code&gt; that prints &lt;strong&gt;hello world&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So far so good, but how can I get/use a string returned by a &lt;strong&gt;lua function&lt;/strong&gt;, let's say:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-lua prettyprint-override&quot;&gt;&lt;code&gt;function firstmodule.hello_string()&#xA;  return 'hello world'&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I try to call this function in my &lt;code&gt;init.vim&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Myvar = v:lua.test.hello_string()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I source the file, I get the errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;E121: Undefined variable: v:lua&#xA;E15: Invalid expression: v:lua.test.hello_string()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I use that string returned by a lua function, let's say in my statusline?&lt;/p&gt;&#xA;" OwnerUserId="29151" LastEditorUserId="51" LastEditDate="2021-01-27T22:01:11.333" LastActivityDate="2021-01-27T22:01:11.333" Title="Neovim Lua integration" Tags="|neovim|plugin-system|vimscript-lua|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="25049" PostTypeId="2" ParentId="25048" CreationDate="2020-05-02T14:38:08.363" Score="1" Body="&lt;p&gt;The &lt;code&gt;v:lua&lt;/code&gt; interface was only introduced to NeoVim in &lt;a href=&quot;https://github.com/neovim/neovim/pull/11338&quot; rel=&quot;nofollow noreferrer&quot;&gt;PR #11338&lt;/a&gt;, which has a milestone of 0.5, so it looks like it's not generally available in released versions of NeoVim just yet. (NeoVim 0.5 is still in Beta as of early May 2020.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should use the &lt;a href=&quot;https://vimhelp.org/if_lua.txt.html#lua-luaeval&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;luaeval()&lt;/code&gt;&lt;/a&gt; Vimscript function to evaluate a Lua expression (such as a function call) and use the returned value back in Vimscript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, it seems to me this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let g:Myvar = luaeval('require(&quot;test&quot;).hello_string()')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Inside &lt;code&gt;'statusline'&lt;/code&gt;, you can use &lt;code&gt;%{...}&lt;/code&gt; to evaluate a Vim expression, which could be a global variable such as &lt;code&gt;g:Myvar&lt;/code&gt; or even a &lt;code&gt;luaeval(...)&lt;/code&gt; function call. Just keep in mind that &lt;code&gt;'statusline'&lt;/code&gt; is evaluated quite often, so the overhead of using a Lua function call from there might become quite noticeable and produce lag while editing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A solution that uses some caching should be used to avoid that, either a Vim global variable updated from an autocmd (such as CursorHold, CursorMoved, CursorMovedI, SafeState, etc.) or a Vim function that evaluates whether conditions changed and require a new call to the Lua code or not.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="18609" LastEditDate="2020-05-02T18:10:44.960" LastActivityDate="2020-05-02T18:10:44.960" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="25050" PostTypeId="2" ParentId="25043" CreationDate="2020-05-02T16:00:46.527" Score="2" Body="&lt;p&gt;Unlike Vim, Neovim by default loads &lt;code&gt;:h matchit&lt;/code&gt; plugin. As plugins are normally loaded after vimrc, your mapping gets redefined inside matchit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't use matchit anyway, you can forbid it to load by adding &lt;code&gt;let g:loaded_matchit = 1&lt;/code&gt; to your vimrc.&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-05-02T16:00:46.527" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="25051" PostTypeId="2" ParentId="25042" CreationDate="2020-05-02T16:07:06.490" Score="4" Body="&lt;p&gt;The standard trick for doing this is to convert your blocks into single lines not by &lt;em&gt;removing&lt;/em&gt; the linebreaks, but instead by &lt;em&gt;replacing&lt;/em&gt; them with something you can find again easily after the sort.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Replace all linebreaks that don't follow a &lt;code&gt;}&lt;/code&gt; with &lt;code&gt;LINEBREAK&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/}\@&amp;lt;!\n/LINEBREAK&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sort:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:sort&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Split the blocks into multiple lines again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:%s/LINEBREAK/\r/g&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You might need to tweak your regular expression in step 1., depending on the content of your more complicated blocks, but you’ve implied that joining the lines is feasible in your question, so I presume you’re comfortable doing this already. (But if not, I’d be happy to help if you add a few more examples.)&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-05-02T16:13:36.107" LastActivityDate="2020-05-02T16:13:36.107" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25052" PostTypeId="2" ParentId="25046" CreationDate="2020-05-02T18:35:18.323" Score="5" Body="&lt;h1&gt;With vim only&lt;/h1&gt;&#xA;&lt;p&gt;There's a few options to make navigation between files less tedious in vanilla vim.&lt;/p&gt;&#xA;&lt;p&gt;First, you need &lt;code&gt;set switchbuf=useopen&lt;/code&gt; in your vimrc (&lt;code&gt;:h 'switchbuf'&lt;/code&gt;) to reuse a split (if it exists, else it will create it), instead of opening the buffer in the current split.&lt;/p&gt;&#xA;&lt;p&gt;If you have the buffer number in &lt;code&gt;'statusline'&lt;/code&gt; (i.e &lt;code&gt;%n&lt;/code&gt;), you can then easily switch to a split by number with &lt;code&gt;:sbuffer buffnumber&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This will also work if you give a unique pattern from the name. If you are in the split 'foo' and have two more splits 'bar' and 'baz', &lt;code&gt;:sbuffer az&lt;/code&gt; will switch to the 'baz' split.&lt;/p&gt;&#xA;&lt;p&gt;You can have a mapping to make it easier: &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :sbuffer &lt;/code&gt; (there's a space at the end).&lt;/p&gt;&#xA;&lt;p&gt;Also, those mappings help switch to different splits (&lt;code&gt;:h windows&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;t&lt;/code&gt; -&amp;gt; top left split&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;b&lt;/code&gt; -&amp;gt; bottom right split&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-w&amp;gt;p&lt;/code&gt; -&amp;gt; last used split&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;More in &lt;code&gt;:h windows&lt;/code&gt;&lt;/p&gt;&#xA;&lt;h1&gt;With FZF&lt;/h1&gt;&#xA;&lt;p&gt;Besides, you could use the &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf.vim&lt;/a&gt; plugin (requires &lt;a href=&quot;https://github.com/junegunn/fzf/wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;fzf&lt;/a&gt;) and its &lt;code&gt;:Buffers&lt;/code&gt; command.&lt;/p&gt;&#xA;&lt;p&gt;Similarly to &lt;code&gt;switchbuf=useopen&lt;/code&gt;, you'll want &lt;code&gt;let g:fzf_buffers_jump = 1&lt;/code&gt; in your vimrc to reuse an open split.&lt;/p&gt;&#xA;&lt;p&gt;The command will show a list of buffers which you can strip down with fuzzy search, and navigate with &lt;code&gt;&amp;lt;c-j&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;c-k&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;Enter&amp;gt;&lt;/code&gt; will then switch to the split if already open, or else use the current one. &lt;code&gt;&amp;lt;c-v&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;c-x&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;c-t&amp;gt;&lt;/code&gt; will open the buffer in a new vertical split, horizontal split or tab.&lt;/p&gt;&#xA;&lt;p&gt;You could have a mapping to launch &lt;code&gt;:Buffers&lt;/code&gt; like &lt;code&gt;nnoremap &amp;lt;leader&amp;gt;b :Buffers&amp;lt;cr&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-05-03T11:54:29.453" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="25053" PostTypeId="2" ParentId="25046" CreationDate="2020-05-02T23:43:16.130" Score="3" Body="&lt;p&gt;Use &lt;a href=&quot;https://vimhelp.org/windows.txt.html#%3Awincmd&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :wincmd&lt;/a&gt; to manipulate window in script, it follow the same rule as &lt;a href=&quot;https://vimhelp.org/index.txt.html#CTRL-W&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h CTRL-W&lt;/a&gt; .&#xA;e.g. If you want to jump to window 3, you can do it by &lt;code&gt;3&amp;lt;c-w&amp;gt;&amp;lt;c-w&amp;gt;&lt;/code&gt; in normal mode, or &lt;code&gt;:3wincmd w&lt;/code&gt; in script.&lt;/p&gt;&#xA;&lt;p&gt;Use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#bufwinnr%28%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h bufwinnr()&lt;/a&gt; to get window number for a specific buffer.&lt;/p&gt;&#xA;&lt;p&gt;Use &lt;a href=&quot;https://vimhelp.org/eval.txt.html#%3Aexecute&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h :execute&lt;/a&gt; to combine them together:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:execute bufwinnr(bufnr) 'wincmd w'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Use &lt;a href=&quot;https://vimhelp.org/usr_41.txt.html#window-functions&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h window-functions&lt;/a&gt; to find window related functions, use &lt;a href=&quot;https://vimhelp.org/index.txt.html#CTRL-W&quot; rel=&quot;nofollow noreferrer&quot;&gt;:h CTRL-W&lt;/a&gt; to find window related normal mode command.&lt;/p&gt;&#xA;&lt;p&gt;Another crucial function for a global terminal is to repeat last terminal command, you can see my global terminal&#xA;&lt;a href=&quot;https://github.com/dedowsdi/.vim/blob/master/autoload/ddd/gterm.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;gterm&lt;/a&gt; for an example, it also remembers it's position and size when you toggle it.&lt;/p&gt;&#xA;" OwnerUserId="5017" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-05-02T23:43:16.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25055" PostTypeId="1" AcceptedAnswerId="25056" CreationDate="2020-05-03T00:59:19.363" Score="2" ViewCount="525" Body="&lt;p&gt;When I do something like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;f&lt;/code&gt; &lt;code&gt;G&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To find the next G on the line, I can press &lt;code&gt;;&lt;/code&gt; to find the next occurrence. However, once I've passed one, is there a way to find the previous occurrence? Likewise with doing capital &lt;code&gt;F&lt;/code&gt; &lt;code&gt;G&lt;/code&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2021-08-13T17:59:28.880" Title="Reverse of `;` in find command" Tags="|vimrc|search|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="25056" PostTypeId="2" ParentId="25055" CreationDate="2020-05-03T01:06:32.107" Score="7" Body="&lt;p&gt;The opposite of &lt;code&gt;;&lt;/code&gt; is &lt;code&gt;,&lt;/code&gt; to find the previous occurrence.&lt;/p&gt;&#xA;&lt;p&gt;It works with both &lt;code&gt;t&lt;/code&gt; and &lt;code&gt;f&lt;/code&gt; searches.&lt;/p&gt;&#xA;&lt;p&gt;Of course, this will be inverted with &lt;code&gt;T&lt;/code&gt; and &lt;code&gt;F&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Thus, to go backwards, you could chose to only use &lt;code&gt;t&lt;/code&gt; and &lt;code&gt;f&lt;/code&gt; together with &lt;code&gt;,&lt;/code&gt; : this is as many keystrokes as using capital letters and keeps cycling consistent in every case.&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2021-08-13T17:59:28.880" LastActivityDate="2021-08-13T17:59:28.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25057" PostTypeId="2" ParentId="3721" CreationDate="2020-05-03T07:41:49.290" Score="0" Body="&lt;p&gt;I found that there are 3 ways to escape the  key:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;; :execute &quot;normal! mqA;&amp;lt;C-v&amp;gt;&amp;lt;esc&amp;gt;`q&quot;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;; :execute &quot;normal! mqA;\&amp;lt;lt&amp;gt;esc&amp;gt;`q&quot;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nnoremap &amp;lt;silent&amp;gt; &amp;lt;leader&amp;gt;; :execute &quot;normal! mqA;\e`q&quot;&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Similar for the Enter key (&lt;code&gt;&amp;lt;cr&amp;gt;&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;c-v&amp;gt;&amp;lt;cr&amp;gt;&lt;/code&gt; or &lt;code&gt;\&amp;lt;lt&amp;gt;cr&amp;gt;&lt;/code&gt; or &lt;code&gt;\r&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="29345" LastActivityDate="2020-05-03T07:41:49.290" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25058" PostTypeId="2" ParentId="20856" CreationDate="2020-05-03T10:57:50.787" Score="1" Body="&lt;p&gt;I have exactly the same problem.&#xA;It seems that SpaceVim overrides the &lt;code&gt;gf&lt;/code&gt; command in some way so that &lt;code&gt;rails-vim&lt;/code&gt; plugin's &lt;code&gt;gf&lt;/code&gt; doesn't check for &lt;code&gt;_&lt;/code&gt; on partial names anymore.&#xA;Also, you have to be on the partial name itself (instead of anywhere on the same line, thanks to &lt;code&gt;vim-ruby&lt;/code&gt; plugin) for &lt;code&gt;gf&lt;/code&gt; to work. So maybe it messes with &lt;code&gt;vim-ruby&lt;/code&gt; too.&lt;/p&gt;&#xA;" OwnerUserId="29347" LastEditorUserId="29347" LastEditDate="2020-05-03T17:12:53.090" LastActivityDate="2020-05-03T17:12:53.090" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="25059" PostTypeId="1" AcceptedAnswerId="25061" CreationDate="2020-05-03T11:55:03.540" Score="1" ViewCount="822" Body="&lt;p&gt;I'm using &lt;code&gt;NVIM v0.4.3&lt;/code&gt; with &lt;code&gt;set clipboard=unnamed&lt;/code&gt;. I can insert special character like &lt;code&gt;üäö&lt;/code&gt; in vim just fine, but if I copy content containing special characters in vim and try to paste them outside of vim they appear as garbage. Yanking/pasting inside of vim works just fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;inside nvim &quot;über&quot; becomes &quot;√ºber&quot; outside&lt;/li&gt;&#xA;&lt;li&gt;inside nvim &quot;äffchen&quot; become √§ffchen outside&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Further Information:&lt;/strong&gt;&#xA;I'm running neovim in iTerm2 (zsh) on macOS Catalina. &lt;/p&gt;&#xA;" OwnerUserId="27325" LastEditorUserId="27325" LastEditDate="2020-05-03T12:26:24.020" LastActivityDate="2020-05-03T12:50:14.883" Title="Can't copy special characters outside of vim" Tags="|neovim|cut-copy-paste|os-clipboard|encoding|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25060" PostTypeId="1" CreationDate="2020-05-03T12:47:42.983" Score="7" ViewCount="1096" Body="&lt;p&gt;I can easily see the output of a command in a split using vim's terminal&lt;/p&gt;&#xA;&lt;p&gt;For example, I use &lt;code&gt;:vertical terminal make re&lt;/code&gt; a lot.&lt;/p&gt;&#xA;&lt;p&gt;This example is also stated in the help (&lt;code&gt;h :terminal&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Or to run build command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:term make myprogram&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I even wrote a short function to easily launch shell commands in a vertical split:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(&amp;lt;q-args&amp;gt;)&#xA;function! s:RunShellCommand(cmdline) abort&#xA;    exe 'vert terminal '. a:cmdline&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However, if the output is larger than the terminal width, new lines will be inserted. This makes the output inconsistent (it will depend on the current splits layout, window and screen size, and so on).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XIrPU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XIrPU.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this state, it's difficult to make use of vim's magic moves, copy, paste, diff, and so on.&lt;/p&gt;&#xA;&lt;p&gt;Is there any way to get the command output without breaking lines?&lt;/p&gt;&#xA;&lt;p&gt;I tried using &lt;code&gt;set nowrap&lt;/code&gt;, &lt;code&gt;nolinebreak&lt;/code&gt;, &lt;code&gt;tw=0&lt;/code&gt; with no luck.&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="-1" LastEditDate="2020-06-17T09:46:33.667" LastActivityDate="2020-06-22T16:12:08.577" Title="prevent line wrap in terminal buffer" Tags="|terminal-buffer|wrapping|job-control|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="25061" PostTypeId="2" ParentId="25059" CreationDate="2020-05-03T12:50:14.883" Score="4" Body="&lt;p&gt;Make sure your locale contains the full UTF8 specification to a language; i.e. not something like &lt;code&gt;en_US&lt;/code&gt;, but &lt;code&gt;en_US.UTF-8&lt;/code&gt;.  See &lt;a href=&quot;https://github.com/neovim/neovim/issues/11432&quot; rel=&quot;nofollow noreferrer&quot;&gt;this issue&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17449" LastActivityDate="2020-05-03T12:50:14.883" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25063" PostTypeId="2" ParentId="18586" CreationDate="2020-05-03T14:47:48.327" Score="3" Body="&lt;p&gt;One thing you should be aware of: flake8 invokes pycodestyle and pyflakes.  So configuring ale to run flake8 and either of those two will lead to duplicate warnings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/dense-analysis/ale/issues/888&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/dense-analysis/ale/issues/888&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="29352" LastActivityDate="2020-05-03T14:47:48.327" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25065" PostTypeId="1" AcceptedAnswerId="25067" CreationDate="2020-05-03T18:10:44.057" Score="0" ViewCount="887" Body="&lt;p&gt;I have Vim in Ubuntu and also gVim in Windows. The point is that gVim displays hints in the command bar (command-line under the statusline) but Vim does not. I mean hints that appears in bottom right corner while using “multi-character” commands like yanking selected text to clipboard. For example, in visual mode, I have some text selected and press &lt;code&gt;quote&lt;/code&gt;, &lt;code&gt;plus&lt;/code&gt;, and &lt;code&gt;y&lt;/code&gt;. While doing this, I can see the following in the command bar (after &lt;code&gt;plus&lt;/code&gt; but before &lt;code&gt;y&lt;/code&gt;): &lt;a href=&quot;https://i.stack.imgur.com/48MC6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;command-bar&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, it works out of the box in my gVim for Windows only. How can I configure the same behavior for Vim in Ubuntu?&lt;/p&gt;&#xA;" OwnerUserId="29357" LastEditorUserId="1292" LastEditDate="2020-05-20T06:59:25.870" LastActivityDate="2020-05-20T06:59:25.870" Title="Vim: How to enable hints in command bar" Tags="|vimrc|gvim|" AnswerCount="1" CommentCount="0" ClosedDate="2020-05-03T18:34:49.197" ContentLicense="CC BY-SA 4.0" />
  <row Id="25066" PostTypeId="2" ParentId="25025" CreationDate="2020-05-03T18:20:20.697" Score="2" Body="&lt;p&gt;Turned out rg command for some reason behaves a certain way when called from the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Window cmd&lt;/li&gt;&#xA;&lt;li&gt;bash&lt;/li&gt;&#xA;&lt;li&gt;vim :!&lt;/li&gt;&#xA;&lt;li&gt;Ubuntu jobstart()&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Differently to when called from&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Windows jobstart()&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The solution is simply to define what to search: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;let cmd = ['rg', '--vimgrep', 'endfunction', './']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-05-03T18:20:20.697" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25067" PostTypeId="2" ParentId="25065" CreationDate="2020-05-03T18:26:36.660" Score="0" Body="&lt;p&gt;Add &lt;code&gt;set showcmd&lt;/code&gt; to your config.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;:help showcmd&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'showcmd' 'sc'      boolean (Vim default: on, Vi default: off)&#xA;            global&#xA;    Show (partial) command in the last line of the screen.  Set this&#xA;    option off if your terminal is slow.&#xA;    In Visual mode the size of the selected area is shown:&#xA;    - When selecting characters within a line, the number of characters.&#xA;      If the number of bytes is different it is also displayed: &quot;2-6&quot;&#xA;      means two characters and six bytes.&#xA;    - When selecting more than one line, the number of lines.&#xA;    - When selecting a block, the size in screen characters:&#xA;      {lines}x{columns}.&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="27110" LastActivityDate="2020-05-03T18:26:36.660" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25068" PostTypeId="1" AcceptedAnswerId="25069" CreationDate="2020-05-03T20:23:52.743" Score="3" ViewCount="293" Body="&lt;p&gt;A common function I do in textmate or any other editor is copy some text and then paste it over some other text, for example: &lt;a href=&quot;https://gyazo.com/fcef05504e83b608b583af085f92ecd2&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gyazo.com/fcef05504e83b608b583af085f92ecd2&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tgcHK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tgcHK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Be03u.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Be03u.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9SP7Z.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9SP7Z.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently to copy a value I do something like &lt;code&gt;yiw&lt;/code&gt;, however if I delete the next work, &lt;code&gt;diw&lt;/code&gt;, it would also yank in that text, which I want to overwrite. What would be the best way to do this process, which I feel like I do all the time?&lt;/p&gt;&#xA;" OwnerUserId="28904" LastActivityDate="2020-05-03T20:51:02.453" Title="How to copy paste one value and overwrite another" Tags="|vimrc|cut-copy-paste|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25069" PostTypeId="2" ParentId="25068" CreationDate="2020-05-03T20:44:35.467" Score="4" Body="&lt;p&gt;The easiest is probably to select the word to be replaced in visual mode instead of deleting it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;viwp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don’t like that, an alternative is to delete without clobbering your yanked text by deleting into the black hole register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;_diwp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another alternative is to delete normally, but then paste from the yank register, which isn’t overwritten by your delete:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diw&quot;0p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://vimhelp.org/change.txt.html#registers&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;:help registers&lt;/code&gt;&lt;/a&gt; for more details on the above.&lt;/p&gt;&#xA;" OwnerUserId="343" LastEditorUserId="343" LastEditDate="2020-05-03T20:51:02.453" LastActivityDate="2020-05-03T20:51:02.453" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25071" PostTypeId="1" CreationDate="2020-05-04T04:05:18.047" Score="0" ViewCount="66" Body="&lt;p&gt;I have the following simple line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;inoremap &amp;lt;silent&amp;gt; &amp;lt;TAB&amp;gt;      &amp;lt;C-o&amp;gt;:set foldmethod=manual&amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, after this command is run and I run set foldmethod?, it reports the foldmethod is still set to syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be sure this map is getting triggered, I added&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;C-o&amp;gt;:set fdm=manual &amp;lt;bar&amp;gt; :let blah = 222&amp;lt;cr&amp;gt;&lt;/code&gt; to the map and &lt;code&gt;echo blah&lt;/code&gt; reports 222 as expected.&lt;/p&gt;&#xA;" OwnerUserId="2021" LastActivityDate="2020-05-04T04:05:18.047" Title="Unable to change foldmethod" Tags="|folding|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="25072" PostTypeId="2" ParentId="25060" CreationDate="2020-05-04T04:48:41.480" Score="1" Body="&lt;p&gt;I came up with a solution using &lt;a href=&quot;https://vimhelp.org/channel.txt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;channels&lt;/a&gt;, an idea based on Bram's presentation in &lt;a href=&quot;https://youtu.be/ayc_qpB-93o?t=3137&quot; rel=&quot;nofollow noreferrer&quot;&gt;this video&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;command! -complete=shellcmd -nargs=+ Shell call s:TmpShellOutput(&amp;lt;q-args&amp;gt;)&#xA;function! s:TmpShellOutput(cmdline) abort&#xA;    if bufexists('tmplog')&#xA;        &amp;quot; clear buffer content&#xA;        call deletebufline('tmplog', 1, '$')&#xA;    else&#xA;        &amp;quot; create new buffer that will not be listed&#xA;        call bufadd('tmplog')&#xA;        call setbufvar('tmplog', &amp;quot;buftype&amp;quot;, &amp;quot;nofile&amp;quot;)&#xA;        call setbufvar('tmplog', &amp;quot;filetype&amp;quot;, &amp;quot;nofile&amp;quot;)&#xA;    endif&#xA;    &amp;quot; start a job with bash on the argument&#xA;    let logjob = job_start([&amp;quot;/bin/bash&amp;quot;, &amp;quot;-c&amp;quot;, a:cmdline],&#xA;                \ {'out_io': 'buffer', 'out_name': 'tmplog', 'out_msg': ''})&#xA;    &amp;quot; show the buffer as a panel on the far right-hand side, unwrapped&#xA;    vert sbuffer tmplog&#xA;    wincmd L&#xA;    30 wincmd |&#xA;endfunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Use the command like in this example :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;:Shell make re&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This function will use a buffer &lt;code&gt;tmplog&lt;/code&gt; to output the result of a job. The buffer is cleared at each call, allowing successive uses without pilling up the buffer list.&lt;/p&gt;&#xA;&lt;p&gt;Several caveats:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ansi escape codes are printed as is, breaking colors and cluttering the output&lt;/li&gt;&#xA;&lt;li&gt;Very long commands can struggle sometimes. I don't know exactly in which circumstance, but computing power seems to be a factor&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;c-c&amp;gt;&lt;/code&gt; does not stop the job... &lt;code&gt;:bw&lt;/code&gt; does when it does not hang vim&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I could theoretically add a local mapping from the function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nnoremap &amp;lt;buffer&amp;gt; &amp;lt;c-c&amp;gt; :call job_stop('logjob')&amp;lt;cr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But is just hangs Vim. Maybe my laptop was to hot by the time I tested that.&lt;/p&gt;&#xA;" OwnerUserId="22375" LastEditorUserId="22375" LastEditDate="2020-06-22T16:12:08.577" LastActivityDate="2020-06-22T16:12:08.577" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25073" PostTypeId="1" AcceptedAnswerId="25074" CreationDate="2020-05-04T08:12:46.613" Score="1" ViewCount="642" Body="&lt;p&gt;Is there any difference between the behaviour of C-p and k? The seam to be doing the same thing; moving up a line&lt;/p&gt;&#xA;" OwnerUserId="23073" LastEditorUserId="-1" LastEditDate="2023-05-31T18:57:43.270" LastActivityDate="2023-05-31T18:57:43.270" Title="Whats the difference between k and C-p?" Tags="|key-bindings|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25074" PostTypeId="2" ParentId="25073" CreationDate="2020-05-04T08:44:57.363" Score="1" Body="&lt;p&gt;By default &lt;strong&gt;in normal mode&lt;/strong&gt; they do the same thing. But, say, in Insert mode they don't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is pretty normal situation when different keys are bound to the same action. If in doubt, read the help system: &lt;code&gt;:h ctrl-p&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="22797" LastActivityDate="2020-05-04T08:44:57.363" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="25075" PostTypeId="1" CreationDate="2020-05-04T09:00:42.727" Score="0" ViewCount="90" Body="&lt;p&gt;I have four files &lt;code&gt;file1&lt;/code&gt;, &lt;code&gt;file2&lt;/code&gt;, &lt;code&gt;file3&lt;/code&gt;, &amp;amp; &lt;code&gt;file4&lt;/code&gt;. So I want to open them with vim directly from command line and get the following structure:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Tabulation 1: &lt;code&gt;file1&lt;/code&gt; taking whole tab&lt;/li&gt;&#xA;&lt;li&gt;Tabulation 2: &lt;code&gt;file2&lt;/code&gt; and &lt;code&gt;file3&lt;/code&gt; sharing the same tab in split mode&lt;/li&gt;&#xA;&lt;li&gt;Tabulation 3: &lt;code&gt;file3&lt;/code&gt; taking whole tab&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, how to do it directly from the invocation?&#xA;I know I can do from vim, when I open it the following command sequences:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:e file1&#xA;:tabedit file2  | vsp file3&#xA;:tabedit file4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then, I have two question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First question —&lt;/strong&gt;  How can I give this script to vim at the invocation and will it produce the expected behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Second question —&lt;/strong&gt; Is their another building and probably more elegant way to do this file structure without script? I imagine a syntax like this: &lt;code&gt;vim -p file1 [ file2 | file3 ] file4&lt;/code&gt;, where the &lt;code&gt;[]&lt;/code&gt; means al what we do inside it should be appear in one tab, and the symbol &lt;code&gt;|&lt;/code&gt; means the two file should be vertically spited. Is such syntax exist or am I just dreaming about it?&lt;/p&gt;&#xA;" OwnerUserId="29366" LastActivityDate="2020-05-04T13:10:29.553" Title="Open some files in split and some other in tab at the vim invocation" Tags="|split|tabbed-user-interface|multiple-files|invocation|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25076" PostTypeId="1" CreationDate="2020-05-04T09:06:47.727" Score="2" ViewCount="728" Body="&lt;p&gt;I have a Python project in a subfolder within my git repo:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.git&#xA;api/&#xA;  requirements.txt&#xA;  .venv/&#xA;  myproj/&#xA;    __init__.py&#xA;    foo.py&#xA;    bar.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The virtual environment is installed in the &lt;code&gt;api&lt;/code&gt; folder which is a subfolder of my git repo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In an interpreter, I can import from &lt;code&gt;myproj/foo.py&lt;/code&gt; by doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from myproj.foo import baz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in Vim, coc-python reports:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unresolved import myproj.foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the autocompletion list includes the parent directory, &lt;code&gt;api&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;api.myproj.foo&#xA;api.myproj.bar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I do &lt;code&gt;:CocCommand &amp;gt; python.startREPL&lt;/code&gt; I can run the import just fine, without prepending &lt;code&gt;api&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't even think about how to debug this problem!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers?&lt;/p&gt;&#xA;" OwnerUserId="2026" LastEditorUserId="2026" LastEditDate="2020-05-04T09:23:32.260" LastActivityDate="2020-05-04T13:40:53.003" Title="CoC Python reports unresolved import in git subfolder" Tags="|neovim|plugin-coc|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25077" PostTypeId="1" AcceptedAnswerId="25079" CreationDate="2020-05-04T09:15:33.833" Score="6" ViewCount="6015" Body="&lt;p&gt;I often use the &lt;code&gt;Ctrl-w&lt;/code&gt; command in &quot;Insert&quot; mode to delete the word behind the cursor, just like I would do in Bash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Bash, I also have a &lt;code&gt;Meta-d&lt;/code&gt; (&lt;code&gt;Esc-d&lt;/code&gt;) command for deleting the word in front of the cursor. Does Vim have a similar command for &quot;Insert&quot; mode?&lt;/p&gt;&#xA;" OwnerUserId="26505" LastActivityDate="2020-05-09T12:14:42.860" Title="How can I delete forward in &quot;Insert&quot; mode?" Tags="|neovim|insert-mode|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25078" PostTypeId="2" ParentId="25075" CreationDate="2020-05-04T09:18:54.997" Score="1" Body="&lt;p&gt;I have the answer of my first question:&#xA;I have to invoque Vim like this &lt;code&gt;vim -c &quot;:edit file1 | tabedit file2 | vsp file3 | tabedit file4&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, I’m still answering if it doesn’t a more “elegant” way and less verbose to do the same thing?&lt;/p&gt;&#xA;" OwnerUserId="29366" LastActivityDate="2020-05-04T09:18:54.997" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25079" PostTypeId="2" ParentId="25077" CreationDate="2020-05-04T10:16:15.583" Score="7" Body="&lt;p&gt;I've the following mappings for this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noremap  &amp;lt;C-Del&amp;gt;   dw&#xA;inoremap &amp;lt;C-Del&amp;gt;   &amp;lt;space&amp;gt;&amp;lt;esc&amp;gt;ce&#xA;&#xA;noremap  &amp;lt;C-S-Del&amp;gt; dW&#xA;inoremap &amp;lt;C-S-Del&amp;gt; &amp;lt;esc&amp;gt;lcW&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, there are several ways to do it (and handle single letters). and I'm quite certain there has been other Q/A|tips on the topic elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: unlike &lt;code&gt;&amp;lt;c-o&amp;gt;de&lt;/code&gt; that I've seen elsewhere, these mappings handle &lt;code&gt;wor|d word&lt;/code&gt; correctly. &lt;code&gt;&amp;lt;c-o&amp;gt;dw&lt;/code&gt; would work though, the difference is that the space after the current word will also be deleted while my mappings leave it alone.&lt;/p&gt;&#xA;" OwnerUserId="626" LastEditorUserId="626" LastEditDate="2020-05-04T19:46:38.940" LastActivityDate="2020-05-04T19:46:38.940" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25080" PostTypeId="1" CreationDate="2020-05-04T10:38:07.693" Score="2" ViewCount="63" Body="&lt;p&gt;I am using AnsiEsc to look at colorized terminal printout, the printout contains bold face filenames (e.g. from gcc). This typically looks like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^[[01m^[[Kmyfile.cpp:32:21:^[[m^[[K&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;AnsiEsc handles that nicely in the version from &lt;a href=&quot;http://www.drchip.org/astronaut/vim/index.html#ANSIESC&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; (the version from &lt;a href=&quot;https://www.vim.org/scripts/script.php?script_id=302&quot; rel=&quot;nofollow noreferrer&quot;&gt;vim.org&lt;/a&gt; has trouble with colorless bold face and with &lt;code&gt;^[[K&lt;/code&gt;). However, when I want to navigate to a file with &lt;code&gt;gF&lt;/code&gt;, instead of opening &lt;code&gt;myfile.cpp&lt;/code&gt;, vim attempts to open &lt;code&gt;Kmyfile.cpp&lt;/code&gt;. It appears to me that &lt;code&gt;isfname&lt;/code&gt; captures the &lt;code&gt;K&lt;/code&gt; that belongs to the escape sequence &lt;code&gt;^[[K&lt;/code&gt; as part of the filename. Is there a way to exclude escape sequences (it seems like only &lt;code&gt;^[[K&lt;/code&gt; is relevant to me at the moment) from &lt;code&gt;isfname&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I am aware that makeprg and errorformat exist. Please assume I can't use these for whatever reasons—say, the build runs on some CI server and I just get the terminal printout via email)&lt;/p&gt;&#xA;" OwnerUserId="6044" LastEditorUserId="10604" LastEditDate="2020-05-04T13:37:58.587" LastActivityDate="2020-05-04T13:37:58.587" Title="ignore leading ansi escape sequence (^[[K) from isfname" Tags="|cword|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25081" PostTypeId="1" AcceptedAnswerId="25085" CreationDate="2020-05-04T11:33:22.303" Score="1" ViewCount="101" Body="&lt;h2&gt;Information&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;VIM version&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 29 2020 00:47:39)&#xA;macOS version&#xA;Included patches: 1-503, 505-680, 682-2292&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Operating System: Catalina 10.15.4&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What went wrong&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I'm sure this will just be a configuration thing but I've been banging my head against the desk for hours trying to figure this out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Below I first noticed this happening on ALEFix - however I've realised even when I do :grep, &lt;code&gt;asofsdfas&lt;/code&gt; is logged to the console... I'm going to keep digging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone knows a way to see what is being executed by vim that would be useful (ie show commands being run? - q: doesn't reveal anything)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;When I run ALEFix on a python file it automatically inserts junk at the top:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;asofsdfas&#xA;import logging&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For me its always the same junk &lt;code&gt;asofsdfas&lt;/code&gt; but if I keep saving it keeps inserting it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my ftplugin/python.vim&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; Check Python files with flake8 and pylint.&#xA;let b:ale_linters = ['flake8', 'mypy']&#xA;&quot; Fix Python files with autopep8 and yapf.&#xA;let b:ale_fixers = ['autopep8', 'yapf']&#xA;&#xA;&quot; python syntax&#xA;let g:python_highlight_all = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I change to &lt;code&gt;let b:ale_fixers = []&lt;/code&gt; it doesn't occur&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I pip uninstall autopep8 and yapf it doesn't occur&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It still occurs if I have either only &lt;code&gt;let b:ale_fixers = ['autopep8']&lt;/code&gt; or &lt;code&gt;let b:ale_fixers = ['yapf']&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please someone help I'm losing my mind&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Turns out it's also happening on my javascript fixers so isn't specific to this python stuff (but the same behaviour is occurring re: if I change the ale_fixers value)&lt;/p&gt;&#xA;" OwnerUserId="29369" LastEditorUserId="29369" LastEditDate="2020-05-04T14:15:56.707" LastActivityDate="2020-05-06T08:08:41.107" Title="Vim adding junk to scripts" Tags="|vimrc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="25082" PostTypeId="2" ParentId="25075" CreationDate="2020-05-04T13:10:29.553" Score="2" Body="&lt;p&gt;Vim’s &lt;code&gt;-S&lt;/code&gt; option can take any file of vim commands and run them at startup. It’s usually used for sessions (&lt;code&gt;:mksession&lt;/code&gt;; pairs well with tpope’s obsession plugin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, though, you could make the following file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot; mylayout.vim&#xA;edit file1&#xA;tabedit file2&#xA;&quot; &amp;amp;c.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then you can do &lt;code&gt;vim -S mylayout.vim&lt;/code&gt; &lt;/p&gt;&#xA;" OwnerUserId="10604" LastActivityDate="2020-05-04T13:10:29.553" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25083" PostTypeId="2" ParentId="25077" CreationDate="2020-05-04T13:16:55.683" Score="1" Body="&lt;p&gt;An alternative to creating a mapping for this single Readline command, is to install the &lt;a href=&quot;https://github.com/tpope/vim-rsi&quot; rel=&quot;nofollow noreferrer&quot;&gt;rsi.vim plugin&lt;/a&gt;, which emulates &lt;em&gt;all&lt;/em&gt; (or at least, many) of Readline's standard shortcuts in insert and command-line modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Future readers may also be interested in &lt;a href=&quot;https://github.com/ryvnf/readline.vim&quot; rel=&quot;nofollow noreferrer&quot;&gt;readline.vim&lt;/a&gt;, which purports to provide a more faithful set of mappings, but only in command line mode.&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-05-04T13:16:55.683" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25084" PostTypeId="2" ParentId="25076" CreationDate="2020-05-04T13:40:53.003" Score="2" Body="&lt;p&gt;CoC assumes that a directory containing &lt;code&gt;.git/&lt;/code&gt; is the root of your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the &lt;a href=&quot;https://github.com/neoclide/coc.nvim/wiki/Using-workspaceFolders#resolve-workspace-folder&quot; rel=&quot;nofollow noreferrer&quot;&gt;CoC docs&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Unlike VSCode vim doesn't have workspace support. The solution is resolve workspace folders from opened files.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This means that CoC uses a list of filenames which, if present in a particular directory, indicate that it might be the project's root.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the variable is not present, CoC falls back to a config setting called &lt;code&gt;coc.preferences.rootPatterns&lt;/code&gt; which, by default is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&quot;.git&quot;, &quot;.hg&quot;, &quot;.projections.json&quot;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To override this behaviour you can set the list to include the name of your virtual environment. In this case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;autocmd FileType python let b:coc_root_patterns = ['.git', '.venv']&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2026" LastActivityDate="2020-05-04T13:40:53.003" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25085" PostTypeId="2" ParentId="25081" CreationDate="2020-05-04T14:26:51.660" Score="1" Body="&lt;p&gt;My problem here was that I had &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set shellcmdflag=-ic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my vimrc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Removing this solved the issue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm still not entirely sure &lt;em&gt;why&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: &#xA;Oh my lord I've found it and it's colossally stupid. &#xA;Thanks to @filbrandon:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When you pass the shell a -i, it will read and execute your initialization file (such as .bashrc for bash.) If you're producing any output from that initialization file, that might explain it. If you run bash -ic 'echo hello' do you actually see anything other than &quot;hello&quot;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Turns out I had &lt;code&gt;echo asofsdfas&lt;/code&gt; in my &lt;code&gt;.bashrc&lt;/code&gt;.... I'm using a mac so I only was ever checking my .bash_profile. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for taking this journey with me and apologies and thank you.&lt;/p&gt;&#xA;" OwnerUserId="29369" LastEditor